Merge "drivers: soc: llcc_perfmon: Periodic counter dump support"
diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt
index d4a352b..18386ab 100644
--- a/Documentation/devicetree/bindings/arm/coresight.txt
+++ b/Documentation/devicetree/bindings/arm/coresight.txt
@@ -39,6 +39,8 @@
 
 		- System Trace Macrocell:
 			"arm,coresight-stm", "arm,primecell"; [1]
+		- Trigger Generation Unit:
+			 "arm,primecell";
 
 	* reg: physical base address and length of the register
 	  set(s) of the component.
@@ -86,6 +88,16 @@
 
 	* qcom,dummy-sink: Configure the device as sink.
 
+* Additional required property for coresight-tgu devices:
+	* tgu-steps: must be present. Indicates number of steps supported
+	  by the TGU.
+	* tgu-conditions: must be present. Indicates the number of conditions
+	  supported by the TGU.
+	* tgu-regs: must be present. Indicates the number of regs supported
+	  by the TGU.
+	* tgu-timer-counters: must be present. Indicates the number of timers and
+	  counters available in the TGU to do a comparision.
+
 * Optional properties for all components:
 	* reg-names: names corresponding to each reg property value.
 
@@ -388,7 +400,7 @@
 		};
 	};
 
-4. CTIs
+5. CTIs
 	cti0: cti@6010000 {
 		compatible = "arm,coresight-cti", "arm,primecell";
 		reg = <0x6010000 0x1000>;
@@ -400,5 +412,21 @@
 		clock-names = "apb_pclk";
 	};
 
+6. TGUs
+	ipcb_tgu: tgu@6b0c000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b999>;
+		reg = <0x06B0C000 0x1000>;
+		reg-names = "tgu-base";
+		tgu-steps = <3>;
+		tgu-conditions = <4>;
+		tgu-regs = <4>;
+		tgu-timer-counters = <8>;
+
+		coresight-name = "coresight-tgu-ipcb";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
 [1]. There is currently two version of STM: STM32 and STM500.  Both
 have the same HW interface and as such don't need an explicit binding name.
diff --git a/Documentation/devicetree/bindings/arm/msm/imem.txt b/Documentation/devicetree/bindings/arm/msm/imem.txt
index eaa7146b..440628d 100644
--- a/Documentation/devicetree/bindings/arm/msm/imem.txt
+++ b/Documentation/devicetree/bindings/arm/msm/imem.txt
@@ -46,6 +46,12 @@
 -compatible: "qcom,msm-imem-restart_reason
 -reg: start address and size of restart_reason region in imem
 
+Download Mode Type:
+-------------------
+Required properties:
+-compatible: "qcom,msm-imem-dload-type"
+-reg: start address and size of dload type region in imem
+
 Download Mode:
 --------------
 Required properties:
@@ -67,6 +73,11 @@
 Memory region used to store USB PID and serial numbers to be used by
 bootloader in download mode.
 
+SSR Minidump Offset
+-------------------
+-Compatible: "qcom,msm-imem-minidump"
+-reg: start address and size of ssr imem region
+
 Required properties:
 -compatible: "qcom,msm-imem-diag-dload"
 -reg: start address and size of USB Diag download mode region in imem
@@ -115,4 +126,9 @@
 			compatible = "qcom,msm-imem-emergency_download_mode";
 			reg = <0xfe0 12>;
 		};
+
+		ss_mdump@b88 {
+			compatible = "qcom,msm-imem-minidump";
+			reg = <0xb88 28>;
+		};
 	};
diff --git a/Documentation/devicetree/bindings/arm/msm/jtag-mm.txt b/Documentation/devicetree/bindings/arm/msm/jtag-mm.txt
new file mode 100644
index 0000000..8f57d0a
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/msm/jtag-mm.txt
@@ -0,0 +1,32 @@
+* JTAG-MM
+
+The jtag-mm entry specifies the memory mapped addresses for the debug and ETM
+registers. The jtag-mm driver uses these to save and restore the registers
+using memory mapped access during power collapse so as to retain their state
+across power collapse. This is necessary in case cp14 access to the registers
+is not permitted.
+
+Required Properties:
+compatible: component name used for driver matching, should be:
+	"qcom,jtag-mm"		- for jtag-mm device
+	"qcom,jtagv8-mm"	- for jtagv8-mm device supporting ARMv8 targets
+
+	reg: physical base address and length of the register set
+	reg-names: should be "etm-base" for etm register set and "debug-base"
+		   for debug register set.
+	qcom,coresight-jtagmm-cpu: specifies phandle for the cpu associated
+				   with the jtag-mm device
+	qcom,si-enable : boolean, indicating etm save and restore is
+			 supported via system instructions
+	qcom,save-restore-disable : boolean, to disable etm save and restore
+				    functionality
+
+Example:
+jtag_mm: jtagmm@fc332000 {
+	compatible = "qcom,jtag-mm";
+	reg = <0xfc332000 0x1000>,
+		<0xfc333000 0x1000>;
+	reg-names = "etm-base","debug-base";
+
+	qcom,coresight-jtagmm-cpu = <&CPU0>;
+};
diff --git a/Documentation/devicetree/bindings/arm/msm/msm.txt b/Documentation/devicetree/bindings/arm/msm/msm.txt
index 76b6141..765b5e4 100644
--- a/Documentation/devicetree/bindings/arm/msm/msm.txt
+++ b/Documentation/devicetree/bindings/arm/msm/msm.txt
@@ -92,6 +92,12 @@
 - SDM670
   compatible = "qcom,sdm670"
 
+- QCS605
+  compatible = "qcom,qcs605"
+
+- SDA670
+  compatible = "qcom,sda670"
+
 - MSM8952
   compatible = "qcom,msm8952"
 
@@ -270,9 +276,16 @@
 compatible = "qcom,sdm845-mtp"
 compatible = "qcom,sdm845-qrd"
 compatible = "qcom,sdm845-qvr"
+compatible = "qcom,sda845-cdp"
+compatible = "qcom,sda845-mtp"
+compatible = "qcom,sda845-qrd"
 compatible = "qcom,sdm670-rumi"
 compatible = "qcom,sdm670-cdp"
 compatible = "qcom,sdm670-mtp"
+compatible = "qcom,qcs605-cdp"
+compatible = "qcom,qcs605-mtp"
+compatible = "qcom,sda670-cdp"
+compatible = "qcom,sda670-mtp"
 compatible = "qcom,msm8952-rumi"
 compatible = "qcom,msm8952-sim"
 compatible = "qcom,msm8952-qrd"
diff --git a/Documentation/devicetree/bindings/arm/msm/msm_bus.txt b/Documentation/devicetree/bindings/arm/msm/msm_bus.txt
index b3f3431..0d955ed 100644
--- a/Documentation/devicetree/bindings/arm/msm/msm_bus.txt
+++ b/Documentation/devicetree/bindings/arm/msm/msm_bus.txt
@@ -139,6 +139,7 @@
 			the command DB driver.
 qcom,drv-id:		The DRV id associated with the RSC, used to differentiate
 			between RSCS owned by different execution environments.
+qcom,defer-init-qos:	Flag to force defer initial QoS configuration at probe time.
 
 
 Example:
diff --git a/Documentation/devicetree/bindings/clock/qcom,camcc.txt b/Documentation/devicetree/bindings/clock/qcom,camcc.txt
index 313e50f..daf8a539 100644
--- a/Documentation/devicetree/bindings/clock/qcom,camcc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,camcc.txt
@@ -2,7 +2,8 @@
 ----------------------------------------------------
 
 Required properties :
-- compatible : shall contain "qcom,cam_cc-sdm845" or "qcom,cam_cc-sdm845-v2"
+- compatible : shall contain "qcom,cam_cc-sdm845", "qcom,cam_cc-sdm845-v2" or
+	       "qcom,cam_cc-sdm670"
 - reg : shall contain base register location and length
 - reg-names: names of registers listed in the same order as in
 	     the reg property.
diff --git a/Documentation/devicetree/bindings/clock/qcom,dispcc.txt b/Documentation/devicetree/bindings/clock/qcom,dispcc.txt
index 87af0f6..d169c31 100644
--- a/Documentation/devicetree/bindings/clock/qcom,dispcc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,dispcc.txt
@@ -2,7 +2,8 @@
 ----------------------------------------------------
 
 Required properties :
-- compatible : shall contain "qcom,dispcc-sdm845" or "qcom,dispcc-sdm845-v2".
+- compatible : shall contain "qcom,dispcc-sdm845", "qcom,dispcc-sdm845-v2" or
+	       "qcom,dispcc-sdm670".
 - reg : shall contain base register location and length.
 - reg-names: names of registers listed in the same order as in
 	     the reg property.
diff --git a/Documentation/devicetree/bindings/clock/qcom,gcc.txt b/Documentation/devicetree/bindings/clock/qcom,gcc.txt
index c280b92..538fb6d 100644
--- a/Documentation/devicetree/bindings/clock/qcom,gcc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,gcc.txt
@@ -18,6 +18,7 @@
 			"qcom,gcc-mdm9615"
 			"qcom,gcc-sdm845"
 			"qcom,gcc-sdm845-v2"
+			"qcom,gcc-sdm670"
 			"qcom,debugcc-sdm845"
 
 - reg : shall contain base register location and length
diff --git a/Documentation/devicetree/bindings/clock/qcom,gpucc.txt b/Documentation/devicetree/bindings/clock/qcom,gpucc.txt
index 12676b7..aa90bc4 100644
--- a/Documentation/devicetree/bindings/clock/qcom,gpucc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,gpucc.txt
@@ -7,6 +7,8 @@
 		"qcom,gpucc-sdm845-v2",
 		"qcom,gfxcc-sdm845",
 		"qcom,gfxcc-sdm845-v2"
+		"qcom,gpucc-sdm670",
+		"qcom,gfxcc-sdm670"
 
 - reg : shall contain base register offset and size.
 - #clock-cells : shall contain 1.
diff --git a/Documentation/devicetree/bindings/clock/qcom,rpmh.txt b/Documentation/devicetree/bindings/clock/qcom,rpmh.txt
index c81a454..9ad7263 100644
--- a/Documentation/devicetree/bindings/clock/qcom,rpmh.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,rpmh.txt
@@ -2,7 +2,8 @@
 -------------------------------------------------------
 
 Required properties :
-- compatible : must be "qcom,rpmh-clk-sdm845"
+- compatible : shall contain "qcom,rpmh-clk-sdm845" or "qcom,rpmh-clk-sdm670"
+
 - #clock-cells : must contain 1
 - mboxes : list of RPMh mailbox phandle and channel identifier tuples.
 - mbox-names : list of names to identify the RPMh mailboxes used.
diff --git a/Documentation/devicetree/bindings/clock/qcom,videocc.txt b/Documentation/devicetree/bindings/clock/qcom,videocc.txt
index 6bd0f0b..9b53c65 100644
--- a/Documentation/devicetree/bindings/clock/qcom,videocc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,videocc.txt
@@ -2,8 +2,8 @@
 ----------------------------------------------------
 
 Required properties :
-- compatible : shall contain "qcom,video_cc-sdm845" or
-	       "qcom,video_cc-sdm845-v2".
+- compatible : shall contain "qcom,video_cc-sdm845", "qcom,video_cc-sdm845-v2"
+	       or "qcom,video_cc-sdm670".
 - reg : shall contain base register location and length.
 - reg-names: names of registers listed in the same order as in
 	     the reg property.
diff --git a/Documentation/devicetree/bindings/display/msm/sde.txt b/Documentation/devicetree/bindings/display/msm/sde.txt
index dd668cb..2782428 100644
--- a/Documentation/devicetree/bindings/display/msm/sde.txt
+++ b/Documentation/devicetree/bindings/display/msm/sde.txt
@@ -135,6 +135,18 @@
 				power collapse feature available or not.
 - qcom,sde-has-mixer-gc:	Boolean property to indicate if mixer has gamma correction
 				feature available or not.
+- qcom,sde-has-dest-scaler: 	Boolean property to indicate if destination scaler
+				feature is available or not.
+- qcom,sde-max-dest-scaler-input-linewidth: A u32 value indicates the
+				maximum input line width to destination scaler.
+- qcom,sde-max-dest-scaler-output-linewidth: A u32 value indicates the
+				maximum output line width of destination scaler.
+- qcom,sde-dest-scaler-top-off: A u32 value provides the
+				offset from mdp base to destination scaler block.
+- qcom,sde-dest-scaler-top-size: A u32 value indicates the address range for ds top
+- qcom,sde-dest-scaler-off: 	Array of u32 offsets indicate the qseed3 scaler blocks
+				offset from destination scaler top offset.
+- qcom,sde-dest-scaler-size:    A u32 value indicates the address range for each scaler block
 - qcom,sde-sspp-clk-ctrl:	Array of offsets describing clk control
 				offsets for dynamic clock gating. 1st value
 				in the array represents offset of the control
@@ -281,6 +293,18 @@
 				core ib calculation.
 - qcom,sde-core-clk-ff:		A string entry indicating the fudge factor for
 				core clock calculation.
+- qcom,sde-min-core-ib-kbps:	This u32 value indicates the minimum mnoc ib
+				vote in Kbps that can be reduced without hitting underflow.
+				BW calculation logic will choose the IB bandwidth requirement
+				based on usecase if this floor value is not defined.
+- qcom,sde-min-llcc-ib-kbps:	This u32 value indicates the minimum llcc ib
+				vote in Kbps that can be reduced without hitting underflow.
+				BW calculation logic will choose the IB bandwidth requirement
+				based on usecase if this floor value is not defined.
+- qcom,sde-min-dram-ib-kbps:	This u32 value indicates the minimum dram ib
+				vote in Kbps that can be reduced without hitting underflow.
+				BW calculation logic will choose the IB bandwidth requirement
+				based on usecase if this floor value is not defined.
 - qcom,sde-comp-ratio-rt:	A string entry indicating the compression ratio
 				for each supported compressed format on realtime interface.
 				The string is composed of one or more of
@@ -342,6 +366,7 @@
 				control register. Number of offsets defined should
 				match the number of xin-ids defined in
 				property: qcom,sde-inline-rot-xin
+- #power-domain-cells:		Number of cells in a power-domain specifier and should contain 0.
 
 Bus Scaling Subnodes:
 - qcom,sde-reg-bus:		Property to provide Bus scaling for register access for
@@ -422,6 +447,7 @@
     interrupt-controller;
     #interrupt-cells = <1>;
     iommus = <&mdp_smmu 0>;
+    #power-domain-cells = <0>;
 
     qcom,sde-off = <0x1000>;
     qcom,sde-ctl-off = <0x00002000 0x00002200 0x00002400
@@ -432,6 +458,8 @@
     qcom,sde-dspp-off = <0x00055000 0x00057000>;
     qcom,sde-dspp-ad-off = <0x24000 0x22800>;
     qcom,sde-dspp-ad-version = <0x00030000>;
+    qcom,sde-dest-scaler-top-off = <0x00061000>;
+    qcom,sde-dest-scaler-off = <0x800 0x1000>;
     qcom,sde-wb-off = <0x00066000>;
     qcom,sde-wb-xin-id = <6>;
     qcom,sde-intf-off = <0x0006b000 0x0006b800
@@ -493,6 +521,8 @@
     qcom,sde-cdm-size = <0x100>;
     qcom,sde-pp-size = <0x100>;
     qcom,sde-wb-size = <0x100>;
+    qcom,sde-dest-scaler-top-size = <0xc>;
+    qcom,sde-dest-scaler-size = <0x800>;
     qcom,sde-len = <0x100>;
     qcom,sde-wb-linewidth = <2560>;
     qcom,sde-sspp-scale-size = <0x100>;
@@ -502,6 +532,9 @@
     qcom,sde-highest-bank-bit = <15>;
     qcom,sde-has-mixer-gc;
     qcom,sde-has-idle-pc;
+    qcom,sde-has-dest-scaler;
+    qcom,sde-max-dest-scaler-input-linewidth = <2048>;
+    qcom,sde-max-dest-scaler-output-linewidth = <2560>;
     qcom,sde-sspp-max-rects = <1 1 1 1
 				1 1 1 1
 				1 1
@@ -572,6 +605,9 @@
 
     qcom,sde-core-ib-ff = "1.1";
     qcom,sde-core-clk-ff = "1.0";
+    qcom,sde-min-core-ib-kbps = <2400000>;
+    qcom,sde-min-llcc-ib-kbps = <800000>;
+    qcom,sde-min-dram-ib-kbps = <800000>;
     qcom,sde-comp-ratio-rt = "NV12/5/1/1.1 AB24/5/1/1.2 XB24/5/1/1.3";
     qcom,sde-comp-ratio-nrt = "NV12/5/1/1.1 AB24/5/1/1.2 XB24/5/1/1.3";
     qcom,sde-undersized-prefill-lines = <4>;
diff --git a/Documentation/devicetree/bindings/dma/qcom-sps-dma.txt b/Documentation/devicetree/bindings/dma/qcom-sps-dma.txt
new file mode 100644
index 0000000..c6c8726
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/qcom-sps-dma.txt
@@ -0,0 +1,42 @@
+* Qualcomm technologies inc, DMA engine driver for BAM (Bus Access Manager).
+
+Required properties:
+- compatible: Should be "qcom,sps-dma".
+- reg: Should contain DMA registers location and length. This should include
+  all of the per-channel registers.
+- interrupts: Should contain the BAM interrupt number.
+- qcom,summing-threshold:  Should contain the BAM event threshold of
+  the sum of descriptors' sizes in bytes.
+
+Optional properties:
+- qcom,managed-locally : Use when BAM global device control is managed locally
+  by the application processor.
+
+Example:
+
+	dma_blsp1: qcom,sps-dma@f9904000 { /* BLSP1 */
+		#dma-cells = <4>;
+		compatible = "qcom,sps-dma";
+		reg = <0xf9904000 0x19000>;
+		interrupts = <0 238 0>;
+		qcom,summing-threshold = <10>;
+	};
+
+DMA clients connected to the qcom-sps-dma DMA controller must use the format
+described in the dma.txt file, using a five-cell specifier for each channel,
+a phandle plus four integer cells, as shown below:
+
+dmas = <[phandle of the dma controller] [pipe index] [number of descriptors]
+				[sps_connect flags] [sps_register_event flags]>;
+
+Example:
+
+i2c_2: i2c@f9924000 { /* BLSP1 QUP2 */
+	.
+	.
+	.
+	/*     <&phandle pipe-idx n-descs connect-flags event-flags> */
+	dmas = <&dma_blsp1 14 32 0x20000020 0x20>,
+	       <&dma_blsp1 15 64 0x20000020 0x20>;
+	dma-names = "tx", "rx";
+};
diff --git a/Documentation/devicetree/bindings/dma/qcom_gpi.txt b/Documentation/devicetree/bindings/dma/qcom_gpi.txt
index 3b3b713..f1b4a429 100644
--- a/Documentation/devicetree/bindings/dma/qcom_gpi.txt
+++ b/Documentation/devicetree/bindings/dma/qcom_gpi.txt
@@ -12,13 +12,12 @@
 - #dma-cells
   Usage: required
   Value type: <u32>
-  Definition: Number of parameters client will provide.  Must be set to 6.
-	1st parameter: gpii index
-	2nd parameter: channel index
-	3rd parameter: serial engine index
-	4th parameter: bus protocol, 1 for SPI, 2 for UART, 3 for I2C
-	5th parameter: channel ring length in transfer ring elements
-	6th parameter: event processing priority, set to 0 for lowest latency
+  Definition: Number of parameters client will provide.  Must be set to 5.
+	1st parameter: channel index, 0 for TX, 1 for RX
+	2nd parameter: serial engine index
+	3rd parameter: bus protocol, 1 for SPI, 2 for UART, 3 for I2C
+	4th parameter: channel ring length in transfer ring elements
+	5th parameter: event processing priority, set to 0 for lowest latency
 
 - compatible
   Usage: required
@@ -64,11 +63,27 @@
 	for the controller.  For more detail please check binding
 	documentation arm,smmu.txt
 
+- qcom,smmu-cfg
+  Usage: required
+  Value type: <u32>
+  Definition: Determine whether GPI driver require to configure SMMU that
+	sits behind GPI controller.
+	Bit mask:
+	BIT(0) : Attach address mapping to endpoint device
+	BIT(1) : Set SMMU attribute S1_BYPASS
+	BIT(2) : Set SMMU attribute FAST
+	BIT(3) : Set SMMU attribute ATOMIC
+
+- qcom,iova-range
+  Usage: required if SMMU S1 translation is enabled
+  Value type: Array of <u64>
+  Definition: Pair of values describing iova base and size to allocate.
+
 ========
 Example:
 ========
 gpi_dma0: qcom,gpi-dma@0x800000 {
-	#dma-cells = <6>;
+	#dma-cells = <5>;
 	compatible = "qcom,gpi-dma";
 	reg = <0x800000 0x60000>;
 	reg-names = "gpi-top";
@@ -80,5 +95,7 @@
 	qcom,gpii-mask = <0xfa>;
 	qcom,ev-factor = <2>;
 	iommus = <&apps_smmu 0x0016 0x0>;
+	qcom,smmu-cfg = <0x1>
+	qcom,iova-range = <0x0 0x100000 0x0 0x100000>;
 	status = "ok";
 };
diff --git a/Documentation/devicetree/bindings/drm/msm/sde-dp.txt b/Documentation/devicetree/bindings/drm/msm/sde-dp.txt
index e46fd5c..ada2eab 100644
--- a/Documentation/devicetree/bindings/drm/msm/sde-dp.txt
+++ b/Documentation/devicetree/bindings/drm/msm/sde-dp.txt
@@ -10,6 +10,7 @@
 			"dp_mmss_cc" - Display Clock Control memory region.
 			"qfprom_physical" - QFPROM Phys memory region.
 			"dp_pll" - USB3 DP combo PLL memory region.
+			"usb3_dp_com" - USB3 DP PHY combo memory region.
 			"hdcp_physical" - DP HDCP memory region.
 - cell-index:           Specifies the controller instance.
 - clocks:               Clocks required for Display Port operation.
diff --git a/Documentation/devicetree/bindings/gpu/adreno.txt b/Documentation/devicetree/bindings/gpu/adreno.txt
index 70f1148..b18d573 100644
--- a/Documentation/devicetree/bindings/gpu/adreno.txt
+++ b/Documentation/devicetree/bindings/gpu/adreno.txt
@@ -93,6 +93,7 @@
 - qcom,chipid:		   If it exists this property is used to replace
 			   the chip identification read from the GPU hardware.
 			   This is used to override faulty hardware readings.
+- qcom,disable-wake-on-touch:   Boolean. Disables the GPU power up on a touch input event.
 - qcom,disable-busy-time-burst:
 				Boolean. Disables the busy time burst to avoid switching
 				of power level for large frames based on the busy time limit.
@@ -210,19 +211,22 @@
 				and pagetable walk.
 - cache-slices:			phandle to the system LLC driver, cache slice index.
 
+
+GPU coresight info:
 The following properties are optional as collecting data via coresight might
 not be supported for every chipset. The documentation for coresight
 properties can be found in:
 Documentation/devicetree/bindings/coresight/coresight.txt
 
-- coresight-id           Unique integer identifier for the bus.
-- coresight-name         Unique descriptive name of the bus.
-- coresight-nr-inports   Number of input ports on the bus.
-- coresight-outports     List of output port numbers on the bus.
-- coresight-child-list   List of phandles pointing to the children of this
+- qcom,gpu-coresights:	 Container for sets of GPU coresight sources.
+- coresight-id:          Unique integer identifier for the bus.
+- coresight-name:        Unique descriptive name of the bus.
+- coresight-nr-inports:  Number of input ports on the bus.
+- coresight-outports:    List of output port numbers on the bus.
+- coresight-child-list:  List of phandles pointing to the children of this
                          component.
-- coresight-child-ports  List of input port numbers of the children.
-- coresight-atid         The unique ATID value of the coresight device
+- coresight-child-ports: List of input port numbers of the children.
+- coresight-atid:        The unique ATID value of the coresight device
 
 Example of A330 GPU in MSM8916:
 
diff --git a/Documentation/devicetree/bindings/i2c/i2c-msm-v2.txt b/Documentation/devicetree/bindings/i2c/i2c-msm-v2.txt
new file mode 100644
index 0000000..fa3abb2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-msm-v2.txt
@@ -0,0 +1,55 @@
+Qualcomm I2C controller
+
+Required properties:
+ - reg : Offset and length of the register region for the device named in
+	reg-names and has the same index.
+ - reg-names : Register region name(s) referenced in reg above
+	"qup_phys_addr" : Physical address of QUP register space.
+ - compatible : should be "qcom,i2c-msm-v2"
+ - interrupts : Interrupt number which correspond to the entry with the same
+	index in interrupt-names.
+ - interrupt-names: QUP core interrupt name(s) referenced in interrupts above
+	"qup_irq" : QUP interrupt used by the controller.
+ - dmas : DMA engine API's parameters for blsp.
+	<[phandle of the dma controller] [pipe index] [number of descriptors]
+				[sps_connect flags] [sps_register_event flags]>;
+ - dma-names :  dma channel names.
+ - qcom,clk-freq-out : Desired I2C bus clock frequency in Hz
+ - qcom,clk-freq-in  : Supplied core clock frequency in Hz.
+
+Required alias:
+ - The desired bus-number is specified by an alias with the following format:
+	'i2c{n}' where n is the bus number.
+
+Optional property:
+ - qcom,noise-rjct-scl : number of low samples on clock line to consider it low.
+	When missing default to 0.
+ - qcom,noise-rjct-sda : number of low samples on data  line to consider it low.
+	When missing default to 0.
+ - qcom,disable-dma : disables DMA transfer mode.
+ - qcom,master-id : Master-port value used on voting for the clock path.
+ - qcom,high-time-clk-div : high time divider value to configure clk-ctl
+	register. When missing, default to the value given in driver.
+ - qcom,fs-clk-div: fs divider value to configure clk-ctl register. When
+	missing, default to the value given in driver.
+
+Example:
+	aliases {
+		i2c10 = &i2c_10;
+	};
+
+	i2c_10: i2c@f9966000 {
+		compatible = "qcom,i2c-msm-v2";
+		reg-names = "qup_phys_addr", "dma_phys_addr";
+		reg = <0xf9966000 0x1000>;
+		interrupt-names = "qup_irq";
+		interrupts = <0 104 0>;
+		dmas = <&dma_blsp1 14 32 0x20000020 0x20>,
+			<&dma_blsp1 15 64 0x20000020 0x20>;
+		dma-names = "tx", "rx";
+		qcom,clk-freq-out = <100000>;
+		qcom,clk-freq-in  = <24000000>;
+		qcom,noise-rjct-scl = <0>;
+		qcom,noise-rjct-sda = <0>;
+
+	};
diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
index 3e5b979..8682ab6 100644
--- a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
@@ -8,8 +8,9 @@
 Required properties:
 - compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton"
 
-Required properties for TPS65218:
+Required properties:
 - interrupts: should be one of the following
+   - <2>: For controllers compatible with tps65217
    - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218
 
 Examples:
@@ -17,6 +18,7 @@
 &tps {
 	tps65217-pwrbutton {
 		compatible = "ti,tps65217-pwrbutton";
+		interrupts = <2>;
 	};
 };
 
diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index a014dac..d2e635a 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -96,10 +96,13 @@
 		  retention. No cache invalidation operations involving asid
 		  may be used.
 
-- qcom,actlr:
-		  An array of <sid mask actlr-setting>.
-		  Any sid X for which X&~mask==sid will be programmed with the
-		  given actlr-setting.
+- qcom,disable-atos:
+		  Some hardware may not have full support for atos debugging
+		  in tandem with other features like power collapse.
+
+- qcom,mmu500-errata-1:
+		  An array of <sid mask>.
+		  Indicates the SIDs for which the workaround is required.
 
 - qcom,deferred-regulator-disable-delay : The time delay for deferred regulator
                   disable in ms. In case of unmap call, regulator is
diff --git a/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt b/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt
index 933ad85..83a58df 100644
--- a/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt
@@ -278,6 +278,46 @@
   Value type: <u32>
   Definition: should specify the power on sequence delay time in ms.
 
+- spiop-read
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI read operation related data.
+
+- spiop-readseq
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI read sequence operation realted data.
+
+- spiop-queryid
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI query eeprom id operation related data.
+
+- spiop-pprog:
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI page program operation related data.
+
+- spiop-wenable
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI write enable operation related data.
+
+- spiop-readst
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI read destination operation related data.
+
+- spiop-erase
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides SPI erase operation related data.
+
+- eeprom-idx
+  Usage: required
+  Value type: <u32>
+  Definition: this array provides eeprom id realted data.
+
 - xxxx-supply
   Usage: required
   Value type: <phandle>
@@ -385,6 +425,10 @@
 		cell-index = <0>;
 		reg = <0x0>;
 		qcom,eeprom-name = "msm_eeprom";
+		eeprom-id0 = <0xF8 0x15>;
+		eeprom-id1 = <0xEF 0x15>;
+		eeprom-id2 = <0xC2 0x36>;
+		eeprom-id3 = <0xC8 0x15>;
 		compatible = "qcom,eeprom";
 		qcom,slave-addr = <0x60>;
 		qcom,num-blocks = <2>;
@@ -400,6 +444,13 @@
 		qcom,cmm-data-compressed;
 		qcom,cmm-data-offset = <0>;
 		qcom,cmm-data-size = <0>;
+		spiop-read = <0x03 3 0 0 0>;
+		spiop-readseq = <0x03 3 0 0 0>;
+		spiop-queryid = <0x90 3 0 0 0>;
+		spiop-pprog = <0x02 3 0 3 100>;
+		spiop-wenable = <0x06 0 0 0 0>;
+		spiop-readst = <0x05 0 0 0 0>;
+		spiop-erase = <0x20 3 0 10 100>;
 		qcom,cam-power-seq-type = "sensor_vreg",
 			"sensor_vreg", "sensor_clk",
 			"sensor_gpio", "sensor_gpio";
diff --git a/Documentation/devicetree/bindings/media/video/msm-cam-fd.txt b/Documentation/devicetree/bindings/media/video/msm-cam-fd.txt
new file mode 100644
index 0000000..cf551f6
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video/msm-cam-fd.txt
@@ -0,0 +1,149 @@
+* Qualcomm Technologies, Inc. MSM Camera FD
+
+The MSM camera Face Detection device provides dependency definitions
+for enabling Camera FD HW. MSM camera FD is implemented in multiple
+device nodes. The root FD device node has properties defined to hint
+the driver about the FD HW nodes available during the probe sequence.
+Each node has multiple properties defined for interrupts, clocks and
+regulators.
+
+=======================
+Required Node Structure
+=======================
+FD root interface node takes care of the handling Face Detection high level
+driver handling and controls underlying FD hardware present.
+
+- compatible
+  Usage: required
+  Value type: <string>
+  Definition: Should be "qcom,cam-fd".
+
+- compat-hw-name
+  Usage: required
+  Value type: <string>
+  Definition: Should be "qcom,fd".
+
+- num-fd
+  Usage: required
+  Value type: <u32>
+  Definition: Number of supported FD HW blocks.
+
+Example:
+	qcom,cam-fd {
+		compatible = "qcom,cam-fd";
+		compat-hw-name = "qcom,fd";
+		num-fd = <1>;
+	};
+
+=======================
+Required Node Structure
+=======================
+FD Node provides interface for Face Detection hardware driver
+about the device register map, interrupt map, clocks, regulators.
+
+- cell-index
+  Usage: required
+  Value type: <u32>
+  Definition: Node instance number.
+
+- compatible
+  Usage: required
+  Value type: <string>
+  Definition: Should be "qcom,fd41".
+
+- reg-names
+  Usage: optional
+  Value type: <string>
+  Definition: Name of the register resources.
+
+- reg
+  Usage: optional
+  Value type: <u32>
+  Definition: Register values.
+
+- reg-cam-base
+  Usage: optional
+  Value type: <u32>
+  Definition: Offset of the register space compared to
+              to Camera base register space.
+
+- interrupt-names
+  Usage: optional
+  Value type: <string>
+  Definition: Name of the interrupt.
+
+- interrupts
+  Usage: optional
+  Value type: <u32>
+  Definition: Interrupt line associated with FD HW.
+
+- regulator-names
+  Usage: required
+  Value type: <string>
+  Definition: Name of the regulator resources for FD HW.
+
+- camss-vdd-supply
+  Usage: required
+  Value type: <phandle>
+  Definition: Regulator reference corresponding to the names listed
+              in "regulator-names".
+
+- clock-names
+  Usage: required
+  Value type: <string>
+  Definition: List of clock names required for FD HW.
+
+- clocks
+  Usage: required
+  Value type: <phandle>
+  Definition: List of clocks required for FD HW.
+
+- clock-rates
+  Usage: required
+  Value type: <u32>
+  Definition: List of clocks rates.
+
+- src-clock-name
+  Usage: required
+  Value type: <string>
+  Definition: Source clock name.
+
+- clock-cntl-level
+  Usage: required
+  Value type: <string>
+  Definition: List of strings corresponds clock-rates levels.
+  Supported strings: minsvs, lowsvs, svs, svs_l1, nominal, turbo.
+
+Examples:
+	cam_fd: qcom,fd@ac5a000 {
+		cell-index = <0>;
+		compatible = "qcom,fd41";
+		reg-names = "fd_core", "fd_wrapper";
+		reg = <0xac5a000 0x1000>,
+			<0xac5b000 0x400>;
+		reg-cam-base = <0x5a000 0x5b000>;
+		interrupt-names = "fd";
+		interrupts = <0 462 0>;
+		regulator-names = "camss-vdd";
+		camss-vdd-supply = <&titan_top_gdsc>;
+		clock-names = "gcc_ahb_clk",
+			"gcc_axi_clk",
+			"soc_ahb_clk",
+			"cpas_ahb_clk",
+			"camnoc_axi_clk",
+			"fd_core_clk_src",
+			"fd_core_clk",
+			"fd_core_uar_clk";
+		clocks = <&clock_gcc GCC_CAMERA_AHB_CLK>,
+			<&clock_gcc GCC_CAMERA_AXI_CLK>,
+			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
+			<&clock_camcc CAM_CC_CPAS_AHB_CLK>,
+			<&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
+			<&clock_camcc CAM_CC_FD_CORE_CLK_SRC>,
+			<&clock_camcc CAM_CC_FD_CORE_CLK>,
+			<&clock_camcc CAM_CC_FD_CORE_UAR_CLK>;
+		src-clock-name = "fd_core_clk_src";
+		clock-cntl-level = "svs";
+		clock-rates = <0 0 0 0 0 400000000 0 0>;
+	};
+
diff --git a/Documentation/devicetree/bindings/media/video/msm-cam-icp.txt b/Documentation/devicetree/bindings/media/video/msm-cam-icp.txt
index 0c63c7e..36dad1a 100644
--- a/Documentation/devicetree/bindings/media/video/msm-cam-icp.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-cam-icp.txt
@@ -105,6 +105,11 @@
   Value type: <string>
   Definition: List of clock names required for CDM HW.
 
+- src-clock-name
+  Usage: required
+  Value type: <string>
+  Definition: Source clock name.
+
 - clocks
   Usage: required
   Value type: <phandle>
@@ -114,7 +119,7 @@
   Usage: required
   Value type: <string>
   Definition: List of strings corresponds clock-rates levels.
-  Supported strings: minsvs, lowsvs, svs, svs_l1, nominal, turbo.
+  Supported strings: lowsvs, svs, svs_l1, nominal, turbo.
 
 - clock-rates
   Usage: required
@@ -176,14 +181,20 @@
 		"ipe_0_axi_clk",
 		"ipe_0_clk",
 		"ipe_0_clk_src";
+	src-clock-name = "ipe_0_clk_src";
 	clocks = <&clock_camcc CAM_CC_IPE_0_AHB_CLK>,
 			<&clock_camcc CAM_CC_IPE_0_AREG_CLK>,
 			<&clock_camcc CAM_CC_IPE_0_AXI_CLK>,
 			<&clock_camcc CAM_CC_IPE_0_CLK>,
 			<&clock_camcc CAM_CC_IPE_0_CLK_SRC>;
 
-	clock-rates = <80000000 400000000 0 0 600000000>;
-	clock-cntl-level = "turbo";
+	clock-rates = <0 0 0 0 240000000>,
+		<0 0 0 0 404000000>,
+		<0 0 0 0 480000000>,
+		<0 0 0 0 538000000>,
+		<0 0 0 0 600000000>;
+	clock-cntl-level = "lowsvs", "svs",
+		"svs_l1", "nominal", "turbo";
 };
 
 qcom,ipe1 {
@@ -196,14 +207,20 @@
 		"ipe_1_axi_clk",
 		"ipe_1_clk",
 		"ipe_1_clk_src";
+	src-clock-name = "ipe_1_clk_src";
 	clocks = <&clock_camcc CAM_CC_IPE_1_AHB_CLK>,
 			<&clock_camcc CAM_CC_IPE_1_AREG_CLK>,
 			<&clock_camcc CAM_CC_IPE_1_AXI_CLK>,
 			<&clock_camcc CAM_CC_IPE_1_CLK>,
 			<&clock_camcc CAM_CC_IPE_1_CLK_SRC>;
 
-	clock-rates = <80000000 400000000 0 0 600000000>;
-	clock-cntl-level = "turbo";
+	clock-rates = <0 0 0 0 240000000>,
+		<0 0 0 0 404000000>,
+		<0 0 0 0 480000000>,
+		<0 0 0 0 538000000>,
+		<0 0 0 0 600000000>;
+	clock-cntl-level = "lowsvs", "svs",
+		"svs_l1", "nominal", "turbo";
 };
 
 bps: qcom,bps {
@@ -216,13 +233,19 @@
 		"bps_axi_clk",
 		"bps_clk",
 		"bps_clk_src";
+	src-clock-name = "bps_clk_src";
 	clocks = <&clock_camcc CAM_CC_BPS_AHB_CLK>,
 			<&clock_camcc CAM_CC_BPS_AREG_CLK>,
 			<&clock_camcc CAM_CC_BPS_AXI_CLK>,
 			<&clock_camcc CAM_CC_BPS_CLK>,
 			<&clock_camcc CAM_CC_BPS_CLK_SRC>;
 
-	clock-rates = <80000000 400000000 0 0 600000000>;
-	clock-cntl-level = "turbo";
+	clock-rates = <0 0 0 0 200000000>,
+		<0 0 0 0 404000000>,
+		<0 0 0 0 480000000>,
+		<0 0 0 0 600000000>,
+		<0 0 0 0 600000000>;
+	clock-cntl-level = "lowsvs", "svs",
+		"svs_l1", "nominal", "turbo";
 };
 
diff --git a/Documentation/devicetree/bindings/media/video/msm-cam-smmu.txt b/Documentation/devicetree/bindings/media/video/msm-cam-smmu.txt
index 72e2ab4..728c5f9 100644
--- a/Documentation/devicetree/bindings/media/video/msm-cam-smmu.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-cam-smmu.txt
@@ -56,6 +56,11 @@
   Value type: <string>
   Definition: Should specify a string label to identify the context bank.
 
+- qcom,secure-cb
+  Usage: optional
+  Value type: boolean
+  Definition: Specifies if the context bank is a secure context bank.
+
 =============================================
 Third Level Node - CAM SMMU memory map device
 =============================================
diff --git a/Documentation/devicetree/bindings/media/video/msm-sde-rotator.txt b/Documentation/devicetree/bindings/media/video/msm-sde-rotator.txt
index 46649af..db34047 100644
--- a/Documentation/devicetree/bindings/media/video/msm-sde-rotator.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-sde-rotator.txt
@@ -123,6 +123,7 @@
 				swizzle configuration value.
 - qcom,rot-reg-bus:		Property to provide Bus scaling for register
 				access for rotator blocks.
+- power-domains:		A phandle to respective power domain node.
 
 Subnode properties:
 - compatible:		Compatible name used in smmu v2.
@@ -150,6 +151,8 @@
 		interrupt-parent = <&mdss_mdp>;
 		interrupts = <2 0>;
 
+		power-domains = <&mdss_mdp>;
+
 		qcom,mdss-mdp-reg-offset = <0x00001000>;
 
 		rot-vdd-supply = <&gdsc_mdss>;
diff --git a/Documentation/devicetree/bindings/media/video/msm-vidc.txt b/Documentation/devicetree/bindings/media/video/msm-vidc.txt
index d61606a..f0549cb 100644
--- a/Documentation/devicetree/bindings/media/video/msm-vidc.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-vidc.txt
@@ -7,9 +7,11 @@
 - compatible : one of:
 	- "qcom,msm-vidc"
         - "qcom,sdm845-vidc" : Invokes driver specific data for SDM845.
+        - "qcom,sdm670-vidc" : Invokes driver specific data for SDM670.
 
 Optional properties:
 - reg : offset and length of the register set for the device.
+- sku-index : sku version of the hardware.
 - interrupts : should contain the vidc interrupt.
 - qcom,reg-presets : list of offset-value pairs for registers to be written.
   The offsets are from the base offset specified in 'reg'. This is mainly
diff --git a/Documentation/devicetree/bindings/mmc/sdhci-msm.txt b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
index 24c75e2..d3098be 100644
--- a/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
+++ b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
@@ -85,6 +85,7 @@
 	  On certain chipsets, coming out of the CX Power Collapse event, the SDCC registers
 	  contents will not be retained. It is software responsibility to restore the
 	  SDCC registers before resuming to normal operation.
+	- qcom,force-sdhc1-probe: Force probing sdhc1 even if it is not the boot device.
 
 In the following, <supply> can be vdd (flash core voltage) or vdd-io (I/O voltage).
 	- qcom,<supply>-always-on - specifies whether supply should be kept "on" always.
diff --git a/Documentation/devicetree/bindings/pci/msm_pcie.txt b/Documentation/devicetree/bindings/pci/msm_pcie.txt
index fc019bd..2a5096f 100644
--- a/Documentation/devicetree/bindings/pci/msm_pcie.txt
+++ b/Documentation/devicetree/bindings/pci/msm_pcie.txt
@@ -70,13 +70,12 @@
   - qcom,common-clk-en: Enables the common clock configuration for the endpoint.
   - qcom,clk-power-manage-en: Enables the clock power management for the
     endpoint.
+  - qcom,max-link-speed: Max Gen speed Root complex supports.
   - qcom,n-fts: The number of fast training sequences sent when the link state
     is changed from L0s to L0.
   - qcom,pcie-phy-ver: version of PCIe PHY.
   - qcom,phy-sequence: The initialization sequence to bring up the PCIe PHY.
     Should be specified in groups (offset, value, delay).
-  - qcom,port-phy-sequence: The initialization sequence to bring up the
-    PCIe port PHY.
     Should be specified in groups (offset, value, delay).
   - qcom,use-19p2mhz-aux-clk: The frequency of PCIe AUX clock is 19.2MHz.
   - qcom,boot-option: Bits that alter PCIe bus driver boot sequence.
@@ -91,7 +90,6 @@
   - iommus: the phandle and stream IDs for the SMMU used by this root
     complex. This should be used in separate nodes from the main root
     complex nodes, and is the only property needed in that case.
-  - qcom,common-phy: There is a common phy for all the Root Complexes.
   - qcom,smmu-exist: PCIe uses a SMMU.
   - qcom,smmu-sid-base: The base SMMU SID that PCIe bus driver will use to calculate
     and assign for each endpoint.
@@ -99,6 +97,7 @@
     stable after power on, before de-assert the PERST to the endpoint.
   - qcom,wr-halt-size: With base 2, this exponent determines the size of the
     data that PCIe core will halt on for each write transaction.
+  - qcom,slv-addr-space-size: The memory space size of PCIe Root Complex.
   - qcom,cpl-timeout: Completion timeout value. This value specifies the time range
     which the root complex will send out a completion packet if there is no response
     from the endpoint.
@@ -214,13 +213,6 @@
 					0x15c 0x06 0x00
 					0x090 0x01 0x00
 					0x808 0x03 0x00>;
-		qcom,port-phy-sequence = <0x804 0x01 0x00
-					0x034 0x14 0x00
-					0x138 0x30 0x00
-					0x048 0x0f 0x00
-					0x15c 0x06 0x00
-					0x090 0x01 0x00
-					0x808 0x03 0x00>;
 		perst-gpio = <&msmgpio 70 0>;
 		wake-gpio = <&msmgpio 69 0>;
 		clkreq-gpio = <&msmgpio 68 0>;
@@ -265,6 +257,7 @@
 		qcom,l1-supported;
 		qcom,l1ss-supported;
 		qcom,aux-clk-sync;
+		qcom,max-link-speed = <0x2>;
 		qcom,n-fts = <0x50>;
 		qcom,pcie-phy-ver = <1>;
 		qcom,boot-option = <0x1>;
@@ -272,11 +265,11 @@
 		qcom,msi-gicm-base = <0x160>;
 		qcom,ext-ref-clk;
 		qcom,tlp-rd-size = <0x5>;
-		qcom,common-phy;
 		qcom,smmu-exist;
 		qcom,smmu-sid-base = <0x1480>;
 		qcom,ep-latency = <100>;
 		qcom,wr-halt-size = <0xa>; /* 1KB */
+		qcom,slv-addr-space-size = <0x1000000>; /* 16MB */
 		qcom,cpl-timeout = <0x2>;
 
 		iommus = <&anoc0_smmu>;
diff --git a/Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt b/Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt
index bc844de..85b0fe9 100644
--- a/Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt
+++ b/Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt
@@ -67,6 +67,9 @@
 			  service.
 - qcom,sysmon-id:	platform device id that sysmon is probed with for the subsystem.
 - qcom,override-acc: Boolean- Present if we need to override the default ACC settings
+- qcom,mss_pdc_offset: Integer- Mandatory if PDC register is specified. It is
+				used to specify which bit in the PDC register
+				corresponds to the modem.
 - qcom,ahb-clk-vote: Boolean- Present if we need to remove the vote for the mss_cfg_ahb
 		     clock after the modem boots up
 - qcom,pnoc-clk-vote: Boolean- Present if the modem needs the PNOC bus to be
@@ -90,6 +93,7 @@
 		    wordline clamp, and compiler memory clamp during MSS restart.
 - qcom,qdsp6v56-1-10: Boolean- Present if the qdsp version is v56 1.10
 - qcom,override-acc-1: Override the default ACC settings with this value if present.
+- qcom,minidump-id: Unique id for each subsystem
 
 One child node to represent the MBA image may be specified, when the MBA image
 needs to be loaded in a specifically carved out memory region.
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,msm8953-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,msm8953-pinctrl.txt
new file mode 100644
index 0000000..d4bf1ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,msm8953-pinctrl.txt
@@ -0,0 +1,210 @@
+Qualcomm MSM8953 TLMM block
+
+This binding describes the Top Level Mode Multiplexer block found in the
+MSM8953 platform.
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be "qcom,msm8953-pinctrl"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: the base address and size of the TLMM register space.
+
+- interrupts:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: should specify the TLMM summary IRQ.
+
+- interrupt-controller:
+	Usage: required
+	Value type: <none>
+	Definition: identifies this node as an interrupt controller
+
+- #interrupt-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 2. Specifying the pin number and flags, as defined
+		    in <dt-bindings/interrupt-controller/irq.h>
+
+- gpio-controller:
+	Usage: required
+	Value type: <none>
+	Definition: identifies this node as a gpio controller
+
+- #gpio-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 2. Specifying the pin number and flags, as defined
+		    in <dt-bindings/gpio/gpio.h>
+
+Please refer to ../gpio/gpio.txt and ../interrupt-controller/interrupts.txt for
+a general description of GPIO and interrupt bindings.
+
+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".
+
+The 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, drive strength, etc.
+
+
+PIN CONFIGURATION NODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+
+- pins:
+	Usage: required
+	Value type: <string-array>
+	Definition: List of gpio pins affected by the properties specified in
+		    this subnode.
+		    Valid pins are:
+		    gpio0-gpio141,
+		    sdc1_clk,
+		    sdc1_cmd,
+		    sdc1_data,
+		    sdc1_rclk,
+		    sdc2_clk,
+		    sdc2_cmd,
+		    sdc2_data,
+		    qdsd_cmd,
+		    qdsd_data0,
+		    qdsd_data1,
+		    qdsd_data2,
+		    qdsd_data3
+
+- function:
+	Usage: required
+	Value type: <string>
+	Definition: Specify the alternative function to be configured for the
+		    specified pins. Functions are only valid for gpio pins.
+		    Valid values are:
+	gpio, blsp_spi1, smb_int, adsp_ext, prng_rosc, blsp_i2c1,
+	qdss_cti_trig_out_b0, qdss_cti_trig_out_a1, blsp_spi2, blsp_uart2,
+	ldo_update, dac_calib0, ldo_en, blsp_i2c2, gcc_gp1_clk_b,
+	atest_gpsadc_dtest0_native, blsp_spi3, qdss_tracedata_b,
+	pwr_modem_enabled_b, blsp_i2c3, gcc_gp2_clk_b, gcc_gp3_clk_b, hall_int,
+	blsp_spi4, blsp_uart4, pwr_nav_enabled_b, dac_calib1, cap_int,
+	pwr_crypto_enabled_b, dac_calib2, blsp_i2c4, nfc_disable, blsp_spi5,
+	blsp_uart5, qdss_traceclk_a, atest_bbrx1, nfc_irq, m_voc,
+	qdss_cti_trig_in_a0, atest_bbrx0, blsp_i2c5, qdss_tracectl_a,
+	atest_gpsadc_dtest1_native, qdss_tracedata_a, blsp_spi6, blsp_uart6,
+	qdss_tracectl_b, dac_calib15, qdss_cti_trig_in_b0, dac_calib16, blsp_i2c6,
+	qdss_traceclk_b, atest_wlan0, atest_wlan1, mdp_vsync, pri_mi2s_mclk_a,
+	sec_mi2s_mclk_a, qdss_cti_trig_out_b1, cam_mclk, dac_calib3, cci_i2c,
+	pwr_modem_enabled_a, dac_calib4, dac_calib19, flash_strobe, cci_timer0,
+	cci_timer1, cam_irq, cci_timer2, blsp1_spi, pwr_nav_enabled_a, ois_sync,
+	cci_timer3, cci_timer4, blsp3_spi, qdss_cti_trig_out_a0, dac_calib7,
+	accel_int, gcc_gp1_clk_a, dac_calib8, alsp_int, gcc_gp2_clk_a, dac_calib9,
+	mag_int, gcc_gp3_clk_a, pwr_crypto_enabled_a, cci_async, cam1_standby,
+	dac_calib5, cam1_rst, dac_calib6, dac_calib10, gyro_int, dac_calib11,
+	pressure_int, dac_calib12, blsp6_spi, dac_calib13, fp_int,
+	qdss_cti_trig_in_b1, dac_calib14, uim_batt, cam0_ldo, sd_write, uim1_data,
+	uim1_clk, uim1_reset, uim1_present, uim2_data, uim2_clk, uim2_reset,
+	uim2_present, ts_xvdd, mipi_dsi0, nfc_dwl, us_euro, atest_char3, dbg_out,
+	bimc_dte0, ts_resout, ts_sample, sec_mi2s_mclk_b, pri_mi2s, codec_reset,
+	cdc_pdm0, atest_char1, ebi_cdc, dac_calib17, us_emitter, atest_char0,
+	pri_mi2s_mclk_b, lpass_slimbus, lpass_slimbus0, lpass_slimbus1, codec_int1,
+	codec_int2, wcss_bt, atest_char2, ebi_ch0, wcss_wlan2, wcss_wlan1,
+	wcss_wlan0, wcss_wlan, wcss_fm, ext_lpass, mss_lte, key_volp, pbs0,
+	cri_trng0, key_snapshot, pbs1, cri_trng1, key_focus, pbs2, cri_trng,
+	gcc_tlmm, key_home, pwr_down, dmic0_clk, blsp7_spi, hdmi_int, dmic0_data,
+	qdss_cti_trig_in_a1, pri_mi2s_ws, wsa_io, wsa_en, blsp_spi8, wsa_irq,
+	blsp_i2c8, gcc_plltest, nav_pps_in_a, pa_indicator, nav_pps_in_b, nav_pps,
+	modem_tsync, nav_tsync, ssbi_wtr1, gsm1_tx, dac_calib18, gsm0_tx,
+	atest_char, atest_tsens, bimc_dte1, dac_calib20, cam2_rst, ddr_bist,
+	dac_calib21, cam2_standby, dac_calib22, cam3_rst, dac_calib23,
+	cam3_standby, dac_calib24, sdcard_det, dac_calib25, cam1_ldo, sec_mi2s,
+	blsp_spi7, blsp_i2c7, ss_switch, tsens_max
+
+- bias-disable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configued as no pull.
+
+- bias-pull-down:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configued as pull down.
+
+- bias-pull-up:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configued as pull up.
+
+- output-high:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    high.
+		    Not valid for sdc pins.
+
+- output-low:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    low.
+		    Not valid for sdc pins.
+
+- drive-strength:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the drive strength for the specified pins, in mA.
+		    Valid values are: 2, 4, 6, 8, 10, 12, 14 and 16
+
+Example:
+
+	tlmm: pinctrl@1000000 {
+		compatible = "qcom,msm8953-pinctrl";
+		reg = <0x1000000 0x300000>;
+		interrupts = <0 208 0>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+
+		pmx-uartconsole {
+			uart_console_active: uart_console_active {
+				mux {
+					pins = "gpio4", "gpio5";
+					function = "blsp_uart2";
+				};
+
+				config {
+					pins = "gpio4", "gpio5";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+
+			uart_console_sleep: uart_console_sleep {
+				mux {
+					pins = "gpio4", "gpio5";
+					function = "blsp_uart2";
+				};
+
+				config {
+					pins = "gpio4", "gpio5";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+
+		};
+	};
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,sdm845-pinctrl b/Documentation/devicetree/bindings/pinctrl/qcom,sdm845-pinctrl
index 9c26374..7e75d2c 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,sdm845-pinctrl
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,sdm845-pinctrl
@@ -6,7 +6,7 @@
 - compatible:
 	Usage: required
 	Value type: <string>
-	Definition: must be "qcom,sdm845-pinctrl"
+	Definition: must be "qcom,sdm845-pinctrl" or "qcom,sdm845-pinctrl-v2"
 
 - reg:
 	Usage: required
diff --git a/Documentation/devicetree/bindings/platform/msm/qpnp-revid.txt b/Documentation/devicetree/bindings/platform/msm/qpnp-revid.txt
index babc452..dd14890 100644
--- a/Documentation/devicetree/bindings/platform/msm/qpnp-revid.txt
+++ b/Documentation/devicetree/bindings/platform/msm/qpnp-revid.txt
@@ -9,6 +9,8 @@
 Optional property:
 - qcom,fab-id-valid: Use this property when support to read Fab
 	identification from REV ID peripheral is available.
+- qcom,tp-rev-valid: Use this property when support to read TP
+	revision identification from REV ID peripheral.
 
 Example:
 	qcom,revid@100 {
diff --git a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt
index d0d878b..d205b0b 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt
+++ b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt
@@ -271,6 +271,14 @@
 	Definition: A boolean property that when defined holds SOC at 100% when
 		    the battery is full.
 
+- qcom,linearize-soc
+	Usage:      optional
+	Value type: <empty>
+	Definition: A boolean property that when defined linearizes SOC when
+		    the SOC drops after charge termination monotonically to
+		    improve the user experience. This is applicable only if
+		    "qcom,hold-soc-while-full" is specified.
+
 - qcom,ki-coeff-soc-dischg
 	Usage:      optional
 	Value type: <prop-encoded-array>
@@ -301,6 +309,13 @@
 		    is specified to make it fully functional. Value has no
 		    unit. Allowed range is 0 to 62200 in micro units.
 
+- qcom,ki-coeff-full-dischg
+	Usage:	    optional
+	Value type: <u32>
+	Definition: Ki coefficient full SOC value that will be applied during
+		    discharging. If not specified, a value of 0 will be set.
+		    Allowed range is from 245 to 62256.
+
 - qcom,fg-rconn-mohms
 	Usage:      optional
 	Value type: <u32>
diff --git a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qnovo.txt b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qnovo.txt
index 96b7dd5..8f35e56 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qnovo.txt
+++ b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qnovo.txt
@@ -20,6 +20,7 @@
 Optional Properties:
 - qcom,external-rsense:		To indicate whether the platform uses external or
 				internal rsense for measuring battery current.
+- qcom,enable-for-dc:		To enable qnovo for dc charging path.
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt b/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
index 92ef23c..fd2729f 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
@@ -43,6 +43,13 @@
   Definition: Boolean flag which indicates that the charger should not draw
 	      current from any of its input sources (USB, DC).
 
+- qcom,use-extcon
+  Usage:      optional
+  Value type: <empty>
+  Definition: Boolean flag which specify that smb138x will act as main charger
+	      to do extcon USB calls. If not defined, other charger driver can
+	      act as main charger to do extcon USB calls.
+
 - qcom,fcc-max-ua
   Usage:      optional
   Value type: <u32>
diff --git a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
index 98d131a..a11072c 100644
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
@@ -2,11 +2,16 @@
 
 Required Properties:
 -compatible: "ti,tps65217-charger"
+-interrupts: TPS65217 interrupt numbers for the AC and USB charger input change.
+             Should be <0> for the USB charger and <1> for the AC adapter.
+-interrupt-names: Should be "USB" and "AC"
 
 This node is a subnode of the tps65217 PMIC.
 
 Example:
 
 	tps65217-charger {
-		compatible = "ti,tps65090-charger";
+		compatible = "ti,tps65217-charger";
+		interrupts = <0>, <1>;
+		interrupt-names = "USB", "AC";
 	};
diff --git a/Documentation/devicetree/bindings/serial/msm_serial_hs.txt b/Documentation/devicetree/bindings/serial/msm_serial_hs.txt
new file mode 100644
index 0000000..031be45
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/msm_serial_hs.txt
@@ -0,0 +1,121 @@
+* Qualcomm MSM HSUART
+
+Required properties:
+- compatible :
+	- "qcom,msm-hsuart-v14" to be used for UARTDM Core v1.4
+- reg : offset and length of the register set for both the device,
+	uart core and bam core
+- reg-names :
+	- "core_mem" to be used as name of the uart core
+	- "bam_mem" to be used as name of the bam core
+- interrupts : interrupts for both the device,uart core and bam core
+- interrupt-names :
+	- "core_irq" to be used as uart irq
+	- "bam irq" to be used as bam irq
+- #interrupt-cells: Specifies the number of cells needed to encode an interrupt
+		source. The type shall be a <u32> and the value shall be 1
+- #address-cells: Specifies the number of cells needed to encode an address.
+		The type shall be <u32> and the value shall be 0
+- interrupt-parent = It is needed for interrupt mapping
+- bam-tx-ep-pipe-index : BAM TX Endpoint Pipe Index for HSUART
+- bam-rx-ep-pipe-index : BAM RX Endpoint Pipe Index for HSUART
+
+BLSP has a static pipe allocation and assumes a pair-pipe for each uart core.
+Pipes [2*i : 2*i+1] are allocated for UART cores where i = [0 : 5].
+Hence, Minimum and Maximum permitted value of endpoint pipe index to be used
+with uart core is 0 and 11 respectively.
+
+There is one HSUART block used in MSM devices,
+"qcom,msm-hsuart-v14". The msm-serial-hs driver is
+able to handle this, and matches against the "qcom,msm-hsuart-v14"
+as the compatibility.
+
+The registers for the "qcom,msm-hsuart-v14" device need to specify both
+register blocks - uart core and bam core.
+
+Example:
+
+	uart7: uart@f995d000 {
+		compatible = "qcom,msm-hsuart-v14";
+		reg = <0xf995d000 0x1000>,
+		      <0xf9944000 0x5000>;
+		reg-names = "core_mem", "bam_mem";
+		interrupt-names = "core_irq", "bam_irq";
+		#address-cells = <0>;
+		interrupt-parent = <&uart7>;
+		interrupts = <0 1>;
+		#interrupt-cells = <1>;
+		interrupt-map = <0 &intc 0 113 0
+				1 &intc 0 239 0>
+		qcom,bam-tx-ep-pipe-index = <0>;
+		qcom,bam-rx-ep-pipe-index = <1>;
+	};
+
+Optional properties:
+- qcom,<gpio-name>-gpio : handle to the GPIO node, see "gpios property" in
+Documentation/devicetree/bindings/gpio/gpio.txt.
+"gpio-name" can be "tx", "rx", "cts" and "rfr" based on number of UART GPIOs
+need to configured.
+Gpio's are optional if it is required to be not configured by UART driver or
+case where there is nothing connected and we want to use internal loopback mode
+for uart.
+- qcom, wakeup_irq : UART RX GPIO IRQ line to be configured as wakeup source.
+- qcom,inject-rx-on-wakeup : inject_rx_on_wakeup enables feature where on
+receiving interrupt with UART RX GPIO IRQ line (i.e. above wakeup_irq property),
+HSUART driver injects provided character with property rx_to_inject.
+- qcom, rx-char-to-inject : The character to be inserted on wakeup.
+- qcom, no-suspend-delay : This decides system to go to suspend immediately
+or not
+
+- Refer to "Documentation/devicetree/bindings/arm/msm/msm_bus.txt" for
+below optional properties:
+    - qcom,msm_bus,name
+    - qcom,msm_bus,num_cases
+    - qcom,msm_bus,active_only
+    - qcom,msm_bus,num_paths
+    - qcom,msm_bus,vectors
+
+Aliases :
+An alias may be optionally used to bind the UART device to a TTY device
+(ttyHS<alias_num>) with a given alias number. Aliases are of the form
+uart<n> where <n> is an integer representing the alias number to use.
+On systems with multiple UART devices present, an alias may optionally be
+defined for such devices. The alias value should be from 0 to 255.
+
+Example:
+
+	aliases {
+		uart4 = &uart7; // This device will be enumerated as ttyHS4
+	};
+
+	uart7: uart@f995d000 {
+		compatible = "qcom,msm-hsuart-v14"
+		reg = <0x19c40000 0x1000">,
+		      <0xf9944000 0x5000>;
+		reg-names = "core_mem", "bam_mem";
+		interrupt-names = "core_irq", "bam_irq", "wakeup_irq";
+		#address-cells = <0>;
+		interrupt-parent = <&uart7>;
+		interrupts = <0 1 2>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xffffffff>;
+		interrupt-map = <0 &intc 0 113 0
+				1 &intc 0 239 0
+				2 &msmgpio 42 0>;
+		qcom,tx-gpio = <&msmgpio 41 0x00>;
+		qcom,rx-gpio = <&msmgpio 42 0x00>;
+		qcom,cts-gpio = <&msmgpio 43 0x00>;
+		qcom,rfr-gpio = <&msmgpio 44 0x00>;
+		qcom,inject-rx-on-wakeup = <1>;
+		qcom,rx-char-to-inject = <0xFD>;
+
+		qcom,bam-tx-ep-pipe-index = <0>;
+		qcom,bam-rx-ep-pipe-index = <1>;
+
+		qcom,msm-bus,name = "uart7";
+		qcom,msm-bus,num-cases = <2>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+				<84 512 0 0>,
+				<84 512 500 800>;
+	};
diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,msm-eud.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,msm-eud.txt
index 800508a..45e309c 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,msm-eud.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,msm-eud.txt
@@ -10,6 +10,10 @@
  - interrupts:  Interrupt number
  - reg: Should be address and size of EUD register space
  - reg-names: Should be "eud_base"
+ - clocks: a list of phandles to the PHY clocks. Use as per
+   Documentation/devicetree/bindings/clock/clock-bindings.txt
+ - clock-names: Names of the clocks in 1-1 correspondence with
+   the "clocks" property.
 
 Driver notifies clients via extcon for VBUS spoof attach/detach
 and charger enable/disable events. Clients registered for these
@@ -23,6 +27,8 @@
 		interrupts = <GIC_SPI 492 IRQ_TYPE_LEVEL_HIGH>;
 		reg = <0x88e0000 0x4000>;
 		reg-names = "eud_base";
+		clocks = <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>;
+		clock-names = "cfg_ahb_clk";
 	};
 
 An example for EUD extcon client:
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
index 4d05e50..57a227e 100644
--- a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
+++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
@@ -2459,6 +2459,10 @@
 		6-pole-jack : Jack on the hardware is 6-pole.
 - clock-names : clock name defined for external clock.
 - clocks : external clock defined for codec clock.
+- qcom,msm-mbhc-hs-mic-max-threshold-mv : headset detection threshold. When micbias is
+					  not set to 2.7v, need scale in driver.
+- qcom,msm-mbhc-hs-mic-min-threshold-mv : headhpone detection threshold. When micbias is
+					  not set to 2.7v, need scale in driver.
 - qcom,hph-en1-gpio : GPIO to enable HiFi amplifiers.
 - qcom,hph-en0-gpio : GPIO to enable HiFi audio route to headset.
 - qcom,wsa-max-devs : Maximum number of WSA881x devices present in the target
@@ -2516,6 +2520,8 @@
 
 		qcom,msm-mbhc-hphl-swh = <0>;
 		qcom,msm-mbhc-gnd-swh = <0>;
+		qcom,msm-mbhc-hs-mic-max-threshold-mv = <1700>;
+		qcom,msm-mbhc-hs-mic-min-threshold-mv = <50>;
 		qcom,hph-en0-gpio = <&tavil_hph_en0>;
 		qcom,hph-en1-gpio = <&tavil_hph_en1>;
 		qcom,tavil-mclk-clk-freq = <9600000>;
diff --git a/Documentation/devicetree/bindings/spi/spi_qsd.txt b/Documentation/devicetree/bindings/spi/spi_qsd.txt
new file mode 100644
index 0000000..1edf082
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi_qsd.txt
@@ -0,0 +1,106 @@
+Qualcomm Serial Peripheral Interface (SPI)
+
+Required properties:
+- compatible : Should be "qcom,spi-qup-v2".
+- reg : Offset and length of the register regions for the device
+- reg-names : Register region names referenced in reg above.
+	Required register resource entries are:
+	"spi_physical" : Physical address of controller register blocks.
+- interrupts : Interrupt numbers used by this controller
+- interrupt-names : Interrupt resource names referenced in interrupts above.
+	Required interrupt resource entries are:
+	"spi_irq" : QUP-core interrupt.
+- spi-max-frequency : Specifies maximum SPI clock frequency, Units - Hz.
+
+Required alias:
+- The desired bus-number is specified via an alias with the following format
+	'spi{n}' where n is the bus number.
+
+Optional properties:
+- qcom,gpio-mosi : GPIO pin number of the MOSI bus line.
+- qcom,gpio-miso : GPIO pin number of the MISO bus line.
+- qcom,gpio-clk  : GPIO pin number of the CLK  bus line.
+- qcom,gpio-cs0  : GPIO pin number of the chipselect0 bus line.
+- qcom,gpio-cs1  : GPIO pin number of the chipselect1 bus line.
+- qcom,gpio-cs2  : GPIO pin number of the chipselect2 bus line.
+- qcom,gpio-cs3  : GPIO pin number of the chipselect3 bus line.
+- qcom,infinite-mode: When missing or set to zero, QUP uses infinite-mode. When
+  value is non-zero, the value is the number of words in maximum transfer
+  length.
+ - qcom,active-only : Vote for core clock when the application processor goes
+  to active state and remove that vote when it goes to idle state. This flag may
+  improve service time of first spi request at the expense of power consumption.
+  When this entry is not present, voting is done by the runtime-pm callbacks.
+ - qcom,master-id : Master endpoint number used for voting on clocks using the
+  bus-scaling driver.
+ - qcom,rt-priority : whether spi message queue is set to run as a realtime task.
+  With this spi transaction message pump with high (realtime) priority to reduce
+  the transfer latency on the bus by minimising the delay between a transfer request
+ - qcom,shared : whether this qup is shared with other ee's
+
+Optional properties which are required for support of BAM-mode:
+- qcom,ver-reg-exists : Boolean. When present, allows driver to verify if HW
+  version support latest features (e.g. BAM) and then enable them. Should be
+  removed for legacy HW.
+- qcom,use-bam : Boolean. When present, enables BAM-mode.
+- qcom,use-pinctrl : Boolean. When present, enables pinctrl frame work to configure GPIO's
+  instead of existing gpio mux hence gpio entries are no more required if present.
+- pinctrl-names : Property must contain "spi_default" and "spi_sleep" if
+  pinctrl is to be used.
+  instead of existing gpio mux hence gpio entries are no more required if present.
+- qcom,bam-consumer-pipe-index : BAM consumer-pipe index.
+- qcom,bam-producer-pipe-index : BAM producer-pipe index.
+- reg-names : register region names referenced in reg.
+	Required register resource for BAM are:
+	"spi_bam_physical" : Physical address of BAM for this controller.
+- interrupt-names : interrupt resource names referenced in interrupts.
+	Required interrupt resource from BAM are:
+	"spi_bam_irq" : BAM interrupt used by the controller.
+
+Optional SPI slave nodes must be children of the SPI master node and contain
+the following properties.
+- reg: (required) chip-select address of the device.
+- compatible : (required) Name of SPI device following generic names.
+- spi-max-frequency : (required) Maximum SPI clocking speed of device in Hz
+- interrupts : (recommended) Should contain the SPI slave interrupt number
+  encoded depending on the type of the interrupt controller.
+- interrupt-parent : (recommended) The phandle for the interrupt controller
+  that services interrupts for this device.
+- spi-cpol : (optional) Empty property indicating device requires inverse
+  clock polarity (CPOL) mode
+- spi-cpha : (optional) Empty property indicating device requires shifted
+  clock phase (CPHA) mode
+- spi-cs-high : (optional) Empty property indicating device requires
+  chip select active high
+
+Example:
+	aliases {
+		spi0 = &spi_0;
+	};
+
+	spi_0: spi@f9923000 {
+		compatible = "qcom,spi-qup-v2";
+
+		reg-names = "spi_physical", "spi_bam_physical";
+		reg = <0xf9923000 0x1000>,
+			<0xf9904000 0x10000>;
+		interrupt-names = "spi_irq", "spi_bam_irq";
+		interrupts = <0 95 0>, <0 238 0>;
+
+		spi-max-frequency = <19200000>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		qcom,gpio-mosi = <&msmgpio 0 0>;
+		qcom,gpio-miso = <&msmgpio 1 0>;
+		qcom,gpio-clk  = <&msmgpio 3 0>;
+		qcom,gpio-cs2  = <&msmgpio 9 0>;
+
+		qcom,infinite-mode = <0>;
+		qcom,use-bam;
+		qcom,use-pinctrl;
+		qcom,bam-consumer-pipe-index = <12>;
+		qcom,bam-producer-pipe-index = <13>;
+		qcom,ver-reg-exists;
+		qcom,master-id = <86>;
+		qcom,rt-priority;
+	};
diff --git a/Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt b/Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt
index bef9193..c50d678 100644
--- a/Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt
+++ b/Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt
@@ -42,6 +42,11 @@
     cell 4: interrupt flags indicating level-sense information, as defined in
             dt-bindings/interrupt-controller/irq.h
 
+Optional properties:
+- qcom,enable-ahb-bus-workaround : Boolean flag which indicates that the AHB bus
+				   workaround sequence should be used for SPMI
+				   write transactions to avoid corruption
+
 Example V1 PMIC-Arbiter:
 
 	spmi {
diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
index 123a65b..794d279 100644
--- a/Documentation/devicetree/bindings/thermal/thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal.txt
@@ -187,6 +187,10 @@
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
+- disable-thermal-zone: Disable the thermal zone monitoring by default. These
+  Type:bool		thermal zones will be enabled by userspace daemons
+			based on usecase.
+
 - tracks-low:		Indicates that the temperature sensor tracks the low
   Type: bool		thresholds, so the governors may mitigate by ensuring
 			timing closures and other low temperature operating
diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 4901fa0..c3e2cab 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -23,6 +23,8 @@
                           with "phys" attribute, provides phandle to UFS PHY node
 - vdd-hba-supply        : phandle to UFS host controller supply regulator node
 - vcc-supply            : phandle to VCC supply regulator node
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max), units uV.
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range is 1.7-1.95V
diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
index 609d853..6838afd 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -58,6 +58,7 @@
 	gating. Default it is enabled.
  - snps,xhci-imod-value: Interrupt moderation interval for host mode
 	(in increments of 250nsec).
+ - usb-core-id: Differentiates between different controllers present on a device.
 
 This is usually a subnode to DWC3 glue to which it is connected.
 
diff --git a/Documentation/devicetree/bindings/usb/msm-phy.txt b/Documentation/devicetree/bindings/usb/msm-phy.txt
index 6109fad..d23cb46 100644
--- a/Documentation/devicetree/bindings/usb/msm-phy.txt
+++ b/Documentation/devicetree/bindings/usb/msm-phy.txt
@@ -159,6 +159,7 @@
    "efuse_addr": EFUSE address to read and update analog tune parameter.
    "emu_phy_base" : phy base address used for programming emulation target phy.
    "ref_clk_addr" : ref_clk bcr address used for on/off ref_clk before reset.
+   "eud_base" : EUD device register address space to use EUD pet functionality.
  - clocks: a list of phandles to the PHY clocks. Use as per
    Documentation/devicetree/bindings/clock/clock-bindings.txt
  - clock-names: Names of the clocks in 1-1 correspondence with the "clocks"
diff --git a/Makefile b/Makefile
index 5894331..665104d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 9
-SUBLEVEL = 40
+SUBLEVEL = 51
 EXTRAVERSION =
 NAME = Roaring Lionus
 
diff --git a/arch/alpha/include/asm/types.h b/arch/alpha/include/asm/types.h
index 4cb4b6d..0bc66e1 100644
--- a/arch/alpha/include/asm/types.h
+++ b/arch/alpha/include/asm/types.h
@@ -1,6 +1,6 @@
 #ifndef _ALPHA_TYPES_H
 #define _ALPHA_TYPES_H
 
-#include <asm-generic/int-ll64.h>
+#include <uapi/asm/types.h>
 
 #endif /* _ALPHA_TYPES_H */
diff --git a/arch/alpha/include/uapi/asm/types.h b/arch/alpha/include/uapi/asm/types.h
index 9fd3cd4..8d1024d 100644
--- a/arch/alpha/include/uapi/asm/types.h
+++ b/arch/alpha/include/uapi/asm/types.h
@@ -9,8 +9,18 @@
  * need to be careful to avoid a name clashes.
  */
 
-#ifndef __KERNEL__
+/*
+ * This is here because we used to use l64 for alpha
+ * and we don't want to impact user mode with our change to ll64
+ * in the kernel.
+ *
+ * However, some user programs are fine with this.  They can
+ * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
+ */
+#if !defined(__SANE_USERSPACE_TYPES__) && !defined(__KERNEL__)
 #include <asm-generic/int-l64.h>
+#else
+#include <asm-generic/int-ll64.h>
 #endif
 
 #endif /* _UAPI_ALPHA_TYPES_H */
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index b3410ff..4fd6272 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -89,7 +89,9 @@
 #define ARC_REG_SLC_FLUSH	0x904
 #define ARC_REG_SLC_INVALIDATE	0x905
 #define ARC_REG_SLC_RGN_START	0x914
+#define ARC_REG_SLC_RGN_START1	0x915
 #define ARC_REG_SLC_RGN_END	0x916
+#define ARC_REG_SLC_RGN_END1	0x917
 
 /* Bit val in SLC_CONTROL */
 #define SLC_CTRL_IM		0x040
diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c
index f39142a..be131b2 100644
--- a/arch/arc/kernel/mcip.c
+++ b/arch/arc/kernel/mcip.c
@@ -10,6 +10,7 @@
 
 #include <linux/smp.h>
 #include <linux/irq.h>
+#include <linux/irqchip/chained_irq.h>
 #include <linux/spinlock.h>
 #include <asm/irqflags-arcv2.h>
 #include <asm/mcip.h>
@@ -221,10 +222,13 @@
 static void idu_cascade_isr(struct irq_desc *desc)
 {
 	struct irq_domain *idu_domain = irq_desc_get_handler_data(desc);
+	struct irq_chip *core_chip = irq_desc_get_chip(desc);
 	irq_hw_number_t core_hwirq = irqd_to_hwirq(irq_desc_get_irq_data(desc));
 	irq_hw_number_t idu_hwirq = core_hwirq - idu_first_hwirq;
 
+	chained_irq_enter(core_chip, desc);
 	generic_handle_irq(irq_find_mapping(idu_domain, idu_hwirq));
+	chained_irq_exit(core_chip, desc);
 }
 
 static int idu_irq_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq)
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 8147583..bbdfeb3 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -562,6 +562,7 @@
 	static DEFINE_SPINLOCK(lock);
 	unsigned long flags;
 	unsigned int ctrl;
+	phys_addr_t end;
 
 	spin_lock_irqsave(&lock, flags);
 
@@ -591,8 +592,16 @@
 	 * END needs to be setup before START (latter triggers the operation)
 	 * END can't be same as START, so add (l2_line_sz - 1) to sz
 	 */
-	write_aux_reg(ARC_REG_SLC_RGN_END, (paddr + sz + l2_line_sz - 1));
-	write_aux_reg(ARC_REG_SLC_RGN_START, paddr);
+	end = paddr + sz + l2_line_sz - 1;
+	if (is_pae40_enabled())
+		write_aux_reg(ARC_REG_SLC_RGN_END1, upper_32_bits(end));
+
+	write_aux_reg(ARC_REG_SLC_RGN_END, lower_32_bits(end));
+
+	if (is_pae40_enabled())
+		write_aux_reg(ARC_REG_SLC_RGN_START1, upper_32_bits(paddr));
+
+	write_aux_reg(ARC_REG_SLC_RGN_START, lower_32_bits(paddr));
 
 	while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY);
 
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index cf61b80..9ce6b7f 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -62,6 +62,10 @@
 	      8 - SIGSEGV faults
 	     16 - SIGBUS faults
 
+config ARCH_SUPPORTS_DEBUG_PAGEALLOC
+	def_bool y
+	depends on FORCE_PAGES
+
 config FORCE_PAGES
 	bool "Force lowmem to be mapped with 4K pages"
         help
diff --git a/arch/arm/boot/dts/am57xx-idk-common.dtsi b/arch/arm/boot/dts/am57xx-idk-common.dtsi
index 03cec62..db858ff 100644
--- a/arch/arm/boot/dts/am57xx-idk-common.dtsi
+++ b/arch/arm/boot/dts/am57xx-idk-common.dtsi
@@ -294,7 +294,7 @@
 };
 
 &usb2 {
-	dr_mode = "otg";
+	dr_mode = "peripheral";
 };
 
 &mmc2 {
diff --git a/arch/arm/boot/dts/armada-388-gp.dts b/arch/arm/boot/dts/armada-388-gp.dts
index 895fa6c..563901e 100644
--- a/arch/arm/boot/dts/armada-388-gp.dts
+++ b/arch/arm/boot/dts/armada-388-gp.dts
@@ -75,7 +75,7 @@
 					pinctrl-names = "default";
 					pinctrl-0 = <&pca0_pins>;
 					interrupt-parent = <&gpio0>;
-					interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
+					interrupts = <18 IRQ_TYPE_LEVEL_LOW>;
 					gpio-controller;
 					#gpio-cells = <2>;
 					interrupt-controller;
@@ -87,7 +87,7 @@
 					compatible = "nxp,pca9555";
 					pinctrl-names = "default";
 					interrupt-parent = <&gpio0>;
-					interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
+					interrupts = <18 IRQ_TYPE_LEVEL_LOW>;
 					gpio-controller;
 					#gpio-cells = <2>;
 					interrupt-controller;
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 87ca50b..4d448f1 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -734,6 +734,8 @@
 	vmmc_aux-supply = <&vsim>;
 	bus-width = <8>;
 	non-removable;
+	no-sdio;
+	no-sd;
 };
 
 &mmc3 {
diff --git a/arch/arm/boot/dts/qcom/pmxpoorwills.dtsi b/arch/arm/boot/dts/qcom/pmxpoorwills.dtsi
new file mode 100644
index 0000000..a3df1f4
--- /dev/null
+++ b/arch/arm/boot/dts/qcom/pmxpoorwills.dtsi
@@ -0,0 +1,62 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <dt-bindings/spmi/spmi.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+
+&spmi_bus {
+	qcom,pmxpoorwills@0 {
+		compatible = "qcom,spmi-pmic";
+		reg = <0x0 SPMI_USID>;
+		#address-cells = <2>;
+		#size-cells = <0>;
+
+		pmxpoorwills_revid: qcom,revid@100 {
+			compatible = "qcom,qpnp-revid";
+			reg = <0x100 0x100>;
+		};
+
+		qcom,power-on@800 {
+			compatible = "qcom,qpnp-power-on";
+			reg = <0x800 0x100>;
+			interrupts = <0x0 0x8 0x0 IRQ_TYPE_NONE>,
+				     <0x0 0x8 0x1 IRQ_TYPE_NONE>,
+				     <0x0 0x8 0x4 IRQ_TYPE_NONE>,
+				     <0x0 0x8 0x5 IRQ_TYPE_NONE>;
+			interrupt-names = "kpdpwr", "resin",
+					"resin-bark", "kpdpwr-resin-bark";
+			qcom,pon-dbc-delay = <15625>;
+			qcom,kpdpwr-sw-debounce;
+			qcom,system-reset;
+			qcom,store-hard-reset-reason;
+
+			qcom,pon_1 {
+				qcom,pon-type = <0>;
+				qcom,pull-up = <1>;
+				linux,code = <116>;
+			};
+
+			qcom,pon_2 {
+				qcom,pon-type = <1>;
+				qcom,pull-up = <1>;
+				linux,code = <114>;
+			};
+		};
+	};
+
+	qcom,pmxpoorwills@1 {
+		compatible ="qcom,spmi-pmic";
+		reg = <0x1 SPMI_USID>;
+		#address-cells = <2>;
+		#size-cells = <0>;
+	};
+};
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills-smp2p.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills-smp2p.dtsi
new file mode 100644
index 0000000..f9ad6f4
--- /dev/null
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills-smp2p.dtsi
@@ -0,0 +1,109 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+&soc {
+	qcom,smp2p-modem@17811008 {
+		compatible = "qcom,smp2p";
+		reg = <0x17811008 0x4>;
+		qcom,remote-pid = <1>;
+		qcom,irq-bitmask = <0x4000>;
+		interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
+	};
+
+	smp2pgpio_smp2p_15_in: qcom,smp2pgpio-smp2p-15-in {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "smp2p";
+		qcom,remote-pid = <15>;
+		qcom,is-inbound;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
+	qcom,smp2pgpio_test_smp2p_15_in {
+		compatible = "qcom,smp2pgpio_test_smp2p_15_in";
+		gpios = <&smp2pgpio_smp2p_15_in 0 0>;
+	};
+
+	smp2pgpio_smp2p_15_out: qcom,smp2pgpio-smp2p-15-out {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "smp2p";
+		qcom,remote-pid = <15>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
+	qcom,smp2pgpio_test_smp2p_15_out {
+		compatible = "qcom,smp2pgpio_test_smp2p_15_out";
+		gpios = <&smp2pgpio_smp2p_15_out 0 0>;
+	};
+
+	smp2pgpio_smp2p_1_in: qcom,smp2pgpio-smp2p-1-in {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "smp2p";
+		qcom,remote-pid = <1>;
+		qcom,is-inbound;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
+	qcom,smp2pgpio_test_smp2p_1_in {
+		compatible = "qcom,smp2pgpio_test_smp2p_1_in";
+		gpios = <&smp2pgpio_smp2p_1_in 0 0>;
+	};
+
+	smp2pgpio_smp2p_1_out: qcom,smp2pgpio-smp2p-1-out {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "smp2p";
+		qcom,remote-pid = <1>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
+	qcom,smp2pgpio_test_smp2p_1_out {
+		compatible = "qcom,smp2pgpio_test_smp2p_1_out";
+		gpios = <&smp2pgpio_smp2p_1_out 0 0>;
+	};
+
+	/* ssr - inbound entry from mss */
+	smp2pgpio_ssr_smp2p_1_in: qcom,smp2pgpio-ssr-smp2p-1-in {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "slave-kernel";
+		qcom,remote-pid = <1>;
+		qcom,is-inbound;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+
+	/* ssr - outbound entry to mss */
+	smp2pgpio_ssr_smp2p_1_out: qcom,smp2pgpio-ssr-smp2p-1-out {
+		compatible = "qcom,smp2pgpio";
+		qcom,entry-name = "master-kernel";
+		qcom,remote-pid = <1>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
+};
+
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
index e8d8f9a..d538efe 100644
--- a/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
@@ -34,6 +34,13 @@
 			reg = <0x8fd00000 0x300000>;
 			label = "peripheral2_mem";
 		};
+
+		mss_mem: mss_region@87800000 {
+			compatible = "removed-dma-pool";
+			no-map;
+			reg = <0x87800000 0x8000000>;
+			label = "mss_mem";
+		};
 	};
 
 	cpus {
@@ -175,6 +182,11 @@
 		status = "ok";
 	};
 
+	qcom,sps {
+		compatible = "qcom,msm_sps_4k";
+		qcom,pipe-attr-ee;
+	};
+
 	gdsc_pcie: qcom,gdsc@137004 {
 		compatible = "qcom,gdsc";
 		regulator-name = "gdsc_pcie";
@@ -319,7 +331,134 @@
 		#interrupt-cells = <4>;
 		cell-index = <0>;
 	};
+
+	qcom,ipc-spinlock@1f40000 {
+		compatible = "qcom,ipc-spinlock-sfpb";
+		reg = <0x1f40000 0x8000>;
+		qcom,num-locks = <8>;
+	};
+
+	qcom,smem@8fe40000 {
+		compatible = "qcom,smem";
+		reg = <0x8fe40000 0xc0000>,
+			<0x17811008 0x4>,
+			<0x1fd4000 0x8>;
+		reg-names = "smem", "irq-reg-base",
+			"smem_targ_info_reg";
+		qcom,mpu-enabled;
+	};
+
+	qcom,glink-smem-native-xprt-modem@8fe40000 {
+		compatible = "qcom,glink-smem-native-xprt";
+		reg = <0x8fe40000 0xc0000>,
+			<0x17811008 0x4>;
+		reg-names = "smem", "irq-reg-base";
+		qcom,irq-mask = <0x1000>;
+		interrupts = <GIC_SPI 111 IRQ_TYPE_EDGE_RISING>;
+		label = "mpss";
+	};
+
+	qcom,ipc_router {
+		compatible = "qcom,ipc_router";
+		qcom,node-id = <1>;
+	};
+
+	qcom,ipc_router_modem_xprt {
+		compatible = "qcom,ipc_router_glink_xprt";
+		qcom,ch-name = "IPCRTR";
+		qcom,xprt-remote = "mpss";
+		qcom,glink-xprt = "smem";
+		qcom,xprt-linkid = <1>;
+		qcom,xprt-version = <1>;
+		qcom,fragmented-data;
+	};
+
+	qcom,glink_pkt {
+		compatible = "qcom,glinkpkt";
+
+		qcom,glinkpkt-at-mdm0 {
+			qcom,glinkpkt-transport = "smem";
+			qcom,glinkpkt-edge = "mpss";
+			qcom,glinkpkt-ch-name = "DS";
+			qcom,glinkpkt-dev-name = "at_mdm0";
+		};
+
+		qcom,glinkpkt-loopback_cntl {
+			qcom,glinkpkt-transport = "lloop";
+			qcom,glinkpkt-edge = "local";
+			qcom,glinkpkt-ch-name = "LOCAL_LOOPBACK_CLNT";
+			qcom,glinkpkt-dev-name = "glink_pkt_loopback_ctrl";
+		};
+
+		qcom,glinkpkt-loopback_data {
+			qcom,glinkpkt-transport = "lloop";
+			qcom,glinkpkt-edge = "local";
+			qcom,glinkpkt-ch-name = "glink_pkt_lloop_CLNT";
+			qcom,glinkpkt-dev-name = "glink_pkt_loopback";
+		};
+
+		qcom,glinkpkt-data40-cntl {
+			qcom,glinkpkt-transport = "smem";
+			qcom,glinkpkt-edge = "mpss";
+			qcom,glinkpkt-ch-name = "DATA40_CNTL";
+			qcom,glinkpkt-dev-name = "smdcntl8";
+		};
+
+		qcom,glinkpkt-data1 {
+			qcom,glinkpkt-transport = "smem";
+			qcom,glinkpkt-edge = "mpss";
+			qcom,glinkpkt-ch-name = "DATA1";
+			qcom,glinkpkt-dev-name = "smd7";
+		};
+
+		qcom,glinkpkt-data4 {
+			qcom,glinkpkt-transport = "smem";
+			qcom,glinkpkt-edge = "mpss";
+			qcom,glinkpkt-ch-name = "DATA4";
+			qcom,glinkpkt-dev-name = "smd8";
+		};
+
+		qcom,glinkpkt-data11 {
+			qcom,glinkpkt-transport = "smem";
+			qcom,glinkpkt-edge = "mpss";
+			qcom,glinkpkt-ch-name = "DATA11";
+			qcom,glinkpkt-dev-name = "smd11";
+		};
+	};
+
+	pil_modem: qcom,mss@4080000 {
+		compatible = "qcom,pil-tz-generic";
+		reg = <0x4080000 0x100>;
+		interrupts = <0 250 1>;
+
+		clocks = <&clock_rpmh RPMH_CXO_CLK>;
+		clock-names = "xo";
+		qcom,proxy-clock-names = "xo";
+
+		vdd_cx-supply = <&pmxpoorwills_s5_level>;
+		qcom,proxy-reg-names = "vdd_cx";
+
+		qcom,pas-id = <0>;
+		qcom,smem-id = <421>;
+		qcom,proxy-timeout-ms = <10000>;
+		qcom,sysmon-id = <0>;
+		qcom,ssctl-instance-id = <0x12>;
+		qcom,firmware-name = "modem";
+		memory-region = <&mss_mem>;
+		status = "ok";
+
+		/* GPIO inputs from mss */
+		qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
+		qcom,gpio-err-ready = <&smp2pgpio_ssr_smp2p_1_in 1 0>;
+		qcom,gpio-proxy-unvote = <&smp2pgpio_ssr_smp2p_1_in 2 0>;
+		qcom,gpio-stop-ack = <&smp2pgpio_ssr_smp2p_1_in 3 0>;
+
+		/* GPIO output to mss */
+		qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_1_out 0 0>;
+	};
 };
 
+#include "pmxpoorwills.dtsi"
 #include "sdxpoorwills-regulator.dtsi"
+#include "sdxpoorwills-smp2p.dtsi"
 #include "sdxpoorwills-usb.dtsi"
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
index 5ea4915..10d3074 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
@@ -56,7 +56,7 @@
 };
 
 &pio {
-	mmc2_pins_nrst: mmc2@0 {
+	mmc2_pins_nrst: mmc2-rst-pin {
 		allwinner,pins = "PC16";
 		allwinner,function = "gpio_out";
 		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
diff --git a/arch/arm/boot/dts/tango4-vantage-1172.dts b/arch/arm/boot/dts/tango4-vantage-1172.dts
index 4cab64c..e3a51e3 100644
--- a/arch/arm/boot/dts/tango4-vantage-1172.dts
+++ b/arch/arm/boot/dts/tango4-vantage-1172.dts
@@ -21,7 +21,7 @@
 };
 
 &eth0 {
-	phy-connection-type = "rgmii";
+	phy-connection-type = "rgmii-id";
 	phy-handle = <&eth0_phy>;
 	#address-cells = <1>;
 	#size-cells = <0>;
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index bc4bfe0..60d3fec 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -86,9 +86,9 @@
 CONFIG_NETFILTER=y
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_EVENTS=y
-CONFIG_NF_CT_PROTO_DCCP=m
-CONFIG_NF_CT_PROTO_SCTP=m
-CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CT_PROTO_DCCP=y
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
 CONFIG_NF_CONNTRACK_AMANDA=m
 CONFIG_NF_CONNTRACK_FTP=m
 CONFIG_NF_CONNTRACK_H323=m
diff --git a/arch/arm/configs/sdxpoorwills-perf_defconfig b/arch/arm/configs/sdxpoorwills-perf_defconfig
index 62d287a..2765e20 100644
--- a/arch/arm/configs/sdxpoorwills-perf_defconfig
+++ b/arch/arm/configs/sdxpoorwills-perf_defconfig
@@ -195,10 +195,11 @@
 CONFIG_INPUT_GPIO=m
 CONFIG_SERIO_LIBPS2=y
 # CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_MSM_HS=y
+CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
-CONFIG_SOUNDWIRE=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_SPIDEV=m
@@ -277,13 +278,19 @@
 CONFIG_SPS_SUPPORT_NDP_BAM=y
 CONFIG_USB_BAM=y
 CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MAILBOX=y
 CONFIG_QCOM_SCM=y
 CONFIG_MSM_BOOT_STATS=y
 CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
 CONFIG_TRACER_PKT=y
 CONFIG_MSM_SMP2P=y
 CONFIG_MSM_SMP2P_TEST=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
 CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
 CONFIG_MSM_SUBSYSTEM_RESTART=y
 CONFIG_MSM_PIL=y
 CONFIG_MSM_PIL_SSR_GENERIC=y
diff --git a/arch/arm/configs/sdxpoorwills_defconfig b/arch/arm/configs/sdxpoorwills_defconfig
index f3b00244..1062175 100644
--- a/arch/arm/configs/sdxpoorwills_defconfig
+++ b/arch/arm/configs/sdxpoorwills_defconfig
@@ -189,11 +189,14 @@
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_SERIAL_MSM=y
 CONFIG_SERIAL_MSM_CONSOLE=y
+CONFIG_SERIAL_MSM_HS=y
+CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
-CONFIG_SOUNDWIRE=y
+CONFIG_I2C_MSM_V2=y
 CONFIG_SPI=y
+CONFIG_SPI_QUP=y
 CONFIG_SPI_SPIDEV=m
 CONFIG_SLIMBUS=y
 CONFIG_PINCTRL_SDXPOORWILLS=y
@@ -203,6 +206,7 @@
 CONFIG_POWER_SUPPLY=y
 CONFIG_THERMAL=y
 CONFIG_THERMAL_TSENS=y
+CONFIG_MFD_SYSCON=y
 CONFIG_MSM_CDC_PINCTRL=y
 CONFIG_MSM_CDC_SUPPLY=y
 CONFIG_REGULATOR=y
@@ -260,6 +264,7 @@
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_RTC_CLASS=y
 CONFIG_DMADEVICES=y
+CONFIG_QCOM_SPS_DMA=y
 CONFIG_UIO=y
 CONFIG_STAGING=y
 CONFIG_GSI=y
@@ -270,13 +275,20 @@
 CONFIG_IPA_UT=y
 CONFIG_SPS=y
 CONFIG_SPS_SUPPORT_NDP_BAM=y
-CONFIG_HWSPINLOCK_QCOM=y
-CONFIG_QCOM_SMEM=y
-CONFIG_QCOM_SMD=y
+CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MAILBOX=y
 CONFIG_QCOM_SCM=y
 CONFIG_MSM_BOOT_STATS=y
+CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
 CONFIG_TRACER_PKT=y
+CONFIG_MSM_SMP2P=y
+CONFIG_MSM_SMP2P_TEST=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
 CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
 CONFIG_MSM_SUBSYSTEM_RESTART=y
 CONFIG_MSM_PIL=y
 CONFIG_MSM_PIL_SSR_GENERIC=y
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
index bfe2a2f..22b7311 100644
--- a/arch/arm/include/asm/ftrace.h
+++ b/arch/arm/include/asm/ftrace.h
@@ -54,6 +54,24 @@
 
 #define ftrace_return_address(n) return_address(n)
 
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+					       const char *name)
+{
+	if (!strcmp(sym, "sys_mmap2"))
+		sym = "sys_mmap_pgoff";
+	else if (!strcmp(sym, "sys_statfs64_wrapper"))
+		sym = "sys_statfs64";
+	else if (!strcmp(sym, "sys_fstatfs64_wrapper"))
+		sym = "sys_fstatfs64";
+	else if (!strcmp(sym, "sys_arm_fadvise64_64"))
+		sym = "sys_fadvise64_64";
+
+	/* Ignore case since sym may start with "SyS" instead of "sys" */
+	return !strcasecmp(sym, name);
+}
+
 #endif /* ifndef __ASSEMBLY__ */
 
 #endif /* _ASM_ARM_FTRACE */
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 332ce3b..2206e0e 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -829,22 +829,22 @@
  * Walks the level-1 page table pointed to by kvm->arch.pgd and frees all
  * underlying level-2 and level-3 tables before freeing the actual level-1 table
  * and setting the struct pointer to NULL.
- *
- * Note we don't need locking here as this is only called when the VM is
- * destroyed, which can only be done once.
  */
 void kvm_free_stage2_pgd(struct kvm *kvm)
 {
-	if (kvm->arch.pgd == NULL)
-		return;
+	void *pgd = NULL;
 
 	spin_lock(&kvm->mmu_lock);
-	unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
+	if (kvm->arch.pgd) {
+		unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
+		pgd = READ_ONCE(kvm->arch.pgd);
+		kvm->arch.pgd = NULL;
+	}
 	spin_unlock(&kvm->mmu_lock);
 
 	/* Free the HW pgd, one page at a time */
-	free_pages_exact(kvm->arch.pgd, S2_PGD_SIZE);
-	kvm->arch.pgd = NULL;
+	if (pgd)
+		free_pages_exact(pgd, S2_PGD_SIZE);
 }
 
 static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
@@ -1664,12 +1664,16 @@
 
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end)
 {
+	if (!kvm->arch.pgd)
+		return 0;
 	trace_kvm_age_hva(start, end);
 	return handle_hva_to_gpa(kvm, start, end, kvm_age_hva_handler, NULL);
 }
 
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
 {
+	if (!kvm->arch.pgd)
+		return 0;
 	trace_kvm_test_age_hva(hva);
 	return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, NULL);
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 1052b29..b5c1714 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -790,14 +790,14 @@
 	int ret = 0;
 	char name[MOD_CLK_MAX_NAME_LEN];
 	struct clk *clk;
+	static const char modck[] = "_mod_ck";
 
-	/* +7 magic comes from '_mod_ck' suffix */
-	if (strlen(oh->name) + 7 > MOD_CLK_MAX_NAME_LEN)
+	if (strlen(oh->name) >= MOD_CLK_MAX_NAME_LEN - strlen(modck))
 		pr_warn("%s: warning: cropping name for %s\n", __func__,
 			oh->name);
 
-	strncpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - 7);
-	strcat(name, "_mod_ck");
+	strlcpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - strlen(modck));
+	strlcat(name, modck, MOD_CLK_MAX_NAME_LEN);
 
 	clk = clk_get(NULL, name);
 	if (!IS_ERR(clk)) {
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index aec74bf..a9ef54d 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -314,8 +314,11 @@
 	 * signal first. We do not need to release the mmap_sem because
 	 * it would already be released in __lock_page_or_retry in
 	 * mm/filemap.c. */
-	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
+		if (!user_mode(regs))
+			goto no_context;
 		return 0;
+	}
 
 	/*
 	 * Major/minor page fault accounting is only done on the
diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c
index 0b26a84..47b1f478 100644
--- a/arch/arm/mm/pageattr.c
+++ b/arch/arm/mm/pageattr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014,2017 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -97,3 +97,19 @@
 					__pgprot(0),
 					__pgprot(L_PTE_XN));
 }
+
+#ifdef CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC
+void __kernel_map_pages(struct page *page, int numpages, int enable)
+{
+	unsigned long addr;
+
+	if (PageHighMem(page))
+		return;
+
+	addr = (unsigned long) page_address(page);
+	if (enable)
+		set_memory_rw(addr, numpages);
+	else
+		set_memory_ro(addr, numpages);
+}
+#endif
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index f96fba6..e1454fb 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -139,6 +139,15 @@
 	  This enables support for the SDM670 chipset. If you do not
 	  wish to build a kernel that runs on this chipset, say 'N' here.
 
+config ARCH_MSM8953
+	bool "Enable Support for Qualcomm Technologies Inc. MSM8953"
+	depends on ARCH_QCOM
+	select COMMON_CLK_QCOM
+	select QCOM_GDSC
+	help
+	  This enables support for the MSM8953 chipset. If you do not
+	  wish to build a kernel that runs on this chipset, say 'N' here.
+
 config ARCH_ROCKCHIP
 	bool "Rockchip Platforms"
 	select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index 49a5d8c..68e6f88 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -170,6 +170,7 @@
 				interrupt-controller;
 				reg = <0x1d00000 0x10000>, /* GICD */
 				      <0x1d40000 0x40000>; /* GICR */
+				interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>;
 			};
 		};
 
diff --git a/arch/arm64/boot/dts/qcom/Makefile b/arch/arm64/boot/dts/qcom/Makefile
index b37c377..aefdb52 100644
--- a/arch/arm64/boot/dts/qcom/Makefile
+++ b/arch/arm64/boot/dts/qcom/Makefile
@@ -8,27 +8,54 @@
 		sdm845-mtp-overlay.dtbo \
 		sdm845-qrd-overlay.dtbo \
 		sdm845-qvr-overlay.dtbo \
-		sdm845-v2-cdp-overlay.dtbo \
-		sdm845-v2-mtp-overlay.dtbo \
-		sdm845-v2-qrd-overlay.dtbo \
 		sdm845-4k-panel-mtp-overlay.dtbo \
 		sdm845-4k-panel-cdp-overlay.dtbo \
 		sdm845-4k-panel-qrd-overlay.dtbo \
-		sdm845-interposer-sdm670-cdp-overlay.dtbo \
-		sdm845-interposer-sdm670-mtp-overlay.dtbo
+		sdm845-v2-cdp-overlay.dtbo \
+		sdm845-v2-mtp-overlay.dtbo \
+		sdm845-v2-qrd-overlay.dtbo \
+		sdm845-v2-4k-panel-mtp-overlay.dtbo \
+		sdm845-v2-4k-panel-cdp-overlay.dtbo \
+		sdm845-v2-4k-panel-qrd-overlay.dtbo \
+		sda845-cdp-overlay.dtbo \
+		sda845-mtp-overlay.dtbo \
+		sda845-qrd-overlay.dtbo \
+		sda845-4k-panel-mtp-overlay.dtbo \
+		sda845-4k-panel-cdp-overlay.dtbo \
+		sda845-4k-panel-qrd-overlay.dtbo \
+		sda845-v2-cdp-overlay.dtbo \
+		sda845-v2-mtp-overlay.dtbo \
+		sda845-v2-qrd-overlay.dtbo \
+		sda845-v2-4k-panel-mtp-overlay.dtbo \
+		sda845-v2-4k-panel-cdp-overlay.dtbo \
+		sda845-v2-4k-panel-qrd-overlay.dtbo
 
 sdm845-cdp-overlay.dtbo-base := sdm845.dtb
 sdm845-mtp-overlay.dtbo-base := sdm845.dtb
 sdm845-qrd-overlay.dtbo-base := sdm845.dtb
+sdm845-qvr-overlay.dtbo-base := sdm845-v2.dtb
 sdm845-qvr-overlay.dtbo-base := sdm845.dtb
-sdm845-v2-cdp-overlay.dtbo-base := sdm845-v2.dtb
-sdm845-v2-mtp-overlay.dtbo-base := sdm845-v2.dtb
-sdm845-v2-qrd-overlay.dtbo-base := sdm845-v2.dtb
 sdm845-4k-panel-mtp-overlay.dtbo-base := sdm845.dtb
 sdm845-4k-panel-cdp-overlay.dtbo-base := sdm845.dtb
 sdm845-4k-panel-qrd-overlay.dtbo-base := sdm845.dtb
-sdm845-interposer-sdm670-cdp-overlay.dtbo-base := sdm845-interposer-sdm670.dtb
-sdm845-interposer-sdm670-mtp-overlay.dtbo-base := sdm845-interposer-sdm670.dtb
+sdm845-v2-cdp-overlay.dtbo-base := sdm845-v2.dtb
+sdm845-v2-mtp-overlay.dtbo-base := sdm845-v2.dtb
+sdm845-v2-qrd-overlay.dtbo-base := sdm845-v2.dtb
+sdm845-v2-4k-panel-mtp-overlay.dtbo-base := sdm845-v2.dtb
+sdm845-v2-4k-panel-cdp-overlay.dtbo-base := sdm845-v2.dtb
+sdm845-v2-4k-panel-qrd-overlay.dtbo-base := sdm845-v2.dtb
+sda845-cdp-overlay.dtbo-base := sda845.dtb
+sda845-mtp-overlay.dtbo-base := sda845.dtb
+sda845-qrd-overlay.dtbo-base := sda845.dtb
+sda845-4k-panel-mtp-overlay.dtbo-base := sda845.dtb
+sda845-4k-panel-cdp-overlay.dtbo-base := sda845.dtb
+sda845-4k-panel-qrd-overlay.dtbo-base := sda845.dtb
+sda845-v2-cdp-overlay.dtbo-base := sda845-v2.dtb
+sda845-v2-mtp-overlay.dtbo-base := sda845-v2.dtb
+sda845-v2-qrd-overlay.dtbo-base := sda845-v2.dtb
+sda845-v2-4k-panel-mtp-overlay.dtbo-base := sda845-v2.dtb
+sda845-v2-4k-panel-cdp-overlay.dtbo-base := sda845-v2.dtb
+sda845-v2-4k-panel-qrd-overlay.dtbo-base := sda845-v2.dtb
 else
 dtb-$(CONFIG_ARCH_SDM845) += sdm845-sim.dtb \
 	sdm845-rumi.dtb \
@@ -50,14 +77,85 @@
 ifeq ($(CONFIG_BUILD_ARM64_DT_OVERLAY),y)
 	dtbo-$(CONFIG_ARCH_SDM670) += \
 		sdm670-cdp-overlay.dtbo \
-		sdm670-mtp-overlay.dtbo
+		sdm670-mtp-overlay.dtbo \
+		sdm670-rumi-overlay.dtbo \
+		sdm670-pm660a-cdp-overlay.dtbo \
+		sdm670-pm660a-mtp-overlay.dtbo \
+		sdm670-external-codec-cdp-overlay.dtbo \
+		sdm670-external-codec-mtp-overlay.dtbo \
+		sdm670-external-codec-pm660a-cdp-overlay.dtbo \
+		sdm670-external-codec-pm660a-mtp-overlay.dtbo \
+		sdm670-usbc-cdp-overlay.dtbo \
+		sdm670-usbc-mtp-overlay.dtbo \
+		sdm670-usbc-pm660a-cdp-overlay.dtbo \
+		sdm670-usbc-pm660a-mtp-overlay.dtbo \
+		sdm670-usbc-external-codec-cdp-overlay.dtbo \
+		sdm670-usbc-external-codec-mtp-overlay.dtbo \
+		sdm670-usbc-external-codec-pm660a-cdp-overlay.dtbo \
+		sdm670-usbc-external-codec-pm660a-mtp-overlay.dtbo \
+		sda670-cdp-overlay.dtbo \
+		sda670-mtp-overlay.dtbo \
+		sda670-pm660a-cdp-overlay.dtbo \
+		sda670-pm660a-mtp-overlay.dtbo \
+		qcs605-cdp-overlay.dtbo \
+		qcs605-mtp-overlay.dtbo \
+		qcs605-external-codec-mtp-overlay.dtbo
 
 sdm670-cdp-overlay.dtbo-base := sdm670.dtb
 sdm670-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-rumi-overlay.dtbo-base := sdm670.dtb
+sdm670-pm660a-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-pm660a-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-external-codec-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-external-codec-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-external-codec-pm660a-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-external-codec-pm660a-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-pm660a-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-pm660a-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-external-codec-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-external-codec-mtp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-external-codec-pm660a-cdp-overlay.dtbo-base := sdm670.dtb
+sdm670-usbc-external-codec-pm660a-mtp-overlay.dtbo-base := sdm670.dtb
+sda670-cdp-overlay.dtbo-base := sda670.dtb
+sda670-mtp-overlay.dtbo-base := sda670.dtb
+sda670-pm660a-cdp-overlay.dtbo-base := sda670.dtb
+sda670-pm660a-mtp-overlay.dtbo-base := sda670.dtb
+qcs605-cdp-overlay.dtbo-base := qcs605.dtb
+qcs605-mtp-overlay.dtbo-base := qcs605.dtb
+qcs605-external-codec-mtp-overlay.dtbo-base := qcs605.dtb
+
 else
 dtb-$(CONFIG_ARCH_SDM670) += sdm670-rumi.dtb \
 	sdm670-mtp.dtb \
-	sdm670-cdp.dtb
+	sdm670-cdp.dtb \
+	sdm670-pm660a-mtp.dtb \
+	sdm670-pm660a-cdp.dtb \
+	sdm670-external-codec-cdp.dtb \
+	sdm670-external-codec-mtp.dtb \
+	sdm670-external-codec-pm660a-cdp.dtb \
+	sdm670-external-codec-pm660a-mtp.dtb \
+	sdm670-usbc-cdp.dtb \
+	sdm670-usbc-external-codec-cdp.dtb \
+	sdm670-usbc-external-codec-mtp.dtb \
+	sdm670-usbc-external-codec-pm660a-cdp.dtb \
+	sdm670-usbc-external-codec-pm660a-mtp.dtb \
+	sdm670-usbc-mtp.dtb \
+	sdm670-usbc-pm660a-cdp.dtb \
+	sdm670-usbc-pm660a-mtp.dtb \
+	sda670-mtp.dtb \
+	sda670-cdp.dtb \
+	sda670-pm660a-mtp.dtb \
+	sda670-pm660a-cdp.dtb \
+	qcs605-mtp.dtb \
+	qcs605-cdp.dtb \
+	qcs605-external-codec-mtp.dtb
+endif
+
+ifeq ($(CONFIG_BUILD_ARM64_DT_OVERLAY),y)
+else
+dtb-$(CONFIG_ARCH_MSM8953) += msm8953-mtp.dtb
 endif
 
 always		:= $(dtb-y)
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
index 0ca1175..0e60a0c 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
@@ -88,7 +88,7 @@
 					15 01 00 00 00 00 02 5d 81
 					15 01 00 00 00 00 02 5e 00
 					15 01 00 00 00 00 02 5f 01
-					15 01 00 00 00 00 02 72 31
+					15 01 00 00 00 00 02 72 11
 					15 01 00 00 00 00 02 68 03
 					/* CMD2_P4 */
 					15 01 00 00 00 00 02 ff 24
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-video.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-video.dtsi
index ac8a956..2c54504 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-video.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-video.dtsi
@@ -74,7 +74,7 @@
 					15 01 00 00 00 00 02 5d 81
 					15 01 00 00 00 00 02 5e 00
 					15 01 00 00 00 00 02 5f 01
-					15 01 00 00 00 00 02 72 31
+					15 01 00 00 00 00 02 72 11
 					15 01 00 00 00 00 02 68 03
 					/* CMD2_P4 */
 					15 01 00 00 00 00 02 ff 24
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
index 87cabae..5b5fbb8 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
@@ -89,7 +89,7 @@
 					15 01 00 00 00 00 02 5D 81
 					15 01 00 00 00 00 02 5E 00
 					15 01 00 00 00 00 02 5F 01
-					15 01 00 00 00 00 02 72 31
+					15 01 00 00 00 00 02 72 11
 					15 01 00 00 00 00 02 68 03
 					/* CMD2_P4 */
 					15 01 00 00 00 00 02 ff 24
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-video.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-video.dtsi
index 0d0e7f7..95e0e5a 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-video.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-video.dtsi
@@ -29,7 +29,6 @@
 		qcom,mdss-dsi-lane-1-state;
 		qcom,mdss-dsi-lane-2-state;
 		qcom,mdss-dsi-lane-3-state;
-		qcom,cmd-sync-wait-broadcast;
 		qcom,mdss-dsi-dma-trigger = "trigger_sw";
 		qcom,mdss-dsi-mdp-trigger = "none";
 		qcom,mdss-dsi-reset-sequence = <1 20>, <0 20>, <1 50>;
@@ -76,7 +75,7 @@
 					15 01 00 00 00 00 02 5D 81
 					15 01 00 00 00 00 02 5E 00
 					15 01 00 00 00 00 02 5F 01
-					15 01 00 00 00 00 02 72 31
+					15 01 00 00 00 00 02 72 11
 					15 01 00 00 00 00 02 68 03
 					/* CMD2_P4 */
 					15 01 00 00 00 00 02 FF 24
diff --git a/arch/arm64/boot/dts/qcom/fg-gen3-batterydata-ascent-3450mah.dtsi b/arch/arm64/boot/dts/qcom/fg-gen3-batterydata-ascent-3450mah.dtsi
index c7cecbc..7705d01 100644
--- a/arch/arm64/boot/dts/qcom/fg-gen3-batterydata-ascent-3450mah.dtsi
+++ b/arch/arm64/boot/dts/qcom/fg-gen3-batterydata-ascent-3450mah.dtsi
@@ -11,71 +11,71 @@
  */
 
 qcom,ascent_3450mah {
-	/* Ascent_with_connector_3450mAh_averaged_MasterSlave_Jan6th2017 */
+	/* Ascent_wConn_Aging_3450mAh_averaged_MasterSlave_Jul11th2017 */
 	qcom,max-voltage-uv = <4350000>;
 	qcom,fg-cc-cv-threshold-mv = <4340>;
 	qcom,fastchg-current-ma = <3450>;
 	qcom,batt-id-kohm = <60>;
 	qcom,battery-beta = <3435>;
-	qcom,battery-type = "ascent_3450mah_averaged_masterslave_jan6th2017";
-	qcom,checksum = <0x96AC>;
-	qcom,gui-version = "PMI8998GUI - 2.0.0.54";
+	qcom,battery-type = "ascent_3450mah_averaged_masterslave_jul11th2017";
+	qcom,checksum = <0x7C33>;
+	qcom,gui-version = "PMI8998GUI - 2.0.0.58";
 	qcom,fg-profile-data = [
-		 9C 1F 85 05
-		 82 0A 73 FC
-		 2B 1D 72 EA
-		 EE 03 66 0C
-		 C8 17 F4 22
-		 E0 45 1F 52
-		 5C 00 00 00
-		 10 00 00 00
-		 00 00 4A C4
-		 C7 BC 48 C2
-		 0F 00 08 00
-		 E1 DA 5D ED
-		 8D FD B2 F3
-		 96 E2 A7 12
-		 7E F4 0E 3B
-		 24 06 09 20
-		 27 00 14 00
-		 83 1F EE 05
-		 1F 0A 45 FD
-		 6B 1D 53 E5
-		 EC 0B 31 14
-		 44 18 49 23
-		 18 45 A6 53
-		 55 00 00 00
-		 0E 00 00 00
-		 00 00 61 CC
-		 B7 C3 0F BC
-		 0F 00 00 00
-		 92 00 5D ED
-		 E3 06 E0 00
-		 75 FD 9C 03
-		 47 DB B3 22
-		 CB 33 CC FF
-		 07 10 00 00
-		 99 0D 99 45
-		 0F 00 40 00
-		 AB 01 0A FA
-		 FF 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
-		 00 00 00 00
+		8F 1F 94 05
+		73 0A 4A 06
+		27 1D 21 EA
+		16 0A 3B 0C
+		07 18 97 22
+		A5 3C EC 4A
+		5C 00 00 00
+		10 00 00 00
+		00 00 92 BC
+		CD BD 02 B4
+		11 00 08 00
+		69 DA AD 07
+		4B FD 19 FA
+		1D 0C B0 0C
+		EB F3 78 3B
+		24 06 09 20
+		27 00 14 00
+		7E 1F F2 05
+		19 0A 55 FD
+		6C 1D C6 ED
+		1A 12 FF 1D
+		6F 18 EB 22
+		B9 45 6F 52
+		55 00 00 00
+		0E 00 00 00
+		00 00 A1 D5
+		34 BA A0 CA
+		0F 00 00 00
+		93 00 AD 07
+		8D FD F6 00
+		BA 0D 5C 04
+		B3 FC F4 1B
+		C3 33 CC FF
+		07 10 00 00
+		A4 0D 99 45
+		0F 00 40 00
+		A4 01 0A FA
+		FF 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
+		00 00 00 00
 	];
 };
diff --git a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
index 5de0e44..a48fba0 100644
--- a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
@@ -21,6 +21,7 @@
 		#iommu-cells = <1>;
 		qcom,dynamic;
 		qcom,use-3-lvl-tables;
+		qcom,disable-atos;
 		#global-interrupts = <2>;
 		qcom,regulator-names = "vdd";
 		vdd-supply = <&gpu_cx_gdsc>;
@@ -62,6 +63,7 @@
 		qcom,skip-init;
 		qcom,use-3-lvl-tables;
 		qcom,no-asid-retention;
+		qcom,disable-atos;
 		#global-interrupts = <1>;
 		#size-cells = <1>;
 		#address-cells = <1>;
@@ -353,4 +355,7 @@
 			<0x1400 0x3ff 0x3>,
 			<0x1800 0x3ff 0x3>,
 			<0x1c00 0x3ff 0x3>;
+
+	qcom,mmu500-errata-1 =	<0x800 0x3ff>,
+				<0xc00 0x3ff>;
 };
diff --git a/arch/arm64/boot/dts/qcom/msm-audio-lpass.dtsi b/arch/arm64/boot/dts/qcom/msm-audio-lpass.dtsi
index 0d2f9e8..2fd1bc4 100644
--- a/arch/arm64/boot/dts/qcom/msm-audio-lpass.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm-audio-lpass.dtsi
@@ -353,6 +353,20 @@
 		qcom,msm-cpudai-afe-clk-ver = <2>;
 	};
 
+	dai_quin_auxpcm: qcom,msm-quin-auxpcm {
+		compatible = "qcom,msm-auxpcm-dev";
+		qcom,msm-cpudai-auxpcm-mode = <0>, <0>;
+		qcom,msm-cpudai-auxpcm-sync = <1>, <1>;
+		qcom,msm-cpudai-auxpcm-frame = <5>, <4>;
+		qcom,msm-cpudai-auxpcm-quant = <2>, <2>;
+		qcom,msm-cpudai-auxpcm-num-slots = <1>, <1>;
+		qcom,msm-cpudai-auxpcm-slot-mapping = <1>, <1>;
+		qcom,msm-cpudai-auxpcm-data = <0>, <0>;
+		qcom,msm-cpudai-auxpcm-pcm-clk-rate = <2048000>, <2048000>;
+		qcom,msm-auxpcm-interface = "quinary";
+		qcom,msm-cpudai-afe-clk-ver = <2>;
+	};
+
 	hdmi_dba: qcom,msm-hdmi-dba-codec-rx {
 		compatible = "qcom,msm-hdmi-dba-codec-rx";
 		qcom,dba-bridge-chip = "adv7533";
@@ -522,4 +536,42 @@
 			qcom,msm-cpudai-tdm-data-align = <0>;
 		};
 	};
+
+	qcom,msm-dai-tdm-quin-rx {
+		compatible = "qcom,msm-dai-tdm";
+		qcom,msm-cpudai-tdm-group-id = <37184>;
+		qcom,msm-cpudai-tdm-group-num-ports = <1>;
+		qcom,msm-cpudai-tdm-group-port-id = <36928>;
+		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
+		qcom,msm-cpudai-tdm-clk-internal = <1>;
+		qcom,msm-cpudai-tdm-sync-mode = <1>;
+		qcom,msm-cpudai-tdm-sync-src = <1>;
+		qcom,msm-cpudai-tdm-data-out = <0>;
+		qcom,msm-cpudai-tdm-invert-sync = <1>;
+		qcom,msm-cpudai-tdm-data-delay = <1>;
+		dai_quin_tdm_rx_0: qcom,msm-dai-q6-tdm-quin-rx-0 {
+			compatible = "qcom,msm-dai-q6-tdm";
+			qcom,msm-cpudai-tdm-dev-id = <36928>;
+			qcom,msm-cpudai-tdm-data-align = <0>;
+		};
+	};
+
+	qcom,msm-dai-tdm-quin-tx {
+		compatible = "qcom,msm-dai-tdm";
+		qcom,msm-cpudai-tdm-group-id = <37185>;
+		qcom,msm-cpudai-tdm-group-num-ports = <1>;
+		qcom,msm-cpudai-tdm-group-port-id = <36929>;
+		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
+		qcom,msm-cpudai-tdm-clk-internal = <1>;
+		qcom,msm-cpudai-tdm-sync-mode = <1>;
+		qcom,msm-cpudai-tdm-sync-src = <1>;
+		qcom,msm-cpudai-tdm-data-out = <0>;
+		qcom,msm-cpudai-tdm-invert-sync = <1>;
+		qcom,msm-cpudai-tdm-data-delay = <1>;
+		dai_quin_tdm_tx_0: qcom,msm-dai-q6-tdm-quin-tx-0 {
+			compatible = "qcom,msm-dai-q6-tdm";
+			qcom,msm-cpudai-tdm-dev-id = <36929>;
+			qcom,msm-cpudai-tdm-data-align = <0>;
+		};
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8953-cpu.dtsi b/arch/arm64/boot/dts/qcom/msm8953-cpu.dtsi
new file mode 100644
index 0000000..1b78fdd
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8953-cpu.dtsi
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/ {
+	psci {
+		compatible = "arm,psci-1.0";
+		method = "smc";
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		cpu-map {
+			cluster0 {
+				core0 {
+					cpu = <&CPU0>;
+				};
+				core1 {
+					cpu = <&CPU1>;
+				};
+				core2 {
+					cpu = <&CPU2>;
+				};
+				core3 {
+					cpu = <&CPU3>;
+				};
+			};
+
+			cluster1 {
+				core0 {
+					cpu = <&CPU4>;
+				};
+				core1 {
+					cpu = <&CPU5>;
+				};
+				core2 {
+					cpu = <&CPU6>;
+				};
+				core3 {
+					cpu = <&CPU7>;
+				};
+			};
+		};
+
+		CPU0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			reg = <0x0>;
+			enable-method = "psci";
+			efficiency = <1024>;
+			next-level-cache = <&L2_0>;
+			L2_0: l2-cache {
+			      compatible = "arm,arch-cache";
+			      cache-level = <2>;
+			      /* A53 L2 dump not supported */
+			      qcom,dump-size = <0x0>;
+			};
+			L1_I_0: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_0: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU1: cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x1>;
+			efficiency = <1024>;
+			next-level-cache = <&L2_0>;
+			L1_I_1: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_1: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU2: cpu@2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x2>;
+			efficiency = <1024>;
+			next-level-cache = <&L2_0>;
+			L1_I_2: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_2: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU3: cpu@3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x3>;
+			efficiency = <1024>;
+			next-level-cache = <&L2_0>;
+			L1_I_3: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_3: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU4: cpu@100 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x100>;
+			efficiency = <1126>;
+			next-level-cache = <&L2_1>;
+			L2_1: l2-cache {
+			      compatible = "arm,arch-cache";
+			      cache-level = <2>;
+			      /* A53 L2 dump not supported */
+			      qcom,dump-size = <0x0>;
+			};
+			L1_I_100: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_100: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU5: cpu@101 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x101>;
+			efficiency = <1126>;
+			next-level-cache = <&L2_1>;
+			L1_I_101: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_101: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU6: cpu@102 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x102>;
+			efficiency = <1126>;
+			next-level-cache = <&L2_1>;
+			L1_I_102: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_102: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+
+		CPU7: cpu@103 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53","arm,armv8";
+			enable-method = "psci";
+			reg = <0x103>;
+			efficiency = <1126>;
+			next-level-cache = <&L2_1>;
+			L1_I_103: l1-icache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x8800>;
+			};
+			L1_D_103: l1-dcache {
+			      compatible = "arm,arch-cache";
+			      qcom,dump-size = <0x9000>;
+			};
+		};
+	};
+};
+
+&soc {
+	cpuss_dump {
+		compatible = "qcom,cpuss-dump";
+		qcom,l2_dump0 {
+			/* L2 cache dump for A53 cluster */
+			qcom,dump-node = <&L2_0>;
+			qcom,dump-id = <0xC0>;
+		};
+		qcom,l2_dump1 {
+			/* L2 cache dump for A53 cluster */
+			qcom,dump-node = <&L2_1>;
+			qcom,dump-id = <0xC1>;
+		};
+		qcom,l1_i_cache0 {
+			qcom,dump-node = <&L1_I_0>;
+			qcom,dump-id = <0x60>;
+		};
+		qcom,l1_i_cache1 {
+			qcom,dump-node = <&L1_I_1>;
+			qcom,dump-id = <0x61>;
+		};
+		qcom,l1_i_cache2 {
+			qcom,dump-node = <&L1_I_2>;
+			qcom,dump-id = <0x62>;
+		};
+		qcom,l1_i_cache3 {
+			qcom,dump-node = <&L1_I_3>;
+			qcom,dump-id = <0x63>;
+		};
+		qcom,l1_i_cache100 {
+			qcom,dump-node = <&L1_I_100>;
+			qcom,dump-id = <0x64>;
+		};
+		qcom,l1_i_cache101 {
+			qcom,dump-node = <&L1_I_101>;
+			qcom,dump-id = <0x65>;
+		};
+		qcom,l1_i_cache102 {
+			qcom,dump-node = <&L1_I_102>;
+			qcom,dump-id = <0x66>;
+		};
+		qcom,l1_i_cache103 {
+			qcom,dump-node = <&L1_I_103>;
+			qcom,dump-id = <0x67>;
+		};
+		qcom,l1_d_cache0 {
+			qcom,dump-node = <&L1_D_0>;
+			qcom,dump-id = <0x80>;
+		};
+		qcom,l1_d_cache1 {
+			qcom,dump-node = <&L1_D_1>;
+			qcom,dump-id = <0x81>;
+		};
+		qcom,l1_d_cache2 {
+			qcom,dump-node = <&L1_D_2>;
+			qcom,dump-id = <0x82>;
+		};
+		qcom,l1_d_cache3 {
+			qcom,dump-node = <&L1_D_3>;
+			qcom,dump-id = <0x83>;
+		};
+		qcom,l1_d_cache100 {
+			qcom,dump-node = <&L1_D_100>;
+			qcom,dump-id = <0x84>;
+		};
+		qcom,l1_d_cache101 {
+			qcom,dump-node = <&L1_D_101>;
+			qcom,dump-id = <0x85>;
+		};
+		qcom,l1_d_cache102 {
+			qcom,dump-node = <&L1_D_102>;
+			qcom,dump-id = <0x86>;
+		};
+		qcom,l1_d_cache103 {
+			qcom,dump-node = <&L1_D_103>;
+			qcom,dump-id = <0x87>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8953-mtp.dts b/arch/arm64/boot/dts/qcom/msm8953-mtp.dts
new file mode 100644
index 0000000..1e8b0f0
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8953-mtp.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+
+#include "msm8953.dtsi"
+#include "msm8953-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM8953 + PMI8950 MTP";
+	compatible = "qcom,msm8953-mtp", "qcom,msm8953", "qcom,mtp";
+	qcom,board-id= <8 0>;
+	qcom,pmic-id = <0x010016 0x010011 0x0 0x0>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
similarity index 61%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
index bc1cd9e..243aaf5 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
@@ -1,4 +1,5 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +9,10 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
-
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
-
-#endif
+&blsp1_uart0 {
+	status = "ok";
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart_console_active>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8953-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/msm8953-pinctrl.dtsi
new file mode 100644
index 0000000..e3ada39
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8953-pinctrl.dtsi
@@ -0,0 +1,1506 @@
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+&soc {
+	tlmm: pinctrl@1000000 {
+		compatible = "qcom,msm8953-pinctrl";
+		reg = <0x1000000 0x300000>;
+		interrupts = <0 208 0>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+
+		pmx-uartconsole {
+			uart_console_active: uart_console_active {
+				mux {
+					pins = "gpio4", "gpio5";
+					function = "blsp_uart2";
+				};
+
+				config {
+					pins = "gpio4", "gpio5";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+
+			uart_console_sleep: uart_console_sleep {
+				mux {
+					pins = "gpio4", "gpio5";
+					function = "blsp_uart2";
+				};
+
+				config {
+					pins = "gpio4", "gpio5";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+
+		};
+		cci {
+			cci0_active: cci0_active {
+				/* cci0 active state */
+				mux {
+					/* CLK, DATA */
+					pins = "gpio29", "gpio30";
+					function = "cci_i2c";
+				};
+
+				config {
+					pins = "gpio29", "gpio30";
+					drive-strength = <2>; /* 2 MA */
+					bias-disable; /* No PULL */
+				};
+			};
+
+			cci0_suspend: cci0_suspend {
+				/* cci0 suspended state */
+				mux {
+					/* CLK, DATA */
+					pins = "gpio29", "gpio30";
+					function = "cci_i2c";
+				};
+
+				config {
+					pins = "gpio29", "gpio30";
+					drive-strength = <2>; /* 2 MA */
+					bias-disable; /* No PULL */
+				};
+			};
+
+			cci1_active: cci1_active {
+				/* cci1 active state */
+				mux {
+					/* CLK, DATA */
+					pins = "gpio31", "gpio32";
+					function = "cci_i2c";
+				};
+
+				config {
+					pins = "gpio31", "gpio32";
+					drive-strength = <2>; /* 2 MA */
+					bias-disable; /* No PULL */
+				};
+			};
+
+			cci1_suspend: cci1_suspend {
+				/* cci1 suspended state */
+				mux {
+					/* CLK, DATA */
+					pins = "gpio31", "gpio32";
+					function = "cci_i2c";
+				};
+
+				config {
+					pins = "gpio31", "gpio32";
+					drive-strength = <2>; /* 2 MA */
+					bias-disable; /* No PULL */
+				};
+			};
+		};
+
+		/*sensors */
+		cam_sensor_mclk0_default: cam_sensor_mclk0_default {
+			/* MCLK0 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio26";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio26";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk0_sleep: cam_sensor_mclk0_sleep {
+			/* MCLK0 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio26";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio26";
+				bias-pull-down; /* PULL DOWN */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_rear_default: cam_sensor_rear_default {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio40", "gpio39";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio40","gpio39";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_rear_sleep: cam_sensor_rear_sleep {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio40","gpio39";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio40","gpio39";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_rear_vana: cam_sensor_rear_vdig {
+			/* VDIG */
+			mux {
+				pins = "gpio134";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio134";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_rear_vana_sleep: cam_sensor_rear_vdig_sleep {
+			/* VDIG */
+			mux {
+				pins = "gpio134";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio134";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk1_default: cam_sensor_mclk1_default {
+			/* MCLK1 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio27";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio27";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk1_sleep: cam_sensor_mclk1_sleep {
+			/* MCLK1 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio27";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio27";
+				bias-pull-down; /* PULL DOWN */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_front_default: cam_sensor_front_default {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio131","gpio132";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio131","gpio132";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_front_sleep: cam_sensor_front_sleep {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio131","gpio132";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio131","gpio132";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk2_default: cam_sensor_mclk2_default {
+			/* MCLK2 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio28";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio28";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk2_sleep: cam_sensor_mclk2_sleep {
+			/* MCLK2 */
+			mux {
+				/* CLK, DATA */
+				pins = "gpio28";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio28";
+				bias-pull-down; /* PULL DOWN */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_front1_default: cam_sensor_front1_default {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio129", "gpio130";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio129", "gpio130";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_front1_sleep: cam_sensor_front1_sleep {
+			/* RESET, STANDBY */
+			mux {
+				pins = "gpio129", "gpio130";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio129", "gpio130";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		pmx_adv7533_int: pmx_adv7533_int {
+			adv7533_int_active: adv7533_int_active {
+				mux {
+					pins = "gpio90";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio90";
+					drive-strength = <16>;
+					bias-disable;
+				};
+			};
+
+			adv7533_int_suspend: adv7533_int_suspend {
+				mux {
+					pins = "gpio90";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio90";
+					drive-strength = <16>;
+					bias-disable;
+				};
+			};
+
+		};
+
+		pmx_mdss: pmx_mdss {
+			mdss_dsi_active: mdss_dsi_active {
+				mux {
+					pins = "gpio61", "gpio59";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio61", "gpio59";
+					drive-strength = <8>; /* 8 mA */
+					bias-disable = <0>; /* no pull */
+					output-high;
+				};
+			};
+
+			mdss_dsi_suspend: mdss_dsi_suspend {
+				mux {
+					pins = "gpio61", "gpio59";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio61", "gpio59";
+					drive-strength = <2>; /* 2 mA */
+					bias-pull-down; /* pull down */
+				};
+			};
+		};
+
+		pmx_mdss_te {
+			mdss_te_active: mdss_te_active {
+				mux {
+					pins = "gpio24";
+					function = "mdp_vsync";
+				};
+				config {
+					pins = "gpio24";
+					drive-strength = <2>; /* 8 mA */
+					bias-pull-down; /* pull down*/
+				};
+			};
+
+			mdss_te_suspend: mdss_te_suspend {
+				mux {
+					pins = "gpio24";
+					function = "mdp_vsync";
+				};
+				config {
+					pins = "gpio24";
+					drive-strength = <2>; /* 2 mA */
+					bias-pull-down; /* pull down */
+				};
+			};
+		};
+
+		hsuart_active: default {
+			mux {
+				pins = "gpio12", "gpio13", "gpio14", "gpio15";
+				function = "blsp_uart4";
+			};
+
+			config {
+				pins = "gpio12", "gpio13", "gpio14", "gpio15";
+				drive-strength = <16>;
+				bias-disable;
+			};
+		};
+
+		hsuart_sleep: sleep {
+			mux {
+				pins = "gpio12", "gpio13", "gpio14", "gpio15";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio12", "gpio13", "gpio14", "gpio15";
+				drive-strength = <2>;
+				bias-disable;
+			};
+		};
+
+		/* SDC pin type */
+		sdc1_clk_on: sdc1_clk_on {
+			config {
+				pins = "sdc1_clk";
+				bias-disable;		/* NO pull */
+				drive-strength = <16>;	/* 16 MA */
+			};
+		};
+
+		sdc1_clk_off: sdc1_clk_off {
+			config {
+				pins = "sdc1_clk";
+				bias-disable;		/* NO pull */
+				drive-strength = <2>;	/* 2 MA */
+			};
+		};
+
+		sdc1_cmd_on: sdc1_cmd_on {
+			config {
+				pins = "sdc1_cmd";
+				bias-pull-up;		/* pull up */
+				drive-strength = <10>;	/* 10 MA */
+			};
+		};
+
+		sdc1_cmd_off: sdc1_cmd_off {
+			config {
+				pins = "sdc1_cmd";
+				num-grp-pins = <1>;
+				bias-pull-up;		/* pull up */
+				drive-strength = <2>;	/* 2 MA */
+			};
+		};
+
+		sdc1_data_on: sdc1_data_on {
+			config {
+				pins = "sdc1_data";
+				bias-pull-up;		/* pull up */
+				drive-strength = <10>;	/* 10 MA */
+			};
+		};
+
+		sdc1_data_off: sdc1_data_off {
+			config {
+				pins = "sdc1_data";
+				bias-pull-up;		/* pull up */
+				drive-strength = <2>;	/* 2 MA */
+			};
+		};
+
+		sdc1_rclk_on: sdc1_rclk_on {
+			config {
+				pins = "sdc1_rclk";
+				bias-pull-down; /* pull down */
+			};
+		};
+
+		sdc1_rclk_off: sdc1_rclk_off {
+			config {
+				pins = "sdc1_rclk";
+				bias-pull-down; /* pull down */
+			};
+		};
+
+		sdc2_clk_on: sdc2_clk_on {
+			config {
+				pins = "sdc2_clk";
+				drive-strength = <16>; /* 16 MA */
+				bias-disable; /* NO pull */
+			};
+		};
+
+		sdc2_clk_off: sdc2_clk_off {
+			config {
+				pins = "sdc2_clk";
+				bias-disable; /* NO pull */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		sdc2_cmd_on: sdc2_cmd_on {
+			config {
+				pins = "sdc2_cmd";
+				bias-pull-up; /* pull up */
+				drive-strength = <10>; /* 10 MA */
+			};
+		};
+
+		sdc2_cmd_off: sdc2_cmd_off {
+			config {
+				pins = "sdc2_cmd";
+				bias-pull-up; /* pull up */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		sdc2_data_on: sdc2_data_on {
+			config {
+				pins = "sdc2_data";
+				bias-pull-up; /* pull up */
+				drive-strength = <10>; /* 10 MA */
+			};
+		};
+
+		sdc2_data_off: sdc2_data_off {
+			config {
+				pins = "sdc2_data";
+				bias-pull-up; /* pull up */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		sdc2_cd_on: cd_on {
+			mux {
+				pins = "gpio133";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio133";
+				drive-strength = <2>;
+				bias-pull-up;
+			};
+		};
+
+		sdc2_cd_off: cd_off {
+			mux {
+				pins = "gpio133";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio133";
+				drive-strength = <2>;
+				bias-disable;
+			};
+		};
+
+		i2c_2 {
+			i2c_2_active: i2c_2_active {
+				/* active state */
+				mux {
+					pins = "gpio6", "gpio7";
+					function = "blsp_i2c2";
+				};
+
+				config {
+					pins = "gpio6", "gpio7";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+
+			i2c_2_sleep: i2c_2_sleep {
+				/* suspended state */
+				mux {
+					pins = "gpio6", "gpio7";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio6", "gpio7";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		i2c_3 {
+			i2c_3_active: i2c_3_active {
+				/* active state */
+				mux {
+					pins = "gpio10", "gpio11";
+					function = "blsp_i2c3";
+				};
+
+				config {
+					pins = "gpio10", "gpio11";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+
+			i2c_3_sleep: i2c_3_sleep {
+				/* suspended state */
+				mux {
+					pins = "gpio10", "gpio11";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio10", "gpio11";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		i2c_5 {
+			i2c_5_active: i2c_5_active {
+				/* active state */
+				mux {
+					pins = "gpio18", "gpio19";
+					function = "blsp_i2c5";
+				};
+
+				config {
+					pins = "gpio18", "gpio19";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+
+			i2c_5_sleep: i2c_5_sleep {
+				/* suspended state */
+				mux {
+					pins = "gpio18", "gpio19";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio18", "gpio19";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		pmx_rd_nfc_int {
+			/*qcom,pins = <&gp 17>;*/
+			pins = "gpio17";
+			qcom,pin-func = <0>;
+			qcom,num-grp-pins = <1>;
+			label = "pmx_nfc_int";
+
+			nfc_int_active: active {
+				drive-strength = <6>;
+				bias-pull-up;
+			};
+
+			nfc_int_suspend: suspend {
+				drive-strength = <6>;
+				bias-pull-up;
+			};
+		};
+
+		pmx_nfc_reset {
+			/*qcom,pins = <&gp 16>;*/
+			pins = "gpio16";
+			qcom,pin-func = <0>;
+			qcom,num-grp-pins = <1>;
+			label = "pmx_nfc_disable";
+
+			nfc_disable_active: active {
+				drive-strength = <6>;
+				bias-pull-up;
+			};
+
+			nfc_disable_suspend: suspend {
+				drive-strength = <6>;
+				bias-disable;
+			};
+		};
+
+		wcnss_pmux_5wire {
+			/* Active configuration of bus pins */
+			wcnss_default: wcnss_default {
+				wcss_wlan2 {
+					pins = "gpio76";
+					function = "wcss_wlan2";
+				};
+				wcss_wlan1 {
+					pins = "gpio77";
+					function = "wcss_wlan1";
+				};
+				wcss_wlan0 {
+					pins = "gpio78";
+					function = "wcss_wlan0";
+				};
+				wcss_wlan {
+					pins = "gpio79", "gpio80";
+					function = "wcss_wlan";
+				};
+
+				config {
+					pins = "gpio76", "gpio77",
+						"gpio78", "gpio79",
+						"gpio80";
+					drive-strength = <6>; /* 6 MA */
+					bias-pull-up; /* PULL UP */
+				};
+			};
+
+			wcnss_sleep: wcnss_sleep {
+				wcss_wlan2 {
+					pins = "gpio76";
+					function = "wcss_wlan2";
+				};
+				wcss_wlan1 {
+					pins = "gpio77";
+					function = "wcss_wlan1";
+				};
+				wcss_wlan0 {
+					pins = "gpio78";
+					function = "wcss_wlan0";
+				};
+				wcss_wlan {
+					pins = "gpio79", "gpio80";
+					function = "wcss_wlan";
+				};
+
+				config {
+					pins = "gpio76", "gpio77",
+						"gpio78", "gpio79",
+						"gpio80";
+					drive-strength = <2>; /* 2 MA */
+					bias-pull-down; /* PULL Down */
+				};
+			};
+		};
+
+		wcnss_pmux_gpio: wcnss_pmux_gpio {
+			wcnss_gpio_default: wcnss_gpio_default {
+				/* Active configuration of bus pins */
+				mux {
+					/* Uses general purpose pins */
+					pins = "gpio76", "gpio77",
+					"gpio78", "gpio79",
+					"gpio80";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio76", "gpio77",
+						"gpio78", "gpio79",
+						"gpio80";
+					drive-strength = <6>; /* 6 MA */
+					bias-pull-up; /* PULL UP */
+				};
+			};
+		};
+
+		wcd9xxx_intr {
+			wcd_intr_default: wcd_intr_default{
+				mux {
+					pins = "gpio73";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio73";
+					drive-strength = <2>; /* 2 mA */
+					bias-pull-down; /* pull down */
+					input-enable;
+				};
+			};
+		};
+
+		cdc_reset_ctrl {
+			cdc_reset_sleep: cdc_reset_sleep {
+				mux {
+					pins = "gpio67";
+					function = "gpio";
+				};
+				config {
+					pins = "gpio67";
+					drive-strength = <16>;
+					bias-disable;
+					output-low;
+				};
+			};
+			cdc_reset_active:cdc_reset_active {
+				mux {
+					pins = "gpio67";
+					function = "gpio";
+				};
+				config {
+					pins = "gpio67";
+					drive-strength = <16>;
+					bias-pull-down;
+					output-high;
+				};
+			};
+		};
+
+		cdc_mclk2_pin {
+			cdc_mclk2_sleep: cdc_mclk2_sleep {
+				mux {
+					pins = "gpio66";
+					function = "pri_mi2s";
+				};
+				config {
+					pins = "gpio66";
+					drive-strength = <2>; /* 2 mA */
+					bias-pull-down;       /* PULL DOWN */
+				};
+			};
+			cdc_mclk2_active: cdc_mclk2_active {
+				mux {
+					pins = "gpio66";
+					function = "pri_mi2s";
+				};
+				config {
+					pins = "gpio66";
+					drive-strength = <8>; /* 8 mA */
+					bias-disable;         /* NO PULL */
+				};
+			};
+		};
+
+		cdc-pdm-2-lines {
+			cdc_pdm_lines_2_act: pdm_lines_2_on {
+				mux {
+					pins = "gpio70", "gpio71", "gpio72";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio70", "gpio71", "gpio72";
+					drive-strength = <8>;
+				};
+			};
+
+			cdc_pdm_lines_2_sus: pdm_lines_2_off {
+				mux {
+					pins = "gpio70", "gpio71", "gpio72";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio70", "gpio71", "gpio72";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		cdc-pdm-lines {
+			cdc_pdm_lines_act: pdm_lines_on {
+				mux {
+					pins = "gpio69", "gpio73", "gpio74";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio69", "gpio73", "gpio74";
+					drive-strength = <8>;
+				};
+			};
+			cdc_pdm_lines_sus: pdm_lines_off {
+				mux {
+					pins = "gpio69", "gpio73", "gpio74";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio69", "gpio73", "gpio74";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		cdc-pdm-comp-lines {
+			cdc_pdm_comp_lines_act: pdm_comp_lines_on {
+				mux {
+					pins = "gpio67", "gpio68";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio67", "gpio68";
+					drive-strength = <8>;
+				};
+			};
+
+			cdc_pdm_comp_lines_sus: pdm_comp_lines_off {
+				mux {
+					pins = "gpio67", "gpio68";
+					function = "cdc_pdm0";
+				};
+
+				config {
+					pins = "gpio67", "gpio68";
+					drive-strength = <2>;
+					bias-disable;
+				};
+			};
+		};
+
+		cross-conn-det {
+			cross_conn_det_act: lines_on {
+				mux {
+					pins = "gpio63";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio63";
+					drive-strength = <8>;
+					output-low;
+					bias-pull-down;
+				};
+			};
+
+			cross_conn_det_sus: lines_off {
+				mux {
+					pins = "gpio63";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio63";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		/* WSA VI sense */
+		wsa-vi {
+			wsa_vi_on: wsa_vi_on {
+				mux {
+					pins = "gpio94", "gpio95";
+					function = "wsa_io";
+				};
+
+				config {
+					pins = "gpio94", "gpio95";
+					drive-strength = <8>; /* 8 MA */
+					bias-disable; /* NO pull */
+				};
+			};
+
+			wsa_vi_off: wsa_vi_off {
+				mux {
+					pins = "gpio94", "gpio95";
+					function = "wsa_io";
+				};
+
+				config {
+					pins = "gpio94", "gpio95";
+					drive-strength = <2>; /* 2 MA */
+					bias-pull-down;
+				};
+			};
+		};
+
+		/* WSA Reset */
+		wsa_reset {
+			wsa_reset_on: wsa_reset_on {
+				mux {
+					pins = "gpio96";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio96";
+					drive-strength = <2>; /* 2 MA */
+					output-high;
+				};
+			};
+
+			wsa_reset_off: wsa_reset_off {
+				mux {
+					pins = "gpio96";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio96";
+					drive-strength = <2>; /* 2 MA */
+					output-low;
+				};
+			};
+		};
+
+		/* WSA CLK */
+		wsa_clk {
+			wsa_clk_on: wsa_clk_on {
+				mux {
+					pins = "gpio25";
+					function = "pri_mi2s_mclk_a";
+				};
+
+				config {
+					pins = "gpio25";
+					drive-strength = <8>; /* 8 MA */
+					output-high;
+				};
+			};
+
+			wsa_clk_off: wsa_clk_off {
+				mux {
+					pins = "gpio25";
+					function = "pri_mi2s_mclk_a";
+				};
+
+				config {
+					pins = "gpio25";
+					drive-strength = <2>; /* 2 MA */
+					output-low;
+					bias-pull-down;
+				};
+			};
+		};
+
+		pri-tlmm-lines {
+			pri_tlmm_lines_act: pri_tlmm_lines_act {
+				mux {
+					pins = "gpio91", "gpio93";
+					function = "pri_mi2s";
+				};
+
+				config {
+					pins = "gpio91", "gpio93";
+					drive-strength = <8>;
+				};
+			};
+
+			pri_tlmm_lines_sus: pri_tlmm_lines_sus {
+				mux {
+					pins = "gpio91", "gpio93";
+					function = "pri_mi2s";
+				};
+
+				config {
+					pins = "gpio91", "gpio93";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		pri-tlmm-ws-lines {
+			pri_tlmm_ws_act: pri_tlmm_ws_act {
+				mux {
+					pins = "gpio92";
+					function = "pri_mi2s_ws";
+				};
+
+				config {
+					pins = "gpio92";
+					drive-strength = <8>;
+				};
+			};
+
+			pri_tlmm_ws_sus: pri_tlmm_ws_sus {
+				mux {
+					pins = "gpio92";
+					function = "pri_mi2s_ws";
+				};
+
+				config {
+					pins = "gpio92";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		spi3 {
+			spi3_default: spi3_default {
+				/* active state */
+				mux {
+					/* MOSI, MISO, CLK */
+					pins = "gpio8", "gpio9", "gpio11";
+					function = "blsp_spi3";
+				};
+
+				config {
+					pins = "gpio8", "gpio9", "gpio11";
+					drive-strength = <12>; /* 12 MA */
+					bias-disable = <0>; /* No PULL */
+				};
+			};
+
+			spi3_sleep: spi3_sleep {
+				/* suspended state */
+				mux {
+					/* MOSI, MISO, CLK */
+					pins = "gpio8", "gpio9", "gpio11";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio8", "gpio9", "gpio11";
+					drive-strength = <2>; /* 2 MA */
+					bias-pull-down; /* PULL Down */
+				};
+			};
+
+			spi3_cs0_active: cs0_active {
+				/* CS */
+				mux {
+					pins = "gpio10";
+					function = "blsp_spi3";
+				};
+
+				config {
+					pins = "gpio10";
+					drive-strength = <2>;
+					bias-disable = <0>;
+				};
+			};
+
+			spi3_cs0_sleep: cs0_sleep {
+				/* CS */
+				mux {
+					pins = "gpio10";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio10";
+					drive-strength = <2>;
+					bias-disable = <0>;
+				};
+			};
+		};
+
+		/* add pingrp for touchscreen */
+		pmx_ts_int_active {
+			ts_int_active: ts_int_active {
+				mux {
+					pins = "gpio65";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio65";
+					drive-strength = <8>;
+					bias-pull-up;
+				};
+			};
+		};
+
+		pmx_ts_int_suspend {
+			ts_int_suspend: ts_int_suspend {
+				mux {
+					pins = "gpio65";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio65";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		pmx_ts_reset_active {
+			ts_reset_active: ts_reset_active {
+				mux {
+					pins = "gpio64";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio64";
+					drive-strength = <8>;
+					bias-pull-up;
+				};
+			};
+		};
+
+		pmx_ts_reset_suspend {
+			ts_reset_suspend: ts_reset_suspend {
+				mux {
+					pins = "gpio64";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio64";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		pmx_ts_release {
+			ts_release: ts_release {
+				mux {
+					pins = "gpio65", "gpio64";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio65", "gpio64";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+		};
+
+		tlmm_gpio_key {
+			gpio_key_active: gpio_key_active {
+				mux {
+					pins = "gpio85", "gpio86", "gpio87";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio85", "gpio86", "gpio87";
+					drive-strength = <2>;
+					bias-pull-up;
+				};
+			};
+
+			gpio_key_suspend: gpio_key_suspend {
+				mux {
+					pins = "gpio85", "gpio86", "gpio87";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio85", "gpio86", "gpio87";
+					drive-strength = <2>;
+					bias-pull-up;
+				};
+			};
+		};
+		pmx_qdsd_clk {
+			qdsd_clk_sdcard: clk_sdcard {
+				config {
+					pins = "qdsd_clk";
+					bias-disable;/* NO pull */
+					drive-strength = <16>; /* 16 MA */
+				};
+			};
+			qdsd_clk_trace: clk_trace {
+				config {
+					pins = "qdsd_clk";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_clk_swdtrc: clk_swdtrc {
+				config {
+					pins = "qdsd_clk";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_clk_spmi: clk_spmi {
+				config {
+					pins = "qdsd_clk";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+		};
+
+		pmx_qdsd_cmd {
+			qdsd_cmd_sdcard: cmd_sdcard {
+				config {
+					pins = "qdsd_cmd";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_cmd_trace: cmd_trace {
+				config {
+					pins = "qdsd_cmd";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_cmd_swduart: cmd_uart {
+				config {
+					pins = "qdsd_cmd";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_cmd_swdtrc: cmd_swdtrc {
+				config {
+					pins = "qdsd_cmd";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_cmd_jtag: cmd_jtag {
+				config {
+					pins = "qdsd_cmd";
+					bias-disable; /* NO pull */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_cmd_spmi: cmd_spmi {
+				config {
+					pins = "qdsd_cmd";
+					bias-pull-down; /* pull down */
+					drive-strength = <10>; /* 10 MA */
+				};
+			};
+		};
+
+		pmx_qdsd_data0 {
+			qdsd_data0_sdcard: data0_sdcard {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data0_trace: data0_trace {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data0_swduart: data0_uart {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data0_swdtrc: data0_swdtrc {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data0_jtag: data0_jtag {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data0_spmi: data0_spmi {
+				config {
+					pins = "qdsd_data0";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+		};
+
+		pmx_qdsd_data1 {
+			qdsd_data1_sdcard: data1_sdcard {
+				config {
+					pins = "qdsd_data1";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data1_trace: data1_trace {
+				config {
+					pins = "qdsd_data1";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data1_swduart: data1_uart {
+				config {
+					pins = "qdsd_data1";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data1_swdtrc: data1_swdtrc {
+				config {
+					pins = "qdsd_data1";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data1_jtag: data1_jtag {
+				config {
+					pins = "qdsd_data1";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+		};
+
+		pmx_qdsd_data2 {
+			qdsd_data2_sdcard: data2_sdcard {
+				config {
+					pins = "qdsd_data2";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data2_trace: data2_trace {
+				config {
+					pins = "qdsd_data2";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data2_swduart: data2_uart {
+				config {
+					pins = "qdsd_data2";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data2_swdtrc: data2_swdtrc {
+				config {
+					pins = "qdsd_data2";
+					bias-pull-down; /* pull down */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data2_jtag: data2_jtag {
+				config {
+					pins = "qdsd_data2";
+					bias-pull-up; /* pull up */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+		};
+
+		pmx_qdsd_data3 {
+			qdsd_data3_sdcard: data3_sdcard {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data3_trace: data3_trace {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+			qdsd_data3_swduart: data3_uart {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data3_swdtrc: data3_swdtrc {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data3_jtag: data3_jtag {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-up; /* pull up */
+					drive-strength = <2>; /* 2 MA */
+				};
+			};
+			qdsd_data3_spmi: data3_spmi {
+				config {
+					pins = "qdsd_data3";
+					bias-pull-down; /* pull down */
+					drive-strength = <8>; /* 8 MA */
+				};
+			};
+		};
+
+		typec_ssmux_config: typec_ssmux_config {
+			mux {
+				pins = "gpio139";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio139";
+				drive-strength = <2>;
+				bias-disable;
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi b/arch/arm64/boot/dts/qcom/msm8953.dtsi
new file mode 100644
index 0000000..f17ac32
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi
@@ -0,0 +1,605 @@
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "skeleton64.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM 8953";
+	compatible = "qcom,msm8953";
+	qcom,msm-id = <293 0x0>;
+	interrupt-parent = <&intc>;
+
+	chosen {
+		bootargs = "sched_enable_hmp=1 sched_enable_power_aware=1";
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		other_ext_mem: other_ext_region@0 {
+			compatible = "removed-dma-pool";
+			no-map;
+			reg = <0x0 0x85b00000 0x0 0xd00000>;
+		};
+
+		modem_mem: modem_region@0 {
+			compatible = "removed-dma-pool";
+			no-map-fixup;
+			reg = <0x0 0x86c00000 0x0 0x6a00000>;
+		};
+
+		adsp_fw_mem: adsp_fw_region@0 {
+			compatible = "removed-dma-pool";
+			no-map;
+			reg = <0x0 0x8d600000 0x0 0x1100000>;
+		};
+
+		wcnss_fw_mem: wcnss_fw_region@0 {
+			compatible = "removed-dma-pool";
+			no-map;
+			reg = <0x0 0x8e700000 0x0 0x700000>;
+		};
+
+		venus_mem: venus_region@0 {
+			compatible = "shared-dma-pool";
+			reusable;
+			alloc-ranges = <0x0 0x80000000 0x0 0x10000000>;
+			alignment = <0 0x400000>;
+			size = <0 0x0800000>;
+		};
+
+		secure_mem: secure_region@0 {
+			compatible = "shared-dma-pool";
+			reusable;
+			alignment = <0 0x400000>;
+			size = <0 0x09800000>;
+		};
+
+		qseecom_mem: qseecom_region@0 {
+			compatible = "shared-dma-pool";
+			reusable;
+			alignment = <0 0x400000>;
+			size = <0 0x1000000>;
+		};
+
+		adsp_mem: adsp_region@0 {
+			compatible = "shared-dma-pool";
+			reusable;
+			size = <0 0x400000>;
+		};
+
+		dfps_data_mem: dfps_data_mem@90000000 {
+		       reg = <0 0x90000000 0 0x1000>;
+		       label = "dfps_data_mem";
+		};
+
+		cont_splash_mem: splash_region@0x90001000 {
+			reg = <0x0 0x90001000 0x0 0x13ff000>;
+			label = "cont_splash_mem";
+		};
+
+		gpu_mem: gpu_region@0 {
+			compatible = "shared-dma-pool";
+			reusable;
+			alloc-ranges = <0x0 0x80000000 0x0 0x10000000>;
+			alignment = <0 0x400000>;
+			size = <0 0x800000>;
+		};
+	};
+
+	aliases {
+		/* smdtty devices */
+		sdhc1 = &sdhc_1; /* SDC1 eMMC slot */
+		sdhc2 = &sdhc_2; /* SDC2 for SD card */
+	};
+
+	soc: soc { };
+
+};
+
+#include "msm8953-pinctrl.dtsi"
+#include "msm8953-cpu.dtsi"
+
+
+&soc {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	ranges = <0 0 0 0xffffffff>;
+	compatible = "simple-bus";
+
+	apc_apm: apm@b111000 {
+		compatible = "qcom,msm8953-apm";
+		reg = <0xb111000 0x1000>;
+		reg-names = "pm-apcc-glb";
+		qcom,apm-post-halt-delay = <0x2>;
+		qcom,apm-halt-clk-delay = <0x11>;
+		qcom,apm-resume-clk-delay = <0x10>;
+		qcom,apm-sel-switch-delay = <0x01>;
+	};
+
+	intc: interrupt-controller@b000000 {
+		compatible = "qcom,msm-qgic2";
+		interrupt-controller;
+		#interrupt-cells = <3>;
+		reg = <0x0b000000 0x1000>,
+		      <0x0b002000 0x1000>;
+	};
+
+	qcom,msm-gladiator@b1c0000 {
+		compatible = "qcom,msm-gladiator";
+		reg = <0x0b1c0000 0x4000>;
+		reg-names = "gladiator_base";
+		interrupts = <0 22 0>;
+	};
+
+	timer {
+		compatible = "arm,armv8-timer";
+		interrupts = <1 2 0xff08>,
+			     <1 3 0xff08>,
+			     <1 4 0xff08>,
+			     <1 1 0xff08>;
+		clock-frequency = <19200000>;
+	};
+
+	timer@b120000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		compatible = "arm,armv7-timer-mem";
+		reg = <0xb120000 0x1000>;
+		clock-frequency = <19200000>;
+
+		frame@b121000 {
+			frame-number = <0>;
+			interrupts = <0 8 0x4>,
+				     <0 7 0x4>;
+			reg = <0xb121000 0x1000>,
+			      <0xb122000 0x1000>;
+		};
+
+		frame@b123000 {
+			frame-number = <1>;
+			interrupts = <0 9 0x4>;
+			reg = <0xb123000 0x1000>;
+			status = "disabled";
+		};
+
+		frame@b124000 {
+			frame-number = <2>;
+			interrupts = <0 10 0x4>;
+			reg = <0xb124000 0x1000>;
+			status = "disabled";
+		};
+
+		frame@b125000 {
+			frame-number = <3>;
+			interrupts = <0 11 0x4>;
+			reg = <0xb125000 0x1000>;
+			status = "disabled";
+		};
+
+		frame@b126000 {
+			frame-number = <4>;
+			interrupts = <0 12 0x4>;
+			reg = <0xb126000 0x1000>;
+			status = "disabled";
+		};
+
+		frame@b127000 {
+			frame-number = <5>;
+			interrupts = <0 13 0x4>;
+			reg = <0xb127000 0x1000>;
+			status = "disabled";
+		};
+
+		frame@b128000 {
+			frame-number = <6>;
+			interrupts = <0 14 0x4>;
+			reg = <0xb128000 0x1000>;
+			status = "disabled";
+		};
+	};
+	qcom,rmtfs_sharedmem@00000000 {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x00000000 0x00180000>;
+		reg-names = "rmtfs";
+		qcom,client-id = <0x00000001>;
+	};
+
+	restart@4ab000 {
+		compatible = "qcom,pshold";
+		reg = <0x4ab000 0x4>,
+			<0x193d100 0x4>;
+		reg-names = "pshold-base", "tcsr-boot-misc-detect";
+	};
+
+	qcom,mpm2-sleep-counter@4a3000 {
+		compatible = "qcom,mpm2-sleep-counter";
+		reg = <0x4a3000 0x1000>;
+		clock-frequency = <32768>;
+	};
+
+	cpu-pmu {
+		compatible = "arm,armv8-pmuv3";
+		interrupts = <1 7 0xff00>;
+	};
+
+	qcom,sps {
+		compatible = "qcom,msm_sps_4k";
+		qcom,pipe-attr-ee;
+	};
+
+	blsp1_uart0: serial@78af000 {
+		compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
+		reg = <0x78af000 0x200>;
+		interrupts = <0 107 0>;
+		status = "disabled";
+	};
+
+	dma_blsp1: qcom,sps-dma@7884000 { /* BLSP1 */
+		#dma-cells = <4>;
+		compatible = "qcom,sps-dma";
+		reg = <0x7884000 0x1f000>;
+		interrupts = <0 238 0>;
+		qcom,summing-threshold = <10>;
+	};
+
+	dma_blsp2: qcom,sps-dma@7ac4000 { /* BLSP2 */
+		#dma-cells = <4>;
+		compatible = "qcom,sps-dma";
+		reg = <0x7ac4000 0x1f000>;
+		interrupts = <0 239 0>;
+		qcom,summing-threshold = <10>;
+	};
+
+	slim_msm: slim@c140000{
+		cell-index = <1>;
+		compatible = "qcom,slim-ngd";
+		reg = <0xc140000 0x2c000>,
+		      <0xc104000 0x2a000>;
+		reg-names = "slimbus_physical", "slimbus_bam_physical";
+		interrupts = <0 163 0>, <0 180 0>;
+		interrupt-names = "slimbus_irq", "slimbus_bam_irq";
+		qcom,apps-ch-pipes = <0x600000>;
+		qcom,ea-pc = <0x200>;
+		status = "disabled";
+	};
+
+	cpubw: qcom,cpubw {
+		compatible = "qcom,devbw";
+		governor = "cpufreq";
+		qcom,src-dst-ports = <1 512>;
+		qcom,active-only;
+		qcom,bw-tbl =
+			<   769 /*  100.8 MHz */ >,
+			<  1611 /*  211.2 MHz */ >,     /*Low SVS*/
+			<  2124 /*  278.4 MHz */ >,
+			<  2929 /*  384   MHz */ >,
+			<  3221 /*  422.4 MHz */ >,	/* SVS */
+			<  4248 /*  556.8 MHz */ >,
+			<  5126 /*  672   MHz */ >,
+			<  5859 /*  768   MHz */ >,     /* SVS+  */
+			<  6152 /*  806.4 MHz */ >,
+			<  6445 /*  844.8 MHz */ >,     /* NOM   */
+			<  7104 /*  931.2 MHz */ >;     /* TURBO */
+	};
+
+	mincpubw: qcom,mincpubw {
+		compatible = "qcom,devbw";
+		governor = "cpufreq";
+		qcom,src-dst-ports = <1 512>;
+		qcom,active-only;
+		qcom,bw-tbl =
+			<   769 /*  100.8 MHz */ >,
+			<  1611 /*  211.2 MHz */ >,     /*Low SVS*/
+			<  2124 /*  278.4 MHz */ >,
+			<  2929 /*  384   MHz */ >,
+			<  3221 /*  422.4 MHz */ >,	/* SVS */
+			<  4248 /*  556.8 MHz */ >,
+			<  5126 /*  672   MHz */ >,
+			<  5859 /*  768   MHz */ >,     /* SVS+  */
+			<  6152 /*  806.4 MHz */ >,
+			<  6445 /*  844.8 MHz */ >,     /* NOM   */
+			<  7104 /*  931.2 MHz */ >;     /* TURBO */
+	};
+
+	qcom,cpu-bwmon {
+		compatible = "qcom,bimc-bwmon2";
+		reg = <0x408000 0x300>, <0x401000 0x200>;
+		reg-names = "base", "global_base";
+		interrupts = <0 183 4>;
+		qcom,mport = <0>;
+		qcom,target-dev = <&cpubw>;
+	};
+
+	devfreq-cpufreq {
+		cpubw-cpufreq {
+		target-dev = <&cpubw>;
+		cpu-to-dev-map =
+			 <  652800  1611>,
+			 < 1036800  3221>,
+			 < 1401600  5859>,
+			 < 1689600  6445>,
+			 < 1804800  7104>,
+			 < 1958400  7104>,
+			 < 2208000  7104>;
+		};
+
+		mincpubw-cpufreq {
+			target-dev = <&mincpubw>;
+			cpu-to-dev-map =
+				<  652800 1611 >,
+				< 1401600 3221 >,
+				< 2208000 5859 >;
+		};
+	};
+
+	qcom,ipc-spinlock@1905000 {
+		compatible = "qcom,ipc-spinlock-sfpb";
+		reg = <0x1905000 0x8000>;
+		qcom,num-locks = <8>;
+	};
+
+	qcom,smem@86300000 {
+		compatible = "qcom,smem";
+		reg = <0x86300000 0x100000>,
+			<0x0b011008 0x4>,
+			<0x60000 0x8000>,
+			<0x193d000 0x8>;
+		reg-names = "smem", "irq-reg-base",
+				"aux-mem1", "smem_targ_info_reg";
+		qcom,mpu-enabled;
+
+		qcom,smd-modem {
+			compatible = "qcom,smd";
+			qcom,smd-edge = <0>;
+			qcom,smd-irq-offset = <0x0>;
+			qcom,smd-irq-bitmask = <0x1000>;
+			interrupts = <0 25 1>;
+			label = "modem";
+			qcom,not-loadable;
+		};
+
+		qcom,smsm-modem {
+			compatible = "qcom,smsm";
+			qcom,smsm-edge = <0>;
+			qcom,smsm-irq-offset = <0x0>;
+			qcom,smsm-irq-bitmask = <0x2000>;
+			interrupts = <0 26 1>;
+		};
+
+		qcom,smd-wcnss {
+			compatible = "qcom,smd";
+			qcom,smd-edge = <6>;
+			qcom,smd-irq-offset = <0x0>;
+			qcom,smd-irq-bitmask = <0x20000>;
+			interrupts = <0 142 1>;
+			label = "wcnss";
+		};
+
+		qcom,smsm-wcnss {
+			compatible = "qcom,smsm";
+			qcom,smsm-edge = <6>;
+			qcom,smsm-irq-offset = <0x0>;
+			qcom,smsm-irq-bitmask = <0x80000>;
+			interrupts = <0 144 1>;
+		};
+
+		qcom,smd-adsp {
+			compatible = "qcom,smd";
+			qcom,smd-edge = <1>;
+			qcom,smd-irq-offset = <0x0>;
+			qcom,smd-irq-bitmask = <0x100>;
+			interrupts = <0 289 1>;
+			label = "adsp";
+		};
+
+		qcom,smsm-adsp {
+			compatible = "qcom,smsm";
+			qcom,smsm-edge = <1>;
+			qcom,smsm-irq-offset = <0x0>;
+			qcom,smsm-irq-bitmask = <0x200>;
+			interrupts = <0 290 1>;
+		};
+
+		qcom,smd-rpm {
+			compatible = "qcom,smd";
+			qcom,smd-edge = <15>;
+			qcom,smd-irq-offset = <0x0>;
+			qcom,smd-irq-bitmask = <0x1>;
+			interrupts = <0 168 1>;
+			label = "rpm";
+			qcom,irq-no-suspend;
+			qcom,not-loadable;
+		};
+	};
+
+	qcom,wdt@b017000 {
+		compatible = "qcom,msm-watchdog";
+		reg = <0xb017000 0x1000>;
+		reg-names = "wdt-base";
+		interrupts = <0 3 0>, <0 4 0>;
+		qcom,bark-time = <11000>;
+		qcom,pet-time = <10000>;
+		qcom,ipi-ping;
+		qcom,wakeup-enable;
+	};
+
+	qcom,chd {
+		compatible = "qcom,core-hang-detect";
+		qcom,threshold-arr = <0xb1880b0 0xb1980b0 0xb1a80b0
+			0xb1b80b0 0xb0880b0 0xb0980b0 0xb0a80b0 0xb0b80b0>;
+		qcom,config-arr = <0xb1880b8 0xb1980b8 0xb1a80b8
+			0xb1b80b8 0xb0880b8 0xb0980b8 0xb0a80b8 0xb0b80b8>;
+	};
+
+	qcom,msm-rtb {
+		compatible = "qcom,msm-rtb";
+		qcom,rtb-size = <0x100000>;
+	};
+
+	qcom,msm-imem@8600000 {
+		compatible = "qcom,msm-imem";
+		reg = <0x08600000 0x1000>;
+		ranges = <0x0 0x08600000 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		mem_dump_table@10 {
+			compatible = "qcom,msm-imem-mem_dump_table";
+			reg = <0x10 8>;
+		};
+
+		restart_reason@65c {
+			compatible = "qcom,msm-imem-restart_reason";
+			reg = <0x65c 4>;
+		};
+
+		boot_stats@6b0 {
+			compatible = "qcom,msm-imem-boot_stats";
+			reg = <0x6b0 32>;
+		};
+
+		 pil@94c {
+			compatible = "qcom,msm-imem-pil";
+			reg = <0x94c 200>;
+
+		};
+	};
+
+	qcom,memshare {
+		compatible = "qcom,memshare";
+
+		qcom,client_1 {
+			compatible = "qcom,memshare-peripheral";
+			qcom,peripheral-size = <0x200000>;
+			qcom,client-id = <0>;
+			qcom,allocate-boot-time;
+			label = "modem";
+		};
+
+		qcom,client_2 {
+			compatible = "qcom,memshare-peripheral";
+			qcom,peripheral-size = <0x300000>;
+			qcom,client-id = <2>;
+			label = "modem";
+		};
+
+		mem_client_3_size: qcom,client_3 {
+			compatible = "qcom,memshare-peripheral";
+			qcom,peripheral-size = <0x0>;
+			qcom,client-id = <1>;
+			label = "modem";
+		};
+	};
+		sdcc1_ice: sdcc1ice@7803000 {
+		compatible = "qcom,ice";
+		reg = <0x7803000 0x8000>;
+		interrupt-names = "sdcc_ice_nonsec_level_irq",
+				  "sdcc_ice_sec_level_irq";
+		interrupts = <0 312 0>, <0 313 0>;
+		qcom,enable-ice-clk;
+		qcom,op-freq-hz = <270000000>, <0>, <0>, <0>;
+		qcom,msm-bus,name = "sdcc_ice_noc";
+		qcom,msm-bus,num-cases = <2>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+			<78 512 0 0>,    /* No vote */
+			<78 512 1000 0>; /* Max. bandwidth */
+		qcom,bus-vector-names = "MIN", "MAX";
+		qcom,instance-type = "sdcc";
+	};
+
+	sdhc_1: sdhci@7824900 {
+		compatible = "qcom,sdhci-msm";
+		reg = <0x7824900 0x500>, <0x7824000 0x800>, <0x7824e00 0x200>;
+		reg-names = "hc_mem", "core_mem", "cmdq_mem";
+
+		interrupts = <0 123 0>, <0 138 0>;
+		interrupt-names = "hc_irq", "pwr_irq";
+
+		sdhc-msm-crypto = <&sdcc1_ice>;
+		qcom,bus-width = <8>;
+
+		qcom,devfreq,freq-table = <50000000 200000000>;
+
+		qcom,pm-qos-irq-type = "affine_irq";
+		qcom,pm-qos-irq-latency = <2 213>;
+
+		qcom,pm-qos-cpu-groups = <0x0f 0xf0>;
+		qcom,pm-qos-cmdq-latency-us = <2 213>, <2 213>;
+
+		qcom,pm-qos-legacy-latency-us = <2 213>, <2 213>;
+
+		qcom,msm-bus,name = "sdhc1";
+		qcom,msm-bus,num-cases = <9>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps = <78 512 0 0>, /* No vote */
+			<78 512 1046 3200>,    /* 400 KB/s*/
+			<78 512 52286 160000>, /* 20 MB/s */
+			<78 512 65360 200000>, /* 25 MB/s */
+			<78 512 130718 400000>, /* 50 MB/s */
+			<78 512 130718 400000>, /* 100 MB/s */
+			<78 512 261438 800000>, /* 200 MB/s */
+			<78 512 261438 800000>, /* 400 MB/s */
+			<78 512 1338562 4096000>; /* Max. bandwidth */
+		qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
+			100000000 200000000 400000000 4294967295>;
+
+		qcom,ice-clk-rates = <270000000 160000000>;
+		qcom,large-address-bus;
+
+		status = "disabled";
+	};
+
+	sdhc_2: sdhci@7864900 {
+		compatible = "qcom,sdhci-msm";
+		reg = <0x7864900 0x500>, <0x7864000 0x800>;
+		reg-names = "hc_mem", "core_mem";
+
+		interrupts = <0 125 0>, <0 221 0>;
+		interrupt-names = "hc_irq", "pwr_irq";
+
+		qcom,bus-width = <4>;
+
+		qcom,pm-qos-irq-type = "affine_irq";
+		qcom,pm-qos-irq-latency = <2 213>;
+
+		qcom,pm-qos-cpu-groups = <0x0f 0xf0>;
+		qcom,pm-qos-legacy-latency-us = <2 213>, <2 213>;
+
+		qcom,devfreq,freq-table = <50000000 200000000>;
+
+		qcom,msm-bus,name = "sdhc2";
+		qcom,msm-bus,num-cases = <8>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps = <81 512 0 0>, /* No vote */
+			<81 512 1046 3200>,    /* 400 KB/s*/
+			<81 512 52286 160000>, /* 20 MB/s */
+			<81 512 65360 200000>, /* 25 MB/s */
+			<81 512 130718 400000>, /* 50 MB/s */
+			<81 512 261438 800000>, /* 100 MB/s */
+			<81 512 261438 800000>, /* 200 MB/s */
+			<81 512 1338562 4096000>; /* Max. bandwidth */
+		qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
+			100000000 200000000 4294967295>;
+
+		qcom,large-address-bus;
+		status = "disabled";
+	};
+
+};
+
diff --git a/arch/arm64/boot/dts/qcom/pm660.dtsi b/arch/arm64/boot/dts/qcom/pm660.dtsi
index 5f23b91..1fdb3f6 100644
--- a/arch/arm64/boot/dts/qcom/pm660.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm660.dtsi
@@ -12,9 +12,10 @@
 
 #include <dt-bindings/spmi/spmi.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/thermal/thermal.h>
 
 &spmi_bus {
-	qcom,pm660@0 {
+	pm660_0: qcom,pm660@0 {
 		compatible ="qcom,spmi-pmic";
 		reg = <0x0 SPMI_USID>;
 		#address-cells = <2>;
@@ -58,100 +59,33 @@
 			};
 		};
 
-		qcom,temp-alarm@2400 {
+		pm660_tz: qcom,temp-alarm@2400 {
 			compatible = "qcom,qpnp-temp-alarm";
 			reg = <0x2400 0x100>;
 			interrupts = <0x0 0x24 0x0 IRQ_TYPE_EDGE_RISING>;
 			label = "pm660_tz";
 			qcom,channel-num = <6>;
 			qcom,temp_alarm-vadc = <&pm660_vadc>;
+			#thermal-sensor-cells = <0>;
 		};
 
-		pm660_gpios: gpios {
-			compatible = "qcom,qpnp-pin";
+		pm660_gpios: pinctrl@c000 {
+			compatible = "qcom,spmi-gpio";
+			reg = <0xc000 0xd00>;
+			interrupts = <0x0 0xc1 0 IRQ_TYPE_NONE>,
+					<0x0 0xc2 0 IRQ_TYPE_NONE>,
+					<0x0 0xc3 0 IRQ_TYPE_NONE>,
+					<0x0 0xc8 0 IRQ_TYPE_NONE>,
+					<0x0 0xca 0 IRQ_TYPE_NONE>,
+					<0x0 0xcb 0 IRQ_TYPE_NONE>,
+					<0x0 0xcc 0 IRQ_TYPE_NONE>;
+			interrupt-names = "pm660_gpio2", "pm660_gpio3",
+					"pm660_gpio4", "pm660_gpio9",
+					"pm660_gpio11", "pm660_gpio12",
+					"pm660_gpio13";
 			gpio-controller;
 			#gpio-cells = <2>;
-			#address-cells = <1>;
-			#size-cells = <1>;
-			label = "pm660-gpio";
-
-			gpio@c000 {
-				reg = <0xc000 0x100>;
-				qcom,pin-num = <1>;
-				status = "disabled";
-			};
-
-			gpio@c100 {
-				reg = <0xc100 0x100>;
-				qcom,pin-num = <2>;
-				status = "disabled";
-			};
-
-			gpio@c200 {
-				reg = <0xc200 0x100>;
-				qcom,pin-num = <3>;
-				status = "disabled";
-			};
-
-			gpio@c300 {
-				reg = <0xc300 0x100>;
-				qcom,pin-num = <4>;
-				status = "disabled";
-			};
-
-			gpio@c400 {
-				reg = <0xc400 0x100>;
-				qcom,pin-num = <5>;
-				status = "disabled";
-			};
-
-			gpio@c500 {
-				reg = <0xc500 0x100>;
-				qcom,pin-num = <6>;
-				status = "disabled";
-			};
-
-			gpio@c600 {
-				reg = <0xc600 0x100>;
-				qcom,pin-num = <7>;
-				status = "disabled";
-			};
-
-			gpio@c700 {
-				reg = <0xc700 0x100>;
-				qcom,pin-num = <8>;
-				status = "disabled";
-			};
-
-			gpio@c800 {
-				reg = <0xc800 0x100>;
-				qcom,pin-num = <9>;
-				status = "disabled";
-			};
-
-			gpio@c900 {
-				reg = <0xc900 0x100>;
-				qcom,pin-num = <10>;
-				status = "disabled";
-			};
-
-			gpio@ca00 {
-				reg = <0xca00 0x100>;
-				qcom,pin-num = <11>;
-				status = "disabled";
-			};
-
-			gpio@cb00 {
-				reg = <0xcb00 0x100>;
-				qcom,pin-num = <12>;
-				status = "disabled";
-			};
-
-			gpio@cc00 {
-				reg = <0xcc00 0x100>;
-				qcom,pin-num = <13>;
-				status = "disabled";
-			};
+			qcom,gpios-disallowed = <1 5 6 7 8 10>;
 		};
 
 		pm660_coincell: qcom,coincell@2800 {
@@ -313,149 +247,12 @@
 			};
 		};
 
-		pm660_charger: qcom,qpnp-smb2 {
-			compatible = "qcom,qpnp-smb2";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			qcom,pmic-revid = <&pm660_revid>;
-
-			io-channels = <&pm660_rradc 8>,
-				      <&pm660_rradc 10>,
-				      <&pm660_rradc 3>,
-				      <&pm660_rradc 4>;
-			io-channel-names = "charger_temp",
-					   "charger_temp_max",
-					   "usbin_i",
-					   "usbin_v";
-
-			qcom,wipower-max-uw = <5000000>;
-
-			/* Enable after the qusb_phy0 device node is added */
-			/* dpdm-supply = <&qusb_phy0>; */
-
-			qcom,thermal-mitigation
-					= <3000000 2500000 2000000 1500000
-						1000000 500000>;
-
-			qcom,chgr@1000 {
-				reg = <0x1000 0x100>;
-				interrupts =
-					<0x0 0x10 0x0 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x10 0x1 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x10 0x2 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x10 0x3 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x10 0x4 IRQ_TYPE_EDGE_RISING>;
-
-				interrupt-names = "chg-error",
-						  "chg-state-change",
-						  "step-chg-state-change",
-						  "step-chg-soc-update-fail",
-						  "step-chg-soc-update-request";
-			};
-
-			qcom,otg@1100 {
-				reg = <0x1100 0x100>;
-				interrupts = <0x0 0x11 0x0 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x11 0x1 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x11 0x2 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x11 0x3 IRQ_TYPE_EDGE_BOTH>;
-
-				interrupt-names = "otg-fail",
-						  "otg-overcurrent",
-						  "otg-oc-dis-sw-sts",
-						  "testmode-change-detect";
-			};
-
-			qcom,bat-if@1200 {
-				reg = <0x1200 0x100>;
-				interrupts =
-					<0x0 0x12 0x0 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x12 0x1 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x12 0x5 IRQ_TYPE_EDGE_BOTH>;
-
-				interrupt-names = "bat-temp",
-						  "bat-ocp",
-						  "bat-ov",
-						  "bat-low",
-						  "bat-therm-or-id-missing",
-						  "bat-terminal-missing";
-			};
-
-			qcom,usb-chgpth@1300 {
-				reg = <0x1300 0x100>;
-				interrupts =
-					<0x0 0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x13 0x5 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>;
-
-				interrupt-names = "usbin-collapse",
-						  "usbin-lt-3p6v",
-						  "usbin-uv",
-						  "usbin-ov",
-						  "usbin-plugin",
-						  "usbin-src-change",
-						  "usbin-icl-change",
-						  "type-c-change";
-			};
-
-			qcom,dc-chgpth@1400 {
-				reg = <0x1400 0x100>;
-				interrupts =
-					<0x0 0x14 0x0 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x14 0x6 IRQ_TYPE_EDGE_RISING>;
-
-				interrupt-names = "dcin-collapse",
-						  "dcin-lt-3p6v",
-						  "dcin-uv",
-						  "dcin-ov",
-						  "dcin-plugin",
-						  "div2-en-dg",
-						  "dcin-icl-change";
-			};
-
-			qcom,chgr-misc@1600 {
-				reg = <0x1600 0x100>;
-				interrupts =
-					<0x0 0x16 0x0 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
-					<0x0 0x16 0x2 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x16 0x3 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x16 0x4 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x16 0x5 IRQ_TYPE_EDGE_BOTH>,
-					<0x0 0x16 0x6 IRQ_TYPE_EDGE_FALLING>,
-					<0x0 0x16 0x7 IRQ_TYPE_EDGE_BOTH>;
-
-				interrupt-names = "wdog-snarl",
-						  "wdog-bark",
-						  "aicl-fail",
-						  "aicl-done",
-						  "high-duty-cycle",
-						  "input-current-limiting",
-						  "temperature-change",
-						  "switcher-power-ok";
-			};
-		};
-
 		pm660_pdphy: qcom,usb-pdphy@1700 {
 			compatible = "qcom,qpnp-pdphy";
 			reg = <0x1700 0x100>;
 			vdd-pdphy-supply = <&pm660l_l7>;
-			vbus-supply = <&smb2_vbus>;
-			vconn-supply = <&smb2_vconn>;
+			vbus-supply = <0>;
+			vconn-supply = <0>;
 			interrupts = <0x0 0x17 0x0 IRQ_TYPE_EDGE_RISING>,
 				     <0x0 0x17 0x1 IRQ_TYPE_EDGE_RISING>,
 				     <0x0 0x17 0x2 IRQ_TYPE_EDGE_RISING>,
@@ -556,123 +353,31 @@
 			};
 		};
 
-		pm660_rradc: rradc@4500 {
-			compatible = "qcom,rradc";
-			reg = <0x4500 0x100>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			#io-channel-cells = <1>;
-			qcom,pmic-revid = <&pm660_revid>;
-		};
-
-		pm660_fg: qpnp,fg {
-			compatible = "qcom,fg-gen3";
-			#address-cells = <1>;
-			#size-cells = <1>;
-			qcom,pmic-revid = <&pm660_revid>;
-			io-channels = <&pm660_rradc 0>,
-				      <&pm660_rradc 7>;
-			io-channel-names = "rradc_batt_id",
-					   "rradc_die_temp";
-			qcom,rradc-base = <0x4500>;
-			qcom,fg-esr-timer-awake = <96 96>;
-			qcom,fg-esr-timer-asleep = <256 256>;
-			qcom,fg-esr-timer-charging = <0 96>;
-			qcom,cycle-counter-en;
-			status = "okay";
-
-			qcom,fg-batt-soc@4000 {
-				status = "okay";
-				reg = <0x4000 0x100>;
-				interrupts = <0x0 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x40 0x2
-							IRQ_TYPE_EDGE_RISING>,
-					     <0x0 0x40 0x3
-							IRQ_TYPE_EDGE_RISING>,
-					     <0x0 0x40 0x4 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x40 0x5
-							IRQ_TYPE_EDGE_RISING>,
-					     <0x0 0x40 0x6 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x40 0x7 IRQ_TYPE_EDGE_BOTH>;
-				interrupt-names = "soc-update",
-						  "soc-ready",
-						  "bsoc-delta",
-						  "msoc-delta",
-						  "msoc-low",
-						  "msoc-empty",
-						  "msoc-high",
-						  "msoc-full";
-			};
-
-			qcom,fg-batt-info@4100 {
-				status = "okay";
-				reg = <0x4100 0x100>;
-				interrupts = <0x0 0x41 0x0 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x41 0x1 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x41 0x2 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x41 0x3 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x41 0x6 IRQ_TYPE_EDGE_BOTH>;
-				interrupt-names = "vbatt-pred-delta",
-						  "vbatt-low",
-						  "esr-delta",
-						  "batt-missing",
-						  "batt-temp-delta";
-			};
-
-			qcom,fg-memif@4400 {
-				status = "okay";
-				reg = <0x4400 0x100>;
-				interrupts = <0x0 0x44 0x0 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x44 0x1 IRQ_TYPE_EDGE_BOTH>,
-					     <0x0 0x44 0x2 IRQ_TYPE_EDGE_BOTH>;
-				interrupt-names = "ima-rdy",
-						  "mem-xcp",
-						  "dma-grant";
-			};
-		};
-
-		bcl@4200 {
+		bcl_sensor: bcl@4200 {
 			compatible = "qcom,msm-bcl-lmh";
 			reg = <0x4200 0xff>,
 				<0x4300 0xff>;
 			reg-names = "fg_user_adc",
 					"fg_lmh";
 			interrupts = <0x0 0x42 0x0 IRQ_TYPE_NONE>,
-					<0x0 0x42 0x2 IRQ_TYPE_NONE>;
-			interrupt-names = "bcl-high-ibat-int",
-					"bcl-low-vbat-int";
-			qcom,vbat-polling-delay-ms = <100>;
-			qcom,ibat-polling-delay-ms = <100>;
+					<0x0 0x42 0x1 IRQ_TYPE_NONE>,
+					<0x0 0x42 0x2 IRQ_TYPE_NONE>,
+					<0x0 0x42 0x3 IRQ_TYPE_NONE>,
+					<0x0 0x42 0x4 IRQ_TYPE_NONE>;
+			interrupt-names = "bcl-high-ibat",
+						"bcl-very-high-ibat",
+						"bcl-low-vbat",
+						"bcl-very-low-vbat",
+						"bcl-crit-low-vbat";
+			#thermal-sensor-cells = <1>;
 		};
 	};
 
-	qcom,pm660@1 {
+	pm660_1: qcom,pm660@1 {
 		compatible ="qcom,spmi-pmic";
 		reg = <0x1 SPMI_USID>;
 		#address-cells = <2>;
 		#size-cells = <0>;
-
-		pm660_haptics: qcom,haptics@c000 {
-			compatible = "qcom,qpnp-haptics";
-			reg = <0xc000 0x100>;
-			interrupts = <0x1 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
-				     <0x1 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
-			interrupt-names = "hap-sc-irq", "hap-play-irq";
-			qcom,pmic-revid = <&pm660_revid>;
-			qcom,pmic-misc = <&pm660_misc>;
-			qcom,misc-clk-trim-error-reg = <0xf3>;
-			qcom,actuator-type = <0>;
-			qcom,play-mode = "direct";
-			qcom,vmax-mv = <3200>;
-			qcom,ilim-ma = <800>;
-			qcom,sc-dbc-cycles = <8>;
-			qcom,wave-play-rate-us = <6667>;
-			qcom,en-brake;
-			qcom,lra-high-z = "opt0";
-			qcom,lra-auto-res-mode = "qwd";
-			qcom,lra-res-cal-period = <4>;
-		};
 	};
 };
 
@@ -751,4 +456,243 @@
 			};
 		};
 	};
+
+	ibat-high {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		thermal-sensors = <&bcl_sensor 0>;
+
+		trips {
+			ibat-high {
+				temperature = <4200>;
+				hysteresis = <200>;
+				type = "passive";
+			};
+		};
+	};
+
+	ibat-vhigh {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		thermal-sensors = <&bcl_sensor 1>;
+
+		trips {
+			ibat-vhigh {
+				temperature = <4300>;
+				hysteresis = <100>;
+				type = "passive";
+			};
+		};
+	};
+
+	vbat_adc {
+		polling-delay-passive = <100>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_cap";
+		thermal-sensors = <&bcl_sensor 2>;
+		tracks-low;
+
+		trips {
+			pm660_vbat_adc: vbat-adc {
+				temperature = <3300>;
+				hysteresis = <100>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			vbat_map6 {
+				trip = <&pm660_vbat_adc>;
+				cooling-device =
+					<&CPU6 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			vbat_map7 {
+				trip = <&pm660_vbat_adc>;
+				cooling-device =
+					<&CPU7 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+		};
+	};
+
+	vbat_low {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_cap";
+		thermal-sensors = <&bcl_sensor 3>;
+		tracks-low;
+
+		trips {
+			vbat-low {
+				temperature = <3100>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+	};
+
+	vbat_too_low {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_cap";
+		thermal-sensors = <&bcl_sensor 4>;
+		tracks-low;
+
+		trips {
+			vbat-too-low {
+				temperature = <2900>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+	};
+
+	soc {
+		polling-delay-passive = <100>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_cap";
+		thermal-sensors = <&bcl_sensor 5>;
+		tracks-low;
+
+		trips {
+			pm660_low_soc: low-soc {
+				temperature = <10>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			soc_map6 {
+				trip = <&pm660_low_soc>;
+				cooling-device =
+					<&CPU6 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			soc_map7 {
+				trip = <&pm660_low_soc>;
+				cooling-device =
+					<&CPU7 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+		};
+	};
+
+	pm660_temp_alarm: pm660_tz {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		thermal-sensors = <&pm660_tz>;
+
+		trips {
+			pm660_trip0: pm660-trip0 {
+				temperature = <105000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+			pm660_trip1: pm660-trip1 {
+				temperature = <125000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+			pm660_trip2: pm660-trip2 {
+				temperature = <145000>;
+				hysteresis = <0>;
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			trip0_cpu0 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU0 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu1 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU1 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu2 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU2 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu3 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU3 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu4 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU4 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu5 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU5 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu6 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU6 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip0_cpu7 {
+				trip = <&pm660_trip0>;
+				cooling-device =
+					<&CPU7 (THERMAL_MAX_LIMIT-1)
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			trip1_cpu1 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU1 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu2 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU2 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu3 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU3 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu4 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU4 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu5 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU5 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu6 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU6 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+			trip1_cpu7 {
+				trip = <&pm660_trip1>;
+				cooling-device =
+					<&CPU7 THERMAL_MAX_LIMIT
+						THERMAL_MAX_LIMIT>;
+			};
+		};
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/pm660l.dtsi b/arch/arm64/boot/dts/qcom/pm660l.dtsi
index 075eaef2..aaf5d05 100644
--- a/arch/arm64/boot/dts/qcom/pm660l.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm660l.dtsi
@@ -39,93 +39,35 @@
 				<PON_POWER_OFF_SHUTDOWN>;
 		};
 
-		qcom,temp-alarm@2400 {
+		pm660l_tz: qcom,temp-alarm@2400 {
 			compatible = "qcom,qpnp-temp-alarm";
 			reg = <0x2400 0x100>;
 			interrupts = <0x2 0x24 0x0 IRQ_TYPE_EDGE_RISING>;
 			label = "pm660l_tz";
+			#thermal-sensor-cells = <0>;
 		};
 
-		pm660l_gpios: gpios {
-			compatible = "qcom,qpnp-pin";
+		pm660l_gpios: pinctrl@c000 {
+			compatible = "qcom,spmi-gpio";
+			reg = <0xc000 0xc00>;
+			interrupts = <0x2 0xc0 0 IRQ_TYPE_NONE>,
+					<0x2 0xc2 0 IRQ_TYPE_NONE>,
+					<0x2 0xc3 0 IRQ_TYPE_NONE>,
+					<0x2 0xc4 0 IRQ_TYPE_NONE>,
+					<0x2 0xc5 0 IRQ_TYPE_NONE>,
+					<0x2 0xc6 0 IRQ_TYPE_NONE>,
+					<0x2 0xc7 0 IRQ_TYPE_NONE>,
+					<0x2 0xc8 0 IRQ_TYPE_NONE>,
+					<0x2 0xca 0 IRQ_TYPE_NONE>,
+					<0x2 0xcb 0 IRQ_TYPE_NONE>;
+			interrupt-names = "pm660l_gpio1", "pm660l_gpio3",
+					"pm660l_gpio4", "pm660l_gpio5",
+					"pm660l_gpio6", "pm660l_gpio7",
+					"pm660l_gpio8", "pm660l_gpio9",
+					"pm660l_gpio11", "pm660l_gpio12";
 			gpio-controller;
 			#gpio-cells = <2>;
-			#address-cells = <1>;
-			#size-cells = <1>;
-			label = "pm660l-gpio";
-
-			gpio@c000 {
-				reg = <0xc000 0x100>;
-				qcom,pin-num = <1>;
-				status = "disabled";
-			};
-
-			gpio@c100 {
-				reg = <0xc100 0x100>;
-				qcom,pin-num = <2>;
-				status = "disabled";
-			};
-
-			gpio@c200 {
-				reg = <0xc200 0x100>;
-				qcom,pin-num = <3>;
-				status = "disabled";
-			};
-
-			gpio@c300 {
-				reg = <0xc300 0x100>;
-				qcom,pin-num = <4>;
-				status = "disabled";
-			};
-
-			gpio@c400 {
-				reg = <0xc400 0x100>;
-				qcom,pin-num = <5>;
-				status = "disabled";
-			};
-
-			gpio@c500 {
-				reg = <0xc500 0x100>;
-				qcom,pin-num = <6>;
-				status = "disabled";
-			};
-
-			gpio@c600 {
-				reg = <0xc600 0x100>;
-				qcom,pin-num = <7>;
-				status = "disabled";
-			};
-
-			gpio@c700 {
-				reg = <0xc700 0x100>;
-				qcom,pin-num = <8>;
-				status = "disabled";
-			};
-
-			gpio@c800 {
-				reg = <0xc800 0x100>;
-				qcom,pin-num = <9>;
-				status = "disabled";
-			};
-
-			gpio@c900 {
-				reg = <0xc900 0x100>;
-				qcom,pin-num = <10>;
-				status = "disabled";
-			};
-
-			gpio@ca00 {
-				reg = <0xca00 0x100>;
-				qcom,pin-num = <11>;
-				status = "disabled";
-			};
-
-			gpio@cb00 {
-				reg = <0xcb00 0x100>;
-				qcom,pin-num = <12>;
-				status = "disabled";
-			};
-
+			qcom,gpios-disallowed = <2 10>;
 		};
 	};
 
@@ -244,35 +186,6 @@
 			};
 		};
 
-		pm660l_wled: qcom,leds@d800 {
-			compatible = "qcom,qpnp-wled";
-			reg = <0xd800 0x100>,
-				<0xd900 0x100>;
-			reg-names = "qpnp-wled-ctrl-base",
-					"qpnp-wled-sink-base";
-			interrupts = <0x3 0xd8 0x1 IRQ_TYPE_EDGE_RISING>;
-			interrupt-names = "ovp-irq";
-			linux,name = "wled";
-			linux,default-trigger = "bkl-trigger";
-			qcom,fdbk-output = "auto";
-			qcom,vref-uv = <127500>;
-			qcom,switch-freq-khz = <800>;
-			qcom,ovp-mv = <29600>;
-			qcom,ilim-ma = <970>;
-			qcom,boost-duty-ns = <26>;
-			qcom,mod-freq-khz = <9600>;
-			qcom,dim-mode = "hybrid";
-			qcom,hyb-thres = <625>;
-			qcom,sync-dly-us = <800>;
-			qcom,fs-curr-ua = <25000>;
-			qcom,cons-sync-write-delay-us = <1000>;
-			qcom,led-strings-list = [00 01 02];
-			qcom,loop-auto-gm-en;
-			qcom,pmic-revid = <&pm660l_revid>;
-			qcom,auto-calibration-enable;
-			status = "ok";
-		};
-
 		flash_led: qcom,leds@d300 {
 			compatible = "qcom,qpnp-flash-led-v2";
 			reg = <0xd300 0x100>;
@@ -381,88 +294,30 @@
 				qcom,default-led-trigger = "switch1_trigger";
 			};
 		};
+	};
+};
 
-		pm660l_lcdb: qpnp-lcdb@ec00 {
-			compatible = "qcom,qpnp-lcdb-regulator";
-			#address-cells = <1>;
-			#size-cells = <1>;
-			reg = <0xec00 0x100>;
-			interrupts = <0x3 0xec 0x1 IRQ_TYPE_EDGE_RISING>;
-			interrupt-names = "sc-irq";
+&thermal_zones {
+	pm660l_tz {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&pm660l_tz>;
 
-			qcom,pmic-revid = <&pm660l_revid>;
-
-			lcdb_ldo_vreg: ldo {
-				label = "ldo";
-				regulator-name = "lcdb_ldo";
-				regulator-min-microvolt = <4000000>;
-				regulator-max-microvolt = <6000000>;
+		trips {
+			pm660l_trip0: pm660l-trip0 {
+				temperature = <105000>;
+				hysteresis = <0>;
+				type = "passive";
 			};
-
-			lcdb_ncp_vreg: ncp {
-				label = "ncp";
-				regulator-name = "lcdb_ncp";
-				regulator-min-microvolt = <4000000>;
-				regulator-max-microvolt = <6000000>;
+			 pm660l_trip1: pm660l-trip1 {
+				temperature = <125000>;
+				hysteresis = <0>;
+				type = "passive";
 			};
-		};
-
-		pm660a_oledb: qpnp-oledb@e000 {
-		       compatible = "qcom,qpnp-oledb-regulator";
-		       #address-cells = <1>;
-		       #size-cells = <1>;
-		       qcom,pmic-revid = <&pm660l_revid>;
-		       reg = <0xe000 0x100>;
-		       qcom,pbs-client = <&pm660l_pbs>;
-
-		       label = "oledb";
-		       regulator-name = "regulator-oledb";
-		       regulator-min-microvolt = <5000000>;
-		       regulator-max-microvolt = <8100000>;
-
-		       qcom,swire-control;
-		       qcom,ext-pin-control;
-		       status = "disabled";
-		};
-
-		pm660a_labibb: qpnp-labibb-regulator {
-			compatible = "qcom,qpnp-labibb-regulator";
-			#address-cells = <1>;
-			#size-cells = <1>;
-			qcom,pmic-revid = <&pm660l_revid>;
-			qcom,swire-control;
-			status = "disabled";
-
-			ibb_regulator: qcom,ibb@dc00 {
-				reg = <0xdc00 0x100>;
-				reg-names = "ibb_reg";
-				regulator-name = "ibb_reg";
-
-				regulator-min-microvolt = <4000000>;
-				regulator-max-microvolt = <6300000>;
-
-				qcom,qpnp-ibb-min-voltage = <1400000>;
-				qcom,qpnp-ibb-step-size = <100000>;
-				qcom,qpnp-ibb-slew-rate = <2000000>;
-				qcom,qpnp-ibb-init-voltage = <4000000>;
-				qcom,qpnp-ibb-init-amoled-voltage = <4000000>;
-			};
-
-			lab_regulator: qcom,lab@de00 {
-				reg = <0xde00 0x100>;
-				reg-names = "lab";
-				regulator-name = "lab_reg";
-
-				regulator-min-microvolt = <4600000>;
-				regulator-max-microvolt = <6100000>;
-
-				qcom,qpnp-lab-min-voltage = <4600000>;
-				qcom,qpnp-lab-step-size = <100000>;
-				qcom,qpnp-lab-slew-rate = <5000>;
-				qcom,qpnp-lab-init-voltage = <4600000>;
-				qcom,qpnp-lab-init-amoled-voltage = <4600000>;
-
-				qcom,notify-lab-vreg-ok-sts;
+			 pm660l_trip2: pm660l-trip2 {
+				temperature = <145000>;
+				hysteresis = <0>;
+				type = "critical";
 			};
 		};
 	};
diff --git a/arch/arm64/boot/dts/qcom/pm8998.dtsi b/arch/arm64/boot/dts/qcom/pm8998.dtsi
index 450295e..013ac48 100644
--- a/arch/arm64/boot/dts/qcom/pm8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8998.dtsi
@@ -192,6 +192,33 @@
 			qcom,fast-avg-setup = <0>;
 			#thermal-sensor-cells = <1>;
 		};
+
+		pm8998_div_clk1: qcom,clkdiv@5b00 {
+			compatible = "qcom,qpnp-clkdiv";
+			reg = <0x5b00 0x100>;
+			#clock-cells = <1>;
+			qcom,cxo-freq = <19200000>;
+			qcom,clkdiv-id = <1>;
+			qcom,clkdiv-init-freq = <19200000>;
+		};
+
+		pm8998_div_clk2: qcom,clkdiv@5c00 {
+			compatible = "qcom,qpnp-clkdiv";
+			reg = <0x5c00 0x100>;
+			#clock-cells = <1>;
+			qcom,cxo-freq = <19200000>;
+			qcom,clkdiv-id = <2>;
+			qcom,clkdiv-init-freq = <19200000>;
+		};
+
+		pm8998_div_clk3: qcom,clkdiv@5d00 {
+			compatible = "qcom,qpnp-clkdiv";
+			reg = <0x5d00 0x100>;
+			#clock-cells = <1>;
+			qcom,cxo-freq = <19200000>;
+			qcom,clkdiv-id = <3>;
+			qcom,clkdiv-init-freq = <19200000>;
+		};
 	};
 
 	qcom,pm8998@1 {
diff --git a/arch/arm64/boot/dts/qcom/pmi8998.dtsi b/arch/arm64/boot/dts/qcom/pmi8998.dtsi
index a8b826a..1ee6d51 100644
--- a/arch/arm64/boot/dts/qcom/pmi8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmi8998.dtsi
@@ -328,7 +328,8 @@
 				reg = <0x4400 0x100>;
 				interrupts = <0x2 0x44 0x0 IRQ_TYPE_EDGE_BOTH>,
 					     <0x2 0x44 0x1 IRQ_TYPE_EDGE_BOTH>,
-					     <0x2 0x44 0x2 IRQ_TYPE_EDGE_BOTH>;
+					     <0x2 0x44 0x2
+							IRQ_TYPE_EDGE_RISING>;
 				interrupt-names = "ima-rdy",
 						  "mem-xcp",
 						  "dma-grant";
diff --git a/arch/arm64/boot/dts/qcom/qcs605-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/qcs605-cdp-overlay.dts
new file mode 100644
index 0000000..fe7a027
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-cdp-overlay.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L CDP";
+	compatible = "qcom,qcs605-cdp", "qcom,qcs605", "qcom,cdp";
+	qcom,msm-id = <347 0x0>;
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/qcs605-cdp.dts b/arch/arm64/boot/dts/qcom/qcs605-cdp.dts
new file mode 100644
index 0000000..7b38a58
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-cdp.dts
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "qcs605.dtsi"
+#include "sdm670-cdp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L CDP";
+	compatible = "qcom,qcs605-cdp", "qcom,qcs605", "qcom,cdp";
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp-overlay.dts
new file mode 100644
index 0000000..1f439ae
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L Ext. Audio Codec MTP";
+	compatible = "qcom,qcs605-mtp", "qcom,qcs605", "qcom,mtp";
+	qcom,msm-id = <347 0x0>;
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp.dts b/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp.dts
new file mode 100644
index 0000000..abc3f2d
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-external-codec-mtp.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "qcs605.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L Ext. Audio Codec MTP";
+	compatible = "qcom,qcs605-mtp", "qcom,qcs605", "qcom,mtp";
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/qcs605-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/qcs605-mtp-overlay.dts
new file mode 100644
index 0000000..7327440
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L MTP";
+	compatible = "qcom,qcs605-mtp", "qcom,qcs605", "qcom,mtp";
+	qcom,msm-id = <347 0x0>;
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/qcs605-mtp.dts b/arch/arm64/boot/dts/qcom/qcs605-mtp.dts
new file mode 100644
index 0000000..bc7b376
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/qcs605-mtp.dts
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "qcs605.dtsi"
+#include "sdm670-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 PM660 + PM660L MTP";
+	compatible = "qcom,qcs605-mtp", "qcom,qcs605", "qcom,mtp";
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/arch/arm64/boot/dts/qcom/qcs605.dts
similarity index 68%
copy from sound/soc/codecs/audio-ext-clk-up.h
copy to arch/arm64/boot/dts/qcom/qcs605.dts
index 8a0232e..28c417f 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/arch/arm64/boot/dts/qcom/qcs605.dts
@@ -7,14 +7,16 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
+/dts-v1/;
 
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
+#include "qcs605.dtsi"
 
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605 SoC";
+	compatible = "qcom,qcs605";
+	qcom,board-id = <0 0>;
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/arch/arm64/boot/dts/qcom/qcs605.dtsi
similarity index 68%
copy from sound/soc/codecs/audio-ext-clk-up.h
copy to arch/arm64/boot/dts/qcom/qcs605.dtsi
index 8a0232e..12da650 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/arch/arm64/boot/dts/qcom/qcs605.dtsi
@@ -7,14 +7,13 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
+#include "sda670.dtsi"
 
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
-
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. QCS605";
+	qcom,msm-id = <347 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda670-cdp-overlay.dts
new file mode 100644
index 0000000..141ed59
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-cdp-overlay.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660L CDP";
+	compatible = "qcom,sda670-cdp", "qcom,sda670", "qcom,cdp";
+	qcom,msm-id = <337 0x0>;
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-cdp.dts b/arch/arm64/boot/dts/qcom/sda670-cdp.dts
new file mode 100644
index 0000000..fcb340e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-cdp.dts
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sda670.dtsi"
+#include "sdm670-cdp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660L CDP";
+	compatible = "qcom,sda670-cdp", "qcom,sda670", "qcom,cdp";
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda670-mtp-overlay.dts
new file mode 100644
index 0000000..af8e8f1
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660L MTP";
+	compatible = "qcom,sda670-mtp", "qcom,sda670", "qcom,mtp";
+	qcom,msm-id = <337 0x0>;
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-mtp.dts b/arch/arm64/boot/dts/qcom/sda670-mtp.dts
new file mode 100644
index 0000000..2123b44
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-mtp.dts
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sda670.dtsi"
+#include "sdm670-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660L MTP";
+	compatible = "qcom,sda670-mtp", "qcom,sda670", "qcom,mtp";
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp-overlay.dts
new file mode 100644
index 0000000..3e1365d
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp-overlay.dts
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660A CDP";
+	compatible = "qcom,sda670-cdp", "qcom,sda670", "qcom,cdp";
+	qcom,msm-id = <337 0x0>;
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp.dts b/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp.dts
new file mode 100644
index 0000000..6cbf224
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-pm660a-cdp.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sda670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660A CDP";
+	compatible = "qcom,sda670-cdp", "qcom,sda670", "qcom,cdp";
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp-overlay.dts
new file mode 100644
index 0000000..9855b11
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp-overlay.dts
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660A MTP";
+	compatible = "qcom,sda670-mtp", "qcom,sda670", "qcom,mtp";
+	qcom,msm-id = <337 0x0>;
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp.dts b/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp.dts
new file mode 100644
index 0000000..ffb6aa3
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda670-pm660a-mtp.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sda670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 PM660 + PM660A MTP";
+	compatible = "qcom,sda670-mtp", "qcom,sda670", "qcom,mtp";
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/arch/arm64/boot/dts/qcom/sda670.dts
similarity index 68%
copy from sound/soc/codecs/audio-ext-clk-up.h
copy to arch/arm64/boot/dts/qcom/sda670.dts
index 8a0232e..8852e30 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/arch/arm64/boot/dts/qcom/sda670.dts
@@ -7,14 +7,16 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
+/dts-v1/;
 
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
+#include "sda670.dtsi"
 
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670 SoC";
+	compatible = "qcom,sda670";
+	qcom,board-id = <0 0>;
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/arch/arm64/boot/dts/qcom/sda670.dtsi
similarity index 68%
copy from sound/soc/codecs/audio-ext-clk-up.h
copy to arch/arm64/boot/dts/qcom/sda670.dtsi
index 8a0232e..d19aac3 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/arch/arm64/boot/dts/qcom/sda670.dtsi
@@ -7,14 +7,13 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
+#include "sdm670.dtsi"
 
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
-
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA670";
+	qcom,msm-id = <337 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-4k-panel-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-4k-panel-cdp-overlay.dts
new file mode 100644
index 0000000..980a57f
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-4k-panel-cdp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-cdp.dtsi"
+#include "sdm845-cdp-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 4K Display Panel CDP";
+	compatible = "qcom,sda845-cdp", "qcom,sda845", "qcom,cdp";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <1 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-4k-panel-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-4k-panel-mtp-overlay.dts
new file mode 100644
index 0000000..46fb259
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-4k-panel-mtp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-mtp.dtsi"
+#include "sdm845-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 4K Display Panel MTP";
+	compatible = "qcom,sda845-mtp", "qcom,sda845", "qcom,mtp";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <8 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb &sde_dp>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-4k-panel-qrd-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-4k-panel-qrd-overlay.dts
new file mode 100644
index 0000000..1cbfe15
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-4k-panel-qrd-overlay.dts
@@ -0,0 +1,64 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-qrd.dtsi"
+#include "sdm845-qrd-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 4K Display Panel QRD";
+	compatible = "qcom,sda845-qrd", "qcom,sda845", "qcom,qrd";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <11 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-cdp-overlay.dts
new file mode 100644
index 0000000..20d4006
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-cdp-overlay.dts
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-cdp.dtsi"
+#include "sdm845-cdp-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v1 CDP";
+	compatible = "qcom,sda845-cdp", "qcom,sda845", "qcom,cdp";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <1 0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-mtp-overlay.dts
new file mode 100644
index 0000000..9d58ebe
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-mtp-overlay.dts
@@ -0,0 +1,32 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-mtp.dtsi"
+#include "sdm845-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v1 MTP";
+	compatible = "qcom,sda845-mtp", "qcom,sda845", "qcom,mtp";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <8 0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-qrd-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-qrd-overlay.dts
new file mode 100644
index 0000000..683cdae
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-qrd-overlay.dts
@@ -0,0 +1,32 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-qrd.dtsi"
+#include "sdm845-qrd-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v1 QRD";
+	compatible = "qcom,sdm845-qrd", "qcom,sdm845", "qcom,qrd";
+	qcom,msm-id = <341 0x10000>;
+	qcom,board-id = <11 0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-cdp-overlay.dts
new file mode 100644
index 0000000..9b7449e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-cdp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-cdp.dtsi"
+#include "sdm845-cdp-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v2 4K Display Panel CDP";
+	compatible = "qcom,sda845-cdp", "qcom,sda845", "qcom,cdp";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <1 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-mtp-overlay.dts
new file mode 100644
index 0000000..bb310d3
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-mtp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-mtp.dtsi"
+#include "sdm845-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v2 4K Display Panel MTP";
+	compatible = "qcom,sda845-mtp", "qcom,sda845", "qcom,mtp";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <8 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb &sde_dp>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-qrd-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-qrd-overlay.dts
new file mode 100644
index 0000000..ab61f2e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-4k-panel-qrd-overlay.dts
@@ -0,0 +1,64 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-qrd.dtsi"
+#include "sdm845-qrd-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v2 4K Display Panel QRD";
+	compatible = "qcom,sda845-qrd", "qcom,sda845", "qcom,qrd";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <11 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-cdp-overlay.dts
new file mode 100644
index 0000000..7de66c0b
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-cdp-overlay.dts
@@ -0,0 +1,32 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-cdp.dtsi"
+#include "sdm845-cdp-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v2 CDP";
+	compatible = "qcom,sda845-cdp", "qcom,sda845", "qcom,cdp";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <1 0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-mtp-overlay.dts
new file mode 100644
index 0000000..a5d2069
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-mtp-overlay.dts
@@ -0,0 +1,32 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-mtp.dtsi"
+#include "sdm845-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sda845 v2 MTP";
+	compatible = "qcom,sda845-mtp", "qcom,sda845", "qcom,mtp";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <8 0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sda845-v2-qrd-overlay.dts b/arch/arm64/boot/dts/qcom/sda845-v2-qrd-overlay.dts
new file mode 100644
index 0000000..a2da1b8
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sda845-v2-qrd-overlay.dts
@@ -0,0 +1,31 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-qrd.dtsi"
+#include "sdm845-qrd-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDA845 v2 QRD";
+	compatible = "qcom,sda845-qrd", "qcom,sda845", "qcom,qrd";
+	qcom,msm-id = <341 0x20000>;
+	qcom,board-id = <11 0>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sda845-v2.dts
similarity index 62%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sda845-v2.dts
index bc1cd9e..38ab5ca 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sda845-v2.dts
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,14 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+/dts-v1/;
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
+#include "sda845-v2.dtsi"
 
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA845 v2 SoC";
+	compatible = "qcom,sda845";
+	qcom,board-id = <0 0>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sda845-v2.dtsi
similarity index 61%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sda845-v2.dtsi
index bc1cd9e..df1f0d1 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sda845-v2.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,11 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+#include "sdm845-v2.dtsi"
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
-
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA 845 V2";
+	qcom,msm-id = <341 0x20000>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sda845.dts
similarity index 62%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sda845.dts
index bc1cd9e..698388c 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sda845.dts
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,14 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+/dts-v1/;
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
+#include "sda845.dtsi"
 
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA845 v1 SoC";
+	compatible = "qcom,sda845";
+	qcom,board-id = <0 0>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sda845.dtsi
similarity index 61%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sda845.dtsi
index bc1cd9e..aa9b733 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sda845.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,11 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+#include "sdm845.dtsi"
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
-
-#endif
+/ {
+	model = "Qualcomm Technologies, Inc. SDA 845";
+	qcom,msm-id = <341 0x10000>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-audio-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm670-audio-overlay.dtsi
new file mode 100644
index 0000000..dfb8142
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-audio-overlay.dtsi
@@ -0,0 +1,362 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+#include "sdm670-wcd.dtsi"
+#include "sdm670-wsa881x.dtsi"
+#include <dt-bindings/clock/qcom,audio-ext-clk.h>
+
+&tavil_snd {
+	qcom,msm-mi2s-master = <1>, <1>, <1>, <1>, <1>;
+	qcom,audio-routing =
+		"AIF4 VI", "MCLK",
+		"RX_BIAS", "MCLK",
+		"MADINPUT", "MCLK",
+		"hifi amp", "LINEOUT1",
+		"hifi amp", "LINEOUT2",
+		"AMIC2", "MIC BIAS2",
+		"MIC BIAS2", "Headset Mic",
+		"AMIC3", "MIC BIAS2",
+		"MIC BIAS2", "ANCRight Headset Mic",
+		"AMIC4", "MIC BIAS2",
+		"MIC BIAS2", "ANCLeft Headset Mic",
+		"AMIC5", "MIC BIAS3",
+		"MIC BIAS3", "Handset Mic",
+		"DMIC0", "MIC BIAS1",
+		"MIC BIAS1", "Digital Mic0",
+		"DMIC1", "MIC BIAS1",
+		"MIC BIAS1", "Digital Mic1",
+		"DMIC2", "MIC BIAS3",
+		"MIC BIAS3", "Digital Mic2",
+		"DMIC3", "MIC BIAS3",
+		"MIC BIAS3", "Digital Mic3",
+		"DMIC4", "MIC BIAS4",
+		"MIC BIAS4", "Digital Mic4",
+		"DMIC5", "MIC BIAS4",
+		"MIC BIAS4", "Digital Mic5",
+		"SpkrLeft IN", "SPK1 OUT",
+		"SpkrRight IN", "SPK2 OUT";
+
+	qcom,msm-mbhc-hphl-swh = <1>;
+	qcom,msm-mbhc-gnd-swh = <1>;
+	qcom,hph-en0-gpio = <&tavil_hph_en0>;
+	qcom,hph-en1-gpio = <&tavil_hph_en1>;
+	qcom,msm-mclk-freq = <9600000>;
+	asoc-codec = <&stub_codec>;
+	asoc-codec-names = "msm-stub-codec.1";
+	qcom,wsa-max-devs = <2>;
+	qcom,wsa-devs = <&wsa881x_0211>, <&wsa881x_0212>,
+		<&wsa881x_0213>, <&wsa881x_0214>;
+	qcom,wsa-aux-dev-prefix = "SpkrLeft", "SpkrRight",
+		"SpkrLeft", "SpkrRight";
+};
+
+&int_codec {
+	qcom,audio-routing =
+		"RX_BIAS", "INT_MCLK0",
+		"SPK_RX_BIAS", "INT_MCLK0",
+		"INT_LDO_H", "INT_MCLK0",
+		"MIC BIAS External", "Handset Mic",
+		"MIC BIAS External2", "Headset Mic",
+		"MIC BIAS External", "Secondary Mic",
+		"AMIC1", "MIC BIAS External",
+		"AMIC2", "MIC BIAS External2",
+		"AMIC3", "MIC BIAS External",
+		"DMIC1", "MIC BIAS External",
+		"MIC BIAS External", "Digital Mic1",
+		"DMIC2", "MIC BIAS External",
+		"MIC BIAS External", "Digital Mic2",
+		"DMIC3", "MIC BIAS External",
+		"MIC BIAS External", "Digital Mic3",
+		"DMIC4", "MIC BIAS External",
+		"MIC BIAS External", "Digital Mic4",
+		"SpkrLeft IN", "SPK1 OUT",
+		"SpkrRight IN", "SPK2 OUT",
+		"PDM_IN_RX1", "PDM_OUT_RX1",
+		"PDM_IN_RX2", "PDM_OUT_RX2",
+		"PDM_IN_RX3", "PDM_OUT_RX3",
+		"ADC1_IN", "ADC1_OUT",
+		"ADC2_IN", "ADC2_OUT",
+		"ADC3_IN", "ADC3_OUT";
+
+	qcom,msm-mi2s-master = <1>, <1>, <1>, <1>, <1>;
+	qcom,msm-mclk-freq = <9600000>;
+	qcom,msm-mbhc-hphl-swh = <1>;
+	qcom,msm-mbhc-gnd-swh = <1>;
+	qcom,msm-micbias2-ext-cap;
+	qcom,msm-hs-micbias-type = "external";
+	qcom,cdc-pdm-gpios = <&cdc_pdm_gpios>;
+	qcom,cdc-comp-gpios = <&cdc_comp_gpios>;
+	qcom,cdc-dmic-gpios = <&cdc_dmic_gpios>;
+
+	asoc-codec = <&stub_codec>, <&msm_digital_codec>,
+		     <&pmic_analog_codec>, <&msm_sdw_codec>;
+	asoc-codec-names = "msm-stub-codec.1", "msm-dig-codec",
+			   "analog-codec", "msm_sdw_codec";
+
+	qcom,wsa-max-devs = <2>;
+	qcom,wsa-devs = <&wsa881x_211_en>, <&wsa881x_212_en>,
+			<&wsa881x_213_en>, <&wsa881x_214_en>;
+	qcom,wsa-aux-dev-prefix = "SpkrLeft", "SpkrRight",
+				  "SpkrLeft", "SpkrRight";
+};
+
+&soc {
+	wcd_usbc_analog_en1_gpio: msm_cdc_pinctrl_usbc_audio_en1 {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&wcd_usbc_analog_en1_active>;
+		pinctrl-1 = <&wcd_usbc_analog_en1_idle>;
+	};
+
+	cdc_pdm_gpios: cdc_pdm_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&cdc_pdm_clk_active &cdc_pdm_sync_active
+			     &cdc_pdm_rx0_active &cdc_pdm_rx1_2_active
+			     &cdc_pdm_2_gpios_active>;
+		pinctrl-1 = <&cdc_pdm_clk_sleep &cdc_pdm_sync_sleep
+			     &cdc_pdm_rx0_sleep &cdc_pdm_rx1_2_sleep
+			     &cdc_pdm_2_gpios_sleep>;
+		qcom,lpi-gpios;
+	};
+
+	cdc_comp_gpios: cdc_comp_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&cdc_rx0_comp_active &cdc_rx1_comp_active>;
+		pinctrl-1 = <&cdc_rx0_comp_sleep &cdc_rx1_comp_sleep>;
+		qcom,lpi-gpios;
+	};
+
+	cdc_dmic_gpios: cdc_dmic_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&cdc_dmic12_gpios_active
+			     &cdc_dmic34_gpios_active>;
+		pinctrl-1 = <&cdc_dmic12_gpios_sleep
+			     &cdc_dmic34_gpios_sleep>;
+		qcom,lpi-gpios;
+	};
+
+	cdc_sdw_gpios: sdw_clk_data_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&sdw_clk_active &sdw_data_active>;
+		pinctrl-1 = <&sdw_clk_sleep &sdw_data_sleep>;
+	};
+
+	wsa_spkr_en1: wsa_spkr_en1_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&spkr_1_sd_n_active>;
+		pinctrl-1 = <&spkr_1_sd_n_sleep>;
+	};
+
+	wsa_spkr_en2: wsa_spkr_en2_pinctrl {
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&spkr_2_sd_n_active>;
+		pinctrl-1 = <&spkr_2_sd_n_sleep>;
+	};
+
+	msm_sdw_codec: msm-sdw-codec@62ec1000 {
+		status = "okay";
+		compatible = "qcom,msm-sdw-codec";
+		reg = <0x62ec1000 0x0>;
+		interrupts = <0 88 0>;
+		interrupt-names = "swr_master_irq";
+		qcom,cdc-sdw-gpios = <&cdc_sdw_gpios>;
+
+		swr_master {
+			compatible = "qcom,swr-wcd";
+			#address-cells = <2>;
+			#size-cells = <0>;
+
+			wsa881x_211_en: wsa881x_en@20170211 {
+				compatible = "qcom,wsa881x";
+				reg = <0x0 0x20170211>;
+				qcom,spkr-sd-n-node = <&wsa_spkr_en1>;
+			};
+
+			wsa881x_212_en: wsa881x_en@20170212 {
+				compatible = "qcom,wsa881x";
+				reg = <0x0 0x20170212>;
+				qcom,spkr-sd-n-node = <&wsa_spkr_en2>;
+			};
+
+			wsa881x_213_en: wsa881x_en@21170213 {
+				compatible = "qcom,wsa881x";
+				reg = <0x0 0x21170213>;
+				qcom,spkr-sd-n-node = <&wsa_spkr_en1>;
+			};
+
+			wsa881x_214_en: wsa881x_en@21170214 {
+				compatible = "qcom,wsa881x";
+				reg = <0x0 0x21170214>;
+				qcom,spkr-sd-n-node = <&wsa_spkr_en2>;
+			};
+		};
+	};
+
+	wcd9xxx_intc: wcd9xxx-irq {
+		status = "disabled";
+		compatible = "qcom,wcd9xxx-irq";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&tlmm>;
+		qcom,gpio-connect = <&tlmm 80 0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&wcd_intr_default>;
+	};
+
+	clock_audio_lnbb: audio_ext_clk_lnbb {
+		status = "disabled";
+		compatible = "qcom,audio-ref-clk";
+		clock-names = "osr_clk";
+		clocks = <&clock_rpmh RPMH_LN_BB_CLK2>;
+		qcom,node_has_rpm_clock;
+		#clock-cells = <1>;
+	};
+
+	wcd_rst_gpio: msm_cdc_pinctrl@64 {
+		status = "disabled";
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&lpi_cdc_reset_active>;
+		pinctrl-1 = <&lpi_cdc_reset_sleep>;
+		qcom,lpi-gpios;
+	};
+
+	wdsp_mgr: qcom,wcd-dsp-mgr {
+		compatible = "qcom,wcd-dsp-mgr";
+		qcom,wdsp-components = <&wcd934x_cdc 0>,
+				       <&wcd_spi_0 1>,
+				       <&glink_spi_xprt_wdsp 2>;
+					qcom,img-filename = "cpe_9340";
+	};
+
+	wdsp_glink: qcom,wcd-dsp-glink {
+		compatible = "qcom,wcd-dsp-glink";
+	};
+};
+
+&slim_aud {
+	wcd934x_cdc: tavil_codec {
+		status = "disabled";
+		compatible = "qcom,tavil-slim-pgd";
+		elemental-addr = [00 01 50 02 17 02];
+
+		interrupt-parent = <&wcd9xxx_intc>;
+		interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+			      17 18 19 20 21 22 23 24 25 26 27 28 29
+			      30 31>;
+
+		qcom,wcd-rst-gpio-node = <&wcd_rst_gpio>;
+
+		clock-names = "wcd_clk";
+		clocks = <&clock_audio_lnbb AUDIO_PMIC_LNBB_CLK>;
+
+		cdc-vdd-mic-bias-supply = <&pm660l_bob>;
+		qcom,cdc-vdd-mic-bias-voltage = <3312000 3312000>;
+		qcom,cdc-vdd-mic-bias-current = <30400>;
+
+		qcom,cdc-static-supplies = "cdc-vdd-mic-bias";
+
+		qcom,cdc-micbias1-mv = <1800>;
+		qcom,cdc-micbias2-mv = <1800>;
+		qcom,cdc-micbias3-mv = <1800>;
+		qcom,cdc-micbias4-mv = <1800>;
+
+		qcom,cdc-mclk-clk-rate = <9600000>;
+		qcom,cdc-slim-ifd = "tavil-slim-ifd";
+		qcom,cdc-slim-ifd-elemental-addr = [00 00 50 02 17 02];
+		qcom,cdc-dmic-sample-rate = <4800000>;
+		qcom,cdc-mad-dmic-rate = <600000>;
+
+		qcom,wdsp-cmpnt-dev-name = "tavil_codec";
+
+		wcd_spi_0: wcd_spi {
+			compatible = "qcom,wcd-spi-v2";
+			qcom,master-bus-num = <0>;
+			qcom,chip-select = <0>;
+			qcom,max-frequency = <24000000>;
+			qcom,mem-base-addr = <0x100000>;
+		};
+	};
+};
+
+&pm660l_3 {
+	pmic_analog_codec: analog-codec@f000 {
+		status = "okay";
+		compatible = "qcom,pmic-analog-codec";
+		reg = <0xf000 0x200>;
+		#address-cells = <2>;
+		#size-cells = <0>;
+		interrupt-parent = <&spmi_bus>;
+		interrupts = <0x3 0xf0 0x0 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x1 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x2 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x3 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x4 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x5 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x6 IRQ_TYPE_NONE>,
+			     <0x3 0xf0 0x7 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x0 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x1 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x2 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x3 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x4 IRQ_TYPE_NONE>,
+			     <0x3 0xf1 0x5 IRQ_TYPE_NONE>;
+		interrupt-names = "spk_cnp_int",
+				   "spk_clip_int",
+				   "spk_ocp_int",
+				   "ins_rem_det1",
+				   "but_rel_det",
+				   "but_press_det",
+				   "ins_rem_det",
+				   "mbhc_int",
+				   "ear_ocp_int",
+				   "hphr_ocp_int",
+				   "hphl_ocp_det",
+				   "ear_cnp_int",
+				   "hphr_cnp_int",
+				   "hphl_cnp_int";
+
+		cdc-vdda-cp-supply = <&pm660_s4>;
+		qcom,cdc-vdda-cp-voltage = <1900000 2050000>;
+		qcom,cdc-vdda-cp-current = <50000>;
+
+		cdc-vdd-pa-supply = <&pm660_s4>;
+		qcom,cdc-vdd-pa-voltage = <2040000 2040000>;
+		qcom,cdc-vdd-pa-current = <260000>;
+
+		cdc-vdd-mic-bias-supply = <&pm660l_l7>;
+		qcom,cdc-vdd-mic-bias-voltage = <3088000 3088000>;
+		qcom,cdc-vdd-mic-bias-current = <5000>;
+
+		qcom,cdc-mclk-clk-rate = <9600000>;
+
+		qcom,cdc-static-supplies = "cdc-vdda-cp",
+					   "cdc-vdd-pa";
+
+		qcom,cdc-on-demand-supplies = "cdc-vdd-mic-bias";
+
+		/*
+		 * Not marking address @ as driver searches this child
+		 * with name msm-dig-codec
+		 */
+		msm_digital_codec: msm-dig-codec {
+			compatible = "qcom,msm-digital-codec";
+			reg = <0x62ec0000 0x0>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-audio.dtsi b/arch/arm64/boot/dts/qcom/sdm670-audio.dtsi
index 3bd0350..ef92cdd 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-audio.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-audio.dtsi
@@ -39,42 +39,6 @@
 		qcom,wcn-btfm;
 		qcom,mi2s-audio-intf;
 		qcom,auxpcm-audio-intf;
-		qcom,msm-mi2s-master = <1>, <1>, <1>, <1>;
-		qcom,audio-routing =
-			"AIF4 VI", "MCLK",
-			"RX_BIAS", "MCLK",
-			"MADINPUT", "MCLK",
-			"hifi amp", "LINEOUT1",
-			"hifi amp", "LINEOUT2",
-			"AMIC2", "MIC BIAS2",
-			"MIC BIAS2", "Headset Mic",
-			"AMIC3", "MIC BIAS2",
-			"MIC BIAS2", "ANCRight Headset Mic",
-			"AMIC4", "MIC BIAS2",
-			"MIC BIAS2", "ANCLeft Headset Mic",
-			"AMIC5", "MIC BIAS3",
-			"MIC BIAS3", "Handset Mic",
-			"DMIC0", "MIC BIAS1",
-			"MIC BIAS1", "Digital Mic0",
-			"DMIC1", "MIC BIAS1",
-			"MIC BIAS1", "Digital Mic1",
-			"DMIC2", "MIC BIAS3",
-			"MIC BIAS3", "Digital Mic2",
-			"DMIC3", "MIC BIAS3",
-			"MIC BIAS3", "Digital Mic3",
-			"DMIC4", "MIC BIAS4",
-			"MIC BIAS4", "Digital Mic4",
-			"DMIC5", "MIC BIAS4",
-			"MIC BIAS4", "Digital Mic5",
-			"SpkrLeft IN", "SPK1 OUT",
-			"SpkrRight IN", "SPK2 OUT";
-
-		qcom,msm-mbhc-hphl-swh = <1>;
-		qcom,msm-mbhc-gnd-swh = <1>;
-		qcom,hph-en0-gpio = <&tavil_hph_en0>;
-		qcom,hph-en1-gpio = <&tavil_hph_en1>;
-		qcom,msm-mclk-freq = <9600000>;
-		qcom,usbc-analog-en1_gpio = <&wcd_usbc_analog_en1_gpio>;
 		asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>,
 			<&loopback>, <&compress>, <&hostless>,
 			<&afe>, <&lsm>, <&routing>, <&cpe>, <&compr>,
@@ -87,9 +51,10 @@
 			"msm-pcm-routing", "msm-cpe-lsm",
 			"msm-compr-dsp", "msm-pcm-dsp-noirq";
 		asoc-cpu = <&dai_mi2s0>, <&dai_mi2s1>,
-			<&dai_mi2s2>, <&dai_mi2s3>,
+			<&dai_mi2s2>, <&dai_mi2s3>, <&dai_mi2s4>,
 			<&dai_pri_auxpcm>, <&dai_sec_auxpcm>,
 			<&dai_tert_auxpcm>, <&dai_quat_auxpcm>,
+			<&dai_quin_auxpcm>,
 			<&sb_0_rx>, <&sb_0_tx>, <&sb_1_rx>, <&sb_1_tx>,
 			<&sb_2_rx>, <&sb_2_tx>, <&sb_3_rx>, <&sb_3_tx>,
 			<&sb_4_rx>, <&sb_4_tx>, <&sb_5_rx>, <&sb_5_tx>,
@@ -103,11 +68,14 @@
 			<&dai_pri_tdm_rx_0>, <&dai_pri_tdm_tx_0>,
 			<&dai_sec_tdm_rx_0>, <&dai_sec_tdm_tx_0>,
 			<&dai_tert_tdm_rx_0>, <&dai_tert_tdm_tx_0>,
-			<&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>;
+			<&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>,
+			<&dai_quin_tdm_rx_0>, <&dai_quin_tdm_tx_0>;
 		asoc-cpu-names = "msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1",
 			"msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3",
+			"msm-dai-q6-mi2s.5",
 			"msm-dai-q6-auxpcm.1", "msm-dai-q6-auxpcm.2",
 			"msm-dai-q6-auxpcm.3", "msm-dai-q6-auxpcm.4",
+			"msm-dai-q6-auxpcm.5",
 			"msm-dai-q6-dev.16384", "msm-dai-q6-dev.16385",
 			"msm-dai-q6-dev.16386", "msm-dai-q6-dev.16387",
 			"msm-dai-q6-dev.16388", "msm-dai-q6-dev.16389",
@@ -125,59 +93,17 @@
 			"msm-dai-q6-tdm.36864", "msm-dai-q6-tdm.36865",
 			"msm-dai-q6-tdm.36880", "msm-dai-q6-tdm.36881",
 			"msm-dai-q6-tdm.36896", "msm-dai-q6-tdm.36897",
-			"msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913";
-		asoc-codec = <&stub_codec>;
-		asoc-codec-names = "msm-stub-codec.1";
-		qcom,wsa-max-devs = <2>;
-		qcom,wsa-devs = <&wsa881x_0211>, <&wsa881x_0212>,
-				<&wsa881x_0213>, <&wsa881x_0214>;
-		qcom,wsa-aux-dev-prefix = "SpkrLeft", "SpkrRight",
-					"SpkrLeft", "SpkrRight";
+			"msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913",
+			"msm-dai-q6-tdm.36928", "msm-dai-q6-tdm.36929";
 	};
 
-int_codec: sound {
+	int_codec: sound {
 		status = "okay";
 		compatible = "qcom,sdm670-asoc-snd";
-		qcom,model = "sdm670-snd-card";
+		qcom,model = "sdm670-snd-card-mtp";
 		qcom,wcn-btfm;
 		qcom,mi2s-audio-intf;
 		qcom,auxpcm-audio-intf;
-		qcom,msm-mi2s-master = <1>, <1>, <1>, <1>;
-		qcom,msm-mclk-freq = <9600000>;
-		qcom,msm-mbhc-hphl-swh = <1>;
-		qcom,msm-mbhc-gnd-swh = <1>;
-		qcom,msm-micbias2-ext-cap;
-		qcom,msm-hs-micbias-type = "external";
-		qcom,cdc-pdm-gpios = <&cdc_pdm_gpios>;
-		qcom,cdc-comp-gpios = <&cdc_comp_gpios>;
-		qcom,cdc-dmic-gpios = <&cdc_dmic_gpios>;
-		qcom,audio-routing =
-			"RX_BIAS", "INT_MCLK0",
-			"SPK_RX_BIAS", "INT_MCLK0",
-			"INT_LDO_H", "INT_MCLK0",
-			"MIC BIAS External", "Handset Mic",
-			"MIC BIAS External2", "Headset Mic",
-			"MIC BIAS External", "Secondary Mic",
-			"AMIC1", "MIC BIAS External",
-			"AMIC2", "MIC BIAS External2",
-			"AMIC3", "MIC BIAS External",
-			"DMIC1", "MIC BIAS External",
-			"MIC BIAS External", "Digital Mic1",
-			"DMIC2", "MIC BIAS External",
-			"MIC BIAS External", "Digital Mic2",
-			"DMIC3", "MIC BIAS External",
-			"MIC BIAS External", "Digital Mic3",
-			"DMIC4", "MIC BIAS External",
-			"MIC BIAS External", "Digital Mic4",
-			"SpkrLeft IN", "SPK1 OUT",
-			"SpkrRight IN", "SPK2 OUT",
-			"PDM_IN_RX1", "PDM_OUT_RX1",
-			"PDM_IN_RX2", "PDM_OUT_RX2",
-			"PDM_IN_RX3", "PDM_OUT_RX3",
-			"ADC1_IN", "ADC1_OUT",
-			"ADC2_IN", "ADC2_OUT",
-			"ADC3_IN", "ADC3_OUT";
-
 		asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>,
 			<&loopback>, <&compress>, <&hostless>,
 			<&afe>, <&lsm>, <&routing>, <&compr>,
@@ -190,12 +116,13 @@
 			"msm-pcm-routing", "msm-compr-dsp",
 			"msm-pcm-dsp-noirq";
 		asoc-cpu = <&dai_mi2s0>, <&dai_mi2s1>,
-			<&dai_mi2s2>, <&dai_mi2s3>,
+			<&dai_mi2s2>, <&dai_mi2s3>, <&dai_mi2s4>,
 			<&dai_int_mi2s0>, <&dai_int_mi2s1>,
 			<&dai_int_mi2s2>, <&dai_int_mi2s3>,
 			<&dai_int_mi2s4>, <&dai_int_mi2s5>,
 			<&dai_pri_auxpcm>, <&dai_sec_auxpcm>,
 			<&dai_tert_auxpcm>, <&dai_quat_auxpcm>,
+			<&dai_quin_auxpcm>,
 			<&afe_pcm_rx>, <&afe_pcm_tx>, <&afe_proxy_rx>,
 			<&afe_proxy_tx>, <&incall_record_rx>,
 			<&incall_record_tx>, <&incall_music_rx>,
@@ -205,14 +132,17 @@
 			<&dai_pri_tdm_rx_0>, <&dai_pri_tdm_tx_0>,
 			<&dai_sec_tdm_rx_0>, <&dai_sec_tdm_tx_0>,
 			<&dai_tert_tdm_rx_0>, <&dai_tert_tdm_tx_0>,
-			<&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>;
+			<&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>,
+			<&dai_quin_tdm_rx_0>, <&dai_quin_tdm_tx_0>;
 		asoc-cpu-names = "msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1",
 			"msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3",
+			"msm-dai-q6-mi2s.5",
 			"msm-dai-q6-mi2s.7", "msm-dai-q6-mi2s.8",
 			"msm-dai-q6-mi2s.9", "msm-dai-q6-mi2s.10",
 			"msm-dai-q6-mi2s.11", "msm-dai-q6-mi2s.12",
 			"msm-dai-q6-auxpcm.1", "msm-dai-q6-auxpcm.2",
 			"msm-dai-q6-auxpcm.3", "msm-dai-q6-auxpcm.4",
+			"msm-dai-q6-auxpcm.5",
 			"msm-dai-q6-dev.224", "msm-dai-q6-dev.225",
 			"msm-dai-q6-dev.241", "msm-dai-q6-dev.240",
 			"msm-dai-q6-dev.32771", "msm-dai-q6-dev.32772",
@@ -223,136 +153,8 @@
 			"msm-dai-q6-tdm.36864", "msm-dai-q6-tdm.36865",
 			"msm-dai-q6-tdm.36880", "msm-dai-q6-tdm.36881",
 			"msm-dai-q6-tdm.36896", "msm-dai-q6-tdm.36897",
-			"msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913";
-		asoc-codec = <&stub_codec>, <&msm_digital_codec>,
-				<&pmic_analog_codec>, <&msm_sdw_codec>;
-		asoc-codec-names = "msm-stub-codec.1", "msm-dig-codec",
-				"analog-codec", "msm_sdw_codec";
-
-		qcom,wsa-max-devs = <2>;
-		qcom,wsa-devs = <&wsa881x_211_en>, <&wsa881x_212_en>,
-				<&wsa881x_213_en>, <&wsa881x_214_en>;
-		qcom,wsa-aux-dev-prefix = "SpkrLeft", "SpkrRight",
-					"SpkrLeft", "SpkrRight";
-	};
-
-	cdc_pdm_gpios: cdc_pdm_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&cdc_pdm_clk_active &cdc_pdm_sync_active
-			     &cdc_pdm_rx0_active &cdc_pdm_rx1_2_active
-			     &cdc_pdm_2_gpios_active>;
-		pinctrl-1 = <&cdc_pdm_clk_sleep &cdc_pdm_sync_sleep
-			     &cdc_pdm_rx0_sleep &cdc_pdm_rx1_2_sleep
-			     &cdc_pdm_2_gpios_sleep>;
-		qcom,lpi-gpios;
-	};
-
-	cdc_comp_gpios: cdc_comp_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&cdc_rx0_comp_active &cdc_rx1_comp_active>;
-		pinctrl-1 = <&cdc_rx0_comp_sleep &cdc_rx1_comp_sleep>;
-		qcom,lpi-gpios;
-	};
-
-	cdc_dmic_gpios: cdc_dmic_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&cdc_dmic12_gpios_active
-				&cdc_dmic34_gpios_active>;
-		pinctrl-1 = <&cdc_dmic12_gpios_sleep
-				&cdc_dmic34_gpios_sleep>;
-		qcom,lpi-gpios;
-	};
-
-	cdc_sdw_gpios: sdw_clk_data_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&sdw_clk_active &sdw_data_active>;
-		pinctrl-1 = <&sdw_clk_sleep &sdw_data_sleep>;
-	};
-
-	wsa_spkr_en1: wsa_spkr_en1_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&spkr_1_sd_n_active>;
-		pinctrl-1 = <&spkr_1_sd_n_sleep>;
-	};
-
-	wsa_spkr_en2: wsa_spkr_en2_pinctrl {
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&spkr_2_sd_n_active>;
-		pinctrl-1 = <&spkr_2_sd_n_sleep>;
-	};
-
-	msm_sdw_codec: msm-sdw-codec@62ec1000 {
-		status = "okay";
-		compatible = "qcom,msm-sdw-codec";
-		reg = <0x62ec1000 0x0>;
-		interrupts = <0 161 0>;
-		interrupt-names = "swr_master_irq";
-		qcom,cdc-sdw-gpios = <&cdc_sdw_gpios>;
-
-		swr_master {
-			compatible = "qcom,swr-wcd";
-			#address-cells = <2>;
-			#size-cells = <0>;
-
-			wsa881x_211_en: wsa881x_en@20170211 {
-				compatible = "qcom,wsa881x";
-				reg = <0x0 0x20170211>;
-				qcom,spkr-sd-n-node = <&wsa_spkr_en1>;
-			};
-
-			wsa881x_212_en: wsa881x_en@20170212 {
-				compatible = "qcom,wsa881x";
-				reg = <0x0 0x20170212>;
-				qcom,spkr-sd-n-node = <&wsa_spkr_en2>;
-			};
-
-			wsa881x_213_en: wsa881x_en@21170213 {
-				compatible = "qcom,wsa881x";
-				reg = <0x0 0x21170213>;
-				qcom,spkr-sd-n-node = <&wsa_spkr_en1>;
-			};
-
-			wsa881x_214_en: wsa881x_en@21170214 {
-				compatible = "qcom,wsa881x";
-				reg = <0x0 0x21170214>;
-				qcom,spkr-sd-n-node = <&wsa_spkr_en2>;
-			};
-		};
-	};
-
-	wcd9xxx_intc: wcd9xxx-irq {
-		status = "disabled";
-		compatible = "qcom,wcd9xxx-irq";
-		interrupt-controller;
-		#interrupt-cells = <1>;
-		interrupt-parent = <&tlmm>;
-		qcom,gpio-connect = <&tlmm 80 0>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&wcd_intr_default>;
-	};
-
-	clock_audio_lnbb: audio_ext_clk_lnbb {
-		status = "disabled";
-		compatible = "qcom,audio-ref-clk";
-		clock-names = "osr_clk";
-		clocks = <&clock_rpmh RPMH_LN_BB_CLK2>;
-		qcom,node_has_rpm_clock;
-		#clock-cells = <1>;
-	};
-
-	wcd_rst_gpio: msm_cdc_pinctrl@64 {
-		status = "disabled";
-		compatible = "qcom,msm-cdc-pinctrl";
-		pinctrl-names = "aud_active", "aud_sleep";
-		pinctrl-0 = <&lpi_cdc_reset_active>;
-		pinctrl-1 = <&lpi_cdc_reset_sleep>;
-		qcom,lpi-gpios;
+			"msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913",
+			"msm-dai-q6-tdm.36928", "msm-dai-q6-tdm.36929";
 	};
 
 	cpe: qcom,msm-cpe-lsm {
@@ -363,18 +165,6 @@
 		compatible = "qcom,msm-cpe-lsm";
 		qcom,msm-cpe-lsm-id = <3>;
 	};
-
-	wdsp_mgr: qcom,wcd-dsp-mgr {
-		compatible = "qcom,wcd-dsp-mgr";
-		qcom,wdsp-components = <&wcd934x_cdc 0>,
-				       <&wcd_spi_0 1>,
-				       <&glink_spi_xprt_wdsp 2>;
-		qcom,img-filename = "cpe_9340";
-	};
-
-	wdsp_glink: qcom,wcd-dsp-glink {
-		compatible = "qcom,wcd-dsp-glink";
-	};
 };
 
 &slim_aud {
@@ -384,56 +174,6 @@
 		compatible = "qcom,msm-dai-slim";
 		elemental-addr = [ff ff ff fe 17 02];
 	};
-
-	wcd934x_cdc: tavil_codec {
-		status = "disabled";
-		compatible = "qcom,tavil-slim-pgd";
-		elemental-addr = [00 01 50 02 17 02];
-
-		interrupt-parent = <&wcd9xxx_intc>;
-		interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
-			      17 18 19 20 21 22 23 24 25 26 27 28 29
-			      30 31>;
-
-		qcom,wcd-rst-gpio-node = <&wcd_rst_gpio>;
-
-		clock-names = "wcd_clk";
-		clocks = <&clock_audio_lnbb AUDIO_PMIC_LNBB_CLK>;
-
-		cdc-vdd-mic-bias-supply = <&pm660l_bob>;
-		qcom,cdc-vdd-mic-bias-voltage = <3300000 3300000>;
-		qcom,cdc-vdd-mic-bias-current = <30400>;
-
-		qcom,cdc-static-supplies = "cdc-vdd-mic-bias";
-
-		qcom,cdc-micbias1-mv = <1800>;
-		qcom,cdc-micbias2-mv = <1800>;
-		qcom,cdc-micbias3-mv = <1800>;
-		qcom,cdc-micbias4-mv = <1800>;
-
-		qcom,cdc-mclk-clk-rate = <9600000>;
-		qcom,cdc-slim-ifd = "tavil-slim-ifd";
-		qcom,cdc-slim-ifd-elemental-addr = [00 00 50 02 17 02];
-		qcom,cdc-dmic-sample-rate = <4800000>;
-		qcom,cdc-mad-dmic-rate = <600000>;
-
-		qcom,wdsp-cmpnt-dev-name = "tavil_codec";
-
-		wcd_spi_0: wcd_spi {
-			compatible = "qcom,wcd-spi-v2";
-			qcom,master-bus-num = <8>;
-			qcom,chip-select = <0>;
-			qcom,max-frequency = <24000000>;
-			qcom,mem-base-addr = <0x100000>;
-		};
-
-		wcd_usbc_analog_en1_gpio: msm_cdc_pinctrl_usbc_audio_en1 {
-			compatible = "qcom,msm-cdc-pinctrl";
-			pinctrl-names = "aud_active", "aud_sleep";
-			pinctrl-0 = <&wcd_usbc_analog_en1_active>;
-			pinctrl-1 = <&wcd_usbc_analog_en1_idle>;
-		};
-	};
 };
 
 &msm_dai_mi2s {
@@ -486,83 +226,3 @@
 		qcom,msm-mi2s-tx-lines = <3>;
 	};
 };
-
-&pm660l_3 {
-	pmic_analog_codec: analog-codec@f000 {
-		status = "okay";
-		compatible = "qcom,pmic-analog-codec";
-		reg = <0xf000 0x200>;
-		#address-cells = <2>;
-		#size-cells = <0>;
-		interrupt-parent = <&spmi_bus>;
-		interrupts = <0x3 0xf0 0x0 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x1 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x2 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x3 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x4 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x5 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x6 IRQ_TYPE_NONE>,
-				<0x3 0xf0 0x7 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x0 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x1 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x2 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x3 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x4 IRQ_TYPE_NONE>,
-				<0x3 0xf1 0x5 IRQ_TYPE_NONE>;
-		interrupt-names = "spk_cnp_int",
-				  "spk_clip_int",
-				  "spk_ocp_int",
-				  "ins_rem_det1",
-				  "but_rel_det",
-				  "but_press_det",
-				  "ins_rem_det",
-				  "mbhc_int",
-				  "ear_ocp_int",
-				  "hphr_ocp_int",
-				  "hphl_ocp_det",
-				  "ear_cnp_int",
-				  "hphr_cnp_int",
-				  "hphl_cnp_int";
-
-
-		cdc-vdda-cp-supply = <&pm660_s4>;
-		qcom,cdc-vdda-cp-voltage = <1900000 2050000>;
-		qcom,cdc-vdda-cp-current = <50000>;
-
-		cdc-vdd-pa-supply = <&pm660_s4>;
-		qcom,cdc-vdd-pa-voltage = <2040000 2040000>;
-		qcom,cdc-vdd-pa-current = <260000>;
-
-		cdc-vdd-mic-bias-supply = <&pm660l_l7>;
-		qcom,cdc-vdd-mic-bias-voltage = <3088000 3088000>;
-		qcom,cdc-vdd-mic-bias-current = <5000>;
-
-		qcom,cdc-mclk-clk-rate = <9600000>;
-
-		qcom,cdc-static-supplies = "cdc-vdda-cp",
-					   "cdc-vdd-pa";
-
-		qcom,cdc-on-demand-supplies = "cdc-vdd-mic-bias";
-
-		/*
-		 * Not marking address @ as driver searches this child
-		 * with name msm-dig-codec
-		 */
-		msm_digital_codec: msm-dig-codec {
-			compatible = "qcom,msm-digital-codec";
-			reg = <0x62ec0000 0x0>;
-		};
-	};
-};
-
-&pm660_gpios {
-	gpio@c200 {
-		status = "ok";
-		qcom,mode = <1>;
-		qcom,pull = <4>;
-		qcom,vin-sel = <0>;
-		qcom,src-sel = <2>;
-		qcom,master-en = <1>;
-		qcom,out-strength = <2>;
-	};
-};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-bus.dtsi b/arch/arm64/boot/dts/qcom/sdm670-bus.dtsi
new file mode 100644
index 0000000..8749145
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-bus.dtsi
@@ -0,0 +1,1873 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <dt-bindings/msm/msm-bus-ids.h>
+#include <dt-bindings/soc/qcom,tcs-mbox.h>
+
+&soc {
+	ad_hoc_bus: ad-hoc-bus {
+		compatible = "qcom,msm-bus-device";
+		reg = <0x016E0000 0x40000>,
+			<0x1700000 0x40000>,
+			<0x1500000 0x40000>,
+			<0x14E0000 0x40000>,
+			<0x17900000 0x40000>,
+			<0x1380000 0x40000>,
+			<0x1380000 0x40000>,
+			<0x1740000 0x40000>,
+			<0x1620000 0x40000>,
+			<0x1620000 0x40000>,
+			<0x1620000 0x40000>;
+
+		reg-names = "aggre1_noc-base", "aggre2_noc-base",
+			"config_noc-base", "dc_noc-base",
+			"gladiator_noc-base", "mc_virt-base", "mem_noc-base",
+			"mmss_noc-base", "system_noc-base", "ipa_virt-base",
+			"camnoc_virt-base";
+
+		mbox-names = "apps_rsc", "disp_rsc";
+		mboxes = <&apps_rsc 0 &disp_rsc 0>;
+
+	/*RSCs*/
+		rsc_apps: rsc-apps {
+			cell-id = <MSM_BUS_RSC_APPS>;
+			label = "apps_rsc";
+			qcom,rsc-dev;
+			qcom,req_state = <2>;
+		};
+
+		rsc_disp: rsc-disp {
+			cell-id = <MSM_BUS_RSC_DISP>;
+			label = "disp_rsc";
+			qcom,rsc-dev;
+			qcom,req_state = <3>;
+		};
+
+	/*BCMs*/
+		bcm_acv: bcm-acv {
+			cell-id = <MSM_BUS_BCM_ACV>;
+			label = "ACV";
+			qcom,bcm-name = "ACV";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_alc: bcm-alc {
+			cell-id = <MSM_BUS_BCM_ALC>;
+			label = "ALC";
+			qcom,bcm-name = "ALC";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mc0: bcm-mc0 {
+			cell-id = <MSM_BUS_BCM_MC0>;
+			label = "MC0";
+			qcom,bcm-name = "MC0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh0: bcm-sh0 {
+			cell-id = <MSM_BUS_BCM_SH0>;
+			label = "SH0";
+			qcom,bcm-name = "SH0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm0: bcm-mm0 {
+			cell-id = <MSM_BUS_BCM_MM0>;
+			label = "MM0";
+			qcom,bcm-name = "MM0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh1: bcm-sh1 {
+			cell-id = <MSM_BUS_BCM_SH1>;
+			label = "SH1";
+			qcom,bcm-name = "SH1";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm1: bcm-mm1 {
+			cell-id = <MSM_BUS_BCM_MM1>;
+			label = "MM1";
+			qcom,bcm-name = "MM1";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh2: bcm-sh2 {
+			cell-id = <MSM_BUS_BCM_SH2>;
+			label = "SH2";
+			qcom,bcm-name = "SH2";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm2: bcm-mm2 {
+			cell-id = <MSM_BUS_BCM_MM2>;
+			label = "MM2";
+			qcom,bcm-name = "MM2";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh3: bcm-sh3 {
+			cell-id = <MSM_BUS_BCM_SH3>;
+			label = "SH3";
+			qcom,bcm-name = "SH3";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm3: bcm-mm3 {
+			cell-id = <MSM_BUS_BCM_MM3>;
+			label = "MM3";
+			qcom,bcm-name = "MM3";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh5: bcm-sh5 {
+			cell-id = <MSM_BUS_BCM_SH5>;
+			label = "SH5";
+			qcom,bcm-name = "SH5";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn0: bcm-sn0 {
+			cell-id = <MSM_BUS_BCM_SN0>;
+			label = "SN0";
+			qcom,bcm-name = "SN0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_ce0: bcm-ce0 {
+			cell-id = <MSM_BUS_BCM_CE0>;
+			label = "CE0";
+			qcom,bcm-name = "CE0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_ip0: bcm-ip0 {
+			cell-id = <MSM_BUS_BCM_IP0>;
+			label = "IP0";
+			qcom,bcm-name = "IP0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_cn0: bcm-cn0 {
+			cell-id = <MSM_BUS_BCM_CN0>;
+			label = "CN0";
+			qcom,bcm-name = "CN0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_qup0: bcm-qup0 {
+			cell-id = <MSM_BUS_BCM_QUP0>;
+			label = "QUP0";
+			qcom,bcm-name = "QUP0";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn1: bcm-sn1 {
+			cell-id = <MSM_BUS_BCM_SN1>;
+			label = "SN1";
+			qcom,bcm-name = "SN1";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn2: bcm-sn2 {
+			cell-id = <MSM_BUS_BCM_SN2>;
+			label = "SN2";
+			qcom,bcm-name = "SN2";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn3: bcm-sn3 {
+			cell-id = <MSM_BUS_BCM_SN3>;
+			label = "SN3";
+			qcom,bcm-name = "SN3";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn4: bcm-sn4 {
+			cell-id = <MSM_BUS_BCM_SN4>;
+			label = "SN4";
+			qcom,bcm-name = "SN4";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn5: bcm-sn5 {
+			cell-id = <MSM_BUS_BCM_SN5>;
+			label = "SN5";
+			qcom,bcm-name = "SN5";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn8: bcm-sn8 {
+			cell-id = <MSM_BUS_BCM_SN8>;
+			label = "SN8";
+			qcom,bcm-name = "SN8";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn10: bcm-sn10 {
+			cell-id = <MSM_BUS_BCM_SN10>;
+			label = "SN10";
+			qcom,bcm-name = "SN10";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn11: bcm-sn11 {
+			cell-id = <MSM_BUS_BCM_SN11>;
+			label = "SN11";
+			qcom,bcm-name = "SN11";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sn13: bcm-sn13 {
+			cell-id = <MSM_BUS_BCM_SN13>;
+			label = "SN13";
+			qcom,bcm-name = "SN13";
+			qcom,rscs = <&rsc_apps>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mc0_display: bcm-mc0_display {
+			cell-id = <MSM_BUS_BCM_MC0_DISPLAY>;
+			label = "MC0_DISPLAY";
+			qcom,bcm-name = "MC0";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+		bcm_sh0_display: bcm-sh0_display {
+			cell-id = <MSM_BUS_BCM_SH0_DISPLAY>;
+			label = "SH0_DISPLAY";
+			qcom,bcm-name = "SH0";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm0_display: bcm-mm0_display {
+			cell-id = <MSM_BUS_BCM_MM0_DISPLAY>;
+			label = "MM0_DISPLAY";
+			qcom,bcm-name = "MM0";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm1_display: bcm-mm1_display {
+			cell-id = <MSM_BUS_BCM_MM1_DISPLAY>;
+			label = "MM1_DISPLAY";
+			qcom,bcm-name = "MM1";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm2_display: bcm-mm2_display {
+			cell-id = <MSM_BUS_BCM_MM2_DISPLAY>;
+			label = "MM2_DISPLAY";
+			qcom,bcm-name = "MM2";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+		bcm_mm3_display: bcm-mm3_display {
+			cell-id = <MSM_BUS_BCM_MM3_DISPLAY>;
+			label = "MM3_DISPLAY";
+			qcom,bcm-name = "MM3";
+			qcom,rscs = <&rsc_disp>;
+			qcom,bcm-dev;
+		};
+
+
+		/*Buses*/
+		fab_aggre1_noc: fab-aggre1_noc {
+			cell-id = <MSM_BUS_FAB_A1_NOC>;
+			label = "fab-aggre1_noc";
+			qcom,fab-dev;
+			qcom,base-name = "aggre1_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <16384>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_aggre2_noc: fab-aggre2_noc {
+			cell-id = <MSM_BUS_FAB_A2_NOC>;
+			label = "fab-aggre2_noc";
+			qcom,fab-dev;
+			qcom,base-name = "aggre2_noc-base";
+			qcom,qos-off = <2048>;
+			qcom,base-offset = <12288>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_camnoc_virt: fab-camnoc_virt {
+			cell-id = <MSM_BUS_FAB_CAMNOC_VIRT>;
+			label = "fab-camnoc_virt";
+			qcom,fab-dev;
+			qcom,base-name = "camnoc_virt-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			clocks = <>;
+		};
+
+		fab_config_noc: fab-config_noc {
+			cell-id = <MSM_BUS_FAB_CONFIG_NOC>;
+			label = "fab-config_noc";
+			qcom,fab-dev;
+			qcom,base-name = "config_noc-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_dc_noc: fab-dc_noc {
+			cell-id = <MSM_BUS_FAB_DC_NOC>;
+			label = "fab-dc_noc";
+			qcom,fab-dev;
+			qcom,base-name = "dc_noc-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_gladiator_noc: fab-gladiator_noc {
+			cell-id = <MSM_BUS_FAB_GNOC>;
+			label = "fab-gladiator_noc";
+			qcom,fab-dev;
+			qcom,base-name = "gladiator_noc-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_ipa_virt: fab-ipa_virt {
+			cell-id = <MSM_BUS_FAB_IPA_VIRT>;
+			label = "fab-ipa_virt";
+			qcom,fab-dev;
+			qcom,base-name = "ipa_virt-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			clocks = <>;
+		};
+
+		fab_mc_virt: fab-mc_virt {
+			cell-id = <MSM_BUS_FAB_MC_VIRT>;
+			label = "fab-mc_virt";
+			qcom,fab-dev;
+			qcom,base-name = "mc_virt-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			clocks = <>;
+		};
+
+		fab_mem_noc: fab-mem_noc {
+			cell-id = <MSM_BUS_FAB_MEM_NOC>;
+			label = "fab-mem_noc";
+			qcom,fab-dev;
+			qcom,base-name = "mem_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <65536>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_mmss_noc: fab-mmss_noc {
+			cell-id = <MSM_BUS_FAB_MMSS_NOC>;
+			label = "fab-mmss_noc";
+			qcom,fab-dev;
+			qcom,base-name = "mmss_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <36864>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_system_noc: fab-system_noc {
+			cell-id = <MSM_BUS_FAB_SYS_NOC>;
+			label = "fab-system_noc";
+			qcom,fab-dev;
+			qcom,base-name = "system_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <36864>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_mc_virt_display: fab-mc_virt_display {
+			cell-id = <MSM_BUS_FAB_MC_VIRT_DISPLAY>;
+			label = "fab-mc_virt_display";
+			qcom,fab-dev;
+			qcom,base-name = "mc_virt-base";
+			qcom,qos-off = <0>;
+			qcom,base-offset = <0>;
+			qcom,bypass-qos-prg;
+			clocks = <>;
+		};
+
+		fab_mem_noc_display: fab-mem_noc_display {
+			cell-id = <MSM_BUS_FAB_MEM_NOC_DISPLAY>;
+			label = "fab-mem_noc_display";
+			qcom,fab-dev;
+			qcom,base-name = "mem_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <65536>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+		fab_mmss_noc_display: fab-mmss_noc_display {
+			cell-id = <MSM_BUS_FAB_MMSS_NOC_DISPLAY>;
+			label = "fab-mmss_noc_display";
+			qcom,fab-dev;
+			qcom,base-name = "mmss_noc-base";
+			qcom,qos-off = <4096>;
+			qcom,base-offset = <36864>;
+			qcom,bypass-qos-prg;
+			qcom,bus-type = <1>;
+			clocks = <>;
+		};
+
+
+		/*Masters*/
+
+		mas_qhm_a1noc_cfg: mas-qhm-a1noc-cfg {
+			cell-id = <MSM_BUS_MASTER_A1NOC_CFG>;
+			label = "mas-qhm-a1noc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_aggre1_noc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+		};
+
+		mas_qhm_qup1: mas-qhm-qup1 {
+			cell-id = <MSM_BUS_MASTER_BLSP_1>;
+			label = "mas-qhm-qup1";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <16>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,bcms = <&bcm_qup0>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_qhm_tsif: mas-qhm-tsif {
+			cell-id = <MSM_BUS_MASTER_TSIF>;
+			label = "mas-qhm-tsif";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+		};
+
+		mas_xm_emmc: mas-xm-emmc {
+			cell-id = <MSM_BUS_MASTER_EMMC>;
+			label = "mas-xm-emmc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <3>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_xm_sdc2: mas-xm-sdc2 {
+			cell-id = <MSM_BUS_MASTER_SDCC_2>;
+			label = "mas-xm-sdc2";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <1>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,ap-owned;
+			qcom,prio = <1>;
+		};
+
+		mas_xm_sdc4: mas-xm-sdc4 {
+			cell-id = <MSM_BUS_MASTER_SDCC_4>;
+			label = "mas-xm-sdc4";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <2>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,ap-owned;
+			qcom,prio = <1>;
+		};
+
+		mas_xm_ufs_mem: mas-xm-ufs-mem {
+			cell-id = <MSM_BUS_MASTER_UFS_MEM>;
+			label = "mas-xm-ufs-mem";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <4>;
+			qcom,connections = <&slv_qns_a1noc_snoc>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_qhm_a2noc_cfg: mas-qhm-a2noc-cfg {
+			cell-id = <MSM_BUS_MASTER_A2NOC_CFG>;
+			label = "mas-qhm-a2noc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_aggre2_noc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+		};
+
+		mas_qhm_qdss_bam: mas-qhm-qdss-bam {
+			cell-id = <MSM_BUS_MASTER_QDSS_BAM>;
+			label = "mas-qhm-qdss-bam";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <17>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_qhm_qup2: mas-qhm-qup2 {
+			cell-id = <MSM_BUS_MASTER_BLSP_2>;
+			label = "mas-qhm-qup2";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <0>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,bcms = <&bcm_qup0>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_qnm_cnoc: mas-qnm-cnoc {
+			cell-id = <MSM_BUS_MASTER_CNOC_A2NOC>;
+			label = "mas-qnm-cnoc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <2>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
+			qcom,prio = <1>;
+		};
+
+		mas_qxm_crypto: mas-qxm-crypto {
+			cell-id = <MSM_BUS_MASTER_CRYPTO_CORE_0>;
+			label = "mas-qxm-crypto";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <4>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,bcms = <&bcm_ce0>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_qxm_ipa: mas-qxm-ipa {
+			cell-id = <MSM_BUS_MASTER_IPA>;
+			label = "mas-qxm-ipa";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <6>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_xm_qdss_etr: mas-xm-qdss-etr {
+			cell-id = <MSM_BUS_MASTER_QDSS_ETR>;
+			label = "mas-xm-qdss-etr";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <16>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_xm_usb3_0: mas-xm-usb3-0 {
+			cell-id = <MSM_BUS_MASTER_USB3>;
+			label = "mas-xm-usb3-0";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <22>;
+			qcom,connections = <&slv_qns_a2noc_snoc>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_qxm_camnoc_hf0_uncomp: mas-qxm-camnoc-hf0-uncomp {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_HF0_UNCOMP>;
+			label = "mas-qxm-camnoc-hf0-uncomp";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qns_camnoc_uncomp>;
+			qcom,bus-dev = <&fab_camnoc_virt>;
+			qcom,bcms = <&bcm_mm1>;
+		};
+
+		mas_qxm_camnoc_hf1_uncomp: mas-qxm-camnoc-hf1-uncomp {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_HF1_UNCOMP>;
+			label = "mas-qxm-camnoc-hf1-uncomp";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qns_camnoc_uncomp>;
+			qcom,bus-dev = <&fab_camnoc_virt>;
+			qcom,bcms = <&bcm_mm1>;
+		};
+
+		mas_qxm_camnoc_sf_uncomp: mas-qxm-camnoc-sf-uncomp {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_SF_UNCOMP>;
+			label = "mas-qxm-camnoc-sf-uncomp";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qns_camnoc_uncomp>;
+			qcom,bus-dev = <&fab_camnoc_virt>;
+			qcom,bcms = <&bcm_mm1>;
+		};
+
+		mas_qhm_spdm: mas-qhm-spdm {
+			cell-id = <MSM_BUS_MASTER_SPDM>;
+			label = "mas-qhm-spdm";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qns_cnoc_a2noc>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		mas_qhm_tic: mas-qhm-tic {
+			cell-id = <MSM_BUS_MASTER_TIC>;
+			label = "mas-qhm-tic";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qhs_tlmm_south
+				&slv_qhs_camera_cfg &slv_qhs_sdc4
+				&slv_qhs_sdc2 &slv_qhs_mnoc_cfg
+				&slv_qhs_ufs_mem_cfg &slv_qhs_glm
+				&slv_qhs_pdm &slv_qhs_a2_noc_cfg
+				&slv_qhs_qdss_cfg &slv_qhs_display_cfg
+				&slv_qhs_tcsr &slv_qhs_dcc_cfg
+				&slv_qhs_ddrss_cfg &slv_qns_cnoc_a2noc
+				&slv_qhs_snoc_cfg &slv_qhs_phy_refgen_south
+				&slv_qhs_gpuss_cfg &slv_qhs_venus_cfg
+				&slv_qhs_tsif &slv_qhs_compute_dsp_cfg
+				&slv_qhs_aop &slv_qhs_qupv3_north
+				&slv_srvc_cnoc &slv_qhs_usb3_0
+				&slv_qhs_ipa &slv_qhs_cpr_cx
+				&slv_qhs_a1_noc_cfg &slv_qhs_aoss
+				&slv_qhs_prng &slv_qhs_vsense_ctrl_cfg
+				&slv_qhs_qupv3_south &slv_qhs_spdm
+				&slv_qhs_crypto0_cfg &slv_qhs_pimem_cfg
+				&slv_qhs_tlmm_north &slv_qhs_clk_ctl
+				&slv_qhs_imem_cfg>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		mas_qnm_snoc: mas-qnm-snoc {
+			cell-id = <MSM_BUS_SNOC_CNOC_MAS>;
+			label = "mas-qnm-snoc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qhs_tlmm_south
+				&slv_qhs_camera_cfg &slv_qhs_sdc4
+				&slv_qhs_sdc2 &slv_qhs_mnoc_cfg
+				&slv_qhs_ufs_mem_cfg &slv_qhs_glm
+				&slv_qhs_pdm &slv_qhs_a2_noc_cfg
+				&slv_qhs_qdss_cfg &slv_qhs_display_cfg
+				&slv_qhs_tcsr &slv_qhs_dcc_cfg
+				&slv_qhs_ddrss_cfg &slv_qhs_snoc_cfg
+				&slv_qhs_phy_refgen_south &slv_qhs_gpuss_cfg
+				&slv_qhs_venus_cfg &slv_qhs_tsif
+				&slv_qhs_compute_dsp_cfg &slv_qhs_aop
+				&slv_qhs_qupv3_north &slv_srvc_cnoc
+				&slv_qhs_usb3_0 &slv_qhs_ipa
+				&slv_qhs_cpr_cx &slv_qhs_a1_noc_cfg
+				&slv_qhs_aoss &slv_qhs_prng
+				&slv_qhs_vsense_ctrl_cfg &slv_qhs_qupv3_south
+				&slv_qhs_spdm &slv_qhs_crypto0_cfg
+				&slv_qhs_pimem_cfg &slv_qhs_tlmm_north
+				&slv_qhs_clk_ctl &slv_qhs_imem_cfg>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		mas_xm_qdss_dap: mas-xm-qdss-dap {
+			cell-id = <MSM_BUS_MASTER_QDSS_DAP>;
+			label = "mas-xm-qdss-dap";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qhs_tlmm_south
+				&slv_qhs_camera_cfg
+				&slv_qhs_sdc4
+				&slv_qhs_sdc2 &slv_qhs_mnoc_cfg
+				&slv_qhs_ufs_mem_cfg &slv_qhs_glm
+				&slv_qhs_pdm &slv_qhs_a2_noc_cfg
+				&slv_qhs_qdss_cfg &slv_qhs_display_cfg
+				&slv_qhs_tcsr &slv_qhs_dcc_cfg
+				&slv_qhs_ddrss_cfg &slv_qns_cnoc_a2noc
+				&slv_qhs_snoc_cfg &slv_qhs_phy_refgen_south
+				&slv_qhs_gpuss_cfg &slv_qhs_venus_cfg
+				&slv_qhs_tsif &slv_qhs_compute_dsp_cfg
+				&slv_qhs_aop &slv_qhs_qupv3_north
+				&slv_srvc_cnoc &slv_qhs_usb3_0
+				&slv_qhs_ipa &slv_qhs_cpr_cx
+				&slv_qhs_a1_noc_cfg &slv_qhs_aoss
+				&slv_qhs_prng &slv_qhs_vsense_ctrl_cfg
+				&slv_qhs_qupv3_south &slv_qhs_spdm
+				&slv_qhs_crypto0_cfg &slv_qhs_pimem_cfg
+				&slv_qhs_tlmm_north &slv_qhs_clk_ctl
+				&slv_qhs_imem_cfg>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		mas_qhm_cnoc: mas-qhm-cnoc {
+			cell-id = <MSM_BUS_MASTER_CNOC_DC_NOC>;
+			label = "mas-qhm-cnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qhs_memnoc &slv_qhs_llcc>;
+			qcom,bus-dev = <&fab_dc_noc>;
+		};
+
+		mas_acm_l3: mas-acm-l3 {
+			cell-id = <MSM_BUS_MASTER_AMPSS_M0>;
+			label = "mas-acm-l3";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_gnoc
+				&slv_qns_gladiator_sodv &slv_qns_gnoc_memnoc>;
+			qcom,bus-dev = <&fab_gladiator_noc>;
+		};
+
+		mas_pm_gnoc_cfg: mas-pm-gnoc-cfg {
+			cell-id = <MSM_BUS_MASTER_GNOC_CFG>;
+			label = "mas-pm-gnoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_gnoc>;
+			qcom,bus-dev = <&fab_gladiator_noc>;
+		};
+
+		mas_ipa_core_master: mas-ipa-core-master {
+			cell-id = <MSM_BUS_MASTER_IPA_CORE>;
+			label = "mas-ipa-core-master";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_ipa_core_slave>;
+			qcom,bus-dev = <&fab_ipa_virt>;
+		};
+
+		mas_llcc_mc: mas-llcc-mc {
+			cell-id = <MSM_BUS_MASTER_LLCC>;
+			label = "mas-llcc-mc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <2>;
+			qcom,connections = <&slv_ebi>;
+			qcom,bus-dev = <&fab_mc_virt>;
+		};
+
+		mas_acm_tcu: mas-acm-tcu {
+			cell-id = <MSM_BUS_MASTER_TCU_0>;
+			label = "mas-acm-tcu";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <0>;
+			qcom,connections = <&slv_qns_apps_io &slv_qns_llcc
+				&slv_qns_memnoc_snoc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,bcms = <&bcm_sh3>;
+			qcom,ap-owned;
+			qcom,prio = <6>;
+		};
+
+		mas_qhm_memnoc_cfg: mas-qhm-memnoc-cfg {
+			cell-id = <MSM_BUS_MASTER_MEM_NOC_CFG>;
+			label = "mas-qhm-memnoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_memnoc
+				&slv_qhs_mdsp_ms_mpu_cfg>;
+			qcom,bus-dev = <&fab_mem_noc>;
+		};
+
+		mas_qnm_apps: mas-qnm-apps {
+			cell-id = <MSM_BUS_MASTER_GNOC_MEM_NOC>;
+			label = "mas-qnm-apps";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,qport = <2 3>;
+			qcom,connections = <&slv_qns_llcc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,bcms = <&bcm_sh5>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_qnm_mnoc_hf: mas-qnm-mnoc-hf {
+			cell-id = <MSM_BUS_MASTER_MNOC_HF_MEM_NOC>;
+			label = "mas-qnm-mnoc-hf";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,qport = <4 5>;
+			qcom,connections = <&slv_qns_llcc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qnm_mnoc_sf: mas-qnm-mnoc-sf {
+			cell-id = <MSM_BUS_MASTER_MNOC_SF_MEM_NOC>;
+			label = "mas-qnm-mnoc-sf";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <7>;
+			qcom,connections = <&slv_qns_apps_io
+				 &slv_qns_llcc &slv_qns_memnoc_snoc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qnm_snoc_gc: mas-qnm-snoc-gc {
+			cell-id = <MSM_BUS_MASTER_SNOC_GC_MEM_NOC>;
+			label = "mas-qnm-snoc-gc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <8>;
+			qcom,connections = <&slv_qns_llcc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qnm_snoc_sf: mas-qnm-snoc-sf {
+			cell-id = <MSM_BUS_MASTER_SNOC_SF_MEM_NOC>;
+			label = "mas-qnm-snoc-sf";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <9>;
+			qcom,connections = <&slv_qns_apps_io &slv_qns_llcc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_gpu: mas-qxm-gpu {
+			cell-id = <MSM_BUS_MASTER_GRAPHICS_3D>;
+			label = "mas-qxm-gpu";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,qport = <10 11>;
+			qcom,connections = <&slv_qns_apps_io
+				 &slv_qns_llcc &slv_qns_memnoc_snoc>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+		};
+
+		mas_qhm_mnoc_cfg: mas-qhm-mnoc-cfg {
+			cell-id = <MSM_BUS_MASTER_CNOC_MNOC_CFG>;
+			label = "mas-qhm-mnoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_mnoc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+		};
+
+		mas_qxm_camnoc_hf0: mas-qxm-camnoc-hf0 {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_HF0>;
+			label = "mas-qxm-camnoc-hf0";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <1>;
+			qcom,connections = <&slv_qns_mem_noc_hf>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm1>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_camnoc_hf1: mas-qxm-camnoc-hf1 {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_HF1>;
+			label = "mas-qxm-camnoc-hf1";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <2>;
+			qcom,connections = <&slv_qns_mem_noc_hf>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm1>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_camnoc_sf: mas-qxm-camnoc-sf {
+			cell-id = <MSM_BUS_MASTER_CAMNOC_SF>;
+			label = "mas-qxm-camnoc-sf";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <0>;
+			qcom,connections = <&slv_qns2_mem_noc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm3>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_mdp0: mas-qxm-mdp0 {
+			cell-id = <MSM_BUS_MASTER_MDP_PORT0>;
+			label = "mas-qxm-mdp0";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <3>;
+			qcom,connections = <&slv_qns_mem_noc_hf>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm1>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_mdp1: mas-qxm-mdp1 {
+			cell-id = <MSM_BUS_MASTER_MDP_PORT1>;
+			label = "mas-qxm-mdp1";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <4>;
+			qcom,connections = <&slv_qns_mem_noc_hf>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm1>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_rot: mas-qxm-rot {
+			cell-id = <MSM_BUS_MASTER_ROTATOR>;
+			label = "mas-qxm-rot";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <5>;
+			qcom,connections = <&slv_qns2_mem_noc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm3>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_venus0: mas-qxm-venus0 {
+			cell-id = <MSM_BUS_MASTER_VIDEO_P0>;
+			label = "mas-qxm-venus0";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <6>;
+			qcom,connections = <&slv_qns2_mem_noc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm3>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_venus1: mas-qxm-venus1 {
+			cell-id = <MSM_BUS_MASTER_VIDEO_P1>;
+			label = "mas-qxm-venus1";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <7>;
+			qcom,connections = <&slv_qns2_mem_noc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm3>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qxm_venus_arm9: mas-qxm-venus-arm9 {
+			cell-id = <MSM_BUS_MASTER_VIDEO_PROC>;
+			label = "mas-qxm-venus-arm9";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <8>;
+			qcom,connections = <&slv_qns2_mem_noc>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,bcms = <&bcm_mm3>;
+			qcom,ap-owned;
+			qcom,prio = <0>;
+			qcom,forwarding;
+		};
+
+		mas_qhm_snoc_cfg: mas-qhm-snoc-cfg {
+			cell-id = <MSM_BUS_MASTER_SNOC_CFG>;
+			label = "mas-qhm-snoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_srvc_snoc>;
+			qcom,bus-dev = <&fab_system_noc>;
+		};
+
+		mas_qnm_aggre1_noc: mas-qnm-aggre1-noc {
+			cell-id = <MSM_BUS_A1NOC_SNOC_MAS>;
+			label = "mas-qnm-aggre1-noc";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qxs_pimem
+				 &slv_qns_memnoc_sf &slv_qxs_imem
+				 &slv_qhs_apss &slv_qns_cnoc
+				 &slv_xs_qdss_stm>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn8>;
+		};
+
+		mas_qnm_aggre2_noc: mas-qnm-aggre2-noc {
+			cell-id = <MSM_BUS_A2NOC_SNOC_MAS>;
+			label = "mas-qnm-aggre2-noc";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qxs_pimem
+				&slv_qns_memnoc_sf &slv_qxs_imem
+				&slv_qhs_apss &slv_qns_cnoc
+				&slv_xs_sys_tcu_cfg &slv_xs_qdss_stm>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn10>;
+		};
+
+		mas_qnm_gladiator_sodv: mas-qnm-gladiator-sodv {
+			cell-id = <MSM_BUS_MASTER_GNOC_SNOC>;
+			label = "mas-qnm-gladiator-sodv";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qxs_pimem
+				&slv_qxs_imem &slv_qhs_apss
+				&slv_qns_cnoc &slv_xs_sys_tcu_cfg
+				&slv_xs_qdss_stm>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn11>;
+		};
+
+		mas_qnm_memnoc: mas-qnm-memnoc {
+			cell-id = <MSM_BUS_MASTER_MEM_NOC_SNOC>;
+			label = "mas-qnm-memnoc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,connections = <&slv_qxs_imem
+				&slv_qhs_apss &slv_qxs_pimem
+				&slv_qns_cnoc &slv_xs_qdss_stm>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn13>;
+		};
+
+		mas_qxm_pimem: mas-qxm-pimem {
+			cell-id = <MSM_BUS_MASTER_PIMEM>;
+			label = "mas-qxm-pimem";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <3>;
+			qcom,connections = <&slv_qxs_imem &slv_qns_memnoc_gc>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn4>;
+			qcom,ap-owned;
+			qcom,prio = <2>;
+		};
+
+		mas_xm_gic: mas-xm-gic {
+			cell-id = <MSM_BUS_MASTER_GIC>;
+			label = "mas-xm-gic";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <0>;
+			qcom,connections = <&slv_qxs_imem &slv_qns_memnoc_gc>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn11>;
+			qcom,ap-owned;
+			qcom,prio = <1>;
+		};
+
+		mas_alc: mas-alc {
+			cell-id = <MSM_BUS_MASTER_ALC>;
+			label = "mas-alc";
+			qcom,buswidth = <1>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mc_virt>;
+			qcom,bcms = <&bcm_alc>;
+		};
+
+		mas_llcc_mc_display: mas-llcc-mc_display {
+			cell-id = <MSM_BUS_MASTER_LLCC_DISPLAY>;
+			label = "mas-llcc-mc_display";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <2>;
+			qcom,connections = <&slv_ebi_display>;
+			qcom,bus-dev = <&fab_mc_virt_display>;
+		};
+
+		mas_qnm_mnoc_hf_display: mas-qnm-mnoc-hf_display {
+			cell-id = <MSM_BUS_MASTER_MNOC_HF_MEM_NOC_DISPLAY>;
+			label = "mas-qnm-mnoc-hf_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,qport = <4 5>;
+			qcom,connections = <&slv_qns_llcc_display>;
+			qcom,bus-dev = <&fab_mem_noc_display>;
+		};
+
+		mas_qnm_mnoc_sf_display: mas-qnm-mnoc-sf_display {
+			cell-id = <MSM_BUS_MASTER_MNOC_SF_MEM_NOC_DISPLAY>;
+			label = "mas-qnm-mnoc-sf_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <7>;
+			qcom,connections = <&slv_qns_llcc_display>;
+			qcom,bus-dev = <&fab_mem_noc_display>;
+		};
+
+		mas_qxm_mdp0_display: mas-qxm-mdp0_display {
+			cell-id = <MSM_BUS_MASTER_MDP_PORT0_DISPLAY>;
+			label = "mas-qxm-mdp0_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <3>;
+			qcom,connections = <&slv_qns_mem_noc_hf_display>;
+			qcom,bus-dev = <&fab_mmss_noc_display>;
+			qcom,bcms = <&bcm_mm1_display>;
+		};
+
+		mas_qxm_mdp1_display: mas-qxm-mdp1_display {
+			cell-id = <MSM_BUS_MASTER_MDP_PORT1_DISPLAY>;
+			label = "mas-qxm-mdp1_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <4>;
+			qcom,connections = <&slv_qns_mem_noc_hf_display>;
+			qcom,bus-dev = <&fab_mmss_noc_display>;
+			qcom,bcms = <&bcm_mm1_display>;
+		};
+
+		mas_qxm_rot_display: mas-qxm-rot_display {
+			cell-id = <MSM_BUS_MASTER_ROTATOR_DISPLAY>;
+			label = "mas-qxm-rot_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,qport = <5>;
+			qcom,connections = <&slv_qns2_mem_noc_display>;
+			qcom,bus-dev = <&fab_mmss_noc_display>;
+			qcom,bcms = <&bcm_mm3_display>;
+		};
+
+		/*Internal nodes*/
+
+		/*Slaves*/
+
+		slv_qns_a1noc_snoc:slv-qns-a1noc-snoc {
+			cell-id = <MSM_BUS_A1NOC_SNOC_SLV>;
+			label = "slv-qns-a1noc-snoc";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,connections = <&mas_qnm_aggre1_noc>;
+		};
+
+		slv_srvc_aggre1_noc:slv-srvc-aggre1-noc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_A1NOC>;
+			label = "slv-srvc-aggre1-noc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_aggre1_noc>;
+			qcom,bcms = <&bcm_sn8>;
+		};
+
+		slv_qns_a2noc_snoc:slv-qns-a2noc-snoc {
+			cell-id = <MSM_BUS_A2NOC_SNOC_SLV>;
+			label = "slv-qns-a2noc-snoc";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,connections = <&mas_qnm_aggre2_noc>;
+		};
+
+		slv_srvc_aggre2_noc:slv-srvc-aggre2-noc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_A2NOC>;
+			label = "slv-srvc-aggre2-noc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,bcms = <&bcm_sn10>;
+		};
+
+		slv_qns_camnoc_uncomp:slv-qns-camnoc-uncomp {
+			cell-id = <MSM_BUS_SLAVE_CAMNOC_UNCOMP>;
+			label = "slv-qns-camnoc-uncomp";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_camnoc_virt>;
+		};
+
+		slv_qhs_a1_noc_cfg:slv-qhs-a1-noc-cfg {
+			cell-id = <MSM_BUS_SLAVE_A1NOC_CFG>;
+			label = "slv-qhs-a1-noc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qhm_a1noc_cfg>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_a2_noc_cfg:slv-qhs-a2-noc-cfg {
+			cell-id = <MSM_BUS_SLAVE_A2NOC_CFG>;
+			label = "slv-qhs-a2-noc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qhm_a2noc_cfg>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_aop:slv-qhs-aop {
+			cell-id = <MSM_BUS_SLAVE_AOP>;
+			label = "slv-qhs-aop";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_aoss:slv-qhs-aoss {
+			cell-id = <MSM_BUS_SLAVE_AOSS>;
+			label = "slv-qhs-aoss";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_camera_cfg:slv-qhs-camera-cfg {
+			cell-id = <MSM_BUS_SLAVE_CAMERA_CFG>;
+			label = "slv-qhs-camera-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_clk_ctl:slv-qhs-clk-ctl {
+			cell-id = <MSM_BUS_SLAVE_CLK_CTL>;
+			label = "slv-qhs-clk-ctl";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_compute_dsp_cfg:slv-qhs-compute-dsp-cfg {
+			cell-id = <MSM_BUS_SLAVE_CDSP_CFG>;
+			label = "slv-qhs-compute-dsp-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_cpr_cx:slv-qhs-cpr-cx {
+			cell-id = <MSM_BUS_SLAVE_RBCPR_CX_CFG>;
+			label = "slv-qhs-cpr-cx";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_crypto0_cfg:slv-qhs-crypto0-cfg {
+			cell-id = <MSM_BUS_SLAVE_CRYPTO_0_CFG>;
+			label = "slv-qhs-crypto0-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_dcc_cfg:slv-qhs-dcc-cfg {
+			cell-id = <MSM_BUS_SLAVE_DCC_CFG>;
+			label = "slv-qhs-dcc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qhm_cnoc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_ddrss_cfg:slv-qhs-ddrss-cfg {
+			cell-id = <MSM_BUS_SLAVE_CNOC_DDRSS>;
+			label = "slv-qhs-ddrss-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_display_cfg:slv-qhs-display-cfg {
+			cell-id = <MSM_BUS_SLAVE_DISPLAY_CFG>;
+			label = "slv-qhs-display-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_glm:slv-qhs-glm {
+			cell-id = <MSM_BUS_SLAVE_GLM>;
+			label = "slv-qhs-glm";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_gpuss_cfg:slv-qhs-gpuss-cfg {
+			cell-id = <MSM_BUS_SLAVE_GRAPHICS_3D_CFG>;
+			label = "slv-qhs-gpuss-cfg";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_imem_cfg:slv-qhs-imem-cfg {
+			cell-id = <MSM_BUS_SLAVE_IMEM_CFG>;
+			label = "slv-qhs-imem-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_ipa:slv-qhs-ipa {
+			cell-id = <MSM_BUS_SLAVE_IPA_CFG>;
+			label = "slv-qhs-ipa";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_mnoc_cfg:slv-qhs-mnoc-cfg {
+			cell-id = <MSM_BUS_SLAVE_CNOC_MNOC_CFG>;
+			label = "slv-qhs-mnoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qhm_mnoc_cfg>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_pdm:slv-qhs-pdm {
+			cell-id = <MSM_BUS_SLAVE_PDM>;
+			label = "slv-qhs-pdm";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_phy_refgen_south:slv-qhs-phy-refgen-south {
+			cell-id = <MSM_BUS_SLAVE_SOUTH_PHY_CFG>;
+			label = "slv-qhs-phy-refgen-south";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_pimem_cfg:slv-qhs-pimem-cfg {
+			cell-id = <MSM_BUS_SLAVE_PIMEM_CFG>;
+			label = "slv-qhs-pimem-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_prng:slv-qhs-prng {
+			cell-id = <MSM_BUS_SLAVE_PRNG>;
+			label = "slv-qhs-prng";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_qdss_cfg:slv-qhs-qdss-cfg {
+			cell-id = <MSM_BUS_SLAVE_QDSS_CFG>;
+			label = "slv-qhs-qdss-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_qupv3_north:slv-qhs-qupv3-north {
+			cell-id = <MSM_BUS_SLAVE_BLSP_2>;
+			label = "slv-qhs-qupv3-north";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_qupv3_south:slv-qhs-qupv3-south {
+			cell-id = <MSM_BUS_SLAVE_BLSP_1>;
+			label = "slv-qhs-qupv3-south";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_sdc2:slv-qhs-sdc2 {
+			cell-id = <MSM_BUS_SLAVE_SDCC_2>;
+			label = "slv-qhs-sdc2";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_sdc4:slv-qhs-sdc4 {
+			cell-id = <MSM_BUS_SLAVE_SDCC_4>;
+			label = "slv-qhs-sdc4";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_snoc_cfg:slv-qhs-snoc-cfg {
+			cell-id = <MSM_BUS_SLAVE_SNOC_CFG>;
+			label = "slv-qhs-snoc-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qhm_snoc_cfg>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_spdm:slv-qhs-spdm {
+			cell-id = <MSM_BUS_SLAVE_SPDM_WRAPPER>;
+			label = "slv-qhs-spdm";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_tcsr:slv-qhs-tcsr {
+			cell-id = <MSM_BUS_SLAVE_TCSR>;
+			label = "slv-qhs-tcsr";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_tlmm_north:slv-qhs-tlmm-north {
+			cell-id = <MSM_BUS_SLAVE_TLMM_NORTH>;
+			label = "slv-qhs-tlmm-north";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_tlmm_south:slv-qhs-tlmm-south {
+			cell-id = <MSM_BUS_SLAVE_TLMM_SOUTH>;
+			label = "slv-qhs-tlmm-south";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_tsif:slv-qhs-tsif {
+			cell-id = <MSM_BUS_SLAVE_TSIF>;
+			label = "slv-qhs-tsif";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_ufs_mem_cfg:slv-qhs-ufs-mem-cfg {
+			cell-id = <MSM_BUS_SLAVE_UFS_MEM_CFG>;
+			label = "slv-qhs-ufs-mem-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_usb3_0:slv-qhs-usb3-0 {
+			cell-id = <MSM_BUS_SLAVE_USB3>;
+			label = "slv-qhs-usb3-0";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_venus_cfg:slv-qhs-venus-cfg {
+			cell-id = <MSM_BUS_SLAVE_VENUS_CFG>;
+			label = "slv-qhs-venus-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_vsense_ctrl_cfg:slv-qhs-vsense-ctrl-cfg {
+			cell-id = <MSM_BUS_SLAVE_VSENSE_CTRL_CFG>;
+			label = "slv-qhs-vsense-ctrl-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qns_cnoc_a2noc:slv-qns-cnoc-a2noc {
+			cell-id = <MSM_BUS_SLAVE_CNOC_A2NOC>;
+			label = "slv-qns-cnoc-a2noc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,connections = <&mas_qnm_cnoc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_srvc_cnoc:slv-srvc-cnoc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_CNOC>;
+			label = "slv-srvc-cnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_config_noc>;
+			qcom,bcms = <&bcm_cn0>;
+		};
+
+		slv_qhs_llcc:slv-qhs-llcc {
+			cell-id = <MSM_BUS_SLAVE_LLCC_CFG>;
+			label = "slv-qhs-llcc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_dc_noc>;
+		};
+
+		slv_qhs_memnoc:slv-qhs-memnoc {
+			cell-id = <MSM_BUS_SLAVE_MEM_NOC_CFG>;
+			label = "slv-qhs-memnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_dc_noc>;
+			qcom,connections = <&mas_qhm_memnoc_cfg>;
+		};
+
+		slv_qns_gladiator_sodv:slv-qns-gladiator-sodv {
+			cell-id = <MSM_BUS_SLAVE_GNOC_SNOC>;
+			label = "slv-qns-gladiator-sodv";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_gladiator_noc>;
+			qcom,connections = <&mas_qnm_gladiator_sodv>;
+		};
+
+		slv_qns_gnoc_memnoc:slv-qns-gnoc-memnoc {
+			cell-id = <MSM_BUS_SLAVE_GNOC_MEM_NOC>;
+			label = "slv-qns-gnoc-memnoc";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_gladiator_noc>;
+			qcom,connections = <&mas_qnm_apps>;
+		};
+
+		slv_srvc_gnoc:slv-srvc-gnoc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_GNOC>;
+			label = "slv-srvc-gnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_gladiator_noc>;
+		};
+
+		slv_ipa_core_slave:slv-ipa-core-slave {
+			cell-id = <MSM_BUS_SLAVE_IPA_CORE>;
+			label = "slv-ipa-core-slave";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_ipa_virt>;
+			qcom,bcms = <&bcm_ip0>;
+		};
+
+		slv_ebi:slv-ebi {
+			cell-id = <MSM_BUS_SLAVE_EBI_CH0>;
+			label = "slv-ebi";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mc_virt>;
+			qcom,bcms = <&bcm_mc0>, <&bcm_acv>;
+		};
+
+		slv_qhs_mdsp_ms_mpu_cfg:slv-qhs-mdsp-ms-mpu-cfg {
+			cell-id = <MSM_BUS_SLAVE_MSS_PROC_MS_MPU_CFG>;
+			label = "slv-qhs-mdsp-ms-mpu-cfg";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mem_noc>;
+		};
+
+		slv_qns_apps_io:slv-qns-apps-io {
+			cell-id = <MSM_BUS_SLAVE_MEM_NOC_GNOC>;
+			label = "slv-qns-apps-io";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,bcms = <&bcm_sh1>;
+		};
+
+		slv_qns_llcc:slv-qns-llcc {
+			cell-id = <MSM_BUS_SLAVE_LLCC>;
+			label = "slv-qns-llcc";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,connections = <&mas_llcc_mc>;
+			qcom,bcms = <&bcm_sh0>;
+		};
+
+		slv_qns_memnoc_snoc:slv-qns-memnoc-snoc {
+			cell-id = <MSM_BUS_SLAVE_MEM_NOC_SNOC>;
+			label = "slv-qns-memnoc-snoc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mem_noc>;
+			qcom,connections = <&mas_qnm_memnoc>;
+			qcom,bcms = <&bcm_sh2>;
+		};
+
+		slv_srvc_memnoc:slv-srvc-memnoc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_MEM_NOC>;
+			label = "slv-srvc-memnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mem_noc>;
+		};
+
+		slv_qns2_mem_noc:slv-qns2-mem-noc {
+			cell-id = <MSM_BUS_SLAVE_MNOC_SF_MEM_NOC>;
+			label = "slv-qns2-mem-noc";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,connections = <&mas_qnm_mnoc_sf>;
+			qcom,bcms = <&bcm_mm2>;
+		};
+
+		slv_qns_mem_noc_hf:slv-qns-mem-noc-hf {
+			cell-id = <MSM_BUS_SLAVE_MNOC_HF_MEM_NOC>;
+			label = "slv-qns-mem-noc-hf";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+			qcom,connections = <&mas_qnm_mnoc_hf>;
+			qcom,bcms = <&bcm_mm0>;
+		};
+
+		slv_srvc_mnoc:slv-srvc-mnoc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_MNOC>;
+			label = "slv-srvc-mnoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mmss_noc>;
+		};
+
+		slv_qhs_apss:slv-qhs-apss {
+			cell-id = <MSM_BUS_SLAVE_APPSS>;
+			label = "slv-qhs-apss";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+		};
+
+		slv_qns_cnoc:slv-qns-cnoc {
+			cell-id = <MSM_BUS_SNOC_CNOC_SLV>;
+			label = "slv-qns-cnoc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,connections = <&mas_qnm_snoc>;
+			qcom,bcms = <&bcm_sn3>;
+		};
+
+		slv_qns_memnoc_gc:slv-qns-memnoc-gc {
+			cell-id = <MSM_BUS_SLAVE_SNOC_MEM_NOC_GC>;
+			label = "slv-qns-memnoc-gc";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,connections = <&mas_qnm_snoc_gc>;
+			qcom,bcms = <&bcm_sn2>;
+		};
+
+		slv_qns_memnoc_sf:slv-qns-memnoc-sf {
+			cell-id = <MSM_BUS_SLAVE_SNOC_MEM_NOC_SF>;
+			label = "slv-qns-memnoc-sf";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,connections = <&mas_qnm_snoc_sf>;
+			qcom,bcms = <&bcm_sn0>;
+		};
+
+		slv_qxs_imem:slv-qxs-imem {
+			cell-id = <MSM_BUS_SLAVE_OCIMEM>;
+			label = "slv-qxs-imem";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn1>;
+		};
+
+		slv_qxs_pimem:slv-qxs-pimem {
+			cell-id = <MSM_BUS_SLAVE_PIMEM>;
+			label = "slv-qxs-pimem";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn4>;
+		};
+
+		slv_srvc_snoc:slv-srvc-snoc {
+			cell-id = <MSM_BUS_SLAVE_SERVICE_SNOC>;
+			label = "slv-srvc-snoc";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+		};
+
+		slv_xs_qdss_stm:slv-xs-qdss-stm {
+			cell-id = <MSM_BUS_SLAVE_QDSS_STM>;
+			label = "slv-xs-qdss-stm";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+			qcom,bcms = <&bcm_sn5>;
+		};
+
+		slv_xs_sys_tcu_cfg:slv-xs-sys-tcu-cfg {
+			cell-id = <MSM_BUS_SLAVE_TCU>;
+			label = "slv-xs-sys-tcu-cfg";
+			qcom,buswidth = <8>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_system_noc>;
+		};
+
+		slv_ebi_display:slv-ebi_display {
+			cell-id = <MSM_BUS_SLAVE_EBI_CH0_DISPLAY>;
+			label = "slv-ebi_display";
+			qcom,buswidth = <4>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mc_virt_display>;
+			qcom,bcms = <&bcm_mc0_display>;
+		};
+
+		slv_qns_llcc_display:slv-qns-llcc_display {
+			cell-id = <MSM_BUS_SLAVE_LLCC_DISPLAY>;
+			label = "slv-qns-llcc_display";
+			qcom,buswidth = <16>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mem_noc_display>;
+			qcom,connections = <&mas_llcc_mc_display>;
+			qcom,bcms = <&bcm_sh0_display>;
+		};
+
+		slv_qns2_mem_noc_display:slv-qns2-mem-noc_display {
+			cell-id = <MSM_BUS_SLAVE_MNOC_SF_MEM_NOC_DISPLAY>;
+			label = "slv-qns2-mem-noc_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <1>;
+			qcom,bus-dev = <&fab_mmss_noc_display>;
+			qcom,connections = <&mas_qnm_mnoc_sf_display>;
+			qcom,bcms = <&bcm_mm2_display>;
+		};
+
+		slv_qns_mem_noc_hf_display:slv-qns-mem-noc-hf_display {
+			cell-id = <MSM_BUS_SLAVE_MNOC_HF_MEM_NOC_DISPLAY>;
+			label = "slv-qns-mem-noc-hf_display";
+			qcom,buswidth = <32>;
+			qcom,agg-ports = <2>;
+			qcom,bus-dev = <&fab_mmss_noc_display>;
+			qcom,connections = <&mas_qnm_mnoc_hf_display>;
+			qcom,bcms = <&bcm_mm0_display>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-cdp-overlay.dts
index f0c820f..2b5ed1a 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-cdp-overlay.dts
+++ b/arch/arm64/boot/dts/qcom/sdm670-cdp-overlay.dts
@@ -20,11 +20,15 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
 #include "sdm670-cdp.dtsi"
+#include "sdm670-audio-overlay.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. SDM670 CDP";
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L CDP";
 	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
 	qcom,msm-id = <336 0x0>;
 	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
 };
 
diff --git a/arch/arm64/boot/dts/qcom/sdm670-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-cdp.dts
index 7e5947b..5a1b945 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-cdp.dts
+++ b/arch/arm64/boot/dts/qcom/sdm670-cdp.dts
@@ -15,9 +15,13 @@
 
 #include "sdm670.dtsi"
 #include "sdm670-cdp.dtsi"
+#include "sdm670-audio-overlay.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. SDM670 CDP";
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L CDP";
 	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
 	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm670-cdp.dtsi b/arch/arm64/boot/dts/qcom/sdm670-cdp.dtsi
index 0cf48a3..fa06779 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-cdp.dtsi
@@ -10,6 +10,36 @@
  * GNU General Public License for more details.
  */
 
+#include <dt-bindings/gpio/gpio.h>
+#include "sdm670-pmic-overlay.dtsi"
+#include "sdm670-sde-display.dtsi"
+
+&ufsphy_mem {
+	compatible = "qcom,ufs-phy-qmp-v3";
+
+	vdda-phy-supply = <&pm660l_l1>; /* 0.88v */
+	vdda-pll-supply = <&pm660_l1>; /* 1.2v */
+	vdda-phy-max-microamp = <62900>;
+	vdda-pll-max-microamp = <18300>;
+
+	status = "ok";
+};
+
+&ufshc_mem {
+	vdd-hba-supply = <&ufs_phy_gdsc>;
+	vdd-hba-fixed-regulator;
+	vcc-supply = <&pm660l_l4>;
+	vcc-voltage-level = <2960000 2960000>;
+	vccq2-supply = <&pm660_l8>;
+	vcc-max-microamp = <600000>;
+	vccq2-max-microamp = <600000>;
+
+	qcom,vddp-ref-clk-supply = <&pm660_l1>;
+	qcom,vddp-ref-clk-max-microamp = <100>;
+
+	status = "ok";
+};
+
 &qupv3_se9_2uart {
 	status = "disabled";
 };
@@ -33,3 +63,185 @@
 &qupv3_se6_4uart {
 	status = "disabled";
 };
+
+&sdhc_1 {
+	vdd-supply = <&pm660l_l4>;
+	qcom,vdd-voltage-level = <2960000 2960000>;
+	qcom,vdd-current-level = <200 570000>;
+
+	vdd-io-supply = <&pm660_l8>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-lpm-sup;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <200 325000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc1_clk_on  &sdc1_cmd_on &sdc1_data_on &sdc1_rclk_on>;
+	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off &sdc1_rclk_off>;
+
+	status = "ok";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm660l_l5>;
+	qcom,vdd-voltage-level = <2960000 2960000>;
+	qcom,vdd-current-level = <200 800000>;
+
+	vdd-io-supply = <&pm660l_l2>;
+	qcom,vdd-io-voltage-level = <1800000 2960000>;
+	qcom,vdd-io-current-level = <200 22000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 0 204 0
+			1 &intc 0 0 222 0
+			2 &tlmm 96 0>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&tlmm 96 0x1>;
+
+	status = "ok";
+};
+
+&pm660_charger {
+	qcom,batteryless-platform;
+};
+
+&soc {
+	gpio_keys {
+		compatible = "gpio-keys";
+		label = "gpio-keys";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&key_cam_snapshot_default
+			     &key_cam_focus_default
+			     &key_vol_up_default>;
+
+		cam_snapshot {
+			label = "cam_snapshot";
+			gpios = <&tlmm 91 0>;
+			linux,input-type = <1>;
+			linux,code = <766>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+
+		cam_focus {
+			label = "cam_focus";
+			gpios = <&tlmm 92 0>;
+			linux,input-type = <1>;
+			linux,code = <528>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&pm660l_gpios 7 GPIO_ACTIVE_LOW>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+	};
+};
+
+&dsi_dual_nt35597_truly_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_nt35597_truly_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+};
+
+&dsi_nt35597_truly_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "single_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_nt35597_truly_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "single_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+};
+
+&dsi_sim_vid {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_vid {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_sim_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_sim_dsc_375_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_dsc_375_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_nt35597_truly_video {
+	qcom,dsi-display-active;
+};
+
+&pm660l_wled {
+	status = "okay";
+	qcom,led-strings-list = [01 02];
+};
+
+&mdss_mdp {
+	#cooling-cells = <2>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-coresight.dtsi b/arch/arm64/boot/dts/qcom/sdm670-coresight.dtsi
new file mode 100644
index 0000000..8b79d8b
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-coresight.dtsi
@@ -0,0 +1,1887 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+&soc {
+
+	replicator_qdss: replicator@6046000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b909>;
+
+		reg = <0x6046000 0x1000>;
+		reg-names = "replicator-base";
+
+		coresight-name = "coresight-replicator";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				replicator_out_tmc_etr: endpoint {
+					remote-endpoint =
+						<&tmc_etr_in_replicator>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				replicator_in_tmc_etf: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tmc_etf_out_replicator>;
+				};
+			};
+		};
+	};
+
+	tmc_etr: tmc@6048000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b961>;
+
+		reg = <0x6048000 0x1000>,
+		      <0x6064000 0x15000>;
+		reg-names = "tmc-base", "bam-base";
+
+		arm,buffer-size = <0x400000>;
+		arm,sg-enable;
+
+		coresight-name = "coresight-tmc-etr";
+		coresight-ctis = <&cti0 &cti8>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tmc_etr_in_replicator: endpoint {
+				slave-mode;
+				remote-endpoint = <&replicator_out_tmc_etr>;
+			};
+		};
+	};
+
+	tmc_etf: tmc@6047000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b961>;
+
+		reg = <0x6047000 0x1000>;
+		reg-names = "tmc-base";
+
+		coresight-name = "coresight-tmc-etf";
+		coresight-ctis = <&cti0 &cti8>;
+		arm,default-sink;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				tmc_etf_out_replicator: endpoint {
+					remote-endpoint =
+						<&replicator_in_tmc_etf>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+				tmc_etf_in_funnel_merg: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_merg_out_tmc_etf>;
+				};
+			};
+		};
+
+	};
+
+	funnel_merg: funnel@6045000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6045000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-merg";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_merg_out_tmc_etf: endpoint {
+					remote-endpoint =
+						<&tmc_etf_in_funnel_merg>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_merg_in_funnel_in0: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_in0_out_funnel_merg>;
+				};
+			};
+
+			port@2 {
+				reg = <1>;
+				funnel_merg_in_funnel_in1: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_in1_out_funnel_merg>;
+				};
+			};
+
+			port@3 {
+				reg = <2>;
+				funnel_merg_in_funnel_in2: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_in2_out_funnel_merg>;
+				};
+			};
+		};
+	};
+
+	stm: stm@6002000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b962>;
+
+		reg = <0x6002000 0x1000>,
+		      <0x16280000 0x180000>;
+		reg-names = "stm-base", "stm-stimulus-base";
+
+		coresight-name = "coresight-stm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			stm_out_funnel_in0: endpoint {
+				remote-endpoint = <&funnel_in0_in_stm>;
+			};
+		};
+
+	};
+
+	hwevent: hwevent@0x014066f0 {
+		compatible = "qcom,coresight-hwevent";
+		reg = <0x14066f0 0x4>,
+		      <0x14166f0 0x4>,
+		      <0x1406038 0x4>,
+		      <0x1416038 0x4>;
+		reg-names = "ddr-ch0-cfg", "ddr-ch23-cfg", "ddr-ch0-ctrl",
+			    "ddr-ch23-ctrl";
+
+		coresight-name = "coresight-hwevent";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	csr: csr@6001000 {
+		compatible = "qcom,coresight-csr";
+		reg = <0x6001000 0x1000>;
+		reg-names = "csr-base";
+
+		coresight-name = "coresight-csr";
+
+		qcom,blk-size = <1>;
+	};
+
+	funnel_in0: funnel@0x6041000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6041000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-in0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_in0_out_funnel_merg: endpoint {
+					remote-endpoint =
+						<&funnel_merg_in_funnel_in0>;
+				};
+			};
+
+			port@1 {
+				reg = <6>;
+				funnel_in0_in_funnel_qatb: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_qatb_out_funnel_in0>;
+				};
+			};
+
+			port@2 {
+				reg = <7>;
+				funnel_in0_in_stm: endpoint {
+					slave-mode;
+					remote-endpoint = <&stm_out_funnel_in0>;
+				};
+			};
+		};
+	};
+
+	funnel_in1: funnel@0x6042000 {
+		 compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6042000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-in1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_in1_out_funnel_merg: endpoint {
+					remote-endpoint =
+					  <&funnel_merg_in_funnel_in1>;
+				};
+			};
+
+			port@1 {
+				reg = <3>;
+				funnel_in1_in_funnel_modem: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&funnel_modem_out_funnel_in1>;
+				};
+			};
+		};
+	};
+
+	funnel_in2: funnel@0x6043000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6043000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-in2";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_in2_out_funnel_merg: endpoint {
+					remote-endpoint =
+					  <&funnel_merg_in_funnel_in2>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_in2_in_modem_etm0: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&modem_etm0_out_funnel_in2>;
+				};
+
+			};
+
+			port@2 {
+				reg = <5>;
+				funnel_in2_in_funnel_apss_merg: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&funnel_apss_merg_out_funnel_in2>;
+				};
+			};
+
+		};
+	};
+
+	tpda: tpda@6004000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b969>;
+		reg = <0x6004000 0x1000>;
+		reg-names = "tpda-base";
+
+		coresight-name = "coresight-tpda";
+
+		qcom,tpda-atid = <65>;
+		qcom,bc-elem-size = <10 32>,
+				    <13 32>;
+		qcom,tc-elem-size = <13 32>;
+		qcom,dsb-elem-size = <0 32>,
+				     <2 32>,
+				     <3 32>,
+				     <5 32>,
+				     <6 32>,
+				     <10 32>,
+				     <11 32>,
+				     <13 32>;
+		qcom,cmb-elem-size = <3 64>,
+				     <7 64>,
+				     <13 64>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				tpda_out_funnel_qatb: endpoint {
+					remote-endpoint =
+						<&funnel_qatb_in_tpda>;
+				};
+
+			};
+
+			port@1 {
+				reg = <0>;
+				tpda_in_tpdm_center: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_center_out_tpda>;
+				};
+			};
+
+			port@2 {
+				reg = <2>;
+				tpda_in_funnel_dl_mm: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_dl_mm_out_tpda>;
+				};
+			};
+
+			port@3 {
+				reg = <3>;
+				tpda_in_funnel_ddr_0: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_ddr_0_out_tpda>;
+				};
+			};
+
+			port@4 {
+				reg = <6>;
+				tpda_in_funnel_turing: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&funnel_turing_out_tpda>;
+				};
+			};
+
+			port@5 {
+				reg = <7>;
+				tpda_in_tpdm_vsense: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_vsense_out_tpda>;
+				};
+			};
+
+			port@6 {
+				reg = <10>;
+				tpda_in_tpdm_qm: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_qm_out_tpda>;
+				};
+			};
+
+			port@7 {
+				reg = <11>;
+				tpda_in_tpdm_north: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_north_out_tpda>;
+				};
+			};
+
+			port@8 {
+				reg = <13>;
+				tpda_in_tpdm_pimem: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_pimem_out_tpda>;
+				};
+			};
+		};
+	};
+
+	funnel_modem: funnel@6832000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6832000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-modem";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_modem_out_funnel_in1: endpoint {
+					remote-endpoint =
+					    <&funnel_in1_in_funnel_modem>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_modem_in_tpda_modem: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpda_modem_out_funnel_modem>;
+				};
+			};
+		};
+	};
+
+	tpda_modem: tpda@6831000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b969>;
+		reg = <0x6831000 0x1000>;
+		reg-names = "tpda-base";
+
+		coresight-name = "coresight-tpda-modem";
+
+		qcom,tpda-atid = <67>;
+		qcom,dsb-elem-size = <0 32>;
+		qcom,cmb-elem-size = <0 64>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				tpda_modem_out_funnel_modem: endpoint {
+					remote-endpoint =
+						<&funnel_modem_in_tpda_modem>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				tpda_modem_in_tpdm_modem: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_modem_out_tpda_modem>;
+				};
+			};
+		};
+	};
+
+	tpdm_modem: tpdm@6830000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6830000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-modem";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_modem_out_tpda_modem: endpoint {
+				remote-endpoint = <&tpda_modem_in_tpdm_modem>;
+			};
+		};
+	};
+
+	tpdm_center: tpdm@6c28000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6c28000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-center";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_center_out_tpda: endpoint {
+				remote-endpoint = <&tpda_in_tpdm_center>;
+			};
+		};
+	};
+
+	tpdm_north: tpdm@6a24000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6a24000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-north";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_north_out_tpda: endpoint {
+				remote-endpoint = <&tpda_in_tpdm_north>;
+			};
+		};
+	};
+
+	tpdm_qm: tpdm@69d0000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x69d0000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-qm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_qm_out_tpda: endpoint {
+				remote-endpoint = <&tpda_in_tpdm_qm>;
+			};
+		};
+	};
+
+	tpda_apss: tpda@7862000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b969>;
+		reg = <0x7862000 0x1000>;
+		reg-names = "tpda-base";
+
+		coresight-name = "coresight-tpda-apss";
+
+		qcom,tpda-atid = <66>;
+		qcom,dsb-elem-size = <0 32>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				tpda_apss_out_funnel_apss_merg: endpoint {
+					remote-endpoint =
+					       <&funnel_apss_merg_in_tpda_apss>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				tpda_apss_in_tpdm_apss: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_apss_out_tpda_apss>;
+				};
+			};
+		};
+	};
+
+	tpdm_apss: tpdm@7860000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x7860000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-apss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_apss_out_tpda_apss: endpoint {
+				remote-endpoint = <&tpda_apss_in_tpdm_apss>;
+			};
+		};
+	};
+
+	funnel_dl_mm: funnel@6c0b000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6c0b000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-dl-mm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_dl_mm_out_tpda: endpoint {
+					remote-endpoint =
+					    <&tpda_in_funnel_dl_mm>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+				funnel_dl_mm_in_tpdm_mm: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&tpdm_mm_out_funnel_dl_mm>;
+				};
+			};
+		};
+	};
+
+	tpdm_mm: tpdm@6c08000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6c08000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-mm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_mm_out_funnel_dl_mm: endpoint {
+				remote-endpoint = <&funnel_dl_mm_in_tpdm_mm>;
+			};
+		};
+	};
+
+	funnel_turing: funnel@6861000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6861000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-turing";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_turing_out_tpda: endpoint {
+					remote-endpoint =
+					    <&tpda_in_funnel_turing>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_turing_in_tpdm_turing: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&tpdm_turing_out_funnel_turing>;
+				};
+			};
+
+			port@2 {
+				reg = <1>;
+				funnel_turing_in_turing_etm0: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&turing_etm0_out_funnel_turing>;
+				};
+			};
+		};
+	};
+
+	tpdm_turing: tpdm@6860000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6860000 0x1000>;
+		reg-names = "tpdm-base";
+		status = "disabled";
+
+		coresight-name = "coresight-tpdm-turing";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_turing_out_funnel_turing: endpoint {
+				remote-endpoint =
+				    <&funnel_turing_in_tpdm_turing>;
+			};
+		};
+	};
+
+	funnel_ddr_0: funnel@69e2000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x69e2000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-ddr-0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_ddr_0_out_tpda: endpoint {
+					remote-endpoint =
+					    <&tpda_in_funnel_ddr_0>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_ddr_0_in_tpdm_ddr: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&tpdm_ddr_out_funnel_ddr_0>;
+				};
+			};
+		};
+	};
+
+	tpdm_ddr: tpdm@69e0000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x69e0000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-ddr";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_ddr_out_funnel_ddr_0: endpoint {
+				remote-endpoint = <&funnel_ddr_0_in_tpdm_ddr>;
+			};
+		};
+	};
+
+	tpdm_pimem: tpdm@6850000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6850000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-pimem";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			tpdm_pimem_out_tpda: endpoint {
+				remote-endpoint = <&tpda_in_tpdm_pimem>;
+			};
+		};
+	};
+
+	tpdm_vsense: tpdm@6840000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x6840000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-vsense";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port{
+			tpdm_vsense_out_tpda: endpoint {
+				remote-endpoint = <&tpda_in_tpdm_vsense>;
+			};
+		};
+	};
+
+	tpda_olc: tpda@7832000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b969>;
+		reg = <0x7832000 0x1000>;
+		reg-names = "tpda-base";
+
+		coresight-name = "coresight-tpda-olc";
+
+		qcom,tpda-atid = <69>;
+		qcom,cmb-elem-size = <0 64>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				tpda_olc_out_funnel_apss_merg: endpoint {
+					remote-endpoint =
+						<&funnel_apss_merg_in_tpda_olc>;
+				};
+			};
+			port@1 {
+				reg = <0>;
+				tpda_olc_in_tpdm_olc: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpdm_olc_out_tpda_olc>;
+				};
+			};
+		};
+	};
+
+	tpdm_olc: tpdm@7830000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b968>;
+		reg = <0x7830000 0x1000>;
+		reg-names = "tpdm-base";
+
+		coresight-name = "coresight-tpdm-olc";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port{
+			tpdm_olc_out_tpda_olc: endpoint {
+				remote-endpoint = <&tpda_olc_in_tpdm_olc>;
+			};
+		};
+	};
+
+	funnel_qatb: funnel@6005000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6005000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-qatb";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_qatb_out_funnel_in0: endpoint {
+					remote-endpoint =
+						<&funnel_in0_in_funnel_qatb>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_qatb_in_tpda: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&tpda_out_funnel_qatb>;
+				};
+			};
+		};
+	};
+
+	cti0_ddr0: cti@69e1000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x69e1000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-ddr0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_ddr1: cti@69e4000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x69e4000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-ddr1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_ddr1: cti@69e5000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x69e5000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-ddr1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_dlmm: cti@6c09000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6c09000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-dlmm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_dlmm: cti@6c0a000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6c0a000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-dlmm";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_dlct: cti@6c29000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6c29000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-dlct";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_dlct: cti@6c2a000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6c2a000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-dlct";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_wcss: cti@69a4000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x69a4000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-wcss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_wcss: cti@69a5000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x69a5000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-wcss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti2_wcss: cti@69a6000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x69a6000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti2-wcss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_mss_q6: cti@683b000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x683b000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-mss-q6";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_turing: cti@6867000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6867000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-turing";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti2_ssc_sdc: cti@6b10000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b10000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti2-ssc_sdc";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_ssc: cti@6b11000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b11000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-ssc";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_ssc_q6: cti@6b1b000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b1b000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-ssc-q6";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_ssc_noc: cti@6b1e000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b1e000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-ssc-noc";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti6_ssc_noc: cti@6b1f000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b1f000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti6-ssc-noc";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_swao: cti@6b04000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b04000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-swao";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_swao: cti@6b05000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b05000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-swao";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti2_swao: cti@6b06000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b06000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti2-swao";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti3_swao: cti@6b07000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b07000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti3-swao";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_aop_m3: cti@6b21000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6b21000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-aop-m3";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_titan: cti@6c13000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6c13000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-titan";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_venus_arm9: cti@6c20000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x6c20000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-venus-arm9";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_apss: cti@78e0000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x78e0000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0-apss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_apss: cti@78f0000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x78f0000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1-apss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti2_apss: cti@7900000 {
+		compatible = "arm,coresight-cti";
+		reg = <0x7900000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti2-apss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0: cti@6010000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6010000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti1: cti@6011000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6011000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti2: cti@6012000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6012000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti2";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti3: cti@6013000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6013000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti3";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti4: cti@6014000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6014000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti4";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti5: cti@6015000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6015000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti5";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti6: cti@6016000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6016000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti6";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti7: cti@6017000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6017000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti7";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti8: cti@6018000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6018000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti8";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti9: cti@6019000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x6019000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti9";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti10: cti@601a000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601a000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti10";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti11: cti@601b000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601b000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti11";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti12: cti@601c000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601c000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti12";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti13: cti@601d000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601d000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti13";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti14: cti@601e000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601e000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti14";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti15: cti@601f000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x601f000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti15";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti_cpu0: cti@7020000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7020000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu0";
+		cpu = <&CPU0>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+	};
+
+	cti_cpu1: cti@7120000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7120000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu1";
+		cpu = <&CPU1>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu2: cti@7220000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7220000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu2";
+		cpu = <&CPU2>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu3: cti@7320000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7320000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu3";
+		cpu = <&CPU3>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu4: cti@7420000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7420000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu4";
+		cpu = <&CPU4>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu5: cti@7520000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7520000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu5";
+		cpu = <&CPU5>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu6: cti@7620000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7620000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu6";
+		cpu = <&CPU6>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti_cpu7: cti@7720000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7720000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-cpu7";
+		cpu = <&CPU7>;
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	turing_etm0 {
+		compatible = "qcom,coresight-remote-etm";
+
+		coresight-name = "coresight-turing-etm0";
+		qcom,inst-id = <13>;
+
+		port{
+			turing_etm0_out_funnel_turing: endpoint {
+				remote-endpoint =
+					<&funnel_turing_in_turing_etm0>;
+			};
+		};
+	};
+
+	modem_etm0 {
+		compatible = "qcom,coresight-remote-etm";
+
+		coresight-name = "coresight-modem-etm0";
+		qcom,inst-id = <2>;
+
+		port {
+			modem_etm0_out_funnel_in2: endpoint {
+				remote-endpoint =
+					<&funnel_in2_in_modem_etm0>;
+			};
+		};
+	};
+
+	funnel_apss_merg: funnel@7810000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x7810000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-apss-merg";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_apss_merg_out_funnel_in2: endpoint {
+					remote-endpoint =
+					    <&funnel_in2_in_funnel_apss_merg>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_apss_merg_in_funnel_apss: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&funnel_apss_out_funnel_apss_merg>;
+				};
+			};
+
+			port@2 {
+				reg = <1>;
+				funnel_apss_merg_in_tpda_olc: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&tpda_olc_out_funnel_apss_merg>;
+				};
+			};
+
+			port@3 {
+				reg = <3>;
+				funnel_apss_merg_in_tpda_apss: endpoint {
+					slave-mode;
+					remote-endpoint =
+					    <&tpda_apss_out_funnel_apss_merg>;
+				};
+			};
+		};
+	};
+
+	etm0: etm@7040000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7040000 0x1000>;
+		cpu = <&CPU0>;
+
+		coresight-name = "coresight-etm0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm0_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm0>;
+			};
+		};
+	};
+
+	etm1: etm@7140000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7140000 0x1000>;
+		cpu = <&CPU1>;
+
+		coresight-name = "coresight-etm1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm1_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm1>;
+			};
+		};
+	};
+
+	etm2: etm@7240000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7240000 0x1000>;
+		cpu = <&CPU2>;
+
+		coresight-name = "coresight-etm2";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm2_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm2>;
+			};
+		};
+	};
+
+	etm3: etm@7340000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7340000 0x1000>;
+		cpu = <&CPU3>;
+
+		coresight-name = "coresight-etm3";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm3_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm3>;
+			};
+		};
+	};
+
+	etm4: etm@7440000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7440000 0x1000>;
+		cpu = <&CPU4>;
+
+		coresight-name = "coresight-etm4";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm4_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm4>;
+			};
+		};
+	};
+
+	etm5: etm@7540000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7540000 0x1000>;
+		cpu = <&CPU5>;
+
+		coresight-name = "coresight-etm5";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm5_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm5>;
+			};
+		};
+	};
+
+	etm6: etm@7640000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7640000 0x1000>;
+		cpu = <&CPU6>;
+
+		coresight-name = "coresight-etm6";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm6_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm6>;
+			};
+		};
+	};
+
+	etm7: etm@7740000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x000bb95d>;
+
+		reg = <0x7740000 0x1000>;
+		cpu = <&CPU7>;
+
+		coresight-name = "coresight-etm7";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		port {
+			etm7_out_funnel_apss: endpoint {
+				remote-endpoint = <&funnel_apss_in_etm7>;
+			};
+		};
+	};
+
+	funnel_apss: funnel@7800000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x7800000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-apss";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_apss_out_funnel_apss_merg: endpoint {
+					remote-endpoint =
+					    <&funnel_apss_merg_in_funnel_apss>;
+				};
+			};
+			port@1 {
+				reg = <0>;
+				funnel_apss_in_etm0: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm0_out_funnel_apss>;
+				};
+			};
+
+			port@2 {
+				reg = <1>;
+				funnel_apss_in_etm1: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm1_out_funnel_apss>;
+				};
+			};
+
+			port@3 {
+				reg = <2>;
+				funnel_apss_in_etm2: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm2_out_funnel_apss>;
+				};
+			};
+
+			port@4 {
+				reg = <3>;
+				funnel_apss_in_etm3: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm3_out_funnel_apss>;
+				};
+			};
+
+			port@5 {
+				reg = <4>;
+				funnel_apss_in_etm4: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm4_out_funnel_apss>;
+				};
+			};
+
+			port@6 {
+				reg = <5>;
+				funnel_apss_in_etm5: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm5_out_funnel_apss>;
+				};
+			};
+
+			port@7 {
+				reg = <6>;
+				funnel_apss_in_etm6: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm6_out_funnel_apss>;
+				};
+			};
+
+			port@8 {
+				reg = <7>;
+				funnel_apss_in_etm7: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&etm7_out_funnel_apss>;
+				};
+			};
+		};
+	};
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/arch/arm64/boot/dts/qcom/sdm670-ext-cdc-usbc-audio.dtsi
similarity index 68%
rename from sound/soc/codecs/audio-ext-clk-up.h
rename to arch/arm64/boot/dts/qcom/sdm670-ext-cdc-usbc-audio.dtsi
index 8a0232e..cd113b3 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/arch/arm64/boot/dts/qcom/sdm670-ext-cdc-usbc-audio.dtsi
@@ -7,14 +7,11 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
-
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
-
-#endif
+&tavil_snd {
+	qcom,msm-mbhc-usbc-audio-supported = <1>;
+	qcom,usbc-analog-en1-gpio = <&wcd_usbc_analog_en1_gpio>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-ext-codec-audio-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm670-ext-codec-audio-overlay.dtsi
new file mode 100644
index 0000000..775cf48
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-ext-codec-audio-overlay.dtsi
@@ -0,0 +1,96 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+#include "sdm670-audio-overlay.dtsi"
+
+&pmic_analog_codec {
+	status = "disabled";
+};
+
+&msm_sdw_codec {
+	status = "disabled";
+};
+
+&cdc_pdm_gpios {
+	status = "disabled";
+};
+
+&cdc_comp_gpios {
+	status = "disabled";
+};
+
+&cdc_dmic_gpios {
+	status = "disabled";
+};
+
+&cdc_sdw_gpios {
+	status = "disabled";
+};
+
+&wsa_spkr_en1 {
+	status = "disabled";
+};
+
+&wsa_spkr_en2 {
+	status = "disabled";
+};
+
+&qupv3_se8_spi {
+	status = "okay";
+};
+
+&soc {
+	wcd_buck_vreg_gpio: msm_cdc_pinctrl@94 {
+		status = "okay";
+		compatible = "qcom,msm-cdc-pinctrl";
+		pinctrl-names = "aud_active", "aud_sleep";
+		pinctrl-0 = <&wcd_buck_vsel_default>;
+		pinctrl-1 = <&wcd_buck_vsel_default>;
+	};
+};
+
+&wcd9xxx_intc {
+	status = "okay";
+};
+
+&wdsp_mgr {
+	status = "okay";
+};
+
+&wdsp_glink {
+	status = "okay";
+};
+
+&slim_aud {
+	status = "okay";
+};
+
+&dai_slim {
+	status = "okay";
+};
+
+&wcd934x_cdc {
+	status = "okay";
+	qcom,has-buck-vsel-gpio;
+	qcom,buck-vsel-gpio-node = <&wcd_buck_vreg_gpio>;
+};
+
+&clock_audio_lnbb {
+	status = "okay";
+};
+
+&wcd_rst_gpio {
+	status = "okay";
+};
+
+&wcd9xxx_intc {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp-overlay.dts
new file mode 100644
index 0000000..32a8580
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp-overlay.dts
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp.dts
new file mode 100644
index 0000000..6a87d3a
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-cdp.dts
@@ -0,0 +1,27 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660 + PM660L Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp-overlay.dts
new file mode 100644
index 0000000..970209ca
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp.dts
new file mode 100644
index 0000000..87ac190
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-mtp.dts
@@ -0,0 +1,27 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660 + PM660L Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp-overlay.dts
new file mode 100644
index 0000000..48a6066
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp-overlay.dts
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 1>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
+
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp.dts
new file mode 100644
index 0000000..e64d13b
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-cdp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660 + PM660A Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 1>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp-overlay.dts
new file mode 100644
index 0000000..8715ddc
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp-overlay.dts
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp.dts
new file mode 100644
index 0000000..0beaddb3
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec-pm660a-mtp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660 + PM660A Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 1>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sdm670-external-codec.dtsi
similarity index 62%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sdm670-external-codec.dtsi
index bc1cd9e..dbcc6bd 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sdm670-external-codec.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,22 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+#include "sdm670-ext-codec-audio-overlay.dtsi"
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
+&int_codec {
+	status = "disabled";
+};
 
-#endif
+&tavil_snd {
+	status = "okay";
+};
+
+&slim_aud {
+	status = "okay";
+};
+
+&dai_slim {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-gpu.dtsi b/arch/arm64/boot/dts/qcom/sdm670-gpu.dtsi
new file mode 100644
index 0000000..89dee0c
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-gpu.dtsi
@@ -0,0 +1,311 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+&soc {
+
+	pil_gpu: qcom,kgsl-hyp {
+		compatible = "qcom,pil-tz-generic";
+		qcom,pas-id = <13>;
+		qcom,firmware-name = "a615_zap";
+	};
+
+	msm_bus: qcom,kgsl-busmon{
+		label = "kgsl-busmon";
+		compatible = "qcom,kgsl-busmon";
+	};
+
+	gpubw: qcom,gpubw {
+		compatible = "qcom,devbw";
+		governor = "bw_vbif";
+		qcom,src-dst-ports = <26 512>;
+		qcom,bw-tbl =
+			<     0 /*  off     */ >,
+			<   381 /*  100  MHz */ >,
+			<   762 /*  200  MHz */ >,
+			<  1144 /*  300  MHz */ >,
+			<  1720 /*  451  MHz */ >,
+			<  2086 /*  547  MHz */ >,
+			<  2597 /*  681  MHz */ >,
+			<  3147 /*  825  MHz */ >,
+			<  3879 /*  1017 MHz */ >,
+			<  5161 /*  1353 MHz */ >,
+			<  5931 /*  1555 MHz */ >,
+			<  6881 /*  1804 MHz */ >;
+	};
+
+	msm_gpu: qcom,kgsl-3d0@5000000 {
+		label = "kgsl-3d0";
+		compatible = "qcom,kgsl-3d0", "qcom,kgsl-3d";
+		status = "ok";
+		reg = <0x5000000 0x40000>;
+		reg-names = "kgsl_3d0_reg_memory";
+		interrupts = <0 300 0>;
+		interrupt-names = "kgsl_3d0_irq";
+		qcom,id = <0>;
+
+		qcom,chipid = <0x06010500>;
+
+		qcom,initial-pwrlevel = <3>;
+
+		qcom,gpu-quirk-hfi-use-reg;
+
+		/* <HZ/12> */
+		qcom,idle-timeout = <80>;
+		qcom,no-nap;
+
+		qcom,highest-bank-bit = <14>;
+
+		qcom,min-access-length = <32>;
+
+		qcom,ubwc-mode = <2>;
+
+		/* size in bytes */
+		qcom,snapshot-size = <1048576>;
+
+		/* base addr, size */
+		qcom,gpu-qdss-stm = <0x161c0000 0x40000>;
+		#cooling-cells = <2>;
+
+		clocks = <&clock_gfx GPU_CC_GX_GFX3D_CLK>,
+			<&clock_gpucc GPU_CC_CXO_CLK>,
+			<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
+			<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
+			<&clock_gpucc GPU_CC_CX_GMU_CLK>,
+			<&clock_gpucc GPU_CC_AHB_CLK>;
+
+		clock-names = "core_clk", "rbbmtimer_clk", "mem_clk",
+				"mem_iface_clk", "gmu_clk", "ahb_clk";
+
+		/* Bus Scale Settings */
+		qcom,gpubw-dev = <&gpubw>;
+		qcom,bus-control;
+		qcom,msm-bus,name = "grp3d";
+		qcom,bus-width = <32>;
+		qcom,msm-bus,num-cases = <12>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+				<26 512 0 0>,
+				<26 512 0 400000>,     /*  1 bus=100  */
+				<26 512 0 800000>,     /*  2 bus=200  */
+				<26 512 0 1200000>,    /*  3 bus=300  */
+				<26 512 0 1804000>,    /*  4 bus=451  */
+				<26 512 0 2188000>,    /*  5 bus=547  */
+				<26 512 0 2724000>,    /*  6 bus=681  */
+				<26 512 0 3300000>,    /*  7 bus=825  */
+				<26 512 0 4068000>,    /*  8 bus=1017 */
+				<26 512 0 5412000>,    /*  9 bus=1353 */
+				<26 512 0 6220000>,    /* 10 bus=1555 */
+				<26 512 0 7216000>;    /* 11 bus=1804 */
+
+		/* GDSC regulator names */
+		regulator-names = "vddcx", "vdd";
+		/* GDSC oxili regulators */
+		vddcx-supply = <&gpu_cx_gdsc>;
+		vdd-supply = <&gpu_gx_gdsc>;
+
+		/* GPU related llc slices */
+		cache-slice-names = "gpu", "gpuhtw";
+		cache-slices = <&llcc 12>, <&llcc 11>;
+
+		/* CPU latency parameter */
+		qcom,pm-qos-active-latency = <660>;
+		qcom,pm-qos-wakeup-latency = <460>;
+
+		/* Enable context aware freq. scaling */
+		qcom,enable-ca-jump;
+		/* Context aware jump busy penalty in us */
+		qcom,ca-busy-penalty = <12000>;
+		/* Context aware jump target power level */
+		qcom,ca-target-pwrlevel = <1>;
+
+		/* GPU Mempools */
+		qcom,gpu-mempools {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "qcom,gpu-mempools";
+
+			/* 4K Page Pool configuration */
+			qcom,gpu-mempool@0 {
+				reg = <0>;
+				qcom,mempool-page-size = <4096>;
+				qcom,mempool-allocate;
+			};
+			/* 8K Page Pool configuration */
+			qcom,gpu-mempool@1 {
+				reg = <1>;
+				qcom,mempool-page-size = <8192>;
+				qcom,mempool-allocate;
+			};
+			/* 64K Page Pool configuration */
+			qcom,gpu-mempool@2 {
+				reg = <2>;
+				qcom,mempool-page-size = <65536>;
+				qcom,mempool-reserved = <256>;
+			};
+			/* 1M Page Pool configuration */
+			qcom,gpu-mempool@3 {
+				reg = <3>;
+				qcom,mempool-page-size = <1048576>;
+				qcom,mempool-reserved = <32>;
+			};
+		};
+
+		/* Power levels */
+		qcom,gpu-pwrlevels {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			compatible = "qcom,gpu-pwrlevels";
+
+			/* SVS_L1 */
+			qcom,gpu-pwrlevel@0 {
+				reg = <0>;
+				qcom,gpu-freq = <430000000>;
+				qcom,bus-freq = <11>;
+				qcom,bus-min = <8>;
+				qcom,bus-max = <11>;
+			};
+
+			/* SVS */
+			qcom,gpu-pwrlevel@1 {
+				reg = <1>;
+				qcom,gpu-freq = <355000000>;
+				qcom,bus-freq = <8>;
+				qcom,bus-min = <5>;
+				qcom,bus-max = <9>;
+			};
+
+			/* LOW SVS */
+			qcom,gpu-pwrlevel@2 {
+				reg = <2>;
+				qcom,gpu-freq = <267000000>;
+				qcom,bus-freq = <6>;
+				qcom,bus-min = <4>;
+				qcom,bus-max = <8>;
+			};
+
+			/* MIN SVS */
+			qcom,gpu-pwrlevel@3 {
+				reg = <3>;
+				qcom,gpu-freq = <180000000>;
+				qcom,bus-freq = <4>;
+				qcom,bus-min = <3>;
+				qcom,bus-max = <4>;
+			};
+
+			/* XO */
+			qcom,gpu-pwrlevel@4 {
+				reg = <4>;
+				qcom,gpu-freq = <0>;
+				qcom,bus-freq = <0>;
+				qcom,bus-min = <0>;
+				qcom,bus-max = <0>;
+			};
+		};
+
+	};
+
+	kgsl_msm_iommu: qcom,kgsl-iommu {
+		compatible = "qcom,kgsl-smmu-v2";
+
+		reg = <0x05040000 0x10000>;
+		qcom,protect = <0x40000 0x10000>;
+		qcom,micro-mmu-control = <0x6000>;
+
+		clocks =<&clock_gcc GCC_GPU_CFG_AHB_CLK>,
+			<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
+			<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>;
+
+		clock-names = "iface_clk", "mem_clk", "mem_iface_clk";
+
+		qcom,secure_align_mask = <0xfff>;
+		qcom,retention;
+		qcom,hyp_secure_alloc;
+
+		gfx3d_user: gfx3d_user {
+			compatible = "qcom,smmu-kgsl-cb";
+			label = "gfx3d_user";
+			iommus = <&kgsl_smmu 0>;
+			qcom,gpu-offset = <0x48000>;
+		};
+
+		gfx3d_secure: gfx3d_secure {
+			compatible = "qcom,smmu-kgsl-cb";
+			iommus = <&kgsl_smmu 2>;
+		};
+	};
+
+	gmu: qcom,gmu {
+		label = "kgsl-gmu";
+		compatible = "qcom,gpu-gmu";
+
+		reg =
+			<0x506a000 0x31000>,
+			<0xb200000 0x300000>,
+			<0xc200000 0x10000>;
+		reg-names =
+			"kgsl_gmu_reg",
+			"kgsl_gmu_pdc_reg",
+			"kgsl_gmu_cpr_reg";
+
+		interrupts = <0 304 0>, <0 305 0>;
+		interrupt-names = "kgsl_hfi_irq", "kgsl_gmu_irq";
+
+		qcom,msm-bus,name = "cnoc";
+		qcom,msm-bus,num-cases = <2>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+			<26 10036 0 0>,      /* CNOC off */
+			<26 10036 0 100>;    /* CNOC on  */
+
+		regulator-names = "vddcx", "vdd";
+		vddcx-supply = <&gpu_cx_gdsc>;
+		vdd-supply = <&gpu_gx_gdsc>;
+
+
+		clocks = <&clock_gpucc GPU_CC_CX_GMU_CLK>,
+				<&clock_gpucc GPU_CC_CXO_CLK>,
+				<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
+				<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
+				<&clock_gpucc GPU_CC_AHB_CLK>;
+
+		clock-names = "gmu_clk", "cxo_clk", "axi_clk",
+				"memnoc_clk", "ahb_clk";
+
+		qcom,gmu-pwrlevels {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			compatible = "qcom,gmu-pwrlevels";
+
+			qcom,gmu-pwrlevel@0 {
+				reg = <0>;
+				qcom,gmu-freq = <200000000>;
+			};
+
+			qcom,gmu-pwrlevel@1 {
+				reg = <1>;
+				qcom,gmu-freq = <0>;
+			};
+		};
+
+		gmu_user: gmu_user {
+			compatible = "qcom,smmu-gmu-user-cb";
+			iommus = <&kgsl_smmu 4>;
+		};
+
+		gmu_kernel: gmu_kernel {
+			compatible = "qcom,smmu-gmu-kernel-cb";
+			iommus = <&kgsl_smmu 5>;
+		};
+	};
+};
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/arch/arm64/boot/dts/qcom/sdm670-int-cdc-usbc-audio-overlay.dtsi
similarity index 61%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to arch/arm64/boot/dts/qcom/sdm670-int-cdc-usbc-audio-overlay.dtsi
index bc1cd9e..df10e7d 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/arch/arm64/boot/dts/qcom/sdm670-int-cdc-usbc-audio-overlay.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,10 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
+#include "sdm670-audio-overlay.dtsi"
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
-
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
-
-#endif
+&int_codec {
+	qcom,msm-mbhc-usbc-audio-supported = <1>;
+	qcom,usbc-analog-en1-gpio = <&wcd_usbc_analog_en1_gpio>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-mtp-overlay.dts
index c8537bc..ac254fd 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-mtp-overlay.dts
+++ b/arch/arm64/boot/dts/qcom/sdm670-mtp-overlay.dts
@@ -20,10 +20,14 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
 #include "sdm670-mtp.dtsi"
+#include "sdm670-audio-overlay.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. SDM670 MTP";
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L MTP";
 	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
 	qcom,msm-id = <336 0x0>;
 	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm670-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-mtp.dts
index 1de40b7..1241a20 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-mtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdm670-mtp.dts
@@ -15,9 +15,13 @@
 
 #include "sdm670.dtsi"
 #include "sdm670-mtp.dtsi"
+#include "sdm670-audio-overlay.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. SDM670 MTP";
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L MTP";
 	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
 	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm670-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm670-mtp.dtsi
index 0cf48a3..466062b 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-mtp.dtsi
@@ -10,6 +10,36 @@
  * GNU General Public License for more details.
  */
 
+#include <dt-bindings/gpio/gpio.h>
+#include "sdm670-pmic-overlay.dtsi"
+#include "sdm670-sde-display.dtsi"
+
+&ufsphy_mem {
+	compatible = "qcom,ufs-phy-qmp-v3";
+
+	vdda-phy-supply = <&pm660l_l1>; /* 0.88v */
+	vdda-pll-supply = <&pm660_l1>; /* 1.2v */
+	vdda-phy-max-microamp = <62900>;
+	vdda-pll-max-microamp = <18300>;
+
+	status = "ok";
+};
+
+&ufshc_mem {
+	vdd-hba-supply = <&ufs_phy_gdsc>;
+	vdd-hba-fixed-regulator;
+	vcc-supply = <&pm660l_l4>;
+	vcc-voltage-level = <2960000 2960000>;
+	vccq2-supply = <&pm660_l8>;
+	vcc-max-microamp = <600000>;
+	vccq2-max-microamp = <600000>;
+
+	qcom,vddp-ref-clk-supply = <&pm660_l1>;
+	qcom,vddp-ref-clk-max-microamp = <100>;
+
+	status = "ok";
+};
+
 &qupv3_se9_2uart {
 	status = "disabled";
 };
@@ -33,3 +63,194 @@
 &qupv3_se6_4uart {
 	status = "disabled";
 };
+
+&sdhc_1 {
+	vdd-supply = <&pm660l_l4>;
+	qcom,vdd-voltage-level = <2960000 2960000>;
+	qcom,vdd-current-level = <200 570000>;
+
+	vdd-io-supply = <&pm660_l8>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-lpm-sup;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <200 325000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc1_clk_on  &sdc1_cmd_on &sdc1_data_on &sdc1_rclk_on>;
+	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off &sdc1_rclk_off>;
+
+	status = "ok";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm660l_l5>;
+	qcom,vdd-voltage-level = <2960000 2960000>;
+	qcom,vdd-current-level = <200 800000>;
+
+	vdd-io-supply = <&pm660l_l2>;
+	qcom,vdd-io-voltage-level = <1800000 2960000>;
+	qcom,vdd-io-current-level = <200 22000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 0 204 0
+			1 &intc 0 0 222 0
+			2 &tlmm 96 0>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&tlmm 96 0x1>;
+
+	status = "ok";
+};
+
+&vendor {
+	mtp_batterydata: qcom,battery-data {
+		qcom,batt-id-range-pct = <15>;
+		#include "fg-gen3-batterydata-itech-3000mah.dtsi"
+		#include "fg-gen3-batterydata-ascent-3450mah.dtsi"
+		#include "fg-gen3-batterydata-demo-6000mah.dtsi"
+	};
+};
+
+&pm660_fg {
+	qcom,battery-data = <&mtp_batterydata>;
+};
+
+&soc {
+	gpio_keys {
+		compatible = "gpio-keys";
+		label = "gpio-keys";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&key_cam_snapshot_default
+			     &key_cam_focus_default
+			     &key_vol_up_default>;
+
+		cam_snapshot {
+			label = "cam_snapshot";
+			gpios = <&tlmm 91 0>;
+			linux,input-type = <1>;
+			linux,code = <766>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+
+		cam_focus {
+			label = "cam_focus";
+			gpios = <&tlmm 92 0>;
+			linux,input-type = <1>;
+			linux,code = <528>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&pm660l_gpios 7 GPIO_ACTIVE_LOW>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+	};
+};
+
+&dsi_dual_nt35597_truly_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_nt35597_truly_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+};
+
+&dsi_nt35597_truly_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "single_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_nt35597_truly_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "single_port";
+	qcom,panel-mode-gpio = <&tlmm 76 0>;
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+};
+
+&dsi_sim_vid {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_vid {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_sim_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_sim_dsc_375_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_sim_dsc_375_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,platform-reset-gpio = <&tlmm 75 0>;
+};
+
+&dsi_dual_nt35597_truly_video {
+	qcom,dsi-display-active;
+};
+
+&pm660l_wled {
+	status = "okay";
+	qcom,led-strings-list = [01 02];
+};
+
+&mdss_mdp {
+	#cooling-cells = <2>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/sdm670-pinctrl.dtsi
index 73df253..177813f 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-pinctrl.dtsi
@@ -1196,6 +1196,20 @@
 			};
 		};
 
+		sdc1_rclk_on: sdc1_rclk_on {
+			config {
+				pins = "sdc1_rclk";
+				bias-pull-down; /* pull down */
+			};
+		};
+
+		sdc1_rclk_off: sdc1_rclk_off {
+			config {
+				pins = "sdc1_rclk";
+				bias-pull-down; /* pull down */
+			};
+		};
+
 		sdc2_clk_on: sdc2_clk_on {
 			config {
 				pins = "sdc2_clk";
@@ -1244,6 +1258,32 @@
 			};
 		};
 
+		sdc2_cd_on: cd_on {
+			mux {
+				pins = "gpio96";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio96";
+				drive-strength = <2>;
+				bias-pull-up;
+			};
+		};
+
+		sdc2_cd_off: cd_off {
+			mux {
+				pins = "gpio96";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio96";
+				drive-strength = <2>;
+				bias-disable;
+			};
+		};
+
 		/* USB C analog configuration */
 		wcd_usbc_analog_en1 {
 			wcd_usbc_analog_en1_idle: wcd_usbc_ana_en1_idle {
@@ -1392,6 +1432,22 @@
 			};
 		};
 
+		wcd_buck_vsel {
+			wcd_buck_vsel_default: wcd_buck_vsel_default{
+				mux {
+					pins = "gpio94";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio94";
+					drive-strength = <8>; /* 8 mA */
+					bias-pull-down; /* pull down */
+					output-high;
+				};
+			};
+		};
+
 		wcd_gnd_mic_swap {
 			wcd_gnd_mic_swap_idle: wcd_gnd_mic_swap_idle {
 				mux {
@@ -1437,5 +1493,145 @@
 				};
 			};
 		};
+
+		/* Pinctrl setting for CAMERA GPIO key */
+		key_cam_snapshot {
+			key_cam_snapshot_default: key_cam_snapshot_default {
+				pins = "gpio91";
+				function = "normal";
+				input-enable;
+				bias-pull-up;
+				power-source = <0>;
+			};
+		};
+
+		key_cam_focus {
+			key_cam_focus_default: key_cam_focus_default {
+				pins = "gpio92";
+				function = "normal";
+				input-enable;
+				bias-pull-up;
+				power-source = <0>;
+			};
+		};
+
+		pmx_sde: pmx_sde {
+			sde_dsi_active: sde_dsi_active {
+				mux {
+					pins = "gpio75", "gpio76";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio75", "gpio76";
+					drive-strength = <8>;   /* 8 mA */
+					bias-disable = <0>;   /* no pull */
+				};
+			};
+			sde_dsi_suspend: sde_dsi_suspend {
+				mux {
+					pins = "gpio75", "gpio76";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio75", "gpio76";
+					drive-strength = <2>;   /* 2 mA */
+					bias-pull-down;         /* PULL DOWN */
+				};
+			};
+		};
+
+		pmx_sde_te {
+			sde_te_active: sde_te_active {
+				mux {
+					pins = "gpio10";
+					function = "mdp_vsync";
+				};
+
+				config {
+					pins = "gpio10";
+					drive-strength = <2>;   /* 2 mA */
+					bias-pull-down;         /* PULL DOWN */
+				};
+			};
+
+			sde_te_suspend: sde_te_suspend {
+				mux {
+					pins = "gpio10";
+					function = "mdp_vsync";
+				};
+
+				config {
+					pins = "gpio10";
+					drive-strength = <2>;   /* 2 mA */
+					bias-pull-down;         /* PULL DOWN */
+				};
+			};
+		};
+
+		sde_dp_aux_active: sde_dp_aux_active {
+			mux {
+				pins = "gpio40", "gpio50";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio40", "gpio50";
+				bias-disable = <0>; /* no pull */
+				drive-strength = <8>;
+			};
+		};
+
+		sde_dp_aux_suspend: sde_dp_aux_suspend {
+			mux {
+				pins = "gpio40", "gpio50";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio40", "gpio50";
+				bias-pull-down;
+				drive-strength = <2>;
+			};
+		};
+
+		sde_dp_usbplug_cc_active: sde_dp_usbplug_cc_active {
+			mux {
+				pins = "gpio38";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio38";
+				bias-disable;
+				drive-strength = <16>;
+			};
+		};
+
+		sde_dp_usbplug_cc_suspend: sde_dp_usbplug_cc_suspend {
+			mux {
+				pins = "gpio38";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio38";
+				bias-pull-down;
+				drive-strength = <2>;
+			};
+		};
+	};
+};
+
+&pm660l_gpios {
+	key_vol_up {
+		key_vol_up_default: key_vol_up_default {
+			pins = "gpio7";
+			function = "normal";
+			input-enable;
+			bias-pull-up;
+			power-source = <0>;
+		};
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp-overlay.dts
new file mode 100644
index 0000000..5b67765
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp-overlay.dts
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
+
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp.dts
new file mode 100644
index 0000000..26f5e78
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-pm660a-cdp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp-overlay.dts
new file mode 100644
index 0000000..1550661
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp-overlay.dts
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp.dts
new file mode 100644
index 0000000..14f48a0
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-pm660a-mtp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 0>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-pmic-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm670-pmic-overlay.dtsi
new file mode 100644
index 0000000..aa6be24
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-pmic-overlay.dtsi
@@ -0,0 +1,381 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+&pm660_0{
+	pm660_charger: qcom,qpnp-smb2 {
+		compatible = "qcom,qpnp-smb2";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		#cooling-cells = <2>;
+
+		qcom,pmic-revid = <&pm660_revid>;
+
+		io-channels = <&pm660_rradc 8>,
+			      <&pm660_rradc 10>,
+			      <&pm660_rradc 3>,
+			      <&pm660_rradc 4>;
+		io-channel-names = "charger_temp",
+				   "charger_temp_max",
+				   "usbin_i",
+				   "usbin_v";
+
+		qcom,wipower-max-uw = <5000000>;
+
+		/* Enable after the qusb_phy0 device node is added */
+		/* dpdm-supply = <&qusb_phy0>; */
+
+		qcom,thermal-mitigation
+				= <3000000 2500000 2000000 1500000
+					1000000 500000>;
+
+		qcom,chgr@1000 {
+			reg = <0x1000 0x100>;
+			interrupts =
+				<0x0 0x10 0x0 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x10 0x1 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x10 0x2 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x10 0x3 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x10 0x4 IRQ_TYPE_EDGE_RISING>;
+
+			interrupt-names = "chg-error",
+					  "chg-state-change",
+					  "step-chg-state-change",
+					  "step-chg-soc-update-fail",
+					  "step-chg-soc-update-request";
+		};
+
+		qcom,otg@1100 {
+			reg = <0x1100 0x100>;
+			interrupts = <0x0 0x11 0x0 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x11 0x1 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x11 0x2 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x11 0x3 IRQ_TYPE_EDGE_BOTH>;
+
+			interrupt-names = "otg-fail",
+					  "otg-overcurrent",
+					  "otg-oc-dis-sw-sts",
+					  "testmode-change-detect";
+		};
+
+		qcom,bat-if@1200 {
+			reg = <0x1200 0x100>;
+			interrupts =
+				<0x0 0x12 0x0 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x12 0x1 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x12 0x5 IRQ_TYPE_EDGE_BOTH>;
+
+			interrupt-names = "bat-temp",
+					  "bat-ocp",
+					  "bat-ov",
+					  "bat-low",
+					  "bat-therm-or-id-missing",
+					  "bat-terminal-missing";
+		};
+
+		qcom,usb-chgpth@1300 {
+			reg = <0x1300 0x100>;
+			interrupts =
+				<0x0 0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x13 0x5 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>;
+
+			interrupt-names = "usbin-collapse",
+					  "usbin-lt-3p6v",
+					  "usbin-uv",
+					  "usbin-ov",
+					  "usbin-plugin",
+					  "usbin-src-change",
+					  "usbin-icl-change",
+					  "type-c-change";
+		};
+
+		qcom,dc-chgpth@1400 {
+			reg = <0x1400 0x100>;
+			interrupts =
+				<0x0 0x14 0x0 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x14 0x6 IRQ_TYPE_EDGE_RISING>;
+
+			interrupt-names = "dcin-collapse",
+					  "dcin-lt-3p6v",
+					  "dcin-uv",
+					  "dcin-ov",
+					  "dcin-plugin",
+					  "div2-en-dg",
+					  "dcin-icl-change";
+		};
+
+		qcom,chgr-misc@1600 {
+			reg = <0x1600 0x100>;
+			interrupts =
+				<0x0 0x16 0x0 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
+				<0x0 0x16 0x2 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x16 0x3 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x16 0x4 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x16 0x5 IRQ_TYPE_EDGE_BOTH>,
+				<0x0 0x16 0x6 IRQ_TYPE_EDGE_FALLING>,
+				<0x0 0x16 0x7 IRQ_TYPE_EDGE_BOTH>;
+
+			interrupt-names = "wdog-snarl",
+					  "wdog-bark",
+					  "aicl-fail",
+					  "aicl-done",
+					  "high-duty-cycle",
+					  "input-current-limiting",
+					  "temperature-change",
+					  "switcher-power-ok";
+		};
+		smb2_vbus: qcom,smb2-vbus {
+			regulator-name = "smb2-vbus";
+		};
+
+		smb2_vconn: qcom,smb2-vconn {
+			regulator-name = "smb2-vconn";
+		};
+	};
+
+	pm660_rradc: rradc@4500 {
+		compatible = "qcom,rradc";
+		reg = <0x4500 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		#io-channel-cells = <1>;
+		qcom,pmic-revid = <&pm660_revid>;
+	};
+
+	pm660_fg: qpnp,fg {
+		compatible = "qcom,fg-gen3";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		qcom,pmic-revid = <&pm660_revid>;
+		io-channels = <&pm660_rradc 0>,
+			      <&pm660_rradc 7>;
+		io-channel-names = "rradc_batt_id",
+				   "rradc_die_temp";
+		qcom,rradc-base = <0x4500>;
+		qcom,fg-esr-timer-awake = <96 96>;
+		qcom,fg-esr-timer-asleep = <256 256>;
+		qcom,fg-esr-timer-charging = <0 96>;
+		qcom,cycle-counter-en;
+		status = "okay";
+
+		qcom,fg-batt-soc@4000 {
+			status = "okay";
+			reg = <0x4000 0x100>;
+			interrupts = <0x0 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x40 0x2
+						IRQ_TYPE_EDGE_RISING>,
+				     <0x0 0x40 0x3
+						IRQ_TYPE_EDGE_RISING>,
+				     <0x0 0x40 0x4 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x40 0x5
+						IRQ_TYPE_EDGE_RISING>,
+				     <0x0 0x40 0x6 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x40 0x7 IRQ_TYPE_EDGE_BOTH>;
+			interrupt-names = "soc-update",
+					  "soc-ready",
+					  "bsoc-delta",
+					  "msoc-delta",
+					  "msoc-low",
+					  "msoc-empty",
+					  "msoc-high",
+					  "msoc-full";
+		};
+
+		qcom,fg-batt-info@4100 {
+			status = "okay";
+			reg = <0x4100 0x100>;
+			interrupts = <0x0 0x41 0x0 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x41 0x1 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x41 0x2 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x41 0x3 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x41 0x6 IRQ_TYPE_EDGE_BOTH>;
+			interrupt-names = "vbatt-pred-delta",
+					  "vbatt-low",
+					  "esr-delta",
+					  "batt-missing",
+					  "batt-temp-delta";
+		};
+
+		qcom,fg-memif@4400 {
+			status = "okay";
+			reg = <0x4400 0x100>;
+			interrupts = <0x0 0x44 0x0 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x44 0x1 IRQ_TYPE_EDGE_BOTH>,
+				     <0x0 0x44 0x2 IRQ_TYPE_EDGE_BOTH>;
+			interrupt-names = "ima-rdy",
+					  "mem-xcp",
+					  "dma-grant";
+		};
+	};
+};
+
+&pm660_1 {
+	pm660_haptics: qcom,haptics@c000 {
+		compatible = "qcom,qpnp-haptics";
+		reg = <0xc000 0x100>;
+		interrupts = <0x1 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
+			     <0x1 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
+		interrupt-names = "hap-sc-irq", "hap-play-irq";
+		qcom,pmic-revid = <&pm660_revid>;
+		qcom,pmic-misc = <&pm660_misc>;
+		qcom,misc-clk-trim-error-reg = <0xf3>;
+		qcom,actuator-type = <0>;
+		qcom,play-mode = "direct";
+		qcom,vmax-mv = <3200>;
+		qcom,ilim-ma = <800>;
+		qcom,sc-dbc-cycles = <8>;
+		qcom,wave-play-rate-us = <6667>;
+		qcom,en-brake;
+		qcom,lra-high-z = "opt0";
+		qcom,lra-auto-res-mode = "qwd";
+		qcom,lra-res-cal-period = <4>;
+	};
+};
+
+&pm660l_3 {
+	pm660l_wled: qcom,leds@d800 {
+		compatible = "qcom,qpnp-wled";
+		reg = <0xd800 0x100>,
+			<0xd900 0x100>;
+		reg-names = "qpnp-wled-ctrl-base",
+				"qpnp-wled-sink-base";
+		interrupts = <0x3 0xd8 0x1 IRQ_TYPE_EDGE_RISING>;
+		interrupt-names = "ovp-irq";
+		linux,name = "wled";
+		linux,default-trigger = "bkl-trigger";
+		qcom,fdbk-output = "auto";
+		qcom,vref-uv = <127500>;
+		qcom,switch-freq-khz = <800>;
+		qcom,ovp-mv = <29600>;
+		qcom,ilim-ma = <970>;
+		qcom,boost-duty-ns = <26>;
+		qcom,mod-freq-khz = <9600>;
+		qcom,dim-mode = "hybrid";
+		qcom,hyb-thres = <625>;
+		qcom,sync-dly-us = <800>;
+		qcom,fs-curr-ua = <25000>;
+		qcom,cons-sync-write-delay-us = <1000>;
+		qcom,led-strings-list = [00 01 02];
+		qcom,loop-auto-gm-en;
+		qcom,pmic-revid = <&pm660l_revid>;
+		qcom,auto-calibration-enable;
+		status = "ok";
+	};
+
+	pm660l_lcdb: qpnp-lcdb@ec00 {
+		compatible = "qcom,qpnp-lcdb-regulator";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0xec00 0x100>;
+		interrupts = <0x3 0xec 0x1 IRQ_TYPE_EDGE_RISING>;
+		interrupt-names = "sc-irq";
+
+		qcom,pmic-revid = <&pm660l_revid>;
+
+		lcdb_ldo_vreg: ldo {
+			label = "ldo";
+			regulator-name = "lcdb_ldo";
+			regulator-min-microvolt = <4000000>;
+			regulator-max-microvolt = <6000000>;
+		};
+
+		lcdb_ncp_vreg: ncp {
+			label = "ncp";
+			regulator-name = "lcdb_ncp";
+			regulator-min-microvolt = <4000000>;
+			regulator-max-microvolt = <6000000>;
+		};
+	};
+
+	pm660a_oledb: qpnp-oledb@e000 {
+	       compatible = "qcom,qpnp-oledb-regulator";
+	       #address-cells = <1>;
+	       #size-cells = <1>;
+	       qcom,pmic-revid = <&pm660l_revid>;
+	       reg = <0xe000 0x100>;
+	       qcom,pbs-client = <&pm660l_pbs>;
+
+	       label = "oledb";
+	       regulator-name = "regulator-oledb";
+	       regulator-min-microvolt = <5000000>;
+	       regulator-max-microvolt = <8100000>;
+
+	       qcom,swire-control;
+	       qcom,ext-pin-control;
+	       status = "disabled";
+	};
+
+	pm660a_labibb: qpnp-labibb-regulator {
+		compatible = "qcom,qpnp-labibb-regulator";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		qcom,pmic-revid = <&pm660l_revid>;
+		qcom,swire-control;
+		status = "disabled";
+
+		ibb_regulator: qcom,ibb@dc00 {
+			reg = <0xdc00 0x100>;
+			reg-names = "ibb_reg";
+			regulator-name = "ibb_reg";
+
+			regulator-min-microvolt = <4000000>;
+			regulator-max-microvolt = <6300000>;
+
+			qcom,qpnp-ibb-min-voltage = <1400000>;
+			qcom,qpnp-ibb-step-size = <100000>;
+			qcom,qpnp-ibb-slew-rate = <2000000>;
+			qcom,qpnp-ibb-init-voltage = <4000000>;
+			qcom,qpnp-ibb-init-amoled-voltage = <4000000>;
+		};
+
+		lab_regulator: qcom,lab@de00 {
+			reg = <0xde00 0x100>;
+			reg-names = "lab";
+			regulator-name = "lab_reg";
+
+			regulator-min-microvolt = <4600000>;
+			regulator-max-microvolt = <6100000>;
+
+			qcom,qpnp-lab-min-voltage = <4600000>;
+			qcom,qpnp-lab-step-size = <100000>;
+			qcom,qpnp-lab-slew-rate = <5000>;
+			qcom,qpnp-lab-init-voltage = <4600000>;
+			qcom,qpnp-lab-init-amoled-voltage = <4600000>;
+
+			qcom,notify-lab-vreg-ok-sts;
+		};
+	};
+};
+
+&pm660_pdphy {
+	vbus-supply = <&smb2_vbus>;
+	vconn-supply = <&smb2_vconn>;
+};
+
+&usb0 {
+	extcon = <&pm660_pdphy>, <&pm660_pdphy>, <0> /* <&eud> */;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm670-regulator.dtsi
index 0a8c49f..24b8dd6 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-regulator.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-regulator.dtsi
@@ -96,6 +96,14 @@
 			regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
 			regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
 		};
+
+		mx_cdev: mx-cdev-lvl {
+			compatible = "qcom,regulator-cooling-device";
+			regulator-cdev-supply = <&pm660l_s1_level>;
+			regulator-levels = <RPMH_REGULATOR_LEVEL_NOM
+					RPMH_REGULATOR_LEVEL_OFF>;
+			#cooling-cells = <2>;
+		};
 	};
 
 	/* pm660l S2 - VDD_GFX supply */
@@ -137,6 +145,13 @@
 			regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
 			qcom,min-dropout-voltage-level = <(-1)>;
 		};
+
+		cx_cdev: regulator-cdev {
+			compatible = "qcom,rpmh-reg-cdev";
+			mboxes = <&qmp_aop 0>;
+			qcom,reg-resource-name = "cx";
+			#cooling-cells = <2>;
+		};
 	};
 
 	rpmh-regulator-ldoa1 {
@@ -627,14 +642,14 @@
 			qcom,init-voltage = <3312000>;
 		};
 	};
-};
 
-&pm660_charger {
-	smb2_vbus: qcom,smb2-vbus {
-		regulator-name = "smb2-vbus";
-	};
-
-	smb2_vconn: qcom,smb2-vconn {
-		regulator-name = "smb2-vconn";
+	refgen: refgen-regulator@ff1000 {
+		compatible = "qcom,refgen-regulator";
+		reg = <0xff1000 0x60>;
+		regulator-name = "refgen";
+		regulator-enable-ramp-delay = <5>;
+		proxy-supply = <&refgen>;
+		qcom,proxy-consumer-enable;
+		regulator-always-on;
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm670-rumi-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-rumi-overlay.dts
new file mode 100644
index 0000000..4a24d87
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-rumi-overlay.dts
@@ -0,0 +1,30 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "sdm670-rumi.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 RUMI";
+	compatible = "qcom,sdm670-rumi", "qcom,sdm670", "qcom,rumi";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <15 0>;
+};
+
+&soc {
+	wdog: qcom,wdt@17980000{
+		status = "disabled";
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-rumi.dts b/arch/arm64/boot/dts/qcom/sdm670-rumi.dts
index 6201488..e137705 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-rumi.dts
+++ b/arch/arm64/boot/dts/qcom/sdm670-rumi.dts
@@ -16,6 +16,7 @@
 
 #include "sdm670.dtsi"
 #include "sdm670-rumi.dtsi"
+#include "sdm670-audio-overlay.dtsi"
 / {
 	model = "Qualcomm Technologies, Inc. SDM670 RUMI";
 	compatible = "qcom,sdm670-rumi", "qcom,sdm670", "qcom,rumi";
diff --git a/arch/arm64/boot/dts/qcom/sdm670-rumi.dtsi b/arch/arm64/boot/dts/qcom/sdm670-rumi.dtsi
index f2f41fd..a50d9b6 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-rumi.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-rumi.dtsi
@@ -10,18 +10,50 @@
  * GNU General Public License for more details.
  */
 
-/{
-	aliases {
-		serial0 = &qupv3_se10_2uart;
-		serial1 = &qupv3_se9_2uart;
-		spi0 = &qupv3_se8_spi;
-		i2c0 = &qupv3_se10_i2c;
-		i2c1 = &qupv3_se3_i2c;
-		hsuart0 = &qupv3_se6_4uart;
-	};
+#include "sdm670-pmic-overlay.dtsi"
 
+&soc {
+	/* Delete all regulators */
+	/delete-node/ rpmh-regulator-smpa4;
+	/delete-node/ rpmh-regulator-smpa6;
+	/delete-node/ rpmh-regulator-mxlvl;
+	/delete-node/ rpmh-regulator-modemlvl;
+	/delete-node/ rpmh-regulator-cxlvl;
+	/delete-node/ rpmh-regulator-ldoa1;
+	/delete-node/ rpmh-regulator-ldoa2;
+	/delete-node/ rpmh-regulator-ldoa3;
+	/delete-node/ rpmh-regulator-ldoa5;
+	/delete-node/ rpmh-regulator-ldoa6;
+	/delete-node/ rpmh-regulator-ldoa7;
+	/delete-node/ rpmh-regulator-ldoa8;
+	/delete-node/ rpmh-regulator-ldoa9;
+	/delete-node/ rpmh-regulator-ldoa10;
+	/delete-node/ rpmh-regulator-ldoa11;
+	/delete-node/ rpmh-regulator-ldoa12;
+	/delete-node/ rpmh-regulator-ldoa13;
+	/delete-node/ rpmh-regulator-ldoa14;
+	/delete-node/ rpmh-regulator-ldoa15;
+	/delete-node/ rpmh-regulator-ldoa16;
+	/delete-node/ rpmh-regulator-ldoa17;
+	/delete-node/ rpmh-regulator-ldoa19;
+	/delete-node/ rpmh-regulator-ldob1;
+	/delete-node/ rpmh-regulator-ldob2;
+	/delete-node/ rpmh-regulator-ldob3;
+	/delete-node/ rpmh-regulator-ldob4;
+	/delete-node/ rpmh-regulator-ldob5;
+	/delete-node/ rpmh-regulator-ldob6;
+	/delete-node/ rpmh-regulator-ldob7;
+	/delete-node/ rpmh-regulator-ldob8;
+	/delete-node/ rpmh-regulator-lcxlvl;
+	/delete-node/ rpmh-regulator-lmxlvl;
+	/delete-node/ rpmh-regulator-ldoa28;
+	/delete-node/ rpmh-regulator-bobb1;
+	/delete-node/ rpmh-regulator-gfxlvl;
+	/delete-node/ thermal-zones;
 };
 
+#include "sdm670-stub-regulator.dtsi"
+
 &qupv3_se9_2uart {
 	status = "disabled";
 };
@@ -96,5 +128,91 @@
 	qcom,clk-rates = <400000 20000000 25000000 50000000>;
 	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
 
+	/delete-property/qcom,devfreq,freq-table;
+
 	status = "ok";
 };
+
+&sdhc_2 {
+	vdd-supply = <&pm660l_l5>;
+	qcom,vdd-voltage-level = <2960000 2960000>;
+	qcom,vdd-current-level = <200 800000>;
+
+	vdd-io-supply = <&pm660l_l2>;
+	qcom,vdd-io-voltage-level = <1800000 2960000>;
+	qcom,vdd-io-current-level = <200 22000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
+
+	qcom,clk-rates = <400000 20000000 25000000 50000000>;
+	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50";
+
+	/delete-property/qcom,devfreq,freq-table;
+
+	status = "ok";
+};
+
+&usb0 {
+	/delete-property/ qcom,usb-dbm;
+	/delete-property/ extcon;
+	qcom,charging-disabled;
+	dwc3@a600000 {
+		maximum-speed = "high-speed";
+		usb-phy = <&qusb_phy0>, <&usb_nop_phy>;
+	};
+};
+
+&qusb_phy0 {
+	reg = <0x088e2000 0x4>,
+		<0x0a720000 0x9500>;
+	reg-names = "qusb_phy_base",
+		"emu_phy_base";
+	qcom,emulation;
+	qcom,emu-init-seq = <0x19 0x1404
+				0x20 0x1414
+				0x79 0x1410
+				0x00 0x1418
+				0x99 0x1404
+				0x04 0x1408
+				0xd9 0x1404>;
+
+	qcom,emu-dcm-reset-seq = <0x5 0x14      /* 0x1 0x14 for E1.2 */
+				0x100000 0x20
+				0x0 0x20
+				0x1a0 0x20    /* 0x220 0x20 for E1.2 */
+				0x80 0x28>;
+};
+
+&usb_qmp_dp_phy {
+	status = "disabled";
+};
+
+&mdss_mdp {
+	status = "disabled";
+};
+
+&sde_rscc {
+	status = "disabled";
+};
+
+&mdss_rotator {
+	status = "disabled";
+};
+
+&mdss_dsi0 {
+	status = "disabled";
+};
+
+&mdss_dsi1 {
+	status = "disabled";
+};
+
+&mdss_dsi_phy0 {
+	status = "disabled";
+};
+
+&mdss_dsi_phy1 {
+	status = "disabled";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-sde-display.dtsi b/arch/arm64/boot/dts/qcom/sdm670-sde-display.dtsi
new file mode 100644
index 0000000..3e9d967
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-sde-display.dtsi
@@ -0,0 +1,597 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "dsi-panel-sim-video.dtsi"
+#include "dsi-panel-sim-cmd.dtsi"
+#include "dsi-panel-sim-dsc375-cmd.dtsi"
+#include "dsi-panel-sim-dualmipi-video.dtsi"
+#include "dsi-panel-sim-dualmipi-cmd.dtsi"
+#include "dsi-panel-sim-dualmipi-dsc375-cmd.dtsi"
+#include "dsi-panel-nt35597-truly-dualmipi-wqxga-video.dtsi"
+#include "dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi"
+#include "dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi"
+#include "dsi-panel-nt35597-truly-dsc-wqxga-video.dtsi"
+#include <dt-bindings/clock/mdss-10nm-pll-clk.h>
+
+&soc {
+	dsi_panel_pwr_supply: dsi_panel_pwr_supply {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,panel-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "vddio";
+			qcom,supply-min-voltage = <1800000>;
+			qcom,supply-max-voltage = <1800000>;
+			qcom,supply-enable-load = <62000>;
+			qcom,supply-disable-load = <80>;
+			qcom,supply-post-on-sleep = <20>;
+		};
+
+		qcom,panel-supply-entry@1 {
+			reg = <1>;
+			qcom,supply-name = "lab";
+			qcom,supply-min-voltage = <4600000>;
+			qcom,supply-max-voltage = <6000000>;
+			qcom,supply-enable-load = <100000>;
+			qcom,supply-disable-load = <100>;
+		};
+
+		qcom,panel-supply-entry@2 {
+			reg = <2>;
+			qcom,supply-name = "ibb";
+			qcom,supply-min-voltage = <4600000>;
+			qcom,supply-max-voltage = <6000000>;
+			qcom,supply-enable-load = <100000>;
+			qcom,supply-disable-load = <100>;
+			qcom,supply-post-on-sleep = <20>;
+		};
+	};
+
+	dsi_panel_pwr_supply_no_labibb: dsi_panel_pwr_supply_no_labibb {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,panel-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "vddio";
+			qcom,supply-min-voltage = <1800000>;
+			qcom,supply-max-voltage = <1800000>;
+			qcom,supply-enable-load = <62000>;
+			qcom,supply-disable-load = <80>;
+			qcom,supply-post-on-sleep = <20>;
+		};
+	};
+
+	dsi_panel_pwr_supply_vdd_no_labibb: dsi_panel_pwr_supply_vdd_no_labibb {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,panel-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "vddio";
+			qcom,supply-min-voltage = <1800000>;
+			qcom,supply-max-voltage = <1800000>;
+			qcom,supply-enable-load = <62000>;
+			qcom,supply-disable-load = <80>;
+			qcom,supply-post-on-sleep = <20>;
+		};
+
+		qcom,panel-supply-entry@1 {
+			reg = <1>;
+			qcom,supply-name = "vdd";
+			qcom,supply-min-voltage = <3000000>;
+			qcom,supply-max-voltage = <3000000>;
+			qcom,supply-enable-load = <857000>;
+			qcom,supply-disable-load = <0>;
+			qcom,supply-post-on-sleep = <0>;
+		};
+	};
+
+	dsi_dual_nt35597_truly_video_display: qcom,dsi-display@0 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_dual_nt35597_truly_video_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0 &mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy0 &mdss_dsi_phy1>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+		qcom,platform-reset-gpio = <&tlmm 75 0>;
+		qcom,panel-mode-gpio = <&tlmm 76 0>;
+
+		qcom,dsi-panel = <&dsi_dual_nt35597_truly_video>;
+		vddio-supply = <&pm660_l11>;
+		lab-supply = <&lcdb_ldo_vreg>;
+		ibb-supply = <&lcdb_ncp_vreg>;
+	};
+
+	dsi_dual_nt35597_truly_cmd_display: qcom,dsi-display@1 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_dual_nt35597_truly_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0 &mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy0 &mdss_dsi_phy1>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+		qcom,platform-te-gpio = <&tlmm 10 0>;
+		qcom,platform-reset-gpio = <&tlmm 75 0>;
+		qcom,panel-mode-gpio = <&tlmm 76 0>;
+
+		qcom,dsi-panel = <&dsi_dual_nt35597_truly_cmd>;
+		vddio-supply = <&pm660_l11>;
+		lab-supply = <&lcdb_ldo_vreg>;
+		ibb-supply = <&lcdb_ncp_vreg>;
+	};
+
+	dsi_nt35597_truly_dsc_cmd_display: qcom,dsi-display@2 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_nt35597_truly_dsc_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy1>;
+		clocks = <&mdss_dsi1_pll BYTECLK_MUX_1_CLK>,
+			<&mdss_dsi1_pll PCLK_MUX_1_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+		qcom,platform-te-gpio = <&tlmm 10 0>;
+		qcom,platform-reset-gpio = <&tlmm 75 0>;
+		qcom,panel-mode-gpio = <&tlmm 76 0>;
+
+		qcom,dsi-panel = <&dsi_nt35597_truly_dsc_cmd>;
+		vddio-supply = <&pm660_l11>;
+		lab-supply = <&lcdb_ldo_vreg>;
+		ibb-supply = <&lcdb_ncp_vreg>;
+	};
+
+	dsi_nt35597_truly_dsc_video_display: qcom,dsi-display@3 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_nt35597_truly_dsc_video_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy1>;
+		clocks = <&mdss_dsi1_pll BYTECLK_MUX_1_CLK>,
+			<&mdss_dsi1_pll PCLK_MUX_1_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+		qcom,platform-te-gpio = <&tlmm 10 0>;
+		qcom,platform-reset-gpio = <&tlmm 75 0>;
+		qcom,panel-mode-gpio = <&tlmm 76 0>;
+
+		qcom,dsi-panel = <&dsi_nt35597_truly_dsc_video>;
+		vddio-supply = <&pm660_l11>;
+		lab-supply = <&lcdb_ldo_vreg>;
+		ibb-supply = <&lcdb_ncp_vreg>;
+	};
+
+	dsi_sim_vid_display: qcom,dsi-display@4 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_sim_vid_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0>;
+		qcom,dsi-phy = <&mdss_dsi_phy0>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_sim_vid>;
+	};
+
+	dsi_dual_sim_vid_display: qcom,dsi-display@5 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_dual_sim_vid_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0 &mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy0 &mdss_dsi_phy1>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_dual_sim_vid>;
+	};
+
+	dsi_sim_cmd_display: qcom,dsi-display@6 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_sim_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0>;
+		qcom,dsi-phy = <&mdss_dsi_phy0>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_sim_cmd>;
+	};
+
+	dsi_dual_sim_cmd_display: qcom,dsi-display@7 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_dual_sim_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0 &mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy0 &mdss_dsi_phy1>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_dual_sim_cmd>;
+	};
+
+	dsi_sim_dsc_375_cmd_display: qcom,dsi-display@8 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_sim_dsc_375_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0>;
+		qcom,dsi-phy = <&mdss_dsi_phy0>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_sim_dsc_375_cmd>;
+	};
+
+	dsi_dual_sim_dsc_375_cmd_display: qcom,dsi-display@9 {
+		compatible = "qcom,dsi-display";
+		label = "dsi_dual_sim_dsc_375_cmd_display";
+		qcom,display-type = "primary";
+
+		qcom,dsi-ctrl = <&mdss_dsi0 &mdss_dsi1>;
+		qcom,dsi-phy = <&mdss_dsi_phy0 &mdss_dsi_phy1>;
+		clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+			<&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+		clock-names = "src_byte_clk", "src_pixel_clk";
+
+		pinctrl-names = "panel_active", "panel_suspend";
+		pinctrl-0 = <&sde_dsi_active &sde_te_active>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend>;
+
+		qcom,dsi-panel = <&dsi_dual_sim_dsc_375_cmd>;
+	};
+
+	sde_wb: qcom,wb-display@0 {
+		compatible = "qcom,wb-display";
+		cell-index = <0>;
+		label = "wb_display";
+	};
+
+	ext_disp: qcom,msm-ext-disp {
+		compatible = "qcom,msm-ext-disp";
+		status = "disabled";
+
+		ext_disp_audio_codec: qcom,msm-ext-disp-audio-codec-rx {
+			compatible = "qcom,msm-ext-disp-audio-codec-rx";
+		};
+	};
+
+	sde_dp: qcom,dp_display@0{
+		cell-index = <0>;
+		compatible = "qcom,dp-display";
+		status = "disabled";
+
+		gdsc-supply = <&mdss_core_gdsc>;
+		vdda-1p2-supply = <&pm660_l1>;
+		vdda-0p9-supply = <&pm660l_l1>;
+
+		reg =	<0xae90000 0xa84>,
+			<0x88eaa00 0x200>,
+			<0x88ea200 0x200>,
+			<0x88ea600 0x200>,
+			<0xaf02000 0x1a0>,
+			<0x780000 0x621c>,
+			<0x88ea030 0x10>,
+			<0x0aee1000 0x034>;
+		reg-names = "dp_ctrl", "dp_phy", "dp_ln_tx0", "dp_ln_tx1",
+			"dp_mmss_cc", "qfprom_physical", "dp_pll",
+			"hdcp_physical";
+
+		interrupt-parent = <&mdss_mdp>;
+		interrupts = <12 0>;
+
+		clocks =  <&clock_dispcc DISP_CC_MDSS_DP_AUX_CLK>,
+			 <&clock_rpmh RPMH_CXO_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_CLKREF_CLK>,
+			 <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_PHY_PIPE_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_INTF_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_CRYPTO_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK_SRC>,
+			 <&mdss_dp_pll DP_VCO_DIVIDED_CLK_SRC_MUX>;
+		clock-names = "core_aux_clk", "core_usb_ref_clk_src",
+			"core_usb_ref_clk", "core_usb_cfg_ahb_clk",
+			"core_usb_pipe_clk", "ctrl_link_clk",
+			"ctrl_link_iface_clk", "ctrl_pixel_clk",
+			"crypto_clk", "pixel_clk_rcg", "pixel_parent";
+
+		qcom,dp-usbpd-detection = <&pm660_pdphy>;
+		qcom,ext-disp = <&ext_disp>;
+
+		qcom,aux-cfg0-settings = [20 00];
+		qcom,aux-cfg1-settings = [24 13 23 1d];
+		qcom,aux-cfg2-settings = [28 24];
+		qcom,aux-cfg3-settings = [2c 00];
+		qcom,aux-cfg4-settings = [30 0a];
+		qcom,aux-cfg5-settings = [34 26];
+		qcom,aux-cfg6-settings = [38 0a];
+		qcom,aux-cfg7-settings = [3c 03];
+		qcom,aux-cfg8-settings = [40 bb];
+		qcom,aux-cfg9-settings = [44 03];
+
+		qcom,max-pclk-frequency-khz = <675000>;
+
+		qcom,core-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,core-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "gdsc";
+				qcom,supply-min-voltage = <0>;
+				qcom,supply-max-voltage = <0>;
+				qcom,supply-enable-load = <0>;
+				qcom,supply-disable-load = <0>;
+			};
+		};
+
+		qcom,ctrl-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,ctrl-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-1p2";
+				qcom,supply-min-voltage = <1200000>;
+				qcom,supply-max-voltage = <1200000>;
+				qcom,supply-enable-load = <21800>;
+				qcom,supply-disable-load = <4>;
+			};
+		};
+
+		qcom,phy-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,phy-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-0p9";
+				qcom,supply-min-voltage = <880000>;
+				qcom,supply-max-voltage = <880000>;
+				qcom,supply-enable-load = <36000>;
+				qcom,supply-disable-load = <32>;
+			};
+		};
+	};
+};
+
+&sde_dp {
+	status = "disabled";
+	pinctrl-names = "mdss_dp_active", "mdss_dp_sleep";
+	pinctrl-0 = <&sde_dp_aux_active &sde_dp_usbplug_cc_active>;
+	pinctrl-1 = <&sde_dp_aux_suspend &sde_dp_usbplug_cc_suspend>;
+	qcom,aux-en-gpio = <&tlmm 50 0>;
+	qcom,aux-sel-gpio = <&tlmm 40 0>;
+	qcom,usbplug-cc-gpio = <&tlmm 38 0>;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb>;
+};
+
+&dsi_dual_nt35597_truly_video {
+	qcom,mdss-dsi-t-clk-post = <0x0D>;
+	qcom,mdss-dsi-t-clk-pre = <0x2D>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <2 0 2>,
+						<1 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_dual_nt35597_truly_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0D>;
+	qcom,mdss-dsi-t-clk-pre = <0x2D>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <2 0 2>,
+						<1 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_nt35597_truly_dsc_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0b>;
+	qcom,mdss-dsi-t-clk-pre = <0x23>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 15 05 05 20 1f 05
+				05 03 03 04 00];
+			qcom,display-topology = <1 1 1>,
+						<2 2 1>, /* dsc merge */
+						<2 1 1>; /* 3d mux */
+			qcom,default-topology-index = <1>;
+		};
+	};
+};
+
+&dsi_nt35597_truly_dsc_video {
+	qcom,mdss-dsi-t-clk-post = <0x0b>;
+	qcom,mdss-dsi-t-clk-pre = <0x23>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 15 05 05 20 1f 05
+				04 03 03 04 00];
+			qcom,display-topology = <1 1 1>,
+						<2 2 1>, /* dsc merge */
+						<2 1 1>; /* 3d mux */
+			qcom,default-topology-index = <1>;
+		};
+	};
+};
+
+&dsi_sim_vid {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <1 0 1>,
+						<2 0 1>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_dual_sim_vid {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <2 0 2>,
+						<1 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_sim_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <1 0 1>,
+						<2 0 1>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_dual_sim_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0{
+			qcom,mdss-dsi-panel-phy-timings = [00 24 09 09 26 24 09
+				09 06 03 04 00];
+			qcom,display-topology = <2 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+		timing@1{
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <2 0 2>,
+						<1 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+		timing@2{
+			qcom,mdss-dsi-panel-phy-timings = [00 18 06 06 21 20 06
+				06 04 03 04 00];
+			qcom,display-topology = <2 0 2>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_sim_dsc_375_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0 { /* 1080p */
+			qcom,mdss-dsi-panel-phy-timings = [00 1A 06 06 22 20 07
+				07 04 03 04 00];
+			qcom,display-topology = <1 1 1>;
+			qcom,default-topology-index = <0>;
+		};
+		timing@1 { /* qhd */
+			qcom,mdss-dsi-panel-phy-timings = [00 15 05 05 20 1f 05
+				05 03 03 04 00];
+			qcom,display-topology = <1 1 1>,
+						<2 2 1>, /* dsc merge */
+						<2 1 1>; /* 3d mux */
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
+
+&dsi_dual_sim_dsc_375_cmd {
+	qcom,mdss-dsi-t-clk-post = <0x0d>;
+	qcom,mdss-dsi-t-clk-pre = <0x2d>;
+	qcom,mdss-dsi-display-timings {
+		timing@0 { /* qhd */
+			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
+				07 05 03 04 00];
+			qcom,display-topology = <2 2 2>;
+			qcom,default-topology-index = <0>;
+		};
+		timing@1 { /* 4k */
+			qcom,mdss-dsi-panel-phy-timings = [00 18 06 06 21 20 06
+				06 04 03 04 00];
+			qcom,display-topology = <2 2 2>;
+			qcom,default-topology-index = <0>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-sde-pll.dtsi b/arch/arm64/boot/dts/qcom/sdm670-sde-pll.dtsi
new file mode 100644
index 0000000..78e5d94
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-sde-pll.dtsi
@@ -0,0 +1,110 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+&soc {
+	mdss_dsi0_pll: qcom,mdss_dsi_pll@ae94a00 {
+		compatible = "qcom,mdss_dsi_pll_10nm";
+		label = "MDSS DSI 0 PLL";
+		cell-index = <0>;
+		#clock-cells = <1>;
+		reg = <0xae94a00 0x1e0>,
+		      <0xae94400 0x800>,
+		      <0xaf03000 0x8>;
+		reg-names = "pll_base", "phy_base", "gdsc_base";
+		clocks = <&clock_dispcc DISP_CC_MDSS_AHB_CLK>;
+		clock-names = "iface_clk";
+		clock-rate = <0>;
+		gdsc-supply = <&mdss_core_gdsc>;
+		qcom,platform-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			qcom,platform-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "gdsc";
+				qcom,supply-min-voltage = <0>;
+				qcom,supply-max-voltage = <0>;
+				qcom,supply-enable-load = <0>;
+				qcom,supply-disable-load = <0>;
+			};
+		};
+	};
+
+	mdss_dsi1_pll: qcom,mdss_dsi_pll@ae96a00 {
+		compatible = "qcom,mdss_dsi_pll_10nm";
+		label = "MDSS DSI 1 PLL";
+		cell-index = <1>;
+		#clock-cells = <1>;
+		reg = <0xae96a00 0x1e0>,
+		      <0xae96400 0x800>,
+		      <0xaf03000 0x8>;
+		reg-names = "pll_base", "phy_base", "gdsc_base";
+		clocks = <&clock_dispcc DISP_CC_MDSS_AHB_CLK>;
+		clock-names = "iface_clk";
+		clock-rate = <0>;
+		gdsc-supply = <&mdss_core_gdsc>;
+		qcom,platform-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			qcom,platform-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "gdsc";
+				qcom,supply-min-voltage = <0>;
+				qcom,supply-max-voltage = <0>;
+				qcom,supply-enable-load = <0>;
+				qcom,supply-disable-load = <0>;
+			};
+		};
+	};
+
+	mdss_dp_pll: qcom,mdss_dp_pll@88ea000 {
+		compatible = "qcom,mdss_dp_pll_10nm";
+		status = "disabled";
+		label = "MDSS DP PLL";
+		cell-index = <0>;
+		#clock-cells = <1>;
+
+		reg = <0x088ea000 0x200>,
+		      <0x088eaa00 0x200>,
+		      <0x088ea200 0x200>,
+		      <0x088ea600 0x200>,
+		      <0xaf03000 0x8>;
+		reg-names = "pll_base", "phy_base", "ln_tx0_base",
+			"ln_tx1_base", "gdsc_base";
+
+		gdsc-supply = <&mdss_core_gdsc>;
+
+		clocks = <&clock_dispcc DISP_CC_MDSS_AHB_CLK>,
+			 <&clock_rpmh RPMH_CXO_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_CLKREF_CLK>,
+			 <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_PHY_PIPE_CLK>;
+		clock-names = "iface_clk", "ref_clk_src", "ref_clk",
+			"cfg_ahb_clk", "pipe_clk";
+		clock-rate = <0>;
+
+		qcom,platform-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,platform-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "gdsc";
+				qcom,supply-min-voltage = <0>;
+				qcom,supply-max-voltage = <0>;
+				qcom,supply-enable-load = <0>;
+				qcom,supply-disable-load = <0>;
+			};
+
+		};
+	};
+
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-sde.dtsi b/arch/arm64/boot/dts/qcom/sdm670-sde.dtsi
new file mode 100644
index 0000000..bb30a20
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-sde.dtsi
@@ -0,0 +1,532 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+&soc {
+	mdss_mdp: qcom,mdss_mdp@ae00000 {
+		compatible = "qcom,sde-kms";
+		reg = <0x0ae00000 0x81d40>,
+		      <0x0aeb0000 0x2008>,
+		      <0x0aeac000 0xf0>;
+		reg-names = "mdp_phys",
+			"vbif_phys",
+			"regdma_phys";
+
+		clocks =
+			<&clock_gcc GCC_DISP_AHB_CLK>,
+			<&clock_gcc GCC_DISP_AXI_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_AHB_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_AXI_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_MDP_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_VSYNC_CLK>;
+		clock-names = "gcc_iface", "gcc_bus", "iface_clk",
+				"bus_clk", "core_clk", "vsync_clk";
+		clock-rate = <0 0 0 0 300000000 19200000 0>;
+		clock-max-rate = <0 0 0 0 412500000 19200000 0>;
+
+		sde-vdd-supply = <&mdss_core_gdsc>;
+
+		/* interrupt config */
+		interrupt-parent = <&pdc>;
+		interrupts = <0 83 0>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		iommus = <&apps_smmu 0x880 0x8>,
+			<&apps_smmu 0xc80 0x8>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* hw blocks */
+		qcom,sde-off = <0x1000>;
+		qcom,sde-len = <0x45C>;
+
+		qcom,sde-ctl-off = <0x2000 0x2200 0x2400
+				     0x2600 0x2800>;
+		qcom,sde-ctl-size = <0xE4>;
+
+		qcom,sde-mixer-off = <0x45000 0x46000 0x47000
+				      0x48000 0x49000 0x4a000>;
+		qcom,sde-mixer-size = <0x320>;
+
+		qcom,sde-dspp-top-off = <0x1300>;
+		qcom,sde-dspp-top-size = <0xc>;
+
+		qcom,sde-dspp-off = <0x55000 0x57000>;
+		qcom,sde-dspp-size = <0x17e0>;
+
+		qcom,sde-wb-off = <0x66000>;
+		qcom,sde-wb-size = <0x2c8>;
+		qcom,sde-wb-xin-id = <6>;
+		qcom,sde-wb-id = <2>;
+		qcom,sde-wb-clk-ctrl = <0x3b8 24>;
+
+		qcom,sde-intf-off = <0x6b000 0x6b800
+					0x6c000 0x6c800>;
+		qcom,sde-intf-size = <0x280>;
+
+		qcom,sde-intf-type = "dp", "dsi", "dsi", "dp";
+		qcom,sde-pp-off = <0x71000 0x71800
+					  0x72000 0x72800 0x73000>;
+		qcom,sde-pp-slave = <0x0 0x0 0x0 0x0 0x1>;
+		qcom,sde-pp-size = <0xd4>;
+
+		qcom,sde-te2-off = <0x2000 0x2000 0x0 0x0 0x0>;
+		qcom,sde-cdm-off = <0x7a200>;
+		qcom,sde-cdm-size = <0x224>;
+
+		qcom,sde-dsc-off = <0x81000 0x81400>;
+		qcom,sde-dsc-size = <0x140>;
+
+		qcom,sde-dither-off = <0x30e0 0x30e0 0x30e0 0x30e0 0x0>;
+		qcom,sde-dither-version = <0x00010000>;
+		qcom,sde-dither-size = <0x20>;
+
+		qcom,sde-sspp-type = "vig", "vig",
+					"dma", "dma", "dma";
+
+		qcom,sde-sspp-off = <0x5000 0x7000 0x25000 0x27000 0x29000>;
+		qcom,sde-sspp-src-size = <0x1c8>;
+
+		qcom,sde-sspp-xin-id = <0 4 1 5 9>;
+		qcom,sde-sspp-excl-rect = <1 1 1 1 1>;
+		qcom,sde-sspp-smart-dma-priority = <4 5 1 2 3>;
+		qcom,sde-smart-dma-rev = "smart_dma_v2";
+
+		qcom,sde-mixer-pair-mask = <2 1 6 0 0 3>;
+
+		qcom,sde-mixer-blend-op-off = <0x20 0x38 0x50 0x68 0x80 0x98
+						0xb0 0xc8 0xe0 0xf8 0x110>;
+
+		/* offsets are relative to "mdp_phys + qcom,sde-off */
+		qcom,sde-sspp-clk-ctrl =
+				<0x2ac 0>, <0x2b4 0>,
+				 <0x2ac 8>, <0x2b4 8>, <0x2bc 8>;
+		qcom,sde-sspp-csc-off = <0x1a00>;
+		qcom,sde-csc-type = "csc-10bit";
+		qcom,sde-qseed-type = "qseedv3";
+		qcom,sde-sspp-qseed-off = <0xa00>;
+		qcom,sde-mixer-linewidth = <2560>;
+		qcom,sde-sspp-linewidth = <2560>;
+		qcom,sde-wb-linewidth = <4096>;
+		qcom,sde-mixer-blendstages = <0xb>;
+		qcom,sde-highest-bank-bit = <0x1>;
+		qcom,sde-ubwc-version = <0x200>;
+		qcom,sde-panic-per-pipe;
+		qcom,sde-has-cdp;
+		qcom,sde-has-src-split;
+		qcom,sde-has-dim-layer;
+		qcom,sde-has-idle-pc;
+		qcom,sde-max-bw-low-kbps = <9600000>;
+		qcom,sde-max-bw-high-kbps = <9600000>;
+		qcom,sde-dram-channels = <2>;
+		qcom,sde-num-nrt-paths = <0>;
+		qcom,sde-dspp-ad-version = <0x00040000>;
+		qcom,sde-dspp-ad-off = <0x28000 0x27000>;
+
+		qcom,sde-vbif-off = <0>;
+		qcom,sde-vbif-size = <0x1040>;
+		qcom,sde-vbif-id = <0>;
+		qcom,sde-vbif-memtype-0 = <3 3 3 3 3 3 3 3>;
+		qcom,sde-vbif-memtype-1 = <3 3 3 3 3 3>;
+
+		qcom,sde-vbif-qos-rt-remap = <3 3 4 4 5 5 6 6>;
+		qcom,sde-vbif-qos-nrt-remap = <3 3 3 3 3 3 3 3>;
+
+		qcom,sde-danger-lut = <0x0000000f 0x0000ffff 0x00000000
+			0x00000000>;
+		qcom,sde-safe-lut = <0xfffc 0xff00 0xffff 0xffff>;
+		qcom,sde-qos-lut-linear =
+			<4 0x00000000 0x00000357>,
+			<5 0x00000000 0x00003357>,
+			<6 0x00000000 0x00023357>,
+			<7 0x00000000 0x00223357>,
+			<8 0x00000000 0x02223357>,
+			<9 0x00000000 0x22223357>,
+			<10 0x00000002 0x22223357>,
+			<11 0x00000022 0x22223357>,
+			<12 0x00000222 0x22223357>,
+			<13 0x00002222 0x22223357>,
+			<14 0x00012222 0x22223357>,
+			<0 0x00112222 0x22223357>;
+		qcom,sde-qos-lut-macrotile =
+			<10 0x00000003 0x44556677>,
+			<11 0x00000033 0x44556677>,
+			<12 0x00000233 0x44556677>,
+			<13 0x00002233 0x44556677>,
+			<14 0x00012233 0x44556677>,
+			<0 0x00112233 0x44556677>;
+		qcom,sde-qos-lut-nrt =
+			<0 0x00000000 0x00000000>;
+		qcom,sde-qos-lut-cwb =
+			<0 0x75300000 0x00000000>;
+
+		qcom,sde-cdp-setting = <1 1>, <1 0>;
+
+		qcom,sde-inline-rotator = <&mdss_rotator 0>;
+		qcom,sde-inline-rot-xin = <10 11>;
+		qcom,sde-inline-rot-xin-type = "sspp", "wb";
+
+		/* offsets are relative to "mdp_phys + qcom,sde-off */
+		qcom,sde-inline-rot-clk-ctrl = <0x2bc 0x8>, <0x2bc 0xc>;
+
+		qcom,sde-reg-dma-off = <0>;
+		qcom,sde-reg-dma-version = <0x1>;
+		qcom,sde-reg-dma-trigger-off = <0x119c>;
+
+		qcom,sde-sspp-vig-blocks {
+			qcom,sde-vig-csc-off = <0x1a00>;
+			qcom,sde-vig-qseed-off = <0xa00>;
+			qcom,sde-vig-qseed-size = <0xa0>;
+		};
+
+		qcom,sde-dspp-blocks {
+			qcom,sde-dspp-igc = <0x0 0x00030001>;
+			qcom,sde-dspp-vlut = <0xa00 0x00010008>;
+			qcom,sde-dspp-gamut = <0x1000 0x00040000>;
+			qcom,sde-dspp-pcc = <0x1700 0x00040000>;
+			qcom,sde-dspp-gc = <0x17c0 0x00010008>;
+		};
+
+		qcom,platform-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,platform-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "sde-vdd";
+				qcom,supply-min-voltage = <0>;
+				qcom,supply-max-voltage = <0>;
+				qcom,supply-enable-load = <0>;
+				qcom,supply-disable-load = <0>;
+			};
+		};
+
+		smmu_sde_sec: qcom,smmu_sde_sec_cb {
+			compatible = "qcom,smmu_sde_sec";
+			iommus = <&apps_smmu 0x881 0x8>,
+			       <&apps_smmu 0xc81 0x8>;
+		};
+
+		/* data and reg bus scale settings */
+		qcom,sde-data-bus {
+			qcom,msm-bus,name = "mdss_sde_mnoc";
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <2>;
+			qcom,msm-bus,vectors-KBps =
+			    <22 773 0 0>, <23 773 0 0>,
+			    <22 773 0 6400000>, <23 773 0 6400000>,
+			    <22 773 0 6400000>, <23 773 0 6400000>;
+		};
+
+		qcom,sde-llcc-bus {
+			qcom,msm-bus,name = "mdss_sde_llcc";
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,vectors-KBps =
+			    <132 770 0 0>,
+			    <132 770 0 6400000>,
+			    <132 770 0 6400000>;
+		};
+
+		qcom,sde-ebi-bus {
+			qcom,msm-bus,name = "mdss_sde_ebi";
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,vectors-KBps =
+			    <129 512 0 0>,
+			    <129 512 0 6400000>,
+			    <129 512 0 6400000>;
+		};
+
+		qcom,sde-reg-bus {
+			qcom,msm-bus,name = "mdss_reg";
+			qcom,msm-bus,num-cases = <4>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,active-only;
+			qcom,msm-bus,vectors-KBps =
+				<1 590 0 0>,
+				<1 590 0 76800>,
+				<1 590 0 150000>,
+				<1 590 0 300000>;
+		};
+	};
+
+	sde_rscc: qcom,sde_rscc@af20000 {
+		cell-index = <0>;
+		compatible = "qcom,sde-rsc";
+		reg = <0xaf20000 0x1c44>,
+			<0xaf30000 0x3fd4>;
+		reg-names = "drv", "wrapper";
+		qcom,sde-rsc-version = <1>;
+
+		vdd-supply = <&mdss_core_gdsc>;
+		clocks = <&clock_dispcc DISP_CC_MDSS_RSCC_VSYNC_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_RSCC_AHB_CLK>;
+		clock-names = "vsync_clk", "iface_clk";
+		clock-rate = <0 0>;
+
+		qcom,sde-dram-channels = <2>;
+
+		mboxes = <&disp_rsc 0>;
+		mbox-names = "disp_rsc";
+
+		/* data and reg bus scale settings */
+		qcom,sde-data-bus {
+			qcom,msm-bus,name = "disp_rsc_mnoc";
+			qcom,msm-bus,active-only;
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <2>;
+			qcom,msm-bus,vectors-KBps =
+			    <20003 20515 0 0>, <20004 20515 0 0>,
+			    <20003 20515 0 6400000>, <20004 20515 0 6400000>,
+			    <20003 20515 0 6400000>, <20004 20515 0 6400000>;
+		};
+
+		qcom,sde-llcc-bus {
+			qcom,msm-bus,name = "disp_rsc_llcc";
+			qcom,msm-bus,active-only;
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,vectors-KBps =
+			    <20001 20513 0 0>,
+			    <20001 20513 0 6400000>,
+			    <20001 20513 0 6400000>;
+		};
+
+		qcom,sde-ebi-bus {
+			qcom,msm-bus,name = "disp_rsc_ebi";
+			qcom,msm-bus,active-only;
+			qcom,msm-bus,num-cases = <3>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,vectors-KBps =
+			    <20000 20512 0 0>,
+			    <20000 20512 0 6400000>,
+			    <20000 20512 0 6400000>;
+		};
+	};
+
+	mdss_rotator: qcom,mdss_rotator@ae00000 {
+		compatible = "qcom,sde_rotator";
+		reg = <0x0ae00000 0xac000>,
+		      <0x0aeb8000 0x3000>;
+		reg-names = "mdp_phys",
+			"rot_vbif_phys";
+
+		#list-cells = <1>;
+
+		qcom,mdss-rot-mode = <1>;
+		qcom,mdss-highest-bank-bit = <0x1>;
+
+		/* Bus Scale Settings */
+		qcom,msm-bus,name = "mdss_rotator";
+		qcom,msm-bus,num-cases = <3>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+			<25 512 0 0>,
+			<25 512 0 6400000>,
+			<25 512 0 6400000>;
+
+		rot-vdd-supply = <&mdss_core_gdsc>;
+		qcom,supply-names = "rot-vdd";
+
+		clocks =
+			<&clock_gcc GCC_DISP_AHB_CLK>,
+			<&clock_gcc GCC_DISP_AXI_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_AHB_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_ROT_CLK>,
+			<&clock_dispcc DISP_CC_MDSS_AXI_CLK>;
+		clock-names = "gcc_iface", "gcc_bus",
+			"iface_clk", "rot_clk", "axi_clk";
+
+		interrupt-parent = <&mdss_mdp>;
+		interrupts = <2 0>;
+
+		/* Offline rotator QoS setting */
+		qcom,mdss-rot-vbif-qos-setting = <3 3 3 3 3 3 3 3>;
+		qcom,mdss-rot-vbif-memtype = <3 3>;
+		qcom,mdss-rot-cdp-setting = <1 1>;
+		qcom,mdss-rot-qos-lut = <0x0 0x0 0x0 0x0>;
+		qcom,mdss-rot-danger-lut = <0x0 0x0>;
+		qcom,mdss-rot-safe-lut = <0x0000ffff 0x0000ffff>;
+
+		/* Inline rotator QoS Setting */
+		/* setting default register values for RD - qos/danger/safe */
+		qcom,mdss-inline-rot-qos-lut = <0x44556677 0x00112233
+							0x44556677 0x00112233>;
+		qcom,mdss-inline-rot-danger-lut = <0x0055aaff 0x0000ffff>;
+		qcom,mdss-inline-rot-safe-lut = <0x0000f000 0x0000ff00>;
+
+		qcom,mdss-default-ot-rd-limit = <32>;
+		qcom,mdss-default-ot-wr-limit = <32>;
+
+		qcom,mdss-sbuf-headroom = <20>;
+
+		cache-slice-names = "rotator";
+		cache-slices = <&llcc 4>;
+
+		/* reg bus scale settings */
+		rot_reg: qcom,rot-reg-bus {
+			qcom,msm-bus,name = "mdss_rot_reg";
+			qcom,msm-bus,num-cases = <2>;
+			qcom,msm-bus,num-paths = <1>;
+			qcom,msm-bus,active-only;
+			qcom,msm-bus,vectors-KBps =
+				<1 590 0 0>,
+				<1 590 0 76800>;
+		};
+
+		smmu_rot_unsec: qcom,smmu_rot_unsec_cb {
+			compatible = "qcom,smmu_sde_rot_unsec";
+			iommus = <&apps_smmu 0x1090 0x0>;
+		};
+
+		smmu_rot_sec: qcom,smmu_rot_sec_cb {
+			compatible = "qcom,smmu_sde_rot_sec";
+			iommus = <&apps_smmu 0x1091 0x0>;
+		};
+	};
+
+	mdss_dsi0: qcom,mdss_dsi_ctrl0@ae94000 {
+		compatible = "qcom,dsi-ctrl-hw-v2.2";
+		label = "dsi-ctrl-0";
+		cell-index = <0>;
+		reg =   <0xae94000 0x400>,
+			<0xaf08000 0x4>;
+		reg-names = "dsi_ctrl", "disp_cc_base";
+		interrupt-parent = <&mdss_mdp>;
+		interrupts = <4 0>;
+		vdda-1p2-supply = <&pm660_l1>;
+		clocks = <&clock_dispcc DISP_CC_MDSS_BYTE0_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_BYTE0_CLK_SRC>,
+		<&clock_dispcc DISP_CC_MDSS_BYTE0_INTF_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_PCLK0_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_PCLK0_CLK_SRC>,
+		<&clock_dispcc DISP_CC_MDSS_ESC0_CLK>;
+		clock-names = "byte_clk", "byte_clk_rcg", "byte_intf_clk",
+					"pixel_clk", "pixel_clk_rcg",
+					"esc_clk";
+
+		qcom,ctrl-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,ctrl-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-1p2";
+				qcom,supply-min-voltage = <1200000>;
+				qcom,supply-max-voltage = <1200000>;
+				qcom,supply-enable-load = <21800>;
+				qcom,supply-disable-load = <4>;
+			};
+		};
+	};
+
+	mdss_dsi1: qcom,mdss_dsi_ctrl1@ae96000 {
+		compatible = "qcom,dsi-ctrl-hw-v2.2";
+		label = "dsi-ctrl-1";
+		cell-index = <1>;
+		reg =   <0xae96000 0x400>,
+			<0xaf08000 0x4>;
+		reg-names = "dsi_ctrl", "disp_cc_base";
+		interrupt-parent = <&mdss_mdp>;
+		interrupts = <5 0>;
+		vdda-1p2-supply = <&pm660_l1>;
+		clocks = <&clock_dispcc DISP_CC_MDSS_BYTE1_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_BYTE1_CLK_SRC>,
+		<&clock_dispcc DISP_CC_MDSS_BYTE1_INTF_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_PCLK1_CLK>,
+		<&clock_dispcc DISP_CC_MDSS_PCLK1_CLK_SRC>,
+		<&clock_dispcc DISP_CC_MDSS_ESC1_CLK>;
+		clock-names = "byte_clk", "byte_clk_rcg", "byte_intf_clk",
+				"pixel_clk", "pixel_clk_rcg", "esc_clk";
+		qcom,ctrl-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,ctrl-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-1p2";
+				qcom,supply-min-voltage = <1200000>;
+				qcom,supply-max-voltage = <1200000>;
+				qcom,supply-enable-load = <21800>;
+				qcom,supply-disable-load = <4>;
+			};
+		};
+	};
+
+	mdss_dsi_phy0: qcom,mdss_dsi_phy0@ae94400 {
+		compatible = "qcom,dsi-phy-v3.0";
+		label = "dsi-phy-0";
+		cell-index = <0>;
+		reg = <0xae94400 0x7c0>;
+		reg-names = "dsi_phy";
+		gdsc-supply = <&mdss_core_gdsc>;
+		vdda-0p9-supply = <&pm660l_l1>;
+		qcom,platform-strength-ctrl = [55 03
+						55 03
+						55 03
+						55 03
+						55 00];
+		qcom,platform-lane-config = [00 00 00 00
+						00 00 00 00
+						00 00 00 00
+						00 00 00 00
+						00 00 00 80];
+		qcom,platform-regulator-settings = [1d 1d 1d 1d 1d];
+		qcom,phy-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			qcom,phy-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-0p9";
+				qcom,supply-min-voltage = <880000>;
+				qcom,supply-max-voltage = <880000>;
+				qcom,supply-enable-load = <36000>;
+				qcom,supply-disable-load = <32>;
+			};
+		};
+	};
+
+	mdss_dsi_phy1: qcom,mdss_dsi_phy0@ae96400 {
+		compatible = "qcom,dsi-phy-v3.0";
+		label = "dsi-phy-1";
+		cell-index = <1>;
+		reg = <0xae96400 0x7c0>;
+		reg-names = "dsi_phy";
+		gdsc-supply = <&mdss_core_gdsc>;
+		vdda-0p9-supply = <&pm660l_l1>;
+		qcom,platform-strength-ctrl = [55 03
+						55 03
+						55 03
+						55 03
+						55 00];
+		qcom,platform-regulator-settings = [1d 1d 1d 1d 1d];
+		qcom,platform-lane-config = [00 00 00 00
+						00 00 00 00
+						00 00 00 00
+						00 00 00 00
+						00 00 00 80];
+		qcom,phy-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			qcom,phy-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-0p9";
+				qcom,supply-min-voltage = <880000>;
+				qcom,supply-max-voltage = <880000>;
+				qcom,supply-enable-load = <36000>;
+				qcom,supply-disable-load = <32>;
+			};
+		};
+	};
+
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-stub-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm670-stub-regulator.dtsi
new file mode 100644
index 0000000..bcdc415
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-stub-regulator.dtsi
@@ -0,0 +1,342 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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  PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+
+/* Stub regulators */
+
+/ {
+	pm660_s4: regulator-pm660-s4 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_s4";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <2040000>;
+		regulator-max-microvolt = <2040000>;
+	};
+
+	/* pm660 S5 - VDD_MODEM supply */
+	pm660_s5_level: regulator-pm660-s5 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_s5_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660_s6: regulator-pm660-s6 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_s6";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <1352000>;
+		regulator-max-microvolt = <1352000>;
+	};
+
+	/* pm660l S1 - VDD_MX supply */
+	pm660l_s1_level: regulator-pm660l-s1 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s1_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_s1_floor_level: regulator-pm660l-s1-floor-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s1_floor_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_s1_level_ao: regulator-pm660l-s1-level-ao {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s1_level_ao";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	/* pm660l S2 - VDD_GFX supply */
+	pm660l_s2_level: regulator-pm660l-s2 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s2_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	/* pm660l S3 + S4 - VDD_CX supply */
+	pm660l_s3_level: regulator-pm660l-s3-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s3_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_s3_floor_level: regulator-pm660l-s3-floor-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_s3_floor_level";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_s3_level_ao: regulator-pm660l-s3-level-ao {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_s3_level_ao";
+		qcom,hpm-min-load = <100000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660_l1: regulator-pm660-l1 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l1";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1200000>;
+		regulator-max-microvolt = <1250000>;
+	};
+
+	pm660_l2: regulator-pm660-l2 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l2";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1000000>;
+		regulator-max-microvolt = <1000000>;
+	};
+
+	pm660_l3: regulator-pm660-l3 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l3";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1000000>;
+		regulator-max-microvolt = <1000000>;
+	};
+
+	pm660_l5: regulator-pm660-l5 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l5";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <800000>;
+		regulator-max-microvolt = <800000>;
+	};
+
+	pm660_l6: regulator-pm660-l6 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l6";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1304000>;
+		regulator-max-microvolt = <1304000>;
+	};
+
+	pm660_l7: regulator-pm660-l7 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l7";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1200000>;
+		regulator-max-microvolt = <1200000>;
+	};
+
+	pm660_l8: regulator-pm660-l8 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l8";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l9: regulator-pm660-l9 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l9";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l10: regulator-pm660-l10 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l10";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l11: regulator-pm660-l11 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l11";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l12: regulator-pm660-l12 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l12";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l13: regulator-pm660-l13 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l13";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l14: regulator-pm660-l14 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l14";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	pm660_l15: regulator-pm660-l15 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l15";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <2950000>;
+	};
+
+	pm660_l16: regulator-pm660-l16 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l16";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <2700000>;
+		regulator-max-microvolt = <2700000>;
+	};
+
+	pm660_l17: regulator-pm660-l17 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l17";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <2950000>;
+	};
+
+	pm660_l19: regulator-pm660-l19 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660_l19";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <3312000>;
+		regulator-max-microvolt = <3312000>;
+	};
+
+	pm660l_l1: regulator-pm660l-l1 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l1";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <880000>;
+		regulator-max-microvolt = <900000>;
+	};
+
+	pm660l_l2: regulator-pm660l-l2 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l2";
+		qcom,hpm-min-load = <5000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <2960000>;
+	};
+
+	pm660l_l3: regulator-pm660l-l3 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l3";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <2850000>;
+		regulator-max-microvolt = <3008000>;
+	};
+
+	pm660l_l4: regulator-pm660l-l4 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l4";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <2960000>;
+		regulator-max-microvolt = <2960000>;
+	};
+
+	pm660l_l5: regulator-pm660l-l5 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l5";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <2960000>;
+		regulator-max-microvolt = <2960000>;
+	};
+
+	pm660l_l6: regulator-pm660l-l6 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l6";
+		qcom,hpm-min-load = <5000>;
+		regulator-min-microvolt = <3008000>;
+		regulator-max-microvolt = <3300000>;
+	};
+
+	pm660l_l7: regulator-pm660l-l7 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l7";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <3088000>;
+		regulator-max-microvolt = <3100000>;
+	};
+
+	pm660l_l8: regulator-pm660l-l8 {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l8";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3312000>;
+	};
+
+	/* pm660l L9 = VDD_LPI_CX supply */
+	pm660l_l9_level: regulator-pm660l-l9-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l9_level";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_l9_floor_level: regulator-pm660l-l9-floor-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l9_floor_level";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	/* pm660l L10 = VDD_LPI_MX supply */
+	pm660l_l10_level: regulator-pm660l-l10-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l10_level";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_l10_floor_level: regulator-pm660l-l10-floor-level {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_l10_floor_level";
+		qcom,hpm-min-load = <10000>;
+		regulator-min-microvolt = <RPMH_REGULATOR_LEVEL_OFF>;
+		regulator-max-microvolt = <RPMH_REGULATOR_LEVEL_MAX>;
+	};
+
+	pm660l_bob: regulator-pm660l-bob {
+		compatible = "qcom,stub-regulator";
+		regulator-name = "pm660l_bob";
+		regulator-min-microvolt = <3312000>;
+		regulator-max-microvolt = <3312000>;
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-thermal.dtsi b/arch/arm64/boot/dts/qcom/sdm670-thermal.dtsi
new file mode 100644
index 0000000..e4993d6
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-thermal.dtsi
@@ -0,0 +1,1507 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+&clock_cpucc {
+	lmh_dcvs0: qcom,limits-dcvs@0 {
+		compatible = "qcom,msm-hw-limits";
+		interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+		qcom,affinity = <0>;
+		#thermal-sensor-cells = <0>;
+	};
+
+	lmh_dcvs1: qcom,limits-dcvs@1 {
+		compatible = "qcom,msm-hw-limits";
+		interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+		qcom,affinity = <1>;
+		#thermal-sensor-cells = <0>;
+	};
+};
+
+&soc {
+	qmi-tmd-devices {
+		compatible = "qcom,qmi_cooling_devices";
+
+		modem {
+			qcom,instance-id = <0x0>;
+
+			modem_pa: modem_pa {
+				qcom,qmi-dev-name = "pa";
+				#cooling-cells = <2>;
+			};
+
+			modem_proc: modem_proc {
+				qcom,qmi-dev-name = "modem";
+				#cooling-cells = <2>;
+			};
+
+			modem_current: modem_current {
+				qcom,qmi-dev-name = "modem_current";
+				#cooling-cells = <2>;
+			};
+
+			modem_vdd: modem_vdd {
+				qcom,qmi-dev-name = "cpuv_restriction_cold";
+				#cooling-cells = <2>;
+			};
+		};
+
+		adsp {
+			qcom,instance-id = <0x1>;
+
+			adsp_vdd: adsp_vdd {
+				qcom,qmi-dev-name = "cpuv_restriction_cold";
+				#cooling-cells = <2>;
+			};
+		};
+
+		cdsp {
+			qcom,instance-id = <0x43>;
+
+			cdsp_vdd: cdsp_vdd {
+				qcom,qmi-dev-name = "cpuv_restriction_cold";
+				#cooling-cells = <2>;
+			};
+		};
+	};
+};
+
+&thermal_zones {
+	aoss0-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&tsens0 0>;
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu0-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&tsens0 1>;
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu1-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&tsens0 2>;
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu2-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&tsens0 3>;
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu3-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 4>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu4-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 5>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu5-silver-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 6>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	kryo-l3-0-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 7>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	kryo-l3-1-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 8>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu0-gold-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 9>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	cpu1-gold-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 10>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	gpu0-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens0 11>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	gpu1-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&tsens0 12>;
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	aoss1-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 0>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	mdm-dsp-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 1>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	ddr-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 2>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	wlan-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 3>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	compute-hvx-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 4>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	camera-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 5>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	mmss-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 6>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	mdm-core-usr {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 7>;
+		thermal-governor = "user_space";
+		trips {
+			active-config0 {
+				temperature = <125000>;
+				hysteresis = <1000>;
+				type = "passive";
+			};
+		};
+	};
+
+	gpu-virt-max-step {
+		polling-delay-passive = <10>;
+		polling-delay = <100>;
+		thermal-governor = "step_wise";
+		trips {
+			gpu_trip0: gpu-trip0 {
+				temperature = <95000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			gpu_cdev0 {
+				trip = <&gpu_trip0>;
+				cooling-device =
+					<&msm_gpu THERMAL_NO_LIMIT
+						THERMAL_NO_LIMIT>;
+			};
+		};
+	};
+
+	hexa-silv-max-step {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		trips {
+			silver-trip {
+				temperature = <120000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+	};
+
+	dual-gold-max-step {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		trips {
+			gold-trip {
+				temperature = <120000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+	};
+
+	pop-mem-step {
+		polling-delay-passive = <10>;
+		polling-delay = <0>;
+		thermal-sensors = <&tsens1 2>;
+		thermal-governor = "step_wise";
+		trips {
+			pop_trip: pop-trip {
+				temperature = <95000>;
+				hysteresis = <0>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			pop_cdev6 {
+				trip = <&pop_trip>;
+				cooling-device =
+					<&CPU6 THERMAL_NO_LIMIT
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+			pop_cdev7 {
+				trip = <&pop_trip>;
+				cooling-device =
+					<&CPU7 THERMAL_NO_LIMIT
+						(THERMAL_MAX_LIMIT-1)>;
+			};
+		};
+	};
+
+	aoss0-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 0>;
+		tracks-low;
+		trips {
+			aoss0_trip: aoss0-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu0-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 1>;
+		tracks-low;
+		trips {
+			cpu0_trip: cpu0-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu0_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu1-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 2>;
+		tracks-low;
+		trips {
+			cpu1_trip: cpu1-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu1_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu2-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 3>;
+		tracks-low;
+		trips {
+			cpu2_trip: cpu2-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu2_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu3-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 4>;
+		tracks-low;
+		trips {
+			cpu3_trip: cpu3-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu3_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu4-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 5>;
+		tracks-low;
+		trips {
+			cpu4_trip: cpu4-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu4_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu5-silver-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 6>;
+		tracks-low;
+		trips {
+			cpu5_trip: cpu5-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpu5_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	kryo-l3-0-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 7>;
+		tracks-low;
+		trips {
+			l3_0_trip: l3-0-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&l3_0_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	kryo-l3-1-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 8>;
+		tracks-low;
+		trips {
+			l3_1_trip: l3-1-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&l3_1_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu0-gold-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 9>;
+		tracks-low;
+		trips {
+			cpug0_trip: cpug0-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpug0_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	cpu1-gold-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 10>;
+		tracks-low;
+		trips {
+			cpug1_trip: cpug1-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&cpug1_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	gpu0-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 11>;
+		tracks-low;
+		trips {
+			gpu0_trip_l: gpu0-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&gpu0_trip_l>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	gpu1-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens0 12>;
+		tracks-low;
+		trips {
+			gpu1_trip_l: gpu1-trip_l {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&gpu1_trip_l>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	aoss1-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 0>;
+		tracks-low;
+		trips {
+			aoss1_trip: aoss1-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&aoss1_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	mdm-dsp-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 1>;
+		tracks-low;
+		trips {
+			dsp_trip: dsp-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&dsp_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	ddr-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 2>;
+		tracks-low;
+		trips {
+			ddr_trip: ddr-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&ddr_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	wlan-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 3>;
+		tracks-low;
+		trips {
+			wlan_trip: wlan-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&wlan_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	compute-hvx-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 4>;
+		tracks-low;
+		trips {
+			hvx_trip: hvx-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&hvx_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	camera-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 5>;
+		tracks-low;
+		trips {
+			camera_trip: camera-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&camera_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	mmss-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 6>;
+		tracks-low;
+		trips {
+			mmss_trip: mmss-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&mmss_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	mdm-core-lowf {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "low_limits_floor";
+		thermal-sensors = <&tsens1 7>;
+		tracks-low;
+		trips {
+			mdm_trip: mdm-trip {
+				temperature = <5000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			cpu0_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&CPU0 4 4>;
+			};
+			cpu6_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&CPU6 9 9>;
+			};
+			gpu_vdd_cdev {
+				trip = <&aoss0_trip>;
+				cooling-device = <&msm_gpu 1 1>;
+			};
+			cx_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&cx_cdev 0 0>;
+			};
+			mx_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&mx_cdev 0 0>;
+			};
+			modem_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&modem_vdd 0 0>;
+			};
+			adsp_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&adsp_vdd 0 0>;
+			};
+			cdsp_vdd_cdev {
+				trip = <&mdm_trip>;
+				cooling-device = <&cdsp_vdd 0 0>;
+			};
+		};
+	};
+
+	lmh-dcvs-01 {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&lmh_dcvs1>;
+
+		trips {
+			active-config {
+				temperature = <95000>;
+				hysteresis = <30000>;
+				type = "passive";
+			};
+		};
+	};
+
+	lmh-dcvs-00 {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "user_space";
+		thermal-sensors = <&lmh_dcvs0>;
+
+		trips {
+			active-config {
+				temperature = <95000>;
+				hysteresis = <30000>;
+				type = "passive";
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi b/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi
new file mode 100644
index 0000000..6a69e29
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "sdm845-usb.dtsi"
+
+&soc {
+	/delete-node/ ssusb@a800000;
+	/delete-node/ qusb@88e3000;
+	/delete-node/ ssphy@88eb000;
+	/delete-node/ usb_audio_qmi_dev;
+	usb_audio_qmi_dev {
+		compatible = "qcom,usb-audio-qmi-dev";
+		iommus = <&apps_smmu 0x180f 0x0>;
+		qcom,usb-audio-stream-id = <0xf>;
+		qcom,usb-audio-intr-num = <2>;
+	};
+};
+
+&usb0 {
+	/delete-property/ iommus;
+	/delete-property/ qcom,smmu-s1-bypass;
+	extcon = <0>, <0>, <0> /* <&eud> */;
+};
+
+&qusb_phy0 {
+	vdd-supply = <&pm660l_l1>;
+	vdda18-supply = <&pm660_l10>;
+	vdda33-supply = <&pm660l_l7>;
+};
+
+&usb_qmp_dp_phy {
+	vdd-supply = <&pm660l_l1>; /* 0.88v */
+	core-supply = <&pm660_l1>; /* 1.2v */
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp-overlay.dts
new file mode 100644
index 0000000..e4e1db5
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp-overlay.dts
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L, USB-C Audio, CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 2>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
+
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp.dts
new file mode 100644
index 0000000..80a8423
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-cdp.dts
@@ -0,0 +1,26 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L, USB-C Audio, CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 2>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp-overlay.dts
new file mode 100644
index 0000000..c5bab55
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp-overlay.dts
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660+PM660L, USB-C Audio, Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 3>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp.dts
new file mode 100644
index 0000000..2c53334
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-cdp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660+PM660L, USB-C Audio, Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 3>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp-overlay.dts
new file mode 100644
index 0000000..09ba184
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660+PM660L, USB-C Audio, Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 3>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp.dts
new file mode 100644
index 0000000..7a19819
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-mtp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660+PM660L, USB-C Audio, Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 3>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp-overlay.dts
new file mode 100644
index 0000000..71db0f7
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp-overlay.dts
@@ -0,0 +1,36 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660+PM660A, USB-C Audio, Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 3>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
+
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp.dts
new file mode 100644
index 0000000..ff641e6
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-cdp.dts
@@ -0,0 +1,29 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660+PM660A, USB-C Audio, Ext. Audio Codec CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 3>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp-overlay.dts
new file mode 100644
index 0000000..c2e6f58
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp-overlay.dts
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660+PM660A, USB-C Audio, Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 3>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp.dts
new file mode 100644
index 0000000..2cd68f1
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-external-codec-pm660a-mtp.dts
@@ -0,0 +1,29 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-external-codec.dtsi"
+#include "sdm670-ext-cdc-usbc-audio.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM 670 PM660+PM660A, USB-C Audio, Ext. Audio Codec MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 3>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp-overlay.dts
new file mode 100644
index 0000000..3d5c04e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp-overlay.dts
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L, USB-C Audio, MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 2>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp.dts
new file mode 100644
index 0000000..8449625
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-mtp.dts
@@ -0,0 +1,27 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660L, USB-C Audio, MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 2>;
+	qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
+		       <0x0001001b 0x0102001a 0x0 0x0>,
+		       <0x0001001b 0x0201011a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp-overlay.dts
new file mode 100644
index 0000000..6a26d95
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp-overlay.dts
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A, USB-C Audio, CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <1 2>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
+
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp.dts
new file mode 100644
index 0000000..1871b45
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-cdp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-cdp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A, USB-C Audio, CDP";
+	compatible = "qcom,sdm670-cdp", "qcom,sdm670", "qcom,cdp";
+	qcom,board-id = <1 2>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp-overlay.dts
new file mode 100644
index 0000000..d565cdd
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp-overlay.dts
@@ -0,0 +1,34 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A, USB-C Audio, MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,msm-id = <336 0x0>;
+	qcom,board-id = <8 2>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp.dts b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp.dts
new file mode 100644
index 0000000..b288569
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-usbc-pm660a-mtp.dts
@@ -0,0 +1,28 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+
+#include "sdm670.dtsi"
+#include "sdm670-mtp.dtsi"
+#include "pm660a.dtsi"
+#include "sdm670-int-cdc-usbc-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. SDM670 PM660 + PM660A, USB-C Audio, MTP";
+	compatible = "qcom,sdm670-mtp", "qcom,sdm670", "qcom,mtp";
+	qcom,board-id = <8 2>;
+	qcom,pmic-id = <0x0001001b 0x0001011a 0x0 0x0>,
+		       <0x0001001b 0x0002001a 0x0 0x0>,
+		       <0x0001001b 0x0202001a 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670-vidc.dtsi b/arch/arm64/boot/dts/qcom/sdm670-vidc.dtsi
new file mode 100644
index 0000000..a74f9d8
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm670-vidc.dtsi
@@ -0,0 +1,214 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/msm/msm-bus-ids.h>
+#include <dt-bindings/clock/qcom,videocc-sdm845.h>
+
+&soc {
+	msm_vidc0: qcom,vidc0 {
+		compatible = "qcom,msm-vidc", "qcom,sdm670-vidc";
+		status = "ok";
+		sku-index = <0>;
+		reg = <0xaa00000 0x200000>;
+		interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+
+		/* Supply */
+		venus-supply = <&venus_gdsc>;
+		venus-core0-supply = <&vcodec0_gdsc>;
+		venus-core1-supply = <&vcodec1_gdsc>;
+
+		/* Clocks */
+		clock-names = "core_clk", "iface_clk", "bus_clk",
+			"core0_clk", "core0_bus_clk",
+			"core1_clk", "core1_bus_clk";
+		clocks = <&clock_videocc VIDEO_CC_VENUS_CTL_CORE_CLK>,
+			<&clock_videocc VIDEO_CC_VENUS_AHB_CLK>,
+			<&clock_videocc VIDEO_CC_VENUS_CTL_AXI_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC0_CORE_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC0_AXI_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC1_CORE_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC1_AXI_CLK>;
+		qcom,proxy-clock-names = "core_clk", "iface_clk",
+			"bus_clk", "core0_clk", "core0_bus_clk",
+			"core1_clk", "core1_bus_clk";
+		qcom,clock-configs = <0x1 0x0 0x0 0x1 0x0 0x1 0x0>;
+		qcom,allowed-clock-rates = <100000000 200000000 320000000
+			380000000 444000000 533000000>;
+
+		/* Buses */
+		bus_cnoc {
+			compatible = "qcom,msm-vidc,bus";
+			label = "cnoc";
+			qcom,bus-master = <MSM_BUS_MASTER_AMPSS_M0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_VENUS_CFG>;
+			qcom,bus-governor = "performance";
+			qcom,bus-range-kbps = <1000 1000>;
+		};
+
+		venus_bus_ddr {
+			compatible = "qcom,msm-vidc,bus";
+			label = "venus-ddr";
+			qcom,bus-master = <MSM_BUS_MASTER_VIDEO_P0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_EBI_CH0>;
+			qcom,bus-governor = "msm-vidc-ddr";
+			qcom,bus-range-kbps = <1000 3388000>;
+		};
+		arm9_bus_ddr {
+			compatible = "qcom,msm-vidc,bus";
+			label = "venus-arm9-ddr";
+			qcom,bus-master = <MSM_BUS_MASTER_VIDEO_P0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_EBI_CH0>;
+			qcom,bus-governor = "performance";
+			qcom,bus-range-kbps = <1000 1000>;
+		};
+
+		/* MMUs */
+		non_secure_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_ns";
+			iommus =
+				<&apps_smmu 0x10a0 0x8>,
+				<&apps_smmu 0x10b0 0x0>;
+			buffer-types = <0xfff>;
+			virtual-addr-pool = <0x70800000 0x6f800000>;
+		};
+
+		secure_bitstream_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_bitstream";
+			iommus =
+				<&apps_smmu 0x10a1 0x8>,
+				<&apps_smmu 0x10a5 0x8>;
+			buffer-types = <0x241>;
+			virtual-addr-pool = <0x4b000000 0x25800000>;
+			qcom,secure-context-bank;
+		};
+
+		secure_pixel_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_pixel";
+			iommus =
+				<&apps_smmu 0x10a3 0x8>;
+			buffer-types = <0x106>;
+			virtual-addr-pool = <0x25800000 0x25800000>;
+			qcom,secure-context-bank;
+		};
+
+		secure_non_pixel_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_non_pixel";
+			iommus =
+				<&apps_smmu 0x10a4 0x8>,
+				<&apps_smmu 0x10b4 0x0>;
+			buffer-types = <0x480>;
+			virtual-addr-pool = <0x1000000 0x24800000>;
+			qcom,secure-context-bank;
+		};
+	};
+
+	msm_vidc1: qcom,vidc1 {
+		compatible = "qcom,msm-vidc", "qcom,sdm670-vidc";
+		status = "ok";
+		sku-index = <1>;
+		reg = <0xaa00000 0x200000>;
+		interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+
+		/* Supply */
+		venus-supply = <&venus_gdsc>;
+		venus-core0-supply = <&vcodec0_gdsc>;
+
+		/* Clocks */
+		clock-names = "core_clk", "iface_clk", "bus_clk",
+			"core0_clk", "core0_bus_clk";
+		clocks = <&clock_videocc VIDEO_CC_VENUS_CTL_CORE_CLK>,
+			<&clock_videocc VIDEO_CC_VENUS_AHB_CLK>,
+			<&clock_videocc VIDEO_CC_VENUS_CTL_AXI_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC0_CORE_CLK>,
+			<&clock_videocc VIDEO_CC_VCODEC0_AXI_CLK>;
+		qcom,proxy-clock-names = "core_clk", "iface_clk",
+			"bus_clk", "core0_clk", "core0_bus_clk";
+		qcom,clock-configs = <0x1 0x0 0x0 0x1 0x0>;
+		qcom,allowed-clock-rates = <100000000 200000000 320000000
+			364800000>;
+
+		/* Buses */
+		bus_cnoc {
+			compatible = "qcom,msm-vidc,bus";
+			label = "cnoc";
+			qcom,bus-master = <MSM_BUS_MASTER_AMPSS_M0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_VENUS_CFG>;
+			qcom,bus-governor = "performance";
+			qcom,bus-range-kbps = <1000 1000>;
+		};
+
+		venus_bus_ddr {
+			compatible = "qcom,msm-vidc,bus";
+			label = "venus-ddr";
+			qcom,bus-master = <MSM_BUS_MASTER_VIDEO_P0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_EBI_CH0>;
+			qcom,bus-governor = "msm-vidc-ddr";
+			qcom,bus-range-kbps = <1000 2128000>;
+		};
+		arm9_bus_ddr {
+			compatible = "qcom,msm-vidc,bus";
+			label = "venus-arm9-ddr";
+			qcom,bus-master = <MSM_BUS_MASTER_VIDEO_P0>;
+			qcom,bus-slave = <MSM_BUS_SLAVE_EBI_CH0>;
+			qcom,bus-governor = "performance";
+			qcom,bus-range-kbps = <1000 1000>;
+		};
+
+		/* MMUs */
+		non_secure_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_ns";
+			iommus =
+				<&apps_smmu 0x10a0 0x8>,
+				<&apps_smmu 0x10b0 0x0>;
+			buffer-types = <0xfff>;
+			virtual-addr-pool = <0x70800000 0x6f800000>;
+		};
+
+		secure_bitstream_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_bitstream";
+			iommus =
+				<&apps_smmu 0x10a1 0x8>,
+				<&apps_smmu 0x10a5 0x8>;
+			buffer-types = <0x241>;
+			virtual-addr-pool = <0x4b000000 0x25800000>;
+			qcom,secure-context-bank;
+		};
+
+		secure_pixel_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_pixel";
+			iommus =
+				<&apps_smmu 0x10a3 0x8>;
+			buffer-types = <0x106>;
+			virtual-addr-pool = <0x25800000 0x25800000>;
+			qcom,secure-context-bank;
+		};
+
+		secure_non_pixel_cb {
+			compatible = "qcom,msm-vidc,context-bank";
+			label = "venus_sec_non_pixel";
+			iommus =
+				<&apps_smmu 0x10a4 0x8>,
+				<&apps_smmu 0x10b4 0x0>;
+			buffer-types = <0x480>;
+			virtual-addr-pool = <0x1000000 0x24800000>;
+			qcom,secure-context-bank;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm670.dtsi b/arch/arm64/boot/dts/qcom/sdm670.dtsi
index 42c072b..b527f3d 100644
--- a/arch/arm64/boot/dts/qcom/sdm670.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670.dtsi
@@ -23,6 +23,8 @@
 #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
 #include <dt-bindings/clock/qcom,aop-qmp.h>
 
+#define MHZ_TO_MBPS(mhz, w) ((mhz * 1000000 * w) / (1024 * 1024))
+
 / {
 	model = "Qualcomm Technologies, Inc. SDM670";
 	compatible = "qcom,sdm670";
@@ -32,9 +34,7 @@
 	aliases {
 		ufshc1 = &ufshc_mem; /* Embedded UFS slot */
 		sdhc1 = &sdhc_1; /* SDC1 eMMC slot */
-	};
-
-	aliases {
+		sdhc2 = &sdhc_2; /* SDC2 SD Card slot */
 		serial0 = &qupv3_se12_2uart;
 		spi0 = &qupv3_se8_spi;
 		i2c0 = &qupv3_se10_i2c;
@@ -42,6 +42,10 @@
 		hsuart0 = &qupv3_se6_4uart;
 	};
 
+	chosen {
+		bootargs = "rcupdate.rcu_expedited=1 core_ctl_disable_cpumask=6-7";
+	};
+
 	cpus {
 		#address-cells = <2>;
 		#size-cells = <0>;
@@ -55,6 +59,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_0>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_0: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -74,6 +81,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_0: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU1: cpu@100 {
@@ -85,6 +95,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_100>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_100: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -99,6 +112,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_100: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU2: cpu@200 {
@@ -110,6 +126,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_200>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_200: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -124,6 +143,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_200: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU3: cpu@300 {
@@ -135,6 +157,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_300>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_300: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -149,6 +174,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_300: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU4: cpu@400 {
@@ -160,6 +188,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_400>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_400: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -174,6 +205,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_400: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU5: cpu@500 {
@@ -185,6 +219,9 @@
 			cache-size = <0x8000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_500>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
+			qcom,lmh-dcvs = <&lmh_dcvs0>;
+			#cooling-cells = <2>;
 			L2_500: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x20000>;
@@ -199,6 +236,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x9000>;
 			};
+			L1_TLB_500: l1-tlb {
+				qcom,dump-size = <0x3000>;
+			};
 		};
 
 		CPU6: cpu@600 {
@@ -210,6 +250,9 @@
 			cache-size = <0x10000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_600>;
+			sched-energy-costs = <&CPU_COST_1 &CLUSTER_COST_1>;
+			qcom,lmh-dcvs = <&lmh_dcvs1>;
+			#cooling-cells = <2>;
 			L2_600: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x40000>;
@@ -224,6 +267,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x12000>;
 			};
+			L1_TLB_600: l1-tlb {
+				qcom,dump-size = <0x3c000>;
+			};
 		};
 
 		CPU7: cpu@700 {
@@ -235,6 +281,9 @@
 			cache-size = <0x10000>;
 			cpu-release-addr = <0x0 0x90000000>;
 			next-level-cache = <&L2_700>;
+			sched-energy-costs = <&CPU_COST_1 &CLUSTER_COST_1>;
+			qcom,lmh-dcvs = <&lmh_dcvs1>;
+			#cooling-cells = <2>;
 			L2_700: l2-cache {
 				compatible = "arm,arch-cache";
 				cache-size = <0x40000>;
@@ -249,6 +298,9 @@
 				compatible = "arm,arch-cache";
 				qcom,dump-size = <0x12000>;
 			};
+			L1_TLB_700: l1-tlb {
+				qcom,dump-size = <0x3c000>;
+			};
 		};
 
 		cpu-map {
@@ -289,6 +341,129 @@
 		};
 	};
 
+	energy_costs: energy-costs {
+		compatible = "sched-energy";
+
+		CPU_COST_0: core-cost0 {
+			busy-cost-data = <
+				 300000    14
+				 403200    18
+				 480000    21
+				 576000    25
+				 652800    27
+				 748800    31
+				 825600    40
+				 902400    43
+				 979200    46
+				1056000    50
+				1132800    53
+				1228800    57
+				1324800    84
+				1420800    90
+				1516800    96
+				1612800   114
+				1689600   135
+				1766400   141
+			>;
+			idle-cost-data = <
+				12 10 8 6
+			>;
+		};
+		CPU_COST_1: core-cost1 {
+			busy-cost-data = <
+				 300000    256
+				 403200    271
+				 480000    282
+				 576000    296
+				 652800    307
+				 748800    321
+				 825600    332
+				 902400    369
+				 979200    382
+				1056000    395
+				1132800    408
+				1209600    421
+				1286400    434
+				1363200    448
+				1459200    567
+				1536000    586
+				1612800    604
+				1689600    622
+				1766400    641
+				1843200    659
+				1920000    678
+				1996800    696
+				2092800    876
+				2169600    900
+				2246400    924
+				2323200    948
+				2400000   1170
+			>;
+			idle-cost-data = <
+				100 80 60 40
+			>;
+		};
+		CLUSTER_COST_0: cluster-cost0 {
+			busy-cost-data = <
+				 300000    5
+				 403200    7
+				 480000    7
+				 576000    7
+				 652800    8
+				 748800    8
+				 825600    9
+				 902400    9
+				 979200    9
+				1056000   10
+				1132800   10
+				1228800   10
+				1324800   13
+				1420800   14
+				1516800   15
+				1612800   16
+				1689600   19
+				1766400   19
+			>;
+			idle-cost-data = <
+				4 3 2 1
+			>;
+		};
+		CLUSTER_COST_1: cluster-cost1 {
+			busy-cost-data = <
+				 300000    25
+				 403200    27
+				 480000    28
+				 576000    29
+				 652800    30
+				 748800    32
+				 825600    33
+				 902400    36
+				 979200    38
+				1056000    39
+				1132800    40
+				1209600    42
+				1286400    43
+				1363200    44
+				1459200    56
+				1536000    58
+				1612800    60
+				1689600    62
+				1766400    64
+				1843200    65
+				1920000    67
+				1996800    69
+				2092800    87
+				2169600    90
+				2246400    92
+				2323200    94
+				2400000   117
+			>;
+			idle-cost-data = <
+				4 3 2 1
+			>;
+		};
+	};
+
 	psci {
 		compatible = "arm,psci-1.0";
 		method = "smc";
@@ -367,24 +542,6 @@
 			reg = <0 0x93d00000 0 0x1e00000>;
 		};
 
-		pil_ipa_fw_mem: pil_ipa_fw_region@95b00000 {
-			compatible = "removed-dma-pool";
-			no-map;
-			reg = <0 0x95b00000 0 0x10000>;
-		};
-
-		pil_ipa_gsi_mem: pil_ipa_gsi_region@95b10000 {
-			compatible = "removed-dma-pool";
-			no-map;
-			reg = <0 0x95b10000 0 0x5000>;
-		};
-
-		pil_gpu_mem: pil_gpu_region@95b15000 {
-			compatible = "removed-dma-pool";
-			no-map;
-			reg = <0 0x95b15000 0 0x1000>;
-		};
-
 		adsp_mem: adsp_region {
 			compatible = "shared-dma-pool";
 			alloc-ranges = <0 0x00000000 0 0xffffffff>;
@@ -417,6 +574,12 @@
 			size = <0 0x5c00000>;
 		};
 
+		dump_mem: mem_dump_region {
+			compatible = "shared-dma-pool";
+			reusable;
+			size = <0 0x2400000>;
+		};
+
 		/* global autoconfigured region for contiguous allocations */
 		linux,cma {
 			compatible = "shared-dma-pool";
@@ -435,12 +598,108 @@
 
 #include "sdm670-qupv3.dtsi"
 
+#include "sdm670-coresight.dtsi"
+
+#include "sdm670-vidc.dtsi"
+
+#include "sdm670-sde-pll.dtsi"
+
+#include "sdm670-sde.dtsi"
+
 &soc {
 	#address-cells = <1>;
 	#size-cells = <1>;
 	ranges = <0 0 0 0xffffffff>;
 	compatible = "simple-bus";
 
+	jtag_mm0: jtagmm@7040000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7040000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU0>;
+	};
+
+	jtag_mm1: jtagmm@7140000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7140000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qom,coresight-jtagmm-cpu = <&CPU1>;
+	};
+
+	jtag_mm2: jtagmm@7240000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7240000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU2>;
+	};
+
+	jtag_mm3: jtagmm@7340000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7340000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU3>;
+	};
+
+	jtag_mm4: jtagmm@7440000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7440000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU4>;
+	};
+
+	jtag_mm5: jtagmm@7540000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7540000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU5>;
+	};
+
+	jtag_mm6: jtagmm@7640000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7640000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU6>;
+	};
+
+	jtag_mm7: jtagmm@7740000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7740000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU7>;
+	};
+
 	intc: interrupt-controller@17a00000 {
 		compatible = "arm,gic-v3";
 		#interrupt-cells = <3>;
@@ -467,302 +726,16 @@
 		qcom,pipe-attr-ee;
 	};
 
-	thermal_zones: thermal-zones {
-		aoss0-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-governor = "user_space";
-			thermal-sensors = <&tsens0 0>;
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu0-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-governor = "user_space";
-			thermal-sensors = <&tsens0 1>;
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu1-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-governor = "user_space";
-			thermal-sensors = <&tsens0 2>;
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu2-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-governor = "user_space";
-			thermal-sensors = <&tsens0 3>;
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu3-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 4>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu4-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 5>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu5-silver-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 6>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		kryo-l3-0-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 7>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		kryo-l3-1-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 8>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu0-gold-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 9>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		cpu1-gold-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 10>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		gpu0-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens0 11>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		gpu1-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-governor = "user_space";
-			thermal-sensors = <&tsens0 12>;
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		aoss1-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 0>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		mdm-dsp-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 1>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		ddr-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 2>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		wlan-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 3>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		compute-hvx-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 4>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		camera-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 5>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		mmss-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 6>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
-
-		mdm-core-usr {
-			polling-delay-passive = <0>;
-			polling-delay = <0>;
-			thermal-sensors = <&tsens1 7>;
-			thermal-governor = "user_space";
-			trips {
-				active-config0 {
-					temperature = <125000>;
-					hysteresis = <1000>;
-					type = "passive";
-				};
-			};
-		};
+	qcom,qbt1000 {
+		compatible = "qcom,qbt1000";
+		clock-names = "core", "iface";
+		clock-frequency = <25000000>;
+		qcom,ipc-gpio = <&tlmm 121 0>;
+		qcom,finger-detect-gpio = <&tlmm 122 0>;
 	};
 
+	thermal_zones: thermal-zones {};
+
 	tsens0: tsens@c222000 {
 		compatible = "qcom,tsens24xx";
 		reg = <0xc222000 0x4>,
@@ -858,53 +831,90 @@
 	};
 
 	clock_rpmh: qcom,rpmhclk {
-		compatible = "qcom,dummycc";
-		clock-output-names = "rpmh_clocks";
+		compatible = "qcom,rpmh-clk-sdm670";
 		#clock-cells = <1>;
+		mboxes = <&apps_rsc 0>;
+		mbox-names = "apps";
 	};
 
 	clock_gcc: qcom,gcc@100000 {
-		compatible = "qcom,dummycc";
-		clock-output-names = "gcc_clocks";
+		compatible = "qcom,gcc-sdm670", "syscon";
+		reg = <0x100000 0x1f0000>;
+		reg-names = "cc_base";
+		vdd_cx-supply = <&pm660l_s3_level>;
+		vdd_cx_ao-supply = <&pm660l_s3_level_ao>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
 	clock_videocc: qcom,videocc@ab00000 {
-		compatible = "qcom,dummycc";
-		clock-output-names = "videocc_clocks";
+		compatible = "qcom,video_cc-sdm670", "syscon";
+		reg = <0xab00000 0x10000>;
+		reg-names = "cc_base";
+		vdd_cx-supply = <&pm660l_s3_level>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
 	clock_camcc: qcom,camcc@ad00000 {
-		compatible = "qcom,dummycc";
-		clock-output-names = "camcc_clocks";
+		compatible = "qcom,cam_cc-sdm670", "syscon";
+		reg = <0xad00000 0x10000>;
+		reg-names = "cc_base";
+		vdd_cx-supply = <&pm660l_s3_level>;
+		vdd_mx-supply = <&pm660l_s1_level>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
 	clock_dispcc: qcom,dispcc@af00000 {
-		compatible = "qcom,dummycc";
-		clock-output-names = "dispcc_clocks";
+		compatible = "qcom,dispcc-sdm670", "syscon";
+		reg = <0xaf00000 0x10000>;
+		reg-names = "cc_base";
+		vdd_cx-supply = <&pm660l_s3_level>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
 	clock_gpucc: qcom,gpucc@5090000 {
-		compatible = "qcom,dummycc";
-		clock-output-names = "gpucc_clocks";
+		compatible = "qcom,gpucc-sdm670", "syscon";
+		reg = <0x5090000 0x9000>;
+		reg-names = "cc_base";
+		vdd_cx-supply = <&pm660l_s3_level>;
+		vdd_mx-supply = <&pm660l_s1_level>;
+		qcom,gpu_cc_gmu_clk_src-opp-handle = <&gmu>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
 	clock_gfx: qcom,gfxcc@5090000  {
-		compatible = "qcom,dummycc";
-		clock-output-names = "gfxcc_clocks";
+		compatible = "qcom,gfxcc-sdm670";
+		reg = <0x5090000 0x9000>;
+		reg-names = "cc_base";
+		vdd_gfx-supply = <&pm660l_s2_level>;
+		qcom,gpu_cc_gx_gfx3d_clk_src-opp-handle = <&msm_gpu>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 	};
 
+	cpucc_debug: syscon@17970018 {
+		compatible = "syscon";
+		reg = <0x17970018 0x4>;
+	};
+
+	clock_debug: qcom,cc-debug {
+		compatible = "qcom,debugcc-sdm845";
+		qcom,cc-count = <5>;
+		qcom,gcc = <&clock_gcc>;
+		qcom,videocc = <&clock_videocc>;
+		qcom,camcc = <&clock_camcc>;
+		qcom,dispcc = <&clock_dispcc>;
+		qcom,gpucc = <&clock_gpucc>;
+		qcom,cpucc = <&cpucc_debug>;
+		clock-names = "xo_clk_src";
+		clocks = <&clock_rpmh RPMH_CXO_CLK>;
+		#clock-cells = <1>;
+	};
+
 	clock_cpucc: qcom,cpucc {
 		compatible = "qcom,dummycc";
 		clock-output-names = "cpucc_clocks";
@@ -913,7 +923,7 @@
 	};
 
 	clock_aop: qcom,aopclk {
-		compatible = "qcom,aop-qmp-clk-v2";
+		compatible = "qcom,aop-qmp-clk-v1";
 		#clock-cells = <1>;
 		mboxes = <&qmp_aop 0>;
 		mbox-names = "qdss_clk";
@@ -930,6 +940,16 @@
 		qcom,apps-ch-pipes = <0x780000>;
 		qcom,ea-pc = <0x290>;
 		status = "disabled";
+		qcom,iommu-s1-bypass;
+
+		iommu_slim_aud_ctrl_cb: qcom,iommu_slim_ctrl_cb {
+			compatible = "qcom,iommu-slim-ctrl-cb";
+			iommus = <&apps_smmu 0x1826 0x0>,
+				 <&apps_smmu 0x182d 0x0>,
+				 <&apps_smmu 0x182e 0x1>,
+				 <&apps_smmu 0x1830 0x1>;
+		};
+
 	};
 
 	slim_qca: slim@62e40000 {
@@ -941,6 +961,13 @@
 		interrupts = <0 291 0>, <0 292 0>;
 		interrupt-names = "slimbus_irq", "slimbus_bam_irq";
 		status = "disabled";
+		qcom,iommu-s1-bypass;
+
+		iommu_slim_qca_ctrl_cb: qcom,iommu_slim_ctrl_cb {
+			compatible = "qcom,iommu-slim-ctrl-cb";
+			iommus = <&apps_smmu 0x1833 0x0>;
+		};
+
 	};
 
 	wdog: qcom,wdt@17980000{
@@ -985,6 +1012,16 @@
 			compatible = "qcom,msm-imem-kaslr_offset";
 			reg = <0x6d0 12>;
 		};
+
+		boot_stats@6b0 {
+			compatible = "qcom,msm-imem-boot_stats";
+			reg = <0x6b0 0x20>;
+		};
+
+		diag_dload@c8 {
+			compatible = "qcom,msm-imem-diag-dload";
+			reg = <0xc8 0xc8>;
+		};
 	};
 
 	gpi_dma0: qcom,gpi-dma@0x800000 {
@@ -1025,31 +1062,31 @@
 			qcom,dump-node = <&L1_I_0>;
 			qcom,dump-id = <0x60>;
 		};
-		qcom,l1_i_cache1 {
+		qcom,l1_i_cache100 {
 			qcom,dump-node = <&L1_I_100>;
 			qcom,dump-id = <0x61>;
 		};
-		qcom,l1_i_cache2 {
+		qcom,l1_i_cache200 {
 			qcom,dump-node = <&L1_I_200>;
 			qcom,dump-id = <0x62>;
 		};
-		qcom,l1_i_cache3 {
+		qcom,l1_i_cache300 {
 			qcom,dump-node = <&L1_I_300>;
 			qcom,dump-id = <0x63>;
 		};
-		qcom,l1_i_cache100 {
+		qcom,l1_i_cache400 {
 			qcom,dump-node = <&L1_I_400>;
 			qcom,dump-id = <0x64>;
 		};
-		qcom,l1_i_cache101 {
+		qcom,l1_i_cache500 {
 			qcom,dump-node = <&L1_I_500>;
 			qcom,dump-id = <0x65>;
 		};
-		qcom,l1_i_cache102 {
+		qcom,l1_i_cache600 {
 			qcom,dump-node = <&L1_I_600>;
 			qcom,dump-id = <0x66>;
 		};
-		qcom,l1_i_cache103 {
+		qcom,l1_i_cache700 {
 			qcom,dump-node = <&L1_I_700>;
 			qcom,dump-id = <0x67>;
 		};
@@ -1057,31 +1094,31 @@
 			qcom,dump-node = <&L1_D_0>;
 			qcom,dump-id = <0x80>;
 		};
-		qcom,l1_d_cache1 {
+		qcom,l1_d_cache100 {
 			qcom,dump-node = <&L1_D_100>;
 			qcom,dump-id = <0x81>;
 		};
-		qcom,l1_d_cache2 {
+		qcom,l1_d_cache200 {
 			qcom,dump-node = <&L1_D_200>;
 			qcom,dump-id = <0x82>;
 		};
-		qcom,l1_d_cache3 {
+		qcom,l1_d_cache300 {
 			qcom,dump-node = <&L1_D_300>;
 			qcom,dump-id = <0x83>;
 		};
-		qcom,l1_d_cache100 {
+		qcom,l1_d_cache400 {
 			qcom,dump-node = <&L1_D_400>;
 			qcom,dump-id = <0x84>;
 		};
-		qcom,l1_d_cache101 {
+		qcom,l1_d_cache500 {
 			qcom,dump-node = <&L1_D_500>;
 			qcom,dump-id = <0x85>;
 		};
-		qcom,l1_d_cache102 {
+		qcom,l1_d_cache600 {
 			qcom,dump-node = <&L1_D_600>;
 			qcom,dump-id = <0x86>;
 		};
-		qcom,l1_d_cache103 {
+		qcom,l1_d_cache700 {
 			qcom,dump-node = <&L1_D_700>;
 			qcom,dump-id = <0x87>;
 		};
@@ -1093,6 +1130,93 @@
 			qcom,dump-node = <&LLCC_2>;
 			qcom,dump-id = <0x141>;
 		};
+		qcom,l1_tlb_dump0 {
+			qcom,dump-node = <&L1_TLB_0>;
+			qcom,dump-id = <0x20>;
+		};
+		qcom,l1_tlb_dump100 {
+			qcom,dump-node = <&L1_TLB_100>;
+			qcom,dump-id = <0x21>;
+		};
+		qcom,l1_tlb_dump200 {
+			qcom,dump-node = <&L1_TLB_200>;
+			qcom,dump-id = <0x22>;
+		};
+		qcom,l1_tlb_dump300 {
+			qcom,dump-node = <&L1_TLB_300>;
+			qcom,dump-id = <0x23>;
+		};
+		qcom,l1_tlb_dump400 {
+			qcom,dump-node = <&L1_TLB_400>;
+			qcom,dump-id = <0x24>;
+		};
+		qcom,l1_tlb_dump500 {
+			qcom,dump-node = <&L1_TLB_500>;
+			qcom,dump-id = <0x25>;
+		};
+		qcom,l1_tlb_dump600 {
+			qcom,dump-node = <&L1_TLB_600>;
+			qcom,dump-id = <0x26>;
+		};
+		qcom,l1_tlb_dump700 {
+			qcom,dump-node = <&L1_TLB_700>;
+			qcom,dump-id = <0x27>;
+		};
+	};
+
+	mem_dump {
+		compatible = "qcom,mem-dump";
+		memory-region = <&dump_mem>;
+
+		rpmh_dump {
+			qcom,dump-size = <0x2000000>;
+			qcom,dump-id = <0xec>;
+		};
+
+		rpm_sw_dump {
+			qcom,dump-size = <0x28000>;
+			qcom,dump-id = <0xea>;
+		};
+
+		pmic_dump {
+			qcom,dump-size = <0x10000>;
+			qcom,dump-id = <0xe4>;
+		};
+
+		tmc_etf_dump {
+			qcom,dump-size = <0x10000>;
+			qcom,dump-id = <0xf0>;
+		};
+
+		tmc_etf_swao_dump {
+			qcom,dump-size = <0x8400>;
+			qcom,dump-id = <0xf1>;
+		};
+
+		tmc_etr_reg_dump {
+			qcom,dump-size = <0x1000>;
+			qcom,dump-id = <0x100>;
+		};
+
+		tmc_etf_reg_dump {
+			qcom,dump-size = <0x1000>;
+			qcom,dump-id = <0x101>;
+		};
+
+		tmc_etf_swao_reg_dump {
+			qcom,dump-size = <0x1000>;
+			qcom,dump-id = <0x102>;
+		};
+
+		misc_data_dump {
+			qcom,dump-size = <0x1000>;
+			qcom,dump-id = <0xe8>;
+		};
+
+		power_regs_data_dump {
+			qcom,dump-size = <0x100000>;
+			qcom,dump-id = <0xed>;
+		};
 	};
 
 	kryo3xx-erp {
@@ -1357,6 +1481,15 @@
 		interrupts = <0 17 0>;
 	};
 
+	eud: qcom,msm-eud@88e0000 {
+		compatible = "qcom,msm-eud";
+		interrupt-names = "eud_irq";
+		interrupts = <GIC_SPI 492 IRQ_TYPE_LEVEL_HIGH>;
+		reg = <0x88e0000 0x2000>;
+		reg-names = "eud_base";
+		status = "disabled";
+	};
+
 	qcom,llcc@1100000 {
 		compatible = "qcom,llcc-core", "syscon", "simple-mfd";
 		reg = <0x1100000 0x250000>;
@@ -1431,6 +1564,8 @@
 		reg = <0x10a2000 0x1000>,
 		      <0x10ae000 0x2000>;
 		reg-names = "dcc-base", "dcc-ram-base";
+
+		dcc-ram-offset = <0x6000>;
 	};
 
 	spmi_bus: qcom,spmi@c440000 {
@@ -1507,6 +1642,44 @@
 			<0 0>,
 			<0 0>;
 
+		qcom,msm-bus,name = "ufshc_mem";
+		qcom,msm-bus,num-cases = <12>;
+		qcom,msm-bus,num-paths = <2>;
+		qcom,msm-bus,vectors-KBps =
+		/*
+		 * During HS G3 UFS runs at nominal voltage corner, vote
+		 * higher bandwidth to push other buses in the data path
+		 * to run at nominal to achieve max throughput.
+		 * 4GBps pushes BIMC to run at nominal.
+		 * 200MBps pushes CNOC to run at nominal.
+		 * Vote for half of this bandwidth for HS G3 1-lane.
+		 * For max bandwidth, vote high enough to push the buses
+		 * to run in turbo voltage corner.
+		 */
+		<123 512 0 0>, <1 757 0 0>,          /* No vote */
+		<123 512 922 0>, <1 757 1000 0>,     /* PWM G1 */
+		<123 512 1844 0>, <1 757 1000 0>,    /* PWM G2 */
+		<123 512 3688 0>, <1 757 1000 0>,    /* PWM G3 */
+		<123 512 7376 0>, <1 757 1000 0>,    /* PWM G4 */
+		<123 512 127796 0>, <1 757 1000 0>,  /* HS G1 RA */
+		<123 512 255591 0>, <1 757 1000 0>,  /* HS G2 RA */
+		<123 512 2097152 0>, <1 757 102400 0>,  /* HS G3 RA */
+		<123 512 149422 0>, <1 757 1000 0>,  /* HS G1 RB */
+		<123 512 298189 0>, <1 757 1000 0>,  /* HS G2 RB */
+		<123 512 2097152 0>, <1 757 102400 0>,  /* HS G3 RB */
+		<123 512 7643136 0>, <1 757 307200 0>; /* Max. bandwidth */
+
+		qcom,bus-vector-names = "MIN",
+		"PWM_G1_L1", "PWM_G2_L1", "PWM_G3_L1", "PWM_G4_L1",
+		"HS_RA_G1_L1", "HS_RA_G2_L1", "HS_RA_G3_L1",
+		"HS_RB_G1_L1", "HS_RB_G2_L1", "HS_RB_G3_L1",
+		"MAX";
+
+		/* PM QoS */
+		qcom,pm-qos-cpu-groups = <0x3f 0xC0>;
+		qcom,pm-qos-cpu-group-latency-us = <70 70>;
+		qcom,pm-qos-default-cpu = <0>;
+
 		resets = <&clock_gcc GCC_UFS_PHY_BCR>;
 		reset-names = "core_reset";
 
@@ -1545,6 +1718,13 @@
 		status = "ok";
 	};
 
+	qcom,rmtfs_sharedmem@0 {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0 0x200000>;
+		reg-names = "rmtfs";
+		qcom,client-id = <0x00000001>;
+	};
+
 	qcom,rmnet-ipa {
 		compatible = "qcom,rmnet-ipa3";
 		qcom,rmnet-ipa-ssr;
@@ -1585,17 +1765,17 @@
 			<90 512 80000 640000>,
 			<90 585 80000 640000>,
 			<1 676 80000 80000>,
-			<143 777 0 150000>,
+			<143 777 0 150>, /* IB defined for IPA clk in MHz*/
 		/* NOMINAL */
 			<90 512 206000 960000>,
 			<90 585 206000 960000>,
 			<1 676 206000 160000>,
-			<143 777 0 300000>,
+			<143 777 0 300>, /* IB defined for IPA clk in MHz*/
 		/* TURBO */
 			<90 512 206000 3600000>,
 			<90 585 206000 3600000>,
 			<1 676 206000 300000>,
-			<143 777 0 355333>;
+			<143 777 0 355>; /* IB defined for IPA clk in MHz*/
 		qcom,bus-vector-names = "MIN", "SVS", "NOMINAL", "TURBO";
 
 		/* IPA RAM mmap */
@@ -1750,6 +1930,7 @@
 		qcom,ssctl-instance-id = <0x12>;
 		qcom,override-acc;
 		qcom,qdsp6v65-1-0;
+		qcom,mss_pdc_offset = <8>;
 		status = "ok";
 		memory-region = <&pil_modem_mem>;
 		qcom,mem-protect-id = <0xF>;
@@ -1838,9 +2019,58 @@
 		qcom,bus-width = <8>;
 		qcom,large-address-bus;
 
+		qcom,clk-rates = <400000 20000000 25000000 50000000 100000000
+						192000000 384000000>;
+		qcom,bus-speed-mode = "HS400_1p8v", "HS200_1p8v", "DDR_1p8v";
+
+		qcom,devfreq,freq-table = <50000000 200000000>;
+
+		qcom,msm-bus,name = "sdhc1";
+		qcom,msm-bus,num-cases = <9>;
+		qcom,msm-bus,num-paths = <2>;
+		qcom,msm-bus,vectors-KBps =
+			/* No vote */
+			<78 512 0 0>, <1 606 0 0>,
+			/* 400 KB/s*/
+			<78 512 1046 1600>,
+			<1 606 1600 1600>,
+			/* 20 MB/s */
+			<78 512 52286 80000>,
+			<1 606 80000 80000>,
+			/* 25 MB/s */
+			<78 512 65360 100000>,
+			<1 606 100000 100000>,
+			/* 50 MB/s */
+			<78 512 130718 200000>,
+			<1 606 133320 133320>,
+			/* 100 MB/s */
+			<78 512 130718 200000>,
+			<1 606 150000 150000>,
+			/* 200 MB/s */
+			<78 512 261438 400000>,
+			<1 606 300000 300000>,
+			/* 400 MB/s */
+			<78 512 261438 400000>,
+			<1 606 300000 300000>,
+			/* Max. bandwidth */
+			<78 512 1338562 4096000>,
+			<1 606 1338562 4096000>;
+		qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
+			100000000 200000000 400000000 4294967295>;
+
+		/* PM QoS */
+		qcom,pm-qos-irq-type = "affine_irq";
+		qcom,pm-qos-irq-latency = <70 70>;
+		qcom,pm-qos-cpu-groups = <0x3f 0xc0>;
+		qcom,pm-qos-cmdq-latency-us = <70 70>, <70 70>;
+		qcom,pm-qos-legacy-latency-us = <70 70>, <70 70>;
+
 		clocks = <&clock_gcc GCC_SDCC1_AHB_CLK>,
-			<&clock_gcc GCC_SDCC1_APPS_CLK>;
-		clock-names = "iface_clk", "core_clk";
+			<&clock_gcc GCC_SDCC1_APPS_CLK>,
+			<&clock_gcc GCC_SDCC1_ICE_CORE_CLK>;
+		clock-names = "iface_clk", "core_clk", "ice_core_clk";
+
+		qcom,ice-clk-rates = <300000000 75000000>;
 
 		qcom,nonremovable;
 
@@ -1848,6 +2078,67 @@
 		status = "disabled";
 	};
 
+	sdhc_2: sdhci@8804000 {
+		compatible = "qcom,sdhci-msm-v5";
+		reg = <0x8804000 0x1000>;
+		reg-names = "hc_mem";
+
+		interrupts = <0 204 0>, <0 222 0>;
+		interrupt-names = "hc_irq", "pwr_irq";
+
+		qcom,bus-width = <4>;
+		qcom,large-address-bus;
+
+		qcom,clk-rates = <400000 20000000 25000000
+					50000000 100000000 201500000>;
+		qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50",
+				      "SDR104";
+
+		qcom,devfreq,freq-table = <50000000 201500000>;
+
+		qcom,msm-bus,name = "sdhc2";
+		qcom,msm-bus,num-cases = <8>;
+		qcom,msm-bus,num-paths = <2>;
+		qcom,msm-bus,vectors-KBps =
+			/* No vote */
+			<81 512 0 0>, <1 608 0 0>,
+			/* 400 KB/s*/
+			<81 512 1046 1600>,
+			<1 608 1600 1600>,
+			/* 20 MB/s */
+			<81 512 52286 80000>,
+			<1 608 80000 80000>,
+			/* 25 MB/s */
+			<81 512 65360 100000>,
+			<1 608 100000 100000>,
+			/* 50 MB/s */
+			<81 512 130718 200000>,
+			<1 608 133320 133320>,
+			/* 100 MB/s */
+			<81 512 261438 200000>,
+			<1 608 150000 150000>,
+			/* 200 MB/s */
+			<81 512 261438 400000>,
+			<1 608 300000 300000>,
+			/* Max. bandwidth */
+			<81 512 1338562 4096000>,
+			<1 608 1338562 4096000>;
+		qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
+			100000000 200000000 4294967295>;
+
+		/* PM QoS */
+		qcom,pm-qos-irq-type = "affine_irq";
+		qcom,pm-qos-irq-latency = <70 70>;
+		qcom,pm-qos-cpu-groups = <0x3f 0xc0>;
+		qcom,pm-qos-legacy-latency-us = <70 70>, <70 70>;
+
+		clocks = <&clock_gcc GCC_SDCC2_AHB_CLK>,
+			<&clock_gcc GCC_SDCC2_APPS_CLK>;
+		clock-names = "iface_clk", "core_clk";
+
+		status = "disabled";
+	};
+
 	qcom,msm-cdsp-loader {
 		compatible = "qcom,cdsp-loader";
 		qcom,proc-img-to-load = "cdsp";
@@ -1930,8 +2221,213 @@
 			dma-coherent;
 		};
 	};
+
+	qcom,icnss@18800000 {
+		status = "disabled";
+		compatible = "qcom,icnss";
+		reg = <0x18800000 0x800000>;
+		interrupts = <0 414 0 /* CE0 */ >,
+			     <0 415 0 /* CE1 */ >,
+			     <0 416 0 /* CE2 */ >,
+			     <0 417 0 /* CE3 */ >,
+			     <0 418 0 /* CE4 */ >,
+			     <0 419 0 /* CE5 */ >,
+			     <0 420 0 /* CE6 */ >,
+			     <0 421 0 /* CE7 */ >,
+			     <0 422 0 /* CE8 */ >,
+			     <0 423 0 /* CE9 */ >,
+			     <0 424 0 /* CE10 */ >,
+			     <0 425 0 /* CE11 */ >;
+		qcom,wlan-msa-memory = <0x100000>;
+		qcom,smmu-s1-bypass;
+	};
+
+	cpubw: qcom,cpubw {
+		compatible = "qcom,devbw";
+		governor = "performance";
+		qcom,src-dst-ports =
+			<MSM_BUS_MASTER_AMPSS_M0 MSM_BUS_SLAVE_EBI_CH0>;
+		qcom,active-only;
+		qcom,bw-tbl =
+			< MHZ_TO_MBPS( 100, 4) >, /* 381 MB/s */
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1353, 4) >, /* 5161 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
+	};
+
+	bwmon: qcom,cpu-bwmon {
+		compatible = "qcom,bimc-bwmon4";
+		reg = <0x1436400 0x300>, <0x1436300 0x200>;
+		reg-names = "base", "global_base";
+		interrupts = <0 581 4>;
+		qcom,mport = <0>;
+		qcom,hw-timer-hz = <19200000>;
+		qcom,target-dev = <&cpubw>;
+	};
+
+	memlat_cpu0: qcom,memlat-cpu0 {
+		compatible = "qcom,devbw";
+		governor = "powersave";
+		qcom,src-dst-ports = <1 512>;
+		qcom,active-only;
+		qcom,bw-tbl =
+			< MHZ_TO_MBPS( 100, 4) >, /* 381 MB/s */
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1353, 4) >, /* 5161 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
+	};
+
+	memlat_cpu4: qcom,memlat-cpu4 {
+		compatible = "qcom,devbw";
+		governor = "powersave";
+		qcom,src-dst-ports = <1 512>;
+		qcom,active-only;
+		status = "ok";
+		qcom,bw-tbl =
+			< MHZ_TO_MBPS( 100, 4) >, /* 381 MB/s */
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1353, 4) >, /* 5161 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
+	};
+
+	devfreq_memlat_0: qcom,cpu0-memlat-mon {
+		compatible = "qcom,arm-memlat-mon";
+		qcom,cpulist = <&CPU0 &CPU1 &CPU2 &CPU3>;
+		qcom,target-dev = <&memlat_cpu0>;
+		qcom,cachemiss-ev = <0x24>;
+		qcom,core-dev-table =
+			<  748800 MHZ_TO_MBPS( 300, 4) >,
+			<  998400 MHZ_TO_MBPS( 451, 4) >,
+			< 1209600 MHZ_TO_MBPS( 547, 4) >,
+			< 1497600 MHZ_TO_MBPS( 768, 4) >,
+			< 1728000 MHZ_TO_MBPS(1017, 4) >;
+	};
+
+	devfreq_memlat_4: qcom,cpu4-memlat-mon {
+		compatible = "qcom,arm-memlat-mon";
+		qcom,cpulist = <&CPU4 &CPU5 &CPU6 &CPU7>;
+		qcom,target-dev = <&memlat_cpu4>;
+		qcom,cachemiss-ev = <0x24>;
+		qcom,core-dev-table =
+			<  787200 MHZ_TO_MBPS( 300, 4) >,
+			< 1113600 MHZ_TO_MBPS( 547, 4) >,
+			< 1344000 MHZ_TO_MBPS(1017, 4) >,
+			< 1900800 MHZ_TO_MBPS(1555, 4) >,
+			< 2438400 MHZ_TO_MBPS(1804, 4) >;
+	};
+
+	l3_cpu0: qcom,l3-cpu0 {
+		compatible = "devfreq-simple-dev";
+		clock-names = "devfreq_clk";
+		clocks = <&clock_cpucc L3_CLUSTER0_VOTE_CLK>;
+		governor = "performance";
+	};
+
+	l3_cpu4: qcom,l3-cpu4 {
+		compatible = "devfreq-simple-dev";
+		clock-names = "devfreq_clk";
+		clocks = <&clock_cpucc L3_CLUSTER1_VOTE_CLK>;
+		governor = "performance";
+	};
+
+	devfreq_l3lat_0: qcom,cpu0-l3lat-mon {
+		compatible = "qcom,arm-memlat-mon";
+		qcom,cpulist = <&CPU0 &CPU1 &CPU2 &CPU3>;
+		qcom,target-dev = <&l3_cpu0>;
+		qcom,cachemiss-ev = <0x17>;
+		qcom,core-dev-table =
+			<  748800  566400000 >,
+			<  998400  787200000 >,
+			< 1209660  940800000 >,
+			< 1497600 1190400000 >,
+			< 1612800 1382400000 >,
+			< 1728000 1440000000 >;
+	};
+
+	devfreq_l3lat_4: qcom,cpu4-l3lat-mon {
+		compatible = "qcom,arm-memlat-mon";
+		qcom,cpulist = <&CPU4 &CPU5 &CPU6 &CPU7>;
+		qcom,target-dev = <&l3_cpu4>;
+		qcom,cachemiss-ev = <0x17>;
+		qcom,core-dev-table =
+			< 1113600  566400000 >,
+			< 1344000  787200000 >,
+			< 1728000  940800000 >,
+			< 1900800 1190400000 >,
+			< 2438400 1440000000 >;
+	};
+
+	mincpubw: qcom,mincpubw {
+		compatible = "qcom,devbw";
+		governor = "powersave";
+		qcom,src-dst-ports = <1 512>;
+		qcom,active-only;
+		qcom,bw-tbl =
+			< MHZ_TO_MBPS( 100, 4) >, /* 381 MB/s */
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1353, 4) >, /* 5161 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
+	};
+
+	devfreq-cpufreq {
+		mincpubw-cpufreq {
+			target-dev = <&mincpubw>;
+			cpu-to-dev-map-0 =
+				<  748800 MHZ_TO_MBPS( 300, 4) >,
+				< 1209600 MHZ_TO_MBPS( 451, 4) >,
+				< 1612000 MHZ_TO_MBPS( 547, 4) >,
+				< 1728000 MHZ_TO_MBPS( 768, 4) >;
+			cpu-to-dev-map-4 =
+				< 1113600 MHZ_TO_MBPS( 300, 4) >,
+				< 1344000 MHZ_TO_MBPS( 547, 4) >,
+				< 1728000 MHZ_TO_MBPS( 768, 4) >,
+				< 1900800 MHZ_TO_MBPS(1017, 4) >,
+				< 2438400 MHZ_TO_MBPS(1804, 4) >;
+		};
+	};
+
+	gpu_gx_domain_addr: syscon@0x5091508 {
+		compatible = "syscon";
+		reg = <0x5091508 0x4>;
+	};
+
+	gpu_gx_sw_reset: syscon@0x5091008 {
+		compatible = "syscon";
+		reg = <0x5091008 0x4>;
+	};
 };
 
+#include "pm660.dtsi"
+#include "pm660l.dtsi"
+#include "sdm670-regulator.dtsi"
 #include "sdm670-pinctrl.dtsi"
 #include "msm-arm-smmu-sdm670.dtsi"
 #include "msm-gdsc-sdm845.dtsi"
@@ -2006,6 +2502,9 @@
 	clocks = <&clock_gfx GPU_CC_GX_GFX3D_CLK_SRC>;
 	qcom,force-enable-root-clk;
 	parent-supply = <&pm660l_s2_level>;
+	domain-addr = <&gpu_gx_domain_addr>;
+	sw-reset = <&gpu_gx_sw_reset>;
+	qcom,reset-aon-logic;
 	status = "ok";
 };
 
@@ -2023,7 +2522,40 @@
 	status = "ok";
 };
 
-#include "pm660.dtsi"
-#include "pm660l.dtsi"
-#include "sdm670-regulator.dtsi"
+&mdss_dsi0 {
+	qcom,core-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,core-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "refgen";
+			qcom,supply-min-voltage = <0>;
+			qcom,supply-max-voltage = <0>;
+			qcom,supply-enable-load = <0>;
+			qcom,supply-disable-load = <0>;
+		};
+	};
+};
+
+&mdss_dsi1 {
+	qcom,core-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,core-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "refgen";
+			qcom,supply-min-voltage = <0>;
+			qcom,supply-max-voltage = <0>;
+			qcom,supply-enable-load = <0>;
+			qcom,supply-disable-load = <0>;
+		};
+	};
+};
+
 #include "sdm670-audio.dtsi"
+#include "sdm670-usb.dtsi"
+#include "sdm670-gpu.dtsi"
+#include "sdm670-thermal.dtsi"
+#include "sdm670-bus.dtsi"
diff --git a/arch/arm64/boot/dts/qcom/sdm845-audio-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm845-audio-overlay.dtsi
index 9bd1d54..9d485b5 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-audio-overlay.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-audio-overlay.dtsi
@@ -47,6 +47,8 @@
 
 	qcom,msm-mbhc-hphl-swh = <1>;
 	qcom,msm-mbhc-gnd-swh = <1>;
+	qcom,msm-mbhc-hs-mic-max-threshold-mv = <1700>;
+	qcom,msm-mbhc-hs-mic-min-threshold-mv = <50>;
 	qcom,hph-en0-gpio = <&tavil_hph_en0>;
 	qcom,hph-en1-gpio = <&tavil_hph_en1>;
 	qcom,tavil-mclk-clk-freq = <9600000>;
@@ -175,7 +177,7 @@
 			compatible = "qcom,wcd-spi-v2";
 			qcom,master-bus-num = <0>;
 			qcom,chip-select = <0>;
-			qcom,max-frequency = <9600000>;
+			qcom,max-frequency = <24000000>;
 			qcom,mem-base-addr = <0x100000>;
 		};
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-bus.dtsi b/arch/arm64/boot/dts/qcom/sdm845-bus.dtsi
index 5fbb1db..cf7ccae 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-bus.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-bus.dtsi
@@ -645,7 +645,10 @@
 			qcom,qport = <2>;
 			qcom,connections = <&slv_qns_a2noc_snoc>;
 			qcom,bus-dev = <&fab_aggre2_noc>;
+			qcom,ap-owned;
 			qcom,prio = <2>;
+			qcom,defer-init-qos;
+			qcom,node-qos-bcms = <7035 0 1>;
 		};
 
 		mas_xm_pcie3_1: mas-xm-pcie3-1 {
@@ -900,7 +903,7 @@
 			qcom,bus-dev = <&fab_mem_noc>;
 			qcom,bcms = <&bcm_sh3>;
 			qcom,ap-owned;
-			qcom,prio = <6>;
+			qcom,prio = <7>;
 		};
 
 		mas_qhm_memnoc_cfg: mas-qhm-memnoc-cfg {
diff --git a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-cdp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-cdp.dtsi
index 9d799cb..04418d4 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-cdp.dtsi
@@ -111,7 +111,7 @@
 		rgltr-min-voltage = <2800000>;
 		rgltr-max-voltage = <2800000>;
 		rgltr-load-current = <0>;
-		status = "disabled";
+		status = "ok";
 	};
 
 	eeprom_rear: qcom,eeprom@0 {
@@ -376,4 +376,47 @@
 		clock-cntl-level = "turbo";
 		clock-rates = <24000000>;
 	};
+
+	qcom,cam-sensor@3 {
+		cell-index = <3>;
+		compatible = "qcom,cam-sensor";
+		reg = <0x03>;
+		csiphy-sd-index = <3>;
+		sensor-position-roll = <270>;
+		sensor-position-pitch = <0>;
+		sensor-position-yaw = <0>;
+		cam_vio-supply = <&pm8998_lvs1>;
+		cam_vana-supply = <&pmi8998_bob>;
+		cam_vdig-supply = <&camera_ldo>;
+		cam_clk-supply = <&titan_top_gdsc>;
+		regulator-names = "cam_vio", "cam_vana", "cam_vdig",
+			"cam_clk";
+		rgltr-cntrl-support;
+		rgltr-min-voltage = <0 3312000 1050000 0>;
+		rgltr-max-voltage = <0 3600000 1050000 0>;
+		rgltr-load-current = <0 80000 105000 0>;
+		gpio-no-mux = <0>;
+		pinctrl-names = "cam_default", "cam_suspend";
+		pinctrl-0 = <&cam_sensor_mclk3_active
+				 &cam_sensor_iris_active>;
+		pinctrl-1 = <&cam_sensor_mclk3_suspend
+				 &cam_sensor_iris_suspend>;
+		gpios = <&tlmm 16 0>,
+			<&tlmm 9 0>,
+			<&tlmm 8 0>;
+		gpio-reset = <1>;
+		gpio-vana = <2>;
+		gpio-req-tbl-num = <0 1 2>;
+		gpio-req-tbl-flags = <1 0 0>;
+		gpio-req-tbl-label = "CAMIF_MCLK3",
+					"CAM_RESET3",
+					"CAM_VANA1";
+		sensor-mode = <0>;
+		cci-master = <1>;
+		status = "ok";
+		clocks = <&clock_camcc CAM_CC_MCLK3_CLK>;
+		clock-names = "cam_clk";
+		clock-cntl-level = "turbo";
+		clock-rates = <24000000>;
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
index f18137c..9088fac 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
@@ -111,7 +111,7 @@
 		rgltr-min-voltage = <2800000>;
 		rgltr-max-voltage = <2800000>;
 		rgltr-load-current = <0>;
-		status = "disabled";
+		status = "ok";
 	};
 
 	eeprom_rear: qcom,eeprom@0 {
@@ -376,4 +376,47 @@
 		clock-cntl-level = "turbo";
 		clock-rates = <24000000>;
 	};
+	qcom,cam-sensor@3 {
+		cell-index = <3>;
+		compatible = "qcom,cam-sensor";
+		reg = <0x03>;
+		csiphy-sd-index = <3>;
+		sensor-position-roll = <270>;
+		sensor-position-pitch = <0>;
+		sensor-position-yaw = <0>;
+		cam_vio-supply = <&pm8998_lvs1>;
+		cam_vana-supply = <&pmi8998_bob>;
+		cam_vdig-supply = <&camera_ldo>;
+		cam_clk-supply = <&titan_top_gdsc>;
+		regulator-names = "cam_vio", "cam_vana", "cam_vdig",
+			"cam_clk";
+		rgltr-cntrl-support;
+		rgltr-min-voltage = <0 3312000 1050000 0>;
+		rgltr-max-voltage = <0 3600000 1050000 0>;
+		rgltr-load-current = <0 80000 105000 0>;
+		gpio-no-mux = <0>;
+		pinctrl-names = "cam_default", "cam_suspend";
+		pinctrl-0 = <&cam_sensor_mclk3_active
+				 &cam_sensor_iris_active>;
+		pinctrl-1 = <&cam_sensor_mclk3_suspend
+				 &cam_sensor_iris_suspend>;
+		gpios = <&tlmm 16 0>,
+			<&tlmm 9 0>,
+			<&tlmm 8 0>;
+		gpio-reset = <1>;
+		gpio-vana = <2>;
+		gpio-req-tbl-num = <0 1 2>;
+		gpio-req-tbl-flags = <1 0 0>;
+		gpio-req-tbl-label = "CAMIF_MCLK3",
+					"CAM_RESET3",
+					"CAM_VANA1";
+		sensor-mode = <0>;
+		cci-master = <1>;
+		status = "ok";
+		clocks = <&clock_camcc CAM_CC_MCLK3_CLK>;
+		clock-names = "cam_clk";
+		clock-cntl-level = "turbo";
+		clock-rates = <24000000>;
+	};
+
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi b/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
index f54cbdc..7c9482c 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
@@ -325,11 +325,17 @@
 
 		msm_cam_smmu_secure {
 			compatible = "qcom,msm-cam-smmu-cb";
-			iommus = <&apps_smmu 0x1001 0x0>;
 			label = "cam-secure";
-			cam_secure_iova_mem_map: iova-mem-map {
-				/* Secure IO region is approximately 3.4 GB */
+			qcom,secure-cb;
+		};
+
+		msm_cam_smmu_fd {
+			compatible = "qcom,msm-cam-smmu-cb";
+			iommus = <&apps_smmu 0x1070 0x0>;
+			label = "fd";
+			fd_iova_mem_map: iova-mem-map {
 				iova-mem-region-io {
+					/* IO region is approximately 3.4 GB */
 					iova-region-name = "io";
 					iova-region-start = <0x7400000>;
 					iova-region-len = <0xd8c00000>;
@@ -811,7 +817,6 @@
 			"soc_ahb_clk",
 			"cpas_ahb_clk",
 			"camnoc_axi_clk",
-			"icp_apb_clk",
 			"icp_clk",
 			"icp_clk_src";
 		clocks = <&clock_gcc GCC_CAMERA_AHB_CLK>,
@@ -820,11 +825,10 @@
 				<&clock_camcc CAM_CC_SOC_AHB_CLK>,
 				<&clock_camcc CAM_CC_CPAS_AHB_CLK>,
 				<&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
-				<&clock_camcc CAM_CC_ICP_APB_CLK>,
 				<&clock_camcc CAM_CC_ICP_CLK>,
 				<&clock_camcc CAM_CC_ICP_CLK_SRC>;
 
-		clock-rates = <0 0 400000000 0 0 0 0 0 600000000>;
+		clock-rates = <0 0 400000000 0 0 0 0 600000000>;
 		clock-cntl-level = "turbo";
 		fw_name = "CAMERA_ICP.elf";
 		status = "ok";
@@ -840,14 +844,20 @@
 			"ipe_0_axi_clk",
 			"ipe_0_clk",
 			"ipe_0_clk_src";
+		src-clock-name = "ipe_0_clk_src";
 		clocks = <&clock_camcc CAM_CC_IPE_0_AHB_CLK>,
 				<&clock_camcc CAM_CC_IPE_0_AREG_CLK>,
 				<&clock_camcc CAM_CC_IPE_0_AXI_CLK>,
 				<&clock_camcc CAM_CC_IPE_0_CLK>,
 				<&clock_camcc CAM_CC_IPE_0_CLK_SRC>;
 
-		clock-rates = <0 0 0 0 600000000>;
-		clock-cntl-level = "turbo";
+		clock-rates = <0 0 0 0 240000000>,
+			<0 0 0 0 404000000>,
+			<0 0 0 0 480000000>,
+			<0 0 0 0 538000000>,
+			<0 0 0 0 600000000>;
+		clock-cntl-level = "lowsvs", "svs",
+			"svs_l1", "nominal", "turbo";
 		status = "ok";
 	};
 
@@ -861,14 +871,20 @@
 			"ipe_1_axi_clk",
 			"ipe_1_clk",
 			"ipe_1_clk_src";
+		src-clock-name = "ipe_1_clk_src";
 		clocks = <&clock_camcc CAM_CC_IPE_1_AHB_CLK>,
 				<&clock_camcc CAM_CC_IPE_1_AREG_CLK>,
 				<&clock_camcc CAM_CC_IPE_1_AXI_CLK>,
 				<&clock_camcc CAM_CC_IPE_1_CLK>,
 				<&clock_camcc CAM_CC_IPE_1_CLK_SRC>;
 
-		clock-rates = <0 0 0 0 600000000>;
-		clock-cntl-level = "turbo";
+		clock-rates = <0 0 0 0 240000000>,
+			<0 0 0 0 404000000>,
+			<0 0 0 0 480000000>,
+			<0 0 0 0 538000000>,
+			<0 0 0 0 600000000>;
+		clock-cntl-level = "lowsvs", "svs",
+			"svs_l1", "nominal", "turbo";
 		status = "ok";
 	};
 
@@ -882,14 +898,20 @@
 			"bps_axi_clk",
 			"bps_clk",
 			"bps_clk_src";
+		src-clock-name = "bps_clk_src";
 		clocks = <&clock_camcc CAM_CC_BPS_AHB_CLK>,
 				<&clock_camcc CAM_CC_BPS_AREG_CLK>,
 				<&clock_camcc CAM_CC_BPS_AXI_CLK>,
 				<&clock_camcc CAM_CC_BPS_CLK>,
 				<&clock_camcc CAM_CC_BPS_CLK_SRC>;
 
-		clock-rates = <0 0 0 0 600000000>;
-		clock-cntl-level = "turbo";
+		clock-rates = <0 0 0 0 200000000>,
+			<0 0 0 0 404000000>,
+			<0 0 0 0 480000000>,
+			<0 0 0 0 600000000>,
+			<0 0 0 0 600000000>;
+		clock-cntl-level = "lowsvs", "svs",
+			"svs_l1", "nominal", "turbo";
 		status = "ok";
 	};
 
@@ -964,4 +986,43 @@
 		status = "ok";
 	};
 
+	qcom,cam-fd {
+		compatible = "qcom,cam-fd";
+		compat-hw-name = "qcom,fd";
+		num-fd = <1>;
+		status = "ok";
+	};
+
+	cam_fd: qcom,fd@ac5a000 {
+		cell-index = <0>;
+		compatible = "qcom,fd41";
+		reg-names = "fd_core", "fd_wrapper";
+		reg = <0xac5a000 0x1000>,
+			<0xac5b000 0x400>;
+		reg-cam-base = <0x5a000 0x5b000>;
+		interrupt-names = "fd";
+		interrupts = <0 462 0>;
+		regulator-names = "camss-vdd";
+		camss-vdd-supply = <&titan_top_gdsc>;
+		clock-names = "gcc_ahb_clk",
+			"gcc_axi_clk",
+			"soc_ahb_clk",
+			"cpas_ahb_clk",
+			"camnoc_axi_clk",
+			"fd_core_clk_src",
+			"fd_core_clk",
+			"fd_core_uar_clk";
+		clocks = <&clock_gcc GCC_CAMERA_AHB_CLK>,
+			<&clock_gcc GCC_CAMERA_AXI_CLK>,
+			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
+			<&clock_camcc CAM_CC_CPAS_AHB_CLK>,
+			<&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
+			<&clock_camcc CAM_CC_FD_CORE_CLK_SRC>,
+			<&clock_camcc CAM_CC_FD_CORE_CLK>,
+			<&clock_camcc CAM_CC_FD_CORE_UAR_CLK>;
+		src-clock-name = "fd_core_clk_src";
+		clock-cntl-level = "svs";
+		clock-rates = <0 0 0 0 0 400000000 0 0>;
+		status = "ok";
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
index dddf1fb..81ce1e5 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
@@ -110,6 +110,7 @@
 	vdd-hba-supply = <&ufs_phy_gdsc>;
 	vdd-hba-fixed-regulator;
 	vcc-supply = <&pm8998_l20>;
+	vcc-voltage-level = <2950000 2960000>;
 	vccq2-supply = <&pm8998_s4>;
 	vcc-max-microamp = <600000>;
 	vccq2-max-microamp = <600000>;
@@ -120,44 +121,6 @@
 	status = "ok";
 };
 
-&extcon_storage_cd {
-	gpio = <&tlmm 126 GPIO_ACTIVE_LOW>;
-	debounce-ms = <200>;
-	irq-flags = <IRQ_TYPE_EDGE_BOTH>;
-
-	pinctrl-names = "default";
-	pinctrl-0 = <&storage_cd>;
-
-	status = "ok";
-};
-
-&ufsphy_card {
-	compatible = "qcom,ufs-phy-qmp-v3";
-
-	vdda-phy-supply = <&pm8998_l1>; /* 0.88v */
-	vdda-pll-supply = <&pm8998_l26>; /* 1.2v */
-	vdda-phy-max-microamp = <62900>;
-	vdda-pll-max-microamp = <18300>;
-
-	status = "ok";
-};
-
-&ufshc_card {
-	vdd-hba-supply = <&ufs_card_gdsc>;
-	vdd-hba-fixed-regulator;
-	vcc-supply = <&pm8998_l21>;
-	vccq2-supply = <&pm8998_s4>;
-	vcc-max-microamp = <300000>;
-	vccq2-max-microamp = <300000>;
-
-	qcom,vddp-ref-clk-supply = <&pm8998_l2>;
-	qcom,vddp-ref-clk-max-microamp = <100>;
-
-	extcon = <&extcon_storage_cd>;
-
-	status = "ok";
-};
-
 &sdhc_2 {
 	vdd-supply = <&pm8998_l21>;
 	qcom,vdd-voltage-level = <2950000 2960000>;
@@ -168,10 +131,10 @@
 	qcom,vdd-io-current-level = <200 22000>;
 
 	pinctrl-names = "active", "sleep";
-	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on>;
-	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
+	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on &storage_cd>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &storage_cd>;
 
-	extcon = <&extcon_storage_cd>;
+	cd-gpios = <&tlmm 126 GPIO_ACTIVE_LOW>;
 
 	status = "ok";
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-coresight.dtsi b/arch/arm64/boot/dts/qcom/sdm845-coresight.dtsi
index c1fcb62..a61d96e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-coresight.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-coresight.dtsi
@@ -12,6 +12,16 @@
 
 &soc {
 
+	csr: csr@6001000 {
+		compatible = "qcom,coresight-csr";
+		reg = <0x6001000 0x1000>;
+		reg-names = "csr-base";
+
+		coresight-name = "coresight-csr";
+
+		qcom,blk-size = <1>;
+	};
+
 	replicator_qdss: replicator@6046000 {
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b909>;
@@ -271,6 +281,9 @@
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
 
+		interrupts = <GIC_SPI 270 IRQ_TYPE_EDGE_RISING>;
+		interrupt-names = "byte-cntr-irq";
+
 		port {
 			tmc_etr_in_replicator: endpoint {
 				slave-mode;
@@ -397,16 +410,6 @@
 		clock-names = "apb_pclk";
 	};
 
-	csr: csr@6001000 {
-		compatible = "qcom,coresight-csr";
-		reg = <0x6001000 0x1000>;
-		reg-names = "csr-base";
-
-		coresight-name = "coresight-csr";
-
-		qcom,blk-size = <1>;
-	};
-
 	funnel_in0: funnel@0x6041000 {
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b908>;
@@ -522,6 +525,58 @@
 				};
 			};
 
+			port@5 {
+				reg = <6>;
+				funnel_in2_in_funnel_gfx: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&funnel_gfx_out_funnel_in2>;
+				};
+			};
+		};
+	};
+
+	funnel_gfx: funnel@0x6943000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b908>;
+
+		reg = <0x6943000 0x1000>;
+		reg-names = "funnel-base";
+
+		coresight-name = "coresight-funnel-gfx";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				funnel_gfx_out_funnel_in2: endpoint {
+					remote-endpoint =
+					  <&funnel_in2_in_funnel_gfx>;
+				};
+			};
+
+			port@1 {
+				reg = <0>;
+				funnel_in2_in_gfx: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&gfx_out_funnel_in2>;
+				};
+			};
+
+			port@2 {
+				reg = <1>;
+				funnel_in2_in_gfx_cx: endpoint {
+					slave-mode;
+					remote-endpoint =
+					  <&gfx_cx_out_funnel_in2>;
+				};
+			};
 		};
 	};
 
@@ -1430,6 +1485,15 @@
 						<&tpda_spss_out_funnel_spss>;
 				};
 			};
+
+			port@2 {
+				reg = <1>;
+				funnel_spss_in_spss_etm0: endpoint {
+					slave-mode;
+					remote-endpoint =
+						<&spss_etm0_out_funnel_spss>;
+				};
+			};
 		};
 	};
 
@@ -1492,7 +1556,7 @@
 		reg = <0x69e1000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti0-ddr0";
+		coresight-name = "coresight-cti-DDR_DL_0_CTI";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1504,7 +1568,7 @@
 		reg = <0x69e4000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti0-ddr1";
+		coresight-name = "coresight-cti-DDR_DL_1_CTI0";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1516,7 +1580,7 @@
 		reg = <0x69e5000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti1-ddr1";
+		coresight-name = "coresight-cti-DDR_DL_1_CTI1";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1528,7 +1592,7 @@
 		reg = <0x6c09000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti0-dlmm";
+		coresight-name = "coresight-cti-DLMM_CTI0";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1540,7 +1604,43 @@
 		reg = <0x6c0a000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti1-dlmm";
+		coresight-name = "coresight-cti-DLMM_CTI1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti0_apss: cti@78e0000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x78e0000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-APSS_CTI0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti1_apss: cti@78f0000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x78f0000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-APSS_CTI1";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	cti2_apss: cti@7900000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b966>;
+		reg = <0x7900000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-name = "coresight-cti-APSS_CTI2";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1868,7 +1968,23 @@
 		reg = <0x6b04000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-name = "coresight-cti0-swao";
+		coresight-name = "coresight-cti-SWAO_CTI0";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "apb_pclk";
+	};
+
+	 ipcb_tgu: tgu@6b0c000 {
+		compatible = "arm,primecell";
+		arm,primecell-periphid = <0x0003b999>;
+		reg = <0x06B0C000 0x1000>;
+		reg-names = "tgu-base";
+		tgu-steps = <3>;
+		tgu-conditions = <4>;
+		tgu-regs = <4>;
+		tgu-timer-counters = <8>;
+
+		coresight-name = "coresight-tgu-ipcb";
 
 		clocks = <&clock_aop QDSS_CLK>;
 		clock-names = "apb_pclk";
@@ -1931,6 +2047,20 @@
 		};
 	};
 
+	spss_etm0 {
+		compatible = "qcom,coresight-dummy";
+
+		coresight-name = "coresight-spss-etm0";
+
+		qcom,dummy-source;
+		port {
+			spss_etm0_out_funnel_spss: endpoint {
+				remote-endpoint =
+					<&funnel_spss_in_spss_etm0>;
+			};
+		};
+	};
+
 	funnel_apss_merg: funnel@7810000 {
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b908>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-gpu.dtsi b/arch/arm64/boot/dts/qcom/sdm845-gpu.dtsi
index 19d69e9..11b6a4d 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-gpu.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-gpu.dtsi
@@ -75,6 +75,8 @@
 		qcom,tsens-name = "tsens_tz_sensor12";
 		#cooling-cells = <2>;
 
+		qcom,pm-qos-active-latency = <460>;
+
 		clocks = <&clock_gfx GPU_CC_GX_GFX3D_CLK>,
 			<&clock_gpucc GPU_CC_CXO_CLK>,
 			<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
@@ -120,6 +122,36 @@
 		cache-slice-names = "gpu", "gpuhtw";
 		cache-slices = <&llcc 12>, <&llcc 11>;
 
+		qcom,gpu-coresights {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "qcom,gpu-coresight";
+
+			qcom,gpu-coresight@0 {
+				reg = <0>;
+				coresight-name = "coresight-gfx";
+				coresight-atid = <50>;
+				port {
+					gfx_out_funnel_in2: endpoint {
+						remote-endpoint =
+						  <&funnel_in2_in_gfx>;
+					};
+				};
+			};
+
+			qcom,gpu-coresight@1 {
+				reg = <1>;
+				coresight-name = "coresight-gfx-cx";
+				coresight-atid = <51>;
+				port {
+					gfx_cx_out_funnel_in2: endpoint {
+						remote-endpoint =
+						  <&funnel_in2_in_gfx_cx>;
+					};
+				};
+			};
+		};
+
 		/* GPU Mempools */
 		qcom,gpu-mempools {
 			#address-cells = <1>;
@@ -264,14 +296,8 @@
 		label = "kgsl-gmu";
 		compatible = "qcom,gpu-gmu";
 
-		reg =
-			<0x506a000 0x31000>,
-			<0xb200000 0x300000>,
-			<0xc200000 0x10000>;
-		reg-names =
-			"kgsl_gmu_reg",
-			"kgsl_gmu_pdc_reg",
-			"kgsl_gmu_cpr_reg";
+		reg = <0x506a000 0x30000>, <0xb200000 0x300000>;
+		reg-names = "kgsl_gmu_reg", "kgsl_gmu_pdc_reg";
 
 		interrupts = <0 304 0>, <0 305 0>;
 		interrupt-names = "kgsl_hfi_irq", "kgsl_gmu_irq";
@@ -303,9 +329,10 @@
 
 			compatible = "qcom,gmu-pwrlevels";
 
+			/* GMU power levels must go from lowest to highest */
 			qcom,gmu-pwrlevel@0 {
 				reg = <0>;
-				qcom,gmu-freq = <400000000>;
+				qcom,gmu-freq = <0>;
 			};
 
 			qcom,gmu-pwrlevel@1 {
@@ -315,7 +342,7 @@
 
 			qcom,gmu-pwrlevel@2 {
 				reg = <2>;
-				qcom,gmu-freq = <0>;
+				qcom,gmu-freq = <400000000>;
 			};
 		};
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-pm660.dtsi b/arch/arm64/boot/dts/qcom/sdm845-interposer-pm660.dtsi
index cac5bc0..cc609aa 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-pm660.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-pm660.dtsi
@@ -84,17 +84,6 @@
 	/delete-property/ qcom,vddp-ref-clk-supply;
 };
 
-&ufsphy_card {
-	/delete-property/ vdda-phy-supply;
-	/delete-property/ vdda-pll-supply;
-};
-
-&ufshc_card {
-	/delete-property/ vcc-supply;
-	/delete-property/ vccq2-supply;
-	/delete-property/ qcom,vddp-ref-clk-supply;
-};
-
 &sdhc_2 {
 	/delete-property/ vdd-supply;
 	/delete-property/ vdd-io-supply;
@@ -129,6 +118,12 @@
 	/delete-property/ vreg-cx-supply;
 };
 
+&pcie1 {
+	/delete-property/ vreg-1.8-supply;
+	/delete-property/ vreg-0.9-supply;
+	/delete-property/ vreg-cx-supply;
+};
+
 &cam_csiphy0 {
 	/delete-property/ mipi-csi-vdd-supply;
 };
@@ -188,6 +183,12 @@
 		/delete-property/ cam_vio-supply;
 		/delete-property/ cam_vana-supply;
 	};
+
+	qcom,cam-sensor@3 {
+		/delete-property/ cam_vio-supply;
+		/delete-property/ cam_vana-supply;
+	};
+
 };
 
 &clock_gcc {
@@ -210,11 +211,11 @@
 
 &clock_gpucc {
 	/delete-property/ vdd_cx-supply;
+	/delete-property/ vdd_mx-supply;
 };
 
 &clock_gfx {
 	/delete-property/ vdd_gfx-supply;
-	/delete-property/ vdd_mx-supply;
 };
 
 &pil_modem {
@@ -383,6 +384,7 @@
 #include "pm660.dtsi"
 #include "pm660l.dtsi"
 #include "sdm670-regulator.dtsi"
+#include "sdm670-pmic-overlay.dtsi"
 
 &soc {
 	/delete-node/ thermal-zones;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio-overlay.dtsi
new file mode 100644
index 0000000..54bd5201
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio-overlay.dtsi
@@ -0,0 +1,53 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+#include "sdm670-audio-overlay.dtsi"
+
+&pm660l_3 {
+	/delete-node/analog-codec;
+};
+
+&soc {
+	/delete-node/msm-sdw-codec@62ec1000;
+	/delete-node/cdc_pdm_pinctrl;
+	/delete-node/wsa_spkr_en1_pinctrl;
+	/delete-node/wsa_spkr_en2_pinctrl;
+	/delete-node/sdw_clk_data_pinctrl;
+};
+
+&qupv3_se8_spi {
+	status = "okay";
+};
+
+&wcd9xxx_intc {
+	status = "okay";
+	qcom,gpio-connect = <&tlmm 54 0>;
+};
+
+&wdsp_mgr {
+	status = "okay";
+};
+
+&wdsp_glink {
+	status = "okay";
+};
+
+&wcd934x_cdc {
+	status = "okay";
+};
+
+&clock_audio_lnbb {
+	status = "okay";
+};
+
+&wcd_rst_gpio {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio.dtsi b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio.dtsi
index f861ca3..88892d7 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-audio.dtsi
@@ -10,44 +10,17 @@
  * GNU General Public License for more details.
  */
 
-#include "sdm670-audio.dtsi"
 
 &msm_audio_ion {
 	iommus = <&apps_smmu 0x1821 0x0>;
 	qcom,smmu-sid-mask = /bits/ 64 <0xf>;
 };
 
-&qupv3_se8_spi {
-	status = "okay";
-};
-
-&pm660l_3 {
-	/delete-node/analog-codec;
-};
-
 &soc {
-	/delete-node/msm-sdw-codec@62ec1000;
 	/delete-node/sound;
-	/delete-node/cdc_pdm_pinctrl;
-	/delete-node/wsa_spkr_en1_pinctrl;
-	/delete-node/wsa_spkr_en2_pinctrl;
-	/delete-node/sdw_clk_data_pinctrl;
 };
 
-&msm_audio_ion {
-	iommus = <&apps_smmu 0x1821 0x0>;
-};
-
-&wcd9xxx_intc {
-	status = "okay";
-	qcom,gpio-connect = <&tlmm 54 0>;
-};
-
-&wdsp_mgr {
-	status = "okay";
-};
-
-&wdsp_glink {
+&tavil_snd {
 	status = "okay";
 };
 
@@ -58,24 +31,3 @@
 &dai_slim {
 	status = "okay";
 };
-
-&wcd934x_cdc {
-	status = "okay";
-};
-
-&clock_audio_lnbb {
-	status = "okay";
-};
-
-&wcd_rst_gpio {
-	status = "okay";
-};
-
-&wcd9xxx_intc {
-	status = "okay";
-};
-
-&tavil_snd {
-	status = "okay";
-};
-
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp-overlay.dts
index da59bcf..9d61324 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp-overlay.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp-overlay.dts
@@ -21,7 +21,7 @@
 
 #include "sdm845-sde-display.dtsi"
 #include "sdm845-interposer-sdm670-cdp.dtsi"
-
+#include "sdm845-interposer-sdm670-audio-overlay.dtsi"
 / {
 	model = "Qualcomm Technologies, Inc. SDM845 v1 Interposer SDM670 CDP";
 	compatible = "qcom,sdm845-cdp", "qcom,sdm845", "qcom,cdp";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dts b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dts
index ebb5e8f..597773e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dts
@@ -16,6 +16,8 @@
 #include "sdm845-interposer-sdm670.dtsi"
 #include "sdm845-sde-display.dtsi"
 #include "sdm845-interposer-sdm670-cdp.dtsi"
+#include "sdm670-audio.dtsi"
+#include "sdm845-interposer-sdm670-audio.dtsi"
 
 / {
 	model = "Qualcomm Technologies, Inc. MSM sdm845 v1 Interposer SDM670 CDP";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dtsi
index ad15615..1265d2a 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-cdp.dtsi
@@ -12,4 +12,28 @@
 
 #include "sdm845-cdp.dtsi"
 #include "sdm845-interposer-pm660.dtsi"
-#include "sdm845-interposer-sdm670-audio.dtsi"
+
+&soc {
+	/delete-node/ ssusb@a800000;
+	/delete-node/ qusb@88e3000;
+	/delete-node/ ssphy@88eb000;
+};
+
+&usb0 {
+	extcon = <&pm660_pdphy>, <&pm660_pdphy>, <0> /* <&eud> */;
+};
+
+&qusb_phy0 {
+	vdd-supply = <&pm660l_l1>;
+	vdda18-supply = <&pm660_l10>;
+	vdda33-supply = <&pm660l_l7>;
+};
+
+&usb_qmp_dp_phy {
+	vdd-supply = <&pm660l_l1>; /* 0.88v */
+	core-supply = <&pm660_l1>; /* 1.2v */
+};
+
+&pcie0 {
+	status = "disabled";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp-overlay.dts
index 3ca15b9..1690174 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp-overlay.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp-overlay.dts
@@ -21,7 +21,7 @@
 
 #include "sdm845-sde-display.dtsi"
 #include "sdm845-interposer-sdm670-mtp.dtsi"
-
+#include "sdm845-interposer-sdm670-audio-overlay.dtsi"
 / {
 	model = "Qualcomm Technologies, Inc. SDM845 v1 Interposer SDM670 MTP";
 	compatible = "qcom,sdm845-mtp", "qcom,sdm845", "qcom,mtp";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dts b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dts
index 39664f1..52869da 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dts
@@ -16,6 +16,8 @@
 #include "sdm845-interposer-sdm670.dtsi"
 #include "sdm845-sde-display.dtsi"
 #include "sdm845-interposer-sdm670-mtp.dtsi"
+#include "sdm670-audio.dtsi"
+#include "sdm845-interposer-sdm670-audio.dtsi"
 
 / {
 	model = "Qualcomm Technologies, Inc. MSM sdm845 v1 Interposer SDM670 MTP";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dtsi
index c709770..9d722df 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-interposer-sdm670-mtp.dtsi
@@ -12,8 +12,33 @@
 
 #include "sdm845-mtp.dtsi"
 #include "sdm845-interposer-pm660.dtsi"
-#include "sdm845-interposer-sdm670-audio.dtsi"
 
 &qupv3_se10_i2c {
 	/delete-node/ qcom,smb1355@8;
+	/delete-node/ qcom,smb1355@c;
+};
+
+&soc {
+	/delete-node/ ssusb@a800000;
+	/delete-node/ qusb@88e3000;
+	/delete-node/ ssphy@88eb000;
+};
+
+&usb0 {
+	extcon = <&pm660_pdphy>, <&pm660_pdphy>, <0> /* <&eud> */;
+};
+
+&qusb_phy0 {
+	vdd-supply = <&pm660l_l1>;
+	vdda18-supply = <&pm660_l10>;
+	vdda33-supply = <&pm660l_l7>;
+};
+
+&usb_qmp_dp_phy {
+	vdd-supply = <&pm660l_l1>; /* 0.88v */
+	core-supply = <&pm660_l1>; /* 1.2v */
+};
+
+&pcie0 {
+	status = "disabled";
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
index 3d58dc1..f0d16ec 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
@@ -198,6 +198,7 @@
 	vdd-hba-supply = <&ufs_phy_gdsc>;
 	vdd-hba-fixed-regulator;
 	vcc-supply = <&pm8998_l20>;
+	vcc-voltage-level = <2950000 2960000>;
 	vccq2-supply = <&pm8998_s4>;
 	vcc-max-microamp = <600000>;
 	vccq2-max-microamp = <600000>;
@@ -208,44 +209,6 @@
 	status = "ok";
 };
 
-&extcon_storage_cd {
-	gpio = <&tlmm 126 GPIO_ACTIVE_LOW>;
-	debounce-ms = <200>;
-	irq-flags = <IRQ_TYPE_EDGE_BOTH>;
-
-	pinctrl-names = "default";
-	pinctrl-0 = <&storage_cd>;
-
-	status = "ok";
-};
-
-&ufsphy_card {
-	compatible = "qcom,ufs-phy-qmp-v3";
-
-	vdda-phy-supply = <&pm8998_l1>; /* 0.88v */
-	vdda-pll-supply = <&pm8998_l26>; /* 1.2v */
-	vdda-phy-max-microamp = <62900>;
-	vdda-pll-max-microamp = <18300>;
-
-	status = "ok";
-};
-
-&ufshc_card {
-	vdd-hba-supply = <&ufs_card_gdsc>;
-	vdd-hba-fixed-regulator;
-	vcc-supply = <&pm8998_l21>;
-	vccq2-supply = <&pm8998_s4>;
-	vcc-max-microamp = <300000>;
-	vccq2-max-microamp = <300000>;
-
-	qcom,vddp-ref-clk-supply = <&pm8998_l2>;
-	qcom,vddp-ref-clk-max-microamp = <100>;
-
-	extcon = <&extcon_storage_cd>;
-
-	status = "ok";
-};
-
 &sdhc_2 {
 	vdd-supply = <&pm8998_l21>;
 	qcom,vdd-voltage-level = <2950000 2960000>;
@@ -256,10 +219,10 @@
 	qcom,vdd-io-current-level = <200 22000>;
 
 	pinctrl-names = "active", "sleep";
-	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on>;
-	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
+	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on &storage_cd>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &storage_cd>;
 
-	extcon = <&extcon_storage_cd>;
+	cd-gpios = <&tlmm 126 GPIO_ACTIVE_LOW>;
 
 	status = "ok";
 };
@@ -291,7 +254,11 @@
 	qcom,battery-data = <&mtp_batterydata>;
 };
 
-&smb1355_charger {
+&smb1355_charger_0 {
+	status = "ok";
+};
+
+&smb1355_charger_1 {
 	status = "ok";
 };
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-pcie.dtsi b/arch/arm64/boot/dts/qcom/sdm845-pcie.dtsi
index c7a4d7d..322c5f5 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-pcie.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-pcie.dtsi
@@ -118,10 +118,9 @@
 					0x068 0x16 0x0
 					0x070 0x36 0x0
 					0x184 0x01 0x0
-					0x15c 0x16 0x0
 					0x138 0x33 0x0
 					0x03c 0x02 0x0
-					0x040 0x07 0x0
+					0x040 0x06 0x0
 					0x080 0x04 0x0
 					0x0dc 0x00 0x0
 					0x0d8 0x3f 0x0
@@ -138,7 +137,7 @@
 					0x260 0x10 0x0
 					0x28c 0x06 0x0
 					0x504 0x03 0x0
-					0x500 0x1c 0x0
+					0x500 0x10 0x0
 					0x50c 0x14 0x0
 					0x4d4 0x0e 0x0
 					0x4d8 0x04 0x0
@@ -155,7 +154,7 @@
 					0x43c 0x40 0x0
 					0x854 0x04 0x0
 					0x62c 0x52 0x0
-					0x654 0x50 0x0
+					0x654 0x10 0x0
 					0x65c 0x1a 0x0
 					0x660 0x06 0x0
 					0x8c8 0x83 0x0
@@ -170,7 +169,7 @@
 					0x9a8 0x00 0x0
 					0x8a4 0x01 0x0
 					0x8a8 0x73 0x0
-					0x9d8 0xaa 0x0
+					0x9d8 0xbb 0x0
 					0x9b0 0x03 0x0
 					0xa0c 0x0d 0x0
 					0x86c 0x00 0x0
@@ -266,4 +265,337 @@
 		reset-names = "pcie_0_core_reset",
 				"pcie_0_phy_reset";
 	};
+
+	pcie1: qcom,pcie@0x1c08000 {
+		compatible = "qcom,pci-msm";
+		cell-index = <1>;
+
+		reg = <0x1c08000 0x2000>,
+		      <0x1c0a000 0x2000>,
+		      <0x40000000 0xf1d>,
+		      <0x40000f20 0xa8>,
+		      <0x40100000 0x100000>,
+		      <0x40200000 0x100000>,
+		      <0x40300000 0x1fd00000>;
+
+		reg-names = "parf", "phy", "dm_core", "elbi",
+				"conf", "io", "bars";
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		ranges = <0x01000000 0x0 0x40200000 0x40200000 0x0 0x100000>,
+			<0x02000000 0x0 0x40300000 0x40300000 0x0 0x1fd00000>;
+		interrupt-parent = <&pcie1>;
+		interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+				20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
+				36 37>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0xffffffff>;
+		interrupt-map = <0 0 0 0 &intc 0 307 0
+				0 0 0 1 &intc 0 434 0
+				0 0 0 2 &intc 0 435 0
+				0 0 0 3 &intc 0 438 0
+				0 0 0 4 &intc 0 439 0
+				0 0 0 5 &intc 0 306 0
+				0 0 0 6 &intc 0 704 0
+				0 0 0 7 &intc 0 705 0
+				0 0 0 8 &intc 0 706 0
+				0 0 0 9 &intc 0 707 0
+				0 0 0 10 &intc 0 708 0
+				0 0 0 11 &intc 0 709 0
+				0 0 0 12 &intc 0 710 0
+				0 0 0 13 &intc 0 711 0
+				0 0 0 14 &intc 0 712 0
+				0 0 0 15 &intc 0 713 0
+				0 0 0 16 &intc 0 714 0
+				0 0 0 17 &intc 0 715 0
+				0 0 0 18 &intc 0 716 0
+				0 0 0 19 &intc 0 717 0
+				0 0 0 20 &intc 0 718 0
+				0 0 0 21 &intc 0 719 0
+				0 0 0 22 &intc 0 720 0
+				0 0 0 23 &intc 0 721 0
+				0 0 0 24 &intc 0 722 0
+				0 0 0 25 &intc 0 723 0
+				0 0 0 26 &intc 0 724 0
+				0 0 0 27 &intc 0 725 0
+				0 0 0 28 &intc 0 726 0
+				0 0 0 29 &intc 0 727 0
+				0 0 0 30 &intc 0 728 0
+				0 0 0 31 &intc 0 729 0
+				0 0 0 32 &intc 0 730 0
+				0 0 0 33 &intc 0 731 0
+				0 0 0 34 &intc 0 732 0
+				0 0 0 35 &intc 0 733 0
+				0 0 0 36 &intc 0 734 0
+				0 0 0 37 &intc 0 735 0>;
+
+		interrupt-names = "int_msi", "int_a", "int_b", "int_c",
+				"int_d", "int_global_int",
+				"msi_0", "msi_1", "msi_2", "msi_3",
+				"msi_4", "msi_5", "msi_6", "msi_7",
+				"msi_8", "msi_9", "msi_10", "msi_11",
+				"msi_12", "msi_13", "msi_14", "msi_15",
+				"msi_16", "msi_17", "msi_18", "msi_19",
+				"msi_20", "msi_21", "msi_22", "msi_23",
+				"msi_24", "msi_25", "msi_26", "msi_27",
+				"msi_28", "msi_29", "msi_30", "msi_31";
+
+		qcom,phy-sequence = <0x1804 0x03 0x0
+					0x00dc 0x27 0x0
+					0x0014 0x01 0x0
+					0x0020 0x31 0x0
+					0x0024 0x01 0x0
+					0x0028 0xde 0x0
+					0x002c 0x07 0x0
+					0x0034 0x4c 0x0
+					0x0038 0x06 0x0
+					0x0054 0x18 0x0
+					0x0058 0xb0 0x0
+					0x006c 0x8c 0x0
+					0x0070 0x20 0x0
+					0x0078 0x14 0x0
+					0x007c 0x34 0x0
+					0x00b4 0x06 0x0
+					0x00b8 0x06 0x0
+					0x00c0 0x16 0x0
+					0x00c4 0x16 0x0
+					0x00cc 0x36 0x0
+					0x00d0 0x36 0x0
+					0x00f0 0x05 0x0
+					0x00f8 0x42 0x0
+					0x0100 0x82 0x0
+					0x0108 0x68 0x0
+					0x011c 0x55 0x0
+					0x0120 0x55 0x0
+					0x0124 0x03 0x0
+					0x0128 0xab 0x0
+					0x012c 0xaa 0x0
+					0x0130 0x02 0x0
+					0x0150 0x3f 0x0
+					0x0158 0x3f 0x0
+					0x0178 0x10 0x0
+					0x01cc 0x04 0x0
+					0x01d0 0x30 0x0
+					0x01e0 0x04 0x0
+					0x01e8 0x73 0x0
+					0x01f0 0x1c 0x0
+					0x01fc 0x15 0x0
+					0x021c 0x04 0x0
+					0x0224 0x01 0x0
+					0x0228 0x22 0x0
+					0x022c 0x00 0x0
+					0x0098 0x05 0x0
+					0x080c 0x00 0x0
+					0x0818 0x0d 0x0
+					0x0860 0x01 0x0
+					0x0864 0x3a 0x0
+					0x087c 0x2f 0x0
+					0x08c0 0x09 0x0
+					0x08c4 0x09 0x0
+					0x08c8 0x1a 0x0
+					0x08d0 0x01 0x0
+					0x08d4 0x07 0x0
+					0x08d8 0x31 0x0
+					0x08dc 0x31 0x0
+					0x08e0 0x03 0x0
+					0x08fc 0x02 0x0
+					0x0900 0x01 0x0
+					0x0908 0x12 0x0
+					0x0914 0x25 0x0
+					0x0918 0x00 0x0
+					0x091c 0x05 0x0
+					0x0920 0x01 0x0
+					0x0924 0x26 0x0
+					0x0928 0x12 0x0
+					0x0930 0x04 0x0
+					0x0934 0x04 0x0
+					0x0938 0x09 0x0
+					0x0954 0x15 0x0
+					0x0960 0x32 0x0
+					0x0968 0x7f 0x0
+					0x096c 0x07 0x0
+					0x0978 0x04 0x0
+					0x0980 0x70 0x0
+					0x0984 0x8b 0x0
+					0x0988 0x08 0x0
+					0x098c 0x09 0x0
+					0x0990 0x03 0x0
+					0x0994 0x04 0x0
+					0x0998 0x02 0x0
+					0x099c 0x0c 0x0
+					0x09a4 0x02 0x0
+					0x09c0 0x5c 0x0
+					0x09c4 0x3e 0x0
+					0x09c8 0x3f 0x0
+					0x0a30 0x01 0x0
+					0x0a34 0xa0 0x0
+					0x0a38 0x08 0x0
+					0x0aa4 0x01 0x0
+					0x0aac 0xc3 0x0
+					0x0ab0 0x00 0x0
+					0x0ab8 0x8c 0x0
+					0x0ac0 0x7f 0x0
+					0x0ac4 0x2a 0x0
+					0x0810 0x0c 0x0
+					0x0814 0x00 0x0
+					0x0acc 0x04 0x0
+					0x093c 0x20 0x0
+					0x100c 0x00 0x0
+					0x1018 0x0d 0x0
+					0x1060 0x01 0x0
+					0x1064 0x3a 0x0
+					0x107c 0x2f 0x0
+					0x10c0 0x09 0x0
+					0x10c4 0x09 0x0
+					0x10c8 0x1a 0x0
+					0x10d0 0x01 0x0
+					0x10d4 0x07 0x0
+					0x10d8 0x31 0x0
+					0x10dc 0x31 0x0
+					0x10e0 0x03 0x0
+					0x10fc 0x02 0x0
+					0x1100 0x01 0x0
+					0x1108 0x12 0x0
+					0x1114 0x25 0x0
+					0x1118 0x00 0x0
+					0x111c 0x05 0x0
+					0x1120 0x01 0x0
+					0x1124 0x26 0x0
+					0x1128 0x12 0x0
+					0x1130 0x04 0x0
+					0x1134 0x04 0x0
+					0x1138 0x09 0x0
+					0x1154 0x15 0x0
+					0x1160 0x32 0x0
+					0x1168 0x7f 0x0
+					0x116c 0x07 0x0
+					0x1178 0x04 0x0
+					0x1180 0x70 0x0
+					0x1184 0x8b 0x0
+					0x1188 0x08 0x0
+					0x118c 0x09 0x0
+					0x1190 0x03 0x0
+					0x1194 0x04 0x0
+					0x1198 0x02 0x0
+					0x119c 0x0c 0x0
+					0x11a4 0x02 0x0
+					0x11c0 0x5c 0x0
+					0x11c4 0x3e 0x0
+					0x11c8 0x3f 0x0
+					0x1230 0x01 0x0
+					0x1234 0xa0 0x0
+					0x1238 0x08 0x0
+					0x12a4 0x01 0x0
+					0x12ac 0xc3 0x0
+					0x12b0 0x00 0x0
+					0x12b8 0x8c 0x0
+					0x12c0 0x7f 0x0
+					0x12c4 0x2a 0x0
+					0x1010 0x0c 0x0
+					0x1014 0x00 0x0
+					0x12cc 0x04 0x0
+					0x113c 0x20 0x0
+					0x195c 0x3f 0x0
+					0x1974 0x58 0x0
+					0x196c 0x9f 0x0
+					0x182c 0x19 0x0
+					0x1840 0x07 0x0
+					0x1854 0x17 0x0
+					0x1868 0x09 0x0
+					0x1800 0x00 0x0
+					0x0aa8 0x01 0x0
+					0x12a8 0x01 0x0
+					0x1808 0x01 0x0>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&pcie1_clkreq_default
+			&pcie1_perst_default
+			&pcie1_wake_default>;
+
+		perst-gpio = <&tlmm 102 0>;
+		wake-gpio = <&tlmm 104 0>;
+
+		gdsc-vdd-supply = <&pcie_1_gdsc>;
+		vreg-1.8-supply = <&pm8998_l26>;
+		vreg-0.9-supply = <&pm8998_l1>;
+		vreg-cx-supply = <&pm8998_s9_level>;
+
+		qcom,vreg-1.8-voltage-level = <1200000 1200000 24000>;
+		qcom,vreg-0.9-voltage-level = <880000 880000 24000>;
+		qcom,vreg-cx-voltage-level = <RPMH_REGULATOR_LEVEL_MAX
+						RPMH_REGULATOR_LEVEL_NOM 0>;
+
+		qcom,l1-supported;
+		qcom,l1ss-supported;
+		qcom,aux-clk-sync;
+
+		qcom,ep-latency = <10>;
+
+		qcom,slv-addr-space-size = <0x20000000>;
+
+		qcom,boot-option = <0x1>;
+
+		linux,pci-domain = <1>;
+
+		qcom,msi-gicm-addr = <0x17a00040>;
+		qcom,msi-gicm-base = <0x2e0>;
+
+		qcom,max-link-speed = <0x3>;
+
+		qcom,use-19p2mhz-aux-clk;
+
+		qcom,smmu-sid-base = <0x1c00>;
+
+		iommu-map = <0x100 &apps_smmu 0x1c01 0x1>,
+			<0x200 &apps_smmu 0x1c02 0x1>,
+			<0x300 &apps_smmu 0x1c03 0x1>,
+			<0x400 &apps_smmu 0x1c04 0x1>,
+			<0x500 &apps_smmu 0x1c05 0x1>,
+			<0x600 &apps_smmu 0x1c06 0x1>,
+			<0x700 &apps_smmu 0x1c07 0x1>,
+			<0x800 &apps_smmu 0x1c08 0x1>,
+			<0x900 &apps_smmu 0x1c09 0x1>,
+			<0xa00 &apps_smmu 0x1c0a 0x1>,
+			<0xb00 &apps_smmu 0x1c0b 0x1>,
+			<0xc00 &apps_smmu 0x1c0c 0x1>,
+			<0xd00 &apps_smmu 0x1c0d 0x1>,
+			<0xe00 &apps_smmu 0x1c0e 0x1>,
+			<0xf00 &apps_smmu 0x1c0f 0x1>;
+
+		qcom,msm-bus,name = "pcie1";
+		qcom,msm-bus,num-cases = <2>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+				<100 512 0 0>,
+				<100 512 500 800>;
+
+		clocks = <&clock_gcc GCC_PCIE_1_PIPE_CLK>,
+			<&clock_rpmh RPMH_CXO_CLK>,
+			<&clock_gcc GCC_PCIE_1_AUX_CLK>,
+			<&clock_gcc GCC_PCIE_1_CFG_AHB_CLK>,
+			<&clock_gcc GCC_PCIE_1_MSTR_AXI_CLK>,
+			<&clock_gcc GCC_PCIE_1_SLV_AXI_CLK>,
+			<&clock_gcc GCC_PCIE_1_CLKREF_CLK>,
+			<&clock_gcc GCC_PCIE_1_SLV_Q2A_AXI_CLK>,
+			<&clock_gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>,
+			<&clock_gcc GCC_PCIE_PHY_REFGEN_CLK>,
+			<&clock_gcc GCC_PCIE_PHY_AUX_CLK>;
+
+		clock-names = "pcie_1_pipe_clk", "pcie_1_ref_clk_src",
+				"pcie_1_aux_clk", "pcie_1_cfg_ahb_clk",
+				"pcie_1_mstr_axi_clk", "pcie_1_slv_axi_clk",
+				"pcie_1_ldo", "pcie_1_slv_q2a_axi_clk",
+				"pcie_tbu_clk", "pcie_phy_refgen_clk",
+				"pcie_phy_aux_clk";
+
+		max-clock-frequency-hz = <0>, <0>, <19200000>, <0>, <0>,
+					<0>, <0>, <0>, <0>, <100000000>, <0>;
+
+		resets = <&clock_gcc GCC_PCIE_1_BCR>,
+			<&clock_gcc GCC_PCIE_1_PHY_BCR>;
+
+		reset-names = "pcie_1_core_reset",
+				"pcie_1_phy_reset";
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
index 3e27297..a0207e5 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
@@ -210,6 +210,47 @@
 				config {
 					pins = "gpio37";
 					drive-strength = <2>;
+					bias-pull-up;
+				};
+			};
+		};
+
+		pcie1 {
+			pcie1_clkreq_default: pcie1_clkreq_default {
+				mux {
+					pins = "gpio103";
+					function = "pci_e1";
+				};
+
+				config {
+					pins = "gpio103";
+					drive-strength = <2>;
+					bias-pull-up;
+				};
+			};
+
+			pcie1_perst_default: pcie1_perst_default {
+				mux {
+					pins = "gpio102";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio102";
+					drive-strength = <2>;
+					bias-pull-down;
+				};
+			};
+
+			pcie1_wake_default: pcie1_wake_default {
+				mux {
+					pins = "gpio104";
+					function = "gpio";
+				};
+
+				config {
+					pins = "gpio104";
+					drive-strength = <2>;
 					bias-pull-down;
 				};
 			};
@@ -2753,6 +2794,7 @@
 				pins = "gpio80","gpio79";
 				bias-pull-down; /* PULL DOWN */
 				drive-strength = <2>; /* 2 MA */
+				output-low;
 			};
 		};
 
@@ -2784,6 +2826,35 @@
 			};
 		};
 
+		cam_sensor_mclk3_active: cam_sensor_mclk3_active {
+			/* MCLK3 */
+			mux {
+				pins = "gpio16";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio16";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_mclk3_suspend: cam_sensor_mclk3_suspend {
+			/* MCLK3 */
+			mux {
+				pins = "gpio16";
+				function = "cam_mclk";
+			};
+
+			config {
+				pins = "gpio16";
+				bias-pull-down; /* PULL DOWN */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+
 		cam_sensor_front_active: cam_sensor_front_active {
 			/* RESET  AVDD_LDO*/
 			mux {
@@ -2809,9 +2880,40 @@
 				pins = "gpio28";
 				bias-pull-down; /* PULL DOWN */
 				drive-strength = <2>; /* 2 MA */
+				output-low;
 			};
 		};
 
+		cam_sensor_iris_active: cam_sensor_iris_active {
+			/* RESET  AVDD_LDO*/
+			mux {
+				pins = "gpio9", "gpio8";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio9", "gpio8";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+			};
+		};
+
+		cam_sensor_iris_suspend: cam_sensor_iris_suspend {
+			/* RESET */
+			mux {
+				pins = "gpio9";
+				function = "gpio";
+			};
+
+			config {
+				pins = "gpio9";
+				bias-disable; /* No PULL */
+				drive-strength = <2>; /* 2 MA */
+				output-low;
+			};
+		};
+
+
 		cam_sensor_mclk2_active: cam_sensor_mclk2_active {
 			/* MCLK1 */
 			mux {
@@ -2866,6 +2968,7 @@
 				pins = "gpio9","gpio8";
 				bias-pull-down; /* PULL DOWN */
 				drive-strength = <2>; /* 2 MA */
+				output-low;
 			};
 		};
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-pmic-overlay.dtsi b/arch/arm64/boot/dts/qcom/sdm845-pmic-overlay.dtsi
index 000d65e7..2ac313d 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-pmic-overlay.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-pmic-overlay.dtsi
@@ -32,6 +32,9 @@
 	smb2_vconn: qcom,smb2-vconn {
 		regulator-name = "smb2-vconn";
 	};
+	smb2_vbus: qcom,smb2-vbus {
+		regulator-name = "smb2-vbus";
+	};
 };
 
 &usb0 {
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi b/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
index 6122eee..6dae069 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
@@ -88,7 +88,11 @@
 	qcom,fg-bmd-en-delay-ms = <300>;
 };
 
-&smb1355_charger {
+&smb1355_charger_0 {
+	status = "ok";
+};
+
+&smb1355_charger_1 {
 	status = "ok";
 };
 
@@ -111,6 +115,7 @@
 	vdd-hba-supply = <&ufs_phy_gdsc>;
 	vdd-hba-fixed-regulator;
 	vcc-supply = <&pm8998_l20>;
+	vcc-voltage-level = <2950000 2960000>;
 	vccq2-supply = <&pm8998_s4>;
 	vcc-max-microamp = <600000>;
 	vccq2-max-microamp = <600000>;
@@ -121,44 +126,6 @@
 	status = "ok";
 };
 
-&extcon_storage_cd {
-	gpio = <&tlmm 126 GPIO_ACTIVE_LOW>;
-	debounce-ms = <200>;
-	irq-flags = <IRQ_TYPE_EDGE_BOTH>;
-
-	pinctrl-names = "default";
-	pinctrl-0 = <&storage_cd>;
-
-	status = "ok";
-};
-
-&ufsphy_card {
-	compatible = "qcom,ufs-phy-qmp-v3";
-
-	vdda-phy-supply = <&pm8998_l1>; /* 0.88v */
-	vdda-pll-supply = <&pm8998_l26>; /* 1.2v */
-	vdda-phy-max-microamp = <62900>;
-	vdda-pll-max-microamp = <18300>;
-
-	status = "ok";
-};
-
-&ufshc_card {
-	vdd-hba-supply = <&ufs_card_gdsc>;
-	vdd-hba-fixed-regulator;
-	vcc-supply = <&pm8998_l21>;
-	vccq2-supply = <&pm8998_s4>;
-	vcc-max-microamp = <300000>;
-	vccq2-max-microamp = <300000>;
-
-	qcom,vddp-ref-clk-supply = <&pm8998_l2>;
-	qcom,vddp-ref-clk-max-microamp = <100>;
-
-	extcon = <&extcon_storage_cd>;
-
-	status = "ok";
-};
-
 &sdhc_2 {
 	vdd-supply = <&pm8998_l21>;
 	qcom,vdd-voltage-level = <2950000 2960000>;
@@ -169,10 +136,10 @@
 	qcom,vdd-io-current-level = <200 22000>;
 
 	pinctrl-names = "active", "sleep";
-	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on>;
-	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
+	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on &storage_cd>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &storage_cd>;
 
-	extcon = <&extcon_storage_cd>;
+	cd-gpios = <&tlmm 126 GPIO_ACTIVE_LOW>;
 
 	status = "ok";
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qupv3.dtsi b/arch/arm64/boot/dts/qcom/sdm845-qupv3.dtsi
index 1fa6e26..a805e2e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qupv3.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-qupv3.dtsi
@@ -221,6 +221,9 @@
 		interrupts = <GIC_SPI 601 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 0 1 64 0>,
+			<&gpi_dma0 1 0 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -240,6 +243,9 @@
 		interrupts = <GIC_SPI 602 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 1 1 64 0>,
+			<&gpi_dma0 1 1 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -259,6 +265,9 @@
 		interrupts = <GIC_SPI 603 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 2 1 64 0>,
+			<&gpi_dma0 1 2 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -278,6 +287,9 @@
 		interrupts = <GIC_SPI 604 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 3 1 64 0>,
+			<&gpi_dma0 1 3 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -297,6 +309,9 @@
 		interrupts = <GIC_SPI 605 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 4 1 64 0>,
+			<&gpi_dma0 1 4 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -316,6 +331,9 @@
 		interrupts = <GIC_SPI 606 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 5 1 64 0>,
+			<&gpi_dma0 1 5 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -335,6 +353,9 @@
 		interrupts = <GIC_SPI 607 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 6 1 64 0>,
+			<&gpi_dma0 1 6 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -354,6 +375,9 @@
 		interrupts = <GIC_SPI 608 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_0>;
+		dmas = <&gpi_dma0 0 7 1 64 0>,
+			<&gpi_dma0 1 7 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -561,6 +585,9 @@
 		interrupts = <GIC_SPI 353 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 0 1 64 0>,
+			<&gpi_dma1 1 0 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -580,6 +607,9 @@
 		interrupts = <GIC_SPI 354 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 1 1 64 0>,
+			<&gpi_dma1 1 1 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -599,6 +629,9 @@
 		interrupts = <GIC_SPI 355 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 2 1 64 0>,
+			<&gpi_dma1 1 2 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -618,6 +651,9 @@
 		interrupts = <GIC_SPI 356 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 3 1 64 0>,
+			<&gpi_dma1 1 3 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -637,6 +673,9 @@
 		interrupts = <GIC_SPI 357 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 4 1 64 0>,
+			<&gpi_dma1 1 4 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -656,6 +695,9 @@
 		interrupts = <GIC_SPI 358 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 5 1 64 0>,
+			<&gpi_dma1 1 5 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -675,6 +717,9 @@
 		interrupts = <GIC_SPI 359 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 6 1 64 0>,
+			<&gpi_dma1 1 6 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -694,6 +739,9 @@
 		interrupts = <GIC_SPI 360 0>;
 		spi-max-frequency = <50000000>;
 		qcom,wrapper-core = <&qupv3_1>;
+		dmas = <&gpi_dma1 0 7 1 64 0>,
+			<&gpi_dma1 1 7 1 64 0>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qvr-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-qvr-overlay.dts
index a47219d..2fac9e8 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qvr-overlay.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-qvr-overlay.dts
@@ -22,8 +22,8 @@
 #include "sdm845-qvr.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. SDM845 v1 QVR";
+	model = "Qualcomm Technologies, Inc. SDM845 v2 QVR";
 	compatible = "qcom,sdm845-qvr", "qcom,sdm845", "qcom,qvr";
-	qcom,msm-id = <321 0x10000>;
+	qcom,msm-id = <321 0x20000>;
 	qcom,board-id = <0x01000B 0x20>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qvr.dts b/arch/arm64/boot/dts/qcom/sdm845-qvr.dts
index f344803..c06b806 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qvr.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-qvr.dts
@@ -13,7 +13,7 @@
 
 /dts-v1/;
 
-#include "sdm845.dtsi"
+#include "sdm845-v2.dtsi"
 #include "sdm845-qvr.dtsi"
 
 / {
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qvr.dtsi b/arch/arm64/boot/dts/qcom/sdm845-qvr.dtsi
index 6ea92ee..d89722f 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qvr.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-qvr.dtsi
@@ -9,3 +9,111 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
+
+#include "sdm845-pmic-overlay.dtsi"
+#include "sdm845-pinctrl-overlay.dtsi"
+#include "smb1355.dtsi"
+
+&pmi8998_pdphy {
+	vbus-supply = <&smb2_vbus>;
+};
+
+&pmi8998_fg {
+	qcom,fg-bmd-en-delay-ms = <300>;
+};
+
+&qupv3_se10_i2c {
+	status = "ok";
+};
+
+&smb1355_charger_0 {
+	status = "ok";
+};
+
+&smb1355_charger_1 {
+	status = "ok";
+};
+
+&soc {
+	qcom,qbt1000 {
+		status = "disabled";
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		label = "gpio-keys";
+		pinctrl-names = "default";
+		pinctrl-0 = <&key_vol_up_default
+			     &key_home_default>;
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&pm8998_gpios 6 GPIO_ACTIVE_LOW>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+
+		home {
+			label = "home";
+			gpios = <&pm8998_gpios 5 GPIO_ACTIVE_LOW>;
+			linux,input-type = <1>;
+			linux,code = <102>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+			linux,can-disable;
+		};
+	};
+};
+
+&pmi8998_haptics {
+	qcom,vmax-mv = <1800>;
+	qcom,wave-play-rate-us = <4255>;
+	qcom,lra-auto-mode;
+	status = "okay";
+};
+
+&ufsphy_mem {
+	compatible = "qcom,ufs-phy-qmp-v3";
+
+	vdda-phy-supply = <&pm8998_l1>; /* 0.88v */
+	vdda-pll-supply = <&pm8998_l26>; /* 1.2v */
+	vdda-phy-max-microamp = <62900>;
+	vdda-pll-max-microamp = <18300>;
+
+	status = "ok";
+};
+
+&ufshc_mem {
+	vdd-hba-supply = <&ufs_phy_gdsc>;
+	vdd-hba-fixed-regulator;
+	vcc-supply = <&pm8998_l20>;
+	vccq2-supply = <&pm8998_s4>;
+	vcc-max-microamp = <600000>;
+	vccq2-max-microamp = <600000>;
+
+	qcom,vddp-ref-clk-supply = <&pm8998_l2>;
+	qcom,vddp-ref-clk-max-microamp = <100>;
+
+	status = "ok";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm8998_l21>;
+	qcom,vdd-voltage-level = <2950000 2960000>;
+	qcom,vdd-current-level = <200 800000>;
+
+	vdd-io-supply = <&pm8998_l13>;
+	qcom,vdd-io-voltage-level = <1808000 2960000>;
+	qcom,vdd-io-current-level = <200 22000>;
+
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &storage_cd>;
+	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &storage_cd>;
+
+	cd-gpios = <&tlmm 126 GPIO_ACTIVE_HIGH>;
+
+	status = "ok";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm845-regulator.dtsi
index f50df47..d22c28a 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-regulator.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-regulator.dtsi
@@ -1389,12 +1389,24 @@
 		compatible = "qcom,rpmh-vrm-regulator";
 		mboxes = <&apps_rsc 0>;
 		qcom,resource-name = "bobb1";
+		qcom,send-defaults;
+
 		pmi8998_bob: regulator-bob {
 			regulator-name = "pmi8998_bob";
 			qcom,set = <RPMH_REGULATOR_SET_ALL>;
 			regulator-min-microvolt = <3312000>;
 			regulator-max-microvolt = <3600000>;
 			qcom,init-voltage = <3312000>;
+			qcom,init-mode = <RPMH_REGULATOR_MODE_BOB_PASS>;
+		};
+
+		pmi8998_bob_ao: regulator-bob-ao {
+			regulator-name = "pmi8998_bob_ao";
+			qcom,set = <RPMH_REGULATOR_SET_ACTIVE>;
+			regulator-min-microvolt = <3312000>;
+			regulator-max-microvolt = <3600000>;
+			qcom,init-voltage = <3312000>;
+			qcom,init-mode = <RPMH_REGULATOR_MODE_BOB_AUTO>;
 		};
 	};
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-rumi.dtsi b/arch/arm64/boot/dts/qcom/sdm845-rumi.dtsi
index e7fd8a0..d607f75 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-rumi.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-rumi.dtsi
@@ -33,6 +33,7 @@
 	vdd-hba-supply = <&ufs_phy_gdsc>;
 	vdd-hba-fixed-regulator;
 	vcc-supply = <&pm8998_l20>;
+	vcc-voltage-level = <2950000 2960000>;
 	vccq2-supply = <&pm8998_s4>;
 	vcc-max-microamp = <600000>;
 	vccq2-max-microamp = <600000>;
@@ -139,37 +140,6 @@
 	qcom,cpr-ignore-invalid-fuses;
 };
 
-&ufsphy_card {
-	compatible = "qcom,ufs-phy-qrbtc-sdm845";
-
-	vdda-phy-supply = <&pm8998_l1>; /* 0.88v */
-	vdda-pll-supply = <&pm8998_l26>; /* 1.2v */
-	vdda-phy-max-microamp = <62900>;
-	vdda-pll-max-microamp = <18300>;
-
-	status = "ok";
-};
-
-&ufshc_card {
-	limit-tx-hs-gear = <1>;
-	limit-rx-hs-gear = <1>;
-
-	vdd-hba-supply = <&ufs_card_gdsc>;
-	vdd-hba-fixed-regulator;
-	vcc-supply = <&pm8998_l21>;
-	vccq2-supply = <&pm8998_s4>;
-	vcc-max-microamp = <300000>;
-	vccq2-max-microamp = <300000>;
-
-	qcom,vddp-ref-clk-supply = <&pm8998_l2>;
-	qcom,vddp-ref-clk-max-microamp = <100>;
-
-	qcom,disable-lpm;
-	rpm-level = <0>;
-	spm-level = <0>;
-	status = "ok";
-};
-
 &pmi8998_charger {
 	qcom,suspend-input;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi b/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
index db3d23c..4337da7 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
@@ -414,108 +414,12 @@
 			compatible = "qcom,msm-ext-disp-audio-codec-rx";
 		};
 	};
-
-	sde_dp: qcom,dp_display@0{
-		cell-index = <0>;
-		compatible = "qcom,dp-display";
-
-		gdsc-supply = <&mdss_core_gdsc>;
-		vdda-1p2-supply = <&pm8998_l26>;
-		vdda-0p9-supply = <&pm8998_l1>;
-
-		reg =	<0xae90000 0xa84>,
-			<0x88eaa00 0x200>,
-			<0x88ea200 0x200>,
-			<0x88ea600 0x200>,
-			<0xaf02000 0x1a0>,
-			<0x780000 0x621c>,
-			<0x88ea030 0x10>,
-			<0x0aee1000 0x034>;
-		reg-names = "dp_ctrl", "dp_phy", "dp_ln_tx0", "dp_ln_tx1",
-			"dp_mmss_cc", "qfprom_physical", "dp_pll",
-			"hdcp_physical";
-
-		interrupt-parent = <&mdss_mdp>;
-		interrupts = <12 0>;
-
-		clocks =  <&clock_dispcc DISP_CC_MDSS_DP_AUX_CLK>,
-			 <&clock_rpmh RPMH_CXO_CLK>,
-			 <&clock_gcc GCC_USB3_PRIM_CLKREF_CLK>,
-			 <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>,
-			 <&clock_gcc GCC_USB3_PRIM_PHY_PIPE_CLK>,
-			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_CLK>,
-			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_INTF_CLK>,
-			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK>,
-			 <&clock_dispcc DISP_CC_MDSS_DP_CRYPTO_CLK>,
-			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK_SRC>,
-			 <&mdss_dp_pll DP_VCO_DIVIDED_CLK_SRC_MUX>;
-		clock-names = "core_aux_clk", "core_usb_ref_clk_src",
-			"core_usb_ref_clk", "core_usb_cfg_ahb_clk",
-			"core_usb_pipe_clk", "ctrl_link_clk",
-			"ctrl_link_iface_clk", "ctrl_pixel_clk",
-			"crypto_clk", "pixel_clk_rcg", "pixel_parent";
-
-		qcom,dp-usbpd-detection = <&pmi8998_pdphy>;
-		qcom,ext-disp = <&ext_disp>;
-
-		qcom,aux-cfg0-settings = [20 00];
-		qcom,aux-cfg1-settings = [24 13 23 1d];
-		qcom,aux-cfg2-settings = [28 24];
-		qcom,aux-cfg3-settings = [2c 00];
-		qcom,aux-cfg4-settings = [30 0a];
-		qcom,aux-cfg5-settings = [34 26];
-		qcom,aux-cfg6-settings = [38 0a];
-		qcom,aux-cfg7-settings = [3c 03];
-		qcom,aux-cfg8-settings = [40 bb];
-		qcom,aux-cfg9-settings = [44 03];
-
-		qcom,max-pclk-frequency-khz = <576000>;
-
-		qcom,core-supply-entries {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			qcom,core-supply-entry@0 {
-				reg = <0>;
-				qcom,supply-name = "gdsc";
-				qcom,supply-min-voltage = <0>;
-				qcom,supply-max-voltage = <0>;
-				qcom,supply-enable-load = <0>;
-				qcom,supply-disable-load = <0>;
-			};
-		};
-
-		qcom,ctrl-supply-entries {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			qcom,ctrl-supply-entry@0 {
-				reg = <0>;
-				qcom,supply-name = "vdda-1p2";
-				qcom,supply-min-voltage = <1200000>;
-				qcom,supply-max-voltage = <1200000>;
-				qcom,supply-enable-load = <21800>;
-				qcom,supply-disable-load = <4>;
-			};
-		};
-
-		qcom,phy-supply-entries {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			qcom,phy-supply-entry@0 {
-				reg = <0>;
-				qcom,supply-name = "vdda-0p9";
-				qcom,supply-min-voltage = <880000>;
-				qcom,supply-max-voltage = <880000>;
-				qcom,supply-enable-load = <36000>;
-				qcom,supply-disable-load = <32>;
-			};
-		};
-	};
 };
 
 &sde_dp {
+	qcom,dp-usbpd-detection = <&pmi8998_pdphy>;
+	qcom,ext-disp = <&ext_disp>;
+
 	pinctrl-names = "mdss_dp_active", "mdss_dp_sleep";
 	pinctrl-0 = <&sde_dp_aux_active &sde_dp_usbplug_cc_active>;
 	pinctrl-1 = <&sde_dp_aux_suspend &sde_dp_usbplug_cc_suspend>;
@@ -531,6 +435,11 @@
 &dsi_dual_nt35597_truly_video {
 	qcom,mdss-dsi-t-clk-post = <0x0D>;
 	qcom,mdss-dsi-t-clk-pre = <0x2D>;
+	qcom,mdss-dsi-min-refresh-rate = <53>;
+	qcom,mdss-dsi-max-refresh-rate = <60>;
+	qcom,mdss-dsi-pan-enable-dynamic-fps;
+	qcom,mdss-dsi-pan-fps-update =
+		"dfps_immediate_porch_mode_vfp";
 	qcom,mdss-dsi-display-timings {
 		timing@0{
 			qcom,mdss-dsi-panel-phy-timings = [00 1c 07 07 23 21 07
@@ -574,6 +483,11 @@
 &dsi_nt35597_truly_dsc_video {
 	qcom,mdss-dsi-t-clk-post = <0x0b>;
 	qcom,mdss-dsi-t-clk-pre = <0x23>;
+	qcom,mdss-dsi-min-refresh-rate = <53>;
+	qcom,mdss-dsi-max-refresh-rate = <60>;
+	qcom,mdss-dsi-pan-enable-dynamic-fps;
+	qcom,mdss-dsi-pan-fps-update =
+		"dfps_immediate_porch_mode_vfp";
 	qcom,mdss-dsi-display-timings {
 		timing@0{
 			qcom,mdss-dsi-panel-phy-timings = [00 15 05 05 20 1f 05
diff --git a/arch/arm64/boot/dts/qcom/sdm845-sde.dtsi b/arch/arm64/boot/dts/qcom/sdm845-sde.dtsi
index 121565e..e7a946c 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-sde.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-sde.dtsi
@@ -9,14 +9,17 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
+#include <dt-bindings/clock/mdss-10nm-pll-clk.h>
 
 &soc {
 	mdss_mdp: qcom,mdss_mdp@ae00000 {
 		compatible = "qcom,sde-kms";
 		reg = <0x0ae00000 0x81d40>,
-		      <0x0aeb0000 0x2008>;
+		      <0x0aeb0000 0x2008>,
+		      <0x0aeac000 0xf0>;
 		reg-names = "mdp_phys",
-			"vbif_phys";
+			"vbif_phys",
+			"regdma_phys";
 
 		clocks =
 			<&clock_gcc GCC_DISP_AHB_CLK>,
@@ -43,6 +46,8 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
+		#power-domain-cells = <0>;
+
 		/* hw blocks */
 		qcom,sde-off = <0x1000>;
 		qcom,sde-len = <0x45C>;
@@ -61,6 +66,11 @@
 		qcom,sde-dspp-off = <0x55000 0x57000 0x59000 0x5b000>;
 		qcom,sde-dspp-size = <0x17e0>;
 
+		qcom,sde-dest-scaler-top-off = <0x00061000>;
+		qcom,sde-dest-scaler-top-size = <0xc>;
+		qcom,sde-dest-scaler-off = <0x800 0x1000>;
+		qcom,sde-dest-scaler-size = <0x800>;
+
 		qcom,sde-wb-off = <0x66000>;
 		qcom,sde-wb-size = <0x2c8>;
 		qcom,sde-wb-xin-id = <6>;
@@ -126,8 +136,14 @@
 		qcom,sde-has-src-split;
 		qcom,sde-has-dim-layer;
 		qcom,sde-has-idle-pc;
-		qcom,sde-max-bw-low-kbps = <9600000>;
-		qcom,sde-max-bw-high-kbps = <9600000>;
+		qcom,sde-has-dest-scaler;
+		qcom,sde-max-dest-scaler-input-linewidth = <2048>;
+		qcom,sde-max-dest-scaler-output-linewidth = <2560>;
+		qcom,sde-max-bw-low-kbps = <6800000>;
+		qcom,sde-max-bw-high-kbps = <6800000>;
+		qcom,sde-min-core-ib-kbps = <2400000>;
+		qcom,sde-min-llcc-ib-kbps = <800000>;
+		qcom,sde-min-dram-ib-kbps = <800000>;
 		qcom,sde-dram-channels = <2>;
 		qcom,sde-num-nrt-paths = <0>;
 		qcom,sde-dspp-ad-version = <0x00040000>;
@@ -179,6 +195,9 @@
 		/* offsets are relative to "mdp_phys + qcom,sde-off */
 		qcom,sde-inline-rot-clk-ctrl = <0x2bc 0x8>, <0x2bc 0xc>;
 
+		qcom,sde-reg-dma-off = <0>;
+		qcom,sde-reg-dma-version = <0x1>;
+		qcom,sde-reg-dma-trigger-off = <0x119c>;
 
 		qcom,sde-sspp-vig-blocks {
 			qcom,sde-vig-csc-off = <0x1a00>;
@@ -192,6 +211,7 @@
 			qcom,sde-dspp-gamut = <0x1000 0x00040000>;
 			qcom,sde-dspp-pcc = <0x1700 0x00040000>;
 			qcom,sde-dspp-gc = <0x17c0 0x00010008>;
+			qcom,sde-dspp-hist = <0x800 0x00010007>;
 		};
 
 		qcom,platform-supply-entries {
@@ -348,6 +368,8 @@
 		interrupt-parent = <&mdss_mdp>;
 		interrupts = <2 0>;
 
+		power-domains = <&mdss_mdp>;
+
 		/* Offline rotator QoS setting */
 		qcom,mdss-rot-vbif-qos-setting = <3 3 3 3 3 3 3 3>;
 		qcom,mdss-rot-vbif-memtype = <3 3>;
@@ -527,4 +549,86 @@
 		};
 	};
 
+	sde_dp: qcom,dp_display@0{
+		cell-index = <0>;
+		compatible = "qcom,dp-display";
+
+		gdsc-supply = <&mdss_core_gdsc>;
+		vdda-1p2-supply = <&pm8998_l26>;
+		vdda-0p9-supply = <&pm8998_l1>;
+
+		reg =	<0xae90000 0xa84>,
+			<0x88eaa00 0x200>,
+			<0x88ea200 0x200>,
+			<0x88ea600 0x200>,
+			<0xaf02000 0x1a0>,
+			<0x780000 0x621c>,
+			<0x88ea030 0x10>,
+			<0x88e8000 0x20>,
+			<0x0aee1000 0x034>;
+		reg-names = "dp_ctrl", "dp_phy", "dp_ln_tx0", "dp_ln_tx1",
+			"dp_mmss_cc", "qfprom_physical", "dp_pll",
+			"usb3_dp_com", "hdcp_physical";
+
+		interrupt-parent = <&mdss_mdp>;
+		interrupts = <12 0>;
+
+		clocks =  <&clock_dispcc DISP_CC_MDSS_DP_AUX_CLK>,
+			 <&clock_rpmh RPMH_CXO_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_CLKREF_CLK>,
+			 <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>,
+			 <&clock_gcc GCC_USB3_PRIM_PHY_PIPE_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_LINK_INTF_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_CRYPTO_CLK>,
+			 <&clock_dispcc DISP_CC_MDSS_DP_PIXEL_CLK_SRC>,
+			 <&mdss_dp_pll DP_VCO_DIVIDED_CLK_SRC_MUX>;
+		clock-names = "core_aux_clk", "core_usb_ref_clk_src",
+			"core_usb_ref_clk", "core_usb_cfg_ahb_clk",
+			"core_usb_pipe_clk", "ctrl_link_clk",
+			"ctrl_link_iface_clk", "ctrl_pixel_clk",
+			"crypto_clk", "pixel_clk_rcg", "pixel_parent";
+
+		qcom,aux-cfg0-settings = [20 00];
+		qcom,aux-cfg1-settings = [24 13 23 1d];
+		qcom,aux-cfg2-settings = [28 24];
+		qcom,aux-cfg3-settings = [2c 00];
+		qcom,aux-cfg4-settings = [30 0a];
+		qcom,aux-cfg5-settings = [34 26];
+		qcom,aux-cfg6-settings = [38 0a];
+		qcom,aux-cfg7-settings = [3c 03];
+		qcom,aux-cfg8-settings = [40 bb];
+		qcom,aux-cfg9-settings = [44 03];
+
+		qcom,max-pclk-frequency-khz = <675000>;
+
+		qcom,ctrl-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,ctrl-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-1p2";
+				qcom,supply-min-voltage = <1200000>;
+				qcom,supply-max-voltage = <1200000>;
+				qcom,supply-enable-load = <21800>;
+				qcom,supply-disable-load = <4>;
+			};
+		};
+
+		qcom,phy-supply-entries {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,phy-supply-entry@0 {
+				reg = <0>;
+				qcom,supply-name = "vdda-0p9";
+				qcom,supply-min-voltage = <880000>;
+				qcom,supply-max-voltage = <880000>;
+				qcom,supply-enable-load = <36000>;
+				qcom,supply-disable-load = <32>;
+			};
+		};
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm845-usb.dtsi b/arch/arm64/boot/dts/qcom/sdm845-usb.dtsi
index 16d0988..09f4efa 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-usb.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-usb.dtsi
@@ -78,6 +78,7 @@
 			snps,disable-clk-gating;
 			snps,has-lpm-erratum;
 			snps,hird-threshold = /bits/ 8 <0x10>;
+			usb-core-id = <0>;
 		};
 
 		qcom,usbbam@a704000 {
@@ -116,8 +117,9 @@
 	qusb_phy0: qusb@88e2000 {
 		compatible = "qcom,qusb2phy-v2";
 		reg = <0x088e2000 0x400>,
-			<0x007801e8 0x4>;
-		reg-names = "qusb_phy_base", "efuse_addr";
+			<0x007801e8 0x4>,
+			<0x088e0000 0x2000>;
+		reg-names = "qusb_phy_base", "efuse_addr", "eud_base";
 
 		qcom,efuse-bit-pos = <25>;
 		qcom,efuse-num-bits = <3>;
@@ -385,6 +387,7 @@
 			snps,disable-clk-gating;
 			snps,has-lpm-erratum;
 			snps,hird-threshold = /bits/ 8 <0x10>;
+			usb-core-id = <1>;
 		};
 	};
 
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-cdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-cdp-overlay.dts
new file mode 100644
index 0000000..5b3e964
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-cdp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-cdp.dtsi"
+#include "sdm845-cdp-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sdm845 v2 4K Display Panel CDP";
+	compatible = "qcom,sdm845-cdp", "qcom,sdm845", "qcom,cdp";
+	qcom,msm-id = <321 0x20000>;
+	qcom,board-id = <1 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-mtp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-mtp-overlay.dts
new file mode 100644
index 0000000..0d6c5e0
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-mtp-overlay.dts
@@ -0,0 +1,66 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-mtp.dtsi"
+#include "sdm845-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sdm845 v2 4K Display Panel MTP";
+	compatible = "qcom,sdm845-mtp", "qcom,sdm845", "qcom,mtp";
+	qcom,msm-id = <321 0x20000>;
+	qcom,board-id = <8 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+	connectors = <&sde_rscc &sde_wb &sde_dp>;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-qrd-overlay.dts b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-qrd-overlay.dts
new file mode 100644
index 0000000..764c145
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2-4k-panel-qrd-overlay.dts
@@ -0,0 +1,64 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/qcom,gcc-sdm845.h>
+#include <dt-bindings/clock/qcom,camcc-sdm845.h>
+#include <dt-bindings/clock/qcom,dispcc-sdm845.h>
+#include <dt-bindings/clock/qcom,rpmh.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+#include "sdm845-sde-display.dtsi"
+#include "sdm845-qrd.dtsi"
+#include "sdm845-qrd-audio-overlay.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. sdm845 v2 4K Display Panel QRD";
+	compatible = "qcom,sdm845-qrd", "qcom,sdm845", "qcom,qrd";
+	qcom,msm-id = <321 0x20000>;
+	qcom,board-id = <11 1>;
+};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+	/delete-property/ qcom,dsi-display-active;
+};
+
+&dsi_sharp_4k_dsc_video {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_cmd {
+	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
+	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+	qcom,mdss-dsi-bl-min-level = <1>;
+	qcom,mdss-dsi-bl-max-level = <4095>;
+	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
+	qcom,panel-mode-gpio = <&tlmm 52 0>;
+	qcom,platform-te-gpio = <&tlmm 10 0>;
+	qcom,platform-reset-gpio = <&tlmm 6 0>;
+	qcom,mdss-dsi-panel-orientation = "180";
+};
+
+&dsi_sharp_4k_dsc_video_display {
+	qcom,dsi-display-active;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2-camera.dtsi b/arch/arm64/boot/dts/qcom/sdm845-v2-camera.dtsi
index c42a7be..0b6e27e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-v2-camera.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2-camera.dtsi
@@ -24,8 +24,7 @@
 		gdscr-supply = <&titan_top_gdsc>;
 		refgen-supply = <&refgen>;
 		csi-vdd-voltage = <1200000>;
-		mipi-csi-vdd-supply = <&pm8998_l26>;
-		mipi-dsi-vdd-supply = <&pm8998_l1>;
+		mipi-csi-vdd-supply = <&pm8998_l1>;
 		clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
 			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
 			<&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>,
@@ -60,8 +59,7 @@
 		gdscr-supply = <&titan_top_gdsc>;
 		refgen-supply = <&refgen>;
 		csi-vdd-voltage = <1200000>;
-		mipi-csi-vdd-supply = <&pm8998_l26>;
-		mipi-dsi-vdd-supply = <&pm8998_l1>;
+		mipi-csi-vdd-supply = <&pm8998_l1>;
 		clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
 			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
 			<&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>,
@@ -97,8 +95,7 @@
 		gdscr-supply = <&titan_top_gdsc>;
 		refgen-supply = <&refgen>;
 		csi-vdd-voltage = <1200000>;
-		mipi-csi-vdd-supply = <&pm8998_l26>;
-		mipi-dsi-vdd-supply = <&pm8998_l1>;
+		mipi-csi-vdd-supply = <&pm8998_l1>;
 		clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
 			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
 			<&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>,
@@ -124,7 +121,7 @@
 	cam_csiphy3: qcom,csiphy@ac68000 {
 		cell-index = <3>;
 		compatible = "qcom,csiphy-v1.0", "qcom,csiphy";
-		reg = <0xac67000 0x1000>;
+		reg = <0xac68000 0x1000>;
 		reg-names = "csiphy";
 		reg-cam-base = <0x68000>;
 		interrupts = <0 448 0>;
@@ -133,8 +130,7 @@
 		gdscr-supply = <&titan_top_gdsc>;
 		refgen-supply = <&refgen>;
 		csi-vdd-voltage = <1200000>;
-		mipi-csi-vdd-supply = <&pm8998_l26>;
-		mipi-dsi-vdd-supply = <&pm8998_l1>;
+		mipi-csi-vdd-supply = <&pm8998_l1>;
 		clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>,
 			<&clock_camcc CAM_CC_SOC_AHB_CLK>,
 			<&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>,
@@ -243,18 +239,8 @@
 
 		msm_cam_smmu_secure {
 			compatible = "qcom,msm-cam-smmu-cb";
-			iommus = <&apps_smmu 0x1001 0x0>;
 			label = "cam-secure";
-			cam_secure_iova_mem_map: iova-mem-map {
-				/* Secure IO region is approximately 3.4 GB */
-				iova-mem-region-io {
-					iova-region-name = "io";
-					iova-region-start = <0x7400000>;
-					iova-region-len = <0xd8c00000>;
-					iova-region-id = <0x3>;
-					status = "ok";
-				};
-			};
+			qcom,secure-cb;
 		};
 	};
 
@@ -329,14 +315,14 @@
 			"turbo", "turbo";
 		client-id-based;
 		client-names =
-			"csiphy0", "csiphy1", "csiphy2", "cci0",
+			"csiphy0", "csiphy1", "csiphy2", "csiphy3", "cci0",
 			"csid0", "csid1", "csid2",
 			"ife0", "ife1", "ife2", "ipe0",
 			"ipe1", "cam-cdm-intf0", "cpas-cdm0", "bps0",
 			"icp0", "jpeg-dma0", "jpeg-enc0", "fd0";
 		client-axi-port-names =
-			"cam_hf_1", "cam_hf_2", "cam_hf_2", "cam_sf_1",
-			"cam_hf_1", "cam_hf_2", "cam_hf_2",
+			"cam_hf_1", "cam_hf_2", "cam_hf_2", "cam_hf_2",
+			"cam_sf_1", "cam_hf_1", "cam_hf_2", "cam_hf_2",
 			"cam_hf_1", "cam_hf_2", "cam_hf_2", "cam_sf_1",
 			"cam_sf_1", "cam_sf_1", "cam_sf_1", "cam_sf_1",
 			"cam_sf_1", "cam_sf_1", "cam_sf_1", "cam_sf_1";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi b/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
index a0b6945..6c85daf 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
@@ -25,6 +25,10 @@
 /delete-node/ &apc0_cpr;
 /delete-node/ &apc1_cpr;
 
+&tlmm {
+	compatible = "qcom,sdm845-pinctrl-v2";
+};
+
 &soc {
 	/* CPR controller regulators */
 	apc0_cpr: cprh-ctrl@17dc0000 {
@@ -57,7 +61,7 @@
 		qcom,cpr-saw-use-unit-mV;
 
 		qcom,saw-avs-ctrl = <0x101C031>;
-		qcom,saw-avs-limit = <0x3B803B8>;
+		qcom,saw-avs-limit = <0x3E803E8>;
 
 		qcom,cpr-enable;
 		qcom,cpr-hw-closed-loop;
@@ -69,7 +73,7 @@
 			"APSS_SILVER_CPRH_STATUS_1",
 			"SILVER_SAW4_PMIC_STS";
 
-		qcom,cpr-aging-ref-voltage = <952000>;
+		qcom,cpr-aging-ref-voltage = <1000000>;
 		vdd-supply = <&pm8998_s13>;
 
 		thread@0 {
@@ -85,9 +89,9 @@
 				regulator-max-microvolt = <18>;
 
 				qcom,cpr-fuse-corners = <4>;
-				qcom,cpr-fuse-combos = <16>;
-				qcom,cpr-speed-bins = <2>;
-				qcom,cpr-speed-bin-corners = <18 18>;
+				qcom,cpr-fuse-combos = <24>;
+				qcom,cpr-speed-bins = <3>;
+				qcom,cpr-speed-bin-corners = <18 18 18>;
 				qcom,cpr-corners = <18>;
 
 				qcom,cpr-corner-fmax-map = <6 12 15 18>;
@@ -133,10 +137,62 @@
 					 1950 2632>;
 
 				qcom,cpr-open-loop-voltage-fuse-adjustment =
-					<     0      0  12000  12000>;
+					/* Speed bin 0 */
+					<      0        0    12000    12000>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					/* Speed bin 1 */
+					<      0        0    12000    12000>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					/* Speed bin 2 */
+					<      0        0    12000    12000>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>,
+					<(-15000) (-15000)  (-3000)  (-3000)>;
 
 				qcom,cpr-closed-loop-voltage-fuse-adjustment =
-					<     0      0  12000  10000>;
+					/* Speed bin 0 */
+					<      0        0    12000    10000>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					/* Speed bin 1 */
+					<      0        0    12000    10000>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					/* Speed bin 2 */
+					<      0        0    12000    10000>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>,
+					<(-15000) (-15000)  (-3000)  (-5000)>;
 
 				qcom,allow-voltage-interpolation;
 				qcom,allow-quotient-interpolation;
@@ -149,6 +205,8 @@
 					/* Speed bin 0 */
 					<0 1 1 1 1 1 1 1>,
 					/* Speed bin 1 */
+					<0 1 1 1 1 1 1 1>,
+					/* Speed bin 2 */
 					<0 1 1 1 1 1 1 1>;
 				qcom,allow-aging-open-loop-voltage-adjustment =
 					<1>;
@@ -168,19 +226,23 @@
 				regulator-max-microvolt = <15>;
 
 				qcom,cpr-fuse-corners = <4>;
-				qcom,cpr-fuse-combos = <16>;
-				qcom,cpr-speed-bins = <2>;
-				qcom,cpr-speed-bin-corners = <14 15>;
+				qcom,cpr-fuse-combos = <24>;
+				qcom,cpr-speed-bins = <3>;
+				qcom,cpr-speed-bin-corners = <14 15 15>;
 				qcom,cpr-corners =
 					/* Speed bin 0 */
 					<14 14 14 14 14 14 14 14>,
 					/* Speed bin 1 */
+					<15 15 15 15 15 15 15 15>,
+					/* Speed bin 2 */
 					<15 15 15 15 15 15 15 15>;
 
 				qcom,cpr-corner-fmax-map =
 					/* Speed bin 0 */
 					<4 8 11 14>,
 					/* Speed bin 1 */
+					<4 8 11 15>,
+					/* Speed bin 2 */
 					<4 8 11 15>;
 
 				qcom,cpr-voltage-ceiling =
@@ -192,6 +254,11 @@
 					<828000  828000  828000  828000  828000
 					 828000  828000  828000  828000  828000
 					 828000  932000  932000 1000000
+					1000000>,
+					/* Speed bin 2 */
+					<828000  828000  828000  828000  828000
+					 828000  828000  828000  828000  828000
+					 828000  932000  932000 1000000
 					1000000>;
 
 				qcom,cpr-voltage-floor =
@@ -203,6 +270,11 @@
 					<568000  568000  568000  568000  568000
 					 568000  568000  568000  568000  568000
 					 568000  568000  568000  568000
+					 568000>,
+					/* Speed bin 2 */
+					<568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000  568000
 					 568000>;
 
 				qcom,cpr-floor-to-ceiling-max-range =
@@ -213,6 +285,10 @@
 					/* Speed bin 1 */
 					<32000  32000  32000  32000  32000
 					 32000  32000  32000  32000  32000
+					 32000  32000  32000  40000  40000>,
+					/* Speed bin 2 */
+					<32000  32000  32000  32000  32000
+					 32000  32000  32000  32000  32000
 					 32000  32000  32000  40000  40000>;
 
 				qcom,corner-frequencies =
@@ -227,6 +303,12 @@
 					 576000000  652800000  748800000
 					 844800000  940800000 1036800000
 					1132800000 1209600000 1305600000
+					1401600000 1497600000 1593600000>,
+					/* Speed bin 2 */
+					<300000000  403200000  480000000
+					 576000000  652800000  748800000
+					 844800000  940800000 1036800000
+					1132800000 1209600000 1305600000
 					1401600000 1497600000 1593600000>;
 
 				qcom,cpr-ro-scaling-factor =
@@ -244,22 +326,76 @@
 					 2501 2095>;
 
 				qcom,cpr-open-loop-voltage-fuse-adjustment =
-					<  8000  16000  16000  12000>;
+					/* Speed bin 0 */
+					<   8000    16000    16000    12000>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					/* Speed bin 1 */
+					<   8000    16000    16000    12000>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					/* Speed bin 2 */
+					<   8000    16000    16000    12000>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>,
+					< (-7000)    1000     1000   (-3000)>;
 
 				qcom,cpr-closed-loop-voltage-fuse-adjustment =
-					<  6000  14000  16000  12000>;
+					/* Speed bin 0 */
+					<   6000    14000    16000    12000>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					/* Speed bin 1 */
+					<   6000    14000    16000    12000>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					/* Speed bin 2 */
+					<   6000    14000    16000    12000>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>,
+					< (-9000)  (-1000)    1000   (-3000)>;
 
 				qcom,allow-voltage-interpolation;
 				qcom,allow-quotient-interpolation;
 				qcom,cpr-scaled-open-loop-voltage-as-ceiling;
 
 				qcom,cpr-aging-max-voltage-adjustment = <15000>;
-				qcom,cpr-aging-ref-corner = <14>;
+				qcom,cpr-aging-ref-corner = <14 15 15>;
 				qcom,cpr-aging-ro-scaling-factor = <1620>;
 				qcom,allow-aging-voltage-adjustment =
 					/* Speed bin 0 */
 					<0 1 1 1 1 1 1 1>,
 					/* Speed bin 1 */
+					<0 1 1 1 1 1 1 1>,
+					/* Speed bin 2 */
 					<0 1 1 1 1 1 1 1>;
 				qcom,allow-aging-open-loop-voltage-adjustment =
 					<1>;
@@ -302,7 +438,7 @@
 		qcom,cpr-saw-use-unit-mV;
 
 		qcom,saw-avs-ctrl = <0x101C031>;
-		qcom,saw-avs-limit = <0x4700470>;
+		qcom,saw-avs-limit = <0x4880488>;
 
 		qcom,cpr-enable;
 		qcom,cpr-hw-closed-loop;
@@ -312,7 +448,7 @@
 		qcom,cpr-panic-reg-name-list =
 			"APSS_GOLD_CPRH_STATUS_0", "GOLD_SAW4_PMIC_STS";
 
-		qcom,cpr-aging-ref-voltage = <1136000>;
+		qcom,cpr-aging-ref-voltage = <1160000>;
 		vdd-supply = <&pm8998_s12>;
 
 		thread@0 {
@@ -325,23 +461,27 @@
 			apc1_perfcl_vreg: regulator {
 				regulator-name = "apc1_perfcl_corner";
 				regulator-min-microvolt = <1>;
-				regulator-max-microvolt = <33>;
+				regulator-max-microvolt = <35>;
 
 				qcom,cpr-fuse-corners = <5>;
-				qcom,cpr-fuse-combos = <16>;
-				qcom,cpr-speed-bins = <2>;
-				qcom,cpr-speed-bin-corners = <28 31>;
+				qcom,cpr-fuse-combos = <24>;
+				qcom,cpr-speed-bins = <3>;
+				qcom,cpr-speed-bin-corners = <28 31 33>;
 				qcom,cpr-corners =
 					/* Speed bin 0 */
 					<28 28 28 28 28 28 28 28>,
 					/* Speed bin 1 */
-					<31 31 31 31 31 31 31 31>;
+					<31 31 31 31 31 31 31 31>,
+					/* Speed bin 2 */
+					<33 33 33 33 33 33 33 33>;
 
 				qcom,cpr-corner-fmax-map =
 					/* Speed bin 0 */
 					<7 14 22 27 28>,
 					/* Speed bin 1 */
-					<7 14 22 27 31>;
+					<7 14 22 27 31>,
+					/* Speed bin 2 */
+					<7 14 22 30 33>;
 
 				qcom,cpr-voltage-ceiling =
 					/* Speed bin 0 */
@@ -350,15 +490,23 @@
 					 828000  828000  828000  828000  828000
 					 828000  828000  828000  932000  932000
 					 932000  932000 1104000 1104000 1104000
-					1104000 1136000 1136000>,
+					1104000 1160000 1160000>,
 					/* Speed bin 1 */
 					<828000  828000  828000  828000  828000
 					 828000  828000  828000  828000  828000
 					 828000  828000  828000  828000  828000
 					 828000  828000  828000  932000  932000
 					 932000  932000 1104000 1104000 1104000
-					1104000 1136000 1136000 1136000 1136000
-					1136000>;
+					1104000 1160000 1160000 1160000 1160000
+					1160000>,
+					/* Speed bin 2 */
+					<828000  828000  828000  828000  828000
+					 828000  828000  828000  828000  828000
+					 828000  828000  828000  828000  828000
+					 828000  828000  828000  932000  932000
+					 932000  932000 1104000 1104000 1104000
+					1104000 1160000 1160000 1160000 1160000
+					1160000 1160000 1160000>;
 
 				qcom,cpr-voltage-floor =
 					/* Speed bin 0 */
@@ -375,7 +523,15 @@
 					 568000  568000  568000  568000  568000
 					 568000  568000  568000  568000  568000
 					 568000  568000  568000  568000  568000
-					 568000>;
+					 568000>,
+					/* Speed bin 2 */
+					<568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000  568000  568000
+					 568000  568000  568000>;
 
 				qcom,cpr-floor-to-ceiling-max-range =
 					/* Speed bin 0 */
@@ -392,7 +548,15 @@
 					 32000  32000  32000  32000  32000
 					 32000  32000  32000  32000  32000
 					 32000  32000  40000  40000  40000
-					 40000>;
+					 40000>,
+					/* Speed bin 2 */
+					<32000  32000  32000  32000  32000
+					 32000  32000  32000  32000  32000
+					 32000  32000  32000  32000  32000
+					 32000  32000  32000  32000  32000
+					 32000  32000  32000  32000  32000
+					 32000  32000  40000  40000  40000
+					 40000  40000  40000>;
 
 				qcom,corner-frequencies =
 					/* Speed bin 0 */
@@ -417,7 +581,19 @@
 					1996800000 2092800000 2169600000
 					2246400000 2323200000 2400000000
 					2476800000 2553600000 2649600000
-					2707200000>;
+					2707200000>,
+					/* Speed bin 2 */
+					<300000000  403200000  480000000
+					 576000000  652800000  748800000
+					 825600000  902400000  979200000
+					1056000000 1132800000 1209600000
+					1286400000 1363200000 1459200000
+					1536000000 1612800000 1689600000
+					1766400000 1843200000 1920000000
+					1996800000 2092800000 2169600000
+					2246400000 2323200000 2400000000
+					2476800000 2553600000 2649600000
+					2707200000 2726400000 2745600000>;
 
 				qcom,cpr-ro-scaling-factor =
 					<2857 3056 2828 2952 2699 2796 2447
@@ -437,28 +613,76 @@
 					 2003 1675>;
 
 				qcom,cpr-open-loop-voltage-fuse-adjustment =
-					/* Speed bin 0 */
-					<  8000   8000   8000      0      0>,
-					/* Speed bin 1 */
-					<  8000   8000   8000      0  16000>;
+				 /* Speed bin 0 */
+				 <   8000     8000     8000        0        0>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 < (-7000)  (-7000)  (-7000) (-15000) (-15000)>,
+				 /* Speed bin 1 */
+				 <   8000     8000     8000        0    16000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 /* Speed bin 2 */
+				 <   8000     8000     8000        0    16000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>,
+				 < (-7000)  (-7000)  (-7000) (-15000)    1000>;
 
 				qcom,cpr-closed-loop-voltage-fuse-adjustment =
-					/* Speed bin 0 */
-					<  6000   6000   8000      0      0>,
-					/* Speed bin 1 */
-					<  6000   6000   8000      0  16000>;
+				 /* Speed bin 0 */
+				 <   6000     6000     8000        0        0>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 < (-9000)  (-9000)  (-7000) (-15000) (-15000)>,
+				 /* Speed bin 1 */
+				 <   6000     6000     8000        0    16000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 /* Speed bin 2 */
+				 <   6000     6000     8000        0    16000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>,
+				 < (-9000)  (-9000)  (-7000) (-15000)    1000>;
 
 				qcom,allow-voltage-interpolation;
 				qcom,allow-quotient-interpolation;
 				qcom,cpr-scaled-open-loop-voltage-as-ceiling;
 
 				qcom,cpr-aging-max-voltage-adjustment = <15000>;
-				qcom,cpr-aging-ref-corner = <27 31>;
+				qcom,cpr-aging-ref-corner = <27 31 33>;
 				qcom,cpr-aging-ro-scaling-factor = <1700>;
 				qcom,allow-aging-voltage-adjustment =
 					/* Speed bin 0 */
 					<0 1 1 1 1 1 1 1>,
 					/* Speed bin 1 */
+					<0 1 1 1 1 1 1 1>,
+					/* Speed bin 2 */
 					<0 1 1 1 1 1 1 1>;
 				qcom,allow-aging-open-loop-voltage-adjustment =
 					<1>;
@@ -477,6 +701,22 @@
 	};
 };
 
+&pil_modem {
+	qcom,mss_pdc_offset = <9>;
+};
+
+/* VDD_APC0 */
+&pm8998_s13 {
+	regulator-min-microvolt = <568000>;
+	regulator-max-microvolt = <1000000>;
+};
+
+/* VDD_APC1 */
+&pm8998_s12 {
+	regulator-min-microvolt = <568000>;
+	regulator-max-microvolt = <1160000>;
+};
+
 &clock_cpucc {
 	compatible = "qcom,clk-cpu-osm-v2";
 
@@ -517,6 +757,23 @@
 		<  1497600000 0x403c0d4e 0x00003e3e 0x2 14 >,
 		<  1593600000 0x403c0e53 0x00004242 0x2 15 >;
 
+	qcom,l3-speedbin2-v0 =
+		<   300000000 0x000c000f 0x00002020 0x1 1 >,
+		<   403200000 0x500c0115 0x00002020 0x1 2 >,
+		<   480000000 0x50140219 0x00002020 0x1 3 >,
+		<   576000000 0x5014031e 0x00002020 0x1 4 >,
+		<   652800000 0x401c0422 0x00002020 0x1 5 >,
+		<   748800000 0x401c0527 0x00002020 0x1 6 >,
+		<   844800000 0x4024062c 0x00002323 0x2 7 >,
+		<   940800000 0x40240731 0x00002727 0x2 8 >,
+		<  1036800000 0x40240836 0x00002b2b 0x2 9 >,
+		<  1132800000 0x402c093b 0x00002f2f 0x2 10 >,
+		<  1209600000 0x402c0a3f 0x00003232 0x2 11 >,
+		<  1305600000 0x40340b44 0x00003636 0x2 12 >,
+		<  1401600000 0x40340c49 0x00003a3a 0x2 13 >,
+		<  1497600000 0x403c0d4e 0x00003e3e 0x2 14 >,
+		<  1593600000 0x403c0e53 0x00004242 0x2 15 >;
+
 	qcom,pwrcl-speedbin0-v0 =
 		<   300000000 0x000c000f 0x00002020 0x1 1 >,
 		<   403200000 0x500c0115 0x00002020 0x1 2 >,
@@ -557,6 +814,26 @@
 		<  1689600000 0x40441058 0x00004646 0x2 17 >,
 		<  1766400000 0x4044115c 0x00004a4a 0x2 18 >;
 
+	qcom,pwrcl-speedbin2-v0 =
+		<   300000000 0x000c000f 0x00002020 0x1 1 >,
+		<   403200000 0x500c0115 0x00002020 0x1 2 >,
+		<   480000000 0x50140219 0x00002020 0x1 3 >,
+		<   576000000 0x5014031e 0x00002020 0x1 4 >,
+		<   652800000 0x401c0422 0x00002020 0x1 5 >,
+		<   748800000 0x401c0527 0x00002020 0x1 6 >,
+		<   825600000 0x401c062b 0x00002222 0x1 7 >,
+		<   902400000 0x4024072f 0x00002626 0x1 8 >,
+		<   979200000 0x40240833 0x00002929 0x1 9 >,
+		<  1056000000 0x402c0937 0x00002c2c 0x2 10 >,
+		<  1132800000 0x402c0a3b 0x00002f2f 0x2 11 >,
+		<  1228800000 0x402c0b40 0x00003333 0x2 12 >,
+		<  1324800000 0x40340c45 0x00003737 0x2 13 >,
+		<  1420800000 0x40340d4a 0x00003b3b 0x2 14 >,
+		<  1516800000 0x403c0e4f 0x00003f3f 0x2 15 >,
+		<  1612800000 0x403c0f54 0x00004343 0x2 16 >,
+		<  1689600000 0x40441058 0x00004646 0x2 17 >,
+		<  1766400000 0x4044115c 0x00004a4a 0x2 18 >;
+
 	qcom,perfcl-speedbin0-v0 =
 		<   300000000 0x000c000f 0x00002020 0x1 1 >,
 		<   403200000 0x500c0115 0x00002020 0x1 2 >,
@@ -619,26 +896,283 @@
 		<  2649600000 0x40541d8a 0x00006e6e 0x2 30 >,
 		<  2745600000 0x40511e8f 0x00007272 0x2 31 >;
 
+	qcom,perfcl-speedbin2-v0 =
+		<   300000000 0x000c000f 0x00002020 0x1 1 >,
+		<   403200000 0x500c0115 0x00002020 0x1 2 >,
+		<   480000000 0x50140219 0x00002020 0x1 3 >,
+		<   576000000 0x5014031e 0x00002020 0x1 4 >,
+		<   652800000 0x401c0422 0x00002020 0x1 5 >,
+		<   748800000 0x401c0527 0x00002020 0x1 6 >,
+		<   825600000 0x401c062b 0x00002222 0x1 7 >,
+		<   902400000 0x4024072f 0x00002626 0x1 8 >,
+		<   979200000 0x40240833 0x00002929 0x1 9 >,
+		<  1056000000 0x402c0937 0x00002c2c 0x1 10 >,
+		<  1132800000 0x402c0a3b 0x00002f2f 0x1 11 >,
+		<  1209600000 0x402c0b3f 0x00003232 0x2 12 >,
+		<  1286400000 0x40340c43 0x00003636 0x2 13 >,
+		<  1363200000 0x40340d47 0x00003939 0x2 14 >,
+		<  1459200000 0x403c0e4c 0x00003d3d 0x2 15 >,
+		<  1536000000 0x403c0f50 0x00004040 0x2 16 >,
+		<  1612800000 0x403c1054 0x00004343 0x2 17 >,
+		<  1689600000 0x40441158 0x00004646 0x2 18 >,
+		<  1766400000 0x4044125c 0x00004a4a 0x2 19 >,
+		<  1843200000 0x40441360 0x00004d4d 0x2 20 >,
+		<  1920000000 0x404c1464 0x00005050 0x2 21 >,
+		<  1996800000 0x404c1568 0x00005353 0x2 22 >,
+		<  2092800000 0x4054166d 0x00005757 0x2 23 >,
+		<  2169600000 0x40541771 0x00005a5a 0x2 24 >,
+		<  2246400000 0x40541875 0x00005e5e 0x2 25 >,
+		<  2323200000 0x40541979 0x00006161 0x2 26 >,
+		<  2400000000 0x40541a7d 0x00006464 0x2 27 >,
+		<  2476800000 0x40541b81 0x00006767 0x2 28 >,
+		<  2553600000 0x40541c85 0x00006a6a 0x2 29 >,
+		<  2649600000 0x40541d8a 0x00006e6e 0x2 30 >,
+		<  2707200000 0x40511e8d 0x00007171 0x2 30 >,
+		<  2764800000 0x40511f90 0x00007373 0x2 31 >,
+		<  2784000000 0x40512091 0x00007474 0x2 32 >,
+		<  2803200000 0x40512192 0x00007575 0x2 33 >;
+
 	qcom,l3-memacc-level-vc-bin0 = <8 13>;
 	qcom,l3-memacc-level-vc-bin1 = <8 13>;
+	qcom,l3-memacc-level-vc-bin2 = <8 13>;
 
 	qcom,pwrcl-memacc-level-vc-bin0 = <12 16>;
 	qcom,pwrcl-memacc-level-vc-bin1 = <12 16>;
+	qcom,pwrcl-memacc-level-vc-bin2 = <12 16>;
 
 	qcom,perfcl-memacc-level-vc-bin0 = <14 22>;
 	qcom,perfcl-memacc-level-vc-bin1 = <14 22>;
+	qcom,perfcl-memacc-level-vc-bin2 = <14 22>;
+};
+
+&pcie1 {
+	qcom,phy-sequence = <0x1804 0x03 0x0
+				0x00dc 0x27 0x0
+				0x0014 0x01 0x0
+				0x0020 0x31 0x0
+				0x0024 0x01 0x0
+				0x0028 0xde 0x0
+				0x002c 0x07 0x0
+				0x0034 0x4c 0x0
+				0x0038 0x06 0x0
+				0x0054 0x18 0x0
+				0x0058 0xb0 0x0
+				0x006c 0x8c 0x0
+				0x0070 0x20 0x0
+				0x0078 0x14 0x0
+				0x007c 0x34 0x0
+				0x00b4 0x06 0x0
+				0x00b8 0x06 0x0
+				0x00c0 0x16 0x0
+				0x00c4 0x16 0x0
+				0x00cc 0x36 0x0
+				0x00d0 0x36 0x0
+				0x00f0 0x05 0x0
+				0x00f8 0x42 0x0
+				0x0100 0x82 0x0
+				0x0108 0x68 0x0
+				0x011c 0x55 0x0
+				0x0120 0x55 0x0
+				0x0124 0x03 0x0
+				0x0128 0xab 0x0
+				0x012c 0xaa 0x0
+				0x0130 0x02 0x0
+				0x0150 0x3f 0x0
+				0x0158 0x3f 0x0
+				0x0178 0x10 0x0
+				0x01cc 0x04 0x0
+				0x01d0 0x30 0x0
+				0x01e0 0x04 0x0
+				0x01e8 0x73 0x0
+				0x01f0 0x1c 0x0
+				0x01fc 0x15 0x0
+				0x021c 0x04 0x0
+				0x0224 0x01 0x0
+				0x0228 0x22 0x0
+				0x022c 0x00 0x0
+				0x0098 0x05 0x0
+				0x080c 0x00 0x0
+				0x0818 0x0d 0x0
+				0x0860 0x01 0x0
+				0x0864 0x3a 0x0
+				0x087c 0x2f 0x0
+				0x08c0 0x09 0x0
+				0x08c4 0x09 0x0
+				0x08c8 0x1a 0x0
+				0x08d0 0x01 0x0
+				0x08d4 0x07 0x0
+				0x08d8 0x31 0x0
+				0x08dc 0x31 0x0
+				0x08e0 0x03 0x0
+				0x08fc 0x02 0x0
+				0x0900 0x01 0x0
+				0x0908 0x12 0x0
+				0x0914 0x25 0x0
+				0x0918 0x00 0x0
+				0x091c 0x05 0x0
+				0x0920 0x01 0x0
+				0x0924 0x26 0x0
+				0x0928 0x12 0x0
+				0x0930 0x04 0x0
+				0x0934 0x04 0x0
+				0x0938 0x09 0x0
+				0x0954 0x15 0x0
+				0x0960 0x32 0x0
+				0x0968 0x7f 0x0
+				0x096c 0x07 0x0
+				0x0978 0x04 0x0
+				0x0980 0x70 0x0
+				0x0984 0x8b 0x0
+				0x0988 0x08 0x0
+				0x098c 0x09 0x0
+				0x0990 0x03 0x0
+				0x0994 0x04 0x0
+				0x0998 0x02 0x0
+				0x099c 0x0c 0x0
+				0x09a4 0x02 0x0
+				0x09c0 0x5c 0x0
+				0x09c4 0x3e 0x0
+				0x09c8 0x3f 0x0
+				0x0a30 0x01 0x0
+				0x0a34 0xa0 0x0
+				0x0a38 0x08 0x0
+				0x0aa4 0x01 0x0
+				0x0aac 0xc3 0x0
+				0x0ab0 0x00 0x0
+				0x0ab8 0x8c 0x0
+				0x0ac0 0x7f 0x0
+				0x0ac4 0x2a 0x0
+				0x0810 0x0c 0x0
+				0x0814 0x00 0x0
+				0x0acc 0x04 0x0
+				0x093c 0x20 0x0
+				0x100c 0x00 0x0
+				0x1018 0x0d 0x0
+				0x1060 0x01 0x0
+				0x1064 0x3a 0x0
+				0x107c 0x2f 0x0
+				0x10c0 0x09 0x0
+				0x10c4 0x09 0x0
+				0x10c8 0x1a 0x0
+				0x10d0 0x01 0x0
+				0x10d4 0x07 0x0
+				0x10d8 0x31 0x0
+				0x10dc 0x31 0x0
+				0x10e0 0x03 0x0
+				0x10fc 0x02 0x0
+				0x1100 0x01 0x0
+				0x1108 0x12 0x0
+				0x1114 0x25 0x0
+				0x1118 0x00 0x0
+				0x111c 0x05 0x0
+				0x1120 0x01 0x0
+				0x1124 0x26 0x0
+				0x1128 0x12 0x0
+				0x1130 0x04 0x0
+				0x1134 0x04 0x0
+				0x1138 0x09 0x0
+				0x1154 0x15 0x0
+				0x1160 0x32 0x0
+				0x1168 0x7f 0x0
+				0x116c 0x07 0x0
+				0x1178 0x04 0x0
+				0x1180 0x70 0x0
+				0x1184 0x8b 0x0
+				0x1188 0x08 0x0
+				0x118c 0x09 0x0
+				0x1190 0x03 0x0
+				0x1194 0x04 0x0
+				0x1198 0x02 0x0
+				0x119c 0x0c 0x0
+				0x11a4 0x02 0x0
+				0x11c0 0x5c 0x0
+				0x11c4 0x3e 0x0
+				0x11c8 0x3f 0x0
+				0x1230 0x01 0x0
+				0x1234 0xa0 0x0
+				0x1238 0x08 0x0
+				0x12a4 0x01 0x0
+				0x12ac 0xc3 0x0
+				0x12b0 0x00 0x0
+				0x12b8 0x8c 0x0
+				0x12c0 0x7f 0x0
+				0x12c4 0x2a 0x0
+				0x1010 0x0c 0x0
+				0x1014 0x0f 0x0
+				0x12cc 0x04 0x0
+				0x113c 0x20 0x0
+				0x195c 0x3f 0x0
+				0x1974 0x50 0x0
+				0x196c 0x9f 0x0
+				0x182c 0x19 0x0
+				0x1840 0x07 0x0
+				0x1854 0x17 0x0
+				0x1868 0x09 0x0
+				0x1800 0x00 0x0
+				0x0aa8 0x01 0x0
+				0x12a8 0x01 0x0
+				0x1808 0x01 0x0>;
+};
+
+&devfreq_l3lat_0 {
+	qcom,core-dev-table =
+		<  300000  300000000 >,
+		<  480000  403200000 >,
+		<  652800  480000000 >,
+		<  748800  576000000 >,
+		<  902400  652800000 >,
+		<  979200  748800000 >,
+		< 1132800  844800000 >,
+		< 1228800  940800000 >,
+		< 1324800 1036800000 >,
+		< 1420800 1132800000 >,
+		< 1516800 1209600000 >,
+		< 1612800 1401600000 >,
+		< 1689600 1497600000 >,
+		< 1766400 1593600000 >;
+};
+
+&devfreq_l3lat_4 {
+	qcom,core-dev-table =
+		<  300000  300000000 >,
+		<  825600  576000000 >,
+		< 1132800  748800000 >,
+		< 1363200  940800000 >,
+		< 1689600 1209600000 >,
+		< 1996800 1401600000 >,
+		< 2400000 1593600000 >;
 };
 
 &bwmon {
 	qcom,count-unit = <0x10000>;
 };
 
+&cpubw {
+	qcom,bw-tbl =
+		< MHZ_TO_MBPS(150, 16) >, /*  2288 MB/s */
+		< MHZ_TO_MBPS(300, 16) >, /*  4577 MB/s */
+		< MHZ_TO_MBPS(426, 16) >, /*  6500 MB/s */
+		< MHZ_TO_MBPS(533, 16) >, /*  8132 MB/s */
+		< MHZ_TO_MBPS(600, 16) >, /*  9155 MB/s */
+		< MHZ_TO_MBPS(806, 16) >, /* 12298 MB/s */
+		< MHZ_TO_MBPS(933, 16) >; /* 14236 MB/s */
+};
+
+&devfreq_cpufreq {
+	mincpubw-cpufreq {
+		cpu-to-dev-map-4 =
+			< 1881600 MHZ_TO_MBPS(200, 4) >,
+			< 2400000 MHZ_TO_MBPS(681, 4) >;
+	};
+};
+
 &clock_gcc {
 	compatible = "qcom,gcc-sdm845-v2", "syscon";
 };
 
 &clock_camcc {
 	compatible = "qcom,cam_cc-sdm845-v2", "syscon";
+	qcom,cam_cc_csi3phytimer_clk_src-opp-handle = <&cam_csiphy3>;
 };
 
 &clock_dispcc {
@@ -675,15 +1209,64 @@
 
 &mdss_mdp {
 	clock-max-rate = <0 0 0 0 430000000 19200000 0>;
+	qcom,sde-min-core-ib-kbps = <4800000>;
+};
+
+&mdss_dsi0 {
+	qcom,core-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,core-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "refgen";
+			qcom,supply-min-voltage = <0>;
+			qcom,supply-max-voltage = <0>;
+			qcom,supply-enable-load = <0>;
+			qcom,supply-disable-load = <0>;
+		};
+	};
+};
+
+&mdss_dsi1 {
+	qcom,core-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,core-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "refgen";
+			qcom,supply-min-voltage = <0>;
+			qcom,supply-max-voltage = <0>;
+			qcom,supply-enable-load = <0>;
+			qcom,supply-disable-load = <0>;
+		};
+	};
+};
+
+&sde_dp {
+	qcom,core-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,core-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "refgen";
+			qcom,supply-min-voltage = <0>;
+			qcom,supply-max-voltage = <0>;
+			qcom,supply-enable-load = <0>;
+			qcom,supply-disable-load = <0>;
+		};
+	};
 };
 
 &energy_costs {
 	CPU_COST_0: core-cost0 {
 		busy-cost-data = <
-			 300000 11
+			 300000 12
 			 403200 17
 			 480000 21
-			 576000 26
+			 576000 27
 			 652800 31
 			 748800 37
 			 825600 42
@@ -691,13 +1274,13 @@
 			 979200 52
 			1056000 57
 			1132800 62
-			1228800 69
+			1228800 70
 			1324800 78
 			1420800 89
 			1516800 103
 			1612800 122
-			1689600 140
-			1766400 159
+			1689600 141
+			1766400 160
 		>;
 		idle-cost-data = <
 			22 18 14 12
@@ -705,37 +1288,37 @@
 	};
 	CPU_COST_1: core-cost1 {
 		busy-cost-data = <
-			 300000 130
-			 403200 480
-			 480000 730
-			 576000 1030
-			 652800 1260
-			 748800 1530
-			 825600 1740
-			 902400 1930
-			 979200 2110
-			1056000 2290
-			1132800 2460
-			1209600 2630
-			1286400 2800
-			1363200 2980
-			1459200 3240
-			1536000 3490
-			1612800 3780
-			1689600 4120
-			1766400 4530
-			1843200 5020
-			1920000 5590
-			1996800 6230
+			 300000 189
+			 403200 523
+			 480000 763
+			 576000 1052
+			 652800 1273
+			 748800 1536
+			 825600 1736
+			 902400 1926
+			 979200 2108
+			1056000 2284
+			1132800 2456
+			1209600 2628
+			1286400 2804
+			1363200 2992
+			1459200 3255
+			1536000 3499
+			1612800 3786
+			1689600 4128
+			1766400 4535
+			1843200 5019
+			1920000 5583
+			1996800 6226
 			2092800 7120
-			2169600 7870
-			2246400 8620
-			2323200 9330
+			2169600 7876
+			2246400 8628
+			2323200 9344
 			2400000 10030
-			2476800 10830
-			2553600 12080
-			2630400 14580
-			2707200 19960
+			2476800 10806
+			2553600 12045
+			2649600 15686
+			2745600 25586
 		>;
 		idle-cost-data = <
 			100 80 60 40
@@ -797,8 +1380,8 @@
 			2400000 135
 			2476800 140
 			2553600 145
-			2630400 150
-			2707200 155
+			2649600 150
+			2745600 155
 		>;
 		idle-cost-data = <
 			4 3 2 1
@@ -816,7 +1399,7 @@
 &msm_gpu {
 	/* Updated chip ID */
 	qcom,chipid = <0x06030001>;
-	qcom,initial-pwrlevel = <5>;
+	qcom,initial-pwrlevel = <6>;
 
 	qcom,gpu-pwrlevels {
 		#address-cells = <1>;
@@ -826,54 +1409,62 @@
 
 		qcom,gpu-pwrlevel@0 {
 			reg = <0>;
+			qcom,gpu-freq = <710000000>;
+			qcom,bus-freq = <12>;
+			qcom,bus-min = <12>;
+			qcom,bus-max = <12>;
+		};
+
+		qcom,gpu-pwrlevel@1 {
+			reg = <1>;
 			qcom,gpu-freq = <675000000>;
 			qcom,bus-freq = <12>;
 			qcom,bus-min = <10>;
 			qcom,bus-max = <12>;
 		};
 
-		qcom,gpu-pwrlevel@1 {
-			reg = <1>;
+		qcom,gpu-pwrlevel@2 {
+			reg = <2>;
 			qcom,gpu-freq = <596000000>;
 			qcom,bus-freq = <10>;
 			qcom,bus-min = <9>;
-			qcom,bus-max = <11>;
+			qcom,bus-max = <12>;
 		};
 
-		qcom,gpu-pwrlevel@2 {
-			reg = <2>;
+		qcom,gpu-pwrlevel@3 {
+			reg = <3>;
 			qcom,gpu-freq = <520000000>;
 			qcom,bus-freq = <9>;
 			qcom,bus-min = <8>;
 			qcom,bus-max = <10>;
 		};
 
-		qcom,gpu-pwrlevel@3 {
-			reg = <3>;
+		qcom,gpu-pwrlevel@4 {
+			reg = <4>;
 			qcom,gpu-freq = <414000000>;
 			qcom,bus-freq = <8>;
 			qcom,bus-min = <7>;
 			qcom,bus-max = <9>;
 		};
 
-		qcom,gpu-pwrlevel@4 {
-			reg = <4>;
+		qcom,gpu-pwrlevel@5 {
+			reg = <5>;
 			qcom,gpu-freq = <342000000>;
 			qcom,bus-freq = <6>;
 			qcom,bus-min = <5>;
 			qcom,bus-max = <7>;
 		};
 
-		qcom,gpu-pwrlevel@5 {
-			reg = <5>;
+		qcom,gpu-pwrlevel@6 {
+			reg = <6>;
 			qcom,gpu-freq = <257000000>;
 			qcom,bus-freq = <4>;
 			qcom,bus-min = <3>;
 			qcom,bus-max = <5>;
 		};
 
-		qcom,gpu-pwrlevel@6 {
-			reg = <6>;
+		qcom,gpu-pwrlevel@7 {
+			reg = <7>;
 			qcom,gpu-freq = <0>;
 			qcom,bus-freq = <0>;
 			qcom,bus-min = <0>;
@@ -889,9 +1480,10 @@
 
 		compatible = "qcom,gmu-pwrlevels";
 
+		/* GMU power levels must go from lowest to highest */
 		qcom,gmu-pwrlevel@0 {
 			reg = <0>;
-			qcom,gmu-freq = <500000000>;
+			qcom,gmu-freq = <0>;
 		};
 
 		qcom,gmu-pwrlevel@1 {
@@ -901,7 +1493,30 @@
 
 		qcom,gmu-pwrlevel@2 {
 			reg = <2>;
-			qcom,gmu-freq = <0>;
+			qcom,gmu-freq = <500000000>;
 		};
 	};
 };
+
+&qusb_phy0 {
+		qcom,qusb-phy-init-seq =
+			/* <value reg_offset> */
+			   <0x23 0x210 /* PWR_CTRL1 */
+			    0x03 0x04  /* PLL_ANALOG_CONTROLS_TWO */
+			    0x7c 0x18c /* PLL_CLOCK_INVERTERS */
+			    0x80 0x2c  /* PLL_CMODE */
+			    0x0a 0x184 /* PLL_LOCK_DELAY */
+			    0x19 0xb4  /* PLL_DIGITAL_TIMERS_TWO */
+			    0x40 0x194 /* PLL_BIAS_CONTROL_1 */
+			    0x20 0x198 /* PLL_BIAS_CONTROL_2 */
+			    0x21 0x214 /* PWR_CTRL2 */
+			    0x07 0x220 /* IMP_CTRL1 */
+			    0x58 0x224 /* IMP_CTRL2 */
+			    0x45 0x240 /* TUNE1 */
+			    0x29 0x244 /* TUNE2 */
+			    0xca 0x248 /* TUNE3 */
+			    0x04 0x24c /* TUNE4 */
+			    0x03 0x250 /* TUNE5 */
+			    0x00 0x23c /* CHG_CTRL2 */
+			    0x22 0x210>; /* PWR_CTRL1 */
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 4366d91..9ea5468 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -26,6 +26,8 @@
 #include <dt-bindings/thermal/thermal.h>
 #include <dt-bindings/msm/msm-bus-ids.h>
 
+#define MHZ_TO_MBPS(mhz, w) ((mhz * 1000000 * w) / (1024 * 1024))
+
 / {
 	model = "Qualcomm Technologies, Inc. SDM845";
 	compatible = "qcom,sdm845";
@@ -34,8 +36,8 @@
 
 	aliases {
 		ufshc1 = &ufshc_mem; /* Embedded UFS slot */
-		ufshc2 = &ufshc_card; /* Removable UFS slot */
 		pci-domain0 = &pcie0;
+		pci-domain1 = &pcie1;
 		sdhc2 = &sdhc_2; /* SDC2 SD card slot */
 	};
 
@@ -646,6 +648,94 @@
 	ranges = <0 0 0 0xffffffff>;
 	compatible = "simple-bus";
 
+	jtag_mm0: jtagmm@7040000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7040000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU0>;
+	};
+
+	jtag_mm1: jtagmm@7140000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7140000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU1>;
+	};
+
+	jtag_mm2: jtagmm@7240000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7240000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU2>;
+	};
+
+	jtag_mm3: jtagmm@7340000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7340000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU3>;
+	};
+
+	jtag_mm4: jtagmm@7440000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7440000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU4>;
+	};
+
+	jtag_mm5: jtagmm@7540000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7540000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU5>;
+	};
+
+	jtag_mm6: jtagmm@7640000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7640000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU6>;
+	};
+
+	jtag_mm7: jtagmm@7740000 {
+		compatible = "qcom,jtagv8-mm";
+		reg = <0x7740000 0x1000>;
+		reg-names = "etm-base";
+
+		clocks = <&clock_aop QDSS_CLK>;
+		clock-names = "core_clk";
+
+		qcom,coresight-jtagmm-cpu = <&CPU7>;
+	};
+
 	intc: interrupt-controller@17a00000 {
 		compatible = "arm,gic-v3";
 		#interrupt-cells = <3>;
@@ -756,6 +846,7 @@
 		interrupt-controller;
 		#interrupt-cells = <4>;
 		cell-index = <0>;
+		qcom,enable-ahb-bus-workaround;
 	};
 
 	spmi_debug_bus: qcom,spmi-debug@6b22000 {
@@ -824,12 +915,12 @@
 			<MSM_BUS_MASTER_AMPSS_M0 MSM_BUS_SLAVE_LLCC>;
 		qcom,active-only;
 		qcom,bw-tbl =
-			<  2288 /* 150 MHz */ >,
-			<  4577 /* 300 MHz */ >,
-			<  6500 /* 426 MHz */ >,
-			<  8132 /* 533 MHz */ >,
-			<  9155 /* 600 MHz */ >,
-			< 10681 /* 700 MHz */ >;
+			< MHZ_TO_MBPS(150, 16) >, /*  2288 MB/s */
+			< MHZ_TO_MBPS(300, 16) >, /*  4577 MB/s */
+			< MHZ_TO_MBPS(426, 16) >, /*  6500 MB/s */
+			< MHZ_TO_MBPS(533, 16) >, /*  8132 MB/s */
+			< MHZ_TO_MBPS(600, 16) >, /*  9155 MB/s */
+			< MHZ_TO_MBPS(700, 16) >; /* 10681 MB/s */
 	};
 
 	bwmon: qcom,cpu-bwmon {
@@ -844,21 +935,21 @@
 
 	llccbw: qcom,llccbw {
 		compatible = "qcom,devbw";
-		governor = "powersave";
+		governor = "performance";
 		qcom,src-dst-ports =
 			<MSM_BUS_MASTER_LLCC MSM_BUS_SLAVE_EBI_CH0>;
 		qcom,active-only;
 		qcom,bw-tbl =
-			<  762 /*  200 MHz */ >,
-			< 1144 /*  300 MHz */ >,
-			< 1720 /*  451 MHz */ >,
-			< 2086 /*  547 MHz */ >,
-			< 2597 /*  681 MHz */ >,
-			< 2929 /*  768 MHz */ >,
-			< 3879 /* 1017 MHz */ >,
-			< 4943 /* 1296 MHz */ >,
-			< 5931 /* 1555 MHz */ >,
-			< 6881 /* 1804 MHz */ >;
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1296, 4) >, /* 4943 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
 	};
 
 	llcc_bwmon: qcom,llcc-bwmon {
@@ -879,16 +970,16 @@
 		qcom,src-dst-ports = <1 512>;
 		qcom,active-only;
 		qcom,bw-tbl =
-			<  762 /*  200 MHz */ >,
-			< 1144 /*  300 MHz */ >,
-			< 1720 /*  451 MHz */ >,
-			< 2086 /*  547 MHz */ >,
-			< 2597 /*  681 MHz */ >,
-			< 2929 /*  768 MHz */ >,
-			< 3879 /* 1017 MHz */ >,
-			< 4943 /* 1296 MHz */ >,
-			< 5931 /* 1555 MHz */ >,
-			< 6881 /* 1804 MHz */ >;
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1296, 4) >, /* 4943 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
 	};
 
 	memlat_cpu4: qcom,memlat-cpu4 {
@@ -898,16 +989,16 @@
 		qcom,active-only;
 		status = "ok";
 		qcom,bw-tbl =
-			<  762 /*  200 MHz */ >,
-			< 1144 /*  300 MHz */ >,
-			< 1720 /*  451 MHz */ >,
-			< 2086 /*  547 MHz */ >,
-			< 2597 /*  681 MHz */ >,
-			< 2929 /*  768 MHz */ >,
-			< 3879 /* 1017 MHz */ >,
-			< 4943 /* 1296 MHz */ >,
-			< 5931 /* 1555 MHz */ >,
-			< 6881 /* 1804 MHz */ >;
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1296, 4) >, /* 4943 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
 	};
 
 	snoc_cnoc_keepalive: qcom,snoc_cnoc_keepalive {
@@ -926,11 +1017,11 @@
 		qcom,target-dev = <&memlat_cpu0>;
 		qcom,cachemiss-ev = <0x2A>;
 		qcom,core-dev-table =
-			<  300000  762 >,
-			<  748800 1720 >,
-			< 1132800 2086 >,
-			< 1440000 2929 >,
-			< 1593600 3879 >;
+			<  300000 MHZ_TO_MBPS( 200, 4) >,
+			<  748800 MHZ_TO_MBPS( 451, 4) >,
+			< 1132800 MHZ_TO_MBPS( 547, 4) >,
+			< 1440000 MHZ_TO_MBPS( 768, 4) >,
+			< 1593600 MHZ_TO_MBPS(1017, 4) >;
 	};
 
 	devfreq_memlat_4: qcom,cpu4-memlat-mon {
@@ -939,14 +1030,14 @@
 		qcom,target-dev = <&memlat_cpu4>;
 		qcom,cachemiss-ev = <0x2A>;
 		qcom,core-dev-table =
-			<  300000  762 >,
-			<  499200 1720 >,
-			<  806400 2086 >,
-			< 1036800 2929 >,
-			< 1190400 3879 >,
-			< 1574400 4943 >,
-			< 1728000 5931 >,
-			< 1958400 6881 >;
+			<  300000 MHZ_TO_MBPS( 200, 4) >,
+			<  499200 MHZ_TO_MBPS( 451, 4) >,
+			<  806400 MHZ_TO_MBPS( 547, 4) >,
+			< 1036800 MHZ_TO_MBPS( 768, 4) >,
+			< 1190400 MHZ_TO_MBPS(1017, 4) >,
+			< 1574400 MHZ_TO_MBPS(1296, 4) >,
+			< 1728000 MHZ_TO_MBPS(1555, 4) >,
+			< 1958400 MHZ_TO_MBPS(1804, 4) >;
 	};
 
 	l3_cpu0: qcom,l3-cpu0 {
@@ -1004,26 +1095,26 @@
 		qcom,src-dst-ports = <1 512>;
 		qcom,active-only;
 		qcom,bw-tbl =
-			<  762 /*  200 MHz */ >,
-			< 1144 /*  300 MHz */ >,
-			< 1720 /*  451 MHz */ >,
-			< 2086 /*  547 MHz */ >,
-			< 2597 /*  681 MHz */ >,
-			< 2929 /*  768 MHz */ >,
-			< 3879 /* 1017 MHz */ >,
-			< 4943 /* 1296 MHz */ >,
-			< 5931 /* 1555 MHz */ >,
-			< 6881 /* 1804 MHz */ >;
+			< MHZ_TO_MBPS( 200, 4) >, /* 762 MB/s */
+			< MHZ_TO_MBPS( 300, 4) >, /* 1144 MB/s */
+			< MHZ_TO_MBPS( 451, 4) >, /* 1720 MB/s */
+			< MHZ_TO_MBPS( 547, 4) >, /* 2086 MB/s */
+			< MHZ_TO_MBPS( 681, 4) >, /* 2597 MB/s */
+			< MHZ_TO_MBPS( 768, 4) >, /* 2929 MB/s */
+			< MHZ_TO_MBPS(1017, 4) >, /* 3879 MB/s */
+			< MHZ_TO_MBPS(1296, 4) >, /* 4943 MB/s */
+			< MHZ_TO_MBPS(1555, 4) >, /* 5931 MB/s */
+			< MHZ_TO_MBPS(1804, 4) >; /* 6881 MB/s */
 	};
 
-	devfreq-cpufreq {
+	devfreq_cpufreq: devfreq-cpufreq {
 		mincpubw-cpufreq {
 			target-dev = <&mincpubw>;
 			cpu-to-dev-map-0 =
-				< 1708800  762 >;
+				< 1708800 MHZ_TO_MBPS(200, 4) >;
 			cpu-to-dev-map-4 =
-				< 1881600  762 >,
-				< 2208000 2597 >;
+				< 1881600 MHZ_TO_MBPS(200, 4) >,
+				< 2208000 MHZ_TO_MBPS(681, 4) >;
 		};
 	};
 
@@ -1091,6 +1182,7 @@
 		reg = <0x5090000 0x9000>;
 		reg-names = "cc_base";
 		vdd_cx-supply = <&pm8998_s9_level>;
+		vdd_mx-supply = <&pm8998_s6_level>;
 		qcom,gpu_cc_gmu_clk_src-opp-handle = <&gmu>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
@@ -1101,7 +1193,6 @@
 		reg = <0x5090000 0x9000>;
 		reg-names = "cc_base";
 		vdd_gfx-supply = <&pm8005_s1_level>;
-		vdd_mx-supply = <&pm8998_s6_level>;
 		qcom,gpu_cc_gx_gfx3d_clk_src-opp-handle = <&msm_gpu>;
 		#clock-cells = <1>;
 		#reset-cells = <1>;
@@ -1543,102 +1634,6 @@
 		status = "disabled";
 	};
 
-	extcon_storage_cd: extcon_storage_cd {
-		compatible = "extcon-gpio";
-		extcon-id = <62>; /* EXTCON_MECHANICAL */
-		status = "disabled";
-	};
-
-	ufsphy_card: ufsphy_card@1da7000 {
-		reg = <0x1da7000 0xda8>; /* PHY regs */
-		reg-names = "phy_mem";
-		#phy-cells = <0>;
-
-		lanes-per-direction = <1>;
-
-		clock-names = "ref_clk_src",
-			"ref_clk",
-			"ref_aux_clk";
-		clocks = <&clock_rpmh RPMH_CXO_CLK>,
-			<&clock_gcc GCC_UFS_CARD_CLKREF_CLK>,
-			<&clock_gcc GCC_UFS_CARD_PHY_AUX_HW_CTL_CLK>;
-
-		status = "disabled";
-	};
-
-	ufshc_card: ufshc_card@1da4000 {
-		compatible = "qcom,ufshc";
-		reg = <0x1da4000 0x2500>;
-		interrupts = <0 125 0>;
-		phys = <&ufsphy_card>;
-		phy-names = "ufsphy";
-
-		lanes-per-direction = <1>;
-		dev-ref-clk-freq = <0>; /* 19.2 MHz */
-
-		clock-names =
-			"core_clk",
-			"bus_aggr_clk",
-			"iface_clk",
-			"core_clk_unipro",
-			"core_clk_ice",
-			"ref_clk",
-			"tx_lane0_sync_clk",
-			"rx_lane0_sync_clk";
-		clocks =
-			<&clock_gcc GCC_UFS_CARD_AXI_HW_CTL_CLK>,
-			<&clock_gcc GCC_AGGRE_UFS_CARD_AXI_HW_CTL_CLK>,
-			<&clock_gcc GCC_UFS_CARD_AHB_CLK>,
-			<&clock_gcc GCC_UFS_CARD_UNIPRO_CORE_HW_CTL_CLK>,
-			<&clock_gcc GCC_UFS_CARD_ICE_CORE_HW_CTL_CLK>,
-			<&clock_rpmh RPMH_CXO_CLK>,
-			<&clock_gcc GCC_UFS_CARD_TX_SYMBOL_0_CLK>,
-			<&clock_gcc GCC_UFS_CARD_RX_SYMBOL_0_CLK>;
-		freq-table-hz =
-			<50000000 200000000>,
-			<0 0>,
-			<0 0>,
-			<37500000 150000000>,
-			<75000000 300000000>,
-			<0 0>,
-			<0 0>,
-			<0 0>;
-
-		qcom,msm-bus,name = "ufshc_card";
-		qcom,msm-bus,num-cases = <9>;
-		qcom,msm-bus,num-paths = <2>;
-		qcom,msm-bus,vectors-KBps =
-		<122 512 0 0>, <1 756 0 0>,          /* No vote */
-		<122 512 922 0>, <1 756 1000 0>,     /* PWM G1 */
-		<122 512 127796 0>, <1 756 1000 0>,  /* HS G1 RA */
-		<122 512 255591 0>, <1 756 1000 0>,  /* HS G2 RA */
-		<122 512 2097152 0>, <1 756 102400 0>,  /* HS G3 RA */
-		<122 512 149422 0>, <1 756 1000 0>,  /* HS G1 RB */
-		<122 512 298189 0>, <1 756 1000 0>,  /* HS G2 RB */
-		<122 512 2097152 0>, <1 756 102400 0>,  /* HS G3 RB */
-		<122 512 7643136 0>, <1 756 307200 0>; /* Max. bandwidth */
-		qcom,bus-vector-names = "MIN",
-		"PWM_G1_L1",
-		"HS_RA_G1_L1", "HS_RA_G2_L1", "HS_RA_G3_L1",
-		"HS_RB_G1_L1", "HS_RB_G2_L1", "HS_RB_G3_L1",
-		"MAX";
-
-		/* PM QoS */
-		qcom,pm-qos-cpu-groups = <0x0f 0xf0>;
-		qcom,pm-qos-cpu-group-latency-us = <70 70>;
-		qcom,pm-qos-default-cpu = <0>;
-
-		/*
-		 * Note: this instance doesn't have control over UFS device
-		 * reset
-		 */
-
-		resets = <&clock_gcc GCC_UFS_CARD_BCR>;
-		reset-names = "core_reset";
-
-		status = "disabled";
-	};
-
 	sdhc_2: sdhci@8804000 {
 		compatible = "qcom,sdhci-msm-v5";
 		reg = <0x8804000 0x1000>;
@@ -1737,7 +1732,9 @@
 		qcom,sysmon-id = <0>;
 		qcom,ssctl-instance-id = <0x12>;
 		qcom,override-acc;
+		qcom,signal-aop;
 		qcom,qdsp6v65-1-0;
+		qcom,mss_pdc_offset = <8>;
 		status = "ok";
 		memory-region = <&pil_modem_mem>;
 		qcom,mem-protect-id = <0xF>;
@@ -1751,6 +1748,9 @@
 
 		/* GPIO output to mss */
 		qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_1_out 0 0>;
+
+		mboxes = <&qmp_aop 0>;
+		mbox-names = "mss-pil";
 		qcom,mba-mem@0 {
 			compatible = "qcom,pil-mba-mem";
 			memory-region = <&pil_mba_mem>;
@@ -1777,6 +1777,7 @@
 		status = "ok";
 		qcom,ssctl-instance-id = <0x14>;
 		qcom,firmware-name = "adsp";
+		qcom,signal-aop;
 		memory-region = <&pil_adsp_mem>;
 
 		/* GPIO inputs from lpass */
@@ -1787,6 +1788,9 @@
 
 		/* GPIO output to lpass */
 		qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_2_out 0 0>;
+
+		mboxes = <&qmp_aop 0>;
+		mbox-names = "adsp-pil";
 	};
 
 	qcom,ssc@5c00000 {
@@ -1808,6 +1812,7 @@
 		qcom,smem-id = <424>;
 		qcom,sysmon-id = <3>;
 		qcom,ssctl-instance-id = <0x16>;
+		qcom,signal-aop;
 		qcom,firmware-name = "slpi";
 		status = "ok";
 		memory-region = <&pil_slpi_mem>;
@@ -1820,6 +1825,9 @@
 
 		/* GPIO output to ssc */
 		qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_3_out 0 0>;
+
+		mboxes = <&qmp_aop 0>;
+		mbox-names = "slpi-pil";
 	};
 
 	slim_aud: slim@171c0000 {
@@ -1874,6 +1882,8 @@
 		interrupts = <GIC_SPI 492 IRQ_TYPE_LEVEL_HIGH>;
 		reg = <0x88e0000 0x2000>;
 		reg-names = "eud_base";
+		clocks = <&clock_gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>;
+		clock-names = "cfg_ahb_clk";
 		status = "ok";
 	};
 
@@ -1902,9 +1912,13 @@
 
 		qcom,pas-id = <14>;
 		qcom,proxy-timeout-ms = <10000>;
+		qcom,signal-aop;
 		qcom,firmware-name = "spss";
 		memory-region = <&pil_spss_mem>;
 		qcom,spss-scsr-bits = <24 25>;
+
+		mboxes = <&qmp_aop 0>;
+		mbox-names = "spss-pil";
 	};
 
 	wdog: qcom,wdt@17980000{
@@ -1913,7 +1927,7 @@
 		reg-names = "wdt-base";
 		interrupts = <0 0 0>, <0 1 0>;
 		qcom,bark-time = <11000>;
-		qcom,pet-time = <10000>;
+		qcom,pet-time = <9360>;
 		qcom,ipi-ping;
 		qcom,wakeup-enable;
 	};
@@ -1937,6 +1951,7 @@
 		qcom,sysmon-id = <7>;
 		qcom,ssctl-instance-id = <0x17>;
 		qcom,firmware-name = "cdsp";
+		qcom,signal-aop;
 		memory-region = <&pil_cdsp_mem>;
 
 		/* GPIO inputs from turing */
@@ -1948,6 +1963,9 @@
 		/* GPIO output to turing*/
 		qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_5_out 0 0>;
 		status = "ok";
+
+		mboxes = <&qmp_aop 0>;
+		mbox-names = "cdsp-pil";
 	};
 
 	qcom,msm-rtb {
@@ -2278,19 +2296,19 @@
 		};
 
 		LLCC_1: llcc_1_dcache {
-			qcom,dump-size = <0x114100>;
+			qcom,dump-size = <0x1141c0>;
 		};
 
 		LLCC_2: llcc_2_dcache {
-			qcom,dump-size = <0x114100>;
+			qcom,dump-size = <0x1141c0>;
 		};
 
 		LLCC_3: llcc_3_dcache {
-			qcom,dump-size = <0x114100>;
+			qcom,dump-size = <0x1141c0>;
 		};
 
 		LLCC_4: llcc_4_dcache {
-			qcom,dump-size = <0x114100>;
+			qcom,dump-size = <0x1141c0>;
 		};
 	};
 
@@ -2540,6 +2558,18 @@
 		qcom,fragmented-data;
 	};
 
+	qcom,qsee_ipc_irq_bridge {
+		compatible = "qcom,qsee-ipc-irq-bridge";
+
+		qcom,qsee-ipc-irq-spss {
+			qcom,rx-irq-clr = <0x1888008 0x4>;
+			qcom,rx-irq-clr-mask = <0x1>;
+			qcom,dev-name = "qsee_ipc_irq_spss";
+			interrupts = <0 349 4>;
+			label = "spss";
+		};
+	};
+
 	qcom,spcom {
 		compatible = "qcom,spcom";
 
@@ -2797,7 +2827,7 @@
 		qcom,smmu-s1-bypass;
 		qcom,bandwidth-vote-for-ipa;
 		qcom,msm-bus,name = "ipa";
-		qcom,msm-bus,num-cases = <4>;
+		qcom,msm-bus,num-cases = <5>;
 		qcom,msm-bus,num-paths = <4>;
 		qcom,msm-bus,vectors-KBps =
 		/* No vote */
@@ -2805,22 +2835,28 @@
 			<90 585 0 0>,
 			<1 676 0 0>,
 			<143 777 0 0>,
+		/* SVS2 */
+			<90 512 80000 600000>,
+			<90 585 80000 350000>,
+			<1 676 40000 40000>, /*gcc_config_noc_clk_src */
+			<143 777 0 75>, /* IB defined for IPA2X_clk in MHz*/
 		/* SVS */
 			<90 512 80000 640000>,
 			<90 585 80000 640000>,
 			<1 676 80000 80000>,
-			<143 777 0 150>, /* IB defined for IPA clk in MHz*/
+			<143 777 0 150>, /* IB defined for IPA2X_clk in MHz*/
 		/* NOMINAL */
 			<90 512 206000 960000>,
 			<90 585 206000 960000>,
 			<1 676 206000 160000>,
-			<143 777 0 300>, /* IB defined for IPA clk in MHz*/
+			<143 777 0 300>, /* IB defined for IPA2X_clk in MHz*/
 		/* TURBO */
 			<90 512 206000 3600000>,
 			<90 585 206000 3600000>,
 			<1 676 206000 300000>,
 			<143 777 0 355>; /* IB defined for IPA clk in MHz*/
-		qcom,bus-vector-names = "MIN", "SVS", "NOMINAL", "TURBO";
+		qcom,bus-vector-names =
+			"MIN", "SVS2", "SVS", "NOMINAL", "TURBO";
 
 		/* IPA RAM mmap */
 		qcom,ipa-ram-mmap = <
@@ -2931,6 +2967,7 @@
 		compatible = "qcom,pil-tz-generic";
 		qcom,pas-id = <0xf>;
 		qcom,firmware-name = "ipa_fws";
+		qcom,pil-force-shutdown;
 	};
 
 	qcom,chd_sliver {
@@ -3034,6 +3071,11 @@
 				#cooling-cells = <2>;
 			};
 
+			modem_skin: modem_skin {
+				qcom,qmi-dev-name = "modem_skin";
+				#cooling-cells = <2>;
+			};
+
 			modem_vdd: modem_vdd {
 				qcom,qmi-dev-name = "cpuv_restriction_cold";
 				#cooling-cells = <2>;
@@ -3556,7 +3598,7 @@
 	};
 
 	gpi_dma0: qcom,gpi-dma@0x800000 {
-		#dma-cells = <6>;
+		#dma-cells = <5>;
 		compatible = "qcom,gpi-dma";
 		reg = <0x800000 0x60000>;
 		reg-names = "gpi-top";
@@ -3568,11 +3610,13 @@
 		qcom,gpii-mask = <0xfa>;
 		qcom,ev-factor = <2>;
 		iommus = <&apps_smmu 0x0016 0x0>;
+		qcom,smmu-cfg = <0x1>;
+		qcom,iova-range = <0x0 0x100000 0x0 0x100000>;
 		status = "ok";
 	};
 
 	gpi_dma1: qcom,gpi-dma@0xa00000 {
-		#dma-cells = <6>;
+		#dma-cells = <5>;
 		compatible = "qcom,gpi-dma";
 		reg = <0xa00000 0x60000>;
 		reg-names = "gpi-top";
@@ -3584,6 +3628,8 @@
 		qcom,gpii-mask = <0xfa>;
 		qcom,ev-factor = <2>;
 		iommus = <&apps_smmu 0x06d6 0x0>;
+		qcom,smmu-cfg = <0x1>;
+		qcom,iova-range = <0x0 0x100000 0x0 0x100000>;
 		status = "ok";
 	};
 
@@ -3677,6 +3723,10 @@
 			 <&clock_rpmh RPMH_RF_CLK3_A>;
 		clock-names = "rf_clk3_clk", "rf_clk3_pin_clk";
 		qcom,smmu-support;
+		qcom,smmu-mapping = <0x20000000 0xe0000000>;
+		qcom,smmu-s1-en;
+		qcom,smmu-fast-map;
+		qcom,smmu-coherent;
 		qcom,keep-radio-on-during-sleep;
 		status = "disabled";
 	};
diff --git a/arch/arm64/boot/dts/qcom/smb1355.dtsi b/arch/arm64/boot/dts/qcom/smb1355.dtsi
index 999d87a..bde4d1e 100644
--- a/arch/arm64/boot/dts/qcom/smb1355.dtsi
+++ b/arch/arm64/boot/dts/qcom/smb1355.dtsi
@@ -13,30 +13,75 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 
 &qupv3_se10_i2c {
-	smb1355: qcom,smb1355@8 {
+	smb1355_0: qcom,smb1355@8 {
 		compatible = "qcom,i2c-pmic";
 		reg = <0x8>;
 		#address-cells = <1>;
-		#size-cells = <1>;
+		#size-cells = <0>;
 		interrupt-parent = <&spmi_bus>;
 		interrupts = <0x0 0xd1 0x0 IRQ_TYPE_LEVEL_LOW>;
-		interrupt_names = "smb1355";
+		interrupt_names = "smb1355_0";
 		interrupt-controller;
 		#interrupt-cells = <3>;
 		qcom,periph-map = <0x10 0x12 0x13 0x16>;
 
-		smb1355_revid: qcom,revid@100 {
+		smb1355_revid_0: qcom,revid@100 {
 			compatible = "qcom,qpnp-revid";
 			reg = <0x100 0x100>;
 		};
 
-		smb1355_charger: qcom,smb1355-charger@1000 {
+		smb1355_charger_0: qcom,smb1355-charger@1000 {
 			compatible = "qcom,smb1355";
-			qcom,pmic-revid = <&smb1355_revid>;
+			qcom,pmic-revid = <&smb1355_revid_0>;
 			reg = <0x1000 0x700>;
 			#address-cells = <1>;
 			#size-cells = <1>;
-			interrupt-parent = <&smb1355>;
+			interrupt-parent = <&smb1355_0>;
+			status = "disabled";
+
+			io-channels = <&pmi8998_rradc 2>,
+				      <&pmi8998_rradc 12>;
+			io-channel-names = "charger_temp",
+					   "charger_temp_max";
+
+			qcom,chgr@1000 {
+				reg = <0x1000 0x100>;
+				interrupts = <0x10 0x1 IRQ_TYPE_EDGE_RISING>;
+				interrupt-names = "chg-state-change";
+			};
+
+			qcom,chgr-misc@1600 {
+				reg = <0x1600 0x100>;
+				interrupts = <0x16 0x1 IRQ_TYPE_EDGE_RISING>;
+				interrupt-names = "wdog-bark";
+			};
+		};
+	};
+
+	smb1355_1: qcom,smb1355@c {
+		compatible = "qcom,i2c-pmic";
+		reg = <0xc>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupt-parent = <&spmi_bus>;
+		interrupts = <0x0 0xd1 0x0 IRQ_TYPE_LEVEL_LOW>;
+		interrupt_names = "smb1355_1";
+		interrupt-controller;
+		#interrupt-cells = <3>;
+		qcom,periph-map = <0x10 0x12 0x13 0x16>;
+
+		smb1355_revid_1: qcom,revid@100 {
+			compatible = "qcom,qpnp-revid";
+			reg = <0x100 0x100>;
+		};
+
+		smb1355_charger_1: qcom,smb1355-charger@1000 {
+			compatible = "qcom,smb1355";
+			qcom,pmic-revid = <&smb1355_revid_1>;
+			reg = <0x1000 0x700>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			interrupt-parent = <&smb1355_1>;
 			status = "disabled";
 
 			io-channels = <&pmi8998_rradc 2>,
diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
index 3580896..ef1b9e5 100644
--- a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
+++ b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
@@ -27,7 +27,7 @@
 		stdout-path = "serial0:115200n8";
 	};
 
-	memory {
+	memory@0 {
 		device_type = "memory";
 		reg = <0x0 0x0 0x0 0x40000000>;
 	};
diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
index 68a90833..54dc283 100644
--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
+++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
@@ -72,7 +72,7 @@
 			     <1 10 0xf08>;
 	};
 
-	amba_apu {
+	amba_apu: amba_apu@0 {
 		compatible = "simple-bus";
 		#address-cells = <2>;
 		#size-cells = <1>;
@@ -175,7 +175,7 @@
 		};
 
 		i2c0: i2c@ff020000 {
-			compatible = "cdns,i2c-r1p10";
+			compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
 			status = "disabled";
 			interrupt-parent = <&gic>;
 			interrupts = <0 17 4>;
@@ -185,7 +185,7 @@
 		};
 
 		i2c1: i2c@ff030000 {
-			compatible = "cdns,i2c-r1p10";
+			compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
 			status = "disabled";
 			interrupt-parent = <&gic>;
 			interrupts = <0 18 4>;
diff --git a/arch/arm64/configs/msm8953-perf_defconfig b/arch/arm64/configs/msm8953-perf_defconfig
new file mode 100644
index 0000000..4e7fe31
--- /dev/null
+++ b/arch/arm64/configs/msm8953-perf_defconfig
@@ -0,0 +1,473 @@
+CONFIG_LOCALVERSION="-perf"
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_FHANDLE is not set
+CONFIG_AUDIT=y
+# CONFIG_AUDITSYSCALL is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IRQ_TIME_ACCOUNTING=y
+CONFIG_SCHED_WALT=y
+CONFIG_RCU_EXPERT=y
+CONFIG_RCU_FAST_NO_HZ=y
+CONFIG_RCU_NOCB_CPU=y
+CONFIG_RCU_NOCB_CPU_ALL=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_CPU_MAX_BUF_SHIFT=17
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CPUSETS=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_SCHEDTUNE=y
+CONFIG_RT_GROUP_SCHED=y
+CONFIG_CGROUP_BPF=y
+CONFIG_SCHED_CORE_CTL=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_SCHED_AUTOGROUP=y
+CONFIG_SCHED_TUNE=y
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_BPF_SYSCALL=y
+# CONFIG_AIO is not set
+# CONFIG_MEMBARRIER is not set
+CONFIG_EMBEDDED=y
+# CONFIG_COMPAT_BRK is not set
+CONFIG_PROFILING=y
+CONFIG_CC_STACKPROTECTOR_STRONG=y
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS=16
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SIG=y
+CONFIG_MODULE_SIG_FORCE=y
+CONFIG_MODULE_SIG_SHA512=y
+# CONFIG_BLK_DEV_BSG is not set
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_ARCH_QCOM=y
+CONFIG_ARCH_MSM8953=y
+CONFIG_SCHED_MC=y
+CONFIG_NR_CPUS=8
+CONFIG_PREEMPT=y
+CONFIG_HZ_100=y
+CONFIG_CMA=y
+CONFIG_ZSMALLOC=y
+CONFIG_BALANCE_ANON_FILE_RECLAIM=y
+CONFIG_SECCOMP=y
+CONFIG_ARMV8_DEPRECATED=y
+CONFIG_SWP_EMULATION=y
+CONFIG_CP15_BARRIER_EMULATION=y
+CONFIG_SETEND_EMULATION=y
+# CONFIG_ARM64_VHE is not set
+CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_COMPAT=y
+CONFIG_PM_AUTOSLEEP=y
+CONFIG_PM_WAKELOCKS=y
+CONFIG_PM_WAKELOCKS_LIMIT=0
+# CONFIG_PM_WAKELOCKS_GC is not set
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+CONFIG_CPU_BOOST=y
+CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_XFRM_USER=y
+CONFIG_XFRM_STATISTICS=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_VERBOSE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_DIAG_DESTROY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+CONFIG_IPV6_MIP6=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_NETFILTER=y
+CONFIG_NF_CONNTRACK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=y
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
+CONFIG_NF_CONNTRACK_AMANDA=y
+CONFIG_NF_CONNTRACK_FTP=y
+CONFIG_NF_CONNTRACK_H323=y
+CONFIG_NF_CONNTRACK_IRC=y
+CONFIG_NF_CONNTRACK_NETBIOS_NS=y
+CONFIG_NF_CONNTRACK_PPTP=y
+CONFIG_NF_CONNTRACK_SANE=y
+CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CT_NETLINK=y
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
+CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_HARDIDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_LOG=y
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+CONFIG_NETFILTER_XT_TARGET_NFLOG=y
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=y
+CONFIG_NETFILTER_XT_TARGET_TEE=y
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TRACE=y
+CONFIG_NETFILTER_XT_TARGET_SECMARK=y
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+CONFIG_NETFILTER_XT_MATCH_COMMENT=y
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+CONFIG_NETFILTER_XT_MATCH_ESP=y
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_HELPER=y
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+# CONFIG_NETFILTER_XT_MATCH_L2TP is not set
+CONFIG_NETFILTER_XT_MATCH_LENGTH=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MAC=y
+CONFIG_NETFILTER_XT_MATCH_MARK=y
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+CONFIG_NETFILTER_XT_MATCH_POLICY=y
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_QTAGUID=y
+CONFIG_NETFILTER_XT_MATCH_QUOTA=y
+CONFIG_NETFILTER_XT_MATCH_QUOTA2=y
+CONFIG_NETFILTER_XT_MATCH_SOCKET=y
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=y
+CONFIG_NETFILTER_XT_MATCH_STRING=y
+CONFIG_NETFILTER_XT_MATCH_TIME=y
+CONFIG_NETFILTER_XT_MATCH_U32=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_MATCH_AH=y
+CONFIG_IP_NF_MATCH_ECN=y
+CONFIG_IP_NF_MATCH_RPFILTER=y
+CONFIG_IP_NF_MATCH_TTL=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_RAW=y
+CONFIG_IP_NF_SECURITY=y
+CONFIG_IP_NF_ARPTABLES=y
+CONFIG_IP_NF_ARPFILTER=y
+CONFIG_IP_NF_ARP_MANGLE=y
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_MATCH_RPFILTER=y
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+CONFIG_IP6_NF_MANGLE=y
+CONFIG_IP6_NF_RAW=y
+CONFIG_BRIDGE_NF_EBTABLES=y
+CONFIG_BRIDGE_EBT_BROUTE=y
+CONFIG_L2TP=y
+CONFIG_L2TP_V3=y
+CONFIG_L2TP_IP=y
+CONFIG_L2TP_ETH=y
+CONFIG_BRIDGE=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_HTB=y
+CONFIG_NET_SCH_PRIO=y
+CONFIG_NET_SCH_MULTIQ=y
+CONFIG_NET_SCH_INGRESS=y
+CONFIG_NET_CLS_FW=y
+CONFIG_NET_CLS_U32=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_FLOW=y
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_CMP=y
+CONFIG_NET_EMATCH_NBYTE=y
+CONFIG_NET_EMATCH_U32=y
+CONFIG_NET_EMATCH_META=y
+CONFIG_NET_EMATCH_TEXT=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_GACT=y
+CONFIG_NET_ACT_MIRRED=y
+CONFIG_NET_ACT_SKBEDIT=y
+CONFIG_RMNET_DATA=y
+CONFIG_RMNET_DATA_FC=y
+CONFIG_RMNET_DATA_DEBUG_PKT=y
+CONFIG_BT=y
+CONFIG_MSM_BT_POWER=y
+CONFIG_CFG80211=y
+CONFIG_CFG80211_INTERNAL_REGDB=y
+# CONFIG_CFG80211_CRDA_SUPPORT is not set
+CONFIG_RFKILL=y
+CONFIG_NFC_NQ=y
+CONFIG_IPC_ROUTER=y
+CONFIG_IPC_ROUTER_SECURITY=y
+CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+CONFIG_DMA_CMA=y
+CONFIG_ZRAM=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_QSEECOM=y
+CONFIG_MEMORY_STATE_TIME=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_SCSI_UFSHCD=y
+CONFIG_SCSI_UFSHCD_PLATFORM=y
+CONFIG_SCSI_UFS_QCOM=y
+CONFIG_SCSI_UFS_QCOM_ICE=y
+CONFIG_SCSI_UFSHCD_CMD_LOGGING=y
+CONFIG_MD=y
+CONFIG_BLK_DEV_DM=y
+CONFIG_DM_DEBUG=y
+CONFIG_DM_CRYPT=y
+CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_UEVENT=y
+CONFIG_DM_VERITY=y
+CONFIG_DM_VERITY_FEC=y
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=y
+CONFIG_TUN=y
+CONFIG_PPP=y
+CONFIG_PPP_BSDCOMP=y
+CONFIG_PPP_DEFLATE=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_MPPE=y
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOE=y
+CONFIG_PPPOL2TP=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CLD_LL_CORE=y
+CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_GPIO=y
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_HBTP_INPUT=y
+CONFIG_INPUT_UINPUT=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_VT is not set
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_MSM=y
+CONFIG_SERIAL_MSM_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MSM_LEGACY=y
+CONFIG_MSM_ADSPRPC=y
+CONFIG_MSM_RDBG=m
+CONFIG_I2C_CHARDEV=y
+CONFIG_SPI=y
+CONFIG_SPI_QUP=y
+CONFIG_SPI_SPIDEV=y
+CONFIG_SLIMBUS_MSM_NGD=y
+CONFIG_SPMI=y
+CONFIG_SPMI_MSM_PMIC_ARB_DEBUG=y
+CONFIG_PINCTRL_MSM8953=y
+CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_POWER_RESET_QCOM=y
+CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_RESET_XGENE=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_SENSORS_QPNP_ADC_VOLTAGE=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_QPNP=y
+CONFIG_THERMAL_QPNP_ADC_TM=y
+CONFIG_THERMAL_TSENS=y
+CONFIG_MSM_BCL_PERIPHERAL_CTL=y
+CONFIG_QTI_THERMAL_LIMITS_DCVS=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_CPRH_KBSS=y
+CONFIG_REGULATOR_QPNP_LABIBB=y
+CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_STUB=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_CONTROLLER=y
+CONFIG_VIDEO_V4L2_SUBDEV_API=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_MSM_VIDC_V4L2=y
+CONFIG_MSM_VIDC_GOVERNORS=y
+CONFIG_MSM_SDE_ROTATOR=y
+CONFIG_MSM_SDE_ROTATOR_EVTLOG_DEBUG=y
+CONFIG_QCOM_KGSL=y
+CONFIG_DRM=y
+CONFIG_DRM_SDE_EVTLOG_DEBUG=y
+CONFIG_DRM_SDE_RSC=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SOC=y
+CONFIG_UHID=y
+CONFIG_HID_APPLE=y
+CONFIG_HID_ELECOM=y
+CONFIG_HID_MAGICMOUSE=y
+CONFIG_HID_MICROSOFT=y
+CONFIG_HID_MULTITOUCH=y
+CONFIG_USB_DWC3=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_DUAL_ROLE_USB_INTF=y
+CONFIG_USB_MSM_SSPHY_QMP=y
+CONFIG_MSM_QUSB_PHY=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DEBUG_FILES=y
+CONFIG_USB_GADGET_DEBUG_FS=y
+CONFIG_USB_GADGET_VBUS_DRAW=500
+CONFIG_MMC=y
+CONFIG_MMC_PERF_PROFILING=y
+CONFIG_MMC_PARANOID_SD_INIT=y
+CONFIG_MMC_CLKGATE=y
+CONFIG_MMC_BLOCK_MINORS=32
+CONFIG_MMC_BLOCK_DEFERRED_RESUME=y
+CONFIG_MMC_TEST=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_QPNP=y
+CONFIG_LEDS_QPNP_WLED=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_EDAC=y
+CONFIG_EDAC_MM_EDAC=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_QPNP=y
+CONFIG_DMADEVICES=y
+CONFIG_QCOM_SPS_DMA=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
+CONFIG_STAGING=y
+CONFIG_ASHMEM=y
+CONFIG_ANDROID_LOW_MEMORY_KILLER=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
+CONFIG_GSI=y
+CONFIG_IPA3=y
+CONFIG_RMNET_IPA3=y
+CONFIG_RNDIS_IPA=y
+CONFIG_IPA_UT=y
+CONFIG_SPS=y
+CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_QPNP_COINCELL=y
+CONFIG_QPNP_REVID=y
+CONFIG_USB_BAM=y
+CONFIG_QCOM_MDSS_PLL=y
+CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MAILBOX=y
+CONFIG_ARM_SMMU=y
+CONFIG_MSM_BOOT_STATS=y
+CONFIG_QCOM_EUD=y
+CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_SECURE_BUFFER=y
+CONFIG_QCOM_EARLY_RANDOM=y
+CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
+CONFIG_MSM_GLINK_SPI_XPRT=y
+CONFIG_MSM_SMP2P=y
+CONFIG_MSM_SMP2P_TEST=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
+CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
+CONFIG_MSM_SUBSYSTEM_RESTART=y
+CONFIG_MSM_PIL=y
+CONFIG_MSM_PIL_SSR_GENERIC=y
+CONFIG_MSM_PIL_MSS_QDSP6V5=y
+CONFIG_ICNSS=y
+CONFIG_MSM_PERFORMANCE=y
+CONFIG_MSM_EVENT_TIMER=y
+CONFIG_MSM_PM=y
+CONFIG_QTI_RPM_STATS_LOG=y
+CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_PWM=y
+CONFIG_PWM_QPNP=y
+CONFIG_ARM_GIC_V3_ACL=y
+CONFIG_ANDROID=y
+CONFIG_ANDROID_BINDER_IPC=y
+CONFIG_SENSORS_SSC=y
+CONFIG_MSM_TZ_LOG=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_FUSE_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_ECRYPT_FS=y
+CONFIG_ECRYPT_FS_MESSAGING=y
+# CONFIG_NETWORK_FILESYSTEMS is not set
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DEBUG_INFO=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_PANIC_TIMEOUT=5
+CONFIG_SCHEDSTATS=y
+# CONFIG_DEBUG_PREEMPT is not set
+CONFIG_IPC_LOGGING=y
+CONFIG_CPU_FREQ_SWITCH_PROFILER=y
+CONFIG_DEBUG_ALIGN_RODATA=y
+CONFIG_CORESIGHT=y
+CONFIG_CORESIGHT_STM=y
+CONFIG_CORESIGHT_EVENT=y
+CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
+CONFIG_SECURITY=y
+CONFIG_HARDENED_USERCOPY=y
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SMACK=y
+CONFIG_CRYPTO_CTR=y
+CONFIG_CRYPTO_XCBC=y
+CONFIG_CRYPTO_MD4=y
+CONFIG_CRYPTO_TWOFISH=y
+CONFIG_CRYPTO_ANSI_CPRNG=y
+CONFIG_CRYPTO_DEV_QCOM_MSM_QCE=y
+CONFIG_CRYPTO_DEV_QCRYPTO=y
+CONFIG_CRYPTO_DEV_QCEDEV=y
+CONFIG_CRYPTO_DEV_QCOM_ICE=y
+CONFIG_ARM64_CRYPTO=y
+CONFIG_CRYPTO_SHA1_ARM64_CE=y
+CONFIG_CRYPTO_SHA2_ARM64_CE=y
+CONFIG_CRYPTO_GHASH_ARM64_CE=y
+CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
+CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
+CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y
+CONFIG_CRYPTO_CRC32_ARM64=y
+CONFIG_QMI_ENCDEC=y
diff --git a/arch/arm64/configs/msm8953_defconfig b/arch/arm64/configs/msm8953_defconfig
new file mode 100644
index 0000000..6951086
--- /dev/null
+++ b/arch/arm64/configs/msm8953_defconfig
@@ -0,0 +1,543 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_FHANDLE is not set
+CONFIG_AUDIT=y
+# CONFIG_AUDITSYSCALL is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IRQ_TIME_ACCOUNTING=y
+CONFIG_SCHED_WALT=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_RCU_EXPERT=y
+CONFIG_RCU_FAST_NO_HZ=y
+CONFIG_RCU_NOCB_CPU=y
+CONFIG_RCU_NOCB_CPU_ALL=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_CPU_MAX_BUF_SHIFT=17
+CONFIG_CGROUP_DEBUG=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CPUSETS=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_SCHEDTUNE=y
+CONFIG_RT_GROUP_SCHED=y
+CONFIG_CGROUP_BPF=y
+CONFIG_SCHED_CORE_CTL=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_SCHED_AUTOGROUP=y
+CONFIG_SCHED_TUNE=y
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_BPF_SYSCALL=y
+# CONFIG_AIO is not set
+# CONFIG_MEMBARRIER is not set
+CONFIG_EMBEDDED=y
+# CONFIG_COMPAT_BRK is not set
+CONFIG_PROFILING=y
+CONFIG_CC_STACKPROTECTOR_STRONG=y
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS=16
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SIG=y
+CONFIG_MODULE_SIG_FORCE=y
+CONFIG_MODULE_SIG_SHA512=y
+# CONFIG_BLK_DEV_BSG is not set
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_ARCH_QCOM=y
+CONFIG_ARCH_MSM8953=y
+CONFIG_SCHED_MC=y
+CONFIG_NR_CPUS=8
+CONFIG_PREEMPT=y
+CONFIG_HZ_100=y
+CONFIG_CLEANCACHE=y
+CONFIG_CMA=y
+CONFIG_CMA_DEBUGFS=y
+CONFIG_ZSMALLOC=y
+CONFIG_BALANCE_ANON_FILE_RECLAIM=y
+CONFIG_SECCOMP=y
+CONFIG_ARMV8_DEPRECATED=y
+CONFIG_SWP_EMULATION=y
+CONFIG_CP15_BARRIER_EMULATION=y
+CONFIG_SETEND_EMULATION=y
+# CONFIG_ARM64_VHE is not set
+CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_COMPAT=y
+CONFIG_PM_AUTOSLEEP=y
+CONFIG_PM_WAKELOCKS=y
+CONFIG_PM_WAKELOCKS_LIMIT=0
+# CONFIG_PM_WAKELOCKS_GC is not set
+CONFIG_PM_DEBUG=y
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+CONFIG_CPU_BOOST=y
+CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_XFRM_USER=y
+CONFIG_XFRM_STATISTICS=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_VERBOSE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_DIAG_DESTROY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+CONFIG_IPV6_MIP6=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_NETFILTER=y
+CONFIG_NF_CONNTRACK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=y
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
+CONFIG_NF_CONNTRACK_AMANDA=y
+CONFIG_NF_CONNTRACK_FTP=y
+CONFIG_NF_CONNTRACK_H323=y
+CONFIG_NF_CONNTRACK_IRC=y
+CONFIG_NF_CONNTRACK_NETBIOS_NS=y
+CONFIG_NF_CONNTRACK_PPTP=y
+CONFIG_NF_CONNTRACK_SANE=y
+CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CT_NETLINK=y
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
+CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_HARDIDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_LOG=y
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+CONFIG_NETFILTER_XT_TARGET_NFLOG=y
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=y
+CONFIG_NETFILTER_XT_TARGET_TEE=y
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TRACE=y
+CONFIG_NETFILTER_XT_TARGET_SECMARK=y
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+CONFIG_NETFILTER_XT_MATCH_COMMENT=y
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+CONFIG_NETFILTER_XT_MATCH_ESP=y
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_HELPER=y
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+# CONFIG_NETFILTER_XT_MATCH_L2TP is not set
+CONFIG_NETFILTER_XT_MATCH_LENGTH=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MAC=y
+CONFIG_NETFILTER_XT_MATCH_MARK=y
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+CONFIG_NETFILTER_XT_MATCH_POLICY=y
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_QTAGUID=y
+CONFIG_NETFILTER_XT_MATCH_QUOTA=y
+CONFIG_NETFILTER_XT_MATCH_QUOTA2=y
+CONFIG_NETFILTER_XT_MATCH_SOCKET=y
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=y
+CONFIG_NETFILTER_XT_MATCH_STRING=y
+CONFIG_NETFILTER_XT_MATCH_TIME=y
+CONFIG_NETFILTER_XT_MATCH_U32=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_MATCH_AH=y
+CONFIG_IP_NF_MATCH_ECN=y
+CONFIG_IP_NF_MATCH_RPFILTER=y
+CONFIG_IP_NF_MATCH_TTL=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_RAW=y
+CONFIG_IP_NF_SECURITY=y
+CONFIG_IP_NF_ARPTABLES=y
+CONFIG_IP_NF_ARPFILTER=y
+CONFIG_IP_NF_ARP_MANGLE=y
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_MATCH_RPFILTER=y
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+CONFIG_IP6_NF_MANGLE=y
+CONFIG_IP6_NF_RAW=y
+CONFIG_BRIDGE_NF_EBTABLES=y
+CONFIG_BRIDGE_EBT_BROUTE=y
+CONFIG_L2TP=y
+CONFIG_L2TP_DEBUGFS=y
+CONFIG_L2TP_V3=y
+CONFIG_L2TP_IP=y
+CONFIG_L2TP_ETH=y
+CONFIG_BRIDGE=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_HTB=y
+CONFIG_NET_SCH_PRIO=y
+CONFIG_NET_SCH_MULTIQ=y
+CONFIG_NET_SCH_INGRESS=y
+CONFIG_NET_CLS_FW=y
+CONFIG_NET_CLS_U32=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_FLOW=y
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_CMP=y
+CONFIG_NET_EMATCH_NBYTE=y
+CONFIG_NET_EMATCH_U32=y
+CONFIG_NET_EMATCH_META=y
+CONFIG_NET_EMATCH_TEXT=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_GACT=y
+CONFIG_NET_ACT_MIRRED=y
+CONFIG_NET_ACT_SKBEDIT=y
+CONFIG_DNS_RESOLVER=y
+CONFIG_RMNET_DATA=y
+CONFIG_RMNET_DATA_FC=y
+CONFIG_RMNET_DATA_DEBUG_PKT=y
+CONFIG_BT=y
+CONFIG_MSM_BT_POWER=y
+CONFIG_CFG80211=y
+CONFIG_CFG80211_INTERNAL_REGDB=y
+# CONFIG_CFG80211_CRDA_SUPPORT is not set
+CONFIG_RFKILL=y
+CONFIG_NFC_NQ=y
+CONFIG_IPC_ROUTER=y
+CONFIG_IPC_ROUTER_SECURITY=y
+CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+CONFIG_DMA_CMA=y
+CONFIG_ZRAM=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_QSEECOM=y
+CONFIG_UID_SYS_STATS=y
+CONFIG_MEMORY_STATE_TIME=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_SCSI_UFSHCD=y
+CONFIG_SCSI_UFSHCD_PLATFORM=y
+CONFIG_SCSI_UFS_QCOM=y
+CONFIG_SCSI_UFS_QCOM_ICE=y
+CONFIG_SCSI_UFSHCD_CMD_LOGGING=y
+CONFIG_MD=y
+CONFIG_BLK_DEV_DM=y
+CONFIG_DM_DEBUG=y
+CONFIG_DM_CRYPT=y
+CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_UEVENT=y
+CONFIG_DM_VERITY=y
+CONFIG_DM_VERITY_FEC=y
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=y
+CONFIG_TUN=y
+CONFIG_PPP=y
+CONFIG_PPP_BSDCOMP=y
+CONFIG_PPP_DEFLATE=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_MPPE=y
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOE=y
+CONFIG_PPPOL2TP=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CLD_LL_CORE=y
+CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_GPIO=y
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_HBTP_INPUT=y
+CONFIG_INPUT_UINPUT=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_VT is not set
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_MSM=y
+CONFIG_SERIAL_MSM_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MSM_LEGACY=y
+CONFIG_MSM_ADSPRPC=y
+CONFIG_MSM_RDBG=m
+CONFIG_I2C_CHARDEV=y
+CONFIG_SPI=y
+CONFIG_SPI_QUP=y
+CONFIG_SPI_SPIDEV=y
+CONFIG_SLIMBUS_MSM_NGD=y
+CONFIG_SPMI=y
+CONFIG_SPMI_MSM_PMIC_ARB_DEBUG=y
+CONFIG_PINCTRL_MSM8953=y
+CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_POWER_RESET_QCOM=y
+CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_RESET_XGENE=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_SENSORS_QPNP_ADC_VOLTAGE=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_QPNP=y
+CONFIG_THERMAL_QPNP_ADC_TM=y
+CONFIG_THERMAL_TSENS=y
+CONFIG_MSM_BCL_PERIPHERAL_CTL=y
+CONFIG_QTI_THERMAL_LIMITS_DCVS=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_CPRH_KBSS=y
+CONFIG_REGULATOR_QPNP_LABIBB=y
+CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_STUB=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_CONTROLLER=y
+CONFIG_VIDEO_V4L2_SUBDEV_API=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_MSM_VIDC_V4L2=y
+CONFIG_MSM_VIDC_GOVERNORS=y
+CONFIG_MSM_SDE_ROTATOR=y
+CONFIG_MSM_SDE_ROTATOR_EVTLOG_DEBUG=y
+CONFIG_QCOM_KGSL=y
+CONFIG_DRM=y
+CONFIG_DRM_SDE_EVTLOG_DEBUG=y
+CONFIG_DRM_SDE_RSC=y
+CONFIG_FB_VIRTUAL=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SOC=y
+CONFIG_UHID=y
+CONFIG_HID_APPLE=y
+CONFIG_HID_ELECOM=y
+CONFIG_HID_MAGICMOUSE=y
+CONFIG_HID_MICROSOFT=y
+CONFIG_HID_MULTITOUCH=y
+CONFIG_USB_DWC3=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_DUAL_ROLE_USB_INTF=y
+CONFIG_USB_MSM_SSPHY_QMP=y
+CONFIG_MSM_QUSB_PHY=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DEBUG_FILES=y
+CONFIG_USB_GADGET_DEBUG_FS=y
+CONFIG_USB_GADGET_VBUS_DRAW=500
+CONFIG_MMC=y
+CONFIG_MMC_PERF_PROFILING=y
+CONFIG_MMC_RING_BUFFER=y
+CONFIG_MMC_PARANOID_SD_INIT=y
+CONFIG_MMC_CLKGATE=y
+CONFIG_MMC_BLOCK_MINORS=32
+CONFIG_MMC_BLOCK_DEFERRED_RESUME=y
+CONFIG_MMC_TEST=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_QPNP=y
+CONFIG_LEDS_QPNP_WLED=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_EDAC=y
+CONFIG_EDAC_MM_EDAC=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_QPNP=y
+CONFIG_DMADEVICES=y
+CONFIG_QCOM_SPS_DMA=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
+CONFIG_STAGING=y
+CONFIG_ASHMEM=y
+CONFIG_ANDROID_LOW_MEMORY_KILLER=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
+CONFIG_GSI=y
+CONFIG_IPA3=y
+CONFIG_RMNET_IPA3=y
+CONFIG_RNDIS_IPA=y
+CONFIG_SPS=y
+CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_QPNP_COINCELL=y
+CONFIG_QPNP_REVID=y
+CONFIG_USB_BAM=y
+CONFIG_QCOM_MDSS_PLL=y
+CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MAILBOX=y
+CONFIG_ARM_SMMU=y
+CONFIG_IOMMU_DEBUG=y
+CONFIG_IOMMU_DEBUG_TRACKING=y
+CONFIG_IOMMU_TESTS=y
+CONFIG_MSM_BOOT_STATS=y
+CONFIG_MSM_CORE_HANG_DETECT=y
+CONFIG_MSM_GLADIATOR_HANG_DETECT=y
+CONFIG_QCOM_EUD=y
+CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_SECURE_BUFFER=y
+CONFIG_QCOM_EARLY_RANDOM=y
+CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
+CONFIG_MSM_GLINK_SPI_XPRT=y
+CONFIG_TRACER_PKT=y
+CONFIG_MSM_SMP2P=y
+CONFIG_MSM_SMP2P_TEST=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
+CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
+CONFIG_MSM_SUBSYSTEM_RESTART=y
+CONFIG_MSM_PIL=y
+CONFIG_MSM_PIL_SSR_GENERIC=y
+CONFIG_MSM_PIL_MSS_QDSP6V5=y
+CONFIG_ICNSS=y
+CONFIG_MSM_PERFORMANCE=y
+CONFIG_MSM_EVENT_TIMER=y
+CONFIG_MSM_PM=y
+CONFIG_QTI_RPM_STATS_LOG=y
+CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_PWM=y
+CONFIG_PWM_QPNP=y
+CONFIG_ARM_GIC_V3_ACL=y
+CONFIG_ANDROID=y
+CONFIG_ANDROID_BINDER_IPC=y
+CONFIG_SENSORS_SSC=y
+CONFIG_MSM_TZ_LOG=y
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_FUSE_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_ECRYPT_FS=y
+CONFIG_ECRYPT_FS_MESSAGING=y
+# CONFIG_NETWORK_FILESYSTEMS is not set
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DYNAMIC_DEBUG=y
+CONFIG_DEBUG_INFO=y
+CONFIG_PAGE_OWNER=y
+CONFIG_PAGE_OWNER_ENABLE_DEFAULT=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_PAGEALLOC=y
+CONFIG_SLUB_DEBUG_PANIC_ON=y
+CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y
+CONFIG_PAGE_POISONING=y
+CONFIG_DEBUG_OBJECTS=y
+CONFIG_DEBUG_OBJECTS_FREE=y
+CONFIG_DEBUG_OBJECTS_TIMERS=y
+CONFIG_DEBUG_OBJECTS_WORK=y
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
+CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
+CONFIG_SLUB_DEBUG_ON=y
+CONFIG_DEBUG_KMEMLEAK=y
+CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=4000
+CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
+CONFIG_DEBUG_STACK_USAGE=y
+CONFIG_DEBUG_MEMORY_INIT=y
+CONFIG_LOCKUP_DETECTOR=y
+CONFIG_WQ_WATCHDOG=y
+CONFIG_PANIC_TIMEOUT=5
+CONFIG_PANIC_ON_SCHED_BUG=y
+CONFIG_PANIC_ON_RT_THROTTLING=y
+CONFIG_SCHEDSTATS=y
+CONFIG_SCHED_STACK_END_CHECK=y
+# CONFIG_DEBUG_PREEMPT is not set
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+CONFIG_DEBUG_ATOMIC_SLEEP=y
+CONFIG_DEBUG_LIST=y
+CONFIG_FAULT_INJECTION=y
+CONFIG_FAIL_PAGE_ALLOC=y
+CONFIG_FAULT_INJECTION_DEBUG_FS=y
+CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
+CONFIG_IPC_LOGGING=y
+CONFIG_QCOM_RTB=y
+CONFIG_QCOM_RTB_SEPARATE_CPUS=y
+CONFIG_FUNCTION_TRACER=y
+CONFIG_IRQSOFF_TRACER=y
+CONFIG_PREEMPT_TRACER=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_CPU_FREQ_SWITCH_PROFILER=y
+CONFIG_LKDTM=y
+CONFIG_MEMTEST=y
+CONFIG_PANIC_ON_DATA_CORRUPTION=y
+CONFIG_ARM64_PTDUMP=y
+CONFIG_PID_IN_CONTEXTIDR=y
+CONFIG_CORESIGHT=y
+CONFIG_CORESIGHT_REMOTE_ETM=y
+CONFIG_CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE=0
+CONFIG_CORESIGHT_STM=y
+CONFIG_CORESIGHT_TPDA=y
+CONFIG_CORESIGHT_TPDM=y
+CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
+CONFIG_CORESIGHT_HWEVENT=y
+CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
+CONFIG_SECURITY=y
+CONFIG_HARDENED_USERCOPY=y
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SMACK=y
+CONFIG_CRYPTO_CTR=y
+CONFIG_CRYPTO_XCBC=y
+CONFIG_CRYPTO_MD4=y
+CONFIG_CRYPTO_TWOFISH=y
+CONFIG_CRYPTO_ANSI_CPRNG=y
+CONFIG_CRYPTO_DEV_QCOM_MSM_QCE=y
+CONFIG_CRYPTO_DEV_QCRYPTO=y
+CONFIG_CRYPTO_DEV_QCEDEV=y
+CONFIG_CRYPTO_DEV_QCOM_ICE=y
+CONFIG_ARM64_CRYPTO=y
+CONFIG_CRYPTO_SHA1_ARM64_CE=y
+CONFIG_CRYPTO_SHA2_ARM64_CE=y
+CONFIG_CRYPTO_GHASH_ARM64_CE=y
+CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
+CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
+CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y
+CONFIG_CRYPTO_CRC32_ARM64=y
+CONFIG_QMI_ENCDEC=y
diff --git a/arch/arm64/configs/sdm670-perf_defconfig b/arch/arm64/configs/sdm670-perf_defconfig
index 1b5eac8..e05f395 100644
--- a/arch/arm64/configs/sdm670-perf_defconfig
+++ b/arch/arm64/configs/sdm670-perf_defconfig
@@ -7,6 +7,9 @@
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IRQ_TIME_ACCOUNTING=y
 CONFIG_SCHED_WALT=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
 CONFIG_RCU_EXPERT=y
 CONFIG_RCU_FAST_NO_HZ=y
 CONFIG_RCU_NOCB_CPU=y
@@ -127,6 +130,7 @@
 CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
 CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
 CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_HARDIDLETIMER=y
 CONFIG_NETFILTER_XT_TARGET_LOG=y
 CONFIG_NETFILTER_XT_TARGET_MARK=y
 CONFIG_NETFILTER_XT_TARGET_NFLOG=y
@@ -202,6 +206,8 @@
 CONFIG_NET_SCH_INGRESS=y
 CONFIG_NET_CLS_FW=y
 CONFIG_NET_CLS_U32=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_FLOW=y
 CONFIG_NET_EMATCH=y
 CONFIG_NET_EMATCH_CMP=y
 CONFIG_NET_EMATCH_NBYTE=y
@@ -230,7 +236,9 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_QSEECOM=y
+CONFIG_UID_SYS_STATS=y
 CONFIG_MEMORY_STATE_TIME=y
+CONFIG_QPNP_MISC=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
@@ -260,9 +268,15 @@
 CONFIG_PPP=y
 CONFIG_PPP_BSDCOMP=y
 CONFIG_PPP_DEFLATE=y
+CONFIG_PPP_FILTER=y
 CONFIG_PPP_MPPE=y
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOE=y
+CONFIG_PPPOL2TP=y
 CONFIG_PPPOLAC=y
 CONFIG_PPPOPNS=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
 CONFIG_USB_USBNET=y
 CONFIG_WIL6210=m
 # CONFIG_WIL6210_TRACING is not set
@@ -289,7 +303,6 @@
 CONFIG_MSM_RDBG=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QCOM_GENI=y
-CONFIG_SOUNDWIRE=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_QCOM_GENI=y
@@ -321,17 +334,21 @@
 CONFIG_THERMAL_QPNP=y
 CONFIG_THERMAL_QPNP_ADC_TM=y
 CONFIG_THERMAL_TSENS=y
+CONFIG_MSM_BCL_PERIPHERAL_CTL=y
 CONFIG_QTI_THERMAL_LIMITS_DCVS=y
 CONFIG_QTI_VIRTUAL_SENSOR=y
 CONFIG_QTI_AOP_REG_COOLING_DEVICE=y
 CONFIG_QTI_QMI_COOLING_DEVICE=y
+CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_I2C_PMIC=y
 CONFIG_MFD_SPMI_PMIC=y
-CONFIG_WCD9XXX_CODEC_CORE=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_CPRH_KBSS=y
 CONFIG_REGULATOR_QPNP_LABIBB=y
+CONFIG_REGULATOR_QPNP_LCDB=y
+CONFIG_REGULATOR_QPNP_OLEDB=y
 CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_REFGEN=y
 CONFIG_REGULATOR_RPMH=y
 CONFIG_REGULATOR_STUB=y
 CONFIG_MEDIA_SUPPORT=y
@@ -363,6 +380,7 @@
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_SOUND=y
 CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_USB_AUDIO_QMI=y
 CONFIG_SND_SOC=y
@@ -388,6 +406,7 @@
 CONFIG_USB_PD_POLICY=y
 CONFIG_QPNP_USB_PDPHY=y
 CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_DUAL_ROLE_USB_INTF=y
 CONFIG_USB_MSM_SSPHY_QMP=y
@@ -420,6 +439,7 @@
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_MSM=y
+CONFIG_MMC_CQ_HCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_QPNP=y
@@ -451,9 +471,14 @@
 CONFIG_MSM_11AD=m
 CONFIG_SEEMP_CORE=y
 CONFIG_QCOM_GENI_SE=y
+CONFIG_MSM_GCC_SDM845=y
+CONFIG_MSM_VIDEOCC_SDM845=y
+CONFIG_MSM_CAMCC_SDM845=y
+CONFIG_MSM_DISPCC_SDM845=y
 CONFIG_CLOCK_QPNP_DIV=y
 CONFIG_MSM_CLK_RPMH=y
 CONFIG_CLOCK_CPU_OSM=y
+CONFIG_MSM_GPUCC_SDM845=y
 CONFIG_MSM_CLK_AOP_QMP=y
 CONFIG_QCOM_MDSS_PLL=y
 CONFIG_REMOTE_SPINLOCK_MSM=y
@@ -472,7 +497,10 @@
 CONFIG_MSM_BOOT_STATS=y
 CONFIG_QCOM_EUD=y
 CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QPNP_PBS=y
 CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_BUS_SCALING=y
+CONFIG_QCOM_BUS_CONFIG_RPMH=y
 CONFIG_QCOM_SECURE_BUFFER=y
 CONFIG_QCOM_EARLY_RANDOM=y
 CONFIG_MSM_SMEM=y
@@ -491,18 +519,22 @@
 CONFIG_MSM_GLINK_PKT=y
 CONFIG_MSM_SUBSYSTEM_RESTART=y
 CONFIG_MSM_PIL=y
+CONFIG_MSM_SYSMON_GLINK_COMM=y
 CONFIG_MSM_PIL_SSR_GENERIC=y
 CONFIG_MSM_PIL_MSS_QDSP6V5=y
 CONFIG_ICNSS=y
 CONFIG_QCOM_COMMAND_DB=y
 CONFIG_MSM_PERFORMANCE=y
 CONFIG_MSM_CDSP_LOADER=y
+CONFIG_QCOM_SMCINVOKE=y
 CONFIG_MSM_EVENT_TIMER=y
 CONFIG_MSM_PM=y
 CONFIG_MSM_QBT1000=y
 CONFIG_APSS_CORE_EA=y
 CONFIG_QTI_RPM_STATS_LOG=y
 CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
+CONFIG_MSM_REMOTEQDSS=y
 CONFIG_QCOM_BIMC_BWMON=y
 CONFIG_ARM_MEMLAT_MON=y
 CONFIG_QCOMCCI_HWMON=y
@@ -553,13 +585,16 @@
 CONFIG_CORESIGHT_TPDA=y
 CONFIG_CORESIGHT_TPDM=y
 CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_DUMMY=y
 CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
 CONFIG_SECURITY=y
 CONFIG_HARDENED_USERCOPY=y
+CONFIG_FORTIFY_SOURCE=y
 CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SMACK=y
+CONFIG_CRYPTO_CTR=y
 CONFIG_CRYPTO_XCBC=y
 CONFIG_CRYPTO_MD4=y
 CONFIG_CRYPTO_TWOFISH=y
diff --git a/arch/arm64/configs/sdm670_defconfig b/arch/arm64/configs/sdm670_defconfig
index e2c6474..b47850c 100644
--- a/arch/arm64/configs/sdm670_defconfig
+++ b/arch/arm64/configs/sdm670_defconfig
@@ -23,23 +23,26 @@
 CONFIG_CGROUP_CPUACCT=y
 CONFIG_CGROUP_SCHEDTUNE=y
 CONFIG_RT_GROUP_SCHED=y
+CONFIG_CGROUP_BPF=y
 CONFIG_SCHED_CORE_CTL=y
 CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
 CONFIG_SCHED_AUTOGROUP=y
 CONFIG_SCHED_TUNE=y
+CONFIG_DEFAULT_USE_ENERGY_AWARE=y
 CONFIG_BLK_DEV_INITRD=y
 # CONFIG_RD_XZ is not set
 # CONFIG_RD_LZO is not set
 # CONFIG_RD_LZ4 is not set
 CONFIG_KALLSYMS_ALL=y
+CONFIG_BPF_SYSCALL=y
 # CONFIG_AIO is not set
 # CONFIG_MEMBARRIER is not set
 CONFIG_EMBEDDED=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_PROFILING=y
-CONFIG_CC_STACKPROTECTOR_REGULAR=y
+CONFIG_CC_STACKPROTECTOR_STRONG=y
 CONFIG_ARCH_MMAP_RND_COMPAT_BITS=16
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
@@ -132,6 +135,7 @@
 CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
 CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
 CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
+CONFIG_NETFILTER_XT_TARGET_HARDIDLETIMER=y
 CONFIG_NETFILTER_XT_TARGET_LOG=y
 CONFIG_NETFILTER_XT_TARGET_MARK=y
 CONFIG_NETFILTER_XT_TARGET_NFLOG=y
@@ -159,6 +163,7 @@
 CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
 CONFIG_NETFILTER_XT_MATCH_POLICY=y
 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_QTAGUID=y
 CONFIG_NETFILTER_XT_MATCH_QUOTA=y
 CONFIG_NETFILTER_XT_MATCH_QUOTA2=y
 CONFIG_NETFILTER_XT_MATCH_QUOTA2_LOG=y
@@ -234,6 +239,7 @@
 CONFIG_IPC_ROUTER=y
 CONFIG_IPC_ROUTER_SECURITY=y
 CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS=y
 CONFIG_DMA_CMA=y
 CONFIG_ZRAM=y
 CONFIG_BLK_DEV_LOOP=y
@@ -242,6 +248,7 @@
 CONFIG_QSEECOM=y
 CONFIG_UID_SYS_STATS=y
 CONFIG_MEMORY_STATE_TIME=y
+CONFIG_QPNP_MISC=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
@@ -267,9 +274,15 @@
 CONFIG_PPP=y
 CONFIG_PPP_BSDCOMP=y
 CONFIG_PPP_DEFLATE=y
+CONFIG_PPP_FILTER=y
 CONFIG_PPP_MPPE=y
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOE=y
+CONFIG_PPPOL2TP=y
 CONFIG_PPPOLAC=y
 CONFIG_PPPOPNS=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
 CONFIG_USB_USBNET=y
 CONFIG_WIL6210=m
 CONFIG_WCNSS_MEM_PRE_ALLOC=y
@@ -294,7 +307,6 @@
 CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QCOM_GENI=y
-CONFIG_SOUNDWIRE=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_QCOM_GENI=y
@@ -330,12 +342,17 @@
 CONFIG_QTI_THERMAL_LIMITS_DCVS=y
 CONFIG_QTI_VIRTUAL_SENSOR=y
 CONFIG_QTI_AOP_REG_COOLING_DEVICE=y
+CONFIG_QTI_QMI_COOLING_DEVICE=y
+CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_I2C_PMIC=y
 CONFIG_MFD_SPMI_PMIC=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_CPRH_KBSS=y
 CONFIG_REGULATOR_QPNP_LABIBB=y
+CONFIG_REGULATOR_QPNP_LCDB=y
+CONFIG_REGULATOR_QPNP_OLEDB=y
 CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_REFGEN=y
 CONFIG_REGULATOR_RPMH=y
 CONFIG_REGULATOR_STUB=y
 CONFIG_MEDIA_SUPPORT=y
@@ -362,10 +379,10 @@
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_SOUND=y
 CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_USB_AUDIO_QMI=y
 CONFIG_SND_SOC=y
-CONFIG_SND_SOC_SDM845=y
 CONFIG_UHID=y
 CONFIG_HID_APPLE=y
 CONFIG_HID_MICROSOFT=y
@@ -383,6 +400,7 @@
 CONFIG_USB_PD_POLICY=y
 CONFIG_QPNP_USB_PDPHY=y
 CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_DUAL_ROLE_USB_INTF=y
 CONFIG_USB_MSM_SSPHY_QMP=y
@@ -408,6 +426,7 @@
 CONFIG_MMC=y
 CONFIG_MMC_PERF_PROFILING=y
 CONFIG_MMC_RING_BUFFER=y
+CONFIG_MMC_PARANOID_SD_INIT=y
 CONFIG_MMC_CLKGATE=y
 CONFIG_MMC_BLOCK_MINORS=32
 CONFIG_MMC_BLOCK_DEFERRED_RESUME=y
@@ -415,6 +434,7 @@
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_MSM=y
+CONFIG_MMC_CQ_HCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_QPNP=y
@@ -453,9 +473,14 @@
 CONFIG_MSM_11AD=m
 CONFIG_SEEMP_CORE=y
 CONFIG_QCOM_GENI_SE=y
+CONFIG_MSM_GCC_SDM845=y
+CONFIG_MSM_VIDEOCC_SDM845=y
+CONFIG_MSM_CAMCC_SDM845=y
+CONFIG_MSM_DISPCC_SDM845=y
 CONFIG_CLOCK_QPNP_DIV=y
 CONFIG_MSM_CLK_RPMH=y
 CONFIG_CLOCK_CPU_OSM=y
+CONFIG_MSM_GPUCC_SDM845=y
 CONFIG_MSM_CLK_AOP_QMP=y
 CONFIG_QCOM_MDSS_PLL=y
 CONFIG_REMOTE_SPINLOCK_MSM=y
@@ -478,7 +503,10 @@
 CONFIG_MSM_GLADIATOR_ERP=y
 CONFIG_QCOM_EUD=y
 CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QPNP_PBS=y
 CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_BUS_SCALING=y
+CONFIG_QCOM_BUS_CONFIG_RPMH=y
 CONFIG_QCOM_SECURE_BUFFER=y
 CONFIG_QCOM_EARLY_RANDOM=y
 CONFIG_MSM_SMEM=y
@@ -497,22 +525,24 @@
 CONFIG_MSM_GLINK_PKT=y
 CONFIG_MSM_SUBSYSTEM_RESTART=y
 CONFIG_MSM_PIL=y
+CONFIG_MSM_SYSMON_GLINK_COMM=y
 CONFIG_MSM_PIL_SSR_GENERIC=y
 CONFIG_MSM_PIL_MSS_QDSP6V5=y
 CONFIG_ICNSS=y
 CONFIG_ICNSS_DEBUG=y
 CONFIG_QCOM_COMMAND_DB=y
-CONFIG_MSM_ADSP_LOADER=y
 CONFIG_MSM_PERFORMANCE=y
 CONFIG_MSM_CDSP_LOADER=y
-CONFIG_MSM_AVTIMER=y
+CONFIG_QCOM_SMCINVOKE=y
 CONFIG_MSM_EVENT_TIMER=y
 CONFIG_MSM_PM=y
 CONFIG_MSM_QBT1000=y
+CONFIG_APSS_CORE_EA=y
 CONFIG_QCOM_DCC_V2=y
 CONFIG_QTI_RPM_STATS_LOG=y
 CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
 CONFIG_QMP_DEBUGFS_CLIENT=y
+CONFIG_MSM_REMOTEQDSS=y
 CONFIG_QCOM_BIMC_BWMON=y
 CONFIG_ARM_MEMLAT_MON=y
 CONFIG_QCOMCCI_HWMON=y
@@ -610,13 +640,16 @@
 CONFIG_CORESIGHT_TPDA=y
 CONFIG_CORESIGHT_TPDM=y
 CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_DUMMY=y
 CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
 CONFIG_SECURITY=y
 CONFIG_HARDENED_USERCOPY=y
+CONFIG_FORTIFY_SOURCE=y
 CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SMACK=y
+CONFIG_CRYPTO_CTR=y
 CONFIG_CRYPTO_XCBC=y
 CONFIG_CRYPTO_MD4=y
 CONFIG_CRYPTO_TWOFISH=y
diff --git a/arch/arm64/configs/sdm845-perf_defconfig b/arch/arm64/configs/sdm845-perf_defconfig
index fb44c40..c1efed5 100644
--- a/arch/arm64/configs/sdm845-perf_defconfig
+++ b/arch/arm64/configs/sdm845-perf_defconfig
@@ -21,6 +21,7 @@
 CONFIG_RT_GROUP_SCHED=y
 CONFIG_CGROUP_BPF=y
 CONFIG_SCHED_CORE_CTL=y
+CONFIG_SCHED_CORE_ROTATE=y
 CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
@@ -296,11 +297,11 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM_LEGACY=y
+# CONFIG_DEVPORT is not set
 CONFIG_MSM_ADSPRPC=y
 CONFIG_MSM_RDBG=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QCOM_GENI=y
-CONFIG_SOUNDWIRE=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_QCOM_GENI=y
@@ -340,7 +341,6 @@
 CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_I2C_PMIC=y
 CONFIG_MFD_SPMI_PMIC=y
-CONFIG_WCD9XXX_CODEC_CORE=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_PROXY_CONSUMER=y
 CONFIG_REGULATOR_CPRH_KBSS=y
@@ -378,11 +378,10 @@
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_SOUND=y
 CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_USB_AUDIO_QMI=y
 CONFIG_SND_SOC=y
-CONFIG_SND_SOC_MACHINE_SDM845=y
-CONFIG_SND_SOC_SDM845=y
 CONFIG_UHID=y
 CONFIG_HID_APPLE=y
 CONFIG_HID_ELECOM=y
@@ -522,10 +521,8 @@
 CONFIG_MSM_PIL_MSS_QDSP6V5=y
 CONFIG_ICNSS=y
 CONFIG_QCOM_COMMAND_DB=y
-CONFIG_MSM_ADSP_LOADER=y
 CONFIG_MSM_PERFORMANCE=y
 CONFIG_MSM_CDSP_LOADER=y
-CONFIG_MSM_AVTIMER=y
 CONFIG_QCOM_SMCINVOKE=y
 CONFIG_MSM_EVENT_TIMER=y
 CONFIG_MSM_PM=y
@@ -534,6 +531,7 @@
 CONFIG_QTI_RPM_STATS_LOG=y
 CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
 CONFIG_QMP_DEBUGFS_CLIENT=y
+CONFIG_QSEE_IPC_IRQ_BRIDGE=y
 CONFIG_QCOM_BIMC_BWMON=y
 CONFIG_ARM_MEMLAT_MON=y
 CONFIG_QCOMCCI_HWMON=y
@@ -584,6 +582,7 @@
 CONFIG_CORESIGHT_TPDA=y
 CONFIG_CORESIGHT_TPDM=y
 CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_DUMMY=y
 CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
diff --git a/arch/arm64/configs/sdm845_defconfig b/arch/arm64/configs/sdm845_defconfig
index fc7d28a..c029b75 100644
--- a/arch/arm64/configs/sdm845_defconfig
+++ b/arch/arm64/configs/sdm845_defconfig
@@ -25,6 +25,7 @@
 CONFIG_RT_GROUP_SCHED=y
 CONFIG_CGROUP_BPF=y
 CONFIG_SCHED_CORE_CTL=y
+CONFIG_SCHED_CORE_ROTATE=y
 CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
@@ -237,6 +238,7 @@
 CONFIG_IPC_ROUTER=y
 CONFIG_IPC_ROUTER_SECURITY=y
 CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS=y
 CONFIG_DMA_CMA=y
 CONFIG_ZRAM=y
 CONFIG_BLK_DEV_LOOP=y
@@ -303,11 +305,11 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM_LEGACY=y
+# CONFIG_DEVPORT is not set
 CONFIG_MSM_ADSPRPC=y
 CONFIG_MSM_RDBG=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QCOM_GENI=y
-CONFIG_SOUNDWIRE=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_QCOM_GENI=y
@@ -347,7 +349,6 @@
 CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_I2C_PMIC=y
 CONFIG_MFD_SPMI_PMIC=y
-CONFIG_WCD9XXX_CODEC_CORE=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_PROXY_CONSUMER=y
 CONFIG_REGULATOR_CPRH_KBSS=y
@@ -385,11 +386,10 @@
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_SOUND=y
 CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_USB_AUDIO_QMI=y
 CONFIG_SND_SOC=y
-CONFIG_SND_SOC_MACHINE_SDM845=y
-CONFIG_SND_SOC_SDM845=y
 CONFIG_UHID=y
 CONFIG_HID_APPLE=y
 CONFIG_HID_ELECOM=y
@@ -457,9 +457,6 @@
 CONFIG_EDAC_KRYO3XX_ARM64=y
 CONFIG_EDAC_KRYO3XX_ARM64_PANIC_ON_CE=y
 CONFIG_EDAC_KRYO3XX_ARM64_PANIC_ON_UE=y
-CONFIG_EDAC_QCOM_LLCC=y
-CONFIG_EDAC_QCOM_LLCC_PANIC_ON_CE=y
-CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_QPNP=y
 CONFIG_DMADEVICES=y
@@ -542,10 +539,8 @@
 CONFIG_ICNSS=y
 CONFIG_ICNSS_DEBUG=y
 CONFIG_QCOM_COMMAND_DB=y
-CONFIG_MSM_ADSP_LOADER=y
 CONFIG_MSM_PERFORMANCE=y
 CONFIG_MSM_CDSP_LOADER=y
-CONFIG_MSM_AVTIMER=y
 CONFIG_QCOM_SMCINVOKE=y
 CONFIG_MSM_EVENT_TIMER=y
 CONFIG_MSM_PM=y
@@ -556,6 +551,7 @@
 CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
 CONFIG_QMP_DEBUGFS_CLIENT=y
 CONFIG_MSM_REMOTEQDSS=y
+CONFIG_QSEE_IPC_IRQ_BRIDGE=y
 CONFIG_QCOM_BIMC_BWMON=y
 CONFIG_ARM_MEMLAT_MON=y
 CONFIG_QCOMCCI_HWMON=y
@@ -616,6 +612,7 @@
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_MEMORY_INIT=y
 CONFIG_LOCKUP_DETECTOR=y
+CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
 CONFIG_WQ_WATCHDOG=y
 CONFIG_PANIC_TIMEOUT=5
 CONFIG_PANIC_ON_SCHED_BUG=y
@@ -655,6 +652,8 @@
 CONFIG_CORESIGHT_TPDA=y
 CONFIG_CORESIGHT_TPDM=y
 CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
+CONFIG_CORESIGHT_TGU=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_DUMMY=y
 CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index 6ebd2c3..f1ace59 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -21,6 +21,7 @@
 #include <asm/sysreg.h>
 
 #define ICC_EOIR1_EL1			sys_reg(3, 0, 12, 12, 1)
+#define ICC_HPPIR1_EL1			sys_reg(3, 0, 12, 12, 2)
 #define ICC_DIR_EL1			sys_reg(3, 0, 12, 11, 1)
 #define ICC_IAR1_EL1			sys_reg(3, 0, 12, 12, 0)
 #define ICC_SGI1R_EL1			sys_reg(3, 0, 12, 11, 5)
diff --git a/arch/arm64/include/asm/debugv8.h b/arch/arm64/include/asm/debugv8.h
new file mode 100644
index 0000000..e32de80
--- /dev/null
+++ b/arch/arm64/include/asm/debugv8.h
@@ -0,0 +1,229 @@
+/* Copyright (c) 2014, 2016-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 __ASM_DEBUGV8_H
+#define __ASM_DEBUGV8_H
+
+#include <linux/types.h>
+
+/* 32 bit register reads for aarch 64 bit */
+#define dbg_readl(reg)			RSYSL_##reg()
+/* 64 bit register reads for aarch 64 bit */
+#define dbg_readq(reg)			RSYSQ_##reg()
+/* 32 and 64 bit register writes for aarch 64 bit */
+#define dbg_write(val, reg)		WSYS_##reg(val)
+
+#define MRSL(reg)				\
+({						\
+uint32_t val;					\
+asm volatile("mrs %0, "#reg : "=r" (val));	\
+val;						\
+})
+
+#define MRSQ(reg)				\
+({						\
+uint64_t val;					\
+asm volatile("mrs %0, "#reg : "=r" (val));	\
+val;						\
+})
+
+#define MSR(val, reg)				\
+({						\
+asm volatile("msr "#reg", %0" : : "r" (val));	\
+})
+
+/*
+ * Debug Feature Register
+ *
+ * Read only
+ */
+#define RSYSQ_ID_AA64DFR0_EL1()		MRSQ(ID_AA64DFR0_EL1)
+
+/*
+ * Debug Registers
+ *
+ * Available only in DBGv8
+ *
+ * Read only
+ * MDCCSR_EL0, MDRAR_EL1, OSLSR_EL1, DBGDTRRX_EL0, DBGAUTHSTATUS_EL1
+ *
+ * Write only
+ * DBGDTRTX_EL0, OSLAR_EL1
+ */
+/* 32 bit registers */
+#define RSYSL_DBGDTRRX_EL0()		MRSL(DBGDTRRX_EL0)
+#define RSYSL_MDCCSR_EL0()		MRSL(MDCCSR_EL0)
+#define RSYSL_MDSCR_EL1()		MRSL(MDSCR_EL1)
+#define RSYSL_OSDTRRX_EL1()		MRSL(OSDTRRX_EL1)
+#define RSYSL_OSDTRTX_EL1()		MRSL(OSDTRTX_EL1)
+#define RSYSL_OSDLR_EL1()		MRSL(OSDLR_EL1)
+#define RSYSL_OSLSR_EL1()		MRSL(OSLSR_EL1)
+#define RSYSL_MDCCINT_EL1()		MRSL(MDCCINT_EL1)
+#define RSYSL_OSECCR_EL1()		MRSL(OSECCR_EL1)
+#define RSYSL_DBGPRCR_EL1()		MRSL(DBGPRCR_EL1)
+#define RSYSL_DBGBCR0_EL1()		MRSL(DBGBCR0_EL1)
+#define RSYSL_DBGBCR1_EL1()		MRSL(DBGBCR1_EL1)
+#define RSYSL_DBGBCR2_EL1()		MRSL(DBGBCR2_EL1)
+#define RSYSL_DBGBCR3_EL1()		MRSL(DBGBCR3_EL1)
+#define RSYSL_DBGBCR4_EL1()		MRSL(DBGBCR4_EL1)
+#define RSYSL_DBGBCR5_EL1()		MRSL(DBGBCR5_EL1)
+#define RSYSL_DBGBCR6_EL1()		MRSL(DBGBCR6_EL1)
+#define RSYSL_DBGBCR7_EL1()		MRSL(DBGBCR7_EL1)
+#define RSYSL_DBGBCR8_EL1()		MRSL(DBGBCR8_EL1)
+#define RSYSL_DBGBCR9_EL1()		MRSL(DBGBCR9_EL1)
+#define RSYSL_DBGBCR10_EL1()		MRSL(DBGBCR10_EL1)
+#define RSYSL_DBGBCR11_EL1()		MRSL(DBGBCR11_EL1)
+#define RSYSL_DBGBCR12_EL1()		MRSL(DBGBCR12_EL1)
+#define RSYSL_DBGBCR13_EL1()		MRSL(DBGBCR13_EL1)
+#define RSYSL_DBGBCR14_EL1()		MRSL(DBGBCR14_EL1)
+#define RSYSL_DBGBCR15_EL1()		MRSL(DBGBCR15_EL1)
+#define RSYSL_DBGWCR0_EL1()		MRSL(DBGWCR0_EL1)
+#define RSYSL_DBGWCR1_EL1()		MRSL(DBGWCR1_EL1)
+#define RSYSL_DBGWCR2_EL1()		MRSL(DBGWCR2_EL1)
+#define RSYSL_DBGWCR3_EL1()		MRSL(DBGWCR3_EL1)
+#define RSYSL_DBGWCR4_EL1()		MRSL(DBGWCR4_EL1)
+#define RSYSL_DBGWCR5_EL1()		MRSL(DBGWCR5_EL1)
+#define RSYSL_DBGWCR6_EL1()		MRSL(DBGWCR6_EL1)
+#define RSYSL_DBGWCR7_EL1()		MRSL(DBGWCR7_EL1)
+#define RSYSL_DBGWCR8_EL1()		MRSL(DBGWCR8_EL1)
+#define RSYSL_DBGWCR9_EL1()		MRSL(DBGWCR9_EL1)
+#define RSYSL_DBGWCR10_EL1()		MRSL(DBGWCR10_EL1)
+#define RSYSL_DBGWCR11_EL1()		MRSL(DBGWCR11_EL1)
+#define RSYSL_DBGWCR12_EL1()		MRSL(DBGWCR12_EL1)
+#define RSYSL_DBGWCR13_EL1()		MRSL(DBGWCR13_EL1)
+#define RSYSL_DBGWCR14_EL1()		MRSL(DBGWCR14_EL1)
+#define RSYSL_DBGWCR15_EL1()		MRSL(DBGWCR15_EL1)
+#define RSYSL_DBGCLAIMSET_EL1()		MRSL(DBGCLAIMSET_EL1)
+#define RSYSL_DBGCLAIMCLR_EL1()		MRSL(DBGCLAIMCLR_EL1)
+#define RSYSL_DBGAUTHSTATUS_EL1()	MRSL(DBGAUTHSTATUS_EL1)
+#define RSYSL_DBGVCR32_EL2()		MRSL(DBGVCR32_EL2)
+#define RSYSL_MDCR_EL2()		MRSL(MDCR_EL2)
+#define RSYSL_MDCR_EL3()		MRSL(MDCR_EL3)
+/* 64 bit registers */
+#define RSYSQ_DBGDTR_EL0()		MRSQ(DBGDTR_EL0)
+#define RSYSQ_MDRAR_EL1()		MRSQ(MDRAR_EL1)
+#define RSYSQ_DBGBVR0_EL1()		MRSQ(DBGBVR0_EL1)
+#define RSYSQ_DBGBVR1_EL1()		MRSQ(DBGBVR1_EL1)
+#define RSYSQ_DBGBVR2_EL1()		MRSQ(DBGBVR2_EL1)
+#define RSYSQ_DBGBVR3_EL1()		MRSQ(DBGBVR3_EL1)
+#define RSYSQ_DBGBVR4_EL1()		MRSQ(DBGBVR4_EL1)
+#define RSYSQ_DBGBVR5_EL1()		MRSQ(DBGBVR5_EL1)
+#define RSYSQ_DBGBVR6_EL1()		MRSQ(DBGBVR6_EL1)
+#define RSYSQ_DBGBVR7_EL1()		MRSQ(DBGBVR7_EL1)
+#define RSYSQ_DBGBVR8_EL1()		MRSQ(DBGBVR8_EL1)
+#define RSYSQ_DBGBVR9_EL1()		MRSQ(DBGBVR9_EL1)
+#define RSYSQ_DBGBVR10_EL1()		MRSQ(DBGBVR10_EL1)
+#define RSYSQ_DBGBVR11_EL1()		MRSQ(DBGBVR11_EL1)
+#define RSYSQ_DBGBVR12_EL1()		MRSQ(DBGBVR12_EL1)
+#define RSYSQ_DBGBVR13_EL1()		MRSQ(DBGBVR13_EL1)
+#define RSYSQ_DBGBVR14_EL1()		MRSQ(DBGBVR14_EL1)
+#define RSYSQ_DBGBVR15_EL1()		MRSQ(DBGBVR15_EL1)
+#define RSYSQ_DBGWVR0_EL1()		MRSQ(DBGWVR0_EL1)
+#define RSYSQ_DBGWVR1_EL1()		MRSQ(DBGWVR1_EL1)
+#define RSYSQ_DBGWVR2_EL1()		MRSQ(DBGWVR2_EL1)
+#define RSYSQ_DBGWVR3_EL1()		MRSQ(DBGWVR3_EL1)
+#define RSYSQ_DBGWVR4_EL1()		MRSQ(DBGWVR4_EL1)
+#define RSYSQ_DBGWVR5_EL1()		MRSQ(DBGWVR5_EL1)
+#define RSYSQ_DBGWVR6_EL1()		MRSQ(DBGWVR6_EL1)
+#define RSYSQ_DBGWVR7_EL1()		MRSQ(DBGWVR7_EL1)
+#define RSYSQ_DBGWVR8_EL1()		MRSQ(DBGWVR8_EL1)
+#define RSYSQ_DBGWVR9_EL1()		MRSQ(DBGWVR9_EL1)
+#define RSYSQ_DBGWVR10_EL1()		MRSQ(DBGWVR10_EL1)
+#define RSYSQ_DBGWVR11_EL1()		MRSQ(DBGWVR11_EL1)
+#define RSYSQ_DBGWVR12_EL1()		MRSQ(DBGWVR12_EL1)
+#define RSYSQ_DBGWVR13_EL1()		MRSQ(DBGWVR13_EL1)
+#define RSYSQ_DBGWVR14_EL1()		MRSQ(DBGWVR14_EL1)
+#define RSYSQ_DBGWVR15_EL1()		MRSQ(DBGWVR15_EL1)
+
+/* 32 bit registers */
+#define WSYS_DBGDTRTX_EL0(val)		MSR(val, DBGDTRTX_EL0)
+#define WSYS_MDCCINT_EL1(val)		MSR(val, MDCCINT_EL1)
+#define WSYS_MDSCR_EL1(val)		MSR(val, MDSCR_EL1)
+#define WSYS_OSDTRRX_EL1(val)		MSR(val, OSDTRRX_EL1)
+#define WSYS_OSDTRTX_EL1(val)		MSR(val, OSDTRTX_EL1)
+#define WSYS_OSDLR_EL1(val)		MSR(val, OSDLR_EL1)
+#define WSYS_OSECCR_EL1(val)		MSR(val, OSECCR_EL1)
+#define WSYS_DBGPRCR_EL1(val)		MSR(val, DBGPRCR_EL1)
+#define WSYS_DBGBCR0_EL1(val)		MSR(val, DBGBCR0_EL1)
+#define WSYS_DBGBCR1_EL1(val)		MSR(val, DBGBCR1_EL1)
+#define WSYS_DBGBCR2_EL1(val)		MSR(val, DBGBCR2_EL1)
+#define WSYS_DBGBCR3_EL1(val)		MSR(val, DBGBCR3_EL1)
+#define WSYS_DBGBCR4_EL1(val)		MSR(val, DBGBCR4_EL1)
+#define WSYS_DBGBCR5_EL1(val)		MSR(val, DBGBCR5_EL1)
+#define WSYS_DBGBCR6_EL1(val)		MSR(val, DBGBCR6_EL1)
+#define WSYS_DBGBCR7_EL1(val)		MSR(val, DBGBCR7_EL1)
+#define WSYS_DBGBCR8_EL1(val)		MSR(val, DBGBCR8_EL1)
+#define WSYS_DBGBCR9_EL1(val)		MSR(val, DBGBCR9_EL1)
+#define WSYS_DBGBCR10_EL1(val)		MSR(val, DBGBCR10_EL1)
+#define WSYS_DBGBCR11_EL1(val)		MSR(val, DBGBCR11_EL1)
+#define WSYS_DBGBCR12_EL1(val)		MSR(val, DBGBCR12_EL1)
+#define WSYS_DBGBCR13_EL1(val)		MSR(val, DBGBCR13_EL1)
+#define WSYS_DBGBCR14_EL1(val)		MSR(val, DBGBCR14_EL1)
+#define WSYS_DBGBCR15_EL1(val)		MSR(val, DBGBCR15_EL1)
+#define WSYS_DBGWCR0_EL1(val)		MSR(val, DBGWCR0_EL1)
+#define WSYS_DBGWCR1_EL1(val)		MSR(val, DBGWCR1_EL1)
+#define WSYS_DBGWCR2_EL1(val)		MSR(val, DBGWCR2_EL1)
+#define WSYS_DBGWCR3_EL1(val)		MSR(val, DBGWCR3_EL1)
+#define WSYS_DBGWCR4_EL1(val)		MSR(val, DBGWCR4_EL1)
+#define WSYS_DBGWCR5_EL1(val)		MSR(val, DBGWCR5_EL1)
+#define WSYS_DBGWCR6_EL1(val)		MSR(val, DBGWCR6_EL1)
+#define WSYS_DBGWCR7_EL1(val)		MSR(val, DBGWCR7_EL1)
+#define WSYS_DBGWCR8_EL1(val)		MSR(val, DBGWCR8_EL1)
+#define WSYS_DBGWCR9_EL1(val)		MSR(val, DBGWCR9_EL1)
+#define WSYS_DBGWCR10_EL1(val)		MSR(val, DBGWCR10_EL1)
+#define WSYS_DBGWCR11_EL1(val)		MSR(val, DBGWCR11_EL1)
+#define WSYS_DBGWCR12_EL1(val)		MSR(val, DBGWCR12_EL1)
+#define WSYS_DBGWCR13_EL1(val)		MSR(val, DBGWCR13_EL1)
+#define WSYS_DBGWCR14_EL1(val)		MSR(val, DBGWCR14_EL1)
+#define WSYS_DBGWCR15_EL1(val)		MSR(val, DBGWCR15_EL1)
+#define WSYS_DBGCLAIMSET_EL1(val)	MSR(val, DBGCLAIMSET_EL1)
+#define WSYS_DBGCLAIMCLR_EL1(val)	MSR(val, DBGCLAIMCLR_EL1)
+#define WSYS_OSLAR_EL1(val)		MSR(val, OSLAR_EL1)
+#define WSYS_DBGVCR32_EL2(val)		MSR(val, DBGVCR32_EL2)
+#define WSYS_MDCR_EL2(val)		MSR(val, MDCR_EL2)
+#define WSYS_MDCR_EL3(val)		MSR(val, MDCR_EL3)
+/* 64 bit registers */
+#define WSYS_DBGDTR_EL0(val)		MSR(val, DBGDTR_EL0)
+#define WSYS_DBGBVR0_EL1(val)		MSR(val, DBGBVR0_EL1)
+#define WSYS_DBGBVR1_EL1(val)		MSR(val, DBGBVR1_EL1)
+#define WSYS_DBGBVR2_EL1(val)		MSR(val, DBGBVR2_EL1)
+#define WSYS_DBGBVR3_EL1(val)		MSR(val, DBGBVR3_EL1)
+#define WSYS_DBGBVR4_EL1(val)		MSR(val, DBGBVR4_EL1)
+#define WSYS_DBGBVR5_EL1(val)		MSR(val, DBGBVR5_EL1)
+#define WSYS_DBGBVR6_EL1(val)		MSR(val, DBGBVR6_EL1)
+#define WSYS_DBGBVR7_EL1(val)		MSR(val, DBGBVR7_EL1)
+#define WSYS_DBGBVR8_EL1(val)		MSR(val, DBGBVR8_EL1)
+#define WSYS_DBGBVR9_EL1(val)		MSR(val, DBGBVR9_EL1)
+#define WSYS_DBGBVR10_EL1(val)		MSR(val, DBGBVR10_EL1)
+#define WSYS_DBGBVR11_EL1(val)		MSR(val, DBGBVR11_EL1)
+#define WSYS_DBGBVR12_EL1(val)		MSR(val, DBGBVR12_EL1)
+#define WSYS_DBGBVR13_EL1(val)		MSR(val, DBGBVR13_EL1)
+#define WSYS_DBGBVR14_EL1(val)		MSR(val, DBGBVR14_EL1)
+#define WSYS_DBGBVR15_EL1(val)		MSR(val, DBGBVR15_EL1)
+#define WSYS_DBGWVR0_EL1(val)		MSR(val, DBGWVR0_EL1)
+#define WSYS_DBGWVR1_EL1(val)		MSR(val, DBGWVR1_EL1)
+#define WSYS_DBGWVR2_EL1(val)		MSR(val, DBGWVR2_EL1)
+#define WSYS_DBGWVR3_EL1(val)		MSR(val, DBGWVR3_EL1)
+#define WSYS_DBGWVR4_EL1(val)		MSR(val, DBGWVR4_EL1)
+#define WSYS_DBGWVR5_EL1(val)		MSR(val, DBGWVR5_EL1)
+#define WSYS_DBGWVR6_EL1(val)		MSR(val, DBGWVR6_EL1)
+#define WSYS_DBGWVR7_EL1(val)		MSR(val, DBGWVR7_EL1)
+#define WSYS_DBGWVR8_EL1(val)		MSR(val, DBGWVR8_EL1)
+#define WSYS_DBGWVR9_EL1(val)		MSR(val, DBGWVR9_EL1)
+#define WSYS_DBGWVR10_EL1(val)		MSR(val, DBGWVR10_EL1)
+#define WSYS_DBGWVR11_EL1(val)		MSR(val, DBGWVR11_EL1)
+#define WSYS_DBGWVR12_EL1(val)		MSR(val, DBGWVR12_EL1)
+#define WSYS_DBGWVR13_EL1(val)		MSR(val, DBGWVR13_EL1)
+#define WSYS_DBGWVR14_EL1(val)		MSR(val, DBGWVR14_EL1)
+#define WSYS_DBGWVR15_EL1(val)		MSR(val, DBGWVR15_EL1)
+
+#endif
diff --git a/arch/arm64/include/asm/dma-iommu.h b/arch/arm64/include/asm/dma-iommu.h
index ab0e5b2..110f750 100644
--- a/arch/arm64/include/asm/dma-iommu.h
+++ b/arch/arm64/include/asm/dma-iommu.h
@@ -14,14 +14,16 @@
 struct dma_iommu_mapping {
 	/* iommu specific data */
 	struct iommu_domain	*domain;
+	bool			init;
+	struct kref		kref;
+	const struct dma_map_ops *ops;
 
+	/* Protects bitmap */
+	spinlock_t		lock;
 	void			*bitmap;
 	size_t			bits;
 	dma_addr_t		base;
 
-	spinlock_t		lock;
-	struct kref		kref;
-
 	struct dma_fast_smmu_mapping *fast;
 };
 
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index afa23b0..1fb0230 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -114,10 +114,10 @@
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE		0x100000000UL
+#define ELF_ET_DYN_BASE		(2 * TASK_SIZE_64 / 3)
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/arm64/include/asm/etmv4x.h b/arch/arm64/include/asm/etmv4x.h
new file mode 100644
index 0000000..4fb91ca
--- /dev/null
+++ b/arch/arm64/include/asm/etmv4x.h
@@ -0,0 +1,385 @@
+/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 __ASM_ETMV4X_H
+#define __ASM_ETMV4X_H
+
+#include <linux/types.h>
+
+/* 32 bit register reads for AArch64 */
+#define trc_readl(reg)			RSYSL_##reg()
+/* 64 bit register reads for AArch64 */
+#define trc_readq(reg)			RSYSQ_##reg()
+/* 32 and 64 bit register writes for AArch64 */
+#define trc_write(val, reg)		WSYS_##reg(val)
+
+#define MRSL(op0, op1, crn, crm, op2)					     \
+({									     \
+uint32_t val;								     \
+asm volatile("mrs %0, S"#op0"_"#op1"_"#crn"_"#crm"_"#op2 : "=r" (val));      \
+val;									     \
+})
+
+#define MRSQ(op0, op1, crn, crm, op2)					     \
+({									     \
+uint64_t val;								     \
+asm volatile("mrs %0, S"#op0"_"#op1"_"#crn"_"#crm"_"#op2 : "=r" (val));      \
+val;									     \
+})
+
+#define MSR(val, op0, op1, crn, crm, op2)				     \
+({									     \
+asm volatile("msr S"#op0"_"#op1"_"#crn"_"#crm"_"#op2", %0" : : "r" (val));   \
+})
+
+/* Clock and Power Management Register */
+#define RSYSL_CPMR_EL1()		MRSL(3, 7, c15, c0, 5)
+#define WSYS_CPMR_EL1(val)		MSR(val, 3, 7, c15, c0, 5)
+
+/*
+ * ETMv4 Registers
+ *
+ * Read only
+ * ETMAUTHSTATUS, ETMDEVARCH, ETMDEVID, ETMIDRn[0-13], ETMOSLSR, ETMSTATR
+ *
+ * Write only
+ * ETMOSLAR
+ */
+/* 32 bit registers */
+#define RSYSL_ETMAUTHSTATUS()		MRSL(2, 1, c7, c14, 6)
+#define RSYSL_ETMAUXCTLR()		MRSL(2, 1, c0, c6, 0)
+#define RSYSL_ETMCCCTLR()		MRSL(2, 1, c0, c14, 0)
+#define RSYSL_ETMCIDCCTLR0()		MRSL(2, 1, c3, c0, 2)
+#define RSYSL_ETMCNTCTLR0()		MRSL(2, 1, c0, c4, 5)
+#define RSYSL_ETMCNTCTLR1()		MRSL(2, 1, c0, c5, 5)
+#define RSYSL_ETMCNTCTLR2()		MRSL(2, 1, c0, c6, 5)
+#define RSYSL_ETMCNTCTLR3()		MRSL(2, 1, c0, c7, 5)
+#define RSYSL_ETMCNTRLDVR0()		MRSL(2, 1, c0, c0, 5)
+#define RSYSL_ETMCNTRLDVR1()		MRSL(2, 1, c0, c1, 5)
+#define RSYSL_ETMCNTRLDVR2()		MRSL(2, 1, c0, c2, 5)
+#define RSYSL_ETMCNTRLDVR3()		MRSL(2, 1, c0, c3, 5)
+#define RSYSL_ETMCNTVR0()		MRSL(2, 1, c0, c8, 5)
+#define RSYSL_ETMCNTVR1()		MRSL(2, 1, c0, c9, 5)
+#define RSYSL_ETMCNTVR2()		MRSL(2, 1, c0, c10, 5)
+#define RSYSL_ETMCNTVR3()		MRSL(2, 1, c0, c11, 5)
+#define RSYSL_ETMCONFIGR()		MRSL(2, 1, c0, c4, 0)
+#define RSYSL_ETMDEVARCH()		MRSL(2, 1, c7, c15, 6)
+#define RSYSL_ETMDEVID()		MRSL(2, 1, c7, c2, 7)
+#define RSYSL_ETMEVENTCTL0R()		MRSL(2, 1, c0, c8, 0)
+#define RSYSL_ETMEVENTCTL1R()		MRSL(2, 1, c0, c9, 0)
+#define RSYSL_ETMEXTINSELR()		MRSL(2, 1, c0, c8, 4)
+#define RSYSL_ETMIDR0()			MRSL(2, 1, c0, c8, 7)
+#define RSYSL_ETMIDR1()			MRSL(2, 1, c0, c9, 7)
+#define RSYSL_ETMIDR10()		MRSL(2, 1, c0, c2, 6)
+#define RSYSL_ETMIDR11()		MRSL(2, 1, c0, c3, 6)
+#define RSYSL_ETMIDR12()		MRSL(2, 1, c0, c4, 6)
+#define RSYSL_ETMIDR13()		MRSL(2, 1, c0, c5, 6)
+#define RSYSL_ETMIDR2()			MRSL(2, 1, c0, c10, 7)
+#define RSYSL_ETMIDR3()			MRSL(2, 1, c0, c11, 7)
+#define RSYSL_ETMIDR4()			MRSL(2, 1, c0, c12, 7)
+#define RSYSL_ETMIDR5()			MRSL(2, 1, c0, c13, 7)
+#define RSYSL_ETMIDR6()			MRSL(2, 1, c0, c14, 7)
+#define RSYSL_ETMIDR7()			MRSL(2, 1, c0, c15, 7)
+#define RSYSL_ETMIDR8()			MRSL(2, 1, c0, c0, 6)
+#define RSYSL_ETMIDR9()			MRSL(2, 1, c0, c1, 6)
+#define RSYSL_ETMIMSPEC0()		MRSL(2, 1, c0, c0, 7)
+#define RSYSL_ETMOSLSR()		MRSL(2, 1, c1, c1, 4)
+#define RSYSL_ETMPRGCTLR()		MRSL(2, 1, c0, c1, 0)
+#define RSYSL_ETMRSCTLR10()		MRSL(2, 1, c1, c10, 0)
+#define RSYSL_ETMRSCTLR11()		MRSL(2, 1, c1, c11, 0)
+#define RSYSL_ETMRSCTLR12()		MRSL(2, 1, c1, c12, 0)
+#define RSYSL_ETMRSCTLR13()		MRSL(2, 1, c1, c13, 0)
+#define RSYSL_ETMRSCTLR14()		MRSL(2, 1, c1, c14, 0)
+#define RSYSL_ETMRSCTLR15()		MRSL(2, 1, c1, c15, 0)
+#define RSYSL_ETMRSCTLR2()		MRSL(2, 1, c1, c2, 0)
+#define RSYSL_ETMRSCTLR3()		MRSL(2, 1, c1, c3, 0)
+#define RSYSL_ETMRSCTLR4()		MRSL(2, 1, c1, c4, 0)
+#define RSYSL_ETMRSCTLR5()		MRSL(2, 1, c1, c5, 0)
+#define RSYSL_ETMRSCTLR6()		MRSL(2, 1, c1, c6, 0)
+#define RSYSL_ETMRSCTLR7()		MRSL(2, 1, c1, c7, 0)
+#define RSYSL_ETMRSCTLR8()		MRSL(2, 1, c1, c8, 0)
+#define RSYSL_ETMRSCTLR9()		MRSL(2, 1, c1, c9, 0)
+#define RSYSL_ETMRSCTLR16()		MRSL(2, 1, c1, c0, 1)
+#define RSYSL_ETMRSCTLR17()		MRSL(2, 1, c1, c1, 1)
+#define RSYSL_ETMRSCTLR18()		MRSL(2, 1, c1, c2, 1)
+#define RSYSL_ETMRSCTLR19()		MRSL(2, 1, c1, c3, 1)
+#define RSYSL_ETMRSCTLR20()		MRSL(2, 1, c1, c4, 1)
+#define RSYSL_ETMRSCTLR21()		MRSL(2, 1, c1, c5, 1)
+#define RSYSL_ETMRSCTLR22()		MRSL(2, 1, c1, c6, 1)
+#define RSYSL_ETMRSCTLR23()		MRSL(2, 1, c1, c7, 1)
+#define RSYSL_ETMRSCTLR24()		MRSL(2, 1, c1, c8, 1)
+#define RSYSL_ETMRSCTLR25()		MRSL(2, 1, c1, c9, 1)
+#define RSYSL_ETMRSCTLR26()		MRSL(2, 1, c1, c10, 1)
+#define RSYSL_ETMRSCTLR27()		MRSL(2, 1, c1, c11, 1)
+#define RSYSL_ETMRSCTLR28()		MRSL(2, 1, c1, c12, 1)
+#define RSYSL_ETMRSCTLR29()		MRSL(2, 1, c1, c13, 1)
+#define RSYSL_ETMRSCTLR30()		MRSL(2, 1, c1, c14, 1)
+#define RSYSL_ETMRSCTLR31()		MRSL(2, 1, c1, c15, 1)
+#define RSYSL_ETMSEQEVR0()		MRSL(2, 1, c0, c0, 4)
+#define RSYSL_ETMSEQEVR1()		MRSL(2, 1, c0, c1, 4)
+#define RSYSL_ETMSEQEVR2()		MRSL(2, 1, c0, c2, 4)
+#define RSYSL_ETMSEQRSTEVR()		MRSL(2, 1, c0, c6, 4)
+#define RSYSL_ETMSEQSTR()		MRSL(2, 1, c0, c7, 4)
+#define RSYSL_ETMSTALLCTLR()		MRSL(2, 1, c0, c11, 0)
+#define RSYSL_ETMSTATR()		MRSL(2, 1, c0, c3, 0)
+#define RSYSL_ETMSYNCPR()		MRSL(2, 1, c0, c13, 0)
+#define RSYSL_ETMTRACEIDR()		MRSL(2, 1, c0, c0, 1)
+#define RSYSL_ETMTSCTLR()		MRSL(2, 1, c0, c12, 0)
+#define RSYSL_ETMVICTLR()		MRSL(2, 1, c0, c0, 2)
+#define RSYSL_ETMVIIECTLR()		MRSL(2, 1, c0, c1, 2)
+#define RSYSL_ETMVISSCTLR()		MRSL(2, 1, c0, c2, 2)
+#define RSYSL_ETMSSCCR0()		MRSL(2, 1, c1, c0, 2)
+#define RSYSL_ETMSSCCR1()		MRSL(2, 1, c1, c1, 2)
+#define RSYSL_ETMSSCCR2()		MRSL(2, 1, c1, c2, 2)
+#define RSYSL_ETMSSCCR3()		MRSL(2, 1, c1, c3, 2)
+#define RSYSL_ETMSSCCR4()		MRSL(2, 1, c1, c4, 2)
+#define RSYSL_ETMSSCCR5()		MRSL(2, 1, c1, c5, 2)
+#define RSYSL_ETMSSCCR6()		MRSL(2, 1, c1, c6, 2)
+#define RSYSL_ETMSSCCR7()		MRSL(2, 1, c1, c7, 2)
+#define RSYSL_ETMSSCSR0()		MRSL(2, 1, c1, c8, 2)
+#define RSYSL_ETMSSCSR1()		MRSL(2, 1, c1, c9, 2)
+#define RSYSL_ETMSSCSR2()		MRSL(2, 1, c1, c10, 2)
+#define RSYSL_ETMSSCSR3()		MRSL(2, 1, c1, c11, 2)
+#define RSYSL_ETMSSCSR4()		MRSL(2, 1, c1, c12, 2)
+#define RSYSL_ETMSSCSR5()		MRSL(2, 1, c1, c13, 2)
+#define RSYSL_ETMSSCSR6()		MRSL(2, 1, c1, c14, 2)
+#define RSYSL_ETMSSCSR7()		MRSL(2, 1, c1, c15, 2)
+#define RSYSL_ETMSSPCICR0()		MRSL(2, 1, c1, c0, 3)
+#define RSYSL_ETMSSPCICR1()		MRSL(2, 1, c1, c1, 3)
+#define RSYSL_ETMSSPCICR2()		MRSL(2, 1, c1, c2, 3)
+#define RSYSL_ETMSSPCICR3()		MRSL(2, 1, c1, c3, 3)
+#define RSYSL_ETMSSPCICR4()		MRSL(2, 1, c1, c4, 3)
+#define RSYSL_ETMSSPCICR5()		MRSL(2, 1, c1, c5, 3)
+#define RSYSL_ETMSSPCICR6()		MRSL(2, 1, c1, c6, 3)
+#define RSYSL_ETMSSPCICR7()		MRSL(2, 1, c1, c7, 3)
+
+/* 64 bit registers */
+#define RSYSQ_ETMACATR0()		MRSQ(2, 1, c2, c0, 2)
+#define RSYSQ_ETMACATR1()		MRSQ(2, 1, c2, c2, 2)
+#define RSYSQ_ETMACATR2()		MRSQ(2, 1, c2, c4, 2)
+#define RSYSQ_ETMACATR3()		MRSQ(2, 1, c2, c6, 2)
+#define RSYSQ_ETMACATR4()		MRSQ(2, 1, c2, c8, 2)
+#define RSYSQ_ETMACATR5()		MRSQ(2, 1, c2, c10, 2)
+#define RSYSQ_ETMACATR6()		MRSQ(2, 1, c2, c12, 2)
+#define RSYSQ_ETMACATR7()		MRSQ(2, 1, c2, c14, 2)
+#define RSYSQ_ETMACATR8()		MRSQ(2, 1, c2, c0, 3)
+#define RSYSQ_ETMACATR9()		MRSQ(2, 1, c2, c2, 3)
+#define RSYSQ_ETMACATR10()		MRSQ(2, 1, c2, c4, 3)
+#define RSYSQ_ETMACATR11()		MRSQ(2, 1, c2, c6, 3)
+#define RSYSQ_ETMACATR12()		MRSQ(2, 1, c2, c8, 3)
+#define RSYSQ_ETMACATR13()		MRSQ(2, 1, c2, c10, 3)
+#define RSYSQ_ETMACATR14()		MRSQ(2, 1, c2, c12, 3)
+#define RSYSQ_ETMACATR15()		MRSQ(2, 1, c2, c14, 3)
+#define RSYSQ_ETMCIDCVR0()		MRSQ(2, 1, c3, c0, 0)
+#define RSYSQ_ETMCIDCVR1()		MRSQ(2, 1, c3, c2, 0)
+#define RSYSQ_ETMCIDCVR2()		MRSQ(2, 1, c3, c4, 0)
+#define RSYSQ_ETMCIDCVR3()		MRSQ(2, 1, c3, c6, 0)
+#define RSYSQ_ETMCIDCVR4()		MRSQ(2, 1, c3, c8, 0)
+#define RSYSQ_ETMCIDCVR5()		MRSQ(2, 1, c3, c10, 0)
+#define RSYSQ_ETMCIDCVR6()		MRSQ(2, 1, c3, c12, 0)
+#define RSYSQ_ETMCIDCVR7()		MRSQ(2, 1, c3, c14, 0)
+#define RSYSQ_ETMACVR0()		MRSQ(2, 1, c2, c0, 0)
+#define RSYSQ_ETMACVR1()		MRSQ(2, 1, c2, c2, 0)
+#define RSYSQ_ETMACVR2()		MRSQ(2, 1, c2, c4, 0)
+#define RSYSQ_ETMACVR3()		MRSQ(2, 1, c2, c6, 0)
+#define RSYSQ_ETMACVR4()		MRSQ(2, 1, c2, c8, 0)
+#define RSYSQ_ETMACVR5()		MRSQ(2, 1, c2, c10, 0)
+#define RSYSQ_ETMACVR6()		MRSQ(2, 1, c2, c12, 0)
+#define RSYSQ_ETMACVR7()		MRSQ(2, 1, c2, c14, 0)
+#define RSYSQ_ETMACVR8()		MRSQ(2, 1, c2, c0, 1)
+#define RSYSQ_ETMACVR9()		MRSQ(2, 1, c2, c2, 1)
+#define RSYSQ_ETMACVR10()		MRSQ(2, 1, c2, c4, 1)
+#define RSYSQ_ETMACVR11()		MRSQ(2, 1, c2, c6, 1)
+#define RSYSQ_ETMACVR12()		MRSQ(2, 1, c2, c8, 1)
+#define RSYSQ_ETMACVR13()		MRSQ(2, 1, c2, c10, 1)
+#define RSYSQ_ETMACVR14()		MRSQ(2, 1, c2, c12, 1)
+#define RSYSQ_ETMACVR15()		MRSQ(2, 1, c2, c14, 1)
+#define RSYSQ_ETMVMIDCVR0()		MRSQ(2, 1, c3, c0, 1)
+#define RSYSQ_ETMVMIDCVR1()		MRSQ(2, 1, c3, c2, 1)
+#define RSYSQ_ETMVMIDCVR2()		MRSQ(2, 1, c3, c4, 1)
+#define RSYSQ_ETMVMIDCVR3()		MRSQ(2, 1, c3, c6, 1)
+#define RSYSQ_ETMVMIDCVR4()		MRSQ(2, 1, c3, c8, 1)
+#define RSYSQ_ETMVMIDCVR5()		MRSQ(2, 1, c3, c10, 1)
+#define RSYSQ_ETMVMIDCVR6()		MRSQ(2, 1, c3, c12, 1)
+#define RSYSQ_ETMVMIDCVR7()		MRSQ(2, 1, c3, c14, 1)
+#define RSYSQ_ETMDVCVR0()		MRSQ(2, 1, c2, c0, 4)
+#define RSYSQ_ETMDVCVR1()		MRSQ(2, 1, c2, c4, 4)
+#define RSYSQ_ETMDVCVR2()		MRSQ(2, 1, c2, c8, 4)
+#define RSYSQ_ETMDVCVR3()		MRSQ(2, 1, c2, c12, 4)
+#define RSYSQ_ETMDVCVR4()		MRSQ(2, 1, c2, c0, 5)
+#define RSYSQ_ETMDVCVR5()		MRSQ(2, 1, c2, c4, 5)
+#define RSYSQ_ETMDVCVR6()		MRSQ(2, 1, c2, c8, 5)
+#define RSYSQ_ETMDVCVR7()		MRSQ(2, 1, c2, c12, 5)
+#define RSYSQ_ETMDVCMR0()		MRSQ(2, 1, c2, c0, 6)
+#define RSYSQ_ETMDVCMR1()		MRSQ(2, 1, c2, c4, 6)
+#define RSYSQ_ETMDVCMR2()		MRSQ(2, 1, c2, c8, 6)
+#define RSYSQ_ETMDVCMR3()		MRSQ(2, 1, c2, c12, 6)
+#define RSYSQ_ETMDVCMR4()		MRSQ(2, 1, c2, c0, 7)
+#define RSYSQ_ETMDVCMR5()		MRSQ(2, 1, c2, c4, 7)
+#define RSYSQ_ETMDVCMR6()		MRSQ(2, 1, c2, c8, 7)
+#define RSYSQ_ETMDVCMR7()		MRSQ(2, 1, c2, c12, 7)
+
+/* 32 and 64 bit registers */
+#define WSYS_ETMAUXCTLR(val)		MSR(val, 2, 1, c0, c6, 0)
+#define WSYS_ETMACATR0(val)		MSR(val, 2, 1, c2, c0, 2)
+#define WSYS_ETMACATR1(val)		MSR(val, 2, 1, c2, c2, 2)
+#define WSYS_ETMACATR2(val)		MSR(val, 2, 1, c2, c4, 2)
+#define WSYS_ETMACATR3(val)		MSR(val, 2, 1, c2, c6, 2)
+#define WSYS_ETMACATR4(val)		MSR(val, 2, 1, c2, c8, 2)
+#define WSYS_ETMACATR5(val)		MSR(val, 2, 1, c2, c10, 2)
+#define WSYS_ETMACATR6(val)		MSR(val, 2, 1, c2, c12, 2)
+#define WSYS_ETMACATR7(val)		MSR(val, 2, 1, c2, c14, 2)
+#define WSYS_ETMACATR8(val)		MSR(val, 2, 1, c2, c0, 3)
+#define WSYS_ETMACATR9(val)		MSR(val, 2, 1, c2, c2, 3)
+#define WSYS_ETMACATR10(val)		MSR(val, 2, 1, c2, c4, 3)
+#define WSYS_ETMACATR11(val)		MSR(val, 2, 1, c2, c6, 3)
+#define WSYS_ETMACATR12(val)		MSR(val, 2, 1, c2, c8, 3)
+#define WSYS_ETMACATR13(val)		MSR(val, 2, 1, c2, c10, 3)
+#define WSYS_ETMACATR14(val)		MSR(val, 2, 1, c2, c12, 3)
+#define WSYS_ETMACATR15(val)		MSR(val, 2, 1, c2, c14, 3)
+#define WSYS_ETMACVR0(val)		MSR(val, 2, 1, c2, c0, 0)
+#define WSYS_ETMACVR1(val)		MSR(val, 2, 1, c2, c2, 0)
+#define WSYS_ETMACVR2(val)		MSR(val, 2, 1, c2, c4, 0)
+#define WSYS_ETMACVR3(val)		MSR(val, 2, 1, c2, c6, 0)
+#define WSYS_ETMACVR4(val)		MSR(val, 2, 1, c2, c8, 0)
+#define WSYS_ETMACVR5(val)		MSR(val, 2, 1, c2, c10, 0)
+#define WSYS_ETMACVR6(val)		MSR(val, 2, 1, c2, c12, 0)
+#define WSYS_ETMACVR7(val)		MSR(val, 2, 1, c2, c14, 0)
+#define WSYS_ETMACVR8(val)		MSR(val, 2, 1, c2, c0, 1)
+#define WSYS_ETMACVR9(val)		MSR(val, 2, 1, c2, c2, 1)
+#define WSYS_ETMACVR10(val)		MSR(val, 2, 1, c2, c4, 1)
+#define WSYS_ETMACVR11(val)		MSR(val, 2, 1, c2, c6, 1)
+#define WSYS_ETMACVR12(val)		MSR(val, 2, 1, c2, c8, 1)
+#define WSYS_ETMACVR13(val)		MSR(val, 2, 1, c2, c10, 1)
+#define WSYS_ETMACVR14(val)		MSR(val, 2, 1, c2, c12, 1)
+#define WSYS_ETMACVR15(val)		MSR(val, 2, 1, c2, c14, 1)
+#define WSYS_ETMCCCTLR(val)		MSR(val, 2, 1, c0, c14, 0)
+#define WSYS_ETMCIDCCTLR0(val)		MSR(val, 2, 1, c3, c0, 2)
+#define WSYS_ETMCIDCVR0(val)		MSR(val, 2, 1, c3, c0, 0)
+#define WSYS_ETMCIDCVR1(val)		MSR(val, 2, 1, c3, c2, 0)
+#define WSYS_ETMCIDCVR2(val)		MSR(val, 2, 1, c3, c4, 0)
+#define WSYS_ETMCIDCVR3(val)		MSR(val, 2, 1, c3, c6, 0)
+#define WSYS_ETMCIDCVR4(val)		MSR(val, 2, 1, c3, c8, 0)
+#define WSYS_ETMCIDCVR5(val)		MSR(val, 2, 1, c3, c10, 0)
+#define WSYS_ETMCIDCVR6(val)		MSR(val, 2, 1, c3, c12, 0)
+#define WSYS_ETMCIDCVR7(val)		MSR(val, 2, 1, c3, c14, 0)
+#define WSYS_ETMCNTCTLR0(val)		MSR(val, 2, 1, c0, c4, 5)
+#define WSYS_ETMCNTCTLR1(val)		MSR(val, 2, 1, c0, c5, 5)
+#define WSYS_ETMCNTCTLR2(val)		MSR(val, 2, 1, c0, c6, 5)
+#define WSYS_ETMCNTCTLR3(val)		MSR(val, 2, 1, c0, c7, 5)
+#define WSYS_ETMCNTRLDVR0(val)		MSR(val, 2, 1, c0, c0, 5)
+#define WSYS_ETMCNTRLDVR1(val)		MSR(val, 2, 1, c0, c1, 5)
+#define WSYS_ETMCNTRLDVR2(val)		MSR(val, 2, 1, c0, c2, 5)
+#define WSYS_ETMCNTRLDVR3(val)		MSR(val, 2, 1, c0, c3, 5)
+#define WSYS_ETMCNTVR0(val)		MSR(val, 2, 1, c0, c8, 5)
+#define WSYS_ETMCNTVR1(val)		MSR(val, 2, 1, c0, c9, 5)
+#define WSYS_ETMCNTVR2(val)		MSR(val, 2, 1, c0, c10, 5)
+#define WSYS_ETMCNTVR3(val)		MSR(val, 2, 1, c0, c11, 5)
+#define WSYS_ETMCONFIGR(val)		MSR(val, 2, 1, c0, c4, 0)
+#define WSYS_ETMEVENTCTL0R(val)		MSR(val, 2, 1, c0, c8, 0)
+#define WSYS_ETMEVENTCTL1R(val)		MSR(val, 2, 1, c0, c9, 0)
+#define WSYS_ETMEXTINSELR(val)		MSR(val, 2, 1, c0, c8, 4)
+#define WSYS_ETMIMSPEC0(val)		MSR(val, 2, 1, c0, c0, 7)
+#define WSYS_ETMOSLAR(val)		MSR(val, 2, 1, c1, c0, 4)
+#define WSYS_ETMPRGCTLR(val)		MSR(val, 2, 1, c0, c1, 0)
+#define WSYS_ETMRSCTLR10(val)		MSR(val, 2, 1, c1, c10, 0)
+#define WSYS_ETMRSCTLR11(val)		MSR(val, 2, 1, c1, c11, 0)
+#define WSYS_ETMRSCTLR12(val)		MSR(val, 2, 1, c1, c12, 0)
+#define WSYS_ETMRSCTLR13(val)		MSR(val, 2, 1, c1, c13, 0)
+#define WSYS_ETMRSCTLR14(val)		MSR(val, 2, 1, c1, c14, 0)
+#define WSYS_ETMRSCTLR15(val)		MSR(val, 2, 1, c1, c15, 0)
+#define WSYS_ETMRSCTLR2(val)		MSR(val, 2, 1, c1, c2, 0)
+#define WSYS_ETMRSCTLR3(val)		MSR(val, 2, 1, c1, c3, 0)
+#define WSYS_ETMRSCTLR4(val)		MSR(val, 2, 1, c1, c4, 0)
+#define WSYS_ETMRSCTLR5(val)		MSR(val, 2, 1, c1, c5, 0)
+#define WSYS_ETMRSCTLR6(val)		MSR(val, 2, 1, c1, c6, 0)
+#define WSYS_ETMRSCTLR7(val)		MSR(val, 2, 1, c1, c7, 0)
+#define WSYS_ETMRSCTLR8(val)		MSR(val, 2, 1, c1, c8, 0)
+#define WSYS_ETMRSCTLR9(val)		MSR(val, 2, 1, c1, c9, 0)
+#define WSYS_ETMRSCTLR16(val)		MSR(val, 2, 1, c1, c0, 1)
+#define WSYS_ETMRSCTLR17(val)		MSR(val, 2, 1, c1, c1, 1)
+#define WSYS_ETMRSCTLR18(val)		MSR(val, 2, 1, c1, c2, 1)
+#define WSYS_ETMRSCTLR19(val)		MSR(val, 2, 1, c1, c3, 1)
+#define WSYS_ETMRSCTLR20(val)		MSR(val, 2, 1, c1, c4, 1)
+#define WSYS_ETMRSCTLR21(val)		MSR(val, 2, 1, c1, c5, 1)
+#define WSYS_ETMRSCTLR22(val)		MSR(val, 2, 1, c1, c6, 1)
+#define WSYS_ETMRSCTLR23(val)		MSR(val, 2, 1, c1, c7, 1)
+#define WSYS_ETMRSCTLR24(val)		MSR(val, 2, 1, c1, c8, 1)
+#define WSYS_ETMRSCTLR25(val)		MSR(val, 2, 1, c1, c9, 1)
+#define WSYS_ETMRSCTLR26(val)		MSR(val, 2, 1, c1, c10, 1)
+#define WSYS_ETMRSCTLR27(val)		MSR(val, 2, 1, c1, c11, 1)
+#define WSYS_ETMRSCTLR28(val)		MSR(val, 2, 1, c1, c12, 1)
+#define WSYS_ETMRSCTLR29(val)		MSR(val, 2, 1, c1, c13, 1)
+#define WSYS_ETMRSCTLR30(val)		MSR(val, 2, 1, c1, c14, 1)
+#define WSYS_ETMRSCTLR31(val)		MSR(val, 2, 1, c1, c15, 1)
+#define WSYS_ETMSEQEVR0(val)		MSR(val, 2, 1, c0, c0, 4)
+#define WSYS_ETMSEQEVR1(val)		MSR(val, 2, 1, c0, c1, 4)
+#define WSYS_ETMSEQEVR2(val)		MSR(val, 2, 1, c0, c2, 4)
+#define WSYS_ETMSEQRSTEVR(val)		MSR(val, 2, 1, c0, c6, 4)
+#define WSYS_ETMSEQSTR(val)		MSR(val, 2, 1, c0, c7, 4)
+#define WSYS_ETMSTALLCTLR(val)		MSR(val, 2, 1, c0, c11, 0)
+#define WSYS_ETMSYNCPR(val)		MSR(val, 2, 1, c0, c13, 0)
+#define WSYS_ETMTRACEIDR(val)		MSR(val, 2, 1, c0, c0, 1)
+#define WSYS_ETMTSCTLR(val)		MSR(val, 2, 1, c0, c12, 0)
+#define WSYS_ETMVICTLR(val)		MSR(val, 2, 1, c0, c0, 2)
+#define WSYS_ETMVIIECTLR(val)		MSR(val, 2, 1, c0, c1, 2)
+#define WSYS_ETMVISSCTLR(val)		MSR(val, 2, 1, c0, c2, 2)
+#define WSYS_ETMVMIDCVR0(val)		MSR(val, 2, 1, c3, c0, 1)
+#define WSYS_ETMVMIDCVR1(val)		MSR(val, 2, 1, c3, c2, 1)
+#define WSYS_ETMVMIDCVR2(val)		MSR(val, 2, 1, c3, c4, 1)
+#define WSYS_ETMVMIDCVR3(val)		MSR(val, 2, 1, c3, c6, 1)
+#define WSYS_ETMVMIDCVR4(val)		MSR(val, 2, 1, c3, c8, 1)
+#define WSYS_ETMVMIDCVR5(val)		MSR(val, 2, 1, c3, c10, 1)
+#define WSYS_ETMVMIDCVR6(val)		MSR(val, 2, 1, c3, c12, 1)
+#define WSYS_ETMVMIDCVR7(val)		MSR(val, 2, 1, c3, c14, 1)
+#define WSYS_ETMDVCVR0(val)		MSR(val, 2, 1, c2, c0, 4)
+#define WSYS_ETMDVCVR1(val)		MSR(val, 2, 1, c2, c4, 4)
+#define WSYS_ETMDVCVR2(val)		MSR(val, 2, 1, c2, c8, 4)
+#define WSYS_ETMDVCVR3(val)		MSR(val, 2, 1, c2, c12, 4)
+#define WSYS_ETMDVCVR4(val)		MSR(val, 2, 1, c2, c0, 5)
+#define WSYS_ETMDVCVR5(val)		MSR(val, 2, 1, c2, c4, 5)
+#define WSYS_ETMDVCVR6(val)		MSR(val, 2, 1, c2, c8, 5)
+#define WSYS_ETMDVCVR7(val)		MSR(val, 2, 1, c2, c12, 5)
+#define WSYS_ETMDVCMR0(val)		MSR(val, 2, 1, c2, c0, 6)
+#define WSYS_ETMDVCMR1(val)		MSR(val, 2, 1, c2, c4, 6)
+#define WSYS_ETMDVCMR2(val)		MSR(val, 2, 1, c2, c8, 6)
+#define WSYS_ETMDVCMR3(val)		MSR(val, 2, 1, c2, c12, 6)
+#define WSYS_ETMDVCMR4(val)		MSR(val, 2, 1, c2, c0, 7)
+#define WSYS_ETMDVCMR5(val)		MSR(val, 2, 1, c2, c4, 7)
+#define WSYS_ETMDVCMR6(val)		MSR(val, 2, 1, c2, c8, 7)
+#define WSYS_ETMDVCMR7(val)		MSR(val, 2, 1, c2, c12, 7)
+#define WSYS_ETMSSCCR0(val)		MSR(val, 2, 1, c1, c0, 2)
+#define WSYS_ETMSSCCR1(val)		MSR(val, 2, 1, c1, c1, 2)
+#define WSYS_ETMSSCCR2(val)		MSR(val, 2, 1, c1, c2, 2)
+#define WSYS_ETMSSCCR3(val)		MSR(val, 2, 1, c1, c3, 2)
+#define WSYS_ETMSSCCR4(val)		MSR(val, 2, 1, c1, c4, 2)
+#define WSYS_ETMSSCCR5(val)		MSR(val, 2, 1, c1, c5, 2)
+#define WSYS_ETMSSCCR6(val)		MSR(val, 2, 1, c1, c6, 2)
+#define WSYS_ETMSSCCR7(val)		MSR(val, 2, 1, c1, c7, 2)
+#define WSYS_ETMSSCSR0(val)		MSR(val, 2, 1, c1, c8, 2)
+#define WSYS_ETMSSCSR1(val)		MSR(val, 2, 1, c1, c9, 2)
+#define WSYS_ETMSSCSR2(val)		MSR(val, 2, 1, c1, c10, 2)
+#define WSYS_ETMSSCSR3(val)		MSR(val, 2, 1, c1, c11, 2)
+#define WSYS_ETMSSCSR4(val)		MSR(val, 2, 1, c1, c12, 2)
+#define WSYS_ETMSSCSR5(val)		MSR(val, 2, 1, c1, c13, 2)
+#define WSYS_ETMSSCSR6(val)		MSR(val, 2, 1, c1, c14, 2)
+#define WSYS_ETMSSCSR7(val)		MSR(val, 2, 1, c1, c15, 2)
+#define WSYS_ETMSSPCICR0(val)		MSR(val, 2, 1, c1, c0, 3)
+#define WSYS_ETMSSPCICR1(val)		MSR(val, 2, 1, c1, c1, 3)
+#define WSYS_ETMSSPCICR2(val)		MSR(val, 2, 1, c1, c2, 3)
+#define WSYS_ETMSSPCICR3(val)		MSR(val, 2, 1, c1, c3, 3)
+#define WSYS_ETMSSPCICR4(val)		MSR(val, 2, 1, c1, c4, 3)
+#define WSYS_ETMSSPCICR5(val)		MSR(val, 2, 1, c1, c5, 3)
+#define WSYS_ETMSSPCICR6(val)		MSR(val, 2, 1, c1, c6, 3)
+#define WSYS_ETMSSPCICR7(val)		MSR(val, 2, 1, c1, c7, 3)
+
+#endif
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 5edb6ed..f3a142e 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -165,6 +165,11 @@
 /* the offset between the kernel virtual and physical mappings */
 extern u64			kimage_voffset;
 
+static inline unsigned long kaslr_offset(void)
+{
+	return kimage_vaddr - KIMAGE_VADDR;
+}
+
 /*
  * Allow all memory at the discovery stage. We will clip it later.
  */
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 394c61d..1d5890f 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -157,9 +157,11 @@
 
 void fpsimd_flush_thread(void)
 {
+	preempt_disable();
 	memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
 	fpsimd_flush_task_state(current);
 	set_thread_flag(TIF_FOREIGN_FPSTATE);
+	preempt_enable();
 }
 
 /*
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index ba29095..a58fb92 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -356,11 +356,11 @@
 static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
 			      void *p)
 {
-	u64 const kaslr_offset = kimage_vaddr - KIMAGE_VADDR;
+	const unsigned long offset = kaslr_offset();
 
-	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset > 0) {
-		pr_emerg("Kernel Offset: 0x%llx from 0x%lx\n",
-			 kaslr_offset, KIMAGE_VADDR);
+	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && offset > 0) {
+		pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
+			 offset, KIMAGE_VADDR);
 	} else {
 		pr_emerg("Kernel Offset: disabled\n");
 	}
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 7b670f1..f2fe96f 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -420,6 +420,11 @@
 	return &cpu_topology[cpu].core_sibling;
 }
 
+static int cpu_cpu_flags(void)
+{
+	return SD_ASYM_CPUCAPACITY;
+}
+
 static inline int cpu_corepower_flags(void)
 {
 	return SD_SHARE_PKG_RESOURCES  | SD_SHARE_POWERDOMAIN | \
@@ -430,7 +435,7 @@
 #ifdef CONFIG_SCHED_MC
 	{ cpu_coregroup_mask, cpu_corepower_flags, cpu_core_energy, SD_INIT_NAME(MC) },
 #endif
-	{ cpu_cpu_mask, NULL, cpu_cluster_energy, SD_INIT_NAME(DIE) },
+	{ cpu_cpu_mask, cpu_cpu_flags, cpu_cluster_energy, SD_INIT_NAME(DIE) },
 	{ NULL, },
 };
 
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index e576c1d..5620500 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -43,6 +43,7 @@
 #include <asm/exception.h>
 #include <asm/system_misc.h>
 #include <asm/sysreg.h>
+#include <trace/events/exception.h>
 
 static const char *handler[]= {
 	"Synchronous Abort",
@@ -458,6 +459,8 @@
 
 asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
 {
+	void __user *pc = (void __user *)instruction_pointer(regs);
+
 	/* check for AArch32 breakpoint instructions */
 	if (!aarch32_break_handler(regs))
 		return;
@@ -465,6 +468,8 @@
 	if (call_undef_hook(regs) == 0)
 		return;
 
+	trace_undef_instr(regs, pc);
+
 	force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
 }
 
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 7f90b7e..5229b33 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -1906,23 +1906,42 @@
  * IO address ranges, which is required to perform memory allocation and
  * mapping with IOMMU aware functions.
  *
- * The client device need to be attached to the mapping with
- * arm_iommu_attach_device function.
+ * Clients may use iommu_domain_set_attr() to set additional flags prior
+ * to calling arm_iommu_attach_device() to complete initialization.
  */
 struct dma_iommu_mapping *
 arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
 {
 	unsigned int bits = size >> PAGE_SHIFT;
-	unsigned int bitmap_size = BITS_TO_LONGS(bits) * sizeof(long);
 	struct dma_iommu_mapping *mapping;
-	int err = -ENOMEM;
 
-	if (!bitmap_size)
+	if (!bits)
 		return ERR_PTR(-EINVAL);
 
 	mapping = kzalloc(sizeof(struct dma_iommu_mapping), GFP_KERNEL);
 	if (!mapping)
-		goto err;
+		return ERR_PTR(-ENOMEM);
+
+	mapping->base = base;
+	mapping->bits = bits;
+
+	mapping->domain = iommu_domain_alloc(bus);
+	if (!mapping->domain)
+		goto err_domain_alloc;
+
+	mapping->init = false;
+	return mapping;
+
+err_domain_alloc:
+	kfree(mapping);
+	return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(arm_iommu_create_mapping);
+
+static int
+bitmap_iommu_init_mapping(struct device *dev, struct dma_iommu_mapping *mapping)
+{
+	unsigned int bitmap_size = BITS_TO_LONGS(mapping->bits) * sizeof(long);
 
 	mapping->bitmap = kzalloc(bitmap_size, GFP_KERNEL | __GFP_NOWARN |
 							__GFP_NORETRY);
@@ -1930,67 +1949,124 @@
 		mapping->bitmap = vzalloc(bitmap_size);
 
 	if (!mapping->bitmap)
-		goto err2;
+		return -ENOMEM;
 
-	mapping->base = base;
-	mapping->bits = bits;
 	spin_lock_init(&mapping->lock);
-
-	mapping->domain = iommu_domain_alloc(bus);
-	if (!mapping->domain)
-		goto err3;
-
-	kref_init(&mapping->kref);
-	return mapping;
-err3:
-	kvfree(mapping->bitmap);
-err2:
-	kfree(mapping);
-err:
-	return ERR_PTR(err);
+	mapping->ops = &iommu_ops;
+	return 0;
 }
-EXPORT_SYMBOL(arm_iommu_create_mapping);
 
-static void release_iommu_mapping(struct kref *kref)
+static void bitmap_iommu_release_mapping(struct kref *kref)
+{
+	struct dma_iommu_mapping *mapping =
+		container_of(kref, struct dma_iommu_mapping, kref);
+
+	kfree(mapping->bitmap);
+	iommu_domain_free(mapping->domain);
+	kfree(mapping);
+}
+
+static void bypass_iommu_release_mapping(struct kref *kref)
 {
 	struct dma_iommu_mapping *mapping =
 		container_of(kref, struct dma_iommu_mapping, kref);
 
 	iommu_domain_free(mapping->domain);
-	kvfree(mapping->bitmap);
 	kfree(mapping);
 }
 
+static int upstream_iommu_init_mapping(struct device *dev,
+					struct dma_iommu_mapping *mapping)
+{
+	struct iommu_domain *domain = mapping->domain;
+	struct iommu_group *group = dev->iommu_group;
+	dma_addr_t base = mapping->base;
+	u64 size = mapping->bits << PAGE_SHIFT;
+
+	if (iommu_get_dma_cookie(domain))
+		return -EINVAL;
+
+	/* Need to attach to get geometry */
+	if (iommu_attach_group(domain, group))
+		goto out_put_cookie;
+
+	if (iommu_dma_init_domain(domain, base, size, dev))
+		goto out_detach_group;
+
+	mapping->ops = &iommu_dma_ops;
+	iommu_detach_group(domain, group);
+	return 0;
+
+out_detach_group:
+	iommu_detach_group(domain, group);
+out_put_cookie:
+	iommu_put_dma_cookie(domain);
+	return -EINVAL;
+}
+
+static void upstream_iommu_release_mapping(struct kref *kref)
+{
+	struct dma_iommu_mapping *mapping =
+		container_of(kref, struct dma_iommu_mapping, kref);
+
+	iommu_put_dma_cookie(mapping->domain);
+	iommu_domain_free(mapping->domain);
+	kfree(mapping);
+}
+
+/*
+ * arm_iommu_release_mapping
+ * @mapping: allocted via arm_iommu_create_mapping()
+ *
+ * Frees all resources associated with the iommu mapping.
+ * The device associated with this mapping must be in the 'detached' state
+ */
 void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping)
 {
-	if (mapping)
-		kref_put(&mapping->kref, release_iommu_mapping);
+	int s1_bypass = 0, is_fast = 0, is_upstream = 0;
+	void (*release)(struct kref *kref);
+
+	if (!mapping)
+		return;
+
+	if (!mapping->init) {
+		iommu_domain_free(mapping->domain);
+		kfree(mapping);
+		return;
+	}
+
+	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
+					&s1_bypass);
+	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_FAST, &is_fast);
+	iommu_domain_get_attr(mapping->domain,
+				DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR,
+				&is_upstream);
+
+	if (s1_bypass)
+		release = bypass_iommu_release_mapping;
+	else if (is_fast)
+		release = fast_smmu_release_mapping;
+	else if (is_upstream)
+		release = upstream_iommu_release_mapping;
+	else
+		release = bitmap_iommu_release_mapping;
+
+	kref_put(&mapping->kref, release);
 }
 EXPORT_SYMBOL(arm_iommu_release_mapping);
 
-/**
- * arm_iommu_attach_device
- * @dev: valid struct device pointer
- * @mapping: io address space mapping structure (returned from
- *	arm_iommu_create_mapping)
- *
- * Attaches specified io address space mapping to the provided device,
- * this replaces the dma operations (dma_map_ops pointer) with the
- * IOMMU aware version. Only one device in an iommu_group may use this
- * function.
- */
-int arm_iommu_attach_device(struct device *dev,
+static int arm_iommu_init_mapping(struct device *dev,
 			    struct dma_iommu_mapping *mapping)
 {
-	int err;
-	int s1_bypass = 0, is_fast = 0;
+	int err = -EINVAL;
+	int s1_bypass = 0, is_fast = 0, is_upstream = 0;
 	struct iommu_group *group;
 	dma_addr_t iova_end;
 
 	group = dev->iommu_group;
 	if (!group) {
 		dev_err(dev, "No iommu associated with device\n");
-		return -ENODEV;
+		return -EINVAL;
 	}
 
 	if (iommu_get_domain_for_dev(dev)) {
@@ -1998,6 +2074,11 @@
 		return -EINVAL;
 	}
 
+	if (mapping->init) {
+		kref_get(&mapping->kref);
+		return 0;
+	}
+
 	iova_end = mapping->base + (mapping->bits << PAGE_SHIFT) - 1;
 	if (iova_end > dma_get_mask(dev)) {
 		dev_err(dev, "dma mask %llx too small for requested iova range %pad to %pad\n",
@@ -2005,21 +2086,59 @@
 		return -EINVAL;
 	}
 
+	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
+					&s1_bypass);
 	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_FAST, &is_fast);
-	if (is_fast)
-		return fast_smmu_attach_device(dev, mapping);
+	iommu_domain_get_attr(mapping->domain,
+				DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR,
+				&is_upstream);
 
-	err = iommu_attach_group(mapping->domain, group);
+	if (s1_bypass) {
+		mapping->ops = &swiotlb_dma_ops;
+		err = 0;
+	} else if (is_fast) {
+		err = fast_smmu_init_mapping(dev, mapping);
+	} else if (is_upstream) {
+		err = upstream_iommu_init_mapping(dev, mapping);
+	} else {
+		err = bitmap_iommu_init_mapping(dev, mapping);
+	}
+	if (!err) {
+		kref_init(&mapping->kref);
+		mapping->init = true;
+	}
+	return err;
+}
+
+/**
+ * arm_iommu_attach_device
+ * @dev: valid struct device pointer
+ * @mapping: io address space mapping structure (returned from
+ *	arm_iommu_create_mapping)
+ *
+ * Attaches specified io address space mapping to the provided device,
+ * this replaces the dma operations (dma_map_ops pointer) with the
+ * IOMMU aware version.
+ *
+ * Clients are expected to call arm_iommu_attach_device() prior to sharing
+ * the dma_iommu_mapping structure with another device. This ensures
+ * initialization is complete.
+ */
+int arm_iommu_attach_device(struct device *dev,
+			    struct dma_iommu_mapping *mapping)
+{
+	int err;
+
+	err = arm_iommu_init_mapping(dev, mapping);
 	if (err)
 		return err;
 
-	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
-					&s1_bypass);
+	err = iommu_attach_group(mapping->domain, dev->iommu_group);
+	if (err)
+		return err;
 
-	kref_get(&mapping->kref);
 	dev->archdata.mapping = mapping;
-	if (!s1_bypass)
-		set_dma_ops(dev, &iommu_ops);
+	set_dma_ops(dev, mapping->ops);
 
 	pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev));
 	return 0;
@@ -2036,8 +2155,7 @@
 void arm_iommu_detach_device(struct device *dev)
 {
 	struct dma_iommu_mapping *mapping;
-	int is_fast, s1_bypass = 0;
-	struct iommu_group *group;
+	int s1_bypass = 0;
 
 	mapping = to_dma_iommu_mapping(dev);
 	if (!mapping) {
@@ -2045,26 +2163,22 @@
 		return;
 	}
 
-	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_FAST, &is_fast);
-	if (is_fast) {
-		fast_smmu_detach_device(dev, mapping);
+	if (!dev->iommu_group) {
+		dev_err(dev, "No iommu associated with device\n");
 		return;
 	}
 
 	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
 					&s1_bypass);
 
+	/*
+	 * ION defers dma_unmap calls. Ensure they have all completed prior to
+	 * setting dma_ops to NULL.
+	 */
 	if (msm_dma_unmap_all_for_dev(dev))
 		dev_warn(dev, "IOMMU detach with outstanding mappings\n");
 
-	group = dev->iommu_group;
-	if (!group) {
-		dev_err(dev, "No iommu associated with device\n");
-		return;
-	}
-
-	iommu_detach_group(mapping->domain, group);
-	kref_put(&mapping->kref, release_iommu_mapping);
+	iommu_detach_group(mapping->domain, dev->iommu_group);
 	dev->archdata.mapping = NULL;
 	if (!s1_bypass)
 		set_dma_ops(dev, NULL);
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index d0ffade..792dac8 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -41,6 +41,7 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <soc/qcom/scm.h>
+#include <trace/events/exception.h>
 
 struct fault_info {
 	int	(*fn)(unsigned long addr, unsigned int esr,
@@ -102,21 +103,21 @@
 			break;
 
 		pud = pud_offset(pgd, addr);
-		printk(", *pud=%016llx", pud_val(*pud));
+		pr_cont(", *pud=%016llx", pud_val(*pud));
 		if (pud_none(*pud) || pud_bad(*pud))
 			break;
 
 		pmd = pmd_offset(pud, addr);
-		printk(", *pmd=%016llx", pmd_val(*pmd));
+		pr_cont(", *pmd=%016llx", pmd_val(*pmd));
 		if (pmd_none(*pmd) || pmd_bad(*pmd))
 			break;
 
 		pte = pte_offset_map(pmd, addr);
-		printk(", *pte=%016llx", pte_val(*pte));
+		pr_cont(", *pte=%016llx", pte_val(*pte));
 		pte_unmap(pte);
 	} while(0);
 
-	printk("\n");
+	pr_cont("\n");
 }
 
 #ifdef CONFIG_ARM64_HW_AFDBM
@@ -212,6 +213,8 @@
 	struct siginfo si;
 	const struct fault_info *inf;
 
+	trace_user_fault(tsk, addr, esr);
+
 	if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) {
 		inf = esr_to_fault_info(esr);
 		pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n",
@@ -381,8 +384,11 @@
 	 * signal first. We do not need to release the mmap_sem because it
 	 * would already be released in __lock_page_or_retry in mm/filemap.c.
 	 */
-	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
+		if (!user_mode(regs))
+			goto no_context;
 		return 0;
+	}
 
 	/*
 	 * Major/minor page fault accounting is only done on the initial
diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S
index 1910223..cea2bb1 100644
--- a/arch/mips/dec/int-handler.S
+++ b/arch/mips/dec/int-handler.S
@@ -147,23 +147,12 @@
 		 * Find irq with highest priority
 		 */
 		# open coded PTR_LA t1, cpu_mask_nr_tbl
-#if (_MIPS_SZPTR == 32)
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
 		# open coded la t1, cpu_mask_nr_tbl
 		lui	t1, %hi(cpu_mask_nr_tbl)
 		addiu	t1, %lo(cpu_mask_nr_tbl)
-
-#endif
-#if (_MIPS_SZPTR == 64)
-		# open coded dla t1, cpu_mask_nr_tbl
-		.set	push
-		.set	noat
-		lui	t1, %highest(cpu_mask_nr_tbl)
-		lui	AT, %hi(cpu_mask_nr_tbl)
-		daddiu	t1, t1, %higher(cpu_mask_nr_tbl)
-		daddiu	AT, AT, %lo(cpu_mask_nr_tbl)
-		dsll	t1, 32
-		daddu	t1, t1, AT
-		.set	pop
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
 #endif
 1:		lw	t2,(t1)
 		nop
@@ -214,23 +203,12 @@
 		 * Find irq with highest priority
 		 */
 		# open coded PTR_LA t1,asic_mask_nr_tbl
-#if (_MIPS_SZPTR == 32)
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
 		# open coded la t1, asic_mask_nr_tbl
 		lui	t1, %hi(asic_mask_nr_tbl)
 		addiu	t1, %lo(asic_mask_nr_tbl)
-
-#endif
-#if (_MIPS_SZPTR == 64)
-		# open coded dla t1, asic_mask_nr_tbl
-		.set	push
-		.set	noat
-		lui	t1, %highest(asic_mask_nr_tbl)
-		lui	AT, %hi(asic_mask_nr_tbl)
-		daddiu	t1, t1, %higher(asic_mask_nr_tbl)
-		daddiu	AT, AT, %lo(asic_mask_nr_tbl)
-		dsll	t1, 32
-		daddu	t1, t1, AT
-		.set	pop
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
 #endif
 2:		lw	t2,(t1)
 		nop
diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
index d68b9ed..c50609a 100644
--- a/arch/openrisc/kernel/vmlinux.lds.S
+++ b/arch/openrisc/kernel/vmlinux.lds.S
@@ -38,6 +38,8 @@
         /* Read-only sections, merged into text segment: */
         . = LOAD_BASE ;
 
+	_text = .;
+
 	/* _s_kernel_ro must be page aligned */
 	. = ALIGN(PAGE_SIZE);
 	_s_kernel_ro = .;
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 53ec75f..df757c9 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -452,8 +452,8 @@
 	  before it can be accessed through the kernel mapping. */
 	preempt_disable();
 	flush_dcache_page_asm(__pa(vfrom), vaddr);
-	preempt_enable();
 	copy_page_asm(vto, vfrom);
+	preempt_enable();
 }
 EXPORT_SYMBOL(copy_user_page);
 
@@ -538,6 +538,10 @@
 	struct vm_area_struct *vma;
 	pgd_t *pgd;
 
+	/* Flush the TLB to avoid speculation if coherency is required. */
+	if (parisc_requires_coherency())
+		flush_tlb_all();
+
 	/* Flushing the whole cache on each cpu takes forever on
 	   rp3440, etc.  So, avoid it if the mm isn't too big.  */
 	if (mm_total_size(mm) >= parisc_cache_flush_threshold) {
@@ -594,33 +598,21 @@
 void flush_cache_range(struct vm_area_struct *vma,
 		unsigned long start, unsigned long end)
 {
-	unsigned long addr;
-	pgd_t *pgd;
-
 	BUG_ON(!vma->vm_mm->context);
 
-	if ((end - start) >= parisc_cache_flush_threshold) {
+	/* Flush the TLB to avoid speculation if coherency is required. */
+	if (parisc_requires_coherency())
+		flush_tlb_range(vma, start, end);
+
+	if ((end - start) >= parisc_cache_flush_threshold
+	    || vma->vm_mm->context != mfsp(3)) {
 		flush_cache_all();
 		return;
 	}
 
-	if (vma->vm_mm->context == mfsp(3)) {
-		flush_user_dcache_range_asm(start, end);
-		if (vma->vm_flags & VM_EXEC)
-			flush_user_icache_range_asm(start, end);
-		return;
-	}
-
-	pgd = vma->vm_mm->pgd;
-	for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
-		unsigned long pfn;
-		pte_t *ptep = get_ptep(pgd, addr);
-		if (!ptep)
-			continue;
-		pfn = pte_pfn(*ptep);
-		if (pfn_valid(pfn))
-			__flush_cache_page(vma, addr, PFN_PHYS(pfn));
-	}
+	flush_user_dcache_range_asm(start, end);
+	if (vma->vm_flags & VM_EXEC)
+		flush_user_icache_range_asm(start, end);
 }
 
 void
@@ -629,7 +621,8 @@
 	BUG_ON(!vma->vm_mm->context);
 
 	if (pfn_valid(pfn)) {
-		flush_tlb_page(vma, vmaddr);
+		if (parisc_requires_coherency())
+			flush_tlb_page(vma, vmaddr);
 		__flush_cache_page(vma, vmaddr, PFN_PHYS(pfn));
 	}
 }
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index e7ffde2..7593787 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -50,6 +50,7 @@
 #include <linux/uaccess.h>
 #include <linux/rcupdate.h>
 #include <linux/random.h>
+#include <linux/nmi.h>
 
 #include <asm/io.h>
 #include <asm/asm-offsets.h>
@@ -142,6 +143,7 @@
 
 	/* prevent soft lockup/stalled CPU messages for endless loop. */
 	rcu_sysrq_start();
+	lockup_detector_suspend();
 	for (;;);
 }
 
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index 0012f03..fe208b7 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -75,9 +75,27 @@
 				      struct task_struct *tsk)
 {
 	/* Mark this context has been used on the new CPU */
-	if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next)))
+	if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) {
 		cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
 
+		/*
+		 * This full barrier orders the store to the cpumask above vs
+		 * a subsequent operation which allows this CPU to begin loading
+		 * translations for next.
+		 *
+		 * When using the radix MMU that operation is the load of the
+		 * MMU context id, which is then moved to SPRN_PID.
+		 *
+		 * For the hash MMU it is either the first load from slb_cache
+		 * in switch_slb(), and/or the store of paca->mm_ctx_id in
+		 * copy_mm_to_paca().
+		 *
+		 * On the read side the barrier is in pte_xchg(), which orders
+		 * the store to the PTE vs the load of mm_cpumask.
+		 */
+		smp_mb();
+	}
+
 	/* 32-bit keeps track of the current PGDIR in the thread struct */
 #ifdef CONFIG_PPC32
 	tsk->thread.pgdir = next->pgd;
diff --git a/arch/powerpc/include/asm/pgtable-be-types.h b/arch/powerpc/include/asm/pgtable-be-types.h
index 49c0a5a..68e087e 100644
--- a/arch/powerpc/include/asm/pgtable-be-types.h
+++ b/arch/powerpc/include/asm/pgtable-be-types.h
@@ -87,6 +87,7 @@
 	unsigned long *p = (unsigned long *)ptep;
 	__be64 prev;
 
+	/* See comment in switch_mm_irqs_off() */
 	prev = (__force __be64)__cmpxchg_u64(p, (__force unsigned long)pte_raw(old),
 					     (__force unsigned long)pte_raw(new));
 
diff --git a/arch/powerpc/include/asm/pgtable-types.h b/arch/powerpc/include/asm/pgtable-types.h
index e7f4f3e..41e9d0a 100644
--- a/arch/powerpc/include/asm/pgtable-types.h
+++ b/arch/powerpc/include/asm/pgtable-types.h
@@ -62,6 +62,7 @@
 {
 	unsigned long *p = (unsigned long *)ptep;
 
+	/* See comment in switch_mm_irqs_off() */
 	return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
 }
 #endif
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 3297715..8b3b46b 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -44,22 +44,8 @@
 extern int sysfs_add_device_to_node(struct device *dev, int nid);
 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
 
-static inline int early_cpu_to_node(int cpu)
-{
-	int nid;
-
-	nid = numa_cpu_lookup_table[cpu];
-
-	/*
-	 * Fall back to node 0 if nid is unset (it should be, except bugs).
-	 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
-	 */
-	return (nid < 0) ? 0 : nid;
-}
 #else
 
-static inline int early_cpu_to_node(int cpu) { return 0; }
-
 static inline void dump_numa_cpu_topology(void) {}
 
 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 3c05c31..028a22b 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -146,6 +146,19 @@
 
 	/* Clear bit 0 which we wouldn't clear otherwise */
 	local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
+	if (happened & PACA_IRQ_HARD_DIS) {
+		/*
+		 * We may have missed a decrementer interrupt if hard disabled.
+		 * Check the decrementer register in case we had a rollover
+		 * while hard disabled.
+		 */
+		if (!(happened & PACA_IRQ_DEC)) {
+			if (decrementer_check_overflow()) {
+				local_paca->irq_happened |= PACA_IRQ_DEC;
+				happened |= PACA_IRQ_DEC;
+			}
+		}
+	}
 
 	/*
 	 * Force the delivery of pending soft-disabled interrupts on PS3.
@@ -171,7 +184,7 @@
 	 * in case we also had a rollover while hard disabled
 	 */
 	local_paca->irq_happened &= ~PACA_IRQ_DEC;
-	if ((happened & PACA_IRQ_DEC) || decrementer_check_overflow())
+	if (happened & PACA_IRQ_DEC)
 		return 0x900;
 
 	/* Finally check if an external interrupt happened */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b249c2f..1c141d5 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -359,7 +359,8 @@
 
 	cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX);
 
-	if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) {
+	if (current->thread.regs &&
+	    (current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) {
 		check_if_tm_restore_required(current);
 		/*
 		 * If a thread has already been reclaimed then the
@@ -383,7 +384,7 @@
 {
 	if (tsk->thread.regs) {
 		preempt_disable();
-		if (tsk->thread.regs->msr & MSR_VSX) {
+		if (tsk->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP)) {
 			BUG_ON(tsk != current);
 			giveup_vsx(tsk);
 		}
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 5c8f12f..dcbb914 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -127,12 +127,19 @@
 	 * If task is not current, it will have been flushed already to
 	 * it's thread_struct during __switch_to().
 	 *
-	 * A reclaim flushes ALL the state.
+	 * A reclaim flushes ALL the state or if not in TM save TM SPRs
+	 * in the appropriate thread structures from live.
 	 */
 
-	if (tsk == current && MSR_TM_SUSPENDED(mfmsr()))
-		tm_reclaim_current(TM_CAUSE_SIGNAL);
+	if (tsk != current)
+		return;
 
+	if (MSR_TM_SUSPENDED(mfmsr())) {
+		tm_reclaim_current(TM_CAUSE_SIGNAL);
+	} else {
+		tm_enable();
+		tm_save_sprs(&(tsk->thread));
+	}
 }
 #else
 static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index ada71be..a12be60 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -595,7 +595,7 @@
 
 static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
 {
-	return __alloc_bootmem_node(NODE_DATA(early_cpu_to_node(cpu)), size, align,
+	return __alloc_bootmem_node(NODE_DATA(cpu_to_node(cpu)), size, align,
 				    __pa(MAX_DMA_ADDRESS));
 }
 
@@ -606,7 +606,7 @@
 
 static int pcpu_cpu_distance(unsigned int from, unsigned int to)
 {
-	if (early_cpu_to_node(from) == early_cpu_to_node(to))
+	if (cpu_to_node(from) == cpu_to_node(to))
 		return LOCAL_DISTANCE;
 	else
 		return REMOTE_DISTANCE;
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 5c02984..218cba2 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2808,6 +2808,8 @@
 	int r;
 	int srcu_idx;
 	unsigned long ebb_regs[3] = {};	/* shut up GCC */
+	unsigned long user_tar = 0;
+	unsigned int user_vrsave;
 
 	if (!vcpu->arch.sane) {
 		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
@@ -2828,6 +2830,8 @@
 			run->fail_entry.hardware_entry_failure_reason = 0;
 			return -EINVAL;
 		}
+		/* Enable TM so we can read the TM SPRs */
+		mtmsr(mfmsr() | MSR_TM);
 		current->thread.tm_tfhar = mfspr(SPRN_TFHAR);
 		current->thread.tm_tfiar = mfspr(SPRN_TFIAR);
 		current->thread.tm_texasr = mfspr(SPRN_TEXASR);
@@ -2856,12 +2860,14 @@
 
 	flush_all_to_thread(current);
 
-	/* Save userspace EBB register values */
+	/* Save userspace EBB and other register values */
 	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
 		ebb_regs[0] = mfspr(SPRN_EBBHR);
 		ebb_regs[1] = mfspr(SPRN_EBBRR);
 		ebb_regs[2] = mfspr(SPRN_BESCR);
+		user_tar = mfspr(SPRN_TAR);
 	}
+	user_vrsave = mfspr(SPRN_VRSAVE);
 
 	vcpu->arch.wqp = &vcpu->arch.vcore->wq;
 	vcpu->arch.pgdir = current->mm->pgd;
@@ -2885,12 +2891,15 @@
 			r = kvmppc_xics_rm_complete(vcpu, 0);
 	} while (is_kvmppc_resume_guest(r));
 
-	/* Restore userspace EBB register values */
+	/* Restore userspace EBB and other register values */
 	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
 		mtspr(SPRN_EBBHR, ebb_regs[0]);
 		mtspr(SPRN_EBBRR, ebb_regs[1]);
 		mtspr(SPRN_BESCR, ebb_regs[2]);
+		mtspr(SPRN_TAR, user_tar);
+		mtspr(SPRN_FSCR, current->thread.fscr);
 	}
+	mtspr(SPRN_VRSAVE, user_vrsave);
 
  out:
 	vcpu->arch.state = KVMPPC_VCPU_NOTREADY;
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 6f81adb..0447a22 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -37,6 +37,13 @@
 #define NAPPING_CEDE	1
 #define NAPPING_NOVCPU	2
 
+/* Stack frame offsets for kvmppc_hv_entry */
+#define SFS			112
+#define STACK_SLOT_TRAP		(SFS-4)
+#define STACK_SLOT_CIABR	(SFS-16)
+#define STACK_SLOT_DAWR		(SFS-24)
+#define STACK_SLOT_DAWRX	(SFS-32)
+
 /*
  * Call kvmppc_hv_entry in real mode.
  * Must be called with interrupts hard-disabled.
@@ -289,10 +296,10 @@
 	bl	kvmhv_accumulate_time
 #endif
 13:	mr	r3, r12
-	stw	r12, 112-4(r1)
+	stw	r12, STACK_SLOT_TRAP(r1)
 	bl	kvmhv_commence_exit
 	nop
-	lwz	r12, 112-4(r1)
+	lwz	r12, STACK_SLOT_TRAP(r1)
 	b	kvmhv_switch_to_host
 
 /*
@@ -537,7 +544,7 @@
 	 */
 	mflr	r0
 	std	r0, PPC_LR_STKOFF(r1)
-	stdu	r1, -112(r1)
+	stdu	r1, -SFS(r1)
 
 	/* Save R1 in the PACA */
 	std	r1, HSTATE_HOST_R1(r13)
@@ -698,6 +705,16 @@
 	mtspr	SPRN_PURR,r7
 	mtspr	SPRN_SPURR,r8
 
+	/* Save host values of some registers */
+BEGIN_FTR_SECTION
+	mfspr	r5, SPRN_CIABR
+	mfspr	r6, SPRN_DAWR
+	mfspr	r7, SPRN_DAWRX
+	std	r5, STACK_SLOT_CIABR(r1)
+	std	r6, STACK_SLOT_DAWR(r1)
+	std	r7, STACK_SLOT_DAWRX(r1)
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
+
 BEGIN_FTR_SECTION
 	/* Set partition DABR */
 	/* Do this before re-enabling PMU to avoid P7 DABR corruption bug */
@@ -1361,8 +1378,7 @@
 	 */
 	li	r0, 0
 	mtspr	SPRN_IAMR, r0
-	mtspr	SPRN_CIABR, r0
-	mtspr	SPRN_DAWRX, r0
+	mtspr	SPRN_PSPB, r0
 	mtspr	SPRN_TCSCR, r0
 	mtspr	SPRN_WORT, r0
 	/* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */
@@ -1378,6 +1394,7 @@
 	std	r6,VCPU_UAMOR(r9)
 	li	r6,0
 	mtspr	SPRN_AMR,r6
+	mtspr	SPRN_UAMOR, r6
 
 	/* Switch DSCR back to host value */
 	mfspr	r8, SPRN_DSCR
@@ -1519,6 +1536,16 @@
 	slbia
 	ptesync
 
+	/* Restore host values of some registers */
+BEGIN_FTR_SECTION
+	ld	r5, STACK_SLOT_CIABR(r1)
+	ld	r6, STACK_SLOT_DAWR(r1)
+	ld	r7, STACK_SLOT_DAWRX(r1)
+	mtspr	SPRN_CIABR, r5
+	mtspr	SPRN_DAWR, r6
+	mtspr	SPRN_DAWRX, r7
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
+
 	/*
 	 * POWER7/POWER8 guest -> host partition switch code.
 	 * We don't have to lock against tlbies but we do
@@ -1652,8 +1679,8 @@
 	li	r0, KVM_GUEST_MODE_NONE
 	stb	r0, HSTATE_IN_GUEST(r13)
 
-	ld	r0, 112+PPC_LR_STKOFF(r1)
-	addi	r1, r1, 112
+	ld	r0, SFS+PPC_LR_STKOFF(r1)
+	addi	r1, r1, SFS
 	mtlr	r0
 	blr
 
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index cc66c49..666ad06 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -82,7 +82,6 @@
 
 	of_detach_node(np);
 	of_node_put(parent);
-	of_node_put(np); /* Must decrement the refcount */
 	return 0;
 }
 
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 0cea702..d33f245 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -480,7 +480,7 @@
  * In the case that a guest uses storage keys
  * faults should no longer be backed by zero pages
  */
-#define mm_forbids_zeropage mm_use_skey
+#define mm_forbids_zeropage mm_has_pgste
 static inline int mm_use_skey(struct mm_struct *mm)
 {
 #ifdef CONFIG_PGSTE
diff --git a/arch/s390/kvm/sthyi.c b/arch/s390/kvm/sthyi.c
index 05c98bb..2f04ad1 100644
--- a/arch/s390/kvm/sthyi.c
+++ b/arch/s390/kvm/sthyi.c
@@ -394,7 +394,7 @@
 		"srl     %[cc],28\n"
 		: [cc] "=d" (cc)
 		: [code] "d" (code), [addr] "a" (addr)
-		: "memory", "cc");
+		: "3", "memory", "cc");
 	return cc;
 }
 
@@ -422,7 +422,7 @@
 	VCPU_EVENT(vcpu, 3, "STHYI: fc: %llu addr: 0x%016llx", code, addr);
 	trace_kvm_s390_handle_sthyi(vcpu, code, addr);
 
-	if (reg1 == reg2 || reg1 & 1 || reg2 & 1 || addr & ~PAGE_MASK)
+	if (reg1 == reg2 || reg1 & 1 || reg2 & 1)
 		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
 	if (code & 0xffff) {
@@ -430,6 +430,9 @@
 		goto out;
 	}
 
+	if (addr & ~PAGE_MASK)
+		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
+
 	/*
 	 * If the page has not yet been faulted in, we want to do that
 	 * now and not after all the expensive calculations.
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index 3ba6227..cb2cd04 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -2125,6 +2125,37 @@
 }
 
 /*
+ * Remove all empty zero pages from the mapping for lazy refaulting
+ * - This must be called after mm->context.has_pgste is set, to avoid
+ *   future creation of zero pages
+ * - This must be called after THP was enabled
+ */
+static int __zap_zero_pages(pmd_t *pmd, unsigned long start,
+			   unsigned long end, struct mm_walk *walk)
+{
+	unsigned long addr;
+
+	for (addr = start; addr != end; addr += PAGE_SIZE) {
+		pte_t *ptep;
+		spinlock_t *ptl;
+
+		ptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
+		if (is_zero_pfn(pte_pfn(*ptep)))
+			ptep_xchg_direct(walk->mm, addr, ptep, __pte(_PAGE_INVALID));
+		pte_unmap_unlock(ptep, ptl);
+	}
+	return 0;
+}
+
+static inline void zap_zero_pages(struct mm_struct *mm)
+{
+	struct mm_walk walk = { .pmd_entry = __zap_zero_pages };
+
+	walk.mm = mm;
+	walk_page_range(0, TASK_SIZE, &walk);
+}
+
+/*
  * switch on pgstes for its userspace process (for kvm)
  */
 int s390_enable_sie(void)
@@ -2141,6 +2172,7 @@
 	mm->context.has_pgste = 1;
 	/* split thp mappings and disable thp for future mappings */
 	thp_split_mm(mm);
+	zap_zero_pages(mm);
 	up_write(&mm->mmap_sem);
 	return 0;
 }
@@ -2153,13 +2185,6 @@
 static int __s390_enable_skey(pte_t *pte, unsigned long addr,
 			      unsigned long next, struct mm_walk *walk)
 {
-	/*
-	 * Remove all zero page mappings,
-	 * after establishing a policy to forbid zero page mappings
-	 * following faults for that page will get fresh anonymous pages
-	 */
-	if (is_zero_pfn(pte_pfn(*pte)))
-		ptep_xchg_direct(walk->mm, addr, pte, __pte(_PAGE_INVALID));
 	/* Clear storage key */
 	ptep_zap_key(walk->mm, addr, pte);
 	return 0;
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index bee281f..e8dee62 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -1252,7 +1252,8 @@
 		insn_count = bpf_jit_insn(jit, fp, i);
 		if (insn_count < 0)
 			return -1;
-		jit->addrs[i + 1] = jit->prg; /* Next instruction address */
+		/* Next instruction address */
+		jit->addrs[i + insn_count] = jit->prg;
 	}
 	bpf_jit_epilogue(jit);
 
diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h
index 349dd23..0cdeb2b 100644
--- a/arch/sparc/include/asm/mmu_context_64.h
+++ b/arch/sparc/include/asm/mmu_context_64.h
@@ -25,9 +25,11 @@
 void __tsb_context_switch(unsigned long pgd_pa,
 			  struct tsb_config *tsb_base,
 			  struct tsb_config *tsb_huge,
-			  unsigned long tsb_descr_pa);
+			  unsigned long tsb_descr_pa,
+			  unsigned long secondary_ctx);
 
-static inline void tsb_context_switch(struct mm_struct *mm)
+static inline void tsb_context_switch_ctx(struct mm_struct *mm,
+					  unsigned long ctx)
 {
 	__tsb_context_switch(__pa(mm->pgd),
 			     &mm->context.tsb_block[0],
@@ -38,9 +40,12 @@
 #else
 			     NULL
 #endif
-			     , __pa(&mm->context.tsb_descr[0]));
+			     , __pa(&mm->context.tsb_descr[0]),
+			     ctx);
 }
 
+#define tsb_context_switch(X) tsb_context_switch_ctx(X, 0)
+
 void tsb_grow(struct mm_struct *mm,
 	      unsigned long tsb_index,
 	      unsigned long mm_rss);
@@ -110,8 +115,7 @@
 	 * cpu0 to update it's TSB because at that point the cpu_vm_mask
 	 * only had cpu1 set in it.
 	 */
-	load_secondary_context(mm);
-	tsb_context_switch(mm);
+	tsb_context_switch_ctx(mm, CTX_HWBITS(mm->context));
 
 	/* Any time a processor runs a context on an address space
 	 * for the first time, we must flush that context out of the
diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h
index ec9c04d..ff05992 100644
--- a/arch/sparc/include/asm/trap_block.h
+++ b/arch/sparc/include/asm/trap_block.h
@@ -54,6 +54,7 @@
 void init_cur_cpu_trap(struct thread_info *);
 void setup_tba(void);
 extern int ncpus_probed;
+extern u64 cpu_mondo_counter[NR_CPUS];
 
 unsigned long real_hard_smp_processor_id(void);
 
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 06981cc..d04111a 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -1240,8 +1240,6 @@
 			 * ATU group, but ATU hcalls won't be available.
 			 */
 			hv_atu = false;
-			pr_err(PFX "Could not register hvapi ATU err=%d\n",
-			       err);
 		} else {
 			pr_info(PFX "Registered hvapi ATU major[%lu] minor[%lu]\n",
 				vatu_major, vatu_minor);
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index d5807d2..2deb89e 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -621,22 +621,48 @@
 	}
 }
 
-/* Multi-cpu list version.  */
+#define	CPU_MONDO_COUNTER(cpuid)	(cpu_mondo_counter[cpuid])
+#define	MONDO_USEC_WAIT_MIN		2
+#define	MONDO_USEC_WAIT_MAX		100
+#define	MONDO_RETRY_LIMIT		500000
+
+/* Multi-cpu list version.
+ *
+ * Deliver xcalls to 'cnt' number of cpus in 'cpu_list'.
+ * Sometimes not all cpus receive the mondo, requiring us to re-send
+ * the mondo until all cpus have received, or cpus are truly stuck
+ * unable to receive mondo, and we timeout.
+ * Occasionally a target cpu strand is borrowed briefly by hypervisor to
+ * perform guest service, such as PCIe error handling. Consider the
+ * service time, 1 second overall wait is reasonable for 1 cpu.
+ * Here two in-between mondo check wait time are defined: 2 usec for
+ * single cpu quick turn around and up to 100usec for large cpu count.
+ * Deliver mondo to large number of cpus could take longer, we adjusts
+ * the retry count as long as target cpus are making forward progress.
+ */
 static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt)
 {
-	int retries, this_cpu, prev_sent, i, saw_cpu_error;
+	int this_cpu, tot_cpus, prev_sent, i, rem;
+	int usec_wait, retries, tot_retries;
+	u16 first_cpu = 0xffff;
+	unsigned long xc_rcvd = 0;
 	unsigned long status;
+	int ecpuerror_id = 0;
+	int enocpu_id = 0;
 	u16 *cpu_list;
+	u16 cpu;
 
 	this_cpu = smp_processor_id();
-
 	cpu_list = __va(tb->cpu_list_pa);
-
-	saw_cpu_error = 0;
-	retries = 0;
+	usec_wait = cnt * MONDO_USEC_WAIT_MIN;
+	if (usec_wait > MONDO_USEC_WAIT_MAX)
+		usec_wait = MONDO_USEC_WAIT_MAX;
+	retries = tot_retries = 0;
+	tot_cpus = cnt;
 	prev_sent = 0;
+
 	do {
-		int forward_progress, n_sent;
+		int n_sent, mondo_delivered, target_cpu_busy;
 
 		status = sun4v_cpu_mondo_send(cnt,
 					      tb->cpu_list_pa,
@@ -644,94 +670,113 @@
 
 		/* HV_EOK means all cpus received the xcall, we're done.  */
 		if (likely(status == HV_EOK))
-			break;
+			goto xcall_done;
+
+		/* If not these non-fatal errors, panic */
+		if (unlikely((status != HV_EWOULDBLOCK) &&
+			(status != HV_ECPUERROR) &&
+			(status != HV_ENOCPU)))
+			goto fatal_errors;
 
 		/* First, see if we made any forward progress.
 		 *
+		 * Go through the cpu_list, count the target cpus that have
+		 * received our mondo (n_sent), and those that did not (rem).
+		 * Re-pack cpu_list with the cpus remain to be retried in the
+		 * front - this simplifies tracking the truly stalled cpus.
+		 *
 		 * The hypervisor indicates successful sends by setting
 		 * cpu list entries to the value 0xffff.
+		 *
+		 * EWOULDBLOCK means some target cpus did not receive the
+		 * mondo and retry usually helps.
+		 *
+		 * ECPUERROR means at least one target cpu is in error state,
+		 * it's usually safe to skip the faulty cpu and retry.
+		 *
+		 * ENOCPU means one of the target cpu doesn't belong to the
+		 * domain, perhaps offlined which is unexpected, but not
+		 * fatal and it's okay to skip the offlined cpu.
 		 */
+		rem = 0;
 		n_sent = 0;
 		for (i = 0; i < cnt; i++) {
-			if (likely(cpu_list[i] == 0xffff))
+			cpu = cpu_list[i];
+			if (likely(cpu == 0xffff)) {
 				n_sent++;
+			} else if ((status == HV_ECPUERROR) &&
+				(sun4v_cpu_state(cpu) == HV_CPU_STATE_ERROR)) {
+				ecpuerror_id = cpu + 1;
+			} else if (status == HV_ENOCPU && !cpu_online(cpu)) {
+				enocpu_id = cpu + 1;
+			} else {
+				cpu_list[rem++] = cpu;
+			}
 		}
 
-		forward_progress = 0;
-		if (n_sent > prev_sent)
-			forward_progress = 1;
+		/* No cpu remained, we're done. */
+		if (rem == 0)
+			break;
 
+		/* Otherwise, update the cpu count for retry. */
+		cnt = rem;
+
+		/* Record the overall number of mondos received by the
+		 * first of the remaining cpus.
+		 */
+		if (first_cpu != cpu_list[0]) {
+			first_cpu = cpu_list[0];
+			xc_rcvd = CPU_MONDO_COUNTER(first_cpu);
+		}
+
+		/* Was any mondo delivered successfully? */
+		mondo_delivered = (n_sent > prev_sent);
 		prev_sent = n_sent;
 
-		/* If we get a HV_ECPUERROR, then one or more of the cpus
-		 * in the list are in error state.  Use the cpu_state()
-		 * hypervisor call to find out which cpus are in error state.
+		/* or, was any target cpu busy processing other mondos? */
+		target_cpu_busy = (xc_rcvd < CPU_MONDO_COUNTER(first_cpu));
+		xc_rcvd = CPU_MONDO_COUNTER(first_cpu);
+
+		/* Retry count is for no progress. If we're making progress,
+		 * reset the retry count.
 		 */
-		if (unlikely(status == HV_ECPUERROR)) {
-			for (i = 0; i < cnt; i++) {
-				long err;
-				u16 cpu;
-
-				cpu = cpu_list[i];
-				if (cpu == 0xffff)
-					continue;
-
-				err = sun4v_cpu_state(cpu);
-				if (err == HV_CPU_STATE_ERROR) {
-					saw_cpu_error = (cpu + 1);
-					cpu_list[i] = 0xffff;
-				}
-			}
-		} else if (unlikely(status != HV_EWOULDBLOCK))
-			goto fatal_mondo_error;
-
-		/* Don't bother rewriting the CPU list, just leave the
-		 * 0xffff and non-0xffff entries in there and the
-		 * hypervisor will do the right thing.
-		 *
-		 * Only advance timeout state if we didn't make any
-		 * forward progress.
-		 */
-		if (unlikely(!forward_progress)) {
-			if (unlikely(++retries > 10000))
-				goto fatal_mondo_timeout;
-
-			/* Delay a little bit to let other cpus catch up
-			 * on their cpu mondo queue work.
-			 */
-			udelay(2 * cnt);
+		if (likely(mondo_delivered || target_cpu_busy)) {
+			tot_retries += retries;
+			retries = 0;
+		} else if (unlikely(retries > MONDO_RETRY_LIMIT)) {
+			goto fatal_mondo_timeout;
 		}
+
+		/* Delay a little bit to let other cpus catch up on
+		 * their cpu mondo queue work.
+		 */
+		if (!mondo_delivered)
+			udelay(usec_wait);
+
+		retries++;
 	} while (1);
 
-	if (unlikely(saw_cpu_error))
-		goto fatal_mondo_cpu_error;
-
+xcall_done:
+	if (unlikely(ecpuerror_id > 0)) {
+		pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) was in error state\n",
+		       this_cpu, ecpuerror_id - 1);
+	} else if (unlikely(enocpu_id > 0)) {
+		pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) does not belong to the domain\n",
+		       this_cpu, enocpu_id - 1);
+	}
 	return;
 
-fatal_mondo_cpu_error:
-	printk(KERN_CRIT "CPU[%d]: SUN4V mondo cpu error, some target cpus "
-	       "(including %d) were in error state\n",
-	       this_cpu, saw_cpu_error - 1);
-	return;
+fatal_errors:
+	/* fatal errors include bad alignment, etc */
+	pr_crit("CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) mondo_block_pa(%lx)\n",
+	       this_cpu, tot_cpus, tb->cpu_list_pa, tb->cpu_mondo_block_pa);
+	panic("Unexpected SUN4V mondo error %lu\n", status);
 
 fatal_mondo_timeout:
-	printk(KERN_CRIT "CPU[%d]: SUN4V mondo timeout, no forward "
-	       " progress after %d retries.\n",
-	       this_cpu, retries);
-	goto dump_cpu_list_and_out;
-
-fatal_mondo_error:
-	printk(KERN_CRIT "CPU[%d]: Unexpected SUN4V mondo error %lu\n",
-	       this_cpu, status);
-	printk(KERN_CRIT "CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) "
-	       "mondo_block_pa(%lx)\n",
-	       this_cpu, cnt, tb->cpu_list_pa, tb->cpu_mondo_block_pa);
-
-dump_cpu_list_and_out:
-	printk(KERN_CRIT "CPU[%d]: CPU list [ ", this_cpu);
-	for (i = 0; i < cnt; i++)
-		printk("%u ", cpu_list[i]);
-	printk("]\n");
+	/* some cpus being non-responsive to the cpu mondo */
+	pr_crit("CPU[%d]: SUN4V mondo timeout, cpu(%d) made no forward progress after %d retries. Total target cpus(%d).\n",
+	       this_cpu, first_cpu, (tot_retries + retries), tot_cpus);
+	panic("SUN4V mondo timeout panic\n");
 }
 
 static void (*xcall_deliver_impl)(struct trap_per_cpu *, int);
diff --git a/arch/sparc/kernel/sun4v_ivec.S b/arch/sparc/kernel/sun4v_ivec.S
index 559bc5e..3463199 100644
--- a/arch/sparc/kernel/sun4v_ivec.S
+++ b/arch/sparc/kernel/sun4v_ivec.S
@@ -26,6 +26,21 @@
 	ldxa	[%g0] ASI_SCRATCHPAD, %g4
 	sub	%g4, TRAP_PER_CPU_FAULT_INFO, %g4
 
+	/* Get smp_processor_id() into %g3 */
+	sethi	%hi(trap_block), %g5
+	or	%g5, %lo(trap_block), %g5
+	sub	%g4, %g5, %g3
+	srlx	%g3, TRAP_BLOCK_SZ_SHIFT, %g3
+
+	/* Increment cpu_mondo_counter[smp_processor_id()] */
+	sethi	%hi(cpu_mondo_counter), %g5
+	or	%g5, %lo(cpu_mondo_counter), %g5
+	sllx	%g3, 3, %g3
+	add	%g5, %g3, %g5
+	ldx	[%g5], %g3
+	add	%g3, 1, %g3
+	stx	%g3, [%g5]
+
 	/* Get CPU mondo queue base phys address into %g7.  */
 	ldx	[%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
 
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index d44fb80..32dafb92 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -2732,6 +2732,7 @@
 	}
 }
 
+u64 cpu_mondo_counter[NR_CPUS] = {0};
 struct trap_per_cpu trap_block[NR_CPUS];
 EXPORT_SYMBOL(trap_block);
 
diff --git a/arch/sparc/kernel/tsb.S b/arch/sparc/kernel/tsb.S
index 395ec18..7d961f6 100644
--- a/arch/sparc/kernel/tsb.S
+++ b/arch/sparc/kernel/tsb.S
@@ -375,6 +375,7 @@
 	 * %o1:	TSB base config pointer
 	 * %o2:	TSB huge config pointer, or NULL if none
 	 * %o3:	Hypervisor TSB descriptor physical address
+	 * %o4: Secondary context to load, if non-zero
 	 *
 	 * We have to run this whole thing with interrupts
 	 * disabled so that the current cpu doesn't change
@@ -387,6 +388,17 @@
 	rdpr	%pstate, %g1
 	wrpr	%g1, PSTATE_IE, %pstate
 
+	brz,pn	%o4, 1f
+	 mov	SECONDARY_CONTEXT, %o5
+
+661:	stxa	%o4, [%o5] ASI_DMMU
+	.section .sun4v_1insn_patch, "ax"
+	.word	661b
+	stxa	%o4, [%o5] ASI_MMU
+	.previous
+	flush	%g6
+
+1:
 	TRAP_LOAD_TRAP_BLOCK(%g2, %g3)
 
 	stx	%o0, [%g2 + TRAP_PER_CPU_PGD_PADDR]
diff --git a/arch/sparc/lib/U3memcpy.S b/arch/sparc/lib/U3memcpy.S
index 54f9870..5a8cb37 100644
--- a/arch/sparc/lib/U3memcpy.S
+++ b/arch/sparc/lib/U3memcpy.S
@@ -145,13 +145,13 @@
 ENTRY(U3_retl_o2_and_7_plus_GS)
 	and	%o2, 7, %o2
 	retl
-	 add	%o2, GLOBAL_SPARE, %o2
+	 add	%o2, GLOBAL_SPARE, %o0
 ENDPROC(U3_retl_o2_and_7_plus_GS)
 ENTRY(U3_retl_o2_and_7_plus_GS_plus_8)
 	add	GLOBAL_SPARE, 8, GLOBAL_SPARE
 	and	%o2, 7, %o2
 	retl
-	 add	%o2, GLOBAL_SPARE, %o2
+	 add	%o2, GLOBAL_SPARE, %o0
 ENDPROC(U3_retl_o2_and_7_plus_GS_plus_8)
 #endif
 
diff --git a/arch/sparc/power/hibernate.c b/arch/sparc/power/hibernate.c
index 17bd2e1..df707a8 100644
--- a/arch/sparc/power/hibernate.c
+++ b/arch/sparc/power/hibernate.c
@@ -35,6 +35,5 @@
 {
 	struct mm_struct *mm = current->active_mm;
 
-	load_secondary_context(mm);
-	tsb_context_switch(mm);
+	tsb_context_switch_ctx(mm, CTX_HWBITS(mm->context));
 }
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index cc3bd58..9e240fc 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -14,6 +14,7 @@
 
 #include <linux/types.h>
 #include "ctype.h"
+#include "string.h"
 
 int memcmp(const void *s1, const void *s2, size_t len)
 {
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h
index 725e820..113588d 100644
--- a/arch/x86/boot/string.h
+++ b/arch/x86/boot/string.h
@@ -18,4 +18,13 @@
 #define memset(d,c,l) __builtin_memset(d,c,l)
 #define memcmp	__builtin_memcmp
 
+extern int strcmp(const char *str1, const char *str2);
+extern int strncmp(const char *cs, const char *ct, size_t count);
+extern size_t strlen(const char *s);
+extern char *strstr(const char *s1, const char *s2);
+extern size_t strnlen(const char *s, size_t maxlen);
+extern unsigned int atou(const char *s);
+extern unsigned long long simple_strtoull(const char *cp, char **endp,
+					  unsigned int base);
+
 #endif /* BOOT_STRING_H */
diff --git a/arch/x86/crypto/sha1_avx2_x86_64_asm.S b/arch/x86/crypto/sha1_avx2_x86_64_asm.S
index 1cd792d..1eab79c 100644
--- a/arch/x86/crypto/sha1_avx2_x86_64_asm.S
+++ b/arch/x86/crypto/sha1_avx2_x86_64_asm.S
@@ -117,11 +117,10 @@
 	.set T1, REG_T1
 .endm
 
-#define K_BASE		%r8
 #define HASH_PTR	%r9
+#define BLOCKS_CTR	%r8
 #define BUFFER_PTR	%r10
 #define BUFFER_PTR2	%r13
-#define BUFFER_END	%r11
 
 #define PRECALC_BUF	%r14
 #define WK_BUF		%r15
@@ -205,14 +204,14 @@
 		 * blended AVX2 and ALU instruction scheduling
 		 * 1 vector iteration per 8 rounds
 		 */
-		vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP
+		vmovdqu (i * 2)(BUFFER_PTR), W_TMP
 	.elseif ((i & 7) == 1)
-		vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\
+		vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\
 			 WY_TMP, WY_TMP
 	.elseif ((i & 7) == 2)
 		vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY
 	.elseif ((i & 7) == 4)
-		vpaddd  K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 	.elseif ((i & 7) == 7)
 		vmovdqu  WY_TMP, PRECALC_WK(i&~7)
 
@@ -255,7 +254,7 @@
 		vpxor	WY, WY_TMP, WY_TMP
 	.elseif ((i & 7) == 7)
 		vpxor	WY_TMP2, WY_TMP, WY
-		vpaddd	K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 		vmovdqu	WY_TMP, PRECALC_WK(i&~7)
 
 		PRECALC_ROTATE_WY
@@ -291,7 +290,7 @@
 		vpsrld	$30, WY, WY
 		vpor	WY, WY_TMP, WY
 	.elseif ((i & 7) == 7)
-		vpaddd	K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 		vmovdqu	WY_TMP, PRECALC_WK(i&~7)
 
 		PRECALC_ROTATE_WY
@@ -446,6 +445,16 @@
 
 .endm
 
+/* Add constant only if (%2 > %3) condition met (uses RTA as temp)
+ * %1 + %2 >= %3 ? %4 : 0
+ */
+.macro ADD_IF_GE a, b, c, d
+	mov     \a, RTA
+	add     $\d, RTA
+	cmp     $\c, \b
+	cmovge  RTA, \a
+.endm
+
 /*
  * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining
  */
@@ -463,13 +472,16 @@
 	lea	(2*4*80+32)(%rsp), WK_BUF
 
 	# Precalc WK for first 2 blocks
-	PRECALC_OFFSET = 0
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64
 	.set i, 0
 	.rept    160
 		PRECALC i
 		.set i, i + 1
 	.endr
-	PRECALC_OFFSET = 128
+
+	/* Go to next block if needed */
+	ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 	xchg	WK_BUF, PRECALC_BUF
 
 	.align 32
@@ -479,8 +491,8 @@
 	 * we use K_BASE value as a signal of a last block,
 	 * it is set below by: cmovae BUFFER_PTR, K_BASE
 	 */
-	cmp	K_BASE, BUFFER_PTR
-	jne	_begin
+	test BLOCKS_CTR, BLOCKS_CTR
+	jnz _begin
 	.align 32
 	jmp	_end
 	.align 32
@@ -512,10 +524,10 @@
 		.set j, j+2
 	.endr
 
-	add	$(2*64), BUFFER_PTR       /* move to next odd-64-byte block */
-	cmp	BUFFER_END, BUFFER_PTR    /* is current block the last one? */
-	cmovae	K_BASE, BUFFER_PTR	/* signal the last iteration smartly */
-
+	/* Update Counter */
+	sub $1, BLOCKS_CTR
+	/* Move to the next block only if needed*/
+	ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128
 	/*
 	 * rounds
 	 * 60,62,64,66,68
@@ -532,8 +544,8 @@
 	UPDATE_HASH	12(HASH_PTR), D
 	UPDATE_HASH	16(HASH_PTR), E
 
-	cmp	K_BASE, BUFFER_PTR	/* is current block the last one? */
-	je	_loop
+	test	BLOCKS_CTR, BLOCKS_CTR
+	jz	_loop
 
 	mov	TB, B
 
@@ -575,10 +587,10 @@
 		.set j, j+2
 	.endr
 
-	add	$(2*64), BUFFER_PTR2      /* move to next even-64-byte block */
-
-	cmp	BUFFER_END, BUFFER_PTR2   /* is current block the last one */
-	cmovae	K_BASE, BUFFER_PTR       /* signal the last iteration smartly */
+	/* update counter */
+	sub     $1, BLOCKS_CTR
+	/* Move to the next block only if needed*/
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 
 	jmp	_loop3
 _loop3:
@@ -641,19 +653,12 @@
 
 	avx2_zeroupper
 
-	lea	K_XMM_AR(%rip), K_BASE
-
+	/* Setup initial values */
 	mov	CTX, HASH_PTR
 	mov	BUF, BUFFER_PTR
-	lea	64(BUF), BUFFER_PTR2
 
-	shl	$6, CNT			/* mul by 64 */
-	add	BUF, CNT
-	add	$64, CNT
-	mov	CNT, BUFFER_END
-
-	cmp	BUFFER_END, BUFFER_PTR2
-	cmovae	K_BASE, BUFFER_PTR2
+	mov	BUF, BUFFER_PTR2
+	mov	CNT, BLOCKS_CTR
 
 	xmm_mov	BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP
 
diff --git a/arch/x86/crypto/sha1_ssse3_glue.c b/arch/x86/crypto/sha1_ssse3_glue.c
index f960a04..fc61739 100644
--- a/arch/x86/crypto/sha1_ssse3_glue.c
+++ b/arch/x86/crypto/sha1_ssse3_glue.c
@@ -201,7 +201,7 @@
 
 static bool avx2_usable(void)
 {
-	if (false && avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
+	if (avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
 		&& boot_cpu_has(X86_FEATURE_BMI1)
 		&& boot_cpu_has(X86_FEATURE_BMI2))
 		return true;
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index ef766a3..e7b0e7f 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1215,6 +1215,8 @@
 	 * other IST entries.
 	 */
 
+	ASM_CLAC
+
 	/* Use %rdx as our temp variable throughout */
 	pushq	%rdx
 
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index fec8a46..1076c9a 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -434,6 +434,7 @@
 	.stop		= cstate_pmu_event_stop,
 	.read		= cstate_pmu_event_update,
 	.capabilities	= PERF_PMU_CAP_NO_INTERRUPT,
+	.module		= THIS_MODULE,
 };
 
 static struct pmu cstate_pkg_pmu = {
@@ -447,6 +448,7 @@
 	.stop		= cstate_pmu_event_stop,
 	.read		= cstate_pmu_event_update,
 	.capabilities	= PERF_PMU_CAP_NO_INTERRUPT,
+	.module		= THIS_MODULE,
 };
 
 static const struct cstate_model nhm_cstates __initconst = {
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index 8b902b6..4c1b7ea 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -161,7 +161,13 @@
 
 static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu)
 {
-	return rapl_pmus->pmus[topology_logical_package_id(cpu)];
+	unsigned int pkgid = topology_logical_package_id(cpu);
+
+	/*
+	 * The unsigned check also catches the '-1' return value for non
+	 * existent mappings in the topology map.
+	 */
+	return pkgid < rapl_pmus->maxpkg ? rapl_pmus->pmus[pkgid] : NULL;
 }
 
 static inline u64 rapl_read_counter(struct perf_event *event)
@@ -402,6 +408,8 @@
 
 	/* must be done before validate_group */
 	pmu = cpu_to_rapl_pmu(event->cpu);
+	if (!pmu)
+		return -EINVAL;
 	event->cpu = pmu->cpu;
 	event->pmu_private = pmu;
 	event->hw.event_base = msr;
@@ -585,6 +593,19 @@
 	struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu);
 	int target;
 
+	if (!pmu) {
+		pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
+		if (!pmu)
+			return -ENOMEM;
+
+		raw_spin_lock_init(&pmu->lock);
+		INIT_LIST_HEAD(&pmu->active_list);
+		pmu->pmu = &rapl_pmus->pmu;
+		pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
+		rapl_hrtimer_init(pmu);
+
+		rapl_pmus->pmus[topology_logical_package_id(cpu)] = pmu;
+	}
 	/*
 	 * Check if there is an online cpu in the package which collects rapl
 	 * events already.
@@ -598,27 +619,6 @@
 	return 0;
 }
 
-static int rapl_cpu_prepare(unsigned int cpu)
-{
-	struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu);
-
-	if (pmu)
-		return 0;
-
-	pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
-	if (!pmu)
-		return -ENOMEM;
-
-	raw_spin_lock_init(&pmu->lock);
-	INIT_LIST_HEAD(&pmu->active_list);
-	pmu->pmu = &rapl_pmus->pmu;
-	pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
-	pmu->cpu = -1;
-	rapl_hrtimer_init(pmu);
-	rapl_pmus->pmus[topology_logical_package_id(cpu)] = pmu;
-	return 0;
-}
-
 static int rapl_check_hw_unit(bool apply_quirk)
 {
 	u64 msr_rapl_power_unit_bits;
@@ -697,6 +697,7 @@
 	rapl_pmus->pmu.start		= rapl_pmu_event_start;
 	rapl_pmus->pmu.stop		= rapl_pmu_event_stop;
 	rapl_pmus->pmu.read		= rapl_pmu_event_read;
+	rapl_pmus->pmu.module		= THIS_MODULE;
 	return 0;
 }
 
@@ -803,28 +804,21 @@
 	 * Install callbacks. Core will call them for each online cpu.
 	 */
 
-	ret = cpuhp_setup_state(CPUHP_PERF_X86_RAPL_PREP, "PERF_X86_RAPL_PREP",
-				rapl_cpu_prepare, NULL);
-	if (ret)
-		goto out;
-
 	ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_RAPL_ONLINE,
 				"AP_PERF_X86_RAPL_ONLINE",
 				rapl_cpu_online, rapl_cpu_offline);
 	if (ret)
-		goto out1;
+		goto out;
 
 	ret = perf_pmu_register(&rapl_pmus->pmu, "power", -1);
 	if (ret)
-		goto out2;
+		goto out1;
 
 	rapl_advertise();
 	return 0;
 
-out2:
-	cpuhp_remove_state(CPUHP_AP_PERF_X86_RAPL_ONLINE);
 out1:
-	cpuhp_remove_state(CPUHP_PERF_X86_RAPL_PREP);
+	cpuhp_remove_state(CPUHP_AP_PERF_X86_RAPL_ONLINE);
 out:
 	pr_warn("Initialization failed (%d), disabled\n", ret);
 	cleanup_rapl_pmus();
@@ -835,7 +829,6 @@
 static void __exit intel_rapl_exit(void)
 {
 	cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_RAPL_ONLINE);
-	cpuhp_remove_state_nocalls(CPUHP_PERF_X86_RAPL_PREP);
 	perf_pmu_unregister(&rapl_pmus->pmu);
 	cleanup_rapl_pmus();
 }
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 19d646a..aec6cc9 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -733,6 +733,7 @@
 			.start		= uncore_pmu_event_start,
 			.stop		= uncore_pmu_event_stop,
 			.read		= uncore_pmu_event_read,
+			.module		= THIS_MODULE,
 		};
 	} else {
 		pmu->pmu = *pmu->type->pmu;
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index c152db2..7bcd138 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -204,6 +204,7 @@
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)			\
 do {								\
+	unsigned long base;					\
 	unsigned v;						\
 	(pr_reg)[0] = (regs)->r15;				\
 	(pr_reg)[1] = (regs)->r14;				\
@@ -226,8 +227,8 @@
 	(pr_reg)[18] = (regs)->flags;				\
 	(pr_reg)[19] = (regs)->sp;				\
 	(pr_reg)[20] = (regs)->ss;				\
-	(pr_reg)[21] = current->thread.fsbase;			\
-	(pr_reg)[22] = current->thread.gsbase;			\
+	rdmsrl(MSR_FS_BASE, base); (pr_reg)[21] = base;		\
+	rdmsrl(MSR_KERNEL_GS_BASE, base); (pr_reg)[22] = base;	\
 	asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v;	\
 	asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v;	\
 	asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v;	\
@@ -247,11 +248,11 @@
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
 #define ELF_ET_DYN_BASE		(mmap_is_ia32() ? 0x000400000UL : \
-						  0x100000000UL)
+						  (TASK_SIZE / 3 * 2))
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports.  This could be done in user space,
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index d34bd37..6c50201 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -304,13 +304,13 @@
 static inline void outs##bwl(int port, const void *addr, unsigned long count) \
 {									\
 	asm volatile("rep; outs" #bwl					\
-		     : "+S"(addr), "+c"(count) : "d"(port));		\
+		     : "+S"(addr), "+c"(count) : "d"(port) : "memory");	\
 }									\
 									\
 static inline void ins##bwl(int port, void *addr, unsigned long count)	\
 {									\
 	asm volatile("rep; ins" #bwl					\
-		     : "+D"(addr), "+c"(count) : "d"(port));		\
+		     : "+D"(addr), "+c"(count) : "d"(port) : "memory");	\
 }
 
 BUILDIO(b, b, char)
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 8e0a9fe..f9dd224 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -116,9 +116,7 @@
 		mm->context.execute_only_pkey = -1;
 	}
 	#endif
-	init_new_context_ldt(tsk, mm);
-
-	return 0;
+	return init_new_context_ldt(tsk, mm);
 }
 static inline void destroy_context(struct mm_struct *mm)
 {
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 3dfca7b..a5b47c1 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -955,6 +955,9 @@
 	const char *name = get_name(bank, NULL);
 	int err = 0;
 
+	if (!dev)
+		return -ENODEV;
+
 	if (is_shared_bank(bank)) {
 		nb = node_to_amd_nb(amd_get_nb_id(cpu));
 
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 9cf697c..55ffd9d 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -152,6 +152,8 @@
 		if (hlist_unhashed(&n.link))
 			break;
 
+		rcu_irq_exit();
+
 		if (!n.halted) {
 			local_irq_enable();
 			schedule();
@@ -160,11 +162,11 @@
 			/*
 			 * We cannot reschedule. So halt.
 			 */
-			rcu_irq_exit();
 			native_safe_halt();
 			local_irq_disable();
-			rcu_irq_enter();
 		}
+
+		rcu_irq_enter();
 	}
 	if (!n.halted)
 		finish_swait(&n.wq, &wait);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b3760b3..0887d2a 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -136,6 +136,123 @@
 	}
 }
 
+enum which_selector {
+	FS,
+	GS
+};
+
+/*
+ * Saves the FS or GS base for an outgoing thread if FSGSBASE extensions are
+ * not available.  The goal is to be reasonably fast on non-FSGSBASE systems.
+ * It's forcibly inlined because it'll generate better code and this function
+ * is hot.
+ */
+static __always_inline void save_base_legacy(struct task_struct *prev_p,
+					     unsigned short selector,
+					     enum which_selector which)
+{
+	if (likely(selector == 0)) {
+		/*
+		 * On Intel (without X86_BUG_NULL_SEG), the segment base could
+		 * be the pre-existing saved base or it could be zero.  On AMD
+		 * (with X86_BUG_NULL_SEG), the segment base could be almost
+		 * anything.
+		 *
+		 * This branch is very hot (it's hit twice on almost every
+		 * context switch between 64-bit programs), and avoiding
+		 * the RDMSR helps a lot, so we just assume that whatever
+		 * value is already saved is correct.  This matches historical
+		 * Linux behavior, so it won't break existing applications.
+		 *
+		 * To avoid leaking state, on non-X86_BUG_NULL_SEG CPUs, if we
+		 * report that the base is zero, it needs to actually be zero:
+		 * see the corresponding logic in load_seg_legacy.
+		 */
+	} else {
+		/*
+		 * If the selector is 1, 2, or 3, then the base is zero on
+		 * !X86_BUG_NULL_SEG CPUs and could be anything on
+		 * X86_BUG_NULL_SEG CPUs.  In the latter case, Linux
+		 * has never attempted to preserve the base across context
+		 * switches.
+		 *
+		 * If selector > 3, then it refers to a real segment, and
+		 * saving the base isn't necessary.
+		 */
+		if (which == FS)
+			prev_p->thread.fsbase = 0;
+		else
+			prev_p->thread.gsbase = 0;
+	}
+}
+
+static __always_inline void save_fsgs(struct task_struct *task)
+{
+	savesegment(fs, task->thread.fsindex);
+	savesegment(gs, task->thread.gsindex);
+	save_base_legacy(task, task->thread.fsindex, FS);
+	save_base_legacy(task, task->thread.gsindex, GS);
+}
+
+static __always_inline void loadseg(enum which_selector which,
+				    unsigned short sel)
+{
+	if (which == FS)
+		loadsegment(fs, sel);
+	else
+		load_gs_index(sel);
+}
+
+static __always_inline void load_seg_legacy(unsigned short prev_index,
+					    unsigned long prev_base,
+					    unsigned short next_index,
+					    unsigned long next_base,
+					    enum which_selector which)
+{
+	if (likely(next_index <= 3)) {
+		/*
+		 * The next task is using 64-bit TLS, is not using this
+		 * segment at all, or is having fun with arcane CPU features.
+		 */
+		if (next_base == 0) {
+			/*
+			 * Nasty case: on AMD CPUs, we need to forcibly zero
+			 * the base.
+			 */
+			if (static_cpu_has_bug(X86_BUG_NULL_SEG)) {
+				loadseg(which, __USER_DS);
+				loadseg(which, next_index);
+			} else {
+				/*
+				 * We could try to exhaustively detect cases
+				 * under which we can skip the segment load,
+				 * but there's really only one case that matters
+				 * for performance: if both the previous and
+				 * next states are fully zeroed, we can skip
+				 * the load.
+				 *
+				 * (This assumes that prev_base == 0 has no
+				 * false positives.  This is the case on
+				 * Intel-style CPUs.)
+				 */
+				if (likely(prev_index | next_index | prev_base))
+					loadseg(which, next_index);
+			}
+		} else {
+			if (prev_index != next_index)
+				loadseg(which, next_index);
+			wrmsrl(which == FS ? MSR_FS_BASE : MSR_KERNEL_GS_BASE,
+			       next_base);
+		}
+	} else {
+		/*
+		 * The next task is using a real segment.  Loading the selector
+		 * is sufficient.
+		 */
+		loadseg(which, next_index);
+	}
+}
+
 int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
 		unsigned long arg, struct task_struct *p, unsigned long tls)
 {
@@ -216,10 +333,19 @@
 		    unsigned long new_sp,
 		    unsigned int _cs, unsigned int _ss, unsigned int _ds)
 {
+	WARN_ON_ONCE(regs != current_pt_regs());
+
+	if (static_cpu_has(X86_BUG_NULL_SEG)) {
+		/* Loading zero below won't clear the base. */
+		loadsegment(fs, __USER_DS);
+		load_gs_index(__USER_DS);
+	}
+
 	loadsegment(fs, 0);
 	loadsegment(es, _ds);
 	loadsegment(ds, _ds);
 	load_gs_index(0);
+
 	regs->ip		= new_ip;
 	regs->sp		= new_sp;
 	regs->cs		= _cs;
@@ -264,7 +390,6 @@
 	struct fpu *next_fpu = &next->fpu;
 	int cpu = smp_processor_id();
 	struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
-	unsigned prev_fsindex, prev_gsindex;
 	fpu_switch_t fpu_switch;
 
 	fpu_switch = switch_fpu_prepare(prev_fpu, next_fpu, cpu);
@@ -274,8 +399,7 @@
 	 *
 	 * (e.g. xen_load_tls())
 	 */
-	savesegment(fs, prev_fsindex);
-	savesegment(gs, prev_gsindex);
+	save_fsgs(prev_p);
 
 	/*
 	 * Load TLS before restoring any segments so that segment loads
@@ -314,108 +438,10 @@
 	if (unlikely(next->ds | prev->ds))
 		loadsegment(ds, next->ds);
 
-	/*
-	 * Switch FS and GS.
-	 *
-	 * These are even more complicated than DS and ES: they have
-	 * 64-bit bases are that controlled by arch_prctl.  The bases
-	 * don't necessarily match the selectors, as user code can do
-	 * any number of things to cause them to be inconsistent.
-	 *
-	 * We don't promise to preserve the bases if the selectors are
-	 * nonzero.  We also don't promise to preserve the base if the
-	 * selector is zero and the base doesn't match whatever was
-	 * most recently passed to ARCH_SET_FS/GS.  (If/when the
-	 * FSGSBASE instructions are enabled, we'll need to offer
-	 * stronger guarantees.)
-	 *
-	 * As an invariant,
-	 * (fsbase != 0 && fsindex != 0) || (gsbase != 0 && gsindex != 0) is
-	 * impossible.
-	 */
-	if (next->fsindex) {
-		/* Loading a nonzero value into FS sets the index and base. */
-		loadsegment(fs, next->fsindex);
-	} else {
-		if (next->fsbase) {
-			/* Next index is zero but next base is nonzero. */
-			if (prev_fsindex)
-				loadsegment(fs, 0);
-			wrmsrl(MSR_FS_BASE, next->fsbase);
-		} else {
-			/* Next base and index are both zero. */
-			if (static_cpu_has_bug(X86_BUG_NULL_SEG)) {
-				/*
-				 * We don't know the previous base and can't
-				 * find out without RDMSR.  Forcibly clear it.
-				 */
-				loadsegment(fs, __USER_DS);
-				loadsegment(fs, 0);
-			} else {
-				/*
-				 * If the previous index is zero and ARCH_SET_FS
-				 * didn't change the base, then the base is
-				 * also zero and we don't need to do anything.
-				 */
-				if (prev->fsbase || prev_fsindex)
-					loadsegment(fs, 0);
-			}
-		}
-	}
-	/*
-	 * Save the old state and preserve the invariant.
-	 * NB: if prev_fsindex == 0, then we can't reliably learn the base
-	 * without RDMSR because Intel user code can zero it without telling
-	 * us and AMD user code can program any 32-bit value without telling
-	 * us.
-	 */
-	if (prev_fsindex)
-		prev->fsbase = 0;
-	prev->fsindex = prev_fsindex;
-
-	if (next->gsindex) {
-		/* Loading a nonzero value into GS sets the index and base. */
-		load_gs_index(next->gsindex);
-	} else {
-		if (next->gsbase) {
-			/* Next index is zero but next base is nonzero. */
-			if (prev_gsindex)
-				load_gs_index(0);
-			wrmsrl(MSR_KERNEL_GS_BASE, next->gsbase);
-		} else {
-			/* Next base and index are both zero. */
-			if (static_cpu_has_bug(X86_BUG_NULL_SEG)) {
-				/*
-				 * We don't know the previous base and can't
-				 * find out without RDMSR.  Forcibly clear it.
-				 *
-				 * This contains a pointless SWAPGS pair.
-				 * Fixing it would involve an explicit check
-				 * for Xen or a new pvop.
-				 */
-				load_gs_index(__USER_DS);
-				load_gs_index(0);
-			} else {
-				/*
-				 * If the previous index is zero and ARCH_SET_GS
-				 * didn't change the base, then the base is
-				 * also zero and we don't need to do anything.
-				 */
-				if (prev->gsbase || prev_gsindex)
-					load_gs_index(0);
-			}
-		}
-	}
-	/*
-	 * Save the old state and preserve the invariant.
-	 * NB: if prev_gsindex == 0, then we can't reliably learn the base
-	 * without RDMSR because Intel user code can zero it without telling
-	 * us and AMD user code can program any 32-bit value without telling
-	 * us.
-	 */
-	if (prev_gsindex)
-		prev->gsbase = 0;
-	prev->gsindex = prev_gsindex;
+	load_seg_legacy(prev->fsindex, prev->fsbase,
+			next->fsindex, next->fsbase, FS);
+	load_seg_legacy(prev->gsindex, prev->gsbase,
+			next->gsindex, next->gsbase, GS);
 
 	switch_fpu_finish(next_fpu, fpu_switch);
 
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 649d8f2..91af75e 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -456,7 +456,7 @@
 			entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
 			cpuid_mask(&entry->ecx, CPUID_7_ECX);
 			/* PKU is not yet implemented for shadow paging. */
-			if (!tdp_enabled)
+			if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
 				entry->ecx &= ~F(PKU);
 		} else {
 			entry->ebx = 0;
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index dd6cfa4..75029d0 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -15,7 +15,7 @@
 obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o
 obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o
 # SPI Devices
-obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_spidev.o
+obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_mrfld_spidev.o
 # I2C Devices
 obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o
 obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
similarity index 91%
rename from arch/x86/platform/intel-mid/device_libs/platform_spidev.c
rename to arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
index 30c601b..27186ad 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
@@ -11,6 +11,7 @@
  * of the License.
  */
 
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/sfi.h>
 #include <linux/spi/pxa2xx_spi.h>
@@ -34,6 +35,9 @@
 {
 	struct spi_board_info *spi_info = info;
 
+	if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
+		return ERR_PTR(-ENODEV);
+
 	spi_info->mode = SPI_MODE_0;
 	spi_info->controller_data = &spidev_spi_chip;
 
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 4d2872f..a71d273 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -94,13 +94,11 @@
 }
 EXPORT_SYMBOL(__sync_fetch_and_or_4);
 
-#ifdef CONFIG_NET
 /*
  * Networking support
  */
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(csum_partial_copy_generic);
-#endif /* CONFIG_NET */
 
 /*
  * Architecture-specific symbols
diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c
index 1a804a2..3c75c4e 100644
--- a/arch/xtensa/mm/cache.c
+++ b/arch/xtensa/mm/cache.c
@@ -103,6 +103,7 @@
 	clear_page_alias(kvaddr, paddr);
 	preempt_enable();
 }
+EXPORT_SYMBOL(clear_user_highpage);
 
 void copy_user_highpage(struct page *dst, struct page *src,
 			unsigned long vaddr, struct vm_area_struct *vma)
@@ -119,10 +120,7 @@
 	copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr);
 	preempt_enable();
 }
-
-#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
-
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+EXPORT_SYMBOL(copy_user_highpage);
 
 /*
  * Any time the kernel writes to a user page cache page, or it is about to
@@ -176,7 +174,7 @@
 
 	/* There shouldn't be an entry in the cache for this page anymore. */
 }
-
+EXPORT_SYMBOL(flush_dcache_page);
 
 /*
  * For now, flush the whole cache. FIXME??
@@ -188,6 +186,7 @@
 	__flush_invalidate_dcache_all();
 	__invalidate_icache_all();
 }
+EXPORT_SYMBOL(local_flush_cache_range);
 
 /* 
  * Remove any entry in the cache for this page. 
@@ -207,8 +206,9 @@
 	__flush_invalidate_dcache_page_alias(virt, phys);
 	__invalidate_icache_page_alias(virt, phys);
 }
+EXPORT_SYMBOL(local_flush_cache_page);
 
-#endif
+#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
 
 void
 update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
@@ -225,7 +225,7 @@
 
 	flush_tlb_page(vma, addr);
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 	if (!PageReserved(page) && test_bit(PG_arch_1, &page->flags)) {
 		unsigned long phys = page_to_phys(page);
@@ -256,7 +256,7 @@
  * flush_dcache_page() on the page.
  */
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
 		unsigned long vaddr, void *dst, const void *src,
diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c
index 966c216..ee9d3d9 100644
--- a/block/blk-mq-pci.c
+++ b/block/blk-mq-pci.c
@@ -36,12 +36,18 @@
 	for (queue = 0; queue < set->nr_hw_queues; queue++) {
 		mask = pci_irq_get_affinity(pdev, queue);
 		if (!mask)
-			return -EINVAL;
+			goto fallback;
 
 		for_each_cpu(cpu, mask)
 			set->mq_map[cpu] = queue;
 	}
 
 	return 0;
+
+fallback:
+	WARN_ON_ONCE(set->nr_hw_queues > 1);
+	for_each_possible_cpu(cpu)
+		set->mq_map[cpu] = 0;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 28556fc..45af0fe 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -86,8 +86,13 @@
 	}
 	sgl = sreq->tsg;
 	n = sg_nents(sgl);
-	for_each_sg(sgl, sg, n, i)
-		put_page(sg_page(sg));
+	for_each_sg(sgl, sg, n, i) {
+		struct page *page = sg_page(sg);
+
+		/* some SGs may not have a page mapped */
+		if (page && page_ref_count(page))
+			put_page(page);
+	}
 
 	kfree(sreq->tsg);
 }
diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index 121010a..18c94e1 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -248,6 +248,9 @@
 	u8 *ihash = ohash + crypto_ahash_digestsize(auth);
 	u32 tmp[2];
 
+	if (!authsize)
+		goto decrypt;
+
 	/* Move high-order bits of sequence number back. */
 	scatterwalk_map_and_copy(tmp, dst, 4, 4, 0);
 	scatterwalk_map_and_copy(tmp + 1, dst, assoclen + cryptlen, 4, 0);
@@ -256,6 +259,8 @@
 	if (crypto_memneq(ihash, ohash, authsize))
 		return -EBADMSG;
 
+decrypt:
+
 	sg_init_table(areq_ctx->dst, 2);
 	dst = scatterwalk_ffwd(areq_ctx->dst, dst, assoclen);
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 5f8abc3..e37c9aa 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -54,8 +54,6 @@
 
 source "drivers/i2c/Kconfig"
 
-source "drivers/soundwire/Kconfig"
-
 source "drivers/spi/Kconfig"
 
 source "drivers/slimbus/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index d0abb5a..04e2d4e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -81,7 +81,6 @@
 obj-$(CONFIG_MTD)		+= mtd/
 obj-$(CONFIG_SPI)		+= spi/
 obj-$(CONFIG_SPMI)		+= spmi/
-obj-$(CONFIG_SOUNDWIRE)		+= soundwire/
 obj-$(CONFIG_SLIMBUS)		+= slimbus/
 obj-$(CONFIG_HSI)		+= hsi/
 obj-y				+= net/
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index e53bef6..0375c60 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1072,6 +1072,7 @@
 		if (list_empty(&ghes_sci))
 			unregister_acpi_hed_notifier(&ghes_notifier_sci);
 		mutex_unlock(&ghes_list_mutex);
+		synchronize_rcu();
 		break;
 	case ACPI_HEST_NOTIFY_NMI:
 		ghes_nmi_remove(ghes);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 79152db..5187469 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1728,7 +1728,7 @@
  * functioning ECDT EC first in order to handle the events.
  * https://bugzilla.kernel.org/show_bug.cgi?id=115021
  */
-int __init acpi_ec_ecdt_start(void)
+static int __init acpi_ec_ecdt_start(void)
 {
 	acpi_handle handle;
 
@@ -1959,20 +1959,17 @@
 int __init acpi_ec_init(void)
 {
 	int result;
+	int ecdt_fail, dsdt_fail;
 
 	/* register workqueue for _Qxx evaluations */
 	result = acpi_ec_query_init();
 	if (result)
-		goto err_exit;
-	/* Now register the driver for the EC */
-	result = acpi_bus_register_driver(&acpi_ec_driver);
-	if (result)
-		goto err_exit;
+		return result;
 
-err_exit:
-	if (result)
-		acpi_ec_query_exit();
-	return result;
+	/* Drivers must be started after acpi_ec_query_init() */
+	ecdt_fail = acpi_ec_ecdt_start();
+	dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
+	return ecdt_fail && dsdt_fail ? -ENODEV : 0;
 }
 
 /* EC driver currently not unloadable */
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 5ea5dc2..73c9c7f 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -98,7 +98,15 @@
 	if (check_children && list_empty(&adev->children))
 		return -ENODEV;
 
-	return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
+	/*
+	 * If the device has a _HID (or _CID) returning a valid ACPI/PNP
+	 * device ID, it is better to make it look less attractive here, so that
+	 * the other device with the same _ADR value (that may not have a valid
+	 * device ID) can be matched going forward.  [This means a second spec
+	 * violation in a row, so whatever we do here is best effort anyway.]
+	 */
+	return sta_present && list_empty(&adev->pnp.ids) ?
+			FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
 }
 
 struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 219b90b..08b3ca0 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -185,7 +185,6 @@
 int acpi_ec_init(void);
 int acpi_ec_ecdt_probe(void);
 int acpi_ec_dsdt_probe(void);
-int acpi_ec_ecdt_start(void);
 void acpi_ec_block_transactions(void);
 void acpi_ec_unblock_transactions(void);
 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
diff --git a/drivers/acpi/ioapic.c b/drivers/acpi/ioapic.c
index 6d7ce6e..5e18ccf 100644
--- a/drivers/acpi/ioapic.c
+++ b/drivers/acpi/ioapic.c
@@ -45,6 +45,12 @@
 	struct resource *res = data;
 	struct resource_win win;
 
+	/*
+	 * We might assign this to 'res' later, make sure all pointers are
+	 * cleared before the resource is added to the global list
+	 */
+	memset(&win, 0, sizeof(win));
+
 	res->flags = 0;
 	if (acpi_dev_filter_resource_type(acpi_res, IORESOURCE_MEM))
 		return AE_OK;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index dd3786a..cf725d5 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2051,7 +2051,6 @@
 
 	acpi_gpe_apply_masked_gpes();
 	acpi_update_all_gpes();
-	acpi_ec_ecdt_start();
 
 	acpi_scan_initialized = true;
 
diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig
index 4d4cdc1..01de42c 100644
--- a/drivers/android/Kconfig
+++ b/drivers/android/Kconfig
@@ -44,6 +44,16 @@
 
 	  Note that enabling this will break newer Android user-space.
 
+config ANDROID_BINDER_IPC_SELFTEST
+	bool "Android Binder IPC Driver Selftest"
+	depends on ANDROID_BINDER_IPC
+	---help---
+	  This feature allows binder selftest to run.
+
+	  Binder selftest checks the allocation and free of binder buffers
+	  exhaustively with combinations of various buffer sizes and
+	  alignments.
+
 endif # if ANDROID
 
 endmenu
diff --git a/drivers/android/Makefile b/drivers/android/Makefile
index 4b7c726..a01254c 100644
--- a/drivers/android/Makefile
+++ b/drivers/android/Makefile
@@ -1,3 +1,4 @@
 ccflags-y += -I$(src)			# needed for trace events
 
 obj-$(CONFIG_ANDROID_BINDER_IPC)	+= binder.o binder_alloc.o
+obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 632c814..fcf85be 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1013,7 +1013,7 @@
 {
 	struct binder_thread *thread;
 
-	BUG_ON(!spin_is_locked(&proc->inner_lock));
+	assert_spin_locked(&proc->inner_lock);
 	thread = list_first_entry_or_null(&proc->waiting_threads,
 					  struct binder_thread,
 					  waiting_thread_node);
@@ -1044,7 +1044,7 @@
 					 struct binder_thread *thread,
 					 bool sync)
 {
-	BUG_ON(!spin_is_locked(&proc->inner_lock));
+	assert_spin_locked(&proc->inner_lock);
 
 	if (thread) {
 		if (sync)
@@ -1223,7 +1223,7 @@
 	struct rb_node *n = proc->nodes.rb_node;
 	struct binder_node *node;
 
-	BUG_ON(!spin_is_locked(&proc->inner_lock));
+	assert_spin_locked(&proc->inner_lock);
 
 	while (n) {
 		node = rb_entry(n, struct binder_node, rb_node);
@@ -1269,7 +1269,8 @@
 	__u32 flags = fp ? fp->flags : 0;
 	s8 priority;
 
-	BUG_ON(!spin_is_locked(&proc->inner_lock));
+	assert_spin_locked(&proc->inner_lock);
+
 	while (*p) {
 
 		parent = *p;
@@ -1348,9 +1349,9 @@
 {
 	struct binder_proc *proc = node->proc;
 
-	BUG_ON(!spin_is_locked(&node->lock));
+	assert_spin_locked(&node->lock);
 	if (proc)
-		BUG_ON(!spin_is_locked(&proc->inner_lock));
+		assert_spin_locked(&proc->inner_lock);
 	if (strong) {
 		if (internal) {
 			if (target_list == NULL &&
@@ -1402,9 +1403,9 @@
 {
 	struct binder_proc *proc = node->proc;
 
-	BUG_ON(!spin_is_locked(&node->lock));
+	assert_spin_locked(&node->lock);
 	if (proc)
-		BUG_ON(!spin_is_locked(&proc->inner_lock));
+		assert_spin_locked(&proc->inner_lock);
 	if (strong) {
 		if (internal)
 			node->internal_strong_refs--;
@@ -1928,7 +1929,7 @@
 					   struct binder_transaction *t)
 {
 	BUG_ON(!target_thread);
-	BUG_ON(!spin_is_locked(&target_thread->proc->inner_lock));
+	assert_spin_locked(&target_thread->proc->inner_lock);
 	BUG_ON(target_thread->transaction_stack != t);
 	BUG_ON(target_thread->transaction_stack->from != target_thread);
 	target_thread->transaction_stack =
@@ -2479,7 +2480,6 @@
 			     (u64)node->ptr);
 		binder_node_unlock(node);
 	} else {
-		int ret;
 		struct binder_ref_data dest_rdata;
 
 		binder_node_unlock(node);
@@ -2743,6 +2743,48 @@
 	return true;
 }
 
+/**
+ * binder_get_node_refs_for_txn() - Get required refs on node for txn
+ * @node:         struct binder_node for which to get refs
+ * @proc:         returns @node->proc if valid
+ * @error:        if no @proc then returns BR_DEAD_REPLY
+ *
+ * User-space normally keeps the node alive when creating a transaction
+ * since it has a reference to the target. The local strong ref keeps it
+ * alive if the sending process dies before the target process processes
+ * the transaction. If the source process is malicious or has a reference
+ * counting bug, relying on the local strong ref can fail.
+ *
+ * Since user-space can cause the local strong ref to go away, we also take
+ * a tmpref on the node to ensure it survives while we are constructing
+ * the transaction. We also need a tmpref on the proc while we are
+ * constructing the transaction, so we take that here as well.
+ *
+ * Return: The target_node with refs taken or NULL if no @node->proc is NULL.
+ * Also sets @proc if valid. If the @node->proc is NULL indicating that the
+ * target proc has died, @error is set to BR_DEAD_REPLY
+ */
+static struct binder_node *binder_get_node_refs_for_txn(
+		struct binder_node *node,
+		struct binder_proc **procp,
+		uint32_t *error)
+{
+	struct binder_node *target_node = NULL;
+
+	binder_node_inner_lock(node);
+	if (node->proc) {
+		target_node = node;
+		binder_inc_node_nilocked(node, 1, 0, NULL);
+		binder_inc_node_tmpref_ilocked(node);
+		node->proc->tmp_ref++;
+		*procp = node->proc;
+	} else
+		*error = BR_DEAD_REPLY;
+	binder_node_inner_unlock(node);
+
+	return target_node;
+}
+
 static void binder_transaction(struct binder_proc *proc,
 			       struct binder_thread *thread,
 			       struct binder_transaction_data *tr, int reply,
@@ -2845,43 +2887,35 @@
 			ref = binder_get_ref_olocked(proc, tr->target.handle,
 						     true);
 			if (ref) {
-				binder_inc_node(ref->node, 1, 0, NULL);
-				target_node = ref->node;
+				target_node = binder_get_node_refs_for_txn(
+						ref->node, &target_proc,
+						&return_error);
+			} else {
+				binder_user_error("%d:%d got transaction to invalid handle\n",
+						  proc->pid, thread->pid);
+				return_error = BR_FAILED_REPLY;
 			}
 			binder_proc_unlock(proc);
-			if (target_node == NULL) {
-				binder_user_error("%d:%d got transaction to invalid handle\n",
-					proc->pid, thread->pid);
-				return_error = BR_FAILED_REPLY;
-				return_error_param = -EINVAL;
-				return_error_line = __LINE__;
-				goto err_invalid_target_handle;
-			}
 		} else {
 			mutex_lock(&context->context_mgr_node_lock);
 			target_node = context->binder_context_mgr_node;
-			if (target_node == NULL) {
+			if (target_node)
+				target_node = binder_get_node_refs_for_txn(
+						target_node, &target_proc,
+						&return_error);
+			else
 				return_error = BR_DEAD_REPLY;
-				mutex_unlock(&context->context_mgr_node_lock);
-				return_error_line = __LINE__;
-				goto err_no_context_mgr_node;
-			}
-			binder_inc_node(target_node, 1, 0, NULL);
 			mutex_unlock(&context->context_mgr_node_lock);
 		}
-		e->to_node = target_node->debug_id;
-		binder_node_lock(target_node);
-		target_proc = target_node->proc;
-		if (target_proc == NULL) {
-			binder_node_unlock(target_node);
-			return_error = BR_DEAD_REPLY;
+		if (!target_node) {
+			/*
+			 * return_error is set above
+			 */
+			return_error_param = -EINVAL;
 			return_error_line = __LINE__;
 			goto err_dead_binder;
 		}
-		binder_inner_proc_lock(target_proc);
-		target_proc->tmp_ref++;
-		binder_inner_proc_unlock(target_proc);
-		binder_node_unlock(target_node);
+		e->to_node = target_node->debug_id;
 		if (security_binder_transaction(proc->tsk,
 						target_proc->tsk) < 0) {
 			return_error = BR_FAILED_REPLY;
@@ -3240,6 +3274,8 @@
 	if (target_thread)
 		binder_thread_dec_tmpref(target_thread);
 	binder_proc_dec_tmpref(target_proc);
+	if (target_node)
+		binder_dec_node_tmpref(target_node);
 	/*
 	 * write barrier to synchronize with initialization
 	 * of log entry
@@ -3251,6 +3287,7 @@
 err_dead_proc_or_thread:
 	return_error = BR_DEAD_REPLY;
 	return_error_line = __LINE__;
+	binder_dequeue_work(proc, tcomplete);
 err_translate_failed:
 err_bad_object_type:
 err_bad_offset:
@@ -3258,6 +3295,8 @@
 err_copy_data_failed:
 	trace_binder_transaction_failed_buffer_release(t->buffer);
 	binder_transaction_buffer_release(target_proc, t->buffer, offp);
+	if (target_node)
+		binder_dec_node_tmpref(target_node);
 	target_node = NULL;
 	t->buffer->transaction = NULL;
 	binder_alloc_free_buf(&target_proc->alloc, t->buffer);
@@ -3272,13 +3311,14 @@
 err_empty_call_stack:
 err_dead_binder:
 err_invalid_target_handle:
-err_no_context_mgr_node:
 	if (target_thread)
 		binder_thread_dec_tmpref(target_thread);
 	if (target_proc)
 		binder_proc_dec_tmpref(target_proc);
-	if (target_node)
+	if (target_node) {
 		binder_dec_node(target_node, 1, 0);
+		binder_dec_node_tmpref(target_node);
+	}
 
 	binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
 		     "%d:%d transaction failed %d/%d, size %lld-%lld line %d\n",
@@ -3520,11 +3560,13 @@
 				BUG_ON(buf_node->proc != proc);
 				w = binder_dequeue_work_head_ilocked(
 						&buf_node->async_todo);
-				if (!w)
+				if (!w) {
 					buf_node->has_async_transaction = 0;
-				else
+				} else {
 					binder_enqueue_work_ilocked(
-							w, &thread->todo);
+							w, &proc->todo);
+					binder_wakeup_proc_ilocked(proc);
+				}
 				binder_node_inner_unlock(buf_node);
 			}
 			trace_binder_transaction_buffer_release(buffer);
@@ -3668,22 +3710,12 @@
 				ref->death = death;
 				if (ref->node->proc == NULL) {
 					ref->death->work.type = BINDER_WORK_DEAD_BINDER;
-					if (thread->looper &
-					    (BINDER_LOOPER_STATE_REGISTERED |
-					     BINDER_LOOPER_STATE_ENTERED))
-						binder_enqueue_work(
-							proc,
-							&ref->death->work,
-							&thread->todo);
-					else {
-						binder_inner_proc_lock(proc);
-						binder_enqueue_work_ilocked(
-							&ref->death->work,
-							&proc->todo);
-						binder_wakeup_proc_ilocked(
-							proc);
-						binder_inner_proc_unlock(proc);
-					}
+
+					binder_inner_proc_lock(proc);
+					binder_enqueue_work_ilocked(
+						&ref->death->work, &proc->todo);
+					binder_wakeup_proc_ilocked(proc);
+					binder_inner_proc_unlock(proc);
 				}
 			} else {
 				if (ref->death == NULL) {
@@ -3800,12 +3832,6 @@
 	}
 }
 
-static int binder_has_thread_work(struct binder_thread *thread)
-{
-	return !binder_worklist_empty(thread->proc, &thread->todo) ||
-		thread->looper_need_return;
-}
-
 static int binder_put_node_cmd(struct binder_proc *proc,
 			       struct binder_thread *thread,
 			       void __user **ptrp,
@@ -4436,12 +4462,9 @@
 
 	binder_inner_proc_unlock(thread->proc);
 
-	if (binder_has_work(thread, wait_for_proc_work))
-		return POLLIN;
-
 	poll_wait(filp, &thread->wait, wait);
 
-	if (binder_has_thread_work(thread))
+	if (binder_has_work(thread, wait_for_proc_work))
 		return POLLIN;
 
 	return 0;
@@ -4595,6 +4618,8 @@
 	/*pr_info("binder_ioctl: %d:%d %x %lx\n",
 			proc->pid, current->pid, cmd, arg);*/
 
+	binder_selftest_alloc(&proc->alloc);
+
 	trace_binder_ioctl(cmd, arg);
 
 	ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
@@ -5071,7 +5096,6 @@
 	struct binder_proc *to_proc;
 	struct binder_buffer *buffer = t->buffer;
 
-	WARN_ON(!spin_is_locked(&proc->inner_lock));
 	spin_lock(&t->lock);
 	to_proc = t->to_proc;
 	seq_printf(m,
@@ -5160,7 +5184,6 @@
 	size_t start_pos = m->count;
 	size_t header_pos;
 
-	WARN_ON(!spin_is_locked(&thread->proc->inner_lock));
 	seq_printf(m, "  thread %d: l %02x need_return %d tr %d\n",
 			thread->pid, thread->looper,
 			thread->looper_need_return,
@@ -5197,10 +5220,6 @@
 	struct binder_work *w;
 	int count;
 
-	WARN_ON(!spin_is_locked(&node->lock));
-	if (node->proc)
-		WARN_ON(!spin_is_locked(&node->proc->inner_lock));
-
 	count = 0;
 	hlist_for_each_entry(ref, &node->refs, node_entry)
 		count++;
@@ -5227,7 +5246,6 @@
 static void print_binder_ref_olocked(struct seq_file *m,
 				     struct binder_ref *ref)
 {
-	WARN_ON(!spin_is_locked(&ref->proc->outer_lock));
 	binder_node_lock(ref->node);
 	seq_printf(m, "  ref %d: desc %d %snode %d s %d w %d d %pK\n",
 		   ref->data.debug_id, ref->data.desc,
@@ -5447,6 +5465,8 @@
 	count = binder_alloc_get_allocated_count(&proc->alloc);
 	seq_printf(m, "  buffers: %d\n", count);
 
+	binder_alloc_print_pages(m, &proc->alloc);
+
 	count = 0;
 	binder_inner_proc_lock(proc);
 	list_for_each_entry(w, &proc->todo, entry) {
@@ -5643,6 +5663,8 @@
 	struct binder_device *device;
 	struct hlist_node *tmp;
 
+	binder_alloc_shrinker_init();
+
 	atomic_set(&binder_transaction_log.cur, ~0U);
 	atomic_set(&binder_transaction_log_failed.cur, ~0U);
 
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index b90222a..e026894 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -27,9 +27,12 @@
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/list_lru.h>
 #include "binder_alloc.h"
 #include "binder_trace.h"
 
+struct list_lru binder_alloc_lru;
+
 static DEFINE_MUTEX(binder_alloc_mmap_lock);
 
 enum {
@@ -48,14 +51,23 @@
 			pr_info(x); \
 	} while (0)
 
+static struct binder_buffer *binder_buffer_next(struct binder_buffer *buffer)
+{
+	return list_entry(buffer->entry.next, struct binder_buffer, entry);
+}
+
+static struct binder_buffer *binder_buffer_prev(struct binder_buffer *buffer)
+{
+	return list_entry(buffer->entry.prev, struct binder_buffer, entry);
+}
+
 static size_t binder_alloc_buffer_size(struct binder_alloc *alloc,
 				       struct binder_buffer *buffer)
 {
 	if (list_is_last(&buffer->entry, &alloc->buffers))
-		return alloc->buffer +
-		       alloc->buffer_size - (void *)buffer->data;
-	return (size_t)list_entry(buffer->entry.next,
-			  struct binder_buffer, entry) - (size_t)buffer->data;
+		return (u8 *)alloc->buffer +
+			alloc->buffer_size - (u8 *)buffer->data;
+	return (u8 *)binder_buffer_next(buffer)->data - (u8 *)buffer->data;
 }
 
 static void binder_insert_free_buffer(struct binder_alloc *alloc,
@@ -105,9 +117,9 @@
 		buffer = rb_entry(parent, struct binder_buffer, rb_node);
 		BUG_ON(buffer->free);
 
-		if (new_buffer < buffer)
+		if (new_buffer->data < buffer->data)
 			p = &parent->rb_left;
-		else if (new_buffer > buffer)
+		else if (new_buffer->data > buffer->data)
 			p = &parent->rb_right;
 		else
 			BUG();
@@ -122,18 +134,17 @@
 {
 	struct rb_node *n = alloc->allocated_buffers.rb_node;
 	struct binder_buffer *buffer;
-	struct binder_buffer *kern_ptr;
+	void *kern_ptr;
 
-	kern_ptr = (struct binder_buffer *)(user_ptr - alloc->user_buffer_offset
-		- offsetof(struct binder_buffer, data));
+	kern_ptr = (void *)(user_ptr - alloc->user_buffer_offset);
 
 	while (n) {
 		buffer = rb_entry(n, struct binder_buffer, rb_node);
 		BUG_ON(buffer->free);
 
-		if (kern_ptr < buffer)
+		if (kern_ptr < buffer->data)
 			n = n->rb_left;
-		else if (kern_ptr > buffer)
+		else if (kern_ptr > buffer->data)
 			n = n->rb_right;
 		else {
 			/*
@@ -180,8 +191,9 @@
 {
 	void *page_addr;
 	unsigned long user_page_addr;
-	struct page **page;
-	struct mm_struct *mm;
+	struct binder_lru_page *page;
+	struct mm_struct *mm = NULL;
+	bool need_mm = false;
 
 	binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
 		     "%d: %s pages %pK-%pK\n", alloc->pid,
@@ -192,9 +204,18 @@
 
 	trace_binder_update_page_range(alloc, allocate, start, end);
 
-	if (vma)
-		mm = NULL;
-	else
+	if (allocate == 0)
+		goto free_range;
+
+	for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
+		page = &alloc->pages[(page_addr - alloc->buffer) / PAGE_SIZE];
+		if (!page->page_ptr) {
+			need_mm = true;
+			break;
+		}
+	}
+
+	if (!vma && need_mm)
 		mm = get_task_mm(alloc->tsk);
 
 	if (mm) {
@@ -207,10 +228,7 @@
 		}
 	}
 
-	if (allocate == 0)
-		goto free_range;
-
-	if (vma == NULL) {
+	if (!vma && need_mm) {
 		pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n",
 			alloc->pid);
 		goto err_no_vma;
@@ -218,18 +236,40 @@
 
 	for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
 		int ret;
+		bool on_lru;
+		size_t index;
 
-		page = &alloc->pages[(page_addr - alloc->buffer) / PAGE_SIZE];
+		index = (page_addr - alloc->buffer) / PAGE_SIZE;
+		page = &alloc->pages[index];
 
-		BUG_ON(*page);
-		*page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
-		if (*page == NULL) {
+		if (page->page_ptr) {
+			trace_binder_alloc_lru_start(alloc, index);
+
+			on_lru = list_lru_del(&binder_alloc_lru, &page->lru);
+			WARN_ON(!on_lru);
+
+			trace_binder_alloc_lru_end(alloc, index);
+			continue;
+		}
+
+		if (WARN_ON(!vma))
+			goto err_page_ptr_cleared;
+
+		trace_binder_alloc_page_start(alloc, index);
+		page->page_ptr = alloc_page(GFP_KERNEL |
+					    __GFP_HIGHMEM |
+					    __GFP_ZERO);
+		if (!page->page_ptr) {
 			pr_err("%d: binder_alloc_buf failed for page at %pK\n",
 				alloc->pid, page_addr);
 			goto err_alloc_page_failed;
 		}
+		page->alloc = alloc;
+		INIT_LIST_HEAD(&page->lru);
+
 		ret = map_kernel_range_noflush((unsigned long)page_addr,
-					PAGE_SIZE, PAGE_KERNEL, page);
+					       PAGE_SIZE, PAGE_KERNEL,
+					       &page->page_ptr);
 		flush_cache_vmap((unsigned long)page_addr,
 				(unsigned long)page_addr + PAGE_SIZE);
 		if (ret != 1) {
@@ -239,12 +279,14 @@
 		}
 		user_page_addr =
 			(uintptr_t)page_addr + alloc->user_buffer_offset;
-		ret = vm_insert_page(vma, user_page_addr, page[0]);
+		ret = vm_insert_page(vma, user_page_addr, page[0].page_ptr);
 		if (ret) {
 			pr_err("%d: binder_alloc_buf failed to map page at %lx in userspace\n",
 			       alloc->pid, user_page_addr);
 			goto err_vm_insert_page_failed;
 		}
+
+		trace_binder_alloc_page_end(alloc, index);
 		/* vm_insert_page does not seem to increment the refcount */
 	}
 	if (mm) {
@@ -256,16 +298,27 @@
 free_range:
 	for (page_addr = end - PAGE_SIZE; page_addr >= start;
 	     page_addr -= PAGE_SIZE) {
-		page = &alloc->pages[(page_addr - alloc->buffer) / PAGE_SIZE];
-		if (vma)
-			zap_page_range(vma, (uintptr_t)page_addr +
-				alloc->user_buffer_offset, PAGE_SIZE, NULL);
+		bool ret;
+		size_t index;
+
+		index = (page_addr - alloc->buffer) / PAGE_SIZE;
+		page = &alloc->pages[index];
+
+		trace_binder_free_lru_start(alloc, index);
+
+		ret = list_lru_add(&binder_alloc_lru, &page->lru);
+		WARN_ON(!ret);
+
+		trace_binder_free_lru_end(alloc, index);
+		continue;
+
 err_vm_insert_page_failed:
 		unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
 err_map_kernel_failed:
-		__free_page(*page);
-		*page = NULL;
+		__free_page(page->page_ptr);
+		page->page_ptr = NULL;
 err_alloc_page_failed:
+err_page_ptr_cleared:
 		;
 	}
 err_no_vma:
@@ -321,6 +374,9 @@
 		return ERR_PTR(-ENOSPC);
 	}
 
+	/* Pad 0-size buffers so they get assigned unique addresses */
+	size = max(size, sizeof(void *));
+
 	while (n) {
 		buffer = rb_entry(n, struct binder_buffer, rb_node);
 		BUG_ON(!buffer->free);
@@ -380,14 +436,9 @@
 
 	has_page_addr =
 		(void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK);
-	if (n == NULL) {
-		if (size + sizeof(struct binder_buffer) + 4 >= buffer_size)
-			buffer_size = size; /* no room for other buffers */
-		else
-			buffer_size = size + sizeof(struct binder_buffer);
-	}
+	WARN_ON(n && buffer_size != size);
 	end_page_addr =
-		(void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size);
+		(void *)PAGE_ALIGN((uintptr_t)buffer->data + size);
 	if (end_page_addr > has_page_addr)
 		end_page_addr = has_page_addr;
 	ret = binder_update_page_range(alloc, 1,
@@ -395,17 +446,25 @@
 	if (ret)
 		return ERR_PTR(ret);
 
-	rb_erase(best_fit, &alloc->free_buffers);
-	buffer->free = 0;
-	buffer->free_in_progress = 0;
-	binder_insert_allocated_buffer_locked(alloc, buffer);
 	if (buffer_size != size) {
-		struct binder_buffer *new_buffer = (void *)buffer->data + size;
+		struct binder_buffer *new_buffer;
 
+		new_buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
+		if (!new_buffer) {
+			pr_err("%s: %d failed to alloc new buffer struct\n",
+			       __func__, alloc->pid);
+			goto err_alloc_buf_struct_failed;
+		}
+		new_buffer->data = (u8 *)buffer->data + size;
 		list_add(&new_buffer->entry, &buffer->entry);
 		new_buffer->free = 1;
 		binder_insert_free_buffer(alloc, new_buffer);
 	}
+
+	rb_erase(best_fit, &alloc->free_buffers);
+	buffer->free = 0;
+	buffer->free_in_progress = 0;
+	binder_insert_allocated_buffer_locked(alloc, buffer);
 	binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
 		     "%d: binder_alloc_buf size %zd got %pK\n",
 		      alloc->pid, size, buffer);
@@ -420,6 +479,12 @@
 			      alloc->pid, size, alloc->free_async_space);
 	}
 	return buffer;
+
+err_alloc_buf_struct_failed:
+	binder_update_page_range(alloc, 0,
+				 (void *)PAGE_ALIGN((uintptr_t)buffer->data),
+				 end_page_addr, NULL);
+	return ERR_PTR(-ENOMEM);
 }
 
 /**
@@ -454,57 +519,59 @@
 
 static void *buffer_start_page(struct binder_buffer *buffer)
 {
-	return (void *)((uintptr_t)buffer & PAGE_MASK);
+	return (void *)((uintptr_t)buffer->data & PAGE_MASK);
 }
 
-static void *buffer_end_page(struct binder_buffer *buffer)
+static void *prev_buffer_end_page(struct binder_buffer *buffer)
 {
-	return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK);
+	return (void *)(((uintptr_t)(buffer->data) - 1) & PAGE_MASK);
 }
 
 static void binder_delete_free_buffer(struct binder_alloc *alloc,
 				      struct binder_buffer *buffer)
 {
 	struct binder_buffer *prev, *next = NULL;
-	int free_page_end = 1;
-	int free_page_start = 1;
-
+	bool to_free = true;
 	BUG_ON(alloc->buffers.next == &buffer->entry);
-	prev = list_entry(buffer->entry.prev, struct binder_buffer, entry);
+	prev = binder_buffer_prev(buffer);
 	BUG_ON(!prev->free);
-	if (buffer_end_page(prev) == buffer_start_page(buffer)) {
-		free_page_start = 0;
-		if (buffer_end_page(prev) == buffer_end_page(buffer))
-			free_page_end = 0;
+	if (prev_buffer_end_page(prev) == buffer_start_page(buffer)) {
+		to_free = false;
 		binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
-			     "%d: merge free, buffer %pK share page with %pK\n",
-			      alloc->pid, buffer, prev);
+				   "%d: merge free, buffer %pK share page with %pK\n",
+				   alloc->pid, buffer->data, prev->data);
 	}
 
 	if (!list_is_last(&buffer->entry, &alloc->buffers)) {
-		next = list_entry(buffer->entry.next,
-				  struct binder_buffer, entry);
-		if (buffer_start_page(next) == buffer_end_page(buffer)) {
-			free_page_end = 0;
-			if (buffer_start_page(next) ==
-			    buffer_start_page(buffer))
-				free_page_start = 0;
+		next = binder_buffer_next(buffer);
+		if (buffer_start_page(next) == buffer_start_page(buffer)) {
+			to_free = false;
 			binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
-				     "%d: merge free, buffer %pK share page with %pK\n",
-				      alloc->pid, buffer, prev);
+					   "%d: merge free, buffer %pK share page with %pK\n",
+					   alloc->pid,
+					   buffer->data,
+					   next->data);
 		}
 	}
-	list_del(&buffer->entry);
-	if (free_page_start || free_page_end) {
+
+	if (PAGE_ALIGNED(buffer->data)) {
 		binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
-			     "%d: merge free, buffer %pK do not share page%s%s with %pK or %pK\n",
-			     alloc->pid, buffer, free_page_start ? "" : " end",
-			     free_page_end ? "" : " start", prev, next);
-		binder_update_page_range(alloc, 0, free_page_start ?
-			buffer_start_page(buffer) : buffer_end_page(buffer),
-			(free_page_end ? buffer_end_page(buffer) :
-			buffer_start_page(buffer)) + PAGE_SIZE, NULL);
+				   "%d: merge free, buffer start %pK is page aligned\n",
+				   alloc->pid, buffer->data);
+		to_free = false;
 	}
+
+	if (to_free) {
+		binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
+				   "%d: merge free, buffer %pK do not share page with %pK or %pK\n",
+				   alloc->pid, buffer->data,
+				   prev->data, next->data);
+		binder_update_page_range(alloc, 0, buffer_start_page(buffer),
+					 buffer_start_page(buffer) + PAGE_SIZE,
+					 NULL);
+	}
+	list_del(&buffer->entry);
+	kfree(buffer);
 }
 
 static void binder_free_buf_locked(struct binder_alloc *alloc,
@@ -525,8 +592,8 @@
 	BUG_ON(buffer->free);
 	BUG_ON(size > buffer_size);
 	BUG_ON(buffer->transaction != NULL);
-	BUG_ON((void *)buffer < alloc->buffer);
-	BUG_ON((void *)buffer > alloc->buffer + alloc->buffer_size);
+	BUG_ON(buffer->data < alloc->buffer);
+	BUG_ON(buffer->data > alloc->buffer + alloc->buffer_size);
 
 	if (buffer->async_transaction) {
 		alloc->free_async_space += size + sizeof(struct binder_buffer);
@@ -544,8 +611,7 @@
 	rb_erase(&buffer->rb_node, &alloc->allocated_buffers);
 	buffer->free = 1;
 	if (!list_is_last(&buffer->entry, &alloc->buffers)) {
-		struct binder_buffer *next = list_entry(buffer->entry.next,
-						struct binder_buffer, entry);
+		struct binder_buffer *next = binder_buffer_next(buffer);
 
 		if (next->free) {
 			rb_erase(&next->rb_node, &alloc->free_buffers);
@@ -553,8 +619,7 @@
 		}
 	}
 	if (alloc->buffers.next != &buffer->entry) {
-		struct binder_buffer *prev = list_entry(buffer->entry.prev,
-						struct binder_buffer, entry);
+		struct binder_buffer *prev = binder_buffer_prev(buffer);
 
 		if (prev->free) {
 			binder_delete_free_buffer(alloc, buffer);
@@ -640,14 +705,14 @@
 	}
 	alloc->buffer_size = vma->vm_end - vma->vm_start;
 
-	if (binder_update_page_range(alloc, 1, alloc->buffer,
-				     alloc->buffer + PAGE_SIZE, vma)) {
+	buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
+	if (!buffer) {
 		ret = -ENOMEM;
-		failure_string = "alloc small buf";
-		goto err_alloc_small_buf_failed;
+		failure_string = "alloc buffer struct";
+		goto err_alloc_buf_struct_failed;
 	}
-	buffer = alloc->buffer;
-	INIT_LIST_HEAD(&alloc->buffers);
+
+	buffer->data = alloc->buffer;
 	list_add(&buffer->entry, &alloc->buffers);
 	buffer->free = 1;
 	binder_insert_free_buffer(alloc, buffer);
@@ -658,7 +723,7 @@
 
 	return 0;
 
-err_alloc_small_buf_failed:
+err_alloc_buf_struct_failed:
 	kfree(alloc->pages);
 	alloc->pages = NULL;
 err_alloc_pages_failed:
@@ -678,14 +743,13 @@
 {
 	struct rb_node *n;
 	int buffers, page_count;
+	struct binder_buffer *buffer;
 
 	BUG_ON(alloc->vma);
 
 	buffers = 0;
 	mutex_lock(&alloc->mutex);
 	while ((n = rb_first(&alloc->allocated_buffers))) {
-		struct binder_buffer *buffer;
-
 		buffer = rb_entry(n, struct binder_buffer, rb_node);
 
 		/* Transaction should already have been freed */
@@ -695,22 +759,36 @@
 		buffers++;
 	}
 
+	while (!list_empty(&alloc->buffers)) {
+		buffer = list_first_entry(&alloc->buffers,
+					  struct binder_buffer, entry);
+		WARN_ON(!buffer->free);
+
+		list_del(&buffer->entry);
+		WARN_ON_ONCE(!list_empty(&alloc->buffers));
+		kfree(buffer);
+	}
+
 	page_count = 0;
 	if (alloc->pages) {
 		int i;
 
 		for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
 			void *page_addr;
+			bool on_lru;
 
-			if (!alloc->pages[i])
+			if (!alloc->pages[i].page_ptr)
 				continue;
 
+			on_lru = list_lru_del(&binder_alloc_lru,
+					      &alloc->pages[i].lru);
 			page_addr = alloc->buffer + i * PAGE_SIZE;
 			binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
-				     "%s: %d: page %d at %pK not freed\n",
-				     __func__, alloc->pid, i, page_addr);
+				     "%s: %d: page %d at %pK %s\n",
+				     __func__, alloc->pid, i, page_addr,
+				     on_lru ? "on lru" : "active");
 			unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
-			__free_page(alloc->pages[i]);
+			__free_page(alloc->pages[i].page_ptr);
 			page_count++;
 		}
 		kfree(alloc->pages);
@@ -754,6 +832,34 @@
 }
 
 /**
+ * binder_alloc_print_pages() - print page usage
+ * @m:     seq_file for output via seq_printf()
+ * @alloc: binder_alloc for this proc
+ */
+void binder_alloc_print_pages(struct seq_file *m,
+			      struct binder_alloc *alloc)
+{
+	struct binder_lru_page *page;
+	int i;
+	int active = 0;
+	int lru = 0;
+	int free = 0;
+
+	mutex_lock(&alloc->mutex);
+	for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+		page = &alloc->pages[i];
+		if (!page->page_ptr)
+			free++;
+		else if (list_empty(&page->lru))
+			active++;
+		else
+			lru++;
+	}
+	mutex_unlock(&alloc->mutex);
+	seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
+}
+
+/**
  * binder_alloc_get_allocated_count() - return count of buffers
  * @alloc: binder_alloc for this proc
  *
@@ -787,6 +893,108 @@
 }
 
 /**
+ * binder_alloc_free_page() - shrinker callback to free pages
+ * @item:   item to free
+ * @lock:   lock protecting the item
+ * @cb_arg: callback argument
+ *
+ * Called from list_lru_walk() in binder_shrink_scan() to free
+ * up pages when the system is under memory pressure.
+ */
+enum lru_status binder_alloc_free_page(struct list_head *item,
+				       struct list_lru_one *lru,
+				       spinlock_t *lock,
+				       void *cb_arg)
+{
+	struct mm_struct *mm = NULL;
+	struct binder_lru_page *page = container_of(item,
+						    struct binder_lru_page,
+						    lru);
+	struct binder_alloc *alloc;
+	uintptr_t page_addr;
+	size_t index;
+	struct vm_area_struct *vma;
+
+	alloc = page->alloc;
+	if (!mutex_trylock(&alloc->mutex))
+		goto err_get_alloc_mutex_failed;
+
+	if (!page->page_ptr)
+		goto err_page_already_freed;
+
+	index = page - alloc->pages;
+	page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE;
+	vma = alloc->vma;
+	if (vma) {
+		mm = get_task_mm(alloc->tsk);
+		if (!mm)
+			goto err_get_task_mm_failed;
+		if (!down_write_trylock(&mm->mmap_sem))
+			goto err_down_write_mmap_sem_failed;
+	}
+
+	list_lru_isolate(lru, item);
+	spin_unlock(lock);
+
+	if (vma) {
+		trace_binder_unmap_user_start(alloc, index);
+
+		zap_page_range(vma,
+			       page_addr +
+			       alloc->user_buffer_offset,
+			       PAGE_SIZE, NULL);
+
+		trace_binder_unmap_user_end(alloc, index);
+
+		up_write(&mm->mmap_sem);
+		mmput(mm);
+	}
+
+	trace_binder_unmap_kernel_start(alloc, index);
+
+	unmap_kernel_range(page_addr, PAGE_SIZE);
+	__free_page(page->page_ptr);
+	page->page_ptr = NULL;
+
+	trace_binder_unmap_kernel_end(alloc, index);
+
+	spin_lock(lock);
+	mutex_unlock(&alloc->mutex);
+	return LRU_REMOVED_RETRY;
+
+err_down_write_mmap_sem_failed:
+	mmput_async(mm);
+err_get_task_mm_failed:
+err_page_already_freed:
+	mutex_unlock(&alloc->mutex);
+err_get_alloc_mutex_failed:
+	return LRU_SKIP;
+}
+
+static unsigned long
+binder_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
+{
+	unsigned long ret = list_lru_count(&binder_alloc_lru);
+	return ret;
+}
+
+static unsigned long
+binder_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
+{
+	unsigned long ret;
+
+	ret = list_lru_walk(&binder_alloc_lru, binder_alloc_free_page,
+			    NULL, sc->nr_to_scan);
+	return ret;
+}
+
+struct shrinker binder_shrinker = {
+	.count_objects = binder_shrink_count,
+	.scan_objects = binder_shrink_scan,
+	.seeks = DEFAULT_SEEKS,
+};
+
+/**
  * binder_alloc_init() - called by binder_open() for per-proc initialization
  * @alloc: binder_alloc for this proc
  *
@@ -798,5 +1006,11 @@
 	alloc->tsk = current->group_leader;
 	alloc->pid = current->group_leader->pid;
 	mutex_init(&alloc->mutex);
+	INIT_LIST_HEAD(&alloc->buffers);
 }
 
+void binder_alloc_shrinker_init(void)
+{
+	list_lru_init(&binder_alloc_lru);
+	register_shrinker(&binder_shrinker);
+}
diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
index 088e4ff..a3a3602 100644
--- a/drivers/android/binder_alloc.h
+++ b/drivers/android/binder_alloc.h
@@ -21,7 +21,9 @@
 #include <linux/rtmutex.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
+#include <linux/list_lru.h>
 
+extern struct list_lru binder_alloc_lru;
 struct binder_transaction;
 
 /**
@@ -57,7 +59,19 @@
 	size_t data_size;
 	size_t offsets_size;
 	size_t extra_buffers_size;
-	uint8_t data[0];
+	void *data;
+};
+
+/**
+ * struct binder_lru_page - page object used for binder shrinker
+ * @page_ptr: pointer to physical page in mmap'd space
+ * @lru:      entry in binder_alloc_lru
+ * @alloc:    binder_alloc for a proc
+ */
+struct binder_lru_page {
+	struct list_head lru;
+	struct page *page_ptr;
+	struct binder_alloc *alloc;
 };
 
 /**
@@ -75,8 +89,7 @@
  * @allocated_buffers:  rb tree of allocated buffers sorted by address
  * @free_async_space:   VA space available for async buffers. This is
  *                      initialized at mmap time to 1/2 the full VA space
- * @pages:              array of physical page addresses for each
- *                      page of mmap'd space
+ * @pages:              array of binder_lru_page
  * @buffer_size:        size of address space specified via mmap
  * @pid:                pid for associated binder_proc (invariant after init)
  *
@@ -96,18 +109,27 @@
 	struct rb_root free_buffers;
 	struct rb_root allocated_buffers;
 	size_t free_async_space;
-	struct page **pages;
+	struct binder_lru_page *pages;
 	size_t buffer_size;
 	uint32_t buffer_free;
 	int pid;
 };
 
+#ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST
+void binder_selftest_alloc(struct binder_alloc *alloc);
+#else
+static inline void binder_selftest_alloc(struct binder_alloc *alloc) {}
+#endif
+enum lru_status binder_alloc_free_page(struct list_head *item,
+				       struct list_lru_one *lru,
+				       spinlock_t *lock, void *cb_arg);
 extern struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
 						  size_t data_size,
 						  size_t offsets_size,
 						  size_t extra_buffers_size,
 						  int is_async);
 extern void binder_alloc_init(struct binder_alloc *alloc);
+void binder_alloc_shrinker_init(void);
 extern void binder_alloc_vma_close(struct binder_alloc *alloc);
 extern struct binder_buffer *
 binder_alloc_prepare_to_free(struct binder_alloc *alloc,
@@ -120,6 +142,8 @@
 extern int binder_alloc_get_allocated_count(struct binder_alloc *alloc);
 extern void binder_alloc_print_allocated(struct seq_file *m,
 					 struct binder_alloc *alloc);
+void binder_alloc_print_pages(struct seq_file *m,
+			      struct binder_alloc *alloc);
 
 /**
  * binder_alloc_get_free_async_space() - get free space available for async
diff --git a/drivers/android/binder_alloc_selftest.c b/drivers/android/binder_alloc_selftest.c
new file mode 100644
index 0000000..8bd7bce
--- /dev/null
+++ b/drivers/android/binder_alloc_selftest.c
@@ -0,0 +1,310 @@
+/* binder_alloc_selftest.c
+ *
+ * Android IPC Subsystem
+ *
+ * Copyright (C) 2017 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/mm_types.h>
+#include <linux/err.h>
+#include "binder_alloc.h"
+
+#define BUFFER_NUM 5
+#define BUFFER_MIN_SIZE (PAGE_SIZE / 8)
+
+static bool binder_selftest_run = true;
+static int binder_selftest_failures;
+static DEFINE_MUTEX(binder_selftest_lock);
+
+/**
+ * enum buf_end_align_type - Page alignment of a buffer
+ * end with regard to the end of the previous buffer.
+ *
+ * In the pictures below, buf2 refers to the buffer we
+ * are aligning. buf1 refers to previous buffer by addr.
+ * Symbol [ means the start of a buffer, ] means the end
+ * of a buffer, and | means page boundaries.
+ */
+enum buf_end_align_type {
+	/**
+	 * @SAME_PAGE_UNALIGNED: The end of this buffer is on
+	 * the same page as the end of the previous buffer and
+	 * is not page aligned. Examples:
+	 * buf1 ][ buf2 ][ ...
+	 * buf1 ]|[ buf2 ][ ...
+	 */
+	SAME_PAGE_UNALIGNED = 0,
+	/**
+	 * @SAME_PAGE_ALIGNED: When the end of the previous buffer
+	 * is not page aligned, the end of this buffer is on the
+	 * same page as the end of the previous buffer and is page
+	 * aligned. When the previous buffer is page aligned, the
+	 * end of this buffer is aligned to the next page boundary.
+	 * Examples:
+	 * buf1 ][ buf2 ]| ...
+	 * buf1 ]|[ buf2 ]| ...
+	 */
+	SAME_PAGE_ALIGNED,
+	/**
+	 * @NEXT_PAGE_UNALIGNED: The end of this buffer is on
+	 * the page next to the end of the previous buffer and
+	 * is not page aligned. Examples:
+	 * buf1 ][ buf2 | buf2 ][ ...
+	 * buf1 ]|[ buf2 | buf2 ][ ...
+	 */
+	NEXT_PAGE_UNALIGNED,
+	/**
+	 * @NEXT_PAGE_ALIGNED: The end of this buffer is on
+	 * the page next to the end of the previous buffer and
+	 * is page aligned. Examples:
+	 * buf1 ][ buf2 | buf2 ]| ...
+	 * buf1 ]|[ buf2 | buf2 ]| ...
+	 */
+	NEXT_PAGE_ALIGNED,
+	/**
+	 * @NEXT_NEXT_UNALIGNED: The end of this buffer is on
+	 * the page that follows the page after the end of the
+	 * previous buffer and is not page aligned. Examples:
+	 * buf1 ][ buf2 | buf2 | buf2 ][ ...
+	 * buf1 ]|[ buf2 | buf2 | buf2 ][ ...
+	 */
+	NEXT_NEXT_UNALIGNED,
+	LOOP_END,
+};
+
+static void pr_err_size_seq(size_t *sizes, int *seq)
+{
+	int i;
+
+	pr_err("alloc sizes: ");
+	for (i = 0; i < BUFFER_NUM; i++)
+		pr_cont("[%zu]", sizes[i]);
+	pr_cont("\n");
+	pr_err("free seq: ");
+	for (i = 0; i < BUFFER_NUM; i++)
+		pr_cont("[%d]", seq[i]);
+	pr_cont("\n");
+}
+
+static bool check_buffer_pages_allocated(struct binder_alloc *alloc,
+					 struct binder_buffer *buffer,
+					 size_t size)
+{
+	void *page_addr, *end;
+	int page_index;
+
+	end = (void *)PAGE_ALIGN((uintptr_t)buffer->data + size);
+	page_addr = buffer->data;
+	for (; page_addr < end; page_addr += PAGE_SIZE) {
+		page_index = (page_addr - alloc->buffer) / PAGE_SIZE;
+		if (!alloc->pages[page_index].page_ptr ||
+		    !list_empty(&alloc->pages[page_index].lru)) {
+			pr_err("expect alloc but is %s at page index %d\n",
+			       alloc->pages[page_index].page_ptr ?
+			       "lru" : "free", page_index);
+			return false;
+		}
+	}
+	return true;
+}
+
+static void binder_selftest_alloc_buf(struct binder_alloc *alloc,
+				      struct binder_buffer *buffers[],
+				      size_t *sizes, int *seq)
+{
+	int i;
+
+	for (i = 0; i < BUFFER_NUM; i++) {
+		buffers[i] = binder_alloc_new_buf(alloc, sizes[i], 0, 0, 0);
+		if (IS_ERR(buffers[i]) ||
+		    !check_buffer_pages_allocated(alloc, buffers[i],
+						  sizes[i])) {
+			pr_err_size_seq(sizes, seq);
+			binder_selftest_failures++;
+		}
+	}
+}
+
+static void binder_selftest_free_buf(struct binder_alloc *alloc,
+				     struct binder_buffer *buffers[],
+				     size_t *sizes, int *seq, size_t end)
+{
+	int i;
+
+	for (i = 0; i < BUFFER_NUM; i++)
+		binder_alloc_free_buf(alloc, buffers[seq[i]]);
+
+	for (i = 0; i < end / PAGE_SIZE; i++) {
+		/**
+		 * Error message on a free page can be false positive
+		 * if binder shrinker ran during binder_alloc_free_buf
+		 * calls above.
+		 */
+		if (list_empty(&alloc->pages[i].lru)) {
+			pr_err_size_seq(sizes, seq);
+			pr_err("expect lru but is %s at page index %d\n",
+			       alloc->pages[i].page_ptr ? "alloc" : "free", i);
+			binder_selftest_failures++;
+		}
+	}
+}
+
+static void binder_selftest_free_page(struct binder_alloc *alloc)
+{
+	int i;
+	unsigned long count;
+
+	while ((count = list_lru_count(&binder_alloc_lru))) {
+		list_lru_walk(&binder_alloc_lru, binder_alloc_free_page,
+			      NULL, count);
+	}
+
+	for (i = 0; i < (alloc->buffer_size / PAGE_SIZE); i++) {
+		if (alloc->pages[i].page_ptr) {
+			pr_err("expect free but is %s at page index %d\n",
+			       list_empty(&alloc->pages[i].lru) ?
+			       "alloc" : "lru", i);
+			binder_selftest_failures++;
+		}
+	}
+}
+
+static void binder_selftest_alloc_free(struct binder_alloc *alloc,
+				       size_t *sizes, int *seq, size_t end)
+{
+	struct binder_buffer *buffers[BUFFER_NUM];
+
+	binder_selftest_alloc_buf(alloc, buffers, sizes, seq);
+	binder_selftest_free_buf(alloc, buffers, sizes, seq, end);
+
+	/* Allocate from lru. */
+	binder_selftest_alloc_buf(alloc, buffers, sizes, seq);
+	if (list_lru_count(&binder_alloc_lru))
+		pr_err("lru list should be empty but is not\n");
+
+	binder_selftest_free_buf(alloc, buffers, sizes, seq, end);
+	binder_selftest_free_page(alloc);
+}
+
+static bool is_dup(int *seq, int index, int val)
+{
+	int i;
+
+	for (i = 0; i < index; i++) {
+		if (seq[i] == val)
+			return true;
+	}
+	return false;
+}
+
+/* Generate BUFFER_NUM factorial free orders. */
+static void binder_selftest_free_seq(struct binder_alloc *alloc,
+				     size_t *sizes, int *seq,
+				     int index, size_t end)
+{
+	int i;
+
+	if (index == BUFFER_NUM) {
+		binder_selftest_alloc_free(alloc, sizes, seq, end);
+		return;
+	}
+	for (i = 0; i < BUFFER_NUM; i++) {
+		if (is_dup(seq, index, i))
+			continue;
+		seq[index] = i;
+		binder_selftest_free_seq(alloc, sizes, seq, index + 1, end);
+	}
+}
+
+static void binder_selftest_alloc_size(struct binder_alloc *alloc,
+				       size_t *end_offset)
+{
+	int i;
+	int seq[BUFFER_NUM] = {0};
+	size_t front_sizes[BUFFER_NUM];
+	size_t back_sizes[BUFFER_NUM];
+	size_t last_offset, offset = 0;
+
+	for (i = 0; i < BUFFER_NUM; i++) {
+		last_offset = offset;
+		offset = end_offset[i];
+		front_sizes[i] = offset - last_offset;
+		back_sizes[BUFFER_NUM - i - 1] = front_sizes[i];
+	}
+	/*
+	 * Buffers share the first or last few pages.
+	 * Only BUFFER_NUM - 1 buffer sizes are adjustable since
+	 * we need one giant buffer before getting to the last page.
+	 */
+	back_sizes[0] += alloc->buffer_size - end_offset[BUFFER_NUM - 1];
+	binder_selftest_free_seq(alloc, front_sizes, seq, 0,
+				 end_offset[BUFFER_NUM - 1]);
+	binder_selftest_free_seq(alloc, back_sizes, seq, 0, alloc->buffer_size);
+}
+
+static void binder_selftest_alloc_offset(struct binder_alloc *alloc,
+					 size_t *end_offset, int index)
+{
+	int align;
+	size_t end, prev;
+
+	if (index == BUFFER_NUM) {
+		binder_selftest_alloc_size(alloc, end_offset);
+		return;
+	}
+	prev = index == 0 ? 0 : end_offset[index - 1];
+	end = prev;
+
+	BUILD_BUG_ON(BUFFER_MIN_SIZE * BUFFER_NUM >= PAGE_SIZE);
+
+	for (align = SAME_PAGE_UNALIGNED; align < LOOP_END; align++) {
+		if (align % 2)
+			end = ALIGN(end, PAGE_SIZE);
+		else
+			end += BUFFER_MIN_SIZE;
+		end_offset[index] = end;
+		binder_selftest_alloc_offset(alloc, end_offset, index + 1);
+	}
+}
+
+/**
+ * binder_selftest_alloc() - Test alloc and free of buffer pages.
+ * @alloc: Pointer to alloc struct.
+ *
+ * Allocate BUFFER_NUM buffers to cover all page alignment cases,
+ * then free them in all orders possible. Check that pages are
+ * correctly allocated, put onto lru when buffers are freed, and
+ * are freed when binder_alloc_free_page is called.
+ */
+void binder_selftest_alloc(struct binder_alloc *alloc)
+{
+	size_t end_offset[BUFFER_NUM];
+
+	if (!binder_selftest_run)
+		return;
+	mutex_lock(&binder_selftest_lock);
+	if (!binder_selftest_run || !alloc->vma)
+		goto done;
+	pr_info("STARTED\n");
+	binder_selftest_alloc_offset(alloc, end_offset, 0);
+	binder_selftest_run = false;
+	if (binder_selftest_failures > 0)
+		pr_info("%d tests FAILED\n", binder_selftest_failures);
+	else
+		pr_info("PASSED\n");
+
+done:
+	mutex_unlock(&binder_selftest_lock);
+}
diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h
index 7967db1..76e3b9c 100644
--- a/drivers/android/binder_trace.h
+++ b/drivers/android/binder_trace.h
@@ -291,6 +291,61 @@
 		  __entry->offset, __entry->size)
 );
 
+DECLARE_EVENT_CLASS(binder_lru_page_class,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index),
+	TP_STRUCT__entry(
+		__field(int, proc)
+		__field(size_t, page_index)
+	),
+	TP_fast_assign(
+		__entry->proc = alloc->pid;
+		__entry->page_index = page_index;
+	),
+	TP_printk("proc=%d page_index=%zu",
+		  __entry->proc, __entry->page_index)
+);
+
+DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
+DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end,
+	TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
+	TP_ARGS(alloc, page_index));
+
 TRACE_EVENT(binder_command,
 	TP_PROTO(uint32_t cmd),
 	TP_ARGS(cmd),
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8e575fb..e3e10e8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2971,10 +2971,12 @@
 static struct ata_device *ata_find_dev(struct ata_port *ap, int devno)
 {
 	if (!sata_pmp_attached(ap)) {
-		if (likely(devno < ata_link_max_devices(&ap->link)))
+		if (likely(devno >= 0 &&
+			   devno < ata_link_max_devices(&ap->link)))
 			return &ap->link.device[devno];
 	} else {
-		if (likely(devno < ap->nr_pmp_links))
+		if (likely(devno >= 0 &&
+			   devno < ap->nr_pmp_links))
 			return &ap->pmp_link[devno].device[0];
 	}
 
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 8d4d959..8706533 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -616,6 +616,7 @@
 	{ PCI_VDEVICE(NVIDIA,	PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE),	8 },
 	{ PCI_VDEVICE(NVIDIA,	PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE),	8 },
 	{ PCI_VDEVICE(AMD,	PCI_DEVICE_ID_AMD_CS5536_IDE),		9 },
+	{ PCI_VDEVICE(AMD,	PCI_DEVICE_ID_AMD_CS5536_DEV_IDE),	9 },
 
 	{ },
 };
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c
index 6c15a55..dc12552 100644
--- a/drivers/ata/pata_cs5536.c
+++ b/drivers/ata/pata_cs5536.c
@@ -289,6 +289,7 @@
 
 static const struct pci_device_id cs5536[] = {
 	{ PCI_VDEVICE(AMD,	PCI_DEVICE_ID_AMD_CS5536_IDE), },
+	{ PCI_VDEVICE(AMD,	PCI_DEVICE_ID_AMD_CS5536_DEV_IDE), },
 	{ },
 };
 
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6470eb8..e32a74e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -736,7 +736,7 @@
 
 out_unregister:
 	kobject_put(&priv->kobj);
-	kfree(drv->p);
+	/* drv->p is freed in driver_release()  */
 	drv->p = NULL;
 out_put_bus:
 	bus_put(bus);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 55687b8..e17ad53 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -208,6 +208,59 @@
 
 #endif
 
+static ssize_t show_sched_load_boost(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	ssize_t rc;
+	unsigned int boost;
+	struct cpu *cpu = container_of(dev, struct cpu, dev);
+	int cpuid = cpu->dev.id;
+
+	boost = per_cpu(sched_load_boost, cpuid);
+	rc = snprintf(buf, PAGE_SIZE-2, "%d\n", boost);
+
+	return rc;
+}
+
+static ssize_t __ref store_sched_load_boost(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	int err;
+	int boost;
+	struct cpu *cpu = container_of(dev, struct cpu, dev);
+	int cpuid = cpu->dev.id;
+
+	err = kstrtoint(strstrip((char *)buf), 0, &boost);
+	if (err)
+		return err;
+
+	/*
+	 * -100 is low enough to cancel out CPU's load and make it near zro.
+	 * 1000 is close to the maximum value that cpu_util_freq_{walt,pelt}
+	 * can take without overflow.
+	 */
+	if (boost < -100 || boost > 1000)
+		return -EINVAL;
+
+	per_cpu(sched_load_boost, cpuid) = boost;
+
+	return count;
+}
+
+static DEVICE_ATTR(sched_load_boost, 0644,
+		   show_sched_load_boost,
+		   store_sched_load_boost);
+
+static struct attribute *sched_cpu_attrs[] = {
+	&dev_attr_sched_load_boost.attr,
+	NULL
+};
+
+static struct attribute_group sched_cpu_attr_group = {
+	.attrs = sched_cpu_attrs,
+};
+
 static const struct attribute_group *common_cpu_attr_groups[] = {
 #ifdef CONFIG_KEXEC
 	&crash_note_cpu_attr_group,
@@ -215,6 +268,7 @@
 #ifdef CONFIG_HOTPLUG_CPU
 	&cpu_isolated_attr_group,
 #endif
+	&sched_cpu_attr_group,
 	NULL
 };
 
@@ -225,6 +279,7 @@
 #ifdef CONFIG_HOTPLUG_CPU
 	&cpu_isolated_attr_group,
 #endif
+	&sched_cpu_attr_group,
 	NULL
 };
 
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index b0beb52..914433f 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -958,7 +958,7 @@
 		timeout = MAX_JIFFY_OFFSET;
 	}
 
-	timeout = wait_for_completion_interruptible_timeout(&buf->completion,
+	timeout = wait_for_completion_killable_timeout(&buf->completion,
 			timeout);
 	if (timeout == -ERESTARTSYS || !timeout) {
 		retval = timeout;
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index a84332a..ce68c1e 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -131,6 +131,8 @@
 /* drivers/base/power/main.c */
 extern struct list_head dpm_list;	/* The active device list */
 
+extern int msm_show_resume_irq_mask;
+
 static inline struct device *to_device(struct list_head *entry)
 {
 	return container_of(entry, struct device, power.entry);
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 4fc6336..b758633 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -17,6 +17,8 @@
 #include <linux/pm_wakeirq.h>
 #include <linux/types.h>
 #include <trace/events/power.h>
+#include <linux/irq.h>
+#include <linux/irqdesc.h>
 
 #include "power.h"
 
@@ -909,7 +911,21 @@
 
 void pm_system_irq_wakeup(unsigned int irq_number)
 {
+	struct irq_desc *desc;
+	const char *name = "null";
+
 	if (pm_wakeup_irq == 0) {
+		if (msm_show_resume_irq_mask) {
+			desc = irq_to_desc(irq_number);
+			if (desc == NULL)
+				name = "stray irq";
+			else if (desc->action && desc->action->name)
+				name = desc->action->name;
+
+			pr_warn("%s: %d triggered %s\n", __func__,
+					irq_number, name);
+
+		}
 		pm_wakeup_irq = irq_number;
 		pm_system_wakeup();
 	}
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 43a36d6..06f6668 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -182,11 +182,12 @@
 	return 0;
 }
 
-static inline struct fwnode_handle *dev_fwnode(struct device *dev)
+struct fwnode_handle *dev_fwnode(struct device *dev)
 {
 	return IS_ENABLED(CONFIG_OF) && dev->of_node ?
 		&dev->of_node->fwnode : dev->fwnode;
 }
+EXPORT_SYMBOL_GPL(dev_fwnode);
 
 /**
  * device_property_present - check if a property of a device is present
diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig
index fc814a3..45fc564 100644
--- a/drivers/base/regmap/Kconfig
+++ b/drivers/base/regmap/Kconfig
@@ -32,3 +32,12 @@
 
 config REGMAP_SWR
 	tristate
+
+config REGMAP_ALLOW_WRITE_DEBUGFS
+	depends on REGMAP && DEBUG_FS
+	bool "Allow REGMAP debugfs write"
+	default n
+	help
+	  Say 'y' here to allow the regmap debugfs write. Regmap debugfs write
+	  could be risky when accessing some essential hardwares, so it is not
+	  recommended to enable this option on any production device.
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index b4c5224..1559070 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -269,8 +269,7 @@
 				   count, ppos);
 }
 
-#define REGMAP_ALLOW_WRITE_DEBUGFS
-#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
+#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
 /*
  * This can be dangerous especially when we have clients such as
  * PMICs, therefore don't provide any real compile time configuration option
@@ -340,7 +339,7 @@
 			new_count, ppos);
 }
 
-#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
+#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
 static ssize_t regmap_data_write_file(struct file *file,
 				     const char __user *user_buf,
 				     size_t count, loff_t *ppos)
@@ -633,7 +632,7 @@
 	if (map->max_register || regmap_readable(map, 0)) {
 		umode_t registers_mode;
 
-#if defined(REGMAP_ALLOW_WRITE_DEBUGFS)
+#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
 		registers_mode = 0600;
 #else
 		registers_mode = 0400;
diff --git a/drivers/base/regmap/regmap-swr.c b/drivers/base/regmap/regmap-swr.c
deleted file mode 100644
index be1eb00..0000000
--- a/drivers/base/regmap/regmap-swr.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-#include <linux/regmap.h>
-#include <linux/soundwire/soundwire.h>
-#include <linux/module.h>
-#include <linux/init.h>
-
-#include "internal.h"
-
-static int regmap_swr_gather_write(void *context,
-				const void *reg, size_t reg_size,
-				const void *val, size_t val_len)
-{
-	struct device *dev = context;
-	struct swr_device *swr = to_swr_device(dev);
-	struct regmap *map = dev_get_regmap(dev, NULL);
-	size_t addr_bytes;
-	size_t val_bytes;
-	int i, ret = 0;
-	u16 reg_addr = 0;
-	u8 *value;
-
-	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
-		return -EINVAL;
-	}
-	addr_bytes = map->format.reg_bytes;
-	if (swr == NULL) {
-		dev_err(dev, "%s: swr device is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (reg_size != addr_bytes) {
-		dev_err(dev, "%s: reg size %zd bytes not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-	reg_addr = *(u16 *)reg;
-	val_bytes = map->format.val_bytes;
-	/* val_len = val_bytes * val_count */
-	for (i = 0; i < (val_len / val_bytes); i++) {
-		value = (u8 *)val + (val_bytes * i);
-		ret = swr_write(swr, swr->dev_num, (reg_addr + i), value);
-		if (ret < 0) {
-			dev_err(dev, "%s: write reg 0x%x failed, err %d\n",
-				__func__, (reg_addr + i), ret);
-			break;
-		}
-	}
-	return ret;
-}
-
-static int regmap_swr_raw_multi_reg_write(void *context, const void *data,
-					  size_t count)
-{
-	struct device *dev = context;
-	struct swr_device *swr = to_swr_device(dev);
-	struct regmap *map = dev_get_regmap(dev, NULL);
-	size_t addr_bytes;
-	size_t val_bytes;
-	size_t pad_bytes;
-	size_t num_regs;
-	int i = 0;
-	int ret = 0;
-	u16 *reg;
-	u8 *val;
-	u8 *buf;
-
-	if (swr == NULL) {
-		dev_err(dev, "%s: swr device is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	addr_bytes = map->format.reg_bytes;
-	val_bytes = map->format.val_bytes;
-	pad_bytes = map->format.pad_bytes;
-
-	if (addr_bytes + val_bytes + pad_bytes == 0) {
-		dev_err(dev, "%s: sum of addr, value and pad is 0\n", __func__);
-		return -EINVAL;
-	}
-	num_regs = count / (addr_bytes + val_bytes + pad_bytes);
-
-	reg = kcalloc(num_regs, sizeof(u16), GFP_KERNEL);
-	if (!reg)
-		return -ENOMEM;
-
-	val = kcalloc(num_regs, sizeof(u8), GFP_KERNEL);
-	if (!val) {
-		ret = -ENOMEM;
-		goto mem_fail;
-	}
-
-	buf = (u8 *)data;
-	for (i = 0; i < num_regs; i++) {
-		reg[i] = *(u16 *)buf;
-		buf += (map->format.reg_bytes + map->format.pad_bytes);
-		val[i] = *buf;
-		buf += map->format.val_bytes;
-	}
-	ret = swr_bulk_write(swr, swr->dev_num, reg, val, num_regs);
-	if (ret)
-		dev_err(dev, "%s: multi reg write failed\n", __func__);
-
-	kfree(val);
-mem_fail:
-	kfree(reg);
-	return ret;
-}
-
-static int regmap_swr_write(void *context, const void *data, size_t count)
-{
-	struct device *dev = context;
-	struct regmap *map = dev_get_regmap(dev, NULL);
-	size_t addr_bytes;
-	size_t val_bytes;
-	size_t pad_bytes;
-
-	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
-		return -EINVAL;
-	}
-	addr_bytes = map->format.reg_bytes;
-	val_bytes = map->format.val_bytes;
-	pad_bytes = map->format.pad_bytes;
-
-	WARN_ON(count < addr_bytes);
-
-	if (count > (addr_bytes + val_bytes + pad_bytes))
-		return regmap_swr_raw_multi_reg_write(context, data, count);
-	else
-		return regmap_swr_gather_write(context, data, addr_bytes,
-					       (data + addr_bytes),
-					       (count - addr_bytes));
-}
-
-static int regmap_swr_read(void *context,
-			const void *reg, size_t reg_size,
-			void *val, size_t val_size)
-{
-	struct device *dev = context;
-	struct swr_device *swr = to_swr_device(dev);
-	struct regmap *map = dev_get_regmap(dev, NULL);
-	size_t addr_bytes;
-	int ret = 0;
-	u16 reg_addr = 0;
-
-	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
-		return -EINVAL;
-	}
-	addr_bytes = map->format.reg_bytes;
-	if (swr == NULL) {
-		dev_err(dev, "%s: swr is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (reg_size != addr_bytes) {
-		dev_err(dev, "%s: register size %zd bytes not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-	reg_addr = *(u16 *)reg;
-	ret = swr_read(swr, swr->dev_num, reg_addr, val, val_size);
-	if (ret < 0)
-		dev_err(dev, "%s: codec reg 0x%x read failed %d\n",
-			__func__, reg_addr, ret);
-	return ret;
-}
-
-static struct regmap_bus regmap_swr = {
-	.write = regmap_swr_write,
-	.gather_write = regmap_swr_gather_write,
-	.read = regmap_swr_read,
-	.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
-};
-
-struct regmap *__regmap_init_swr(struct swr_device *swr,
-				 const struct regmap_config *config,
-				 struct lock_class_key *lock_key,
-				 const char *lock_name)
-{
-	return __regmap_init(&swr->dev, &regmap_swr, &swr->dev, config,
-			   lock_key, lock_name);
-}
-EXPORT_SYMBOL(__regmap_init_swr);
-
-struct regmap *__devm_regmap_init_swr(struct swr_device *swr,
-				      const struct regmap_config *config,
-				      struct lock_class_key *lock_key,
-				      const char *lock_name)
-{
-	return __devm_regmap_init(&swr->dev, &regmap_swr, &swr->dev, config,
-				lock_key, lock_name);
-}
-EXPORT_SYMBOL(__devm_regmap_init_swr);
-
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index c9441f9..98b767d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -929,6 +929,7 @@
 		return -ENOMEM;
 
 	for (i = 0; i < nbds_max; i++) {
+		struct request_queue *q;
 		struct gendisk *disk = alloc_disk(1 << part_shift);
 		if (!disk)
 			goto out;
@@ -954,12 +955,13 @@
 		 * every gendisk to have its very own request_queue struct.
 		 * These structs are big so we dynamically allocate them.
 		 */
-		disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set);
-		if (!disk->queue) {
+		q = blk_mq_init_queue(&nbd_dev[i].tag_set);
+		if (IS_ERR(q)) {
 			blk_mq_free_tag_set(&nbd_dev[i].tag_set);
 			put_disk(disk);
 			goto out;
 		}
+		disk->queue = q;
 
 		/*
 		 * Tell the block layer that we are not a rotational device
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 3c3b8f6..10332c2 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -630,11 +630,12 @@
 	if (err)
 		goto out_put_disk;
 
-	q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set);
+	q = blk_mq_init_queue(&vblk->tag_set);
 	if (IS_ERR(q)) {
 		err = -ENOMEM;
 		goto out_free_tags;
 	}
+	vblk->disk->queue = q;
 
 	q->queuedata = vblk;
 
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 9908597..f11d62d 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2112,9 +2112,9 @@
 			/*
 			 * Get the bios in the request so we can re-queue them.
 			 */
-			if (req_op(shadow[i].request) == REQ_OP_FLUSH ||
-			    req_op(shadow[i].request) == REQ_OP_DISCARD ||
-			    req_op(shadow[i].request) == REQ_OP_SECURE_ERASE ||
+			if (req_op(shadow[j].request) == REQ_OP_FLUSH ||
+			    req_op(shadow[j].request) == REQ_OP_DISCARD ||
+			    req_op(shadow[j].request) == REQ_OP_SECURE_ERASE ||
 			    shadow[j].request->cmd_flags & REQ_FUA) {
 				/*
 				 * Flush operations don't contain bios, so
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index dd220fa..74e677a 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -342,6 +342,7 @@
 	{ USB_DEVICE(0x13d3, 0x3410), .driver_info = BTUSB_REALTEK },
 	{ USB_DEVICE(0x13d3, 0x3416), .driver_info = BTUSB_REALTEK },
 	{ USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK },
+	{ USB_DEVICE(0x13d3, 0x3494), .driver_info = BTUSB_REALTEK },
 
 	/* Additional Realtek 8821AE Bluetooth devices */
 	{ USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c
index 636c982..89bf7c6 100644
--- a/drivers/char/adsprpc.c
+++ b/drivers/char/adsprpc.c
@@ -60,6 +60,7 @@
 #define NUM_SESSIONS	9	/*8 compute, 1 cpz*/
 #define M_FDLIST	(16)
 #define M_CRCLIST	(64)
+#define SESSION_ID_INDEX (30)
 
 #define IS_CACHE_ALIGNED(x) (((x) & ((L1_CACHE_BYTES)-1)) == 0)
 
@@ -282,6 +283,7 @@
 	struct fastrpc_session_ctx *secsctx;
 	uint32_t mode;
 	uint32_t profile;
+	int sessionid;
 	int tgid;
 	int cid;
 	int ssrcount;
@@ -860,7 +862,7 @@
 	}
 	ctx->retval = -1;
 	ctx->pid = current->pid;
-	ctx->tgid = current->tgid;
+	ctx->tgid = fl->tgid;
 	init_completion(&ctx->work);
 
 	spin_lock(&fl->hlock);
@@ -1351,8 +1353,10 @@
 	VERIFY(err, 0 != channel_ctx->chan);
 	if (err)
 		goto bail;
-	msg->pid = current->tgid;
+	msg->pid = fl->tgid;
 	msg->tid = current->pid;
+	if (fl->sessionid)
+		msg->tid |= (1 << SESSION_ID_INDEX);
 	if (kernel)
 		msg->pid = 0;
 	msg->invoke.header.ctx = ptr_to_uint64(ctx) | fl->pd;
@@ -1407,6 +1411,7 @@
 	if (fl->profile)
 		getnstimeofday(&invoket);
 
+
 	VERIFY(err, fl->sctx != NULL);
 	if (err)
 		goto bail;
@@ -1504,7 +1509,7 @@
 		goto bail;
 	if (init->flags == FASTRPC_INIT_ATTACH) {
 		remote_arg_t ra[1];
-		int tgid = current->tgid;
+		int tgid = fl->tgid;
 
 		ra[0].buf.pv = (void *)&tgid;
 		ra[0].buf.len = sizeof(tgid);
@@ -1532,7 +1537,7 @@
 			int siglen;
 		} inbuf;
 
-		inbuf.pgid = current->tgid;
+		inbuf.pgid = fl->tgid;
 		inbuf.namelen = strlen(current->comm) + 1;
 		inbuf.filelen = init->filelen;
 		fl->pd = 1;
@@ -1645,7 +1650,7 @@
 		uintptr_t vaddrout;
 	} routargs;
 
-	inargs.pid = current->tgid;
+	inargs.pid = fl->tgid;
 	inargs.vaddrin = (uintptr_t)map->va;
 	inargs.flags = flags;
 	inargs.num = fl->apps->compat ? num * sizeof(page) : num;
@@ -1687,7 +1692,7 @@
 		ssize_t size;
 	} inargs;
 
-	inargs.pid = current->tgid;
+	inargs.pid = fl->tgid;
 	inargs.size = map->size;
 	inargs.vaddrout = map->raddr;
 	ra[0].buf.pv = (void *)&inargs;
@@ -1817,18 +1822,62 @@
 {
 }
 
+static int fastrpc_search_ctx(uint64_t rctx)
+{
+	struct fastrpc_apps *me = &gfa;
+	struct fastrpc_file *fl;
+	struct hlist_node *n, *m;
+	struct smq_invoke_ctx *ictx = NULL;
+	struct smq_invoke_ctx *ctx;
+	int bfound = 0;
+
+	ctx = (struct smq_invoke_ctx *)(uint64_to_ptr(rctx));
+	if (!ctx)
+		return bfound;
+
+	spin_lock(&me->hlock);
+	hlist_for_each_entry_safe(fl, n, &me->drivers, hn) {
+		if (ctx->fl != fl)
+			continue;
+		spin_lock(&fl->hlock);
+		hlist_for_each_entry_safe(ictx, m, &fl->clst.pending, hn) {
+			if (ptr_to_uint64(ictx) == rctx) {
+				bfound = 1;
+				break;
+			}
+		}
+		hlist_for_each_entry_safe(ictx, m, &fl->clst.interrupted, hn) {
+			if (ptr_to_uint64(ictx) == rctx) {
+				bfound = 1;
+				break;
+			}
+		}
+		spin_unlock(&fl->hlock);
+		if (bfound)
+			break;
+	}
+	spin_unlock(&me->hlock);
+	return bfound;
+}
+
 void fastrpc_glink_notify_rx(void *handle, const void *priv,
 	const void *pkt_priv, const void *ptr, size_t size)
 {
 	struct smq_invoke_rsp *rsp = (struct smq_invoke_rsp *)ptr;
-	int len = size;
+	int bfound = 0;
 
-	while (len >= sizeof(*rsp) && rsp) {
-		rsp->ctx = rsp->ctx & ~1;
-		context_notify_user(uint64_to_ptr(rsp->ctx), rsp->retval);
-		rsp++;
-		len = len - sizeof(*rsp);
+	if (!rsp || (size < sizeof(*rsp)))
+		goto bail;
+
+	bfound = fastrpc_search_ctx((uint64_t)(rsp->ctx & ~1));
+	if (!bfound) {
+		pr_err("adsprpc: invalid context %pK\n", (void *)rsp->ctx);
+		goto bail;
 	}
+
+	rsp->ctx = rsp->ctx & ~1;
+	context_notify_user(uint64_to_ptr(rsp->ctx), rsp->retval);
+bail:
 	glink_rx_done(handle, ptr, true);
 }
 
@@ -1894,6 +1943,8 @@
 		return 0;
 	cid = fl->cid;
 
+	(void)fastrpc_release_current_dsp_process(fl);
+
 	spin_lock(&fl->apps->hlock);
 	hlist_del_init(&fl->hn);
 	spin_unlock(&fl->apps->hlock);
@@ -1902,7 +1953,6 @@
 		kfree(fl);
 		return 0;
 	}
-	(void)fastrpc_release_current_dsp_process(fl);
 	spin_lock(&fl->hlock);
 	fl->file_close = 1;
 	spin_unlock(&fl->hlock);
@@ -2226,6 +2276,7 @@
 	INIT_HLIST_HEAD(&fl->maps);
 	INIT_HLIST_HEAD(&fl->bufs);
 	INIT_HLIST_NODE(&fl->hn);
+	fl->sessionid = 0;
 	fl->tgid = current->tgid;
 	fl->apps = me;
 	fl->mode = FASTRPC_MODE_SERIAL;
@@ -2386,6 +2437,10 @@
 		case FASTRPC_MODE_PROFILE:
 			fl->profile = (uint32_t)ioctl_param;
 			break;
+		case FASTRPC_MODE_SESSION:
+			fl->sessionid = 1;
+			fl->tgid |= (1 << SESSION_ID_INDEX);
+			break;
 		default:
 			err = -ENOTTY;
 			break;
diff --git a/drivers/char/adsprpc_shared.h b/drivers/char/adsprpc_shared.h
index 9f964d2..2e8bfc2 100644
--- a/drivers/char/adsprpc_shared.h
+++ b/drivers/char/adsprpc_shared.h
@@ -52,6 +52,9 @@
 /* Driver should operate in profile mode with the co-processor */
 #define FASTRPC_MODE_PROFILE     2
 
+/* Set FastRPC session ID to 1 */
+#define FASTRPC_MODE_SESSION     4
+
 /* INIT a new process or attach to guestos */
 #define FASTRPC_INIT_ATTACH      0
 #define FASTRPC_INIT_CREATE      1
diff --git a/drivers/char/diag/diag_masks.c b/drivers/char/diag/diag_masks.c
index d734e29..ee76d39 100644
--- a/drivers/char/diag/diag_masks.c
+++ b/drivers/char/diag/diag_masks.c
@@ -1982,7 +1982,8 @@
 
 void diag_send_updates_peripheral(uint8_t peripheral)
 {
-	diag_send_feature_mask_update(peripheral);
+	if (!driver->feature[peripheral].sent_feature_mask)
+		diag_send_feature_mask_update(peripheral);
 	/*
 	 * Masks (F3, logs and events) will be sent to
 	 * peripheral immediately following feature mask update only
diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h
index ac3c1fd..c9ae689 100644
--- a/drivers/char/diag/diagchar.h
+++ b/drivers/char/diag/diagchar.h
@@ -21,7 +21,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/sched.h>
-#include <linux/wakelock.h>
+#include <linux/device.h>
 #include <linux/atomic.h>
 #include "diagfwd_bridge.h"
 
diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c
index 18f941d..543f0a2 100644
--- a/drivers/char/diag/diagchar_core.c
+++ b/drivers/char/diag/diagchar_core.c
@@ -2368,7 +2368,9 @@
 		mutex_unlock(&driver->dci_mutex);
 		break;
 	case DIAG_IOCTL_DCI_EVENT_STATUS:
+		mutex_lock(&driver->dci_mutex);
 		result = diag_ioctl_dci_event_status(ioarg);
+		mutex_unlock(&driver->dci_mutex);
 		break;
 	case DIAG_IOCTL_DCI_CLEAR_LOGS:
 		mutex_lock(&driver->dci_mutex);
diff --git a/drivers/char/diag/diagfwd_bridge.c b/drivers/char/diag/diagfwd_bridge.c
index 3684b8d..5de7897 100644
--- a/drivers/char/diag/diagfwd_bridge.c
+++ b/drivers/char/diag/diagfwd_bridge.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -90,6 +90,18 @@
 {
 	if (id < 0 || id >= NUM_REMOTE_DEV)
 		return -EINVAL;
+
+	if ((mode == DIAG_USB_MODE &&
+		driver->logging_mode == DIAG_MEMORY_DEVICE_MODE) ||
+		(mode == DIAG_MEMORY_DEVICE_MODE &&
+		driver->logging_mode == DIAG_USB_MODE)) {
+		/*
+		 * Don't close the MHI channels when usb is disconnected
+		 * and a process is running in memory device mode.
+		 */
+		return 0;
+	}
+
 	if (bridge_info[id].dev_ops && bridge_info[id].dev_ops->close)
 		bridge_info[id].dev_ops->close(bridge_info[id].ctxt);
 	return 0;
diff --git a/drivers/char/diag/diagfwd_cntl.c b/drivers/char/diag/diagfwd_cntl.c
index d7e24fc..710271e 100644
--- a/drivers/char/diag/diagfwd_cntl.c
+++ b/drivers/char/diag/diagfwd_cntl.c
@@ -729,8 +729,9 @@
 	struct diagfwd_info *fwd_info_cmd = NULL;
 	char *process_name = NULL;
 	int err = 0;
+	char *root_str = NULL;
 	uint8_t local_diag_id = 0;
-	uint8_t new_request = 0;
+	uint8_t new_request = 0, i = 0;
 
 	if (!buf || len == 0 || peripheral >= NUM_PERIPHERALS)
 		return;
@@ -753,19 +754,26 @@
 		ctrl_pkt.diag_id = diag_id;
 		new_request = 1;
 	}
+	root_str = strnstr(process_name, DIAG_ID_ROOT_STRING,
+		strlen(process_name));
 
 	if (new_request) {
 		fwd_info_data->num_pd++;
 		fwd_info_cmd->num_pd++;
-	}
+		if (root_str) {
+			fwd_info_cmd->diagid_root = ctrl_pkt.diag_id;
+			fwd_info_data->diagid_root = ctrl_pkt.diag_id;
+		} else {
+			i = fwd_info_cmd->num_pd - 2;
+			if (i >= 0 && i < MAX_PERIPHERAL_UPD)
+				fwd_info_cmd->diagid_user[i] =
+				ctrl_pkt.diag_id;
 
-	if (strnstr(process_name, DIAG_ID_ROOT_STRING, strlen(process_name))) {
-		fwd_info_cmd->diagid_root = diag_id;
-		fwd_info_data->diagid_root = diag_id;
-		driver->diag_id_sent[peripheral] = 0;
-	} else {
-		fwd_info_cmd->diagid_user[fwd_info_cmd->num_pd - 2] = diag_id;
-		fwd_info_data->diagid_user[fwd_info_data->num_pd - 2] = diag_id;
+			i = fwd_info_data->num_pd - 2;
+			if (i >= 0 && i < MAX_PERIPHERAL_UPD)
+				fwd_info_data->diagid_user[i] =
+				ctrl_pkt.diag_id;
+		}
 	}
 
 	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
@@ -784,18 +792,24 @@
 		pr_err("diag: Unable to send diag id ctrl packet to peripheral %d, err: %d\n",
 		       peripheral, err);
 	} else {
-	/*
-	 * Masks (F3, logs and events) will be sent to
-	 * peripheral immediately following feature mask update only
-	 * if diag_id support is not present or
-	 * diag_id support is present and diag_id has been sent to
-	 * peripheral.
-	 * With diag_id being sent now, mask will be updated
-	 * to peripherals.
-	 */
-		driver->diag_id_sent[peripheral] = 1;
-		diag_send_updates_peripheral(peripheral);
+		/*
+		 * Masks (F3, logs and events) will be sent to
+		 * peripheral immediately following feature mask update only
+		 * if diag_id support is not present or
+		 * diag_id support is present and diag_id has been sent to
+		 * peripheral.
+		 * With diag_id being sent now, mask will be updated
+		 * to peripherals.
+		 */
+		if (root_str) {
+			driver->diag_id_sent[peripheral] = 1;
+			diag_send_updates_peripheral(peripheral);
+		}
 		diagfwd_buffers_init(fwd_info_data);
+		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
+		"diag: diag_id sent = %d to peripheral = %d with diag_id = %d for %s :\n",
+			driver->diag_id_sent[peripheral], peripheral,
+			ctrl_pkt.diag_id, process_name);
 	}
 }
 
diff --git a/drivers/char/diag/diagfwd_peripheral.c b/drivers/char/diag/diagfwd_peripheral.c
index 955d81f..e00a61d 100644
--- a/drivers/char/diag/diagfwd_peripheral.c
+++ b/drivers/char/diag/diagfwd_peripheral.c
@@ -497,6 +497,19 @@
 					fwd_info->upd_len[i][1] = 0;
 			}
 		}
+
+		if (flag_buf_1) {
+			fwd_info->cpd_len_1 = len_cpd;
+			for (i = 0; i <= (fwd_info->num_pd - 2); i++)
+				if (fwd_info->type == TYPE_DATA)
+					fwd_info->upd_len[i][0] = len_upd[i];
+		} else if (flag_buf_2) {
+			fwd_info->cpd_len_2 = len_cpd;
+			for (i = 0; i <= (fwd_info->num_pd - 2); i++)
+				if (fwd_info->type == TYPE_DATA)
+					fwd_info->upd_len[i][1] = len_upd[i];
+		}
+
 		if (len_cpd) {
 			if (flag_buf_1)
 				fwd_info->cpd_len_1 = len_cpd;
@@ -1004,16 +1017,7 @@
 		dest_info->buf_ptr[i] = fwd_info->buf_ptr[i];
 	if (!check_channel_state(dest_info->ctxt))
 		diagfwd_late_open(dest_info);
-
-	/*
-	 *	Open control channel to update masks after buffers are
-	 *	initialized for peripherals that have transport other than
-	 *	GLINK. GLINK supported peripheral mask update will
-	 *	happen after glink buffers are initialized.
-	 */
-
-	if (dest_info->transport != TRANSPORT_GLINK)
-		diagfwd_cntl_open(dest_info);
+	diagfwd_cntl_open(dest_info);
 	init_fn(peripheral);
 	mutex_unlock(&driver->diagfwd_channel_mutex[peripheral]);
 	diagfwd_queue_read(&peripheral_info[TYPE_DATA][peripheral]);
@@ -1067,7 +1071,7 @@
 		return -ENODEV;
 
 	if (type == TYPE_CMD) {
-		if (driver->feature[peripheral].untag_header)
+		if (driver->feature[peripheral].diag_id_support)
 			if (!fwd_info->diagid_root ||
 				(!driver->diag_id_sent[peripheral])) {
 			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
@@ -1208,15 +1212,11 @@
 	diagfwd_buffers_init(fwd_info);
 
 	/*
-	 *	Initialize buffers for glink supported
-	 *	peripherals only. Open control channel to update
-	 *	masks after buffers are initialized.
+	 * Initialize buffers for glink supported
+	 * peripherals only.
 	 */
-	if (fwd_info->transport == TRANSPORT_GLINK) {
+	if (fwd_info->transport == TRANSPORT_GLINK)
 		diagfwd_write_buffers_init(fwd_info);
-		if (fwd_info->type == TYPE_CNTL)
-			diagfwd_cntl_open(fwd_info);
-	}
 
 	if (fwd_info && fwd_info->c_ops && fwd_info->c_ops->open)
 		fwd_info->c_ops->open(fwd_info);
@@ -1294,7 +1294,7 @@
 
 void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
 {
-	int i = 0;
+	int i = 0, upd_valid_len = 0;
 	struct diagfwd_info *fwd_info = NULL;
 
 	if (peripheral >= NUM_PERIPHERALS || type >= NUM_TYPES)
@@ -1306,12 +1306,26 @@
 
 	if (ctxt == 1 && fwd_info->buf_1) {
 		/* Buffer 1 for core PD is freed */
-		atomic_set(&fwd_info->buf_1->in_busy, 0);
 		fwd_info->cpd_len_1 = 0;
+		for (i = 0; i <= (fwd_info->num_pd - 2); i++) {
+			if (fwd_info->upd_len[i][0]) {
+				upd_valid_len = 1;
+				break;
+			}
+		}
+		if (!upd_valid_len)
+			atomic_set(&fwd_info->buf_1->in_busy, 0);
 	} else if (ctxt == 2 && fwd_info->buf_2) {
 		/* Buffer 2 for core PD is freed */
-		atomic_set(&fwd_info->buf_2->in_busy, 0);
 		fwd_info->cpd_len_2 = 0;
+		for (i = 0; i <= (fwd_info->num_pd - 2); i++) {
+			if (fwd_info->upd_len[i][1]) {
+				upd_valid_len = 1;
+				break;
+			}
+		}
+		if (!upd_valid_len)
+			atomic_set(&fwd_info->buf_2->in_busy, 0);
 	} else if (ctxt >= 3 && (ctxt % 2)) {
 		for (i = 0; i <= (fwd_info->num_pd - 2); i++) {
 			if (fwd_info->buf_upd[i][0]) {
@@ -1574,10 +1588,11 @@
 							fwd_info->type, 2);
 		}
 
-		if (driver->feature[fwd_info->peripheral].untag_header)
+		if (driver->feature[fwd_info->peripheral].untag_header) {
 			ret = diagfwd_buffers_allocate(fwd_info);
 			if (ret)
 				goto err;
+		}
 
 		if (driver->supports_apps_hdlc_encoding) {
 			/* In support of hdlc encoding */
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 4facc75..9093110 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -1162,10 +1162,11 @@
 			ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
 			ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
 		} else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
-			/* Set a long timer to let the reboot happens, but
-			   reboot if it hangs, but only if the watchdog
+			/* Set a long timer to let the reboot happen or
+			   reset if it hangs, but only if the watchdog
 			   timer was already running. */
-			timeout = 120;
+			if (timeout < 120)
+				timeout = 120;
 			pretimeout = 0;
 			ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
 			ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5638333..4f2fb77 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2712,9 +2712,10 @@
 	struct clk_core *core;
 	int cnt = 0;
 
-	clock_debug_output(s, 0, "Enabled clocks:\n");
+	if (!mutex_trylock(&clk_debug_lock))
+		return;
 
-	mutex_lock(&clk_debug_lock);
+	clock_debug_output(s, 0, "Enabled clocks:\n");
 
 	hlist_for_each_entry(core, &clk_debug_list, debug_node)
 		cnt += clock_debug_print_clock(core, s);
@@ -3037,14 +3038,19 @@
 
 /*
  * Print the names of all enabled clocks and their parents if
- * debug_suspend is set from debugfs.
+ * debug_suspend is set from debugfs along with print_parent flag set to 1.
+ * Otherwise if print_parent set to 0, print only enabled clocks
+ *
  */
-void clock_debug_print_enabled(void)
+void clock_debug_print_enabled(bool print_parent)
 {
 	if (likely(!debug_suspend))
 		return;
 
-	clock_debug_print_enabled_debug_suspend(NULL);
+	if (print_parent)
+		clock_debug_print_enabled_clocks(NULL);
+	else
+		clock_debug_print_enabled_debug_suspend(NULL);
 }
 EXPORT_SYMBOL_GPL(clock_debug_print_enabled);
 
diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h
index b52aa25..a7d0981 100644
--- a/drivers/clk/clk.h
+++ b/drivers/clk/clk.h
@@ -23,7 +23,7 @@
 void __clk_free_clk(struct clk *clk);
 
 /* Debugfs API to print the enabled clocks */
-void clock_debug_print_enabled(void);
+void clock_debug_print_enabled(bool print_parent);
 void clk_debug_print_hw(struct clk_core *clk, struct seq_file *f);
 
 #else
diff --git a/drivers/clk/qcom/camcc-sdm845.c b/drivers/clk/qcom/camcc-sdm845.c
index 1984d4a..5caa975 100644
--- a/drivers/clk/qcom/camcc-sdm845.c
+++ b/drivers/clk/qcom/camcc-sdm845.c
@@ -442,7 +442,7 @@
 	.mnd_width = 0,
 	.hid_width = 5,
 	.parent_map = cam_cc_parent_map_0,
-	.freq_tbl = NULL,
+	.freq_tbl = ftbl_cam_cc_csi0phytimer_clk_src,
 	.clkr.hw.init = &(struct clk_init_data){
 		.name = "cam_cc_csi3phytimer_clk_src",
 		.parent_names = cam_cc_parent_names_0,
@@ -1959,6 +1959,7 @@
 static const struct of_device_id cam_cc_sdm845_match_table[] = {
 	{ .compatible = "qcom,cam_cc-sdm845" },
 	{ .compatible = "qcom,cam_cc-sdm845-v2" },
+	{ .compatible = "qcom,cam_cc-sdm670" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, cam_cc_sdm845_match_table);
@@ -1972,6 +1973,7 @@
 		&cam_cc_csi3phytimer_clk_src.clkr;
 	cam_cc_cphy_rx_clk_src.freq_tbl = ftbl_cam_cc_cphy_rx_clk_src_sdm845_v2;
 	cam_cc_cphy_rx_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = 384000000;
+	cam_cc_cphy_rx_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 384000000;
 	cam_cc_fd_core_clk_src.freq_tbl = ftbl_cam_cc_fd_core_clk_src_sdm845_v2;
 	cam_cc_fd_core_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = 384000000;
 	cam_cc_icp_clk_src.freq_tbl = ftbl_cam_cc_icp_clk_src_sdm845_v2;
@@ -1984,6 +1986,14 @@
 	cam_cc_lrme_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] = 320000000;
 	cam_cc_lrme_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] = 400000000;
 	cam_cc_slow_ahb_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = 80000000;
+	cam_cc_slow_ahb_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 80000000;
+	cam_cc_slow_ahb_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		80000000;
+}
+
+static void cam_cc_sdm845_fixup_sdm670(void)
+{
+	cam_cc_sdm845_fixup_sdm845v2();
 }
 
 static int cam_cc_sdm845_fixup(struct platform_device *pdev)
@@ -1997,6 +2007,8 @@
 
 	if (!strcmp(compat, "qcom,cam_cc-sdm845-v2"))
 		cam_cc_sdm845_fixup_sdm845v2();
+	else if (!strcmp(compat, "qcom,cam_cc-sdm670"))
+		cam_cc_sdm845_fixup_sdm670();
 
 	return 0;
 }
diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c
index e7d3ee4..afb2c01 100644
--- a/drivers/clk/qcom/clk-alpha-pll.c
+++ b/drivers/clk/qcom/clk-alpha-pll.c
@@ -459,6 +459,37 @@
 	}
 }
 
+static int clk_fabia_pll_latch_input(struct clk_alpha_pll *pll,
+					struct regmap *regmap)
+{
+	u32 regval;
+	int ret = 0;
+
+	/* Latch the PLL input */
+	ret = regmap_update_bits(regmap, pll->offset + PLL_MODE,
+			   FABIA_PLL_UPDATE, FABIA_PLL_UPDATE);
+	if (ret)
+		return ret;
+
+	/* Wait for 2 reference cycles before checking the ACK bit. */
+	udelay(1);
+	regmap_read(regmap, pll->offset + PLL_MODE, &regval);
+	if (!(regval & FABIA_PLL_ACK_LATCH)) {
+		WARN(1, "clk: PLL latch failed. Output may be unstable!\n");
+		return -EINVAL;
+	}
+
+	/* Return the latch input to 0 */
+	ret = regmap_update_bits(regmap, pll->offset + PLL_MODE,
+			   FABIA_PLL_UPDATE, 0);
+	if (ret)
+		return ret;
+
+	/* Wait for PLL output to stabilize */
+	udelay(100);
+	return ret;
+}
+
 void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 				const struct pll_config *config)
 {
@@ -471,6 +502,7 @@
 	if (config->frac)
 		regmap_write(regmap, pll->offset + FABIA_FRAC_VAL,
 						config->frac);
+
 	if (config->config_ctl_val)
 		regmap_write(regmap, pll->offset + PLL_CONFIG_CTL,
 				config->config_ctl_val);
@@ -482,6 +514,14 @@
 					mask, val);
 	}
 
+	/*
+	 * If the PLL has already been initialized, it would now be in a STANDBY
+	 * state. Any new updates to the PLL frequency will require setting the
+	 * PLL_UPDATE bit.
+	 */
+	if (pll->inited)
+		clk_fabia_pll_latch_input(pll, regmap);
+
 	regmap_update_bits(regmap, pll->offset + PLL_MODE,
 				 FABIA_PLL_HW_UPDATE_LOGIC_BYPASS,
 				 FABIA_PLL_HW_UPDATE_LOGIC_BYPASS);
@@ -627,29 +667,8 @@
 	regmap_write(pll->clkr.regmap, off + PLL_L_VAL, l);
 	regmap_write(pll->clkr.regmap, off + FABIA_FRAC_VAL, a);
 
-	/* Latch the PLL input */
-	ret = regmap_update_bits(pll->clkr.regmap, off + PLL_MODE,
-			   FABIA_PLL_UPDATE, FABIA_PLL_UPDATE);
-	if (ret)
-		return ret;
-
-	/* Wait for 2 reference cycles before checking the ACK bit. */
-	udelay(1);
-	regmap_read(pll->clkr.regmap, off + PLL_MODE, &regval);
-	if (!(regval & FABIA_PLL_ACK_LATCH)) {
-		WARN(1, "clk: PLL latch failed. Output may be unstable!\n");
-		return -EINVAL;
-	}
-
-	/* Return the latch input to 0 */
-	ret = regmap_update_bits(pll->clkr.regmap, off + PLL_MODE,
-			   FABIA_PLL_UPDATE, 0);
-	if (ret)
-		return ret;
-
-	/* Wait for PLL output to stabilize */
-	udelay(100);
-	return 0;
+	ret = clk_fabia_pll_latch_input(pll, pll->clkr.regmap);
+	return ret;
 }
 
 static void clk_fabia_pll_list_registers(struct seq_file *f, struct clk_hw *hw)
diff --git a/drivers/clk/qcom/clk-aop-qmp.c b/drivers/clk/qcom/clk-aop-qmp.c
index ff229fb..e2bfe42 100644
--- a/drivers/clk/qcom/clk-aop-qmp.c
+++ b/drivers/clk/qcom/clk-aop-qmp.c
@@ -139,6 +139,12 @@
 	struct clk_aop_qmp *clk = to_aop_qmp_clk(hw);
 
 	mutex_lock(&clk_aop_lock);
+	/*
+	 * Return early if the clock has been enabled already. This
+	 * is to avoid issues with sending duplicate enable requests.
+	 */
+	if (clk->enabled)
+		goto err;
 
 	if (clk->level)
 		rate = clk->level;
@@ -179,6 +185,9 @@
 
 	mutex_lock(&clk_aop_lock);
 
+	if (!clk->enabled)
+		goto err;
+
 	rate = clk->disable_state;
 
 	snprintf(mbox_msg, MAX_LEN, "{class: %s, res: %s, val: %ld}",
diff --git a/drivers/clk/qcom/clk-cpu-osm.c b/drivers/clk/qcom/clk-cpu-osm.c
index 258a6f2..93a08db 100644
--- a/drivers/clk/qcom/clk-cpu-osm.c
+++ b/drivers/clk/qcom/clk-cpu-osm.c
@@ -2060,7 +2060,7 @@
 			last_entry = true;
 		}
 	}
-	fmax_temp[k] = abs_fmax;
+	fmax_temp[k++] = abs_fmax;
 
 	osm_clks_init[c->cluster_num].rate_max = devm_kzalloc(&pdev->dev,
 						 k * sizeof(unsigned long),
diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
index 7f56fb6..60758b4 100644
--- a/drivers/clk/qcom/clk-rcg.h
+++ b/drivers/clk/qcom/clk-rcg.h
@@ -23,8 +23,6 @@
 	u8 pre_div;
 	u16 m;
 	u16 n;
-	unsigned long src_freq;
-#define FIXED_FREQ_SRC   0
 };
 
 /**
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index 7382cfa..8d5e527 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -281,10 +281,9 @@
 		const struct freq_tbl *f, struct clk_rate_request *req)
 {
 	unsigned long clk_flags, rate = req->rate;
-	struct clk_rate_request parent_req = { };
 	struct clk_hw *p;
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
-	int index, ret = 0;
+	int index;
 
 	f = qcom_find_freq(f, rate);
 	if (!f)
@@ -315,21 +314,6 @@
 	req->best_parent_rate = rate;
 	req->rate = f->freq;
 
-	if (f->src_freq != FIXED_FREQ_SRC) {
-		rate = parent_req.rate = f->src_freq;
-		parent_req.best_parent_hw = p;
-		ret = __clk_determine_rate(p, &parent_req);
-		if (ret)
-			return ret;
-
-		ret = clk_set_rate(p->clk, parent_req.rate);
-		if (ret) {
-			pr_err("Failed set rate(%lu) on parent for non-fixed source\n",
-							parent_req.rate);
-			return ret;
-		}
-	}
-
 	return 0;
 }
 
diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index e1cda90..2109132 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -317,10 +317,32 @@
 
 static const struct of_device_id clk_rpmh_match_table[] = {
 	{ .compatible = "qcom,rpmh-clk-sdm845", .data = &clk_rpmh_sdm845},
+	{ .compatible = "qcom,rpmh-clk-sdm670", .data = &clk_rpmh_sdm845},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, clk_rpmh_match_table);
 
+static void clk_rpmh_sdm670_fixup_sdm670(void)
+{
+	sdm845_rpmh_clocks[RPMH_RF_CLK3] = NULL;
+	sdm845_rpmh_clocks[RPMH_RF_CLK3_A] = NULL;
+}
+
+static int clk_rpmh_sdm670_fixup(struct platform_device *pdev)
+{
+	const char *compat = NULL;
+	int compatlen = 0;
+
+	compat = of_get_property(pdev->dev.of_node, "compatible", &compatlen);
+	if (!compat || (compatlen <= 0))
+		return -EINVAL;
+
+	if (!strcmp(compat, "qcom,rpmh-clk-sdm670"))
+		clk_rpmh_sdm670_fixup_sdm670();
+
+	return 0;
+}
+
 static int clk_rpmh_probe(struct platform_device *pdev)
 {
 	struct clk **clks;
@@ -388,6 +410,10 @@
 		goto err2;
 	}
 
+	ret = clk_rpmh_sdm670_fixup(pdev);
+	if (ret)
+		return ret;
+
 	hw_clks = desc->clks;
 	num_clks = desc->num_clks;
 
@@ -404,6 +430,11 @@
 	data->clk_num = num_clks;
 
 	for (i = 0; i < num_clks; i++) {
+		if (!hw_clks[i]) {
+			clks[i] = ERR_PTR(-ENOENT);
+			continue;
+		}
+
 		rpmh_clk = to_clk_rpmh(hw_clks[i]);
 		rpmh_clk->res_addr = cmd_db_get_addr(rpmh_clk->res_name);
 		if (!rpmh_clk->res_addr) {
diff --git a/drivers/clk/qcom/debugcc-sdm845.c b/drivers/clk/qcom/debugcc-sdm845.c
index cb0cadd..be84b46 100644
--- a/drivers/clk/qcom/debugcc-sdm845.c
+++ b/drivers/clk/qcom/debugcc-sdm845.c
@@ -117,6 +117,7 @@
 	"gcc_aggre_ufs_phy_axi_clk",
 	"gcc_aggre_usb3_prim_axi_clk",
 	"gcc_aggre_usb3_sec_axi_clk",
+	"gcc_apc_vs_clk",
 	"gcc_boot_rom_ahb_clk",
 	"gcc_camera_ahb_clk",
 	"gcc_camera_axi_clk",
@@ -144,12 +145,14 @@
 	"gcc_gpu_gpll0_div_clk_src",
 	"gcc_gpu_memnoc_gfx_clk",
 	"gcc_gpu_snoc_dvm_gfx_clk",
+	"gcc_gpu_vs_clk",
 	"gcc_mss_axis2_clk",
 	"gcc_mss_cfg_ahb_clk",
 	"gcc_mss_gpll0_div_clk_src",
 	"gcc_mss_mfab_axis_clk",
 	"gcc_mss_q6_memnoc_axi_clk",
 	"gcc_mss_snoc_axi_clk",
+	"gcc_mss_vs_clk",
 	"gcc_pcie_0_aux_clk",
 	"gcc_pcie_0_cfg_ahb_clk",
 	"gcc_pcie_0_mstr_axi_clk",
@@ -232,9 +235,17 @@
 	"gcc_usb3_sec_phy_com_aux_clk",
 	"gcc_usb3_sec_phy_pipe_clk",
 	"gcc_usb_phy_cfg_ahb2phy_clk",
+	"gcc_vdda_vs_clk",
+	"gcc_vddcx_vs_clk",
+	"gcc_vddmx_vs_clk",
 	"gcc_video_ahb_clk",
 	"gcc_video_axi_clk",
 	"gcc_video_xo_clk",
+	"gcc_vs_ctrl_ahb_clk",
+	"gcc_vs_ctrl_clk",
+	"gcc_sdcc1_ahb_clk",
+	"gcc_sdcc1_apps_clk",
+	"gcc_sdcc1_ice_core_clk",
 	"gpu_cc_acd_cxo_clk",
 	"gpu_cc_ahb_clk",
 	"gpu_cc_crc_ahb_clk",
@@ -449,6 +460,8 @@
 			0x11B, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_aggre_usb3_sec_axi_clk", 0x11C, 4, GCC,
 			0x11C, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_apc_vs_clk", 0x113, 4, GCC,
+			0x113, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_boot_rom_ahb_clk", 0x94, 4, GCC,
 			0x94, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_camera_ahb_clk", 0x3A, 4, GCC,
@@ -503,6 +516,8 @@
 			0x145, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_gpu_snoc_dvm_gfx_clk", 0x147, 4, GCC,
 			0x147, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_gpu_vs_clk", 0x112, 4, GCC,
+			0x112, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_mss_axis2_clk", 0x12F, 4, GCC,
 			0x12F, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_mss_cfg_ahb_clk", 0x12D, 4, GCC,
@@ -515,6 +530,8 @@
 			0x135, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_mss_snoc_axi_clk", 0x134, 4, GCC,
 			0x134, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_mss_vs_clk", 0x111, 4, GCC,
+			0x111, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_pcie_0_aux_clk", 0xE5, 4, GCC,
 			0xE5, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_pcie_0_cfg_ahb_clk", 0xE4, 4, GCC,
@@ -679,12 +696,28 @@
 			0x6A, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_usb_phy_cfg_ahb2phy_clk", 0x6F, 4, GCC,
 			0x6F, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_vdda_vs_clk", 0x10E, 4, GCC,
+			0x10E, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_vddcx_vs_clk", 0x10C, 4, GCC,
+			0x10C, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_vddmx_vs_clk", 0x10D, 4, GCC,
+			0x10D, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_video_ahb_clk", 0x39, 4, GCC,
 			0x39, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_video_axi_clk", 0x3F, 4, GCC,
 			0x3F, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gcc_video_xo_clk", 0x42, 4, GCC,
 			0x42, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_vs_ctrl_ahb_clk", 0x110, 4, GCC,
+			0x110, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_vs_ctrl_clk", 0x10F, 4, GCC,
+			0x10F, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_sdcc1_ahb_clk", 0x15C, 4, GCC,
+			0x42, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_sdcc1_apps_clk", 0x15B, 4, GCC,
+			0x42, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
+		{ "gcc_sdcc1_ice_core_clk", 0x15D, 4, GCC,
+			0x42, 0x3FF, 0, 0xF, 0, 4, 0x62008, 0x62000, 0x62004 },
 		{ "gpu_cc_acd_cxo_clk", 0x144, 4, GPU_CC,
 			0x1F, 0xFF, 0, 0x3, 0, 1, 0x1568, 0x10FC, 0x1100 },
 		{ "gpu_cc_ahb_clk", 0x144, 4, GPU_CC,
diff --git a/drivers/clk/qcom/dispcc-sdm845.c b/drivers/clk/qcom/dispcc-sdm845.c
index 53bfe77..3b13c9b 100644
--- a/drivers/clk/qcom/dispcc-sdm845.c
+++ b/drivers/clk/qcom/dispcc-sdm845.c
@@ -40,8 +40,6 @@
 #define DISP_CC_MISC_CMD	0x8000
 
 #define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
-#define F_SLEW(f, s, h, m, n, src_freq) { (f), (s), (2 * (h) - 1), (m), (n), \
-					(src_freq) }
 
 static DEFINE_VDD_REGULATORS(vdd_cx, VDD_CX_NUM, 1, vdd_corner);
 
@@ -385,6 +383,20 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src_sdm670[] = {
+	F(19200000, P_BI_TCXO, 1, 0, 0),
+	F(85714286, P_GPLL0_OUT_MAIN, 7, 0, 0),
+	F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
+	F(150000000, P_GPLL0_OUT_MAIN, 4, 0, 0),
+	F(171428571, P_GPLL0_OUT_MAIN, 3.5, 0, 0),
+	F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
+	F(286670000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
+	F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
+	F(344000000, P_DISP_CC_PLL0_OUT_MAIN, 2.5, 0, 0),
+	F(430000000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
 	.cmd_rcgr = 0x2088,
 	.mnd_width = 0,
@@ -1014,6 +1026,7 @@
 static const struct of_device_id disp_cc_sdm845_match_table[] = {
 	{ .compatible = "qcom,dispcc-sdm845" },
 	{ .compatible = "qcom,dispcc-sdm845-v2" },
+	{ .compatible = "qcom,dispcc-sdm670" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, disp_cc_sdm845_match_table);
@@ -1021,23 +1034,23 @@
 static void disp_cc_sdm845_fixup_sdm845v2(struct regmap *regmap)
 {
 	clk_fabia_pll_configure(&disp_cc_pll0, regmap,
-					&disp_cc_pll0_config_v2);
+		&disp_cc_pll0_config_v2);
 	disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] =
 		180000000;
 	disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
 		275000000;
 	disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
-		358000000;
+		328580000;
 	disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] =
 		180000000;
 	disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
 		275000000;
 	disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
-		358000000;
+		328580000;
 	disp_cc_mdss_dp_pixel1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
-		337500000;
+		337500;
 	disp_cc_mdss_dp_pixel_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
-		337500000;
+		337500;
 	disp_cc_mdss_mdp_clk_src.freq_tbl =
 		ftbl_disp_cc_mdss_mdp_clk_src_sdm845_v2;
 	disp_cc_mdss_mdp_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] =
@@ -1050,10 +1063,14 @@
 		280000000;
 	disp_cc_mdss_pclk0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
 		430000000;
+	disp_cc_mdss_pclk0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		430000000;
 	disp_cc_mdss_pclk1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] =
 		280000000;
 	disp_cc_mdss_pclk1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] =
 		430000000;
+	disp_cc_mdss_pclk1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		430000000;
 	disp_cc_mdss_rot_clk_src.freq_tbl =
 		ftbl_disp_cc_mdss_rot_clk_src_sdm845_v2;
 	disp_cc_mdss_rot_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] =
@@ -1064,6 +1081,18 @@
 		430000000;
 }
 
+static void disp_cc_sdm845_fixup_sdm670(struct regmap *regmap)
+{
+	disp_cc_sdm845_fixup_sdm845v2(regmap);
+
+	disp_cc_mdss_mdp_clk_src.freq_tbl =
+		ftbl_disp_cc_mdss_mdp_clk_src_sdm670;
+	disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		358000000;
+	disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		358000000;
+}
+
 static int disp_cc_sdm845_fixup(struct platform_device *pdev,
 						struct regmap *regmap)
 {
@@ -1076,6 +1105,8 @@
 
 	if (!strcmp(compat, "qcom,dispcc-sdm845-v2"))
 		disp_cc_sdm845_fixup_sdm845v2(regmap);
+	else if (!strcmp(compat, "qcom,dispcc-sdm670"))
+		disp_cc_sdm845_fixup_sdm670(regmap);
 
 	return 0;
 }
diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c
index 17b2403..4142dd5 100644
--- a/drivers/clk/qcom/gcc-sdm845.c
+++ b/drivers/clk/qcom/gcc-sdm845.c
@@ -198,6 +198,22 @@
 	"core_bi_pll_test_se",
 };
 
+static const struct parent_map gcc_parent_map_7[] = {
+	{ P_BI_TCXO, 0 },
+	{ P_GPLL0_OUT_MAIN, 1 },
+	{ P_GPLL6_OUT_MAIN, 2 },
+	{ P_GPLL0_OUT_EVEN, 6 },
+	{ P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_11[] = {
+	"bi_tcxo",
+	"gpll0",
+	"gpll6",
+	"gpll0_out_even",
+	"core_bi_pll_test_se",
+};
+
 static struct clk_dummy measure_only_snoc_clk = {
 	.rrate = 1000,
 	.hw.init = &(struct clk_init_data){
@@ -301,6 +317,28 @@
 	},
 };
 
+static struct clk_alpha_pll gpll6 = {
+	.offset = 0x13000,
+	.vco_table = fabia_vco,
+	.num_vco = ARRAY_SIZE(fabia_vco),
+	.type = FABIA_PLL,
+	.clkr = {
+		.enable_reg = 0x52000,
+		.enable_mask = BIT(6),
+		.hw.init = &(struct clk_init_data){
+			.name = "gpll6",
+			.parent_names = (const char *[]){ "bi_tcxo" },
+			.num_parents = 1,
+			.ops = &clk_fabia_fixed_pll_ops,
+			VDD_CX_FMAX_MAP4(
+				MIN, 615000000,
+				LOW, 1066000000,
+				LOW_L1, 1600000000,
+				NOMINAL, 2000000000),
+		},
+	},
+};
+
 static const struct freq_tbl ftbl_gcc_cpuss_ahb_clk_src[] = {
 	F(19200000, P_BI_TCXO, 1, 0, 0),
 	{ }
@@ -330,6 +368,12 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_gcc_cpuss_rbcpr_clk_src_sdm670[] = {
+	F(19200000, P_BI_TCXO, 1, 0, 0),
+	F(50000000, P_GPLL0_OUT_MAIN, 12, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 gcc_cpuss_rbcpr_clk_src = {
 	.cmd_rcgr = 0x4815c,
 	.mnd_width = 0,
@@ -862,6 +906,67 @@
 	},
 };
 
+static const struct freq_tbl ftbl_gcc_sdcc1_ice_core_clk_src[] = {
+	F(75000000, P_GPLL0_OUT_EVEN, 4, 0, 0),
+	F(150000000, P_GPLL0_OUT_MAIN, 4, 0, 0),
+	F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
+	F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
+	{ }
+};
+
+static struct clk_rcg2 gcc_sdcc1_ice_core_clk_src = {
+	.cmd_rcgr = 0x26010,
+	.mnd_width = 8,
+	.hid_width = 5,
+	.parent_map = gcc_parent_map_0,
+	.freq_tbl = ftbl_gcc_sdcc1_ice_core_clk_src,
+	.enable_safe_config = true,
+	.clkr.hw.init = &(struct clk_init_data){
+		.name = "gcc_sdcc1_ice_core_clk_src",
+		.parent_names = gcc_parent_names_0,
+		.num_parents = 4,
+		.flags = CLK_SET_RATE_PARENT,
+		.ops = &clk_rcg2_ops,
+		VDD_CX_FMAX_MAP3(
+			MIN, 75000000,
+			LOW, 150000000,
+			NOMINAL, 300000000),
+	},
+};
+
+static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk_src[] = {
+	F(144000, P_BI_TCXO, 16, 3, 25),
+	F(400000, P_BI_TCXO, 12, 1, 4),
+	F(20000000, P_GPLL0_OUT_EVEN, 5, 1, 3),
+	F(25000000, P_GPLL0_OUT_EVEN, 6, 1, 2),
+	F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),
+	F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
+	F(192000000, P_GPLL6_OUT_MAIN, 2, 0, 0),
+	F(384000000, P_GPLL6_OUT_MAIN, 1, 0, 0),
+	{ }
+};
+
+static struct clk_rcg2 gcc_sdcc1_apps_clk_src = {
+	.cmd_rcgr = 0x26028,
+	.mnd_width = 8,
+	.hid_width = 5,
+	.parent_map = gcc_parent_map_7,
+	.freq_tbl = ftbl_gcc_sdcc1_apps_clk_src,
+	.enable_safe_config = true,
+	.clkr.hw.init = &(struct clk_init_data){
+		.name = "gcc_sdcc1_apps_clk_src",
+		.parent_names = gcc_parent_names_11,
+		.num_parents = 5,
+		.flags = CLK_SET_RATE_PARENT,
+		.ops = &clk_rcg2_ops,
+		VDD_CX_FMAX_MAP4(
+			MIN, 19200000,
+			LOWER, 50000000,
+			LOW, 100000000,
+			NOMINAL, 384000000),
+	},
+};
+
 static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
 	F(400000, P_BI_TCXO, 12, 1, 4),
 	F(9600000, P_BI_TCXO, 2, 0, 0),
@@ -904,17 +1009,28 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_gcc_sdcc4_apps_clk_src_sdm670[] = {
+	F(400000, P_BI_TCXO, 12, 1, 4),
+	F(9600000, P_BI_TCXO, 2, 0, 0),
+	F(19200000, P_BI_TCXO, 1, 0, 0),
+	F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
+	F(33333333, P_GPLL0_OUT_EVEN, 9, 0, 0),
+	F(50000000, P_GPLL0_OUT_MAIN, 12, 0, 0),
+	F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 gcc_sdcc4_apps_clk_src = {
 	.cmd_rcgr = 0x1600c,
 	.mnd_width = 8,
 	.hid_width = 5,
-	.parent_map = gcc_parent_map_3,
+	.parent_map = gcc_parent_map_0,
 	.freq_tbl = ftbl_gcc_sdcc4_apps_clk_src,
 	.enable_safe_config = true,
 	.clkr.hw.init = &(struct clk_init_data){
 		.name = "gcc_sdcc4_apps_clk_src",
-		.parent_names = gcc_parent_names_3,
-		.num_parents = 3,
+		.parent_names = gcc_parent_names_0,
+		.num_parents = 4,
 		.flags = CLK_SET_RATE_PARENT,
 		.ops = &clk_rcg2_ops,
 		VDD_CX_FMAX_MAP4(
@@ -2700,6 +2816,55 @@
 	},
 };
 
+static struct clk_branch gcc_sdcc1_ice_core_clk = {
+	.halt_reg = 0x2600c,
+	.halt_check = BRANCH_HALT,
+	.clkr = {
+		.enable_reg = 0x2600c,
+		.enable_mask = BIT(0),
+		.hw.init = &(struct clk_init_data){
+			.name = "gcc_sdcc1_ice_core_clk",
+			.parent_names = (const char *[]){
+				"gcc_sdcc1_ice_core_clk_src",
+			},
+			.num_parents = 1,
+			.flags = CLK_SET_RATE_PARENT,
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
+static struct clk_branch gcc_sdcc1_ahb_clk = {
+	.halt_reg = 0x26008,
+	.halt_check = BRANCH_HALT,
+	.clkr = {
+		.enable_reg = 0x26008,
+		.enable_mask = BIT(0),
+		.hw.init = &(struct clk_init_data){
+			.name = "gcc_sdcc1_ahb_clk",
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
+static struct clk_branch gcc_sdcc1_apps_clk = {
+	.halt_reg = 0x26004,
+	.halt_check = BRANCH_HALT,
+	.clkr = {
+		.enable_reg = 0x26004,
+		.enable_mask = BIT(0),
+		.hw.init = &(struct clk_init_data){
+			.name = "gcc_sdcc1_apps_clk",
+			.parent_names = (const char *[]){
+				"gcc_sdcc1_apps_clk_src",
+			},
+			.num_parents = 1,
+			.flags = CLK_SET_RATE_PARENT,
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
 static struct clk_branch gcc_sdcc2_ahb_clk = {
 	.halt_reg = 0x14008,
 	.halt_check = BRANCH_HALT,
@@ -3824,6 +3989,12 @@
 	[GPLL0] = &gpll0.clkr,
 	[GPLL0_OUT_EVEN] = &gpll0_out_even.clkr,
 	[GPLL4] = &gpll4.clkr,
+	[GCC_SDCC1_AHB_CLK] = NULL,
+	[GCC_SDCC1_APPS_CLK] = NULL,
+	[GCC_SDCC1_ICE_CORE_CLK] = NULL,
+	[GCC_SDCC1_APPS_CLK_SRC] = NULL,
+	[GCC_SDCC1_ICE_CORE_CLK_SRC] = NULL,
+	[GPLL6] = NULL,
 };
 
 static const struct qcom_reset_map gcc_sdm845_resets[] = {
@@ -3853,6 +4024,7 @@
 	[GCC_USB_PHY_CFG_AHB2PHY_BCR] = { 0x6a000 },
 	[GCC_PCIE_0_PHY_BCR] = { 0x6c01c },
 	[GCC_PCIE_1_PHY_BCR] = { 0x8e01c },
+	[GCC_SDCC1_BCR] = { 0x26000 },
 };
 
 /* List of RCG clocks and corresponding flags requested for DFS Mode */
@@ -3899,6 +4071,7 @@
 static const struct of_device_id gcc_sdm845_match_table[] = {
 	{ .compatible = "qcom,gcc-sdm845" },
 	{ .compatible = "qcom,gcc-sdm845-v2" },
+	{ .compatible = "qcom,gcc-sdm670" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, gcc_sdm845_match_table);
@@ -4007,6 +4180,85 @@
 		240000000;
 	gcc_ufs_phy_axi_clk_src.freq_tbl =
 		ftbl_gcc_ufs_card_axi_clk_src_sdm845_v2;
+	gcc_vsensor_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 600000000;
+}
+
+static void gcc_sdm845_fixup_sdm670(void)
+{
+	gcc_sdm845_fixup_sdm845v2();
+
+	gcc_sdm845_clocks[GCC_SDCC1_AHB_CLK] = &gcc_sdcc1_ahb_clk.clkr;
+	gcc_sdm845_clocks[GCC_SDCC1_APPS_CLK] = &gcc_sdcc1_apps_clk.clkr;
+	gcc_sdm845_clocks[GCC_SDCC1_ICE_CORE_CLK] =
+					&gcc_sdcc1_ice_core_clk.clkr;
+	gcc_sdm845_clocks[GCC_SDCC1_APPS_CLK_SRC] =
+					&gcc_sdcc1_apps_clk_src.clkr;
+	gcc_sdm845_clocks[GCC_SDCC1_ICE_CORE_CLK_SRC] =
+					&gcc_sdcc1_ice_core_clk_src.clkr;
+	gcc_sdm845_clocks[GPLL6] = &gpll6.clkr;
+	gcc_sdm845_clocks[GCC_AGGRE_UFS_CARD_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_AGGRE_UFS_CARD_AXI_HW_CTL_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_AGGRE_USB3_SEC_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_AGGRE_NOC_PCIE_TBU_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_CFG_NOC_USB3_SEC_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_AUX_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_CFG_AHB_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_CLKREF_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_MSTR_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_PIPE_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_SLV_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_0_SLV_Q2A_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_AUX_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_CFG_AHB_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_CLKREF_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_MSTR_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_PIPE_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_SLV_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_1_SLV_Q2A_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_PHY_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_PHY_REFGEN_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_PCIE_PHY_REFGEN_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_AHB_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_AXI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_AXI_HW_CTL_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_AXI_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_CLKREF_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_ICE_CORE_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_ICE_CORE_HW_CTL_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_ICE_CORE_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_PHY_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_PHY_AUX_HW_CTL_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_PHY_AUX_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_RX_SYMBOL_0_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_RX_SYMBOL_1_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_TX_SYMBOL_0_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_UNIPRO_CORE_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_UNIPRO_CORE_HW_CTL_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_CARD_UNIPRO_CORE_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_UFS_PHY_RX_SYMBOL_1_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB30_SEC_MASTER_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB30_SEC_MASTER_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_USB30_SEC_MOCK_UTMI_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB30_SEC_MOCK_UTMI_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_USB30_SEC_SLEEP_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB3_SEC_CLKREF_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB3_SEC_PHY_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB3_SEC_PHY_AUX_CLK_SRC] = NULL;
+	gcc_sdm845_clocks[GCC_USB3_SEC_PHY_COM_AUX_CLK] = NULL;
+	gcc_sdm845_clocks[GCC_USB3_SEC_PHY_PIPE_CLK] = NULL;
+
+	gcc_cpuss_rbcpr_clk_src.freq_tbl = ftbl_gcc_cpuss_rbcpr_clk_src_sdm670;
+	gcc_cpuss_rbcpr_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] =
+		50000000;
+	gcc_sdcc2_apps_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = 50000000;
+	gcc_sdcc2_apps_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		100000000;
+	gcc_sdcc2_apps_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] =
+		201500000;
+	gcc_sdcc4_apps_clk_src.freq_tbl = ftbl_gcc_sdcc4_apps_clk_src_sdm670;
+	gcc_sdcc4_apps_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = 33333333;
 }
 
 static int gcc_sdm845_fixup(struct platform_device *pdev)
@@ -4020,6 +4272,8 @@
 
 	if (!strcmp(compat, "qcom,gcc-sdm845-v2"))
 		gcc_sdm845_fixup_sdm845v2();
+	else if (!strcmp(compat, "qcom,gcc-sdm670"))
+		gcc_sdm845_fixup_sdm670();
 
 	return 0;
 }
diff --git a/drivers/clk/qcom/gpucc-sdm845.c b/drivers/clk/qcom/gpucc-sdm845.c
index cf4a8a5..35a23f7 100644
--- a/drivers/clk/qcom/gpucc-sdm845.c
+++ b/drivers/clk/qcom/gpucc-sdm845.c
@@ -224,6 +224,12 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src_sdm670[] = {
+	F(19200000, P_BI_TCXO, 1, 0, 0),
+	F(200000000, P_GPLL0_OUT_MAIN_DIV, 1.5, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 gpu_cc_gmu_clk_src = {
 	.cmd_rcgr = 0x1120,
 	.mnd_width = 0,
@@ -279,6 +285,18 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_gpu_cc_gx_gfx3d_clk_src_sdm670[] = {
+	F(180000000, P_CRC_DIV,  1, 0, 0),
+	F(267000000, P_CRC_DIV,  1, 0, 0),
+	F(355000000, P_CRC_DIV,  1, 0, 0),
+	F(430000000, P_CRC_DIV,  1, 0, 0),
+	F(565000000, P_CRC_DIV,  1, 0, 0),
+	F(650000000, P_CRC_DIV,  1, 0, 0),
+	F(750000000, P_CRC_DIV,  1, 0, 0),
+	F(780000000, P_CRC_DIV,  1, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 gpu_cc_gx_gfx3d_clk_src = {
 	.cmd_rcgr = 0x101c,
 	.mnd_width = 0,
@@ -585,6 +603,7 @@
 static const struct of_device_id gpu_cc_sdm845_match_table[] = {
 	{ .compatible = "qcom,gpucc-sdm845" },
 	{ .compatible = "qcom,gpucc-sdm845-v2" },
+	{ .compatible = "qcom,gpucc-sdm670" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, gpu_cc_sdm845_match_table);
@@ -592,6 +611,7 @@
 static const struct of_device_id gpu_cc_gfx_sdm845_match_table[] = {
 	{ .compatible = "qcom,gfxcc-sdm845" },
 	{ .compatible = "qcom,gfxcc-sdm845-v2" },
+	{ .compatible = "qcom,gfxcc-sdm670" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, gpu_cc_gfx_sdm845_match_table);
@@ -605,23 +625,51 @@
 	gpu_cc_gmu_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 500000000;
 }
 
+static void gpu_cc_sdm845_fixup_sdm670(struct regmap *regmap)
+{
+	gpu_cc_sdm845_clocks[GPU_CC_PLL1] = &gpu_cc_pll1.clkr;
+	clk_fabia_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
+
+	gpu_cc_gmu_clk_src.freq_tbl = ftbl_gpu_cc_gmu_clk_src_sdm670;
+	gpu_cc_gmu_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 200000000;
+}
+
 static void gpu_cc_gfx_sdm845_fixup_sdm845v2(void)
 {
 	gpu_cc_gx_gfx3d_clk_src.freq_tbl =
 				ftbl_gpu_cc_gx_gfx3d_clk_src_sdm845_v2;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_MIN] = 180000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOWER] =
-				257000000;
+		257000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOW] = 342000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOW_L1] =
-				414000000;
+		414000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_NOMINAL] =
-				520000000;
+		520000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_NOMINAL_L1] =
-				596000000;
+		596000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_HIGH] = 675000000;
 	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_HIGH_L1] =
-				710000000;
+		710000000;
+}
+
+static void gpu_cc_gfx_sdm845_fixup_sdm670(void)
+{
+	gpu_cc_gx_gfx3d_clk_src.freq_tbl =
+				ftbl_gpu_cc_gx_gfx3d_clk_src_sdm670;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_MIN] = 180000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOWER] =
+		267000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOW] = 355000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_LOW_L1] =
+		430000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_NOMINAL] =
+		565000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_NOMINAL_L1] =
+		650000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_HIGH] = 750000000;
+	gpu_cc_gx_gfx3d_clk_src.clkr.hw.init->rate_max[VDD_GX_HIGH_L1] =
+		780000000;
 }
 
 static int gpu_cc_gfx_sdm845_fixup(struct platform_device *pdev)
@@ -635,6 +683,8 @@
 
 	if (!strcmp(compat, "qcom,gfxcc-sdm845-v2"))
 		gpu_cc_gfx_sdm845_fixup_sdm845v2();
+	else if (!strcmp(compat, "qcom,gfxcc-sdm670"))
+		gpu_cc_gfx_sdm845_fixup_sdm670();
 
 	return 0;
 }
@@ -651,6 +701,8 @@
 
 	if (!strcmp(compat, "qcom,gpucc-sdm845-v2"))
 		gpu_cc_sdm845_fixup_sdm845v2(regmap);
+	else if (!strcmp(compat, "qcom,gpucc-sdm670"))
+		gpu_cc_sdm845_fixup_sdm670(regmap);
 
 	return 0;
 }
diff --git a/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c b/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
index eb6c658..89ed5cd 100644
--- a/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
+++ b/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
@@ -289,6 +289,14 @@
 
 	(void)mdss_pll_resource_enable(rsc, false);
 
+	/*
+	 * cache the current parent index for cases where parent
+	 * is not changing but rate is changing. In that case
+	 * clock framework won't call parent_set and hence dsiclk_sel
+	 * bit won't be programmed. e.g. dfps update use case.
+	 */
+	rsc->cached_cfg1 = val;
+
 	return rc;
 }
 
@@ -633,6 +641,12 @@
 	if (rsc->slave)
 		dsi_pll_enable_pll_bias(rsc->slave);
 
+	phy_reg_update_bits_sub(rsc, PHY_CMN_CLK_CFG1, 0x03, rsc->cached_cfg1);
+	if (rsc->slave)
+		phy_reg_update_bits_sub(rsc->slave, PHY_CMN_CLK_CFG1,
+				0x03, rsc->cached_cfg1);
+	wmb(); /* ensure dsiclk_sel is always programmed before pll start */
+
 	/* Start PLL */
 	MDSS_PLL_REG_W(rsc->phy_base, PHY_CMN_PLL_CNTRL, 0x01);
 
@@ -665,7 +679,6 @@
 
 static void dsi_pll_disable_sub(struct mdss_pll_resources *rsc)
 {
-	dsi_pll_disable_global_clk(rsc);
 	MDSS_PLL_REG_W(rsc->phy_base, PHY_CMN_RBUF_CTRL, 0);
 	dsi_pll_disable_pll_bias(rsc);
 }
@@ -684,11 +697,20 @@
 
 	pr_debug("stop PLL (%d)\n", rsc->index);
 
+	/*
+	 * To avoid any stray glitches while
+	 * abruptly powering down the PLL
+	 * make sure to gate the clock using
+	 * the clock enable bit before powering
+	 * down the PLL
+	 */
+	dsi_pll_disable_global_clk(rsc);
 	MDSS_PLL_REG_W(rsc->phy_base, PHY_CMN_PLL_CNTRL, 0);
 	dsi_pll_disable_sub(rsc);
-	if (rsc->slave)
+	if (rsc->slave) {
+		dsi_pll_disable_global_clk(rsc->slave);
 		dsi_pll_disable_sub(rsc->slave);
-
+	}
 	/* flush, ensure all register writes are done*/
 	wmb();
 	rsc->pll_on = false;
@@ -720,7 +742,6 @@
 		return;
 	}
 	pll->cached_cfg0 = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG0);
-	pll->cached_cfg1 = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
 	pll->cached_outdiv = MDSS_PLL_REG_R(pll->pll_base, PLL_PLL_OUTDIV_RATE);
 	pr_debug("cfg0=%d,cfg1=%d, outdiv=%d\n", pll->cached_cfg0,
 			pll->cached_cfg1, pll->cached_outdiv);
@@ -762,8 +783,6 @@
 			pll->cached_cfg1);
 		MDSS_PLL_REG_W(pll->phy_base, PHY_CMN_CLK_CFG0,
 					pll->cached_cfg0);
-		MDSS_PLL_REG_W(pll->phy_base, PHY_CMN_CLK_CFG1,
-					pll->cached_cfg1);
 		MDSS_PLL_REG_W(pll->pll_base, PLL_PLL_OUTDIV_RATE,
 					pll->cached_outdiv);
 	}
diff --git a/drivers/clk/qcom/videocc-sdm845.c b/drivers/clk/qcom/videocc-sdm845.c
index ba4e591..f8fdf3f 100644
--- a/drivers/clk/qcom/videocc-sdm845.c
+++ b/drivers/clk/qcom/videocc-sdm845.c
@@ -114,6 +114,17 @@
 	{ }
 };
 
+static const struct freq_tbl ftbl_video_cc_venus_clk_src_sdm670[] = {
+	F(100000000, P_VIDEO_PLL0_OUT_MAIN, 4, 0, 0),
+	F(200000000, P_VIDEO_PLL0_OUT_MAIN, 2, 0, 0),
+	F(330000000, P_VIDEO_PLL0_OUT_MAIN, 2, 0, 0),
+	F(364800000, P_VIDEO_PLL0_OUT_MAIN, 2, 0, 0),
+	F(404000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
+	F(444000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
+	F(533000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
+	{ }
+};
+
 static struct clk_rcg2 video_cc_venus_clk_src = {
 	.cmd_rcgr = 0x7f0,
 	.mnd_width = 0,
@@ -328,6 +339,7 @@
 static const struct of_device_id video_cc_sdm845_match_table[] = {
 	{ .compatible = "qcom,video_cc-sdm845" },
 	{ .compatible = "qcom,video_cc-sdm845-v2" },
+	{ .compatible = "qcom,video_cc-sdm670" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, video_cc_sdm845_match_table);
@@ -340,6 +352,14 @@
 		404000000;
 }
 
+static void video_cc_sdm845_fixup_sdm670(void)
+{
+	video_cc_venus_clk_src.freq_tbl = ftbl_video_cc_venus_clk_src_sdm670;
+	video_cc_venus_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = 330000000;
+	video_cc_venus_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+		404000000;
+}
+
 static int video_cc_sdm845_fixup(struct platform_device *pdev)
 {
 	const char *compat = NULL;
@@ -351,6 +371,8 @@
 
 	if (!strcmp(compat, "qcom,video_cc-sdm845-v2"))
 		video_cc_sdm845_fixup_sdm845v2();
+	else if (!strcmp(compat, "qcom,video_cc-sdm670"))
+		video_cc_sdm845_fixup_sdm670();
 
 	return 0;
 }
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 8c8b495..cdc092a 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -586,7 +586,7 @@
 	GATE(CLK_ACLK550_CAM, "aclk550_cam", "mout_user_aclk550_cam",
 				GATE_BUS_TOP, 24, 0, 0),
 	GATE(CLK_ACLK432_SCALER, "aclk432_scaler", "mout_user_aclk432_scaler",
-				GATE_BUS_TOP, 27, 0, 0),
+				GATE_BUS_TOP, 27, CLK_IS_CRITICAL, 0),
 };
 
 static const struct samsung_mux_clock exynos5420_mux_clks[] __initconst = {
@@ -956,20 +956,20 @@
 	GATE(CLK_SMMU_G2D, "smmu_g2d", "aclk333_g2d", GATE_IP_G2D, 7, 0, 0),
 
 	GATE(0, "aclk200_fsys", "mout_user_aclk200_fsys",
-			GATE_BUS_FSYS0, 9, CLK_IGNORE_UNUSED, 0),
+			GATE_BUS_FSYS0, 9, CLK_IS_CRITICAL, 0),
 	GATE(0, "aclk200_fsys2", "mout_user_aclk200_fsys2",
 			GATE_BUS_FSYS0, 10, CLK_IGNORE_UNUSED, 0),
 
 	GATE(0, "aclk333_g2d", "mout_user_aclk333_g2d",
 			GATE_BUS_TOP, 0, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk266_g2d", "mout_user_aclk266_g2d",
-			GATE_BUS_TOP, 1, CLK_IGNORE_UNUSED, 0),
+			GATE_BUS_TOP, 1, CLK_IS_CRITICAL, 0),
 	GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg",
 			GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk333_432_isp0", "mout_user_aclk333_432_isp0",
 			GATE_BUS_TOP, 5, 0, 0),
 	GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl",
-			GATE_BUS_TOP, 6, CLK_IGNORE_UNUSED, 0),
+			GATE_BUS_TOP, 6, CLK_IS_CRITICAL, 0),
 	GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl",
 			GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk333_432_isp", "mout_user_aclk333_432_isp",
@@ -983,20 +983,20 @@
 	GATE(0, "aclk166", "mout_user_aclk166",
 			GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0),
 	GATE(CLK_ACLK333, "aclk333", "mout_user_aclk333",
-			GATE_BUS_TOP, 15, CLK_IGNORE_UNUSED, 0),
+			GATE_BUS_TOP, 15, CLK_IS_CRITICAL, 0),
 	GATE(0, "aclk400_isp", "mout_user_aclk400_isp",
 			GATE_BUS_TOP, 16, 0, 0),
 	GATE(0, "aclk400_mscl", "mout_user_aclk400_mscl",
 			GATE_BUS_TOP, 17, 0, 0),
 	GATE(0, "aclk200_disp1", "mout_user_aclk200_disp1",
-			GATE_BUS_TOP, 18, 0, 0),
+			GATE_BUS_TOP, 18, CLK_IS_CRITICAL, 0),
 	GATE(CLK_SCLK_MPHY_IXTAL24, "sclk_mphy_ixtal24", "mphy_refclk_ixtal24",
 			GATE_BUS_TOP, 28, 0, 0),
 	GATE(CLK_SCLK_HSIC_12M, "sclk_hsic_12m", "ff_hsic_12m",
 			GATE_BUS_TOP, 29, 0, 0),
 
 	GATE(0, "aclk300_disp1", "mout_user_aclk300_disp1",
-			SRC_MASK_TOP2, 24, 0, 0),
+			SRC_MASK_TOP2, 24, CLK_IS_CRITICAL, 0),
 
 	GATE(CLK_MAU_EPLL, "mau_epll", "mout_mau_epll_clk",
 			SRC_MASK_TOP7, 20, 0, 0),
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index a6edf2f..c59e980 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -455,15 +455,11 @@
 	struct cpufreq_interactive_cpuinfo *pcpu = &per_cpu(cpuinfo, cpu);
 	struct cpufreq_interactive_tunables *tunables =
 		ppol->policy->governor_data;
-	u64 now;
-	u64 now_idle;
-	unsigned int delta_idle;
-	unsigned int delta_time;
-	u64 active_time;
+	u64 now_idle, now, active_time, delta_idle, delta_time;
 
 	now_idle = get_cpu_idle_time(cpu, &now, tunables->io_is_busy);
-	delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle);
-	delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp);
+	delta_idle = (now_idle - pcpu->time_in_idle);
+	delta_time = (now - pcpu->time_in_idle_timestamp);
 
 	if (delta_time <= delta_idle)
 		active_time = 0;
diff --git a/drivers/cpuidle/lpm-levels-of.c b/drivers/cpuidle/lpm-levels-of.c
index 0ab4c21..fb11acd 100644
--- a/drivers/cpuidle/lpm-levels-of.c
+++ b/drivers/cpuidle/lpm-levels-of.c
@@ -779,6 +779,7 @@
 	if (ret)
 		goto failed_parse_params;
 
+	INIT_LIST_HEAD(&c->list);
 	INIT_LIST_HEAD(&c->child);
 	INIT_LIST_HEAD(&c->cpu);
 	c->parent = parent;
diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c
index 261b8b1..746cdc0 100644
--- a/drivers/cpuidle/lpm-levels.c
+++ b/drivers/cpuidle/lpm-levels.c
@@ -601,16 +601,14 @@
 	uint32_t *max_residency = get_per_cpu_max_residency(dev->cpu);
 
 	if ((sleep_disabled && !cpu_isolated(dev->cpu)) || sleep_us < 0)
-		return 0;
+		return best_level;
 
 	idx_restrict = cpu->nlevels + 1;
 
 	next_event_us = (uint32_t)(ktime_to_us(get_next_event_time(dev->cpu)));
 
-	if (is_cpu_biased(dev->cpu)) {
-		best_level = 0;
+	if (is_cpu_biased(dev->cpu))
 		goto done_select;
-	}
 
 	for (i = 0; i < cpu->nlevels; i++) {
 		struct lpm_cpu_level *level = &cpu->levels[i];
@@ -1342,14 +1340,14 @@
 		struct cpuidle_driver *drv, int idx)
 {
 	struct lpm_cpu *cpu = per_cpu(cpu_lpm, dev->cpu);
-	bool success = true;
+	bool success = false;
 	const struct cpumask *cpumask = get_cpu_mask(dev->cpu);
 	int64_t start_time = ktime_to_ns(ktime_get()), end_time;
 	struct power_params *pwr_params;
 
 	pwr_params = &cpu->levels[idx].pwr;
-
-	pwr_params = &cpu->levels[idx].pwr;
+	sched_set_cpu_cstate(dev->cpu, idx + 1,
+			pwr_params->energy_overhead, pwr_params->latency_us);
 
 	cpu_prepare(cpu, idx, true);
 	cluster_prepare(cpu->parent, cpumask, idx, true, start_time);
@@ -1608,7 +1606,7 @@
 	 * clocks that are enabled and preventing the system level
 	 * LPMs(XO and Vmin).
 	 */
-	clock_debug_print_enabled();
+	clock_debug_print_enabled(true);
 
 	psci_enter_sleep(lpm_cpu, idx, false);
 
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 7868765..b54af97 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -1074,7 +1074,7 @@
 		req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,
 				&crypt->icv_rev_aes);
 		if (unlikely(!req_ctx->hmac_virt))
-			goto free_buf_src;
+			goto free_buf_dst;
 		if (!encrypt) {
 			scatterwalk_map_and_copy(req_ctx->hmac_virt,
 				req->src, cryptlen, authsize, 0);
@@ -1089,10 +1089,10 @@
 	BUG_ON(qmgr_stat_overflow(SEND_QID));
 	return -EINPROGRESS;
 
-free_buf_src:
-	free_buf_chain(dev, req_ctx->src, crypt->src_buf);
 free_buf_dst:
 	free_buf_chain(dev, req_ctx->dst, crypt->dst_buf);
+free_buf_src:
+	free_buf_chain(dev, req_ctx->src, crypt->src_buf);
 	crypt->ctl_flags = CTL_FLAG_UNUSED;
 	return -ENOMEM;
 }
diff --git a/drivers/crypto/msm/ice.c b/drivers/crypto/msm/ice.c
index 6ed82ef..6fa91ae 100644
--- a/drivers/crypto/msm/ice.c
+++ b/drivers/crypto/msm/ice.c
@@ -888,7 +888,7 @@
 static int qcom_ice_init_clocks(struct ice_device *ice)
 {
 	int ret = -EINVAL;
-	struct ice_clk_info *clki;
+	struct ice_clk_info *clki = NULL;
 	struct device *dev = ice->pdev;
 	struct list_head *head = &ice->clk_list_head;
 
@@ -932,7 +932,7 @@
 static int qcom_ice_enable_clocks(struct ice_device *ice, bool enable)
 {
 	int ret = 0;
-	struct ice_clk_info *clki;
+	struct ice_clk_info *clki = NULL;
 	struct device *dev = ice->pdev;
 	struct list_head *head = &ice->clk_list_head;
 
@@ -1608,12 +1608,14 @@
 		if (ice_dev->pdev->of_node == node) {
 			pr_info("%s: found ice device %pK\n", __func__,
 			ice_dev);
+			ice_pdev = to_platform_device(ice_dev->pdev);
 			break;
 		}
 	}
 
-	ice_pdev = to_platform_device(ice_dev->pdev);
-	pr_info("%s: matching platform device %pK\n", __func__, ice_pdev);
+	if (ice_pdev)
+		pr_info("%s: matching platform device %pK\n", __func__,
+			ice_pdev);
 out:
 	return ice_pdev;
 }
@@ -1632,11 +1634,11 @@
 	list_for_each_entry(ice_dev, &ice_devices, list) {
 		if (!strcmp(ice_dev->ice_instance_type, storage_type)) {
 			pr_info("%s: found ice device %p\n", __func__, ice_dev);
-			break;
+			return ice_dev;
 		}
 	}
 out:
-	return ice_dev;
+	return NULL;
 }
 
 static int enable_ice_setup(struct ice_device *ice_dev)
diff --git a/drivers/crypto/msm/qcedev.c b/drivers/crypto/msm/qcedev.c
index 2cf303e..94b3c17 100644
--- a/drivers/crypto/msm/qcedev.c
+++ b/drivers/crypto/msm/qcedev.c
@@ -340,8 +340,6 @@
 	if (authdata) {
 		handle->sha_ctxt.auth_data[0] = auth32[0];
 		handle->sha_ctxt.auth_data[1] = auth32[1];
-		handle->sha_ctxt.auth_data[2] = auth32[2];
-		handle->sha_ctxt.auth_data[3] = auth32[3];
 	}
 
 	tasklet_schedule(&pdev->done_tasklet);
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index 586f954..40be374 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -546,7 +546,8 @@
 	struct dax_dev *dax_dev = to_dax_dev(dev);
 	struct dax_region *dax_region = dax_dev->region;
 
-	ida_simple_remove(&dax_region->ida, dax_dev->id);
+	if (dax_dev->id >= 0)
+		ida_simple_remove(&dax_region->ida, dax_dev->id);
 	ida_simple_remove(&dax_minor_ida, MINOR(dev->devt));
 	dax_region_put(dax_region);
 	iput(dax_dev->inode);
@@ -581,7 +582,7 @@
 }
 
 struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
-		struct resource *res, int count)
+		int id, struct resource *res, int count)
 {
 	struct device *parent = dax_region->dev;
 	struct dax_dev *dax_dev;
@@ -608,10 +609,16 @@
 	if (i < count)
 		goto err_id;
 
-	dax_dev->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL);
-	if (dax_dev->id < 0) {
-		rc = dax_dev->id;
-		goto err_id;
+	if (id < 0) {
+		id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL);
+		dax_dev->id = id;
+		if (id < 0) {
+			rc = id;
+			goto err_id;
+		}
+	} else {
+		/* region provider owns @id lifetime */
+		dax_dev->id = -1;
 	}
 
 	minor = ida_simple_get(&dax_minor_ida, 0, 0, GFP_KERNEL);
@@ -650,7 +657,7 @@
 	dev->parent = parent;
 	dev->groups = dax_attribute_groups;
 	dev->release = dax_dev_release;
-	dev_set_name(dev, "dax%d.%d", dax_region->id, dax_dev->id);
+	dev_set_name(dev, "dax%d.%d", dax_region->id, id);
 	rc = device_add(dev);
 	if (rc) {
 		kill_dax_dev(dax_dev);
@@ -669,7 +676,8 @@
  err_inode:
 	ida_simple_remove(&dax_minor_ida, minor);
  err_minor:
-	ida_simple_remove(&dax_region->ida, dax_dev->id);
+	if (dax_dev->id >= 0)
+		ida_simple_remove(&dax_region->ida, dax_dev->id);
  err_id:
 	kfree(dax_dev);
 
diff --git a/drivers/dax/dax.h b/drivers/dax/dax.h
index ddd829a..b5ed850 100644
--- a/drivers/dax/dax.h
+++ b/drivers/dax/dax.h
@@ -21,5 +21,5 @@
 		int region_id, struct resource *res, unsigned int align,
 		void *addr, unsigned long flags);
 struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
-		struct resource *res, int count);
+		int id, struct resource *res, int count);
 #endif /* __DAX_H__ */
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 73c6ce9..eebb357 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -58,13 +58,12 @@
 
 static int dax_pmem_probe(struct device *dev)
 {
-	int rc;
 	void *addr;
 	struct resource res;
 	struct dax_dev *dax_dev;
+	int rc, id, region_id;
 	struct nd_pfn_sb *pfn_sb;
 	struct dax_pmem *dax_pmem;
-	struct nd_region *nd_region;
 	struct nd_namespace_io *nsio;
 	struct dax_region *dax_region;
 	struct nd_namespace_common *ndns;
@@ -122,14 +121,17 @@
 	/* adjust the dax_region resource to the start of data */
 	res.start += le64_to_cpu(pfn_sb->dataoff);
 
-	nd_region = to_nd_region(dev->parent);
-	dax_region = alloc_dax_region(dev, nd_region->id, &res,
+	rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", &region_id, &id);
+	if (rc != 2)
+		return -EINVAL;
+
+	dax_region = alloc_dax_region(dev, region_id, &res,
 			le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP);
 	if (!dax_region)
 		return -ENOMEM;
 
 	/* TODO: support for subdividing a dax region... */
-	dax_dev = devm_create_dax_dev(dax_region, &res, 1);
+	dax_dev = devm_create_dax_dev(dax_region, id, &res, 1);
 
 	/* child dax_dev instances now own the lifetime of the dax_region */
 	dax_region_put(dax_region);
diff --git a/drivers/devfreq/arm-memlat-mon.c b/drivers/devfreq/arm-memlat-mon.c
index 5802c21..f4f503e 100644
--- a/drivers/devfreq/arm-memlat-mon.c
+++ b/drivers/devfreq/arm-memlat-mon.c
@@ -55,8 +55,7 @@
 struct cpu_grp_info {
 	cpumask_t cpus;
 	cpumask_t inited_cpus;
-	unsigned long cache_miss_event;
-	unsigned long inst_event;
+	unsigned int event_ids[NUM_EVENTS];
 	struct cpu_pmu_stats *cpustats;
 	struct memlat_hwmon hw;
 	struct notifier_block arm_memlat_cpu_notif;
@@ -97,13 +96,8 @@
 	u64 total, enabled, running;
 
 	total = perf_event_read_value(event->pevent, &enabled, &running);
-	if (total >= event->prev_count)
-		ev_count = total - event->prev_count;
-	else
-		ev_count = (MAX_COUNT_LIM - event->prev_count) + total;
-
+	ev_count = total - event->prev_count;
 	event->prev_count = total;
-
 	return ev_count;
 }
 
@@ -134,7 +128,7 @@
 {
 	int i;
 
-	for (i = 0; i < NUM_EVENTS; i++) {
+	for (i = 0; i < ARRAY_SIZE(cpustats->events); i++) {
 		cpustats->events[i].prev_count = 0;
 		perf_event_release_kernel(cpustats->events[i].pevent);
 	}
@@ -187,7 +181,7 @@
 {
 	struct perf_event *pevent;
 	struct perf_event_attr *attr;
-	int err;
+	int err, i;
 	struct cpu_pmu_stats *cpustats = to_cpustats(cpu_grp, cpu);
 
 	/* Allocate an attribute for event initialization */
@@ -195,26 +189,15 @@
 	if (!attr)
 		return -ENOMEM;
 
-	attr->config = cpu_grp->inst_event;
-	pevent = perf_event_create_kernel_counter(attr, cpu, NULL, NULL, NULL);
-	if (IS_ERR(pevent))
-		goto err_out;
-	cpustats->events[INST_IDX].pevent = pevent;
-	perf_event_enable(cpustats->events[INST_IDX].pevent);
-
-	attr->config = cpu_grp->cache_miss_event;
-	pevent = perf_event_create_kernel_counter(attr, cpu, NULL, NULL, NULL);
-	if (IS_ERR(pevent))
-		goto err_out;
-	cpustats->events[CM_IDX].pevent = pevent;
-	perf_event_enable(cpustats->events[CM_IDX].pevent);
-
-	attr->config = CYC_EV;
-	pevent = perf_event_create_kernel_counter(attr, cpu, NULL, NULL, NULL);
-	if (IS_ERR(pevent))
-		goto err_out;
-	cpustats->events[CYC_IDX].pevent = pevent;
-	perf_event_enable(cpustats->events[CYC_IDX].pevent);
+	for (i = 0; i < ARRAY_SIZE(cpustats->events); i++) {
+		attr->config = cpu_grp->event_ids[i];
+		pevent = perf_event_create_kernel_counter(attr, cpu, NULL,
+							  NULL, NULL);
+		if (IS_ERR(pevent))
+			goto err_out;
+		cpustats->events[i].pevent = pevent;
+		perf_event_enable(pevent);
+	}
 
 	kfree(attr);
 	return 0;
@@ -315,7 +298,7 @@
 	struct memlat_hwmon *hw;
 	struct cpu_grp_info *cpu_grp;
 	int cpu, ret;
-	u32 cachemiss_ev, inst_ev;
+	u32 event_id;
 
 	cpu_grp = devm_kzalloc(dev, sizeof(*cpu_grp), GFP_KERNEL);
 	if (!cpu_grp)
@@ -346,22 +329,24 @@
 	if (!cpu_grp->cpustats)
 		return -ENOMEM;
 
+	cpu_grp->event_ids[CYC_IDX] = CYC_EV;
+
 	ret = of_property_read_u32(dev->of_node, "qcom,cachemiss-ev",
-			&cachemiss_ev);
+				   &event_id);
 	if (ret) {
 		dev_dbg(dev, "Cache Miss event not specified. Using def:0x%x\n",
-				L2DM_EV);
-		cachemiss_ev = L2DM_EV;
+			L2DM_EV);
+		event_id = L2DM_EV;
 	}
-	cpu_grp->cache_miss_event = cachemiss_ev;
+	cpu_grp->event_ids[CM_IDX] = event_id;
 
-	ret = of_property_read_u32(dev->of_node, "qcom,inst-ev", &inst_ev);
+	ret = of_property_read_u32(dev->of_node, "qcom,inst-ev", &event_id);
 	if (ret) {
 		dev_dbg(dev, "Inst event not specified. Using def:0x%x\n",
-				INST_EV);
-		inst_ev = INST_EV;
+			INST_EV);
+		event_id = INST_EV;
 	}
-	cpu_grp->inst_event = inst_ev;
+	cpu_grp->event_ids[INST_IDX] = event_id;
 
 	for_each_cpu(cpu, &cpu_grp->cpus)
 		to_devstats(cpu_grp, cpu)->id = cpu;
diff --git a/drivers/devfreq/bimc-bwmon.c b/drivers/devfreq/bimc-bwmon.c
index ffe60de..f9b758f 100644
--- a/drivers/devfreq/bimc-bwmon.c
+++ b/drivers/devfreq/bimc-bwmon.c
@@ -575,7 +575,9 @@
 		count = readl_relaxed(MON2_ZONE_MAX(m, zone)) + 1;
 		break;
 	case MON3:
-		count = readl_relaxed(MON3_ZONE_MAX(m, zone)) + 1;
+		count = readl_relaxed(MON3_ZONE_MAX(m, zone));
+		if (count)
+			count++;
 		break;
 	}
 
diff --git a/drivers/devfreq/governor_memlat.c b/drivers/devfreq/governor_memlat.c
index e1afa60..1a8ef1f 100644
--- a/drivers/devfreq/governor_memlat.c
+++ b/drivers/devfreq/governor_memlat.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -36,6 +36,7 @@
 struct memlat_node {
 	unsigned int ratio_ceil;
 	bool mon_started;
+	bool already_zero;
 	struct list_head list;
 	void *orig_data;
 	struct memlat_hwmon *hw;
@@ -224,7 +225,7 @@
 static int devfreq_memlat_get_freq(struct devfreq *df,
 					unsigned long *freq)
 {
-	int i, lat_dev;
+	int i, lat_dev = 0;
 	struct memlat_node *node = df->data;
 	struct memlat_hwmon *hw = node->hw;
 	unsigned long max_freq = 0;
@@ -238,21 +239,27 @@
 		if (hw->core_stats[i].mem_count)
 			ratio /= hw->core_stats[i].mem_count;
 
+		if (!hw->core_stats[i].inst_count
+		    || !hw->core_stats[i].freq)
+			continue;
+
 		trace_memlat_dev_meas(dev_name(df->dev.parent),
 					hw->core_stats[i].id,
 					hw->core_stats[i].inst_count,
 					hw->core_stats[i].mem_count,
 					hw->core_stats[i].freq, ratio);
 
-		if (ratio && ratio <= node->ratio_ceil
+		if (ratio <= node->ratio_ceil
 		    && hw->core_stats[i].freq > max_freq) {
 			lat_dev = i;
 			max_freq = hw->core_stats[i].freq;
 		}
 	}
 
-	if (max_freq) {
+	if (max_freq)
 		max_freq = core_to_dev_freq(node, max_freq);
+
+	if (max_freq || !node->already_zero) {
 		trace_memlat_dev_update(dev_name(df->dev.parent),
 					hw->core_stats[lat_dev].id,
 					hw->core_stats[lat_dev].inst_count,
@@ -261,6 +268,8 @@
 					max_freq);
 	}
 
+	node->already_zero = !max_freq;
+
 	*freq = max_freq;
 	return 0;
 }
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 5a9166a..2f34a01 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -285,7 +285,7 @@
 	struct sync_file *sync_file = container_of(kref, struct sync_file,
 						     kref);
 
-	if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
+	if (test_bit(POLL_ENABLED, &sync_file->flags))
 		fence_remove_callback(sync_file->fence, &sync_file->cb);
 	fence_put(sync_file->fence);
 	kfree(sync_file);
@@ -305,7 +305,7 @@
 
 	poll_wait(file, &sync_file->wq, wait);
 
-	if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
+	if (!test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
 		if (fence_add_callback(sync_file->fence, &sync_file->cb,
 					   fence_check_cb_func) < 0)
 			wake_up_all(&sync_file->wq);
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 141aefb..4e2379b 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -422,6 +422,16 @@
 	  16 to 32 channels for peripheral to memory or memory to memory
 	  transfers.
 
+config QCOM_SPS_DMA
+	tristate "Qualcomm technologies inc DMA driver for sps-BAM"
+	depends on ARCH_QCOM
+	select DMA_ENGINE
+	help
+	  Enable support for Qualcomm technologies inc, BAM DMA engine.
+	  This DMA-engine-driver is a wrapper of the sps-BAM library. DMA
+	  engine callbacks are implemented using the sps-BAM functionality
+	  to access HW.
+
 config SIRF_DMA
 	tristate "CSR SiRFprimaII/SiRFmarco DMA support"
 	depends on ARCH_SIRF
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index e4dc9ca..2c19be4 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -67,6 +67,7 @@
 obj-$(CONFIG_TI_EDMA) += edma.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx296702_dma.o
+obj-$(CONFIG_QCOM_SPS_DMA) += qcom-sps-dma.o
 
 obj-y += qcom/
 obj-y += xilinx/
diff --git a/drivers/dma/ioat/hw.h b/drivers/dma/ioat/hw.h
index 8e67895..abcc51b 100644
--- a/drivers/dma/ioat/hw.h
+++ b/drivers/dma/ioat/hw.h
@@ -64,6 +64,8 @@
 #define PCI_DEVICE_ID_INTEL_IOAT_BDX8	0x6f2e
 #define PCI_DEVICE_ID_INTEL_IOAT_BDX9	0x6f2f
 
+#define PCI_DEVICE_ID_INTEL_IOAT_SKX	0x2021
+
 #define IOAT_VER_1_2            0x12    /* Version 1.2 */
 #define IOAT_VER_2_0            0x20    /* Version 2.0 */
 #define IOAT_VER_3_0            0x30    /* Version 3.0 */
diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index d235fbe..0dea6d55 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -106,6 +106,8 @@
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX8) },
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX9) },
 
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SKX) },
+
 	/* I/OAT v3.3 platforms */
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD0) },
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD1) },
@@ -243,10 +245,15 @@
 	}
 }
 
+static inline bool is_skx_ioat(struct pci_dev *pdev)
+{
+	return (pdev->device == PCI_DEVICE_ID_INTEL_IOAT_SKX) ? true : false;
+}
+
 static bool is_xeon_cb32(struct pci_dev *pdev)
 {
 	return is_jf_ioat(pdev) || is_snb_ioat(pdev) || is_ivb_ioat(pdev) ||
-		is_hsw_ioat(pdev) || is_bdx_ioat(pdev);
+		is_hsw_ioat(pdev) || is_bdx_ioat(pdev) || is_skx_ioat(pdev);
 }
 
 bool is_bwd_ioat(struct pci_dev *pdev)
@@ -1350,6 +1357,8 @@
 
 	device->version = readb(device->reg_base + IOAT_VER_OFFSET);
 	if (device->version >= IOAT_VER_3_0) {
+		if (is_skx_ioat(pdev))
+			device->version = IOAT_VER_3_2;
 		err = ioat3_dma_probe(device, ioat_dca_enabled);
 
 		if (device->version >= IOAT_VER_3_3)
diff --git a/drivers/dma/qcom-sps-dma.c b/drivers/dma/qcom-sps-dma.c
new file mode 100644
index 0000000..d9fd653
--- /dev/null
+++ b/drivers/dma/qcom-sps-dma.c
@@ -0,0 +1,721 @@
+/*
+ * Copyright (c) 2014-2015,2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ *
+ */
+
+/*
+ * Qualcomm technologies inc, DMA API for BAM (Bus Access Manager).
+ * This DMA driver uses sps-BAM API to access the HW, thus it is effectively a
+ * DMA engine wrapper of the sps-BAM API.
+ *
+ * Client channel configuration example:
+ * struct dma_slave_config config {
+ *    .direction = DMA_MEM_TO_DEV;
+ * };
+ *
+ * chan = dma_request_slave_channel(client_dev, "rx");
+ * dmaengine_slave_config(chan, &config);
+ */
+
+#include <linux/kernel.h>
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/dma-mapping.h>
+#include <linux/scatterlist.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_dma.h>
+#include <linux/list.h>
+#include <linux/msm-sps.h>
+#include "dmaengine.h"
+
+#define QBAM_OF_SLAVE_N_ARGS	(4)
+#define QBAM_OF_MANAGE_LOCAL	"qcom,managed-locally"
+#define QBAM_OF_SUM_THRESHOLD	"qcom,summing-threshold"
+#define QBAM_MAX_DESCRIPTORS	(0x100)
+#define QBAM_MAX_CHANNELS	(32)
+
+/*
+ * qbam_async_tx_descriptor - dma descriptor plus a list of xfer_bufs
+ *
+ * @sgl scatterlist of transfer buffers
+ * @sg_len size of that list
+ * @flags dma xfer flags
+ */
+struct qbam_async_tx_descriptor {
+	struct dma_async_tx_descriptor	dma_desc;
+	struct scatterlist		*sgl;
+	unsigned int			sg_len;
+	unsigned long			flags;
+};
+
+#define DMA_TO_QBAM_ASYNC_DESC(dma_async_desc) \
+	container_of(dma_async_desc, struct qbam_async_tx_descriptor, dma_desc)
+
+struct qbam_channel;
+/*
+ * qbam_device - top level device of current driver
+ * @handle bam sps handle.
+ * @regs bam register space virtual base address.
+ * @mem_resource bam register space resource.
+ * @deregister_required if bam is registered by this driver it need to be
+ *   unregistered by this driver.
+ * @manage is bame managed locally or remotely,
+ * @summing_threshold event threshold.
+ * @irq bam interrupt line.
+ * @channels has the same channels as qbam_dev->dma_dev.channels but
+ *   supports fast access by pipe index.
+ */
+struct qbam_device {
+	struct dma_device		dma_dev;
+	void __iomem			*regs;
+	struct resource			*mem_resource;
+	ulong				handle;
+	bool				deregister_required;
+	u32				summing_threshold;
+	u32				manage;
+	int				irq;
+	struct qbam_channel		*channels[QBAM_MAX_CHANNELS];
+};
+
+/* qbam_pipe: aggregate of bam pipe related entries of qbam_channel */
+struct qbam_pipe {
+	u32				index;
+	struct sps_pipe			*handle;
+	struct sps_connect		cfg;
+	u32				num_descriptors;
+	u32				sps_connect_flags;
+	u32				sps_register_event_flags;
+};
+
+/*
+ * qbam_channel - dma channel plus bam pipe info and current pending transfers
+ *
+ * @direction is a producer or consumer (MEM => DEV or DEV => MEM)
+ * @pending_desc next set of transfer to process
+ * @error last error that took place on the current pending_desc
+ */
+struct qbam_channel {
+	struct qbam_pipe		bam_pipe;
+
+	struct dma_chan			chan;
+	enum dma_transfer_direction	direction;
+	struct qbam_async_tx_descriptor	pending_desc;
+
+	struct qbam_device		*qbam_dev;
+	struct mutex			lock;
+	int				error;
+};
+#define DMA_TO_QBAM_CHAN(dma_chan) \
+			container_of(dma_chan, struct qbam_channel, chan)
+#define qbam_err(qbam_dev, fmt ...) dev_err(qbam_dev->dma_dev.dev, fmt)
+
+/*  qbam_disconnect_chan - disconnect a channel */
+static int qbam_disconnect_chan(struct qbam_channel *qbam_chan)
+{
+	struct qbam_device  *qbam_dev    = qbam_chan->qbam_dev;
+	struct sps_pipe     *pipe_handle = qbam_chan->bam_pipe.handle;
+	struct sps_connect   pipe_config_no_irq = {.options = SPS_O_POLL};
+	int ret;
+
+	/*
+	 * SW workaround:
+	 * When disconnecting BAM pipe a spurious interrupt sometimes appears.
+	 * To avoid that, we change the pipe setting from interrupt (default)
+	 * to polling (SPS_O_POLL) before diconnecting the pipe.
+	 */
+	ret = sps_set_config(pipe_handle, &pipe_config_no_irq);
+	if (ret)
+		qbam_err(qbam_dev,
+			"error:%d sps_set_config(pipe:%d) before disconnect\n",
+			ret, qbam_chan->bam_pipe.index);
+
+	ret = sps_disconnect(pipe_handle);
+	if (ret)
+		qbam_err(qbam_dev, "error:%d sps_disconnect(pipe:%d)\n",
+			 ret, qbam_chan->bam_pipe.index);
+
+	return ret;
+}
+
+/*  qbam_free_chan - disconnect channel and free its resources */
+static void qbam_free_chan(struct dma_chan *chan)
+{
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	struct qbam_device  *qbam_dev  = qbam_chan->qbam_dev;
+
+	mutex_lock(&qbam_chan->lock);
+	if (qbam_disconnect_chan(qbam_chan))
+		qbam_err(qbam_dev,
+			"error free_chan() failed to disconnect(pipe:%d)\n",
+			qbam_chan->bam_pipe.index);
+	qbam_chan->pending_desc.sgl = NULL;
+	qbam_chan->pending_desc.sg_len = 0;
+	mutex_unlock(&qbam_chan->lock);
+}
+
+static struct dma_chan *qbam_dma_xlate(struct of_phandle_args *dma_spec,
+							struct of_dma *of)
+{
+	struct qbam_device  *qbam_dev  = of->of_dma_data;
+	struct qbam_channel *qbam_chan;
+	u32 channel_index;
+	u32 num_descriptors;
+
+	if (dma_spec->args_count != QBAM_OF_SLAVE_N_ARGS) {
+		qbam_err(qbam_dev,
+			"invalid number of dma arguments, expect:%d got:%d\n",
+			QBAM_OF_SLAVE_N_ARGS, dma_spec->args_count);
+		return NULL;
+	};
+
+	channel_index = dma_spec->args[0];
+
+	if (channel_index >= QBAM_MAX_CHANNELS) {
+		qbam_err(qbam_dev,
+			"error: channel_index:%d out of bounds",
+			channel_index);
+		return NULL;
+	}
+	qbam_chan = qbam_dev->channels[channel_index];
+	 /* return qbam_chan if exists, or create one */
+	if (qbam_chan) {
+		qbam_chan->chan.client_count = 1;
+		return &qbam_chan->chan;
+	}
+
+	num_descriptors = dma_spec->args[1];
+	if (!num_descriptors || (num_descriptors > QBAM_MAX_DESCRIPTORS)) {
+		qbam_err(qbam_dev,
+			"invalid number of descriptors, range[1..%d] got:%d\n",
+			QBAM_MAX_DESCRIPTORS, num_descriptors);
+		return NULL;
+	}
+
+	/* allocate a channel */
+	qbam_chan = kzalloc(sizeof(*qbam_chan), GFP_KERNEL);
+	if (!qbam_chan)
+		return NULL;
+
+	/* allocate BAM resources for that channel */
+	qbam_chan->bam_pipe.handle = sps_alloc_endpoint();
+	if (!qbam_chan->bam_pipe.handle) {
+		qbam_err(qbam_dev, "error: sps_alloc_endpoint() return NULL\n");
+		kfree(qbam_chan);
+		return NULL;
+	}
+
+	/* init dma_chan */
+	qbam_chan->chan.device = &qbam_dev->dma_dev;
+	dma_cookie_init(&qbam_chan->chan);
+	qbam_chan->chan.client_count                 = 1;
+	/* init qbam_chan */
+	qbam_chan->bam_pipe.index                    = channel_index;
+	qbam_chan->bam_pipe.num_descriptors          = num_descriptors;
+	qbam_chan->bam_pipe.sps_connect_flags        = dma_spec->args[2];
+	qbam_chan->bam_pipe.sps_register_event_flags = dma_spec->args[3];
+	qbam_chan->qbam_dev                          = qbam_dev;
+	mutex_init(&qbam_chan->lock);
+
+	/* add to dma_device list of channels */
+	list_add(&qbam_chan->chan.device_node, &qbam_dev->dma_dev.channels);
+	qbam_dev->channels[channel_index] = qbam_chan;
+
+	return &qbam_chan->chan;
+}
+
+static enum dma_status qbam_tx_status(struct dma_chan *chan,
+			dma_cookie_t cookie, struct dma_tx_state *state)
+{
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	struct qbam_async_tx_descriptor	*qbam_desc = &qbam_chan->pending_desc;
+	enum dma_status ret;
+
+	mutex_lock(&qbam_chan->lock);
+
+	if (qbam_chan->error) {
+		mutex_unlock(&qbam_chan->lock);
+		return DMA_ERROR;
+	}
+
+	ret = dma_cookie_status(chan, cookie, state);
+	if (ret == DMA_IN_PROGRESS) {
+		struct scatterlist *sg;
+		int i;
+		u32 transfer_size = 0;
+
+		for_each_sg(qbam_desc->sgl, sg, qbam_desc->sg_len, i)
+			transfer_size += sg_dma_len(sg);
+
+		dma_set_residue(state, transfer_size);
+	}
+	mutex_unlock(&qbam_chan->lock);
+
+	return ret;
+}
+
+/*
+ * qbam_init_bam_handle - find or create bam handle.
+ *
+ * BAM device needs to be registered for each BLSP once and only once. if it
+ * was registered, then we find the handle to the registered bam and return
+ * it, otherwise we register it here.
+ * The module which registered BAM is responsible for deregistering it.
+ */
+static int qbam_init_bam_handle(struct qbam_device *qbam_dev)
+{
+	int ret = 0;
+	struct sps_bam_props bam_props = {0};
+
+	/*
+	 * Check if BAM is already registred with SPS on the current
+	 * BLSP. If it isn't then go ahead and register it.
+	 */
+	ret = sps_phy2h(qbam_dev->mem_resource->start, &qbam_dev->handle);
+	if (qbam_dev->handle)
+		return 0;
+
+	qbam_dev->regs = devm_ioremap_resource(qbam_dev->dma_dev.dev,
+					       qbam_dev->mem_resource);
+	if (IS_ERR(qbam_dev->regs)) {
+		qbam_err(qbam_dev, "error:%ld ioremap(phy:0x%lx len:0x%lx)\n",
+			 PTR_ERR(qbam_dev->regs),
+			 (ulong) qbam_dev->mem_resource->start,
+			 (ulong) resource_size(qbam_dev->mem_resource));
+		return PTR_ERR(qbam_dev->regs);
+	};
+
+	bam_props.phys_addr		= qbam_dev->mem_resource->start;
+	bam_props.virt_addr		= qbam_dev->regs;
+	bam_props.summing_threshold	= qbam_dev->summing_threshold;
+	bam_props.manage		= qbam_dev->manage;
+	bam_props.irq			= qbam_dev->irq;
+
+	ret = sps_register_bam_device(&bam_props, &qbam_dev->handle);
+	if (ret)
+		qbam_err(qbam_dev, "error:%d sps_register_bam_device\n"
+			 "(phy:0x%lx virt:0x%lx irq:%d)\n",
+			 ret, (ulong) bam_props.phys_addr,
+			 (ulong) bam_props.virt_addr, qbam_dev->irq);
+	else
+		qbam_dev->deregister_required = true;
+
+	return ret;
+}
+
+
+static int qbam_alloc_chan(struct dma_chan *chan)
+{
+	return 0;
+}
+
+static void qbam_eot_callback(struct sps_event_notify *notify)
+{
+	struct qbam_async_tx_descriptor *qbam_desc = notify->data.transfer.user;
+	struct dma_async_tx_descriptor  *dma_desc  = &qbam_desc->dma_desc;
+	dma_async_tx_callback callback	= dma_desc->callback;
+	void *param			= dma_desc->callback_param;
+
+	if (callback)
+		callback(param);
+}
+
+static void qbam_error_callback(struct sps_event_notify *notify)
+{
+	struct qbam_channel *qbam_chan	= notify->user;
+
+	qbam_err(qbam_chan->qbam_dev, "error: qbam_error_callback(pipe:%d\n)",
+		 qbam_chan->bam_pipe.index);
+}
+
+static int qbam_connect_chan(struct qbam_channel *qbam_chan)
+{
+	int ret = 0;
+	struct qbam_device       *qbam_dev = qbam_chan->qbam_dev;
+	struct sps_register_event bam_eot_event = {
+		.mode		= SPS_TRIGGER_CALLBACK,
+		.options	= qbam_chan->bam_pipe.sps_register_event_flags,
+		.callback	= qbam_eot_callback,
+		};
+	struct sps_register_event bam_error_event = {
+		.mode		= SPS_TRIGGER_CALLBACK,
+		.options	= SPS_O_ERROR,
+		.callback	= qbam_error_callback,
+		.user		= qbam_chan,
+		};
+
+	ret = sps_connect(qbam_chan->bam_pipe.handle, &qbam_chan->bam_pipe.cfg);
+	if (ret) {
+		qbam_err(qbam_dev, "error:%d sps_connect(pipe:%d)\n", ret,
+			 qbam_chan->bam_pipe.index);
+		return ret;
+	}
+
+	ret = sps_register_event(qbam_chan->bam_pipe.handle, &bam_eot_event);
+	if (ret) {
+		qbam_err(qbam_dev, "error:%d sps_register_event(eot@pipe:%d)\n",
+			 ret, qbam_chan->bam_pipe.index);
+		goto need_disconnect;
+	}
+
+	ret = sps_register_event(qbam_chan->bam_pipe.handle, &bam_error_event);
+	if (ret) {
+		qbam_err(qbam_dev, "error:%d sps_register_event(err@pipe:%d)\n",
+			 ret, qbam_chan->bam_pipe.index);
+		goto need_disconnect;
+	}
+
+	return 0;
+
+need_disconnect:
+	ret = sps_disconnect(qbam_chan->bam_pipe.handle);
+	if (ret)
+		qbam_err(qbam_dev, "error:%d sps_disconnect(pipe:%d)\n", ret,
+			 qbam_chan->bam_pipe.index);
+	return ret;
+}
+
+/*
+ * qbam_slave_cfg - configure and connect a BAM pipe
+ *
+ * @cfg only cares about cfg->direction
+ */
+static int qbam_slave_cfg(struct dma_chan *chan,
+						struct dma_slave_config *cfg)
+{
+	int ret = 0;
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	struct qbam_device *qbam_dev = qbam_chan->qbam_dev;
+	struct sps_connect *pipe_cfg = &qbam_chan->bam_pipe.cfg;
+
+	if (!qbam_dev->handle) {
+		ret = qbam_init_bam_handle(qbam_dev);
+		if (ret)
+			return ret;
+	}
+
+	if (qbam_chan->bam_pipe.cfg.desc.base)
+		goto cfg_done;
+
+	ret = sps_get_config(qbam_chan->bam_pipe.handle,
+						&qbam_chan->bam_pipe.cfg);
+	if (ret) {
+		qbam_err(qbam_dev, "error:%d sps_get_config(0x%p)\n",
+			 ret, qbam_chan->bam_pipe.handle);
+		return ret;
+	}
+
+	qbam_chan->direction = cfg->direction;
+	if (cfg->direction == DMA_MEM_TO_DEV) {
+		pipe_cfg->source          = SPS_DEV_HANDLE_MEM;
+		pipe_cfg->destination     = qbam_dev->handle;
+		pipe_cfg->mode            = SPS_MODE_DEST;
+		pipe_cfg->src_pipe_index  = 0;
+		pipe_cfg->dest_pipe_index = qbam_chan->bam_pipe.index;
+	} else {
+		pipe_cfg->source          = qbam_dev->handle;
+		pipe_cfg->destination     = SPS_DEV_HANDLE_MEM;
+		pipe_cfg->mode            = SPS_MODE_SRC;
+		pipe_cfg->src_pipe_index  = qbam_chan->bam_pipe.index;
+		pipe_cfg->dest_pipe_index = 0;
+	}
+	pipe_cfg->options   =  qbam_chan->bam_pipe.sps_connect_flags;
+	pipe_cfg->desc.size = (qbam_chan->bam_pipe.num_descriptors + 1) *
+						 sizeof(struct sps_iovec);
+	/* managed dma_alloc_coherent() */
+	pipe_cfg->desc.base = dmam_alloc_coherent(qbam_dev->dma_dev.dev,
+						  pipe_cfg->desc.size,
+						  &pipe_cfg->desc.phys_base,
+						  GFP_KERNEL);
+	if (!pipe_cfg->desc.base) {
+		qbam_err(qbam_dev,
+			"error dma_alloc_coherent(desc-sz:%llu * n-descs:%d)\n",
+			(u64) sizeof(struct sps_iovec),
+			qbam_chan->bam_pipe.num_descriptors);
+		return -ENOMEM;
+	}
+cfg_done:
+	ret = qbam_connect_chan(qbam_chan);
+	if (ret)
+		dmam_free_coherent(qbam_dev->dma_dev.dev, pipe_cfg->desc.size,
+				 pipe_cfg->desc.base, pipe_cfg->desc.phys_base);
+
+	return ret;
+}
+
+static int qbam_flush_chan(struct dma_chan *chan)
+{
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	int ret = qbam_disconnect_chan(qbam_chan);
+
+	if (ret) {
+		qbam_err(qbam_chan->qbam_dev,
+			 "error: disconnect flush(pipe:%d\n)",
+			 qbam_chan->bam_pipe.index);
+		return ret;
+	}
+	ret = qbam_connect_chan(qbam_chan);
+	if (ret)
+		qbam_err(qbam_chan->qbam_dev,
+			 "error: reconnect flush(pipe:%d\n)",
+			 qbam_chan->bam_pipe.index);
+	return ret;
+}
+
+/* qbam_tx_submit - sets the descriptor as the next one to be executed */
+static dma_cookie_t qbam_tx_submit(struct dma_async_tx_descriptor *dma_desc)
+{
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(dma_desc->chan);
+	dma_cookie_t ret;
+
+	mutex_lock(&qbam_chan->lock);
+
+	ret = dma_cookie_assign(dma_desc);
+
+	mutex_unlock(&qbam_chan->lock);
+
+	return ret;
+}
+
+/*
+ * qbam_prep_slave_sg - creates qbam_xfer_buf from a list of sg
+ *
+ * @chan: dma channel
+ * @sgl: scatter gather list
+ * @sg_len: length of sg
+ * @direction: DMA transfer direction
+ * @flags: DMA flags
+ * @context: transfer context (unused)
+ * @return the newly created descriptor or negative ERR_PTR() on error
+ */
+static struct dma_async_tx_descriptor *qbam_prep_slave_sg(struct dma_chan *chan,
+	struct scatterlist *sgl, unsigned int sg_len,
+	enum dma_transfer_direction direction, unsigned long flags,
+	void *context)
+{
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	struct qbam_device *qbam_dev = qbam_chan->qbam_dev;
+	struct qbam_async_tx_descriptor *qbam_desc = &qbam_chan->pending_desc;
+
+	if (qbam_chan->direction != direction) {
+		qbam_err(qbam_dev,
+			"invalid dma transfer direction expected:%d given:%d\n",
+			qbam_chan->direction, direction);
+		return ERR_PTR(-EINVAL);
+	}
+
+	qbam_desc->dma_desc.chan	= &qbam_chan->chan;
+	qbam_desc->dma_desc.tx_submit	= qbam_tx_submit;
+	qbam_desc->sgl			= sgl;
+	qbam_desc->sg_len		= sg_len;
+	qbam_desc->flags		= flags;
+	return &qbam_desc->dma_desc;
+}
+
+/*
+ * qbam_issue_pending - queue pending descriptor to BAM
+ *
+ * Iterate over the transfers of the pending descriptor and push them to bam
+ */
+static void qbam_issue_pending(struct dma_chan *chan)
+{
+	int i;
+	int ret = 0;
+	struct qbam_channel *qbam_chan = DMA_TO_QBAM_CHAN(chan);
+	struct qbam_device  *qbam_dev  = qbam_chan->qbam_dev;
+	struct qbam_async_tx_descriptor *qbam_desc = &qbam_chan->pending_desc;
+	struct scatterlist		*sg;
+
+	mutex_lock(&qbam_chan->lock);
+	if (!qbam_chan->pending_desc.sgl) {
+		qbam_err(qbam_dev,
+		   "error qbam_issue_pending() no pending descriptor pipe:%d\n",
+		   qbam_chan->bam_pipe.index);
+		mutex_unlock(&qbam_chan->lock);
+		return;
+	}
+
+	for_each_sg(qbam_desc->sgl, sg, qbam_desc->sg_len, i) {
+
+		/* Add BAM flags only on the last buffer */
+		bool is_last_buf = (i == ((qbam_desc->sg_len) - 1));
+
+		ret = sps_transfer_one(qbam_chan->bam_pipe.handle,
+					sg_dma_address(sg), sg_dma_len(sg),
+					qbam_desc,
+					(is_last_buf ? qbam_desc->flags : 0));
+		if (ret < 0) {
+			qbam_chan->error = ret;
+
+			qbam_err(qbam_dev, "erorr:%d sps_transfer_one\n"
+				"(addr:0x%lx len:%d flags:0x%lx pipe:%d)\n",
+				ret, (ulong) sg_dma_address(sg), sg_dma_len(sg),
+				qbam_desc->flags, qbam_chan->bam_pipe.index);
+			break;
+		}
+	}
+
+	dma_cookie_complete(&qbam_desc->dma_desc);
+	qbam_chan->error = 0;
+	qbam_desc->sgl = NULL;
+	qbam_desc->sg_len = 0;
+	mutex_unlock(&qbam_chan->lock);
+};
+
+static int qbam_deregister_bam_dev(struct qbam_device *qbam_dev)
+{
+	int ret;
+
+	if (!qbam_dev->handle)
+		return 0;
+
+	ret = sps_deregister_bam_device(qbam_dev->handle);
+	if (ret)
+		qbam_err(qbam_dev,
+			"error:%d sps_deregister_bam_device(hndl:0x%lx) failed",
+			ret, qbam_dev->handle);
+	return ret;
+}
+
+static void qbam_pipes_free(struct qbam_device *qbam_dev)
+{
+	struct qbam_channel *qbam_chan_cur, *qbam_chan_next;
+
+	list_for_each_entry_safe(qbam_chan_cur, qbam_chan_next,
+			&qbam_dev->dma_dev.channels, chan.device_node) {
+		mutex_lock(&qbam_chan_cur->lock);
+		qbam_free_chan(&qbam_chan_cur->chan);
+		sps_free_endpoint(qbam_chan_cur->bam_pipe.handle);
+		list_del(&qbam_chan_cur->chan.device_node);
+		mutex_unlock(&qbam_chan_cur->lock);
+		kfree(qbam_chan_cur);
+	}
+}
+
+static int qbam_probe(struct platform_device *pdev)
+{
+	struct qbam_device *qbam_dev;
+	int ret;
+	bool managed_locally;
+	struct device_node *of_node = pdev->dev.of_node;
+
+	qbam_dev = devm_kzalloc(&pdev->dev, sizeof(*qbam_dev), GFP_KERNEL);
+	if (!qbam_dev)
+		return -ENOMEM;
+
+	qbam_dev->dma_dev.dev = &pdev->dev;
+	platform_set_drvdata(pdev, qbam_dev);
+
+	qbam_dev->mem_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!qbam_dev->mem_resource) {
+		qbam_err(qbam_dev, "missing 'reg' DT entry");
+		return -ENODEV;
+	}
+
+	qbam_dev->irq = platform_get_irq(pdev, 0);
+	if (qbam_dev->irq < 0) {
+		qbam_err(qbam_dev, "missing DT IRQ resource entry");
+		return -EINVAL;
+	}
+
+	ret = of_property_read_u32(of_node, QBAM_OF_SUM_THRESHOLD,
+				   &qbam_dev->summing_threshold);
+	if (ret) {
+		qbam_err(qbam_dev, "missing '%s' DT entry",
+			 QBAM_OF_SUM_THRESHOLD);
+		return ret;
+	}
+
+	/* read from DT and set sps_bam_props.manage */
+	managed_locally = of_property_read_bool(of_node, QBAM_OF_MANAGE_LOCAL);
+	qbam_dev->manage = managed_locally ? SPS_BAM_MGR_LOCAL :
+					     SPS_BAM_MGR_DEVICE_REMOTE;
+
+	/* Init channels */
+	INIT_LIST_HEAD(&qbam_dev->dma_dev.channels);
+
+	/* Set capabilities */
+	dma_cap_zero(qbam_dev->dma_dev.cap_mask);
+	dma_cap_set(DMA_SLAVE,		qbam_dev->dma_dev.cap_mask);
+	dma_cap_set(DMA_PRIVATE,	qbam_dev->dma_dev.cap_mask);
+
+	/* Initialize dmaengine callback apis */
+	qbam_dev->dma_dev.device_alloc_chan_resources	= qbam_alloc_chan;
+	qbam_dev->dma_dev.device_free_chan_resources	= qbam_free_chan;
+	qbam_dev->dma_dev.device_prep_slave_sg		= qbam_prep_slave_sg;
+	qbam_dev->dma_dev.device_terminate_all		= qbam_flush_chan;
+	qbam_dev->dma_dev.device_config			= qbam_slave_cfg;
+	qbam_dev->dma_dev.device_issue_pending		= qbam_issue_pending;
+	qbam_dev->dma_dev.device_tx_status		= qbam_tx_status;
+
+	/* Regiser to DMA framework */
+	dma_async_device_register(&qbam_dev->dma_dev);
+
+	/*
+	 * Do not return error in order to not break the existing
+	 * way of requesting channels.
+	 */
+	ret = of_dma_controller_register(of_node, qbam_dma_xlate, qbam_dev);
+	if (ret) {
+		qbam_err(qbam_dev, "error:%d of_dma_controller_register()\n",
+			 ret);
+		goto err_unregister_dma;
+	}
+	return 0;
+
+err_unregister_dma:
+	dma_async_device_unregister(&qbam_dev->dma_dev);
+	if (qbam_dev->deregister_required)
+		return qbam_deregister_bam_dev(qbam_dev);
+
+	return ret;
+}
+
+static int qbam_remove(struct platform_device *pdev)
+{
+	struct qbam_device *qbam_dev = platform_get_drvdata(pdev);
+
+	dma_async_device_unregister(&qbam_dev->dma_dev);
+
+	/* free BAM pipes resources */
+	qbam_pipes_free(qbam_dev);
+
+	if (qbam_dev->deregister_required)
+		return qbam_deregister_bam_dev(qbam_dev);
+
+	return 0;
+}
+
+static const struct of_device_id qbam_of_match[] = {
+	{ .compatible = "qcom,sps-dma" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, qbam_of_match);
+
+static struct platform_driver qbam_driver = {
+	.probe = qbam_probe,
+	.remove = qbam_remove,
+	.driver = {
+		.name = "qcom-sps-dma",
+		.owner = THIS_MODULE,
+		.of_match_table = qbam_of_match,
+	},
+};
+
+module_platform_driver(qbam_driver);
+
+MODULE_DESCRIPTION("DMA-API driver to qcom BAM");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:qcom-sps-dma");
diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
index 3cc035c..94a8e6a 100644
--- a/drivers/dma/qcom/gpi.c
+++ b/drivers/dma/qcom/gpi.c
@@ -131,9 +131,11 @@
 #define GPI_LABEL_SIZE (256)
 #define GPI_DBG_COMMON (99)
 #define MAX_CHANNELS_PER_GPII (2)
+#define GPI_TX_CHAN (0)
+#define GPI_RX_CHAN (1)
 #define CMD_TIMEOUT_MS (50)
 #define STATE_IGNORE (U32_MAX)
-#define REQ_OF_DMA_ARGS (6) /* # of arguments required from client */
+#define REQ_OF_DMA_ARGS (5) /* # of arguments required from client */
 
 struct __packed gpi_error_log_entry {
 	u32 routine : 4;
@@ -437,6 +439,9 @@
 	u32 max_gpii; /* maximum # of gpii instances available per gpi block */
 	u32 gpii_mask; /* gpii instances available for apps */
 	u32 ev_factor; /* ev ring length factor */
+	u32 smmu_cfg;
+	dma_addr_t iova_base;
+	size_t iova_size;
 	struct gpii *gpiis;
 	void *ilctxt;
 	u32 ipc_log_lvl;
@@ -509,6 +514,11 @@
 	struct gpii_chan *gpii_chan;
 };
 
+#define GPI_SMMU_ATTACH BIT(0)
+#define GPI_SMMU_S1_BYPASS BIT(1)
+#define GPI_SMMU_FAST BIT(2)
+#define GPI_SMMU_ATOMIC BIT(3)
+
 const u32 GPII_CHAN_DIR[MAX_CHANNELS_PER_GPII] = {
 	GPI_CHTYPE_DIR_OUT, GPI_CHTYPE_DIR_IN
 };
@@ -2464,12 +2474,53 @@
 	return ret;
 }
 
+static int gpi_find_avail_gpii(struct gpi_dev *gpi_dev, u32 seid)
+{
+	int gpii;
+	struct gpii_chan *tx_chan, *rx_chan;
+
+	/* check if same seid is already configured for another chid */
+	for (gpii = 0; gpii < gpi_dev->max_gpii; gpii++) {
+		if (!((1 << gpii) & gpi_dev->gpii_mask))
+			continue;
+
+		tx_chan = &gpi_dev->gpiis[gpii].gpii_chan[GPI_TX_CHAN];
+		rx_chan = &gpi_dev->gpiis[gpii].gpii_chan[GPI_RX_CHAN];
+
+		if (rx_chan->vc.chan.client_count && rx_chan->seid == seid)
+			return gpii;
+		if (tx_chan->vc.chan.client_count && tx_chan->seid == seid)
+			return gpii;
+	}
+
+	/* no channels configured with same seid, return next avail gpii */
+	for (gpii = 0; gpii < gpi_dev->max_gpii; gpii++) {
+		if (!((1 << gpii) & gpi_dev->gpii_mask))
+			continue;
+
+		tx_chan = &gpi_dev->gpiis[gpii].gpii_chan[GPI_TX_CHAN];
+		rx_chan = &gpi_dev->gpiis[gpii].gpii_chan[GPI_RX_CHAN];
+
+		/* check if gpii is configured */
+		if (tx_chan->vc.chan.client_count ||
+		    rx_chan->vc.chan.client_count)
+			continue;
+
+		/* found a free gpii */
+		return gpii;
+	}
+
+	/* no gpii instance available to use */
+	return -EIO;
+}
+
 /* gpi_of_dma_xlate: open client requested channel */
 static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args,
 					 struct of_dma *of_dma)
 {
 	struct gpi_dev *gpi_dev = (struct gpi_dev *)of_dma->of_dma_data;
-	u32 gpii, chid;
+	u32 seid, chid;
+	int gpii;
 	struct gpii_chan *gpii_chan;
 
 	if (args->args_count < REQ_OF_DMA_ARGS) {
@@ -2479,25 +2530,33 @@
 		return NULL;
 	}
 
-	/* Check if valid gpii instance */
-	gpii = args->args[0];
-	if (!((1 << gpii) & gpi_dev->gpii_mask)) {
-		GPI_ERR(gpi_dev, "gpii instance:%d is not supported\n", gpii);
-		return NULL;
-	}
-
-	chid = args->args[1];
+	chid = args->args[0];
 	if (chid >= MAX_CHANNELS_PER_GPII) {
 		GPI_ERR(gpi_dev, "gpii channel:%d not valid\n", chid);
 		return NULL;
 	}
 
-	/* get ring size, protocol, se_id, and priority */
+	seid = args->args[1];
+
+	/* find next available gpii to use */
+	gpii = gpi_find_avail_gpii(gpi_dev, seid);
+	if (gpii < 0) {
+		GPI_ERR(gpi_dev, "no available gpii instances\n");
+		return NULL;
+	}
+
 	gpii_chan = &gpi_dev->gpiis[gpii].gpii_chan[chid];
-	gpii_chan->seid = args->args[2];
-	gpii_chan->protocol = args->args[3];
-	gpii_chan->req_tres = args->args[4];
-	gpii_chan->priority = args->args[5];
+	if (gpii_chan->vc.chan.client_count) {
+		GPI_ERR(gpi_dev, "gpii:%d chid:%d seid:%d already configured\n",
+			gpii, chid, gpii_chan->seid);
+		return NULL;
+	}
+
+	/* get ring size, protocol, se_id, and priority */
+	gpii_chan->seid = seid;
+	gpii_chan->protocol = args->args[2];
+	gpii_chan->req_tres = args->args[3];
+	gpii_chan->priority = args->args[4];
 
 	GPI_LOG(gpi_dev,
 		"client req. gpii:%u chid:%u #_tre:%u priority:%u protocol:%u\n",
@@ -2562,52 +2621,123 @@
 	}
 }
 
+static struct dma_iommu_mapping *gpi_create_mapping(struct gpi_dev *gpi_dev)
+{
+	dma_addr_t base;
+	size_t size;
+
+	/*
+	 * If S1_BYPASS enabled then iommu space is not used, however framework
+	 * still require clients to create a mapping space before attaching. So
+	 * set to smallest size required by iommu framework.
+	 */
+	if (gpi_dev->smmu_cfg & GPI_SMMU_S1_BYPASS) {
+		base = 0;
+		size = PAGE_SIZE;
+	} else {
+		base = gpi_dev->iova_base;
+		size = gpi_dev->iova_size;
+	}
+
+	GPI_LOG(gpi_dev, "Creating iommu mapping of base:0x%llx size:%lu\n",
+		base, size);
+
+	return arm_iommu_create_mapping(&platform_bus_type, base, size);
+}
+
+static int gpi_dma_mask(struct gpi_dev *gpi_dev)
+{
+	int mask = 64;
+
+	if (gpi_dev->smmu_cfg && !(gpi_dev->smmu_cfg & GPI_SMMU_S1_BYPASS)) {
+		unsigned long addr;
+
+		addr = gpi_dev->iova_base + gpi_dev->iova_size + 1;
+		mask = find_last_bit(&addr, 64);
+	}
+
+	GPI_LOG(gpi_dev, "Setting dma mask to %d\n", mask);
+
+	return dma_set_mask(gpi_dev->dev, DMA_BIT_MASK(mask));
+}
+
 static int gpi_smmu_init(struct gpi_dev *gpi_dev)
 {
-	u64 size = PAGE_SIZE;
-	dma_addr_t base = 0x0;
-	struct dma_iommu_mapping *map;
-	int attr, ret;
+	struct dma_iommu_mapping *mapping = NULL;
+	int ret;
 
-	map = arm_iommu_create_mapping(&platform_bus_type, base, size);
-	if (IS_ERR_OR_NULL(map)) {
-		ret = PTR_ERR(map) ? : -EIO;
-		GPI_ERR(gpi_dev, "error create_mapping, ret:%d\n", ret);
-		return ret;
+	if (gpi_dev->smmu_cfg) {
+
+		/* create mapping table */
+		mapping = gpi_create_mapping(gpi_dev);
+		if (IS_ERR(mapping)) {
+			GPI_ERR(gpi_dev,
+				"Failed to create iommu mapping, ret:%ld\n",
+				PTR_ERR(mapping));
+			return PTR_ERR(mapping);
+		}
+
+		if (gpi_dev->smmu_cfg & GPI_SMMU_S1_BYPASS) {
+			int s1_bypass = 1;
+
+			ret = iommu_domain_set_attr(mapping->domain,
+					DOMAIN_ATTR_S1_BYPASS, &s1_bypass);
+			if (ret) {
+				GPI_ERR(gpi_dev,
+					"Failed to set attr S1_BYPASS, ret:%d\n",
+					ret);
+				goto release_mapping;
+			}
+		}
+
+		if (gpi_dev->smmu_cfg & GPI_SMMU_FAST) {
+			int fast = 1;
+
+			ret = iommu_domain_set_attr(mapping->domain,
+						    DOMAIN_ATTR_FAST, &fast);
+			if (ret) {
+				GPI_ERR(gpi_dev,
+					"Failed to set attr FAST, ret:%d\n",
+					ret);
+				goto release_mapping;
+			}
+		}
+
+		if (gpi_dev->smmu_cfg & GPI_SMMU_ATOMIC) {
+			int atomic = 1;
+
+			ret = iommu_domain_set_attr(mapping->domain,
+						DOMAIN_ATTR_ATOMIC, &atomic);
+			if (ret) {
+				GPI_ERR(gpi_dev,
+					"Failed to set attr ATOMIC, ret:%d\n",
+					ret);
+				goto release_mapping;
+			}
+		}
+
+		ret = arm_iommu_attach_device(gpi_dev->dev, mapping);
+		if (ret) {
+			GPI_ERR(gpi_dev,
+				"Failed with iommu_attach, ret:%d\n", ret);
+			goto release_mapping;
+		}
 	}
 
-	attr = 1;
-	ret = iommu_domain_set_attr(map->domain, DOMAIN_ATTR_ATOMIC, &attr);
+	ret = gpi_dma_mask(gpi_dev);
 	if (ret) {
-		GPI_ERR(gpi_dev, "error setting ATTTR_ATOMIC, ret:%d\n", ret);
-		goto error_smmu;
-	}
-
-	attr = 1;
-	ret = iommu_domain_set_attr(map->domain, DOMAIN_ATTR_S1_BYPASS, &attr);
-	if (ret) {
-		GPI_ERR(gpi_dev, "error setting S1_BYPASS, ret:%d\n", ret);
-		goto error_smmu;
-	}
-
-	ret = arm_iommu_attach_device(gpi_dev->dev, map);
-	if (ret) {
-		GPI_ERR(gpi_dev, "error iommu_attach, ret:%d\n", ret);
-		goto error_smmu;
-	}
-
-	ret = dma_set_mask(gpi_dev->dev, DMA_BIT_MASK(64));
-	if (ret) {
-		GPI_ERR(gpi_dev, "error setting dma_mask, ret:%d\n", ret);
+		GPI_ERR(gpi_dev, "Error setting dma_mask, ret:%d\n", ret);
 		goto error_set_mask;
 	}
 
 	return ret;
 
 error_set_mask:
-	arm_iommu_detach_device(gpi_dev->dev);
-error_smmu:
-	arm_iommu_release_mapping(map);
+	if (gpi_dev->smmu_cfg)
+		arm_iommu_detach_device(gpi_dev->dev);
+release_mapping:
+	if (mapping)
+		arm_iommu_release_mapping(mapping);
 	return ret;
 }
 
@@ -2656,6 +2786,36 @@
 		return ret;
 	}
 
+	ret = of_property_read_u32(gpi_dev->dev->of_node, "qcom,smmu-cfg",
+				   &gpi_dev->smmu_cfg);
+	if (ret) {
+		GPI_ERR(gpi_dev, "missing 'qcom,smmu-cfg' DT node\n");
+		return ret;
+	}
+	if (gpi_dev->smmu_cfg && !(gpi_dev->smmu_cfg & GPI_SMMU_S1_BYPASS)) {
+		u64 iova_range[2];
+
+		ret = of_property_count_elems_of_size(gpi_dev->dev->of_node,
+						      "qcom,iova-range",
+						      sizeof(iova_range));
+		if (ret != 1) {
+			GPI_ERR(gpi_dev,
+				"missing or incorrect 'qcom,iova-range' DT node ret:%d\n",
+				ret);
+		}
+
+		ret = of_property_read_u64_array(gpi_dev->dev->of_node,
+					"qcom,iova-range", iova_range,
+					sizeof(iova_range) / sizeof(u64));
+		if (ret) {
+			GPI_ERR(gpi_dev,
+				"could not read DT prop 'qcom,iova-range\n");
+			return ret;
+		}
+		gpi_dev->iova_base = iova_range[0];
+		gpi_dev->iova_size = iova_range[1];
+	}
+
 	ret = gpi_smmu_init(gpi_dev);
 	if (ret) {
 		GPI_ERR(gpi_dev, "error configuring smmu, ret:%d\n", ret);
diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 3f24aeb..2403475 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -149,6 +149,7 @@
 	match = of_match_node(ti_am335x_master_match, dma_node);
 	if (!match) {
 		dev_err(&pdev->dev, "DMA master is not supported\n");
+		of_node_put(dma_node);
 		return -EINVAL;
 	}
 
@@ -339,6 +340,7 @@
 	match = of_match_node(ti_dra7_master_match, dma_node);
 	if (!match) {
 		dev_err(&pdev->dev, "DMA master is not supported\n");
+		of_node_put(dma_node);
 		return -EINVAL;
 	}
 
diff --git a/drivers/edac/qcom_llcc_edac.c b/drivers/edac/qcom_llcc_edac.c
index 4b89cbf..038e89c 100644
--- a/drivers/edac/qcom_llcc_edac.c
+++ b/drivers/edac/qcom_llcc_edac.c
@@ -397,21 +397,6 @@
 	if (rc)
 		goto out_mem;
 
-	if (interrupt_mode) {
-		drv->ecc_irq = platform_get_irq_byname(pdev, "ecc_irq");
-		if (!drv->ecc_irq) {
-			rc = -ENODEV;
-			goto out_dev;
-		}
-
-		rc = devm_request_irq(dev, drv->ecc_irq, llcc_ecc_irq_handler,
-				IRQF_TRIGGER_HIGH, "llcc_ecc", edev_ctl);
-		if (rc) {
-			dev_err(dev, "failed to request ecc irq\n");
-			goto out_dev;
-		}
-	}
-
 	drv->llcc_banks = devm_kzalloc(&pdev->dev,
 		sizeof(u32) * drv->num_banks, GFP_KERNEL);
 
@@ -437,6 +422,21 @@
 
 	platform_set_drvdata(pdev, edev_ctl);
 
+	if (interrupt_mode) {
+		drv->ecc_irq = platform_get_irq_byname(pdev, "ecc_irq");
+		if (!drv->ecc_irq) {
+			rc = -ENODEV;
+			goto out_dev;
+		}
+
+		rc = devm_request_irq(dev, drv->ecc_irq, llcc_ecc_irq_handler,
+				IRQF_TRIGGER_HIGH, "llcc_ecc", edev_ctl);
+		if (rc) {
+			dev_err(dev, "failed to request ecc irq\n");
+			goto out_dev;
+		}
+	}
+
 	return 0;
 
 out_dev:
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f2bb512..063d176 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -703,24 +703,23 @@
 {
 	struct lineevent_state *le = p;
 	struct gpioevent_data ge;
-	int ret;
+	int ret, level;
 
 	ge.timestamp = ktime_get_real_ns();
+	level = gpiod_get_value_cansleep(le->desc);
 
 	if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE
 	    && le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
-		int level = gpiod_get_value_cansleep(le->desc);
-
 		if (level)
 			/* Emit low-to-high event */
 			ge.id = GPIOEVENT_EVENT_RISING_EDGE;
 		else
 			/* Emit high-to-low event */
 			ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
-	} else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE) {
+	} else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE && level) {
 		/* Emit low-to-high event */
 		ge.id = GPIOEVENT_EVENT_RISING_EDGE;
-	} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
+	} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE && !level) {
 		/* Emit high-to-low event */
 		ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
 	} else {
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index dc9511c..327bdf1 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -1301,6 +1301,7 @@
 		amdgpu_program_register_sequence(adev,
 						 pitcairn_mgcg_cgcg_init,
 						 (const u32)ARRAY_SIZE(pitcairn_mgcg_cgcg_init));
+		break;
 	case CHIP_VERDE:
 		amdgpu_program_register_sequence(adev,
 						 verde_golden_registers,
@@ -1325,6 +1326,7 @@
 		amdgpu_program_register_sequence(adev,
 						 oland_mgcg_cgcg_init,
 						 (const u32)ARRAY_SIZE(oland_mgcg_cgcg_init));
+		break;
 	case CHIP_HAINAN:
 		amdgpu_program_register_sequence(adev,
 						 hainan_golden_registers,
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 161c923..3e74e1a 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -315,6 +315,8 @@
 	bool edid_read;
 
 	wait_queue_head_t wq;
+	struct work_struct hpd_work;
+
 	struct drm_bridge bridge;
 	struct drm_connector connector;
 
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 8ed3906..213d892 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -402,6 +402,27 @@
 	return false;
 }
 
+static void adv7511_hpd_work(struct work_struct *work)
+{
+	struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+	enum drm_connector_status status;
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
+	if (ret < 0)
+		status = connector_status_disconnected;
+	else if (val & ADV7511_STATUS_HPD)
+		status = connector_status_connected;
+	else
+		status = connector_status_disconnected;
+
+	if (adv7511->connector.status != status) {
+		adv7511->connector.status = status;
+		drm_kms_helper_hotplug_event(adv7511->connector.dev);
+	}
+}
+
 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
 {
 	unsigned int irq0, irq1;
@@ -419,7 +440,7 @@
 	regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
 
 	if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
-		drm_helper_hpd_irq_event(adv7511->connector.dev);
+		schedule_work(&adv7511->hpd_work);
 
 	if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
 		adv7511->edid_read = true;
@@ -1006,6 +1027,8 @@
 			goto err_i2c_unregister_edid;
 	}
 
+	INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work);
+
 	if (i2c->irq) {
 		init_waitqueue_head(&adv7511->wq);
 
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 99011621..4e16dff 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1459,6 +1459,9 @@
 	if (config->funcs->atomic_check)
 		ret = config->funcs->atomic_check(state->dev, state);
 
+	if (ret)
+		return ret;
+
 	if (!state->allow_modeset) {
 		for_each_crtc_in_state(state, crtc, crtc_state, i) {
 			if (drm_atomic_crtc_needs_modeset(crtc_state)) {
@@ -1469,7 +1472,7 @@
 		}
 	}
 
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL(drm_atomic_check_only);
 
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index ac5437e..6394109 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -358,20 +358,13 @@
  */
 int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link)
 {
-	u8 value;
+	u8 value = DP_SET_POWER_D0;
 	int err;
 
 	/* DP_SET_POWER register is only available on DPCD v1.1 and later */
 	if (link->revision < 0x11)
 		return 0;
 
-	err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value);
-	if (err < 0)
-		return err;
-
-	value &= ~DP_SET_POWER_MASK;
-	value |= DP_SET_POWER_D0;
-
 	err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value);
 	if (err < 0)
 		return err;
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 465bacd..48e99ab 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -255,13 +255,13 @@
 	struct drm_gem_object *obj = ptr;
 	struct drm_device *dev = obj->dev;
 
+	if (dev->driver->gem_close_object)
+		dev->driver->gem_close_object(obj, file_priv);
+
 	if (drm_core_check_feature(dev, DRIVER_PRIME))
 		drm_gem_remove_prime_handles(obj, file_priv);
 	drm_vma_node_revoke(&obj->vma_node, file_priv);
 
-	if (dev->driver->gem_close_object)
-		dev->driver->gem_close_object(obj, file_priv);
-
 	drm_gem_object_handle_unreference_unlocked(obj);
 
 	return 0;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index afdd55d..1ac9a95 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -264,8 +264,8 @@
 		if (ret)
 			return ret;
 
-		if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
-			DRM_ERROR("relocation %u outside object", i);
+		if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) {
+			DRM_ERROR("relocation %u outside object\n", i);
 			return -EINVAL;
 		}
 
diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
index 95a7277..89a7774 100644
--- a/drivers/gpu/drm/i915/intel_color.c
+++ b/drivers/gpu/drm/i915/intel_color.c
@@ -394,6 +394,7 @@
 		}
 
 		/* Program the max register to clamp values > 1.0. */
+		i = lut_size - 1;
 		I915_WRITE(PREC_PAL_GC_MAX(pipe, 0),
 			   drm_color_lut_extract(lut[i].red, 16));
 		I915_WRITE(PREC_PAL_GC_MAX(pipe, 1),
diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index 4015832..c81832a 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -161,7 +161,8 @@
 	sde/sde_hw_color_processing_v1_7.o \
 	sde/sde_reg_dma.o \
 	sde/sde_hw_reg_dma_v1.o \
-	sde/sde_hw_dsc.o
+	sde/sde_hw_dsc.o \
+	sde/sde_hw_ds.o
 
 msm_drm-$(CONFIG_DRM_SDE_WB) += sde/sde_wb.o \
 	sde/sde_encoder_phys_wb.o
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 961d47f..8214127 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -210,7 +210,14 @@
 void adreno_flush(struct msm_gpu *gpu)
 {
 	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
-	uint32_t wptr = get_wptr(gpu->rb);
+	uint32_t wptr;
+
+	/*
+	 * Mask wptr value that we calculate to fit in the HW range. This is
+	 * to account for the possibility that the last command fit exactly into
+	 * the ringbuffer and rb->next hasn't wrapped to zero yet
+	 */
+	wptr = get_wptr(gpu->rb) & ((gpu->rb->size / 4) - 1);
 
 	/* ensure writes to ringbuffer have hit system memory: */
 	mb();
diff --git a/drivers/gpu/drm/msm/dp/dp_audio.c b/drivers/gpu/drm/msm/dp/dp_audio.c
index c263115..c4a60dc 100644
--- a/drivers/gpu/drm/msm/dp/dp_audio.c
+++ b/drivers/gpu/drm/msm/dp/dp_audio.c
@@ -379,7 +379,7 @@
 	case DP_LINK_BW_5_4:
 		select = 2;
 		break;
-	case DP_LINK_RATE_810:
+	case DP_LINK_BW_8_1:
 		select = 3;
 		break;
 	default:
@@ -771,8 +771,10 @@
 	dp_audio->off = dp_audio_off;
 
 	rc = dp_audio_init_ext_disp(audio);
-	if (rc)
+	if (rc) {
+		devm_kfree(&pdev->dev, audio);
 		goto error;
+	}
 
 	catalog->init(catalog);
 
@@ -790,5 +792,5 @@
 
 	audio = container_of(dp_audio, struct dp_audio_private, dp_audio);
 
-	kzfree(audio);
+	devm_kfree(&audio->pdev->dev, audio);
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c
index 9106027..acbaec4 100644
--- a/drivers/gpu/drm/msm/dp/dp_aux.c
+++ b/drivers/gpu/drm/msm/dp/dp_aux.c
@@ -38,6 +38,10 @@
 	bool cmd_busy;
 	bool native;
 	bool read;
+	bool no_send_addr;
+	bool no_send_stop;
+	u32 offset;
+	u32 segment;
 
 	struct drm_dp_aux drm_aux;
 };
@@ -102,9 +106,19 @@
 		aux->catalog->write_data(aux->catalog);
 	}
 
+	aux->catalog->clear_trans(aux->catalog, false);
+	aux->catalog->clear_hw_interrupts(aux->catalog);
+
 	reg = 0; /* Transaction number == 1 */
-	if (!aux->native) /* i2c */
-		reg |= (BIT(8) | BIT(10) | BIT(11));
+	if (!aux->native) { /* i2c */
+		reg |= BIT(8);
+
+		if (aux->no_send_addr)
+			reg |= BIT(10);
+
+		if (aux->no_send_stop)
+			reg |= BIT(11);
+	}
 
 	reg |= BIT(9);
 	aux->catalog->data = reg;
@@ -150,9 +164,11 @@
 {
 	u32 data;
 	u8 *dp;
-	u32 i;
+	u32 i, actual_i;
 	u32 len = msg->size;
 
+	aux->catalog->clear_trans(aux->catalog, true);
+
 	data = 0;
 	data |= DP_AUX_DATA_INDEX_WRITE; /* INDEX_WRITE */
 	data |= BIT(0);  /* read */
@@ -168,6 +184,11 @@
 	for (i = 0; i < len; i++) {
 		data = aux->catalog->read_data(aux->catalog);
 		*dp++ = (u8)((data >> 8) & 0xff);
+
+		actual_i = (data >> 16) & 0xFF;
+		if (i != actual_i)
+			pr_warn("Index mismatch: expected %d, found %d\n",
+				i, actual_i);
 	}
 }
 
@@ -183,6 +204,10 @@
 		aux->aux_error_num = DP_AUX_ERR_TOUT;
 	if (isr & DP_INTR_NACK_DEFER)
 		aux->aux_error_num = DP_AUX_ERR_NACK;
+	if (isr & DP_INTR_AUX_ERROR) {
+		aux->aux_error_num = DP_AUX_ERR_PHY;
+		aux->catalog->clear_hw_interrupts(aux->catalog);
+	}
 
 	complete(&aux->comp);
 }
@@ -207,6 +232,10 @@
 			aux->aux_error_num = DP_AUX_ERR_NACK;
 		if (isr & DP_INTR_I2C_DEFER)
 			aux->aux_error_num = DP_AUX_ERR_DEFER;
+		if (isr & DP_INTR_AUX_ERROR) {
+			aux->aux_error_num = DP_AUX_ERR_PHY;
+			aux->catalog->clear_hw_interrupts(aux->catalog);
+		}
 	}
 
 	complete(&aux->comp);
@@ -250,6 +279,87 @@
 	aux->catalog->reset(aux->catalog);
 }
 
+static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux,
+		struct drm_dp_aux_msg *input_msg)
+{
+	u32 const edid_address = 0x50;
+	u32 const segment_address = 0x30;
+	bool i2c_read = input_msg->request &
+		(DP_AUX_I2C_READ & DP_AUX_NATIVE_READ);
+	u8 *data = NULL;
+
+	if (aux->native || i2c_read || ((input_msg->address != edid_address) &&
+		(input_msg->address != segment_address)))
+		return;
+
+
+	data = input_msg->buffer;
+	if (input_msg->address == segment_address)
+		aux->segment = *data;
+	else
+		aux->offset = *data;
+}
+
+/**
+ * dp_aux_transfer_helper() - helper function for EDID read transactions
+ *
+ * @aux: DP AUX private structure
+ * @input_msg: input message from DRM upstream APIs
+ *
+ * return: void
+ *
+ * This helper function is used to fix EDID reads for non-compliant
+ * sinks that do not handle the i2c middle-of-transaction flag correctly.
+ */
+static void dp_aux_transfer_helper(struct dp_aux_private *aux,
+		struct drm_dp_aux_msg *input_msg)
+{
+	struct drm_dp_aux_msg helper_msg;
+	u32 const message_size = 0x10;
+	u32 const segment_address = 0x30;
+	bool i2c_mot = input_msg->request & DP_AUX_I2C_MOT;
+	bool i2c_read = input_msg->request &
+		(DP_AUX_I2C_READ & DP_AUX_NATIVE_READ);
+
+	if (!i2c_mot || !i2c_read || (input_msg->size == 0))
+		return;
+
+	aux->read = false;
+	aux->cmd_busy = true;
+	aux->no_send_addr = true;
+	aux->no_send_stop = true;
+
+	/*
+	 * Send the segment address for every i2c read in which the
+	 * middle-of-tranaction flag is set. This is required to support EDID
+	 * reads of more than 2 blocks as the segment address is reset to 0
+	 * since we are overriding the middle-of-transaction flag for read
+	 * transactions.
+	 */
+	memset(&helper_msg, 0, sizeof(helper_msg));
+	helper_msg.address = segment_address;
+	helper_msg.buffer = &aux->segment;
+	helper_msg.size = 1;
+	dp_aux_cmd_fifo_tx(aux, &helper_msg);
+
+	/*
+	 * Send the offset address for every i2c read in which the
+	 * middle-of-transaction flag is set. This will ensure that the sink
+	 * will update its read pointer and return the correct portion of the
+	 * EDID buffer in the subsequent i2c read trasntion triggered in the
+	 * native AUX transfer function.
+	 */
+	memset(&helper_msg, 0, sizeof(helper_msg));
+	helper_msg.address = input_msg->address;
+	helper_msg.buffer = &aux->offset;
+	helper_msg.size = 1;
+	dp_aux_cmd_fifo_tx(aux, &helper_msg);
+	aux->offset += message_size;
+
+	if (aux->offset == 0x80 || aux->offset == 0x100)
+		aux->segment = 0x0; /* reset segment at end of block */
+}
+
 /*
  * This function does the real job to process an AUX transaction.
  * It will call aux_reset() function to reset the AUX channel,
@@ -268,8 +378,6 @@
 	mutex_lock(&aux->mutex);
 
 	aux->native = msg->request & (DP_AUX_NATIVE_WRITE & DP_AUX_NATIVE_READ);
-	aux->read = msg->request & (DP_AUX_I2C_READ & DP_AUX_NATIVE_READ);
-	aux->cmd_busy = true;
 
 	/* Ignore address only message */
 	if ((msg->size == 0) || (msg->buffer == NULL)) {
@@ -288,6 +396,20 @@
 		goto unlock_exit;
 	}
 
+	dp_aux_update_offset_and_segment(aux, msg);
+	dp_aux_transfer_helper(aux, msg);
+
+	aux->read = msg->request & (DP_AUX_I2C_READ & DP_AUX_NATIVE_READ);
+	aux->cmd_busy = true;
+
+	if (aux->read) {
+		aux->no_send_addr = true;
+		aux->no_send_stop = false;
+	} else {
+		aux->no_send_addr = true;
+		aux->no_send_stop = true;
+	}
+
 	ret = dp_aux_cmd_fifo_tx(aux, msg);
 	if ((ret < 0) && aux->native) {
 		aux->retry_cnt++;
@@ -341,11 +463,11 @@
 
 	aux = container_of(dp_aux, struct dp_aux_private, dp_aux);
 
+	dp_aux_reset_phy_config_indices(aux_cfg);
+	aux->catalog->setup(aux->catalog, aux_cfg);
 	aux->catalog->reset(aux->catalog);
 	aux->catalog->enable(aux->catalog, true);
 	aux->retry_cnt = 0;
-	dp_aux_reset_phy_config_indices(aux_cfg);
-	aux->catalog->setup(aux->catalog, aux_cfg);
 }
 
 static void dp_aux_deinit(struct dp_aux *dp_aux)
@@ -451,5 +573,7 @@
 
 	aux = container_of(dp_aux, struct dp_aux_private, dp_aux);
 
+	mutex_destroy(&aux->mutex);
+
 	devm_kfree(aux->dev, aux);
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_aux.h b/drivers/gpu/drm/msm/dp/dp_aux.h
index 5d96fd9..85761ce 100644
--- a/drivers/gpu/drm/msm/dp/dp_aux.h
+++ b/drivers/gpu/drm/msm/dp/dp_aux.h
@@ -25,6 +25,7 @@
 	DP_AUX_ERR_NACK	= -3,
 	DP_AUX_ERR_DEFER	= -4,
 	DP_AUX_ERR_NACK_DEFER	= -5,
+	DP_AUX_ERR_PHY	= -6,
 };
 
 struct dp_aux {
diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c
index 94bd199..2894e82 100644
--- a/drivers/gpu/drm/msm/dp/dp_catalog.c
+++ b/drivers/gpu/drm/msm/dp/dp_catalog.c
@@ -15,10 +15,14 @@
 #define pr_fmt(fmt)	"[drm-dp] %s: " fmt, __func__
 
 #include <linux/delay.h>
+#include <drm/drm_dp_helper.h>
 
 #include "dp_catalog.h"
 #include "dp_reg.h"
 
+#define DP_GET_MSB(x)	(x >> 8)
+#define DP_GET_LSB(x)	(x & 0xff)
+
 #define dp_read(offset) readl_relaxed((offset))
 #define dp_write(offset, data) writel_relaxed((data), (offset))
 
@@ -127,6 +131,58 @@
 	return rc;
 }
 
+static int dp_catalog_aux_clear_trans(struct dp_catalog_aux *aux, bool read)
+{
+	int rc = 0;
+	u32 data = 0;
+	struct dp_catalog_private *catalog;
+	void __iomem *base;
+
+	if (!aux) {
+		pr_err("invalid input\n");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	dp_catalog_get_priv(aux);
+	base = catalog->io->ctrl_io.base;
+
+	if (read) {
+		data = dp_read(base + DP_AUX_TRANS_CTRL);
+		data &= ~BIT(9);
+		dp_write(base + DP_AUX_TRANS_CTRL, data);
+	} else {
+		dp_write(base + DP_AUX_TRANS_CTRL, 0);
+	}
+end:
+	return rc;
+}
+
+static void dp_catalog_aux_clear_hw_interrupts(struct dp_catalog_aux *aux)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *phy_base;
+	u32 data = 0;
+
+	if (!aux) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(aux);
+	phy_base = catalog->io->phy_io.base;
+
+	data = dp_read(phy_base + DP_PHY_AUX_INTERRUPT_STATUS);
+	pr_debug("PHY_AUX_INTERRUPT_STATUS=0x%08x\n", data);
+
+	dp_write(phy_base + DP_PHY_AUX_INTERRUPT_CLEAR, 0x1f);
+	wmb(); /* make sure 0x1f is written before next write */
+	dp_write(phy_base + DP_PHY_AUX_INTERRUPT_CLEAR, 0x9f);
+	wmb(); /* make sure 0x9f is written before next write */
+	dp_write(phy_base + DP_PHY_AUX_INTERRUPT_CLEAR, 0);
+	wmb(); /* make sure register is cleared */
+}
+
 static void dp_catalog_aux_reset(struct dp_catalog_aux *aux)
 {
 	u32 aux_ctrl;
@@ -149,6 +205,7 @@
 
 	aux_ctrl &= ~BIT(1);
 	dp_write(base + DP_AUX_CTRL, aux_ctrl);
+	wmb(); /* make sure AUX reset is done here */
 }
 
 static void dp_catalog_aux_enable(struct dp_catalog_aux *aux, bool enable)
@@ -168,14 +225,15 @@
 	aux_ctrl = dp_read(base + DP_AUX_CTRL);
 
 	if (enable) {
+		aux_ctrl |= BIT(0);
+		dp_write(base + DP_AUX_CTRL, aux_ctrl);
+		wmb(); /* make sure AUX module is enabled */
 		dp_write(base + DP_TIMEOUT_COUNT, 0xffff);
 		dp_write(base + DP_AUX_LIMITS, 0xffff);
-		aux_ctrl |= BIT(0);
 	} else {
 		aux_ctrl &= ~BIT(0);
+		dp_write(base + DP_AUX_CTRL, aux_ctrl);
 	}
-
-	dp_write(base + DP_AUX_CTRL, aux_ctrl);
 }
 
 static void dp_catalog_aux_update_cfg(struct dp_catalog_aux *aux,
@@ -215,13 +273,12 @@
 
 	dp_catalog_get_priv(aux);
 
-	dp_write(catalog->io->phy_io.base + DP_PHY_PD_CTL, 0x02);
+	dp_write(catalog->io->phy_io.base + DP_PHY_PD_CTL, 0x65);
 	wmb(); /* make sure PD programming happened */
-	dp_write(catalog->io->phy_io.base + DP_PHY_PD_CTL, 0x7d);
 
 	/* Turn on BIAS current for PHY/PLL */
 	dp_write(catalog->io->dp_pll_io.base +
-		QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x3f);
+		QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x1b);
 
 	/* DP AUX CFG register programming */
 	for (i = 0; i < PHY_AUX_CFG_MAX; i++) {
@@ -233,6 +290,7 @@
 	}
 
 	dp_write(catalog->io->phy_io.base + DP_PHY_AUX_INTERRUPT_MASK, 0x1F);
+	wmb(); /* make sure AUX configuration is done before enabling it */
 }
 
 static void dp_catalog_aux_get_irq(struct dp_catalog_aux *aux, bool cmd_busy)
@@ -249,9 +307,6 @@
 	dp_catalog_get_priv(aux);
 	base = catalog->io->ctrl_io.base;
 
-	if (cmd_busy)
-		dp_write(base + DP_AUX_TRANS_CTRL, 0x0);
-
 	aux->isr = dp_read(base + DP_INTR_STATUS);
 	aux->isr &= ~DP_INTR_MASK1;
 	ack = aux->isr & DP_INTERRUPT_STATUS1;
@@ -277,6 +332,174 @@
 	return dp_read(base + DP_HDCP_STATUS);
 }
 
+static void dp_catalog_ctrl_setup_infoframe_sdp(struct dp_catalog_ctrl *ctrl)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *base;
+	u32 header, data;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(ctrl);
+	base = catalog->io->ctrl_io.base;
+
+	header = dp_read(base + MMSS_DP_VSCEXT_0);
+	header |= ctrl->hdr_data.vsc_hdr_byte1;
+	dp_write(base + MMSS_DP_VSCEXT_0, header);
+
+	header = dp_read(base + MMSS_DP_VSCEXT_1);
+	header |= ctrl->hdr_data.vsc_hdr_byte1;
+	dp_write(base + MMSS_DP_VSCEXT_1, header);
+
+	header = dp_read(base + MMSS_DP_VSCEXT_1);
+	header |= ctrl->hdr_data.vsc_hdr_byte1;
+	dp_write(base + MMSS_DP_VSCEXT_1, header);
+
+	header =  ctrl->hdr_data.version;
+	header |=  ctrl->hdr_data.length << 8;
+	header |= ctrl->hdr_data.eotf << 16;
+	header |= (ctrl->hdr_data.descriptor_id << 24);
+	dp_write(base + MMSS_DP_VSCEXT_2, header);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.display_primaries_x[0]) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_x[0]) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.display_primaries_y[0]) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_y[0]) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_3, data);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.display_primaries_x[1]) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_x[1]) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.display_primaries_y[1]) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_y[1]) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_4, data);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.display_primaries_x[2]) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_x[2]) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.display_primaries_y[2]) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.display_primaries_y[2]) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_5, data);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.white_point_x) |
+		(DP_GET_MSB(ctrl->hdr_data.white_point_x) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.white_point_y) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.white_point_y) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_6, data);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.max_luminance) |
+		(DP_GET_MSB(ctrl->hdr_data.max_luminance) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.min_luminance) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.min_luminance) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_7, data);
+
+	data = (DP_GET_LSB(ctrl->hdr_data.max_content_light_level) |
+		(DP_GET_MSB(ctrl->hdr_data.max_content_light_level) << 8) |
+		(DP_GET_LSB(ctrl->hdr_data.max_average_light_level) << 16) |
+		(DP_GET_MSB(ctrl->hdr_data.max_average_light_level) << 24));
+	dp_write(base + MMSS_DP_VSCEXT_8, data);
+
+	dp_write(base + MMSS_DP_VSCEXT_9, 0x00);
+}
+
+static void dp_catalog_ctrl_setup_vsc_sdp(struct dp_catalog_ctrl *ctrl)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *base;
+	u32 value;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(ctrl);
+	base = catalog->io->ctrl_io.base;
+
+	value = dp_read(base + MMSS_DP_GENERIC0_0);
+	value |= ctrl->hdr_data.vsc_hdr_byte1;
+	dp_write(base + MMSS_DP_GENERIC0_0, value);
+
+	value = dp_read(base + MMSS_DP_GENERIC0_1);
+	value |= ctrl->hdr_data.vsc_hdr_byte2;
+	dp_write(base + MMSS_DP_GENERIC0_1, value);
+
+	value = dp_read(base + MMSS_DP_GENERIC0_1);
+	value |= ctrl->hdr_data.vsc_hdr_byte3;
+	dp_write(base + MMSS_DP_GENERIC0_1, value);
+
+	dp_write(base + MMSS_DP_GENERIC0_2, 0x00);
+	dp_write(base + MMSS_DP_GENERIC0_3, 0x00);
+	dp_write(base + MMSS_DP_GENERIC0_4, 0x00);
+	dp_write(base + MMSS_DP_GENERIC0_5, 0x00);
+
+	dp_write(base + MMSS_DP_GENERIC0_6, ctrl->hdr_data.pkt_payload);
+	dp_write(base + MMSS_DP_GENERIC0_7, 0x00);
+	dp_write(base + MMSS_DP_GENERIC0_8, 0x00);
+	dp_write(base + MMSS_DP_GENERIC0_9, 0x00);
+}
+
+static void dp_catalog_ctrl_config_hdr(struct dp_catalog_ctrl *ctrl)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *base;
+	u32 cfg, cfg2;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(ctrl);
+	base = catalog->io->ctrl_io.base;
+
+	cfg = dp_read(base + MMSS_DP_SDP_CFG);
+	/* VSCEXT_SDP_EN */
+	cfg |= BIT(16);
+
+	/* GEN0_SDP_EN */
+	cfg |= BIT(17);
+
+	dp_write(base + MMSS_DP_SDP_CFG, cfg);
+
+	cfg2 = dp_read(base + MMSS_DP_SDP_CFG2);
+	/* Generic0 SDP Payload is 19 bytes which is > 16, so Bit16 is 1 */
+	cfg2 |= BIT(16);
+	dp_write(base + MMSS_DP_SDP_CFG2, cfg2);
+
+	dp_catalog_ctrl_setup_vsc_sdp(ctrl);
+	dp_catalog_ctrl_setup_infoframe_sdp(ctrl);
+
+	cfg = dp_read(base + DP_MISC1_MISC0);
+	/* Indicates presence of VSC */
+	cfg |= BIT(6) << 8;
+
+	dp_write(base + DP_MISC1_MISC0, cfg);
+
+	cfg = dp_read(base + DP_CONFIGURATION_CTRL);
+	/* Send VSC */
+	cfg |= BIT(7);
+
+	switch (ctrl->hdr_data.bpc) {
+	default:
+	case 10:
+		cfg |= BIT(9);
+		break;
+	case 8:
+		cfg |= BIT(8);
+		break;
+	}
+
+	dp_write(base + DP_CONFIGURATION_CTRL, cfg);
+
+	cfg = dp_read(base + DP_COMPRESSION_MODE_CTRL);
+
+	/* Trigger SDP values in registers */
+	cfg |= BIT(8);
+	dp_write(base + DP_COMPRESSION_MODE_CTRL, cfg);
+}
+
 static void dp_catalog_ctrl_update_transfer_unit(struct dp_catalog_ctrl *ctrl)
 {
 	struct dp_catalog_private *catalog;
@@ -381,7 +604,7 @@
 static void dp_catalog_ctrl_config_misc(struct dp_catalog_ctrl *ctrl,
 					u32 cc, u32 tb)
 {
-	u32 misc_val = cc;
+	u32 misc_val;
 	struct dp_catalog_private *catalog;
 	void __iomem *base;
 
@@ -393,6 +616,8 @@
 	dp_catalog_get_priv(ctrl);
 	base = catalog->io->ctrl_io.base;
 
+	misc_val = dp_read(base + DP_MISC1_MISC0);
+	misc_val |= cc;
 	misc_val |= (tb << 5);
 	misc_val |= BIT(0); /* Configure clock to synchronous mode */
 
@@ -408,7 +633,8 @@
 	u32 mvid, nvid;
 	u64 mvid_calc;
 	u32 const nvid_fixed = 0x8000;
-	u32 const link_rate = 540000;
+	u32 const link_rate_hbr2 = 540000;
+	u32 const link_rate_hbr3 = 810000;
 	struct dp_catalog_private *catalog;
 	void __iomem *base_cc, *base_ctrl;
 
@@ -449,8 +675,11 @@
 
 		pr_debug("rate = %d\n", rate);
 
-		if (link_rate == rate)
+		if (link_rate_hbr2 == rate)
 			nvid *= 2;
+
+		if (link_rate_hbr3 == rate)
+			nvid *= 3;
 	}
 
 	base_ctrl = catalog->io->ctrl_io.base;
@@ -493,6 +722,43 @@
 		pr_err("set link_train=%d failed\n", pattern);
 }
 
+static void dp_catalog_ctrl_usb_reset(struct dp_catalog_ctrl *ctrl, bool flip)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *base;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(ctrl);
+
+	base = catalog->io->usb3_dp_com.base;
+
+	dp_write(base + USB3_DP_COM_RESET_OVRD_CTRL, 0x0a);
+	dp_write(base + USB3_DP_COM_PHY_MODE_CTRL, 0x02);
+	dp_write(base + USB3_DP_COM_SW_RESET, 0x01);
+	/* make sure usb3 com phy software reset is done */
+	wmb();
+
+	if (!flip) /* CC1 */
+		dp_write(base + USB3_DP_COM_TYPEC_CTRL, 0x02);
+	else /* CC2 */
+		dp_write(base + USB3_DP_COM_TYPEC_CTRL, 0x03);
+
+	dp_write(base + USB3_DP_COM_SWI_CTRL, 0x00);
+	dp_write(base + USB3_DP_COM_SW_RESET, 0x00);
+	/* make sure the software reset is done */
+	wmb();
+
+	dp_write(base + USB3_DP_COM_POWER_DOWN_CTRL, 0x01);
+	dp_write(base + USB3_DP_COM_RESET_OVRD_CTRL, 0x00);
+	/* make sure phy is brought out of reset */
+	wmb();
+
+}
+
 static void dp_catalog_ctrl_reset(struct dp_catalog_ctrl *ctrl)
 {
 	u32 sw_reset;
@@ -706,6 +972,82 @@
 	}
 }
 
+static void dp_catalog_ctrl_send_phy_pattern(struct dp_catalog_ctrl *ctrl,
+			u32 pattern)
+{
+	struct dp_catalog_private *catalog;
+	u32 value = 0x0;
+	void __iomem *base = NULL;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp_catalog_get_priv(ctrl);
+
+	base = catalog->io->ctrl_io.base;
+
+	dp_write(base + DP_STATE_CTRL, 0x0);
+
+	switch (pattern) {
+	case DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING:
+		dp_write(base + DP_STATE_CTRL, 0x1);
+		break;
+	case DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT:
+		value &= ~(1 << 16);
+		dp_write(base + DP_HBR2_COMPLIANCE_SCRAMBLER_RESET, value);
+		value |= 0xFC;
+		dp_write(base + DP_HBR2_COMPLIANCE_SCRAMBLER_RESET, value);
+		dp_write(base + DP_MAINLINK_LEVELS, 0x2);
+		dp_write(base + DP_STATE_CTRL, 0x10);
+		break;
+	case DP_TEST_PHY_PATTERN_PRBS7:
+		dp_write(base + DP_STATE_CTRL, 0x20);
+		break;
+	case DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN:
+		dp_write(base + DP_STATE_CTRL, 0x40);
+		/* 00111110000011111000001111100000 */
+		dp_write(base + DP_TEST_80BIT_CUSTOM_PATTERN_REG0, 0x3E0F83E0);
+		/* 00001111100000111110000011111000 */
+		dp_write(base + DP_TEST_80BIT_CUSTOM_PATTERN_REG1, 0x0F83E0F8);
+		/* 1111100000111110 */
+		dp_write(base + DP_TEST_80BIT_CUSTOM_PATTERN_REG2, 0x0000F83E);
+		break;
+	case DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN:
+		value = BIT(16);
+		dp_write(base + DP_HBR2_COMPLIANCE_SCRAMBLER_RESET, value);
+		value |= 0xFC;
+		dp_write(base + DP_HBR2_COMPLIANCE_SCRAMBLER_RESET, value);
+		dp_write(base + DP_MAINLINK_LEVELS, 0x2);
+		dp_write(base + DP_STATE_CTRL, 0x10);
+		break;
+	default:
+		pr_debug("No valid test pattern requested: 0x%x\n", pattern);
+		return;
+	}
+
+	/* Make sure the test pattern is programmed in the hardware */
+	wmb();
+}
+
+static u32 dp_catalog_ctrl_read_phy_pattern(struct dp_catalog_ctrl *ctrl)
+{
+	struct dp_catalog_private *catalog;
+	void __iomem *base = NULL;
+
+	if (!ctrl) {
+		pr_err("invalid input\n");
+		return 0;
+	}
+
+	dp_catalog_get_priv(ctrl);
+
+	base = catalog->io->ctrl_io.base;
+
+	return dp_read(base + DP_MAINLINK_READY);
+}
+
 /* panel related catalog functions */
 static int dp_catalog_panel_timing_cfg(struct dp_catalog_panel *panel)
 {
@@ -922,11 +1264,13 @@
 		.read_data     = dp_catalog_aux_read_data,
 		.write_data    = dp_catalog_aux_write_data,
 		.write_trans   = dp_catalog_aux_write_trans,
+		.clear_trans   = dp_catalog_aux_clear_trans,
 		.reset         = dp_catalog_aux_reset,
 		.update_aux_cfg = dp_catalog_aux_update_cfg,
 		.enable        = dp_catalog_aux_enable,
 		.setup         = dp_catalog_aux_setup,
 		.get_irq       = dp_catalog_aux_get_irq,
+		.clear_hw_interrupts = dp_catalog_aux_clear_hw_interrupts,
 	};
 	struct dp_catalog_ctrl ctrl = {
 		.state_ctrl     = dp_catalog_ctrl_state_ctrl,
@@ -937,6 +1281,7 @@
 		.config_msa     = dp_catalog_ctrl_config_msa,
 		.set_pattern    = dp_catalog_ctrl_set_pattern,
 		.reset          = dp_catalog_ctrl_reset,
+		.usb_reset      = dp_catalog_ctrl_usb_reset,
 		.mainlink_ready = dp_catalog_ctrl_mainlink_ready,
 		.enable_irq     = dp_catalog_ctrl_enable_irq,
 		.hpd_config     = dp_catalog_ctrl_hpd_config,
@@ -944,8 +1289,11 @@
 		.phy_lane_cfg   = dp_catalog_ctrl_phy_lane_cfg,
 		.update_vx_px   = dp_catalog_ctrl_update_vx_px,
 		.get_interrupt  = dp_catalog_ctrl_get_interrupt,
+		.config_hdr     = dp_catalog_ctrl_config_hdr,
 		.update_transfer_unit = dp_catalog_ctrl_update_transfer_unit,
 		.read_hdcp_status     = dp_catalog_ctrl_read_hdcp_status,
+		.send_phy_pattern    = dp_catalog_ctrl_send_phy_pattern,
+		.read_phy_pattern = dp_catalog_ctrl_read_phy_pattern,
 	};
 	struct dp_catalog_audio audio = {
 		.init       = dp_catalog_audio_init,
diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h
index 47c10bf..aca2f18 100644
--- a/drivers/gpu/drm/msm/dp/dp_catalog.h
+++ b/drivers/gpu/drm/msm/dp/dp_catalog.h
@@ -34,6 +34,32 @@
 #define DP_INTR_FRAME_END		BIT(6)
 #define DP_INTR_CRC_UPDATED		BIT(9)
 
+#define HDR_PRIMARIES_COUNT   3
+
+struct dp_catalog_hdr_data {
+	u32 vsc_hdr_byte0;
+	u32 vsc_hdr_byte1;
+	u32 vsc_hdr_byte2;
+	u32 vsc_hdr_byte3;
+	u32 pkt_payload;
+
+	u32 bpc;
+
+	u32 version;
+	u32 length;
+	u32 eotf;
+	u32 descriptor_id;
+
+	u32 display_primaries_x[HDR_PRIMARIES_COUNT];
+	u32 display_primaries_y[HDR_PRIMARIES_COUNT];
+	u32 white_point_x;
+	u32 white_point_y;
+	u32 max_luminance;
+	u32 min_luminance;
+	u32 max_content_light_level;
+	u32 max_average_light_level;
+};
+
 struct dp_catalog_aux {
 	u32 data;
 	u32 isr;
@@ -41,6 +67,7 @@
 	u32 (*read_data)(struct dp_catalog_aux *aux);
 	int (*write_data)(struct dp_catalog_aux *aux);
 	int (*write_trans)(struct dp_catalog_aux *aux);
+	int (*clear_trans)(struct dp_catalog_aux *aux, bool read);
 	void (*reset)(struct dp_catalog_aux *aux);
 	void (*enable)(struct dp_catalog_aux *aux, bool enable);
 	void (*update_aux_cfg)(struct dp_catalog_aux *aux,
@@ -48,6 +75,7 @@
 	void (*setup)(struct dp_catalog_aux *aux,
 			struct dp_aux_cfg *aux_cfg);
 	void (*get_irq)(struct dp_catalog_aux *aux, bool cmd_busy);
+	void (*clear_hw_interrupts)(struct dp_catalog_aux *aux);
 };
 
 struct dp_catalog_ctrl {
@@ -55,6 +83,7 @@
 	u32 valid_boundary;
 	u32 valid_boundary2;
 	u32 isr;
+	struct dp_catalog_hdr_data hdr_data;
 
 	void (*state_ctrl)(struct dp_catalog_ctrl *ctrl, u32 state);
 	void (*config_ctrl)(struct dp_catalog_ctrl *ctrl, u32 config);
@@ -65,6 +94,7 @@
 				u32 stream_rate_khz, bool fixed_nvid);
 	void (*set_pattern)(struct dp_catalog_ctrl *ctrl, u32 pattern);
 	void (*reset)(struct dp_catalog_ctrl *ctrl);
+	void (*usb_reset)(struct dp_catalog_ctrl *ctrl, bool flip);
 	bool (*mainlink_ready)(struct dp_catalog_ctrl *ctrl);
 	void (*enable_irq)(struct dp_catalog_ctrl *ctrl, bool enable);
 	void (*hpd_config)(struct dp_catalog_ctrl *ctrl, bool enable);
@@ -74,8 +104,12 @@
 	void (*update_vx_px)(struct dp_catalog_ctrl *ctrl, u8 v_level,
 				u8 p_level);
 	void (*get_interrupt)(struct dp_catalog_ctrl *ctrl);
+	void (*config_hdr)(struct dp_catalog_ctrl *ctrl);
 	void (*update_transfer_unit)(struct dp_catalog_ctrl *ctrl);
 	u32 (*read_hdcp_status)(struct dp_catalog_ctrl *ctrl);
+	void (*send_phy_pattern)(struct dp_catalog_ctrl *ctrl,
+			u32 pattern);
+	u32 (*read_phy_pattern)(struct dp_catalog_ctrl *ctrl);
 };
 
 enum dp_catalog_audio_sdp_type {
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 51abcf5..13ca6b2 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -36,6 +36,11 @@
 #define ST_SEND_VIDEO			BIT(7)
 #define ST_PUSH_IDLE			BIT(8)
 
+#define MR_LINK_TRAINING1  0x8
+#define MR_LINK_SYMBOL_ERM 0x80
+#define MR_LINK_PRBS7 0x100
+#define MR_LINK_CUSTOM80 0x200
+
 struct dp_vc_tu_mapping_table {
 	u32 vic;
 	u8 lanes;
@@ -63,9 +68,7 @@
 
 	struct completion idle_comp;
 	struct completion video_comp;
-	struct completion irq_comp;
 
-	bool psm_enabled;
 	bool orientation;
 	atomic_t aborted;
 
@@ -155,7 +158,7 @@
 	config |= tbd << 8;
 
 	/* Num of Lanes */
-	config |= ((ctrl->link->lane_count - 1) << 4);
+	config |= ((ctrl->link->link_params.lane_count - 1) << 4);
 
 	if (drm_dp_enhanced_frame_cap(dpcd))
 		config |= 0x40;
@@ -303,7 +306,7 @@
 	u64 brute_force_threshold = 10;
 	u64 diff_abs;
 
-	ln_cnt =  ctrl->link->lane_count;
+	ln_cnt =  ctrl->link->link_params.lane_count;
 
 	bpp = pinfo->bpp;
 	lwidth = pinfo->h_active;
@@ -322,7 +325,8 @@
 	even_distribution = 0;
 	min_hblank = 0;
 
-	lclk = drm_dp_bw_code_to_link_rate(ctrl->link->bw_code) * DP_KHZ_TO_HZ;
+	lclk = drm_dp_bw_code_to_link_rate(
+		ctrl->link->link_params.bw_code) * DP_KHZ_TO_HZ;
 
 	pr_debug("pclk=%lld, active_width=%d, h_blank=%d\n",
 						pclk, lwidth, h_blank);
@@ -761,9 +765,10 @@
 	struct dp_link *link = ctrl->link;
 
 	ctrl->catalog->update_vx_px(ctrl->catalog,
-			link->v_level, link->p_level);
+		link->phy_params.v_level, link->phy_params.p_level);
 
-	dp_ctrl_update_sink_vx_px(ctrl, link->v_level, link->p_level);
+	dp_ctrl_update_sink_vx_px(ctrl, link->phy_params.v_level,
+		link->phy_params.p_level);
 }
 
 static void dp_ctrl_train_pattern_set(struct dp_ctrl_private *ctrl,
@@ -816,7 +821,7 @@
 	dp_ctrl_update_vx_px(ctrl);
 
 	tries = 0;
-	old_v_level = ctrl->link->v_level;
+	old_v_level = ctrl->link->phy_params.v_level;
 	while (1) {
 		drm_dp_link_train_clock_recovery_delay(ctrl->panel->dpcd);
 
@@ -825,26 +830,26 @@
 			break;
 
 		if (drm_dp_clock_recovery_ok(link_status,
-			ctrl->link->lane_count)) {
+			ctrl->link->link_params.lane_count)) {
 			break;
 		}
 
-		if (ctrl->link->v_level == DP_LINK_VOLTAGE_MAX) {
+		if (ctrl->link->phy_params.v_level == DP_LINK_VOLTAGE_MAX) {
 			pr_err_ratelimited("max v_level reached\n");
 			ret = -EAGAIN;
 			break;
 		}
 
-		if (old_v_level == ctrl->link->v_level) {
+		if (old_v_level == ctrl->link->phy_params.v_level) {
 			tries++;
 			if (tries >= maximum_retries) {
 				pr_err("max tries reached\n");
-				ret = -EAGAIN;
+				ret = -ETIMEDOUT;
 				break;
 			}
 		} else {
 			tries = 0;
-			old_v_level = ctrl->link->v_level;
+			old_v_level = ctrl->link->phy_params.v_level;
 		}
 
 		pr_debug("clock recovery not done, adjusting vx px\n");
@@ -859,41 +864,25 @@
 static int dp_ctrl_link_rate_down_shift(struct dp_ctrl_private *ctrl)
 {
 	int ret = 0;
-	u32 min_req_link_rate_khz;
-	u32 new_proposed_link_bw_code;
-	u32 new_proposed_link_rate_khz;
 
 	if (!ctrl)
 		return -EINVAL;
 
-	min_req_link_rate_khz = ctrl->panel->get_min_req_link_rate(ctrl->panel);
-
-	switch (ctrl->link->bw_code) {
-	case DP_LINK_RATE_810:
-		new_proposed_link_bw_code = DP_LINK_BW_5_4;
+	switch (ctrl->link->link_params.bw_code) {
+	case DP_LINK_BW_8_1:
+		ctrl->link->link_params.bw_code = DP_LINK_BW_5_4;
 		break;
 	case DP_LINK_BW_5_4:
-		new_proposed_link_bw_code = DP_LINK_BW_2_7;
+		ctrl->link->link_params.bw_code = DP_LINK_BW_2_7;
 		break;
 	case DP_LINK_BW_2_7:
 	case DP_LINK_BW_1_62:
 	default:
-		new_proposed_link_bw_code = DP_LINK_BW_1_62;
+		ctrl->link->link_params.bw_code = DP_LINK_BW_1_62;
 		break;
 	};
 
-	new_proposed_link_rate_khz = drm_dp_bw_code_to_link_rate(
-						new_proposed_link_bw_code);
-
-	pr_debug("new proposed link rate=%d khz\n", new_proposed_link_rate_khz);
-	pr_debug("min required link rate=%d khz\n", min_req_link_rate_khz);
-
-	if (new_proposed_link_rate_khz >= min_req_link_rate_khz)
-		ctrl->link->bw_code = new_proposed_link_bw_code;
-	else
-		pr_debug("can't go below min required link rate\n");
-
-	pr_debug("new bw code=0x%x\n", ctrl->link->bw_code);
+	pr_debug("new bw code=0x%x\n", ctrl->link->link_params.bw_code);
 
 	return ret;
 }
@@ -931,11 +920,12 @@
 		if (ret)
 			break;
 
-		if (drm_dp_channel_eq_ok(link_status, ctrl->link->lane_count))
+		if (drm_dp_channel_eq_ok(link_status,
+			ctrl->link->link_params.lane_count))
 			break;
 
 		if (tries > maximum_retries) {
-			ret = -EAGAIN;
+			ret = -ETIMEDOUT;
 			break;
 		}
 		tries++;
@@ -953,13 +943,14 @@
 	u8 encoding = 0x1;
 	struct drm_dp_link link_info = {0};
 
-	ctrl->link->p_level = 0;
-	ctrl->link->v_level = 0;
+	ctrl->link->phy_params.p_level = 0;
+	ctrl->link->phy_params.v_level = 0;
 
 	dp_ctrl_config_ctrl(ctrl);
 
-	link_info.num_lanes = ctrl->link->lane_count;
-	link_info.rate = drm_dp_bw_code_to_link_rate(ctrl->link->bw_code);
+	link_info.num_lanes = ctrl->link->link_params.lane_count;
+	link_info.rate = drm_dp_bw_code_to_link_rate(
+		ctrl->link->link_params.bw_code);
 	link_info.capabilities = ctrl->panel->link_info.capabilities;
 
 	drm_dp_link_configure(ctrl->aux->drm_aux, &link_info);
@@ -1000,9 +991,12 @@
 
 	ctrl->catalog->mainlink_ctrl(ctrl->catalog, true);
 
-	drm_dp_link_power_up(ctrl->aux->drm_aux, &ctrl->panel->link_info);
+	ret = ctrl->link->psm_config(ctrl->link,
+		&ctrl->panel->link_info, false);
+	if (ret)
+		goto end;
 
-	if (ctrl->link->phy_pattern_requested(ctrl->link))
+	if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN)
 		goto end;
 
 	if (!train)
@@ -1060,7 +1054,7 @@
 	ctrl->power->set_pixel_clk_parent(ctrl->power);
 
 	dp_ctrl_set_clock_rate(ctrl, "ctrl_link_clk",
-		drm_dp_bw_code_to_link_rate(ctrl->link->bw_code));
+		drm_dp_bw_code_to_link_rate(ctrl->link->link_params.bw_code));
 
 	dp_ctrl_set_clock_rate(ctrl, "ctrl_pixel_clk", ctrl->pixel_rate);
 
@@ -1093,7 +1087,7 @@
 	ctrl->orientation = flip;
 	catalog = ctrl->catalog;
 
-	catalog->reset(ctrl->catalog);
+	catalog->usb_reset(ctrl->catalog, flip);
 	catalog->phy_reset(ctrl->catalog);
 	catalog->enable_irq(ctrl->catalog, true);
 
@@ -1119,12 +1113,6 @@
 	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
 
 	ctrl->catalog->enable_irq(ctrl->catalog, false);
-	ctrl->catalog->reset(ctrl->catalog);
-
-	/* Make sure DP is disabled before clk disable */
-	wmb();
-
-	dp_ctrl_disable_mainlink_clocks(ctrl);
 
 	pr_debug("Host deinitialized successfully\n");
 }
@@ -1147,95 +1135,223 @@
 	return false;
 }
 
-static int dp_ctrl_on_irq(struct dp_ctrl_private *ctrl, bool lt_needed)
+static int dp_ctrl_link_maintenance(struct dp_ctrl_private *ctrl)
 {
 	int ret = 0;
 
+	ctrl->dp_ctrl.push_idle(&ctrl->dp_ctrl);
+	ctrl->dp_ctrl.reset(&ctrl->dp_ctrl);
+
+	ctrl->pixel_rate = ctrl->panel->pinfo.pixel_clk_khz;
+
 	do {
-		if (ret == -EAGAIN)
+		if (ret == -EAGAIN) {
+			/* try with lower link rate */
+			dp_ctrl_link_rate_down_shift(ctrl);
+
 			ctrl->catalog->mainlink_ctrl(ctrl->catalog, false);
+		}
 
 		ctrl->catalog->phy_lane_cfg(ctrl->catalog,
-			ctrl->orientation, ctrl->link->lane_count);
+			ctrl->orientation, ctrl->link->link_params.lane_count);
 
-		if (lt_needed) {
-			/*
-			 * Diasable and re-enable the mainlink clock since the
-			 * link clock might have been adjusted as part of the
-			 * link maintenance.
-			 */
-			if (!ctrl->link->phy_pattern_requested(
-					ctrl->link))
-				dp_ctrl_disable_mainlink_clocks(ctrl);
+		/*
+		 * Disable and re-enable the mainlink clock since the
+		 * link clock might have been adjusted as part of the
+		 * link maintenance.
+		 */
+		dp_ctrl_disable_mainlink_clocks(ctrl);
 
-			ret = dp_ctrl_enable_mainlink_clocks(ctrl);
-			if (ret)
-				continue;
-		}
+		ret = dp_ctrl_enable_mainlink_clocks(ctrl);
+		if (ret)
+			continue;
 
 		dp_ctrl_configure_source_params(ctrl);
 
 		ctrl->catalog->config_msa(ctrl->catalog,
-			drm_dp_bw_code_to_link_rate(ctrl->link->bw_code),
+			drm_dp_bw_code_to_link_rate(
+			ctrl->link->link_params.bw_code),
 			ctrl->pixel_rate, dp_ctrl_use_fixed_nvid(ctrl));
 
 		reinit_completion(&ctrl->idle_comp);
 
-		if (ctrl->psm_enabled) {
-			ret = ctrl->link->send_psm_request(ctrl->link, false);
-			if (ret) {
-				pr_err("failed to exit low power mode, rc=%d\n",
-					ret);
-				continue;
-			}
-		}
-
-		ret = dp_ctrl_setup_main_link(ctrl, lt_needed);
+		ret = dp_ctrl_setup_main_link(ctrl, true);
 	} while (ret == -EAGAIN);
 
 	return ret;
 }
 
-static int dp_ctrl_on_hpd(struct dp_ctrl_private *ctrl)
+static void dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl)
 {
 	int ret = 0;
-	u32 rate = ctrl->panel->link_info.rate;
+
+	if (!ctrl->link->phy_params.phy_test_pattern_sel) {
+		pr_debug("no test pattern selected by sink\n");
+		return;
+	}
+
+	pr_debug("start\n");
+
+	ctrl->dp_ctrl.push_idle(&ctrl->dp_ctrl);
+	/*
+	 * The global reset will need DP link ralated clocks to be
+	 * running. Add the global reset just before disabling the
+	 * link clocks and core clocks.
+	 */
+	ctrl->dp_ctrl.reset(&ctrl->dp_ctrl);
+	ctrl->dp_ctrl.off(&ctrl->dp_ctrl);
+
+	ret = ctrl->dp_ctrl.on(&ctrl->dp_ctrl);
+	if (ret)
+		pr_err("failed to enable DP controller\n");
+
+	pr_debug("end\n");
+}
+
+static void dp_ctrl_send_phy_test_pattern(struct dp_ctrl_private *ctrl)
+{
+	bool success = false;
+	u32 pattern_sent = 0x0;
+	u32 pattern_requested = ctrl->link->phy_params.phy_test_pattern_sel;
+
+	pr_debug("request: %s\n",
+			dp_link_get_phy_test_pattern(pattern_requested));
+
+	ctrl->catalog->update_vx_px(ctrl->catalog,
+			ctrl->link->phy_params.v_level,
+			ctrl->link->phy_params.p_level);
+	ctrl->catalog->send_phy_pattern(ctrl->catalog, pattern_requested);
+	ctrl->link->send_test_response(ctrl->link);
+
+	pattern_sent = ctrl->catalog->read_phy_pattern(ctrl->catalog);
+
+	switch (pattern_sent) {
+	case MR_LINK_TRAINING1:
+		if (pattern_requested ==
+				DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING)
+			success = true;
+		break;
+	case MR_LINK_SYMBOL_ERM:
+		if ((pattern_requested ==
+				DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT)
+			|| (pattern_requested ==
+				DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN))
+			success = true;
+		break;
+	case MR_LINK_PRBS7:
+		if (pattern_requested == DP_TEST_PHY_PATTERN_PRBS7)
+			success = true;
+		break;
+	case MR_LINK_CUSTOM80:
+		if (pattern_requested ==
+				DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN)
+			success = true;
+		break;
+	default:
+		success = false;
+		return;
+	}
+
+	pr_debug("%s: %s\n", success ? "success" : "failed",
+			dp_link_get_phy_test_pattern(pattern_requested));
+}
+
+static void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl)
+{
+	struct dp_ctrl_private *ctrl;
+	u32 sink_request = 0x0;
+
+	if (!dp_ctrl) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
+	sink_request = ctrl->link->sink_request;
+
+	if (sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) {
+		pr_info("PHY_TEST_PATTERN request\n");
+		dp_ctrl_process_phy_test_request(ctrl);
+	}
+
+	if (sink_request & DP_LINK_STATUS_UPDATED)
+		dp_ctrl_link_maintenance(ctrl);
+
+	if (sink_request & DP_TEST_LINK_TRAINING) {
+		ctrl->link->send_test_response(ctrl->link);
+		dp_ctrl_link_maintenance(ctrl);
+	}
+}
+
+static void dp_ctrl_reset(struct dp_ctrl *dp_ctrl)
+{
+	struct dp_ctrl_private *ctrl;
+
+	if (!dp_ctrl) {
+		pr_err("invalid params\n");
+		return;
+	}
+
+	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
+	ctrl->catalog->reset(ctrl->catalog);
+}
+
+static int dp_ctrl_on(struct dp_ctrl *dp_ctrl)
+{
+	int rc = 0;
+	struct dp_ctrl_private *ctrl;
+	u32 rate = 0;
 	u32 link_train_max_retries = 100;
+	u32 const phy_cts_pixel_clk_khz = 148500;
+
+	if (!dp_ctrl) {
+		rc = -EINVAL;
+		goto end;
+	}
+
+	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
 
 	atomic_set(&ctrl->aborted, 0);
+	rate = ctrl->panel->link_info.rate;
 
 	ctrl->power->clk_enable(ctrl->power, DP_CORE_PM, true);
 	ctrl->catalog->hpd_config(ctrl->catalog, true);
 
-	ctrl->link->bw_code  = drm_dp_link_rate_to_bw_code(rate);
-	ctrl->link->lane_count = ctrl->panel->link_info.num_lanes;
-	ctrl->pixel_rate = ctrl->panel->pinfo.pixel_clk_khz;
+	if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) {
+		pr_debug("using phy test link parameters\n");
+		if (!ctrl->panel->pinfo.pixel_clk_khz)
+			ctrl->pixel_rate = phy_cts_pixel_clk_khz;
+	} else {
+		ctrl->link->link_params.bw_code =
+			drm_dp_link_rate_to_bw_code(rate);
+		ctrl->link->link_params.lane_count =
+			ctrl->panel->link_info.num_lanes;
+		ctrl->pixel_rate = ctrl->panel->pinfo.pixel_clk_khz;
+	}
 
 	pr_debug("bw_code=%d, lane_count=%d, pixel_rate=%d\n",
-		ctrl->link->bw_code, ctrl->link->lane_count,
-		ctrl->pixel_rate);
+		ctrl->link->link_params.bw_code,
+		ctrl->link->link_params.lane_count, ctrl->pixel_rate);
 
 	ctrl->catalog->phy_lane_cfg(ctrl->catalog,
-			ctrl->orientation, ctrl->link->lane_count);
+			ctrl->orientation, ctrl->link->link_params.lane_count);
 
-	ret = dp_ctrl_enable_mainlink_clocks(ctrl);
-	if (ret)
-		goto exit;
+	rc = dp_ctrl_enable_mainlink_clocks(ctrl);
+	if (rc)
+		goto end;
 
 	reinit_completion(&ctrl->idle_comp);
 
 	dp_ctrl_configure_source_params(ctrl);
 
-	if (ctrl->psm_enabled)
-		ret = ctrl->link->send_psm_request(ctrl->link, false);
-
 	while (--link_train_max_retries && !atomic_read(&ctrl->aborted)) {
 		ctrl->catalog->config_msa(ctrl->catalog,
-			drm_dp_bw_code_to_link_rate(ctrl->link->bw_code),
+			drm_dp_bw_code_to_link_rate(
+			ctrl->link->link_params.bw_code),
 			ctrl->pixel_rate, dp_ctrl_use_fixed_nvid(ctrl));
 
-		ret = dp_ctrl_setup_main_link(ctrl, true);
-		if (!ret)
+		rc = dp_ctrl_setup_main_link(ctrl, true);
+		if (!rc)
 			break;
 
 		/* try with lower link rate */
@@ -1250,50 +1366,16 @@
 		dp_ctrl_enable_mainlink_clocks(ctrl);
 	}
 
+	if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN)
+		dp_ctrl_send_phy_test_pattern(ctrl);
+
 	pr_debug("End-\n");
 
-exit:
-	return ret;
-}
-
-static void dp_ctrl_off_irq(struct dp_ctrl_private *ctrl)
-{
-	ctrl->catalog->mainlink_ctrl(ctrl->catalog, false);
-
-	/* Make sure DP mainlink and audio engines are disabled */
-	wmb();
-
-	complete_all(&ctrl->irq_comp);
-	pr_debug("end\n");
-}
-
-static void dp_ctrl_off_hpd(struct dp_ctrl_private *ctrl)
-{
-	ctrl->catalog->mainlink_ctrl(ctrl->catalog, false);
-	pr_debug("DP off done\n");
-}
-
-static int dp_ctrl_on(struct dp_ctrl *dp_ctrl, bool hpd_irq)
-{
-	int rc = 0;
-	struct dp_ctrl_private *ctrl;
-
-	if (!dp_ctrl) {
-		rc = -EINVAL;
-		goto end;
-	}
-
-	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
-
-	if (hpd_irq)
-		rc = dp_ctrl_on_irq(ctrl, false);
-	else
-		rc = dp_ctrl_on_hpd(ctrl);
 end:
 	return rc;
 }
 
-static void dp_ctrl_off(struct dp_ctrl *dp_ctrl, bool hpd_irq)
+static void dp_ctrl_off(struct dp_ctrl *dp_ctrl)
 {
 	struct dp_ctrl_private *ctrl;
 
@@ -1302,10 +1384,15 @@
 
 	ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
 
-	if (hpd_irq)
-		dp_ctrl_off_irq(ctrl);
-	else
-		dp_ctrl_off_hpd(ctrl);
+	ctrl->catalog->mainlink_ctrl(ctrl->catalog, false);
+	ctrl->catalog->reset(ctrl->catalog);
+
+	/* Make sure DP is disabled before clk disable */
+	wmb();
+
+	dp_ctrl_disable_mainlink_clocks(ctrl);
+
+	pr_debug("DP off done\n");
 }
 
 static void dp_ctrl_isr(struct dp_ctrl *dp_ctrl)
@@ -1347,7 +1434,6 @@
 
 	init_completion(&ctrl->idle_comp);
 	init_completion(&ctrl->video_comp);
-	init_completion(&ctrl->irq_comp);
 
 	/* in parameters */
 	ctrl->parser   = in->parser;
@@ -1367,6 +1453,8 @@
 	dp_ctrl->push_idle = dp_ctrl_push_idle;
 	dp_ctrl->abort     = dp_ctrl_abort;
 	dp_ctrl->isr       = dp_ctrl_isr;
+	dp_ctrl->reset	   = dp_ctrl_reset;
+	dp_ctrl->handle_sink_request = dp_ctrl_handle_sink_request;
 
 	return dp_ctrl;
 error:
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h
index 2ecfa0d..d6d10ed 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.h
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h
@@ -25,11 +25,13 @@
 struct dp_ctrl {
 	int (*init)(struct dp_ctrl *dp_ctrl, bool flip);
 	void (*deinit)(struct dp_ctrl *dp_ctrl);
-	int (*on)(struct dp_ctrl *dp_ctrl, bool hpd_irq);
-	void (*off)(struct dp_ctrl *dp_ctrl, bool hpd_irq);
+	int (*on)(struct dp_ctrl *dp_ctrl);
+	void (*off)(struct dp_ctrl *dp_ctrl);
+	void (*reset)(struct dp_ctrl *dp_ctrl);
 	void (*push_idle)(struct dp_ctrl *dp_ctrl);
 	void (*abort)(struct dp_ctrl *dp_ctrl);
 	void (*isr)(struct dp_ctrl *dp_ctrl);
+	void (*handle_sink_request)(struct dp_ctrl *dp_ctrl);
 };
 
 struct dp_ctrl_in {
diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c
index 82e34df..92ac0ec 100644
--- a/drivers/gpu/drm/msm/dp/dp_debug.c
+++ b/drivers/gpu/drm/msm/dp/dp_debug.c
@@ -74,7 +74,7 @@
 	struct dp_debug_private *debug = file->private_data;
 	char buf[SZ_32];
 	size_t len = 0;
-	int hdisplay = 0, vdisplay = 0, vrefresh = 0;
+	int hdisplay = 0, vdisplay = 0, vrefresh = 0, aspect_ratio;
 
 	if (!debug)
 		return -ENODEV;
@@ -89,7 +89,8 @@
 
 	buf[len] = '\0';
 
-	if (sscanf(buf, "%d %d %d", &hdisplay, &vdisplay, &vrefresh) != 3)
+	if (sscanf(buf, "%d %d %d %d", &hdisplay, &vdisplay, &vrefresh,
+				&aspect_ratio) != 4)
 		goto clear;
 
 	if (!hdisplay || !vdisplay || !vrefresh)
@@ -99,6 +100,7 @@
 	debug->dp_debug.hdisplay = hdisplay;
 	debug->dp_debug.vdisplay = vdisplay;
 	debug->dp_debug.vrefresh = vrefresh;
+	debug->dp_debug.aspect_ratio = aspect_ratio;
 	goto end;
 clear:
 	pr_debug("clearing debug modes\n");
@@ -107,6 +109,40 @@
 	return len;
 }
 
+static ssize_t dp_debug_bw_code_write(struct file *file,
+		const char __user *user_buff, size_t count, loff_t *ppos)
+{
+	struct dp_debug_private *debug = file->private_data;
+	char buf[SZ_8];
+	size_t len = 0;
+	u32 max_bw_code = 0;
+
+	if (!debug)
+		return -ENODEV;
+
+	if (*ppos)
+		return 0;
+
+	/* Leave room for termination char */
+	len = min_t(size_t, count, SZ_8 - 1);
+	if (copy_from_user(buf, user_buff, len))
+		return 0;
+
+	buf[len] = '\0';
+
+	if (kstrtoint(buf, 10, &max_bw_code) != 0)
+		return 0;
+
+	if (!is_link_rate_valid(max_bw_code)) {
+		pr_err("Unsupported bw code %d\n", max_bw_code);
+		return len;
+	}
+	debug->panel->max_bw_code = max_bw_code;
+	pr_debug("max_bw_code: %d\n", max_bw_code);
+
+	return len;
+}
+
 static ssize_t dp_debug_read_connected(struct file *file,
 		char __user *user_buff, size_t count, loff_t *ppos)
 {
@@ -164,11 +200,11 @@
 
 	list_for_each_entry(mode, &connector->modes, head) {
 		len += snprintf(buf + len, SZ_4K - len,
-		"%s %d %d %d %d %d %d %d %d %d 0x%x\n",
-		mode->name, mode->vrefresh, mode->hdisplay,
-		mode->hsync_start, mode->hsync_end, mode->htotal,
-		mode->vdisplay, mode->vsync_start, mode->vsync_end,
-		mode->vtotal, mode->flags);
+		"%s %d %d %d %d %d %d %d %d %d %d 0x%x\n",
+		mode->name, mode->vrefresh, mode->picture_aspect_ratio,
+		mode->hdisplay, mode->hsync_start, mode->hsync_end,
+		mode->htotal, mode->vdisplay, mode->vsync_start,
+		mode->vsync_end, mode->vtotal, mode->flags);
 	}
 
 	if (copy_to_user(user_buff, buf, len)) {
@@ -306,33 +342,34 @@
 	/* Link Information */
 	rc = snprintf(buf + len, max_size,
 		"\tdp_link:\n\t\ttest_requested = %d\n",
-		debug->link->test_requested);
+		debug->link->sink_request);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
 	rc = snprintf(buf + len, max_size,
-		"\t\tlane_count = %d\n", debug->link->lane_count);
+		"\t\tlane_count = %d\n", debug->link->link_params.lane_count);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
 	rc = snprintf(buf + len, max_size,
-		"\t\tbw_code = %d\n", debug->link->bw_code);
+		"\t\tbw_code = %d\n", debug->link->link_params.bw_code);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
-	lclk = drm_dp_bw_code_to_link_rate(debug->link->bw_code) * 1000;
+	lclk = drm_dp_bw_code_to_link_rate(
+			debug->link->link_params.bw_code) * 1000;
 	rc = snprintf(buf + len, max_size,
 		"\t\tlclk = %lld\n", lclk);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
 	rc = snprintf(buf + len, max_size,
-		"\t\tv_level = %d\n", debug->link->v_level);
+		"\t\tv_level = %d\n", debug->link->phy_params.v_level);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
 	rc = snprintf(buf + len, max_size,
-		"\t\tp_level = %d\n", debug->link->p_level);
+		"\t\tp_level = %d\n", debug->link->phy_params.p_level);
 	if (dp_debug_check_buffer_overflow(rc, &max_size, &len))
 		goto error;
 
@@ -348,6 +385,36 @@
 	return -EINVAL;
 }
 
+static ssize_t dp_debug_bw_code_read(struct file *file,
+	char __user *user_buff, size_t count, loff_t *ppos)
+{
+	struct dp_debug_private *debug = file->private_data;
+	char *buf;
+	u32 len = 0;
+
+	if (!debug)
+		return -ENODEV;
+
+	if (*ppos)
+		return 0;
+
+	buf = kzalloc(SZ_4K, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	len += snprintf(buf + len, (SZ_4K - len),
+			"max_bw_code = %d\n", debug->panel->max_bw_code);
+
+	if (copy_to_user(user_buff, buf, len)) {
+		kfree(buf);
+		return -EFAULT;
+	}
+
+	*ppos += len;
+	kfree(buf);
+	return len;
+}
+
 static const struct file_operations dp_debug_fops = {
 	.open = simple_open,
 	.read = dp_debug_read_info,
@@ -369,6 +436,12 @@
 	.read = dp_debug_read_connected,
 };
 
+static const struct file_operations bw_code_fops = {
+	.open = simple_open,
+	.read = dp_debug_bw_code_read,
+	.write = dp_debug_bw_code_write,
+};
+
 static int dp_debug_init(struct dp_debug *dp_debug)
 {
 	int rc = 0;
@@ -376,6 +449,7 @@
 		struct dp_debug_private, dp_debug);
 	struct dentry *dir, *file, *edid_modes;
 	struct dentry *hpd, *connected;
+	struct dentry *max_bw_code;
 	struct dentry *root = debug->root;
 
 	dir = debugfs_create_dir(DEBUG_NAME, NULL);
@@ -422,6 +496,15 @@
 		goto error_remove_dir;
 	}
 
+	max_bw_code = debugfs_create_file("max_bw_code", 0644, dir,
+			debug, &bw_code_fops);
+	if (IS_ERR_OR_NULL(max_bw_code)) {
+		rc = PTR_ERR(max_bw_code);
+		pr_err("[%s] debugfs max_bw_code failed, rc=%d\n",
+		       DEBUG_NAME, rc);
+		goto error_remove_dir;
+	}
+
 	root = dir;
 	return rc;
 error_remove_dir:
@@ -462,7 +545,11 @@
 	dp_debug->hdisplay = 0;
 	dp_debug->vrefresh = 0;
 
-	dp_debug_init(dp_debug);
+	rc = dp_debug_init(dp_debug);
+	if (rc) {
+		devm_kfree(dev, debug);
+		goto error;
+	}
 
 	return dp_debug;
 error:
@@ -494,5 +581,5 @@
 
 	dp_debug_deinit(dp_debug);
 
-	kzfree(debug);
+	devm_kfree(debug->dev, debug);
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_debug.h b/drivers/gpu/drm/msm/dp/dp_debug.h
index 7fd5330..d5a9301 100644
--- a/drivers/gpu/drm/msm/dp/dp_debug.h
+++ b/drivers/gpu/drm/msm/dp/dp_debug.h
@@ -28,6 +28,7 @@
  */
 struct dp_debug {
 	bool debug_en;
+	int aspect_ratio;
 	int vdisplay;
 	int hdisplay;
 	int vrefresh;
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 7e40cc6..ea07d15 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -37,6 +37,7 @@
 #include "dp_debug.h"
 
 static struct dp_display *g_dp_display;
+#define HPD_STRING_SIZE 30
 
 struct dp_hdcp {
 	void *data;
@@ -422,33 +423,127 @@
 	.unbind = dp_display_unbind,
 };
 
+static bool dp_display_is_ds_bridge(struct dp_panel *panel)
+{
+	return (panel->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
+		DP_DWN_STRM_PORT_PRESENT);
+}
+
+static bool dp_display_is_sink_count_zero(struct dp_display_private *dp)
+{
+	return dp_display_is_ds_bridge(dp->panel) &&
+		(dp->link->sink_count.count == 0);
+}
+
+static void dp_display_send_hpd_event(struct dp_display *dp_display)
+{
+	struct drm_device *dev = NULL;
+	struct dp_display_private *dp;
+	struct drm_connector *connector;
+	char name[HPD_STRING_SIZE], status[HPD_STRING_SIZE],
+		bpp[HPD_STRING_SIZE], pattern[HPD_STRING_SIZE];
+	char *envp[5];
+
+	if (!dp_display) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp = container_of(dp_display, struct dp_display_private, dp_display);
+	if (!dp) {
+		pr_err("invalid params\n");
+		return;
+	}
+	connector = dp->dp_display.connector;
+	dev = dp_display->connector->dev;
+
+	connector->status = connector->funcs->detect(connector, false);
+	pr_debug("[%s] status updated to %s\n",
+			      connector->name,
+			      drm_get_connector_status_name(connector->status));
+	snprintf(name, HPD_STRING_SIZE, "name=%s", connector->name);
+	snprintf(status, HPD_STRING_SIZE, "status=%s",
+		drm_get_connector_status_name(connector->status));
+	snprintf(bpp, HPD_STRING_SIZE, "bpp=%d",
+		dp_link_bit_depth_to_bpp(
+		dp->link->test_video.test_bit_depth));
+	snprintf(pattern, HPD_STRING_SIZE, "pattern=%d",
+		dp->link->test_video.test_video_pattern);
+
+	pr_debug("generating hotplug event [%s]:[%s] [%s] [%s]\n",
+		name, status, bpp, pattern);
+	envp[0] = name;
+	envp[1] = status;
+	envp[2] = bpp;
+	envp[3] = pattern;
+	envp[4] = NULL;
+	kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE,
+			envp);
+}
+
+static int dp_display_send_hpd_notification(struct dp_display_private *dp,
+		bool hpd)
+{
+	if ((hpd && dp->dp_display.is_connected) ||
+			(!hpd && !dp->dp_display.is_connected)) {
+		pr_info("HPD already %s\n", (hpd ? "on" : "off"));
+		return 0;
+	}
+
+	/* reset video pattern flag on disconnect */
+	if (!hpd)
+		dp->panel->video_test = false;
+
+	dp->dp_display.is_connected = hpd;
+	reinit_completion(&dp->notification_comp);
+	dp_display_send_hpd_event(&dp->dp_display);
+
+	if (!wait_for_completion_timeout(&dp->notification_comp, HZ * 5)) {
+		pr_warn("%s timeout\n", hpd ? "connect" : "disconnect");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int dp_display_process_hpd_high(struct dp_display_private *dp)
 {
 	int rc = 0;
 	u32 max_pclk_from_edid = 0;
 	struct edid *edid;
 
+	dp->aux->init(dp->aux, dp->parser->aux_cfg);
+
+	if (dp->link->psm_enabled)
+		goto notify;
+
 	rc = dp->panel->read_sink_caps(dp->panel, dp->dp_display.connector);
 	if (rc)
-		return rc;
+		goto notify;
+
+	dp->link->process_request(dp->link);
+
+	if (dp_display_is_sink_count_zero(dp)) {
+		pr_debug("no downstream devices connected\n");
+		rc = -EINVAL;
+		goto end;
+	}
 
 	edid = dp->panel->edid_ctrl->edid;
 
 	dp->audio_supported = drm_detect_monitor_audio(edid);
 
+	dp->panel->handle_sink_request(dp->panel);
+
 	max_pclk_from_edid = dp->panel->get_max_pclk(dp->panel);
 
 	dp->dp_display.max_pclk_khz = min(max_pclk_from_edid,
 		dp->parser->max_pclk_khz);
 
-	dp->dp_display.is_connected = true;
+notify:
+	dp_display_send_hpd_notification(dp, true);
 
-	drm_helper_hpd_irq_event(dp->dp_display.connector->dev);
-
-	reinit_completion(&dp->notification_comp);
-	if (!wait_for_completion_timeout(&dp->notification_comp, HZ * 2))
-		pr_warn("timeout\n");
-
+end:
 	return rc;
 }
 
@@ -466,7 +561,6 @@
 
 	dp->power->init(dp->power, flip);
 	dp->ctrl->init(dp->ctrl, flip);
-	dp->aux->init(dp->aux, dp->parser->aux_cfg);
 	enable_irq(dp->irq);
 	dp->core_initialized = true;
 }
@@ -478,7 +572,6 @@
 		return;
 	}
 
-	dp->aux->deinit(dp->aux);
 	dp->ctrl->deinit(dp->ctrl);
 	dp->power->deinit(dp->power);
 	disable_irq(dp->irq);
@@ -498,12 +591,9 @@
 	if (dp->audio_supported)
 		dp->audio->off(dp->audio);
 
-	dp->dp_display.is_connected = false;
-	drm_helper_hpd_irq_event(dp->dp_display.connector->dev);
+	dp_display_send_hpd_notification(dp, false);
 
-	reinit_completion(&dp->notification_comp);
-	if (!wait_for_completion_timeout(&dp->notification_comp, HZ * 2))
-		pr_warn("timeout\n");
+	dp->aux->deinit(dp->aux);
 }
 
 static int dp_display_usbpd_configure_cb(struct device *dev)
@@ -543,7 +633,7 @@
 	}
 
 	dp->ctrl->push_idle(dp->ctrl);
-	dp->ctrl->off(dp->ctrl, false);
+	dp->ctrl->off(dp->ctrl);
 }
 
 static int dp_display_usbpd_disconnect_cb(struct device *dev)
@@ -570,22 +660,51 @@
 	if (dp->audio_supported)
 		dp->audio->off(dp->audio);
 
-	dp->dp_display.is_connected = false;
-	drm_helper_hpd_irq_event(dp->dp_display.connector->dev);
+	rc = dp_display_send_hpd_notification(dp, false);
 
-	reinit_completion(&dp->notification_comp);
-	if (!wait_for_completion_timeout(&dp->notification_comp, HZ * 2)) {
-		pr_warn("timeout\n");
+	/* if cable is disconnected, reset psm_enabled flag */
+	if (!dp->usbpd->alt_mode_cfg_done)
+		dp->link->psm_enabled = false;
 
-		if (dp->power_on)
-			dp_display_clean(dp);
-	}
+	if ((rc < 0) && dp->power_on)
+		dp_display_clean(dp);
 
 	dp_display_host_deinit(dp);
 end:
 	return rc;
 }
 
+static void dp_display_handle_video_request(struct dp_display_private *dp)
+{
+	if (dp->link->sink_request & DP_TEST_LINK_VIDEO_PATTERN) {
+		/* force disconnect followed by connect */
+		dp->usbpd->connect(dp->usbpd, false);
+		dp->panel->video_test = true;
+		dp->usbpd->connect(dp->usbpd, true);
+		dp->link->send_test_response(dp->link);
+	}
+}
+
+static int dp_display_handle_hpd_irq(struct dp_display_private *dp)
+{
+	if (dp->link->sink_request & DS_PORT_STATUS_CHANGED) {
+		dp_display_send_hpd_notification(dp, false);
+
+		if (dp_display_is_sink_count_zero(dp)) {
+			pr_debug("sink count is zero, nothing to do\n");
+			return 0;
+		}
+
+		return dp_display_process_hpd_high(dp);
+	}
+
+	dp->ctrl->handle_sink_request(dp->ctrl);
+
+	dp_display_handle_video_request(dp);
+
+	return 0;
+}
+
 static int dp_display_usbpd_attention_cb(struct device *dev)
 {
 	int rc = 0;
@@ -611,9 +730,12 @@
 		}
 
 		rc = dp->link->process_request(dp->link);
-		dp->hpd_irq_on = false;
+		/* check for any test request issued by sink */
 		if (!rc)
-			goto end;
+			dp_display_handle_hpd_irq(dp);
+
+		dp->hpd_irq_on = false;
+		goto end;
 	}
 
 	if (!dp->usbpd->hpd_high) {
@@ -627,6 +749,20 @@
 	return rc;
 }
 
+static void dp_display_deinit_sub_modules(struct dp_display_private *dp)
+{
+	dp_audio_put(dp->audio);
+	dp_ctrl_put(dp->ctrl);
+	dp_link_put(dp->link);
+	dp_panel_put(dp->panel);
+	dp_aux_put(dp->aux);
+	dp_power_put(dp->power);
+	dp_catalog_put(dp->catalog);
+	dp_parser_put(dp->parser);
+	dp_usbpd_put(dp->usbpd);
+	dp_debug_put(dp->debug);
+}
+
 static int dp_init_sub_modules(struct dp_display_private *dp)
 {
 	int rc = 0;
@@ -635,6 +771,9 @@
 	struct dp_ctrl_in ctrl_in = {
 		.dev = dev,
 	};
+	struct dp_panel_in panel_in = {
+		.dev = dev,
+	};
 
 	cb->configure  = dp_display_usbpd_configure_cb;
 	cb->disconnect = dp_display_usbpd_disconnect_cb;
@@ -644,49 +783,60 @@
 	if (IS_ERR(dp->usbpd)) {
 		rc = PTR_ERR(dp->usbpd);
 		pr_err("failed to initialize usbpd, rc = %d\n", rc);
-		goto err;
+		dp->usbpd = NULL;
+		goto error;
 	}
 
 	dp->parser = dp_parser_get(dp->pdev);
 	if (IS_ERR(dp->parser)) {
 		rc = PTR_ERR(dp->parser);
 		pr_err("failed to initialize parser, rc = %d\n", rc);
-		goto err;
+		dp->parser = NULL;
+		goto error_parser;
 	}
 
 	dp->catalog = dp_catalog_get(dev, &dp->parser->io);
 	if (IS_ERR(dp->catalog)) {
 		rc = PTR_ERR(dp->catalog);
 		pr_err("failed to initialize catalog, rc = %d\n", rc);
-		goto err;
+		dp->catalog = NULL;
+		goto error_catalog;
 	}
 
 	dp->power = dp_power_get(dp->parser);
 	if (IS_ERR(dp->power)) {
 		rc = PTR_ERR(dp->power);
 		pr_err("failed to initialize power, rc = %d\n", rc);
-		goto err;
+		dp->power = NULL;
+		goto error_power;
 	}
 
 	dp->aux = dp_aux_get(dev, &dp->catalog->aux, dp->parser->aux_cfg);
 	if (IS_ERR(dp->aux)) {
 		rc = PTR_ERR(dp->aux);
 		pr_err("failed to initialize aux, rc = %d\n", rc);
-		goto err;
-	}
-
-	dp->panel = dp_panel_get(dev, dp->aux, &dp->catalog->panel);
-	if (IS_ERR(dp->panel)) {
-		rc = PTR_ERR(dp->panel);
-		pr_err("failed to initialize panel, rc = %d\n", rc);
-		goto err;
+		dp->aux = NULL;
+		goto error_aux;
 	}
 
 	dp->link = dp_link_get(dev, dp->aux);
 	if (IS_ERR(dp->link)) {
 		rc = PTR_ERR(dp->link);
 		pr_err("failed to initialize link, rc = %d\n", rc);
-		goto err;
+		dp->link = NULL;
+		goto error_link;
+	}
+
+	panel_in.aux = dp->aux;
+	panel_in.catalog = &dp->catalog->panel;
+	panel_in.link = dp->link;
+
+	dp->panel = dp_panel_get(&panel_in);
+	if (IS_ERR(dp->panel)) {
+		rc = PTR_ERR(dp->panel);
+		pr_err("failed to initialize panel, rc = %d\n", rc);
+		dp->panel = NULL;
+		goto error_panel;
 	}
 
 	ctrl_in.link = dp->link;
@@ -700,13 +850,16 @@
 	if (IS_ERR(dp->ctrl)) {
 		rc = PTR_ERR(dp->ctrl);
 		pr_err("failed to initialize ctrl, rc = %d\n", rc);
-		goto err;
+		dp->ctrl = NULL;
+		goto error_ctrl;
 	}
 
 	dp->audio = dp_audio_get(dp->pdev, dp->panel, &dp->catalog->audio);
 	if (IS_ERR(dp->audio)) {
 		rc = PTR_ERR(dp->audio);
 		pr_err("failed to initialize audio, rc = %d\n", rc);
+		dp->audio = NULL;
+		goto error_audio;
 	}
 
 	dp->debug = dp_debug_get(dev, dp->panel, dp->usbpd,
@@ -714,9 +867,30 @@
 	if (IS_ERR(dp->debug)) {
 		rc = PTR_ERR(dp->debug);
 		pr_err("failed to initialize debug, rc = %d\n", rc);
-		goto err;
+		dp->debug = NULL;
+		goto error_debug;
 	}
-err:
+
+	return rc;
+error_debug:
+	dp_audio_put(dp->audio);
+error_audio:
+	dp_ctrl_put(dp->ctrl);
+error_ctrl:
+	dp_panel_put(dp->panel);
+error_panel:
+	dp_link_put(dp->link);
+error_link:
+	dp_aux_put(dp->aux);
+error_aux:
+	dp_power_put(dp->power);
+error_power:
+	dp_catalog_put(dp->catalog);
+error_catalog:
+	dp_parser_put(dp->parser);
+error_parser:
+	dp_usbpd_put(dp->usbpd);
+error:
 	return rc;
 }
 
@@ -757,7 +931,12 @@
 
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-	rc = dp->ctrl->on(dp->ctrl, dp->hpd_irq_on);
+	if (dp->power_on) {
+		pr_debug("Link already setup, return\n");
+		return 0;
+	}
+
+	rc = dp->ctrl->on(dp->ctrl);
 	if (!rc)
 		dp->power_on = true;
 error:
@@ -778,8 +957,8 @@
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
 	if (dp->audio_supported) {
-		dp->audio->bw_code = dp->link->bw_code;
-		dp->audio->lane_count = dp->link->lane_count;
+		dp->audio->bw_code = dp->link->link_params.bw_code;
+		dp->audio->lane_count = dp->link->link_params.lane_count;
 		dp->audio->on(dp->audio);
 	}
 
@@ -819,6 +998,10 @@
 			dp->hdcp.ops->off(dp->hdcp.data);
 	}
 
+	if (dp->usbpd->alt_mode_cfg_done && (dp->usbpd->hpd_high ||
+		dp->usbpd->forced_disconnect))
+		dp->link->psm_config(dp->link, &dp->panel->link_info, true);
+
 	dp->ctrl->push_idle(dp->ctrl);
 error:
 	return rc;
@@ -840,7 +1023,7 @@
 	if (!dp->power_on || !dp->core_initialized)
 		goto error;
 
-	dp->ctrl->off(dp->ctrl, dp->hpd_irq_on);
+	dp->ctrl->off(dp->ctrl);
 
 	dp->power_on = false;
 
@@ -905,19 +1088,58 @@
 	return 0;
 }
 
-static int dp_display_get_modes(struct dp_display *dp)
+static int dp_display_get_modes(struct dp_display *dp,
+	struct dp_display_mode *dp_mode)
 {
-	int ret = 0;
 	struct dp_display_private *dp_display;
+	int ret = 0;
+
+	if (!dp) {
+		pr_err("invalid params\n");
+		return 0;
+	}
 
 	dp_display = container_of(dp, struct dp_display_private, dp_display);
 
-	ret = _sde_edid_update_modes(dp->connector,
-		dp_display->panel->edid_ctrl);
-
+	ret = dp_display->panel->get_modes(dp_display->panel,
+		dp->connector, dp_mode);
+	if (dp_mode->timing.pixel_clk_khz)
+		dp->max_pclk_khz = dp_mode->timing.pixel_clk_khz;
 	return ret;
 }
 
+static bool dp_display_check_video_test(struct dp_display *dp)
+{
+	struct dp_display_private *dp_display;
+
+	if (!dp) {
+		pr_err("invalid params\n");
+		return false;
+	}
+
+	dp_display = container_of(dp, struct dp_display_private, dp_display);
+
+	if (dp_display->panel->video_test)
+		return true;
+
+	return false;
+}
+
+static int dp_display_get_test_bpp(struct dp_display *dp)
+{
+	struct dp_display_private *dp_display;
+
+	if (!dp) {
+		pr_err("invalid params\n");
+		return 0;
+	}
+
+	dp_display = container_of(dp, struct dp_display_private, dp_display);
+
+	return dp_link_bit_depth_to_bpp(
+		dp_display->link->test_video.test_bit_depth);
+}
+
 static int dp_display_probe(struct platform_device *pdev)
 {
 	int rc = 0;
@@ -958,10 +1180,16 @@
 	g_dp_display->unprepare     = dp_display_unprepare;
 	g_dp_display->request_irq   = dp_request_irq;
 	g_dp_display->get_debug     = dp_get_debug;
+	g_dp_display->send_hpd_event    = dp_display_send_hpd_event;
+	g_dp_display->is_video_test = dp_display_check_video_test;
+	g_dp_display->get_test_bpp = dp_display_get_test_bpp;
 
 	rc = component_add(&pdev->dev, &dp_display_comp_ops);
-	if (rc)
+	if (rc) {
 		pr_err("component add failed, rc=%d\n", rc);
+		dp_display_deinit_sub_modules(dp);
+		devm_kfree(&pdev->dev, dp);
+	}
 
 	return rc;
 }
@@ -987,20 +1215,6 @@
 	return 1;
 }
 
-static void dp_display_deinit_sub_modules(struct dp_display_private *dp)
-{
-	dp_audio_put(dp->audio);
-	dp_ctrl_put(dp->ctrl);
-	dp_link_put(dp->link);
-	dp_panel_put(dp->panel);
-	dp_aux_put(dp->aux);
-	dp_power_put(dp->power);
-	dp_catalog_put(dp->catalog);
-	dp_parser_put(dp->parser);
-	dp_usbpd_put(dp->usbpd);
-	dp_debug_put(dp->debug);
-}
-
 static int dp_display_remove(struct platform_device *pdev)
 {
 	struct dp_display_private *dp;
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h
index 5943629..5539d61 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.h
+++ b/drivers/gpu/drm/msm/dp/dp_display.h
@@ -19,11 +19,6 @@
 
 #include "dp_panel.h"
 
-struct dp_display_mode {
-	struct dp_panel_info timing;
-	u32 capabilities;
-};
-
 struct dp_display {
 	struct drm_device *drm_dev;
 	struct dp_bridge *bridge;
@@ -41,11 +36,15 @@
 			struct dp_display_mode *mode);
 	int (*validate_mode)(struct dp_display *dp_display,
 			struct dp_display_mode *mode);
-	int (*get_modes)(struct dp_display *dp_display);
+	int (*get_modes)(struct dp_display *dp_display,
+		struct dp_display_mode *dp_mode);
 	int (*prepare)(struct dp_display *dp_display);
 	int (*unprepare)(struct dp_display *dp_display);
 	int (*request_irq)(struct dp_display *dp_display);
 	struct dp_debug *(*get_debug)(struct dp_display *dp_display);
+	void (*send_hpd_event)(struct dp_display *dp_display);
+	bool (*is_video_test)(struct dp_display *dp_display);
+	int (*get_test_bpp)(struct dp_display *dp_display);
 };
 
 int dp_display_get_num_of_displays(void);
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index 802f295..254343a 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -48,7 +48,15 @@
 
 	dp_mode->timing.v_front_porch = drm_mode->vsync_start -
 					 drm_mode->vdisplay;
-	dp_mode->timing.bpp = dp->connector->display_info.bpc * num_components;
+
+	if (dp->is_video_test(dp))
+		dp_mode->timing.bpp = dp->get_test_bpp(dp);
+	else
+		dp_mode->timing.bpp = dp->connector->display_info.bpc *
+		num_components;
+
+	if (!dp_mode->timing.bpp)
+		dp_mode->timing.bpp = 24;
 
 	dp_mode->timing.refresh_rate = drm_mode->vrefresh;
 
@@ -375,26 +383,65 @@
 	return status;
 }
 
+void dp_connector_send_hpd_event(void *display)
+{
+	struct dp_display *dp;
+
+	if (!display) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	dp = display;
+
+	if (dp->send_hpd_event)
+		dp->send_hpd_event(dp);
+}
+
 int dp_connector_get_modes(struct drm_connector *connector,
 		void *display)
 {
 	int rc = 0;
 	struct dp_display *dp;
+	struct dp_display_mode *dp_mode = NULL;
+	struct drm_display_mode *m, drm_mode;
 
 	if (!connector || !display)
-		return -EINVAL;
+		return 0;
 
 	dp = display;
+
+	dp_mode = kzalloc(sizeof(*dp_mode),  GFP_KERNEL);
+	if (!dp_mode)
+		return 0;
+
 	/* pluggable case assumes EDID is read when HPD */
 	if (dp->is_connected) {
-		rc = dp->get_modes(dp);
+		rc = dp->get_modes(dp, dp_mode);
 		if (!rc)
 			pr_err("failed to get DP sink modes, rc=%d\n", rc);
+
+		if (dp_mode->timing.pixel_clk_khz) { /* valid DP mode */
+			memset(&drm_mode, 0x0, sizeof(drm_mode));
+			convert_to_drm_mode(dp_mode, &drm_mode);
+			m = drm_mode_duplicate(connector->dev, &drm_mode);
+			if (!m) {
+				pr_err("failed to add mode %ux%u\n",
+				       drm_mode.hdisplay,
+				       drm_mode.vdisplay);
+				kfree(dp_mode);
+				return 0;
+			}
+			m->width_mm = connector->display_info.width_mm;
+			m->height_mm = connector->display_info.height_mm;
+			drm_mode_probed_add(connector, m);
+		}
 	} else {
 		pr_err("No sink connected\n");
 	}
+	kfree(dp_mode);
 
-	return 0;
+	return rc;
 }
 
 int dp_drm_bridge_init(void *data, struct drm_encoder *encoder)
@@ -467,18 +514,19 @@
 	dp_disp = display;
 	debug = dp_disp->get_debug(dp_disp);
 
-	if (debug->debug_en) {
-		if (mode->hdisplay == debug->hdisplay &&
-				mode->vdisplay == debug->vdisplay &&
-				mode->vrefresh == debug->vrefresh &&
-				mode->clock <= dp_disp->max_pclk_khz)
-			return MODE_OK;
-		else
-			return MODE_ERROR;
-	} else {
-		if (mode->clock > dp_disp->max_pclk_khz)
-			return MODE_BAD;
-		else
-			return MODE_OK;
-	}
+	mode->vrefresh = drm_mode_vrefresh(mode);
+
+	if (mode->vrefresh > 60)
+		return MODE_BAD;
+
+	if (mode->clock > dp_disp->max_pclk_khz)
+		return MODE_BAD;
+
+	if (debug->debug_en && (mode->hdisplay != debug->hdisplay ||
+			mode->vdisplay != debug->vdisplay ||
+			mode->vrefresh != debug->vrefresh ||
+			mode->picture_aspect_ratio != debug->aspect_ratio))
+		return MODE_BAD;
+
+	return MODE_OK;
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h
index 5918df1..53570f5 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.h
+++ b/drivers/gpu/drm/msm/dp/dp_drm.h
@@ -86,6 +86,8 @@
 
 int dp_connector_get_info(struct msm_display_info *info, void *display);
 
+void dp_connector_send_hpd_event(void *display);
+
 int dp_drm_bridge_init(void *display,
 	struct drm_encoder *encoder);
 
diff --git a/drivers/gpu/drm/msm/dp/dp_hdcp2p2.c b/drivers/gpu/drm/msm/dp/dp_hdcp2p2.c
index 061acee..016e1b8 100644
--- a/drivers/gpu/drm/msm/dp/dp_hdcp2p2.c
+++ b/drivers/gpu/drm/msm/dp/dp_hdcp2p2.c
@@ -27,6 +27,7 @@
 #define DP_INTR_STATUS3				(0x00000028)
 #define dp_read(offset) readl_relaxed((offset))
 #define dp_write(offset, data) writel_relaxed((data), (offset))
+#define DP_HDCP_RXCAPS_LENGTH 3
 
 enum dp_hdcp2p2_sink_status {
 	SINK_DISCONNECTED,
@@ -893,21 +894,22 @@
 static bool dp_hdcp2p2_supported(struct dp_hdcp2p2_ctrl *ctrl)
 {
 	u32 const rxcaps_dpcd_offset = 0x6921d;
-	ssize_t const bytes_to_read = 1;
 	ssize_t bytes_read = 0;
-	u8 buf = 0;
+	u8 buf[DP_HDCP_RXCAPS_LENGTH];
 
 	bytes_read = drm_dp_dpcd_read(ctrl->init_data.drm_aux,
-			rxcaps_dpcd_offset, &buf, bytes_to_read);
-	if (bytes_read != bytes_to_read) {
+			rxcaps_dpcd_offset, &buf, DP_HDCP_RXCAPS_LENGTH);
+	if (bytes_read != DP_HDCP_RXCAPS_LENGTH) {
 		pr_err("RxCaps read failed\n");
 		goto error;
 	}
 
-	pr_debug("rxcaps 0x%x\n", buf);
+	pr_debug("HDCP_CAPABLE=%lu\n", (buf[2] & BIT(1)) >> 1);
+	pr_debug("VERSION=%d\n", buf[0]);
 
-	if (buf & BIT(1))
+	if ((buf[2] & BIT(1)) && (buf[0] == 0x2))
 		return true;
+
 error:
 	return false;
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_link.c b/drivers/gpu/drm/msm/dp/dp_link.c
index 48e6c8f..0cf488d 100644
--- a/drivers/gpu/drm/msm/dp/dp_link.c
+++ b/drivers/gpu/drm/msm/dp/dp_link.c
@@ -17,14 +17,6 @@
 #include "dp_link.h"
 #include "dp_panel.h"
 
-#define DP_LINK_ENUM_STR(x)		#x
-
-enum dp_lane_count {
-	DP_LANE_COUNT_1	= 1,
-	DP_LANE_COUNT_2	= 2,
-	DP_LANE_COUNT_4	= 4,
-};
-
 enum dynamic_range {
 	DP_DYNAMIC_RANGE_RGB_VESA = 0x00,
 	DP_DYNAMIC_RANGE_RGB_CEA = 0x01,
@@ -50,111 +42,18 @@
 	u32 test_requested;
 	u32 test_link_rate;
 	u32 test_lane_count;
-	u32 phy_test_pattern_sel;
-	u32 test_video_pattern;
-	u32 test_bit_depth;
-	u32 test_dyn_range;
-	u32 test_h_total;
-	u32 test_v_total;
-	u32 test_h_start;
-	u32 test_v_start;
-	u32 test_hsync_pol;
-	u32 test_hsync_width;
-	u32 test_vsync_pol;
-	u32 test_vsync_width;
-	u32 test_h_width;
-	u32 test_v_height;
-	u32 test_rr_d;
-	u32 test_rr_n;
-	u32 test_audio_sampling_rate;
-	u32 test_audio_channel_count;
-	u32 test_audio_pattern_type;
-	u32 test_audio_period_ch_1;
-	u32 test_audio_period_ch_2;
-	u32 test_audio_period_ch_3;
-	u32 test_audio_period_ch_4;
-	u32 test_audio_period_ch_5;
-	u32 test_audio_period_ch_6;
-	u32 test_audio_period_ch_7;
-	u32 test_audio_period_ch_8;
-	u32 response;
-};
-
-struct dp_link_sink_count {
-	u32 count;
-	bool cp_ready;
 };
 
 struct dp_link_private {
+	u32 prev_sink_count;
 	struct device *dev;
 	struct dp_aux *aux;
 	struct dp_link dp_link;
 
 	struct dp_link_request request;
-	struct dp_link_sink_count sink_count;
 	u8 link_status[DP_LINK_STATUS_SIZE];
 };
 
-/**
- * mdss_dp_test_bit_depth_to_bpp() - convert test bit depth to bpp
- * @tbd: test bit depth
- *
- * Returns the bits per pixel (bpp) to be used corresponding to the
- * git bit depth value. This function assumes that bit depth has
- * already been validated.
- */
-static inline u32 dp_link_bit_depth_to_bpp(u32 tbd)
-{
-	u32 bpp;
-
-	/*
-	 * Few simplistic rules and assumptions made here:
-	 *    1. Bit depth is per color component
-	 *    2. If bit depth is unknown return 0
-	 *    3. Assume 3 color components
-	 */
-	switch (tbd) {
-	case DP_TEST_BIT_DEPTH_6:
-		bpp = 18;
-		break;
-	case DP_TEST_BIT_DEPTH_8:
-		bpp = 24;
-		break;
-	case DP_TEST_BIT_DEPTH_10:
-		bpp = 30;
-		break;
-	case DP_TEST_BIT_DEPTH_UNKNOWN:
-	default:
-		bpp = 0;
-	}
-
-	return bpp;
-}
-
-static char *dp_link_get_phy_test_pattern(u32 phy_test_pattern_sel)
-{
-	switch (phy_test_pattern_sel) {
-	case DP_TEST_PHY_PATTERN_NONE:
-		return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_NONE);
-	case DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING:
-		return DP_LINK_ENUM_STR(
-			DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING);
-	case DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT:
-		return DP_LINK_ENUM_STR(
-			DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT);
-	case DP_TEST_PHY_PATTERN_PRBS7:
-		return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_PRBS7);
-	case DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN:
-		return DP_LINK_ENUM_STR(
-			DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN);
-	case DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN:
-		return DP_LINK_ENUM_STR(
-			DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN);
-	default:
-		return "unknown";
-	}
-}
-
 static char *dp_link_get_audio_test_pattern(u32 pattern)
 {
 	switch (pattern) {
@@ -223,7 +122,7 @@
 static int dp_link_parse_audio_channel_period(struct dp_link_private *link)
 {
 	int ret = 0;
-	struct dp_link_request *req = &link->request;
+	struct dp_link_test_audio *req = &link->dp_link.test_audio;
 
 	ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH1);
 	if (ret == -EINVAL)
@@ -310,7 +209,7 @@
 		goto exit;
 	}
 
-	link->request.test_audio_pattern_type = data;
+	link->dp_link.test_audio.test_audio_pattern_type = data;
 	pr_debug("audio pattern type = %s\n",
 			dp_link_get_audio_test_pattern(data));
 exit:
@@ -356,8 +255,8 @@
 		goto exit;
 	}
 
-	link->request.test_audio_sampling_rate = sampling_rate;
-	link->request.test_audio_channel_count = channel_count;
+	link->dp_link.test_audio.test_audio_sampling_rate = sampling_rate;
+	link->dp_link.test_audio.test_audio_channel_count = channel_count;
 	pr_debug("sampling_rate = %s, channel_count = 0x%x\n",
 		dp_link_get_audio_sample_rate(sampling_rate), channel_count);
 exit:
@@ -578,11 +477,11 @@
 		goto exit;
 	}
 
-	link->request.test_video_pattern = data;
+	link->dp_link.test_video.test_video_pattern = data;
 	pr_debug("link video pattern = 0x%x (%s)\n",
-		link->request.test_video_pattern,
+		link->dp_link.test_video.test_video_pattern,
 		dp_link_video_pattern_to_string(
-			link->request.test_video_pattern));
+			link->dp_link.test_video.test_video_pattern));
 
 	/* Read the requested color bit depth and dynamic range (Byte 0x232) */
 	rlen = drm_dp_dpcd_read(link->aux->drm_aux, DP_TEST_MISC0,
@@ -601,11 +500,11 @@
 		ret = -EINVAL;
 		goto exit;
 	}
-	link->request.test_dyn_range = dyn_range;
+	link->dp_link.test_video.test_dyn_range = dyn_range;
 	pr_debug("link dynamic range = 0x%x (%s)\n",
-		link->request.test_dyn_range,
+		link->dp_link.test_video.test_dyn_range,
 		dp_link_dynamic_range_to_string(
-			link->request.test_dyn_range));
+			link->dp_link.test_video.test_dyn_range));
 
 	/* Color bit depth */
 	data &= DP_TEST_BIT_DEPTH_MASK;
@@ -615,128 +514,109 @@
 		goto exit;
 	}
 
-	link->request.test_bit_depth = data;
+	link->dp_link.test_video.test_bit_depth = data;
 	pr_debug("link bit depth = 0x%x (%s)\n",
-		link->request.test_bit_depth,
-		dp_link_bit_depth_to_string(link->request.test_bit_depth));
+		link->dp_link.test_video.test_bit_depth,
+		dp_link_bit_depth_to_string(
+		link->dp_link.test_video.test_bit_depth));
 
 	/* resolution timing params */
 	ret = dp_link_parse_timing_params1(link, DP_TEST_H_TOTAL_HI, 2,
-			&link->request.test_h_total);
+			&link->dp_link.test_video.test_h_total);
 	if (ret) {
 		pr_err("failed to parse test_h_total (DP_TEST_H_TOTAL_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_H_TOTAL = %d\n", link->request.test_h_total);
+	pr_debug("TEST_H_TOTAL = %d\n", link->dp_link.test_video.test_h_total);
 
 	ret = dp_link_parse_timing_params1(link, DP_TEST_V_TOTAL_HI, 2,
-			&link->request.test_v_total);
+			&link->dp_link.test_video.test_v_total);
 	if (ret) {
 		pr_err("failed to parse test_v_total (DP_TEST_V_TOTAL_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_V_TOTAL = %d\n", link->request.test_v_total);
+	pr_debug("TEST_V_TOTAL = %d\n", link->dp_link.test_video.test_v_total);
 
 	ret = dp_link_parse_timing_params1(link, DP_TEST_H_START_HI, 2,
-			&link->request.test_h_start);
+			&link->dp_link.test_video.test_h_start);
 	if (ret) {
 		pr_err("failed to parse test_h_start (DP_TEST_H_START_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_H_START = %d\n", link->request.test_h_start);
+	pr_debug("TEST_H_START = %d\n", link->dp_link.test_video.test_h_start);
 
 	ret = dp_link_parse_timing_params1(link, DP_TEST_V_START_HI, 2,
-			&link->request.test_v_start);
+			&link->dp_link.test_video.test_v_start);
 	if (ret) {
 		pr_err("failed to parse test_v_start (DP_TEST_V_START_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_V_START = %d\n", link->request.test_v_start);
+	pr_debug("TEST_V_START = %d\n", link->dp_link.test_video.test_v_start);
 
 	ret = dp_link_parse_timing_params2(link, DP_TEST_HSYNC_HI, 2,
-			&link->request.test_hsync_pol,
-			&link->request.test_hsync_width);
+			&link->dp_link.test_video.test_hsync_pol,
+			&link->dp_link.test_video.test_hsync_width);
 	if (ret) {
 		pr_err("failed to parse (DP_TEST_HSYNC_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_HSYNC_POL = %d\n", link->request.test_hsync_pol);
-	pr_debug("TEST_HSYNC_WIDTH = %d\n", link->request.test_hsync_width);
+	pr_debug("TEST_HSYNC_POL = %d\n",
+		link->dp_link.test_video.test_hsync_pol);
+	pr_debug("TEST_HSYNC_WIDTH = %d\n",
+		link->dp_link.test_video.test_hsync_width);
 
 	ret = dp_link_parse_timing_params2(link, DP_TEST_VSYNC_HI, 2,
-			&link->request.test_vsync_pol,
-			&link->request.test_vsync_width);
+			&link->dp_link.test_video.test_vsync_pol,
+			&link->dp_link.test_video.test_vsync_width);
 	if (ret) {
 		pr_err("failed to parse (DP_TEST_VSYNC_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_VSYNC_POL = %d\n", link->request.test_vsync_pol);
-	pr_debug("TEST_VSYNC_WIDTH = %d\n", link->request.test_vsync_width);
+	pr_debug("TEST_VSYNC_POL = %d\n",
+		link->dp_link.test_video.test_vsync_pol);
+	pr_debug("TEST_VSYNC_WIDTH = %d\n",
+		link->dp_link.test_video.test_vsync_width);
 
 	ret = dp_link_parse_timing_params1(link, DP_TEST_H_WIDTH_HI, 2,
-			&link->request.test_h_width);
+			&link->dp_link.test_video.test_h_width);
 	if (ret) {
 		pr_err("failed to parse test_h_width (DP_TEST_H_WIDTH_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_H_WIDTH = %d\n", link->request.test_h_width);
+	pr_debug("TEST_H_WIDTH = %d\n", link->dp_link.test_video.test_h_width);
 
 	ret = dp_link_parse_timing_params1(link, DP_TEST_V_HEIGHT_HI, 2,
-			&link->request.test_v_height);
+			&link->dp_link.test_video.test_v_height);
 	if (ret) {
 		pr_err("failed to parse test_v_height (DP_TEST_V_HEIGHT_HI)\n");
 		goto exit;
 	}
-	pr_debug("TEST_V_HEIGHT = %d\n", link->request.test_v_height);
+	pr_debug("TEST_V_HEIGHT = %d\n",
+		link->dp_link.test_video.test_v_height);
 
 	ret = dp_link_parse_timing_params3(link, DP_TEST_MISC1,
-		&link->request.test_rr_d);
-	link->request.test_rr_d &= DP_TEST_REFRESH_DENOMINATOR;
+		&link->dp_link.test_video.test_rr_d);
+	link->dp_link.test_video.test_rr_d &= DP_TEST_REFRESH_DENOMINATOR;
 	if (ret) {
 		pr_err("failed to parse test_rr_d (DP_TEST_MISC1)\n");
 		goto exit;
 	}
-	pr_debug("TEST_REFRESH_DENOMINATOR = %d\n", link->request.test_rr_d);
+	pr_debug("TEST_REFRESH_DENOMINATOR = %d\n",
+		link->dp_link.test_video.test_rr_d);
 
 	ret = dp_link_parse_timing_params3(link, DP_TEST_REFRESH_RATE_NUMERATOR,
-		&link->request.test_rr_n);
+		&link->dp_link.test_video.test_rr_n);
 	if (ret) {
 		pr_err("failed to parse test_rr_n (DP_TEST_REFRESH_RATE_NUMERATOR)\n");
 		goto exit;
 	}
-	pr_debug("TEST_REFRESH_NUMERATOR = %d\n", link->request.test_rr_n);
+	pr_debug("TEST_REFRESH_NUMERATOR = %d\n",
+		link->dp_link.test_video.test_rr_n);
 exit:
 	return ret;
 }
 
 /**
- * dp_link_is_link_rate_valid() - validates the link rate
- * @lane_rate: link rate requested by the sink
- *
- * Returns true if the requested link rate is supported.
- */
-static bool dp_link_is_link_rate_valid(u32 bw_code)
-{
-	return ((bw_code == DP_LINK_BW_1_62) ||
-		(bw_code == DP_LINK_BW_2_7) ||
-		(bw_code == DP_LINK_BW_5_4) ||
-		(bw_code == DP_LINK_RATE_810));
-}
-
-/**
- * dp_link_is_lane_count_valid() - validates the lane count
- * @lane_count: lane count requested by the sink
- *
- * Returns true if the requested lane count is supported.
- */
-static bool dp_link_is_lane_count_valid(u32 lane_count)
-{
-	return (lane_count == DP_LANE_COUNT_1) ||
-		(lane_count == DP_LANE_COUNT_2) ||
-		(lane_count == DP_LANE_COUNT_4);
-}
-
-/**
  * dp_link_parse_link_training_params() - parses link training parameters from
  * DPCD
  * @link: Display Port Driver data
@@ -761,7 +641,7 @@
 	}
 	data = bp;
 
-	if (!dp_link_is_link_rate_valid(data)) {
+	if (!is_link_rate_valid(data)) {
 		pr_err("invalid link rate = 0x%x\n", data);
 		ret = -EINVAL;
 		goto exit;
@@ -780,7 +660,7 @@
 	data = bp;
 	data &= 0x1F;
 
-	if (!dp_link_is_lane_count_valid(data)) {
+	if (!is_lane_count_valid(data)) {
 		pr_err("invalid lane count = 0x%x\n", data);
 		ret = -EINVAL;
 		goto exit;
@@ -832,7 +712,7 @@
 
 	data = bp;
 
-	link->request.phy_test_pattern_sel = data;
+	link->dp_link.phy_params.phy_test_pattern_sel = data;
 
 	pr_debug("phy_test_pattern_sel = %s\n",
 			dp_link_get_phy_test_pattern(data));
@@ -891,6 +771,11 @@
 		dp_link_is_video_audio_test_requested(test_requested);
 }
 
+static bool dp_link_is_test_edid_read(struct dp_link_private *link)
+{
+	return (link->request.test_requested == DP_TEST_LINK_EDID_READ);
+}
+
 /**
  * dp_sink_parse_test_request() - parses link request parameters from sink
  * @link: Display Port Driver data
@@ -972,10 +857,15 @@
 	 * Send a DP_TEST_ACK if all link parameters are valid, otherwise send
 	 * a DP_TEST_NAK.
 	 */
-	if (ret)
-		link->request.response = DP_TEST_NAK;
-	else
-		link->request.response = DP_TEST_ACK;
+	if (ret) {
+		link->dp_link.test_response = DP_TEST_NAK;
+	} else {
+		if (!dp_link_is_test_edid_read(link))
+			link->dp_link.test_response = DP_TEST_ACK;
+		else
+			link->dp_link.test_response =
+				DP_TEST_EDID_CHECKSUM_WRITE;
+	}
 
 	return ret;
 }
@@ -987,46 +877,49 @@
  * (Byte 0x200), and whether all the sink devices connected have Content
  * Protection enabled.
  */
-static void dp_link_parse_sink_count(struct dp_link_private *link)
+static int dp_link_parse_sink_count(struct dp_link *dp_link)
 {
-	u8 bp;
-	u8 data;
 	int rlen;
 	int const param_len = 0x1;
+	struct dp_link_private *link = container_of(dp_link,
+			struct dp_link_private, dp_link);
 
 	rlen = drm_dp_dpcd_read(link->aux->drm_aux, DP_SINK_COUNT,
-			&bp, param_len);
+			&link->dp_link.sink_count.count, param_len);
 	if (rlen < param_len) {
 		pr_err("failed to read sink count\n");
-		return;
+		return -EINVAL;
 	}
 
-	data = bp;
-
+	link->dp_link.sink_count.cp_ready =
+		link->dp_link.sink_count.count & DP_SINK_CP_READY;
 	/* BIT 7, BIT 5:0 */
-	link->sink_count.count = (data & BIT(7)) << 6 | (data & 0x63);
-	/* BIT 6*/
-	link->sink_count.cp_ready = data & BIT(6);
+	link->dp_link.sink_count.count =
+		DP_GET_SINK_COUNT(link->dp_link.sink_count.count);
 
 	pr_debug("sink_count = 0x%x, cp_ready = 0x%x\n",
-		link->sink_count.count, link->sink_count.cp_ready);
+		link->dp_link.sink_count.count,
+		link->dp_link.sink_count.cp_ready);
+	return 0;
 }
 
 static void dp_link_parse_sink_status_field(struct dp_link_private *link)
 {
 	int len = 0;
 
-	dp_link_parse_sink_count(link);
-	dp_link_parse_request(link);
+	link->prev_sink_count = link->dp_link.sink_count.count;
+	dp_link_parse_sink_count(&link->dp_link);
+
 	len = drm_dp_dpcd_read_link_status(link->aux->drm_aux,
 		link->link_status);
 	if (len < DP_LINK_STATUS_SIZE)
 		pr_err("DP link status read failed\n");
+	dp_link_parse_request(link);
 }
 
 static bool dp_link_is_link_training_requested(struct dp_link_private *link)
 {
-	return (link->request.test_requested == DP_TEST_LINK_PHY_TEST_PATTERN);
+	return (link->request.test_requested == DP_TEST_LINK_TRAINING);
 }
 
 /**
@@ -1046,22 +939,73 @@
 		return -EINVAL;
 
 	pr_debug("%s link rate = 0x%x, lane count = 0x%x\n",
-			dp_link_get_test_name(DP_TEST_LINK_PHY_TEST_PATTERN),
+			dp_link_get_test_name(DP_TEST_LINK_TRAINING),
 			link->request.test_link_rate,
 			link->request.test_lane_count);
 
-	link->dp_link.lane_count = link->request.test_lane_count;
-	link->dp_link.bw_code = link->request.test_link_rate;
+	link->dp_link.link_params.lane_count = link->request.test_lane_count;
+	link->dp_link.link_params.bw_code = link->request.test_link_rate;
 
 	return 0;
 }
 
-static bool dp_link_phy_pattern_requested(struct dp_link *dp_link)
+static void dp_link_send_test_response(struct dp_link *dp_link)
 {
-	struct dp_link_private *link = container_of(dp_link,
-			struct dp_link_private, dp_link);
+	struct dp_link_private *link = NULL;
+	u32 const response_len = 0x1;
 
-	return (link->request.test_requested == DP_TEST_LINK_PHY_TEST_PATTERN);
+	if (!dp_link) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	link = container_of(dp_link, struct dp_link_private, dp_link);
+
+	drm_dp_dpcd_write(link->aux->drm_aux, DP_TEST_RESPONSE,
+			&dp_link->test_response, response_len);
+}
+
+static int dp_link_psm_config(struct dp_link *dp_link,
+	struct drm_dp_link *link_info, bool enable)
+{
+	struct dp_link_private *link = NULL;
+	int ret = 0;
+
+	if (!dp_link) {
+		pr_err("invalid params\n");
+		return -EINVAL;
+	}
+
+	link = container_of(dp_link, struct dp_link_private, dp_link);
+
+	if (enable)
+		ret = drm_dp_link_power_down(link->aux->drm_aux, link_info);
+	else
+		ret = drm_dp_link_power_up(link->aux->drm_aux, link_info);
+
+	if (ret)
+		pr_err("Failed to %s low power mode\n",
+			(enable ? "enter" : "exit"));
+	else
+		dp_link->psm_enabled = enable;
+
+	return ret;
+}
+
+static void dp_link_send_edid_checksum(struct dp_link *dp_link, u8 checksum)
+{
+	struct dp_link_private *link = NULL;
+	u32 const response_len = 0x1;
+
+	if (!dp_link) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	link = container_of(dp_link, struct dp_link_private, dp_link);
+
+	drm_dp_dpcd_write(link->aux->drm_aux, DP_TEST_EDID_CHECKSUM,
+			&checksum, response_len);
 }
 
 static int dp_link_parse_vx_px(struct dp_link_private *link)
@@ -1127,10 +1071,11 @@
 	 * vector.
 	 */
 	pr_debug("Current: v_level = 0x%x, p_level = 0x%x\n",
-			link->dp_link.v_level, link->dp_link.p_level);
+			link->dp_link.phy_params.v_level,
+			link->dp_link.phy_params.p_level);
 	pr_debug("Requested: v_level = 0x%x, p_level = 0x%x\n", v0, p0);
-	link->dp_link.v_level = v0;
-	link->dp_link.p_level = p0;
+	link->dp_link.phy_params.v_level = v0;
+	link->dp_link.phy_params.p_level = p0;
 
 	pr_debug("Success\n");
 end:
@@ -1150,14 +1095,16 @@
 {
 	u32 test_link_rate = 0, test_lane_count = 0;
 
-	if (!dp_link_phy_pattern_requested(&link->dp_link))
+	if (!(link->request.test_requested & DP_TEST_LINK_PHY_TEST_PATTERN)) {
+		pr_debug("no phy test\n");
 		return -EINVAL;
+	}
 
 	test_link_rate = link->request.test_link_rate;
 	test_lane_count = link->request.test_lane_count;
 
-	if (!dp_link_is_link_rate_valid(test_link_rate) ||
-		!dp_link_is_lane_count_valid(test_lane_count)) {
+	if (!is_link_rate_valid(test_link_rate) ||
+		!is_lane_count_valid(test_lane_count)) {
 		pr_err("Invalid params: link rate = 0x%x, lane count = 0x%x\n",
 				test_link_rate, test_lane_count);
 		return -EINVAL;
@@ -1165,8 +1112,15 @@
 
 	pr_debug("start\n");
 
-	link->dp_link.lane_count = link->request.test_lane_count;
-	link->dp_link.bw_code = link->request.test_link_rate;
+	pr_info("Current: bw_code = 0x%x, lane count = 0x%x\n",
+			link->dp_link.link_params.bw_code,
+			link->dp_link.link_params.lane_count);
+
+	pr_info("Requested: bw_code = 0x%x, lane count = 0x%x\n",
+			test_link_rate, test_lane_count);
+
+	link->dp_link.link_params.lane_count = link->request.test_lane_count;
+	link->dp_link.link_params.bw_code = link->request.test_link_rate;
 
 	dp_link_parse_vx_px(link);
 
@@ -1196,16 +1150,16 @@
 	if (!(get_link_status(link->link_status, DP_LANE_ALIGN_STATUS_UPDATED) &
 		DP_LINK_STATUS_UPDATED) || /* link status updated */
 		(drm_dp_clock_recovery_ok(link->link_status,
-			link->dp_link.lane_count) &&
+			link->dp_link.link_params.lane_count) &&
 	     drm_dp_channel_eq_ok(link->link_status,
-			link->dp_link.lane_count)))
+			link->dp_link.link_params.lane_count)))
 		return -EINVAL;
 
 	pr_debug("channel_eq_done = %d, clock_recovery_done = %d\n",
 			drm_dp_clock_recovery_ok(link->link_status,
-			link->dp_link.lane_count),
+			link->dp_link.link_params.lane_count),
 			drm_dp_clock_recovery_ok(link->link_status,
-			link->dp_link.lane_count));
+			link->dp_link.link_params.lane_count));
 
 	return 0;
 }
@@ -1216,6 +1170,9 @@
 		DP_DOWNSTREAM_PORT_STATUS_CHANGED) /* port status changed */
 		return true;
 
+	if (link->prev_sink_count != link->dp_link.sink_count.count)
+		return true;
+
 	return false;
 }
 
@@ -1235,6 +1192,9 @@
 	if (!dp_link_is_ds_port_status_changed(link))
 		return -EINVAL;
 
+	/* reset prev_sink_count */
+	link->prev_sink_count = link->dp_link.sink_count.count;
+
 	return 0;
 }
 
@@ -1267,10 +1227,11 @@
 
 	pr_debug("%s: bit depth=%d(%d bpp) pattern=%s\n",
 		dp_link_get_test_name(DP_TEST_LINK_VIDEO_PATTERN),
-		link->request.test_bit_depth,
-		dp_link_bit_depth_to_bpp(link->request.test_bit_depth),
+		link->dp_link.test_video.test_bit_depth,
+		dp_link_bit_depth_to_bpp(
+		link->dp_link.test_video.test_bit_depth),
 		dp_link_video_pattern_to_string(
-			link->request.test_video_pattern));
+			link->dp_link.test_video.test_video_pattern));
 
 	return 0;
 end:
@@ -1293,22 +1254,22 @@
 
 	pr_debug("sampling_rate=%s, channel_count=%d, pattern_type=%s\n",
 		dp_link_get_audio_sample_rate(
-			link->request.test_audio_sampling_rate),
-		link->request.test_audio_channel_count,
+			link->dp_link.test_audio.test_audio_sampling_rate),
+		link->dp_link.test_audio.test_audio_channel_count,
 		dp_link_get_audio_test_pattern(
-			link->request.test_audio_pattern_type));
+			link->dp_link.test_audio.test_audio_pattern_type));
 
 	pr_debug("audio_period: ch1=0x%x, ch2=0x%x, ch3=0x%x, ch4=0x%x\n",
-		link->request.test_audio_period_ch_1,
-		link->request.test_audio_period_ch_2,
-		link->request.test_audio_period_ch_3,
-		link->request.test_audio_period_ch_4);
+		link->dp_link.test_audio.test_audio_period_ch_1,
+		link->dp_link.test_audio.test_audio_period_ch_2,
+		link->dp_link.test_audio.test_audio_period_ch_3,
+		link->dp_link.test_audio.test_audio_period_ch_4);
 
 	pr_debug("audio_period: ch5=0x%x, ch6=0x%x, ch7=0x%x, ch8=0x%x\n",
-		link->request.test_audio_period_ch_5,
-		link->request.test_audio_period_ch_6,
-		link->request.test_audio_period_ch_7,
-		link->request.test_audio_period_ch_8);
+		link->dp_link.test_audio.test_audio_period_ch_5,
+		link->dp_link.test_audio.test_audio_period_ch_6,
+		link->dp_link.test_audio.test_audio_period_ch_7,
+		link->dp_link.test_audio.test_audio_period_ch_8);
 
 	return 0;
 }
@@ -1316,8 +1277,12 @@
 static void dp_link_reset_data(struct dp_link_private *link)
 {
 	link->request = (const struct dp_link_request){ 0 };
-	link->request.test_bit_depth = DP_TEST_BIT_DEPTH_UNKNOWN;
-	link->dp_link.test_requested = 0;
+	link->dp_link.test_video = (const struct dp_link_test_video){ 0 };
+	link->dp_link.test_video.test_bit_depth = DP_TEST_BIT_DEPTH_UNKNOWN;
+	link->dp_link.test_audio = (const struct dp_link_test_audio){ 0 };
+	link->dp_link.phy_params.phy_test_pattern_sel = 0;
+	link->dp_link.sink_request = 0;
+	link->dp_link.test_response = 0;
 }
 
 /**
@@ -1346,39 +1311,44 @@
 
 	dp_link_parse_sink_status_field(link);
 
-	ret = dp_link_process_link_training_request(link);
-	if (!ret) {
-		dp_link->test_requested |= DP_TEST_LINK_TRAINING;
-		goto exit;
-	}
-
-	ret = dp_link_process_phy_test_pattern_request(link);
-	if (!ret) {
-		dp_link->test_requested |= DP_TEST_LINK_PHY_TEST_PATTERN;
-		goto exit;
-	}
-
-	ret = dp_link_process_link_status_update(link);
-	if (!ret) {
-		dp_link->test_requested |= DP_LINK_STATUS_UPDATED;
+	if (dp_link_is_test_edid_read(link)) {
+		dp_link->sink_request |= DP_TEST_LINK_EDID_READ;
 		goto exit;
 	}
 
 	ret = dp_link_process_ds_port_status_change(link);
 	if (!ret) {
-		dp_link->test_requested |= DS_PORT_STATUS_CHANGED;
+		dp_link->sink_request |= DS_PORT_STATUS_CHANGED;
+		goto exit;
+	}
+
+	ret = dp_link_process_link_training_request(link);
+	if (!ret) {
+		dp_link->sink_request |= DP_TEST_LINK_TRAINING;
+		goto exit;
+	}
+
+	ret = dp_link_process_phy_test_pattern_request(link);
+	if (!ret) {
+		dp_link->sink_request |= DP_TEST_LINK_PHY_TEST_PATTERN;
+		goto exit;
+	}
+
+	ret = dp_link_process_link_status_update(link);
+	if (!ret) {
+		dp_link->sink_request |= DP_LINK_STATUS_UPDATED;
 		goto exit;
 	}
 
 	ret = dp_link_process_video_pattern_request(link);
 	if (!ret) {
-		dp_link->test_requested |= DP_TEST_LINK_VIDEO_PATTERN;
+		dp_link->sink_request |= DP_TEST_LINK_VIDEO_PATTERN;
 		goto exit;
 	}
 
 	ret = dp_link_process_audio_pattern_request(link);
 	if (!ret) {
-		dp_link->test_requested |= DP_TEST_LINK_AUDIO_PATTERN;
+		dp_link->sink_request |= DP_TEST_LINK_AUDIO_PATTERN;
 		goto exit;
 	}
 
@@ -1402,7 +1372,7 @@
 
 	/* unless a video pattern CTS test is ongoing, use CEA_VESA */
 	if (dp_link_is_video_pattern_requested(link))
-		dr = link->request.test_dyn_range;
+		dr = link->dp_link.test_video.test_dyn_range;
 	else
 		dr = DP_DYNAMIC_RANGE_RGB_VESA;
 
@@ -1434,51 +1404,52 @@
 	link = container_of(dp_link, struct dp_link_private, dp_link);
 
 	/* use the max level across lanes */
-	for (i = 0; i < dp_link->lane_count; i++) {
+	for (i = 0; i < dp_link->link_params.lane_count; i++) {
 		data = drm_dp_get_adjust_request_voltage(link_status, i);
 		pr_debug("lane=%d req_voltage_swing=%d\n", i, data);
 		if (max < data)
 			max = data;
 	}
 
-	dp_link->v_level = max >> DP_TRAIN_VOLTAGE_SWING_SHIFT;
+	dp_link->phy_params.v_level = max >> DP_TRAIN_VOLTAGE_SWING_SHIFT;
 
 	/* use the max level across lanes */
 	max = 0;
-	for (i = 0; i < dp_link->lane_count; i++) {
+	for (i = 0; i < dp_link->link_params.lane_count; i++) {
 		data = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
 		pr_debug("lane=%d req_pre_emphasis=%d\n", i, data);
 		if (max < data)
 			max = data;
 	}
 
-	dp_link->p_level = max >> DP_TRAIN_PRE_EMPHASIS_SHIFT;
+	dp_link->phy_params.p_level = max >> DP_TRAIN_PRE_EMPHASIS_SHIFT;
 
 	/**
 	 * Adjust the voltage swing and pre-emphasis level combination to within
 	 * the allowable range.
 	 */
-	if (dp_link->v_level > DP_LINK_VOLTAGE_MAX) {
+	if (dp_link->phy_params.v_level > DP_LINK_VOLTAGE_MAX) {
 		pr_debug("Requested vSwingLevel=%d, change to %d\n",
-				dp_link->v_level, DP_LINK_VOLTAGE_MAX);
-		dp_link->v_level = DP_LINK_VOLTAGE_MAX;
+			dp_link->phy_params.v_level, DP_LINK_VOLTAGE_MAX);
+		dp_link->phy_params.v_level = DP_LINK_VOLTAGE_MAX;
 	}
 
-	if (dp_link->p_level > DP_LINK_PRE_EMPHASIS_MAX) {
+	if (dp_link->phy_params.p_level > DP_LINK_PRE_EMPHASIS_MAX) {
 		pr_debug("Requested preEmphasisLevel=%d, change to %d\n",
-				dp_link->p_level, DP_LINK_PRE_EMPHASIS_MAX);
-		dp_link->p_level = DP_LINK_PRE_EMPHASIS_MAX;
+			dp_link->phy_params.p_level, DP_LINK_PRE_EMPHASIS_MAX);
+		dp_link->phy_params.p_level = DP_LINK_PRE_EMPHASIS_MAX;
 	}
 
-	if ((dp_link->p_level > DP_LINK_PRE_EMPHASIS_LEVEL_1)
-			&& (dp_link->v_level == DP_LINK_VOLTAGE_LEVEL_2)) {
+	if ((dp_link->phy_params.p_level > DP_LINK_PRE_EMPHASIS_LEVEL_1)
+		&& (dp_link->phy_params.v_level == DP_LINK_VOLTAGE_LEVEL_2)) {
 		pr_debug("Requested preEmphasisLevel=%d, change to %d\n",
-				dp_link->p_level, DP_LINK_PRE_EMPHASIS_LEVEL_1);
-		dp_link->p_level = DP_LINK_PRE_EMPHASIS_LEVEL_1;
+			dp_link->phy_params.p_level,
+			DP_LINK_PRE_EMPHASIS_LEVEL_1);
+		dp_link->phy_params.p_level = DP_LINK_PRE_EMPHASIS_LEVEL_1;
 	}
 
 	pr_debug("adjusted: v_level=%d, p_level=%d\n",
-		dp_link->v_level, dp_link->p_level);
+		dp_link->phy_params.v_level, dp_link->phy_params.p_level);
 
 	return 0;
 }
@@ -1555,7 +1526,9 @@
 	dp_link->get_colorimetry_config = dp_link_get_colorimetry_config;
 	dp_link->adjust_levels          = dp_link_adjust_levels;
 	dp_link->send_psm_request       = dp_link_send_psm_request;
-	dp_link->phy_pattern_requested  = dp_link_phy_pattern_requested;
+	dp_link->send_test_response     = dp_link_send_test_response;
+	dp_link->psm_config             = dp_link_psm_config;
+	dp_link->send_edid_checksum     = dp_link_send_edid_checksum;
 
 	return dp_link;
 error:
diff --git a/drivers/gpu/drm/msm/dp/dp_link.h b/drivers/gpu/drm/msm/dp/dp_link.h
index 419186f..b1d9249 100644
--- a/drivers/gpu/drm/msm/dp/dp_link.h
+++ b/drivers/gpu/drm/msm/dp/dp_link.h
@@ -17,6 +17,10 @@
 
 #include "dp_aux.h"
 
+#define DS_PORT_STATUS_CHANGED 0x200
+#define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF
+#define DP_LINK_ENUM_STR(x)		#x
+
 enum dp_link_voltage_level {
 	DP_LINK_VOLTAGE_LEVEL_0	= 0,
 	DP_LINK_VOLTAGE_LEVEL_1	= 1,
@@ -31,25 +35,136 @@
 	DP_LINK_PRE_EMPHASIS_MAX	= DP_LINK_PRE_EMPHASIS_LEVEL_2,
 };
 
-#define DS_PORT_STATUS_CHANGED 0x200
-#define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF
+struct dp_link_sink_count {
+	u32 count;
+	bool cp_ready;
+};
 
-struct dp_link {
-	u32 test_requested;
+struct dp_link_test_video {
+	u32 test_video_pattern;
+	u32 test_bit_depth;
+	u32 test_dyn_range;
+	u32 test_h_total;
+	u32 test_v_total;
+	u32 test_h_start;
+	u32 test_v_start;
+	u32 test_hsync_pol;
+	u32 test_hsync_width;
+	u32 test_vsync_pol;
+	u32 test_vsync_width;
+	u32 test_h_width;
+	u32 test_v_height;
+	u32 test_rr_d;
+	u32 test_rr_n;
+};
 
+struct dp_link_test_audio {
+	u32 test_audio_sampling_rate;
+	u32 test_audio_channel_count;
+	u32 test_audio_pattern_type;
+	u32 test_audio_period_ch_1;
+	u32 test_audio_period_ch_2;
+	u32 test_audio_period_ch_3;
+	u32 test_audio_period_ch_4;
+	u32 test_audio_period_ch_5;
+	u32 test_audio_period_ch_6;
+	u32 test_audio_period_ch_7;
+	u32 test_audio_period_ch_8;
+};
+
+struct dp_link_phy_params {
+	u32 phy_test_pattern_sel;
+	u8 v_level;
+	u8 p_level;
+};
+
+struct dp_link_params {
 	u32 lane_count;
 	u32 bw_code;
-	u32 v_level;
-	u32 p_level;
+};
+
+struct dp_link {
+	u32 sink_request;
+	u32 test_response;
+	bool psm_enabled;
+
+	struct dp_link_sink_count sink_count;
+	struct dp_link_test_video test_video;
+	struct dp_link_test_audio test_audio;
+	struct dp_link_phy_params phy_params;
+	struct dp_link_params link_params;
 
 	u32 (*get_test_bits_depth)(struct dp_link *dp_link, u32 bpp);
 	int (*process_request)(struct dp_link *dp_link);
 	int (*get_colorimetry_config)(struct dp_link *dp_link);
 	int (*adjust_levels)(struct dp_link *dp_link, u8 *link_status);
 	int (*send_psm_request)(struct dp_link *dp_link, bool req);
-	bool (*phy_pattern_requested)(struct dp_link *dp_link);
+	void (*send_test_response)(struct dp_link *dp_link);
+	int (*psm_config)(struct dp_link *dp_link,
+		struct drm_dp_link *link_info, bool enable);
+	void (*send_edid_checksum)(struct dp_link *dp_link, u8 checksum);
 };
 
+static inline char *dp_link_get_phy_test_pattern(u32 phy_test_pattern_sel)
+{
+	switch (phy_test_pattern_sel) {
+	case DP_TEST_PHY_PATTERN_NONE:
+		return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_NONE);
+	case DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING:
+		return DP_LINK_ENUM_STR(
+			DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING);
+	case DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT:
+		return DP_LINK_ENUM_STR(
+			DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT);
+	case DP_TEST_PHY_PATTERN_PRBS7:
+		return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_PRBS7);
+	case DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN:
+		return DP_LINK_ENUM_STR(
+			DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN);
+	case DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN:
+		return DP_LINK_ENUM_STR(
+			DP_TEST_PHY_PATTERN_HBR2_CTS_EYE_PATTERN);
+	default:
+		return "unknown";
+	}
+}
+
+/**
+ * mdss_dp_test_bit_depth_to_bpp() - convert test bit depth to bpp
+ * @tbd: test bit depth
+ *
+ * Returns the bits per pixel (bpp) to be used corresponding to the
+ * git bit depth value. This function assumes that bit depth has
+ * already been validated.
+ */
+static inline u32 dp_link_bit_depth_to_bpp(u32 tbd)
+{
+	u32 bpp;
+
+	/*
+	 * Few simplistic rules and assumptions made here:
+	 *    1. Bit depth is per color component
+	 *    2. If bit depth is unknown return 0
+	 *    3. Assume 3 color components
+	 */
+	switch (tbd) {
+	case DP_TEST_BIT_DEPTH_6:
+		bpp = 18;
+		break;
+	case DP_TEST_BIT_DEPTH_8:
+		bpp = 24;
+		break;
+	case DP_TEST_BIT_DEPTH_10:
+		bpp = 30;
+		break;
+	case DP_TEST_BIT_DEPTH_UNKNOWN:
+	default:
+		bpp = 0;
+	}
+
+	return bpp;
+}
+
 /**
  * dp_link_get() - get the functionalities of dp test module
  *
diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
index 2e21033..fc3fb56 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -17,6 +17,7 @@
 #include "dp_panel.h"
 
 #define DP_PANEL_DEFAULT_BPP 24
+#define DP_MAX_DS_PORT_COUNT 1
 
 enum {
 	DP_LINK_RATE_MULTIPLIER = 27000000,
@@ -26,17 +27,35 @@
 	struct device *dev;
 	struct dp_panel dp_panel;
 	struct dp_aux *aux;
+	struct dp_link *link;
 	struct dp_catalog_panel *catalog;
-	bool lane_switch_supported;
 	bool aux_cfg_update_done;
 };
 
+static const struct dp_panel_info fail_safe = {
+	.h_active = 640,
+	.v_active = 480,
+	.h_back_porch = 48,
+	.h_front_porch = 16,
+	.h_sync_width = 96,
+	.h_active_low = 0,
+	.v_back_porch = 33,
+	.v_front_porch = 10,
+	.v_sync_width = 2,
+	.v_active_low = 0,
+	.h_skew = 0,
+	.refresh_rate = 60,
+	.pixel_clk_khz = 25200,
+	.bpp = 24,
+};
+
 static int dp_panel_read_dpcd(struct dp_panel *dp_panel)
 {
 	int rlen, rc = 0;
 	struct dp_panel_private *panel;
 	struct drm_dp_link *link_info;
-	u8 major = 0, minor = 0;
+	u8 *dpcd, major = 0, minor = 0;
+	u32 dfp_count = 0;
 	unsigned long caps = DP_LINK_CAP_ENHANCED_FRAMING;
 
 	if (!dp_panel) {
@@ -45,11 +64,13 @@
 		goto end;
 	}
 
+	dpcd = dp_panel->dpcd;
+
 	panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
 	link_info = &dp_panel->link_info;
 
 	rlen = drm_dp_dpcd_read(panel->aux->drm_aux, DP_DPCD_REV,
-		dp_panel->dpcd, (DP_RECEIVER_CAP_SIZE + 1));
+		dpcd, (DP_RECEIVER_CAP_SIZE + 1));
 	if (rlen < (DP_RECEIVER_CAP_SIZE + 1)) {
 		pr_err("dpcd read failed, rlen=%d\n", rlen);
 		rc = -EINVAL;
@@ -66,21 +87,54 @@
 		drm_dp_bw_code_to_link_rate(dp_panel->dpcd[DP_MAX_LINK_RATE]);
 	pr_debug("link_rate=%d\n", link_info->rate);
 
-	if (panel->lane_switch_supported)
-		link_info->num_lanes = dp_panel->dpcd[DP_MAX_LANE_COUNT] &
-			DP_MAX_LANE_COUNT_MASK;
-	else
-		link_info->num_lanes = 2;
+	link_info->num_lanes = dp_panel->dpcd[DP_MAX_LANE_COUNT] &
+				DP_MAX_LANE_COUNT_MASK;
 
 	pr_debug("lane_count=%d\n", link_info->num_lanes);
 
-	if (dp_panel->dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP)
+	if (drm_dp_enhanced_frame_cap(dpcd))
 		link_info->capabilities |= caps;
 
+	dfp_count = dpcd[DP_DOWN_STREAM_PORT_COUNT] &
+						DP_DOWN_STREAM_PORT_COUNT;
+
+	if ((dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT)
+		&& (dpcd[DP_DPCD_REV] > 0x10)) {
+		rlen = drm_dp_dpcd_read(panel->aux->drm_aux,
+			DP_DOWNSTREAM_PORT_0, dp_panel->ds_ports,
+			DP_MAX_DOWNSTREAM_PORTS);
+		if (rlen < DP_MAX_DOWNSTREAM_PORTS) {
+			pr_err("ds port status failed, rlen=%d\n", rlen);
+			rc = -EINVAL;
+			goto end;
+		}
+	}
+
+	if (dfp_count > DP_MAX_DS_PORT_COUNT)
+		pr_debug("DS port count %d greater that max (%d) supported\n",
+			dfp_count, DP_MAX_DS_PORT_COUNT);
+
 end:
 	return rc;
 }
 
+static int dp_panel_set_default_link_params(struct dp_panel *dp_panel)
+{
+	struct drm_dp_link *link_info;
+	const int default_bw_code = 162000;
+	const int default_num_lanes = 1;
+
+	if (!dp_panel) {
+		pr_err("invalid input\n");
+		return -EINVAL;
+	}
+	link_info = &dp_panel->link_info;
+	link_info->rate = default_bw_code;
+	link_info->num_lanes = default_num_lanes;
+	pr_debug("link_rate=%d num_lanes=%d\n",
+		link_info->rate, link_info->num_lanes);
+	return 0;
+}
 
 static int dp_panel_read_edid(struct dp_panel *dp_panel,
 	struct drm_connector *connector)
@@ -126,14 +180,18 @@
 	panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
 
 	rc = dp_panel_read_dpcd(dp_panel);
-	if (rc) {
-		pr_err("panel dpcd read failed\n");
-		return rc;
+	if (rc || !is_link_rate_valid(drm_dp_link_rate_to_bw_code(
+		dp_panel->link_info.rate)) || !is_lane_count_valid(
+		dp_panel->link_info.num_lanes) ||
+		((drm_dp_link_rate_to_bw_code(dp_panel->link_info.rate)) >
+		dp_panel->max_bw_code)) {
+		pr_err("panel dpcd read failed/incorrect, set default params\n");
+		dp_panel_set_default_link_params(dp_panel);
 	}
 
 	rc = dp_panel_read_edid(dp_panel, connector);
 	if (rc) {
-		pr_err("panel edid read failed\n");
+		pr_err("panel edid read failed, set failsafe mode\n");
 		return rc;
 	}
 
@@ -174,6 +232,94 @@
 	return max_pclk_rate_khz;
 }
 
+static void dp_panel_set_test_mode(struct dp_panel_private *panel,
+		struct dp_display_mode *mode)
+{
+	struct dp_panel_info *pinfo = NULL;
+	struct dp_link_test_video *test_info = NULL;
+
+	if (!panel) {
+		pr_err("invalid params\n");
+		return;
+	}
+
+	pinfo = &mode->timing;
+	test_info = &panel->link->test_video;
+
+	pinfo->h_active = test_info->test_h_width;
+	pinfo->h_sync_width = test_info->test_hsync_width;
+	pinfo->h_back_porch = test_info->test_h_start -
+		test_info->test_hsync_width;
+	pinfo->h_front_porch = test_info->test_h_total -
+		(test_info->test_h_start + test_info->test_h_width);
+
+	pinfo->v_active = test_info->test_v_height;
+	pinfo->v_sync_width = test_info->test_vsync_width;
+	pinfo->v_back_porch = test_info->test_v_start -
+		test_info->test_vsync_width;
+	pinfo->v_front_porch = test_info->test_v_total -
+		(test_info->test_v_start + test_info->test_v_height);
+
+	pinfo->bpp = dp_link_bit_depth_to_bpp(test_info->test_bit_depth);
+	pinfo->h_active_low = test_info->test_hsync_pol;
+	pinfo->v_active_low = test_info->test_vsync_pol;
+
+	pinfo->refresh_rate = test_info->test_rr_n;
+	pinfo->pixel_clk_khz = test_info->test_h_total *
+		test_info->test_v_total * pinfo->refresh_rate;
+
+	if (test_info->test_rr_d == 0)
+		pinfo->pixel_clk_khz /= 1000;
+	else
+		pinfo->pixel_clk_khz /= 1001;
+
+	if (test_info->test_h_width == 640)
+		pinfo->pixel_clk_khz = 25170;
+}
+
+static int dp_panel_get_modes(struct dp_panel *dp_panel,
+	struct drm_connector *connector, struct dp_display_mode *mode)
+{
+	struct dp_panel_private *panel;
+
+	if (!dp_panel) {
+		pr_err("invalid input\n");
+		return -EINVAL;
+	}
+
+	panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
+
+	if (dp_panel->video_test) {
+		dp_panel_set_test_mode(panel, mode);
+		return 1;
+	} else if (dp_panel->edid_ctrl->edid) {
+		return _sde_edid_update_modes(connector, dp_panel->edid_ctrl);
+	} else { /* fail-safe mode */
+		memcpy(&mode->timing, &fail_safe,
+			sizeof(fail_safe));
+		return 1;
+	}
+}
+
+static void dp_panel_handle_sink_request(struct dp_panel *dp_panel)
+{
+	struct dp_panel_private *panel;
+
+	if (!dp_panel) {
+		pr_err("invalid input\n");
+		return;
+	}
+
+	panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
+
+	if (panel->link->sink_request & DP_TEST_LINK_EDID_READ) {
+		u8 checksum = sde_get_edid_checksum(dp_panel->edid_ctrl);
+
+		panel->link->send_edid_checksum(panel->link, checksum);
+		panel->link->send_test_response(panel->link);
+	}
+}
+
 static int dp_panel_timing_cfg(struct dp_panel *dp_panel)
 {
 	int rc = 0;
@@ -332,31 +478,32 @@
 	return min_link_rate_khz;
 }
 
-struct dp_panel *dp_panel_get(struct device *dev, struct dp_aux *aux,
-				struct dp_catalog_panel *catalog)
+struct dp_panel *dp_panel_get(struct dp_panel_in *in)
 {
 	int rc = 0;
 	struct dp_panel_private *panel;
 	struct dp_panel *dp_panel;
 
-	if (!dev || !aux || !catalog) {
+	if (!in->dev || !in->catalog || !in->aux || !in->link) {
 		pr_err("invalid input\n");
 		rc = -EINVAL;
 		goto error;
 	}
 
-	panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
+	panel = devm_kzalloc(in->dev, sizeof(*panel), GFP_KERNEL);
 	if (!panel) {
 		rc = -ENOMEM;
 		goto error;
 	}
 
-	panel->dev = dev;
-	panel->aux = aux;
-	panel->catalog = catalog;
+	panel->dev = in->dev;
+	panel->aux = in->aux;
+	panel->catalog = in->catalog;
+	panel->link = in->link;
 
 	dp_panel = &panel->dp_panel;
 	panel->aux_cfg_update_done = false;
+	dp_panel->max_bw_code = DP_LINK_BW_8_1;
 
 	dp_panel->sde_edid_register = dp_panel_edid_register;
 	dp_panel->sde_edid_deregister = dp_panel_edid_deregister;
@@ -365,6 +512,8 @@
 	dp_panel->read_sink_caps = dp_panel_read_sink_caps;
 	dp_panel->get_min_req_link_rate = dp_panel_get_min_req_link_rate;
 	dp_panel->get_max_pclk = dp_panel_get_max_pclk;
+	dp_panel->get_modes = dp_panel_get_modes;
+	dp_panel->handle_sink_request = dp_panel_handle_sink_request;
 
 	return dp_panel;
 error:
diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h b/drivers/gpu/drm/msm/dp/dp_panel.h
index ab9a451..01a978a 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.h
+++ b/drivers/gpu/drm/msm/dp/dp_panel.h
@@ -16,9 +16,17 @@
 #define _DP_PANEL_H_
 
 #include "dp_aux.h"
+#include "dp_link.h"
+#include "dp_usbpd.h"
 #include "sde_edid_parser.h"
 
-#define DP_LINK_RATE_810	30	/* 8.10G = 270M * 30 */
+enum dp_lane_count {
+	DP_LANE_COUNT_1	= 1,
+	DP_LANE_COUNT_2	= 2,
+	DP_LANE_COUNT_4	= 4,
+};
+
+#define DP_MAX_DOWNSTREAM_PORTS 0x10
 
 struct dp_panel_info {
 	u32 h_active;
@@ -37,18 +45,35 @@
 	u32 bpp;
 };
 
+struct dp_display_mode {
+	struct dp_panel_info timing;
+	u32 capabilities;
+};
+
+struct dp_panel_in {
+	struct device *dev;
+	struct dp_aux *aux;
+	struct dp_link *link;
+	struct dp_catalog_panel *catalog;
+};
+
 struct dp_panel {
 	/* dpcd raw data */
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
-	struct drm_dp_link link_info;
+	u8 ds_ports[DP_MAX_DOWNSTREAM_PORTS];
 
+	struct drm_dp_link link_info;
 	struct sde_edid_ctrl *edid_ctrl;
 	struct drm_connector *connector;
 	struct dp_panel_info pinfo;
+	bool video_test;
 
 	u32 vic;
 	u32 max_pclk_khz;
 
+	/* debug */
+	u32 max_bw_code;
+
 	int (*sde_edid_register)(struct dp_panel *dp_panel);
 	void (*sde_edid_deregister)(struct dp_panel *dp_panel);
 	int (*init_info)(struct dp_panel *dp_panel);
@@ -57,9 +82,38 @@
 		struct drm_connector *connector);
 	u32 (*get_min_req_link_rate)(struct dp_panel *dp_panel);
 	u32 (*get_max_pclk)(struct dp_panel *dp_panel);
+	int (*get_modes)(struct dp_panel *dp_panel,
+		struct drm_connector *connector, struct dp_display_mode *mode);
+	void (*handle_sink_request)(struct dp_panel *dp_panel);
 };
 
-struct dp_panel *dp_panel_get(struct device *dev, struct dp_aux *aux,
-				struct dp_catalog_panel *catalog);
+/**
+ * is_link_rate_valid() - validates the link rate
+ * @lane_rate: link rate requested by the sink
+ *
+ * Returns true if the requested link rate is supported.
+ */
+static inline bool is_link_rate_valid(u32 bw_code)
+{
+	return ((bw_code == DP_LINK_BW_1_62) ||
+		(bw_code == DP_LINK_BW_2_7) ||
+		(bw_code == DP_LINK_BW_5_4) ||
+		(bw_code == DP_LINK_BW_8_1));
+}
+
+/**
+ * dp_link_is_lane_count_valid() - validates the lane count
+ * @lane_count: lane count requested by the sink
+ *
+ * Returns true if the requested lane count is supported.
+ */
+static inline bool is_lane_count_valid(u32 lane_count)
+{
+	return (lane_count == DP_LANE_COUNT_1) ||
+		(lane_count == DP_LANE_COUNT_2) ||
+		(lane_count == DP_LANE_COUNT_4);
+}
+
+struct dp_panel *dp_panel_get(struct dp_panel_in *in);
 void dp_panel_put(struct dp_panel *dp_panel);
 #endif /* _DP_PANEL_H_ */
diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c
index c85c2a2..c8da99a 100644
--- a/drivers/gpu/drm/msm/dp/dp_parser.c
+++ b/drivers/gpu/drm/msm/dp/dp_parser.c
@@ -22,22 +22,15 @@
 {
 	struct dp_io *io = &parser->io;
 
-	if (&io->ctrl_io)
-		msm_dss_iounmap(&io->ctrl_io);
-	if (&io->phy_io)
-		msm_dss_iounmap(&io->phy_io);
-	if (&io->ln_tx0_io)
-		msm_dss_iounmap(&io->ln_tx0_io);
-	if (&io->ln_tx1_io)
-		msm_dss_iounmap(&io->ln_tx0_io);
-	if (&io->dp_pll_io)
-		msm_dss_iounmap(&io->dp_pll_io);
-	if (&io->dp_cc_io)
-		msm_dss_iounmap(&io->dp_cc_io);
-	if (&io->qfprom_io)
-		msm_dss_iounmap(&io->qfprom_io);
-	if (&io->hdcp_io)
-		msm_dss_iounmap(&io->hdcp_io);
+	msm_dss_iounmap(&io->ctrl_io);
+	msm_dss_iounmap(&io->phy_io);
+	msm_dss_iounmap(&io->ln_tx0_io);
+	msm_dss_iounmap(&io->ln_tx0_io);
+	msm_dss_iounmap(&io->dp_pll_io);
+	msm_dss_iounmap(&io->dp_cc_io);
+	msm_dss_iounmap(&io->usb3_dp_com);
+	msm_dss_iounmap(&io->qfprom_io);
+	msm_dss_iounmap(&io->hdcp_io);
 }
 
 static int dp_parser_ctrl_res(struct dp_parser *parser)
@@ -84,6 +77,12 @@
 		goto err;
 	}
 
+	rc = msm_dss_ioremap_byname(pdev, &io->usb3_dp_com, "usb3_dp_com");
+	if (rc) {
+		pr_err("unable to remap USB3 DP com resources\n");
+		goto err;
+	}
+
 	if (msm_dss_ioremap_byname(pdev, &io->dp_cc_io, "dp_mmss_cc")) {
 		pr_err("unable to remap dp MMSS_CC resources\n");
 		goto err;
diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h
index 7794da5..76a72a2 100644
--- a/drivers/gpu/drm/msm/dp/dp_parser.h
+++ b/drivers/gpu/drm/msm/dp/dp_parser.h
@@ -65,6 +65,7 @@
  * @dp_cc_io: DP cc's mapped memory address
  * @qfprom_io: qfprom's mapped memory address
  * @dp_pll_io: DP PLL mapped memory address
+ * @usb3_dp_com: USB3 DP PHY combo mapped memory address
  * @hdcp_io: hdcp's mapped memory address
  */
 struct dp_io {
@@ -75,6 +76,7 @@
 	struct dss_io_data dp_cc_io;
 	struct dss_io_data qfprom_io;
 	struct dss_io_data dp_pll_io;
+	struct dss_io_data usb3_dp_com;
 	struct dss_io_data hdcp_io;
 };
 
diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c
index 60c8966..eb787fa 100644
--- a/drivers/gpu/drm/msm/dp/dp_power.c
+++ b/drivers/gpu/drm/msm/dp/dp_power.c
@@ -612,8 +612,12 @@
 
 void dp_power_put(struct dp_power *dp_power)
 {
-	struct dp_power_private *power = container_of(dp_power,
-			struct dp_power_private, dp_power);
+	struct dp_power_private *power = NULL;
+
+	if (!dp_power)
+		return;
+
+	power = container_of(dp_power, struct dp_power_private, dp_power);
 
 	devm_kfree(&power->pdev->dev, power);
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_reg.h b/drivers/gpu/drm/msm/dp/dp_reg.h
index 30377a0..25d035d 100644
--- a/drivers/gpu/drm/msm/dp/dp_reg.h
+++ b/drivers/gpu/drm/msm/dp/dp_reg.h
@@ -79,6 +79,8 @@
 #define MMSS_DP_PSR_CRC_RG			(0x00000554)
 #define MMSS_DP_PSR_CRC_B			(0x00000558)
 
+#define DP_COMPRESSION_MODE_CTRL		(0x00000580)
+
 #define MMSS_DP_AUDIO_CFG			(0x00000600)
 #define MMSS_DP_AUDIO_STATUS			(0x00000604)
 #define MMSS_DP_AUDIO_PKT_CTRL			(0x00000608)
@@ -141,6 +143,17 @@
 #define MMSS_DP_GENERIC1_8			(0x00000748)
 #define MMSS_DP_GENERIC1_9			(0x0000074C)
 
+#define MMSS_DP_VSCEXT_0			(0x000006D0)
+#define MMSS_DP_VSCEXT_1			(0x000006D4)
+#define MMSS_DP_VSCEXT_2			(0x000006D8)
+#define MMSS_DP_VSCEXT_3			(0x000006DC)
+#define MMSS_DP_VSCEXT_4			(0x000006E0)
+#define MMSS_DP_VSCEXT_5			(0x000006E4)
+#define MMSS_DP_VSCEXT_6			(0x000006E8)
+#define MMSS_DP_VSCEXT_7			(0x000006EC)
+#define MMSS_DP_VSCEXT_8			(0x000006F0)
+#define MMSS_DP_VSCEXT_9			(0x000006F4)
+
 #define MMSS_DP_TIMING_ENGINE_EN		(0x00000A10)
 #define MMSS_DP_ASYNC_FIFO_CONFIG		(0x00000A88)
 
@@ -166,6 +179,7 @@
 #define DP_PHY_AUX_CFG9                         (0x00000044)
 #define DP_PHY_AUX_INTERRUPT_MASK               (0x00000048)
 #define DP_PHY_AUX_INTERRUPT_CLEAR              (0x0000004C)
+#define DP_PHY_AUX_INTERRUPT_STATUS             (0x000000BC)
 
 #define DP_PHY_SPARE0				(0x00AC)
 
@@ -205,4 +219,14 @@
 #define HDCP_SEC_DP_TZ_HV_HLOS_HDCP_RCVPORT_DATA11     (0x01C)
 #define HDCP_SEC_DP_TZ_HV_HLOS_HDCP_RCVPORT_DATA12     (0x020)
 
+/* USB3 DP COM registers */
+#define USB3_DP_COM_RESET_OVRD_CTRL (0x1C)
+#define USB3_DP_COM_PHY_MODE_CTRL   (0x00)
+#define USB3_DP_COM_SW_RESET        (0x04)
+#define USB3_DP_COM_TYPEC_CTRL      (0x10)
+#define USB3_DP_COM_SWI_CTRL        (0x0c)
+#define USB3_DP_COM_POWER_DOWN_CTRL (0x08)
+
+
+
 #endif /* _DP_REG_H_ */
diff --git a/drivers/gpu/drm/msm/dp/dp_usbpd.c b/drivers/gpu/drm/msm/dp/dp_usbpd.c
index df43267..98781abb 100644
--- a/drivers/gpu/drm/msm/dp/dp_usbpd.c
+++ b/drivers/gpu/drm/msm/dp/dp_usbpd.c
@@ -73,8 +73,6 @@
 	struct dp_usbpd dp_usbpd;
 	enum dp_usbpd_alt_mode alt_mode;
 	u32 dp_usbpd_config;
-
-	bool forced_disconnect;
 };
 
 static const char *dp_usbpd_pin_name(u8 pin)
@@ -178,7 +176,10 @@
 	u32 config = 0;
 	const u32 ufp_d_config = 0x2, dp_ver = 0x1;
 
-	pin_cfg = pd->cap.dlink_pin_config;
+	if (pd->cap.receptacle_state)
+		pin_cfg = pd->cap.ulink_pin_config;
+	else
+		pin_cfg = pd->cap.dlink_pin_config;
 
 	for (pin = DP_USBPD_PIN_A; pin < DP_USBPD_PIN_MAX; pin++) {
 		if (pin_cfg & BIT(pin)) {
@@ -344,7 +345,7 @@
 		dp_usbpd_send_event(pd, DP_USBPD_EVT_STATUS);
 		break;
 	case USBPD_SVDM_ATTENTION:
-		if (pd->forced_disconnect)
+		if (pd->dp_usbpd.forced_disconnect)
 			break;
 
 		pd->vdo = *vdos;
@@ -374,6 +375,18 @@
 
 		pd->dp_usbpd.orientation = usbpd_get_plug_orientation(pd->pd);
 
+		/*
+		 * By default, USB reserves two lanes for Super Speed.
+		 * Which means DP has remaining two lanes to operate on.
+		 * If multi-function is not supported, request USB to
+		 * release the Super Speed lanes so that DP can use
+		 * all four lanes in case DPCD indicates support for
+		 * four lanes.
+		 */
+		if (!pd->dp_usbpd.multi_func)
+			pd->svid_handler.request_usb_ss_lane(pd->pd,
+				&pd->svid_handler);
+
 		if (pd->dp_cb && pd->dp_cb->configure)
 			pd->dp_cb->configure(pd->dev);
 		break;
@@ -397,7 +410,7 @@
 	pd = container_of(dp_usbpd, struct dp_usbpd_private, dp_usbpd);
 
 	dp_usbpd->hpd_high = hpd;
-	pd->forced_disconnect = !hpd;
+	dp_usbpd->forced_disconnect = !hpd;
 
 	if (hpd)
 		pd->dp_cb->configure(pd->dev);
@@ -451,7 +464,7 @@
 	if (rc) {
 		pr_err("pd registration failed\n");
 		rc = -ENODEV;
-		kfree(usbpd);
+		devm_kfree(dev, usbpd);
 		goto error;
 	}
 
@@ -472,5 +485,7 @@
 
 	usbpd = container_of(dp_usbpd, struct dp_usbpd_private, dp_usbpd);
 
-	kfree(usbpd);
+	usbpd_unregister_svid(usbpd->pd, &usbpd->svid_handler);
+
+	devm_kfree(usbpd->dev, usbpd);
 }
diff --git a/drivers/gpu/drm/msm/dp/dp_usbpd.h b/drivers/gpu/drm/msm/dp/dp_usbpd.h
index 2682e98..5b392f5 100644
--- a/drivers/gpu/drm/msm/dp/dp_usbpd.h
+++ b/drivers/gpu/drm/msm/dp/dp_usbpd.h
@@ -63,6 +63,7 @@
 	bool hpd_irq;
 	bool alt_mode_cfg_done;
 	bool debug_en;
+	bool forced_disconnect;
 
 	int (*connect)(struct dp_usbpd *dp_usbpd, bool hpd);
 };
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
index e9dabb1..5d9d21f 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
@@ -28,6 +28,7 @@
 	ctrl->ops.video_engine_en        = dsi_ctrl_hw_cmn_video_engine_en;
 	ctrl->ops.video_engine_setup     = dsi_ctrl_hw_cmn_video_engine_setup;
 	ctrl->ops.set_video_timing       = dsi_ctrl_hw_cmn_set_video_timing;
+	ctrl->ops.set_timing_db          = dsi_ctrl_hw_cmn_set_timing_db;
 	ctrl->ops.cmd_engine_setup       = dsi_ctrl_hw_cmn_cmd_engine_setup;
 	ctrl->ops.setup_cmd_stream       = dsi_ctrl_hw_cmn_setup_cmd_stream;
 	ctrl->ops.ctrl_en                = dsi_ctrl_hw_cmn_ctrl_en;
@@ -58,6 +59,9 @@
 	ctrl->ops.phy_reset_config = dsi_ctrl_hw_cmn_phy_reset_config;
 	ctrl->ops.setup_misr = dsi_ctrl_hw_cmn_setup_misr;
 	ctrl->ops.collect_misr = dsi_ctrl_hw_cmn_collect_misr;
+	ctrl->ops.debug_bus = dsi_ctrl_hw_cmn_debug_bus;
+	ctrl->ops.get_cmd_read_data = dsi_ctrl_hw_cmn_get_cmd_read_data;
+	ctrl->ops.clear_rdbk_register = dsi_ctrl_hw_cmn_clear_rdbk_reg;
 
 	switch (version) {
 	case DSI_CTRL_VERSION_1_4:
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
index e8d594c..186a5b5 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
@@ -104,6 +104,7 @@
 
 /* DSI controller common ops */
 u32 dsi_ctrl_hw_cmn_get_interrupt_status(struct dsi_ctrl_hw *ctrl);
+void dsi_ctrl_hw_cmn_debug_bus(struct dsi_ctrl_hw *ctrl);
 void dsi_ctrl_hw_cmn_clear_interrupt_status(struct dsi_ctrl_hw *ctrl, u32 ints);
 void dsi_ctrl_hw_cmn_enable_status_interrupts(struct dsi_ctrl_hw *ctrl,
 					     u32 ints);
@@ -132,7 +133,8 @@
 				       struct dsi_video_engine_cfg *cfg);
 void dsi_ctrl_hw_cmn_set_video_timing(struct dsi_ctrl_hw *ctrl,
 			 struct dsi_mode_info *mode);
-
+void dsi_ctrl_hw_cmn_set_timing_db(struct dsi_ctrl_hw *ctrl,
+				     bool enable);
 void dsi_ctrl_hw_cmn_cmd_engine_setup(struct dsi_ctrl_hw *ctrl,
 				     struct dsi_host_common_cfg *common_cfg,
 				     struct dsi_cmd_engine_cfg *cfg);
@@ -168,6 +170,12 @@
 			bool enable);
 void dsi_ctrl_hw_22_phy_reset_config(struct dsi_ctrl_hw *ctrl,
 			bool enable);
+u32 dsi_ctrl_hw_cmn_get_cmd_read_data(struct dsi_ctrl_hw *ctrl,
+				     u8 *rd_buf,
+				     u32 read_offset,
+				     u32 rx_byte,
+				     u32 pkt_size, u32 *hw_read_cnt);
+void dsi_ctrl_hw_cmn_clear_rdbk_reg(struct dsi_ctrl_hw *ctrl);
 
 /* Definitions specific to 1.4 DSI controller hardware */
 int dsi_ctrl_hw_14_wait_for_lane_idle(struct dsi_ctrl_hw *ctrl, u32 lanes);
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
index dcde566..790ee22 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
@@ -38,6 +38,8 @@
 #define DSI_CTRL_TX_TO_MS     200
 
 #define TO_ON_OFF(x) ((x) ? "ON" : "OFF")
+
+#define CEIL(x, y)              (((x) + ((y)-1)) / (y))
 /**
  * enum dsi_ctrl_driver_ops - controller driver ops
  */
@@ -884,12 +886,49 @@
 		buf[3] |= BIT(6);
 
 	buf[3] |= BIT(7);
+
+	/* send embedded BTA for read commands */
+	if ((buf[2] & 0x3f) == MIPI_DSI_DCS_READ)
+		buf[3] |= BIT(5);
+
 	*buffer = buf;
 	*size = len;
 
 	return rc;
 }
 
+static void dsi_ctrl_wait_for_video_done(struct dsi_ctrl *dsi_ctrl)
+{
+	u32 v_total = 0, v_blank = 0, sleep_ms = 0, fps = 0, ret;
+	struct dsi_mode_info *timing;
+
+	if (dsi_ctrl->host_config.panel_mode != DSI_OP_VIDEO_MODE)
+		return;
+
+	dsi_ctrl->hw.ops.clear_interrupt_status(&dsi_ctrl->hw,
+				DSI_VIDEO_MODE_FRAME_DONE);
+
+	dsi_ctrl_enable_status_interrupt(dsi_ctrl,
+				DSI_SINT_VIDEO_MODE_FRAME_DONE, NULL);
+	reinit_completion(&dsi_ctrl->irq_info.vid_frame_done);
+	ret = wait_for_completion_timeout(
+			&dsi_ctrl->irq_info.vid_frame_done,
+			msecs_to_jiffies(DSI_CTRL_TX_TO_MS));
+	if (ret <= 0)
+		pr_debug("wait for video done failed\n");
+	dsi_ctrl_disable_status_interrupt(dsi_ctrl,
+				DSI_SINT_VIDEO_MODE_FRAME_DONE);
+
+	timing = &(dsi_ctrl->host_config.video_timing);
+	v_total = timing->v_sync_width + timing->v_back_porch +
+			timing->v_front_porch + timing->v_active;
+	v_blank = timing->v_sync_width + timing->v_back_porch;
+	fps = timing->refresh_rate;
+
+	sleep_ms = CEIL((v_blank * 1000), (v_total * fps)) + 1;
+	udelay(sleep_ms * 1000);
+}
+
 static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
 			  const struct mipi_dsi_msg *msg,
 			  u32 flags)
@@ -971,6 +1010,7 @@
 	}
 
 	if (!(flags & DSI_CTRL_CMD_DEFER_TRIGGER)) {
+		dsi_ctrl_wait_for_video_done(dsi_ctrl);
 		dsi_ctrl_enable_status_interrupt(dsi_ctrl,
 					DSI_SINT_CMD_MODE_DMA_DONE, NULL);
 		reinit_completion(&dsi_ctrl->irq_info.cmd_dma_done);
@@ -1026,6 +1066,7 @@
 {
 	int rc = 0;
 	u8 tx[2] = { (u8)(size & 0xFF), (u8)(size >> 8) };
+	u32 flags = DSI_CTRL_CMD_FETCH_MEMORY;
 	struct mipi_dsi_msg msg = {
 		.channel = rx_msg->channel,
 		.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
@@ -1033,24 +1074,77 @@
 		.tx_buf = tx,
 	};
 
-	rc = dsi_message_tx(dsi_ctrl, &msg, 0x0);
+	rc = dsi_message_tx(dsi_ctrl, &msg, flags);
 	if (rc)
 		pr_err("failed to send max return size packet, rc=%d\n", rc);
 
 	return rc;
 }
 
+/* Helper functions to support DCS read operation */
+static int dsi_parse_short_read1_resp(const struct mipi_dsi_msg *msg,
+		unsigned char *buff)
+{
+	u8 *data = msg->rx_buf;
+	int read_len = 1;
+
+	if (!data)
+		return 0;
+
+	/* remove dcs type */
+	if (msg->rx_len >= 1)
+		data[0] = buff[1];
+	else
+		read_len = 0;
+
+	return read_len;
+}
+
+static int dsi_parse_short_read2_resp(const struct mipi_dsi_msg *msg,
+		unsigned char *buff)
+{
+	u8 *data = msg->rx_buf;
+	int read_len = 2;
+
+	if (!data)
+		return 0;
+
+	/* remove dcs type */
+	if (msg->rx_len >= 2) {
+		data[0] = buff[1];
+		data[1] = buff[2];
+	} else {
+		read_len = 0;
+	}
+
+	return read_len;
+}
+
+static int dsi_parse_long_read_resp(const struct mipi_dsi_msg *msg,
+		unsigned char *buff)
+{
+	if (!msg->rx_buf)
+		return 0;
+
+	/* remove dcs type */
+	if (msg->rx_buf && msg->rx_len)
+		memcpy(msg->rx_buf, buff + 4, msg->rx_len);
+
+	return msg->rx_len;
+}
+
 static int dsi_message_rx(struct dsi_ctrl *dsi_ctrl,
 			  const struct mipi_dsi_msg *msg,
 			  u32 flags)
 {
 	int rc = 0;
-	u32 rd_pkt_size;
-	u32 total_read_len;
-	u32 bytes_read = 0, tot_bytes_read = 0;
-	u32 current_read_len;
+	u32 rd_pkt_size, total_read_len, hw_read_cnt;
+	u32 current_read_len = 0, total_bytes_read = 0;
 	bool short_resp = false;
 	bool read_done = false;
+	u32 dlen, diff, rlen = msg->rx_len;
+	unsigned char *buff;
+	char cmd;
 
 	if (msg->rx_len <= 2) {
 		short_resp = true;
@@ -1066,6 +1160,7 @@
 
 		total_read_len = current_read_len + 6;
 	}
+	buff = msg->rx_buf;
 
 	while (!read_done) {
 		rc = dsi_set_max_return_size(dsi_ctrl, msg, rd_pkt_size);
@@ -1075,24 +1170,79 @@
 			goto error;
 		}
 
+		/* clear RDBK_DATA registers before proceeding */
+		dsi_ctrl->hw.ops.clear_rdbk_register(&dsi_ctrl->hw);
+
 		rc = dsi_message_tx(dsi_ctrl, msg, flags);
 		if (rc) {
 			pr_err("Message transmission failed, rc=%d\n", rc);
 			goto error;
 		}
 
+		dlen = dsi_ctrl->hw.ops.get_cmd_read_data(&dsi_ctrl->hw,
+					buff, total_bytes_read,
+					total_read_len, rd_pkt_size,
+					&hw_read_cnt);
+		if (!dlen)
+			goto error;
 
-		tot_bytes_read += bytes_read;
 		if (short_resp)
+			break;
+
+		if (rlen <= current_read_len) {
+			diff = current_read_len - rlen;
 			read_done = true;
-		else if (msg->rx_len <= tot_bytes_read)
-			read_done = true;
+		} else {
+			diff = 0;
+			rlen -= current_read_len;
+		}
+
+		dlen -= 2; /* 2 bytes of CRC */
+		dlen -= diff;
+		buff += dlen;
+		total_bytes_read += dlen;
+		if (!read_done) {
+			current_read_len = 14; /* Not first read */
+			if (rlen < current_read_len)
+				rd_pkt_size += rlen;
+			else
+				rd_pkt_size += current_read_len;
+		}
 	}
+
+	if (hw_read_cnt < 16 && !short_resp)
+		buff = msg->rx_buf + (16 - hw_read_cnt);
+	else
+		buff = msg->rx_buf;
+
+	/* parse the data read from panel */
+	cmd = buff[0];
+	switch (cmd) {
+	case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT:
+		pr_err("Rx ACK_ERROR\n");
+		rc = 0;
+		break;
+	case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE:
+	case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
+		rc = dsi_parse_short_read1_resp(msg, buff);
+		break;
+	case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE:
+	case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE:
+		rc = dsi_parse_short_read2_resp(msg, buff);
+		break;
+	case MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE:
+	case MIPI_DSI_RX_DCS_LONG_READ_RESPONSE:
+		rc = dsi_parse_long_read_resp(msg, buff);
+		break;
+	default:
+		pr_warn("Invalid response\n");
+		rc = 0;
+	}
+
 error:
 	return rc;
 }
 
-
 static int dsi_enable_ulps(struct dsi_ctrl *dsi_ctrl)
 {
 	int rc = 0;
@@ -1193,7 +1343,9 @@
 
 		msm_gem_put_iova(dsi_ctrl->tx_cmd_buf, aspace);
 
+		mutex_lock(&dsi_ctrl->drm_dev->struct_mutex);
 		msm_gem_free_object(dsi_ctrl->tx_cmd_buf);
+		mutex_unlock(&dsi_ctrl->drm_dev->struct_mutex);
 		dsi_ctrl->tx_cmd_buf = NULL;
 	}
 
@@ -1429,6 +1581,26 @@
 	},
 };
 
+#if defined(CONFIG_DEBUG_FS)
+
+void dsi_ctrl_debug_dump(void)
+{
+	struct list_head *pos, *tmp;
+	struct dsi_ctrl *ctrl = NULL;
+
+	mutex_lock(&dsi_ctrl_list_lock);
+	list_for_each_safe(pos, tmp, &dsi_ctrl_list) {
+		struct dsi_ctrl_list_item *n;
+
+		n = list_entry(pos, struct dsi_ctrl_list_item, list);
+		ctrl = n->ctrl;
+		pr_err("dsi ctrl:%d\n", ctrl->cell_index);
+		ctrl->hw.ops.debug_bus(&ctrl->hw);
+	}
+	mutex_unlock(&dsi_ctrl_list_lock);
+}
+
+#endif
 /**
  * dsi_ctrl_get() - get a dsi_ctrl handle from an of_node
  * @of_node:    of_node of the DSI controller.
@@ -1645,7 +1817,7 @@
 
 	host_mode = &dsi_ctrl->host_config.video_timing;
 	memcpy(host_mode, timing, sizeof(*host_mode));
-
+	dsi_ctrl->hw.ops.set_timing_db(&dsi_ctrl->hw, true);
 	dsi_ctrl->hw.ops.set_video_timing(&dsi_ctrl->hw, host_mode);
 
 exit:
@@ -1653,6 +1825,53 @@
 	return rc;
 }
 
+/**
+ * dsi_ctrl_timing_db_update() - update only controller Timing DB
+ * @dsi_ctrl:          DSI controller handle.
+ * @enable:            Enable/disable Timing DB register
+ *
+ *  Update timing db register value during dfps usecases
+ *
+ * Return: error code.
+ */
+int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
+		bool enable)
+{
+	int rc = 0;
+
+	if (!dsi_ctrl) {
+		pr_err("Invalid dsi_ctrl\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&dsi_ctrl->ctrl_lock);
+
+	rc = dsi_ctrl_check_state(dsi_ctrl, DSI_CTRL_OP_ASYNC_TIMING,
+			DSI_CTRL_ENGINE_ON);
+	if (rc) {
+		pr_err("[DSI_%d] Controller state check failed, rc=%d\n",
+		       dsi_ctrl->cell_index, rc);
+		goto exit;
+	}
+
+	/*
+	 * Add HW recommended delay for dfps feature.
+	 * When prefetch is enabled, MDSS HW works on 2 vsync
+	 * boundaries i.e. mdp_vsync and panel_vsync.
+	 * In the current implementation we are only waiting
+	 * for mdp_vsync. We need to make sure that interface
+	 * flush is after panel_vsync. So, added the recommended
+	 * delays after dfps update.
+	 */
+	usleep_range(2000, 2010);
+
+	dsi_ctrl->hw.ops.set_timing_db(&dsi_ctrl->hw, enable);
+
+exit:
+	mutex_unlock(&dsi_ctrl->ctrl_lock);
+	return rc;
+}
+
 int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl)
 {
 	int rc = 0;
@@ -2146,7 +2365,7 @@
 		goto error;
 	}
 
-	if (!(flags & DSI_MODE_FLAG_SEAMLESS)) {
+	if (!(flags & (DSI_MODE_FLAG_SEAMLESS | DSI_MODE_FLAG_VRR))) {
 		rc = dsi_ctrl_update_link_freqs(ctrl, config, clk_handle);
 		if (rc) {
 			pr_err("[%s] failed to update link frequencies, rc=%d\n",
@@ -2231,8 +2450,8 @@
 
 	if (flags & DSI_CTRL_CMD_READ) {
 		rc = dsi_message_rx(dsi_ctrl, msg, flags);
-		if (rc)
-			pr_err("read message failed, rc=%d\n", rc);
+		if (rc <= 0)
+			pr_err("read message failed read length, rc=%d\n", rc);
 	} else {
 		rc = dsi_message_tx(dsi_ctrl, msg, flags);
 		if (rc)
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
index f10c7a6..4781299 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
@@ -311,6 +311,18 @@
 				int flags, void *clk_handle);
 
 /**
+ * dsi_ctrl_timing_db_update() - update only controller Timing DB
+ * @dsi_ctrl:          DSI controller handle.
+ * @enable:            Enable/disable Timing DB register
+ *
+ * Update timing db register value during dfps usecases
+ *
+ * Return: error code.
+ */
+int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
+		bool enable);
+
+/**
  * dsi_ctrl_async_timing_update() - update only controller timing
  * @dsi_ctrl:          DSI controller handle.
  * @timing:            New DSI timing info
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
index 57f9bcd..714a450 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
@@ -445,6 +445,12 @@
 	void (*phy_sw_reset)(struct dsi_ctrl_hw *ctrl);
 
 	/**
+	 * debug_bus() - get dsi debug bus status.
+	 * @ctrl:        Pointer to the controller host hardware.
+	 */
+	void (*debug_bus)(struct dsi_ctrl_hw *ctrl);
+
+	/**
 	 * soft_reset() - perform a soft reset on DSI controller
 	 * @ctrl:          Pointer to the controller host hardware.
 	 *
@@ -514,11 +520,17 @@
 	 * get_cmd_read_data() - get data read from the peripheral
 	 * @ctrl:           Pointer to the controller host hardware.
 	 * @rd_buf:         Buffer where data will be read into.
-	 * @total_read_len: Number of bytes to read.
+	 * @read_offset:    Offset from where to read.
+	 * @rx_byte:        Number of bytes to be read.
+	 * @pkt_size:        Size of response expected.
+	 * @hw_read_cnt:    Actual number of bytes read by HW.
 	 */
 	u32 (*get_cmd_read_data)(struct dsi_ctrl_hw *ctrl,
 				 u8 *rd_buf,
-				 u32 total_read_len);
+				 u32 read_offset,
+				 u32 rx_byte,
+				 u32 pkt_size,
+				 u32 *hw_read_cnt);
 
 	/**
 	 * wait_for_lane_idle() - wait for DSI lanes to go to idle state
@@ -695,6 +707,20 @@
 	u32 (*collect_misr)(struct dsi_ctrl_hw *ctrl,
 			    enum dsi_op_mode panel_mode);
 
+	/**
+	 * set_timing_db() - enable/disable Timing DB register
+	 * @ctrl:          Pointer to controller host hardware.
+	 * @enable:        Enable/Disable flag.
+	 *
+	 * Enable or Disabe the Timing DB register.
+	 */
+	void (*set_timing_db)(struct dsi_ctrl_hw *ctrl,
+				 bool enable);
+	/**
+	 * clear_rdbk_register() - Clear and reset read back register
+	 * @ctrl:         Pointer to the controller host hardware.
+	 */
+	void (*clear_rdbk_register)(struct dsi_ctrl_hw *ctrl);
 };
 
 /*
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
index 3fec296..2959e94 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
@@ -16,11 +16,13 @@
 #include <linux/delay.h>
 #include <linux/iopoll.h>
 
+#include "dsi_catalog.h"
 #include "dsi_ctrl_hw.h"
 #include "dsi_ctrl_reg.h"
 #include "dsi_hw.h"
 #include "dsi_panel.h"
 #include "dsi_catalog.h"
+#include "sde_dbg.h"
 
 #define MMSS_MISC_CLAMP_REG_OFF           0x0014
 #define DSI_CTRL_DYNAMIC_FORCE_ON         (0x23F|BIT(8)|BIT(9)|BIT(11)|BIT(21))
@@ -218,6 +220,27 @@
 }
 
 /**
+* set_timing_db() - enable/disable Timing DB register
+* @ctrl:          Pointer to controller host hardware.
+* @enable:        Enable/Disable flag.
+*
+* Enable or Disabe the Timing DB register.
+*/
+void dsi_ctrl_hw_cmn_set_timing_db(struct dsi_ctrl_hw *ctrl,
+				     bool enable)
+{
+	if (enable)
+		DSI_W32(ctrl, DSI_DSI_TIMING_DB_MODE, 0x1);
+	else
+		DSI_W32(ctrl, DSI_DSI_TIMING_DB_MODE, 0x0);
+
+	wmb(); /* make sure timing db registers are set */
+	pr_debug("[DSI_%d] ctrl timing DB set:%d\n", ctrl->index,
+				enable);
+	SDE_EVT32(ctrl->index, enable);
+}
+
+/**
  * set_video_timing() - set up the timing for video frame
  * @ctrl:          Pointer to controller host hardware.
  * @mode:          Video mode information.
@@ -290,6 +313,7 @@
 	DSI_W32(ctrl, DSI_MISR_VIDEO_CTRL, 0x10100);
 	DSI_W32(ctrl, DSI_DSI_TIMING_FLUSH, 0x1);
 	pr_debug("[DSI_%d] ctrl video parameters updated\n", ctrl->index);
+	SDE_EVT32(v_total, h_total);
 }
 
 /**
@@ -354,8 +378,6 @@
 		reg_ctrl |= (reg << offset);
 		reg_ctrl2 &= ~(0xFFFF << offset);
 		reg_ctrl2 |= (dsc.bytes_in_slice << offset);
-		DSI_W32(ctrl, DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl);
-		DSI_W32(ctrl, DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2);
 
 		pr_debug("ctrl %d reg_ctrl 0x%x reg_ctrl2 0x%x\n", ctrl->index,
 				reg_ctrl, reg_ctrl2);
@@ -373,6 +395,9 @@
 	stream_ctrl |= (vc_id & 0x3) << 8;
 	stream_ctrl |= 0x39; /* packet data type */
 
+	DSI_W32(ctrl, DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl);
+	DSI_W32(ctrl, DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2);
+
 	DSI_W32(ctrl, DSI_COMMAND_MODE_MDP_STREAM0_CTRL, stream_ctrl);
 	DSI_W32(ctrl, DSI_COMMAND_MODE_MDP_STREAM1_CTRL, stream_ctrl);
 
@@ -423,6 +448,18 @@
 	pr_debug("[DSI_%d] Video engine setup done\n", ctrl->index);
 }
 
+void dsi_ctrl_hw_cmn_debug_bus(struct dsi_ctrl_hw *ctrl)
+{
+	u32 reg = 0;
+
+	DSI_W32(ctrl, DSI_DEBUG_BUS_CTL, 0x181);
+
+	/* make sure that debug test point is enabled */
+	wmb();
+	reg = DSI_R32(ctrl, DSI_DEBUG_BUS_STATUS);
+
+	pr_err("[DSI_%d] debug bus status:0x%x\n", ctrl->index, reg);
+}
 /**
  * cmd_engine_setup() - setup dsi host controller for command mode
  * @ctrl:          Pointer to the controller host hardware.
@@ -673,6 +710,22 @@
 }
 
 /**
+ * clear_rdbk_reg() - clear previously read panel data.
+ * @ctrl:          Pointer to the controller host hardware.
+ *
+ * This function is called before sending DSI Rx command to
+ * panel in order to clear if any stale data remaining from
+ * previous read operation.
+ */
+void dsi_ctrl_hw_cmn_clear_rdbk_reg(struct dsi_ctrl_hw *ctrl)
+{
+	DSI_W32(ctrl, DSI_RDBK_DATA_CTRL, 0x1);
+	wmb(); /* ensure read back register is reset */
+	DSI_W32(ctrl, DSI_RDBK_DATA_CTRL, 0x0);
+	wmb(); /* ensure read back register is cleared */
+}
+
+/**
  * get_cmd_read_data() - get data read from the peripheral
  * @ctrl:           Pointer to the controller host hardware.
  * @rd_buf:         Buffer where data will be read into.
@@ -683,16 +736,16 @@
 u32 dsi_ctrl_hw_cmn_get_cmd_read_data(struct dsi_ctrl_hw *ctrl,
 				     u8 *rd_buf,
 				     u32 read_offset,
-				     u32 total_read_len)
+				     u32 rx_byte,
+				     u32 pkt_size,
+				     u32 *hw_read_cnt)
 {
 	u32 *lp, *temp, data;
-	int i, j = 0, cnt;
+	int i, j = 0, cnt, off;
 	u32 read_cnt;
-	u32 rx_byte = 0;
 	u32 repeated_bytes = 0;
 	u8 reg[16] = {0};
-	u32 pkt_size = 0;
-	int buf_offset = read_offset;
+	bool ack_err = false;
 
 	lp = (u32 *)rd_buf;
 	temp = (u32 *)reg;
@@ -701,28 +754,49 @@
 	if (cnt > 4)
 		cnt = 4;
 
-	if (rx_byte == 4)
-		read_cnt = 4;
-	else
-		read_cnt = pkt_size + 6;
+	read_cnt = (DSI_R32(ctrl, DSI_RDBK_DATA_CTRL) >> 16);
+	ack_err = (rx_byte == 4) ? (read_cnt == 8) :
+			((read_cnt - 4) == (pkt_size + 6));
+
+	if (ack_err)
+		read_cnt -= 4;
+	if (!read_cnt) {
+		pr_err("Panel detected error, no data read\n");
+		return 0;
+	}
 
 	if (read_cnt > 16) {
-		int bytes_shifted;
+		int bytes_shifted, data_lost = 0, rem_header = 0;
 
-		bytes_shifted = read_cnt - 16;
-		repeated_bytes = buf_offset - bytes_shifted;
+		bytes_shifted = read_cnt - rx_byte;
+		if (bytes_shifted >= 4)
+			data_lost = bytes_shifted - 4; /* remove DCS header */
+		else
+			rem_header = 4 - bytes_shifted; /* remaining header */
+
+		repeated_bytes = (read_offset - 4) - data_lost + rem_header;
 	}
 
-	for (i = cnt - 1; i >= 0; i--) {
-		data = DSI_R32(ctrl, DSI_RDBK_DATA0 + i*4);
-		*temp++ = ntohl(data);
+	off = DSI_RDBK_DATA0;
+	off += ((cnt - 1) * 4);
+
+	for (i = 0; i < cnt; i++) {
+		data = DSI_R32(ctrl, off);
+		if (!repeated_bytes)
+			*lp++ = ntohl(data);
+		else
+			*temp++ = ntohl(data);
+		off -= 4;
 	}
 
-	for (i = repeated_bytes; i < 16; i++)
-		rd_buf[j++] = reg[i];
+	if (repeated_bytes) {
+		for (i = repeated_bytes; i < 16; i++)
+			rd_buf[j++] = reg[i];
+	}
 
-	pr_debug("[DSI_%d] Read %d bytes\n", ctrl->index, j);
-	return j;
+	*hw_read_cnt = read_cnt;
+	pr_debug("[DSI_%d] Read %d bytes\n", ctrl->index, rx_byte);
+	return rx_byte;
 }
 
 /**
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_reg.h b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_reg.h
index f8f7e13..39ac021 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_reg.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_reg.h
@@ -82,6 +82,8 @@
 #define DSI_SOFT_RESET                             (0x0118)
 #define DSI_CLK_CTRL                               (0x011C)
 #define DSI_CLK_STATUS                             (0x0120)
+#define DSI_DEBUG_BUS_CTL                          (0x0124)
+#define DSI_DEBUG_BUS_STATUS                       (0x0128)
 #define DSI_PHY_SW_RESET                           (0x012C)
 #define DSI_AXI2AHB_CTRL                           (0x0130)
 #define DSI_MISR_CMD_MDP0_32BIT                    (0x0134)
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_defs.h b/drivers/gpu/drm/msm/dsi-staging/dsi_defs.h
index fcc59ef..96ed47e 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_defs.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_defs.h
@@ -77,12 +77,15 @@
  * @DSI_MODE_FLAG_DFPS:		Seamless transition is DynamicFPS
  * @DSI_MODE_FLAG_VBLANK_PRE_MODESET:	Transition needs VBLANK before Modeset
  * @DSI_MODE_FLAG_DMS: Seamless transition is dynamic mode switch
+ * @DSI_MODE_FLAG_VRR: Seamless transition is DynamicFPS.
+ *                     New timing values are sent from DAL.
  */
 enum dsi_mode_flags {
 	DSI_MODE_FLAG_SEAMLESS			= BIT(0),
 	DSI_MODE_FLAG_DFPS			= BIT(1),
 	DSI_MODE_FLAG_VBLANK_PRE_MODESET	= BIT(2),
 	DSI_MODE_FLAG_DMS			= BIT(3),
+	DSI_MODE_FLAG_VRR			= BIT(4),
 };
 
 /**
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
index 4e76aa5..d71a5f21 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
@@ -28,6 +28,7 @@
 #include "dsi_drm.h"
 #include "dsi_clk.h"
 #include "dsi_pwr.h"
+#include "sde_dbg.h"
 
 #define to_dsi_display(x) container_of(x, struct dsi_display, host)
 #define INT_BASE_10 10
@@ -84,6 +85,10 @@
 		return -EINVAL;
 
 	panel = dsi_display->panel;
+
+	if (!dsi_panel_initialized(panel))
+		return -EINVAL;
+
 	panel->bl_config.bl_level = bl_lvl;
 
 	/* scale backlight */
@@ -95,10 +100,304 @@
 
 	pr_debug("bl_scale = %u, bl_scale_ad = %u, bl_lvl = %u\n",
 		bl_scale, bl_scale_ad, (u32)bl_temp);
+
+	rc = dsi_display_clk_ctrl(dsi_display->dsi_clk_handle,
+			DSI_CORE_CLK, DSI_CLK_ON);
+	if (rc) {
+		pr_err("[%s] failed to enable DSI core clocks, rc=%d\n",
+		       dsi_display->name, rc);
+		goto error;
+	}
+
 	rc = dsi_panel_set_backlight(panel, (u32)bl_temp);
 	if (rc)
 		pr_err("unable to set backlight\n");
 
+	rc = dsi_display_clk_ctrl(dsi_display->dsi_clk_handle,
+			DSI_CORE_CLK, DSI_CLK_OFF);
+	if (rc) {
+		pr_err("[%s] failed to disable DSI core clocks, rc=%d\n",
+		       dsi_display->name, rc);
+		goto error;
+	}
+
+error:
+	return rc;
+}
+
+static int dsi_display_cmd_engine_enable(struct dsi_display *display)
+{
+	int rc = 0;
+	int i;
+	struct dsi_display_ctrl *m_ctrl, *ctrl;
+
+	if (display->cmd_engine_refcount > 0) {
+		display->cmd_engine_refcount++;
+		return 0;
+	}
+
+	m_ctrl = &display->ctrl[display->cmd_master_idx];
+
+	rc = dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_ON);
+	if (rc) {
+		pr_err("[%s] failed to enable cmd engine, rc=%d\n",
+		       display->name, rc);
+		goto error;
+	}
+
+	for (i = 0; i < display->ctrl_count; i++) {
+		ctrl = &display->ctrl[i];
+		if (!ctrl->ctrl || (ctrl == m_ctrl))
+			continue;
+
+		rc = dsi_ctrl_set_cmd_engine_state(ctrl->ctrl,
+						   DSI_CTRL_ENGINE_ON);
+		if (rc) {
+			pr_err("[%s] failed to enable cmd engine, rc=%d\n",
+			       display->name, rc);
+			goto error_disable_master;
+		}
+	}
+
+	display->cmd_engine_refcount++;
+	return rc;
+error_disable_master:
+	(void)dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_OFF);
+error:
+	return rc;
+}
+
+static int dsi_display_cmd_engine_disable(struct dsi_display *display)
+{
+	int rc = 0;
+	int i;
+	struct dsi_display_ctrl *m_ctrl, *ctrl;
+
+	if (display->cmd_engine_refcount == 0) {
+		pr_err("[%s] Invalid refcount\n", display->name);
+		return 0;
+	} else if (display->cmd_engine_refcount > 1) {
+		display->cmd_engine_refcount--;
+		return 0;
+	}
+
+	m_ctrl = &display->ctrl[display->cmd_master_idx];
+	for (i = 0; i < display->ctrl_count; i++) {
+		ctrl = &display->ctrl[i];
+		if (!ctrl->ctrl || (ctrl == m_ctrl))
+			continue;
+
+		rc = dsi_ctrl_set_cmd_engine_state(ctrl->ctrl,
+						   DSI_CTRL_ENGINE_OFF);
+		if (rc)
+			pr_err("[%s] failed to enable cmd engine, rc=%d\n",
+			       display->name, rc);
+	}
+
+	rc = dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_OFF);
+	if (rc) {
+		pr_err("[%s] failed to enable cmd engine, rc=%d\n",
+		       display->name, rc);
+		goto error;
+	}
+
+error:
+	display->cmd_engine_refcount = 0;
+	return rc;
+}
+
+static bool dsi_display_validate_reg_read(struct dsi_panel *panel)
+{
+	int i, j = 0;
+	int len = 0, *lenp;
+	int group = 0, count = 0;
+	struct dsi_display_mode *mode;
+	struct drm_panel_esd_config *config;
+
+	if (!panel)
+		return false;
+
+	config = &(panel->esd_config);
+
+	lenp = config->status_valid_params ?: config->status_cmds_rlen;
+	mode = panel->cur_mode;
+	count = mode->priv_info->cmd_sets[DSI_CMD_SET_PANEL_STATUS].count;
+
+	for (i = 0; i < count; i++)
+		len += lenp[i];
+
+	for (i = 0; i < len; i++)
+		j += len;
+
+	for (j = 0; j < config->groups; ++j) {
+		for (i = 0; i < len; ++i) {
+			if (config->return_buf[i] !=
+				config->status_value[group + i])
+				break;
+		}
+
+		if (i == len)
+			return true;
+		group += len;
+	}
+
+	return false;
+}
+
+static int dsi_display_read_status(struct dsi_display_ctrl *ctrl,
+		struct dsi_panel *panel)
+{
+	int i, rc = 0, count = 0, start = 0, *lenp;
+	struct drm_panel_esd_config *config;
+	struct dsi_cmd_desc *cmds;
+	u32 flags = 0;
+
+	if (!panel)
+		return -EINVAL;
+
+	config = &(panel->esd_config);
+	lenp = config->status_valid_params ?: config->status_cmds_rlen;
+	count = config->status_cmd.count;
+	cmds = config->status_cmd.cmds;
+	flags = (DSI_CTRL_CMD_FETCH_MEMORY | DSI_CTRL_CMD_READ);
+
+	for (i = 0; i < count; ++i) {
+		memset(config->status_buf, 0x0, SZ_4K);
+		cmds[i].msg.rx_buf = config->status_buf;
+		cmds[i].msg.rx_len = config->status_cmds_rlen[i];
+		rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, &cmds[i].msg, flags);
+		if (rc <= 0) {
+			pr_err("rx cmd transfer failed rc=%d\n", rc);
+			goto error;
+		}
+
+		memcpy(config->return_buf + start,
+			config->status_buf, lenp[i]);
+		start += lenp[i];
+	}
+
+error:
+	return rc;
+}
+
+static int dsi_display_validate_status(struct dsi_display_ctrl *ctrl,
+		struct dsi_panel *panel)
+{
+	int rc = 0;
+
+	rc = dsi_display_read_status(ctrl, panel);
+	if (rc <= 0) {
+		goto exit;
+	} else {
+		/*
+		 * panel status read successfully.
+		 * check for validity of the data read back.
+		 */
+		rc = dsi_display_validate_reg_read(panel);
+		if (!rc) {
+			rc = -EINVAL;
+			goto exit;
+		}
+	}
+
+exit:
+	return rc;
+}
+
+static int dsi_display_status_reg_read(struct dsi_display *display)
+{
+	int rc = 0, i;
+	struct dsi_display_ctrl *m_ctrl, *ctrl;
+
+	pr_debug(" ++\n");
+
+	m_ctrl = &display->ctrl[display->cmd_master_idx];
+
+	rc = dsi_display_cmd_engine_enable(display);
+	if (rc) {
+		pr_err("cmd engine enable failed\n");
+		return -EPERM;
+	}
+
+	rc = dsi_display_validate_status(m_ctrl, display->panel);
+	if (rc <= 0) {
+		pr_err("[%s] read status failed on master,rc=%d\n",
+		       display->name, rc);
+		goto exit;
+	}
+
+	if (!display->panel->sync_broadcast_en)
+		goto exit;
+
+	for (i = 0; i < display->ctrl_count; i++) {
+		ctrl = &display->ctrl[i];
+		if (ctrl == m_ctrl)
+			continue;
+
+		rc = dsi_display_validate_status(ctrl, display->panel);
+		if (rc <= 0) {
+			pr_err("[%s] read status failed on master,rc=%d\n",
+			       display->name, rc);
+			goto exit;
+		}
+	}
+
+exit:
+	dsi_display_cmd_engine_disable(display);
+	return rc;
+}
+
+static int dsi_display_status_bta_request(struct dsi_display *display)
+{
+	int rc = 0;
+
+	pr_debug(" ++\n");
+	/* TODO: trigger SW BTA and wait for acknowledgment */
+
+	return rc;
+}
+
+static int dsi_display_status_check_te(struct dsi_display *display)
+{
+	int rc = 0;
+
+	pr_debug(" ++\n");
+	/* TODO: wait for TE interrupt from panel */
+
+	return rc;
+}
+
+int dsi_display_check_status(void *display)
+{
+	struct dsi_display *dsi_display = display;
+	struct dsi_panel *panel;
+	u32 status_mode;
+	int rc = 0;
+
+	if (dsi_display == NULL)
+		return -EINVAL;
+
+	panel = dsi_display->panel;
+
+	status_mode = panel->esd_config.status_mode;
+
+	dsi_display_clk_ctrl(dsi_display->dsi_clk_handle,
+		DSI_ALL_CLKS, DSI_CLK_ON);
+
+	if (status_mode == ESD_MODE_REG_READ) {
+		rc = dsi_display_status_reg_read(dsi_display);
+	} else if (status_mode == ESD_MODE_SW_BTA) {
+		rc = dsi_display_status_bta_request(dsi_display);
+	} else if (status_mode == ESD_MODE_PANEL_TE) {
+		rc = dsi_display_status_check_te(dsi_display);
+	} else {
+		pr_warn("unsupported check status mode\n");
+		panel->esd_config.esd_enabled = false;
+	}
+
+	dsi_display_clk_ctrl(dsi_display->dsi_clk_handle,
+		DSI_ALL_CLKS, DSI_CLK_OFF);
+
 	return rc;
 }
 
@@ -1188,87 +1487,6 @@
 	return rc;
 }
 
-static int dsi_display_cmd_engine_enable(struct dsi_display *display)
-{
-	int rc = 0;
-	int i;
-	struct dsi_display_ctrl *m_ctrl, *ctrl;
-
-	if (display->cmd_engine_refcount > 0) {
-		display->cmd_engine_refcount++;
-		return 0;
-	}
-
-	m_ctrl = &display->ctrl[display->cmd_master_idx];
-
-	rc = dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_ON);
-	if (rc) {
-		pr_err("[%s] failed to enable cmd engine, rc=%d\n",
-		       display->name, rc);
-		goto error;
-	}
-
-	for (i = 0; i < display->ctrl_count; i++) {
-		ctrl = &display->ctrl[i];
-		if (!ctrl->ctrl || (ctrl == m_ctrl))
-			continue;
-
-		rc = dsi_ctrl_set_cmd_engine_state(ctrl->ctrl,
-						   DSI_CTRL_ENGINE_ON);
-		if (rc) {
-			pr_err("[%s] failed to enable cmd engine, rc=%d\n",
-			       display->name, rc);
-			goto error_disable_master;
-		}
-	}
-
-	display->cmd_engine_refcount++;
-	return rc;
-error_disable_master:
-	(void)dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_OFF);
-error:
-	return rc;
-}
-
-static int dsi_display_cmd_engine_disable(struct dsi_display *display)
-{
-	int rc = 0;
-	int i;
-	struct dsi_display_ctrl *m_ctrl, *ctrl;
-
-	if (display->cmd_engine_refcount == 0) {
-		pr_err("[%s] Invalid refcount\n", display->name);
-		return 0;
-	} else if (display->cmd_engine_refcount > 1) {
-		display->cmd_engine_refcount--;
-		return 0;
-	}
-
-	m_ctrl = &display->ctrl[display->cmd_master_idx];
-	for (i = 0; i < display->ctrl_count; i++) {
-		ctrl = &display->ctrl[i];
-		if (!ctrl->ctrl || (ctrl == m_ctrl))
-			continue;
-
-		rc = dsi_ctrl_set_cmd_engine_state(ctrl->ctrl,
-						   DSI_CTRL_ENGINE_OFF);
-		if (rc)
-			pr_err("[%s] failed to enable cmd engine, rc=%d\n",
-			       display->name, rc);
-	}
-
-	rc = dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_OFF);
-	if (rc) {
-		pr_err("[%s] failed to enable cmd engine, rc=%d\n",
-		       display->name, rc);
-		goto error;
-	}
-
-error:
-	display->cmd_engine_refcount = 0;
-	return rc;
-}
-
 static int dsi_display_ctrl_host_enable(struct dsi_display *display)
 {
 	int rc = 0;
@@ -1690,7 +1908,9 @@
 put_iova:
 	msm_gem_put_iova(display->tx_cmd_buf, aspace);
 free_gem:
+	mutex_lock(&display->drm_dev->struct_mutex);
 	msm_gem_free_object(display->tx_cmd_buf);
+	mutex_unlock(&display->drm_dev->struct_mutex);
 error:
 	return rc;
 }
@@ -2533,7 +2753,7 @@
 }
 
 static int dsi_display_dfps_calc_front_porch(
-		u64 clk_hz,
+		u32 old_fps,
 		u32 new_fps,
 		u32 a_total,
 		u32 b_total,
@@ -2541,6 +2761,7 @@
 		u32 *b_fp_out)
 {
 	s32 b_fp_new;
+	int add_porches, diff;
 
 	if (!b_fp_out) {
 		pr_err("Invalid params");
@@ -2552,15 +2773,22 @@
 		return -EINVAL;
 	}
 
-	/**
+	/*
 	 * Keep clock, other porches constant, use new fps, calc front porch
-	 * clk = (hor * ver * fps)
-	 * hfront = clk / (vtotal * fps)) - hactive - hback - hsync
+	 * new_vtotal = old_vtotal * (old_fps / new_fps )
+	 * new_vfp - old_vfp = new_vtotal - old_vtotal
+	 * new_vfp = old_vfp + old_vtotal * ((old_fps - new_fps)/ new_fps)
 	 */
-	b_fp_new = (clk_hz / (a_total * new_fps)) - (b_total - b_fp);
+	diff = abs(old_fps - new_fps);
+	add_porches = mult_frac(b_total, diff, new_fps);
 
-	pr_debug("clk %llu fps %u a %u b %u b_fp %u new_fp %d\n",
-			clk_hz, new_fps, a_total, b_total, b_fp, b_fp_new);
+	if (old_fps > new_fps)
+		b_fp_new = b_fp + add_porches;
+	else
+		b_fp_new = b_fp - add_porches;
+
+	pr_debug("fps %u a %u b %u b_fp %u new_fp %d\n",
+			new_fps, a_total, b_total, b_fp, b_fp_new);
 
 	if (b_fp_new < 0) {
 		pr_err("Invalid new_hfp calcluated%d\n", b_fp_new);
@@ -2576,14 +2804,25 @@
 	return 0;
 }
 
+/**
+ * dsi_display_get_dfps_timing() - Get the new dfps values.
+ * @display:         DSI display handle.
+ * @adj_mode:        Mode value structure to be changed.
+ *                   It contains old timing values and latest fps value.
+ *                   New timing values are updated based on new fps.
+ * @curr_refresh_rate:  Current fps rate.
+ *                      If zero , current fps rate is taken from
+ *                      display->panel->cur_mode.
+ * Return: error code.
+ */
 static int dsi_display_get_dfps_timing(struct dsi_display *display,
-				       struct dsi_display_mode *adj_mode)
+			struct dsi_display_mode *adj_mode,
+				u32 curr_refresh_rate)
 {
 	struct dsi_dfps_capabilities dfps_caps;
 	struct dsi_display_mode per_ctrl_mode;
 	struct dsi_mode_info *timing;
 	struct dsi_ctrl *m_ctrl;
-	u64 clk_hz;
 
 	int rc = 0;
 
@@ -2602,20 +2841,27 @@
 	per_ctrl_mode = *adj_mode;
 	adjust_timing_by_ctrl_count(display, &per_ctrl_mode);
 
-	if (!dsi_display_is_seamless_dfps_possible(display,
-			&per_ctrl_mode, dfps_caps.type)) {
-		pr_err("seamless dynamic fps not supported for mode\n");
-		return -EINVAL;
+	if (!curr_refresh_rate) {
+		if (!dsi_display_is_seamless_dfps_possible(display,
+				&per_ctrl_mode, dfps_caps.type)) {
+			pr_err("seamless dynamic fps not supported for mode\n");
+			return -EINVAL;
+		}
+		if (display->panel->cur_mode) {
+			curr_refresh_rate =
+				display->panel->cur_mode->timing.refresh_rate;
+		} else {
+			pr_err("cur_mode is not initialized\n");
+			return -EINVAL;
+		}
 	}
-
 	/* TODO: Remove this direct reference to the dsi_ctrl */
-	clk_hz = m_ctrl->clk_freq.pix_clk_rate;
 	timing = &per_ctrl_mode.timing;
 
 	switch (dfps_caps.type) {
 	case DSI_DFPS_IMMEDIATE_VFP:
 		rc = dsi_display_dfps_calc_front_porch(
-				clk_hz,
+				curr_refresh_rate,
 				timing->refresh_rate,
 				DSI_H_TOTAL(timing),
 				DSI_V_TOTAL(timing),
@@ -2625,7 +2871,7 @@
 
 	case DSI_DFPS_IMMEDIATE_HFP:
 		rc = dsi_display_dfps_calc_front_porch(
-				clk_hz,
+				curr_refresh_rate,
 				timing->refresh_rate,
 				DSI_V_TOTAL(timing),
 				DSI_H_TOTAL(timing),
@@ -2654,7 +2900,7 @@
 	}
 
 	/* Currently the only seamless transition is dynamic fps */
-	rc = dsi_display_get_dfps_timing(display, adj_mode);
+	rc = dsi_display_get_dfps_timing(display, adj_mode, 0);
 	if (rc) {
 		pr_debug("Dynamic FPS not supported for seamless\n");
 	} else {
@@ -2694,7 +2940,8 @@
 	memcpy(&display->config.lane_map, &display->lane_map,
 	       sizeof(display->lane_map));
 
-	if (mode->dsi_mode_flags & DSI_MODE_FLAG_DFPS) {
+	if (mode->dsi_mode_flags &
+			(DSI_MODE_FLAG_DFPS | DSI_MODE_FLAG_VRR)) {
 		rc = dsi_display_dfps_update(display, mode);
 		if (rc) {
 			pr_err("[%s]DSI dfps update failed, rc=%d\n",
@@ -3366,6 +3613,9 @@
 		break;
 	}
 
+	if (display->panel->esd_config.esd_enabled)
+		info->capabilities |= MSM_DISPLAY_ESD_ENABLED;
+
 	memcpy(&info->roi_caps, &display->panel->roi_caps,
 			sizeof(info->roi_caps));
 
@@ -3472,6 +3722,7 @@
 
 		for (i = 0; i < num_dfps_rates; i++) {
 			struct dsi_display_mode *sub_mode = &modes[array_idx];
+			u32 curr_refresh_rate;
 
 			if (!sub_mode) {
 				pr_err("invalid mode data\n");
@@ -3481,9 +3732,15 @@
 			memcpy(sub_mode, &panel_mode, sizeof(panel_mode));
 
 			if (dfps_caps.dfps_support) {
+				curr_refresh_rate =
+					sub_mode->timing.refresh_rate;
 				sub_mode->timing.refresh_rate =
 					dfps_caps.min_refresh_rate +
 					(i % num_dfps_rates);
+
+				dsi_display_get_dfps_timing(display,
+					sub_mode, curr_refresh_rate);
+
 				sub_mode->pixel_clk_khz =
 					(DSI_H_TOTAL(&sub_mode->timing) *
 					DSI_V_TOTAL(&sub_mode->timing) *
@@ -3498,6 +3755,102 @@
 	return rc;
 }
 
+/**
+ * dsi_display_validate_mode_vrr() - Validate if varaible refresh case.
+ * @display:     DSI display handle.
+ * @cur_dsi_mode:   Current DSI mode.
+ * @mode:        Mode value structure to be validated.
+ *               MSM_MODE_FLAG_SEAMLESS_VRR flag is set if there
+ *               is change in fps but vactive and hactive are same.
+ * Return: error code.
+ */
+int dsi_display_validate_mode_vrr(struct dsi_display *display,
+			struct dsi_display_mode *cur_dsi_mode,
+			struct dsi_display_mode *mode)
+{
+	int rc = 0;
+	struct dsi_display_mode adj_mode, cur_mode;
+	struct dsi_dfps_capabilities dfps_caps;
+	u32 curr_refresh_rate;
+
+	if (!display || !mode) {
+		pr_err("Invalid params\n");
+		return -EINVAL;
+	}
+
+	if (!display->panel || !display->panel->cur_mode) {
+		pr_debug("Current panel mode not set\n");
+		return rc;
+	}
+
+	mutex_lock(&display->display_lock);
+
+	adj_mode = *mode;
+	cur_mode = *cur_dsi_mode;
+
+	if ((cur_mode.timing.refresh_rate != adj_mode.timing.refresh_rate) &&
+		(cur_mode.timing.v_active == adj_mode.timing.v_active) &&
+		(cur_mode.timing.h_active == adj_mode.timing.h_active)) {
+
+		curr_refresh_rate = cur_mode.timing.refresh_rate;
+		rc = dsi_panel_get_dfps_caps(display->panel, &dfps_caps);
+		if (rc) {
+			pr_err("[%s] failed to get dfps caps from panel\n",
+					display->name);
+			goto error;
+		}
+
+		cur_mode.timing.refresh_rate =
+			adj_mode.timing.refresh_rate;
+
+		rc = dsi_display_get_dfps_timing(display,
+			&cur_mode, curr_refresh_rate);
+		if (rc) {
+			pr_err("[%s] seamless vrr not possible rc=%d\n",
+			display->name, rc);
+			goto error;
+		}
+		switch (dfps_caps.type) {
+		/*
+		 * Ignore any round off factors in porch calculation.
+		 * Worse case is set to 5.
+		 */
+		case DSI_DFPS_IMMEDIATE_VFP:
+			if (abs(DSI_V_TOTAL(&cur_mode.timing) -
+				DSI_V_TOTAL(&adj_mode.timing)) > 5)
+				pr_err("Mismatch vfp fps:%d new:%d given:%d\n",
+				adj_mode.timing.refresh_rate,
+				cur_mode.timing.v_front_porch,
+				adj_mode.timing.v_front_porch);
+			break;
+
+		case DSI_DFPS_IMMEDIATE_HFP:
+			if (abs(DSI_H_TOTAL(&cur_mode.timing) -
+				DSI_H_TOTAL(&adj_mode.timing)) > 5)
+				pr_err("Mismatch hfp fps:%d new:%d given:%d\n",
+				adj_mode.timing.refresh_rate,
+				cur_mode.timing.h_front_porch,
+				adj_mode.timing.h_front_porch);
+			break;
+
+		default:
+			pr_err("Unsupported DFPS mode %d\n",
+				dfps_caps.type);
+			rc = -ENOTSUPP;
+		}
+
+		pr_debug("Mode switch is seamless variable refresh\n");
+		mode->dsi_mode_flags |= DSI_MODE_FLAG_VRR;
+		SDE_EVT32(curr_refresh_rate, adj_mode.timing.refresh_rate,
+				cur_mode.timing.h_front_porch,
+				adj_mode.timing.h_front_porch);
+	}
+
+error:
+	mutex_unlock(&display->display_lock);
+	return rc;
+}
+
 int dsi_display_validate_mode(struct dsi_display *display,
 			      struct dsi_display_mode *mode,
 			      u32 flags)
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
index 1c30b9c..da4f5eb 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
@@ -324,6 +324,17 @@
 			      u32 flags);
 
 /**
+ * dsi_display_validate_mode_vrr() - validates mode if variable refresh case
+ * @display:             Handle to display.
+ * @mode:                Mode to be validated..
+ *
+ * Return: 0 if  error code.
+ */
+int dsi_display_validate_mode_vrr(struct dsi_display *display,
+			struct dsi_display_mode *cur_dsi_mode,
+			struct dsi_display_mode *mode);
+
+/**
  * dsi_display_set_mode() - Set mode on the display.
  * @display:           Handle to display.
  * @mode:              mode to be set.
@@ -478,6 +489,12 @@
 int dsi_display_set_backlight(void *display, u32 bl_lvl);
 
 /**
+ * dsi_display_check_status() - check if panel is dead or alive
+ * @display:            Handle to display.
+ */
+int dsi_display_check_status(void *display);
+
+/**
  * dsi_display_soft_reset() - perform a soft reset on DSI controller
  * @display:         Handle to display
  *
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c
index 30e5f02..af721eb 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c
@@ -61,6 +61,8 @@
 		dsi_mode->dsi_mode_flags |= DSI_MODE_FLAG_VBLANK_PRE_MODESET;
 	if (msm_is_mode_seamless_dms(drm_mode))
 		dsi_mode->dsi_mode_flags |= DSI_MODE_FLAG_DMS;
+	if (msm_is_mode_seamless_vrr(drm_mode))
+		dsi_mode->dsi_mode_flags |= DSI_MODE_FLAG_VRR;
 }
 
 static void convert_to_drm_mode(const struct dsi_display_mode *dsi_mode,
@@ -96,6 +98,8 @@
 		drm_mode->private_flags |= MSM_MODE_FLAG_VBLANK_PRE_MODESET;
 	if (dsi_mode->dsi_mode_flags & DSI_MODE_FLAG_DMS)
 		drm_mode->private_flags |= MSM_MODE_FLAG_SEAMLESS_DMS;
+	if (dsi_mode->dsi_mode_flags & DSI_MODE_FLAG_VRR)
+		drm_mode->private_flags |= MSM_MODE_FLAG_SEAMLESS_VRR;
 
 	drm_mode_set_name(drm_mode);
 }
@@ -134,7 +138,8 @@
 		return;
 	}
 
-	if (c_bridge->dsi_mode.dsi_mode_flags & DSI_MODE_FLAG_SEAMLESS) {
+	if (c_bridge->dsi_mode.dsi_mode_flags &
+		(DSI_MODE_FLAG_SEAMLESS | DSI_MODE_FLAG_VRR)) {
 		pr_debug("[%d] seamless pre-enable\n", c_bridge->id);
 		return;
 	}
@@ -169,7 +174,8 @@
 		return;
 	}
 
-	if (c_bridge->dsi_mode.dsi_mode_flags & DSI_MODE_FLAG_SEAMLESS) {
+	if (c_bridge->dsi_mode.dsi_mode_flags &
+			(DSI_MODE_FLAG_SEAMLESS | DSI_MODE_FLAG_VRR)) {
 		pr_debug("[%d] seamless enable\n", c_bridge->id);
 		return;
 	}
@@ -249,7 +255,7 @@
 {
 	int rc = 0;
 	struct dsi_bridge *c_bridge = to_dsi_bridge(bridge);
-	struct dsi_display_mode dsi_mode;
+	struct dsi_display_mode dsi_mode, cur_dsi_mode;
 	struct drm_display_mode cur_mode;
 
 	if (!bridge || !mode || !adjusted_mode) {
@@ -267,9 +273,20 @@
 	}
 
 	if (bridge->encoder && bridge->encoder->crtc) {
+
+		convert_to_dsi_mode(&bridge->encoder->crtc->mode,
+							&cur_dsi_mode);
+		rc = dsi_display_validate_mode_vrr(c_bridge->display,
+					&cur_dsi_mode, &dsi_mode);
+		if (rc)
+			pr_debug("[%s] vrr mode mismatch failure rc=%d\n",
+				c_bridge->display->name, rc);
+
 		cur_mode = bridge->encoder->crtc->mode;
 
-		if (!drm_mode_equal(&cur_mode, adjusted_mode))
+		if (!drm_mode_equal(&cur_mode, adjusted_mode) &&
+			(!(dsi_mode.dsi_mode_flags &
+				DSI_MODE_FLAG_VRR)))
 			dsi_mode.dsi_mode_flags |= DSI_MODE_FLAG_DMS;
 	}
 
@@ -383,6 +400,13 @@
 	sde_kms_info_add_keystr(info, "dfps support",
 			panel->dfps_caps.dfps_support ? "true" : "false");
 
+	if (panel->dfps_caps.dfps_support) {
+		sde_kms_info_add_keyint(info, "min_fps",
+			panel->dfps_caps.min_refresh_rate);
+		sde_kms_info_add_keyint(info, "max_fps",
+			panel->dfps_caps.max_refresh_rate);
+	}
+
 	switch (panel->phy_props.rotation) {
 	case DSI_PANEL_ROTATE_NONE:
 		sde_kms_info_add_keystr(info, "panel orientation", "none");
@@ -598,6 +622,52 @@
 	dsi_display_enable_event(display, event_idx, &event_info, enable);
 }
 
+int dsi_conn_post_kickoff(struct drm_connector *connector)
+{
+	struct drm_encoder *encoder;
+	struct dsi_bridge *c_bridge;
+	struct dsi_display_mode adj_mode;
+	struct dsi_display *display;
+	struct dsi_display_ctrl *m_ctrl, *ctrl;
+	int i, rc = 0;
+
+	if (!connector || !connector->state->best_encoder)
+		return -EINVAL;
+
+	encoder = connector->state->best_encoder;
+	c_bridge = to_dsi_bridge(encoder->bridge);
+	adj_mode = c_bridge->dsi_mode;
+	display = c_bridge->display;
+
+	if (adj_mode.dsi_mode_flags & DSI_MODE_FLAG_VRR) {
+		m_ctrl = &display->ctrl[display->clk_master_idx];
+		rc = dsi_ctrl_timing_db_update(m_ctrl->ctrl, false);
+		if (rc) {
+			pr_err("[%s] failed to dfps update  rc=%d\n",
+				display->name, rc);
+			return -EINVAL;
+		}
+
+		/* Update the rest of the controllers */
+		for (i = 0; i < display->ctrl_count; i++) {
+			ctrl = &display->ctrl[i];
+			if (!ctrl->ctrl || (ctrl == m_ctrl))
+				continue;
+
+			rc = dsi_ctrl_timing_db_update(ctrl->ctrl, false);
+			if (rc) {
+				pr_err("[%s] failed to dfps update rc=%d\n",
+					display->name,  rc);
+				return -EINVAL;
+			}
+		}
+
+		c_bridge->dsi_mode.dsi_mode_flags &= ~DSI_MODE_FLAG_VRR;
+	}
+
+	return 0;
+}
+
 struct dsi_bridge *dsi_drm_bridge_init(struct dsi_display *display,
 				       struct drm_device *dev,
 				       struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.h b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.h
index 793f8f1..9700e68 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.h
@@ -119,4 +119,11 @@
 		void *display,
 		struct msm_display_kickoff_params *params);
 
+/**
+ * dsi_display_post_kickoff - program post kickoff-time features
+ * @connector: Pointer to drm connector structure
+ * Returns: Zero on success
+ */
+int dsi_conn_post_kickoff(struct drm_connector *connector);
+
 #endif /* _DSI_DRM_H_ */
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
index 3a8df99..6718156 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
@@ -1650,6 +1650,9 @@
 
 	panel->te_using_watchdog_timer = of_property_read_bool(of_node,
 					"qcom,mdss-dsi-te-using-wd");
+
+	panel->sync_broadcast_en = of_property_read_bool(of_node,
+			"qcom,cmd-sync-wait-broadcast");
 	return 0;
 }
 
@@ -2438,6 +2441,216 @@
 	return 0;
 };
 
+/*
+ * The length of all the valid values to be checked should not be greater
+ * than the length of returned data from read command.
+ */
+static bool
+dsi_panel_parse_esd_check_valid_params(struct dsi_panel *panel, u32 count)
+{
+	int i;
+	struct drm_panel_esd_config *config = &panel->esd_config;
+
+	for (i = 0; i < count; ++i) {
+		if (config->status_valid_params[i] >
+				config->status_cmds_rlen[i]) {
+			pr_debug("ignore valid params\n");
+			return false;
+		}
+	}
+
+	return true;
+}
+
+static bool dsi_panel_parse_esd_status_len(struct device_node *np,
+	char *prop_key, u32 **target, u32 cmd_cnt)
+{
+	int tmp;
+
+	if (!of_find_property(np, prop_key, &tmp))
+		return false;
+
+	tmp /= sizeof(u32);
+	if (tmp != cmd_cnt) {
+		pr_err("request property(%d) do not match cmd count(%d)\n",
+				tmp, cmd_cnt);
+		return false;
+	}
+
+	*target = kcalloc(tmp, sizeof(u32), GFP_KERNEL);
+	if (IS_ERR_OR_NULL(*target)) {
+		pr_err("Error allocating memory for property\n");
+		return false;
+	}
+
+	if (of_property_read_u32_array(np, prop_key, *target, tmp)) {
+		pr_err("cannot get values from dts\n");
+		kfree(*target);
+		*target = NULL;
+		return false;
+	}
+
+	return true;
+}
+
+static void dsi_panel_esd_config_deinit(struct drm_panel_esd_config *esd_config)
+{
+	kfree(esd_config->status_buf);
+	kfree(esd_config->return_buf);
+	kfree(esd_config->status_value);
+	kfree(esd_config->status_valid_params);
+	kfree(esd_config->status_cmds_rlen);
+	kfree(esd_config->status_cmd.cmds);
+}
+
+static int dsi_panel_parse_esd_config(struct dsi_panel *panel,
+				     struct device_node *of_node)
+{
+	int rc = 0;
+	u32 tmp;
+	u32 i, status_len, *lenp;
+	struct property *data;
+	const char *string;
+	struct drm_panel_esd_config *esd_config;
+
+	esd_config = &panel->esd_config;
+	esd_config->esd_enabled = of_property_read_bool(of_node,
+		"qcom,esd-check-enabled");
+
+	if (!esd_config->esd_enabled)
+		return 0;
+
+	rc = of_property_read_string(of_node,
+			"qcom,mdss-dsi-panel-status-check-mode", &string);
+	if (!rc) {
+		if (!strcmp(string, "bta_check")) {
+			esd_config->status_mode = ESD_MODE_SW_BTA;
+		} else if (!strcmp(string, "reg_read")) {
+			esd_config->status_mode = ESD_MODE_REG_READ;
+		} else if (!strcmp(string, "te_signal_check")) {
+			if (panel->panel_mode == DSI_OP_CMD_MODE) {
+				esd_config->status_mode = ESD_MODE_PANEL_TE;
+			} else {
+				pr_err("TE-ESD not valid for video mode\n");
+				rc = -EINVAL;
+				goto error;
+			}
+		} else {
+			pr_err("No valid panel-status-check-mode string\n");
+			rc = -EINVAL;
+			goto error;
+		}
+	} else {
+		pr_debug("status check method not defined!\n");
+		rc = -EINVAL;
+		goto error;
+	}
+
+	if ((esd_config->status_mode == ESD_MODE_SW_BTA) ||
+		(esd_config->status_mode == ESD_MODE_PANEL_TE))
+		return 0;
+
+	dsi_panel_parse_cmd_sets_sub(&esd_config->status_cmd,
+				DSI_CMD_SET_PANEL_STATUS, of_node);
+	if (!esd_config->status_cmd.count) {
+		pr_err("panel status command parsing failed\n");
+		rc = -EINVAL;
+		goto error;
+	}
+
+	if (!dsi_panel_parse_esd_status_len(of_node,
+		"qcom,mdss-dsi-panel-status-read-length",
+			&panel->esd_config.status_cmds_rlen,
+				esd_config->status_cmd.count)) {
+		pr_err("Invalid status read length\n");
+		rc = -EINVAL;
+		goto error1;
+	}
+
+	if (dsi_panel_parse_esd_status_len(of_node,
+		"qcom,mdss-dsi-panel-status-valid-params",
+			&panel->esd_config.status_valid_params,
+				esd_config->status_cmd.count)) {
+		if (!dsi_panel_parse_esd_check_valid_params(panel,
+					esd_config->status_cmd.count)) {
+			rc = -EINVAL;
+			goto error2;
+		}
+	}
+
+	status_len = 0;
+	lenp = esd_config->status_valid_params ?: esd_config->status_cmds_rlen;
+	for (i = 0; i < esd_config->status_cmd.count; ++i)
+		status_len += lenp[i];
+
+	if (!status_len) {
+		rc = -EINVAL;
+		goto error2;
+	}
+
+	/*
+	 * Some panel may need multiple read commands to properly
+	 * check panel status. Do a sanity check for proper status
+	 * value which will be compared with the value read by dsi
+	 * controller during ESD check. Also check if multiple read
+	 * commands are there then, there should be corresponding
+	 * status check values for each read command.
+	 */
+	data = of_find_property(of_node,
+			"qcom,mdss-dsi-panel-status-value", &tmp);
+	tmp /= sizeof(u32);
+	if (!IS_ERR_OR_NULL(data) && tmp != 0 && (tmp % status_len) == 0) {
+		esd_config->groups = tmp / status_len;
+	} else {
+		pr_err("error parse panel-status-value\n");
+		rc = -EINVAL;
+		goto error2;
+	}
+
+	esd_config->status_value =
+		kzalloc(sizeof(u32) * status_len * esd_config->groups,
+			GFP_KERNEL);
+	if (!esd_config->status_value) {
+		rc = -ENOMEM;
+		goto error2;
+	}
+
+	esd_config->return_buf = kcalloc(status_len * esd_config->groups,
+			sizeof(unsigned char), GFP_KERNEL);
+	if (!esd_config->return_buf) {
+		rc = -ENOMEM;
+		goto error3;
+	}
+
+	esd_config->status_buf = kzalloc(SZ_4K, GFP_KERNEL);
+	if (!esd_config->status_buf)
+		goto error4;
+
+	rc = of_property_read_u32_array(of_node,
+		"qcom,mdss-dsi-panel-status-value",
+		esd_config->status_value, esd_config->groups * status_len);
+	if (rc) {
+		pr_debug("error reading panel status values\n");
+		memset(esd_config->status_value, 0,
+				esd_config->groups * status_len);
+	}
+
+	return 0;
+
+error4:
+	kfree(esd_config->return_buf);
+error3:
+	kfree(esd_config->status_value);
+error2:
+	kfree(esd_config->status_valid_params);
+	kfree(esd_config->status_cmds_rlen);
+error1:
+	kfree(esd_config->status_cmd.cmds);
+error:
+	panel->esd_config.esd_enabled = false;
+	return rc;
+}
+
 struct dsi_panel *dsi_panel_get(struct device *parent,
 				struct device_node *of_node,
 				int topology_override)
@@ -2511,6 +2724,22 @@
 	if (rc)
 		pr_debug("failed to get dms info, rc=%d\n", rc);
 
+	rc = dsi_panel_parse_esd_config(panel, of_node);
+	if (rc) {
+		pr_debug("failed to parse esd config, rc=%d\n", rc);
+	} else {
+		u8 *esd_mode = NULL;
+
+		if (panel->esd_config.status_mode == ESD_MODE_REG_READ)
+			esd_mode = "register_read";
+		else if (panel->esd_config.status_mode == ESD_MODE_SW_BTA)
+			esd_mode = "bta_trigger";
+		else if (panel->esd_config.status_mode ==  ESD_MODE_PANEL_TE)
+			esd_mode = "te_check";
+
+		pr_info("ESD enabled with mode: %s\n", esd_mode);
+	}
+
 	panel->panel_of_node = of_node;
 	drm_panel_init(&panel->drm_panel);
 	mutex_init(&panel->panel_lock);
@@ -2523,6 +2752,9 @@
 
 void dsi_panel_put(struct dsi_panel *panel)
 {
+	/* free resources allocated for ESD check */
+	dsi_panel_esd_config_deinit(&panel->esd_config);
+
 	kfree(panel);
 }
 
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
index a8864ee..f63fd27 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
@@ -120,6 +120,26 @@
 	u32 mode_sel_state;
 };
 
+enum esd_check_status_mode {
+	ESD_MODE_REG_READ,
+	ESD_MODE_SW_BTA,
+	ESD_MODE_PANEL_TE,
+	ESD_MODE_MAX
+};
+
+struct drm_panel_esd_config {
+	bool esd_enabled;
+
+	enum esd_check_status_mode status_mode;
+	struct dsi_panel_cmd_set status_cmd;
+	u32 *status_cmds_rlen;
+	u32 *status_valid_params;
+	u32 *status_value;
+	u8 *return_buf;
+	u8 *status_buf;
+	u32 groups;
+};
+
 struct dsi_panel {
 	const char *name;
 	struct device_node *panel_of_node;
@@ -148,6 +168,7 @@
 	struct dsi_panel_reset_config reset_config;
 	struct dsi_pinctrl_info pinctrl;
 	struct drm_panel_hdr_properties hdr_props;
+	struct drm_panel_esd_config esd_config;
 
 	bool lp11_init;
 	bool ulps_enabled;
@@ -158,6 +179,8 @@
 
 	char dsc_pps_cmd[DSI_CMD_PPS_SIZE];
 	enum dsi_dms_mode dms_mode;
+
+	bool sync_broadcast_en;
 };
 
 static inline bool dsi_panel_ulps_feature_enabled(struct dsi_panel *panel)
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 0c1bcf6..cbcf580 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -130,11 +130,13 @@
 			continue;
 
 		if (msm_is_mode_seamless(
-				&connector->encoder->crtc->state->mode))
+			&connector->encoder->crtc->state->mode) ||
+			msm_is_mode_seamless_vrr(
+			&connector->encoder->crtc->state->adjusted_mode))
 			continue;
 
 		if (msm_is_mode_seamless_dms(
-			       &connector->encoder->crtc->state->adjusted_mode))
+			&connector->encoder->crtc->state->adjusted_mode))
 			continue;
 
 		funcs = encoder->helper_private;
@@ -169,7 +171,8 @@
 		if (!old_crtc_state->active)
 			continue;
 
-		if (msm_is_mode_seamless(&crtc->state->mode))
+		if (msm_is_mode_seamless(&crtc->state->mode) ||
+			msm_is_mode_seamless_vrr(&crtc->state->adjusted_mode))
 			continue;
 
 		if (msm_is_mode_seamless_dms(&crtc->state->adjusted_mode))
@@ -309,7 +312,8 @@
 		if (!crtc->state->active)
 			continue;
 
-		if (msm_is_mode_seamless(&crtc->state->mode))
+		if (msm_is_mode_seamless(&crtc->state->mode) ||
+			msm_is_mode_seamless_vrr(&crtc->state->adjusted_mode))
 			continue;
 
 		funcs = crtc->helper_private;
@@ -476,6 +480,10 @@
 	struct drm_crtc *crtc = NULL;
 	struct drm_crtc_state *crtc_state = NULL;
 	int ret = -EINVAL, i = 0, j = 0;
+	bool nonblock;
+
+	/* cache since work will kfree commit in non-blocking case */
+	nonblock = commit->nonblock;
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
 		for (j = 0; j < priv->num_crtcs; j++) {
@@ -515,10 +523,13 @@
 		 */
 		DRM_ERROR("failed to dispatch commit to any CRTC\n");
 		complete_commit(commit);
-	} else if (!commit->nonblock) {
+	} else if (!nonblock) {
 		kthread_flush_work(&commit->commit_work);
-		kfree(commit);
 	}
+
+	/* free nonblocking commits in this context, after processing */
+	if (!nonblock)
+		kfree(commit);
 }
 
 /**
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 5e47daf..2f9571b 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -58,51 +58,6 @@
 #define MSM_VERSION_PATCHLEVEL	0
 
 #define TEARDOWN_DEADLOCK_RETRY_MAX 5
-#define HPD_STRING_SIZE 30
-
-static void msm_drm_helper_hotplug_event(struct drm_device *dev)
-{
-	struct drm_connector *connector;
-	char name[HPD_STRING_SIZE], status[HPD_STRING_SIZE];
-	char const *connector_name;
-	char *envp[3];
-
-	if (!dev) {
-		DRM_ERROR("hotplug_event failed, invalid input\n");
-		return;
-	}
-
-	if (!dev->mode_config.poll_enabled)
-		return;
-
-	mutex_lock(&dev->mode_config.mutex);
-	drm_for_each_connector(connector, dev) {
-		/* Only handle HPD capable connectors. */
-		if (!(connector->polled & DRM_CONNECTOR_POLL_HPD))
-			continue;
-
-		connector->status = connector->funcs->detect(connector, false);
-
-		if (connector->name)
-			connector_name = connector->name;
-		else
-			connector_name = "unknown";
-
-		snprintf(name, HPD_STRING_SIZE, "name=%s", connector_name);
-
-		snprintf(status, HPD_STRING_SIZE, "status=%s",
-			drm_get_connector_status_name(connector->status));
-
-		DRM_DEBUG("generating hotplug event [%s]: [%s]\n",
-			name, status);
-		envp[0] = name;
-		envp[1] = status;
-		envp[2] = NULL;
-		kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE,
-				envp);
-	}
-	mutex_unlock(&dev->mode_config.mutex);
-}
 
 static void msm_fb_output_poll_changed(struct drm_device *dev)
 {
@@ -117,8 +72,6 @@
 
 	if (priv->fbdev)
 		drm_fb_helper_hotplug_event(priv->fbdev);
-	else
-		msm_drm_helper_hotplug_event(dev);
 }
 
 /**
@@ -1416,7 +1369,9 @@
 			continue;
 		len = event->length + sizeof(struct drm_msm_event_resp);
 		if (node->base.file_priv->event_space < len) {
-			DRM_ERROR("Insufficient space to notify\n");
+			DRM_ERROR("Insufficient space %d for event %x len %d\n",
+				node->base.file_priv->event_space, event->type,
+				len);
 			continue;
 		}
 		notify = kzalloc(len, GFP_ATOMIC);
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index a59da57..e19d1db 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -127,6 +127,9 @@
 
 enum msm_mdp_crtc_property {
 	CRTC_PROP_INFO,
+	CRTC_PROP_DEST_SCALER_LUT_ED,
+	CRTC_PROP_DEST_SCALER_LUT_CIR,
+	CRTC_PROP_DEST_SCALER_LUT_SEP,
 
 	/* # of blob properties */
 	CRTC_PROP_BLOBCOUNT,
@@ -147,7 +150,8 @@
 	CRTC_PROP_ROT_CLK,
 	CRTC_PROP_ROI_V1,
 	CRTC_PROP_SECURITY_LEVEL,
-	CRTC_PROP_IDLE_TIME,
+	CRTC_PROP_IDLE_TIMEOUT,
+	CRTC_PROP_DEST_SCALER,
 
 	/* total # of properties */
 	CRTC_PROP_COUNT
@@ -208,12 +212,14 @@
  * @MSM_DISPLAY_CAP_CMD_MODE:           Command mode supported
  * @MSM_DISPLAY_CAP_HOT_PLUG:           Hot plug detection supported
  * @MSM_DISPLAY_CAP_EDID:               EDID supported
+ * @MSM_DISPLAY_ESD_ENABLED:            ESD feature enabled
  */
 enum msm_display_caps {
 	MSM_DISPLAY_CAP_VID_MODE	= BIT(0),
 	MSM_DISPLAY_CAP_CMD_MODE	= BIT(1),
 	MSM_DISPLAY_CAP_HOT_PLUG	= BIT(2),
 	MSM_DISPLAY_CAP_EDID		= BIT(3),
+	MSM_DISPLAY_ESD_ENABLED		= BIT(4),
 };
 
 /**
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index b829460..f8c3df5 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -311,8 +311,7 @@
 	}
 }
 
-static void
-put_iova(struct drm_gem_object *obj)
+static void put_iova(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
 	struct msm_gem_object *msm_obj = to_msm_bo(obj);
@@ -324,12 +323,14 @@
 		if (iommu_present(&platform_bus_type)) {
 			msm_gem_unmap_vma(domain->aspace, domain,
 				msm_obj->sgt, get_dmabuf_ptr(obj));
-
-			msm_gem_remove_obj_from_aspace_active_list(
-					domain->aspace,
-					obj);
 		}
 
+		/*
+		 * put_iova removes the domain connected to the obj which makes
+		 * the aspace inaccessible. Store the aspace, as it is used to
+		 * update the active_list during gem_free_obj and gem_purege.
+		 */
+		msm_obj->aspace = domain->aspace;
 		obj_remove_domain(domain);
 	}
 }
@@ -409,7 +410,8 @@
 
 	if (!ret && domain) {
 		*iova = domain->iova;
-		msm_gem_add_obj_to_aspace_active_list(aspace, obj);
+		if (aspace && aspace->domain_attached)
+			msm_gem_add_obj_to_aspace_active_list(aspace, obj);
 	} else {
 		obj_remove_domain(domain);
 	}
@@ -485,24 +487,21 @@
 		/**
 		 * Unmap active buffers,
 		 * typically clients should do this when the callback is called,
-		 * but this needs to be done for the framebuffers which are not
-		 * attached to any planes. (background apps)
+		 * but this needs to be done for the buffers which are not
+		 * attached to any planes.
 		 */
 		list_for_each_entry(msm_obj, &aspace->active_list, iova_list) {
 			obj = &msm_obj->base;
-			if (obj->import_attach) {
+			if (obj->import_attach)
 				put_iova(obj);
-				put_pages(obj);
-			}
 		}
 	} else {
 		/* map active buffers */
-		list_for_each_entry(msm_obj, &aspace->active_list,
-				iova_list) {
+		list_for_each_entry(msm_obj, &aspace->active_list, iova_list) {
 			obj = &msm_obj->base;
 			ret = msm_gem_get_iova_locked(obj, aspace, &iova);
 			if (ret) {
-				mutex_unlock(&obj->dev->struct_mutex);
+				mutex_unlock(&aspace->dev->struct_mutex);
 				return;
 			}
 		}
@@ -613,6 +612,7 @@
 	WARN_ON(obj->import_attach);
 
 	put_iova(obj);
+	msm_gem_remove_obj_from_aspace_active_list(msm_obj->aspace, obj);
 
 	msm_gem_vunmap(obj);
 
@@ -841,6 +841,7 @@
 	list_del(&msm_obj->mm_list);
 
 	put_iova(obj);
+	msm_gem_remove_obj_from_aspace_active_list(msm_obj->aspace, obj);
 
 	if (obj->import_attach) {
 		if (msm_obj->vaddr)
@@ -913,6 +914,8 @@
 		return -EINVAL;
 	}
 
+	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
+
 	if (!iommu_present(&platform_bus_type))
 		use_vram = true;
 	else if ((flags & MSM_BO_STOLEN) && priv->vram.size)
@@ -946,6 +949,7 @@
 	INIT_LIST_HEAD(&msm_obj->submit_entry);
 	INIT_LIST_HEAD(&msm_obj->domains);
 	INIT_LIST_HEAD(&msm_obj->iova_list);
+	msm_obj->aspace = NULL;
 
 	list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
 
@@ -987,7 +991,7 @@
 		struct dma_buf *dmabuf, struct sg_table *sgt)
 {
 	struct msm_gem_object *msm_obj;
-	struct drm_gem_object *obj;
+	struct drm_gem_object *obj = NULL;
 	uint32_t size;
 	int ret, npages;
 
@@ -999,7 +1003,12 @@
 
 	size = PAGE_ALIGN(dmabuf->size);
 
+	ret = mutex_lock_interruptible(&dev->struct_mutex);
+	if (ret)
+		return ERR_PTR(ret);
+
 	ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj);
+	mutex_unlock(&dev->struct_mutex);
 	if (ret)
 		goto fail;
 
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index c50c453..8521bea 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -122,6 +122,8 @@
 	 */
 	struct drm_mm_node *vram_node;
 	struct list_head iova_list;
+
+	struct msm_gem_address_space *aspace;
 };
 #define to_msm_bo(x) container_of(x, struct msm_gem_object, base)
 
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index c695dda..cc75fb5 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -109,7 +109,8 @@
 			pagefault_disable();
 		}
 
-		if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) {
+		if ((submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) ||
+			!(submit_bo.flags & MSM_SUBMIT_BO_FLAGS)) {
 			DRM_ERROR("invalid flags: %x\n", submit_bo.flags);
 			ret = -EINVAL;
 			goto out_unlock;
@@ -293,7 +294,7 @@
 {
 	uint32_t i, last_offset = 0;
 	uint32_t *ptr;
-	int ret;
+	int ret = 0;
 
 	if (offset % 4) {
 		DRM_ERROR("non-aligned cmdstream buffer: %u\n", offset);
@@ -320,12 +321,13 @@
 
 		ret = copy_from_user(&submit_reloc, userptr, sizeof(submit_reloc));
 		if (ret)
-			return -EFAULT;
+			goto out;
 
 		if (submit_reloc.submit_offset % 4) {
 			DRM_ERROR("non-aligned reloc offset: %u\n",
 					submit_reloc.submit_offset);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		/* offset in dwords: */
@@ -334,12 +336,13 @@
 		if ((off >= (obj->base.size / 4)) ||
 				(off < last_offset)) {
 			DRM_ERROR("invalid offset %u at reloc %u\n", off, i);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		ret = submit_bo(submit, submit_reloc.reloc_idx, NULL, &iova, &valid);
 		if (ret)
-			return ret;
+			goto out;
 
 		if (valid)
 			continue;
@@ -356,9 +359,10 @@
 		last_offset = off;
 	}
 
+out:
 	msm_gem_put_vaddr_locked(&obj->base);
 
-	return 0;
+	return ret;
 }
 
 static void submit_cleanup(struct msm_gem_submit *submit)
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 76523c7..304faa6 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -36,6 +36,8 @@
 #define MSM_MODE_FLAG_VBLANK_PRE_MODESET	(1<<1)
 /* Request to switch the connector mode */
 #define MSM_MODE_FLAG_SEAMLESS_DMS			(1<<2)
+/* Request to switch the fps */
+#define MSM_MODE_FLAG_SEAMLESS_VRR			(1<<3)
 
 /* As there are different display controller blocks depending on the
  * snapdragon version, the kms support is split out and the appropriate
@@ -163,6 +165,12 @@
 		(mode->private_flags & MSM_MODE_FLAG_SEAMLESS_DYNAMIC_FPS));
 }
 
+static inline bool msm_is_mode_seamless_vrr(const struct drm_display_mode *mode)
+{
+	return mode ? (mode->private_flags & MSM_MODE_FLAG_SEAMLESS_VRR)
+		: false;
+}
+
 static inline bool msm_needs_vblank_pre_modeset(
 		const struct drm_display_mode *mode)
 {
diff --git a/drivers/gpu/drm/msm/msm_prop.c b/drivers/gpu/drm/msm/msm_prop.c
index d1991a4..033be6e 100644
--- a/drivers/gpu/drm/msm/msm_prop.c
+++ b/drivers/gpu/drm/msm/msm_prop.c
@@ -269,9 +269,16 @@
 		info->property_data[property_idx].default_value = 0;
 		info->property_data[property_idx].force_dirty = false;
 
+		/* select first defined value for enums */
+		if (!is_bitmask)
+			info->property_data[property_idx].default_value =
+				values->type;
+
 		/* always attach property, if created */
 		if (*prop) {
-			drm_object_attach_property(info->base, *prop, 0);
+			drm_object_attach_property(info->base, *prop,
+					info->property_data
+					[property_idx].default_value);
 			++info->install_count;
 		}
 	}
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
index f326cf6..67b34e0 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -23,7 +23,8 @@
 	struct msm_ringbuffer *ring;
 	int ret;
 
-	size = ALIGN(size, 4);   /* size should be dword aligned */
+	if (WARN_ON(!is_power_of_2(size)))
+		return ERR_PTR(-EINVAL);
 
 	ring = kzalloc(sizeof(*ring), GFP_KERNEL);
 	if (!ring) {
diff --git a/drivers/gpu/drm/msm/sde/sde_color_processing.c b/drivers/gpu/drm/msm/sde/sde_color_processing.c
index 9409066..e9ffb96 100644
--- a/drivers/gpu/drm/msm/sde/sde_color_processing.c
+++ b/drivers/gpu/drm/msm/sde/sde_color_processing.c
@@ -62,6 +62,8 @@
 
 static void dspp_igc_install_property(struct drm_crtc *crtc);
 
+static void dspp_hist_install_property(struct drm_crtc *crtc);
+
 typedef void (*dspp_prop_install_func_t)(struct drm_crtc *crtc);
 
 static dspp_prop_install_func_t dspp_prop_install_func[SDE_DSPP_MAX];
@@ -77,6 +79,8 @@
 static void sde_cp_ad_set_prop(struct sde_crtc *sde_crtc,
 		enum ad_property ad_prop);
 
+static void sde_cp_notify_hist_event(struct drm_crtc *crtc_drm, void *arg);
+
 #define setup_dspp_prop_install_funcs(func) \
 do { \
 	func[SDE_DSPP_PCC] = dspp_pcc_install_property; \
@@ -86,6 +90,7 @@
 	func[SDE_DSPP_GAMUT] = dspp_gamut_install_property; \
 	func[SDE_DSPP_GC] = dspp_gc_install_property; \
 	func[SDE_DSPP_IGC] = dspp_igc_install_property; \
+	func[SDE_DSPP_HIST] = dspp_hist_install_property; \
 } while (0)
 
 typedef void (*lm_prop_install_func_t)(struct drm_crtc *crtc);
@@ -111,7 +116,8 @@
 	SDE_CP_CRTC_DSPP_SIXZONE,
 	SDE_CP_CRTC_DSPP_GAMUT,
 	SDE_CP_CRTC_DSPP_DITHER,
-	SDE_CP_CRTC_DSPP_HIST,
+	SDE_CP_CRTC_DSPP_HIST_CTRL,
+	SDE_CP_CRTC_DSPP_HIST_IRQ,
 	SDE_CP_CRTC_DSPP_AD,
 	SDE_CP_CRTC_DSPP_VLUT,
 	SDE_CP_CRTC_DSPP_AD_MODE,
@@ -365,6 +371,13 @@
 		return;
 	}
 
+	/* create blob to store histogram data */
+	sde_crtc->hist_blob = drm_property_create_blob(crtc->dev,
+				sizeof(struct drm_msm_hist), NULL);
+	if (IS_ERR(sde_crtc->hist_blob))
+		sde_crtc->hist_blob = NULL;
+
+	mutex_init(&sde_crtc->crtc_cp_lock);
 	INIT_LIST_HEAD(&sde_crtc->active_list);
 	INIT_LIST_HEAD(&sde_crtc->dirty_list);
 	INIT_LIST_HEAD(&sde_crtc->feature_list);
@@ -531,6 +544,77 @@
 	sde_cp_crtc_prop_attach(&prop_attach);
 }
 
+static struct sde_crtc_irq_info *_sde_cp_get_intr_node(u32 event,
+				struct sde_crtc *sde_crtc)
+{
+	bool found = false;
+	struct sde_crtc_irq_info *node = NULL;
+
+	list_for_each_entry(node, &sde_crtc->user_event_list, list) {
+		if (node->event == event) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found)
+		node = NULL;
+
+	return node;
+}
+
+static void _sde_cp_crtc_enable_hist_irq(struct sde_crtc *sde_crtc)
+{
+	struct drm_crtc *crtc_drm = &sde_crtc->base;
+	struct sde_kms *kms = NULL;
+	struct sde_hw_mixer *hw_lm;
+	struct sde_hw_dspp *hw_dspp = NULL;
+	struct sde_crtc_irq_info *node = NULL;
+	int i, irq_idx, ret = 0;
+	unsigned long flags;
+
+	if (!crtc_drm) {
+		DRM_ERROR("invalid crtc %pK\n", crtc_drm);
+		return;
+	}
+
+	kms = get_kms(crtc_drm);
+
+	for (i = 0; i < sde_crtc->num_mixers; i++) {
+		hw_lm = sde_crtc->mixers[i].hw_lm;
+		hw_dspp = sde_crtc->mixers[i].hw_dspp;
+		if (!hw_lm->cfg.right_mixer)
+			break;
+	}
+
+	if (!hw_dspp) {
+		DRM_ERROR("invalid dspp\n");
+		return;
+	}
+
+	irq_idx = sde_core_irq_idx_lookup(kms, SDE_IRQ_TYPE_HIST_DSPP_DONE,
+					hw_dspp->idx);
+	if (irq_idx < 0) {
+		DRM_ERROR("failed to get irq idx\n");
+		return;
+	}
+
+	spin_lock_irqsave(&sde_crtc->spin_lock, flags);
+	node = _sde_cp_get_intr_node(DRM_EVENT_HISTOGRAM, sde_crtc);
+	spin_unlock_irqrestore(&sde_crtc->spin_lock, flags);
+
+	if (!node)
+		return;
+
+	if (node->state == IRQ_DISABLED) {
+		ret = sde_core_irq_enable(kms, &irq_idx, 1);
+		if (ret)
+			DRM_ERROR("failed to enable irq %d\n", irq_idx);
+		else
+			node->state = IRQ_ENABLED;
+	}
+}
+
 static void sde_cp_crtc_setfeature(struct sde_cp_node *prop_node,
 				   struct sde_crtc *sde_crtc)
 {
@@ -639,6 +723,21 @@
 			}
 			hw_lm->ops.setup_gc(hw_lm, &hw_cfg);
 			break;
+		case SDE_CP_CRTC_DSPP_HIST_CTRL:
+			if (!hw_dspp || !hw_dspp->ops.setup_histogram) {
+				ret = -EINVAL;
+				continue;
+			}
+			hw_dspp->ops.setup_histogram(hw_dspp, &feature_enabled);
+			break;
+		case SDE_CP_CRTC_DSPP_HIST_IRQ:
+			if (!hw_dspp || !hw_lm) {
+				ret = -EINVAL;
+				continue;
+			}
+			if (!hw_lm->cfg.right_mixer)
+				_sde_cp_crtc_enable_hist_irq(sde_crtc);
+			break;
 		case SDE_CP_CRTC_DSPP_AD_MODE:
 			if (!hw_dspp || !hw_dspp->ops.setup_ad) {
 				ret = -EINVAL;
@@ -746,6 +845,8 @@
 		return;
 	}
 
+	mutex_lock(&sde_crtc->crtc_cp_lock);
+
 	/* Check if dirty lists are empty and ad features are disabled for
 	 * early return. If ad properties are active then we need to issue
 	 * dspp flush.
@@ -754,7 +855,7 @@
 		list_empty(&sde_crtc->ad_dirty)) {
 		if (list_empty(&sde_crtc->ad_active)) {
 			DRM_DEBUG_DRIVER("Dirty list is empty\n");
-			return;
+			goto exit;
 		}
 		sde_cp_ad_set_prop(sde_crtc, AD_IPC_RESET);
 		set_dspp_flush = true;
@@ -794,6 +895,8 @@
 			ctl->ops.update_pending_flush(ctl, flush_mask);
 		}
 	}
+exit:
+	mutex_unlock(&sde_crtc->crtc_cp_lock);
 }
 
 void sde_cp_crtc_install_properties(struct drm_crtc *crtc)
@@ -824,13 +927,15 @@
 		return;
 	}
 
+	mutex_lock(&sde_crtc->crtc_cp_lock);
+
 	/**
 	 * Function can be called during the atomic_check with test_only flag
 	 * and actual commit. Allocate properties only if feature list is
 	 * empty during the atomic_check with test_only flag.
 	 */
 	if (!list_empty(&sde_crtc->feature_list))
-		return;
+		goto exit;
 
 	catalog = kms->catalog;
 	priv = crtc->dev->dev_private;
@@ -846,7 +951,7 @@
 		setup_lm_prop_install_funcs(lm_prop_install_func);
 	}
 	if (!priv->cp_property)
-		return;
+		goto exit;
 
 	if (!catalog->dspp_count)
 		goto lm_property;
@@ -862,7 +967,7 @@
 
 lm_property:
 	if (!catalog->mixer_count)
-		return;
+		goto exit;
 
 	/* Check for all the LM properties and attach it to CRTC */
 	features = catalog->mixer[0].features;
@@ -872,6 +977,9 @@
 		if (lm_prop_install_func[i])
 			lm_prop_install_func[i](crtc);
 	}
+exit:
+	mutex_unlock(&sde_crtc->crtc_cp_lock);
+
 }
 
 int sde_cp_crtc_set_property(struct drm_crtc *crtc,
@@ -894,6 +1002,7 @@
 		return -EINVAL;
 	}
 
+	mutex_lock(&sde_crtc->crtc_cp_lock);
 	list_for_each_entry(prop_node, &sde_crtc->feature_list, feature_list) {
 		if (property->base.id == prop_node->property_id) {
 			found = 1;
@@ -902,7 +1011,8 @@
 	}
 
 	if (!found)
-		return 0;
+		goto exit;
+
 	/**
 	 * sde_crtc is virtual ensure that hardware has been attached to the
 	 * crtc. Check LM and dspp counts based on whether feature is a
@@ -912,7 +1022,8 @@
 	    sde_crtc->num_mixers > ARRAY_SIZE(sde_crtc->mixers)) {
 		DRM_ERROR("Invalid mixer config act cnt %d max cnt %ld\n",
 			sde_crtc->num_mixers, ARRAY_SIZE(sde_crtc->mixers));
-		return -EINVAL;
+		ret = -EINVAL;
+		goto exit;
 	}
 
 	dspp_cnt = 0;
@@ -927,17 +1038,19 @@
 	if (prop_node->is_dspp_feature && dspp_cnt < sde_crtc->num_mixers) {
 		DRM_ERROR("invalid dspp cnt %d mixer cnt %d\n", dspp_cnt,
 			sde_crtc->num_mixers);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto exit;
 	} else if (lm_cnt < sde_crtc->num_mixers) {
 		DRM_ERROR("invalid lm cnt %d mixer cnt %d\n", lm_cnt,
 			sde_crtc->num_mixers);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto exit;
 	}
 
 	ret = sde_cp_ad_validate_prop(prop_node, sde_crtc);
 	if (ret) {
 		DRM_ERROR("ad property validation failed ret %d\n", ret);
-		return ret;
+		goto exit;
 	}
 
 	/* remove the property from dirty list */
@@ -955,6 +1068,8 @@
 		/* Mark the feature as dirty */
 		sde_cp_update_list(prop_node, sde_crtc, true);
 	}
+exit:
+	mutex_unlock(&sde_crtc->crtc_cp_lock);
 	return ret;
 }
 
@@ -977,12 +1092,14 @@
 	}
 	/* Return 0 if property is not supported */
 	*val = 0;
+	mutex_lock(&sde_crtc->crtc_cp_lock);
 	list_for_each_entry(prop_node, &sde_crtc->feature_list, feature_list) {
 		if (property->base.id == prop_node->property_id) {
 			*val = prop_node->prop_val;
 			break;
 		}
 	}
+	mutex_unlock(&sde_crtc->crtc_cp_lock);
 	return 0;
 }
 
@@ -1015,6 +1132,10 @@
 		kfree(prop_node);
 	}
 
+	if (sde_crtc->hist_blob)
+		drm_property_unreference_blob(sde_crtc->hist_blob);
+
+	mutex_destroy(&sde_crtc->crtc_cp_lock);
 	INIT_LIST_HEAD(&sde_crtc->active_list);
 	INIT_LIST_HEAD(&sde_crtc->dirty_list);
 	INIT_LIST_HEAD(&sde_crtc->feature_list);
@@ -1035,6 +1156,7 @@
 		return;
 	}
 
+	mutex_lock(&sde_crtc->crtc_cp_lock);
 	list_for_each_entry_safe(prop_node, n, &sde_crtc->active_list,
 				 active_list) {
 		sde_cp_update_list(prop_node, sde_crtc, true);
@@ -1046,6 +1168,7 @@
 		sde_cp_update_list(prop_node, sde_crtc, true);
 		list_del_init(&prop_node->active_list);
 	}
+	mutex_unlock(&sde_crtc->crtc_cp_lock);
 }
 
 void sde_cp_crtc_resume(struct drm_crtc *crtc)
@@ -1273,6 +1396,30 @@
 	}
 }
 
+static void dspp_hist_install_property(struct drm_crtc *crtc)
+{
+	struct sde_kms *kms = NULL;
+	struct sde_mdss_cfg *catalog = NULL;
+	u32 version;
+
+	kms = get_kms(crtc);
+	catalog = kms->catalog;
+
+	version = catalog->dspp[0].sblk->hist.version >> 16;
+	switch (version) {
+	case 1:
+		sde_cp_crtc_install_enum_property(crtc,
+			SDE_CP_CRTC_DSPP_HIST_CTRL, sde_hist_modes,
+			ARRAY_SIZE(sde_hist_modes), "SDE_DSPP_HIST_CTRL_V1");
+		sde_cp_crtc_install_range_property(crtc, "SDE_DSPP_HIST_IRQ_V1",
+			SDE_CP_CRTC_DSPP_HIST_IRQ, 0, U16_MAX, 0);
+		break;
+	default:
+		DRM_ERROR("version %d not supported\n", version);
+		break;
+	}
+}
+
 static void sde_cp_update_list(struct sde_cp_node *prop_node,
 		struct sde_crtc *crtc, bool dirty_list)
 {
@@ -1394,6 +1541,7 @@
 	int i;
 	int irq_idx, ret;
 	struct sde_cp_node prop_node;
+	struct sde_crtc_irq_info *node = NULL;
 
 	if (!crtc_drm || !ad_irq) {
 		DRM_ERROR("invalid crtc %pK irq %pK\n", crtc_drm, ad_irq);
@@ -1438,14 +1586,28 @@
 		goto exit;
 	}
 
+	node = _sde_cp_get_intr_node(DRM_EVENT_AD_BACKLIGHT, crtc);
+
 	if (!en) {
-		sde_core_irq_disable(kms, &irq_idx, 1);
+		if (node) {
+			if (node->state == IRQ_ENABLED) {
+				ret = sde_core_irq_disable(kms, &irq_idx, 1);
+				if (ret)
+					DRM_ERROR("disable irq %d error %d\n",
+						irq_idx, ret);
+				else
+					node->state = IRQ_NOINIT;
+			} else {
+				node->state = IRQ_NOINIT;
+			}
+		} else {
+			DRM_ERROR("failed to get node from crtc event list\n");
+		}
 		sde_core_irq_unregister_callback(kms, irq_idx, ad_irq);
 		ret = 0;
 		goto exit;
 	}
 
-	INIT_LIST_HEAD(&ad_irq->list);
 	ad_irq->arg = crtc;
 	ad_irq->func = sde_cp_ad_interrupt_cb;
 	ret = sde_core_irq_register_callback(kms, irq_idx, ad_irq);
@@ -1453,10 +1615,30 @@
 		DRM_ERROR("failed to register the callback ret %d\n", ret);
 		goto exit;
 	}
-	ret = sde_core_irq_enable(kms, &irq_idx, 1);
-	if (ret) {
-		DRM_ERROR("failed to enable irq ret %d\n", ret);
-		sde_core_irq_unregister_callback(kms, irq_idx, ad_irq);
+
+	if (node) {
+		/* device resume or resume from IPC cases */
+		if (node->state == IRQ_DISABLED || node->state == IRQ_NOINIT) {
+			ret = sde_core_irq_enable(kms, &irq_idx, 1);
+			if (ret) {
+				DRM_ERROR("enable irq %d error %d\n",
+					irq_idx, ret);
+				sde_core_irq_unregister_callback(kms,
+					irq_idx, ad_irq);
+			} else {
+				node->state = IRQ_ENABLED;
+			}
+		}
+	} else {
+		/* request from userspace to register the event
+		 * in this case, node has not been added into the event list
+		 */
+		ret = sde_core_irq_enable(kms, &irq_idx, 1);
+		if (ret) {
+			DRM_ERROR("failed to enable irq ret %d\n", ret);
+			sde_core_irq_unregister_callback(kms,
+				irq_idx, ad_irq);
+		}
 	}
 exit:
 	return ret;
@@ -1519,3 +1701,201 @@
 
 	sde_cp_ad_set_prop(sde_crtc, AD_IPC_RESUME);
 }
+
+static void sde_cp_hist_interrupt_cb(void *arg, int irq_idx)
+{
+	struct sde_crtc *crtc = arg;
+	struct drm_crtc *crtc_drm = &crtc->base;
+	struct sde_hw_dspp *hw_dspp;
+	struct sde_kms *kms;
+	struct sde_crtc_irq_info *node = NULL;
+	u32 i;
+	int ret = 0;
+	unsigned long flags;
+
+	/* disable histogram irq */
+	kms = get_kms(crtc_drm);
+	spin_lock_irqsave(&crtc->spin_lock, flags);
+	node = _sde_cp_get_intr_node(DRM_EVENT_HISTOGRAM, crtc);
+	spin_unlock_irqrestore(&crtc->spin_lock, flags);
+
+	if (!node) {
+		DRM_ERROR("cannot find histogram event node in crtc\n");
+		return;
+	}
+
+	if (node->state == IRQ_ENABLED) {
+		if (sde_core_irq_disable_nolock(kms, irq_idx)) {
+			DRM_ERROR("failed to disable irq %d, ret %d\n",
+				irq_idx, ret);
+			return;
+		}
+		node->state = IRQ_DISABLED;
+	}
+
+	/* lock histogram buffer */
+	for (i = 0; i < crtc->num_mixers; i++) {
+		hw_dspp = crtc->mixers[i].hw_dspp;
+		if (hw_dspp && hw_dspp->ops.lock_histogram)
+			hw_dspp->ops.lock_histogram(hw_dspp, NULL);
+	}
+
+	/* notify histogram event */
+	sde_crtc_event_queue(crtc_drm, sde_cp_notify_hist_event, NULL);
+}
+
+static void sde_cp_notify_hist_event(struct drm_crtc *crtc_drm, void *arg)
+{
+	struct sde_hw_dspp *hw_dspp = NULL;
+	struct sde_crtc *crtc;
+	struct drm_event event;
+	struct drm_msm_hist *hist_data;
+	struct drm_msm_hist tmp_hist_data;
+	u32 i, j;
+
+	if (!crtc_drm) {
+		DRM_ERROR("invalid crtc %pK\n", crtc_drm);
+		return;
+	}
+
+	crtc = to_sde_crtc(crtc_drm);
+	if (!crtc) {
+		DRM_ERROR("invalid sde_crtc %pK\n", crtc);
+		return;
+	}
+
+	if (!crtc->hist_blob)
+		return;
+
+	/* read histogram data into blob */
+	hist_data = (struct drm_msm_hist *)crtc->hist_blob->data;
+	for (i = 0; i < crtc->num_mixers; i++) {
+		hw_dspp = crtc->mixers[i].hw_dspp;
+		if (!hw_dspp || !hw_dspp->ops.read_histogram) {
+			DRM_ERROR("invalid dspp %pK or read_histogram func\n",
+				hw_dspp);
+			return;
+		}
+		if (!i) {
+			hw_dspp->ops.read_histogram(hw_dspp, hist_data);
+		} else {
+			/* Merge hist data for DSPP0 and DSPP1 */
+			hw_dspp->ops.read_histogram(hw_dspp, &tmp_hist_data);
+			for (j = 0; j < HIST_V_SIZE; j++)
+				hist_data->data[j] += tmp_hist_data.data[j];
+		}
+	}
+
+	/* send histogram event with blob id */
+	event.length = sizeof(u32);
+	event.type = DRM_EVENT_HISTOGRAM;
+	msm_mode_object_event_notify(&crtc_drm->base, crtc_drm->dev,
+			&event, (u8 *)(&crtc->hist_blob->base.id));
+}
+
+int sde_cp_hist_interrupt(struct drm_crtc *crtc_drm, bool en,
+	struct sde_irq_callback *hist_irq)
+{
+	struct sde_kms *kms = NULL;
+	u32 num_mixers;
+	struct sde_hw_mixer *hw_lm;
+	struct sde_hw_dspp *hw_dspp = NULL;
+	struct sde_crtc *crtc;
+	struct sde_crtc_irq_info *node = NULL;
+	int i, irq_idx, ret = 0;
+
+	if (!crtc_drm || !hist_irq) {
+		DRM_ERROR("invalid crtc %pK irq %pK\n", crtc_drm, hist_irq);
+		return -EINVAL;
+	}
+
+	crtc = to_sde_crtc(crtc_drm);
+	if (!crtc) {
+		DRM_ERROR("invalid sde_crtc %pK\n", crtc);
+		return -EINVAL;
+	}
+
+	kms = get_kms(crtc_drm);
+	num_mixers = crtc->num_mixers;
+
+	for (i = 0; i < num_mixers; i++) {
+		hw_lm = crtc->mixers[i].hw_lm;
+		hw_dspp = crtc->mixers[i].hw_dspp;
+		if (!hw_lm->cfg.right_mixer)
+			break;
+	}
+
+	if (!hw_dspp) {
+		DRM_ERROR("invalid dspp\n");
+		ret = -EINVAL;
+		goto exit;
+	}
+
+	irq_idx = sde_core_irq_idx_lookup(kms, SDE_IRQ_TYPE_HIST_DSPP_DONE,
+			hw_dspp->idx);
+	if (irq_idx < 0) {
+		DRM_ERROR("failed to get the irq idx ret %d\n", irq_idx);
+		ret = irq_idx;
+		goto exit;
+	}
+
+	node = _sde_cp_get_intr_node(DRM_EVENT_HISTOGRAM, crtc);
+
+	/* deregister histogram irq */
+	if (!en) {
+		if (node) {
+			/* device suspend case or suspend to IPC cases */
+			if (node->state == IRQ_ENABLED) {
+				ret = sde_core_irq_disable(kms, &irq_idx, 1);
+				if (ret)
+					DRM_ERROR("disable irq %d error %d\n",
+						irq_idx, ret);
+				else
+					node->state = IRQ_NOINIT;
+			} else {
+				node->state = IRQ_NOINIT;
+			}
+		} else {
+			DRM_ERROR("failed to get node from crtc event list\n");
+		}
+
+		sde_core_irq_unregister_callback(kms, irq_idx, hist_irq);
+		goto exit;
+	}
+
+	/* register histogram irq */
+	hist_irq->arg = crtc;
+	hist_irq->func = sde_cp_hist_interrupt_cb;
+	ret = sde_core_irq_register_callback(kms, irq_idx, hist_irq);
+	if (ret) {
+		DRM_ERROR("failed to register the callback ret %d\n", ret);
+		goto exit;
+	}
+
+	if (node) {
+		/* device resume or resume from IPC cases */
+		if (node->state == IRQ_DISABLED || node->state == IRQ_NOINIT) {
+			ret = sde_core_irq_enable(kms, &irq_idx, 1);
+			if (ret) {
+				DRM_ERROR("enable irq %d error %d\n",
+					irq_idx, ret);
+				sde_core_irq_unregister_callback(kms,
+					irq_idx, hist_irq);
+			} else {
+				node->state = IRQ_ENABLED;
+			}
+		}
+	} else {
+		/* request from userspace to register the event
+		 * in this case, node has not been added into the event list
+		 */
+		ret = sde_core_irq_enable(kms, &irq_idx, 1);
+		if (ret) {
+			DRM_ERROR("failed to enable irq ret %d\n", ret);
+			sde_core_irq_unregister_callback(kms,
+				irq_idx, hist_irq);
+		}
+	}
+exit:
+	return ret;
+}
diff --git a/drivers/gpu/drm/msm/sde/sde_color_processing.h b/drivers/gpu/drm/msm/sde/sde_color_processing.h
index 08e345d..aff07ef 100644
--- a/drivers/gpu/drm/msm/sde/sde_color_processing.h
+++ b/drivers/gpu/drm/msm/sde/sde_color_processing.h
@@ -29,6 +29,25 @@
 	MEMCOLOR_FOLIAGE
 };
 
+/*
+ * PA HISTOGRAM modes
+ * @HIST_DISABLED          Histogram disabled
+ * @HIST_ENABLED           Histogram enabled
+ */
+enum sde_hist_modes {
+	HIST_DISABLED,
+	HIST_ENABLED
+};
+
+/**
+ * struct drm_prop_enum_list - drm structure for creating enum property and
+ *                             enumerating values
+ */
+static const struct drm_prop_enum_list sde_hist_modes[] = {
+	{HIST_DISABLED, "hist_off"},
+	{HIST_ENABLED, "hist_on"},
+};
+
 /**
  * sde_cp_crtc_init(): Initialize color processing lists for a crtc.
  *                     Should be called during crtc initialization.
@@ -117,4 +136,13 @@
  * @crtc: Pointer to crtc.
  */
 void sde_cp_crtc_post_ipc(struct drm_crtc *crtc);
+
+/**
+ * sde_cp_hist_interrupt: Api to enable/disable histogram interrupt
+ * @crtc: Pointer to crtc.
+ * @en: Variable to enable/disable interrupt.
+ * @irq: Pointer to irq callback
+ */
+int sde_cp_hist_interrupt(struct drm_crtc *crtc_drm, bool en,
+	struct sde_irq_callback *hist_irq);
 #endif /*_SDE_COLOR_PROCESSING_H */
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.c b/drivers/gpu/drm/msm/sde/sde_connector.c
index 9d70525..d83f476 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.c
+++ b/drivers/gpu/drm/msm/sde/sde_connector.c
@@ -12,12 +12,14 @@
 
 #define pr_fmt(fmt)	"[drm:%s:%d] " fmt, __func__, __LINE__
 #include "msm_drv.h"
+#include "sde_dbg.h"
 
 #include "sde_kms.h"
 #include "sde_connector.h"
 #include <linux/backlight.h>
 #include "dsi_drm.h"
 #include "dsi_display.h"
+#include "sde_crtc.h"
 
 #define BL_NODE_NAME_SIZE 32
 
@@ -107,7 +109,6 @@
 static int sde_backlight_setup(struct sde_connector *c_conn,
 					struct drm_device *dev)
 {
-	struct backlight_device *bl_device;
 	struct backlight_properties props;
 	struct dsi_display *display;
 	struct dsi_backlight_config *bl_config;
@@ -131,11 +132,12 @@
 	props.brightness = bl_config->brightness_max_level;
 	snprintf(bl_node_name, BL_NODE_NAME_SIZE, "panel%u-backlight",
 							display_count);
-	bl_device = backlight_device_register(bl_node_name, dev->dev,
+	c_conn->bl_device = backlight_device_register(bl_node_name, dev->dev,
 			c_conn, &sde_backlight_device_ops, &props);
-	if (IS_ERR_OR_NULL(bl_device)) {
+	if (IS_ERR_OR_NULL(c_conn->bl_device)) {
 		SDE_ERROR("Failed to register backlight: %ld\n",
-				    PTR_ERR(bl_device));
+				    PTR_ERR(c_conn->bl_device));
+		c_conn->bl_device = NULL;
 		return -ENODEV;
 	}
 	display_count++;
@@ -365,6 +367,29 @@
 	return c_conn->ops.get_info(info, c_conn->display);
 }
 
+void sde_connector_schedule_status_work(struct drm_connector *connector,
+		bool en)
+{
+	struct sde_connector *c_conn;
+	struct msm_display_info info;
+
+	c_conn = to_sde_connector(connector);
+	if (!c_conn)
+		return;
+
+	sde_connector_get_info(connector, &info);
+	if (c_conn->ops.check_status &&
+		(info.capabilities & MSM_DISPLAY_ESD_ENABLED)) {
+		if (en)
+			/* Schedule ESD status check */
+			schedule_delayed_work(&c_conn->status_work,
+				msecs_to_jiffies(STATUS_CHECK_INTERVAL_MS));
+		else
+			/* Cancel any pending ESD status check */
+			cancel_delayed_work_sync(&c_conn->status_work);
+	}
+}
+
 static int _sde_connector_update_power_locked(struct sde_connector *c_conn)
 {
 	struct drm_connector *connector;
@@ -410,6 +435,9 @@
 	}
 	c_conn->last_panel_power_mode = mode;
 
+	if (mode != SDE_MODE_DPMS_ON)
+		sde_connector_schedule_status_work(connector, false);
+
 	return rc;
 }
 
@@ -491,6 +519,9 @@
 
 	c_conn = to_sde_connector(connector);
 
+	/* cancel if any pending esd work */
+	sde_connector_schedule_status_work(connector, false);
+
 	if (c_conn->ops.put_modes)
 		c_conn->ops.put_modes(connector, c_conn->display);
 
@@ -502,6 +533,8 @@
 		drm_property_unreference_blob(c_conn->blob_dither);
 	msm_property_destroy(&c_conn->property_info);
 
+	if (c_conn->bl_device)
+		backlight_device_unregister(c_conn->bl_device);
 	drm_connector_unregister(connector);
 	mutex_destroy(&c_conn->lock);
 	sde_fence_deinit(&c_conn->retire_fence);
@@ -556,6 +589,8 @@
 	if (c_state->out_fb)
 		_sde_connector_destroy_fb(c_conn, c_state);
 
+	__drm_atomic_helper_connector_destroy_state(&c_state->base);
+
 	if (!c_conn) {
 		kfree(c_state);
 	} else {
@@ -577,6 +612,12 @@
 
 	c_conn = to_sde_connector(connector);
 
+	if (connector->state &&
+			!sde_crtc_is_reset_required(connector->state->crtc)) {
+		SDE_DEBUG_CONN(c_conn, "avoid reset for connector\n");
+		return;
+	}
+
 	if (connector->state) {
 		sde_connector_atomic_destroy_state(connector, connector->state);
 		connector->state = 0;
@@ -593,8 +634,7 @@
 			&c_state->property_state,
 			c_state->property_values);
 
-	c_state->base.connector = connector;
-	connector->state = &c_state->base;
+	__drm_atomic_helper_connector_reset(connector, &c_state->base);
 }
 
 static struct drm_connector_state *
@@ -621,6 +661,9 @@
 			c_oldstate, c_state,
 			&c_state->property_state, c_state->property_values);
 
+	__drm_atomic_helper_connector_duplicate_state(connector,
+			&c_state->base);
+
 	/* additional handling for drm framebuffer objects */
 	if (c_state->out_fb)
 		drm_framebuffer_reference(c_state->out_fb);
@@ -1053,6 +1096,7 @@
 static int sde_connector_init_debugfs(struct drm_connector *connector)
 {
 	struct sde_connector *sde_connector;
+	struct msm_display_info info;
 
 	if (!connector || !connector->debugfs_entry) {
 		SDE_ERROR("invalid connector\n");
@@ -1061,6 +1105,13 @@
 
 	sde_connector = to_sde_connector(connector);
 
+	sde_connector_get_info(connector, &info);
+	if (sde_connector->ops.check_status &&
+		(info.capabilities & MSM_DISPLAY_ESD_ENABLED))
+		debugfs_create_u32("force_panel_dead", 0600,
+				connector->debugfs_entry,
+				&sde_connector->force_panel_dead);
+
 	if (!debugfs_create_bool("fb_kmap", 0600, connector->debugfs_entry,
 			&sde_connector->fb_kmap)) {
 		SDE_ERROR("failed to create connector fb_kmap\n");
@@ -1157,6 +1208,56 @@
 	return c_conn->encoder;
 }
 
+static void sde_connector_check_status_work(struct work_struct *work)
+{
+	struct sde_connector *conn;
+	struct drm_event event;
+	int rc = 0;
+	bool panel_dead = false;
+
+	conn = container_of(to_delayed_work(work),
+			struct sde_connector, status_work);
+	if (!conn) {
+		SDE_ERROR("not able to get connector object\n");
+		return;
+	}
+
+	mutex_lock(&conn->lock);
+	if (!conn->ops.check_status ||
+			(conn->dpms_mode != DRM_MODE_DPMS_ON)) {
+		SDE_DEBUG("dpms mode: %d\n", conn->dpms_mode);
+		mutex_unlock(&conn->lock);
+		return;
+	}
+
+	rc = conn->ops.check_status(conn->display);
+	mutex_unlock(&conn->lock);
+
+	if (conn->force_panel_dead) {
+		conn->force_panel_dead--;
+		if (!conn->force_panel_dead)
+			goto status_dead;
+	}
+
+	if (rc > 0) {
+		SDE_DEBUG("esd check status success conn_id: %d enc_id: %d\n",
+				conn->base.base.id, conn->encoder->base.id);
+		schedule_delayed_work(&conn->status_work,
+			msecs_to_jiffies(STATUS_CHECK_INTERVAL_MS));
+		return;
+	}
+
+status_dead:
+	SDE_EVT32(rc, SDE_EVTLOG_ERROR);
+	SDE_ERROR("esd check failed report PANEL_DEAD conn_id: %d enc_id: %d\n",
+			conn->base.base.id, conn->encoder->base.id);
+	panel_dead = true;
+	event.type = DRM_EVENT_PANEL_DEAD;
+	event.length = sizeof(u32);
+	msm_mode_object_event_notify(&conn->base.base,
+		conn->base.dev, &event, (u8 *)&panel_dead);
+}
+
 static const struct drm_connector_helper_funcs sde_connector_helper_ops = {
 	.get_modes =    sde_connector_get_modes,
 	.mode_valid =   sde_connector_mode_valid,
@@ -1197,6 +1298,8 @@
 		return ERR_PTR(-ENOMEM);
 	}
 
+	memset(&display_info, 0, sizeof(display_info));
+
 	rc = drm_connector_init(dev,
 			&c_conn->base,
 			&sde_connector_ops,
@@ -1363,6 +1466,9 @@
 
 	priv->connectors[priv->num_connectors++] = &c_conn->base;
 
+	INIT_DELAYED_WORK(&c_conn->status_work,
+			sde_connector_check_status_work);
+
 	return &c_conn->base;
 
 error_destroy_property:
@@ -1394,6 +1500,9 @@
 	case DRM_EVENT_SYS_BACKLIGHT:
 		ret = 0;
 		break;
+	case DRM_EVENT_PANEL_DEAD:
+		ret = 0;
+		break;
 	default:
 		break;
 	}
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.h b/drivers/gpu/drm/msm/sde/sde_connector.h
index b44bfae..4018441 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.h
+++ b/drivers/gpu/drm/msm/sde/sde_connector.h
@@ -199,6 +199,26 @@
 	 * Returns: dst_format of display
 	 */
 	enum dsi_pixel_format (*get_dst_format)(void *display);
+
+	/**
+	 * post_kickoff - display to program post kickoff-time features
+	 * @connector: Pointer to drm connector structure
+	 * Returns: Zero on success
+	 */
+	int (*post_kickoff)(struct drm_connector *connector);
+
+	/**
+	 * send_hpd_event - send HPD uevent notification to userspace
+	 * @display: Pointer to private display structure
+	 */
+	void (*send_hpd_event)(void *display);
+
+	/**
+	 * check_status - check status of connected display panel
+	 * @display: Pointer to private display handle
+	 * Returns: positive value for success, negetive or zero for failure
+	 */
+	int (*check_status)(void *display);
 };
 
 /**
@@ -247,6 +267,9 @@
  * @fb_kmap: true if kernel mapping of framebuffer is requested
  * @event_table: Array of registered events
  * @event_lock: Lock object for event_table
+ * @bl_device: backlight device node
+ * @status_work: work object to perform status checks
+ * @force_panel_dead: variable to trigger forced ESD recovery
  */
 struct sde_connector {
 	struct drm_connector base;
@@ -277,6 +300,10 @@
 	bool fb_kmap;
 	struct sde_connector_evt event_table[SDE_CONN_EVENT_COUNT];
 	spinlock_t event_lock;
+
+	struct backlight_device *bl_device;
+	struct delayed_work status_work;
+	u32 force_panel_dead;
 };
 
 /**
@@ -564,4 +591,11 @@
 int sde_connector_get_dither_cfg(struct drm_connector *conn,
 		struct drm_connector_state *state, void **cfg, size_t *len);
 
+/**
+ * sde_connector_schedule_status_work - manage ESD thread
+ * conn: Pointer to drm_connector struct
+ * @en: flag to start/stop ESD thread
+ */
+void sde_connector_schedule_status_work(struct drm_connector *conn, bool en);
+
 #endif /* _SDE_CONNECTOR_H_ */
diff --git a/drivers/gpu/drm/msm/sde/sde_core_irq.c b/drivers/gpu/drm/msm/sde/sde_core_irq.c
index 1402fdd..a0846ff 100644
--- a/drivers/gpu/drm/msm/sde/sde_core_irq.c
+++ b/drivers/gpu/drm/msm/sde/sde_core_irq.c
@@ -31,14 +31,17 @@
 	struct sde_irq *irq_obj = &sde_kms->irq_obj;
 	struct sde_irq_callback *cb;
 	unsigned long irq_flags;
+	bool cb_tbl_error = false;
+	int enable_counts = 0;
 
 	pr_debug("irq_idx=%d\n", irq_idx);
 
+	spin_lock_irqsave(&sde_kms->irq_obj.cb_lock, irq_flags);
 	if (list_empty(&irq_obj->irq_cb_tbl[irq_idx])) {
-		SDE_ERROR("irq_idx=%d has no registered callback\n", irq_idx);
-		SDE_EVT32_IRQ(irq_idx, atomic_read(
-				&sde_kms->irq_obj.enable_counts[irq_idx]),
-				SDE_EVTLOG_ERROR);
+		/* print error outside lock */
+		cb_tbl_error = true;
+		enable_counts = atomic_read(
+				&sde_kms->irq_obj.enable_counts[irq_idx]);
 	}
 
 	atomic_inc(&irq_obj->irq_counts[irq_idx]);
@@ -46,12 +49,17 @@
 	/*
 	 * Perform registered function callback
 	 */
-	spin_lock_irqsave(&sde_kms->irq_obj.cb_lock, irq_flags);
 	list_for_each_entry(cb, &irq_obj->irq_cb_tbl[irq_idx], list)
 		if (cb->func)
 			cb->func(cb->arg, irq_idx);
 	spin_unlock_irqrestore(&sde_kms->irq_obj.cb_lock, irq_flags);
 
+	if (cb_tbl_error) {
+		SDE_ERROR("irq has no registered callback, idx %d enables %d\n",
+				irq_idx, enable_counts);
+		SDE_EVT32_IRQ(irq_idx, enable_counts, SDE_EVTLOG_ERROR);
+	}
+
 	/*
 	 * Clear pending interrupt status in HW.
 	 * NOTE: sde_core_irq_callback_handler is protected by top-level
diff --git a/drivers/gpu/drm/msm/sde/sde_core_perf.c b/drivers/gpu/drm/msm/sde/sde_core_perf.c
index 7243fe2..9ddca8c 100644
--- a/drivers/gpu/drm/msm/sde/sde_core_perf.c
+++ b/drivers/gpu/drm/msm/sde/sde_core_perf.c
@@ -722,6 +722,12 @@
 			(u32 *)&catalog->perf.max_bw_low);
 	debugfs_create_u32("threshold_high", 0600, perf->debugfs_root,
 			(u32 *)&catalog->perf.max_bw_high);
+	debugfs_create_u32("min_core_ib", 0600, perf->debugfs_root,
+			(u32 *)&catalog->perf.min_core_ib);
+	debugfs_create_u32("min_llcc_ib", 0600, perf->debugfs_root,
+			(u32 *)&catalog->perf.min_llcc_ib);
+	debugfs_create_u32("min_dram_ib", 0600, perf->debugfs_root,
+			(u32 *)&catalog->perf.min_dram_ib);
 	debugfs_create_file("perf_mode", 0600, perf->debugfs_root,
 			(u32 *)perf, &sde_core_perf_mode_fops);
 	debugfs_create_u32("bw_vote_mode", 0600, perf->debugfs_root,
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c
index 8397e1c..23ca2e9 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.c
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.c
@@ -48,14 +48,6 @@
 #define MEM_PROTECT_SD_CTRL_SWITCH 0x18
 #define MDP_DEVICE_ID            0x1A
 
-struct sde_crtc_irq_info {
-	struct sde_irq_callback irq;
-	u32 event;
-	int (*func)(struct drm_crtc *crtc, bool en,
-			struct sde_irq_callback *irq);
-	struct list_head list;
-};
-
 struct sde_crtc_custom_events {
 	u32 event;
 	int (*func)(struct drm_crtc *crtc, bool en,
@@ -67,14 +59,11 @@
 static int sde_crtc_idle_interrupt_handler(struct drm_crtc *crtc_drm,
 	bool en, struct sde_irq_callback *idle_irq);
 
-static int sde_crtc_pm_event_handler(struct drm_crtc *crtc_drm,
-	bool en, struct sde_irq_callback *noirq);
-
 static struct sde_crtc_custom_events custom_events[] = {
 	{DRM_EVENT_AD_BACKLIGHT, sde_cp_ad_interrupt},
 	{DRM_EVENT_CRTC_POWER, sde_crtc_power_interrupt_handler},
-	{DRM_EVENT_SDE_POWER, sde_crtc_pm_event_handler},
-	{DRM_EVENT_IDLE_NOTIFY, sde_crtc_idle_interrupt_handler}
+	{DRM_EVENT_IDLE_NOTIFY, sde_crtc_idle_interrupt_handler},
+	{DRM_EVENT_HISTOGRAM, sde_cp_hist_interrupt},
 };
 
 /* default input fence timeout, in ms */
@@ -615,6 +604,18 @@
 		return;
 }
 
+/**
+ * sde_crtc_destroy_dest_scaler - free memory allocated for scaler lut
+ * @sde_crtc: Pointer to sde crtc
+ */
+static void _sde_crtc_destroy_dest_scaler(struct sde_crtc *sde_crtc)
+{
+	if (!sde_crtc)
+		return;
+
+	kfree(sde_crtc->scl3_lut_cfg);
+}
+
 static void sde_crtc_destroy(struct drm_crtc *crtc)
 {
 	struct sde_crtc *sde_crtc = to_sde_crtc(crtc);
@@ -628,6 +629,7 @@
 		drm_property_unreference_blob(sde_crtc->blob_info);
 	msm_property_destroy(&sde_crtc->property_info);
 	sde_cp_crtc_destroy_properties(crtc);
+	_sde_crtc_destroy_dest_scaler(sde_crtc);
 
 	sde_fence_deinit(&sde_crtc->output_fence);
 	_sde_crtc_deinit_events(sde_crtc);
@@ -643,8 +645,9 @@
 {
 	SDE_DEBUG("\n");
 
-	if (msm_is_mode_seamless(adjusted_mode) &&
-		(!crtc->enabled || crtc->state->active_changed)) {
+	if ((msm_is_mode_seamless(adjusted_mode) ||
+			msm_is_mode_seamless_vrr(adjusted_mode)) &&
+		(!crtc->enabled)) {
 		SDE_ERROR("crtc state prevents seamless transition\n");
 		return false;
 	}
@@ -794,7 +797,7 @@
 }
 
 static int _sde_crtc_set_roi_v1(struct drm_crtc_state *state,
-		void *usr_ptr)
+		void __user *usr_ptr)
 {
 	struct drm_crtc *crtc;
 	struct sde_crtc_state *cstate;
@@ -916,23 +919,6 @@
 
 	sde_kms_rect_merge_rectangles(&crtc_state->user_roi_list, crtc_roi);
 
-	/*
-	 * for 3dmux dsc, make sure is full ROI, since current driver doesn't
-	 * support partial update for this configuration.
-	 */
-	if (!sde_kms_rect_is_null(crtc_roi) &&
-		_sde_crtc_setup_is_3dmux_dsc(state)) {
-		struct drm_display_mode *adj_mode = &state->adjusted_mode;
-
-		if (crtc_roi->w != adj_mode->hdisplay ||
-			crtc_roi->h != adj_mode->vdisplay) {
-			SDE_ERROR("%s: unsupported top roi[%d %d] wxh[%d %d]\n",
-				sde_crtc->name, crtc_roi->w, crtc_roi->h,
-				adj_mode->hdisplay, adj_mode->vdisplay);
-			return -EINVAL;
-		}
-	}
-
 	SDE_DEBUG("%s: crtc roi (%d,%d,%d,%d)\n", sde_crtc->name,
 			crtc_roi->x, crtc_roi->y, crtc_roi->w, crtc_roi->h);
 
@@ -1003,6 +989,18 @@
 	SDE_DEBUG("%s: lm%d roi (%d,%d,%d,%d)\n", sde_crtc->name, lm_idx,
 			lm_roi->x, lm_roi->y, lm_roi->w, lm_roi->h);
 
+	/*
+	 * partial update is not supported with 3dmux dsc or dest scaler.
+	 * hence, crtc roi must match the mixer dimensions.
+	 */
+	if (crtc_state->num_ds_enabled ||
+		_sde_crtc_setup_is_3dmux_dsc(state)) {
+		if (memcmp(lm_roi, lm_bounds, sizeof(struct sde_rect))) {
+			SDE_ERROR("Unsupported: Dest scaler/3d mux DSC + PU\n");
+			return -EINVAL;
+		}
+	}
+
 	/* if any dimension is zero, clear all dimensions for clarity */
 	if (sde_kms_rect_is_null(lm_roi))
 		memset(lm_roi, 0, sizeof(*lm_roi));
@@ -1267,7 +1265,7 @@
 	struct sde_hw_stage_cfg *stage_cfg;
 	struct sde_rect plane_crtc_roi;
 
-	u32 flush_mask, flush_sbuf, flush_tmp;
+	u32 flush_mask, flush_sbuf;
 	uint32_t stage_idx, lm_idx;
 	int zpos_cnt[SDE_STAGE_MAX + 1] = { 0 };
 	int i;
@@ -1283,10 +1281,9 @@
 	lm = mixer->hw_lm;
 	stage_cfg = &sde_crtc->stage_cfg;
 	cstate = to_sde_crtc_state(crtc->state);
-	flush_sbuf = 0x0;
 
-	cstate->sbuf_cfg.rot_op_mode = SDE_CTL_ROT_OP_MODE_OFFLINE;
 	cstate->sbuf_prefill_line = 0;
+	sde_crtc->sbuf_flush_mask = 0x0;
 
 	drm_atomic_crtc_for_each_plane(plane, crtc) {
 		state = plane->state;
@@ -1301,17 +1298,14 @@
 		pstate = to_sde_plane_state(state);
 		fb = state->fb;
 
-		if (sde_plane_is_sbuf_mode(plane, &prefill))
-			cstate->sbuf_cfg.rot_op_mode =
-					SDE_CTL_ROT_OP_MODE_INLINE_SYNC;
+		prefill = sde_plane_rot_calc_prefill(plane);
 		if (prefill > cstate->sbuf_prefill_line)
 			cstate->sbuf_prefill_line = prefill;
 
-		sde_plane_get_ctl_flush(plane, ctl, &flush_mask, &flush_tmp);
+		sde_plane_get_ctl_flush(plane, ctl, &flush_mask, &flush_sbuf);
 
-		/* persist rotator flush bit(s) for one more commit */
-		flush_mask |= cstate->sbuf_flush_mask | flush_tmp;
-		flush_sbuf |= flush_tmp;
+		/* save sbuf flush value for later */
+		sde_crtc->sbuf_flush_mask |= flush_sbuf;
 
 		SDE_DEBUG("crtc %d stage:%d - plane %d sspp %d fb %d\n",
 				crtc->base.id,
@@ -1335,8 +1329,7 @@
 				state->src_w >> 16, state->src_h >> 16,
 				state->crtc_x, state->crtc_y,
 				state->crtc_w, state->crtc_h,
-				flush_tmp ? cstate->sbuf_cfg.rot_op_mode :
-				SDE_CTL_ROT_OP_MODE_OFFLINE);
+				flush_sbuf != 0);
 
 		stage_idx = zpos_cnt[pstate->stage]++;
 		stage_cfg->stage[pstate->stage][stage_idx] =
@@ -1363,8 +1356,6 @@
 		}
 	}
 
-	cstate->sbuf_flush_mask = flush_sbuf;
-
 	if (lm && lm->ops.setup_dim_layer) {
 		cstate = to_sde_crtc_state(crtc->state);
 		for (i = 0; i < cstate->num_dim_layers; i++)
@@ -1506,6 +1497,7 @@
 
 		lm->ops.setup_alpha_out(lm, mixer[i].mixer_op_mode);
 
+		mixer[i].pipe_mask = mixer[i].flush_mask;
 		mixer[i].flush_mask |= ctl->ops.get_bitmask_mixer(ctl,
 			mixer[i].hw_lm->idx);
 
@@ -1528,7 +1520,6 @@
 static int _sde_crtc_find_plane_fb_modes(struct drm_crtc_state *state,
 		uint32_t *fb_ns,
 		uint32_t *fb_sec,
-		uint32_t *fb_ns_dir,
 		uint32_t *fb_sec_dir)
 {
 	struct drm_plane *plane;
@@ -1544,7 +1535,6 @@
 
 	*fb_ns = 0;
 	*fb_sec = 0;
-	*fb_ns_dir = 0;
 	*fb_sec_dir = 0;
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
 		if (IS_ERR_OR_NULL(pstate)) {
@@ -1564,16 +1554,12 @@
 		case SDE_DRM_FB_SEC:
 			(*fb_sec)++;
 			break;
-		case SDE_DRM_FB_NON_SEC_DIR_TRANS:
-			(*fb_ns_dir)++;
-			break;
 		case SDE_DRM_FB_SEC_DIR_TRANS:
 			(*fb_sec_dir)++;
 			break;
 		default:
 			SDE_ERROR("Error: Plane[%d], fb_trans_mode:%d",
-					plane->base.id,
-					mode);
+					plane->base.id, mode);
 			return -EINVAL;
 		}
 	}
@@ -1597,7 +1583,7 @@
 	struct sde_crtc *sde_crtc;
 	struct sde_crtc_state *cstate;
 	struct sde_crtc_smmu_state_data *smmu_state;
-	uint32_t translation_mode = 0;
+	uint32_t translation_mode = 0, secure_level;
 	int ops  = 0;
 	bool post_commit = false;
 
@@ -1609,10 +1595,10 @@
 	sde_crtc = to_sde_crtc(crtc);
 	cstate = to_sde_crtc_state(crtc->state);
 	smmu_state = &sde_crtc->smmu_state;
+	secure_level = sde_crtc_get_secure_level(crtc, crtc->state);
 
-	SDE_DEBUG("crtc%d, secure_level%d\n",
-			crtc->base.id,
-			sde_crtc_get_secure_level(crtc, crtc->state));
+	SDE_DEBUG("crtc%d, secure_level%d old_valid_fb%d\n",
+			crtc->base.id, secure_level, old_valid_fb);
 
 	/**
 	 * SMMU operations need to be delayed in case of
@@ -1636,8 +1622,7 @@
 				PLANE_PROP_FB_TRANSLATION_MODE);
 		if (translation_mode > SDE_DRM_FB_SEC_DIR_TRANS) {
 			SDE_ERROR("crtc%d, invalid translation_mode%d\n",
-					crtc->base.id,
-					translation_mode);
+					crtc->base.id, translation_mode);
 			return -EINVAL;
 		}
 
@@ -1645,14 +1630,15 @@
 		 * we can break if we find sec_fir or non_sec_dir
 		 * plane
 		 */
-		if ((translation_mode == SDE_DRM_FB_NON_SEC_DIR_TRANS) ||
-			(translation_mode == SDE_DRM_FB_SEC_DIR_TRANS))
+		if (translation_mode == SDE_DRM_FB_SEC_DIR_TRANS)
 			break;
 	}
 
 	switch (translation_mode) {
-	case SDE_DRM_FB_NON_SEC_DIR_TRANS:
-		if (smmu_state->state == ATTACHED) {
+	case SDE_DRM_FB_SEC_DIR_TRANS:
+		/* secure display usecase */
+		if ((smmu_state->state == ATTACHED) &&
+				(secure_level == SDE_DRM_SEC_ONLY)) {
 			smmu_state->state = DETACH_ALL_REQ;
 			smmu_state->transition_type = PRE_COMMIT;
 			ops |= SDE_KMS_OPS_CRTC_SECURE_STATE_CHANGE;
@@ -1660,10 +1646,8 @@
 				ops |= (SDE_KMS_OPS_WAIT_FOR_TX_DONE  |
 					SDE_KMS_OPS_CLEANUP_PLANE_FB);
 			}
-		}
-		break;
-	case SDE_DRM_FB_SEC_DIR_TRANS:
-		if (smmu_state->state == ATTACHED) {
+		/* secure camera usecase */
+		} else if (smmu_state->state == ATTACHED) {
 			smmu_state->state = DETACH_SEC_REQ;
 			smmu_state->transition_type = PRE_COMMIT;
 			ops |= SDE_KMS_OPS_CRTC_SECURE_STATE_CHANGE;
@@ -1671,34 +1655,33 @@
 		break;
 	case SDE_DRM_FB_SEC:
 	case SDE_DRM_FB_NON_SEC:
-		if (smmu_state->state == DETACHED_SEC) {
+		if ((smmu_state->state == DETACHED_SEC) ||
+			(smmu_state->state == DETACH_SEC_REQ)) {
 			smmu_state->state = ATTACH_SEC_REQ;
 			smmu_state->transition_type = post_commit ?
 				POST_COMMIT : PRE_COMMIT;
 			ops |= SDE_KMS_OPS_CRTC_SECURE_STATE_CHANGE;
-			if (translation_mode == SDE_DRM_FB_SEC)
-				ops |= SDE_KMS_OPS_PREPARE_PLANE_FB;
-		} else if (smmu_state->state == DETACHED) {
+			if (old_valid_fb)
+				ops |= SDE_KMS_OPS_WAIT_FOR_TX_DONE;
+		} else if ((smmu_state->state == DETACHED) ||
+				(smmu_state->state == DETACH_ALL_REQ)) {
 			smmu_state->state = ATTACH_ALL_REQ;
 			smmu_state->transition_type = post_commit ?
 				POST_COMMIT : PRE_COMMIT;
-			ops |= SDE_KMS_OPS_CRTC_SECURE_STATE_CHANGE |
-				SDE_KMS_OPS_PREPARE_PLANE_FB;
+			ops |= SDE_KMS_OPS_CRTC_SECURE_STATE_CHANGE;
 			if (old_valid_fb)
 				ops |= (SDE_KMS_OPS_WAIT_FOR_TX_DONE |
 				 SDE_KMS_OPS_CLEANUP_PLANE_FB);
 		}
 		break;
 	default:
-		SDE_ERROR("invalid plane fb_mode:%d\n",
-				translation_mode);
+		SDE_ERROR("invalid plane fb_mode:%d\n", translation_mode);
 		ops = 0;
 		return -EINVAL;
 	}
 
 	SDE_DEBUG("SMMU State:%d, type:%d ops:%x\n", smmu_state->state,
-			smmu_state->transition_type,
-			ops);
+			smmu_state->transition_type, ops);
 	return ops;
 }
 
@@ -1726,13 +1709,13 @@
 	 */
 	sec_sid[0] = SEC_SID_MASK_0;
 	sec_sid[1] = SEC_SID_MASK_1;
-	dmac_flush_range(&sec_sid, &sec_sid + num_sids);
+	dmac_flush_range(sec_sid, sec_sid + num_sids);
 
 	SDE_DEBUG("calling scm_call for vmid %d", vmid);
 
 	desc.arginfo = SCM_ARGS(4, SCM_VAL, SCM_RW, SCM_VAL, SCM_VAL);
 	desc.args[0] = MDP_DEVICE_ID;
-	desc.args[1] = SCM_BUFFER_PHYS(&sec_sid);
+	desc.args[1] = SCM_BUFFER_PHYS(sec_sid);
 	desc.args[2] = sizeof(uint32_t) * num_sids;
 	desc.args[3] =  vmid;
 
@@ -1740,8 +1723,7 @@
 				mem_protect_sd_ctrl_id), &desc);
 	if (ret) {
 		SDE_ERROR("Error:scm_call2, vmid (%lld): ret%d\n",
-				desc.args[3],
-				ret);
+				desc.args[3], ret);
 	}
 
 	kfree(sec_sid);
@@ -1749,6 +1731,64 @@
 }
 
 /**
+ * _sde_crtc_setup_scaler3_lut - Set up scaler lut
+ * LUTs are configured only once during boot
+ * @sde_crtc: Pointer to sde crtc
+ * @cstate: Pointer to sde crtc state
+ */
+static int _sde_crtc_set_dest_scaler_lut(struct sde_crtc *sde_crtc,
+		struct sde_crtc_state *cstate, uint32_t lut_idx)
+{
+	struct sde_hw_scaler3_lut_cfg *cfg;
+	u32 *lut_data = NULL;
+	size_t len = 0;
+	int ret = 0;
+
+	if (!sde_crtc || !cstate || !sde_crtc->scl3_lut_cfg) {
+		SDE_ERROR("invalid args\n");
+		return -EINVAL;
+	}
+
+	if (sde_crtc->scl3_lut_cfg->is_configured) {
+		SDE_DEBUG("lut already configured\n");
+		return 0;
+	}
+
+	lut_data = msm_property_get_blob(&sde_crtc->property_info,
+			&cstate->property_state, &len, lut_idx);
+	if (!lut_data || !len) {
+		SDE_ERROR("lut(%d): no data, len(%zu)\n", lut_idx, len);
+		return -ENODATA;
+	}
+
+	cfg = sde_crtc->scl3_lut_cfg;
+
+	switch (lut_idx) {
+	case CRTC_PROP_DEST_SCALER_LUT_ED:
+		cfg->dir_lut = lut_data;
+		cfg->dir_len = len;
+		break;
+	case CRTC_PROP_DEST_SCALER_LUT_CIR:
+		cfg->cir_lut = lut_data;
+		cfg->cir_len = len;
+		break;
+	case CRTC_PROP_DEST_SCALER_LUT_SEP:
+		cfg->sep_lut = lut_data;
+		cfg->sep_len = len;
+		break;
+	default:
+		ret = -EINVAL;
+		SDE_ERROR("invalid LUT index = %d", lut_idx);
+		break;
+	}
+
+	if (cfg->dir_lut && cfg->cir_lut && cfg->sep_lut)
+		cfg->is_configured = true;
+
+	return ret;
+}
+
+/**
  * sde_crtc_secure_ctrl - Initiates the operations to swtich  between secure
  *                       and non-secure mode
  * @crtc: Pointer to crtc
@@ -1784,7 +1824,6 @@
 		/* Bail out */
 		return 0;
 
-
 	/* Secure UI use case enable */
 	switch (smmu_state->state) {
 	case DETACH_ALL_REQ:
@@ -1860,14 +1899,112 @@
 	SDE_DEBUG("crtc: %d, old_state %d new_state %d\n", crtc->base.id,
 			old_smmu_state,
 			smmu_state->state);
-	smmu_state->transition_error = false;
 	smmu_state->transition_type = NONE;
 
 error:
-	smmu_state->transition_error = true;
+	smmu_state->transition_error = ret ? true : false;
 	return ret;
 }
 
+/**
+ * _sde_crtc_dest_scaler_setup - Set up dest scaler block
+ * @crtc: Pointer to drm crtc
+ */
+static void _sde_crtc_dest_scaler_setup(struct drm_crtc *crtc)
+{
+	struct sde_crtc *sde_crtc;
+	struct sde_crtc_state *cstate;
+	struct sde_hw_mixer *hw_lm;
+	struct sde_hw_ctl *hw_ctl;
+	struct sde_hw_ds *hw_ds;
+	struct sde_hw_ds_cfg *cfg;
+	struct sde_kms *kms;
+	u32 flush_mask = 0, op_mode = 0;
+	u32 lm_idx = 0, num_mixers = 0;
+	int i, count = 0;
+
+	if (!crtc)
+		return;
+
+	sde_crtc   = to_sde_crtc(crtc);
+	cstate = to_sde_crtc_state(crtc->state);
+	kms    = _sde_crtc_get_kms(crtc);
+	num_mixers = sde_crtc->num_mixers;
+
+	SDE_DEBUG("crtc%d\n", crtc->base.id);
+
+	if (!cstate->ds_dirty) {
+		SDE_DEBUG("no change in settings, skip commit\n");
+	} else if (!kms || !kms->catalog) {
+		SDE_ERROR("invalid parameters\n");
+	} else if (!kms->catalog->mdp[0].has_dest_scaler) {
+		SDE_DEBUG("dest scaler feature not supported\n");
+	} else if (num_mixers > CRTC_DUAL_MIXERS) {
+		SDE_ERROR("invalid number mixers: %d\n", num_mixers);
+	} else if (!sde_crtc->scl3_lut_cfg->is_configured) {
+		SDE_DEBUG("no LUT data available\n");
+	} else {
+		count = cstate->num_ds_enabled ? cstate->num_ds : num_mixers;
+
+		for (i = 0; i < count; i++) {
+			cfg = &cstate->ds_cfg[i];
+
+			if (!cfg->flags)
+				continue;
+
+			lm_idx = cfg->ndx;
+			hw_lm  = sde_crtc->mixers[lm_idx].hw_lm;
+			hw_ctl = sde_crtc->mixers[lm_idx].hw_ctl;
+			hw_ds  = sde_crtc->mixers[lm_idx].hw_ds;
+
+			/* Setup op mode - Dual/single */
+			if (cfg->flags & SDE_DRM_DESTSCALER_ENABLE)
+				op_mode |= BIT(hw_ds->idx - DS_0);
+
+			if ((i == count-1) && hw_ds->ops.setup_opmode) {
+				op_mode |= (cstate->num_ds_enabled ==
+					CRTC_DUAL_MIXERS) ?
+					SDE_DS_OP_MODE_DUAL : 0;
+				hw_ds->ops.setup_opmode(hw_ds, op_mode);
+				SDE_EVT32(DRMID(crtc), op_mode);
+			}
+
+			/* Setup scaler */
+			if ((cfg->flags & SDE_DRM_DESTSCALER_SCALE_UPDATE) ||
+				(cfg->flags &
+					SDE_DRM_DESTSCALER_ENHANCER_UPDATE)) {
+				if (hw_ds->ops.setup_scaler)
+					hw_ds->ops.setup_scaler(hw_ds,
+							cfg->scl3_cfg,
+							sde_crtc->scl3_lut_cfg);
+
+				/**
+				 * Clear the flags as the block doesn't have to
+				 * be programmed in each commit if no updates
+				 */
+				cfg->flags &= ~SDE_DRM_DESTSCALER_SCALE_UPDATE;
+				cfg->flags &=
+					~SDE_DRM_DESTSCALER_ENHANCER_UPDATE;
+			}
+
+			/*
+			 * Dest scaler shares the flush bit of the LM in control
+			 */
+			if (cfg->set_lm_flush && hw_lm && hw_ctl &&
+				hw_ctl->ops.get_bitmask_mixer) {
+				flush_mask = hw_ctl->ops.get_bitmask_mixer(
+						hw_ctl, hw_lm->idx);
+				SDE_DEBUG("Set lm[%d] flush = %d",
+					hw_lm->idx, flush_mask);
+				hw_ctl->ops.update_pending_flush(hw_ctl,
+								flush_mask);
+			}
+			cfg->set_lm_flush = false;
+		}
+		cstate->ds_dirty = false;
+	}
+}
+
 void sde_crtc_prepare_commit(struct drm_crtc *crtc,
 		struct drm_crtc_state *old_state)
 {
@@ -2026,6 +2163,47 @@
 	SDE_ATRACE_END("signal_retire_fence");
 }
 
+/* _sde_crtc_idle_notify - signal idle timeout to client */
+static void _sde_crtc_idle_notify(struct sde_crtc *sde_crtc)
+{
+	struct drm_crtc *crtc;
+	struct drm_event event;
+	int ret = 0;
+
+	if (!sde_crtc) {
+		SDE_ERROR("invalid sde crtc\n");
+		return;
+	}
+
+	crtc = &sde_crtc->base;
+	event.type = DRM_EVENT_IDLE_NOTIFY;
+	event.length = sizeof(u32);
+	msm_mode_object_event_notify(&crtc->base, crtc->dev, &event,
+								(u8 *)&ret);
+
+	SDE_DEBUG("crtc:%d idle timeout notified\n", crtc->base.id);
+}
+
+/*
+ * sde_crtc_handle_event - crtc frame event handle.
+ * This API must manage only non-IRQ context events.
+ */
+static bool _sde_crtc_handle_event(struct sde_crtc *sde_crtc, u32 event)
+{
+	bool event_processed = false;
+
+	/**
+	 * idle events are originated from commit thread and can be processed
+	 * in same context
+	 */
+	if (event & SDE_ENCODER_FRAME_EVENT_IDLE) {
+		_sde_crtc_idle_notify(sde_crtc);
+		event_processed = true;
+	}
+
+	return event_processed;
+}
+
 static void sde_crtc_frame_event_work(struct kthread_work *work)
 {
 	struct msm_drm_private *priv;
@@ -2119,6 +2297,15 @@
 	SDE_ATRACE_END("crtc_frame_event");
 }
 
+/*
+ * sde_crtc_frame_event_cb - crtc frame event callback API. CRTC module
+ * registers this API to encoder for all frame event callbacks like
+ * release_fence, retire_fence, frame_error, frame_done, idle_timeout,
+ * etc. Encoder may call different events from different context - IRQ,
+ * user thread, commit_thread, etc. Each event should be carefully
+ * reviewed and should be processed in proper task context to avoid scheduling
+ * delay or properly manage the irq context's bottom half processing.
+ */
 static void sde_crtc_frame_event_cb(void *data, u32 event)
 {
 	struct drm_crtc *crtc = (struct drm_crtc *)data;
@@ -2127,6 +2314,7 @@
 	struct sde_crtc_frame_event *fevent;
 	unsigned long flags;
 	u32 crtc_id;
+	bool event_processed = false;
 
 	if (!crtc || !crtc->dev || !crtc->dev->dev_private) {
 		SDE_ERROR("invalid parameters\n");
@@ -2139,6 +2327,11 @@
 	SDE_DEBUG("crtc%d\n", crtc->base.id);
 	SDE_EVT32_VERBOSE(DRMID(crtc), event);
 
+	/* try to process the event in caller context */
+	event_processed = _sde_crtc_handle_event(sde_crtc, event);
+	if (event_processed)
+		return;
+
 	spin_lock_irqsave(&sde_crtc->spin_lock, flags);
 	fevent = list_first_entry_or_null(&sde_crtc->frame_event_list,
 			struct sde_crtc_frame_event, list);
@@ -2179,6 +2372,24 @@
 		sde_crtc_secure_ctrl(crtc, true);
 }
 
+/* _sde_crtc_set_idle_timeout - update idle timeout wait duration */
+static void _sde_crtc_set_idle_timeout(struct drm_crtc *crtc, u64 val)
+{
+	struct drm_encoder *encoder;
+
+	if (!crtc) {
+		SDE_ERROR("invalid crtc\n");
+		return;
+	}
+
+	drm_for_each_encoder(encoder, crtc->dev) {
+		if (encoder->crtc != crtc)
+			continue;
+
+		sde_encoder_set_idle_timeout(encoder, (u32) val);
+	}
+}
+
 /**
  * _sde_crtc_set_input_fence_timeout - update ns version of in fence timeout
  * @cstate: Pointer to sde crtc state
@@ -2200,7 +2411,7 @@
  * @user_ptr:    User ptr for sde_drm_dim_layer_v1 struct
  */
 static void _sde_crtc_set_dim_layer_v1(struct sde_crtc_state *cstate,
-		void *usr_ptr)
+		void __user *usr_ptr)
 {
 	struct sde_drm_dim_layer_v1 dim_layer_v1;
 	struct sde_drm_dim_layer_cfg *user_cfg;
@@ -2262,6 +2473,363 @@
 }
 
 /**
+ * _sde_crtc_dest_scaler_init - allocate memory for scaler lut
+ * @sde_crtc    :  Pointer to sde crtc
+ * @catalog :  Pointer to mdss catalog info
+ */
+static void _sde_crtc_dest_scaler_init(struct sde_crtc *sde_crtc,
+				struct sde_mdss_cfg *catalog)
+{
+	if (!sde_crtc || !catalog)
+		return;
+
+	if (!catalog->mdp[0].has_dest_scaler) {
+		SDE_DEBUG("dest scaler feature not supported\n");
+		return;
+	}
+
+	sde_crtc->scl3_lut_cfg = kzalloc(sizeof(struct sde_hw_scaler3_lut_cfg),
+				GFP_KERNEL);
+	if (!sde_crtc->scl3_lut_cfg)
+		SDE_ERROR("failed to create scale LUT for dest scaler");
+}
+
+/**
+ * _sde_crtc_set_dest_scaler - copy dest scaler settings from userspace
+ * @sde_crtc   :  Pointer to sde crtc
+ * @cstate :  Pointer to sde crtc state
+ * @usr_ptr:  User ptr for sde_drm_dest_scaler_data struct
+ */
+static int _sde_crtc_set_dest_scaler(struct sde_crtc *sde_crtc,
+				struct sde_crtc_state *cstate,
+				void __user *usr_ptr)
+{
+	struct sde_drm_dest_scaler_data ds_data;
+	struct sde_drm_dest_scaler_cfg *ds_cfg_usr;
+	struct sde_drm_scaler_v2 scaler_v2;
+	void __user *scaler_v2_usr;
+	int i, count, ret = 0;
+
+	if (!sde_crtc || !cstate) {
+		SDE_ERROR("invalid sde_crtc/state\n");
+		return -EINVAL;
+	}
+
+	SDE_DEBUG("crtc %s\n", sde_crtc->name);
+
+	cstate->num_ds = 0;
+	cstate->ds_dirty = false;
+	if (!usr_ptr) {
+		SDE_DEBUG("ds data removed\n");
+		return 0;
+	}
+
+	if (copy_from_user(&ds_data, usr_ptr, sizeof(ds_data))) {
+		SDE_ERROR("failed to copy dest scaler data from user\n");
+		return -EINVAL;
+	}
+
+	count = ds_data.num_dest_scaler;
+	if (!sde_crtc->num_mixers || count > sde_crtc->num_mixers ||
+		(count && (count != sde_crtc->num_mixers) &&
+		!(ds_data.ds_cfg[0].flags & SDE_DRM_DESTSCALER_PU_ENABLE))) {
+		SDE_ERROR("invalid config:num ds(%d), mixers(%d),flags(%d)\n",
+			count, sde_crtc->num_mixers, ds_data.ds_cfg[0].flags);
+		return -EINVAL;
+	}
+
+	/* Populate from user space */
+	for (i = 0; i < count; i++) {
+		ds_cfg_usr = &ds_data.ds_cfg[i];
+
+		cstate->ds_cfg[i].ndx = ds_cfg_usr->index;
+		cstate->ds_cfg[i].flags = ds_cfg_usr->flags;
+		cstate->ds_cfg[i].lm_width = ds_cfg_usr->lm_width;
+		cstate->ds_cfg[i].lm_height = ds_cfg_usr->lm_height;
+		cstate->ds_cfg[i].scl3_cfg = NULL;
+
+		if (ds_cfg_usr->scaler_cfg) {
+			scaler_v2_usr =
+			(void __user *)((uintptr_t)ds_cfg_usr->scaler_cfg);
+
+			memset(&scaler_v2, 0, sizeof(scaler_v2));
+
+			cstate->ds_cfg[i].scl3_cfg =
+				kzalloc(sizeof(struct sde_hw_scaler3_cfg),
+					GFP_KERNEL);
+
+			if (!cstate->ds_cfg[i].scl3_cfg) {
+				ret = -ENOMEM;
+				goto err;
+			}
+
+			if (copy_from_user(&scaler_v2, scaler_v2_usr,
+					sizeof(scaler_v2))) {
+				SDE_ERROR("scale data:copy from user failed\n");
+				ret = -EINVAL;
+				goto err;
+			}
+
+			sde_set_scaler_v2(cstate->ds_cfg[i].scl3_cfg,
+					&scaler_v2);
+
+			SDE_DEBUG("en(%d)dir(%d)de(%d) src(%dx%d) dst(%dx%d)\n",
+				scaler_v2.enable, scaler_v2.dir_en,
+				scaler_v2.de.enable, scaler_v2.src_width[0],
+				scaler_v2.src_height[0], scaler_v2.dst_width,
+				scaler_v2.dst_height);
+			SDE_EVT32_VERBOSE(DRMID(&sde_crtc->base),
+				scaler_v2.enable, scaler_v2.dir_en,
+				scaler_v2.de.enable, scaler_v2.src_width[0],
+				scaler_v2.src_height[0], scaler_v2.dst_width,
+				scaler_v2.dst_height);
+		}
+
+		SDE_DEBUG("ds cfg[%d]-ndx(%d) flags(%d) lm(%dx%d)\n",
+			i, ds_cfg_usr->index, ds_cfg_usr->flags,
+			ds_cfg_usr->lm_width, ds_cfg_usr->lm_height);
+		SDE_EVT32_VERBOSE(DRMID(&sde_crtc->base), i, ds_cfg_usr->index,
+			ds_cfg_usr->flags, ds_cfg_usr->lm_width,
+			ds_cfg_usr->lm_height);
+	}
+
+	cstate->num_ds = count;
+	cstate->ds_dirty = true;
+	return 0;
+
+err:
+	for (; i >= 0; i--)
+		kfree(cstate->ds_cfg[i].scl3_cfg);
+
+	return ret;
+}
+
+/**
+ * _sde_crtc_check_dest_scaler_data - validate the dest scaler data
+ * @crtc  :  Pointer to drm crtc
+ * @state :  Pointer to drm crtc state
+ */
+static int _sde_crtc_check_dest_scaler_data(struct drm_crtc *crtc,
+				struct drm_crtc_state *state)
+{
+	struct sde_crtc *sde_crtc;
+	struct sde_crtc_state *cstate;
+	struct drm_display_mode *mode;
+	struct sde_kms *kms;
+	struct sde_hw_ds *hw_ds;
+	struct sde_hw_ds_cfg *cfg;
+	u32 i, ret = 0, lm_idx;
+	u32 num_ds_enable = 0;
+	u32 max_in_width = 0, max_out_width = 0;
+	u32 prev_lm_width = 0, prev_lm_height = 0;
+
+	if (!crtc || !state)
+		return -EINVAL;
+
+	sde_crtc = to_sde_crtc(crtc);
+	cstate = to_sde_crtc_state(state);
+	kms = _sde_crtc_get_kms(crtc);
+	mode = &state->adjusted_mode;
+
+	SDE_DEBUG("crtc%d\n", crtc->base.id);
+
+	if (!cstate->ds_dirty && !cstate->num_ds_enabled) {
+		SDE_DEBUG("dest scaler property not set, skip validation\n");
+		return 0;
+	}
+
+	if (!kms || !kms->catalog) {
+		SDE_ERROR("invalid parameters\n");
+		return -EINVAL;
+	}
+
+	if (!kms->catalog->mdp[0].has_dest_scaler) {
+		SDE_DEBUG("dest scaler feature not supported\n");
+		return 0;
+	}
+
+	if (!sde_crtc->num_mixers) {
+		SDE_ERROR("mixers not allocated\n");
+		return -EINVAL;
+	}
+
+	/**
+	 * Check if sufficient hw resources are
+	 * available as per target caps & topology
+	 */
+	if (sde_crtc->num_mixers > CRTC_DUAL_MIXERS) {
+		SDE_ERROR("invalid config: mixers(%d) max(%d)\n",
+			sde_crtc->num_mixers, CRTC_DUAL_MIXERS);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	for (i = 0; i < sde_crtc->num_mixers; i++) {
+		if (!sde_crtc->mixers[i].hw_lm || !sde_crtc->mixers[i].hw_ds) {
+			SDE_ERROR("insufficient HW resources allocated\n");
+			ret = -EINVAL;
+			goto err;
+		}
+	}
+
+	/**
+	 * Check if DS needs to be enabled or disabled
+	 * In case of enable, validate the data
+	 */
+	if (!cstate->ds_dirty || !cstate->num_ds ||
+		!(cstate->ds_cfg[0].flags & SDE_DRM_DESTSCALER_ENABLE)) {
+		SDE_DEBUG("disable dest scaler,dirty(%d)num(%d)flags(%d)\n",
+			cstate->ds_dirty, cstate->num_ds,
+			cstate->ds_cfg[0].flags);
+		goto disable;
+	}
+
+	/**
+	 * No of dest scalers shouldn't exceed hw ds block count and
+	 * also, match the num of mixers unless it is partial update
+	 * left only/right only use case - currently PU + DS is not supported
+	 */
+	if (cstate->num_ds > kms->catalog->ds_count ||
+		((cstate->num_ds != sde_crtc->num_mixers) &&
+		!(cstate->ds_cfg[0].flags & SDE_DRM_DESTSCALER_PU_ENABLE))) {
+		SDE_ERROR("invalid cfg: num_ds(%d), hw_ds_cnt(%d) flags(%d)\n",
+			cstate->num_ds, kms->catalog->ds_count,
+			cstate->ds_cfg[0].flags);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* Validate the DS data */
+	for (i = 0; i < cstate->num_ds; i++) {
+		cfg = &cstate->ds_cfg[i];
+		lm_idx = cfg->ndx;
+
+		/**
+		 * Validate against topology
+		 * No of dest scalers should match the num of mixers
+		 * unless it is partial update left only/right only use case
+		 */
+		if (lm_idx >= sde_crtc->num_mixers || (i != lm_idx &&
+			!(cfg->flags & SDE_DRM_DESTSCALER_PU_ENABLE))) {
+			SDE_ERROR("invalid user data(%d):idx(%d), flags(%d)\n",
+				i, lm_idx, cfg->flags);
+			ret = -EINVAL;
+			goto err;
+		}
+
+		hw_ds = sde_crtc->mixers[lm_idx].hw_ds;
+
+		if (!max_in_width && !max_out_width) {
+			max_in_width = hw_ds->scl->top->maxinputwidth;
+			max_out_width = hw_ds->scl->top->maxoutputwidth;
+
+			if (cstate->num_ds == CRTC_DUAL_MIXERS)
+				max_in_width -= SDE_DS_OVERFETCH_SIZE;
+
+			SDE_DEBUG("max DS width [%d,%d] for num_ds = %d\n",
+				max_in_width, max_out_width, cstate->num_ds);
+		}
+
+		/* Check LM width and height */
+		if (cfg->lm_width > (mode->hdisplay/sde_crtc->num_mixers) ||
+			cfg->lm_height > mode->vdisplay ||
+			!cfg->lm_width || !cfg->lm_height) {
+			SDE_ERROR("invalid lm size[%d,%d] display [%d,%d]\n",
+				cfg->lm_width,
+				cfg->lm_height,
+				mode->hdisplay/sde_crtc->num_mixers,
+				mode->vdisplay);
+			ret = -E2BIG;
+			goto err;
+		}
+
+		if (!prev_lm_width && !prev_lm_height) {
+			prev_lm_width = cfg->lm_width;
+			prev_lm_height = cfg->lm_height;
+		} else {
+			if (cfg->lm_width != prev_lm_width ||
+				cfg->lm_height != prev_lm_height) {
+				SDE_ERROR("lm size:left[%d,%d], right[%d %d]\n",
+					cfg->lm_width, cfg->lm_height,
+					prev_lm_width, prev_lm_height);
+				ret = -EINVAL;
+				goto err;
+			}
+		}
+
+		/* Check scaler data */
+		if (cfg->flags & SDE_DRM_DESTSCALER_SCALE_UPDATE ||
+			cfg->flags & SDE_DRM_DESTSCALER_ENHANCER_UPDATE) {
+			if (!cfg->scl3_cfg) {
+				ret = -EINVAL;
+				SDE_ERROR("null scale data\n");
+				goto err;
+			}
+			if (cfg->scl3_cfg->src_width[0] > max_in_width ||
+				cfg->scl3_cfg->dst_width > max_out_width ||
+				!cfg->scl3_cfg->src_width[0] ||
+				!cfg->scl3_cfg->dst_width) {
+				SDE_ERROR("scale width(%d %d) for ds-%d:\n",
+					cfg->scl3_cfg->src_width[0],
+					cfg->scl3_cfg->dst_width,
+					hw_ds->idx - DS_0);
+				SDE_ERROR("scale_en = %d, DE_en =%d\n",
+					cfg->scl3_cfg->enable,
+					cfg->scl3_cfg->de.enable);
+
+				cfg->flags &=
+					~SDE_DRM_DESTSCALER_SCALE_UPDATE;
+				cfg->flags &=
+					~SDE_DRM_DESTSCALER_ENHANCER_UPDATE;
+
+				ret = -EINVAL;
+				goto err;
+			}
+		}
+
+		if (cfg->flags & SDE_DRM_DESTSCALER_ENABLE)
+			num_ds_enable++;
+
+		/**
+		 * Validation successful, indicator for flush to be issued
+		 */
+		cfg->set_lm_flush = true;
+
+		SDE_DEBUG("ds[%d]: flags = 0x%X\n",
+			hw_ds->idx - DS_0, cfg->flags);
+	}
+
+disable:
+	SDE_DEBUG("dest scaler enable status, old = %d, new = %d",
+		cstate->num_ds_enabled, num_ds_enable);
+	SDE_EVT32(DRMID(crtc), cstate->num_ds_enabled, num_ds_enable,
+		cstate->ds_dirty);
+
+	if (cstate->num_ds_enabled != num_ds_enable) {
+		/* Disabling destination scaler */
+		if (!num_ds_enable) {
+			for (i = 0; i < sde_crtc->num_mixers; i++) {
+				cfg = &cstate->ds_cfg[i];
+				cfg->ndx = i;
+				/* Update scaler settings in disable case */
+				cfg->flags = SDE_DRM_DESTSCALER_SCALE_UPDATE;
+				cfg->scl3_cfg->enable = 0;
+				cfg->scl3_cfg->de.enable = 0;
+				cfg->set_lm_flush = true;
+			}
+		}
+		cstate->num_ds_enabled = num_ds_enable;
+		cstate->ds_dirty = true;
+	}
+
+	return 0;
+
+err:
+	cstate->ds_dirty = false;
+	return ret;
+}
+
+/**
  * _sde_crtc_wait_for_fences - wait for incoming framebuffer sync fences
  * @crtc: Pointer to CRTC object
  */
@@ -2318,11 +2886,12 @@
 	struct sde_crtc_mixer *mixer;
 	struct sde_hw_ctl *last_valid_ctl = NULL;
 	int i;
-	struct sde_rm_hw_iter lm_iter, ctl_iter, dspp_iter;
+	struct sde_rm_hw_iter lm_iter, ctl_iter, dspp_iter, ds_iter;
 
 	sde_rm_init_hw_iter(&lm_iter, enc->base.id, SDE_HW_BLK_LM);
 	sde_rm_init_hw_iter(&ctl_iter, enc->base.id, SDE_HW_BLK_CTL);
 	sde_rm_init_hw_iter(&dspp_iter, enc->base.id, SDE_HW_BLK_DSPP);
+	sde_rm_init_hw_iter(&ds_iter, enc->base.id, SDE_HW_BLK_DS);
 
 	/* Set up all the mixers and ctls reserved by this encoder */
 	for (i = sde_crtc->num_mixers; i < ARRAY_SIZE(sde_crtc->mixers); i++) {
@@ -2353,6 +2922,10 @@
 		(void) sde_rm_get_hw(rm, &dspp_iter);
 		mixer->hw_dspp = (struct sde_hw_dspp *)dspp_iter.hw;
 
+		/* DS may be null */
+		(void) sde_rm_get_hw(rm, &ds_iter);
+		mixer->hw_ds = (struct sde_hw_ds *)ds_iter.hw;
+
 		mixer->encoder = enc;
 
 		sde_crtc->num_mixers++;
@@ -2360,6 +2933,9 @@
 				i, mixer->hw_lm->idx - LM_0);
 		SDE_DEBUG("setup mixer %d: ctl %d\n",
 				i, mixer->hw_ctl->idx - CTL_0);
+		if (mixer->hw_ds)
+			SDE_DEBUG("setup mixer %d: ds %d\n",
+				i, mixer->hw_ds->idx - DS_0);
 	}
 }
 
@@ -2369,6 +2945,7 @@
 	struct drm_encoder *enc;
 
 	sde_crtc->num_mixers = 0;
+	sde_crtc->mixers_swapped = false;
 	memset(sde_crtc->mixers, 0, sizeof(sde_crtc->mixers));
 
 	mutex_lock(&sde_crtc->crtc_lock);
@@ -2418,13 +2995,14 @@
 	cstate = to_sde_crtc_state(state);
 
 	adj_mode = &state->adjusted_mode;
-	crtc_split_width = sde_crtc_mixer_width(sde_crtc, adj_mode);
+	crtc_split_width = sde_crtc_get_mixer_width(sde_crtc, cstate, adj_mode);
 
 	for (i = 0; i < sde_crtc->num_mixers; i++) {
 		cstate->lm_bounds[i].x = crtc_split_width * i;
 		cstate->lm_bounds[i].y = 0;
 		cstate->lm_bounds[i].w = crtc_split_width;
-		cstate->lm_bounds[i].h = adj_mode->vdisplay;
+		cstate->lm_bounds[i].h =
+			sde_crtc_get_mixer_height(sde_crtc, cstate, adj_mode);
 		memcpy(&cstate->lm_roi[i], &cstate->lm_bounds[i],
 				sizeof(cstate->lm_roi[i]));
 		SDE_EVT32_VERBOSE(DRMID(crtc), i,
@@ -2494,13 +3072,8 @@
 	if (unlikely(!sde_crtc->num_mixers))
 		return;
 
-	/* cancel the idle notify delayed work */
-	if (sde_encoder_check_mode(sde_crtc->mixers[0].encoder,
-					MSM_DISPLAY_CAP_VID_MODE) &&
-		kthread_cancel_delayed_work_sync(&sde_crtc->idle_notify_work))
-		SDE_DEBUG("idle notify work cancelled\n");
-
 	_sde_crtc_blend_setup(crtc);
+	_sde_crtc_dest_scaler_setup(crtc);
 
 	/*
 	 * Since CP properties use AXI buffer to program the
@@ -2509,7 +3082,7 @@
 	 * apply color processing properties only if
 	 * smmu state is attached,
 	 */
-	if ((smmu_state->state != DETACHED) ||
+	if ((smmu_state->state != DETACHED) &&
 			(smmu_state->state != DETACH_ALL_REQ))
 		sde_cp_crtc_apply_properties(crtc);
 
@@ -2533,7 +3106,6 @@
 	struct msm_drm_thread *event_thread;
 	unsigned long flags;
 	struct sde_crtc_state *cstate;
-	int idle_time = 0;
 
 	if (!crtc || !crtc->dev || !crtc->dev->dev_private) {
 		SDE_ERROR("invalid crtc\n");
@@ -2559,7 +3131,6 @@
 	}
 
 	event_thread = &priv->event_thread[crtc->index];
-	idle_time = sde_crtc_get_property(cstate, CRTC_PROP_IDLE_TIME);
 
 	if (sde_crtc->event) {
 		SDE_DEBUG("already received sde_crtc->event\n");
@@ -2590,15 +3161,6 @@
 	/* wait for acquire fences before anything else is done */
 	_sde_crtc_wait_for_fences(crtc);
 
-	/* schedule the idle notify delayed work */
-	if (idle_time && sde_encoder_check_mode(sde_crtc->mixers[0].encoder,
-						MSM_DISPLAY_CAP_VID_MODE)) {
-		kthread_queue_delayed_work(&event_thread->worker,
-					&sde_crtc->idle_notify_work,
-					msecs_to_jiffies(idle_time));
-		SDE_DEBUG("schedule idle notify work in %dms\n", idle_time);
-	}
-
 	if (!cstate->rsc_update) {
 		drm_for_each_encoder(encoder, dev) {
 			if (encoder->crtc != crtc)
@@ -2660,7 +3222,7 @@
 static int _sde_crtc_wait_for_frame_done(struct drm_crtc *crtc)
 {
 	struct sde_crtc *sde_crtc;
-	int ret, rc = 0;
+	int ret, rc = 0, i;
 
 	if (!crtc) {
 		SDE_ERROR("invalid argument\n");
@@ -2673,7 +3235,17 @@
 		return 0;
 	}
 
-	SDE_EVT32_VERBOSE(DRMID(crtc), SDE_EVTLOG_FUNC_ENTRY);
+	SDE_EVT32(DRMID(crtc), SDE_EVTLOG_FUNC_ENTRY);
+
+	/*
+	 * flush all the event thread work to make sure all the
+	 * FRAME_EVENTS from encoder are propagated to crtc
+	 */
+	for (i = 0; i < ARRAY_SIZE(sde_crtc->frame_events); i++) {
+		if (list_empty(&sde_crtc->frame_events[i].list))
+			kthread_flush_work(&sde_crtc->frame_events[i].work);
+	}
+
 	ret = wait_for_completion_timeout(&sde_crtc->frame_done_comp,
 			msecs_to_jiffies(SDE_FRAME_DONE_TIMEOUT));
 	if (!ret) {
@@ -2687,17 +3259,120 @@
 	return rc;
 }
 
-void sde_crtc_commit_kickoff(struct drm_crtc *crtc)
+static int _sde_crtc_commit_kickoff_rot(struct drm_crtc *crtc,
+		struct sde_crtc_state *cstate)
 {
 	struct drm_plane *plane;
+	struct sde_crtc *sde_crtc;
+	struct sde_hw_ctl *ctl, *master_ctl;
+	u32 flush_mask;
+	int i, rc = 0;
+
+	if (!crtc || !cstate)
+		return -EINVAL;
+
+	sde_crtc = to_sde_crtc(crtc);
+
+	/*
+	 * Update sbuf configuration and flush bits if a flush
+	 * mask has been defined for either the current or
+	 * previous commit.
+	 *
+	 * Updates are also required for the first commit after
+	 * sbuf_flush_mask becomes 0x0, to properly transition
+	 * the hardware out of sbuf mode.
+	 */
+	if (!sde_crtc->sbuf_flush_mask_old && !sde_crtc->sbuf_flush_mask)
+		return 0;
+
+	flush_mask = sde_crtc->sbuf_flush_mask_old | sde_crtc->sbuf_flush_mask;
+	sde_crtc->sbuf_flush_mask_old = sde_crtc->sbuf_flush_mask;
+
+	SDE_ATRACE_BEGIN("crtc_kickoff_rot");
+
+	if (cstate->sbuf_cfg.rot_op_mode != SDE_CTL_ROT_OP_MODE_OFFLINE) {
+		drm_atomic_crtc_for_each_plane(plane, crtc) {
+			rc = sde_plane_kickoff_rot(plane);
+			if (rc) {
+				SDE_ERROR("crtc%d cancelling inline rotation\n",
+						crtc->base.id);
+				SDE_EVT32(DRMID(crtc), SDE_EVTLOG_ERROR);
+
+				/* revert to offline on errors */
+				cstate->sbuf_cfg.rot_op_mode =
+					SDE_CTL_ROT_OP_MODE_OFFLINE;
+				break;
+			}
+		}
+	}
+
+	master_ctl = NULL;
+	for (i = 0; i < sde_crtc->num_mixers; i++) {
+		ctl = sde_crtc->mixers[i].hw_ctl;
+		if (!ctl)
+			continue;
+
+		if (!master_ctl || master_ctl->idx > ctl->idx)
+			master_ctl = ctl;
+	}
+
+	/* only update sbuf_cfg and flush for master ctl */
+	if (master_ctl && master_ctl->ops.setup_sbuf_cfg &&
+			master_ctl->ops.update_pending_flush) {
+		master_ctl->ops.setup_sbuf_cfg(master_ctl, &cstate->sbuf_cfg);
+		master_ctl->ops.update_pending_flush(master_ctl, flush_mask);
+
+		/* explicitly trigger rotator for async modes */
+		if (cstate->sbuf_cfg.rot_op_mode ==
+				SDE_CTL_ROT_OP_MODE_INLINE_ASYNC &&
+				master_ctl->ops.trigger_rot_start) {
+			master_ctl->ops.trigger_rot_start(master_ctl);
+			SDE_EVT32(DRMID(crtc), master_ctl->idx - CTL_0);
+		}
+	}
+
+	SDE_ATRACE_END("crtc_kickoff_rot");
+	return rc;
+}
+
+/**
+ * _sde_crtc_remove_pipe_flush - remove staged pipes from flush mask
+ * @sde_crtc: Pointer to sde crtc structure
+ */
+static void _sde_crtc_remove_pipe_flush(struct sde_crtc *sde_crtc)
+{
+	struct sde_crtc_mixer *mixer;
+	struct sde_hw_ctl *ctl;
+	u32 i, flush_mask;
+
+	if (!sde_crtc)
+		return;
+
+	mixer = sde_crtc->mixers;
+	for (i = 0; i < sde_crtc->num_mixers; i++) {
+		ctl = mixer[i].hw_ctl;
+		if (!ctl || !ctl->ops.get_pending_flush ||
+				!ctl->ops.clear_pending_flush ||
+				!ctl->ops.update_pending_flush)
+			continue;
+
+		flush_mask = ctl->ops.get_pending_flush(ctl);
+		flush_mask &= ~mixer[i].pipe_mask;
+		ctl->ops.clear_pending_flush(ctl);
+		ctl->ops.update_pending_flush(ctl, flush_mask);
+	}
+}
+
+void sde_crtc_commit_kickoff(struct drm_crtc *crtc)
+{
 	struct drm_encoder *encoder;
 	struct drm_device *dev;
 	struct sde_crtc *sde_crtc;
 	struct msm_drm_private *priv;
 	struct sde_kms *sde_kms;
 	struct sde_crtc_state *cstate;
-	struct sde_hw_ctl *ctl;
-	int ret, i;
+	bool is_error;
+	int ret;
 
 	if (!crtc) {
 		SDE_ERROR("invalid argument\n");
@@ -2706,6 +3381,7 @@
 	dev = crtc->dev;
 	sde_crtc = to_sde_crtc(crtc);
 	sde_kms = _sde_crtc_get_kms(crtc);
+	is_error = false;
 
 	if (!sde_kms || !sde_kms->dev || !sde_kms->dev->dev_private) {
 		SDE_ERROR("invalid argument\n");
@@ -2724,6 +3400,11 @@
 		return;
 
 	SDE_ATRACE_BEGIN("crtc_commit");
+
+	/* default to ASYNC mode for inline rotation */
+	cstate->sbuf_cfg.rot_op_mode = sde_crtc->sbuf_flush_mask ?
+		SDE_CTL_ROT_OP_MODE_INLINE_ASYNC : SDE_CTL_ROT_OP_MODE_OFFLINE;
+
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
 		struct sde_encoder_kickoff_params params = { 0 };
 
@@ -2738,8 +3419,28 @@
 		params.affected_displays = _sde_crtc_get_displays_affected(crtc,
 				crtc->state);
 		sde_encoder_prepare_for_kickoff(encoder, &params);
+
+		/*
+		 * For inline ASYNC modes, the flush bits are not written
+		 * to hardware atomically, so avoid using it if a video
+		 * mode encoder is active on this CRTC.
+		 */
+		if (cstate->sbuf_cfg.rot_op_mode ==
+				SDE_CTL_ROT_OP_MODE_INLINE_ASYNC &&
+				sde_encoder_get_intf_mode(encoder) ==
+				INTF_MODE_VIDEO)
+			cstate->sbuf_cfg.rot_op_mode =
+				SDE_CTL_ROT_OP_MODE_INLINE_SYNC;
 	}
 
+	/*
+	 * For ASYNC inline modes, kick off the rotator now so that the H/W
+	 * can start as soon as it's ready.
+	 */
+	if (cstate->sbuf_cfg.rot_op_mode == SDE_CTL_ROT_OP_MODE_INLINE_ASYNC)
+		if (_sde_crtc_commit_kickoff_rot(crtc, cstate))
+			is_error = true;
+
 	/* wait for frame_event_done completion */
 	SDE_ATRACE_BEGIN("wait_for_frame_done_event");
 	ret = _sde_crtc_wait_for_frame_done(crtc);
@@ -2748,39 +3449,48 @@
 		SDE_ERROR("crtc%d wait for frame done failed;frame_pending%d\n",
 				crtc->base.id,
 				atomic_read(&sde_crtc->frame_pending));
-		goto end;
+
+		is_error = true;
+
+		/* force offline rotation mode since the commit has no pipes */
+		cstate->sbuf_cfg.rot_op_mode = SDE_CTL_ROT_OP_MODE_OFFLINE;
 	}
 
 	if (atomic_inc_return(&sde_crtc->frame_pending) == 1) {
 		/* acquire bandwidth and other resources */
 		SDE_DEBUG("crtc%d first commit\n", crtc->base.id);
-		SDE_EVT32(DRMID(crtc), SDE_EVTLOG_FUNC_CASE1);
+		SDE_EVT32(DRMID(crtc), cstate->sbuf_cfg.rot_op_mode,
+				SDE_EVTLOG_FUNC_CASE1);
 	} else {
 		SDE_DEBUG("crtc%d commit\n", crtc->base.id);
-		SDE_EVT32(DRMID(crtc), SDE_EVTLOG_FUNC_CASE2);
+		SDE_EVT32(DRMID(crtc), cstate->sbuf_cfg.rot_op_mode,
+				SDE_EVTLOG_FUNC_CASE2);
 	}
 	sde_crtc->play_count++;
 
-	if (cstate->sbuf_cfg.rot_op_mode != SDE_CTL_ROT_OP_MODE_OFFLINE)
-		drm_atomic_crtc_for_each_plane(plane, crtc)
-			sde_plane_kickoff(plane);
-
-	for (i = 0; i < sde_crtc->num_mixers; i++) {
-		ctl = sde_crtc->mixers[i].hw_ctl;
-		if (ctl && ctl->ops.setup_sbuf_cfg)
-			ctl->ops.setup_sbuf_cfg(ctl, &cstate->sbuf_cfg);
-	}
+	/*
+	 * For SYNC inline modes, delay the kick off until after the
+	 * wait for frame done in case the wait times out.
+	 *
+	 * Also perform a final kickoff when transitioning back to
+	 * offline mode.
+	 */
+	if (cstate->sbuf_cfg.rot_op_mode != SDE_CTL_ROT_OP_MODE_INLINE_ASYNC)
+		if (_sde_crtc_commit_kickoff_rot(crtc, cstate))
+			is_error = true;
 
 	sde_vbif_clear_errors(sde_kms);
 
+	if (is_error)
+		_sde_crtc_remove_pipe_flush(sde_crtc);
+
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
 		if (encoder->crtc != crtc)
 			continue;
 
-		sde_encoder_kickoff(encoder);
+		sde_encoder_kickoff(encoder, is_error);
 	}
 
-end:
 	reinit_completion(&sde_crtc->frame_done_comp);
 	SDE_ATRACE_END("crtc_commit");
 	return;
@@ -2955,9 +3665,16 @@
 	}
 
 	/* revert suspend actions, if necessary */
-	if (sde_kms_is_suspend_state(crtc->dev))
+	if (sde_kms_is_suspend_state(crtc->dev)) {
 		_sde_crtc_set_suspend(crtc, false);
 
+		if (!sde_crtc_is_reset_required(crtc)) {
+			SDE_DEBUG("avoiding reset for crtc:%d\n",
+					crtc->base.id);
+			return;
+		}
+	}
+
 	/* remove previous state, if present */
 	if (crtc->state) {
 		sde_crtc_destroy_state(crtc, crtc->state);
@@ -2992,8 +3709,10 @@
 	struct drm_plane *plane;
 	struct drm_encoder *encoder;
 	struct sde_crtc_mixer *m;
-	struct drm_event event;
-	u32 power_on = 0, i, misr_status;
+	u32 i, misr_status;
+	unsigned long flags;
+	struct sde_crtc_irq_info *node = NULL;
+	int ret = 0;
 
 	if (!crtc) {
 		SDE_ERROR("invalid crtc\n");
@@ -3014,13 +3733,19 @@
 
 			sde_encoder_virt_restore(encoder);
 		}
-		sde_cp_crtc_post_ipc(crtc);
 
-		event.type = DRM_EVENT_SDE_POWER;
-		event.length = sizeof(power_on);
-		power_on = 1;
-		msm_mode_object_event_notify(&crtc->base, crtc->dev, &event,
-				(u8 *)&power_on);
+		spin_lock_irqsave(&sde_crtc->spin_lock, flags);
+		list_for_each_entry(node, &sde_crtc->user_event_list, list) {
+			ret = 0;
+			if (node->func)
+				ret = node->func(crtc, true, &node->irq);
+			if (ret)
+				SDE_ERROR("%s failed to enable event %x\n",
+						sde_crtc->name, node->event);
+		}
+		spin_unlock_irqrestore(&sde_crtc->spin_lock, flags);
+
+		sde_cp_crtc_post_ipc(crtc);
 
 		for (i = 0; i < sde_crtc->num_mixers; ++i) {
 			m = &sde_crtc->mixers[i];
@@ -3043,6 +3768,19 @@
 			sde_crtc->misr_data[i] = misr_status ? misr_status :
 							sde_crtc->misr_data[i];
 		}
+
+		spin_lock_irqsave(&sde_crtc->spin_lock, flags);
+		node = NULL;
+		list_for_each_entry(node, &sde_crtc->user_event_list, list) {
+			ret = 0;
+			if (node->func)
+				ret = node->func(crtc, false, &node->irq);
+			if (ret)
+				SDE_ERROR("%s failed to disable event %x\n",
+						sde_crtc->name, node->event);
+		}
+		spin_unlock_irqrestore(&sde_crtc->spin_lock, flags);
+
 		sde_cp_crtc_pre_ipc(crtc);
 		break;
 	case SDE_POWER_EVENT_POST_DISABLE:
@@ -3054,12 +3792,6 @@
 			sde_plane_set_revalidate(plane, true);
 
 		sde_cp_crtc_suspend(crtc);
-
-		event.type = DRM_EVENT_SDE_POWER;
-		event.length = sizeof(power_on);
-		power_on = 0;
-		msm_mode_object_event_notify(&crtc->base, crtc->dev, &event,
-				(u8 *)&power_on);
 		break;
 	default:
 		SDE_DEBUG("event:%d not handled\n", event_type);
@@ -3091,6 +3823,10 @@
 
 	SDE_DEBUG("crtc%d\n", crtc->base.id);
 
+	for (i = 0; i < cstate->num_connectors; i++)
+		sde_connector_schedule_status_work(cstate->connectors[i],
+							false);
+
 	if (sde_kms_is_suspend_state(crtc->dev))
 		_sde_crtc_set_suspend(crtc, true);
 
@@ -3165,6 +3901,7 @@
 
 	memset(sde_crtc->mixers, 0, sizeof(sde_crtc->mixers));
 	sde_crtc->num_mixers = 0;
+	sde_crtc->mixers_swapped = false;
 
 	/* disable clk & bw control until clk & bw properties are set */
 	cstate->bw_control = false;
@@ -3182,13 +3919,15 @@
 	struct sde_crtc_irq_info *node = NULL;
 	struct drm_event event;
 	u32 power_on;
-	int ret;
+	int ret, i;
+	struct sde_crtc_state *cstate;
 
 	if (!crtc || !crtc->dev || !crtc->dev->dev_private) {
 		SDE_ERROR("invalid crtc\n");
 		return;
 	}
 	priv = crtc->dev->dev_private;
+	cstate = to_sde_crtc_state(crtc->state);
 
 	SDE_DEBUG("crtc%d\n", crtc->base.id);
 	SDE_EVT32_VERBOSE(DRMID(crtc));
@@ -3239,6 +3978,9 @@
 		SDE_POWER_EVENT_POST_ENABLE | SDE_POWER_EVENT_POST_DISABLE |
 		SDE_POWER_EVENT_PRE_DISABLE,
 		sde_crtc_handle_power_event, crtc, sde_crtc->name);
+
+	for (i = 0; i < cstate->num_connectors; i++)
+		sde_connector_schedule_status_work(cstate->connectors[i], true);
 }
 
 struct plane_state {
@@ -3348,7 +4090,7 @@
 	struct drm_encoder *encoder;
 	struct sde_crtc_state *cstate;
 	uint32_t secure;
-	uint32_t fb_ns = 0, fb_sec = 0, fb_ns_dir = 0, fb_sec_dir = 0;
+	uint32_t fb_ns = 0, fb_sec = 0, fb_sec_dir = 0;
 	int encoder_cnt = 0;
 	int rc;
 
@@ -3365,26 +4107,21 @@
 	rc = _sde_crtc_find_plane_fb_modes(state,
 			&fb_ns,
 			&fb_sec,
-			&fb_ns_dir,
 			&fb_sec_dir);
 	if (rc)
 		return rc;
 
 	/**
 	 * validate planes
-	 * fb_ns_dir is for  secure display use case,
-	 * fb_sec_dir is for secure camera preview use case,
+	 * fb_sec_dir is for secure camera preview and secure display  use case,
 	 * fb_sec is for secure video playback,
 	 * fb_ns is for normal non secure use cases.
 	 */
-	if (((secure == SDE_DRM_SEC_ONLY) &&
-				(fb_ns || fb_sec || fb_sec_dir)) ||
-			(fb_sec && fb_sec_dir)) {
+	if ((secure == SDE_DRM_SEC_ONLY) &&
+			(fb_ns || fb_sec || (fb_sec && fb_sec_dir))) {
 		SDE_ERROR(
-			"crtc%d: invalid planes fb_modes Sec:%d, NS:%d, Sec_Dir:%d, NS_Dir%d\n",
-				crtc->base.id,
-				fb_sec, fb_ns, fb_sec_dir,
-				fb_ns_dir);
+		"crtc%d: invalid planes fb_modes Sec:%d, NS:%d, Sec_Dir:%d\n",
+				crtc->base.id, fb_sec, fb_ns, fb_sec_dir);
 		return -EINVAL;
 	}
 
@@ -3392,7 +4129,7 @@
 	 * secure_crtc is not allowed in a shared toppolgy
 	 * across different encoders.
 	 */
-	if (fb_ns_dir || fb_sec_dir) {
+	if (fb_sec_dir) {
 		drm_for_each_encoder(encoder, crtc->dev)
 			if (encoder->crtc ==  crtc)
 				encoder_cnt++;
@@ -3452,7 +4189,14 @@
 
 	memset(pipe_staged, 0, sizeof(pipe_staged));
 
-	mixer_width = sde_crtc_mixer_width(sde_crtc, mode);
+	rc = _sde_crtc_check_dest_scaler_data(crtc, state);
+	if (rc) {
+		SDE_ERROR("crtc%d failed dest scaler check %d\n",
+			crtc->base.id, rc);
+		goto end;
+	}
+
+	mixer_width = sde_crtc_get_mixer_width(sde_crtc, cstate, mode);
 
 	_sde_crtc_setup_is_ppsplit(state);
 	_sde_crtc_setup_lm_bounds(crtc, state);
@@ -3805,7 +4549,8 @@
 			CRTC_PROP_ROT_CLK);
 
 	msm_property_install_range(&sde_crtc->property_info,
-		"idle_time", 0x0, 0, U64_MAX, 0, CRTC_PROP_IDLE_TIME);
+		"idle_time", IDLE_TIMEOUT, 0, U64_MAX, 0,
+		CRTC_PROP_IDLE_TIMEOUT);
 
 	msm_property_install_blob(&sde_crtc->property_info, "capabilities",
 		DRM_MODE_PROP_IMMUTABLE, CRTC_PROP_INFO);
@@ -3846,6 +4591,39 @@
 					"smart_dma_rev", "smart_dma_v2");
 	}
 
+	if (catalog->mdp[0].has_dest_scaler) {
+		sde_kms_info_add_keyint(info, "has_dest_scaler",
+				catalog->mdp[0].has_dest_scaler);
+		sde_kms_info_add_keyint(info, "dest_scaler_count",
+					catalog->ds_count);
+
+		if (catalog->ds[0].top) {
+			sde_kms_info_add_keyint(info,
+					"max_dest_scaler_input_width",
+					catalog->ds[0].top->maxinputwidth);
+			sde_kms_info_add_keyint(info,
+					"max_dest_scaler_output_width",
+					catalog->ds[0].top->maxinputwidth);
+			sde_kms_info_add_keyint(info, "max_dest_scale_up",
+					catalog->ds[0].top->maxupscale);
+		}
+
+		if (catalog->ds[0].features & BIT(SDE_SSPP_SCALER_QSEED3)) {
+			msm_property_install_volatile_range(
+					&sde_crtc->property_info, "dest_scaler",
+					0x0, 0, ~0, 0, CRTC_PROP_DEST_SCALER);
+			msm_property_install_blob(&sde_crtc->property_info,
+					"ds_lut_ed", 0,
+					CRTC_PROP_DEST_SCALER_LUT_ED);
+			msm_property_install_blob(&sde_crtc->property_info,
+					"ds_lut_cir", 0,
+					CRTC_PROP_DEST_SCALER_LUT_CIR);
+			msm_property_install_blob(&sde_crtc->property_info,
+					"ds_lut_sep", 0,
+					CRTC_PROP_DEST_SCALER_LUT_SEP);
+		}
+	}
+
 	sde_kms_info_add_keyint(info, "has_src_split", catalog->has_src_split);
 	if (catalog->perf.max_bw_low)
 		sde_kms_info_add_keyint(info, "max_bandwidth_low",
@@ -3853,6 +4631,15 @@
 	if (catalog->perf.max_bw_high)
 		sde_kms_info_add_keyint(info, "max_bandwidth_high",
 				catalog->perf.max_bw_high * 1000LL);
+	if (catalog->perf.min_core_ib)
+		sde_kms_info_add_keyint(info, "min_core_ib",
+				catalog->perf.min_core_ib * 1000LL);
+	if (catalog->perf.min_llcc_ib)
+		sde_kms_info_add_keyint(info, "min_llcc_ib",
+				catalog->perf.min_llcc_ib * 1000LL);
+	if (catalog->perf.min_dram_ib)
+		sde_kms_info_add_keyint(info, "min_dram_ib",
+				catalog->perf.min_dram_ib * 1000LL);
 	if (sde_kms->perf.max_core_clk_rate)
 		sde_kms_info_add_keyint(info, "max_mdp_clk",
 				sde_kms->perf.max_core_clk_rate);
@@ -3921,10 +4708,22 @@
 				_sde_crtc_set_input_fence_timeout(cstate);
 				break;
 			case CRTC_PROP_DIM_LAYER_V1:
-				_sde_crtc_set_dim_layer_v1(cstate, (void *)val);
+				_sde_crtc_set_dim_layer_v1(cstate,
+							(void __user *)val);
 				break;
 			case CRTC_PROP_ROI_V1:
-				ret = _sde_crtc_set_roi_v1(state, (void *)val);
+				ret = _sde_crtc_set_roi_v1(state,
+							(void __user *)val);
+				break;
+			case CRTC_PROP_DEST_SCALER:
+				ret = _sde_crtc_set_dest_scaler(sde_crtc,
+						cstate, (void __user *)val);
+				break;
+			case CRTC_PROP_DEST_SCALER_LUT_ED:
+			case CRTC_PROP_DEST_SCALER_LUT_CIR:
+			case CRTC_PROP_DEST_SCALER_LUT_SEP:
+				ret = _sde_crtc_set_dest_scaler_lut(sde_crtc,
+								cstate, idx);
 				break;
 			case CRTC_PROP_CORE_CLK:
 			case CRTC_PROP_CORE_AB:
@@ -3938,6 +4737,8 @@
 				cstate->bw_control = true;
 				cstate->bw_split_vote = true;
 				break;
+			case CRTC_PROP_IDLE_TIMEOUT:
+				_sde_crtc_set_idle_timeout(crtc, val);
 			default:
 				/* nothing to do */
 				break;
@@ -4070,7 +4871,7 @@
 
 	mutex_lock(&sde_crtc->crtc_lock);
 	mode = &crtc->state->adjusted_mode;
-	out_width = sde_crtc_mixer_width(sde_crtc, mode);
+	out_width = sde_crtc_get_mixer_width(sde_crtc, cstate, mode);
 
 	seq_printf(s, "crtc:%d width:%d height:%d\n", crtc->base.id,
 				mode->hdisplay, mode->vdisplay);
@@ -4539,31 +5340,6 @@
 	return rc;
 }
 
-/*
- * __sde_crtc_idle_notify_work - signal idle timeout to user space
- */
-static void __sde_crtc_idle_notify_work(struct kthread_work *work)
-{
-	struct sde_crtc *sde_crtc = container_of(work, struct sde_crtc,
-				idle_notify_work.work);
-	struct drm_crtc *crtc;
-	struct drm_event event;
-	int ret = 0;
-
-	if (!sde_crtc) {
-		SDE_ERROR("invalid sde crtc\n");
-	} else {
-		crtc = &sde_crtc->base;
-		event.type = DRM_EVENT_IDLE_NOTIFY;
-		event.length = sizeof(u32);
-		msm_mode_object_event_notify(&crtc->base, crtc->dev,
-				&event, (u8 *)&ret);
-
-		SDE_DEBUG("crtc[%d]: idle timeout notified\n", crtc->base.id);
-	}
-}
-
-
 /* initialize crtc */
 struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane)
 {
@@ -4630,13 +5406,13 @@
 
 	sde_crtc_install_properties(crtc, kms->catalog);
 
+	/* Init dest scaler */
+	_sde_crtc_dest_scaler_init(sde_crtc, kms->catalog);
+
 	/* Install color processing properties */
 	sde_cp_crtc_init(crtc);
 	sde_cp_crtc_install_properties(crtc);
 
-	kthread_init_delayed_work(&sde_crtc->idle_notify_work,
-					__sde_crtc_idle_notify_work);
-
 	SDE_DEBUG("%s: successfully initialized crtc\n", sde_crtc->name);
 	return crtc;
 }
@@ -4690,6 +5466,7 @@
 	if (crtc_drm->enabled) {
 		sde_power_resource_enable(&priv->phandle, kms->core_client,
 				true);
+		INIT_LIST_HEAD(&node->irq.list);
 		ret = node->func(crtc_drm, true, &node->irq);
 		sde_power_resource_enable(&priv->phandle, kms->core_client,
 				false);
@@ -4697,6 +5474,8 @@
 
 	if (!ret) {
 		spin_lock_irqsave(&crtc->spin_lock, flags);
+		/* irq is regiestered and enabled and set the state */
+		node->state = IRQ_ENABLED;
 		list_add_tail(&node->list, &crtc->user_event_list);
 		spin_unlock_irqrestore(&crtc->spin_lock, flags);
 	} else {
@@ -4720,7 +5499,6 @@
 	spin_lock_irqsave(&crtc->spin_lock, flags);
 	list_for_each_entry(node, &crtc->user_event_list, list) {
 		if (node->event == event) {
-			list_del(&node->list);
 			found = true;
 			break;
 		}
@@ -4736,12 +5514,15 @@
 	 * no need to disable/de-register.
 	 */
 	if (!crtc_drm->enabled) {
+		list_del(&node->list);
 		kfree(node);
 		return 0;
 	}
 	priv = kms->dev->dev_private;
 	sde_power_resource_enable(&priv->phandle, kms->core_client, true);
 	ret = node->func(crtc_drm, false, &node->irq);
+	list_del(&node->list);
+	kfree(node);
 	sde_power_resource_enable(&priv->phandle, kms->core_client, false);
 	return ret;
 }
@@ -4773,16 +5554,6 @@
 	return 0;
 }
 
-static int sde_crtc_pm_event_handler(struct drm_crtc *crtc, bool en,
-		struct sde_irq_callback *noirq)
-{
-	/*
-	 * IRQ object noirq is not being used here since there is
-	 * no crtc irq from pm event.
-	 */
-	return 0;
-}
-
 static int sde_crtc_idle_interrupt_handler(struct drm_crtc *crtc_drm,
 	bool en, struct sde_irq_callback *irq)
 {
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.h b/drivers/gpu/drm/msm/sde/sde_crtc.h
index 1e0e917..59bfc47 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.h
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.h
@@ -26,6 +26,7 @@
 #include "sde_kms.h"
 #include "sde_core_perf.h"
 #include "sde_hw_blk.h"
+#include "sde_hw_ds.h"
 
 #define SDE_CRTC_NAME_SIZE	12
 
@@ -106,17 +107,21 @@
  * @hw_lm:	LM HW Driver context
  * @hw_ctl:	CTL Path HW driver context
  * @hw_dspp:	DSPP HW driver context
+ * @hw_ds:	DS HW driver context
  * @encoder:	Encoder attached to this lm & ctl
- * @mixer_op_mode: mixer blending operation mode
+ * @mixer_op_mode:	mixer blending operation mode
  * @flush_mask:	mixer flush mask for ctl, mixer and pipe
+ * @pipe_mask:	mixer flush mask for pipe
  */
 struct sde_crtc_mixer {
 	struct sde_hw_mixer *hw_lm;
 	struct sde_hw_ctl *hw_ctl;
-	struct sde_hw_dspp  *hw_dspp;
+	struct sde_hw_dspp *hw_dspp;
+	struct sde_hw_ds *hw_ds;
 	struct drm_encoder *encoder;
 	u32 mixer_op_mode;
 	u32 flush_mask;
+	u32 pipe_mask;
 };
 
 /**
@@ -204,11 +209,13 @@
  * @misr_enable   : boolean entry indicates misr enable/disable status.
  * @misr_frame_count  : misr frame count provided by client
  * @misr_data     : store misr data before turning off the clocks.
- * @idle_notify_work: delayed worker to notify idle timeout to user space
+ * @sbuf_flush_mask: flush mask for inline rotator
+ * @sbuf_flush_mask_old: inline rotator flush mask for previous commit
  * @power_event   : registered power event handle
  * @cur_perf      : current performance committed to clock/bandwidth driver
  * @rp_lock       : serialization lock for resource pool
  * @rp_head       : list of active resource pool
+ * @scl3_cfg_lut  : qseed3 lut config
  */
 struct sde_crtc {
 	struct drm_crtc base;
@@ -219,6 +226,7 @@
 	u32 num_mixers;
 	bool mixers_swapped;
 	struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS];
+	struct sde_hw_scaler3_lut_cfg *scl3_lut_cfg;
 
 	struct drm_pending_vblank_event *event;
 	u32 vsync_count;
@@ -248,6 +256,7 @@
 	struct list_head user_event_list;
 
 	struct mutex crtc_lock;
+	struct mutex crtc_cp_lock;
 
 	atomic_t frame_pending;
 	struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE];
@@ -265,7 +274,8 @@
 	u32 misr_frame_count;
 	u32 misr_data[CRTC_DUAL_MIXERS];
 
-	struct kthread_delayed_work idle_notify_work;
+	u32 sbuf_flush_mask;
+	u32 sbuf_flush_mask_old;
 
 	struct sde_power_event *power_event;
 
@@ -275,6 +285,9 @@
 	struct list_head rp_head;
 
 	struct sde_crtc_smmu_state_data smmu_state;
+
+	/* blob for histogram data */
+	struct drm_property_blob *hist_blob;
 };
 
 #define to_sde_crtc(x) container_of(x, struct sde_crtc, base)
@@ -340,7 +353,6 @@
  * @base: Base drm crtc state structure
  * @connectors    : Currently associated drm connectors
  * @num_connectors: Number of associated drm connectors
- * @intf_mode     : Interface mode of the primary connector
  * @rsc_client    : sde rsc client when mode is valid
  * @is_ppsplit    : Whether current topology requires PPSplit special handling
  * @bw_control    : true if bw/clk controlled by core bw/clk properties
@@ -357,17 +369,19 @@
  * @input_fence_timeout_ns : Cached input fence timeout, in ns
  * @num_dim_layers: Number of dim layers
  * @dim_layer: Dim layer configs
+ * @num_ds: Number of destination scalers to be configured
+ * @num_ds_enabled: Number of destination scalers enabled
+ * @ds_dirty: Boolean to indicate if dirty or not
+ * @ds_cfg: Destination scaler config
  * @new_perf: new performance state being requested
  * @sbuf_cfg: stream buffer configuration
  * @sbuf_prefill_line: number of line for inline rotator prefetch
- * @sbuf_flush_mask: flush mask for inline rotator
  */
 struct sde_crtc_state {
 	struct drm_crtc_state base;
 
 	struct drm_connector *connectors[MAX_CONNECTORS];
 	int num_connectors;
-	enum sde_intf_mode intf_mode;
 	struct sde_rsc_client *rsc_client;
 	bool rsc_update;
 	bool bw_control;
@@ -384,15 +398,41 @@
 	uint64_t input_fence_timeout_ns;
 	uint32_t num_dim_layers;
 	struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS];
+	uint32_t num_ds;
+	uint32_t num_ds_enabled;
+	bool ds_dirty;
+	struct sde_hw_ds_cfg ds_cfg[SDE_MAX_DS_COUNT];
 
 	struct sde_core_perf_params new_perf;
 	struct sde_ctl_sbuf_cfg sbuf_cfg;
 	u32 sbuf_prefill_line;
-	u32 sbuf_flush_mask;
 
 	struct sde_crtc_respool rp;
 };
 
+enum sde_crtc_irq_state {
+	IRQ_NOINIT,
+	IRQ_ENABLED,
+	IRQ_DISABLED,
+};
+
+/**
+ * sde_crtc_irq_info - crtc interrupt info
+ * @irq: interrupt callback
+ * @event: event type of the interrupt
+ * @func: function pointer to enable/disable the interrupt
+ * @list: list of user customized event in crtc
+ * @ref_count: reference count for the interrupt
+ */
+struct sde_crtc_irq_info {
+	struct sde_irq_callback irq;
+	u32 event;
+	int (*func)(struct drm_crtc *crtc, bool en,
+			struct sde_irq_callback *irq);
+	struct list_head list;
+	enum sde_crtc_irq_state state;
+};
+
 #define to_sde_crtc_state(x) \
 	container_of(x, struct sde_crtc_state, base)
 
@@ -405,14 +445,41 @@
 #define sde_crtc_get_property(S, X) \
 	((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0)
 
-static inline int sde_crtc_mixer_width(struct sde_crtc *sde_crtc,
-	struct drm_display_mode *mode)
+/**
+ * sde_crtc_get_mixer_width - get the mixer width
+ * Mixer width will be same as panel width(/2 for split)
+ * unless destination scaler feature is enabled
+ */
+static inline int sde_crtc_get_mixer_width(struct sde_crtc *sde_crtc,
+	struct sde_crtc_state *cstate, struct drm_display_mode *mode)
 {
-	if (!sde_crtc || !mode)
+	u32 mixer_width;
+
+	if (!sde_crtc || !cstate || !mode)
 		return 0;
 
-	return  sde_crtc->num_mixers == CRTC_DUAL_MIXERS ?
-		mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay;
+	if (cstate->num_ds_enabled)
+		mixer_width = cstate->ds_cfg[0].lm_width;
+	else
+		mixer_width = (sde_crtc->num_mixers == CRTC_DUAL_MIXERS ?
+			mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay);
+
+	return mixer_width;
+}
+
+/**
+ * sde_crtc_get_mixer_height - get the mixer height
+ * Mixer height will be same as panel height unless
+ * destination scaler feature is enabled
+ */
+static inline int sde_crtc_get_mixer_height(struct sde_crtc *sde_crtc,
+		struct sde_crtc_state *cstate, struct drm_display_mode *mode)
+{
+	if (!sde_crtc || !cstate || !mode)
+		return 0;
+
+	return (cstate->num_ds_enabled ?
+			cstate->ds_cfg[0].lm_height : mode->vdisplay);
 }
 
 /**
@@ -503,8 +570,8 @@
 	if (!cstate)
 		return NRT_CLIENT;
 
-	return cstate->rsc_client ? RT_RSC_CLIENT :
-	    (cstate->intf_mode == INTF_MODE_WB_LINE ? NRT_CLIENT : RT_CLIENT);
+	return sde_crtc_get_intf_mode(crtc) == INTF_MODE_WB_LINE ? NRT_CLIENT :
+			(cstate->rsc_client ? RT_RSC_CLIENT : RT_CLIENT);
 }
 
 /**
@@ -534,6 +601,30 @@
 }
 
 /**
+ * sde_crtc_is_reset_required - validate the reset request based on the
+ *	pm_suspend and crtc's active status. crtc's are left active
+ *	on pm_suspend during LP1/LP2 states, as the display is still
+ *	left ON. Avoid reset for the subsequent pm_resume in such cases.
+ * @crtc: Pointer to crtc
+ * return: false if in suspend state and crtc active, true otherwise
+ */
+static inline bool sde_crtc_is_reset_required(struct drm_crtc *crtc)
+{
+	/*
+	 * reset is required even when there is no crtc_state as it is required
+	 * to create the initial state object
+	 */
+	if (!crtc || !crtc->state)
+		return true;
+
+	/* reset not required if crtc is active during suspend state */
+	if (sde_kms_is_suspend_state(crtc->dev) && crtc->state->active)
+		return false;
+
+	return true;
+}
+
+/**
  * sde_crtc_event_queue - request event callback
  * @crtc: Pointer to drm crtc structure
  * @func: Pointer to callback function
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder.c b/drivers/gpu/drm/msm/sde/sde_encoder.c
index 4a643cc..7c600ca 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder.c
@@ -71,7 +71,6 @@
 
 #define MISR_BUFF_SIZE			256
 
-#define IDLE_TIMEOUT	(66 - 16/2)
 #define IDLE_SHORT_TIMEOUT	1
 
 /* Maximum number of VSYNC wait attempts for RSC state transition */
@@ -180,6 +179,7 @@
  * @crtc_frame_event_cb_data:	callback handler private data
  * @frame_done_timeout:		frame done timeout in Hz
  * @frame_done_timer:		watchdog timer for frame done event
+ * @vsync_event_timer:		vsync timer
  * @rsc_client:			rsc client pointer
  * @rsc_state_init:		boolean to indicate rsc config init
  * @disp_info:			local copy of msm_display_info struct
@@ -192,11 +192,13 @@
  * @rc_state:			resource controller state
  * @delayed_off_work:		delayed worker to schedule disabling of
  *				clks and resources after IDLE_TIMEOUT time.
+ * @vsync_event_work:		worker to handle vsync event for autorefresh
  * @topology:                   topology of the display
  * @mode_set_complete:          flag to indicate modeset completion
  * @rsc_config:			rsc configuration for display vtotal, fps, etc.
  * @cur_conn_roi:		current connector roi
  * @prv_conn_roi:		previous connector roi to optimize if unchanged
+ * @idle_timeout:		idle timeout duration in milliseconds
  */
 struct sde_encoder_virt {
 	struct drm_encoder base;
@@ -224,6 +226,7 @@
 
 	atomic_t frame_done_timeout;
 	struct timer_list frame_done_timer;
+	struct timer_list vsync_event_timer;
 
 	struct sde_rsc_client *rsc_client;
 	bool rsc_state_init;
@@ -236,12 +239,15 @@
 	struct mutex rc_lock;
 	enum sde_enc_rc_states rc_state;
 	struct kthread_delayed_work delayed_off_work;
+	struct kthread_work vsync_event_work;
 	struct msm_display_topology topology;
 	bool mode_set_complete;
 
 	struct sde_rsc_cmd_config rsc_config;
 	struct sde_rect cur_conn_roi;
 	struct sde_rect prv_conn_roi;
+
+	u32 idle_timeout;
 };
 
 #define to_sde_encoder_virt(x) container_of(x, struct sde_encoder_virt, base)
@@ -261,6 +267,17 @@
 	return (comp_info->comp_type == MSM_DISPLAY_COMPRESSION_DSC);
 }
 
+void sde_encoder_set_idle_timeout(struct drm_encoder *drm_enc, u32 idle_timeout)
+{
+	struct sde_encoder_virt *sde_enc;
+
+	if (!drm_enc)
+		return;
+
+	sde_enc = to_sde_encoder_virt(drm_enc);
+	sde_enc->idle_timeout = idle_timeout;
+}
+
 bool sde_encoder_is_dsc_merge(struct drm_encoder *drm_enc)
 {
 	enum sde_rm_topology_name topology;
@@ -425,7 +442,7 @@
 	irq = &phys_enc->irq[intr_idx];
 
 	if (irq->irq_idx >= 0) {
-		SDE_ERROR_PHYS(phys_enc,
+		SDE_DEBUG_PHYS(phys_enc,
 				"skipping already registered irq %s type %d\n",
 				irq->name, irq->intr_type);
 		return 0;
@@ -1224,6 +1241,102 @@
 	}
 }
 
+static int _sde_encoder_dsc_disable(struct sde_encoder_virt *sde_enc)
+{
+	enum sde_rm_topology_name topology;
+	struct drm_connector *drm_conn;
+	int i, ret = 0;
+	struct sde_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC];
+	struct sde_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC] = {NULL};
+	int pp_count = 0;
+	int dsc_count = 0;
+
+	if (!sde_enc || !sde_enc->phys_encs[0] ||
+			!sde_enc->phys_encs[0]->connector) {
+		SDE_ERROR("invalid params %d %d\n",
+			!sde_enc, sde_enc ? !sde_enc->phys_encs[0] : -1);
+		return -EINVAL;
+	}
+
+	drm_conn = sde_enc->phys_encs[0]->connector;
+
+	topology = sde_connector_get_topology_name(drm_conn);
+	if (topology == SDE_RM_TOPOLOGY_NONE) {
+		SDE_ERROR_ENC(sde_enc, "topology not set yet\n");
+		return -EINVAL;
+	}
+
+	switch (topology) {
+	case SDE_RM_TOPOLOGY_SINGLEPIPE:
+	case SDE_RM_TOPOLOGY_SINGLEPIPE_DSC:
+		/* single PP */
+		hw_pp[0] = sde_enc->hw_pp[0];
+		hw_dsc[0] = sde_enc->hw_dsc[0];
+		pp_count = 1;
+		dsc_count = 1;
+		break;
+	case SDE_RM_TOPOLOGY_DUALPIPE_DSC:
+	case SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC:
+	case SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE:
+		/* dual dsc */
+		for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+			hw_dsc[i] = sde_enc->hw_dsc[i];
+			if (hw_dsc[i])
+				dsc_count++;
+		}
+		/* fall through */
+	case SDE_RM_TOPOLOGY_DUALPIPE:
+	case SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE:
+		/* dual pp */
+		for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+			hw_pp[i] = sde_enc->hw_pp[i];
+			if (hw_pp[i])
+				pp_count++;
+		}
+		break;
+	default:
+		SDE_DEBUG_ENC(sde_enc, "Unexpected topology:%d\n", topology);
+		return -EINVAL;
+	};
+
+	SDE_EVT32(DRMID(&sde_enc->base), topology, pp_count, dsc_count);
+
+	if (pp_count > MAX_CHANNELS_PER_ENC ||
+		dsc_count > MAX_CHANNELS_PER_ENC) {
+		SDE_ERROR_ENC(sde_enc, "Wrong count pp:%d dsc:%d top:%d\n",
+				pp_count, dsc_count, topology);
+		return -EINVAL;
+	}
+
+	/* Disable DSC for all the pp's present in this topology */
+	for (i = 0; i < pp_count; i++) {
+
+		if (!hw_pp[i]) {
+			SDE_ERROR_ENC(sde_enc, "null pp:%d top:%d cnt:%d\n",
+					i, topology, pp_count);
+			return -EINVAL;
+		}
+
+		if (hw_pp[i]->ops.disable_dsc)
+			hw_pp[i]->ops.disable_dsc(hw_pp[i]);
+	}
+
+	/* Disable DSC HW */
+	for (i = 0; i < dsc_count; i++) {
+
+		if (!hw_dsc[i]) {
+			SDE_ERROR_ENC(sde_enc, "null dsc:%d top:%d cnt:%d\n",
+					i, topology, dsc_count);
+			return -EINVAL;
+		}
+
+		if (hw_dsc[i]->ops.dsc_disable)
+			hw_dsc[i]->ops.dsc_disable(hw_dsc[i]);
+	}
+
+	return ret;
+}
+
 static int _sde_encoder_update_rsc_client(
 		struct drm_encoder *drm_enc,
 		struct sde_encoder_rsc_config *config, bool enable)
@@ -1393,29 +1506,31 @@
 {
 	struct sde_encoder_virt *sde_enc = to_sde_encoder_virt(drm_enc);
 	struct sde_encoder_rsc_config rsc_cfg = { 0 };
+	int i;
 
 	if (enable) {
 		rsc_cfg.inline_rotate_prefill =
 				sde_crtc_get_inline_prefill(drm_enc->crtc);
 
-		/* connect the TE source to actual TE GPIO to drive RSC */
-		_sde_encoder_update_vsync_source(sde_enc, &sde_enc->disp_info,
-				false);
-
 		_sde_encoder_update_rsc_client(drm_enc, &rsc_cfg, true);
 	} else {
 		_sde_encoder_update_rsc_client(drm_enc, NULL, false);
 
 		/**
-		 * disconnect the TE source from the actual TE GPIO for RSC
-		 *
-		 * this call is for hardware workaround on sdm845 and should
-		 * not be removed without considering the design changes for
-		 * sde rsc + command mode concurrency. It may lead to pp
-		 * timeout due to vsync from panel for command mode panel.
+		 * disable the vsync source after updating the rsc state. rsc
+		 * state update might have vsync wait and vsync source must be
+		 * disabled after it. It will avoid generating any vsync from
+		 * this point till mode-2 entry. It is SW workaround for
+		 * HW limitation and should not be removed without checking the
+		 * updated design.
 		 */
-		_sde_encoder_update_vsync_source(sde_enc, &sde_enc->disp_info,
-				true);
+		for (i = 0; i < sde_enc->num_phys_encs; i++) {
+			struct sde_encoder_phys *phys = sde_enc->phys_encs[i];
+
+			if (phys && phys->ops.prepare_idle_pc)
+				phys->ops.prepare_idle_pc(phys);
+		}
+
 	}
 }
 
@@ -1472,6 +1587,7 @@
 	struct msm_drm_private *priv;
 	struct msm_drm_thread *disp_thread;
 	int ret;
+	bool is_vid_mode = false;
 
 	if (!drm_enc || !drm_enc->dev || !drm_enc->dev->dev_private ||
 			!drm_enc->crtc) {
@@ -1480,6 +1596,8 @@
 	}
 	sde_enc = to_sde_encoder_virt(drm_enc);
 	priv = drm_enc->dev->dev_private;
+	is_vid_mode = sde_enc->disp_info.capabilities &
+						MSM_DISPLAY_CAP_VID_MODE;
 
 	if (drm_enc->crtc->index >= ARRAY_SIZE(priv->disp_thread)) {
 		SDE_ERROR("invalid crtc index\n");
@@ -1489,7 +1607,7 @@
 
 	/*
 	 * when idle_pc is not supported, process only KICKOFF, STOP and MODESET
-	 * events and return early for other events (ie video mode).
+	 * events and return early for other events (ie wb display).
 	 */
 	if (!sde_enc->idle_pc_supported &&
 			(sw_event != SDE_ENC_RC_EVENT_KICKOFF &&
@@ -1518,6 +1636,8 @@
 		if (sde_enc->rc_state == SDE_ENC_RC_STATE_ON) {
 			SDE_DEBUG_ENC(sde_enc, "sw_event:%d, rc in ON state\n",
 					sw_event);
+			SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
+				SDE_EVTLOG_FUNC_CASE1);
 			mutex_unlock(&sde_enc->rc_lock);
 			return 0;
 		} else if (sde_enc->rc_state != SDE_ENC_RC_STATE_OFF &&
@@ -1530,9 +1650,13 @@
 			return -EINVAL;
 		}
 
-		/* enable all the clks and resources */
-		_sde_encoder_resource_control_helper(drm_enc, true);
-		_sde_encoder_resource_control_rsc_update(drm_enc, true);
+		if (is_vid_mode && sde_enc->rc_state == SDE_ENC_RC_STATE_IDLE) {
+			_sde_encoder_irq_control(drm_enc, true);
+		} else {
+			/* enable all the clks and resources */
+			_sde_encoder_resource_control_helper(drm_enc, true);
+			_sde_encoder_resource_control_rsc_update(drm_enc, true);
+		}
 
 		SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
 				SDE_ENC_RC_STATE_ON, SDE_EVTLOG_FUNC_CASE1);
@@ -1562,6 +1686,8 @@
 		 */
 		if (sde_crtc_frame_pending(drm_enc->crtc) > 1) {
 			SDE_DEBUG_ENC(sde_enc, "skip schedule work");
+			SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
+				SDE_EVTLOG_FUNC_CASE2);
 			return 0;
 		}
 
@@ -1582,7 +1708,7 @@
 		if (lp == SDE_MODE_DPMS_LP2)
 			idle_timeout = IDLE_SHORT_TIMEOUT;
 		else
-			idle_timeout = IDLE_TIMEOUT;
+			idle_timeout = sde_enc->idle_timeout;
 
 		if (!autorefresh_enabled)
 			kthread_queue_delayed_work(
@@ -1605,11 +1731,17 @@
 
 		mutex_lock(&sde_enc->rc_lock);
 
+		if (is_vid_mode &&
+			  sde_enc->rc_state == SDE_ENC_RC_STATE_IDLE) {
+			_sde_encoder_irq_control(drm_enc, true);
+		}
 		/* skip if is already OFF or IDLE, resources are off already */
-		if (sde_enc->rc_state == SDE_ENC_RC_STATE_OFF ||
+		else if (sde_enc->rc_state == SDE_ENC_RC_STATE_OFF ||
 				sde_enc->rc_state == SDE_ENC_RC_STATE_IDLE) {
 			SDE_DEBUG_ENC(sde_enc, "sw_event:%d, rc in %d state\n",
 					sw_event, sde_enc->rc_state);
+			SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
+				SDE_EVTLOG_FUNC_CASE3);
 			mutex_unlock(&sde_enc->rc_lock);
 			return 0;
 		}
@@ -1636,6 +1768,8 @@
 		if (sde_enc->rc_state == SDE_ENC_RC_STATE_OFF) {
 			SDE_DEBUG_ENC(sde_enc, "sw_event:%d, rc in OFF state\n",
 					sw_event);
+			SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
+				SDE_EVTLOG_FUNC_CASE4);
 			mutex_unlock(&sde_enc->rc_lock);
 			return 0;
 		} else if (sde_enc->rc_state == SDE_ENC_RC_STATE_ON ||
@@ -1756,9 +1890,15 @@
 			return 0;
 		}
 
-		/* disable all the clks and resources */
-		_sde_encoder_resource_control_rsc_update(drm_enc, false);
-		_sde_encoder_resource_control_helper(drm_enc, false);
+		if (is_vid_mode) {
+			_sde_encoder_irq_control(drm_enc, false);
+		} else {
+			/* disable all the clks and resources */
+			_sde_encoder_resource_control_rsc_update(drm_enc,
+								false);
+			_sde_encoder_resource_control_helper(drm_enc, false);
+		}
+
 		SDE_EVT32(DRMID(drm_enc), sw_event, sde_enc->rc_state,
 				SDE_ENC_RC_STATE_IDLE, SDE_EVTLOG_FUNC_CASE7);
 		sde_enc->rc_state = SDE_ENC_RC_STATE_IDLE;
@@ -1777,20 +1917,6 @@
 	return 0;
 }
 
-static void sde_encoder_off_work(struct kthread_work *work)
-{
-	struct sde_encoder_virt *sde_enc = container_of(work,
-			struct sde_encoder_virt, delayed_off_work.work);
-
-	if (!sde_enc) {
-		SDE_ERROR("invalid sde encoder\n");
-		return;
-	}
-
-	sde_encoder_resource_control(&sde_enc->base,
-			SDE_ENC_RC_EVENT_ENTER_IDLE);
-}
-
 static void sde_encoder_virt_mode_set(struct drm_encoder *drm_enc,
 				      struct drm_display_mode *mode,
 				      struct drm_display_mode *adj_mode)
@@ -1852,6 +1978,12 @@
 					ret);
 			return;
 		}
+
+		/*
+		 * Disable dsc before switch the mode and after pre_modeset,
+		 * to guarantee that previous kickoff finished.
+		 */
+		_sde_encoder_dsc_disable(sde_enc);
 	}
 
 	/* Reserve dynamic resources now. Indicating non-AtomicTest phase */
@@ -2083,6 +2215,13 @@
 			phys->ops.disable(phys);
 	}
 
+	/*
+	 * disable dsc after the transfer is complete (for command mode)
+	 * and after physical encoder is disabled, to make sure timing
+	 * engine is already disabled (for video mode).
+	 */
+	_sde_encoder_dsc_disable(sde_enc);
+
 	/* after phys waits for frame-done, should be no more frames pending */
 	if (atomic_xchg(&sde_enc->frame_done_timeout, 0)) {
 		SDE_ERROR("enc%d timeout pending\n", drm_enc->base.id);
@@ -2091,11 +2230,13 @@
 
 	sde_encoder_resource_control(drm_enc, SDE_ENC_RC_EVENT_STOP);
 
-	if (sde_enc->cur_master) {
-		sde_enc->cur_master->connector = NULL;
-		sde_enc->cur_master = NULL;
+	for (i = 0; i < sde_enc->num_phys_encs; i++) {
+		if (sde_enc->phys_encs[i])
+			sde_enc->phys_encs[i]->connector = NULL;
 	}
 
+	sde_enc->cur_master = NULL;
+
 	SDE_DEBUG_ENC(sde_enc, "encoder disabled\n");
 
 	sde_rm_release(&sde_kms->rm, drm_enc);
@@ -2259,6 +2400,23 @@
 	}
 }
 
+static void sde_encoder_off_work(struct kthread_work *work)
+{
+	struct sde_encoder_virt *sde_enc = container_of(work,
+			struct sde_encoder_virt, delayed_off_work.work);
+
+	if (!sde_enc) {
+		SDE_ERROR("invalid sde encoder\n");
+		return;
+	}
+
+	sde_encoder_resource_control(&sde_enc->base,
+						SDE_ENC_RC_EVENT_ENTER_IDLE);
+
+	sde_encoder_frame_done_callback(&sde_enc->base, NULL,
+				SDE_ENCODER_FRAME_EVENT_IDLE);
+}
+
 /**
  * _sde_encoder_trigger_flush - trigger flush for a physical encoder
  * drm_enc: Pointer to drm encoder structure
@@ -2479,7 +2637,8 @@
 				phys->split_role == ENC_ROLE_SLAVE) &&
 				phys->split_role != ENC_ROLE_SKIP)
 			set_bit(i, sde_enc->frame_busy_mask);
-
+		if (phys->hw_ctl->ops.reg_dma_flush)
+			phys->hw_ctl->ops.reg_dma_flush(phys->hw_ctl);
 		if (!phys->ops.needs_single_flush ||
 				!phys->ops.needs_single_flush(phys))
 			_sde_encoder_trigger_flush(&sde_enc->base, phys, 0x0);
@@ -2689,6 +2848,165 @@
 		phys->hw_pp->ops.setup_dither(phys->hw_pp, dither_cfg, len);
 }
 
+static u32 _sde_encoder_calculate_linetime(struct sde_encoder_virt *sde_enc,
+		struct drm_display_mode *mode)
+{
+	u64 pclk_rate;
+	u32 pclk_period;
+	u32 line_time;
+
+	/*
+	 * For linetime calculation, only operate on master encoder.
+	 */
+	if (!sde_enc->cur_master)
+		return 0;
+
+	if (!sde_enc->cur_master->ops.get_line_count) {
+		SDE_ERROR("get_line_count function not defined\n");
+		return 0;
+	}
+
+	pclk_rate = mode->clock; /* pixel clock in kHz */
+	if (pclk_rate == 0) {
+		SDE_ERROR("pclk is 0, cannot calculate line time\n");
+		return 0;
+	}
+
+	pclk_period = DIV_ROUND_UP_ULL(1000000000ull, pclk_rate);
+	if (pclk_period == 0) {
+		SDE_ERROR("pclk period is 0\n");
+		return 0;
+	}
+
+	/*
+	 * Line time calculation based on Pixel clock and HTOTAL.
+	 * Final unit is in ns.
+	 */
+	line_time = (pclk_period * mode->htotal) / 1000;
+	if (line_time == 0) {
+		SDE_ERROR("line time calculation is 0\n");
+		return 0;
+	}
+
+	SDE_DEBUG_ENC(sde_enc,
+			"clk_rate=%lldkHz, clk_period=%d, linetime=%dns\n",
+			pclk_rate, pclk_period, line_time);
+
+	return line_time;
+}
+
+static int _sde_encoder_wakeup_time(struct drm_encoder *drm_enc,
+		ktime_t *wakeup_time)
+{
+	struct drm_display_mode *mode;
+	struct sde_encoder_virt *sde_enc;
+	u32 cur_line;
+	u32 line_time;
+	u32 vtotal, time_to_vsync;
+	ktime_t cur_time;
+
+	sde_enc = to_sde_encoder_virt(drm_enc);
+
+	if (!drm_enc->crtc || !drm_enc->crtc->state) {
+		SDE_ERROR("crtc/crtc state object is NULL\n");
+		return -EINVAL;
+	}
+	mode = &drm_enc->crtc->state->adjusted_mode;
+
+	line_time = _sde_encoder_calculate_linetime(sde_enc, mode);
+	if (!line_time)
+		return -EINVAL;
+
+	cur_line = sde_enc->cur_master->ops.get_line_count(sde_enc->cur_master);
+
+	vtotal = mode->vtotal;
+	if (cur_line >= vtotal)
+		time_to_vsync = line_time * vtotal;
+	else
+		time_to_vsync = line_time * (vtotal - cur_line);
+
+	if (time_to_vsync == 0) {
+		SDE_ERROR("time to vsync should not be zero, vtotal=%d\n",
+				vtotal);
+		return -EINVAL;
+	}
+
+	cur_time = ktime_get();
+	*wakeup_time = ktime_add_ns(cur_time, time_to_vsync);
+
+	SDE_DEBUG_ENC(sde_enc,
+			"cur_line=%u vtotal=%u time_to_vsync=%u, cur_time=%lld, wakeup_time=%lld\n",
+			cur_line, vtotal, time_to_vsync,
+			ktime_to_ms(cur_time),
+			ktime_to_ms(*wakeup_time));
+	return 0;
+}
+
+static void sde_encoder_vsync_event_handler(unsigned long data)
+{
+	struct drm_encoder *drm_enc = (struct drm_encoder *) data;
+	struct sde_encoder_virt *sde_enc;
+	struct msm_drm_private *priv;
+	struct msm_drm_thread *event_thread;
+	bool autorefresh_enabled = false;
+
+	if (!drm_enc || !drm_enc->dev || !drm_enc->dev->dev_private ||
+			!drm_enc->crtc) {
+		SDE_ERROR("invalid parameters\n");
+		return;
+	}
+
+	sde_enc = to_sde_encoder_virt(drm_enc);
+	priv = drm_enc->dev->dev_private;
+
+	if (drm_enc->crtc->index >= ARRAY_SIZE(priv->event_thread)) {
+		SDE_ERROR("invalid crtc index\n");
+		return;
+	}
+	event_thread = &priv->event_thread[drm_enc->crtc->index];
+	if (!event_thread) {
+		SDE_ERROR("event_thread not found for crtc:%d\n",
+				drm_enc->crtc->index);
+		return;
+	}
+
+	if (sde_enc->cur_master &&
+		sde_enc->cur_master->ops.is_autorefresh_enabled)
+		autorefresh_enabled =
+			sde_enc->cur_master->ops.is_autorefresh_enabled(
+						sde_enc->cur_master);
+
+	/*
+	 * Queue work to update the vsync event timer
+	 * if autorefresh is enabled.
+	 */
+	SDE_EVT32_VERBOSE(autorefresh_enabled);
+	if (autorefresh_enabled)
+		kthread_queue_work(&event_thread->worker,
+				&sde_enc->vsync_event_work);
+	else
+		del_timer(&sde_enc->vsync_event_timer);
+}
+
+static void sde_encoder_vsync_event_work_handler(struct kthread_work *work)
+{
+	struct sde_encoder_virt *sde_enc = container_of(work,
+			struct sde_encoder_virt, vsync_event_work);
+	ktime_t wakeup_time;
+
+	if (!sde_enc) {
+		SDE_ERROR("invalid sde encoder\n");
+		return;
+	}
+
+	if (_sde_encoder_wakeup_time(&sde_enc->base, &wakeup_time))
+		return;
+
+	SDE_EVT32_VERBOSE(ktime_to_ms(wakeup_time));
+	mod_timer(&sde_enc->vsync_event_timer,
+			nsecs_to_jiffies(ktime_to_ns(wakeup_time)));
+}
+
 void sde_encoder_prepare_for_kickoff(struct drm_encoder *drm_enc,
 		struct sde_encoder_kickoff_params *params)
 {
@@ -2752,11 +3070,51 @@
 	}
 }
 
-void sde_encoder_kickoff(struct drm_encoder *drm_enc)
+/**
+ * _sde_encoder_reset_ctl_hw - reset h/w configuration for all ctl's associated
+ *	with the specified encoder, and unstage all pipes from it
+ * @encoder:	encoder pointer
+ * Returns: 0 on success
+ */
+static int _sde_encoder_reset_ctl_hw(struct drm_encoder *drm_enc)
 {
 	struct sde_encoder_virt *sde_enc;
 	struct sde_encoder_phys *phys;
 	unsigned int i;
+	int rc = 0;
+
+	if (!drm_enc) {
+		SDE_ERROR("invalid encoder\n");
+		return -EINVAL;
+	}
+
+	sde_enc = to_sde_encoder_virt(drm_enc);
+
+	SDE_ATRACE_BEGIN("encoder_release_lm");
+	SDE_DEBUG_ENC(sde_enc, "\n");
+
+	for (i = 0; i < sde_enc->num_phys_encs; i++) {
+		phys = sde_enc->phys_encs[i];
+		if (!phys)
+			continue;
+
+		SDE_EVT32(DRMID(drm_enc), phys->intf_idx - INTF_0);
+
+		rc = sde_encoder_helper_reset_mixers(phys, NULL);
+		if (rc)
+			SDE_EVT32(DRMID(drm_enc), rc, SDE_EVTLOG_ERROR);
+	}
+
+	SDE_ATRACE_END("encoder_release_lm");
+	return rc;
+}
+
+void sde_encoder_kickoff(struct drm_encoder *drm_enc, bool is_error)
+{
+	struct sde_encoder_virt *sde_enc;
+	struct sde_encoder_phys *phys;
+	ktime_t wakeup_time;
+	unsigned int i;
 
 	if (!drm_enc) {
 		SDE_ERROR("invalid encoder\n");
@@ -2773,6 +3131,10 @@
 	mod_timer(&sde_enc->frame_done_timer, jiffies +
 		((atomic_read(&sde_enc->frame_done_timeout) * HZ) / 1000));
 
+	/* create a 'no pipes' commit to release buffers on errors */
+	if (is_error)
+		_sde_encoder_reset_ctl_hw(drm_enc);
+
 	/* All phys encs are ready to go, trigger the kickoff */
 	_sde_encoder_kickoff_phys(sde_enc);
 
@@ -2782,10 +3144,18 @@
 		if (phys && phys->ops.handle_post_kickoff)
 			phys->ops.handle_post_kickoff(phys);
 	}
+
+	if (sde_enc->disp_info.intf_type == DRM_MODE_CONNECTOR_DSI &&
+			!_sde_encoder_wakeup_time(drm_enc, &wakeup_time)) {
+		SDE_EVT32_VERBOSE(ktime_to_ms(wakeup_time));
+		mod_timer(&sde_enc->vsync_event_timer,
+				nsecs_to_jiffies(ktime_to_ns(wakeup_time)));
+	}
+
 	SDE_ATRACE_END("encoder_kickoff");
 }
 
-int sde_encoder_helper_hw_release(struct sde_encoder_phys *phys_enc,
+int sde_encoder_helper_reset_mixers(struct sde_encoder_phys *phys_enc,
 		struct drm_framebuffer *fb)
 {
 	struct drm_encoder *drm_enc;
@@ -2802,8 +3172,6 @@
 	memset(&mixer, 0, sizeof(mixer));
 
 	/* reset associated CTL/LMs */
-	if (phys_enc->hw_ctl->ops.clear_pending_flush)
-		phys_enc->hw_ctl->ops.clear_pending_flush(phys_enc->hw_ctl);
 	if (phys_enc->hw_ctl->ops.clear_all_blendstages)
 		phys_enc->hw_ctl->ops.clear_all_blendstages(phys_enc->hw_ctl);
 
@@ -2843,7 +3211,7 @@
 	}
 
 	if (!lm_valid) {
-		SDE_DEBUG_ENC(to_sde_encoder_virt(drm_enc), "lm not found\n");
+		SDE_ERROR_ENC(to_sde_encoder_virt(drm_enc), "lm not found\n");
 		return -EFAULT;
 	}
 	return 0;
@@ -3246,7 +3614,8 @@
 
 	SDE_DEBUG("dsi_info->num_of_h_tiles %d\n", disp_info->num_of_h_tiles);
 
-	if (disp_info->capabilities & MSM_DISPLAY_CAP_CMD_MODE)
+	if ((disp_info->capabilities & MSM_DISPLAY_CAP_CMD_MODE) ||
+	    (disp_info->capabilities & MSM_DISPLAY_CAP_VID_MODE))
 		sde_enc->idle_pc_supported = sde_kms->catalog->has_idle_pc;
 
 	mutex_lock(&sde_enc->enc_lock);
@@ -3399,6 +3768,12 @@
 	setup_timer(&sde_enc->frame_done_timer, sde_encoder_frame_done_timeout,
 			(unsigned long) sde_enc);
 
+	if ((disp_info->intf_type == DRM_MODE_CONNECTOR_DSI) &&
+			disp_info->is_primary)
+		setup_timer(&sde_enc->vsync_event_timer,
+				sde_encoder_vsync_event_handler,
+				(unsigned long)sde_enc);
+
 	snprintf(name, SDE_NAME_SIZE, "rsc_enc%u", drm_enc->base.id);
 	sde_enc->rsc_client = sde_rsc_client_create(SDE_RSC_INDEX, name,
 					disp_info->is_primary);
@@ -3411,6 +3786,10 @@
 	mutex_init(&sde_enc->rc_lock);
 	kthread_init_delayed_work(&sde_enc->delayed_off_work,
 			sde_encoder_off_work);
+	sde_enc->idle_timeout = IDLE_TIMEOUT;
+
+	kthread_init_work(&sde_enc->vsync_event_work,
+			sde_encoder_vsync_event_work_handler);
 
 	memcpy(&sde_enc->disp_info, disp_info, sizeof(*disp_info));
 
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder.h b/drivers/gpu/drm/msm/sde/sde_encoder.h
index 618d4ae..baf59b4 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder.h
+++ b/drivers/gpu/drm/msm/sde/sde_encoder.h
@@ -29,6 +29,9 @@
 #define SDE_ENCODER_FRAME_EVENT_PANEL_DEAD		BIT(2)
 #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE	BIT(3)
 #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE	BIT(4)
+#define SDE_ENCODER_FRAME_EVENT_IDLE			BIT(5)
+
+#define IDLE_TIMEOUT	(66 - 16/2)
 
 /**
  * Encoder functions and data types
@@ -125,8 +128,10 @@
  * sde_encoder_kickoff - trigger a double buffer flip of the ctl path
  *	(i.e. ctl flush and start) immediately.
  * @encoder:	encoder pointer
+ * @is_error:	whether the current commit needs to be aborted and replaced
+ *		with a 'safe' commit
  */
-void sde_encoder_kickoff(struct drm_encoder *encoder);
+void sde_encoder_kickoff(struct drm_encoder *encoder, bool is_error);
 
 /**
  * sde_encoder_wait_for_event - Waits for encoder events
@@ -205,4 +210,13 @@
  */
 void sde_encoder_prepare_commit(struct drm_encoder *drm_enc);
 
+/**
+ * sde_encoder_set_idle_timeout - set the idle timeout for video
+ *                    and command mode encoders.
+ * @drm_enc:    Pointer to previously created drm encoder structure
+ * @idle_timeout:    idle timeout duration in milliseconds
+ */
+void sde_encoder_set_idle_timeout(struct drm_encoder *drm_enc,
+							u32 idle_timeout);
+
 #endif /* __SDE_ENCODER_H__ */
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder_phys.h b/drivers/gpu/drm/msm/sde/sde_encoder_phys.h
index 5a78e4d..8813fd2 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder_phys.h
+++ b/drivers/gpu/drm/msm/sde/sde_encoder_phys.h
@@ -125,9 +125,12 @@
  *				SDE_ENC_ERR_NEEDS_HW_RESET state
  * @irq_control:		Handler to enable/disable all the encoder IRQs
  * @update_split_role:		Update the split role of the phys enc
+ * @prepare_idle_pc:		phys encoder can update the vsync_enable status
+ *                              on idle power collapse prepare
  * @restore:			Restore all the encoder configs.
  * @is_autorefresh_enabled:	provides the autorefresh current
  *                              enable/disable state.
+ * @get_line_count:		Obtain current vertical line count
  */
 
 struct sde_encoder_phys_ops {
@@ -167,8 +170,10 @@
 	void (*irq_control)(struct sde_encoder_phys *phys, bool enable);
 	void (*update_split_role)(struct sde_encoder_phys *phys_enc,
 			enum sde_enc_split_role role);
+	void (*prepare_idle_pc)(struct sde_encoder_phys *phys_enc);
 	void (*restore)(struct sde_encoder_phys *phys);
 	bool (*is_autorefresh_enabled)(struct sde_encoder_phys *phys);
+	int (*get_line_count)(struct sde_encoder_phys *phys);
 };
 
 /**
@@ -517,12 +522,12 @@
 		enum sde_intf interface);
 
 /**
- * sde_encoder_helper_hw_release - prepare for h/w reset during disable
+ * sde_encoder_helper_reset_mixers - reset mixers associated with phys enc
  * @phys_enc: Pointer to physical encoder structure
  * @fb: Optional fb for specifying new mixer output resolution, may be NULL
  * Return: Zero on success
  */
-int sde_encoder_helper_hw_release(struct sde_encoder_phys *phys_enc,
+int sde_encoder_helper_reset_mixers(struct sde_encoder_phys *phys_enc,
 		struct drm_framebuffer *fb);
 
 /**
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder_phys_cmd.c b/drivers/gpu/drm/msm/sde/sde_encoder_phys_cmd.c
index 70a25dd..4291098 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder_phys_cmd.c
@@ -34,9 +34,6 @@
 
 #define PP_TIMEOUT_MAX_TRIALS	10
 
-/* wait for 2 vyncs only */
-#define CTL_START_TIMEOUT_MS	32
-
 /*
  * Tearcheck sync start and continue thresholds are empirically found
  * based on common panels In the future, may want to allow panels to override
@@ -897,6 +894,30 @@
 	phys_enc->hw_pp->ops.connect_external_te(phys_enc->hw_pp, enable);
 }
 
+static void sde_encoder_phys_cmd_prepare_idle_pc(
+		struct sde_encoder_phys *phys_enc)
+{
+	_sde_encoder_phys_cmd_connect_te(phys_enc, false);
+}
+
+static int sde_encoder_phys_cmd_get_line_count(
+		struct sde_encoder_phys *phys_enc)
+{
+	struct sde_hw_pingpong *hw_pp;
+
+	if (!phys_enc || !phys_enc->hw_pp)
+		return -EINVAL;
+
+	if (!sde_encoder_phys_cmd_is_master(phys_enc))
+		return -EINVAL;
+
+	hw_pp = phys_enc->hw_pp;
+	if (!hw_pp->ops.get_line_count)
+		return -EINVAL;
+
+	return hw_pp->ops.get_line_count(hw_pp);
+}
+
 static void sde_encoder_phys_cmd_disable(struct sde_encoder_phys *phys_enc)
 {
 	struct sde_encoder_phys_cmd *cmd_enc =
@@ -1007,7 +1028,7 @@
 
 	wait_info.wq = &phys_enc->pending_kickoff_wq;
 	wait_info.atomic_cnt = &phys_enc->pending_ctlstart_cnt;
-	wait_info.timeout_ms = CTL_START_TIMEOUT_MS;
+	wait_info.timeout_ms = KICKOFF_TIMEOUT_MS;
 
 	/* slave encoder doesn't enable for ppsplit */
 	if (_sde_encoder_phys_is_ppsplit_slave(phys_enc))
@@ -1239,9 +1260,11 @@
 	ops->irq_control = sde_encoder_phys_cmd_irq_control;
 	ops->update_split_role = sde_encoder_phys_cmd_update_split_role;
 	ops->restore = sde_encoder_phys_cmd_enable_helper;
+	ops->prepare_idle_pc = sde_encoder_phys_cmd_prepare_idle_pc;
 	ops->is_autorefresh_enabled =
 			sde_encoder_phys_cmd_is_autorefresh_enabled;
 	ops->handle_post_kickoff = sde_encoder_phys_cmd_handle_post_kickoff;
+	ops->get_line_count = sde_encoder_phys_cmd_get_line_count;
 }
 
 struct sde_encoder_phys *sde_encoder_phys_cmd_init(
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder_phys_vid.c b/drivers/gpu/drm/msm/sde/sde_encoder_phys_vid.c
index 78c22c9..6a4348ba 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder_phys_vid.c
@@ -157,15 +157,6 @@
 	u32 needed_vfp_lines = worst_case_needed_lines - start_of_frame_lines;
 	u32 actual_vfp_lines = 0;
 
-	if (worst_case_needed_lines < start_of_frame_lines) {
-		needed_vfp_lines = 0;
-		SDE_ERROR("invalid params - needed_lines:%d, frame_lines:%d\n",
-				worst_case_needed_lines, start_of_frame_lines);
-	} else {
-		needed_vfp_lines = worst_case_needed_lines
-					- start_of_frame_lines;
-	}
-
 	/* Fetch must be outside active lines, otherwise undefined. */
 	if (start_of_frame_lines >= worst_case_needed_lines) {
 		SDE_DEBUG_VIDENC(vid_enc,
@@ -288,8 +279,9 @@
 		return;
 
 	SDE_DEBUG_VIDENC(vid_enc,
-		"rot_fetch_lines %u rot_fetch_start_vsync_counter %u\n",
-		rot_fetch_lines, rot_fetch_start_vsync_counter);
+		"rot_fetch_lines %u vfp_fetch_lines %u rot_fetch_start_vsync_counter %u\n",
+		rot_fetch_lines, vfp_fetch_lines,
+		rot_fetch_start_vsync_counter);
 
 	phys_enc->hw_ctl->ops.get_bitmask_intf(
 			phys_enc->hw_ctl, &flush_mask, vid_enc->hw_intf->idx);
@@ -464,10 +456,26 @@
 	return false;
 }
 
+static bool _sde_encoder_phys_is_dual_ctl(struct sde_encoder_phys *phys_enc)
+{
+	enum sde_rm_topology_name topology;
+
+	if (!phys_enc)
+		return false;
+
+	topology = sde_connector_get_topology_name(phys_enc->connector);
+	if ((topology == SDE_RM_TOPOLOGY_DUALPIPE_DSC) ||
+		(topology == SDE_RM_TOPOLOGY_DUALPIPE))
+		return true;
+
+	return false;
+}
+
 static bool sde_encoder_phys_vid_needs_single_flush(
 		struct sde_encoder_phys *phys_enc)
 {
-	return phys_enc && _sde_encoder_phys_is_ppsplit(phys_enc);
+	return phys_enc && (_sde_encoder_phys_is_ppsplit(phys_enc) ||
+		_sde_encoder_phys_is_dual_ctl(phys_enc));
 }
 
 static void _sde_encoder_phys_vid_setup_irq_hw_idx(
@@ -475,13 +483,19 @@
 {
 	struct sde_encoder_irq *irq;
 
+	/*
+	 * Initialize irq->hw_idx only when irq is not registered.
+	 * Prevent invalidating irq->irq_idx as modeset may be
+	 * called many times during dfps.
+	 */
+
 	irq = &phys_enc->irq[INTR_IDX_VSYNC];
-	irq->hw_idx = phys_enc->intf_idx;
-	irq->irq_idx = -EINVAL;
+	if (irq->irq_idx < 0)
+		irq->hw_idx = phys_enc->intf_idx;
 
 	irq = &phys_enc->irq[INTR_IDX_UNDERRUN];
-	irq->hw_idx = phys_enc->intf_idx;
-	irq->irq_idx = -EINVAL;
+	if (irq->irq_idx < 0)
+		irq->hw_idx = phys_enc->intf_idx;
 }
 
 static void sde_encoder_phys_vid_mode_set(
@@ -532,17 +546,25 @@
 {
 	int ret = 0;
 	struct sde_encoder_phys_vid *vid_enc;
+	int refcount;
 
 	if (!phys_enc) {
 		SDE_ERROR("invalid encoder\n");
 		return -EINVAL;
 	}
 
+	refcount = atomic_read(&phys_enc->vblank_refcount);
 	vid_enc = to_sde_encoder_phys_vid(phys_enc);
 
 	/* Slave encoders don't report vblank */
 	if (!sde_encoder_phys_vid_is_master(phys_enc))
-		return 0;
+		goto end;
+
+	/* protect against negative */
+	if (!enable && refcount == 0) {
+		ret = -EINVAL;
+		goto end;
+	}
 
 	SDE_DEBUG_VIDENC(vid_enc, "[%pS] enable=%d/%d\n",
 			__builtin_return_address(0),
@@ -557,11 +579,15 @@
 		ret = sde_encoder_helper_unregister_irq(phys_enc,
 				INTR_IDX_VSYNC);
 
-	if (ret)
+end:
+	if (ret) {
 		SDE_ERROR_VIDENC(vid_enc,
 				"control vblank irq error %d, enable %d\n",
 				ret, enable);
-
+		SDE_EVT32(DRMID(phys_enc->parent),
+				vid_enc->hw_intf->idx - INTF_0,
+				enable, refcount, SDE_EVTLOG_ERROR);
+	}
 	return ret;
 }
 
@@ -572,7 +598,6 @@
 	struct sde_hw_intf *intf;
 	struct sde_hw_ctl *ctl;
 	u32 flush_mask = 0;
-	int ret;
 
 	if (!phys_enc || !phys_enc->parent || !phys_enc->parent->dev ||
 			!phys_enc->parent->dev->dev_private) {
@@ -601,21 +626,13 @@
 	sde_encoder_helper_split_config(phys_enc, vid_enc->hw_intf->idx);
 
 	sde_encoder_phys_vid_setup_timing_engine(phys_enc);
-	ret = sde_encoder_phys_vid_control_vblank_irq(phys_enc, true);
-	if (ret)
-		goto end;
-
-	ret = sde_encoder_helper_register_irq(phys_enc, INTR_IDX_UNDERRUN);
-	if (ret) {
-		sde_encoder_phys_vid_control_vblank_irq(phys_enc, false);
-		goto end;
-	}
 
 	/*
-	 * For pp-split, skip setting the flush bit for the slave intf, since
-	 * both intfs use same ctl and HW will only flush the master.
+	 * For single flush cases (dual-ctl or pp-split), skip setting the
+	 * flush bit for the slave intf, since both intfs use same ctl
+	 * and HW will only flush the master.
 	 */
-	if (_sde_encoder_phys_is_ppsplit(phys_enc) &&
+	if (sde_encoder_phys_vid_needs_single_flush(phys_enc) &&
 		!sde_encoder_phys_vid_is_master(phys_enc))
 		goto skip_flush;
 
@@ -630,7 +647,6 @@
 	if (phys_enc->enable_state == SDE_ENC_DISABLED)
 		phys_enc->enable_state = SDE_ENC_ENABLING;
 
-end:
 	return;
 }
 
@@ -804,11 +820,8 @@
 			SDE_EVT32(DRMID(phys_enc->parent),
 					vid_enc->hw_intf->idx - INTF_0, ret);
 		}
-		sde_encoder_phys_vid_control_vblank_irq(phys_enc, false);
 	}
 
-	sde_encoder_helper_unregister_irq(phys_enc, INTR_IDX_UNDERRUN);
-
 	phys_enc->enable_state = SDE_ENC_DISABLED;
 }
 
@@ -840,6 +853,32 @@
 	}
 }
 
+static void sde_encoder_phys_vid_irq_control(struct sde_encoder_phys *phys_enc,
+		bool enable)
+{
+	struct sde_encoder_phys_vid *vid_enc;
+	int ret;
+
+	if (!phys_enc)
+		return;
+
+	vid_enc = to_sde_encoder_phys_vid(phys_enc);
+
+	SDE_EVT32(DRMID(phys_enc->parent), vid_enc->hw_intf->idx - INTF_0,
+			enable, atomic_read(&phys_enc->vblank_refcount));
+
+	if (enable) {
+		ret = sde_encoder_phys_vid_control_vblank_irq(phys_enc, true);
+		if (ret)
+			return;
+
+		sde_encoder_helper_register_irq(phys_enc, INTR_IDX_UNDERRUN);
+	} else {
+		sde_encoder_phys_vid_control_vblank_irq(phys_enc, false);
+		sde_encoder_helper_unregister_irq(phys_enc, INTR_IDX_UNDERRUN);
+	}
+}
+
 static void sde_encoder_phys_vid_setup_misr(struct sde_encoder_phys *phys_enc,
 						bool enable, u32 frame_count)
 {
@@ -866,6 +905,24 @@
 		vid_enc->hw_intf->ops.collect_misr(vid_enc->hw_intf) : 0;
 }
 
+static int sde_encoder_phys_vid_get_line_count(
+		struct sde_encoder_phys *phys_enc)
+{
+	struct sde_encoder_phys_vid *vid_enc;
+
+	if (!phys_enc)
+		return -EINVAL;
+
+	if (!sde_encoder_phys_vid_is_master(phys_enc))
+		return -EINVAL;
+
+	vid_enc = to_sde_encoder_phys_vid(phys_enc);
+	if (!vid_enc->hw_intf || !vid_enc->hw_intf->ops.get_line_count)
+		return -EINVAL;
+
+	return vid_enc->hw_intf->ops.get_line_count(vid_enc->hw_intf);
+}
+
 static void sde_encoder_phys_vid_init_ops(struct sde_encoder_phys_ops *ops)
 {
 	ops->is_master = sde_encoder_phys_vid_is_master;
@@ -879,12 +936,14 @@
 	ops->wait_for_commit_done = sde_encoder_phys_vid_wait_for_vblank;
 	ops->wait_for_vblank = sde_encoder_phys_vid_wait_for_vblank;
 	ops->wait_for_tx_complete = sde_encoder_phys_vid_wait_for_vblank;
+	ops->irq_control = sde_encoder_phys_vid_irq_control;
 	ops->prepare_for_kickoff = sde_encoder_phys_vid_prepare_for_kickoff;
 	ops->handle_post_kickoff = sde_encoder_phys_vid_handle_post_kickoff;
 	ops->needs_single_flush = sde_encoder_phys_vid_needs_single_flush;
 	ops->setup_misr = sde_encoder_phys_vid_setup_misr;
 	ops->collect_misr = sde_encoder_phys_vid_collect_misr;
 	ops->hw_reset = sde_encoder_helper_hw_reset;
+	ops->get_line_count = sde_encoder_phys_vid_get_line_count;
 }
 
 struct sde_encoder_phys *sde_encoder_phys_vid_init(
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c b/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
index 240e521..12115756 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
@@ -1139,7 +1139,9 @@
 	}
 
 	/* reset h/w before final flush */
-	if (sde_encoder_helper_hw_release(phys_enc, wb_enc->fb_disable))
+	if (phys_enc->hw_ctl->ops.clear_pending_flush)
+		phys_enc->hw_ctl->ops.clear_pending_flush(phys_enc->hw_ctl);
+	if (sde_encoder_helper_reset_mixers(phys_enc, wb_enc->fb_disable))
 		goto exit;
 
 	phys_enc->enable_state = SDE_ENC_DISABLING;
diff --git a/drivers/gpu/drm/msm/sde/sde_fence.c b/drivers/gpu/drm/msm/sde/sde_fence.c
index b3bc28f..816339b 100644
--- a/drivers/gpu/drm/msm/sde/sde_fence.c
+++ b/drivers/gpu/drm/msm/sde/sde_fence.c
@@ -136,31 +136,12 @@
 
 static void sde_fence_release(struct fence *fence)
 {
-	struct sde_fence *f = to_sde_fence(fence);
-	struct sde_fence *fc, *next;
-	struct sde_fence_context *ctx;
-	bool release_kref = false;
+	struct sde_fence *f;
 
-	if (!fence || !f->ctx)
-		return;
-
-	ctx = f->ctx;
-
-	spin_lock(&ctx->list_lock);
-	list_for_each_entry_safe(fc, next, &ctx->fence_list_head, fence_list) {
-		/* fence release called before signal */
-		if (f == fc) {
-			list_del_init(&fc->fence_list);
-			release_kref = true;
-			break;
-		}
+	if (fence) {
+		f = to_sde_fence(fence);
+		kfree(f);
 	}
-	spin_unlock(&ctx->list_lock);
-
-	/* keep kput outside spin_lock because it may release ctx */
-	if (release_kref)
-		kref_put(&ctx->kref, sde_fence_destroy);
-	kfree(f);
 }
 
 static void sde_fence_value_str(struct fence *fence, char *str, int size)
@@ -225,9 +206,9 @@
 	/* create fd */
 	fd = get_unused_fd_flags(0);
 	if (fd < 0) {
-		fence_put(&sde_fence->base);
 		SDE_ERROR("failed to get_unused_fd_flags(), %s\n",
 							sde_fence->name);
+		fence_put(&sde_fence->base);
 		goto exit;
 	}
 
@@ -236,8 +217,8 @@
 	if (sync_file == NULL) {
 		put_unused_fd(fd);
 		fd = -EINVAL;
-		fence_put(&sde_fence->base);
 		SDE_ERROR("couldn't create fence, %s\n", sde_fence->name);
+		fence_put(&sde_fence->base);
 		goto exit;
 	}
 
@@ -297,6 +278,44 @@
 	}
 }
 
+static void _sde_fence_trigger(struct sde_fence_context *ctx, ktime_t ts)
+{
+	unsigned long flags;
+	struct sde_fence *fc, *next;
+	bool is_signaled = false;
+	struct list_head local_list_head;
+
+	INIT_LIST_HEAD(&local_list_head);
+
+	spin_lock(&ctx->list_lock);
+	if (list_empty(&ctx->fence_list_head)) {
+		SDE_DEBUG("nothing to trigger!\n");
+		spin_unlock(&ctx->list_lock);
+		return;
+	}
+
+	list_for_each_entry_safe(fc, next, &ctx->fence_list_head, fence_list)
+		list_move(&fc->fence_list, &local_list_head);
+	spin_unlock(&ctx->list_lock);
+
+	list_for_each_entry_safe(fc, next, &local_list_head, fence_list) {
+		spin_lock_irqsave(&ctx->lock, flags);
+		fc->base.timestamp = ts;
+		is_signaled = fence_is_signaled_locked(&fc->base);
+		spin_unlock_irqrestore(&ctx->lock, flags);
+
+		if (is_signaled) {
+			list_del_init(&fc->fence_list);
+			fence_put(&fc->base);
+			kref_put(&ctx->kref, sde_fence_destroy);
+		} else {
+			spin_lock(&ctx->list_lock);
+			list_move(&fc->fence_list, &ctx->fence_list_head);
+			spin_unlock(&ctx->list_lock);
+		}
+	}
+}
+
 int sde_fence_create(struct sde_fence_context *ctx, uint64_t *val,
 							uint32_t offset)
 {
@@ -330,10 +349,12 @@
 
 	SDE_EVT32(ctx->drm_id, trigger_value, fd);
 
-	if (fd >= 0)
+	if (fd >= 0) {
 		rc = 0;
-	else
+		_sde_fence_trigger(ctx, ktime_get());
+	} else {
 		rc = fd;
+	}
 
 	return rc;
 }
@@ -342,17 +363,12 @@
 							bool reset_timeline)
 {
 	unsigned long flags;
-	struct sde_fence *fc, *next;
-	bool is_signaled = false;
-	struct list_head local_list_head;
 
 	if (!ctx) {
 		SDE_ERROR("invalid ctx, %pK\n", ctx);
 		return;
 	}
 
-	INIT_LIST_HEAD(&local_list_head);
-
 	spin_lock_irqsave(&ctx->lock, flags);
 	if (reset_timeline) {
 		if ((int)(ctx->done_count - ctx->commit_count) < 0) {
@@ -384,29 +400,5 @@
 	SDE_EVT32(ctx->drm_id, ctx->done_count, ctx->commit_count,
 			ktime_to_us(ts));
 
-	spin_lock(&ctx->list_lock);
-	if (list_empty(&ctx->fence_list_head)) {
-		SDE_DEBUG("nothing to trigger!-no get_prop call\n");
-		spin_unlock(&ctx->list_lock);
-		return;
-	}
-
-	list_for_each_entry_safe(fc, next, &ctx->fence_list_head, fence_list)
-		list_move(&fc->fence_list, &local_list_head);
-	spin_unlock(&ctx->list_lock);
-
-	list_for_each_entry_safe(fc, next, &local_list_head, fence_list) {
-		spin_lock_irqsave(&ctx->lock, flags);
-		fc->base.timestamp = ts;
-		is_signaled = fence_is_signaled_locked(&fc->base);
-		spin_unlock_irqrestore(&ctx->lock, flags);
-
-		if (is_signaled) {
-			kref_put(&ctx->kref, sde_fence_destroy);
-		} else {
-			spin_lock(&ctx->list_lock);
-			list_move(&fc->fence_list, &ctx->fence_list_head);
-			spin_unlock(&ctx->list_lock);
-		}
-	}
+	_sde_fence_trigger(ctx, ts);
 }
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_catalog.c b/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
index 0e1ab51..aea2c6b 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
@@ -36,9 +36,12 @@
 /* each entry will have register address and bit offset in that register */
 #define MAX_BIT_OFFSET 2
 
-/* default line width for sspp */
+/* default line width for sspp, mixer, ds (input), wb */
 #define DEFAULT_SDE_LINE_WIDTH 2048
 
+/* default output line width for ds */
+#define DEFAULT_SDE_OUTPUT_LINE_WIDTH 2560
+
 /* max mixer blend stages */
 #define DEFAULT_SDE_MIXER_BLENDSTAGES 7
 
@@ -60,8 +63,8 @@
 /* total number of intf - dp, dsi, hdmi */
 #define INTF_COUNT			3
 
-#define MAX_SSPP_UPSCALE		20
-#define MAX_SSPP_DOWNSCALE		4
+#define MAX_UPSCALE_RATIO		20
+#define MAX_DOWNSCALE_RATIO		4
 #define SSPP_UNITY_SCALE		1
 
 #define MAX_HORZ_DECIMATION		4
@@ -140,12 +143,16 @@
 	DIM_LAYER,
 	SMART_DMA_REV,
 	IDLE_PC,
+	DEST_SCALER,
 	SDE_PROP_MAX,
 };
 
 enum {
 	PERF_MAX_BW_LOW,
 	PERF_MAX_BW_HIGH,
+	PERF_MIN_CORE_IB,
+	PERF_MIN_LLCC_IB,
+	PERF_MIN_DRAM_IB,
 	PERF_CORE_IB_FF,
 	PERF_CORE_CLK_FF,
 	PERF_COMP_RATIO_RT,
@@ -230,6 +237,20 @@
 };
 
 enum {
+	DS_TOP_OFF,
+	DS_TOP_LEN,
+	DS_TOP_INPUT_LINEWIDTH,
+	DS_TOP_OUTPUT_LINEWIDTH,
+	DS_TOP_PROP_MAX,
+};
+
+enum {
+	DS_OFF,
+	DS_LEN,
+	DS_PROP_MAX,
+};
+
+enum {
 	DSPP_TOP_OFF,
 	DSPP_TOP_SIZE,
 	DSPP_TOP_PROP_MAX,
@@ -371,11 +392,15 @@
 	{DIM_LAYER, "qcom,sde-has-dim-layer", false, PROP_TYPE_BOOL},
 	{SMART_DMA_REV, "qcom,sde-smart-dma-rev", false, PROP_TYPE_STRING},
 	{IDLE_PC, "qcom,sde-has-idle-pc", false, PROP_TYPE_BOOL},
+	{DEST_SCALER, "qcom,sde-has-dest-scaler", false, PROP_TYPE_BOOL},
 };
 
 static struct sde_prop_type sde_perf_prop[] = {
 	{PERF_MAX_BW_LOW, "qcom,sde-max-bw-low-kbps", false, PROP_TYPE_U32},
 	{PERF_MAX_BW_HIGH, "qcom,sde-max-bw-high-kbps", false, PROP_TYPE_U32},
+	{PERF_MIN_CORE_IB, "qcom,sde-min-core-ib-kbps", false, PROP_TYPE_U32},
+	{PERF_MIN_LLCC_IB, "qcom,sde-min-llcc-ib-kbps", false, PROP_TYPE_U32},
+	{PERF_MIN_DRAM_IB, "qcom,sde-min-dram-ib-kbps", false, PROP_TYPE_U32},
 	{PERF_CORE_IB_FF, "qcom,sde-core-ib-ff", false, PROP_TYPE_STRING},
 	{PERF_CORE_CLK_FF, "qcom,sde-core-clk-ff", false, PROP_TYPE_STRING},
 	{PERF_COMP_RATIO_RT, "qcom,sde-comp-ratio-rt", false,
@@ -500,6 +525,20 @@
 	{AD_VERSION, "qcom,sde-dspp-ad-version", false, PROP_TYPE_U32},
 };
 
+static struct sde_prop_type ds_top_prop[] = {
+	{DS_TOP_OFF, "qcom,sde-dest-scaler-top-off", false, PROP_TYPE_U32},
+	{DS_TOP_LEN, "qcom,sde-dest-scaler-top-size", false, PROP_TYPE_U32},
+	{DS_TOP_INPUT_LINEWIDTH, "qcom,sde-max-dest-scaler-input-linewidth",
+		false, PROP_TYPE_U32},
+	{DS_TOP_OUTPUT_LINEWIDTH, "qcom,sde-max-dest-scaler-output-linewidth",
+		false, PROP_TYPE_U32},
+};
+
+static struct sde_prop_type ds_prop[] = {
+	{DS_OFF, "qcom,sde-dest-scaler-off", false, PROP_TYPE_U32_ARRAY},
+	{DS_LEN, "qcom,sde-dest-scaler-size", false, PROP_TYPE_U32},
+};
+
 static struct sde_prop_type pp_prop[] = {
 	{PP_OFF, "qcom,sde-pp-off", true, PROP_TYPE_U32_ARRAY},
 	{PP_LEN, "qcom,sde-pp-size", false, PROP_TYPE_U32},
@@ -857,8 +896,8 @@
 	struct sde_sspp_cfg *sspp, struct sde_sspp_sub_blks *sblk,
 	bool *prop_exists, struct sde_prop_value *prop_value, u32 *vig_count)
 {
-	sblk->maxupscale = MAX_SSPP_UPSCALE;
-	sblk->maxdwnscale = MAX_SSPP_DOWNSCALE;
+	sblk->maxupscale = MAX_UPSCALE_RATIO;
+	sblk->maxdwnscale = MAX_DOWNSCALE_RATIO;
 	sspp->id = SSPP_VIG0 + *vig_count;
 	snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
 			sspp->id - SSPP_VIG0);
@@ -952,8 +991,8 @@
 	struct sde_sspp_cfg *sspp, struct sde_sspp_sub_blks *sblk,
 	bool *prop_exists, struct sde_prop_value *prop_value, u32 *rgb_count)
 {
-	sblk->maxupscale = MAX_SSPP_UPSCALE;
-	sblk->maxdwnscale = MAX_SSPP_DOWNSCALE;
+	sblk->maxupscale = MAX_UPSCALE_RATIO;
+	sblk->maxdwnscale = MAX_DOWNSCALE_RATIO;
 	sspp->id = SSPP_RGB0 + *rgb_count;
 	snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
 			sspp->id - SSPP_VIG0);
@@ -1287,8 +1326,8 @@
 	u32 off_count, blend_off_count, max_blendstages, lm_pair_mask;
 	struct sde_lm_cfg *mixer;
 	struct sde_lm_sub_blks *sblk;
-	int pp_count, dspp_count;
-	u32 pp_idx, dspp_idx;
+	int pp_count, dspp_count, ds_count;
+	u32 pp_idx, dspp_idx, ds_idx;
 	struct device_node *snp = NULL;
 
 	if (!sde_cfg) {
@@ -1319,6 +1358,7 @@
 
 	pp_count = sde_cfg->pingpong_count;
 	dspp_count = sde_cfg->dspp_count;
+	ds_count = sde_cfg->ds_count;
 
 	/* get mixer feature dt properties if they exist */
 	snp = of_get_child_by_name(np, mixer_prop[MIXER_BLOCKS].prop_name);
@@ -1358,7 +1398,7 @@
 	if (rc)
 		goto end;
 
-	for (i = 0, pp_idx = 0, dspp_idx = 0; i < off_count; i++) {
+	for (i = 0, pp_idx = 0, dspp_idx = 0, ds_idx = 0; i < off_count; i++) {
 		mixer = sde_cfg->mixer + i;
 		sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
 		if (!sblk) {
@@ -1400,13 +1440,17 @@
 								: PINGPONG_MAX;
 			mixer->dspp = dspp_count > 0 ? dspp_idx + DSPP_0
 								: DSPP_MAX;
+			mixer->ds = ds_count > 0 ? ds_idx + DS_0 : DS_MAX;
 			pp_count--;
 			dspp_count--;
+			ds_count--;
 			pp_idx++;
 			dspp_idx++;
+			ds_idx++;
 		} else {
 			mixer->pingpong = PINGPONG_MAX;
 			mixer->dspp = DSPP_MAX;
+			mixer->ds = DS_MAX;
 		}
 
 		sblk->gc.id = SDE_MIXER_GC;
@@ -2038,6 +2082,116 @@
 	return rc;
 }
 
+static int sde_ds_parse_dt(struct device_node *np,
+			struct sde_mdss_cfg *sde_cfg)
+{
+	int rc, prop_count[DS_PROP_MAX], top_prop_count[DS_TOP_PROP_MAX], i;
+	struct sde_prop_value *prop_value = NULL, *top_prop_value = NULL;
+	bool prop_exists[DS_PROP_MAX], top_prop_exists[DS_TOP_PROP_MAX];
+	u32 off_count = 0, top_off_count = 0;
+	struct sde_ds_cfg *ds;
+	struct sde_ds_top_cfg *ds_top = NULL;
+
+	if (!sde_cfg) {
+		SDE_ERROR("invalid argument\n");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	if (!sde_cfg->mdp[0].has_dest_scaler) {
+		SDE_DEBUG("dest scaler feature not supported\n");
+		rc = 0;
+		goto end;
+	}
+
+	/* Parse the dest scaler top register offset and capabilities */
+	top_prop_value = kzalloc(DS_TOP_PROP_MAX *
+			sizeof(struct sde_prop_value), GFP_KERNEL);
+	if (!top_prop_value) {
+		rc = -ENOMEM;
+		goto end;
+	}
+
+	rc = _validate_dt_entry(np, ds_top_prop,
+				ARRAY_SIZE(ds_top_prop),
+				top_prop_count, &top_off_count);
+	if (rc)
+		goto end;
+
+	rc = _read_dt_entry(np, ds_top_prop,
+			ARRAY_SIZE(ds_top_prop), top_prop_count,
+			top_prop_exists, top_prop_value);
+	if (rc)
+		goto end;
+
+	/* Parse the offset of each dest scaler block */
+	prop_value = kzalloc(DS_PROP_MAX *
+			sizeof(struct sde_prop_value), GFP_KERNEL);
+	if (!prop_value) {
+		rc = -ENOMEM;
+		goto end;
+	}
+
+	rc = _validate_dt_entry(np, ds_prop, ARRAY_SIZE(ds_prop), prop_count,
+		&off_count);
+	if (rc)
+		goto end;
+
+	sde_cfg->ds_count = off_count;
+
+	rc = _read_dt_entry(np, ds_prop, ARRAY_SIZE(ds_prop), prop_count,
+		prop_exists, prop_value);
+	if (rc)
+		goto end;
+
+	if (!off_count)
+		goto end;
+
+	ds_top = kzalloc(sizeof(struct sde_ds_top_cfg), GFP_KERNEL);
+	if (!ds_top) {
+		rc = -ENOMEM;
+		goto end;
+	}
+
+	ds_top->id = DS_TOP;
+	snprintf(ds_top->name, SDE_HW_BLK_NAME_LEN, "ds_top_%u",
+		ds_top->id - DS_TOP);
+	ds_top->base = PROP_VALUE_ACCESS(top_prop_value, DS_TOP_OFF, 0);
+	ds_top->len = PROP_VALUE_ACCESS(top_prop_value, DS_TOP_LEN, 0);
+	ds_top->maxupscale = MAX_UPSCALE_RATIO;
+
+	ds_top->maxinputwidth = PROP_VALUE_ACCESS(top_prop_value,
+			DS_TOP_INPUT_LINEWIDTH, 0);
+	if (!top_prop_exists[DS_TOP_INPUT_LINEWIDTH])
+		ds_top->maxinputwidth = DEFAULT_SDE_LINE_WIDTH;
+
+	ds_top->maxoutputwidth = PROP_VALUE_ACCESS(top_prop_value,
+			DS_TOP_OUTPUT_LINEWIDTH, 0);
+	if (!top_prop_exists[DS_TOP_OUTPUT_LINEWIDTH])
+		ds_top->maxoutputwidth = DEFAULT_SDE_OUTPUT_LINE_WIDTH;
+
+	for (i = 0; i < off_count; i++) {
+		ds = sde_cfg->ds + i;
+		ds->top = ds_top;
+		ds->base = PROP_VALUE_ACCESS(prop_value, DS_OFF, i);
+		ds->id = DS_0 + i;
+		ds->len = PROP_VALUE_ACCESS(prop_value, DS_LEN, 0);
+		snprintf(ds->name, SDE_HW_BLK_NAME_LEN, "ds_%u",
+			ds->id - DS_0);
+
+		if (!prop_exists[DS_LEN])
+			ds->len = DEFAULT_SDE_HW_BLOCK_LEN;
+
+		if (sde_cfg->qseed_type == SDE_SSPP_SCALER_QSEED3)
+			set_bit(SDE_SSPP_SCALER_QSEED3, &ds->features);
+	}
+
+end:
+	kfree(top_prop_value);
+	kfree(prop_value);
+	return rc;
+};
+
 static int sde_dsc_parse_dt(struct device_node *np,
 			struct sde_mdss_cfg *sde_cfg)
 {
@@ -2542,6 +2696,9 @@
 	if (!prop_exists[UBWC_SWIZZLE])
 		cfg->mdp[0].ubwc_swizzle = DEFAULT_SDE_UBWC_SWIZZLE;
 
+	cfg->mdp[0].has_dest_scaler =
+		PROP_VALUE_ACCESS(prop_value, DEST_SCALER, 0);
+
 	rc = of_property_read_string(np, sde_prop[QSEED_TYPE].prop_name, &type);
 	if (!rc && !strcmp(type, "qseedv3")) {
 		cfg->qseed_type = SDE_SSPP_SCALER_QSEED3;
@@ -2691,6 +2848,18 @@
 			prop_exists[PERF_MAX_BW_HIGH] ?
 			PROP_VALUE_ACCESS(prop_value, PERF_MAX_BW_HIGH, 0) :
 			DEFAULT_MAX_BW_HIGH;
+	cfg->perf.min_core_ib =
+			prop_exists[PERF_MIN_CORE_IB] ?
+			PROP_VALUE_ACCESS(prop_value, PERF_MIN_CORE_IB, 0) :
+			DEFAULT_MAX_BW_LOW;
+	cfg->perf.min_llcc_ib =
+			prop_exists[PERF_MIN_LLCC_IB] ?
+			PROP_VALUE_ACCESS(prop_value, PERF_MIN_LLCC_IB, 0) :
+			DEFAULT_MAX_BW_LOW;
+	cfg->perf.min_dram_ib =
+			prop_exists[PERF_MIN_DRAM_IB] ?
+			PROP_VALUE_ACCESS(prop_value, PERF_MIN_DRAM_IB, 0) :
+			DEFAULT_MAX_BW_LOW;
 
 	/*
 	 * The following performance parameters (e.g. core_ib_ff) are
@@ -2873,7 +3042,8 @@
 	vig_list_size += ARRAY_SIZE(rgb_10bit_formats)
 		+ ARRAY_SIZE(tp10_ubwc_formats)
 		+ ARRAY_SIZE(p010_formats);
-	if (IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_400))
+	if (IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_400) ||
+		(IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_410)))
 		vig_list_size += ARRAY_SIZE(p010_ubwc_formats);
 
 	wb2_list_size += ARRAY_SIZE(rgb_10bit_formats)
@@ -2914,7 +3084,8 @@
 		ARRAY_SIZE(rgb_10bit_formats));
 	index += sde_copy_formats(sde_cfg->vig_formats, vig_list_size,
 		index, p010_formats, ARRAY_SIZE(p010_formats));
-	if (IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_400))
+	if (IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_400) ||
+		(IS_SDE_MAJOR_MINOR_SAME((hw_rev), SDE_HW_VER_410)))
 		index += sde_copy_formats(sde_cfg->vig_formats,
 			vig_list_size, index, p010_ubwc_formats,
 			ARRAY_SIZE(p010_ubwc_formats));
@@ -2944,33 +3115,25 @@
 
 	rc = sde_hardware_format_caps(sde_cfg, hw_rev);
 
-	switch (hw_rev) {
-	case SDE_HW_VER_170:
-	case SDE_HW_VER_171:
-	case SDE_HW_VER_172:
+	if (IS_MSM8996_TARGET(hw_rev)) {
 		/* update msm8996 target here */
 		sde_cfg->perf.min_prefill_lines = 21;
-		break;
-	case SDE_HW_VER_300:
-	case SDE_HW_VER_301:
+	} else if (IS_MSM8998_TARGET(hw_rev)) {
 		/* update msm8998 target here */
 		sde_cfg->has_wb_ubwc = true;
 		sde_cfg->perf.min_prefill_lines = 25;
 		sde_cfg->vbif_qos_nlvl = 4;
 		sde_cfg->ts_prefill_rev = 1;
-		sde_cfg->perf.min_prefill_lines = 25;
-		break;
-	case SDE_HW_VER_400:
+	} else if (IS_SDM845_TARGET(hw_rev) || IS_SDM670_TARGET(hw_rev)) {
 		/* update sdm845 target here */
 		sde_cfg->has_wb_ubwc = true;
 		sde_cfg->perf.min_prefill_lines = 24;
 		sde_cfg->vbif_qos_nlvl = 8;
 		sde_cfg->ts_prefill_rev = 2;
-		sde_cfg->perf.min_prefill_lines = 24;
-		break;
-	default:
+	} else {
+		SDE_ERROR("unsupported chipset id:%X\n", hw_rev);
 		sde_cfg->perf.min_prefill_lines = 0xffff;
-		break;
+		rc = -ENODEV;
 	}
 
 	return rc;
@@ -2995,6 +3158,9 @@
 	for (i = 0; i < sde_cfg->dspp_count; i++)
 		kfree(sde_cfg->dspp[i].sblk);
 
+	if (sde_cfg->ds_count)
+		kfree(sde_cfg->ds[0].top);
+
 	for (i = 0; i < sde_cfg->pingpong_count; i++)
 		kfree(sde_cfg->pingpong[i].sblk);
 
@@ -3063,6 +3229,10 @@
 	if (rc)
 		goto end;
 
+	rc = sde_ds_parse_dt(np, sde_cfg);
+	if (rc)
+		goto end;
+
 	rc = sde_dsc_parse_dt(np, sde_cfg);
 	if (rc)
 		goto end;
@@ -3071,7 +3241,9 @@
 	if (rc)
 		goto end;
 
-	/* mixer parsing should be done after dspp and pp for mapping setup */
+	/* mixer parsing should be done after dspp,
+	 * ds and pp for mapping setup
+	 */
 	rc = sde_mixer_parse_dt(np, sde_cfg);
 	if (rc)
 		goto end;
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_catalog.h b/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
index fa10a88..e60b5ca 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
@@ -45,8 +45,13 @@
 #define SDE_HW_VER_300	SDE_HW_VER(3, 0, 0) /* 8998 v1.0 */
 #define SDE_HW_VER_301	SDE_HW_VER(3, 0, 1) /* 8998 v1.1 */
 #define SDE_HW_VER_400	SDE_HW_VER(4, 0, 0) /* sdm845 v1.0 */
+#define SDE_HW_VER_401	SDE_HW_VER(4, 0, 1) /* sdm845 v2.0 */
+#define SDE_HW_VER_410	SDE_HW_VER(4, 1, 0) /* sdm670 v1.0 */
 
+#define IS_MSM8996_TARGET(rev) IS_SDE_MAJOR_MINOR_SAME((rev), SDE_HW_VER_170)
+#define IS_MSM8998_TARGET(rev) IS_SDE_MAJOR_MINOR_SAME((rev), SDE_HW_VER_300)
 #define IS_SDM845_TARGET(rev) IS_SDE_MAJOR_MINOR_SAME((rev), SDE_HW_VER_400)
+#define IS_SDM670_TARGET(rev) IS_SDE_MAJOR_MINOR_SAME((rev), SDE_HW_VER_410)
 
 #define SDE_HW_BLK_NAME_LEN	16
 
@@ -514,6 +519,7 @@
  * @highest_bank_bit:  UBWC parameter
  * @ubwc_static:       ubwc static configuration
  * @ubwc_swizzle:      ubwc default swizzle setting
+ * @has_dest_scaler:   indicates support of destination scaler
  * @clk_ctrls          clock control register definition
  */
 struct sde_mdp_cfg {
@@ -521,6 +527,7 @@
 	u32 highest_bank_bit;
 	u32 ubwc_static;
 	u32 ubwc_swizzle;
+	bool has_dest_scaler;
 	struct sde_clk_ctrl_reg clk_ctrls[SDE_CLK_CTRL_MAX];
 };
 
@@ -559,6 +566,7 @@
  * @sblk:              LM Sub-blocks information
  * @dspp:              ID of connected DSPP, DSPP_MAX if unsupported
  * @pingpong:          ID of connected PingPong, PINGPONG_MAX if unsupported
+ * @ds:                ID of connected DS, DS_MAX if unsupported
  * @lm_pair_mask:      Bitmask of LMs that can be controlled by same CTL
  */
 struct sde_lm_cfg {
@@ -566,6 +574,7 @@
 	const struct sde_lm_sub_blks *sblk;
 	u32 dspp;
 	u32 pingpong;
+	u32 ds;
 	unsigned long lm_pair_mask;
 };
 
@@ -594,6 +603,38 @@
 };
 
 /**
+ * struct sde_ds_top_cfg - information of dest scaler top
+ * @id               enum identifying this block
+ * @base             register offset of this block
+ * @features         bit mask identifying features
+ * @version          hw version of dest scaler
+ * @maxinputwidth    maximum input line width
+ * @maxoutputwidth   maximum output line width
+ * @maxupscale       maximum upscale ratio
+ */
+struct sde_ds_top_cfg {
+	SDE_HW_BLK_INFO;
+	u32 version;
+	u32 maxinputwidth;
+	u32 maxoutputwidth;
+	u32 maxupscale;
+};
+
+/**
+ * struct sde_ds_cfg - information of dest scaler blocks
+ * @id          enum identifying this block
+ * @base        register offset wrt DS top offset
+ * @features    bit mask identifying features
+ * @version     hw version of the qseed block
+ * @top         DS top information
+ */
+struct sde_ds_cfg {
+	SDE_HW_BLK_INFO;
+	u32 version;
+	const struct sde_ds_top_cfg *top;
+};
+
+/**
  * struct sde_pingpong_cfg - information of PING-PONG blocks
  * @id                 enum identifying this block
  * @base               register offset of this block
@@ -800,6 +841,10 @@
  * struct sde_perf_cfg - performance control settings
  * @max_bw_low         low threshold of maximum bandwidth (kbps)
  * @max_bw_high        high threshold of maximum bandwidth (kbps)
+ * @min_core_ib        minimum bandwidth for core (kbps)
+ * @min_core_ib        minimum mnoc ib vote in kbps
+ * @min_llcc_ib        minimum llcc ib vote in kbps
+ * @min_dram_ib        minimum dram ib vote in kbps
  * @core_ib_ff         core instantaneous bandwidth fudge factor
  * @core_clk_ff        core clock fudge factor
  * @comp_ratio_rt      string of 0 or more of <fourcc>/<ven>/<mod>/<comp ratio>
@@ -821,6 +866,9 @@
 struct sde_perf_cfg {
 	u32 max_bw_low;
 	u32 max_bw_high;
+	u32 min_core_ib;
+	u32 min_llcc_ib;
+	u32 min_dram_ib;
 	const char *core_ib_ff;
 	const char *core_clk_ff;
 	const char *comp_ratio_rt;
@@ -909,6 +957,9 @@
 	u32 dspp_count;
 	struct sde_dspp_cfg dspp[MAX_BLOCKS];
 
+	u32 ds_count;
+	struct sde_ds_cfg ds[MAX_BLOCKS];
+
 	u32 pingpong_count;
 	struct sde_pingpong_cfg pingpong[MAX_BLOCKS];
 
@@ -961,6 +1012,7 @@
 #define BLK_CURSOR(s) ((s)->cursor)
 #define BLK_MIXER(s) ((s)->mixer)
 #define BLK_DSPP(s) ((s)->dspp)
+#define BLK_DS(s) ((s)->ds)
 #define BLK_PINGPONG(s) ((s)->pingpong)
 #define BLK_CDM(s) ((s)->cdm)
 #define BLK_INTF(s) ((s)->intf)
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_cdm.c b/drivers/gpu/drm/msm/sde/sde_hw_cdm.c
index 304106d..7a391ae 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_cdm.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_cdm.c
@@ -81,6 +81,7 @@
 		if (cdm == m->cdm[i].id) {
 			b->base_off = addr;
 			b->blk_off = m->cdm[i].base;
+			b->length = m->cdm[i].len;
 			b->hwversion = m->hwversion;
 			b->log_mask = SDE_DBG_MASK_CDM;
 			return &m->cdm[i];
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_color_proc_v4.c b/drivers/gpu/drm/msm/sde/sde_hw_color_proc_v4.c
index dcfd81d..f5aeddf 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_color_proc_v4.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_color_proc_v4.c
@@ -49,7 +49,6 @@
 		break;
 	case GAMUT_3D_MODE_5:
 		*opcode = gamut_mode_5 << 2;
-		*opcode |= GAMUT_MAP_EN;
 		tbl_len = GAMUT_3D_MODE5_TBL_SZ;
 		tbl_off = GAMUT_MODE_5_OFF;
 		scale_off = GAMUT_SCALEB_OFFSET_OFF;
@@ -81,7 +80,8 @@
 		else
 			scale_tbl_len = GAMUT_3D_SCALEB_OFF_SZ;
 		for (i = 0; i < GAMUT_3D_SCALE_OFF_TBL_NUM; i++) {
-			scale_tbl_off = base + scale_off + i * scale_tbl_len;
+			scale_tbl_off = base + scale_off +
+					i * scale_tbl_len * sizeof(u32);
 			scale_data = &payload->scale_off[i][0];
 			for (j = 0; j < scale_tbl_len; j++)
 				SDE_REG_WRITE(hw,
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.c b/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.c
index 4191367..8e54a2a 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.c
@@ -12,6 +12,7 @@
 
 #include <drm/msm_drm_pp.h>
 #include "sde_hw_color_processing_v1_7.h"
+#include "sde_hw_ctl.h"
 
 #define PA_HUE_VIG_OFF		0x110
 #define PA_SAT_VIG_OFF		0x114
@@ -23,9 +24,15 @@
 #define PA_VAL_DSPP_OFF		0x240
 #define PA_CONT_DSPP_OFF	0x244
 
+#define PA_HIST_CTRL_DSPP_OFF	0x4
+#define PA_HIST_DATA_DSPP_OFF	0x400
+
 #define PA_LUTV_DSPP_OFF	0x1400
 #define PA_LUT_SWAP_OFF		0x234
 
+#define PA_LUTV_DSPP_CTRL_OFF	0x4c
+#define PA_LUTV_DSPP_SWAP_OFF	0x18
+
 #define PA_HUE_MASK		0xFFF
 #define PA_SAT_MASK		0xFFFF
 #define PA_VAL_MASK		0xFF
@@ -66,6 +73,7 @@
 #define DSPP_OP_PA_CONT_EN	BIT(28)
 #define DSPP_OP_PA_EN		BIT(20)
 #define DSPP_OP_PA_LUTV_EN	BIT(19)
+#define DSPP_OP_PA_HIST_EN	BIT(16)
 #define DSPP_OP_PA_SKIN_EN	BIT(5)
 #define DSPP_OP_PA_FOL_EN	BIT(6)
 #define DSPP_OP_PA_SKY_EN	BIT(7)
@@ -458,6 +466,62 @@
 	SDE_REG_WRITE(&ctx->hw, base, op_mode);
 }
 
+void sde_setup_dspp_pa_vlut_v1_8(struct sde_hw_dspp *ctx, void *cfg)
+{
+	struct drm_msm_pa_vlut *payload = NULL;
+	struct sde_hw_cp_cfg *hw_cfg = cfg;
+	struct sde_hw_ctl *ctl = NULL;
+	u32 vlut_base, pa_hist_base;
+	u32 ctrl_off, swap_off;
+	u32 tmp = 0;
+	int i = 0, j = 0;
+	u32 flush_mask = 0;
+
+	if (!ctx) {
+		DRM_ERROR("invalid input parameter NULL ctx\n");
+		return;
+	}
+
+	if (!hw_cfg || (hw_cfg->payload && hw_cfg->len !=
+			sizeof(struct drm_msm_pa_vlut))) {
+		DRM_ERROR("hw %pK payload %pK payloadsize %d exp size %zd\n",
+			  hw_cfg, ((hw_cfg) ? hw_cfg->payload : NULL),
+			  ((hw_cfg) ? hw_cfg->len : 0),
+			  sizeof(struct drm_msm_pa_vlut));
+		return;
+	}
+
+	ctl = hw_cfg->ctl;
+	vlut_base = ctx->cap->sblk->vlut.base;
+	pa_hist_base = ctx->cap->sblk->hist.base;
+	ctrl_off = pa_hist_base + PA_LUTV_DSPP_CTRL_OFF;
+	swap_off = pa_hist_base + PA_LUTV_DSPP_SWAP_OFF;
+
+	if (!hw_cfg->payload) {
+		DRM_DEBUG_DRIVER("Disable vlut feature\n");
+		SDE_REG_WRITE(&ctx->hw, ctrl_off, 0);
+		goto exit;
+	}
+
+	payload = hw_cfg->payload;
+	DRM_DEBUG_DRIVER("Enable vlut feature flags %llx\n", payload->flags);
+	for (i = 0, j = 0; i < ARRAY_SIZE(payload->val); i += 2, j += 4) {
+		tmp = (payload->val[i] & REG_MASK(10)) |
+			((payload->val[i + 1] & REG_MASK(10)) << 16);
+		SDE_REG_WRITE(&ctx->hw, (vlut_base + j), tmp);
+	}
+	SDE_REG_WRITE(&ctx->hw, ctrl_off, 1);
+	SDE_REG_WRITE(&ctx->hw, swap_off, 1);
+
+exit:
+	/* update flush bit */
+	if (ctl && ctl->ops.get_bitmask_dspp_pavlut) {
+		ctl->ops.get_bitmask_dspp_pavlut(ctl, &flush_mask, ctx->idx);
+		if (ctl->ops.update_pending_flush)
+			ctl->ops.update_pending_flush(ctl, flush_mask);
+	}
+}
+
 void sde_setup_dspp_gc_v1_7(struct sde_hw_dspp *ctx, void *cfg)
 {
 	struct drm_msm_pgc_lut *payload = NULL;
@@ -503,3 +567,69 @@
 	i = BIT(0) | ((payload->flags & PGC_8B_ROUND) ? BIT(1) : 0);
 	SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->gc.base, i);
 }
+
+void sde_setup_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg)
+{
+	u32 base, offset;
+	u32 op_mode;
+	bool feature_enabled;
+
+	if (!ctx || !cfg) {
+		DRM_ERROR("invalid parameters ctx %pK cfg %pK", ctx, cfg);
+		return;
+	}
+
+	feature_enabled = *(bool *)cfg;
+	base = ctx->cap->sblk->hist.base;
+	offset = base + PA_HIST_CTRL_DSPP_OFF;
+
+	op_mode = SDE_REG_READ(&ctx->hw, base);
+	if (!feature_enabled) {
+		op_mode &= ~DSPP_OP_PA_HIST_EN;
+		if (PA_DSPP_DISABLE_REQUIRED(op_mode))
+			op_mode &= ~DSPP_OP_PA_EN;
+	} else {
+		op_mode |= DSPP_OP_PA_HIST_EN | DSPP_OP_PA_EN;
+	}
+
+	SDE_REG_WRITE(&ctx->hw, offset, 0);
+	SDE_REG_WRITE(&ctx->hw, base, op_mode);
+}
+
+void sde_read_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg)
+{
+	struct drm_msm_hist *hist_data;
+	u32 offset, offset_ctl;
+	u32 i;
+
+	if (!ctx || !cfg) {
+		DRM_ERROR("invalid parameters ctx %pK cfg %pK", ctx, cfg);
+		return;
+	}
+
+	hist_data = (struct drm_msm_hist *)cfg;
+	offset = ctx->cap->sblk->hist.base + PA_HIST_DATA_DSPP_OFF;
+	offset_ctl = ctx->cap->sblk->hist.base + PA_HIST_CTRL_DSPP_OFF;
+
+	for (i = 0; i < HIST_V_SIZE; i++)
+		hist_data->data[i] = SDE_REG_READ(&ctx->hw, offset + i * 4) &
+					REG_MASK(24);
+
+	/* unlock hist buffer */
+	SDE_REG_WRITE(&ctx->hw, offset_ctl, 0);
+}
+
+void sde_lock_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg)
+{
+	u32 offset_ctl;
+
+	if (!ctx) {
+		DRM_ERROR("invalid parameters ctx %pK", ctx);
+		return;
+	}
+
+	offset_ctl = ctx->cap->sblk->hist.base + PA_HIST_CTRL_DSPP_OFF;
+
+	/* lock hist buffer */
+	SDE_REG_WRITE(&ctx->hw, offset_ctl, 1);
+}
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.h b/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.h
index 25e446b7..74018a3 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_color_processing_v1_7.h
@@ -76,10 +76,36 @@
 void sde_setup_dspp_pa_vlut_v1_7(struct sde_hw_dspp *ctx, void *cfg);
 
 /**
+ * sde_setup_dspp_pa_vlut_v1_8 - setup DSPP PA vLUT feature in v1.8 hardware
+ * @ctx: Pointer to DSPP context
+ * @cfg: Pointer to vLUT data
+ */
+void sde_setup_dspp_pa_vlut_v1_8(struct sde_hw_dspp *ctx, void *cfg);
+
+/**
  * sde_setup_dspp_gc_v1_7 - setup DSPP gc feature in v1.7 hardware
  * @ctx: Pointer to DSPP context
  * @cfg: Pointer to gc data
  */
 void sde_setup_dspp_gc_v1_7(struct sde_hw_dspp *ctx, void *cfg);
 
+/**
+ * sde_setup_dspp_hist_v1_7 - setup DSPP histogram feature in v1.7 hardware
+ * @ctx: Pointer to DSPP context
+ * @cfg: Pointer to histogram control data
+ */
+void sde_setup_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg);
+
+/**
+ * sde_read_dspp_hist_v1_7 - read DSPP histogram data in v1.7 hardware
+ * @ctx: Pointer to DSPP context
+ * @cfg: Pointer to histogram data
+ */
+void sde_read_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg);
+
+/**
+ * sde_lock_dspp_hist_v1_7 - lock DSPP histogram buffer in v1.7 hardware
+ * @ctx: Pointer to DSPP context
+ */
+void sde_lock_dspp_hist_v1_7(struct sde_hw_dspp *ctx, void *cfg);
 #endif
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_ctl.c b/drivers/gpu/drm/msm/sde/sde_hw_ctl.c
index 606fdeb..95b7a6d 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_ctl.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_ctl.c
@@ -39,7 +39,7 @@
 #define CTL_FLUSH_MASK_ROT              BIT(27)
 #define CTL_FLUSH_MASK_CTL              BIT(17)
 
-#define SDE_REG_RESET_TIMEOUT_COUNT    20
+#define SDE_REG_RESET_TIMEOUT_US        2000
 
 static struct sde_ctl_cfg *_ctl_offset(enum sde_ctl ctl,
 		struct sde_mdss_cfg *m,
@@ -89,6 +89,11 @@
 
 static inline void sde_hw_ctl_trigger_rot_start(struct sde_hw_ctl *ctx)
 {
+	/* ROT flush bit is latched during ROT start, so set it first */
+	if (CTL_FLUSH_MASK_ROT & ctx->pending_flush_mask) {
+		ctx->pending_flush_mask &= ~CTL_FLUSH_MASK_ROT;
+		SDE_REG_WRITE(&ctx->hw, CTL_FLUSH, CTL_FLUSH_MASK_ROT);
+	}
 	SDE_REG_WRITE(&ctx->hw, CTL_ROT_START, BIT(0));
 }
 
@@ -113,10 +118,6 @@
 
 static inline void sde_hw_ctl_trigger_flush(struct sde_hw_ctl *ctx)
 {
-	struct sde_hw_reg_dma_ops *ops = sde_reg_dma_get_ops();
-
-	if (ops && ops->last_command)
-		ops->last_command(ctx, DMA_CTL_QUEUE0);
 
 	SDE_REG_WRITE(&ctx->hw, CTL_FLUSH, ctx->pending_flush_mask);
 }
@@ -239,6 +240,22 @@
 	return 0;
 }
 
+static inline int sde_hw_ctl_get_bitmask_dspp_pavlut(struct sde_hw_ctl *ctx,
+		u32 *flushbits, enum sde_dspp dspp)
+{
+	switch (dspp) {
+	case DSPP_0:
+		*flushbits |= BIT(3);
+		break;
+	case DSPP_1:
+		*flushbits |= BIT(4);
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static inline int sde_hw_ctl_get_bitmask_intf(struct sde_hw_ctl *ctx,
 		u32 *flushbits, enum sde_intf intf)
 {
@@ -302,14 +319,13 @@
 	return 0;
 }
 
-static u32 sde_hw_ctl_poll_reset_status(struct sde_hw_ctl *ctx, u32 count)
+static u32 sde_hw_ctl_poll_reset_status(struct sde_hw_ctl *ctx, u32 timeout_us)
 {
 	struct sde_hw_blk_reg_map *c = &ctx->hw;
+	ktime_t timeout;
 	u32 status;
 
-	/* protect to do at least one iteration */
-	if (!count)
-		count = 1;
+	timeout = ktime_add_us(ktime_get(), timeout_us);
 
 	/*
 	 * it takes around 30us to have mdp finish resetting its ctl path
@@ -317,10 +333,10 @@
 	 */
 	do {
 		status = SDE_REG_READ(c, CTL_SW_RESET);
-		status &= 0x01;
+		status &= 0x1;
 		if (status)
 			usleep_range(20, 50);
-	} while (status && --count > 0);
+	} while (status && ktime_compare_safe(ktime_get(), timeout) < 0);
 
 	return status;
 }
@@ -331,7 +347,7 @@
 
 	pr_debug("issuing hw ctl reset for ctl:%d\n", ctx->idx);
 	SDE_REG_WRITE(c, CTL_SW_RESET, 0x1);
-	if (sde_hw_ctl_poll_reset_status(ctx, SDE_REG_RESET_TIMEOUT_COUNT))
+	if (sde_hw_ctl_poll_reset_status(ctx, SDE_REG_RESET_TIMEOUT_US))
 		return -EINVAL;
 
 	return 0;
@@ -348,7 +364,7 @@
 		return 0;
 
 	pr_debug("hw ctl reset is set for ctl:%d\n", ctx->idx);
-	if (sde_hw_ctl_poll_reset_status(ctx, SDE_REG_RESET_TIMEOUT_COUNT)) {
+	if (sde_hw_ctl_poll_reset_status(ctx, SDE_REG_RESET_TIMEOUT_US)) {
 		pr_err("hw recovery is not complete for ctl:%d\n", ctx->idx);
 		return -EINVAL;
 	}
@@ -547,6 +563,14 @@
 	SDE_REG_WRITE(c, CTL_ROT_TOP, val);
 }
 
+static void sde_hw_reg_dma_flush(struct sde_hw_ctl *ctx)
+{
+	struct sde_hw_reg_dma_ops *ops = sde_reg_dma_get_ops();
+
+	if (ops && ops->last_command)
+		ops->last_command(ctx, DMA_CTL_QUEUE0);
+}
+
 static void _setup_ctl_ops(struct sde_hw_ctl_ops *ops,
 		unsigned long cap)
 {
@@ -565,9 +589,12 @@
 	ops->get_bitmask_sspp = sde_hw_ctl_get_bitmask_sspp;
 	ops->get_bitmask_mixer = sde_hw_ctl_get_bitmask_mixer;
 	ops->get_bitmask_dspp = sde_hw_ctl_get_bitmask_dspp;
+	ops->get_bitmask_dspp_pavlut = sde_hw_ctl_get_bitmask_dspp_pavlut;
 	ops->get_bitmask_intf = sde_hw_ctl_get_bitmask_intf;
 	ops->get_bitmask_cdm = sde_hw_ctl_get_bitmask_cdm;
 	ops->get_bitmask_wb = sde_hw_ctl_get_bitmask_wb;
+	ops->reg_dma_flush = sde_hw_reg_dma_flush;
+
 	if (cap & BIT(SDE_CTL_SBUF)) {
 		ops->get_bitmask_rot = sde_hw_ctl_get_bitmask_rot;
 		ops->setup_sbuf_cfg = sde_hw_ctl_setup_sbuf_cfg;
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_ctl.h b/drivers/gpu/drm/msm/sde/sde_hw_ctl.h
index a111916..97bc1c1 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_ctl.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_ctl.h
@@ -173,6 +173,10 @@
 		u32 *flushbits,
 		enum sde_dspp blk);
 
+	int (*get_bitmask_dspp_pavlut)(struct sde_hw_ctl *ctx,
+		u32 *flushbits,
+		enum sde_dspp blk);
+
 	int (*get_bitmask_intf)(struct sde_hw_ctl *ctx,
 		u32 *flushbits,
 		enum sde_intf blk);
@@ -206,6 +210,13 @@
 
 	void (*setup_sbuf_cfg)(struct sde_hw_ctl *ctx,
 		struct sde_ctl_sbuf_cfg *cfg);
+
+	/**
+	 * Flush the reg dma by sending last command.
+	 * @ctx       : ctl path ctx pointer
+	 */
+	void (*reg_dma_flush)(struct sde_hw_ctl *ctx);
+
 };
 
 /**
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_ds.c b/drivers/gpu/drm/msm/sde/sde_hw_ds.c
new file mode 100644
index 0000000..e37a7d6
--- /dev/null
+++ b/drivers/gpu/drm/msm/sde/sde_hw_ds.c
@@ -0,0 +1,149 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "sde_hw_ds.h"
+#include "sde_formats.h"
+#include "sde_dbg.h"
+#include "sde_kms.h"
+
+/* Destination scaler TOP registers */
+#define DEST_SCALER_OP_MODE     0x00
+#define DEST_SCALER_HW_VERSION  0x10
+
+static void sde_hw_ds_setup_opmode(struct sde_hw_ds *hw_ds,
+				u32 op_mode)
+{
+	struct sde_hw_blk_reg_map *hw = &hw_ds->hw;
+
+	SDE_REG_WRITE(hw, DEST_SCALER_OP_MODE, op_mode);
+}
+
+static void sde_hw_ds_setup_scaler3(struct sde_hw_ds *hw_ds,
+			void *scaler_cfg, void *scaler_lut_cfg)
+{
+	struct sde_hw_scaler3_cfg *scl3_cfg = scaler_cfg;
+	struct sde_hw_scaler3_lut_cfg *scl3_lut_cfg = scaler_lut_cfg;
+
+	if (!hw_ds || !hw_ds->scl || !scl3_cfg || !scl3_lut_cfg)
+		return;
+
+	/*
+	 * copy LUT values to scaler structure
+	 */
+	if (scl3_lut_cfg->is_configured) {
+		scl3_cfg->dir_lut = scl3_lut_cfg->dir_lut;
+		scl3_cfg->dir_len = scl3_lut_cfg->dir_len;
+		scl3_cfg->cir_lut = scl3_lut_cfg->cir_lut;
+		scl3_cfg->cir_len = scl3_lut_cfg->cir_len;
+		scl3_cfg->sep_lut = scl3_lut_cfg->sep_lut;
+		scl3_cfg->sep_len = scl3_lut_cfg->sep_len;
+	}
+
+	sde_hw_setup_scaler3(&hw_ds->hw, scl3_cfg,
+			 hw_ds->scl->base,
+			 hw_ds->scl->version,
+			 sde_get_sde_format(DRM_FORMAT_XBGR2101010));
+}
+
+static void _setup_ds_ops(struct sde_hw_ds_ops *ops, unsigned long features)
+{
+	ops->setup_opmode = sde_hw_ds_setup_opmode;
+
+	if (test_bit(SDE_SSPP_SCALER_QSEED3, &features))
+		ops->setup_scaler = sde_hw_ds_setup_scaler3;
+}
+
+static struct sde_ds_cfg *_ds_offset(enum sde_ds ds,
+		struct sde_mdss_cfg *m,
+		void __iomem *addr,
+		struct sde_hw_blk_reg_map *b)
+{
+	int i;
+
+	if (!m || !addr || !b)
+		return ERR_PTR(-EINVAL);
+
+	for (i = 0; i < m->ds_count; i++) {
+		if ((ds == m->ds[i].id) &&
+			 (m->ds[i].top)) {
+			b->base_off = addr;
+			b->blk_off = m->ds[i].top->base;
+			b->length = m->ds[i].top->len;
+			b->hwversion = m->hwversion;
+			b->log_mask = SDE_DBG_MASK_DS;
+			return &m->ds[i];
+		}
+	}
+
+	return ERR_PTR(-EINVAL);
+}
+
+static struct sde_hw_blk_ops sde_hw_ops = {
+	.start = NULL,
+	.stop = NULL,
+};
+
+struct sde_hw_ds *sde_hw_ds_init(enum sde_ds idx,
+			void __iomem *addr,
+			struct sde_mdss_cfg *m)
+{
+	struct sde_hw_ds *hw_ds;
+	struct sde_ds_cfg *cfg;
+	int rc;
+
+	if (!addr || !m)
+		return ERR_PTR(-EINVAL);
+
+	hw_ds = kzalloc(sizeof(*hw_ds), GFP_KERNEL);
+	if (!hw_ds)
+		return ERR_PTR(-ENOMEM);
+
+	cfg = _ds_offset(idx, m, addr, &hw_ds->hw);
+	if (IS_ERR_OR_NULL(cfg)) {
+		SDE_ERROR("failed to get ds cfg\n");
+		kfree(hw_ds);
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* Assign ops */
+	hw_ds->idx = idx;
+	hw_ds->scl = cfg;
+	_setup_ds_ops(&hw_ds->ops, hw_ds->scl->features);
+
+	rc = sde_hw_blk_init(&hw_ds->base, SDE_HW_BLK_DS, idx, &sde_hw_ops);
+	if (rc) {
+		SDE_ERROR("failed to init hw blk %d\n", rc);
+		goto blk_init_error;
+	}
+
+	if (cfg->len) {
+		sde_dbg_reg_register_dump_range(SDE_DBG_NAME, cfg->name,
+				hw_ds->hw.blk_off + cfg->base,
+				hw_ds->hw.blk_off + cfg->base + cfg->len,
+				hw_ds->hw.xin_id);
+	}
+
+	return hw_ds;
+
+blk_init_error:
+	kzfree(hw_ds);
+
+	return ERR_PTR(rc);
+
+}
+
+void sde_hw_ds_destroy(struct sde_hw_ds *hw_ds)
+{
+	if (hw_ds)
+		sde_hw_blk_destroy(&hw_ds->base);
+	kfree(hw_ds);
+}
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_ds.h b/drivers/gpu/drm/msm/sde/sde_hw_ds.h
new file mode 100644
index 0000000..d81cfaf
--- /dev/null
+++ b/drivers/gpu/drm/msm/sde/sde_hw_ds.h
@@ -0,0 +1,111 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _SDE_HW_DS_H
+#define _SDE_HW_DS_H
+
+#include "sde_hw_mdss.h"
+#include "sde_hw_util.h"
+#include "sde_hw_catalog.h"
+#include "sde_hw_blk.h"
+
+struct sde_hw_ds;
+
+/* Destination Scaler DUAL mode overfetch pixel count */
+#define SDE_DS_OVERFETCH_SIZE 5
+
+/* Destination scaler DUAL mode operation bit */
+#define SDE_DS_OP_MODE_DUAL BIT(16)
+
+/* struct sde_hw_ds_cfg - destination scaler config
+ * @ndx          : DS selection index
+ * @flags        : Flag to switch between mode for DS
+ * @lm_width     : Layer mixer width configuration
+ * @lm_heigh     : Layer mixer height configuration
+ * @set_lm_flush : LM flush bit
+ * @scl3_cfg     : Pointer to sde_hw_scaler3_cfg.
+ */
+struct sde_hw_ds_cfg {
+	u32 ndx;
+	int flags;
+	u32 lm_width;
+	u32 lm_height;
+	bool set_lm_flush;
+	struct sde_hw_scaler3_cfg *scl3_cfg;
+};
+
+/**
+ * struct sde_hw_ds_ops - interface to the destination scaler
+ * hardware driver functions
+ * Caller must call the init function to get the ds context for each ds
+ * Assumption is these functions will be called after clocks are enabled
+ */
+struct sde_hw_ds_ops {
+	/**
+	 * setup_opmode - destination scaler op mode setup
+	 * @hw_ds   : Pointer to ds context
+	 * @op_mode : Op mode configuration
+	 */
+	void (*setup_opmode)(struct sde_hw_ds *hw_ds,
+				u32 op_mode);
+
+	/**
+	 * setup_scaler - destination scaler block setup
+	 * @hw_ds          : Pointer to ds context
+	 * @scaler_cfg     : Pointer to scaler data
+	 * @scaler_lut_cfg : Pointer to scaler lut
+	 */
+	void (*setup_scaler)(struct sde_hw_ds *hw_ds,
+				void *scaler_cfg,
+				void *scaler_lut_cfg);
+
+};
+
+/**
+ * struct sde_hw_ds - destination scaler description
+ * @base : Hardware block base structure
+ * @hw   : Block hardware details
+ * @idx  : Destination scaler index
+ * @scl  : Pointer to
+ *          - scaler offset relative to top offset
+ *          - capabilities
+ * @ops  : Pointer to operations for this DS
+ */
+struct sde_hw_ds {
+	struct sde_hw_blk base;
+	struct sde_hw_blk_reg_map hw;
+	enum sde_ds idx;
+	const struct sde_ds_cfg *scl;
+	struct sde_hw_ds_ops ops;
+};
+
+/**
+ * sde_hw_ds_init - initializes the destination scaler
+ * hw driver object and should be called once before
+ * accessing every destination scaler
+ * @idx : DS index for which driver object is required
+ * @addr: Mapped register io address of MDP
+ * @m   : MDSS catalog information
+ * @Return: pointer to structure or ERR_PTR
+ */
+struct sde_hw_ds *sde_hw_ds_init(enum sde_ds idx,
+			void __iomem *addr,
+			struct sde_mdss_cfg *m);
+
+/**
+ * sde_hw_ds_destroy - destroys destination scaler
+ * driver context
+ * @hw_ds:   Pointer to DS context
+ */
+void sde_hw_ds_destroy(struct sde_hw_ds *hw_ds);
+
+#endif /*_SDE_HW_DS_H */
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_dspp.c b/drivers/gpu/drm/msm/sde/sde_hw_dspp.c
index 5b3f51e..36e30b7 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_dspp.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_dspp.c
@@ -82,9 +82,23 @@
 			} else if (c->cap->sblk->vlut.version ==
 					(SDE_COLOR_PROCESS_VER(0x1, 0x8))) {
 				ret = reg_dmav1_init_dspp_op_v4(i, c->idx);
-				if (ret)
+				if (!ret)
 					c->ops.setup_vlut =
 					reg_dmav1_setup_dspp_vlutv18;
+				else
+					c->ops.setup_vlut =
+					sde_setup_dspp_pa_vlut_v1_8;
+			}
+			break;
+		case SDE_DSPP_HIST:
+			if (c->cap->sblk->hist.version ==
+				(SDE_COLOR_PROCESS_VER(0x1, 0x7))) {
+				c->ops.setup_histogram =
+				    sde_setup_dspp_hist_v1_7;
+				c->ops.read_histogram =
+				    sde_read_dspp_hist_v1_7;
+				c->ops.lock_histogram =
+				    sde_lock_dspp_hist_v1_7;
 			}
 			break;
 		case SDE_DSPP_GAMUT:
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_dspp.h b/drivers/gpu/drm/msm/sde/sde_hw_dspp.h
index 44b3831..4878fc6 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_dspp.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_dspp.h
@@ -38,6 +38,13 @@
 	void (*read_histogram)(struct sde_hw_dspp *ctx, void *cfg);
 
 	/**
+	 * lock_histogram - lock dspp histogram buffer
+	 * @ctx: Pointer to dspp context
+	 * @cfg: Pointer to configuration
+	 */
+	void (*lock_histogram)(struct sde_hw_dspp *ctx, void *cfg);
+
+	/**
 	 * setup_igc - update dspp igc
 	 * @ctx: Pointer to dspp context
 	 * @cfg: Pointer to configuration
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_intf.c b/drivers/gpu/drm/msm/sde/sde_hw_intf.c
index 35f1800..fd06c12 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_intf.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_intf.c
@@ -289,6 +289,18 @@
 	return SDE_REG_READ(c, INTF_MISR_SIGNATURE);
 }
 
+static u32 sde_hw_intf_get_line_count(struct sde_hw_intf *intf)
+{
+	struct sde_hw_blk_reg_map *c;
+
+	if (!intf)
+		return 0;
+
+	c = &intf->hw;
+
+	return SDE_REG_READ(c, INTF_LINE_COUNT);
+}
+
 static void _setup_intf_ops(struct sde_hw_intf_ops *ops,
 		unsigned long cap)
 {
@@ -298,6 +310,7 @@
 	ops->enable_timing = sde_hw_intf_enable_timing_engine;
 	ops->setup_misr = sde_hw_intf_setup_misr;
 	ops->collect_misr = sde_hw_intf_collect_misr;
+	ops->get_line_count = sde_hw_intf_get_line_count;
 	if (cap & BIT(SDE_INTF_ROT_START))
 		ops->setup_rot_start = sde_hw_intf_setup_rot_start;
 }
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_intf.h b/drivers/gpu/drm/msm/sde/sde_hw_intf.h
index 83e206d..89068bc 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_intf.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_intf.h
@@ -62,6 +62,7 @@
  * @ get_status: returns if timing engine is enabled or not
  * @ setup_misr: enables/disables MISR in HW register
  * @ collect_misr: reads and stores MISR data from HW register
+ * @ get_line_count: reads current vertical line counter
  */
 struct sde_hw_intf_ops {
 	void (*setup_timing_gen)(struct sde_hw_intf *intf,
@@ -84,6 +85,8 @@
 			bool enable, u32 frame_count);
 
 	u32 (*collect_misr)(struct sde_hw_intf *intf);
+
+	u32 (*get_line_count)(struct sde_hw_intf *intf);
 };
 
 struct sde_hw_intf {
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_lm.c b/drivers/gpu/drm/msm/sde/sde_hw_lm.c
index 3d282ee..4e677c2 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_lm.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_lm.c
@@ -262,7 +262,7 @@
 		unsigned long features)
 {
 	ops->setup_mixer_out = sde_hw_lm_setup_out;
-	if (IS_SDM845_TARGET(m->hwversion))
+	if (IS_SDM845_TARGET(m->hwversion) || IS_SDM670_TARGET(m->hwversion))
 		ops->setup_blend_config = sde_hw_lm_setup_blend_config_sdm845;
 	else
 		ops->setup_blend_config = sde_hw_lm_setup_blend_config;
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_mdss.h b/drivers/gpu/drm/msm/sde/sde_hw_mdss.h
index f07f5ed..952ee8f 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_mdss.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_mdss.h
@@ -100,6 +100,7 @@
 	SDE_HW_BLK_SSPP,
 	SDE_HW_BLK_LM,
 	SDE_HW_BLK_DSPP,
+	SDE_HW_BLK_DS,
 	SDE_HW_BLK_CTL,
 	SDE_HW_BLK_CDM,
 	SDE_HW_BLK_PINGPONG,
@@ -176,6 +177,13 @@
 	DSPP_MAX
 };
 
+enum sde_ds {
+	DS_TOP,
+	DS_0,
+	DS_1,
+	DS_MAX
+};
+
 enum sde_ctl {
 	CTL_0 = 1,
 	CTL_1,
@@ -489,6 +497,7 @@
 #define SDE_DBG_MASK_VBIF     (1 << 10)
 #define SDE_DBG_MASK_DSC      (1 << 11)
 #define SDE_DBG_MASK_ROT      (1 << 12)
+#define SDE_DBG_MASK_DS       (1 << 13)
 
 /**
  * struct sde_hw_cp_cfg: hardware dspp/lm feature payload.
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_pingpong.c b/drivers/gpu/drm/msm/sde/sde_hw_pingpong.c
index ff796f7..d8f79f1 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_pingpong.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_pingpong.c
@@ -165,11 +165,16 @@
 static void sde_hw_pp_dsc_disable(struct sde_hw_pingpong *pp)
 {
 	struct sde_hw_blk_reg_map *c;
+	u32 data;
 
 	if (!pp)
 		return;
 	c = &pp->hw;
 
+	data = SDE_REG_READ(c, PP_DCE_DATA_OUT_SWAP);
+	data &= ~BIT(18); /* disable endian flip */
+	SDE_REG_WRITE(c, PP_DCE_DATA_OUT_SWAP, data);
+
 	SDE_REG_WRITE(c, PP_DSC_MODE, 0);
 }
 
@@ -297,6 +302,33 @@
 	return 0;
 }
 
+static u32 sde_hw_pp_get_line_count(struct sde_hw_pingpong *pp)
+{
+	struct sde_hw_blk_reg_map *c = &pp->hw;
+	u32 height, init;
+	u32 line = 0xFFFF;
+
+	if (!pp)
+		return 0;
+	c = &pp->hw;
+
+	init = SDE_REG_READ(c, PP_VSYNC_INIT_VAL) & 0xFFFF;
+	height = SDE_REG_READ(c, PP_SYNC_CONFIG_HEIGHT) & 0xFFFF;
+
+	if (height < init)
+		goto line_count_exit;
+
+	line = SDE_REG_READ(c, PP_INT_COUNT_VAL) & 0xFFFF;
+
+	if (line < init)
+		line += (0xFFFF - init);
+	else
+		line -= init;
+
+line_count_exit:
+	return line;
+}
+
 static void _setup_pingpong_ops(struct sde_hw_pingpong_ops *ops,
 	const struct sde_pingpong_cfg *hw_cap)
 {
@@ -312,6 +344,7 @@
 	ops->disable_dsc = sde_hw_pp_dsc_disable;
 	ops->get_autorefresh = sde_hw_pp_get_autorefresh_config;
 	ops->poll_timeout_wr_ptr = sde_hw_pp_poll_timeout_wr_ptr;
+	ops->get_line_count = sde_hw_pp_get_line_count;
 
 	version = SDE_COLOR_PROCESS_MAJOR(hw_cap->sblk->dither.version);
 	switch (version) {
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_pingpong.h b/drivers/gpu/drm/msm/sde/sde_hw_pingpong.h
index f0a2054..389b2d2 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_pingpong.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_pingpong.h
@@ -64,6 +64,7 @@
  *  @enable_dsc : enables DSC encoder
  *  @disable_dsc : disables DSC encoder
  *  @setup_dither : function to program the dither hw block
+ *  @get_line_count: obtain current vertical line counter
  */
 struct sde_hw_pingpong_ops {
 	/**
@@ -130,6 +131,11 @@
 	 * Program the dither hw block
 	 */
 	int (*setup_dither)(struct sde_hw_pingpong *pp, void *cfg, size_t len);
+
+	/**
+	 * Obtain current vertical line counter
+	 */
+	u32 (*get_line_count)(struct sde_hw_pingpong *pp);
 };
 
 struct sde_hw_pingpong {
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1.c b/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1.c
index 9199048..d7b7625 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1.c
@@ -50,7 +50,6 @@
 			(cfg)->dma_buf->index)
 
 #define REG_DMA_DECODE_SEL 0x180AC060
-#define REG_DMA_LAST_CMD 0x180AC004
 #define SINGLE_REG_WRITE_OPCODE (BIT(28))
 #define REL_ADDR_OPCODE (BIT(27))
 #define HW_INDEX_REG_WRITE_OPCODE (BIT(28) | BIT(29))
@@ -471,7 +470,8 @@
 			cfg->dma_buf->iova);
 	SDE_REG_WRITE(&hw, reg_dma_ctl_queue_off[cfg->ctl->idx] + 0x4,
 			cmd1);
-	SDE_REG_WRITE(&cfg->ctl->hw, REG_DMA_CTL_TRIGGER_OFF,
+	if (cfg->last_command)
+		SDE_REG_WRITE(&cfg->ctl->hw, REG_DMA_CTL_TRIGGER_OFF,
 			queue_sel[cfg->queue_select]);
 
 	return 0;
@@ -582,7 +582,7 @@
 	return 0;
 }
 
-static void sde_reg_dma_aspace_cb(void *cb_data, bool attach)
+static void sde_reg_dma_aspace_cb_locked(void *cb_data, bool is_detach)
 {
 	struct sde_reg_dma_buffer *dma_buf = NULL;
 	struct msm_gem_address_space *aspace = NULL;
@@ -597,14 +597,23 @@
 	dma_buf = (struct sde_reg_dma_buffer *)cb_data;
 	aspace = dma_buf->aspace;
 
-	if (attach) {
-		rc = msm_gem_get_iova(dma_buf->buf, aspace, &dma_buf->iova);
+	if (is_detach) {
+		/* invalidate the stored iova */
+		dma_buf->iova = 0;
+
+		/* return the virtual address mapping */
+		msm_gem_put_vaddr_locked(dma_buf->buf);
+		msm_gem_vunmap(dma_buf->buf);
+
+	} else {
+		rc = msm_gem_get_iova_locked(dma_buf->buf, aspace,
+				&dma_buf->iova);
 		if (rc) {
 			DRM_ERROR("failed to get the iova rc %d\n", rc);
 			return;
 		}
 
-		dma_buf->vaddr = msm_gem_get_vaddr(dma_buf->buf);
+		dma_buf->vaddr = msm_gem_get_vaddr_locked(dma_buf->buf);
 		if (IS_ERR_OR_NULL(dma_buf->vaddr)) {
 			DRM_ERROR("failed to get va rc %d\n", rc);
 			return;
@@ -615,13 +624,6 @@
 		dma_buf->iova = dma_buf->iova + offset;
 		dma_buf->vaddr = (void *)(((u8 *)dma_buf->vaddr) + offset);
 		dma_buf->next_op_allowed = DECODE_SEL_OP;
-	} else {
-		/* invalidate the stored iova */
-		dma_buf->iova = 0;
-
-		/* return the virtual address mapping */
-		msm_gem_put_vaddr(dma_buf->buf);
-		msm_gem_vunmap(dma_buf->buf);
 	}
 }
 
@@ -661,7 +663,7 @@
 
 	/* register to aspace */
 	rc = msm_gem_address_space_register_cb(aspace,
-			sde_reg_dma_aspace_cb,
+			sde_reg_dma_aspace_cb_locked,
 			(void *)dma_buf);
 	if (rc) {
 		DRM_ERROR("failed to register callback %d", rc);
@@ -694,10 +696,12 @@
 put_iova:
 	msm_gem_put_iova(dma_buf->buf, aspace);
 free_aspace_cb:
-	msm_gem_address_space_unregister_cb(aspace, sde_reg_dma_aspace_cb,
-			dma_buf);
+	msm_gem_address_space_unregister_cb(aspace,
+			sde_reg_dma_aspace_cb_locked, dma_buf);
 free_gem:
+	mutex_lock(&reg_dma->drm_dev->struct_mutex);
 	msm_gem_free_object(dma_buf->buf);
+	mutex_unlock(&reg_dma->drm_dev->struct_mutex);
 fail:
 	kfree(dma_buf);
 	return ERR_PTR(rc);
@@ -713,7 +717,7 @@
 	if (dma_buf->buf) {
 		msm_gem_put_iova(dma_buf->buf, 0);
 		msm_gem_address_space_unregister_cb(dma_buf->aspace,
-				sde_reg_dma_aspace_cb, dma_buf);
+				sde_reg_dma_aspace_cb_locked, dma_buf);
 		mutex_lock(&reg_dma->drm_dev->struct_mutex);
 		msm_gem_free_object(dma_buf->buf);
 		mutex_unlock(&reg_dma->drm_dev->struct_mutex);
@@ -754,8 +758,8 @@
 
 	loc =  (u32 *)((u8 *)cfg->dma_buf->vaddr +
 			cfg->dma_buf->index);
-	loc[0] = REG_DMA_LAST_CMD;
-	loc[1] = BIT(0);
+	loc[0] = REG_DMA_DECODE_SEL;
+	loc[1] = 0;
 	cfg->dma_buf->index = sizeof(u32) * 2;
 	cfg->dma_buf->ops_completed = REG_WRITE_OP | DECODE_SEL_OP;
 	cfg->dma_buf->next_op_allowed = REG_WRITE_OP;
@@ -774,6 +778,11 @@
 		return -EINVAL;
 	}
 
+	if (!last_cmd_buf->iova) {
+		DRM_DEBUG("iova not set, possible secure session\n");
+		return 0;
+	}
+
 	cfg.dma_buf = last_cmd_buf;
 	reset_reg_dma_buffer_v1(last_cmd_buf);
 	if (validate_last_cmd(&cfg)) {
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1_color_proc.c b/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1_color_proc.c
index 55cb260..b59dd16 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1_color_proc.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_reg_dma_v1_color_proc.c
@@ -44,7 +44,7 @@
 static struct sde_reg_dma_buffer *dspp_buf[REG_DMA_FEATURES_MAX][DSPP_MAX];
 
 static u32 feature_map[SDE_DSPP_MAX] = {
-	[SDE_DSPP_VLUT] = VLUT,
+	[SDE_DSPP_VLUT] = REG_DMA_FEATURES_MAX,
 	[SDE_DSPP_GAMUT] = GAMUT,
 	[SDE_DSPP_IGC] = IGC,
 	[SDE_DSPP_PCC] = PCC,
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_rot.c b/drivers/gpu/drm/msm/sde/sde_hw_rot.c
index 1a00517..c5af3a9 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_rot.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_rot.c
@@ -656,7 +656,7 @@
 			SDE_ERROR("failed to get dst format\n");
 			return -EINVAL;
 		}
-	} else if (hw_cmd == SDE_HW_ROT_CMD_COMMIT) {
+	} else {
 		rc = sde_hw_rot_to_v4l2_pixfmt(data->dst_pixel_format,
 				data->dst_modifier, &rot_cmd.dst_pixfmt);
 		if (rc) {
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_sspp.c b/drivers/gpu/drm/msm/sde/sde_hw_sspp.c
index a4564c1..acecf1a 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_sspp.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_sspp.c
@@ -85,6 +85,7 @@
 #define SSPP_TRAFFIC_SHAPER                0x130
 #define SSPP_CDP_CNTL                      0x134
 #define SSPP_UBWC_ERROR_STATUS             0x138
+#define SSPP_CDP_CNTL_REC1                 0x13c
 #define SSPP_TRAFFIC_SHAPER_PREFILL        0x150
 #define SSPP_TRAFFIC_SHAPER_REC1_PREFILL   0x154
 #define SSPP_TRAFFIC_SHAPER_REC1           0x158
@@ -119,57 +120,6 @@
 #define COMP1_2_INIT_PHASE_Y               0x2C
 #define VIG_0_QSEED2_SHARP                 0x30
 
-/* SDE_SSPP_SCALER_QSEED3 */
-#define QSEED3_HW_VERSION                  0x00
-#define QSEED3_OP_MODE                     0x04
-#define QSEED3_RGB2Y_COEFF                 0x08
-#define QSEED3_PHASE_INIT                  0x0C
-#define QSEED3_PHASE_STEP_Y_H              0x10
-#define QSEED3_PHASE_STEP_Y_V              0x14
-#define QSEED3_PHASE_STEP_UV_H             0x18
-#define QSEED3_PHASE_STEP_UV_V             0x1C
-#define QSEED3_PRELOAD                     0x20
-#define QSEED3_DE_SHARPEN                  0x24
-#define QSEED3_DE_SHARPEN_CTL              0x28
-#define QSEED3_DE_SHAPE_CTL                0x2C
-#define QSEED3_DE_THRESHOLD                0x30
-#define QSEED3_DE_ADJUST_DATA_0            0x34
-#define QSEED3_DE_ADJUST_DATA_1            0x38
-#define QSEED3_DE_ADJUST_DATA_2            0x3C
-#define QSEED3_SRC_SIZE_Y_RGB_A            0x40
-#define QSEED3_SRC_SIZE_UV                 0x44
-#define QSEED3_DST_SIZE                    0x48
-#define QSEED3_COEF_LUT_CTRL               0x4C
-#define QSEED3_COEF_LUT_SWAP_BIT           0
-#define QSEED3_COEF_LUT_DIR_BIT            1
-#define QSEED3_COEF_LUT_Y_CIR_BIT          2
-#define QSEED3_COEF_LUT_UV_CIR_BIT         3
-#define QSEED3_COEF_LUT_Y_SEP_BIT          4
-#define QSEED3_COEF_LUT_UV_SEP_BIT         5
-#define QSEED3_BUFFER_CTRL                 0x50
-#define QSEED3_CLK_CTRL0                   0x54
-#define QSEED3_CLK_CTRL1                   0x58
-#define QSEED3_CLK_STATUS                  0x5C
-#define QSEED3_MISR_CTRL                   0x70
-#define QSEED3_MISR_SIGNATURE_0            0x74
-#define QSEED3_MISR_SIGNATURE_1            0x78
-#define QSEED3_PHASE_INIT_Y_H              0x90
-#define QSEED3_PHASE_INIT_Y_V              0x94
-#define QSEED3_PHASE_INIT_UV_H             0x98
-#define QSEED3_PHASE_INIT_UV_V             0x9C
-#define QSEED3_COEF_LUT                    0x100
-#define QSEED3_FILTERS                     5
-#define QSEED3_LUT_REGIONS                 4
-#define QSEED3_CIRCULAR_LUTS               9
-#define QSEED3_SEPARABLE_LUTS              10
-#define QSEED3_LUT_SIZE                    60
-#define QSEED3_ENABLE                      2
-#define QSEED3_DIR_LUT_SIZE                (200 * sizeof(u32))
-#define QSEED3_CIR_LUT_SIZE \
-	(QSEED3_LUT_SIZE * QSEED3_CIRCULAR_LUTS * sizeof(u32))
-#define QSEED3_SEP_LUT_SIZE \
-	(QSEED3_LUT_SIZE * QSEED3_SEPARABLE_LUTS * sizeof(u32))
-
 /*
  * Definitions for ViG op modes
  */
@@ -422,19 +372,19 @@
 	if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
 		return;
 
-	if (rect_mode == SDE_SSPP_RECT_SOLO || rect_mode == SDE_SSPP_RECT_0)
-		secure_bit_mask = (rect_mode == SDE_SSPP_RECT_SOLO) ? 0xF :
-			0x5;
-	else
-		secure_bit_mask = 0xA;
-
 	c = &ctx->hw;
 
-	secure = SDE_REG_READ(c, SSPP_SRC_ADDR_SW_STATUS + idx);
-	if (enable)
+	if (enable) {
+		if ((rect_mode == SDE_SSPP_RECT_SOLO)
+				|| (rect_mode == SDE_SSPP_RECT_0))
+			secure_bit_mask =
+				(rect_mode == SDE_SSPP_RECT_SOLO) ? 0xF : 0x5;
+		else
+			secure_bit_mask = 0xA;
+
+		secure = SDE_REG_READ(c, SSPP_SRC_ADDR_SW_STATUS + idx);
 		secure |= secure_bit_mask;
-	else
-		secure &= ~secure_bit_mask;
+	}
 
 	SDE_REG_WRITE(c, SSPP_SRC_ADDR_SW_STATUS + idx, secure);
 }
@@ -556,144 +506,12 @@
 		pe->phase_step_y[SDE_SSPP_COMP_1_2]);
 }
 
-static void _sde_hw_sspp_setup_scaler3_lut(struct sde_hw_pipe *ctx,
-		struct sde_hw_scaler3_cfg *scaler3_cfg)
-{
-	u32 idx;
-	int i, j, filter;
-	int config_lut = 0x0;
-	unsigned long lut_flags;
-	u32 lut_addr, lut_offset, lut_len;
-	u32 *lut[QSEED3_FILTERS] = {NULL, NULL, NULL, NULL, NULL};
-	static const uint32_t offset[QSEED3_FILTERS][QSEED3_LUT_REGIONS][2] = {
-		{{18, 0x000}, {12, 0x120}, {12, 0x1E0}, {8, 0x2A0} },
-		{{6, 0x320}, {3, 0x3E0}, {3, 0x440}, {3, 0x4A0} },
-		{{6, 0x500}, {3, 0x5c0}, {3, 0x620}, {3, 0x680} },
-		{{6, 0x380}, {3, 0x410}, {3, 0x470}, {3, 0x4d0} },
-		{{6, 0x560}, {3, 0x5f0}, {3, 0x650}, {3, 0x6b0} },
-	};
-
-	if (_sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED3, &idx) ||
-		!scaler3_cfg)
-		return;
-
-	lut_flags = (unsigned long) scaler3_cfg->lut_flag;
-	if (test_bit(QSEED3_COEF_LUT_DIR_BIT, &lut_flags) &&
-		(scaler3_cfg->dir_len == QSEED3_DIR_LUT_SIZE)) {
-		lut[0] = scaler3_cfg->dir_lut;
-		config_lut = 1;
-	}
-	if (test_bit(QSEED3_COEF_LUT_Y_CIR_BIT, &lut_flags) &&
-		(scaler3_cfg->y_rgb_cir_lut_idx < QSEED3_CIRCULAR_LUTS) &&
-		(scaler3_cfg->cir_len == QSEED3_CIR_LUT_SIZE)) {
-		lut[1] = scaler3_cfg->cir_lut +
-			scaler3_cfg->y_rgb_cir_lut_idx * QSEED3_LUT_SIZE;
-		config_lut = 1;
-	}
-	if (test_bit(QSEED3_COEF_LUT_UV_CIR_BIT, &lut_flags) &&
-		(scaler3_cfg->uv_cir_lut_idx < QSEED3_CIRCULAR_LUTS) &&
-		(scaler3_cfg->cir_len == QSEED3_CIR_LUT_SIZE)) {
-		lut[2] = scaler3_cfg->cir_lut +
-			scaler3_cfg->uv_cir_lut_idx * QSEED3_LUT_SIZE;
-		config_lut = 1;
-	}
-	if (test_bit(QSEED3_COEF_LUT_Y_SEP_BIT, &lut_flags) &&
-		(scaler3_cfg->y_rgb_sep_lut_idx < QSEED3_SEPARABLE_LUTS) &&
-		(scaler3_cfg->sep_len == QSEED3_SEP_LUT_SIZE)) {
-		lut[3] = scaler3_cfg->sep_lut +
-			scaler3_cfg->y_rgb_sep_lut_idx * QSEED3_LUT_SIZE;
-		config_lut = 1;
-	}
-	if (test_bit(QSEED3_COEF_LUT_UV_SEP_BIT, &lut_flags) &&
-		(scaler3_cfg->uv_sep_lut_idx < QSEED3_SEPARABLE_LUTS) &&
-		(scaler3_cfg->sep_len == QSEED3_SEP_LUT_SIZE)) {
-		lut[4] = scaler3_cfg->sep_lut +
-			scaler3_cfg->uv_sep_lut_idx * QSEED3_LUT_SIZE;
-		config_lut = 1;
-	}
-
-	if (config_lut) {
-		for (filter = 0; filter < QSEED3_FILTERS; filter++) {
-			if (!lut[filter])
-				continue;
-			lut_offset = 0;
-			for (i = 0; i < QSEED3_LUT_REGIONS; i++) {
-				lut_addr = QSEED3_COEF_LUT + idx
-					+ offset[filter][i][1];
-				lut_len = offset[filter][i][0] << 2;
-				for (j = 0; j < lut_len; j++) {
-					SDE_REG_WRITE(&ctx->hw,
-						lut_addr,
-						(lut[filter])[lut_offset++]);
-					lut_addr += 4;
-				}
-			}
-		}
-	}
-
-	if (test_bit(QSEED3_COEF_LUT_SWAP_BIT, &lut_flags))
-		SDE_REG_WRITE(&ctx->hw, QSEED3_COEF_LUT_CTRL + idx, BIT(0));
-
-}
-
-static void _sde_hw_sspp_setup_scaler3_de(struct sde_hw_pipe *ctx,
-		struct sde_hw_scaler3_de_cfg *de_cfg)
-{
-	u32 idx;
-	u32 sharp_lvl, sharp_ctl, shape_ctl, de_thr;
-	u32 adjust_a, adjust_b, adjust_c;
-	struct sde_hw_blk_reg_map *hw;
-
-	if (_sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED3, &idx) || !de_cfg)
-		return;
-
-	if (!de_cfg->enable)
-		return;
-
-	hw = &ctx->hw;
-	sharp_lvl = (de_cfg->sharpen_level1 & 0x1FF) |
-		((de_cfg->sharpen_level2 & 0x1FF) << 16);
-
-	sharp_ctl = ((de_cfg->limit & 0xF) << 9) |
-		((de_cfg->prec_shift & 0x7) << 13) |
-		((de_cfg->clip & 0x7) << 16);
-
-	shape_ctl = (de_cfg->thr_quiet & 0xFF) |
-		((de_cfg->thr_dieout & 0x3FF) << 16);
-
-	de_thr = (de_cfg->thr_low & 0x3FF) |
-		((de_cfg->thr_high & 0x3FF) << 16);
-
-	adjust_a = (de_cfg->adjust_a[0] & 0x3FF) |
-		((de_cfg->adjust_a[1] & 0x3FF) << 10) |
-		((de_cfg->adjust_a[2] & 0x3FF) << 20);
-
-	adjust_b = (de_cfg->adjust_b[0] & 0x3FF) |
-		((de_cfg->adjust_b[1] & 0x3FF) << 10) |
-		((de_cfg->adjust_b[2] & 0x3FF) << 20);
-
-	adjust_c = (de_cfg->adjust_c[0] & 0x3FF) |
-		((de_cfg->adjust_c[1] & 0x3FF) << 10) |
-		((de_cfg->adjust_c[2] & 0x3FF) << 20);
-
-	SDE_REG_WRITE(hw, QSEED3_DE_SHARPEN + idx, sharp_lvl);
-	SDE_REG_WRITE(hw, QSEED3_DE_SHARPEN_CTL + idx, sharp_ctl);
-	SDE_REG_WRITE(hw, QSEED3_DE_SHAPE_CTL + idx, shape_ctl);
-	SDE_REG_WRITE(hw, QSEED3_DE_THRESHOLD + idx, de_thr);
-	SDE_REG_WRITE(hw, QSEED3_DE_ADJUST_DATA_0 + idx, adjust_a);
-	SDE_REG_WRITE(hw, QSEED3_DE_ADJUST_DATA_1 + idx, adjust_b);
-	SDE_REG_WRITE(hw, QSEED3_DE_ADJUST_DATA_2 + idx, adjust_c);
-
-}
-
 static void _sde_hw_sspp_setup_scaler3(struct sde_hw_pipe *ctx,
 		struct sde_hw_pipe_cfg *sspp,
 		struct sde_hw_pixel_ext *pe,
 		void *scaler_cfg)
 {
 	u32 idx;
-	u32 op_mode = 0;
-	u32 phase_init, preload, src_y_rgb, src_uv, dst;
 	struct sde_hw_scaler3_cfg *scaler3_cfg = scaler_cfg;
 
 	(void)pe;
@@ -701,93 +519,9 @@
 		|| !scaler3_cfg || !ctx || !ctx->cap || !ctx->cap->sblk)
 		return;
 
-	if (!scaler3_cfg->enable)
-		goto end;
-
-	op_mode |= BIT(0);
-	op_mode |= (scaler3_cfg->y_rgb_filter_cfg & 0x3) << 16;
-
-	if (SDE_FORMAT_IS_YUV(sspp->layout.format)) {
-		op_mode |= BIT(12);
-		op_mode |= (scaler3_cfg->uv_filter_cfg & 0x3) << 24;
-	}
-
-	op_mode |= (scaler3_cfg->blend_cfg & 1) << 31;
-	op_mode |= (scaler3_cfg->dir_en) ? BIT(4) : 0;
-
-	preload =
-		((scaler3_cfg->preload_x[0] & 0x7F) << 0) |
-		((scaler3_cfg->preload_y[0] & 0x7F) << 8) |
-		((scaler3_cfg->preload_x[1] & 0x7F) << 16) |
-		((scaler3_cfg->preload_y[1] & 0x7F) << 24);
-
-	src_y_rgb = (scaler3_cfg->src_width[0] & 0x1FFFF) |
-		((scaler3_cfg->src_height[0] & 0x1FFFF) << 16);
-
-	src_uv = (scaler3_cfg->src_width[1] & 0x1FFFF) |
-		((scaler3_cfg->src_height[1] & 0x1FFFF) << 16);
-
-	dst = (scaler3_cfg->dst_width & 0x1FFFF) |
-		((scaler3_cfg->dst_height & 0x1FFFF) << 16);
-
-	if (scaler3_cfg->de.enable) {
-		_sde_hw_sspp_setup_scaler3_de(ctx, &scaler3_cfg->de);
-		op_mode |= BIT(8);
-	}
-
-	if (scaler3_cfg->lut_flag)
-		_sde_hw_sspp_setup_scaler3_lut(ctx, scaler3_cfg);
-
-	if (ctx->cap->sblk->scaler_blk.version == 0x1002) {
-		phase_init =
-			((scaler3_cfg->init_phase_x[0] & 0x3F) << 0) |
-			((scaler3_cfg->init_phase_y[0] & 0x3F) << 8) |
-			((scaler3_cfg->init_phase_x[1] & 0x3F) << 16) |
-			((scaler3_cfg->init_phase_y[1] & 0x3F) << 24);
-		SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_INIT + idx, phase_init);
-	} else {
-		SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_INIT_Y_H + idx,
-			scaler3_cfg->init_phase_x[0] & 0x1FFFFF);
-		SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_INIT_Y_V + idx,
-			scaler3_cfg->init_phase_y[0] & 0x1FFFFF);
-		SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_INIT_UV_H + idx,
-			scaler3_cfg->init_phase_x[1] & 0x1FFFFF);
-		SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_INIT_UV_V + idx,
-			scaler3_cfg->init_phase_y[1] & 0x1FFFFF);
-	}
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_STEP_Y_H + idx,
-		scaler3_cfg->phase_step_x[0] & 0xFFFFFF);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_STEP_Y_V + idx,
-		scaler3_cfg->phase_step_y[0] & 0xFFFFFF);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_STEP_UV_H + idx,
-		scaler3_cfg->phase_step_x[1] & 0xFFFFFF);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_PHASE_STEP_UV_V + idx,
-		scaler3_cfg->phase_step_y[1] & 0xFFFFFF);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_PRELOAD + idx, preload);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_SRC_SIZE_Y_RGB_A + idx, src_y_rgb);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_SRC_SIZE_UV + idx, src_uv);
-
-	SDE_REG_WRITE(&ctx->hw, QSEED3_DST_SIZE + idx, dst);
-
-end:
-	if (!SDE_FORMAT_IS_DX(sspp->layout.format))
-		op_mode |= BIT(14);
-
-	if (sspp->layout.format->alpha_enable) {
-		op_mode |= BIT(10);
-		if (ctx->cap->sblk->scaler_blk.version == 0x1002)
-			op_mode |= (scaler3_cfg->alpha_filter_cfg & 0x1) << 30;
-		else
-			op_mode |= (scaler3_cfg->alpha_filter_cfg & 0x3) << 29;
-	}
-	SDE_REG_WRITE(&ctx->hw, QSEED3_OP_MODE + idx, op_mode);
+	sde_hw_setup_scaler3(&ctx->hw, scaler3_cfg, idx,
+			ctx->cap->sblk->scaler_blk.version,
+			sspp->layout.format);
 }
 
 static u32 _sde_hw_sspp_get_scaler3_ver(struct sde_hw_pipe *ctx)
@@ -797,7 +531,7 @@
 	if (!ctx || _sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED3, &idx))
 		return 0;
 
-	return SDE_REG_READ(&ctx->hw, QSEED3_HW_VERSION + idx);
+	return sde_hw_get_scaler3_ver(&ctx->hw, idx);
 }
 
 /**
@@ -1140,10 +874,12 @@
 }
 
 static void sde_hw_sspp_setup_cdp(struct sde_hw_pipe *ctx,
-		struct sde_hw_pipe_cdp_cfg *cfg)
+		struct sde_hw_pipe_cdp_cfg *cfg,
+		enum sde_sspp_multirect_index index)
 {
 	u32 idx;
 	u32 cdp_cntl = 0;
+	u32 cdp_cntl_offset = 0;
 
 	if (!ctx || !cfg)
 		return;
@@ -1151,6 +887,13 @@
 	if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
 		return;
 
+	if (index == SDE_SSPP_RECT_0)
+		cdp_cntl_offset = SSPP_CDP_CNTL;
+	else if (index == SDE_SSPP_RECT_1)
+		cdp_cntl_offset = SSPP_CDP_CNTL_REC1;
+	else
+		return;
+
 	if (cfg->enable)
 		cdp_cntl |= BIT(0);
 	if (cfg->ubwc_meta_enable)
@@ -1160,7 +903,7 @@
 	if (cfg->preload_ahead == SDE_SSPP_CDP_PRELOAD_AHEAD_64)
 		cdp_cntl |= BIT(3);
 
-	SDE_REG_WRITE(&ctx->hw, SSPP_CDP_CNTL, cdp_cntl);
+	SDE_REG_WRITE(&ctx->hw, cdp_cntl_offset, cdp_cntl);
 }
 
 static void _setup_layer_ops(struct sde_hw_pipe *c,
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_sspp.h b/drivers/gpu/drm/msm/sde/sde_hw_sspp.h
index 8700627..d32c9d8 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_sspp.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_sspp.h
@@ -156,114 +156,6 @@
 };
 
 /**
- * struct sde_hw_scaler3_de_cfg : QSEEDv3 detail enhancer configuration
- * @enable:         detail enhancer enable/disable
- * @sharpen_level1: sharpening strength for noise
- * @sharpen_level2: sharpening strength for signal
- * @ clip:          clip shift
- * @ limit:         limit value
- * @ thr_quiet:     quiet threshold
- * @ thr_dieout:    dieout threshold
- * @ thr_high:      low threshold
- * @ thr_high:      high threshold
- * @ prec_shift:    precision shift
- * @ adjust_a:      A-coefficients for mapping curve
- * @ adjust_b:      B-coefficients for mapping curve
- * @ adjust_c:      C-coefficients for mapping curve
- */
-struct sde_hw_scaler3_de_cfg {
-	u32 enable;
-	int16_t sharpen_level1;
-	int16_t sharpen_level2;
-	uint16_t clip;
-	uint16_t limit;
-	uint16_t thr_quiet;
-	uint16_t thr_dieout;
-	uint16_t thr_low;
-	uint16_t thr_high;
-	uint16_t prec_shift;
-	int16_t adjust_a[SDE_MAX_DE_CURVES];
-	int16_t adjust_b[SDE_MAX_DE_CURVES];
-	int16_t adjust_c[SDE_MAX_DE_CURVES];
-};
-
-/**
- * struct sde_hw_scaler3_cfg : QSEEDv3 configuration
- * @enable:        scaler enable
- * @dir_en:        direction detection block enable
- * @ init_phase_x: horizontal initial phase
- * @ phase_step_x: horizontal phase step
- * @ init_phase_y: vertical initial phase
- * @ phase_step_y: vertical phase step
- * @ preload_x:    horizontal preload value
- * @ preload_y:    vertical preload value
- * @ src_width:    source width
- * @ src_height:   source height
- * @ dst_width:    destination width
- * @ dst_height:   destination height
- * @ y_rgb_filter_cfg: y/rgb plane filter configuration
- * @ uv_filter_cfg: uv plane filter configuration
- * @ alpha_filter_cfg: alpha filter configuration
- * @ blend_cfg:    blend coefficients configuration
- * @ lut_flag:     scaler LUT update flags
- *                 0x1 swap LUT bank
- *                 0x2 update 2D filter LUT
- *                 0x4 update y circular filter LUT
- *                 0x8 update uv circular filter LUT
- *                 0x10 update y separable filter LUT
- *                 0x20 update uv separable filter LUT
- * @ dir_lut_idx:  2D filter LUT index
- * @ y_rgb_cir_lut_idx: y circular filter LUT index
- * @ uv_cir_lut_idx: uv circular filter LUT index
- * @ y_rgb_sep_lut_idx: y circular filter LUT index
- * @ uv_sep_lut_idx: uv separable filter LUT index
- * @ dir_lut:      pointer to 2D LUT
- * @ cir_lut:      pointer to circular filter LUT
- * @ sep_lut:      pointer to separable filter LUT
- * @ de: detail enhancer configuration
- */
-struct sde_hw_scaler3_cfg {
-	u32 enable;
-	u32 dir_en;
-	int32_t init_phase_x[SDE_MAX_PLANES];
-	int32_t phase_step_x[SDE_MAX_PLANES];
-	int32_t init_phase_y[SDE_MAX_PLANES];
-	int32_t phase_step_y[SDE_MAX_PLANES];
-
-	u32 preload_x[SDE_MAX_PLANES];
-	u32 preload_y[SDE_MAX_PLANES];
-	u32 src_width[SDE_MAX_PLANES];
-	u32 src_height[SDE_MAX_PLANES];
-
-	u32 dst_width;
-	u32 dst_height;
-
-	u32 y_rgb_filter_cfg;
-	u32 uv_filter_cfg;
-	u32 alpha_filter_cfg;
-	u32 blend_cfg;
-
-	u32 lut_flag;
-	u32 dir_lut_idx;
-
-	u32 y_rgb_cir_lut_idx;
-	u32 uv_cir_lut_idx;
-	u32 y_rgb_sep_lut_idx;
-	u32 uv_sep_lut_idx;
-	u32 *dir_lut;
-	size_t dir_len;
-	u32 *cir_lut;
-	size_t cir_len;
-	u32 *sep_lut;
-	size_t sep_len;
-
-	/*
-	 * Detail enhancer settings
-	 */
-	struct sde_hw_scaler3_de_cfg de;
-};
-
-/**
  * struct sde_hw_pipe_cfg : Pipe description
  * @layout:    format layout information for programming buffer to hardware
  * @src_rect:  src ROI, caller takes into account the different operations
@@ -610,9 +502,11 @@
 	 * setup_cdp - setup client driven prefetch
 	 * @ctx: Pointer to pipe context
 	 * @cfg: Pointer to cdp configuration
+	 * @index: rectangle index in multirect
 	 */
 	void (*setup_cdp)(struct sde_hw_pipe *ctx,
-			struct sde_hw_pipe_cdp_cfg *cfg);
+			struct sde_hw_pipe_cdp_cfg *cfg,
+			enum sde_sspp_multirect_index index);
 
 	/**
 	 * setup_secure_address - setup secureity status of the source address
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_util.c b/drivers/gpu/drm/msm/sde/sde_hw_util.c
index 7df5736..08fe5e1 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_util.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_util.c
@@ -10,6 +10,8 @@
  * GNU General Public License for more details.
  */
 #define pr_fmt(fmt)	"[drm:%s:%d] " fmt, __func__, __LINE__
+
+#include <uapi/drm/sde_drm.h>
 #include "msm_drv.h"
 #include "sde_kms.h"
 #include "sde_hw_mdss.h"
@@ -18,6 +20,57 @@
 /* using a file static variables for debugfs access */
 static u32 sde_hw_util_log_mask = SDE_DBG_MASK_NONE;
 
+/* SDE_SCALER_QSEED3 */
+#define QSEED3_HW_VERSION                  0x00
+#define QSEED3_OP_MODE                     0x04
+#define QSEED3_RGB2Y_COEFF                 0x08
+#define QSEED3_PHASE_INIT                  0x0C
+#define QSEED3_PHASE_STEP_Y_H              0x10
+#define QSEED3_PHASE_STEP_Y_V              0x14
+#define QSEED3_PHASE_STEP_UV_H             0x18
+#define QSEED3_PHASE_STEP_UV_V             0x1C
+#define QSEED3_PRELOAD                     0x20
+#define QSEED3_DE_SHARPEN                  0x24
+#define QSEED3_DE_SHARPEN_CTL              0x28
+#define QSEED3_DE_SHAPE_CTL                0x2C
+#define QSEED3_DE_THRESHOLD                0x30
+#define QSEED3_DE_ADJUST_DATA_0            0x34
+#define QSEED3_DE_ADJUST_DATA_1            0x38
+#define QSEED3_DE_ADJUST_DATA_2            0x3C
+#define QSEED3_SRC_SIZE_Y_RGB_A            0x40
+#define QSEED3_SRC_SIZE_UV                 0x44
+#define QSEED3_DST_SIZE                    0x48
+#define QSEED3_COEF_LUT_CTRL               0x4C
+#define QSEED3_COEF_LUT_SWAP_BIT           0
+#define QSEED3_COEF_LUT_DIR_BIT            1
+#define QSEED3_COEF_LUT_Y_CIR_BIT          2
+#define QSEED3_COEF_LUT_UV_CIR_BIT         3
+#define QSEED3_COEF_LUT_Y_SEP_BIT          4
+#define QSEED3_COEF_LUT_UV_SEP_BIT         5
+#define QSEED3_BUFFER_CTRL                 0x50
+#define QSEED3_CLK_CTRL0                   0x54
+#define QSEED3_CLK_CTRL1                   0x58
+#define QSEED3_CLK_STATUS                  0x5C
+#define QSEED3_MISR_CTRL                   0x70
+#define QSEED3_MISR_SIGNATURE_0            0x74
+#define QSEED3_MISR_SIGNATURE_1            0x78
+#define QSEED3_PHASE_INIT_Y_H              0x90
+#define QSEED3_PHASE_INIT_Y_V              0x94
+#define QSEED3_PHASE_INIT_UV_H             0x98
+#define QSEED3_PHASE_INIT_UV_V             0x9C
+#define QSEED3_COEF_LUT                    0x100
+#define QSEED3_FILTERS                     5
+#define QSEED3_LUT_REGIONS                 4
+#define QSEED3_CIRCULAR_LUTS               9
+#define QSEED3_SEPARABLE_LUTS              10
+#define QSEED3_LUT_SIZE                    60
+#define QSEED3_ENABLE                      2
+#define QSEED3_DIR_LUT_SIZE                (200 * sizeof(u32))
+#define QSEED3_CIR_LUT_SIZE \
+	(QSEED3_LUT_SIZE * QSEED3_CIRCULAR_LUTS * sizeof(u32))
+#define QSEED3_SEP_LUT_SIZE \
+	(QSEED3_LUT_SIZE * QSEED3_SEPARABLE_LUTS * sizeof(u32))
+
 void sde_reg_write(struct sde_hw_blk_reg_map *c,
 		u32 reg_off,
 		u32 val,
@@ -40,6 +93,283 @@
 	return &sde_hw_util_log_mask;
 }
 
+void sde_set_scaler_v2(struct sde_hw_scaler3_cfg *cfg,
+		const struct sde_drm_scaler_v2 *scale_v2)
+{
+	int i;
+
+	cfg->enable = scale_v2->enable;
+	cfg->dir_en = scale_v2->dir_en;
+
+	for (i = 0; i < SDE_MAX_PLANES; i++) {
+		cfg->init_phase_x[i] = scale_v2->init_phase_x[i];
+		cfg->phase_step_x[i] = scale_v2->phase_step_x[i];
+		cfg->init_phase_y[i] = scale_v2->init_phase_y[i];
+		cfg->phase_step_y[i] = scale_v2->phase_step_y[i];
+
+		cfg->preload_x[i] = scale_v2->preload_x[i];
+		cfg->preload_y[i] = scale_v2->preload_y[i];
+		cfg->src_width[i] = scale_v2->src_width[i];
+		cfg->src_height[i] = scale_v2->src_height[i];
+	}
+
+	cfg->dst_width = scale_v2->dst_width;
+	cfg->dst_height = scale_v2->dst_height;
+
+	cfg->y_rgb_filter_cfg = scale_v2->y_rgb_filter_cfg;
+	cfg->uv_filter_cfg = scale_v2->uv_filter_cfg;
+	cfg->alpha_filter_cfg = scale_v2->alpha_filter_cfg;
+	cfg->blend_cfg = scale_v2->blend_cfg;
+
+	cfg->lut_flag = scale_v2->lut_flag;
+	cfg->dir_lut_idx = scale_v2->dir_lut_idx;
+	cfg->y_rgb_cir_lut_idx = scale_v2->y_rgb_cir_lut_idx;
+	cfg->uv_cir_lut_idx = scale_v2->uv_cir_lut_idx;
+	cfg->y_rgb_sep_lut_idx = scale_v2->y_rgb_sep_lut_idx;
+	cfg->uv_sep_lut_idx = scale_v2->uv_sep_lut_idx;
+
+	cfg->de.enable = scale_v2->de.enable;
+	cfg->de.sharpen_level1 = scale_v2->de.sharpen_level1;
+	cfg->de.sharpen_level2 = scale_v2->de.sharpen_level2;
+	cfg->de.clip = scale_v2->de.clip;
+	cfg->de.limit = scale_v2->de.limit;
+	cfg->de.thr_quiet = scale_v2->de.thr_quiet;
+	cfg->de.thr_dieout = scale_v2->de.thr_dieout;
+	cfg->de.thr_low = scale_v2->de.thr_low;
+	cfg->de.thr_high = scale_v2->de.thr_high;
+	cfg->de.prec_shift = scale_v2->de.prec_shift;
+
+	for (i = 0; i < SDE_MAX_DE_CURVES; i++) {
+		cfg->de.adjust_a[i] = scale_v2->de.adjust_a[i];
+		cfg->de.adjust_b[i] = scale_v2->de.adjust_b[i];
+		cfg->de.adjust_c[i] = scale_v2->de.adjust_c[i];
+	}
+}
+
+static void _sde_hw_setup_scaler3_lut(struct sde_hw_blk_reg_map *c,
+		struct sde_hw_scaler3_cfg *scaler3_cfg, u32 offset)
+{
+	int i, j, filter;
+	int config_lut = 0x0;
+	unsigned long lut_flags;
+	u32 lut_addr, lut_offset, lut_len;
+	u32 *lut[QSEED3_FILTERS] = {NULL, NULL, NULL, NULL, NULL};
+	static const uint32_t off_tbl[QSEED3_FILTERS][QSEED3_LUT_REGIONS][2] = {
+		{{18, 0x000}, {12, 0x120}, {12, 0x1E0}, {8, 0x2A0} },
+		{{6, 0x320}, {3, 0x3E0}, {3, 0x440}, {3, 0x4A0} },
+		{{6, 0x500}, {3, 0x5c0}, {3, 0x620}, {3, 0x680} },
+		{{6, 0x380}, {3, 0x410}, {3, 0x470}, {3, 0x4d0} },
+		{{6, 0x560}, {3, 0x5f0}, {3, 0x650}, {3, 0x6b0} },
+	};
+
+	lut_flags = (unsigned long) scaler3_cfg->lut_flag;
+	if (test_bit(QSEED3_COEF_LUT_DIR_BIT, &lut_flags) &&
+		(scaler3_cfg->dir_len == QSEED3_DIR_LUT_SIZE)) {
+		lut[0] = scaler3_cfg->dir_lut;
+		config_lut = 1;
+	}
+	if (test_bit(QSEED3_COEF_LUT_Y_CIR_BIT, &lut_flags) &&
+		(scaler3_cfg->y_rgb_cir_lut_idx < QSEED3_CIRCULAR_LUTS) &&
+		(scaler3_cfg->cir_len == QSEED3_CIR_LUT_SIZE)) {
+		lut[1] = scaler3_cfg->cir_lut +
+			scaler3_cfg->y_rgb_cir_lut_idx * QSEED3_LUT_SIZE;
+		config_lut = 1;
+	}
+	if (test_bit(QSEED3_COEF_LUT_UV_CIR_BIT, &lut_flags) &&
+		(scaler3_cfg->uv_cir_lut_idx < QSEED3_CIRCULAR_LUTS) &&
+		(scaler3_cfg->cir_len == QSEED3_CIR_LUT_SIZE)) {
+		lut[2] = scaler3_cfg->cir_lut +
+			scaler3_cfg->uv_cir_lut_idx * QSEED3_LUT_SIZE;
+		config_lut = 1;
+	}
+	if (test_bit(QSEED3_COEF_LUT_Y_SEP_BIT, &lut_flags) &&
+		(scaler3_cfg->y_rgb_sep_lut_idx < QSEED3_SEPARABLE_LUTS) &&
+		(scaler3_cfg->sep_len == QSEED3_SEP_LUT_SIZE)) {
+		lut[3] = scaler3_cfg->sep_lut +
+			scaler3_cfg->y_rgb_sep_lut_idx * QSEED3_LUT_SIZE;
+		config_lut = 1;
+	}
+	if (test_bit(QSEED3_COEF_LUT_UV_SEP_BIT, &lut_flags) &&
+		(scaler3_cfg->uv_sep_lut_idx < QSEED3_SEPARABLE_LUTS) &&
+		(scaler3_cfg->sep_len == QSEED3_SEP_LUT_SIZE)) {
+		lut[4] = scaler3_cfg->sep_lut +
+			scaler3_cfg->uv_sep_lut_idx * QSEED3_LUT_SIZE;
+		config_lut = 1;
+	}
+
+	if (config_lut) {
+		for (filter = 0; filter < QSEED3_FILTERS; filter++) {
+			if (!lut[filter])
+				continue;
+			lut_offset = 0;
+			for (i = 0; i < QSEED3_LUT_REGIONS; i++) {
+				lut_addr = QSEED3_COEF_LUT + offset
+					+ off_tbl[filter][i][1];
+				lut_len = off_tbl[filter][i][0] << 2;
+				for (j = 0; j < lut_len; j++) {
+					SDE_REG_WRITE(c,
+						lut_addr,
+						(lut[filter])[lut_offset++]);
+					lut_addr += 4;
+				}
+			}
+		}
+	}
+
+	if (test_bit(QSEED3_COEF_LUT_SWAP_BIT, &lut_flags))
+		SDE_REG_WRITE(c, QSEED3_COEF_LUT_CTRL + offset, BIT(0));
+
+}
+
+static void _sde_hw_setup_scaler3_de(struct sde_hw_blk_reg_map *c,
+		struct sde_hw_scaler3_de_cfg *de_cfg, u32 offset)
+{
+	u32 sharp_lvl, sharp_ctl, shape_ctl, de_thr;
+	u32 adjust_a, adjust_b, adjust_c;
+
+	if (!de_cfg->enable)
+		return;
+
+	sharp_lvl = (de_cfg->sharpen_level1 & 0x1FF) |
+		((de_cfg->sharpen_level2 & 0x1FF) << 16);
+
+	sharp_ctl = ((de_cfg->limit & 0xF) << 9) |
+		((de_cfg->prec_shift & 0x7) << 13) |
+		((de_cfg->clip & 0x7) << 16);
+
+	shape_ctl = (de_cfg->thr_quiet & 0xFF) |
+		((de_cfg->thr_dieout & 0x3FF) << 16);
+
+	de_thr = (de_cfg->thr_low & 0x3FF) |
+		((de_cfg->thr_high & 0x3FF) << 16);
+
+	adjust_a = (de_cfg->adjust_a[0] & 0x3FF) |
+		((de_cfg->adjust_a[1] & 0x3FF) << 10) |
+		((de_cfg->adjust_a[2] & 0x3FF) << 20);
+
+	adjust_b = (de_cfg->adjust_b[0] & 0x3FF) |
+		((de_cfg->adjust_b[1] & 0x3FF) << 10) |
+		((de_cfg->adjust_b[2] & 0x3FF) << 20);
+
+	adjust_c = (de_cfg->adjust_c[0] & 0x3FF) |
+		((de_cfg->adjust_c[1] & 0x3FF) << 10) |
+		((de_cfg->adjust_c[2] & 0x3FF) << 20);
+
+	SDE_REG_WRITE(c, QSEED3_DE_SHARPEN + offset, sharp_lvl);
+	SDE_REG_WRITE(c, QSEED3_DE_SHARPEN_CTL + offset, sharp_ctl);
+	SDE_REG_WRITE(c, QSEED3_DE_SHAPE_CTL + offset, shape_ctl);
+	SDE_REG_WRITE(c, QSEED3_DE_THRESHOLD + offset, de_thr);
+	SDE_REG_WRITE(c, QSEED3_DE_ADJUST_DATA_0 + offset, adjust_a);
+	SDE_REG_WRITE(c, QSEED3_DE_ADJUST_DATA_1 + offset, adjust_b);
+	SDE_REG_WRITE(c, QSEED3_DE_ADJUST_DATA_2 + offset, adjust_c);
+
+}
+
+void sde_hw_setup_scaler3(struct sde_hw_blk_reg_map *c,
+		struct sde_hw_scaler3_cfg *scaler3_cfg,
+		u32 scaler_offset, u32 scaler_version,
+		const struct sde_format *format)
+{
+	u32 op_mode = 0;
+	u32 phase_init, preload, src_y_rgb, src_uv, dst;
+
+	if (!scaler3_cfg->enable)
+		goto end;
+
+	op_mode |= BIT(0);
+	op_mode |= (scaler3_cfg->y_rgb_filter_cfg & 0x3) << 16;
+
+	if (format && SDE_FORMAT_IS_YUV(format)) {
+		op_mode |= BIT(12);
+		op_mode |= (scaler3_cfg->uv_filter_cfg & 0x3) << 24;
+	}
+
+	op_mode |= (scaler3_cfg->blend_cfg & 1) << 31;
+	op_mode |= (scaler3_cfg->dir_en) ? BIT(4) : 0;
+
+	preload =
+		((scaler3_cfg->preload_x[0] & 0x7F) << 0) |
+		((scaler3_cfg->preload_y[0] & 0x7F) << 8) |
+		((scaler3_cfg->preload_x[1] & 0x7F) << 16) |
+		((scaler3_cfg->preload_y[1] & 0x7F) << 24);
+
+	src_y_rgb = (scaler3_cfg->src_width[0] & 0x1FFFF) |
+		((scaler3_cfg->src_height[0] & 0x1FFFF) << 16);
+
+	src_uv = (scaler3_cfg->src_width[1] & 0x1FFFF) |
+		((scaler3_cfg->src_height[1] & 0x1FFFF) << 16);
+
+	dst = (scaler3_cfg->dst_width & 0x1FFFF) |
+		((scaler3_cfg->dst_height & 0x1FFFF) << 16);
+
+	if (scaler3_cfg->de.enable) {
+		_sde_hw_setup_scaler3_de(c, &scaler3_cfg->de, scaler_offset);
+		op_mode |= BIT(8);
+	}
+
+	if (scaler3_cfg->lut_flag)
+		_sde_hw_setup_scaler3_lut(c, scaler3_cfg,
+								scaler_offset);
+
+	if (scaler_version == 0x1002) {
+		phase_init =
+			((scaler3_cfg->init_phase_x[0] & 0x3F) << 0) |
+			((scaler3_cfg->init_phase_y[0] & 0x3F) << 8) |
+			((scaler3_cfg->init_phase_x[1] & 0x3F) << 16) |
+			((scaler3_cfg->init_phase_y[1] & 0x3F) << 24);
+		SDE_REG_WRITE(c, QSEED3_PHASE_INIT + scaler_offset, phase_init);
+	} else {
+		SDE_REG_WRITE(c, QSEED3_PHASE_INIT_Y_H + scaler_offset,
+			scaler3_cfg->init_phase_x[0] & 0x1FFFFF);
+		SDE_REG_WRITE(c, QSEED3_PHASE_INIT_Y_V + scaler_offset,
+			scaler3_cfg->init_phase_y[0] & 0x1FFFFF);
+		SDE_REG_WRITE(c, QSEED3_PHASE_INIT_UV_H + scaler_offset,
+			scaler3_cfg->init_phase_x[1] & 0x1FFFFF);
+		SDE_REG_WRITE(c, QSEED3_PHASE_INIT_UV_V + scaler_offset,
+			scaler3_cfg->init_phase_y[1] & 0x1FFFFF);
+	}
+
+	SDE_REG_WRITE(c, QSEED3_PHASE_STEP_Y_H + scaler_offset,
+		scaler3_cfg->phase_step_x[0] & 0xFFFFFF);
+
+	SDE_REG_WRITE(c, QSEED3_PHASE_STEP_Y_V + scaler_offset,
+		scaler3_cfg->phase_step_y[0] & 0xFFFFFF);
+
+	SDE_REG_WRITE(c, QSEED3_PHASE_STEP_UV_H + scaler_offset,
+		scaler3_cfg->phase_step_x[1] & 0xFFFFFF);
+
+	SDE_REG_WRITE(c, QSEED3_PHASE_STEP_UV_V + scaler_offset,
+		scaler3_cfg->phase_step_y[1] & 0xFFFFFF);
+
+	SDE_REG_WRITE(c, QSEED3_PRELOAD + scaler_offset, preload);
+
+	SDE_REG_WRITE(c, QSEED3_SRC_SIZE_Y_RGB_A + scaler_offset, src_y_rgb);
+
+	SDE_REG_WRITE(c, QSEED3_SRC_SIZE_UV + scaler_offset, src_uv);
+
+	SDE_REG_WRITE(c, QSEED3_DST_SIZE + scaler_offset, dst);
+
+end:
+	if (format && !SDE_FORMAT_IS_DX(format))
+		op_mode |= BIT(14);
+
+	if (format && format->alpha_enable) {
+		op_mode |= BIT(10);
+		if (scaler_version == 0x1002)
+			op_mode |= (scaler3_cfg->alpha_filter_cfg & 0x1) << 30;
+		else
+			op_mode |= (scaler3_cfg->alpha_filter_cfg & 0x3) << 29;
+	}
+
+	SDE_REG_WRITE(c, QSEED3_OP_MODE + scaler_offset, op_mode);
+}
+
+u32 sde_hw_get_scaler3_ver(struct sde_hw_blk_reg_map *c,
+			u32 scaler_offset)
+{
+	return SDE_REG_READ(c, QSEED3_HW_VERSION + scaler_offset);
+}
+
 void sde_hw_csc_setup(struct sde_hw_blk_reg_map *c,
 		u32 csc_reg_off,
 		struct sde_csc_cfg *data, bool csc10)
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_util.h b/drivers/gpu/drm/msm/sde/sde_hw_util.h
index aa3d5b9..720e113 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_util.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_util.h
@@ -39,6 +39,125 @@
 	u32 log_mask;
 };
 
+/**
+ * struct sde_hw_scaler3_de_cfg : QSEEDv3 detail enhancer configuration
+ * @enable:         detail enhancer enable/disable
+ * @sharpen_level1: sharpening strength for noise
+ * @sharpen_level2: sharpening strength for signal
+ * @ clip:          clip shift
+ * @ limit:         limit value
+ * @ thr_quiet:     quiet threshold
+ * @ thr_dieout:    dieout threshold
+ * @ thr_high:      low threshold
+ * @ thr_high:      high threshold
+ * @ prec_shift:    precision shift
+ * @ adjust_a:      A-coefficients for mapping curve
+ * @ adjust_b:      B-coefficients for mapping curve
+ * @ adjust_c:      C-coefficients for mapping curve
+ */
+struct sde_hw_scaler3_de_cfg {
+	u32 enable;
+	int16_t sharpen_level1;
+	int16_t sharpen_level2;
+	uint16_t clip;
+	uint16_t limit;
+	uint16_t thr_quiet;
+	uint16_t thr_dieout;
+	uint16_t thr_low;
+	uint16_t thr_high;
+	uint16_t prec_shift;
+	int16_t adjust_a[SDE_MAX_DE_CURVES];
+	int16_t adjust_b[SDE_MAX_DE_CURVES];
+	int16_t adjust_c[SDE_MAX_DE_CURVES];
+};
+
+
+/**
+ * struct sde_hw_scaler3_cfg : QSEEDv3 configuration
+ * @enable:        scaler enable
+ * @dir_en:        direction detection block enable
+ * @ init_phase_x: horizontal initial phase
+ * @ phase_step_x: horizontal phase step
+ * @ init_phase_y: vertical initial phase
+ * @ phase_step_y: vertical phase step
+ * @ preload_x:    horizontal preload value
+ * @ preload_y:    vertical preload value
+ * @ src_width:    source width
+ * @ src_height:   source height
+ * @ dst_width:    destination width
+ * @ dst_height:   destination height
+ * @ y_rgb_filter_cfg: y/rgb plane filter configuration
+ * @ uv_filter_cfg: uv plane filter configuration
+ * @ alpha_filter_cfg: alpha filter configuration
+ * @ blend_cfg:    blend coefficients configuration
+ * @ lut_flag:     scaler LUT update flags
+ *                 0x1 swap LUT bank
+ *                 0x2 update 2D filter LUT
+ *                 0x4 update y circular filter LUT
+ *                 0x8 update uv circular filter LUT
+ *                 0x10 update y separable filter LUT
+ *                 0x20 update uv separable filter LUT
+ * @ dir_lut_idx:  2D filter LUT index
+ * @ y_rgb_cir_lut_idx: y circular filter LUT index
+ * @ uv_cir_lut_idx: uv circular filter LUT index
+ * @ y_rgb_sep_lut_idx: y circular filter LUT index
+ * @ uv_sep_lut_idx: uv separable filter LUT index
+ * @ dir_lut:      pointer to 2D LUT
+ * @ cir_lut:      pointer to circular filter LUT
+ * @ sep_lut:      pointer to separable filter LUT
+ * @ de: detail enhancer configuration
+ */
+struct sde_hw_scaler3_cfg {
+	u32 enable;
+	u32 dir_en;
+	int32_t init_phase_x[SDE_MAX_PLANES];
+	int32_t phase_step_x[SDE_MAX_PLANES];
+	int32_t init_phase_y[SDE_MAX_PLANES];
+	int32_t phase_step_y[SDE_MAX_PLANES];
+
+	u32 preload_x[SDE_MAX_PLANES];
+	u32 preload_y[SDE_MAX_PLANES];
+	u32 src_width[SDE_MAX_PLANES];
+	u32 src_height[SDE_MAX_PLANES];
+
+	u32 dst_width;
+	u32 dst_height;
+
+	u32 y_rgb_filter_cfg;
+	u32 uv_filter_cfg;
+	u32 alpha_filter_cfg;
+	u32 blend_cfg;
+
+	u32 lut_flag;
+	u32 dir_lut_idx;
+
+	u32 y_rgb_cir_lut_idx;
+	u32 uv_cir_lut_idx;
+	u32 y_rgb_sep_lut_idx;
+	u32 uv_sep_lut_idx;
+	u32 *dir_lut;
+	size_t dir_len;
+	u32 *cir_lut;
+	size_t cir_len;
+	u32 *sep_lut;
+	size_t sep_len;
+
+	/*
+	 * Detail enhancer settings
+	 */
+	struct sde_hw_scaler3_de_cfg de;
+};
+
+struct sde_hw_scaler3_lut_cfg {
+	bool is_configured;
+	u32 *dir_lut;
+	size_t dir_len;
+	u32 *cir_lut;
+	size_t cir_len;
+	u32 *sep_lut;
+	size_t sep_len;
+};
+
 u32 *sde_hw_util_get_log_mask_ptr(void);
 
 void sde_reg_write(struct sde_hw_blk_reg_map *c,
@@ -58,6 +177,17 @@
 
 void *sde_hw_util_get_dir(void);
 
+void sde_set_scaler_v2(struct sde_hw_scaler3_cfg *cfg,
+		const struct sde_drm_scaler_v2 *scale_v2);
+
+void sde_hw_setup_scaler3(struct sde_hw_blk_reg_map *c,
+		struct sde_hw_scaler3_cfg *scaler3_cfg,
+		u32 scaler_offset, u32 scaler_version,
+		const struct sde_format *format);
+
+u32 sde_hw_get_scaler3_ver(struct sde_hw_blk_reg_map *c,
+		u32 scaler_offset);
+
 void sde_hw_csc_setup(struct sde_hw_blk_reg_map  *c,
 		u32 csc_reg_off,
 		struct sde_csc_cfg *data, bool csc10);
diff --git a/drivers/gpu/drm/msm/sde/sde_irq.c b/drivers/gpu/drm/msm/sde/sde_irq.c
index eeb7a00..76f89f4 100644
--- a/drivers/gpu/drm/msm/sde/sde_irq.c
+++ b/drivers/gpu/drm/msm/sde/sde_irq.c
@@ -19,6 +19,30 @@
 #include "sde_irq.h"
 #include "sde_core_irq.h"
 
+static uint32_t g_sde_irq_status;
+
+void sde_irq_update(struct msm_kms *msm_kms, bool enable)
+{
+	int irq_num;
+	struct sde_kms *sde_kms = to_sde_kms(msm_kms);
+
+	if (!msm_kms || !sde_kms) {
+		SDE_ERROR("invalid kms arguments\n");
+		return;
+	}
+
+	irq_num = platform_get_irq(sde_kms->dev->platformdev, 0);
+	if (irq_num < 0) {
+		SDE_ERROR("invalid irq number\n");
+		return;
+	}
+
+	if (enable)
+		enable_irq(irq_num);
+	else
+		disable_irq(irq_num);
+}
+
 irqreturn_t sde_irq(struct msm_kms *kms)
 {
 	struct sde_kms *sde_kms = to_sde_kms(kms);
@@ -27,6 +51,9 @@
 	sde_kms->hw_intr->ops.get_interrupt_sources(sde_kms->hw_intr,
 			&interrupts);
 
+	/* store irq status in case of irq-storm debugging */
+	g_sde_irq_status = interrupts;
+
 	/*
 	 * Taking care of MDP interrupt
 	 */
@@ -40,13 +67,30 @@
 	 */
 	while (interrupts) {
 		irq_hw_number_t hwirq = fls(interrupts) - 1;
+		unsigned int mapping;
+		int rc;
 
-		generic_handle_irq(irq_find_mapping(
-				sde_kms->irq_controller.domain, hwirq));
+		mapping = irq_find_mapping(sde_kms->irq_controller.domain,
+				hwirq);
+		if (mapping == 0) {
+			SDE_EVT32(hwirq, SDE_EVTLOG_ERROR);
+			goto error;
+		}
+
+		rc = generic_handle_irq(mapping);
+		if (rc < 0) {
+			SDE_EVT32(hwirq, mapping, rc, SDE_EVTLOG_ERROR);
+			goto error;
+		}
+
 		interrupts &= ~(1 << hwirq);
 	}
 
 	return IRQ_HANDLED;
+
+error:
+	/* bad situation, inform irq system, it may disable overall MDSS irq */
+	return IRQ_NONE;
 }
 
 void sde_irq_preinstall(struct msm_kms *kms)
diff --git a/drivers/gpu/drm/msm/sde/sde_irq.h b/drivers/gpu/drm/msm/sde/sde_irq.h
index e1090071..5bb299a 100644
--- a/drivers/gpu/drm/msm/sde/sde_irq.h
+++ b/drivers/gpu/drm/msm/sde/sde_irq.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -56,4 +56,11 @@
  */
 irqreturn_t sde_irq(struct msm_kms *kms);
 
+/**
+ * sde_irq_update - enable/disable IRQ line
+ * @kms:		pointer to kms context
+ * @enable:		enable:true, disable:false
+ */
+void sde_irq_update(struct msm_kms *kms, bool enable);
+
 #endif /* __SDE_IRQ_H__ */
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.c b/drivers/gpu/drm/msm/sde/sde_kms.c
index 4efddb4..bf06dfb 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.c
+++ b/drivers/gpu/drm/msm/sde/sde_kms.c
@@ -545,7 +545,9 @@
 	struct msm_drm_private *priv;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
-	int i;
+	struct drm_connector *connector;
+	struct drm_connector_state *old_conn_state;
+	int i, rc = 0;
 
 	if (!kms || !old_state)
 		return;
@@ -558,6 +560,19 @@
 	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i)
 		sde_crtc_complete_commit(crtc, old_crtc_state);
 
+	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
+		struct sde_connector *c_conn;
+
+		c_conn = to_sde_connector(connector);
+		if (!c_conn->ops.post_kickoff)
+			continue;
+		rc = c_conn->ops.post_kickoff(connector);
+		if (rc) {
+			pr_err("Connector Post kickoff failed rc=%d\n",
+					 rc);
+		}
+	}
+
 	sde_power_resource_enable(&priv->phandle, sde_kms->core_client, false);
 
 	SDE_EVT32_VERBOSE(SDE_EVTLOG_FUNC_EXIT);
@@ -758,6 +773,8 @@
 		.set_power = dsi_display_set_power,
 		.get_mode_info = dsi_conn_get_mode_info,
 		.get_dst_format = dsi_display_get_dst_format,
+		.post_kickoff = dsi_conn_post_kickoff,
+		.check_status = dsi_display_check_status,
 	};
 	static const struct sde_connector_ops wb_ops = {
 		.post_init =    sde_wb_connector_post_init,
@@ -767,7 +784,8 @@
 		.get_info =     sde_wb_get_info,
 		.soft_reset =   NULL,
 		.get_mode_info = sde_wb_get_mode_info,
-		.get_dst_format = NULL
+		.get_dst_format = NULL,
+		.check_status = NULL,
 	};
 	static const struct sde_connector_ops dp_ops = {
 		.post_init  = dp_connector_post_init,
@@ -776,6 +794,8 @@
 		.mode_valid = dp_connector_mode_valid,
 		.get_info   = dp_connector_get_info,
 		.get_mode_info  = dp_connector_get_mode_info,
+		.send_hpd_event = dp_connector_send_hpd_event,
+		.check_status = NULL,
 	};
 	struct msm_display_info info;
 	struct drm_encoder *encoder;
@@ -1259,11 +1279,13 @@
 	/* allocate backing buffer object */
 	if (sde_kms->iclient) {
 		u32 heap_id = fbo->flags & DRM_MODE_FB_SECURE ?
-				ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID) :
+				ION_HEAP(ION_SECURE_HEAP_ID) :
 				ION_HEAP(ION_SYSTEM_HEAP_ID);
+		u32 iflags = fbo->flags & DRM_MODE_FB_SECURE ?
+				(ION_FLAG_SECURE | ION_FLAG_CP_PIXEL) : 0;
 
 		fbo->ihandle = ion_alloc(sde_kms->iclient,
-				fbo->layout.total_size, SZ_4K, heap_id, 0);
+				fbo->layout.total_size, SZ_4K, heap_id, iflags);
 		if (IS_ERR_OR_NULL(fbo->ihandle)) {
 			SDE_ERROR("failed to alloc ion memory\n");
 			ret = PTR_ERR(fbo->ihandle);
@@ -1401,6 +1423,12 @@
 	if (!priv)
 		return;
 
+	if (sde_kms->genpd_init) {
+		sde_kms->genpd_init = false;
+		pm_genpd_remove(&sde_kms->genpd);
+		of_genpd_del_provider(pdev->dev.of_node);
+	}
+
 	if (sde_kms->hw_intr)
 		sde_hw_intr_destroy(sde_kms->hw_intr);
 	sde_kms->hw_intr = NULL;
@@ -1683,6 +1711,8 @@
 {
 	struct drm_device *dev = NULL;
 	struct sde_kms *sde_kms = NULL;
+	struct drm_connector *connector = NULL;
+	struct sde_connector *sde_conn = NULL;
 
 	if (!kms) {
 		SDE_ERROR("invalid kms\n");
@@ -1697,8 +1727,22 @@
 		return;
 	}
 
-	if (dev->mode_config.funcs->output_poll_changed)
-		dev->mode_config.funcs->output_poll_changed(dev);
+	if (!dev->mode_config.poll_enabled)
+		return;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_for_each_connector(connector, dev) {
+		/* Only handle HPD capable connectors. */
+		if (!(connector->polled & DRM_CONNECTOR_POLL_HPD))
+			continue;
+
+		sde_conn = to_sde_connector(connector);
+
+		if (sde_conn->ops.send_hpd_event)
+			sde_conn->ops.send_hpd_event(sde_conn->display);
+	}
+	mutex_unlock(&dev->mode_config.mutex);
+
 }
 
 static int sde_kms_pm_suspend(struct device *dev)
@@ -1708,7 +1752,7 @@
 	struct drm_connector *conn;
 	struct drm_atomic_state *state;
 	struct sde_kms *sde_kms;
-	int ret = 0;
+	int ret = 0, num_crtcs = 0;
 
 	if (!dev)
 		return -EINVAL;
@@ -1768,7 +1812,9 @@
 				drm_atomic_state_free(state);
 				goto unlock;
 			}
-		} else if (lp != SDE_MODE_DPMS_LP2) {
+		}
+
+		if (lp != SDE_MODE_DPMS_LP2) {
 			/* force CRTC to be inactive */
 			crtc_state = drm_atomic_get_crtc_state(state,
 					conn->state->crtc);
@@ -1778,19 +1824,31 @@
 				drm_atomic_state_free(state);
 				goto unlock;
 			}
-			crtc_state->active = false;
+
+			if (lp != SDE_MODE_DPMS_LP1)
+				crtc_state->active = false;
+			++num_crtcs;
 		}
 	}
 
+	/* check for nothing to do */
+	if (num_crtcs == 0) {
+		DRM_DEBUG("all crtcs are already in the off state\n");
+		drm_atomic_state_free(state);
+		goto suspended;
+	}
+
 	/* commit the "disable all" state */
 	ret = drm_atomic_commit(state);
 	if (ret < 0) {
 		DRM_ERROR("failed to disable crtcs, %d\n", ret);
 		drm_atomic_state_free(state);
-	} else {
-		sde_kms->suspend_block = true;
+		goto unlock;
 	}
 
+suspended:
+	sde_kms->suspend_block = true;
+
 unlock:
 	if (ret == -EDEADLK) {
 		drm_modeset_backoff(&ctx);
@@ -1944,12 +2002,71 @@
 static void sde_kms_handle_power_event(u32 event_type, void *usr)
 {
 	struct sde_kms *sde_kms = usr;
+	struct msm_kms *msm_kms;
 
+	msm_kms = &sde_kms->base;
 	if (!sde_kms)
 		return;
 
-	if (event_type == SDE_POWER_EVENT_POST_ENABLE)
+	SDE_DEBUG("event_type:%d\n", event_type);
+	SDE_EVT32_VERBOSE(event_type);
+
+	if (event_type == SDE_POWER_EVENT_POST_ENABLE) {
+		sde_irq_update(msm_kms, true);
 		sde_vbif_init_memtypes(sde_kms);
+	} else if (event_type == SDE_POWER_EVENT_PRE_DISABLE) {
+		sde_irq_update(msm_kms, false);
+	}
+}
+
+#define genpd_to_sde_kms(domain) container_of(domain, struct sde_kms, genpd)
+
+static int sde_kms_pd_enable(struct generic_pm_domain *genpd)
+{
+	struct sde_kms *sde_kms = genpd_to_sde_kms(genpd);
+	struct drm_device *dev;
+	struct msm_drm_private *priv;
+	int rc;
+
+	SDE_DEBUG("\n");
+
+	dev = sde_kms->dev;
+	if (!dev)
+		return -EINVAL;
+
+	priv = dev->dev_private;
+	if (!priv)
+		return -EINVAL;
+
+	SDE_EVT32(genpd->device_count);
+
+	rc = sde_power_resource_enable(&priv->phandle, priv->pclient, true);
+
+	return rc;
+}
+
+static int sde_kms_pd_disable(struct generic_pm_domain *genpd)
+{
+	struct sde_kms *sde_kms = genpd_to_sde_kms(genpd);
+	struct drm_device *dev;
+	struct msm_drm_private *priv;
+	int rc;
+
+	SDE_DEBUG("\n");
+
+	dev = sde_kms->dev;
+	if (!dev)
+		return -EINVAL;
+
+	priv = dev->dev_private;
+	if (!priv)
+		return -EINVAL;
+
+	SDE_EVT32(genpd->device_count);
+
+	rc = sde_power_resource_enable(&priv->phandle, priv->pclient, false);
+
+	return rc;
 }
 
 static int sde_kms_hw_init(struct msm_kms *kms)
@@ -2031,7 +2148,7 @@
 	} else {
 		sde_kms->reg_dma_len = msm_iomap_size(dev->platformdev,
 								"regdma_phys");
-		rc =  sde_dbg_reg_register_base("vbif_nrt",
+		rc =  sde_dbg_reg_register_base("reg_dma",
 				sde_kms->reg_dma,
 				sde_kms->reg_dma_len);
 		if (rc)
@@ -2177,12 +2294,41 @@
 	 */
 	sde_kms_handle_power_event(SDE_POWER_EVENT_POST_ENABLE, sde_kms);
 	sde_kms->power_event = sde_power_handle_register_event(&priv->phandle,
-			SDE_POWER_EVENT_POST_ENABLE,
+			SDE_POWER_EVENT_POST_ENABLE |
+			SDE_POWER_EVENT_PRE_DISABLE,
 			sde_kms_handle_power_event, sde_kms, "kms");
 
+	/* initialize power domain if defined */
+	if (of_find_property(dev->dev->of_node, "#power-domain-cells", NULL)) {
+		sde_kms->genpd.name = dev->unique;
+		sde_kms->genpd.power_off = sde_kms_pd_disable;
+		sde_kms->genpd.power_on = sde_kms_pd_enable;
+
+		rc = pm_genpd_init(&sde_kms->genpd, NULL, true);
+		if (rc < 0) {
+			SDE_ERROR("failed to init genpd provider %s: %d\n",
+					sde_kms->genpd.name, rc);
+			goto genpd_err;
+		}
+
+		rc = of_genpd_add_provider_simple(dev->dev->of_node,
+				&sde_kms->genpd);
+		if (rc < 0) {
+			SDE_ERROR("failed to add genpd provider %s: %d\n",
+					sde_kms->genpd.name, rc);
+			pm_genpd_remove(&sde_kms->genpd);
+			goto genpd_err;
+		}
+
+		sde_kms->genpd_init = true;
+		SDE_DEBUG("added genpd provider %s\n", sde_kms->genpd.name);
+	}
+
 	sde_power_resource_enable(&priv->phandle, sde_kms->core_client, false);
+
 	return 0;
 
+genpd_err:
 drm_obj_init_err:
 	sde_core_perf_destroy(&sde_kms->perf);
 hw_intr_init_err:
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.h b/drivers/gpu/drm/msm/sde/sde_kms.h
index 0ddfb30..aacff78 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.h
+++ b/drivers/gpu/drm/msm/sde/sde_kms.h
@@ -20,6 +20,7 @@
 #define __SDE_KMS_H__
 
 #include <linux/msm_ion.h>
+#include <linux/pm_domain.h>
 
 #include "msm_drv.h"
 #include "msm_kms.h"
@@ -107,6 +108,9 @@
 #define SDE_KMS_OPS_CLEANUP_PLANE_FB                       BIT(2)
 #define SDE_KMS_OPS_PREPARE_PLANE_FB                       BIT(3)
 
+/* ESD status check interval in miliseconds */
+#define STATUS_CHECK_INTERVAL_MS 5000
+
 /*
  * struct sde_irq_callback - IRQ callback handlers
  * @list: list to callback
@@ -173,6 +177,9 @@
 	int core_rev;
 	struct sde_mdss_cfg *catalog;
 
+	struct generic_pm_domain genpd;
+	bool genpd_init;
+
 	struct msm_gem_address_space *aspace[MSM_SMMU_DOMAIN_MAX];
 	struct sde_power_client *core_client;
 
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.c b/drivers/gpu/drm/msm/sde/sde_plane.c
index 40dad76..f4672b8 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.c
+++ b/drivers/gpu/drm/msm/sde/sde_plane.c
@@ -878,7 +878,6 @@
 			return -EINVAL;
 		break;
 	case SDE_DRM_FB_SEC_DIR_TRANS:
-	case SDE_DRM_FB_NON_SEC_DIR_TRANS:
 		*aspace = NULL;
 		break;
 	default:
@@ -917,6 +916,22 @@
 		return;
 	}
 
+	/*
+	 * framebuffer prepare is deferred for prepare_fb calls that
+	 * happen during the transition from secure to non-secure.
+	 * Handle the prepare at this point for such cases. This can be
+	 * expected for one or two frames during the transition.
+	 */
+	if (aspace && pstate->defer_prepare_fb) {
+		ret = msm_framebuffer_prepare(fb, pstate->aspace);
+		if (ret) {
+			SDE_ERROR_PLANE(psde,
+				"failed to prepare framebuffer %d\n", ret);
+			return;
+		}
+		pstate->defer_prepare_fb = false;
+	}
+
 	ret = sde_format_populate_layout(aspace, fb, &pipe_cfg->layout);
 	if (ret == -EAGAIN)
 		SDE_DEBUG_PLANE(psde, "not updating same src addrs\n");
@@ -1469,6 +1484,12 @@
 		if (psde->pipe_hw->ops.setup_pe)
 			psde->pipe_hw->ops.setup_pe(psde->pipe_hw,
 					&pstate->pixel_ext);
+
+		if (psde->pipe_hw->ops.setup_scaler &&
+				pstate->multirect_index != SDE_SSPP_RECT_1)
+			psde->pipe_hw->ops.setup_scaler(psde->pipe_hw,
+					&psde->pipe_cfg, &pstate->pixel_ext,
+					&pstate->scaler3_cfg);
 	}
 
 	return 0;
@@ -1513,7 +1534,7 @@
  * @plane: Pointer to drm plane
  * return: prefill time in line
  */
-static u32 sde_plane_rot_calc_prefill(struct drm_plane *plane)
+u32 sde_plane_rot_calc_prefill(struct drm_plane *plane)
 {
 	struct drm_plane_state *state;
 	struct sde_plane_state *pstate;
@@ -1542,33 +1563,19 @@
 				&blocksize, &blocksize);
 
 	prefill_line = blocksize + sde_kms->catalog->sbuf_headroom;
-
-	SDE_DEBUG("plane%d prefill:%u\n", plane->base.id, prefill_line);
+	prefill_line = mult_frac(prefill_line, rstate->out_src_h >> 16,
+			state->crtc_h);
+	SDE_DEBUG(
+		"plane%d.%d blk:%u head:%u vdst/vsrc:%u/%u prefill:%u\n",
+			plane->base.id, rstate->sequence_id,
+			blocksize, sde_kms->catalog->sbuf_headroom,
+			state->crtc_h, rstate->out_src_h >> 16,
+			prefill_line);
 
 	return prefill_line;
 }
 
 /**
- * sde_plane_is_sbuf_mode - check if sspp of given plane is in streaming
- *	buffer mode
- * @plane: Pointer to drm plane
- * @prefill: Pointer to prefill line count
- * return: true if sspp is in stream buffer mode
- */
-bool sde_plane_is_sbuf_mode(struct drm_plane *plane, u32 *prefill)
-{
-	struct sde_plane_state *pstate = plane && plane->state ?
-			to_sde_plane_state(plane->state) : NULL;
-	struct sde_plane_rot_state *rstate = pstate ? &pstate->rot : NULL;
-	bool sbuf_mode = rstate ? rstate->out_sbuf : false;
-
-	if (prefill)
-		*prefill = sde_plane_rot_calc_prefill(plane);
-
-	return sbuf_mode;
-}
-
-/**
  * sde_plane_rot_calc_cfg - calculate rotator/sspp configuration by
  *	enumerating over all planes attached to the same rotator
  * @plane: Pointer to drm plane
@@ -2126,6 +2133,13 @@
 		}
 	}
 
+	if (new_pstate->defer_prepare_fb) {
+		SDE_DEBUG(
+		    "plane%d, domain not attached, prepare fb handled later\n",
+		    plane->base.id);
+		return 0;
+	}
+
 	/* prepare rotator input buffer */
 	ret = msm_framebuffer_prepare(new_state->fb, new_pstate->aspace);
 	if (ret) {
@@ -2395,6 +2409,7 @@
 	struct drm_plane_state *state;
 	struct sde_plane_state *pstate;
 	struct sde_plane_rot_state *rstate;
+	int ret = 0;
 
 	if (!plane || !plane->state) {
 		SDE_ERROR("invalid plane/state\n");
@@ -2416,24 +2431,57 @@
 	if (!rstate->out_sbuf || !rstate->rot_hw)
 		return;
 
+	/*
+	 * framebuffer prepare is deferred for prepare_fb calls that
+	 * happen during the transition from secure to non-secure.
+	 * Handle the prepare at this point for rotator in such cases.
+	 * This can be expected for one or two frames during the transition.
+	 */
+	if (pstate->aspace && pstate->defer_prepare_fb) {
+		/* prepare rotator input buffer */
+		ret = msm_framebuffer_prepare(state->fb, pstate->aspace);
+		if (ret) {
+			SDE_ERROR("p%d failed to prepare input fb %d\n",
+							plane->base.id, ret);
+			return;
+		}
+
+		/* prepare rotator output buffer */
+		if (sde_plane_enabled(state) && rstate->out_fb) {
+			ret = msm_framebuffer_prepare(rstate->out_fb,
+						pstate->aspace);
+			if (ret) {
+				SDE_ERROR(
+				  "p%d failed to prepare inline fb %d\n",
+				  plane->base.id, ret);
+				goto error_prepare_output_buffer;
+			}
+		}
+	}
+
 	sde_plane_rot_submit_command(plane, state, SDE_HW_ROT_CMD_COMMIT);
+
+	return;
+
+error_prepare_output_buffer:
+	msm_framebuffer_cleanup(state->fb, pstate->aspace);
 }
 
-void sde_plane_kickoff(struct drm_plane *plane)
+int sde_plane_kickoff_rot(struct drm_plane *plane)
 {
 	struct sde_plane_state *pstate;
 
 	if (!plane || !plane->state) {
 		SDE_ERROR("invalid plane\n");
-		return;
+		return -EINVAL;
 	}
 
 	pstate = to_sde_plane_state(plane->state);
 
 	if (!pstate->rot.rot_hw || !pstate->rot.rot_hw->ops.commit)
-		return;
+		return 0;
 
-	pstate->rot.rot_hw->ops.commit(pstate->rot.rot_hw,
+	return pstate->rot.rot_hw->ops.commit(pstate->rot.rot_hw,
 			&pstate->rot.rot_cmd,
 			SDE_HW_ROT_CMD_START);
 }
@@ -2747,7 +2795,7 @@
 		return;
 
 	*flush_rot = 0x0;
-	if (sde_plane_is_sbuf_mode(plane, NULL) && rstate->rot_hw &&
+	if (rstate && rstate->out_sbuf && rstate->rot_hw &&
 			ctl->ops.get_bitmask_rot)
 		ctl->ops.get_bitmask_rot(ctl, flush_rot, rstate->rot_hw->idx);
 }
@@ -2774,14 +2822,30 @@
 		return ret;
 	}
 
-	/*cache aspace */
+	/* cache aspace */
 	pstate->aspace = aspace;
+
+	/*
+	 * when transitioning from secure to non-secure,
+	 * plane->prepare_fb happens before the commit. In such case,
+	 * defer the prepare_fb and handled it late, during the commit
+	 * after attaching the domains as part of the transition
+	 */
+	pstate->defer_prepare_fb = (aspace && !aspace->domain_attached) ?
+							true : false;
+
 	ret = sde_plane_rot_prepare_fb(plane, new_state);
 	if (ret) {
 		SDE_ERROR("failed to prepare rot framebuffer\n");
 		return ret;
 	}
 
+	if (pstate->defer_prepare_fb) {
+		SDE_DEBUG_PLANE(psde,
+		    "domain not attached, prepare_fb handled later\n");
+		return 0;
+	}
+
 	new_rstate = &to_sde_plane_state(new_state)->rot;
 
 	if (pstate->aspace) {
@@ -3539,7 +3603,8 @@
 					SDE_FORMAT_IS_TILE(fmt);
 			cdp_cfg->preload_ahead = SDE_WB_CDP_PRELOAD_AHEAD_64;
 
-			psde->pipe_hw->ops.setup_cdp(psde->pipe_hw, cdp_cfg);
+			psde->pipe_hw->ops.setup_cdp(psde->pipe_hw, cdp_cfg,
+					pstate->multirect_index);
 		}
 
 		if (psde->pipe_hw->ops.setup_sys_cache) {
@@ -4061,51 +4126,11 @@
 			&pstate->property_state, PLANE_PROP_SCALER_V2);
 
 	/* populate from user space */
+	sde_set_scaler_v2(cfg, &scale_v2);
+
 	pe = &pstate->pixel_ext;
 	memset(pe, 0, sizeof(struct sde_hw_pixel_ext));
-	cfg->enable = scale_v2.enable;
-	cfg->dir_en = scale_v2.dir_en;
-	for (i = 0; i < SDE_MAX_PLANES; i++) {
-		cfg->init_phase_x[i] = scale_v2.init_phase_x[i];
-		cfg->phase_step_x[i] = scale_v2.phase_step_x[i];
-		cfg->init_phase_y[i] = scale_v2.init_phase_y[i];
-		cfg->phase_step_y[i] = scale_v2.phase_step_y[i];
 
-		cfg->preload_x[i] = scale_v2.preload_x[i];
-		cfg->preload_y[i] = scale_v2.preload_y[i];
-		cfg->src_width[i] = scale_v2.src_width[i];
-		cfg->src_height[i] = scale_v2.src_height[i];
-	}
-	cfg->dst_width = scale_v2.dst_width;
-	cfg->dst_height = scale_v2.dst_height;
-
-	cfg->y_rgb_filter_cfg = scale_v2.y_rgb_filter_cfg;
-	cfg->uv_filter_cfg = scale_v2.uv_filter_cfg;
-	cfg->alpha_filter_cfg = scale_v2.alpha_filter_cfg;
-	cfg->blend_cfg = scale_v2.blend_cfg;
-
-	cfg->lut_flag = scale_v2.lut_flag;
-	cfg->dir_lut_idx = scale_v2.dir_lut_idx;
-	cfg->y_rgb_cir_lut_idx = scale_v2.y_rgb_cir_lut_idx;
-	cfg->uv_cir_lut_idx = scale_v2.uv_cir_lut_idx;
-	cfg->y_rgb_sep_lut_idx = scale_v2.y_rgb_sep_lut_idx;
-	cfg->uv_sep_lut_idx = scale_v2.uv_sep_lut_idx;
-
-	cfg->de.enable = scale_v2.de.enable;
-	cfg->de.sharpen_level1 = scale_v2.de.sharpen_level1;
-	cfg->de.sharpen_level2 = scale_v2.de.sharpen_level2;
-	cfg->de.clip = scale_v2.de.clip;
-	cfg->de.limit = scale_v2.de.limit;
-	cfg->de.thr_quiet = scale_v2.de.thr_quiet;
-	cfg->de.thr_dieout = scale_v2.de.thr_dieout;
-	cfg->de.thr_low = scale_v2.de.thr_low;
-	cfg->de.thr_high = scale_v2.de.thr_high;
-	cfg->de.prec_shift = scale_v2.de.prec_shift;
-	for (i = 0; i < SDE_MAX_DE_CURVES; i++) {
-		cfg->de.adjust_a[i] = scale_v2.de.adjust_a[i];
-		cfg->de.adjust_b[i] = scale_v2.de.adjust_b[i];
-		cfg->de.adjust_c[i] = scale_v2.de.adjust_c[i];
-	}
 	for (i = 0; i < SDE_MAX_PLANES; i++) {
 		pe->left_ftch[i] = scale_v2.pe.left_ftch[i];
 		pe->right_ftch[i] = scale_v2.pe.right_ftch[i];
@@ -4362,6 +4387,11 @@
 	psde = to_sde_plane(plane);
 	SDE_DEBUG_PLANE(psde, "\n");
 
+	if (plane->state && !sde_crtc_is_reset_required(plane->state->crtc)) {
+		SDE_DEBUG_PLANE(psde, "avoid reset for plane\n");
+		return;
+	}
+
 	/* remove previous state, if present */
 	if (plane->state) {
 		sde_plane_destroy_state(plane, plane->state);
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.h b/drivers/gpu/drm/msm/sde/sde_plane.h
index 913647f..d6c5876 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.h
+++ b/drivers/gpu/drm/msm/sde/sde_plane.h
@@ -129,6 +129,7 @@
  * @multirect_index: index of the rectangle of SSPP
  * @multirect_mode: parallel or time multiplex multirect mode
  * @pending:	whether the current update is still pending
+ * @defer_prepare_fb:	indicate if prepare_fb call was deferred
  * @scaler3_cfg: configuration data for scaler3
  * @pixel_ext: configuration data for pixel extensions
  * @scaler_check_state: indicates status of user provided pixel extension data
@@ -146,6 +147,7 @@
 	uint32_t multirect_index;
 	uint32_t multirect_mode;
 	bool pending;
+	bool defer_prepare_fb;
 
 	/* scaler configuration */
 	struct sde_hw_scaler3_cfg scaler3_cfg;
@@ -207,12 +209,11 @@
 		u32 *flush_sspp, u32 *flush_rot);
 
 /**
- * sde_plane_is_sbuf_mode - return status of stream buffer mode
- * @plane:   Pointer to DRM plane object
- * @prefill: Pointer to updated prefill in stream buffer mode (optional)
- * Returns: true if plane is in stream buffer mode
+ * sde_plane_rot_calc_prefill - calculate rotator start prefill
+ * @plane: Pointer to drm plane
+ * return: prefill time in line
  */
-bool sde_plane_is_sbuf_mode(struct drm_plane *plane, u32 *prefill);
+u32 sde_plane_rot_calc_prefill(struct drm_plane *plane);
 
 /**
  * sde_plane_restore - restore hw state if previously power collapsed
@@ -227,10 +228,11 @@
 void sde_plane_flush(struct drm_plane *plane);
 
 /**
- * sde_plane_kickoff - final plane operations before commit kickoff
+ * sde_plane_kickoff_rot - final plane rotator operations before commit kickoff
  * @plane: Pointer to drm plane structure
+ * Returns: Zero on success
  */
-void sde_plane_kickoff(struct drm_plane *plane);
+int sde_plane_kickoff_rot(struct drm_plane *plane);
 
 /**
  * sde_plane_set_error: enable/disable error condition
diff --git a/drivers/gpu/drm/msm/sde/sde_reg_dma.c b/drivers/gpu/drm/msm/sde/sde_reg_dma.c
index cc87aeb..a52abd9 100644
--- a/drivers/gpu/drm/msm/sde/sde_reg_dma.c
+++ b/drivers/gpu/drm/msm/sde/sde_reg_dma.c
@@ -12,6 +12,7 @@
 
 #include "sde_reg_dma.h"
 #include "sde_hw_reg_dma_v1.h"
+#include "sde_dbg.h"
 
 static int default_check_support(enum sde_reg_dma_features feature,
 		     enum sde_reg_dma_blk blk,
diff --git a/drivers/gpu/drm/msm/sde/sde_rm.c b/drivers/gpu/drm/msm/sde/sde_rm.c
index be3a8af..ebcf9e0 100644
--- a/drivers/gpu/drm/msm/sde/sde_rm.c
+++ b/drivers/gpu/drm/msm/sde/sde_rm.c
@@ -18,6 +18,7 @@
 #include "sde_hw_ctl.h"
 #include "sde_hw_cdm.h"
 #include "sde_hw_dspp.h"
+#include "sde_hw_ds.h"
 #include "sde_hw_pingpong.h"
 #include "sde_hw_intf.h"
 #include "sde_hw_wb.h"
@@ -32,6 +33,7 @@
 #define RM_RQ_LOCK(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_RESERVE_LOCK))
 #define RM_RQ_CLEAR(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_RESERVE_CLEAR))
 #define RM_RQ_DSPP(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_DSPP))
+#define RM_RQ_DS(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_DS))
 #define RM_IS_TOPOLOGY_MATCH(t, r) ((t).num_lm == (r).num_lm && \
 				(t).num_comp_enc == (r).num_enc && \
 				(t).num_intf == (r).num_intf)
@@ -234,6 +236,9 @@
 	case SDE_HW_BLK_DSPP:
 		sde_hw_dspp_destroy(hw);
 		break;
+	case SDE_HW_BLK_DS:
+		sde_hw_ds_destroy(hw);
+		break;
 	case SDE_HW_BLK_CTL:
 		sde_hw_ctl_destroy(hw);
 		break;
@@ -304,7 +309,7 @@
 static int _sde_rm_hw_blk_create(
 		struct sde_rm *rm,
 		struct sde_mdss_cfg *cat,
-		void *mmio,
+		void __iomem *mmio,
 		enum sde_hw_blk_type type,
 		uint32_t id,
 		void *hw_catalog_info)
@@ -322,6 +327,9 @@
 	case SDE_HW_BLK_DSPP:
 		hw = sde_hw_dspp_init(id, mmio, cat);
 		break;
+	case SDE_HW_BLK_DS:
+		hw = sde_hw_ds_init(id, mmio, cat);
+		break;
 	case SDE_HW_BLK_CTL:
 		hw = sde_hw_ctl_init(id, mmio, cat);
 		break;
@@ -375,7 +383,7 @@
 
 int sde_rm_init(struct sde_rm *rm,
 		struct sde_mdss_cfg *cat,
-		void *mmio,
+		void __iomem *mmio,
 		struct drm_device *dev)
 {
 	int rc, i;
@@ -444,6 +452,17 @@
 		}
 	}
 
+	if (cat->mdp[0].has_dest_scaler) {
+		for (i = 0; i < cat->ds_count; i++) {
+			rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_DS,
+					cat->ds[i].id, &cat->ds[i]);
+			if (rc) {
+				SDE_ERROR("failed: ds hw not available\n");
+				goto fail;
+			}
+		}
+	}
+
 	for (i = 0; i < cat->pingpong_count; i++) {
 		rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_PINGPONG,
 				cat->pingpong[i].id, &cat->pingpong[i]);
@@ -543,18 +562,22 @@
 		struct sde_rm_requirements *reqs,
 		struct sde_rm_hw_blk *lm,
 		struct sde_rm_hw_blk **dspp,
+		struct sde_rm_hw_blk **ds,
 		struct sde_rm_hw_blk **pp,
 		struct sde_rm_hw_blk *primary_lm)
 {
 	const struct sde_lm_cfg *lm_cfg = to_sde_hw_mixer(lm->hw)->cap;
 	const struct sde_pingpong_cfg *pp_cfg;
 	struct sde_rm_hw_iter iter;
+	bool is_valid_dspp, is_valid_ds, ret;
 
 	*dspp = NULL;
+	*ds = NULL;
 	*pp = NULL;
 
-	SDE_DEBUG("check lm %d: dspp %d pp %d\n", lm_cfg->id, lm_cfg->dspp,
-			lm_cfg->pingpong);
+	SDE_DEBUG("check lm %d: dspp %d ds %d pp %d\n",
+			   lm_cfg->id, lm_cfg->dspp,
+			   lm_cfg->ds, lm_cfg->pingpong);
 
 	/* Check if this layer mixer is a peer of the proposed primary LM */
 	if (primary_lm) {
@@ -568,13 +591,28 @@
 		}
 	}
 
-	/* Matches user requirements? */
-	if ((RM_RQ_DSPP(reqs) && lm_cfg->dspp == DSPP_MAX) ||
-			(!RM_RQ_DSPP(reqs) && lm_cfg->dspp != DSPP_MAX)) {
-		SDE_DEBUG("dspp req mismatch lm %d reqdspp %d, lm->dspp %d\n",
-				lm_cfg->id, (bool)(RM_RQ_DSPP(reqs)),
-				lm_cfg->dspp);
-		return false;
+	is_valid_dspp = (lm_cfg->dspp != DSPP_MAX) ? true : false;
+	is_valid_ds = (lm_cfg->ds != DS_MAX) ? true : false;
+
+	/**
+	 * RM_RQ_X: specification of which LMs to choose
+	 * is_valid_X: indicates whether LM is tied with block X
+	 * ret: true if given LM matches the user requirement, false otherwise
+	 */
+	if (RM_RQ_DSPP(reqs) && RM_RQ_DS(reqs))
+		ret = (is_valid_dspp && is_valid_ds);
+	else if (RM_RQ_DSPP(reqs))
+		ret = is_valid_dspp;
+	else if (RM_RQ_DS(reqs))
+		ret = is_valid_ds;
+	else
+		ret = !(is_valid_dspp || is_valid_ds);
+
+	if (!ret) {
+		SDE_DEBUG("fail:lm(%d)req_dspp(%d)dspp(%d)req_ds(%d)ds(%d)\n",
+			lm_cfg->id, (bool)(RM_RQ_DSPP(reqs)), lm_cfg->dspp,
+			(bool)(RM_RQ_DS(reqs)), lm_cfg->ds);
+		return ret;
 	}
 
 	/* Already reserved? */
@@ -605,6 +643,28 @@
 		}
 	}
 
+	if (lm_cfg->ds != DS_MAX) {
+		sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_DS);
+		while (_sde_rm_get_hw_locked(rm, &iter)) {
+			if (iter.blk->id == lm_cfg->ds) {
+				*ds = iter.blk;
+				break;
+			}
+		}
+
+		if (!*ds) {
+			SDE_DEBUG("lm %d failed to retrieve ds %d\n", lm->id,
+					lm_cfg->ds);
+			return false;
+		}
+
+		if (RESERVED_BY_OTHER(*ds, rsvp)) {
+			SDE_DEBUG("lm %d ds %d already reserved\n",
+					lm->id, (*ds)->id);
+			return false;
+		}
+	}
+
 	sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_PINGPONG);
 	while (_sde_rm_get_hw_locked(rm, &iter)) {
 		if (iter.blk->id == lm_cfg->pingpong) {
@@ -622,6 +682,7 @@
 		SDE_DEBUG("lm %d pp %d already reserved\n", lm->id,
 				(*pp)->id);
 		*dspp = NULL;
+		*ds = NULL;
 		return false;
 	}
 
@@ -630,6 +691,7 @@
 			!(test_bit(SDE_PINGPONG_SPLIT, &pp_cfg->features))) {
 		SDE_DEBUG("pp %d doesn't support ppsplit\n", pp_cfg->id);
 		*dspp = NULL;
+		*ds = NULL;
 		return false;
 	}
 
@@ -644,6 +706,7 @@
 {
 	struct sde_rm_hw_blk *lm[MAX_BLOCKS];
 	struct sde_rm_hw_blk *dspp[MAX_BLOCKS];
+	struct sde_rm_hw_blk *ds[MAX_BLOCKS];
 	struct sde_rm_hw_blk *pp[MAX_BLOCKS];
 	struct sde_rm_hw_iter iter_i, iter_j;
 	int lm_count = 0;
@@ -660,14 +723,16 @@
 			_sde_rm_get_hw_locked(rm, &iter_i)) {
 		memset(&lm, 0, sizeof(lm));
 		memset(&dspp, 0, sizeof(dspp));
+		memset(&ds, 0, sizeof(ds));
 		memset(&pp, 0, sizeof(pp));
 
 		lm_count = 0;
 		lm[lm_count] = iter_i.blk;
 
-		if (!_sde_rm_check_lm_and_get_connected_blks(rm, rsvp, reqs,
-				lm[lm_count], &dspp[lm_count], &pp[lm_count],
-				NULL))
+		if (!_sde_rm_check_lm_and_get_connected_blks(
+				rm, rsvp, reqs, lm[lm_count],
+				&dspp[lm_count], &ds[lm_count],
+				&pp[lm_count], NULL))
 			continue;
 
 		++lm_count;
@@ -680,8 +745,9 @@
 			if (iter_i.blk == iter_j.blk)
 				continue;
 
-			if (!_sde_rm_check_lm_and_get_connected_blks(rm, rsvp,
-					reqs, iter_j.blk, &dspp[lm_count],
+			if (!_sde_rm_check_lm_and_get_connected_blks(
+					rm, rsvp, reqs, iter_j.blk,
+					&dspp[lm_count], &ds[lm_count],
 					&pp[lm_count], iter_i.blk))
 				continue;
 
@@ -704,8 +770,12 @@
 		if (dspp[i])
 			dspp[i]->rsvp_nxt = rsvp;
 
+		if (ds[i])
+			ds[i]->rsvp_nxt = rsvp;
+
 		SDE_EVT32(lm[i]->type, rsvp->enc_id, lm[i]->id, pp[i]->id,
-				dspp[i] ? dspp[i]->id : 0);
+				dspp[i] ? dspp[i]->id : 0,
+				ds[i] ? ds[i]->id : 0);
 	}
 
 	if (reqs->topology->top_name == SDE_RM_TOPOLOGY_PPSPLIT) {
@@ -1018,6 +1088,15 @@
 	if (reqs->topology->num_comp_enc)
 		reqs->top_ctrl |= BIT(SDE_RM_TOPCTL_DSPP);
 
+	/**
+	 * Set the requirement based on caps if not set from user space
+	 * This will ensure to select LM tied with DS blocks
+	 * Currently, DS blocks are tied with LM 0 and LM 1 (primary display)
+	 */
+	if (!RM_RQ_DS(reqs) && rm->hw_mdp->caps->has_dest_scaler &&
+		conn_state->connector->connector_type == DRM_MODE_CONNECTOR_DSI)
+		reqs->top_ctrl |= BIT(SDE_RM_TOPCTL_DS);
+
 	SDE_DEBUG("top_ctrl: 0x%llX num_h_tiles: %d\n", reqs->top_ctrl,
 			reqs->hw_res.display_num_of_h_tiles);
 	SDE_DEBUG("num_lm: %d num_ctl: %d topology: %d split_display: %d\n",
diff --git a/drivers/gpu/drm/msm/sde/sde_rm.h b/drivers/gpu/drm/msm/sde/sde_rm.h
index b4a801a..1e48855 100644
--- a/drivers/gpu/drm/msm/sde/sde_rm.h
+++ b/drivers/gpu/drm/msm/sde/sde_rm.h
@@ -56,11 +56,13 @@
  *                               Normal behavior would not impact the
  *                               reservation list during the AtomicTest phase.
  * @SDE_RM_TOPCTL_DSPP: Require layer mixers with DSPP capabilities
+ * @SDE_RM_TOPCTL_DS  : Require layer mixers with DS capabilities
  */
 enum sde_rm_topology_control {
 	SDE_RM_TOPCTL_RESERVE_LOCK,
 	SDE_RM_TOPCTL_RESERVE_CLEAR,
 	SDE_RM_TOPCTL_DSPP,
+	SDE_RM_TOPCTL_DS,
 };
 
 /**
diff --git a/drivers/gpu/drm/msm/sde_dbg.c b/drivers/gpu/drm/msm/sde_dbg.c
index 7e58c2f..dc16ab1 100644
--- a/drivers/gpu/drm/msm/sde_dbg.c
+++ b/drivers/gpu/drm/msm/sde_dbg.c
@@ -44,6 +44,7 @@
 
 /* offsets from sde top address for the debug buses */
 #define DBGBUS_SSPP0	0x188
+#define DBGBUS_AXI_INTF	0x194
 #define DBGBUS_SSPP1	0x298
 #define DBGBUS_DSPP	0x348
 #define DBGBUS_PERIPH	0x418
@@ -66,6 +67,7 @@
 /* print debug ranges in groups of 4 u32s */
 #define REG_DUMP_ALIGN		16
 
+#define RSC_DEBUG_MUX_SEL_SDM845 9
 /**
  * struct sde_dbg_reg_offset - tracking for start and end of region
  * @start: start offset
@@ -128,7 +130,8 @@
 	u32 wr_addr;
 	u32 block_id;
 	u32 test_id;
-	void (*analyzer)(struct sde_debug_bus_entry *entry, u32 val);
+	void (*analyzer)(void __iomem *mem_base,
+				struct sde_debug_bus_entry *entry, u32 val);
 };
 
 struct vbif_debug_bus_entry {
@@ -174,6 +177,7 @@
  * @dbgbus_sde: debug bus structure for the sde
  * @dbgbus_vbif_rt: debug bus structure for the realtime vbif
  * @dump_all: dump all entries in register dump
+ * @dsi_dbg_bus: dump dsi debug bus register
  */
 static struct sde_dbg_base {
 	struct sde_dbg_evtlog *evtlog;
@@ -191,20 +195,21 @@
 	struct sde_dbg_sde_debug_bus dbgbus_sde;
 	struct sde_dbg_vbif_debug_bus dbgbus_vbif_rt;
 	bool dump_all;
+	bool dsi_dbg_bus;
 } sde_dbg_base;
 
 /* sde_dbg_base_evtlog - global pointer to main sde event log for macro use */
 struct sde_dbg_evtlog *sde_dbg_base_evtlog;
 
-static void _sde_debug_bus_xbar_dump(struct sde_debug_bus_entry *entry,
-		u32 val)
+static void _sde_debug_bus_xbar_dump(void __iomem *mem_base,
+		struct sde_debug_bus_entry *entry, u32 val)
 {
 	dev_err(sde_dbg_base.dev, "xbar 0x%x %d %d 0x%x\n",
 			entry->wr_addr, entry->block_id, entry->test_id, val);
 }
 
-static void _sde_debug_bus_lm_dump(struct sde_debug_bus_entry *entry,
-		u32 val)
+static void _sde_debug_bus_lm_dump(void __iomem *mem_base,
+		struct sde_debug_bus_entry *entry, u32 val)
 {
 	if (!(val & 0xFFF000))
 		return;
@@ -213,8 +218,8 @@
 			entry->wr_addr, entry->block_id, entry->test_id, val);
 }
 
-static void _sde_debug_bus_ppb0_dump(struct sde_debug_bus_entry *entry,
-		u32 val)
+static void _sde_debug_bus_ppb0_dump(void __iomem *mem_base,
+		struct sde_debug_bus_entry *entry, u32 val)
 {
 	if (!(val & BIT(15)))
 		return;
@@ -223,8 +228,8 @@
 			entry->wr_addr, entry->block_id, entry->test_id, val);
 }
 
-static void _sde_debug_bus_ppb1_dump(struct sde_debug_bus_entry *entry,
-		u32 val)
+static void _sde_debug_bus_ppb1_dump(void __iomem *mem_base,
+		struct sde_debug_bus_entry *entry, u32 val)
 {
 	if (!(val & BIT(15)))
 		return;
@@ -233,6 +238,29 @@
 			entry->wr_addr, entry->block_id, entry->test_id, val);
 }
 
+static void _sde_debug_bus_axi_dump_sdm845(void __iomem *mem_base,
+		struct sde_debug_bus_entry *entry, u32 val)
+{
+	u32 status, i;
+
+	if (!mem_base || !entry)
+		return;
+
+	for (i = 0; i <= RSC_DEBUG_MUX_SEL_SDM845; i++) {
+		sde_rsc_debug_dump(i);
+
+		/* make sure that mux_sel updated */
+		wmb();
+
+		/* read status again after rsc routes the debug bus */
+		status = readl_relaxed(mem_base + DBGBUS_DSPP_STATUS);
+
+		dev_err(sde_dbg_base.dev, "rsc mux_sel:%d 0x%x %d %d 0x%x\n",
+			i, entry->wr_addr, entry->block_id,
+			entry->test_id, status);
+	}
+}
+
 static struct sde_debug_bus_entry dbg_bus_sde_8998[] = {
 
 	/* Unpack 0 sspp 0*/
@@ -1986,6 +2014,9 @@
 	{ DBGBUS_PERIPH, 71, 3},
 	{ DBGBUS_PERIPH, 71, 4},
 	{ DBGBUS_PERIPH, 71, 5},
+
+	/* axi - should be last entry */
+	{ DBGBUS_AXI_INTF, 62, 0, _sde_debug_bus_axi_dump_sdm845},
 };
 
 static struct vbif_debug_bus_entry vbif_dbg_bus_msm8998[] = {
@@ -2332,7 +2363,7 @@
 		}
 
 		if (head->analyzer)
-			head->analyzer(head, status);
+			head->analyzer(mem_base, head, status);
 
 		/* Disable debug bus once we are done */
 		writel_relaxed(0, mem_base + head->wr_addr);
@@ -2541,6 +2572,9 @@
 	if (dump_dbgbus_vbif_rt)
 		_sde_dbg_dump_vbif_dbg_bus(&sde_dbg_base.dbgbus_vbif_rt);
 
+	if (sde_dbg_base.dsi_dbg_bus || dump_all)
+		dsi_ctrl_debug_dump();
+
 	if (do_panic && sde_dbg_base.panic_on_err)
 		panic(name);
 }
@@ -2615,6 +2649,9 @@
 		if (!strcmp(blk_name, "vbif_dbg_bus"))
 			dump_dbgbus_vbif_rt = true;
 
+		if (!strcmp(blk_name, "dsi_dbg_bus"))
+			sde_dbg_base.dsi_dbg_bus = true;
+
 		if (!strcmp(blk_name, "panic"))
 			do_panic = true;
 	}
@@ -2627,6 +2664,7 @@
 				dump_dbgbus_sde;
 		sde_dbg_base.dbgbus_vbif_rt.cmn.include_in_deferred_work =
 				dump_dbgbus_vbif_rt;
+		sde_dbg_base.dump_all = dump_all;
 		schedule_work(&sde_dbg_base.dump_work);
 	} else {
 		_sde_dump_array(blk_arr, blk_len, do_panic, name,
@@ -3067,9 +3105,7 @@
 	memset(&dbg->dbgbus_sde, 0, sizeof(dbg->dbgbus_sde));
 	memset(&dbg->dbgbus_vbif_rt, 0, sizeof(dbg->dbgbus_vbif_rt));
 
-	switch (hwversion) {
-	case SDE_HW_VER_300:
-	case SDE_HW_VER_301:
+	if (IS_MSM8998_TARGET(hwversion)) {
 		dbg->dbgbus_sde.entries = dbg_bus_sde_8998;
 		dbg->dbgbus_sde.cmn.entries_size = ARRAY_SIZE(dbg_bus_sde_8998);
 		dbg->dbgbus_sde.cmn.flags = DBGBUS_FLAGS_DSPP;
@@ -3077,9 +3113,7 @@
 		dbg->dbgbus_vbif_rt.entries = vbif_dbg_bus_msm8998;
 		dbg->dbgbus_vbif_rt.cmn.entries_size =
 				ARRAY_SIZE(vbif_dbg_bus_msm8998);
-		break;
-
-	case SDE_HW_VER_400:
+	} else if (IS_SDM845_TARGET(hwversion) || IS_SDM670_TARGET(hwversion)) {
 		dbg->dbgbus_sde.entries = dbg_bus_sde_sdm845;
 		dbg->dbgbus_sde.cmn.entries_size =
 				ARRAY_SIZE(dbg_bus_sde_sdm845);
@@ -3089,10 +3123,8 @@
 		dbg->dbgbus_vbif_rt.entries = vbif_dbg_bus_msm8998;
 		dbg->dbgbus_vbif_rt.cmn.entries_size =
 				ARRAY_SIZE(vbif_dbg_bus_msm8998);
-		break;
-	default:
-		pr_err("unsupported chipset id %u\n", hwversion);
-		break;
+	} else {
+		pr_err("unsupported chipset id %X\n", hwversion);
 	}
 }
 
diff --git a/drivers/gpu/drm/msm/sde_dbg.h b/drivers/gpu/drm/msm/sde_dbg.h
index a266574..786451c3 100644
--- a/drivers/gpu/drm/msm/sde_dbg.h
+++ b/drivers/gpu/drm/msm/sde_dbg.h
@@ -315,6 +315,17 @@
 int sde_evtlog_get_filter(struct sde_dbg_evtlog *evtlog, int index,
 		char *buf, size_t bufsz);
 
+/**
+ * sde_rsc_debug_dump - sde rsc debug dump status
+ * @mux_sel:	select mux on rsc debug bus
+ */
+void sde_rsc_debug_dump(u32 mux_sel);
+
+/**
+ * dsi_ctrl_debug_dump - dump dsi debug dump status
+ */
+void dsi_ctrl_debug_dump(void);
+
 #else
 static inline struct sde_dbg_evtlog *sde_evtlog_init(void)
 {
@@ -396,6 +407,14 @@
 	return -EINVAL;
 }
 
+static inline void sde_rsc_debug_dump(u32 mux_sel)
+{
+}
+
+static inline void dsi_ctrl_debug_dump(void)
+{
+}
+
 #endif /* defined(CONFIG_DEBUG_FS) */
 
 
diff --git a/drivers/gpu/drm/msm/sde_edid_parser.c b/drivers/gpu/drm/msm/sde_edid_parser.c
index 3d6c2ea..791a6ca 100644
--- a/drivers/gpu/drm/msm/sde_edid_parser.c
+++ b/drivers/gpu/drm/msm/sde_edid_parser.c
@@ -605,6 +605,30 @@
 	}
 }
 
+u8 sde_get_edid_checksum(void *input)
+{
+	struct sde_edid_ctrl *edid_ctrl = (struct sde_edid_ctrl *)(input);
+	struct edid *edid = NULL, *last_block = NULL;
+	u8 *raw_edid = NULL;
+
+	if (!edid_ctrl || !edid_ctrl->edid) {
+		SDE_ERROR("invalid edid input\n");
+		return 0;
+	}
+
+	edid = edid_ctrl->edid;
+
+	raw_edid = (u8 *)edid;
+	raw_edid += (edid->extensions * EDID_LENGTH);
+	last_block = (struct edid *)raw_edid;
+
+	if (last_block)
+		return last_block->checksum;
+
+	SDE_ERROR("Invalid block, no checksum\n");
+	return 0;
+}
+
 bool sde_detect_hdmi_monitor(void *input)
 {
 	struct sde_edid_ctrl *edid_ctrl = (struct sde_edid_ctrl *)(input);
diff --git a/drivers/gpu/drm/msm/sde_edid_parser.h b/drivers/gpu/drm/msm/sde_edid_parser.h
index b58b322..07bdf50 100644
--- a/drivers/gpu/drm/msm/sde_edid_parser.h
+++ b/drivers/gpu/drm/msm/sde_edid_parser.h
@@ -146,6 +146,14 @@
 u32 sde_get_sink_bpc(void *edid_ctrl);
 
 /**
+ * sde_get_edid_checksum() - return the checksum of last block of EDID.
+ * @input:     Handle to the edid_ctrl structure.
+ *
+ * Return: checksum of the last EDID block.
+ */
+u8 sde_get_edid_checksum(void *input);
+
+/**
  * _sde_edid_update_modes() - populate EDID modes.
  * @edid_ctrl:     Handle to the edid_ctrl structure.
  *
diff --git a/drivers/gpu/drm/msm/sde_hdcp_1x.c b/drivers/gpu/drm/msm/sde_hdcp_1x.c
index 7951c23..3673d125 100644
--- a/drivers/gpu/drm/msm/sde_hdcp_1x.c
+++ b/drivers/gpu/drm/msm/sde_hdcp_1x.c
@@ -363,12 +363,15 @@
 			if (bytes_read != read_size) {
 				pr_err("fail: offset(0x%x), size(0x%x), rc(0x%x)\n",
 					offset, read_size, bytes_read);
+				rc = -EIO;
 				break;
 			}
 
 			buf += read_size;
-			offset += read_size;
 			size -= read_size;
+
+			if (!realign)
+				offset += read_size;
 		} while (size > 0);
 	}
 
@@ -393,6 +396,7 @@
 			if (bytes_written != write_size) {
 				pr_err("fail: offset(0x%x), size(0x%x), rc(0x%x)\n",
 					offset, write_size, bytes_written);
+				rc = -EIO;
 				break;
 			}
 
diff --git a/drivers/gpu/drm/msm/sde_rsc.c b/drivers/gpu/drm/msm/sde_rsc.c
index b654b26..82b1199 100644
--- a/drivers/gpu/drm/msm/sde_rsc.c
+++ b/drivers/gpu/drm/msm/sde_rsc.c
@@ -456,7 +456,7 @@
 	} else if (rsc->hw_ops.state_update) {
 		rc = rsc->hw_ops.state_update(rsc, SDE_RSC_IDLE_STATE);
 		if (!rc)
-			rpmh_mode_solver_set(rsc->disp_rsc, false);
+			rpmh_mode_solver_set(rsc->disp_rsc, true);
 	}
 
 	return rc;
@@ -837,6 +837,21 @@
 }
 EXPORT_SYMBOL(sde_rsc_client_vote);
 
+#if defined(CONFIG_DEBUG_FS)
+void sde_rsc_debug_dump(u32 mux_sel)
+{
+	struct sde_rsc_priv *rsc;
+
+	rsc = rsc_prv_list[SDE_RSC_INDEX];
+	if (!rsc)
+		return;
+
+	/* this must be called with rsc clocks enabled */
+	if (rsc->hw_ops.debug_dump)
+		rsc->hw_ops.debug_dump(rsc, mux_sel);
+}
+#endif /* defined(CONFIG_DEBUG_FS) */
+
 static int _sde_debugfs_status_show(struct seq_file *s, void *data)
 {
 	struct sde_rsc_priv *rsc;
diff --git a/drivers/gpu/drm/msm/sde_rsc_hw.c b/drivers/gpu/drm/msm/sde_rsc_hw.c
index b474d21..e957779 100644
--- a/drivers/gpu/drm/msm/sde_rsc_hw.c
+++ b/drivers/gpu/drm/msm/sde_rsc_hw.c
@@ -515,7 +515,7 @@
 		reg = dss_reg_r(&rsc->wrapper_io,
 			SDE_RSCC_WRAPPER_OVERRIDE_CTRL, rsc->debug_mode);
 		reg |= (BIT(0) | BIT(8));
-		reg &= ~(BIT(1) | BIT(2) | BIT(3) | BIT(6) | BIT(7));
+		reg &= ~(BIT(1) | BIT(2) | BIT(3) | BIT(6) | BIT(7) | BIT(9));
 		dss_reg_w(&rsc->wrapper_io, SDE_RSCC_WRAPPER_OVERRIDE_CTRL,
 							reg, rsc->debug_mode);
 		/* make sure that solver is enabled */
@@ -746,6 +746,12 @@
 	return blen;
 }
 
+static void rsc_hw_debug_dump(struct sde_rsc_priv *rsc, u32 mux_sel)
+{
+	dss_reg_w(&rsc->wrapper_io, SDE_RSCC_WRAPPER_DEBUG_BUS,
+		((mux_sel & 0xf) << 1) | BIT(0), rsc->debug_mode);
+}
+
 bool rsc_hw_is_amc_mode(struct sde_rsc_priv *rsc)
 {
 	return dss_reg_r(&rsc->drv_io, SDE_RSCC_TCS_DRV0_CONTROL,
@@ -806,6 +812,7 @@
 	rsc->hw_ops.state_update = sde_rsc_state_update;
 	rsc->hw_ops.debug_show = sde_rsc_debug_show;
 	rsc->hw_ops.mode_ctrl = rsc_hw_mode_ctrl;
+	rsc->hw_ops.debug_dump = rsc_hw_debug_dump;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/msm/sde_rsc_priv.h b/drivers/gpu/drm/msm/sde_rsc_priv.h
index c96ce75..64b0216 100644
--- a/drivers/gpu/drm/msm/sde_rsc_priv.h
+++ b/drivers/gpu/drm/msm/sde_rsc_priv.h
@@ -73,6 +73,7 @@
  * @hw_vsync:			Enables the vsync on RSC block.
  * @tcs_use_ok:			set TCS set to high to allow RSC to use it.
  * @is_amc_mode:		Check current amc mode status
+ * @debug_dump:			dump debug bus registers or enable debug bus
  * @state_update:		Enable/override the solver based on rsc state
  *                              status (command/video)
  * @mode_show:			shows current mode status, mode0/1/2
@@ -87,6 +88,7 @@
 		char *buffer, int buffer_size, u32 mode);
 	int (*tcs_use_ok)(struct sde_rsc_priv *rsc);
 	bool (*is_amc_mode)(struct sde_rsc_priv *rsc);
+	void (*debug_dump)(struct sde_rsc_priv *rsc, u32 mux_sel);
 	int (*state_update)(struct sde_rsc_priv *rsc, enum sde_rsc_state state);
 	int (*debug_show)(struct seq_file *s, struct sde_rsc_priv *rsc);
 	int (*mode_ctrl)(struct sde_rsc_priv *rsc, enum rsc_mode_req request,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
index 1e1de6b..5893be9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
@@ -27,7 +27,7 @@
 		u8 type[3];
 	} pior;
 
-	struct nv50_disp_chan *chan[17];
+	struct nv50_disp_chan *chan[21];
 };
 
 int nv50_disp_root_scanoutpos(NV50_DISP_MTHD_V0);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
index c794b2c..6d8f212 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
@@ -129,7 +129,7 @@
 
 	if (bar->bar[0].mem) {
 		addr = nvkm_memory_addr(bar->bar[0].mem) >> 12;
-		nvkm_wr32(device, 0x001714, 0xc0000000 | addr);
+		nvkm_wr32(device, 0x001714, 0x80000000 | addr);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
index eb9b278..a4cb824 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
@@ -192,6 +192,10 @@
 		}
 	}
 
+#ifdef __BIG_ENDIAN
+	pci->msi = false;
+#endif
+
 	pci->msi = nvkm_boolopt(device->cfgopt, "NvMSI", pci->msi);
 	if (pci->msi && func->msi_rearm) {
 		pci->msi = pci_enable_msi(pci->pdev) == 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 7316fc7..a2ec6d8 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -149,8 +149,8 @@
 	rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? OTAR2 : OTAR, 0);
 
 	/* Signal polarities */
-	value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
-	      | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL)
+	value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? DSMR_VSL : 0)
+	      | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? DSMR_HSL : 0)
 	      | DSMR_DIPM_DISP | DSMR_CSPM;
 	rcar_du_crtc_write(rcrtc, DSMR, value);
 
@@ -172,7 +172,7 @@
 					mode->crtc_vsync_start - 1);
 	rcar_du_crtc_write(rcrtc, VCR,  mode->crtc_vtotal - 1);
 
-	rcar_du_crtc_write(rcrtc, DESR,  mode->htotal - mode->hsync_start);
+	rcar_du_crtc_write(rcrtc, DESR,  mode->htotal - mode->hsync_start - 1);
 	rcar_du_crtc_write(rcrtc, DEWR,  mode->hdisplay);
 }
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 73c971e..ae125d0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -285,7 +285,6 @@
 
 	drm_kms_helper_poll_fini(ddev);
 	drm_mode_config_cleanup(ddev);
-	drm_vblank_cleanup(ddev);
 
 	drm_dev_unref(ddev);
 
@@ -305,7 +304,7 @@
 		return -ENODEV;
 	}
 
-	/* Allocate and initialize the DRM and R-Car device structures. */
+	/* Allocate and initialize the R-Car device structure. */
 	rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
 	if (rcdu == NULL)
 		return -ENOMEM;
@@ -315,6 +314,15 @@
 	rcdu->dev = &pdev->dev;
 	rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
 
+	platform_set_drvdata(pdev, rcdu);
+
+	/* I/O resources */
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(rcdu->mmio))
+		return PTR_ERR(rcdu->mmio);
+
+	/* DRM/KMS objects */
 	ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev);
 	if (IS_ERR(ddev))
 		return PTR_ERR(ddev);
@@ -322,24 +330,6 @@
 	rcdu->ddev = ddev;
 	ddev->dev_private = rcdu;
 
-	platform_set_drvdata(pdev, rcdu);
-
-	/* I/O resources */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
-	if (IS_ERR(rcdu->mmio)) {
-		ret = PTR_ERR(rcdu->mmio);
-		goto error;
-	}
-
-	/* Initialize vertical blanking interrupts handling. Start with vblank
-	 * disabled for all CRTCs.
-	 */
-	ret = drm_vblank_init(ddev, (1 << rcdu->info->num_crtcs) - 1);
-	if (ret < 0)
-		goto error;
-
-	/* DRM/KMS objects */
 	ret = rcar_du_modeset_init(rcdu);
 	if (ret < 0) {
 		if (ret != -EPROBE_DEFER)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 392c7e6..c58602b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -453,13 +453,13 @@
 	}
 
 	ret = rcar_du_encoder_init(rcdu, enc_type, output, encoder, connector);
-	of_node_put(encoder);
-	of_node_put(connector);
-
 	if (ret && ret != -EPROBE_DEFER)
 		dev_warn(rcdu->dev,
-			 "failed to initialize encoder %s (%d), skipping\n",
-			 encoder->full_name, ret);
+			 "failed to initialize encoder %s on output %u (%d), skipping\n",
+			 of_node_full_name(encoder), output, ret);
+
+	of_node_put(encoder);
+	of_node_put(connector);
 
 	return ret;
 }
@@ -567,6 +567,13 @@
 	if (ret < 0)
 		return ret;
 
+	/* Initialize vertical blanking interrupts handling. Start with vblank
+	 * disabled for all CRTCs.
+	 */
+	ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
+	if (ret < 0)
+		return ret;
+
 	/* Initialize the groups. */
 	num_groups = DIV_ROUND_UP(rcdu->num_crtcs, 2);
 
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index a37de5d..ddd6badd 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -612,7 +612,7 @@
 		} else {
 			pr_err("Failed to fill pool (%p)\n", pool);
 			/* If we have any pages left put them to the pool. */
-			list_for_each_entry(p, &pool->list, lru) {
+			list_for_each_entry(p, &new_pages, lru) {
 				++cpages;
 			}
 			list_splice(&new_pages, &pool->list);
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index 2242a80..dc2976c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -337,7 +337,7 @@
 	info->fbops = &virtio_gpufb_ops;
 	info->pixmap.flags = FB_PIXMAP_SYSTEM;
 
-	info->screen_base = obj->vmap;
+	info->screen_buffer = obj->vmap;
 	info->screen_size = obj->gem_base.size;
 	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
 	drm_fb_helper_fill_var(info, &vfbdev->helper,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index c7b53d9..fefb9d9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -519,7 +519,7 @@
 			   struct vmw_sw_context *sw_context,
 			   SVGA3dCmdHeader *header)
 {
-	return capable(CAP_SYS_ADMIN) ? : -EINVAL;
+	return -EINVAL;
 }
 
 static int vmw_cmd_ok(struct vmw_private *dev_priv,
diff --git a/drivers/gpu/msm/a6xx_reg.h b/drivers/gpu/msm/a6xx_reg.h
index 41b64cdc..c2eb9ea 100644
--- a/drivers/gpu/msm/a6xx_reg.h
+++ b/drivers/gpu/msm/a6xx_reg.h
@@ -764,6 +764,29 @@
 #define A6XX_VBIF_PERF_PWR_CNT_HIGH1            0x3119
 #define A6XX_VBIF_PERF_PWR_CNT_HIGH2            0x311a
 
+/* GBIF registers */
+#define A6XX_GBIF_HALT                    0x3c45
+#define A6XX_GBIF_HALT_ACK                0x3c46
+#define A6XX_GBIF_HALT_MASK               0x1
+
+#define A6XX_GBIF_PERF_PWR_CNT_EN         0x3cc0
+#define A6XX_GBIF_PERF_CNT_SEL            0x3cc2
+#define A6XX_GBIF_PERF_CNT_LOW0           0x3cc4
+#define A6XX_GBIF_PERF_CNT_LOW1           0x3cc5
+#define A6XX_GBIF_PERF_CNT_LOW2           0x3cc6
+#define A6XX_GBIF_PERF_CNT_LOW3           0x3cc7
+#define A6XX_GBIF_PERF_CNT_HIGH0          0x3cc8
+#define A6XX_GBIF_PERF_CNT_HIGH1          0x3cc9
+#define A6XX_GBIF_PERF_CNT_HIGH2          0x3cca
+#define A6XX_GBIF_PERF_CNT_HIGH3          0x3ccb
+#define A6XX_GBIF_PWR_CNT_LOW0            0x3ccc
+#define A6XX_GBIF_PWR_CNT_LOW1            0x3ccd
+#define A6XX_GBIF_PWR_CNT_LOW2            0x3cce
+#define A6XX_GBIF_PWR_CNT_HIGH0           0x3ccf
+#define A6XX_GBIF_PWR_CNT_HIGH1           0x3cd0
+#define A6XX_GBIF_PWR_CNT_HIGH2           0x3cd1
+
+
 /* CX_DBGC_CFG registers */
 #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_A                   0x18400
 #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_B                   0x18401
@@ -935,6 +958,7 @@
 #define A6XX_GMU_AO_SPARE_CNTL			0x23B16
 
 /* GMU RSC control registers */
+#define A6XX_GPU_RSCC_RSC_STATUS0_DRV0		0x23404
 #define A6XX_GMU_RSCC_CONTROL_REQ		0x23B07
 #define A6XX_GMU_RSCC_CONTROL_ACK		0x23B08
 
@@ -965,10 +989,6 @@
 #define A6XX_RSCC_TCS2_DRV0_STATUS                      0x23A16
 #define A6XX_RSCC_TCS3_DRV0_STATUS                      0x23B7E
 
-
-/* CPR controller */
-#define A6XX_GPU_CPR_FSM_CTL				0x26801
-
 /* GPU PDC sequencer registers in AOSS.RPMh domain */
 #define	PDC_GPU_ENABLE_PDC			0x21140
 #define PDC_GPU_SEQ_START_ADDR			0x21148
@@ -986,7 +1006,5 @@
 #define PDC_GPU_TCS1_CMD0_DATA			0x21577
 #define PDC_GPU_SEQ_MEM_0			0xA0000
 
-/* GFX rail CPR registers in AOSS.CPR domain */
-#define CPR_CPRF_CPRF5_CTRL			0x1801
 #endif /* _A6XX_REG_H */
 
diff --git a/drivers/gpu/msm/adreno-gpulist.h b/drivers/gpu/msm/adreno-gpulist.h
index 7dda62a..b451750 100644
--- a/drivers/gpu/msm/adreno-gpulist.h
+++ b/drivers/gpu/msm/adreno-gpulist.h
@@ -346,7 +346,8 @@
 		.major = 1,
 		.minor = 5,
 		.patchid = ANY_ID,
-		.features = ADRENO_64BIT | ADRENO_RPMH,
+		.features = ADRENO_64BIT | ADRENO_RPMH |
+			ADRENO_GPMU | ADRENO_CONTENT_PROTECTION,
 		.sqefw_name = "a630_sqe.fw",
 		.zap_name = "a615_zap",
 		.gpudev = &adreno_a6xx_gpudev,
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 2dae758..844142a 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -554,7 +554,13 @@
 	return 0;
 }
 
-
+/**
+ * adreno_irqctrl() - Enables/disables the RBBM interrupt mask
+ * @adreno_dev: Pointer to an adreno_device
+ * @state: 1 for masked or 0 for unmasked
+ * Power: The caller of this function must make sure to use OOBs
+ * so that we know that the GPU is powered on
+ */
 void adreno_irqctrl(struct adreno_device *adreno_dev, int state)
 {
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
@@ -599,7 +605,7 @@
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
 	struct adreno_irq *irq_params = gpudev->irq;
 	irqreturn_t ret = IRQ_NONE;
-	unsigned int status = 0, tmp, int_bit;
+	unsigned int status = 0, fence = 0, tmp, int_bit;
 	int i;
 
 	atomic_inc(&adreno_dev->pending_irq_refcnt);
@@ -614,6 +620,17 @@
 	if (gpudev->gpu_keepalive)
 		gpudev->gpu_keepalive(adreno_dev, true);
 
+	/*
+	 * If the AHB fence is not in ALLOW mode when we receive an RBBM
+	 * interrupt, something went wrong. Set a fault and change the
+	 * fence to ALLOW so we can clear the interrupt.
+	 */
+	adreno_readreg(adreno_dev, ADRENO_REG_GMU_AO_AHB_FENCE_CTRL, &fence);
+	if (fence != 0) {
+		KGSL_DRV_CRIT_RATELIMIT(device, "AHB fence is stuck in ISR\n");
+		return ret;
+	}
+
 	adreno_readreg(adreno_dev, ADRENO_REG_RBBM_INT_0_STATUS, &status);
 
 	/*
@@ -948,6 +965,9 @@
 	device->pwrctrl.bus_control = of_property_read_bool(node,
 		"qcom,bus-control");
 
+	device->pwrctrl.input_disable = of_property_read_bool(node,
+		"qcom,disable-wake-on-touch");
+
 	return 0;
 }
 
@@ -1091,15 +1111,19 @@
 		adreno_dev->gpuhtw_llc_slice = NULL;
 	}
 
-	adreno_input_handler.private = device;
-
 #ifdef CONFIG_INPUT
-	/*
-	 * It isn't fatal if we cannot register the input handler.  Sad,
-	 * perhaps, but not fatal
-	 */
-	if (input_register_handler(&adreno_input_handler))
-		KGSL_DRV_ERR(device, "Unable to register the input handler\n");
+	if (!device->pwrctrl.input_disable) {
+		adreno_input_handler.private = device;
+		/*
+		 * It isn't fatal if we cannot register the input handler.  Sad,
+		 * perhaps, but not fatal
+		 */
+		if (input_register_handler(&adreno_input_handler)) {
+			adreno_input_handler.private = NULL;
+			KGSL_DRV_ERR(device,
+				"Unable to register the input handler\n");
+		}
+	}
 #endif
 out:
 	if (status) {
@@ -1153,7 +1177,8 @@
 	_adreno_free_memories(adreno_dev);
 
 #ifdef CONFIG_INPUT
-	input_unregister_handler(&adreno_input_handler);
+	if (adreno_input_handler.private)
+		input_unregister_handler(&adreno_input_handler);
 #endif
 	adreno_sysfs_close(adreno_dev);
 
@@ -1325,8 +1350,7 @@
 
 	}
 
-	if (nopreempt == false &&
-		ADRENO_FEATURE(adreno_dev, ADRENO_PREEMPTION)) {
+	if (nopreempt == false) {
 		int r = 0;
 
 		if (gpudev->preemption_init)
@@ -1491,9 +1515,9 @@
 
 	/* Send OOB request to turn on the GX */
 	if (gpudev->oob_set) {
-		status = gpudev->oob_set(adreno_dev, OOB_GPUSTART_SET_MASK,
-				OOB_GPUSTART_CHECK_MASK,
-				OOB_GPUSTART_CLEAR_MASK);
+		status = gpudev->oob_set(adreno_dev, OOB_GPU_SET_MASK,
+				OOB_GPU_CHECK_MASK,
+				OOB_GPU_CLEAR_MASK);
 		if (status)
 			goto error_mmu_off;
 	}
@@ -1592,17 +1616,28 @@
 				pmqos_active_vote);
 
 	/* Send OOB request to allow IFPC */
-	if (gpudev->oob_clear)
-		gpudev->oob_clear(adreno_dev, OOB_GPUSTART_CLEAR_MASK);
+	if (gpudev->oob_clear) {
+		gpudev->oob_clear(adreno_dev, OOB_GPU_CLEAR_MASK);
+
+		/* If we made it this far, the BOOT OOB was sent to the GMU */
+		if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
+			gpudev->oob_clear(adreno_dev,
+					OOB_BOOT_SLUMBER_CLEAR_MASK);
+	}
 
 	return 0;
 
 error_oob_clear:
 	if (gpudev->oob_clear)
-		gpudev->oob_clear(adreno_dev, OOB_GPUSTART_CLEAR_MASK);
+		gpudev->oob_clear(adreno_dev, OOB_GPU_CLEAR_MASK);
 
 error_mmu_off:
 	kgsl_mmu_stop(&device->mmu);
+	if (gpudev->oob_clear &&
+			ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
+		gpudev->oob_clear(adreno_dev,
+				OOB_BOOT_SLUMBER_CLEAR_MASK);
+	}
 
 error_pwr_off:
 	/* set the state back to original state */
@@ -1660,10 +1695,23 @@
 static int adreno_stop(struct kgsl_device *device)
 {
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+	int error = 0;
 
 	if (!test_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv))
 		return 0;
 
+	/* Turn the power on one last time before stopping */
+	if (gpudev->oob_set) {
+		error = gpudev->oob_set(adreno_dev, OOB_GPU_SET_MASK,
+				OOB_GPU_CHECK_MASK,
+				OOB_GPU_CLEAR_MASK);
+		if (error) {
+			gpudev->oob_clear(adreno_dev, OOB_GPU_CLEAR_MASK);
+			return error;
+		}
+	}
+
 	adreno_set_active_ctxs_null(adreno_dev);
 
 	adreno_dispatcher_stop(adreno_dev);
@@ -1687,6 +1735,19 @@
 	/* Save physical performance counter values before GPU power down*/
 	adreno_perfcounter_save(adreno_dev);
 
+	if (gpudev->oob_clear)
+		gpudev->oob_clear(adreno_dev, OOB_GPU_CLEAR_MASK);
+
+	/*
+	 * Saving perfcounters will use an OOB to put the GMU into
+	 * active state. Before continuing, we should wait for the
+	 * GMU to return to the lowest idle level. This is
+	 * because some idle level transitions require VBIF and MMU.
+	 */
+	if (gpudev->wait_for_lowest_idle &&
+			gpudev->wait_for_lowest_idle(adreno_dev))
+		return -EINVAL;
+
 	adreno_vbif_clear_pending_transactions(device);
 
 	kgsl_mmu_stop(&device->mmu);
@@ -2457,7 +2518,7 @@
 
 	dev_err(device->dev, " hwfault=%8.8X\n", hwfault);
 
-	kgsl_device_snapshot(device, NULL);
+	kgsl_device_snapshot(device, NULL, adreno_gmu_gpu_fault(adreno_dev));
 }
 
 /**
@@ -2863,7 +2924,7 @@
 			gpu_busy += adj;
 		}
 
-		if (kgsl_gmu_isenabled(device)) {
+		if (adreno_is_a6xx(adreno_dev)) {
 			/* clock sourced from XO */
 			stats->busy_time = gpu_busy * 10 / 192;
 		} else {
@@ -3084,6 +3145,7 @@
 	.irq_handler = adreno_irq_handler,
 	.drain = adreno_drain,
 	/* Optional functions */
+	.snapshot_gmu = adreno_snapshot_gmu,
 	.drawctxt_create = adreno_drawctxt_create,
 	.drawctxt_detach = adreno_drawctxt_detach,
 	.drawctxt_destroy = adreno_drawctxt_destroy,
diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h
index 87a7f00..3118375 100644
--- a/drivers/gpu/msm/adreno.h
+++ b/drivers/gpu/msm/adreno.h
@@ -483,6 +483,10 @@
 	void *gpuhtw_llc_slice;
 	bool gpuhtw_llc_slice_enable;
 	unsigned int zap_loaded;
+	unsigned int preempt_level;
+	bool usesgmem;
+	bool skipsaverestore;
+
 };
 
 /**
@@ -524,6 +528,7 @@
 	ADRENO_DEVICE_ISDB_ENABLED = 12,
 	ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED = 13,
 	ADRENO_DEVICE_HARD_RESET = 14,
+	ADRENO_DEVICE_PREEMPTION_EXECUTION = 15,
 };
 
 /**
@@ -616,6 +621,8 @@
 	ADRENO_REG_RBBM_RBBM_CTL,
 	ADRENO_REG_UCHE_INVALIDATE0,
 	ADRENO_REG_UCHE_INVALIDATE1,
+	ADRENO_REG_RBBM_PERFCTR_RBBM_0_LO,
+	ADRENO_REG_RBBM_PERFCTR_RBBM_0_HI,
 	ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_LO,
 	ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_HI,
 	ADRENO_REG_RBBM_SECVID_TRUST_CONTROL,
@@ -629,6 +636,9 @@
 	ADRENO_REG_VBIF_XIN_HALT_CTRL0,
 	ADRENO_REG_VBIF_XIN_HALT_CTRL1,
 	ADRENO_REG_VBIF_VERSION,
+	ADRENO_REG_GBIF_HALT,
+	ADRENO_REG_GBIF_HALT_ACK,
+	ADRENO_REG_GMU_AO_AHB_FENCE_CTRL,
 	ADRENO_REG_GMU_AO_INTERRUPT_EN,
 	ADRENO_REG_GMU_AO_HOST_INTERRUPT_CLR,
 	ADRENO_REG_GMU_AO_HOST_INTERRUPT_STATUS,
@@ -827,6 +837,7 @@
 	/* GPU specific function hooks */
 	void (*irq_trace)(struct adreno_device *, unsigned int status);
 	void (*snapshot)(struct adreno_device *, struct kgsl_snapshot *);
+	void (*snapshot_gmu)(struct adreno_device *, struct kgsl_snapshot *);
 	void (*platform_setup)(struct adreno_device *);
 	void (*init)(struct adreno_device *);
 	void (*remove)(struct adreno_device *);
@@ -851,7 +862,7 @@
 				unsigned int *cmds,
 				struct kgsl_context *context);
 	int (*preemption_yield_enable)(unsigned int *);
-	unsigned int (*preemption_set_marker)(unsigned int *cmds, int start);
+	unsigned int (*set_marker)(unsigned int *cmds, int start);
 	unsigned int (*preemption_post_ibsubmit)(
 				struct adreno_device *adreno_dev,
 				unsigned int *cmds);
@@ -876,6 +887,7 @@
 	int (*rpmh_gpu_pwrctrl)(struct adreno_device *, unsigned int ops,
 				unsigned int arg1, unsigned int arg2);
 	bool (*hw_isidle)(struct adreno_device *);
+	int (*wait_for_lowest_idle)(struct adreno_device *);
 	int (*wait_for_gmu_idle)(struct adreno_device *);
 	const char *(*iommu_fault_block)(struct adreno_device *adreno_dev,
 				unsigned int fsynr1);
@@ -883,6 +895,8 @@
 	int (*soft_reset)(struct adreno_device *);
 	bool (*gx_is_on)(struct adreno_device *);
 	bool (*sptprac_is_on)(struct adreno_device *);
+	unsigned int (*ccu_invalidate)(struct adreno_device *adreno_dev,
+				unsigned int *cmds);
 };
 
 /**
@@ -1001,6 +1015,9 @@
 		struct kgsl_snapshot *snapshot,
 		struct kgsl_context *context);
 
+void adreno_snapshot_gmu(struct kgsl_device *device,
+		struct kgsl_snapshot *snapshot);
+
 int adreno_reset(struct kgsl_device *device, int fault);
 
 void adreno_fault_skipcmd_detached(struct adreno_device *adreno_dev,
@@ -1330,6 +1347,10 @@
 	smp_wmb();
 }
 
+static inline bool adreno_gmu_gpu_fault(struct adreno_device *adreno_dev)
+{
+	return adreno_gpu_fault(adreno_dev) & ADRENO_GMU_FAULT;
+}
 
 /**
  * adreno_clear_gpu_fault() - Clear the GPU fault register
@@ -1552,11 +1573,23 @@
 	smp_wmb();
 }
 
-static inline bool adreno_is_preemption_enabled(
+static inline bool adreno_is_preemption_execution_enabled(
+				struct adreno_device *adreno_dev)
+{
+	return test_bit(ADRENO_DEVICE_PREEMPTION_EXECUTION, &adreno_dev->priv);
+}
+
+static inline bool adreno_is_preemption_setup_enabled(
 				struct adreno_device *adreno_dev)
 {
 	return test_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv);
 }
+
+static inline bool adreno_is_preemption_enabled(
+				struct adreno_device *adreno_dev)
+{
+	return 0;
+}
 /**
  * adreno_ctx_get_rb() - Return the ringbuffer that a context should
  * use based on priority
@@ -1580,7 +1613,7 @@
 	 * ringbuffer
 	 */
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_execution_enabled(adreno_dev))
 		return &(adreno_dev->ringbuffers[0]);
 
 	/*
@@ -1682,21 +1715,60 @@
 	spin_unlock_irqrestore(&rb->preempt_lock, flags);
 }
 
+static inline bool is_power_counter_overflow(struct adreno_device *adreno_dev,
+	unsigned int reg, unsigned int prev_val, unsigned int *perfctr_pwr_hi)
+{
+	unsigned int val;
+	bool ret = false;
+
+	/*
+	 * If prev_val is zero, it is first read after perf counter reset.
+	 * So set perfctr_pwr_hi register to zero.
+	 */
+	if (prev_val == 0) {
+		*perfctr_pwr_hi = 0;
+		return ret;
+	}
+	adreno_readreg(adreno_dev, ADRENO_REG_RBBM_PERFCTR_RBBM_0_HI, &val);
+	if (val != *perfctr_pwr_hi) {
+		*perfctr_pwr_hi = val;
+		ret = true;
+	}
+	return ret;
+}
+
 static inline unsigned int counter_delta(struct kgsl_device *device,
 			unsigned int reg, unsigned int *counter)
 {
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	unsigned int val;
 	unsigned int ret = 0;
+	bool overflow = true;
+	static unsigned int perfctr_pwr_hi;
 
 	/* Read the value */
 	kgsl_regread(device, reg, &val);
 
+	if (adreno_is_a5xx(adreno_dev) && reg == adreno_getreg
+		(adreno_dev, ADRENO_REG_RBBM_PERFCTR_RBBM_0_LO))
+		overflow = is_power_counter_overflow(adreno_dev, reg,
+				*counter, &perfctr_pwr_hi);
+
 	/* Return 0 for the first read */
 	if (*counter != 0) {
-		if (val < *counter)
-			ret = (0xFFFFFFFF - *counter) + val;
-		else
+		if (val >= *counter) {
 			ret = val - *counter;
+		} else if (overflow == true) {
+			ret = (0xFFFFFFFF - *counter) + val;
+		} else {
+			/*
+			 * Since KGSL got abnormal value from the counter,
+			 * We will drop the value from being accumulated.
+			 */
+			pr_warn_once("KGSL: Abnormal value :0x%x (0x%x) from perf counter : 0x%x\n",
+					val, *counter, reg);
+			return 0;
+		}
 	}
 
 	*counter = val;
@@ -1735,6 +1807,47 @@
 	kgsl_active_count_put(KGSL_DEVICE(adreno_dev));
 }
 
+static inline bool adreno_has_gbif(struct adreno_device *adreno_dev)
+{
+	if (adreno_is_a615(adreno_dev))
+		return true;
+	else
+		return false;
+}
+
+/**
+ * adreno_wait_for_vbif_halt_ack() - wait for VBIF acknowledgment
+ * for given HALT request.
+ * @ack_reg: register offset to wait for acknowledge
+ */
+static inline int adreno_wait_for_vbif_halt_ack(struct kgsl_device *device,
+	int ack_reg)
+{
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+	unsigned long wait_for_vbif;
+	unsigned int mask = gpudev->vbif_xin_halt_ctrl0_mask;
+	unsigned int val;
+	int ret = 0;
+
+	/* wait for the transactions to clear */
+	wait_for_vbif = jiffies + msecs_to_jiffies(100);
+	while (1) {
+		adreno_readreg(adreno_dev, ack_reg,
+			&val);
+		if ((val & mask) == mask)
+			break;
+		if (time_after(jiffies, wait_for_vbif)) {
+			KGSL_DRV_ERR(device,
+				"Wait limit reached for VBIF XIN Halt\n");
+			ret = -ETIMEDOUT;
+			break;
+		}
+	}
+
+	return ret;
+}
+
 /**
  * adreno_vbif_clear_pending_transactions() - Clear transactions in VBIF pipe
  * @device: Pointer to the device whose VBIF pipe is to be cleared
@@ -1745,26 +1858,20 @@
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
 	unsigned int mask = gpudev->vbif_xin_halt_ctrl0_mask;
-	unsigned int val;
-	unsigned long wait_for_vbif;
 	int ret = 0;
 
-	adreno_writereg(adreno_dev, ADRENO_REG_VBIF_XIN_HALT_CTRL0, mask);
-	/* wait for the transactions to clear */
-	wait_for_vbif = jiffies + msecs_to_jiffies(100);
-	while (1) {
-		adreno_readreg(adreno_dev,
-			ADRENO_REG_VBIF_XIN_HALT_CTRL1, &val);
-		if ((val & mask) == mask)
-			break;
-		if (time_after(jiffies, wait_for_vbif)) {
-			KGSL_DRV_ERR(device,
-				"Wait limit reached for VBIF XIN Halt\n");
-			ret = -ETIMEDOUT;
-			break;
-		}
+	if (adreno_has_gbif(adreno_dev)) {
+		adreno_writereg(adreno_dev, ADRENO_REG_GBIF_HALT, mask);
+		ret = adreno_wait_for_vbif_halt_ack(device,
+				ADRENO_REG_GBIF_HALT_ACK);
+		adreno_writereg(adreno_dev, ADRENO_REG_GBIF_HALT, 0);
+	} else {
+		adreno_writereg(adreno_dev, ADRENO_REG_VBIF_XIN_HALT_CTRL0,
+			mask);
+		ret = adreno_wait_for_vbif_halt_ack(device,
+				ADRENO_REG_VBIF_XIN_HALT_CTRL1);
+		adreno_writereg(adreno_dev, ADRENO_REG_VBIF_XIN_HALT_CTRL0, 0);
 	}
-	adreno_writereg(adreno_dev, ADRENO_REG_VBIF_XIN_HALT_CTRL0, 0);
 	return ret;
 }
 
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index 5d7fb21..b2cdf56 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -685,7 +685,7 @@
 		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
 		dev_err(device->dev, "CP initialization failed to idle\n");
-		kgsl_device_snapshot(device, NULL);
+		kgsl_device_snapshot(device, NULL, false);
 	}
 
 	return ret;
@@ -1533,6 +1533,10 @@
 			A3XX_UCHE_CACHE_INVALIDATE0_REG),
 	ADRENO_REG_DEFINE(ADRENO_REG_UCHE_INVALIDATE1,
 			A3XX_UCHE_CACHE_INVALIDATE1_REG),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_LO,
+			A3XX_RBBM_PERFCTR_RBBM_0_LO),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_HI,
+			A3XX_RBBM_PERFCTR_RBBM_0_HI),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_LO,
 				A3XX_RBBM_PERFCTR_LOAD_VALUE_LO),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_HI,
@@ -1823,7 +1827,7 @@
 
 	if (ret) {
 		KGSL_DRV_ERR(device, "microcode bootstrap failed to idle\n");
-		kgsl_device_snapshot(device, NULL);
+		kgsl_device_snapshot(device, NULL, false);
 	}
 
 	/* Clear the chicken bit for speed up on A430 and its derivatives */
diff --git a/drivers/gpu/msm/adreno_a4xx.c b/drivers/gpu/msm/adreno_a4xx.c
index c807b67..80ceabd 100644
--- a/drivers/gpu/msm/adreno_a4xx.c
+++ b/drivers/gpu/msm/adreno_a4xx.c
@@ -808,6 +808,10 @@
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, A4XX_RBBM_SW_RESET_CMD),
 	ADRENO_REG_DEFINE(ADRENO_REG_UCHE_INVALIDATE0, A4XX_UCHE_INVALIDATE0),
 	ADRENO_REG_DEFINE(ADRENO_REG_UCHE_INVALIDATE1, A4XX_UCHE_INVALIDATE1),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_LO,
+				A4XX_RBBM_PERFCTR_RBBM_0_LO),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_HI,
+				A4XX_RBBM_PERFCTR_RBBM_0_HI),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_LO,
 				A4XX_RBBM_PERFCTR_LOAD_VALUE_LO),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_HI,
@@ -1535,7 +1539,7 @@
 		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
 		dev_err(device->dev, "CP initialization failed to idle\n");
-		kgsl_device_snapshot(device, NULL);
+		kgsl_device_snapshot(device, NULL, false);
 	}
 
 	return ret;
diff --git a/drivers/gpu/msm/adreno_a5xx.c b/drivers/gpu/msm/adreno_a5xx.c
index 742da91..434fef8 100644
--- a/drivers/gpu/msm/adreno_a5xx.c
+++ b/drivers/gpu/msm/adreno_a5xx.c
@@ -61,8 +61,8 @@
 };
 
 static void a5xx_irq_storm_worker(struct work_struct *work);
-static int _read_fw2_block_header(uint32_t *header, uint32_t id,
-	uint32_t major, uint32_t minor);
+static int _read_fw2_block_header(uint32_t *header, uint32_t remain,
+	uint32_t id, uint32_t major, uint32_t minor);
 static void a5xx_gpmu_reset(struct work_struct *work);
 static int a5xx_gpmu_init(struct adreno_device *adreno_dev);
 
@@ -678,12 +678,17 @@
 	if (data[1] != GPMU_FIRMWARE_ID)
 		goto err;
 	ret = _read_fw2_block_header(&data[2],
+		data[0] - 2,
 		GPMU_FIRMWARE_ID,
 		adreno_dev->gpucore->gpmu_major,
 		adreno_dev->gpucore->gpmu_minor);
 	if (ret)
 		goto err;
 
+	/* Integer overflow check for cmd_size */
+	if (data[2] > (data[0] - 2))
+		goto err;
+
 	cmds = data + data[2] + 3;
 	cmd_size = data[0] - data[2] - 2;
 
@@ -1196,8 +1201,8 @@
 	kgsl_regwrite(device, A5XX_RBBM_ISDB_CNT, on ? 0x00000182 : 0x00000180);
 }
 
-static int _read_fw2_block_header(uint32_t *header, uint32_t id,
-				uint32_t major, uint32_t minor)
+static int _read_fw2_block_header(uint32_t *header, uint32_t remain,
+			uint32_t id, uint32_t major, uint32_t minor)
 {
 	uint32_t header_size;
 	int i = 1;
@@ -1207,7 +1212,8 @@
 
 	header_size = header[0];
 	/* Headers have limited size and always occur as pairs of words */
-	if (header_size > MAX_HEADER_SIZE || header_size % 2)
+	if (header_size >  MAX_HEADER_SIZE || header_size >= remain ||
+				header_size % 2 || header_size == 0)
 		return -EINVAL;
 	/* Sequences must have an identifying id first thing in their header */
 	if (id == GPMU_SEQUENCE_ID) {
@@ -1302,6 +1308,7 @@
 		/* For now ignore blocks other than the LM sequence */
 		if (block[4] == LM_SEQUENCE_ID) {
 			ret = _read_fw2_block_header(&block[2],
+				block_size - 2,
 				GPMU_SEQUENCE_ID,
 				adreno_dev->gpucore->lm_major,
 				adreno_dev->gpucore->lm_minor);
@@ -2037,6 +2044,9 @@
 
 	}
 
+	/* Disable All flat shading optimization */
+	kgsl_regrmw(device, A5XX_VPC_DBG_ECO_CNTL, 0, 0x1 << 10);
+
 	/*
 	 * VPC corner case with local memory load kill leads to corrupt
 	 * internal state. Normal Disable does not work for all a5x chips.
@@ -2991,6 +3001,10 @@
 		ADRENO_REG_DEFINE(ADRENO_REG_RBBM_BLOCK_SW_RESET_CMD2,
 					  A5XX_RBBM_BLOCK_SW_RESET_CMD2),
 	ADRENO_REG_DEFINE(ADRENO_REG_UCHE_INVALIDATE0, A5XX_UCHE_INVALIDATE0),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_LO,
+				A5XX_RBBM_PERFCTR_RBBM_0_LO),
+	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_RBBM_0_HI,
+				A5XX_RBBM_PERFCTR_RBBM_0_HI),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_LO,
 				A5XX_RBBM_PERFCTR_LOAD_VALUE_LO),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_PERFCTR_LOAD_VALUE_HI,
diff --git a/drivers/gpu/msm/adreno_a5xx_snapshot.c b/drivers/gpu/msm/adreno_a5xx_snapshot.c
index 78b56bc..6dc62866 100644
--- a/drivers/gpu/msm/adreno_a5xx_snapshot.c
+++ b/drivers/gpu/msm/adreno_a5xx_snapshot.c
@@ -767,6 +767,8 @@
 
 	crash_dump_valid = false;
 
+	if (!device->snapshot_crashdumper)
+		return;
 	if (capturescript.gpuaddr == 0 || registers.gpuaddr == 0)
 		return;
 
@@ -872,8 +874,7 @@
 		ARRAY_SIZE(a5xx_vbif_snapshot_registers));
 
 	/* Try to run the crash dumper */
-	if (device->snapshot_crashdumper)
-		_a5xx_do_crashdump(device);
+	_a5xx_do_crashdump(device);
 
 	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
 		snapshot, a5xx_snapshot_registers, NULL);
diff --git a/drivers/gpu/msm/adreno_a6xx.c b/drivers/gpu/msm/adreno_a6xx.c
index 24f452f..de4677a 100644
--- a/drivers/gpu/msm/adreno_a6xx.c
+++ b/drivers/gpu/msm/adreno_a6xx.c
@@ -50,10 +50,15 @@
 	{0, 0},
 };
 
-static const struct adreno_vbif_platform a6xx_vbif_platforms[] = {
-	{ adreno_is_a630, a630_vbif },
+static const struct adreno_vbif_data a615_gbif[] = {
+	{A6XX_RBBM_VBIF_CLIENT_QOS_CNTL, 0x3},
+	{0, 0},
 };
 
+static const struct adreno_vbif_platform a6xx_vbif_platforms[] = {
+	{ adreno_is_a630, a630_vbif },
+	{ adreno_is_a615, a615_gbif },
+};
 
 struct kgsl_hwcg_reg {
 	unsigned int off;
@@ -244,18 +249,6 @@
 	{ A6XX_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 0x0 },
 };
 
-static void a6xx_platform_setup(struct adreno_device *adreno_dev)
-{
-	uint64_t addr;
-	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
-
-	/* Calculate SP local and private mem addresses */
-	addr = ALIGN(ADRENO_UCHE_GMEM_BASE + adreno_dev->gmem_size, SZ_64K);
-	adreno_dev->sp_local_gpuaddr = addr;
-	adreno_dev->sp_pvt_gpuaddr = addr + SZ_64K;
-	gpudev->vbif_xin_halt_ctrl0_mask = A6XX_VBIF_XIN_HALT_CTRL0_MASK;
-}
-
 static void _update_always_on_regs(struct adreno_device *adreno_dev)
 {
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
@@ -272,7 +265,7 @@
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
 	if (kgsl_allocate_global(device, &adreno_dev->pwrup_reglist,
-		PAGE_SIZE, 0, KGSL_MEMDESC_PRIVILEGED,
+		PAGE_SIZE, KGSL_MEMFLAGS_GPUREADONLY, 0,
 		"powerup_register_list")) {
 		adreno_dev->pwrup_reglist.gpuaddr = 0;
 		return;
@@ -369,14 +362,33 @@
 	kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL, 0x1);
 }
 
+#define RBBM_CLOCK_CNTL_ON 0x8AA8AA02
 
 static void a6xx_hwcg_set(struct adreno_device *adreno_dev, bool on)
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 	const struct kgsl_hwcg_reg *regs;
+	unsigned int value;
 	int i, j;
 
 	if (!test_bit(ADRENO_HWCG_CTRL, &adreno_dev->pwrctrl_flag))
+		on = false;
+
+	if (kgsl_gmu_isenabled(device)) {
+		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_MODE_CNTL,
+			on ? 0x00020222 : 0);
+		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_DELAY_CNTL,
+			on ? 0x00010111 : 0);
+		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_HYST_CNTL,
+			on ? 0x00050555 : 0);
+	}
+
+	kgsl_regread(device, A6XX_RBBM_CLOCK_CNTL, &value);
+
+	if (value == RBBM_CLOCK_CNTL_ON && on)
+		return;
+
+	if (value == 0 && !on)
 		return;
 
 	for (i = 0; i < ARRAY_SIZE(a6xx_hwcg_registers); i++) {
@@ -395,19 +407,12 @@
 	for (j = 0; j < a6xx_hwcg_registers[i].count; j++)
 		kgsl_regwrite(device, regs[j].off, on ? regs[j].val : 0);
 
-	if (kgsl_gmu_isenabled(device)) {
-		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_MODE_CNTL,
-			0x00020222);
-		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_DELAY_CNTL,
-			0x00010111);
-		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_HYST_CNTL,
-			0x00050555);
-	}
 	/* Enable SP clock */
 	kgsl_gmu_regrmw(device, A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 0, 1);
 
 	/* enable top level HWCG */
-	kgsl_regwrite(device, A6XX_RBBM_CLOCK_CNTL, on ? 0x8AA8AA02 : 0);
+	kgsl_regwrite(device, A6XX_RBBM_CLOCK_CNTL,
+		on ? RBBM_CLOCK_CNTL_ON : 0);
 }
 
 #define LM_DEFAULT_LIMIT	6000
@@ -567,7 +572,7 @@
 		kgsl_regrmw(device, A6XX_PC_DBG_ECO_CNTL, 0, (1 << 8));
 
 	/* Enable the GMEM save/restore feature for preemption */
-	if (adreno_is_preemption_enabled(adreno_dev))
+	if (adreno_is_preemption_setup_enabled(adreno_dev))
 		kgsl_regwrite(device, A6XX_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE,
 			0x1);
 
@@ -694,7 +699,7 @@
 		*cmds++ = lower_32_bits(gpuaddr);
 		*cmds++ = upper_32_bits(gpuaddr);
 		/* Size is in dwords */
-		*cmds++ = sizeof(a6xx_pwrup_reglist) >> 2;
+		*cmds++ = 0;
 	}
 
 	/* Pad rest of the cmds with 0's */
@@ -773,7 +778,7 @@
 	struct adreno_ringbuffer *rb = adreno_dev->cur_rb;
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_execution_enabled(adreno_dev))
 		return 0;
 
 	cmds = adreno_ringbuffer_allocspace(rb, 42);
@@ -871,16 +876,6 @@
 
 #define RSC_CMD_OFFSET 2
 #define PDC_CMD_OFFSET 4
-static void _regread(void __iomem *regbase,
-		unsigned int offsetwords, unsigned int *value)
-{
-	void __iomem *reg;
-
-	reg = regbase + (offsetwords << 2);
-	*value = __raw_readl(reg);
-	/* Ensure read completes */
-	rmb();
-}
 
 static void _regwrite(void __iomem *regbase,
 		unsigned int offsetwords, unsigned int value)
@@ -898,8 +893,12 @@
  */
 static void _load_gmu_rpmh_ucode(struct kgsl_device *device)
 {
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	struct gmu_device *gmu = &device->gmu;
 
+	/* Disable SDE clock gating */
+	kgsl_gmu_regwrite(device, A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
+
 	/* Setup RSC PDC handshake for sleep and wakeup */
 	kgsl_gmu_regwrite(device, A6XX_RSCC_PDC_SLAVE_ID_DRV0, 1);
 	kgsl_gmu_regwrite(device, A6XX_RSCC_HIDDEN_TCS_CMD0_DATA, 0);
@@ -919,8 +918,9 @@
 	kgsl_gmu_regwrite(device, A6XX_RSCC_PDC_MATCH_VALUE_LO, 0x4510);
 	kgsl_gmu_regwrite(device, A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
 
-	/* Enable timestamp event */
-	kgsl_gmu_regwrite(device, A6XX_RSCC_TIMESTAMP_UNIT1_EN_DRV0, 1);
+	/* Enable timestamp event for v1 only */
+	if (adreno_is_a630v1(adreno_dev))
+		kgsl_gmu_regwrite(device, A6XX_RSCC_TIMESTAMP_UNIT1_EN_DRV0, 1);
 
 	/* Load RSC sequencer uCode for sleep and wakeup */
 	kgsl_gmu_regwrite(device, A6XX_RSCC_SEQ_MEM_0_DRV0, 0xA7A506A0);
@@ -930,11 +930,11 @@
 	kgsl_gmu_regwrite(device, A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 0x0020E8A8);
 
 	/* Load PDC sequencer uCode for power up and power down sequence */
-	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0, 0xFFBFA1E1);
-	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 1, 0xE0A4A3A2);
-	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 2, 0xE2848382);
-	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 3, 0xFDBDE4E3);
-	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 4, 0x00002081);
+	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0, 0xFEBEA1E1);
+	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 1, 0xA5A4A3A2);
+	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 2, 0x8382A6E0);
+	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 3, 0xBCE3E284);
+	_regwrite(gmu->pdc_reg_virt, PDC_GPU_SEQ_MEM_0 + 4, 0x002081FC);
 
 	/* Set TCS commands used by PDC sequence for low power modes */
 	_regwrite(gmu->pdc_reg_virt, PDC_GPU_TCS0_CMD_ENABLE_BANK, 7);
@@ -1017,10 +1017,24 @@
 		cond_resched();
 	} while (!time_after(jiffies, t));
 
+	/* Double check one last time */
+	kgsl_gmu_regread(device, offset, &value);
+	if ((value & mask) == expected_ret)
+		return 0;
+
 	return -EINVAL;
 }
 
 /*
+ * The lowest 16 bits of this value are the number of XO clock cycles
+ * for main hysteresis. This is the first hysteresis. Here we set it
+ * to 0x5DC cycles, or 78.1 us. The highest 16 bits of this value are
+ * the number of XO clock cycles for short hysteresis. This happens
+ * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
+ */
+#define GMU_PWR_COL_HYST 0x000A05DC
+
+/*
  * a6xx_gmu_power_config() - Configure and enable GMU's low power mode
  * setting based on ADRENO feature flags.
  * @device: Pointer to KGSL device
@@ -1051,13 +1065,13 @@
 		/* fall through */
 	case GPU_HW_IFPC:
 		kgsl_gmu_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
-				0x000A0080);
+				GMU_PWR_COL_HYST);
 		kgsl_gmu_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0,
 				IFPC_ENABLE_MASK);
 		/* fall through */
 	case GPU_HW_SPTP_PC:
 		kgsl_gmu_regwrite(device, A6XX_GMU_PWR_COL_SPTPRAC_HYST,
-				0x000A0080);
+				GMU_PWR_COL_HYST);
 		kgsl_gmu_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0,
 				SPTP_ENABLE_MASK);
 		/* fall through */
@@ -1276,21 +1290,12 @@
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 	unsigned int val;
-	bool state;
 
 	if (!kgsl_gmu_isenabled(device))
 		return true;
 
 	kgsl_gmu_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
-	state = !(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF));
-
-	/* If GMU is holding on to the fence then we cannot dump any GX stuff */
-	kgsl_gmu_regread(device, A6XX_GMU_AO_AHB_FENCE_CTRL, &val);
-	if (val)
-		return false;
-
-	return state;
-
+	return !(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF));
 }
 
 /*
@@ -1361,12 +1366,13 @@
 	/* Disable the power counter so that the GMU is not busy */
 	kgsl_gmu_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
 
-	/* Turn off SPTPRAC before GMU turns off GX */
-	a6xx_sptprac_disable(adreno_dev);
+	/* Turn off SPTPRAC if we own it */
+	if (gmu->idle_level < GPU_HW_SPTP_PC)
+		a6xx_sptprac_disable(adreno_dev);
 
 	if (!ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
 		ret = hfi_notify_slumber(gmu, perf_idx, bus_level);
-		return ret;
+		goto out;
 	}
 
 	kgsl_gmu_regwrite(device, A6XX_GMU_BOOT_SLUMBER_OPTION,
@@ -1392,6 +1398,9 @@
 		}
 	}
 
+out:
+	/* Make sure the fence is in ALLOW mode */
+	kgsl_gmu_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
 	return ret;
 }
 
@@ -1399,12 +1408,12 @@
 {
 	struct gmu_device *gmu = &device->gmu;
 	struct device *dev = &gmu->pdev->dev;
-	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
-	unsigned int tmp;
 	int val;
 
 	kgsl_gmu_regread(device, A6XX_GPU_CC_GX_DOMAIN_MISC, &val);
-	WARN_ON(!(val & 0x1));
+	if (!(val & 0x1))
+		dev_err_ratelimited(&gmu->pdev->dev,
+			"GMEM CLAMP IO not set while GFX rail off\n");
 
 	/* RSC wake sequence */
 	kgsl_gmu_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, BIT(1));
@@ -1430,19 +1439,6 @@
 
 	kgsl_gmu_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);
 
-	/* Turn on GFX rail CPR */
-	if (adreno_is_a630v2(adreno_dev)) {
-		_regread(gmu->cpr_reg_virt, CPR_CPRF_CPRF5_CTRL, &tmp);
-		tmp |= BIT(2);
-		_regwrite(gmu->cpr_reg_virt, CPR_CPRF_CPRF5_CTRL, tmp);
-
-		kgsl_gmu_regread(device, A6XX_GPU_CPR_FSM_CTL, &tmp);
-		tmp |= BIT(0);
-		kgsl_gmu_regwrite(device, A6XX_GPU_CPR_FSM_CTL, tmp);
-		/* Ensure write happens before exit the function */
-		wmb();
-	}
-
 	/* Enable the power counter because it was disabled before slumber */
 	kgsl_gmu_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
 
@@ -1456,49 +1452,49 @@
 {
 	struct gmu_device *gmu = &device->gmu;
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
-	unsigned int tmp;
-	int val;
+	int ret;
 
-	/* Turn off GFX rail CPR */
-	if (adreno_is_a630v2(adreno_dev)) {
-		_regread(gmu->cpr_reg_virt, CPR_CPRF_CPRF5_CTRL, &tmp);
-		tmp &= ~BIT(2);
-		_regwrite(gmu->cpr_reg_virt, CPR_CPRF_CPRF5_CTRL, tmp);
+	/* RSC sleep sequence is different on v1 */
+	if (adreno_is_a630v1(adreno_dev))
+		kgsl_gmu_regwrite(device, A6XX_RSCC_TIMESTAMP_UNIT1_EN_DRV0, 1);
 
-		kgsl_gmu_regread(device, A6XX_GPU_CPR_FSM_CTL, &tmp);
-		tmp &= ~BIT(0);
-		kgsl_gmu_regwrite(device, A6XX_GPU_CPR_FSM_CTL, tmp);
-		/* Ensure write completes before starting sleep seq */
-		wmb();
-	}
-
-	/* RSC sleep sequence */
-	kgsl_gmu_regwrite(device, A6XX_RSCC_TIMESTAMP_UNIT1_EN_DRV0, 1);
 	kgsl_gmu_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 1);
 	wmb();
 
-	if (timed_poll_check(device,
-			A6XX_RSCC_TIMESTAMP_UNIT1_OUTPUT_DRV0,
-			BIT(0),
-			GPU_START_TIMEOUT,
-			BIT(0))) {
+	if (adreno_is_a630v1(adreno_dev))
+		ret = timed_poll_check(device,
+				A6XX_RSCC_TIMESTAMP_UNIT1_OUTPUT_DRV0,
+				BIT(0),
+				GPU_START_TIMEOUT,
+				BIT(0));
+	else
+		ret = timed_poll_check(device,
+				A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
+				BIT(16),
+				GPU_START_TIMEOUT,
+				BIT(16));
+
+	if (ret) {
 		dev_err(&gmu->pdev->dev, "GPU RSC power off fail\n");
-		return -EINVAL;
+		return -ETIMEDOUT;
 	}
 
-	/* Read to clear the timestamp */
-	kgsl_gmu_regread(device, A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_L_DRV0,
-			&val);
-	kgsl_gmu_regread(device, A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_H_DRV0,
-			&val);
+	/* Read to clear the timestamp valid signal. Don't care what we read. */
+	if (adreno_is_a630v1(adreno_dev)) {
+		kgsl_gmu_regread(device,
+				A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_L_DRV0,
+				&ret);
+		kgsl_gmu_regread(device,
+				A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_H_DRV0,
+				&ret);
+	}
+
 	kgsl_gmu_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);
 
 	if (ADRENO_FEATURE(adreno_dev, ADRENO_LM) &&
-		test_bit(ADRENO_LM_CTRL, &adreno_dev->pwrctrl_flag))
+			test_bit(ADRENO_LM_CTRL, &adreno_dev->pwrctrl_flag))
 		kgsl_gmu_regwrite(device, A6XX_GMU_AO_SPARE_CNTL, 0);
 
-	/* FIXME: v2 has different procedure to trigger sequence */
-
 	return 0;
 }
 
@@ -1574,6 +1570,8 @@
 	kgsl_gmu_regwrite(device, A6XX_GPU_CS_AMP_CALIBRATION_DONE, 1);
 
 }
+
+#define GPU_LIMIT_THRESHOLD_ENABLE	BIT(31)
 /*
  * a6xx_gmu_fw_start() - set up GMU and start FW
  * @device: Pointer to KGSL device
@@ -1657,7 +1655,7 @@
 	if (ADRENO_FEATURE(adreno_dev, ADRENO_LM) &&
 		test_bit(ADRENO_LM_CTRL, &adreno_dev->pwrctrl_flag)) {
 		kgsl_gmu_regwrite(device, A6XX_GPU_GMU_CX_GMU_PWR_THRESHOLD,
-			lm_limit(adreno_dev));
+			GPU_LIMIT_THRESHOLD_ENABLE | lm_limit(adreno_dev));
 		isense_cold_trimm(device);
 	}
 
@@ -1754,6 +1752,53 @@
 	return true;
 }
 
+static int a6xx_wait_for_lowest_idle(struct adreno_device *adreno_dev)
+{
+	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
+	struct gmu_device *gmu = &device->gmu;
+	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+	unsigned int reg;
+	unsigned long t;
+
+	if (!kgsl_gmu_isenabled(device))
+		return 0;
+
+	t = jiffies + msecs_to_jiffies(GMU_IDLE_TIMEOUT);
+	while (!time_after(jiffies, t)) {
+		adreno_read_gmureg(ADRENO_DEVICE(device),
+				ADRENO_REG_GMU_RPMH_POWER_STATE, &reg);
+
+		/* SPTPRAC PC has the same idle level as IFPC */
+		if ((reg == gmu->idle_level) ||
+				(gmu->idle_level == GPU_HW_SPTP_PC &&
+				reg == GPU_HW_IFPC)) {
+			/* IFPC is not complete until GX is off */
+			if (gmu->idle_level != GPU_HW_IFPC ||
+					!gpudev->gx_is_on(adreno_dev))
+				return 0;
+		}
+
+		/* Wait 100us to reduce unnecessary AHB bus traffic */
+		udelay(100);
+		cond_resched();
+	}
+
+	/* Check one last time */
+	adreno_read_gmureg(ADRENO_DEVICE(device),
+			ADRENO_REG_GMU_RPMH_POWER_STATE, &reg);
+	if ((reg == gmu->idle_level) ||
+			(gmu->idle_level == GPU_HW_SPTP_PC &&
+			reg == GPU_HW_IFPC)) {
+		if (gmu->idle_level != GPU_HW_IFPC ||
+				!gpudev->gx_is_on(adreno_dev))
+			return 0;
+	}
+
+	dev_err(&gmu->pdev->dev,
+			"Timeout waiting for lowest idle level: %d\n", reg);
+	return -ETIMEDOUT;
+}
+
 static int a6xx_wait_for_gmu_idle(struct adreno_device *adreno_dev)
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
@@ -1982,9 +2027,7 @@
 	/* If SPTP_RAC is on, turn off SPTP_RAC HS */
 	a6xx_sptprac_disable(adreno_dev);
 
-	/* Disconnect GPU from BUS. Clear and reconnected after reset */
-	/* adreno_vbif_clear_pending_transactions(device); */
-	/* Unnecessary: a6xx_soft_reset(adreno_dev); */
+	/* Disconnect GPU from BUS is not needed if CX GDSC goes off later */
 
 	/* Check no outstanding RPMh voting */
 	a6xx_complete_rpmh_votes(device);
@@ -2334,7 +2377,7 @@
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
-	if (adreno_is_preemption_enabled(adreno_dev))
+	if (adreno_is_preemption_execution_enabled(adreno_dev))
 		a6xx_preemption_trigger(adreno_dev);
 
 	adreno_dispatcher_schedule(device);
@@ -2726,6 +2769,27 @@
 		A6XX_VBIF_PERF_PWR_CNT_HIGH2, -1, A6XX_VBIF_PERF_PWR_CNT_EN2 },
 };
 
+
+static struct adreno_perfcount_register a6xx_perfcounters_gbif[] = {
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW0,
+		A6XX_GBIF_PERF_CNT_HIGH0, -1, A6XX_GBIF_PERF_CNT_SEL },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW1,
+		A6XX_GBIF_PERF_CNT_HIGH1, -1, A6XX_GBIF_PERF_CNT_SEL },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW2,
+		A6XX_GBIF_PERF_CNT_HIGH2, -1, A6XX_GBIF_PERF_CNT_SEL },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW3,
+		A6XX_GBIF_PERF_CNT_HIGH3, -1, A6XX_GBIF_PERF_CNT_SEL },
+};
+
+static struct adreno_perfcount_register a6xx_perfcounters_gbif_pwr[] = {
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW0,
+		A6XX_GBIF_PWR_CNT_HIGH0, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW1,
+		A6XX_GBIF_PWR_CNT_HIGH1, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW2,
+		A6XX_GBIF_PWR_CNT_HIGH2, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
+};
+
 static struct adreno_perfcount_register a6xx_perfcounters_pwr[] = {
 	{ KGSL_PERFCOUNTER_BROKEN, 0, 0, 0, 0, -1, 0 },
 	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0,
@@ -2836,6 +2900,49 @@
 	return 0;
 }
 
+static void a6xx_platform_setup(struct adreno_device *adreno_dev)
+{
+	uint64_t addr;
+	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+
+	/* Calculate SP local and private mem addresses */
+	addr = ALIGN(ADRENO_UCHE_GMEM_BASE + adreno_dev->gmem_size, SZ_64K);
+	adreno_dev->sp_local_gpuaddr = addr;
+	adreno_dev->sp_pvt_gpuaddr = addr + SZ_64K;
+
+	if (adreno_has_gbif(adreno_dev)) {
+		a6xx_perfcounter_groups[KGSL_PERFCOUNTER_GROUP_VBIF].regs =
+				a6xx_perfcounters_gbif;
+		a6xx_perfcounter_groups[KGSL_PERFCOUNTER_GROUP_VBIF].reg_count
+				= ARRAY_SIZE(a6xx_perfcounters_gbif);
+
+		a6xx_perfcounter_groups[KGSL_PERFCOUNTER_GROUP_VBIF_PWR].regs =
+				a6xx_perfcounters_gbif_pwr;
+		a6xx_perfcounter_groups[KGSL_PERFCOUNTER_GROUP_VBIF].reg_count
+				= ARRAY_SIZE(a6xx_perfcounters_gbif_pwr);
+
+		gpudev->vbif_xin_halt_ctrl0_mask =
+				A6XX_GBIF_HALT_MASK;
+	} else
+		gpudev->vbif_xin_halt_ctrl0_mask =
+				A6XX_VBIF_XIN_HALT_CTRL0_MASK;
+}
+
+
+static unsigned int a6xx_ccu_invalidate(struct adreno_device *adreno_dev,
+	unsigned int *cmds)
+{
+	/* CCU_INVALIDATE_DEPTH */
+	*cmds++ = cp_packet(adreno_dev, CP_EVENT_WRITE, 1);
+	*cmds++ = 24;
+
+	/* CCU_INVALIDATE_COLOR */
+	*cmds++ = cp_packet(adreno_dev, CP_EVENT_WRITE, 1);
+	*cmds++ = 25;
+
+	return 4;
+}
+
 /* Register offset defines for A6XX, in order of enum adreno_regs */
 static unsigned int a6xx_register_offsets[ADRENO_REG_REGISTER_MAX] = {
 
@@ -2895,10 +3002,14 @@
 				A6XX_VBIF_XIN_HALT_CTRL0),
 	ADRENO_REG_DEFINE(ADRENO_REG_VBIF_XIN_HALT_CTRL1,
 				A6XX_VBIF_XIN_HALT_CTRL1),
+	ADRENO_REG_DEFINE(ADRENO_REG_GBIF_HALT, A6XX_GBIF_HALT),
+	ADRENO_REG_DEFINE(ADRENO_REG_GBIF_HALT_ACK, A6XX_GBIF_HALT_ACK),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_ALWAYSON_COUNTER_LO,
 				A6XX_GMU_ALWAYS_ON_COUNTER_L),
 	ADRENO_REG_DEFINE(ADRENO_REG_RBBM_ALWAYSON_COUNTER_HI,
 				A6XX_GMU_ALWAYS_ON_COUNTER_H),
+	ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_AHB_FENCE_CTRL,
+				A6XX_GMU_AO_AHB_FENCE_CTRL),
 	ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_INTERRUPT_EN,
 				A6XX_GMU_AO_INTERRUPT_EN),
 	ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_CLR,
@@ -2956,6 +3067,7 @@
 	.reg_offsets = &a6xx_reg_offsets,
 	.start = a6xx_start,
 	.snapshot = a6xx_snapshot,
+	.snapshot_gmu = a6xx_snapshot_gmu,
 	.irq = &a6xx_irq,
 	.snapshot_data = &a6xx_snapshot_data,
 	.irq_trace = trace_kgsl_a5xx_irq_status,
@@ -2978,6 +3090,7 @@
 	.gpu_keepalive = a6xx_gpu_keepalive,
 	.rpmh_gpu_pwrctrl = a6xx_rpmh_gpu_pwrctrl,
 	.hw_isidle = a6xx_hw_isidle, /* Replaced by NULL if GMU is disabled */
+	.wait_for_lowest_idle = a6xx_wait_for_lowest_idle,
 	.wait_for_gmu_idle = a6xx_wait_for_gmu_idle,
 	.iommu_fault_block = a6xx_iommu_fault_block,
 	.reset = a6xx_reset,
@@ -2986,9 +3099,10 @@
 	.preemption_post_ibsubmit = a6xx_preemption_post_ibsubmit,
 	.preemption_init = a6xx_preemption_init,
 	.preemption_schedule = a6xx_preemption_schedule,
-	.preemption_set_marker = a6xx_preemption_set_marker,
+	.set_marker = a6xx_set_marker,
 	.preemption_context_init = a6xx_preemption_context_init,
 	.preemption_context_destroy = a6xx_preemption_context_destroy,
 	.gx_is_on = a6xx_gx_is_on,
 	.sptprac_is_on = a6xx_sptprac_is_on,
+	.ccu_invalidate = a6xx_ccu_invalidate,
 };
diff --git a/drivers/gpu/msm/adreno_a6xx.h b/drivers/gpu/msm/adreno_a6xx.h
index 02748a6..dd8af80 100644
--- a/drivers/gpu/msm/adreno_a6xx.h
+++ b/drivers/gpu/msm/adreno_a6xx.h
@@ -100,7 +100,7 @@
 		struct adreno_ringbuffer *rb,
 		unsigned int *cmds, struct kgsl_context *context);
 
-unsigned int a6xx_preemption_set_marker(unsigned int *cmds, int start);
+unsigned int a6xx_set_marker(unsigned int *cmds, int start);
 
 void a6xx_preemption_callback(struct adreno_device *adreno_dev, int bit);
 
@@ -110,6 +110,8 @@
 
 void a6xx_snapshot(struct adreno_device *adreno_dev,
 		struct kgsl_snapshot *snapshot);
+void a6xx_snapshot_gmu(struct adreno_device *adreno_dev,
+		struct kgsl_snapshot *snapshot);
 
 void a6xx_crashdump_init(struct adreno_device *adreno_dev);
 #endif
diff --git a/drivers/gpu/msm/adreno_a6xx_preempt.c b/drivers/gpu/msm/adreno_a6xx_preempt.c
index 00325e5..ca011e4 100644
--- a/drivers/gpu/msm/adreno_a6xx_preempt.c
+++ b/drivers/gpu/msm/adreno_a6xx_preempt.c
@@ -207,7 +207,11 @@
 	uint64_t ttbr0;
 	unsigned int contextidr;
 	unsigned long flags;
-	uint32_t preempt_level = 0, usesgmem = 1, skipsaverestore = 0;
+	uint32_t preempt_level, usesgmem, skipsaverestore;
+
+	preempt_level = adreno_dev->preempt_level;
+	usesgmem = adreno_dev->usesgmem;
+	skipsaverestore = adreno_dev->skipsaverestore;
 
 	/* Put ourselves into a possible trigger state */
 	if (!adreno_move_preempt_state(adreno_dev,
@@ -356,7 +360,7 @@
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_execution_enabled(adreno_dev))
 		return;
 
 	mutex_lock(&device->mutex);
@@ -369,7 +373,7 @@
 	mutex_unlock(&device->mutex);
 }
 
-unsigned int a6xx_preemption_set_marker(unsigned int *cmds, int start)
+unsigned int a6xx_set_marker(unsigned int *cmds, int start)
 {
 	*cmds++ = cp_type7_packet(CP_SET_MARKER, 1);
 
@@ -449,7 +453,7 @@
 	struct adreno_ringbuffer *rb;
 	unsigned int i;
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_execution_enabled(adreno_dev))
 		return;
 
 	/* Force the state to be clear */
@@ -627,10 +631,13 @@
 	struct kgsl_device *device = context->device;
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_setup_enabled(adreno_dev))
 		return;
 
 	gpumem_free_entry(context->user_ctxt_record);
+
+	/* Put the extra ref from gpumem_alloc_entry() */
+	kgsl_mem_entry_put(context->user_ctxt_record);
 }
 
 int a6xx_preemption_context_init(struct kgsl_context *context)
@@ -638,9 +645,13 @@
 	struct kgsl_device *device = context->device;
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 
-	if (!adreno_is_preemption_enabled(adreno_dev))
+	if (!adreno_is_preemption_setup_enabled(adreno_dev))
 		return 0;
 
+	/*
+	 * gpumem_alloc_entry takes an extra refcount. Put it only when
+	 * destroying the context to keep the context record valid
+	 */
 	context->user_ctxt_record = gpumem_alloc_entry(context->dev_priv,
 			A6XX_CP_CTXRECORD_USER_RESTORE_SIZE, 0);
 	if (IS_ERR(context->user_ctxt_record)) {
diff --git a/drivers/gpu/msm/adreno_a6xx_snapshot.c b/drivers/gpu/msm/adreno_a6xx_snapshot.c
index 80c9a61..e865f20 100644
--- a/drivers/gpu/msm/adreno_a6xx_snapshot.c
+++ b/drivers/gpu/msm/adreno_a6xx_snapshot.c
@@ -557,6 +557,7 @@
 	const unsigned int *regs;
 	unsigned int count;
 	const struct sel_reg *sel;
+	uint64_t offset;
 } a6xx_reg_list[] = {
 	{ a6xx_registers, ARRAY_SIZE(a6xx_registers) / 2, NULL },
 	{ a6xx_rb_rac_registers, ARRAY_SIZE(a6xx_rb_rac_registers) / 2,
@@ -569,64 +570,56 @@
 	(((_a)[(2 * (_i)) + 1] - (_a)[2 * (_i)]) + 1)
 
 static size_t a6xx_legacy_snapshot_registers(struct kgsl_device *device,
-		u8 *buf, size_t remain)
+		u8 *buf, size_t remain, struct reg_list *regs)
 {
-	unsigned int i;
-	size_t used = 0;
+	struct kgsl_snapshot_registers snapshot_regs = {
+		.regs = regs->regs,
+		.count = regs->count,
+	};
 
-	for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
-		struct reg_list *regs = &a6xx_reg_list[i];
-		struct kgsl_snapshot_registers snapshot_regs = {
-			.regs = regs->regs,
-			.count = regs->count,
-		};
+	if (regs->sel)
+		kgsl_regwrite(device, regs->sel->host_reg, regs->sel->val);
 
-		if (regs->sel)
-			kgsl_regwrite(device, regs->sel->host_reg,
-				regs->sel->val);
-		used += kgsl_snapshot_dump_registers(device, buf + used,
-						remain - used, &snapshot_regs);
-	}
-	return used;
+	return kgsl_snapshot_dump_registers(device, buf, remain,
+		&snapshot_regs);
 }
 
 static size_t a6xx_snapshot_registers(struct kgsl_device *device, u8 *buf,
 		size_t remain, void *priv)
 {
 	struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf;
+	struct reg_list *regs = (struct reg_list *)priv;
 	unsigned int *data = (unsigned int *)(buf + sizeof(*header));
-	unsigned int *src = (unsigned int *)a6xx_crashdump_registers.hostptr;
-	unsigned int i, j, k;
+	unsigned int *src;
+	unsigned int j, k;
 	unsigned int count = 0;
 
 	if (crash_dump_valid == false)
-		return a6xx_legacy_snapshot_registers(device, buf, remain);
+		return a6xx_legacy_snapshot_registers(device, buf, remain,
+			regs);
 
 	if (remain < sizeof(*header)) {
 		SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
 		return 0;
 	}
 
+	src = (unsigned int *)(a6xx_crashdump_registers.hostptr + regs->offset);
 	remain -= sizeof(*header);
 
-	for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
-		struct reg_list *regs = &a6xx_reg_list[i];
+	for (j = 0; j < regs->count; j++) {
+		unsigned int start = regs->regs[2 * j];
+		unsigned int end = regs->regs[(2 * j) + 1];
 
-		for (j = 0; j < regs->count; j++) {
-			unsigned int start = regs->regs[2 * j];
-			unsigned int end = regs->regs[(2 * j) + 1];
+		if (remain < ((end - start) + 1) * 8) {
+			SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
+			goto out;
+		}
 
-			if (remain < ((end - start) + 1) * 8) {
-				SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
-				goto out;
-			}
+		remain -= ((end - start) + 1) * 8;
 
-			remain -= ((end - start) + 1) * 8;
-
-			for (k = start; k <= end; k++, count++) {
-				*data++ = k;
-				*data++ = *src++;
-			}
+		for (k = start; k <= end; k++, count++) {
+			*data++ = k;
+			*data++ = *src++;
 		}
 	}
 
@@ -1366,6 +1359,7 @@
 		struct kgsl_snapshot *snapshot)
 {
 	int i;
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 
 	kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_CNTLT,
 		(0xf << A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT_SHIFT) |
@@ -1456,9 +1450,12 @@
 			(void *) &a6xx_dbgc_debugbus_blocks[i]);
 	}
 
-	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUGBUS,
-			snapshot, a6xx_snapshot_vbif_debugbus_block,
-			(void *) &a6xx_vbif_debugbus_blocks);
+	/* Skip if GPU has GBIF */
+	if (!adreno_has_gbif(adreno_dev))
+		kgsl_snapshot_add_section(device,
+				KGSL_SNAPSHOT_SECTION_DEBUGBUS,
+				snapshot, a6xx_snapshot_vbif_debugbus_block,
+				(void *) &a6xx_vbif_debugbus_blocks);
 
 	if (a6xx_cx_dbgc) {
 		for (i = 0; i < ARRAY_SIZE(a6xx_cx_dbgc_debugbus_blocks); i++) {
@@ -1471,10 +1468,18 @@
 	}
 }
 
-static void a6xx_snapshot_gmu(struct kgsl_device *device,
+/*
+ * a6xx_snapshot_gmu() - A6XX GMU snapshot function
+ * @adreno_dev: Device being snapshotted
+ * @snapshot: Pointer to the snapshot instance
+ *
+ * This is where all of the A6XX GMU specific bits and pieces are grabbed
+ * into the snapshot memory
+ */
+void a6xx_snapshot_gmu(struct adreno_device *adreno_dev,
 		struct kgsl_snapshot *snapshot)
 {
-	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
 
 	if (!kgsl_gmu_isenabled(device))
@@ -1519,6 +1524,8 @@
 
 	crash_dump_valid = false;
 
+	if (!device->snapshot_crashdumper)
+		return;
 	if (a6xx_capturescript.gpuaddr == 0 ||
 		a6xx_crashdump_registers.gpuaddr == 0)
 		return;
@@ -1570,33 +1577,38 @@
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
 	struct adreno_snapshot_data *snap_data = gpudev->snapshot_data;
 	bool sptprac_on;
+	unsigned int i;
+
+	/* Make sure the fence is in ALLOW mode so registers can be read */
+	kgsl_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
 
 	/* GMU TCM data dumped through AHB */
-	a6xx_snapshot_gmu(device, snapshot);
+	a6xx_snapshot_gmu(adreno_dev, snapshot);
 
 	sptprac_on = gpudev->sptprac_is_on(adreno_dev);
 
 	/* Return if the GX is off */
-	if (!gpudev->gx_is_on(adreno_dev)) {
-		pr_err("GX is off. Only dumping GMU data in snapshot\n");
+	if (!gpudev->gx_is_on(adreno_dev))
 		return;
-	}
 
 	/* Dump the registers which get affected by crash dumper trigger */
 	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
 		snapshot, a6xx_snapshot_pre_crashdump_regs, NULL);
 
 	/* Dump vbif registers as well which get affected by crash dumper */
-	adreno_snapshot_vbif_registers(device, snapshot,
-		a6xx_vbif_snapshot_registers,
-		ARRAY_SIZE(a6xx_vbif_snapshot_registers));
+	if (!adreno_has_gbif(adreno_dev))
+		adreno_snapshot_vbif_registers(device, snapshot,
+			a6xx_vbif_snapshot_registers,
+			ARRAY_SIZE(a6xx_vbif_snapshot_registers));
 
 	/* Try to run the crash dumper */
 	if (sptprac_on)
 		_a6xx_do_crashdump(device);
 
-	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
-		snapshot, a6xx_snapshot_registers, NULL);
+	for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
+		kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
+			snapshot, a6xx_snapshot_registers, &a6xx_reg_list[i]);
+	}
 
 	/* CP_SQE indexed registers */
 	kgsl_snapshot_indexed_registers(device, snapshot,
@@ -1920,6 +1932,8 @@
 	for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
 		struct reg_list *regs = &a6xx_reg_list[i];
 
+		regs->offset = offset;
+
 		/* Program the SEL_CNTL_CD register appropriately */
 		if (regs->sel) {
 			*ptr++ = regs->sel->val;
diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c
index 8fd8b88..cb42a70 100644
--- a/drivers/gpu/msm/adreno_dispatch.c
+++ b/drivers/gpu/msm/adreno_dispatch.c
@@ -2046,7 +2046,7 @@
 	kfree(replay);
 }
 
-static void do_header_and_snapshot(struct kgsl_device *device,
+static void do_header_and_snapshot(struct kgsl_device *device, int fault,
 		struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj)
 {
 	struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
@@ -2054,7 +2054,7 @@
 	/* Always dump the snapshot on a non-drawobj failure */
 	if (cmdobj == NULL) {
 		adreno_fault_header(device, rb, NULL);
-		kgsl_device_snapshot(device, NULL);
+		kgsl_device_snapshot(device, NULL, fault & ADRENO_GMU_FAULT);
 		return;
 	}
 
@@ -2066,7 +2066,8 @@
 	adreno_fault_header(device, rb, cmdobj);
 
 	if (!(drawobj->context->flags & KGSL_CONTEXT_NO_SNAPSHOT))
-		kgsl_device_snapshot(device, drawobj->context);
+		kgsl_device_snapshot(device, drawobj->context,
+					fault & ADRENO_GMU_FAULT);
 }
 
 static int dispatcher_do_fault(struct adreno_device *adreno_dev)
@@ -2078,7 +2079,7 @@
 	struct adreno_ringbuffer *rb;
 	struct adreno_ringbuffer *hung_rb = NULL;
 	unsigned int reg;
-	uint64_t base;
+	uint64_t base = 0;
 	struct kgsl_drawobj_cmd *cmdobj = NULL;
 	int ret, i;
 	int fault;
@@ -2139,7 +2140,7 @@
 	 * Deleting uninitialized timer will block for ever on kernel debug
 	 * disable build. Hence skip del timer if it is not initialized.
 	 */
-	if (adreno_is_preemption_enabled(adreno_dev))
+	if (adreno_is_preemption_execution_enabled(adreno_dev))
 		del_timer_sync(&adreno_dev->preempt.timer);
 
 	mutex_lock(&device->mutex);
@@ -2192,7 +2193,7 @@
 		adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB1_BASE,
 			ADRENO_REG_CP_IB1_BASE_HI, &base);
 
-	do_header_and_snapshot(device, hung_rb, cmdobj);
+	do_header_and_snapshot(device, fault, hung_rb, cmdobj);
 
 	/* Turn off the KEEPALIVE vote from the ISR for hard fault */
 	if (gpudev->gpu_keepalive && fault & ADRENO_HARD_FAULT)
diff --git a/drivers/gpu/msm/adreno_drawctxt.c b/drivers/gpu/msm/adreno_drawctxt.c
index 0882447..2615d44 100644
--- a/drivers/gpu/msm/adreno_drawctxt.c
+++ b/drivers/gpu/msm/adreno_drawctxt.c
@@ -533,7 +533,8 @@
 				drawctxt->internal_timestamp,
 				drawctxt->type, ret);
 		device->force_panic = 1;
-		kgsl_device_snapshot(device, context);
+		kgsl_device_snapshot(device, context,
+				adreno_gmu_gpu_fault(adreno_dev));
 	}
 
 	kgsl_sharedmem_writel(device, &device->memstore,
diff --git a/drivers/gpu/msm/adreno_ioctl.c b/drivers/gpu/msm/adreno_ioctl.c
index 7c7bfa5..8b283ae 100644
--- a/drivers/gpu/msm/adreno_ioctl.c
+++ b/drivers/gpu/msm/adreno_ioctl.c
@@ -96,7 +96,7 @@
 	int levels_to_copy;
 
 	if (!adreno_is_a5xx(adreno_dev) ||
-		!adreno_is_preemption_enabled(adreno_dev))
+		!adreno_is_preemption_execution_enabled(adreno_dev))
 		return -EOPNOTSUPP;
 
 	if (read->size_user < size_level)
diff --git a/drivers/gpu/msm/adreno_perfcounter.c b/drivers/gpu/msm/adreno_perfcounter.c
index 0da4da9..9ea8069 100644
--- a/drivers/gpu/msm/adreno_perfcounter.c
+++ b/drivers/gpu/msm/adreno_perfcounter.c
@@ -28,6 +28,20 @@
 /* offset of enable register from select register */
 #define VBIF2_PERF_EN_REG_SEL_OFF 16
 
+/* offset of clear register from select register for GBIF */
+#define GBIF_PERF_CLR_REG_SEL_OFF 1
+
+/* offset of enable register from select register for GBIF*/
+#define GBIF_PERF_EN_REG_SEL_OFF  2
+
+/* offset of clear register from the power enable register for GBIF*/
+#define GBIF_PWR_CLR_REG_EN_OFF    1
+
+/* */
+#define GBIF_PERF_RMW_MASK   0xFF
+/* */
+#define GBIF_PWR_RMW_MASK    0x10000
+
 /* offset of clear register from the enable register */
 #define VBIF2_PERF_PWR_CLR_REG_EN_OFF 8
 
@@ -160,10 +174,15 @@
 	struct adreno_perfcounters *counters = ADRENO_PERFCOUNTERS(adreno_dev);
 	struct adreno_perfcount_group *group;
 	unsigned int counter, groupid;
+	int ret;
 
 	if (counters == NULL)
 		return;
 
+	ret = adreno_perfcntr_active_oob_get(adreno_dev);
+	if (ret)
+		return;
+
 	for (groupid = 0; groupid < counters->group_count; groupid++) {
 		group = &(counters->groups[groupid]);
 
@@ -183,6 +202,8 @@
 								counter);
 		}
 	}
+
+	adreno_perfcntr_active_oob_put(adreno_dev);
 }
 
 static int adreno_perfcounter_enable(struct adreno_device *adreno_dev,
@@ -612,14 +633,41 @@
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 	struct adreno_perfcount_register *reg;
+	unsigned int shift = counter << 3;
 
 	reg = &counters->groups[KGSL_PERFCOUNTER_GROUP_VBIF].regs[counter];
-	/* Write 1, followed by 0 to CLR register for clearing the counter */
-	kgsl_regwrite(device, reg->select - VBIF2_PERF_CLR_REG_SEL_OFF, 1);
-	kgsl_regwrite(device, reg->select - VBIF2_PERF_CLR_REG_SEL_OFF, 0);
-	kgsl_regwrite(device, reg->select, countable & VBIF2_PERF_CNT_SEL_MASK);
-	/* enable reg is 8 DWORDS before select reg */
-	kgsl_regwrite(device, reg->select - VBIF2_PERF_EN_REG_SEL_OFF, 1);
+
+	if (adreno_has_gbif(adreno_dev)) {
+		/*
+		 * Write 1, followed by 0 to CLR register for
+		 * clearing the counter
+		 */
+		kgsl_regrmw(device, reg->select - GBIF_PERF_CLR_REG_SEL_OFF,
+			1 << counter, 1);
+		kgsl_regrmw(device, reg->select - GBIF_PERF_CLR_REG_SEL_OFF,
+			1 << counter, 0);
+		/* select the desired countable */
+		kgsl_regrmw(device, reg->select,
+			GBIF_PERF_RMW_MASK << shift, countable << shift);
+		/* enable counter */
+		kgsl_regrmw(device, reg->select - GBIF_PERF_EN_REG_SEL_OFF,
+			1 << counter, 1);
+
+	} else {
+		/*
+		 * Write 1, followed by 0 to CLR register for
+		 * clearing the counter
+		 */
+		kgsl_regwrite(device,
+			reg->select - VBIF2_PERF_CLR_REG_SEL_OFF, 1);
+		kgsl_regwrite(device,
+			reg->select - VBIF2_PERF_CLR_REG_SEL_OFF, 0);
+		kgsl_regwrite(device,
+			reg->select, countable & VBIF2_PERF_CNT_SEL_MASK);
+		/* enable reg is 8 DWORDS before select reg */
+		kgsl_regwrite(device,
+			reg->select - VBIF2_PERF_EN_REG_SEL_OFF, 1);
+	}
 	reg->value = 0;
 }
 
@@ -630,10 +678,30 @@
 	struct adreno_perfcount_register *reg;
 
 	reg = &counters->groups[KGSL_PERFCOUNTER_GROUP_VBIF_PWR].regs[counter];
-	/* Write 1, followed by 0 to CLR register for clearing the counter */
-	kgsl_regwrite(device, reg->select + VBIF2_PERF_PWR_CLR_REG_EN_OFF, 1);
-	kgsl_regwrite(device, reg->select + VBIF2_PERF_PWR_CLR_REG_EN_OFF, 0);
-	kgsl_regwrite(device, reg->select, 1);
+
+	if (adreno_has_gbif(adreno_dev)) {
+		/*
+		 * Write 1, followed by 0 to CLR register for
+		 * clearing the counter
+		 */
+		kgsl_regrmw(device, reg->select + GBIF_PWR_CLR_REG_EN_OFF,
+			GBIF_PWR_RMW_MASK << counter, 1);
+		kgsl_regrmw(device, reg->select + GBIF_PWR_CLR_REG_EN_OFF,
+			GBIF_PWR_RMW_MASK << counter, 0);
+		/* Enable the counter */
+		kgsl_regrmw(device, reg->select,
+			GBIF_PWR_RMW_MASK << counter, 1);
+	} else {
+		/*
+		 * Write 1, followed by 0 to CLR register for
+		 * clearing the counter
+		 */
+		kgsl_regwrite(device, reg->select +
+			VBIF2_PERF_PWR_CLR_REG_EN_OFF, 1);
+		kgsl_regwrite(device, reg->select +
+			VBIF2_PERF_PWR_CLR_REG_EN_OFF, 0);
+		kgsl_regwrite(device, reg->select, 1);
+	}
 	reg->value = 0;
 }
 
diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c
index 15c68fb..d248479 100644
--- a/drivers/gpu/msm/adreno_ringbuffer.c
+++ b/drivers/gpu/msm/adreno_ringbuffer.c
@@ -25,6 +25,7 @@
 #include "adreno_iommu.h"
 #include "adreno_pm4types.h"
 #include "adreno_ringbuffer.h"
+#include "adreno_trace.h"
 
 #include "a3xx_reg.h"
 #include "adreno_a5xx.h"
@@ -37,6 +38,7 @@
 	((_rb)->buffer_desc.gpuaddr + ((_pos) * sizeof(unsigned int)))
 
 static void adreno_get_submit_time(struct adreno_device *adreno_dev,
+		struct adreno_ringbuffer *rb,
 		struct adreno_submit_time *time)
 {
 	unsigned long flags;
@@ -66,6 +68,9 @@
 	} else
 		time->ticks = 0;
 
+	/* Trace the GPU time to create a mapping to ftrace time */
+	trace_adreno_cmdbatch_sync(rb->drawctxt_active, time->ticks);
+
 	/* Get the kernel clock for time since boot */
 	time->ktime = local_clock();
 
@@ -78,10 +83,12 @@
 /*
  * Wait time before trying to write the register again.
  * Hopefully the GMU has finished waking up during this delay.
+ * This delay must be less than the IFPC main hysteresis or
+ * the GMU will start shutting down before we try again.
  */
-#define GMU_WAKEUP_DELAY 50
+#define GMU_WAKEUP_DELAY 20
 /* Max amount of tries to wake up the GMU. */
-#define GMU_WAKEUP_RETRY_MAX 20
+#define GMU_WAKEUP_RETRY_MAX 60
 
 /*
  * Check the WRITEDROPPED0 bit in the
@@ -148,7 +155,7 @@
 	struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
 
 	if (time != NULL)
-		adreno_get_submit_time(adreno_dev, time);
+		adreno_get_submit_time(adreno_dev, rb, time);
 
 	adreno_ringbuffer_wptr(adreno_dev, rb);
 }
@@ -284,7 +291,7 @@
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
 	int i;
 
-	if (nopreempt == false && ADRENO_FEATURE(adreno_dev, ADRENO_PREEMPTION))
+	if (nopreempt == false)
 		adreno_dev->num_ringbuffers = gpudev->num_prio_levels;
 	else
 		adreno_dev->num_ringbuffers = 1;
@@ -473,11 +480,11 @@
 		total_sizedwords += 4;
 
 	if (gpudev->preemption_pre_ibsubmit &&
-				adreno_is_preemption_enabled(adreno_dev))
+			adreno_is_preemption_execution_enabled(adreno_dev))
 		total_sizedwords += 22;
 
 	if (gpudev->preemption_post_ibsubmit &&
-				adreno_is_preemption_enabled(adreno_dev))
+			adreno_is_preemption_execution_enabled(adreno_dev))
 		total_sizedwords += 5;
 
 	/*
@@ -523,7 +530,7 @@
 	*ringcmds++ = cp_packet(adreno_dev, CP_NOP, 1);
 	*ringcmds++ = KGSL_CMD_IDENTIFIER;
 
-	if (adreno_is_preemption_enabled(adreno_dev) &&
+	if (adreno_is_preemption_execution_enabled(adreno_dev) &&
 				gpudev->preemption_pre_ibsubmit)
 		ringcmds += gpudev->preemption_pre_ibsubmit(
 					adreno_dev, rb, ringcmds, context);
@@ -660,7 +667,7 @@
 		ringcmds += cp_secure_mode(adreno_dev, ringcmds, 0);
 
 	if (gpudev->preemption_post_ibsubmit &&
-				adreno_is_preemption_enabled(adreno_dev))
+			adreno_is_preemption_execution_enabled(adreno_dev))
 		ringcmds += gpudev->preemption_post_ibsubmit(adreno_dev,
 			ringcmds);
 
@@ -864,13 +871,17 @@
 			dwords += 2;
 	}
 
-	if (adreno_is_preemption_enabled(adreno_dev)) {
-		if (gpudev->preemption_set_marker)
-			dwords += 4;
-		else if (gpudev->preemption_yield_enable)
+	if (adreno_is_preemption_execution_enabled(adreno_dev)) {
+		if (gpudev->preemption_yield_enable)
 			dwords += 8;
 	}
 
+	if (gpudev->set_marker)
+		dwords += 4;
+
+	if (gpudev->ccu_invalidate)
+		dwords += 4;
+
 	link = kcalloc(dwords, sizeof(unsigned int), GFP_KERNEL);
 	if (!link) {
 		ret = -ENOMEM;
@@ -900,9 +911,8 @@
 			gpu_ticks_submitted));
 	}
 
-	if (gpudev->preemption_set_marker &&
-			adreno_is_preemption_enabled(adreno_dev))
-		cmds += gpudev->preemption_set_marker(cmds, 1);
+	if (gpudev->set_marker)
+		cmds += gpudev->set_marker(cmds, 1);
 
 	if (numibs) {
 		list_for_each_entry(ib, &cmdobj->cmdlist, node) {
@@ -925,10 +935,14 @@
 		}
 	}
 
-	if (adreno_is_preemption_enabled(adreno_dev)) {
-		if (gpudev->preemption_set_marker)
-			cmds += gpudev->preemption_set_marker(cmds, 0);
-		else if (gpudev->preemption_yield_enable)
+	if (gpudev->ccu_invalidate)
+		cmds += gpudev->ccu_invalidate(adreno_dev, cmds);
+
+	if (gpudev->set_marker)
+		cmds += gpudev->set_marker(cmds, 0);
+
+	if (adreno_is_preemption_execution_enabled(adreno_dev)) {
+		if (gpudev->preemption_yield_enable)
 			cmds += gpudev->preemption_yield_enable(cmds);
 	}
 
diff --git a/drivers/gpu/msm/adreno_snapshot.c b/drivers/gpu/msm/adreno_snapshot.c
index 0840aba..b5999e6 100644
--- a/drivers/gpu/msm/adreno_snapshot.c
+++ b/drivers/gpu/msm/adreno_snapshot.c
@@ -945,6 +945,24 @@
 
 }
 
+/* adreno_snapshot_gmu - Snapshot the Adreno GMU state
+ * @device - KGSL device to snapshot
+ * @snapshot - Pointer to the snapshot instance
+ * This is a hook function called by kgsl_snapshot to snapshot the
+ * Adreno specific information for the GMU snapshot.  In turn, this function
+ * calls the GMU specific snapshot function to get core specific information.
+ */
+void adreno_snapshot_gmu(struct kgsl_device *device,
+		struct kgsl_snapshot *snapshot)
+{
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+
+	/* Add GMU specific sections */
+	if (gpudev->snapshot_gmu)
+		gpudev->snapshot_gmu(adreno_dev, snapshot);
+}
+
 /*
  * adreno_snapshot_cp_roq - Dump CP merciu data in snapshot
  * @device: Device being snapshotted
diff --git a/drivers/gpu/msm/adreno_sysfs.c b/drivers/gpu/msm/adreno_sysfs.c
index 89ea1d9..704e79e 100644
--- a/drivers/gpu/msm/adreno_sysfs.c
+++ b/drivers/gpu/msm/adreno_sysfs.c
@@ -51,6 +51,43 @@
 	return adreno_dev->ft_policy;
 }
 
+static int _preempt_level_store(struct adreno_device *adreno_dev,
+		unsigned int val)
+{
+	if (val <= 2)
+		adreno_dev->preempt_level = val;
+	return 0;
+}
+
+static unsigned int _preempt_level_show(struct adreno_device *adreno_dev)
+{
+	return adreno_dev->preempt_level;
+}
+
+static int _usesgmem_store(struct adreno_device *adreno_dev,
+		unsigned int val)
+{
+	adreno_dev->usesgmem = val ? 1 : 0;
+	return 0;
+}
+
+static unsigned int _usesgmem_show(struct adreno_device *adreno_dev)
+{
+	return adreno_dev->usesgmem;
+}
+
+static int _skipsaverestore_store(struct adreno_device *adreno_dev,
+		unsigned int val)
+{
+	adreno_dev->skipsaverestore = val ? 1 : 0;
+	return 0;
+}
+
+static unsigned int _skipsaverestore_show(struct adreno_device *adreno_dev)
+{
+	return adreno_dev->skipsaverestore;
+}
+
 static int _ft_pagefault_policy_store(struct adreno_device *adreno_dev,
 		unsigned int val)
 {
@@ -128,7 +165,6 @@
 
 	if (test_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv)) {
 		kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
-		adreno_irqctrl(adreno_dev, 1);
 	} else if (device->state == KGSL_STATE_INIT) {
 		ret = -EACCES;
 		change_bit(ADRENO_DEVICE_HANG_INTR, &adreno_dev->priv);
@@ -168,13 +204,14 @@
 {
 	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
 
-	if (test_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv) == val)
+	if (test_bit(ADRENO_DEVICE_PREEMPTION_EXECUTION,
+		&adreno_dev->priv) == val)
 		return 0;
 
 	mutex_lock(&device->mutex);
 
 	kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);
-	change_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv);
+	change_bit(ADRENO_DEVICE_PREEMPTION_EXECUTION, &adreno_dev->priv);
 	adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]);
 	kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER);
 
@@ -183,9 +220,26 @@
 	return 0;
 }
 
+static int _gmu_idle_level_store(struct adreno_device *adreno_dev,
+		unsigned int val)
+{
+	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
+	struct gmu_device *gmu = &device->gmu;
+
+	mutex_lock(&device->mutex);
+
+	/* Power down the GPU before changing the idle level */
+	kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);
+	gmu->idle_level = val;
+	kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER);
+
+	mutex_unlock(&device->mutex);
+	return 0;
+}
+
 static unsigned int _preemption_show(struct adreno_device *adreno_dev)
 {
-	return adreno_is_preemption_enabled(adreno_dev);
+	return adreno_is_preemption_execution_enabled(adreno_dev);
 }
 
 static int _hwcg_store(struct adreno_device *adreno_dev,
@@ -231,6 +285,40 @@
 	return test_bit(ADRENO_LM_CTRL, &adreno_dev->pwrctrl_flag);
 }
 
+static int _ifpc_store(struct adreno_device *adreno_dev, unsigned int val)
+{
+	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
+	struct gmu_device *gmu = &device->gmu;
+	unsigned int requested_idle_level;
+
+	if (!kgsl_gmu_isenabled(device) ||
+			!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
+		return -EINVAL;
+
+	if ((val && gmu->idle_level >= GPU_HW_IFPC) ||
+			(!val && gmu->idle_level < GPU_HW_IFPC))
+		return 0;
+
+	if (val)
+		requested_idle_level = GPU_HW_IFPC;
+	else {
+		if (ADRENO_FEATURE(adreno_dev, ADRENO_SPTP_PC))
+			requested_idle_level = GPU_HW_SPTP_PC;
+		else
+			requested_idle_level = GPU_HW_ACTIVE;
+	}
+
+	return _gmu_idle_level_store(adreno_dev, requested_idle_level);
+}
+
+static unsigned int _ifpc_show(struct adreno_device *adreno_dev)
+{
+	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
+	struct gmu_device *gmu = &device->gmu;
+
+	return kgsl_gmu_isenabled(device) && gmu->idle_level >= GPU_HW_IFPC;
+}
+
 static ssize_t _sysfs_store_u32(struct device *dev,
 		struct device_attribute *attr,
 		const char *buf, size_t count)
@@ -313,6 +401,9 @@
 
 static ADRENO_SYSFS_U32(ft_policy);
 static ADRENO_SYSFS_U32(ft_pagefault_policy);
+static ADRENO_SYSFS_U32(preempt_level);
+static ADRENO_SYSFS_BOOL(usesgmem);
+static ADRENO_SYSFS_BOOL(skipsaverestore);
 static ADRENO_SYSFS_BOOL(ft_long_ib_detect);
 static ADRENO_SYSFS_BOOL(ft_hang_intr_status);
 static ADRENO_SYSFS_BOOL(gpu_llc_slice_enable);
@@ -326,6 +417,7 @@
 static ADRENO_SYSFS_BOOL(preemption);
 static ADRENO_SYSFS_BOOL(hwcg);
 static ADRENO_SYSFS_BOOL(throttling);
+static ADRENO_SYSFS_BOOL(ifpc);
 
 
 
@@ -343,6 +435,10 @@
 	&adreno_attr_throttling.attr,
 	&adreno_attr_gpu_llc_slice_enable.attr,
 	&adreno_attr_gpuhtw_llc_slice_enable.attr,
+	&adreno_attr_preempt_level.attr,
+	&adreno_attr_usesgmem.attr,
+	&adreno_attr_skipsaverestore.attr,
+	&adreno_attr_ifpc.attr,
 	NULL,
 };
 
diff --git a/drivers/gpu/msm/adreno_trace.h b/drivers/gpu/msm/adreno_trace.h
index 7bc4c93..e33060a 100644
--- a/drivers/gpu/msm/adreno_trace.h
+++ b/drivers/gpu/msm/adreno_trace.h
@@ -148,6 +148,29 @@
 	)
 );
 
+TRACE_EVENT(adreno_cmdbatch_sync,
+	TP_PROTO(struct adreno_context *drawctxt,
+		uint64_t ticks),
+	TP_ARGS(drawctxt, ticks),
+	TP_STRUCT__entry(
+		__field(unsigned int, id)
+		__field(unsigned int, timestamp)
+		__field(uint64_t, ticks)
+		__field(int, prio)
+	),
+	TP_fast_assign(
+		__entry->id = drawctxt->base.id;
+		__entry->timestamp = drawctxt->timestamp;
+		__entry->ticks = ticks;
+		__entry->prio = drawctxt->base.priority;
+	),
+	TP_printk(
+		"ctx=%u ctx_prio=%d ts=%u ticks=%lld",
+			__entry->id, __entry->prio, __entry->timestamp,
+			__entry->ticks
+	)
+);
+
 TRACE_EVENT(adreno_cmdbatch_fault,
 	TP_PROTO(struct kgsl_drawobj_cmd *cmdobj, unsigned int fault),
 	TP_ARGS(cmdobj, fault),
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 9968d8c..0a7d165 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -2280,7 +2280,7 @@
 		struct kgsl_mem_entry *entry,
 		struct kgsl_gpuobj_import *param)
 {
-	struct kgsl_gpuobj_import_useraddr useraddr;
+	struct kgsl_gpuobj_import_useraddr useraddr = {0};
 	int ret;
 
 	param->flags &= KGSL_MEMFLAGS_GPUREADONLY
@@ -3471,7 +3471,7 @@
 	struct sparse_bind_object *new;
 	struct rb_node **node, *parent = NULL;
 
-	new = kzalloc(sizeof(*new), GFP_KERNEL);
+	new = kzalloc(sizeof(*new), GFP_ATOMIC);
 	if (new == NULL)
 		return -ENOMEM;
 
@@ -3505,7 +3505,6 @@
 		struct sparse_bind_object *obj,
 		uint64_t v_offset, uint64_t size)
 {
-	spin_lock(&entry->bind_lock);
 	if (v_offset == obj->v_off && size >= obj->size) {
 		/*
 		 * We are all encompassing, remove the entry and free
@@ -3538,7 +3537,6 @@
 
 		obj->size = v_offset - obj->v_off;
 
-		spin_unlock(&entry->bind_lock);
 		ret = _sparse_add_to_bind_tree(entry, v_offset + size,
 				obj->p_memdesc,
 				obj->p_off + (v_offset - obj->v_off) + size,
@@ -3548,11 +3546,10 @@
 		return ret;
 	}
 
-	spin_unlock(&entry->bind_lock);
-
 	return 0;
 }
 
+/* entry->bind_lock must be held by the caller */
 static struct sparse_bind_object *_find_containing_bind_obj(
 		struct kgsl_mem_entry *entry,
 		uint64_t offset, uint64_t size)
@@ -3560,8 +3557,6 @@
 	struct sparse_bind_object *obj = NULL;
 	struct rb_node *node = entry->bind_tree.rb_node;
 
-	spin_lock(&entry->bind_lock);
-
 	while (node != NULL) {
 		obj = rb_entry(node, struct sparse_bind_object, node);
 
@@ -3580,33 +3575,16 @@
 		}
 	}
 
-	spin_unlock(&entry->bind_lock);
-
 	return obj;
 }
 
+/* entry->bind_lock must be held by the caller */
 static int _sparse_unbind(struct kgsl_mem_entry *entry,
 		struct sparse_bind_object *bind_obj,
 		uint64_t offset, uint64_t size)
 {
-	struct kgsl_memdesc *memdesc = bind_obj->p_memdesc;
-	struct kgsl_pagetable *pt = memdesc->pagetable;
 	int ret;
 
-	if (memdesc->cur_bindings < (size / PAGE_SIZE))
-		return -EINVAL;
-
-	memdesc->cur_bindings -= size / PAGE_SIZE;
-
-	ret = kgsl_mmu_unmap_offset(pt, memdesc,
-			entry->memdesc.gpuaddr, offset, size);
-	if (ret)
-		return ret;
-
-	ret = kgsl_mmu_sparse_dummy_map(pt, &entry->memdesc, offset, size);
-	if (ret)
-		return ret;
-
 	ret = _sparse_rm_from_bind_tree(entry, bind_obj, offset, size);
 	if (ret == 0) {
 		atomic_long_sub(size, &kgsl_driver.stats.mapped);
@@ -3620,6 +3598,8 @@
 	struct kgsl_mem_entry *virt_entry)
 {
 	struct sparse_bind_object *bind_obj;
+	struct kgsl_memdesc *memdesc;
+	struct kgsl_pagetable *pt;
 	int ret = 0;
 	uint64_t size = obj->size;
 	uint64_t tmp_size = obj->size;
@@ -3627,9 +3607,14 @@
 
 	while (size > 0 && ret == 0) {
 		tmp_size = size;
+
+		spin_lock(&virt_entry->bind_lock);
 		bind_obj = _find_containing_bind_obj(virt_entry, offset, size);
-		if (bind_obj == NULL)
+
+		if (bind_obj == NULL) {
+			spin_unlock(&virt_entry->bind_lock);
 			return 0;
+		}
 
 		if (bind_obj->v_off > offset) {
 			tmp_size = size - bind_obj->v_off - offset;
@@ -3646,7 +3631,28 @@
 				tmp_size = bind_obj->size;
 		}
 
+		memdesc = bind_obj->p_memdesc;
+		pt = memdesc->pagetable;
+
+		if (memdesc->cur_bindings < (tmp_size / PAGE_SIZE)) {
+			spin_unlock(&virt_entry->bind_lock);
+			return -EINVAL;
+		}
+
+		memdesc->cur_bindings -= tmp_size / PAGE_SIZE;
+
 		ret = _sparse_unbind(virt_entry, bind_obj, offset, tmp_size);
+		spin_unlock(&virt_entry->bind_lock);
+
+		ret = kgsl_mmu_unmap_offset(pt, memdesc,
+				virt_entry->memdesc.gpuaddr, offset, tmp_size);
+		if (ret)
+			return ret;
+
+		ret = kgsl_mmu_sparse_dummy_map(pt, memdesc, offset, tmp_size);
+		if (ret)
+			return ret;
+
 		if (ret == 0) {
 			offset += tmp_size;
 			size -= tmp_size;
diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h
index 2cc1869..0ab775a 100644
--- a/drivers/gpu/msm/kgsl_device.h
+++ b/drivers/gpu/msm/kgsl_device.h
@@ -151,6 +151,8 @@
 	unsigned int (*gpuid)(struct kgsl_device *device, unsigned int *chipid);
 	void (*snapshot)(struct kgsl_device *device,
 		struct kgsl_snapshot *snapshot, struct kgsl_context *context);
+	void (*snapshot_gmu)(struct kgsl_device *device,
+		struct kgsl_snapshot *snapshot);
 	irqreturn_t (*irq_handler)(struct kgsl_device *device);
 	int (*drain)(struct kgsl_device *device);
 	/*
@@ -493,7 +495,9 @@
  * @work: worker to dump the frozen memory
  * @dump_gate: completion gate signaled by worker when it is finished.
  * @process: the process that caused the hang, if known.
- * @sysfs_read: An atomic for concurrent snapshot reads via syfs.
+ * @sysfs_read: Count of current reads via sysfs
+ * @first_read: True until the snapshot read is started
+ * @gmu_fault: Snapshot collected when GMU fault happened
  */
 struct kgsl_snapshot {
 	uint64_t ib1base;
@@ -514,7 +518,9 @@
 	struct work_struct work;
 	struct completion dump_gate;
 	struct kgsl_process_private *process;
-	atomic_t sysfs_read;
+	unsigned int sysfs_read;
+	bool first_read;
+	bool gmu_fault;
 };
 
 /**
@@ -700,9 +706,8 @@
 
 int kgsl_device_snapshot_init(struct kgsl_device *device);
 void kgsl_device_snapshot(struct kgsl_device *device,
-			struct kgsl_context *context);
+			struct kgsl_context *context, bool gmu_fault);
 void kgsl_device_snapshot_close(struct kgsl_device *device);
-void kgsl_snapshot_save_frozen_objs(struct work_struct *work);
 
 void kgsl_events_init(void);
 void kgsl_events_exit(void);
diff --git a/drivers/gpu/msm/kgsl_gmu.c b/drivers/gpu/msm/kgsl_gmu.c
index 29814a0..78ef8e5 100644
--- a/drivers/gpu/msm/kgsl_gmu.c
+++ b/drivers/gpu/msm/kgsl_gmu.c
@@ -456,11 +456,12 @@
 			GMU_DCVS_NOHFI, perf_idx, bw_idx);
 
 		if (ret) {
-			dev_err(&gmu->pdev->dev,
+			dev_err_ratelimited(&gmu->pdev->dev,
 				"Failed to set GPU perf idx %d, bw idx %d\n",
 				perf_idx, bw_idx);
 
-			gmu_snapshot(device);
+			adreno_set_gpu_fault(adreno_dev, ADRENO_GMU_FAULT);
+			adreno_dispatcher_schedule(device);
 		}
 
 		return ret;
@@ -504,9 +505,10 @@
 	unsigned int len;
 
 	len = cmd_db_get_aux_data_len(res_id);
+	if (len == 0)
+		return -EINVAL;
 
 	if (len > (MAX_GX_LEVELS << 1)) {
-		/* CmdDB VLVL table size in bytes is too large */
 		dev_err(&gmu->pdev->dev,
 			"gfx cmddb size %d larger than alloc buf %d of %s\n",
 			len, (MAX_GX_LEVELS << 1), res_id);
@@ -514,8 +516,16 @@
 	}
 
 	cmd_db_get_aux_data(res_id, (uint8_t *)arc->val, len);
-	for (arc->num = 1; arc->num <= MAX_GX_LEVELS; arc->num++) {
-		if (arc->num == MAX_GX_LEVELS ||
+
+	/*
+	 * cmd_db_get_aux_data() gives us a zero-padded table of
+	 * size len that contains the arc values. To determine the
+	 * number of arc values, we loop through the table and count
+	 * them until we get to the end of the buffer or hit the
+	 * zero padding.
+	 */
+	for (arc->num = 1; arc->num <= len; arc->num++) {
+		if (arc->num == len ||
 				arc->val[arc->num - 1] >= arc->val[arc->num])
 			break;
 	}
@@ -862,7 +872,7 @@
 	return 0;
 }
 
-static int gmu_reg_probe(struct gmu_device *gmu, const char *name)
+static int gmu_reg_probe(struct gmu_device *gmu, const char *name, bool is_gmu)
 {
 	struct resource *res;
 
@@ -880,7 +890,7 @@
 		return -EINVAL;
 	}
 
-	if (!strcmp(name, "kgsl_gmu_reg")) {
+	if (is_gmu) {
 		gmu->reg_phys = res->start;
 		gmu->reg_len = resource_size(res);
 		gmu->reg_virt = devm_ioremap(&gmu->pdev->dev, res->start,
@@ -891,20 +901,13 @@
 			return -ENODEV;
 		}
 
-	} else if (!strcmp(name, "kgsl_gmu_pdc_reg")) {
+	} else {
 		gmu->pdc_reg_virt = devm_ioremap(&gmu->pdev->dev, res->start,
 				resource_size(res));
 		if (gmu->pdc_reg_virt == NULL) {
 			dev_err(&gmu->pdev->dev, "PDC regs ioremap failed\n");
 			return -ENODEV;
 		}
-	} else if (!strcmp(name, "kgsl_gmu_cpr_reg")) {
-		gmu->cpr_reg_virt = devm_ioremap(&gmu->pdev->dev, res->start,
-				resource_size(res));
-		if (gmu->cpr_reg_virt == NULL) {
-			dev_err(&gmu->pdev->dev, "CPR regs ioremap failed\n");
-			return -ENODEV;
-		}
 	}
 
 	return 0;
@@ -1125,15 +1128,11 @@
 	mem_addr = gmu->hfi_mem;
 
 	/* Map and reserve GMU CSRs registers */
-	ret = gmu_reg_probe(gmu, "kgsl_gmu_reg");
+	ret = gmu_reg_probe(gmu, "kgsl_gmu_reg", true);
 	if (ret)
 		goto error;
 
-	ret = gmu_reg_probe(gmu, "kgsl_gmu_pdc_reg");
-	if (ret)
-		goto error;
-
-	ret = gmu_reg_probe(gmu, "kgsl_gmu_cpr_reg");
+	ret = gmu_reg_probe(gmu, "kgsl_gmu_pdc_reg", false);
 	if (ret)
 		goto error;
 
@@ -1159,7 +1158,6 @@
 		goto error;
 
 	gmu->num_gpupwrlevels = pwr->num_pwrlevels;
-	gmu->wakeup_pwrlevel = pwr->default_pwrlevel;
 
 	for (i = 0; i < gmu->num_gpupwrlevels; i++) {
 		int j = gmu->num_gpupwrlevels - 1 - i;
@@ -1352,6 +1350,7 @@
 
 	gmu_disable_clks(gmu);
 	gmu_disable_gdsc(gmu);
+	dev_err(&gmu->pdev->dev, "Suspended GMU\n");
 	return 0;
 }
 
@@ -1360,7 +1359,7 @@
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	struct gmu_device *gmu = &device->gmu;
 
-	if (!test_and_set_bit(GMU_FAULT, &gmu->flags)) {
+	if (!gmu->fault_count) {
 		/* Mask so there's no interrupt caused by NMI */
 		adreno_write_gmureg(adreno_dev,
 				ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 0xFFFFFFFF);
@@ -1375,7 +1374,7 @@
 		/* Wait for the NMI to be handled */
 		wmb();
 		udelay(100);
-		kgsl_device_snapshot(device, NULL);
+		kgsl_device_snapshot(device, NULL, true);
 
 		adreno_write_gmureg(adreno_dev,
 				ADRENO_REG_GMU_GMU2HOST_INTR_CLR, 0xFFFFFFFF);
@@ -1383,6 +1382,8 @@
 				ADRENO_REG_GMU_GMU2HOST_INTR_MASK,
 				(unsigned int) ~HFI_IRQ_MASK);
 	}
+
+	gmu->fault_count++;
 }
 
 /* To be called to power on both GPU and GMU */
@@ -1400,32 +1401,26 @@
 		WARN_ON(test_bit(GMU_CLK_ON, &gmu->flags));
 		gmu_enable_gdsc(gmu);
 		gmu_enable_clks(gmu);
+		gmu_irq_enable(device);
 
 		/* Vote for 300MHz DDR for GMU to init */
 		ret = msm_bus_scale_client_update_request(gmu->pcl,
 				pwr->pwrlevels[pwr->default_pwrlevel].bus_freq);
-		if (ret) {
+		if (ret)
 			dev_err(&gmu->pdev->dev,
-					"Failed to allocate gmu b/w\n");
-			goto error_clks;
-		}
+				"Failed to allocate gmu b/w: %d\n", ret);
 
 		ret = gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_FW_START,
 				GMU_COLD_BOOT, 0);
 		if (ret)
-			goto error_bus;
-
-		gmu_irq_enable(device);
+			goto error_gmu;
 
 		ret = hfi_start(gmu, GMU_COLD_BOOT);
 		if (ret)
-			goto error_gpu;
+			goto error_gmu;
 
-		/* Send default DCVS level */
-		ret = gmu_dcvs_set(gmu, pwr->default_pwrlevel,
-				pwr->pwrlevels[pwr->default_pwrlevel].bus_freq);
-		if (ret)
-			goto error_gpu;
+		/* Request default DCVS level */
+		kgsl_pwrctrl_pwrlevel_change(device, pwr->default_pwrlevel);
 
 		msm_bus_scale_client_update_request(gmu->pcl, 0);
 		break;
@@ -1434,49 +1429,41 @@
 		WARN_ON(test_bit(GMU_CLK_ON, &gmu->flags));
 		gmu_enable_gdsc(gmu);
 		gmu_enable_clks(gmu);
+		gmu_irq_enable(device);
 
 		ret = gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_FW_START,
 				GMU_WARM_BOOT, 0);
 		if (ret)
-			goto error_clks;
-
-		gmu_irq_enable(device);
+			goto error_gmu;
 
 		ret = hfi_start(gmu, GMU_WARM_BOOT);
 		if (ret)
-			goto error_gpu;
+			goto error_gmu;
 
-		ret = gmu_dcvs_set(gmu, gmu->wakeup_pwrlevel,
-				pwr->pwrlevels[gmu->wakeup_pwrlevel].bus_freq);
-		if (ret)
-			goto error_gpu;
-
-		gmu->wakeup_pwrlevel = pwr->default_pwrlevel;
+		kgsl_pwrctrl_pwrlevel_change(device, pwr->default_pwrlevel);
 		break;
 
 	case KGSL_STATE_RESET:
-		if (test_bit(ADRENO_DEVICE_HARD_RESET, &adreno_dev->priv)) {
+		if (test_bit(ADRENO_DEVICE_HARD_RESET, &adreno_dev->priv) ||
+			test_bit(GMU_FAULT, &gmu->flags)) {
 			gmu_suspend(device);
 			gmu_enable_gdsc(gmu);
 			gmu_enable_clks(gmu);
+			gmu_irq_enable(device);
 
 			ret = gpudev->rpmh_gpu_pwrctrl(
 				adreno_dev, GMU_FW_START, GMU_RESET, 0);
 			if (ret)
-				goto error_clks;
+				goto error_gmu;
 
-			gmu_irq_enable(device);
 
 			ret = hfi_start(gmu, GMU_COLD_BOOT);
 			if (ret)
-				goto error_gpu;
+				goto error_gmu;
 
 			/* Send DCVS level prior to reset*/
-			ret = gmu_dcvs_set(gmu, pwr->active_pwrlevel,
-					pwr->pwrlevels[pwr->active_pwrlevel]
-					.bus_freq);
-			if (ret)
-				goto error_gpu;
+			kgsl_pwrctrl_pwrlevel_change(device,
+				pwr->default_pwrlevel);
 
 			ret = gpudev->oob_set(adreno_dev,
 				OOB_CPINIT_SET_MASK,
@@ -1490,74 +1477,57 @@
 		break;
 	}
 
-	if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
-		gpudev->oob_clear(adreno_dev,
-				OOB_BOOT_SLUMBER_CLEAR_MASK);
-
 	return ret;
 
-error_gpu:
+error_gmu:
 	gmu_snapshot(device);
-	hfi_stop(gmu);
-	gmu_irq_disable(device);
-	if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
-		gpudev->oob_clear(adreno_dev,
-				OOB_BOOT_SLUMBER_CLEAR_MASK);
-	gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_FW_STOP, 0, 0);
-error_bus:
-	msm_bus_scale_client_update_request(gmu->pcl, 0);
-error_clks:
-	gmu_snapshot(device);
-	gmu_disable_clks(gmu);
-	gmu_disable_gdsc(gmu);
 	return ret;
 }
 
-#define GMU_IDLE_TIMEOUT	10 /* ms */
-
 /* Caller shall ensure GPU is ready for SLUMBER */
 void gmu_stop(struct kgsl_device *device)
 {
 	struct gmu_device *gmu = &device->gmu;
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
-	unsigned long t;
-	bool idle = false;
-	unsigned int reg;
+	bool idle = true;
 
 	if (!test_bit(GMU_CLK_ON, &gmu->flags))
 		return;
 
-	t = jiffies + msecs_to_jiffies(GMU_IDLE_TIMEOUT);
-	while (!time_after(jiffies, t)) {
-		adreno_read_gmureg(ADRENO_DEVICE(device),
-			ADRENO_REG_GMU_RPMH_POWER_STATE, &reg);
-		if (reg == device->gmu.idle_level) {
-			idle = true;
-			break;
-		}
-		/* Wait 100us to reduce unnecessary AHB bus traffic */
-		udelay(100);
-		cond_resched();
-	}
+	/* Wait for the lowest idle level we requested */
+	if (gpudev->wait_for_lowest_idle &&
+			gpudev->wait_for_lowest_idle(adreno_dev))
+		idle = false;
 
 	gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_NOTIFY_SLUMBER, 0, 0);
-
 	if (!idle || (gpudev->wait_for_gmu_idle &&
 			gpudev->wait_for_gmu_idle(adreno_dev))) {
 		dev_err(&gmu->pdev->dev, "Stopping GMU before it is idle\n");
+		idle = false;
+		set_bit(GMU_FAULT, &gmu->flags);
+	} else {
+		idle = true;
 	}
 
-	/* Pending message in all queues are abandoned */
-	hfi_stop(gmu);
-	clear_bit(GMU_HFI_ON, &gmu->flags);
-	gmu_irq_disable(device);
+	if (idle) {
+		/* Pending message in all queues are abandoned */
+		hfi_stop(gmu);
+		clear_bit(GMU_HFI_ON, &gmu->flags);
+		gmu_irq_disable(device);
 
-	gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_FW_STOP, 0, 0);
-	gmu_disable_clks(gmu);
-	gmu_disable_gdsc(gmu);
-
-	/* TODO: Vote CX, MX retention off */
+		gpudev->rpmh_gpu_pwrctrl(adreno_dev, GMU_FW_STOP, 0, 0);
+		gmu_disable_clks(gmu);
+		gmu_disable_gdsc(gmu);
+	} else {
+		/*
+		 * The power controller will change state to SLUMBER anyway
+		 * Set GMU_FAULT flag to indicate to power contrller
+		 * that hang recovery is needed to power on GPU
+		 */
+		set_bit(GMU_FAULT, &gmu->flags);
+		gmu_snapshot(device);
+	}
 
 	msm_bus_scale_client_update_request(gmu->pcl, 0);
 }
diff --git a/drivers/gpu/msm/kgsl_gmu.h b/drivers/gpu/msm/kgsl_gmu.h
index c558067..fc6bafa 100644
--- a/drivers/gpu/msm/kgsl_gmu.h
+++ b/drivers/gpu/msm/kgsl_gmu.h
@@ -56,6 +56,9 @@
 #define GPUBUSYIGNAHB		BIT(23)
 #define CXGXCPUBUSYIGNAHB	BIT(30)
 
+/* GMU timeouts */
+#define GMU_IDLE_TIMEOUT        10 /* ms */
+
 /* Constants for GMU OOBs */
 #define OOB_BOOT_OPTION         0
 #define OOB_SLUMBER_OPTION      1
@@ -73,16 +76,17 @@
 #define OOB_PERFCNTR_SET_MASK		BIT(17)
 #define OOB_PERFCNTR_CHECK_MASK		BIT(25)
 #define OOB_PERFCNTR_CLEAR_MASK		BIT(25)
-#define OOB_GPUSTART_SET_MASK		BIT(18)
-#define OOB_GPUSTART_CHECK_MASK		BIT(26)
-#define OOB_GPUSTART_CLEAR_MASK		BIT(26)
+#define OOB_GPU_SET_MASK		BIT(18)
+#define OOB_GPU_CHECK_MASK		BIT(26)
+#define OOB_GPU_CLEAR_MASK		BIT(26)
 
 /* Bits for the flags field in the gmu structure */
 enum gmu_flags {
 	GMU_BOOT_INIT_DONE = 0,
 	GMU_CLK_ON = 1,
 	GMU_HFI_ON = 2,
-	GMU_FAULT = 3
+	GMU_FAULT = 3,
+	GMU_DCVS_REPLAY = 4,
 };
 
 /**
@@ -166,7 +170,6 @@
  *	and GPU register set, the offset will be used when accessing
  *	gmu registers using offset defined in GPU register space.
  * @pdc_reg_virt: starting kernel virtual address for RPMh PDC registers
- * @cpr_reg_virt: starting kernel virtual address for RPMh CPR controller
  * @gmu_interrupt_num: GMU interrupt number
  * @fw_image: descriptor of GMU memory that has GMU image in it
  * @hfi_mem: pointer to HFI shared memory
@@ -194,6 +197,7 @@
  * @pcl: GPU BW scaling client
  * @ccl: CNOC BW scaling client
  * @idle_level: Minimal GPU idle power level
+ * @fault_count: GMU fault count
  */
 struct gmu_device {
 	unsigned int ver;
@@ -203,7 +207,6 @@
 	unsigned int reg_len;
 	unsigned int gmu2gpu_offset;
 	void __iomem *pdc_reg_virt;
-	void __iomem *cpr_reg_virt;
 	unsigned int gmu_interrupt_num;
 	struct gmu_memdesc fw_image;
 	struct gmu_memdesc *hfi_mem;
@@ -228,6 +231,7 @@
 	unsigned int pcl;
 	unsigned int ccl;
 	unsigned int idle_level;
+	unsigned int fault_count;
 };
 
 bool kgsl_gmu_isenabled(struct kgsl_device *device);
diff --git a/drivers/gpu/msm/kgsl_hfi.c b/drivers/gpu/msm/kgsl_hfi.c
index 68e0f3a..2cc60b5 100644
--- a/drivers/gpu/msm/kgsl_hfi.c
+++ b/drivers/gpu/msm/kgsl_hfi.c
@@ -278,8 +278,7 @@
 	int rc = 0;
 	struct pending_msg msg;
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *)&init_msg,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &init_msg.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -309,8 +308,7 @@
 	int rc = 0;
 	struct pending_msg msg;
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *)&fw_ver,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &fw_ver.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -346,8 +344,7 @@
 		lmconfig.lm_enable_bitmask =
 			(1 << (gmu->lm_dcvs_level + 1)) - 1;
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *) &lmconfig,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &lmconfig.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -388,8 +385,7 @@
 
 	}
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *)&dcvstbl,
-			msg_size, &msg);
+	rc = hfi_send_msg(gmu, &dcvstbl.hdr, msg_size, &msg);
 	if (rc)
 		return rc;
 
@@ -441,8 +437,7 @@
 					gmu->rpmh_votes.cnoc_votes.
 					cmd_data[i][j];
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *) &bwtbl,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &bwtbl.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -454,6 +449,22 @@
 	return rc;
 }
 
+static int hfi_send_test(struct gmu_device *gmu)
+{
+	struct hfi_test_cmd test_msg = {
+		.hdr = {
+			.id = H2F_MSG_TEST,
+			.size = sizeof(test_msg) >> 2,
+			.type = HFI_MSG_CMD,
+		},
+	};
+	uint32_t msg_size_dwords = (sizeof(test_msg)) >> 2;
+	struct pending_msg msg;
+
+	return hfi_send_msg(gmu, (struct hfi_msg_hdr *)&test_msg.hdr,
+			msg_size_dwords, &msg);
+}
+
 int hfi_send_dcvs_vote(struct gmu_device *gmu, uint32_t perf_idx,
 		uint32_t bw_idx, enum rpm_ack_type ack_type)
 {
@@ -478,8 +489,7 @@
 	int rc = 0;
 	struct pending_msg msg;
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *)&dcvs_cmd,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &dcvs_cmd.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -511,8 +521,7 @@
 	if (init_perf_idx >= MAX_GX_LEVELS || init_bw_idx >= MAX_GX_LEVELS)
 		return -EINVAL;
 
-	rc = hfi_send_msg(gmu, (struct hfi_msg_hdr *) &slumber_cmd,
-			msg_size_dwords, &msg);
+	rc = hfi_send_msg(gmu, &slumber_cmd.hdr, msg_size_dwords, &msg);
 	if (rc)
 		return rc;
 
@@ -614,12 +623,19 @@
 
 		result = hfi_send_lmconfig(gmu);
 		if (result) {
-			dev_err(dev, "Failire enabling limits management (%d)\n",
-				result);
+			dev_err(dev, "Failure enabling LM (%d)\n",
+					result);
 			return result;
 		}
 	}
 
+	/* Tell the GMU we are sending no more HFIs until the next boot */
+	if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
+		result = hfi_send_test(gmu);
+		if (result)
+			return result;
+	}
+
 	set_bit(GMU_HFI_ON, &gmu->flags);
 	return 0;
 }
diff --git a/drivers/gpu/msm/kgsl_hfi.h b/drivers/gpu/msm/kgsl_hfi.h
index 47d07d9..191987e 100644
--- a/drivers/gpu/msm/kgsl_hfi.h
+++ b/drivers/gpu/msm/kgsl_hfi.h
@@ -228,6 +228,10 @@
 	uint32_t ddr_cmd_data[MAX_GX_LEVELS][MAX_BW_CMDS];
 };
 
+struct hfi_test_cmd {
+	struct hfi_msg_hdr hdr;
+};
+
 struct arc_vote_desc {
 	/* In case of GPU freq vote, primary is GX, secondary is MX
 	 * in case of GMU freq vote, primary is CX, secondary is MX
diff --git a/drivers/gpu/msm/kgsl_mmu.c b/drivers/gpu/msm/kgsl_mmu.c
index 8ea4492..a0fd3ec 100644
--- a/drivers/gpu/msm/kgsl_mmu.c
+++ b/drivers/gpu/msm/kgsl_mmu.c
@@ -26,6 +26,17 @@
 
 static void pagetable_remove_sysfs_objects(struct kgsl_pagetable *pagetable);
 
+static void _deferred_destroy(struct work_struct *ws)
+{
+	struct kgsl_pagetable *pagetable = container_of(ws,
+					struct kgsl_pagetable, destroy_ws);
+
+	if (PT_OP_VALID(pagetable, mmu_destroy_pagetable))
+		pagetable->pt_ops->mmu_destroy_pagetable(pagetable);
+
+	kfree(pagetable);
+}
+
 static void kgsl_destroy_pagetable(struct kref *kref)
 {
 	struct kgsl_pagetable *pagetable = container_of(kref,
@@ -33,10 +44,7 @@
 
 	kgsl_mmu_detach_pagetable(pagetable);
 
-	if (PT_OP_VALID(pagetable, mmu_destroy_pagetable))
-		pagetable->pt_ops->mmu_destroy_pagetable(pagetable);
-
-	kfree(pagetable);
+	kgsl_schedule_work(&pagetable->destroy_ws);
 }
 
 static inline void kgsl_put_pagetable(struct kgsl_pagetable *pagetable)
@@ -299,6 +307,7 @@
 	kref_init(&pagetable->refcount);
 
 	spin_lock_init(&pagetable->lock);
+	INIT_WORK(&pagetable->destroy_ws, _deferred_destroy);
 
 	pagetable->mmu = mmu;
 	pagetable->name = name;
diff --git a/drivers/gpu/msm/kgsl_mmu.h b/drivers/gpu/msm/kgsl_mmu.h
index 56bb317..7a8ab74 100644
--- a/drivers/gpu/msm/kgsl_mmu.h
+++ b/drivers/gpu/msm/kgsl_mmu.h
@@ -42,6 +42,7 @@
 	struct list_head list;
 	unsigned int name;
 	struct kobject *kobj;
+	struct work_struct destroy_ws;
 
 	struct {
 		atomic_t entries;
diff --git a/drivers/gpu/msm/kgsl_pool.c b/drivers/gpu/msm/kgsl_pool.c
index 685ce3e..c31a85b 100644
--- a/drivers/gpu/msm/kgsl_pool.c
+++ b/drivers/gpu/msm/kgsl_pool.c
@@ -65,19 +65,26 @@
 
 /* Map the page into kernel and zero it out */
 static void
-_kgsl_pool_zero_page(struct page *p)
+_kgsl_pool_zero_page(struct page *p, unsigned int pool_order)
 {
-	void *addr = kmap_atomic(p);
+	int i;
 
-	memset(addr, 0, PAGE_SIZE);
-	dmac_flush_range(addr, addr + PAGE_SIZE);
-	kunmap_atomic(addr);
+	for (i = 0; i < (1 << pool_order); i++) {
+		struct page *page = nth_page(p, i);
+		void *addr = kmap_atomic(page);
+
+		memset(addr, 0, PAGE_SIZE);
+		dmac_flush_range(addr, addr + PAGE_SIZE);
+		kunmap_atomic(addr);
+	}
 }
 
 /* Add a page to specified pool */
 static void
 _kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
 {
+	_kgsl_pool_zero_page(p, pool->pool_order);
+
 	spin_lock(&pool->list_lock);
 	list_add_tail(&p->lru, &pool->page_list);
 	pool->page_count++;
@@ -322,6 +329,7 @@
 			} else
 				return -ENOMEM;
 		}
+		_kgsl_pool_zero_page(page, order);
 		goto done;
 	}
 
@@ -341,6 +349,7 @@
 			page = alloc_pages(gfp_mask, order);
 			if (page == NULL)
 				return -ENOMEM;
+			_kgsl_pool_zero_page(page, order);
 			goto done;
 		}
 	}
@@ -370,12 +379,13 @@
 			} else
 				return -ENOMEM;
 		}
+
+		_kgsl_pool_zero_page(page, order);
 	}
 
 done:
 	for (j = 0; j < (*page_size >> PAGE_SHIFT); j++) {
 		p = nth_page(page, j);
-		_kgsl_pool_zero_page(p);
 		pages[pcount] = p;
 		pcount++;
 	}
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c
index 8cca248..97e5c22 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.c
+++ b/drivers/gpu/msm/kgsl_pwrctrl.c
@@ -214,18 +214,10 @@
 static int kgsl_bus_scale_request(struct kgsl_device *device,
 		unsigned int buslevel)
 {
-	struct gmu_device *gmu = &device->gmu;
 	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
 	int ret = 0;
 
-	/* GMU scales BW */
-	if (kgsl_gmu_isenabled(device)) {
-		if (!(gmu->flags & GMU_HFI_ON) || !buslevel)
-			/* Zero bus level is invalid for GMU to vote */
-			return 0;
-
-		ret = gmu_dcvs_set(gmu, INVALID_DCVS_IDX, buslevel);
-	} else if (pwr->pcl) {
+	if (pwr->pcl) {
 		/* Linux bus driver scales BW */
 		ret = msm_bus_scale_client_update_request(pwr->pcl, buslevel);
 	}
@@ -252,12 +244,9 @@
 	/* GMU scales GPU freq */
 	if (kgsl_gmu_isenabled(device)) {
 		/* If GMU has not been started, save it */
-		if (!(gmu->flags & GMU_HFI_ON)) {
-			/* In slumber the clock is off so we are done */
-			if (pwrlevel == (gmu->num_gpupwrlevels - 1))
-				return 0;
-
-			gmu->wakeup_pwrlevel = pwrlevel;
+		if (!test_bit(GMU_HFI_ON, &gmu->flags)) {
+			/* store clock change request */
+			set_bit(GMU_DCVS_REPLAY, &gmu->flags);
 			return 0;
 		}
 
@@ -267,6 +256,8 @@
 			return -EINVAL;
 		}
 		ret = gmu_dcvs_set(gmu, pwrlevel, INVALID_DCVS_IDX);
+		/* indicate actual clock  change */
+		clear_bit(GMU_DCVS_REPLAY, &gmu->flags);
 	} else
 		/* Linux clock driver scales GPU freq */
 		ret = clk_set_rate(pwr->grp_clks[0], pl->gpu_freq);
@@ -291,8 +282,7 @@
 	unsigned long ab;
 
 	/* the bus should be ON to update the active frequency */
-	if (!(kgsl_gmu_isenabled(device)) && on &&
-		!(test_bit(KGSL_PWRFLAGS_AXI_ON, &pwr->power_flags)))
+	if (on && !(test_bit(KGSL_PWRFLAGS_AXI_ON, &pwr->power_flags)))
 		return;
 	/*
 	 * If the bus should remain on calculate our request and submit it,
@@ -421,7 +411,8 @@
 	 */
 	kgsl_pwrctrl_set_thermal_cycle(pwr, new_level);
 
-	if (new_level == old_level)
+	if (new_level == old_level &&
+		!test_bit(GMU_DCVS_REPLAY, &device->gmu.flags))
 		return;
 
 	kgsl_pwrscale_update_stats(device);
@@ -2494,6 +2485,9 @@
 static void kgsl_pwrctrl_disable(struct kgsl_device *device)
 {
 	if (kgsl_gmu_isenabled(device)) {
+		struct kgsl_pwrctrl *pwr = &device->pwrctrl;
+
+		pwr->active_pwrlevel = pwr->num_pwrlevels - 1;
 		kgsl_pwrctrl_axi(device, KGSL_PWRFLAGS_OFF);
 		return gmu_stop(device);
 	}
@@ -2638,6 +2632,7 @@
 _aware(struct kgsl_device *device)
 {
 	int status = 0;
+	struct gmu_device *gmu = &device->gmu;
 
 	switch (device->state) {
 	case KGSL_STATE_RESET:
@@ -2657,15 +2652,42 @@
 		kgsl_pwrscale_midframe_timer_cancel(device);
 		break;
 	case KGSL_STATE_SLUMBER:
+		/* if GMU already in FAULT */
+		if (kgsl_gmu_isenabled(device) &&
+			test_bit(GMU_FAULT, &gmu->flags)) {
+			status = -EINVAL;
+			break;
+		}
+
 		status = kgsl_pwrctrl_enable(device);
 		break;
 	default:
 		status = -EINVAL;
 	}
-	if (status)
+
+	if (status) {
+		if (kgsl_gmu_isenabled(device)) {
+			/* GMU hang recovery */
+			kgsl_pwrctrl_set_state(device, KGSL_STATE_RESET);
+			set_bit(GMU_FAULT, &gmu->flags);
+			status = kgsl_pwrctrl_enable(device);
+			if (status) {
+				/*
+				 * Cannot recover GMU failure
+				 * GPU will not be powered on
+				 */
+				WARN_ONCE(1, "Failed to recover GMU\n");
+			}
+
+			clear_bit(GMU_FAULT, &gmu->flags);
+			kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
+			return status;
+		}
+
 		kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE);
-	else
+	} else {
 		kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
+	}
 	return status;
 }
 
@@ -3111,7 +3133,7 @@
 {
 	struct kgsl_pwr_limit *limit = limit_ptr;
 
-	if (IS_ERR(limit))
+	if (IS_ERR_OR_NULL(limit))
 		return;
 
 	_update_limits(limit, KGSL_PWR_DEL_LIMIT, 0);
@@ -3132,7 +3154,7 @@
 	struct kgsl_pwr_limit *limit = limit_ptr;
 	int level;
 
-	if (IS_ERR(limit))
+	if (IS_ERR_OR_NULL(limit))
 		return -EINVAL;
 
 	pwr = &limit->device->pwrctrl;
@@ -3154,7 +3176,7 @@
 {
 	struct kgsl_pwr_limit *limit = limit_ptr;
 
-	if (IS_ERR(limit))
+	if (IS_ERR_OR_NULL(limit))
 		return;
 
 	_update_limits(limit, KGSL_PWR_SET_LIMIT, 0);
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.h b/drivers/gpu/msm/kgsl_pwrctrl.h
index 53bb255..85bab11 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.h
+++ b/drivers/gpu/msm/kgsl_pwrctrl.h
@@ -145,6 +145,7 @@
  * @pm_qos_req_dma - the power management quality of service structure
  * @pm_qos_active_latency - allowed CPU latency in microseconds when active
  * @pm_qos_cpu_mask_latency - allowed CPU mask latency in microseconds
+ * @input_disable - To disable GPU wakeup on touch input event
  * @pm_qos_wakeup_latency - allowed CPU latency in microseconds during wakeup
  * @bus_control - true if the bus calculation is independent
  * @bus_mod - modifier from the current power level for the bus vote
@@ -200,6 +201,7 @@
 	unsigned int pm_qos_active_latency;
 	unsigned int pm_qos_cpu_mask_latency;
 	unsigned int pm_qos_wakeup_latency;
+	bool input_disable;
 	bool bus_control;
 	int bus_mod;
 	unsigned int bus_percent_ab;
diff --git a/drivers/gpu/msm/kgsl_pwrscale.c b/drivers/gpu/msm/kgsl_pwrscale.c
index 6fb81ee..20590ea 100644
--- a/drivers/gpu/msm/kgsl_pwrscale.c
+++ b/drivers/gpu/msm/kgsl_pwrscale.c
@@ -615,7 +615,7 @@
 	struct kgsl_device *device = dev_get_drvdata(dev);
 	struct kgsl_pwrctrl *pwrctrl;
 	struct kgsl_pwrscale *pwrscale;
-	ktime_t tmp;
+	ktime_t tmp1, tmp2;
 
 	if (device == NULL)
 		return -ENODEV;
@@ -626,6 +626,8 @@
 	pwrctrl = &device->pwrctrl;
 
 	mutex_lock(&device->mutex);
+
+	tmp1 = ktime_get();
 	/*
 	 * If the GPU clock is on grab the latest power counter
 	 * values.  Otherwise the most recent ACTIVE values will
@@ -633,9 +635,9 @@
 	 */
 	kgsl_pwrscale_update_stats(device);
 
-	tmp = ktime_get();
-	stat->total_time = ktime_us_delta(tmp, pwrscale->time);
-	pwrscale->time = tmp;
+	tmp2 = ktime_get();
+	stat->total_time = ktime_us_delta(tmp2, pwrscale->time);
+	pwrscale->time = tmp1;
 
 	stat->busy_time = pwrscale->accum_stats.busy_time;
 
diff --git a/drivers/gpu/msm/kgsl_snapshot.c b/drivers/gpu/msm/kgsl_snapshot.c
index 7cbda72..f710d8f 100644
--- a/drivers/gpu/msm/kgsl_snapshot.c
+++ b/drivers/gpu/msm/kgsl_snapshot.c
@@ -24,6 +24,8 @@
 #include "kgsl_snapshot.h"
 #include "adreno_cp_parser.h"
 
+static void kgsl_snapshot_save_frozen_objs(struct work_struct *work);
+
 /* Placeholder for list of ib objects that contain all objects in that IB */
 
 struct kgsl_snapshot_cp_obj {
@@ -182,7 +184,7 @@
 	context = kgsl_context_get(device, header->current_context);
 
 	/* Get the current PT base */
-	 header->ptbase = kgsl_mmu_get_current_ttbr0(&device->mmu);
+	header->ptbase = kgsl_mmu_get_current_ttbr0(&device->mmu);
 
 	/* And the PID for the task leader */
 	if (context) {
@@ -206,6 +208,44 @@
 	return size;
 }
 
+/* Snapshot the Linux specific information */
+static size_t snapshot_os_no_ctxt(struct kgsl_device *device,
+	u8 *buf, size_t remain, void *priv)
+{
+	struct kgsl_snapshot_linux_v2 *header =
+		(struct kgsl_snapshot_linux_v2 *)buf;
+	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
+	size_t size = sizeof(*header);
+
+	/* Make sure there is enough room for the data */
+	if (remain < size) {
+		SNAPSHOT_ERR_NOMEM(device, "OS");
+		return 0;
+	}
+
+	memset(header, 0, sizeof(*header));
+
+	header->osid = KGSL_SNAPSHOT_OS_LINUX_V3;
+
+	/* Get the kernel build information */
+	strlcpy(header->release, init_utsname()->release,
+			sizeof(header->release));
+	strlcpy(header->version, init_utsname()->version,
+			sizeof(header->version));
+
+	/* Get the Unix time for the timestamp */
+	header->seconds = get_seconds();
+
+	/* Remember the power information */
+	header->power_flags = pwr->power_flags;
+	header->power_level = pwr->active_pwrlevel;
+	header->power_interval_timeout = pwr->interval_timeout;
+	header->grpclk = kgsl_get_clkrate(pwr->grp_clks[0]);
+
+	/* Return the size of the data segment */
+	return size;
+}
+
 static void kgsl_snapshot_put_object(struct kgsl_snapshot_object *obj)
 {
 	list_del(&obj->node);
@@ -572,16 +612,34 @@
 	snapshot->size += header->size;
 }
 
+static void kgsl_free_snapshot(struct kgsl_snapshot *snapshot)
+{
+	struct kgsl_snapshot_object *obj, *tmp;
+
+	wait_for_completion(&snapshot->dump_gate);
+
+	list_for_each_entry_safe(obj, tmp,
+				&snapshot->obj_list, node)
+		kgsl_snapshot_put_object(obj);
+
+	if (snapshot->mempool)
+		vfree(snapshot->mempool);
+
+	kfree(snapshot);
+	KGSL_CORE_ERR("snapshot: objects released\n");
+}
+
 /**
  * kgsl_snapshot() - construct a device snapshot
  * @device: device to snapshot
  * @context: the context that is hung, might be NULL if unknown.
+ * @gmu_fault: whether this snapshot is triggered by a GMU fault.
  *
  * Given a device, construct a binary snapshot dump of the current device state
  * and store it in the device snapshot memory.
  */
 void kgsl_device_snapshot(struct kgsl_device *device,
-		struct kgsl_context *context)
+		struct kgsl_context *context, bool gmu_fault)
 {
 	struct kgsl_snapshot_header *header = device->snapshot_memory.ptr;
 	struct kgsl_snapshot *snapshot;
@@ -602,11 +660,20 @@
 	device->snapshot_faultcount++;
 
 	/*
-	 * The first hang is always the one we are interested in. Don't capture
-	 * a new snapshot instance if the old one hasn't been grabbed yet
+	 * Overwrite a non-GMU fault snapshot if a GMU fault occurs.
 	 */
-	if (device->snapshot != NULL)
-		return;
+	if (device->snapshot != NULL) {
+		if (!gmu_fault || device->snapshot->gmu_fault)
+			return;
+
+		/*
+		 * If another thread is currently reading it, that thread
+		 * will free it, otherwise free it now.
+		 */
+		if (!device->snapshot->sysfs_read)
+			kgsl_free_snapshot(device->snapshot);
+		device->snapshot = NULL;
+	}
 
 	/* Allocate memory for the snapshot instance */
 	snapshot = kzalloc(sizeof(*snapshot), GFP_KERNEL);
@@ -621,7 +688,9 @@
 	snapshot->start = device->snapshot_memory.ptr;
 	snapshot->ptr = device->snapshot_memory.ptr;
 	snapshot->remain = device->snapshot_memory.size;
-	atomic_set(&snapshot->sysfs_read, 0);
+	snapshot->gmu_fault = gmu_fault;
+	snapshot->first_read = true;
+	snapshot->sysfs_read = 0;
 
 	header = (struct kgsl_snapshot_header *) snapshot->ptr;
 
@@ -633,12 +702,24 @@
 	snapshot->size += sizeof(*header);
 
 	/* Build the Linux specific header */
-	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_OS,
-			snapshot, snapshot_os, NULL);
+	/* We either want to only dump GMU, or we want to dump GPU and GMU */
+	if (gmu_fault) {
+		/* Dump only the GMU */
+		kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_OS,
+				snapshot, snapshot_os_no_ctxt, NULL);
 
-	/* Get the device specific sections */
-	if (device->ftbl->snapshot)
-		device->ftbl->snapshot(device, snapshot, context);
+		if (device->ftbl->snapshot_gmu)
+			device->ftbl->snapshot_gmu(device, snapshot);
+	} else {
+		/* Dump GPU and GMU */
+		kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_OS,
+				snapshot, snapshot_os, NULL);
+
+		if (device->ftbl->snapshot)
+			device->ftbl->snapshot(device, snapshot, context);
+		if (device->ftbl->snapshot_gmu)
+			device->ftbl->snapshot_gmu(device, snapshot);
+	}
 
 	/*
 	 * The timestamp is the seconds since boot so it is easier to match to
@@ -708,6 +789,30 @@
 #define kobj_to_device(a) \
 container_of(a, struct kgsl_device, snapshot_kobj)
 
+static int snapshot_release(struct kgsl_device *device,
+	struct kgsl_snapshot *snapshot)
+{
+	bool snapshot_free = false;
+	int ret = 0;
+
+	mutex_lock(&device->mutex);
+	snapshot->sysfs_read--;
+
+	/*
+	 * If someone's replaced the snapshot, return an error and free
+	 * the snapshot if this is the last thread to read it.
+	 */
+	if (device->snapshot != snapshot) {
+		ret = -EIO;
+		if (!snapshot->sysfs_read)
+			snapshot_free = true;
+	}
+	mutex_unlock(&device->mutex);
+	if (snapshot_free)
+		kgsl_free_snapshot(snapshot);
+	return ret;
+}
+
 /* Dump the sysfs binary data to the user */
 static ssize_t snapshot_show(struct file *filep, struct kobject *kobj,
 	struct bin_attribute *attr, char *buf, loff_t off,
@@ -715,20 +820,35 @@
 {
 	struct kgsl_device *device = kobj_to_device(kobj);
 	struct kgsl_snapshot *snapshot;
-	struct kgsl_snapshot_object *obj, *tmp;
 	struct kgsl_snapshot_section_header head;
 	struct snapshot_obj_itr itr;
-	int ret;
+	int ret = 0;
 
 	if (device == NULL)
 		return 0;
 
 	mutex_lock(&device->mutex);
 	snapshot = device->snapshot;
-	if (snapshot != NULL)
-		atomic_inc(&snapshot->sysfs_read);
+	if (snapshot != NULL) {
+		/*
+		 * If we're reading at a non-zero offset from a new snapshot,
+		 * that means we want to read from the previous snapshot (which
+		 * was overwritten), so return an error
+		 */
+		if (snapshot->first_read) {
+			if (off)
+				ret = -EIO;
+			else
+				snapshot->first_read = false;
+		}
+		if (!ret)
+			snapshot->sysfs_read++;
+	}
 	mutex_unlock(&device->mutex);
 
+	if (ret)
+		return ret;
+
 	/* Return nothing if we haven't taken a snapshot yet */
 	if (snapshot == NULL)
 		return 0;
@@ -739,7 +859,7 @@
 	 */
 	ret = wait_for_completion_interruptible(&snapshot->dump_gate);
 	if (ret) {
-		atomic_dec(&snapshot->sysfs_read);
+		snapshot_release(device, snapshot);
 		return ret;
 	}
 
@@ -776,29 +896,21 @@
 		bool snapshot_free = false;
 
 		mutex_lock(&device->mutex);
-		if (atomic_dec_and_test(&snapshot->sysfs_read)) {
-			device->snapshot = NULL;
+		if (--snapshot->sysfs_read == 0) {
+			if (device->snapshot == snapshot)
+				device->snapshot = NULL;
 			snapshot_free = true;
 		}
 		mutex_unlock(&device->mutex);
 
-		if (snapshot_free) {
-			list_for_each_entry_safe(obj, tmp,
-						&snapshot->obj_list, node)
-				kgsl_snapshot_put_object(obj);
-
-			if (snapshot->mempool)
-				vfree(snapshot->mempool);
-
-			kfree(snapshot);
-			KGSL_CORE_ERR("snapshot: objects released\n");
-		}
+		if (snapshot_free)
+			kgsl_free_snapshot(snapshot);
 		return 0;
 	}
 
 done:
-	atomic_dec(&snapshot->sysfs_read);
-	return itr.write;
+	ret = snapshot_release(device, snapshot);
+	return (ret < 0) ? ret : itr.write;
 }
 
 /* Show the total number of hangs since device boot */
@@ -869,9 +981,11 @@
 /* Show the timestamp of the last collected snapshot */
 static ssize_t timestamp_show(struct kgsl_device *device, char *buf)
 {
-	unsigned long timestamp =
-		device->snapshot ? device->snapshot->timestamp : 0;
+	unsigned long timestamp;
 
+	mutex_lock(&device->mutex);
+	timestamp = device->snapshot ? device->snapshot->timestamp : 0;
+	mutex_unlock(&device->mutex);
 	return snprintf(buf, PAGE_SIZE, "%lu\n", timestamp);
 }
 
@@ -1128,7 +1242,7 @@
  * is taken
  * @work: The work item that scheduled this work
  */
-void kgsl_snapshot_save_frozen_objs(struct work_struct *work)
+static void kgsl_snapshot_save_frozen_objs(struct work_struct *work)
 {
 	struct kgsl_snapshot *snapshot = container_of(work,
 				struct kgsl_snapshot, work);
@@ -1140,6 +1254,9 @@
 	if (IS_ERR_OR_NULL(device))
 		return;
 
+	if (snapshot->gmu_fault)
+		goto gmu_only;
+
 	kgsl_snapshot_process_ib_obj_list(snapshot);
 
 	list_for_each_entry(obj, &snapshot->obj_list, node) {
@@ -1186,6 +1303,7 @@
 			       "snapshot: Active IB2:%016llx not dumped\n",
 				snapshot->ib2base);
 
+gmu_only:
 	complete_all(&snapshot->dump_gate);
 	BUG_ON(device->force_panic);
 }
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d7f6cf0..d42ace8 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2485,6 +2485,7 @@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_PETZL, USB_DEVICE_ID_PETZL_HEADLAMP) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
 #if IS_ENABLED(CONFIG_MOUSE_SYNAPTICS_USB)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index cfca43f..08fd3f8 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -819,6 +819,9 @@
 #define USB_VENDOR_ID_PETALYNX		0x18b1
 #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE	0x0037
 
+#define USB_VENDOR_ID_PETZL		0x2122
+#define USB_DEVICE_ID_PETZL_HEADLAMP	0x1234
+
 #define USB_VENDOR_ID_PHILIPS		0x0471
 #define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617
 
diff --git a/drivers/hwmon/qpnp-adc-current.c b/drivers/hwmon/qpnp-adc-current.c
index a597ef9..c4da780 100644
--- a/drivers/hwmon/qpnp-adc-current.c
+++ b/drivers/hwmon/qpnp-adc-current.c
@@ -27,17 +27,11 @@
 #include <linux/spmi.h>
 #include <linux/platform_device.h>
 #include <linux/of_irq.h>
-#ifdef CONFIG_WAKELOCK
-#include <linux/wakelock.h>
-#endif
 #include <linux/interrupt.h>
 #include <linux/completion.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/qpnp/qpnp-adc.h>
 #include <linux/platform_device.h>
-#ifdef CONFIG_WAKELOCK
-#include <linux/wakelock.h>
-#endif
 
 /* QPNP IADC register definition */
 #define QPNP_IADC_REVISION1				0x0
diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig
index 285b80d..8d242f8 100644
--- a/drivers/hwtracing/coresight/Kconfig
+++ b/drivers/hwtracing/coresight/Kconfig
@@ -148,6 +148,25 @@
 	  hardware component to another. It can also be used to pass
 	  software generated events.
 
+config CORESIGHT_EVENT
+        tristate "CoreSight Event driver"
+        help
+          This driver provides support for registering with various events
+          and performing CoreSight actions like aborting trace on their
+          occurrence. These events can be controlled by using module
+          parameters.
+
+config CORESIGHT_TGU
+	bool "CoreSight Trigger Generation Unit driver"
+	help
+	  This driver provides support for Trigger Generation Unit that is
+	  used to detect patterns or sequences on a given set of signals.
+	  TGU is used to monitor a particular bus within a given region to
+	  detect illegal transaction sequences or slave responses. It is also
+	  used to monitor a data stream to detect protocol violations and to
+	  provide a trigger point for centering data around a specific event
+	  within the trace data buffer.
+
 config CORESIGHT_CSR
 	bool "CoreSight Slave Register driver"
 	help
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
index af94ad7..cb47ecd 100644
--- a/drivers/hwtracing/coresight/Makefile
+++ b/drivers/hwtracing/coresight/Makefile
@@ -5,7 +5,8 @@
 obj-$(CONFIG_OF) += of_coresight.o
 obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \
 					     coresight-tmc-etf.o \
-					     coresight-tmc-etr.o
+					     coresight-tmc-etr.o \
+					     coresight-byte-cntr.o
 obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o
 obj-$(CONFIG_CORESIGHT_SINK_ETBV10) += coresight-etb10.o
 obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \
@@ -19,7 +20,9 @@
 obj-$(CONFIG_CORESIGHT_OST) += coresight-ost.o
 obj-$(CONFIG_CORESIGHT_TPDA) += coresight-tpda.o
 obj-$(CONFIG_CORESIGHT_TPDM) += coresight-tpdm.o
+obj-$(CONFIG_CORESIGHT_EVENT) += coresight-event.o
 obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o
+obj-$(CONFIG_CORESIGHT_TGU) += coresight-tgu.o
 obj-$(CONFIG_CORESIGHT_CSR) += coresight-csr.o
 obj-$(CONFIG_CORESIGHT_HWEVENT) += coresight-hwevent.o
 obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
diff --git a/drivers/hwtracing/coresight/coresight-byte-cntr.c b/drivers/hwtracing/coresight/coresight-byte-cntr.c
new file mode 100644
index 0000000..7ef2710
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-byte-cntr.c
@@ -0,0 +1,373 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
+#include <linux/fs.h>
+#include <linux/of_irq.h>
+#include <linux/moduleparam.h>
+#include <linux/delay.h>
+
+#include "coresight-byte-cntr.h"
+#include "coresight-priv.h"
+#include "coresight-tmc.h"
+
+static struct tmc_drvdata *tmcdrvdata;
+
+static void tmc_etr_read_bytes(struct byte_cntr *byte_cntr_data, loff_t *ppos,
+			       size_t bytes, size_t *len)
+{
+	if (*len >= bytes) {
+		atomic_dec(&byte_cntr_data->irq_cnt);
+		*len = bytes;
+	} else {
+		if (((uint32_t)*ppos % bytes) + *len > bytes)
+			*len = bytes - ((uint32_t)*ppos % bytes);
+		if ((*len + (uint32_t)*ppos) % bytes == 0)
+			atomic_dec(&byte_cntr_data->irq_cnt);
+	}
+}
+
+static void tmc_etr_sg_read_pos(loff_t *ppos,
+				size_t bytes, bool noirq, size_t *len,
+				char **bufpp)
+{
+	uint32_t rwp, i = 0;
+	uint32_t blk_num, sg_tbl_num, blk_num_loc, read_off;
+	uint32_t *virt_pte, *virt_st_tbl;
+	void *virt_blk;
+	phys_addr_t phys_pte;
+	int total_ents = DIV_ROUND_UP(tmcdrvdata->size, PAGE_SIZE);
+	int ents_per_pg = PAGE_SIZE/sizeof(uint32_t);
+
+	if (*len == 0)
+		return;
+
+	blk_num = *ppos / PAGE_SIZE;
+	read_off = *ppos % PAGE_SIZE;
+
+	virt_st_tbl = (uint32_t *)tmcdrvdata->vaddr;
+
+	/* Compute table index and block entry index within that table */
+	if (blk_num && (blk_num == (total_ents - 1)) &&
+	    !(blk_num % (ents_per_pg - 1))) {
+		sg_tbl_num = blk_num / ents_per_pg;
+		blk_num_loc = ents_per_pg - 1;
+	} else {
+		sg_tbl_num = blk_num / (ents_per_pg - 1);
+		blk_num_loc = blk_num % (ents_per_pg - 1);
+	}
+
+	for (i = 0; i < sg_tbl_num; i++) {
+		virt_pte = virt_st_tbl + (ents_per_pg - 1);
+		phys_pte = TMC_ETR_SG_ENT_TO_BLK(*virt_pte);
+		virt_st_tbl = (uint32_t *)phys_to_virt(phys_pte);
+	}
+
+	virt_pte = virt_st_tbl + blk_num_loc;
+	phys_pte = TMC_ETR_SG_ENT_TO_BLK(*virt_pte);
+	virt_blk = phys_to_virt(phys_pte);
+
+	*bufpp = (char *)(virt_blk + read_off);
+
+	if (noirq) {
+		rwp = readl_relaxed(tmcdrvdata->base + TMC_RWP);
+		tmc_etr_sg_rwp_pos(tmcdrvdata, rwp);
+		if (tmcdrvdata->sg_blk_num == blk_num &&
+		    rwp >= (phys_pte + read_off))
+			*len = rwp - phys_pte - read_off;
+		else if (tmcdrvdata->sg_blk_num > blk_num)
+			*len = PAGE_SIZE - read_off;
+		else
+			*len = bytes;
+	} else {
+
+		if (*len > (PAGE_SIZE - read_off))
+			*len = PAGE_SIZE - read_off;
+
+		if (*len >= (bytes - ((uint32_t)*ppos % bytes)))
+			*len = bytes - ((uint32_t)*ppos % bytes);
+
+		if ((*len + (uint32_t)*ppos) % bytes == 0)
+			atomic_dec(&tmcdrvdata->byte_cntr->irq_cnt);
+	}
+
+	/*
+	 * Invalidate cache range before reading. This will make sure that CPU
+	 * reads latest contents from DDR
+	 */
+	dmac_inv_range((void *)(*bufpp), (void *)(*bufpp) + *len);
+}
+
+static irqreturn_t etr_handler(int irq, void *data)
+{
+	struct byte_cntr *byte_cntr_data = data;
+
+	atomic_inc(&byte_cntr_data->irq_cnt);
+
+	wake_up(&byte_cntr_data->wq);
+
+	return IRQ_HANDLED;
+}
+
+static void tmc_etr_flush_bytes(loff_t *ppos, size_t bytes, size_t *len)
+{
+	uint32_t rwp = 0;
+
+	rwp = readl_relaxed(tmcdrvdata->base + TMC_RWP);
+
+	if (rwp >= (tmcdrvdata->paddr + *ppos)) {
+		if (bytes > (rwp - tmcdrvdata->paddr - *ppos))
+			*len = rwp - tmcdrvdata->paddr - *ppos;
+	}
+}
+
+static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
+			       size_t len, loff_t *ppos)
+{
+	struct byte_cntr *byte_cntr_data = fp->private_data;
+	char *bufp;
+
+	if (!data)
+		return -EINVAL;
+
+	mutex_lock(&byte_cntr_data->byte_cntr_lock);
+	if (!byte_cntr_data->read_active)
+		goto err0;
+
+	if (byte_cntr_data->enable) {
+		if (!atomic_read(&byte_cntr_data->irq_cnt)) {
+			mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+			if (wait_event_interruptible(byte_cntr_data->wq,
+				atomic_read(&byte_cntr_data->irq_cnt) > 0))
+				return -ERESTARTSYS;
+			mutex_lock(&byte_cntr_data->byte_cntr_lock);
+			if (!byte_cntr_data->read_active)
+				goto err0;
+		}
+		bufp = (char *)(tmcdrvdata->vaddr + *ppos);
+
+		if (tmcdrvdata->mem_type == TMC_ETR_MEM_TYPE_CONTIG)
+			tmc_etr_read_bytes(byte_cntr_data, ppos,
+					   byte_cntr_data->block_size, &len);
+		else
+			tmc_etr_sg_read_pos(ppos, byte_cntr_data->block_size, 0,
+					    &len, &bufp);
+
+	} else {
+		if (!atomic_read(&byte_cntr_data->irq_cnt)) {
+			if (tmcdrvdata->mem_type == TMC_ETR_MEM_TYPE_CONTIG)
+				tmc_etr_flush_bytes(ppos,
+						    byte_cntr_data->block_size,
+						    &len);
+			else
+				tmc_etr_sg_read_pos(ppos,
+						    byte_cntr_data->block_size,
+						    1,
+						    &len, &bufp);
+			if (!len)
+				goto err0;
+		} else {
+			if (tmcdrvdata->mem_type == TMC_ETR_MEM_TYPE_CONTIG)
+				tmc_etr_read_bytes(byte_cntr_data, ppos,
+						   byte_cntr_data->block_size,
+						   &len);
+			else
+				tmc_etr_sg_read_pos(ppos,
+						    byte_cntr_data->block_size,
+						    1,
+						    &len, &bufp);
+		}
+	}
+
+	if (copy_to_user(data, bufp, len)) {
+		mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+		dev_dbg(tmcdrvdata->dev, "%s: copy_to_user failed\n", __func__);
+		return -EFAULT;
+	}
+
+	if (*ppos + len >= tmcdrvdata->size)
+		*ppos = 0;
+	else
+		*ppos += len;
+err0:
+	mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+
+	return len;
+}
+
+void tmc_etr_byte_cntr_start(struct byte_cntr *byte_cntr_data)
+{
+	if (!byte_cntr_data)
+		return;
+
+	mutex_lock(&byte_cntr_data->byte_cntr_lock);
+
+	if (byte_cntr_data->block_size == 0) {
+		mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+		return;
+	}
+
+	atomic_set(&byte_cntr_data->irq_cnt, 0);
+	byte_cntr_data->enable = true;
+	mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+}
+EXPORT_SYMBOL(tmc_etr_byte_cntr_start);
+
+void tmc_etr_byte_cntr_stop(struct byte_cntr *byte_cntr_data)
+{
+	if (!byte_cntr_data)
+		return;
+
+	mutex_lock(&byte_cntr_data->byte_cntr_lock);
+	byte_cntr_data->enable = false;
+	coresight_csr_set_byte_cntr(0);
+	mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+
+}
+EXPORT_SYMBOL(tmc_etr_byte_cntr_stop);
+
+
+static int tmc_etr_byte_cntr_release(struct inode *in, struct file *fp)
+{
+	struct byte_cntr *byte_cntr_data = fp->private_data;
+
+	mutex_lock(&byte_cntr_data->byte_cntr_lock);
+	byte_cntr_data->read_active = false;
+
+	coresight_csr_set_byte_cntr(0);
+	mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+
+	return 0;
+}
+
+static int tmc_etr_byte_cntr_open(struct inode *in, struct file *fp)
+{
+	struct byte_cntr *byte_cntr_data =
+			container_of(in->i_cdev, struct byte_cntr, dev);
+
+	mutex_lock(&byte_cntr_data->byte_cntr_lock);
+
+	if (!tmcdrvdata->enable || !byte_cntr_data->block_size) {
+		mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+		return -EINVAL;
+	}
+
+	coresight_csr_set_byte_cntr(byte_cntr_data->block_size);
+	fp->private_data = byte_cntr_data;
+	nonseekable_open(in, fp);
+	byte_cntr_data->enable = true;
+	byte_cntr_data->read_active = true;
+	mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+
+	return 0;
+}
+
+static const struct file_operations byte_cntr_fops = {
+	.owner		= THIS_MODULE,
+	.open		= tmc_etr_byte_cntr_open,
+	.read		= tmc_etr_byte_cntr_read,
+	.release	= tmc_etr_byte_cntr_release,
+	.llseek		= no_llseek,
+};
+
+static int byte_cntr_register_chardev(struct byte_cntr *byte_cntr_data)
+{
+	int ret;
+	unsigned int baseminor = 0;
+	unsigned int count = 1;
+	struct device *device;
+	dev_t dev;
+
+	ret = alloc_chrdev_region(&dev, baseminor, count, "byte-cntr");
+	if (ret < 0) {
+		pr_err("alloc_chrdev_region failed %d\n", ret);
+		return ret;
+	}
+	cdev_init(&byte_cntr_data->dev, &byte_cntr_fops);
+
+	byte_cntr_data->dev.owner = THIS_MODULE;
+	byte_cntr_data->dev.ops = &byte_cntr_fops;
+
+	ret = cdev_add(&byte_cntr_data->dev, dev, 1);
+	if (ret)
+		goto exit_unreg_chrdev_region;
+
+	byte_cntr_data->driver_class = class_create(THIS_MODULE,
+						   "coresight-tmc-etr-stream");
+	if (IS_ERR(byte_cntr_data->driver_class)) {
+		ret = -ENOMEM;
+		pr_err("class_create failed %d\n", ret);
+		goto exit_unreg_chrdev_region;
+	}
+
+	device = device_create(byte_cntr_data->driver_class, NULL,
+			       byte_cntr_data->dev.dev, byte_cntr_data,
+			       "byte-cntr");
+
+	if (IS_ERR(device)) {
+		pr_err("class_device_create failed %d\n", ret);
+		ret = -ENOMEM;
+		goto exit_destroy_class;
+	}
+
+	return 0;
+
+exit_destroy_class:
+	class_destroy(byte_cntr_data->driver_class);
+exit_unreg_chrdev_region:
+	unregister_chrdev_region(byte_cntr_data->dev.dev, 1);
+	return ret;
+}
+
+struct byte_cntr *byte_cntr_init(struct amba_device *adev,
+				 struct tmc_drvdata *drvdata)
+{
+	struct device *dev = &adev->dev;
+	struct device_node *np = adev->dev.of_node;
+	int byte_cntr_irq;
+	int ret;
+	struct byte_cntr *byte_cntr_data;
+
+	byte_cntr_irq = of_irq_get_byname(np, "byte-cntr-irq");
+	if (byte_cntr_irq < 0)
+		return NULL;
+
+	byte_cntr_data = devm_kzalloc(dev, sizeof(*byte_cntr_data), GFP_KERNEL);
+	if (!byte_cntr_data)
+		return NULL;
+
+	ret = devm_request_irq(dev, byte_cntr_irq, etr_handler,
+			       IRQF_TRIGGER_RISING | IRQF_SHARED,
+			       "tmc-etr", byte_cntr_data);
+	if (ret) {
+		devm_kfree(dev, byte_cntr_data);
+		dev_err(dev, "Byte_cntr interrupt registration failed\n");
+		return NULL;
+	}
+
+	ret = byte_cntr_register_chardev(byte_cntr_data);
+	if (ret) {
+		devm_free_irq(dev, byte_cntr_irq, byte_cntr_data);
+		devm_kfree(dev, byte_cntr_data);
+		dev_err(dev, "Byte_cntr char dev registration failed\n");
+		return NULL;
+	}
+
+	tmcdrvdata = drvdata;
+	byte_cntr_data->byte_cntr_irq = byte_cntr_irq;
+	atomic_set(&byte_cntr_data->irq_cnt, 0);
+	init_waitqueue_head(&byte_cntr_data->wq);
+	mutex_init(&byte_cntr_data->byte_cntr_lock);
+
+	return byte_cntr_data;
+}
+EXPORT_SYMBOL(byte_cntr_init);
diff --git a/drivers/hwtracing/coresight/coresight-byte-cntr.h b/drivers/hwtracing/coresight/coresight-byte-cntr.h
new file mode 100644
index 0000000..94e9089
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-byte-cntr.h
@@ -0,0 +1,24 @@
+#ifndef _CORESIGHT_BYTE_CNTR_H
+#define _CORESIGHT_BYTE_CNTR_H
+#include <linux/cdev.h>
+#include <linux/amba/bus.h>
+#include <linux/wait.h>
+#include <linux/mutex.h>
+
+struct byte_cntr {
+	struct cdev		dev;
+	struct class		*driver_class;
+	bool			enable;
+	bool			read_active;
+	uint32_t		byte_cntr_value;
+	uint32_t		block_size;
+	int			byte_cntr_irq;
+	atomic_t		irq_cnt;
+	wait_queue_head_t	wq;
+	struct mutex		byte_cntr_lock;
+};
+
+extern void tmc_etr_byte_cntr_start(struct byte_cntr *byte_cntr_data);
+extern void tmc_etr_byte_cntr_stop(struct byte_cntr *byte_cntr_data);
+
+#endif
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index 71e4103..ee4b8b4 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -976,7 +976,12 @@
 
 	spin_lock_init(&drvdata->spinlock);
 
-	drvdata->cpu = pdata ? pdata->cpu : 0;
+	drvdata->cpu = pdata ? pdata->cpu : -1;
+
+	if (drvdata->cpu == -1) {
+		dev_info(dev, "CPU not available\n");
+		return -ENODEV;
+	}
 
 	get_online_cpus();
 
diff --git a/drivers/hwtracing/coresight/coresight-event.c b/drivers/hwtracing/coresight/coresight-event.c
new file mode 100644
index 0000000..d5f304f
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-event.c
@@ -0,0 +1,169 @@
+/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/coresight.h>
+
+#include <trace/events/exception.h>
+
+static int event_abort_enable;
+static int event_abort_set(const char *val, struct kernel_param *kp);
+module_param_call(event_abort_enable, event_abort_set, param_get_int,
+		  &event_abort_enable, 0644);
+
+static int event_abort_early_panic = 1;
+static int event_abort_on_panic_set(const char *val, struct kernel_param *kp);
+module_param_call(event_abort_early_panic, event_abort_on_panic_set,
+		  param_get_int, &event_abort_early_panic, 0644);
+
+static void event_abort_user_fault(void *ignore,
+				   struct task_struct *task,
+				   unsigned long addr,
+				   unsigned int fsr)
+{
+	coresight_abort();
+	pr_debug("coresight_event: task_name: %s, addr: %lu, fsr:%u",
+		(char *)task->comm, addr, fsr);
+}
+
+static void event_abort_undef_instr(void *ignore,
+				    struct pt_regs *regs,
+				    void __user *pc)
+{
+	if (user_mode(regs)) {
+		coresight_abort();
+		pr_debug("coresight_event: pc: %pK", pc);
+	}
+}
+
+static void event_abort_unhandled_abort(void *ignore,
+					struct pt_regs *regs,
+					unsigned long addr,
+					unsigned int fsr)
+{
+	if (user_mode(regs)) {
+		coresight_abort();
+		pr_debug("coresight_event: addr: %lu, fsr:%u", addr, fsr);
+	}
+}
+
+static void event_abort_kernel_panic(void *ignore, long state)
+{
+	coresight_abort();
+}
+
+static int event_abort_register(void)
+{
+	int ret;
+
+	ret = register_trace_user_fault(event_abort_user_fault, NULL);
+	if (ret)
+		goto err_usr_fault;
+	ret = register_trace_undef_instr(event_abort_undef_instr, NULL);
+	if (ret)
+		goto err_undef_instr;
+	ret = register_trace_unhandled_abort(event_abort_unhandled_abort, NULL);
+	if (ret)
+		goto err_unhandled_abort;
+
+	return 0;
+
+err_unhandled_abort:
+	unregister_trace_undef_instr(event_abort_undef_instr, NULL);
+err_undef_instr:
+	unregister_trace_user_fault(event_abort_user_fault, NULL);
+err_usr_fault:
+	return ret;
+}
+
+static void event_abort_unregister(void)
+{
+	unregister_trace_user_fault(event_abort_user_fault, NULL);
+	unregister_trace_undef_instr(event_abort_undef_instr, NULL);
+	unregister_trace_unhandled_abort(event_abort_unhandled_abort, NULL);
+}
+
+static int event_abort_set(const char *val, struct kernel_param *kp)
+{
+	int ret;
+
+	ret = param_set_int(val, kp);
+	if (ret) {
+		pr_err("coresight_event: error setting value %d\n", ret);
+		return ret;
+	}
+
+	if (event_abort_enable)
+		ret = event_abort_register();
+	else
+		event_abort_unregister();
+
+	return ret;
+}
+
+static int event_abort_on_panic_set(const char *val, struct kernel_param *kp)
+{
+	int ret;
+
+	ret = param_set_int(val, kp);
+	if (ret) {
+		pr_err("coresight_event: error setting val on panic %d\n", ret);
+		return ret;
+	}
+
+	if (event_abort_early_panic) {
+		unregister_trace_kernel_panic_late(event_abort_kernel_panic,
+						   NULL);
+		 ret = register_trace_kernel_panic(event_abort_kernel_panic,
+						  NULL);
+		if (ret)
+			goto err;
+	} else {
+		unregister_trace_kernel_panic(event_abort_kernel_panic, NULL);
+		ret = register_trace_kernel_panic_late(event_abort_kernel_panic,
+							NULL);
+		if (ret)
+			goto err;
+	}
+	return 0;
+err:
+	pr_err("coresight_event: error registering panic event %d\n", ret);
+	return ret;
+}
+
+static int __init event_init(void)
+{
+	int ret;
+
+	ret = register_trace_kernel_panic(event_abort_kernel_panic, NULL);
+	if (ret) {
+		/* We do not want to fail module init. This module can still
+		 * be used to register other abort events.
+		 */
+		pr_err("coresight_event: error registering on panic %d\n", ret);
+	}
+	return 0;
+}
+module_init(event_init);
+
+static void __exit event_exit(void)
+{
+	unregister_trace_kernel_panic(event_abort_kernel_panic, NULL);
+}
+module_exit(event_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Coresight Event driver to abort tracing");
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index 3af358a..afe9f3d 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -153,12 +153,14 @@
 extern void msm_qdss_csr_disable_bam_to_usb(void);
 extern void msm_qdss_csr_disable_flush(void);
 extern int coresight_csr_hwctrl_set(uint64_t addr, uint32_t val);
+extern void coresight_csr_set_byte_cntr(uint32_t count);
 #else
 static inline void msm_qdss_csr_enable_bam_to_usb(void) {}
 static inline void msm_qdss_csr_disable_bam_to_usb(void) {}
 static inline void msm_qdss_csr_disable_flush(void) {}
-static inline int coresight_csr_hwctrl_set(uint64_t addr,	95
+static inline int coresight_csr_hwctrl_set(uint64_t addr,
 					   uint32_t val) { return -EINVAL; }
+static inline void coresight_csr_set_byte_cntr(uint32_t count) {}
 #endif
 
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-tgu.c b/drivers/hwtracing/coresight/coresight-tgu.c
new file mode 100644
index 0000000..e919f47
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-tgu.c
@@ -0,0 +1,534 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/amba/bus.h>
+#include <linux/topology.h>
+#include <linux/of.h>
+#include <linux/coresight.h>
+
+#include "coresight-priv.h"
+
+#define tgu_writel(drvdata, val, off)	__raw_writel((val), drvdata->base + off)
+#define tgu_readl(drvdata, off)		__raw_readl(drvdata->base + off)
+
+#define TGU_LOCK(drvdata)						\
+do {									\
+	mb(); /* ensure configuration take effect before we lock it */	\
+	tgu_writel(drvdata, 0x0, CORESIGHT_LAR);			\
+} while (0)
+#define TGU_UNLOCK(drvdata)						\
+do {									\
+	tgu_writel(drvdata, CORESIGHT_UNLOCK, CORESIGHT_LAR);		\
+	mb(); /* ensure unlock take effect before we configure */	\
+} while (0)
+
+#define TGU_CONTROL			0x0000
+#define TIMER0_STATUS			0x0004
+#define COUNTER0_STATUS			0x000C
+#define TGU_STATUS			0x0014
+#define TIMER0_COMPARE_STEP(n)		(0x0040 + 0x1D8 * n)
+#define COUNTER0_COMPARE_STEP(n)	(0x0048 + 0x1D8 * n)
+#define GROUP_REG_STEP(grp, reg, step)	(0x0074 + 0x60 * grp + 0x4 * reg + \
+								 0x1D8 * step)
+#define CONDITION_DECODE_STEP(m, n)	(0x0050 + 0x4 * m + 0x1D8 * n)
+#define CONDITION_SELECT_STEP(m, n)	(0x0060 + 0x4 * m + 0x1D8 * n)
+#define GROUP0				0x0074
+#define GROUP1				0x00D4
+#define GROUP2				0x0134
+#define GROUP3				0x0194
+#define TGU_LAR				0x0FB0
+
+#define MAX_GROUP_SETS			256
+#define MAX_GROUPS			4
+#define MAX_CONDITION_SETS		64
+#define MAX_TIMER_COUNTER_SETS		8
+
+#define to_tgu_drvdata(c)		container_of(c, struct tgu_drvdata, tgu)
+
+struct Trigger_group_data {
+	unsigned long grpaddr;
+	unsigned long value;
+};
+
+struct Trigger_condition_data {
+	unsigned long condaddr;
+	unsigned long value;
+};
+
+struct Trigger_select_data {
+	unsigned long selectaddr;
+	unsigned long value;
+};
+
+struct Trigger_timer_data {
+	unsigned long timeraddr;
+	unsigned long value;
+};
+
+struct Trigger_counter_data {
+	unsigned long counteraddr;
+	unsigned long value;
+};
+struct tgu_drvdata {
+	void __iomem			*base;
+	struct device			*dev;
+	struct coresight_device		*csdev;
+	struct clk			*clk;
+	spinlock_t			spinlock;
+	int				max_steps;
+	int				max_conditions;
+	int				max_regs;
+	int				max_timer_counter;
+	struct Trigger_group_data	*grp_data;
+	struct Trigger_condition_data	*condition_data;
+	struct Trigger_select_data	*select_data;
+	struct Trigger_timer_data	*timer_data;
+	struct Trigger_counter_data	*counter_data;
+	int				grp_refcnt;
+	int				cond_refcnt;
+	int				select_refcnt;
+	int				timer_refcnt;
+	int				counter_refcnt;
+	bool				enable;
+};
+
+static ssize_t enable_tgu(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t size)
+{
+	unsigned long value;
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	int ret, i, j;
+
+	if (kstrtoul(buf, 16, &value))
+		return -EINVAL;
+
+	/* Enable clock */
+	ret = pm_runtime_get_sync(drvdata->dev);
+	if (ret)
+		return ret;
+
+	spin_lock(&drvdata->spinlock);
+	/* Unlock the TGU LAR */
+	TGU_UNLOCK(drvdata);
+
+	if (value) {
+
+		/* Disable TGU to program the triggers */
+		tgu_writel(drvdata, 0, TGU_CONTROL);
+
+		/* program the TGU Group data for the desired use case*/
+
+		for (i = 0; i <= drvdata->grp_refcnt; i++)
+			tgu_writel(drvdata, drvdata->grp_data[i].value,
+						drvdata->grp_data[i].grpaddr);
+
+		/* program the unused Condition Decode registers NOT bits to 1*/
+		for (i = 0; i <= drvdata->max_conditions; i++) {
+			for (j = 0; j <= drvdata->max_steps; j++)
+				tgu_writel(drvdata, 0x1000000,
+						CONDITION_DECODE_STEP(i, j));
+		}
+		/* program the TGU Condition Decode for the desired use case*/
+		for (i = 0; i <= drvdata->cond_refcnt; i++)
+			tgu_writel(drvdata, drvdata->condition_data[i].value,
+					drvdata->condition_data[i].condaddr);
+
+		/* program the TGU Condition Select for the desired use case*/
+		for (i = 0; i <= drvdata->select_refcnt; i++)
+			tgu_writel(drvdata, drvdata->select_data[i].value,
+					drvdata->select_data[i].selectaddr);
+
+		/*  Timer and Counter Check */
+		for (i = 0; i <= drvdata->timer_refcnt; i++)
+			tgu_writel(drvdata, drvdata->timer_data[i].value,
+					drvdata->timer_data[i].timeraddr);
+
+		for (i = 0; i <= drvdata->counter_refcnt; i++)
+			tgu_writel(drvdata, drvdata->counter_data[i].value,
+					drvdata->counter_data[i].counteraddr);
+
+		/* Enable TGU to program the triggers */
+		tgu_writel(drvdata, 1, TGU_CONTROL);
+
+		drvdata->enable = true;
+		dev_dbg(dev, "Coresight-TGU enabled\n");
+
+	} else {
+		/* Disable TGU to program the triggers */
+		tgu_writel(drvdata, 0, TGU_CONTROL);
+		TGU_LOCK(drvdata);
+		spin_unlock(&drvdata->spinlock);
+
+		pm_runtime_put(drvdata->dev);
+		dev_dbg(dev, "Coresight-TGU disabled\n");
+	}
+
+	TGU_LOCK(drvdata);
+	spin_unlock(&drvdata->spinlock);
+	return size;
+}
+static DEVICE_ATTR(enable_tgu, 0200, NULL, enable_tgu);
+
+static ssize_t reset_tgu(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t size)
+{
+	unsigned long value;
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	int ret;
+
+	if (kstrtoul(buf, 16, &value))
+		return -EINVAL;
+
+	if (!drvdata->enable) {
+		/* Enable clock */
+		ret = pm_runtime_get_sync(drvdata->dev);
+		if (ret)
+			return ret;
+	}
+
+	spin_lock(&drvdata->spinlock);
+	/* Unlock the TGU LAR */
+	TGU_UNLOCK(drvdata);
+
+	if (value) {
+		/* Disable TGU to program the triggers */
+		tgu_writel(drvdata, 0, TGU_CONTROL);
+
+		/* Reset the Reference counters*/
+		drvdata->grp_refcnt = 0;
+		drvdata->cond_refcnt = 0;
+		drvdata->select_refcnt = 0;
+		drvdata->timer_refcnt = 0;
+		drvdata->counter_refcnt = 0;
+
+		dev_dbg(dev, "Coresight-TGU disabled\n");
+	} else
+		dev_dbg(dev, "Invalid input to reset the TGU\n");
+
+	TGU_LOCK(drvdata);
+	spin_unlock(&drvdata->spinlock);
+	pm_runtime_put(drvdata->dev);
+	return size;
+}
+static DEVICE_ATTR(reset_tgu, 0200, NULL, reset_tgu);
+
+static ssize_t set_group(struct device *dev, struct device_attribute *attr,
+						const char *buf, size_t size)
+{
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	int grp, reg, step;
+	unsigned long value;
+
+	if (drvdata->grp_refcnt >= MAX_GROUP_SETS) {
+		dev_err(drvdata->dev, " Too many groups are being configured");
+		return -EINVAL;
+	}
+
+	if (sscanf(buf, "%d %d %d %lx", &grp, &reg, &step, &value) != 4)
+		return -EINVAL;
+
+	spin_lock(&drvdata->spinlock);
+	if ((grp <= MAX_GROUPS) && (reg <= drvdata->max_regs)) {
+		drvdata->grp_data[drvdata->grp_refcnt].grpaddr =
+						GROUP_REG_STEP(grp, reg, step);
+		drvdata->grp_data[drvdata->grp_refcnt].value = value;
+		drvdata->grp_refcnt++;
+	} else
+		dev_err(drvdata->dev, "Invalid group data\n");
+
+	spin_unlock(&drvdata->spinlock);
+
+	return size;
+}
+static DEVICE_ATTR(set_group, 0200, NULL, set_group);
+
+static ssize_t tgu_set_condition(struct device *dev, struct device_attribute
+					*attr, const char *buf, size_t size)
+{
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	unsigned long value;
+	int cond, step;
+
+	if (drvdata->cond_refcnt >= MAX_CONDITION_SETS) {
+		dev_err(drvdata->dev, " Too many groups are being configured");
+		return -EINVAL;
+	}
+
+	if (sscanf(buf, "%d %d %lx", &cond, &step, &value) != 3)
+		return -EINVAL;
+
+	spin_lock(&drvdata->spinlock);
+	if ((cond <= drvdata->max_conditions) && (step <=
+						drvdata->max_steps)) {
+		drvdata->condition_data[drvdata->cond_refcnt].condaddr =
+					CONDITION_DECODE_STEP(cond, step);
+		drvdata->condition_data[drvdata->cond_refcnt].value = value;
+		drvdata->cond_refcnt++;
+	} else
+		dev_err(drvdata->dev, "Invalid condition decode data\n");
+
+	spin_unlock(&drvdata->spinlock);
+
+	return size;
+}
+static DEVICE_ATTR(set_condition, 0200, NULL, tgu_set_condition);
+
+static ssize_t tgu_set_select(struct device *dev, struct device_attribute *attr,
+						const char *buf, size_t size)
+{
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	unsigned long value;
+	int select, step;
+
+	if (drvdata->select_refcnt >= MAX_CONDITION_SETS) {
+		dev_err(drvdata->dev, " Too many groups are being configured");
+		return -EINVAL;
+	}
+
+	if (sscanf(buf, "%d %d %lx", &select, &step, &value) != 3)
+		return -EINVAL;
+
+	spin_lock(&drvdata->spinlock);
+
+	if ((select <= drvdata->max_conditions) && (step <=
+					drvdata->max_steps)) {
+		drvdata->select_data[drvdata->select_refcnt].selectaddr =
+					CONDITION_SELECT_STEP(select, step);
+		drvdata->select_data[drvdata->select_refcnt].value = value;
+		drvdata->select_refcnt++;
+	} else
+		dev_err(drvdata->dev, "Invalid select decode data\n");
+
+	spin_unlock(&drvdata->spinlock);
+
+	return size;
+}
+static DEVICE_ATTR(set_select, 0200, NULL, tgu_set_select);
+
+static ssize_t tgu_set_timers(struct device *dev, struct device_attribute *attr,
+						const char *buf, size_t size)
+{
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	unsigned long value;
+	int step;
+
+	if (drvdata->select_refcnt >= MAX_TIMER_COUNTER_SETS) {
+		dev_err(drvdata->dev, " Too many groups are being configured");
+		return -EINVAL;
+	}
+
+	if (sscanf(buf, "%d %lx", &step, &value) != 2)
+		return -EINVAL;
+
+	spin_lock(&drvdata->spinlock);
+	if (step <= drvdata->max_timer_counter) {
+		drvdata->timer_data[drvdata->timer_refcnt].timeraddr =
+						TIMER0_COMPARE_STEP(step);
+		drvdata->timer_data[drvdata->timer_refcnt].value = value;
+		drvdata->timer_refcnt++;
+	} else
+		dev_err(drvdata->dev, "Invalid TGU timer data\n");
+
+	spin_unlock(&drvdata->spinlock);
+
+	return size;
+}
+static DEVICE_ATTR(set_timer, 0200, NULL, tgu_set_timers);
+
+static ssize_t tgu_set_counters(struct device *dev, struct device_attribute
+					*attr, const char *buf, size_t size)
+{
+	struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	unsigned long value;
+	int step;
+
+	if (drvdata->counter_refcnt >= MAX_TIMER_COUNTER_SETS) {
+		dev_err(drvdata->dev, " Too many groups are being configured");
+		return -EINVAL;
+	}
+
+	if (sscanf(buf, "%d %lx", &step, &value) != 2)
+		return -EINVAL;
+
+	spin_lock(&drvdata->spinlock);
+	if (step <= drvdata->max_timer_counter) {
+		drvdata->counter_data[drvdata->counter_refcnt].counteraddr =
+						COUNTER0_COMPARE_STEP(step);
+		drvdata->counter_data[drvdata->counter_refcnt].value = value;
+		drvdata->counter_refcnt++;
+	} else
+		dev_err(drvdata->dev, "Invalid TGU counter data\n");
+
+	spin_unlock(&drvdata->spinlock);
+
+	return size;
+}
+static DEVICE_ATTR(set_counter, 0200, NULL, tgu_set_counters);
+
+static struct attribute *tgu_attrs[] = {
+	&dev_attr_enable_tgu.attr,
+	&dev_attr_reset_tgu.attr,
+	&dev_attr_set_group.attr,
+	&dev_attr_set_condition.attr,
+	&dev_attr_set_select.attr,
+	&dev_attr_set_timer.attr,
+	&dev_attr_set_counter.attr,
+	NULL,
+};
+
+static struct attribute_group tgu_attr_grp = {
+	.attrs = tgu_attrs,
+};
+
+static const struct attribute_group *tgu_attr_grps[] = {
+	&tgu_attr_grp,
+	NULL,
+};
+
+static int tgu_probe(struct amba_device *adev, const struct amba_id *id)
+{
+	int ret = 0;
+	struct device *dev = &adev->dev;
+	struct coresight_platform_data *pdata;
+	struct tgu_drvdata *drvdata;
+	struct coresight_desc *desc;
+
+	pdata = of_get_coresight_platform_data(dev, adev->dev.of_node);
+	if (IS_ERR(pdata))
+		return PTR_ERR(pdata);
+	adev->dev.platform_data = pdata;
+
+	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	drvdata->dev = &adev->dev;
+
+	dev_set_drvdata(dev, drvdata);
+
+	drvdata->base = devm_ioremap_resource(dev, &adev->res);
+	if (!drvdata->base)
+		return -ENOMEM;
+
+	spin_lock_init(&drvdata->spinlock);
+
+	ret = of_property_read_u32(adev->dev.of_node, "tgu-steps",
+						&drvdata->max_steps);
+	if (ret)
+		return -EINVAL;
+
+	ret = of_property_read_u32(adev->dev.of_node, "tgu-conditions",
+						&drvdata->max_conditions);
+	if (ret)
+		return -EINVAL;
+
+	ret = of_property_read_u32(adev->dev.of_node, "tgu-regs",
+							&drvdata->max_regs);
+	if (ret)
+		return -EINVAL;
+
+	ret = of_property_read_u32(adev->dev.of_node, "tgu-timer-counters",
+						&drvdata->max_timer_counter);
+	if (ret)
+		return -EINVAL;
+
+	/* Alloc memory for Grps, Conditions and Steps */
+	drvdata->grp_data = devm_kzalloc(dev, MAX_GROUP_SETS *
+				       sizeof(*drvdata->grp_data),
+				       GFP_KERNEL);
+	if (!drvdata->grp_data)
+		return -ENOMEM;
+
+	drvdata->condition_data = devm_kzalloc(dev, MAX_CONDITION_SETS *
+				       sizeof(*drvdata->condition_data),
+				       GFP_KERNEL);
+
+	if (!drvdata->condition_data)
+		return -ENOMEM;
+
+	drvdata->select_data = devm_kzalloc(dev, MAX_CONDITION_SETS *
+				       sizeof(*drvdata->select_data),
+				       GFP_KERNEL);
+	if (!drvdata->select_data)
+		return -ENOMEM;
+
+	drvdata->timer_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS *
+				       sizeof(*drvdata->timer_data),
+				       GFP_KERNEL);
+	if (!drvdata->timer_data)
+		return -ENOMEM;
+
+	drvdata->counter_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS *
+				       sizeof(*drvdata->counter_data),
+				       GFP_KERNEL);
+	if (!drvdata->counter_data)
+		return -ENOMEM;
+
+	drvdata->enable = false;
+
+	desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
+	if (!desc) {
+		ret = -ENOMEM;
+		goto err;
+	}
+	desc->type = CORESIGHT_DEV_TYPE_NONE;
+	desc->pdata = adev->dev.platform_data;
+	desc->dev = &adev->dev;
+	desc->groups = tgu_attr_grps;
+	drvdata->csdev = coresight_register(desc);
+	if (IS_ERR(drvdata->csdev)) {
+		ret = PTR_ERR(drvdata->csdev);
+		goto err;
+	}
+
+	pm_runtime_put(&adev->dev);
+	dev_dbg(dev, "TGU initialized\n");
+	return 0;
+err:
+	pm_runtime_put(&adev->dev);
+	return ret;
+}
+
+static struct amba_id tgu_ids[] = {
+	{
+		.id	=	0x0003b999,
+		.mask	=	0x0003ffff,
+		.data	=	"TGU",
+	},
+	{ 0, 0},
+};
+
+static struct amba_driver tgu_driver = {
+	.drv = {
+		.name			=	"coresight-tgu",
+		.owner			=	THIS_MODULE,
+		.suppress_bind_attrs	=	true,
+	},
+	.probe		=	tgu_probe,
+	.id_table	=	tgu_ids,
+};
+
+builtin_amba_driver(tgu_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("CoreSight TGU driver");
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index 85fe87f..4ade209 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -484,6 +484,36 @@
 	CS_LOCK(drvdata->base);
 }
 
+static void tmc_abort_etf_sink(struct coresight_device *csdev)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+	unsigned long flags;
+	enum tmc_mode mode;
+
+	spin_lock_irqsave(&drvdata->spinlock, flags);
+	if (drvdata->reading)
+		goto out0;
+
+	if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
+		tmc_etb_disable_hw(drvdata);
+	} else {
+
+		mode = readl_relaxed(drvdata->base + TMC_MODE);
+		if (mode == TMC_MODE_CIRCULAR_BUFFER)
+			tmc_etb_disable_hw(drvdata);
+		else
+			goto out1;
+	}
+out0:
+	drvdata->enable = false;
+	spin_unlock_irqrestore(&drvdata->spinlock, flags);
+
+	dev_info(drvdata->dev, "TMC aborted\n");
+	return;
+out1:
+	spin_unlock_irqrestore(&drvdata->spinlock, flags);
+}
+
 static const struct coresight_ops_sink tmc_etf_sink_ops = {
 	.enable		= tmc_enable_etf_sink,
 	.disable	= tmc_disable_etf_sink,
@@ -492,6 +522,7 @@
 	.set_buffer	= tmc_set_etf_buffer,
 	.reset_buffer	= tmc_reset_etf_buffer,
 	.update_buffer	= tmc_update_etf_buffer,
+	.abort		= tmc_abort_etf_sink,
 };
 
 static const struct coresight_ops_link tmc_etf_link_ops = {
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index eb355f4..eb70e7a 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -351,7 +351,7 @@
 	tmc_etr_sg_tbl_flush(vaddr, size);
 }
 
-static void tmc_etr_sg_rwp_pos(struct tmc_drvdata *drvdata, uint32_t rwp)
+void tmc_etr_sg_rwp_pos(struct tmc_drvdata *drvdata, uint32_t rwp)
 {
 	uint32_t i = 0, pte_n = 0, last_pte;
 	uint32_t *virt_st_tbl, *virt_pte;
@@ -403,6 +403,7 @@
 			break;
 	}
 }
+EXPORT_SYMBOL(tmc_etr_sg_rwp_pos);
 
 static void tmc_etr_mem_reset(struct tmc_drvdata *drvdata)
 {
@@ -831,6 +832,8 @@
 	drvdata->sticky_enable = true;
 out:
 	spin_unlock_irqrestore(&drvdata->spinlock, flags);
+	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
+		tmc_etr_byte_cntr_start(drvdata->byte_cntr);
 	mutex_unlock(&drvdata->mem_lock);
 
 	if (!ret)
@@ -919,15 +922,37 @@
 	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM) {
 		coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
 		coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
+		tmc_etr_byte_cntr_stop(drvdata->byte_cntr);
 	}
 out:
 	mutex_unlock(&drvdata->mem_lock);
 	dev_info(drvdata->dev, "TMC-ETR disabled\n");
 }
 
+static void tmc_abort_etr_sink(struct coresight_device *csdev)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+	unsigned long flags;
+
+	spin_lock_irqsave(&drvdata->spinlock, flags);
+	if (drvdata->reading)
+		goto out0;
+
+	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
+		tmc_etr_disable_hw(drvdata);
+	else if (drvdata->out_mode == TMC_ETR_OUT_MODE_USB)
+		__tmc_etr_disable_to_bam(drvdata);
+out0:
+	drvdata->enable = false;
+	spin_unlock_irqrestore(&drvdata->spinlock, flags);
+
+	dev_info(drvdata->dev, "TMC aborted\n");
+}
+
 static const struct coresight_ops_sink tmc_etr_sink_ops = {
 	.enable		= tmc_enable_etr_sink,
 	.disable	= tmc_disable_etr_sink,
+	.abort		= tmc_abort_etr_sink,
 };
 
 const struct coresight_ops tmc_etr_cs_ops = {
@@ -969,6 +994,11 @@
 		goto out;
 	}
 
+	if (drvdata->byte_cntr && drvdata->byte_cntr->enable) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	/* Disable the TMC if need be */
 	if (val == CS_MODE_SYSFS)
 		tmc_etr_disable_hw(drvdata);
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
index b97ebb8..6f13eb3 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.c
+++ b/drivers/hwtracing/coresight/coresight-tmc.c
@@ -459,6 +459,42 @@
 }
 static DEVICE_ATTR_RW(mem_type);
 
+static ssize_t block_size_show(struct device *dev,
+			     struct device_attribute *attr,
+			     char *buf)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	uint32_t val = 0;
+
+	if (drvdata->byte_cntr)
+		val = drvdata->byte_cntr->block_size;
+
+	return scnprintf(buf, PAGE_SIZE, "%d\n",
+			val);
+}
+
+static ssize_t block_size_store(struct device *dev,
+			      struct device_attribute *attr,
+			      const char *buf,
+			      size_t size)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	unsigned long val;
+
+	if (kstrtoul(buf, 0, &val))
+		return -EINVAL;
+
+	if (!drvdata->byte_cntr)
+		return -EINVAL;
+
+	mutex_lock(&drvdata->byte_cntr->byte_cntr_lock);
+	drvdata->byte_cntr->block_size = val * 8;
+	mutex_unlock(&drvdata->byte_cntr->byte_cntr_lock);
+
+	return size;
+}
+static DEVICE_ATTR_RW(block_size);
+
 static struct attribute *coresight_tmc_etf_attrs[] = {
 	&dev_attr_trigger_cntr.attr,
 	NULL,
@@ -470,6 +506,7 @@
 	&dev_attr_trigger_cntr.attr,
 	&dev_attr_out_mode.attr,
 	&dev_attr_available_out_modes.attr,
+	&dev_attr_block_size.attr,
 	NULL,
 };
 
@@ -587,6 +624,8 @@
 		desc.groups = coresight_tmc_etr_groups;
 		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
 
+		drvdata->byte_cntr = byte_cntr_init(adev, drvdata);
+
 		ret = tmc_etr_bam_init(adev, drvdata);
 		if (ret)
 			goto out;
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index 6643adc..fe6bc76 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -27,6 +27,8 @@
 #include <linux/usb/usb_qdss.h>
 #include <linux/coresight-cti.h>
 
+#include "coresight-byte-cntr.h"
+
 #define TMC_RSZ			0x004
 #define TMC_STS			0x00c
 #define TMC_RRD			0x010
@@ -167,7 +169,7 @@
 	bool			enable;
 	char			*buf;
 	dma_addr_t		paddr;
-	void __iomem		*vaddr;
+	void			*vaddr;
 	u32			size;
 	u32			len;
 	local_t			mode;
@@ -187,6 +189,7 @@
 	bool			sticky_enable;
 	struct coresight_cti	*cti_flush;
 	struct coresight_cti	*cti_reset;
+	struct byte_cntr	*byte_cntr;
 };
 
 /* Generic functions */
@@ -214,5 +217,9 @@
 		  struct usb_qdss_ch *ch);
 int tmc_etr_bam_init(struct amba_device *adev,
 		     struct tmc_drvdata *drvdata);
+extern struct byte_cntr *byte_cntr_init(struct amba_device *adev,
+					struct tmc_drvdata *drvdata);
+extern void tmc_etr_sg_rwp_pos(struct tmc_drvdata *drvdata, uint32_t rwp);
+
 extern const struct coresight_ops tmc_etr_cs_ops;
 #endif
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index e233e76..7598ab8 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -29,7 +29,7 @@
 #include "coresight-priv.h"
 
 static DEFINE_MUTEX(coresight_mutex);
-
+static struct coresight_device *curr_sink;
 /**
  * struct coresight_node - elements of a path, from source to sink
  * @csdev:	Address of an element.
@@ -577,7 +577,7 @@
 	coresight_release_path(csdev, path);
 	goto out;
 }
-EXPORT_SYMBOL_GPL(coresight_enable);
+EXPORT_SYMBOL(coresight_enable);
 
 static void __coresight_disable(struct coresight_device *csdev)
 {
@@ -604,7 +604,27 @@
 	__coresight_disable(csdev);
 	mutex_unlock(&coresight_mutex);
 }
-EXPORT_SYMBOL_GPL(coresight_disable);
+EXPORT_SYMBOL(coresight_disable);
+
+void coresight_abort(void)
+{
+	if (!mutex_trylock(&coresight_mutex)) {
+		pr_err("coresight: abort could not be processed\n");
+		return;
+	}
+	if (!curr_sink)
+		goto out;
+
+	if (curr_sink->enable && sink_ops(curr_sink)->abort) {
+		sink_ops(curr_sink)->abort(curr_sink);
+		curr_sink->enable = false;
+	}
+
+out:
+	mutex_unlock(&coresight_mutex);
+}
+EXPORT_SYMBOL(coresight_abort);
+
 
 static ssize_t enable_sink_show(struct device *dev,
 				struct device_attribute *attr, char *buf)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 81bbd78..5473fcf 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -182,8 +182,8 @@
 		} while (ep);
 	}
 
-	/* Affinity defaults to CPU0 */
-	pdata->cpu = 0;
+	/* Affinity defaults to invalid */
+	pdata->cpu = -1;
 	dn = of_parse_phandle(node, "cpu", 0);
 	for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) {
 		if (dn == of_get_cpu_node(cpu, NULL)) {
diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
index 0bba384..63b5db4 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -85,6 +85,16 @@
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6),
 		.driver_data = (kernel_ulong_t)0,
 	},
+	{
+		/* Cannon Lake H */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa326),
+		.driver_data = (kernel_ulong_t)0,
+	},
+	{
+		/* Cannon Lake LP */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9da6),
+		.driver_data = (kernel_ulong_t)0,
+	},
 	{ 0 },
 };
 
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a9cf687..b8353ad 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -1224,4 +1224,16 @@
 	  This driver can also be built as a module. If so, the module will be
 	  called as i2c-opal.
 
+config I2C_MSM_V2
+        tristate "I2C_MSM_V2"
+        depends on ARCH_QCOM
+        help
+          If you say yes to this option, support will be included for the
+          built-in I2C interface and its DMA engine on the MSM family
+          processors.
+
+          This driver can also be built as a module.  If so, the module
+          will be called i2c-msm-v2.
+
+
 endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 7f2523f..190f8ba 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -100,6 +100,7 @@
 obj-$(CONFIG_I2C_XLR)		+= i2c-xlr.o
 obj-$(CONFIG_I2C_XLP9XX)	+= i2c-xlp9xx.o
 obj-$(CONFIG_I2C_RCAR)		+= i2c-rcar.o
+obj-$(CONFIG_I2C_MSM_V2)        += i2c-msm-v2.o
 
 # External I2C/SMBus adapter drivers
 obj-$(CONFIG_I2C_DIOLAN_U2C)	+= i2c-diolan-u2c.o
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0b42a12..b42d95f 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -319,7 +319,7 @@
 #endif
 
 #ifdef CONFIG_PM
-static int dw_i2c_plat_suspend(struct device *dev)
+static int dw_i2c_plat_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
@@ -343,11 +343,21 @@
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int dw_i2c_plat_suspend(struct device *dev)
+{
+	pm_runtime_resume(dev);
+	return dw_i2c_plat_runtime_suspend(dev);
+}
+#endif
+
 static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
 	.prepare = dw_i2c_plat_prepare,
 	.complete = dw_i2c_plat_complete,
 	SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
-	SET_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL)
+	SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend,
+			   dw_i2c_plat_resume,
+			   NULL)
 };
 
 #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index f573448..8477292 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -341,8 +341,10 @@
 			break;
 		case I2C_SMBUS_BLOCK_DATA:
 		case I2C_SMBUS_I2C_BLOCK_DATA:
-			memcpy(&data->block[1], dma_buffer, desc->rxbytes);
-			data->block[0] = desc->rxbytes;
+			if (desc->rxbytes != dma_buffer[0] + 1)
+				return -EMSGSIZE;
+
+			memcpy(data->block, dma_buffer, desc->rxbytes);
 			break;
 		}
 		return 0;
diff --git a/drivers/i2c/busses/i2c-msm-v2.c b/drivers/i2c/busses/i2c-msm-v2.c
new file mode 100644
index 0000000..4daed7f
--- /dev/null
+++ b/drivers/i2c/busses/i2c-msm-v2.c
@@ -0,0 +1,3039 @@
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ *
+ */
+/*
+ * I2C controller driver for Qualcomm Technologies Inc platforms
+ */
+
+#define pr_fmt(fmt) "#%d " fmt "\n", __LINE__
+
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/mutex.h>
+#include <linux/timer.h>
+#include <linux/time.h>
+#include <linux/slab.h>
+#include <linux/pm_runtime.h>
+#include <linux/dma-mapping.h>
+#include <linux/i2c.h>
+#include <linux/of.h>
+#include <linux/msm-sps.h>
+#include <linux/msm-bus.h>
+#include <linux/msm-bus-board.h>
+#include <linux/i2c/i2c-msm-v2.h>
+
+#ifdef DEBUG
+static const enum msm_i2_debug_level DEFAULT_DBG_LVL = MSM_DBG;
+#else
+static const enum msm_i2_debug_level DEFAULT_DBG_LVL = MSM_ERR;
+#endif
+
+/* Forward declarations */
+static bool i2c_msm_xfer_next_buf(struct i2c_msm_ctrl *ctrl);
+static int i2c_msm_xfer_wait_for_completion(struct i2c_msm_ctrl *ctrl,
+						struct completion *complete);
+static int  i2c_msm_pm_resume(struct device *dev);
+static void i2c_msm_pm_suspend(struct device *dev);
+static void i2c_msm_clk_path_init(struct i2c_msm_ctrl *ctrl);
+static void i2c_msm_pm_pinctrl_state(struct i2c_msm_ctrl *ctrl,
+						bool runtime_active);
+
+/* string table for enum i2c_msm_xfer_mode_id */
+const char * const i2c_msm_mode_str_tbl[] = {
+	"FIFO", "BLOCK", "DMA", "None",
+};
+
+static const u32 i2c_msm_fifo_block_sz_tbl[] = {16, 16, 32, 0};
+
+/* from enum i2c_msm_xfer_mode_id to qup_io_modes register values */
+static const u32 i2c_msm_mode_to_reg_tbl[] = {
+	0x0, /* map I2C_MSM_XFER_MODE_FIFO -> binary 00 */
+	0x1, /* map I2C_MSM_XFER_MODE_BLOCK -> binary 01 */
+	0x3  /* map I2C_MSM_XFER_MODE_DMA -> binary 11 */
+};
+
+const char *i2c_msm_err_str_table[] = {
+	[I2C_MSM_NO_ERR]     = "NONE",
+	[I2C_MSM_ERR_NACK]   = "NACK: slave not responding, ensure its powered",
+	[I2C_MSM_ERR_ARB_LOST] = "ARB_LOST",
+	[I2C_MSM_ERR_BUS_ERR] = "BUS ERROR:noisy bus/unexpected start/stop tag",
+	[I2C_MSM_ERR_TIMEOUT]  = "TIMEOUT_ERROR",
+	[I2C_MSM_ERR_CORE_CLK] = "CLOCK OFF: Check Core Clock",
+	[I2C_MSM_ERR_OVR_UNDR_RUN] = "OVER_UNDER_RUN_ERROR",
+};
+
+static void i2c_msm_dbg_dump_diag(struct i2c_msm_ctrl *ctrl,
+				bool use_param_vals, u32 status, u32 qup_op)
+{
+	struct i2c_msm_xfer *xfer = &ctrl->xfer;
+	const char *str = i2c_msm_err_str_table[xfer->err];
+	char buf[I2C_MSM_REG_2_STR_BUF_SZ];
+
+	if (!use_param_vals) {
+		void __iomem        *base = ctrl->rsrcs.base;
+
+		status = readl_relaxed(base + QUP_I2C_STATUS);
+		qup_op = readl_relaxed(base + QUP_OPERATIONAL);
+	}
+
+	if (xfer->err == I2C_MSM_ERR_TIMEOUT) {
+		/*
+		 * if we are not the bus master or SDA/SCL is low then it may be
+		 * that slave is pulling the lines low. Otherwise it is likely a
+		 * GPIO issue
+		 */
+		if (!(status & QUP_BUS_MASTER))
+			snprintf(buf, I2C_MSM_REG_2_STR_BUF_SZ,
+				"%s(val:%dmsec) misconfigured GPIO or slave pulling bus line(s) low\n",
+				str, jiffies_to_msecs(xfer->timeout));
+		else
+			snprintf(buf, I2C_MSM_REG_2_STR_BUF_SZ,
+			"%s(val:%dmsec)", str, jiffies_to_msecs(xfer->timeout));
+
+		str = buf;
+	}
+
+	/* dump xfer details */
+	dev_err(ctrl->dev,
+		"%s: msgs(n:%d cur:%d %s) bc(rx:%zu tx:%zu) mode:%s slv_addr:0x%0x MSTR_STS:0x%08x OPER:0x%08x\n",
+		str, xfer->msg_cnt, xfer->cur_buf.msg_idx,
+		xfer->cur_buf.is_rx ? "rx" : "tx", xfer->rx_cnt, xfer->tx_cnt,
+		i2c_msm_mode_str_tbl[xfer->mode_id], xfer->msgs->addr,
+		status, qup_op);
+}
+
+static u32 i2c_msm_reg_io_modes_out_blk_sz(u32 qup_io_modes)
+{
+	return i2c_msm_fifo_block_sz_tbl[qup_io_modes & 0x3];
+}
+
+static u32 i2c_msm_reg_io_modes_in_blk_sz(u32 qup_io_modes)
+{
+	return i2c_msm_fifo_block_sz_tbl[BITS_AT(qup_io_modes, 5, 2)];
+}
+
+static const u32 i2c_msm_fifo_sz_table[] = {2, 4, 8, 16};
+
+static void i2c_msm_qup_fifo_calc_size(struct i2c_msm_ctrl *ctrl)
+{
+	u32 reg_data, output_fifo_size, input_fifo_size;
+	struct i2c_msm_xfer_mode_fifo *fifo = &ctrl->xfer.fifo;
+
+	/* Gurad to read fifo size only once. It hard wired and never changes */
+	if (fifo->input_fifo_sz && fifo->output_fifo_sz)
+		return;
+
+	reg_data = readl_relaxed(ctrl->rsrcs.base + QUP_IO_MODES);
+	output_fifo_size  = BITS_AT(reg_data, 2, 2);
+	input_fifo_size   = BITS_AT(reg_data, 7, 2);
+
+	fifo->input_fifo_sz = i2c_msm_reg_io_modes_in_blk_sz(reg_data) *
+					i2c_msm_fifo_sz_table[input_fifo_size];
+	fifo->output_fifo_sz = i2c_msm_reg_io_modes_out_blk_sz(reg_data) *
+					i2c_msm_fifo_sz_table[output_fifo_size];
+
+	i2c_msm_dbg(ctrl, MSM_PROF, "QUP input-sz:%zu, input-sz:%zu",
+			fifo->input_fifo_sz, fifo->output_fifo_sz);
+
+}
+
+/*
+ * i2c_msm_tag_byte: accessor for tag as four bytes array
+ */
+static u8 *i2c_msm_tag_byte(struct i2c_msm_tag *tag, int byte_n)
+{
+	return ((u8 *)tag) + byte_n;
+}
+
+/*
+ * i2c_msm_buf_to_ptr: translates a xfer buf to a pointer into the i2c_msg data
+ */
+static u8 *i2c_msm_buf_to_ptr(struct i2c_msm_xfer_buf *buf)
+{
+	struct i2c_msm_xfer *xfer =
+				container_of(buf, struct i2c_msm_xfer, cur_buf);
+	struct i2c_msg *msg = xfer->msgs + buf->msg_idx;
+
+	return msg->buf + buf->byte_idx;
+}
+
+/*
+ * tag_lookup_table[is_new_addr][is_last][is_rx]
+ * @is_new_addr Is start tag required? (which requires two more bytes.)
+ * @is_last     Use the XXXXX_N_STOP tag variant
+ * @is_rx       READ/WRITE
+ */
+static const struct i2c_msm_tag tag_lookup_table[2][2][2] = {
+	{{{QUP_TAG2_DATA_WRITE,					2},
+	   {QUP_TAG2_DATA_READ,					2} },
+	/* last buffer */
+	  {{QUP_TAG2_DATA_WRITE_N_STOP,				2},
+	   {QUP_TAG2_DATA_READ_N_STOP,				2} } },
+	/* new addr */
+	 {{{QUP_TAG2_START | (QUP_TAG2_DATA_WRITE           << 16), 4},
+	   {QUP_TAG2_START | (QUP_TAG2_DATA_READ            << 16), 4} },
+	/* last buffer + new addr */
+	  {{QUP_TAG2_START | (QUP_TAG2_DATA_WRITE_N_STOP    << 16), 4},
+	   {QUP_TAG2_START | (QUP_TAG2_DATA_READ_N_STOP     << 16), 4} } },
+};
+
+/*
+ * i2c_msm_tag_create: format a qup tag ver2
+ */
+static struct i2c_msm_tag i2c_msm_tag_create(bool is_new_addr, bool is_last_buf,
+					bool is_rx, u8 buf_len, u8 slave_addr)
+{
+	struct i2c_msm_tag tag;
+	/* Normalize booleans to 1 or 0 */
+	is_new_addr = is_new_addr ? 1 : 0;
+	is_last_buf = is_last_buf ? 1 : 0;
+	is_rx = is_rx ? 1 : 0;
+
+	tag = tag_lookup_table[is_new_addr][is_last_buf][is_rx];
+	/* fill in the non-const value: the address and the length */
+	if (tag.len == I2C_MSM_TAG2_MAX_LEN) {
+		*i2c_msm_tag_byte(&tag, 1) = slave_addr;
+		*i2c_msm_tag_byte(&tag, 3) = buf_len;
+	} else {
+		*i2c_msm_tag_byte(&tag, 1) = buf_len;
+	}
+
+	return tag;
+}
+
+static int
+i2c_msm_qup_state_wait_valid(struct i2c_msm_ctrl *ctrl,
+			enum i2c_msm_qup_state state, bool only_valid)
+{
+	u32 status;
+	void __iomem  *base     = ctrl->rsrcs.base;
+	int ret      = 0;
+	int read_cnt = 0;
+
+	do {
+		status = readl_relaxed(base + QUP_STATE);
+		++read_cnt;
+
+		/*
+		 * If only valid bit needs to be checked, requested state is
+		 * 'don't care'
+		 */
+		if (status & QUP_STATE_VALID) {
+			if (only_valid)
+				goto poll_valid_end;
+			else if ((state & QUP_I2C_MAST_GEN) &&
+					(status & QUP_I2C_MAST_GEN))
+				goto poll_valid_end;
+			else if ((status & QUP_STATE_MASK) == state)
+				goto poll_valid_end;
+		}
+
+		/*
+		 * Sleeping for 1-1.5 ms for every 100 iterations and break if
+		 * iterations crosses the 1500 marks allows roughly 10-15 msec
+		 * of time to get the core to valid state.
+		 */
+		if (!(read_cnt % 100))
+			usleep_range(1000, 1500);
+	} while (read_cnt <= 1500);
+
+	ret = -ETIMEDOUT;
+	dev_err(ctrl->dev,
+		"error timeout on polling for valid state. check core_clk\n");
+
+poll_valid_end:
+	if (!only_valid)
+		i2c_msm_prof_evnt_add(ctrl, MSM_DBG, I2C_MSM_VALID_END,
+				/* aggregate ret and state */
+				(((-ret) & 0xff) | ((state & 0xf) << 16)),
+				read_cnt, status);
+
+	return ret;
+}
+
+static int i2c_msm_qup_state_set(struct i2c_msm_ctrl *ctrl,
+						enum i2c_msm_qup_state state)
+{
+	if (i2c_msm_qup_state_wait_valid(ctrl, 0, true))
+		return -EIO;
+
+	writel_relaxed(state, ctrl->rsrcs.base + QUP_STATE);
+
+	if (i2c_msm_qup_state_wait_valid(ctrl, state, false))
+		return -EIO;
+
+	return 0;
+}
+
+static int i2c_msm_qup_sw_reset(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	writel_relaxed(1, ctrl->rsrcs.base + QUP_SW_RESET);
+	/*
+	 * Ensure that QUP that reset state is written before waiting for a the
+	 * reset state to be valid.
+	 */
+	wmb();
+	ret = i2c_msm_qup_state_wait_valid(ctrl, QUP_STATE_RESET, false);
+	if (ret) {
+		if (atomic_read(&ctrl->xfer.is_active))
+			ctrl->xfer.err = I2C_MSM_ERR_CORE_CLK;
+		dev_err(ctrl->dev, "error on issuing QUP software-reset\n");
+	}
+	return ret;
+}
+
+/*
+ * i2c_msm_qup_xfer_init_reset_state: setup QUP registers for the next run state
+ * @pre QUP must be in reset state.
+ * @pre xfer->mode_id is set to the chosen transfer state
+ * @post update values in QUP_MX_*_COUNT, QUP_CONFIG, QUP_IO_MODES,
+ *       and QUP_OPERATIONAL_MASK registers
+ */
+static void
+i2c_msm_qup_xfer_init_reset_state(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer *xfer = &ctrl->xfer;
+	void __iomem * const base = ctrl->rsrcs.base;
+	u32  mx_rd_cnt     = 0;
+	u32  mx_wr_cnt     = 0;
+	u32  mx_in_cnt     = 0;
+	u32  mx_out_cnt    = 0;
+	u32  no_input      = 0;
+	u32  no_output     = 0;
+	u32  input_mode    = i2c_msm_mode_to_reg_tbl[xfer->mode_id] << 12;
+	u32  output_mode   = i2c_msm_mode_to_reg_tbl[xfer->mode_id] << 10;
+	u32  config_reg;
+	u32  io_modes_reg;
+	u32  op_mask;
+	u32  rx_cnt = 0;
+	u32  tx_cnt = 0;
+	/*
+	 * DMA mode:
+	 * 1. QUP_MX_*_COUNT must be zero in all cases.
+	 * 2. both QUP_NO_INPUT and QUP_NO_OUTPUT are unset.
+	 * FIFO mode:
+	 * 1. QUP_MX_INPUT_COUNT and QUP_MX_OUTPUT_COUNT are zero
+	 * 2. QUP_MX_READ_COUNT and QUP_MX_WRITE_COUNT reflect true count
+	 * 3. QUP_NO_INPUT and QUP_NO_OUTPUT are set according to counts
+	 */
+	if (xfer->mode_id != I2C_MSM_XFER_MODE_DMA) {
+		rx_cnt   = xfer->rx_cnt + xfer->rx_ovrhd_cnt;
+		tx_cnt   = xfer->tx_cnt + xfer->tx_ovrhd_cnt;
+		no_input = rx_cnt  ? 0 : QUP_NO_INPUT;
+
+		switch (xfer->mode_id) {
+		case I2C_MSM_XFER_MODE_FIFO:
+			mx_rd_cnt  = rx_cnt;
+			mx_wr_cnt  = tx_cnt;
+			break;
+		case I2C_MSM_XFER_MODE_BLOCK:
+			mx_in_cnt  = rx_cnt;
+			mx_out_cnt = tx_cnt;
+			break;
+		default:
+			break;
+		}
+	}
+
+	/* init DMA/BLOCK modes counter */
+	writel_relaxed(mx_in_cnt,  base + QUP_MX_INPUT_COUNT);
+	writel_relaxed(mx_out_cnt, base + QUP_MX_OUTPUT_COUNT);
+
+	/* int FIFO mode counter */
+	writel_relaxed(mx_rd_cnt, base + QUP_MX_READ_COUNT);
+	writel_relaxed(mx_wr_cnt, base + QUP_MX_WRITE_COUNT);
+
+	/*
+	 * Set QUP mini-core to I2C tags ver-2
+	 * sets NO_INPUT / NO_OUTPUT as needed
+	 */
+	config_reg = readl_relaxed(base + QUP_CONFIG);
+	config_reg &=
+	      ~(QUP_NO_INPUT | QUP_NO_OUTPUT | QUP_N_MASK | QUP_MINI_CORE_MASK);
+	config_reg |= (no_input | no_output | QUP_N_VAL |
+							QUP_MINI_CORE_I2C_VAL);
+	writel_relaxed(config_reg, base + QUP_CONFIG);
+
+	/*
+	 * Turns-on packing/unpacking
+	 * sets NO_INPUT / NO_OUTPUT as needed
+	 */
+	io_modes_reg = readl_relaxed(base + QUP_IO_MODES);
+	io_modes_reg &=
+	   ~(QUP_INPUT_MODE | QUP_OUTPUT_MODE | QUP_PACK_EN | QUP_UNPACK_EN
+	     | QUP_OUTPUT_BIT_SHIFT_EN);
+	io_modes_reg |=
+	   (input_mode | output_mode | QUP_PACK_EN | QUP_UNPACK_EN);
+	writel_relaxed(io_modes_reg, base + QUP_IO_MODES);
+
+	/*
+	 * mask INPUT and OUTPUT service flags in to prevent IRQs on FIFO status
+	 * change on DMA-mode transfers
+	 */
+	op_mask = (xfer->mode_id == I2C_MSM_XFER_MODE_DMA) ?
+		    (QUP_INPUT_SERVICE_MASK | QUP_OUTPUT_SERVICE_MASK) : 0;
+	writel_relaxed(op_mask, base + QUP_OPERATIONAL_MASK);
+	/* Ensure that QUP configuration is written before leaving this func */
+	wmb();
+}
+
+/*
+ * i2c_msm_clk_div_fld:
+ * @clk_freq_out output clock frequency
+ * @fs_div fs divider value
+ * @ht_div high time divider value
+ */
+struct i2c_msm_clk_div_fld {
+	u32                clk_freq_out;
+	u8                 fs_div;
+	u8                 ht_div;
+};
+
+/*
+ * divider values as per HW Designers
+ */
+static struct i2c_msm_clk_div_fld i2c_msm_clk_div_map[] = {
+	{KHz(100), 124, 62},
+	{KHz(400),  28, 14},
+	{KHz(1000),  8,  5},
+};
+
+/*
+ * @return zero on success
+ * @fs_div when zero use value from table above, otherwise use given value
+ * @ht_div when zero use value from table above, otherwise use given value
+ *
+ * Format the value to be configured into the clock divider register. This
+ * register is configured every time core is moved from reset to run state.
+ */
+static int i2c_msm_set_mstr_clk_ctl(struct i2c_msm_ctrl *ctrl, int fs_div,
+			int ht_div, int noise_rjct_scl, int noise_rjct_sda)
+{
+	int ret = 0;
+	int i;
+	u32 reg_val = 0;
+	struct i2c_msm_clk_div_fld *itr = i2c_msm_clk_div_map;
+
+	/* set noise rejection values for scl and sda */
+	reg_val = I2C_MSM_SCL_NOISE_REJECTION(reg_val, noise_rjct_scl);
+	reg_val = I2C_MSM_SDA_NOISE_REJECTION(reg_val, noise_rjct_sda);
+
+	/*
+	 * find matching freq and set divider values unless they are forced
+	 * from parametr list
+	 */
+	for (i = 0; i < ARRAY_SIZE(i2c_msm_clk_div_map); ++i, ++itr) {
+		if (ctrl->rsrcs.clk_freq_out == itr->clk_freq_out) {
+			if (!fs_div)
+				fs_div = itr->fs_div;
+			if (!ht_div)
+				ht_div = itr->ht_div;
+			break;
+		}
+	}
+	if (!fs_div) {
+		dev_err(ctrl->dev, "For non-standard clock freq:%dKHz\n"
+		"clk divider value fs_div should be supply by client through\n"
+		"device tree\n", (ctrl->rsrcs.clk_freq_out / 1000));
+		return -EINVAL;
+	}
+
+	/* format values in clk-ctl cache */
+	ctrl->mstr_clk_ctl = (reg_val & (~0xff07ff)) | ((ht_div & 0xff) << 16)
+							|(fs_div & 0xff);
+
+	return ret;
+}
+
+/*
+ * i2c_msm_qup_xfer_init_run_state: set qup regs which must be set *after* reset
+ */
+static void i2c_msm_qup_xfer_init_run_state(struct i2c_msm_ctrl *ctrl)
+{
+	void __iomem *base = ctrl->rsrcs.base;
+
+	writel_relaxed(ctrl->mstr_clk_ctl, base + QUP_I2C_MASTER_CLK_CTL);
+
+	/* Ensure that QUP configuration is written before leaving this func */
+	wmb();
+
+	if (ctrl->dbgfs.dbg_lvl == MSM_DBG) {
+		dev_info(ctrl->dev,
+			"QUP state after programming for next transfers\n");
+		i2c_msm_dbg_qup_reg_dump(ctrl);
+	}
+}
+
+static void i2c_msm_fifo_wr_word(struct i2c_msm_ctrl *ctrl, u32 data)
+{
+	writel_relaxed(data, ctrl->rsrcs.base + QUP_OUT_FIFO_BASE);
+	i2c_msm_dbg(ctrl, MSM_DBG, "OUT-FIFO:0x%08x", data);
+}
+
+static u32 i2c_msm_fifo_rd_word(struct i2c_msm_ctrl *ctrl, u32 *data)
+{
+	u32 val;
+
+	val = readl_relaxed(ctrl->rsrcs.base + QUP_IN_FIFO_BASE);
+	i2c_msm_dbg(ctrl, MSM_DBG, "IN-FIFO :0x%08x", val);
+
+	if (data)
+		*data = val;
+
+	return val;
+}
+
+/*
+ * i2c_msm_fifo_wr_buf_flush:
+ */
+static void i2c_msm_fifo_wr_buf_flush(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_fifo *fifo = &ctrl->xfer.fifo;
+	u32 *word;
+
+	if (!fifo->out_buf_idx)
+		return;
+
+	word = (u32 *) fifo->out_buf;
+	i2c_msm_fifo_wr_word(ctrl, *word);
+	fifo->out_buf_idx = 0;
+	*word = 0;
+}
+
+/*
+ * i2c_msm_fifo_wr_buf:
+ *
+ * @len buf size (in bytes)
+ * @return number of bytes from buf which have been processed (written to
+ *         FIFO or kept in out buffer and will be written later)
+ */
+static size_t
+i2c_msm_fifo_wr_buf(struct i2c_msm_ctrl *ctrl, u8 *buf, size_t len)
+{
+	struct i2c_msm_xfer_mode_fifo *fifo = &ctrl->xfer.fifo;
+	int i;
+
+	for (i = 0 ; i < len; ++i, ++buf) {
+
+		fifo->out_buf[fifo->out_buf_idx] = *buf;
+		++fifo->out_buf_idx;
+
+		if (fifo->out_buf_idx == 4) {
+			u32 *word = (u32 *) fifo->out_buf;
+
+			i2c_msm_fifo_wr_word(ctrl, *word);
+			fifo->out_buf_idx = 0;
+			*word = 0;
+		}
+	}
+	return i;
+}
+
+static size_t i2c_msm_fifo_xfer_wr_tag(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *buf = &ctrl->xfer.cur_buf;
+	size_t len = 0;
+
+	if (ctrl->dbgfs.dbg_lvl >= MSM_DBG) {
+		char str[I2C_MSM_REG_2_STR_BUF_SZ];
+
+		dev_info(ctrl->dev, "tag.val:0x%llx tag.len:%d %s\n",
+			buf->out_tag.val, buf->out_tag.len,
+			i2c_msm_dbg_tag_to_str(&buf->out_tag, str,
+								sizeof(str)));
+	}
+
+	if (buf->out_tag.len) {
+		len = i2c_msm_fifo_wr_buf(ctrl, (u8 *) &buf->out_tag.val,
+							buf->out_tag.len);
+
+		if (len < buf->out_tag.len)
+			goto done;
+
+		buf->out_tag = (struct i2c_msm_tag) {0};
+	}
+done:
+	return len;
+}
+
+/*
+ * i2c_msm_fifo_read: reads up to fifo size into user's buf
+ */
+static void i2c_msm_fifo_read_xfer_buf(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *buf = &ctrl->xfer.cur_buf;
+	struct i2c_msg          *msg = ctrl->xfer.msgs + buf->msg_idx;
+	u8 *p_tag_val   = (u8 *) &buf->in_tag.val;
+	int buf_need_bc = msg->len - buf->byte_idx;
+	u8  word[4];
+	int copy_bc;
+	int word_idx;
+	int word_bc;
+
+	if (!buf->is_rx)
+		return;
+
+	while (buf_need_bc || buf->in_tag.len) {
+		i2c_msm_fifo_rd_word(ctrl, (u32 *) word);
+		word_bc  = sizeof(word);
+		word_idx = 0;
+
+		/*
+		 * copy bytes from fifo word to tag.
+		 * @note buf->in_tag.len (max 2bytes) < word_bc (4bytes)
+		 */
+		if (buf->in_tag.len) {
+			copy_bc = min_t(int, word_bc, buf->in_tag.len);
+
+			memcpy(p_tag_val + buf->in_tag.len, word, copy_bc);
+
+			word_idx        += copy_bc;
+			word_bc         -= copy_bc;
+			buf->in_tag.len -= copy_bc;
+
+			if ((ctrl->dbgfs.dbg_lvl >= MSM_DBG) &&
+							!buf->in_tag.len) {
+				char str[64];
+
+				dev_info(ctrl->dev, "%s\n",
+					i2c_msm_dbg_tag_to_str(&buf->in_tag,
+							str, sizeof(str)));
+			}
+		}
+
+		/* copy bytes from fifo word to user's buffer */
+		copy_bc = min_t(int, word_bc, buf_need_bc);
+		memcpy(msg->buf + buf->byte_idx, word + word_idx, copy_bc);
+
+		buf->byte_idx += copy_bc;
+		buf_need_bc   -= copy_bc;
+	}
+}
+
+/*
+ * i2c_msm_fifo_write_xfer_buf: write xfer.cur_buf (user's-buf + tag) to fifo
+ */
+static void i2c_msm_fifo_write_xfer_buf(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *buf  = &ctrl->xfer.cur_buf;
+	size_t len;
+	size_t tag_len;
+
+	tag_len = buf->out_tag.len;
+	len = i2c_msm_fifo_xfer_wr_tag(ctrl);
+	if (len < tag_len) {
+		dev_err(ctrl->dev, "error on writing tag to out FIFO\n");
+		return;
+	}
+
+	if (!buf->is_rx) {
+		if (ctrl->dbgfs.dbg_lvl >= MSM_DBG) {
+			char str[I2C_MSM_REG_2_STR_BUF_SZ];
+			int  offset = 0;
+			u8  *p      = i2c_msm_buf_to_ptr(buf);
+			int  i;
+
+			for (i = 0 ; i < len; ++i, ++p)
+				offset += snprintf(str + offset,
+						   sizeof(str) - offset,
+						   "0x%x ", *p);
+			dev_info(ctrl->dev, "data: %s\n", str);
+		}
+
+		len = i2c_msm_fifo_wr_buf(ctrl, i2c_msm_buf_to_ptr(buf),
+						buf->len);
+		if (len < buf->len)
+			dev_err(ctrl->dev, "error on xfering buf with FIFO\n");
+	}
+}
+
+/*
+ * i2c_msm_fifo_xfer_process:
+ *
+ * @pre    transfer size is less then or equal to fifo size.
+ * @pre    QUP in run state/pause
+ * @return zero on success
+ */
+static int i2c_msm_fifo_xfer_process(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf first_buf = ctrl->xfer.cur_buf;
+	int ret;
+
+	/* load fifo while in pause state to avoid race conditions */
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_PAUSE);
+	if (ret < 0)
+		return ret;
+
+	/* write all that goes to output fifo */
+	while (i2c_msm_xfer_next_buf(ctrl))
+		i2c_msm_fifo_write_xfer_buf(ctrl);
+
+	i2c_msm_fifo_wr_buf_flush(ctrl);
+
+	ctrl->xfer.cur_buf = first_buf;
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0)
+		return ret;
+
+	/* wait for input done interrupt */
+	ret = i2c_msm_xfer_wait_for_completion(ctrl, &ctrl->xfer.complete);
+	if (ret < 0)
+		return ret;
+
+	/* read all from input fifo */
+	while (i2c_msm_xfer_next_buf(ctrl))
+		i2c_msm_fifo_read_xfer_buf(ctrl);
+
+	return 0;
+}
+
+/*
+ * i2c_msm_fifo_xfer: process transfer using fifo mode
+ */
+static int i2c_msm_fifo_xfer(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "Starting FIFO transfer");
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RESET);
+	if (ret < 0)
+		return ret;
+
+	/* program qup registers */
+	i2c_msm_qup_xfer_init_reset_state(ctrl);
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0)
+		return ret;
+
+	/* program qup registers which must be set *after* reset */
+	i2c_msm_qup_xfer_init_run_state(ctrl);
+
+	ret = i2c_msm_fifo_xfer_process(ctrl);
+
+	return ret;
+}
+
+/*
+ * i2c_msm_blk_init_struct: Allocate memory and initialize blk structure
+ *
+ * @return 0 on success or error code
+ */
+static int i2c_msm_blk_init_struct(struct i2c_msm_ctrl *ctrl)
+{
+	u32 reg_data = readl_relaxed(ctrl->rsrcs.base + QUP_IO_MODES);
+	int ret;
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+
+	blk->in_blk_sz  = i2c_msm_reg_io_modes_in_blk_sz(reg_data),
+	blk->out_blk_sz = i2c_msm_reg_io_modes_out_blk_sz(reg_data),
+
+	blk->tx_cache = kmalloc(blk->out_blk_sz, GFP_KERNEL);
+	if (!blk->tx_cache) {
+		ret = -ENOMEM;
+		goto out_buf_err;
+	}
+
+	blk->rx_cache = kmalloc(blk->in_blk_sz, GFP_KERNEL);
+	if (!blk->tx_cache) {
+		dev_err(ctrl->dev,
+		"error on allocating memory for block tx_cache. malloc(size:%zu)\n",
+		 blk->out_blk_sz);
+		ret = -ENOMEM;
+		goto in_buf_err;
+	}
+
+	blk->is_init = true;
+	return 0;
+
+in_buf_err:
+	kfree(blk->tx_cache);
+out_buf_err:
+
+	return ret;
+}
+
+/*
+ * i2c_msm_blk_wr_flush: flushes internal cached block to FIFO
+ *
+ * @return 0 on success or error code
+ */
+static int i2c_msm_blk_wr_flush(struct i2c_msm_ctrl *ctrl)
+{
+	int byte_num;
+	int ret = 0;
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+	u32 *buf_u32_ptr;
+
+	if (!blk->tx_cache_idx)
+		return 0;
+
+	/* if no blocks available wait for interrupt */
+	ret = i2c_msm_xfer_wait_for_completion(ctrl, &blk->wait_tx_blk);
+	if (ret)
+		return ret;
+
+	/*
+	 * pause the controller until we finish loading the block in order to
+	 * avoid race conditions
+	 */
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_PAUSE);
+	if (ret < 0)
+		return ret;
+	i2c_msm_dbg(ctrl, MSM_DBG, "OUT-BLK:%*phC", blk->tx_cache_idx,
+							blk->tx_cache);
+
+	for (byte_num = 0; byte_num < blk->tx_cache_idx;
+						byte_num += sizeof(u32)) {
+		buf_u32_ptr = (u32 *) (blk->tx_cache + byte_num);
+		writel_relaxed(*buf_u32_ptr,
+					ctrl->rsrcs.base + QUP_OUT_FIFO_BASE);
+		*buf_u32_ptr = 0;
+	}
+
+	/* now cache is empty */
+	blk->tx_cache_idx = 0;
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0)
+		return ret;
+
+	return ret;
+}
+
+/*
+ * i2c_msm_blk_wr_buf:
+ *
+ * @len buf size (in bytes)
+ * @return number of bytes from buf which have been processed (written to
+ *         FIFO or kept in out buffer and will be written later)
+ */
+static int
+i2c_msm_blk_wr_buf(struct i2c_msm_ctrl *ctrl, const u8 *buf, int len)
+{
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+	int byte_num;
+	int ret = 0;
+
+	for (byte_num = 0; byte_num < len; ++byte_num, ++buf) {
+		blk->tx_cache[blk->tx_cache_idx] = *buf;
+		++blk->tx_cache_idx;
+
+		/* flush cached buffer to HW FIFO when full */
+		if (blk->tx_cache_idx == blk->out_blk_sz) {
+			ret = i2c_msm_blk_wr_flush(ctrl);
+			if (ret)
+				return ret;
+		}
+	}
+	return byte_num;
+}
+
+/*
+ * i2c_msm_blk_xfer_wr_tag: buffered writing the tag of current buf
+ * @return zero on success
+ */
+static int i2c_msm_blk_xfer_wr_tag(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *buf = &ctrl->xfer.cur_buf;
+	int len = 0;
+
+	if (!buf->out_tag.len)
+		return 0;
+
+	len = i2c_msm_blk_wr_buf(ctrl, (u8 *) &buf->out_tag.val,
+							buf->out_tag.len);
+	if (len != buf->out_tag.len)
+		return -EFAULT;
+
+	buf->out_tag = (struct i2c_msm_tag) {0};
+	return 0;
+}
+
+/*
+ * i2c_msm_blk_wr_xfer_buf: writes ctrl->xfer.cur_buf to HW
+ *
+ * @return zero on success
+ */
+static int i2c_msm_blk_wr_xfer_buf(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *buf  = &ctrl->xfer.cur_buf;
+	int len;
+	int ret;
+
+	ret = i2c_msm_blk_xfer_wr_tag(ctrl);
+	if (ret)
+		return ret;
+
+	len = i2c_msm_blk_wr_buf(ctrl, i2c_msm_buf_to_ptr(buf), buf->len);
+	if (len < buf->len)
+		return -EFAULT;
+
+	buf->byte_idx += len;
+	return 0;
+}
+
+/*
+ * i2c_msm_blk_rd_blk: read a block from HW FIFO to internal cache
+ *
+ * @return number of bytes read or negative error value
+ * @need_bc number of bytes that we need
+ *
+ * uses internal counter to keep track of number of available blocks. When
+ * zero, waits for interrupt.
+ */
+static int i2c_msm_blk_rd_blk(struct i2c_msm_ctrl *ctrl, int need_bc)
+{
+	int byte_num;
+	int ret = 0;
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+	u32 *cache_ptr = (u32 *) blk->rx_cache;
+	int read_bc    = min_t(int, blk->in_blk_sz, need_bc);
+
+	/* wait for block avialble interrupt */
+	ret = i2c_msm_xfer_wait_for_completion(ctrl, &blk->wait_rx_blk);
+	if (ret)
+		return ret;
+
+	/* Read block from HW to cache */
+	for (byte_num = 0; byte_num < blk->in_blk_sz;
+					byte_num += sizeof(u32)) {
+		if (byte_num < read_bc) {
+			*cache_ptr = readl_relaxed(ctrl->rsrcs.base +
+							QUP_IN_FIFO_BASE);
+			++cache_ptr;
+		}
+	}
+	blk->rx_cache_idx = 0;
+	return read_bc;
+}
+
+/*
+ * i2c_msm_blk_rd_xfer_buf: fill in ctrl->xfer.cur_buf from HW
+ *
+ * @return zero on success
+ */
+static int i2c_msm_blk_rd_xfer_buf(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+	struct i2c_msm_xfer_buf *buf      = &ctrl->xfer.cur_buf;
+	struct i2c_msg *msg               = ctrl->xfer.msgs + buf->msg_idx;
+	int    copy_bc;         /* number of bytes to copy to user's buffer */
+	int    cache_avail_bc;
+	int    ret = 0;
+
+	/* write tag to out FIFO */
+	ret = i2c_msm_blk_xfer_wr_tag(ctrl);
+	if (ret)
+		return ret;
+	i2c_msm_blk_wr_flush(ctrl);
+
+	while (buf->len || buf->in_tag.len) {
+		cache_avail_bc = i2c_msm_blk_rd_blk(ctrl,
+						buf->len + buf->in_tag.len);
+
+		i2c_msm_dbg(ctrl, MSM_DBG, "IN-BLK:%*phC\n", cache_avail_bc,
+					blk->rx_cache + blk->rx_cache_idx);
+
+		if (cache_avail_bc < 0)
+			return cache_avail_bc;
+
+		/* discard tag from input FIFO */
+		if (buf->in_tag.len) {
+			int discard_bc = min_t(int, cache_avail_bc,
+							buf->in_tag.len);
+			blk->rx_cache_idx += discard_bc;
+			buf->in_tag.len   -= discard_bc;
+			cache_avail_bc    -= discard_bc;
+		}
+
+		/* copy bytes from cached block to user's buffer */
+		copy_bc = min_t(int, cache_avail_bc, buf->len);
+		memcpy(msg->buf + buf->byte_idx,
+			blk->rx_cache + blk->rx_cache_idx, copy_bc);
+
+		blk->rx_cache_idx += copy_bc;
+		buf->len          -= copy_bc;
+		buf->byte_idx     += copy_bc;
+	}
+	return ret;
+}
+
+/*
+ * i2c_msm_blk_xfer: process transfer using block mode
+ */
+static int i2c_msm_blk_xfer(struct i2c_msm_ctrl *ctrl)
+{
+	int ret = 0;
+	struct i2c_msm_xfer_buf      *buf = &ctrl->xfer.cur_buf;
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+
+	if (!blk->is_init) {
+		ret = i2c_msm_blk_init_struct(ctrl);
+		if (!blk->is_init)
+			return ret;
+	}
+
+	init_completion(&blk->wait_rx_blk);
+	init_completion(&blk->wait_tx_blk);
+
+	/* tx_cnt > 0 always */
+	blk->complete_mask = QUP_MAX_OUTPUT_DONE_FLAG;
+	if (ctrl->xfer.rx_cnt)
+		blk->complete_mask |= QUP_MAX_INPUT_DONE_FLAG;
+
+	/* initialize block mode for new transfer */
+	blk->tx_cache_idx = 0;
+	blk->rx_cache_idx = 0;
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RESET);
+	if (ret < 0)
+		return ret;
+
+	/* program qup registers */
+	i2c_msm_qup_xfer_init_reset_state(ctrl);
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0)
+		return ret;
+
+	/* program qup registers which must be set *after* reset */
+	i2c_msm_qup_xfer_init_run_state(ctrl);
+
+	while (i2c_msm_xfer_next_buf(ctrl)) {
+		if (buf->is_rx) {
+			ret = i2c_msm_blk_rd_xfer_buf(ctrl);
+			if (ret)
+				return ret;
+			/*
+			 * SW workaround to wait for extra interrupt from
+			 * hardware for last block in block mode for read
+			 */
+			if (buf->is_last) {
+				ret = i2c_msm_xfer_wait_for_completion(ctrl,
+							&blk->wait_rx_blk);
+				if (!ret)
+					complete(&ctrl->xfer.complete);
+			}
+		} else {
+			ret = i2c_msm_blk_wr_xfer_buf(ctrl);
+			if (ret)
+				return ret;
+		}
+	}
+	i2c_msm_blk_wr_flush(ctrl);
+	return i2c_msm_xfer_wait_for_completion(ctrl, &ctrl->xfer.complete);
+}
+
+/*
+ * i2c_msm_dma_xfer_prepare: map DMA buffers, and create tags.
+ * @return zero on success or negative error value
+ */
+static int i2c_msm_dma_xfer_prepare(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_dma *dma  = &ctrl->xfer.dma;
+	struct i2c_msm_xfer_buf      *buf  = &ctrl->xfer.cur_buf;
+	struct i2c_msm_dma_chan      *tx = &dma->chan[I2C_MSM_DMA_TX];
+	struct i2c_msm_dma_chan      *rx = &dma->chan[I2C_MSM_DMA_RX];
+	struct i2c_msm_dma_buf *dma_buf;
+	int                     rem_buf_cnt = I2C_MSM_DMA_DESC_ARR_SIZ;
+	struct i2c_msg         *cur_msg;
+	enum dma_data_direction buf_dma_dirctn;
+	struct i2c_msm_dma_mem  data;
+	u8        *tag_arr_itr_vrtl_addr;
+	dma_addr_t tag_arr_itr_phy_addr;
+
+	tx->desc_cnt_cur    = 0;
+	rx->desc_cnt_cur    = 0;
+	dma->buf_arr_cnt      = 0;
+	dma_buf               = dma->buf_arr;
+	tag_arr_itr_vrtl_addr = ((u8 *) dma->tag_arr.vrtl_addr);
+	tag_arr_itr_phy_addr  = dma->tag_arr.phy_addr;
+
+	for (; i2c_msm_xfer_next_buf(ctrl) && rem_buf_cnt;
+		++dma_buf,
+		tag_arr_itr_phy_addr  += sizeof(dma_addr_t),
+		tag_arr_itr_vrtl_addr += sizeof(dma_addr_t)) {
+
+		/* dma-map the client's message */
+		cur_msg        = ctrl->xfer.msgs + buf->msg_idx;
+		data.vrtl_addr = cur_msg->buf + buf->byte_idx;
+		if (buf->is_rx) {
+			buf_dma_dirctn  = DMA_FROM_DEVICE;
+			rx->desc_cnt_cur += 2; /* msg + tag */
+			tx->desc_cnt_cur += 1; /* tag */
+		} else {
+			buf_dma_dirctn  = DMA_TO_DEVICE;
+			tx->desc_cnt_cur += 2; /* msg + tag */
+		}
+
+		/* for last buffer in a transfer msg */
+		if (buf->is_last) {
+			/* add ovrhead byte cnt for tags specific to DMA mode */
+			ctrl->xfer.rx_ovrhd_cnt += 2; /* EOT+FLUSH_STOP tags*/
+			ctrl->xfer.tx_ovrhd_cnt += 2; /* EOT+FLUSH_STOP tags */
+
+			/* increment rx desc cnt to read off tags and
+			 * increment tx desc cnt to queue EOT+FLUSH_STOP tags
+			 */
+			tx->desc_cnt_cur++;
+			rx->desc_cnt_cur++;
+		}
+
+		if ((rx->desc_cnt_cur >= I2C_MSM_DMA_RX_SZ) ||
+		    (tx->desc_cnt_cur >= I2C_MSM_DMA_TX_SZ))
+			return -ENOMEM;
+
+		data.phy_addr = dma_map_single(ctrl->dev, data.vrtl_addr,
+						buf->len, buf_dma_dirctn);
+
+		if (dma_mapping_error(ctrl->dev, data.phy_addr)) {
+			dev_err(ctrl->dev,
+			  "error DMA mapping DMA buffers, err:%lld buf_vrtl:0x%p data_len:%d dma_dir:%s\n",
+			  (u64) data.phy_addr, data.vrtl_addr, buf->len,
+			  ((buf_dma_dirctn == DMA_FROM_DEVICE)
+				? "DMA_FROM_DEVICE" : "DMA_TO_DEVICE"));
+			return -EFAULT;
+		}
+
+		/* copy 8 bytes. Only tag.len bytes will be used */
+		*((u64 *)tag_arr_itr_vrtl_addr) =  buf->out_tag.val;
+
+		i2c_msm_dbg(ctrl, MSM_DBG,
+			"vrtl:0x%p phy:0x%llx val:0x%llx sizeof(dma_addr_t):%zu",
+			tag_arr_itr_vrtl_addr, (u64) tag_arr_itr_phy_addr,
+			*((u64 *)tag_arr_itr_vrtl_addr), sizeof(dma_addr_t));
+
+		/*
+		 * create dma buf, in the dma buf arr, based on the buf created
+		 * by i2c_msm_xfer_next_buf()
+		 */
+		*dma_buf = (struct i2c_msm_dma_buf) {
+			.ptr      = data,
+			.len      = buf->len,
+			.dma_dir  = buf_dma_dirctn,
+			.is_rx    = buf->is_rx,
+			.is_last  = buf->is_last,
+			.tag      = (struct i2c_msm_dma_tag) {
+				.buf = tag_arr_itr_phy_addr,
+				.len = buf->out_tag.len,
+			},
+		};
+		++dma->buf_arr_cnt;
+		--rem_buf_cnt;
+	}
+	return 0;
+}
+
+/*
+ * i2c_msm_dma_xfer_unprepare: DAM unmap buffers.
+ */
+static void i2c_msm_dma_xfer_unprepare(struct i2c_msm_ctrl *ctrl)
+{
+	int i;
+	struct i2c_msm_dma_buf *buf_itr = ctrl->xfer.dma.buf_arr;
+
+	for (i = 0 ; i < ctrl->xfer.dma.buf_arr_cnt ; ++i, ++buf_itr)
+		dma_unmap_single(ctrl->dev, buf_itr->ptr.phy_addr, buf_itr->len,
+							buf_itr->dma_dir);
+}
+
+static void i2c_msm_dma_callback_tx_complete(void *dma_async_param)
+{
+	struct i2c_msm_ctrl *ctrl = dma_async_param;
+
+	complete(&ctrl->xfer.complete);
+}
+
+static void i2c_msm_dma_callback_rx_complete(void *dma_async_param)
+{
+	struct i2c_msm_ctrl *ctrl = dma_async_param;
+
+	complete(&ctrl->xfer.rx_complete);
+}
+
+/*
+ * i2c_msm_dma_xfer_process: Queue transfers to DMA
+ * @pre 1)QUP is in run state. 2) i2c_msm_dma_xfer_prepare() was called.
+ * @return zero on success or negative error value
+ */
+static int i2c_msm_dma_xfer_process(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_dma *dma = &ctrl->xfer.dma;
+	struct i2c_msm_dma_chan *tx       = &dma->chan[I2C_MSM_DMA_TX];
+	struct i2c_msm_dma_chan *rx       = &dma->chan[I2C_MSM_DMA_RX];
+	struct scatterlist *sg_rx         = NULL;
+	struct scatterlist *sg_rx_itr     = NULL;
+	struct scatterlist *sg_tx         = NULL;
+	struct scatterlist *sg_tx_itr     = NULL;
+	struct dma_async_tx_descriptor     *dma_desc_rx;
+	struct dma_async_tx_descriptor     *dma_desc_tx;
+	struct i2c_msm_dma_buf             *buf_itr;
+	int  i;
+	int  ret = 0;
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "Going to enqueue %zu buffers in DMA",
+							dma->buf_arr_cnt);
+
+	/* Set the QUP State to pause while DMA completes the txn */
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_PAUSE);
+	if (ret) {
+		dev_err(ctrl->dev, "transition to pause state failed before DMA transaction :%d\n",
+									ret);
+		return ret;
+	}
+
+	sg_tx = kcalloc(tx->desc_cnt_cur, sizeof(struct scatterlist),
+								GFP_KERNEL);
+	if (!sg_tx) {
+		ret = -ENOMEM;
+		goto dma_xfer_end;
+	}
+	sg_init_table(sg_tx, tx->desc_cnt_cur);
+	sg_tx_itr = sg_tx;
+
+	sg_rx = kcalloc(rx->desc_cnt_cur, sizeof(struct scatterlist),
+								GFP_KERNEL);
+	if (!sg_rx) {
+		ret = -ENOMEM;
+		goto dma_xfer_end;
+	}
+	sg_init_table(sg_rx, rx->desc_cnt_cur);
+	sg_rx_itr = sg_rx;
+
+	buf_itr = dma->buf_arr;
+
+	for (i = 0; i < dma->buf_arr_cnt ; ++i, ++buf_itr) {
+		/* Queue tag */
+		sg_dma_address(sg_tx_itr) = buf_itr->tag.buf;
+		sg_dma_len(sg_tx_itr) = buf_itr->tag.len;
+		++sg_tx_itr;
+
+		/* read off tag + len bytes(don't care) in input FIFO
+		 * on read transfer
+		 */
+		if (buf_itr->is_rx) {
+			/* rid of input tag */
+			sg_dma_address(sg_rx_itr) =
+					ctrl->xfer.dma.input_tag.phy_addr;
+			sg_dma_len(sg_rx_itr)     = QUP_BUF_OVERHD_BC;
+			++sg_rx_itr;
+
+			/* queue data buffer */
+			sg_dma_address(sg_rx_itr) = buf_itr->ptr.phy_addr;
+			sg_dma_len(sg_rx_itr)     = buf_itr->len;
+			++sg_rx_itr;
+		} else {
+			sg_dma_address(sg_tx_itr) = buf_itr->ptr.phy_addr;
+			sg_dma_len(sg_tx_itr)     = buf_itr->len;
+			++sg_tx_itr;
+		}
+	}
+
+	/* this tag will be copied to rx fifo */
+	sg_dma_address(sg_tx_itr) = dma->eot_n_flush_stop_tags.phy_addr;
+	sg_dma_len(sg_tx_itr)     = QUP_BUF_OVERHD_BC;
+	++sg_tx_itr;
+
+	/*
+	 * Reading the tag off the input fifo has side effects and
+	 * it is mandatory for getting the DMA's interrupt.
+	 */
+	sg_dma_address(sg_rx_itr) = ctrl->xfer.dma.input_tag.phy_addr;
+	sg_dma_len(sg_rx_itr)     = QUP_BUF_OVERHD_BC;
+	++sg_rx_itr;
+
+	/*
+	 * We only want a single BAM interrupt per transfer, and we always
+	 * add a flush-stop i2c tag as the last tx sg entry. Since the dma
+	 * driver puts the supplied BAM flags only on the last BAM descriptor,
+	 * the flush stop will always be the one which generate that interrupt
+	 * and invokes the callback.
+	 */
+	dma_desc_tx = dmaengine_prep_slave_sg(tx->dma_chan,
+						sg_tx,
+						sg_tx_itr - sg_tx,
+						tx->dir,
+						(SPS_IOVEC_FLAG_EOT |
+							SPS_IOVEC_FLAG_NWD));
+	if (dma_desc_tx < 0) {
+		dev_err(ctrl->dev, "error dmaengine_prep_slave_sg tx:%ld\n",
+							PTR_ERR(dma_desc_tx));
+		ret = PTR_ERR(dma_desc_tx);
+		goto dma_xfer_end;
+	}
+
+	/* callback defined for tx dma desc */
+	dma_desc_tx->callback       = i2c_msm_dma_callback_tx_complete;
+	dma_desc_tx->callback_param = ctrl;
+	dmaengine_submit(dma_desc_tx);
+	dma_async_issue_pending(tx->dma_chan);
+
+	/* queue the rx dma desc */
+	dma_desc_rx = dmaengine_prep_slave_sg(rx->dma_chan, sg_rx,
+					sg_rx_itr - sg_rx, rx->dir,
+					(SPS_IOVEC_FLAG_EOT |
+							SPS_IOVEC_FLAG_NWD));
+	if (dma_desc_rx < 0) {
+		dev_err(ctrl->dev,
+			"error dmaengine_prep_slave_sg rx:%ld\n",
+						PTR_ERR(dma_desc_rx));
+		ret = PTR_ERR(dma_desc_rx);
+		goto dma_xfer_end;
+	}
+
+	dma_desc_rx->callback       = i2c_msm_dma_callback_rx_complete;
+	dma_desc_rx->callback_param = ctrl;
+	dmaengine_submit(dma_desc_rx);
+	dma_async_issue_pending(rx->dma_chan);
+
+	/* Set the QUP State to Run when completes the txn */
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret) {
+		dev_err(ctrl->dev, "transition to run state failed before DMA transaction :%d\n",
+									ret);
+		goto dma_xfer_end;
+	}
+
+	ret = i2c_msm_xfer_wait_for_completion(ctrl, &ctrl->xfer.complete);
+	if (!ret && ctrl->xfer.rx_cnt)
+		ret = i2c_msm_xfer_wait_for_completion(ctrl,
+						&ctrl->xfer.rx_complete);
+
+dma_xfer_end:
+	/* free scatter-gather lists */
+	kfree(sg_tx);
+	kfree(sg_rx);
+
+	return ret;
+}
+
+static void i2c_msm_dma_free_channels(struct i2c_msm_ctrl *ctrl)
+{
+	int i;
+
+	for (i = 0; i < I2C_MSM_DMA_CNT; ++i) {
+		struct i2c_msm_dma_chan *chan = &ctrl->xfer.dma.chan[i];
+
+		if (!chan->is_init)
+			continue;
+
+		dma_release_channel(chan->dma_chan);
+		chan->is_init  = false;
+		chan->dma_chan = NULL;
+	}
+	if (ctrl->xfer.dma.state > I2C_MSM_DMA_INIT_CORE)
+		ctrl->xfer.dma.state = I2C_MSM_DMA_INIT_CORE;
+}
+
+static const char * const i2c_msm_dma_chan_name[] = {"tx", "rx"};
+
+static int i2c_msm_dmaengine_dir[] = {
+	DMA_MEM_TO_DEV, DMA_DEV_TO_MEM
+};
+
+static int i2c_msm_dma_init_channels(struct i2c_msm_ctrl *ctrl)
+{
+	int ret = 0;
+	int i;
+
+	/* Iterate over the dma channels to initialize them */
+	for (i = 0; i < I2C_MSM_DMA_CNT; ++i) {
+		struct dma_slave_config cfg = {0};
+		struct i2c_msm_dma_chan *chan = &ctrl->xfer.dma.chan[i];
+
+		if (chan->is_init)
+			continue;
+
+		chan->name     = i2c_msm_dma_chan_name[i];
+		chan->dma_chan = dma_request_slave_channel(ctrl->dev,
+								chan->name);
+		if (!chan->dma_chan) {
+			dev_err(ctrl->dev,
+				"error dma_request_slave_channel(dev:%s chan:%s)\n",
+				dev_name(ctrl->dev), chan->name);
+			/* free the channels if allocated before */
+			i2c_msm_dma_free_channels(ctrl);
+			return -ENODEV;
+		}
+
+		chan->dir = cfg.direction = i2c_msm_dmaengine_dir[i];
+		ret = dmaengine_slave_config(chan->dma_chan, &cfg);
+		if (ret) {
+			dev_err(ctrl->dev,
+			"error:%d dmaengine_slave_config(chan:%s)\n",
+						ret, chan->name);
+			dma_release_channel(chan->dma_chan);
+			chan->dma_chan = NULL;
+			i2c_msm_dma_free_channels(ctrl);
+			return ret;
+		}
+		chan->is_init = true;
+	}
+	ctrl->xfer.dma.state = I2C_MSM_DMA_INIT_CHAN;
+	return 0;
+}
+
+static void i2c_msm_dma_teardown(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_dma *dma = &ctrl->xfer.dma;
+
+	i2c_msm_dma_free_channels(ctrl);
+
+	if (dma->state > I2C_MSM_DMA_INIT_NONE)
+		dma_free_coherent(ctrl->dev, I2C_MSM_DMA_TAG_MEM_SZ,
+				  dma->input_tag.vrtl_addr,
+				  dma->input_tag.phy_addr);
+
+	dma->state = I2C_MSM_DMA_INIT_NONE;
+}
+
+static int i2c_msm_dma_init(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_dma *dma = &ctrl->xfer.dma;
+	u8             *tags_space_virt_addr;
+	dma_addr_t      tags_space_phy_addr;
+
+	/* check if DMA core is initialized */
+	if (dma->state > I2C_MSM_DMA_INIT_NONE)
+		goto dma_core_is_init;
+
+	/*
+	 * allocate dma memory for input_tag + eot_n_flush_stop_tags + tag_arr
+	 * for more see: I2C_MSM_DMA_TAG_MEM_SZ definition
+	 */
+	tags_space_virt_addr = dma_alloc_coherent(
+						ctrl->dev,
+						I2C_MSM_DMA_TAG_MEM_SZ,
+						&tags_space_phy_addr,
+						GFP_KERNEL);
+	if (!tags_space_virt_addr) {
+		dev_err(ctrl->dev,
+		  "error alloc %d bytes of DMAable memory for DMA tags space\n",
+		  I2C_MSM_DMA_TAG_MEM_SZ);
+		return -ENOMEM;
+	}
+
+	/*
+	 * set the dma-tags virtual and physical addresses:
+	 * 1) the first tag space is for the input (throw away) tag
+	 */
+	dma->input_tag.vrtl_addr  = tags_space_virt_addr;
+	dma->input_tag.phy_addr   = tags_space_phy_addr;
+
+	/* 2) second tag space is for eot_flush_stop tag which is const value */
+	tags_space_virt_addr += I2C_MSM_TAG2_MAX_LEN;
+	tags_space_phy_addr  += I2C_MSM_TAG2_MAX_LEN;
+	dma->eot_n_flush_stop_tags.vrtl_addr = tags_space_virt_addr;
+	dma->eot_n_flush_stop_tags.phy_addr  = tags_space_phy_addr;
+
+	/* set eot_n_flush_stop_tags value */
+	*((u16 *) dma->eot_n_flush_stop_tags.vrtl_addr) =
+				QUP_TAG2_INPUT_EOT | (QUP_TAG2_FLUSH_STOP << 8);
+
+	/* 3) all other tag spaces are used for transfer tags */
+	tags_space_virt_addr  += I2C_MSM_TAG2_MAX_LEN;
+	tags_space_phy_addr   += I2C_MSM_TAG2_MAX_LEN;
+	dma->tag_arr.vrtl_addr = tags_space_virt_addr;
+	dma->tag_arr.phy_addr  = tags_space_phy_addr;
+
+	dma->state = I2C_MSM_DMA_INIT_CORE;
+
+dma_core_is_init:
+	return i2c_msm_dma_init_channels(ctrl);
+}
+
+static int i2c_msm_dma_xfer(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	ret = i2c_msm_dma_init(ctrl);
+	if (ret) {
+		dev_err(ctrl->dev, "DMA Init Failed: %d\n", ret);
+		return ret;
+	}
+
+	/* dma map user's buffers and create tags */
+	ret = i2c_msm_dma_xfer_prepare(ctrl);
+	if (ret < 0) {
+		dev_err(ctrl->dev, "error on i2c_msm_dma_xfer_prepare():%d\n",
+									ret);
+		goto err_dma_xfer;
+	}
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RESET);
+	if (ret < 0)
+		goto err_dma_xfer;
+
+	/* program qup registers */
+	i2c_msm_qup_xfer_init_reset_state(ctrl);
+
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0)
+		goto err_dma_xfer;
+
+	/* program qup registers which must be set *after* reset */
+	i2c_msm_qup_xfer_init_run_state(ctrl);
+
+	/* enqueue transfer buffers */
+	ret = i2c_msm_dma_xfer_process(ctrl);
+	if (ret)
+		dev_err(ctrl->dev,
+			"error i2c_msm_dma_xfer_process(n_bufs:%zu):%d\n",
+			ctrl->xfer.dma.buf_arr_cnt, ret);
+
+err_dma_xfer:
+	i2c_msm_dma_xfer_unprepare(ctrl);
+	return ret;
+}
+
+/*
+ * i2c_msm_qup_slv_holds_bus: true when slave hold the SDA low
+ */
+static bool i2c_msm_qup_slv_holds_bus(struct i2c_msm_ctrl *ctrl)
+{
+	u32 status = readl_relaxed(ctrl->rsrcs.base + QUP_I2C_STATUS);
+
+	bool slv_holds_bus =	!(status & QUP_I2C_SDA) &&
+				(status & QUP_BUS_ACTIVE) &&
+				!(status & QUP_BUS_MASTER);
+	if (slv_holds_bus)
+		dev_info(ctrl->dev,
+			"bus lines held low by a slave detected\n");
+
+	return slv_holds_bus;
+}
+
+/*
+ * i2c_msm_qup_poll_bus_active_unset: poll until QUP_BUS_ACTIVE is unset
+ *
+ * @return zero when bus inactive, or nonzero on timeout.
+ *
+ * Loop and reads QUP_I2C_MASTER_STATUS until bus is inactive or timeout
+ * reached. Used to avoid race condition due to gap between QUP completion
+ * interrupt and QUP issuing stop signal on the bus.
+ */
+static int i2c_msm_qup_poll_bus_active_unset(struct i2c_msm_ctrl *ctrl)
+{
+	void __iomem *base    = ctrl->rsrcs.base;
+	ulong timeout = jiffies + msecs_to_jiffies(I2C_MSM_MAX_POLL_MSEC);
+	int    ret      = 0;
+	size_t read_cnt = 0;
+
+	do {
+		if (!(readl_relaxed(base + QUP_I2C_STATUS) & QUP_BUS_ACTIVE))
+			goto poll_active_end;
+		++read_cnt;
+	} while (time_before_eq(jiffies, timeout));
+
+	ret = -EBUSY;
+
+poll_active_end:
+	/* second logged value is time-left before timeout or zero if expired */
+	i2c_msm_prof_evnt_add(ctrl, MSM_DBG, I2C_MSM_ACTV_END,
+				ret, (ret ? 0 : (timeout - jiffies)), read_cnt);
+
+	return ret;
+}
+
+static void i2c_msm_clk_path_vote(struct i2c_msm_ctrl *ctrl)
+{
+	i2c_msm_clk_path_init(ctrl);
+
+	if (ctrl->rsrcs.clk_path_vote.client_hdl)
+		msm_bus_scale_client_update_request(
+					ctrl->rsrcs.clk_path_vote.client_hdl,
+					I2C_MSM_CLK_PATH_RESUME_VEC);
+}
+
+static void i2c_msm_clk_path_unvote(struct i2c_msm_ctrl *ctrl)
+{
+	if (ctrl->rsrcs.clk_path_vote.client_hdl)
+		msm_bus_scale_client_update_request(
+					ctrl->rsrcs.clk_path_vote.client_hdl,
+					I2C_MSM_CLK_PATH_SUSPEND_VEC);
+}
+
+static void i2c_msm_clk_path_teardown(struct i2c_msm_ctrl *ctrl)
+{
+	if (ctrl->rsrcs.clk_path_vote.client_hdl) {
+		msm_bus_scale_unregister_client(
+					ctrl->rsrcs.clk_path_vote.client_hdl);
+		ctrl->rsrcs.clk_path_vote.client_hdl = 0;
+	}
+}
+
+/*
+ * i2c_msm_clk_path_init_structs: internal impl detail of i2c_msm_clk_path_init
+ *
+ * allocates and initilizes the bus scaling vectors.
+ */
+static int i2c_msm_clk_path_init_structs(struct i2c_msm_ctrl *ctrl)
+{
+	struct msm_bus_vectors *paths    = NULL;
+	struct msm_bus_paths   *usecases = NULL;
+
+	i2c_msm_dbg(ctrl, MSM_PROF, "initializes path clock voting structs");
+
+	paths = devm_kzalloc(ctrl->dev, sizeof(*paths) * 2, GFP_KERNEL);
+	if (!paths)
+		return -ENOMEM;
+
+	usecases = devm_kzalloc(ctrl->dev, sizeof(*usecases) * 2, GFP_KERNEL);
+	if (!usecases)
+		goto path_init_err;
+
+	ctrl->rsrcs.clk_path_vote.pdata = devm_kzalloc(ctrl->dev,
+				       sizeof(*ctrl->rsrcs.clk_path_vote.pdata),
+				       GFP_KERNEL);
+	if (!ctrl->rsrcs.clk_path_vote.pdata) {
+		dev_err(ctrl->dev,
+			"error  msm_bus_scale_pdata memory allocation failed\n");
+		goto path_init_err;
+	}
+
+	paths[I2C_MSM_CLK_PATH_SUSPEND_VEC] = (struct msm_bus_vectors) {
+		.src = ctrl->rsrcs.clk_path_vote.mstr_id,
+		.dst = MSM_BUS_SLAVE_EBI_CH0,
+		.ab  = 0,
+		.ib  = 0,
+	};
+
+	paths[I2C_MSM_CLK_PATH_RESUME_VEC]  = (struct msm_bus_vectors) {
+		.src = ctrl->rsrcs.clk_path_vote.mstr_id,
+		.dst = MSM_BUS_SLAVE_EBI_CH0,
+		.ab  = I2C_MSM_CLK_PATH_AVRG_BW(ctrl),
+		.ib  = I2C_MSM_CLK_PATH_BRST_BW(ctrl),
+	};
+
+	usecases[I2C_MSM_CLK_PATH_SUSPEND_VEC] = (struct msm_bus_paths) {
+		.num_paths = 1,
+		.vectors   = &paths[I2C_MSM_CLK_PATH_SUSPEND_VEC],
+	};
+
+	usecases[I2C_MSM_CLK_PATH_RESUME_VEC] = (struct msm_bus_paths) {
+		.num_paths = 1,
+		.vectors   = &paths[I2C_MSM_CLK_PATH_RESUME_VEC],
+	};
+
+	*ctrl->rsrcs.clk_path_vote.pdata = (struct msm_bus_scale_pdata) {
+		.usecase      = usecases,
+		.num_usecases = 2,
+		.name         = dev_name(ctrl->dev),
+	};
+
+	return 0;
+
+path_init_err:
+	devm_kfree(ctrl->dev, paths);
+	devm_kfree(ctrl->dev, usecases);
+	devm_kfree(ctrl->dev, ctrl->rsrcs.clk_path_vote.pdata);
+	ctrl->rsrcs.clk_path_vote.pdata = NULL;
+	return -ENOMEM;
+}
+
+/*
+ * i2c_msm_clk_path_postponed_register: reg with bus-scaling after it is probed
+ *
+ * @return zero on success
+ *
+ * Workaround: i2c driver may be probed before the bus scaling driver. Calling
+ * msm_bus_scale_register_client() will fail if the bus scaling driver is not
+ * ready yet. Thus, this function should be called not from probe but from a
+ * later context. Also, this function may be called more then once before
+ * register succeed. At this case only one error message will be logged. At boot
+ * time all clocks are on, so earlier i2c transactions should succeed.
+ */
+static int i2c_msm_clk_path_postponed_register(struct i2c_msm_ctrl *ctrl)
+{
+	ctrl->rsrcs.clk_path_vote.client_hdl =
+		msm_bus_scale_register_client(ctrl->rsrcs.clk_path_vote.pdata);
+
+	if (ctrl->rsrcs.clk_path_vote.client_hdl) {
+		if (ctrl->rsrcs.clk_path_vote.reg_err) {
+			/* log a success message if an error msg was logged */
+			ctrl->rsrcs.clk_path_vote.reg_err = false;
+			dev_err(ctrl->dev,
+				"msm_bus_scale_register_client(mstr-id:%d):0x%x (ok)",
+				ctrl->rsrcs.clk_path_vote.mstr_id,
+				ctrl->rsrcs.clk_path_vote.client_hdl);
+		}
+	} else {
+		/* guard to log only one error on multiple failure */
+		if (!ctrl->rsrcs.clk_path_vote.reg_err) {
+			ctrl->rsrcs.clk_path_vote.reg_err = true;
+
+			dev_info(ctrl->dev,
+				"msm_bus_scale_register_client(mstr-id:%d):0 (not a problem)",
+				ctrl->rsrcs.clk_path_vote.mstr_id);
+		}
+	}
+
+	return ctrl->rsrcs.clk_path_vote.client_hdl ? 0 : -EAGAIN;
+}
+
+static void i2c_msm_clk_path_init(struct i2c_msm_ctrl *ctrl)
+{
+	/*
+	 * bail out if path voting is diabled (master_id == 0) or if it is
+	 * already registered (client_hdl != 0)
+	 */
+	if (!ctrl->rsrcs.clk_path_vote.mstr_id ||
+		ctrl->rsrcs.clk_path_vote.client_hdl)
+		return;
+
+	/* if fail once then try no more */
+	if (!ctrl->rsrcs.clk_path_vote.pdata &&
+					i2c_msm_clk_path_init_structs(ctrl)) {
+		ctrl->rsrcs.clk_path_vote.mstr_id = 0;
+		return;
+	};
+
+	/* on failure try again later */
+	if (i2c_msm_clk_path_postponed_register(ctrl))
+		return;
+}
+
+/*
+ * i2c_msm_qup_isr: QUP interrupt service routine
+ */
+static irqreturn_t i2c_msm_qup_isr(int irq, void *devid)
+{
+	struct i2c_msm_ctrl *ctrl = devid;
+	void __iomem        *base = ctrl->rsrcs.base;
+	struct i2c_msm_xfer *xfer = &ctrl->xfer;
+	struct i2c_msm_xfer_mode_blk *blk = &ctrl->xfer.blk;
+	u32  err_flags  = 0;
+	u32  clr_flds   = 0;
+	bool log_event       = false;
+	bool signal_complete = false;
+	bool need_wmb        = false;
+
+	i2c_msm_prof_evnt_add(ctrl, MSM_PROF, I2C_MSM_IRQ_BGN, irq, 0, 0);
+
+	if (!atomic_read(&ctrl->xfer.is_active)) {
+		dev_info(ctrl->dev, "irq:%d when no active transfer\n", irq);
+		return IRQ_HANDLED;
+	}
+
+	ctrl->i2c_sts_reg  = readl_relaxed(base + QUP_I2C_STATUS);
+	err_flags	   = readl_relaxed(base + QUP_ERROR_FLAGS);
+	ctrl->qup_op_reg   = readl_relaxed(base + QUP_OPERATIONAL);
+
+	if (ctrl->i2c_sts_reg & QUP_MSTR_STTS_ERR_MASK) {
+		signal_complete = true;
+		log_event       = true;
+		/*
+		 * If there is more than 1 error here, last one sticks.
+		 * The order of the error set here matters.
+		 */
+		if (ctrl->i2c_sts_reg & QUP_ARB_LOST)
+			ctrl->xfer.err = I2C_MSM_ERR_ARB_LOST;
+
+		if (ctrl->i2c_sts_reg & QUP_BUS_ERROR)
+			ctrl->xfer.err = I2C_MSM_ERR_BUS_ERR;
+
+		if (ctrl->i2c_sts_reg & QUP_PACKET_NACKED)
+			ctrl->xfer.err = I2C_MSM_ERR_NACK;
+	}
+
+	/* check for FIFO over/under runs error */
+	if (err_flags & QUP_ERR_FLGS_MASK)
+		ctrl->xfer.err = I2C_MSM_ERR_OVR_UNDR_RUN;
+
+	/* Dump the register values before reset the core */
+	if (ctrl->xfer.err && ctrl->dbgfs.dbg_lvl >= MSM_DBG)
+		i2c_msm_dbg_qup_reg_dump(ctrl);
+
+	/* clear interrupts fields */
+	clr_flds = ctrl->i2c_sts_reg & QUP_MSTR_STTS_ERR_MASK;
+	if (clr_flds) {
+		writel_relaxed(clr_flds, base + QUP_I2C_STATUS);
+		need_wmb = true;
+	}
+
+	clr_flds = err_flags & QUP_ERR_FLGS_MASK;
+	if (clr_flds) {
+		writel_relaxed(clr_flds,  base + QUP_ERROR_FLAGS);
+		need_wmb = true;
+	}
+
+	clr_flds = ctrl->qup_op_reg &
+			(QUP_OUTPUT_SERVICE_FLAG |
+			QUP_INPUT_SERVICE_FLAG);
+	if (clr_flds) {
+		writel_relaxed(clr_flds, base + QUP_OPERATIONAL);
+		need_wmb = true;
+	}
+
+	if (need_wmb)
+		/*
+		 * flush writes that clear the interrupt flags before changing
+		 * state to reset.
+		 */
+		wmb();
+
+	/* Reset and bail out on error */
+	if (ctrl->xfer.err) {
+		/* Flush for the tags in case of an error and DMA Mode*/
+		if (ctrl->xfer.mode_id == I2C_MSM_XFER_MODE_DMA) {
+			writel_relaxed(QUP_I2C_FLUSH, ctrl->rsrcs.base
+								+ QUP_STATE);
+			/*
+			 * Ensure that QUP_I2C_FLUSH is written before
+			 * State reset
+			 */
+			wmb();
+		}
+
+		/* HW workaround: when interrupt is level triggerd, more
+		 * than one interrupt may fire in error cases. Thus we
+		 * change the QUP core state to Reset immediately in the
+		 * ISR to ward off the next interrupt.
+		 */
+		writel_relaxed(QUP_STATE_RESET, ctrl->rsrcs.base + QUP_STATE);
+
+		signal_complete = true;
+		log_event       = true;
+		goto isr_end;
+	}
+
+	/* handle data completion */
+	if (xfer->mode_id == I2C_MSM_XFER_MODE_BLOCK) {
+		/* block ready for writing */
+		if (ctrl->qup_op_reg & QUP_OUTPUT_SERVICE_FLAG) {
+			log_event = true;
+			if (ctrl->qup_op_reg & QUP_OUT_BLOCK_WRITE_REQ)
+				complete(&blk->wait_tx_blk);
+
+			if ((ctrl->qup_op_reg & blk->complete_mask)
+					== blk->complete_mask) {
+				log_event       = true;
+				signal_complete = true;
+			}
+		}
+		/* block ready for reading */
+		if (ctrl->qup_op_reg & QUP_INPUT_SERVICE_FLAG) {
+			log_event = true;
+			complete(&blk->wait_rx_blk);
+		}
+	} else {
+		/* for FIFO/DMA Mode*/
+		if (ctrl->qup_op_reg & QUP_MAX_INPUT_DONE_FLAG) {
+			log_event = true;
+			/*
+			 * If last transaction is an input then the entire
+			 * transfer is done
+			 */
+			if (ctrl->xfer.last_is_rx)
+				signal_complete = true;
+		}
+		/*
+		 * Ideally, would like to check QUP_MAX_OUTPUT_DONE_FLAG.
+		 * However, QUP_MAX_OUTPUT_DONE_FLAG is lagging behind
+		 * QUP_OUTPUT_SERVICE_FLAG. The only reason for
+		 * QUP_OUTPUT_SERVICE_FLAG to be set in FIFO mode is
+		 * QUP_MAX_OUTPUT_DONE_FLAG condition. The code checking
+		 * here QUP_OUTPUT_SERVICE_FLAG and assumes that
+		 * QUP_MAX_OUTPUT_DONE_FLAG.
+		 */
+		if (ctrl->qup_op_reg & (QUP_OUTPUT_SERVICE_FLAG |
+						QUP_MAX_OUTPUT_DONE_FLAG)) {
+			log_event = true;
+			/*
+			 * If last transaction is an output then the
+			 * entire transfer is done
+			 */
+			if (!ctrl->xfer.last_is_rx)
+				signal_complete = true;
+		}
+	}
+
+isr_end:
+	if (log_event || (ctrl->dbgfs.dbg_lvl >= MSM_DBG))
+		i2c_msm_prof_evnt_add(ctrl, MSM_PROF,
+					I2C_MSM_IRQ_END,
+					ctrl->i2c_sts_reg, ctrl->qup_op_reg,
+					err_flags);
+
+	if (signal_complete)
+		complete(&ctrl->xfer.complete);
+
+	return IRQ_HANDLED;
+}
+
+static void i2x_msm_blk_free_cache(struct i2c_msm_ctrl *ctrl)
+{
+	kfree(ctrl->xfer.blk.tx_cache);
+	kfree(ctrl->xfer.blk.rx_cache);
+}
+
+static void i2c_msm_qup_init(struct i2c_msm_ctrl *ctrl)
+{
+	u32 state;
+	void __iomem *base = ctrl->rsrcs.base;
+
+	i2c_msm_prof_evnt_add(ctrl, MSM_PROF, I2C_MSM_PROF_RESET, 0, 0, 0);
+
+	i2c_msm_qup_sw_reset(ctrl);
+	i2c_msm_qup_state_set(ctrl, QUP_STATE_RESET);
+
+	writel_relaxed(QUP_N_VAL | QUP_MINI_CORE_I2C_VAL, base + QUP_CONFIG);
+
+	writel_relaxed(QUP_OUTPUT_OVER_RUN_ERR_EN | QUP_INPUT_UNDER_RUN_ERR_EN
+		     | QUP_OUTPUT_UNDER_RUN_ERR_EN | QUP_INPUT_OVER_RUN_ERR_EN,
+					base + QUP_ERROR_FLAGS_EN);
+
+	writel_relaxed(QUP_INPUT_SERVICE_MASK | QUP_OUTPUT_SERVICE_MASK,
+					base + QUP_OPERATIONAL_MASK);
+
+	writel_relaxed(QUP_EN_VERSION_TWO_TAG, base + QUP_I2C_MASTER_CONFIG);
+
+	i2c_msm_qup_fifo_calc_size(ctrl);
+	/*
+	 * Ensure that QUP configuration is written and that fifo size if read
+	 * before leaving this function
+	 */
+	mb();
+
+	state = readl_relaxed(base + QUP_STATE);
+
+	if (!(state & QUP_I2C_MAST_GEN))
+		dev_err(ctrl->dev,
+			"error on verifying HW support (I2C_MAST_GEN=0)\n");
+}
+
+/*
+ * qup_i2c_try_recover_bus_busy: issue QUP bus clear command
+ */
+static int qup_i2c_try_recover_bus_busy(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+	ulong min_sleep_usec;
+
+	/* call i2c_msm_qup_init() to set core in idle state */
+	i2c_msm_qup_init(ctrl);
+
+	/* must be in run state for bus clear */
+	ret = i2c_msm_qup_state_set(ctrl, QUP_STATE_RUN);
+	if (ret < 0) {
+		dev_err(ctrl->dev, "error: bus clear fail to set run state\n");
+		return ret;
+	}
+
+	/*
+	 * call i2c_msm_qup_xfer_init_run_state() to set clock dividers.
+	 * the dividers are necessary for bus clear.
+	 */
+	i2c_msm_qup_xfer_init_run_state(ctrl);
+
+	writel_relaxed(0x1, ctrl->rsrcs.base + QUP_I2C_MASTER_BUS_CLR);
+
+	/*
+	 * wait for recovery (9 clock pulse cycles) to complete.
+	 * min_time = 9 clock *10  (1000% margin)
+	 * max_time = 10* min_time
+	 */
+	min_sleep_usec =
+	  max_t(ulong, (9 * 10 * USEC_PER_SEC) / ctrl->rsrcs.clk_freq_out, 100);
+
+	usleep_range(min_sleep_usec, min_sleep_usec * 10);
+	return ret;
+}
+
+static int qup_i2c_recover_bus_busy(struct i2c_msm_ctrl *ctrl)
+{
+	u32 bus_clr, bus_active, status;
+	int retry = 0;
+
+	dev_info(ctrl->dev, "Executing bus recovery procedure (9 clk pulse)\n");
+
+	do {
+		qup_i2c_try_recover_bus_busy(ctrl);
+		bus_clr    = readl_relaxed(ctrl->rsrcs.base +
+							QUP_I2C_MASTER_BUS_CLR);
+		status     = readl_relaxed(ctrl->rsrcs.base + QUP_I2C_STATUS);
+		bus_active = status & I2C_STATUS_BUS_ACTIVE;
+		if (++retry >= I2C_QUP_MAX_BUS_RECOVERY_RETRY)
+			break;
+	} while (bus_clr || bus_active);
+
+	dev_info(ctrl->dev, "Bus recovery %s after %d retries\n",
+		(bus_clr || bus_active) ? "fail" : "success", retry);
+	return 0;
+}
+
+static int i2c_msm_qup_post_xfer(struct i2c_msm_ctrl *ctrl, int err)
+{
+	/* poll until bus is released */
+	if (i2c_msm_qup_poll_bus_active_unset(ctrl)) {
+		if ((ctrl->xfer.err == I2C_MSM_ERR_ARB_LOST) ||
+		    (ctrl->xfer.err == I2C_MSM_ERR_BUS_ERR)  ||
+		    (ctrl->xfer.err == I2C_MSM_ERR_TIMEOUT)) {
+			if (i2c_msm_qup_slv_holds_bus(ctrl))
+				qup_i2c_recover_bus_busy(ctrl);
+
+			/* do not generalize error to EIO if its already set */
+			if (!err)
+				err = -EIO;
+		}
+	}
+
+	/*
+	 * Disable the IRQ before change to reset state to avoid
+	 * spurious interrupts.
+	 *
+	 */
+	disable_irq(ctrl->rsrcs.irq);
+
+	/* flush dma data and reset the qup core in timeout error.
+	 * for other error case, its handled by the ISR
+	 */
+	if (ctrl->xfer.err & I2C_MSM_ERR_TIMEOUT) {
+		/* Flush for the DMA registers */
+		if (ctrl->xfer.mode_id == I2C_MSM_XFER_MODE_DMA)
+			writel_relaxed(QUP_I2C_FLUSH, ctrl->rsrcs.base
+								+ QUP_STATE);
+
+		/* reset the qup core */
+		i2c_msm_qup_state_set(ctrl, QUP_STATE_RESET);
+		err = -ETIMEDOUT;
+	} else if (ctrl->xfer.err == I2C_MSM_ERR_NACK) {
+		err = -ENOTCONN;
+	}
+
+	return err;
+}
+
+static enum i2c_msm_xfer_mode_id
+i2c_msm_qup_choose_mode(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_mode_fifo *fifo = &ctrl->xfer.fifo;
+	struct i2c_msm_xfer           *xfer = &ctrl->xfer;
+	size_t rx_cnt_sum = xfer->rx_cnt + xfer->rx_ovrhd_cnt;
+	size_t tx_cnt_sum = xfer->tx_cnt + xfer->tx_ovrhd_cnt;
+
+
+	if (ctrl->dbgfs.force_xfer_mode != I2C_MSM_XFER_MODE_NONE)
+		return ctrl->dbgfs.force_xfer_mode;
+
+	if (((rx_cnt_sum < fifo->input_fifo_sz) &&
+		(tx_cnt_sum < fifo->output_fifo_sz)))
+		return I2C_MSM_XFER_MODE_FIFO;
+
+	if (ctrl->rsrcs.disable_dma)
+		return I2C_MSM_XFER_MODE_BLOCK;
+
+	return I2C_MSM_XFER_MODE_DMA;
+}
+
+/*
+ * i2c_msm_xfer_calc_timeout: calc maximum xfer time in jiffies
+ *
+ * Basically timeout = (bit_count / frequency) * safety_coefficient.
+ * The safety-coefficient also accounts for debugging delay (mostly from
+ * printk() calls).
+ */
+static void i2c_msm_xfer_calc_timeout(struct i2c_msm_ctrl *ctrl)
+{
+	size_t byte_cnt = ctrl->xfer.rx_cnt + ctrl->xfer.tx_cnt;
+	size_t bit_cnt  = byte_cnt * 9;
+	size_t bit_usec = (bit_cnt * USEC_PER_SEC) / ctrl->rsrcs.clk_freq_out;
+	size_t loging_ovrhd_coef = ctrl->dbgfs.dbg_lvl + 1;
+	size_t safety_coef   = I2C_MSM_TIMEOUT_SAFETY_COEF * loging_ovrhd_coef;
+	size_t xfer_max_usec = (bit_usec * safety_coef) +
+						I2C_MSM_TIMEOUT_MIN_USEC;
+
+	ctrl->xfer.timeout = usecs_to_jiffies(xfer_max_usec);
+}
+
+static int i2c_msm_xfer_wait_for_completion(struct i2c_msm_ctrl *ctrl,
+						struct completion *complete)
+{
+	struct i2c_msm_xfer *xfer = &ctrl->xfer;
+	long  time_left;
+	int   ret = 0;
+
+	time_left = wait_for_completion_timeout(complete,
+						xfer->timeout);
+	if (!time_left) {
+		xfer->err = I2C_MSM_ERR_TIMEOUT;
+		i2c_msm_dbg_dump_diag(ctrl, false, 0, 0);
+		ret = -EIO;
+		i2c_msm_prof_evnt_add(ctrl, MSM_ERR, I2C_MSM_COMPLT_FL,
+					xfer->timeout, time_left, 0);
+	} else {
+		/* return an error if one detected by ISR */
+		if (ctrl->xfer.err ||
+				(ctrl->dbgfs.dbg_lvl >= MSM_DBG)) {
+			i2c_msm_dbg_dump_diag(ctrl, true,
+					ctrl->i2c_sts_reg, ctrl->qup_op_reg);
+			ret = -(xfer->err);
+		}
+		i2c_msm_prof_evnt_add(ctrl, MSM_DBG, I2C_MSM_COMPLT_OK,
+					xfer->timeout, time_left, 0);
+	}
+
+	return ret;
+}
+
+static u16 i2c_msm_slv_rd_wr_addr(u16 slv_addr, bool is_rx)
+{
+	return (slv_addr << 1) | (is_rx ? 0x1 : 0x0);
+}
+
+/*
+ * @return true when the current transfer's buffer points to the last message
+ *    of the user's request.
+ */
+static bool i2c_msm_xfer_msg_is_last(struct i2c_msm_ctrl *ctrl)
+{
+	return ctrl->xfer.cur_buf.msg_idx >= (ctrl->xfer.msg_cnt - 1);
+}
+
+/*
+ * @return true when the current transfer's buffer points to the last
+ *    transferable buffer (size =< QUP_MAX_BUF_SZ) of the last message of the
+ *    user's request.
+ */
+static bool i2c_msm_xfer_buf_is_last(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf;
+	struct i2c_msg *cur_msg = ctrl->xfer.msgs + cur_buf->msg_idx;
+
+	return i2c_msm_xfer_msg_is_last(ctrl) &&
+		((cur_buf->byte_idx + QUP_MAX_BUF_SZ) >= cur_msg->len);
+}
+
+static void i2c_msm_xfer_create_cur_tag(struct i2c_msm_ctrl *ctrl,
+								bool start_req)
+{
+	struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf;
+
+	cur_buf->out_tag = i2c_msm_tag_create(start_req, cur_buf->is_last,
+					cur_buf->is_rx, cur_buf->len,
+					cur_buf->slv_addr);
+
+	cur_buf->in_tag.len = cur_buf->is_rx ? QUP_BUF_OVERHD_BC : 0;
+}
+
+/*
+ * i2c_msm_xfer_next_buf: support cases when msg.len > 256 bytes
+ *
+ * @return true when next buffer exist, or false when no such buffer
+ */
+static bool i2c_msm_xfer_next_buf(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf;
+	struct i2c_msg          *cur_msg = ctrl->xfer.msgs + cur_buf->msg_idx;
+	int bc_rem = cur_msg->len - cur_buf->end_idx;
+
+	if (cur_buf->is_init && cur_buf->end_idx && bc_rem) {
+		/* not the first buffer in a message */
+
+		cur_buf->byte_idx  = cur_buf->end_idx;
+		cur_buf->is_last   = i2c_msm_xfer_buf_is_last(ctrl);
+		cur_buf->len       = min_t(int, bc_rem, QUP_MAX_BUF_SZ);
+		cur_buf->end_idx  += cur_buf->len;
+
+		/* No Start is required if it is not a first buffer in msg */
+		i2c_msm_xfer_create_cur_tag(ctrl, false);
+	} else {
+		/* first buffer in a new message */
+		if (cur_buf->is_init) {
+			if (i2c_msm_xfer_msg_is_last(ctrl))
+				return false;
+
+			++cur_buf->msg_idx;
+			++cur_msg;
+		} else {
+			cur_buf->is_init = true;
+		}
+		cur_buf->byte_idx  = 0;
+		cur_buf->is_last   = i2c_msm_xfer_buf_is_last(ctrl);
+		cur_buf->len       = min_t(int, cur_msg->len, QUP_MAX_BUF_SZ);
+		cur_buf->is_rx     = (cur_msg->flags & I2C_M_RD);
+		cur_buf->end_idx   = cur_buf->len;
+		cur_buf->slv_addr  = i2c_msm_slv_rd_wr_addr(cur_msg->addr,
+								cur_buf->is_rx);
+		i2c_msm_xfer_create_cur_tag(ctrl, true);
+	}
+	i2c_msm_prof_evnt_add(ctrl, MSM_DBG, I2C_MSM_NEXT_BUF, cur_buf->msg_idx,
+							cur_buf->byte_idx, 0);
+	return  true;
+}
+
+static void i2c_msm_pm_clk_unprepare(struct i2c_msm_ctrl *ctrl)
+{
+	clk_unprepare(ctrl->rsrcs.core_clk);
+	clk_unprepare(ctrl->rsrcs.iface_clk);
+}
+
+static int i2c_msm_pm_clk_prepare(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	ret = clk_prepare(ctrl->rsrcs.iface_clk);
+
+	if (ret) {
+		dev_err(ctrl->dev,
+			"error on clk_prepare(iface_clk):%d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare(ctrl->rsrcs.core_clk);
+	if (ret) {
+		clk_unprepare(ctrl->rsrcs.iface_clk);
+		dev_err(ctrl->dev,
+			"error clk_prepare(core_clk):%d\n", ret);
+	}
+	return ret;
+}
+
+static void i2c_msm_pm_clk_disable(struct i2c_msm_ctrl *ctrl)
+{
+	clk_disable(ctrl->rsrcs.core_clk);
+	clk_disable(ctrl->rsrcs.iface_clk);
+}
+
+static int i2c_msm_pm_clk_enable(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	ret = clk_enable(ctrl->rsrcs.iface_clk);
+	if (ret) {
+		dev_err(ctrl->dev,
+			"error on clk_enable(iface_clk):%d\n", ret);
+		i2c_msm_pm_clk_unprepare(ctrl);
+		return ret;
+	}
+	ret = clk_enable(ctrl->rsrcs.core_clk);
+	if (ret) {
+		clk_disable(ctrl->rsrcs.iface_clk);
+		i2c_msm_pm_clk_unprepare(ctrl);
+		dev_err(ctrl->dev,
+			"error clk_enable(core_clk):%d\n", ret);
+	}
+	return ret;
+}
+
+static int i2c_msm_pm_xfer_start(struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	mutex_lock(&ctrl->xfer.mtx);
+
+	i2c_msm_pm_pinctrl_state(ctrl, true);
+	pm_runtime_get_sync(ctrl->dev);
+	/*
+	 * if runtime PM callback was not invoked (when both runtime-pm
+	 * and systme-pm are in transition concurrently)
+	 */
+	if (ctrl->pwr_state != I2C_MSM_PM_RT_ACTIVE) {
+		dev_info(ctrl->dev, "Runtime PM-callback was not invoked.\n");
+		i2c_msm_pm_resume(ctrl->dev);
+	}
+
+	ret = i2c_msm_pm_clk_enable(ctrl);
+	if (ret) {
+		mutex_unlock(&ctrl->xfer.mtx);
+		return ret;
+	}
+	i2c_msm_qup_init(ctrl);
+
+	/* Set xfer to active state (efectively enabling our ISR)*/
+	atomic_set(&ctrl->xfer.is_active, 1);
+
+	enable_irq(ctrl->rsrcs.irq);
+	return 0;
+}
+
+static void i2c_msm_pm_xfer_end(struct i2c_msm_ctrl *ctrl)
+{
+
+	atomic_set(&ctrl->xfer.is_active, 0);
+
+	/*
+	 * DMA resources are freed due to multi-EE use case.
+	 * Other EEs can potentially use the DMA
+	 * resources with in the same runtime PM vote.
+	 */
+	if (ctrl->xfer.mode_id == I2C_MSM_XFER_MODE_DMA)
+		i2c_msm_dma_free_channels(ctrl);
+
+	i2c_msm_pm_clk_disable(ctrl);
+
+	if (!pm_runtime_enabled(ctrl->dev))
+		i2c_msm_pm_suspend(ctrl->dev);
+
+	pm_runtime_mark_last_busy(ctrl->dev);
+	pm_runtime_put_autosuspend(ctrl->dev);
+	i2c_msm_pm_pinctrl_state(ctrl, false);
+	mutex_unlock(&ctrl->xfer.mtx);
+}
+
+/*
+ * i2c_msm_xfer_scan: initial input scan
+ */
+static void i2c_msm_xfer_scan(struct i2c_msm_ctrl *ctrl)
+{
+	struct i2c_msm_xfer     *xfer      = &ctrl->xfer;
+	struct i2c_msm_xfer_buf *cur_buf   = &xfer->cur_buf;
+
+	while (i2c_msm_xfer_next_buf(ctrl)) {
+
+		if (cur_buf->is_rx)
+			xfer->rx_cnt += cur_buf->len;
+		else
+			xfer->tx_cnt += cur_buf->len;
+
+		xfer->rx_ovrhd_cnt += cur_buf->in_tag.len;
+		xfer->tx_ovrhd_cnt += cur_buf->out_tag.len;
+
+		if (i2c_msm_xfer_msg_is_last(ctrl))
+			xfer->last_is_rx = cur_buf->is_rx;
+	}
+	xfer->cur_buf = (struct i2c_msm_xfer_buf){0};
+}
+
+static int
+i2c_msm_frmwrk_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
+{
+	int ret = 0;
+	struct i2c_msm_ctrl      *ctrl = i2c_get_adapdata(adap);
+	struct i2c_msm_xfer      *xfer = &ctrl->xfer;
+
+	if (IS_ERR_OR_NULL(msgs)) {
+		dev_err(ctrl->dev, " error on msgs Accessing invalid  pointer location\n");
+		return PTR_ERR(msgs);
+	}
+
+	/* if system is suspended just bail out */
+	if (ctrl->pwr_state == I2C_MSM_PM_SYS_SUSPENDED) {
+		dev_err(ctrl->dev,
+				"slave:0x%x is calling xfer when system is suspended\n",
+				msgs->addr);
+		return -EIO;
+	}
+
+	ret = i2c_msm_pm_xfer_start(ctrl);
+	if (ret)
+		return ret;
+
+	/* init xfer */
+	xfer->msgs         = msgs;
+	xfer->msg_cnt      = num;
+	xfer->mode_id      = I2C_MSM_XFER_MODE_NONE;
+	xfer->err          = 0;
+	xfer->rx_cnt       = 0;
+	xfer->tx_cnt       = 0;
+	xfer->rx_ovrhd_cnt = 0;
+	xfer->tx_ovrhd_cnt = 0;
+	atomic_set(&xfer->event_cnt, 0);
+	init_completion(&xfer->complete);
+	init_completion(&xfer->rx_complete);
+
+	xfer->cur_buf.is_init = false;
+	xfer->cur_buf.msg_idx = 0;
+
+	i2c_msm_prof_evnt_add(ctrl, MSM_PROF, I2C_MSM_XFER_BEG, num,
+								msgs->addr, 0);
+
+	i2c_msm_xfer_scan(ctrl);
+	i2c_msm_xfer_calc_timeout(ctrl);
+	xfer->mode_id = i2c_msm_qup_choose_mode(ctrl);
+
+	dev_dbg(ctrl->dev, "xfer() mode:%d msg_cnt:%d rx_cbt:%zu tx_cnt:%zu\n",
+		xfer->mode_id, xfer->msg_cnt, xfer->rx_cnt, xfer->tx_cnt);
+
+	switch (xfer->mode_id) {
+	case I2C_MSM_XFER_MODE_FIFO:
+		ret = i2c_msm_fifo_xfer(ctrl);
+		break;
+	case I2C_MSM_XFER_MODE_BLOCK:
+		ret = i2c_msm_blk_xfer(ctrl);
+		break;
+	case I2C_MSM_XFER_MODE_DMA:
+		ret = i2c_msm_dma_xfer(ctrl);
+		break;
+	default:
+		ret = -EINTR;
+	};
+
+	i2c_msm_prof_evnt_add(ctrl, MSM_PROF, I2C_MSM_SCAN_SUM,
+		((xfer->rx_cnt & 0xff) | ((xfer->rx_ovrhd_cnt & 0xff) << 16)),
+		((xfer->tx_cnt & 0xff) | ((xfer->tx_ovrhd_cnt & 0xff) << 16)),
+		((ctrl->xfer.timeout & 0xfff) | ((xfer->mode_id & 0xf) << 24)));
+
+	ret = i2c_msm_qup_post_xfer(ctrl, ret);
+	/* on success, return number of messages sent (which is index + 1)*/
+	if (!ret)
+		ret = xfer->cur_buf.msg_idx + 1;
+
+	i2c_msm_prof_evnt_add(ctrl, MSM_PROF, I2C_MSM_XFER_END, ret, xfer->err,
+						xfer->cur_buf.msg_idx + 1);
+	/* process and dump profiling data */
+	if (xfer->err || (ctrl->dbgfs.dbg_lvl >= MSM_PROF))
+		i2c_msm_prof_evnt_dump(ctrl);
+
+	i2c_msm_pm_xfer_end(ctrl);
+	return ret;
+}
+
+enum i2c_msm_dt_entry_status {
+	DT_REQ,  /* Required:  fail if missing */
+	DT_SGST, /* Suggested: warn if missing */
+	DT_OPT,  /* Optional:  don't warn if missing */
+};
+
+enum i2c_msm_dt_entry_type {
+	DT_U32,
+	DT_BOOL,
+	DT_ID,   /* of_alias_get_id() */
+};
+
+struct i2c_msm_dt_to_pdata_map {
+	const char                  *dt_name;
+	void                        *ptr_data;
+	enum i2c_msm_dt_entry_status status;
+	enum i2c_msm_dt_entry_type   type;
+	int                          default_val;
+};
+
+static int i2c_msm_dt_to_pdata_populate(struct i2c_msm_ctrl *ctrl,
+					struct platform_device *pdev,
+					struct i2c_msm_dt_to_pdata_map *itr)
+{
+	int  ret, err = 0;
+	struct device_node *node = pdev->dev.of_node;
+
+	for (; itr->dt_name ; ++itr) {
+		switch (itr->type) {
+		case DT_U32:
+			ret = of_property_read_u32(node, itr->dt_name,
+							 (u32 *) itr->ptr_data);
+			break;
+		case DT_BOOL:
+			*((bool *) itr->ptr_data) =
+				of_property_read_bool(node, itr->dt_name);
+			ret = 0;
+			break;
+		case DT_ID:
+			ret = of_alias_get_id(node, itr->dt_name);
+			if (ret >= 0) {
+				*((int *) itr->ptr_data) = ret;
+				ret = 0;
+			}
+			break;
+		default:
+			dev_err(ctrl->dev,
+				"error %d is of unknown DT entry type\n",
+				itr->type);
+			ret = -EBADE;
+		}
+
+		i2c_msm_dbg(ctrl, MSM_PROF, "DT entry ret:%d name:%s val:%d",
+				ret, itr->dt_name, *((int *)itr->ptr_data));
+
+		if (ret) {
+			*((int *)itr->ptr_data) = itr->default_val;
+
+			if (itr->status < DT_OPT) {
+				dev_err(ctrl->dev,
+					"error Missing '%s' DT entry\n",
+					itr->dt_name);
+
+				/* cont on err to dump all missing entries */
+				if (itr->status == DT_REQ && !err)
+					err = ret;
+			}
+		}
+	}
+
+	return err;
+}
+
+
+/*
+ * i2c_msm_rsrcs_process_dt: copy data from DT to platform data
+ * @return zero on success or negative error code
+ */
+static int i2c_msm_rsrcs_process_dt(struct i2c_msm_ctrl *ctrl,
+					struct platform_device *pdev)
+{
+	u32 fs_clk_div, ht_clk_div, noise_rjct_scl, noise_rjct_sda;
+	int ret;
+
+	struct i2c_msm_dt_to_pdata_map map[] = {
+	{"i2c",				&pdev->id,	DT_REQ,  DT_ID,  -1},
+	{"qcom,clk-freq-out",		&ctrl->rsrcs.clk_freq_out,
+							DT_REQ,  DT_U32,  0},
+	{"qcom,clk-freq-in",		&ctrl->rsrcs.clk_freq_in,
+							DT_REQ,  DT_U32,  0},
+	{"qcom,disable-dma",		&(ctrl->rsrcs.disable_dma),
+							DT_OPT,  DT_BOOL, 0},
+	{"qcom,master-id",		&(ctrl->rsrcs.clk_path_vote.mstr_id),
+							DT_SGST, DT_U32,  0},
+	{"qcom,noise-rjct-scl",		&noise_rjct_scl,
+							DT_OPT,  DT_U32,  0},
+	{"qcom,noise-rjct-sda",		&noise_rjct_sda,
+							DT_OPT,  DT_U32,  0},
+	{"qcom,high-time-clk-div",	&ht_clk_div,
+							DT_OPT,  DT_U32,  0},
+	{"qcom,fs-clk-div",		&fs_clk_div,
+							DT_OPT,  DT_U32,  0},
+	{NULL,  NULL,					0,       0,       0},
+	};
+
+	ret = i2c_msm_dt_to_pdata_populate(ctrl, pdev, map);
+	if (ret)
+		return ret;
+
+	/* set divider and noise reject values */
+	return i2c_msm_set_mstr_clk_ctl(ctrl, fs_clk_div, ht_clk_div,
+						noise_rjct_scl, noise_rjct_sda);
+}
+
+/*
+ * i2c_msm_rsrcs_mem_init: reads pdata request region and ioremap it
+ * @return zero on success or negative error code
+ */
+static int i2c_msm_rsrcs_mem_init(struct platform_device *pdev,
+						struct i2c_msm_ctrl *ctrl)
+{
+	struct resource *mem_region;
+
+	ctrl->rsrcs.mem = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+							"qup_phys_addr");
+	if (!ctrl->rsrcs.mem) {
+		dev_err(ctrl->dev, "error Missing 'qup_phys_addr' resource\n");
+		return -ENODEV;
+	}
+
+	mem_region = request_mem_region(ctrl->rsrcs.mem->start,
+					resource_size(ctrl->rsrcs.mem),
+					pdev->name);
+	if (!mem_region) {
+		dev_err(ctrl->dev,
+			"QUP physical memory region already claimed\n");
+		return -EBUSY;
+	}
+
+	ctrl->rsrcs.base = devm_ioremap(ctrl->dev, ctrl->rsrcs.mem->start,
+				   resource_size(ctrl->rsrcs.mem));
+	if (!ctrl->rsrcs.base) {
+		dev_err(ctrl->dev,
+			"error failed ioremap(base:0x%llx size:0x%llx\n)",
+			(u64) ctrl->rsrcs.mem->start,
+			(u64) resource_size(ctrl->rsrcs.mem));
+		release_mem_region(ctrl->rsrcs.mem->start,
+						resource_size(ctrl->rsrcs.mem));
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+static void i2c_msm_rsrcs_mem_teardown(struct i2c_msm_ctrl *ctrl)
+{
+	release_mem_region(ctrl->rsrcs.mem->start,
+						resource_size(ctrl->rsrcs.mem));
+}
+
+/*
+ * i2c_msm_rsrcs_irq_init: finds irq num in pdata and requests it
+ * @return zero on success or negative error code
+ */
+static int i2c_msm_rsrcs_irq_init(struct platform_device *pdev,
+						struct i2c_msm_ctrl *ctrl)
+{
+	int ret, irq;
+
+	irq = platform_get_irq_byname(pdev, "qup_irq");
+	if (irq < 0) {
+		dev_err(ctrl->dev, "error reading irq resource\n");
+		return irq;
+	}
+
+	ret = request_irq(irq, i2c_msm_qup_isr, IRQF_TRIGGER_HIGH,
+						"i2c-msm-v2-irq", ctrl);
+	if (ret) {
+		dev_err(ctrl->dev, "error request_irq(irq_num:%d ) ret:%d\n",
+								irq, ret);
+		return ret;
+	}
+
+	disable_irq(irq);
+	ctrl->rsrcs.irq = irq;
+	return 0;
+}
+
+static void i2c_msm_rsrcs_irq_teardown(struct i2c_msm_ctrl *ctrl)
+{
+	free_irq(ctrl->rsrcs.irq, ctrl);
+}
+
+
+static struct pinctrl_state *
+i2c_msm_rsrcs_gpio_get_state(struct i2c_msm_ctrl *ctrl, const char *name)
+{
+	struct pinctrl_state *pin_state
+			= pinctrl_lookup_state(ctrl->rsrcs.pinctrl, name);
+
+	if (IS_ERR_OR_NULL(pin_state))
+		dev_info(ctrl->dev, "note pinctrl_lookup_state(%s) err:%ld\n",
+						name, PTR_ERR(pin_state));
+	return pin_state;
+}
+
+/*
+ * i2c_msm_rsrcs_gpio_pinctrl_init: initializes the pinctrl for i2c gpios
+ *
+ * @pre platform data must be initialized
+ */
+static int i2c_msm_rsrcs_gpio_pinctrl_init(struct i2c_msm_ctrl *ctrl)
+{
+	ctrl->rsrcs.pinctrl = devm_pinctrl_get(ctrl->dev);
+	if (IS_ERR_OR_NULL(ctrl->rsrcs.pinctrl)) {
+		dev_err(ctrl->dev, "error devm_pinctrl_get() failed err:%ld\n",
+				PTR_ERR(ctrl->rsrcs.pinctrl));
+		return PTR_ERR(ctrl->rsrcs.pinctrl);
+	}
+
+	ctrl->rsrcs.gpio_state_active =
+		i2c_msm_rsrcs_gpio_get_state(ctrl, I2C_MSM_PINCTRL_ACTIVE);
+
+	ctrl->rsrcs.gpio_state_suspend =
+		i2c_msm_rsrcs_gpio_get_state(ctrl, I2C_MSM_PINCTRL_SUSPEND);
+
+	return 0;
+}
+
+static void i2c_msm_pm_pinctrl_state(struct i2c_msm_ctrl *ctrl,
+				bool runtime_active)
+{
+	struct pinctrl_state *pins_state;
+	const char           *pins_state_name;
+
+	if (runtime_active) {
+		pins_state      = ctrl->rsrcs.gpio_state_active;
+		pins_state_name = I2C_MSM_PINCTRL_ACTIVE;
+	} else {
+		pins_state      = ctrl->rsrcs.gpio_state_suspend;
+		pins_state_name = I2C_MSM_PINCTRL_SUSPEND;
+	}
+
+	if (!IS_ERR_OR_NULL(pins_state)) {
+		int ret = pinctrl_select_state(ctrl->rsrcs.pinctrl, pins_state);
+
+		if (ret)
+			dev_err(ctrl->dev,
+			"error pinctrl_select_state(%s) err:%d\n",
+			pins_state_name, ret);
+	} else {
+		dev_err(ctrl->dev,
+			"error pinctrl state-name:'%s' is not configured\n",
+			pins_state_name);
+	}
+}
+
+/*
+ * i2c_msm_rsrcs_clk_init: get clocks and set rate
+ *
+ * @return zero on success or negative error code
+ */
+static int i2c_msm_rsrcs_clk_init(struct i2c_msm_ctrl *ctrl)
+{
+	int ret = 0;
+
+	if ((ctrl->rsrcs.clk_freq_out <= 0) ||
+	    (ctrl->rsrcs.clk_freq_out > I2C_MSM_CLK_FAST_PLUS_FREQ)) {
+		dev_err(ctrl->dev,
+			"error clock frequency %dKHZ is not supported\n",
+			(ctrl->rsrcs.clk_freq_out / 1000));
+		return -EIO;
+	}
+
+	ctrl->rsrcs.core_clk = clk_get(ctrl->dev, "core_clk");
+	if (IS_ERR(ctrl->rsrcs.core_clk)) {
+		ret = PTR_ERR(ctrl->rsrcs.core_clk);
+		dev_err(ctrl->dev, "error on clk_get(core_clk):%d\n", ret);
+		return ret;
+	}
+
+	ret = clk_set_rate(ctrl->rsrcs.core_clk, ctrl->rsrcs.clk_freq_in);
+	if (ret) {
+		dev_err(ctrl->dev, "error on clk_set_rate(core_clk, %dKHz):%d\n",
+					(ctrl->rsrcs.clk_freq_in / 1000), ret);
+		goto err_set_rate;
+	}
+
+	ctrl->rsrcs.iface_clk = clk_get(ctrl->dev, "iface_clk");
+	if (IS_ERR(ctrl->rsrcs.iface_clk)) {
+		ret = PTR_ERR(ctrl->rsrcs.iface_clk);
+		dev_err(ctrl->dev, "error on clk_get(iface_clk):%d\n", ret);
+		goto err_set_rate;
+	}
+
+	return 0;
+
+err_set_rate:
+		clk_put(ctrl->rsrcs.core_clk);
+		ctrl->rsrcs.core_clk = NULL;
+	return ret;
+}
+
+static void i2c_msm_rsrcs_clk_teardown(struct i2c_msm_ctrl *ctrl)
+{
+	clk_put(ctrl->rsrcs.core_clk);
+	clk_put(ctrl->rsrcs.iface_clk);
+	i2c_msm_clk_path_teardown(ctrl);
+}
+
+
+
+static void i2c_msm_pm_suspend(struct device *dev)
+{
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+
+	if (ctrl->pwr_state == I2C_MSM_PM_RT_SUSPENDED) {
+		dev_err(ctrl->dev, "attempt to suspend when suspended\n");
+		return;
+	}
+	i2c_msm_dbg(ctrl, MSM_DBG, "suspending...");
+	i2c_msm_pm_clk_unprepare(ctrl);
+	i2c_msm_clk_path_unvote(ctrl);
+
+	/*
+	 * We implement system and runtime suspend in the same way. However
+	 * it is important for us to distinguish between them in when servicing
+	 * a transfer requests. If we get transfer request while in runtime
+	 * suspend we want to simply wake up and service that request. But if we
+	 * get a transfer request while system is suspending we want to bail
+	 * out on that request. This is why if we marked that we are in system
+	 * suspend, we do not want to override that state with runtime suspend.
+	 */
+	if (ctrl->pwr_state != I2C_MSM_PM_SYS_SUSPENDED)
+		ctrl->pwr_state = I2C_MSM_PM_RT_SUSPENDED;
+}
+
+static int i2c_msm_pm_resume(struct device *dev)
+{
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+
+	if (ctrl->pwr_state == I2C_MSM_PM_RT_ACTIVE)
+		return 0;
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "resuming...");
+
+	i2c_msm_clk_path_vote(ctrl);
+	i2c_msm_pm_clk_prepare(ctrl);
+	ctrl->pwr_state = I2C_MSM_PM_RT_ACTIVE;
+	return 0;
+}
+
+#ifdef CONFIG_PM
+/*
+ * i2c_msm_pm_sys_suspend_noirq: system power management callback
+ */
+static int i2c_msm_pm_sys_suspend_noirq(struct device *dev)
+{
+	int ret = 0;
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+	enum i2c_msm_power_state prev_state = ctrl->pwr_state;
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "pm_sys_noirq: suspending...");
+
+	/* Acquire mutex to ensure current transaction is over */
+	mutex_lock(&ctrl->xfer.mtx);
+	ctrl->pwr_state = I2C_MSM_PM_SYS_SUSPENDED;
+	mutex_unlock(&ctrl->xfer.mtx);
+	i2c_msm_dbg(ctrl, MSM_DBG, "pm_sys_noirq: suspending...");
+
+	if (prev_state == I2C_MSM_PM_RT_ACTIVE) {
+		i2c_msm_pm_suspend(dev);
+		/*
+		 * Synchronize runtime-pm and system-pm states:
+		 * at this point we are already suspended. However, the
+		 * runtime-PM framework still thinks that we are active.
+		 * The three calls below let the runtime-PM know that we are
+		 * suspended already without re-invoking the suspend callback
+		 */
+		pm_runtime_disable(dev);
+		pm_runtime_set_suspended(dev);
+		pm_runtime_enable(dev);
+	}
+
+	return ret;
+}
+
+/*
+ * i2c_msm_pm_sys_resume: system power management callback
+ * shifts the controller's power state from system suspend to runtime suspend
+ */
+static int i2c_msm_pm_sys_resume_noirq(struct device *dev)
+{
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "pm_sys_noirq: resuming...");
+	mutex_lock(&ctrl->xfer.mtx);
+	ctrl->pwr_state = I2C_MSM_PM_RT_SUSPENDED;
+	mutex_unlock(&ctrl->xfer.mtx);
+	return  0;
+}
+#endif
+
+#ifdef CONFIG_PM
+static void i2c_msm_pm_rt_init(struct device *dev)
+{
+	pm_runtime_set_suspended(dev);
+	pm_runtime_set_autosuspend_delay(dev, (MSEC_PER_SEC >> 2));
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_enable(dev);
+}
+
+/*
+ * i2c_msm_pm_rt_suspend: runtime power management callback
+ */
+static int i2c_msm_pm_rt_suspend(struct device *dev)
+{
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "pm_runtime: suspending...");
+	i2c_msm_pm_suspend(dev);
+	return 0;
+}
+
+/*
+ * i2c_msm_pm_rt_resume: runtime power management callback
+ */
+static int i2c_msm_pm_rt_resume(struct device *dev)
+{
+	struct i2c_msm_ctrl *ctrl = dev_get_drvdata(dev);
+
+	i2c_msm_dbg(ctrl, MSM_DBG, "pm_runtime: resuming...");
+	return  i2c_msm_pm_resume(dev);
+}
+
+#else
+static void i2c_msm_pm_rt_init(struct device *dev) {}
+#define i2c_msm_pm_rt_suspend NULL
+#define i2c_msm_pm_rt_resume NULL
+#endif
+
+static const struct dev_pm_ops i2c_msm_pm_ops = {
+#ifdef CONFIG_PM_SLEEP
+	.suspend_noirq		= i2c_msm_pm_sys_suspend_noirq,
+	.resume_noirq		= i2c_msm_pm_sys_resume_noirq,
+#endif
+	SET_RUNTIME_PM_OPS(i2c_msm_pm_rt_suspend,
+			   i2c_msm_pm_rt_resume,
+			   NULL)
+};
+
+static u32 i2c_msm_frmwrk_func(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
+}
+
+static const struct i2c_algorithm i2c_msm_frmwrk_algrtm = {
+	.master_xfer	= i2c_msm_frmwrk_xfer,
+	.functionality	= i2c_msm_frmwrk_func,
+};
+
+static const char * const i2c_msm_adapter_name = "MSM-I2C-v2-adapter";
+
+static int i2c_msm_frmwrk_reg(struct platform_device *pdev,
+						struct i2c_msm_ctrl *ctrl)
+{
+	int ret;
+
+	i2c_set_adapdata(&ctrl->adapter, ctrl);
+	ctrl->adapter.algo = &i2c_msm_frmwrk_algrtm;
+	strlcpy(ctrl->adapter.name, i2c_msm_adapter_name,
+						sizeof(ctrl->adapter.name));
+
+	ctrl->adapter.nr = pdev->id;
+	ctrl->adapter.dev.parent = &pdev->dev;
+	ctrl->adapter.dev.of_node = pdev->dev.of_node;
+	ret = i2c_add_numbered_adapter(&ctrl->adapter);
+	if (ret) {
+		dev_err(ctrl->dev, "error i2c_add_adapter failed\n");
+		return ret;
+	}
+
+	return ret;
+}
+
+static void i2c_msm_frmwrk_unreg(struct i2c_msm_ctrl *ctrl)
+{
+	i2c_del_adapter(&ctrl->adapter);
+}
+
+static int i2c_msm_probe(struct platform_device *pdev)
+{
+	struct i2c_msm_ctrl *ctrl;
+	int ret = 0;
+
+	dev_info(&pdev->dev, "probing driver i2c-msm-v2\n");
+
+	ctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL);
+	if (!ctrl)
+		return -ENOMEM;
+	ctrl->dev = &pdev->dev;
+	platform_set_drvdata(pdev, ctrl);
+	ctrl->dbgfs.dbg_lvl         = DEFAULT_DBG_LVL;
+	ctrl->dbgfs.force_xfer_mode = I2C_MSM_XFER_MODE_NONE;
+	mutex_init(&ctrl->xfer.mtx);
+	ctrl->pwr_state = I2C_MSM_PM_RT_SUSPENDED;
+
+	if (!pdev->dev.of_node) {
+		dev_err(&pdev->dev, "error: null device-tree node");
+		return -EBADE;
+	}
+
+	ret = i2c_msm_rsrcs_process_dt(ctrl, pdev);
+	if (ret) {
+		dev_err(ctrl->dev, "error in process device tree node");
+		return ret;
+	}
+
+	ret = i2c_msm_rsrcs_mem_init(pdev, ctrl);
+	if (ret)
+		goto mem_err;
+
+	ret = i2c_msm_rsrcs_clk_init(ctrl);
+	if (ret)
+		goto clk_err;
+
+	/* vote for clock to enable reading the version number off the HW */
+	i2c_msm_clk_path_vote(ctrl);
+
+	ret = i2c_msm_pm_clk_prepare(ctrl);
+	if (ret)
+		goto clk_err;
+
+	ret = i2c_msm_pm_clk_enable(ctrl);
+	if (ret) {
+		i2c_msm_pm_clk_unprepare(ctrl);
+		goto clk_err;
+	}
+
+	/*
+	 * reset the core before registering for interrupts. This solves an
+	 * interrupt storm issue when the bootloader leaves a pending interrupt.
+	 */
+	ret = i2c_msm_qup_sw_reset(ctrl);
+	if (ret)
+		dev_err(ctrl->dev, "error error on qup software reset\n");
+
+	i2c_msm_pm_clk_disable(ctrl);
+	i2c_msm_pm_clk_unprepare(ctrl);
+	i2c_msm_clk_path_unvote(ctrl);
+
+	ret = i2c_msm_rsrcs_gpio_pinctrl_init(ctrl);
+	if (ret)
+		goto err_no_pinctrl;
+
+	i2c_msm_pm_rt_init(ctrl->dev);
+
+	ret = i2c_msm_rsrcs_irq_init(pdev, ctrl);
+	if (ret)
+		goto irq_err;
+
+	i2c_msm_dbgfs_init(ctrl);
+
+	ret = i2c_msm_frmwrk_reg(pdev, ctrl);
+	if (ret)
+		goto reg_err;
+
+	i2c_msm_dbg(ctrl, MSM_PROF, "probe() completed with success");
+	return 0;
+
+reg_err:
+	i2c_msm_dbgfs_teardown(ctrl);
+	i2c_msm_rsrcs_irq_teardown(ctrl);
+irq_err:
+	i2x_msm_blk_free_cache(ctrl);
+err_no_pinctrl:
+	i2c_msm_rsrcs_clk_teardown(ctrl);
+clk_err:
+	i2c_msm_rsrcs_mem_teardown(ctrl);
+mem_err:
+	dev_err(ctrl->dev, "error probe() failed with err:%d\n", ret);
+	devm_kfree(&pdev->dev, ctrl);
+	return ret;
+}
+
+static int i2c_msm_remove(struct platform_device *pdev)
+{
+	struct i2c_msm_ctrl *ctrl = platform_get_drvdata(pdev);
+
+	/* Grab mutex to ensure ongoing transaction is over */
+	mutex_lock(&ctrl->xfer.mtx);
+	ctrl->pwr_state = I2C_MSM_PM_SYS_SUSPENDED;
+	pm_runtime_disable(ctrl->dev);
+	/* no one can call a xfer after the next line */
+	i2c_msm_frmwrk_unreg(ctrl);
+	mutex_unlock(&ctrl->xfer.mtx);
+	mutex_destroy(&ctrl->xfer.mtx);
+
+	i2c_msm_dma_teardown(ctrl);
+	i2c_msm_dbgfs_teardown(ctrl);
+	i2c_msm_rsrcs_irq_teardown(ctrl);
+	i2c_msm_rsrcs_clk_teardown(ctrl);
+	i2c_msm_rsrcs_mem_teardown(ctrl);
+	i2x_msm_blk_free_cache(ctrl);
+	return 0;
+}
+
+static const struct of_device_id i2c_msm_dt_match[] = {
+	{
+		.compatible = "qcom,i2c-msm-v2",
+	},
+	{}
+};
+
+static struct platform_driver i2c_msm_driver = {
+	.probe  = i2c_msm_probe,
+	.remove = i2c_msm_remove,
+	.driver = {
+		.name           = "i2c-msm-v2",
+		.owner          = THIS_MODULE,
+		.pm             = &i2c_msm_pm_ops,
+		.of_match_table = i2c_msm_dt_match,
+	},
+};
+
+static int i2c_msm_init(void)
+{
+	return platform_driver_register(&i2c_msm_driver);
+}
+arch_initcall(i2c_msm_init);
+
+static void i2c_msm_exit(void)
+{
+	platform_driver_unregister(&i2c_msm_driver);
+}
+module_exit(i2c_msm_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:i2c-msm-v2");
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 91e7b0c..2460ba7 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -191,13 +191,6 @@
 
 static void geni_i2c_err(struct geni_i2c_dev *gi2c, int err)
 {
-	u32 m_cmd = readl_relaxed(gi2c->base + SE_GENI_M_CMD0);
-	u32 m_stat = readl_relaxed(gi2c->base + SE_GENI_M_IRQ_STATUS);
-	u32 geni_s = readl_relaxed(gi2c->base + SE_GENI_STATUS);
-	u32 geni_ios = readl_relaxed(gi2c->base + SE_GENI_IOS);
-	u32 dma = readl_relaxed(gi2c->base + SE_GENI_DMA_MODE_EN);
-	u32 rx_st, tx_st;
-
 	if (gi2c->cur)
 		GENI_SE_DBG(gi2c->ipcl, false, gi2c->dev,
 			    "len:%d, slv-addr:0x%x, RD/WR:%d\n", gi2c->cur->len,
@@ -211,23 +204,9 @@
 		GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev, "%s\n",
 			     gi2c_log[err].msg);
 	}
-	if (gi2c->se_mode == GSI_ONLY)
-		goto err_out;
-
-	if (dma) {
-		rx_st = readl_relaxed(gi2c->base + SE_DMA_RX_IRQ_STAT);
-		tx_st = readl_relaxed(gi2c->base + SE_DMA_TX_IRQ_STAT);
-	} else {
-		rx_st = readl_relaxed(gi2c->base + SE_GENI_RX_FIFO_STATUS);
-		tx_st = readl_relaxed(gi2c->base + SE_GENI_TX_FIFO_STATUS);
-	}
-	GENI_SE_DBG(gi2c->ipcl, false, gi2c->dev,
-		     "DMA:%d tx_stat:0x%x, rx_stat:0x%x, irq-stat:0x%x\n",
-		     dma, tx_st, rx_st, m_stat);
-err_out:
-	GENI_SE_DBG(gi2c->ipcl, false, gi2c->dev,
-			     "m_cmd:0x%x, geni_status:0x%x, geni_ios:0x%x\n",
-			     m_cmd, geni_s, geni_ios);
+	GENI_SE_DBG(gi2c->ipcl, false, gi2c->dev, "%s: se-mode:%d\n", __func__,
+							gi2c->se_mode);
+	geni_se_dump_dbg_regs(&gi2c->i2c_rsc, gi2c->base, gi2c->ipcl);
 err_ret:
 	gi2c->err = gi2c_log[err].err;
 }
@@ -469,8 +448,8 @@
 		int stretch = (i < (num - 1));
 		dma_cookie_t tx_cookie, rx_cookie;
 		struct msm_gpi_tre *go_t = &gi2c->go_t;
-		struct device *rx_dev = gi2c->rx_c->device->dev;
-		struct device *tx_dev = gi2c->tx_c->device->dev;
+		struct device *rx_dev = gi2c->wrapper_dev;
+		struct device *tx_dev = gi2c->wrapper_dev;
 
 		gi2c->cur = &msgs[i];
 		if (!gi2c->cfg_sent) {
@@ -501,9 +480,8 @@
 
 		if (msgs[i].flags & I2C_M_RD) {
 			sg_init_table(&gi2c->rx_sg, 1);
-			gi2c->rx_ph = dma_map_single(rx_dev, msgs[i].buf,
-						     msgs[i].len,
-						     DMA_FROM_DEVICE);
+			geni_se_iommu_map_buf(rx_dev, &gi2c->rx_ph, msgs[i].buf,
+						msgs[i].len, DMA_FROM_DEVICE);
 			gi2c->rx_t.dword[0] =
 				MSM_GPI_DMA_W_BUFFER_TRE_DWORD0(gi2c->rx_ph);
 			gi2c->rx_t.dword[1] =
@@ -533,9 +511,8 @@
 			rx_cookie = dmaengine_submit(gi2c->rx_desc);
 			dma_async_issue_pending(gi2c->rx_c);
 		} else {
-			gi2c->tx_ph = dma_map_single(tx_dev, msgs[i].buf,
-						     msgs[i].len,
-						     DMA_TO_DEVICE);
+			geni_se_iommu_map_buf(tx_dev, &gi2c->tx_ph, msgs[i].buf,
+						msgs[i].len, DMA_TO_DEVICE);
 			gi2c->tx_t.dword[0] =
 				MSM_GPI_DMA_W_BUFFER_TRE_DWORD0(gi2c->tx_ph);
 			gi2c->tx_t.dword[1] =
@@ -568,11 +545,11 @@
 
 		timeout = wait_for_completion_timeout(&gi2c->xfer, HZ);
 		if (msgs[i].flags & I2C_M_RD)
-			dma_unmap_single(rx_dev, gi2c->rx_ph, msgs[i].len,
-					 DMA_FROM_DEVICE);
+			geni_se_iommu_unmap_buf(rx_dev, &gi2c->rx_ph,
+				msgs[i].len, DMA_FROM_DEVICE);
 		else
-			dma_unmap_single(tx_dev, gi2c->tx_ph, msgs[i].len,
-					 DMA_TO_DEVICE);
+			geni_se_iommu_unmap_buf(tx_dev, &gi2c->tx_ph,
+				msgs[i].len, DMA_TO_DEVICE);
 
 		if (!timeout) {
 			GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev,
@@ -933,8 +910,23 @@
 
 static int geni_i2c_suspend_noirq(struct device *device)
 {
-	if (!pm_runtime_status_suspended(device))
+	struct geni_i2c_dev *gi2c = dev_get_drvdata(device);
+	int ret;
+
+	/* Make sure no transactions are pending */
+	ret = i2c_trylock_bus(&gi2c->adap, I2C_LOCK_SEGMENT);
+	if (!ret) {
+		GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev,
+				"late I2C transaction request\n");
 		return -EBUSY;
+	}
+	if (!pm_runtime_status_suspended(device)) {
+		geni_i2c_runtime_suspend(device);
+		pm_runtime_disable(device);
+		pm_runtime_set_suspended(device);
+		pm_runtime_enable(device);
+	}
+	i2c_unlock_bus(&gi2c->adap, I2C_LOCK_SEGMENT);
 	return 0;
 }
 #else
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 59b380d..c388882 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -193,7 +193,6 @@
 	struct regmap *regmap;
 	int irq;
 	struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
-	atomic_t active_intr;
 	struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
 	struct mutex mutex;
 	u8 fifo_mode, watermark;
@@ -493,11 +492,6 @@
 		goto out_fix_power_state;
 	}
 
-	if (state)
-		atomic_inc(&data->active_intr);
-	else
-		atomic_dec(&data->active_intr);
-
 	return 0;
 
 out_fix_power_state:
@@ -1709,8 +1703,7 @@
 	struct bmc150_accel_data *data = iio_priv(indio_dev);
 
 	mutex_lock(&data->mutex);
-	if (atomic_read(&data->active_intr))
-		bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
+	bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
 	bmc150_accel_fifo_set_mode(data);
 	mutex_unlock(&data->mutex);
 
diff --git a/drivers/iio/adc/qcom-rradc.c b/drivers/iio/adc/qcom-rradc.c
index b055ff6..02dfbf8 100644
--- a/drivers/iio/adc/qcom-rradc.c
+++ b/drivers/iio/adc/qcom-rradc.c
@@ -22,6 +22,7 @@
 #include <linux/regmap.h>
 #include <linux/delay.h>
 #include <linux/qpnp/qpnp-revid.h>
+#include <linux/power_supply.h>
 
 #define FG_ADC_RR_EN_CTL			0x46
 #define FG_ADC_RR_SKIN_TEMP_LSB			0x50
@@ -180,6 +181,9 @@
 #define FG_ADC_RR_VOLT_INPUT_FACTOR		8
 #define FG_ADC_RR_CURR_INPUT_FACTOR		2000
 #define FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL	1886
+#define FG_ADC_RR_CURR_USBIN_660_FACTOR_MIL	9
+#define FG_ADC_RR_CURR_USBIN_660_UV_VAL	579500
+
 #define FG_ADC_SCALE_MILLI_FACTOR		1000
 #define FG_ADC_KELVINMIL_CELSIUSMIL		273150
 
@@ -189,9 +193,11 @@
 #define FG_RR_ADC_STS_CHANNEL_READING_MASK	0x3
 #define FG_RR_ADC_STS_CHANNEL_STS		0x2
 
-#define FG_RR_CONV_CONTINUOUS_TIME_MIN_US	50000
-#define FG_RR_CONV_CONTINUOUS_TIME_MAX_US	51000
+#define FG_RR_CONV_CONTINUOUS_TIME_MIN_MS	50
 #define FG_RR_CONV_MAX_RETRY_CNT		50
+#define FG_RR_TP_REV_VERSION1		21
+#define FG_RR_TP_REV_VERSION2		29
+#define FG_RR_TP_REV_VERSION3		32
 
 /*
  * The channel number is not a physical index in hardware,
@@ -228,6 +234,8 @@
 	struct rradc_chan_prop		*chan_props;
 	struct device_node		*revid_dev_node;
 	struct pmic_revid_data		*pmic_fab_id;
+	int volt;
+	struct power_supply		*usb_trig;
 };
 
 struct rradc_channels {
@@ -353,7 +361,7 @@
 	return 0;
 }
 
-static int rradc_post_process_curr(struct rradc_chip *chip,
+static int rradc_post_process_usbin_curr(struct rradc_chip *chip,
 			struct rradc_chan_prop *prop, u16 adc_code,
 			int *result_ua)
 {
@@ -361,11 +369,33 @@
 
 	if (!prop)
 		return -EINVAL;
-
-	if (prop->channel == RR_ADC_USBIN_I)
-		scale = FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL;
-	else
-		scale = FG_ADC_RR_CURR_INPUT_FACTOR;
+	if (chip->revid_dev_node) {
+		switch (chip->pmic_fab_id->pmic_subtype) {
+		case PM660_SUBTYPE:
+			if (((chip->pmic_fab_id->tp_rev
+				>= FG_RR_TP_REV_VERSION1)
+			&& (chip->pmic_fab_id->tp_rev
+				<= FG_RR_TP_REV_VERSION2))
+			|| (chip->pmic_fab_id->tp_rev
+				>= FG_RR_TP_REV_VERSION3)) {
+				chip->volt = div64_s64(chip->volt, 1000);
+				chip->volt = chip->volt *
+					FG_ADC_RR_CURR_USBIN_660_FACTOR_MIL;
+				chip->volt = FG_ADC_RR_CURR_USBIN_660_UV_VAL -
+					(chip->volt);
+				chip->volt = div64_s64(1000000000, chip->volt);
+				scale = chip->volt;
+			} else
+				scale = FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL;
+			break;
+		case PMI8998_SUBTYPE:
+			scale = FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL;
+			break;
+		default:
+			pr_err("No PMIC subtype found\n");
+			return -EINVAL;
+		}
+	}
 
 	/* scale * V/A; 2.5V ADC full scale */
 	ua = ((int64_t)adc_code * scale);
@@ -376,6 +406,24 @@
 	return 0;
 }
 
+static int rradc_post_process_dcin_curr(struct rradc_chip *chip,
+			struct rradc_chan_prop *prop, u16 adc_code,
+			int *result_ua)
+{
+	int64_t ua = 0;
+
+	if (!prop)
+		return -EINVAL;
+
+	/* 0.5 V/A; 2.5V ADC full scale */
+	ua = ((int64_t)adc_code * FG_ADC_RR_CURR_INPUT_FACTOR);
+	ua *= (FG_ADC_RR_FS_VOLTAGE_MV * FG_ADC_SCALE_MILLI_FACTOR);
+	ua = div64_s64(ua, (FG_MAX_ADC_READINGS * 1000));
+	*result_ua = ua;
+
+	return 0;
+}
+
 static int rradc_post_process_die_temp(struct rradc_chip *chip,
 			struct rradc_chan_prop *prop, u16 adc_code,
 			int *result_millidegc)
@@ -591,13 +639,13 @@
 			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_PROCESSED),
 			FG_ADC_RR_SKIN_TEMP_LSB, FG_ADC_RR_SKIN_TEMP_MSB,
 			FG_ADC_RR_AUX_THERM_STS)
-	RR_ADC_CHAN_CURRENT("usbin_i", &rradc_post_process_curr,
+	RR_ADC_CHAN_CURRENT("usbin_i", &rradc_post_process_usbin_curr,
 			FG_ADC_RR_USB_IN_I_LSB, FG_ADC_RR_USB_IN_I_MSB,
 			FG_ADC_RR_USB_IN_I_STS)
 	RR_ADC_CHAN_VOLT("usbin_v", &rradc_post_process_volt,
 			FG_ADC_RR_USB_IN_V_LSB, FG_ADC_RR_USB_IN_V_MSB,
 			FG_ADC_RR_USB_IN_V_STS)
-	RR_ADC_CHAN_CURRENT("dcin_i", &rradc_post_process_curr,
+	RR_ADC_CHAN_CURRENT("dcin_i", &rradc_post_process_dcin_curr,
 			FG_ADC_RR_DC_IN_I_LSB, FG_ADC_RR_DC_IN_I_MSB,
 			FG_ADC_RR_DC_IN_I_STS)
 	RR_ADC_CHAN_VOLT("dcin_v", &rradc_post_process_volt,
@@ -679,6 +727,24 @@
 	return rc;
 }
 
+static bool rradc_is_usb_present(struct rradc_chip *chip)
+{
+	union power_supply_propval pval;
+	int rc;
+	bool usb_present = false;
+
+	if (!chip->usb_trig) {
+		pr_debug("USB property not present\n");
+		return usb_present;
+	}
+
+	rc = power_supply_get_property(chip->usb_trig,
+			POWER_SUPPLY_PROP_PRESENT, &pval);
+	usb_present = (rc < 0) ? 0 : pval.intval;
+
+	return usb_present;
+}
+
 static int rradc_check_status_ready_with_retry(struct rradc_chip *chip,
 		struct rradc_chan_prop *prop, u8 *buf, u16 status)
 {
@@ -698,8 +764,18 @@
 			(retry_cnt < FG_RR_CONV_MAX_RETRY_CNT)) {
 		pr_debug("%s is not ready; nothing to read:0x%x\n",
 			rradc_chans[prop->channel].datasheet_name, buf[0]);
-		usleep_range(FG_RR_CONV_CONTINUOUS_TIME_MIN_US,
-				FG_RR_CONV_CONTINUOUS_TIME_MAX_US);
+
+		if (((prop->channel == RR_ADC_CHG_TEMP) ||
+			(prop->channel == RR_ADC_SKIN_TEMP) ||
+			(prop->channel == RR_ADC_USBIN_I) ||
+			(prop->channel == RR_ADC_DIE_TEMP)) &&
+					((!rradc_is_usb_present(chip)))) {
+			pr_debug("USB not present for %d\n", prop->channel);
+			rc = -ENODATA;
+			break;
+		}
+
+		msleep(FG_RR_CONV_CONTINUOUS_TIME_MIN_MS);
 		retry_cnt++;
 		rc = rradc_read(chip, status, buf, 1);
 		if (rc < 0) {
@@ -717,7 +793,7 @@
 static int rradc_read_channel_with_continuous_mode(struct rradc_chip *chip,
 			struct rradc_chan_prop *prop, u8 *buf)
 {
-	int rc = 0;
+	int rc = 0, ret = 0;
 	u16 status = 0;
 
 	rc = rradc_enable_continuous_mode(chip);
@@ -730,23 +806,25 @@
 	rc = rradc_read(chip, status, buf, 1);
 	if (rc < 0) {
 		pr_err("status read failed:%d\n", rc);
-		return rc;
+		ret = rc;
+		goto disable;
 	}
 
 	rc = rradc_check_status_ready_with_retry(chip, prop,
 						buf, status);
 	if (rc < 0) {
 		pr_err("Status read failed:%d\n", rc);
-		return rc;
+		ret = rc;
 	}
 
+disable:
 	rc = rradc_disable_continuous_mode(chip);
 	if (rc < 0) {
 		pr_err("Failed to switch to non continuous mode\n");
-		return rc;
+		ret = rc;
 	}
 
-	return rc;
+	return ret;
 }
 
 static int rradc_enable_batt_id_channel(struct rradc_chip *chip, bool enable)
@@ -955,6 +1033,21 @@
 
 	switch (mask) {
 	case IIO_CHAN_INFO_PROCESSED:
+		if (((chip->pmic_fab_id->tp_rev
+				>= FG_RR_TP_REV_VERSION1)
+		&& (chip->pmic_fab_id->tp_rev
+				<= FG_RR_TP_REV_VERSION2))
+		|| (chip->pmic_fab_id->tp_rev
+				>= FG_RR_TP_REV_VERSION3)) {
+			if (chan->address == RR_ADC_USBIN_I) {
+				prop = &chip->chan_props[RR_ADC_USBIN_V];
+				rc = rradc_do_conversion(chip, prop, &adc_code);
+				if (rc)
+					break;
+				prop->scale(chip, prop, adc_code, &chip->volt);
+			}
+		}
+
 		prop = &chip->chan_props[chan->address];
 		rc = rradc_do_conversion(chip, prop, &adc_code);
 		if (rc)
@@ -1090,6 +1183,10 @@
 	indio_dev->channels = chip->iio_chans;
 	indio_dev->num_channels = chip->nchannels;
 
+	chip->usb_trig = power_supply_get_by_name("usb");
+	if (!chip->usb_trig)
+		pr_debug("Error obtaining usb power supply\n");
+
 	return devm_iio_device_register(dev, indio_dev);
 }
 
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index cde6f13..472641f 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -80,18 +80,12 @@
 	8, 16, 32, 64, 128, 250, 475, 860
 };
 
-static const struct {
-	int scale;
-	int uscale;
-} ads1015_scale[] = {
-	{3, 0},
-	{2, 0},
-	{1, 0},
-	{0, 500000},
-	{0, 250000},
-	{0, 125000},
-	{0, 125000},
-	{0, 125000},
+/*
+ * Translation from PGA bits to full-scale positive and negative input voltage
+ * range in mV
+ */
+static int ads1015_fullscale_range[] = {
+	6144, 4096, 2048, 1024, 512, 256, 256, 256
 };
 
 #define ADS1015_V_CHAN(_chan, _addr) {				\
@@ -182,6 +176,12 @@
 	struct ads1015_channel_data channel_data[ADS1015_CHANNELS];
 
 	unsigned int *data_rate;
+	/*
+	 * Set to true when the ADC is switched to the continuous-conversion
+	 * mode and exits from a power-down state.  This flag is used to avoid
+	 * getting the stale result from the conversion register.
+	 */
+	bool conv_invalid;
 };
 
 static bool ads1015_is_writeable_reg(struct device *dev, unsigned int reg)
@@ -234,33 +234,43 @@
 		ret = pm_runtime_put_autosuspend(dev);
 	}
 
-	return ret;
+	return ret < 0 ? ret : 0;
 }
 
 static
 int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
 {
 	int ret, pga, dr, conv_time;
-	bool change;
+	unsigned int old, mask, cfg;
 
 	if (chan < 0 || chan >= ADS1015_CHANNELS)
 		return -EINVAL;
 
-	pga = data->channel_data[chan].pga;
-	dr = data->channel_data[chan].data_rate;
-
-	ret = regmap_update_bits_check(data->regmap, ADS1015_CFG_REG,
-				       ADS1015_CFG_MUX_MASK |
-				       ADS1015_CFG_PGA_MASK,
-				       chan << ADS1015_CFG_MUX_SHIFT |
-				       pga << ADS1015_CFG_PGA_SHIFT,
-				       &change);
-	if (ret < 0)
+	ret = regmap_read(data->regmap, ADS1015_CFG_REG, &old);
+	if (ret)
 		return ret;
 
-	if (change) {
-		conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]);
+	pga = data->channel_data[chan].pga;
+	dr = data->channel_data[chan].data_rate;
+	mask = ADS1015_CFG_MUX_MASK | ADS1015_CFG_PGA_MASK |
+		ADS1015_CFG_DR_MASK;
+	cfg = chan << ADS1015_CFG_MUX_SHIFT | pga << ADS1015_CFG_PGA_SHIFT |
+		dr << ADS1015_CFG_DR_SHIFT;
+
+	cfg = (old & ~mask) | (cfg & mask);
+
+	ret = regmap_write(data->regmap, ADS1015_CFG_REG, cfg);
+	if (ret)
+		return ret;
+
+	if (old != cfg || data->conv_invalid) {
+		int dr_old = (old & ADS1015_CFG_DR_MASK) >>
+				ADS1015_CFG_DR_SHIFT;
+
+		conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]);
+		conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]);
 		usleep_range(conv_time, conv_time + 1);
+		data->conv_invalid = false;
 	}
 
 	return regmap_read(data->regmap, ADS1015_CONV_REG, val);
@@ -297,17 +307,20 @@
 	return IRQ_HANDLED;
 }
 
-static int ads1015_set_scale(struct ads1015_data *data, int chan,
+static int ads1015_set_scale(struct ads1015_data *data,
+			     struct iio_chan_spec const *chan,
 			     int scale, int uscale)
 {
 	int i, ret, rindex = -1;
+	int fullscale = div_s64((scale * 1000000LL + uscale) <<
+				(chan->scan_type.realbits - 1), 1000000);
 
-	for (i = 0; i < ARRAY_SIZE(ads1015_scale); i++)
-		if (ads1015_scale[i].scale == scale &&
-		    ads1015_scale[i].uscale == uscale) {
+	for (i = 0; i < ARRAY_SIZE(ads1015_fullscale_range); i++) {
+		if (ads1015_fullscale_range[i] == fullscale) {
 			rindex = i;
 			break;
 		}
+	}
 	if (rindex < 0)
 		return -EINVAL;
 
@@ -317,32 +330,23 @@
 	if (ret < 0)
 		return ret;
 
-	data->channel_data[chan].pga = rindex;
+	data->channel_data[chan->address].pga = rindex;
 
 	return 0;
 }
 
 static int ads1015_set_data_rate(struct ads1015_data *data, int chan, int rate)
 {
-	int i, ret, rindex = -1;
+	int i;
 
-	for (i = 0; i < ARRAY_SIZE(ads1015_data_rate); i++)
+	for (i = 0; i < ARRAY_SIZE(ads1015_data_rate); i++) {
 		if (data->data_rate[i] == rate) {
-			rindex = i;
-			break;
+			data->channel_data[chan].data_rate = i;
+			return 0;
 		}
-	if (rindex < 0)
-		return -EINVAL;
+	}
 
-	ret = regmap_update_bits(data->regmap, ADS1015_CFG_REG,
-				 ADS1015_CFG_DR_MASK,
-				 rindex << ADS1015_CFG_DR_SHIFT);
-	if (ret < 0)
-		return ret;
-
-	data->channel_data[chan].data_rate = rindex;
-
-	return 0;
+	return -EINVAL;
 }
 
 static int ads1015_read_raw(struct iio_dev *indio_dev,
@@ -384,9 +388,9 @@
 	}
 	case IIO_CHAN_INFO_SCALE:
 		idx = data->channel_data[chan->address].pga;
-		*val = ads1015_scale[idx].scale;
-		*val2 = ads1015_scale[idx].uscale;
-		ret = IIO_VAL_INT_PLUS_MICRO;
+		*val = ads1015_fullscale_range[idx];
+		*val2 = chan->scan_type.realbits - 1;
+		ret = IIO_VAL_FRACTIONAL_LOG2;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		idx = data->channel_data[chan->address].data_rate;
@@ -413,7 +417,7 @@
 	mutex_lock(&data->lock);
 	switch (mask) {
 	case IIO_CHAN_INFO_SCALE:
-		ret = ads1015_set_scale(data, chan->address, val, val2);
+		ret = ads1015_set_scale(data, chan, val, val2);
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		ret = ads1015_set_data_rate(data, chan->address, val);
@@ -445,7 +449,10 @@
 	.validate_scan_mask = &iio_validate_scan_mask_onehot,
 };
 
-static IIO_CONST_ATTR(scale_available, "3 2 1 0.5 0.25 0.125");
+static IIO_CONST_ATTR_NAMED(ads1015_scale_available, scale_available,
+	"3 2 1 0.5 0.25 0.125");
+static IIO_CONST_ATTR_NAMED(ads1115_scale_available, scale_available,
+	"0.1875 0.125 0.0625 0.03125 0.015625 0.007813");
 
 static IIO_CONST_ATTR_NAMED(ads1015_sampling_frequency_available,
 	sampling_frequency_available, "128 250 490 920 1600 2400 3300");
@@ -453,7 +460,7 @@
 	sampling_frequency_available, "8 16 32 64 128 250 475 860");
 
 static struct attribute *ads1015_attributes[] = {
-	&iio_const_attr_scale_available.dev_attr.attr,
+	&iio_const_attr_ads1015_scale_available.dev_attr.attr,
 	&iio_const_attr_ads1015_sampling_frequency_available.dev_attr.attr,
 	NULL,
 };
@@ -463,7 +470,7 @@
 };
 
 static struct attribute *ads1115_attributes[] = {
-	&iio_const_attr_scale_available.dev_attr.attr,
+	&iio_const_attr_ads1115_scale_available.dev_attr.attr,
 	&iio_const_attr_ads1115_sampling_frequency_available.dev_attr.attr,
 	NULL,
 };
@@ -624,6 +631,15 @@
 		dev_err(&client->dev, "iio triggered buffer setup failed\n");
 		return ret;
 	}
+
+	ret = regmap_update_bits(data->regmap, ADS1015_CFG_REG,
+				ADS1015_CFG_MOD_MASK,
+				ADS1015_CONTINUOUS << ADS1015_CFG_MOD_SHIFT);
+	if (ret)
+		return ret;
+
+	data->conv_invalid = true;
+
 	ret = pm_runtime_set_active(&client->dev);
 	if (ret)
 		goto err_buffer_cleanup;
@@ -679,10 +695,15 @@
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct ads1015_data *data = iio_priv(indio_dev);
+	int ret;
 
-	return regmap_update_bits(data->regmap, ADS1015_CFG_REG,
+	ret = regmap_update_bits(data->regmap, ADS1015_CFG_REG,
 				  ADS1015_CFG_MOD_MASK,
 				  ADS1015_CONTINUOUS << ADS1015_CFG_MOD_SHIFT);
+	if (!ret)
+		data->conv_invalid = true;
+
+	return ret;
 }
 #endif
 
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 228a003..d1bde6d 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -77,7 +77,7 @@
 #define VF610_ADC_ADSTS_MASK		0x300
 #define VF610_ADC_ADLPC_EN		0x80
 #define VF610_ADC_ADHSC_EN		0x400
-#define VF610_ADC_REFSEL_VALT		0x100
+#define VF610_ADC_REFSEL_VALT		0x800
 #define VF610_ADC_REFSEL_VBG		0x1000
 #define VF610_ADC_ADTRG_HARD		0x2000
 #define VF610_ADC_AVGS_8		0x4000
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 6082934..b60e5d8 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -36,8 +36,6 @@
 	s32 poll_value = 0;
 
 	if (state) {
-		if (!atomic_read(&st->user_requested_state))
-			return 0;
 		if (sensor_hub_device_open(st->hsdev))
 			return -EIO;
 
@@ -86,6 +84,9 @@
 				       &report_val);
 	}
 
+	pr_debug("HID_SENSOR %s set power_state %d report_state %d\n",
+		 st->pdev->name, state_val, report_val);
+
 	sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
 			       st->power_state.index,
 			       sizeof(state_val), &state_val);
@@ -107,6 +108,7 @@
 		ret = pm_runtime_get_sync(&st->pdev->dev);
 	else {
 		pm_runtime_mark_last_busy(&st->pdev->dev);
+		pm_runtime_use_autosuspend(&st->pdev->dev);
 		ret = pm_runtime_put_autosuspend(&st->pdev->dev);
 	}
 	if (ret < 0) {
@@ -201,8 +203,6 @@
 	/* Default to 3 seconds, but can be changed from sysfs */
 	pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
 					 3000);
-	pm_runtime_use_autosuspend(&attrb->pdev->dev);
-
 	return ret;
 error_unreg_trigger:
 	iio_trigger_unregister(trig);
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 8cf84d3..1289842 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -696,7 +696,7 @@
 		.gyro_max_val = IIO_RAD_TO_DEGREE(22500),
 		.gyro_max_scale = 450,
 		.accel_max_val = IIO_M_S_2_TO_G(12500),
-		.accel_max_scale = 5,
+		.accel_max_scale = 10,
 	},
 	[ADIS16485] = {
 		.channels = adis16485_channels,
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 04598ae..f0d3f74 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -626,7 +626,7 @@
 	struct tsl2563_chip *chip = iio_priv(dev_info);
 
 	iio_push_event(dev_info,
-		       IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
+		       IIO_UNMOD_EVENT_CODE(IIO_INTENSITY,
 					    0,
 					    IIO_EV_TYPE_THRESH,
 					    IIO_EV_DIR_EITHER),
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 01e3a37..d118ffe 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2342,8 +2342,9 @@
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	if (cmd.port_num < rdma_start_port(ib_dev) ||
-	    cmd.port_num > rdma_end_port(ib_dev))
+	if ((cmd.attr_mask & IB_QP_PORT) &&
+	    (cmd.port_num < rdma_start_port(ib_dev) ||
+	     cmd.port_num > rdma_end_port(ib_dev)))
 		return -EINVAL;
 
 	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index f1510cc..9398143 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1804,20 +1804,21 @@
 	skb_trim(skb, dlen);
 	mutex_lock(&ep->com.mutex);
 
-	/* update RX credits */
-	update_rx_credits(ep, dlen);
-
 	switch (ep->com.state) {
 	case MPA_REQ_SENT:
+		update_rx_credits(ep, dlen);
 		ep->rcv_seq += dlen;
 		disconnect = process_mpa_reply(ep, skb);
 		break;
 	case MPA_REQ_WAIT:
+		update_rx_credits(ep, dlen);
 		ep->rcv_seq += dlen;
 		disconnect = process_mpa_request(ep, skb);
 		break;
 	case FPDU_MODE: {
 		struct c4iw_qp_attributes attrs;
+
+		update_rx_credits(ep, dlen);
 		BUG_ON(!ep->com.qp);
 		if (status)
 			pr_err("%s Unexpected streaming data." \
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f2a885e..8059b7e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1680,9 +1680,19 @@
 		size += ret;
 	}
 
+	if (mlx4_is_master(mdev->dev) && flow_type == MLX4_FS_REGULAR &&
+	    flow_attr->num_of_specs == 1) {
+		struct _rule_hw *rule_header = (struct _rule_hw *)(ctrl + 1);
+		enum ib_flow_spec_type header_spec =
+			((union ib_flow_spec *)(flow_attr + 1))->type;
+
+		if (header_spec == IB_FLOW_SPEC_ETH)
+			mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
+	}
+
 	ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
 			   MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
-			   MLX4_CMD_WRAPPED);
+			   MLX4_CMD_NATIVE);
 	if (ret == -ENOMEM)
 		pr_err("mcg table is full. Fail to register network rule.\n");
 	else if (ret == -ENXIO)
@@ -1699,7 +1709,7 @@
 	int err;
 	err = mlx4_cmd(dev, reg_id, 0, 0,
 		       MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
-		       MLX4_CMD_WRAPPED);
+		       MLX4_CMD_NATIVE);
 	if (err)
 		pr_err("Fail to detach network rule. registration id = 0x%llx\n",
 		       reg_id);
diff --git a/drivers/input/misc/hbtp_input.c b/drivers/input/misc/hbtp_input.c
index 7a6f50b..66d1499 100644
--- a/drivers/input/misc/hbtp_input.c
+++ b/drivers/input/misc/hbtp_input.c
@@ -92,6 +92,7 @@
 	struct kobject *sysfs_kobject;
 	s16 ROI[MAX_ROI_SIZE];
 	s16 accelBuffer[MAX_ACCEL_SIZE];
+	u32 display_status;
 };
 
 static struct hbtp_data *hbtp;
@@ -1425,10 +1426,11 @@
 	if (ret) {
 		pr_err("hbtp: ret error: %zd\n", ret);
 		mutex_unlock(&hbtp->mutex);
-		return ret;
+		return 0;
 	}
-	if (!hbtp || !hbtp->input_dev) {
-		pr_err("hbtp: hbtp or hbtp->input_dev not ready!\n");
+	hbtp->display_status = status;
+	if (!hbtp->input_dev) {
+		pr_err("hbtp: hbtp->input_dev not ready!\n");
 		mutex_unlock(&hbtp->mutex);
 		return ret;
 	}
@@ -1445,8 +1447,20 @@
 	return count;
 }
 
+static ssize_t hbtp_display_pwr_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	ssize_t ret = 0;
+
+	mutex_lock(&hbtp->mutex);
+	ret = snprintf(buf, PAGE_SIZE, "%u\n", hbtp->display_status);
+	mutex_unlock(&hbtp->mutex);
+	return ret;
+}
+
 static struct kobj_attribute hbtp_display_attribute =
-		__ATTR(display_pwr, 0660, NULL, hbtp_display_pwr_store);
+		__ATTR(display_pwr, 0660, hbtp_display_pwr_show,
+			hbtp_display_pwr_store);
 
 static int __init hbtp_init(void)
 {
@@ -1463,6 +1477,7 @@
 
 	mutex_init(&hbtp->mutex);
 	mutex_init(&hbtp->sensormutex);
+	hbtp->display_status = 1;
 
 	error = misc_register(&hbtp_input_misc);
 	if (error) {
@@ -1545,6 +1560,8 @@
 	sysfs_remove_bin_file(sensor_kobject, &vibdata_attr);
 	sysfs_remove_bin_file(sensor_kobject, &capdata_attr);
 	kobject_put(sensor_kobject);
+	sysfs_remove_file(hbtp->sysfs_kobject, &hbtp_display_attribute.attr);
+	kobject_put(hbtp->sysfs_kobject);
 	misc_deregister(&hbtp_input_misc);
 	if (hbtp->input_dev)
 		input_unregister_device(hbtp->input_dev);
diff --git a/drivers/input/misc/keychord.c b/drivers/input/misc/keychord.c
index c5ab3dd..fdcc146 100644
--- a/drivers/input/misc/keychord.c
+++ b/drivers/input/misc/keychord.c
@@ -60,6 +60,10 @@
 	unsigned char		head;
 	unsigned char		tail;
 	__u16			buff[BUFFER_SIZE];
+	/* Bit to serialize writes to this device */
+#define KEYCHORD_BUSY			0x01
+	unsigned long		flags;
+	wait_queue_head_t	write_waitq;
 };
 
 static int check_keychord(struct keychord_device *kdev,
@@ -172,7 +176,6 @@
 		goto err_input_open_device;
 
 	pr_info("keychord: using input dev %s for fevent\n", dev->name);
-
 	return 0;
 
 err_input_open_device:
@@ -225,6 +228,41 @@
 }
 
 /*
+ * serializes writes on a device. can use mutex_lock_interruptible()
+ * for this particular use case as well - a matter of preference.
+ */
+static int
+keychord_write_lock(struct keychord_device *kdev)
+{
+	int ret;
+	unsigned long flags;
+
+	spin_lock_irqsave(&kdev->lock, flags);
+	while (kdev->flags & KEYCHORD_BUSY) {
+		spin_unlock_irqrestore(&kdev->lock, flags);
+		ret = wait_event_interruptible(kdev->write_waitq,
+			       ((kdev->flags & KEYCHORD_BUSY) == 0));
+		if (ret)
+			return ret;
+		spin_lock_irqsave(&kdev->lock, flags);
+	}
+	kdev->flags |= KEYCHORD_BUSY;
+	spin_unlock_irqrestore(&kdev->lock, flags);
+	return 0;
+}
+
+static void
+keychord_write_unlock(struct keychord_device *kdev)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&kdev->lock, flags);
+	kdev->flags &= ~KEYCHORD_BUSY;
+	spin_unlock_irqrestore(&kdev->lock, flags);
+	wake_up_interruptible(&kdev->write_waitq);
+}
+
+/*
  * keychord_write is used to configure the driver
  */
 static ssize_t keychord_write(struct file *file, const char __user *buffer,
@@ -250,6 +288,22 @@
 		return -EFAULT;
 	}
 
+	/*
+	 * Serialize writes to this device to prevent various races.
+	 * 1) writers racing here could do duplicate input_unregister_handler()
+	 *    calls, resulting in attempting to unlink a node from a list that
+	 *    does not exist.
+	 * 2) writers racing here could do duplicate input_register_handler() calls
+	 *    below, resulting in a duplicate insertion of a node into the list.
+	 * 3) a double kfree of keychords can occur (in the event that
+	 *    input_register_handler() fails below.
+	 */
+	ret = keychord_write_lock(kdev);
+	if (ret) {
+		kfree(keychords);
+		return ret;
+	}
+
 	/* unregister handler before changing configuration */
 	if (kdev->registered) {
 		input_unregister_handler(&kdev->input_handler);
@@ -318,15 +372,19 @@
 	if (ret) {
 		kfree(keychords);
 		kdev->keychords = 0;
+		keychord_write_unlock(kdev);
 		return ret;
 	}
 	kdev->registered = 1;
 
+	keychord_write_unlock(kdev);
+
 	return count;
 
 err_unlock_return:
 	spin_unlock_irqrestore(&kdev->lock, flags);
 	kfree(keychords);
+	keychord_write_unlock(kdev);
 	return -EINVAL;
 }
 
@@ -352,6 +410,7 @@
 
 	spin_lock_init(&kdev->lock);
 	init_waitqueue_head(&kdev->waitq);
+	init_waitqueue_head(&kdev->write_waitq);
 
 	kdev->input_handler.event = keychord_event;
 	kdev->input_handler.connect = keychord_connect;
@@ -373,6 +432,7 @@
 
 	if (kdev->registered)
 		input_unregister_handler(&kdev->input_handler);
+	kfree(kdev->keychords);
 	kfree(kdev);
 
 	return 0;
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 518e8a7..f26807c 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -1212,14 +1212,24 @@
 
 	case SS4_PACKET_ID_TWO:
 		if (priv->flags & ALPS_BUTTONPAD) {
-			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+			if (IS_SS4PLUS_DEV(priv->dev_id)) {
+				f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+			} else {
+				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
+			}
 			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
-			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
 			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
 		} else {
-			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+			if (IS_SS4PLUS_DEV(priv->dev_id)) {
+				f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+			} else {
+				f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+			}
 			f->mt[0].y = SS4_STD_MF_Y_V2(p, 0);
-			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
 			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
 		}
 		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
@@ -1236,16 +1246,27 @@
 
 	case SS4_PACKET_ID_MULTI:
 		if (priv->flags & ALPS_BUTTONPAD) {
-			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+			if (IS_SS4PLUS_DEV(priv->dev_id)) {
+				f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+			} else {
+				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
+			}
+
 			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
-			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
 			f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1);
 			no_data_x = SS4_MFPACKET_NO_AX_BL;
 			no_data_y = SS4_MFPACKET_NO_AY_BL;
 		} else {
-			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
+			if (IS_SS4PLUS_DEV(priv->dev_id)) {
+				f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+			} else {
+				f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+			}
 			f->mt[2].y = SS4_STD_MF_Y_V2(p, 0);
-			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
 			f->mt[3].y = SS4_STD_MF_Y_V2(p, 1);
 			no_data_x = SS4_MFPACKET_NO_AX;
 			no_data_y = SS4_MFPACKET_NO_AY;
@@ -2535,8 +2556,8 @@
 
 	memset(otp, 0, sizeof(otp));
 
-	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
-	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
+	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
+	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
 		return -1;
 
 	alps_update_device_area_ss4_v2(otp, priv);
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index dbfd260..7931237 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -91,6 +91,10 @@
 				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
 				)
 
+#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
+				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
+				)
+
 #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
 				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
 				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
@@ -100,6 +104,10 @@
 				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
 				)
 
+#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
+				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
+				)
+
 #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
 				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
 				)
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index da5458d..681dce1 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1234,7 +1234,12 @@
 	{ "ELAN0000", 0 },
 	{ "ELAN0100", 0 },
 	{ "ELAN0600", 0 },
+	{ "ELAN0602", 0 },
 	{ "ELAN0605", 0 },
+	{ "ELAN0608", 0 },
+	{ "ELAN0605", 0 },
+	{ "ELAN0609", 0 },
+	{ "ELAN060B", 0 },
 	{ "ELAN1000", 0 },
 	{ }
 };
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 354d47e..7e2dc5e 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -265,7 +265,8 @@
 	if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
 		return -1;
 
-	if (param[0] != TP_MAGIC_IDENT)
+	/* add new TP ID. */
+	if (!(param[0] & TP_MAGIC_IDENT))
 		return -1;
 
 	if (firmware_id)
@@ -380,8 +381,8 @@
 		return 0;
 
 	if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
-		psmouse_warn(psmouse, "failed to get extended button data\n");
-		button_info = 0;
+		psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
+		button_info = 0x33;
 	}
 
 	psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
index 5617ed3..8805575 100644
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -21,8 +21,9 @@
 #define TP_COMMAND		0xE2	/* Commands start with this */
 
 #define TP_READ_ID		0xE1	/* Sent for device identification */
-#define TP_MAGIC_IDENT		0x01	/* Sent after a TP_READ_ID followed */
+#define TP_MAGIC_IDENT		0x03	/* Sent after a TP_READ_ID followed */
 					/* by the firmware ID */
+					/* Firmware ID includes 0x1, 0x2, 0x3 */
 
 
 /*
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 41800b6..c380b7e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -4294,6 +4294,7 @@
 		/* Setting */
 		irte->hi.fields.ga_root_ptr = (pi_data->base >> 12);
 		irte->hi.fields.vector = vcpu_pi_info->vector;
+		irte->lo.fields_vapic.ga_log_intr = 1;
 		irte->lo.fields_vapic.guest_mode = 1;
 		irte->lo.fields_vapic.ga_tag = pi_data->ga_tag;
 
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 23eab00..a0e1f59 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -51,6 +51,9 @@
 #include <linux/of_platform.h>
 #include <linux/msm-bus.h>
 #include <dt-bindings/msm/msm-bus-ids.h>
+#include <linux/remote_spinlock.h>
+#include <linux/ktime.h>
+#include <trace/events/iommu.h>
 
 #include <linux/amba/bus.h>
 
@@ -319,6 +322,14 @@
 	QCOM_SMMUV500,
 };
 
+struct arm_smmu_device;
+struct arm_smmu_arch_ops {
+	int (*init)(struct arm_smmu_device *smmu);
+	void (*device_reset)(struct arm_smmu_device *smmu);
+	phys_addr_t (*iova_to_phys_hard)(struct iommu_domain *domain,
+					 dma_addr_t iova);
+};
+
 struct arm_smmu_impl_def_reg {
 	u32 offset;
 	u32 value;
@@ -392,7 +403,6 @@
 	int				regulator_defer;
 };
 
-struct arm_smmu_arch_ops;
 struct arm_smmu_device {
 	struct device			*dev;
 
@@ -420,6 +430,8 @@
 #define ARM_SMMU_OPT_DYNAMIC		(1 << 3)
 #define ARM_SMMU_OPT_3LVL_TABLES	(1 << 4)
 #define ARM_SMMU_OPT_NO_ASID_RETENTION	(1 << 5)
+#define ARM_SMMU_OPT_DISABLE_ATOS	(1 << 6)
+#define ARM_SMMU_OPT_QCOM_MMU500_ERRATA1	(1 << 7)
 	u32				options;
 	enum arm_smmu_arch_version	version;
 	enum arm_smmu_implementation	model;
@@ -519,6 +531,9 @@
 	struct mutex			assign_lock;
 	struct list_head		secure_pool_list;
 	struct iommu_domain		domain;
+
+	bool				qsmmuv500_errata1_init;
+	bool				qsmmuv500_errata1_client;
 };
 
 static DEFINE_SPINLOCK(arm_smmu_devices_lock);
@@ -540,6 +555,8 @@
 	{ ARM_SMMU_OPT_DYNAMIC, "qcom,dynamic" },
 	{ ARM_SMMU_OPT_3LVL_TABLES, "qcom,use-3-lvl-tables" },
 	{ ARM_SMMU_OPT_NO_ASID_RETENTION, "qcom,no-asid-retention" },
+	{ ARM_SMMU_OPT_DISABLE_ATOS, "qcom,disable-atos" },
+	{ ARM_SMMU_OPT_QCOM_MMU500_ERRATA1, "qcom,mmu500-errata-1" },
 	{ 0, NULL},
 };
 
@@ -554,6 +571,9 @@
 static int arm_smmu_assign_table(struct arm_smmu_domain *smmu_domain);
 static void arm_smmu_unassign_table(struct arm_smmu_domain *smmu_domain);
 
+static int arm_smmu_arch_init(struct arm_smmu_device *smmu);
+static void arm_smmu_arch_device_reset(struct arm_smmu_device *smmu);
+
 static uint64_t arm_smmu_iova_to_pte(struct iommu_domain *domain,
 				    dma_addr_t iova);
 
@@ -562,6 +582,7 @@
 static int arm_smmu_alloc_cb(struct iommu_domain *domain,
 				struct arm_smmu_device *smmu,
 				struct device *dev);
+static struct iommu_gather_ops qsmmuv500_errata1_smmu_gather_ops;
 
 static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom)
 {
@@ -617,76 +638,6 @@
 		mutex_unlock(&smmu_domain->assign_lock);
 }
 
-/*
- * init()
- * Hook for additional device tree parsing at probe time.
- *
- * device_reset()
- * Hook for one-time architecture-specific register settings.
- *
- * iova_to_phys_hard()
- * Provides debug information. May be called from the context fault irq handler.
- *
- * init_context_bank()
- * Hook for architecture-specific settings which require knowledge of the
- * dynamically allocated context bank number.
- *
- * device_group()
- * Hook for checking whether a device is compatible with a said group.
- */
-struct arm_smmu_arch_ops {
-	int (*init)(struct arm_smmu_device *smmu);
-	void (*device_reset)(struct arm_smmu_device *smmu);
-	phys_addr_t (*iova_to_phys_hard)(struct iommu_domain *domain,
-					 dma_addr_t iova);
-	void (*init_context_bank)(struct arm_smmu_domain *smmu_domain,
-					struct device *dev);
-	int (*device_group)(struct device *dev, struct iommu_group *group);
-};
-
-static int arm_smmu_arch_init(struct arm_smmu_device *smmu)
-{
-	if (!smmu->arch_ops)
-		return 0;
-	if (!smmu->arch_ops->init)
-		return 0;
-	return smmu->arch_ops->init(smmu);
-}
-
-static void arm_smmu_arch_device_reset(struct arm_smmu_device *smmu)
-{
-	if (!smmu->arch_ops)
-		return;
-	if (!smmu->arch_ops->device_reset)
-		return;
-	return smmu->arch_ops->device_reset(smmu);
-}
-
-static void arm_smmu_arch_init_context_bank(
-		struct arm_smmu_domain *smmu_domain, struct device *dev)
-{
-	struct arm_smmu_device *smmu = smmu_domain->smmu;
-
-	if (!smmu->arch_ops)
-		return;
-	if (!smmu->arch_ops->init_context_bank)
-		return;
-	return smmu->arch_ops->init_context_bank(smmu_domain, dev);
-}
-
-static int arm_smmu_arch_device_group(struct device *dev,
-					struct iommu_group *group)
-{
-	struct iommu_fwspec *fwspec = dev->iommu_fwspec;
-	struct arm_smmu_device *smmu = fwspec_smmu(fwspec);
-
-	if (!smmu->arch_ops)
-		return 0;
-	if (!smmu->arch_ops->device_group)
-		return 0;
-	return smmu->arch_ops->device_group(dev, group);
-}
-
 static struct device_node *dev_get_dev_node(struct device *dev)
 {
 	if (dev_is_pci(dev)) {
@@ -1286,11 +1237,12 @@
 {
 	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
 	struct arm_smmu_device *smmu = smmu_domain->smmu;
+	const struct iommu_gather_ops *tlb = smmu_domain->pgtbl_cfg.tlb;
 	phys_addr_t phys;
 	phys_addr_t phys_post_tlbiall;
 
 	phys = arm_smmu_iova_to_phys_hard(domain, iova);
-	arm_smmu_tlb_inv_context(smmu_domain);
+	tlb->tlb_flush_all(smmu_domain);
 	phys_post_tlbiall = arm_smmu_iova_to_phys_hard(domain, iova);
 
 	if (phys != phys_post_tlbiall) {
@@ -1646,6 +1598,7 @@
 	bool is_fast = smmu_domain->attributes & (1 << DOMAIN_ATTR_FAST);
 	unsigned long quirks = 0;
 	bool dynamic;
+	const struct iommu_gather_ops *tlb;
 
 	mutex_lock(&smmu_domain->init_mutex);
 	if (smmu_domain->smmu)
@@ -1760,6 +1713,13 @@
 		quirks |= IO_PGTABLE_QUIRK_QCOM_USE_UPSTREAM_HINT;
 	if (is_iommu_pt_coherent(smmu_domain))
 		quirks |= IO_PGTABLE_QUIRK_PAGE_TABLE_COHERENT;
+	if ((quirks & IO_PGTABLE_QUIRK_QCOM_USE_UPSTREAM_HINT) &&
+		(smmu->model == QCOM_SMMUV500))
+		quirks |= IO_PGTABLE_QUIRK_QSMMUV500_NON_SHAREABLE;
+
+	tlb = &arm_smmu_gather_ops;
+	if (smmu->options & ARM_SMMU_OPT_QCOM_MMU500_ERRATA1)
+		tlb = &qsmmuv500_errata1_smmu_gather_ops;
 
 	ret = arm_smmu_alloc_cb(domain, smmu, dev);
 	if (ret < 0)
@@ -1778,7 +1738,7 @@
 		.pgsize_bitmap	= smmu->pgsize_bitmap,
 		.ias		= ias,
 		.oas		= oas,
-		.tlb		= &arm_smmu_gather_ops,
+		.tlb		= tlb,
 		.iommu_dev	= smmu->dev,
 	};
 
@@ -1814,8 +1774,6 @@
 		arm_smmu_init_context_bank(smmu_domain,
 						&smmu_domain->pgtbl_cfg);
 
-		arm_smmu_arch_init_context_bank(smmu_domain, dev);
-
 		/*
 		 * Request context fault interrupt. Do this last to avoid the
 		 * handler seeing a half-initialised domain state.
@@ -2438,6 +2396,8 @@
 	if (ret)
 		return ret;
 
+	arm_smmu_secure_domain_lock(smmu_domain);
+
 	__saved_iova_start = iova;
 	idx_start = idx_end = 0;
 	sg_start = sg_end = sg;
@@ -2475,6 +2435,7 @@
 		arm_smmu_unmap(domain, __saved_iova_start, size_to_unmap);
 		iova = __saved_iova_start;
 	}
+	arm_smmu_secure_domain_unlock(smmu_domain);
 	arm_smmu_domain_power_off(domain, smmu_domain->smmu);
 	return iova - __saved_iova_start;
 }
@@ -2552,6 +2513,10 @@
 	phys_addr_t ret = 0;
 	unsigned long flags;
 	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
+	struct arm_smmu_device *smmu = smmu_domain->smmu;
+
+	if (smmu->options & ARM_SMMU_OPT_DISABLE_ATOS)
+		return 0;
 
 	if (smmu_domain->smmu->arch_ops &&
 	    smmu_domain->smmu->arch_ops->iova_to_phys_hard) {
@@ -2721,20 +2686,13 @@
 		group = smmu->s2crs[idx].group;
 	}
 
-	if (!group) {
-		if (dev_is_pci(dev))
-			group = pci_device_group(dev);
-		else
-			group = generic_device_group(dev);
+	if (group)
+		return group;
 
-		if (IS_ERR(group))
-			return NULL;
-	}
-
-	if (arm_smmu_arch_device_group(dev, group)) {
-		iommu_group_put(group);
-		return ERR_PTR(-EINVAL);
-	}
+	if (dev_is_pci(dev))
+		group = pci_device_group(dev);
+	else
+		group = generic_device_group(dev);
 
 	return group;
 }
@@ -2829,6 +2787,11 @@
 					& (1 << DOMAIN_ATTR_FAST));
 		ret = 0;
 		break;
+	case DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR:
+		*((int *)data) = !!(smmu_domain->attributes
+			& (1 << DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR));
+		ret = 0;
+		break;
 	case DOMAIN_ATTR_USE_UPSTREAM_HINT:
 		*((int *)data) = !!(smmu_domain->attributes &
 				   (1 << DOMAIN_ATTR_USE_UPSTREAM_HINT));
@@ -2981,6 +2944,12 @@
 		}
 		smmu_domain->secure_vmid = *((int *)data);
 		break;
+	case DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR:
+		if (*((int *)data))
+			smmu_domain->attributes |=
+				1 << DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR;
+		ret = 0;
+		break;
 	case DOMAIN_ATTR_FAST:
 		if (*((int *)data))
 			smmu_domain->attributes |= 1 << DOMAIN_ATTR_FAST;
@@ -3190,7 +3159,10 @@
 
 static void arm_smmu_tlbi_domain(struct iommu_domain *domain)
 {
-	arm_smmu_tlb_inv_context(to_smmu_domain(domain));
+	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
+	const struct iommu_gather_ops *tlb = smmu_domain->pgtbl_cfg.tlb;
+
+	tlb->tlb_flush_all(smmu_domain);
 }
 
 static int arm_smmu_enable_config_clocks(struct iommu_domain *domain)
@@ -3334,11 +3306,6 @@
 	u32 sctlr, sctlr_orig, fsr;
 	void __iomem *cb_base;
 
-	if (smmu->model == QCOM_SMMUV2) {
-		dev_err(smmu->dev, "ATOS support is disabled\n");
-		return 0;
-	}
-
 	ret = arm_smmu_power_on(smmu_domain->smmu->pwr);
 	if (ret)
 		return ret;
@@ -3563,6 +3530,7 @@
 
 		raw_s2cr = readl_relaxed(ARM_SMMU_GR0(smmu) +
 					ARM_SMMU_GR0_S2CR(i));
+		memset(&s2cr, 0, sizeof(s2cr));
 		s2cr.group = NULL;
 		s2cr.count = 1;
 		s2cr.type = (raw_s2cr >> S2CR_TYPE_SHIFT) & S2CR_TYPE_MASK;
@@ -4010,6 +3978,24 @@
 	return 0;
 }
 
+static int arm_smmu_arch_init(struct arm_smmu_device *smmu)
+{
+	if (!smmu->arch_ops)
+		return 0;
+	if (!smmu->arch_ops->init)
+		return 0;
+	return smmu->arch_ops->init(smmu);
+}
+
+static void arm_smmu_arch_device_reset(struct arm_smmu_device *smmu)
+{
+	if (!smmu->arch_ops)
+		return;
+	if (!smmu->arch_ops->device_reset)
+		return;
+	return smmu->arch_ops->device_reset(smmu);
+}
+
 struct arm_smmu_match_data {
 	enum arm_smmu_arch_version version;
 	enum arm_smmu_implementation model;
@@ -4334,12 +4320,6 @@
 
 #define TBU_DBG_TIMEOUT_US		30000
 
-
-struct actlr_setting {
-	struct arm_smmu_smr smr;
-	u32 actlr;
-};
-
 struct qsmmuv500_archdata {
 	struct list_head		tbus;
 	void __iomem			*tcu_base;
@@ -4347,6 +4327,11 @@
 
 	struct actlr_setting		*actlrs;
 	u32				actlr_tbl_size;
+
+	struct arm_smmu_smr		*errata1_clients;
+	u32				num_errata1_clients;
+	remote_spinlock_t		errata1_lock;
+	ktime_t				last_tlbi_ktime;
 };
 #define get_qsmmuv500_archdata(smmu)				\
 	((struct qsmmuv500_archdata *)(smmu->archdata))
@@ -4367,13 +4352,117 @@
 	u32				halt_count;
 };
 
-struct qsmmuv500_group_iommudata {
-	bool has_actlr;
-	u32 actlr;
+static bool arm_smmu_domain_match_smr(struct arm_smmu_domain *smmu_domain,
+				      struct arm_smmu_smr *smr)
+{
+	struct arm_smmu_smr *smr2;
+	int i, idx;
+
+	for_each_cfg_sme(smmu_domain->dev->iommu_fwspec, i, idx) {
+		smr2 = &smmu_domain->smmu->smrs[idx];
+		/* Continue if table entry does not match */
+		if ((smr->id ^ smr2->id) & ~(smr->mask | smr2->mask))
+			continue;
+		return true;
+	}
+	return false;
+}
+
+#define ERRATA1_REMOTE_SPINLOCK       "S:6"
+#define ERRATA1_TLBI_INTERVAL_US		10
+static bool
+qsmmuv500_errata1_required(struct arm_smmu_domain *smmu_domain,
+				 struct qsmmuv500_archdata *data)
+{
+	bool ret = false;
+	int j;
+	struct arm_smmu_smr *smr;
+
+	if (smmu_domain->qsmmuv500_errata1_init)
+		return smmu_domain->qsmmuv500_errata1_client;
+
+	for (j = 0; j < data->num_errata1_clients; j++) {
+		smr = &data->errata1_clients[j];
+		if (arm_smmu_domain_match_smr(smmu_domain, smr)) {
+			ret = true;
+			break;
+		}
+	}
+
+	smmu_domain->qsmmuv500_errata1_init = true;
+	smmu_domain->qsmmuv500_errata1_client = ret;
+	return ret;
+}
+
+static void __qsmmuv500_errata1_tlbiall(struct arm_smmu_domain *smmu_domain)
+{
+	struct arm_smmu_device *smmu = smmu_domain->smmu;
+	struct device *dev = smmu_domain->dev;
+	struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
+	void __iomem *base;
+	ktime_t cur;
+	u32 val;
+
+	base = ARM_SMMU_CB_BASE(smmu) + ARM_SMMU_CB(smmu, cfg->cbndx);
+	writel_relaxed(0, base + ARM_SMMU_CB_S1_TLBIALL);
+	writel_relaxed(0, base + ARM_SMMU_CB_TLBSYNC);
+	if (readl_poll_timeout_atomic(base + ARM_SMMU_CB_TLBSTATUS, val,
+				      !(val & TLBSTATUS_SACTIVE), 0, 100)) {
+		cur = ktime_get();
+		trace_errata_throttle_start(dev, 0);
+
+		msm_bus_noc_throttle_wa(true);
+		if (readl_poll_timeout_atomic(base + ARM_SMMU_CB_TLBSTATUS, val,
+				      !(val & TLBSTATUS_SACTIVE), 0, 10000)) {
+			dev_err(smmu->dev, "ERRATA1 TLBSYNC timeout");
+			trace_errata_failed(dev, 0);
+		}
+
+		msm_bus_noc_throttle_wa(false);
+
+		trace_errata_throttle_end(
+				dev, ktime_us_delta(ktime_get(), cur));
+	}
+}
+
+/* Must be called with clocks/regulators enabled */
+static void qsmmuv500_errata1_tlb_inv_context(void *cookie)
+{
+	struct arm_smmu_domain *smmu_domain = cookie;
+	struct device *dev = smmu_domain->dev;
+	struct qsmmuv500_archdata *data =
+			get_qsmmuv500_archdata(smmu_domain->smmu);
+	ktime_t cur;
+	bool errata;
+
+	cur = ktime_get();
+	trace_errata_tlbi_start(dev, 0);
+
+	errata = qsmmuv500_errata1_required(smmu_domain, data);
+	remote_spin_lock(&data->errata1_lock);
+	if (errata) {
+		s64 delta;
+
+		delta = ktime_us_delta(ktime_get(), data->last_tlbi_ktime);
+		if (delta < ERRATA1_TLBI_INTERVAL_US)
+			udelay(ERRATA1_TLBI_INTERVAL_US - delta);
+
+		__qsmmuv500_errata1_tlbiall(smmu_domain);
+
+		data->last_tlbi_ktime = ktime_get();
+	} else {
+		__qsmmuv500_errata1_tlbiall(smmu_domain);
+	}
+	remote_spin_unlock(&data->errata1_lock);
+
+	trace_errata_tlbi_end(dev, ktime_us_delta(ktime_get(), cur));
+}
+
+static struct iommu_gather_ops qsmmuv500_errata1_smmu_gather_ops = {
+	.tlb_flush_all	= qsmmuv500_errata1_tlb_inv_context,
+	.alloc_pages_exact = arm_smmu_alloc_pages_exact,
+	.free_pages_exact = arm_smmu_free_pages_exact,
 };
-#define to_qsmmuv500_group_iommudata(group)				\
-	((struct qsmmuv500_group_iommudata *)				\
-		(iommu_group_get_iommudata(group)))
 
 static int qsmmuv500_tbu_halt(struct qsmmuv500_tbu_device *tbu)
 {
@@ -4628,79 +4717,6 @@
 	return qsmmuv500_iova_to_phys(domain, iova, sid);
 }
 
-static void qsmmuv500_release_group_iommudata(void *data)
-{
-	kfree(data);
-}
-
-/* If a device has a valid actlr, it must match */
-static int qsmmuv500_device_group(struct device *dev,
-				struct iommu_group *group)
-{
-	struct iommu_fwspec *fwspec = dev->iommu_fwspec;
-	struct arm_smmu_device *smmu = fwspec_smmu(fwspec);
-	struct qsmmuv500_archdata *data = get_qsmmuv500_archdata(smmu);
-	struct qsmmuv500_group_iommudata *iommudata;
-	u32 actlr, i, j, idx;
-	struct arm_smmu_smr *smr, *smr2;
-
-	iommudata = to_qsmmuv500_group_iommudata(group);
-	if (!iommudata) {
-		iommudata = kzalloc(sizeof(*iommudata), GFP_KERNEL);
-		if (!iommudata)
-			return -ENOMEM;
-
-		iommu_group_set_iommudata(group, iommudata,
-				qsmmuv500_release_group_iommudata);
-	}
-
-	for_each_cfg_sme(fwspec, i, idx) {
-		smr = &smmu->smrs[idx];
-		for (j = 0; j < data->actlr_tbl_size; j++) {
-			smr2 = &data->actlrs[j].smr;
-			actlr = data->actlrs[j].actlr;
-
-			/* Continue if table entry does not match */
-			if ((smr->id ^ smr2->id) & ~(smr->mask | smr2->mask))
-				continue;
-
-			if (!iommudata->has_actlr) {
-				iommudata->actlr = actlr;
-				iommudata->has_actlr = true;
-			} else if (iommudata->actlr != actlr) {
-				return -EINVAL;
-			}
-		}
-	}
-
-	return 0;
-}
-
-static void qsmmuv500_init_cb(struct arm_smmu_domain *smmu_domain,
-				struct device *dev)
-{
-	struct arm_smmu_device *smmu = smmu_domain->smmu;
-	struct qsmmuv500_group_iommudata *iommudata =
-		to_qsmmuv500_group_iommudata(dev->iommu_group);
-	void __iomem *cb_base;
-	const struct iommu_gather_ops *tlb;
-
-	if (!iommudata->has_actlr)
-		return;
-
-	tlb = smmu_domain->pgtbl_cfg.tlb;
-	cb_base = ARM_SMMU_CB_BASE(smmu) +
-			ARM_SMMU_CB(smmu, smmu_domain->cfg.cbndx);
-
-	writel_relaxed(iommudata->actlr, cb_base + ARM_SMMU_CB_ACTLR);
-
-	/*
-	 * Flush the context bank after modifying ACTLR to ensure there
-	 * are no cache entries with stale state
-	 */
-	tlb->tlb_flush_all(smmu_domain);
-}
-
 static int qsmmuv500_tbu_register(struct device *dev, void *cookie)
 {
 	struct arm_smmu_device *smmu = cookie;
@@ -4720,35 +4736,35 @@
 	return 0;
 }
 
-static int qsmmuv500_read_actlr_tbl(struct arm_smmu_device *smmu)
+static int qsmmuv500_parse_errata1(struct arm_smmu_device *smmu)
 {
 	int len, i;
 	struct device *dev = smmu->dev;
 	struct qsmmuv500_archdata *data = get_qsmmuv500_archdata(smmu);
-	struct actlr_setting *actlrs;
+	struct arm_smmu_smr *smrs;
 	const __be32 *cell;
 
-	cell = of_get_property(dev->of_node, "qcom,actlr", NULL);
+	cell = of_get_property(dev->of_node, "qcom,mmu500-errata-1", NULL);
 	if (!cell)
 		return 0;
 
-	len = of_property_count_elems_of_size(dev->of_node, "qcom,actlr",
-						sizeof(u32) * 3);
+	remote_spin_lock_init(&data->errata1_lock, ERRATA1_REMOTE_SPINLOCK);
+	len = of_property_count_elems_of_size(
+			dev->of_node, "qcom,mmu500-errata-1", sizeof(u32) * 2);
 	if (len < 0)
 		return 0;
 
-	actlrs = devm_kzalloc(dev, sizeof(*actlrs) * len, GFP_KERNEL);
-	if (!actlrs)
+	smrs = devm_kzalloc(dev, sizeof(*smrs) * len, GFP_KERNEL);
+	if (!smrs)
 		return -ENOMEM;
 
 	for (i = 0; i < len; i++) {
-		actlrs[i].smr.id = of_read_number(cell++, 1);
-		actlrs[i].smr.mask = of_read_number(cell++, 1);
-		actlrs[i].actlr = of_read_number(cell++, 1);
+		smrs[i].id = of_read_number(cell++, 1);
+		smrs[i].mask = of_read_number(cell++, 1);
 	}
 
-	data->actlrs = actlrs;
-	data->actlr_tbl_size = len;
+	data->errata1_clients = smrs;
+	data->num_errata1_clients = len;
 	return 0;
 }
 
@@ -4759,8 +4775,6 @@
 	struct qsmmuv500_archdata *data;
 	struct platform_device *pdev;
 	int ret;
-	u32 val;
-	void __iomem *reg;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -4777,23 +4791,10 @@
 	data->version = readl_relaxed(data->tcu_base + TCU_HW_VERSION_HLOS1);
 	smmu->archdata = data;
 
-	ret = qsmmuv500_read_actlr_tbl(smmu);
+	ret = qsmmuv500_parse_errata1(smmu);
 	if (ret)
 		return ret;
 
-	reg = ARM_SMMU_GR0(smmu);
-	val = readl_relaxed(reg + ARM_SMMU_GR0_sACR);
-	val &= ~ARM_MMU500_ACR_CACHE_LOCK;
-	writel_relaxed(val, reg + ARM_SMMU_GR0_sACR);
-	val = readl_relaxed(reg + ARM_SMMU_GR0_sACR);
-	/*
-	 * Modifiying the nonsecure copy of the sACR register is only
-	 * allowed if permission is given in the secure sACR register.
-	 * Attempt to detect if we were able to update the value.
-	 */
-	WARN_ON(val & ARM_MMU500_ACR_CACHE_LOCK);
-
-
 	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (ret)
 		return ret;
@@ -4809,8 +4810,6 @@
 struct arm_smmu_arch_ops qsmmuv500_arch_ops = {
 	.init = qsmmuv500_arch_init,
 	.iova_to_phys_hard = qsmmuv500_iova_to_phys_hard,
-	.init_context_bank = qsmmuv500_init_cb,
-	.device_group = qsmmuv500_device_group,
 };
 
 static const struct of_device_id qsmmuv500_tbu_of_match[] = {
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index d92a352..da4d283 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -202,39 +202,58 @@
 	}
 }
 
-static struct iova *__alloc_iova(struct iommu_domain *domain, size_t size,
-		dma_addr_t dma_limit)
+static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
+		size_t size, dma_addr_t dma_limit, struct device *dev)
 {
 	struct iova_domain *iovad = cookie_iovad(domain);
 	unsigned long shift = iova_shift(iovad);
-	unsigned long length = iova_align(iovad, size) >> shift;
+	unsigned long iova_len = size >> shift;
+	unsigned long iova = 0;
+	dma_addr_t limit;
+
+	/*
+	 * Freeing non-power-of-two-sized allocations back into the IOVA caches
+	 * will come back to bite us badly, so we have to waste a bit of space
+	 * rounding up anything cacheable to make sure that can't happen. The
+	 * order of the unadjusted size will still match upon freeing.
+	 */
+	if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1)))
+		iova_len = roundup_pow_of_two(iova_len);
 
 	if (domain->geometry.force_aperture)
 		dma_limit = min(dma_limit, domain->geometry.aperture_end);
+
 	/*
-	 * Enforce size-alignment to be safe - there could perhaps be an
-	 * attribute to control this per-device, or at least per-domain...
+	 * Ensure iova is within range specified in iommu_dma_init_domain().
+	 * This also prevents unnecessary work iterating through the entire
+	 * rb_tree.
 	 */
-	return alloc_iova(iovad, length, dma_limit >> shift, true);
+	limit = min_t(dma_addr_t, dma_limit >> shift, iovad->dma_32bit_pfn);
+	iova = alloc_iova_fast(iovad, iova_len, limit);
+
+	return (dma_addr_t)iova << shift;
 }
 
-/* The IOVA allocator knows what we mapped, so just unmap whatever that was */
-static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr)
+static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
+		dma_addr_t iova, size_t size)
+{
+	struct iova_domain *iovad = &cookie->iovad;
+	unsigned long shift = iova_shift(iovad);
+
+	free_iova_fast(iovad, iova >> shift, size >> shift);
+}
+
+static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr,
+		size_t size)
 {
 	struct iova_domain *iovad = cookie_iovad(domain);
-	unsigned long shift = iova_shift(iovad);
-	unsigned long pfn = dma_addr >> shift;
-	struct iova *iova = find_iova(iovad, pfn);
-	size_t size;
+	size_t iova_off = iova_offset(iovad, dma_addr);
 
-	if (WARN_ON(!iova))
-		return;
+	dma_addr -= iova_off;
+	size = iova_align(iovad, size + iova_off);
 
-	size = iova_size(iova) << shift;
-	size -= iommu_unmap(domain, pfn << shift, size);
-	/* ...and if we can't, then something is horribly, horribly wrong */
-	WARN_ON(size > 0);
-	__free_iova(iovad, iova);
+	WARN_ON(iommu_unmap(domain, dma_addr, size) != size);
+	iommu_dma_free_iova(domain->iova_cookie, dma_addr, size);
 }
 
 static void __iommu_dma_free_pages(struct page **pages, int count)
@@ -316,7 +335,7 @@
 void iommu_dma_free(struct device *dev, struct page **pages, size_t size,
 		dma_addr_t *handle)
 {
-	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), *handle);
+	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), *handle, size);
 	__iommu_dma_free_pages(pages, PAGE_ALIGN(size) >> PAGE_SHIFT);
 	*handle = DMA_ERROR_CODE;
 }
@@ -344,11 +363,11 @@
 		void (*flush_page)(struct device *, const void *, phys_addr_t))
 {
 	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-	struct iova_domain *iovad = cookie_iovad(domain);
-	struct iova *iova;
+	struct iommu_dma_cookie *cookie = domain->iova_cookie;
+	struct iova_domain *iovad = &cookie->iovad;
 	struct page **pages;
 	struct sg_table sgt;
-	dma_addr_t dma_addr;
+	dma_addr_t iova;
 	unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap;
 
 	*handle = DMA_ERROR_CODE;
@@ -368,11 +387,11 @@
 	if (!pages)
 		return NULL;
 
-	iova = __alloc_iova(domain, size, dev->coherent_dma_mask);
+	size = iova_align(iovad, size);
+	iova = iommu_dma_alloc_iova(domain, size, dev->coherent_dma_mask, dev);
 	if (!iova)
 		goto out_free_pages;
 
-	size = iova_align(iovad, size);
 	if (sg_alloc_table_from_pages(&sgt, pages, count, 0, size, GFP_KERNEL))
 		goto out_free_iova;
 
@@ -388,19 +407,18 @@
 		sg_miter_stop(&miter);
 	}
 
-	dma_addr = iova_dma_addr(iovad, iova);
-	if (iommu_map_sg(domain, dma_addr, sgt.sgl, sgt.orig_nents, prot)
+	if (iommu_map_sg(domain, iova, sgt.sgl, sgt.orig_nents, prot)
 			< size)
 		goto out_free_sg;
 
-	*handle = dma_addr;
+	*handle = iova;
 	sg_free_table(&sgt);
 	return pages;
 
 out_free_sg:
 	sg_free_table(&sgt);
 out_free_iova:
-	__free_iova(iovad, iova);
+	iommu_dma_free_iova(cookie, iova, size);
 out_free_pages:
 	__iommu_dma_free_pages(pages, count);
 	return NULL;
@@ -434,22 +452,22 @@
 static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
 		size_t size, int prot)
 {
-	dma_addr_t dma_addr;
 	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-	struct iova_domain *iovad = cookie_iovad(domain);
+	struct iommu_dma_cookie *cookie = domain->iova_cookie;
+	struct iova_domain *iovad = &cookie->iovad;
 	size_t iova_off = iova_offset(iovad, phys);
-	size_t len = iova_align(iovad, size + iova_off);
-	struct iova *iova = __alloc_iova(domain, len, dma_get_mask(dev));
+	dma_addr_t iova;
 
+	size = iova_align(iovad, size + iova_off);
+	iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev);
 	if (!iova)
 		return DMA_ERROR_CODE;
 
-	dma_addr = iova_dma_addr(iovad, iova);
-	if (iommu_map(domain, dma_addr, phys - iova_off, len, prot)) {
-		__free_iova(iovad, iova);
+	if (iommu_map(domain, iova, phys - iova_off, size, prot)) {
+		iommu_dma_free_iova(cookie, iova, size);
 		return DMA_ERROR_CODE;
 	}
-	return dma_addr + iova_off;
+	return iova + iova_off;
 }
 
 dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
@@ -461,7 +479,7 @@
 void iommu_dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
 		enum dma_data_direction dir, unsigned long attrs)
 {
-	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), handle);
+	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), handle, size);
 }
 
 /*
@@ -550,10 +568,10 @@
 		int nents, int prot)
 {
 	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-	struct iova_domain *iovad = cookie_iovad(domain);
-	struct iova *iova;
+	struct iommu_dma_cookie *cookie = domain->iova_cookie;
+	struct iova_domain *iovad = &cookie->iovad;
 	struct scatterlist *s, *prev = NULL;
-	dma_addr_t dma_addr;
+	dma_addr_t iova;
 	size_t iova_len = 0;
 	unsigned long mask = dma_get_seg_boundary(dev);
 	int i;
@@ -597,7 +615,7 @@
 		prev = s;
 	}
 
-	iova = __alloc_iova(domain, iova_len, dma_get_mask(dev));
+	iova = iommu_dma_alloc_iova(domain, iova_len, dma_get_mask(dev), dev);
 	if (!iova)
 		goto out_restore_sg;
 
@@ -605,14 +623,13 @@
 	 * We'll leave any physical concatenation to the IOMMU driver's
 	 * implementation - it knows better than we do.
 	 */
-	dma_addr = iova_dma_addr(iovad, iova);
-	if (iommu_map_sg(domain, dma_addr, sg, nents, prot) < iova_len)
+	if (iommu_map_sg(domain, iova, sg, nents, prot) < iova_len)
 		goto out_free_iova;
 
-	return __finalise_sg(dev, sg, nents, dma_addr);
+	return __finalise_sg(dev, sg, nents, iova);
 
 out_free_iova:
-	__free_iova(iovad, iova);
+	iommu_dma_free_iova(cookie, iova, iova_len);
 out_restore_sg:
 	__invalidate_sg(sg, nents);
 	return 0;
@@ -621,11 +638,21 @@
 void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
 		enum dma_data_direction dir, unsigned long attrs)
 {
+	dma_addr_t start, end;
+	struct scatterlist *tmp;
+	int i;
 	/*
 	 * The scatterlist segments are mapped into a single
 	 * contiguous IOVA allocation, so this is incredibly easy.
 	 */
-	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), sg_dma_address(sg));
+	start = sg_dma_address(sg);
+	for_each_sg(sg_next(sg), tmp, nents - 1, i) {
+		if (sg_dma_len(tmp) == 0)
+			break;
+		sg = tmp;
+	}
+	end = sg_dma_address(sg) + sg_dma_len(sg);
+	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), start, end - start);
 }
 
 dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys,
@@ -638,7 +665,7 @@
 void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
-	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), handle);
+	__iommu_dma_unmap(iommu_get_domain_for_dev(dev), handle, size);
 }
 
 int iommu_dma_supported(struct device *dev, u64 mask)
@@ -662,7 +689,7 @@
 	struct iommu_dma_cookie *cookie = domain->iova_cookie;
 	struct iommu_dma_msi_page *msi_page;
 	struct iova_domain *iovad = &cookie->iovad;
-	struct iova *iova;
+	dma_addr_t iova;
 	int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
 
 	msi_addr &= ~(phys_addr_t)iova_mask(iovad);
@@ -674,12 +701,13 @@
 	if (!msi_page)
 		return NULL;
 
-	iova = __alloc_iova(domain, iovad->granule, dma_get_mask(dev));
+	iova = iommu_dma_alloc_iova(domain, iovad->granule, dma_get_mask(dev),
+				    dev);
 	if (!iova)
 		goto out_free_page;
 
 	msi_page->phys = msi_addr;
-	msi_page->iova = iova_dma_addr(iovad, iova);
+	msi_page->iova = iova;
 	if (iommu_map(domain, msi_page->iova, msi_addr, iovad->granule, prot))
 		goto out_free_iova;
 
@@ -688,7 +716,7 @@
 	return msi_page;
 
 out_free_iova:
-	__free_iova(iovad, iova);
+	iommu_dma_free_iova(cookie, iova, iovad->granule);
 out_free_page:
 	kfree(msi_page);
 	return NULL;
diff --git a/drivers/iommu/dma-mapping-fast.c b/drivers/iommu/dma-mapping-fast.c
index b5e817b..04a5c09 100644
--- a/drivers/iommu/dma-mapping-fast.c
+++ b/drivers/iommu/dma-mapping-fast.c
@@ -855,29 +855,28 @@
 	spin_unlock_irqrestore(&mapping->lock, flags);
 }
 
-
 /**
- * fast_smmu_attach_device
+ * fast_smmu_init_mapping
  * @dev: valid struct device pointer
  * @mapping: io address space mapping structure (returned from
- *	fast_smmu_create_mapping)
+ *	arm_iommu_create_mapping)
  *
- * Attaches specified io address space mapping to the provided device,
- * this replaces the dma operations (dma_map_ops pointer) with the
- * IOMMU aware version. More than one client might be attached to
- * the same io address space mapping.
+ * Called the first time a device is attached to this mapping.
+ * Not for dma client use.
  */
-int fast_smmu_attach_device(struct device *dev,
+int fast_smmu_init_mapping(struct device *dev,
 			    struct dma_iommu_mapping *mapping)
 {
-	int atomic_domain = 1;
+	int err, atomic_domain = 1;
 	struct iommu_domain *domain = mapping->domain;
 	struct iommu_group *group;
 	struct iommu_pgtbl_info info;
 	u64 size = (u64)mapping->bits << PAGE_SHIFT;
 
-	if (mapping->base + size > (SZ_1G * 4ULL))
+	if (mapping->base + size > (SZ_1G * 4ULL)) {
+		dev_err(dev, "Iova end address too large\n");
 		return -EINVAL;
+	}
 
 	if (iommu_domain_set_attr(domain, DOMAIN_ATTR_ATOMIC,
 				  &atomic_domain))
@@ -894,54 +893,67 @@
 	group = dev->iommu_group;
 	if (!group) {
 		dev_err(dev, "No iommu associated with device\n");
-		return -ENODEV;
+		err = -ENODEV;
+		goto release_mapping;
 	}
 
 	if (iommu_get_domain_for_dev(dev)) {
 		dev_err(dev, "Device already attached to other iommu_domain\n");
-		return -EINVAL;
+		err = -EINVAL;
+		goto release_mapping;
 	}
 
-	if (iommu_attach_group(mapping->domain, group))
-		return -EINVAL;
+	/*
+	 * Need to attach prior to calling DOMAIN_ATTR_PGTBL_INFO and then
+	 * detach to be in the expected state. Its a bit messy.
+	 */
+	if (iommu_attach_group(mapping->domain, group)) {
+		err = -EINVAL;
+		goto release_mapping;
+	}
 
 	if (iommu_domain_get_attr(domain, DOMAIN_ATTR_PGTBL_INFO,
 				  &info)) {
 		dev_err(dev, "Couldn't get page table info\n");
-		fast_smmu_detach_device(dev, mapping);
-		return -EINVAL;
+		err = -EINVAL;
+		goto detach_group;
 	}
 	mapping->fast->pgtbl_pmds = info.pmds;
 
 	if (iommu_domain_get_attr(domain, DOMAIN_ATTR_PAGE_TABLE_IS_COHERENT,
-				  &mapping->fast->is_smmu_pt_coherent))
-		return -EINVAL;
+				  &mapping->fast->is_smmu_pt_coherent)) {
+		err = -EINVAL;
+		goto detach_group;
+	}
 
 	mapping->fast->notifier.notifier_call = fast_smmu_notify;
 	av8l_register_notify(&mapping->fast->notifier);
 
-	dev->archdata.mapping = mapping;
-	set_dma_ops(dev, &fast_smmu_dma_ops);
-
+	iommu_detach_group(mapping->domain, group);
+	mapping->ops = &fast_smmu_dma_ops;
 	return 0;
+
+detach_group:
+	iommu_detach_group(mapping->domain, group);
+release_mapping:
+	kfree(mapping->fast->bitmap);
+	kfree(mapping->fast);
+	return err;
 }
-EXPORT_SYMBOL(fast_smmu_attach_device);
 
 /**
- * fast_smmu_detach_device
- * @dev: valid struct device pointer
+ * fast_smmu_release_mapping
+ * @kref: dma_iommu_mapping->kref
  *
- * Detaches the provided device from a previously attached map.
- * This voids the dma operations (dma_map_ops pointer)
+ * Cleans up the given iommu mapping.
  */
-void fast_smmu_detach_device(struct device *dev,
-			     struct dma_iommu_mapping *mapping)
+void fast_smmu_release_mapping(struct kref *kref)
 {
-	iommu_detach_group(mapping->domain, dev->iommu_group);
-	dev->archdata.mapping = NULL;
-	set_dma_ops(dev, NULL);
+	struct dma_iommu_mapping *mapping =
+		container_of(kref, struct dma_iommu_mapping, kref);
 
 	kvfree(mapping->fast->bitmap);
 	kfree(mapping->fast);
+	iommu_domain_free(mapping->domain);
+	kfree(mapping);
 }
-EXPORT_SYMBOL(fast_smmu_detach_device);
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index dde2876..a3594d2 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -1011,6 +1011,11 @@
 		reg = (ARM_LPAE_TCR_SH_OS << ARM_LPAE_TCR_SH0_SHIFT) |
 			(ARM_LPAE_TCR_RGN_WBWA << ARM_LPAE_TCR_IRGN0_SHIFT) |
 			(ARM_LPAE_TCR_RGN_WBWA << ARM_LPAE_TCR_ORGN0_SHIFT);
+	else if ((cfg->quirks & IO_PGTABLE_QUIRK_QCOM_USE_UPSTREAM_HINT) &&
+		(cfg->quirks & IO_PGTABLE_QUIRK_QSMMUV500_NON_SHAREABLE))
+		reg = (ARM_LPAE_TCR_SH_NS << ARM_LPAE_TCR_SH0_SHIFT) |
+			(ARM_LPAE_TCR_RGN_NC << ARM_LPAE_TCR_IRGN0_SHIFT) |
+			(ARM_LPAE_TCR_RGN_WBWA << ARM_LPAE_TCR_ORGN0_SHIFT);
 	else if (cfg->quirks & IO_PGTABLE_QUIRK_QCOM_USE_UPSTREAM_HINT)
 		reg = (ARM_LPAE_TCR_SH_OS << ARM_LPAE_TCR_SH0_SHIFT) |
 			(ARM_LPAE_TCR_RGN_NC << ARM_LPAE_TCR_IRGN0_SHIFT) |
diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
index a686ad0..b35016e 100644
--- a/drivers/iommu/io-pgtable.h
+++ b/drivers/iommu/io-pgtable.h
@@ -81,6 +81,12 @@
 	 *
 	 * IO_PGTABLE_QUIRK_PAGE_TABLE_COHERENT: Set the page table as
 	 *	coherent.
+	 *
+	 * IO_PGTABLE_QUIRK_QSMMUV500_NON_SHAREABLE:
+	 *	Having page tables which are non coherent, but cached in a
+	 *	system cache requires SH=Non-Shareable. This applies to the
+	 *	qsmmuv500 model. For data buffers SH=Non-Shareable is not
+	 *	required.
 	 */
 	#define IO_PGTABLE_QUIRK_ARM_NS		BIT(0)
 	#define IO_PGTABLE_QUIRK_NO_PERMS	BIT(1)
@@ -88,6 +94,7 @@
 	#define IO_PGTABLE_QUIRK_ARM_MTK_4GB	BIT(3)
 	#define IO_PGTABLE_QUIRK_QCOM_USE_UPSTREAM_HINT	BIT(4)
 	#define IO_PGTABLE_QUIRK_PAGE_TABLE_COHERENT BIT(5)
+	#define IO_PGTABLE_QUIRK_QSMMUV500_NON_SHAREABLE BIT(6)
 	unsigned long			quirks;
 	unsigned long			pgsize_bitmap;
 	unsigned int			ias;
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index e23001b..5c88ba7 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -56,13 +56,13 @@
 static struct rb_node *
 __get_cached_rbnode(struct iova_domain *iovad, unsigned long *limit_pfn)
 {
-	if ((*limit_pfn != iovad->dma_32bit_pfn) ||
+	if ((*limit_pfn > iovad->dma_32bit_pfn) ||
 		(iovad->cached32_node == NULL))
 		return rb_last(&iovad->rbroot);
 	else {
 		struct rb_node *prev_node = rb_prev(iovad->cached32_node);
 		struct iova *curr_iova =
-			container_of(iovad->cached32_node, struct iova, node);
+			rb_entry(iovad->cached32_node, struct iova, node);
 		*limit_pfn = curr_iova->pfn_lo - 1;
 		return prev_node;
 	}
@@ -86,11 +86,11 @@
 	if (!iovad->cached32_node)
 		return;
 	curr = iovad->cached32_node;
-	cached_iova = container_of(curr, struct iova, node);
+	cached_iova = rb_entry(curr, struct iova, node);
 
 	if (free->pfn_lo >= cached_iova->pfn_lo) {
 		struct rb_node *node = rb_next(&free->node);
-		struct iova *iova = container_of(node, struct iova, node);
+		struct iova *iova = rb_entry(node, struct iova, node);
 
 		/* only cache if it's below 32bit pfn */
 		if (node && iova->pfn_lo < iovad->dma_32bit_pfn)
@@ -100,6 +100,34 @@
 	}
 }
 
+/* Insert the iova into domain rbtree by holding writer lock */
+static void
+iova_insert_rbtree(struct rb_root *root, struct iova *iova,
+		   struct rb_node *start)
+{
+	struct rb_node **new, *parent = NULL;
+
+	new = (start) ? &start : &(root->rb_node);
+	/* Figure out where to put new node */
+	while (*new) {
+		struct iova *this = rb_entry(*new, struct iova, node);
+
+		parent = *new;
+
+		if (iova->pfn_lo < this->pfn_lo)
+			new = &((*new)->rb_left);
+		else if (iova->pfn_lo > this->pfn_lo)
+			new = &((*new)->rb_right);
+		else {
+			WARN_ON(1); /* this should not happen */
+			return;
+		}
+	}
+	/* Add new node and rebalance tree. */
+	rb_link_node(&iova->node, parent, new);
+	rb_insert_color(&iova->node, root);
+}
+
 /*
  * Computes the padding size required, to make the start address
  * naturally aligned on the power-of-two order of its size
@@ -125,7 +153,7 @@
 	curr = __get_cached_rbnode(iovad, &limit_pfn);
 	prev = curr;
 	while (curr) {
-		struct iova *curr_iova = container_of(curr, struct iova, node);
+		struct iova *curr_iova = rb_entry(curr, struct iova, node);
 
 		if (limit_pfn < curr_iova->pfn_lo)
 			goto move_left;
@@ -138,7 +166,7 @@
 				break;	/* found a free slot */
 		}
 adjust_limit_pfn:
-		limit_pfn = curr_iova->pfn_lo - 1;
+		limit_pfn = curr_iova->pfn_lo ? (curr_iova->pfn_lo - 1) : 0;
 move_left:
 		prev = curr;
 		curr = rb_prev(curr);
@@ -157,36 +185,8 @@
 	new->pfn_lo = limit_pfn - (size + pad_size) + 1;
 	new->pfn_hi = new->pfn_lo + size - 1;
 
-	/* Insert the new_iova into domain rbtree by holding writer lock */
-	/* Add new node and rebalance tree. */
-	{
-		struct rb_node **entry, *parent = NULL;
-
-		/* If we have 'prev', it's a valid place to start the
-		   insertion. Otherwise, start from the root. */
-		if (prev)
-			entry = &prev;
-		else
-			entry = &iovad->rbroot.rb_node;
-
-		/* Figure out where to put new node */
-		while (*entry) {
-			struct iova *this = container_of(*entry,
-							struct iova, node);
-			parent = *entry;
-
-			if (new->pfn_lo < this->pfn_lo)
-				entry = &((*entry)->rb_left);
-			else if (new->pfn_lo > this->pfn_lo)
-				entry = &((*entry)->rb_right);
-			else
-				BUG(); /* this should not happen */
-		}
-
-		/* Add new node and rebalance tree. */
-		rb_link_node(&new->node, parent, entry);
-		rb_insert_color(&new->node, &iovad->rbroot);
-	}
+	/* If we have 'prev', it's a valid place to start the insertion. */
+	iova_insert_rbtree(&iovad->rbroot, new, prev);
 	__cached_rbnode_insert_update(iovad, saved_pfn, new);
 
 	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
@@ -195,28 +195,6 @@
 	return 0;
 }
 
-static void
-iova_insert_rbtree(struct rb_root *root, struct iova *iova)
-{
-	struct rb_node **new = &(root->rb_node), *parent = NULL;
-	/* Figure out where to put new node */
-	while (*new) {
-		struct iova *this = container_of(*new, struct iova, node);
-
-		parent = *new;
-
-		if (iova->pfn_lo < this->pfn_lo)
-			new = &((*new)->rb_left);
-		else if (iova->pfn_lo > this->pfn_lo)
-			new = &((*new)->rb_right);
-		else
-			BUG(); /* this should not happen */
-	}
-	/* Add new node and rebalance tree. */
-	rb_link_node(&iova->node, parent, new);
-	rb_insert_color(&iova->node, root);
-}
-
 static struct kmem_cache *iova_cache;
 static unsigned int iova_cache_users;
 static DEFINE_MUTEX(iova_cache_mutex);
@@ -311,7 +289,7 @@
 	assert_spin_locked(&iovad->iova_rbtree_lock);
 
 	while (node) {
-		struct iova *iova = container_of(node, struct iova, node);
+		struct iova *iova = rb_entry(node, struct iova, node);
 
 		/* If pfn falls within iova's range, return iova */
 		if ((pfn >= iova->pfn_lo) && (pfn <= iova->pfn_hi)) {
@@ -463,7 +441,7 @@
 	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
 	node = rb_first(&iovad->rbroot);
 	while (node) {
-		struct iova *iova = container_of(node, struct iova, node);
+		struct iova *iova = rb_entry(node, struct iova, node);
 
 		rb_erase(node, &iovad->rbroot);
 		free_iova_mem(iova);
@@ -477,7 +455,7 @@
 __is_range_overlap(struct rb_node *node,
 	unsigned long pfn_lo, unsigned long pfn_hi)
 {
-	struct iova *iova = container_of(node, struct iova, node);
+	struct iova *iova = rb_entry(node, struct iova, node);
 
 	if ((pfn_lo <= iova->pfn_hi) && (pfn_hi >= iova->pfn_lo))
 		return 1;
@@ -506,7 +484,7 @@
 
 	iova = alloc_and_init_iova(pfn_lo, pfn_hi);
 	if (iova)
-		iova_insert_rbtree(&iovad->rbroot, iova);
+		iova_insert_rbtree(&iovad->rbroot, iova, NULL);
 
 	return iova;
 }
@@ -541,7 +519,7 @@
 	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
 	for (node = rb_first(&iovad->rbroot); node; node = rb_next(node)) {
 		if (__is_range_overlap(node, pfn_lo, pfn_hi)) {
-			iova = container_of(node, struct iova, node);
+			iova = rb_entry(node, struct iova, node);
 			__adjust_overlap_range(iova, &pfn_lo, &pfn_hi);
 			if ((pfn_lo >= iova->pfn_lo) &&
 				(pfn_hi <= iova->pfn_hi))
@@ -578,7 +556,7 @@
 
 	spin_lock_irqsave(&from->iova_rbtree_lock, flags);
 	for (node = rb_first(&from->rbroot); node; node = rb_next(node)) {
-		struct iova *iova = container_of(node, struct iova, node);
+		struct iova *iova = rb_entry(node, struct iova, node);
 		struct iova *new_iova;
 
 		new_iova = reserve_iova(to, iova->pfn_lo, iova->pfn_hi);
@@ -613,11 +591,11 @@
 	rb_erase(&iova->node, &iovad->rbroot);
 
 	if (prev) {
-		iova_insert_rbtree(&iovad->rbroot, prev);
+		iova_insert_rbtree(&iovad->rbroot, prev, NULL);
 		iova->pfn_lo = pfn_lo;
 	}
 	if (next) {
-		iova_insert_rbtree(&iovad->rbroot, next);
+		iova_insert_rbtree(&iovad->rbroot, next, NULL);
 		iova->pfn_hi = pfn_hi;
 	}
 	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 28b26c8..0565070 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -142,9 +142,9 @@
 	struct device_node *np;
 	void __iomem *regs;
 
-	np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc");
+	np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc");
 	if (!np)
-		np = of_find_compatible_node(root, NULL,
+		np = of_find_compatible_node(NULL, NULL,
 					     "atmel,at91sam9x5-rtc");
 
 	if (!np)
@@ -196,7 +196,6 @@
 		return;
 
 	match = of_match_node(matches, root);
-	of_node_put(root);
 
 	if (match) {
 		void (*fixup)(struct device_node *) = match->data;
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 779001e..01f9435 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -132,6 +132,45 @@
 }
 #endif
 
+/*
+ * gic_show_pending_irq - Shows the pending interrupts
+ * Note: Interrupts should be disabled on the cpu from which
+ * this is called to get accurate list of pending interrupts.
+ */
+void gic_show_pending_irqs(void)
+{
+	void __iomem *base;
+	u32 pending[32], enabled;
+	unsigned int j;
+
+	base = gic_data.dist_base;
+	for (j = 0; j * 32 < gic_data.irq_nr; j++) {
+		enabled = readl_relaxed(base +
+					GICD_ISENABLER + j * 4);
+		pending[j] = readl_relaxed(base +
+					GICD_ISPENDR + j * 4);
+		pending[j] &= enabled;
+		pr_err("Pending irqs[%d] %x\n", j, pending[j]);
+	}
+}
+
+/*
+ * get_gic_highpri_irq - Returns next high priority interrupt on current CPU
+ */
+unsigned int get_gic_highpri_irq(void)
+{
+	unsigned long flags;
+	unsigned int val = 0;
+
+	local_irq_save(flags);
+	val = read_gicreg(ICC_HPPIR1_EL1);
+	local_irq_restore(flags);
+
+	if (val >= 1020)
+		return 0;
+	return val;
+}
+
 static void gic_enable_redist(bool enable)
 {
 	void __iomem *rbase;
diff --git a/drivers/irqchip/irq-keystone.c b/drivers/irqchip/irq-keystone.c
index 54a5e87..efbcf84 100644
--- a/drivers/irqchip/irq-keystone.c
+++ b/drivers/irqchip/irq-keystone.c
@@ -19,9 +19,9 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/interrupt.h>
 #include <linux/irqdomain.h>
 #include <linux/irqchip.h>
-#include <linux/irqchip/chained_irq.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/mfd/syscon.h>
@@ -39,6 +39,7 @@
 	struct irq_domain	*irqd;
 	struct regmap		*devctrl_regs;
 	u32			devctrl_offset;
+	raw_spinlock_t		wa_lock;
 };
 
 static inline u32 keystone_irq_readl(struct keystone_irq_device *kirq)
@@ -83,17 +84,15 @@
 	/* nothing to do here */
 }
 
-static void keystone_irq_handler(struct irq_desc *desc)
+static irqreturn_t keystone_irq_handler(int irq, void *keystone_irq)
 {
-	unsigned int irq = irq_desc_get_irq(desc);
-	struct keystone_irq_device *kirq = irq_desc_get_handler_data(desc);
+	struct keystone_irq_device *kirq = keystone_irq;
+	unsigned long wa_lock_flags;
 	unsigned long pending;
 	int src, virq;
 
 	dev_dbg(kirq->dev, "start irq %d\n", irq);
 
-	chained_irq_enter(irq_desc_get_chip(desc), desc);
-
 	pending = keystone_irq_readl(kirq);
 	keystone_irq_writel(kirq, pending);
 
@@ -111,13 +110,15 @@
 			if (!virq)
 				dev_warn(kirq->dev, "spurious irq detected hwirq %d, virq %d\n",
 					 src, virq);
+			raw_spin_lock_irqsave(&kirq->wa_lock, wa_lock_flags);
 			generic_handle_irq(virq);
+			raw_spin_unlock_irqrestore(&kirq->wa_lock,
+						   wa_lock_flags);
 		}
 	}
 
-	chained_irq_exit(irq_desc_get_chip(desc), desc);
-
 	dev_dbg(kirq->dev, "end irq %d\n", irq);
+	return IRQ_HANDLED;
 }
 
 static int keystone_irq_map(struct irq_domain *h, unsigned int virq,
@@ -182,9 +183,16 @@
 		return -ENODEV;
 	}
 
+	raw_spin_lock_init(&kirq->wa_lock);
+
 	platform_set_drvdata(pdev, kirq);
 
-	irq_set_chained_handler_and_data(kirq->irq, keystone_irq_handler, kirq);
+	ret = request_irq(kirq->irq, keystone_irq_handler,
+			  0, dev_name(dev), kirq);
+	if (ret) {
+		irq_domain_remove(kirq->irqd);
+		return ret;
+	}
 
 	/* clear all source bits */
 	keystone_irq_writel(kirq, ~0x0);
@@ -199,6 +207,8 @@
 	struct keystone_irq_device *kirq = platform_get_drvdata(pdev);
 	int hwirq;
 
+	free_irq(kirq->irq, kirq);
+
 	for (hwirq = 0; hwirq < KEYSTONE_N_IRQ; hwirq++)
 		irq_dispose_mapping(irq_find_mapping(kirq->irqd, hwirq));
 
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index c0178a1..d74374f 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -1115,8 +1115,11 @@
 		gic_len = resource_size(&res);
 	}
 
-	if (mips_cm_present())
+	if (mips_cm_present()) {
 		write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK);
+		/* Ensure GIC region is enabled before trying to access it */
+		__sync();
+	}
 	gic_present = true;
 
 	__gic_init(gic_base, gic_len, cpu_vec, 0, node);
diff --git a/drivers/irqchip/irq-mxs.c b/drivers/irqchip/irq-mxs.c
index 1730470..05fa9f7 100644
--- a/drivers/irqchip/irq-mxs.c
+++ b/drivers/irqchip/irq-mxs.c
@@ -131,12 +131,16 @@
 	.irq_ack = icoll_ack_irq,
 	.irq_mask = icoll_mask_irq,
 	.irq_unmask = icoll_unmask_irq,
+	.flags = IRQCHIP_MASK_ON_SUSPEND |
+		 IRQCHIP_SKIP_SET_WAKE,
 };
 
 static struct irq_chip asm9260_icoll_chip = {
 	.irq_ack = icoll_ack_irq,
 	.irq_mask = asm9260_mask_irq,
 	.irq_unmask = asm9260_unmask_irq,
+	.flags = IRQCHIP_MASK_ON_SUSPEND |
+		 IRQCHIP_SKIP_SET_WAKE,
 };
 
 asmlinkage void __exception_irq_entry icoll_handle_irq(struct pt_regs *regs)
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 9b856e1..e4c43a1 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1379,6 +1379,7 @@
 			if (arg) {
 				if (copy_from_user(bname, argp, sizeof(bname) - 1))
 					return -EFAULT;
+				bname[sizeof(bname)-1] = 0;
 			} else
 				return -EINVAL;
 			ret = mutex_lock_interruptible(&dev->mtx);
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index c151c6d..f63a110 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2611,10 +2611,9 @@
 	char newname[10];
 
 	if (p) {
-		/* Slave-Name MUST not be empty */
-		if (!strlen(p + 1))
+		/* Slave-Name MUST not be empty or overflow 'newname' */
+		if (strscpy(newname, p + 1, sizeof(newname)) <= 0)
 			return NULL;
-		strcpy(newname, p + 1);
 		*p = 0;
 		/* Master must already exist */
 		if (!(n = isdn_net_findif(parm)))
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 9c1e8ad..bf3fbd0 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -2364,7 +2364,7 @@
 		       id);
 		return NULL;
 	} else {
-		rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
+		rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_ATOMIC);
 		if (!rs)
 			return NULL;
 		rs->state = CCPResetIdle;
diff --git a/drivers/leds/leds-qpnp-wled.c b/drivers/leds/leds-qpnp-wled.c
index 568c9f9..5c9c75c 100644
--- a/drivers/leds/leds-qpnp-wled.c
+++ b/drivers/leds/leds-qpnp-wled.c
@@ -123,6 +123,7 @@
 #define QPNP_WLED_ILIM_FAULT_BIT	BIT(0)
 #define QPNP_WLED_OVP_FAULT_BIT		BIT(1)
 #define QPNP_WLED_SC_FAULT_BIT		BIT(2)
+#define QPNP_WLED_OVP_FLT_RT_STS_BIT	BIT(1)
 
 /* sink registers */
 #define QPNP_WLED_CURR_SINK_REG(b)	(b + 0x46)
@@ -1103,14 +1104,6 @@
 	int rc = 0, i;
 	u8 reg = 0, sink_config = 0, sink_test = 0, sink_valid = 0, int_sts;
 
-	mutex_lock(&wled->lock);
-
-	/* disable OVP IRQ */
-	if (wled->ovp_irq > 0 && !wled->ovp_irq_disabled) {
-		disable_irq_nosync(wled->ovp_irq);
-		wled->ovp_irq_disabled = true;
-	}
-
 	/* read configured sink configuration */
 	rc = qpnp_wled_read_reg(wled,
 		QPNP_WLED_CURR_SINK_REG(wled->sink_base), &sink_config);
@@ -1259,7 +1252,8 @@
 	}
 
 	/* restore  brightness */
-	rc = qpnp_wled_set_level(wled, wled->cdev.brightness);
+	rc = qpnp_wled_set_level(wled, !wled->cdev.brightness ?
+			AUTO_CALIB_BRIGHTNESS : wled->cdev.brightness);
 	if (rc < 0) {
 		pr_err("Failed to set brightness after calibration rc=%d\n",
 						rc);
@@ -1280,11 +1274,6 @@
 			QPNP_WLED_SOFT_START_DLY_US + 1000);
 
 failed_calib:
-	if (wled->ovp_irq > 0 && wled->ovp_irq_disabled) {
-		enable_irq(wled->ovp_irq);
-		wled->ovp_irq_disabled = false;
-	}
-	mutex_unlock(&wled->lock);
 	return rc;
 }
 
@@ -1320,6 +1309,38 @@
 	return false;
 }
 
+static int qpnp_wled_auto_calibrate_at_init(struct qpnp_wled *wled)
+{
+	int rc;
+	u8 fault_status = 0, rt_status = 0;
+
+	if (!wled->auto_calib_enabled)
+		return 0;
+
+	rc = qpnp_wled_read_reg(wled,
+			QPNP_WLED_INT_RT_STS(wled->ctrl_base), &rt_status);
+	if (rc < 0)
+		pr_err("Failed to read RT status rc=%d\n", rc);
+
+	rc = qpnp_wled_read_reg(wled,
+			QPNP_WLED_FAULT_STATUS(wled->ctrl_base), &fault_status);
+	if (rc < 0)
+		pr_err("Failed to read fault status rc=%d\n", rc);
+
+	if ((rt_status & QPNP_WLED_OVP_FLT_RT_STS_BIT) ||
+			(fault_status & QPNP_WLED_OVP_FAULT_BIT)) {
+		mutex_lock(&wled->lock);
+		rc = wled_auto_calibrate(wled);
+		if (rc < 0)
+			pr_err("Failed auto-calibration rc=%d\n", rc);
+		else
+			wled->auto_calib_done = true;
+		mutex_unlock(&wled->lock);
+	}
+
+	return rc;
+}
+
 /* ovp irq handler */
 static irqreturn_t qpnp_wled_ovp_irq_handler(int irq, void *_wled)
 {
@@ -1348,13 +1369,26 @@
 	if (fault_sts & QPNP_WLED_OVP_FAULT_BIT) {
 		if (wled->auto_calib_enabled && !wled->auto_calib_done) {
 			if (qpnp_wled_auto_cal_required(wled)) {
-				rc = wled_auto_calibrate(wled);
-				if (rc < 0) {
-					pr_err("Failed auto-calibration rc=%d\n",
-							rc);
-					return IRQ_HANDLED;
+				mutex_lock(&wled->lock);
+				if (wled->ovp_irq > 0 &&
+						!wled->ovp_irq_disabled) {
+					disable_irq_nosync(wled->ovp_irq);
+					wled->ovp_irq_disabled = true;
 				}
-				wled->auto_calib_done = true;
+
+				rc = wled_auto_calibrate(wled);
+				if (rc < 0)
+					pr_err("Failed auto-calibration rc=%d\n",
+								rc);
+				else
+					wled->auto_calib_done = true;
+
+				if (wled->ovp_irq > 0 &&
+						wled->ovp_irq_disabled) {
+					enable_irq(wled->ovp_irq);
+					wled->ovp_irq_disabled = false;
+				}
+				mutex_unlock(&wled->lock);
 			}
 		}
 	}
@@ -1946,6 +1980,10 @@
 		return rc;
 	}
 
+	rc = qpnp_wled_auto_calibrate_at_init(wled);
+	if (rc < 0)
+		pr_err("Failed to auto-calibrate at init rc=%d\n", rc);
+
 	/* setup ovp and sc irqs */
 	if (wled->ovp_irq >= 0) {
 		rc = devm_request_threaded_irq(&wled->pdev->dev, wled->ovp_irq,
diff --git a/drivers/leds/leds-qpnp.c b/drivers/leds/leds-qpnp.c
index 817dfa3..e3cfffb 100644
--- a/drivers/leds/leds-qpnp.c
+++ b/drivers/leds/leds-qpnp.c
@@ -875,6 +875,14 @@
 		}
 		if (led->mpp_cfg->pwm_mode == PWM_MODE) {
 			/*config pwm for brightness scaling*/
+			rc = pwm_change_mode(led->mpp_cfg->pwm_cfg->pwm_dev,
+					PM_PWM_MODE_PWM);
+			if (rc < 0) {
+				dev_err(&led->pdev->dev,
+					"Failed to set PWM mode, rc = %d\n",
+					rc);
+				return rc;
+			}
 			period_us = led->mpp_cfg->pwm_cfg->pwm_period_us;
 			if (period_us > INT_MAX / NSEC_PER_USEC) {
 				duty_us = (period_us * led->cdev.brightness) /
@@ -1213,7 +1221,7 @@
 
 static int qpnp_flash_set(struct qpnp_led_data *led)
 {
-	int rc, error;
+	int rc = 0, error;
 	int val = led->cdev.brightness;
 
 	if (led->flash_cfg->torch_enable)
@@ -1251,7 +1259,8 @@
 				}
 			}
 
-			qpnp_led_masked_write(led, FLASH_MAX_CURR(led->base),
+			rc = qpnp_led_masked_write(led,
+				FLASH_MAX_CURR(led->base),
 				FLASH_CURRENT_MASK,
 				TORCH_MAX_LEVEL);
 			if (rc) {
@@ -1261,7 +1270,7 @@
 				goto error_reg_write;
 			}
 
-			qpnp_led_masked_write(led,
+			rc = qpnp_led_masked_write(led,
 				FLASH_LED_TMR_CTRL(led->base),
 				FLASH_TMR_MASK,
 				FLASH_TMR_WATCHDOG);
@@ -1293,7 +1302,7 @@
 				goto error_reg_write;
 			}
 
-			qpnp_led_masked_write(led,
+			rc = qpnp_led_masked_write(led,
 				FLASH_WATCHDOG_TMR(led->base),
 				FLASH_WATCHDOG_MASK,
 				led->flash_cfg->duration);
@@ -1341,7 +1350,7 @@
 				goto error_flash_set;
 			}
 
-			qpnp_led_masked_write(led,
+			rc = qpnp_led_masked_write(led,
 				FLASH_LED_TMR_CTRL(led->base),
 				FLASH_TMR_MASK,
 				FLASH_TMR_SAFETY);
@@ -1580,6 +1589,14 @@
 		}
 
 		if (led->kpdbl_cfg->pwm_cfg->mode == PWM_MODE) {
+			rc = pwm_change_mode(led->kpdbl_cfg->pwm_cfg->pwm_dev,
+					PM_PWM_MODE_PWM);
+			if (rc < 0) {
+				dev_err(&led->pdev->dev,
+					"Failed to set PWM mode, rc = %d\n",
+					rc);
+				return rc;
+			}
 			period_us = led->kpdbl_cfg->pwm_cfg->pwm_period_us;
 			if (period_us > INT_MAX / NSEC_PER_USEC) {
 				duty_us = (period_us * led->cdev.brightness) /
@@ -1701,6 +1718,14 @@
 			led->rgb_cfg->pwm_cfg->mode =
 				led->rgb_cfg->pwm_cfg->default_mode;
 		if (led->rgb_cfg->pwm_cfg->mode == PWM_MODE) {
+			rc = pwm_change_mode(led->rgb_cfg->pwm_cfg->pwm_dev,
+					PM_PWM_MODE_PWM);
+			if (rc < 0) {
+				dev_err(&led->pdev->dev,
+					"Failed to set PWM mode, rc = %d\n",
+					rc);
+				return rc;
+			}
 			period_us = led->rgb_cfg->pwm_cfg->pwm_period_us;
 			if (period_us > INT_MAX / NSEC_PER_USEC) {
 				duty_us = (period_us * led->cdev.brightness) /
@@ -2135,6 +2160,11 @@
 				dev_err(&pdev->dev, "Failed to configure pwm LUT\n");
 				return rc;
 			}
+			rc = pwm_change_mode(pwm_cfg->pwm_dev, PM_PWM_MODE_LPG);
+			if (rc < 0) {
+				dev_err(&pdev->dev, "Failed to set LPG mode\n");
+				return rc;
+			}
 		}
 	} else {
 		dev_err(&pdev->dev, "Invalid PWM device\n");
diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c
index c9f3862..410c39c 100644
--- a/drivers/leds/trigger/ledtrig-heartbeat.c
+++ b/drivers/leds/trigger/ledtrig-heartbeat.c
@@ -19,7 +19,6 @@
 #include <linux/sched.h>
 #include <linux/leds.h>
 #include <linux/reboot.h>
-#include <linux/suspend.h>
 #include "../leds.h"
 
 static int panic_heartbeats;
@@ -155,30 +154,6 @@
 	.deactivate = heartbeat_trig_deactivate,
 };
 
-static int heartbeat_pm_notifier(struct notifier_block *nb,
-				 unsigned long pm_event, void *unused)
-{
-	int rc;
-
-	switch (pm_event) {
-	case PM_SUSPEND_PREPARE:
-	case PM_HIBERNATION_PREPARE:
-	case PM_RESTORE_PREPARE:
-		led_trigger_unregister(&heartbeat_led_trigger);
-		break;
-	case PM_POST_SUSPEND:
-	case PM_POST_HIBERNATION:
-	case PM_POST_RESTORE:
-		rc = led_trigger_register(&heartbeat_led_trigger);
-		if (rc)
-			pr_err("could not re-register heartbeat trigger\n");
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_DONE;
-}
-
 static int heartbeat_reboot_notifier(struct notifier_block *nb,
 				     unsigned long code, void *unused)
 {
@@ -193,10 +168,6 @@
 	return NOTIFY_DONE;
 }
 
-static struct notifier_block heartbeat_pm_nb = {
-	.notifier_call = heartbeat_pm_notifier,
-};
-
 static struct notifier_block heartbeat_reboot_nb = {
 	.notifier_call = heartbeat_reboot_notifier,
 };
@@ -213,14 +184,12 @@
 		atomic_notifier_chain_register(&panic_notifier_list,
 					       &heartbeat_panic_nb);
 		register_reboot_notifier(&heartbeat_reboot_nb);
-		register_pm_notifier(&heartbeat_pm_nb);
 	}
 	return rc;
 }
 
 static void __exit heartbeat_trig_exit(void)
 {
-	unregister_pm_notifier(&heartbeat_pm_nb);
 	unregister_reboot_notifier(&heartbeat_reboot_nb);
 	atomic_notifier_chain_unregister(&panic_notifier_list,
 					 &heartbeat_panic_nb);
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 3c811d3..63949b7 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -30,6 +30,6 @@
 
 obj-$(CONFIG_BCM_PDC_MBOX)	+= bcm-pdc-mailbox.o
 
-obj-$(CONFIG_QTI_RPMH_MBOX)	+= qti-tcs.o
+obj-$(CONFIG_QTI_RPMH_MBOX)	+= qcom-rpmh-mailbox.o
 
 obj-$(CONFIG_MSM_QMP)	+= msm_qmp.o
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 3989bc6..9f340bf 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -115,11 +115,14 @@
 	/* Submit next message */
 	msg_submit(chan);
 
+	if (!mssg)
+		return;
+
 	/* Notify the client */
-	if (mssg && chan->cl->tx_done)
+	if (chan->cl->tx_done)
 		chan->cl->tx_done(chan->cl, mssg, r);
 
-	if (chan->cl->tx_block)
+	if (r != -ETIME && chan->cl->tx_block)
 		complete(&chan->tx_complete);
 }
 
@@ -272,7 +275,7 @@
 
 	msg_submit(chan);
 
-	if (chan->cl->tx_block && chan->active_req) {
+	if (chan->cl->tx_block) {
 		unsigned long wait;
 		int ret;
 
@@ -283,8 +286,8 @@
 
 		ret = wait_for_completion_timeout(&chan->tx_complete, wait);
 		if (ret == 0) {
-			t = -EIO;
-			tx_tick(chan, -EIO);
+			t = -ETIME;
+			tx_tick(chan, t);
 		}
 	}
 
@@ -293,8 +296,9 @@
 EXPORT_SYMBOL_GPL(mbox_send_message);
 
 /**
- * mbox_send_controller_data-	For client to submit a message to be
- *				sent only to the controller.
+ * mbox_write_controller_data -	For client to submit a message to be
+ *				written to the controller but not sent to
+ *				the remote processor.
  * @chan: Mailbox channel assigned to this client.
  * @mssg: Client specific message typecasted.
  *
@@ -305,7 +309,7 @@
  *	or transmission over chan (blocking mode).
  *	Negative value denotes failure.
  */
-int mbox_send_controller_data(struct mbox_chan *chan, void *mssg)
+int mbox_write_controller_data(struct mbox_chan *chan, void *mssg)
 {
 	unsigned long flags;
 	int err;
@@ -314,12 +318,12 @@
 		return -EINVAL;
 
 	spin_lock_irqsave(&chan->lock, flags);
-	err = chan->mbox->ops->send_controller_data(chan, mssg);
+	err = chan->mbox->ops->write_controller_data(chan, mssg);
 	spin_unlock_irqrestore(&chan->lock, flags);
 
 	return err;
 }
-EXPORT_SYMBOL(mbox_send_controller_data);
+EXPORT_SYMBOL(mbox_write_controller_data);
 
 bool mbox_controller_is_idle(struct mbox_chan *chan)
 {
diff --git a/drivers/mailbox/msm_qmp.c b/drivers/mailbox/msm_qmp.c
index f0bb0bc..d6e41ae 100644
--- a/drivers/mailbox/msm_qmp.c
+++ b/drivers/mailbox/msm_qmp.c
@@ -27,7 +27,7 @@
 #define QMP_VERSION	0x1
 #define QMP_FEATURES	0x0
 #define QMP_TOUT_MS	5000
-#define QMP_TX_TOUT_MS	2000
+#define QMP_TX_TOUT_MS	1000
 
 #define QMP_MBOX_LINK_DOWN		0xFFFF0000
 #define QMP_MBOX_LINK_UP		0x0000FFFF
@@ -229,7 +229,7 @@
 }
 
 /**
- * qmp_notify_timeout() - Notify client of tx timeout with -EIO
+ * qmp_notify_timeout() - Notify client of tx timeout with -ETIME
  * @work:	Structure for work that was scheduled.
  */
 static void qmp_notify_timeout(struct work_struct *work)
@@ -237,7 +237,7 @@
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct qmp_mbox *mbox = container_of(dwork, struct qmp_mbox, dwork);
 	struct mbox_chan *chan = &mbox->ctrl.chans[mbox->idx_in_flight];
-	int err = -EIO;
+	int err = -ETIME;
 	unsigned long flags;
 
 	spin_lock_irqsave(&mbox->tx_lock, flags);
@@ -246,6 +246,7 @@
 		return;
 	}
 	pr_err("%s: qmp tx timeout for %d\n", __func__, mbox->idx_in_flight);
+	iowrite32(0, mbox->mdev->msgram + mbox->mcore_mbox_offset);
 	mbox->tx_sent = false;
 	spin_unlock_irqrestore(&mbox->tx_lock, flags);
 	mbox_chan_txdone(chan, err);
@@ -358,7 +359,7 @@
 	addr = mdev->msgram + mbox->mcore_mbox_offset;
 	if (mbox->tx_sent) {
 		spin_unlock_irqrestore(&mbox->tx_lock, flags);
-		return -EBUSY;
+		return -EAGAIN;
 	}
 
 	if (pkt->size + sizeof(pkt->size) > mbox->mcore_mbox_size) {
diff --git a/drivers/mailbox/qti-tcs.c b/drivers/mailbox/qcom-rpmh-mailbox.c
similarity index 84%
rename from drivers/mailbox/qti-tcs.c
rename to drivers/mailbox/qcom-rpmh-mailbox.c
index f923db5..7bf8a18 100644
--- a/drivers/mailbox/qti-tcs.c
+++ b/drivers/mailbox/qcom-rpmh-mailbox.c
@@ -41,14 +41,14 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/rpmh.h>
 
-#define TCS_DRV_IPC_LOG_SIZE		2
+#define RSC_DRV_IPC_LOG_SIZE		2
 
 #define MAX_CMDS_PER_TCS		16
 #define MAX_TCS_PER_TYPE		3
 #define MAX_TCS_SLOTS			(MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
 
-#define TCS_DRV_TCS_OFFSET		672
-#define TCS_DRV_CMD_OFFSET		20
+#define RSC_DRV_TCS_OFFSET		672
+#define RSC_DRV_CMD_OFFSET		20
 
 /* DRV Configuration Information Register */
 #define DRV_PRNT_CHLD_CONFIG		0x0C
@@ -58,18 +58,18 @@
 #define DRV_NCPT_SHIFT			27
 
 /* Register offsets */
-#define TCS_DRV_IRQ_ENABLE		0x00
-#define TCS_DRV_IRQ_STATUS		0x04
-#define TCS_DRV_IRQ_CLEAR		0x08
-#define TCS_DRV_CMD_WAIT_FOR_CMPL	0x10
-#define TCS_DRV_CONTROL			0x14
-#define TCS_DRV_STATUS			0x18
-#define TCS_DRV_CMD_ENABLE		0x1C
-#define TCS_DRV_CMD_MSGID		0x30
-#define TCS_DRV_CMD_ADDR		0x34
-#define TCS_DRV_CMD_DATA		0x38
-#define TCS_DRV_CMD_STATUS		0x3C
-#define TCS_DRV_CMD_RESP_DATA		0x40
+#define RSC_DRV_IRQ_ENABLE		0x00
+#define RSC_DRV_IRQ_STATUS		0x04
+#define RSC_DRV_IRQ_CLEAR		0x08
+#define RSC_DRV_CMD_WAIT_FOR_CMPL	0x10
+#define RSC_DRV_CONTROL			0x14
+#define RSC_DRV_STATUS			0x18
+#define RSC_DRV_CMD_ENABLE		0x1C
+#define RSC_DRV_CMD_MSGID		0x30
+#define RSC_DRV_CMD_ADDR		0x34
+#define RSC_DRV_CMD_DATA		0x38
+#define RSC_DRV_CMD_STATUS		0x3C
+#define RSC_DRV_CMD_RESP_DATA		0x40
 
 #define TCS_AMC_MODE_ENABLE		BIT(16)
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
@@ -90,10 +90,10 @@
 #define MAX_POOL_SIZE			(MAX_TCS_PER_TYPE * TCS_TYPE_NR)
 #define TCS_M_INIT			0xFFFF
 
-struct tcs_drv;
+struct rsc_drv;
 
 struct tcs_response {
-	struct tcs_drv *drv;
+	struct rsc_drv *drv;
 	struct mbox_chan *chan;
 	struct tcs_mbox_msg *msg;
 	u32 m; /* m-th TCS */
@@ -111,7 +111,7 @@
 
 /* One per TCS type of a controller */
 struct tcs_mbox {
-	struct tcs_drv *drv;
+	struct rsc_drv *drv;
 	u32 *cmd_addr;
 	int type;
 	u32 tcs_mask;
@@ -123,7 +123,7 @@
 };
 
 /* One per MBOX controller */
-struct tcs_drv {
+struct rsc_drv {
 	struct mbox_controller mbox;
 	const char *name;
 	void __iomem *base; /* start address of the RSC's registers */
@@ -172,7 +172,7 @@
 	} while (0)
 
 
-static int tcs_response_pool_init(struct tcs_drv *drv)
+static int tcs_response_pool_init(struct rsc_drv *drv)
 {
 	struct tcs_response_pool *pool;
 	int i;
@@ -194,7 +194,7 @@
 	return 0;
 }
 
-static struct tcs_response *setup_response(struct tcs_drv *drv,
+static struct tcs_response *setup_response(struct rsc_drv *drv,
 		struct tcs_mbox_msg *msg, struct mbox_chan *chan,
 		u32 m, int err)
 {
@@ -233,7 +233,7 @@
 	spin_unlock_irqrestore(&pool->lock, flags);
 }
 
-static inline struct tcs_response *get_response(struct tcs_drv *drv, u32 m,
+static inline struct tcs_response *get_response(struct rsc_drv *drv, u32 m,
 					bool for_use)
 {
 	struct tcs_response_pool *pool = drv->resp_pool;
@@ -259,7 +259,7 @@
 	return resp;
 }
 
-static void print_response(struct tcs_drv *drv, int m)
+static void print_response(struct rsc_drv *drv, int m)
 {
 	struct tcs_response *resp;
 	struct tcs_mbox_msg *msg;
@@ -288,14 +288,14 @@
 static inline u32 read_tcs_reg(void __iomem *base, int reg, int m, int n)
 {
 	return le32_to_cpu(readl_relaxed(base + reg +
-			TCS_DRV_TCS_OFFSET * m + TCS_DRV_CMD_OFFSET * n));
+			RSC_DRV_TCS_OFFSET * m + RSC_DRV_CMD_OFFSET * n));
 }
 
 static inline void write_tcs_reg(void __iomem *base, int reg, int m, int n,
 				u32 data)
 {
 	writel_relaxed(cpu_to_le32(data), base + reg +
-			TCS_DRV_TCS_OFFSET * m + TCS_DRV_CMD_OFFSET * n);
+			RSC_DRV_TCS_OFFSET * m + RSC_DRV_CMD_OFFSET * n);
 }
 
 static inline void write_tcs_reg_sync(void __iomem *base, int reg, int m, int n,
@@ -309,15 +309,15 @@
 	} while (1);
 }
 
-static inline bool tcs_is_free(struct tcs_drv *drv, int m)
+static inline bool tcs_is_free(struct rsc_drv *drv, int m)
 {
 	void __iomem *base = drv->reg_base;
 
-	return read_tcs_reg(base, TCS_DRV_STATUS, m, 0) &&
+	return read_tcs_reg(base, RSC_DRV_STATUS, m, 0) &&
 			!atomic_read(&drv->tcs_in_use[m]);
 }
 
-static inline struct tcs_mbox *get_tcs_from_index(struct tcs_drv *drv, int m)
+static inline struct tcs_mbox *get_tcs_from_index(struct rsc_drv *drv, int m)
 {
 	struct tcs_mbox *tcs = NULL;
 	int i;
@@ -336,7 +336,7 @@
 	return tcs;
 }
 
-static inline struct tcs_mbox *get_tcs_of_type(struct tcs_drv *drv, int type)
+static inline struct tcs_mbox *get_tcs_of_type(struct rsc_drv *drv, int type)
 {
 	int i;
 	struct tcs_mbox *tcs;
@@ -355,7 +355,7 @@
 	return tcs;
 }
 
-static inline struct tcs_mbox *get_tcs_for_msg(struct tcs_drv *drv,
+static inline struct tcs_mbox *get_tcs_for_msg(struct rsc_drv *drv,
 						struct tcs_mbox_msg *msg)
 {
 	int type = -1;
@@ -394,7 +394,7 @@
 
 static inline void send_tcs_response(struct tcs_response *resp)
 {
-	struct tcs_drv *drv = resp->drv;
+	struct rsc_drv *drv = resp->drv;
 	unsigned long flags;
 
 	spin_lock_irqsave(&drv->drv_lock, flags);
@@ -405,18 +405,18 @@
 	tasklet_schedule(&drv->tasklet);
 }
 
-static inline void enable_tcs_irq(struct tcs_drv *drv, int m, bool enable)
+static inline void enable_tcs_irq(struct rsc_drv *drv, int m, bool enable)
 {
 	void __iomem *base = drv->reg_base;
 	u32 data;
 
 	/* Enable interrupts for non-ACTIVE TCS */
-	data = read_tcs_reg(base, TCS_DRV_IRQ_ENABLE, 0, 0);
+	data = read_tcs_reg(base, RSC_DRV_IRQ_ENABLE, 0, 0);
 	if (enable)
 		data |= BIT(m);
 	else
 		data &= ~BIT(m);
-	write_tcs_reg(base, TCS_DRV_IRQ_ENABLE, 0, 0, data);
+	write_tcs_reg(base, RSC_DRV_IRQ_ENABLE, 0, 0, data);
 }
 
 /**
@@ -424,7 +424,7 @@
  */
 static irqreturn_t tcs_irq_handler(int irq, void *p)
 {
-	struct tcs_drv *drv = p;
+	struct rsc_drv *drv = p;
 	void __iomem *base = drv->reg_base;
 	int m, i;
 	u32 irq_status, sts;
@@ -434,7 +434,7 @@
 	u32 data;
 
 	/* Know which TCSes were triggered */
-	irq_status = read_tcs_reg(base, TCS_DRV_IRQ_STATUS, 0, 0);
+	irq_status = read_tcs_reg(base, RSC_DRV_IRQ_STATUS, 0, 0);
 
 	for (m = 0; m < drv->num_tcs; m++) {
 		if (!(irq_status & (u32)BIT(m)))
@@ -451,7 +451,7 @@
 		resp->err = 0;
 		for (i = 0; i < resp->msg->num_payload; i++) {
 			cmd = &resp->msg->payload[i];
-			sts = read_tcs_reg(base, TCS_DRV_CMD_STATUS, m, i);
+			sts = read_tcs_reg(base, RSC_DRV_CMD_STATUS, m, i);
 			if ((!(sts & CMD_STATUS_ISSUED)) ||
 				((resp->msg->is_complete || cmd->complete) &&
 				(!(sts & CMD_STATUS_COMPL)))) {
@@ -463,7 +463,7 @@
 		/* Check for response if this was a read request */
 		if (resp->msg->is_read) {
 			/* Respond the data back in the same req data */
-			data = read_tcs_reg(base, TCS_DRV_CMD_RESP_DATA, m, 0);
+			data = read_tcs_reg(base, RSC_DRV_CMD_RESP_DATA, m, 0);
 			resp->msg->payload[0].data = data;
 			mbox_chan_received_data(resp->chan, resp->msg);
 		}
@@ -474,11 +474,11 @@
 		/* Clear the AMC mode for non-ACTIVE TCSes */
 		tcs = get_tcs_from_index(drv, m);
 		if (tcs && tcs->type != ACTIVE_TCS) {
-			data = read_tcs_reg(base, TCS_DRV_CONTROL, m, 0);
+			data = read_tcs_reg(base, RSC_DRV_CONTROL, m, 0);
 			data &= ~TCS_AMC_MODE_TRIGGER;
-			write_tcs_reg_sync(base, TCS_DRV_CONTROL, m, 0, data);
+			write_tcs_reg_sync(base, RSC_DRV_CONTROL, m, 0, data);
 			data &= ~TCS_AMC_MODE_ENABLE;
-			write_tcs_reg(base, TCS_DRV_CONTROL, m, 0, data);
+			write_tcs_reg(base, RSC_DRV_CONTROL, m, 0, data);
 			/*
 			 * Disable interrupt for this TCS to avoid being
 			 * spammed with interrupts coming when the solver
@@ -487,7 +487,7 @@
 			enable_tcs_irq(drv, m, false);
 		} else {
 			/* Clear the enable bit for the commands */
-			write_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0, 0);
+			write_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0, 0);
 		}
 
 no_resp:
@@ -495,7 +495,7 @@
 		drv->tcs_last_recv_ts[m] = arch_counter_get_cntvct();
 
 		/* Clear the TCS IRQ status */
-		write_tcs_reg(base, TCS_DRV_IRQ_CLEAR, 0, 0, BIT(m));
+		write_tcs_reg(base, RSC_DRV_IRQ_CLEAR, 0, 0, BIT(m));
 
 		/* Notify the client that this request is completed. */
 		atomic_set(&drv->tcs_in_use[m], 0);
@@ -511,7 +511,7 @@
 static inline void mbox_notify_tx_done(struct mbox_chan *chan,
 				struct tcs_mbox_msg *msg, int m, int err)
 {
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 
 	log_rpmh_notify(drv, m, msg->payload[0].addr, err);
 	mbox_chan_txdone(chan, err);
@@ -533,7 +533,7 @@
  */
 static void tcs_notify_tx_done(unsigned long data)
 {
-	struct tcs_drv *drv = (struct tcs_drv *)data;
+	struct rsc_drv *drv = (struct rsc_drv *)data;
 	struct tcs_response *resp;
 	unsigned long flags;
 
@@ -551,7 +551,7 @@
 	} while (1);
 }
 
-static void __tcs_buffer_write(struct tcs_drv *drv, int d, int m, int n,
+static void __tcs_buffer_write(struct rsc_drv *drv, int d, int m, int n,
 			struct tcs_mbox_msg *msg, bool trigger)
 {
 	u32 msgid, cmd_msgid = 0;
@@ -568,7 +568,7 @@
 	cmd_msgid |= (!msg->is_read) ? CMD_MSGID_WRITE : 0;
 
 	/* Read the send-after-prev complete flag for those already in TCS */
-	cmd_complete = read_tcs_reg(base, TCS_DRV_CMD_WAIT_FOR_CMPL, m, 0);
+	cmd_complete = read_tcs_reg(base, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0);
 
 	for (i = 0; i < msg->num_payload; i++) {
 		cmd = &msg->payload[i];
@@ -576,19 +576,19 @@
 		cmd_complete |= cmd->complete << (n + i);
 		msgid = cmd_msgid;
 		msgid |= (cmd->complete) ? CMD_MSGID_RESP_REQ : 0;
-		write_tcs_reg(base, TCS_DRV_CMD_MSGID, m, n + i, msgid);
-		write_tcs_reg(base, TCS_DRV_CMD_ADDR, m, n + i, cmd->addr);
-		write_tcs_reg(base, TCS_DRV_CMD_DATA, m, n + i, cmd->data);
+		write_tcs_reg(base, RSC_DRV_CMD_MSGID, m, n + i, msgid);
+		write_tcs_reg(base, RSC_DRV_CMD_ADDR, m, n + i, cmd->addr);
+		write_tcs_reg(base, RSC_DRV_CMD_DATA, m, n + i, cmd->data);
 		log_send_msg(drv, m, n + i, msgid, cmd->addr,
 					cmd->data, cmd->complete, trigger);
 	}
 
 	/* Write the send-after-prev completion bits for the batch */
-	write_tcs_reg(base, TCS_DRV_CMD_WAIT_FOR_CMPL, m, 0, cmd_complete);
+	write_tcs_reg(base, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0, cmd_complete);
 
 	/* Enable the new commands in TCS */
-	cmd_enable |= read_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0);
-	write_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0, cmd_enable);
+	cmd_enable |= read_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0);
+	write_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0, cmd_enable);
 
 	if (trigger) {
 		/*
@@ -596,31 +596,31 @@
 		 * While clearing ensure that the AMC mode trigger is cleared
 		 * and then the mode enable is cleared.
 		 */
-		enable = read_tcs_reg(base, TCS_DRV_CONTROL, m, 0);
+		enable = read_tcs_reg(base, RSC_DRV_CONTROL, m, 0);
 		enable &= ~TCS_AMC_MODE_TRIGGER;
-		write_tcs_reg_sync(base, TCS_DRV_CONTROL, m, 0, enable);
+		write_tcs_reg_sync(base, RSC_DRV_CONTROL, m, 0, enable);
 		enable &= ~TCS_AMC_MODE_ENABLE;
-		write_tcs_reg_sync(base, TCS_DRV_CONTROL, m, 0, enable);
+		write_tcs_reg_sync(base, RSC_DRV_CONTROL, m, 0, enable);
 
 		/* Enable the AMC mode on the TCS and then trigger the TCS */
 		enable = TCS_AMC_MODE_ENABLE;
-		write_tcs_reg_sync(base, TCS_DRV_CONTROL, m, 0, enable);
+		write_tcs_reg_sync(base, RSC_DRV_CONTROL, m, 0, enable);
 		enable |= TCS_AMC_MODE_TRIGGER;
-		write_tcs_reg(base, TCS_DRV_CONTROL, m, 0, enable);
+		write_tcs_reg(base, RSC_DRV_CONTROL, m, 0, enable);
 	}
 }
 
 /**
- * tcs_drv_is_idle: Check if any of the AMCs are busy.
+ * rsc_drv_is_idle: Check if any of the AMCs are busy.
  *
  * @mbox: The mailbox controller.
  *
  * Returns true if the AMCs are not engaged or absent.
  */
-static bool tcs_drv_is_idle(struct mbox_controller *mbox)
+static bool rsc_drv_is_idle(struct mbox_controller *mbox)
 {
 	int m;
-	struct tcs_drv *drv = container_of(mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(mbox, struct rsc_drv, mbox);
 	struct tcs_mbox *tcs = get_tcs_of_type(drv, ACTIVE_TCS);
 
 	/* Check for WAKE TCS if there are no ACTIVE TCS */
@@ -634,7 +634,7 @@
 	return true;
 }
 
-static int check_for_req_inflight(struct tcs_drv *drv, struct tcs_mbox *tcs,
+static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_mbox *tcs,
 						struct tcs_mbox_msg *msg)
 {
 	u32 curr_enabled, addr;
@@ -646,13 +646,13 @@
 		if (tcs_is_free(drv, m))
 			continue;
 
-		curr_enabled = read_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0);
+		curr_enabled = read_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0);
 
 		for (j = 0; j < MAX_CMDS_PER_TCS; j++) {
 			if (!(curr_enabled & (u32)BIT(j)))
 				continue;
 
-			addr = read_tcs_reg(base, TCS_DRV_CMD_ADDR, m, j);
+			addr = read_tcs_reg(base, RSC_DRV_CMD_ADDR, m, j);
 			for (k = 0; k < msg->num_payload; k++) {
 				if (addr == msg->payload[k].addr)
 					return -EBUSY;
@@ -734,7 +734,7 @@
 static int tcs_mbox_write(struct mbox_chan *chan, struct tcs_mbox_msg *msg,
 				bool trigger)
 {
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 	int d = drv->drv_id;
 	struct tcs_mbox *tcs;
 	int i, slot, offset, m, n, ret;
@@ -804,12 +804,12 @@
 
 static void __tcs_buffer_invalidate(void __iomem *base, int m)
 {
-	write_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0, 0);
+	write_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0, 0);
 }
 
 static int tcs_mbox_invalidate(struct mbox_chan *chan)
 {
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 	struct tcs_mbox *tcs;
 	int m, i;
 	int inv_types[] = { WAKE_TCS, SLEEP_TCS };
@@ -838,7 +838,7 @@
 	return 0;
 }
 
-static void print_tcs_regs(struct tcs_drv *drv, int m)
+static void print_tcs_regs(struct rsc_drv *drv, int m)
 {
 	int n;
 	struct tcs_mbox *tcs = get_tcs_from_index(drv, m);
@@ -848,15 +848,15 @@
 	if (!tcs || tcs_is_free(drv, m))
 		return;
 
-	enable = read_tcs_reg(base, TCS_DRV_CMD_ENABLE, m, 0);
+	enable = read_tcs_reg(base, RSC_DRV_CMD_ENABLE, m, 0);
 	if (!enable)
 		return;
 
 	pr_warn("RSC:%s\n", drv->name);
 
-	sts = read_tcs_reg(base, TCS_DRV_STATUS, m, 0);
-	data = read_tcs_reg(base, TCS_DRV_CONTROL, m, 0);
-	irq_sts = read_tcs_reg(base, TCS_DRV_IRQ_STATUS, 0, 0);
+	sts = read_tcs_reg(base, RSC_DRV_STATUS, m, 0);
+	data = read_tcs_reg(base, RSC_DRV_CONTROL, m, 0);
+	irq_sts = read_tcs_reg(base, RSC_DRV_IRQ_STATUS, 0, 0);
 	pr_warn("TCS=%d [ctrlr-sts:%s amc-mode:0x%x irq-sts:%s]\n",
 			m, sts ? "IDLE" : "BUSY", data,
 			(irq_sts & BIT(m)) ? "COMPLETED" : "PENDING");
@@ -864,16 +864,16 @@
 	for (n = 0; n < tcs->ncpt; n++) {
 		if (!(enable & BIT(n)))
 			continue;
-		addr = read_tcs_reg(base, TCS_DRV_CMD_ADDR, m, n);
-		data = read_tcs_reg(base, TCS_DRV_CMD_DATA, m, n);
-		msgid = read_tcs_reg(base, TCS_DRV_CMD_MSGID, m, n);
-		sts = read_tcs_reg(base, TCS_DRV_CMD_STATUS, m, n);
+		addr = read_tcs_reg(base, RSC_DRV_CMD_ADDR, m, n);
+		data = read_tcs_reg(base, RSC_DRV_CMD_DATA, m, n);
+		msgid = read_tcs_reg(base, RSC_DRV_CMD_MSGID, m, n);
+		sts = read_tcs_reg(base, RSC_DRV_CMD_STATUS, m, n);
 		pr_warn("\tCMD=%d [addr=0x%x data=0x%x hdr=0x%x sts=0x%x]\n",
 						n, addr, data, msgid, sts);
 	}
 }
 
-static void dump_tcs_stats(struct tcs_drv *drv)
+static void dump_tcs_stats(struct rsc_drv *drv)
 {
 	int i;
 	unsigned long long curr = arch_counter_get_cntvct();
@@ -894,7 +894,7 @@
 
 static void chan_debug(struct mbox_chan *chan)
 {
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 
 	dump_tcs_stats(drv);
 }
@@ -912,7 +912,7 @@
  */
 static int chan_tcs_write(struct mbox_chan *chan, void *data)
 {
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 	struct tcs_mbox_msg *msg = data;
 	const struct device *dev = chan->cl->dev;
 	int ret = 0;
@@ -986,7 +986,7 @@
 	return ret;
 }
 
-static void __tcs_write_hidden(struct tcs_drv *drv, int d,
+static void __tcs_write_hidden(struct rsc_drv *drv, int d,
 					struct tcs_mbox_msg *msg)
 {
 	int i;
@@ -1003,7 +1003,7 @@
 static int tcs_control_write(struct mbox_chan *chan, struct tcs_mbox_msg *msg)
 {
 	const struct device *dev = chan->cl->dev;
-	struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(chan->mbox, struct rsc_drv, mbox);
 	struct tcs_mbox *tcs;
 	unsigned long flags;
 
@@ -1075,7 +1075,7 @@
 
 static const struct mbox_chan_ops mbox_ops = {
 	.send_data = chan_tcs_write,
-	.send_controller_data = chan_tcs_ctrl_write,
+	.write_controller_data = chan_tcs_ctrl_write,
 	.startup = chan_init,
 	.shutdown = chan_shutdown,
 };
@@ -1083,7 +1083,7 @@
 static struct mbox_chan *of_tcs_mbox_xlate(struct mbox_controller *mbox,
 				const struct of_phandle_args *sp)
 {
-	struct tcs_drv *drv = container_of(mbox, struct tcs_drv, mbox);
+	struct rsc_drv *drv = container_of(mbox, struct rsc_drv, mbox);
 	struct mbox_chan *chan;
 
 	if (drv->num_assigned >= mbox->num_chans) {
@@ -1097,11 +1097,11 @@
 	return chan;
 }
 
-static int tcs_drv_probe(struct platform_device *pdev)
+static int rsc_drv_probe(struct platform_device *pdev)
 {
 	struct device_node *dn = pdev->dev.of_node;
 	struct device_node *np;
-	struct tcs_drv *drv;
+	struct rsc_drv *drv;
 	struct mbox_chan *chans;
 	struct tcs_mbox *tcs;
 	struct of_phandle_args p;
@@ -1178,11 +1178,10 @@
 		if (tcs->num_tcs <= 0 || tcs->type == CONTROL_TCS)
 			continue;
 
-		if (tcs->num_tcs > MAX_TCS_PER_TYPE)
-			return -EINVAL;
-
-		if (st + tcs->num_tcs > max_tcs &&
-				st + tcs->num_tcs >= sizeof(tcs->tcs_mask))
+		if (tcs->num_tcs > MAX_TCS_PER_TYPE ||
+			st + tcs->num_tcs > max_tcs ||
+			st + tcs->num_tcs >=
+				BITS_PER_BYTE * sizeof(tcs->tcs_mask))
 			return -EINVAL;
 
 		tcs->tcs_mask = ((1 << tcs->num_tcs) - 1) << st;
@@ -1234,7 +1233,7 @@
 	drv->mbox.num_chans = num_chans;
 	drv->mbox.txdone_irq = true;
 	drv->mbox.of_xlate = of_tcs_mbox_xlate;
-	drv->mbox.is_idle = tcs_drv_is_idle;
+	drv->mbox.is_idle = rsc_drv_is_idle;
 	drv->mbox.debug = chan_debug;
 	drv->num_tcs = st;
 	drv->pdev = pdev;
@@ -1261,13 +1260,13 @@
 		return ret;
 
 	/* Enable interrupts for AMC TCS */
-	write_tcs_reg(drv->reg_base, TCS_DRV_IRQ_ENABLE, 0, 0,
+	write_tcs_reg(drv->reg_base, RSC_DRV_IRQ_ENABLE, 0, 0,
 					drv->tcs[ACTIVE_TCS].tcs_mask);
 
 	for (i = 0; i < ARRAY_SIZE(drv->tcs_in_use); i++)
 		atomic_set(&drv->tcs_in_use[i], 0);
 
-	drv->ipc_log_ctx = ipc_log_context_create(TCS_DRV_IPC_LOG_SIZE,
+	drv->ipc_log_ctx = ipc_log_context_create(RSC_DRV_IPC_LOG_SIZE,
 						drv->name, 0);
 
 	ret = mbox_controller_register(&drv->mbox);
@@ -1280,21 +1279,21 @@
 	return 0;
 }
 
-static const struct of_device_id tcs_drv_match[] = {
+static const struct of_device_id rsc_drv_match[] = {
 	{ .compatible = "qcom,tcs-drv", },
 	{ }
 };
 
-static struct platform_driver tcs_mbox_driver = {
-	.probe = tcs_drv_probe,
+static struct platform_driver rpmh_mbox_driver = {
+	.probe = rsc_drv_probe,
 	.driver = {
 		.name = KBUILD_MODNAME,
-		.of_match_table = tcs_drv_match,
+		.of_match_table = rsc_drv_match,
 	},
 };
 
-static int __init tcs_mbox_driver_init(void)
+static int __init rpmh_mbox_driver_init(void)
 {
-	return platform_driver_register(&tcs_mbox_driver);
+	return platform_driver_register(&rpmh_mbox_driver);
 }
-arch_initcall(tcs_mbox_driver_init);
+arch_initcall(rpmh_mbox_driver_init);
diff --git a/drivers/mcb/mcb-lpc.c b/drivers/mcb/mcb-lpc.c
index d072c08..945091a 100644
--- a/drivers/mcb/mcb-lpc.c
+++ b/drivers/mcb/mcb-lpc.c
@@ -114,6 +114,12 @@
 	.flags = IORESOURCE_MEM,
 };
 
+static struct resource sc31_fpga_resource = {
+	.start = 0xf000e000,
+	.end = 0xf000e000 + CHAM_HEADER_SIZE,
+	.flags = IORESOURCE_MEM,
+};
+
 static struct platform_driver mcb_lpc_driver = {
 	.driver		= {
 		.name = "mcb-lpc",
@@ -132,6 +138,15 @@
 		.driver_data = (void *)&sc24_fpga_resource,
 		.callback = mcb_lpc_create_platform_device,
 	},
+	{
+		.ident = "SC31",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "MEN"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "14SC31"),
+		},
+		.driver_data = (void *)&sc31_fpga_resource,
+		.callback = mcb_lpc_create_platform_device,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(dmi, mcb_lpc_dmi_table);
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index bca4c0e..e289aae 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -848,8 +848,12 @@
 		tio = tio_from_request(rq);
 		/* Establish tio->ti before queuing work (map_tio_request) */
 		tio->ti = ti;
-		kthread_queue_work(&md->kworker, &tio->work);
+		spin_unlock(q->queue_lock);
+		if (map_request(tio) == DM_MAPIO_REQUEUE)
+			dm_requeue_original_request(tio, false);
+
 		BUG_ON(!irqs_disabled());
+		spin_lock(q->queue_lock);
 	}
 }
 
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8f117d6..549b4af 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5843,6 +5843,10 @@
 	pr_debug("%d stripes handled\n", handled);
 
 	spin_unlock_irq(&conf->device_lock);
+
+	r5l_flush_stripe_to_raid(conf->log);
+
+	async_tx_issue_pending_all();
 	blk_finish_plug(&plug);
 
 	pr_debug("--- raid5worker inactive\n");
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
index 0a06033..2e71850 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
@@ -211,7 +211,7 @@
 	}
 
 	if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS)
-		ret = s5c73m3_af_run(state, ~af_lock);
+		ret = s5c73m3_af_run(state, !af_lock);
 
 	return ret;
 }
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c
index a18fe5d..b4857cd 100644
--- a/drivers/media/pci/saa7164/saa7164-bus.c
+++ b/drivers/media/pci/saa7164/saa7164-bus.c
@@ -393,11 +393,11 @@
 	msg_tmp.size = le16_to_cpu((__force __le16)msg_tmp.size);
 	msg_tmp.command = le32_to_cpu((__force __le32)msg_tmp.command);
 	msg_tmp.controlselector = le16_to_cpu((__force __le16)msg_tmp.controlselector);
+	memcpy(msg, &msg_tmp, sizeof(*msg));
 
 	/* No need to update the read positions, because this was a peek */
 	/* If the caller specifically want to peek, return */
 	if (peekonly) {
-		memcpy(msg, &msg_tmp, sizeof(*msg));
 		goto peekout;
 	}
 
@@ -442,21 +442,15 @@
 		space_rem = bus->m_dwSizeGetRing - curr_grp;
 
 		if (space_rem < sizeof(*msg)) {
-			/* msg wraps around the ring */
-			memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem);
-			memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing,
-				sizeof(*msg) - space_rem);
 			if (buf)
 				memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) -
 					space_rem, buf_size);
 
 		} else if (space_rem == sizeof(*msg)) {
-			memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg));
 			if (buf)
 				memcpy_fromio(buf, bus->m_pdwGetRing, buf_size);
 		} else {
 			/* Additional data wraps around the ring */
-			memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg));
 			if (buf) {
 				memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp +
 					sizeof(*msg), space_rem - sizeof(*msg));
@@ -469,15 +463,10 @@
 
 	} else {
 		/* No wrapping */
-		memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg));
 		if (buf)
 			memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg),
 				buf_size);
 	}
-	/* Convert from little endian to CPU */
-	msg->size = le16_to_cpu((__force __le16)msg->size);
-	msg->command = le32_to_cpu((__force __le32)msg->command);
-	msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector);
 
 	/* Update the read positions, adjusting the ring */
 	saa7164_writel(bus->m_dwGetReadPos, new_grp);
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index 6efb2f1..bdb7a0a 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1725,27 +1725,9 @@
 
 	switch (cmd) {
 	case VPFE_CMD_S_CCDC_RAW_PARAMS:
+		ret = -EINVAL;
 		v4l2_warn(&vpfe_dev->v4l2_dev,
-			  "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
-		if (ccdc_dev->hw_ops.set_params) {
-			ret = ccdc_dev->hw_ops.set_params(param);
-			if (ret) {
-				v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-					"Error setting parameters in CCDC\n");
-				goto unlock_out;
-			}
-			ret = vpfe_get_ccdc_image_format(vpfe_dev,
-							 &vpfe_dev->fmt);
-			if (ret < 0) {
-				v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-					"Invalid image format at CCDC\n");
-				goto unlock_out;
-			}
-		} else {
-			ret = -EINVAL;
-			v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-				"VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
-		}
+			"VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
 		break;
 	default:
 		ret = -ENOTTY;
diff --git a/drivers/media/platform/msm/broadcast/tspp.c b/drivers/media/platform/msm/broadcast/tspp.c
index 2c90e47..be7f4a1 100644
--- a/drivers/media/platform/msm/broadcast/tspp.c
+++ b/drivers/media/platform/msm/broadcast/tspp.c
@@ -36,7 +36,6 @@
 #include <linux/regulator/consumer.h>
 #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
 #include <linux/msm-sps.h>            /* BAM stuff */
-#include <linux/wakelock.h>      /* Locking functions */
 #include <linux/timer.h>         /* Timer services */
 #include <linux/jiffies.h>       /* Jiffies counter */
 #include <linux/qcom_tspp.h>
diff --git a/drivers/media/platform/msm/camera/Makefile b/drivers/media/platform/msm/camera/Makefile
index 800c9ea..48fa1c0 100644
--- a/drivers/media/platform/msm/camera/Makefile
+++ b/drivers/media/platform/msm/camera/Makefile
@@ -9,3 +9,4 @@
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_module/
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_icp/
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_jpeg/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd/
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
index 6c8bde1..3fbb3f0 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
@@ -338,6 +338,7 @@
 				}
 			} else {
 				client->stream_on = false;
+				rc = 0;
 				CAM_DBG(CAM_CDM,
 					"Client stream off success =%d",
 					cdm_hw->open_count);
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
index 5f6895c..29de315 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
@@ -785,18 +785,6 @@
 	time_left = wait_for_completion_timeout(&cdm_core->reset_complete,
 		msecs_to_jiffies(CAM_CDM_HW_RESET_TIMEOUT));
 
-	/*
-	 * Check for HW error and recover as a workaround
-	 * Sometimes CDM HW triggers irq with invalid status for
-	 * HW reset command, so ignore reset failure and proceed further
-	 * as a workaround.
-	 */
-	if (time_left <= 0) {
-		CAM_ERR(CAM_CDM, "CDM HW reset Wait failed time_left=%ld",
-			time_left);
-		time_left = 1;
-	}
-
 	if (time_left <= 0) {
 		CAM_ERR(CAM_CDM, "CDM HW reset Wait failed rc=%d", rc);
 		goto disable_return;
@@ -869,6 +857,8 @@
 
 	cdm_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
 	cdm_hw->soc_info.pdev = pdev;
+	cdm_hw->soc_info.dev = &pdev->dev;
+	cdm_hw->soc_info.dev_name = pdev->name;
 	cdm_hw_intf->hw_type = CAM_HW_CDM;
 	cdm_hw->open_count = 0;
 	mutex_init(&cdm_hw->hw_mutex);
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
index b230d4e..d76f344 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
@@ -131,8 +131,10 @@
 				cdm_cmd->cmd[i].len, client->data.base_array,
 				client->data.base_array_cnt, core->bl_tag);
 			if (rc) {
-				CAM_ERR(CAM_CDM, "write failed for cnt=%d:%d",
-					i, req->data->cmd_arrary_count);
+				CAM_ERR(CAM_CDM,
+					"write failed for cnt=%d:%d len %u",
+					i, req->data->cmd_arrary_count,
+					cdm_cmd->cmd[i].len);
 				break;
 			}
 		} else {
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_node.c b/drivers/media/platform/msm/camera/cam_core/cam_node.c
index 043f44d..6e48c6a 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_node.c
+++ b/drivers/media/platform/msm/camera/cam_core/cam_node.c
@@ -65,7 +65,8 @@
 
 	rc = cam_context_handle_acquire_dev(ctx, acquire);
 	if (rc) {
-		CAM_ERR(CAM_CORE, "Acquire device failed");
+		CAM_ERR(CAM_CORE, "Acquire device failed for node %s",
+			node->name);
 		goto free_ctx;
 	}
 
@@ -82,6 +83,7 @@
 	struct cam_start_stop_dev_cmd *start)
 {
 	struct cam_context *ctx = NULL;
+	int rc;
 
 	if (!start)
 		return -EINVAL;
@@ -103,13 +105,18 @@
 		return -EINVAL;
 	}
 
-	return cam_context_handle_start_dev(ctx, start);
+	rc = cam_context_handle_start_dev(ctx, start);
+	if (rc)
+		CAM_ERR(CAM_CORE, "Start failure for node %s", node->name);
+
+	return rc;
 }
 
 static int __cam_node_handle_stop_dev(struct cam_node *node,
 	struct cam_start_stop_dev_cmd *stop)
 {
 	struct cam_context *ctx = NULL;
+	int rc;
 
 	if (!stop)
 		return -EINVAL;
@@ -131,13 +138,18 @@
 		return -EINVAL;
 	}
 
-	return cam_context_handle_stop_dev(ctx, stop);
+	rc = cam_context_handle_stop_dev(ctx, stop);
+	if (rc)
+		CAM_ERR(CAM_CORE, "Stop failure for node %s", node->name);
+
+	return rc;
 }
 
 static int __cam_node_handle_config_dev(struct cam_node *node,
 	struct cam_config_dev_cmd *config)
 {
 	struct cam_context *ctx = NULL;
+	int rc;
 
 	if (!config)
 		return -EINVAL;
@@ -159,7 +171,11 @@
 		return -EINVAL;
 	}
 
-	return cam_context_handle_config_dev(ctx, config);
+	rc = cam_context_handle_config_dev(ctx, config);
+	if (rc)
+		CAM_ERR(CAM_CORE, "Config failure for node %s", node->name);
+
+	return rc;
 }
 
 static int __cam_node_handle_release_dev(struct cam_node *node,
@@ -183,18 +199,19 @@
 
 	ctx = (struct cam_context *)cam_get_device_priv(release->dev_handle);
 	if (!ctx) {
-		CAM_ERR(CAM_CORE, "Can not get context for handle %d",
-			release->dev_handle);
+		CAM_ERR(CAM_CORE, "Can not get context for handle %d node %s",
+			release->dev_handle, node->name);
 		return -EINVAL;
 	}
 
 	rc = cam_context_handle_release_dev(ctx, release);
 	if (rc)
-		CAM_ERR(CAM_CORE, "context release failed");
+		CAM_ERR(CAM_CORE, "context release failed node %s", node->name);
 
 	rc = cam_destroy_device_hdl(release->dev_handle);
 	if (rc)
-		CAM_ERR(CAM_CORE, "destroy device handle is failed");
+		CAM_ERR(CAM_CORE, "destroy device handle is failed node %s",
+			node->name);
 
 	mutex_lock(&node->list_mutex);
 	list_add_tail(&ctx->list, &node->free_ctx_list);
@@ -256,7 +273,7 @@
 		return -EINVAL;
 	}
 
-	trace_cam_apply_req("Node", apply);
+	trace_cam_apply_req("Node", apply->request_id);
 
 	return cam_context_handle_crm_apply_req(ctx, apply);
 }
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
index 82035e9..6bf81af 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
@@ -1338,6 +1338,8 @@
 
 	cpas_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
 	cpas_hw->soc_info.pdev = pdev;
+	cpas_hw->soc_info.dev = &pdev->dev;
+	cpas_hw->soc_info.dev_name = pdev->name;
 	cpas_hw->open_count = 0;
 	mutex_init(&cpas_hw->hw_mutex);
 	spin_lock_init(&cpas_hw->hw_lock);
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
index d9133b9..e3d46df 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
@@ -402,9 +402,10 @@
 			CAM_CPAS_POLL_RETRY_CNT,
 			CAM_CPAS_POLL_MIN_USECS, CAM_CPAS_POLL_MAX_USECS);
 		if (rc) {
-			CAM_ERR(CAM_CPAS,
+			CAM_DBG(CAM_CPAS,
 				"camnoc flush slave pending trans failed");
 			/* Do not return error, passthrough */
+			rc = 0;
 		}
 	}
 
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cpastop_v170_110.h b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cpastop_v170_110.h
index f4d0e36..918258d 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cpastop_v170_110.h
+++ b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cpastop_v170_110.h
@@ -515,7 +515,7 @@
 
 static struct cam_cpas_hw_errata_wa_list cam170_cpas110_errata_wa_list = {
 	.camnoc_flush_slave_pending_trans = {
-		.enable = true,
+		.enable = false,
 		.data.reg_info = {
 			.access_type = CAM_REG_TYPE_READ,
 			.offset = 0x2100, /* SidebandManager_SenseIn0_Low */
diff --git a/drivers/media/platform/msm/camera/cam_fd/Makefile b/drivers/media/platform/msm/camera/cam_fd/Makefile
new file mode 100644
index 0000000..f8177e8
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/Makefile
@@ -0,0 +1,14 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_core
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sync
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cdm
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw
+ccflags-y += -Idrivers/media/platform/msm/camera
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
+
+obj-$(CONFIG_SPECTRA_CAMERA) += fd_hw_mgr/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_dev.o cam_fd_context.o
diff --git a/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.c b/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.c
new file mode 100644
index 0000000..f23c4c1
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.c
@@ -0,0 +1,241 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "cam_debug_util.h"
+#include "cam_fd_context.h"
+#include "cam_trace.h"
+
+/* Functions in Available state */
+static int __cam_fd_ctx_acquire_dev_in_available(struct cam_context *ctx,
+	struct cam_acquire_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_acquire_dev_to_hw(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Acquire dev, rc=%d", rc);
+		return rc;
+	}
+
+	ctx->state = CAM_CTX_ACQUIRED;
+	trace_cam_context_state("FD", ctx);
+
+	return rc;
+}
+
+/* Functions in Acquired state */
+static int __cam_fd_ctx_release_dev_in_acquired(struct cam_context *ctx,
+	struct cam_release_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_release_dev_to_hw(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Release dev, rc=%d", rc);
+		return rc;
+	}
+
+	ctx->state = CAM_CTX_AVAILABLE;
+	trace_cam_context_state("FD", ctx);
+
+	return rc;
+}
+
+static int __cam_fd_ctx_config_dev_in_acquired(struct cam_context *ctx,
+	struct cam_config_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_prepare_dev_to_hw(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Prepare dev, rc=%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+static int __cam_fd_ctx_start_dev_in_acquired(struct cam_context *ctx,
+	struct cam_start_stop_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_start_dev_to_hw(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Start dev, rc=%d", rc);
+		return rc;
+	}
+
+	ctx->state = CAM_CTX_ACTIVATED;
+	trace_cam_context_state("FD", ctx);
+
+	return rc;
+}
+
+/* Functions in Activated state */
+static int __cam_fd_ctx_stop_dev_in_activated(struct cam_context *ctx,
+	struct cam_start_stop_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_stop_dev_to_hw(ctx);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Stop dev, rc=%d", rc);
+		return rc;
+	}
+
+	ctx->state = CAM_CTX_ACQUIRED;
+	trace_cam_context_state("FD", ctx);
+
+	return rc;
+}
+
+static int __cam_fd_ctx_release_dev_in_activated(struct cam_context *ctx,
+	struct cam_release_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = __cam_fd_ctx_stop_dev_in_activated(ctx, NULL);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Stop dev, rc=%d", rc);
+		return rc;
+	}
+
+	rc = __cam_fd_ctx_release_dev_in_acquired(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Release dev, rc=%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+static int __cam_fd_ctx_config_dev_in_activated(
+	struct cam_context *ctx, struct cam_config_dev_cmd *cmd)
+{
+	int rc;
+
+	rc = cam_context_prepare_dev_to_hw(ctx, cmd);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in Prepare dev, rc=%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+static int __cam_fd_ctx_handle_irq_in_activated(void *context,
+	uint32_t evt_id, void *evt_data)
+{
+	int rc;
+
+	rc = cam_context_buf_done_from_hw(context, evt_data, evt_id);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in buf done, rc=%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+/* top state machine */
+static struct cam_ctx_ops
+	cam_fd_ctx_state_machine[CAM_CTX_STATE_MAX] = {
+	/* Uninit */
+	{
+		.ioctl_ops = {},
+		.crm_ops = {},
+		.irq_ops = NULL,
+	},
+	/* Available */
+	{
+		.ioctl_ops = {
+			.acquire_dev = __cam_fd_ctx_acquire_dev_in_available,
+		},
+		.crm_ops = {},
+		.irq_ops = NULL,
+	},
+	/* Acquired */
+	{
+		.ioctl_ops = {
+			.release_dev = __cam_fd_ctx_release_dev_in_acquired,
+			.config_dev = __cam_fd_ctx_config_dev_in_acquired,
+			.start_dev = __cam_fd_ctx_start_dev_in_acquired,
+		},
+		.crm_ops = {},
+		.irq_ops = NULL,
+	},
+	/* Ready */
+	{
+		.ioctl_ops = { },
+		.crm_ops = {},
+		.irq_ops = NULL,
+	},
+	/* Activated */
+	{
+		.ioctl_ops = {
+			.stop_dev = __cam_fd_ctx_stop_dev_in_activated,
+			.release_dev = __cam_fd_ctx_release_dev_in_activated,
+			.config_dev = __cam_fd_ctx_config_dev_in_activated,
+		},
+		.crm_ops = {},
+		.irq_ops = __cam_fd_ctx_handle_irq_in_activated,
+	},
+};
+
+
+int cam_fd_context_init(struct cam_fd_context *fd_ctx,
+	struct cam_context *base_ctx, struct cam_hw_mgr_intf *hw_intf)
+{
+	int rc;
+
+	if (!base_ctx || !fd_ctx) {
+		CAM_ERR(CAM_FD, "Invalid Context %pK %pK", base_ctx, fd_ctx);
+		return -EINVAL;
+	}
+
+	memset(fd_ctx, 0, sizeof(*fd_ctx));
+
+	rc = cam_context_init(base_ctx, NULL, hw_intf, fd_ctx->req_base,
+		CAM_CTX_REQ_MAX);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Camera Context Base init failed, rc=%d", rc);
+		return rc;
+	}
+
+	fd_ctx->base = base_ctx;
+	base_ctx->ctx_priv = fd_ctx;
+	base_ctx->state_machine = cam_fd_ctx_state_machine;
+
+	return rc;
+}
+
+int cam_fd_context_deinit(struct cam_fd_context *fd_ctx)
+{
+	int rc = 0;
+
+	if (!fd_ctx || !fd_ctx->base) {
+		CAM_ERR(CAM_FD, "Invalid inputs %pK", fd_ctx);
+		return -EINVAL;
+	}
+
+	rc = cam_context_deinit(fd_ctx->base);
+	if (rc)
+		CAM_ERR(CAM_FD, "Error in base deinit, rc=%d", rc);
+
+	memset(fd_ctx, 0, sizeof(*fd_ctx));
+
+	return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.h b/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.h
new file mode 100644
index 0000000..6aa5edb
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/cam_fd_context.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_CONTEXT_H_
+#define _CAM_FD_CONTEXT_H_
+
+#include "cam_context.h"
+#include "cam_context_utils.h"
+#include "cam_hw_mgr_intf.h"
+#include "cam_req_mgr_interface.h"
+
+/**
+ * struct cam_fd_context - Face Detection context information
+ *
+ * @base     : Base context pointer for this FD context
+ * @req_base : List of base requests for this FD context
+ */
+struct cam_fd_context {
+	struct cam_context       *base;
+	struct cam_ctx_request    req_base[CAM_CTX_REQ_MAX];
+};
+
+int cam_fd_context_init(struct cam_fd_context *fd_ctx,
+	struct cam_context *base_ctx, struct cam_hw_mgr_intf *hw_intf);
+int cam_fd_context_deinit(struct cam_fd_context *ctx);
+
+#endif /* _CAM_FD_CONTEXT_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/cam_fd_dev.c b/drivers/media/platform/msm/camera/cam_fd/cam_fd_dev.c
new file mode 100644
index 0000000..27f5518
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/cam_fd_dev.c
@@ -0,0 +1,205 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "cam_subdev.h"
+#include "cam_node.h"
+#include "cam_fd_context.h"
+#include "cam_fd_hw_mgr.h"
+#include "cam_fd_hw_mgr_intf.h"
+
+#define CAM_FD_DEV_NAME "cam-fd"
+
+/**
+ * struct cam_fd_dev - FD device information
+ *
+ * @sd:         Subdev information
+ * @base_ctx:   List of base contexts
+ * @fd_ctx:     List of FD contexts
+ * @lock:       Mutex handle
+ * @open_cnt:   FD subdev open count
+ * @probe_done: Whether FD probe is completed
+ */
+struct cam_fd_dev {
+	struct cam_subdev     sd;
+	struct cam_context    base_ctx[CAM_CTX_MAX];
+	struct cam_fd_context fd_ctx[CAM_CTX_MAX];
+	struct mutex          lock;
+	uint32_t              open_cnt;
+	bool                  probe_done;
+};
+
+static struct cam_fd_dev g_fd_dev;
+
+static int cam_fd_dev_open(struct v4l2_subdev *sd,
+	struct v4l2_subdev_fh *fh)
+{
+	struct cam_fd_dev *fd_dev = &g_fd_dev;
+
+	if (!fd_dev->probe_done) {
+		CAM_ERR(CAM_FD, "FD Dev not initialized, fd_dev=%pK", fd_dev);
+		return -ENODEV;
+	}
+
+	mutex_lock(&fd_dev->lock);
+	fd_dev->open_cnt++;
+	CAM_DBG(CAM_FD, "FD Subdev open count %d", fd_dev->open_cnt);
+	mutex_unlock(&fd_dev->lock);
+
+	return 0;
+}
+
+static int cam_fd_dev_close(struct v4l2_subdev *sd,
+	struct v4l2_subdev_fh *fh)
+{
+	struct cam_fd_dev *fd_dev = &g_fd_dev;
+
+	if (!fd_dev->probe_done) {
+		CAM_ERR(CAM_FD, "FD Dev not initialized, fd_dev=%pK", fd_dev);
+		return -ENODEV;
+	}
+
+	mutex_lock(&fd_dev->lock);
+	fd_dev->open_cnt--;
+	CAM_DBG(CAM_FD, "FD Subdev open count %d", fd_dev->open_cnt);
+	mutex_unlock(&fd_dev->lock);
+
+	return 0;
+}
+
+static const struct v4l2_subdev_internal_ops cam_fd_subdev_internal_ops = {
+	.open = cam_fd_dev_open,
+	.close = cam_fd_dev_close,
+};
+
+static int cam_fd_dev_probe(struct platform_device *pdev)
+{
+	int rc;
+	int i;
+	struct cam_hw_mgr_intf hw_mgr_intf;
+	struct cam_node *node;
+
+	g_fd_dev.sd.internal_ops = &cam_fd_subdev_internal_ops;
+
+	/* Initialze the v4l2 subdevice first. (create cam_node) */
+	rc = cam_subdev_probe(&g_fd_dev.sd, pdev, CAM_FD_DEV_NAME,
+		CAM_FD_DEVICE_TYPE);
+	if (rc) {
+		CAM_ERR(CAM_FD, "FD cam_subdev_probe failed, rc=%d", rc);
+		return rc;
+	}
+	node = (struct cam_node *) g_fd_dev.sd.token;
+
+	rc = cam_fd_hw_mgr_init(pdev->dev.of_node, &hw_mgr_intf);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in initializing FD HW manager, rc=%d",
+			rc);
+		goto unregister_subdev;
+	}
+
+	for (i = 0; i < CAM_CTX_MAX; i++) {
+		rc = cam_fd_context_init(&g_fd_dev.fd_ctx[i],
+			&g_fd_dev.base_ctx[i], &node->hw_mgr_intf);
+		if (rc) {
+			CAM_ERR(CAM_FD, "FD context init failed i=%d, rc=%d",
+				i, rc);
+			goto deinit_ctx;
+		}
+	}
+
+	rc = cam_node_init(node, &hw_mgr_intf, g_fd_dev.base_ctx, CAM_CTX_MAX,
+		CAM_FD_DEV_NAME);
+	if (rc) {
+		CAM_ERR(CAM_FD, "FD node init failed, rc=%d", rc);
+		goto deinit_ctx;
+	}
+
+	mutex_init(&g_fd_dev.lock);
+	g_fd_dev.probe_done = true;
+
+	CAM_DBG(CAM_FD, "Camera FD probe complete");
+
+	return 0;
+
+deinit_ctx:
+	for (--i; i >= 0; i--) {
+		if (cam_fd_context_deinit(&g_fd_dev.fd_ctx[i]))
+			CAM_ERR(CAM_FD, "FD context %d deinit failed", i);
+	}
+unregister_subdev:
+	if (cam_subdev_remove(&g_fd_dev.sd))
+		CAM_ERR(CAM_FD, "Failed in subdev remove");
+
+	return rc;
+}
+
+static int cam_fd_dev_remove(struct platform_device *pdev)
+{
+	int i, rc;
+
+	for (i = 0; i < CAM_CTX_MAX; i++) {
+		rc = cam_fd_context_deinit(&g_fd_dev.fd_ctx[i]);
+		if (rc)
+			CAM_ERR(CAM_FD, "FD context %d deinit failed, rc=%d",
+				i, rc);
+	}
+
+	rc = cam_fd_hw_mgr_deinit(pdev->dev.of_node);
+	if (rc)
+		CAM_ERR(CAM_FD, "Failed in hw mgr deinit, rc=%d", rc);
+
+	rc = cam_subdev_remove(&g_fd_dev.sd);
+	if (rc)
+		CAM_ERR(CAM_FD, "Unregister failed, rc=%d", rc);
+
+	mutex_destroy(&g_fd_dev.lock);
+	g_fd_dev.probe_done = false;
+
+	return rc;
+}
+
+static const struct of_device_id cam_fd_dt_match[] = {
+	{
+		.compatible = "qcom,cam-fd"
+	},
+	{}
+};
+
+static struct platform_driver cam_fd_driver = {
+	.probe = cam_fd_dev_probe,
+	.remove = cam_fd_dev_remove,
+	.driver = {
+		.name = "cam_fd",
+		.owner = THIS_MODULE,
+		.of_match_table = cam_fd_dt_match,
+	},
+};
+
+static int __init cam_fd_dev_init_module(void)
+{
+	return platform_driver_register(&cam_fd_driver);
+}
+
+static void __exit cam_fd_dev_exit_module(void)
+{
+	platform_driver_unregister(&cam_fd_driver);
+}
+
+module_init(cam_fd_dev_init_module);
+module_exit(cam_fd_dev_exit_module);
+MODULE_DESCRIPTION("MSM FD driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/Makefile b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/Makefile
new file mode 100644
index 0000000..e7478cb
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/Makefile
@@ -0,0 +1,14 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_core
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sync
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cdm
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw
+ccflags-y += -Idrivers/media/platform/msm/camera
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
+
+obj-$(CONFIG_SPECTRA_CAMERA) += fd_hw/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_hw_mgr.o
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c
new file mode 100644
index 0000000..37e6954
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c
@@ -0,0 +1,1741 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <media/cam_cpas.h>
+#include <media/cam_req_mgr.h>
+
+#include "cam_io_util.h"
+#include "cam_soc_util.h"
+#include "cam_mem_mgr_api.h"
+#include "cam_smmu_api.h"
+#include "cam_packet_util.h"
+#include "cam_fd_context.h"
+#include "cam_fd_hw_intf.h"
+#include "cam_fd_hw_core.h"
+#include "cam_fd_hw_soc.h"
+#include "cam_fd_hw_mgr_intf.h"
+#include "cam_fd_hw_mgr.h"
+#include "cam_trace.h"
+
+static struct cam_fd_hw_mgr g_fd_hw_mgr;
+
+static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet)
+{
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+	int i, rc;
+
+	if (!packet)
+		return -EINVAL;
+
+	CAM_DBG(CAM_FD, "Packet request=%d, op_code=0x%x, size=%d, flags=%d",
+		packet->header.request_id, packet->header.op_code,
+		packet->header.size, packet->header.flags);
+	CAM_DBG(CAM_FD,
+		"Packet cmdbuf(offset=%d, num=%d) io(offset=%d, num=%d)",
+		packet->cmd_buf_offset, packet->num_cmd_buf,
+		packet->io_configs_offset, packet->num_io_configs);
+	CAM_DBG(CAM_FD,
+		"Packet Patch(offset=%d, num=%d) kmd(offset=%d, num=%d)",
+		packet->patch_offset, packet->num_patches,
+		packet->kmd_cmd_buf_offset, packet->kmd_cmd_buf_index);
+
+	if (cam_packet_util_validate_packet(packet)) {
+		CAM_ERR(CAM_FD, "invalid packet:%d %d %d %d %d",
+			packet->kmd_cmd_buf_index,
+			packet->num_cmd_buf, packet->cmd_buf_offset,
+			packet->io_configs_offset, packet->header.size);
+		return -EINVAL;
+	}
+
+	/* All buffers must come through io config, do not support patching */
+	if (packet->num_patches || !packet->num_io_configs) {
+		CAM_ERR(CAM_FD, "wrong number of cmd/patch info: %u %u",
+			packet->num_cmd_buf, packet->num_patches);
+		return -EINVAL;
+	}
+
+	/* KMD Buf index can never be greater than or equal to num cmd bufs */
+	if (packet->kmd_cmd_buf_index >= packet->num_cmd_buf) {
+		CAM_ERR(CAM_FD, "Invalid kmd index %d (%d)",
+			packet->kmd_cmd_buf_index, packet->num_cmd_buf);
+		return -EINVAL;
+	}
+
+	if ((packet->header.op_code & 0xff) !=
+		CAM_PACKET_OPCODES_FD_FRAME_UPDATE) {
+		CAM_ERR(CAM_FD, "Invalid op_code %u",
+			packet->header.op_code & 0xff);
+		return -EINVAL;
+	}
+
+	cmd_desc = (struct cam_cmd_buf_desc *) ((uint8_t *)&packet->payload +
+		packet->cmd_buf_offset);
+
+	for (i = 0; i < packet->num_cmd_buf; i++) {
+		/*
+		 * We can allow 0 length cmd buffer. This can happen in case
+		 * umd gives an empty cmd buffer as kmd buffer
+		 */
+		if (!cmd_desc[i].length)
+			continue;
+
+		if ((cmd_desc[i].meta_data != CAM_FD_CMD_BUFFER_ID_GENERIC) &&
+			(cmd_desc[i].meta_data != CAM_FD_CMD_BUFFER_ID_CDM)) {
+			CAM_ERR(CAM_FD, "Invalid meta_data [%d] %u", i,
+				cmd_desc[i].meta_data);
+			return -EINVAL;
+		}
+
+		CAM_DBG(CAM_FD,
+			"CmdBuf[%d] hdl=%d, offset=%d, size=%d, len=%d, type=%d, meta_data=%d",
+			i,
+			cmd_desc[i].mem_handle, cmd_desc[i].offset,
+			cmd_desc[i].size, cmd_desc[i].length, cmd_desc[i].type,
+			cmd_desc[i].meta_data);
+
+		rc = cam_packet_util_validate_cmd_desc(&cmd_desc[i]);
+		if (rc) {
+			CAM_ERR(CAM_FD, "Invalid cmd buffer %d", i);
+			return rc;
+		}
+	}
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_put_ctx(
+	struct list_head *src_list,
+	struct cam_fd_hw_mgr_ctx **fd_ctx)
+{
+	int rc = 0;
+	struct cam_fd_hw_mgr_ctx *ctx_ptr = NULL;
+
+	mutex_lock(&g_fd_hw_mgr.ctx_mutex);
+	ctx_ptr = *fd_ctx;
+	if (ctx_ptr)
+		list_add_tail(&ctx_ptr->list, src_list);
+	*fd_ctx = NULL;
+	mutex_unlock(&g_fd_hw_mgr.ctx_mutex);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_get_ctx(
+	struct list_head *src_list,
+	struct cam_fd_hw_mgr_ctx **fd_ctx)
+{
+	int rc = 0;
+	struct cam_fd_hw_mgr_ctx *ctx_ptr = NULL;
+
+	mutex_lock(&g_fd_hw_mgr.ctx_mutex);
+	if (!list_empty(src_list)) {
+		ctx_ptr = list_first_entry(src_list,
+			struct cam_fd_hw_mgr_ctx, list);
+		list_del_init(&ctx_ptr->list);
+	} else {
+		CAM_ERR(CAM_FD, "No more free fd hw mgr ctx");
+		rc = -1;
+	}
+	*fd_ctx = ctx_ptr;
+	mutex_unlock(&g_fd_hw_mgr.ctx_mutex);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_put_frame_req(
+	struct list_head *src_list,
+	struct cam_fd_mgr_frame_request **frame_req)
+{
+	int rc = 0;
+	struct cam_fd_mgr_frame_request *req_ptr = NULL;
+
+	mutex_lock(&g_fd_hw_mgr.frame_req_mutex);
+	req_ptr = *frame_req;
+	if (req_ptr)
+		list_add_tail(&req_ptr->list, src_list);
+	*frame_req = NULL;
+	mutex_unlock(&g_fd_hw_mgr.frame_req_mutex);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_get_frame_req(
+	struct list_head *src_list,
+	struct cam_fd_mgr_frame_request **frame_req)
+{
+	int rc = 0;
+	struct cam_fd_mgr_frame_request *req_ptr = NULL;
+
+	mutex_lock(&g_fd_hw_mgr.frame_req_mutex);
+	if (!list_empty(src_list)) {
+		req_ptr = list_first_entry(src_list,
+			struct cam_fd_mgr_frame_request, list);
+		list_del_init(&req_ptr->list);
+	} else {
+		CAM_DBG(CAM_FD, "Frame req not available");
+		rc = -EPERM;
+	}
+	*frame_req = req_ptr;
+	mutex_unlock(&g_fd_hw_mgr.frame_req_mutex);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_get_device(struct cam_fd_hw_mgr *hw_mgr,
+	struct cam_fd_hw_mgr_ctx *hw_ctx, struct cam_fd_device **hw_device)
+{
+	if (!hw_mgr || !hw_ctx || !hw_device) {
+		CAM_ERR(CAM_FD, "Invalid input %pK %pK %pK", hw_mgr, hw_ctx,
+			hw_device);
+		return -EINVAL;
+	}
+
+	if ((hw_ctx->device_index < 0) ||
+		(hw_ctx->device_index >= CAM_FD_HW_MAX)) {
+		CAM_ERR(CAM_FD, "Invalid device indx %d", hw_ctx->device_index);
+		return -EINVAL;
+	}
+
+	CAM_DBG(CAM_FD, "ctx index=%d, hw_ctx=%d", hw_ctx->ctx_index,
+		hw_ctx->device_index);
+
+	*hw_device = &hw_mgr->hw_device[hw_ctx->device_index];
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_release_device(struct cam_fd_hw_mgr *hw_mgr,
+	struct cam_fd_hw_mgr_ctx *hw_ctx)
+{
+	struct cam_fd_device *hw_device;
+	struct cam_fd_hw_release_args hw_release_args;
+	int rc;
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		return rc;
+	}
+
+	if (hw_device->hw_intf->hw_ops.release) {
+		hw_release_args.hw_ctx = hw_ctx;
+		hw_release_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+		rc = hw_device->hw_intf->hw_ops.release(
+			hw_device->hw_intf->hw_priv, &hw_release_args,
+			sizeof(hw_release_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW release %d", rc);
+			return rc;
+		}
+	} else {
+		CAM_ERR(CAM_FD, "Invalid release function");
+	}
+
+	mutex_lock(&hw_mgr->hw_mgr_mutex);
+	hw_device->num_ctxts--;
+	mutex_unlock(&hw_mgr->hw_mgr_mutex);
+
+	hw_ctx->device_index = -1;
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_select_device(struct cam_fd_hw_mgr *hw_mgr,
+	struct cam_fd_hw_mgr_ctx *hw_ctx,
+	struct cam_fd_acquire_dev_info *fd_acquire_args)
+{
+	int i, rc;
+	struct cam_fd_hw_reserve_args hw_reserve_args;
+	struct cam_fd_device *hw_device = NULL;
+
+	if (!hw_mgr || !hw_ctx || !fd_acquire_args) {
+		CAM_ERR(CAM_FD, "Invalid input %pK %pK %pK", hw_mgr, hw_ctx,
+			fd_acquire_args);
+		return -EINVAL;
+	}
+
+	mutex_lock(&hw_mgr->hw_mgr_mutex);
+
+	/* Check if a device is free which can satisfy the requirements */
+	for (i = 0; i < hw_mgr->num_devices; i++) {
+		hw_device = &hw_mgr->hw_device[i];
+		CAM_DBG(CAM_FD,
+			"[%d] : num_ctxts=%d, modes=%d, raw_results=%d",
+			i, hw_device->num_ctxts,
+			hw_device->hw_caps.supported_modes,
+			hw_device->hw_caps.raw_results_available);
+		if ((hw_device->num_ctxts == 0) &&
+			(fd_acquire_args->mode &
+			hw_device->hw_caps.supported_modes) &&
+			(!fd_acquire_args->get_raw_results ||
+			hw_device->hw_caps.raw_results_available)) {
+			CAM_DBG(CAM_FD, "Found dedicated HW Index=%d", i);
+			hw_device->num_ctxts++;
+			break;
+		}
+	}
+
+	/*
+	 * We couldn't find a free HW which meets requirement, now check if
+	 * there is a HW which meets acquire requirements
+	 */
+	if (i == hw_mgr->num_devices) {
+		for (i = 0; i < hw_mgr->num_devices; i++) {
+			hw_device = &hw_mgr->hw_device[i];
+			if ((fd_acquire_args->mode &
+				hw_device->hw_caps.supported_modes) &&
+				(!fd_acquire_args->get_raw_results ||
+				hw_device->hw_caps.raw_results_available)) {
+				hw_device->num_ctxts++;
+				CAM_DBG(CAM_FD, "Found sharing HW Index=%d", i);
+				break;
+			}
+		}
+	}
+
+	mutex_unlock(&hw_mgr->hw_mgr_mutex);
+
+	if ((i == hw_mgr->num_devices) || !hw_device) {
+		CAM_ERR(CAM_FD, "Couldn't acquire HW %d %d",
+			fd_acquire_args->mode,
+			fd_acquire_args->get_raw_results);
+		return -EBUSY;
+	}
+
+	CAM_DBG(CAM_FD, "Device index %d selected for this acquire", i);
+
+	/* Check if we can reserve this HW */
+	if (hw_device->hw_intf->hw_ops.reserve) {
+		hw_reserve_args.hw_ctx = hw_ctx;
+		hw_reserve_args.mode = fd_acquire_args->mode;
+		rc = hw_device->hw_intf->hw_ops.reserve(
+			hw_device->hw_intf->hw_priv, &hw_reserve_args,
+			sizeof(hw_reserve_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW reserve %d", rc);
+			return rc;
+		}
+		hw_ctx->ctx_hw_private = hw_reserve_args.ctx_hw_private;
+	} else {
+		CAM_ERR(CAM_FD, "Invalid reserve function");
+		return -EPERM;
+	}
+
+	/* Update required info in hw context */
+	hw_ctx->device_index = i;
+
+	CAM_DBG(CAM_FD, "ctx index=%d, device_index=%d", hw_ctx->ctx_index,
+		hw_ctx->device_index);
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_pdev_get_hw_intf(struct device_node *of_node,
+	int i, struct cam_hw_intf **device_hw_intf)
+{
+	struct device_node *device_node = NULL;
+	struct platform_device *child_pdev = NULL;
+	struct cam_hw_intf *hw_intf = NULL;
+	const char *name = NULL;
+	int rc;
+
+	rc = of_property_read_string_index(of_node, "compat-hw-name", i, &name);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Getting dev object name failed %d %d", i, rc);
+		goto put_node;
+	}
+
+	device_node = of_find_node_by_name(NULL, name);
+	if (!device_node) {
+		CAM_ERR(CAM_FD, "Cannot find node in dtsi %s", name);
+		return -ENODEV;
+	}
+
+	child_pdev = of_find_device_by_node(device_node);
+	if (!child_pdev) {
+		CAM_ERR(CAM_FD, "Failed to find device on bus %s",
+			device_node->name);
+		rc = -ENODEV;
+		goto put_node;
+	}
+
+	hw_intf = (struct cam_hw_intf *)platform_get_drvdata(child_pdev);
+	if (!hw_intf) {
+		CAM_ERR(CAM_FD, "No driver data for child device");
+		rc = -ENODEV;
+		goto put_node;
+	}
+
+	CAM_DBG(CAM_FD, "child type %d index %d child_intf %pK",
+		hw_intf->hw_type, hw_intf->hw_idx, hw_intf);
+
+	if (hw_intf->hw_idx >= CAM_FD_HW_MAX) {
+		CAM_ERR(CAM_FD, "hw_idx invalid %d", hw_intf->hw_idx);
+		rc = -ENODEV;
+		goto put_node;
+	}
+
+	rc = 0;
+	*device_hw_intf = hw_intf;
+
+put_node:
+	of_node_put(device_node);
+
+	return rc;
+}
+
+static int cam_fd_packet_generic_blob_handler(void *user_data,
+	uint32_t blob_type, uint32_t blob_size, uint8_t *blob_data)
+{
+	struct cam_fd_hw_cmd_prestart_args *prestart_args =
+		(struct cam_fd_hw_cmd_prestart_args *)user_data;
+
+	if (!blob_data || (blob_size == 0)) {
+		CAM_ERR(CAM_FD, "Invalid blob info %pK %d", blob_data,
+			blob_size);
+		return -EINVAL;
+	}
+
+	if (!prestart_args) {
+		CAM_ERR(CAM_FD, "Invalid user data");
+		return -EINVAL;
+	}
+
+	switch (blob_type) {
+	case CAM_FD_BLOB_TYPE_RAW_RESULTS_REQUIRED: {
+		uint32_t *get_raw_results = (uint32_t *)blob_data;
+
+		if (sizeof(uint32_t) != blob_size) {
+			CAM_ERR(CAM_FD, "Invalid blob size %d %d",
+				sizeof(uint32_t), blob_size);
+			return -EINVAL;
+		}
+
+		prestart_args->get_raw_results = *get_raw_results;
+		break;
+	}
+	case CAM_FD_BLOB_TYPE_SOC_CLOCK_BW_REQUEST: {
+		struct cam_fd_soc_clock_bw_request *clk_req =
+			(struct cam_fd_soc_clock_bw_request *)blob_data;
+
+		if (sizeof(struct cam_fd_soc_clock_bw_request) != blob_size) {
+			CAM_ERR(CAM_FD, "Invalid blob size %d %d",
+				sizeof(struct cam_fd_soc_clock_bw_request),
+				blob_size);
+			return -EINVAL;
+		}
+
+		CAM_DBG(CAM_FD, "SOC Clk Request clock=%lld, bw=%lld",
+			clk_req->clock_rate, clk_req->bandwidth);
+
+		break;
+	}
+	default:
+		CAM_WARN(CAM_FD, "Unknown blob type %d", blob_type);
+		break;
+	}
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_parse_generic_cmd_buffer(
+	struct cam_fd_hw_mgr_ctx *hw_ctx, struct cam_packet *packet,
+	struct cam_fd_hw_cmd_prestart_args *prestart_args)
+{
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+	int i, rc = 0;
+
+	cmd_desc = (struct cam_cmd_buf_desc *) ((uint8_t *)&packet->payload +
+		packet->cmd_buf_offset);
+
+	for (i = 0; i < packet->num_cmd_buf; i++) {
+		if (!cmd_desc[i].length)
+			continue;
+
+		if (cmd_desc[i].meta_data == CAM_FD_CMD_BUFFER_ID_CDM)
+			continue;
+
+		rc = cam_packet_util_validate_cmd_desc(&cmd_desc[i]);
+		if (rc)
+			return rc;
+
+		rc = cam_packet_util_process_generic_cmd_buffer(&cmd_desc[i],
+			cam_fd_packet_generic_blob_handler, prestart_args);
+		if (rc)
+			CAM_ERR(CAM_FD, "Failed in processing blobs %d", rc);
+
+		break;
+	}
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction,
+	uint32_t resource_type, bool *need_io_map, bool *need_cpu_map)
+{
+	if (!need_io_map || !need_cpu_map) {
+		CAM_ERR(CAM_FD, "Invalid input pointers %pK %pK", need_io_map,
+			need_cpu_map);
+		return -EINVAL;
+	}
+
+	if (direction == CAM_BUF_INPUT) {
+		switch (resource_type) {
+		case CAM_FD_INPUT_PORT_ID_IMAGE:
+			*need_io_map = true;
+			*need_cpu_map = false;
+			break;
+		default:
+			CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d",
+				direction, resource_type);
+			return -EINVAL;
+		}
+	} else if (direction == CAM_BUF_OUTPUT) {
+		switch (resource_type) {
+		case CAM_FD_OUTPUT_PORT_ID_RESULTS:
+			*need_io_map = true;
+			*need_cpu_map = true;
+			break;
+		case CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS:
+			*need_io_map = true;
+			*need_cpu_map = true;
+			break;
+		case CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER:
+			*need_io_map = true;
+			*need_cpu_map = false;
+			break;
+		default:
+			CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d",
+				direction, resource_type);
+			return -EINVAL;
+		}
+	} else {
+		CAM_WARN(CAM_FD, "Invalid direction %d", direction);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl,
+	struct cam_hw_prepare_update_args *prepare,
+	struct cam_fd_hw_io_buffer *input_buf,
+	struct cam_fd_hw_io_buffer *output_buf, uint32_t io_buf_size)
+{
+	int rc = -EINVAL;
+	uint32_t i, j, plane, num_out_buf, num_in_buf;
+	struct cam_buf_io_cfg *io_cfg;
+	uint64_t io_addr[CAM_PACKET_MAX_PLANES];
+	uint64_t cpu_addr[CAM_PACKET_MAX_PLANES];
+	size_t size;
+	bool need_io_map, need_cpu_map;
+
+	/* Get IO Buf information */
+	num_out_buf = 0;
+	num_in_buf  = 0;
+	io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *)
+		&prepare->packet->payload + prepare->packet->io_configs_offset);
+
+	for (i = 0; i < prepare->packet->num_io_configs; i++) {
+		CAM_DBG(CAM_FD,
+			"IOConfig[%d] : handle[%d] Dir[%d] Res[%d] Fence[%d], Format[%d]",
+			i, io_cfg[i].mem_handle[0], io_cfg[i].direction,
+			io_cfg[i].resource_type,
+			io_cfg[i].fence, io_cfg[i].format);
+
+		if ((num_in_buf >= io_buf_size) ||
+			(num_out_buf >= io_buf_size)) {
+			CAM_ERR(CAM_FD, "Invalid number of buffers %d %d %d",
+				num_in_buf, num_out_buf, io_buf_size);
+			return -EINVAL;
+		}
+
+		rc = cam_fd_mgr_util_get_buf_map_requirement(
+			io_cfg[i].direction, io_cfg[i].resource_type,
+			&need_io_map, &need_cpu_map);
+		if (rc) {
+			CAM_WARN(CAM_FD, "Invalid io buff [%d] : %d %d %d",
+				i, io_cfg[i].direction,
+				io_cfg[i].resource_type, rc);
+			continue;
+		}
+
+		memset(io_addr, 0x0, sizeof(io_addr));
+		for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) {
+			if (!io_cfg[i].mem_handle[plane])
+				break;
+
+			io_addr[plane] = 0x0;
+			cpu_addr[plane] = 0x0;
+
+			if (need_io_map) {
+				rc = cam_mem_get_io_buf(
+					io_cfg[i].mem_handle[plane],
+					iommu_hdl, &io_addr[plane], &size);
+				if ((rc) || (io_addr[plane] >> 32)) {
+					CAM_ERR(CAM_FD,
+						"Invalid io buf %d %d %d %d",
+						io_cfg[i].direction,
+						io_cfg[i].resource_type, plane,
+						rc);
+					return -ENOMEM;
+				}
+
+				io_addr[plane] += io_cfg[i].offsets[plane];
+			}
+
+			if (need_cpu_map) {
+				rc = cam_mem_get_cpu_buf(
+					io_cfg[i].mem_handle[plane],
+					&cpu_addr[plane], &size);
+				if (rc) {
+					CAM_ERR(CAM_FD,
+						"Invalid cpu buf %d %d %d %d",
+						io_cfg[i].direction,
+						io_cfg[i].resource_type, plane,
+						rc);
+					return rc;
+				}
+
+				cpu_addr[plane] += io_cfg[i].offsets[plane];
+			}
+
+			CAM_DBG(CAM_FD, "IO Address[%d][%d] : %pK, %pK",
+				io_cfg[i].direction, plane, io_addr[plane],
+				cpu_addr[plane]);
+		}
+
+		switch (io_cfg[i].direction) {
+		case CAM_BUF_INPUT: {
+			prepare->in_map_entries[num_in_buf].resource_handle =
+				io_cfg[i].resource_type;
+			prepare->in_map_entries[num_in_buf].sync_id =
+				io_cfg[i].fence;
+
+			input_buf[num_in_buf].valid = true;
+			for (j = 0; j < plane; j++) {
+				input_buf[num_in_buf].io_addr[j] = io_addr[j];
+				input_buf[num_in_buf].cpu_addr[j] = cpu_addr[j];
+			}
+			input_buf[num_in_buf].num_buf = plane;
+			input_buf[num_in_buf].io_cfg = &io_cfg[i];
+
+			num_in_buf++;
+			break;
+		}
+		case CAM_BUF_OUTPUT: {
+			prepare->out_map_entries[num_out_buf].resource_handle =
+				io_cfg[i].resource_type;
+			prepare->out_map_entries[num_out_buf].sync_id =
+				io_cfg[i].fence;
+
+			output_buf[num_out_buf].valid = true;
+			for (j = 0; j < plane; j++) {
+				output_buf[num_out_buf].io_addr[j] = io_addr[j];
+				output_buf[num_out_buf].cpu_addr[j] =
+					cpu_addr[j];
+			}
+			output_buf[num_out_buf].num_buf = plane;
+			output_buf[num_out_buf].io_cfg = &io_cfg[i];
+
+			num_out_buf++;
+			break;
+		}
+		default:
+			CAM_ERR(CAM_FD, "Unsupported io direction %d",
+				io_cfg[i].direction);
+			return -EINVAL;
+		}
+	}
+
+	prepare->num_in_map_entries  = num_in_buf;
+	prepare->num_out_map_entries = num_out_buf;
+
+	return 0;
+}
+
+static int cam_fd_mgr_util_prepare_hw_update_entries(
+	struct cam_fd_hw_mgr *hw_mgr,
+	struct cam_hw_prepare_update_args *prepare,
+	struct cam_fd_hw_cmd_prestart_args *prestart_args,
+	struct cam_kmd_buf_info *kmd_buf_info)
+{
+	int i, rc;
+	struct cam_hw_update_entry *hw_entry;
+	uint32_t num_ent;
+	struct cam_fd_hw_mgr_ctx *hw_ctx =
+		(struct cam_fd_hw_mgr_ctx *)prepare->ctxt_to_hw_map;
+	struct cam_fd_device *hw_device;
+	uint32_t kmd_buf_max_size, kmd_buf_used_bytes = 0;
+	uint32_t *kmd_buf_addr;
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		return rc;
+	}
+
+	kmd_buf_addr = (uint32_t *)((uint8_t *)kmd_buf_info->cpu_addr +
+		kmd_buf_info->used_bytes);
+	kmd_buf_max_size = kmd_buf_info->size - kmd_buf_info->used_bytes;
+
+	prestart_args->cmd_buf_addr = kmd_buf_addr;
+	prestart_args->size  = kmd_buf_max_size;
+	prestart_args->pre_config_buf_size = 0;
+	prestart_args->post_config_buf_size = 0;
+
+	if (hw_device->hw_intf->hw_ops.process_cmd) {
+		rc = hw_device->hw_intf->hw_ops.process_cmd(
+			hw_device->hw_intf->hw_priv, CAM_FD_HW_CMD_PRESTART,
+			prestart_args,
+			sizeof(struct cam_fd_hw_cmd_prestart_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in CMD_PRESTART %d", rc);
+			return rc;
+		}
+	}
+
+	kmd_buf_used_bytes += prestart_args->pre_config_buf_size;
+	kmd_buf_used_bytes += prestart_args->post_config_buf_size;
+
+	/* HW layer is expected to add commands */
+	if (!kmd_buf_used_bytes || (kmd_buf_used_bytes > kmd_buf_max_size)) {
+		CAM_ERR(CAM_FD, "Invalid kmd used bytes %d (%d)",
+			kmd_buf_used_bytes, kmd_buf_max_size);
+		return -ENOMEM;
+	}
+
+	hw_entry = prepare->hw_update_entries;
+	num_ent = 0;
+
+	if (prestart_args->pre_config_buf_size) {
+		if ((num_ent + 1) >= prepare->max_hw_update_entries) {
+			CAM_ERR(CAM_FD, "Insufficient  HW entries :%d %d",
+				num_ent, prepare->max_hw_update_entries);
+			return -EINVAL;
+		}
+
+		hw_entry[num_ent].handle = kmd_buf_info->handle;
+		hw_entry[num_ent].len  = prestart_args->pre_config_buf_size;
+		hw_entry[num_ent].offset = kmd_buf_info->offset;
+
+		kmd_buf_info->used_bytes += prestart_args->pre_config_buf_size;
+		kmd_buf_info->offset += prestart_args->pre_config_buf_size;
+		num_ent++;
+	}
+
+	/*
+	 * set the cmd_desc to point the first command descriptor in the
+	 * packet and update hw entries with CDM command buffers
+	 */
+	cmd_desc = (struct cam_cmd_buf_desc *)((uint8_t *)
+		&prepare->packet->payload + prepare->packet->cmd_buf_offset);
+
+	for (i = 0; i < prepare->packet->num_cmd_buf; i++) {
+		if (!cmd_desc[i].length)
+			continue;
+
+		if (cmd_desc[i].meta_data != CAM_FD_CMD_BUFFER_ID_CDM)
+			continue;
+
+		if (num_ent + 1 >= prepare->max_hw_update_entries) {
+			CAM_ERR(CAM_FD, "Insufficient  HW entries :%d %d",
+				num_ent, prepare->max_hw_update_entries);
+			return -EINVAL;
+		}
+
+		hw_entry[num_ent].handle = cmd_desc[i].mem_handle;
+		hw_entry[num_ent].len = cmd_desc[i].length;
+		hw_entry[num_ent].offset = cmd_desc[i].offset;
+		num_ent++;
+	}
+
+	if (prestart_args->post_config_buf_size) {
+		if (num_ent + 1 >= prepare->max_hw_update_entries) {
+			CAM_ERR(CAM_FD, "Insufficient  HW entries :%d %d",
+				num_ent, prepare->max_hw_update_entries);
+			return -EINVAL;
+		}
+
+		hw_entry[num_ent].handle = kmd_buf_info->handle;
+		hw_entry[num_ent].len    = prestart_args->post_config_buf_size;
+		hw_entry[num_ent].offset = kmd_buf_info->offset;
+
+		kmd_buf_info->used_bytes += prestart_args->post_config_buf_size;
+		kmd_buf_info->offset     += prestart_args->post_config_buf_size;
+
+		num_ent++;
+	}
+
+	prepare->num_hw_update_entries = num_ent;
+
+	CAM_DBG(CAM_FD, "FinalConfig : hw_entries=%d, Sync(in=%d, out=%d)",
+		prepare->num_hw_update_entries, prepare->num_in_map_entries,
+		prepare->num_out_map_entries);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_submit_frame(void *priv, void *data)
+{
+	struct cam_fd_device *hw_device;
+	struct cam_fd_hw_mgr *hw_mgr;
+	struct cam_fd_mgr_frame_request *frame_req;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_hw_cmd_start_args start_args;
+	int rc;
+
+	if (!priv) {
+		CAM_ERR(CAM_FD, "Invalid data");
+		return -EINVAL;
+	}
+
+	hw_mgr = (struct cam_fd_hw_mgr *)priv;
+	mutex_lock(&hw_mgr->frame_req_mutex);
+
+	/* Check if we have any frames pending in high priority list */
+	if (!list_empty(&hw_mgr->frame_pending_list_high)) {
+		CAM_DBG(CAM_FD, "Pending frames in high priority list");
+		frame_req = list_first_entry(&hw_mgr->frame_pending_list_high,
+			struct cam_fd_mgr_frame_request, list);
+	} else if (!list_empty(&hw_mgr->frame_pending_list_normal)) {
+		CAM_DBG(CAM_FD, "Pending frames in normal priority list");
+		frame_req = list_first_entry(&hw_mgr->frame_pending_list_normal,
+			struct cam_fd_mgr_frame_request, list);
+	} else {
+		mutex_unlock(&hw_mgr->frame_req_mutex);
+		CAM_DBG(CAM_FD, "No pending frames");
+		return 0;
+	}
+
+	CAM_DBG(CAM_FD, "FrameSubmit : Frame[%lld]", frame_req->request_id);
+	hw_ctx = frame_req->hw_ctx;
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		mutex_unlock(&hw_mgr->frame_req_mutex);
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		return rc;
+	}
+
+	mutex_lock(&hw_device->lock);
+	if (hw_device->ready_to_process == false) {
+		mutex_unlock(&hw_device->lock);
+		mutex_unlock(&hw_mgr->frame_req_mutex);
+		return -EBUSY;
+	}
+
+	trace_cam_submit_to_hw("FD", frame_req->request_id);
+
+	list_del_init(&frame_req->list);
+	mutex_unlock(&hw_mgr->frame_req_mutex);
+
+	if (hw_device->hw_intf->hw_ops.start) {
+		start_args.hw_ctx = hw_ctx;
+		start_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+		start_args.hw_req_private = &frame_req->hw_req_private;
+		start_args.hw_update_entries = frame_req->hw_update_entries;
+		start_args.num_hw_update_entries =
+			frame_req->num_hw_update_entries;
+
+		rc = hw_device->hw_intf->hw_ops.start(
+			hw_device->hw_intf->hw_priv, &start_args,
+			sizeof(start_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW Start %d", rc);
+			mutex_unlock(&hw_device->lock);
+			goto put_req_into_free_list;
+		}
+	} else {
+		CAM_ERR(CAM_FD, "Invalid hw_ops.start");
+		mutex_unlock(&hw_device->lock);
+		rc = -EPERM;
+		goto put_req_into_free_list;
+	}
+
+	hw_device->ready_to_process = false;
+	mutex_unlock(&hw_device->lock);
+
+	rc = cam_fd_mgr_util_put_frame_req(
+		&hw_mgr->frame_processing_list, &frame_req);
+	if (rc) {
+		CAM_ERR(CAM_FD,
+			"Failed in putting frame req in processing list");
+		goto stop_unlock;
+	}
+
+	return rc;
+
+stop_unlock:
+	if (hw_device->hw_intf->hw_ops.stop) {
+		struct cam_fd_hw_stop_args stop_args;
+
+		stop_args.hw_ctx = hw_ctx;
+		stop_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+		stop_args.hw_req_private = &frame_req->hw_req_private;
+		if (hw_device->hw_intf->hw_ops.stop(
+			hw_device->hw_intf->hw_priv, &stop_args,
+			sizeof(stop_args)))
+			CAM_ERR(CAM_FD, "Failed in HW Stop %d", rc);
+	}
+put_req_into_free_list:
+	cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &frame_req);
+
+	return rc;
+}
+
+static int cam_fd_mgr_util_schedule_frame_worker_task(
+	struct cam_fd_hw_mgr *hw_mgr)
+{
+	int32_t rc = 0;
+	struct crm_workq_task *task;
+	struct cam_fd_mgr_work_data *work_data;
+
+	task = cam_req_mgr_workq_get_task(hw_mgr->work);
+	if (!task) {
+		CAM_ERR(CAM_FD, "no empty task available");
+		return -ENOMEM;
+	}
+
+	work_data = (struct cam_fd_mgr_work_data *)task->payload;
+	work_data->type = CAM_FD_WORK_FRAME;
+
+	task->process_cb = cam_fd_mgr_util_submit_frame;
+	rc = cam_req_mgr_workq_enqueue_task(task, hw_mgr, CRM_TASK_PRIORITY_0);
+
+	return rc;
+}
+
+static int32_t cam_fd_mgr_workq_irq_cb(void *priv, void *data)
+{
+	struct cam_fd_device *hw_device = NULL;
+	struct cam_fd_hw_mgr *hw_mgr;
+	struct cam_fd_mgr_work_data *work_data;
+	struct cam_fd_mgr_frame_request *frame_req = NULL;
+	enum cam_fd_hw_irq_type irq_type;
+	bool frame_abort = true;
+	int rc;
+
+	if (!data || !priv) {
+		CAM_ERR(CAM_FD, "Invalid data %pK %pK", data, priv);
+		return -EINVAL;
+	}
+
+	hw_mgr = (struct cam_fd_hw_mgr *)priv;
+	work_data = (struct cam_fd_mgr_work_data *)data;
+	irq_type = work_data->irq_type;
+
+	CAM_DBG(CAM_FD, "FD IRQ type=%d", irq_type);
+
+	if (irq_type == CAM_FD_IRQ_HALT_DONE) {
+		/* HALT would be followed by a RESET, ignore this */
+		CAM_DBG(CAM_FD, "HALT IRQ callback");
+		return 0;
+	}
+
+	/* Get the frame from processing list */
+	rc = cam_fd_mgr_util_get_frame_req(&hw_mgr->frame_processing_list,
+		&frame_req);
+	if (rc || !frame_req) {
+		/*
+		 * This can happen if reset is triggered while no frames
+		 * were pending, so not an error, just continue to check if
+		 * there are any pending frames and submit
+		 */
+		CAM_DBG(CAM_FD, "No Frame in processing list, rc=%d", rc);
+		goto submit_next_frame;
+	}
+
+	if (!frame_req->hw_ctx) {
+		CAM_ERR(CAM_FD, "Invalid Frame request %lld",
+			frame_req->request_id);
+		goto put_req_in_free_list;
+	}
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, frame_req->hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		goto put_req_in_free_list;
+	}
+
+	/* Read frame results first */
+	if (irq_type == CAM_FD_IRQ_FRAME_DONE) {
+		struct cam_fd_hw_frame_done_args frame_done_args;
+
+		CAM_DBG(CAM_FD, "FrameDone : Frame[%lld]",
+			frame_req->request_id);
+
+		frame_done_args.hw_ctx = frame_req->hw_ctx;
+		frame_done_args.ctx_hw_private =
+			frame_req->hw_ctx->ctx_hw_private;
+		frame_done_args.request_id = frame_req->request_id;
+		frame_done_args.hw_req_private = &frame_req->hw_req_private;
+
+		if (hw_device->hw_intf->hw_ops.process_cmd) {
+			rc = hw_device->hw_intf->hw_ops.process_cmd(
+				hw_device->hw_intf->hw_priv,
+				CAM_FD_HW_CMD_FRAME_DONE,
+				&frame_done_args, sizeof(frame_done_args));
+			if (rc) {
+				CAM_ERR(CAM_FD, "Failed in CMD_PRESTART %d",
+					rc);
+				frame_abort = true;
+				goto notify_context;
+			}
+		}
+
+		frame_abort = false;
+	}
+
+	trace_cam_irq_handled("FD", irq_type);
+
+notify_context:
+	/* Do a callback to inform frame done or stop done */
+	if (frame_req->hw_ctx->event_cb) {
+		struct cam_hw_done_event_data buf_data;
+
+		CAM_DBG(CAM_FD, "FrameHALT : Frame[%lld]",
+			frame_req->request_id);
+
+		buf_data.num_handles = frame_req->num_hw_update_entries;
+		buf_data.request_id = frame_req->request_id;
+
+		rc = frame_req->hw_ctx->event_cb(frame_req->hw_ctx->cb_priv,
+			frame_abort, &buf_data);
+		if (rc)
+			CAM_ERR(CAM_FD, "Error in event cb handling %d", rc);
+	}
+
+	/*
+	 * Now we can set hw device is free to process further frames.
+	 * Note - Do not change state to IDLE until we read the frame results,
+	 * Otherwise, other thread may schedule frame processing before
+	 * reading current frame's results. Also, we need to set to IDLE state
+	 * in case some error happens after getting this irq callback
+	 */
+	mutex_lock(&hw_device->lock);
+	hw_device->ready_to_process = true;
+	CAM_DBG(CAM_FD, "ready_to_process=%d", hw_device->ready_to_process);
+	mutex_unlock(&hw_device->lock);
+
+put_req_in_free_list:
+	rc = cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
+		&frame_req);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in putting frame req in free list");
+		/* continue */
+	}
+
+submit_next_frame:
+	/* Check if there are any frames pending for processing and submit */
+	rc = cam_fd_mgr_util_submit_frame(hw_mgr, NULL);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error while submit frame, rc=%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+static int cam_fd_mgr_irq_cb(void *data, enum cam_fd_hw_irq_type irq_type)
+{
+	struct cam_fd_hw_mgr *hw_mgr = &g_fd_hw_mgr;
+	int rc = 0;
+	unsigned long flags;
+	struct crm_workq_task *task;
+	struct cam_fd_mgr_work_data *work_data;
+
+	spin_lock_irqsave(&hw_mgr->hw_mgr_slock, flags);
+	task = cam_req_mgr_workq_get_task(hw_mgr->work);
+	if (!task) {
+		CAM_ERR(CAM_FD, "no empty task available");
+		spin_unlock_irqrestore(&hw_mgr->hw_mgr_slock, flags);
+		return -ENOMEM;
+	}
+
+	work_data = (struct cam_fd_mgr_work_data *)task->payload;
+	work_data->type = CAM_FD_WORK_IRQ;
+	work_data->irq_type = irq_type;
+
+	task->process_cb = cam_fd_mgr_workq_irq_cb;
+	rc = cam_req_mgr_workq_enqueue_task(task, hw_mgr, CRM_TASK_PRIORITY_0);
+	if (rc)
+		CAM_ERR(CAM_FD, "Failed in enqueue work task, rc=%d", rc);
+
+	spin_unlock_irqrestore(&hw_mgr->hw_mgr_slock, flags);
+
+	return rc;
+}
+
+static int cam_fd_mgr_hw_get_caps(void *hw_mgr_priv, void *hw_get_caps_args)
+{
+	int rc = 0;
+	struct cam_fd_hw_mgr *hw_mgr = hw_mgr_priv;
+	struct cam_query_cap_cmd *query = hw_get_caps_args;
+	struct cam_fd_query_cap_cmd query_fd;
+
+	if (copy_from_user(&query_fd, (void __user *)query->caps_handle,
+		sizeof(struct cam_fd_query_cap_cmd))) {
+		CAM_ERR(CAM_FD, "Failed in copy from user, rc=%d", rc);
+		return -EFAULT;
+	}
+
+	query_fd  = hw_mgr->fd_caps;
+
+	CAM_DBG(CAM_FD,
+		"IOMMU device(%d, %d), CDM(%d, %d), versions %d.%d, %d.%d",
+		query_fd.device_iommu.secure, query_fd.device_iommu.non_secure,
+		query_fd.cdm_iommu.secure, query_fd.cdm_iommu.non_secure,
+		query_fd.hw_caps.core_version.major,
+		query_fd.hw_caps.core_version.minor,
+		query_fd.hw_caps.wrapper_version.major,
+		query_fd.hw_caps.wrapper_version.minor);
+
+	if (copy_to_user((void __user *)query->caps_handle, &query_fd,
+		sizeof(struct cam_fd_query_cap_cmd)))
+		rc = -EFAULT;
+
+	return rc;
+}
+
+static int cam_fd_mgr_hw_acquire(void *hw_mgr_priv, void *hw_acquire_args)
+{
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_acquire_args *acquire_args =
+		(struct cam_hw_acquire_args *)hw_acquire_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_acquire_dev_info fd_acquire_args;
+	int rc;
+
+	if (!acquire_args || acquire_args->num_acq <= 0) {
+		CAM_ERR(CAM_FD, "Invalid acquire args %pK", acquire_args);
+		return -EINVAL;
+	}
+
+	if (copy_from_user(&fd_acquire_args,
+		(void __user *)acquire_args->acquire_info,
+		sizeof(struct cam_fd_acquire_dev_info))) {
+		CAM_ERR(CAM_FD, "Copy from user failed");
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_FD, "Acquire : mode=%d, get_raw_results=%d, priority=%d",
+		fd_acquire_args.mode, fd_acquire_args.get_raw_results,
+		fd_acquire_args.priority);
+
+	/* get a free fd hw mgr ctx */
+	rc = cam_fd_mgr_util_get_ctx(&hw_mgr->free_ctx_list, &hw_ctx);
+	if (rc || !hw_ctx) {
+		CAM_ERR(CAM_FD, "Get hw context failed, rc=%d, hw_ctx=%pK",
+			rc, hw_ctx);
+		return -EINVAL;
+	}
+
+	if (fd_acquire_args.get_raw_results && !hw_mgr->raw_results_available) {
+		CAM_ERR(CAM_FD, "HW cannot support raw results %d (%d)",
+			fd_acquire_args.get_raw_results,
+			hw_mgr->raw_results_available);
+		goto put_ctx;
+	}
+
+	if (!(fd_acquire_args.mode & hw_mgr->supported_modes)) {
+		CAM_ERR(CAM_FD, "HW cannot support requested mode 0x%x (0x%x)",
+			fd_acquire_args.mode, hw_mgr->supported_modes);
+		rc = -EPERM;
+		goto put_ctx;
+	}
+
+	rc = cam_fd_mgr_util_select_device(hw_mgr, hw_ctx, &fd_acquire_args);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in selecting device, rc=%d", rc);
+		goto put_ctx;
+	}
+
+	hw_ctx->ctx_in_use = true;
+	hw_ctx->hw_mgr = hw_mgr;
+	hw_ctx->get_raw_results = fd_acquire_args.get_raw_results;
+	hw_ctx->mode = fd_acquire_args.mode;
+
+	/* Save incoming cam core info into hw ctx*/
+	hw_ctx->cb_priv = acquire_args->context_data;
+	hw_ctx->event_cb = acquire_args->event_cb;
+
+	/* Update out args */
+	acquire_args->ctxt_to_hw_map = hw_ctx;
+
+	cam_fd_mgr_util_put_ctx(&hw_mgr->used_ctx_list, &hw_ctx);
+
+	return 0;
+put_ctx:
+	list_del_init(&hw_ctx->list);
+	cam_fd_mgr_util_put_ctx(&hw_mgr->free_ctx_list, &hw_ctx);
+	return rc;
+}
+
+static int cam_fd_mgr_hw_release(void *hw_mgr_priv, void *hw_release_args)
+{
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_release_args *release_args = hw_release_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	int rc;
+
+	if (!hw_mgr_priv || !hw_release_args) {
+		CAM_ERR(CAM_FD, "Invalid arguments %pK, %pK",
+			hw_mgr_priv, hw_release_args);
+		return -EINVAL;
+	}
+
+	hw_ctx = (struct cam_fd_hw_mgr_ctx *)release_args->ctxt_to_hw_map;
+	if (!hw_ctx || !hw_ctx->ctx_in_use) {
+		CAM_ERR(CAM_FD, "Invalid context is used, hw_ctx=%pK", hw_ctx);
+		return -EPERM;
+	}
+
+	rc = cam_fd_mgr_util_release_device(hw_mgr, hw_ctx);
+	if (rc)
+		CAM_ERR(CAM_FD, "Failed in release device, rc=%d", rc);
+
+	list_del_init(&hw_ctx->list);
+	cam_fd_mgr_util_put_ctx(&hw_mgr->free_ctx_list, &hw_ctx);
+
+	return 0;
+}
+
+static int cam_fd_mgr_hw_start(void *hw_mgr_priv, void *mgr_start_args)
+{
+	int rc = 0;
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_start_args *hw_mgr_start_args =
+		(struct cam_hw_start_args *)mgr_start_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_device *hw_device;
+	struct cam_fd_hw_init_args hw_init_args;
+
+	if (!hw_mgr_priv || !hw_mgr_start_args) {
+		CAM_ERR(CAM_FD, "Invalid arguments %pK %pK",
+			hw_mgr_priv, hw_mgr_start_args);
+		return -EINVAL;
+	}
+
+	hw_ctx = (struct cam_fd_hw_mgr_ctx *)hw_mgr_start_args->ctxt_to_hw_map;
+	if (!hw_ctx || !hw_ctx->ctx_in_use) {
+		CAM_ERR(CAM_FD, "Invalid context is used, hw_ctx=%pK", hw_ctx);
+		return -EPERM;
+	}
+
+	CAM_DBG(CAM_FD, "ctx index=%d, device_index=%d", hw_ctx->ctx_index,
+		hw_ctx->device_index);
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		return rc;
+	}
+
+	if (hw_device->hw_intf->hw_ops.init) {
+		hw_init_args.hw_ctx = hw_ctx;
+		hw_init_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+		rc = hw_device->hw_intf->hw_ops.init(
+			hw_device->hw_intf->hw_priv, &hw_init_args,
+			sizeof(hw_init_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW Init %d", rc);
+			return rc;
+		}
+	} else {
+		CAM_ERR(CAM_FD, "Invalid init function");
+		return -EINVAL;
+	}
+
+	return rc;
+}
+
+static int cam_fd_mgr_hw_stop(void *hw_mgr_priv, void *mgr_stop_args)
+{
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_stop_args *hw_mgr_stop_args =
+		(struct cam_hw_stop_args *)mgr_stop_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_device *hw_device;
+	struct cam_fd_hw_stop_args hw_stop_args;
+	struct cam_fd_hw_deinit_args hw_deinit_args;
+	int rc = 0;
+
+	if (!hw_mgr_priv || !hw_mgr_stop_args) {
+		CAM_ERR(CAM_FD, "Invalid arguments %pK %pK",
+			hw_mgr_priv, hw_mgr_stop_args);
+		return -EINVAL;
+	}
+
+	hw_ctx = (struct cam_fd_hw_mgr_ctx *)hw_mgr_stop_args->ctxt_to_hw_map;
+	if (!hw_ctx || !hw_ctx->ctx_in_use) {
+		CAM_ERR(CAM_FD, "Invalid context is used, hw_ctx=%pK", hw_ctx);
+		return -EPERM;
+	}
+	CAM_DBG(CAM_FD, "ctx index=%d, hw_ctx=%d", hw_ctx->ctx_index,
+		hw_ctx->device_index);
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		return rc;
+	}
+
+	CAM_DBG(CAM_FD, "FD Device ready_to_process = %d",
+		hw_device->ready_to_process);
+
+	if ((hw_device->hw_intf->hw_ops.stop) &&
+		(hw_device->ready_to_process == false)) {
+		/*
+		 * Even if device is in processing state, we should submit
+		 * stop command only if this ctx is running on hw
+		 */
+		hw_stop_args.hw_ctx = hw_ctx;
+		rc = hw_device->hw_intf->hw_ops.stop(
+			hw_device->hw_intf->hw_priv, &hw_stop_args,
+			sizeof(hw_stop_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW Stop %d", rc);
+			return rc;
+		}
+	}
+
+	if (hw_device->hw_intf->hw_ops.deinit) {
+		hw_deinit_args.hw_ctx = hw_ctx;
+		hw_deinit_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+		rc = hw_device->hw_intf->hw_ops.deinit(
+			hw_device->hw_intf->hw_priv, &hw_deinit_args,
+			sizeof(hw_deinit_args));
+		if (rc) {
+			CAM_ERR(CAM_FD, "Failed in HW DeInit %d", rc);
+			return rc;
+		}
+	}
+
+	return rc;
+}
+
+static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv,
+	void *hw_prepare_update_args)
+{
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_prepare_update_args *prepare =
+		(struct cam_hw_prepare_update_args *) hw_prepare_update_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_device *hw_device;
+	struct cam_kmd_buf_info kmd_buf;
+	int rc;
+	struct cam_fd_hw_cmd_prestart_args prestart_args;
+	struct cam_fd_mgr_frame_request *frame_req;
+
+	if (!hw_mgr_priv || !hw_prepare_update_args) {
+		CAM_ERR(CAM_FD, "Invalid args %pK %pK",
+			hw_mgr_priv, hw_prepare_update_args);
+		return -EINVAL;
+	}
+
+	hw_ctx = (struct cam_fd_hw_mgr_ctx *)prepare->ctxt_to_hw_map;
+	if (!hw_ctx || !hw_ctx->ctx_in_use) {
+		CAM_ERR(CAM_FD, "Invalid context is used, hw_ctx=%pK", hw_ctx);
+		return -EPERM;
+	}
+
+	rc = cam_fd_mgr_util_get_device(hw_mgr, hw_ctx, &hw_device);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in getting device %d", rc);
+		goto error;
+	}
+
+	rc = cam_fd_mgr_util_packet_validate(prepare->packet);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in packet validation %d", rc);
+		goto error;
+	}
+
+	rc = cam_packet_util_get_kmd_buffer(prepare->packet, &kmd_buf);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in get kmd buf buffer %d", rc);
+		goto error;
+	}
+
+	CAM_DBG(CAM_FD,
+		"KMD Buf : hdl=%d, cpu_addr=%pK, offset=%d, size=%d, used=%d",
+		kmd_buf.handle, kmd_buf.cpu_addr, kmd_buf.offset,
+		kmd_buf.size, kmd_buf.used_bytes);
+
+	/* We do not expect any patching, but just do it anyway */
+	rc = cam_packet_util_process_patches(prepare->packet,
+		hw_mgr->device_iommu.non_secure, -1);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Patch FD packet failed, rc=%d", rc);
+		return rc;
+	}
+
+	memset(&prestart_args, 0x0, sizeof(prestart_args));
+	prestart_args.ctx_hw_private = hw_ctx->ctx_hw_private;
+	prestart_args.hw_ctx = hw_ctx;
+	prestart_args.request_id = prepare->packet->header.request_id;
+
+	rc = cam_fd_mgr_util_parse_generic_cmd_buffer(hw_ctx, prepare->packet,
+		&prestart_args);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in parsing gerneric cmd buffer %d", rc);
+		goto error;
+	}
+
+	rc = cam_fd_mgr_util_prepare_io_buf_info(
+		hw_mgr->device_iommu.non_secure, prepare,
+		prestart_args.input_buf, prestart_args.output_buf,
+		CAM_FD_MAX_IO_BUFFERS);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in prepare IO Buf %d", rc);
+		goto error;
+	}
+
+	rc = cam_fd_mgr_util_prepare_hw_update_entries(hw_mgr, prepare,
+		&prestart_args, &kmd_buf);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in hw update entries %d", rc);
+		goto error;
+	}
+
+	/* get a free frame req from free list */
+	rc = cam_fd_mgr_util_get_frame_req(&hw_mgr->frame_free_list,
+		&frame_req);
+	if (rc || !frame_req) {
+		CAM_ERR(CAM_FD, "Get frame_req failed, rc=%d, hw_ctx=%pK",
+			rc, hw_ctx);
+		return -ENOMEM;
+	}
+
+	/* Setup frame request info and queue to pending list */
+	frame_req->hw_ctx = hw_ctx;
+	frame_req->request_id = prepare->packet->header.request_id;
+	/* This has to be passed to HW while calling hw_ops->start */
+	frame_req->hw_req_private = prestart_args.hw_req_private;
+
+	/*
+	 * Save the current frame_req into priv,
+	 * this will come as priv while hw_config
+	 */
+	prepare->priv = frame_req;
+
+	CAM_DBG(CAM_FD, "FramePrepare : Frame[%lld]", frame_req->request_id);
+
+	return 0;
+error:
+	return rc;
+}
+
+static int cam_fd_mgr_hw_config(void *hw_mgr_priv, void *hw_config_args)
+{
+	struct cam_fd_hw_mgr *hw_mgr = (struct cam_fd_hw_mgr *)hw_mgr_priv;
+	struct cam_hw_config_args *config =
+		(struct cam_hw_config_args *) hw_config_args;
+	struct cam_fd_hw_mgr_ctx *hw_ctx;
+	struct cam_fd_mgr_frame_request *frame_req;
+	int rc;
+	int i;
+
+	if (!hw_mgr || !config) {
+		CAM_ERR(CAM_FD, "Invalid arguments %pK %pK", hw_mgr, config);
+		return -EINVAL;
+	}
+
+	if (!config->num_hw_update_entries) {
+		CAM_ERR(CAM_FD, "No hw update enteries are available");
+		return -EINVAL;
+	}
+
+	hw_ctx = (struct cam_fd_hw_mgr_ctx *)config->ctxt_to_hw_map;
+	if (!hw_ctx || !hw_ctx->ctx_in_use) {
+		CAM_ERR(CAM_FD, "Invalid context is used, hw_ctx=%pK", hw_ctx);
+		return -EPERM;
+	}
+
+	frame_req = config->priv;
+
+	trace_cam_apply_req("FD", frame_req->request_id);
+	CAM_DBG(CAM_FD, "FrameHWConfig : Frame[%lld]", frame_req->request_id);
+
+	frame_req->num_hw_update_entries = config->num_hw_update_entries;
+	for (i = 0; i < config->num_hw_update_entries; i++) {
+		frame_req->hw_update_entries[i] = config->hw_update_entries[i];
+		CAM_DBG(CAM_FD, "PreStart HWEntry[%d] : %d %d %d %d %pK",
+			frame_req->hw_update_entries[i].handle,
+			frame_req->hw_update_entries[i].offset,
+			frame_req->hw_update_entries[i].len,
+			frame_req->hw_update_entries[i].flags,
+			frame_req->hw_update_entries[i].addr);
+	}
+
+	if (hw_ctx->priority == CAM_FD_PRIORITY_HIGH) {
+		CAM_DBG(CAM_FD, "Insert frame into prio0 queue");
+		rc = cam_fd_mgr_util_put_frame_req(
+			&hw_mgr->frame_pending_list_high, &frame_req);
+	} else {
+		CAM_DBG(CAM_FD, "Insert frame into prio1 queue");
+		rc = cam_fd_mgr_util_put_frame_req(
+			&hw_mgr->frame_pending_list_normal, &frame_req);
+	}
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in queuing frame req, rc=%d", rc);
+		goto put_free_list;
+	}
+
+	rc = cam_fd_mgr_util_schedule_frame_worker_task(hw_mgr);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Worker task scheduling failed %d", rc);
+		goto remove_and_put_free_list;
+	}
+
+	return 0;
+
+remove_and_put_free_list:
+
+	if (hw_ctx->priority == CAM_FD_PRIORITY_HIGH) {
+		CAM_DBG(CAM_FD, "Removing frame into prio0 queue");
+		cam_fd_mgr_util_get_frame_req(
+			&hw_mgr->frame_pending_list_high, &frame_req);
+	} else {
+		CAM_DBG(CAM_FD, "Removing frame into prio1 queue");
+		cam_fd_mgr_util_get_frame_req(
+			&hw_mgr->frame_pending_list_normal, &frame_req);
+	}
+put_free_list:
+	cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
+		&frame_req);
+
+	return rc;
+}
+
+int cam_fd_hw_mgr_deinit(struct device_node *of_node)
+{
+	CAM_DBG(CAM_FD, "HW Mgr Deinit");
+
+	cam_req_mgr_workq_destroy(&g_fd_hw_mgr.work);
+
+	cam_smmu_ops(g_fd_hw_mgr.device_iommu.non_secure, CAM_SMMU_DETACH);
+	cam_smmu_destroy_handle(g_fd_hw_mgr.device_iommu.non_secure);
+	g_fd_hw_mgr.device_iommu.non_secure = -1;
+
+	mutex_destroy(&g_fd_hw_mgr.ctx_mutex);
+	mutex_destroy(&g_fd_hw_mgr.frame_req_mutex);
+	mutex_destroy(&g_fd_hw_mgr.hw_mgr_mutex);
+
+	return 0;
+}
+
+int cam_fd_hw_mgr_init(struct device_node *of_node,
+	struct cam_hw_mgr_intf *hw_mgr_intf)
+{
+	int count, i, rc = 0;
+	struct cam_hw_intf *hw_intf = NULL;
+	struct cam_fd_hw_mgr_ctx *hw_mgr_ctx;
+	struct cam_fd_device *hw_device;
+	struct cam_fd_mgr_frame_request *frame_req;
+
+	if (!of_node || !hw_mgr_intf) {
+		CAM_ERR(CAM_FD, "Invalid args of_node %pK hw_mgr_intf %pK",
+			of_node, hw_mgr_intf);
+		return -EINVAL;
+	}
+
+	memset(&g_fd_hw_mgr, 0x0, sizeof(g_fd_hw_mgr));
+	memset(hw_mgr_intf, 0x0, sizeof(*hw_mgr_intf));
+
+	mutex_init(&g_fd_hw_mgr.ctx_mutex);
+	mutex_init(&g_fd_hw_mgr.frame_req_mutex);
+	mutex_init(&g_fd_hw_mgr.hw_mgr_mutex);
+	spin_lock_init(&g_fd_hw_mgr.hw_mgr_slock);
+
+	count = of_property_count_strings(of_node, "compat-hw-name");
+	if (!count || (count > CAM_FD_HW_MAX)) {
+		CAM_ERR(CAM_FD, "Invalid compat names in dev tree %d", count);
+		return -EINVAL;
+	}
+	g_fd_hw_mgr.num_devices = count;
+
+	g_fd_hw_mgr.raw_results_available = false;
+	g_fd_hw_mgr.supported_modes = 0;
+
+	for (i = 0; i < count; i++) {
+		hw_device = &g_fd_hw_mgr.hw_device[i];
+
+		rc = cam_fd_mgr_util_pdev_get_hw_intf(of_node, i, &hw_intf);
+		if (rc) {
+			CAM_ERR(CAM_FD, "hw intf from pdev failed, rc=%d", rc);
+			return rc;
+		}
+
+		mutex_init(&hw_device->lock);
+
+		hw_device->valid = true;
+		hw_device->hw_intf = hw_intf;
+		hw_device->ready_to_process = true;
+
+		if (hw_device->hw_intf->hw_ops.process_cmd) {
+			struct cam_fd_hw_cmd_set_irq_cb irq_cb_args;
+
+			irq_cb_args.cam_fd_hw_mgr_cb = cam_fd_mgr_irq_cb;
+			irq_cb_args.data = hw_device;
+
+			rc = hw_device->hw_intf->hw_ops.process_cmd(
+				hw_device->hw_intf->hw_priv,
+				CAM_FD_HW_CMD_REGISTER_CALLBACK,
+				&irq_cb_args, sizeof(irq_cb_args));
+			if (rc) {
+				CAM_ERR(CAM_FD,
+					"Failed in REGISTER_CALLBACK %d", rc);
+				return rc;
+			}
+		}
+
+		if (hw_device->hw_intf->hw_ops.get_hw_caps) {
+			rc = hw_device->hw_intf->hw_ops.get_hw_caps(
+				hw_intf->hw_priv, &hw_device->hw_caps,
+				sizeof(hw_device->hw_caps));
+			if (rc) {
+				CAM_ERR(CAM_FD, "Failed in get_hw_caps %d", rc);
+				return rc;
+			}
+
+			g_fd_hw_mgr.raw_results_available |=
+				hw_device->hw_caps.raw_results_available;
+			g_fd_hw_mgr.supported_modes |=
+				hw_device->hw_caps.supported_modes;
+
+			CAM_DBG(CAM_FD,
+				"Device[mode=%d, raw=%d], Mgr[mode=%d, raw=%d]",
+				hw_device->hw_caps.supported_modes,
+				hw_device->hw_caps.raw_results_available,
+				g_fd_hw_mgr.supported_modes,
+				g_fd_hw_mgr.raw_results_available);
+		}
+	}
+
+	INIT_LIST_HEAD(&g_fd_hw_mgr.free_ctx_list);
+	INIT_LIST_HEAD(&g_fd_hw_mgr.used_ctx_list);
+	INIT_LIST_HEAD(&g_fd_hw_mgr.frame_free_list);
+	INIT_LIST_HEAD(&g_fd_hw_mgr.frame_pending_list_high);
+	INIT_LIST_HEAD(&g_fd_hw_mgr.frame_pending_list_normal);
+	INIT_LIST_HEAD(&g_fd_hw_mgr.frame_processing_list);
+
+	g_fd_hw_mgr.device_iommu.non_secure = -1;
+	g_fd_hw_mgr.device_iommu.secure = -1;
+	g_fd_hw_mgr.cdm_iommu.non_secure = -1;
+	g_fd_hw_mgr.cdm_iommu.secure = -1;
+
+	rc = cam_smmu_get_handle("fd",
+		&g_fd_hw_mgr.device_iommu.non_secure);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Get iommu handle failed, rc=%d", rc);
+		goto destroy_mutex;
+	}
+
+	rc = cam_smmu_ops(g_fd_hw_mgr.device_iommu.non_secure, CAM_SMMU_ATTACH);
+	if (rc) {
+		CAM_ERR(CAM_FD, "FD attach iommu handle failed, rc=%d", rc);
+		goto destroy_smmu;
+	}
+
+	rc = cam_cdm_get_iommu_handle("fd", &g_fd_hw_mgr.cdm_iommu);
+	if (rc)
+		CAM_DBG(CAM_FD, "Failed to acquire the CDM iommu handles");
+
+	CAM_DBG(CAM_FD, "iommu handles : device(%d, %d), cdm(%d, %d)",
+		g_fd_hw_mgr.device_iommu.non_secure,
+		g_fd_hw_mgr.device_iommu.secure,
+		g_fd_hw_mgr.cdm_iommu.non_secure,
+		g_fd_hw_mgr.cdm_iommu.secure);
+
+	/* Init hw mgr contexts and add to free list */
+	for (i = 0; i < CAM_CTX_MAX; i++) {
+		hw_mgr_ctx = &g_fd_hw_mgr.ctx_pool[i];
+
+		memset(hw_mgr_ctx, 0x0, sizeof(*hw_mgr_ctx));
+		INIT_LIST_HEAD(&hw_mgr_ctx->list);
+
+		hw_mgr_ctx->ctx_index = i;
+		hw_mgr_ctx->device_index = -1;
+		hw_mgr_ctx->hw_mgr = &g_fd_hw_mgr;
+
+		list_add_tail(&hw_mgr_ctx->list, &g_fd_hw_mgr.free_ctx_list);
+	}
+
+	/* Init hw mgr frame requests and add to free list */
+	for (i = 0; i < CAM_CTX_REQ_MAX; i++) {
+		frame_req = &g_fd_hw_mgr.frame_req[i];
+
+		memset(frame_req, 0x0, sizeof(*frame_req));
+		INIT_LIST_HEAD(&frame_req->list);
+
+		list_add_tail(&frame_req->list, &g_fd_hw_mgr.frame_free_list);
+	}
+
+	rc = cam_req_mgr_workq_create("cam_fd_worker", CAM_FD_WORKQ_NUM_TASK,
+		&g_fd_hw_mgr.work, CRM_WORKQ_USAGE_IRQ);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Unable to create a worker, rc=%d", rc);
+		goto detach_smmu;
+	}
+
+	for (i = 0; i < CAM_FD_WORKQ_NUM_TASK; i++)
+		g_fd_hw_mgr.work->task.pool[i].payload =
+			&g_fd_hw_mgr.work_data[i];
+
+	/* Setup hw cap so that we can just return the info when requested */
+	memset(&g_fd_hw_mgr.fd_caps, 0, sizeof(g_fd_hw_mgr.fd_caps));
+	g_fd_hw_mgr.fd_caps.device_iommu = g_fd_hw_mgr.device_iommu;
+	g_fd_hw_mgr.fd_caps.cdm_iommu = g_fd_hw_mgr.cdm_iommu;
+	g_fd_hw_mgr.fd_caps.hw_caps = g_fd_hw_mgr.hw_device[0].hw_caps;
+
+	CAM_DBG(CAM_FD,
+		"IOMMU device(%d, %d), CDM(%d, %d) versions core[%d.%d], wrapper[%d.%d]",
+		g_fd_hw_mgr.fd_caps.device_iommu.secure,
+		g_fd_hw_mgr.fd_caps.device_iommu.non_secure,
+		g_fd_hw_mgr.fd_caps.cdm_iommu.secure,
+		g_fd_hw_mgr.fd_caps.cdm_iommu.non_secure,
+		g_fd_hw_mgr.fd_caps.hw_caps.core_version.major,
+		g_fd_hw_mgr.fd_caps.hw_caps.core_version.minor,
+		g_fd_hw_mgr.fd_caps.hw_caps.wrapper_version.major,
+		g_fd_hw_mgr.fd_caps.hw_caps.wrapper_version.minor);
+
+	hw_mgr_intf->hw_mgr_priv = &g_fd_hw_mgr;
+	hw_mgr_intf->hw_get_caps = cam_fd_mgr_hw_get_caps;
+	hw_mgr_intf->hw_acquire = cam_fd_mgr_hw_acquire;
+	hw_mgr_intf->hw_release = cam_fd_mgr_hw_release;
+	hw_mgr_intf->hw_start = cam_fd_mgr_hw_start;
+	hw_mgr_intf->hw_stop = cam_fd_mgr_hw_stop;
+	hw_mgr_intf->hw_prepare_update = cam_fd_mgr_hw_prepare_update;
+	hw_mgr_intf->hw_config = cam_fd_mgr_hw_config;
+	hw_mgr_intf->hw_read = NULL;
+	hw_mgr_intf->hw_write = NULL;
+	hw_mgr_intf->hw_close = NULL;
+
+	return rc;
+
+detach_smmu:
+	cam_smmu_ops(g_fd_hw_mgr.device_iommu.non_secure, CAM_SMMU_DETACH);
+destroy_smmu:
+	cam_smmu_destroy_handle(g_fd_hw_mgr.device_iommu.non_secure);
+	g_fd_hw_mgr.device_iommu.non_secure = -1;
+destroy_mutex:
+	mutex_destroy(&g_fd_hw_mgr.ctx_mutex);
+	mutex_destroy(&g_fd_hw_mgr.frame_req_mutex);
+	mutex_destroy(&g_fd_hw_mgr.hw_mgr_mutex);
+
+	return rc;
+}
+
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.h
new file mode 100644
index 0000000..135e006
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.h
@@ -0,0 +1,182 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_MGR_H_
+#define _CAM_FD_HW_MGR_H_
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include <media/cam_fd.h>
+#include "cam_hw.h"
+#include "cam_hw_intf.h"
+#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
+#include "cam_hw_mgr_intf.h"
+#include "cam_req_mgr_workq.h"
+#include "cam_fd_hw_intf.h"
+
+#define CAM_FD_HW_MAX            1
+#define CAM_FD_WORKQ_NUM_TASK    10
+
+struct cam_fd_hw_mgr;
+
+/**
+ * enum cam_fd_mgr_work_type - Type of worker task
+ *
+ * @CAM_FD_WORK_FRAME : Work type indicating frame task
+ * @CAM_FD_WORK_IRQ   : Work type indicating irq task
+ */
+enum cam_fd_mgr_work_type {
+	CAM_FD_WORK_FRAME,
+	CAM_FD_WORK_IRQ,
+};
+
+/**
+ * struct cam_fd_hw_mgr_ctx : FD HW Mgr context
+ *
+ * @list            : List pointer used to maintain this context
+ *                    in free, used list
+ * @ctx_index       : Index of this context
+ * @ctx_in_use      : Whether this context is in use
+ * @event_cb        : Event callback pointer to notify cam core context
+ * @cb_priv         : Event callback private pointer
+ * @hw_mgr          : Pointer to hw manager
+ * @get_raw_results : Whether this context needs raw results
+ * @mode            : Mode in which this context runs
+ * @device_index    : HW Device used by this context
+ * @ctx_hw_private  : HW layer's private context pointer for this context
+ * @priority        : Priority of this context
+ */
+struct cam_fd_hw_mgr_ctx {
+	struct list_head               list;
+	uint32_t                       ctx_index;
+	bool                           ctx_in_use;
+	cam_hw_event_cb_func           event_cb;
+	void                          *cb_priv;
+	struct cam_fd_hw_mgr          *hw_mgr;
+	bool                           get_raw_results;
+	enum cam_fd_hw_mode            mode;
+	int32_t                        device_index;
+	void                          *ctx_hw_private;
+	uint32_t                       priority;
+};
+
+/**
+ * struct cam_fd_device : FD HW Device
+ *
+ * @hw_caps          : This FD device's capabilities
+ * @hw_intf          : FD device's interface information
+ * @ready_to_process : Whether this device is ready to process next frame
+ * @num_ctxts        : Number of context currently running on this device
+ * @valid            : Whether this device is valid
+ * @lock             : Lock used for protectin
+ */
+struct cam_fd_device {
+	struct cam_fd_hw_caps    hw_caps;
+	struct cam_hw_intf      *hw_intf;
+	bool                     ready_to_process;
+	uint32_t                 num_ctxts;
+	bool                     valid;
+	struct mutex             lock;
+};
+
+/**
+ * struct cam_fd_mgr_frame_request : Frame request information maintained
+ *                                   in HW Mgr layer
+ *
+ * @list                  : List pointer used to maintain this request in
+ *                          free, pending, processing request lists
+ * @request_id            : Request ID corresponding to this request
+ * @hw_ctx                : HW context from which this request is coming
+ * @hw_req_private        : HW layer's private information specific to
+ *                          this request
+ * @hw_update_entries     : HW update entries corresponding to this request
+ *                          which needs to be submitted to HW through CDM
+ * @num_hw_update_entries : Number of HW update entries
+ */
+struct cam_fd_mgr_frame_request {
+	struct list_head               list;
+	uint64_t                       request_id;
+	struct cam_fd_hw_mgr_ctx      *hw_ctx;
+	struct cam_fd_hw_req_private   hw_req_private;
+	struct cam_hw_update_entry     hw_update_entries[CAM_FD_MAX_HW_ENTRIES];
+	uint32_t                       num_hw_update_entries;
+};
+
+/**
+ * struct cam_fd_mgr_work_data : HW Mgr work data information
+ *
+ * @type     : Type of work
+ * @irq_type : IRQ type when this work is queued because of irq callback
+ */
+struct cam_fd_mgr_work_data {
+	enum cam_fd_mgr_work_type      type;
+	enum cam_fd_hw_irq_type        irq_type;
+};
+
+/**
+ * struct cam_fd_hw_mgr : FD HW Mgr information
+ *
+ * @free_ctx_list             : List of free contexts available for acquire
+ * @used_ctx_list             : List of contexts that are acquired
+ * @frame_free_list           : List of free frame requests available
+ * @frame_pending_list_high   : List of high priority frame requests pending
+ *                              for processing
+ * @frame_pending_list_normal : List of normal priority frame requests pending
+ *                              for processing
+ * @frame_processing_list     : List of frame requests currently being
+ *                              processed currently. Generally maximum one
+ *                              request would be present in this list
+ * @hw_mgr_mutex              : Mutex to protect hw mgr data when accessed
+ *                              from multiple threads
+ * @hw_mgr_slock              : Spin lock to protect hw mgr data when accessed
+ *                              from multiple threads
+ * @ctx_mutex                 : Mutex to protect context list
+ * @frame_req_mutex           : Mutex to protect frame request list
+ * @device_iommu              : Device IOMMU information
+ * @cdm_iommu                 : CDM IOMMU information
+ * @hw_device                 : Underlying HW device information
+ * @num_devices               : Number of HW devices available
+ * @raw_results_available     : Whether raw results available in this driver
+ * @supported_modes           : Supported modes by this driver
+ * @ctx_pool                  : List of context
+ * @frame_req                 : List of frame requests
+ * @work                      : Worker handle
+ * @work_data                 : Worker data
+ * @fd_caps                   : FD driver capabilities
+ */
+struct cam_fd_hw_mgr {
+	struct list_head                   free_ctx_list;
+	struct list_head                   used_ctx_list;
+	struct list_head                   frame_free_list;
+	struct list_head                   frame_pending_list_high;
+	struct list_head                   frame_pending_list_normal;
+	struct list_head                   frame_processing_list;
+	struct mutex                       hw_mgr_mutex;
+	spinlock_t                         hw_mgr_slock;
+	struct mutex                       ctx_mutex;
+	struct mutex                       frame_req_mutex;
+	struct cam_iommu_handle            device_iommu;
+	struct cam_iommu_handle            cdm_iommu;
+	struct cam_fd_device               hw_device[CAM_FD_HW_MAX];
+	uint32_t                           num_devices;
+	bool                               raw_results_available;
+	uint32_t                           supported_modes;
+	struct cam_fd_hw_mgr_ctx           ctx_pool[CAM_CTX_MAX];
+	struct cam_fd_mgr_frame_request    frame_req[CAM_CTX_REQ_MAX];
+	struct cam_req_mgr_core_workq     *work;
+	struct cam_fd_mgr_work_data        work_data[CAM_FD_WORKQ_NUM_TASK];
+	struct cam_fd_query_cap_cmd        fd_caps;
+};
+
+#endif /* _CAM_FD_HW_MGR_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr_intf.h
new file mode 100644
index 0000000..58cba4f
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr_intf.h
@@ -0,0 +1,25 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_MGR_INTF_H_
+#define _CAM_FD_HW_MGR_INTF_H_
+
+#include <linux/of.h>
+
+#include "cam_debug_util.h"
+#include "cam_hw_mgr_intf.h"
+
+int cam_fd_hw_mgr_init(struct device_node *of_node,
+	struct cam_hw_mgr_intf *hw_mgr_intf);
+int cam_fd_hw_mgr_deinit(struct device_node *of_node);
+
+#endif /* _CAM_FD_HW_MGR_INTF_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/Makefile b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/Makefile
new file mode 100644
index 0000000..c3e706d
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_core
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sync
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cdm
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw
+ccflags-y += -Idrivers/media/platform/msm/camera
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
+
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_hw_dev.o cam_fd_hw_core.o cam_fd_hw_soc.o
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.c b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.c
new file mode 100644
index 0000000..b8a5685
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.c
@@ -0,0 +1,1130 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "cam_fd_hw_core.h"
+#include "cam_fd_hw_soc.h"
+#include "cam_trace.h"
+
+#define CAM_FD_REG_VAL_PAIR_SIZE 256
+
+static uint32_t cam_fd_cdm_write_reg_val_pair(uint32_t *buffer,
+	uint32_t index, uint32_t reg_offset, uint32_t reg_value)
+{
+	buffer[index++] = reg_offset;
+	buffer[index++] = reg_value;
+
+	CAM_DBG(CAM_FD, "FD_CDM_CMD: Base[FD_CORE] Offset[0x%8x] Value[0x%8x]",
+		reg_offset, reg_value);
+
+	return index;
+}
+
+static void cam_fd_hw_util_cdm_callback(uint32_t handle, void *userdata,
+	enum cam_cdm_cb_status status, uint32_t cookie)
+{
+	trace_cam_cdm_cb("FD", status);
+	CAM_DBG(CAM_FD, "CDM hdl=%x, udata=%pK, status=%d, cookie=%d",
+		handle, userdata, status, cookie);
+}
+
+static void cam_fd_hw_util_enable_power_on_settings(struct cam_hw_info *fd_hw)
+{
+	struct cam_hw_soc_info *soc_info = &fd_hw->soc_info;
+	struct cam_fd_hw_static_info *hw_static_info =
+		((struct cam_fd_core *)fd_hw->core_info)->hw_static_info;
+
+	if (hw_static_info->enable_errata_wa.single_irq_only == false) {
+		/* Enable IRQs here */
+		cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+			hw_static_info->wrapper_regs.irq_mask,
+			hw_static_info->irq_mask);
+	}
+
+	/* QoS settings */
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.vbif_req_priority,
+		hw_static_info->qos_priority);
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.vbif_priority_level,
+		hw_static_info->qos_priority_level);
+}
+
+int cam_fd_hw_util_get_hw_caps(struct cam_hw_info *fd_hw,
+	struct cam_fd_hw_caps *hw_caps)
+{
+	struct cam_hw_soc_info *soc_info = &fd_hw->soc_info;
+	struct cam_fd_hw_static_info *hw_static_info =
+		((struct cam_fd_core *)fd_hw->core_info)->hw_static_info;
+	uint32_t reg_value;
+
+	if (!hw_static_info) {
+		CAM_ERR(CAM_FD, "Invalid hw info data");
+		return -EINVAL;
+	}
+
+	reg_value = cam_fd_soc_register_read(soc_info, CAM_FD_REG_CORE,
+		hw_static_info->core_regs.version);
+	hw_caps->core_version.major =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xf00, 0x8);
+	hw_caps->core_version.minor =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xf0, 0x4);
+	hw_caps->core_version.incr =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xf, 0x0);
+
+	reg_value = cam_fd_soc_register_read(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.wrapper_version);
+	hw_caps->wrapper_version.major =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xf0000000, 0x1c);
+	hw_caps->wrapper_version.minor =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xfff0000, 0x10);
+	hw_caps->wrapper_version.incr =
+		CAM_BITS_MASK_SHIFT(reg_value, 0xffff, 0x0);
+
+	hw_caps->raw_results_available =
+		hw_static_info->results.raw_results_available;
+	hw_caps->supported_modes = hw_static_info->supported_modes;
+
+	CAM_DBG(CAM_FD, "core:%d.%d.%d wrapper:%d.%d.%d intermediate:%d",
+		hw_caps->core_version.major, hw_caps->core_version.minor,
+		hw_caps->core_version.incr, hw_caps->wrapper_version.major,
+		hw_caps->wrapper_version.minor, hw_caps->wrapper_version.incr,
+		hw_caps->raw_results_available);
+
+	return 0;
+}
+
+static int cam_fd_hw_util_fdwrapper_sync_reset(struct cam_hw_info *fd_hw)
+{
+	struct cam_fd_core *fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	struct cam_fd_hw_static_info *hw_static_info = fd_core->hw_static_info;
+	struct cam_hw_soc_info *soc_info = &fd_hw->soc_info;
+	long time_left;
+
+	/* Before triggering reset to HW, clear the reset complete */
+	reinit_completion(&fd_core->reset_complete);
+
+	if (hw_static_info->enable_errata_wa.single_irq_only) {
+		cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+			hw_static_info->wrapper_regs.irq_mask,
+			CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_RESET_DONE));
+	}
+
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.sw_reset, 0x1);
+
+	time_left = wait_for_completion_timeout(&fd_core->reset_complete,
+		msecs_to_jiffies(CAM_FD_HW_HALT_RESET_TIMEOUT));
+	if (time_left <= 0)
+		CAM_WARN(CAM_FD, "HW reset timeout time_left=%d", time_left);
+
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_CORE,
+		hw_static_info->core_regs.control, 0x1);
+
+	CAM_DBG(CAM_FD, "FD Wrapper SW Sync Reset complete");
+
+	return 0;
+}
+
+
+static int cam_fd_hw_util_fdwrapper_halt(struct cam_hw_info *fd_hw)
+{
+	struct cam_fd_core *fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	struct cam_fd_hw_static_info *hw_static_info = fd_core->hw_static_info;
+	struct cam_hw_soc_info *soc_info = &fd_hw->soc_info;
+	long time_left;
+
+	/* Before triggering halt to HW, clear halt complete */
+	reinit_completion(&fd_core->halt_complete);
+
+	if (hw_static_info->enable_errata_wa.single_irq_only) {
+		cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+			hw_static_info->wrapper_regs.irq_mask,
+			CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_HALT_DONE));
+	}
+
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.hw_stop, 0x1);
+
+	time_left = wait_for_completion_timeout(&fd_core->halt_complete,
+		msecs_to_jiffies(CAM_FD_HW_HALT_RESET_TIMEOUT));
+	if (time_left <= 0)
+		CAM_WARN(CAM_FD, "HW halt timeout time_left=%d", time_left);
+
+	CAM_DBG(CAM_FD, "FD Wrapper Halt complete");
+
+	return 0;
+}
+
+static int cam_fd_hw_util_processcmd_prestart(struct cam_hw_info *fd_hw,
+	struct cam_fd_hw_cmd_prestart_args *prestart_args)
+{
+	struct cam_hw_soc_info *soc_info = &fd_hw->soc_info;
+	struct cam_fd_hw_static_info *hw_static_info =
+		((struct cam_fd_core *)fd_hw->core_info)->hw_static_info;
+	struct cam_fd_ctx_hw_private *ctx_hw_private =
+		prestart_args->ctx_hw_private;
+	uint32_t size, size_required = 0;
+	uint32_t mem_base;
+	uint32_t *cmd_buf_addr = prestart_args->cmd_buf_addr;
+	uint32_t reg_val_pair[CAM_FD_REG_VAL_PAIR_SIZE];
+	uint32_t num_cmds = 0;
+	int i;
+	struct cam_fd_hw_io_buffer *io_buf;
+	struct cam_fd_hw_req_private *req_private;
+	uint32_t available_size = prestart_args->size;
+	bool work_buffer_configured = false;
+
+	if (!ctx_hw_private || !cmd_buf_addr) {
+		CAM_ERR(CAM_FD, "Invalid input prestart args %pK %pK",
+			ctx_hw_private, cmd_buf_addr);
+		return -EINVAL;
+	}
+
+	if (prestart_args->get_raw_results &&
+		!hw_static_info->results.raw_results_available) {
+		CAM_ERR(CAM_FD, "Raw results not supported %d %d",
+			prestart_args->get_raw_results,
+			hw_static_info->results.raw_results_available);
+		return -EINVAL;
+	}
+
+	req_private = &prestart_args->hw_req_private;
+	req_private->ctx_hw_private = prestart_args->ctx_hw_private;
+	req_private->request_id = prestart_args->request_id;
+	req_private->get_raw_results = prestart_args->get_raw_results;
+	req_private->fd_results = NULL;
+	req_private->raw_results = NULL;
+
+	/* Start preparing CDM register values that KMD has to insert */
+	num_cmds = cam_fd_cdm_write_reg_val_pair(reg_val_pair, num_cmds,
+		hw_static_info->core_regs.control, 0x1);
+	num_cmds = cam_fd_cdm_write_reg_val_pair(reg_val_pair, num_cmds,
+		hw_static_info->core_regs.control, 0x0);
+
+	for (i = 0; i < CAM_FD_MAX_IO_BUFFERS; i++) {
+		io_buf = &prestart_args->input_buf[i];
+
+		if (io_buf->valid == false)
+			break;
+
+		if (io_buf->io_cfg->direction != CAM_BUF_INPUT) {
+			CAM_ERR(CAM_FD, "Incorrect direction %d %d",
+				io_buf->io_cfg->direction, CAM_BUF_INPUT);
+			return -EINVAL;
+		}
+
+		switch (io_buf->io_cfg->resource_type) {
+		case CAM_FD_INPUT_PORT_ID_IMAGE: {
+			if ((num_cmds + 2) > CAM_FD_REG_VAL_PAIR_SIZE) {
+				CAM_ERR(CAM_FD,
+					"Invalid reg_val pair size %d, %d",
+					num_cmds, CAM_FD_REG_VAL_PAIR_SIZE);
+				return -EINVAL;
+			}
+
+			num_cmds = cam_fd_cdm_write_reg_val_pair(
+				reg_val_pair, num_cmds,
+				hw_static_info->core_regs.image_addr,
+				io_buf->io_addr[0]);
+			break;
+		}
+		default:
+			CAM_ERR(CAM_FD, "Invalid resource type %d",
+				io_buf->io_cfg->resource_type);
+			return -EINVAL;
+		}
+	}
+
+	for (i = 0; i < CAM_FD_MAX_IO_BUFFERS; i++) {
+		io_buf = &prestart_args->output_buf[i];
+
+		if (io_buf->valid == false)
+			break;
+
+		if (io_buf->io_cfg->direction != CAM_BUF_OUTPUT) {
+			CAM_ERR(CAM_FD, "Incorrect direction %d %d",
+				io_buf->io_cfg->direction, CAM_BUF_INPUT);
+			return -EINVAL;
+		}
+
+		switch (io_buf->io_cfg->resource_type) {
+		case CAM_FD_OUTPUT_PORT_ID_RESULTS: {
+			uint32_t face_results_offset;
+
+			size_required = hw_static_info->results.max_faces *
+				hw_static_info->results.per_face_entries * 4;
+
+			if (io_buf->io_cfg->planes[0].plane_stride <
+				size_required) {
+				CAM_ERR(CAM_FD, "Invalid results size %d %d",
+					io_buf->io_cfg->planes[0].plane_stride,
+					size_required);
+				return -EINVAL;
+			}
+
+			req_private->fd_results =
+				(struct cam_fd_results *)io_buf->cpu_addr[0];
+
+			face_results_offset =
+				(uint8_t *)&req_private->fd_results->faces[0] -
+				(uint8_t *)req_private->fd_results;
+
+			if (hw_static_info->ro_mode_supported) {
+				if ((num_cmds + 4) > CAM_FD_REG_VAL_PAIR_SIZE) {
+					CAM_ERR(CAM_FD,
+						"Invalid reg_val size %d, %d",
+						num_cmds,
+						CAM_FD_REG_VAL_PAIR_SIZE);
+					return -EINVAL;
+				}
+				/*
+				 * Face data actually starts 16bytes later in
+				 * the io buffer  Check cam_fd_results.
+				 */
+				num_cmds = cam_fd_cdm_write_reg_val_pair(
+					reg_val_pair, num_cmds,
+					hw_static_info->core_regs.result_addr,
+					io_buf->io_addr[0] +
+					face_results_offset);
+				num_cmds = cam_fd_cdm_write_reg_val_pair(
+					reg_val_pair, num_cmds,
+					hw_static_info->core_regs.ro_mode,
+					0x1);
+
+				req_private->ro_mode_enabled = true;
+			} else {
+				req_private->ro_mode_enabled = false;
+			}
+			break;
+		}
+		case CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS: {
+			size_required =
+				hw_static_info->results.raw_results_entries *
+				sizeof(uint32_t);
+
+			if (io_buf->io_cfg->planes[0].plane_stride <
+				size_required) {
+				CAM_ERR(CAM_FD, "Invalid results size %d %d",
+					io_buf->io_cfg->planes[0].plane_stride,
+					size_required);
+				return -EINVAL;
+			}
+
+			req_private->raw_results =
+				(uint32_t *)io_buf->cpu_addr[0];
+			break;
+		}
+		case CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER: {
+			if ((num_cmds + 2) > CAM_FD_REG_VAL_PAIR_SIZE) {
+				CAM_ERR(CAM_FD,
+					"Invalid reg_val pair size %d, %d",
+					num_cmds, CAM_FD_REG_VAL_PAIR_SIZE);
+				return -EINVAL;
+			}
+
+			num_cmds = cam_fd_cdm_write_reg_val_pair(
+				reg_val_pair, num_cmds,
+				hw_static_info->core_regs.work_addr,
+				io_buf->io_addr[0]);
+
+			work_buffer_configured = true;
+			break;
+		}
+		default:
+			CAM_ERR(CAM_FD, "Invalid resource type %d",
+				io_buf->io_cfg->resource_type);
+			return -EINVAL;
+		}
+	}
+
+	if (!req_private->fd_results || !work_buffer_configured) {
+		CAM_ERR(CAM_FD, "Invalid IO Buffers results=%pK work=%d",
+			req_private->fd_results, work_buffer_configured);
+		return -EINVAL;
+	}
+
+	/* First insert CHANGE_BASE command */
+	size = ctx_hw_private->cdm_ops->cdm_required_size_changebase();
+	/* since cdm returns dwords, we need to convert it into bytes */
+	if ((size * 4) > available_size) {
+		CAM_ERR(CAM_FD, "buf size:%d is not sufficient, expected: %d",
+			prestart_args->size, size);
+		return -EINVAL;
+	}
+
+	mem_base = CAM_SOC_GET_REG_MAP_CAM_BASE(soc_info,
+		((struct cam_fd_soc_private *)soc_info->soc_private)->
+		regbase_index[CAM_FD_REG_CORE]);
+
+	ctx_hw_private->cdm_ops->cdm_write_changebase(cmd_buf_addr, mem_base);
+	cmd_buf_addr += size;
+	available_size -= (size * 4);
+
+	size = ctx_hw_private->cdm_ops->cdm_required_size_reg_random(
+		num_cmds/2);
+	/* cdm util returns dwords, need to convert to bytes */
+	if ((size * 4) > available_size) {
+		CAM_ERR(CAM_FD, "Insufficient size:%d , expected size:%d",
+			available_size, size);
+		return -ENOMEM;
+	}
+	ctx_hw_private->cdm_ops->cdm_write_regrandom(cmd_buf_addr, num_cmds/2,
+		reg_val_pair);
+	cmd_buf_addr += size;
+	available_size -= (size * 4);
+
+	/* Update pre_config_buf_size in bytes */
+	prestart_args->pre_config_buf_size =
+		prestart_args->size - available_size;
+
+	/* Insert start trigger command into CDM as post config commands. */
+	num_cmds = cam_fd_cdm_write_reg_val_pair(reg_val_pair, 0,
+		hw_static_info->core_regs.control, 0x2);
+	size = ctx_hw_private->cdm_ops->cdm_required_size_reg_random(
+		num_cmds/2);
+	if ((size * 4) > available_size) {
+		CAM_ERR(CAM_FD, "Insufficient size:%d , expected size:%d",
+			available_size, size);
+		return -ENOMEM;
+	}
+	ctx_hw_private->cdm_ops->cdm_write_regrandom(cmd_buf_addr, num_cmds/2,
+		reg_val_pair);
+	cmd_buf_addr += size;
+	available_size -= (size * 4);
+
+	prestart_args->post_config_buf_size = size * 4;
+
+	CAM_DBG(CAM_FD, "PreConfig [%pK %d], PostConfig[%pK %d]",
+		prestart_args->cmd_buf_addr, prestart_args->pre_config_buf_size,
+		cmd_buf_addr, prestart_args->post_config_buf_size);
+
+	for (i = 0; i < (prestart_args->pre_config_buf_size +
+		prestart_args->post_config_buf_size) / 4; i++)
+		CAM_DBG(CAM_FD, "CDM KMD Commands [%d] : [%pK] [0x%x]", i,
+			&prestart_args->cmd_buf_addr[i],
+			prestart_args->cmd_buf_addr[i]);
+
+	return 0;
+}
+
+static int cam_fd_hw_util_processcmd_frame_done(struct cam_hw_info *fd_hw,
+	struct cam_fd_hw_frame_done_args *frame_done_args)
+{
+	struct cam_fd_core *fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	struct cam_fd_hw_static_info *hw_static_info = fd_core->hw_static_info;
+	struct cam_fd_hw_req_private *req_private;
+	uint32_t base, face_cnt;
+	uint32_t *buffer;
+	int i;
+
+	spin_lock(&fd_core->spin_lock);
+	if ((fd_core->core_state != CAM_FD_CORE_STATE_IDLE) ||
+		(fd_core->results_valid == false) ||
+		!fd_core->hw_req_private) {
+		CAM_ERR(CAM_FD,
+			"Invalid state for results state=%d, results=%d %pK",
+			fd_core->core_state, fd_core->results_valid,
+			fd_core->hw_req_private);
+		spin_unlock(&fd_core->spin_lock);
+		return -EINVAL;
+	}
+	fd_core->core_state = CAM_FD_CORE_STATE_READING_RESULTS;
+	req_private = fd_core->hw_req_private;
+	spin_unlock(&fd_core->spin_lock);
+
+	/*
+	 * Copy the register value as is into output buffers.
+	 * Wehter we are copying the output data by reading registers or
+	 * programming output buffer directly to HW must be transparent to UMD.
+	 * In case HW supports writing face count value directly into
+	 * DDR memory in future, these values should match.
+	 */
+	req_private->fd_results->face_count =
+		cam_fd_soc_register_read(&fd_hw->soc_info, CAM_FD_REG_CORE,
+		hw_static_info->core_regs.result_cnt);
+
+	face_cnt = req_private->fd_results->face_count & 0x3F;
+
+	if (face_cnt > hw_static_info->results.max_faces) {
+		CAM_WARN(CAM_FD, "Face count greater than max %d %d",
+			face_cnt, hw_static_info->results.max_faces);
+		face_cnt = hw_static_info->results.max_faces;
+	}
+
+	CAM_DBG(CAM_FD, "ReqID[%lld] Faces Detected = %d",
+		req_private->request_id, face_cnt);
+
+	/*
+	 * We need to read the face data information from registers only
+	 * if one of below is true
+	 * 1. RO mode is not set. i.e FD HW doesn't write face data into
+	 *    DDR memory
+	 * 2. On the current chipset, results written into DDR memory by FD HW
+	 *    are not gauranteed to be correct
+	 */
+	if (!req_private->ro_mode_enabled ||
+		hw_static_info->enable_errata_wa.ro_mode_results_invalid) {
+		buffer = (uint32_t *)&req_private->fd_results->faces[0];
+		base = hw_static_info->core_regs.results_reg_base;
+
+		/*
+		 * Write register values as is into face data buffer.  Its UMD
+		 * driver responsibility to interpret the data and extract face
+		 * properties from output buffer. Think in case output buffer
+		 * is directly programmed to HW, then KMD has no control to
+		 * extract the face properties and UMD anyway has to extract
+		 * face properties. So we follow the same approach and keep
+		 * this transparent to UMD.
+		 */
+		for (i = 0;
+			i < (face_cnt *
+			hw_static_info->results.per_face_entries); i++) {
+			*buffer = cam_fd_soc_register_read(&fd_hw->soc_info,
+				CAM_FD_REG_CORE, base + (i * 0x4));
+			CAM_DBG(CAM_FD, "FaceData[%d] : 0x%x", i / 4, *buffer);
+			buffer++;
+		}
+	}
+
+	if (req_private->get_raw_results &&
+		req_private->raw_results &&
+		hw_static_info->results.raw_results_available) {
+		buffer = req_private->raw_results;
+		base = hw_static_info->core_regs.raw_results_reg_base;
+
+		for (i = 0;
+			i < hw_static_info->results.raw_results_entries;
+			i++) {
+			*buffer = cam_fd_soc_register_read(&fd_hw->soc_info,
+				CAM_FD_REG_CORE, base + (i * 0x4));
+			CAM_DBG(CAM_FD, "RawData[%d] : 0x%x", i, *buffer);
+			buffer++;
+		}
+	}
+
+	spin_lock(&fd_core->spin_lock);
+	fd_core->hw_req_private = NULL;
+	fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+	spin_unlock(&fd_core->spin_lock);
+
+	return 0;
+}
+
+irqreturn_t cam_fd_hw_irq(int irq_num, void *data)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)data;
+	struct cam_fd_core *fd_core;
+	struct cam_hw_soc_info *soc_info;
+	struct cam_fd_hw_static_info *hw_static_info;
+	uint32_t reg_value;
+	enum cam_fd_hw_irq_type irq_type = CAM_FD_IRQ_FRAME_DONE;
+	uint32_t num_irqs = 0;
+
+	if (!fd_hw) {
+		CAM_ERR(CAM_FD, "Invalid data in IRQ callback");
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *) fd_hw->core_info;
+	soc_info = &fd_hw->soc_info;
+	hw_static_info = fd_core->hw_static_info;
+
+	reg_value = cam_fd_soc_register_read(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.irq_status);
+
+	CAM_DBG(CAM_FD, "FD IRQ status 0x%x", reg_value);
+
+	if (reg_value & CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_HALT_DONE)) {
+		complete_all(&fd_core->halt_complete);
+		irq_type = CAM_FD_IRQ_HALT_DONE;
+		num_irqs++;
+	}
+
+	if (reg_value & CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_RESET_DONE)) {
+		complete_all(&fd_core->reset_complete);
+		irq_type = CAM_FD_IRQ_RESET_DONE;
+		num_irqs++;
+	}
+
+	if (reg_value & CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_FRAME_DONE)) {
+		complete_all(&fd_core->processing_complete);
+		irq_type = CAM_FD_IRQ_FRAME_DONE;
+		num_irqs++;
+	}
+
+	/*
+	 * We should never get an IRQ callback with no or more than one mask.
+	 * Validate first to make sure nothing going wrong.
+	 */
+	if (num_irqs != 1) {
+		CAM_ERR(CAM_FD,
+			"Invalid number of IRQs, value=0x%x, num_irqs=%d",
+			reg_value, num_irqs);
+		return -EINVAL;
+	}
+
+	trace_cam_irq_activated("FD", irq_type);
+
+	cam_fd_soc_register_write(soc_info, CAM_FD_REG_WRAPPER,
+		hw_static_info->wrapper_regs.irq_clear,
+		hw_static_info->irq_mask);
+
+	if (irq_type == CAM_FD_IRQ_HALT_DONE) {
+		/*
+		 * Do not send HALT IRQ callback to Hw Mgr,
+		 * a reset would always follow
+		 */
+		return IRQ_HANDLED;
+	}
+
+	spin_lock(&fd_core->spin_lock);
+	/* Do not change state to IDLE on HALT IRQ. Reset must follow halt */
+	if ((irq_type == CAM_FD_IRQ_RESET_DONE) ||
+		(irq_type == CAM_FD_IRQ_FRAME_DONE)) {
+
+		fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+		if (irq_type == CAM_FD_IRQ_FRAME_DONE)
+			fd_core->results_valid = true;
+
+		CAM_DBG(CAM_FD, "FD IRQ type %d, state=%d",
+			irq_type, fd_core->core_state);
+	}
+	spin_unlock(&fd_core->spin_lock);
+
+	if (fd_core->irq_cb.cam_fd_hw_mgr_cb)
+		fd_core->irq_cb.cam_fd_hw_mgr_cb(fd_core->irq_cb.data,
+			irq_type);
+
+	return IRQ_HANDLED;
+}
+
+int cam_fd_hw_get_hw_caps(void *hw_priv, void *get_hw_cap_args,
+	uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	struct cam_fd_core *fd_core;
+	struct cam_fd_hw_caps *fd_hw_caps =
+		(struct cam_fd_hw_caps *)get_hw_cap_args;
+
+	if (!hw_priv || !get_hw_cap_args) {
+		CAM_ERR(CAM_FD, "Invalid input pointers %pK %pK",
+			hw_priv, get_hw_cap_args);
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	*fd_hw_caps = fd_core->hw_caps;
+
+	CAM_DBG(CAM_FD, "core:%d.%d wrapper:%d.%d mode:%d, raw:%d",
+		fd_hw_caps->core_version.major,
+		fd_hw_caps->core_version.minor,
+		fd_hw_caps->wrapper_version.major,
+		fd_hw_caps->wrapper_version.minor,
+		fd_hw_caps->supported_modes,
+		fd_hw_caps->raw_results_available);
+
+	return 0;
+}
+
+int cam_fd_hw_init(void *hw_priv, void *init_hw_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	struct cam_fd_core *fd_core;
+	struct cam_fd_hw_init_args *init_args =
+		(struct cam_fd_hw_init_args *)init_hw_args;
+	int rc = 0;
+
+	if (!fd_hw || !init_args) {
+		CAM_ERR(CAM_FD, "Invalid argument %pK %pK", fd_hw, init_args);
+		return -EINVAL;
+	}
+
+	if (arg_size != sizeof(struct cam_fd_hw_init_args)) {
+		CAM_ERR(CAM_FD, "Invalid arg size %d, %d", arg_size,
+			sizeof(struct cam_fd_hw_init_args));
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+
+	mutex_lock(&fd_hw->hw_mutex);
+	CAM_DBG(CAM_FD, "FD HW Init ref count before %d", fd_hw->open_count);
+
+	if (fd_hw->open_count > 0) {
+		rc = 0;
+		goto cdm_streamon;
+	}
+
+	rc = cam_fd_soc_enable_resources(&fd_hw->soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Enable SOC failed, rc=%d", rc);
+		goto unlock_return;
+	}
+
+	rc = cam_fd_hw_reset(hw_priv, NULL, 0);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Reset Failed, rc=%d", rc);
+		goto disable_soc;
+	}
+
+	cam_fd_hw_util_enable_power_on_settings(fd_hw);
+
+	fd_hw->hw_state = CAM_HW_STATE_POWER_UP;
+	fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+
+cdm_streamon:
+	fd_hw->open_count++;
+	CAM_DBG(CAM_FD, "FD HW Init ref count after %d", fd_hw->open_count);
+
+	mutex_unlock(&fd_hw->hw_mutex);
+
+	if (init_args->ctx_hw_private) {
+		struct cam_fd_ctx_hw_private *ctx_hw_private =
+			init_args->ctx_hw_private;
+
+		rc = cam_cdm_stream_on(ctx_hw_private->cdm_handle);
+		if (rc) {
+			CAM_ERR(CAM_FD, "CDM StreamOn fail :handle=0x%x, rc=%d",
+				ctx_hw_private->cdm_handle, rc);
+			return rc;
+		}
+	}
+
+	return rc;
+
+disable_soc:
+	if (cam_fd_soc_disable_resources(&fd_hw->soc_info))
+		CAM_ERR(CAM_FD, "Error in disable soc resources");
+unlock_return:
+	mutex_unlock(&fd_hw->hw_mutex);
+	return rc;
+}
+
+int cam_fd_hw_deinit(void *hw_priv, void *deinit_hw_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = hw_priv;
+	struct cam_fd_core *fd_core = NULL;
+	struct cam_fd_hw_deinit_args *deinit_args =
+		(struct cam_fd_hw_deinit_args *)deinit_hw_args;
+	int rc = 0;
+
+	if (!fd_hw || !deinit_hw_args) {
+		CAM_ERR(CAM_FD, "Invalid argument");
+		return -EINVAL;
+	}
+
+	if (arg_size != sizeof(struct cam_fd_hw_deinit_args)) {
+		CAM_ERR(CAM_FD, "Invalid arg size %d, %d", arg_size,
+			sizeof(struct cam_fd_hw_deinit_args));
+		return -EINVAL;
+	}
+
+	mutex_lock(&fd_hw->hw_mutex);
+	if (fd_hw->open_count == 0) {
+		mutex_unlock(&fd_hw->hw_mutex);
+		CAM_ERR(CAM_FD, "Error Unbalanced deinit");
+		return -EFAULT;
+	}
+
+	fd_hw->open_count--;
+	CAM_DBG(CAM_FD, "FD HW ref count=%d", fd_hw->open_count);
+
+	if (fd_hw->open_count > 0) {
+		rc = 0;
+		goto positive_ref_cnt;
+	}
+
+	rc = cam_fd_soc_disable_resources(&fd_hw->soc_info);
+	if (rc)
+		CAM_ERR(CAM_FD, "Failed in Disable SOC, rc=%d", rc);
+
+	fd_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+
+	/* With the ref_cnt correct, this should never happen */
+	WARN_ON(!fd_core);
+
+	fd_core->core_state = CAM_FD_CORE_STATE_POWERDOWN;
+
+positive_ref_cnt:
+	if (deinit_args->ctx_hw_private) {
+		struct cam_fd_ctx_hw_private *ctx_hw_private =
+			deinit_args->ctx_hw_private;
+
+		rc = cam_cdm_stream_off(ctx_hw_private->cdm_handle);
+		if (rc) {
+			CAM_ERR(CAM_FD,
+				"Failed in CDM StreamOff, handle=0x%x, rc=%d",
+				ctx_hw_private->cdm_handle, rc);
+		}
+	}
+
+	mutex_unlock(&fd_hw->hw_mutex);
+	return rc;
+}
+
+int cam_fd_hw_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	struct cam_fd_core *fd_core;
+	int rc;
+
+	if (!fd_hw) {
+		CAM_ERR(CAM_FD, "Invalid input handle");
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+
+	spin_lock(&fd_core->spin_lock);
+	if (fd_core->core_state == CAM_FD_CORE_STATE_RESET_PROGRESS) {
+		CAM_ERR(CAM_FD, "Reset not allowed in %d state",
+			fd_core->core_state);
+		spin_unlock(&fd_core->spin_lock);
+		return -EINVAL;
+	}
+
+	fd_core->results_valid = false;
+	fd_core->core_state = CAM_FD_CORE_STATE_RESET_PROGRESS;
+	spin_unlock(&fd_core->spin_lock);
+
+	rc = cam_fd_hw_util_fdwrapper_halt(fd_hw);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in HALT rc=%d", rc);
+		return rc;
+	}
+
+	rc = cam_fd_hw_util_fdwrapper_sync_reset(fd_hw);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in RESET rc=%d", rc);
+		return rc;
+	}
+
+	spin_lock(&fd_core->spin_lock);
+	fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+	spin_unlock(&fd_core->spin_lock);
+
+	return rc;
+}
+
+int cam_fd_hw_start(void *hw_priv, void *hw_start_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	struct cam_fd_core *fd_core;
+	struct cam_fd_hw_static_info *hw_static_info;
+	struct cam_fd_hw_cmd_start_args *start_args =
+		(struct cam_fd_hw_cmd_start_args *)hw_start_args;
+	struct cam_fd_ctx_hw_private *ctx_hw_private;
+	int rc;
+
+	if (!hw_priv || !start_args) {
+		CAM_ERR(CAM_FD, "Invalid input args %pK %pK", hw_priv,
+			start_args);
+		return -EINVAL;
+	}
+
+	if (arg_size != sizeof(struct cam_fd_hw_cmd_start_args)) {
+		CAM_ERR(CAM_FD, "Invalid arg size %d, %d", arg_size,
+			sizeof(struct cam_fd_hw_cmd_start_args));
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	hw_static_info = fd_core->hw_static_info;
+
+	spin_lock(&fd_core->spin_lock);
+	if (fd_core->core_state != CAM_FD_CORE_STATE_IDLE) {
+		CAM_ERR(CAM_FD, "Cannot start in %d state",
+			fd_core->core_state);
+		spin_unlock(&fd_core->spin_lock);
+		return -EINVAL;
+	}
+
+	/*
+	 * We are about to start FD HW processing, save the request
+	 * private data which is being processed by HW. Once the frame
+	 * processing is finished, process_cmd(FRAME_DONE) should be called
+	 * with same hw_req_private as input.
+	 */
+	fd_core->hw_req_private = start_args->hw_req_private;
+	fd_core->core_state = CAM_FD_CORE_STATE_PROCESSING;
+	fd_core->results_valid = false;
+	spin_unlock(&fd_core->spin_lock);
+
+	ctx_hw_private = start_args->ctx_hw_private;
+
+	/* Before starting HW process, clear processing complete */
+	reinit_completion(&fd_core->processing_complete);
+
+	if (hw_static_info->enable_errata_wa.single_irq_only) {
+		cam_fd_soc_register_write(&fd_hw->soc_info, CAM_FD_REG_WRAPPER,
+			hw_static_info->wrapper_regs.irq_mask,
+			CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_FRAME_DONE));
+	}
+
+	if (start_args->num_hw_update_entries > 0) {
+		struct cam_cdm_bl_request *cdm_cmd = ctx_hw_private->cdm_cmd;
+		struct cam_hw_update_entry *cmd;
+		int i;
+
+		cdm_cmd->cmd_arrary_count = start_args->num_hw_update_entries;
+		cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE;
+		cdm_cmd->flag = false;
+		cdm_cmd->userdata = NULL;
+		cdm_cmd->cookie = 0;
+
+		for (i = 0 ; i <= start_args->num_hw_update_entries; i++) {
+			cmd = (start_args->hw_update_entries + i);
+			cdm_cmd->cmd[i].bl_addr.mem_handle = cmd->handle;
+			cdm_cmd->cmd[i].offset = cmd->offset;
+			cdm_cmd->cmd[i].len = cmd->len;
+		}
+
+		rc = cam_cdm_submit_bls(ctx_hw_private->cdm_handle, cdm_cmd);
+		if (rc) {
+			CAM_ERR(CAM_FD,
+				"Failed to submit cdm commands, rc=%d", rc);
+			goto error;
+		}
+	} else {
+		CAM_ERR(CAM_FD, "Invalid number of hw update entries");
+		rc = -EINVAL;
+		goto error;
+	}
+
+	return 0;
+error:
+	spin_lock(&fd_core->spin_lock);
+	fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+	spin_unlock(&fd_core->spin_lock);
+
+	return rc;
+}
+
+int cam_fd_hw_halt_reset(void *hw_priv, void *stop_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	struct cam_fd_core *fd_core;
+	int rc;
+
+	if (!fd_hw) {
+		CAM_ERR(CAM_FD, "Invalid input handle");
+		return -EINVAL;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+
+	spin_lock(&fd_core->spin_lock);
+	if ((fd_core->core_state == CAM_FD_CORE_STATE_POWERDOWN) ||
+		(fd_core->core_state == CAM_FD_CORE_STATE_RESET_PROGRESS)) {
+		CAM_ERR(CAM_FD, "Reset not allowed in %d state",
+			fd_core->core_state);
+		spin_unlock(&fd_core->spin_lock);
+		return -EINVAL;
+	}
+
+	fd_core->results_valid = false;
+	fd_core->core_state = CAM_FD_CORE_STATE_RESET_PROGRESS;
+	spin_unlock(&fd_core->spin_lock);
+
+	rc = cam_fd_hw_util_fdwrapper_halt(fd_hw);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in HALT rc=%d", rc);
+		return rc;
+	}
+
+	/* HALT must be followed by RESET */
+	rc = cam_fd_hw_util_fdwrapper_sync_reset(fd_hw);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in RESET rc=%d", rc);
+		return rc;
+	}
+
+	spin_lock(&fd_core->spin_lock);
+	fd_core->core_state = CAM_FD_CORE_STATE_IDLE;
+	spin_unlock(&fd_core->spin_lock);
+
+	return rc;
+}
+
+int cam_fd_hw_reserve(void *hw_priv, void *hw_reserve_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	int rc = -EINVAL;
+	struct cam_fd_ctx_hw_private *ctx_hw_private;
+	struct cam_fd_hw_reserve_args *reserve_args =
+		(struct cam_fd_hw_reserve_args *)hw_reserve_args;
+	struct cam_cdm_acquire_data cdm_acquire;
+	struct cam_cdm_bl_request *cdm_cmd;
+	int i;
+
+	if (!fd_hw || !reserve_args) {
+		CAM_ERR(CAM_FD, "Invalid input %pK, %pK", fd_hw, reserve_args);
+		return -EINVAL;
+	}
+
+	if (arg_size != sizeof(struct cam_fd_hw_reserve_args)) {
+		CAM_ERR(CAM_FD, "Invalid arg size %d, %d", arg_size,
+			sizeof(struct cam_fd_hw_reserve_args));
+		return -EINVAL;
+	}
+
+	cdm_cmd = kzalloc(((sizeof(struct cam_cdm_bl_request)) +
+			((CAM_FD_MAX_HW_ENTRIES - 1) *
+			sizeof(struct cam_cdm_bl_cmd))), GFP_KERNEL);
+	if (!cdm_cmd)
+		return -ENOMEM;
+
+	ctx_hw_private = kzalloc(sizeof(struct cam_fd_ctx_hw_private),
+		GFP_KERNEL);
+	if (!ctx_hw_private) {
+		kfree(cdm_cmd);
+		return -ENOMEM;
+	}
+
+	memset(&cdm_acquire, 0, sizeof(cdm_acquire));
+	strlcpy(cdm_acquire.identifier, "fd", sizeof("fd"));
+	cdm_acquire.cell_index = fd_hw->soc_info.index;
+	cdm_acquire.handle = 0;
+	cdm_acquire.userdata = ctx_hw_private;
+	cdm_acquire.cam_cdm_callback = cam_fd_hw_util_cdm_callback;
+	cdm_acquire.id = CAM_CDM_VIRTUAL;
+	cdm_acquire.base_array_cnt = fd_hw->soc_info.num_reg_map;
+	for (i = 0; i < fd_hw->soc_info.num_reg_map; i++)
+		cdm_acquire.base_array[i] = &fd_hw->soc_info.reg_map[i];
+
+	rc = cam_cdm_acquire(&cdm_acquire);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed to acquire the CDM HW");
+		goto error;
+	}
+
+	ctx_hw_private->hw_ctx = reserve_args->hw_ctx;
+	ctx_hw_private->fd_hw = fd_hw;
+	ctx_hw_private->mode = reserve_args->mode;
+	ctx_hw_private->cdm_handle = cdm_acquire.handle;
+	ctx_hw_private->cdm_ops = cdm_acquire.ops;
+	ctx_hw_private->cdm_cmd = cdm_cmd;
+
+	reserve_args->ctx_hw_private = ctx_hw_private;
+
+	CAM_DBG(CAM_FD, "private=%pK, hw_ctx=%pK, mode=%d, cdm_handle=0x%x",
+		ctx_hw_private, ctx_hw_private->hw_ctx, ctx_hw_private->mode,
+		ctx_hw_private->cdm_handle);
+
+	return 0;
+error:
+	kfree(ctx_hw_private);
+	kfree(cdm_cmd);
+	return rc;
+}
+
+int cam_fd_hw_release(void *hw_priv, void *hw_release_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	int rc = -EINVAL;
+	struct cam_fd_ctx_hw_private *ctx_hw_private;
+	struct cam_fd_hw_release_args *release_args =
+		(struct cam_fd_hw_release_args *)hw_release_args;
+
+	if (!fd_hw || !release_args) {
+		CAM_ERR(CAM_FD, "Invalid input %pK, %pK", fd_hw, release_args);
+		return -EINVAL;
+	}
+
+	if (arg_size != sizeof(struct cam_fd_hw_release_args)) {
+		CAM_ERR(CAM_FD, "Invalid arg size %d, %d", arg_size,
+			sizeof(struct cam_fd_hw_release_args));
+		return -EINVAL;
+	}
+
+	ctx_hw_private =
+		(struct cam_fd_ctx_hw_private *)release_args->ctx_hw_private;
+
+	rc = cam_cdm_release(ctx_hw_private->cdm_handle);
+	if (rc)
+		CAM_ERR(CAM_FD, "Release cdm handle failed, handle=0x%x, rc=%d",
+			ctx_hw_private->cdm_handle, rc);
+
+	kfree(ctx_hw_private);
+	release_args->ctx_hw_private = NULL;
+
+	return 0;
+}
+
+int cam_fd_hw_process_cmd(void *hw_priv, uint32_t cmd_type,
+	void *cmd_args, uint32_t arg_size)
+{
+	struct cam_hw_info *fd_hw = (struct cam_hw_info *)hw_priv;
+	int rc = -EINVAL;
+
+	if (!hw_priv || !cmd_args ||
+		(cmd_type >= CAM_FD_HW_CMD_MAX)) {
+		CAM_ERR(CAM_FD, "Invalid arguments %pK %pK %d", hw_priv,
+			cmd_args, cmd_type);
+		return -EINVAL;
+	}
+
+	switch (cmd_type) {
+	case CAM_FD_HW_CMD_REGISTER_CALLBACK: {
+		struct cam_fd_hw_cmd_set_irq_cb *irq_cb_args;
+		struct cam_fd_core *fd_core =
+			(struct cam_fd_core *)fd_hw->core_info;
+
+		if (sizeof(struct cam_fd_hw_cmd_set_irq_cb) != arg_size) {
+			CAM_ERR(CAM_FD, "cmd_type %d, size mismatch %d",
+				cmd_type, arg_size);
+			break;
+		}
+
+		irq_cb_args = (struct cam_fd_hw_cmd_set_irq_cb *)cmd_args;
+		fd_core->irq_cb.cam_fd_hw_mgr_cb =
+			irq_cb_args->cam_fd_hw_mgr_cb;
+		fd_core->irq_cb.data = irq_cb_args->data;
+		rc = 0;
+		break;
+	}
+	case CAM_FD_HW_CMD_PRESTART: {
+		struct cam_fd_hw_cmd_prestart_args *prestart_args;
+
+		if (sizeof(struct cam_fd_hw_cmd_prestart_args) != arg_size) {
+			CAM_ERR(CAM_FD, "cmd_type %d, size mismatch %d",
+				cmd_type, arg_size);
+			break;
+		}
+
+		prestart_args = (struct cam_fd_hw_cmd_prestart_args *)cmd_args;
+		rc = cam_fd_hw_util_processcmd_prestart(fd_hw, prestart_args);
+		break;
+	}
+	case CAM_FD_HW_CMD_FRAME_DONE: {
+		struct cam_fd_hw_frame_done_args *cmd_frame_results;
+
+		if (sizeof(struct cam_fd_hw_frame_done_args) !=
+			arg_size) {
+			CAM_ERR(CAM_FD, "cmd_type %d, size mismatch %d",
+				cmd_type, arg_size);
+			break;
+		}
+
+		cmd_frame_results =
+			(struct cam_fd_hw_frame_done_args *)cmd_args;
+		rc = cam_fd_hw_util_processcmd_frame_done(fd_hw,
+			cmd_frame_results);
+		break;
+	}
+	default:
+		break;
+	}
+
+	return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.h
new file mode 100644
index 0000000..bdd72af
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.h
@@ -0,0 +1,244 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_CORE_H_
+#define _CAM_FD_HW_CORE_H_
+
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <media/cam_defs.h>
+#include <media/cam_fd.h>
+
+#include "cam_common_util.h"
+#include "cam_debug_util.h"
+#include "cam_io_util.h"
+#include "cam_cpas_api.h"
+#include "cam_cdm_intf_api.h"
+#include "cam_fd_hw_intf.h"
+#include "cam_fd_hw_soc.h"
+
+#define CAM_FD_IRQ_TO_MASK(irq)        (1 << (irq))
+#define CAM_FD_MASK_TO_IRQ(mask, irq)  ((mask) >> (irq))
+
+#define CAM_FD_HW_HALT_RESET_TIMEOUT   100
+
+/**
+ * enum cam_fd_core_state - FD Core internal states
+ *
+ * @CAM_FD_CORE_STATE_POWERDOWN       : Indicates FD core is powered down
+ * @CAM_FD_CORE_STATE_IDLE            : Indicates FD HW is in idle state.
+ *                                      Core can be in this state when it is
+ *                                      ready to process frames or when
+ *                                      processing is finished and results are
+ *                                      available
+ * @CAM_FD_CORE_STATE_PROCESSING      : Indicates FD core is processing frame
+ * @CAM_FD_CORE_STATE_READING_RESULTS : Indicates results are being read from
+ *                                      FD core
+ * @CAM_FD_CORE_STATE_RESET_PROGRESS  :  Indicates FD Core is in reset state
+ */
+enum cam_fd_core_state {
+	CAM_FD_CORE_STATE_POWERDOWN,
+	CAM_FD_CORE_STATE_IDLE,
+	CAM_FD_CORE_STATE_PROCESSING,
+	CAM_FD_CORE_STATE_READING_RESULTS,
+	CAM_FD_CORE_STATE_RESET_PROGRESS,
+};
+
+/**
+ * struct cam_fd_ctx_hw_private : HW private information for a specific hw ctx.
+ *                                This information is populated by HW layer on
+ *                                reserve() and given back to HW Mgr as private
+ *                                data for the hw context. This private_data
+ *                                has to be passed by HW Mgr layer while
+ *                                further HW layer calls
+ *
+ * @hw_ctx           : Corresponding hw_ctx pointer
+ * @fd_hw            : FD HW info pointer
+ * @cdm_handle       : CDM Handle for this context
+ * @cdm_ops          : CDM Ops
+ * @cdm_cmd          : CDM command pointer
+ * @mode             : Mode this context is running
+ * @curr_req_private : Current Request information
+ *
+ */
+struct cam_fd_ctx_hw_private {
+	void                          *hw_ctx;
+	struct cam_hw_info            *fd_hw;
+	uint32_t                       cdm_handle;
+	struct cam_cdm_utils_ops      *cdm_ops;
+	struct cam_cdm_bl_request     *cdm_cmd;
+	enum cam_fd_hw_mode            mode;
+	struct cam_fd_hw_req_private  *curr_req_private;
+};
+
+/**
+ * struct cam_fd_core_regs : FD HW Core register offsets info
+ *
+ * @version              : Offset of version register
+ * @control              : Offset of control register
+ * @result_cnt           : Offset of result count register
+ * @result_addr          : Offset of results address register
+ * @image_addr           : Offset of image address register
+ * @work_addr            : Offset of work address register
+ * @ro_mode              : Offset of ro_mode register
+ * @results_reg_base     : Offset of results_reg_base register
+ * @raw_results_reg_base : Offset of raw_results_reg_base register
+ *
+ */
+struct cam_fd_core_regs {
+	uint32_t       version;
+	uint32_t       control;
+	uint32_t       result_cnt;
+	uint32_t       result_addr;
+	uint32_t       image_addr;
+	uint32_t       work_addr;
+	uint32_t       ro_mode;
+	uint32_t       results_reg_base;
+	uint32_t       raw_results_reg_base;
+};
+
+/**
+ * struct cam_fd_core_regs : FD HW Wrapper register offsets info
+ *
+ * @wrapper_version     : Offset of wrapper_version register
+ * @cgc_disable         : Offset of cgc_disable register
+ * @hw_stop             : Offset of hw_stop register
+ * @sw_reset            : Offset of sw_reset register
+ * @vbif_req_priority   : Offset of vbif_req_priority register
+ * @vbif_priority_level : Offset of vbif_priority_level register
+ * @vbif_done_status    : Offset of vbif_done_status register
+ * @irq_mask            : Offset of irq mask register
+ * @irq_status          : Offset of irq status register
+ * @irq_clear           : Offset of irq clear register
+ *
+ */
+struct cam_fd_wrapper_regs {
+	uint32_t       wrapper_version;
+	uint32_t       cgc_disable;
+	uint32_t       hw_stop;
+	uint32_t       sw_reset;
+	uint32_t       vbif_req_priority;
+	uint32_t       vbif_priority_level;
+	uint32_t       vbif_done_status;
+	uint32_t       irq_mask;
+	uint32_t       irq_status;
+	uint32_t       irq_clear;
+};
+
+/**
+ * struct cam_fd_hw_errata_wa : FD HW Errata workaround enable/dsiable info
+ *
+ * @single_irq_only         : Whether to enable only one irq at any time
+ * @ro_mode_enable_always   : Whether to enable ro mode always
+ * @ro_mode_results_invalid : Whether results written directly into output
+ *                            memory by HW are valid or not
+ */
+struct cam_fd_hw_errata_wa {
+	bool   single_irq_only;
+	bool   ro_mode_enable_always;
+	bool   ro_mode_results_invalid;
+};
+
+/**
+ * struct cam_fd_hw_results_prop : FD HW Results properties
+ *
+ * @max_faces             : Maximum number of faces supported
+ * @per_face_entries      : Number of register with properties for each face
+ * @raw_results_entries   : Number of raw results entries for the full search
+ * @raw_results_available : Whether raw results available on this HW
+ *
+ */
+struct cam_fd_hw_results_prop {
+	uint32_t       max_faces;
+	uint32_t       per_face_entries;
+	uint32_t       raw_results_entries;
+	bool           raw_results_available;
+};
+
+/**
+ * struct cam_fd_hw_static_info : FD HW information based on HW version
+ *
+ * @core_version       : Core version of FD HW
+ * @wrapper_version    : Wrapper version of FD HW
+ * @core_regs          : Register offset information for core registers
+ * @wrapper_regs       : Register offset information for wrapper registers
+ * @results            : Information about results available on this HW
+ * @enable_errata_wa   : Errata workaround information
+ * @irq_mask           : IRQ mask to enable
+ * @qos_priority       : QoS priority setting for this chipset
+ * @qos_priority_level : QoS priority level setting for this chipset
+ * @supported_modes    : Supported HW modes on this HW version
+ * @ro_mode_supported  : Whether RO mode is supported on this HW
+ *
+ */
+struct cam_fd_hw_static_info {
+	struct cam_hw_version          core_version;
+	struct cam_hw_version          wrapper_version;
+	struct cam_fd_core_regs        core_regs;
+	struct cam_fd_wrapper_regs     wrapper_regs;
+	struct cam_fd_hw_results_prop  results;
+	struct cam_fd_hw_errata_wa     enable_errata_wa;
+	uint32_t                       irq_mask;
+	uint32_t                       qos_priority;
+	uint32_t                       qos_priority_level;
+	uint32_t                       supported_modes;
+	bool                           ro_mode_supported;
+};
+
+/**
+ * struct cam_fd_core : FD HW core data structure
+ *
+ * @hw_static_info      : HW information specific to version
+ * @hw_caps             : HW capabilities
+ * @core_state          : Current HW state
+ * @processing_complete : Whether processing is complete
+ * @reset_complete      : Whether reset is complete
+ * @halt_complete       : Whether halt is complete
+ * @hw_req_private      : Request that is being currently processed by HW
+ * @results_valid       : Whether HW frame results are available to get
+ * @spin_lock           : Mutex to protect shared data in hw layer
+ * @irq_cb              : HW Manager callback information
+ *
+ */
+struct cam_fd_core {
+	struct cam_fd_hw_static_info   *hw_static_info;
+	struct cam_fd_hw_caps           hw_caps;
+	enum cam_fd_core_state          core_state;
+	struct completion               processing_complete;
+	struct completion               reset_complete;
+	struct completion               halt_complete;
+	struct cam_fd_hw_req_private   *hw_req_private;
+	bool                            results_valid;
+	spinlock_t                      spin_lock;
+	struct cam_fd_hw_cmd_set_irq_cb irq_cb;
+};
+
+int cam_fd_hw_util_get_hw_caps(struct cam_hw_info *fd_hw,
+	struct cam_fd_hw_caps *hw_caps);
+irqreturn_t cam_fd_hw_irq(int irq_num, void *data);
+
+int cam_fd_hw_get_hw_caps(void *hw_priv, void *get_hw_cap_args,
+	uint32_t arg_size);
+int cam_fd_hw_init(void *hw_priv, void *init_hw_args, uint32_t arg_size);
+int cam_fd_hw_deinit(void *hw_priv, void *deinit_hw_args, uint32_t arg_size);
+int cam_fd_hw_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size);
+int cam_fd_hw_reserve(void *hw_priv, void *hw_reserve_args, uint32_t arg_size);
+int cam_fd_hw_release(void *hw_priv, void *hw_release_args, uint32_t arg_size);
+int cam_fd_hw_start(void *hw_priv, void *hw_start_args, uint32_t arg_size);
+int cam_fd_hw_halt_reset(void *hw_priv, void *stop_args, uint32_t arg_size);
+int cam_fd_hw_read(void *hw_priv, void *read_args, uint32_t arg_size);
+int cam_fd_hw_write(void *hw_priv, void *write_args, uint32_t arg_size);
+int cam_fd_hw_process_cmd(void *hw_priv, uint32_t cmd_type,
+	void *cmd_args, uint32_t arg_size);
+
+#endif /* _CAM_FD_HW_CORE_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c
new file mode 100644
index 0000000..803da76
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c
@@ -0,0 +1,223 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "cam_subdev.h"
+#include "cam_fd_hw_intf.h"
+#include "cam_fd_hw_core.h"
+#include "cam_fd_hw_soc.h"
+#include "cam_fd_hw_v41.h"
+
+static int cam_fd_hw_dev_probe(struct platform_device *pdev)
+{
+	struct cam_hw_info *fd_hw;
+	struct cam_hw_intf *fd_hw_intf;
+	struct cam_fd_core *fd_core;
+	const struct of_device_id *match_dev = NULL;
+	struct cam_fd_hw_static_info *hw_static_info = NULL;
+	int rc = 0;
+	struct cam_fd_hw_init_args init_args;
+	struct cam_fd_hw_deinit_args deinit_args;
+
+	fd_hw_intf = kzalloc(sizeof(struct cam_hw_intf), GFP_KERNEL);
+	if (!fd_hw_intf)
+		return -ENOMEM;
+
+	fd_hw = kzalloc(sizeof(struct cam_hw_info), GFP_KERNEL);
+	if (!fd_hw) {
+		kfree(fd_hw_intf);
+		return -ENOMEM;
+	}
+
+	fd_core = kzalloc(sizeof(struct cam_fd_core), GFP_KERNEL);
+	if (!fd_core) {
+		kfree(fd_hw);
+		kfree(fd_hw_intf);
+		return -ENOMEM;
+	}
+
+	fd_hw_intf->hw_priv = fd_hw;
+	fd_hw->core_info = fd_core;
+
+	fd_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
+	fd_hw->soc_info.pdev = pdev;
+	fd_hw->soc_info.dev = &pdev->dev;
+	fd_hw->soc_info.dev_name = pdev->name;
+	fd_hw->open_count = 0;
+	mutex_init(&fd_hw->hw_mutex);
+	spin_lock_init(&fd_hw->hw_lock);
+	init_completion(&fd_hw->hw_complete);
+
+	spin_lock_init(&fd_core->spin_lock);
+	init_completion(&fd_core->processing_complete);
+	init_completion(&fd_core->halt_complete);
+	init_completion(&fd_core->reset_complete);
+
+	fd_hw_intf->hw_ops.get_hw_caps = cam_fd_hw_get_hw_caps;
+	fd_hw_intf->hw_ops.init = cam_fd_hw_init;
+	fd_hw_intf->hw_ops.deinit = cam_fd_hw_deinit;
+	fd_hw_intf->hw_ops.reset = cam_fd_hw_reset;
+	fd_hw_intf->hw_ops.reserve = cam_fd_hw_reserve;
+	fd_hw_intf->hw_ops.release = cam_fd_hw_release;
+	fd_hw_intf->hw_ops.start = cam_fd_hw_start;
+	fd_hw_intf->hw_ops.stop = cam_fd_hw_halt_reset;
+	fd_hw_intf->hw_ops.read = NULL;
+	fd_hw_intf->hw_ops.write = NULL;
+	fd_hw_intf->hw_ops.process_cmd = cam_fd_hw_process_cmd;
+	fd_hw_intf->hw_type = CAM_HW_FD;
+
+	match_dev = of_match_device(pdev->dev.driver->of_match_table,
+		&pdev->dev);
+	if (!match_dev || !match_dev->data) {
+		CAM_ERR(CAM_FD, "No Of_match data, %pK", match_dev);
+		rc = -EINVAL;
+		goto free_memory;
+	}
+	hw_static_info = (struct cam_fd_hw_static_info *)match_dev->data;
+	fd_core->hw_static_info = hw_static_info;
+
+	CAM_DBG(CAM_FD, "HW Static Info : version core[%d.%d] wrapper[%d.%d]",
+		hw_static_info->core_version.major,
+		hw_static_info->core_version.minor,
+		hw_static_info->wrapper_version.major,
+		hw_static_info->wrapper_version.minor);
+
+	rc = cam_fd_soc_init_resources(&fd_hw->soc_info, cam_fd_hw_irq, fd_hw);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed to init soc, rc=%d", rc);
+		goto free_memory;
+	}
+
+	fd_hw_intf->hw_idx = fd_hw->soc_info.index;
+
+	memset(&init_args, 0x0, sizeof(init_args));
+	memset(&deinit_args, 0x0, sizeof(deinit_args));
+	rc = cam_fd_hw_init(fd_hw, &init_args, sizeof(init_args));
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed to hw init, rc=%d", rc);
+		goto deinit_platform_res;
+	}
+
+	rc = cam_fd_hw_util_get_hw_caps(fd_hw, &fd_core->hw_caps);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed to get hw caps, rc=%d", rc);
+		goto deinit_hw;
+	}
+
+	rc = cam_fd_hw_deinit(fd_hw, &deinit_args, sizeof(deinit_args));
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed to deinit hw, rc=%d", rc);
+		goto deinit_platform_res;
+	}
+
+	platform_set_drvdata(pdev, fd_hw_intf);
+	CAM_DBG(CAM_FD, "FD-%d probe successful", fd_hw_intf->hw_idx);
+
+	return rc;
+
+deinit_hw:
+	if (cam_fd_hw_deinit(fd_hw, &deinit_args, sizeof(deinit_args)))
+		CAM_ERR(CAM_FD, "Failed in hw deinit");
+deinit_platform_res:
+	if (cam_fd_soc_deinit_resources(&fd_hw->soc_info))
+		CAM_ERR(CAM_FD, "Failed in soc deinit");
+	mutex_destroy(&fd_hw->hw_mutex);
+free_memory:
+	kfree(fd_hw);
+	kfree(fd_hw_intf);
+	kfree(fd_core);
+
+	return rc;
+}
+
+static int cam_fd_hw_dev_remove(struct platform_device *pdev)
+{
+	int rc = 0;
+	struct cam_hw_intf *fd_hw_intf;
+	struct cam_hw_info *fd_hw;
+	struct cam_fd_core *fd_core;
+
+	fd_hw_intf = platform_get_drvdata(pdev);
+	if (!fd_hw_intf) {
+		CAM_ERR(CAM_FD, "Invalid fd_hw_intf from pdev");
+		return -EINVAL;
+	}
+
+	fd_hw = fd_hw_intf->hw_priv;
+	if (!fd_hw) {
+		CAM_ERR(CAM_FD, "Invalid fd_hw from fd_hw_intf");
+		rc = -ENODEV;
+		goto free_fd_hw_intf;
+	}
+
+	fd_core = (struct cam_fd_core *)fd_hw->core_info;
+	if (!fd_core) {
+		CAM_ERR(CAM_FD, "Invalid fd_core from fd_hw");
+		rc = -EINVAL;
+		goto deinit_platform_res;
+	}
+
+	kfree(fd_core);
+
+deinit_platform_res:
+	rc = cam_fd_soc_deinit_resources(&fd_hw->soc_info);
+	if (rc)
+		CAM_ERR(CAM_FD, "Error in FD soc deinit, rc=%d", rc);
+
+	mutex_destroy(&fd_hw->hw_mutex);
+	kfree(fd_hw);
+
+free_fd_hw_intf:
+	kfree(fd_hw_intf);
+
+	return rc;
+}
+
+static const struct of_device_id cam_fd_hw_dt_match[] = {
+	{
+		.compatible = "qcom,fd41",
+		.data = &cam_fd_wrapper120_core410_info,
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(of, cam_fd_hw_dt_match);
+
+static struct platform_driver cam_fd_hw_driver = {
+	.probe = cam_fd_hw_dev_probe,
+	.remove = cam_fd_hw_dev_remove,
+	.driver = {
+		.name = "cam_fd_hw",
+		.owner = THIS_MODULE,
+		.of_match_table = cam_fd_hw_dt_match,
+	},
+};
+
+static int __init cam_fd_hw_init_module(void)
+{
+	return platform_driver_register(&cam_fd_hw_driver);
+}
+
+static void __exit cam_fd_hw_exit_module(void)
+{
+	platform_driver_unregister(&cam_fd_hw_driver);
+}
+
+module_init(cam_fd_hw_init_module);
+module_exit(cam_fd_hw_exit_module);
+MODULE_DESCRIPTION("CAM FD HW driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h
new file mode 100644
index 0000000..aae7648
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h
@@ -0,0 +1,289 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_INTF_H_
+#define _CAM_FD_HW_INTF_H_
+
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <media/cam_cpas.h>
+#include <media/cam_req_mgr.h>
+#include <media/cam_fd.h>
+
+#include "cam_io_util.h"
+#include "cam_soc_util.h"
+#include "cam_hw.h"
+#include "cam_hw_intf.h"
+#include "cam_subdev.h"
+#include "cam_cpas_api.h"
+#include "cam_hw_mgr_intf.h"
+#include "cam_debug_util.h"
+
+#define CAM_FD_MAX_IO_BUFFERS        5
+#define CAM_FD_MAX_HW_ENTRIES        5
+
+/**
+ * enum cam_fd_hw_type - Enum for FD HW type
+ *
+ * @CAM_HW_FD : FaceDetection HW type
+ */
+enum cam_fd_hw_type {
+	CAM_HW_FD,
+};
+
+/**
+ * enum cam_fd_hw_mode - Mode in which HW can run
+ *
+ * @CAM_FD_MODE_FACEDETECTION : Face Detection mode in which face search
+ *                              is done on the given frame
+ * @CAM_FD_MODE_PYRAMID       : Pyramid mode where a pyramid image is generated
+ *                              from an input image
+ */
+enum cam_fd_hw_mode {
+	CAM_FD_MODE_FACEDETECTION    = 0x1,
+	CAM_FD_MODE_PYRAMID          = 0x2,
+};
+
+/**
+ * enum cam_fd_priority - FD priority levels
+ *
+ * @CAM_FD_PRIORITY_HIGH   : Indicates high priority client, driver prioritizes
+ *                           frame requests coming from contexts with HIGH
+ *                           priority compared to context with normal priority
+ * @CAM_FD_PRIORITY_NORMAL : Indicates normal priority client
+ */
+enum cam_fd_priority {
+	CAM_FD_PRIORITY_HIGH         = 0x0,
+	CAM_FD_PRIORITY_NORMAL,
+};
+
+/**
+ * enum cam_fd_hw_irq_type - FD HW IRQ types
+ *
+ * @CAM_FD_IRQ_FRAME_DONE : Indicates frame processing is finished
+ * @CAM_FD_IRQ_HALT_DONE  : Indicates HW halt is finished
+ * @CAM_FD_IRQ_RESET_DONE : Indicates HW reset is finished
+ */
+enum cam_fd_hw_irq_type {
+	CAM_FD_IRQ_FRAME_DONE,
+	CAM_FD_IRQ_HALT_DONE,
+	CAM_FD_IRQ_RESET_DONE,
+};
+
+/**
+ * enum cam_fd_hw_cmd_type - FD HW layer custom commands
+ *
+ * @CAM_FD_HW_CMD_PRESTART          : Command to process pre-start settings
+ * @CAM_FD_HW_CMD_FRAME_DONE        : Command to process frame done settings
+ * @CAM_FD_HW_CMD_UPDATE_SOC        : Command to process soc update
+ * @CAM_FD_HW_CMD_REGISTER_CALLBACK : Command to set hw mgr callback
+ * @CAM_FD_HW_CMD_MAX               : Indicates max cmd
+ */
+enum cam_fd_hw_cmd_type {
+	CAM_FD_HW_CMD_PRESTART,
+	CAM_FD_HW_CMD_FRAME_DONE,
+	CAM_FD_HW_CMD_UPDATE_SOC,
+	CAM_FD_HW_CMD_REGISTER_CALLBACK,
+	CAM_FD_HW_CMD_MAX,
+};
+
+/**
+ * struct cam_fd_hw_io_buffer : FD HW IO Buffer information
+ *
+ * @valid    : Whether this IO Buf configuration is valid
+ * @io_cfg   : IO Configuration information
+ * @num_buf  : Number planes in io_addr, cpu_addr array
+ * @io_addr  : Array of IO address information for planes
+ * @cpu_addr : Array of CPU address information for planes
+ */
+struct cam_fd_hw_io_buffer {
+	bool                   valid;
+	struct cam_buf_io_cfg *io_cfg;
+	uint32_t               num_buf;
+	uint64_t               io_addr[CAM_PACKET_MAX_PLANES];
+	uint64_t               cpu_addr[CAM_PACKET_MAX_PLANES];
+};
+
+/**
+ * struct cam_fd_hw_req_private : FD HW layer's private information
+ *               specific to a request
+ *
+ * @ctx_hw_private  : FD HW layer's ctx specific private data
+ * @request_id      : Request ID corresponding to this private information
+ * @get_raw_results : Whether to get raw results for this request
+ * @ro_mode_enabled : Whether RO mode is enabled for this request
+ * @fd_results      : Pointer to save face detection results
+ * @raw_results     : Pointer to save face detection raw results
+ */
+struct cam_fd_hw_req_private {
+	void                  *ctx_hw_private;
+	uint64_t               request_id;
+	bool                   get_raw_results;
+	bool                   ro_mode_enabled;
+	struct cam_fd_results *fd_results;
+	uint32_t              *raw_results;
+};
+
+/**
+ * struct cam_fd_hw_reserve_args : Reserve args for this HW context
+ *
+ * @hw_ctx         : HW context for which reserve is requested
+ * @mode           : Mode for which this reserve is requested
+ * @ctx_hw_private : Pointer to save HW layer's private information specific
+ *                   to this hw context. This has to be passed while calling
+ *                   further HW layer calls
+ */
+struct cam_fd_hw_reserve_args {
+	void                  *hw_ctx;
+	enum cam_fd_hw_mode    mode;
+	void                  *ctx_hw_private;
+};
+
+/**
+ * struct cam_fd_hw_release_args : Release args for this HW context
+ *
+ * @hw_ctx         : HW context for which release is requested
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ */
+struct cam_fd_hw_release_args {
+	void    *hw_ctx;
+	void    *ctx_hw_private;
+};
+
+/**
+ * struct cam_fd_hw_init_args : Init args for this HW context
+ *
+ * @hw_ctx         : HW context for which init is requested
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ */
+struct cam_fd_hw_init_args {
+	void    *hw_ctx;
+	void    *ctx_hw_private;
+};
+
+/**
+ * struct cam_fd_hw_deinit_args : Deinit args for this HW context
+ *
+ * @hw_ctx         : HW context for which deinit is requested
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ */
+struct cam_fd_hw_deinit_args {
+	void    *hw_ctx;
+	void    *ctx_hw_private;
+};
+
+/**
+ * struct cam_fd_hw_cmd_prestart_args : Prestart command args
+ *
+ * @hw_ctx               : HW context which submitted this prestart
+ * @ctx_hw_private       : HW layer's private information specific to
+ *                         this hw context
+ * @request_id           : Request ID corresponds to this pre-start command
+ * @get_raw_results      : Whether to get raw results for this request
+ * @input_buf            : Input IO Buffer information for this request
+ * @output_buf           : Output IO Buffer information for this request
+ * @cmd_buf_addr         : Command buffer address to fill kmd commands
+ * @size                 : Size available in command buffer
+ * @pre_config_buf_size  : Buffer size filled with commands by KMD that has
+ *                         to be inserted before umd commands
+ * @post_config_buf_size : Buffer size filled with commands by KMD that has
+ *                         to be inserted after umd commands
+ * @hw_req_private       : HW layer's private information specific to
+ *                         this request
+ */
+struct cam_fd_hw_cmd_prestart_args {
+	void                         *hw_ctx;
+	void                         *ctx_hw_private;
+	uint64_t                      request_id;
+	bool                          get_raw_results;
+	struct cam_fd_hw_io_buffer    input_buf[CAM_FD_MAX_IO_BUFFERS];
+	struct cam_fd_hw_io_buffer    output_buf[CAM_FD_MAX_IO_BUFFERS];
+	uint32_t                     *cmd_buf_addr;
+	uint32_t                      size;
+	uint32_t                      pre_config_buf_size;
+	uint32_t                      post_config_buf_size;
+	struct cam_fd_hw_req_private  hw_req_private;
+};
+
+/**
+ * struct cam_fd_hw_cmd_start_args : Start command args
+ *
+ * @hw_ctx                : HW context which submitting start command
+ * @ctx_hw_private        : HW layer's private information specific to
+ *                            this hw context
+ * @hw_req_private        : HW layer's private information specific to
+ *          this request
+ * @hw_update_entries     : HW update entries corresponds to this request
+ * @num_hw_update_entries : Number of hw update entries
+ */
+struct cam_fd_hw_cmd_start_args {
+	void                          *hw_ctx;
+	void                          *ctx_hw_private;
+	struct cam_fd_hw_req_private  *hw_req_private;
+	struct cam_hw_update_entry    *hw_update_entries;
+	uint32_t                       num_hw_update_entries;
+};
+
+/**
+ * struct cam_fd_hw_stop_args : Stop command args
+ *
+ * @hw_ctx         : HW context which submitting stop command
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ * @request_id     : Request ID that need to be stopped
+ * @hw_req_private : HW layer's private information specific to this request
+ */
+struct cam_fd_hw_stop_args {
+	void                         *hw_ctx;
+	void                         *ctx_hw_private;
+	uint64_t                      request_id;
+	struct cam_fd_hw_req_private *hw_req_private;
+};
+
+/**
+ * struct cam_fd_hw_frame_done_args : Frame done command args
+ *
+ * @hw_ctx         : HW context which submitting frame done request
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ * @request_id     : Request ID that need to be stopped
+ * @hw_req_private : HW layer's private information specific to this request
+ */
+struct cam_fd_hw_frame_done_args {
+	void                         *hw_ctx;
+	void                         *ctx_hw_private;
+	uint64_t                      request_id;
+	struct cam_fd_hw_req_private *hw_req_private;
+};
+
+/**
+ * struct cam_fd_hw_reset_args : Reset command args
+ *
+ * @hw_ctx         : HW context which submitting reset command
+ * @ctx_hw_private : HW layer's private information specific to this hw context
+ */
+struct cam_fd_hw_reset_args {
+	void    *hw_ctx;
+	void    *ctx_hw_private;
+};
+
+/**
+ * struct cam_fd_hw_cmd_set_irq_cb : Set IRQ callback command args
+ *
+ * @cam_fd_hw_mgr_cb : HW Mgr's callback pointer
+ * @data             : HW Mgr's private data
+ */
+struct cam_fd_hw_cmd_set_irq_cb {
+	int (*cam_fd_hw_mgr_cb)(void *data, enum cam_fd_hw_irq_type irq_type);
+	void *data;
+};
+
+#endif /* _CAM_FD_HW_INTF_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c
new file mode 100644
index 0000000..9045dc1
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c
@@ -0,0 +1,285 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "cam_fd_hw_core.h"
+#include "cam_fd_hw_soc.h"
+
+static void cam_fd_hw_util_cpas_callback(uint32_t handle, void *userdata,
+	enum cam_camnoc_irq_type event_type, uint32_t event_data)
+{
+	CAM_DBG(CAM_FD, "CPAS hdl=%d, udata=%pK, event=%d, event_data=%d",
+		handle, userdata, event_type, event_data);
+}
+
+static int cam_fd_hw_soc_util_setup_regbase_indices(
+	struct cam_hw_soc_info *soc_info)
+{
+	struct cam_fd_soc_private *soc_private =
+		(struct cam_fd_soc_private *)soc_info->soc_private;
+	uint32_t index;
+	int rc, i;
+
+	for (i = 0; i < CAM_FD_REG_MAX; i++)
+		soc_private->regbase_index[i] = -1;
+
+	if ((soc_info->num_mem_block > CAM_SOC_MAX_BLOCK) ||
+		(soc_info->num_mem_block != CAM_FD_REG_MAX)) {
+		CAM_ERR(CAM_FD, "Invalid num_mem_block=%d",
+			soc_info->num_mem_block);
+		return -EINVAL;
+	}
+
+	rc = cam_common_util_get_string_index(soc_info->mem_block_name,
+		soc_info->num_mem_block, "fd_core", &index);
+	if ((rc == 0) && (index < CAM_FD_REG_MAX)) {
+		soc_private->regbase_index[CAM_FD_REG_CORE] = index;
+	} else {
+		CAM_ERR(CAM_FD, "regbase not found for FD_CORE, rc=%d, %d %d",
+			rc, index, CAM_FD_REG_MAX);
+		return -EINVAL;
+	}
+
+	rc = cam_common_util_get_string_index(soc_info->mem_block_name,
+		soc_info->num_mem_block, "fd_wrapper", &index);
+	if ((rc == 0) && (index < CAM_FD_REG_MAX)) {
+		soc_private->regbase_index[CAM_FD_REG_WRAPPER] = index;
+	} else {
+		CAM_ERR(CAM_FD, "regbase not found FD_WRAPPER, rc=%d, %d %d",
+			rc, index, CAM_FD_REG_MAX);
+		return -EINVAL;
+	}
+
+	CAM_DBG(CAM_FD, "Reg indices : CORE=%d, WRAPPER=%d",
+		soc_private->regbase_index[CAM_FD_REG_CORE],
+		soc_private->regbase_index[CAM_FD_REG_WRAPPER]);
+
+	return 0;
+}
+
+static int cam_fd_soc_set_clk_flags(struct cam_hw_soc_info *soc_info)
+{
+	int i, rc = 0;
+
+	if (soc_info->num_clk > CAM_SOC_MAX_CLK) {
+		CAM_ERR(CAM_FD, "Invalid num clk %d", soc_info->num_clk);
+		return -EINVAL;
+	}
+
+	/* set memcore and mem periphery logic flags to 0 */
+	for (i = 0; i < soc_info->num_clk; i++) {
+		if ((strcmp(soc_info->clk_name[i], "fd_core_clk") == 0) ||
+			(strcmp(soc_info->clk_name[i], "fd_core_uar_clk") ==
+			0)) {
+			rc = cam_soc_util_set_clk_flags(soc_info, i,
+				CLKFLAG_NORETAIN_MEM);
+			if (rc)
+				CAM_ERR(CAM_FD,
+					"Failed in NORETAIN_MEM i=%d, rc=%d",
+					i, rc);
+
+			cam_soc_util_set_clk_flags(soc_info, i,
+				CLKFLAG_NORETAIN_PERIPH);
+			if (rc)
+				CAM_ERR(CAM_FD,
+					"Failed in NORETAIN_PERIPH i=%d, rc=%d",
+					i, rc);
+		}
+	}
+
+	return rc;
+}
+
+void cam_fd_soc_register_write(struct cam_hw_soc_info *soc_info,
+	enum cam_fd_reg_base reg_base, uint32_t reg_offset, uint32_t reg_value)
+{
+	struct cam_fd_soc_private *soc_private =
+		(struct cam_fd_soc_private *)soc_info->soc_private;
+	int32_t reg_index = soc_private->regbase_index[reg_base];
+
+	CAM_DBG(CAM_FD, "FD_REG_WRITE: Base[%d] Offset[0x%8x] Value[0x%8x]",
+		reg_base, reg_offset, reg_value);
+
+	cam_io_w_mb(reg_value,
+		soc_info->reg_map[reg_index].mem_base + reg_offset);
+}
+
+uint32_t cam_fd_soc_register_read(struct cam_hw_soc_info *soc_info,
+	enum cam_fd_reg_base reg_base, uint32_t reg_offset)
+{
+	struct cam_fd_soc_private *soc_private =
+		(struct cam_fd_soc_private *)soc_info->soc_private;
+	int32_t reg_index = soc_private->regbase_index[reg_base];
+	uint32_t reg_value;
+
+	reg_value = cam_io_r_mb(
+		soc_info->reg_map[reg_index].mem_base + reg_offset);
+
+	CAM_DBG(CAM_FD, "FD_REG_READ: Base[%d] Offset[0x%8x] Value[0x%8x]",
+		reg_base, reg_offset, reg_value);
+
+	return reg_value;
+}
+
+int cam_fd_soc_enable_resources(struct cam_hw_soc_info *soc_info)
+{
+	struct cam_fd_soc_private *soc_private = soc_info->soc_private;
+	struct cam_ahb_vote ahb_vote;
+	struct cam_axi_vote axi_vote;
+	int rc;
+
+	ahb_vote.type = CAM_VOTE_ABSOLUTE;
+	ahb_vote.vote.level = CAM_SVS_VOTE;
+	axi_vote.compressed_bw = 7200000;
+	axi_vote.uncompressed_bw = 7200000;
+	rc = cam_cpas_start(soc_private->cpas_handle, &ahb_vote, &axi_vote);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in CPAS START, rc=%d", rc);
+		return -EFAULT;
+	}
+
+	rc = cam_soc_util_enable_platform_resource(soc_info, true, CAM_SVS_VOTE,
+		true);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error enable platform failed, rc=%d", rc);
+		goto stop_cpas;
+	}
+
+	return rc;
+
+stop_cpas:
+	if (cam_cpas_stop(soc_private->cpas_handle))
+		CAM_ERR(CAM_FD, "Error in CPAS STOP");
+
+	return rc;
+}
+
+
+int cam_fd_soc_disable_resources(struct cam_hw_soc_info *soc_info)
+{
+	struct cam_fd_soc_private *soc_private;
+	int rc = 0;
+
+	if (!soc_info) {
+		CAM_ERR(CAM_FD, "Invalid soc_info param");
+		return -EINVAL;
+	}
+	soc_private = soc_info->soc_private;
+
+	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
+	if (rc) {
+		CAM_ERR(CAM_FD, "disable platform resources failed, rc=%d", rc);
+		return rc;
+	}
+
+	rc = cam_cpas_stop(soc_private->cpas_handle);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Error in CPAS STOP, handle=0x%x, rc=%d",
+			soc_private->cpas_handle, rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+int cam_fd_soc_init_resources(struct cam_hw_soc_info *soc_info,
+	irq_handler_t irq_handler, void *private_data)
+{
+	struct cam_fd_soc_private *soc_private;
+	struct cam_cpas_register_params cpas_register_param;
+	int rc;
+
+	rc = cam_soc_util_get_dt_properties(soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in get_dt_properties, rc=%d", rc);
+		return rc;
+	}
+
+	rc = cam_soc_util_request_platform_resource(soc_info, irq_handler,
+		private_data);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in request_platform_resource rc=%d",
+			rc);
+		return rc;
+	}
+
+	rc = cam_fd_soc_set_clk_flags(soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FD, "failed in set_clk_flags rc=%d", rc);
+		goto release_res;
+	}
+
+	soc_private = kzalloc(sizeof(struct cam_fd_soc_private), GFP_KERNEL);
+	if (!soc_private) {
+		rc = -ENOMEM;
+		goto release_res;
+	}
+	soc_info->soc_private = soc_private;
+
+	rc = cam_fd_hw_soc_util_setup_regbase_indices(soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FD, "Failed in setup regbase, rc=%d", rc);
+		goto free_soc_private;
+	}
+
+	memset(&cpas_register_param, 0, sizeof(cpas_register_param));
+	strlcpy(cpas_register_param.identifier, "fd", CAM_HW_IDENTIFIER_LENGTH);
+	cpas_register_param.cell_index = soc_info->index;
+	cpas_register_param.dev = &soc_info->pdev->dev;
+	cpas_register_param.userdata = private_data;
+	cpas_register_param.cam_cpas_client_cb = cam_fd_hw_util_cpas_callback;
+
+	rc = cam_cpas_register_client(&cpas_register_param);
+	if (rc) {
+		CAM_ERR(CAM_FD, "CPAS registration failed");
+		goto free_soc_private;
+	}
+	soc_private->cpas_handle = cpas_register_param.client_handle;
+	CAM_DBG(CAM_FD, "CPAS handle=%d", soc_private->cpas_handle);
+
+	return rc;
+
+free_soc_private:
+	kfree(soc_info->soc_private);
+	soc_info->soc_private = NULL;
+release_res:
+	cam_soc_util_release_platform_resource(soc_info);
+
+	return rc;
+}
+
+int cam_fd_soc_deinit_resources(struct cam_hw_soc_info *soc_info)
+{
+	struct cam_fd_soc_private *soc_private =
+		(struct cam_fd_soc_private *)soc_info->soc_private;
+	int rc;
+
+	rc = cam_cpas_unregister_client(soc_private->cpas_handle);
+	if (rc)
+		CAM_ERR(CAM_FD, "Unregister cpas failed, handle=%d, rc=%d",
+			soc_private->cpas_handle, rc);
+
+	rc = cam_soc_util_release_platform_resource(soc_info);
+	if (rc)
+		CAM_ERR(CAM_FD, "release platform failed, rc=%d", rc);
+
+	kfree(soc_info->soc_private);
+	soc_info->soc_private = NULL;
+
+	return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.h
new file mode 100644
index 0000000..4a22293
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.h
@@ -0,0 +1,53 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_SOC_H_
+#define _CAM_FD_HW_SOC_H_
+
+#include "cam_soc_util.h"
+
+/**
+ * enum cam_fd_reg_base - Enum for FD register sets
+ *
+ * @CAM_FD_REG_CORE    : Indicates FD Core register space
+ * @CAM_FD_REG_WRAPPER : Indicates FD Wrapper register space
+ * @CAM_FD_REG_MAX     : Max number of register sets supported
+ */
+enum cam_fd_reg_base {
+	CAM_FD_REG_CORE,
+	CAM_FD_REG_WRAPPER,
+	CAM_FD_REG_MAX
+};
+
+/**
+ * struct cam_fd_soc_private : FD private SOC information
+ *
+ * @regbase_index : Mapping between Register base enum to register index in SOC
+ * @cpas_handle   : CPAS handle
+ *
+ */
+struct cam_fd_soc_private {
+	int32_t        regbase_index[CAM_FD_REG_MAX];
+	uint32_t       cpas_handle;
+};
+
+int cam_fd_soc_init_resources(struct cam_hw_soc_info *soc_info,
+	irq_handler_t irq_handler, void *private_data);
+int cam_fd_soc_deinit_resources(struct cam_hw_soc_info *soc_info);
+int cam_fd_soc_enable_resources(struct cam_hw_soc_info *soc_info);
+int cam_fd_soc_disable_resources(struct cam_hw_soc_info *soc_info);
+uint32_t cam_fd_soc_register_read(struct cam_hw_soc_info *soc_info,
+	enum cam_fd_reg_base reg_base, uint32_t reg_offset);
+void cam_fd_soc_register_write(struct cam_hw_soc_info *soc_info,
+	enum cam_fd_reg_base reg_base, uint32_t reg_offset, uint32_t reg_value);
+
+#endif /* _CAM_FD_HW_SOC_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_v41.h b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_v41.h
new file mode 100644
index 0000000..70448bb
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_v41.h
@@ -0,0 +1,70 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_FD_HW_V41_H_
+#define _CAM_FD_HW_V41_H_
+
+static struct cam_fd_hw_static_info cam_fd_wrapper120_core410_info = {
+	.core_version = {
+		.major  = 4,
+		.minor  = 1,
+		.incr   = 0,
+	},
+	.wrapper_version = {
+		.major  = 1,
+		.minor  = 2,
+		.incr   = 0,
+	},
+	.core_regs = {
+		.version               = 0x38,
+		.control               = 0x0,
+		.result_cnt            = 0x4,
+		.result_addr           = 0x20,
+		.image_addr            = 0x24,
+		.work_addr             = 0x28,
+		.ro_mode               = 0x34,
+		.results_reg_base      = 0x400,
+		.raw_results_reg_base  = 0x800,
+	},
+	.wrapper_regs = {
+		.wrapper_version       = 0x0,
+		.cgc_disable           = 0x4,
+		.hw_stop               = 0x8,
+		.sw_reset              = 0x10,
+		.vbif_req_priority     = 0x20,
+		.vbif_priority_level   = 0x24,
+		.vbif_done_status      = 0x34,
+		.irq_mask              = 0x50,
+		.irq_status            = 0x54,
+		.irq_clear             = 0x58,
+	},
+	.results = {
+		.max_faces             = 35,
+		.per_face_entries      = 4,
+		.raw_results_available = true,
+		.raw_results_entries   = 512,
+	},
+	.enable_errata_wa = {
+		.single_irq_only         = true,
+		.ro_mode_enable_always   = true,
+		.ro_mode_results_invalid = true,
+	},
+	.irq_mask = CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_FRAME_DONE) |
+		CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_HALT_DONE) |
+		CAM_FD_IRQ_TO_MASK(CAM_FD_IRQ_RESET_DONE),
+	.qos_priority       = 4,
+	.qos_priority_level = 4,
+	.supported_modes    = CAM_FD_MODE_FACEDETECTION | CAM_FD_MODE_PYRAMID,
+	.ro_mode_supported  = true,
+};
+
+#endif /* _CAM_FD_HW_V41_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
index bbdff27..8a0d5f7 100644
--- a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
@@ -41,8 +41,8 @@
 struct cam_icp_subdev {
 	struct cam_subdev sd;
 	struct cam_node *node;
-	struct cam_context ctx[CAM_CTX_MAX];
-	struct cam_icp_context ctx_icp[CAM_CTX_MAX];
+	struct cam_context ctx[CAM_ICP_CTX_MAX];
+	struct cam_icp_context ctx_icp[CAM_ICP_CTX_MAX];
 	struct mutex icp_lock;
 	int32_t open_cnt;
 	int32_t reserved;
@@ -164,7 +164,7 @@
 		goto hw_init_fail;
 	}
 
-	for (i = 0; i < CAM_CTX_MAX; i++) {
+	for (i = 0; i < CAM_ICP_CTX_MAX; i++) {
 		g_icp_dev.ctx_icp[i].base = &g_icp_dev.ctx[i];
 		rc = cam_icp_context_init(&g_icp_dev.ctx_icp[i],
 					hw_mgr_intf);
@@ -175,7 +175,7 @@
 	}
 
 	rc = cam_node_init(node, hw_mgr_intf, g_icp_dev.ctx,
-				CAM_CTX_MAX, CAM_ICP_DEV_NAME);
+				CAM_ICP_CTX_MAX, CAM_ICP_DEV_NAME);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "ICP node init failed");
 		goto ctx_fail;
@@ -220,7 +220,7 @@
 		return -ENODEV;
 	}
 
-	for (i = 0; i < CAM_CTX_MAX; i++)
+	for (i = 0; i < CAM_ICP_CTX_MAX; i++)
 		cam_icp_context_deinit(&g_icp_dev.ctx_icp[i]);
 	cam_node_deinit(g_icp_dev.node);
 	cam_subdev_remove(&g_icp_dev.sd);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
index daffae8..99e2e79 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
@@ -96,6 +96,8 @@
 	}
 
 	a5_dev->soc_info.pdev = pdev;
+	a5_dev->soc_info.dev = &pdev->dev;
+	a5_dev->soc_info.dev_name = pdev->name;
 	a5_dev_intf->hw_priv = a5_dev;
 	a5_dev_intf->hw_ops.init = cam_a5_init_hw;
 	a5_dev_intf->hw_ops.deinit = cam_a5_deinit_hw;
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
index 55a2e1b..3473d08 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
@@ -75,8 +75,8 @@
 
 	cpas_vote.ahb_vote.type = CAM_VOTE_ABSOLUTE;
 	cpas_vote.ahb_vote.vote.level = CAM_SVS_VOTE;
-	cpas_vote.axi_vote.compressed_bw = ICP_TURBO_VOTE;
-	cpas_vote.axi_vote.uncompressed_bw = ICP_TURBO_VOTE;
+	cpas_vote.axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+	cpas_vote.axi_vote.uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
 
 	rc = cam_cpas_start(core_info->cpas_handle,
 			&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
@@ -269,6 +269,13 @@
 	case CAM_ICP_BPS_CMD_POWER_RESUME:
 		rc = cam_bps_handle_resume(bps_dev);
 		break;
+	case CAM_ICP_BPS_CMD_UPDATE_CLK: {
+		uint32_t clk_rate = *(uint32_t *)cmd_args;
+
+		CAM_DBG(CAM_ICP, "bps_src_clk rate = %d", (int)clk_rate);
+		rc = cam_bps_update_clk_rate(soc_info, clk_rate);
+	}
+		break;
 	default:
 		break;
 	}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
index 419bb52..0e36ec0 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
@@ -78,6 +78,8 @@
 		return -ENOMEM;
 	}
 	bps_dev->soc_info.pdev = pdev;
+	bps_dev->soc_info.dev = &pdev->dev;
+	bps_dev->soc_info.dev_name = pdev->name;
 	bps_dev_intf->hw_priv = bps_dev;
 	bps_dev_intf->hw_ops.init = cam_bps_init_hw;
 	bps_dev_intf->hw_ops.deinit = cam_bps_deinit_hw;
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
index 07dacb2..2477e7d 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
@@ -132,3 +132,13 @@
 
 	return rc;
 }
+
+int cam_bps_update_clk_rate(struct cam_hw_soc_info *soc_info,
+	uint32_t clk_rate)
+{
+	if (!soc_info)
+		return -EINVAL;
+
+	return cam_soc_util_set_clk_rate(soc_info->clk[soc_info->src_clk_idx],
+		soc_info->clk_name[soc_info->src_clk_idx], clk_rate);
+}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.h
index 3cffb09..2dd2c08 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.h
@@ -26,4 +26,6 @@
 
 int cam_bps_transfer_gdsc_control(struct cam_hw_soc_info *soc_info);
 
+int cam_bps_update_clk_rate(struct cam_hw_soc_info *soc_info,
+	uint32_t clk_rate);
 #endif /* _CAM_BPS_SOC_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
index 5055e8d..3844673 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
@@ -45,13 +45,659 @@
 #include "a5_core.h"
 #include "hfi_sys_defs.h"
 #include "cam_debug_util.h"
+#include "cam_soc_util.h"
 
-#define ICP_WORKQ_NUM_TASK      30
 #define ICP_WORKQ_TASK_CMD_TYPE 1
 #define ICP_WORKQ_TASK_MSG_TYPE 2
 
 static struct cam_icp_hw_mgr icp_hw_mgr;
 
+static void cam_icp_hw_mgr_clk_info_update(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data)
+{
+	struct cam_icp_clk_info *hw_mgr_clk_info;
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_BPS];
+	else
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_IPE];
+
+	if (hw_mgr_clk_info->base_clk >= ctx_data->clk_info.base_clk)
+		hw_mgr_clk_info->base_clk -= ctx_data->clk_info.base_clk;
+}
+
+static void cam_icp_hw_mgr_reset_clk_info(struct cam_icp_hw_mgr *hw_mgr)
+{
+	int i;
+
+	for (i = 0; i < ICP_CLK_HW_MAX; i++) {
+		hw_mgr->clk_info[i].base_clk = 0;
+		hw_mgr->clk_info[i].curr_clk = ICP_TURBO_VOTE;
+		hw_mgr->clk_info[i].threshold = ICP_OVER_CLK_THRESHOLD;
+		hw_mgr->clk_info[i].over_clked = 0;
+		hw_mgr->clk_info[i].uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+		hw_mgr->clk_info[i].compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+	}
+	hw_mgr->icp_default_clk = ICP_SVS_VOTE;
+}
+
+static int cam_icp_get_actual_clk_rate_idx(
+	struct cam_icp_hw_ctx_data *ctx_data, uint32_t base_clk)
+{
+	int i;
+
+	for (i = 0; i < CAM_MAX_VOTE; i++)
+		if (ctx_data->clk_info.clk_rate[i] >= base_clk)
+			return i;
+
+	return 0;
+}
+
+static bool cam_icp_is_over_clk(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	struct cam_icp_clk_info *hw_mgr_clk_info)
+{
+	int base_clk_idx;
+	int curr_clk_idx;
+
+	base_clk_idx = cam_icp_get_actual_clk_rate_idx(ctx_data,
+		hw_mgr_clk_info->base_clk);
+
+	curr_clk_idx = cam_icp_get_actual_clk_rate_idx(ctx_data,
+		hw_mgr_clk_info->curr_clk);
+
+	CAM_DBG(CAM_ICP, "bc_idx = %d cc_idx = %d %lld %lld",
+		base_clk_idx, curr_clk_idx, hw_mgr_clk_info->base_clk,
+		hw_mgr_clk_info->curr_clk);
+
+	if (curr_clk_idx > base_clk_idx)
+		return true;
+
+	return false;
+}
+
+static int cam_icp_get_lower_clk_rate(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, uint32_t base_clk)
+{
+	int i;
+
+	i = cam_icp_get_actual_clk_rate_idx(ctx_data, base_clk);
+
+	if (i > 0)
+		return ctx_data->clk_info.clk_rate[i - 1];
+
+	CAM_DBG(CAM_ICP, "Already clk at lower level");
+	return base_clk;
+}
+
+static int cam_icp_get_next_clk_rate(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, uint32_t base_clk)
+{
+	int i;
+
+	i = cam_icp_get_actual_clk_rate_idx(ctx_data, base_clk);
+
+	if (i < CAM_MAX_VOTE - 1)
+		return ctx_data->clk_info.clk_rate[i + 1];
+
+	CAM_DBG(CAM_ICP, "Already clk at higher level");
+
+	return base_clk;
+}
+
+static int cam_icp_get_actual_clk_rate(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, uint32_t base_clk)
+{
+	int i;
+
+	for (i = 0; i < CAM_MAX_VOTE; i++)
+		if (ctx_data->clk_info.clk_rate[i] >= base_clk)
+			return ctx_data->clk_info.clk_rate[i];
+
+	return base_clk;
+}
+
+static int cam_icp_supported_clk_rates(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data)
+{
+	int i;
+	struct cam_hw_soc_info *soc_info;
+	struct cam_hw_intf *dev_intf = NULL;
+	struct cam_hw_info *dev = NULL;
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
+		dev_intf = hw_mgr->devices[CAM_ICP_DEV_BPS][0];
+	else
+		dev_intf = hw_mgr->devices[CAM_ICP_DEV_IPE][0];
+
+	if (!dev_intf) {
+		CAM_ERR(CAM_ICP, "dev_intf is invalid");
+		return -EINVAL;
+	}
+	dev = (struct cam_hw_info *)dev_intf->hw_priv;
+	soc_info = &dev->soc_info;
+
+	for (i = 0; i < CAM_MAX_VOTE; i++) {
+		ctx_data->clk_info.clk_rate[i] =
+			soc_info->clk_rate[i][soc_info->num_clk - 1];
+		CAM_DBG(CAM_ICP, "clk_info = %d",
+			ctx_data->clk_info.clk_rate[i]);
+	}
+
+	return 0;
+}
+
+static int cam_icp_clk_idx_from_req_id(struct cam_icp_hw_ctx_data *ctx_data,
+	uint64_t req_id)
+{
+	struct hfi_frame_process_info *frame_process;
+	int i;
+
+	frame_process = &ctx_data->hfi_frame_process;
+
+	for (i = 0; i < CAM_FRAME_CMD_MAX; i++)
+		if (frame_process->request_id[i] == req_id)
+			return i;
+
+	return 0;
+}
+
+static int cam_icp_clk_info_init(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data)
+{
+	int i;
+
+	for (i = 0; i < ICP_CLK_HW_MAX; i++) {
+		hw_mgr->clk_info[i].base_clk = ICP_TURBO_VOTE;
+		hw_mgr->clk_info[i].curr_clk = ICP_TURBO_VOTE;
+		hw_mgr->clk_info[i].threshold = ICP_OVER_CLK_THRESHOLD;
+		hw_mgr->clk_info[i].over_clked = 0;
+		hw_mgr->clk_info[i].uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+		hw_mgr->clk_info[i].compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+	}
+	hw_mgr->icp_default_clk = ICP_SVS_VOTE;
+
+	return 0;
+}
+
+static int cam_icp_ctx_clk_info_init(struct cam_icp_hw_ctx_data *ctx_data)
+{
+	ctx_data->clk_info.curr_fc = 0;
+	ctx_data->clk_info.base_clk = 0;
+	ctx_data->clk_info.uncompressed_bw = 0;
+	ctx_data->clk_info.compressed_bw = 0;
+	cam_icp_supported_clk_rates(&icp_hw_mgr, ctx_data);
+
+	return 0;
+}
+
+static uint32_t cam_icp_mgr_calc_base_clk(uint32_t frame_cycles,
+	uint64_t budget)
+{
+	uint64_t base_clk;
+	uint64_t mul = 1000000000;
+
+	base_clk = (frame_cycles * mul) / budget;
+
+	CAM_DBG(CAM_ICP, "budget = %lld fc = %d ib = %lld base_clk = %lld",
+		budget, frame_cycles,
+		(long long int)(frame_cycles * mul), base_clk);
+
+	return base_clk;
+}
+
+static bool cam_icp_busy_prev_reqs(struct hfi_frame_process_info *frm_process,
+	uint64_t req_id)
+{
+	int i;
+	int cnt;
+
+	for (i = 0, cnt = 0; i < CAM_FRAME_CMD_MAX; i++) {
+		if (frm_process->request_id[i]) {
+			if (frm_process->fw_process_flag[i]) {
+				CAM_DBG(CAM_ICP, "r id = %lld busy = %d",
+					frm_process->request_id[i],
+					frm_process->fw_process_flag[i]);
+				cnt++;
+			}
+		}
+	}
+	if (cnt > 1)
+		return true;
+
+	return false;
+}
+
+static int cam_icp_calc_total_clk(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_clk_info *hw_mgr_clk_info, uint32_t dev_type)
+{
+	int i;
+	struct cam_icp_hw_ctx_data *ctx_data;
+
+	hw_mgr_clk_info->base_clk = 0;
+	for (i = 0; i < CAM_ICP_CTX_MAX; i++) {
+		ctx_data = &hw_mgr->ctx_data[i];
+		if (ctx_data->in_use &&
+			ctx_data->icp_dev_acquire_info->dev_type == dev_type)
+			hw_mgr_clk_info->base_clk +=
+				ctx_data->clk_info.base_clk;
+	}
+
+	return 0;
+}
+
+static bool cam_icp_update_clk_busy(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	struct cam_icp_clk_info *hw_mgr_clk_info,
+	struct cam_icp_clk_bw_request *clk_info,
+	uint32_t base_clk)
+{
+	uint32_t next_clk_level;
+	uint32_t actual_clk;
+	bool rc = false;
+
+	/* 1. if current request frame cycles(fc) are more than previous
+	 *      frame fc
+	 *      Calculate the new base clock.
+	 *      if sum of base clocks are more than next available clk level
+	 *       Update clock rate, change curr_clk_rate to sum of base clock
+	 *       rates and make over_clked to zero
+	 *      else
+	 *       Update clock rate to next level, update curr_clk_rate and make
+	 *       overclked cnt to zero
+	 * 2. if current fc is less than or equal to previous  frame fc
+	 *      Still Bump up the clock to next available level
+	 *      if it is available, then update clock, make overclk cnt to
+	 *      zero. If the clock is already at highest clock rate then
+	 *      no need to update the clock
+	 */
+	mutex_lock(&hw_mgr->hw_mgr_mutex);
+	ctx_data->clk_info.curr_fc = clk_info->frame_cycles;
+	ctx_data->clk_info.base_clk = base_clk;
+	hw_mgr_clk_info->over_clked = 0;
+	if (clk_info->frame_cycles > ctx_data->clk_info.curr_fc) {
+		cam_icp_calc_total_clk(hw_mgr, hw_mgr_clk_info,
+			ctx_data->icp_dev_acquire_info->dev_type);
+		actual_clk = cam_icp_get_actual_clk_rate(hw_mgr,
+			ctx_data, base_clk);
+		if (hw_mgr_clk_info->base_clk > actual_clk) {
+			hw_mgr_clk_info->curr_clk = hw_mgr_clk_info->base_clk;
+		} else {
+			next_clk_level = cam_icp_get_next_clk_rate(hw_mgr,
+				ctx_data, hw_mgr_clk_info->curr_clk);
+			hw_mgr_clk_info->curr_clk = next_clk_level;
+		}
+		rc = true;
+	} else {
+		next_clk_level =
+			cam_icp_get_next_clk_rate(hw_mgr, ctx_data,
+			hw_mgr_clk_info->curr_clk);
+		if (hw_mgr_clk_info->curr_clk < next_clk_level) {
+			hw_mgr_clk_info->curr_clk = next_clk_level;
+			rc = true;
+		}
+	}
+	mutex_unlock(&hw_mgr->hw_mgr_mutex);
+
+	return rc;
+}
+
+static bool cam_icp_update_clk_overclk_free(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	struct cam_icp_clk_info *hw_mgr_clk_info,
+	struct cam_icp_clk_bw_request *clk_info,
+	uint32_t base_clk)
+{
+	int rc = false;
+
+	/*
+	 * In caseof no pending packets case
+	 *    1. In caseof overclk cnt is less than threshold, increase
+	 *       overclk count and no update in the clock rate
+	 *    2. In caseof overclk cnt is greater than or equal to threshold
+	 *       then lower clock rate by one level and update hw_mgr current
+	 *       clock value.
+	 *        a. In case of new clock rate greater than sum of clock
+	 *           rates, reset overclk count value to zero if it is
+	 *           overclock
+	 *        b. if it is less than sum of base clocks then go to next
+	 *           level of clock and make overclk count to zero
+	 *        c. if it is same as sum of base clock rates update overclock
+	 *           cnt to 0
+	 */
+	if (hw_mgr_clk_info->over_clked < hw_mgr_clk_info->threshold) {
+		hw_mgr_clk_info->over_clked++;
+		rc = false;
+	} else {
+		hw_mgr_clk_info->curr_clk =
+			cam_icp_get_lower_clk_rate(hw_mgr, ctx_data,
+			hw_mgr_clk_info->curr_clk);
+		if (hw_mgr_clk_info->curr_clk > hw_mgr_clk_info->base_clk) {
+			if (cam_icp_is_over_clk(hw_mgr, ctx_data,
+				hw_mgr_clk_info))
+				hw_mgr_clk_info->over_clked = 0;
+		} else if (hw_mgr_clk_info->curr_clk <
+			hw_mgr_clk_info->base_clk) {
+			hw_mgr_clk_info->curr_clk =
+				cam_icp_get_next_clk_rate(hw_mgr, ctx_data,
+				hw_mgr_clk_info->curr_clk);
+				hw_mgr_clk_info->over_clked = 0;
+		} else if (hw_mgr_clk_info->curr_clk ==
+			hw_mgr_clk_info->base_clk) {
+			hw_mgr_clk_info->over_clked = 0;
+		}
+		rc = true;
+	}
+
+	return rc;
+}
+
+static bool cam_icp_update_clk_free(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	struct cam_icp_clk_info *hw_mgr_clk_info,
+	struct cam_icp_clk_bw_request *clk_info,
+	uint32_t base_clk)
+{
+	int rc = false;
+	bool over_clocked = false;
+
+	ctx_data->clk_info.curr_fc = clk_info->frame_cycles;
+	ctx_data->clk_info.base_clk = base_clk;
+	mutex_lock(&hw_mgr->hw_mgr_mutex);
+	cam_icp_calc_total_clk(hw_mgr, hw_mgr_clk_info,
+		ctx_data->icp_dev_acquire_info->dev_type);
+	mutex_unlock(&hw_mgr->hw_mgr_mutex);
+
+	/*
+	 * Current clock is not always sum of base clocks, due to
+	 * clock scales update to next higher or lower levels, it
+	 * equals to one of discrete clock values supported by hardware.
+	 * So even current clock is higher than sum of base clocks, we
+	 * can not consider it is over clocked. if it is greater than
+	 * discrete clock level then only it is considered as over clock.
+	 * 1. Handle over clock case
+	 * 2. If current clock is less than sum of base clocks
+	 *    update current clock
+	 * 3. If current clock is same as sum of base clocks no action
+	 */
+
+	over_clocked = cam_icp_is_over_clk(hw_mgr, ctx_data,
+		hw_mgr_clk_info);
+
+	mutex_lock(&hw_mgr->hw_mgr_mutex);
+	if (hw_mgr_clk_info->curr_clk > hw_mgr_clk_info->base_clk &&
+		over_clocked) {
+		rc = cam_icp_update_clk_overclk_free(hw_mgr, ctx_data,
+			hw_mgr_clk_info, clk_info, base_clk);
+	} else if (hw_mgr_clk_info->curr_clk > hw_mgr_clk_info->base_clk) {
+		hw_mgr_clk_info->over_clked = 0;
+		rc = false;
+	}  else if (hw_mgr_clk_info->curr_clk < hw_mgr_clk_info->base_clk) {
+		hw_mgr_clk_info->curr_clk = hw_mgr_clk_info->base_clk;
+		rc = true;
+	}
+	mutex_unlock(&hw_mgr->hw_mgr_mutex);
+
+	return rc;
+}
+
+static bool cam_icp_debug_clk_update(struct cam_icp_clk_info *hw_mgr_clk_info)
+{
+	if (icp_hw_mgr.icp_debug_clk < ICP_TURBO_VOTE &&
+		icp_hw_mgr.icp_debug_clk &&
+		icp_hw_mgr.icp_debug_clk != hw_mgr_clk_info->curr_clk) {
+		mutex_lock(&icp_hw_mgr.hw_mgr_mutex);
+		hw_mgr_clk_info->base_clk = icp_hw_mgr.icp_debug_clk;
+		hw_mgr_clk_info->curr_clk = icp_hw_mgr.icp_debug_clk;
+		hw_mgr_clk_info->uncompressed_bw = icp_hw_mgr.icp_debug_clk;
+		hw_mgr_clk_info->compressed_bw = icp_hw_mgr.icp_debug_clk;
+		mutex_unlock(&icp_hw_mgr.hw_mgr_mutex);
+		CAM_DBG(CAM_ICP, "bc = %d cc = %d",
+			hw_mgr_clk_info->base_clk, hw_mgr_clk_info->curr_clk);
+		return true;
+	}
+
+	return false;
+}
+
+static bool cam_icp_default_clk_update(struct cam_icp_clk_info *hw_mgr_clk_info)
+{
+	if (icp_hw_mgr.icp_default_clk != hw_mgr_clk_info->curr_clk) {
+		mutex_lock(&icp_hw_mgr.hw_mgr_mutex);
+		hw_mgr_clk_info->base_clk = icp_hw_mgr.icp_default_clk;
+		hw_mgr_clk_info->curr_clk = icp_hw_mgr.icp_default_clk;
+		hw_mgr_clk_info->uncompressed_bw = icp_hw_mgr.icp_default_clk;
+		hw_mgr_clk_info->compressed_bw = icp_hw_mgr.icp_default_clk;
+		mutex_unlock(&icp_hw_mgr.hw_mgr_mutex);
+		CAM_DBG(CAM_ICP, "bc = %d cc = %d",
+			hw_mgr_clk_info->base_clk, hw_mgr_clk_info->curr_clk);
+		return true;
+	}
+
+	return false;
+}
+
+static bool cam_icp_update_bw(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	struct cam_icp_clk_info *hw_mgr_clk_info,
+	struct cam_icp_clk_bw_request *clk_info,
+	bool busy)
+{
+	int i;
+	struct cam_icp_hw_ctx_data *ctx;
+
+	/*
+	 * If current request bandwidth is different from previous frames, then
+	 * recalculate bandwidth of all contexts of same hardware and update
+	 * voting of bandwidth
+	 */
+	if (clk_info->uncompressed_bw == ctx_data->clk_info.uncompressed_bw)
+		return false;
+
+	if (busy &&
+		ctx_data->clk_info.uncompressed_bw > clk_info->uncompressed_bw)
+		return false;
+
+	ctx_data->clk_info.uncompressed_bw = clk_info->uncompressed_bw;
+	ctx_data->clk_info.compressed_bw = clk_info->compressed_bw;
+	hw_mgr_clk_info->uncompressed_bw = 0;
+	hw_mgr_clk_info->compressed_bw = 0;
+	for (i = 0; i < CAM_ICP_CTX_MAX; i++) {
+		ctx = &hw_mgr->ctx_data[i];
+		if (ctx->in_use &&
+			ctx->icp_dev_acquire_info->dev_type ==
+			ctx_data->icp_dev_acquire_info->dev_type) {
+			mutex_lock(&hw_mgr->hw_mgr_mutex);
+			hw_mgr_clk_info->uncompressed_bw +=
+				ctx->clk_info.uncompressed_bw;
+			hw_mgr_clk_info->compressed_bw +=
+				ctx->clk_info.compressed_bw;
+			mutex_unlock(&hw_mgr->hw_mgr_mutex);
+		}
+	}
+
+	return true;
+}
+
+static bool cam_icp_check_clk_update(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, int idx)
+{
+	bool busy, rc = false;
+	uint32_t base_clk;
+	struct cam_icp_clk_bw_request *clk_info;
+	struct hfi_frame_process_info *frame_info;
+	uint64_t req_id;
+	struct cam_icp_clk_info *hw_mgr_clk_info;
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_BPS];
+	else
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_IPE];
+
+	if (icp_hw_mgr.icp_debug_clk)
+		return cam_icp_debug_clk_update(hw_mgr_clk_info);
+
+	/* Check is there any pending frames in this context */
+	frame_info = &ctx_data->hfi_frame_process;
+	req_id = frame_info->request_id[idx];
+	busy = cam_icp_busy_prev_reqs(frame_info, req_id);
+	CAM_DBG(CAM_ICP, "busy = %d req_id = %lld", busy, req_id);
+
+	clk_info = &ctx_data->hfi_frame_process.clk_info[idx];
+	if (!clk_info->frame_cycles)
+		return cam_icp_default_clk_update(hw_mgr_clk_info);
+
+	/* Calculate base clk rate */
+	base_clk = cam_icp_mgr_calc_base_clk(
+		clk_info->frame_cycles, clk_info->budget_ns);
+	ctx_data->clk_info.rt_flag = clk_info->rt_flag;
+
+	if (busy)
+		rc = cam_icp_update_clk_busy(hw_mgr, ctx_data,
+			hw_mgr_clk_info, clk_info, base_clk);
+	else
+		rc = cam_icp_update_clk_free(hw_mgr, ctx_data,
+			hw_mgr_clk_info, clk_info, base_clk);
+
+	CAM_DBG(CAM_ICP, "bc = %d cc = %d busy = %d overclk = %d uc = %d",
+		hw_mgr_clk_info->base_clk, hw_mgr_clk_info->curr_clk,
+		busy, hw_mgr_clk_info->over_clked, rc);
+
+	return rc;
+}
+
+static bool cam_icp_check_bw_update(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, int idx)
+{
+	bool busy, rc = false;
+	struct cam_icp_clk_bw_request *clk_info;
+	struct cam_icp_clk_info *hw_mgr_clk_info;
+	struct hfi_frame_process_info *frame_info;
+	uint64_t req_id;
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_BPS];
+	else
+		hw_mgr_clk_info = &hw_mgr->clk_info[ICP_CLK_HW_IPE];
+
+	clk_info = &ctx_data->hfi_frame_process.clk_info[idx];
+	frame_info = &ctx_data->hfi_frame_process;
+	req_id = frame_info->request_id[idx];
+	busy = cam_icp_busy_prev_reqs(frame_info, req_id);
+	rc = cam_icp_update_bw(hw_mgr, ctx_data, hw_mgr_clk_info,
+		clk_info, busy);
+
+	CAM_DBG(CAM_ICP, "ubw = %lld, cbw = %lld, update_bw = %d",
+		hw_mgr_clk_info->uncompressed_bw,
+		hw_mgr_clk_info->compressed_bw, rc);
+
+	return rc;
+}
+
+static int cam_icp_update_clk_rate(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data)
+{
+	uint32_t id;
+	uint32_t curr_clk_rate;
+	struct cam_hw_intf *ipe0_dev_intf = NULL;
+	struct cam_hw_intf *ipe1_dev_intf = NULL;
+	struct cam_hw_intf *bps_dev_intf = NULL;
+	struct cam_hw_intf *dev_intf = NULL;
+
+	ipe0_dev_intf = hw_mgr->devices[CAM_ICP_DEV_IPE][0];
+	ipe1_dev_intf = hw_mgr->devices[CAM_ICP_DEV_IPE][1];
+	bps_dev_intf = hw_mgr->devices[CAM_ICP_DEV_BPS][0];
+
+
+	if ((!ipe0_dev_intf) || (!bps_dev_intf)) {
+		CAM_ERR(CAM_ICP, "dev intfs are wrong, failed to update clk");
+		return -EINVAL;
+	}
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS) {
+		dev_intf = bps_dev_intf;
+		curr_clk_rate = hw_mgr->clk_info[ICP_CLK_HW_BPS].curr_clk;
+		id = CAM_ICP_BPS_CMD_UPDATE_CLK;
+	} else {
+		dev_intf = ipe0_dev_intf;
+		curr_clk_rate = hw_mgr->clk_info[ICP_CLK_HW_IPE].curr_clk;
+		id = CAM_ICP_IPE_CMD_UPDATE_CLK;
+	}
+
+	dev_intf->hw_ops.process_cmd(dev_intf->hw_priv, id,
+		&curr_clk_rate, sizeof(curr_clk_rate));
+
+	if (ctx_data->icp_dev_acquire_info->dev_type != CAM_ICP_RES_TYPE_BPS)
+		if (ipe1_dev_intf)
+			ipe1_dev_intf->hw_ops.process_cmd(
+				ipe1_dev_intf->hw_priv, id,
+				&curr_clk_rate, sizeof(curr_clk_rate));
+
+	return 0;
+}
+
+static int cam_icp_update_cpas_vote(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data)
+{
+	uint32_t id;
+	struct cam_hw_intf *ipe0_dev_intf = NULL;
+	struct cam_hw_intf *ipe1_dev_intf = NULL;
+	struct cam_hw_intf *bps_dev_intf = NULL;
+	struct cam_hw_intf *dev_intf = NULL;
+	struct cam_icp_clk_info *clk_info;
+	struct cam_icp_cpas_vote clk_update;
+
+	ipe0_dev_intf = hw_mgr->devices[CAM_ICP_DEV_IPE][0];
+	ipe1_dev_intf = hw_mgr->devices[CAM_ICP_DEV_IPE][1];
+	bps_dev_intf = hw_mgr->devices[CAM_ICP_DEV_BPS][0];
+
+	if ((!ipe0_dev_intf) || (!bps_dev_intf)) {
+		CAM_ERR(CAM_ICP, "dev intfs are wrong, failed to update clk");
+		return -EINVAL;
+	}
+
+	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS) {
+		dev_intf = bps_dev_intf;
+		clk_info = &hw_mgr->clk_info[ICP_CLK_HW_BPS];
+		id = CAM_ICP_BPS_CMD_VOTE_CPAS;
+	} else {
+		dev_intf = ipe0_dev_intf;
+		clk_info = &hw_mgr->clk_info[ICP_CLK_HW_IPE];
+		id = CAM_ICP_IPE_CMD_VOTE_CPAS;
+	}
+
+	clk_update.ahb_vote.type = CAM_VOTE_DYNAMIC;
+	clk_update.ahb_vote.vote.freq = clk_info->curr_clk;
+	clk_update.ahb_vote_valid = true;
+	clk_update.axi_vote.compressed_bw = clk_info->compressed_bw;
+	clk_update.axi_vote.uncompressed_bw = clk_info->uncompressed_bw;
+	clk_update.axi_vote_valid = true;
+	dev_intf->hw_ops.process_cmd(dev_intf->hw_priv, id,
+		&clk_update, sizeof(clk_update));
+
+	if (ctx_data->icp_dev_acquire_info->dev_type != CAM_ICP_RES_TYPE_BPS)
+		if (ipe1_dev_intf)
+			ipe1_dev_intf->hw_ops.process_cmd(
+				ipe1_dev_intf->hw_priv, id,
+				&clk_update, sizeof(clk_update));
+
+	return 0;
+}
+
+static int cam_icp_mgr_ipe_bps_clk_update(struct cam_icp_hw_mgr *hw_mgr,
+	struct cam_icp_hw_ctx_data *ctx_data, int idx)
+{
+	int rc = 0;
+
+	if (cam_icp_check_clk_update(hw_mgr, ctx_data, idx))
+		rc = cam_icp_update_clk_rate(hw_mgr, ctx_data);
+
+	if (cam_icp_check_bw_update(hw_mgr, ctx_data, idx))
+		rc |= cam_icp_update_cpas_vote(hw_mgr, ctx_data);
+
+	return rc;
+}
+
 static int cam_icp_mgr_ipe_bps_resume(struct cam_icp_hw_mgr *hw_mgr,
 	struct cam_icp_hw_ctx_data *ctx_data)
 {
@@ -128,8 +774,26 @@
 	return rc;
 }
 
+static int cam_icp_set_dbg_default_clk(void *data, u64 val)
+{
+	icp_hw_mgr.icp_debug_clk = val;
+	return 0;
+}
+
+static int cam_icp_get_dbg_default_clk(void *data, u64 *val)
+{
+	*val = icp_hw_mgr.icp_debug_clk;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(cam_icp_debug_default_clk,
+	cam_icp_get_dbg_default_clk,
+	cam_icp_set_dbg_default_clk, "%16llu");
+
 static int cam_icp_hw_mgr_create_debugfs_entry(void)
 {
+	int rc = 0;
+
 	icp_hw_mgr.dentry = debugfs_create_dir("camera_icp", NULL);
 	if (!icp_hw_mgr.dentry)
 		return -ENOMEM;
@@ -139,7 +803,8 @@
 		icp_hw_mgr.dentry,
 		&icp_hw_mgr.a5_debug)) {
 		debugfs_remove_recursive(icp_hw_mgr.dentry);
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto err;
 	}
 
 	if (!debugfs_create_bool("icp_pc",
@@ -147,10 +812,23 @@
 		icp_hw_mgr.dentry,
 		&icp_hw_mgr.icp_pc_flag)) {
 		CAM_ERR(CAM_ICP, "failed to create icp_pc entry");
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto err;
 	}
 
-	return 0;
+	if (!debugfs_create_file("icp_debug_clk",
+		0644,
+		icp_hw_mgr.dentry, NULL,
+		&cam_icp_debug_default_clk)) {
+		CAM_ERR(CAM_ICP, "failed to create icp_debug_clk entry");
+		rc = -ENOMEM;
+		goto err;
+	}
+
+	return rc;
+err:
+	debugfs_remove_recursive(icp_hw_mgr.dentry);
+	return rc;
 }
 
 static int cam_icp_mgr_process_cmd(void *priv, void *data)
@@ -209,7 +887,14 @@
 	buf_data.request_id = hfi_frame_process->request_id[idx];
 	ctx_data->ctxt_event_cb(ctx_data->context_priv, flag, &buf_data);
 	hfi_frame_process->request_id[idx] = 0;
+	if (ctx_data->hfi_frame_process.in_resource[idx] > 0) {
+		CAM_DBG(CAM_ICP, "Delete merged sync in object: %d",
+			ctx_data->hfi_frame_process.in_resource[idx]);
+		cam_sync_destroy(ctx_data->hfi_frame_process.in_resource[idx]);
+		ctx_data->hfi_frame_process.in_resource[idx] = 0;
+	}
 	clear_bit(idx, ctx_data->hfi_frame_process.bitmap);
+	hfi_frame_process->fw_process_flag[idx] = false;
 	mutex_unlock(&ctx_data->ctx_mutex);
 
 	return 0;
@@ -228,7 +913,7 @@
 	ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
 	if (ioconfig_ack->err_type != HFI_ERR_SYS_NONE) {
 		CAM_ERR(CAM_ICP, "failed with error : %u",
-			ioconfig_ack->err_type);
+		ioconfig_ack->err_type);
 		cam_icp_mgr_handle_frame_process(msg_ptr,
 			ICP_FRAME_PROCESS_FAILURE);
 		return -EIO;
@@ -642,40 +1327,52 @@
 {
 	int rc = 0;
 	unsigned long rem_jiffies;
+	size_t packet_size;
 	int timeout = 5000;
 	struct hfi_cmd_work_data *task_data;
-	struct hfi_cmd_ipebps_async abort_cmd;
+	struct hfi_cmd_ipebps_async *abort_cmd;
 	struct crm_workq_task *task;
 
 	task = cam_req_mgr_workq_get_task(icp_hw_mgr.cmd_work);
 	if (!task)
 		return -ENOMEM;
 
-	abort_cmd.size =
-		sizeof(struct hfi_cmd_ipebps_async);
-	abort_cmd.pkt_type = HFI_CMD_IPEBPS_ASYNC_COMMAND_DIRECT;
+	packet_size =
+		sizeof(struct hfi_cmd_ipebps_async) +
+		sizeof(struct hfi_cmd_abort_destroy) -
+		sizeof(((struct hfi_cmd_ipebps_async *)0)->payload.direct);
+	abort_cmd = kzalloc(packet_size, GFP_KERNEL);
+	if (!abort_cmd) {
+		rc = -ENOMEM;
+		return rc;
+	}
+
+	abort_cmd->size = packet_size;
+	abort_cmd->pkt_type = HFI_CMD_IPEBPS_ASYNC_COMMAND_DIRECT;
 	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
-		abort_cmd.opcode = HFI_IPEBPS_CMD_OPCODE_BPS_ABORT;
+		abort_cmd->opcode = HFI_IPEBPS_CMD_OPCODE_BPS_ABORT;
 	else
-		abort_cmd.opcode = HFI_IPEBPS_CMD_OPCODE_IPE_ABORT;
+		abort_cmd->opcode = HFI_IPEBPS_CMD_OPCODE_IPE_ABORT;
 
 	reinit_completion(&ctx_data->wait_complete);
-	abort_cmd.num_fw_handles = 1;
-	abort_cmd.fw_handles[0] = ctx_data->fw_handle;
-	abort_cmd.user_data1 = (uint64_t)ctx_data;
-	abort_cmd.user_data2 = (uint64_t)0x0;
-	memcpy(abort_cmd.payload.direct, &ctx_data->temp_payload,
-		sizeof(uint32_t));
+	abort_cmd->num_fw_handles = 1;
+	abort_cmd->fw_handles[0] = ctx_data->fw_handle;
+	abort_cmd->user_data1 = (uint64_t)ctx_data;
+	abort_cmd->user_data2 = (uint64_t)0x0;
+	memcpy(abort_cmd->payload.direct, &ctx_data->temp_payload,
+		sizeof(uint64_t));
 
 	task_data = (struct hfi_cmd_work_data *)task->payload;
-	task_data->data = (void *)&abort_cmd;
+	task_data->data = (void *)abort_cmd;
 	task_data->request_id = 0;
 	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
 	task->process_cb = cam_icp_mgr_process_cmd;
 	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
 		CRM_TASK_PRIORITY_0);
-	if (rc)
+	if (rc) {
+		kfree(abort_cmd);
 		return rc;
+	}
 
 	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
 		ctx_data->fw_handle, ctx_data);
@@ -686,6 +1383,7 @@
 		CAM_DBG(CAM_ICP, "FW timeout/err in abort handle command");
 	}
 
+	kfree(abort_cmd);
 	return rc;
 }
 
@@ -695,39 +1393,51 @@
 	int rc = 0;
 	int timeout = 5000;
 	unsigned long rem_jiffies;
+	size_t packet_size;
 	struct hfi_cmd_work_data *task_data;
-	struct hfi_cmd_ipebps_async destroy_cmd;
+	struct hfi_cmd_ipebps_async *destroy_cmd;
 	struct crm_workq_task *task;
 
 	task = cam_req_mgr_workq_get_task(icp_hw_mgr.cmd_work);
 	if (!task)
 		return -ENOMEM;
 
-	destroy_cmd.size =
-		sizeof(struct hfi_cmd_ipebps_async);
-	destroy_cmd.pkt_type = HFI_CMD_IPEBPS_ASYNC_COMMAND_DIRECT;
+	packet_size =
+		sizeof(struct hfi_cmd_ipebps_async) +
+		sizeof(struct hfi_cmd_abort_destroy) -
+		sizeof(((struct hfi_cmd_ipebps_async *)0)->payload.direct);
+	destroy_cmd = kzalloc(packet_size, GFP_KERNEL);
+	if (!destroy_cmd) {
+		rc = -ENOMEM;
+		return rc;
+	}
+
+	destroy_cmd->size = packet_size;
+	destroy_cmd->pkt_type = HFI_CMD_IPEBPS_ASYNC_COMMAND_DIRECT;
 	if (ctx_data->icp_dev_acquire_info->dev_type == CAM_ICP_RES_TYPE_BPS)
-		destroy_cmd.opcode = HFI_IPEBPS_CMD_OPCODE_BPS_DESTROY;
+		destroy_cmd->opcode = HFI_IPEBPS_CMD_OPCODE_BPS_DESTROY;
 	else
-		destroy_cmd.opcode = HFI_IPEBPS_CMD_OPCODE_IPE_DESTROY;
+		destroy_cmd->opcode = HFI_IPEBPS_CMD_OPCODE_IPE_DESTROY;
 
 	reinit_completion(&ctx_data->wait_complete);
-	destroy_cmd.num_fw_handles = 1;
-	destroy_cmd.fw_handles[0] = ctx_data->fw_handle;
-	destroy_cmd.user_data1 = (uint64_t)ctx_data;
-	destroy_cmd.user_data2 = (uint64_t)0x0;
-	memcpy(destroy_cmd.payload.direct, &ctx_data->temp_payload,
-						sizeof(uint32_t));
+	destroy_cmd->num_fw_handles = 1;
+	destroy_cmd->fw_handles[0] = ctx_data->fw_handle;
+	destroy_cmd->user_data1 = (uint64_t)ctx_data;
+	destroy_cmd->user_data2 = (uint64_t)0x0;
+	memcpy(destroy_cmd->payload.direct, &ctx_data->temp_payload,
+		sizeof(uint64_t));
 
 	task_data = (struct hfi_cmd_work_data *)task->payload;
-	task_data->data = (void *)&destroy_cmd;
+	task_data->data = (void *)destroy_cmd;
 	task_data->request_id = 0;
 	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
 	task->process_cb = cam_icp_mgr_process_cmd;
 	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
 		CRM_TASK_PRIORITY_0);
-	if (rc)
+	if (rc) {
+		kfree(destroy_cmd);
 		return rc;
+	}
 
 	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
 		ctx_data->fw_handle, ctx_data);
@@ -738,6 +1448,7 @@
 		CAM_ERR(CAM_ICP, "FW response timeout: %d", rc);
 	}
 
+	kfree(destroy_cmd);
 	return rc;
 }
 
@@ -765,6 +1476,9 @@
 	for (i = 0; i < CAM_FRAME_CMD_MAX; i++)
 		clear_bit(i, hw_mgr->ctx_data[ctx_id].hfi_frame_process.bitmap);
 	kfree(hw_mgr->ctx_data[ctx_id].hfi_frame_process.bitmap);
+	cam_icp_hw_mgr_clk_info_update(hw_mgr, &hw_mgr->ctx_data[ctx_id]);
+	hw_mgr->ctx_data[ctx_id].clk_info.curr_fc = 0;
+	hw_mgr->ctx_data[ctx_id].clk_info.base_clk = 0;
 	hw_mgr->ctxt_cnt--;
 	kfree(hw_mgr->ctx_data[ctx_id].icp_dev_acquire_info);
 	hw_mgr->ctx_data[ctx_id].icp_dev_acquire_info = NULL;
@@ -849,6 +1563,7 @@
 	cam_icp_mgr_device_deinit(hw_mgr);
 	cam_icp_free_hfi_mem();
 	hw_mgr->fw_download = false;
+	hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE;
 	mutex_unlock(&hw_mgr->hw_mgr_mutex);
 
 	return rc;
@@ -1109,13 +1824,18 @@
 
 static int cam_icp_mgr_handle_config_err(
 	struct cam_hw_config_args *config_args,
-	struct cam_icp_hw_ctx_data *ctx_data)
+	struct cam_icp_hw_ctx_data *ctx_data,
+	int idx)
 {
 	struct cam_hw_done_event_data buf_data;
 
 	buf_data.request_id = *(uint64_t *)config_args->priv;
 	ctx_data->ctxt_event_cb(ctx_data->context_priv, true, &buf_data);
 
+	ctx_data->hfi_frame_process.request_id[idx] = 0;
+	ctx_data->hfi_frame_process.fw_process_flag[idx] = false;
+	clear_bit(idx, ctx_data->hfi_frame_process.bitmap);
+
 	return 0;
 }
 
@@ -1154,6 +1874,8 @@
 static int cam_icp_mgr_config_hw(void *hw_mgr_priv, void *config_hw_args)
 {
 	int rc = 0;
+	int idx;
+	uint64_t req_id;
 	struct cam_icp_hw_mgr *hw_mgr = hw_mgr_priv;
 	struct cam_hw_config_args *config_args = config_hw_args;
 	struct cam_icp_hw_ctx_data *ctx_data = NULL;
@@ -1173,10 +1895,14 @@
 	mutex_lock(&ctx_data->ctx_mutex);
 	if (!ctx_data->in_use) {
 		CAM_ERR(CAM_ICP, "ctx is not in use");
-		rc = -EINVAL;
-		goto config_err;
+		return -EINVAL;
 	}
 
+	req_id = *(uint64_t *)config_args->priv;
+	idx = cam_icp_clk_idx_from_req_id(ctx_data, req_id);
+	ctx_data->hfi_frame_process.fw_process_flag[idx] = true;
+	cam_icp_mgr_ipe_bps_clk_update(hw_mgr, ctx_data, idx);
+
 	rc = cam_icp_mgr_enqueue_config(hw_mgr, config_args);
 	if (rc)
 		goto config_err;
@@ -1184,8 +1910,8 @@
 
 	return 0;
 config_err:
+	cam_icp_mgr_handle_config_err(config_args, ctx_data, idx);
 	mutex_unlock(&ctx_data->ctx_mutex);
-	cam_icp_mgr_handle_config_err(config_args, ctx_data);
 	return rc;
 }
 
@@ -1224,14 +1950,8 @@
 			packet->header.op_code & 0xff);
 		return -EINVAL;
 	}
-
-	if ((packet->num_cmd_buf > 1) || (!packet->num_patches) ||
-		(!packet->num_io_configs)) {
-		CAM_ERR(CAM_ICP, "wrong number of cmd/patch info: %u %u",
+	CAM_DBG(CAM_ICP, "number of cmd/patch info: %u %u",
 			packet->num_cmd_buf, packet->num_patches);
-		return -EINVAL;
-	}
-
 	return 0;
 }
 
@@ -1240,36 +1960,43 @@
 	uint32_t *fw_cmd_buf_iova_addr)
 {
 	int rc = 0;
-	uint64_t iova_addr;
-	size_t   fw_cmd_buf_len;
+	int i;
+	uint64_t addr;
+	size_t len;
 	struct cam_cmd_buf_desc *cmd_desc = NULL;
 
 	cmd_desc = (struct cam_cmd_buf_desc *)
 		((uint32_t *) &packet->payload + packet->cmd_buf_offset/4);
 
-	rc = cam_mem_get_io_buf(cmd_desc->mem_handle,
-		hw_mgr->iommu_hdl, &iova_addr, &fw_cmd_buf_len);
-	if (rc) {
-		CAM_ERR(CAM_ICP, "unable to get src buf info for cmd buf: %x",
-			hw_mgr->iommu_hdl);
-		return rc;
+	*fw_cmd_buf_iova_addr = 0;
+	for (i = 0; i < packet->num_cmd_buf; i++) {
+		if (cmd_desc[i].type == CAM_CMD_BUF_FW) {
+			rc = cam_mem_get_io_buf(cmd_desc[i].mem_handle,
+				hw_mgr->iommu_hdl, &addr, &len);
+			if (rc) {
+				CAM_ERR(CAM_ICP, "get cmd buf failed %x",
+					hw_mgr->iommu_hdl);
+				return rc;
+			}
+			*fw_cmd_buf_iova_addr = addr;
+			*fw_cmd_buf_iova_addr =
+				(*fw_cmd_buf_iova_addr + cmd_desc[i].offset);
+		}
 	}
-	CAM_DBG(CAM_ICP, "cmd_buf desc cpu and iova address: %pK %zu",
-		(void *)iova_addr, fw_cmd_buf_len);
-
-	*fw_cmd_buf_iova_addr = iova_addr;
-	*fw_cmd_buf_iova_addr = (*fw_cmd_buf_iova_addr + cmd_desc->offset);
 
 	return rc;
 }
 
-static void cam_icp_mgr_process_io_cfg(struct cam_icp_hw_mgr *hw_mgr,
+static int cam_icp_mgr_process_io_cfg(struct cam_icp_hw_mgr *hw_mgr,
 	struct cam_icp_hw_ctx_data *ctx_data,
 	struct cam_packet *packet,
-	struct cam_hw_prepare_update_args *prepare_args)
+	struct cam_hw_prepare_update_args *prepare_args,
+	int32_t index)
 {
-	int i, j, k;
+	int i, j, k, rc = 0;
 	struct cam_buf_io_cfg *io_cfg_ptr = NULL;
+	int32_t sync_in_obj[CAM_MAX_OUT_RES];
+	int32_t merged_sync_in_obj;
 
 	io_cfg_ptr = (struct cam_buf_io_cfg *) ((uint32_t *) &packet->payload +
 				packet->io_configs_offset/4);
@@ -1278,8 +2005,7 @@
 
 	for (i = 0, j = 0, k = 0; i < packet->num_io_configs; i++) {
 		if (io_cfg_ptr[i].direction == CAM_BUF_INPUT) {
-			prepare_args->in_map_entries[j++].sync_id =
-				io_cfg_ptr[i].fence;
+			sync_in_obj[j++] = io_cfg_ptr[i].fence;
 			prepare_args->num_in_map_entries++;
 		} else {
 			prepare_args->out_map_entries[k++].sync_id =
@@ -1289,6 +2015,107 @@
 		CAM_DBG(CAM_ICP, "dir[%d]: %u, fence: %u",
 			i, io_cfg_ptr[i].direction, io_cfg_ptr[i].fence);
 	}
+
+	if (prepare_args->num_in_map_entries > 1) {
+		rc = cam_sync_merge(&sync_in_obj[0],
+			prepare_args->num_in_map_entries, &merged_sync_in_obj);
+		if (rc) {
+			prepare_args->num_out_map_entries = 0;
+			prepare_args->num_in_map_entries = 0;
+			return rc;
+		}
+
+		ctx_data->hfi_frame_process.in_resource[index] =
+			merged_sync_in_obj;
+		prepare_args->in_map_entries[0].sync_id = merged_sync_in_obj;
+		prepare_args->num_in_map_entries = 1;
+		CAM_DBG(CAM_ICP, "Merged Sync obj = %d", merged_sync_in_obj);
+	} else if (prepare_args->num_in_map_entries == 1) {
+		prepare_args->in_map_entries[0].sync_id = sync_in_obj[0];
+		prepare_args->num_in_map_entries = 1;
+		ctx_data->hfi_frame_process.in_resource[index] = 0;
+	} else {
+		CAM_ERR(CAM_ICP, "No input fences");
+		prepare_args->num_in_map_entries = 0;
+		ctx_data->hfi_frame_process.in_resource[index] = 0;
+		rc = -EINVAL;
+	}
+
+	return rc;
+}
+
+static int cam_icp_packet_generic_blob_handler(void *user_data,
+	uint32_t blob_type, uint32_t blob_size, uint8_t *blob_data)
+{
+	struct cam_icp_clk_bw_request *soc_req;
+	struct cam_icp_clk_bw_request *clk_info;
+	struct icp_cmd_generic_blob *blob;
+	struct cam_icp_hw_ctx_data *ctx_data;
+	uint32_t index;
+	int rc = 0;
+
+	if (!blob_data || (blob_size == 0)) {
+		CAM_ERR(CAM_ICP, "Invalid blob info %pK %d", blob_data,
+			blob_size);
+		return -EINVAL;
+	}
+
+	blob = (struct icp_cmd_generic_blob *)user_data;
+	ctx_data = blob->ctx;
+	index = blob->frame_info_idx;
+
+	switch (blob_type) {
+	case CAM_ICP_CMD_GENERIC_BLOB_CLK:
+		if (blob_size != sizeof(struct cam_icp_clk_bw_request)) {
+			rc = -EINVAL;
+			break;
+		}
+		clk_info = &ctx_data->hfi_frame_process.clk_info[index];
+		memset(clk_info, 0, sizeof(struct cam_icp_clk_bw_request));
+
+		soc_req = (struct cam_icp_clk_bw_request *)blob_data;
+		*clk_info = *soc_req;
+		CAM_DBG(CAM_ICP, "%llu %llu %d %d %d",
+			clk_info->budget_ns, clk_info->frame_cycles,
+			clk_info->rt_flag, clk_info->uncompressed_bw,
+			clk_info->compressed_bw);
+		break;
+
+	default:
+		CAM_WARN(CAM_ICP, "Invalid blob type %d", blob_type);
+		break;
+	}
+	return rc;
+}
+
+static int cam_icp_process_generic_cmd_buffer(
+	struct cam_packet *packet,
+	struct cam_icp_hw_ctx_data *ctx_data,
+	int32_t index)
+{
+	int i, rc = 0;
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+	struct icp_cmd_generic_blob cmd_generic_blob;
+
+	cmd_generic_blob.ctx = ctx_data;
+	cmd_generic_blob.frame_info_idx = index;
+
+	cmd_desc = (struct cam_cmd_buf_desc *)
+		((uint32_t *) &packet->payload + packet->cmd_buf_offset/4);
+	for (i = 0; i < packet->num_cmd_buf; i++) {
+		if (!cmd_desc[i].length)
+			continue;
+
+		if (cmd_desc[i].meta_data != CAM_ICP_CMD_META_GENERIC_BLOB)
+			continue;
+
+		rc = cam_packet_util_process_generic_cmd_buffer(&cmd_desc[i],
+			cam_icp_packet_generic_blob_handler, &cmd_generic_blob);
+		if (rc)
+			CAM_ERR(CAM_ICP, "Failed in processing blobs %d", rc);
+	}
+
+	return rc;
 }
 
 static int cam_icp_mgr_update_hfi_frame_process(
@@ -1297,7 +2124,7 @@
 	struct cam_hw_prepare_update_args *prepare_args,
 	int32_t *idx)
 {
-	int32_t index;
+	int32_t index, rc;
 
 	index = find_first_zero_bit(ctx_data->hfi_frame_process.bitmap,
 		ctx_data->hfi_frame_process.bits);
@@ -1309,7 +2136,12 @@
 
 	ctx_data->hfi_frame_process.request_id[index] =
 		packet->header.request_id;
-
+	rc = cam_icp_process_generic_cmd_buffer(packet, ctx_data, index);
+	if (rc) {
+		clear_bit(index, ctx_data->hfi_frame_process.bitmap);
+		ctx_data->hfi_frame_process.request_id[index] = -1;
+		return rc;
+	}
 	*idx = index;
 
 	return 0;
@@ -1357,21 +2189,28 @@
 	}
 
 	/* Update Buffer Address from handles and patch information */
-	rc = cam_packet_util_process_patches(packet, hw_mgr->iommu_hdl);
+	rc = cam_packet_util_process_patches(packet, hw_mgr->iommu_hdl,
+		hw_mgr->iommu_sec_hdl);
 	if (rc) {
 		mutex_unlock(&ctx_data->ctx_mutex);
 		return rc;
 	}
 
-	cam_icp_mgr_process_io_cfg(hw_mgr, ctx_data,
-		packet, prepare_args);
-
 	rc = cam_icp_mgr_update_hfi_frame_process(ctx_data, packet,
 		prepare_args, &idx);
 	if (rc) {
-		if (prepare_args->in_map_entries[0].sync_id > 0)
+		mutex_unlock(&ctx_data->ctx_mutex);
+		return rc;
+	}
+
+	rc = cam_icp_mgr_process_io_cfg(hw_mgr, ctx_data,
+		packet, prepare_args, idx);
+	if (rc) {
+		if (ctx_data->hfi_frame_process.in_resource[idx] > 0)
 			cam_sync_destroy(
-				prepare_args->in_map_entries[0].sync_id);
+				ctx_data->hfi_frame_process.in_resource[idx]);
+		clear_bit(idx, ctx_data->hfi_frame_process.bitmap);
+		ctx_data->hfi_frame_process.request_id[idx] = -1;
 		mutex_unlock(&ctx_data->ctx_mutex);
 		return rc;
 	}
@@ -1406,6 +2245,13 @@
 
 		/* now release memory for hfi frame process command */
 		hfi_frame_process->request_id[idx] = 0;
+		if (ctx_data->hfi_frame_process.in_resource[idx] > 0) {
+			CAM_DBG(CAM_ICP, "Delete merged sync in object: %d",
+				ctx_data->hfi_frame_process.in_resource[idx]);
+			cam_sync_destroy(
+				ctx_data->hfi_frame_process.in_resource[idx]);
+			ctx_data->hfi_frame_process.in_resource[idx] = 0;
+	}
 		clear_bit(idx, ctx_data->hfi_frame_process.bitmap);
 	}
 	mutex_unlock(&ctx_data->ctx_mutex);
@@ -1449,6 +2295,8 @@
 		cam_icp_mgr_ipe_bps_power_collapse(hw_mgr,
 			NULL, 0);
 		cam_icp_mgr_hw_close(hw_mgr, NULL);
+		cam_icp_hw_mgr_reset_clk_info(hw_mgr);
+		hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE;
 	}
 
 	return rc;
@@ -1594,6 +2442,12 @@
 		sizeof(struct cam_icp_acquire_dev_info)))
 		return -EFAULT;
 
+	if (icp_dev_acquire_info.secure_mode > CAM_SECURE_MODE_SECURE) {
+		CAM_ERR(CAM_ICP, "Invalid mode:%d",
+			icp_dev_acquire_info.secure_mode);
+		return -EINVAL;
+	}
+
 	if (icp_dev_acquire_info.num_out_res > ICP_MAX_OUTPUT_SUPPORTED) {
 		CAM_ERR(CAM_ICP, "num of out resources exceeding : %u",
 			icp_dev_acquire_info.num_out_res);
@@ -1606,28 +2460,46 @@
 		return -EFAULT;
 	}
 
+	if (!hw_mgr->ctxt_cnt) {
+		hw_mgr->secure_mode = icp_dev_acquire_info.secure_mode;
+	} else {
+		if (hw_mgr->secure_mode != icp_dev_acquire_info.secure_mode) {
+			CAM_ERR(CAM_ICP,
+				"secure mode mismatch driver:%d, context:%d",
+				hw_mgr->secure_mode,
+				icp_dev_acquire_info.secure_mode);
+			return -EINVAL;
+		}
+	}
+
 	acquire_size = sizeof(struct cam_icp_acquire_dev_info) +
 		(icp_dev_acquire_info.num_out_res *
 		sizeof(struct cam_icp_res_info));
 	ctx_data->icp_dev_acquire_info = kzalloc(acquire_size, GFP_KERNEL);
-	if (!ctx_data->icp_dev_acquire_info)
+	if (!ctx_data->icp_dev_acquire_info) {
+		if (!hw_mgr->ctxt_cnt)
+			hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE;
 		return -ENOMEM;
+	}
 
 	if (copy_from_user(ctx_data->icp_dev_acquire_info,
 		(void __user *)args->acquire_info, acquire_size)) {
+		if (!hw_mgr->ctxt_cnt)
+			hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE;
 		kfree(ctx_data->icp_dev_acquire_info);
 		ctx_data->icp_dev_acquire_info = NULL;
 		return -EFAULT;
 	}
 
-	CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x",
+	CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x %u",
 		ctx_data->icp_dev_acquire_info->dev_type,
 		ctx_data->icp_dev_acquire_info->in_res.format,
 		ctx_data->icp_dev_acquire_info->in_res.width,
 		ctx_data->icp_dev_acquire_info->in_res.height,
 		ctx_data->icp_dev_acquire_info->in_res.fps,
 		ctx_data->icp_dev_acquire_info->num_out_res,
-		ctx_data->icp_dev_acquire_info->scratch_mem_size);
+		ctx_data->icp_dev_acquire_info->scratch_mem_size,
+		hw_mgr->secure_mode);
 
 	p_icp_out = ctx_data->icp_dev_acquire_info->out_res;
 	for (i = 0; i < icp_dev_acquire_info.num_out_res; i++)
@@ -1680,18 +2552,10 @@
 		goto acquire_info_failed;
 	icp_dev_acquire_info = ctx_data->icp_dev_acquire_info;
 
-	/* Get IOCONFIG command info */
-	if (icp_dev_acquire_info->secure_mode)
-		rc = cam_mem_get_io_buf(
-			icp_dev_acquire_info->io_config_cmd_handle,
-			hw_mgr->iommu_sec_hdl,
-			&io_buf_addr, &io_buf_size);
-	else
-		rc = cam_mem_get_io_buf(
-			icp_dev_acquire_info->io_config_cmd_handle,
-			hw_mgr->iommu_hdl,
-			&io_buf_addr, &io_buf_size);
-
+	rc = cam_mem_get_io_buf(
+		icp_dev_acquire_info->io_config_cmd_handle,
+		hw_mgr->iommu_hdl,
+		&io_buf_addr, &io_buf_size);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "unable to get src buf info from io desc");
 		goto get_io_buf_failed;
@@ -1704,6 +2568,9 @@
 	mutex_lock(&hw_mgr->hw_mgr_mutex);
 	if (!hw_mgr->ctxt_cnt) {
 		mutex_unlock(&hw_mgr->hw_mgr_mutex);
+		rc = cam_icp_clk_info_init(hw_mgr, ctx_data);
+		if (rc)
+			goto get_io_buf_failed;
 		rc = cam_icp_mgr_download_fw(hw_mgr, ctx_data);
 		if (rc)
 			goto get_io_buf_failed;
@@ -1749,6 +2616,7 @@
 		icp_dev_acquire_info, sizeof(struct cam_icp_acquire_dev_info)))
 		goto copy_to_user_failed;
 
+	cam_icp_ctx_clk_info_init(ctx_data);
 	mutex_unlock(&ctx_data->ctx_mutex);
 	CAM_DBG(CAM_ICP, "scratch size = %x fw_handle = %x",
 			(unsigned int)icp_dev_acquire_info->scratch_mem_size,
@@ -2014,6 +2882,7 @@
 	hw_mgr_intf->download_fw = cam_icp_mgr_download_fw;
 	hw_mgr_intf->hw_close = cam_icp_mgr_hw_close;
 
+	icp_hw_mgr.secure_mode = CAM_SECURE_MODE_NON_SECURE;
 	mutex_init(&icp_hw_mgr.hw_mgr_mutex);
 	spin_lock_init(&icp_hw_mgr.hw_mgr_lock);
 
@@ -2026,7 +2895,7 @@
 
 	rc = cam_smmu_get_handle("icp", &icp_hw_mgr.iommu_hdl);
 	if (rc) {
-		CAM_ERR(CAM_ICP, "icp get iommu handle failed: %d", rc);
+		CAM_ERR(CAM_ICP, "get mmu handle failed: %d", rc);
 		goto icp_get_hdl_failed;
 	}
 
@@ -2036,6 +2905,12 @@
 		goto icp_attach_failed;
 	}
 
+	rc = cam_smmu_get_handle("cam-secure", &icp_hw_mgr.iommu_sec_hdl);
+	if (rc) {
+		CAM_ERR(CAM_ICP, "get secure mmu handle failed: %d", rc);
+		goto secure_hdl_failed;
+	}
+
 	rc = cam_icp_mgr_create_wq();
 	if (rc)
 		goto icp_wq_create_failed;
@@ -2045,6 +2920,9 @@
 	return rc;
 
 icp_wq_create_failed:
+	cam_smmu_destroy_handle(icp_hw_mgr.iommu_sec_hdl);
+	icp_hw_mgr.iommu_sec_hdl = -1;
+secure_hdl_failed:
 	cam_smmu_ops(icp_hw_mgr.iommu_hdl, CAM_SMMU_DETACH);
 icp_attach_failed:
 	cam_smmu_destroy_handle(icp_hw_mgr.iommu_hdl);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h
index 27a86b2..c4a483f 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h
@@ -24,7 +24,7 @@
 #include "cam_req_mgr_workq.h"
 #include "cam_mem_mgr.h"
 #include "cam_smmu_api.h"
-
+#include "cam_soc_util.h"
 
 #define CAM_ICP_ROLE_PARENT     1
 #define CAM_ICP_ROLE_CHILD      2
@@ -33,7 +33,7 @@
 
 #define CAM_MAX_OUT_RES         6
 
-#define ICP_WORKQ_NUM_TASK      30
+#define ICP_WORKQ_NUM_TASK      100
 #define ICP_WORKQ_TASK_CMD_TYPE 1
 #define ICP_WORKQ_TASK_MSG_TYPE 2
 
@@ -45,6 +45,12 @@
 #define ICP_FRAME_PROCESS_SUCCESS 0
 #define ICP_FRAME_PROCESS_FAILURE 1
 
+#define ICP_CLK_HW_IPE          0x0
+#define ICP_CLK_HW_BPS          0x1
+#define ICP_CLK_HW_MAX          0x2
+
+#define ICP_OVER_CLK_THRESHOLD  15
+
 /**
  * struct icp_hfi_mem_info
  * @qtbl: Memory info of queue table
@@ -97,6 +103,8 @@
  * @request_id: Request id list
  * @num_out_resources: Number of out syncs
  * @out_resource: Out sync info
+ * @fw_process_flag: Frame process flag
+ * @clk_info: Clock information for a request
  */
 struct hfi_frame_process_info {
 	struct hfi_cmd_ipebps_async hfi_frame_cmd[CAM_FRAME_CMD_MAX];
@@ -106,9 +114,31 @@
 	uint64_t request_id[CAM_FRAME_CMD_MAX];
 	uint32_t num_out_resources[CAM_FRAME_CMD_MAX];
 	uint32_t out_resource[CAM_FRAME_CMD_MAX][CAM_MAX_OUT_RES];
+	uint32_t in_resource[CAM_FRAME_CMD_MAX];
+	uint32_t fw_process_flag[CAM_FRAME_CMD_MAX];
+	struct cam_icp_clk_bw_request clk_info[CAM_FRAME_CMD_MAX];
 };
 
 /**
+ * struct cam_ctx_clk_info
+ * @curr_fc: Context latest request frame cycles
+ * @rt_flag: Flag to indicate real time request
+ * @base_clk: Base clock to process the request
+ * @reserved: Reserved field
+ * #uncompressed_bw: Current bandwidth voting
+ * @compressed_bw: Current compressed bandwidth voting
+ * @clk_rate: Supported clock rates for the context
+ */
+struct cam_ctx_clk_info {
+	uint32_t curr_fc;
+	uint32_t rt_flag;
+	uint32_t base_clk;
+	uint32_t reserved;
+	uint64_t uncompressed_bw;
+	uint64_t compressed_bw;
+	int32_t clk_rate[CAM_MAX_VOTE];
+};
+/**
  * struct cam_icp_hw_ctx_data
  * @context_priv: Context private data
  * @ctx_mutex: Mutex for context
@@ -122,8 +152,9 @@
  * @chain_ctx: Peer context
  * @hfi_frame_process: Frame process command
  * @wait_complete: Completion info
- * @ctx_id: Context Id
  * @temp_payload: Payload for destroy handle data
+ * @ctx_id: Context Id
+ * @clk_info: Current clock info of a context
  */
 struct cam_icp_hw_ctx_data {
 	void *context_priv;
@@ -140,6 +171,35 @@
 	struct completion wait_complete;
 	struct ipe_bps_destroy temp_payload;
 	uint32_t ctx_id;
+	struct cam_ctx_clk_info clk_info;
+};
+
+/**
+ * struct icp_cmd_generic_blob
+ * @ctx: Current context info
+ * @frame_info_idx: Index used for frame process info
+ */
+struct icp_cmd_generic_blob {
+	struct cam_icp_hw_ctx_data *ctx;
+	uint32_t frame_info_idx;
+};
+
+/**
+ * struct cam_icp_clk_info
+ * @base_clk: Base clock to process request
+ * @curr_clk: Current clock of hadrware
+ * @threshold: Threshold for overclk count
+ * @over_clked: Over clock count
+ * #uncompressed_bw: Current bandwidth voting
+ * @compressed_bw: Current compressed bandwidth voting
+ */
+struct cam_icp_clk_info {
+	uint32_t base_clk;
+	uint32_t curr_clk;
+	uint32_t threshold;
+	uint32_t over_clked;
+	uint64_t uncompressed_bw;
+	uint64_t compressed_bw;
 };
 
 /**
@@ -166,6 +226,10 @@
  * @dentry: Debugfs entry
  * @a5_debug: A5 debug flag
  * @icp_pc_flag: Flag to enable/disable power collapse
+ * @icp_debug_clk: Set clock based on debug value
+ * @icp_default_clk: Set this clok if user doesn't supply
+ * @clk_info: Clock info of hardware
+ * @secure_mode: Flag to enable/disable secure camera
  */
 struct cam_icp_hw_mgr {
 	struct mutex hw_mgr_mutex;
@@ -192,6 +256,10 @@
 	struct dentry *dentry;
 	bool a5_debug;
 	bool icp_pc_flag;
+	uint64_t icp_debug_clk;
+	uint64_t icp_default_clk;
+	struct cam_icp_clk_info clk_info[ICP_CLK_HW_MAX];
+	bool secure_mode;
 };
 
 static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_bps_hw_intf.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_bps_hw_intf.h
index 4427a30..d79187f 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_bps_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_bps_hw_intf.h
@@ -26,6 +26,7 @@
 	CAM_ICP_BPS_CMD_VOTE_CPAS,
 	CAM_ICP_BPS_CMD_CPAS_START,
 	CAM_ICP_BPS_CMD_CPAS_STOP,
+	CAM_ICP_BPS_CMD_UPDATE_CLK,
 	CAM_ICP_BPS_CMD_MAX,
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_icp_hw_intf.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_icp_hw_intf.h
index 9300ea8..6915ad5 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_icp_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_icp_hw_intf.h
@@ -13,8 +13,6 @@
 #ifndef CAM_ICP_HW_INTF_H
 #define CAM_ICP_HW_INTF_H
 
-#define CAM_ICP_CTX_MAX                 8
-
 #define CAM_ICP_CMD_BUF_MAX_SIZE     128
 #define CAM_ICP_MSG_BUF_MAX_SIZE     CAM_ICP_CMD_BUF_MAX_SIZE
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_ipe_hw_intf.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_ipe_hw_intf.h
index 0db66c0..697757e 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_ipe_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/include/cam_ipe_hw_intf.h
@@ -26,6 +26,7 @@
 	CAM_ICP_IPE_CMD_VOTE_CPAS,
 	CAM_ICP_IPE_CMD_CPAS_START,
 	CAM_ICP_IPE_CMD_CPAS_STOP,
+	CAM_ICP_IPE_CMD_UPDATE_CLK,
 	CAM_ICP_IPE_CMD_MAX,
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
index 2f100ca..4f6fce8 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
@@ -18,7 +18,9 @@
 #include <linux/of.h>
 #include "cam_cpas_api.h"
 
-#define ICP_TURBO_VOTE           640000000
+#define ICP_TURBO_VOTE           600000000
+#define ICP_SVS_VOTE             400000000
+#define CAM_ICP_CTX_MAX          36
 
 int cam_icp_hw_mgr_init(struct device_node *of_node,
 	uint64_t *hw_mgr_hdl);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
index 79c3388..8630e34 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
@@ -73,8 +73,8 @@
 
 	cpas_vote.ahb_vote.type = CAM_VOTE_ABSOLUTE;
 	cpas_vote.ahb_vote.vote.level = CAM_SVS_VOTE;
-	cpas_vote.axi_vote.compressed_bw = ICP_TURBO_VOTE;
-	cpas_vote.axi_vote.uncompressed_bw = ICP_TURBO_VOTE;
+	cpas_vote.axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+	cpas_vote.axi_vote.uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
 
 	rc = cam_cpas_start(core_info->cpas_handle,
 		&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
@@ -263,6 +263,13 @@
 	case CAM_ICP_IPE_CMD_POWER_RESUME:
 		rc = cam_ipe_handle_resume(ipe_dev);
 		break;
+	case CAM_ICP_IPE_CMD_UPDATE_CLK: {
+		uint32_t clk_rate = *(uint32_t *)cmd_args;
+
+		CAM_DBG(CAM_ICP, "ipe_src_clk rate = %d", (int)clk_rate);
+		rc = cam_ipe_update_clk_rate(soc_info, clk_rate);
+		}
+		break;
 	default:
 		break;
 	}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
index d13363e..cbd9d84 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
@@ -86,6 +86,8 @@
 		return -ENOMEM;
 	}
 	ipe_dev->soc_info.pdev = pdev;
+	ipe_dev->soc_info.dev = &pdev->dev;
+	ipe_dev->soc_info.dev_name = pdev->name;
 	ipe_dev_intf->hw_priv = ipe_dev;
 	ipe_dev_intf->hw_ops.init = cam_ipe_init_hw;
 	ipe_dev_intf->hw_ops.deinit = cam_ipe_deinit_hw;
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
index e7b2733f..49176b5 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
@@ -135,3 +135,13 @@
 
 	return rc;
 }
+
+int cam_ipe_update_clk_rate(struct cam_hw_soc_info *soc_info,
+	uint32_t clk_rate)
+{
+	if (!soc_info)
+		return -EINVAL;
+
+	return cam_soc_util_set_clk_rate(soc_info->clk[soc_info->src_clk_idx],
+		soc_info->clk_name[soc_info->src_clk_idx], clk_rate);
+}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.h
index ed8bb6e..8e5a38a 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.h
@@ -25,4 +25,7 @@
 int cam_ipe_get_gdsc_control(struct cam_hw_soc_info *soc_info);
 
 int cam_ipe_transfer_gdsc_control(struct cam_hw_soc_info *soc_info);
+
+int cam_ipe_update_clk_rate(struct cam_hw_soc_info *soc_info,
+	uint32_t clk_rate);
 #endif /* CAM_IPE_SOC_H */
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
index a6f60f5..aad7902 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
@@ -24,6 +24,91 @@
 #include "cam_trace.h"
 #include "cam_debug_util.h"
 
+static int __cam_isp_ctx_enqueue_request_in_order(
+	struct cam_context *ctx, struct cam_ctx_request *req)
+{
+	struct cam_ctx_request           *req_current;
+	struct cam_ctx_request           *req_prev;
+	struct list_head                  temp_list;
+
+	INIT_LIST_HEAD(&temp_list);
+	spin_lock_bh(&ctx->lock);
+	if (list_empty(&ctx->pending_req_list)) {
+		list_add_tail(&req->list, &ctx->pending_req_list);
+	} else {
+		list_for_each_entry_safe_reverse(
+			req_current, req_prev, &ctx->pending_req_list, list) {
+			if (req->request_id < req_current->request_id) {
+				list_del_init(&req_current->list);
+				list_add(&req_current->list, &temp_list);
+				continue;
+			} else if (req->request_id == req_current->request_id) {
+				CAM_WARN(CAM_ISP,
+					"Received duplicated request %lld",
+					req->request_id);
+			}
+			break;
+		}
+		list_add_tail(&req->list, &ctx->pending_req_list);
+
+		if (!list_empty(&temp_list)) {
+			list_for_each_entry_safe(
+				req_current, req_prev, &temp_list, list) {
+				list_del_init(&req_current->list);
+				list_add_tail(&req_current->list,
+					&ctx->pending_req_list);
+			}
+		}
+	}
+	spin_unlock_bh(&ctx->lock);
+	return 0;
+}
+
+static const char *__cam_isp_resource_handle_id_to_type
+	(uint32_t resource_handle)
+{
+	switch (resource_handle) {
+	case CAM_ISP_IFE_OUT_RES_FULL:
+		return "CAM_ISP_IFE_OUT_RES_FULL";
+	case CAM_ISP_IFE_OUT_RES_DS4:
+		return "CAM_ISP_IFE_OUT_RES_DS4";
+	case CAM_ISP_IFE_OUT_RES_DS16:
+		return "CAM_ISP_IFE_OUT_RES_DS16";
+	case CAM_ISP_IFE_OUT_RES_RAW_DUMP:
+		return "CAM_ISP_IFE_OUT_RES_RAW_DUMP";
+	case CAM_ISP_IFE_OUT_RES_FD:
+		return "CAM_ISP_IFE_OUT_RES_FD";
+	case CAM_ISP_IFE_OUT_RES_PDAF:
+		return "CAM_ISP_IFE_OUT_RES_PDAF";
+	case CAM_ISP_IFE_OUT_RES_RDI_0:
+		return "CAM_ISP_IFE_OUT_RES_RDI_0";
+	case CAM_ISP_IFE_OUT_RES_RDI_1:
+		return "CAM_ISP_IFE_OUT_RES_RDI_1";
+	case CAM_ISP_IFE_OUT_RES_RDI_2:
+		return "CAM_ISP_IFE_OUT_RES_RDI_2";
+	case CAM_ISP_IFE_OUT_RES_RDI_3:
+		return "CAM_ISP_IFE_OUT_RES_RDI_3";
+	case CAM_ISP_IFE_OUT_RES_STATS_HDR_BE:
+		return "CAM_ISP_IFE_OUT_RES_STATS_HDR_BE";
+	case CAM_ISP_IFE_OUT_RES_STATS_HDR_BHIST:
+		return "CAM_ISP_IFE_OUT_RES_STATS_HDR_BHIST";
+	case CAM_ISP_IFE_OUT_RES_STATS_TL_BG:
+		return "CAM_ISP_IFE_OUT_RES_STATS_TL_BG";
+	case CAM_ISP_IFE_OUT_RES_STATS_BF:
+		return "CAM_ISP_IFE_OUT_RES_STATS_BF";
+	case CAM_ISP_IFE_OUT_RES_STATS_AWB_BG:
+		return "CAM_ISP_IFE_OUT_RES_STATS_AWB_BG";
+	case CAM_ISP_IFE_OUT_RES_STATS_BHIST:
+		return "CAM_ISP_IFE_OUT_RES_STATS_BHIST";
+	case CAM_ISP_IFE_OUT_RES_STATS_RS:
+		return "CAM_ISP_IFE_OUT_RES_STATS_RS";
+	case CAM_ISP_IFE_OUT_RES_STATS_CS:
+		return "CAM_ISP_IFE_OUT_RES_STATS_CS";
+	default:
+		return "CAM_ISP_Invalid_Resource_Type";
+	}
+}
+
 static uint64_t __cam_isp_ctx_get_event_ts(uint32_t evt_id, void *evt_data)
 {
 	uint64_t ts = 0;
@@ -61,6 +146,23 @@
 	return ts;
 }
 
+static void __cam_isp_ctx_handle_buf_done_fail_log(
+	struct cam_isp_ctx_req *req_isp)
+{
+	int i;
+
+	CAM_ERR_RATE_LIMIT(CAM_ISP,
+		"Resource Handles that fail to generate buf_done in prev frame");
+	for (i = 0; i < req_isp->num_fence_map_out; i++) {
+		if (req_isp->fence_map_out[i].sync_id != -1)
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"Resource_Handle: [%s] Sync_ID: [0x%x]",
+			__cam_isp_resource_handle_id_to_type(
+			req_isp->fence_map_out[i].resource_handle),
+			req_isp->fence_map_out[i].sync_id);
+	}
+}
+
 static int __cam_isp_ctx_handle_buf_done_in_activated_state(
 	struct cam_isp_context *ctx_isp,
 	struct cam_isp_hw_done_event_data *done,
@@ -103,8 +205,12 @@
 		if (!bubble_state) {
 			CAM_DBG(CAM_ISP, "Sync with success: fd 0x%x",
 				   req_isp->fence_map_out[j].sync_id);
-			rc = cam_sync_signal(req_isp->fence_map_out[j].sync_id,
-				CAM_SYNC_STATE_SIGNALED_SUCCESS);
+			if (req_isp->fence_map_out[j].sync_id == -1)
+				__cam_isp_ctx_handle_buf_done_fail_log(req_isp);
+			else
+				rc = cam_sync_signal(req_isp->
+					fence_map_out[j].sync_id,
+					CAM_SYNC_STATE_SIGNALED_SUCCESS);
 			if (rc)
 				CAM_ERR(CAM_ISP, "Sync failed with rc = %d",
 					 rc);
@@ -219,7 +325,8 @@
 static int __cam_isp_ctx_notify_sof_in_actived_state(
 	struct cam_isp_context *ctx_isp, void *evt_data)
 {
-	struct cam_req_mgr_sof_notify  notify;
+	int rc = 0;
+	struct cam_req_mgr_trigger_notify  notify;
 	struct cam_context *ctx = ctx_isp->base;
 	struct cam_ctx_request  *req;
 	uint64_t  request_id  = 0;
@@ -231,15 +338,18 @@
 	 * In this case, we need to skip the current notification. This
 	 * helps the state machine to catch up the delay.
 	 */
-	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof &&
+	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_trigger &&
 		ctx_isp->active_req_cnt <= 2) {
-		notify.link_hdl = ctx->link_hdl;
-		notify.dev_hdl = ctx->dev_hdl;
-		notify.frame_id = ctx_isp->frame_id;
+		if (ctx_isp->subscribe_event & CAM_TRIGGER_POINT_SOF) {
+			notify.link_hdl = ctx->link_hdl;
+			notify.dev_hdl = ctx->dev_hdl;
+			notify.frame_id = ctx_isp->frame_id;
+			notify.trigger = CAM_TRIGGER_POINT_SOF;
 
-		ctx->ctx_crm_intf->notify_sof(&notify);
-		CAM_DBG(CAM_ISP, "Notify CRM  SOF frame %lld",
-			ctx_isp->frame_id);
+			ctx->ctx_crm_intf->notify_trigger(&notify);
+			CAM_DBG(CAM_ISP, "Notify CRM  SOF frame %lld",
+				ctx_isp->frame_id);
+		}
 
 		list_for_each_entry(req, &ctx->active_req_list, list) {
 			if (req->request_id > ctx_isp->reported_req_id) {
@@ -252,12 +362,40 @@
 		__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
 			CAM_REQ_MGR_SOF_EVENT_SUCCESS);
 	} else {
-		CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Can not notify SOF to CRM");
+		rc = -EFAULT;
 	}
 
 	return 0;
 }
 
+static int __cam_isp_ctx_notify_eof_in_actived_state(
+	struct cam_isp_context *ctx_isp, void *evt_data)
+{
+	int rc = 0;
+	struct cam_req_mgr_trigger_notify  notify;
+	struct cam_context *ctx = ctx_isp->base;
+
+	if (!(ctx_isp->subscribe_event & CAM_TRIGGER_POINT_EOF))
+		return rc;
+
+	/* notify reqmgr with eof signal */
+	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_trigger) {
+		notify.link_hdl = ctx->link_hdl;
+		notify.dev_hdl = ctx->dev_hdl;
+		notify.frame_id = ctx_isp->frame_id;
+		notify.trigger = CAM_TRIGGER_POINT_EOF;
+
+		ctx->ctx_crm_intf->notify_trigger(&notify);
+		CAM_DBG(CAM_ISP, "Notify CRM EOF frame %lld\n",
+			ctx_isp->frame_id);
+	} else {
+		CAM_ERR(CAM_ISP, "Can not notify EOF to CRM");
+		rc = -EFAULT;
+	}
+
+	return rc;
+}
 
 static int __cam_isp_ctx_sof_in_activated_state(
 	struct cam_isp_context *ctx_isp, void *evt_data)
@@ -542,7 +680,8 @@
 	 */
 
 	if (list_empty(&ctx->active_req_list)) {
-		CAM_ERR(CAM_ISP, "handling error with no active request");
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"handling error with no active request");
 		rc = -EINVAL;
 		goto end;
 	}
@@ -556,10 +695,10 @@
 		notify.req_id = req->request_id;
 
 		ctx->ctx_crm_intf->notify_err(&notify);
-		CAM_ERR(CAM_ISP, "Notify CRM about ERROR frame %lld",
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Notify CRM about ERROR frame %lld",
 			ctx_isp->frame_id);
 	} else {
-		CAM_ERR(CAM_ISP, "Can not notify ERRROR to CRM");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Can not notify ERRROR to CRM");
 		rc = -EFAULT;
 	}
 
@@ -581,7 +720,7 @@
 			__cam_isp_ctx_sof_in_activated_state,
 			__cam_isp_ctx_reg_upd_in_sof,
 			__cam_isp_ctx_notify_sof_in_actived_state,
-			NULL,
+			__cam_isp_ctx_notify_eof_in_actived_state,
 			NULL,
 		},
 	},
@@ -592,7 +731,7 @@
 			__cam_isp_ctx_sof_in_activated_state,
 			__cam_isp_ctx_reg_upd_in_activated_state,
 			__cam_isp_ctx_epoch_in_applied,
-			NULL,
+			__cam_isp_ctx_notify_eof_in_actived_state,
 			__cam_isp_ctx_buf_done_in_applied,
 		},
 	},
@@ -603,7 +742,7 @@
 			__cam_isp_ctx_sof_in_epoch,
 			NULL,
 			__cam_isp_ctx_notify_sof_in_actived_state,
-			NULL,
+			__cam_isp_ctx_notify_eof_in_actived_state,
 			__cam_isp_ctx_buf_done_in_epoch,
 		},
 	},
@@ -614,7 +753,7 @@
 			__cam_isp_ctx_sof_in_activated_state,
 			NULL,
 			__cam_isp_ctx_notify_sof_in_actived_state,
-			NULL,
+			__cam_isp_ctx_notify_eof_in_actived_state,
 			__cam_isp_ctx_buf_done_in_bubble,
 		},
 	},
@@ -658,14 +797,6 @@
 	 *
 	 */
 	ctx_isp = (struct cam_isp_context *) ctx->ctx_priv;
-	if (ctx_isp->active_req_cnt >=  2) {
-		CAM_DBG(CAM_ISP,
-			"Reject apply request due to congestion(cnt = %d)",
-			ctx_isp->active_req_cnt);
-		rc = -EFAULT;
-		goto end;
-	}
-
 	req = list_first_entry(&ctx->pending_req_list, struct cam_ctx_request,
 		list);
 
@@ -674,6 +805,9 @@
 	 * we are in the middle of the error handling. Need to reject this apply
 	 */
 	if (req->request_id != apply->request_id) {
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"Invalid Request Id asking %llu existing %llu",
+			apply->request_id, req->request_id);
 		rc = -EFAULT;
 		goto end;
 	}
@@ -681,6 +815,14 @@
 	CAM_DBG(CAM_ISP, "Apply request %lld", req->request_id);
 	req_isp = (struct cam_isp_ctx_req *) req->req_priv;
 
+	if (ctx_isp->active_req_cnt >=  2) {
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"Reject apply request due to congestion(cnt = %d)",
+			ctx_isp->active_req_cnt);
+		__cam_isp_ctx_handle_buf_done_fail_log(req_isp);
+		rc = -EFAULT;
+		goto end;
+	}
 	req_isp->bubble_report = apply->report_if_bubble;
 
 	cfg.ctxt_to_hw_map = ctx_isp->hw_ctx;
@@ -689,7 +831,7 @@
 
 	rc = ctx->hw_mgr_intf->hw_config(ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Can not apply the configuration");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Can not apply the configuration");
 	} else {
 		spin_lock_bh(&ctx->lock);
 		ctx_isp->substate_activated = next_state;
@@ -890,7 +1032,7 @@
 {
 	int rc = 0;
 	struct cam_context                    *ctx = ctx_isp->base;
-	struct cam_req_mgr_sof_notify          notify;
+	struct cam_req_mgr_trigger_notify      notify;
 	struct cam_isp_hw_sof_event_data      *sof_event_data = evt_data;
 	uint64_t                               request_id  = 0;
 
@@ -911,13 +1053,14 @@
 	 * In this case, we need to skip the current notification. This
 	 * helps the state machine to catch up the delay.
 	 */
-	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof &&
+	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_trigger &&
 		ctx_isp->active_req_cnt <= 2) {
 		notify.link_hdl = ctx->link_hdl;
 		notify.dev_hdl = ctx->dev_hdl;
 		notify.frame_id = ctx_isp->frame_id;
+		notify.trigger = CAM_TRIGGER_POINT_SOF;
 
-		ctx->ctx_crm_intf->notify_sof(&notify);
+		ctx->ctx_crm_intf->notify_trigger(&notify);
 		CAM_DBG(CAM_ISP, "Notify CRM  SOF frame %lld",
 			ctx_isp->frame_id);
 
@@ -928,7 +1071,7 @@
 		__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
 			CAM_REQ_MGR_SOF_EVENT_SUCCESS);
 	} else {
-		CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Can not notify SOF to CRM");
 	}
 
 	if (list_empty(&ctx->active_req_list))
@@ -1037,7 +1180,7 @@
 	uint32_t i;
 	struct cam_ctx_request                *req;
 	struct cam_context                    *ctx = ctx_isp->base;
-	struct cam_req_mgr_sof_notify          notify;
+	struct cam_req_mgr_trigger_notify      notify;
 	struct cam_isp_hw_sof_event_data      *sof_event_data = evt_data;
 	struct cam_isp_ctx_req                *req_isp;
 	uint64_t                               request_id  = 0;
@@ -1072,12 +1215,13 @@
 	}
 
 	/* notify reqmgr with sof signal */
-	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof) {
+	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_trigger) {
 		notify.link_hdl = ctx->link_hdl;
 		notify.dev_hdl = ctx->dev_hdl;
 		notify.frame_id = ctx_isp->frame_id;
+		notify.trigger = CAM_TRIGGER_POINT_SOF;
 
-		ctx->ctx_crm_intf->notify_sof(&notify);
+		ctx->ctx_crm_intf->notify_trigger(&notify);
 		CAM_DBG(CAM_ISP, "Notify CRM  SOF frame %lld",
 			ctx_isp->frame_id);
 
@@ -1106,11 +1250,11 @@
 	struct cam_ctx_request  *req;
 	struct cam_context      *ctx = ctx_isp->base;
 	struct cam_isp_ctx_req  *req_isp;
-	struct cam_req_mgr_sof_notify  notify;
+	struct cam_req_mgr_trigger_notify  notify;
 	uint64_t  request_id  = 0;
 
 	/* notify reqmgr with sof signal*/
-	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof) {
+	if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_trigger) {
 		if (list_empty(&ctx->pending_req_list)) {
 			CAM_ERR(CAM_ISP, "Reg upd ack with no pending request");
 			goto error;
@@ -1138,8 +1282,9 @@
 		notify.link_hdl = ctx->link_hdl;
 		notify.dev_hdl = ctx->dev_hdl;
 		notify.frame_id = ctx_isp->frame_id;
+		notify.trigger = CAM_TRIGGER_POINT_SOF;
 
-		ctx->ctx_crm_intf->notify_sof(&notify);
+		ctx->ctx_crm_intf->notify_trigger(&notify);
 		CAM_DBG(CAM_ISP, "Notify CRM  SOF frame %lld",
 			ctx_isp->frame_id);
 	} else {
@@ -1428,6 +1573,7 @@
 		add_req.link_hdl = ctx->link_hdl;
 		add_req.dev_hdl  = ctx->dev_hdl;
 		add_req.req_id   = req->request_id;
+		add_req.skip_before_applying = 0;
 		rc = ctx->ctx_crm_intf->add_req(&add_req);
 		if (rc) {
 			CAM_ERR(CAM_ISP, "Error: Adding request id=%llu",
@@ -1439,9 +1585,7 @@
 	CAM_DBG(CAM_ISP, "Packet request id 0x%llx",
 		packet->header.request_id);
 
-	spin_lock_bh(&ctx->lock);
-	list_add_tail(&req->list, &ctx->pending_req_list);
-	spin_unlock_bh(&ctx->lock);
+	__cam_isp_ctx_enqueue_request_in_order(ctx, req);
 
 	CAM_DBG(CAM_ISP, "Preprocessing Config %lld successful",
 		req->request_id);
@@ -1608,11 +1752,14 @@
 	struct cam_req_mgr_core_dev_link_setup *link)
 {
 	int rc = 0;
+	struct cam_isp_context *ctx_isp =
+		(struct cam_isp_context *) ctx->ctx_priv;
 
 	CAM_DBG(CAM_ISP, "Enter.........");
 
 	ctx->link_hdl = link->link_hdl;
 	ctx->ctx_crm_intf = link->crm_cb;
+	ctx_isp->subscribe_event = link->subscribe_event;
 
 	/* change state only if we had the init config */
 	if (!list_empty(&ctx->pending_req_list)) {
@@ -1645,6 +1792,7 @@
 	strlcpy(dev_info->name, CAM_ISP_DEV_NAME, sizeof(dev_info->name));
 	dev_info->dev_id = CAM_REQ_MGR_DEVICE_IFE;
 	dev_info->p_delay = 1;
+	dev_info->trigger = CAM_TRIGGER_POINT_SOF;
 
 	return rc;
 }
@@ -1801,27 +1949,14 @@
 	struct cam_release_dev_cmd *cmd)
 {
 	int rc = 0;
-	struct cam_isp_context *ctx_isp =
-		(struct cam_isp_context *) ctx->ctx_priv;
 
-	__cam_isp_ctx_stop_dev_in_activated_unlock(ctx);
+	rc = __cam_isp_ctx_stop_dev_in_activated_unlock(ctx);
+	if (rc)
+		CAM_ERR(CAM_ISP, "Stop device failed rc=%d", rc);
 
-	if (ctx_isp->hw_ctx) {
-		struct cam_hw_release_args   arg;
-
-		arg.ctxt_to_hw_map = ctx_isp->hw_ctx;
-		ctx->hw_mgr_intf->hw_release(ctx->hw_mgr_intf->hw_mgr_priv,
-			&arg);
-		ctx_isp->hw_ctx = NULL;
-	}
-
-	ctx->session_hdl = 0;
-	ctx->dev_hdl = 0;
-	ctx->link_hdl = 0;
-	ctx->ctx_crm_intf = NULL;
-
-	ctx->state =  CAM_CTX_AVAILABLE;
-	trace_cam_context_state("ISP", ctx);
+	rc = __cam_isp_ctx_release_dev_in_top_state(ctx, cmd);
+	if (rc)
+		CAM_ERR(CAM_ISP, "Release device failed rc=%d", rc);
 
 	return rc;
 }
@@ -1833,7 +1968,7 @@
 	struct cam_isp_context *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
 
-	trace_cam_apply_req("ISP", apply);
+	trace_cam_apply_req("ISP", apply->request_id);
 	CAM_DBG(CAM_ISP, "Enter: apply req in Substate %d request _id:%lld",
 		 ctx_isp->substate_activated, apply->request_id);
 	if (ctx_isp->substate_machine[ctx_isp->substate_activated].
@@ -1841,14 +1976,16 @@
 		rc = ctx_isp->substate_machine[ctx_isp->substate_activated].
 			crm_ops.apply_req(ctx, apply);
 	} else {
-		CAM_ERR(CAM_ISP, "No handle function in activated substate %d",
-			 ctx_isp->substate_activated);
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"No handle function in activated substate %d",
+			ctx_isp->substate_activated);
 		rc = -EFAULT;
 	}
 
 	if (rc)
-		CAM_ERR(CAM_ISP, "Apply failed in active substate %d",
-			 ctx_isp->substate_activated);
+		CAM_ERR_RATE_LIMIT(CAM_ISP,
+			"Apply failed in active substate %d",
+			ctx_isp->substate_activated);
 	return rc;
 }
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
index b0b883c..621d652 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
@@ -109,6 +109,9 @@
  * @sof_timestamp_val:     Captured time stamp value at sof hw event
  * @active_req_cnt:        Counter for the active request
  * @reported_req_id:       Last reported request id
+ * @subscribe_event:       The irq event mask that CRM subscribes to, IFE will
+ *                         invoke CRM cb at those event.
+ *
  */
 struct cam_isp_context {
 	struct cam_context              *base;
@@ -125,6 +128,7 @@
 	uint64_t                         sof_timestamp_val;
 	int32_t                          active_req_cnt;
 	int64_t                          reported_req_id;
+	uint32_t                         subscribe_event;
 };
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
index 4893960..6060278 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/uaccess.h>
+#include <linux/debugfs.h>
 #include <uapi/media/cam_isp.h>
 #include "cam_smmu_api.h"
 #include "cam_req_mgr_workq.h"
@@ -64,16 +65,16 @@
 		sizeof(struct cam_isp_query_cap_cmd)))
 		rc = -EFAULT;
 
-	CAM_DBG(CAM_ISP, "exit rc :%d !", rc);
+	CAM_DBG(CAM_ISP, "exit rc :%d", rc);
 
 	return rc;
 }
 
-static int cam_ife_hw_mgr_is_rdi_res(uint32_t format)
+static int cam_ife_hw_mgr_is_rdi_res(uint32_t res_id)
 {
 	int rc = 0;
 
-	switch (format) {
+	switch (res_id) {
 	case CAM_ISP_IFE_OUT_RES_RDI_0:
 	case CAM_ISP_IFE_OUT_RES_RDI_1:
 	case CAM_ISP_IFE_OUT_RES_RDI_2:
@@ -111,7 +112,7 @@
 
 	return 0;
 err:
-	CAM_ERR(CAM_ISP, "INIT HW res failed! (type:%d, id:%d)",
+	CAM_ERR(CAM_ISP, "INIT HW res failed: (type:%d, id:%d)",
 		isp_hw_res->res_type, isp_hw_res->res_id);
 	return rc;
 }
@@ -132,7 +133,7 @@
 				isp_hw_res->hw_res[i],
 				sizeof(struct cam_isp_resource_node));
 			if (rc) {
-				CAM_ERR(CAM_ISP, "Can not start HW resources!");
+				CAM_ERR(CAM_ISP, "Can not start HW resources");
 				goto err;
 			}
 		} else {
@@ -143,7 +144,7 @@
 
 	return 0;
 err:
-	CAM_ERR(CAM_ISP, "Start hw res failed! (type:%d, id:%d)",
+	CAM_ERR(CAM_ISP, "Start hw res failed (type:%d, id:%d)",
 		isp_hw_res->res_type, isp_hw_res->res_id);
 	return rc;
 }
@@ -210,7 +211,7 @@
 			struct cam_ife_hw_mgr_res, list);
 		list_del_init(&res_ptr->list);
 	} else {
-		CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx!");
+		CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx");
 		rc = -1;
 	}
 	*res = res_ptr;
@@ -235,7 +236,7 @@
 				sizeof(struct cam_isp_resource_node));
 			if (rc)
 				CAM_ERR(CAM_ISP,
-					"Release hw resrouce id %d failed!",
+					"Release hw resrouce id %d failed",
 					isp_hw_res->res_id);
 			isp_hw_res->hw_res[i] = NULL;
 		} else
@@ -362,7 +363,7 @@
 			struct cam_ife_hw_mgr_ctx, list);
 		list_del_init(&ctx_ptr->list);
 	} else {
-		CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx!");
+		CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx");
 		rc = -1;
 	}
 	*ife_ctx = ctx_ptr;
@@ -379,11 +380,12 @@
 	uint32_t    i;
 
 	if (!ctx->num_base) {
-		CAM_DBG(CAM_ISP, "Add split id = %d for base idx = %d",
-			split_id, base_idx);
 		ctx->base[0].split_id = split_id;
 		ctx->base[0].idx      = base_idx;
 		ctx->num_base++;
+		CAM_DBG(CAM_ISP,
+			"Add split id = %d for base idx = %d num_base=%d",
+			split_id, base_idx, ctx->num_base);
 	} else {
 		/*Check if base index is alreay exist in the list */
 		for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) {
@@ -398,11 +400,12 @@
 		}
 
 		if (i == CAM_IFE_HW_NUM_MAX) {
-			CAM_DBG(CAM_ISP, "Add split id = %d for base idx = %d",
-				 split_id, base_idx);
 			ctx->base[ctx->num_base].split_id = split_id;
 			ctx->base[ctx->num_base].idx      = base_idx;
 			ctx->num_base++;
+			CAM_DBG(CAM_ISP,
+				"Add split_id=%d for base idx=%d num_base=%d",
+				 split_id, base_idx, ctx->num_base);
 		}
 	}
 }
@@ -415,7 +418,7 @@
 	uint32_t i;
 
 	if (list_empty(&ctx->res_list_ife_src)) {
-		CAM_ERR(CAM_ISP, "Error! Mux List empty");
+		CAM_ERR(CAM_ISP, "Mux List empty");
 		return -ENODEV;
 	}
 
@@ -427,15 +430,12 @@
 		for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
 			if (!hw_mgr_res->hw_res[i])
 				continue;
-			res = hw_mgr_res->hw_res[i];
-			if (res->res_id == CAM_ISP_HW_VFE_IN_CAMIF)
-				cam_ife_mgr_add_base_info(ctx, i,
-					res->hw_intf->hw_idx);
 
-			else
-				cam_ife_mgr_add_base_info(ctx,
-						CAM_ISP_HW_SPLIT_MAX,
-						res->hw_intf->hw_idx);
+			res = hw_mgr_res->hw_res[i];
+			cam_ife_mgr_add_base_info(ctx, i,
+					res->hw_intf->hw_idx);
+			CAM_DBG(CAM_ISP, "add base info for hw %d",
+				res->hw_intf->hw_idx);
 		}
 	}
 	CAM_DBG(CAM_ISP, "ctx base num = %d", ctx->num_base);
@@ -475,6 +475,8 @@
 		CAM_ERR(CAM_ISP, "invalid resource type");
 		goto err;
 	}
+	CAM_DBG(CAM_ISP, "vfe_in_res_id = %d, vfe_out_red_id = %d",
+		vfe_in_res_id, vfe_out_res_id);
 
 	vfe_acquire.rsrc_type = CAM_ISP_RESOURCE_VFE_OUT;
 	vfe_acquire.tasklet = ife_ctx->common.tasklet_info;
@@ -483,6 +485,9 @@
 	for (i = 0; i < in_port->num_out_res; i++) {
 		out_port = &in_port->data[i];
 
+		CAM_DBG(CAM_ISP, "i = %d, vfe_out_res_id = %d, out_port: %d",
+			i, vfe_out_res_id, out_port->res_type);
+
 		if (vfe_out_res_id != out_port->res_type)
 			continue;
 
@@ -491,6 +496,7 @@
 		vfe_acquire.vfe_out.out_port_info = out_port;
 		vfe_acquire.vfe_out.split_id = CAM_ISP_HW_SPLIT_LEFT;
 		vfe_acquire.vfe_out.unique_id = ife_ctx->ctx_index;
+		vfe_acquire.vfe_out.is_dual = 0;
 		hw_intf = ife_src_res->hw_res[0]->hw_intf;
 		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
 			&vfe_acquire,
@@ -504,7 +510,9 @@
 	}
 
 	if (i == in_port->num_out_res) {
-		CAM_ERR(CAM_ISP, "Can not acquire out resource");
+		CAM_ERR(CAM_ISP,
+			"Cannot acquire out resource, i=%d, num_out_res=%d",
+			i, in_port->num_out_res);
 		goto err;
 	}
 
@@ -512,6 +520,7 @@
 	ife_out_res->is_dual_vfe = 0;
 	ife_out_res->res_id = vfe_out_res_id;
 	ife_out_res->res_type = CAM_ISP_RESOURCE_VFE_OUT;
+	ife_src_res->child[ife_src_res->num_children++] = ife_out_res;
 
 	return 0;
 err:
@@ -634,7 +643,8 @@
 				ife_src_res, in_port);
 			break;
 		default:
-			CAM_ERR(CAM_ISP, "Fatal: Unknown IFE SRC resource!");
+			CAM_ERR(CAM_ISP, "Unknown IFE SRC resource: %d",
+				ife_src_res->res_id);
 			break;
 		}
 		if (rc)
@@ -668,7 +678,7 @@
 		rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list,
 			&ife_src_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
+			CAM_ERR(CAM_ISP, "No more free hw mgr resource");
 			goto err;
 		}
 		cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_src,
@@ -676,7 +686,6 @@
 
 		vfe_acquire.rsrc_type = CAM_ISP_RESOURCE_VFE_IN;
 		vfe_acquire.tasklet = ife_ctx->common.tasklet_info;
-		vfe_acquire.rsrc_type = CAM_ISP_RESOURCE_VFE_IN;
 		vfe_acquire.vfe_in.cdm_ops = ife_ctx->cdm_ops;
 
 		switch (csid_res->res_id) {
@@ -708,7 +717,7 @@
 			vfe_acquire.vfe_in.sync_mode = CAM_ISP_HW_SYNC_NONE;
 			break;
 		default:
-			CAM_ERR(CAM_ISP, "Wrong IFE CSID Resource Node!");
+			CAM_ERR(CAM_ISP, "Wrong IFE CSID Resource Node");
 			goto err;
 		}
 		ife_src_res->res_type = vfe_acquire.rsrc_type;
@@ -750,9 +759,11 @@
 		 * csid resource and ife source resource
 		 */
 		csid_res->child[0] = ife_src_res;
-		csid_res->num_children = 1;
 		ife_src_res->parent = csid_res;
 		csid_res->child[csid_res->num_children++] = ife_src_res;
+		CAM_DBG(CAM_ISP, "csid_res=%d  num_children=%d ife_src_res=%d",
+			csid_res->res_id, csid_res->num_children,
+			ife_src_res->res_id);
 	}
 
 	return 0;
@@ -778,7 +789,7 @@
 
 	rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &csid_res);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
+		CAM_ERR(CAM_ISP, "No more free hw mgr resource");
 		goto err;
 	}
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_csid, &csid_res);
@@ -787,6 +798,7 @@
 	csid_acquire.res_id = CAM_IFE_PIX_PATH_RES_IPP;
 	csid_acquire.cid = cid_res_id;
 	csid_acquire.in_port = in_port;
+	csid_acquire.out_port = in_port->data;
 
 	if (in_port->usage_type)
 		csid_acquire.sync_mode = CAM_ISP_HW_SYNC_MASTER;
@@ -809,11 +821,11 @@
 	}
 
 	if (i == CAM_IFE_CSID_HW_NUM_MAX) {
-		CAM_ERR(CAM_ISP, "Can not acquire ife csid ipp resrouce!");
+		CAM_ERR(CAM_ISP, "Can not acquire ife csid ipp resource");
 		goto err;
 	}
 
-	CAM_DBG(CAM_ISP, "acquired csid(%d) left ipp resrouce successfully!",
+	CAM_DBG(CAM_ISP, "acquired csid(%d) left ipp resource successfully",
 		 i);
 
 	csid_res->res_type = CAM_ISP_RESOURCE_PIX_PATH;
@@ -824,6 +836,7 @@
 
 	if (csid_res->is_dual_vfe) {
 		csid_acquire.sync_mode = CAM_ISP_HW_SYNC_SLAVE;
+		csid_acquire.master_idx = csid_res->hw_res[0]->hw_intf->hw_idx;
 
 		for (j = i + 1; j < CAM_IFE_CSID_HW_NUM_MAX; j++) {
 			if (!ife_hw_mgr->csid_devices[j])
@@ -840,18 +853,17 @@
 
 		if (j == CAM_IFE_CSID_HW_NUM_MAX) {
 			CAM_ERR(CAM_ISP,
-				"Can not acquire ife csid rdi resrouce!");
+				"Can not acquire ife csid rdi resrouce");
 			goto err;
 		}
 		csid_res->hw_res[1] = csid_acquire.node_res;
 
 		CAM_DBG(CAM_ISP,
-			"acquired csid(%d)right ipp resrouce successfully!", j);
+			"acquired csid(%d)right ipp resrouce successfully", j);
 
 	}
 	csid_res->parent = &ife_ctx->res_list_ife_in;
-	ife_ctx->res_list_ife_in.child[
-		ife_ctx->res_list_ife_in.num_children++] = csid_res;
+	CAM_DBG(CAM_ISP, "acquire res %d", csid_acquire.res_id);
 
 	return 0;
 err:
@@ -863,7 +875,6 @@
 	uint32_t                 out_port_type)
 {
 	enum cam_ife_pix_path_res_id path_id;
-
 	switch (out_port_type) {
 	case CAM_ISP_IFE_OUT_RES_RDI_0:
 		path_id = CAM_IFE_PIX_PATH_RES_RDI_0;
@@ -883,6 +894,8 @@
 		break;
 	}
 
+	CAM_DBG(CAM_ISP, "out_port %d path_id %d", out_port_type, path_id);
+
 	return path_id;
 }
 
@@ -910,7 +923,7 @@
 		rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list,
 			&csid_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "No more free hw mgr resource!",
+			CAM_ERR(CAM_ISP, "No more free hw mgr resource",
 				__func__);
 			goto err;
 		}
@@ -946,7 +959,7 @@
 
 		if (j == CAM_IFE_CSID_HW_NUM_MAX) {
 			CAM_ERR(CAM_ISP,
-				"Can not acquire ife csid rdi resrouce!");
+				"Can not acquire ife csid rdi resource");
 			goto err;
 		}
 
@@ -955,10 +968,8 @@
 		csid_res->is_dual_vfe = 0;
 		csid_res->hw_res[0] = csid_acquire.node_res;
 		csid_res->hw_res[1] = NULL;
-
+		CAM_DBG(CAM_ISP, "acquire res %d", csid_acquire.res_id);
 		csid_res->parent = &ife_ctx->res_list_ife_in;
-		ife_ctx->res_list_ife_in.child[
-			ife_ctx->res_list_ife_in.num_children++] = csid_res;
 	}
 
 	return 0;
@@ -979,7 +990,7 @@
 		ife_ctx->res_list_ife_in.res_id = in_port->res_type;
 		ife_ctx->res_list_ife_in.is_dual_vfe = in_port->usage_type;
 	} else if (ife_ctx->res_list_ife_in.res_id != in_port->res_type) {
-		CAM_ERR(CAM_ISP, "No Free resource for this context!");
+		CAM_ERR(CAM_ISP, "No Free resource for this context");
 		goto err;
 	} else {
 		/* else do nothing */
@@ -1030,18 +1041,11 @@
 	struct cam_hw_intf                  *hw_intf;
 	struct cam_csid_hw_reserve_resource_args  csid_acquire;
 
-	/* no dual vfe for TPG */
-	if ((in_port->res_type == CAM_ISP_IFE_IN_RES_TPG) &&
-		(in_port->usage_type != 0)) {
-		CAM_ERR(CAM_ISP, "No Dual VFE on TPG input!");
-		goto err;
-	}
-
 	ife_hw_mgr = ife_ctx->hw_mgr;
 
 	rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &cid_res);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
+		CAM_ERR(CAM_ISP, "No more free hw mgr resource");
 		goto err;
 	}
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_cid, &cid_res);
@@ -1063,7 +1067,7 @@
 	}
 
 	if (i == CAM_IFE_CSID_HW_NUM_MAX || !csid_acquire.node_res) {
-		CAM_ERR(CAM_ISP, "Can not acquire ife csid rdi resrouce!");
+		CAM_ERR(CAM_ISP, "Can not acquire ife csid rdi resource");
 		goto err;
 	}
 
@@ -1094,7 +1098,7 @@
 
 		if (j == CAM_IFE_CSID_HW_NUM_MAX) {
 			CAM_ERR(CAM_ISP,
-				"Can not acquire ife csid rdi resrouce!");
+				"Can not acquire ife csid rdi resource");
 			goto err;
 		}
 		cid_res->hw_res[1] = csid_acquire.node_res;
@@ -1124,14 +1128,14 @@
 	/* get root node resource */
 	rc = cam_ife_hw_mgr_acquire_res_root(ife_ctx, in_port);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Can not acquire csid rx resource!");
+		CAM_ERR(CAM_ISP, "Can not acquire csid rx resource");
 		goto err;
 	}
 
 	/* get cid resource */
 	rc = cam_ife_mgr_acquire_cid_res(ife_ctx, in_port, &cid_res_id);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Acquire IFE CID resource Failed!");
+		CAM_ERR(CAM_ISP, "Acquire IFE CID resource Failed");
 		goto err;
 	}
 
@@ -1139,7 +1143,7 @@
 		&pixel_count, &rdi_count);
 
 	if (!pixel_count && !rdi_count) {
-		CAM_ERR(CAM_ISP, "Error! no PIX or RDI resource");
+		CAM_ERR(CAM_ISP, "No PIX or RDI resource");
 		return -EINVAL;
 	}
 
@@ -1149,7 +1153,7 @@
 				cid_res_id);
 		if (rc) {
 			CAM_ERR(CAM_ISP,
-				"Acquire IFE CSID IPP resource Failed!");
+				"Acquire IFE CSID IPP resource Failed");
 			goto err;
 		}
 	}
@@ -1160,7 +1164,7 @@
 			cid_res_id);
 		if (rc) {
 			CAM_ERR(CAM_ISP,
-				"Acquire IFE CSID RDI resource Failed!");
+				"Acquire IFE CSID RDI resource Failed");
 			goto err;
 		}
 	}
@@ -1168,13 +1172,13 @@
 	/* get ife src resource */
 	rc = cam_ife_hw_mgr_acquire_res_ife_src(ife_ctx, in_port);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Acquire IFE SRC resource Failed!");
+		CAM_ERR(CAM_ISP, "Acquire IFE SRC resource Failed");
 		goto err;
 	}
 
 	rc = cam_ife_hw_mgr_acquire_res_ife_out(ife_ctx, in_port);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Acquire IFE OUT resource Failed!");
+		CAM_ERR(CAM_ISP, "Acquire IFE OUT resource Failed");
 		goto err;
 	}
 
@@ -1207,8 +1211,10 @@
 	struct cam_isp_in_port_info       *in_port = NULL;
 	struct cam_isp_resource           *isp_resource = NULL;
 	struct cam_cdm_acquire_data        cdm_acquire;
-	uint32_t                           num_pix_port = 0;
-	uint32_t                           num_rdi_port = 0;
+	uint32_t                           num_pix_port_per_in = 0;
+	uint32_t                           num_rdi_port_per_in = 0;
+	uint32_t                           total_pix_port = 0;
+	uint32_t                           total_rdi_port = 0;
 
 	CAM_DBG(CAM_ISP, "Enter...");
 
@@ -1220,7 +1226,7 @@
 	/* get the ife ctx */
 	rc = cam_ife_hw_mgr_get_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx);
 	if (rc || !ife_ctx) {
-		CAM_ERR(CAM_ISP, "Get ife hw context failed!");
+		CAM_ERR(CAM_ISP, "Get ife hw context failed");
 		goto err;
 	}
 
@@ -1272,7 +1278,10 @@
 			isp_resource[i].length);
 		if (in_port > 0) {
 			rc = cam_ife_mgr_acquire_hw_for_ctx(ife_ctx, in_port,
-				&num_pix_port, &num_rdi_port);
+				&num_pix_port_per_in, &num_rdi_port_per_in);
+			total_pix_port += num_pix_port_per_in;
+			total_rdi_port += num_rdi_port_per_in;
+
 			kfree(in_port);
 			if (rc) {
 				CAM_ERR(CAM_ISP, "can not acquire resource");
@@ -1280,7 +1289,7 @@
 			}
 		} else {
 			CAM_ERR(CAM_ISP,
-				"copy from user failed with in_port = %pK",
+				"Copy from user failed with in_port = %pK",
 				in_port);
 			rc = -EFAULT;
 			goto free_res;
@@ -1288,13 +1297,15 @@
 	}
 
 	/* Check whether context has only RDI resource */
-	if (!num_pix_port)
+	if (!total_pix_port) {
 		ife_ctx->is_rdi_only_context = 1;
+		CAM_DBG(CAM_ISP, "RDI only context");
+	}
 
 	/* Process base info */
 	rc = cam_ife_mgr_process_base_info(ife_ctx);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Error process) base info!");
+		CAM_ERR(CAM_ISP, "Process base info failed");
 		return -EINVAL;
 	}
 
@@ -1303,14 +1314,14 @@
 
 	cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->used_ctx_list, &ife_ctx);
 
-	CAM_DBG(CAM_ISP, "Exit...(success)!");
+	CAM_DBG(CAM_ISP, "Exit...(success)");
 
 	return 0;
 free_res:
 	cam_ife_hw_mgr_release_hw_for_ctx(ife_ctx);
 	cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx);
 err:
-	CAM_DBG(CAM_ISP, "Exit...(rc=%d)!", rc);
+	CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc);
 	return rc;
 }
 
@@ -1333,16 +1344,17 @@
 	cfg = config_hw_args;
 	ctx = (struct cam_ife_hw_mgr_ctx *)cfg->ctxt_to_hw_map;
 	if (!ctx) {
-		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
 	if (!ctx->ctx_in_use || !ctx->cdm_cmd) {
-		CAM_ERR(CAM_ISP, "Invalid context parameters !");
+		CAM_ERR(CAM_ISP, "Invalid context parameters");
 		return -EPERM;
 	}
 
-	CAM_DBG(CAM_ISP, "Enter ctx id:%d", ctx->ctx_index);
+	CAM_DBG(CAM_ISP, "Enter ctx id:%d num_hw_upd_entries %d",
+		ctx->ctx_index, cfg->num_hw_update_entries);
 
 	if (cfg->num_hw_update_entries > 0) {
 		cdm_cmd = ctx->cdm_cmd;
@@ -1359,6 +1371,7 @@
 			cdm_cmd->cmd[i].len = cmd->len;
 		}
 
+		CAM_DBG(CAM_ISP, "Submit to CDM");
 		rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd);
 		if (rc)
 			CAM_ERR(CAM_ISP, "Failed to apply the configs");
@@ -1385,7 +1398,7 @@
 	}
 	ctx = (struct cam_ife_hw_mgr_ctx *)stop_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
@@ -1394,7 +1407,7 @@
 
 	/* stop resource will remove the irq mask from the hardware */
 	if (!ctx->num_base) {
-		CAM_ERR(CAM_ISP, "error number of bases are zero");
+		CAM_ERR(CAM_ISP, "Number of bases are zero");
 		return -EINVAL;
 	}
 
@@ -1471,7 +1484,7 @@
 	}
 	ctx = (struct cam_ife_hw_mgr_ctx *)stop_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
@@ -1481,7 +1494,7 @@
 	/* Note:stop resource will remove the irq mask from the hardware */
 
 	if (!ctx->num_base) {
-		CAM_ERR(CAM_ISP, "error number of bases are zero");
+		CAM_ERR(CAM_ISP, "number of bases are zero");
 		return -EINVAL;
 	}
 
@@ -1625,7 +1638,7 @@
 
 	ctx = (struct cam_ife_hw_mgr_ctx *)start_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
@@ -1636,7 +1649,7 @@
 	for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
 		rc = cam_ife_hw_mgr_start_hw_res(&ctx->res_list_ife_out[i]);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)!", i);
+			CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)", i);
 			goto err;
 		}
 	}
@@ -1646,7 +1659,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1657,7 +1670,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1668,7 +1681,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1699,7 +1712,7 @@
 
 	ctx = (struct cam_ife_hw_mgr_ctx *)start_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
@@ -1710,6 +1723,16 @@
 
 	cam_tasklet_start(ctx->common.tasklet_info);
 
+	/* set current csid debug information to CSID HW */
+	for (i = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) {
+		if (g_ife_hw_mgr.csid_devices[i])
+			rc = g_ife_hw_mgr.csid_devices[i]->hw_ops.process_cmd(
+				g_ife_hw_mgr.csid_devices[i]->hw_priv,
+				CAM_IFE_CSID_SET_CSID_DEBUG,
+				&g_ife_hw_mgr.debug_cfg.csid_debug,
+				sizeof(g_ife_hw_mgr.debug_cfg.csid_debug));
+	}
+
 	/* INIT IFE Root: do nothing */
 
 	CAM_DBG(CAM_ISP, "INIT IFE CID ... in ctx id:%d",
@@ -1718,7 +1741,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
 		rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not INIT IFE CID.(id :%d)!",
+			CAM_ERR(CAM_ISP, "Can not INIT IFE CID(id :%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1732,7 +1755,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
 		rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not INIT IFE CSID.(id :%d)!",
+			CAM_ERR(CAM_ISP, "Can not INIT IFE CSID(id :%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1744,7 +1767,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
 		rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not INIT IFE SRC (%d)!",
+			CAM_ERR(CAM_ISP, "Can not INIT IFE SRC (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1757,7 +1780,7 @@
 	for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
 		rc = cam_ife_hw_mgr_init_hw_res(&ctx->res_list_ife_out[i]);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not INIT IFE OUT (%d)!",
+			CAM_ERR(CAM_ISP, "Can not INIT IFE OUT (%d)",
 				 ctx->res_list_ife_out[i].res_id);
 			goto err;
 		}
@@ -1766,7 +1789,7 @@
 	CAM_DBG(CAM_ISP, "start cdm interface");
 	rc = cam_cdm_stream_on(ctx->cdm_handle);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Can not start cdm (%d)!",
+		CAM_ERR(CAM_ISP, "Can not start cdm (%d)",
 			 ctx->cdm_handle);
 		goto err;
 	}
@@ -1785,7 +1808,7 @@
 	for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
 		rc = cam_ife_hw_mgr_start_hw_res(&ctx->res_list_ife_out[i]);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)",
 				 i);
 			goto err;
 		}
@@ -1797,7 +1820,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1809,7 +1832,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1821,7 +1844,7 @@
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
 		rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
 		if (rc) {
-			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+			CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)",
 				 hw_mgr_res->res_id);
 			goto err;
 		}
@@ -1861,7 +1884,7 @@
 
 	ctx = (struct cam_ife_hw_mgr_ctx *)release_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Invalid context is used");
 		return -EPERM;
 	}
 
@@ -1898,6 +1921,7 @@
 	struct cam_kmd_buf_info           kmd_buf;
 	uint32_t                          i;
 	bool                              fill_fence = true;
+	struct cam_isp_generic_blob_info  blob_info;
 
 	if (!hw_mgr_priv || !prepare_hw_update_args) {
 		CAM_ERR(CAM_ISP, "Invalid args");
@@ -1913,19 +1937,27 @@
 	if (rc)
 		return rc;
 
-	CAM_DBG(CAM_ISP, "enter");
 	/* Pre parse the packet*/
 	rc = cam_packet_util_get_kmd_buffer(prepare->packet, &kmd_buf);
 	if (rc)
 		return rc;
 
 	rc = cam_packet_util_process_patches(prepare->packet,
-		hw_mgr->mgr_common.cmd_iommu_hdl);
+		hw_mgr->mgr_common.cmd_iommu_hdl,
+		hw_mgr->mgr_common.cmd_iommu_hdl_secure);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Patch ISP packet failed.");
 		return rc;
 	}
 
+	memset(&blob_info, 0x0, sizeof(struct cam_isp_generic_blob_info));
+	rc = cam_isp_process_generic_cmd_buffer(prepare, &blob_info);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Failed in generic blob cmd buffer, rc=%d",
+			rc);
+		goto end;
+	}
+
 	prepare->num_hw_update_entries = 0;
 	prepare->num_in_map_entries = 0;
 	prepare->num_out_map_entries = 0;
@@ -1936,25 +1968,53 @@
 		/* Add change base */
 		rc = cam_isp_add_change_base(prepare, &ctx->res_list_ife_src,
 			ctx->base[i].idx, &kmd_buf);
-		if (rc)
-			return rc;
+		if (rc) {
+			CAM_ERR(CAM_ISP,
+				"Failed in change base i=%d, idx=%d, rc=%d",
+				i, ctx->base[i].idx, rc);
+			goto end;
+		}
+
 
 		/* get command buffers */
 		if (ctx->base[i].split_id != CAM_ISP_HW_SPLIT_MAX) {
 			rc = cam_isp_add_command_buffers(prepare,
-				ctx->base[i].split_id);
-			if (rc)
-				return rc;
+			ctx->base[i].split_id, ctx->base[i].idx,
+			ctx->res_list_ife_out, CAM_IFE_HW_OUT_RES_MAX);
+				if (rc) {
+					CAM_ERR(CAM_ISP,
+						"Failed in add cmdbuf, i=%d, split_id=%d, rc=%d",
+						i, ctx->base[i].split_id, rc);
+					goto end;
+				}
+		}
+
+		if (blob_info.hfr_config) {
+			rc = cam_isp_add_hfr_config_hw_update(
+				blob_info.hfr_config, prepare,
+				ctx->base[i].idx, &kmd_buf,
+				ctx->res_list_ife_out, CAM_IFE_HW_OUT_RES_MAX);
+			if (rc) {
+				CAM_ERR(CAM_ISP,
+					"Failed in hfr config, i=%d, rc=%d",
+					i, rc);
+				goto end;
+			}
 		}
 
 		/* get IO buffers */
 		rc = cam_isp_add_io_buffers(hw_mgr->mgr_common.img_iommu_hdl,
-				prepare, ctx->base[i].idx,
+			hw_mgr->mgr_common.img_iommu_hdl_secure,
+			prepare, ctx->base[i].idx,
 			&kmd_buf, ctx->res_list_ife_out,
 			CAM_IFE_HW_OUT_RES_MAX, fill_fence);
 
-		if (rc)
-			return rc;
+		if (rc) {
+			CAM_ERR(CAM_ISP,
+				"Failed in io buffers, i=%d, rc=%d",
+				i, rc);
+			goto end;
+		}
 
 		/* fence map table entries need to fill only once in the loop */
 		if (fill_fence)
@@ -1969,23 +2029,33 @@
 	 */
 	if (((prepare->packet->header.op_code + 1) & 0xF) ==
 					CAM_ISP_PACKET_INIT_DEV)
-		return rc;
+		goto end;
 
 	/* add reg update commands */
 	for (i = 0; i < ctx->num_base; i++) {
 		/* Add change base */
 		rc = cam_isp_add_change_base(prepare, &ctx->res_list_ife_src,
 			ctx->base[i].idx, &kmd_buf);
-		if (rc)
-			return rc;
+		if (rc) {
+			CAM_ERR(CAM_ISP,
+				"Failed in change base adding reg_update cmd i=%d, idx=%d, rc=%d",
+				i, ctx->base[i].idx, rc);
+			goto end;
+		}
 
 		/*Add reg update */
 		rc = cam_isp_add_reg_update(prepare, &ctx->res_list_ife_src,
 			ctx->base[i].idx, &kmd_buf);
-		if (rc)
-			return rc;
+		if (rc) {
+			CAM_ERR(CAM_ISP,
+				"Add Reg_update cmd Failed i=%d, idx=%d, rc=%d",
+				i, ctx->base[i].idx, rc);
+			goto end;
+		}
 	}
 
+end:
+	kfree(blob_info.hfr_config);
 	return rc;
 }
 
@@ -2002,7 +2072,7 @@
 
 	ctx = (struct cam_ife_hw_mgr_ctx *)hw_cmd_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
-		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used");
 		return -EPERM;
 	}
 
@@ -2070,7 +2140,7 @@
 	}
 end:
 	if (rc)
-		CAM_ERR(CAM_ISP, "error in getting sof time stamp");
+		CAM_ERR(CAM_ISP, "Getting sof time stamp failed");
 
 	return rc;
 }
@@ -2088,7 +2158,7 @@
 	struct cam_ife_hw_mgr_ctx        *ctx = NULL;
 
 	/* Here recovery is performed */
-	CAM_DBG(CAM_ISP, "Enter: ErrorType = %d", error_type);
+	CAM_DBG(CAM_ISP, "ErrorType = %d", error_type);
 
 	switch (error_type) {
 	case CAM_ISP_HW_ERROR_OVERFLOW:
@@ -2444,34 +2514,53 @@
 	return 0;
 }
 
-static int cam_ife_hw_mgr_check_epoch_for_dual_vfe(
+static int cam_ife_hw_mgr_check_irq_for_dual_vfe(
 	struct cam_ife_hw_mgr_ctx   *ife_hw_mgr_ctx,
 	uint32_t                     core_idx0,
-	uint32_t                     core_idx1)
+	uint32_t                     core_idx1,
+	uint32_t                     hw_event_type)
 {
 	int32_t rc = -1;
-	uint32_t *epoch_cnt = ife_hw_mgr_ctx->epoch_cnt;
+	uint32_t *event_cnt = NULL;
 
-	if (epoch_cnt[core_idx0] ==
-			epoch_cnt[core_idx1]) {
+	switch (hw_event_type) {
+	case CAM_ISP_HW_EVENT_SOF:
+		event_cnt = ife_hw_mgr_ctx->sof_cnt;
+		break;
+	case CAM_ISP_HW_EVENT_EPOCH:
+		event_cnt = ife_hw_mgr_ctx->epoch_cnt;
+		break;
+	case CAM_ISP_HW_EVENT_EOF:
+		event_cnt = ife_hw_mgr_ctx->eof_cnt;
+		break;
+	default:
+		return 0;
+	}
 
-		epoch_cnt[core_idx0] = 0;
-		epoch_cnt[core_idx1] = 0;
+	if (event_cnt[core_idx0] ==
+			event_cnt[core_idx1]) {
+
+		event_cnt[core_idx0] = 0;
+		event_cnt[core_idx1] = 0;
 
 		rc = 0;
 		return rc;
 	}
 
-	if ((epoch_cnt[core_idx0] - epoch_cnt[core_idx1] > 1) ||
-		(epoch_cnt[core_idx1] - epoch_cnt[core_idx0] > 1)) {
+	if ((event_cnt[core_idx0] &&
+		(event_cnt[core_idx0] - event_cnt[core_idx1] > 1)) ||
+		(event_cnt[core_idx1] &&
+		(event_cnt[core_idx1] - event_cnt[core_idx0] > 1))) {
 
 		CAM_WARN(CAM_ISP,
-			"One of the VFE of dual VFE cound not generate error");
+			"One of the VFE cound not generate hw event %d",
+			hw_event_type);
 		rc = -1;
 		return rc;
 	}
 
-	CAM_DBG(CAM_ISP, "Only one core_index has given EPOCH");
+	CAM_DBG(CAM_ISP, "Only one core_index has given hw event %d",
+			hw_event_type);
 
 	return rc;
 }
@@ -2548,6 +2637,8 @@
 
 				if (!epoch_status)
 					ife_hwr_mgr_ctx->epoch_cnt[core_idx]++;
+				else
+					break;
 			}
 
 			/* SOF check for Right side VFE */
@@ -2557,15 +2648,18 @@
 
 				if (!epoch_status)
 					ife_hwr_mgr_ctx->epoch_cnt[core_idx]++;
+				else
+					break;
 			}
 
 			core_index0 = hw_res_l->hw_intf->hw_idx;
 			core_index1 = hw_res_r->hw_intf->hw_idx;
 
-			rc = cam_ife_hw_mgr_check_epoch_for_dual_vfe(
+			rc = cam_ife_hw_mgr_check_irq_for_dual_vfe(
 					ife_hwr_mgr_ctx,
 					core_index0,
-					core_index1);
+					core_index1,
+					evt_payload->evt_id);
 
 			if (!rc)
 				ife_hwr_irq_epoch_cb(
@@ -2588,37 +2682,6 @@
 	return 0;
 }
 
-static int cam_ife_hw_mgr_check_sof_for_dual_vfe(
-	struct cam_ife_hw_mgr_ctx   *ife_hwr_mgr_ctx,
-	uint32_t                     core_idx0,
-	uint32_t                     core_idx1)
-{
-	uint32_t *sof_cnt = ife_hwr_mgr_ctx->sof_cnt;
-	int32_t rc = -1;
-
-	if (sof_cnt[core_idx0] ==
-			sof_cnt[core_idx1]) {
-
-		sof_cnt[core_idx0] = 0;
-		sof_cnt[core_idx1] = 0;
-
-		rc = 0;
-		return rc;
-	}
-
-	if ((sof_cnt[core_idx0] - sof_cnt[core_idx1] > 1) ||
-		(sof_cnt[core_idx1] - sof_cnt[core_idx0] > 1)) {
-
-		CAM_ERR(CAM_ISP, "One VFE of dual VFE cound not generate SOF");
-		rc = -1;
-		return rc;
-	}
-
-	CAM_INFO(CAM_ISP, "Only one core_index has given SOF");
-
-	return rc;
-}
-
 static int cam_ife_hw_mgr_process_camif_sof(
 	struct cam_ife_hw_mgr_res            *isp_ife_camif_res,
 	struct cam_ife_hw_mgr_ctx            *ife_hwr_mgr_ctx,
@@ -2689,6 +2752,8 @@
 				hw_res_l, evt_payload);
 			if (!sof_status)
 				ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
+			else
+				break;
 		}
 
 		/* SOF check for Right side VFE */
@@ -2704,13 +2769,15 @@
 				evt_payload);
 			if (!sof_status)
 				ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
+			else
+				break;
 		}
 
 		core_index0 = hw_res_l->hw_intf->hw_idx;
 		core_index1 = hw_res_r->hw_intf->hw_idx;
 
-		rc = cam_ife_hw_mgr_check_sof_for_dual_vfe(ife_hwr_mgr_ctx,
-			core_index0, core_index1);
+		rc = cam_ife_hw_mgr_check_irq_for_dual_vfe(ife_hwr_mgr_ctx,
+			core_index0, core_index1, evt_payload->evt_id);
 
 		if (!rc)
 			ife_hwr_irq_sof_cb(ife_hwr_mgr_ctx->common.cb_priv,
@@ -2723,7 +2790,7 @@
 		break;
 	}
 
-	CAM_DBG(CAM_ISP, "Exit (sof_status = %d)!", sof_status);
+	CAM_DBG(CAM_ISP, "Exit (sof_status = %d)", sof_status);
 
 	return 0;
 }
@@ -2780,10 +2847,10 @@
 						ife_hw_mgr_ctx->common.cb_priv,
 						CAM_ISP_HW_EVENT_SOF,
 						&sof_done_event_data);
+					CAM_DBG(CAM_ISP, "sof_status = %d",
+						sof_status);
 				}
 
-				CAM_DBG(CAM_ISP, "sof_status = %d", sof_status);
-
 				/* this is RDI only context so exit from here */
 				return 0;
 			}
@@ -2803,6 +2870,128 @@
 	return 0;
 }
 
+static int cam_ife_hw_mgr_handle_eof_for_camif_hw_res(
+	void                              *handler_priv,
+	void                              *payload)
+{
+	int32_t rc = -EINVAL;
+	struct cam_isp_resource_node         *hw_res_l = NULL;
+	struct cam_isp_resource_node         *hw_res_r = NULL;
+	struct cam_ife_hw_mgr_ctx            *ife_hwr_mgr_ctx;
+	struct cam_vfe_top_irq_evt_payload   *evt_payload;
+	struct cam_ife_hw_mgr_res            *isp_ife_camif_res = NULL;
+	cam_hw_event_cb_func                  ife_hwr_irq_eof_cb;
+	struct cam_isp_hw_eof_event_data      eof_done_event_data;
+	uint32_t  core_idx;
+	uint32_t  eof_status = 0;
+	uint32_t  core_index0;
+	uint32_t  core_index1;
+
+	CAM_DBG(CAM_ISP, "Enter");
+
+	ife_hwr_mgr_ctx = handler_priv;
+	evt_payload = payload;
+	if (!evt_payload) {
+		pr_err("%s: no payload\n", __func__);
+		return IRQ_HANDLED;
+	}
+	core_idx = evt_payload->core_index;
+	ife_hwr_irq_eof_cb =
+		ife_hwr_mgr_ctx->common.event_cb[CAM_ISP_HW_EVENT_EOF];
+
+	evt_payload->evt_id = CAM_ISP_HW_EVENT_EOF;
+
+	list_for_each_entry(isp_ife_camif_res,
+		&ife_hwr_mgr_ctx->res_list_ife_src, list) {
+
+		if ((isp_ife_camif_res->res_type ==
+			CAM_IFE_HW_MGR_RES_UNINIT) ||
+			(isp_ife_camif_res->res_id != CAM_ISP_HW_VFE_IN_CAMIF))
+			continue;
+
+		hw_res_l = isp_ife_camif_res->hw_res[0];
+		hw_res_r = isp_ife_camif_res->hw_res[1];
+
+		CAM_DBG(CAM_ISP, "is_dual_vfe ? = %d",
+				isp_ife_camif_res->is_dual_vfe);
+		switch (isp_ife_camif_res->is_dual_vfe) {
+		/* Handling Single VFE Scenario */
+		case 0:
+			/* EOF check for Left side VFE */
+			if (!hw_res_l) {
+				pr_err("%s: VFE Device is NULL\n",
+					__func__);
+				break;
+			}
+			CAM_DBG(CAM_ISP, "curr_core_idx = %d, core idx hw = %d",
+					core_idx, hw_res_l->hw_intf->hw_idx);
+
+			if (core_idx == hw_res_l->hw_intf->hw_idx) {
+				eof_status = hw_res_l->bottom_half_handler(
+					hw_res_l, evt_payload);
+				if (!eof_status)
+					ife_hwr_irq_eof_cb(
+						ife_hwr_mgr_ctx->common.cb_priv,
+						CAM_ISP_HW_EVENT_EOF,
+						&eof_done_event_data);
+			}
+
+			break;
+		/* Handling dual VFE Scenario */
+		case 1:
+			if ((!hw_res_l) || (!hw_res_r)) {
+				CAM_ERR(CAM_ISP, "Dual VFE Device is NULL");
+				break;
+			}
+			if (core_idx == hw_res_l->hw_intf->hw_idx) {
+				eof_status = hw_res_l->bottom_half_handler(
+					hw_res_l, evt_payload);
+
+				if (!eof_status)
+					ife_hwr_mgr_ctx->eof_cnt[core_idx]++;
+				else
+					break;
+			}
+
+			/* EOF check for Right side VFE */
+			if (core_idx == hw_res_r->hw_intf->hw_idx) {
+				eof_status = hw_res_r->bottom_half_handler(
+					hw_res_r, evt_payload);
+
+				if (!eof_status)
+					ife_hwr_mgr_ctx->eof_cnt[core_idx]++;
+				else
+					break;
+			}
+
+			core_index0 = hw_res_l->hw_intf->hw_idx;
+			core_index1 = hw_res_r->hw_intf->hw_idx;
+
+			rc = cam_ife_hw_mgr_check_irq_for_dual_vfe(
+					ife_hwr_mgr_ctx,
+					core_index0,
+					core_index1,
+					evt_payload->evt_id);
+
+			if (!rc)
+				ife_hwr_irq_eof_cb(
+					ife_hwr_mgr_ctx->common.cb_priv,
+					CAM_ISP_HW_EVENT_EOF,
+					&eof_done_event_data);
+
+			break;
+
+		default:
+			CAM_ERR(CAM_ISP, "error with hw_res");
+		}
+	}
+
+	CAM_DBG(CAM_ISP, "Exit (eof_status = %d)", eof_status);
+
+	return 0;
+}
+
+
 static int cam_ife_hw_mgr_handle_buf_done_for_hw_res(
 	void                              *handler_priv,
 	void                              *payload)
@@ -2847,6 +3036,8 @@
 			hw_res_l->hw_intf->hw_idx))
 			buf_done_status = hw_res_l->bottom_half_handler(
 				hw_res_l, evt_payload);
+		else
+			continue;
 
 		switch (buf_done_status) {
 		case CAM_VFE_IRQ_STATUS_ERR_COMP:
@@ -2928,7 +3119,7 @@
 	 * for the first phase, we are going to reset entire HW.
 	 */
 
-	CAM_DBG(CAM_ISP, "Exit (buf_done_status (Error) = %d)!",
+	CAM_DBG(CAM_ISP, "Exit buf_done_status Error = %d",
 		buf_done_status);
 	return rc;
 }
@@ -2946,7 +3137,8 @@
 	evt_payload = evt_payload_priv;
 	ife_hwr_mgr_ctx = (struct cam_ife_hw_mgr_ctx *)evt_payload->ctx;
 
-	CAM_DBG(CAM_ISP, "addr of evt_payload = %llx", (uint64_t)evt_payload);
+	CAM_DBG(CAM_ISP, "addr of evt_payload = %llx core index:0x%x",
+		(uint64_t)evt_payload, evt_payload->core_index);
 	CAM_DBG(CAM_ISP, "bus_irq_status_0: = %x", evt_payload->irq_reg_val[0]);
 	CAM_DBG(CAM_ISP, "bus_irq_status_1: = %x", evt_payload->irq_reg_val[1]);
 	CAM_DBG(CAM_ISP, "bus_irq_status_2: = %x", evt_payload->irq_reg_val[2]);
@@ -2976,7 +3168,9 @@
 	evt_payload = evt_payload_priv;
 	ife_hwr_mgr_ctx = (struct cam_ife_hw_mgr_ctx *)handler_priv;
 
-	CAM_DBG(CAM_ISP, "addr of evt_payload = %llx", (uint64_t)evt_payload);
+	CAM_DBG(CAM_ISP, "addr of evt_payload = %pK core_index:%d",
+		(void *)evt_payload,
+		evt_payload->core_index);
 	CAM_DBG(CAM_ISP, "irq_status_0: = %x", evt_payload->irq_reg_val[0]);
 	CAM_DBG(CAM_ISP, "irq_status_1: = %x", evt_payload->irq_reg_val[1]);
 	CAM_DBG(CAM_ISP, "Violation register: = %x",
@@ -3009,6 +3203,8 @@
 	/* EPOCH IRQ */
 	cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(ife_hwr_mgr_ctx,
 		evt_payload_priv);
+	cam_ife_hw_mgr_handle_eof_for_camif_hw_res(ife_hwr_mgr_ctx,
+		evt_payload_priv);
 
 	return IRQ_HANDLED;
 }
@@ -3045,6 +3241,51 @@
 	return 0;
 }
 
+static int cam_ife_set_csid_debug(void *data, u64 val)
+{
+	g_ife_hw_mgr.debug_cfg.csid_debug = val;
+	CAM_DBG(CAM_ISP, "Set CSID Debug value :%lld", val);
+	return 0;
+}
+
+static int cam_ife_get_csid_debug(void *data, u64 *val)
+{
+	*val = g_ife_hw_mgr.debug_cfg.csid_debug;
+	CAM_DBG(CAM_ISP, "Get CSID Debug value :%lld",
+		g_ife_hw_mgr.debug_cfg.csid_debug);
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(cam_ife_csid_debug,
+	cam_ife_get_csid_debug,
+	cam_ife_set_csid_debug, "%16llu");
+
+static int cam_ife_hw_mgr_debug_register(void)
+{
+	g_ife_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_ife",
+		NULL);
+
+	if (!g_ife_hw_mgr.debug_cfg.dentry) {
+		CAM_ERR(CAM_ISP, "failed to create dentry");
+		return -ENOMEM;
+	}
+
+	if (!debugfs_create_file("ife_csid_debug",
+		0644,
+		g_ife_hw_mgr.debug_cfg.dentry, NULL,
+		&cam_ife_csid_debug)) {
+		CAM_ERR(CAM_ISP, "failed to create cam_ife_csid_debug");
+		goto err;
+	}
+
+	return 0;
+
+err:
+	debugfs_remove_recursive(g_ife_hw_mgr.debug_cfg.dentry);
+	return -ENOMEM;
+}
+
 int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
 {
 	int rc = -EFAULT;
@@ -3058,8 +3299,8 @@
 	mutex_init(&g_ife_hw_mgr.ctx_mutex);
 
 	if (CAM_IFE_HW_NUM_MAX != CAM_IFE_CSID_HW_NUM_MAX) {
-		CAM_ERR(CAM_ISP, "Fatal, CSID num is different then IFE num!");
-		goto end;
+		CAM_ERR(CAM_ISP, "CSID num is different then IFE num");
+		return -EINVAL;
 	}
 
 	/* fill ife hw intf information */
@@ -3083,8 +3324,8 @@
 		}
 	}
 	if (j == 0) {
-		CAM_ERR(CAM_ISP, "no valid IFE HW!");
-		goto end;
+		CAM_ERR(CAM_ISP, "no valid IFE HW");
+		return -EINVAL;
 	}
 
 	/* fill csid hw intf information */
@@ -3094,8 +3335,8 @@
 			j++;
 	}
 	if (!j) {
-		CAM_ERR(CAM_ISP, "no valid IFE CSID HW!");
-		goto end;
+		CAM_ERR(CAM_ISP, "no valid IFE CSID HW");
+		return -EINVAL;
 	}
 
 	cam_ife_hw_mgr_sort_dev_with_caps(&g_ife_hw_mgr);
@@ -3113,19 +3354,25 @@
 	 */
 	if (cam_smmu_get_handle("ife",
 		&g_ife_hw_mgr.mgr_common.img_iommu_hdl)) {
-		CAM_ERR(CAM_ISP, "Can not get iommu handle.");
-		goto end;
+		CAM_ERR(CAM_ISP, "Can not get iommu handle");
+		return -EINVAL;
 	}
 
 	if (cam_smmu_ops(g_ife_hw_mgr.mgr_common.img_iommu_hdl,
 		CAM_SMMU_ATTACH)) {
 		CAM_ERR(CAM_ISP, "Attach iommu handle failed.");
-		goto end;
+		goto attach_fail;
 	}
 
-	CAM_DBG(CAM_ISP, "got iommu_handle=%d",
-		g_ife_hw_mgr.mgr_common.img_iommu_hdl);
-	g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure = -1;
+	if (cam_smmu_get_handle("cam-secure",
+		&g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure)) {
+		CAM_ERR(CAM_ISP, "Failed to get secure iommu handle");
+		goto secure_fail;
+	}
+
+	CAM_DBG(CAM_ISP, "iommu_handles: non-secure[0x%x], secure[0x%x]",
+		g_ife_hw_mgr.mgr_common.img_iommu_hdl,
+		g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure);
 
 	if (!cam_cdm_get_iommu_handle("ife", &cdm_handles)) {
 		CAM_DBG(CAM_ISP, "Successfully acquired the CDM iommu handles");
@@ -3187,7 +3434,6 @@
 	/* Create Worker for ife_hw_mgr with 10 tasks */
 	rc = cam_req_mgr_workq_create("cam_ife_worker", 10,
 			&g_ife_hw_mgr.workq, CRM_WORKQ_USAGE_NON_IRQ);
-
 	if (rc < 0) {
 		CAM_ERR(CAM_ISP, "Unable to create worker");
 		goto end;
@@ -3206,13 +3452,29 @@
 	hw_mgr_intf->hw_config = cam_ife_mgr_config_hw;
 	hw_mgr_intf->hw_cmd = cam_ife_mgr_cmd;
 
+	cam_ife_hw_mgr_debug_register();
 	CAM_DBG(CAM_ISP, "Exit");
+
 	return 0;
 end:
 	if (rc) {
-		for (i = 0; i < CAM_CTX_MAX; i++)
+		for (i = 0; i < CAM_CTX_MAX; i++) {
+			cam_tasklet_deinit(
+				&g_ife_hw_mgr.mgr_common.tasklet_pool[i]);
 			kfree(g_ife_hw_mgr.ctx_pool[i].cdm_cmd);
+			g_ife_hw_mgr.ctx_pool[i].cdm_cmd = NULL;
+			g_ife_hw_mgr.ctx_pool[i].common.tasklet_info = NULL;
+		}
 	}
+	cam_smmu_destroy_handle(
+		g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure);
+	g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure = -1;
+secure_fail:
+	cam_smmu_ops(g_ife_hw_mgr.mgr_common.img_iommu_hdl,
+		CAM_SMMU_DETACH);
+attach_fail:
+	cam_smmu_destroy_handle(g_ife_hw_mgr.mgr_common.img_iommu_hdl);
+	g_ife_hw_mgr.mgr_common.img_iommu_hdl = -1;
 	return rc;
 }
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
index 6dfdb21..2e66210 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
@@ -81,6 +81,18 @@
 };
 
 /**
+ * struct cam_ife_hw_mgr_debug - contain the debug information
+ *
+ * @dentry:              Debugfs entry
+ * @csid_debug:          csid debug information
+ *
+ */
+struct cam_ife_hw_mgr_debug {
+	struct dentry                  *dentry;
+	uint64_t                        csid_debug;
+};
+
+/**
  * struct cam_vfe_hw_mgr_ctx - IFE HW manager Context object
  *
  * @list:                   used by the ctx list.
@@ -106,6 +118,7 @@
  * @cdm_cmd                 cdm base and length request pointer
  * @sof_cnt                 sof count value per core, used for dual VFE
  * @epoch_cnt               epoch count value per core, used for dual VFE
+ * @eof_cnt                 eof count value per core, used for dual VFE
  * @overflow_pending        flat to specify the overflow is pending for the
  *                          context
  * @is_rdi_only_context     flag to specify the context has only rdi resource
@@ -138,9 +151,9 @@
 
 	uint32_t                        sof_cnt[CAM_IFE_HW_NUM_MAX];
 	uint32_t                        epoch_cnt[CAM_IFE_HW_NUM_MAX];
+	uint32_t                        eof_cnt[CAM_IFE_HW_NUM_MAX];
 	atomic_t                        overflow_pending;
 	uint32_t                        is_rdi_only_context;
-
 };
 
 /**
@@ -174,6 +187,7 @@
 						CAM_IFE_CSID_HW_NUM_MAX];
 	struct cam_vfe_hw_get_hw_cap   ife_dev_caps[CAM_IFE_HW_NUM_MAX];
 	struct cam_req_mgr_core_workq  *workq;
+	struct cam_ife_hw_mgr_debug     debug_cfg;
 };
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
index 0a0eecb..5f68f21 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
@@ -82,10 +82,66 @@
 	return rc;
 }
 
+static int cam_isp_update_dual_config(
+	struct cam_hw_prepare_update_args  *prepare,
+	struct cam_cmd_buf_desc            *cmd_desc,
+	uint32_t                            split_id,
+	uint32_t                            base_idx,
+	struct cam_ife_hw_mgr_res          *res_list_isp_out,
+	uint32_t                            size_isp_out)
+{
+	int rc = -EINVAL;
+	struct cam_isp_dual_config                 *dual_config;
+	struct cam_ife_hw_mgr_res                  *hw_mgr_res;
+	struct cam_isp_resource_node               *res;
+	struct cam_isp_hw_dual_isp_update_args      dual_isp_update_args;
+	size_t                                      len = 0;
+	uint32_t                                   *cpu_addr;
+	uint32_t                                    i, j;
+
+	CAM_DBG(CAM_UTIL, "cmd des size %d, length: %d",
+		cmd_desc->size, cmd_desc->length);
+
+	rc = cam_packet_util_get_cmd_mem_addr(
+		cmd_desc->mem_handle, &cpu_addr, &len);
+	if (rc)
+		return rc;
+
+	cpu_addr += (cmd_desc->offset / 4);
+	dual_config = (struct cam_isp_dual_config *)cpu_addr;
+
+	for (i = 0; i < dual_config->num_ports; i++) {
+		hw_mgr_res = &res_list_isp_out[i];
+		for (j = 0; j < CAM_ISP_HW_SPLIT_MAX; j++) {
+			if (!hw_mgr_res->hw_res[j])
+				continue;
+
+			if (hw_mgr_res->hw_res[j]->hw_intf->hw_idx != base_idx)
+				continue;
+
+			res = hw_mgr_res->hw_res[j];
+			dual_isp_update_args.split_id = j;
+			dual_isp_update_args.res      = res;
+			dual_isp_update_args.dual_cfg = dual_config;
+			rc = res->hw_intf->hw_ops.process_cmd(
+				res->hw_intf->hw_priv,
+				CAM_VFE_HW_CMD_STRIPE_UPDATE,
+				&dual_isp_update_args,
+				sizeof(struct cam_isp_hw_dual_isp_update_args));
+			if (rc)
+				return rc;
+		}
+	}
+
+	return rc;
+}
 
 int cam_isp_add_command_buffers(
 	struct cam_hw_prepare_update_args  *prepare,
-	uint32_t                            split_id)
+	enum cam_isp_hw_split_id            split_id,
+	uint32_t                            base_idx,
+	struct cam_ife_hw_mgr_res          *res_list_isp_out,
+	uint32_t                            size_isp_out)
 {
 	int rc = 0;
 	uint32_t  cmd_meta_data, num_ent, i;
@@ -168,6 +224,16 @@
 
 			num_ent++;
 			break;
+		case CAM_ISP_PACKET_META_DUAL_CONFIG:
+			rc = cam_isp_update_dual_config(prepare,
+				&cmd_desc[i], split_id, base_idx,
+				res_list_isp_out, size_isp_out);
+
+			if (rc)
+				return rc;
+			break;
+		case CAM_ISP_PACKET_META_GENERIC_BLOB:
+			break;
 		default:
 			CAM_ERR(CAM_ISP, "invalid cdm command meta data %d",
 				cmd_meta_data);
@@ -180,9 +246,233 @@
 	return rc;
 }
 
+static int cam_isp_handle_hfr_config(
+	struct cam_isp_generic_blob_info *blob_info,
+	struct cam_isp_resource_hfr_config *hfr_config, uint32_t blob_size)
+{
+	uint32_t cal_blob_size =
+		sizeof(struct cam_isp_resource_hfr_config) +
+		(sizeof(struct cam_isp_port_hfr_config) *
+		(hfr_config->num_io_configs - 1));
+
+	if (cal_blob_size != blob_size) {
+		CAM_ERR(CAM_ISP, "Invalid blob size %d %d",
+			cal_blob_size, blob_size);
+		return -EINVAL;
+	}
+
+	CAM_DBG(CAM_ISP, "HFR num_io_config = %d", hfr_config->num_io_configs);
+
+	if (blob_info->hfr_config) {
+		CAM_WARN(CAM_ISP,
+			"Ignoring previous hfr_config, prev=%d, curr=%d",
+			blob_info->hfr_config->num_io_configs,
+			hfr_config->num_io_configs);
+		kfree(blob_info->hfr_config);
+	}
+
+	blob_info->hfr_config = kzalloc(blob_size, GFP_ATOMIC);
+	if (!blob_info->hfr_config)
+		return -ENOMEM;
+
+	memcpy(blob_info->hfr_config, hfr_config, blob_size);
+
+	return 0;
+}
+
+static int cam_isp_packet_generic_blob_handler(void *user_data,
+	uint32_t blob_type, uint32_t blob_size, uint8_t *blob_data)
+{
+	int rc = 0;
+
+	if (!blob_data || (blob_size == 0)) {
+		CAM_ERR(CAM_ISP, "Invalid blob info %pK %d", blob_data,
+			blob_size);
+		return -EINVAL;
+	}
+
+	switch (blob_type) {
+	case CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG:
+		rc = cam_isp_handle_hfr_config(user_data,
+			(struct cam_isp_resource_hfr_config *)blob_data,
+			blob_size);
+		if (rc)
+			CAM_ERR(CAM_ISP, "Failed in handling hfr config %d",
+				rc);
+
+		break;
+	default:
+		CAM_WARN(CAM_ISP, "Invalid blob type %d", blob_type);
+		break;
+	}
+
+	return rc;
+}
+
+int cam_isp_process_generic_cmd_buffer(
+	struct cam_hw_prepare_update_args *prepare,
+	struct cam_isp_generic_blob_info  *blob_info)
+{
+	int i, rc = 0;
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+
+	/*
+	 * set the cmd_desc to point the first command descriptor in the
+	 * packet
+	 */
+	cmd_desc = (struct cam_cmd_buf_desc *)
+			((uint8_t *)&prepare->packet->payload +
+			prepare->packet->cmd_buf_offset);
+
+	for (i = 0; i < prepare->packet->num_cmd_buf; i++) {
+		if (!cmd_desc[i].length)
+			continue;
+
+		if (cmd_desc[i].meta_data != CAM_ISP_PACKET_META_GENERIC_BLOB)
+			continue;
+
+		rc = cam_packet_util_validate_cmd_desc(&cmd_desc[i]);
+		if (rc)
+			return rc;
+
+		rc = cam_packet_util_process_generic_cmd_buffer(&cmd_desc[i],
+			cam_isp_packet_generic_blob_handler, blob_info);
+		if (rc)
+			CAM_ERR(CAM_ISP, "Failed in processing blobs %d", rc);
+
+		break;
+	}
+
+	return rc;
+}
+
+int cam_isp_add_hfr_config_hw_update(
+	struct cam_isp_resource_hfr_config   *hfr_config,
+	struct cam_hw_prepare_update_args    *prepare,
+	uint32_t                              base_idx,
+	struct cam_kmd_buf_info              *kmd_buf_info,
+	struct cam_ife_hw_mgr_res            *res_list_isp_out,
+	uint32_t                              size_isp_out)
+{
+	int rc = 0;
+	struct cam_isp_resource_node       *res;
+	struct cam_ife_hw_mgr_res          *hw_mgr_res;
+	struct cam_isp_hw_get_hfr_update    update_hfr;
+	struct cam_isp_port_hfr_config     *io_hfr_config;
+	uint32_t                            kmd_buf_remain_size;
+	uint32_t                            i, j;
+	uint32_t                            res_id_out;
+	uint32_t                            hfr_cfg_used_bytes, num_ent;
+
+	hfr_cfg_used_bytes = 0;
+
+	/* Max one hw entries required for hfr config update */
+	if (prepare->num_hw_update_entries + 1 >=
+			prepare->max_hw_update_entries) {
+		CAM_ERR(CAM_ISP, "Insufficient  HW entries :%d %d",
+			prepare->num_hw_update_entries,
+			prepare->max_hw_update_entries);
+		return -EINVAL;
+	}
+
+	CAM_DBG(CAM_ISP, "num_io_configs= %d", hfr_config->num_io_configs);
+
+	for (i = 0; i < hfr_config->num_io_configs; i++) {
+		io_hfr_config = &hfr_config->io_hfr_config[i];
+		res_id_out = io_hfr_config->resource_type & 0xFF;
+
+		CAM_DBG(CAM_ISP, "hfr config idx %d, type=%d", i, res_id_out);
+
+		if (res_id_out >= size_isp_out) {
+			CAM_ERR(CAM_ISP, "invalid out restype:%x",
+				io_hfr_config->resource_type);
+			return -EINVAL;
+		}
+
+		hw_mgr_res = &res_list_isp_out[res_id_out];
+		if (hw_mgr_res->res_type == CAM_IFE_HW_MGR_RES_UNINIT) {
+			CAM_ERR(CAM_ISP, "io res id:%d not valid",
+				io_hfr_config->resource_type);
+			return -EINVAL;
+		}
+
+		for (j = 0; j < CAM_ISP_HW_SPLIT_MAX; j++) {
+			if (!hw_mgr_res->hw_res[j])
+				continue;
+
+			if (hw_mgr_res->hw_res[j]->hw_intf->hw_idx != base_idx)
+				continue;
+
+			res = hw_mgr_res->hw_res[j];
+			if (res->res_id !=
+				io_hfr_config->resource_type) {
+				CAM_ERR(CAM_ISP,
+					"wm err res id:%d io res id:%d",
+					res->res_id,
+					io_hfr_config->resource_type);
+				return -EINVAL;
+			}
+
+			if ((kmd_buf_info->used_bytes + hfr_cfg_used_bytes) <
+				kmd_buf_info->size) {
+				kmd_buf_remain_size = kmd_buf_info->size -
+					(kmd_buf_info->used_bytes +
+					hfr_cfg_used_bytes);
+			} else {
+				CAM_ERR(CAM_ISP,
+					"no free kmd memory for base %d",
+					base_idx);
+				rc = -ENOMEM;
+				return rc;
+			}
+
+			update_hfr.cdm.res = res;
+			update_hfr.cdm.cmd_buf_addr = kmd_buf_info->cpu_addr +
+				kmd_buf_info->used_bytes/4 +
+					hfr_cfg_used_bytes/4;
+			update_hfr.cdm.size = kmd_buf_remain_size;
+			update_hfr.io_hfr_cfg    = io_hfr_config;
+
+			CAM_DBG(CAM_ISP, "cmd buffer 0x%pK, size %d",
+				update_hfr.cdm.cmd_buf_addr,
+				update_hfr.cdm.size);
+			rc = res->hw_intf->hw_ops.process_cmd(
+				res->hw_intf->hw_priv,
+				CAM_VFE_HW_CMD_GET_HFR_UPDATE, &update_hfr,
+				sizeof(struct cam_isp_hw_get_hfr_update));
+
+			if (rc) {
+				CAM_ERR(CAM_ISP, "get buf cmd error:%d",
+					res->res_id);
+				rc = -ENOMEM;
+				return rc;
+			}
+			hfr_cfg_used_bytes += update_hfr.cdm.used_bytes;
+		}
+	}
+
+	CAM_DBG(CAM_ISP, "hfr_cfg_used_bytes %d", hfr_cfg_used_bytes);
+	if (hfr_cfg_used_bytes) {
+		/* Update the HW entries */
+		num_ent = prepare->num_hw_update_entries;
+		prepare->hw_update_entries[num_ent].handle =
+					kmd_buf_info->handle;
+		prepare->hw_update_entries[num_ent].len = hfr_cfg_used_bytes;
+		prepare->hw_update_entries[num_ent].offset =
+			kmd_buf_info->offset;
+		num_ent++;
+
+		kmd_buf_info->used_bytes += hfr_cfg_used_bytes;
+		kmd_buf_info->offset     += hfr_cfg_used_bytes;
+		prepare->num_hw_update_entries = num_ent;
+	}
+
+	return rc;
+}
 
 int cam_isp_add_io_buffers(
 	int                                   iommu_hdl,
+	int                                   sec_iommu_hdl,
 	struct cam_hw_prepare_update_args    *prepare,
 	uint32_t                              base_idx,
 	struct cam_kmd_buf_info              *kmd_buf_info,
@@ -200,7 +490,10 @@
 	uint32_t                            i, j, num_out_buf, num_in_buf;
 	uint32_t                            res_id_out, res_id_in, plane_id;
 	uint32_t                            io_cfg_used_bytes, num_ent;
-	size_t size;
+	size_t                              size;
+	int32_t                             hdl;
+	int                                 mmu_hdl;
+	bool                                mode, is_buf_secure;
 
 	io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *)
 			&prepare->packet->payload +
@@ -311,9 +604,31 @@
 				if (!io_cfg[i].mem_handle[plane_id])
 					break;
 
+				hdl = io_cfg[i].mem_handle[plane_id];
+				if (res->process_cmd(res,
+						CAM_VFE_HW_CMD_GET_SECURE_MODE,
+						&mode,
+						sizeof(bool)))
+					return -EINVAL;
+
+				is_buf_secure = cam_mem_is_secure_buf(hdl);
+				if ((mode == CAM_SECURE_MODE_SECURE) &&
+					is_buf_secure) {
+					mmu_hdl = sec_iommu_hdl;
+				} else if (
+					(mode == CAM_SECURE_MODE_NON_SECURE) &&
+					(!is_buf_secure)) {
+					mmu_hdl = iommu_hdl;
+				} else {
+					CAM_ERR_RATE_LIMIT(CAM_ISP,
+						"Invalid hdl: port mode[%u], buf mode[%u]",
+						mode, is_buf_secure);
+					return -EINVAL;
+				}
+
 				rc = cam_mem_get_io_buf(
 					io_cfg[i].mem_handle[plane_id],
-					iommu_hdl, &io_addr[plane_id], &size);
+					mmu_hdl, &io_addr[plane_id], &size);
 				if (rc) {
 					CAM_ERR(CAM_ISP,
 						"no io addr for plane%d",
@@ -471,6 +786,8 @@
 			if (rc)
 				return rc;
 
+			CAM_DBG(CAM_ISP, "Reg update added for res %d hw_id %d",
+				res->res_id, res->hw_intf->hw_idx);
 			reg_update_size += get_regup.used_bytes;
 		}
 	}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
index 7ac729f..cce0071 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
@@ -21,6 +21,16 @@
 #include "cam_packet_util.h"
 
 /**
+ * struct cam_isp_generic_blob_info  Generic blob information
+ *
+ * @hfr_config             Initial configuration required to enable HFR
+ *
+ */
+struct cam_isp_generic_blob_info {
+	struct cam_isp_resource_hfr_config *hfr_config;
+};
+
+/**
  * @brief                  Add change base in the hw entries list
  *                         processe the isp source list get the change base from
  *                         ISP HW instance
@@ -44,14 +54,19 @@
  *                         left or right VFE/IFE instance.
  *
  * @prepare:               Contain the  packet and HW update variables
- * @dual_type:             Left of right command buffers to be extracted
- *
+ * @split_id:              Left or right command buffers to be extracted
+ * @base_idx:              Base or dev index of the IFE/VFE HW instance
+ * @res_list_isp_out:      IFE /VFE out resource list
+ * @size_isp_out:          Size of the res_list_isp_out array
  * @return:                0 for success
  *                         -EINVAL for Fail
  */
 int cam_isp_add_command_buffers(
-	struct cam_hw_prepare_update_args    *prepare,
-	enum cam_isp_hw_split_id              split_id);
+	struct cam_hw_prepare_update_args  *prepare,
+	enum cam_isp_hw_split_id            split_id,
+	uint32_t                            base_idx,
+	struct cam_ife_hw_mgr_res          *res_list_isp_out,
+	uint32_t                            size_isp_out);
 
 /**
  * @brief                  Add io buffer configurations in the HW entries list
@@ -59,6 +74,8 @@
  *                         index and update the HW entries list
  *
  * @iommu_hdl:             Iommu handle to get the IO buf from memory manager
+ * @sec_iommu_hdl:         Secure iommu handle to get the IO buf from
+ *                         memory manager
  * @prepare:               Contain the  packet and HW update variables
  * @base_idx:              Base or dev index of the IFE/VFE HW instance
  * @kmd_buf_info:          Kmd buffer to store the change base command
@@ -69,7 +86,9 @@
  * @return:                0 for success
  *                         -EINVAL for Fail
  */
-int cam_isp_add_io_buffers(int	 iommu_hdl,
+int cam_isp_add_io_buffers(
+	int                                   iommu_hdl,
+	int                                   sec_iommu_hdl,
 	struct cam_hw_prepare_update_args    *prepare,
 	uint32_t                              base_idx,
 	struct cam_kmd_buf_info              *kmd_buf_info,
@@ -96,5 +115,40 @@
 	uint32_t                              base_idx,
 	struct cam_kmd_buf_info              *kmd_buf_info);
 
+/**
+ * @brief                  Add HFR configurations in the HW entries list
+ *                         processe the hfr configurations based on the base
+ *                         index and update the HW entries list
+ *
+ * @hfr_config:            HFR resource configuration info
+ * @prepare:               Contain the  packet and HW update variables
+ * @base_idx:              Base or dev index of the IFE/VFE HW instance
+ * @kmd_buf_info:          Kmd buffer to store the change base command
+ * @res_list_isp_out:      IFE /VFE out resource list
+ * @size_isp_out:          Size of the res_list_isp_out array
+ *
+ * @return:                0 for success
+ *                         -EINVAL for Fail
+ */
+int cam_isp_add_hfr_config_hw_update(
+	struct cam_isp_resource_hfr_config   *hfr_config,
+	struct cam_hw_prepare_update_args    *prepare,
+	uint32_t                              base_idx,
+	struct cam_kmd_buf_info              *kmd_buf_info,
+	struct cam_ife_hw_mgr_res            *res_list_isp_out,
+	uint32_t                              size_isp_out);
+
+/**
+ * @brief                  Processing Generic command buffer.
+ *
+ * @prepare:               Contain the  packet and HW update variables
+ * @blob_info:             Information from generic blob command buffer
+ *
+ * @return:                0 for success
+ *                         -EINVAL for Fail
+ */
+int cam_isp_process_generic_cmd_buffer(
+	struct cam_hw_prepare_update_args *prepare,
+	struct cam_isp_generic_blob_info  *blob_info);
 
 #endif /*_CAM_ISP_HW_PARSER_H */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
index 2341b38..dcbea8d 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
@@ -329,6 +329,111 @@
 	return rc;
 }
 
+int cam_irq_controller_enable_irq(void *irq_controller, uint32_t handle)
+{
+	struct cam_irq_controller  *controller  = irq_controller;
+	struct cam_irq_evt_handler *evt_handler = NULL;
+	struct cam_irq_evt_handler *evt_handler_temp;
+	unsigned long               flags;
+	unsigned int                i;
+	uint32_t                    irq_mask;
+	uint32_t                    found = 0;
+	int                         rc = -EINVAL;
+
+	if (!controller)
+		return rc;
+
+	list_for_each_entry_safe(evt_handler, evt_handler_temp,
+		&controller->evt_handler_list_head, list_node) {
+		if (evt_handler->index == handle) {
+			CAM_DBG(CAM_ISP, "enable item %d", handle);
+			found = 1;
+			rc = 0;
+			break;
+		}
+	}
+
+	if (!found)
+		return rc;
+
+	write_lock_irqsave(&controller->rw_lock, flags);
+	for (i = 0; i < controller->num_registers; i++) {
+		controller->irq_register_arr[i].
+		top_half_enable_mask[evt_handler->priority] |=
+			evt_handler->evt_bit_mask_arr[i];
+
+		irq_mask = cam_io_r_mb(controller->mem_base +
+			controller->irq_register_arr[i].
+			mask_reg_offset);
+		irq_mask |= evt_handler->evt_bit_mask_arr[i];
+
+		cam_io_w_mb(irq_mask, controller->mem_base +
+		controller->irq_register_arr[i].mask_reg_offset);
+	}
+	write_unlock_irqrestore(&controller->rw_lock, flags);
+
+	return rc;
+}
+
+int cam_irq_controller_disable_irq(void *irq_controller, uint32_t handle)
+{
+	struct cam_irq_controller  *controller  = irq_controller;
+	struct cam_irq_evt_handler *evt_handler = NULL;
+	struct cam_irq_evt_handler *evt_handler_temp;
+	unsigned long               flags;
+	unsigned int                i;
+	uint32_t                    irq_mask;
+	uint32_t                    found = 0;
+	int                         rc = -EINVAL;
+
+	if (!controller)
+		return rc;
+
+	list_for_each_entry_safe(evt_handler, evt_handler_temp,
+		&controller->evt_handler_list_head, list_node) {
+		if (evt_handler->index == handle) {
+			CAM_DBG(CAM_ISP, "disable item %d", handle);
+			found = 1;
+			rc = 0;
+			break;
+		}
+	}
+
+	if (!found)
+		return rc;
+
+	write_lock_irqsave(&controller->rw_lock, flags);
+	for (i = 0; i < controller->num_registers; i++) {
+		controller->irq_register_arr[i].
+		top_half_enable_mask[evt_handler->priority] &=
+			~(evt_handler->evt_bit_mask_arr[i]);
+
+		irq_mask = cam_io_r_mb(controller->mem_base +
+			controller->irq_register_arr[i].
+			mask_reg_offset);
+		irq_mask &= ~(evt_handler->evt_bit_mask_arr[i]);
+
+		cam_io_w_mb(irq_mask, controller->mem_base +
+			controller->irq_register_arr[i].
+			mask_reg_offset);
+
+		/* Clear the IRQ bits of this handler */
+		cam_io_w_mb(evt_handler->evt_bit_mask_arr[i],
+			controller->mem_base +
+			controller->irq_register_arr[i].
+			clear_reg_offset);
+
+		if (controller->global_clear_offset)
+			cam_io_w_mb(
+				controller->global_clear_bitmask,
+				controller->mem_base +
+				controller->global_clear_offset);
+	}
+	write_unlock_irqrestore(&controller->rw_lock, flags);
+
+	return rc;
+}
+
 int cam_irq_controller_unsubscribe_irq(void *irq_controller,
 	uint32_t handle)
 {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.h
index 1990c51..7e307b5 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.h
@@ -214,4 +214,40 @@
  */
 irqreturn_t cam_irq_controller_handle_irq(int irq_num, void *priv);
 
+/*
+ * cam_irq_controller_disable_irq()
+ *
+ * @brief:              Disable the interrupts on given controller.
+ *                      Unsubscribe will disable the IRQ by default, so this is
+ *                      only needed if between subscribe/unsubscribe there is
+ *                      need to disable IRQ again
+ *
+ * @irq_controller:     Pointer to IRQ Controller that controls the registered
+ *                      events to it.
+ * @handle:             Handle returned on successful subscribe, used to
+ *                      identify the handler object
+ *
+ * @return:             0: events found and disabled
+ *                      Negative: events not registered on this controller
+ */
+int cam_irq_controller_disable_irq(void *irq_controller, uint32_t handle);
+
+/*
+ * cam_irq_controller_enable_irq()
+ *
+ * @brief:              Enable the interrupts on given controller.
+ *                      Subscribe will enable the IRQ by default, so this is
+ *                      only needed if between subscribe/unsubscribe there is
+ *                      need to enable IRQ again
+ *
+ * @irq_controller:     Pointer to IRQ Controller that controls the registered
+ *                      events to it.
+ * @handle:             Handle returned on successful subscribe, used to
+ *                      identify the handler object
+ *
+ * @return:             0: events found and enabled
+ *                      Negative: events not registered on this controller
+ */
+int cam_irq_controller_enable_irq(void *irq_controller, uint32_t handle);
+
 #endif /* _CAM_IRQ_CONTROLLER_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
index 8ff2a55..c68ddf7 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
@@ -199,7 +199,7 @@
 	.csid_csi2_rx_captured_long_pkt_0_addr        = 0x130,
 	.csid_csi2_rx_captured_long_pkt_1_addr        = 0x134,
 	.csid_csi2_rx_captured_long_pkt_ftr_addr      = 0x138,
-	.csid_csi2_rx_captured_cphy_pkt_ftr_addr      = 0x13c,
+	.csid_csi2_rx_captured_cphy_pkt_hdr_addr      = 0x13c,
 	.csid_csi2_rx_lane0_misr_addr                 = 0x150,
 	.csid_csi2_rx_lane1_misr_addr                 = 0x154,
 	.csid_csi2_rx_lane2_misr_addr                 = 0x158,
@@ -213,6 +213,14 @@
 	.csi2_irq_mask_all                            = 0xFFFFFFF,
 	.csi2_misr_enable_shift_val                   = 6,
 	.csi2_vc_mode_shift_val                       = 2,
+	.csi2_capture_long_pkt_en_shift               = 0,
+	.csi2_capture_short_pkt_en_shift              = 1,
+	.csi2_capture_cphy_pkt_en_shift               = 2,
+	.csi2_capture_long_pkt_dt_shift               = 4,
+	.csi2_capture_long_pkt_vc_shift               = 10,
+	.csi2_capture_short_pkt_vc_shift              = 15,
+	.csi2_capture_cphy_pkt_dt_shift               = 20,
+	.csi2_capture_cphy_pkt_vc_shift               = 26,
 };
 
 static struct cam_ife_csid_csi2_tpg_reg_offset
@@ -236,9 +244,10 @@
 	.csid_tpg_cgen_n_y1_addr                      = 0x664,
 	.csid_tpg_cgen_n_y2_addr                      = 0x668,
 
-	/*configurations */
+	/* configurations */
 	.tpg_dtn_cfg_offset                           = 0xc,
 	.tpg_cgen_cfg_offset                          = 0x20,
+	.tpg_cpas_ife_reg_offset                      = 0x28,
 };
 
 static struct cam_ife_csid_common_reg_offset
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
index a2f773e..7d6e758 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
@@ -33,11 +33,11 @@
 #define CAM_IFE_CSID_TIMEOUT_ALL_US                    1000000
 
 static int cam_ife_csid_is_ipp_format_supported(
-				uint32_t decode_fmt)
+	uint32_t in_format)
 {
 	int rc = -EINVAL;
 
-	switch (decode_fmt) {
+	switch (in_format) {
 	case CAM_FORMAT_MIPI_RAW_6:
 	case CAM_FORMAT_MIPI_RAW_8:
 	case CAM_FORMAT_MIPI_RAW_10:
@@ -59,127 +59,223 @@
 	return rc;
 }
 
-static int cam_ife_csid_get_format(uint32_t input_fmt,
-	uint32_t *path_fmt)
+static int cam_ife_csid_get_format_rdi(
+	uint32_t in_format, uint32_t out_format,
+	uint32_t *decode_fmt, uint32_t *plain_fmt)
 {
 	int rc = 0;
 
-	switch (input_fmt) {
+	switch (in_format) {
 	case CAM_FORMAT_MIPI_RAW_6:
-		*path_fmt  = 0;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_6:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN8:
+			*decode_fmt = 0x0;
+			*plain_fmt = 0x0;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_8:
-		*path_fmt  = 1;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_8:
+		case CAM_FORMAT_PLAIN128:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN8:
+			*decode_fmt = 0x1;
+			*plain_fmt = 0x0;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_10:
-		*path_fmt  = 2;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_10:
+		case CAM_FORMAT_PLAIN128:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN16_10:
+			*decode_fmt = 0x2;
+			*plain_fmt = 0x1;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_12:
-		*path_fmt  = 3;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_12:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN16_12:
+			*decode_fmt = 0x3;
+			*plain_fmt = 0x1;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_14:
-		*path_fmt  = 4;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_14:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN16_14:
+			*decode_fmt = 0x4;
+			*plain_fmt = 0x1;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_16:
-		*path_fmt  = 5;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_16:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN16_16:
+			*decode_fmt = 0x5;
+			*plain_fmt = 0x1;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_MIPI_RAW_20:
-		*path_fmt  = 6;
+		switch (out_format) {
+		case CAM_FORMAT_MIPI_RAW_20:
+			*decode_fmt = 0xf;
+			break;
+		case CAM_FORMAT_PLAIN32_20:
+			*decode_fmt = 0x6;
+			*plain_fmt = 0x2;
+			break;
+		default:
+			rc = -EINVAL;
+			break;
+		}
 		break;
 	case CAM_FORMAT_DPCM_10_6_10:
-		*path_fmt  = 7;
+		*decode_fmt  = 0x7;
+		*plain_fmt = 0x1;
 		break;
 	case CAM_FORMAT_DPCM_10_8_10:
-		*path_fmt  = 8;
+		*decode_fmt  = 0x8;
+		*plain_fmt = 0x1;
 		break;
 	case CAM_FORMAT_DPCM_12_6_12:
-		*path_fmt  = 9;
+		*decode_fmt  = 0x9;
+		*plain_fmt = 0x1;
 		break;
 	case CAM_FORMAT_DPCM_12_8_12:
-		*path_fmt  = 0xA;
+		*decode_fmt  = 0xA;
+		*plain_fmt = 0x1;
 		break;
 	case CAM_FORMAT_DPCM_14_8_14:
-		*path_fmt  = 0xB;
+		*decode_fmt  = 0xB;
+		*plain_fmt = 0x1;
 		break;
 	case CAM_FORMAT_DPCM_14_10_14:
-		*path_fmt  = 0xC;
+		*decode_fmt  = 0xC;
+		*plain_fmt = 0x1;
 		break;
 	default:
-		CAM_ERR(CAM_ISP, "CSID:%d un supported format",
-			input_fmt);
+		rc = -EINVAL;
+		break;
+	}
+
+	if (rc)
+		CAM_ERR(CAM_ISP, "Unsupported format pair in %d out %d",
+			in_format, out_format);
+
+	return rc;
+}
+
+static int cam_ife_csid_get_format_ipp(
+	uint32_t in_format,
+	uint32_t *decode_fmt, uint32_t *plain_fmt)
+{
+	int rc = 0;
+
+	CAM_DBG(CAM_ISP, "input format:%d",
+		 in_format);
+
+	switch (in_format) {
+	case CAM_FORMAT_MIPI_RAW_6:
+		*decode_fmt  = 0;
+		*plain_fmt = 0;
+		break;
+	case CAM_FORMAT_MIPI_RAW_8:
+		*decode_fmt  = 0x1;
+		*plain_fmt = 0;
+		break;
+	case CAM_FORMAT_MIPI_RAW_10:
+		*decode_fmt  = 0x2;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_MIPI_RAW_12:
+		*decode_fmt  = 0x3;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_MIPI_RAW_14:
+		*decode_fmt  = 0x4;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_MIPI_RAW_16:
+		*decode_fmt  = 0x5;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_MIPI_RAW_20:
+		*decode_fmt  = 0x6;
+		*plain_fmt = 0x2;
+		break;
+	case CAM_FORMAT_DPCM_10_6_10:
+		*decode_fmt  = 0x7;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_DPCM_10_8_10:
+		*decode_fmt  = 0x8;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_DPCM_12_6_12:
+		*decode_fmt  = 0x9;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_DPCM_12_8_12:
+		*decode_fmt  = 0xA;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_DPCM_14_8_14:
+		*decode_fmt  = 0xB;
+		*plain_fmt = 0x1;
+		break;
+	case CAM_FORMAT_DPCM_14_10_14:
+		*decode_fmt  = 0xC;
+		*plain_fmt = 0x1;
+		break;
+	default:
+		CAM_ERR(CAM_ISP, "Unsupported format %d",
+			in_format);
 		rc = -EINVAL;
 	}
 
+	CAM_DBG(CAM_ISP, "decode_fmt:%d plain_fmt:%d",
+		 *decode_fmt, *plain_fmt);
+
 	return rc;
 }
 
-static int cam_ife_csid_get_rdi_format(uint32_t input_fmt,
-	uint32_t output_fmt, uint32_t *path_fmt, uint32_t *plain_fmt)
-{
-	int rc = 0;
-
-	CAM_DBG(CAM_ISP, "input format:%d output format:%d",
-		 input_fmt, output_fmt);
-
-	switch (output_fmt) {
-	case CAM_FORMAT_MIPI_RAW_6:
-	case CAM_FORMAT_MIPI_RAW_8:
-	case CAM_FORMAT_MIPI_RAW_10:
-	case CAM_FORMAT_MIPI_RAW_12:
-	case CAM_FORMAT_MIPI_RAW_14:
-	case CAM_FORMAT_MIPI_RAW_16:
-	case CAM_FORMAT_MIPI_RAW_20:
-	case CAM_FORMAT_DPCM_10_6_10:
-	case CAM_FORMAT_DPCM_10_8_10:
-	case CAM_FORMAT_DPCM_12_6_12:
-	case CAM_FORMAT_DPCM_12_8_12:
-	case CAM_FORMAT_DPCM_14_8_14:
-	case CAM_FORMAT_DPCM_14_10_14:
-		*path_fmt  = 0xF;
-		*plain_fmt = 0;
-		break;
-
-	case CAM_FORMAT_PLAIN8:
-		rc = cam_ife_csid_get_format(input_fmt, path_fmt);
-		if (rc)
-			goto error;
-
-		*plain_fmt = 0;
-		break;
-	case CAM_FORMAT_PLAIN16_8:
-	case CAM_FORMAT_PLAIN16_10:
-	case CAM_FORMAT_PLAIN16_12:
-	case CAM_FORMAT_PLAIN16_14:
-	case CAM_FORMAT_PLAIN16_16:
-		rc = cam_ife_csid_get_format(input_fmt, path_fmt);
-		if (rc)
-			goto error;
-
-		*plain_fmt = 1;
-		break;
-	case CAM_FORMAT_PLAIN32_20:
-		rc = cam_ife_csid_get_format(input_fmt, path_fmt);
-		if (rc)
-			goto error;
-
-		*plain_fmt = 2;
-		break;
-	default:
-		*path_fmt  = 0xF;
-		*plain_fmt = 0;
-		break;
-	}
-
-	CAM_DBG(CAM_ISP, "path format value:%d plain format value:%d",
-		 *path_fmt, *plain_fmt);
-
-	return 0;
-error:
-	return rc;
-
-}
-
-
 static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
 	struct cam_isp_resource_node **res, int32_t vc, uint32_t dt,
 	uint32_t res_type)
@@ -466,7 +562,7 @@
 	struct cam_ife_csid_cid_data       *cid_data;
 
 	CAM_DBG(CAM_ISP,
-		"CSID:%d res_sel:%d Lane type:%d lane_num:%d dt:%d vc:%d",
+		"CSID:%d res_sel:0x%x Lane type:%d lane_num:%d dt:%d vc:%d",
 		csid_hw->hw_intf->hw_idx,
 		cid_reserv->in_port->res_type,
 		cid_reserv->in_port->lane_type,
@@ -549,7 +645,7 @@
 				goto end;
 				}
 		} else {
-			if (csid_hw->tpg_cfg.decode_fmt !=
+			if (csid_hw->tpg_cfg.in_format !=
 				cid_reserv->in_port->format     ||
 				csid_hw->tpg_cfg.width !=
 				cid_reserv->in_port->left_width ||
@@ -585,13 +681,26 @@
 				rc = -EINVAL;
 				goto end;
 			}
-			csid_hw->tpg_cfg.decode_fmt =
+			csid_hw->tpg_cfg.in_format =
 				cid_reserv->in_port->format;
-			csid_hw->tpg_cfg.width =
-				cid_reserv->in_port->left_width;
+			csid_hw->tpg_cfg.usage_type =
+				cid_reserv->in_port->usage_type;
+			if (cid_reserv->in_port->usage_type)
+				csid_hw->tpg_cfg.width =
+					(cid_reserv->in_port->right_stop + 1);
+			else
+				csid_hw->tpg_cfg.width =
+					cid_reserv->in_port->left_width;
+
 			csid_hw->tpg_cfg.height = cid_reserv->in_port->height;
 			csid_hw->tpg_cfg.test_pattern =
 				cid_reserv->in_port->test_pattern;
+
+			CAM_DBG(CAM_ISP, "CSID:%d TPG width:%d height:%d",
+				csid_hw->hw_intf->hw_idx,
+				csid_hw->tpg_cfg.width,
+				csid_hw->tpg_cfg.height);
+
 			cid_data->tpg_set = 1;
 		} else {
 			csid_hw->csi2_rx_cfg.phy_sel =
@@ -712,24 +821,14 @@
 	res->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 	path_data = (struct cam_ife_csid_path_cfg   *)res->res_priv;
 
-	/* store the output format for RDI */
-	switch (reserve->res_id) {
-	case CAM_IFE_PIX_PATH_RES_RDI_0:
-	case CAM_IFE_PIX_PATH_RES_RDI_1:
-	case CAM_IFE_PIX_PATH_RES_RDI_2:
-	case CAM_IFE_PIX_PATH_RES_RDI_3:
-		path_data->output_fmt = reserve->out_port->format;
-		break;
-	default:
-		break;
-	}
-
 	path_data->cid = reserve->cid;
-	path_data->decode_fmt = reserve->in_port->format;
+	path_data->in_format = reserve->in_port->format;
+	path_data->out_format = reserve->out_port->format;
 	path_data->master_idx = reserve->master_idx;
 	path_data->sync_mode = reserve->sync_mode;
 	path_data->height  = reserve->in_port->height;
 	path_data->start_line = reserve->in_port->line_start;
+	path_data->end_line = reserve->in_port->line_stop;
 	if (reserve->in_port->res_type == CAM_ISP_IFE_IN_RES_TPG) {
 		path_data->dt = CAM_IFE_CSID_TPG_DT_VAL;
 		path_data->vc = CAM_IFE_CSID_TPG_VC_VAL;
@@ -741,14 +840,33 @@
 	if (reserve->sync_mode == CAM_ISP_HW_SYNC_MASTER) {
 		path_data->crop_enable = 1;
 		path_data->start_pixel = reserve->in_port->left_start;
+		path_data->end_pixel = reserve->in_port->left_stop;
 		path_data->width  = reserve->in_port->left_width;
+		CAM_DBG(CAM_ISP, "CSID:%dmaster:startpixel 0x%x endpixel:0x%x",
+			csid_hw->hw_intf->hw_idx, path_data->start_pixel,
+			path_data->end_pixel);
+		CAM_DBG(CAM_ISP, "CSID:%dmaster:line start:0x%x line end:0x%x",
+			csid_hw->hw_intf->hw_idx, path_data->start_line,
+			path_data->end_line);
 	} else if (reserve->sync_mode == CAM_ISP_HW_SYNC_SLAVE) {
 		path_data->crop_enable = 1;
 		path_data->start_pixel = reserve->in_port->right_start;
+		path_data->end_pixel = reserve->in_port->right_stop;
 		path_data->width  = reserve->in_port->right_width;
-	} else
+		CAM_DBG(CAM_ISP, "CSID:%d slave:start:0x%x end:0x%x width 0x%x",
+			csid_hw->hw_intf->hw_idx, path_data->start_pixel,
+			path_data->end_pixel, path_data->width);
+		CAM_DBG(CAM_ISP, "CSID:%dmaster:line start:0x%x line end:0x%x",
+			csid_hw->hw_intf->hw_idx, path_data->start_line,
+			path_data->end_line);
+	} else {
 		path_data->crop_enable = 0;
+		path_data->width  = reserve->in_port->left_width;
+		path_data->start_pixel = reserve->in_port->left_start;
+	}
 
+	CAM_DBG(CAM_ISP, "Res %d width %d height %d", reserve->res_id,
+		path_data->width, path_data->height);
 	reserve->node_res = res;
 
 end:
@@ -904,6 +1022,7 @@
 static int cam_ife_csid_tpg_start(struct cam_ife_csid_hw   *csid_hw,
 	struct cam_isp_resource_node       *res)
 {
+	int rc = 0;
 	uint32_t  val = 0;
 	struct cam_hw_soc_info    *soc_info;
 
@@ -949,6 +1068,15 @@
 			}
 		}
 
+		/* Enable the IFE force clock on for dual isp case */
+		if (csid_hw->tpg_cfg.usage_type) {
+			rc = cam_ife_csid_enable_ife_force_clock_on(soc_info,
+				csid_hw->csid_info->csid_reg->tpg_reg->
+				tpg_cpas_ife_reg_offset);
+			if (rc)
+				return rc;
+		}
+
 		CAM_DBG(CAM_ISP, "============ TPG control ============");
 		val = (4 << 20);
 		val |= (0x80 << 8);
@@ -968,6 +1096,7 @@
 static int cam_ife_csid_tpg_stop(struct cam_ife_csid_hw   *csid_hw,
 	struct cam_isp_resource_node       *res)
 {
+	int rc = 0;
 	struct cam_hw_soc_info    *soc_info;
 
 	if (csid_hw->tpg_start_cnt)
@@ -983,6 +1112,12 @@
 		CAM_DBG(CAM_ISP, "CSID:%d stop CSID TPG",
 			csid_hw->hw_intf->hw_idx);
 
+		/* Disable the IFE force clock on for dual isp case */
+		if (csid_hw->tpg_cfg.usage_type)
+			rc = cam_ife_csid_disable_ife_force_clock_on(soc_info,
+				csid_hw->csid_info->csid_reg->tpg_reg->
+				tpg_cpas_ife_reg_offset);
+
 		/*stop the TPG */
 		cam_io_w_mb(0,  soc_info->reg_map[0].mem_base +
 		csid_hw->csid_info->csid_reg->tpg_reg->csid_tpg_ctrl_addr);
@@ -1010,8 +1145,8 @@
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->tpg_reg->csid_tpg_vc_cfg0_addr);
 
-	/* vertical blanking count = 0x740, horzontal blanking count = 0x740*/
-	val = (0x740 << 12) | 0x740;
+	/* vertical blanking count = 0x3FF, horzontal blanking count = 0x740*/
+	val = (0x3FF << 12) | 0x740;
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->tpg_reg->csid_tpg_vc_cfg1_addr);
 
@@ -1027,10 +1162,10 @@
 		csid_reg->tpg_reg->csid_tpg_dt_n_cfg_1_addr);
 
 	/*
-	 * decode_fmt is the same as the input resource format.
+	 * in_format is the same as the input resource format.
 	 * it is one larger than the register spec format.
 	 */
-	val = ((csid_hw->tpg_cfg.decode_fmt - 1) << 16) | 0x8;
+	val = ((csid_hw->tpg_cfg.in_format - 1) << 16) | 0x8;
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->tpg_reg->csid_tpg_dt_n_cfg_2_addr);
 
@@ -1113,6 +1248,28 @@
 		CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION |
 		CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION |
 		CSID_CSI2_RX_ERROR_CPHY_PH_CRC;
+
+	/* Enable the interrupt based on csid debug info set */
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOT_IRQ)
+		val |= CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL1_SOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL2_SOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL3_SOT_CAPTURED;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOT_IRQ)
+		val |= CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED |
+			CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE)
+		val |= CSID_CSI2_RX_INFO_SHORT_PKT_CAPTURED;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE)
+		val |= CSID_CSI2_RX_INFO_LONG_PKT_CAPTURED;
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE)
+		val |= CSID_CSI2_RX_INFO_CPHY_PKT_HDR_CAPTURED;
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr);
 
@@ -1160,7 +1317,7 @@
 	struct cam_ife_csid_path_cfg           *path_data;
 	struct cam_ife_csid_reg_offset         *csid_reg;
 	struct cam_hw_soc_info                 *soc_info;
-	uint32_t path_format = 0, val = 0;
+	uint32_t decode_format = 0, plain_format = 0, val = 0;
 
 	path_data = (struct cam_ife_csid_path_cfg  *) res->res_priv;
 	csid_reg = csid_hw->csid_info->csid_reg;
@@ -1173,8 +1330,9 @@
 		return -EINVAL;
 	}
 
-	CAM_DBG(CAM_ISP, "Enabled IPP Path.......");
-	rc = cam_ife_csid_get_format(path_data->decode_fmt, &path_format);
+	CAM_DBG(CAM_ISP, "Config IPP Path");
+	rc = cam_ife_csid_get_format_ipp(path_data->in_format,
+		&decode_format, &plain_format);
 	if (rc)
 		return rc;
 
@@ -1185,10 +1343,10 @@
 	val = (path_data->vc << csid_reg->cmn_reg->vc_shift_val) |
 		(path_data->dt << csid_reg->cmn_reg->dt_shift_val) |
 		(path_data->cid << csid_reg->cmn_reg->dt_id_shift_val) |
-		(path_format << csid_reg->cmn_reg->fmt_shift_val) |
-		(path_data->crop_enable & 1 <<
+		(decode_format << csid_reg->cmn_reg->fmt_shift_val) |
+		(path_data->crop_enable <<
 		csid_reg->cmn_reg->crop_h_en_shift_val) |
-		(path_data->crop_enable & 1 <<
+		(path_data->crop_enable <<
 		csid_reg->cmn_reg->crop_v_en_shift_val) |
 		(1 << 1) | 1;
 	val |= (1 << csid_reg->ipp_reg->pix_store_en_shift_val);
@@ -1200,21 +1358,21 @@
 		csid_reg->ipp_reg->csid_ipp_cfg1_addr);
 
 	if (path_data->crop_enable) {
-		val = ((path_data->width +
-			path_data->start_pixel) & 0xFFFF <<
+		val = (((path_data->end_pixel & 0xFFFF) <<
 			csid_reg->cmn_reg->crop_shift) |
-			(path_data->start_pixel & 0xFFFF);
-
+			(path_data->start_pixel & 0xFFFF));
 		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->ipp_reg->csid_ipp_hcrop_addr);
+		CAM_DBG(CAM_ISP, "CSID:%d Horizontal crop config val: 0x%x",
+			csid_hw->hw_intf->hw_idx, val);
 
-		val = ((path_data->height +
-			path_data->start_line) & 0xFFFF <<
+		val = (((path_data->end_line & 0xFFFF) <<
 			csid_reg->cmn_reg->crop_shift) |
-			(path_data->start_line & 0xFFFF);
-
+			(path_data->start_line & 0xFFFF));
 		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->ipp_reg->csid_ipp_vcrop_addr);
+		CAM_DBG(CAM_ISP, "CSID:%d Vertical Crop config val: 0x%x",
+			csid_hw->hw_intf->hw_idx, val);
 	}
 
 	/* set frame drop pattern to 0 and period to 1 */
@@ -1259,6 +1417,34 @@
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_cfg0_addr);
 
+	/* configure the rx packet capture based on csid debug set */
+	val = 0;
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE)
+		val = ((1 <<
+			csid_reg->csi2_reg->csi2_capture_short_pkt_en_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_short_pkt_vc_shift));
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE)
+		val |= ((1 <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_en_shift) |
+			(path_data->dt <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_dt_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_vc_shift));
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE)
+		val |= ((1 <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_en_shift) |
+			(path_data->dt <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_dt_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_vc_shift));
+
+	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+		csid_reg->csi2_reg->csid_csi2_rx_capture_ctrl_addr);
+	CAM_DBG(CAM_ISP, "rx capture control value 0x%x", val);
+
 	res->res_state = CAM_ISP_RESOURCE_STATE_INIT_HW;
 
 	return rc;
@@ -1330,9 +1516,9 @@
 		return -EINVAL;
 	}
 
-	CAM_DBG(CAM_ISP, "enable IPP path.......");
+	CAM_DBG(CAM_ISP, "Enable IPP path");
 
-	/*Resume at frame boundary */
+	/* Resume at frame boundary */
 	if (path_data->sync_mode == CAM_ISP_HW_SYNC_MASTER) {
 		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
 			csid_reg->ipp_reg->csid_ipp_ctrl_addr);
@@ -1348,6 +1534,12 @@
 
 	/* Enable the required ipp interrupts */
 	val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ)
+		val |= CSID_PATH_INFO_INPUT_SOF;
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ)
+		val |= CSID_PATH_INFO_INPUT_EOF;
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_irq_mask_addr);
 
@@ -1432,7 +1624,7 @@
 			csid_reg->ipp_reg->csid_ipp_irq_mask_addr);
 	} else {
 		val &= ~(CSID_PATH_INFO_RST_DONE |
-				CSID_PATH_ERROR_FIFO_OVERFLOW);
+			CSID_PATH_ERROR_FIFO_OVERFLOW);
 		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->ipp_reg->csid_ipp_irq_mask_addr);
 	}
@@ -1462,8 +1654,8 @@
 		return -EINVAL;
 	}
 
-	rc = cam_ife_csid_get_rdi_format(path_data->decode_fmt,
-		path_data->output_fmt, &path_format, &plain_fmt);
+	rc = cam_ife_csid_get_format_rdi(path_data->in_format,
+		path_data->out_format, &path_format, &plain_fmt);
 	if (rc)
 		return rc;
 
@@ -1476,9 +1668,9 @@
 		(path_data->cid << csid_reg->cmn_reg->dt_id_shift_val) |
 		(path_format << csid_reg->cmn_reg->fmt_shift_val) |
 		(plain_fmt << csid_reg->cmn_reg->plain_fmt_shit_val) |
-		(path_data->crop_enable & 1 <<
+		(path_data->crop_enable  <<
 			csid_reg->cmn_reg->crop_h_en_shift_val) |
-		(path_data->crop_enable & 1 <<
+		(path_data->crop_enable  <<
 		csid_reg->cmn_reg->crop_v_en_shift_val) |
 		(1 << 2) | 3;
 
@@ -1490,21 +1682,23 @@
 			csid_reg->rdi_reg[id]->csid_rdi_cfg1_addr);
 
 	if (path_data->crop_enable) {
-		val = ((path_data->width +
-			path_data->start_pixel) & 0xFFFF <<
+		val = (((path_data->end_pixel & 0xFFFF) <<
 			csid_reg->cmn_reg->crop_shift) |
-			(path_data->start_pixel & 0xFFFF);
+			(path_data->start_pixel & 0xFFFF));
 
 		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->rdi_reg[id]->csid_rdi_rpp_hcrop_addr);
+		CAM_DBG(CAM_ISP, "CSID:%d Horizontal crop config val: 0x%x",
+			csid_hw->hw_intf->hw_idx, val);
 
-		val = ((path_data->height +
-			path_data->start_line) & 0xFFFF <<
+		val = (((path_data->end_line & 0xFFFF) <<
 			csid_reg->cmn_reg->crop_shift) |
-			(path_data->start_line & 0xFFFF);
+			(path_data->start_line & 0xFFFF));
 
 		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->rdi_reg[id]->csid_rdi_rpp_vcrop_addr);
+		CAM_DBG(CAM_ISP, "CSID:%d Vertical Crop config val: 0x%x",
+			csid_hw->hw_intf->hw_idx, val);
 	}
 	/* set frame drop pattern to 0 and period to 1 */
 	cam_io_w_mb(1, soc_info->reg_map[0].mem_base +
@@ -1536,9 +1730,35 @@
 	val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
 		csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
 	val |= (1 << csid_reg->cmn_reg->path_en_shift_val);
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
 
+	/* configure the rx packet capture based on csid debug set */
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE)
+		val = ((1 <<
+			csid_reg->csi2_reg->csi2_capture_short_pkt_en_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_short_pkt_vc_shift));
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE)
+		val |= ((1 <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_en_shift) |
+			(path_data->dt <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_dt_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_long_pkt_vc_shift));
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE)
+		val |= ((1 <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_en_shift) |
+			(path_data->dt <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_dt_shift) |
+			(path_data->vc <<
+			csid_reg->csi2_reg->csi2_capture_cphy_pkt_vc_shift));
+	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+		csid_reg->csi2_reg->csid_csi2_rx_capture_ctrl_addr);
+
 	res->res_state = CAM_ISP_RESOURCE_STATE_INIT_HW;
 
 	return rc;
@@ -1606,6 +1826,12 @@
 
 	/* Enable the required RDI interrupts */
 	val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ)
+		val |= CSID_PATH_INFO_INPUT_SOF;
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ)
+		val |= CSID_PATH_INFO_INPUT_EOF;
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr);
 
@@ -1737,6 +1963,20 @@
 
 	return 0;
 }
+
+static int cam_ife_csid_set_csid_debug(struct cam_ife_csid_hw   *csid_hw,
+	void *cmd_args)
+{
+	uint32_t  *csid_debug;
+
+	csid_debug = (uint32_t  *) cmd_args;
+	csid_hw->csid_debug = *csid_debug;
+	CAM_DBG(CAM_ISP, "CSID:%d set csid debug value:%d",
+		csid_hw->hw_intf->hw_idx, csid_hw->csid_debug);
+
+	return 0;
+}
+
 static int cam_ife_csid_res_wait_for_halt(
 	struct cam_ife_csid_hw          *csid_hw,
 	struct cam_isp_resource_node    *res)
@@ -2280,6 +2520,9 @@
 	case CAM_IFE_CSID_CMD_GET_TIME_STAMP:
 		rc = cam_ife_csid_get_time_stamp(csid_hw, cmd_args);
 		break;
+	case CAM_IFE_CSID_SET_CSID_DEBUG:
+		rc = cam_ife_csid_set_csid_debug(csid_hw, cmd_args);
+		break;
 	default:
 		CAM_ERR(CAM_ISP, "CSID:%d un supported cmd:%d",
 			csid_hw->hw_intf->hw_idx, cmd_type);
@@ -2298,6 +2541,7 @@
 	struct cam_ife_csid_reg_offset  *csid_reg;
 	uint32_t i, irq_status_top, irq_status_rx, irq_status_ipp = 0,
 		irq_status_rdi[4];
+	uint32_t val;
 
 	csid_hw = (struct cam_ife_csid_hw *)data;
 
@@ -2391,6 +2635,93 @@
 			 csid_hw->hw_intf->hw_idx);
 	}
 
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOT_IRQ) {
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL0_EOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL1_EOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL2_EOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL3_EOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+	}
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOT_IRQ) {
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL0_SOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL1_SOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL1_SOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL2_SOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL2_SOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+		if (irq_status_rx & CSID_CSI2_RX_INFO_PHY_DL3_SOT_CAPTURED) {
+			CAM_ERR(CAM_ISP, "CSID:%d PHY_DL3_SOT_CAPTURED",
+				csid_hw->hw_intf->hw_idx);
+		}
+	}
+
+	if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE) &&
+		(irq_status_rx & CSID_CSI2_RX_INFO_LONG_PKT_CAPTURED)) {
+		CAM_ERR(CAM_ISP, "CSID:%d LONG_PKT_CAPTURED",
+			csid_hw->hw_intf->hw_idx);
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_long_pkt_0_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d long packet VC :%d DT:%d WC:%d",
+			csid_hw->hw_intf->hw_idx,
+			(val >> 22), ((val >> 16) & 0x3F), (val & 0xFFFF));
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_long_pkt_1_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d long packet ECC :%d",
+			csid_hw->hw_intf->hw_idx, val);
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_long_pkt_ftr_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d long pkt cal CRC:%d expected CRC:%d",
+			csid_hw->hw_intf->hw_idx, (val >> 16), (val & 0xFFFF));
+	}
+	if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE) &&
+		(irq_status_rx & CSID_CSI2_RX_INFO_SHORT_PKT_CAPTURED)) {
+		CAM_ERR(CAM_ISP, "CSID:%d SHORT_PKT_CAPTURED",
+			csid_hw->hw_intf->hw_idx);
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_short_pkt_0_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d short pkt VC :%d DT:%d LC:%d",
+			csid_hw->hw_intf->hw_idx,
+			(val >> 22), ((val >> 16) & 0x1F), (val & 0xFFFF));
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_short_pkt_1_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d short packet ECC :%d", val);
+	}
+
+	if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE) &&
+		(irq_status_rx & CSID_CSI2_RX_INFO_CPHY_PKT_HDR_CAPTURED)) {
+		CAM_ERR(CAM_ISP, "CSID:%d CPHY_PKT_HDR_CAPTURED",
+			csid_hw->hw_intf->hw_idx);
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->csi2_reg->
+			csid_csi2_rx_captured_cphy_pkt_hdr_addr);
+		CAM_ERR(CAM_ISP, "CSID:%d cphy packet VC :%d DT:%d WC:%d",
+			csid_hw->hw_intf->hw_idx,
+			(val >> 22), ((val >> 16) & 0x1F), (val & 0xFFFF));
+	}
+
 	/*read the IPP errors */
 	if (csid_reg->cmn_reg->no_pix) {
 		/* IPP reset done bit */
@@ -2399,14 +2730,16 @@
 			CAM_DBG(CAM_ISP, "CSID IPP reset complete");
 			complete(&csid_hw->csid_ipp_complete);
 		}
-		if (irq_status_ipp & CSID_PATH_INFO_INPUT_SOF)
-			CAM_DBG(CAM_ISP, "CSID IPP SOF received");
-		if (irq_status_ipp & CSID_PATH_INFO_INPUT_SOL)
-			CAM_DBG(CAM_ISP, "CSID IPP SOL received");
-		if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOL)
-			CAM_DBG(CAM_ISP, "CSID IPP EOL received");
-		if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOF)
-			CAM_DBG(CAM_ISP, "CSID IPP EOF received");
+
+		if ((irq_status_ipp & CSID_PATH_INFO_INPUT_SOF) &&
+			(csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ))
+			CAM_ERR(CAM_ISP, "CSID:%d IPP SOF received",
+				csid_hw->hw_intf->hw_idx);
+
+		if ((irq_status_ipp & CSID_PATH_INFO_INPUT_EOF) &&
+			(csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ))
+			CAM_ERR(CAM_ISP, "CSID:%d IPP EOF received",
+				csid_hw->hw_intf->hw_idx);
 
 		if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOF)
 			complete(&csid_hw->csid_ipp_complete);
@@ -2424,14 +2757,17 @@
 	for (i = 0; i < csid_reg->cmn_reg->no_rdis; i++) {
 		if (irq_status_rdi[i] &
 			BIT(csid_reg->cmn_reg->path_rst_done_shift_val)) {
-			CAM_DBG(CAM_ISP, "CSID rdi%d reset complete", i);
+			CAM_DBG(CAM_ISP, "CSID RDI%d reset complete", i);
 			complete(&csid_hw->csid_rdin_complete[i]);
 		}
 
-		if (irq_status_rdi[i]  & CSID_PATH_INFO_INPUT_SOF)
-			CAM_DBG(CAM_ISP, "CSID RDI SOF received");
-		if (irq_status_rdi[i]  & CSID_PATH_INFO_INPUT_EOF)
-			CAM_DBG(CAM_ISP, "CSID RDI EOF received");
+		if ((irq_status_rdi[i] & CSID_PATH_INFO_INPUT_SOF) &&
+			(csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ))
+			CAM_ERR(CAM_ISP, "CSID RDI:%d SOF received", i);
+
+		if ((irq_status_rdi[i]  & CSID_PATH_INFO_INPUT_EOF) &&
+			(csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ))
+			CAM_ERR(CAM_ISP, "CSID RDI:%d EOF received", i);
 
 		if (irq_status_rdi[i] & CSID_PATH_INFO_INPUT_EOF)
 			complete(&csid_hw->csid_rdin_complete[i]);
@@ -2559,6 +2895,7 @@
 		ife_csid_hw->rdi_res[i].res_priv = path_data;
 	}
 
+	ife_csid_hw->csid_debug = 0;
 	return 0;
 err:
 	if (rc) {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
index ef585c3..deef41f 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
@@ -22,7 +22,7 @@
 #define CAM_IFE_CSID_RDI_MAX         4
 
 #define CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED    BIT(0)
-#define CSID_CSI2_RX_NFO_PHY_DL1_EOT_CAPTURED     BIT(1)
+#define CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED    BIT(1)
 #define CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED    BIT(2)
 #define CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED    BIT(3)
 #define CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED    BIT(4)
@@ -65,6 +65,18 @@
 #define CSID_PATH_ERROR_PIX_COUNT                 BIT(13)
 #define CSID_PATH_ERROR_LINE_COUNT                BIT(14)
 
+/*
+ * Debug values enable the corresponding interrupts and debug logs provide
+ * necessary information
+ */
+#define CSID_DEBUG_ENABLE_SOF_IRQ                 BIT(0)
+#define CSID_DEBUG_ENABLE_EOF_IRQ                 BIT(1)
+#define CSID_DEBUG_ENABLE_SOT_IRQ                 BIT(2)
+#define CSID_DEBUG_ENABLE_EOT_IRQ                 BIT(3)
+#define CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE       BIT(4)
+#define CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE        BIT(5)
+#define CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE        BIT(6)
+
 /* enum cam_csid_path_halt_mode select the path halt mode control */
 enum cam_csid_path_halt_mode {
 	CSID_HALT_MODE_INTERNAL,
@@ -187,7 +199,7 @@
 	uint32_t csid_csi2_rx_captured_long_pkt_0_addr;
 	uint32_t csid_csi2_rx_captured_long_pkt_1_addr;
 	uint32_t csid_csi2_rx_captured_long_pkt_ftr_addr;
-	uint32_t csid_csi2_rx_captured_cphy_pkt_ftr_addr;
+	uint32_t csid_csi2_rx_captured_cphy_pkt_hdr_addr;
 	uint32_t csid_csi2_rx_lane0_misr_addr;
 	uint32_t csid_csi2_rx_lane1_misr_addr;
 	uint32_t csid_csi2_rx_lane2_misr_addr;
@@ -202,6 +214,14 @@
 	uint32_t csi2_irq_mask_all;
 	uint32_t csi2_misr_enable_shift_val;
 	uint32_t csi2_vc_mode_shift_val;
+	uint32_t csi2_capture_long_pkt_en_shift;
+	uint32_t csi2_capture_short_pkt_en_shift;
+	uint32_t csi2_capture_cphy_pkt_en_shift;
+	uint32_t csi2_capture_long_pkt_dt_shift;
+	uint32_t csi2_capture_long_pkt_vc_shift;
+	uint32_t csi2_capture_short_pkt_vc_shift;
+	uint32_t csi2_capture_cphy_pkt_dt_shift;
+	uint32_t csi2_capture_cphy_pkt_vc_shift;
 };
 
 struct cam_ife_csid_csi2_tpg_reg_offset {
@@ -226,6 +246,7 @@
 	/*configurations */
 	uint32_t tpg_dtn_cfg_offset;
 	uint32_t tpg_cgen_cfg_offset;
+	uint32_t tpg_cpas_ife_reg_offset;
 
 };
 struct cam_ife_csid_common_reg_offset {
@@ -320,14 +341,16 @@
  * @width:            width
  * @height:           height
  * @test_pattern :    pattern
- * @decode_format:    decode format
+ * @in_format:        decode format
+ * @usage_type:       whether dual isp is required
  *
  */
 struct cam_ife_csid_tpg_cfg  {
 	uint32_t                        width;
 	uint32_t                        height;
 	uint32_t                        test_pattern;
-	uint32_t                        decode_fmt;
+	uint32_t                        in_format;
+	uint32_t                        usage_type;
 };
 
 /**
@@ -353,13 +376,15 @@
  * @vc :            Virtual channel number
  * @dt :            Data type number
  * @cid             cid number, it is same as DT_ID number in HW
- * @decode_fmt:     input decode format
- * @output_fmt:     output resource format, needed for RDI resource
+ * @in_format:      input decode format
+ * @out_format:     output format
  * @crop_enable:    crop is enable or disabled, if enabled
  *                  then remaining parameters are valid.
  * @start_pixel:    start pixel
+ * @end_pixel:      end_pixel
  * @width:          width
  * @start_line:     start line
+ * @end_line:       end_line
  * @height:         heigth
  * @sync_mode:       Applicable for IPP/RDI path reservation
  *                  Reserving the path for master IPP or slave IPP
@@ -373,12 +398,14 @@
 	uint32_t                        vc;
 	uint32_t                        dt;
 	uint32_t                        cid;
-	uint32_t                        decode_fmt;
-	uint32_t                        output_fmt;
+	uint32_t                        in_format;
+	uint32_t                        out_format;
 	bool                            crop_enable;
 	uint32_t                        start_pixel;
+	uint32_t                        end_pixel;
 	uint32_t                        width;
 	uint32_t                        start_line;
+	uint32_t                        end_line;
 	uint32_t                        height;
 	enum cam_isp_hw_sync_mode       sync_mode;
 	uint32_t                        master_idx;
@@ -403,6 +430,8 @@
  * @csid_csi2_reset_complete: csi2 reset completion
  * @csid_ipp_reset_complete:  ipp reset completion
  * @csid_rdin_reset_complete: rdi n completion
+ * @csid_debug:               csid debug information to enable the SOT, EOT,
+ *                            SOF, EOF, measure etc in the csid hw
  *
  */
 struct cam_ife_csid_hw {
@@ -422,6 +451,7 @@
 	struct completion                csid_csi2_complete;
 	struct completion                csid_ipp_complete;
 	struct completion    csid_rdin_complete[CAM_IFE_CSID_RDI_MAX];
+	uint64_t                         csid_debug;
 };
 
 int cam_ife_csid_hw_probe_init(struct cam_hw_intf  *csid_hw_intf,
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
index 5a57046..128c050 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
@@ -69,6 +69,8 @@
 
 	csid_hw_info->core_info = csid_dev;
 	csid_hw_info->soc_info.pdev = pdev;
+	csid_hw_info->soc_info.dev = &pdev->dev;
+	csid_hw_info->soc_info.dev_name = pdev->name;
 	csid_hw_info->soc_info.index = csid_dev_idx;
 
 	csid_hw_data = (struct cam_ife_csid_hw_info  *)match_dev->data;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.h
index e857f8b..952426d 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.h
@@ -210,7 +210,7 @@
 	.csid_csi2_rx_captured_long_pkt_0_addr        = 0x130,
 	.csid_csi2_rx_captured_long_pkt_1_addr        = 0x134,
 	.csid_csi2_rx_captured_long_pkt_ftr_addr      = 0x138,
-	.csid_csi2_rx_captured_cphy_pkt_ftr_addr      = 0x13c,
+	.csid_csi2_rx_captured_cphy_pkt_hdr_addr      = 0x13c,
 	.csid_csi2_rx_lane0_misr_addr                 = 0x150,
 	.csid_csi2_rx_lane1_misr_addr                 = 0x154,
 	.csid_csi2_rx_lane2_misr_addr                 = 0x158,
@@ -224,6 +224,14 @@
 	.csi2_irq_mask_all                            = 0xFFFFFFF,
 	.csi2_misr_enable_shift_val                   = 6,
 	.csi2_vc_mode_shift_val                       = 2,
+	.csi2_capture_long_pkt_en_shift               = 0,
+	.csi2_capture_short_pkt_en_shift              = 1,
+	.csi2_capture_cphy_pkt_en_shift               = 2,
+	.csi2_capture_long_pkt_dt_shift               = 4,
+	.csi2_capture_long_pkt_vc_shift               = 10,
+	.csi2_capture_short_pkt_vc_shift              = 15,
+	.csi2_capture_cphy_pkt_dt_shift               = 20,
+	.csi2_capture_cphy_pkt_vc_shift               = 26,
 };
 
 
@@ -252,6 +260,7 @@
 	/*configurations */
 	.tpg_dtn_cfg_offset                           = 0xc,
 	.tpg_cgen_cfg_offset                          = 0x20,
+	.tpg_cpas_ife_reg_offset                      = 0x28,
 };
 
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
index 72050aa..c036bca 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
@@ -76,7 +76,7 @@
 	strlcpy(cpas_register_param.identifier, "csid",
 		CAM_HW_IDENTIFIER_LENGTH);
 	cpas_register_param.cell_index = soc_info->index;
-	cpas_register_param.dev = &soc_info->pdev->dev;
+	cpas_register_param.dev = soc_info->dev;
 	rc = cam_cpas_register_client(&cpas_register_param);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc);
@@ -129,8 +129,8 @@
 
 	ahb_vote.type = CAM_VOTE_ABSOLUTE;
 	ahb_vote.vote.level = CAM_SVS_VOTE;
-	axi_vote.compressed_bw = 640000000;
-	axi_vote.uncompressed_bw = 640000000;
+	axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
+	axi_vote.uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
 
 	CAM_DBG(CAM_ISP, "csid vote compressed_bw:%lld uncompressed_bw:%lld",
 		axi_vote.compressed_bw, axi_vote.uncompressed_bw);
@@ -181,3 +181,59 @@
 	return rc;
 }
 
+int cam_ife_csid_enable_ife_force_clock_on(struct cam_hw_soc_info  *soc_info,
+	uint32_t cpas_ife_base_offset)
+{
+	int rc = 0;
+	struct cam_csid_soc_private       *soc_private;
+	uint32_t                           cpass_ife_force_clk_offset;
+
+	if (!soc_info) {
+		CAM_ERR(CAM_ISP, "Error Invalid params");
+		return -EINVAL;
+	}
+
+	soc_private = soc_info->soc_private;
+	cpass_ife_force_clk_offset =
+		cpas_ife_base_offset + (0x4 * soc_info->index);
+	rc = cam_cpas_reg_write(soc_private->cpas_handle, CAM_CPAS_REG_CPASTOP,
+		cpass_ife_force_clk_offset, 1, 1);
+
+	if (rc)
+		CAM_ERR(CAM_ISP, "CPASS set IFE:%d Force clock On failed",
+			soc_info->index);
+	else
+		CAM_DBG(CAM_ISP, "CPASS set IFE:%d Force clock On",
+		soc_info->index);
+
+	return rc;
+}
+
+int cam_ife_csid_disable_ife_force_clock_on(struct cam_hw_soc_info *soc_info,
+	uint32_t cpas_ife_base_offset)
+{
+	int rc = 0;
+	struct cam_csid_soc_private       *soc_private;
+	uint32_t                           cpass_ife_force_clk_offset;
+
+	if (!soc_info) {
+		CAM_ERR(CAM_ISP, "Error Invalid params");
+		return -EINVAL;
+	}
+
+	soc_private = soc_info->soc_private;
+	cpass_ife_force_clk_offset =
+		cpas_ife_base_offset + (0x4 * soc_info->index);
+	rc = cam_cpas_reg_write(soc_private->cpas_handle, CAM_CPAS_REG_CPASTOP,
+		cpass_ife_force_clk_offset,  1, 0);
+
+	if (rc)
+		CAM_ERR(CAM_ISP, "CPASS set IFE:%d Force clock Off failed",
+			soc_info->index);
+	else
+		CAM_DBG(CAM_ISP, "CPASS set IFE:%d Force clock off",
+		soc_info->index);
+
+	return rc;
+}
+
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
index 1a30722..8e963de 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
@@ -82,4 +82,33 @@
  */
 int cam_ife_csid_disable_soc_resources(struct cam_hw_soc_info *soc_info);
 
+/**
+ * cam_ife_csid_enable_ife_force_clock()
+ *
+ * @brief:                 if csid testgen used for dual isp case, before
+ *                         starting csid test gen, enable ife force clock on
+ *                         through cpas
+ *
+ * @soc_info:              soc info structure pointer
+ * @cpas_ife_base_offset:  cpas ife force clock base reg offset value
+ *
+ */
+int cam_ife_csid_enable_ife_force_clock_on(struct cam_hw_soc_info  *soc_info,
+	uint32_t cpas_ife_base_offset);
+
+/**
+ * cam_ife_csid_disable_ife_force_clock_on()
+ *
+ * @brief:                 disable the IFE force clock on after dual ISP
+ *                         CSID test gen stop
+ *
+ * @soc_info:              soc info structure pointer
+ * @cpas_ife_base_offset:  cpas ife force clock base reg offset value
+ *
+ */
+int cam_ife_csid_disable_ife_force_clock_on(struct cam_hw_soc_info *soc_info,
+	uint32_t cpas_ife_base_offset);
+
+
+
 #endif
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
index 52b712a..37e0ce3 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
@@ -10,8 +10,8 @@
  * GNU General Public License for more details.
  */
 
-#ifndef __CAM_CSID_HW_INTF_H__
-#define __CAM_CSID_HW_INTF_H__
+#ifndef _CAM_CSID_HW_INTF_H_
+#define _CAM_CSID_HW_INTF_H_
 
 #include "cam_isp_hw.h"
 #include "cam_hw_intf.h"
@@ -19,7 +19,6 @@
 /* MAX IFE CSID instance */
 #define CAM_IFE_CSID_HW_NUM_MAX                        4
 
-
 /**
  * enum cam_ife_pix_path_res_id - Specify the csid patch
  */
@@ -43,7 +42,6 @@
 	CAM_IFE_CSID_CID_MAX,
 };
 
-
 /**
  * struct cam_ife_csid_hw_caps- get the CSID hw capability
  * @no_rdis :       number of rdis supported by CSID HW device
@@ -61,7 +59,6 @@
 	uint32_t      version_incr;
 };
 
-
 /**
  * struct cam_csid_hw_reserve_resource- hw reserve
  * @res_type :  reource type CID or PATH
@@ -89,10 +86,8 @@
 	uint32_t                                  master_idx;
 	uint32_t                                  cid;
 	struct cam_isp_resource_node             *node_res;
-
 };
 
-
 /**
  *  enum cam_ife_csid_halt_cmd - Specify the halt command type
  */
@@ -156,6 +151,7 @@
  */
 enum cam_ife_csid_cmd_type {
 	CAM_IFE_CSID_CMD_GET_TIME_STAMP,
+	CAM_IFE_CSID_SET_CSID_DEBUG,
 	CAM_IFE_CSID_CMD_MAX,
 };
 
@@ -170,4 +166,4 @@
 int cam_ife_csid_hw_init(struct cam_hw_intf **ife_csid_hw,
 	uint32_t hw_idx);
 
-#endif /* __CAM_CSID_HW_INTF_H__ */
+#endif /* _CAM_CSID_HW_INTF_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
index 6c6f38b..3a0c6a7 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
@@ -17,6 +17,7 @@
 #include "cam_hw.h"
 #include "cam_soc_util.h"
 #include "cam_irq_controller.h"
+#include <uapi/media/cam_isp.h>
 
 /*
  * struct cam_isp_timestamp:
@@ -161,4 +162,33 @@
 	struct cam_buf_io_cfg          *io_cfg;
 };
 
+/*
+ * struct cam_isp_hw_get_hfr_update:
+ *
+ * @Brief:         Get cdm commands for HFR updates.
+ *
+ * @ cdm:          Command buffer information
+ * @ io_hfr_cfg:   IO buffer config information sent from UMD
+ *
+ */
+struct cam_isp_hw_get_hfr_update {
+	struct cam_isp_hw_get_cdm_args  cdm;
+	struct cam_isp_port_hfr_config *io_hfr_cfg;
+};
+
+/*
+ * struct cam_isp_hw_dual_isp_update_args:
+ *
+ * @Brief:        update the dual isp striping configuration.
+ *
+ * @ split_id:    spilt id to inform left or rifht
+ * @ res:         resource node
+ * @ dual_cfg:    dual isp configuration
+ *
+ */
+struct cam_isp_hw_dual_isp_update_args {
+	enum cam_isp_hw_split_id         split_id;
+	struct cam_isp_resource_node    *res;
+	struct cam_isp_dual_config      *dual_cfg;
+};
 #endif /* _CAM_ISP_HW_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h
index 418280a..96263de 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h
@@ -48,6 +48,9 @@
 	CAM_VFE_HW_CMD_GET_CHANGE_BASE,
 	CAM_VFE_HW_CMD_GET_BUF_UPDATE,
 	CAM_VFE_HW_CMD_GET_REG_UPDATE,
+	CAM_VFE_HW_CMD_GET_HFR_UPDATE,
+	CAM_VFE_HW_CMD_GET_SECURE_MODE,
+	CAM_VFE_HW_CMD_STRIPE_UPDATE,
 	CAM_VFE_HW_CMD_MAX,
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
index e330c84..77b830c 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
@@ -179,6 +179,13 @@
 
 	CAM_DBG(CAM_ISP, "Enable soc done");
 
+	/* Do HW Reset */
+	rc = cam_vfe_reset(hw_priv, NULL, 0);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Reset Failed rc=%d", rc);
+		goto disable_soc;
+	}
+
 	rc = core_info->vfe_bus->hw_ops.init(core_info->vfe_bus->bus_priv,
 		NULL, 0);
 	if (rc) {
@@ -186,18 +193,7 @@
 		goto disable_soc;
 	}
 
-	/* Do HW Reset */
-	rc = cam_vfe_reset(hw_priv, NULL, 0);
-	if (rc) {
-		CAM_ERR(CAM_ISP, "Reset Failed rc=%d", rc);
-		goto deinit_bus;
-	}
-
 	return 0;
-
-deinit_bus:
-	core_info->vfe_bus->hw_ops.deinit(core_info->vfe_bus->bus_priv,
-		NULL, 0);
 disable_soc:
 	cam_vfe_disable_soc_resources(soc_info);
 decrement_open_cnt:
@@ -350,7 +346,11 @@
 	 *  will block everything.
 	 */
 	if (evt_payload->irq_reg_val[1]) {
-		CAM_ERR(CAM_ISP, "Mask all the interrupts");
+		CAM_ERR(CAM_ISP,
+			"Encountered Error Irq_status1=0x%x. Stopping further IRQ processing from this HW",
+			evt_payload->irq_reg_val[1]);
+		CAM_ERR(CAM_ISP, "Violation status = %x",
+			evt_payload->irq_reg_val[2]);
 		cam_io_w(0, handler_priv->mem_base + 0x60);
 		cam_io_w(0, handler_priv->mem_base + 0x5C);
 
@@ -556,6 +556,8 @@
 
 		break;
 	case CAM_VFE_HW_CMD_GET_BUF_UPDATE:
+	case CAM_VFE_HW_CMD_GET_HFR_UPDATE:
+	case CAM_VFE_HW_CMD_STRIPE_UPDATE:
 		rc = core_info->vfe_bus->hw_ops.process_cmd(
 			core_info->vfe_bus->bus_priv, cmd_type, cmd_args,
 			arg_size);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
index 3e2307c..74627b8 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
@@ -45,6 +45,8 @@
 		goto free_vfe_hw_intf;
 	}
 	vfe_hw->soc_info.pdev = pdev;
+	vfe_hw->soc_info.dev = &pdev->dev;
+	vfe_hw->soc_info.dev_name = pdev->name;
 	vfe_hw_intf->hw_priv = vfe_hw;
 	vfe_hw_intf->hw_ops.get_hw_caps = cam_vfe_get_hw_caps;
 	vfe_hw_intf->hw_ops.init = cam_vfe_init_hw;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
index 3b2ead2..b5ca432 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
@@ -88,7 +88,7 @@
 	strlcpy(cpas_register_param.identifier, "ife",
 		CAM_HW_IDENTIFIER_LENGTH);
 	cpas_register_param.cell_index = soc_info->index;
-	cpas_register_param.dev = &soc_info->pdev->dev;
+	cpas_register_param.dev = soc_info->dev;
 	rc = cam_cpas_register_client(&cpas_register_param);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
index 275c7b5..e3a6f7b 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
@@ -49,6 +49,7 @@
 	.epoch_irq                = 0x000004A0,
 	.raw_crop_width_cfg       = 0x00000CE4,
 	.raw_crop_height_cfg      = 0x00000CE8,
+	.reg_update_cmd           = 0x000004AC,
 };
 
 static struct cam_vfe_camif_reg_data vfe_170_camif_reg_data = {
@@ -66,10 +67,12 @@
 	.extern_reg_update_mask          = 1,
 	.pixel_pattern_shift             = 0,
 	.pixel_pattern_mask              = 0x7,
-	.epoch_line_cfg                  = 0x140000,
+	.reg_update_cmd_data             = 0x1,
+	.epoch_line_cfg                  = 0x00140014,
 	.sof_irq_mask                    = 0x00000001,
 	.epoch0_irq_mask                 = 0x00000004,
 	.reg_update_irq_mask             = 0x00000010,
+	.eof_irq_mask                    = 0x00000002,
 };
 
 struct cam_vfe_top_ver2_reg_offset_module_ctrl lens_170_reg = {
@@ -220,6 +223,9 @@
 		.comp_ovrwr_status            = 0x00002070,
 		.dual_comp_error_status       = 0x00002074,
 		.dual_comp_error_status       = 0x00002078,
+		.addr_sync_cfg                = 0x0000207C,
+		.addr_sync_frame_hdr          = 0x00002080,
+		.addr_sync_no_sync            = 0x00002084,
 	},
 	.bus_client_reg = {
 		/* BUS Client 0 */
@@ -671,26 +677,34 @@
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 */
 		{
 			.comp_mask                    = 0x0000202C,
+			.addr_sync_mask               = 0x00002088,
 		},
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_1 */
 		{
 			.comp_mask                    = 0x00002030,
+			.addr_sync_mask               = 0x0000208C,
+
 		},
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_2 */
 		{
 			.comp_mask                    = 0x00002034,
+			.addr_sync_mask               = 0x00002090,
+
 		},
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_3 */
 		{
 			.comp_mask                    = 0x00002038,
+			.addr_sync_mask               = 0x00002094,
 		},
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_4 */
 		{
 			.comp_mask                    = 0x0000203C,
+			.addr_sync_mask               = 0x00002098,
 		},
 		/* CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5 */
 		{
 			.comp_mask                    = 0x00002040,
+			.addr_sync_mask               = 0x0000209C,
 		},
 	},
 	.vfe_out_hw_info = {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
index c041eef..005d7e0 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
@@ -12,7 +12,9 @@
 
 #include <linux/ratelimit.h>
 #include <linux/slab.h>
+#include <uapi/media/cam_isp.h>
 #include "cam_io_util.h"
+#include "cam_debug_util.h"
 #include "cam_cdm_util.h"
 #include "cam_hw_intf.h"
 #include "cam_ife_hw_mgr.h"
@@ -33,14 +35,18 @@
 
 #define CAM_VFE_BUS_VER2_PAYLOAD_MAX             256
 
-#define CAM_VFE_RDI_BUS_DEFAULT_WIDTH           0xFF01
-#define CAM_VFE_RDI_BUS_DEFAULT_STRIDE          0xFF01
+#define CAM_VFE_RDI_BUS_DEFAULT_WIDTH               0xFF01
+#define CAM_VFE_RDI_BUS_DEFAULT_STRIDE              0xFF01
+#define CAM_VFE_BUS_INTRA_CLIENT_MASK               0x3
+#define CAM_VFE_BUS_ADDR_SYNC_INTRA_CLIENT_SHIFT    8
+#define CAM_VFE_BUS_ADDR_NO_SYNC_DEFAULT_VAL        0xFFFFF
 
 #define ALIGNUP(value, alignment) \
 	((value + alignment - 1) / alignment * alignment)
 
 #define MAX_BUF_UPDATE_REG_NUM   \
-	(sizeof(struct cam_vfe_bus_ver2_reg_offset_bus_client)/4)
+	((sizeof(struct cam_vfe_bus_ver2_reg_offset_bus_client) +  \
+	sizeof(struct cam_vfe_bus_ver2_reg_offset_ubwc_client))/4)
 #define MAX_REG_VAL_PAIR_SIZE    \
 	(MAX_BUF_UPDATE_REG_NUM * 2 * CAM_PACKET_MAX_PLANES)
 
@@ -70,6 +76,16 @@
 	PACKER_FMT_MAX                         = 0xF,
 };
 
+enum cam_vfe_bus_comp_grp_id {
+	CAM_VFE_BUS_COMP_GROUP_NONE = -EINVAL,
+	CAM_VFE_BUS_COMP_GROUP_ID_0 = 0x0,
+	CAM_VFE_BUS_COMP_GROUP_ID_1 = 0x1,
+	CAM_VFE_BUS_COMP_GROUP_ID_2 = 0x2,
+	CAM_VFE_BUS_COMP_GROUP_ID_3 = 0x3,
+	CAM_VFE_BUS_COMP_GROUP_ID_4 = 0x4,
+	CAM_VFE_BUS_COMP_GROUP_ID_5 = 0x5,
+};
+
 struct cam_vfe_bus_ver2_common_data {
 	uint32_t                                    core_index;
 	void __iomem                               *mem_base;
@@ -83,6 +99,10 @@
 	struct cam_vfe_bus_irq_evt_payload          evt_payload[
 		CAM_VFE_BUS_VER2_PAYLOAD_MAX];
 	struct list_head                            free_payload_list;
+	struct mutex                                bus_mutex;
+	uint32_t                                    secure_mode;
+	uint32_t                                    num_sec_out;
+	uint32_t                                    addr_no_sync;
 };
 
 struct cam_vfe_bus_ver2_wm_resource_data {
@@ -92,7 +112,8 @@
 	void                                *ctx;
 
 	uint32_t             irq_enabled;
-	uint32_t             init_cfg_done;
+	bool                 init_cfg_done;
+	bool                 hfr_cfg_done;
 
 	uint32_t             offset;
 	uint32_t             width;
@@ -102,7 +123,6 @@
 	enum cam_vfe_bus_packer_format pack_fmt;
 
 	uint32_t             burst_len;
-	uint32_t             frame_based;
 
 	uint32_t             en_ubwc;
 	uint32_t             packer_cfg;
@@ -119,6 +139,7 @@
 	uint32_t             framedrop_pattern;
 
 	uint32_t             en_cfg;
+	uint32_t             is_dual;
 };
 
 struct cam_vfe_bus_ver2_comp_grp_data {
@@ -134,6 +155,10 @@
 	uint32_t                         dual_slave_core;
 	uint32_t                         intra_client_mask;
 	uint32_t                         composite_mask;
+	uint32_t                         addr_sync_mode;
+
+	uint32_t                         acquire_dev_cnt;
+	uint32_t                         irq_trigger_cnt;
 
 	void                            *ctx;
 };
@@ -154,6 +179,7 @@
 	uint32_t                         max_width;
 	uint32_t                         max_height;
 	struct cam_cdm_utils_ops        *cdm_util_ops;
+	uint32_t                         secure_mode;
 };
 
 struct cam_vfe_bus_ver2_priv {
@@ -170,6 +196,10 @@
 	uint32_t                            irq_handle;
 };
 
+static int cam_vfe_bus_process_cmd(
+	struct cam_isp_resource_node *priv,
+	uint32_t cmd_type, void *cmd_args, uint32_t arg_size);
+
 static int cam_vfe_bus_get_evt_payload(
 	struct cam_vfe_bus_ver2_common_data  *common_data,
 	struct cam_vfe_bus_irq_evt_payload  **evt_payload)
@@ -186,6 +216,28 @@
 	return 0;
 }
 
+static enum cam_vfe_bus_comp_grp_id
+	cam_vfe_bus_comp_grp_id_convert(uint32_t comp_grp)
+{
+	switch (comp_grp) {
+	case CAM_ISP_RES_COMP_GROUP_ID_0:
+		return CAM_VFE_BUS_COMP_GROUP_ID_0;
+	case CAM_ISP_RES_COMP_GROUP_ID_1:
+		return CAM_VFE_BUS_COMP_GROUP_ID_1;
+	case CAM_ISP_RES_COMP_GROUP_ID_2:
+		return CAM_VFE_BUS_COMP_GROUP_ID_2;
+	case CAM_ISP_RES_COMP_GROUP_ID_3:
+		return CAM_VFE_BUS_COMP_GROUP_ID_3;
+	case CAM_ISP_RES_COMP_GROUP_ID_4:
+		return CAM_VFE_BUS_COMP_GROUP_ID_4;
+	case CAM_ISP_RES_COMP_GROUP_ID_5:
+		return CAM_VFE_BUS_COMP_GROUP_ID_5;
+	case CAM_ISP_RES_COMP_GROUP_NONE:
+	default:
+		return CAM_VFE_BUS_COMP_GROUP_NONE;
+	}
+}
+
 static int cam_vfe_bus_put_evt_payload(void     *core_info,
 	struct cam_vfe_bus_irq_evt_payload     **evt_payload)
 {
@@ -240,7 +292,7 @@
 	case CAM_VFE_BUS_VER2_VFE_CORE_0:
 		switch (dual_slave_core) {
 		case CAM_VFE_BUS_VER2_VFE_CORE_1:
-			*intra_client_mask = 0x1;
+			*intra_client_mask = 0x3;
 			break;
 		case CAM_VFE_BUS_VER2_VFE_CORE_2:
 			*intra_client_mask = 0x2;
@@ -292,6 +344,34 @@
 	return rc;
 }
 
+static bool cam_vfe_bus_can_be_secure(uint32_t out_type)
+{
+	switch (out_type) {
+	case CAM_VFE_BUS_VER2_VFE_OUT_FULL:
+	case CAM_VFE_BUS_VER2_VFE_OUT_DS4:
+	case CAM_VFE_BUS_VER2_VFE_OUT_DS16:
+	case CAM_VFE_BUS_VER2_VFE_OUT_FD:
+	case CAM_VFE_BUS_VER2_VFE_OUT_RAW_DUMP:
+	case CAM_VFE_BUS_VER2_VFE_OUT_RDI0:
+	case CAM_VFE_BUS_VER2_VFE_OUT_RDI1:
+	case CAM_VFE_BUS_VER2_VFE_OUT_RDI2:
+		return true;
+
+	case CAM_VFE_BUS_VER2_VFE_OUT_PDAF:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_BF:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_BHIST:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_RS:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_CS:
+	case CAM_VFE_BUS_VER2_VFE_OUT_STATS_IHIST:
+	default:
+		return false;
+	}
+}
+
 static enum cam_vfe_bus_ver2_vfe_out_type
 	cam_vfe_bus_get_out_res_id(uint32_t res_type)
 {
@@ -359,7 +439,6 @@
 		case CAM_FORMAT_DPCM_14_8_14:
 		case CAM_FORMAT_DPCM_14_10_14:
 		case CAM_FORMAT_PLAIN8:
-		case CAM_FORMAT_PLAIN16_8:
 		case CAM_FORMAT_PLAIN16_10:
 		case CAM_FORMAT_PLAIN16_12:
 		case CAM_FORMAT_PLAIN16_14:
@@ -656,8 +735,20 @@
 	case CAM_FORMAT_UBWC_NV12:
 	case CAM_FORMAT_UBWC_NV12_4R:
 		return PACKER_FMT_PLAIN_8_LSB_MSB_10;
+	case CAM_FORMAT_PLAIN16_16:
+		return PACKER_FMT_PLAIN_16_16BPP;
 	case CAM_FORMAT_PLAIN64:
 		return PACKER_FMT_PLAIN_64;
+	case CAM_FORMAT_PLAIN8:
+		return PACKER_FMT_PLAIN_8;
+	case CAM_FORMAT_PLAIN16_10:
+		return PACKER_FMT_PLAIN_16_10BPP;
+	case CAM_FORMAT_PLAIN16_12:
+		return PACKER_FMT_PLAIN_16_12BPP;
+	case CAM_FORMAT_PLAIN16_14:
+		return PACKER_FMT_PLAIN_16_14BPP;
+	case CAM_FORMAT_PLAIN32_20:
+		return PACKER_FMT_PLAIN_32_20BPP;
 	case CAM_FORMAT_MIPI_RAW_6:
 	case CAM_FORMAT_MIPI_RAW_8:
 	case CAM_FORMAT_MIPI_RAW_10:
@@ -665,20 +756,16 @@
 	case CAM_FORMAT_MIPI_RAW_14:
 	case CAM_FORMAT_MIPI_RAW_16:
 	case CAM_FORMAT_MIPI_RAW_20:
-	case CAM_FORMAT_PLAIN128:
-	case CAM_FORMAT_PLAIN8:
 	case CAM_FORMAT_PLAIN16_8:
-	case CAM_FORMAT_PLAIN16_10:
-	case CAM_FORMAT_PLAIN16_12:
-	case CAM_FORMAT_PLAIN16_14:
-	case CAM_FORMAT_PLAIN16_16:
-	case CAM_FORMAT_PLAIN32_20:
+	case CAM_FORMAT_PLAIN128:
 	case CAM_FORMAT_PD8:
 	case CAM_FORMAT_PD10:
 		return PACKER_FMT_PLAIN_128;
 	case CAM_FORMAT_UBWC_TP10:
 	case CAM_FORMAT_TP10:
 		return PACKER_FMT_TP_10;
+	case CAM_FORMAT_ARGB_14:
+		return PACKER_FMT_ARGB_14;
 	default:
 		return PACKER_FMT_MAX;
 	}
@@ -691,10 +778,10 @@
 	void                                  *ctx,
 	enum cam_vfe_bus_ver2_vfe_out_type     vfe_out_res_id,
 	enum cam_vfe_bus_plane_type            plane,
-	enum cam_isp_hw_split_id               split_id,
 	uint32_t                               subscribe_irq,
 	struct cam_isp_resource_node         **wm_res,
-	uint32_t                              *client_done_mask)
+	uint32_t                              *client_done_mask,
+	uint32_t                               is_dual)
 {
 	uint32_t wm_idx = 0;
 	struct cam_isp_resource_node              *wm_res_local = NULL;
@@ -723,14 +810,72 @@
 
 	rsrc_data->width = out_port_info->width;
 	rsrc_data->height = out_port_info->height;
+	rsrc_data->is_dual = is_dual;
+	/* Set WM offset value to default */
+	rsrc_data->offset  = 0;
+	CAM_DBG(CAM_ISP, "WM %d width %d height %d", rsrc_data->index,
+		rsrc_data->width, rsrc_data->height);
 
 	if (rsrc_data->index < 3) {
 		/* Write master 0-2 refers to RDI 0/ RDI 1/RDI 2 */
-		rsrc_data->width = CAM_VFE_RDI_BUS_DEFAULT_WIDTH;
-		rsrc_data->height = 0;
-		rsrc_data->stride = CAM_VFE_RDI_BUS_DEFAULT_STRIDE;
-		rsrc_data->pack_fmt = 0x0;
-		rsrc_data->en_cfg = 0x3;
+		switch (rsrc_data->format) {
+		case CAM_FORMAT_MIPI_RAW_6:
+		case CAM_FORMAT_MIPI_RAW_8:
+		case CAM_FORMAT_MIPI_RAW_10:
+		case CAM_FORMAT_MIPI_RAW_12:
+		case CAM_FORMAT_MIPI_RAW_14:
+		case CAM_FORMAT_MIPI_RAW_16:
+		case CAM_FORMAT_MIPI_RAW_20:
+		case CAM_FORMAT_PLAIN128:
+			rsrc_data->width = CAM_VFE_RDI_BUS_DEFAULT_WIDTH;
+			rsrc_data->height = 0;
+			rsrc_data->stride = CAM_VFE_RDI_BUS_DEFAULT_STRIDE;
+			rsrc_data->pack_fmt = 0x0;
+			rsrc_data->en_cfg = 0x3;
+			break;
+		case CAM_FORMAT_PLAIN8:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x1;
+			rsrc_data->width = rsrc_data->width * 2;
+			rsrc_data->stride = rsrc_data->width;
+			break;
+		case CAM_FORMAT_PLAIN16_10:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x2;
+			rsrc_data->width = rsrc_data->width * 2;
+			rsrc_data->stride = rsrc_data->width;
+			break;
+		case CAM_FORMAT_PLAIN16_12:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x3;
+			rsrc_data->width = rsrc_data->width * 2;
+			rsrc_data->stride = rsrc_data->width;
+			break;
+		case CAM_FORMAT_PLAIN16_14:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x4;
+			rsrc_data->width = rsrc_data->width * 2;
+			rsrc_data->stride = rsrc_data->width;
+			break;
+		case CAM_FORMAT_PLAIN16_16:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x5;
+			rsrc_data->width = rsrc_data->width * 2;
+			rsrc_data->stride = rsrc_data->width;
+			break;
+		case CAM_FORMAT_PLAIN32_20:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0x9;
+			break;
+		case CAM_FORMAT_PLAIN64:
+			rsrc_data->en_cfg = 0x1;
+			rsrc_data->pack_fmt = 0xA;
+			break;
+		default:
+			CAM_ERR(CAM_ISP, "Unsupported RDI format %d",
+				rsrc_data->format);
+			return -EINVAL;
+		}
 	} else if (rsrc_data->index < 5 ||
 		rsrc_data->index == 7 || rsrc_data->index == 8) {
 		/* Write master 3, 4 - for Full OUT , 7-8  FD OUT */
@@ -745,7 +890,7 @@
 			case PLANE_Y:
 				break;
 			default:
-				CAM_ERR(CAM_ISP, "Invalid plane %d\n", plane);
+				CAM_ERR(CAM_ISP, "Invalid plane %d", plane);
 				return -EINVAL;
 			}
 			break;
@@ -761,7 +906,7 @@
 			case PLANE_Y:
 				break;
 			default:
-				CAM_ERR(CAM_ISP, "Invalid plane %d\n", plane);
+				CAM_ERR(CAM_ISP, "Invalid plane %d", plane);
 				return -EINVAL;
 			}
 			break;
@@ -776,7 +921,7 @@
 			case PLANE_Y:
 				break;
 			default:
-				CAM_ERR(CAM_ISP, "Invalid plane %d\n", plane);
+				CAM_ERR(CAM_ISP, "Invalid plane %d", plane);
 				return -EINVAL;
 			}
 			break;
@@ -790,12 +935,12 @@
 			case PLANE_Y:
 				break;
 			default:
-				CAM_ERR(CAM_ISP, "Invalid plane %d\n", plane);
+				CAM_ERR(CAM_ISP, "Invalid plane %d", plane);
 				return -EINVAL;
 			}
 			break;
 		default:
-			CAM_ERR(CAM_ISP, "Invalid format %d\n",
+			CAM_ERR(CAM_ISP, "Invalid format %d",
 				rsrc_data->format);
 			return -EINVAL;
 		}
@@ -806,15 +951,17 @@
 		rsrc_data->height = 0;
 		rsrc_data->stride = 1;
 		rsrc_data->en_cfg = 0x3;
-	} else {
-		/* Write master 5-6 DS ports , 9 - Raw dump , 10 PDAF */
+	}  else if (rsrc_data->index == 9) {
+		/* Write master 9 - Raw dump */
+		rsrc_data->width = rsrc_data->width * 2;
+		rsrc_data->stride = rsrc_data->width;
+		rsrc_data->en_cfg = 0x1;
+	}  else {
+		/* Write master 5-6 DS ports, 10 PDAF */
 		rsrc_data->width = rsrc_data->width * 4;
 		rsrc_data->height = rsrc_data->height / 2;
 		rsrc_data->en_cfg = 0x1;
 	}
-	if (vfe_out_res_id >= CAM_ISP_IFE_OUT_RES_RDI_0 &&
-		vfe_out_res_id <= CAM_ISP_IFE_OUT_RES_RDI_3)
-		rsrc_data->frame_based = 1;
 
 	*client_done_mask = (1 << wm_idx);
 	*wm_res = wm_res_local;
@@ -836,7 +983,6 @@
 	rsrc_data->format = 0;
 	rsrc_data->pack_fmt = 0;
 	rsrc_data->burst_len = 0;
-	rsrc_data->frame_based = 0;
 	rsrc_data->irq_subsample_period = 0;
 	rsrc_data->irq_subsample_pattern = 0;
 	rsrc_data->framedrop_period = 0;
@@ -849,8 +995,10 @@
 	rsrc_data->ubwc_meta_stride = 0;
 	rsrc_data->ubwc_mode_cfg = 0;
 	rsrc_data->ubwc_meta_offset = 0;
-	rsrc_data->init_cfg_done = 0;
+	rsrc_data->init_cfg_done = false;
+	rsrc_data->hfr_cfg_done = false;
 	rsrc_data->en_cfg = 0;
+	rsrc_data->is_dual = 0;
 
 	wm_res->tasklet_info = NULL;
 	wm_res->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
@@ -965,7 +1113,7 @@
 
 	wm_res = th_payload->handler_priv;
 	if (!wm_res) {
-		CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! No resource\n");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Error: No resource");
 		return -ENODEV;
 	}
 
@@ -977,7 +1125,7 @@
 	rc  = cam_vfe_bus_get_evt_payload(rsrc_data->common_data, &evt_payload);
 	if (rc) {
 		CAM_ERR_RATE_LIMIT(CAM_ISP,
-			"No tasklet_cmd is free in queue\n");
+			"No tasklet_cmd is free in queue");
 		return rc;
 	}
 
@@ -1074,10 +1222,8 @@
 
 	rsrc_data = wm_res->res_priv;
 	wm_res->res_priv = NULL;
-	if (!rsrc_data) {
-		CAM_ERR(CAM_ISP, "Error! WM res priv is NULL");
+	if (!rsrc_data)
 		return -ENOMEM;
-	}
 	kfree(rsrc_data);
 
 	return 0;
@@ -1127,16 +1273,23 @@
 	struct cam_isp_resource_node       **comp_grp)
 {
 	int rc = 0;
+	uint32_t bus_comp_grp_id;
 	struct cam_isp_resource_node           *comp_grp_local = NULL;
 	struct cam_vfe_bus_ver2_comp_grp_data  *rsrc_data = NULL;
 
-	/* Check if matching comp_grp already acquired */
-	cam_vfe_bus_match_comp_grp(ver2_bus_priv, &comp_grp_local,
-		out_port_info->comp_grp_id, unique_id);
+	bus_comp_grp_id = cam_vfe_bus_comp_grp_id_convert(
+		out_port_info->comp_grp_id);
+	/* Perform match only if there is valid comp grp request */
+	if (out_port_info->comp_grp_id != CAM_ISP_RES_COMP_GROUP_NONE) {
+		/* Check if matching comp_grp already acquired */
+		cam_vfe_bus_match_comp_grp(ver2_bus_priv, &comp_grp_local,
+			bus_comp_grp_id, unique_id);
+	}
 
 	if (!comp_grp_local) {
 		/* First find a free group */
 		if (is_dual) {
+			CAM_DBG(CAM_ISP, "Acquire dual comp group");
 			if (list_empty(&ver2_bus_priv->free_dual_comp_grp)) {
 				CAM_ERR(CAM_ISP, "No Free Composite Group");
 				return -ENODEV;
@@ -1149,7 +1302,10 @@
 				dual_slave_core,
 				comp_grp_local->hw_intf->hw_idx,
 				&rsrc_data->intra_client_mask);
+			if (rc)
+				return rc;
 		} else {
+			CAM_DBG(CAM_ISP, "Acquire comp group");
 			if (list_empty(&ver2_bus_priv->free_comp_grp)) {
 				CAM_ERR(CAM_ISP, "No Free Composite Group");
 				return -ENODEV;
@@ -1167,7 +1323,12 @@
 		rsrc_data->is_master = is_master;
 		rsrc_data->composite_mask = 0;
 		rsrc_data->unique_id = unique_id;
-		rsrc_data->comp_grp_local_idx = out_port_info->comp_grp_id;
+		rsrc_data->comp_grp_local_idx = bus_comp_grp_id;
+
+		if (is_master)
+			rsrc_data->addr_sync_mode = 0;
+		else
+			rsrc_data->addr_sync_mode = 1;
 
 		list_add_tail(&comp_grp_local->list,
 			&ver2_bus_priv->used_comp_grp);
@@ -1184,7 +1345,10 @@
 		}
 	}
 
+	CAM_DBG(CAM_ISP, "Comp Grp type %u", rsrc_data->comp_grp_type);
+
 	rsrc_data->ctx = ctx;
+	rsrc_data->acquire_dev_cnt++;
 	*comp_grp = comp_grp_local;
 
 	return rc;
@@ -1199,16 +1363,23 @@
 	int match_found = 0;
 
 	if (!in_comp_grp) {
-		CAM_ERR(CAM_ISP, "Invalid Params Comp Grp %pK", in_rsrc_data);
+		CAM_ERR(CAM_ISP, "Invalid Params Comp Grp %pK", in_comp_grp);
 		return -EINVAL;
 	}
 
 	if (in_comp_grp->res_state == CAM_ISP_RESOURCE_STATE_AVAILABLE) {
-		/* Already Released. Do Nothing */
+		CAM_ERR(CAM_ISP, "Already released Comp Grp");
 		return 0;
 	}
 
+	if (in_comp_grp->res_state == CAM_ISP_RESOURCE_STATE_STREAMING) {
+		CAM_ERR(CAM_ISP, "Invalid State %d",
+			in_comp_grp->res_state);
+		return -EBUSY;
+	}
+
 	in_rsrc_data = in_comp_grp->res_priv;
+	CAM_DBG(CAM_ISP, "Comp Grp type %u", in_rsrc_data->comp_grp_type);
 
 	list_for_each_entry(comp_grp, &ver2_bus_priv->used_comp_grp, list) {
 		if (comp_grp == in_comp_grp) {
@@ -1223,23 +1394,32 @@
 		return -ENODEV;
 	}
 
+	in_rsrc_data->acquire_dev_cnt--;
+	if (in_rsrc_data->acquire_dev_cnt == 0) {
+		list_del(&comp_grp->list);
 
-	list_del(&comp_grp->list);
-	if (in_rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
-		in_rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5)
-		list_add_tail(&comp_grp->list,
-			&ver2_bus_priv->free_dual_comp_grp);
-	else if (in_rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_0
-		&& in_rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_5)
-		list_add_tail(&comp_grp->list, &ver2_bus_priv->free_comp_grp);
+		in_rsrc_data->unique_id = 0;
+		in_rsrc_data->comp_grp_local_idx = CAM_VFE_BUS_COMP_GROUP_NONE;
+		in_rsrc_data->composite_mask = 0;
+		in_rsrc_data->dual_slave_core = CAM_VFE_BUS_VER2_VFE_CORE_MAX;
+		in_rsrc_data->addr_sync_mode = 0;
 
-	in_rsrc_data->unique_id = 0;
-	in_rsrc_data->comp_grp_local_idx = 0;
-	in_rsrc_data->composite_mask = 0;
-	in_rsrc_data->dual_slave_core = CAM_VFE_BUS_VER2_VFE_CORE_MAX;
+		comp_grp->tasklet_info = NULL;
+		comp_grp->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
 
-	comp_grp->tasklet_info = NULL;
-	comp_grp->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
+		if (in_rsrc_data->comp_grp_type >=
+			CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
+			in_rsrc_data->comp_grp_type <=
+			CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5)
+			list_add_tail(&comp_grp->list,
+				&ver2_bus_priv->free_dual_comp_grp);
+		else if (in_rsrc_data->comp_grp_type >=
+			CAM_VFE_BUS_VER2_COMP_GRP_0 &&
+			in_rsrc_data->comp_grp_type <=
+			CAM_VFE_BUS_VER2_COMP_GRP_5)
+			list_add_tail(&comp_grp->list,
+				&ver2_bus_priv->free_comp_grp);
+	}
 
 	return 0;
 }
@@ -1247,55 +1427,103 @@
 static int cam_vfe_bus_start_comp_grp(struct cam_isp_resource_node *comp_grp)
 {
 	int rc = 0;
+	uint32_t addr_sync_cfg;
 	struct cam_vfe_bus_ver2_comp_grp_data      *rsrc_data =
 		comp_grp->res_priv;
 	struct cam_vfe_bus_ver2_common_data        *common_data =
 		rsrc_data->common_data;
 	uint32_t bus_irq_reg_mask[CAM_VFE_BUS_IRQ_MAX] = {0};
 
+	CAM_DBG(CAM_ISP, "comp group id:%d streaming state:%d",
+		rsrc_data->comp_grp_type, comp_grp->res_state);
+
 	cam_io_w_mb(rsrc_data->composite_mask, common_data->mem_base +
 		rsrc_data->hw_regs->comp_mask);
+	if (comp_grp->res_state == CAM_ISP_RESOURCE_STATE_STREAMING)
+		return 0;
 
 	CAM_DBG(CAM_ISP, "composite_mask is 0x%x", rsrc_data->composite_mask);
 	CAM_DBG(CAM_ISP, "composite_mask addr 0x%x",
 		rsrc_data->hw_regs->comp_mask);
 
 	if (rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
-		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5 &&
-		rsrc_data->is_master) {
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5) {
 		int dual_comp_grp = (rsrc_data->comp_grp_type -
 			CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0);
-		int intra_client_en = cam_io_r_mb(common_data->mem_base +
-			common_data->common_reg->dual_master_comp_cfg);
 
-		/* 2 Bits per comp_grp. Hence left shift by comp_grp * 2 */
-		intra_client_en |=
-			(rsrc_data->intra_client_mask << dual_comp_grp * 2);
+		if (rsrc_data->is_master) {
+			int intra_client_en = cam_io_r_mb(
+				common_data->mem_base +
+				common_data->common_reg->dual_master_comp_cfg);
 
-		cam_io_w_mb(intra_client_en, common_data->mem_base +
-			common_data->common_reg->dual_master_comp_cfg);
+			/*
+			 * 2 Bits per comp_grp. Hence left shift by
+			 * comp_grp * 2
+			 */
+			intra_client_en |=
+				(rsrc_data->intra_client_mask <<
+					(dual_comp_grp * 2));
 
-		bus_irq_reg_mask[CAM_VFE_BUS_IRQ_REG2] = (1 << dual_comp_grp);
+			cam_io_w_mb(intra_client_en, common_data->mem_base +
+				common_data->common_reg->dual_master_comp_cfg);
+
+			bus_irq_reg_mask[CAM_VFE_BUS_IRQ_REG2] =
+				(1 << dual_comp_grp);
+		}
+
+		CAM_DBG(CAM_ISP, "addr_sync_mask addr 0x%x",
+			rsrc_data->hw_regs->addr_sync_mask);
+		cam_io_w_mb(rsrc_data->composite_mask, common_data->mem_base +
+			rsrc_data->hw_regs->addr_sync_mask);
+
+		addr_sync_cfg = cam_io_r_mb(common_data->mem_base +
+			common_data->common_reg->addr_sync_cfg);
+		addr_sync_cfg |= (rsrc_data->addr_sync_mode << dual_comp_grp);
+		/*
+		 * 2 Bits per dual_comp_grp. dual_comp_grp stats at bit number
+		 * 8. Hence left shift cdual_comp_grp dual comp_grp * 2 and
+		 * add 8
+		 */
+		addr_sync_cfg |=
+			(rsrc_data->intra_client_mask <<
+				((dual_comp_grp * 2) +
+				CAM_VFE_BUS_ADDR_SYNC_INTRA_CLIENT_SHIFT));
+		cam_io_w_mb(addr_sync_cfg, common_data->mem_base +
+			common_data->common_reg->addr_sync_cfg);
+
+		common_data->addr_no_sync &= ~(rsrc_data->composite_mask);
+		cam_io_w_mb(common_data->addr_no_sync, common_data->mem_base +
+			common_data->common_reg->addr_sync_no_sync);
+		CAM_DBG(CAM_ISP, "addr_sync_cfg: 0x%x addr_no_sync_cfg: 0x%x",
+			addr_sync_cfg, common_data->addr_no_sync);
 	} else {
 		/* IRQ bits for COMP GRP start at 5. So add 5 to the shift */
 		bus_irq_reg_mask[CAM_VFE_BUS_IRQ_REG0] =
 			(1 << (rsrc_data->comp_grp_type + 5));
 	}
 
-	/* Subscribe IRQ */
+	/*
+	 * For Dual composite subscribe IRQ only for master
+	 * For regular composite, subscribe IRQ always
+	 */
 	CAM_DBG(CAM_ISP, "Subscribe COMP_GRP%d IRQ", rsrc_data->comp_grp_type);
-	comp_grp->irq_handle = cam_irq_controller_subscribe_irq(
-		common_data->bus_irq_controller, CAM_IRQ_PRIORITY_1,
-		bus_irq_reg_mask, comp_grp,
-		comp_grp->top_half_handler,
-		cam_ife_mgr_do_tasklet_buf_done,
-		comp_grp->tasklet_info, cam_tasklet_enqueue_cmd);
-	if (comp_grp->irq_handle < 0) {
-		CAM_ERR(CAM_ISP, "Subscribe IRQ failed for comp_grp %d",
-			rsrc_data->comp_grp_type);
-		return -EFAULT;
+	if (((rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5) &&
+		(rsrc_data->is_master)) ||
+		(rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_0 &&
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_5)) {
+		comp_grp->irq_handle = cam_irq_controller_subscribe_irq(
+			common_data->bus_irq_controller, CAM_IRQ_PRIORITY_1,
+			bus_irq_reg_mask, comp_grp,
+			comp_grp->top_half_handler,
+			cam_ife_mgr_do_tasklet_buf_done,
+			comp_grp->tasklet_info, cam_tasklet_enqueue_cmd);
+		if (comp_grp->irq_handle < 0) {
+			CAM_ERR(CAM_ISP, "Subscribe IRQ failed for comp_grp %d",
+				rsrc_data->comp_grp_type);
+			return -EFAULT;
+		}
 	}
-
 	comp_grp->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
 
 	return rc;
@@ -1304,32 +1532,65 @@
 static int cam_vfe_bus_stop_comp_grp(struct cam_isp_resource_node *comp_grp)
 {
 	int rc = 0;
+	uint32_t addr_sync_cfg;
 	struct cam_vfe_bus_ver2_comp_grp_data      *rsrc_data =
 		comp_grp->res_priv;
 	struct cam_vfe_bus_ver2_common_data        *common_data =
 		rsrc_data->common_data;
 
 	/* Unsubscribe IRQ */
-	rc = cam_irq_controller_unsubscribe_irq(
-		common_data->bus_irq_controller,
-		comp_grp->irq_handle);
+	if (((rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5) &&
+		(rsrc_data->is_master)) ||
+		(rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_0 &&
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_5)) {
+		rc = cam_irq_controller_unsubscribe_irq(
+			common_data->bus_irq_controller,
+			comp_grp->irq_handle);
+	}
 
 	cam_io_w_mb(rsrc_data->composite_mask, common_data->mem_base +
 		rsrc_data->hw_regs->comp_mask);
 	if (rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
-		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5 &&
-		rsrc_data->is_master) {
+		rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5) {
+
 		int dual_comp_grp = (rsrc_data->comp_grp_type -
 			CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0);
-		int intra_client_en = cam_io_r_mb(common_data->mem_base +
-			common_data->common_reg->dual_master_comp_cfg);
 
-		/* 2 Bits per comp_grp. Hence left shift by comp_grp * 2 */
-		intra_client_en &=
-			~(rsrc_data->intra_client_mask << dual_comp_grp * 2);
+		if (rsrc_data->is_master) {
+			int intra_client_en = cam_io_r_mb(
+				common_data->mem_base +
+				common_data->common_reg->dual_master_comp_cfg);
 
-		cam_io_w_mb(intra_client_en, common_data->mem_base +
-			common_data->common_reg->dual_master_comp_cfg);
+			/*
+			 * 2 Bits per comp_grp. Hence left shift by
+			 * comp_grp * 2
+			 */
+			intra_client_en &=
+				~(rsrc_data->intra_client_mask <<
+					dual_comp_grp * 2);
+
+			cam_io_w_mb(intra_client_en, common_data->mem_base +
+				common_data->common_reg->dual_master_comp_cfg);
+		}
+
+		addr_sync_cfg = cam_io_r_mb(common_data->mem_base +
+			common_data->common_reg->addr_sync_cfg);
+		addr_sync_cfg &= ~(1 << dual_comp_grp);
+		addr_sync_cfg &= ~(CAM_VFE_BUS_INTRA_CLIENT_MASK <<
+			((dual_comp_grp * 2) +
+			CAM_VFE_BUS_ADDR_SYNC_INTRA_CLIENT_SHIFT));
+		cam_io_w_mb(addr_sync_cfg, common_data->mem_base +
+			common_data->common_reg->addr_sync_cfg);
+
+		cam_io_w_mb(0, common_data->mem_base +
+			rsrc_data->hw_regs->addr_sync_mask);
+		common_data->addr_no_sync |= rsrc_data->composite_mask;
+		cam_io_w_mb(common_data->addr_no_sync, common_data->mem_base +
+			common_data->common_reg->addr_sync_no_sync);
+		CAM_DBG(CAM_ISP, "addr_sync_cfg: 0x% addr_no_sync_cfg: 0x%x",
+			addr_sync_cfg, common_data->addr_no_sync);
+
 	}
 
 	comp_grp->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
@@ -1348,7 +1609,7 @@
 
 	comp_grp = th_payload->handler_priv;
 	if (!comp_grp) {
-		CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! No resource\n");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "No resource");
 		return -ENODEV;
 	}
 
@@ -1356,11 +1617,12 @@
 
 	CAM_DBG(CAM_ISP, "IRQ status_0 = %x", th_payload->evt_status_arr[0]);
 	CAM_DBG(CAM_ISP, "IRQ status_1 = %x", th_payload->evt_status_arr[1]);
+	CAM_DBG(CAM_ISP, "IRQ status_2 = %x", th_payload->evt_status_arr[2]);
 
 	rc  = cam_vfe_bus_get_evt_payload(rsrc_data->common_data, &evt_payload);
 	if (rc) {
 		CAM_ERR_RATE_LIMIT(CAM_ISP,
-			"No tasklet_cmd is free in queue\n");
+			"No tasklet_cmd is free in queue");
 		return rc;
 	}
 
@@ -1430,8 +1692,13 @@
 
 		/* Regular Composite SUCCESS */
 		if (status_reg & BIT(comp_grp_id + 5)) {
-			cam_ife_irq_regs[CAM_IFE_IRQ_BUS_REG_STATUS0] &=
-				~BIT(comp_grp_id + 5);
+			rsrc_data->irq_trigger_cnt++;
+			if (rsrc_data->irq_trigger_cnt ==
+				rsrc_data->acquire_dev_cnt) {
+				cam_ife_irq_regs[CAM_IFE_IRQ_BUS_REG_STATUS0] &=
+					~BIT(comp_grp_id + 5);
+				rsrc_data->irq_trigger_cnt = 0;
+			}
 			rc = CAM_VFE_IRQ_STATUS_SUCCESS;
 		}
 
@@ -1469,15 +1736,20 @@
 
 		/* DUAL Composite SUCCESS */
 		if (status_reg & BIT(comp_grp_id)) {
-			cam_ife_irq_regs[CAM_IFE_IRQ_BUS_REG_STATUS2] &=
-				~BIT(comp_grp_id + 5);
+			rsrc_data->irq_trigger_cnt++;
+			if (rsrc_data->irq_trigger_cnt ==
+				rsrc_data->acquire_dev_cnt) {
+				cam_ife_irq_regs[CAM_IFE_IRQ_BUS_REG_STATUS2] &=
+					~BIT(comp_grp_id);
+				rsrc_data->irq_trigger_cnt = 0;
+			}
 			rc = CAM_VFE_IRQ_STATUS_SUCCESS;
 		}
 
 		break;
 	default:
 		rc = CAM_VFE_IRQ_STATUS_ERR;
-		CAM_ERR(CAM_ISP, "Error! Invalid comp_grp_type %u",
+		CAM_ERR(CAM_ISP, "Invalid comp_grp_type %u",
 			rsrc_data->comp_grp_type);
 		break;
 	}
@@ -1498,10 +1770,9 @@
 
 	rsrc_data = kzalloc(sizeof(struct cam_vfe_bus_ver2_comp_grp_data),
 		GFP_KERNEL);
-	if (!rsrc_data) {
-		CAM_DBG(CAM_ISP, "Failed to alloc for comp_grp_priv");
+	if (!rsrc_data)
 		return -ENOMEM;
-	}
+
 	comp_grp->res_priv = rsrc_data;
 
 	comp_grp->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
@@ -1548,7 +1819,7 @@
 	comp_grp->res_priv = NULL;
 
 	if (!rsrc_data) {
-		CAM_ERR(CAM_ISP, "Error! comp_grp_priv is NULL");
+		CAM_ERR(CAM_ISP, "comp_grp_priv is NULL");
 		return -ENODEV;
 	}
 	kfree(rsrc_data);
@@ -1556,6 +1827,22 @@
 	return 0;
 }
 
+static int cam_vfe_bus_get_secure_mode(void *priv, void *cmd_args,
+	uint32_t arg_size)
+{
+	bool *mode = cmd_args;
+	struct cam_isp_resource_node *res =
+		(struct cam_isp_resource_node *) priv;
+	struct cam_vfe_bus_ver2_vfe_out_data *rsrc_data =
+		(struct cam_vfe_bus_ver2_vfe_out_data *)res->res_priv;
+
+	*mode =
+		(rsrc_data->secure_mode == CAM_SECURE_MODE_SECURE) ?
+		true : false;
+
+	return 0;
+}
+
 static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
 	uint32_t args_size)
 {
@@ -1563,7 +1850,7 @@
 	int                                     i;
 	enum cam_vfe_bus_ver2_vfe_out_type      vfe_out_res_id;
 	uint32_t                                format;
-	uint32_t                                num_wm;
+	int                                     num_wm;
 	uint32_t                                subscribe_irq;
 	uint32_t                                client_done_mask;
 	struct cam_vfe_bus_ver2_priv           *ver2_bus_priv = bus_priv;
@@ -1571,6 +1858,7 @@
 	struct cam_vfe_hw_vfe_out_acquire_args *out_acquire_args;
 	struct cam_isp_resource_node           *rsrc_node = NULL;
 	struct cam_vfe_bus_ver2_vfe_out_data   *rsrc_data = NULL;
+	uint32_t                                secure_caps = 0, mode;
 
 	if (!bus_priv || !acquire_args) {
 		CAM_ERR(CAM_ISP, "Invalid Param");
@@ -1600,6 +1888,33 @@
 	}
 
 	rsrc_data = rsrc_node->res_priv;
+	secure_caps = cam_vfe_bus_can_be_secure(
+		rsrc_data->out_type);
+	mode = out_acquire_args->out_port_info->secure_mode;
+	mutex_lock(&rsrc_data->common_data->bus_mutex);
+	if (secure_caps) {
+		if (!rsrc_data->common_data->num_sec_out) {
+			rsrc_data->secure_mode = mode;
+			rsrc_data->common_data->secure_mode = mode;
+		} else {
+			if (mode == rsrc_data->common_data->secure_mode) {
+				rsrc_data->secure_mode =
+					rsrc_data->common_data->secure_mode;
+			} else {
+				rc = -EINVAL;
+				CAM_ERR_RATE_LIMIT(CAM_ISP,
+					"Mismatch: Acquire mode[%d], drvr mode[%d]",
+					rsrc_data->common_data->secure_mode,
+					mode);
+				mutex_unlock(
+					&rsrc_data->common_data->bus_mutex);
+				return -EINVAL;
+			}
+		}
+		rsrc_data->common_data->num_sec_out++;
+	}
+	mutex_unlock(&rsrc_data->common_data->bus_mutex);
+
 	rsrc_data->num_wm = num_wm;
 	rsrc_node->res_id = out_acquire_args->out_port_info->res_type;
 	rsrc_node->tasklet_info = acq_args->tasklet;
@@ -1607,10 +1922,12 @@
 	rsrc_data->cdm_util_ops = out_acquire_args->cdm_ops;
 
 	/* Reserve Composite Group */
-	if (num_wm > 1 || (out_acquire_args->out_port_info->comp_grp_id >
-		CAM_ISP_RES_COMP_GROUP_NONE &&
-		out_acquire_args->out_port_info->comp_grp_id <
-		CAM_ISP_RES_COMP_GROUP_ID_MAX)) {
+		if (num_wm > 1 || (out_acquire_args->is_dual) ||
+			(out_acquire_args->out_port_info->comp_grp_id >
+			CAM_ISP_RES_COMP_GROUP_NONE &&
+			out_acquire_args->out_port_info->comp_grp_id <
+			CAM_ISP_RES_COMP_GROUP_ID_MAX)) {
+
 		rc = cam_vfe_bus_acquire_comp_grp(ver2_bus_priv,
 			out_acquire_args->out_port_info,
 			acq_args->tasklet,
@@ -1641,10 +1958,10 @@
 			out_acquire_args->ctx,
 			vfe_out_res_id,
 			i,
-			out_acquire_args->split_id,
 			subscribe_irq,
 			&rsrc_data->wm_res[i],
-			&client_done_mask);
+			&client_done_mask,
+			out_acquire_args->is_dual);
 		if (rc) {
 			CAM_ERR(CAM_ISP,
 				"VFE%d WM acquire failed for Out %d rc=%d",
@@ -1680,6 +1997,7 @@
 	uint32_t i;
 	struct cam_isp_resource_node          *vfe_out = NULL;
 	struct cam_vfe_bus_ver2_vfe_out_data  *rsrc_data = NULL;
+	uint32_t                               secure_caps = 0;
 
 	if (!bus_priv || !release_args) {
 		CAM_ERR(CAM_ISP, "Invalid input bus_priv %pK release_args %pK",
@@ -1691,7 +2009,7 @@
 	rsrc_data = vfe_out->res_priv;
 
 	if (vfe_out->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
-		CAM_ERR(CAM_ISP, "Error! Invalid resource state:%d",
+		CAM_ERR(CAM_ISP, "Invalid resource state:%d",
 			vfe_out->res_state);
 	}
 
@@ -1707,6 +2025,32 @@
 	vfe_out->cdm_ops = NULL;
 	rsrc_data->cdm_util_ops = NULL;
 
+	secure_caps = cam_vfe_bus_can_be_secure(rsrc_data->out_type);
+	mutex_lock(&rsrc_data->common_data->bus_mutex);
+	if (secure_caps) {
+		if (rsrc_data->secure_mode ==
+			rsrc_data->common_data->secure_mode) {
+			rsrc_data->common_data->num_sec_out--;
+			rsrc_data->secure_mode =
+				CAM_SECURE_MODE_NON_SECURE;
+		} else {
+			/*
+			 * The validity of the mode is properly
+			 * checked while acquiring the output port.
+			 * not expected to reach here, unless there is
+			 * some corruption.
+			 */
+			CAM_ERR(CAM_ISP, "driver[%d],resource[%d] mismatch",
+				rsrc_data->common_data->secure_mode,
+				rsrc_data->secure_mode);
+		}
+
+		if (!rsrc_data->common_data->num_sec_out)
+			rsrc_data->common_data->secure_mode =
+				CAM_SECURE_MODE_NON_SECURE;
+	}
+	mutex_unlock(&rsrc_data->common_data->bus_mutex);
+
 	if (vfe_out->res_state == CAM_ISP_RESOURCE_STATE_RESERVED)
 		vfe_out->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
 
@@ -1731,7 +2075,7 @@
 	CAM_DBG(CAM_ISP, "Start resource index %d", rsrc_data->out_type);
 
 	if (vfe_out->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
-		CAM_ERR(CAM_ISP, "Error! Invalid resource state:%d",
+		CAM_ERR(CAM_ISP, "Invalid resource state:%d",
 			vfe_out->res_state);
 		return -EACCES;
 	}
@@ -1742,28 +2086,6 @@
 	if (rsrc_data->comp_grp)
 		rc = cam_vfe_bus_start_comp_grp(rsrc_data->comp_grp);
 
-	/* BUS_WR_INPUT_IF_ADDR_SYNC_CFG */
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x0000207C);
-	/*  BUS_WR_INPUT_IF_ADDR_SYNC_FRAME_HEADER */
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x00002080);
-	/* BUS_WR_INPUT_IF_ADDR_SYNC_NO_SYNC */
-	cam_io_w_mb(0xFFFFF, rsrc_data->common_data->mem_base + 0x00002084);
-	/*  BUS_WR_INPUT_IF_ADDR_SYNC_0 */
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x00002088);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x0000208c);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x00002090);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x00002094);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x00002098);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x0000209c);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x000020a0);
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x000020a4);
-
-	/* no clock gating at bus input */
-	cam_io_w_mb(0xFFFFF, rsrc_data->common_data->mem_base + 0x0000200C);
-
-	/* BUS_WR_TEST_BUS_CTRL */
-	cam_io_w_mb(0x0, rsrc_data->common_data->mem_base + 0x0000211C);
-
 	vfe_out->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
 	return rc;
 }
@@ -1792,7 +2114,6 @@
 	for (i = 0; i < rsrc_data->num_wm; i++)
 		rc = cam_vfe_bus_stop_wm(rsrc_data->wm_res[i]);
 
-
 	vfe_out->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 	return rc;
 }
@@ -1838,7 +2159,6 @@
 	rsrc_data = kzalloc(sizeof(struct cam_vfe_bus_ver2_vfe_out_data),
 		GFP_KERNEL);
 	if (!rsrc_data) {
-		CAM_DBG(CAM_ISP, "Error! Failed to alloc for vfe out priv");
 		rc = -ENOMEM;
 		return rc;
 	}
@@ -1854,12 +2174,14 @@
 		ver2_hw_info->vfe_out_hw_info[index].max_width;
 	rsrc_data->max_height  =
 		ver2_hw_info->vfe_out_hw_info[index].max_height;
+	rsrc_data->secure_mode = CAM_SECURE_MODE_NON_SECURE;
 
 	vfe_out->start = cam_vfe_bus_start_vfe_out;
 	vfe_out->stop = cam_vfe_bus_stop_vfe_out;
 	vfe_out->top_half_handler = cam_vfe_bus_handle_vfe_out_done_top_half;
 	vfe_out->bottom_half_handler =
 		cam_vfe_bus_handle_vfe_out_done_bottom_half;
+	vfe_out->process_cmd = cam_vfe_bus_process_cmd;
 	vfe_out->hw_intf = ver2_bus_priv->common_data.hw_intf;
 
 	return 0;
@@ -1880,10 +2202,8 @@
 	INIT_LIST_HEAD(&vfe_out->list);
 	vfe_out->res_priv = NULL;
 
-	if (!rsrc_data) {
-		CAM_ERR(CAM_ISP, "Error! vfe out priv is NULL");
+	if (!rsrc_data)
 		return -ENOMEM;
-	}
 	kfree(rsrc_data);
 
 	return 0;
@@ -1912,11 +2232,6 @@
 	uint32_t  i, j, size = 0;
 	uint32_t  frame_inc = 0;
 
-	/*
-	 * Need the entire buf io config so we can get the stride info
-	 * for the wm.
-	 */
-
 	bus_priv = (struct cam_vfe_bus_ver2_priv  *) priv;
 	update_buf =  (struct cam_isp_hw_get_buf_update *) cmd_args;
 
@@ -1948,6 +2263,12 @@
 
 		wm_data = vfe_out_data->wm_res[i]->res_priv;
 
+		/* update width register */
+		CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+			wm_data->hw_regs->buffer_width_cfg,
+			wm_data->width);
+		CAM_DBG(CAM_ISP, "image width 0x%x", wm_data->width);
+
 		/* For initial configuration program all bus registers */
 		if ((wm_data->stride != io_cfg->planes[i].plane_stride ||
 			!wm_data->init_cfg_done) && (wm_data->index >= 3)) {
@@ -1959,7 +2280,7 @@
 		CAM_DBG(CAM_ISP, "image stride 0x%x", wm_data->stride);
 
 		if (wm_data->framedrop_pattern != io_cfg->framedrop_pattern ||
-			!wm_data->init_cfg_done) {
+			!wm_data->hfr_cfg_done) {
 			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 				wm_data->hw_regs->framedrop_pattern,
 				io_cfg->framedrop_pattern);
@@ -1969,7 +2290,7 @@
 			wm_data->framedrop_pattern);
 
 		if (wm_data->framedrop_period != io_cfg->framedrop_period ||
-			!wm_data->init_cfg_done) {
+			!wm_data->hfr_cfg_done) {
 			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 				wm_data->hw_regs->framedrop_period,
 				io_cfg->framedrop_period);
@@ -1979,7 +2300,7 @@
 			wm_data->framedrop_period);
 
 		if (wm_data->irq_subsample_period != io_cfg->subsample_period
-			|| !wm_data->init_cfg_done) {
+			|| !wm_data->hfr_cfg_done) {
 			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 				wm_data->hw_regs->irq_subsample_period,
 				io_cfg->subsample_period);
@@ -1990,7 +2311,7 @@
 			wm_data->irq_subsample_period);
 
 		if (wm_data->irq_subsample_pattern != io_cfg->subsample_pattern
-			|| !wm_data->init_cfg_done) {
+			|| !wm_data->hfr_cfg_done) {
 			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 				wm_data->hw_regs->irq_subsample_pattern,
 				io_cfg->subsample_pattern);
@@ -2018,7 +2339,12 @@
 			CAM_DBG(CAM_ISP, "packer cfg 0x%x",
 				wm_data->packer_cfg);
 
-			if (wm_data->tile_cfg != io_cfg->planes[i].tile_config
+			if (wm_data->is_dual) {
+				CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+					wm_data->hw_regs->ubwc_regs->tile_cfg,
+					wm_data->tile_cfg);
+			} else if ((wm_data->tile_cfg !=
+				io_cfg->planes[i].tile_config)
 				|| !wm_data->init_cfg_done) {
 				CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 					wm_data->hw_regs->ubwc_regs->tile_cfg,
@@ -2028,7 +2354,22 @@
 			}
 			CAM_DBG(CAM_ISP, "tile cfg 0x%x", wm_data->tile_cfg);
 
-			if (wm_data->h_init != io_cfg->planes[i].h_init ||
+			if (wm_data->is_dual) {
+				if ((wm_data->h_init != wm_data->offset) ||
+					!wm_data->init_cfg_done) {
+				/*
+				 * For dual ife h init value need to take from
+				 * offset.Striping config update offset value
+				 */
+					CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair,
+						j,
+						wm_data->hw_regs->ubwc_regs->
+						h_init,
+						wm_data->offset);
+					wm_data->h_init = wm_data->offset;
+				}
+			} else if (wm_data->h_init !=
+				io_cfg->planes[i].h_init ||
 				!wm_data->init_cfg_done) {
 				CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
 					wm_data->hw_regs->ubwc_regs->h_init,
@@ -2100,8 +2441,9 @@
 				io_cfg->planes[i].meta_size));
 		else
 			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
-				wm_data->hw_regs->image_addr,
-				update_buf->image_buf[i]);
+			wm_data->hw_regs->image_addr,
+			update_buf->image_buf[i] +
+			wm_data->offset);
 
 		CAM_DBG(CAM_ISP, "image address 0x%x", reg_val_pair[j-1]);
 
@@ -2117,7 +2459,7 @@
 
 		/* set initial configuration done */
 		if (!wm_data->init_cfg_done)
-			wm_data->init_cfg_done = 1;
+			wm_data->init_cfg_done = true;
 	}
 
 	size = vfe_out_data->cdm_util_ops->cdm_required_size_reg_random(j/2);
@@ -2139,6 +2481,152 @@
 	return 0;
 }
 
+static int cam_vfe_bus_update_hfr(void *priv, void *cmd_args,
+	uint32_t arg_size)
+{
+	struct cam_vfe_bus_ver2_priv             *bus_priv;
+	struct cam_isp_hw_get_hfr_update         *update_hfr;
+	struct cam_vfe_bus_ver2_vfe_out_data     *vfe_out_data = NULL;
+	struct cam_vfe_bus_ver2_wm_resource_data *wm_data = NULL;
+	struct cam_isp_port_hfr_config           *hfr_cfg = NULL;
+	uint32_t *reg_val_pair;
+	uint32_t  i, j, size = 0;
+
+	bus_priv = (struct cam_vfe_bus_ver2_priv  *) priv;
+	update_hfr =  (struct cam_isp_hw_get_hfr_update *) cmd_args;
+
+	vfe_out_data = (struct cam_vfe_bus_ver2_vfe_out_data *)
+		update_hfr->cdm.res->res_priv;
+
+	if (!vfe_out_data || !vfe_out_data->cdm_util_ops) {
+		CAM_ERR(CAM_ISP, "Failed! Invalid data");
+		return -EINVAL;
+	}
+
+	reg_val_pair = &vfe_out_data->common_data->io_buf_update[0];
+	hfr_cfg = update_hfr->io_hfr_cfg;
+
+	for (i = 0, j = 0; i < vfe_out_data->num_wm; i++) {
+		if (j >= (MAX_REG_VAL_PAIR_SIZE - MAX_BUF_UPDATE_REG_NUM * 2)) {
+			CAM_ERR(CAM_ISP,
+				"reg_val_pair %d exceeds the array limit %lu",
+				j, MAX_REG_VAL_PAIR_SIZE);
+			return -ENOMEM;
+		}
+
+		wm_data = vfe_out_data->wm_res[i]->res_priv;
+
+		if ((wm_data->framedrop_pattern !=
+			hfr_cfg->framedrop_pattern) ||
+			!wm_data->hfr_cfg_done) {
+			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+				wm_data->hw_regs->framedrop_pattern,
+				hfr_cfg->framedrop_pattern);
+			wm_data->framedrop_pattern = hfr_cfg->framedrop_pattern;
+		}
+		CAM_DBG(CAM_ISP, "framedrop pattern 0x%x",
+			wm_data->framedrop_pattern);
+
+		if (wm_data->framedrop_period != hfr_cfg->framedrop_period ||
+			!wm_data->hfr_cfg_done) {
+			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+				wm_data->hw_regs->framedrop_period,
+				hfr_cfg->framedrop_period);
+			wm_data->framedrop_period = hfr_cfg->framedrop_period;
+		}
+		CAM_DBG(CAM_ISP, "framedrop period 0x%x",
+			wm_data->framedrop_period);
+
+		if (wm_data->irq_subsample_period != hfr_cfg->subsample_period
+			|| !wm_data->hfr_cfg_done) {
+			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+				wm_data->hw_regs->irq_subsample_period,
+				hfr_cfg->subsample_period);
+			wm_data->irq_subsample_period =
+				hfr_cfg->subsample_period;
+		}
+		CAM_DBG(CAM_ISP, "irq subsample period 0x%x",
+			wm_data->irq_subsample_period);
+
+		if (wm_data->irq_subsample_pattern != hfr_cfg->subsample_pattern
+			|| !wm_data->hfr_cfg_done) {
+			CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
+				wm_data->hw_regs->irq_subsample_pattern,
+				hfr_cfg->subsample_pattern);
+			wm_data->irq_subsample_pattern =
+				hfr_cfg->subsample_pattern;
+		}
+		CAM_DBG(CAM_ISP, "irq subsample pattern 0x%x",
+			wm_data->irq_subsample_pattern);
+
+		/* set initial configuration done */
+		if (!wm_data->hfr_cfg_done)
+			wm_data->hfr_cfg_done = true;
+	}
+
+	size = vfe_out_data->cdm_util_ops->cdm_required_size_reg_random(j/2);
+
+	/* cdm util returns dwords, need to convert to bytes */
+	if ((size * 4) > update_hfr->cdm.size) {
+		CAM_ERR(CAM_ISP,
+			"Failed! Buf size:%d insufficient, expected size:%d",
+			update_hfr->cdm.size, size);
+		return -ENOMEM;
+	}
+
+	vfe_out_data->cdm_util_ops->cdm_write_regrandom(
+		update_hfr->cdm.cmd_buf_addr, j/2, reg_val_pair);
+
+	/* cdm util returns dwords, need to convert to bytes */
+	update_hfr->cdm.used_bytes = size * 4;
+
+	return 0;
+}
+
+static int cam_vfe_bus_update_stripe_cfg(void *priv, void *cmd_args,
+	uint32_t arg_size)
+{
+	struct cam_vfe_bus_ver2_priv                *bus_priv;
+	struct cam_isp_hw_dual_isp_update_args      *stripe_args;
+	struct cam_vfe_bus_ver2_vfe_out_data        *vfe_out_data = NULL;
+	struct cam_vfe_bus_ver2_wm_resource_data    *wm_data = NULL;
+	struct cam_isp_dual_stripe_config           *stripe_config;
+	uint32_t outport_id, ports_plane_idx, i;
+
+	bus_priv = (struct cam_vfe_bus_ver2_priv  *) priv;
+	stripe_args = (struct cam_isp_hw_dual_isp_update_args *)cmd_args;
+
+	vfe_out_data = (struct cam_vfe_bus_ver2_vfe_out_data *)
+		stripe_args->res->res_priv;
+
+	if (!vfe_out_data) {
+		CAM_ERR(CAM_ISP, "Failed! Invalid data");
+		return -EINVAL;
+	}
+
+	outport_id = stripe_args->res->res_id & 0xFF;
+	if (stripe_args->res->res_id < CAM_ISP_IFE_OUT_RES_BASE ||
+		stripe_args->res->res_id >= CAM_ISP_IFE_OUT_RES_MAX)
+		return 0;
+
+	ports_plane_idx = (stripe_args->split_id *
+	(stripe_args->dual_cfg->num_ports * CAM_PACKET_MAX_PLANES)) +
+	(outport_id * CAM_PACKET_MAX_PLANES);
+	for (i = 0; i < vfe_out_data->num_wm; i++) {
+		wm_data = vfe_out_data->wm_res[i]->res_priv;
+		stripe_config = (struct cam_isp_dual_stripe_config  *)
+			&stripe_args->dual_cfg->stripes[ports_plane_idx + i];
+		wm_data->width = stripe_config->width;
+		wm_data->offset = stripe_config->offset;
+		wm_data->tile_cfg = stripe_config->tileconfig;
+		CAM_DBG(CAM_ISP, "id:%x wm:%d width:0x%x offset:%x tilecfg:%x",
+			stripe_args->res->res_id, i, wm_data->width,
+			wm_data->offset, wm_data->tile_cfg);
+	}
+
+	return 0;
+}
+
 static int cam_vfe_bus_start_hw(void *hw_priv,
 	void *start_hw_args, uint32_t arg_size)
 {
@@ -2158,7 +2646,7 @@
 	uint32_t                         top_irq_reg_mask[2] = {0};
 
 	if (!bus_priv) {
-		CAM_ERR(CAM_ISP, "Error! Invalid args");
+		CAM_ERR(CAM_ISP, "Invalid args");
 		return -EINVAL;
 	}
 
@@ -2179,6 +2667,21 @@
 		return -EFAULT;
 	}
 
+	/* BUS_WR_INPUT_IF_ADDR_SYNC_FRAME_HEADER */
+	cam_io_w_mb(0x0, bus_priv->common_data.mem_base +
+		bus_priv->common_data.common_reg->addr_sync_frame_hdr);
+
+	/* no clock gating at bus input */
+	cam_io_w_mb(0xFFFFF, bus_priv->common_data.mem_base + 0x0000200C);
+
+	/* BUS_WR_TEST_BUS_CTRL */
+	cam_io_w_mb(0x0, bus_priv->common_data.mem_base + 0x0000211C);
+
+	/* if addr_no_sync has default value then config the addr no sync reg */
+	cam_io_w_mb(CAM_VFE_BUS_ADDR_NO_SYNC_DEFAULT_VAL,
+		bus_priv->common_data.mem_base +
+		bus_priv->common_data.common_reg->addr_sync_no_sync);
+
 	return 0;
 }
 
@@ -2189,7 +2692,7 @@
 	int                              rc;
 
 	if (!bus_priv || (bus_priv->irq_handle <= 0)) {
-		CAM_ERR(CAM_ISP, "Error! Invalid args");
+		CAM_ERR(CAM_ISP, "Error: Invalid args");
 		return -EINVAL;
 	}
 
@@ -2202,13 +2705,20 @@
 	return rc;
 }
 
-static int cam_vfe_bus_process_cmd(void *priv,
+static int __cam_vfe_bus_process_cmd(void *priv,
+	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
+{
+	return cam_vfe_bus_process_cmd(priv, cmd_type, cmd_args, arg_size);
+}
+
+static int cam_vfe_bus_process_cmd(
+	struct cam_isp_resource_node *priv,
 	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
 {
 	int rc = -EINVAL;
 
 	if (!priv || !cmd_args) {
-		CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! Invalid input arguments\n");
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Invalid input arguments");
 		return -EINVAL;
 	}
 
@@ -2216,8 +2726,17 @@
 	case CAM_VFE_HW_CMD_GET_BUF_UPDATE:
 		rc = cam_vfe_bus_update_buf(priv, cmd_args, arg_size);
 		break;
+	case CAM_VFE_HW_CMD_GET_HFR_UPDATE:
+		rc = cam_vfe_bus_update_hfr(priv, cmd_args, arg_size);
+		break;
+	case CAM_VFE_HW_CMD_GET_SECURE_MODE:
+		rc = cam_vfe_bus_get_secure_mode(priv, cmd_args, arg_size);
+		break;
+	case CAM_VFE_HW_CMD_STRIPE_UPDATE:
+		rc = cam_vfe_bus_update_stripe_cfg(priv, cmd_args, arg_size);
+		break;
 	default:
-		CAM_ERR_RATE_LIMIT(CAM_ISP, "Inval camif process command:%d\n",
+		CAM_ERR_RATE_LIMIT(CAM_ISP, "Invalid camif process command:%d",
 			cmd_type);
 		break;
 	}
@@ -2264,18 +2783,24 @@
 	}
 	vfe_bus_local->bus_priv = bus_priv;
 
+	bus_priv->common_data.num_sec_out        = 0;
+	bus_priv->common_data.secure_mode        = CAM_SECURE_MODE_NON_SECURE;
 	bus_priv->common_data.core_index         = soc_info->index;
 	bus_priv->common_data.mem_base           =
 		CAM_SOC_GET_REG_MAP_START(soc_info, VFE_CORE_BASE_IDX);
 	bus_priv->common_data.hw_intf            = hw_intf;
 	bus_priv->common_data.vfe_irq_controller = vfe_irq_controller;
 	bus_priv->common_data.common_reg         = &ver2_hw_info->common_reg;
+	bus_priv->common_data.addr_no_sync       =
+		CAM_VFE_BUS_ADDR_NO_SYNC_DEFAULT_VAL;
+
+	mutex_init(&bus_priv->common_data.bus_mutex);
 
 	rc = cam_irq_controller_init(drv_name, bus_priv->common_data.mem_base,
 		&ver2_hw_info->common_reg.irq_reg_info,
 		&bus_priv->common_data.bus_irq_controller);
 	if (rc) {
-		CAM_ERR(CAM_ISP, "Error! cam_irq_controller_init failed");
+		CAM_ERR(CAM_ISP, "cam_irq_controller_init failed");
 		goto free_bus_priv;
 	}
 
@@ -2287,7 +2812,7 @@
 		rc = cam_vfe_bus_init_wm_resource(i, bus_priv, bus_hw_info,
 			&bus_priv->bus_client[i]);
 		if (rc < 0) {
-			CAM_ERR(CAM_ISP, "Error! Init WM failed rc=%d", rc);
+			CAM_ERR(CAM_ISP, "Init WM failed rc=%d", rc);
 			goto deinit_wm;
 		}
 	}
@@ -2325,7 +2850,7 @@
 	vfe_bus_local->hw_ops.deinit       = cam_vfe_bus_deinit_hw;
 	vfe_bus_local->top_half_handler    = cam_vfe_bus_ver2_handle_irq;
 	vfe_bus_local->bottom_half_handler = NULL;
-	vfe_bus_local->hw_ops.process_cmd  = cam_vfe_bus_process_cmd;
+	vfe_bus_local->hw_ops.process_cmd  = __cam_vfe_bus_process_cmd;
 
 	*vfe_bus = vfe_bus_local;
 
@@ -2368,14 +2893,14 @@
 	struct cam_vfe_bus              *vfe_bus_local;
 
 	if (!vfe_bus || !*vfe_bus) {
-		CAM_ERR(CAM_ISP, "Error! Invalid input");
+		CAM_ERR(CAM_ISP, "Invalid input");
 		return -EINVAL;
 	}
 	vfe_bus_local = *vfe_bus;
 
 	bus_priv = vfe_bus_local->bus_priv;
 	if (!bus_priv) {
-		CAM_ERR(CAM_ISP, "Error! bus_priv is NULL");
+		CAM_ERR(CAM_ISP, "bus_priv is NULL");
 		rc = -ENODEV;
 		goto free_bus_local;
 	}
@@ -2388,21 +2913,21 @@
 		rc = cam_vfe_bus_deinit_wm_resource(&bus_priv->bus_client[i]);
 		if (rc < 0)
 			CAM_ERR(CAM_ISP,
-				"Error! Deinit WM failed rc=%d", rc);
+				"Deinit WM failed rc=%d", rc);
 	}
 
 	for (i = 0; i < CAM_VFE_BUS_VER2_COMP_GRP_MAX; i++) {
 		rc = cam_vfe_bus_deinit_comp_grp(&bus_priv->comp_grp[i]);
 		if (rc < 0)
 			CAM_ERR(CAM_ISP,
-				"Error! Deinit Comp Grp failed rc=%d", rc);
+				"Deinit Comp Grp failed rc=%d", rc);
 	}
 
 	for (i = 0; i < CAM_VFE_BUS_VER2_VFE_OUT_MAX; i++) {
 		rc = cam_vfe_bus_deinit_vfe_out_resource(&bus_priv->vfe_out[i]);
 		if (rc < 0)
 			CAM_ERR(CAM_ISP,
-				"Error! Deinit VFE Out failed rc=%d", rc);
+				"Deinit VFE Out failed rc=%d", rc);
 	}
 
 	INIT_LIST_HEAD(&bus_priv->free_comp_grp);
@@ -2413,8 +2938,9 @@
 		&bus_priv->common_data.bus_irq_controller);
 	if (rc)
 		CAM_ERR(CAM_ISP,
-			"Error! Deinit IRQ Controller failed rc=%d", rc);
+			"Deinit IRQ Controller failed rc=%d", rc);
 
+	mutex_destroy(&bus_priv->common_data.bus_mutex);
 	kfree(vfe_bus_local->bus_priv);
 
 free_bus_local:
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.h
index ba98077..c90d4ce 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.h
@@ -81,8 +81,8 @@
 	uint32_t dual_comp_error_status;
 	uint32_t dual_comp_ovrwr_status;
 	uint32_t addr_sync_cfg;
-	uint32_t addr_syn_frame_hdr;
-	uint32_t addr_syn_no_sync;
+	uint32_t addr_sync_frame_hdr;
+	uint32_t addr_sync_no_sync;
 };
 
 /*
@@ -130,9 +130,12 @@
  * struct cam_vfe_bus_ver2_reg_offset_comp_grp:
  *
  * @Brief:        Register offsets for Composite Group registers
+ * comp_mask:     Comp group register address
+ * addr_sync_mask:Address sync group register address
  */
 struct cam_vfe_bus_ver2_reg_offset_comp_grp {
 	uint32_t                            comp_mask;
+	uint32_t                            addr_sync_mask;
 };
 
 /*
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
index e70ecc5..e81a9f2 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
@@ -10,15 +10,17 @@
  * GNU General Public License for more details.
  */
 
- #include <linux/slab.h>
+#include <linux/slab.h>
 #include <uapi/media/cam_isp.h>
 #include "cam_io_util.h"
 #include "cam_isp_hw_mgr_intf.h"
+#include "cam_isp_hw.h"
 #include "cam_vfe_hw_intf.h"
 #include "cam_vfe_top.h"
 #include "cam_vfe_top_ver2.h"
 #include "cam_vfe_camif_ver2.h"
 #include "cam_debug_util.h"
+#include "cam_cdm_util.h"
 
 struct cam_vfe_mux_camif_data {
 	void __iomem                                *mem_base;
@@ -58,6 +60,55 @@
 	return rc;
 }
 
+static int cam_vfe_camif_get_reg_update(
+	struct cam_isp_resource_node  *camif_res,
+	void *cmd_args, uint32_t arg_size)
+{
+	uint32_t                          size = 0;
+	uint32_t                          reg_val_pair[2];
+	struct cam_isp_hw_get_cdm_args   *cdm_args = cmd_args;
+	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
+	struct cam_vfe_mux_camif_data    *rsrc_data = NULL;
+
+	if (arg_size != sizeof(struct cam_isp_hw_get_cdm_args)) {
+		CAM_ERR(CAM_ISP, "Invalid cmd size");
+		return -EINVAL;
+	}
+
+	if (!cdm_args || !cdm_args->res) {
+		CAM_ERR(CAM_ISP, "Invalid args");
+		return -EINVAL;
+	}
+
+	cdm_util_ops = (struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
+
+	if (!cdm_util_ops) {
+		CAM_ERR(CAM_ISP, "Invalid CDM ops");
+		return -EINVAL;
+	}
+
+	size = cdm_util_ops->cdm_required_size_reg_random(1);
+	/* since cdm returns dwords, we need to convert it into bytes */
+	if ((size * 4) > cdm_args->size) {
+		CAM_ERR(CAM_ISP, "buf size:%d is not sufficient, expected: %d",
+			cdm_args->size, size);
+		return -EINVAL;
+	}
+
+	rsrc_data = camif_res->res_priv;
+	reg_val_pair[0] = rsrc_data->camif_reg->reg_update_cmd;
+	reg_val_pair[1] = rsrc_data->reg_data->reg_update_cmd_data;
+	CAM_DBG(CAM_ISP, "CAMIF reg_update_cmd %x offset %x",
+		reg_val_pair[1], reg_val_pair[0]);
+
+	cdm_util_ops->cdm_write_regrandom(cdm_args->cmd_buf_addr,
+		1, reg_val_pair);
+
+	cdm_args->used_bytes = size * 4;
+
+	return 0;
+}
+
 int cam_vfe_camif_ver2_acquire_resource(
 	struct cam_isp_resource_node  *camif_res,
 	void                          *acquire_param)
@@ -107,8 +158,14 @@
 	/*config vfe core*/
 	val = (rsrc_data->pix_pattern <<
 			rsrc_data->reg_data->pixel_pattern_shift);
+	if (rsrc_data->sync_mode == CAM_ISP_HW_SYNC_SLAVE)
+		val |= (1 << rsrc_data->reg_data->extern_reg_update_shift);
+
 	cam_io_w_mb(val, rsrc_data->mem_base + rsrc_data->common_reg->core_cfg);
 
+	CAM_DBG(CAM_ISP, "hw id:%d core_cfg val:%d", camif_res->hw_intf->hw_idx,
+		val);
+
 	cam_io_w_mb(0x00400040, rsrc_data->mem_base +
 		rsrc_data->camif_reg->camif_config);
 	cam_io_w_mb(0x1, rsrc_data->mem_base +
@@ -117,15 +174,16 @@
 			rsrc_data->camif_reg->pixel_skip_pattern);
 
 	/* epoch config with 20 line */
-	cam_io_w_mb(0x00140014,
+	cam_io_w_mb(rsrc_data->reg_data->epoch_line_cfg,
 		rsrc_data->mem_base + rsrc_data->camif_reg->epoch_irq);
 
 	camif_res->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
 
 	/* Reg Update */
-	cam_io_w_mb(0x1, rsrc_data->mem_base + 0x4AC);
+	cam_io_w_mb(rsrc_data->reg_data->reg_update_cmd_data,
+		rsrc_data->mem_base + rsrc_data->camif_reg->reg_update_cmd);
 
-	CAM_DBG(CAM_ISP, "Exit");
+	CAM_DBG(CAM_ISP, "Start Camif IFE %d Done", camif_res->hw_intf->hw_idx);
 	return 0;
 }
 
@@ -155,10 +213,28 @@
 	return rc;
 }
 
-int cam_vfe_camif_process_cmd(void *priv,
+static int cam_vfe_camif_process_cmd(struct cam_isp_resource_node *rsrc_node,
 	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
 {
-	return -EPERM;
+	int rc = -EINVAL;
+
+	if (!rsrc_node || !cmd_args) {
+		CAM_ERR(CAM_ISP, "Invalid input arguments");
+		return -EINVAL;
+	}
+
+	switch (cmd_type) {
+	case CAM_VFE_HW_CMD_GET_REG_UPDATE:
+		rc = cam_vfe_camif_get_reg_update(rsrc_node, cmd_args,
+			arg_size);
+		break;
+	default:
+		CAM_ERR(CAM_ISP,
+			"unsupported process command:%d", cmd_type);
+		break;
+	}
+
+	return rc;
 }
 
 static int cam_vfe_camif_handle_irq_top_half(uint32_t evt_id,
@@ -207,6 +283,12 @@
 			ret = CAM_VFE_IRQ_STATUS_SUCCESS;
 		}
 		break;
+	case CAM_ISP_HW_EVENT_EOF:
+		if (irq_status0 & camif_priv->reg_data->eof_irq_mask) {
+			CAM_DBG(CAM_ISP, "Received EOF\n");
+			ret = CAM_VFE_IRQ_STATUS_SUCCESS;
+		}
+		break;
 	default:
 		break;
 	}
@@ -241,6 +323,7 @@
 
 	camif_node->start = cam_vfe_camif_resource_start;
 	camif_node->stop  = cam_vfe_camif_resource_stop;
+	camif_node->process_cmd = cam_vfe_camif_process_cmd;
 	camif_node->top_half_handler = cam_vfe_camif_handle_irq_top_half;
 	camif_node->bottom_half_handler = cam_vfe_camif_handle_irq_bottom_half;
 
@@ -254,6 +337,7 @@
 
 	camif_node->start = NULL;
 	camif_node->stop  = NULL;
+	camif_node->process_cmd = NULL;
 	camif_node->top_half_handler = NULL;
 	camif_node->bottom_half_handler = NULL;
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
index 553abf2..847b7d5 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
@@ -50,10 +50,12 @@
 	uint32_t     pixel_pattern_shift;
 	uint32_t     pixel_pattern_mask;
 
+	uint32_t     reg_update_cmd_data;
 	uint32_t     epoch_line_cfg;
 	uint32_t     sof_irq_mask;
 	uint32_t     epoch0_irq_mask;
 	uint32_t     reg_update_irq_mask;
+	uint32_t     eof_irq_mask;
 };
 
 struct cam_vfe_camif_ver2_hw_info {
@@ -66,9 +68,6 @@
 	struct cam_isp_resource_node  *camif_res,
 	void                          *acquire_param);
 
-int cam_vfe_camif_process_cmd(void *priv,
-	uint32_t cmd_type, void *cmd_args, uint32_t arg_size);
-
 int cam_vfe_camif_ver2_init(
 	struct cam_hw_intf            *hw_intf,
 	struct cam_hw_soc_info        *soc_info,
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
index df7b0f9..797873c 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
@@ -13,9 +13,11 @@
 #include <linux/slab.h>
 #include "cam_vfe_rdi.h"
 #include "cam_isp_hw_mgr_intf.h"
+#include "cam_isp_hw.h"
 #include "cam_vfe_hw_intf.h"
 #include "cam_io_util.h"
 #include "cam_debug_util.h"
+#include "cam_cdm_util.h"
 
 struct cam_vfe_mux_rdi_data {
 	void __iomem                                *mem_base;
@@ -27,6 +29,54 @@
 	enum cam_isp_hw_sync_mode          sync_mode;
 };
 
+static int cam_vfe_rdi_get_reg_update(
+	struct cam_isp_resource_node  *rdi_res,
+	void *cmd_args, uint32_t arg_size)
+{
+	uint32_t                          size = 0;
+	uint32_t                          reg_val_pair[2];
+	struct cam_isp_hw_get_cdm_args   *cdm_args = cmd_args;
+	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
+	struct cam_vfe_mux_rdi_data      *rsrc_data = NULL;
+
+	if (arg_size != sizeof(struct cam_isp_hw_get_cdm_args)) {
+		CAM_ERR(CAM_ISP, "Error - Invalid cmd size");
+		return -EINVAL;
+	}
+
+	if (!cdm_args || !cdm_args->res) {
+		CAM_ERR(CAM_ISP, "Error - Invalid args");
+		return -EINVAL;
+	}
+
+	cdm_util_ops = (struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
+	if (!cdm_util_ops) {
+		CAM_ERR(CAM_ISP, "Error - Invalid CDM ops");
+		return -EINVAL;
+	}
+
+	size = cdm_util_ops->cdm_required_size_reg_random(1);
+	/* since cdm returns dwords, we need to convert it into bytes */
+	if ((size * 4) > cdm_args->size) {
+		CAM_ERR(CAM_ISP,
+			"Error - buf size:%d is not sufficient, expected: %d",
+			cdm_args->size, size * 4);
+		return -EINVAL;
+	}
+
+	rsrc_data = rdi_res->res_priv;
+	reg_val_pair[0] = rsrc_data->rdi_reg->reg_update_cmd;
+	reg_val_pair[1] = rsrc_data->reg_data->reg_update_cmd_data;
+	CAM_DBG(CAM_ISP, "RDI%d reg_update_cmd %x",
+		rdi_res->res_id - CAM_ISP_HW_VFE_IN_RDI0, reg_val_pair[1]);
+
+	cdm_util_ops->cdm_write_regrandom(cdm_args->cmd_buf_addr,
+		1, reg_val_pair);
+	cdm_args->used_bytes = size * 4;
+
+	return 0;
+}
+
 int cam_vfe_rdi_ver2_acquire_resource(
 	struct cam_isp_resource_node  *rdi_res,
 	void                          *acquire_param)
@@ -63,9 +113,11 @@
 	rdi_res->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
 
 	/* Reg Update */
-	cam_io_w_mb(0x2, rsrc_data->mem_base + 0x4AC);
+	cam_io_w_mb(rsrc_data->reg_data->reg_update_cmd_data,
+		rsrc_data->mem_base + rsrc_data->rdi_reg->reg_update_cmd);
 
-	CAM_DBG(CAM_ISP, "Exit");
+	CAM_DBG(CAM_ISP, "Start RDI %d",
+		rdi_res->res_id - CAM_ISP_HW_VFE_IN_RDI0);
 
 	return rc;
 }
@@ -95,17 +147,21 @@
 	return rc;
 }
 
-int cam_vfe_rdi_process_cmd(void *priv,
+static int cam_vfe_rdi_process_cmd(struct cam_isp_resource_node *rsrc_node,
 	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
 {
 	int rc = -EINVAL;
 
-	if (!priv || !cmd_args) {
+	if (!rsrc_node || !cmd_args) {
 		CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
 		return -EINVAL;
 	}
 
 	switch (cmd_type) {
+	case CAM_VFE_HW_CMD_GET_REG_UPDATE:
+		rc = cam_vfe_rdi_get_reg_update(rsrc_node, cmd_args,
+			arg_size);
+		break;
 	default:
 		CAM_ERR(CAM_ISP,
 			"unsupported RDI process command:%d", cmd_type);
@@ -211,6 +267,7 @@
 
 	rdi_node->start = cam_vfe_rdi_resource_start;
 	rdi_node->stop  = cam_vfe_rdi_resource_stop;
+	rdi_node->process_cmd = cam_vfe_rdi_process_cmd;
 	rdi_node->top_half_handler = cam_vfe_rdi_handle_irq_top_half;
 	rdi_node->bottom_half_handler = cam_vfe_rdi_handle_irq_bottom_half;
 
@@ -227,6 +284,7 @@
 
 	rdi_node->start = NULL;
 	rdi_node->stop  = NULL;
+	rdi_node->process_cmd = NULL;
 	rdi_node->top_half_handler = NULL;
 	rdi_node->bottom_half_handler = NULL;
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
index 04e4f02..32a67c4 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
@@ -38,9 +38,6 @@
 	struct cam_isp_resource_node  *rdi_res,
 	void                          *acquire_param);
 
-int cam_vfe_rdi_process_cmd(void *priv,
-	uint32_t cmd_type, void *cmd_args, uint32_t arg_size);
-
 int cam_vfe_rdi_ver2_init(
 	struct cam_hw_intf            *hw_intf,
 	struct cam_hw_soc_info        *soc_info,
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
index 1a3eeae..f87953d 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
@@ -80,53 +80,13 @@
 	struct cam_vfe_top_ver2_priv *top_priv,
 	void *cmd_args, uint32_t arg_size)
 {
-	uint32_t                          size = 0;
-	uint32_t                          reg_val_pair[2];
 	struct cam_isp_hw_get_cdm_args   *cdm_args = cmd_args;
-	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
 
-	if (arg_size != sizeof(struct cam_isp_hw_get_cdm_args)) {
-		CAM_ERR(CAM_ISP, "Error! Invalid cmd size");
-		return -EINVAL;
-	}
+	if (cdm_args->res->process_cmd)
+		return cdm_args->res->process_cmd(cdm_args->res,
+			CAM_VFE_HW_CMD_GET_REG_UPDATE, cmd_args, arg_size);
 
-	if (!cdm_args || !cdm_args->res) {
-		CAM_ERR(CAM_ISP, "Error! Invalid args");
-		return -EINVAL;
-	}
-
-	cdm_util_ops = (struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
-
-	if (!cdm_util_ops) {
-		CAM_ERR(CAM_ISP, "Error! Invalid CDM ops");
-		return -EINVAL;
-	}
-
-	size = cdm_util_ops->cdm_required_size_reg_random(1);
-	/* since cdm returns dwords, we need to convert it into bytes */
-	if ((size * 4) > cdm_args->size) {
-		CAM_ERR(CAM_ISP, "buf size:%d is not sufficient, expected: %d",
-			cdm_args->size, size);
-		return -EINVAL;
-	}
-
-	reg_val_pair[0] = top_priv->common_data.common_reg->reg_update_cmd;
-
-	if (cdm_args->res->res_id == CAM_ISP_HW_VFE_IN_CAMIF)
-		reg_val_pair[1] = BIT(0);
-	else {
-		uint32_t rdi_num = cdm_args->res->res_id -
-			CAM_ISP_HW_VFE_IN_RDI0;
-		/* RDI reg_update starts at BIT 1, so add 1 */
-		reg_val_pair[1] = BIT(rdi_num + 1);
-	}
-
-	cdm_util_ops->cdm_write_regrandom(cdm_args->cmd_buf_addr,
-		1, reg_val_pair);
-
-	cdm_args->used_bytes = size * 4;
-
-	return 0;
+	return -EINVAL;
 }
 
 int cam_vfe_top_get_hw_caps(void *device_priv,
@@ -257,12 +217,8 @@
 	top_priv = (struct cam_vfe_top_ver2_priv   *)device_priv;
 	mux_res = (struct cam_isp_resource_node *)start_args;
 
-	if (mux_res->res_id == CAM_ISP_HW_VFE_IN_CAMIF) {
+	if (mux_res->start) {
 		rc = mux_res->start(mux_res);
-	} else if (mux_res->res_id >= CAM_ISP_HW_VFE_IN_RDI0 &&
-		mux_res->res_id <= CAM_ISP_HW_VFE_IN_RDI3) {
-		mux_res->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
-		rc = 0;
 	} else {
 		CAM_ERR(CAM_ISP, "Invalid res id:%d", mux_res->res_id);
 		rc = -EINVAL;
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
index b06b5c4..2cd6b04 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
@@ -214,22 +214,22 @@
 
 
 static int cam_jpeg_mgr_release_ctx(
-	struct cam_jpeg_hw_mgr *hw_mgr, int ctx_id)
+	struct cam_jpeg_hw_mgr *hw_mgr, struct cam_jpeg_hw_ctx_data *ctx_data)
 {
-	if (ctx_id >= CAM_JPEG_CTX_MAX) {
-		CAM_ERR(CAM_JPEG, "ctx_id is wrong: %d", ctx_id);
+	if (!ctx_data) {
+		CAM_ERR(CAM_JPEG, "invalid ctx_data %pK", ctx_data);
 		return -EINVAL;
 	}
 
-	mutex_lock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
-	if (!hw_mgr->ctx_data[ctx_id].in_use) {
-		CAM_ERR(CAM_JPEG, "ctx is already in use: %d", ctx_id);
-		mutex_unlock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
+	mutex_lock(&ctx_data->ctx_mutex);
+	if (!ctx_data->in_use) {
+		CAM_ERR(CAM_JPEG, "ctx is already un-used: %pK", ctx_data);
+		mutex_unlock(&ctx_data->ctx_mutex);
 		return -EINVAL;
 	}
 
-	hw_mgr->ctx_data[ctx_id].in_use = 0;
-	mutex_unlock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
+	ctx_data->in_use = false;
+	mutex_unlock(&ctx_data->ctx_mutex);
 
 	return 0;
 }
@@ -280,7 +280,8 @@
 		hw_mgr->dev_hw_cfg_args[p_cfg_req->dev_type][0] = p_cfg_req;
 		list_del_init(&p_cfg_req->list);
 	} else {
-		CAM_ERR(CAM_JPEG, "NOT dequeing, just return");
+		CAM_DBG(CAM_JPEG, "Not dequeing, just return");
+		mutex_unlock(&hw_mgr->hw_mgr_mutex);
 		rc = -EFAULT;
 		goto end;
 	}
@@ -289,7 +290,7 @@
 	config_args = (struct cam_hw_config_args *)&p_cfg_req->hw_cfg_args;
 	request_id = task_data->request_id;
 	if (request_id != (uint64_t)config_args->priv) {
-		CAM_WARN(CAM_JPEG, "not a recent req %d %d",
+		CAM_DBG(CAM_JPEG, "not a recent req %lld %lld",
 			request_id, (uint64_t)config_args->priv);
 	}
 
@@ -475,8 +476,8 @@
 
 	request_id = (uint64_t)config_args->priv;
 	hw_update_entries = config_args->hw_update_entries;
-	CAM_DBG(CAM_JPEG, "ctx_data = %pK req_id = %d %pK",
-		ctx_data, request_id, config_args->priv);
+	CAM_DBG(CAM_JPEG, "ctx_data = %pK req_id = %lld %lld",
+		ctx_data, request_id, (uint64_t)config_args->priv);
 	task = cam_req_mgr_workq_get_task(g_jpeg_hw_mgr.work_process_frame);
 	if (!task) {
 		CAM_ERR(CAM_JPEG, "no empty task");
@@ -578,7 +579,7 @@
 		(void *)packet, (void *)cmd_desc,
 		sizeof(struct cam_cmd_buf_desc));
 
-	rc = cam_packet_util_process_patches(packet, hw_mgr->iommu_hdl);
+	rc = cam_packet_util_process_patches(packet, hw_mgr->iommu_hdl, -1);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, "Patch processing failed %d", rc);
 		return rc;
@@ -631,13 +632,12 @@
 static int cam_jpeg_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args)
 {
 	int rc;
-	int ctx_id = 0;
 	struct cam_hw_release_args *release_hw = release_hw_args;
 	struct cam_jpeg_hw_mgr *hw_mgr = hw_mgr_priv;
 	struct cam_jpeg_hw_ctx_data *ctx_data = NULL;
 	uint32_t dev_type;
 
-	if (!release_hw || !hw_mgr) {
+	if (!hw_mgr || !release_hw || !release_hw->ctxt_to_hw_map) {
 		CAM_ERR(CAM_JPEG, "Invalid args");
 		return -EINVAL;
 	}
@@ -671,7 +671,7 @@
 	}
 	mutex_unlock(&hw_mgr->hw_mgr_mutex);
 
-	rc = cam_jpeg_mgr_release_ctx(hw_mgr, ctx_id);
+	rc = cam_jpeg_mgr_release_ctx(hw_mgr, ctx_data);
 	if (rc) {
 		mutex_unlock(&hw_mgr->hw_mgr_mutex);
 		return -EINVAL;
@@ -838,7 +838,7 @@
 	cam_cdm_release(hw_mgr->cdm_info[dev_type][0].cdm_handle);
 acq_cdm_hdl_failed:
 	kfree(ctx_data->cdm_cmd);
-	cam_jpeg_mgr_release_ctx(hw_mgr, ctx_id);
+	cam_jpeg_mgr_release_ctx(hw_mgr, ctx_data);
 	mutex_unlock(&hw_mgr->hw_mgr_mutex);
 
 	return rc;
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.c
index 05c1a95..0a15f71 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.c
@@ -57,6 +57,13 @@
 		return -EINVAL;
 	}
 
+
+	mutex_lock(&core_info->core_mutex);
+	if (++core_info->ref_count > 1) {
+		mutex_unlock(&core_info->core_mutex);
+		return 0;
+	}
+
 	cpas_vote.ahb_vote.type = CAM_VOTE_ABSOLUTE;
 	cpas_vote.ahb_vote.vote.level = CAM_SVS_VOTE;
 	cpas_vote.axi_vote.compressed_bw = JPEG_TURBO_VOTE;
@@ -64,15 +71,26 @@
 
 	rc = cam_cpas_start(core_info->cpas_handle,
 		&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
-	if (rc)
+	if (rc) {
 		CAM_ERR(CAM_JPEG, "cpass start failed: %d", rc);
+		goto cpas_failed;
+	}
 
 	rc = cam_jpeg_dma_enable_soc_resources(soc_info);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, "soc enable is failed %d", rc);
-		cam_cpas_stop(core_info->cpas_handle);
+		goto soc_failed;
 	}
 
+	mutex_unlock(&core_info->core_mutex);
+
+	return 0;
+
+soc_failed:
+	cam_cpas_stop(core_info->cpas_handle);
+cpas_failed:
+	--core_info->ref_count;
+	mutex_unlock(&core_info->core_mutex);
 	return rc;
 }
 
@@ -98,6 +116,19 @@
 		return -EINVAL;
 	}
 
+	mutex_lock(&core_info->core_mutex);
+	if (--core_info->ref_count > 0) {
+		mutex_unlock(&core_info->core_mutex);
+		return 0;
+	}
+
+	if (core_info->ref_count < 0) {
+		CAM_ERR(CAM_JPEG, "ref cnt %d", core_info->ref_count);
+		core_info->ref_count = 0;
+		mutex_unlock(&core_info->core_mutex);
+		return -EFAULT;
+	}
+
 	rc = cam_jpeg_dma_disable_soc_resources(soc_info);
 	if (rc)
 		CAM_ERR(CAM_JPEG, "soc enable failed %d", rc);
@@ -106,6 +137,8 @@
 	if (rc)
 		CAM_ERR(CAM_JPEG, "cpas stop failed: %d", rc);
 
+	mutex_unlock(&core_info->core_mutex);
+
 	return 0;
 }
 
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h
index bb4e34a..1e0c2e2 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h
@@ -41,6 +41,8 @@
 	struct cam_jpeg_dma_device_hw_info *jpeg_dma_hw_info;
 	uint32_t cpas_handle;
 	struct cam_jpeg_dma_set_irq_cb irq_cb;
+	int32_t ref_count;
+	struct mutex core_mutex;
 };
 
 int cam_jpeg_dma_init_hw(void *device_priv,
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c
index 829bb51..ed58b41 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c
@@ -38,7 +38,7 @@
 	struct cam_cpas_register_params cpas_register_params;
 	int rc;
 
-	cpas_register_params.dev = &soc_info->pdev->dev;
+	cpas_register_params.dev = soc_info->dev;
 	memcpy(cpas_register_params.identifier, "jpeg-dma",
 		sizeof("jpeg-dma"));
 	cpas_register_params.cam_cpas_client_cb = NULL;
@@ -99,6 +99,7 @@
 	if (rc)
 		CAM_ERR(CAM_JPEG, " unreg failed to reg cpas %d", rc);
 
+	mutex_destroy(&core_info->core_mutex);
 	kfree(core_info);
 
 deinit_soc:
@@ -136,6 +137,8 @@
 		goto error_alloc_dev;
 	}
 	jpeg_dma_dev->soc_info.pdev = pdev;
+	jpeg_dma_dev->soc_info.dev = &pdev->dev;
+	jpeg_dma_dev->soc_info.dev_name = pdev->name;
 	jpeg_dma_dev_intf->hw_priv = jpeg_dma_dev;
 	jpeg_dma_dev_intf->hw_ops.init = cam_jpeg_dma_init_hw;
 	jpeg_dma_dev_intf->hw_ops.deinit = cam_jpeg_dma_deinit_hw;
@@ -163,13 +166,14 @@
 	hw_info = (struct cam_jpeg_dma_device_hw_info *)match_dev->data;
 	core_info->jpeg_dma_hw_info = hw_info;
 	core_info->core_state = CAM_JPEG_DMA_CORE_NOT_READY;
+	mutex_init(&core_info->core_mutex);
 
 	rc = cam_jpeg_dma_init_soc_resources(&jpeg_dma_dev->soc_info,
 		cam_jpeg_dma_irq,
 		jpeg_dma_dev);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, "%failed to init_soc %d", rc);
-		goto error_match_dev;
+		goto error_init_soc;
 	}
 
 	rc = cam_jpeg_dma_register_cpas(&jpeg_dma_dev->soc_info,
@@ -189,6 +193,8 @@
 
 error_reg_cpas:
 	rc = cam_soc_util_release_platform_resource(&jpeg_dma_dev->soc_info);
+error_init_soc:
+	mutex_destroy(&core_info->core_mutex);
 error_match_dev:
 	kfree(jpeg_dma_dev->core_info);
 error_alloc_core:
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_soc.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_soc.c
index efc161b..63d54fd 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_soc.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_soc.c
@@ -55,7 +55,7 @@
 {
 	int rc;
 
-	rc = cam_soc_util_disable_platform_resource(soc_info, true, false);
+	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_JPEG, "disable platform failed %d", rc);
 
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.c
index 25405cf..06ad260 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.c
@@ -100,6 +100,13 @@
 		return -EINVAL;
 	}
 
+
+	mutex_lock(&core_info->core_mutex);
+	if (++core_info->ref_count > 1) {
+		mutex_unlock(&core_info->core_mutex);
+		return 0;
+	}
+
 	cpas_vote.ahb_vote.type = CAM_VOTE_ABSOLUTE;
 	cpas_vote.ahb_vote.vote.level = CAM_SVS_VOTE;
 	cpas_vote.axi_vote.compressed_bw = JPEG_TURBO_VOTE;
@@ -107,15 +114,26 @@
 
 	rc = cam_cpas_start(core_info->cpas_handle,
 		&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
-	if (rc)
+	if (rc) {
 		CAM_ERR(CAM_JPEG, "cpass start failed: %d", rc);
+		goto cpas_failed;
+	}
 
 	rc = cam_jpeg_enc_enable_soc_resources(soc_info);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, "soc enable is failed %d", rc);
-		cam_cpas_stop(core_info->cpas_handle);
+		goto soc_failed;
 	}
 
+	mutex_unlock(&core_info->core_mutex);
+
+	return 0;
+
+soc_failed:
+	cam_cpas_stop(core_info->cpas_handle);
+cpas_failed:
+	--core_info->ref_count;
+	mutex_unlock(&core_info->core_mutex);
 	return rc;
 }
 
@@ -141,6 +159,19 @@
 		return -EINVAL;
 	}
 
+	mutex_lock(&core_info->core_mutex);
+	if (--core_info->ref_count > 0) {
+		mutex_unlock(&core_info->core_mutex);
+		return 0;
+	}
+
+	if (core_info->ref_count < 0) {
+		CAM_ERR(CAM_JPEG, "ref cnt %d", core_info->ref_count);
+		core_info->ref_count = 0;
+		mutex_unlock(&core_info->core_mutex);
+		return -EFAULT;
+	}
+
 	rc = cam_jpeg_enc_disable_soc_resources(soc_info);
 	if (rc)
 		CAM_ERR(CAM_JPEG, "soc enable failed %d", rc);
@@ -149,6 +180,8 @@
 	if (rc)
 		CAM_ERR(CAM_JPEG, "cpas stop failed: %d", rc);
 
+	mutex_unlock(&core_info->core_mutex);
+
 	return 0;
 }
 
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h
index 6ae4cdc..eb5caef 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h
@@ -45,6 +45,8 @@
 	struct cam_jpeg_enc_device_hw_info *jpeg_enc_hw_info;
 	uint32_t cpas_handle;
 	struct cam_jpeg_enc_set_irq_cb irq_cb;
+	int32_t ref_count;
+	struct mutex core_mutex;
 };
 
 int cam_jpeg_enc_init_hw(void *device_priv,
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c
index 5dd1e1f..570d9f9 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c
@@ -42,7 +42,7 @@
 	struct cam_cpas_register_params cpas_register_params;
 	int rc;
 
-	cpas_register_params.dev = &soc_info->pdev->dev;
+	cpas_register_params.dev = soc_info->dev;
 	memcpy(cpas_register_params.identifier, "jpeg-enc",
 		sizeof("jpeg-enc"));
 	cpas_register_params.cam_cpas_client_cb = NULL;
@@ -103,6 +103,7 @@
 	if (rc)
 		CAM_ERR(CAM_JPEG, " unreg failed to reg cpas %d", rc);
 
+	mutex_destroy(&core_info->core_mutex);
 	kfree(core_info);
 
 deinit_soc:
@@ -140,6 +141,8 @@
 		goto error_alloc_dev;
 	}
 	jpeg_enc_dev->soc_info.pdev = pdev;
+	jpeg_enc_dev->soc_info.dev = &pdev->dev;
+	jpeg_enc_dev->soc_info.dev_name = pdev->name;
 	jpeg_enc_dev_intf->hw_priv = jpeg_enc_dev;
 	jpeg_enc_dev_intf->hw_ops.init = cam_jpeg_enc_init_hw;
 	jpeg_enc_dev_intf->hw_ops.deinit = cam_jpeg_enc_deinit_hw;
@@ -169,13 +172,14 @@
 	hw_info = (struct cam_jpeg_enc_device_hw_info *)match_dev->data;
 	core_info->jpeg_enc_hw_info = hw_info;
 	core_info->core_state = CAM_JPEG_ENC_CORE_NOT_READY;
+	mutex_init(&core_info->core_mutex);
 
 	rc = cam_jpeg_enc_init_soc_resources(&jpeg_enc_dev->soc_info,
 		cam_jpeg_enc_irq,
 		jpeg_enc_dev);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, " failed to init_soc %d", rc);
-		goto error_match_dev;
+		goto error_init_soc;
 	}
 
 	rc = cam_jpeg_enc_register_cpas(&jpeg_enc_dev->soc_info,
@@ -193,6 +197,8 @@
 
 error_reg_cpas:
 	cam_soc_util_release_platform_resource(&jpeg_enc_dev->soc_info);
+error_init_soc:
+	mutex_destroy(&core_info->core_mutex);
 error_match_dev:
 	kfree(jpeg_enc_dev->core_info);
 error_alloc_core:
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_soc.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_soc.c
index 3f450cd..ddf2465 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_soc.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_soc.c
@@ -55,7 +55,7 @@
 {
 	int rc;
 
-	rc = cam_soc_util_disable_platform_resource(soc_info, true, false);
+	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_JPEG, "disable platform failed %d", rc);
 
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
index c150244..9d454e9 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
@@ -52,6 +52,8 @@
 		rc = DMA_FROM_DEVICE;
 	else if (flags & CAM_MEM_FLAG_HW_READ_WRITE)
 		rc = DMA_BIDIRECTIONAL;
+	else if (flags & CAM_MEM_FLAG_PROTECTED_MODE)
+		rc = DMA_BIDIRECTIONAL;
 
 	return rc;
 }
@@ -211,10 +213,16 @@
 		goto handle_mismatch;
 	}
 
-	rc = cam_smmu_get_iova(mmu_handle,
-		tbl.bufq[idx].fd,
-		iova_ptr,
-		len_ptr);
+	if (CAM_MEM_MGR_IS_SECURE_HDL(buf_handle))
+		rc = cam_smmu_get_stage2_iova(mmu_handle,
+			tbl.bufq[idx].fd,
+			iova_ptr,
+			len_ptr);
+	else
+		rc = cam_smmu_get_iova(mmu_handle,
+			tbl.bufq[idx].fd,
+			iova_ptr,
+			len_ptr);
 	if (rc < 0)
 		CAM_ERR(CAM_CRM, "fail to get buf hdl :%d", buf_handle);
 
@@ -376,10 +384,12 @@
 	uint32_t ion_flag = 0;
 	int rc;
 
-	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)
+	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) {
 		heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID);
-	else
+		ion_flag |= ION_FLAG_SECURE | ION_FLAG_CP_CAMERA;
+	} else {
 		heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID);
+	}
 
 	if (cmd->flags & CAM_MEM_FLAG_CACHE)
 		ion_flag |= ION_FLAG_CACHED;
@@ -466,10 +476,11 @@
 
 	if (flags & CAM_MEM_FLAG_PROTECTED_MODE) {
 		for (i = 0; i < num_hdls; i++) {
-			rc = cam_smmu_map_sec_iova(mmu_hdls[i],
+			rc = cam_smmu_map_stage2_iova(mmu_hdls[i],
 				fd,
 				dir,
-				(dma_addr_t *)hw_vaddr,
+				tbl.client,
+				(ion_phys_addr_t *)hw_vaddr,
 				len);
 
 			if (rc < 0) {
@@ -498,7 +509,7 @@
 multi_map_fail:
 	if (flags & CAM_MEM_FLAG_PROTECTED_MODE)
 		for (--i; i > 0; i--)
-			cam_smmu_unmap_sec_iova(mmu_hdls[i], fd);
+			cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd);
 	else
 		for (--i; i > 0; i--)
 			cam_smmu_unmap_iova(mmu_hdls[i],
@@ -543,8 +554,9 @@
 		goto slot_fail;
 	}
 
-	if (cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE ||
-		cmd->flags & CAM_MEM_FLAG_HW_SHARED_ACCESS) {
+	if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
+		(cmd->flags & CAM_MEM_FLAG_HW_SHARED_ACCESS) ||
+		(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
 
 		enum cam_smmu_region_id region;
 
@@ -570,6 +582,8 @@
 	tbl.bufq[idx].fd = ion_fd;
 	tbl.bufq[idx].flags = cmd->flags;
 	tbl.bufq[idx].buf_handle = GET_MEM_HANDLE(idx, ion_fd);
+	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)
+		CAM_MEM_MGR_SET_SECURE_HDL(tbl.bufq[idx].buf_handle, true);
 	tbl.bufq[idx].kmdvaddr = 0;
 
 	if (cmd->num_hdl > 0)
@@ -630,7 +644,8 @@
 		return -EINVAL;
 	}
 
-	if (cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) {
+	if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
+		(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
 		rc = cam_mem_util_map_hw_va(cmd->flags,
 			cmd->mmu_hdls,
 			cmd->num_hdl,
@@ -652,6 +667,8 @@
 	tbl.bufq[idx].fd = cmd->fd;
 	tbl.bufq[idx].flags = cmd->flags;
 	tbl.bufq[idx].buf_handle = GET_MEM_HANDLE(idx, cmd->fd);
+	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)
+		CAM_MEM_MGR_SET_SECURE_HDL(tbl.bufq[idx].buf_handle, true);
 	tbl.bufq[idx].kmdvaddr = 0;
 
 	if (cmd->num_hdl > 0)
@@ -699,7 +716,7 @@
 
 	if (flags & CAM_MEM_FLAG_PROTECTED_MODE) {
 		for (i = 0; i < num_hdls; i++) {
-			rc = cam_smmu_unmap_sec_iova(mmu_hdls[i], fd);
+			rc = cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd);
 			if (rc < 0)
 				goto unmap_end;
 		}
@@ -741,8 +758,9 @@
 			region = CAM_SMMU_REGION_IO;
 	}
 
-	if (tbl.bufq[idx].flags & CAM_MEM_FLAG_HW_READ_WRITE ||
-		tbl.bufq[idx].flags & CAM_MEM_FLAG_HW_SHARED_ACCESS)
+	if ((tbl.bufq[idx].flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
+		(tbl.bufq[idx].flags & CAM_MEM_FLAG_HW_SHARED_ACCESS) ||
+		(tbl.bufq[idx].flags & CAM_MEM_FLAG_PROTECTED_MODE))
 		rc = cam_mem_util_unmap_hw_va(idx, region);
 
 
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr_api.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr_api.h
index 0858b8a..af7962a 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr_api.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr_api.h
@@ -95,4 +95,9 @@
 int cam_mem_get_cpu_buf(int32_t buf_handle, uint64_t *vaddr_ptr,
 	size_t *len);
 
+static inline bool cam_mem_is_secure_buf(int32_t buf_handle)
+{
+	return CAM_MEM_MGR_IS_SECURE_HDL(buf_handle);
+}
+
 #endif /* _CAM_MEM_MGR_API_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
index efdda4f..8565ad1 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
@@ -180,6 +180,15 @@
 		tbl->pd, curr_idx, tbl->slot[curr_idx].state,
 		tbl->skip_traverse, traverse_data->in_q->slot[curr_idx].status);
 
+	if (tbl->inject_delay > 0) {
+		CAM_DBG(CAM_CRM, "Injecting Delay of one frame");
+		apply_data[tbl->pd].req_id = -1;
+		tbl->inject_delay--;
+		/* This pd table is not ready to proceed with asked idx */
+		SET_FAILURE_BIT(traverse_data->result, tbl->pd);
+		return -EAGAIN;
+	}
+
 	/* Check if req is ready or in skip mode or pd tbl is in skip mode */
 	if (tbl->slot[curr_idx].state == CRM_REQ_STATE_READY ||
 		traverse_data->in_q->slot[curr_idx].skip_idx == 1 ||
@@ -365,7 +374,7 @@
  *
  */
 static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
-	struct cam_req_mgr_req_queue *in_q)
+	struct cam_req_mgr_req_queue *in_q, uint32_t trigger)
 {
 	int                                  rc = 0, pd, i, idx;
 	struct cam_req_mgr_connected_device *dev = NULL;
@@ -391,6 +400,9 @@
 					link->req.apply_data[pd].req_id);
 				continue;
 			}
+			if (!(dev->dev_info.trigger & trigger))
+				continue;
+
 			apply_req.dev_hdl = dev->dev_hdl;
 			apply_req.request_id =
 				link->req.apply_data[pd].req_id;
@@ -400,6 +412,7 @@
 
 			trace_cam_req_mgr_apply_request(link, &apply_req, dev);
 
+			apply_req.trigger_point = trigger;
 			CAM_DBG(CAM_CRM, "SEND: pd %d req_id %lld",
 				pd, apply_req.request_id);
 			if (dev->ops && dev->ops->apply_req) {
@@ -410,7 +423,7 @@
 		}
 	}
 	if (rc < 0) {
-		CAM_ERR(CAM_CRM, "APPLY FAILED pd %d req_id %lld",
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "APPLY FAILED pd %d req_id %lld",
 			dev->dev_info.p_delay, apply_req.request_id);
 		/* Apply req failed notify already applied devs */
 		for (; i >= 0; i--) {
@@ -488,7 +501,8 @@
  * @return   : 0 for success, negative for failure
  *
  */
-static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link)
+static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
+	uint32_t trigger)
 {
 	int                                  rc = 0, idx;
 	struct cam_req_mgr_slot             *slot = NULL;
@@ -499,7 +513,7 @@
 	session = (struct cam_req_mgr_core_session *)link->parent;
 
 	/*
-	 * 1. Check if new read index,
+	 * Check if new read index,
 	 * - if in pending  state, traverse again to complete
 	 *    transaction of this read index.
 	 * - if in applied_state, somthign wrong.
@@ -514,58 +528,70 @@
 		return 0;
 	}
 
-	rc = __cam_req_mgr_check_link_is_ready(link, slot->idx);
-	if (rc >= 0) {
-		rc = __cam_req_mgr_send_req(link, link->req.in_q);
-		if (rc < 0) {
-			/* Apply req failed retry at next sof */
-			slot->status = CRM_SLOT_STATUS_REQ_PENDING;
-		} else {
-			slot->status = CRM_SLOT_STATUS_REQ_APPLIED;
+	if (trigger != CAM_TRIGGER_POINT_SOF &&
+			trigger != CAM_TRIGGER_POINT_EOF)
+		return rc;
 
+	if (trigger == CAM_TRIGGER_POINT_SOF) {
+		if (link->trigger_mask) {
+			CAM_ERR_RATE_LIMIT(CAM_CRM,
+				"Applying for last EOF fails");
+			return -EINVAL;
+		}
+		rc = __cam_req_mgr_check_link_is_ready(link, slot->idx);
+		if (rc < 0) {
+
+			 /* If traverse result is not success, then some devices
+			  * are not ready with packet for the asked request id,
+			  * hence try again in next sof
+			  */
+			slot->status = CRM_SLOT_STATUS_REQ_PENDING;
 			if (link->state == CAM_CRM_LINK_STATE_ERR) {
-				CAM_WARN(CAM_CRM,
-					"Err recovery done idx %d status %d",
+				/*
+				 * During error recovery all tables should be
+				 * ready, don't expect to enter here.
+				 * @TODO: gracefully handle if recovery fails.
+				 */
+				CAM_ERR_RATE_LIMIT(CAM_CRM,
+					"FATAL recovery cant finish idx %d status %d",
 					in_q->rd_idx,
 					in_q->slot[in_q->rd_idx].status);
-				mutex_lock(&link->lock);
-				link->state = CAM_CRM_LINK_STATE_READY;
-				mutex_unlock(&link->lock);
+				rc = -EPERM;
 			}
+			return rc;
+		}
+	}
+	if (trigger == CAM_TRIGGER_POINT_EOF &&
+			(!(link->trigger_mask & CAM_TRIGGER_POINT_SOF))) {
+		CAM_DBG(CAM_CRM, "Applying for last SOF fails");
+		return -EINVAL;
+	}
 
-			/*
-			 * 2. Check if any new req is pending in input queue,
-			 *    if not finish the lower pipeline delay device with
-			 *    available req ids.
-			 */
-			__cam_req_mgr_check_next_req_slot(in_q);
+	rc = __cam_req_mgr_send_req(link, link->req.in_q, trigger);
+	if (rc < 0) {
+		/* Apply req failed retry at next sof */
+		slot->status = CRM_SLOT_STATUS_REQ_PENDING;
+	} else {
+		link->trigger_mask |= trigger;
 
-			/*
-			 * 3. Older req slots can be safely reset as no err ack.
-			 */
+		if (link->state == CAM_CRM_LINK_STATE_ERR) {
+			CAM_WARN(CAM_CRM, "Err recovery done idx %d",
+				in_q->rd_idx);
+			mutex_lock(&link->lock);
+			link->state = CAM_CRM_LINK_STATE_READY;
+			mutex_unlock(&link->lock);
+		}
+		if (link->trigger_mask == link->subscribe_event) {
+			slot->status = CRM_SLOT_STATUS_REQ_APPLIED;
+			link->trigger_mask = 0;
+			CAM_DBG(CAM_CRM, "req is applied\n");
+
 			idx = in_q->rd_idx;
-			__cam_req_mgr_dec_idx(&idx, link->max_delay + 1,
+			__cam_req_mgr_dec_idx(
+				&idx, link->max_delay + 1,
 				in_q->num_slots);
 			__cam_req_mgr_reset_req_slot(link, idx);
 		}
-	} else {
-		/*
-		 * 4.If traverse result is not success, then some devices are
-		 *   not ready with packet for the asked request id,
-		 *   hence try again in next sof
-		 */
-		slot->status = CRM_SLOT_STATUS_REQ_PENDING;
-		if (link->state == CAM_CRM_LINK_STATE_ERR) {
-			/*
-			 * During error recovery all tables should be ready
-			 *   don't expect to enter here.
-			 * @TODO: gracefully handle if recovery fails.
-			 */
-			CAM_ERR(CAM_CRM,
-				"FATAL recovery cant finish idx %d status %d",
-				in_q->rd_idx, in_q->slot[in_q->rd_idx].status);
-			rc = -EPERM;
-		}
 	}
 
 	return rc;
@@ -576,7 +602,7 @@
  *
  * @brief    : Add table to list under link sorted by pd decremeting order
  * @l_tbl    : list of pipeline delay tables.
- * @new_tbl : new tbl which will be appended to above list as per its pd value
+ * @new_tbl  : new tbl which will be appended to above list as per its pd value
  *
  */
 static void __cam_req_mgr_add_tbl_to_link(struct cam_req_mgr_req_tbl **l_tbl,
@@ -828,6 +854,7 @@
 	link_data.link_enable = 0;
 	link_data.link_hdl = link->link_hdl;
 	link_data.crm_cb = NULL;
+	link_data.subscribe_event = 0;
 
 	/* Using device ops unlink devices */
 	for (i = 0; i < link->num_devs; i++) {
@@ -885,7 +912,13 @@
 		CAM_ERR(CAM_CRM, "failed to create link, no mem");
 		return NULL;
 	}
-	in_q = &session->in_q;
+	in_q = (struct cam_req_mgr_req_queue *)
+		kzalloc(sizeof(struct cam_req_mgr_req_queue), GFP_KERNEL);
+	if (!in_q) {
+		CAM_ERR(CAM_CRM, "failed to create input queue, no mem");
+		kfree(link);
+		return NULL;
+	}
 	mutex_init(&link->lock);
 
 	mutex_lock(&link->lock);
@@ -911,7 +944,7 @@
 }
 
 /**
- * __cam_req_mgr_reserve_link()
+ * __cam_req_mgr_unreserve_link()
  *
  * @brief  : Reserves one link data struct within session
  * @session: session identifier
@@ -943,6 +976,8 @@
 		CAM_DBG(CAM_CRM, "Active session links (%d)",
 			session->num_links);
 	}
+	kfree((*link)->req.in_q);
+	(*link)->req.in_q = NULL;
 	kfree(*link);
 	*link = NULL;
 	mutex_unlock(&session->lock);
@@ -977,7 +1012,7 @@
 	send_req = (struct cam_req_mgr_send_request *)data;
 	in_q = send_req->in_q;
 
-	rc = __cam_req_mgr_send_req(link, in_q);
+	rc = __cam_req_mgr_send_req(link, in_q, CAM_TRIGGER_POINT_SOF);
 end:
 	return rc;
 }
@@ -1161,7 +1196,7 @@
 		}
 	}
 	if (!tbl) {
-		CAM_ERR(CAM_CRM, "dev_hdl not found %x, %x %x",
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "dev_hdl not found %x, %x %x",
 			add_req->dev_hdl,
 			link->l_dev[0].dev_hdl,
 			link->l_dev[1].dev_hdl);
@@ -1184,6 +1219,10 @@
 		mutex_unlock(&link->req.lock);
 		goto end;
 	}
+
+	if (add_req->skip_before_applying > tbl->inject_delay)
+		tbl->inject_delay = add_req->skip_before_applying;
+
 	slot = &tbl->slot[idx];
 	if (slot->state != CRM_REQ_STATE_PENDING &&
 		slot->state != CRM_REQ_STATE_EMPTY) {
@@ -1250,8 +1289,9 @@
 	if (err_info->error == CRM_KMD_ERR_BUBBLE) {
 		idx = __cam_req_mgr_find_slot_for_req(in_q, err_info->req_id);
 		if (idx < 0) {
-			CAM_ERR(CAM_CRM, "req_id %lld not found in input queue",
-			err_info->req_id);
+			CAM_ERR_RATE_LIMIT(CAM_CRM,
+				"req_id %lld not found in input queue",
+				err_info->req_id);
 		} else {
 			CAM_DBG(CAM_CRM, "req_id %lld found at idx %d",
 				err_info->req_id, idx);
@@ -1302,7 +1342,7 @@
 }
 
 /**
- * cam_req_mgr_process_sof()
+ * cam_req_mgr_process_trigger()
  *
  * @brief: This runs in workque thread context. Call core funcs to check
  *         which peding requests can be processed.
@@ -1311,10 +1351,10 @@
  *
  * @return: 0 on success.
  */
-static int cam_req_mgr_process_sof(void *priv, void *data)
+static int cam_req_mgr_process_trigger(void *priv, void *data)
 {
 	int                                  rc = 0;
-	struct cam_req_mgr_sof_notify       *sof_data = NULL;
+	struct cam_req_mgr_trigger_notify   *trigger_data = NULL;
 	struct cam_req_mgr_core_link        *link = NULL;
 	struct cam_req_mgr_req_queue        *in_q = NULL;
 	struct crm_task_payload             *task_data = NULL;
@@ -1326,11 +1366,12 @@
 	}
 	link = (struct cam_req_mgr_core_link *)priv;
 	task_data = (struct crm_task_payload *)data;
-	sof_data = (struct cam_req_mgr_sof_notify *)&task_data->u;
+	trigger_data = (struct cam_req_mgr_trigger_notify *)&task_data->u;
 
-	CAM_DBG(CAM_CRM, "link_hdl %x frame_id %lld",
-		sof_data->link_hdl,
-		sof_data->frame_id);
+	CAM_DBG(CAM_CRM, "link_hdl %x frame_id %lld, trigger %x\n",
+		trigger_data->link_hdl,
+		trigger_data->frame_id,
+		trigger_data->trigger);
 
 	in_q = link->req.in_q;
 
@@ -1351,10 +1392,14 @@
 		/*
 		 * Do NOT reset req q slot data here, it can not be done
 		 * here because we need to preserve the data to handle bubble.
+		 *
+		 * Check if any new req is pending in slot, if not finish the
+		 * lower pipeline delay device with available req ids.
 		 */
+		__cam_req_mgr_check_next_req_slot(in_q);
 		__cam_req_mgr_inc_idx(&in_q->rd_idx, 1, in_q->num_slots);
 	}
-	rc = __cam_req_mgr_process_req(link);
+	rc = __cam_req_mgr_process_req(link, trigger_data->trigger);
 	mutex_unlock(&link->req.lock);
 
 end:
@@ -1408,7 +1453,7 @@
 
 	task = cam_req_mgr_workq_get_task(link->workq);
 	if (!task) {
-		CAM_ERR(CAM_CRM, "no empty task dev %x req %lld",
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "no empty task dev %x req %lld",
 			add_req->dev_hdl, add_req->req_id);
 		rc = -EBUSY;
 		goto end;
@@ -1420,6 +1465,7 @@
 	dev_req->req_id = add_req->req_id;
 	dev_req->link_hdl = add_req->link_hdl;
 	dev_req->dev_hdl = add_req->dev_hdl;
+	dev_req->skip_before_applying = add_req->skip_before_applying;
 	task->process_cb = &cam_req_mgr_process_add_req;
 	rc = cam_req_mgr_workq_enqueue_task(task, link, CRM_TASK_PRIORITY_0);
 	CAM_DBG(CAM_CRM, "X: dev %x dev req %lld",
@@ -1484,7 +1530,7 @@
 }
 
 /**
- * cam_req_mgr_cb_notify_sof()
+ * cam_req_mgr_cb_notify_trigger()
  *
  * @brief   : SOF received from device, sends trigger through workqueue
  * @sof_data: contains information about frame_id, link etc.
@@ -1492,25 +1538,25 @@
  * @return  : 0 on success
  *
  */
-static int cam_req_mgr_cb_notify_sof(
-	struct cam_req_mgr_sof_notify *sof_data)
+static int cam_req_mgr_cb_notify_trigger(
+	struct cam_req_mgr_trigger_notify *trigger_data)
 {
 	int                              rc = 0;
 	struct crm_workq_task           *task = NULL;
 	struct cam_req_mgr_core_link    *link = NULL;
-	struct cam_req_mgr_sof_notify   *notify_sof;
+	struct cam_req_mgr_trigger_notify   *notify_trigger;
 	struct crm_task_payload         *task_data;
 
-	if (!sof_data) {
+	if (!trigger_data) {
 		CAM_ERR(CAM_CRM, "sof_data is NULL");
 		rc = -EINVAL;
 		goto end;
 	}
 
 	link = (struct cam_req_mgr_core_link *)
-		cam_get_device_priv(sof_data->link_hdl);
+		cam_get_device_priv(trigger_data->link_hdl);
 	if (!link) {
-		CAM_DBG(CAM_CRM, "link ptr NULL %x", sof_data->link_hdl);
+		CAM_DBG(CAM_CRM, "link ptr NULL %x", trigger_data->link_hdl);
 		rc = -EINVAL;
 		goto end;
 	}
@@ -1519,17 +1565,18 @@
 	task = cam_req_mgr_workq_get_task(link->workq);
 	if (!task) {
 		CAM_ERR(CAM_CRM, "no empty task frame %lld",
-			sof_data->frame_id);
+			trigger_data->frame_id);
 		rc = -EBUSY;
 		goto end;
 	}
 	task_data = (struct crm_task_payload *)task->payload;
 	task_data->type = CRM_WORKQ_TASK_NOTIFY_SOF;
-	notify_sof = (struct cam_req_mgr_sof_notify *)&task_data->u;
-	notify_sof->frame_id = sof_data->frame_id;
-	notify_sof->link_hdl = sof_data->link_hdl;
-	notify_sof->dev_hdl = sof_data->dev_hdl;
-	task->process_cb = &cam_req_mgr_process_sof;
+	notify_trigger = (struct cam_req_mgr_trigger_notify *)&task_data->u;
+	notify_trigger->frame_id = trigger_data->frame_id;
+	notify_trigger->link_hdl = trigger_data->link_hdl;
+	notify_trigger->dev_hdl = trigger_data->dev_hdl;
+	notify_trigger->trigger = trigger_data->trigger;
+	task->process_cb = &cam_req_mgr_process_trigger;
 	rc = cam_req_mgr_workq_enqueue_task(task, link, CRM_TASK_PRIORITY_0);
 
 end:
@@ -1537,9 +1584,9 @@
 }
 
 static struct cam_req_mgr_crm_cb cam_req_mgr_ops = {
-	.notify_sof = cam_req_mgr_cb_notify_sof,
-	.notify_err = cam_req_mgr_cb_notify_err,
-	.add_req    = cam_req_mgr_cb_add_req,
+	.notify_trigger = cam_req_mgr_cb_notify_trigger,
+	.notify_err     = cam_req_mgr_cb_notify_err,
+	.add_req        = cam_req_mgr_cb_add_req,
 };
 
 /**
@@ -1561,6 +1608,7 @@
 	struct cam_req_mgr_connected_device    *dev;
 	struct cam_req_mgr_req_tbl             *pd_tbl;
 	enum cam_pipeline_delay                 max_delay;
+	uint32_t                                subscribe_event = 0;
 
 	if (link_info->num_devices > CAM_REQ_MGR_MAX_HANDLES)
 		return -EPERM;
@@ -1594,9 +1642,11 @@
 
 		trace_cam_req_mgr_connect_device(link, &dev->dev_info);
 
-		CAM_DBG(CAM_CRM, "%x: connected: %s, id %d, delay %d",
+		CAM_DBG(CAM_CRM,
+			"%x: connected: %s, id %d, delay %d, trigger %x",
 			link_info->session_hdl, dev->dev_info.name,
-			dev->dev_info.dev_id, dev->dev_info.p_delay);
+			dev->dev_info.dev_id, dev->dev_info.p_delay,
+			dev->dev_info.trigger);
 		if (rc < 0 ||
 			dev->dev_info.p_delay >=
 			CAM_PIPELINE_DELAY_MAX ||
@@ -1609,18 +1659,19 @@
 				link_info->session_hdl,
 				dev->dev_info.name,
 				dev->dev_info.p_delay);
-			if (dev->dev_info.p_delay >
-				max_delay)
-			max_delay =
-				dev->dev_info.p_delay;
+			if (dev->dev_info.p_delay > max_delay)
+				max_delay = dev->dev_info.p_delay;
+
+			subscribe_event |= (uint32_t)dev->dev_info.trigger;
 		}
 	}
 
-
+	link->subscribe_event = subscribe_event;
 	link_data.link_enable = 1;
 	link_data.link_hdl = link->link_hdl;
 	link_data.crm_cb = &cam_req_mgr_ops;
 	link_data.max_delay = max_delay;
+	link_data.subscribe_event = subscribe_event;
 
 	for (i = 0; i < link_info->num_devices; i++) {
 		dev = &link->l_dev[i];
@@ -1875,10 +1926,7 @@
 	cam_destroy_device_hdl(link->link_hdl);
 	link_info->link_hdl = 0;
 link_hdl_fail:
-	mutex_lock(&link->lock);
-	link->state = CAM_CRM_LINK_STATE_AVAILABLE;
-	mutex_unlock(&link->lock);
-
+	__cam_req_mgr_unreserve_link(cam_session, &link);
 	mutex_unlock(&g_crm_core_dev->crm_lock);
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
index 3ee0e2f..3687a5a 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
@@ -47,15 +47,15 @@
 
 /**
  * struct crm_task_payload
- * @type       : to identify which type of task is present
- * @u          : union of payload of all types of tasks supported
- * @sched_req  : contains info of  incoming reqest from CSL to CRM
- * @flush_info : contains info of cancelled reqest
- * @dev_req    : contains tracking info of available req id at device
- * @send_req   : contains info of apply settings to be sent to devs in link
- * @apply_req  : contains info of which request is applied at device
- * @notify_sof : contains notification from IFE to CRM about SOF trigger
- * @notify_err : contains error info happened while processing request
+ * @type           : to identify which type of task is present
+ * @u              : union of payload of all types of tasks supported
+ * @sched_req      : contains info of  incoming reqest from CSL to CRM
+ * @flush_info     : contains info of cancelled reqest
+ * @dev_req        : contains tracking info of available req id at device
+ * @send_req       : contains info of apply settings to be sent to devs in link
+ * @apply_req      : contains info of which request is applied at device
+ * @notify_trigger : contains notification from IFE to CRM about trigger
+ * @notify_err     : contains error info happened while processing request
  * -
  */
 struct crm_task_payload {
@@ -65,7 +65,7 @@
 		struct cam_req_mgr_flush_info           flush_info;
 		struct cam_req_mgr_add_request          dev_req;
 		struct cam_req_mgr_send_request         send_req;
-		struct cam_req_mgr_sof_notify           notify_sof;
+		struct cam_req_mgr_trigger_notify       notify_trigger;
 		struct cam_req_mgr_error_notify         notify_err;
 	} u;
 };
@@ -90,8 +90,8 @@
  * State machine for life cycle of request in input queue
  * NO_REQ     : empty slot
  * REQ_ADDED  : new entry in slot
- * INCOMPLETE : waiting for
- * APPLIED    : req is sent to devices
+ * PENDING    : waiting for next trigger to apply
+ * APPLIED    : req is sent to all devices
  * INVALID    : invalid state
  */
 enum crm_slot_status {
@@ -108,7 +108,7 @@
  * AVAILABLE  : link available
  * IDLE       : link initialized but not ready yet
  * READY      : link is ready for use
- * ERR	      : link has encountered error
+ * ERR        : link has encountered error
  * MAX        : invalid state
  */
 enum cam_req_mgr_link_state {
@@ -173,6 +173,7 @@
  * @pd_delta      : differnce between this table's pipeline delay and next
  * @num_slots     : number of request slots present in the table
  * @slot          : array of slots tracking requests availability at devices
+ * @inject_delay  : insert extra bubbling for flash type of use cases
  */
 struct cam_req_mgr_req_tbl {
 	int32_t                     id;
@@ -184,17 +185,18 @@
 	int32_t                     pd_delta;
 	int32_t                     num_slots;
 	struct cam_req_mgr_tbl_slot slot[MAX_REQ_SLOTS];
+	uint32_t                    inject_delay;
 };
 
 /**
  * struct cam_req_mgr_slot
  * - Internal Book keeping
- * @idx      : slot index
- * @skip_idx : if req id in this slot needs to be skipped/not applied
- * @status   : state machine for life cycle of a slot
+ * @idx          : slot index
+ * @skip_idx     : if req id in this slot needs to be skipped/not applied
+ * @status       : state machine for life cycle of a slot
  * - members updated due to external events
- * @recover  : if user enabled recovery for this request.
- * @req_id   : mask tracking which all devices have request ready
+ * @recover      : if user enabled recovery for this request.
+ * @req_id       : mask tracking which all devices have request ready
  */
 struct cam_req_mgr_slot {
 	int32_t               idx;
@@ -275,6 +277,9 @@
  * @state          : link state machine
  * @parent         : pvt data - link's parent is session
  * @lock           : mutex lock to guard link data operations
+ * @subscribe_event: irqs that link subscribes, IFE should send notification
+ * to CRM at those hw events.
+ * @trigger_mask   : mask on which irq the req is already applied
  */
 struct cam_req_mgr_core_link {
 	int32_t                              link_hdl;
@@ -289,6 +294,8 @@
 	enum cam_req_mgr_link_state          state;
 	void                                *parent;
 	struct mutex                         lock;
+	uint32_t                             subscribe_event;
+	uint32_t                             trigger_mask;
 };
 
 /**
@@ -310,7 +317,6 @@
 	int32_t                       session_hdl;
 	uint32_t                      num_links;
 	struct cam_req_mgr_core_link *links[MAX_LINKS_PER_SESSION];
-	struct cam_req_mgr_req_queue  in_q;
 	struct list_head              entry;
 	struct mutex                  lock;
 	int32_t                       force_err_recovery;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
index f61c41e..475b640 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
@@ -15,13 +15,9 @@
 #define CRM_TRACE_ENABLE 0
 #define CRM_DEBUG_MUTEX 0
 
-#define SET_SUCCESS_BIT(ret, pd)	{\
-	(ret) |= (1 << (pd));	\
-	}
+#define SET_SUCCESS_BIT(ret, pd)  (ret |= (1 << (pd)))
 
-#define SET_FAILURE_BIT(ret, pd)	{\
-	(ret) &= (0 << (pd));	\
-	}
+#define SET_FAILURE_BIT(ret, pd)  (ret &= (~(1 << (pd))))
 
 #define CRM_GET_REQ_ID(in_q, idx) in_q->slot[idx].req_id
 
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
index 7a2bc09..e4bc98f 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
@@ -500,6 +500,12 @@
 	g_dev.video = NULL;
 }
 
+void cam_register_subdev_fops(struct v4l2_file_operations *fops)
+{
+	*fops = v4l2_subdev_fops;
+}
+EXPORT_SYMBOL(cam_register_subdev_fops);
+
 int cam_register_subdev(struct cam_subdev *csd)
 {
 	struct v4l2_subdev *sd;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
index 8faf35a..ce8dfa7 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
@@ -18,7 +18,7 @@
 #include "cam_req_mgr_core_defs.h"
 #include "cam_req_mgr_util.h"
 
-struct cam_req_mgr_sof_notify;
+struct cam_req_mgr_trigger_notify;
 struct cam_req_mgr_error_notify;
 struct cam_req_mgr_add_request;
 struct cam_req_mgr_device_info;
@@ -29,13 +29,15 @@
 
 /* Request Manager -- camera device driver interface */
 /**
- * @brief: camera kernel drivers  to cam req mgr communication
+ * @brief: camera kernel drivers to cam req mgr communication
  *
- * @cam_req_mgr_notify_sof: for device which generates sof to inform CRM
- * @cam_req_mgr_notify_err: device use this to inform about different errors.
- * @cam_req_mgr_add_req: to info CRm about new rqeuest received from userspace
+ * @cam_req_mgr_notify_trigger: for device which generates trigger to inform CRM
+ * @cam_req_mgr_notify_err    : device use this to inform about different errors
+ * @cam_req_mgr_add_req       : to info CRm about new rqeuest received from
+ *                              userspace
  */
-typedef int (*cam_req_mgr_notify_sof)(struct cam_req_mgr_sof_notify *);
+typedef int (*cam_req_mgr_notify_trigger)(
+	struct cam_req_mgr_trigger_notify *);
 typedef int (*cam_req_mgr_notify_err)(struct cam_req_mgr_error_notify *);
 typedef int (*cam_req_mgr_add_req)(struct cam_req_mgr_add_request *);
 
@@ -57,16 +59,16 @@
 typedef int (*cam_req_mgr_process_evt)(struct cam_req_mgr_link_evt_data *);
 
 /**
- * @brief      : cam_req_mgr_crm_cb - func table
+ * @brief          : cam_req_mgr_crm_cb - func table
  *
- * @notify_sof : payload for sof indication event
- * @notify_err : payload for different error occurred at device
- * @add_req    : payload to inform which device and what request is received
+ * @notify_trigger : payload for trigger indication event
+ * @notify_err     : payload for different error occurred at device
+ * @add_req        : payload to inform which device and what request is received
  */
 struct cam_req_mgr_crm_cb {
-	cam_req_mgr_notify_sof  notify_sof;
-	cam_req_mgr_notify_err  notify_err;
-	cam_req_mgr_add_req     add_req;
+	cam_req_mgr_notify_trigger  notify_trigger;
+	cam_req_mgr_notify_err      notify_err;
+	cam_req_mgr_add_req         add_req;
 };
 
 /**
@@ -103,6 +105,13 @@
 };
 
 /**
+ * @CAM_TRIGGER_POINT_SOF   : Trigger point for SOF
+ * @CAM_TRIGGER_POINT_EOF   : Trigger point for EOF
+ */
+#define CAM_TRIGGER_POINT_SOF     (1 << 0)
+#define CAM_TRIGGER_POINT_EOF     (1 << 1)
+
+/**
  * enum cam_req_status
  * @brief   : enumerator for request status
  *
@@ -177,15 +186,18 @@
 };
 
 /**
- * struct cam_req_mgr_sof_notify
+ * struct cam_req_mgr_trigger_notify
  * @link_hdl : link identifier
  * @dev_hdl  : device handle which has sent this req id
  * @frame_id : frame id for internal tracking
+ * @trigger  : trigger point of this notification, CRM will send apply
+ * only to the devices which subscribe to this point.
  */
-struct cam_req_mgr_sof_notify {
-	int32_t link_hdl;
-	int32_t dev_hdl;
-	int64_t frame_id;
+struct cam_req_mgr_trigger_notify {
+	int32_t  link_hdl;
+	int32_t  dev_hdl;
+	int64_t  frame_id;
+	uint32_t trigger;
 };
 
 /**
@@ -204,15 +216,18 @@
 
 /**
  * struct cam_req_mgr_add_request
- * @link_hdl : link identifier
- * @dev_hdl  : device handle which has sent this req id
- * @req_id   : req id which device is ready to process
- *
+ * @link_hdl             : link identifier
+ * @dev_hdl              : device handle which has sent this req id
+ * @req_id               : req id which device is ready to process
+ * @skip_before_applying : before applying req mgr introduce bubble
+ *                         by not sending request to device/s.
+ *                         ex: IFE and Flash
  */
 struct cam_req_mgr_add_request {
 	int32_t  link_hdl;
 	int32_t  dev_hdl;
 	uint64_t req_id;
+	uint32_t skip_before_applying;
 };
 
 
@@ -223,6 +238,7 @@
  * @name    : link link or unlink
  * @dev_id  : device id info
  * @p_delay : delay between time settings applied and take effect
+ * @trigger : Trigger point for the client
  *
  */
 struct cam_req_mgr_device_info {
@@ -230,15 +246,17 @@
 	char                        name[256];
 	enum cam_req_mgr_device_id  dev_id;
 	enum cam_pipeline_delay     p_delay;
+	uint32_t                    trigger;
 };
 
 /**
  * struct cam_req_mgr_core_dev_link_setup
- * @link_enable : link link or unlink
- * @link_hdl    : link identifier
- * @dev_hdl     : device handle for reference
- * @max_delay   : max pipeline delay on this link
- * @crm_cb      : callback funcs to communicate with req mgr
+ * @link_enable     : link link or unlink
+ * @link_hdl        : link identifier
+ * @dev_hdl         : device handle for reference
+ * @max_delay       : max pipeline delay on this link
+ * @crm_cb          : callback funcs to communicate with req mgr
+ * @subscribe_event : the mask of trigger points this link subscribes
  *
  */
 struct cam_req_mgr_core_dev_link_setup {
@@ -247,6 +265,7 @@
 	int32_t                    dev_hdl;
 	enum cam_pipeline_delay    max_delay;
 	struct cam_req_mgr_crm_cb *crm_cb;
+	uint32_t                   subscribe_event;
 };
 
 /**
@@ -255,6 +274,7 @@
  * @dev_hdl          : device handle for cross check
  * @request_id       : request id settings to apply
  * @report_if_bubble : report to crm if failure in applying
+ * @trigger_point    : the trigger point of this apply
  *
  */
 struct cam_req_mgr_apply_request {
@@ -262,6 +282,7 @@
 	int32_t    dev_hdl;
 	uint64_t   request_id;
 	int32_t    report_if_bubble;
+	uint32_t   trigger_point;
 };
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
index a9134fb..1d2169b 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
@@ -203,29 +203,29 @@
 
 	spin_lock_bh(&hdl_tbl_lock);
 	if (!hdl_tbl) {
-		CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "Hdl tbl is NULL");
 		goto device_priv_fail;
 	}
 
 	idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
 	if (idx >= CAM_REQ_MGR_MAX_HANDLES) {
-		CAM_ERR(CAM_CRM, "Invalid idx");
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx");
 		goto device_priv_fail;
 	}
 
 	if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
-		CAM_ERR(CAM_CRM, "Invalid state");
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state");
 		goto device_priv_fail;
 	}
 
 	type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
 	if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) {
-		CAM_ERR(CAM_CRM, "Invalid type");
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type");
 		goto device_priv_fail;
 	}
 
 	if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
-		CAM_ERR(CAM_CRM, "Invalid hdl");
+		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid hdl");
 		goto device_priv_fail;
 	}
 
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_subdev.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_subdev.h
index 78f2223..8cd3214 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_subdev.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_subdev.h
@@ -82,6 +82,15 @@
 int cam_subdev_remove(struct cam_subdev *sd);
 
 /**
+ * cam_register_subdev_fops()
+ *
+ * @brief:   This common utility function assigns subdev ops
+ *
+ * @fops:    v4l file operations
+ */
+void cam_register_subdev_fops(struct v4l2_file_operations *fops);
+
+/**
  * cam_register_subdev()
  *
  * @brief:   This is the common utility function to be called by each camera
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
index b66480c..94a591c 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
@@ -6,3 +6,4 @@
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor/
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash/
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
index 18097b0..c3475b6 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
@@ -16,6 +16,70 @@
 #include "cam_sensor_util.h"
 #include "cam_trace.h"
 
+static int32_t cam_actuator_i2c_modes_util(
+	struct camera_io_master *io_master_info,
+	struct i2c_settings_list *i2c_list)
+{
+	int32_t rc = 0;
+	uint32_t i, size;
+
+	if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) {
+		rc = camera_io_dev_write(io_master_info,
+			&(i2c_list->i2c_settings));
+		if (rc < 0) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed to random write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_SEQ) {
+		rc = camera_io_dev_write_continuous(
+			io_master_info,
+			&(i2c_list->i2c_settings),
+			0);
+		if (rc < 0) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed to seq write I2C settings: %d",
+				rc);
+			return rc;
+			}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_BURST) {
+		rc = camera_io_dev_write_continuous(
+			io_master_info,
+			&(i2c_list->i2c_settings),
+			1);
+		if (rc < 0) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed to burst write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
+		size = i2c_list->i2c_settings.size;
+		for (i = 0; i < size; i++) {
+			rc = camera_io_dev_poll(
+			io_master_info,
+			i2c_list->i2c_settings.
+				reg_setting[i].reg_addr,
+			i2c_list->i2c_settings.
+				reg_setting[i].reg_data,
+			i2c_list->i2c_settings.
+				reg_setting[i].data_mask,
+			i2c_list->i2c_settings.addr_type,
+				i2c_list->i2c_settings.data_type,
+			i2c_list->i2c_settings.
+				reg_setting[i].delay);
+			if (rc < 0) {
+				CAM_ERR(CAM_ACTUATOR,
+					"i2c poll apply setting Fail: %d", rc);
+				return rc;
+			}
+		}
+	}
+
+	return rc;
+}
+
 int32_t cam_actuator_slaveInfo_pkt_parser(struct cam_actuator_ctrl_t *a_ctrl,
 	uint32_t *cmd_buf)
 {
@@ -28,12 +92,23 @@
 	}
 
 	i2c_info = (struct cam_cmd_i2c_info *)cmd_buf;
-	a_ctrl->io_master_info.cci_client->i2c_freq_mode =
-		i2c_info->i2c_freq_mode;
-	a_ctrl->io_master_info.cci_client->sid =
-		i2c_info->slave_addr >> 1;
-	CAM_DBG(CAM_ACTUATOR, "Slave addr: 0x%x Freq Mode: %d",
-		i2c_info->slave_addr, i2c_info->i2c_freq_mode);
+	if (a_ctrl->io_master_info.master_type == CCI_MASTER) {
+		a_ctrl->io_master_info.cci_client->cci_i2c_master =
+			a_ctrl->cci_i2c_master;
+		a_ctrl->io_master_info.cci_client->i2c_freq_mode =
+			i2c_info->i2c_freq_mode;
+		a_ctrl->io_master_info.cci_client->sid =
+			i2c_info->slave_addr >> 1;
+		CAM_DBG(CAM_ACTUATOR, "Slave addr: 0x%x Freq Mode: %d",
+			i2c_info->slave_addr, i2c_info->i2c_freq_mode);
+	} else if (a_ctrl->io_master_info.master_type == I2C_MASTER) {
+		a_ctrl->io_master_info.client->addr = i2c_info->slave_addr;
+		CAM_DBG(CAM_ACTUATOR, "Slave addr: 0x%x", i2c_info->slave_addr);
+	} else {
+		CAM_ERR(CAM_ACTUATOR, "Invalid Master type: %d",
+			a_ctrl->io_master_info.master_type);
+		 rc = -EINVAL;
+	}
 
 	return rc;
 }
@@ -43,7 +118,6 @@
 {
 	struct i2c_settings_list *i2c_list;
 	int32_t rc = 0;
-	uint32_t i, size;
 
 	if (a_ctrl == NULL || i2c_set == NULL) {
 		CAM_ERR(CAM_ACTUATOR, "Invalid Args");
@@ -57,35 +131,14 @@
 
 	list_for_each_entry(i2c_list,
 		&(i2c_set->list_head), list) {
-		if (i2c_list->op_code ==  CAM_SENSOR_I2C_WRITE_RANDOM) {
-			rc = camera_io_dev_write(&(a_ctrl->io_master_info),
-				&(i2c_list->i2c_settings));
-			if (rc < 0) {
-				CAM_ERR(CAM_ACTUATOR,
-					"Failed in Applying i2c wrt settings");
-				return rc;
-			}
-		} else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
-			size = i2c_list->i2c_settings.size;
-			for (i = 0; i < size; i++) {
-				rc = camera_io_dev_poll(
-					&(a_ctrl->io_master_info),
-					i2c_list->i2c_settings.
-						reg_setting[i].reg_addr,
-					i2c_list->i2c_settings.
-						reg_setting[i].reg_data,
-					i2c_list->i2c_settings.
-						reg_setting[i].data_mask,
-					i2c_list->i2c_settings.addr_type,
-					i2c_list->i2c_settings.data_type,
-					i2c_list->i2c_settings.
-						reg_setting[i].delay);
-				if (rc < 0) {
-					CAM_ERR(CAM_ACTUATOR,
-						"i2c poll apply setting Fail");
-					return rc;
-				}
-			}
+		rc = cam_actuator_i2c_modes_util(
+			&(a_ctrl->io_master_info),
+			i2c_list);
+		if (rc < 0) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed to apply settings: %d",
+				rc);
+			return rc;
 		}
 	}
 
@@ -110,7 +163,7 @@
 	}
 	request_id = apply->request_id % MAX_PER_FRAME_ARRAY;
 
-	trace_cam_apply_req("Actuator", apply);
+	trace_cam_apply_req("Actuator", apply->request_id);
 
 	CAM_DBG(CAM_ACTUATOR, "Request Id: %lld", apply->request_id);
 
@@ -185,6 +238,7 @@
 	info->dev_id = CAM_REQ_MGR_DEVICE_ACTUATOR;
 	strlcpy(info->name, CAM_ACTUATOR_NAME, sizeof(info->name));
 	info->p_delay = 0;
+	info->trigger = CAM_TRIGGER_POINT_SOF;
 
 	return 0;
 }
@@ -318,6 +372,7 @@
 		add_req.link_hdl = a_ctrl->bridge_intf.link_hdl;
 		add_req.req_id = csl_packet->header.request_id;
 		add_req.dev_hdl = a_ctrl->bridge_intf.device_hdl;
+		add_req.skip_before_applying = 0;
 		if (a_ctrl->bridge_intf.crm_cb &&
 			a_ctrl->bridge_intf.crm_cb->add_req)
 			a_ctrl->bridge_intf.crm_cb->add_req(&add_req);
@@ -502,7 +557,7 @@
 	case CAM_QUERY_CAP: {
 		struct cam_actuator_query_cap actuator_cap = {0};
 
-		actuator_cap.slot_info = a_ctrl->id;
+		actuator_cap.slot_info = a_ctrl->soc_info.index;
 		if (copy_to_user((void __user *) cmd->handle, &actuator_cap,
 			sizeof(struct cam_actuator_query_cap))) {
 			CAM_ERR(CAM_ACTUATOR, "Failed Copy to User");
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
index 7eba9d1..45dbba1 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
@@ -35,11 +35,94 @@
 	return rc;
 }
 
+#ifdef CONFIG_COMPAT
+static long cam_actuator_init_subdev_do_ioctl(struct v4l2_subdev *sd,
+	unsigned int cmd, unsigned long arg)
+{
+	struct cam_control cmd_data;
+	int32_t rc = 0;
+
+	if (copy_from_user(&cmd_data, (void __user *)arg,
+		sizeof(cmd_data))) {
+		CAM_ERR(CAM_ACTUATOR,
+			"Failed to copy from user_ptr=%pK size=%zu",
+			(void __user *)arg, sizeof(cmd_data));
+		return -EFAULT;
+	}
+
+	switch (cmd) {
+	case VIDIOC_CAM_CONTROL:
+		cmd = VIDIOC_CAM_CONTROL;
+		rc = cam_actuator_subdev_ioctl(sd, cmd, &cmd_data);
+		if (rc) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed in actuator subdev handling rc: %d",
+				rc);
+			return rc;
+		}
+	break;
+	default:
+		CAM_ERR(CAM_ACTUATOR, "Invalid compat ioctl: %d", cmd);
+		rc = -EINVAL;
+	}
+
+	if (!rc) {
+		if (copy_to_user((void __user *)arg, &cmd_data,
+			sizeof(cmd_data))) {
+			CAM_ERR(CAM_ACTUATOR,
+				"Failed to copy to user_ptr=%pK size=%zu",
+				(void __user *)arg, sizeof(cmd_data));
+			rc = -EFAULT;
+		}
+	}
+	return rc;
+}
+#endif
+
+static struct v4l2_subdev_core_ops cam_actuator_subdev_core_ops = {
+	.ioctl = cam_actuator_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl32 = cam_actuator_init_subdev_do_ioctl,
+#endif
+};
+
+static struct v4l2_subdev_ops cam_actuator_subdev_ops = {
+	.core = &cam_actuator_subdev_core_ops,
+};
+
+static const struct v4l2_subdev_internal_ops cam_actuator_internal_ops;
+
+static int cam_actuator_init_subdev(struct cam_actuator_ctrl_t *a_ctrl)
+{
+	int rc = 0;
+
+	a_ctrl->v4l2_dev_str.internal_ops =
+		&cam_actuator_internal_ops;
+	a_ctrl->v4l2_dev_str.ops =
+		&cam_actuator_subdev_ops;
+	strlcpy(a_ctrl->device_name, CAMX_ACTUATOR_DEV_NAME,
+		sizeof(a_ctrl->device_name));
+	a_ctrl->v4l2_dev_str.name =
+		a_ctrl->device_name;
+	a_ctrl->v4l2_dev_str.sd_flags =
+		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
+	a_ctrl->v4l2_dev_str.ent_function =
+		CAM_ACTUATOR_DEVICE_TYPE;
+	a_ctrl->v4l2_dev_str.token = a_ctrl;
+
+	rc = cam_register_subdev(&(a_ctrl->v4l2_dev_str));
+	if (rc)
+		CAM_ERR(CAM_SENSOR, "Fail with cam_register_subdev rc: %d", rc);
+
+	return rc;
+}
+
 static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
 {
 	int32_t rc = 0, i = 0;
 	struct cam_actuator_ctrl_t *a_ctrl;
+	struct cam_hw_soc_info *soc_info = NULL;
 
 	if (client == NULL || id == NULL) {
 		CAM_ERR(CAM_ACTUATOR, "Invalid Args client: %pK id: %pK",
@@ -61,13 +144,29 @@
 
 	i2c_set_clientdata(client, a_ctrl);
 
+	a_ctrl->io_master_info.client = client;
+	soc_info = &a_ctrl->soc_info;
+	soc_info->dev = &client->dev;
+	soc_info->dev_name = client->name;
+	a_ctrl->io_master_info.master_type = I2C_MASTER;
+
+	rc = cam_actuator_parse_dt(a_ctrl, &client->dev);
+	if (rc < 0) {
+		CAM_ERR(CAM_ACTUATOR, "failed: cam_sensor_parse_dt rc %d", rc);
+		goto free_ctrl;
+	}
+
+	rc = cam_actuator_init_subdev(a_ctrl);
+	if (rc)
+		goto free_ctrl;
+
 	a_ctrl->i2c_data.per_frame =
 		(struct i2c_settings_array *)
 		kzalloc(sizeof(struct i2c_settings_array) *
 		MAX_PER_FRAME_ARRAY, GFP_KERNEL);
 	if (a_ctrl->i2c_data.per_frame == NULL) {
 		rc = -ENOMEM;
-		goto free_ctrl;
+		goto unreg_subdev;
 	}
 
 	INIT_LIST_HEAD(&(a_ctrl->i2c_data.init_settings.list_head));
@@ -75,18 +174,28 @@
 	for (i = 0; i < MAX_PER_FRAME_ARRAY; i++)
 		INIT_LIST_HEAD(&(a_ctrl->i2c_data.per_frame[i].list_head));
 
-	/* Initialize sensor device type */
-	a_ctrl->io_master_info.master_type = I2C_MASTER;
-
-	rc = cam_actuator_parse_dt(a_ctrl, &client->dev);
+	rc = cam_soc_util_request_platform_resource(&a_ctrl->soc_info,
+		NULL, NULL);
 	if (rc < 0) {
-		CAM_ERR(CAM_ACTUATOR, "failed: cam_sensor_parse_dt rc %d", rc);
+		CAM_ERR(CAM_ACTUATOR,
+			"Requesting Platform Resources failed rc %d", rc);
 		goto free_mem;
 	}
 
+	a_ctrl->bridge_intf.device_hdl = -1;
+	a_ctrl->bridge_intf.ops.get_dev_info =
+		cam_actuator_publish_dev_info;
+	a_ctrl->bridge_intf.ops.link_setup =
+		cam_actuator_establish_link;
+	a_ctrl->bridge_intf.ops.apply_req =
+		cam_actuator_apply_request;
+
+	v4l2_set_subdevdata(&(a_ctrl->v4l2_dev_str.sd), a_ctrl);
 	return rc;
 free_mem:
 	kfree(a_ctrl->i2c_data.per_frame);
+unreg_subdev:
+	cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
 free_ctrl:
 	kfree(a_ctrl);
 	return rc;
@@ -129,63 +238,6 @@
 	return rc;
 }
 
-#ifdef CONFIG_COMPAT
-static long cam_actuator_init_subdev_do_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, unsigned long arg)
-{
-	struct cam_control cmd_data;
-	int32_t rc = 0;
-
-	if (copy_from_user(&cmd_data, (void __user *)arg,
-		sizeof(cmd_data))) {
-		CAM_ERR(CAM_ACTUATOR,
-			"Failed to copy from user_ptr=%pK size=%zu\n",
-			(void __user *)arg, sizeof(cmd_data));
-		return -EFAULT;
-	}
-
-	switch (cmd) {
-	case VIDIOC_CAM_CONTROL:
-		cmd = VIDIOC_CAM_CONTROL;
-		rc = cam_actuator_subdev_ioctl(sd, cmd, &cmd_data);
-		if (rc < 0) {
-			CAM_ERR(CAM_ACTUATOR,
-				"Failed in actuator suddev handling");
-			return rc;
-		}
-		break;
-	default:
-		CAM_ERR(CAM_ACTUATOR, "Invalid compat ioctl: %d", cmd);
-		rc = -EINVAL;
-	}
-
-	if (!rc) {
-		if (copy_to_user((void __user *)arg, &cmd_data,
-			sizeof(cmd_data))) {
-			CAM_ERR(CAM_ACTUATOR,
-				"Failed to copy to user_ptr=%pK size=%zu\n",
-				(void __user *)arg, sizeof(cmd_data));
-			rc = -EFAULT;
-		}
-	}
-	return rc;
-}
-
-#endif
-
-static struct v4l2_subdev_core_ops cam_actuator_subdev_core_ops = {
-	.ioctl = cam_actuator_subdev_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl32 = cam_actuator_init_subdev_do_ioctl,
-#endif
-};
-
-static struct v4l2_subdev_ops cam_actuator_subdev_ops = {
-	.core = &cam_actuator_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops cam_actuator_internal_ops;
-
 static const struct of_device_id cam_actuator_driver_dt_match[] = {
 	{.compatible = "qcom,actuator"},
 	{}
@@ -206,7 +258,8 @@
 	/*fill in platform device*/
 	a_ctrl->v4l2_dev_str.pdev = pdev;
 	a_ctrl->soc_info.pdev = pdev;
-
+	a_ctrl->soc_info.dev = &pdev->dev;
+	a_ctrl->soc_info.dev_name = pdev->name;
 	a_ctrl->io_master_info.master_type = CCI_MASTER;
 
 	a_ctrl->io_master_info.cci_client = kzalloc(sizeof(
@@ -233,34 +286,18 @@
 	}
 
 	/* Fill platform device id*/
-	pdev->id = a_ctrl->id;
+	pdev->id = a_ctrl->soc_info.index;
 
-	a_ctrl->v4l2_dev_str.internal_ops =
-		&cam_actuator_internal_ops;
-	a_ctrl->v4l2_dev_str.ops =
-		&cam_actuator_subdev_ops;
-	strlcpy(a_ctrl->device_name, CAMX_ACTUATOR_DEV_NAME,
-		sizeof(a_ctrl->device_name));
-	a_ctrl->v4l2_dev_str.name =
-		a_ctrl->device_name;
-	a_ctrl->v4l2_dev_str.sd_flags =
-		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
-	a_ctrl->v4l2_dev_str.ent_function =
-		CAM_ACTUATOR_DEVICE_TYPE;
-	a_ctrl->v4l2_dev_str.token = a_ctrl;
-
-	rc = cam_register_subdev(&(a_ctrl->v4l2_dev_str));
-	if (rc < 0) {
-		CAM_ERR(CAM_ACTUATOR, "Fail with cam_register_subdev");
+	rc = cam_actuator_init_subdev(a_ctrl);
+	if (rc)
 		goto free_mem;
-	}
 
 	rc = cam_soc_util_request_platform_resource(&a_ctrl->soc_info,
 			NULL, NULL);
 	if (rc < 0) {
 		CAM_ERR(CAM_ACTUATOR,
 			"Requesting Platform Resources failed rc %d", rc);
-		goto free_ctrl;
+		goto unreg_subdev;
 	}
 
 	a_ctrl->bridge_intf.device_hdl = -1;
@@ -275,6 +312,8 @@
 	v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, a_ctrl);
 
 	return rc;
+unreg_subdev:
+	cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
 free_mem:
 	kfree(a_ctrl->i2c_data.per_frame);
 free_ctrl:
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
index fdf881f3..ad42a3d 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
@@ -75,7 +75,6 @@
  * @cci_i2c_master: I2C structure
  * @io_master_info: Information about the communication master
  * @actuator_mutex: Actuator mutex
- * @id: Cell Index
  * @act_apply_state: Actuator settings aRegulator config
  * @gconf: GPIO config
  * @pinctrl_info: Pinctrl information
@@ -91,7 +90,6 @@
 	struct camera_io_master io_master_info;
 	struct cam_hw_soc_info soc_info;
 	struct mutex actuator_mutex;
-	uint32_t id;
 	enum msm_actuator_state_t act_apply_state;
 	struct msm_camera_gpio_num_info *gpio_num_info;
 	uint8_t cam_pinctrl_status;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
index ddc89a8..f47ec2f 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
@@ -25,15 +25,6 @@
 	int32_t                   rc = 0;
 	struct cam_hw_soc_info *soc_info = &a_ctrl->soc_info;
 	struct device_node *of_node = NULL;
-	struct platform_device *pdev = NULL;
-
-	if (!soc_info->pdev) {
-		CAM_ERR(CAM_ACTUATOR, "soc_info is not initialized");
-		return -EINVAL;
-	}
-
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
 
 	/* Initialize mutex */
 	mutex_init(&(a_ctrl->actuator_mutex));
@@ -43,14 +34,19 @@
 		CAM_ERR(CAM_ACTUATOR, "parsing common soc dt(rc %d)", rc);
 		return rc;
 	}
-	rc = of_property_read_u32(of_node, "cci-master",
-		&(a_ctrl->cci_i2c_master));
-	CAM_DBG(CAM_ACTUATOR, "cci-master %d, rc %d",
-		a_ctrl->cci_i2c_master, rc);
-	if (rc < 0 || a_ctrl->cci_i2c_master >= MASTER_MAX) {
-		CAM_ERR(CAM_ACTUATOR, "Wrong info from dt CCI master as : %d",
-			a_ctrl->cci_i2c_master);
-		return rc;
+
+	of_node = soc_info->dev->of_node;
+
+	if (a_ctrl->io_master_info.master_type == CCI_MASTER) {
+		rc = of_property_read_u32(of_node, "cci-master",
+			&(a_ctrl->cci_i2c_master));
+		CAM_DBG(CAM_ACTUATOR, "cci-master %d, rc %d",
+			a_ctrl->cci_i2c_master, rc);
+		if ((rc < 0) || (a_ctrl->cci_i2c_master >= MASTER_MAX)) {
+			CAM_ERR(CAM_ACTUATOR, "Wrong info: dt CCI master:%d",
+				a_ctrl->cci_i2c_master);
+			return rc;
+		}
 	}
 
 	if (!soc_info->gpio_data) {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
index 975b301..c62b251 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
@@ -424,7 +424,8 @@
 	msg = &c_ctrl->cfg.cci_i2c_write_cfg;
 	*pack = 0;
 
-	if (c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ) {
+	if (c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ ||
+		c_ctrl->cmd == MSM_CCI_I2C_WRITE_BURST) {
 		addr_len = cam_cci_convert_type_to_num_bytes(msg->addr_type);
 		len = (size + addr_len) <= (cci_dev->payload_size) ?
 			(size + addr_len):cci_dev->payload_size;
@@ -725,24 +726,29 @@
 		do {
 			if (i2c_msg->data_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
 				data[i++] = i2c_cmd->reg_data;
-				reg_addr++;
+				if (c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ)
+					reg_addr++;
 			} else {
 				if ((i + 1) <= cci_dev->payload_size) {
 					data[i++] = (i2c_cmd->reg_data &
 						0xFF00) >> 8; /* MSB */
 					data[i++] = i2c_cmd->reg_data &
 						0x00FF; /* LSB */
-					reg_addr++;
+					if (c_ctrl->cmd ==
+						MSM_CCI_I2C_WRITE_SEQ)
+						reg_addr++;
 				} else
 					break;
 			}
 			i2c_cmd++;
 			--cmd_size;
-		} while (((c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ) || pack--) &&
+		} while (((c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ ||
+			c_ctrl->cmd == MSM_CCI_I2C_WRITE_BURST) || pack--) &&
 				(cmd_size > 0) && (i <= cci_dev->payload_size));
 		free_size = cam_cci_get_queue_free_size(cci_dev, master,
 				queue);
-		if ((c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ) &&
+		if ((c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ ||
+			c_ctrl->cmd == MSM_CCI_I2C_WRITE_BURST) &&
 			((i-1) == MSM_CCI_WRITE_DATA_PAYLOAD_SIZE_11) &&
 			cci_dev->support_seq_write && cmd_size > 0 &&
 			free_size > BURST_MIN_FREE_SIZE) {
@@ -1205,10 +1211,8 @@
 	rc = cam_cci_soc_release(cci_dev);
 	if (rc < 0) {
 		CAM_ERR(CAM_CCI, "Failed in releasing the cci: %d", rc);
-		cam_cpas_stop(cci_dev->cpas_handle);
 		return rc;
 	}
-	cam_cpas_stop(cci_dev->cpas_handle);
 
 	return rc;
 }
@@ -1253,6 +1257,7 @@
 		break;
 	case MSM_CCI_I2C_WRITE:
 	case MSM_CCI_I2C_WRITE_SEQ:
+	case MSM_CCI_I2C_WRITE_BURST:
 		for (i = 0; i < NUM_QUEUES; i++) {
 			if (mutex_trylock(&cci_master_info->mutex_q[i])) {
 				rc = cam_cci_i2c_write(sd, c_ctrl, i,
@@ -1295,6 +1300,7 @@
 		break;
 	case MSM_CCI_I2C_WRITE:
 	case MSM_CCI_I2C_WRITE_SEQ:
+	case MSM_CCI_I2C_WRITE_BURST:
 	case MSM_CCI_I2C_WRITE_SYNC:
 	case MSM_CCI_I2C_WRITE_ASYNC:
 	case MSM_CCI_I2C_WRITE_SYNC_BLOCK:
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
index dad02bf..6cfb965 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
@@ -30,6 +30,11 @@
 {
 	int32_t rc = 0;
 
+	if (arg == NULL) {
+		CAM_ERR(CAM_CCI, "Invalid Args");
+		return rc;
+	}
+
 	switch (cmd) {
 	case VIDIOC_MSM_CCI_CFG:
 		rc = cam_cci_core_cfg(sd, arg);
@@ -44,6 +49,14 @@
 	return rc;
 }
 
+#ifdef CONFIG_COMPAT
+static long cam_cci_subdev_compat_ioctl(struct v4l2_subdev *sd,
+	unsigned int cmd, unsigned long arg)
+{
+	return cam_cci_subdev_ioctl(sd, cmd, NULL);
+}
+#endif
+
 irqreturn_t cam_cci_irq(int irq_num, void *data)
 {
 	uint32_t irq;
@@ -162,6 +175,9 @@
 
 static struct v4l2_subdev_core_ops cci_subdev_core_ops = {
 	.ioctl = cam_cci_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl32 = cam_cci_subdev_compat_ioctl,
+#endif
 	.interrupt_service_routine = cam_cci_irq_routine,
 };
 
@@ -171,6 +187,34 @@
 
 static const struct v4l2_subdev_internal_ops cci_subdev_intern_ops;
 
+static struct v4l2_file_operations cci_v4l2_subdev_fops;
+
+static long cam_cci_subdev_do_ioctl(
+	struct file *file, unsigned int cmd, void *arg)
+{
+	struct video_device *vdev = video_devdata(file);
+	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
+
+	return cam_cci_subdev_ioctl(sd, cmd, NULL);
+}
+
+static long cam_cci_subdev_fops_ioctl(struct file *file, unsigned int cmd,
+	unsigned long arg)
+{
+	return video_usercopy(file, cmd, arg, cam_cci_subdev_do_ioctl);
+}
+
+#ifdef CONFIG_COMPAT
+static long cam_cci_subdev_fops_compat_ioctl(struct file *file,
+	unsigned int cmd, unsigned long arg)
+{
+	struct video_device *vdev = video_devdata(file);
+	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
+
+	return v4l2_subdev_call(sd, core, ioctl, cmd, NULL);
+}
+#endif
+
 static int cam_cci_platform_probe(struct platform_device *pdev)
 {
 	struct cam_cpas_register_params cpas_parms;
@@ -188,6 +232,8 @@
 	new_cci_dev->v4l2_dev_str.pdev = pdev;
 
 	soc_info->pdev = pdev;
+	soc_info->dev = &pdev->dev;
+	soc_info->dev_name = pdev->name;
 
 	rc = cam_cci_parse_dt_info(pdev, new_cci_dev);
 	if (rc < 0) {
@@ -220,6 +266,13 @@
 	v4l2_set_subdevdata(&new_cci_dev->v4l2_dev_str.sd, new_cci_dev);
 	g_cci_subdev = &new_cci_dev->v4l2_dev_str.sd;
 
+	cam_register_subdev_fops(&cci_v4l2_subdev_fops);
+	cci_v4l2_subdev_fops.unlocked_ioctl = cam_cci_subdev_fops_ioctl;
+#ifdef CONFIG_COMPAT
+	cci_v4l2_subdev_fops.compat_ioctl32 =
+		cam_cci_subdev_fops_compat_ioctl;
+#endif
+
 	cpas_parms.cam_cpas_client_cb = NULL;
 	cpas_parms.cell_index = 0;
 	cpas_parms.dev = &pdev->dev;
@@ -269,6 +322,26 @@
 	},
 };
 
+static int cam_cci_assign_fops(void)
+{
+	struct v4l2_subdev *sd;
+
+	sd = g_cci_subdev;
+	if (!sd || !(sd->devnode)) {
+		CAM_ERR(CAM_CRM,
+			"Invalid args sd node: %pK", sd);
+		return -EINVAL;
+	}
+	sd->devnode->fops = &cci_v4l2_subdev_fops;
+
+	return 0;
+}
+
+static int __init cam_cci_late_init(void)
+{
+	return cam_cci_assign_fops();
+}
+
 static int __init cam_cci_init_module(void)
 {
 	return platform_driver_register(&cci_driver);
@@ -280,6 +353,7 @@
 }
 
 module_init(cam_cci_init_module);
+late_initcall(cam_cci_late_init);
 module_exit(cam_cci_exit_module);
 MODULE_DESCRIPTION("MSM CCI driver");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
index cb01c6c..4c996e08 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
@@ -95,6 +95,7 @@
 	MSM_CCI_I2C_READ,
 	MSM_CCI_I2C_WRITE,
 	MSM_CCI_I2C_WRITE_SEQ,
+	MSM_CCI_I2C_WRITE_BURST,
 	MSM_CCI_I2C_WRITE_ASYNC,
 	MSM_CCI_GPIO_WRITE,
 	MSM_CCI_I2C_WRITE_SYNC,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
index 83cb49e3..8de4472 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
@@ -392,5 +392,7 @@
 	cci_dev->cycles_per_us = 0;
 	soc_info->src_clk_idx = 0;
 
+	cam_cpas_stop(cci_dev->cpas_handle);
+
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
index fcf76c8..57d576a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
@@ -14,8 +14,34 @@
 #include "cam_csiphy_core.h"
 #include "cam_csiphy_dev.h"
 #include "cam_csiphy_soc.h"
+
+#include <soc/qcom/scm.h>
 #include <cam_mem_mgr.h>
 
+#define SCM_SVC_CAMERASS 0x18
+#define SECURE_SYSCALL_ID 0x6
+
+static int csiphy_dump;
+module_param(csiphy_dump, int, 0644);
+
+static int cam_csiphy_notify_secure_mode(int phy, bool protect)
+{
+	struct scm_desc desc = {0};
+
+	desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL);
+	desc.args[0] = protect;
+	desc.args[1] = phy;
+
+	CAM_DBG(CAM_CSIPHY, "phy : %d, protect : %d", phy, protect);
+	if (scm_call2(SCM_SIP_FNID(SCM_SVC_CAMERASS, SECURE_SYSCALL_ID),
+		&desc)) {
+		CAM_ERR(CAM_CSIPHY, "scm call to hypervisor failed");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 void cam_csiphy_query_cap(struct csiphy_device *csiphy_dev,
 	struct cam_csiphy_query_cap *csiphy_cap)
 {
@@ -67,17 +93,10 @@
 		return -EINVAL;
 	}
 
-	csiphy_dev->csiphy_info =
-		kzalloc(sizeof(struct cam_csiphy_info), GFP_KERNEL);
-	if (!csiphy_dev->csiphy_info)
-		return -ENOMEM;
-
 	rc = cam_mem_get_cpu_buf((int32_t) cfg_dev->packet_handle,
 		(uint64_t *)&generic_ptr, &len);
 	if (rc < 0) {
 		CAM_ERR(CAM_CSIPHY, "Failed to get packet Mem address: %d", rc);
-		kfree(csiphy_dev->csiphy_info);
-		csiphy_dev->csiphy_info = NULL;
 		return rc;
 	}
 
@@ -85,8 +104,6 @@
 		CAM_ERR(CAM_CSIPHY,
 			"offset is out of bounds: offset: %lld len: %zu",
 			cfg_dev->offset, len);
-		kfree(csiphy_dev->csiphy_info);
-		csiphy_dev->csiphy_info = NULL;
 		return -EINVAL;
 	}
 
@@ -101,8 +118,6 @@
 	if (rc < 0) {
 		CAM_ERR(CAM_CSIPHY,
 			"Failed to get cmd buf Mem address : %d", rc);
-		kfree(csiphy_dev->csiphy_info);
-		csiphy_dev->csiphy_info = NULL;
 		return rc;
 	}
 
@@ -110,13 +125,26 @@
 	cmd_buf += cmd_desc->offset / 4;
 	cam_cmd_csiphy_info = (struct cam_csiphy_info *)cmd_buf;
 
-	csiphy_dev->csiphy_info->lane_cnt = cam_cmd_csiphy_info->lane_cnt;
-	csiphy_dev->csiphy_info->lane_mask = cam_cmd_csiphy_info->lane_mask;
-	csiphy_dev->csiphy_info->csiphy_3phase =
+	csiphy_dev->config_count++;
+	csiphy_dev->csiphy_info.lane_cnt += cam_cmd_csiphy_info->lane_cnt;
+	csiphy_dev->csiphy_info.lane_mask |= cam_cmd_csiphy_info->lane_mask;
+	csiphy_dev->csiphy_info.csiphy_3phase =
 		cam_cmd_csiphy_info->csiphy_3phase;
-	csiphy_dev->csiphy_info->combo_mode = cam_cmd_csiphy_info->combo_mode;
-	csiphy_dev->csiphy_info->settle_time = cam_cmd_csiphy_info->settle_time;
-	csiphy_dev->csiphy_info->data_rate = cam_cmd_csiphy_info->data_rate;
+	csiphy_dev->csiphy_info.combo_mode |= cam_cmd_csiphy_info->combo_mode;
+	if (cam_cmd_csiphy_info->combo_mode == 1)
+		csiphy_dev->csiphy_info.settle_time_combo_sensor =
+			cam_cmd_csiphy_info->settle_time;
+	else
+		csiphy_dev->csiphy_info.settle_time =
+			cam_cmd_csiphy_info->settle_time;
+	csiphy_dev->csiphy_info.data_rate = cam_cmd_csiphy_info->data_rate;
+	csiphy_dev->csiphy_info.secure_mode = cam_cmd_csiphy_info->secure_mode;
+
+	if (csiphy_dev->csiphy_info.secure_mode &&
+		(csiphy_dev->config_count == 1))
+		rc = cam_csiphy_notify_secure_mode(
+			csiphy_dev->soc_info.index,
+			CAM_SECURE_MODE_SECURE);
 
 	return rc;
 }
@@ -202,14 +230,8 @@
 	void __iomem *csiphybase;
 	struct csiphy_reg_t (*reg_array)[MAX_SETTINGS_PER_LANE];
 
-	if (csiphy_dev->csiphy_info == NULL) {
-		CAM_ERR(CAM_CSIPHY, "csiphy_info is NULL, No/Fail CONFIG_DEV?");
-		return -EINVAL;
-	}
-
-	lane_cnt = csiphy_dev->csiphy_info->lane_cnt;
-	lane_mask = csiphy_dev->csiphy_info->lane_mask & 0x1f;
-	settle_cnt = (csiphy_dev->csiphy_info->settle_time / 200000000);
+	lane_cnt = csiphy_dev->csiphy_info.lane_cnt;
+	lane_mask = csiphy_dev->csiphy_info.lane_mask & 0x1f;
 	csiphybase = csiphy_dev->soc_info.reg_map[0].mem_base;
 
 	if (!csiphybase) {
@@ -228,8 +250,8 @@
 		mask <<= 1;
 	}
 
-	if (!csiphy_dev->csiphy_info->csiphy_3phase) {
-		if (csiphy_dev->csiphy_info->combo_mode == 1)
+	if (!csiphy_dev->csiphy_info.csiphy_3phase) {
+		if (csiphy_dev->csiphy_info.combo_mode == 1)
 			reg_array =
 				csiphy_dev->ctrl_reg->csiphy_2ph_combo_mode_reg;
 		else
@@ -239,7 +261,7 @@
 		cfg_size = csiphy_dev->ctrl_reg->csiphy_reg.
 			csiphy_2ph_config_array_size;
 	} else {
-		if (csiphy_dev->csiphy_info->combo_mode == 1)
+		if (csiphy_dev->csiphy_info.combo_mode == 1)
 			reg_array =
 				csiphy_dev->ctrl_reg->csiphy_2ph_3ph_mode_reg;
 		else
@@ -280,6 +302,12 @@
 			continue;
 		}
 
+		settle_cnt = (csiphy_dev->csiphy_info.settle_time / 200000000);
+		if (csiphy_dev->csiphy_info.combo_mode == 1 &&
+			(lane_pos >= 3))
+			settle_cnt =
+				(csiphy_dev->csiphy_info.
+				settle_time_combo_sensor / 200000000);
 		for (i = 0; i < cfg_size; i++) {
 			switch (reg_array[lane_pos][i].csiphy_param_type) {
 			case CSIPHY_LANE_ENABLE:
@@ -350,6 +378,14 @@
 
 		csiphy_acq_params.combo_mode = 0;
 
+		if (copy_from_user(&csiphy_acq_params,
+			(void __user *)csiphy_acq_dev.info_handle,
+			sizeof(csiphy_acq_params))) {
+			CAM_ERR(CAM_CSIPHY,
+				"Failed copying from User");
+			goto release_mutex;
+		}
+
 		if (csiphy_dev->acquire_count == 2) {
 			CAM_ERR(CAM_CSIPHY,
 					"CSIPHY device do not allow more than 2 acquires");
@@ -357,6 +393,27 @@
 			goto release_mutex;
 		}
 
+		if ((csiphy_acq_params.combo_mode == 1) &&
+			(csiphy_dev->is_acquired_dev_combo_mode == 1)) {
+			CAM_ERR(CAM_CSIPHY,
+				"Multiple Combo Acq are not allowed: cm: %d, acm: %d",
+				csiphy_acq_params.combo_mode,
+				csiphy_dev->is_acquired_dev_combo_mode);
+			rc = -EINVAL;
+			goto release_mutex;
+		}
+
+		if ((csiphy_acq_params.combo_mode != 1) &&
+			(csiphy_dev->is_acquired_dev_combo_mode != 1) &&
+			(csiphy_dev->acquire_count == 1)) {
+			CAM_ERR(CAM_CSIPHY,
+				"Multiple Acquires are not allowed cm: %d acm: %d",
+				csiphy_acq_params.combo_mode,
+				csiphy_dev->is_acquired_dev_combo_mode);
+			rc = -EINVAL;
+			goto release_mutex;
+		}
+
 		bridge_params.ops = NULL;
 		bridge_params.session_hdl = csiphy_acq_dev.session_handle;
 		bridge_params.v4l2_sub_dev_flag = 0;
@@ -381,7 +438,9 @@
 		}
 		if (csiphy_acq_params.combo_mode == 1)
 			csiphy_dev->is_acquired_dev_combo_mode = 1;
+
 		csiphy_dev->acquire_count++;
+		csiphy_dev->csiphy_state = CAM_CSIPHY_ACQUIRE;
 	}
 		break;
 	case CAM_QUERY_CAP: {
@@ -397,6 +456,19 @@
 	}
 		break;
 	case CAM_STOP_DEV: {
+		if (csiphy_dev->csiphy_state !=
+			CAM_CSIPHY_START) {
+			CAM_ERR(CAM_CSIPHY, "Not in right state to stop : %d",
+				csiphy_dev->csiphy_state);
+			goto release_mutex;
+		}
+
+		if (--csiphy_dev->start_dev_count) {
+			CAM_DBG(CAM_CSIPHY, "Stop Dev ref Cnt: %d",
+				csiphy_dev->start_dev_count);
+			goto release_mutex;
+		}
+
 		rc = cam_csiphy_disable_hw(csiphy_dev);
 		if (rc < 0) {
 			CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
@@ -408,6 +480,8 @@
 			CAM_ERR(CAM_CSIPHY, "de-voting CPAS: %d", rc);
 			goto release_mutex;
 		}
+		csiphy_dev->csiphy_info.combo_mode = 0;
+		csiphy_dev->csiphy_state = CAM_CSIPHY_STOP;
 	}
 		break;
 	case CAM_RELEASE_DEV: {
@@ -438,8 +512,22 @@
 			csiphy_dev->bridge_intf.link_hdl[1] = -1;
 			csiphy_dev->bridge_intf.
 				session_hdl[1] = -1;
+			csiphy_dev->is_acquired_dev_combo_mode = 0;
 		}
+
+		csiphy_dev->config_count--;
 		csiphy_dev->acquire_count--;
+		if (csiphy_dev->acquire_count == 0)
+			csiphy_dev->csiphy_state = CAM_CSIPHY_RELEASE;
+
+		if (csiphy_dev->csiphy_info.secure_mode &&
+			(!csiphy_dev->config_count)) {
+			csiphy_dev->csiphy_info.secure_mode =
+				CAM_SECURE_MODE_NON_SECURE;
+			rc = cam_csiphy_notify_secure_mode(
+				csiphy_dev->soc_info.index,
+				CAM_SECURE_MODE_NON_SECURE);
+		}
 	}
 		break;
 	case CAM_CONFIG_DEV: {
@@ -461,6 +549,11 @@
 		struct cam_ahb_vote ahb_vote;
 		struct cam_axi_vote axi_vote;
 
+		csiphy_dev->start_dev_count++;
+
+		if (csiphy_dev->csiphy_state == CAM_CSIPHY_START)
+			goto release_mutex;
+
 		ahb_vote.type = CAM_VOTE_ABSOLUTE;
 		ahb_vote.vote.level = CAM_SVS_VOTE;
 		axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
@@ -480,11 +573,15 @@
 			goto release_mutex;
 		}
 		rc = cam_csiphy_config_dev(csiphy_dev);
+		if (csiphy_dump == 1)
+			cam_csiphy_mem_dmp(&csiphy_dev->soc_info);
+
 		if (rc < 0) {
 			CAM_ERR(CAM_CSIPHY, "cam_csiphy_config_dev failed");
 			cam_cpas_stop(csiphy_dev->cpas_handle);
 			goto release_mutex;
 		}
+		csiphy_dev->csiphy_state = CAM_CSIPHY_START;
 	}
 		break;
 	case CAM_SD_SHUTDOWN:
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
index 1c93a1a..a136fa7 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
@@ -113,7 +113,8 @@
 	new_csiphy_dev->v4l2_dev_str.pdev = pdev;
 
 	new_csiphy_dev->soc_info.pdev = pdev;
-
+	new_csiphy_dev->soc_info.dev = &pdev->dev;
+	new_csiphy_dev->soc_info.dev_name = pdev->name;
 	new_csiphy_dev->ref_count = 0;
 
 	rc = cam_csiphy_parse_dt_info(pdev, new_csiphy_dev);
@@ -156,6 +157,7 @@
 		NULL;
 
 	new_csiphy_dev->acquire_count = 0;
+	new_csiphy_dev->start_dev_count = 0;
 	new_csiphy_dev->is_acquired_dev_combo_mode = 0;
 
 	cpas_parms.cam_cpas_client_cb = NULL;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
index 8ed5ba4..25891c5 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
@@ -67,6 +67,13 @@
 #define CDBG(fmt, args...) pr_debug(fmt, ##args)
 #endif
 
+enum cam_csiphy_state {
+	CAM_CSIPHY_ACQUIRE,
+	CAM_CSIPHY_RELEASE,
+	CAM_CSIPHY_START,
+	CAM_CSIPHY_STOP,
+};
+
 /**
  * struct csiphy_reg_parms_t
  * @mipi_csiphy_glbl_irq_cmd_addr: CSIPhy irq addr
@@ -150,6 +157,32 @@
 };
 
 /**
+ * cam_csiphy_param: Provides cmdbuffer structre
+ * @lane_mask     :  Lane mask details
+ * @lane_assign   :  Lane sensor will be using
+ * @csiphy_3phase :  Mentions DPHY or CPHY
+ * @combo_mode    :  Info regarding combo_mode is enable / disable
+ * @lane_cnt      :  Total number of lanes
+ * @reserved
+ * @3phase        :  Details whether 3Phase / 2Phase operation
+ * @settle_time   :  Settling time in ms
+ * @settle_time_combo_sensor   :  Settling time in ms
+ * @data_rate     :  Data rate in mbps
+ *
+ */
+struct cam_csiphy_param {
+	uint16_t    lane_mask;
+	uint16_t    lane_assign;
+	uint8_t     csiphy_3phase;
+	uint8_t     combo_mode;
+	uint8_t     lane_cnt;
+	uint8_t     secure_mode;
+	uint64_t    settle_time;
+	uint64_t    settle_time_combo_sensor;
+	uint64_t    data_rate;
+};
+
+/**
  * struct csiphy_device
  * @pdev: Platform device
  * @irq: Interrupt structure
@@ -171,6 +204,7 @@
  * @ref_count: Reference count
  * @clk_lane: Clock lane
  * @acquire_count: Acquire device count
+ * @start_dev_count: Start count
  * @is_acquired_dev_combo_mode:
  *    Flag that mentions whether already acquired
  *   device is for combo mode
@@ -178,7 +212,7 @@
 struct csiphy_device {
 	struct mutex mutex;
 	uint32_t hw_version;
-	uint32_t csiphy_state;
+	enum cam_csiphy_state csiphy_state;
 	struct csiphy_ctrl_t *ctrl_reg;
 	uint32_t csiphy_max_clk;
 	struct msm_cam_clk_info csiphy_3p_clk_info[2];
@@ -190,14 +224,16 @@
 	uint8_t is_csiphy_3phase_hw;
 	uint8_t num_irq_registers;
 	struct cam_subdev v4l2_dev_str;
-	struct cam_csiphy_info *csiphy_info;
+	struct cam_csiphy_param csiphy_info;
 	struct intf_params bridge_intf;
 	uint32_t clk_lane;
 	uint32_t acquire_count;
+	uint32_t start_dev_count;
 	char device_name[20];
 	uint32_t is_acquired_dev_combo_mode;
 	struct cam_hw_soc_info   soc_info;
 	uint32_t cpas_handle;
+	uint32_t config_count;
 };
 
 #endif /* _CAM_CSIPHY_DEV_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
index a79e0d4..d2a8467 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
@@ -14,7 +14,47 @@
 #include "cam_csiphy_core.h"
 #include "include/cam_csiphy_1_0_hwreg.h"
 
-#ifdef CAM_CSIPHY_MEM_DMP
+#define BYTES_PER_REGISTER           4
+#define NUM_REGISTER_PER_LINE        4
+#define REG_OFFSET(__start, __i)    ((__start) + ((__i) * BYTES_PER_REGISTER))
+
+static int cam_io_phy_dump(void __iomem *base_addr,
+	uint32_t start_offset, int size)
+{
+	char          line_str[128];
+	char         *p_str;
+	int           i;
+	uint32_t      data;
+
+	CAM_INFO(CAM_CSIPHY, "addr=%pK offset=0x%x size=%d",
+		base_addr, start_offset, size);
+
+	if (!base_addr || (size <= 0))
+		return -EINVAL;
+
+	line_str[0] = '\0';
+	p_str = line_str;
+	for (i = 0; i < size; i++) {
+		if (i % NUM_REGISTER_PER_LINE == 0) {
+			snprintf(p_str, 12, "0x%08x: ",
+				REG_OFFSET(start_offset, i));
+			p_str += 11;
+		}
+		data = readl_relaxed(base_addr + REG_OFFSET(start_offset, i));
+		snprintf(p_str, 9, "%08x ", data);
+		p_str += 8;
+		if ((i + 1) % NUM_REGISTER_PER_LINE == 0) {
+			CAM_ERR(CAM_CSIPHY, "%s", line_str);
+			line_str[0] = '\0';
+			p_str = line_str;
+		}
+	}
+	if (line_str[0] != '\0')
+		CAM_ERR(CAM_CSIPHY, "%s", line_str);
+
+	return 0;
+}
+
 int32_t cam_csiphy_mem_dmp(struct cam_hw_soc_info *soc_info)
 {
 	int32_t rc = 0;
@@ -28,14 +68,13 @@
 	}
 	addr = soc_info->reg_map[0].mem_base;
 	size = resource_size(soc_info->mem_block[0]);
-	rc = cam_io_dump(addr, 0, (size >> 2));
+	rc = cam_io_phy_dump(addr, 0, (size >> 2));
 	if (rc < 0) {
 		CAM_ERR(CAM_CSIPHY, "generating dump failed %d", rc);
 		return rc;
 	}
 	return rc;
 }
-#endif
 
 int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev)
 {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
index 96697f9..a173954 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
@@ -243,7 +243,8 @@
 	struct camera_io_master *client = &e_ctrl->io_master_info;
 	uint8_t                  id[2];
 
-	rc = cam_spi_query_id(client, 0, &id[0], 2);
+	rc = cam_spi_query_id(client, 0, CAMERA_SENSOR_I2C_TYPE_WORD,
+		&id[0], 2);
 	if (rc)
 		return rc;
 	CAM_DBG(CAM_EEPROM, "read 0x%x 0x%x, check 0x%x 0x%x",
@@ -310,6 +311,8 @@
 data_mem_free:
 	kfree(e_ctrl->cal_data.mapdata);
 	kfree(e_ctrl->cal_data.map);
+	e_ctrl->cal_data.num_data = 0;
+	e_ctrl->cal_data.num_map = 0;
 	return rc;
 }
 
@@ -483,7 +486,7 @@
 	uint16_t                        cmd_length_in_bytes = 0;
 	struct cam_cmd_i2c_info        *i2c_info = NULL;
 	int                             num_map = -1;
-	struct cam_eeprom_memory_map_t *map;
+	struct cam_eeprom_memory_map_t *map = NULL;
 	struct cam_eeprom_soc_private  *soc_private =
 		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
 	struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info;
@@ -617,7 +620,7 @@
 				return -EINVAL;
 			}
 
-			CAM_ERR(CAM_EEPROM, "copy the data, len:%d",
+			CAM_DBG(CAM_EEPROM, "copy the data, len:%d",
 				e_ctrl->cal_data.num_data);
 			memcpy(read_buffer, e_ctrl->cal_data.mapdata,
 					e_ctrl->cal_data.num_data);
@@ -664,53 +667,60 @@
 	switch (csl_packet->header.op_code & 0xFFFFFF) {
 	case CAM_EEPROM_PACKET_OPCODE_INIT:
 		if (e_ctrl->userspace_probe == false) {
-			rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
-			CAM_ERR(CAM_EEPROM,
-				"Eeprom already probed at kernel boot");
-			rc = -EINVAL;
-		break;
-		}
-		if (e_ctrl->cal_data.num_data == 0) {
-			rc = cam_eeprom_init_pkt_parser(e_ctrl, csl_packet);
-			if (rc) {
-				CAM_ERR(CAM_EEPROM,
-					"Failed in parsing the pkt");
+			rc = cam_eeprom_parse_read_memory_map(
+					e_ctrl->pdev->dev.of_node, e_ctrl);
+			if (rc < 0) {
+				CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc);
 				return rc;
 			}
-
-			e_ctrl->cal_data.mapdata =
-				kzalloc(e_ctrl->cal_data.num_data, GFP_KERNEL);
-			if (!e_ctrl->cal_data.mapdata) {
-				rc = -ENOMEM;
-				CAM_ERR(CAM_EEPROM, "failed");
-				goto error;
-			}
-
-			rc = cam_eeprom_power_up(e_ctrl,
-				&soc_private->power_info);
-			if (rc) {
-				CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
-				goto memdata_free;
-			}
-
-			rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
-			if (rc) {
-				CAM_ERR(CAM_EEPROM,
-					"read_eeprom_memory failed");
-				goto power_down;
-			}
-
 			rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
-			rc = cam_eeprom_power_down(e_ctrl);
-		} else {
-			CAM_DBG(CAM_EEPROM, "Already read eeprom");
+			kfree(e_ctrl->cal_data.mapdata);
+			kfree(e_ctrl->cal_data.map);
+			e_ctrl->cal_data.num_data = 0;
+			e_ctrl->cal_data.num_map = 0;
+			CAM_DBG(CAM_EEPROM,
+				"Returning the data using kernel probe");
+		break;
 		}
+		rc = cam_eeprom_init_pkt_parser(e_ctrl, csl_packet);
+		if (rc) {
+			CAM_ERR(CAM_EEPROM,
+				"Failed in parsing the pkt");
+			return rc;
+		}
+
+		e_ctrl->cal_data.mapdata =
+			kzalloc(e_ctrl->cal_data.num_data, GFP_KERNEL);
+		if (!e_ctrl->cal_data.mapdata) {
+			rc = -ENOMEM;
+			CAM_ERR(CAM_EEPROM, "failed");
+			goto error;
+		}
+
+		rc = cam_eeprom_power_up(e_ctrl,
+			&soc_private->power_info);
+		if (rc) {
+			CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
+			goto memdata_free;
+		}
+
+		rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
+		if (rc) {
+			CAM_ERR(CAM_EEPROM,
+				"read_eeprom_memory failed");
+			goto power_down;
+		}
+
+		rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
+		rc = cam_eeprom_power_down(e_ctrl);
+		kfree(e_ctrl->cal_data.mapdata);
+		kfree(e_ctrl->cal_data.map);
+		e_ctrl->cal_data.num_data = 0;
+		e_ctrl->cal_data.num_map = 0;
 		break;
 	default:
 		break;
 	}
-	kfree(e_ctrl->cal_data.mapdata);
-	kfree(e_ctrl->cal_data.map);
 	return rc;
 power_down:
 	rc = cam_eeprom_power_down(e_ctrl);
@@ -718,6 +728,8 @@
 	kfree(e_ctrl->cal_data.mapdata);
 error:
 	kfree(e_ctrl->cal_data.map);
+	e_ctrl->cal_data.num_data = 0;
+	e_ctrl->cal_data.num_map = 0;
 	return rc;
 }
 
@@ -731,7 +743,7 @@
 int32_t cam_eeprom_driver_cmd(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
 {
 	int                            rc = 0;
-	struct cam_eeprom_query_cap_t  eeprom_cap;
+	struct cam_eeprom_query_cap_t  eeprom_cap = {0};
 	struct cam_control            *cmd = (struct cam_control *)arg;
 
 	if (!e_ctrl) {
@@ -742,7 +754,7 @@
 	mutex_lock(&(e_ctrl->eeprom_mutex));
 	switch (cmd->op_code) {
 	case CAM_QUERY_CAP:
-		eeprom_cap.slot_info = e_ctrl->subdev_id;
+		eeprom_cap.slot_info = e_ctrl->soc_info.index;
 		if (e_ctrl->userspace_probe == false)
 			eeprom_cap.eeprom_kernel_probe = true;
 		else
@@ -764,6 +776,23 @@
 			goto release_mutex;
 		}
 		break;
+	case CAM_RELEASE_DEV:
+		if (e_ctrl->bridge_intf.device_hdl == -1) {
+			CAM_ERR(CAM_EEPROM,
+				"Invalid Handles: link hdl: %d device hdl: %d",
+				e_ctrl->bridge_intf.device_hdl,
+				e_ctrl->bridge_intf.link_hdl);
+			rc = -EINVAL;
+			goto release_mutex;
+		}
+		rc = cam_destroy_device_hdl(e_ctrl->bridge_intf.device_hdl);
+		if (rc < 0)
+			CAM_ERR(CAM_EEPROM,
+				"failed in destroying the device hdl");
+		e_ctrl->bridge_intf.device_hdl = -1;
+		e_ctrl->bridge_intf.link_hdl = -1;
+		e_ctrl->bridge_intf.session_hdl = -1;
+		break;
 	case CAM_CONFIG_DEV:
 		rc = cam_eeprom_pkt_parse(e_ctrl, arg);
 		if (rc) {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
index 82dcc9c..88d7665 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
@@ -111,12 +111,34 @@
 	.core = &cam_eeprom_subdev_core_ops,
 };
 
+static int cam_eeprom_init_subdev(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+	int rc = 0;
+
+	e_ctrl->v4l2_dev_str.internal_ops = &cam_eeprom_internal_ops;
+	e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
+	strlcpy(e_ctrl->device_name, CAM_EEPROM_NAME,
+		sizeof(e_ctrl->device_name));
+	e_ctrl->v4l2_dev_str.name = e_ctrl->device_name;
+	e_ctrl->v4l2_dev_str.sd_flags =
+		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
+	e_ctrl->v4l2_dev_str.ent_function = CAM_EEPROM_DEVICE_TYPE;
+	e_ctrl->v4l2_dev_str.token = e_ctrl;
+
+	rc = cam_register_subdev(&(e_ctrl->v4l2_dev_str));
+	if (rc)
+		CAM_ERR(CAM_SENSOR, "Fail with cam_register_subdev");
+
+	return rc;
+}
+
 static int cam_eeprom_i2c_driver_probe(struct i2c_client *client,
 	 const struct i2c_device_id *id)
 {
 	int                             rc = 0;
 	struct cam_eeprom_ctrl_t       *e_ctrl = NULL;
 	struct cam_eeprom_soc_private  *soc_private = NULL;
+	struct cam_hw_soc_info         *soc_info = NULL;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		CAM_ERR(CAM_EEPROM, "i2c_check_functionality failed");
@@ -129,27 +151,64 @@
 		rc = -ENOMEM;
 		goto probe_failure;
 	}
-	e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
+
+	soc_private = kzalloc(sizeof(*soc_private), GFP_KERNEL);
+	if (!soc_private)
+		goto ectrl_free;
+
+	e_ctrl->soc_info.soc_private = soc_private;
+
+	i2c_set_clientdata(client, e_ctrl);
+
+	mutex_init(&(e_ctrl->eeprom_mutex));
+
+	soc_info = &e_ctrl->soc_info;
+	soc_info->dev = &client->dev;
+	soc_info->dev_name = client->name;
+	e_ctrl->io_master_info.master_type = I2C_MASTER;
+	e_ctrl->io_master_info.client = client;
+	e_ctrl->eeprom_device_type = MSM_CAMERA_I2C_DEVICE;
+
+	rc = cam_eeprom_parse_dt(e_ctrl);
+	if (rc) {
+		CAM_ERR(CAM_EEPROM, "failed: soc init rc %d", rc);
+		goto free_soc;
+	}
+
+	rc = cam_eeprom_update_i2c_info(e_ctrl, &soc_private->i2c_info);
+	if (rc) {
+		CAM_ERR(CAM_EEPROM, "failed: to update i2c info rc %d", rc);
+		goto free_soc;
+	}
+
 	soc_private = (struct cam_eeprom_soc_private *)(id->driver_data);
 	if (!soc_private) {
 		CAM_ERR(CAM_EEPROM, "board info NULL");
 		rc = -EINVAL;
 		goto ectrl_free;
 	}
+
+	rc = cam_eeprom_init_subdev(e_ctrl);
+	if (rc)
+		goto free_soc;
+
 	e_ctrl->cal_data.mapdata = NULL;
 	e_ctrl->cal_data.map = NULL;
 	e_ctrl->userspace_probe = false;
 
-	e_ctrl->eeprom_device_type = MSM_CAMERA_I2C_DEVICE;
-	e_ctrl->io_master_info.master_type = I2C_MASTER;
-	e_ctrl->io_master_info.client = client;
-
 	if (soc_private->i2c_info.slave_addr != 0)
 		e_ctrl->io_master_info.client->addr =
 			soc_private->i2c_info.slave_addr;
 
-	return rc;
+	e_ctrl->bridge_intf.device_hdl = -1;
+	e_ctrl->bridge_intf.ops.get_dev_info = NULL;
+	e_ctrl->bridge_intf.ops.link_setup = NULL;
+	e_ctrl->bridge_intf.ops.apply_req = NULL;
+	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, e_ctrl);
 
+	return rc;
+free_soc:
+	kfree(soc_private);
 ectrl_free:
 	kfree(e_ctrl);
 probe_failure:
@@ -180,8 +239,6 @@
 		return -EINVAL;
 	}
 
-	kfree(e_ctrl->cal_data.mapdata);
-	kfree(e_ctrl->cal_data.map);
 	if (soc_private) {
 		kfree(soc_private->power_info.gpio_num_info);
 		kfree(soc_private);
@@ -194,6 +251,7 @@
 static int cam_eeprom_spi_setup(struct spi_device *spi)
 {
 	struct cam_eeprom_ctrl_t       *e_ctrl = NULL;
+	struct cam_hw_soc_info         *soc_info = NULL;
 	struct cam_sensor_spi_client   *spi_client;
 	struct cam_eeprom_soc_private  *eb_info;
 	struct cam_sensor_power_ctrl_t *power_info = NULL;
@@ -203,6 +261,10 @@
 	if (!e_ctrl)
 		return -ENOMEM;
 
+	soc_info = &e_ctrl->soc_info;
+	soc_info->dev = &spi->dev;
+	soc_info->dev_name = spi->modalias;
+
 	e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
 	e_ctrl->userspace_probe = false;
 	e_ctrl->cal_data.mapdata = NULL;
@@ -234,21 +296,28 @@
 	/* Initialize mutex */
 	mutex_init(&(e_ctrl->eeprom_mutex));
 
-	rc = cam_eeprom_spi_driver_soc_init(e_ctrl);
+	rc = cam_eeprom_parse_dt(e_ctrl);
 	if (rc) {
 		CAM_ERR(CAM_EEPROM, "failed: spi soc init rc %d", rc);
 		goto board_free;
 	}
 
-	if (e_ctrl->userspace_probe == false) {
-		rc = cam_eeprom_parse_read_memory_map(spi->dev.of_node,
-			e_ctrl);
-		if (rc) {
-			CAM_ERR(CAM_EEPROM, "failed: read mem map rc %d", rc);
-			goto board_free;
-		}
+	rc = cam_eeprom_spi_parse_of(spi_client);
+	if (rc) {
+		CAM_ERR(CAM_EEPROM, "Device tree parsing error");
+		goto board_free;
 	}
 
+	rc = cam_eeprom_init_subdev(e_ctrl);
+	if (rc)
+		goto board_free;
+
+	e_ctrl->bridge_intf.device_hdl = -1;
+	e_ctrl->bridge_intf.ops.get_dev_info = NULL;
+	e_ctrl->bridge_intf.ops.link_setup = NULL;
+	e_ctrl->bridge_intf.ops.apply_req = NULL;
+
+	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, e_ctrl);
 	return rc;
 
 board_free:
@@ -292,8 +361,6 @@
 	}
 
 	kfree(e_ctrl->io_master_info.spi_client);
-	kfree(e_ctrl->cal_data.mapdata);
-	kfree(e_ctrl->cal_data.map);
 	soc_private =
 		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
 	if (soc_private) {
@@ -317,6 +384,8 @@
 		return -ENOMEM;
 
 	e_ctrl->soc_info.pdev = pdev;
+	e_ctrl->soc_info.dev = &pdev->dev;
+	e_ctrl->soc_info.dev_name = pdev->name;
 	e_ctrl->eeprom_device_type = MSM_CAMERA_PLATFORM_DEVICE;
 	e_ctrl->cal_data.mapdata = NULL;
 	e_ctrl->cal_data.map = NULL;
@@ -338,7 +407,7 @@
 
 	/* Initialize mutex */
 	mutex_init(&(e_ctrl->eeprom_mutex));
-	rc = cam_eeprom_platform_driver_soc_init(e_ctrl);
+	rc = cam_eeprom_parse_dt(e_ctrl);
 	if (rc) {
 		CAM_ERR(CAM_EEPROM, "failed: soc init rc %d", rc);
 		goto free_soc;
@@ -349,30 +418,9 @@
 		goto free_soc;
 	}
 
-	if (e_ctrl->userspace_probe == false) {
-		rc = cam_eeprom_parse_read_memory_map(pdev->dev.of_node,
-			e_ctrl);
-		if (rc) {
-			CAM_ERR(CAM_EEPROM, "failed: read mem map rc %d", rc);
-			goto free_soc;
-		}
-	}
-
-	e_ctrl->v4l2_dev_str.internal_ops = &cam_eeprom_internal_ops;
-	e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
-	strlcpy(e_ctrl->device_name, CAM_EEPROM_NAME,
-		sizeof(e_ctrl->device_name));
-	e_ctrl->v4l2_dev_str.name = e_ctrl->device_name;
-	e_ctrl->v4l2_dev_str.sd_flags =
-		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
-	e_ctrl->v4l2_dev_str.ent_function = CAM_EEPROM_DEVICE_TYPE;
-	e_ctrl->v4l2_dev_str.token = e_ctrl;
-
-	rc = cam_register_subdev(&(e_ctrl->v4l2_dev_str));
-	if (rc) {
-		CAM_ERR(CAM_EEPROM, "fail to create subdev");
+	rc = cam_eeprom_init_subdev(e_ctrl);
+	if (rc)
 		goto free_soc;
-	}
 
 	e_ctrl->bridge_intf.device_hdl = -1;
 	e_ctrl->bridge_intf.ops.get_dev_info = NULL;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
index a98bf00..e06e22a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
@@ -154,7 +154,6 @@
  * @cci_i2c_master  :   I2C structure
  * @v4l2_dev_str    :   V4L2 device structure
  * @bridge_intf     :   bridge interface params
- * @subdev_id       :   subdev id
  * @userspace_probe :   flag indicates userspace or kernel probe
  * @cal_data        :   Calibration data
  * @device_name     :   Device name
@@ -171,7 +170,6 @@
 	struct cam_subdev v4l2_dev_str;
 	struct cam_eeprom_intf_params bridge_intf;
 	enum msm_camera_device_type_t eeprom_device_type;
-	uint32_t subdev_id;
 	bool userspace_probe;
 	struct cam_eeprom_memory_block_t cal_data;
 	char device_name[20];
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c
index 84e723f..70c40fd 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c
@@ -20,6 +20,96 @@
 #include "cam_eeprom_soc.h"
 #include "cam_debug_util.h"
 
+#define cam_eeprom_spi_parse_cmd(spi_dev, name, out)          \
+	{                                                     \
+		spi_dev->cmd_tbl.name.opcode = out[0];        \
+		spi_dev->cmd_tbl.name.addr_len = out[1];      \
+		spi_dev->cmd_tbl.name.dummy_len = out[2];     \
+		spi_dev->cmd_tbl.name.delay_intv = out[3];    \
+		spi_dev->cmd_tbl.name.delay_count = out[4];   \
+	}
+
+int cam_eeprom_spi_parse_of(struct cam_sensor_spi_client *spi_dev)
+{
+	int rc = -EFAULT;
+	uint32_t tmp[5];
+
+	rc  = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-read", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, read, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get read data");
+		return -EFAULT;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-readseq", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, read_seq, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get readseq data");
+		return -EFAULT;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-queryid", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, query_id, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get queryid data");
+		return -EFAULT;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-pprog", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, page_program, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get page program data");
+		return -EFAULT;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-wenable", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, write_enable, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get write enable data");
+		return rc;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-readst", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, read_status, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get readdst data");
+		return rc;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"spiop-erase", tmp, 5);
+	if (!rc) {
+		cam_eeprom_spi_parse_cmd(spi_dev, erase, tmp);
+	} else {
+		CAM_ERR(CAM_EEPROM, "Failed to get erase data");
+		return rc;
+	}
+
+	rc = of_property_read_u32_array(spi_dev->spi_master->dev.of_node,
+		"eeprom-id", tmp, 2);
+	if (rc) {
+		CAM_ERR(CAM_EEPROM, "Failed to get eeprom id");
+		return rc;
+	}
+
+	spi_dev->mfr_id0 = tmp[0];
+	spi_dev->device_id0 = tmp[1];
+
+	return 0;
+}
+
 /*
  * cam_eeprom_parse_memory_map() - parse memory map in device node
  * @of:         device node
@@ -121,23 +211,7 @@
 	struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info;
 	struct device_node             *of_node = NULL;
 
-	if (e_ctrl->eeprom_device_type == MSM_CAMERA_SPI_DEVICE)
-		of_node = e_ctrl->io_master_info.
-			spi_client->spi_master->dev.of_node;
-	else if (e_ctrl->eeprom_device_type == MSM_CAMERA_PLATFORM_DEVICE)
-		of_node = soc_info->pdev->dev.of_node;
-
-	if (!of_node) {
-		CAM_ERR(CAM_EEPROM, "of_node is NULL, device type %d",
-			e_ctrl->eeprom_device_type);
-		return -EINVAL;
-	}
-	rc = cam_soc_util_get_dt_properties(soc_info);
-	if (rc < 0) {
-		CAM_ERR(CAM_EEPROM, "cam_soc_util_get_dt_properties rc %d",
-			rc);
-		return rc;
-	}
+	of_node = soc_info->dev->of_node;
 
 	if (e_ctrl->userspace_probe == false) {
 		rc = cam_get_dt_power_setting_data(of_node,
@@ -209,83 +283,31 @@
 /**
  * @e_ctrl: ctrl structure
  *
- * This function is called from cam_eeprom_spi_driver_probe, it parses
- * the eeprom dt node and decides for userspace or kernel probe.
+ * This function is called from cam_eeprom_platform/i2c/spi_driver_probe
+ * it parses the eeprom dt node and decides for userspace or kernel probe.
  */
-int cam_eeprom_spi_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl)
-{
-	int                             rc = 0;
-	struct cam_eeprom_soc_private  *soc_private =
-		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
-
-	rc = of_property_read_u32(e_ctrl->spi->dev.of_node, "cell-index",
-		&e_ctrl->subdev_id);
-	if (rc < 0) {
-		CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
-		return rc;
-	}
-	rc = of_property_read_string(e_ctrl->spi->dev.of_node,
-		"eeprom-name", &soc_private->eeprom_name);
-	if (rc < 0) {
-		CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
-		e_ctrl->userspace_probe = true;
-	}
-
-	CAM_DBG(CAM_EEPROM, "eeprom-name %s, rc %d", soc_private->eeprom_name,
-		rc);
-	rc = cam_eeprom_cmm_dts(soc_private,
-		e_ctrl->io_master_info.spi_client->spi_master->dev.of_node);
-	if (rc < 0)
-		CAM_DBG(CAM_EEPROM, "MM data not available rc %d", rc);
-	rc = cam_eeprom_get_dt_data(e_ctrl);
-	if (rc < 0)
-		CAM_DBG(CAM_EEPROM, "failed: eeprom get dt data rc %d", rc);
-
-	return rc;
-}
-
-/**
- * @e_ctrl: ctrl structure
- *
- * This function is called from cam_eeprom_platform_driver_probe, it parses
- * the eeprom dt node and decides for userspace or kernel probe.
- */
-int cam_eeprom_platform_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl)
+int cam_eeprom_parse_dt(struct cam_eeprom_ctrl_t *e_ctrl)
 {
 	int                             rc = 0;
 	struct cam_hw_soc_info         *soc_info = &e_ctrl->soc_info;
 	struct device_node             *of_node = NULL;
-	struct platform_device         *pdev = NULL;
 	struct cam_eeprom_soc_private  *soc_private =
 		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
 	uint32_t                        temp;
 
-	if (!soc_info->pdev) {
-		CAM_ERR(CAM_EEPROM, "Error:soc_info is not initialized");
-		return -EINVAL;
-	}
-
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
-	if (!of_node) {
-		CAM_ERR(CAM_EEPROM, "dev.of_node NULL");
-		return -EINVAL;
-	}
-
-	rc = of_property_read_u32(of_node, "cell-index",
-		&e_ctrl->subdev_id);
+	rc = cam_soc_util_get_dt_properties(soc_info);
 	if (rc < 0) {
-		CAM_ERR(CAM_EEPROM, "failed rc %d\n", rc);
+		CAM_ERR(CAM_EEPROM, "Failed to read DT properties rc : %d", rc);
 		return rc;
 	}
 
-	rc = of_property_read_u32(of_node, "cci-master",
-		&e_ctrl->cci_i2c_master);
-	if (rc < 0) {
-		CAM_DBG(CAM_EEPROM, "failed rc %d", rc);
-		return rc;
+	if (!soc_info->dev) {
+		CAM_ERR(CAM_EEPROM, "Dev is NULL");
+		return -EINVAL;
 	}
 
+	of_node = soc_info->dev->of_node;
+
 	rc = of_property_read_string(of_node, "eeprom-name",
 		&soc_private->eeprom_name);
 	if (rc < 0) {
@@ -293,11 +315,27 @@
 		e_ctrl->userspace_probe = true;
 	}
 
+	if (e_ctrl->io_master_info.master_type == CCI_MASTER) {
+		rc = of_property_read_u32(of_node, "cci-master",
+			&e_ctrl->cci_i2c_master);
+		if (rc < 0) {
+			CAM_DBG(CAM_EEPROM, "failed rc %d", rc);
+			return rc;
+		}
+	}
+
+	if (e_ctrl->io_master_info.master_type == SPI_MASTER) {
+		rc = cam_eeprom_cmm_dts(soc_private, soc_info->dev->of_node);
+		if (rc < 0)
+			CAM_DBG(CAM_EEPROM, "MM data not available rc %d", rc);
+	}
+
 	rc = cam_eeprom_get_dt_data(e_ctrl);
 	if (rc < 0)
 		CAM_DBG(CAM_EEPROM, "failed: eeprom get dt data rc %d", rc);
 
-	if (e_ctrl->userspace_probe == false) {
+	if ((e_ctrl->userspace_probe == false) &&
+			(e_ctrl->io_master_info.master_type != SPI_MASTER)) {
 		rc = of_property_read_u32(of_node, "slave-addr", &temp);
 		if (rc < 0)
 			CAM_DBG(CAM_EEPROM, "failed: no slave-addr rc %d", rc);
@@ -319,5 +357,6 @@
 		CAM_DBG(CAM_EEPROM, "slave-addr = 0x%X",
 			soc_private->i2c_info.slave_addr);
 	}
+
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h
index 02e59d7..d311549 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h
@@ -14,9 +14,10 @@
 
 #include "cam_eeprom_dev.h"
 
+int cam_eeprom_spi_parse_of(struct cam_sensor_spi_client *client);
+
 int cam_eeprom_parse_dt_memory_map(struct device_node *of,
 	struct cam_eeprom_memory_block_t *data);
 
-int cam_eeprom_platform_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl);
-int cam_eeprom_spi_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl);
+int cam_eeprom_parse_dt(struct cam_eeprom_ctrl_t *e_ctrl);
 #endif/* _CAM_EEPROM_SOC_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
index 7af7efc..b0fe293 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
@@ -67,7 +67,7 @@
 	}
 
 	soc_private = (struct cam_flash_private_soc *)
-		&flash_ctrl->soc_info.soc_private;
+		flash_ctrl->soc_info.soc_private;
 
 	if (op == CAMERA_SENSOR_FLASH_OP_FIRELOW) {
 		for (i = 0; i < flash_ctrl->torch_num_sources; i++) {
@@ -334,7 +334,8 @@
 		flash_data = &fctrl->per_frame[frame_offset];
 
 		if ((flash_data->opcode == CAMERA_SENSOR_FLASH_OP_FIREHIGH) &&
-			(flash_data->cmn_attr.is_settings_valid)) {
+			(flash_data->cmn_attr.is_settings_valid) &&
+			(flash_data->cmn_attr.request_id == req_id)) {
 			/* Turn On Flash */
 			if (fctrl->flash_state == CAM_FLASH_STATE_INIT) {
 				rc = cam_flash_high(fctrl, flash_data);
@@ -348,8 +349,9 @@
 			}
 		} else if ((flash_data->opcode ==
 			CAMERA_SENSOR_FLASH_OP_FIRELOW) &&
-			(flash_data->cmn_attr.is_settings_valid)) {
-			/* Turn Off Flash */
+			(flash_data->cmn_attr.is_settings_valid) &&
+			(flash_data->cmn_attr.request_id == req_id)) {
+			/* Turn On Torch */
 			if (fctrl->flash_state == CAM_FLASH_STATE_INIT) {
 				rc = cam_flash_low(fctrl, flash_data);
 				if (rc) {
@@ -361,7 +363,8 @@
 				fctrl->flash_state = CAM_FLASH_STATE_LOW;
 			}
 		} else if ((flash_data->opcode == CAMERA_SENSOR_FLASH_OP_OFF) &&
-			(flash_data->cmn_attr.is_settings_valid)) {
+			(flash_data->cmn_attr.is_settings_valid) &&
+			(flash_data->cmn_attr.request_id == req_id)) {
 			if ((fctrl->flash_state != CAM_FLASH_STATE_RELEASE) ||
 				(fctrl->flash_state != CAM_FLASH_STATE_INIT)) {
 				rc = cam_flash_off(fctrl);
@@ -374,10 +377,7 @@
 				}
 			}
 		} else {
-			CAM_ERR(CAM_FLASH, "Wrong opcode : %d",
-				flash_data->opcode);
-			rc = -EINVAL;
-			goto apply_setting_err;
+			CAM_DBG(CAM_FLASH, "NOP opcode: req_id: %u", req_id);
 		}
 	}
 
@@ -427,7 +427,15 @@
 		return rc;
 	}
 
-	csl_packet = (struct cam_packet *)generic_ptr;
+	if (config.offset > len_of_buffer) {
+		CAM_ERR(CAM_FLASH,
+			"offset is out of bounds: offset: %lld len: %zu",
+			config.offset, len_of_buffer);
+		return -EINVAL;
+	}
+
+	/* Add offset to the flash csl header */
+	csl_packet = (struct cam_packet *)(generic_ptr + config.offset);
 
 	switch (csl_packet->header.op_code & 0xFFFFFF) {
 	case CAM_FLASH_PACKET_OPCODE_INIT: {
@@ -462,6 +470,19 @@
 			csl_packet->cmd_buf_offset);
 		frame_offset = csl_packet->header.request_id %
 			MAX_PER_FRAME_ARRAY;
+		if (fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid
+			== true) {
+			fctrl->per_frame[frame_offset].cmn_attr.request_id = 0;
+			fctrl->per_frame[frame_offset].
+				cmn_attr.is_settings_valid = false;
+			for (i = 0;
+			i < fctrl->per_frame[frame_offset].cmn_attr.count;
+			i++) {
+				fctrl->per_frame[frame_offset].
+					led_current_ma[i] = 0;
+			}
+		}
+
 		fctrl->per_frame[frame_offset].cmn_attr.request_id =
 			csl_packet->header.request_id;
 		fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid =
@@ -471,6 +492,10 @@
 			(uint64_t *)&generic_ptr, &len_of_buffer);
 		cmd_buf = (uint32_t *)((uint8_t *)generic_ptr +
 			cmd_desc->offset);
+
+		if (!cmd_buf)
+			return -EINVAL;
+
 		cmn_hdr = (struct common_header *)cmd_buf;
 
 		switch (cmn_hdr->cmd_type) {
@@ -479,6 +504,11 @@
 				"CAMERA_FLASH_CMD_TYPE_OPS case called");
 			flash_operation_info =
 				(struct cam_flash_set_on_off *) cmd_buf;
+			if (!flash_operation_info) {
+				CAM_ERR(CAM_FLASH, "flash_operation_info Null");
+				return -EINVAL;
+			}
+
 			fctrl->per_frame[frame_offset].opcode =
 				flash_operation_info->opcode;
 			fctrl->per_frame[frame_offset].cmn_attr.count =
@@ -494,7 +524,6 @@
 				cmn_hdr->cmd_type);
 			return -EINVAL;
 		}
-
 		break;
 	}
 	case CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS: {
@@ -588,6 +617,8 @@
 		break;
 	}
 	case CAM_PKT_NOP_OPCODE: {
+		CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %u",
+			csl_packet->header.request_id);
 		goto update_req_mgr;
 	}
 	default:
@@ -603,6 +634,13 @@
 		add_req.link_hdl = fctrl->bridge_intf.link_hdl;
 		add_req.req_id = csl_packet->header.request_id;
 		add_req.dev_hdl = fctrl->bridge_intf.device_hdl;
+
+		if ((csl_packet->header.op_code & 0xFFFFF) ==
+			CAM_FLASH_PACKET_OPCODE_SET_OPS)
+			add_req.skip_before_applying = 1;
+		else
+			add_req.skip_before_applying = 0;
+
 		if (fctrl->bridge_intf.crm_cb &&
 			fctrl->bridge_intf.crm_cb->add_req)
 			fctrl->bridge_intf.crm_cb->add_req(&add_req);
@@ -617,6 +655,7 @@
 	info->dev_id = CAM_REQ_MGR_DEVICE_FLASH;
 	strlcpy(info->name, CAM_FLASH_NAME, sizeof(info->name));
 	info->p_delay = CAM_FLASH_PIPELINE_DELAY;
+	info->trigger = CAM_TRIGGER_POINT_SOF;
 	return 0;
 }
 
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
index 32df2f1..d743cf0 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
@@ -93,7 +93,7 @@
 		break;
 	}
 	case CAM_QUERY_CAP: {
-		struct cam_flash_query_cap_info flash_cap;
+		struct cam_flash_query_cap_info flash_cap = {0};
 
 		CAM_DBG(CAM_FLASH, "CAM_QUERY_CAP");
 		flash_cap.slot_info = fctrl->soc_info.index;
@@ -286,6 +286,8 @@
 
 	flash_ctrl->pdev = pdev;
 	flash_ctrl->soc_info.pdev = pdev;
+	flash_ctrl->soc_info.dev = &pdev->dev;
+	flash_ctrl->soc_info.dev_name = pdev->name;
 
 	rc = cam_flash_get_dt_data(flash_ctrl, &flash_ctrl->soc_info);
 	if (rc) {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/Makefile
new file mode 100644
index 0000000..ec1d2fd
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/Makefile
@@ -0,0 +1,9 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_cci
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
+
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois_dev.o cam_ois_core.o cam_ois_soc.o
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c
new file mode 100644
index 0000000..0a283ab
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c
@@ -0,0 +1,594 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/firmware.h>
+#include <cam_sensor_cmn_header.h>
+#include "cam_ois_core.h"
+#include "cam_ois_soc.h"
+#include "cam_sensor_util.h"
+#include "cam_debug_util.h"
+
+/**
+ * cam_ois_get_dev_handle - get device handle
+ * @o_ctrl:     ctrl structure
+ * @arg:        Camera control command argument
+ *
+ * Returns success or failure
+ */
+static int cam_ois_get_dev_handle(struct cam_ois_ctrl_t *o_ctrl,
+	void *arg)
+{
+	struct cam_sensor_acquire_dev    ois_acq_dev;
+	struct cam_create_dev_hdl        bridge_params;
+	struct cam_control              *cmd = (struct cam_control *)arg;
+
+	if (o_ctrl->bridge_intf.device_hdl != -1) {
+		CAM_ERR(CAM_OIS, "Device is already acquired");
+		return -EFAULT;
+	}
+	if (copy_from_user(&ois_acq_dev, (void __user *) cmd->handle,
+		sizeof(ois_acq_dev)))
+		return -EFAULT;
+
+	bridge_params.session_hdl = ois_acq_dev.session_handle;
+	bridge_params.ops = &o_ctrl->bridge_intf.ops;
+	bridge_params.v4l2_sub_dev_flag = 0;
+	bridge_params.media_entity_flag = 0;
+	bridge_params.priv = o_ctrl;
+
+	ois_acq_dev.device_handle =
+		cam_create_device_hdl(&bridge_params);
+	o_ctrl->bridge_intf.device_hdl = ois_acq_dev.device_handle;
+	o_ctrl->bridge_intf.session_hdl = ois_acq_dev.session_handle;
+
+	CAM_DBG(CAM_OIS, "Device Handle: %d", ois_acq_dev.device_handle);
+	if (copy_to_user((void __user *) cmd->handle, &ois_acq_dev,
+		sizeof(struct cam_sensor_acquire_dev))) {
+		CAM_ERR(CAM_OIS, "ACQUIRE_DEV: copy to user failed");
+		return -EFAULT;
+	}
+	return 0;
+}
+
+static int cam_ois_vreg_control(struct cam_ois_ctrl_t *o_ctrl,
+	int config)
+{
+	int rc = 0, cnt;
+	struct cam_hw_soc_info  *soc_info;
+
+	soc_info = &o_ctrl->soc_info;
+	cnt = soc_info->num_rgltr;
+
+	if (!cnt)
+		return 0;
+
+	if (cnt >= CAM_SOC_MAX_REGULATOR) {
+		CAM_ERR(CAM_OIS, "Regulators more than supported %d", cnt);
+		return -EINVAL;
+	}
+
+	if (config)
+		rc = cam_soc_util_enable_platform_resource(soc_info, false, 0,
+			false);
+	else
+		rc = cam_soc_util_disable_platform_resource(soc_info, false,
+			false);
+
+	return rc;
+}
+
+static int cam_ois_power_up(struct cam_ois_ctrl_t *o_ctrl)
+{
+	int rc = 0;
+	struct cam_hw_soc_info  *soc_info =
+		&o_ctrl->soc_info;
+	struct msm_camera_gpio_num_info *gpio_num_info = NULL;
+
+	rc = cam_ois_vreg_control(o_ctrl, 1);
+	if (rc < 0) {
+		CAM_ERR(CAM_OIS, "OIS Reg Failed %d", rc);
+		return rc;
+	}
+
+	gpio_num_info = o_ctrl->gpio_num_info;
+
+	if (soc_info->gpio_data &&
+		gpio_num_info &&
+		gpio_num_info->valid[SENSOR_VAF] == 1) {
+		rc = cam_soc_util_request_platform_resource(&o_ctrl->soc_info,
+			NULL, NULL);
+		rc = cam_soc_util_enable_platform_resource(&o_ctrl->soc_info,
+			false, 0, false);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "Failed in req gpio: %d", rc);
+			return rc;
+		}
+
+		gpio_set_value_cansleep(
+			gpio_num_info->gpio_num[SENSOR_VAF],
+			1);
+	}
+
+	/* VREG needs some delay to power up */
+	usleep_range(2000, 2050);
+
+	return rc;
+}
+
+static int cam_ois_power_down(struct cam_ois_ctrl_t *o_ctrl)
+{
+	int32_t rc = 0;
+	struct cam_hw_soc_info *soc_info =
+		&o_ctrl->soc_info;
+	struct msm_camera_gpio_num_info *gpio_num_info = NULL;
+
+	rc = cam_ois_vreg_control(o_ctrl, 0);
+	if (rc < 0) {
+		CAM_ERR(CAM_OIS, "Failed %d");
+		return rc;
+	}
+
+	gpio_num_info = o_ctrl->gpio_num_info;
+
+	if (soc_info->gpio_data &&
+		gpio_num_info &&
+		gpio_num_info->valid[SENSOR_VAF] == 1) {
+
+		gpio_set_value_cansleep(
+			gpio_num_info->gpio_num[SENSOR_VAF],
+			GPIOF_OUT_INIT_LOW);
+
+		rc = cam_soc_util_release_platform_resource(&o_ctrl->soc_info);
+		rc |= cam_soc_util_disable_platform_resource(&o_ctrl->soc_info,
+					0, 0);
+		if (rc < 0)
+			CAM_ERR(CAM_OIS,
+				"Failed to disable platform resources: %d", rc);
+	}
+
+	return rc;
+}
+
+static int cam_ois_apply_settings(struct cam_ois_ctrl_t *o_ctrl,
+	struct i2c_settings_array *i2c_set)
+{
+	struct i2c_settings_list *i2c_list;
+	int32_t rc = 0;
+	uint32_t i, size;
+
+	if (o_ctrl == NULL || i2c_set == NULL) {
+		CAM_ERR(CAM_OIS, "Invalid Args");
+		return -EINVAL;
+	}
+
+	if (i2c_set->is_settings_valid != 1) {
+		CAM_ERR(CAM_OIS, " Invalid settings");
+		return -EINVAL;
+	}
+
+	list_for_each_entry(i2c_list,
+		&(i2c_set->list_head), list) {
+		if (i2c_list->op_code ==  CAM_SENSOR_I2C_WRITE_RANDOM) {
+			rc = camera_io_dev_write(&(o_ctrl->io_master_info),
+				&(i2c_list->i2c_settings));
+			if (rc < 0) {
+				CAM_ERR(CAM_OIS,
+					"Failed in Applying i2c wrt settings");
+				return rc;
+			}
+		} else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
+			size = i2c_list->i2c_settings.size;
+			for (i = 0; i < size; i++) {
+				rc = camera_io_dev_poll(
+					&(o_ctrl->io_master_info),
+					i2c_list->i2c_settings.
+						reg_setting[i].reg_addr,
+					i2c_list->i2c_settings.
+						reg_setting[i].reg_data,
+					i2c_list->i2c_settings.
+						reg_setting[i].data_mask,
+					i2c_list->i2c_settings.addr_type,
+					i2c_list->i2c_settings.data_type,
+					i2c_list->i2c_settings.
+						reg_setting[i].delay);
+				if (rc < 0) {
+					CAM_ERR(CAM_OIS,
+						"i2c poll apply setting Fail");
+					return rc;
+				}
+			}
+		}
+	}
+
+	return rc;
+}
+
+static int cam_ois_slaveInfo_pkt_parser(struct cam_ois_ctrl_t *o_ctrl,
+	uint32_t *cmd_buf)
+{
+	int32_t rc = 0;
+	struct cam_cmd_ois_info *ois_info;
+
+	if (!o_ctrl || !cmd_buf) {
+		CAM_ERR(CAM_OIS, "Invalid Args");
+		return -EINVAL;
+	}
+
+	ois_info = (struct cam_cmd_ois_info *)cmd_buf;
+	if (o_ctrl->io_master_info.master_type == CCI_MASTER) {
+		o_ctrl->io_master_info.cci_client->i2c_freq_mode =
+			ois_info->i2c_freq_mode;
+		o_ctrl->io_master_info.cci_client->sid =
+			ois_info->slave_addr >> 1;
+		o_ctrl->ois_fw_flag = ois_info->ois_fw_flag;
+		o_ctrl->is_ois_calib = ois_info->is_ois_calib;
+		memcpy(o_ctrl->ois_name, ois_info->ois_name, 32);
+		o_ctrl->io_master_info.cci_client->retries = 3;
+		o_ctrl->io_master_info.cci_client->id_map = 0;
+		memcpy(&(o_ctrl->opcode), &(ois_info->opcode),
+			sizeof(struct cam_ois_opcode));
+		CAM_DBG(CAM_OIS, "Slave addr: 0x%x Freq Mode: %d",
+			ois_info->slave_addr, ois_info->i2c_freq_mode);
+	} else if (o_ctrl->io_master_info.master_type == I2C_MASTER) {
+		o_ctrl->io_master_info.client->addr = ois_info->slave_addr;
+		CAM_DBG(CAM_OIS, "Slave addr: 0x%x", ois_info->slave_addr);
+	} else {
+		CAM_ERR(CAM_OIS, "Invalid Master type : %d",
+			o_ctrl->io_master_info.master_type);
+		rc = -EINVAL;
+	}
+
+	return rc;
+}
+
+static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
+{
+	uint16_t                           total_bytes = 0;
+	uint8_t                           *ptr = NULL;
+	int32_t                            rc = 0, cnt;
+	const struct firmware             *fw = NULL;
+	const char                        *fw_name_prog = NULL;
+	const char                        *fw_name_coeff = NULL;
+	char                               name_prog[32] = {0};
+	char                               name_coeff[32] = {0};
+	struct device                     *dev = &(o_ctrl->pdev->dev);
+	struct cam_sensor_i2c_reg_setting  i2c_reg_setting;
+
+	if (!o_ctrl) {
+		CAM_ERR(CAM_OIS, "Invalid Args");
+		return -EINVAL;
+	}
+
+	snprintf(name_coeff, 32, "%s.coeff", o_ctrl->ois_name);
+
+	snprintf(name_prog, 32, "%s.prog", o_ctrl->ois_name);
+
+	/* cast pointer as const pointer*/
+	fw_name_prog = name_prog;
+	fw_name_coeff = name_coeff;
+
+	/* Load FW */
+	rc = request_firmware(&fw, fw_name_prog, dev);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "Failed to locate %s", fw_name_prog);
+		return rc;
+	}
+
+	total_bytes = fw->size;
+	i2c_reg_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
+	i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
+	i2c_reg_setting.size = total_bytes;
+	i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *)
+		kzalloc(sizeof(struct cam_sensor_i2c_reg_array) * total_bytes,
+		GFP_KERNEL);
+	if (!i2c_reg_setting.reg_setting) {
+		CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
+		release_firmware(fw);
+		return -ENOMEM;
+	}
+
+	for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
+		cnt++, ptr++) {
+		i2c_reg_setting.reg_setting[cnt].reg_addr =
+			o_ctrl->opcode.prog;
+		i2c_reg_setting.reg_setting[cnt].reg_data = *ptr;
+		i2c_reg_setting.reg_setting[cnt].delay = 0;
+		i2c_reg_setting.reg_setting[cnt].data_mask = 0;
+	}
+
+	rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info),
+		&i2c_reg_setting, 1);
+	if (rc < 0) {
+		CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
+		goto release_firmware;
+	}
+	kfree(i2c_reg_setting.reg_setting);
+	release_firmware(fw);
+
+	rc = request_firmware(&fw, fw_name_coeff, dev);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "Failed to locate %s", fw_name_coeff);
+		return rc;
+	}
+
+	total_bytes = fw->size;
+	i2c_reg_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
+	i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
+	i2c_reg_setting.size = total_bytes;
+	i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *)
+		kzalloc(sizeof(struct cam_sensor_i2c_reg_array) * total_bytes,
+		GFP_KERNEL);
+	if (!i2c_reg_setting.reg_setting) {
+		CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
+		release_firmware(fw);
+		return -ENOMEM;
+	}
+
+	for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
+		cnt++, ptr++) {
+		i2c_reg_setting.reg_setting[cnt].reg_addr =
+			o_ctrl->opcode.coeff;
+		i2c_reg_setting.reg_setting[cnt].reg_data = *ptr;
+		i2c_reg_setting.reg_setting[cnt].delay = 0;
+		i2c_reg_setting.reg_setting[cnt].data_mask = 0;
+	}
+
+	rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info),
+		&i2c_reg_setting, 1);
+	if (rc < 0)
+		CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
+
+release_firmware:
+	kfree(i2c_reg_setting.reg_setting);
+	release_firmware(fw);
+
+	return rc;
+}
+
+/**
+ * cam_ois_pkt_parse - Parse csl packet
+ * @o_ctrl:     ctrl structure
+ * @arg:        Camera control command argument
+ *
+ * Returns success or failure
+ */
+static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg)
+{
+	int32_t                         rc = 0;
+	uint64_t                        generic_ptr;
+	struct cam_control             *ioctl_ctrl = NULL;
+	struct cam_config_dev_cmd       dev_config;
+	struct i2c_settings_array      *i2c_reg_settings = NULL;
+	struct cam_cmd_buf_desc        *cmd_desc = NULL;
+	uint64_t                        generic_pkt_addr;
+	size_t                          pkt_len;
+	struct cam_packet              *csl_packet = NULL;
+	size_t                          len_of_buff = 0;
+	uint32_t                       *offset = NULL, *cmd_buf;
+
+	ioctl_ctrl = (struct cam_control *)arg;
+	if (copy_from_user(&dev_config, (void __user *) ioctl_ctrl->handle,
+		sizeof(dev_config)))
+		return -EFAULT;
+	rc = cam_mem_get_cpu_buf(dev_config.packet_handle,
+		(uint64_t *)&generic_pkt_addr, &pkt_len);
+	if (rc) {
+		CAM_ERR(CAM_OIS,
+			"error in converting command Handle Error: %d", rc);
+		return rc;
+	}
+
+	if (dev_config.offset > pkt_len) {
+		CAM_ERR(CAM_OIS,
+			"offset is out of bound: off: %lld len: %zu",
+			dev_config.offset, pkt_len);
+		return -EINVAL;
+	}
+
+	csl_packet = (struct cam_packet *)
+		(generic_pkt_addr + dev_config.offset);
+	switch (csl_packet->header.op_code & 0xFFFFFF) {
+	case CAM_OIS_PACKET_OPCODE_INIT:
+		offset = (uint32_t *)&csl_packet->payload;
+		offset += (csl_packet->cmd_buf_offset / sizeof(uint32_t));
+		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+
+		if ((csl_packet->num_cmd_buf < 2) &&
+			(csl_packet->num_cmd_buf > 3)) {
+			CAM_ERR(CAM_OIS, "wrong cmd Buffer count: %d",
+				csl_packet->num_cmd_buf);
+			return -EINVAL;
+		}
+
+		rc = cam_mem_get_cpu_buf(cmd_desc[0].mem_handle,
+			(uint64_t *)&generic_ptr, &len_of_buff);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "Failed to get cpu buf");
+			return rc;
+		}
+
+		cmd_buf = (uint32_t *)generic_ptr;
+		cmd_buf += cmd_desc->offset / sizeof(uint32_t);
+		rc = cam_ois_slaveInfo_pkt_parser(o_ctrl, cmd_buf);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "Failed in parsing the pkt");
+			return rc;
+		}
+
+		cmd_buf += (sizeof(struct cam_cmd_i2c_info)/sizeof(uint32_t));
+
+		i2c_reg_settings = &(o_ctrl->i2c_init_data);
+		i2c_reg_settings->is_settings_valid = 1;
+		i2c_reg_settings->request_id = 0;
+		rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
+			&cmd_desc[1], 1);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "OIS pkt parsing failed: %d",
+				rc);
+			return rc;
+		}
+
+		if (o_ctrl->is_ois_calib) {
+			i2c_reg_settings = &(o_ctrl->i2c_calib_data);
+			i2c_reg_settings->is_settings_valid = 1;
+			i2c_reg_settings->request_id = 0;
+			rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
+				&cmd_desc[2], 1);
+			if (rc < 0) {
+				CAM_ERR(CAM_OIS,
+					"OIS pkt parsing failed: %d", rc);
+				return rc;
+			}
+		}
+		break;
+	case CAM_OIS_PACKET_OPCODE_OIS_CONTROL:
+		offset = (uint32_t *)&csl_packet->payload;
+		offset += (csl_packet->cmd_buf_offset / sizeof(uint32_t));
+		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+		i2c_reg_settings = &(o_ctrl->i2c_mode_data);
+		i2c_reg_settings->is_settings_valid = 1;
+		i2c_reg_settings->request_id = 0;
+		rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
+			cmd_desc, 1);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "OIS pkt parsing failed: %d", rc);
+			return rc;
+		}
+
+		rc = cam_ois_apply_settings(o_ctrl, i2c_reg_settings);
+		if (rc < 0)
+			CAM_ERR(CAM_OIS, "Cannot apply mode settings");
+		break;
+	default:
+		break;
+	}
+	return rc;
+}
+
+/**
+ * cam_ois_driver_cmd - Handle ois cmds
+ * @e_ctrl:     ctrl structure
+ * @arg:        Camera control command argument
+ *
+ * Returns success or failure
+ */
+int cam_ois_driver_cmd(struct cam_ois_ctrl_t *o_ctrl, void *arg)
+{
+	int                            rc = 0;
+	struct cam_ois_query_cap_t     ois_cap = {0};
+	struct cam_control            *cmd = (struct cam_control *)arg;
+
+	if (!o_ctrl) {
+		CAM_ERR(CAM_OIS, "e_ctrl is NULL");
+		return -EINVAL;
+	}
+
+	mutex_lock(&(o_ctrl->ois_mutex));
+	switch (cmd->op_code) {
+	case CAM_QUERY_CAP:
+		ois_cap.slot_info = o_ctrl->soc_info.index;
+
+		if (copy_to_user((void __user *) cmd->handle,
+			&ois_cap,
+			sizeof(struct cam_ois_query_cap_t))) {
+			CAM_ERR(CAM_OIS, "Failed Copy to User");
+			return -EFAULT;
+			goto release_mutex;
+		}
+		CAM_DBG(CAM_OIS, "ois_cap: ID: %d", ois_cap.slot_info);
+		break;
+	case CAM_ACQUIRE_DEV:
+		rc = cam_ois_get_dev_handle(o_ctrl, arg);
+		if (rc) {
+			CAM_ERR(CAM_OIS, "Failed to acquire dev");
+			goto release_mutex;
+		}
+		break;
+	case CAM_START_DEV:
+		rc = cam_ois_power_up(o_ctrl);
+		if (rc) {
+			CAM_ERR(CAM_OIS, " OIS Power up failed");
+			goto release_mutex;
+		}
+		rc = camera_io_init(&o_ctrl->io_master_info);
+		if (rc) {
+			CAM_ERR(CAM_OIS, "cci_init failed");
+			goto pwr_dwn;
+		}
+
+		if (o_ctrl->ois_fw_flag) {
+			rc = cam_ois_fw_download(o_ctrl);
+			if (rc) {
+				CAM_ERR(CAM_OIS, "Failed OIS FW Download");
+				goto pwr_dwn;
+			}
+		}
+
+		rc = cam_ois_apply_settings(o_ctrl, &o_ctrl->i2c_init_data);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "Cannot apply Init settings");
+			goto pwr_dwn;
+		}
+
+		if (o_ctrl->is_ois_calib) {
+			rc = cam_ois_apply_settings(o_ctrl,
+				&o_ctrl->i2c_calib_data);
+			if (rc) {
+				CAM_ERR(CAM_OIS, "Cannot apply calib data");
+				goto pwr_dwn;
+			}
+		}
+		break;
+	case CAM_CONFIG_DEV:
+		rc = cam_ois_pkt_parse(o_ctrl, arg);
+		if (rc) {
+			CAM_ERR(CAM_OIS, "Failed in ois pkt Parsing");
+			goto release_mutex;
+		}
+		break;
+	case CAM_RELEASE_DEV:
+		if (o_ctrl->bridge_intf.device_hdl == -1) {
+			CAM_ERR(CAM_OIS, "link hdl: %d device hdl: %d",
+				o_ctrl->bridge_intf.device_hdl,
+				o_ctrl->bridge_intf.link_hdl);
+			rc = -EINVAL;
+			goto release_mutex;
+		}
+		rc = cam_destroy_device_hdl(o_ctrl->bridge_intf.device_hdl);
+		if (rc < 0)
+			CAM_ERR(CAM_OIS, "destroying the device hdl");
+		o_ctrl->bridge_intf.device_hdl = -1;
+		o_ctrl->bridge_intf.link_hdl = -1;
+		o_ctrl->bridge_intf.session_hdl = -1;
+		break;
+	case CAM_STOP_DEV:
+		rc = camera_io_release(&o_ctrl->io_master_info);
+		if (rc < 0)
+			CAM_ERR(CAM_OIS, "Failed in releasing CCI");
+		rc = cam_ois_power_down(o_ctrl);
+		if (rc < 0) {
+			CAM_ERR(CAM_OIS, "OIS Power down failed");
+			goto release_mutex;
+		}
+		break;
+	default:
+		CAM_ERR(CAM_OIS, "invalid opcode");
+		goto release_mutex;
+	}
+pwr_dwn:
+	cam_ois_power_down(o_ctrl);
+release_mutex:
+	mutex_unlock(&(o_ctrl->ois_mutex));
+
+	return rc;
+}
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.h
similarity index 63%
rename from include/linux/qdsp6v2/dsp_debug.h
rename to drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.h
index bc1cd9e..13da82a 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,13 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
+#ifndef _CAM_OIS_CORE_H_
+#define _CAM_OIS_CORE_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+#include "cam_ois_dev.h"
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
+int cam_ois_driver_cmd(struct cam_ois_ctrl_t *e_ctrl, void *arg);
 
 #endif
+/* _CAM_OIS_CORE_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.c
new file mode 100644
index 0000000..aeab388
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.c
@@ -0,0 +1,362 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include "cam_ois_dev.h"
+#include "cam_req_mgr_dev.h"
+#include "cam_ois_soc.h"
+#include "cam_ois_core.h"
+#include "cam_debug_util.h"
+
+static long cam_ois_subdev_ioctl(struct v4l2_subdev *sd,
+	unsigned int cmd, void *arg)
+{
+	int                       rc     = 0;
+	struct cam_ois_ctrl_t *o_ctrl = v4l2_get_subdevdata(sd);
+
+	switch (cmd) {
+	case VIDIOC_CAM_CONTROL:
+		rc = cam_ois_driver_cmd(o_ctrl, arg);
+		break;
+	default:
+		rc = -ENOIOCTLCMD;
+		break;
+	}
+
+	return rc;
+}
+
+static int32_t cam_ois_update_i2c_info(struct cam_ois_ctrl_t *o_ctrl,
+	struct cam_ois_i2c_info_t *i2c_info)
+{
+	struct cam_sensor_cci_client        *cci_client = NULL;
+
+	if (o_ctrl->io_master_info.master_type == CCI_MASTER) {
+		cci_client = o_ctrl->io_master_info.cci_client;
+		if (!cci_client) {
+			CAM_ERR(CAM_OIS, "failed: cci_client %pK",
+				cci_client);
+			return -EINVAL;
+		}
+		cci_client->cci_i2c_master = o_ctrl->cci_i2c_master;
+		cci_client->sid = (i2c_info->slave_addr) >> 1;
+		cci_client->retries = 3;
+		cci_client->id_map = 0;
+		cci_client->i2c_freq_mode = i2c_info->i2c_freq_mode;
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_COMPAT
+static long cam_ois_init_subdev_do_ioctl(struct v4l2_subdev *sd,
+	unsigned int cmd, unsigned long arg)
+{
+	struct cam_control cmd_data;
+	int32_t rc = 0;
+
+	if (copy_from_user(&cmd_data, (void __user *)arg,
+		sizeof(cmd_data))) {
+		CAM_ERR(CAM_OIS,
+			"Failed to copy from user_ptr=%pK size=%zu",
+			(void __user *)arg, sizeof(cmd_data));
+		return -EFAULT;
+	}
+
+	switch (cmd) {
+	case VIDIOC_CAM_CONTROL:
+		rc = cam_ois_subdev_ioctl(sd, cmd, &cmd_data);
+		if (rc) {
+			CAM_ERR(CAM_OIS,
+				"Failed in ois suddev handling rc %d",
+				rc);
+			return rc;
+		}
+		break;
+	default:
+		CAM_ERR(CAM_OIS, "Invalid compat ioctl: %d", cmd);
+		rc = -EINVAL;
+	}
+
+	if (!rc) {
+		if (copy_to_user((void __user *)arg, &cmd_data,
+			sizeof(cmd_data))) {
+			CAM_ERR(CAM_OIS,
+				"Failed to copy from user_ptr=%pK size=%zu",
+				(void __user *)arg, sizeof(cmd_data));
+			rc = -EFAULT;
+		}
+	}
+	return rc;
+}
+#endif
+
+static const struct v4l2_subdev_internal_ops cam_ois_internal_ops;
+
+static struct v4l2_subdev_core_ops cam_ois_subdev_core_ops = {
+	.ioctl = cam_ois_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl32 = cam_ois_init_subdev_do_ioctl,
+#endif
+};
+
+static struct v4l2_subdev_ops cam_ois_subdev_ops = {
+	.core = &cam_ois_subdev_core_ops,
+};
+
+static int cam_ois_init_subdev_param(struct cam_ois_ctrl_t *o_ctrl)
+{
+	int rc = 0;
+
+	o_ctrl->v4l2_dev_str.internal_ops = &cam_ois_internal_ops;
+	o_ctrl->v4l2_dev_str.ops = &cam_ois_subdev_ops;
+	strlcpy(o_ctrl->device_name, CAM_OIS_NAME,
+		sizeof(o_ctrl->device_name));
+	o_ctrl->v4l2_dev_str.name = o_ctrl->device_name;
+	o_ctrl->v4l2_dev_str.sd_flags =
+		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
+	o_ctrl->v4l2_dev_str.ent_function = CAM_OIS_DEVICE_TYPE;
+	o_ctrl->v4l2_dev_str.token = o_ctrl;
+
+	rc = cam_register_subdev(&(o_ctrl->v4l2_dev_str));
+	if (rc)
+		CAM_ERR(CAM_OIS, "fail to create subdev");
+
+	return rc;
+}
+
+static int cam_ois_i2c_driver_probe(struct i2c_client *client,
+	 const struct i2c_device_id *id)
+{
+	int                          rc = 0;
+	struct cam_ois_ctrl_t       *o_ctrl = NULL;
+	struct cam_ois_soc_private  *soc_private = NULL;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_OIS, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_OIS, "i2c_check_functionality failed");
+		goto probe_failure;
+	}
+
+	o_ctrl = kzalloc(sizeof(*o_ctrl), GFP_KERNEL);
+	if (!o_ctrl) {
+		CAM_ERR(CAM_OIS, "kzalloc failed");
+		rc = -ENOMEM;
+		goto probe_failure;
+	}
+
+	i2c_set_clientdata(client, o_ctrl);
+
+	o_ctrl->soc_info.dev = &client->dev;
+	o_ctrl->soc_info.dev_name = client->name;
+	o_ctrl->ois_device_type = MSM_CAMERA_I2C_DEVICE;
+	o_ctrl->io_master_info.master_type = I2C_MASTER;
+	o_ctrl->io_master_info.client = client;
+
+	soc_private = kzalloc(sizeof(struct cam_ois_soc_private),
+		GFP_KERNEL);
+	if (!soc_private) {
+		rc = -ENOMEM;
+		goto octrl_free;
+	}
+
+	o_ctrl->soc_info.soc_private = soc_private;
+	rc = cam_ois_driver_soc_init(o_ctrl);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "failed: cam_sensor_parse_dt rc %d", rc);
+		goto octrl_free;
+	}
+
+	rc = cam_ois_init_subdev_param(o_ctrl);
+	if (rc)
+		goto octrl_free;
+
+	return rc;
+
+octrl_free:
+	kfree(o_ctrl);
+probe_failure:
+	return rc;
+}
+
+static int cam_ois_i2c_driver_remove(struct i2c_client *client)
+{
+	struct cam_ois_ctrl_t       *o_ctrl = i2c_get_clientdata(client);
+
+	if (!o_ctrl) {
+		CAM_ERR(CAM_OIS, "ois device is NULL");
+		return -EINVAL;
+	}
+
+	kfree(o_ctrl->soc_info.soc_private);
+	kfree(o_ctrl);
+
+	return 0;
+}
+
+static int32_t cam_ois_platform_driver_probe(
+	struct platform_device *pdev)
+{
+	int32_t                         rc = 0;
+	struct cam_ois_ctrl_t          *o_ctrl = NULL;
+	struct cam_ois_soc_private     *soc_private = NULL;
+
+	o_ctrl = kzalloc(sizeof(struct cam_ois_ctrl_t), GFP_KERNEL);
+	if (!o_ctrl)
+		return -ENOMEM;
+
+	o_ctrl->soc_info.pdev = pdev;
+	o_ctrl->soc_info.dev = &pdev->dev;
+	o_ctrl->soc_info.dev_name = pdev->name;
+
+	o_ctrl->ois_device_type = MSM_CAMERA_PLATFORM_DEVICE;
+
+	o_ctrl->io_master_info.master_type = CCI_MASTER;
+	o_ctrl->io_master_info.cci_client = kzalloc(
+		sizeof(struct cam_sensor_cci_client), GFP_KERNEL);
+	if (!o_ctrl->io_master_info.cci_client)
+		goto free_o_ctrl;
+
+	soc_private = kzalloc(sizeof(struct cam_ois_soc_private),
+		GFP_KERNEL);
+	if (!soc_private) {
+		rc = -ENOMEM;
+		goto free_cci_client;
+	}
+	o_ctrl->soc_info.soc_private = soc_private;
+
+	INIT_LIST_HEAD(&(o_ctrl->i2c_init_data.list_head));
+	INIT_LIST_HEAD(&(o_ctrl->i2c_calib_data.list_head));
+	INIT_LIST_HEAD(&(o_ctrl->i2c_mode_data.list_head));
+	mutex_init(&(o_ctrl->ois_mutex));
+	rc = cam_ois_driver_soc_init(o_ctrl);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "failed: soc init rc %d", rc);
+		goto free_soc;
+	}
+
+	rc = cam_ois_init_subdev_param(o_ctrl);
+	if (rc)
+		goto free_soc;
+
+	rc = cam_ois_update_i2c_info(o_ctrl, &soc_private->i2c_info);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "failed: to update i2c info rc %d", rc);
+		goto unreg_subdev;
+	}
+	o_ctrl->bridge_intf.device_hdl = -1;
+
+	platform_set_drvdata(pdev, o_ctrl);
+	v4l2_set_subdevdata(&o_ctrl->v4l2_dev_str.sd, o_ctrl);
+
+	return rc;
+unreg_subdev:
+	cam_unregister_subdev(&(o_ctrl->v4l2_dev_str));
+free_soc:
+	kfree(soc_private);
+free_cci_client:
+	kfree(o_ctrl->io_master_info.cci_client);
+free_o_ctrl:
+	kfree(o_ctrl);
+	return rc;
+}
+
+static int cam_ois_platform_driver_remove(struct platform_device *pdev)
+{
+	struct cam_ois_ctrl_t  *o_ctrl;
+
+	o_ctrl = platform_get_drvdata(pdev);
+	if (!o_ctrl) {
+		CAM_ERR(CAM_OIS, "ois device is NULL");
+		return -EINVAL;
+	}
+
+	kfree(o_ctrl->soc_info.soc_private);
+	kfree(o_ctrl->io_master_info.cci_client);
+	kfree(o_ctrl);
+	return 0;
+}
+
+static const struct of_device_id cam_ois_dt_match[] = {
+	{ .compatible = "qcom,ois" },
+	{ }
+};
+
+
+MODULE_DEVICE_TABLE(of, cam_ois_dt_match);
+
+static struct platform_driver cam_ois_platform_driver = {
+	.driver = {
+		.name = "qcom,ois",
+		.owner = THIS_MODULE,
+		.of_match_table = cam_ois_dt_match,
+	},
+	.probe = cam_ois_platform_driver_probe,
+	.remove = cam_ois_platform_driver_remove,
+};
+static const struct i2c_device_id cam_ois_i2c_id[] = {
+	{ "msm_ois", (kernel_ulong_t)NULL},
+	{ }
+};
+
+static struct i2c_driver cam_ois_i2c_driver = {
+	.id_table = cam_ois_i2c_id,
+	.probe  = cam_ois_i2c_driver_probe,
+	.remove = cam_ois_i2c_driver_remove,
+	.driver = {
+		.name = "msm_ois",
+	},
+};
+
+static struct cam_ois_registered_driver_t registered_driver = {
+	0, 0};
+
+static int __init cam_ois_driver_init(void)
+{
+	int rc = 0;
+
+	rc = platform_driver_register(&cam_ois_platform_driver);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "platform_driver_register failed rc = %d",
+			rc);
+		return rc;
+	}
+
+	registered_driver.platform_driver = 1;
+
+	rc = i2c_add_driver(&cam_ois_i2c_driver);
+	if (rc) {
+		CAM_ERR(CAM_OIS, "i2c_add_driver failed rc = %d", rc);
+		return rc;
+	}
+
+	registered_driver.i2c_driver = 1;
+	return rc;
+}
+
+static void __exit cam_ois_driver_exit(void)
+{
+	if (registered_driver.platform_driver)
+		platform_driver_unregister(&cam_ois_platform_driver);
+
+	if (registered_driver.i2c_driver)
+		i2c_del_driver(&cam_ois_i2c_driver);
+}
+
+module_init(cam_ois_driver_init);
+module_exit(cam_ois_driver_exit);
+MODULE_DESCRIPTION("CAM OIS driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.h
new file mode 100644
index 0000000..794b65a
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_dev.h
@@ -0,0 +1,125 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _CAM_OIS_DEV_H_
+#define _CAM_OIS_DEV_H_
+
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <media/v4l2-event.h>
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-ioctl.h>
+#include <media/cam_sensor.h>
+#include <cam_sensor_i2c.h>
+#include <cam_sensor_spi.h>
+#include <cam_sensor_io.h>
+#include <cam_cci_dev.h>
+#include <cam_req_mgr_util.h>
+#include <cam_req_mgr_interface.h>
+#include <cam_mem_mgr.h>
+#include <cam_subdev.h>
+#include "cam_soc_util.h"
+
+#define DEFINE_MSM_MUTEX(mutexname) \
+	static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
+
+/**
+ * struct cam_ois_registered_driver_t - registered driver info
+ * @platform_driver      :   flag indicates if platform driver is registered
+ * @i2c_driver           :   flag indicates if i2c driver is registered
+ *
+ */
+struct cam_ois_registered_driver_t {
+	bool platform_driver;
+	bool i2c_driver;
+};
+
+/**
+ * struct cam_ois_i2c_info_t - I2C info
+ * @slave_addr      :   slave address
+ * @i2c_freq_mode   :   i2c frequency mode
+ *
+ */
+struct cam_ois_i2c_info_t {
+	uint16_t slave_addr;
+	uint8_t i2c_freq_mode;
+};
+
+/**
+ * struct cam_ois_soc_private - ois soc private data structure
+ * @ois_name        :   ois name
+ * @i2c_info        :   i2c info structure
+ * @power_info      :   ois power info
+ *
+ */
+struct cam_ois_soc_private {
+	const char *ois_name;
+	struct cam_ois_i2c_info_t i2c_info;
+	struct cam_sensor_power_ctrl_t power_info;
+};
+
+/**
+ * struct cam_ois_intf_params - bridge interface params
+ * @device_hdl   : Device Handle
+ * @session_hdl  : Session Handle
+ * @ops          : KMD operations
+ * @crm_cb       : Callback API pointers
+ */
+struct cam_ois_intf_params {
+	int32_t device_hdl;
+	int32_t session_hdl;
+	int32_t link_hdl;
+	struct cam_req_mgr_kmd_ops ops;
+	struct cam_req_mgr_crm_cb *crm_cb;
+};
+
+/**
+ * struct cam_ois_ctrl_t - OIS ctrl private data
+ * @pdev            :   platform device
+ * @ois_mutex       :   ois mutex
+ * @soc_info        :   ois soc related info
+ * @io_master_info  :   Information about the communication master
+ * @gpio_num_info   :   gpio info
+ * @cci_i2c_master  :   I2C structure
+ * @v4l2_dev_str    :   V4L2 device structure
+ * @bridge_intf     :   bridge interface params
+ * @i2c_init_data   :   ois i2c init settings
+ * @i2c_mode_data   :   ois i2c mode settings
+ * @i2c_calib_data  :   ois i2c calib settings
+ * @ois_device_type :   ois device type
+ * @ois_name        :   ois name
+ * @ois_fw_flag     :   flag for firmware download
+ * @is_ois_calib    :   flag for Calibration data
+ * @opcode          :   ois opcode
+ * @device_name     :   Device name
+ *
+ */
+struct cam_ois_ctrl_t {
+	struct platform_device *pdev;
+	struct mutex ois_mutex;
+	struct cam_hw_soc_info soc_info;
+	struct camera_io_master io_master_info;
+	struct msm_camera_gpio_num_info *gpio_num_info;
+	enum cci_i2c_master_t cci_i2c_master;
+	struct cam_subdev v4l2_dev_str;
+	struct cam_ois_intf_params bridge_intf;
+	struct i2c_settings_array i2c_init_data;
+	struct i2c_settings_array i2c_calib_data;
+	struct i2c_settings_array i2c_mode_data;
+	enum msm_camera_device_type_t ois_device_type;
+	char device_name[20];
+	char ois_name[32];
+	uint8_t ois_fw_flag;
+	uint8_t is_ois_calib;
+	struct cam_ois_opcode opcode;
+};
+
+#endif /*_CAM_OIS_DEV_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.c
new file mode 100644
index 0000000..5886413
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.c
@@ -0,0 +1,107 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <cam_sensor_cmn_header.h>
+#include <cam_sensor_util.h>
+#include <cam_sensor_io.h>
+#include <cam_req_mgr_util.h>
+
+#include "cam_ois_soc.h"
+#include "cam_debug_util.h"
+
+/**
+ * @e_ctrl: ctrl structure
+ *
+ * Parses ois dt
+ */
+static int cam_ois_get_dt_data(struct cam_ois_ctrl_t *o_ctrl)
+{
+	int                             rc = 0;
+	struct cam_hw_soc_info         *soc_info = &o_ctrl->soc_info;
+	struct cam_ois_soc_private     *soc_private =
+		(struct cam_ois_soc_private *)o_ctrl->soc_info.soc_private;
+	struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info;
+	struct device_node             *of_node = NULL;
+
+	of_node = soc_info->dev->of_node;
+
+	if (!of_node) {
+		CAM_ERR(CAM_OIS, "of_node is NULL, device type %d",
+			o_ctrl->ois_device_type);
+		return -EINVAL;
+	}
+	rc = cam_soc_util_get_dt_properties(soc_info);
+	if (rc < 0) {
+		CAM_ERR(CAM_OIS, "cam_soc_util_get_dt_properties rc %d",
+			rc);
+		return rc;
+	}
+
+	if (!soc_info->gpio_data) {
+		CAM_INFO(CAM_OIS, "No GPIO found");
+		return 0;
+	}
+
+	if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
+		CAM_INFO(CAM_OIS, "No GPIO found");
+		return -EINVAL;
+	}
+
+	rc = cam_sensor_util_init_gpio_pin_tbl(soc_info,
+		&power_info->gpio_num_info);
+	if ((rc < 0) || (!power_info->gpio_num_info)) {
+		CAM_ERR(CAM_OIS, "No/Error OIS GPIOs");
+		return -EINVAL;
+	}
+
+	return rc;
+}
+/**
+ * @o_ctrl: ctrl structure
+ *
+ * This function is called from cam_ois_platform/i2c_driver_probe, it parses
+ * the ois dt node.
+ */
+int cam_ois_driver_soc_init(struct cam_ois_ctrl_t *o_ctrl)
+{
+	int                             rc = 0;
+	struct cam_hw_soc_info         *soc_info = &o_ctrl->soc_info;
+	struct device_node             *of_node = NULL;
+
+	if (!soc_info->dev) {
+		CAM_ERR(CAM_OIS, "soc_info is not initialized");
+		return -EINVAL;
+	}
+
+	of_node = soc_info->dev->of_node;
+	if (!of_node) {
+		CAM_ERR(CAM_OIS, "dev.of_node NULL");
+		return -EINVAL;
+	}
+
+	if (o_ctrl->ois_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
+		rc = of_property_read_u32(of_node, "cci-master",
+			&o_ctrl->cci_i2c_master);
+		if (rc < 0) {
+			CAM_DBG(CAM_OIS, "failed rc %d", rc);
+			return rc;
+		}
+	}
+
+	rc = cam_ois_get_dt_data(o_ctrl);
+	if (rc < 0)
+		CAM_DBG(CAM_OIS, "failed: ois get dt data rc %d", rc);
+
+	return rc;
+}
diff --git a/include/linux/qdsp6v2/dsp_debug.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.h
similarity index 62%
copy from include/linux/qdsp6v2/dsp_debug.h
copy to drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.h
index bc1cd9e..af04134 100644
--- a/include/linux/qdsp6v2/dsp_debug.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_soc.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -8,15 +8,12 @@
  * 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 __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
+#ifndef _CAM_OIS_SOC_H_
+#define _CAM_OIS_SOC_H_
 
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
+#include "cam_ois_dev.h"
 
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
+int cam_ois_driver_soc_init(struct cam_ois_ctrl_t *o_ctrl);
 
-#endif
+#endif/* _CAM_OIS_SOC_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
index f6e6a9a..cd96129 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
@@ -118,6 +118,7 @@
 		CAM_DBG(CAM_SENSOR, " Rxed Req Id: %lld",
 			 csl_packet->header.request_id);
 		add_req.dev_hdl = s_ctrl->bridge_intf.device_hdl;
+		add_req.skip_before_applying = 0;
 		if (s_ctrl->bridge_intf.crm_cb &&
 			s_ctrl->bridge_intf.crm_cb->add_req)
 			s_ctrl->bridge_intf.crm_cb->add_req(&add_req);
@@ -127,6 +128,70 @@
 	return rc;
 }
 
+static int32_t cam_sensor_i2c_modes_util(
+	struct camera_io_master *io_master_info,
+	struct i2c_settings_list *i2c_list)
+{
+	int32_t rc = 0;
+	uint32_t i, size;
+
+	if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) {
+		rc = camera_io_dev_write(io_master_info,
+			&(i2c_list->i2c_settings));
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to random write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_SEQ) {
+		rc = camera_io_dev_write_continuous(
+			io_master_info,
+			&(i2c_list->i2c_settings),
+			0);
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to seq write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_BURST) {
+		rc = camera_io_dev_write_continuous(
+			io_master_info,
+			&(i2c_list->i2c_settings),
+			1);
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to burst write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	} else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
+		size = i2c_list->i2c_settings.size;
+		for (i = 0; i < size; i++) {
+			rc = camera_io_dev_poll(
+			io_master_info,
+			i2c_list->i2c_settings.
+				reg_setting[i].reg_addr,
+			i2c_list->i2c_settings.
+				reg_setting[i].reg_data,
+			i2c_list->i2c_settings.
+				reg_setting[i].data_mask,
+			i2c_list->i2c_settings.addr_type,
+				i2c_list->i2c_settings.data_type,
+			i2c_list->i2c_settings.
+				reg_setting[i].delay);
+			if (rc < 0) {
+				CAM_ERR(CAM_SENSOR,
+					"i2c poll apply setting Fail: %d", rc);
+				return rc;
+			}
+		}
+	}
+
+	return rc;
+}
+
 int32_t cam_sensor_update_i2c_info(struct cam_cmd_i2c_info *i2c_info,
 	struct cam_sensor_ctrl_t *s_ctrl)
 {
@@ -588,6 +653,7 @@
 	info->dev_id = CAM_REQ_MGR_DEVICE_SENSOR;
 	strlcpy(info->name, CAM_SENSOR_NAME, sizeof(info->name));
 	info->p_delay = 2;
+	info->trigger = CAM_TRIGGER_POINT_SOF;
 
 	return rc;
 }
@@ -714,12 +780,13 @@
 		if (i2c_set->is_settings_valid == 1) {
 			list_for_each_entry(i2c_list,
 				&(i2c_set->list_head), list) {
-				rc = camera_io_dev_write(
+				rc = cam_sensor_i2c_modes_util(
 					&(s_ctrl->io_master_info),
-					&(i2c_list->i2c_settings));
+					i2c_list);
 				if (rc < 0) {
 					CAM_ERR(CAM_SENSOR,
-					"Failed to write the I2C settings");
+						"Failed to apply settings: %d",
+						rc);
 					return rc;
 				}
 			}
@@ -737,39 +804,37 @@
 			i2c_set->request_id == req_id) {
 			list_for_each_entry(i2c_list,
 				&(i2c_set->list_head), list) {
-				rc = camera_io_dev_write(
+				rc = cam_sensor_i2c_modes_util(
 					&(s_ctrl->io_master_info),
-					&(i2c_list->i2c_settings));
+					i2c_list);
 				if (rc < 0) {
 					CAM_ERR(CAM_SENSOR,
-					"Fail to write the I2C settings: %d",
-						 rc);
+						"Failed to apply settings: %d",
+						rc);
 					return rc;
 				}
 			}
-			del_req_id = (req_id +
-				MAX_PER_FRAME_ARRAY -
-				MAX_SYSTEM_PIPELINE_DELAY) %
-				MAX_PER_FRAME_ARRAY;
-			CAM_DBG(CAM_SENSOR, "Deleting the Request: %d",
-				del_req_id);
-			if (req_id >
-				s_ctrl->i2c_data.per_frame[del_req_id].
-				request_id) {
-				s_ctrl->i2c_data.per_frame[del_req_id].
-					request_id = 0;
-				rc = delete_request(
-					&(s_ctrl->i2c_data.
-					per_frame[del_req_id]));
-				if (rc < 0)
-					CAM_ERR(CAM_SENSOR,
-						"Delete request Fail:%d rc:%d",
-						del_req_id, rc);
-			}
 		} else {
 			CAM_DBG(CAM_SENSOR,
 				"Invalid/NOP request to apply: %lld", req_id);
 		}
+
+		del_req_id = (req_id + MAX_PER_FRAME_ARRAY -
+			MAX_SYSTEM_PIPELINE_DELAY) % MAX_PER_FRAME_ARRAY;
+		CAM_DBG(CAM_SENSOR, "Deleting the Request: %d", del_req_id);
+
+		if ((req_id >
+			 s_ctrl->i2c_data.per_frame[del_req_id].request_id) &&
+			(s_ctrl->i2c_data.per_frame[del_req_id].
+				is_settings_valid == 1)) {
+			s_ctrl->i2c_data.per_frame[del_req_id].request_id = 0;
+			rc = delete_request(
+				&(s_ctrl->i2c_data.per_frame[del_req_id]));
+			if (rc < 0)
+				CAM_ERR(CAM_SENSOR,
+					"Delete request Fail:%d rc:%d",
+					del_req_id, rc);
+		}
 	}
 	return rc;
 }
@@ -789,7 +854,7 @@
 		return -EINVAL;
 	}
 	CAM_DBG(CAM_SENSOR, " Req Id: %lld", apply->request_id);
-	trace_cam_apply_req("Sensor", apply);
+	trace_cam_apply_req("Sensor", apply->request_id);
 	rc = cam_sensor_apply_settings(s_ctrl, apply->request_id);
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
index 40cf689..122aa3e 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
@@ -34,11 +34,91 @@
 	return rc;
 }
 
+#ifdef CONFIG_COMPAT
+static long cam_sensor_init_subdev_do_ioctl(struct v4l2_subdev *sd,
+	unsigned int cmd, unsigned long arg)
+{
+	struct cam_control cmd_data;
+	int32_t rc = 0;
+
+	if (copy_from_user(&cmd_data, (void __user *)arg,
+		sizeof(cmd_data))) {
+		CAM_ERR(CAM_SENSOR, "Failed to copy from user_ptr=%pK size=%zu",
+			(void __user *)arg, sizeof(cmd_data));
+		return -EFAULT;
+	}
+
+	switch (cmd) {
+	case VIDIOC_CAM_CONTROL:
+		rc = cam_sensor_subdev_ioctl(sd, cmd, &cmd_data);
+		if (rc < 0)
+			CAM_ERR(CAM_SENSOR, "cam_sensor_subdev_ioctl failed");
+			break;
+	default:
+		CAM_ERR(CAM_SENSOR, "Invalid compat ioctl cmd_type: %d", cmd);
+		rc = -EINVAL;
+	}
+
+	if (!rc) {
+		if (copy_to_user((void __user *)arg, &cmd_data,
+			sizeof(cmd_data))) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to copy to user_ptr=%pK size=%zu",
+				(void __user *)arg, sizeof(cmd_data));
+			rc = -EFAULT;
+		}
+	}
+
+	return rc;
+}
+
+#endif
+static struct v4l2_subdev_core_ops cam_sensor_subdev_core_ops = {
+	.ioctl = cam_sensor_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl32 = cam_sensor_init_subdev_do_ioctl,
+#endif
+	.s_power = cam_sensor_power,
+};
+
+static struct v4l2_subdev_ops cam_sensor_subdev_ops = {
+	.core = &cam_sensor_subdev_core_ops,
+};
+
+static const struct v4l2_subdev_internal_ops cam_sensor_internal_ops;
+
+static int cam_sensor_init_subdev_params(struct cam_sensor_ctrl_t *s_ctrl)
+{
+	int rc = 0;
+
+	s_ctrl->v4l2_dev_str.internal_ops =
+		&cam_sensor_internal_ops;
+	s_ctrl->v4l2_dev_str.ops =
+		&cam_sensor_subdev_ops;
+	strlcpy(s_ctrl->device_name, CAMX_SENSOR_DEV_NAME,
+		sizeof(s_ctrl->device_name));
+	s_ctrl->v4l2_dev_str.name =
+		s_ctrl->device_name;
+	s_ctrl->v4l2_dev_str.sd_flags =
+		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
+	s_ctrl->v4l2_dev_str.ent_function =
+		CAM_SENSOR_DEVICE_TYPE;
+	s_ctrl->v4l2_dev_str.token = s_ctrl;
+
+	rc = cam_register_subdev(&(s_ctrl->v4l2_dev_str));
+	if (rc)
+		CAM_ERR(CAM_SENSOR, "Fail with cam_register_subdev rc: %d", rc);
+
+	return rc;
+}
+
 static int32_t cam_sensor_driver_i2c_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
 {
 	int32_t rc = 0;
-	struct cam_sensor_ctrl_t *s_ctrl;
+	int i = 0;
+	struct cam_sensor_ctrl_t *s_ctrl = NULL;
+	struct cam_hw_soc_info   *soc_info = NULL;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		CAM_ERR(CAM_SENSOR,
@@ -53,9 +133,15 @@
 
 	i2c_set_clientdata(client, s_ctrl);
 
+	s_ctrl->io_master_info.client = client;
+	soc_info = &s_ctrl->soc_info;
+	soc_info->dev = &client->dev;
+	soc_info->dev_name = client->name;
+
 	/* Initialize sensor device type */
 	s_ctrl->of_node = client->dev.of_node;
 	s_ctrl->io_master_info.master_type = I2C_MASTER;
+	s_ctrl->is_probe_succeed = 0;
 
 	rc = cam_sensor_parse_dt(s_ctrl);
 	if (rc < 0) {
@@ -63,7 +149,35 @@
 		goto free_s_ctrl;
 	}
 
+	rc = cam_sensor_init_subdev_params(s_ctrl);
+	if (rc)
+		goto free_s_ctrl;
+
+	s_ctrl->i2c_data.per_frame =
+		(struct i2c_settings_array *)
+		kzalloc(sizeof(struct i2c_settings_array) *
+		MAX_PER_FRAME_ARRAY, GFP_KERNEL);
+	if (s_ctrl->i2c_data.per_frame == NULL) {
+		rc = -ENOMEM;
+		goto unreg_subdev;
+	}
+
+	INIT_LIST_HEAD(&(s_ctrl->i2c_data.init_settings.list_head));
+
+	for (i = 0; i < MAX_PER_FRAME_ARRAY; i++)
+		INIT_LIST_HEAD(&(s_ctrl->i2c_data.per_frame[i].list_head));
+
+	s_ctrl->bridge_intf.device_hdl = -1;
+	s_ctrl->bridge_intf.ops.get_dev_info = cam_sensor_publish_dev_info;
+	s_ctrl->bridge_intf.ops.link_setup = cam_sensor_establish_link;
+	s_ctrl->bridge_intf.ops.apply_req = cam_sensor_apply_request;
+	s_ctrl->bridge_intf.ops.flush_req = cam_sensor_flush_request;
+
+	s_ctrl->sensordata->power_info.dev = soc_info->dev;
+	v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), s_ctrl);
 	return rc;
+unreg_subdev:
+	cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
 free_s_ctrl:
 	kfree(s_ctrl);
 	return rc;
@@ -100,59 +214,6 @@
 	return 0;
 }
 
-#ifdef CONFIG_COMPAT
-static long cam_sensor_init_subdev_do_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, unsigned long arg)
-{
-	struct cam_control cmd_data;
-	int32_t rc = 0;
-
-	if (copy_from_user(&cmd_data, (void __user *)arg,
-		sizeof(cmd_data))) {
-		CAM_ERR(CAM_SENSOR, "Failed to copy from user_ptr=%pK size=%zu",
-			(void __user *)arg, sizeof(cmd_data));
-		return -EFAULT;
-	}
-
-	switch (cmd) {
-	case VIDIOC_CAM_CONTROL:
-		rc = cam_sensor_subdev_ioctl(sd, cmd, &cmd_data);
-		if (rc < 0)
-			CAM_ERR(CAM_SENSOR, "cam_sensor_subdev_ioctl failed");
-		break;
-	default:
-		CAM_ERR(CAM_SENSOR, "Invalid compat ioctl cmd_type: %d", cmd);
-		rc = -EINVAL;
-	}
-
-	if (!rc) {
-		if (copy_to_user((void __user *)arg, &cmd_data,
-			sizeof(cmd_data))) {
-			CAM_ERR(CAM_SENSOR,
-				"Failed to copy to user_ptr=%pK size=%zu",
-				(void __user *)arg, sizeof(cmd_data));
-			rc = -EFAULT;
-		}
-	}
-	return rc;
-}
-
-#endif
-
-static struct v4l2_subdev_core_ops cam_sensor_subdev_core_ops = {
-	.ioctl = cam_sensor_subdev_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl32 = cam_sensor_init_subdev_do_ioctl,
-#endif
-	.s_power = cam_sensor_power,
-};
-
-static struct v4l2_subdev_ops cam_sensor_subdev_ops = {
-	.core = &cam_sensor_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops cam_sensor_internal_ops;
-
 static const struct of_device_id cam_sensor_driver_dt_match[] = {
 	{.compatible = "qcom,cam-sensor"},
 	{}
@@ -173,6 +234,8 @@
 
 	soc_info = &s_ctrl->soc_info;
 	soc_info->pdev = pdev;
+	soc_info->dev = &pdev->dev;
+	soc_info->dev_name = pdev->name;
 
 	/* Initialize sensor device type */
 	s_ctrl->of_node = pdev->dev.of_node;
@@ -192,25 +255,9 @@
 	/* Fill platform device id*/
 	pdev->id = soc_info->index;
 
-	s_ctrl->v4l2_dev_str.internal_ops =
-		&cam_sensor_internal_ops;
-	s_ctrl->v4l2_dev_str.ops =
-		&cam_sensor_subdev_ops;
-	strlcpy(s_ctrl->device_name, CAMX_SENSOR_DEV_NAME,
-		sizeof(s_ctrl->device_name));
-	s_ctrl->v4l2_dev_str.name =
-		s_ctrl->device_name;
-	s_ctrl->v4l2_dev_str.sd_flags =
-		(V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
-	s_ctrl->v4l2_dev_str.ent_function =
-		CAM_SENSOR_DEVICE_TYPE;
-	s_ctrl->v4l2_dev_str.token = s_ctrl;
-
-	rc = cam_register_subdev(&(s_ctrl->v4l2_dev_str));
-	if (rc < 0) {
-		CAM_ERR(CAM_SENSOR, "Fail with cam_register_subdev");
+	rc = cam_sensor_init_subdev_params(s_ctrl);
+	if (rc)
 		goto free_s_ctrl;
-	}
 
 	s_ctrl->i2c_data.per_frame =
 		(struct i2c_settings_array *)
@@ -218,7 +265,7 @@
 		MAX_PER_FRAME_ARRAY, GFP_KERNEL);
 	if (s_ctrl->i2c_data.per_frame == NULL) {
 		rc = -ENOMEM;
-		goto free_s_ctrl;
+		goto unreg_subdev;
 	}
 
 	INIT_LIST_HEAD(&(s_ctrl->i2c_data.init_settings.list_head));
@@ -237,6 +284,8 @@
 	v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), s_ctrl);
 
 	return rc;
+unreg_subdev:
+	cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
 free_s_ctrl:
 	devm_kfree(&pdev->dev, s_ctrl);
 	return rc;
@@ -273,9 +322,12 @@
 	int32_t rc = 0;
 
 	rc = platform_driver_register(&cam_sensor_platform_driver);
-	if (rc)
-		CAM_ERR(CAM_SENSOR, "platform_driver_register failed rc = %d",
+	if (rc < 0) {
+		CAM_ERR(CAM_SENSOR, "platform_driver_register Failed: rc = %d",
 			rc);
+		return rc;
+	}
+
 	rc = i2c_add_driver(&cam_sensor_driver_i2c);
 	if (rc)
 		CAM_ERR(CAM_SENSOR, "i2c_add_driver failed rc = %d", rc);
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
index c10d634..1c3ead0 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
@@ -143,14 +143,17 @@
 		goto FREE_SENSOR_DATA;
 	}
 
-	/* Get CCI master */
-	rc = of_property_read_u32(of_node, "cci-master",
-		&s_ctrl->cci_i2c_master);
-	CAM_DBG(CAM_SENSOR, "cci-master %d, rc %d", s_ctrl->cci_i2c_master, rc);
-	if (rc < 0) {
-		/* Set default master 0 */
-		s_ctrl->cci_i2c_master = MASTER_0;
-		rc = 0;
+	if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
+		/* Get CCI master */
+		rc = of_property_read_u32(of_node, "cci-master",
+			&s_ctrl->cci_i2c_master);
+		CAM_DBG(CAM_SENSOR, "cci-master %d, rc %d",
+			s_ctrl->cci_i2c_master, rc);
+		if (rc < 0) {
+			/* Set default master 0 */
+			s_ctrl->cci_i2c_master = MASTER_0;
+			rc = 0;
+		}
 	}
 
 	if (of_property_read_u32(of_node, "sensor-position-pitch",
@@ -194,6 +197,9 @@
 		if (!(s_ctrl->io_master_info.cci_client))
 			return -ENOMEM;
 
+	} else if (s_ctrl->io_master_info.master_type == I2C_MASTER) {
+		if (!(s_ctrl->io_master_info.client))
+			return -EINVAL;
 	} else {
 		CAM_ERR(CAM_SENSOR,
 			"Invalid master / Master type Not supported");
@@ -220,7 +226,7 @@
 
 	/* Initialize default parameters */
 	for (i = 0; i < soc_info->num_clk; i++) {
-		soc_info->clk[i] = devm_clk_get(&soc_info->pdev->dev,
+		soc_info->clk[i] = devm_clk_get(soc_info->dev,
 					soc_info->clk_name[i]);
 		if (!soc_info->clk[i]) {
 			CAM_ERR(CAM_SENSOR, "get failed for %s",
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
index ca648f01..2c1f520 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
@@ -38,7 +38,7 @@
 	rc = v4l2_subdev_call(cci_client->cci_subdev,
 		core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
 	if (rc < 0) {
-		CAM_ERR(CAM_SENSOR, "line %d rc = %d", rc);
+		CAM_ERR(CAM_SENSOR, "rc = %d", rc);
 		return rc;
 	}
 
@@ -145,6 +145,23 @@
 		MSM_CCI_I2C_WRITE);
 }
 
+int32_t cam_cci_i2c_write_continuous_table(
+	struct camera_io_master *client,
+	struct cam_sensor_i2c_reg_setting *write_setting,
+	uint8_t cam_sensor_i2c_write_flag)
+{
+	int32_t rc = 0;
+
+	if (cam_sensor_i2c_write_flag == 1)
+		rc = cam_cci_i2c_write_table_cmd(client, write_setting,
+			MSM_CCI_I2C_WRITE_BURST);
+	else if (cam_sensor_i2c_write_flag == 0)
+		rc = cam_cci_i2c_write_table_cmd(client, write_setting,
+			MSM_CCI_I2C_WRITE_SEQ);
+
+	return rc;
+}
+
 static int32_t cam_cci_i2c_compare(struct cam_sensor_cci_client *client,
 	uint32_t addr, uint16_t data, uint16_t data_mask,
 	enum camera_sensor_i2c_type data_type,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
index 6207a8a..10b07ec 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
@@ -57,7 +57,7 @@
 
 /**
  * @client: CCI client structure
- * @cci_cmd: CCI command type
+ * @write_setting: I2C register setting
  *
  * This API handles CCI random write
  */
@@ -66,6 +66,18 @@
 	struct cam_sensor_i2c_reg_setting *write_setting);
 
 /**
+ * @client: CCI client structure
+ * @write_setting: I2C register setting
+ * @cam_sensor_i2c_write_flag: burst or seq write
+ *
+ * This API handles CCI continuous write
+ */
+int32_t cam_cci_i2c_write_continuous_table(
+	struct camera_io_master *client,
+	struct cam_sensor_i2c_reg_setting *write_setting,
+	uint8_t cam_sensor_i2c_write_flag);
+
+/**
  * @cci_client: CCI client structure
  * @cci_cmd: CCI command type
  *
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
index 154f4ad..8eb04ec 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
@@ -58,7 +58,7 @@
 			addr, data, addr_type, data_type);
 	} else if (io_master_info->master_type == SPI_MASTER) {
 		return cam_spi_read(io_master_info,
-			addr, data, addr_type);
+			addr, data, addr_type, data_type);
 	} else {
 		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
 			io_master_info->master_type);
@@ -78,8 +78,8 @@
 		return cam_qup_i2c_read_seq(io_master_info->client,
 			addr, data, addr_type, num_bytes);
 	} else if (io_master_info->master_type == SPI_MASTER) {
-		return cam_spi_read(io_master_info,
-			addr, (uint32_t *)data, addr_type);
+		return cam_spi_read_seq(io_master_info,
+			addr, data, addr_type, num_bytes);
 	} else {
 		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
 			io_master_info->master_type);
@@ -104,6 +104,36 @@
 	} else if (io_master_info->master_type == I2C_MASTER) {
 		return cam_qup_i2c_write_table(io_master_info,
 			write_setting);
+	} else if (io_master_info->master_type == SPI_MASTER) {
+		return cam_spi_write_table(io_master_info,
+			write_setting);
+	} else {
+		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+			io_master_info->master_type);
+		return -EINVAL;
+	}
+}
+
+int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info,
+	struct cam_sensor_i2c_reg_setting *write_setting,
+	uint8_t cam_sensor_i2c_write_flag)
+{
+	if (!write_setting || !io_master_info) {
+		CAM_ERR(CAM_SENSOR,
+			"Input parameters not valid ws: %pK ioinfo: %pK",
+			write_setting, io_master_info);
+		return -EINVAL;
+	}
+
+	if (io_master_info->master_type == CCI_MASTER) {
+		return cam_cci_i2c_write_continuous_table(io_master_info,
+			write_setting, cam_sensor_i2c_write_flag);
+	} else if (io_master_info->master_type == I2C_MASTER) {
+		return cam_qup_i2c_write_table(io_master_info,
+			write_setting);
+	} else if (io_master_info->master_type == SPI_MASTER) {
+		return cam_spi_write_table(io_master_info,
+			write_setting);
 	} else {
 		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
 			io_master_info->master_type);
@@ -123,6 +153,9 @@
 			cam_cci_get_subdev();
 		return cam_sensor_cci_i2c_util(io_master_info->cci_client,
 			MSM_CCI_INIT);
+	} else if ((io_master_info->master_type == I2C_MASTER) ||
+			(io_master_info->master_type == SPI_MASTER)) {
+		return 0;
 	} else {
 		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
 			io_master_info->master_type);
@@ -140,6 +173,9 @@
 	if (io_master_info->master_type == CCI_MASTER) {
 		return cam_sensor_cci_i2c_util(io_master_info->cci_client,
 			MSM_CCI_RELEASE);
+	} else if ((io_master_info->master_type == I2C_MASTER) ||
+			(io_master_info->master_type == SPI_MASTER)) {
+		return 0;
 	} else {
 		CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
 			io_master_info->master_type);
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
index 9a60fd0e..f6620c0 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
@@ -87,6 +87,18 @@
 
 /**
  * @io_master_info: I2C/SPI master information
+ * @write_setting: write settings information
+ * @cam_sensor_i2c_write_flag: differentiate between burst & seq
+ *
+ * This API abstracts write functionality based on master type and
+ * write flag for continuous write
+ */
+int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info,
+	struct cam_sensor_i2c_reg_setting *write_setting,
+	uint8_t cam_sensor_i2c_write_flag);
+
+/**
+ * @io_master_info: I2C/SPI master information
  * @addr: I2C address
  * @data: I2C data
  * @data_mask: I2C data mask
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c
index 4011aa0..131b0ae 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c
@@ -59,25 +59,27 @@
  * instruction and the data length.
  */
 static void cam_set_addr(uint32_t addr, uint8_t addr_len,
-	enum camera_sensor_i2c_type type,
+	enum camera_sensor_i2c_type addr_type,
 	char *str)
 {
-	int i, len;
-
 	if (!addr_len)
 		return;
 
-	if (addr_len < type)
-		CAM_DBG(CAM_EEPROM, "omitting higher bits in address");
-
-	/* only support transfer MSB first for now */
-	len = addr_len - type;
-	for (i = len; i < addr_len; i++) {
-		if (i >= 0)
-			str[i] = (addr >> (BITS_PER_BYTE * (addr_len - i - 1)))
-				& 0xFF;
+	if (addr_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
+		str[0] = addr;
+	} else if (addr_type == CAMERA_SENSOR_I2C_TYPE_WORD) {
+		str[0] = addr >> 8;
+		str[1] = addr;
+	} else if (addr_type == CAMERA_SENSOR_I2C_TYPE_3B) {
+		str[0] = addr >> 16;
+		str[1] = addr >> 8;
+		str[2] = addr;
+	} else {
+		str[0] = addr >> 24;
+		str[1] = addr >> 16;
+		str[2] = addr >> 8;
+		str[3] = addr;
 	}
-
 }
 
 /**
@@ -105,6 +107,7 @@
  */
 static int32_t cam_spi_tx_helper(struct camera_io_master *client,
 	struct cam_camera_spi_inst *inst, uint32_t addr, uint8_t *data,
+	enum camera_sensor_i2c_type addr_type,
 	uint32_t num_byte, char *tx, char *rx)
 {
 	int32_t rc = -EINVAL;
@@ -112,10 +115,6 @@
 	char *ctx = NULL, *crx = NULL;
 	uint32_t len, hlen;
 	uint8_t retries = client->spi_client->retries;
-	enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
-
-	if (addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
-		return rc;
 
 	hlen = cam_camera_spi_get_hlen(inst);
 	len = hlen + num_byte;
@@ -166,6 +165,7 @@
 
 static int32_t cam_spi_tx_read(struct camera_io_master *client,
 	struct cam_camera_spi_inst *inst, uint32_t addr, uint8_t *data,
+	enum camera_sensor_i2c_type addr_type,
 	uint32_t num_byte, char *tx, char *rx)
 {
 	int32_t rc = -EINVAL;
@@ -173,12 +173,6 @@
 	char *ctx = NULL, *crx = NULL;
 	uint32_t hlen;
 	uint8_t retries = client->spi_client->retries;
-	enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
-
-	if ((addr_type != CAMERA_SENSOR_I2C_TYPE_WORD)
-		&& (addr_type != CAMERA_SENSOR_I2C_TYPE_BYTE)
-		&& (addr_type != CAMERA_SENSOR_I2C_TYPE_3B))
-		return rc;
 
 	hlen = cam_camera_spi_get_hlen(inst);
 	if (tx) {
@@ -204,14 +198,8 @@
 	}
 
 	ctx[0] = inst->opcode;
-	if (addr_type == CAMERA_SENSOR_I2C_TYPE_3B) {
-		cam_set_addr(addr, inst->addr_len, addr_type,
-			ctx + 1);
-	} else {
-		ctx[1] = (addr >> BITS_PER_BYTE) & 0xFF;
-		ctx[2] = (addr & 0xFF);
-		ctx[3] = 0;
-	}
+	cam_set_addr(addr, inst->addr_len, addr_type, ctx + 1);
+
 	CAM_DBG(CAM_EEPROM, "tx(%u): %02x %02x %02x %02x", hlen, ctx[0],
 		ctx[1], ctx[2],	ctx[3]);
 	while ((rc = cam_spi_txfr_read(spi, ctx, crx, hlen, num_byte))
@@ -235,18 +223,23 @@
 
 int cam_spi_read(struct camera_io_master *client,
 	uint32_t addr, uint32_t *data,
+	enum camera_sensor_i2c_type addr_type,
 	enum camera_sensor_i2c_type data_type)
 {
 	int rc = -EINVAL;
 	uint8_t temp[CAMERA_SENSOR_I2C_TYPE_MAX];
 
-	if ((data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
-		|| (data_type >= CAMERA_SENSOR_I2C_TYPE_MAX))
+	if (addr_type <= CAMERA_SENSOR_I2C_TYPE_INVALID
+		|| addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX
+		|| data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID
+		|| data_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
+		CAM_ERR(CAM_SENSOR, "Failed with addr/data_type verification");
 		return rc;
+	}
 
 	rc = cam_spi_tx_read(client,
 		&client->spi_client->cmd_tbl.read, addr, &temp[0],
-		data_type, NULL, NULL);
+		addr_type, data_type, NULL, NULL);
 	if (rc < 0) {
 		CAM_ERR(CAM_SENSOR, "failed %d", rc);
 		return rc;
@@ -254,23 +247,50 @@
 
 	if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE)
 		*data = temp[0];
-	else
+	else if (data_type == CAMERA_SENSOR_I2C_TYPE_WORD)
 		*data = (temp[0] << BITS_PER_BYTE) | temp[1];
+	else if (data_type == CAMERA_SENSOR_I2C_TYPE_3B)
+		*data = (temp[0] << 16 | temp[1] << 8 | temp[2]);
+	else
+		*data = (temp[0] << 24 | temp[1] << 16 | temp[2] << 8 |
+			temp[3]);
 
 	CAM_DBG(CAM_SENSOR, "addr 0x%x, data %u", addr, *data);
 	return rc;
 }
 
+int32_t cam_spi_read_seq(struct camera_io_master *client,
+	uint32_t addr, uint8_t *data,
+	enum camera_sensor_i2c_type addr_type, int32_t num_bytes)
+{
+	if ((addr_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+		|| (addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)) {
+		CAM_ERR(CAM_SENSOR, "Failed with addr_type verification");
+		return -EINVAL;
+	}
+
+	if (num_bytes == 0) {
+		CAM_ERR(CAM_SENSOR, "num_byte: 0x%x", num_bytes);
+		return -EINVAL;
+	}
+
+	return cam_spi_tx_helper(client,
+		&client->spi_client->cmd_tbl.read_seq, addr, data,
+		addr_type, num_bytes, NULL, NULL);
+}
+
 int cam_spi_query_id(struct camera_io_master *client,
-	uint32_t addr, uint8_t *data, uint32_t num_byte)
+	uint32_t addr, enum camera_sensor_i2c_type addr_type,
+	uint8_t *data, uint32_t num_byte)
 {
 	return cam_spi_tx_helper(client,
-		&client->spi_client->cmd_tbl.query_id, addr, data, num_byte,
-		NULL, NULL);
+		&client->spi_client->cmd_tbl.query_id,
+		addr, data, addr_type, num_byte, NULL, NULL);
 }
 
 static int32_t cam_spi_read_status_reg(
-	struct camera_io_master *client, uint8_t *status)
+	struct camera_io_master *client, uint8_t *status,
+	enum camera_sensor_i2c_type addr_type)
 {
 	struct cam_camera_spi_inst *rs =
 		&client->spi_client->cmd_tbl.read_status;
@@ -279,16 +299,17 @@
 		CAM_ERR(CAM_SENSOR, "not implemented yet");
 		return -ENXIO;
 	}
-	return cam_spi_tx_helper(client, rs, 0, status, 1, NULL, NULL);
+	return cam_spi_tx_helper(client, rs, 0, status,
+		addr_type, 1, NULL, NULL);
 }
 
 static int32_t cam_spi_device_busy(struct camera_io_master *client,
-	uint8_t *busy)
+	uint8_t *busy, enum camera_sensor_i2c_type addr_type)
 {
 	int rc;
 	uint8_t st = 0;
 
-	rc = cam_spi_read_status_reg(client,  &st);
+	rc = cam_spi_read_status_reg(client, &st, addr_type);
 	if (rc < 0) {
 		CAM_ERR(CAM_SENSOR, "failed to read status reg");
 		return rc;
@@ -298,14 +319,15 @@
 }
 
 static int32_t cam_spi_wait(struct camera_io_master *client,
-	struct cam_camera_spi_inst *inst)
+	struct cam_camera_spi_inst *inst,
+	enum camera_sensor_i2c_type addr_type)
 {
 	uint8_t busy;
 	int i, rc;
 
 	CAM_DBG(CAM_SENSOR, "op 0x%x wait start", inst->opcode);
 	for (i = 0; i < inst->delay_count; i++) {
-		rc = cam_spi_device_busy(client, &busy);
+		rc = cam_spi_device_busy(client, &busy, addr_type);
 		if (rc < 0)
 			return rc;
 		if (!busy)
@@ -321,8 +343,8 @@
 	return 0;
 }
 
-static int32_t cam_spi_write_enable(
-	struct camera_io_master *client)
+static int32_t cam_spi_write_enable(struct camera_io_master *client,
+	enum camera_sensor_i2c_type addr_type)
 {
 	struct cam_camera_spi_inst *we =
 		&client->spi_client->cmd_tbl.write_enable;
@@ -334,7 +356,8 @@
 		CAM_ERR(CAM_SENSOR, "not implemented yet");
 		return -EINVAL;
 	}
-	rc = cam_spi_tx_helper(client, we, 0, NULL, 0, NULL, NULL);
+	rc = cam_spi_tx_helper(client, we, 0, NULL, addr_type,
+		0, NULL, NULL);
 	if (rc < 0)
 		CAM_ERR(CAM_SENSOR, "write enable failed");
 	return rc;
@@ -354,7 +377,9 @@
  * used outside cam_spi_write_seq().
  */
 static int32_t cam_spi_page_program(struct camera_io_master *client,
-	uint32_t addr, uint8_t *data, uint16_t len, uint8_t *tx)
+	uint32_t addr, uint8_t *data,
+	enum camera_sensor_i2c_type addr_type,
+	uint16_t len, uint8_t *tx)
 {
 	int rc;
 	struct cam_camera_spi_inst *pg =
@@ -362,10 +387,9 @@
 	struct spi_device *spi = client->spi_client->spi_master;
 	uint8_t retries = client->spi_client->retries;
 	uint8_t header_len = sizeof(pg->opcode) + pg->addr_len + pg->dummy_len;
-	enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
 
 	CAM_DBG(CAM_SENSOR, "addr 0x%x, size 0x%x", addr, len);
-	rc = cam_spi_write_enable(client);
+	rc = cam_spi_write_enable(client, addr_type);
 	if (rc < 0)
 		return rc;
 	memset(tx, 0, header_len);
@@ -375,7 +399,7 @@
 	CAM_DBG(CAM_SENSOR, "tx(%u): %02x %02x %02x %02x",
 		len, tx[0], tx[1], tx[2], tx[3]);
 	while ((rc = spi_write(spi, tx, len + header_len)) && retries) {
-		rc = cam_spi_wait(client, pg);
+		rc = cam_spi_wait(client, pg, addr_type);
 		msleep(client->spi_client->retry_delay);
 		retries--;
 	}
@@ -383,41 +407,54 @@
 		CAM_ERR(CAM_SENSOR, "failed %d", rc);
 		return rc;
 	}
-	rc = cam_spi_wait(client, pg);
+	rc = cam_spi_wait(client, pg, addr_type);
 		return rc;
 }
 
 int cam_spi_write(struct camera_io_master *client,
-	uint32_t addr, uint16_t data,
+	uint32_t addr, uint32_t data,
+	enum camera_sensor_i2c_type addr_type,
 	enum camera_sensor_i2c_type data_type)
 {
 	struct cam_camera_spi_inst *pg =
 		&client->spi_client->cmd_tbl.page_program;
 	uint8_t header_len = sizeof(pg->opcode) + pg->addr_len + pg->dummy_len;
 	uint16_t len = 0;
-	char buf[2];
+	char buf[CAMERA_SENSOR_I2C_TYPE_MAX];
 	char *tx;
 	int rc = -EINVAL;
-	enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
 
-	if ((addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
-		|| (data_type != CAMERA_SENSOR_I2C_TYPE_BYTE
-		&& data_type != CAMERA_SENSOR_I2C_TYPE_WORD))
+	if ((addr_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+		|| (addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
+		|| (data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+		|| (data_type != CAMERA_SENSOR_I2C_TYPE_MAX))
 		return rc;
+
 	CAM_DBG(CAM_EEPROM, "Data: 0x%x", data);
 	len = header_len + (uint8_t)data_type;
 	tx = kmalloc(len, GFP_KERNEL | GFP_DMA);
 	if (!tx)
 		goto NOMEM;
+
 	if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
 		buf[0] = data;
 		CAM_DBG(CAM_EEPROM, "Byte %d: 0x%x", len, buf[0]);
 	} else if (data_type == CAMERA_SENSOR_I2C_TYPE_WORD) {
 		buf[0] = (data >> BITS_PER_BYTE) & 0x00FF;
 		buf[1] = (data & 0x00FF);
+	} else if (data_type == CAMERA_SENSOR_I2C_TYPE_3B) {
+		buf[0] = (data >> 16) & 0x00FF;
+		buf[1] = (data >> 8) & 0x00FF;
+		buf[2] = (data & 0x00FF);
+	} else {
+		buf[0] = (data >> 24) & 0x00FF;
+		buf[1] = (data >> 16) & 0x00FF;
+		buf[2] = (data >> 8) & 0x00FF;
+		buf[3] = (data & 0x00FF);
 	}
+
 	rc = cam_spi_page_program(client, addr, buf,
-		(uint16_t)data_type, tx);
+		addr_type, data_type, tx);
 	if (rc < 0)
 		goto ERROR;
 	goto OUT;
@@ -442,18 +479,22 @@
 
 	if (!client || !write_setting)
 		return rc;
-	if (write_setting->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX
-		|| (write_setting->data_type != CAMERA_SENSOR_I2C_TYPE_BYTE
-		&& write_setting->data_type != CAMERA_SENSOR_I2C_TYPE_WORD))
+
+	if ((write_setting->addr_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+		|| (write_setting->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
+		|| (write_setting->data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+		|| (write_setting->data_type >= CAMERA_SENSOR_I2C_TYPE_MAX))
 		return rc;
+
 	reg_setting = write_setting->reg_setting;
-	client_addr_type = addr_type;
+	client_addr_type = write_setting->addr_type;
 	addr_type = write_setting->addr_type;
 	for (i = 0; i < write_setting->size; i++) {
 		CAM_DBG(CAM_SENSOR, "addr %x data %x",
 			reg_setting->reg_addr, reg_setting->reg_data);
-		rc = cam_spi_write(client, reg_setting->reg_addr,
-			reg_setting->reg_data, write_setting->data_type);
+		rc = cam_spi_write(client,
+			reg_setting->reg_addr, reg_setting->reg_data,
+			write_setting->addr_type, write_setting->data_type);
 		if (rc < 0)
 			break;
 		reg_setting++;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h
index a497491..ec1bede 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h
@@ -78,13 +78,22 @@
 
 int cam_spi_read(struct camera_io_master *client,
 	uint32_t addr, uint32_t *data,
+	enum camera_sensor_i2c_type addr_type,
 	enum camera_sensor_i2c_type data_type);
 
+int cam_spi_read_seq(struct camera_io_master *client,
+	uint32_t addr, uint8_t *data,
+	enum camera_sensor_i2c_type addr_type,
+	int32_t num_bytes);
+
 int cam_spi_query_id(struct camera_io_master *client,
-	uint32_t addr, uint8_t *data, uint32_t num_byte);
+	uint32_t addr,
+	enum camera_sensor_i2c_type addr_type,
+	uint8_t *data, uint32_t num_byte);
 
 int cam_spi_write(struct camera_io_master *client,
-	uint32_t addr, uint16_t data,
+	uint32_t addr, uint32_t data,
+	enum camera_sensor_i2c_type addr_type,
 	enum camera_sensor_i2c_type data_type);
 
 int cam_spi_write_table(struct camera_io_master *client,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
index 6520042b..97b4c01 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
@@ -33,6 +33,7 @@
 #define CAM_CSIPHY_NAME    "cam-csiphy"
 #define CAM_FLASH_NAME     "cam-flash"
 #define CAM_EEPROM_NAME    "cam-eeprom"
+#define CAM_OIS_NAME       "cam-ois"
 
 #define MAX_SYSTEM_PIPELINE_DELAY 2
 
@@ -165,6 +166,11 @@
 	CAM_EEPROM_PACKET_OPCODE_INIT
 };
 
+enum cam_ois_packet_opcodes {
+	CAM_OIS_PACKET_OPCODE_INIT,
+	CAM_OIS_PACKET_OPCODE_OIS_CONTROL
+};
+
 enum msm_bus_perf_setting {
 	S_INIT,
 	S_PREVIEW,
@@ -204,6 +210,8 @@
 
 enum cam_sensor_i2c_cmd_type {
 	CAM_SENSOR_I2C_WRITE_RANDOM,
+	CAM_SENSOR_I2C_WRITE_BURST,
+	CAM_SENSOR_I2C_WRITE_SEQ,
 	CAM_SENSOR_I2C_READ,
 	CAM_SENSOR_I2C_POLL
 };
@@ -224,14 +232,6 @@
 	enum camera_vreg_type type;
 };
 
-struct cam_sensor_module_power_setting {
-	enum msm_camera_power_seq_type seq_type;
-	unsigned short seq_val;
-	uint32_t config_val_low;
-	uint32_t config_val_high;
-	unsigned short delay;
-};
-
 struct msm_camera_gpio_num_info {
 	uint16_t gpio_num[SENSOR_SEQ_TYPE_MAX];
 	uint8_t valid[SENSOR_SEQ_TYPE_MAX];
@@ -333,26 +333,6 @@
 	void *data[10];
 };
 
-struct cam_sensor_power_setting_array {
-	struct cam_sensor_power_setting  power_setting_a[MAX_POWER_CONFIG];
-	struct cam_sensor_power_setting *power_setting;
-	unsigned short size;
-	struct cam_sensor_power_setting  power_down_setting_a[MAX_POWER_CONFIG];
-	struct cam_sensor_power_setting *power_down_setting;
-	unsigned short size_down;
-};
-
-struct msm_camera_sensor_slave_info {
-	enum msm_sensor_camera_id_t camera_id;
-	unsigned short slave_addr;
-	enum i2c_freq_mode i2c_freq_mode;
-	enum camera_sensor_i2c_type addr_type;
-	struct msm_sensor_id_info_t sensor_id_info;
-	struct cam_sensor_power_setting_array power_setting_array;
-	unsigned char  is_init_params_valid;
-	enum msm_sensor_output_format_t output_format;
-};
-
 struct cam_sensor_board_info {
 	struct cam_camera_slave_info slave_info;
 	int32_t sensor_mount_angle;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
index b1698ca..bcdaf6d 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
@@ -82,7 +82,7 @@
 		(struct cam_cmd_unconditional_wait *) *cmd_buf;
 	struct i2c_settings_list *i2c_list = NULL;
 
-	if (i2c_list == NULL) {
+	if (list_ptr == NULL) {
 		CAM_ERR(CAM_SENSOR, "Invalid list ptr");
 		return -EINVAL;
 	}
@@ -196,6 +196,59 @@
 	return rc;
 }
 
+static int32_t cam_sensor_handle_continuous_write(
+	struct cam_cmd_i2c_continuous_wr *cam_cmd_i2c_continuous_wr,
+	struct i2c_settings_array *i2c_reg_settings,
+	uint16_t *cmd_length_in_bytes, int32_t *offset,
+	struct list_head **list)
+{
+	struct i2c_settings_list *i2c_list;
+	int32_t rc = 0, cnt;
+
+	i2c_list = cam_sensor_get_i2c_ptr(i2c_reg_settings,
+		cam_cmd_i2c_continuous_wr->header.count);
+	if (i2c_list == NULL ||
+		i2c_list->i2c_settings.reg_setting == NULL) {
+		CAM_ERR(CAM_SENSOR, "Failed in allocating i2c_list");
+		return -ENOMEM;
+	}
+
+	*cmd_length_in_bytes = (sizeof(struct i2c_rdwr_header) +
+		sizeof(cam_cmd_i2c_continuous_wr->reg_addr) +
+		sizeof(struct cam_cmd_read) *
+		(cam_cmd_i2c_continuous_wr->header.count));
+	if (cam_cmd_i2c_continuous_wr->header.op_code ==
+		CAMERA_SENSOR_I2C_OP_CONT_WR_BRST)
+		i2c_list->op_code = CAM_SENSOR_I2C_WRITE_BURST;
+	else if (cam_cmd_i2c_continuous_wr->header.op_code ==
+		CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN)
+		i2c_list->op_code = CAM_SENSOR_I2C_WRITE_SEQ;
+	else
+		return -EINVAL;
+
+	i2c_list->i2c_settings.addr_type =
+		cam_cmd_i2c_continuous_wr->header.addr_type;
+	i2c_list->i2c_settings.data_type =
+		cam_cmd_i2c_continuous_wr->header.data_type;
+
+	for (cnt = 0; cnt < (cam_cmd_i2c_continuous_wr->header.count);
+		cnt++) {
+		i2c_list->i2c_settings.reg_setting[cnt].reg_addr =
+			cam_cmd_i2c_continuous_wr->
+			reg_addr;
+		i2c_list->i2c_settings.
+			reg_setting[cnt].reg_data =
+			cam_cmd_i2c_continuous_wr->
+			data_read[cnt].reg_data;
+		i2c_list->i2c_settings.
+			reg_setting[cnt].data_mask = 0;
+	}
+	(*offset) += cnt;
+	*list = &(i2c_list->list);
+
+	return rc;
+}
+
 /**
  * Name : cam_sensor_i2c_pkt_parser
  * Description : Parse CSL CCI packet and apply register settings
@@ -260,7 +313,29 @@
 					&cmd_length_in_bytes, &j, &list);
 				if (rc < 0) {
 					CAM_ERR(CAM_SENSOR,
-						"Failed in random read %d", rc);
+					"Failed in random write %d", rc);
+					return rc;
+				}
+
+				cmd_buf += cmd_length_in_bytes /
+					sizeof(uint32_t);
+				byte_cnt += cmd_length_in_bytes;
+				break;
+			}
+			case CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR: {
+				uint16_t cmd_length_in_bytes   = 0;
+				struct cam_cmd_i2c_continuous_wr
+				*cam_cmd_i2c_continuous_wr =
+				(struct cam_cmd_i2c_continuous_wr *)
+				cmd_buf;
+
+				rc = cam_sensor_handle_continuous_write(
+					cam_cmd_i2c_continuous_wr,
+					i2c_reg_settings,
+					&cmd_length_in_bytes, &j, &list);
+				if (rc < 0) {
+					CAM_ERR(CAM_SENSOR,
+					"Failed in continuous write %d", rc);
 					return rc;
 				}
 
@@ -323,7 +398,7 @@
 	uint16_t power_setting_size)
 {
 	int32_t rc = 0, j = 0, i = 0;
-	uint32_t num_vreg;
+	int num_vreg;
 
 	/* Validate input parameters */
 	if (!soc_info || !power_setting) {
@@ -334,12 +409,20 @@
 
 	num_vreg = soc_info->num_rgltr;
 
-	if (num_vreg <= 0) {
+	if ((num_vreg <= 0) || (num_vreg > CAM_SOC_MAX_REGULATOR)) {
 		CAM_ERR(CAM_SENSOR, "failed: num_vreg %d", num_vreg);
 		return -EINVAL;
 	}
 
 	for (i = 0; i < power_setting_size; i++) {
+
+		if (power_setting[i].seq_type < SENSOR_MCLK ||
+			power_setting[i].seq_type >= SENSOR_SEQ_TYPE_MAX) {
+			CAM_ERR(CAM_SENSOR, "failed: Invalid Seq type\n",
+				power_setting[i].seq_type);
+			return -EINVAL;
+		}
+
 		switch (power_setting[i].seq_type) {
 		case SENSOR_VDIG:
 			for (j = 0; j < num_vreg; j++) {
@@ -488,12 +571,8 @@
 			if (j == num_vreg)
 				power_setting[i].seq_val = INVALID_VREG;
 			break;
-
-		default: {
-			CAM_ERR(CAM_SENSOR, "invalid seq_val %d",
-				power_setting[i].seq_val);
+		default:
 			break;
-			}
 		}
 	}
 
@@ -507,15 +586,21 @@
 	uint8_t size = 0;
 	struct cam_soc_gpio_data *gpio_conf =
 			soc_info->gpio_data;
-	struct gpio *gpio_tbl = gpio_conf->cam_gpio_req_tbl;
+	struct gpio *gpio_tbl = NULL;
 
-	size = gpio_conf->cam_gpio_req_tbl_size;
+	if (!gpio_conf) {
+		CAM_INFO(CAM_SENSOR, "No GPIO data");
+		return 0;
+	}
 
 	if (gpio_conf->cam_gpio_common_tbl_size <= 0) {
 		CAM_INFO(CAM_SENSOR, "No GPIO entry");
-		return 0;
+		return -EINVAL;
 	}
 
+	gpio_tbl = gpio_conf->cam_gpio_req_tbl;
+	size = gpio_conf->cam_gpio_req_tbl_size;
+
 	if (!gpio_tbl || !size) {
 		CAM_ERR(CAM_SENSOR, "invalid gpio_tbl %pK / size %d",
 			gpio_tbl, size);
@@ -857,13 +942,16 @@
 {
 	int rc = 0, val = 0;
 	uint32_t gpio_array_size;
-	struct platform_device *pdev = NULL;
 	struct device_node *of_node = NULL;
 	struct cam_soc_gpio_data *gconf = NULL;
 	struct msm_camera_gpio_num_info *gpio_num_info = NULL;
 
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
+	if (!soc_info->dev) {
+		CAM_ERR(CAM_SENSOR, "device node NULL");
+		return -EINVAL;
+	}
+
+	of_node = soc_info->dev->of_node;
 
 	gconf = soc_info->gpio_data;
 	if (!gconf) {
@@ -1096,8 +1184,8 @@
 	int gpio_offset = -1;
 
 	if (!gpio_num_info) {
-		CAM_ERR(CAM_SENSOR, "Input Parameters are not proper");
-		return -EINVAL;
+		CAM_INFO(CAM_SENSOR, "Input Parameters are not proper");
+		return 0;
 	}
 
 	CAM_DBG(CAM_SENSOR, "Seq type: %d, config: %d", seq_type, val);
@@ -1132,8 +1220,8 @@
 	gpio_num_info = ctrl->gpio_num_info;
 	num_vreg = soc_info->num_rgltr;
 
-	if ((num_vreg == 0) || (num_vreg > CAM_SOC_MAX_REGULATOR)) {
-		CAM_ERR(CAM_SENSOR, "Regulators are not initialized");
+	if ((num_vreg <= 0) || (num_vreg > CAM_SOC_MAX_REGULATOR)) {
+		CAM_ERR(CAM_SENSOR, "failed: num_vreg %d", num_vreg);
 		return -EINVAL;
 	}
 
@@ -1177,7 +1265,7 @@
 
 					soc_info->rgltr[j] =
 					regulator_get(
-						&soc_info->pdev->dev,
+						soc_info->dev,
 						soc_info->rgltr_name[j]);
 
 					if (IS_ERR_OR_NULL(
@@ -1229,16 +1317,13 @@
 				CAM_ERR(CAM_SENSOR, "request gpio failed");
 				return no_gpio;
 			}
-			if (power_setting->seq_val >= CAM_VREG_MAX ||
-				!gpio_num_info) {
-				CAM_ERR(CAM_SENSOR, "gpio index %d >= max %d",
-					power_setting->seq_val,
-					CAM_VREG_MAX);
+			if (!gpio_num_info) {
+				CAM_ERR(CAM_SENSOR, "Invalid gpio_num_info");
 				goto power_up_failed;
 			}
 			CAM_DBG(CAM_SENSOR, "gpio set val %d",
 				gpio_num_info->gpio_num
-				[power_setting->seq_val]);
+				[power_setting->seq_type]);
 
 			rc = msm_cam_sensor_handle_reg_gpio(
 				power_setting->seq_type,
@@ -1270,7 +1355,7 @@
 				vreg_idx = power_setting->seq_val;
 
 				soc_info->rgltr[vreg_idx] =
-					regulator_get(&soc_info->pdev->dev,
+					regulator_get(soc_info->dev,
 						soc_info->rgltr_name[vreg_idx]);
 				if (IS_ERR_OR_NULL(
 					soc_info->rgltr[vreg_idx])) {
@@ -1336,11 +1421,11 @@
 			if (!gpio_num_info)
 				continue;
 			if (!gpio_num_info->valid
-				[power_setting->seq_val])
+				[power_setting->seq_type])
 				continue;
 			gpio_set_value_cansleep(
 				gpio_num_info->gpio_num
-				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
+				[power_setting->seq_type], GPIOF_OUT_INIT_LOW);
 			break;
 		case SENSOR_VANA:
 		case SENSOR_VDIG:
@@ -1481,6 +1566,11 @@
 	gpio_num_info = ctrl->gpio_num_info;
 	num_vreg = soc_info->num_rgltr;
 
+	if ((num_vreg <= 0) || (num_vreg > CAM_SOC_MAX_REGULATOR)) {
+		CAM_ERR(CAM_SENSOR, "failed: num_vreg %d", num_vreg);
+		return -EINVAL;
+	}
+
 	for (index = 0; index < ctrl->power_down_setting_size; index++) {
 		CAM_DBG(CAM_SENSOR, "index %d",  index);
 		pd = &ctrl->power_down_setting[index];
@@ -1506,12 +1596,12 @@
 		case SENSOR_CUSTOM_GPIO1:
 		case SENSOR_CUSTOM_GPIO2:
 
-			if (!gpio_num_info->valid[pd->seq_val])
+			if (!gpio_num_info->valid[pd->seq_type])
 				continue;
 
 			gpio_set_value_cansleep(
 				gpio_num_info->gpio_num
-				[pd->seq_val],
+				[pd->seq_type],
 				(int) pd->config_val);
 
 			break;
diff --git a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
index ff7a0e5..cbf54f7 100644
--- a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
+++ b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
@@ -21,7 +21,8 @@
 #include <linux/msm_dma_iommu_mapping.h>
 #include <linux/workqueue.h>
 #include <linux/genalloc.h>
-
+#include <soc/qcom/scm.h>
+#include <soc/qcom/secure_buffer.h>
 #include "cam_smmu_api.h"
 #include "cam_debug_util.h"
 
@@ -118,6 +119,7 @@
 		int, void*);
 	void *token[CAM_SMMU_CB_MAX];
 	int cb_count;
+	int secure_count;
 };
 
 struct cam_iommu_cb_set {
@@ -151,6 +153,17 @@
 	size_t phys_len;
 };
 
+struct cam_sec_buff_info {
+	struct ion_handle *i_hdl;
+	struct ion_client *i_client;
+	enum dma_data_direction dir;
+	int ref_count;
+	dma_addr_t paddr;
+	struct list_head list;
+	int ion_fd;
+	size_t len;
+};
+
 static struct cam_iommu_cb_set iommu_cb_set;
 
 static enum dma_data_direction cam_smmu_translate_dir(
@@ -166,6 +179,9 @@
 static struct cam_dma_buff_info *cam_smmu_find_mapping_by_ion_index(int idx,
 	int ion_fd);
 
+static struct cam_sec_buff_info *cam_smmu_find_mapping_by_sec_buf_idx(int idx,
+	int ion_fd);
+
 static int cam_smmu_init_scratch_map(struct scratch_mapping *scratch_map,
 	dma_addr_t base, size_t size,
 	int order);
@@ -544,7 +560,15 @@
 					"Error: %s already got handle 0x%x",
 					name,
 					iommu_cb_set.cb_info[i].handle);
+
+				if (iommu_cb_set.cb_info[i].is_secure)
+					iommu_cb_set.cb_info[i].secure_count++;
+
 				mutex_unlock(&iommu_cb_set.cb_info[i].lock);
+				if (iommu_cb_set.cb_info[i].is_secure) {
+					*hdl = iommu_cb_set.cb_info[i].handle;
+					return 0;
+				}
 				return -EINVAL;
 			}
 
@@ -556,6 +580,8 @@
 			/* put handle in the table */
 			iommu_cb_set.cb_info[i].handle = handle;
 			iommu_cb_set.cb_info[i].cb_count = 0;
+			if (iommu_cb_set.cb_info[i].is_secure)
+				iommu_cb_set.cb_info[i].secure_count++;
 			*hdl = handle;
 			CAM_DBG(CAM_SMMU, "%s creates handle 0x%x",
 				name, handle);
@@ -693,6 +719,24 @@
 
 	CAM_ERR(CAM_SMMU, "Error: Cannot find fd %d by index %d",
 		ion_fd, idx);
+
+	return NULL;
+}
+
+static struct cam_sec_buff_info *cam_smmu_find_mapping_by_sec_buf_idx(int idx,
+	int ion_fd)
+{
+	struct cam_sec_buff_info *mapping;
+
+	list_for_each_entry(mapping, &iommu_cb_set.cb_info[idx].smmu_buf_list,
+		list) {
+		if (mapping->ion_fd == ion_fd) {
+			CAM_DBG(CAM_SMMU, "find ion_fd %d", ion_fd);
+			return mapping;
+		}
+	}
+	CAM_ERR(CAM_SMMU, "Error: Cannot find fd %d by index %d",
+		ion_fd, idx);
 	return NULL;
 }
 
@@ -1339,6 +1383,25 @@
 	return CAM_SMMU_BUFF_NOT_EXIST;
 }
 
+static enum cam_smmu_buf_state cam_smmu_check_secure_fd_in_list(int idx,
+					int ion_fd, dma_addr_t *paddr_ptr,
+					size_t *len_ptr)
+{
+	struct cam_sec_buff_info *mapping;
+
+	list_for_each_entry(mapping,
+			&iommu_cb_set.cb_info[idx].smmu_buf_list,
+			list) {
+		if (mapping->ion_fd == ion_fd) {
+			*paddr_ptr = mapping->paddr;
+			*len_ptr = mapping->len;
+			return CAM_SMMU_BUFF_EXIST;
+		}
+	}
+
+	return CAM_SMMU_BUFF_NOT_EXIST;
+}
+
 int cam_smmu_get_handle(char *identifier, int *handle_ptr)
 {
 	int ret = 0;
@@ -1722,14 +1785,200 @@
 	return rc;
 }
 
-int cam_smmu_map_sec_iova(int handle, int ion_fd,
-	enum cam_smmu_map_dir dir, dma_addr_t *paddr_ptr,
-	size_t *len_ptr)
+static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd,
+		 enum dma_data_direction dma_dir, struct ion_client *client,
+		 dma_addr_t *paddr_ptr,
+		 size_t *len_ptr)
 {
-	/* not implemented yet */
-	return -EPERM;
+	int rc = 0;
+	struct ion_handle *i_handle = NULL;
+	struct cam_sec_buff_info *mapping_info;
+
+	/* clean the content from clients */
+	*paddr_ptr = (dma_addr_t)NULL;
+	*len_ptr = (size_t)0;
+
+	i_handle = ion_import_dma_buf_fd(client, ion_fd);
+	if (IS_ERR_OR_NULL((void *)(i_handle))) {
+		CAM_ERR(CAM_SMMU, "ion import dma buffer failed");
+		return -EINVAL;
+	}
+
+	/* return addr and len to client */
+	rc = ion_phys(client, i_handle, paddr_ptr, len_ptr);
+	if (rc) {
+		CAM_ERR(CAM_SMMU, "ION Get Physical failed, rc: %d",
+			rc);
+		return rc;
+	}
+
+	/* fill up mapping_info */
+	mapping_info = kzalloc(sizeof(struct cam_sec_buff_info), GFP_KERNEL);
+	if (!mapping_info)
+		return -ENOMEM;
+
+	mapping_info->ion_fd = ion_fd;
+	mapping_info->paddr = *paddr_ptr;
+	mapping_info->len = *len_ptr;
+	mapping_info->dir = dma_dir;
+	mapping_info->ref_count = 1;
+	mapping_info->i_hdl = i_handle;
+	mapping_info->i_client = client;
+
+	CAM_DBG(CAM_SMMU, "ion_fd = %d, dev = %pK, paddr= %pK, len = %u",
+			ion_fd,
+			(void *)iommu_cb_set.cb_info[idx].dev,
+			(void *)*paddr_ptr, (unsigned int)*len_ptr);
+
+	/* add to the list */
+	list_add(&mapping_info->list, &iommu_cb_set.cb_info[idx].smmu_buf_list);
+
+	return rc;
 }
-EXPORT_SYMBOL(cam_smmu_map_sec_iova);
+
+int cam_smmu_map_stage2_iova(int handle,
+		int ion_fd, enum cam_smmu_map_dir dir,
+		struct ion_client *client, ion_phys_addr_t *paddr_ptr,
+		size_t *len_ptr)
+{
+	int idx, rc;
+	enum dma_data_direction dma_dir;
+	enum cam_smmu_buf_state buf_state;
+
+	if (!paddr_ptr || !len_ptr) {
+		CAM_ERR(CAM_SMMU,
+			"Error: Invalid inputs, paddr_ptr:%pK, len_ptr: %pK",
+			paddr_ptr, len_ptr);
+		return -EINVAL;
+	}
+	/* clean the content from clients */
+	*paddr_ptr = (dma_addr_t)NULL;
+	*len_ptr = (size_t)0;
+
+	dma_dir = cam_smmu_translate_dir(dir);
+	if (dma_dir == DMA_NONE) {
+		CAM_ERR(CAM_SMMU,
+			"Error: translate direction failed. dir = %d", dir);
+		return -EINVAL;
+	}
+
+	idx = GET_SMMU_TABLE_IDX(handle);
+	if ((handle == HANDLE_INIT) ||
+		(idx < 0) ||
+		(idx >= iommu_cb_set.cb_num)) {
+		CAM_ERR(CAM_SMMU,
+			"Error: handle or index invalid. idx = %d hdl = %x",
+			idx, handle);
+		return -EINVAL;
+	}
+
+	if (!iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't map secure mem to non secure cb");
+		return -EINVAL;
+	}
+
+	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
+	if (iommu_cb_set.cb_info[idx].handle != handle) {
+		CAM_ERR(CAM_SMMU,
+			"Error: hdl is not valid, table_hdl = %x, hdl = %x",
+			iommu_cb_set.cb_info[idx].handle, handle);
+		rc = -EINVAL;
+		goto get_addr_end;
+	}
+
+	buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, paddr_ptr,
+			len_ptr);
+	if (buf_state == CAM_SMMU_BUFF_EXIST) {
+		CAM_DBG(CAM_SMMU, "fd:%d already in list, give same addr back",
+			ion_fd);
+		rc = 0;
+		goto get_addr_end;
+	}
+	rc = cam_smmu_map_stage2_buffer_and_add_to_list(idx, ion_fd, dma_dir,
+			client, paddr_ptr, len_ptr);
+	if (rc < 0) {
+		CAM_ERR(CAM_SMMU, "Error: mapping or add list fail");
+		goto get_addr_end;
+	}
+
+get_addr_end:
+	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+	return rc;
+}
+EXPORT_SYMBOL(cam_smmu_map_stage2_iova);
+
+static int cam_smmu_secure_unmap_buf_and_remove_from_list(
+		struct cam_sec_buff_info *mapping_info,
+		int idx)
+{
+	if (!mapping_info) {
+		CAM_ERR(CAM_SMMU, "Error: List doesn't exist");
+		return -EINVAL;
+	}
+	ion_free(mapping_info->i_client, mapping_info->i_hdl);
+	list_del_init(&mapping_info->list);
+
+	CAM_DBG(CAM_SMMU, "unmap fd: %d, idx : %d", mapping_info->ion_fd, idx);
+
+	/* free one buffer */
+	kfree(mapping_info);
+	return 0;
+}
+
+int cam_smmu_unmap_stage2_iova(int handle, int ion_fd)
+{
+	int idx, rc;
+	struct cam_sec_buff_info *mapping_info;
+
+	/* find index in the iommu_cb_set.cb_info */
+	idx = GET_SMMU_TABLE_IDX(handle);
+	if ((handle == HANDLE_INIT) ||
+		(idx < 0) ||
+		(idx >= iommu_cb_set.cb_num)) {
+		CAM_ERR(CAM_SMMU,
+			"Error: handle or index invalid. idx = %d hdl = %x",
+			idx, handle);
+		return -EINVAL;
+	}
+
+	if (!iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't unmap secure mem from non secure cb");
+		return -EINVAL;
+	}
+
+	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
+	if (iommu_cb_set.cb_info[idx].handle != handle) {
+		CAM_ERR(CAM_SMMU,
+			"Error: hdl is not valid, table_hdl = %x, hdl = %x",
+			iommu_cb_set.cb_info[idx].handle, handle);
+		rc = -EINVAL;
+		goto put_addr_end;
+	}
+
+	/* based on ion fd and index, we can find mapping info of buffer */
+	mapping_info = cam_smmu_find_mapping_by_sec_buf_idx(idx, ion_fd);
+	if (!mapping_info) {
+		CAM_ERR(CAM_SMMU,
+			"Error: Invalid params! idx = %d, fd = %d",
+			idx, ion_fd);
+		rc = -EINVAL;
+		goto put_addr_end;
+	}
+
+	/* unmapping one buffer from device */
+	rc = cam_smmu_secure_unmap_buf_and_remove_from_list(mapping_info, idx);
+	if (rc) {
+		CAM_ERR(CAM_SMMU, "Error: unmap or remove list fail");
+		goto put_addr_end;
+	}
+
+put_addr_end:
+	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+	return rc;
+}
+EXPORT_SYMBOL(cam_smmu_unmap_stage2_iova);
 
 int cam_smmu_map_iova(int handle, int ion_fd,
 	enum cam_smmu_map_dir dir, dma_addr_t *paddr_ptr,
@@ -1767,6 +2016,12 @@
 		return -EINVAL;
 	}
 
+	if (iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't map non-secure mem to secure cb");
+		return -EINVAL;
+	}
+
 	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
 	if (iommu_cb_set.cb_info[idx].handle != handle) {
 		CAM_ERR(CAM_SMMU, "hdl is not valid, table_hdl = %x, hdl = %x",
@@ -1786,9 +2041,7 @@
 	buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, paddr_ptr,
 		len_ptr);
 	if (buf_state == CAM_SMMU_BUFF_EXIST) {
-		CAM_ERR(CAM_SMMU,
-			"ion_fd:%d already in the list, give same addr back",
-			 ion_fd);
+		CAM_ERR(CAM_SMMU, "ion_fd:%d already in the list", ion_fd);
 		rc = -EALREADY;
 		goto get_addr_end;
 	}
@@ -1832,6 +2085,12 @@
 		return -EINVAL;
 	}
 
+	if (iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't get non-secure mem from secure cb");
+		return -EINVAL;
+	}
+
 	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
 	if (iommu_cb_set.cb_info[idx].handle != handle) {
 		CAM_ERR(CAM_SMMU,
@@ -1854,12 +2113,65 @@
 }
 EXPORT_SYMBOL(cam_smmu_get_iova);
 
-int cam_smmu_unmap_sec_iova(int handle, int ion_fd)
+int cam_smmu_get_stage2_iova(int handle, int ion_fd,
+	dma_addr_t *paddr_ptr, size_t *len_ptr)
 {
-	/* not implemented yet */
-	return -EPERM;
+	int idx, rc = 0;
+	enum cam_smmu_buf_state buf_state;
+
+	if (!paddr_ptr || !len_ptr) {
+		CAM_ERR(CAM_SMMU, "Error: Input pointers are invalid");
+		return -EINVAL;
+	}
+
+	if (handle == HANDLE_INIT) {
+		CAM_ERR(CAM_SMMU, "Error: Invalid handle");
+		return -EINVAL;
+	}
+
+	/* clean the content from clients */
+	*paddr_ptr = (dma_addr_t)NULL;
+	*len_ptr = (size_t)0;
+
+	idx = GET_SMMU_TABLE_IDX(handle);
+	if (idx < 0 || idx >= iommu_cb_set.cb_num) {
+		CAM_ERR(CAM_SMMU,
+			"Error: handle or index invalid. idx = %d hdl = %x",
+			idx, handle);
+		return -EINVAL;
+	}
+
+	if (!iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't get secure mem from non secure cb");
+		return -EINVAL;
+	}
+
+	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
+	if (iommu_cb_set.cb_info[idx].handle != handle) {
+		CAM_ERR(CAM_SMMU,
+			"Error: hdl is not valid, table_hdl = %x, hdl = %x",
+			iommu_cb_set.cb_info[idx].handle, handle);
+		rc = -EINVAL;
+		goto get_addr_end;
+	}
+
+	buf_state = cam_smmu_check_secure_fd_in_list(idx,
+		ion_fd,
+		paddr_ptr,
+		len_ptr);
+
+	if (buf_state == CAM_SMMU_BUFF_NOT_EXIST) {
+		CAM_ERR(CAM_SMMU, "ion_fd:%d not in the mapped list", ion_fd);
+		rc = -EINVAL;
+		goto get_addr_end;
+	}
+
+get_addr_end:
+	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+	return rc;
 }
-EXPORT_SYMBOL(cam_smmu_unmap_sec_iova);
+EXPORT_SYMBOL(cam_smmu_get_stage2_iova);
 
 int cam_smmu_unmap_iova(int handle,
 	int ion_fd,
@@ -1882,6 +2194,12 @@
 		return -EINVAL;
 	}
 
+	if (iommu_cb_set.cb_info[idx].is_secure) {
+		CAM_ERR(CAM_SMMU,
+			"Error: can't unmap non-secure mem from secure cb");
+		return -EINVAL;
+	}
+
 	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
 	if (iommu_cb_set.cb_info[idx].handle != handle) {
 		CAM_ERR(CAM_SMMU,
@@ -1989,6 +2307,22 @@
 		cam_smmu_clean_buffer_list(idx);
 	}
 
+	if (&iommu_cb_set.cb_info[idx].is_secure) {
+		if (iommu_cb_set.cb_info[idx].secure_count == 0) {
+			mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+			return -EPERM;
+		}
+
+		iommu_cb_set.cb_info[idx].secure_count--;
+		if (iommu_cb_set.cb_info[idx].secure_count == 0) {
+			iommu_cb_set.cb_info[idx].cb_count = 0;
+			iommu_cb_set.cb_info[idx].handle = HANDLE_INIT;
+		}
+
+		mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+		return 0;
+	}
+
 	iommu_cb_set.cb_info[idx].cb_count = 0;
 	iommu_cb_set.cb_info[idx].handle = HANDLE_INIT;
 	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
@@ -2168,7 +2502,15 @@
 	}
 
 	mem_map_node = of_get_child_by_name(of_node, "iova-mem-map");
+	cb->is_secure = of_property_read_bool(of_node, "qcom,secure-cb");
+
+	/*
+	 * We always expect a memory map node, except when it is a secure
+	 * context bank.
+	 */
 	if (!mem_map_node) {
+		if (cb->is_secure)
+			return 0;
 		CAM_ERR(CAM_SMMU, "iova-mem-map not present");
 		return -EINVAL;
 	}
@@ -2292,6 +2634,12 @@
 		return rc;
 	}
 
+	if (cb->is_secure) {
+		/* increment count to next bank */
+		iommu_cb_set.cb_init_count++;
+		return 0;
+	}
+
 	/* set up the iommu mapping for the  context bank */
 	if (type == CAM_QSMMU) {
 		CAM_ERR(CAM_SMMU, "Error: QSMMU ctx not supported for : %s",
diff --git a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
index 20445f3..4cb6efb 100644
--- a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
+++ b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
@@ -204,6 +204,19 @@
  */
 int cam_smmu_get_iova(int handle, int ion_fd,
 	dma_addr_t *paddr_ptr, size_t *len_ptr);
+
+/**
+ * @brief Maps memory from an ION fd into IOVA space
+ *
+ * @param handle: SMMU handle identifying the secure context bank to map to
+ * @param ion_fd: ION fd of memory to map to
+ * @param paddr_ptr: Pointer IOVA address that will be returned
+ * @param len_ptr: Length of memory mapped
+ *
+ * @return Status of operation. Negative in case of error. Zero otherwise.
+ */
+int cam_smmu_get_stage2_iova(int handle, int ion_fd,
+	dma_addr_t *paddr_ptr, size_t *len_ptr);
 /**
  * @brief Unmaps memory from context bank
  *
@@ -217,27 +230,28 @@
 /**
  * @brief Maps secure memory for SMMU handle
  *
- * @param handle: SMMU handle identifying context bank
+ * @param handle: SMMU handle identifying secure context bank
  * @param ion_fd: ION fd to map securely
  * @param dir: DMA Direction for the mapping
+ * @param client: Ion client passed by caller
  * @param dma_addr: Returned IOVA address after mapping
  * @param len_ptr: Length of memory mapped
  *
  * @return Status of operation. Negative in case of error. Zero otherwise.
  */
-int cam_smmu_map_sec_iova(int handle,
-	int ion_fd, enum cam_smmu_map_dir dir,
-	dma_addr_t *dma_addr, size_t *len_ptr);
+int cam_smmu_map_stage2_iova(int handle,
+	int ion_fd, enum cam_smmu_map_dir dir, struct ion_client *client,
+	ion_phys_addr_t *dma_addr, size_t *len_ptr);
 
 /**
  * @brief Unmaps secure memopry for SMMU handle
  *
- * @param handle: SMMU handle identifying context bank
+ * @param handle: SMMU handle identifying secure context bank
  * @param ion_fd: ION fd to unmap
  *
  * @return Status of operation. Negative in case of error. Zero otherwise.
  */
-int cam_smmu_unmap_sec_iova(int handle, int ion_fd);
+int cam_smmu_unmap_stage2_iova(int handle, int ion_fd);
 
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
index 21f90ca..f451155 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
@@ -83,6 +83,9 @@
 	case CAM_HFI:
 		name = "CAM-HFI";
 		break;
+	case CAM_OIS:
+		name = "CAM-OIS";
+		break;
 	default:
 		name = "CAM";
 		break;
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
index 7275d56..40dbe00 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
@@ -33,6 +33,7 @@
 #define CAM_UTIL       (1 << 17)
 #define CAM_HFI        (1 << 18)
 #define CAM_CTXT       (1 << 19)
+#define CAM_OIS        (1 << 20)
 
 #define STR_BUFFER_MAX_LENGTH  1024
 
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
index a1cdfe9..aecce12 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
@@ -17,7 +17,7 @@
 #include "cam_packet_util.h"
 #include "cam_debug_util.h"
 
-static int cam_packet_util_get_cmd_mem_addr(int handle, uint32_t **buf_addr,
+int cam_packet_util_get_cmd_mem_addr(int handle, uint32_t **buf_addr,
 	size_t *len)
 {
 	int rc = 0;
@@ -124,7 +124,7 @@
 }
 
 int cam_packet_util_process_patches(struct cam_packet *packet,
-	int32_t iommu_hdl)
+	int32_t iommu_hdl, int32_t sec_mmu_hdl)
 {
 	struct cam_patch_desc *patch_desc = NULL;
 	uint64_t   iova_addr;
@@ -136,6 +136,7 @@
 	size_t     src_buf_size;
 	int        i;
 	int        rc = 0;
+	int32_t    hdl;
 
 	/* process patch descriptor */
 	patch_desc = (struct cam_patch_desc *)
@@ -146,8 +147,11 @@
 			sizeof(struct cam_patch_desc));
 
 	for (i = 0; i < packet->num_patches; i++) {
+
+		hdl = cam_mem_is_secure_buf(patch_desc[i].src_buf_hdl) ?
+			sec_mmu_hdl : iommu_hdl;
 		rc = cam_mem_get_io_buf(patch_desc[i].src_buf_hdl,
-			iommu_hdl, &iova_addr, &src_buf_size);
+			hdl, &iova_addr, &src_buf_size);
 		if (rc < 0) {
 			CAM_ERR(CAM_UTIL, "unable to get src buf address");
 			return rc;
@@ -182,3 +186,78 @@
 	return rc;
 }
 
+int cam_packet_util_process_generic_cmd_buffer(
+	struct cam_cmd_buf_desc *cmd_buf,
+	cam_packet_generic_blob_handler blob_handler_cb, void *user_data)
+{
+	int       rc;
+	uint64_t  cpu_addr;
+	size_t    buf_size;
+	uint32_t *blob_ptr;
+	uint32_t  blob_type, blob_size, blob_block_size, len_read;
+
+	if (!cmd_buf || !blob_handler_cb) {
+		CAM_ERR(CAM_UTIL, "Invalid args %pK %pK",
+			cmd_buf, blob_handler_cb);
+		return -EINVAL;
+	}
+
+	if (!cmd_buf->length || !cmd_buf->size) {
+		CAM_ERR(CAM_UTIL, "Invalid cmd buf size %d %d",
+			cmd_buf->length, cmd_buf->size);
+		return -EINVAL;
+	}
+
+	rc = cam_mem_get_cpu_buf(cmd_buf->mem_handle, &cpu_addr, &buf_size);
+	if (rc || !cpu_addr || (buf_size == 0)) {
+		CAM_ERR(CAM_UTIL, "Failed in Get cpu addr, rc=%d, cpu_addr=%pK",
+			rc, cpu_addr);
+		return rc;
+	}
+
+	blob_ptr = (uint32_t *)((uint8_t *)cpu_addr + cmd_buf->offset);
+
+	CAM_DBG(CAM_UTIL,
+		"GenericCmdBuffer cpuaddr=%pK, blobptr=%pK, len=%d",
+		cpu_addr, blob_ptr, cmd_buf->length);
+
+	len_read = 0;
+	while (len_read < cmd_buf->length) {
+		blob_type =
+			((*blob_ptr) & CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK) >>
+			CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT;
+		blob_size =
+			((*blob_ptr) & CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK) >>
+			CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT;
+
+		blob_block_size = sizeof(uint32_t) +
+			(((blob_size + sizeof(uint32_t) - 1) /
+			sizeof(uint32_t)) * sizeof(uint32_t));
+
+		CAM_DBG(CAM_UTIL,
+			"Blob type=%d size=%d block_size=%d len_read=%d total=%d",
+			blob_type, blob_size, blob_block_size, len_read,
+			cmd_buf->length);
+
+		if (len_read + blob_block_size > cmd_buf->length) {
+			CAM_ERR(CAM_UTIL, "Invalid Blob %d %d %d %d",
+				blob_type, blob_size, len_read,
+				cmd_buf->length);
+			return -EINVAL;
+		}
+
+		len_read += blob_block_size;
+
+		rc = blob_handler_cb(user_data, blob_type, blob_size,
+			(uint8_t *)(blob_ptr + 1));
+		if (rc) {
+			CAM_ERR(CAM_UTIL, "Error in handling blob type %d %d",
+				blob_type, blob_size);
+			return rc;
+		}
+
+		blob_ptr += (blob_block_size / sizeof(uint32_t));
+	}
+
+	return 0;
+}
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
index 8b590a7..94d2693 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
@@ -33,6 +33,25 @@
 	uint32_t   used_bytes;
 };
 
+/* Generic Cmd Buffer blob callback function type */
+typedef int (*cam_packet_generic_blob_handler)(void *user_data,
+	uint32_t blob_type, uint32_t blob_size, uint8_t *blob_data);
+
+/**
+ * cam_packet_util_get_cmd_mem_addr()
+ *
+ * @brief                  Get command buffer address
+ *
+ * @handle:                Command buffer memory handle
+ * @buf_addr:              Command buffer cpu mapped address
+ * @len:                   Command buffer length
+ *
+ * @return:                0 for success
+ *                         -EINVAL for Fail
+ */
+int cam_packet_util_get_cmd_mem_addr(int handle, uint32_t **buf_addr,
+	size_t *len);
+
 /**
  * cam_packet_util_validate_packet()
  *
@@ -79,11 +98,33 @@
  *
  * @packet:             Input packet containing Command Buffers and Patches
  * @iommu_hdl:          IOMMU handle of the HW Device that received the packet
+ * @sec_iommu_hdl:      Secure IOMMU handle of the HW Device that
+ *                      received the packet
  *
  * @return:             0: Success
  *                      Negative: Failure
  */
 int cam_packet_util_process_patches(struct cam_packet *packet,
-	int32_t iommu_hdl);
+	int32_t iommu_hdl, int32_t sec_mmu_hdl);
+
+/**
+ * cam_packet_util_process_generic_cmd_buffer()
+ *
+ * @brief:              Process Generic Blob command buffer. This utility
+ *                      function process the command buffer and calls the
+ *                      blob_handle_cb callback for each blob that exists
+ *                      in the command buffer.
+ *
+ * @cmd_buf:            Generic Blob Cmd Buffer handle
+ * @blob_handler_cb:    Callback pointer to call for each blob exists in the
+ *                      command buffer
+ * @user_data:          User data to be passed while callback
+ *
+ * @return:             0: Success
+ *                      Negative: Failure
+ */
+int cam_packet_util_process_generic_cmd_buffer(
+	struct cam_cmd_buf_desc *cmd_buf,
+	cam_packet_generic_blob_handler blob_handler_cb, void *user_data);
 
 #endif /* _CAM_PACKET_UTIL_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.c
index e5c7dbb..743dfda 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.c
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.c
@@ -315,17 +315,14 @@
 	int num_clk_rates, num_clk_levels;
 	int i, j, rc;
 	int32_t num_clk_level_strings;
-	struct platform_device *pdev = NULL;
 	const char *src_clk_str = NULL;
 	const char *clk_cntl_lvl_string = NULL;
 	enum cam_vote_level level;
 
-	if (!soc_info || !soc_info->pdev)
+	if (!soc_info || !soc_info->dev)
 		return -EINVAL;
 
-	pdev = soc_info->pdev;
-
-	of_node = pdev->dev.of_node;
+	of_node = soc_info->dev->of_node;
 
 	count = of_property_count_strings(of_node, "clock-names");
 
@@ -563,13 +560,11 @@
 	int16_t gpio_array_size = 0;
 	struct cam_soc_gpio_data *gconf = NULL;
 	struct device_node *of_node = NULL;
-	struct platform_device *pdev = NULL;
 
-	if (!soc_info || !soc_info->pdev)
+	if (!soc_info || !soc_info->dev)
 		return -EINVAL;
 
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
+	of_node = soc_info->dev->of_node;
 
 	/* Validate input parameters */
 	if (!of_node) {
@@ -685,15 +680,13 @@
 {
 	int rc = 0, count = 0, i = 0;
 	struct device_node *of_node = NULL;
-	struct platform_device *pdev = NULL;
 
-	if (!soc_info || !soc_info->pdev) {
+	if (!soc_info || !soc_info->dev) {
 		CAM_ERR(CAM_UTIL, "Invalid parameters");
 		return -EINVAL;
 	}
 
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
+	of_node = soc_info->dev->of_node;
 
 	soc_info->num_rgltr = 0;
 	count = of_property_count_strings(of_node, "regulator-names");
@@ -758,20 +751,19 @@
 {
 	struct device_node *of_node = NULL;
 	int count = 0, i = 0, rc = 0;
-	struct platform_device *pdev = NULL;
 
-	if (!soc_info || !soc_info->pdev)
+	if (!soc_info || !soc_info->dev)
 		return -EINVAL;
 
-	pdev = soc_info->pdev;
-	of_node = pdev->dev.of_node;
+	of_node = soc_info->dev->of_node;
 
 	rc = of_property_read_u32(of_node, "cell-index", &soc_info->index);
 	if (rc) {
 		CAM_ERR(CAM_UTIL, "device %s failed to read cell-index",
-			pdev->name);
+			soc_info->dev_name);
 		return rc;
 	}
+
 	count = of_property_count_strings(of_node, "reg-names");
 	if (count <= 0) {
 		CAM_ERR(CAM_UTIL, "no reg-names found");
@@ -787,8 +779,8 @@
 			return rc;
 		}
 		soc_info->mem_block[i] =
-			platform_get_resource_byname(pdev, IORESOURCE_MEM,
-			soc_info->mem_block_name[i]);
+			platform_get_resource_byname(soc_info->pdev,
+			IORESOURCE_MEM, soc_info->mem_block_name[i]);
 
 		if (!soc_info->mem_block[i]) {
 			CAM_ERR(CAM_UTIL, "no mem resource by name %s",
@@ -813,7 +805,8 @@
 		CAM_WARN(CAM_UTIL, "No interrupt line present");
 		rc = 0;
 	} else {
-		soc_info->irq_line = platform_get_resource_byname(pdev,
+		soc_info->irq_line =
+			platform_get_resource_byname(soc_info->pdev,
 			IORESOURCE_IRQ, soc_info->irq_name);
 		if (!soc_info->irq_line) {
 			CAM_ERR(CAM_UTIL, "no irq resource");
@@ -842,17 +835,17 @@
  *
  * @brief:              Get regulator resource named vdd
  *
- * @pdev:               Platform device associated with regulator
+ * @dev:                Device associated with regulator
  * @reg:                Return pointer to be filled with regulator on success
  * @rgltr_name:         Name of regulator to get
  *
  * @return:             0 for Success, negative value for failure
  */
-static int cam_soc_util_get_regulator(struct platform_device *pdev,
+static int cam_soc_util_get_regulator(struct device *dev,
 	struct regulator **reg, const char *rgltr_name)
 {
 	int rc = 0;
-	*reg = regulator_get(&pdev->dev, rgltr_name);
+	*reg = regulator_get(dev, rgltr_name);
 	if (IS_ERR_OR_NULL(*reg)) {
 		rc = PTR_ERR(*reg);
 		rc = rc ? rc : -EINVAL;
@@ -945,7 +938,7 @@
 	struct cam_hw_soc_info *soc_info) {
 
 	struct cam_soc_pinctrl_info *device_pctrl = &soc_info->pinctrl_info;
-	struct device *dev = &soc_info->pdev->dev;
+	struct device *dev = soc_info->dev;
 
 	device_pctrl->pinctrl = devm_pinctrl_get(dev);
 	if (IS_ERR_OR_NULL(device_pctrl->pinctrl)) {
@@ -1046,23 +1039,19 @@
 	irq_handler_t handler, void *irq_data)
 {
 	int i = 0, rc = 0;
-	struct platform_device *pdev = NULL;
 
-
-	if (!soc_info || !soc_info->pdev) {
+	if (!soc_info || !soc_info->dev) {
 		CAM_ERR(CAM_UTIL, "Invalid parameters");
 		return -EINVAL;
 	}
 
-	pdev = soc_info->pdev;
-
 	for (i = 0; i < soc_info->num_mem_block; i++) {
 		if (soc_info->reserve_mem) {
 			if (!request_mem_region(soc_info->mem_block[i]->start,
 				resource_size(soc_info->mem_block[i]),
 				soc_info->mem_block_name[i])){
 				CAM_ERR(CAM_UTIL,
-					"Error Mem Region request Failed:%s",
+					"Error Mem region request Failed:%s",
 					soc_info->mem_block_name[i]);
 				rc = -ENOMEM;
 				goto unmap_base;
@@ -1089,14 +1078,15 @@
 			goto put_regulator;
 		}
 
-		rc = cam_soc_util_get_regulator(pdev, &soc_info->rgltr[i],
+		rc = cam_soc_util_get_regulator(soc_info->dev,
+			&soc_info->rgltr[i],
 			soc_info->rgltr_name[i]);
 		if (rc)
 			goto put_regulator;
 	}
 
 	if (soc_info->irq_line) {
-		rc = devm_request_irq(&pdev->dev, soc_info->irq_line->start,
+		rc = devm_request_irq(soc_info->dev, soc_info->irq_line->start,
 			handler, IRQF_TRIGGER_RISING,
 			soc_info->irq_name, irq_data);
 		if (rc) {
@@ -1110,7 +1100,7 @@
 
 	/* Get Clock */
 	for (i = 0; i < soc_info->num_clk; i++) {
-		soc_info->clk[i] = clk_get(&soc_info->pdev->dev,
+		soc_info->clk[i] = clk_get(soc_info->dev,
 			soc_info->clk_name[i]);
 		if (!soc_info->clk[i]) {
 			CAM_ERR(CAM_UTIL, "get failed for %s",
@@ -1144,7 +1134,7 @@
 
 	if (soc_info->irq_line) {
 		disable_irq(soc_info->irq_line->start);
-		devm_free_irq(&soc_info->pdev->dev,
+		devm_free_irq(soc_info->dev,
 			soc_info->irq_line->start, irq_data);
 	}
 
@@ -1177,16 +1167,12 @@
 int cam_soc_util_release_platform_resource(struct cam_hw_soc_info *soc_info)
 {
 	int i;
-	struct platform_device *pdev = NULL;
 
-	if (!soc_info || !soc_info->pdev) {
+	if (!soc_info || !soc_info->dev) {
 		CAM_ERR(CAM_UTIL, "Invalid parameter");
 		return -EINVAL;
 	}
 
-
-	pdev = soc_info->pdev;
-
 	for (i = soc_info->num_clk - 1; i >= 0; i--) {
 		clk_put(soc_info->clk[i]);
 		soc_info->clk[i] = NULL;
@@ -1207,7 +1193,7 @@
 
 	if (soc_info->irq_line) {
 		disable_irq(soc_info->irq_line->start);
-		devm_free_irq(&soc_info->pdev->dev,
+		devm_free_irq(soc_info->dev,
 			soc_info->irq_line->start, soc_info->irq_data);
 	}
 
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.h
index ae92cab..86c2737 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_soc_util.h
@@ -18,6 +18,8 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/spi/spi.h>
 #include <linux/regulator/consumer.h>
 #include <linux/clk/qcom.h>
 
@@ -113,8 +115,10 @@
  *                          Camera hardware driver module
  *
  * @pdev:                   Platform device pointer
+ * @device:                 Device pointer
  * @hw_version:             Camera device version
  * @index:                  Instance id for the camera device
+ * @dev_name:               Device Name
  * @irq_name:               Name of the irq associated with the device
  * @irq_line:               Irq resource
  * @irq_data:               Private data that is passed when IRQ is requested
@@ -147,12 +151,13 @@
  * @gpio_data:              Pointer to gpio info
  * @pinctrl_info:           Pointer to pinctrl info
  * @soc_private:            Soc private data
- *
  */
 struct cam_hw_soc_info {
 	struct platform_device         *pdev;
+	struct device                  *dev;
 	uint32_t                        hw_version;
 	uint32_t                        index;
+	const char                     *dev_name;
 	const char                     *irq_name;
 	struct resource                *irq_line;
 	void                           *irq_data;
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_trace.h b/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
index 2e9e61f..f4f85e4 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
@@ -92,15 +92,15 @@
 );
 
 TRACE_EVENT(cam_apply_req,
-	TP_PROTO(const char *entity, struct cam_req_mgr_apply_request *req),
-	TP_ARGS(entity, req),
+	TP_PROTO(const char *entity, uint64_t req_id),
+	TP_ARGS(entity, req_id),
 	TP_STRUCT__entry(
 		__string(entity, entity)
 		__field(uint64_t, req_id)
 	),
 	TP_fast_assign(
 		__assign_str(entity, entity);
-		__entry->req_id = req->request_id;
+		__entry->req_id = req_id;
 	),
 	TP_printk(
 		"%8s: ApplyRequest request=%llu",
@@ -217,6 +217,75 @@
 			__entry->devicemap, __entry->link, __entry->session
 	)
 );
+
+TRACE_EVENT(cam_submit_to_hw,
+	TP_PROTO(const char *entity, uint64_t req_id),
+	TP_ARGS(entity, req_id),
+	TP_STRUCT__entry(
+		__string(entity, entity)
+		__field(uint64_t, req_id)
+	),
+	TP_fast_assign(
+		__assign_str(entity, entity);
+		__entry->req_id = req_id;
+	),
+	TP_printk(
+		"%8s: submit request=%llu",
+			__get_str(entity), __entry->req_id
+	)
+);
+
+TRACE_EVENT(cam_irq_activated,
+	TP_PROTO(const char *entity, uint32_t irq_type),
+	TP_ARGS(entity, irq_type),
+	TP_STRUCT__entry(
+		__string(entity, entity)
+		__field(uint32_t, irq_type)
+	),
+	TP_fast_assign(
+		__assign_str(entity, entity);
+		__entry->irq_type = irq_type;
+	),
+	TP_printk(
+		"%8s: got irq type=%d",
+			__get_str(entity), __entry->irq_type
+	)
+);
+
+TRACE_EVENT(cam_irq_handled,
+	TP_PROTO(const char *entity, uint32_t irq_type),
+	TP_ARGS(entity, irq_type),
+	TP_STRUCT__entry(
+		__string(entity, entity)
+		__field(uint32_t, irq_type)
+	),
+	TP_fast_assign(
+		__assign_str(entity, entity);
+		__entry->irq_type = irq_type;
+	),
+	TP_printk(
+		"%8s: handled irq type=%d",
+			__get_str(entity), __entry->irq_type
+	)
+);
+
+TRACE_EVENT(cam_cdm_cb,
+	TP_PROTO(const char *entity, uint32_t status),
+	TP_ARGS(entity, status),
+	TP_STRUCT__entry(
+		__string(entity, entity)
+		__field(uint32_t, status)
+	),
+	TP_fast_assign(
+		__assign_str(entity, entity);
+		__entry->status = status;
+	),
+	TP_printk(
+		"%8s: cdm cb status=%d",
+			__get_str(entity), __entry->status
+	)
+);
+
 #endif /* _CAM_TRACE_H */
 
 /* This part must be outside protection */
diff --git a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c b/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
index f16c1ba..39793b6 100644
--- a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
+++ b/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
@@ -523,13 +523,17 @@
 	int level;
 	struct mpq_demux *mpq_demux = fp->private_data;
 
-	if (count >= 16)
+	if (count == 0 || count >= 16)
 		return -EINVAL;
 
-	ret_count = simple_write_to_buffer(user_str, 16, position, user_buffer,
+	memset(user_str, '\0', sizeof(user_str));
+
+	ret_count = simple_write_to_buffer(user_str, 15, position, user_buffer,
 		count);
 	if (ret_count < 0)
 		return ret_count;
+	else if (ret_count == 0)
+		return -EINVAL;
 
 	ret = kstrtoint(user_str, 0, &level);
 	if (ret)
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_base.h b/drivers/media/platform/msm/sde/rotator/sde_rotator_base.h
index b1438d5..400f53b 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_base.h
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_base.h
@@ -39,6 +39,7 @@
 #define SDE_MDP_HW_REV_300	SDE_MDP_REV(3, 0, 0)	/* 8998 v1.0 */
 #define SDE_MDP_HW_REV_301	SDE_MDP_REV(3, 0, 1)	/* 8998 v1.1 */
 #define SDE_MDP_HW_REV_400	SDE_MDP_REV(4, 0, 0)	/* sdm845 v1.0 */
+#define SDE_MDP_HW_REV_410	SDE_MDP_REV(4, 1, 0)	/* sdm670 v1.0 */
 
 #define SDE_MDP_VBIF_4_LEVEL_REMAPPER	4
 #define SDE_MDP_VBIF_8_LEVEL_REMAPPER	8
@@ -157,6 +158,7 @@
 	struct reg_bus_client *reg_bus_clt;
 	bool domain_attached;
 	int domain;
+	u32 sid;
 };
 
 /*
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c
index 0704602..a54f028 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c
@@ -45,18 +45,12 @@
 /* Rotator device id to be used in SCM call */
 #define SDE_ROTATOR_DEVICE	21
 
-#ifndef VMID_CP_CAMERA_PREVIEW
-#define VMID_CP_CAMERA_PREVIEW	VMID_INVAL
-#endif
-
-/* SCM call function id to be used for switching between secure and non
+/*
+ * SCM call function id to be used for switching between secure and non
  * secure context
  */
 #define MEM_PROTECT_SD_CTRL_SWITCH 0x18
 
-/* Rotator secure SID */
-#define SDE_ROTATOR_SECURE_SID  0xe01
-
 /* waiting for hw time out, 3 vsync for 30fps*/
 #define ROT_HW_ACQUIRE_TIMEOUT_IN_MS 100
 
@@ -71,6 +65,9 @@
 #define ROT_OVERHEAD_NUMERATOR		27
 #define ROT_OVERHEAD_DENOMINATOR	10000
 
+/* Minimum Rotator Clock value */
+#define ROT_MIN_ROT_CLK			20000000
+
 /* default minimum bandwidth vote */
 #define ROT_ENABLE_BW_VOTE		64000
 /*
@@ -601,7 +598,7 @@
 
 	if (test_bit(SDE_CAPS_SEC_ATTACH_DETACH_SMMU,
 		mdata->sde_caps_map)) {
-		sid_info = SDE_ROTATOR_SECURE_SID;
+		sid_info = mdata->sde_smmu[SDE_IOMMU_DOMAIN_ROT_SECURE].sid;
 		desc.arginfo = SCM_ARGS(4, SCM_VAL, SCM_RW, SCM_VAL, SCM_VAL);
 		desc.args[0] = SDE_ROTATOR_DEVICE;
 		desc.args[1] = SCM_BUFFER_PHYS(&sid_info);
@@ -631,9 +628,12 @@
 				return -EINVAL;
 			}
 
-			SDEROT_DBG("scm_call(1) ret=%d, resp=%x",
+			SDEROT_DBG(
+			  "scm(1) sid0x%x dev0x%llx vmid0x%llx ret%d resp%x\n",
+				sid_info, desc.args[0], desc.args[3],
 				ret, resp);
-			SDEROT_EVTLOG(1);
+			SDEROT_EVTLOG(1, sid_info, desc.args[0], desc.args[3],
+					ret, resp);
 		} else if (mdata->sec_cam_en && !enable) {
 			/*
 			 * Disable secure camera operation
@@ -648,12 +648,16 @@
 				MEM_PROTECT_SD_CTRL_SWITCH), &desc);
 			resp = desc.ret[0];
 
-			SDEROT_DBG("scm_call(0): ret=%d, resp=%x",
+			SDEROT_DBG(
+			  "scm(0) sid0x%x dev0x%llx vmid0x%llx ret%d resp%d\n",
+				sid_info, desc.args[0], desc.args[3],
 				ret, resp);
 
 			/* force smmu to reattach */
 			sde_smmu_secure_ctrl(1);
-			SDEROT_EVTLOG(0);
+
+			SDEROT_EVTLOG(0, sid_info, desc.args[0], desc.args[3],
+					ret, resp);
 		}
 	} else {
 		return 0;
@@ -1377,6 +1381,9 @@
 	if (rot_dev->min_rot_clk > perf->clk_rate)
 		perf->clk_rate = rot_dev->min_rot_clk;
 
+	if (mgr->min_rot_clk > perf->clk_rate)
+		perf->clk_rate = mgr->min_rot_clk;
+
 	read_bw =  sde_rotator_calc_buf_bw(in_fmt, config->input.width,
 				config->input.height, max_fps);
 
@@ -2382,11 +2389,15 @@
 	}
 
 	SDEROT_DBG(
-		"reconfig session id=%u in{%u,%u}f:%u out{%u,%u}f:%u fps:%d clk:%lu, bw:%llu\n",
+		"reconfig session id=%u in{%u,%u}f:%x out{%u,%u}f:%x fps:%d clk:%lu bw:%llu\n",
 		config->session_id, config->input.width, config->input.height,
 		config->input.format, config->output.width,
 		config->output.height, config->output.format,
 		config->frame_rate, perf->clk_rate, perf->bw);
+	SDEROT_EVTLOG(config->session_id, config->input.width,
+			config->input.height, config->input.format,
+			config->output.width, config->output.height,
+			config->output.format, config->frame_rate);
 done:
 	return ret;
 }
@@ -3079,8 +3090,11 @@
 	} else if (IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version,
 			SDE_MDP_HW_REV_300) ||
 		IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version,
-			SDE_MDP_HW_REV_400)) {
+			SDE_MDP_HW_REV_400) ||
+		IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version,
+			SDE_MDP_HW_REV_410)) {
 		mgr->ops_hw_init = sde_rotator_r3_init;
+		mgr->min_rot_clk = ROT_MIN_ROT_CLK;
 	} else {
 		ret = -ENODEV;
 		SDEROT_ERR("unsupported sde version %x\n",
@@ -3395,3 +3409,38 @@
 
 	return sde_rotator_config_session(mgr, private, config);
 }
+
+/*
+ * sde_rotator_session_validate - validate session
+ */
+int sde_rotator_session_validate(struct sde_rot_mgr *mgr,
+	struct sde_rot_file_private *private,
+	struct sde_rotation_config *config)
+{
+	int ret;
+
+	if (!mgr || !private || !config) {
+		SDEROT_ERR("null parameters\n");
+		return -EINVAL;
+	}
+
+	SDEROT_DBG(
+		"validate session id=%u in{%u,%u}f:%x out{%u,%u}f:%x fps:%d\n",
+		config->session_id, config->input.width, config->input.height,
+		config->input.format, config->output.width,
+		config->output.height, config->output.format,
+		config->frame_rate);
+
+	ret = sde_rotator_verify_config_all(mgr, config);
+	if (ret) {
+		SDEROT_WARN("rotator verify format failed %d\n", ret);
+		return ret;
+	}
+
+	if (config->output.sbuf && mgr->sbuf_ctx != private && mgr->sbuf_ctx) {
+		SDEROT_WARN("too many sbuf sessions\n");
+		return -EBUSY;
+	}
+
+	return 0;
+}
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.h b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.h
index eb8cb88..e2f5465 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.h
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.h
@@ -396,6 +396,7 @@
  * @pixel_per_clk: rotator hardware performance in pixel for clock
  * @fudge_factor: fudge factor for clock calculation
  * @overhead: software overhead for offline rotation in msec
+ * @min_rot_clk: minimum rotator clock rate
  * @sbuf_ctx: pointer to sbuf session context
  * @ops_xxx: function pointers of rotator HAL layer
  * @hw_data: private handle of rotator HAL layer
@@ -443,6 +444,7 @@
 	struct sde_mult_factor pixel_per_clk;
 	struct sde_mult_factor fudge_factor;
 	struct sde_mult_factor overhead;
+	unsigned long min_rot_clk;
 
 	struct sde_rot_file_private *sbuf_ctx;
 
@@ -602,6 +604,17 @@
 	struct sde_rotation_config *config);
 
 /*
+ * sde_rotator_session_validate - validate session configuration
+ * @mgr: Pointer to rotator manager
+ * @private: Pointer to per file session
+ * @config: Pointer to rotator configuration
+ * return: 0 if success; error code otherwise
+ */
+int sde_rotator_session_validate(struct sde_rot_mgr *mgr,
+	struct sde_rot_file_private *private,
+	struct sde_rotation_config *config);
+
+/*
  * sde_rotator_req_init - allocate a new request and initialzie with given
  *	array of rotation items
  * @rot_dev: Pointer to rotator device
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
index 4ad960d8..f81cd2f 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
@@ -1460,9 +1460,10 @@
 	struct sde_rotator_device *rot_dev;
 	struct sde_rotator_request *request = NULL;
 	struct sde_rot_entry_container *req = NULL;
+	struct sde_rotation_config rotcfg;
 	ktime_t *ts;
 	u32 flags = 0;
-	int i, ret;
+	int i, ret = 0;
 
 	if (!handle || !cmd) {
 		SDEROT_ERR("invalid rotator handle/cmd\n");
@@ -1478,7 +1479,7 @@
 	}
 
 	SDEROT_DBG(
-		"s:%d.%u src:(%u,%u,%u,%u)/%ux%u/%c%c%c%c dst:(%u,%u,%u,%u)/%c%c%c%c r:%d f:%d/%d s:%d fps:%u clk:%llu bw:%llu wb:%d vid:%d cmd:%d\n",
+		"s:%d.%u src:(%u,%u,%u,%u)/%ux%u/%c%c%c%c dst:(%u,%u,%u,%u)/%c%c%c%c r:%d f:%d/%d s:%d fps:%u clk:%llu bw:%llu prefill:%llu wb:%d vid:%d cmd:%d\n",
 		ctx->session_id, cmd->sequence_id,
 		cmd->src_rect_x, cmd->src_rect_y,
 		cmd->src_rect_w, cmd->src_rect_h,
@@ -1490,7 +1491,7 @@
 		cmd->dst_pixfmt >> 0, cmd->dst_pixfmt >> 8,
 		cmd->dst_pixfmt >> 16, cmd->dst_pixfmt >> 24,
 		cmd->rot90, cmd->hflip, cmd->vflip, cmd->secure, cmd->fps,
-		cmd->clkrate, cmd->data_bw,
+		cmd->clkrate, cmd->data_bw, cmd->prefill_bw,
 		cmd->dst_writeback, cmd->video_mode, cmd_type);
 	SDEROT_EVTLOG(ctx->session_id, cmd->sequence_id,
 		cmd->src_rect_x, cmd->src_rect_y,
@@ -1498,11 +1499,11 @@
 		cmd->src_pixfmt,
 		cmd->dst_rect_w, cmd->dst_rect_h,
 		cmd->dst_pixfmt,
+		cmd->fps, cmd->clkrate, cmd->data_bw, cmd->prefill_bw,
 		(cmd->rot90 << 0) | (cmd->hflip << 1) | (cmd->vflip << 2) |
 		(cmd->secure << 3) | (cmd->dst_writeback << 4) |
-		(cmd->video_mode << 5),
-		cmd->fps, cmd->clkrate, cmd->data_bw,
-		cmd_type);
+		(cmd->video_mode << 5) |
+		(cmd_type << 24));
 
 	sde_rot_mgr_lock(rot_dev->mgr);
 
@@ -1584,11 +1585,8 @@
 			ret = -ENOMEM;
 			goto error_init_request;
 		}
-	}
 
-	if (cmd_type == SDE_ROTATOR_INLINE_CMD_VALIDATE) {
-		struct sde_rotation_config rotcfg;
-
+		/* initialize session configuration */
 		memset(&rotcfg, 0, sizeof(struct sde_rotation_config));
 		rotcfg.flags = flags;
 		rotcfg.frame_rate = cmd->fps;
@@ -1606,25 +1604,16 @@
 		rotcfg.output.comp_ratio.numer = 1;
 		rotcfg.output.comp_ratio.denom = 1;
 		rotcfg.output.sbuf = true;
+	}
 
-		if (memcmp(&rotcfg, &ctx->rotcfg, sizeof(rotcfg))) {
-			ret = sde_rotator_session_config(rot_dev->mgr,
-					ctx->private, &rotcfg);
-			if (ret) {
-				SDEROT_WARN("fail session config s:%d\n",
-						ctx->session_id);
-				goto error_session_config;
-			}
+	if (cmd_type == SDE_ROTATOR_INLINE_CMD_VALIDATE) {
 
-			ctx->rotcfg = rotcfg;
-		}
-
-		ret = sde_rotator_validate_request(rot_dev->mgr, ctx->private,
-				req);
+		ret = sde_rotator_session_validate(rot_dev->mgr,
+				ctx->private, &rotcfg);
 		if (ret) {
-			SDEROT_WARN("fail validate request s:%d\n",
+			SDEROT_WARN("fail session validation s:%d\n",
 					ctx->session_id);
-			goto error_validate_request;
+			goto error_session_validate;
 		}
 
 		devm_kfree(rot_dev->dev, req);
@@ -1632,6 +1621,18 @@
 
 	} else if (cmd_type == SDE_ROTATOR_INLINE_CMD_COMMIT) {
 
+		if (memcmp(&rotcfg, &ctx->rotcfg, sizeof(rotcfg))) {
+			ret = sde_rotator_session_config(rot_dev->mgr,
+					ctx->private, &rotcfg);
+			if (ret) {
+				SDEROT_ERR("fail session config s:%d\n",
+						ctx->session_id);
+				goto error_session_config;
+			}
+
+			ctx->rotcfg = rotcfg;
+		}
+
 		request = list_first_entry_or_null(&ctx->retired_list,
 				struct sde_rotator_request, list);
 		if (!request) {
@@ -1745,7 +1746,7 @@
 	sde_rotator_update_retire_sequence(request);
 	sde_rotator_retire_request(request);
 error_retired_list:
-error_validate_request:
+error_session_validate:
 error_session_config:
 	devm_kfree(rot_dev->dev, req);
 error_invalid_handle:
@@ -2183,6 +2184,7 @@
 	if (ret < 0)
 		SDEDEV_ERR(ctx->rot_dev->dev, "fail qbuf s:%d t:%d r:%d\n",
 				ctx->session_id, buf->type, ret);
+	SDEROT_EVTLOG(buf->type, buf->bytesused, buf->length, buf->m.fd, ret);
 
 	return ret;
 }
@@ -2365,6 +2367,7 @@
 	a->pixelaspect.numerator = 1;
 	a->pixelaspect.denominator = 1;
 
+	SDEROT_EVTLOG(format->fmt.pix.width, format->fmt.pix.height, a->type);
 	return 0;
 }
 
@@ -2614,13 +2617,6 @@
 			}
 
 			/**
-			 * Loose any reference to sync fence once we pass
-			 * it to user. Driver does not clean up user
-			 * unclosed fence descriptors.
-			 */
-			vbinfo->fence = NULL;
-
-			/**
 			 * Cache fence descriptor in case user calls this
 			 * ioctl multiple times. Cached value would be stale
 			 * if user duplicated and closed old descriptor.
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_r3.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_r3.c
index 2f2a439..3206844 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_r3.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_r3.c
@@ -37,6 +37,7 @@
 #include "sde_rotator_debug.h"
 
 #define RES_UHD              (3840*2160)
+#define MS_TO_US(t) ((t) * USEC_PER_MSEC)
 
 /* traffic shaping clock ticks = finish_time x 19.2MHz */
 #define TRAFFIC_SHAPE_CLKTICK_14MS   268800
@@ -48,7 +49,7 @@
 #define XIN_WRITEBACK		1
 
 /* wait for at most 2 vsync for lowest refresh rate (24hz) */
-#define KOFF_TIMEOUT		(42 * 32)
+#define KOFF_TIMEOUT		(42 * 8)
 
 /* default stream buffer headroom in lines */
 #define DEFAULT_SBUF_HEADROOM	20
@@ -65,35 +66,54 @@
 	do { \
 		SDEROT_DBG("SDEREG.W:[%s:0x%X] <= 0x%X\n", #off, (off),\
 				(u32)(data));\
-		*p++ = REGDMA_OP_REGWRITE | \
-			((off) & REGDMA_ADDR_OFFSET_MASK); \
-		*p++ = (data); \
+		writel_relaxed_no_log( \
+				(REGDMA_OP_REGWRITE | \
+				 ((off) & REGDMA_ADDR_OFFSET_MASK)), \
+				p); \
+		p += sizeof(u32); \
+		writel_relaxed_no_log(data, p); \
+		p += sizeof(u32); \
 	} while (0)
 
 #define SDE_REGDMA_MODIFY(p, off, mask, data) \
 	do { \
 		SDEROT_DBG("SDEREG.M:[%s:0x%X] <= 0x%X\n", #off, (off),\
 				(u32)(data));\
-		*p++ = REGDMA_OP_REGMODIFY | \
-			((off) & REGDMA_ADDR_OFFSET_MASK); \
-		*p++ = (mask); \
-		*p++ = (data); \
+		writel_relaxed_no_log( \
+				(REGDMA_OP_REGMODIFY | \
+				 ((off) & REGDMA_ADDR_OFFSET_MASK)), \
+				p); \
+		p += sizeof(u32); \
+		writel_relaxed_no_log(mask, p); \
+		p += sizeof(u32); \
+		writel_relaxed_no_log(data, p); \
+		p += sizeof(u32); \
 	} while (0)
 
 #define SDE_REGDMA_BLKWRITE_INC(p, off, len) \
 	do { \
 		SDEROT_DBG("SDEREG.B:[%s:0x%X:0x%X]\n", #off, (off),\
 				(u32)(len));\
-		*p++ = REGDMA_OP_BLKWRITE_INC | \
-			((off) & REGDMA_ADDR_OFFSET_MASK); \
-		*p++ = (len); \
+		writel_relaxed_no_log( \
+				(REGDMA_OP_BLKWRITE_INC | \
+				 ((off) & REGDMA_ADDR_OFFSET_MASK)), \
+				p); \
+		p += sizeof(u32); \
+		writel_relaxed_no_log(len, p); \
+		p += sizeof(u32); \
 	} while (0)
 
 #define SDE_REGDMA_BLKWRITE_DATA(p, data) \
 	do { \
 		SDEROT_DBG("SDEREG.I:[:] <= 0x%X\n", (u32)(data));\
-		*(p) = (data); \
-		(p)++; \
+		writel_relaxed_no_log(data, p); \
+		p += sizeof(u32); \
+	} while (0)
+
+#define SDE_REGDMA_READ(p, data) \
+	do { \
+		data = readl_relaxed_no_log(p); \
+		p += sizeof(u32); \
 	} while (0)
 
 /* Macro for directly accessing mapped registers */
@@ -647,12 +667,99 @@
 }
 
 /**
+ * sde_hw_rotator_reset - Reset rotator hardware
+ * @rot: pointer to hw rotator
+ * @ctx: pointer to current rotator context during the hw hang
+ */
+static int sde_hw_rotator_reset(struct sde_hw_rotator *rot,
+		struct sde_hw_rotator_context *ctx)
+{
+	struct sde_hw_rotator_context *rctx = NULL;
+	u32 int_mask = (REGDMA_INT_0_MASK | REGDMA_INT_1_MASK |
+			REGDMA_INT_2_MASK);
+	u32 last_ts[ROT_QUEUE_MAX] = {0,};
+	u32 latest_ts;
+	int elapsed_time, t;
+	int i, j;
+	unsigned long flags;
+
+	if (!rot || !ctx) {
+		SDEROT_ERR("NULL rotator context\n");
+		return -EINVAL;
+	}
+
+	if (ctx->q_id >= ROT_QUEUE_MAX) {
+		SDEROT_ERR("context q_id out of range: %d\n", ctx->q_id);
+		return -EINVAL;
+	}
+
+	/* sw reset the hw rotator */
+	SDE_ROTREG_WRITE(rot->mdss_base, ROTTOP_SW_RESET_OVERRIDE, 1);
+	usleep_range(MS_TO_US(10), MS_TO_US(20));
+	SDE_ROTREG_WRITE(rot->mdss_base, ROTTOP_SW_RESET_OVERRIDE, 0);
+
+	spin_lock_irqsave(&rot->rotisr_lock, flags);
+
+	/* update timestamp register with current context */
+	last_ts[ctx->q_id] = ctx->timestamp;
+	sde_hw_rotator_update_swts(rot, ctx, ctx->timestamp);
+	SDEROT_EVTLOG(ctx->timestamp);
+
+	/*
+	 * Search for any pending rot session, and look for last timestamp
+	 * per hw queue.
+	 */
+	for (i = 0; i < ROT_QUEUE_MAX; i++) {
+		latest_ts = atomic_read(&rot->timestamp[i]);
+		latest_ts &= SDE_REGDMA_SWTS_MASK;
+		elapsed_time = sde_hw_rotator_elapsed_swts(latest_ts,
+			last_ts[i]);
+
+		for (j = 0; j < SDE_HW_ROT_REGDMA_TOTAL_CTX; j++) {
+			rctx = rot->rotCtx[i][j];
+			if (rctx && rctx != ctx) {
+				rctx->last_regdma_isr_status = int_mask;
+				rctx->last_regdma_timestamp  = rctx->timestamp;
+
+				t = sde_hw_rotator_elapsed_swts(latest_ts,
+							rctx->timestamp);
+				if (t < elapsed_time) {
+					elapsed_time = t;
+					last_ts[i] = rctx->timestamp;
+					sde_hw_rotator_update_swts(rot, rctx,
+							last_ts[i]);
+				}
+
+				SDEROT_DBG("rotctx[%d][%d], ts:%d\n",
+						i, j, rctx->timestamp);
+				SDEROT_EVTLOG(i, j, rctx->timestamp,
+						last_ts[i]);
+			}
+		}
+	}
+
+	/* Finally wakeup all pending rotator context in queue */
+	for (i = 0; i < ROT_QUEUE_MAX; i++) {
+		for (j = 0; j < SDE_HW_ROT_REGDMA_TOTAL_CTX; j++) {
+			rctx = rot->rotCtx[i][j];
+			if (rctx && rctx != ctx)
+				wake_up_all(&rctx->regdma_waitq);
+		}
+	}
+
+	spin_unlock_irqrestore(&rot->rotisr_lock, flags);
+
+	return 0;
+}
+
+/**
  * sde_hw_rotator_dump_status - Dump hw rotator status on error
  * @rot: Pointer to hw rotator
  */
-static void sde_hw_rotator_dump_status(struct sde_hw_rotator *rot)
+static void sde_hw_rotator_dump_status(struct sde_hw_rotator *rot, u32 *ubwcerr)
 {
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
+	u32 reg = 0;
 
 	SDEROT_ERR(
 		"op_mode = %x, int_en = %x, int_status = %x\n",
@@ -681,9 +788,11 @@
 		SDE_ROTREG_READ(rot->mdss_base,
 			REGDMA_CSR_REGDMA_FSM_STATE));
 
+	reg = SDE_ROTREG_READ(rot->mdss_base, ROT_SSPP_UBWC_ERROR_STATUS);
+	if (ubwcerr)
+		*ubwcerr = reg;
 	SDEROT_ERR(
-		"UBWC decode status = %x, UBWC encode status = %x\n",
-		SDE_ROTREG_READ(rot->mdss_base, ROT_SSPP_UBWC_ERROR_STATUS),
+		"UBWC decode status = %x, UBWC encode status = %x\n", reg,
 		SDE_ROTREG_READ(rot->mdss_base, ROT_WB_UBWC_ERROR_STATUS));
 
 	SDEROT_ERR("VBIF XIN HALT status = %x VBIF AXI HALT status = %x\n",
@@ -851,7 +960,7 @@
 static void sde_hw_rotator_setup_timestamp_packet(
 		struct sde_hw_rotator_context *ctx, u32 mask, u32 swts)
 {
-	u32 *wrptr;
+	char __iomem *wrptr;
 
 	wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
@@ -908,7 +1017,7 @@
 		struct sde_rot_cdp_params *params)
 {
 	int reg_val;
-	u32 *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
+	char __iomem *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
 	if (!params->enable) {
 		SDE_REGDMA_WRITE(wrptr, params->offset, 0x0);
@@ -942,7 +1051,7 @@
 static void sde_hw_rotator_setup_qos_lut_wr(struct sde_hw_rotator_context *ctx)
 {
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
-	u32 *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
+	char __iomem *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
 	/* Offline rotation setting */
 	if (!ctx->sbuf_mode) {
@@ -1000,7 +1109,7 @@
 static void sde_hw_rotator_setup_qos_lut_rd(struct sde_hw_rotator_context *ctx)
 {
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
-	u32 *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
+	char __iomem *wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
 	/* Offline rotation setting */
 	if (!ctx->sbuf_mode) {
@@ -1070,7 +1179,7 @@
 	struct sde_mdp_data *data;
 	struct sde_rot_cdp_params cdp_params = {0};
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
-	u32 *wrptr;
+	char __iomem *wrptr;
 	u32 opmode = 0;
 	u32 chroma_samp = 0;
 	u32 src_format = 0;
@@ -1081,8 +1190,10 @@
 	int i;
 
 	if (ctx->rot->mode == ROT_REGDMA_ON) {
-		SDE_ROTREG_WRITE(rot->mdss_base, REGDMA_CSR_REGDMA_INT_EN,
-				REGDMA_INT_MASK);
+		if (rot->irq_num >= 0)
+			SDE_ROTREG_WRITE(rot->mdss_base,
+					REGDMA_CSR_REGDMA_INT_EN,
+					REGDMA_INT_MASK);
 		SDE_ROTREG_WRITE(rot->mdss_base, REGDMA_CSR_REGDMA_OP_MODE,
 				REGDMA_EN);
 	}
@@ -1289,7 +1400,7 @@
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
 	struct sde_mdp_format_params *fmt;
 	struct sde_rot_cdp_params cdp_params = {0};
-	u32 *wrptr;
+	char __iomem *wrptr;
 	u32 pack = 0;
 	u32 dst_format = 0;
 	u32 no_partial_writes = 0;
@@ -1435,8 +1546,7 @@
 	wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
 	/* setup traffic shaper for 4k 30fps content or if prefill_bw is set */
-	if (!ctx->sbuf_mode &&
-			(ctx->is_traffic_shaping || cfg->prefill_bw)) {
+	if (ctx->is_traffic_shaping || cfg->prefill_bw) {
 		u32 bw;
 
 		/*
@@ -1487,13 +1597,18 @@
 		enum sde_rot_queue_prio queue_id)
 {
 	struct sde_hw_rotator *rot = ctx->rot;
-	u32 *wrptr;
-	u32 *rdptr;
-	u8 *addr;
+	char __iomem *wrptr;
+	char __iomem *mem_rdptr;
+	char __iomem *addr;
 	u32 mask;
+	u32 cmd0, cmd1, cmd2;
 	u32 blksize;
 
-	rdptr = sde_hw_rotator_get_regdma_segment_base(ctx);
+	/*
+	 * when regdma is not using, the regdma segment is just a normal
+	 * DRAM, and not an iomem.
+	 */
+	mem_rdptr = sde_hw_rotator_get_regdma_segment_base(ctx);
 	wrptr = sde_hw_rotator_get_regdma_segment(ctx);
 
 	if (rot->irq_num >= 0) {
@@ -1511,54 +1626,65 @@
 	SDEROT_DBG("BEGIN %d\n", ctx->timestamp);
 	/* Write all command stream to Rotator blocks */
 	/* Rotator will start right away after command stream finish writing */
-	while (rdptr < wrptr) {
-		u32 op = REGDMA_OP_MASK & *rdptr;
+	while (mem_rdptr < wrptr) {
+		u32 op = REGDMA_OP_MASK & readl_relaxed_no_log(mem_rdptr);
 
 		switch (op) {
 		case REGDMA_OP_NOP:
 			SDEROT_DBG("NOP\n");
-			rdptr++;
+			mem_rdptr += sizeof(u32);
 			break;
 		case REGDMA_OP_REGWRITE:
+			SDE_REGDMA_READ(mem_rdptr, cmd0);
+			SDE_REGDMA_READ(mem_rdptr, cmd1);
 			SDEROT_DBG("REGW %6.6x %8.8x\n",
-					rdptr[0] & REGDMA_ADDR_OFFSET_MASK,
-					rdptr[1]);
+					cmd0 & REGDMA_ADDR_OFFSET_MASK,
+					cmd1);
 			addr =  rot->mdss_base +
-				(*rdptr++ & REGDMA_ADDR_OFFSET_MASK);
-			writel_relaxed(*rdptr++, addr);
+				(cmd0 & REGDMA_ADDR_OFFSET_MASK);
+			writel_relaxed(cmd1, addr);
 			break;
 		case REGDMA_OP_REGMODIFY:
+			SDE_REGDMA_READ(mem_rdptr, cmd0);
+			SDE_REGDMA_READ(mem_rdptr, cmd1);
+			SDE_REGDMA_READ(mem_rdptr, cmd2);
 			SDEROT_DBG("REGM %6.6x %8.8x %8.8x\n",
-					rdptr[0] & REGDMA_ADDR_OFFSET_MASK,
-					rdptr[1], rdptr[2]);
+					cmd0 & REGDMA_ADDR_OFFSET_MASK,
+					cmd1, cmd2);
 			addr =  rot->mdss_base +
-				(*rdptr++ & REGDMA_ADDR_OFFSET_MASK);
-			mask = *rdptr++;
-			writel_relaxed((readl_relaxed(addr) & mask) | *rdptr++,
+				(cmd0 & REGDMA_ADDR_OFFSET_MASK);
+			mask = cmd1;
+			writel_relaxed((readl_relaxed(addr) & mask) | cmd2,
 					addr);
 			break;
 		case REGDMA_OP_BLKWRITE_SINGLE:
+			SDE_REGDMA_READ(mem_rdptr, cmd0);
+			SDE_REGDMA_READ(mem_rdptr, cmd1);
 			SDEROT_DBG("BLKWS %6.6x %6.6x\n",
-					rdptr[0] & REGDMA_ADDR_OFFSET_MASK,
-					rdptr[1]);
+					cmd0 & REGDMA_ADDR_OFFSET_MASK,
+					cmd1);
 			addr =  rot->mdss_base +
-				(*rdptr++ & REGDMA_ADDR_OFFSET_MASK);
-			blksize = *rdptr++;
+				(cmd0 & REGDMA_ADDR_OFFSET_MASK);
+			blksize = cmd1;
 			while (blksize--) {
-				SDEROT_DBG("DATA %8.8x\n", rdptr[0]);
-				writel_relaxed(*rdptr++, addr);
+				SDE_REGDMA_READ(mem_rdptr, cmd0);
+				SDEROT_DBG("DATA %8.8x\n", cmd0);
+				writel_relaxed(cmd0, addr);
 			}
 			break;
 		case REGDMA_OP_BLKWRITE_INC:
+			SDE_REGDMA_READ(mem_rdptr, cmd0);
+			SDE_REGDMA_READ(mem_rdptr, cmd1);
 			SDEROT_DBG("BLKWI %6.6x %6.6x\n",
-					rdptr[0] & REGDMA_ADDR_OFFSET_MASK,
-					rdptr[1]);
+					cmd0 & REGDMA_ADDR_OFFSET_MASK,
+					cmd1);
 			addr =  rot->mdss_base +
-				(*rdptr++ & REGDMA_ADDR_OFFSET_MASK);
-			blksize = *rdptr++;
+				(cmd0 & REGDMA_ADDR_OFFSET_MASK);
+			blksize = cmd1;
 			while (blksize--) {
-				SDEROT_DBG("DATA %8.8x\n", rdptr[0]);
-				writel_relaxed(*rdptr++, addr);
+				SDE_REGDMA_READ(mem_rdptr, cmd0);
+				SDEROT_DBG("DATA %8.8x\n", cmd0);
+				writel_relaxed(cmd0, addr);
 				addr += 4;
 			}
 			break;
@@ -1567,7 +1693,7 @@
 			 * Skip data for now for unregonized OP mode
 			 */
 			SDEROT_DBG("UNDEFINED\n");
-			rdptr++;
+			mem_rdptr += sizeof(u32);
 			break;
 		}
 	}
@@ -1585,11 +1711,11 @@
 		enum sde_rot_queue_prio queue_id)
 {
 	struct sde_hw_rotator *rot = ctx->rot;
-	u32 *wrptr;
+	char __iomem *wrptr;
 	u32  regdmaSlot;
 	u32  offset;
-	long length;
-	long ts_length;
+	u32  length;
+	u32  ts_length;
 	u32  enableInt;
 	u32  swts = 0;
 	u32  mask = 0;
@@ -1608,15 +1734,15 @@
 	 * Start REGDMA with command offset and size
 	 */
 	regdmaSlot = sde_hw_rotator_get_regdma_ctxidx(ctx);
-	length = ((long)wrptr - (long)ctx->regdma_base) / 4;
-	offset = (u32)(ctx->regdma_base - (u32 *)(rot->mdss_base +
-				REGDMA_RAM_REGDMA_CMD_RAM));
+	length = (wrptr - ctx->regdma_base) / 4;
+	offset = (ctx->regdma_base - (rot->mdss_base +
+				REGDMA_RAM_REGDMA_CMD_RAM)) / sizeof(u32);
 	enableInt = ((ctx->timestamp & 1) + 1) << 30;
 	trig_sel = ctx->sbuf_mode ? REGDMA_CMD_TRIG_SEL_MDP_FLUSH :
 			REGDMA_CMD_TRIG_SEL_SW_START;
 
 	SDEROT_DBG(
-		"regdma(%d)[%d] <== INT:0x%X|length:%ld|offset:0x%X, ts:%X\n",
+		"regdma(%d)[%d] <== INT:0x%X|length:%d|offset:0x%X, ts:%X\n",
 		queue_id, regdmaSlot, enableInt, length, offset,
 		ctx->timestamp);
 
@@ -1646,6 +1772,7 @@
 		sde_hw_rotator_setup_timestamp_packet(ctx, mask, swts);
 		offset += length;
 		ts_length = sde_hw_rotator_get_regdma_segment(ctx) - wrptr;
+		ts_length /= sizeof(u32);
 		WARN_ON((length + ts_length) > SDE_HW_ROT_REGDMA_SEG_SIZE);
 
 		/* ensure command packet is issue before the submit command */
@@ -1751,6 +1878,7 @@
 	u32 int_id;
 	u32 swts;
 	u32 sts = 0;
+	u32 ubwcerr = 0;
 	unsigned long flags;
 
 	if (rot->irq_num >= 0) {
@@ -1787,8 +1915,26 @@
 			else if (status & REGDMA_INVALID_CMD)
 				SDEROT_ERR("REGDMA invalid command\n");
 
-			sde_hw_rotator_dump_status(rot);
-			status = ROT_ERROR_BIT;
+			sde_hw_rotator_dump_status(rot, &ubwcerr);
+
+			if (ubwcerr) {
+				/*
+				 * Perform recovery for ROT SSPP UBWC decode
+				 * error.
+				 * - SW reset rotator hw block
+				 * - reset TS logic so all pending rotation
+				 *   in hw queue got done signalled
+				 */
+				spin_unlock_irqrestore(&rot->rotisr_lock,
+						flags);
+				if (!sde_hw_rotator_reset(rot, ctx))
+					status = REGDMA_INCOMPLETE_CMD;
+				else
+					status = ROT_ERROR_BIT;
+				spin_lock_irqsave(&rot->rotisr_lock, flags);
+			} else {
+				status = ROT_ERROR_BIT;
+			}
 		} else {
 			if (rc == 1)
 				SDEROT_WARN(
@@ -1814,12 +1960,12 @@
 		if (last_isr & REGDMA_INT_ERR_MASK) {
 			SDEROT_ERR("Rotator error, ts:0x%X/0x%X status:%x\n",
 				ctx->timestamp, swts, last_isr);
-			sde_hw_rotator_dump_status(rot);
+			sde_hw_rotator_dump_status(rot, NULL);
 			status = ROT_ERROR_BIT;
 		} else if (pending) {
 			SDEROT_ERR("Rotator timeout, ts:0x%X/0x%X status:%x\n",
 				ctx->timestamp, swts, last_isr);
-			sde_hw_rotator_dump_status(rot);
+			sde_hw_rotator_dump_status(rot, NULL);
 			status = ROT_ERROR_BIT;
 		} else {
 			status = 0;
@@ -1829,7 +1975,7 @@
 				last_isr);
 	}
 
-	sts = (status & ROT_ERROR_BIT) ? -ENODEV : 0;
+	sts = (status & (ROT_ERROR_BIT | REGDMA_INCOMPLETE_CMD)) ? -ENODEV : 0;
 
 	if (status & ROT_ERROR_BIT)
 		SDEROT_EVTLOG_TOUT_HANDLER("rot", "rot_dbg_bus",
@@ -2322,7 +2468,7 @@
 				if (status & BIT(0)) {
 					SDEROT_ERR("rotator busy 0x%x\n",
 							status);
-					sde_hw_rotator_dump_status(rot);
+					sde_hw_rotator_dump_status(rot, NULL);
 					SDEROT_EVTLOG_TOUT_HANDLER("rot",
 							"vbif_dbg_bus",
 							"panic");
@@ -2698,7 +2844,9 @@
 	SDE_ROTREG_WRITE(rot->mdss_base, REGDMA_TIMESTAMP_REG, 0);
 
 	/* features exposed via mdss h/w version */
-	if (IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version, SDE_MDP_HW_REV_400)) {
+	if (IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version, SDE_MDP_HW_REV_400) ||
+		IS_SDE_MAJOR_MINOR_SAME(mdata->mdss_version,
+			SDE_MDP_HW_REV_410)) {
 		SDEROT_DBG("Supporting sys cache inline rotation\n");
 		set_bit(SDE_CAPS_SBUF_1,  mdata->sde_caps_map);
 		set_bit(SDE_CAPS_UBWC_2,  mdata->sde_caps_map);
@@ -3432,21 +3580,22 @@
 	/* REGDMA initialization */
 	if (rot->mode == ROT_REGDMA_OFF) {
 		for (i = 0; i < SDE_HW_ROT_REGDMA_TOTAL_CTX; i++)
-			rot->cmd_wr_ptr[0][i] = &rot->cmd_queue[
-				SDE_HW_ROT_REGDMA_SEG_SIZE * i];
+			rot->cmd_wr_ptr[0][i] = (char __iomem *)(
+					&rot->cmd_queue[
+					SDE_HW_ROT_REGDMA_SEG_SIZE * i]);
 	} else {
 		for (i = 0; i < SDE_HW_ROT_REGDMA_TOTAL_CTX; i++)
 			rot->cmd_wr_ptr[ROT_QUEUE_HIGH_PRIORITY][i] =
-				(u32 *)(rot->mdss_base +
+				rot->mdss_base +
 					REGDMA_RAM_REGDMA_CMD_RAM +
-					SDE_HW_ROT_REGDMA_SEG_SIZE * 4 * i);
+					SDE_HW_ROT_REGDMA_SEG_SIZE * 4 * i;
 
 		for (i = 0; i < SDE_HW_ROT_REGDMA_TOTAL_CTX; i++)
 			rot->cmd_wr_ptr[ROT_QUEUE_LOW_PRIORITY][i] =
-				(u32 *)(rot->mdss_base +
+				rot->mdss_base +
 					REGDMA_RAM_REGDMA_CMD_RAM +
 					SDE_HW_ROT_REGDMA_SEG_SIZE * 4 *
-					(i + SDE_HW_ROT_REGDMA_TOTAL_CTX));
+					(i + SDE_HW_ROT_REGDMA_TOTAL_CTX);
 	}
 
 	for (i = 0; i < ROT_QUEUE_MAX; i++) {
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_r3_internal.h b/drivers/media/platform/msm/sde/rotator/sde_rotator_r3_internal.h
index 4c1316c..8b391ea 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_r3_internal.h
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_r3_internal.h
@@ -218,8 +218,8 @@
 	enum   sde_rot_queue_prio q_id;
 	u32    session_id;
 	u32    sequence_id;
-	u32    *regdma_base;
-	u32    *regdma_wrptr;
+	char __iomem *regdma_base;
+	char __iomem *regdma_wrptr;
 	u32    timestamp;
 	struct completion rot_comp;
 	wait_queue_head_t regdma_waitq;
@@ -280,7 +280,7 @@
 	u32    cmd_queue[SDE_HW_ROT_REGDMA_RAM_SIZE];
 
 	/* Cmd Queue Write Ptr */
-	u32   *cmd_wr_ptr[ROT_QUEUE_MAX][SDE_HW_ROT_REGDMA_TOTAL_CTX];
+	char __iomem *cmd_wr_ptr[ROT_QUEUE_MAX][SDE_HW_ROT_REGDMA_TOTAL_CTX];
 
 	/* Rotator Context */
 	struct sde_hw_rotator_context
@@ -349,7 +349,7 @@
  * @ctx: Rotator Context
  * return: base segment address
  */
-static inline u32 *sde_hw_rotator_get_regdma_segment_base(
+static inline char __iomem *sde_hw_rotator_get_regdma_segment_base(
 		struct sde_hw_rotator_context *ctx)
 {
 	SDEROT_DBG("regdma base @slot[%d]: %p\n",
@@ -365,11 +365,11 @@
  * @ctx: Rotator Context
  * return: segment address
  */
-static inline u32 *sde_hw_rotator_get_regdma_segment(
+static inline char __iomem *sde_hw_rotator_get_regdma_segment(
 		struct sde_hw_rotator_context *ctx)
 {
 	u32 idx = sde_hw_rotator_get_regdma_ctxidx(ctx);
-	u32 *addr = ctx->regdma_wrptr;
+	char __iomem *addr = ctx->regdma_wrptr;
 
 	SDEROT_DBG("regdma slot[%d] ==> %p\n", idx, addr);
 	return addr;
@@ -383,7 +383,7 @@
  */
 static inline void sde_hw_rotator_put_regdma_segment(
 		struct sde_hw_rotator_context *ctx,
-		u32 *wrptr)
+		char __iomem *wrptr)
 {
 	u32 idx = sde_hw_rotator_get_regdma_ctxidx(ctx);
 
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c
index 9e47187..cc1407a 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c
@@ -517,6 +517,7 @@
 	const struct of_device_id *match;
 	struct sde_module_power *mp;
 	char name[MAX_CLIENT_NAME_LEN];
+	u32 sid = 0;
 
 	if (!mdata) {
 		SDEROT_INFO(
@@ -538,6 +539,11 @@
 
 	if (of_find_property(pdev->dev.of_node, "iommus", NULL)) {
 		dev = &pdev->dev;
+		rc = of_property_read_u32_index(pdev->dev.of_node, "iommus",
+			1, &sid);
+		if (rc)
+			SDEROT_DBG("SID not defined for domain:%d",
+					smmu_domain.domain);
 	} else {
 		SDEROT_ERR("Invalid SMMU ctx for domain:%d\n",
 				smmu_domain.domain);
@@ -546,6 +552,7 @@
 
 	sde_smmu = &mdata->sde_smmu[smmu_domain.domain];
 	sde_smmu->domain = smmu_domain.domain;
+	sde_smmu->sid = sid;
 	mp = &sde_smmu->mp;
 	memset(mp, 0, sizeof(struct sde_module_power));
 
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_util.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_util.c
index 9ef4282..ac4ab54 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_util.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_util.c
@@ -35,6 +35,7 @@
 
 #include "sde_rotator_util.h"
 #include "sde_rotator_smmu.h"
+#include "sde_rotator_debug.h"
 
 #define Y_TILEWIDTH     48
 #define Y_TILEHEIGHT    4
@@ -1038,6 +1039,8 @@
 			break;
 		}
 	}
+	SDEROT_EVTLOG(data->num_planes, dir, data->p[0].addr, data->p[0].len,
+			data->p[0].mapped);
 
 	return rc;
 }
diff --git a/drivers/media/platform/msm/vidc/hfi_packetization.c b/drivers/media/platform/msm/vidc/hfi_packetization.c
index 85db6f0..cf0413e 100644
--- a/drivers/media/platform/msm/vidc/hfi_packetization.c
+++ b/drivers/media/platform/msm/vidc/hfi_packetization.c
@@ -58,6 +58,8 @@
 	[ilog2(HAL_COLOR_FORMAT_NV12_UBWC)] =  HFI_COLOR_FORMAT_NV12_UBWC,
 	[ilog2(HAL_COLOR_FORMAT_NV12_TP10_UBWC)] =
 			HFI_COLOR_FORMAT_YUV420_TP10_UBWC,
+	/*P010 10bit format*/
+	[ilog2(HAL_COLOR_FORMAT_P010)] =  HFI_COLOR_FORMAT_P010,
 };
 
 static int nal_type[] = {
@@ -664,6 +666,26 @@
 	return ltrmode;
 }
 
+static u32 get_hfi_work_mode(enum hal_work_mode work_mode)
+{
+	u32 hfi_work_mode;
+
+	switch (work_mode) {
+	case VIDC_WORK_MODE_1:
+		hfi_work_mode = HFI_WORKMODE_1;
+		break;
+	case VIDC_WORK_MODE_2:
+		hfi_work_mode = HFI_WORKMODE_2;
+		break;
+	default:
+		dprintk(VIDC_ERR, "Invalid work mode: %#x\n",
+			work_mode);
+		hfi_work_mode = HFI_WORKMODE_2;
+		break;
+	}
+	return hfi_work_mode;
+}
+
 int create_pkt_cmd_session_set_buffers(
 		struct hfi_cmd_session_set_buffers_packet *pkt,
 		struct hal_session *session,
@@ -1398,6 +1420,9 @@
 		case HAL_FLIP_VERTICAL:
 			hfi->flip = HFI_FLIP_VERTICAL;
 			break;
+		case HAL_FLIP_BOTH:
+			hfi->flip = HFI_FLIP_HORIZONTAL | HFI_FLIP_VERTICAL;
+			break;
 		default:
 			dprintk(VIDC_ERR, "Invalid flip setting: %#x\n",
 				prop->flip);
@@ -1844,7 +1869,8 @@
 			(struct hfi_video_work_mode *)
 			&pkt->rg_property_data[1];
 
-		work_mode->video_work_mode = hal->video_work_mode;
+		work_mode->video_work_mode = get_hfi_work_mode(
+						hal->video_work_mode);
 
 		pkt->rg_property_data[0] =
 			HFI_PROPERTY_PARAM_WORK_MODE;
diff --git a/drivers/media/platform/msm/vidc/msm_smem.c b/drivers/media/platform/msm/vidc/msm_smem.c
index 9b23376..5198bc3 100644
--- a/drivers/media/platform/msm/vidc/msm_smem.c
+++ b/drivers/media/platform/msm/vidc/msm_smem.c
@@ -80,6 +80,8 @@
 			dprintk(VIDC_ERR,
 				"Size mismatch! Dmabuf size: %zu Expected Size: %lu",
 				buf->size, *buffer_size);
+			msm_vidc_res_handle_fatal_hw_error(smem_client->res,
+					true);
 			goto mem_buf_size_mismatch;
 		}
 		/* Prepare a dma buf for dma on the given device */
@@ -327,6 +329,7 @@
 	if (ion_flags & ION_FLAG_SECURE)
 		smem->flags |= SMEM_SECURE;
 
+	buffer_size = smem->size;
 	rc = msm_ion_get_device_address(inst->mem_client, ion_handle,
 			align, &iova, &buffer_size, smem->flags,
 			smem->buffer_type, &smem->mapping_info);
@@ -603,22 +606,25 @@
 		__func__, mem->handle, mem->device_addr, mem->size,
 		mem->kvaddr, mem->buffer_type);
 
-	if (mem->device_addr)
+	if (mem->device_addr) {
 		msm_ion_put_device_address(client, mem->handle, mem->flags,
 			&mem->mapping_info, mem->buffer_type);
+		mem->device_addr = 0x0;
+	}
 
-	if (mem->kvaddr)
+	if (mem->kvaddr) {
 		ion_unmap_kernel(client->clnt, mem->handle);
+		mem->kvaddr = NULL;
+	}
 
 	if (mem->handle) {
 		trace_msm_smem_buffer_ion_op_start("FREE",
 				(u32)mem->buffer_type, -1, mem->size, -1,
 				mem->flags, -1);
 		ion_free(client->clnt, mem->handle);
+		mem->handle = NULL;
 		trace_msm_smem_buffer_ion_op_end("FREE", (u32)mem->buffer_type,
 			-1, mem->size, -1, mem->flags, -1);
-	} else {
-		dprintk(VIDC_ERR, "%s: invalid ion_handle\n", __func__);
 	}
 
 	return rc;
diff --git a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
index 4b16af6..fa40091 100644
--- a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
@@ -448,14 +448,14 @@
 static DEVICE_ATTR(thermal_level, 0644, show_thermal_level,
 		store_thermal_level);
 
-static ssize_t show_platform_version(struct device *dev,
+static ssize_t show_sku_version(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	return scnprintf(buf, PAGE_SIZE, "%d",
-			vidc_driver->platform_version);
+			vidc_driver->sku_version);
 }
 
-static ssize_t store_platform_version(struct device *dev,
+static ssize_t store_sku_version(struct device *dev,
 		struct device_attribute *attr, const char *buf,
 		size_t count)
 {
@@ -463,13 +463,13 @@
 	return count;
 }
 
-static DEVICE_ATTR(platform_version, 0444, show_platform_version,
-		store_platform_version);
+static DEVICE_ATTR(sku_version, 0444, show_sku_version,
+		store_sku_version);
 
 static struct attribute *msm_vidc_core_attrs[] = {
 		&dev_attr_pwr_collapse_delay.attr,
 		&dev_attr_thermal_level.attr,
-		&dev_attr_platform_version.attr,
+		&dev_attr_sku_version.attr,
 		NULL
 };
 
@@ -487,8 +487,6 @@
 static int msm_vidc_probe_vidc_device(struct platform_device *pdev)
 {
 	int rc = 0;
-	void __iomem *base;
-	struct resource *res;
 	struct msm_vidc_core *core;
 	struct device *dev;
 	int nr = BASE_DEVICE_NUMBER;
@@ -605,32 +603,7 @@
 	core->debugfs_root = msm_vidc_debugfs_init_core(
 		core, vidc_driver->debugfs_root);
 
-	vidc_driver->platform_version = 0;
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "efuse");
-	if (!res) {
-		dprintk(VIDC_DBG, "failed to get efuse resource\n");
-	} else {
-		base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-		if (!base) {
-			dprintk(VIDC_ERR,
-				"failed efuse ioremap: res->start %#x, size %d\n",
-				(u32)res->start, (u32)resource_size(res));
-		} else {
-			u32 efuse = 0;
-			struct platform_version_table *pf_ver_tbl =
-				core->resources.pf_ver_tbl;
-
-			efuse = readl_relaxed(base);
-			vidc_driver->platform_version =
-				(efuse & pf_ver_tbl->version_mask) >>
-				pf_ver_tbl->version_shift;
-			dprintk(VIDC_DBG,
-				"efuse 0x%x, platform version 0x%x\n",
-				efuse, vidc_driver->platform_version);
-
-			devm_iounmap(&pdev->dev, base);
-		}
-	}
+	vidc_driver->sku_version = core->resources.sku_version;
 
 	dprintk(VIDC_DBG, "populating sub devices\n");
 	/*
@@ -816,7 +789,6 @@
 	if (rc) {
 		dprintk(VIDC_ERR,
 			"Failed to register platform driver\n");
-		msm_vidc_debugfs_deinit_drv();
 		debugfs_remove_recursive(vidc_driver->debugfs_root);
 		kfree(vidc_driver);
 		vidc_driver = NULL;
@@ -828,7 +800,6 @@
 static void __exit msm_vidc_exit(void)
 {
 	platform_driver_unregister(&msm_vidc_driver);
-	msm_vidc_debugfs_deinit_drv();
 	debugfs_remove_recursive(vidc_driver->debugfs_root);
 	mutex_destroy(&vidc_driver->lock);
 	kfree(vidc_driver);
diff --git a/drivers/media/platform/msm/vidc/msm_vdec.c b/drivers/media/platform/msm/vidc/msm_vdec.c
index aa20a07..286a67e 100644
--- a/drivers/media/platform/msm/vidc/msm_vdec.c
+++ b/drivers/media/platform/msm/vidc/msm_vdec.c
@@ -413,7 +413,16 @@
 		.minimum = 0,
 		.maximum = INT_MAX,
 		.default_value = 0,
-		.step = OPERATING_FRAME_RATE_STEP,
+		.step = 1,
+	},
+	{
+		.id = V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE,
+		.name = "Set Decoder Frame rate",
+		.type = V4L2_CTRL_TYPE_INTEGER,
+		.minimum = 0,
+		.maximum = INT_MAX,
+		.default_value = 0,
+		.step = 1,
 	},
 	{
 		.id = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE,
@@ -480,6 +489,13 @@
 		.type = CAPTURE_PORT,
 	},
 	{
+		.name = "YCbCr Semiplanar 4:2:0 10bit",
+		.description = "Y/CbCr 4:2:0 10bit",
+		.fourcc = V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010,
+		.get_frame_size = get_frame_size_p010,
+		.type = CAPTURE_PORT,
+	},
+	{
 		.name = "UBWC YCbCr Semiplanar 4:2:0",
 		.description = "UBWC Y/CbCr 4:2:0",
 		.fourcc = V4L2_PIX_FMT_NV12_UBWC,
@@ -521,7 +537,7 @@
 		.name = "VP8",
 		.description = "VP8 compressed format",
 		.fourcc = V4L2_PIX_FMT_VP8,
-		.get_frame_size = get_frame_size_compressed,
+		.get_frame_size = get_frame_size_compressed_full_yuv,
 		.type = OUTPUT_PORT,
 		.defer_outputs = false,
 	},
@@ -574,6 +590,13 @@
 
 		inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width;
 		inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height;
+		rc = msm_vidc_check_session_supported(inst);
+		if (rc) {
+			dprintk(VIDC_ERR,
+				"%s: session not supported\n", __func__);
+			goto err_invalid_fmt;
+		}
+
 		msm_comm_set_color_format(inst,
 				msm_comm_get_hal_output_buffer(inst),
 				f->fmt.pix_mp.pixelformat);
@@ -641,6 +664,12 @@
 		}
 		inst->prop.width[OUTPUT_PORT] = f->fmt.pix_mp.width;
 		inst->prop.height[OUTPUT_PORT] = f->fmt.pix_mp.height;
+		rc = msm_vidc_check_session_supported(inst);
+		if (rc) {
+			dprintk(VIDC_ERR,
+				"%s: session not supported\n", __func__);
+			goto err_invalid_fmt;
+		}
 
 		frame_sz.buffer_type = HAL_BUFFER_INPUT;
 		frame_sz.width = inst->prop.width[OUTPUT_PORT];
@@ -1107,11 +1136,27 @@
 		}
 		break;
 	case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE:
-		dprintk(VIDC_DBG,
-			"inst(%pK) operating rate changed from %d to %d\n",
-			inst, inst->clk_data.operating_rate >> 16,
-				ctrl->val >> 16);
-		inst->clk_data.operating_rate = ctrl->val;
+		if (((ctrl->val >> 16) < inst->capability.frame_rate.min ||
+			(ctrl->val >> 16) > inst->capability.frame_rate.max) &&
+			ctrl->val != INT_MAX) {
+			dprintk(VIDC_ERR, "Invalid operating rate %u\n",
+				(ctrl->val >> 16));
+			rc = -ENOTSUPP;
+		} else if (ctrl->val == INT_MAX) {
+			dprintk(VIDC_DBG,
+				"inst(%pK) Request for turbo mode\n", inst);
+			inst->clk_data.turbo_mode = true;
+		} else if (msm_vidc_validate_operating_rate(inst, ctrl->val)) {
+			dprintk(VIDC_ERR, "Failed to set operating rate\n");
+			rc = -ENOTSUPP;
+		} else {
+			dprintk(VIDC_DBG,
+				"inst(%pK) operating rate changed from %d to %d\n",
+				inst, inst->clk_data.operating_rate >> 16,
+					ctrl->val >> 16);
+			inst->clk_data.operating_rate = ctrl->val;
+			inst->clk_data.turbo_mode = false;
+		}
 		break;
 	case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE:
 		if (ctrl->val ==
diff --git a/drivers/media/platform/msm/vidc/msm_venc.c b/drivers/media/platform/msm/vidc/msm_venc.c
index dfb2ad5..22c0df1 100644
--- a/drivers/media/platform/msm/vidc/msm_venc.c
+++ b/drivers/media/platform/msm/vidc/msm_venc.c
@@ -61,6 +61,14 @@
 	NULL
 };
 
+static const char *const mpeg_video_flip[] = {
+	"No Flip",
+	"Horizontal Flip",
+	"Vertical Flip",
+	"Both",
+	NULL
+};
+
 static const char *const h264_video_entropy_cabac_model[] = {
 	"Model 0",
 	"Model 1",
@@ -909,7 +917,16 @@
 		.minimum = 0,
 		.maximum = INT_MAX,
 		.default_value = 0,
-		.step = OPERATING_FRAME_RATE_STEP,
+		.step = 1,
+	},
+	{
+		.id = V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE,
+		.name = "Set Encoder Frame rate",
+		.type = V4L2_CTRL_TYPE_INTEGER,
+		.minimum = 0,
+		.maximum = INT_MAX,
+		.default_value = 0,
+		.step = 1,
 	},
 	{
 		.id = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_TYPE,
@@ -1036,6 +1053,21 @@
 		.default_value = 0,
 		.step = 1,
 	},
+	{
+		.id = V4L2_CID_MPEG_VIDC_VIDEO_FLIP,
+		.name = "Flip",
+		.type = V4L2_CTRL_TYPE_MENU,
+		.minimum = V4L2_CID_MPEG_VIDC_VIDEO_FLIP_NONE,
+		.maximum = V4L2_CID_MPEG_VIDC_VIDEO_FLIP_BOTH,
+		.default_value = V4L2_CID_MPEG_VIDC_VIDEO_FLIP_NONE,
+		.menu_skip_mask = ~(
+		(1 << V4L2_CID_MPEG_VIDC_VIDEO_FLIP_NONE) |
+		(1 << V4L2_CID_MPEG_VIDC_VIDEO_FLIP_HORI) |
+		(1 << V4L2_CID_MPEG_VIDC_VIDEO_FLIP_VERT) |
+		(1 << V4L2_CID_MPEG_VIDC_VIDEO_FLIP_BOTH)
+		),
+		.qmenu = mpeg_video_flip,
+	},
 
 };
 
@@ -1112,6 +1144,13 @@
 		.get_frame_size = get_frame_size_compressed,
 		.type = CAPTURE_PORT,
 	},
+	{
+		.name = "YCbCr Semiplanar 4:2:0 10bit",
+		.description = "Y/CbCr 4:2:0 10bit",
+		.fourcc = V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010,
+		.get_frame_size = get_frame_size_p010,
+		.type = OUTPUT_PORT,
+	},
 };
 
 static int msm_venc_set_csc(struct msm_vidc_inst *inst,
@@ -1420,11 +1459,27 @@
 		break;
 	case V4L2_CID_MPEG_VIDC_VIDEO_ROTATION:
 	{
+		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_FLIP);
 		property_id = HAL_PARAM_VPE_ROTATION;
 		vpe_rotation.rotate = msm_comm_v4l2_to_hal(
 				V4L2_CID_MPEG_VIDC_VIDEO_ROTATION,
 				ctrl->val);
-		vpe_rotation.flip = HAL_FLIP_NONE;
+		vpe_rotation.flip = msm_comm_v4l2_to_hal(
+				V4L2_CID_MPEG_VIDC_VIDEO_FLIP,
+				temp_ctrl->val);
+		pdata = &vpe_rotation;
+		break;
+	}
+	case V4L2_CID_MPEG_VIDC_VIDEO_FLIP:
+	{
+		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_ROTATION);
+		property_id = HAL_PARAM_VPE_ROTATION;
+		vpe_rotation.rotate = msm_comm_v4l2_to_hal(
+				V4L2_CID_MPEG_VIDC_VIDEO_ROTATION,
+				temp_ctrl->val);
+		vpe_rotation.flip = msm_comm_v4l2_to_hal(
+				V4L2_CID_MPEG_VIDC_VIDEO_FLIP,
+				ctrl->val);
 		pdata = &vpe_rotation;
 		break;
 	}
@@ -1464,13 +1519,14 @@
 		pdata = &multi_slice_control;
 		break;
 	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_DELIVERY_MODE: {
-		bool codec_avc =
+		bool codecs_supported =
+			inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC ||
 			inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_H264 ||
 			inst->fmts[CAPTURE_PORT].fourcc ==
 							V4L2_PIX_FMT_H264_NO_SC;
 
 		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);
-		if (codec_avc && temp_ctrl->val ==
+		if (codecs_supported && temp_ctrl->val ==
 				V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
 			property_id = HAL_PARAM_VENC_SLICE_DELIVERY_MODE;
 			enable.enable = true;
@@ -1817,12 +1873,27 @@
 		}
 		break;
 	case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE:
-		dprintk(VIDC_DBG,
-			"inst(%pK) operating rate changed from %d to %d\n",
-			inst, inst->clk_data.operating_rate >> 16,
+		if (((ctrl->val >> 16) < inst->capability.frame_rate.min ||
+			 (ctrl->val >> 16) > inst->capability.frame_rate.max) &&
+			  ctrl->val != INT_MAX) {
+			dprintk(VIDC_ERR, "Invalid operating rate %u\n",
+				(ctrl->val >> 16));
+			rc = -ENOTSUPP;
+		} else if (ctrl->val == INT_MAX) {
+			dprintk(VIDC_DBG, "inst(%pK) Request for turbo mode\n",
+				inst);
+			inst->clk_data.turbo_mode = true;
+		} else if (msm_vidc_validate_operating_rate(inst, ctrl->val)) {
+			dprintk(VIDC_ERR, "Failed to set operating rate\n");
+			rc = -ENOTSUPP;
+		} else {
+			dprintk(VIDC_DBG,
+				"inst(%pK) operating rate changed from %d to %d\n",
+				inst, inst->clk_data.operating_rate >> 16,
 				ctrl->val >> 16);
-		inst->clk_data.operating_rate = ctrl->val;
-
+			inst->clk_data.operating_rate = ctrl->val;
+			inst->clk_data.turbo_mode = false;
+		}
 		break;
 	case V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_TYPE:
 	{
@@ -2385,6 +2456,12 @@
 
 		inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width;
 		inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height;
+		rc = msm_vidc_check_session_supported(inst);
+		if (rc) {
+			dprintk(VIDC_ERR,
+				"%s: session not supported\n", __func__);
+			goto exit;
+		}
 
 		frame_sz.buffer_type = HAL_BUFFER_OUTPUT;
 		frame_sz.width = inst->prop.width[CAPTURE_PORT];
@@ -2443,6 +2520,12 @@
 
 		inst->prop.width[OUTPUT_PORT] = f->fmt.pix_mp.width;
 		inst->prop.height[OUTPUT_PORT] = f->fmt.pix_mp.height;
+		rc = msm_vidc_check_session_supported(inst);
+		if (rc) {
+			dprintk(VIDC_ERR,
+				"%s: session not supported\n", __func__);
+			goto exit;
+		}
 
 		frame_sz.buffer_type = HAL_BUFFER_INPUT;
 		frame_sz.width = inst->prop.width[OUTPUT_PORT];
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c
index 920e91a..ae2a2c6 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc.c
@@ -179,6 +179,10 @@
 	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES:
 		msm_vidc_ctrl_get_range(ctrl, &inst->capability.slice_bytes);
 		break;
+	case V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE:
+	case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE:
+		msm_vidc_ctrl_get_range(ctrl, &inst->capability.frame_rate);
+		break;
 	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
 	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE:
 	case V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_PROFILE:
@@ -277,6 +281,9 @@
 	case V4L2_PIX_FMT_NV12_TP10_UBWC:
 		color_format = COLOR_FMT_NV12_BPP10_UBWC;
 		break;
+	case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010:
+		color_format = COLOR_FMT_P010;
+		break;
 	default:
 		dprintk(VIDC_DBG,
 			"Invalid : g_fmt called on %s port with Invalid fourcc 0x%x\n",
@@ -510,6 +517,12 @@
 		msm_comm_update_input_cr(inst, b->index, cr);
 	}
 
+	if (inst->session_type == MSM_VIDC_DECODER &&
+			b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+		msm_comm_store_mark_data(&inst->etb_data, b->index,
+			b->m.planes[0].reserved[3], b->m.planes[0].reserved[4]);
+	}
+
 	q = msm_comm_get_vb2q(inst, b->type);
 	if (!q) {
 		dprintk(VIDC_ERR,
@@ -562,6 +575,13 @@
 		b->m.planes[i].reserved[1] = b->m.planes[i].data_offset;
 	}
 
+	if (inst->session_type == MSM_VIDC_DECODER &&
+			b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+		msm_comm_fetch_mark_data(&inst->fbd_data, b->index,
+			&b->m.planes[0].reserved[3],
+			&b->m.planes[0].reserved[4]);
+	}
+
 	return rc;
 }
 EXPORT_SYMBOL(msm_vidc_dqbuf);
@@ -868,6 +888,13 @@
 		goto fail_start;
 	}
 
+	rc = msm_vidc_check_scaling_supported(inst);
+	if (rc) {
+		dprintk(VIDC_ERR,
+			"This session scaling is not supported %pK\n", inst);
+		goto fail_start;
+	}
+
 	/* Decide work mode for current session */
 	rc = msm_vidc_decide_work_mode(inst);
 	if (rc) {
@@ -1566,6 +1593,8 @@
 	INIT_MSM_VIDC_LIST(&inst->registeredbufs);
 	INIT_MSM_VIDC_LIST(&inst->reconbufs);
 	INIT_MSM_VIDC_LIST(&inst->eosbufs);
+	INIT_MSM_VIDC_LIST(&inst->etb_data);
+	INIT_MSM_VIDC_LIST(&inst->fbd_data);
 
 	kref_init(&inst->kref);
 
@@ -1673,6 +1702,8 @@
 	DEINIT_MSM_VIDC_LIST(&inst->eosbufs);
 	DEINIT_MSM_VIDC_LIST(&inst->freqs);
 	DEINIT_MSM_VIDC_LIST(&inst->input_crs);
+	DEINIT_MSM_VIDC_LIST(&inst->etb_data);
+	DEINIT_MSM_VIDC_LIST(&inst->fbd_data);
 
 	kfree(inst);
 	inst = NULL;
@@ -1684,6 +1715,7 @@
 static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst)
 {
 	struct msm_vidc_buffer *temp, *dummy;
+	struct getprop_buf *temp_prop, *dummy_prop;
 
 	if (!inst) {
 		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1716,6 +1748,10 @@
 		dprintk(VIDC_ERR,
 			"Failed to release persist buffers\n");
 
+	if (msm_comm_release_mark_data(inst))
+		dprintk(VIDC_ERR,
+			"Failed to release mark_data buffers\n");
+
 	/*
 	 * At this point all buffes should be with driver
 	 * irrespective of scenario
@@ -1731,10 +1767,18 @@
 	if (inst->extradata_handle)
 		msm_comm_smem_free(inst, inst->extradata_handle);
 
-	debugfs_remove_recursive(inst->debugfs_root);
-
 	mutex_lock(&inst->pending_getpropq.lock);
-	WARN_ON(!list_empty(&inst->pending_getpropq.list));
+	if (!list_empty(&inst->pending_getpropq.list)) {
+		dprintk(VIDC_ERR,
+			"pending_getpropq not empty for instance %pK\n",
+			inst);
+		list_for_each_entry_safe(temp_prop, dummy_prop,
+			&inst->pending_getpropq.list, list) {
+			kfree(temp_prop->data);
+			list_del(&temp_prop->list);
+			kfree(temp_prop);
+		}
+	}
 	mutex_unlock(&inst->pending_getpropq.lock);
 }
 
@@ -1771,12 +1815,16 @@
 	DEINIT_MSM_VIDC_LIST(&inst->eosbufs);
 	DEINIT_MSM_VIDC_LIST(&inst->freqs);
 	DEINIT_MSM_VIDC_LIST(&inst->input_crs);
+	DEINIT_MSM_VIDC_LIST(&inst->etb_data);
+	DEINIT_MSM_VIDC_LIST(&inst->fbd_data);
 
 	mutex_destroy(&inst->sync_lock);
 	mutex_destroy(&inst->bufq[CAPTURE_PORT].lock);
 	mutex_destroy(&inst->bufq[OUTPUT_PORT].lock);
 	mutex_destroy(&inst->lock);
 
+	msm_vidc_debugfs_deinit_inst(inst);
+
 	pr_info(VIDC_DBG_TAG "Closed video instance: %pK\n",
 			VIDC_MSG_PRIO2STRING(VIDC_INFO), inst);
 	kfree(inst);
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_clocks.c b/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
index d557959..f2f6d58 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
@@ -553,7 +553,8 @@
 static int msm_vidc_set_clocks(struct msm_vidc_core *core)
 {
 	struct hfi_device *hdev;
-	unsigned long freq = 0, rate = 0;
+	unsigned long freq_core_1 = 0, freq_core_2 = 0, rate = 0;
+	unsigned long freq_core_max = 0;
 	struct msm_vidc_inst *temp = NULL;
 	int rc = 0, i = 0;
 	struct allowed_clock_rates_table *allowed_clks_tbl = NULL;
@@ -568,14 +569,33 @@
 
 	mutex_lock(&core->lock);
 	list_for_each_entry(temp, &core->instances, list) {
-		freq += temp->clk_data.curr_freq;
+
+		if (temp->clk_data.core_id == VIDC_CORE_ID_1)
+			freq_core_1 += temp->clk_data.min_freq;
+		else if (temp->clk_data.core_id == VIDC_CORE_ID_2)
+			freq_core_2 += temp->clk_data.min_freq;
+		else if (temp->clk_data.core_id == VIDC_CORE_ID_3) {
+			freq_core_1 += temp->clk_data.min_freq / 2;
+			freq_core_2 += temp->clk_data.min_freq / 2;
+		}
+
+		freq_core_max = max_t(unsigned long, freq_core_1, freq_core_2);
+
+		if (temp->clk_data.turbo_mode) {
+			dprintk(VIDC_PROF,
+				"Found an instance with Turbo request\n");
+			freq_core_max = msm_vidc_max_freq(core);
+			break;
+		}
 	}
+
 	for (i = core->resources.allowed_clks_tbl_size - 1; i >= 0; i--) {
 		rate = allowed_clks_tbl[i].clock_rate;
-		if (rate >= freq)
+		if (rate >= freq_core_max)
 			break;
 	}
-	core->min_freq = freq;
+
+	core->min_freq = freq_core_max;
 	core->curr_freq = rate;
 	mutex_unlock(&core->lock);
 
@@ -587,19 +607,22 @@
 	return rc;
 }
 
-int msm_vidc_update_operating_rate(struct msm_vidc_inst *inst)
+int msm_vidc_validate_operating_rate(struct msm_vidc_inst *inst,
+	u32 operating_rate)
 {
-	struct v4l2_ctrl *ctrl = NULL;
 	struct msm_vidc_inst *temp;
 	struct msm_vidc_core *core;
 	unsigned long max_freq, freq_left, ops_left, load, cycles, freq = 0;
 	unsigned long mbs_per_second;
+	int rc = 0;
+	u32 curr_operating_rate = 0;
 
 	if (!inst || !inst->core) {
 		dprintk(VIDC_ERR, "%s Invalid args\n", __func__);
 		return -EINVAL;
 	}
 	core = inst->core;
+	curr_operating_rate = inst->clk_data.operating_rate >> 16;
 
 	mutex_lock(&core->lock);
 	max_freq = msm_vidc_max_freq(core);
@@ -614,51 +637,35 @@
 
 	freq_left = max_freq - freq;
 
-	list_for_each_entry(temp, &core->instances, list) {
-
-		if (!temp ||
-				temp->state < MSM_VIDC_START_DONE ||
-				temp->state >= MSM_VIDC_RELEASE_RESOURCES_DONE)
-			continue;
-
-		mbs_per_second = msm_comm_get_inst_load_per_core(temp,
+	mbs_per_second = msm_comm_get_inst_load_per_core(inst,
 		LOAD_CALC_NO_QUIRKS);
 
-		cycles = temp->clk_data.entry->vpp_cycles;
-		if (temp->session_type == MSM_VIDC_ENCODER)
-			cycles = temp->flags & VIDC_LOW_POWER ?
-				temp->clk_data.entry->low_power_cycles :
-				cycles;
+	cycles = inst->clk_data.entry->vpp_cycles;
+	if (inst->session_type == MSM_VIDC_ENCODER)
+		cycles = inst->flags & VIDC_LOW_POWER ?
+			inst->clk_data.entry->low_power_cycles :
+			cycles;
 
-		load = cycles * mbs_per_second;
+	load = cycles * mbs_per_second;
 
-		ops_left = load ? (freq_left / load) : 0;
-		/* Convert remaining operating rate to Q16 format */
-		ops_left = ops_left << 16;
+	ops_left = load ? (freq_left / load) : 0;
 
-		ctrl = v4l2_ctrl_find(&temp->ctrl_handler,
-			V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE);
-		if (ctrl) {
-			dprintk(VIDC_DBG,
-				"%s: Before Range = %lld --> %lld\n",
-				ctrl->name, ctrl->minimum, ctrl->maximum);
-			dprintk(VIDC_DBG,
-				"%s: Before Def value = %lld Cur val = %d\n",
-				ctrl->name, ctrl->default_value, ctrl->val);
-			v4l2_ctrl_modify_range(ctrl, ctrl->minimum,
-				ctrl->val + ops_left, ctrl->step,
-				ctrl->default_value);
-			dprintk(VIDC_DBG,
-				"%s: Updated Range = %lld --> %lld\n",
-				ctrl->name, ctrl->minimum, ctrl->maximum);
-			dprintk(VIDC_DBG,
-				"%s: Updated Def value = %lld Cur val = %d\n",
-				ctrl->name, ctrl->default_value, ctrl->val);
-		}
+	operating_rate = operating_rate >> 16;
+
+	if ((curr_operating_rate + ops_left) >= operating_rate) {
+		dprintk(VIDC_DBG,
+			"Requestd operating rate is valid %u\n",
+			operating_rate);
+		rc = 0;
+	} else {
+		dprintk(VIDC_DBG,
+			"Current load is high for requested settings. Cannot set operating rate to %u\n",
+			operating_rate);
+		rc = -EINVAL;
 	}
 	mutex_unlock(&core->lock);
 
-	return 0;
+	return rc;
 }
 
 int msm_comm_scale_clocks(struct msm_vidc_inst *inst)
@@ -701,9 +708,9 @@
 
 	if (inst->clk_data.buffer_counter < DCVS_FTB_WINDOW ||
 		!msm_vidc_clock_scaling)
-		inst->clk_data.curr_freq = msm_vidc_max_freq(inst->core);
+		inst->clk_data.min_freq = msm_vidc_max_freq(inst->core);
 	else
-		inst->clk_data.curr_freq = freq;
+		inst->clk_data.min_freq = freq;
 
 	msm_vidc_set_clocks(inst->core);
 
@@ -980,8 +987,8 @@
 		return 0;
 	}
 	mbs_per_frame = msm_vidc_get_mbs_per_frame(inst);
-	if (mbs_per_frame >= inst->core->resources.max_hq_mbs_per_frame ||
-		inst->prop.fps >= inst->core->resources.max_hq_fps) {
+	if (mbs_per_frame > inst->core->resources.max_hq_mbs_per_frame ||
+		inst->prop.fps > inst->core->resources.max_hq_fps) {
 		enable = true;
 	}
 
@@ -1025,17 +1032,21 @@
 }
 
 static u32 get_core_load(struct msm_vidc_core *core,
-	u32 core_id, bool lp_mode)
+	u32 core_id, bool lp_mode, bool real_time)
 {
 	struct msm_vidc_inst *inst = NULL;
 	u32 current_inst_mbs_per_sec = 0, load = 0;
+	bool real_time_mode = false;
 
 	mutex_lock(&core->lock);
 	list_for_each_entry(inst, &core->instances, list) {
 		u32 cycles, lp_cycles;
 
+		real_time_mode = inst->flags & VIDC_REALTIME ? true : false;
 		if (!(inst->clk_data.core_id & core_id))
 			continue;
+		if (real_time_mode != real_time)
+			continue;
 		if (inst->session_type == MSM_VIDC_DECODER) {
 			cycles = lp_cycles = inst->clk_data.entry->vpp_cycles;
 		} else if (inst->session_type == MSM_VIDC_ENCODER) {
@@ -1080,10 +1091,10 @@
 	max_freq = msm_vidc_max_freq(inst->core);
 	inst->clk_data.core_id = 0;
 
-	core0_load = get_core_load(core, VIDC_CORE_ID_1, false);
-	core1_load = get_core_load(core, VIDC_CORE_ID_2, false);
-	core0_lp_load = get_core_load(core, VIDC_CORE_ID_1, true);
-	core1_lp_load = get_core_load(core, VIDC_CORE_ID_2, true);
+	core0_load = get_core_load(core, VIDC_CORE_ID_1, false, true);
+	core1_load = get_core_load(core, VIDC_CORE_ID_2, false, true);
+	core0_lp_load = get_core_load(core, VIDC_CORE_ID_1, true, true);
+	core1_lp_load = get_core_load(core, VIDC_CORE_ID_2, true, true);
 
 	min_load = min(core0_load, core1_load);
 	min_core_id = core0_load < core1_load ?
@@ -1095,6 +1106,16 @@
 	lp_cycles = inst->session_type == MSM_VIDC_ENCODER ?
 			inst->clk_data.entry->low_power_cycles :
 			inst->clk_data.entry->vpp_cycles;
+	/*
+	 * Incase there is only 1 core enabled, mark it as the core
+	 * with min load. This ensures that this core is selected and
+	 * video session is set to run on the enabled core.
+	 */
+	if (inst->capability.max_video_cores.max <= VIDC_CORE_ID_1) {
+		min_core_id = min_lp_core_id = VIDC_CORE_ID_1;
+		min_load = core0_load;
+		min_lp_load = core0_lp_load;
+	}
 
 	current_inst_load = msm_comm_get_inst_load(inst, LOAD_CALC_NO_QUIRKS) *
 		inst->clk_data.entry->vpp_cycles;
@@ -1102,9 +1123,9 @@
 	current_inst_lp_load = msm_comm_get_inst_load(inst,
 		LOAD_CALC_NO_QUIRKS) * lp_cycles;
 
-	dprintk(VIDC_DBG, "Core 0 Load = %d Core 1 Load = %d\n",
+	dprintk(VIDC_DBG, "Core 0 RT Load = %d Core 1 RT Load = %d\n",
 		 core0_load, core1_load);
-	dprintk(VIDC_DBG, "Core 0 LP Load = %d Core 1 LP Load = %d\n",
+	dprintk(VIDC_DBG, "Core 0 RT LP Load = %d Core 1 RT LP Load = %d\n",
 		core0_lp_load, core1_lp_load);
 	dprintk(VIDC_DBG, "Max Load = %lu\n", max_freq);
 	dprintk(VIDC_DBG, "Current Load = %d Current LP Load = %d\n",
@@ -1118,7 +1139,8 @@
 		V4L2_CID_MPEG_VIDC_VIDEO_HYBRID_HIERP_MODE);
 
 	/* Try for preferred core based on settings. */
-	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode) {
+	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode &&
+		inst->capability.max_video_cores.max >= VIDC_CORE_ID_3) {
 		if (current_inst_load / 2 + core0_load <= max_freq &&
 			current_inst_load / 2 + core1_load <= max_freq) {
 			if (inst->clk_data.work_mode == VIDC_WORK_MODE_2) {
@@ -1129,7 +1151,8 @@
 		}
 	}
 
-	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode) {
+	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode &&
+		inst->capability.max_video_cores.max >= VIDC_CORE_ID_3) {
 		if (current_inst_lp_load / 2 +
 				core0_lp_load <= max_freq &&
 			current_inst_lp_load / 2 +
@@ -1184,7 +1207,38 @@
 
 	rc = msm_comm_scale_clocks_and_bus(inst);
 
+	msm_print_core_status(core, VIDC_CORE_ID_1);
+	msm_print_core_status(core, VIDC_CORE_ID_2);
+
 	return rc;
 }
 
+void msm_print_core_status(struct msm_vidc_core *core, u32 core_id)
+{
+	struct msm_vidc_inst *inst = NULL;
 
+	dprintk(VIDC_PROF, "Instances running on core %u", core_id);
+	mutex_lock(&core->lock);
+	list_for_each_entry(inst, &core->instances, list) {
+
+		if ((inst->clk_data.core_id != core_id) &&
+			(inst->clk_data.core_id != VIDC_CORE_ID_3))
+			continue;
+
+		dprintk(VIDC_PROF,
+			"inst %pK (%4ux%4u) to (%4ux%4u) %3u %s %s %s %s %lu\n",
+			inst,
+			inst->prop.width[OUTPUT_PORT],
+			inst->prop.height[OUTPUT_PORT],
+			inst->prop.width[CAPTURE_PORT],
+			inst->prop.height[CAPTURE_PORT],
+			inst->prop.fps,
+			inst->session_type == MSM_VIDC_ENCODER ? "ENC" : "DEC",
+			inst->clk_data.work_mode == VIDC_WORK_MODE_1 ?
+				"WORK_MODE_1" : "WORK_MODE_2",
+			inst->flags & VIDC_LOW_POWER ? "LP" : "HQ",
+			inst->flags & VIDC_REALTIME ? "RealTime" : "NonRTime",
+			inst->clk_data.min_freq);
+	}
+	mutex_unlock(&core->lock);
+}
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_clocks.h b/drivers/media/platform/msm/vidc/msm_vidc_clocks.h
index 707f034..142d63f 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_clocks.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_clocks.h
@@ -22,7 +22,8 @@
 #define DCVS_DEC_EXTRA_OUTPUT_BUFFERS 4
 
 void msm_clock_data_reset(struct msm_vidc_inst *inst);
-int msm_vidc_update_operating_rate(struct msm_vidc_inst *inst);
+int msm_vidc_validate_operating_rate(struct msm_vidc_inst *inst,
+	u32 operating_rate);
 int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst,
 	enum hal_buffer buffer_type);
 int msm_dcvs_try_enable(struct msm_vidc_inst *inst);
@@ -31,6 +32,7 @@
 void msm_comm_free_freq_table(struct msm_vidc_inst *inst);
 int msm_vidc_decide_work_mode(struct msm_vidc_inst *inst);
 int msm_vidc_decide_core_and_power_mode(struct msm_vidc_inst *inst);
+void msm_print_core_status(struct msm_vidc_core *core, u32 core_id);
 void msm_vidc_clear_freq_entry(struct msm_vidc_inst *inst,
 	u32 device_addr);
 void msm_comm_free_input_cr_table(struct msm_vidc_inst *inst);
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 8fd1dd1..f8c5798 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -70,11 +70,6 @@
 	"Extradata UBWC CR stats info",
 };
 
-struct getprop_buf {
-	struct list_head list;
-	void *data;
-};
-
 static void msm_comm_generate_session_error(struct msm_vidc_inst *inst);
 static void msm_comm_generate_sys_error(struct msm_vidc_inst *inst);
 static void handle_session_error(enum hal_command_response cmd, void *data);
@@ -565,6 +560,19 @@
 		default:
 			goto unknown_value;
 		}
+	case V4L2_CID_MPEG_VIDC_VIDEO_FLIP:
+		switch (value) {
+		case V4L2_CID_MPEG_VIDC_VIDEO_FLIP_NONE:
+			return HAL_FLIP_NONE;
+		case V4L2_CID_MPEG_VIDC_VIDEO_FLIP_HORI:
+			return HAL_FLIP_HORIZONTAL;
+		case V4L2_CID_MPEG_VIDC_VIDEO_FLIP_VERT:
+			return HAL_FLIP_VERTICAL;
+		case V4L2_CID_MPEG_VIDC_VIDEO_FLIP_BOTH:
+			return HAL_FLIP_BOTH;
+		default:
+			goto unknown_value;
+		}
 	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
 		switch (value) {
 		case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED:
@@ -955,6 +963,9 @@
 	case V4L2_PIX_FMT_NV12_TP10_UBWC:
 		format = HAL_COLOR_FORMAT_NV12_TP10_UBWC;
 		break;
+	case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010:
+		format = HAL_COLOR_FORMAT_P010;
+		break;
 	default:
 		format = HAL_UNUSED_COLOR;
 		break;
@@ -1439,6 +1450,9 @@
 				V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES,
 				&inst->capability.bframe);
 	}
+	msm_vidc_comm_update_ctrl(inst,
+		V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE,
+		&inst->capability.frame_rate);
 }
 
 static void handle_session_init_done(enum hal_command_response cmd, void *data)
@@ -1672,6 +1686,11 @@
 		event_notify->crop_data.height;
 	inst->prop.crop_info.width =
 		event_notify->crop_data.width;
+	/* HW returns progressive_only flag in pic_struct. */
+	inst->pic_struct =
+		event_notify->pic_struct ?
+		MSM_VIDC_PIC_STRUCT_PROGRESSIVE :
+		MSM_VIDC_PIC_STRUCT_MAYBE_INTERLACED;
 
 	ptr = (u32 *)seq_changed_event.u.data;
 	ptr[0] = event_notify->height;
@@ -2163,6 +2182,7 @@
 				"Got SYS_ERR but unable to identify core\n");
 		return;
 	}
+	hdev = core->device;
 
 	mutex_lock(&core->lock);
 	if (core->state == VIDC_CORE_UNINIT) {
@@ -2181,9 +2201,9 @@
 			"%s: Send sys error for inst %pK\n", __func__, inst);
 		change_inst_state(inst, MSM_VIDC_CORE_INVALID);
 		msm_vidc_queue_v4l2_event(inst, V4L2_EVENT_MSM_VIDC_SYS_ERROR);
-		msm_comm_print_inst_info(inst);
+		if (!core->trigger_ssr)
+			msm_comm_print_inst_info(inst);
 	}
-	hdev = core->device;
 	dprintk(VIDC_DBG, "Calling core_release\n");
 	rc = call_hfi_op(hdev, core_release, hdev->hfi_device_data);
 	if (rc) {
@@ -2274,6 +2294,8 @@
 	mutex_lock(&inst->bufq[port].lock);
 	found = false;
 	list_for_each_entry(vb, &q->queued_list, queued_entry) {
+		if (vb->state != VB2_BUF_STATE_ACTIVE)
+			continue;
 		if (msm_comm_compare_vb2_planes(inst, mbuf, vb)) {
 			found = true;
 			break;
@@ -2569,6 +2591,11 @@
 	}
 	vb->timestamp = (time_usec * NSEC_PER_USEC);
 
+	if (inst->session_type == MSM_VIDC_DECODER) {
+		msm_comm_store_mark_data(&inst->fbd_data, vb->index,
+			fill_buf_done->mark_data, fill_buf_done->mark_target);
+	}
+
 	extra_idx = EXTRADATA_IDX(inst->bufq[CAPTURE_PORT].num_planes);
 	if (extra_idx && extra_idx < VIDEO_MAX_PLANES)
 		vb->planes[extra_idx].bytesused = vb->planes[extra_idx].length;
@@ -3008,6 +3035,23 @@
 	return msm_vidc_deinit_core(inst);
 }
 
+static int msm_comm_session_init_done(int flipped_state,
+	struct msm_vidc_inst *inst)
+{
+	int rc;
+
+	dprintk(VIDC_DBG, "inst %pK: waiting for session init done\n", inst);
+	rc = wait_for_state(inst, flipped_state, MSM_VIDC_OPEN_DONE,
+			HAL_SESSION_INIT_DONE);
+	if (rc) {
+		dprintk(VIDC_ERR, "Session init failed for inst %pK\n", inst);
+		msm_comm_generate_sys_error(inst);
+		return rc;
+	}
+
+	return rc;
+}
+
 static int msm_comm_session_init(int flipped_state,
 	struct msm_vidc_inst *inst)
 {
@@ -3345,7 +3389,7 @@
 	enum hal_buffer buffer_type)
 {
 	int rc = 0;
-	struct internal_buf *binfo;
+	struct internal_buf *binfo = NULL;
 	u32 smem_flags = 0, buffer_size;
 	struct hal_buffer_requirements *output_buf, *extradata_buf;
 	int i;
@@ -3454,10 +3498,10 @@
 	}
 	return rc;
 fail_set_buffers:
-	kfree(binfo);
-fail_kzalloc:
 	msm_comm_smem_free(inst, &binfo->smem);
 err_no_mem:
+	kfree(binfo);
+fail_kzalloc:
 	return rc;
 }
 
@@ -3690,8 +3734,7 @@
 		if (rc || state <= get_flipped_state(inst->state, state))
 			break;
 	case MSM_VIDC_OPEN_DONE:
-		rc = wait_for_state(inst, flipped_state, MSM_VIDC_OPEN_DONE,
-			HAL_SESSION_INIT_DONE);
+		rc = msm_comm_session_init_done(flipped_state, inst);
 		if (rc || state <= get_flipped_state(inst->state, state))
 			break;
 	case MSM_VIDC_LOAD_RESOURCES:
@@ -3871,18 +3914,13 @@
 		rc = msm_comm_session_continue(inst);
 		break;
 	}
+	/* This case also for V4L2_ENC_CMD_STOP */
 	case V4L2_DEC_CMD_STOP:
 	{
 		struct eos_buf *binfo = NULL;
 		u32 smem_flags = 0;
 
 		get_inst(inst->core, inst);
-		if (inst->session_type != MSM_VIDC_DECODER) {
-			dprintk(VIDC_DBG,
-				"Non-Decoder session. DEC_STOP is not valid\n");
-			rc = -EINVAL;
-			goto exit;
-		}
 
 		binfo = kzalloc(sizeof(*binfo), GFP_KERNEL);
 		if (!binfo) {
@@ -3955,9 +3993,6 @@
 	data->clnt_data = data->device_addr;
 
 	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-		bool pic_decoding_mode = msm_comm_g_ctrl_for_id(inst,
-				V4L2_CID_MPEG_VIDC_VIDEO_PICTYPE_DEC_MODE);
-
 		data->buffer_type = HAL_BUFFER_INPUT;
 		data->filled_len = vb->planes[0].bytesused;
 		data->offset = vb->planes[0].data_offset;
@@ -3974,13 +4009,10 @@
 		if (vbuf->flags & V4L2_QCOM_BUF_TIMESTAMP_INVALID)
 			data->timestamp = LLONG_MAX;
 
-		/* XXX: This is a dirty hack necessitated by the firmware,
-		 * which refuses to issue FBDs for non I-frames in Picture Type
-		 * Decoding mode, unless we pass in non-zero value in mark_data
-		 * and mark_target.
-		 */
-		data->mark_data = data->mark_target =
-			pic_decoding_mode ? 0xdeadbeef : 0;
+		if (inst->session_type == MSM_VIDC_DECODER) {
+			msm_comm_fetch_mark_data(&inst->etb_data, vb->index,
+				&data->mark_data, &data->mark_target);
+		}
 
 	} else if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
 		data->buffer_type = msm_comm_get_hal_output_buffer(inst);
@@ -4750,6 +4782,7 @@
 	mutex_lock(&inst->eosbufs.lock);
 	list_for_each_entry_safe(buf, next, &inst->eosbufs.list, list) {
 		list_del(&buf->list);
+		msm_comm_smem_free(inst, &buf->smem);
 		kfree(buf);
 	}
 	INIT_LIST_HEAD(&inst->eosbufs.list);
@@ -5297,8 +5330,7 @@
 		LOAD_CALC_IGNORE_NON_REALTIME_LOAD;
 
 	if (inst->state == MSM_VIDC_OPEN_DONE) {
-		max_load_adj = inst->core->resources.max_load +
-			inst->capability.mbs_per_frame.max;
+		max_load_adj = inst->core->resources.max_load;
 		num_mbs_per_sec = msm_comm_get_load(inst->core,
 					MSM_VIDC_DECODER, quirks);
 		num_mbs_per_sec += msm_comm_get_load(inst->core,
@@ -5480,10 +5512,6 @@
 			capability->width.max, capability->height.max);
 			rc = -ENOTSUPP;
 		}
-
-		if (!rc && msm_vidc_check_scaling_supported(inst)) {
-			rc = -ENOTSUPP;
-		}
 	}
 	if (rc) {
 		dprintk(VIDC_ERR,
@@ -5971,6 +5999,10 @@
 			goto sess_continue_fail;
 		}
 		inst->in_reconfig = false;
+		inst->prop.height[CAPTURE_PORT] = inst->reconfig_height;
+		inst->prop.width[CAPTURE_PORT] = inst->reconfig_width;
+		inst->prop.height[OUTPUT_PORT] = inst->reconfig_height;
+		inst->prop.width[OUTPUT_PORT] = inst->reconfig_width;
 	} else if (inst->session_type == MSM_VIDC_ENCODER) {
 		dprintk(VIDC_DBG,
 				"session_continue not supported for encoder");
@@ -6009,6 +6041,11 @@
 	return VENUS_BUFFER_SIZE(COLOR_FMT_NV12_BPP10_UBWC, width, height);
 }
 
+u32 get_frame_size_p010(int plane, u32 height, u32 width)
+{
+	return VENUS_BUFFER_SIZE(COLOR_FMT_P010, width, height);
+}
+
 
 void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
 		struct msm_vidc_buffer *mbuf)
@@ -6297,10 +6334,26 @@
 	}
 
 	mutex_lock(&inst->registeredbufs.lock);
-	list_for_each_entry(mbuf, &inst->registeredbufs.list, list) {
-		if (msm_comm_compare_dma_planes(inst, mbuf, dma_planes)) {
-			found = true;
-			break;
+	if (inst->session_type == MSM_VIDC_DECODER) {
+		list_for_each_entry(mbuf, &inst->registeredbufs.list, list) {
+			if (msm_comm_compare_dma_planes(inst, mbuf,
+					dma_planes)) {
+				found = true;
+				break;
+			}
+		}
+	} else {
+		/*
+		 * for encoder, client may queue the same buffer with different
+		 * fd before driver returned old buffer to the client. This
+		 * buffer should be treated as new buffer. Search the list with
+		 * fd so that it will be treated as new msm_vidc_buffer.
+		 */
+		list_for_each_entry(mbuf, &inst->registeredbufs.list, list) {
+			if (msm_comm_compare_vb2_planes(inst, mbuf, vb2)) {
+				found = true;
+				break;
+			}
 		}
 	}
 
@@ -6610,3 +6663,93 @@
 	return ret;
 }
 
+void msm_comm_store_mark_data(struct msm_vidc_list *data_list,
+		u32 index, u32 mark_data, u32 mark_target)
+{
+	struct msm_vidc_buf_data *pdata = NULL;
+	bool found = false;
+
+	if (!data_list) {
+		dprintk(VIDC_ERR, "%s: invalid params %pK\n",
+			__func__, data_list);
+		return;
+	}
+
+	mutex_lock(&data_list->lock);
+	list_for_each_entry(pdata, &data_list->list, list) {
+		if (pdata->index == index) {
+			pdata->mark_data = mark_data;
+			pdata->mark_target = mark_target;
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+		if (!pdata)  {
+			dprintk(VIDC_WARN, "%s: malloc failure.\n", __func__);
+			goto exit;
+		}
+		pdata->index = index;
+		pdata->mark_data = mark_data;
+		pdata->mark_target = mark_target;
+		list_add_tail(&pdata->list, &data_list->list);
+	}
+
+exit:
+	mutex_unlock(&data_list->lock);
+}
+
+void msm_comm_fetch_mark_data(struct msm_vidc_list *data_list,
+		u32 index, u32 *mark_data, u32 *mark_target)
+{
+	struct msm_vidc_buf_data *pdata = NULL;
+
+	if (!data_list || !mark_data || !mark_target) {
+		dprintk(VIDC_ERR, "%s: invalid params %pK %pK %pK\n",
+			__func__, data_list, mark_data, mark_target);
+		return;
+	}
+
+	*mark_data = *mark_target = 0;
+	mutex_lock(&data_list->lock);
+	list_for_each_entry(pdata, &data_list->list, list) {
+		if (pdata->index == index) {
+			*mark_data = pdata->mark_data;
+			*mark_target = pdata->mark_target;
+			/* clear after fetch */
+			pdata->mark_data = pdata->mark_target = 0;
+			break;
+		}
+	}
+	mutex_unlock(&data_list->lock);
+}
+
+int msm_comm_release_mark_data(struct msm_vidc_inst *inst)
+{
+	struct msm_vidc_buf_data *pdata, *next;
+
+	if (!inst) {
+		dprintk(VIDC_ERR, "%s: invalid params %pK\n",
+			__func__, inst);
+		return -EINVAL;
+	}
+
+	mutex_lock(&inst->etb_data.lock);
+	list_for_each_entry_safe(pdata, next, &inst->etb_data.list, list) {
+		list_del(&pdata->list);
+		kfree(pdata);
+	}
+	mutex_unlock(&inst->etb_data.lock);
+
+	mutex_lock(&inst->fbd_data.lock);
+	list_for_each_entry_safe(pdata, next, &inst->fbd_data.list, list) {
+		list_del(&pdata->list);
+		kfree(pdata);
+	}
+	mutex_unlock(&inst->fbd_data.lock);
+
+	return 0;
+}
+
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.h b/drivers/media/platform/msm/vidc/msm_vidc_common.h
index 05e2b91..79f3c6b 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.h
@@ -20,6 +20,11 @@
 	struct vb2_buffer *vb;
 };
 
+struct getprop_buf {
+	struct list_head list;
+	void *data;
+};
+
 extern const char *const mpeg_video_vidc_extradata[];
 
 enum load_calc_quirks {
@@ -114,6 +119,7 @@
 u32 get_frame_size_rgba(int plane, u32 height, u32 width);
 u32 get_frame_size_nv21(int plane, u32 height, u32 width);
 u32 get_frame_size_tp10_ubwc(int plane, u32 height, u32 width);
+u32 get_frame_size_p010(int plane, u32 height, u32 width);
 struct vb2_buffer *msm_comm_get_vb_using_vidc_buffer(
 		struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
 struct msm_vidc_buffer *msm_comm_get_buffer_using_device_planes(
@@ -154,5 +160,10 @@
 		struct v4l2_buffer *v4l2);
 void kref_put_mbuf(struct msm_vidc_buffer *mbuf);
 bool kref_get_mbuf(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
+void msm_comm_store_mark_data(struct msm_vidc_list *data_list,
+		u32 index, u32 mark_data, u32 mark_target);
+void msm_comm_fetch_mark_data(struct msm_vidc_list *data_list,
+		u32 index, u32 *mark_data, u32 *mark_target);
+int msm_comm_release_mark_data(struct msm_vidc_inst *inst);
 
 #endif
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_debug.c b/drivers/media/platform/msm/vidc/msm_vidc_debug.c
index 98120ac..215bb78 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_debug.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_debug.c
@@ -33,44 +33,31 @@
 
 #define MAX_DBG_BUF_SIZE 4096
 
-struct debug_buffer {
-	struct mutex lock;
-	char ptr[MAX_DBG_BUF_SIZE];
-	char *curr;
-	u32 filled_size;
-};
-
-static struct debug_buffer dbg_buf;
-
-#define INIT_DBG_BUF(__buf) ({ \
-	__buf.curr = __buf.ptr;\
-	__buf.filled_size = 0; \
-})
-
 #define DYNAMIC_BUF_OWNER(__binfo) ({ \
 	atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\
 })
 
+struct core_inst_pair {
+	struct msm_vidc_core *core;
+	struct msm_vidc_inst *inst;
+};
+
 static int core_info_open(struct inode *inode, struct file *file)
 {
 	file->private_data = inode->i_private;
 	return 0;
 }
 
-static u32 write_str(struct debug_buffer *buffer, const char *fmt, ...)
+static u32 write_str(char *buffer,
+		size_t size, const char *fmt, ...)
 {
 	va_list args;
-	u32 size;
-
-	char *curr = buffer->curr;
-	char *end = buffer->ptr + MAX_DBG_BUF_SIZE;
+	u32 len;
 
 	va_start(args, fmt);
-	size = vscnprintf(curr, end - curr, fmt, args);
+	len = vscnprintf(buffer, size, fmt, args);
 	va_end(args);
-	buffer->curr += size;
-	buffer->filled_size += size;
-	return size;
+	return len;
 }
 
 static ssize_t core_info_read(struct file *file, char __user *buf,
@@ -79,6 +66,7 @@
 	struct msm_vidc_core *core = file->private_data;
 	struct hfi_device *hdev;
 	struct hal_fw_info fw_info = { {0} };
+	char *dbuf, *cur, *end;
 	int i = 0, rc = 0;
 	ssize_t len = 0;
 
@@ -86,36 +74,46 @@
 		dprintk(VIDC_ERR, "Invalid params, core: %pK\n", core);
 		return 0;
 	}
+
+	dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL);
+	if (!dbuf) {
+		dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__);
+		return -ENOMEM;
+	}
+	cur = dbuf;
+	end = cur + MAX_DBG_BUF_SIZE;
 	hdev = core->device;
 
-	mutex_lock(&dbg_buf.lock);
-	INIT_DBG_BUF(dbg_buf);
-	write_str(&dbg_buf, "===============================\n");
-	write_str(&dbg_buf, "CORE %d: %pK\n", core->id, core);
-	write_str(&dbg_buf, "===============================\n");
-	write_str(&dbg_buf, "Core state: %d\n", core->state);
+	cur += write_str(cur, end - cur, "===============================\n");
+	cur += write_str(cur, end - cur, "CORE %d: %pK\n", core->id, core);
+	cur += write_str(cur, end - cur, "===============================\n");
+	cur += write_str(cur, end - cur, "Core state: %d\n", core->state);
 	rc = call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data, &fw_info);
 	if (rc) {
 		dprintk(VIDC_WARN, "Failed to read FW info\n");
 		goto err_fw_info;
 	}
 
-	write_str(&dbg_buf, "FW version : %s\n", &fw_info.version);
-	write_str(&dbg_buf, "base addr: 0x%x\n", fw_info.base_addr);
-	write_str(&dbg_buf, "register_base: 0x%x\n", fw_info.register_base);
-	write_str(&dbg_buf, "register_size: %u\n", fw_info.register_size);
-	write_str(&dbg_buf, "irq: %u\n", fw_info.irq);
+	cur += write_str(cur, end - cur,
+		"FW version : %s\n", &fw_info.version);
+	cur += write_str(cur, end - cur,
+		"base addr: 0x%x\n", fw_info.base_addr);
+	cur += write_str(cur, end - cur,
+		"register_base: 0x%x\n", fw_info.register_base);
+	cur += write_str(cur, end - cur,
+		"register_size: %u\n", fw_info.register_size);
+	cur += write_str(cur, end - cur, "irq: %u\n", fw_info.irq);
 
 err_fw_info:
 	for (i = SYS_MSG_START; i < SYS_MSG_END; i++) {
-		write_str(&dbg_buf, "completions[%d]: %s\n", i,
+		cur += write_str(cur, end - cur, "completions[%d]: %s\n", i,
 			completion_done(&core->completions[SYS_MSG_INDEX(i)]) ?
 			"pending" : "done");
 	}
 	len = simple_read_from_buffer(buf, count, ppos,
-			dbg_buf.ptr, dbg_buf.filled_size);
+			dbuf, cur - dbuf);
 
-	mutex_unlock(&dbg_buf.lock);
+	kfree(dbuf);
 	return len;
 }
 
@@ -175,7 +173,6 @@
 	bool ok = false;
 	struct dentry *dir = NULL;
 
-	mutex_init(&dbg_buf.lock);
 	dir = debugfs_create_dir("msm_vidc", NULL);
 	if (IS_ERR_OR_NULL(dir)) {
 		dir = NULL;
@@ -256,13 +253,16 @@
 
 static int inst_info_open(struct inode *inode, struct file *file)
 {
+	dprintk(VIDC_INFO, "Open inode ptr: %pK\n", inode->i_private);
 	file->private_data = inode->i_private;
 	return 0;
 }
 
-static int publish_unreleased_reference(struct msm_vidc_inst *inst)
+static int publish_unreleased_reference(struct msm_vidc_inst *inst,
+		char **dbuf, char *end)
 {
 	struct msm_vidc_buffer *temp = NULL;
+	char *cur = *dbuf;
 
 	if (!inst) {
 		dprintk(VIDC_ERR, "%s: invalid param\n", __func__);
@@ -270,14 +270,14 @@
 	}
 
 	if (inst->buffer_mode_set[CAPTURE_PORT] == HAL_BUFFER_MODE_DYNAMIC) {
-		write_str(&dbg_buf, "Pending buffer references:\n");
+		cur += write_str(cur, end - cur, "Pending buffer references\n");
 
 		mutex_lock(&inst->registeredbufs.lock);
 		list_for_each_entry(temp, &inst->registeredbufs.list, list) {
 			struct vb2_buffer *vb2 = &temp->vvb.vb2_buf;
 
 			if (vb2->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-				write_str(&dbg_buf,
+				cur += write_str(cur, end - cur,
 				"\tbuffer: %#x fd[0] = %d size %d refcount = %d\n",
 				temp->smem[0].device_addr,
 				vb2->planes[0].m.fd,
@@ -287,110 +287,206 @@
 		}
 		mutex_unlock(&inst->registeredbufs.lock);
 	}
+
+	*dbuf = cur;
 	return 0;
 }
 
+static void put_inst_helper(struct kref *kref)
+{
+	struct msm_vidc_inst *inst = container_of(kref,
+			struct msm_vidc_inst, kref);
+
+	msm_vidc_destroy(inst);
+}
+
 static ssize_t inst_info_read(struct file *file, char __user *buf,
 		size_t count, loff_t *ppos)
 {
-	struct msm_vidc_inst *inst = file->private_data;
+	struct core_inst_pair *idata = file->private_data;
+	struct msm_vidc_core *core;
+	struct msm_vidc_inst *inst, *temp = NULL;
+	char *dbuf, *cur, *end;
 	int i, j;
 	ssize_t len = 0;
 
-	if (!inst) {
-		dprintk(VIDC_ERR, "Invalid params, inst %pK\n", inst);
+	if (!idata || !idata->core || !idata->inst) {
+		dprintk(VIDC_ERR, "%s: Invalid params\n", __func__);
 		return 0;
 	}
 
-	mutex_lock(&dbg_buf.lock);
-	INIT_DBG_BUF(dbg_buf);
-	write_str(&dbg_buf, "===============================\n");
-	write_str(&dbg_buf, "INSTANCE: %pK (%s)\n", inst,
+	core = idata->core;
+	inst = idata->inst;
+
+	mutex_lock(&core->lock);
+	list_for_each_entry(temp, &core->instances, list) {
+		if (temp == inst)
+			break;
+	}
+	inst = ((temp == inst) && kref_get_unless_zero(&inst->kref)) ?
+		inst : NULL;
+	mutex_unlock(&core->lock);
+
+	if (!inst) {
+		dprintk(VIDC_ERR, "%s: Instance has become obsolete", __func__);
+		return 0;
+	}
+
+	dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL);
+	if (!dbuf) {
+		dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__);
+		len = -ENOMEM;
+		goto failed_alloc;
+	}
+	cur = dbuf;
+	end = cur + MAX_DBG_BUF_SIZE;
+
+	cur += write_str(cur, end - cur, "==============================\n");
+	cur += write_str(cur, end - cur, "INSTANCE: %pK (%s)\n", inst,
 		inst->session_type == MSM_VIDC_ENCODER ? "Encoder" : "Decoder");
-	write_str(&dbg_buf, "===============================\n");
-	write_str(&dbg_buf, "core: %pK\n", inst->core);
-	write_str(&dbg_buf, "height: %d\n", inst->prop.height[CAPTURE_PORT]);
-	write_str(&dbg_buf, "width: %d\n", inst->prop.width[CAPTURE_PORT]);
-	write_str(&dbg_buf, "fps: %d\n", inst->prop.fps);
-	write_str(&dbg_buf, "state: %d\n", inst->state);
-	write_str(&dbg_buf, "secure: %d\n", !!(inst->flags & VIDC_SECURE));
-	write_str(&dbg_buf, "-----------Formats-------------\n");
+	cur += write_str(cur, end - cur, "==============================\n");
+	cur += write_str(cur, end - cur, "core: %pK\n", inst->core);
+	cur += write_str(cur, end - cur, "height: %d\n",
+		inst->prop.height[CAPTURE_PORT]);
+	cur += write_str(cur, end - cur, "width: %d\n",
+		inst->prop.width[CAPTURE_PORT]);
+	cur += write_str(cur, end - cur, "fps: %d\n", inst->prop.fps);
+	cur += write_str(cur, end - cur, "state: %d\n", inst->state);
+	cur += write_str(cur, end - cur, "secure: %d\n",
+		!!(inst->flags & VIDC_SECURE));
+	cur += write_str(cur, end - cur, "-----------Formats-------------\n");
 	for (i = 0; i < MAX_PORT_NUM; i++) {
-		write_str(&dbg_buf, "capability: %s\n", i == OUTPUT_PORT ?
+		cur += write_str(cur, end - cur, "capability: %s\n",
+			i == OUTPUT_PORT ? "Output" : "Capture");
+		cur += write_str(cur, end - cur, "name : %s\n",
+			inst->fmts[i].name);
+		cur += write_str(cur, end - cur, "planes : %d\n",
+			inst->bufq[i].num_planes);
+		cur += write_str(cur, end - cur,
+			"type: %s\n", inst->fmts[i].type == OUTPUT_PORT ?
 			"Output" : "Capture");
-		write_str(&dbg_buf, "name : %s\n", inst->fmts[i].name);
-		write_str(&dbg_buf, "planes : %d\n", inst->bufq[i].num_planes);
-		write_str(
-		&dbg_buf, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ?
-		"Output" : "Capture");
 		switch (inst->buffer_mode_set[i]) {
 		case HAL_BUFFER_MODE_STATIC:
-			write_str(&dbg_buf, "buffer mode : %s\n", "static");
+			cur += write_str(cur, end - cur,
+				"buffer mode : %s\n", "static");
 			break;
 		case HAL_BUFFER_MODE_DYNAMIC:
-			write_str(&dbg_buf, "buffer mode : %s\n", "dynamic");
+			cur += write_str(cur, end - cur,
+				"buffer mode : %s\n", "dynamic");
 			break;
 		default:
-			write_str(&dbg_buf, "buffer mode : unsupported\n");
+			cur += write_str(cur, end - cur,
+				"buffer mode : unsupported\n");
 		}
 
-		write_str(&dbg_buf, "count: %u\n",
+		cur += write_str(cur, end - cur, "count: %u\n",
 				inst->bufq[i].vb2_bufq.num_buffers);
 
 		for (j = 0; j < inst->bufq[i].num_planes; j++)
-			write_str(&dbg_buf, "size for plane %d: %u\n", j,
-			inst->bufq[i].plane_sizes[j]);
+			cur += write_str(cur, end - cur,
+				"size for plane %d: %u\n",
+				j, inst->bufq[i].plane_sizes[j]);
 
 		if (i < MAX_PORT_NUM - 1)
-			write_str(&dbg_buf, "\n");
+			cur += write_str(cur, end - cur, "\n");
 	}
-	write_str(&dbg_buf, "-------------------------------\n");
+	cur += write_str(cur, end - cur, "-------------------------------\n");
 	for (i = SESSION_MSG_START; i < SESSION_MSG_END; i++) {
-		write_str(&dbg_buf, "completions[%d]: %s\n", i,
+		cur += write_str(cur, end - cur, "completions[%d]: %s\n", i,
 		completion_done(&inst->completions[SESSION_MSG_INDEX(i)]) ?
 		"pending" : "done");
 	}
-	write_str(&dbg_buf, "ETB Count: %d\n", inst->count.etb);
-	write_str(&dbg_buf, "EBD Count: %d\n", inst->count.ebd);
-	write_str(&dbg_buf, "FTB Count: %d\n", inst->count.ftb);
-	write_str(&dbg_buf, "FBD Count: %d\n", inst->count.fbd);
+	cur += write_str(cur, end - cur, "ETB Count: %d\n", inst->count.etb);
+	cur += write_str(cur, end - cur, "EBD Count: %d\n", inst->count.ebd);
+	cur += write_str(cur, end - cur, "FTB Count: %d\n", inst->count.ftb);
+	cur += write_str(cur, end - cur, "FBD Count: %d\n", inst->count.fbd);
 
-	publish_unreleased_reference(inst);
-
+	publish_unreleased_reference(inst, &cur, end);
 	len = simple_read_from_buffer(buf, count, ppos,
-		dbg_buf.ptr, dbg_buf.filled_size);
-	mutex_unlock(&dbg_buf.lock);
+		dbuf, cur - dbuf);
+
+	kfree(dbuf);
+failed_alloc:
+	kref_put(&inst->kref, put_inst_helper);
 	return len;
 }
 
+static int inst_info_release(struct inode *inode, struct file *file)
+{
+	dprintk(VIDC_INFO, "Release inode ptr: %pK\n", inode->i_private);
+	file->private_data = NULL;
+	return 0;
+}
+
 static const struct file_operations inst_info_fops = {
 	.open = inst_info_open,
 	.read = inst_info_read,
+	.release = inst_info_release,
 };
 
 struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst,
 		struct dentry *parent)
 {
-	struct dentry *dir = NULL;
+	struct dentry *dir = NULL, *info = NULL;
 	char debugfs_name[MAX_DEBUGFS_NAME];
+	struct core_inst_pair *idata = NULL;
 
 	if (!inst) {
 		dprintk(VIDC_ERR, "Invalid params, inst: %pK\n", inst);
-		goto failed_create_dir;
+		goto exit;
 	}
 	snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%p", inst);
+
+	idata = kzalloc(sizeof(struct core_inst_pair), GFP_KERNEL);
+	if (!idata) {
+		dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__);
+		goto exit;
+	}
+
+	idata->core = inst->core;
+	idata->inst = inst;
+
 	dir = debugfs_create_dir(debugfs_name, parent);
 	if (!dir) {
 		dprintk(VIDC_ERR, "Failed to create debugfs for msm_vidc\n");
 		goto failed_create_dir;
 	}
-	if (!debugfs_create_file("info", 0444, dir, inst, &inst_info_fops)) {
+
+	info = debugfs_create_file("info", 0444, dir,
+			idata, &inst_info_fops);
+	if (!info) {
 		dprintk(VIDC_ERR, "debugfs_create_file: fail\n");
-		goto failed_create_dir;
+		goto failed_create_file;
 	}
+
+	dir->d_inode->i_private = info->d_inode->i_private;
 	inst->debug.pdata[FRAME_PROCESSING].sampling = true;
-failed_create_dir:
 	return dir;
+
+failed_create_file:
+	debugfs_remove_recursive(dir);
+	dir = NULL;
+failed_create_dir:
+	kfree(idata);
+exit:
+	return dir;
+}
+
+void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst)
+{
+	struct dentry *dentry = NULL;
+
+	if (!inst || !inst->debugfs_root)
+		return;
+
+	dentry = inst->debugfs_root;
+	if (dentry->d_inode) {
+		dprintk(VIDC_INFO, "Destroy %pK\n", dentry->d_inode->i_private);
+		kfree(dentry->d_inode->i_private);
+		dentry->d_inode->i_private = NULL;
+	}
+	debugfs_remove_recursive(dentry);
+	inst->debugfs_root = NULL;
 }
 
 void msm_vidc_debugfs_update(struct msm_vidc_inst *inst,
@@ -441,8 +537,3 @@
 	}
 }
 
-void msm_vidc_debugfs_deinit_drv(void)
-{
-	mutex_destroy(&dbg_buf.lock);
-}
-
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_debug.h b/drivers/media/platform/msm/vidc/msm_vidc_debug.h
index 7a73a50..dbebe5d 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_debug.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_debug.h
@@ -113,7 +113,6 @@
 
 #define MSM_VIDC_ERROR(value)					\
 	do {							\
-		dprintk(VIDC_DBG, "Fatal Level = %d\n", value);\
 		BUG_ON(value);					\
 	} while (0)
 
@@ -123,9 +122,9 @@
 		struct dentry *parent);
 struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst,
 		struct dentry *parent);
+void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst);
 void msm_vidc_debugfs_update(struct msm_vidc_inst *inst,
 		enum msm_vidc_debugfs_event e);
-void msm_vidc_debugfs_deinit_drv(void);
 
 static inline void tic(struct msm_vidc_inst *i, enum profiling_points p,
 				 char *b)
@@ -179,11 +178,17 @@
 	}
 }
 
+static inline void msm_vidc_res_handle_fatal_hw_error(
+	struct msm_vidc_platform_resources *resources,
+	bool enable_fatal)
+{
+	enable_fatal &= resources->debug_timeout;
+	MSM_VIDC_ERROR(enable_fatal);
+}
+
 static inline void msm_vidc_handle_hw_error(struct msm_vidc_core *core)
 {
-	bool enable_fatal;
-
-	enable_fatal = core->resources.debug_timeout;
+	bool enable_fatal = true;
 
 	/*
 	 * In current implementation user-initiated SSR triggers
@@ -200,8 +205,7 @@
 	 * based on multiple factors. This condition check will
 	 * be enhanced later.
 	 */
-
-	MSM_VIDC_ERROR(enable_fatal);
+	msm_vidc_res_handle_fatal_hw_error(&core->resources, enable_fatal);
 }
 
 #endif
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_internal.h b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
index ba05059..37645fe 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_internal.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
@@ -175,6 +175,13 @@
 	u32 *vpe_csc_custom_limit_coeff;
 };
 
+struct msm_vidc_buf_data {
+	struct list_head list;
+	u32 index;
+	u32 mark_data;
+	u32 mark_target;
+};
+
 struct msm_vidc_common_data {
 	char key[128];
 	int value;
@@ -188,12 +195,33 @@
 	int low_power_cycles;
 };
 
+enum efuse_purpose {
+	SKU_VERSION = 0,
+};
+
+enum sku_version {
+	SKU_VERSION_0 = 0,
+	SKU_VERSION_1,
+	SKU_VERSION_2,
+};
+
+struct msm_vidc_efuse_data {
+	u32 start_address;
+	u32 size;
+	u32 mask;
+	u32 shift;
+	enum efuse_purpose purpose;
+};
+
 struct msm_vidc_platform_data {
 	struct msm_vidc_common_data *common_data;
 	unsigned int common_data_length;
 	struct msm_vidc_codec_data *codec_data;
 	unsigned int codec_data_length;
 	struct msm_vidc_csc_coeff csc_data;
+	struct msm_vidc_efuse_data *efuse_data;
+	unsigned int efuse_data_length;
+	unsigned int sku_version;
 };
 
 struct msm_vidc_format {
@@ -211,7 +239,7 @@
 	int num_cores;
 	struct dentry *debugfs_root;
 	int thermal_level;
-	u32 platform_version;
+	u32 sku_version;
 };
 
 struct msm_video_device {
@@ -279,6 +307,7 @@
 	u32 opb_fourcc;
 	enum hal_work_mode work_mode;
 	bool low_latency_mode;
+	bool turbo_mode;
 };
 
 struct profile_data {
@@ -349,6 +378,8 @@
 	struct msm_vidc_list reconbufs;
 	struct msm_vidc_list eosbufs;
 	struct msm_vidc_list registeredbufs;
+	struct msm_vidc_list etb_data;
+	struct msm_vidc_list fbd_data;
 	struct buffer_requirements buff_req;
 	struct smem_client *mem_client;
 	struct v4l2_ctrl_handler ctrl_handler;
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_platform.c b/drivers/media/platform/msm/vidc/msm_vidc_platform.c
index 0fe09e2..56524ccd4 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_platform.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_platform.c
@@ -24,6 +24,7 @@
 #include <linux/version.h>
 #include <linux/io.h>
 #include "msm_vidc_internal.h"
+#include "msm_vidc_debug.h"
 
 
 #define CODEC_ENTRY(n, p, vsp, vpp, lp) \
@@ -35,6 +36,15 @@
 	.low_power_cycles = lp	\
 }
 
+#define EFUSE_ENTRY(sa, s, m, sh, p) \
+{	\
+	.start_address = sa,		\
+	.size = s,	\
+	.mask = m,	\
+	.shift = sh,	\
+	.purpose = p	\
+}
+
 static struct msm_vidc_codec_data default_codec_data[] =  {
 	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_ENCODER, 125, 675, 320),
 	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_DECODER, 125, 675, 320),
@@ -44,7 +54,18 @@
 	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_ENCODER, 125, 675, 320),
 	CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_ENCODER, 125, 675, 320),
 	CODEC_ENTRY(V4L2_PIX_FMT_VP8, MSM_VIDC_ENCODER, 125, 675, 320),
-	CODEC_ENTRY(V4L2_PIX_FMT_TME, MSM_VIDC_ENCODER, 125, 675, 320),
+	CODEC_ENTRY(V4L2_PIX_FMT_TME, MSM_VIDC_ENCODER, 0, 540, 540),
+	CODEC_ENTRY(V4L2_PIX_FMT_MPEG2, MSM_VIDC_DECODER, 50, 200, 200),
+	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_DECODER, 50, 200, 200),
+	CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_DECODER, 50, 200, 200),
+	CODEC_ENTRY(V4L2_PIX_FMT_VP8, MSM_VIDC_DECODER, 50, 200, 200),
+	CODEC_ENTRY(V4L2_PIX_FMT_VP9, MSM_VIDC_DECODER, 50, 200, 200),
+};
+
+static struct msm_vidc_codec_data sdm670_codec_data[] =  {
+	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_ENCODER, 125, 675, 320),
+	CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_ENCODER, 125, 675, 320),
+	CODEC_ENTRY(V4L2_PIX_FMT_VP8, MSM_VIDC_ENCODER, 125, 675, 320),
 	CODEC_ENTRY(V4L2_PIX_FMT_MPEG2, MSM_VIDC_DECODER, 50, 200, 200),
 	CODEC_ENTRY(V4L2_PIX_FMT_H264, MSM_VIDC_DECODER, 50, 200, 200),
 	CODEC_ENTRY(V4L2_PIX_FMT_HEVC, MSM_VIDC_DECODER, 50, 200, 200),
@@ -98,7 +119,7 @@
 	},
 	{
 		.key = "qcom,max-hw-load",
-		.value = 2563200,
+		.value = 3110400,	/* 4096x2160@90 */
 	},
 	{
 		.key = "qcom,max-hq-mbs-per-frame",
@@ -130,6 +151,95 @@
 	},
 };
 
+static struct msm_vidc_common_data sdm670_common_data_v0[] = {
+	{
+		.key = "qcom,never-unload-fw",
+		.value = 1,
+	},
+	{
+		.key = "qcom,sw-power-collapse",
+		.value = 1,
+	},
+	{
+		.key = "qcom,max-secure-instances",
+		.value = 5,
+	},
+	{
+		.key = "qcom,max-hw-load",
+		.value = 1944000,
+	},
+	{
+		.key = "qcom,max-hq-mbs-per-frame",
+		.value = 8160,
+	},
+	{
+		.key = "qcom,max-hq-frames-per-sec",
+		.value = 60,
+	},
+	{
+		.key = "qcom,max-b-frame-size",
+		.value = 8160,
+	},
+	{
+		.key = "qcom,max-b-frames-per-sec",
+		.value = 60,
+	},
+	{
+		.key = "qcom,power-collapse-delay",
+		.value = 500,
+	},
+	{
+		.key = "qcom,hw-resp-timeout",
+		.value = 250,
+	},
+};
+
+static struct msm_vidc_common_data sdm670_common_data_v1[] = {
+	{
+		.key = "qcom,never-unload-fw",
+		.value = 1,
+	},
+	{
+		.key = "qcom,sw-power-collapse",
+		.value = 1,
+	},
+	{
+		.key = "qcom,max-secure-instances",
+		.value = 5,
+	},
+	{
+		.key = "qcom,max-hw-load",
+		.value = 1216800,
+	},
+	{
+		.key = "qcom,max-hq-mbs-per-frame",
+		.value = 8160,
+	},
+	{
+		.key = "qcom,max-hq-frames-per-sec",
+		.value = 60,
+	},
+	{
+		.key = "qcom,max-b-frame-size",
+		.value = 8160,
+	},
+	{
+		.key = "qcom,max-b-frames-per-sec",
+		.value = 60,
+	},
+	{
+		.key = "qcom,power-collapse-delay",
+		.value = 500,
+	},
+	{
+		.key = "qcom,hw-resp-timeout",
+		.value = 250,
+	},
+};
+
+static struct msm_vidc_efuse_data sdm670_efuse_data[] = {
+	EFUSE_ENTRY(0x007801A0, 4, 0x00008000, 0x0f, SKU_VERSION),
+};
 
 static struct msm_vidc_platform_data default_data = {
 	.codec_data = default_codec_data,
@@ -139,6 +249,9 @@
 	.csc_data.vpe_csc_custom_bias_coeff = vpe_csc_custom_bias_coeff,
 	.csc_data.vpe_csc_custom_matrix_coeff = vpe_csc_custom_matrix_coeff,
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
+	.efuse_data = NULL,
+	.efuse_data_length = 0,
+	.sku_version = 0,
 };
 
 static struct msm_vidc_platform_data sdm845_data = {
@@ -149,6 +262,22 @@
 	.csc_data.vpe_csc_custom_bias_coeff = vpe_csc_custom_bias_coeff,
 	.csc_data.vpe_csc_custom_matrix_coeff = vpe_csc_custom_matrix_coeff,
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
+	.efuse_data = NULL,
+	.efuse_data_length = 0,
+	.sku_version = 0,
+};
+
+static struct msm_vidc_platform_data sdm670_data = {
+	.codec_data = sdm670_codec_data,
+	.codec_data_length =  ARRAY_SIZE(sdm670_codec_data),
+	.common_data = sdm670_common_data_v0,
+	.common_data_length =  ARRAY_SIZE(sdm670_common_data_v0),
+	.csc_data.vpe_csc_custom_bias_coeff = vpe_csc_custom_bias_coeff,
+	.csc_data.vpe_csc_custom_matrix_coeff = vpe_csc_custom_matrix_coeff,
+	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
+	.efuse_data = sdm670_efuse_data,
+	.efuse_data_length = ARRAY_SIZE(sdm670_efuse_data),
+	.sku_version = 0,
 };
 
 static const struct of_device_id msm_vidc_dt_match[] = {
@@ -156,15 +285,63 @@
 		.compatible = "qcom,sdm845-vidc",
 		.data = &sdm845_data,
 	},
+	{
+		.compatible = "qcom,sdm670-vidc",
+		.data = &sdm670_data,
+	},
 	{},
 };
 
 MODULE_DEVICE_TABLE(of, msm_vidc_dt_match);
 
+static int msm_vidc_read_efuse(
+		struct msm_vidc_platform_data *data, struct device *dev)
+{
+	void __iomem *base;
+	uint32_t i;
+	struct msm_vidc_efuse_data *efuse_data = data->efuse_data;
+	uint32_t efuse_data_count = data->efuse_data_length;
+
+	for (i = 0; i < efuse_data_count; i++) {
+
+		switch ((efuse_data[i]).purpose) {
+
+		case SKU_VERSION:
+			base = devm_ioremap(dev, (efuse_data[i]).start_address,
+					(efuse_data[i]).size);
+			if (!base) {
+				dprintk(VIDC_ERR,
+					"failed efuse ioremap: res->start %#x, size %d\n",
+					(efuse_data[i]).start_address,
+					(efuse_data[i]).size);
+					return -EINVAL;
+			} else {
+				u32 efuse = 0;
+
+				efuse = readl_relaxed(base);
+				data->sku_version =
+					(efuse & (efuse_data[i]).mask) >>
+					(efuse_data[i]).shift;
+				dprintk(VIDC_DBG,
+					"efuse 0x%x, platform version 0x%x\n",
+					efuse, data->sku_version);
+
+				devm_iounmap(dev, base);
+			}
+			break;
+
+		default:
+			break;
+		}
+	}
+	return 0;
+}
+
 void *vidc_get_drv_data(struct device *dev)
 {
 	struct msm_vidc_platform_data *driver_data = NULL;
 	const struct of_device_id *match;
+	int rc = 0;
 
 	if (!IS_ENABLED(CONFIG_OF) || !dev->of_node) {
 		driver_data = &default_data;
@@ -176,6 +353,21 @@
 	if (match)
 		driver_data = (struct msm_vidc_platform_data *)match->data;
 
+	if (!of_find_property(dev->of_node, "sku-index", NULL) ||
+			!driver_data) {
+		goto exit;
+	} else if (!strcmp(match->compatible, "qcom,sdm670-vidc")) {
+		rc = msm_vidc_read_efuse(driver_data, dev);
+		if (rc)
+			goto exit;
+
+		if (driver_data->sku_version == SKU_VERSION_1) {
+			driver_data->common_data = sdm670_common_data_v1;
+			driver_data->common_data_length =
+					ARRAY_SIZE(sdm670_common_data_v1);
+		}
+	}
+
 exit:
 	return driver_data;
 }
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c
index f343939..a0214a2 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c
@@ -73,12 +73,6 @@
 	res->clock_freq_tbl.clk_prof_entries = NULL;
 }
 
-static inline void msm_vidc_free_platform_version_table(
-		struct msm_vidc_platform_resources *res)
-{
-	res->pf_ver_tbl = NULL;
-}
-
 static inline void msm_vidc_free_reg_table(
 			struct msm_vidc_platform_resources *res)
 {
@@ -133,7 +127,6 @@
 {
 	msm_vidc_free_clock_table(res);
 	msm_vidc_free_regulator_table(res);
-	msm_vidc_free_platform_version_table(res);
 	msm_vidc_free_allowed_clocks_table(res);
 	msm_vidc_free_reg_table(res);
 	msm_vidc_free_qdss_addr_table(res);
@@ -344,33 +337,6 @@
 }
 EXPORT_SYMBOL(msm_vidc_load_u32_table);
 
-static int msm_vidc_load_platform_version_table(
-		struct msm_vidc_platform_resources *res)
-{
-	int rc = 0;
-	struct platform_device *pdev = res->pdev;
-
-	if (!of_find_property(pdev->dev.of_node,
-			"qcom,platform-version", NULL)) {
-		dprintk(VIDC_DBG, "qcom,platform-version not found\n");
-		return 0;
-	}
-
-	rc = msm_vidc_load_u32_table(pdev, pdev->dev.of_node,
-			"qcom,platform-version",
-			sizeof(*res->pf_ver_tbl),
-			(u32 **)&res->pf_ver_tbl,
-			NULL);
-	if (rc) {
-		dprintk(VIDC_ERR,
-			"%s: failed to read platform version table\n",
-			__func__);
-		return rc;
-	}
-
-	return 0;
-}
-
 /* A comparator to compare loads (needed later on) */
 static int cmp(const void *a, const void *b)
 {
@@ -712,6 +678,29 @@
 	return rc;
 }
 
+static int msm_decide_dt_node(
+		struct msm_vidc_platform_resources *res) {
+	struct platform_device *pdev = res->pdev;
+	int rc = 0;
+	u32 sku_index = 0;
+
+	rc = of_property_read_u32(pdev->dev.of_node, "sku-index",
+			&sku_index);
+	if (rc) {
+		dprintk(VIDC_DBG, "'sku_index' not found in node\n");
+		return 0;
+	}
+
+	if (sku_index != res->sku_version) {
+		dprintk(VIDC_DBG,
+			"Failed to parser dt: sku_index %d res->sku_version - %d\n",
+			sku_index, res->sku_version);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int find_key_value(struct msm_vidc_platform_data *platform_data,
 	const char *key)
 {
@@ -743,6 +732,8 @@
 	res->codec_data_count = platform_data->codec_data_length;
 	res->codec_data = platform_data->codec_data;
 
+	res->sku_version = platform_data->sku_version;
+
 	res->fw_name = "venus";
 
 	dprintk(VIDC_DBG, "Firmware filename: %s\n", res->fw_name);
@@ -805,6 +796,11 @@
 		return -ENOENT;
 	}
 
+	rc = msm_decide_dt_node(res);
+	if (rc)
+		return rc;
+
+
 	INIT_LIST_HEAD(&res->context_banks);
 
 	res->firmware_base = (phys_addr_t)firmware_base;
@@ -816,10 +812,6 @@
 	kres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	res->irq = kres ? kres->start : -1;
 
-	rc = msm_vidc_load_platform_version_table(res);
-	if (rc)
-		dprintk(VIDC_ERR, "Failed to load pf version table: %d\n", rc);
-
 	rc = msm_vidc_load_subcache_info(res);
 	if (rc)
 		dprintk(VIDC_WARN, "Failed to load subcache info: %d\n", rc);
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_resources.h b/drivers/media/platform/msm/vidc/msm_vidc_resources.h
index 8309fce..99b4e30 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_resources.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_resources.h
@@ -21,11 +21,6 @@
 
 #define MAX_BUFFER_TYPES 32
 
-struct platform_version_table {
-	u32 version_mask;
-	u32 version_shift;
-};
-
 struct dcvs_table {
 	u32 load;
 	u32 load_low;
@@ -153,7 +148,7 @@
 	phys_addr_t register_base;
 	uint32_t register_size;
 	uint32_t irq;
-	struct platform_version_table *pf_ver_tbl;
+	uint32_t sku_version;
 	struct allowed_clock_rates_table *allowed_clks_tbl;
 	u32 allowed_clks_tbl_size;
 	struct clock_freq_table clock_freq_tbl;
diff --git a/drivers/media/platform/msm/vidc/venus_hfi.c b/drivers/media/platform/msm/vidc/venus_hfi.c
index 47ff1db..e260886 100644
--- a/drivers/media/platform/msm/vidc/venus_hfi.c
+++ b/drivers/media/platform/msm/vidc/venus_hfi.c
@@ -110,7 +110,8 @@
  */
 static inline void __strict_check(struct venus_hfi_device *device)
 {
-	WARN_ON(!mutex_is_locked(&device->lock));
+	msm_vidc_res_handle_fatal_hw_error(device->res,
+		!mutex_is_locked(&device->lock));
 }
 
 static inline void __set_state(struct venus_hfi_device *device,
@@ -238,7 +239,8 @@
 	}
 }
 
-static int __acquire_regulator(struct regulator_info *rinfo)
+static int __acquire_regulator(struct regulator_info *rinfo,
+				struct venus_hfi_device *device)
 {
 	int rc = 0;
 
@@ -266,7 +268,7 @@
 	if (!regulator_is_enabled(rinfo->regulator)) {
 		dprintk(VIDC_WARN, "Regulator is not enabled %s\n",
 			rinfo->name);
-		WARN_ON(1);
+		msm_vidc_res_handle_fatal_hw_error(device->res, true);
 	}
 
 	return rc;
@@ -312,7 +314,7 @@
 	return rc;
 err_reg_handoff_failed:
 	venus_hfi_for_each_regulator_reverse_continue(device, rinfo, c)
-		__acquire_regulator(rinfo);
+		__acquire_regulator(rinfo, device);
 
 	return rc;
 }
@@ -624,7 +626,7 @@
 	if (!device->power_enabled) {
 		dprintk(VIDC_WARN,
 			"HFI Write register failed : Power is OFF\n");
-		WARN_ON(1);
+		msm_vidc_res_handle_fatal_hw_error(device->res, true);
 		return;
 	}
 
@@ -655,7 +657,7 @@
 	if (!device->power_enabled) {
 		dprintk(VIDC_WARN,
 			"HFI Read register failed : Power is OFF\n");
-		WARN_ON(1);
+		msm_vidc_res_handle_fatal_hw_error(device->res, true);
 		return -EINVAL;
 	}
 
@@ -1045,9 +1047,9 @@
 
 	mutex_lock(&device->lock);
 
-	if (device->power_enabled) {
-		dprintk(VIDC_DBG, "Venus is busy\n");
-		rc = -EBUSY;
+	if (!device->power_enabled) {
+		dprintk(VIDC_WARN, "%s: venus power off\n", __func__);
+		rc = -EINVAL;
 		goto exit;
 	}
 	__flush_debug_queue(device, NULL);
@@ -1691,6 +1693,12 @@
 
 	dev->bus_vote.data =
 		kzalloc(sizeof(struct vidc_bus_vote_data), GFP_KERNEL);
+	if (!dev->bus_vote.data) {
+		dprintk(VIDC_ERR, "Bus vote data memory is not allocated\n");
+		rc = -ENOMEM;
+		goto err_no_mem;
+	}
+
 	dev->bus_vote.data_count = 1;
 	dev->bus_vote.data->power_mode = VIDC_POWER_TURBO;
 
@@ -1749,9 +1757,8 @@
 	if (rc || __iface_cmdq_write(dev, &version_pkt))
 		dprintk(VIDC_WARN, "Failed to send image version pkt to f/w\n");
 
-	rc = __enable_subcaches(device);
-	if (!rc)
-		__set_subcaches(device);
+	__enable_subcaches(device);
+	__set_subcaches(device);
 
 	if (dev->res->pm_qos_latency_us) {
 #ifdef CONFIG_SMP
@@ -1768,6 +1775,7 @@
 	__set_state(dev, VENUS_STATE_DEINIT);
 	__unload_fw(dev);
 err_load_fw:
+err_no_mem:
 	dprintk(VIDC_ERR, "Core init failed\n");
 	mutex_unlock(&dev->lock);
 	return rc;
@@ -3065,7 +3073,11 @@
 		if (session_id) {
 			struct hal_session *session = NULL;
 
-			WARN_ON(upper_32_bits((uintptr_t)*session_id) != 0);
+			if (upper_32_bits((uintptr_t)*session_id) != 0) {
+				dprintk(VIDC_ERR,
+					"Upper 32-bits != 0 for sess_id=%pK\n",
+					*session_id);
+			}
 			session = __get_session(device,
 					(u32)(uintptr_t)*session_id);
 			if (!session) {
@@ -3668,7 +3680,8 @@
 	return rc;
 }
 
-static int __disable_regulator(struct regulator_info *rinfo)
+static int __disable_regulator(struct regulator_info *rinfo,
+				struct venus_hfi_device *device)
 {
 	int rc = 0;
 
@@ -3680,7 +3693,7 @@
 	 * is unknown.
 	 */
 
-	rc = __acquire_regulator(rinfo);
+	rc = __acquire_regulator(rinfo, device);
 	if (rc) {
 		/*
 		 * This is somewhat fatal, but nothing we can do
@@ -3706,7 +3719,7 @@
 disable_regulator_failed:
 
 	/* Bring attention to this issue */
-	WARN_ON(1);
+	msm_vidc_res_handle_fatal_hw_error(device->res, true);
 	return rc;
 }
 
@@ -3752,7 +3765,7 @@
 
 err_reg_enable_failed:
 	venus_hfi_for_each_regulator_reverse_continue(device, rinfo, c)
-		__disable_regulator(rinfo);
+		__disable_regulator(rinfo, device);
 
 	return rc;
 }
@@ -3765,7 +3778,7 @@
 	dprintk(VIDC_DBG, "Disabling regulators\n");
 
 	venus_hfi_for_each_regulator_reverse(device, rinfo)
-		__disable_regulator(rinfo);
+		__disable_regulator(rinfo, device);
 
 	return rc;
 }
@@ -3783,8 +3796,9 @@
 	venus_hfi_for_each_subcache(device, sinfo) {
 		rc = llcc_slice_activate(sinfo->subcache);
 		if (rc) {
-			dprintk(VIDC_ERR, "Failed to activate %s: %d\n",
+			dprintk(VIDC_WARN, "Failed to activate %s: %d\n",
 				sinfo->name, rc);
+			msm_vidc_res_handle_fatal_hw_error(device->res, true);
 			goto err_activate_fail;
 		}
 		sinfo->isactive = true;
@@ -3799,7 +3813,7 @@
 err_activate_fail:
 	__release_subcaches(device);
 	__disable_subcaches(device);
-	return -EINVAL;
+	return 0;
 }
 
 static int __set_subcaches(struct venus_hfi_device *device)
@@ -3841,25 +3855,25 @@
 
 		rc = __core_set_resource(device, &rhdr, (void *)sc_res_info);
 		if (rc) {
-			dprintk(VIDC_ERR, "Failed to set subcaches %d\n", rc);
+			dprintk(VIDC_WARN, "Failed to set subcaches %d\n", rc);
 			goto err_fail_set_subacaches;
 		}
-	}
 
-	venus_hfi_for_each_subcache(device, sinfo) {
-		if (sinfo->isactive == true)
-			sinfo->isset = true;
-	}
+		venus_hfi_for_each_subcache(device, sinfo) {
+			if (sinfo->isactive == true)
+				sinfo->isset = true;
+		}
 
-	dprintk(VIDC_DBG, "Set Subcaches done to Venus\n");
-	device->res->sys_cache_res_set = true;
+		dprintk(VIDC_DBG, "Set Subcaches done to Venus\n");
+		device->res->sys_cache_res_set = true;
+	}
 
 	return 0;
 
 err_fail_set_subacaches:
 	__disable_subcaches(device);
 
-	return rc;
+	return 0;
 }
 
 static int __release_subcaches(struct venus_hfi_device *device)
@@ -3898,13 +3912,13 @@
 
 		rc = __core_release_resource(device, &rhdr);
 		if (rc)
-			dprintk(VIDC_ERR,
+			dprintk(VIDC_WARN,
 				"Failed to release %d subcaches\n", c);
 	}
 
 	device->res->sys_cache_res_set = false;
 
-	return rc;
+	return 0;
 }
 
 static int __disable_subcaches(struct venus_hfi_device *device)
@@ -3922,7 +3936,7 @@
 				sinfo->name);
 			rc = llcc_slice_deactivate(sinfo->subcache);
 			if (rc) {
-				dprintk(VIDC_ERR,
+				dprintk(VIDC_WARN,
 					"Failed to de-activate %s: %d\n",
 					sinfo->name, rc);
 			}
@@ -3930,7 +3944,7 @@
 		}
 	}
 
-	return rc;
+	return 0;
 }
 
 static int __venus_power_on(struct venus_hfi_device *device)
@@ -4104,9 +4118,8 @@
 
 	__sys_set_debug(device, msm_vidc_fw_debug);
 
-	rc = __enable_subcaches(device);
-	if (!rc)
-		__set_subcaches(device);
+	__enable_subcaches(device);
+	__set_subcaches(device);
 
 	dprintk(VIDC_PROF, "Resumed from power collapse\n");
 exit:
@@ -4275,10 +4288,65 @@
 	return rc;
 }
 
+static void __noc_error_info(struct venus_hfi_device *device, u32 core_num)
+{
+	u32 vcodec_core_video_noc_base_offs, val;
+
+	if (!device) {
+		dprintk(VIDC_ERR, "%s: null device\n", __func__);
+		return;
+	}
+	if (!core_num) {
+		vcodec_core_video_noc_base_offs =
+			VCODEC_CORE0_VIDEO_NOC_BASE_OFFS;
+	} else if (core_num == 1) {
+		vcodec_core_video_noc_base_offs =
+			VCODEC_CORE1_VIDEO_NOC_BASE_OFFS;
+	} else {
+		dprintk(VIDC_ERR, "%s: invalid core_num %u\n",
+			__func__, core_num);
+		return;
+	}
+
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_SWID_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_SWID_LOW:     %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_SWID_HIGH_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_SWID_HIGH:    %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_MAINCTL_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_MAINCTL_LOW:  %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG0_LOW:  %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_HIGH_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG0_HIGH: %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG1_LOW:  %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_HIGH_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG1_HIGH: %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG2_LOW:  %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_HIGH_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG2_HIGH: %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_LOW_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG3_LOW:  %#x\n", core_num, val);
+	val = __read_register(device, vcodec_core_video_noc_base_offs +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_HIGH_OFFS);
+	dprintk(VIDC_ERR, "CORE%d_NOC_ERR_ERRLOG3_HIGH: %#x\n", core_num, val);
+}
+
 static int venus_hfi_noc_error_info(void *dev)
 {
 	struct venus_hfi_device *device;
-	u32 val = 0;
+	const u32 core0 = 0, core1 = 1;
 
 	if (!dev) {
 		dprintk(VIDC_ERR, "%s: null device\n", __func__);
@@ -4289,44 +4357,13 @@
 	mutex_lock(&device->lock);
 	dprintk(VIDC_ERR, "%s: non error information\n", __func__);
 
-	val = __read_register(device, 0x0C500);
-	dprintk(VIDC_ERR, "NOC_ERR_SWID_LOW(0x00AA0C500):     %#x\n", val);
+	if (__read_register(device, VCODEC_CORE0_VIDEO_NOC_BASE_OFFS +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRVLD_LOW_OFFS))
+		__noc_error_info(device, core0);
 
-	val = __read_register(device, 0x0C504);
-	dprintk(VIDC_ERR, "NOC_ERR_SWID_HIGH(0x00AA0C504):    %#x\n", val);
-
-	val = __read_register(device, 0x0C508);
-	dprintk(VIDC_ERR, "NOC_ERR_MAINCTL_LOW(0x00AA0C508):  %#x\n", val);
-
-	val = __read_register(device, 0x0C510);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRVLD_LOW(0x00AA0C510):   %#x\n", val);
-
-	val = __read_register(device, 0x0C518);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRCLR_LOW(0x00AA0C518):   %#x\n", val);
-
-	val = __read_register(device, 0x0C520);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG0_LOW(0x00AA0C520):  %#x\n", val);
-
-	val = __read_register(device, 0x0C524);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG0_HIGH(0x00AA0C524): %#x\n", val);
-
-	val = __read_register(device, 0x0C528);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG1_LOW(0x00AA0C528):  %#x\n", val);
-
-	val = __read_register(device, 0x0C52C);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG1_HIGH(0x00AA0C52C): %#x\n", val);
-
-	val = __read_register(device, 0x0C530);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG2_LOW(0x00AA0C530):  %#x\n", val);
-
-	val = __read_register(device, 0x0C534);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG2_HIGH(0x00AA0C534): %#x\n", val);
-
-	val = __read_register(device, 0x0C538);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG3_LOW(0x00AA0C538):  %#x\n", val);
-
-	val = __read_register(device, 0x0C53C);
-	dprintk(VIDC_ERR, "NOC_ERR_ERRLOG3_HIGH(0x00AA0C53C): %#x\n", val);
+	if (__read_register(device, VCODEC_CORE1_VIDEO_NOC_BASE_OFFS +
+			VCODEC_COREX_VIDEO_NOC_ERR_ERRVLD_LOW_OFFS))
+		__noc_error_info(device, core1);
 
 	mutex_unlock(&device->lock);
 
diff --git a/drivers/media/platform/msm/vidc/vidc_hfi_api.h b/drivers/media/platform/msm/vidc/vidc_hfi_api.h
index ff43e3d..53df90f5 100644
--- a/drivers/media/platform/msm/vidc/vidc_hfi_api.h
+++ b/drivers/media/platform/msm/vidc/vidc_hfi_api.h
@@ -433,6 +433,7 @@
 	HAL_COLOR_FORMAT_NV12_TP10_UBWC = 0x00004000,
 	HAL_COLOR_FORMAT_RGBA8888       = 0x00008000,
 	HAL_COLOR_FORMAT_RGBA8888_UBWC  = 0x00010000,
+	HAL_COLOR_FORMAT_P010           = 0x00020000,
 	HAL_UNUSED_COLOR                = 0x10000000,
 };
 
@@ -659,6 +660,7 @@
 	HAL_FLIP_NONE,
 	HAL_FLIP_HORIZONTAL,
 	HAL_FLIP_VERTICAL,
+	HAL_FLIP_BOTH,
 	HAL_UNUSED_FLIP = 0x10000000,
 };
 
@@ -866,8 +868,8 @@
 };
 
 enum hal_work_mode {
-	VIDC_WORK_MODE_1,
-	VIDC_WORK_MODE_2,
+	VIDC_WORK_MODE_1 = 1,
+	VIDC_WORK_MODE_2 = 2,
 	VIDC_WORK_MODE_UNUSED = 0x10000000,
 };
 
diff --git a/drivers/media/platform/msm/vidc/vidc_hfi_io.h b/drivers/media/platform/msm/vidc/vidc_hfi_io.h
index fc32d73..3433483 100644
--- a/drivers/media/platform/msm/vidc/vidc_hfi_io.h
+++ b/drivers/media/platform/msm/vidc/vidc_hfi_io.h
@@ -190,4 +190,25 @@
 #define VIDC_UC_REGION_ADDR 0x000D2064
 #define VIDC_UC_REGION_SIZE 0x000D2068
 
+/*
+ * --------------------------------------------------------------------------
+ * MODULE: vcodec noc error log registers
+ * --------------------------------------------------------------------------
+ */
+#define VCODEC_CORE0_VIDEO_NOC_BASE_OFFS		0x00004000
+#define VCODEC_CORE1_VIDEO_NOC_BASE_OFFS		0x0000C000
+#define VCODEC_COREX_VIDEO_NOC_ERR_SWID_LOW_OFFS	0x0500
+#define VCODEC_COREX_VIDEO_NOC_ERR_SWID_HIGH_OFFS	0x0504
+#define VCODEC_COREX_VIDEO_NOC_ERR_MAINCTL_LOW_OFFS	0x0508
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRVLD_LOW_OFFS	0x0510
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRCLR_LOW_OFFS	0x0518
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_LOW_OFFS	0x0520
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_HIGH_OFFS	0x0524
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_LOW_OFFS	0x0528
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_HIGH_OFFS	0x052C
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_LOW_OFFS	0x0530
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_HIGH_OFFS	0x0534
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_LOW_OFFS	0x0538
+#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_HIGH_OFFS	0x053C
+
 #endif
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index c3277308..b49f80c 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -254,7 +254,7 @@
 		return 0;
 
 	case LIRC_GET_REC_RESOLUTION:
-		val = dev->rx_resolution;
+		val = dev->rx_resolution / 1000;
 		break;
 
 	case LIRC_SET_WIDEBAND_RECEIVER:
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 71341a7..521b639 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1636,20 +1636,6 @@
 	  power supply enable or disable. This driver acts as interface
 	  between codec and regulator framework.
 
-config WCD9XXX_CODEC_CORE
-	tristate "WCD9XXX Codec Core"
-	select SLIMBUS
-	select SOUNDWIRE_WCD_CTRL
-	select MSM_CDC_SUPPLY
-	select MSM_CDC_PINCTRL
-	select REGMAP_ALLOW_WRITE_DEBUGFS
-	select PINCTRL_WCD
-	help
-	  WCD9XXX Core driver provides APIs for WCD drivers to reset,
-	  suspend/resume, regmap bus callback functions and read/write
-	  functions. This driver also hides the underlying bus related
-	  functionalities.
-
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0ce70f3..eae6458 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -205,13 +205,6 @@
 obj-$(CONFIG_MFD_DLN2)		+= dln2.o
 obj-$(CONFIG_MFD_RT5033)	+= rt5033.o
 obj-$(CONFIG_MFD_SKY81452)	+= sky81452.o
-wcd-core-objs			:= wcd9xxx-rst.o wcd9xxx-core-init.o \
-				   wcd9xxx-core.o wcd9xxx-irq.o \
-				   wcd9xxx-slimslave.o wcd9xxx-utils.o \
-				   wcd934x-regmap.o wcd934x-tables.o \
-				   wcd9335-regmap.o wcd9335-tables.o \
-				   msm-cdc-pinctrl.o msm-cdc-supply.o
-obj-$(CONFIG_WCD9XXX_CODEC_CORE) += wcd-core.o
 intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
diff --git a/drivers/mfd/msm-cdc-pinctrl.c b/drivers/mfd/msm-cdc-pinctrl.c
deleted file mode 100644
index 938ffd5..0000000
--- a/drivers/mfd/msm-cdc-pinctrl.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
-#include <linux/platform_device.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-
-struct msm_cdc_pinctrl_info {
-	struct pinctrl *pinctrl;
-	struct pinctrl_state *pinctrl_active;
-	struct pinctrl_state *pinctrl_sleep;
-	int gpio;
-	bool state;
-};
-
-static struct msm_cdc_pinctrl_info *msm_cdc_pinctrl_get_gpiodata(
-						struct device_node *np)
-{
-	struct platform_device *pdev;
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	if (!np) {
-		pr_err("%s: device node is null\n", __func__);
-		return NULL;
-	}
-
-	pdev = of_find_device_by_node(np);
-	if (!pdev) {
-		pr_err("%s: platform device not found!\n", __func__);
-		return NULL;
-	}
-
-	gpio_data = dev_get_drvdata(&pdev->dev);
-	if (!gpio_data)
-		dev_err(&pdev->dev, "%s: cannot find cdc gpio info\n",
-			__func__);
-
-	return gpio_data;
-}
-
-/*
- * msm_cdc_get_gpio_state: select pinctrl sleep state
- * @np: pointer to struct device_node
- *
- * Returns error code for failure and GPIO value on success
- */
-int msm_cdc_get_gpio_state(struct device_node *np)
-{
-	struct msm_cdc_pinctrl_info *gpio_data;
-	int value = -EINVAL;
-
-	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
-	if (!gpio_data)
-		return value;
-
-	if (gpio_is_valid(gpio_data->gpio))
-		value = gpio_get_value_cansleep(gpio_data->gpio);
-
-	return value;
-}
-EXPORT_SYMBOL(msm_cdc_get_gpio_state);
-
-/*
- * msm_cdc_pinctrl_select_sleep_state: select pinctrl sleep state
- * @np: pointer to struct device_node
- *
- * Returns error code for failure
- */
-int msm_cdc_pinctrl_select_sleep_state(struct device_node *np)
-{
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
-	if (!gpio_data)
-		return -EINVAL;
-
-	if (!gpio_data->pinctrl_sleep) {
-		pr_err("%s: pinctrl sleep state is null\n", __func__);
-		return -EINVAL;
-	}
-	gpio_data->state = false;
-
-	return pinctrl_select_state(gpio_data->pinctrl,
-				    gpio_data->pinctrl_sleep);
-}
-EXPORT_SYMBOL(msm_cdc_pinctrl_select_sleep_state);
-
-/*
- * msm_cdc_pinctrl_select_active_state: select pinctrl active state
- * @np: pointer to struct device_node
- *
- * Returns error code for failure
- */
-int msm_cdc_pinctrl_select_active_state(struct device_node *np)
-{
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
-	if (!gpio_data)
-		return -EINVAL;
-
-	if (!gpio_data->pinctrl_active) {
-		pr_err("%s: pinctrl active state is null\n", __func__);
-		return -EINVAL;
-	}
-	gpio_data->state = true;
-
-	return pinctrl_select_state(gpio_data->pinctrl,
-				    gpio_data->pinctrl_active);
-}
-EXPORT_SYMBOL(msm_cdc_pinctrl_select_active_state);
-
-/*
- * msm_cdc_pinctrl_get_state: get curren pinctrl state
- * @np: pointer to struct device_node
- *
- * Returns 0 for sleep state, 1 for active state
- */
-bool msm_cdc_pinctrl_get_state(struct device_node *np)
-{
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
-	if (!gpio_data)
-		return -EINVAL;
-
-	return gpio_data->state;
-}
-EXPORT_SYMBOL(msm_cdc_pinctrl_get_state);
-
-static int msm_cdc_pinctrl_probe(struct platform_device *pdev)
-{
-	int ret = 0;
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	gpio_data = devm_kzalloc(&pdev->dev,
-				 sizeof(struct msm_cdc_pinctrl_info),
-				 GFP_KERNEL);
-	if (!gpio_data)
-		return -ENOMEM;
-
-	gpio_data->pinctrl = devm_pinctrl_get(&pdev->dev);
-	if (IS_ERR_OR_NULL(gpio_data->pinctrl)) {
-		dev_err(&pdev->dev, "%s: Cannot get cdc gpio pinctrl:%ld\n",
-			__func__, PTR_ERR(gpio_data->pinctrl));
-		ret = PTR_ERR(gpio_data->pinctrl);
-		goto err_pctrl_get;
-	}
-
-	gpio_data->pinctrl_active = pinctrl_lookup_state(
-					gpio_data->pinctrl, "aud_active");
-	if (IS_ERR_OR_NULL(gpio_data->pinctrl_active)) {
-		dev_err(&pdev->dev, "%s: Cannot get aud_active pinctrl state:%ld\n",
-			__func__, PTR_ERR(gpio_data->pinctrl_active));
-		ret = PTR_ERR(gpio_data->pinctrl_active);
-		goto err_lookup_state;
-	}
-
-	gpio_data->pinctrl_sleep = pinctrl_lookup_state(
-					gpio_data->pinctrl, "aud_sleep");
-	if (IS_ERR_OR_NULL(gpio_data->pinctrl_sleep)) {
-		dev_err(&pdev->dev, "%s: Cannot get aud_sleep pinctrl state:%ld\n",
-			__func__, PTR_ERR(gpio_data->pinctrl_sleep));
-		ret = PTR_ERR(gpio_data->pinctrl_sleep);
-		goto err_lookup_state;
-	}
-	/* skip setting to sleep state for LPI_TLMM GPIOs */
-	if (!of_property_read_bool(pdev->dev.of_node, "qcom,lpi-gpios")) {
-		/* Set pinctrl state to aud_sleep by default */
-		ret = pinctrl_select_state(gpio_data->pinctrl,
-					   gpio_data->pinctrl_sleep);
-		if (ret)
-			dev_err(&pdev->dev, "%s: set cdc gpio sleep state fail: %d\n",
-				__func__, ret);
-	}
-
-	gpio_data->gpio = of_get_named_gpio(pdev->dev.of_node,
-					    "qcom,cdc-rst-n-gpio", 0);
-	if (gpio_is_valid(gpio_data->gpio)) {
-		ret = gpio_request(gpio_data->gpio, "MSM_CDC_RESET");
-		if (ret) {
-			dev_err(&pdev->dev, "%s: Failed to request gpio %d\n",
-				__func__, gpio_data->gpio);
-			goto err_lookup_state;
-		}
-	}
-
-	dev_set_drvdata(&pdev->dev, gpio_data);
-	return 0;
-
-err_lookup_state:
-	devm_pinctrl_put(gpio_data->pinctrl);
-err_pctrl_get:
-	devm_kfree(&pdev->dev, gpio_data);
-	return ret;
-}
-
-static int msm_cdc_pinctrl_remove(struct platform_device *pdev)
-{
-	struct msm_cdc_pinctrl_info *gpio_data;
-
-	gpio_data = dev_get_drvdata(&pdev->dev);
-
-	/* to free the requested gpio before exiting */
-	if (gpio_data) {
-		if (gpio_is_valid(gpio_data->gpio))
-			gpio_free(gpio_data->gpio);
-
-		if (gpio_data->pinctrl)
-			devm_pinctrl_put(gpio_data->pinctrl);
-	}
-
-	devm_kfree(&pdev->dev, gpio_data);
-
-	return 0;
-}
-
-static const struct of_device_id msm_cdc_pinctrl_match[] = {
-	{.compatible = "qcom,msm-cdc-pinctrl"},
-	{}
-};
-
-static struct platform_driver msm_cdc_pinctrl_driver = {
-	.driver = {
-		.name = "msm-cdc-pinctrl",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_cdc_pinctrl_match,
-	},
-	.probe = msm_cdc_pinctrl_probe,
-	.remove = msm_cdc_pinctrl_remove,
-};
-
-int msm_cdc_pinctrl_drv_init(void)
-{
-	return platform_driver_register(&msm_cdc_pinctrl_driver);
-}
-
-void msm_cdc_pinctrl_drv_exit(void)
-{
-	platform_driver_unregister(&msm_cdc_pinctrl_driver);
-}
-MODULE_DESCRIPTION("MSM CODEC pin control platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/msm-cdc-supply.c b/drivers/mfd/msm-cdc-supply.c
deleted file mode 100644
index 9c7ebf7..0000000
--- a/drivers/mfd/msm-cdc-supply.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/of_irq.h>
-#include <linux/of_device.h>
-#include <linux/slab.h>
-#include <linux/mfd/msm-cdc-supply.h>
-#include <linux/regulator/consumer.h>
-
-#define CODEC_DT_MAX_PROP_SIZE 40
-
-static int msm_cdc_dt_parse_vreg_info(struct device *dev,
-				      struct cdc_regulator *cdc_vreg,
-				      const char *name, bool is_ond)
-{
-	char prop_name[CODEC_DT_MAX_PROP_SIZE];
-	struct device_node *regulator_node = NULL;
-	const __be32 *prop;
-	int len, rc;
-	u32 prop_val;
-
-	/* Parse supply name */
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE, "%s-supply", name);
-
-	regulator_node = of_parse_phandle(dev->of_node, prop_name, 0);
-	if (!regulator_node) {
-		dev_err(dev, "%s: Looking up %s property in node %s failed",
-			__func__, prop_name, dev->of_node->full_name);
-		rc = -EINVAL;
-		goto done;
-	}
-	cdc_vreg->name = name;
-	cdc_vreg->ondemand = is_ond;
-
-	/* Parse supply - voltage */
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE, "qcom,%s-voltage", name);
-	prop = of_get_property(dev->of_node, prop_name, &len);
-	if (!prop || (len != (2 * sizeof(__be32)))) {
-		dev_err(dev, "%s: %s %s property\n", __func__,
-			prop ? "invalid format" : "no", prop_name);
-		rc = -EINVAL;
-		goto done;
-	} else {
-		cdc_vreg->min_uV = be32_to_cpup(&prop[0]);
-		cdc_vreg->max_uV = be32_to_cpup(&prop[1]);
-	}
-
-	/* Parse supply - current */
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE, "qcom,%s-current", name);
-	rc = of_property_read_u32(dev->of_node, prop_name, &prop_val);
-	if (rc) {
-		dev_err(dev, "%s: Looking up %s property in node %s failed",
-			__func__, prop_name, dev->of_node->full_name);
-		goto done;
-	}
-	cdc_vreg->optimum_uA = prop_val;
-
-	dev_info(dev, "%s: %s: vol=[%d %d]uV, curr=[%d]uA, ond %d\n",
-		 __func__, cdc_vreg->name, cdc_vreg->min_uV, cdc_vreg->max_uV,
-		 cdc_vreg->optimum_uA, cdc_vreg->ondemand);
-
-done:
-	return rc;
-}
-
-static int msm_cdc_parse_supplies(struct device *dev,
-				  struct cdc_regulator *cdc_reg,
-				  const char *sup_list, int sup_cnt,
-				  bool is_ond)
-{
-	int idx, rc = 0;
-	const char *name = NULL;
-
-	for (idx = 0; idx < sup_cnt; idx++) {
-		rc = of_property_read_string_index(dev->of_node, sup_list, idx,
-						   &name);
-		if (rc) {
-			dev_err(dev, "%s: read string %s[%d] error (%d)\n",
-				__func__, sup_list, idx, rc);
-			goto done;
-		}
-
-		dev_dbg(dev, "%s: Found cdc supply %s as part of %s\n",
-			__func__, name, sup_list);
-
-		rc = msm_cdc_dt_parse_vreg_info(dev, &cdc_reg[idx], name,
-						is_ond);
-		if (rc) {
-			dev_err(dev, "%s: parse %s vreg info failed (%d)\n",
-				__func__, name, rc);
-			goto done;
-		}
-	}
-
-done:
-	return rc;
-}
-
-static int msm_cdc_check_supply_param(struct device *dev,
-				      struct cdc_regulator *cdc_vreg,
-				      int num_supplies)
-{
-	if (!dev) {
-		pr_err("%s: device is NULL\n", __func__);
-		return -ENODEV;
-	}
-
-	if (!cdc_vreg || (num_supplies <= 0)) {
-		dev_err(dev, "%s: supply check failed: vreg: %pK, num_supplies: %d\n",
-			__func__, cdc_vreg, num_supplies);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-/*
- * msm_cdc_disable_static_supplies:
- *	Disable codec static supplies
- *
- * @dev: pointer to codec device
- * @supplies: pointer to regulator bulk data
- * @cdc_vreg: pointer to platform regulator data
- * @num_supplies: number of supplies
- *
- * Return error code if supply disable is failed
- */
-int msm_cdc_disable_static_supplies(struct device *dev,
-				    struct regulator_bulk_data *supplies,
-				    struct cdc_regulator *cdc_vreg,
-				    int num_supplies)
-{
-	int rc, i;
-
-	if ((!dev) || (!supplies) || (!cdc_vreg)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
-				__func__);
-		return -EINVAL;
-	}
-	/* input parameter validation */
-	rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
-	if (rc)
-		return rc;
-
-	for (i = 0; i < num_supplies; i++) {
-		if (cdc_vreg[i].ondemand)
-			continue;
-
-		rc = regulator_disable(supplies[i].consumer);
-		if (rc)
-			dev_err(dev, "%s: failed to disable supply %s, err:%d\n",
-				__func__, supplies[i].supply, rc);
-		else
-			dev_dbg(dev, "%s: disabled regulator %s\n",
-				__func__, supplies[i].supply);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_cdc_disable_static_supplies);
-
-/*
- * msm_cdc_release_supplies:
- *	Release codec power supplies
- *
- * @dev: pointer to codec device
- * @supplies: pointer to regulator bulk data
- * @cdc_vreg: pointer to platform regulator data
- * @num_supplies: number of supplies
- *
- * Return error code if supply disable is failed
- */
-int msm_cdc_release_supplies(struct device *dev,
-			     struct regulator_bulk_data *supplies,
-			     struct cdc_regulator *cdc_vreg,
-			     int num_supplies)
-{
-	int rc = 0;
-	int i;
-
-	if ((!dev) || (!supplies) || (!cdc_vreg)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
-				__func__);
-		return -EINVAL;
-	}
-	/* input parameter validation */
-	rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
-	if (rc)
-		return rc;
-
-	msm_cdc_disable_static_supplies(dev, supplies, cdc_vreg,
-					num_supplies);
-	for (i = 0; i < num_supplies; i++) {
-		if (regulator_count_voltages(supplies[i].consumer) < 0)
-			continue;
-
-		regulator_set_voltage(supplies[i].consumer, 0,
-				      cdc_vreg[i].max_uV);
-		regulator_set_load(supplies[i].consumer, 0);
-		devm_regulator_put(supplies[i].consumer);
-		supplies[i].consumer = NULL;
-	}
-	devm_kfree(dev, supplies);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_cdc_release_supplies);
-
-/*
- * msm_cdc_enable_static_supplies:
- *	Enable codec static supplies
- *
- * @dev: pointer to codec device
- * @supplies: pointer to regulator bulk data
- * @cdc_vreg: pointer to platform regulator data
- * @num_supplies: number of supplies
- *
- * Return error code if supply enable is failed
- */
-int msm_cdc_enable_static_supplies(struct device *dev,
-				   struct regulator_bulk_data *supplies,
-				   struct cdc_regulator *cdc_vreg,
-				   int num_supplies)
-{
-	int rc, i;
-
-	if ((!dev) || (!supplies) || (!cdc_vreg)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
-				__func__);
-		return -EINVAL;
-	}
-	/* input parameter validation */
-	rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
-	if (rc)
-		return rc;
-
-	for (i = 0; i < num_supplies; i++) {
-		if (cdc_vreg[i].ondemand)
-			continue;
-
-		rc = regulator_enable(supplies[i].consumer);
-		if (rc) {
-			dev_err(dev, "%s: failed to enable supply %s, rc: %d\n",
-				__func__, supplies[i].supply, rc);
-			break;
-		}
-	}
-
-	while (rc && i--)
-		if (!cdc_vreg[i].ondemand)
-			regulator_disable(supplies[i].consumer);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_cdc_enable_static_supplies);
-
-/*
- * msm_cdc_init_supplies:
- *	Initialize codec static supplies with regulator get
- *
- * @dev: pointer to codec device
- * @supplies: pointer to regulator bulk data
- * @cdc_vreg: pointer to platform regulator data
- * @num_supplies: number of supplies
- *
- * Return error code if supply init is failed
- */
-int msm_cdc_init_supplies(struct device *dev,
-			  struct regulator_bulk_data **supplies,
-			  struct cdc_regulator *cdc_vreg,
-			  int num_supplies)
-{
-	struct regulator_bulk_data *vsup;
-	int rc;
-	int i;
-
-	if (!dev || !cdc_vreg) {
-		pr_err("%s: device pointer or dce_vreg is NULL\n",
-				__func__);
-		return -EINVAL;
-	}
-	/* input parameter validation */
-	rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
-	if (rc)
-		return rc;
-
-	vsup = devm_kcalloc(dev, num_supplies,
-			    sizeof(struct regulator_bulk_data),
-			    GFP_KERNEL);
-	if (!vsup)
-		return -ENOMEM;
-
-	for (i = 0; i < num_supplies; i++) {
-		if (!cdc_vreg[i].name) {
-			dev_err(dev, "%s: supply name not defined\n",
-				__func__);
-			rc = -EINVAL;
-			goto err_supply;
-		}
-		vsup[i].supply = cdc_vreg[i].name;
-	}
-
-	rc = devm_regulator_bulk_get(dev, num_supplies, vsup);
-	if (rc) {
-		dev_err(dev, "%s: failed to get supplies (%d)\n",
-			__func__, rc);
-		goto err_supply;
-	}
-
-	/* Set voltage and current on regulators */
-	for (i = 0; i < num_supplies; i++) {
-		if (regulator_count_voltages(vsup[i].consumer) < 0)
-			continue;
-
-		rc = regulator_set_voltage(vsup[i].consumer,
-					   cdc_vreg[i].min_uV,
-					   cdc_vreg[i].max_uV);
-		if (rc) {
-			dev_err(dev, "%s: set regulator voltage failed for %s, err:%d\n",
-				__func__, vsup[i].supply, rc);
-			goto err_set_supply;
-		}
-		rc = regulator_set_load(vsup[i].consumer,
-					cdc_vreg[i].optimum_uA);
-		if (rc < 0) {
-			dev_err(dev, "%s: set regulator optimum mode failed for %s, err:%d\n",
-				__func__, vsup[i].supply, rc);
-			goto err_set_supply;
-		}
-	}
-
-	*supplies = vsup;
-
-	return 0;
-
-err_set_supply:
-	for (i = 0; i < num_supplies; i++)
-		devm_regulator_put(vsup[i].consumer);
-err_supply:
-	devm_kfree(dev, vsup);
-	return rc;
-}
-EXPORT_SYMBOL(msm_cdc_init_supplies);
-
-/*
- * msm_cdc_get_power_supplies:
- *	Get codec power supplies from device tree.
- *	Allocate memory to hold regulator data for
- *	all power supplies.
- *
- * @dev: pointer to codec device
- * @cdc_vreg: pointer to codec regulator
- * @total_num_supplies: total number of supplies read from DT
- *
- * Return error code if supply disable is failed
- */
-int msm_cdc_get_power_supplies(struct device *dev,
-			       struct cdc_regulator **cdc_vreg,
-			       int *total_num_supplies)
-{
-	const char *static_prop_name = "qcom,cdc-static-supplies";
-	const char *ond_prop_name = "qcom,cdc-on-demand-supplies";
-	const char *cp_prop_name = "qcom,cdc-cp-supplies";
-	int static_sup_cnt = 0;
-	int ond_sup_cnt = 0;
-	int cp_sup_cnt = 0;
-	int num_supplies = 0;
-	struct cdc_regulator *cdc_reg;
-	int rc;
-
-	if (!dev) {
-		pr_err("%s: device pointer is NULL\n", __func__);
-		return -EINVAL;
-	}
-	static_sup_cnt = of_property_count_strings(dev->of_node,
-						   static_prop_name);
-	if (static_sup_cnt < 0) {
-		dev_err(dev, "%s: Failed to get static supplies(%d)\n",
-			__func__, static_sup_cnt);
-		rc = static_sup_cnt;
-		goto err_supply_cnt;
-	}
-	ond_sup_cnt = of_property_count_strings(dev->of_node, ond_prop_name);
-	if (ond_sup_cnt < 0)
-		ond_sup_cnt = 0;
-
-	cp_sup_cnt = of_property_count_strings(dev->of_node,
-					       cp_prop_name);
-	if (cp_sup_cnt < 0)
-		cp_sup_cnt = 0;
-
-	num_supplies = static_sup_cnt + ond_sup_cnt + cp_sup_cnt;
-	if (num_supplies <= 0) {
-		dev_err(dev, "%s: supply count is 0 or negative\n", __func__);
-		rc = -EINVAL;
-		goto err_supply_cnt;
-	}
-
-	cdc_reg = devm_kcalloc(dev, num_supplies,
-			       sizeof(struct cdc_regulator),
-			       GFP_KERNEL);
-	if (!cdc_reg) {
-		rc = -ENOMEM;
-		goto err_mem_alloc;
-	}
-
-	rc = msm_cdc_parse_supplies(dev, cdc_reg, static_prop_name,
-				    static_sup_cnt, false);
-	if (rc) {
-		dev_err(dev, "%s: failed to parse static supplies(%d)\n",
-				__func__, rc);
-		goto err_sup;
-	}
-
-	rc = msm_cdc_parse_supplies(dev, &cdc_reg[static_sup_cnt],
-				    ond_prop_name, ond_sup_cnt,
-				    true);
-	if (rc) {
-		dev_err(dev, "%s: failed to parse demand supplies(%d)\n",
-				__func__, rc);
-		goto err_sup;
-	}
-
-	rc = msm_cdc_parse_supplies(dev,
-				    &cdc_reg[static_sup_cnt + ond_sup_cnt],
-				    cp_prop_name, cp_sup_cnt, true);
-	if (rc) {
-		dev_err(dev, "%s: failed to parse cp supplies(%d)\n",
-				__func__, rc);
-		goto err_sup;
-	}
-
-	*cdc_vreg = cdc_reg;
-	*total_num_supplies = num_supplies;
-
-	return 0;
-
-err_sup:
-	devm_kfree(dev, cdc_reg);
-err_supply_cnt:
-err_mem_alloc:
-	return rc;
-}
-EXPORT_SYMBOL(msm_cdc_get_power_supplies);
diff --git a/drivers/mfd/qcom-i2c-pmic.c b/drivers/mfd/qcom-i2c-pmic.c
index 590e4c1..28c3343 100644
--- a/drivers/mfd/qcom-i2c-pmic.c
+++ b/drivers/mfd/qcom-i2c-pmic.c
@@ -62,8 +62,12 @@
 	struct irq_domain	*domain;
 	struct i2c_pmic_periph	*periph;
 	struct pinctrl		*pinctrl;
+	struct mutex		irq_complete;
 	const char		*pinctrl_name;
 	int			num_periphs;
+	int			summary_irq;
+	bool			resume_completed;
+	bool			irq_waiting;
 };
 
 static void i2c_pmic_irq_bus_lock(struct irq_data *d)
@@ -400,6 +404,16 @@
 	unsigned int summary_status;
 	int rc, i;
 
+	mutex_lock(&chip->irq_complete);
+	chip->irq_waiting = true;
+	if (!chip->resume_completed) {
+		pr_debug("IRQ triggered before device-resume\n");
+		disable_irq_nosync(irq);
+		mutex_unlock(&chip->irq_complete);
+		return IRQ_HANDLED;
+	}
+	chip->irq_waiting = false;
+
 	for (i = 0; i < DIV_ROUND_UP(chip->num_periphs, BITS_PER_BYTE); i++) {
 		rc = regmap_read(chip->regmap, I2C_INTR_STATUS_BASE + i,
 				&summary_status);
@@ -416,6 +430,8 @@
 		i2c_pmic_summary_status_handler(chip, periph, summary_status);
 	}
 
+	mutex_unlock(&chip->irq_complete);
+
 	return IRQ_HANDLED;
 }
 
@@ -559,6 +575,9 @@
 		}
 	}
 
+	chip->resume_completed = true;
+	mutex_init(&chip->irq_complete);
+
 	rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 				       i2c_pmic_irq_handler,
 				       IRQF_ONESHOT | IRQF_SHARED,
@@ -568,6 +587,7 @@
 		goto cleanup;
 	}
 
+	chip->summary_irq = client->irq;
 	enable_irq_wake(client->irq);
 
 probe_children:
@@ -594,6 +614,17 @@
 }
 
 #ifdef CONFIG_PM_SLEEP
+static int i2c_pmic_suspend_noirq(struct device *dev)
+{
+	struct i2c_pmic *chip = dev_get_drvdata(dev);
+
+	if (chip->irq_waiting) {
+		pr_err_ratelimited("Aborting suspend, an interrupt was detected while suspending\n");
+		return -EBUSY;
+	}
+	return 0;
+}
+
 static int i2c_pmic_suspend(struct device *dev)
 {
 	struct i2c_pmic *chip = dev_get_drvdata(dev);
@@ -618,6 +649,11 @@
 			pr_err_ratelimited("Couldn't enable 0x%04x wake irqs 0x%02x rc=%d\n",
 			       periph->addr, periph->wake, rc);
 	}
+	if (!rc) {
+		mutex_lock(&chip->irq_complete);
+		chip->resume_completed = false;
+		mutex_unlock(&chip->irq_complete);
+	}
 
 	return rc;
 }
@@ -647,10 +683,38 @@
 			       periph->addr, periph->synced[IRQ_EN_SET], rc);
 	}
 
+	mutex_lock(&chip->irq_complete);
+	chip->resume_completed = true;
+	if (chip->irq_waiting) {
+		mutex_unlock(&chip->irq_complete);
+		/* irq was pending, call the handler */
+		i2c_pmic_irq_handler(chip->summary_irq, chip);
+		enable_irq(chip->summary_irq);
+	} else {
+		mutex_unlock(&chip->irq_complete);
+	}
+
 	return rc;
 }
+#else
+static int i2c_pmic_suspend(struct device *dev)
+{
+	return 0;
+}
+static int i2c_pmic_resume(struct device *dev)
+{
+	return 0;
+}
+static int i2c_pmic_suspend_noirq(struct device *dev)
+{
+	return 0
+}
 #endif
-static SIMPLE_DEV_PM_OPS(i2c_pmic_pm_ops, i2c_pmic_suspend, i2c_pmic_resume);
+static const struct dev_pm_ops i2c_pmic_pm_ops = {
+	.suspend	= i2c_pmic_suspend,
+	.suspend_noirq	= i2c_pmic_suspend_noirq,
+	.resume		= i2c_pmic_resume,
+};
 
 static const struct of_device_id i2c_pmic_match_table[] = {
 	{ .compatible = "qcom,i2c-pmic", },
diff --git a/drivers/mfd/wcd9335-regmap.c b/drivers/mfd/wcd9335-regmap.c
deleted file mode 100644
index 1762374..0000000
--- a/drivers/mfd/wcd9335-regmap.c
+++ /dev/null
@@ -1,1611 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9335/registers.h>
-#include <linux/regmap.h>
-#include <linux/device.h>
-#include "wcd9xxx-regmap.h"
-
-static const struct reg_sequence wcd9335_1_x_defaults[] = {
-	{ WCD9335_CODEC_RPM_CLK_GATE,                     0x03,  0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,       0x1f,  0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0,           0x00,  0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,               0x00,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG,          0x00,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG,          0x00,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG,          0x00,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG,          0x00,  0x00 },
-	{ WCD9335_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD,       0x14,  0x00 },
-	{ WCD9335_CPE_SS_SS_ERROR_INT_MASK,               0x3f,  0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,              0x00,  0x00 },
-	{ WCD9335_BIAS_VBG_FINE_ADJ,                      0x55,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_2,                        0x6c,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_3,                        0x2d,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_8,                        0x6c,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_10,                       0x6c,  0x00 },
-	{ WCD9335_SIDO_SIDO_DRIVER_2,                     0x77,  0x00 },
-	{ WCD9335_SIDO_SIDO_DRIVER_3,                     0x77,  0x00 },
-	{ WCD9335_SIDO_SIDO_TEST_2,                       0x00,  0x00 },
-	{ WCD9335_MBHC_ZDET_ANA_CTL,                      0x00,  0x00 },
-	{ WCD9335_MBHC_FSM_DEBUG,                         0xc0,  0x00 },
-	{ WCD9335_TX_1_2_ATEST_REFCTL,                    0x08,  0x00 },
-	{ WCD9335_TX_3_4_ATEST_REFCTL,                    0x08,  0x00 },
-	{ WCD9335_TX_5_6_ATEST_REFCTL,                    0x08,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_1,                    0x67,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_4,                    0x5f,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_9,                    0x50,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_DAC_CTRL_1,                0x65,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_DAC_CTRL_4,                0x40,  0x00 },
-	{ WCD9335_RX_BIAS_HPH_PA,                         0xaa,  0x00 },
-	{ WCD9335_RX_BIAS_HPH_LOWPOWER,                   0x62,  0x00 },
-	{ WCD9335_HPH_PA_CTL2,                            0x40,  0x00 },
-	{ WCD9335_HPH_L_EN,                               0x00,  0x00 },
-	{ WCD9335_HPH_R_EN,                               0x00,  0x00 },
-	{ WCD9335_HPH_R_ATEST,                            0x50,  0x00 },
-	{ WCD9335_HPH_RDAC_LDO_CTL,                       0x00,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_CFG0,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_CFG1,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC2,                   0x00,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC3,                   0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER1_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER2_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER3_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER4_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER5_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER6_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER7_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_COMPANDER8_CTL7,                    0x0c,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_CFG1,                   0x04,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_CFG,                0x0e,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC0,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC1,                   0x00,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,               0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC0_CLK_RST_CTL_0,              0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC1_CLK_RST_CTL_0,              0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC2_CLK_RST_CTL_0,              0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC3_CLK_RST_CTL_0,              0x00,  0x00 },
-	{ WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,        0x00,  0x00 },
-	{ WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,              0x00,  0x00 },
-	{ WCD9335_TEST_DEBUG_NPL_DLY_TEST_2,              0x00,  0x00 },
-};
-
-static const struct reg_sequence wcd9335_2_0_defaults[] = {
-	{ WCD9335_CODEC_RPM_CLK_GATE,                     0x07,  0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,       0x3f,  0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0,           0x01,  0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,               0x10,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG,          0x08,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG,          0x08,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG,          0x08,  0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG,          0x08,  0x00 },
-	{ WCD9335_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD,       0x13,  0x00 },
-	{ WCD9335_CPE_SS_SS_ERROR_INT_MASK,               0xff,  0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,              0x40,  0x00 },
-	{ WCD9335_BIAS_VBG_FINE_ADJ,                      0xc5,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_2,                        0x92,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_3,                        0x35,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_8,                        0x6e,  0x00 },
-	{ WCD9335_SIDO_SIDO_CCL_10,                       0x6e,  0x00 },
-	{ WCD9335_SIDO_SIDO_DRIVER_2,                     0x55,  0x00 },
-	{ WCD9335_SIDO_SIDO_DRIVER_3,                     0x55,  0x00 },
-	{ WCD9335_SIDO_SIDO_TEST_2,                       0x0f,  0x00 },
-	{ WCD9335_MBHC_ZDET_ANA_CTL,                      0x0f,  0x00 },
-	{ WCD9335_TX_1_2_ATEST_REFCTL,                    0x0a,  0x00 },
-	{ WCD9335_TX_3_4_ATEST_REFCTL,                    0x0a,  0x00 },
-	{ WCD9335_TX_5_6_ATEST_REFCTL,                    0x0a,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_1,                    0xeb,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_4,                    0x7f,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_9,                    0x64,  0x00 },
-	{ WCD9335_FLYBACK_VNEG_DAC_CTRL_1,                0xed,  0x00 },
-	{ WCD9335_RX_BIAS_HPH_PA,                         0x9a,  0x00 },
-	{ WCD9335_RX_BIAS_HPH_LOWPOWER,                   0x82,  0x00 },
-	{ WCD9335_HPH_PA_CTL2,                            0x50,  0x00 },
-	{ WCD9335_HPH_L_EN,                               0x80,  0x00 },
-	{ WCD9335_HPH_R_EN,                               0x80,  0x00 },
-	{ WCD9335_HPH_R_ATEST,                            0x54,  0x00 },
-	{ WCD9335_HPH_RDAC_LDO_CTL,                       0x33,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_CFG0,                   0x10,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_CFG1,                   0x02,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC2,                   0x01,  0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC3,                   0x3c,  0x00 },
-	{ WCD9335_CDC_COMPANDER1_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER2_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER3_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER4_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER5_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER6_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER7_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_COMPANDER8_CTL7,                    0x08,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_CFG1,                   0x44,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_CFG,                0x1e,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC0,                   0xfc,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC1,                   0x08,  0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,               0x08,  0x00 },
-	{ WCD9335_SPLINE_SRC0_CLK_RST_CTL_0,              0x20,  0x00 },
-	{ WCD9335_SPLINE_SRC1_CLK_RST_CTL_0,              0x20,  0x00 },
-	{ WCD9335_SPLINE_SRC2_CLK_RST_CTL_0,              0x20,  0x00 },
-	{ WCD9335_SPLINE_SRC3_CLK_RST_CTL_0,              0x20,  0x00 },
-	{ WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,        0x0c,  0x00 },
-	{ WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,              0x10,  0x00 },
-	{ WCD9335_TEST_DEBUG_NPL_DLY_TEST_2,              0x60,  0x00 },
-	{ WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,              0x00,  0x00 },
-	{ WCD9335_DATA_HUB_NATIVE_FIFO_STATUS,            0x00,  0x00 },
-	{ WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,            0x60,  0x00 },
-	{ WCD9335_CPE_SS_TX_PP_CFG,                       0x3C,  0x00 },
-	{ WCD9335_CPE_SS_SVA_CFG,                         0x00,  0x00 },
-	{ WCD9335_MBHC_FSM_STATUS,                        0x00,  0x00 },
-	{ WCD9335_FLYBACK_CTRL_1,                         0x45,  0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC7,                   0x25,  0x00 },
-	{ WCD9335_SPLINE_SRC0_STATUS,                     0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC1_STATUS,                     0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC2_STATUS,                     0x00,  0x00 },
-	{ WCD9335_SPLINE_SRC3_STATUS,                     0x00,  0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT,    0x00,  0x00 },
-};
-
-static const struct reg_default wcd9335_defaults[] = {
-	/* Page #0 registers */
-	{ WCD9335_PAGE0_PAGE_REGISTER,                    0x00 },
-	{ WCD9335_CODEC_RPM_CLK_BYPASS,                   0x00 },
-	{ WCD9335_CODEC_RPM_CLK_MCLK_CFG,                 0x00 },
-	{ WCD9335_CODEC_RPM_RST_CTL,                      0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,           0x07 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_1,            0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_2,            0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_3,            0x00 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_IRAM_SHUTDOWN,        0x01 },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_1,     0xff },
-	{ WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_2,     0xff },
-	{ WCD9335_CODEC_RPM_INT_MASK,                     0x3f },
-	{ WCD9335_CODEC_RPM_INT_STATUS,                   0x00 },
-	{ WCD9335_CODEC_RPM_INT_CLEAR,                    0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE1,           0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE2,           0x07 },
-	{ WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE3,           0x01 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_TEST0,             0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_TEST1,             0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT3,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT4,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT5,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT6,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT7,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT8,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT9,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT13,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT14,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT15,         0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS,            0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO,    0x0d },
-	{ WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_1,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_2,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_3,          0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL,      0xCC },
-	{ WCD9335_CHIP_TIER_CTRL_I2C_ACTIVE,              0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC1_MON_CTL,           0x06 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC1_MON_STATUS,        0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_MSB,       0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_LSB,       0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC2_MON_CTL,           0x06 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC2_MON_STATUS,        0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_MSB,       0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_LSB,       0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC3_MON_CTL,           0x06 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC3_MON_STATUS,        0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_MSB,       0x00 },
-	{ WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_LSB,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,           0x0c },
-	{ WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,           0x0c },
-	{ WCD9335_DATA_HUB_DATA_HUB_I2S_CLK,              0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX4_INP_CFG,          0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX5_INP_CFG,          0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX6_INP_CFG,          0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_RX7_INP_CFG,          0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX0_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX1_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX2_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX3_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX4_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX5_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX6_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX7_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX8_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX9_INP_CFG,       0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX10_INP_CFG,      0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG,      0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,      0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX14_INP_CFG,      0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_SB_TX15_INP_CFG,      0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,     0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,     0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,     0x00 },
-	{ WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,     0x00 },
-	{ WCD9335_INTR_CFG,                               0x00 },
-	{ WCD9335_INTR_CLR_COMMIT,                        0x00 },
-	{ WCD9335_INTR_PIN1_MASK0,                        0xff },
-	{ WCD9335_INTR_PIN1_MASK1,                        0xff },
-	{ WCD9335_INTR_PIN1_MASK2,                        0xff },
-	{ WCD9335_INTR_PIN1_MASK3,                        0xff },
-	{ WCD9335_INTR_PIN1_STATUS0,                      0x00 },
-	{ WCD9335_INTR_PIN1_STATUS1,                      0x00 },
-	{ WCD9335_INTR_PIN1_STATUS2,                      0x00 },
-	{ WCD9335_INTR_PIN1_STATUS3,                      0x00 },
-	{ WCD9335_INTR_PIN1_CLEAR0,                       0x00 },
-	{ WCD9335_INTR_PIN1_CLEAR1,                       0x00 },
-	{ WCD9335_INTR_PIN1_CLEAR2,                       0x00 },
-	{ WCD9335_INTR_PIN1_CLEAR3,                       0x00 },
-	{ WCD9335_INTR_PIN2_MASK0,                        0xff },
-	{ WCD9335_INTR_PIN2_MASK1,                        0xff },
-	{ WCD9335_INTR_PIN2_MASK2,                        0xff },
-	{ WCD9335_INTR_PIN2_MASK3,                        0xff },
-	{ WCD9335_INTR_PIN2_STATUS0,                      0x00 },
-	{ WCD9335_INTR_PIN2_STATUS1,                      0x00 },
-	{ WCD9335_INTR_PIN2_STATUS2,                      0x00 },
-	{ WCD9335_INTR_PIN2_STATUS3,                      0x00 },
-	{ WCD9335_INTR_PIN2_CLEAR0,                       0x00 },
-	{ WCD9335_INTR_PIN2_CLEAR1,                       0x00 },
-	{ WCD9335_INTR_PIN2_CLEAR2,                       0x00 },
-	{ WCD9335_INTR_PIN2_CLEAR3,                       0x00 },
-	{ WCD9335_INTR_LEVEL0,                            0x03 },
-	{ WCD9335_INTR_LEVEL1,                            0xe0 },
-	{ WCD9335_INTR_LEVEL2,                            0x10 },
-	{ WCD9335_INTR_LEVEL3,                            0x80 },
-	{ WCD9335_INTR_BYPASS0,                           0x00 },
-	{ WCD9335_INTR_BYPASS1,                           0x00 },
-	{ WCD9335_INTR_BYPASS2,                           0x00 },
-	{ WCD9335_INTR_BYPASS3,                           0x00 },
-	{ WCD9335_INTR_SET0,                              0x00 },
-	{ WCD9335_INTR_SET1,                              0x00 },
-	{ WCD9335_INTR_SET2,                              0x00 },
-	{ WCD9335_INTR_SET3,                              0x00 },
-	/* Page #1 registers */
-	{ WCD9335_PAGE1_PAGE_REGISTER,                    0x00 },
-	{ WCD9335_CPE_FLL_USER_CTL_0,                     0x71 },
-	{ WCD9335_CPE_FLL_USER_CTL_1,                     0x34 },
-	{ WCD9335_CPE_FLL_USER_CTL_2,                     0x0b },
-	{ WCD9335_CPE_FLL_USER_CTL_3,                     0x02 },
-	{ WCD9335_CPE_FLL_USER_CTL_4,                     0x04 },
-	{ WCD9335_CPE_FLL_USER_CTL_5,                     0x02 },
-	{ WCD9335_CPE_FLL_USER_CTL_6,                     0x64 },
-	{ WCD9335_CPE_FLL_USER_CTL_7,                     0x00 },
-	{ WCD9335_CPE_FLL_USER_CTL_8,                     0x94 },
-	{ WCD9335_CPE_FLL_USER_CTL_9,                     0x70 },
-	{ WCD9335_CPE_FLL_L_VAL_CTL_0,                    0x40 },
-	{ WCD9335_CPE_FLL_L_VAL_CTL_1,                    0x00 },
-	{ WCD9335_CPE_FLL_DSM_FRAC_CTL_0,                 0x00 },
-	{ WCD9335_CPE_FLL_DSM_FRAC_CTL_1,                 0xff },
-	{ WCD9335_CPE_FLL_CONFIG_CTL_0,                   0x6b },
-	{ WCD9335_CPE_FLL_CONFIG_CTL_1,                   0x05 },
-	{ WCD9335_CPE_FLL_CONFIG_CTL_2,                   0x08 },
-	{ WCD9335_CPE_FLL_CONFIG_CTL_3,                   0x00 },
-	{ WCD9335_CPE_FLL_CONFIG_CTL_4,                   0x10 },
-	{ WCD9335_CPE_FLL_TEST_CTL_0,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_1,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_2,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_3,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_4,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_5,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_6,                     0x00 },
-	{ WCD9335_CPE_FLL_TEST_CTL_7,                     0x33 },
-	{ WCD9335_CPE_FLL_FREQ_CTL_0,                     0x00 },
-	{ WCD9335_CPE_FLL_FREQ_CTL_1,                     0x00 },
-	{ WCD9335_CPE_FLL_FREQ_CTL_2,                     0x00 },
-	{ WCD9335_CPE_FLL_FREQ_CTL_3,                     0x00 },
-	{ WCD9335_CPE_FLL_SSC_CTL_0,                      0x00 },
-	{ WCD9335_CPE_FLL_SSC_CTL_1,                      0x00 },
-	{ WCD9335_CPE_FLL_SSC_CTL_2,                      0x00 },
-	{ WCD9335_CPE_FLL_SSC_CTL_3,                      0x00 },
-	{ WCD9335_CPE_FLL_FLL_MODE,                       0x20 },
-	{ WCD9335_CPE_FLL_STATUS_0,                       0x00 },
-	{ WCD9335_CPE_FLL_STATUS_1,                       0x00 },
-	{ WCD9335_CPE_FLL_STATUS_2,                       0x00 },
-	{ WCD9335_CPE_FLL_STATUS_3,                       0x00 },
-	{ WCD9335_I2S_FLL_USER_CTL_0,                     0x41 },
-	{ WCD9335_I2S_FLL_USER_CTL_1,                     0x94 },
-	{ WCD9335_I2S_FLL_USER_CTL_2,                     0x08 },
-	{ WCD9335_I2S_FLL_USER_CTL_3,                     0x02 },
-	{ WCD9335_I2S_FLL_USER_CTL_4,                     0x04 },
-	{ WCD9335_I2S_FLL_USER_CTL_5,                     0x02 },
-	{ WCD9335_I2S_FLL_USER_CTL_6,                     0x40 },
-	{ WCD9335_I2S_FLL_USER_CTL_7,                     0x00 },
-	{ WCD9335_I2S_FLL_USER_CTL_8,                     0x5f },
-	{ WCD9335_I2S_FLL_USER_CTL_9,                     0x02 },
-	{ WCD9335_I2S_FLL_L_VAL_CTL_0,                    0x40 },
-	{ WCD9335_I2S_FLL_L_VAL_CTL_1,                    0x00 },
-	{ WCD9335_I2S_FLL_DSM_FRAC_CTL_0,                 0x00 },
-	{ WCD9335_I2S_FLL_DSM_FRAC_CTL_1,                 0xff },
-	{ WCD9335_I2S_FLL_CONFIG_CTL_0,                   0x6b },
-	{ WCD9335_I2S_FLL_CONFIG_CTL_1,                   0x05 },
-	{ WCD9335_I2S_FLL_CONFIG_CTL_2,                   0x08 },
-	{ WCD9335_I2S_FLL_CONFIG_CTL_3,                   0x00 },
-	{ WCD9335_I2S_FLL_CONFIG_CTL_4,                   0x30 },
-	{ WCD9335_I2S_FLL_TEST_CTL_0,                     0x80 },
-	{ WCD9335_I2S_FLL_TEST_CTL_1,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_2,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_3,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_4,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_5,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_6,                     0x00 },
-	{ WCD9335_I2S_FLL_TEST_CTL_7,                     0xff },
-	{ WCD9335_I2S_FLL_FREQ_CTL_0,                     0x00 },
-	{ WCD9335_I2S_FLL_FREQ_CTL_1,                     0x00 },
-	{ WCD9335_I2S_FLL_FREQ_CTL_2,                     0x00 },
-	{ WCD9335_I2S_FLL_FREQ_CTL_3,                     0x00 },
-	{ WCD9335_I2S_FLL_SSC_CTL_0,                      0x00 },
-	{ WCD9335_I2S_FLL_SSC_CTL_1,                      0x00 },
-	{ WCD9335_I2S_FLL_SSC_CTL_2,                      0x00 },
-	{ WCD9335_I2S_FLL_SSC_CTL_3,                      0x00 },
-	{ WCD9335_I2S_FLL_FLL_MODE,                       0x00 },
-	{ WCD9335_I2S_FLL_STATUS_0,                       0x00 },
-	{ WCD9335_I2S_FLL_STATUS_1,                       0x00 },
-	{ WCD9335_I2S_FLL_STATUS_2,                       0x00 },
-	{ WCD9335_I2S_FLL_STATUS_3,                       0x00 },
-	{ WCD9335_SB_FLL_USER_CTL_0,                      0x41 },
-	{ WCD9335_SB_FLL_USER_CTL_1,                      0x94 },
-	{ WCD9335_SB_FLL_USER_CTL_2,                      0x08 },
-	{ WCD9335_SB_FLL_USER_CTL_3,                      0x02 },
-	{ WCD9335_SB_FLL_USER_CTL_4,                      0x04 },
-	{ WCD9335_SB_FLL_USER_CTL_5,                      0x02 },
-	{ WCD9335_SB_FLL_USER_CTL_6,                      0x40 },
-	{ WCD9335_SB_FLL_USER_CTL_7,                      0x00 },
-	{ WCD9335_SB_FLL_USER_CTL_8,                      0x5e },
-	{ WCD9335_SB_FLL_USER_CTL_9,                      0x01 },
-	{ WCD9335_SB_FLL_L_VAL_CTL_0,                     0x40 },
-	{ WCD9335_SB_FLL_L_VAL_CTL_1,                     0x00 },
-	{ WCD9335_SB_FLL_DSM_FRAC_CTL_0,                  0x00 },
-	{ WCD9335_SB_FLL_DSM_FRAC_CTL_1,                  0xff },
-	{ WCD9335_SB_FLL_CONFIG_CTL_0,                    0x6b },
-	{ WCD9335_SB_FLL_CONFIG_CTL_1,                    0x05 },
-	{ WCD9335_SB_FLL_CONFIG_CTL_2,                    0x08 },
-	{ WCD9335_SB_FLL_CONFIG_CTL_3,                    0x00 },
-	{ WCD9335_SB_FLL_CONFIG_CTL_4,                    0x10 },
-	{ WCD9335_SB_FLL_TEST_CTL_0,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_1,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_2,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_3,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_4,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_5,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_6,                      0x00 },
-	{ WCD9335_SB_FLL_TEST_CTL_7,                      0xff },
-	{ WCD9335_SB_FLL_FREQ_CTL_0,                      0x00 },
-	{ WCD9335_SB_FLL_FREQ_CTL_1,                      0x00 },
-	{ WCD9335_SB_FLL_FREQ_CTL_2,                      0x00 },
-	{ WCD9335_SB_FLL_FREQ_CTL_3,                      0x00 },
-	{ WCD9335_SB_FLL_SSC_CTL_0,                       0x00 },
-	{ WCD9335_SB_FLL_SSC_CTL_1,                       0x00 },
-	{ WCD9335_SB_FLL_SSC_CTL_2,                       0x00 },
-	{ WCD9335_SB_FLL_SSC_CTL_3,                       0x00 },
-	{ WCD9335_SB_FLL_FLL_MODE,                        0x00 },
-	{ WCD9335_SB_FLL_STATUS_0,                        0x00 },
-	{ WCD9335_SB_FLL_STATUS_1,                        0x00 },
-	{ WCD9335_SB_FLL_STATUS_2,                        0x00 },
-	{ WCD9335_SB_FLL_STATUS_3,                        0x00 },
-	/* Page #2 registers */
-	{ WCD9335_PAGE2_PAGE_REGISTER,                    0x00 },
-	{ WCD9335_CPE_SS_MEM_PTR_0,                       0x00 },
-	{ WCD9335_CPE_SS_MEM_PTR_1,                       0x00 },
-	{ WCD9335_CPE_SS_MEM_PTR_2,                       0x00 },
-	{ WCD9335_CPE_SS_MEM_CTRL,                        0x08 },
-	{ WCD9335_CPE_SS_MEM_BANK_0,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_1,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_2,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_3,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_4,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_5,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_6,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_7,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_8,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_9,                      0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_10,                     0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_11,                     0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_12,                     0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_13,                     0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_14,                     0x00 },
-	{ WCD9335_CPE_SS_MEM_BANK_15,                     0x00 },
-	{ WCD9335_CPE_SS_INBOX1_TRG,                      0x00 },
-	{ WCD9335_CPE_SS_INBOX2_TRG,                      0x00 },
-	{ WCD9335_CPE_SS_INBOX1_0,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_1,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_2,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_3,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_4,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_5,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_6,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_7,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_8,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_9,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX1_10,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX1_11,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX1_12,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX1_13,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX1_14,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX1_15,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_0,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_1,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_2,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_3,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_4,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_5,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_6,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_7,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_8,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_9,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_10,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_11,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_12,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_13,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_14,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_15,                      0x00 },
-	{ WCD9335_CPE_SS_INBOX2_0,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_1,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_2,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_3,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_4,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_5,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_6,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_7,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_8,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_9,                        0x00 },
-	{ WCD9335_CPE_SS_INBOX2_10,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX2_11,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX2_12,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX2_13,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX2_14,                       0x00 },
-	{ WCD9335_CPE_SS_INBOX2_15,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_0,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_1,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_2,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_3,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_4,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_5,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_6,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_7,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_8,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_9,                       0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_10,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_11,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_12,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_13,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_14,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_15,                      0x00 },
-	{ WCD9335_CPE_SS_OUTBOX1_ACK,                     0x00 },
-	{ WCD9335_CPE_SS_OUTBOX2_ACK,                     0x00 },
-	{ WCD9335_CPE_SS_EC_BUF_INT_PERIOD,               0x3c },
-	{ WCD9335_CPE_SS_US_BUF_INT_PERIOD,               0x60 },
-	{ WCD9335_CPE_SS_CFG,                             0x41 },
-	{ WCD9335_CPE_SS_US_EC_MUX_CFG,                   0x00 },
-	{ WCD9335_CPE_SS_MAD_CTL,                         0x00 },
-	{ WCD9335_CPE_SS_CPAR_CTL,                        0x00 },
-	{ WCD9335_CPE_SS_DMIC0_CTL,                       0x00 },
-	{ WCD9335_CPE_SS_DMIC1_CTL,                       0x00 },
-	{ WCD9335_CPE_SS_DMIC2_CTL,                       0x00 },
-	{ WCD9335_CPE_SS_DMIC_CFG,                        0x80 },
-	{ WCD9335_CPE_SS_CPAR_CFG,                        0x00 },
-	{ WCD9335_CPE_SS_WDOG_CFG,                        0x01 },
-	{ WCD9335_CPE_SS_BACKUP_INT,                      0x00 },
-	{ WCD9335_CPE_SS_STATUS,                          0x00 },
-	{ WCD9335_CPE_SS_CPE_OCD_CFG,                     0x00 },
-	{ WCD9335_CPE_SS_SS_ERROR_INT_STATUS,             0x00 },
-	{ WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,              0x00 },
-	{ WCD9335_SOC_MAD_MAIN_CTL_1,                     0x00 },
-	{ WCD9335_SOC_MAD_MAIN_CTL_2,                     0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_1,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_2,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_3,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_4,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_5,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_6,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_7,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_CTL_8,                    0x00 },
-	{ WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,              0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_1,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_2,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_3,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_4,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_5,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_6,                     0x00 },
-	{ WCD9335_SOC_MAD_ULTR_CTL_7,                     0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_1,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_2,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_3,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_4,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_5,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_6,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_7,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_CTL_8,                   0x00 },
-	{ WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,             0x00 },
-	{ WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,             0x00 },
-	{ WCD9335_SOC_MAD_INP_SEL,                        0x00 },
-	/* Page #6 registers */
-	{ WCD9335_PAGE6_PAGE_REGISTER,                    0x00 },
-	{ WCD9335_ANA_BIAS,                               0x00 },
-	{ WCD9335_ANA_CLK_TOP,                            0x00 },
-	{ WCD9335_ANA_RCO,                                0x30 },
-	{ WCD9335_ANA_BUCK_VOUT_A,                        0xb4 },
-	{ WCD9335_ANA_BUCK_VOUT_D,                        0xb4 },
-	{ WCD9335_ANA_BUCK_CTL,                           0x00 },
-	{ WCD9335_ANA_BUCK_STATUS,                        0xe0 },
-	{ WCD9335_ANA_RX_SUPPLIES,                        0x00 },
-	{ WCD9335_ANA_HPH,                                0x00 },
-	{ WCD9335_ANA_EAR,                                0x00 },
-	{ WCD9335_ANA_LO_1_2,                             0x00 },
-	{ WCD9335_ANA_LO_3_4,                             0x00 },
-	{ WCD9335_ANA_MAD_SETUP,                          0x81 },
-	{ WCD9335_ANA_AMIC1,                              0x20 },
-	{ WCD9335_ANA_AMIC2,                              0x00 },
-	{ WCD9335_ANA_AMIC3,                              0x20 },
-	{ WCD9335_ANA_AMIC4,                              0x00 },
-	{ WCD9335_ANA_AMIC5,                              0x20 },
-	{ WCD9335_ANA_AMIC6,                              0x00 },
-	{ WCD9335_ANA_MBHC_MECH,                          0x39 },
-	{ WCD9335_ANA_MBHC_ELECT,                         0x08 },
-	{ WCD9335_ANA_MBHC_ZDET,                          0x00 },
-	{ WCD9335_ANA_MBHC_RESULT_1,                      0x00 },
-	{ WCD9335_ANA_MBHC_RESULT_2,                      0x00 },
-	{ WCD9335_ANA_MBHC_RESULT_3,                      0x00 },
-	{ WCD9335_ANA_MBHC_BTN0,                          0x00 },
-	{ WCD9335_ANA_MBHC_BTN1,                          0x10 },
-	{ WCD9335_ANA_MBHC_BTN2,                          0x20 },
-	{ WCD9335_ANA_MBHC_BTN3,                          0x30 },
-	{ WCD9335_ANA_MBHC_BTN4,                          0x40 },
-	{ WCD9335_ANA_MBHC_BTN5,                          0x50 },
-	{ WCD9335_ANA_MBHC_BTN6,                          0x60 },
-	{ WCD9335_ANA_MBHC_BTN7,                          0x70 },
-	{ WCD9335_ANA_MICB1,                              0x10 },
-	{ WCD9335_ANA_MICB2,                              0x10 },
-	{ WCD9335_ANA_MICB2_RAMP,                         0x00 },
-	{ WCD9335_ANA_MICB3,                              0x10 },
-	{ WCD9335_ANA_MICB4,                              0x10 },
-	{ WCD9335_ANA_VBADC,                              0x00 },
-	{ WCD9335_BIAS_CTL,                               0x28 },
-	{ WCD9335_CLOCK_TEST_CTL,                         0x00 },
-	{ WCD9335_RCO_CTRL_1,                             0x44 },
-	{ WCD9335_RCO_CTRL_2,                             0x44 },
-	{ WCD9335_RCO_CAL,                                0x00 },
-	{ WCD9335_RCO_CAL_1,                              0x00 },
-	{ WCD9335_RCO_CAL_2,                              0x00 },
-	{ WCD9335_RCO_TEST_CTRL,                          0x00 },
-	{ WCD9335_RCO_CAL_OUT_1,                          0x00 },
-	{ WCD9335_RCO_CAL_OUT_2,                          0x00 },
-	{ WCD9335_RCO_CAL_OUT_3,                          0x00 },
-	{ WCD9335_RCO_CAL_OUT_4,                          0x00 },
-	{ WCD9335_RCO_CAL_OUT_5,                          0x00 },
-	{ WCD9335_SIDO_SIDO_MODE_1,                       0x84 },
-	{ WCD9335_SIDO_SIDO_MODE_2,                       0xfe },
-	{ WCD9335_SIDO_SIDO_MODE_3,                       0xf6 },
-	{ WCD9335_SIDO_SIDO_MODE_4,                       0x56 },
-	{ WCD9335_SIDO_SIDO_VCL_1,                        0x00 },
-	{ WCD9335_SIDO_SIDO_VCL_2,                        0x6c },
-	{ WCD9335_SIDO_SIDO_VCL_3,                        0x44 },
-	{ WCD9335_SIDO_SIDO_CCL_1,                        0x57 },
-	{ WCD9335_SIDO_SIDO_CCL_4,                        0x61 },
-	{ WCD9335_SIDO_SIDO_CCL_5,                        0x6d },
-	{ WCD9335_SIDO_SIDO_CCL_6,                        0x60 },
-	{ WCD9335_SIDO_SIDO_CCL_7,                        0x6f },
-	{ WCD9335_SIDO_SIDO_CCL_9,                        0x6e },
-	{ WCD9335_SIDO_SIDO_FILTER_1,                     0x92 },
-	{ WCD9335_SIDO_SIDO_FILTER_2,                     0x54 },
-	{ WCD9335_SIDO_SIDO_DRIVER_1,                     0x77 },
-	{ WCD9335_SIDO_SIDO_CAL_CODE_EXT_1,               0x9c },
-	{ WCD9335_SIDO_SIDO_CAL_CODE_EXT_2,               0x82 },
-	{ WCD9335_SIDO_SIDO_CAL_CODE_OUT_1,               0x00 },
-	{ WCD9335_SIDO_SIDO_CAL_CODE_OUT_2,               0x00 },
-	{ WCD9335_SIDO_SIDO_TEST_1,                       0x00 },
-	{ WCD9335_MBHC_CTL_1,                             0x32 },
-	{ WCD9335_MBHC_CTL_2,                             0x01 },
-	{ WCD9335_MBHC_PLUG_DETECT_CTL,                   0x69 },
-	{ WCD9335_MBHC_ZDET_RAMP_CTL,                     0x00 },
-	{ WCD9335_MBHC_TEST_CTL,                          0x00 },
-	{ WCD9335_VBADC_SUBBLOCK_EN,                      0xfe },
-	{ WCD9335_VBADC_IBIAS_FE,                         0x54 },
-	{ WCD9335_VBADC_BIAS_ADC,                         0x51 },
-	{ WCD9335_VBADC_FE_CTRL,                          0x1c },
-	{ WCD9335_VBADC_ADC_REF,                          0x20 },
-	{ WCD9335_VBADC_ADC_IO,                           0x80 },
-	{ WCD9335_VBADC_ADC_SAR,                          0xff },
-	{ WCD9335_VBADC_DEBUG,                            0x00 },
-	{ WCD9335_VBADC_ADC_DOUTMSB,                      0x00 },
-	{ WCD9335_VBADC_ADC_DOUTLSB,                      0x00 },
-	{ WCD9335_LDOH_MODE,                              0x2b },
-	{ WCD9335_LDOH_BIAS,                              0x68 },
-	{ WCD9335_LDOH_STB_LOADS,                         0x00 },
-	{ WCD9335_LDOH_SLOWRAMP,                          0x50 },
-	{ WCD9335_MICB1_TEST_CTL_1,                       0x1a },
-	{ WCD9335_MICB1_TEST_CTL_2,                       0x18 },
-	{ WCD9335_MICB1_TEST_CTL_3,                       0xa4 },
-	{ WCD9335_MICB2_TEST_CTL_1,                       0x1a },
-	{ WCD9335_MICB2_TEST_CTL_2,                       0x18 },
-	{ WCD9335_MICB2_TEST_CTL_3,                       0x24 },
-	{ WCD9335_MICB3_TEST_CTL_1,                       0x1a },
-	{ WCD9335_MICB3_TEST_CTL_2,                       0x18 },
-	{ WCD9335_MICB3_TEST_CTL_3,                       0xa4 },
-	{ WCD9335_MICB4_TEST_CTL_1,                       0x1a },
-	{ WCD9335_MICB4_TEST_CTL_2,                       0x18 },
-	{ WCD9335_MICB4_TEST_CTL_3,                       0xa4 },
-	{ WCD9335_TX_COM_ADC_VCM,                         0x39 },
-	{ WCD9335_TX_COM_BIAS_ATEST,                      0xc0 },
-	{ WCD9335_TX_COM_ADC_INT1_IB,                     0x6f },
-	{ WCD9335_TX_COM_ADC_INT2_IB,                     0x4f },
-	{ WCD9335_TX_COM_TXFE_DIV_CTL,                    0x2e },
-	{ WCD9335_TX_COM_TXFE_DIV_START,                  0x00 },
-	{ WCD9335_TX_COM_TXFE_DIV_STOP_9P6M,              0xc7 },
-	{ WCD9335_TX_COM_TXFE_DIV_STOP_12P288M,           0xff },
-	{ WCD9335_TX_1_2_TEST_EN,                         0xcc },
-	{ WCD9335_TX_1_2_ADC_IB,                          0x09 },
-	{ WCD9335_TX_1_2_TEST_CTL,                        0x38 },
-	{ WCD9335_TX_1_2_TEST_BLK_EN,                     0xff },
-	{ WCD9335_TX_1_2_TXFE_CLKDIV,                     0x00 },
-	{ WCD9335_TX_1_2_SAR1_ERR,                        0x00 },
-	{ WCD9335_TX_1_2_SAR2_ERR,                        0x00 },
-	{ WCD9335_TX_3_4_TEST_EN,                         0xcc },
-	{ WCD9335_TX_3_4_ADC_IB,                          0x09 },
-	{ WCD9335_TX_3_4_TEST_CTL,                        0x38 },
-	{ WCD9335_TX_3_4_TEST_BLK_EN,                     0xff },
-	{ WCD9335_TX_3_4_TXFE_CLKDIV,                     0x00 },
-	{ WCD9335_TX_3_4_SAR1_ERR,                        0x00 },
-	{ WCD9335_TX_3_4_SAR2_ERR,                        0x00 },
-	{ WCD9335_TX_5_6_TEST_EN,                         0xcc },
-	{ WCD9335_TX_5_6_ADC_IB,                          0x09 },
-	{ WCD9335_TX_5_6_TEST_CTL,                        0x38 },
-	{ WCD9335_TX_5_6_TEST_BLK_EN,                     0xff },
-	{ WCD9335_TX_5_6_TXFE_CLKDIV,                     0x00 },
-	{ WCD9335_TX_5_6_SAR1_ERR,                        0x00 },
-	{ WCD9335_TX_5_6_SAR2_ERR,                        0x00 },
-	{ WCD9335_CLASSH_MODE_1,                          0x40 },
-	{ WCD9335_CLASSH_MODE_2,                          0x3a },
-	{ WCD9335_CLASSH_MODE_3,                          0x00 },
-	{ WCD9335_CLASSH_CTRL_VCL_1,                      0x70 },
-	{ WCD9335_CLASSH_CTRL_VCL_2,                      0xa2 },
-	{ WCD9335_CLASSH_CTRL_CCL_1,                      0x51 },
-	{ WCD9335_CLASSH_CTRL_CCL_2,                      0x80 },
-	{ WCD9335_CLASSH_CTRL_CCL_3,                      0x80 },
-	{ WCD9335_CLASSH_CTRL_CCL_4,                      0x51 },
-	{ WCD9335_CLASSH_CTRL_CCL_5,                      0x00 },
-	{ WCD9335_CLASSH_BUCK_TMUX_A_D,                   0x00 },
-	{ WCD9335_CLASSH_BUCK_SW_DRV_CNTL,                0x77 },
-	{ WCD9335_CLASSH_SPARE,                           0x00 },
-	{ WCD9335_FLYBACK_EN,                             0x4e },
-	{ WCD9335_FLYBACK_VNEG_CTRL_2,                    0x45 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_3,                    0x74 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_5,                    0x83 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_6,                    0x98 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_7,                    0xa9 },
-	{ WCD9335_FLYBACK_VNEG_CTRL_8,                    0x68 },
-	{ WCD9335_FLYBACK_VNEG_DAC_CTRL_2,                0x50 },
-	{ WCD9335_FLYBACK_VNEG_DAC_CTRL_3,                0xa6 },
-	{ WCD9335_FLYBACK_TEST_CTL,                       0x00 },
-	{ WCD9335_RX_AUX_SW_CTL,                          0x00 },
-	{ WCD9335_RX_PA_AUX_IN_CONN,                      0x00 },
-	{ WCD9335_RX_TIMER_DIV,                           0x74 },
-	{ WCD9335_RX_OCP_CTL,                             0x1f },
-	{ WCD9335_RX_OCP_COUNT,                           0x77 },
-	{ WCD9335_RX_BIAS_EAR_DAC,                        0xa0 },
-	{ WCD9335_RX_BIAS_EAR_AMP,                        0xaa },
-	{ WCD9335_RX_BIAS_HPH_LDO,                        0xa9 },
-	{ WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,              0x8a },
-	{ WCD9335_RX_BIAS_HPH_RDAC_LDO,                   0x88 },
-	{ WCD9335_RX_BIAS_HPH_CNP1,                       0x86 },
-	{ WCD9335_RX_BIAS_DIFFLO_PA,                      0x80 },
-	{ WCD9335_RX_BIAS_DIFFLO_REF,                     0x88 },
-	{ WCD9335_RX_BIAS_DIFFLO_LDO,                     0x88 },
-	{ WCD9335_RX_BIAS_SELO_DAC_PA,                    0xa8 },
-	{ WCD9335_RX_BIAS_BUCK_RST,                       0x08 },
-	{ WCD9335_RX_BIAS_BUCK_VREF_ERRAMP,               0x44 },
-	{ WCD9335_RX_BIAS_FLYB_ERRAMP,                    0x40 },
-	{ WCD9335_RX_BIAS_FLYB_BUFF,                      0xaa },
-	{ WCD9335_RX_BIAS_FLYB_MID_RST,                   0x44 },
-	{ WCD9335_HPH_L_STATUS,                           0x04 },
-	{ WCD9335_HPH_R_STATUS,                           0x04 },
-	{ WCD9335_HPH_CNP_EN,                             0x80 },
-	{ WCD9335_HPH_CNP_WG_CTL,                         0xda },
-	{ WCD9335_HPH_CNP_WG_TIME,                        0x15 },
-	{ WCD9335_HPH_OCP_CTL,                            0x28 },
-	{ WCD9335_HPH_AUTO_CHOP,                          0x12 },
-	{ WCD9335_HPH_CHOP_CTL,                           0x83 },
-	{ WCD9335_HPH_PA_CTL1,                            0x46 },
-	{ WCD9335_HPH_L_TEST,                             0x00 },
-	{ WCD9335_HPH_L_ATEST,                            0x50 },
-	{ WCD9335_HPH_R_TEST,                             0x00 },
-	{ WCD9335_HPH_RDAC_CLK_CTL1,                      0x99 },
-	{ WCD9335_HPH_RDAC_CLK_CTL2,                      0x9b },
-	{ WCD9335_HPH_RDAC_CHOP_CLK_LP_CTL,               0x00 },
-	{ WCD9335_HPH_REFBUFF_UHQA_CTL,                   0xa8 },
-	{ WCD9335_HPH_REFBUFF_LP_CTL,                     0x00 },
-	{ WCD9335_HPH_L_DAC_CTL,                          0x00 },
-	{ WCD9335_HPH_R_DAC_CTL,                          0x00 },
-	{ WCD9335_EAR_EN_REG,                             0x60 },
-	{ WCD9335_EAR_CMBUFF,                             0x0d },
-	{ WCD9335_EAR_ICTL,                               0x40 },
-	{ WCD9335_EAR_EN_DBG_CTL,                         0x00 },
-	{ WCD9335_EAR_CNP,                                0xe0 },
-	{ WCD9335_EAR_DAC_CTL_ATEST,                      0x00 },
-	{ WCD9335_EAR_STATUS_REG,                         0x04 },
-	{ WCD9335_EAR_OUT_SHORT,                          0x00 },
-	{ WCD9335_DIFF_LO_MISC,                           0x03 },
-	{ WCD9335_DIFF_LO_LO2_COMPANDER,                  0x00 },
-	{ WCD9335_DIFF_LO_LO1_COMPANDER,                  0x00 },
-	{ WCD9335_DIFF_LO_COMMON,                         0x40 },
-	{ WCD9335_DIFF_LO_BYPASS_EN,                      0x00 },
-	{ WCD9335_DIFF_LO_CNP,                            0x20 },
-	{ WCD9335_DIFF_LO_CORE_OUT_PROG,                  0x00 },
-	{ WCD9335_DIFF_LO_LDO_OUT_PROG,                   0x00 },
-	{ WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ,          0x9b },
-	{ WCD9335_DIFF_LO_COM_PA_FREQ,                    0xb0 },
-	{ WCD9335_DIFF_LO_RESERVED_REG,                   0x60 },
-	{ WCD9335_DIFF_LO_LO1_STATUS_1,                   0x00 },
-	{ WCD9335_DIFF_LO_LO1_STATUS_2,                   0x00 },
-	{ WCD9335_SE_LO_COM1,                             0x80 },
-	{ WCD9335_SE_LO_COM2,                             0x04 },
-	{ WCD9335_SE_LO_LO3_GAIN,                         0x20 },
-	{ WCD9335_SE_LO_LO3_CTRL,                         0x04 },
-	{ WCD9335_SE_LO_LO4_GAIN,                         0x20 },
-	{ WCD9335_SE_LO_LO4_CTRL,                         0x04 },
-	{ WCD9335_SE_LO_LO3_STATUS,                       0x00 },
-	{ WCD9335_SE_LO_LO4_STATUS,                       0x00 },
-	/* Page #10 registers */
-	{ WCD9335_PAGE10_PAGE_REGISTER,                   0x00 },
-	{ WCD9335_CDC_ANC0_CLK_RESET_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC0_MODE_1_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC0_MODE_2_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC0_FF_SHIFT,                      0x00 },
-	{ WCD9335_CDC_ANC0_FB_SHIFT,                      0x00 },
-	{ WCD9335_CDC_ANC0_LPF_FF_A_CTL,                  0x00 },
-	{ WCD9335_CDC_ANC0_LPF_FF_B_CTL,                  0x00 },
-	{ WCD9335_CDC_ANC0_LPF_FB_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC0_SMLPF_CTL,                     0x00 },
-	{ WCD9335_CDC_ANC0_DCFLT_SHIFT_CTL,               0x00 },
-	{ WCD9335_CDC_ANC0_IIR_ADAPT_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,               0x00 },
-	{ WCD9335_CDC_ANC0_IIR_COEFF_2_CTL,               0x00 },
-	{ WCD9335_CDC_ANC0_FF_A_GAIN_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC0_FF_B_GAIN_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC0_FB_GAIN_CTL,                   0x00 },
-	{ WCD9335_CDC_ANC1_CLK_RESET_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC1_MODE_1_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC1_MODE_2_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC1_FF_SHIFT,                      0x00 },
-	{ WCD9335_CDC_ANC1_FB_SHIFT,                      0x00 },
-	{ WCD9335_CDC_ANC1_LPF_FF_A_CTL,                  0x00 },
-	{ WCD9335_CDC_ANC1_LPF_FF_B_CTL,                  0x00 },
-	{ WCD9335_CDC_ANC1_LPF_FB_CTL,                    0x00 },
-	{ WCD9335_CDC_ANC1_SMLPF_CTL,                     0x00 },
-	{ WCD9335_CDC_ANC1_DCFLT_SHIFT_CTL,               0x00 },
-	{ WCD9335_CDC_ANC1_IIR_ADAPT_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,               0x00 },
-	{ WCD9335_CDC_ANC1_IIR_COEFF_2_CTL,               0x00 },
-	{ WCD9335_CDC_ANC1_FF_A_GAIN_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC1_FF_B_GAIN_CTL,                 0x00 },
-	{ WCD9335_CDC_ANC1_FB_GAIN_CTL,                   0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX0_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX0_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX1_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX1_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX2_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX2_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX3_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX3_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX4_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX4_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX5_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX5_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX6_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX6_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX7_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX7_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_TX8_TX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_192_CTL,                0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_192_CFG,                0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC0,                   0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC1,                   0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC4,                   0x20 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_TX8_TX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL,             0x02 },
-	{ WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0,            0x00 },
-	{ WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL,            0x02 },
-	{ WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0,           0x00 },
-	{ WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL,            0x02 },
-	{ WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0,           0x00 },
-	{ WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL,            0x02 },
-	{ WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0,           0x00 },
-	/* Page #11 registers */
-	{ WCD9335_PAGE11_PAGE_REGISTER,                   0x00 },
-	{ WCD9335_CDC_COMPANDER1_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER1_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER1_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER1_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER1_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER1_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER1_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER2_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER2_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER2_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER2_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER2_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER2_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER2_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER3_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER3_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER3_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER3_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER3_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER3_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER3_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER4_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER4_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER4_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER4_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER4_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER4_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER4_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER5_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER5_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER5_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER5_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER5_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER5_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER5_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER6_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER6_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER6_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER6_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER6_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER6_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER6_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER7_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER7_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER7_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER7_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER7_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER7_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER7_CTL6,                    0x01 },
-	{ WCD9335_CDC_COMPANDER8_CTL0,                    0x60 },
-	{ WCD9335_CDC_COMPANDER8_CTL1,                    0xdb },
-	{ WCD9335_CDC_COMPANDER8_CTL2,                    0xff },
-	{ WCD9335_CDC_COMPANDER8_CTL3,                    0x35 },
-	{ WCD9335_CDC_COMPANDER8_CTL4,                    0xff },
-	{ WCD9335_CDC_COMPANDER8_CTL5,                    0x00 },
-	{ WCD9335_CDC_COMPANDER8_CTL6,                    0x01 },
-	{ WCD9335_CDC_RX0_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX0_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX0_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX0_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX0_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX1_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX1_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX1_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC4,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX1_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX2_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX2_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX2_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC4,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX2_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX3_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX3_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX3_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX3_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX4_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX4_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX4_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX4_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX5_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX5_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX5_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX5_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX6_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX6_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX6_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX6_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX7_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX7_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX7_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX7_RX_PATH_MIX_SEC1,               0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_CTL,                    0x04 },
-	{ WCD9335_CDC_RX8_RX_PATH_CFG0,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_CFG2,                   0x8f },
-	{ WCD9335_CDC_RX8_RX_VOL_CTL,                     0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_CTL,                0x04 },
-	{ WCD9335_CDC_RX8_RX_VOL_MIX_CTL,                 0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC2,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC3,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC5,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC6,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_SEC7,                   0x00 },
-	{ WCD9335_CDC_RX8_RX_PATH_MIX_SEC1,               0x00 },
-	/* Page #12 registers */
-	{ WCD9335_PAGE12_PAGE_REGISTER,                   0x00 },
-	{ WCD9335_CDC_CLSH_CRC,                           0x00 },
-	{ WCD9335_CDC_CLSH_DLY_CTRL,                      0x03 },
-	{ WCD9335_CDC_CLSH_DECAY_CTRL,                    0x02 },
-	{ WCD9335_CDC_CLSH_HPH_V_PA,                      0x1c },
-	{ WCD9335_CDC_CLSH_EAR_V_PA,                      0x39 },
-	{ WCD9335_CDC_CLSH_HPH_V_HD,                      0x0c },
-	{ WCD9335_CDC_CLSH_EAR_V_HD,                      0x0c },
-	{ WCD9335_CDC_CLSH_K1_MSB,                        0x01 },
-	{ WCD9335_CDC_CLSH_K1_LSB,                        0x00 },
-	{ WCD9335_CDC_CLSH_K2_MSB,                        0x00 },
-	{ WCD9335_CDC_CLSH_K2_LSB,                        0x80 },
-	{ WCD9335_CDC_CLSH_IDLE_CTRL,                     0x00 },
-	{ WCD9335_CDC_CLSH_IDLE_HPH,                      0x00 },
-	{ WCD9335_CDC_CLSH_IDLE_EAR,                      0x00 },
-	{ WCD9335_CDC_CLSH_TEST0,                         0x07 },
-	{ WCD9335_CDC_CLSH_TEST1,                         0x00 },
-	{ WCD9335_CDC_CLSH_OVR_VREF,                      0x00 },
-	{ WCD9335_CDC_BOOST0_BOOST_PATH_CTL,              0x00 },
-	{ WCD9335_CDC_BOOST0_BOOST_CTL,                   0xb2 },
-	{ WCD9335_CDC_BOOST0_BOOST_CFG1,                  0x00 },
-	{ WCD9335_CDC_BOOST0_BOOST_CFG2,                  0x00 },
-	{ WCD9335_CDC_BOOST1_BOOST_PATH_CTL,              0x00 },
-	{ WCD9335_CDC_BOOST1_BOOST_CTL,                   0xb2 },
-	{ WCD9335_CDC_BOOST1_BOOST_CFG1,                  0x00 },
-	{ WCD9335_CDC_BOOST1_BOOST_CFG2,                  0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_DATA_0,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_DATA_1,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_DATA_2,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_DATA_3,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_ADDR_1,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_ADDR_2,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_WR_ADDR_3,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_ADDR_1,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_ADDR_2,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_ADDR_3,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_DATA_0,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_DATA_1,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_DATA_2,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_RD_DATA_3,               0x00 },
-	{ WCD9335_SWR_AHB_BRIDGE_ACCESS_CFG,              0x0f },
-	{ WCD9335_SWR_AHB_BRIDGE_ACCESS_STATUS,           0x03 },
-	{ WCD9335_CDC_VBAT_VBAT_PATH_CTL,                 0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_CFG,                      0x0a },
-	{ WCD9335_CDC_VBAT_VBAT_ADC_CAL1,                 0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_ADC_CAL2,                 0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_ADC_CAL3,                 0x04 },
-	{ WCD9335_CDC_VBAT_VBAT_PK_EST1,                  0xe0 },
-	{ WCD9335_CDC_VBAT_VBAT_PK_EST2,                  0x01 },
-	{ WCD9335_CDC_VBAT_VBAT_PK_EST3,                  0x40 },
-	{ WCD9335_CDC_VBAT_VBAT_RF_PROC1,                 0x2a },
-	{ WCD9335_CDC_VBAT_VBAT_RF_PROC2,                 0x86 },
-	{ WCD9335_CDC_VBAT_VBAT_TAC1,                     0x70 },
-	{ WCD9335_CDC_VBAT_VBAT_TAC2,                     0x18 },
-	{ WCD9335_CDC_VBAT_VBAT_TAC3,                     0x18 },
-	{ WCD9335_CDC_VBAT_VBAT_TAC4,                     0x03 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_UPD1,                0x01 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_UPD2,                0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_UPD3,                0x64 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_UPD4,                0x01 },
-	{ WCD9335_CDC_VBAT_VBAT_DEBUG1,                   0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_UPD_MON,             0x00 },
-	{ WCD9335_CDC_VBAT_VBAT_GAIN_MON_VAL,             0x00 },
-	{ WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,      0x04 },
-	{ WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1,     0x00 },
-	{ WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,      0x04 },
-	{ WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1,     0x00 },
-	/* Page #13 registers */
-	{ WCD9335_PAGE13_PAGE_REGISTER,                   0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1,            0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0,             0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1,             0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2,             0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3,             0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4,             0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0,       0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1,       0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_ANC_CFG0,                0x00 },
-	{ WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0,         0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0,           0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0,          0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0,          0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0,          0x00 },
-	{ WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0,          0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0x00 },
-	{ WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,              0x00 },
-	{ WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1,              0x00 },
-	{ WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2,              0x00 },
-	{ WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3,              0x00 },
-	{ WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,          0x00 },
-	{ WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,           0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_CTL,               0x08 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD0,      0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD1,      0x4b },
-	{ WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB,   0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB,   0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_STATUS,            0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_TEST_CTRL,         0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB,     0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB,     0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD,  0x00 },
-	{ WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD,  0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,         0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_CTL,              0x40 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL,   0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,         0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_CTL,              0x40 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL,   0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL,      0x00 },
-	{ WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL,      0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG0,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG1,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG2,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG3,                       0x18 },
-	{ WCD9335_CDC_TOP_TOP_CFG4,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG5,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG6,                       0x00 },
-	{ WCD9335_CDC_TOP_TOP_CFG7,                       0x00 },
-	{ WCD9335_CDC_TOP_HPHL_COMP_WR_LSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHL_COMP_WR_MSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHL_COMP_LUT,                  0x00 },
-	{ WCD9335_CDC_TOP_HPHL_COMP_RD_LSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHL_COMP_RD_MSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHR_COMP_WR_LSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHR_COMP_WR_MSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHR_COMP_LUT,                  0x00 },
-	{ WCD9335_CDC_TOP_HPHR_COMP_RD_LSB,               0x00 },
-	{ WCD9335_CDC_TOP_HPHR_COMP_RD_MSB,               0x00 },
-	{ WCD9335_CDC_TOP_DIFFL_COMP_WR_LSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFL_COMP_WR_MSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFL_COMP_LUT,                 0x00 },
-	{ WCD9335_CDC_TOP_DIFFL_COMP_RD_LSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFL_COMP_RD_MSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFR_COMP_WR_LSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFR_COMP_WR_MSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFR_COMP_LUT,                 0x00 },
-	{ WCD9335_CDC_TOP_DIFFR_COMP_RD_LSB,              0x00 },
-	{ WCD9335_CDC_TOP_DIFFR_COMP_RD_MSB,              0x00 },
-	/* Page #0x80 registers */
-	{ WCD9335_PAGE80_PAGE_REGISTER,                   0x00 },
-	{ WCD9335_TLMM_BIST_MODE_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_RF_PA_ON_PINCFG,                   0x00 },
-	{ WCD9335_TLMM_INTR1_PINCFG,                      0x00 },
-	{ WCD9335_TLMM_INTR2_PINCFG,                      0x00 },
-	{ WCD9335_TLMM_SWR_DATA_PINCFG,                   0x00 },
-	{ WCD9335_TLMM_SWR_CLK_PINCFG,                    0x00 },
-	{ WCD9335_TLMM_SLIMBUS_DATA2_PINCFG,              0x00 },
-	{ WCD9335_TLMM_I2C_CLK_PINCFG,                    0x00 },
-	{ WCD9335_TLMM_I2C_DATA_PINCFG,                   0x00 },
-	{ WCD9335_TLMM_I2S_RX_SD0_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_RX_SD1_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_RX_SCK_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_RX_WS_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_I2S_TX_SD0_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_TX_SD1_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_TX_SCK_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_I2S_TX_WS_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_DMIC1_CLK_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_DMIC1_DATA_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_DMIC2_CLK_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_DMIC2_DATA_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_DMIC3_CLK_PINCFG,                  0x00 },
-	{ WCD9335_TLMM_DMIC3_DATA_PINCFG,                 0x00 },
-	{ WCD9335_TLMM_JTDI_PINCFG,                       0x00 },
-	{ WCD9335_TLMM_JTDO_PINCFG,                       0x00 },
-	{ WCD9335_TLMM_JTMS_PINCFG,                       0x00 },
-	{ WCD9335_TLMM_JTCK_PINCFG,                       0x00 },
-	{ WCD9335_TLMM_JTRST_PINCFG,                      0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_OE_0,                0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_OE_1,                0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_OE_2,                0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_OE_3,                0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_DATA_0,              0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_DATA_1,              0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_DATA_2,              0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_CTL_DATA_3,              0x00 },
-	{ WCD9335_TEST_DEBUG_PAD_DRVCTL,                  0x00 },
-	{ WCD9335_TEST_DEBUG_PIN_STATUS,                  0x00 },
-	{ WCD9335_TEST_DEBUG_MEM_CTRL,                    0x00 },
-	{ WCD9335_TEST_DEBUG_DEBUG_BUS_SEL,               0x00 },
-	{ WCD9335_TEST_DEBUG_DEBUG_JTAG,                  0x00 },
-	{ WCD9335_TEST_DEBUG_DEBUG_EN_1,                  0x00 },
-	{ WCD9335_TEST_DEBUG_DEBUG_EN_2,                  0x00 },
-	{ WCD9335_TEST_DEBUG_DEBUG_EN_3,                  0x00 },
-};
-
-/*
- * wcd9335_regmap_register_patch: Update register defaults based on version
- * @regmap: handle to wcd9xxx regmap
- * @version: wcd9335 version
- *
- * Returns error code in case of failure or 0 for success
- */
-int wcd9335_regmap_register_patch(struct regmap *regmap, int version)
-{
-	int rc;
-
-	if (!regmap) {
-		pr_err("%s: regmap struct is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (version) {
-	case TASHA_VERSION_1_0:
-	case TASHA_VERSION_1_1:
-		regcache_cache_only(regmap, true);
-		rc = regmap_multi_reg_write(regmap, wcd9335_1_x_defaults,
-					    ARRAY_SIZE(wcd9335_1_x_defaults));
-		regcache_cache_only(regmap, false);
-		break;
-	case TASHA_VERSION_2_0:
-		regcache_cache_only(regmap, true);
-		rc = regmap_multi_reg_write(regmap, wcd9335_2_0_defaults,
-					    ARRAY_SIZE(wcd9335_2_0_defaults));
-		regcache_cache_only(regmap, false);
-		break;
-	default:
-		pr_err("%s: unknown version: %d\n", __func__, version);
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9335_regmap_register_patch);
-
-static bool wcd9335_is_readable_register(struct device *dev, unsigned int reg)
-{
-	u8 pg_num, reg_offset;
-	const u8 *reg_tbl = NULL;
-
-	/*
-	 * Get the page number from MSB of codec register. If its 0x80, assign
-	 * the corresponding page index PAGE_0x80.
-	 */
-	pg_num = reg >> 0x8;
-	if (pg_num == 0x80)
-		pg_num = PAGE_0X80;
-	else if (pg_num >= 0xE)
-		return false;
-
-	reg_tbl = wcd9335_reg[pg_num];
-	reg_offset = reg & 0xFF;
-
-	if (reg_tbl)
-		return reg_tbl[reg_offset];
-	else
-		return false;
-}
-
-static bool wcd9335_is_volatile_register(struct device *dev, unsigned int reg)
-{
-	/*
-	 * registers from 0x000 to 0x0FF are volatile because
-	 * this space contains registers related to interrupt
-	 * status, mask etc
-	 */
-	if (reg < 0x100)
-		return true;
-
-	/* IIR Coeff registers are not cacheable */
-	if ((reg >= WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL) &&
-	    (reg <= WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL))
-		return true;
-
-	if ((reg >= WCD9335_CDC_ANC0_IIR_COEFF_1_CTL) &&
-	    (reg <= WCD9335_CDC_ANC0_FB_GAIN_CTL))
-		return true;
-
-	if ((reg >= WCD9335_CDC_ANC1_IIR_COEFF_1_CTL) &&
-	    (reg <= WCD9335_CDC_ANC1_FB_GAIN_CTL))
-		return true;
-	/*
-	 * CPE inbox and outbox registers are volatile
-	 * since they can be updated in the codec hardware
-	 * to indicate CPE status
-	 */
-	if (reg >= WCD9335_CPE_SS_MEM_PTR_0 &&
-	    reg <= WCD9335_CPE_SS_OUTBOX2_ACK)
-		return true;
-
-	if (reg >= WCD9335_RCO_CAL_OUT_1 &&
-	    reg <= WCD9335_RCO_CAL_OUT_5)
-		return true;
-
-	switch (reg) {
-	case WCD9335_CPE_SS_INBOX1_TRG:
-	case WCD9335_CPE_SS_INBOX2_TRG:
-	case WCD9335_SWR_AHB_BRIDGE_WR_DATA_0:
-	case WCD9335_SWR_AHB_BRIDGE_WR_DATA_1:
-	case WCD9335_SWR_AHB_BRIDGE_WR_DATA_2:
-	case WCD9335_SWR_AHB_BRIDGE_WR_DATA_3:
-	case WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0:
-	case WCD9335_SWR_AHB_BRIDGE_WR_ADDR_1:
-	case WCD9335_SWR_AHB_BRIDGE_WR_ADDR_2:
-	case WCD9335_SWR_AHB_BRIDGE_WR_ADDR_3:
-	case WCD9335_SWR_AHB_BRIDGE_RD_DATA_0:
-	case WCD9335_SWR_AHB_BRIDGE_RD_DATA_1:
-	case WCD9335_SWR_AHB_BRIDGE_RD_DATA_2:
-	case WCD9335_SWR_AHB_BRIDGE_RD_DATA_3:
-	case WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0:
-	case WCD9335_SWR_AHB_BRIDGE_RD_ADDR_1:
-	case WCD9335_SWR_AHB_BRIDGE_RD_ADDR_2:
-	case WCD9335_SWR_AHB_BRIDGE_RD_ADDR_3:
-	case WCD9335_ANA_BIAS:
-	case WCD9335_ANA_CLK_TOP:
-	case WCD9335_ANA_RCO:
-	case WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL:
-	case WCD9335_ANA_MBHC_RESULT_3:
-	case WCD9335_ANA_MBHC_RESULT_2:
-	case WCD9335_ANA_MBHC_RESULT_1:
-	case WCD9335_ANA_MBHC_MECH:
-	case WCD9335_ANA_MBHC_ELECT:
-	case WCD9335_ANA_MBHC_ZDET:
-	case WCD9335_ANA_MICB2:
-	case WCD9335_CPE_SS_SS_ERROR_INT_STATUS:
-	case WCD9335_CPE_SS_SS_ERROR_INT_MASK:
-	case WCD9335_CPE_SS_SS_ERROR_INT_CLEAR:
-	case WCD9335_CPE_SS_STATUS:
-	case WCD9335_CPE_SS_BACKUP_INT:
-	case WCD9335_CPE_SS_CFG:
-	case WCD9335_SOC_MAD_MAIN_CTL_1:
-	case WCD9335_SOC_MAD_AUDIO_CTL_3:
-	case WCD9335_SOC_MAD_AUDIO_CTL_4:
-	case WCD9335_FLYBACK_EN:
-	case WCD9335_ANA_RX_SUPPLIES:
-	case WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL:
-	case WCD9335_SIDO_SIDO_CCL_2:
-	case WCD9335_SIDO_SIDO_CCL_4:
-	case WCD9335_DATA_HUB_NATIVE_FIFO_STATUS:
-	case WCD9335_MBHC_FSM_STATUS:
-	case WCD9335_SPLINE_SRC0_STATUS:
-	case WCD9335_SPLINE_SRC1_STATUS:
-	case WCD9335_SPLINE_SRC2_STATUS:
-	case WCD9335_SPLINE_SRC3_STATUS:
-	case WCD9335_SIDO_SIDO_TEST_2:
-	case WCD9335_SIDO_SIDO_CCL_8:
-	case WCD9335_BIAS_VBG_FINE_ADJ:
-	case WCD9335_VBADC_ADC_DOUTMSB:
-	case WCD9335_VBADC_ADC_DOUTLSB:
-	case WCD9335_CDC_VBAT_VBAT_GAIN_MON_VAL:
-	case WCD9335_ANA_BUCK_CTL:
-		return true;
-	default:
-		return false;
-	}
-}
-
-struct regmap_config wcd9335_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.cache_type = REGCACHE_RBTREE,
-	.reg_defaults = wcd9335_defaults,
-	.num_reg_defaults = ARRAY_SIZE(wcd9335_defaults),
-	.max_register = WCD9335_MAX_REGISTER,
-	.volatile_reg = wcd9335_is_volatile_register,
-	.readable_reg = wcd9335_is_readable_register,
-	.can_multi_write = true,
-};
diff --git a/drivers/mfd/wcd9335-tables.c b/drivers/mfd/wcd9335-tables.c
deleted file mode 100644
index f5c32ef..0000000
--- a/drivers/mfd/wcd9335-tables.c
+++ /dev/null
@@ -1,1325 +0,0 @@
-/*
- * Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include <linux/mfd/wcd9335/registers.h>
-
-#define WCD9335_REG(reg)  ((reg) & 0xFF)
-
-const u8 wcd9335_page0_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE0_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_CLK_BYPASS)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_CLK_GATE)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_CLK_MCLK_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_RST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_1)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_2)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_3)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_IRAM_SHUTDOWN)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_1)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_2)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_INT_MASK)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_INT_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CODEC_RPM_INT_CLEAR)] = 0,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE1)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE2)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE3)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_TEST0)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_TEST1)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT3)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT4)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT5)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT6)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT7)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT8)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT9)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT13)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT14)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT15)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_1)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_2)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_3)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_I2C_ACTIVE)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC1_MON_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC1_MON_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC2_MON_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC2_MON_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC3_MON_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC3_MON_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_LSB)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_I2S_CLK)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX4_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX5_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX6_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_RX7_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX0_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX1_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX2_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX3_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX4_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX5_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX6_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX7_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX8_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX9_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX10_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX14_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_SB_TX15_INP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_NATIVE_FIFO_SYNC)] = 1,
-	[WCD9335_REG(WCD9335_DATA_HUB_NATIVE_FIFO_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_INTR_CFG)] = 1,
-	[WCD9335_REG(WCD9335_INTR_CLR_COMMIT)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN1_MASK0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_MASK1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_MASK2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_MASK3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_STATUS0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_STATUS1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_STATUS2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_STATUS3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN1_CLEAR0)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN1_CLEAR1)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN1_CLEAR2)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN1_CLEAR3)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN2_MASK0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_MASK1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_MASK2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_MASK3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_STATUS0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_STATUS1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_STATUS2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_STATUS3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_PIN2_CLEAR0)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN2_CLEAR1)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN2_CLEAR2)] = 0,
-	[WCD9335_REG(WCD9335_INTR_PIN2_CLEAR3)] = 0,
-	[WCD9335_REG(WCD9335_INTR_LEVEL0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_LEVEL1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_LEVEL2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_LEVEL3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_BYPASS0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_BYPASS1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_BYPASS2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_BYPASS3)] = 1,
-	[WCD9335_REG(WCD9335_INTR_SET0)] = 1,
-	[WCD9335_REG(WCD9335_INTR_SET1)] = 1,
-	[WCD9335_REG(WCD9335_INTR_SET2)] = 1,
-	[WCD9335_REG(WCD9335_INTR_SET3)] = 1,
-};
-
-const u8 wcd9335_page1_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE1_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_8)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_USER_CTL_9)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_L_VAL_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_L_VAL_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_DSM_FRAC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_DSM_FRAC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_CONFIG_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_CONFIG_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_CONFIG_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_CONFIG_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_CONFIG_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_TEST_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_FREQ_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_FREQ_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_FREQ_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_FREQ_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_SSC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_SSC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_SSC_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_SSC_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_FLL_MODE)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_STATUS_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_STATUS_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_STATUS_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_FLL_STATUS_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_8)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_USER_CTL_9)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_L_VAL_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_L_VAL_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_DSM_FRAC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_DSM_FRAC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_CONFIG_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_CONFIG_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_CONFIG_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_CONFIG_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_CONFIG_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_TEST_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_FREQ_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_FREQ_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_FREQ_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_FREQ_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_SSC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_SSC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_SSC_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_SSC_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_FLL_MODE)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_STATUS_0)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_STATUS_1)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_STATUS_2)] = 1,
-	[WCD9335_REG(WCD9335_I2S_FLL_STATUS_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_8)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_USER_CTL_9)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_L_VAL_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_L_VAL_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_DSM_FRAC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_DSM_FRAC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_CONFIG_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_CONFIG_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_CONFIG_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_CONFIG_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_CONFIG_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_TEST_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_FREQ_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_FREQ_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_FREQ_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_FREQ_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_SSC_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_SSC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_SSC_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_SSC_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_FLL_MODE)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_STATUS_0)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_STATUS_1)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_STATUS_2)] = 1,
-	[WCD9335_REG(WCD9335_SB_FLL_STATUS_3)] = 1,
-};
-
-const u8 wcd9335_page2_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE2_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_PTR_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_PTR_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_PTR_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_5)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_6)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_7)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_8)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_9)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_10)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_11)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_12)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_13)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_14)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MEM_BANK_15)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_TRG)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_TRG)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_0)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_1)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_2)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_3)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_4)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_5)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_6)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_7)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_8)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_9)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_10)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_11)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_12)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_13)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_14)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX1_15)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_5)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_6)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_7)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_8)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_9)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_10)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_11)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_12)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_13)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_14)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_15)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_0)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_1)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_2)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_3)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_4)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_5)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_6)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_7)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_8)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_9)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_10)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_11)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_12)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_13)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_14)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_INBOX2_15)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_0)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_1)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_2)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_3)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_4)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_5)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_6)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_7)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_8)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_9)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_10)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_11)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_12)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_13)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_14)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_15)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX1_ACK)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_OUTBOX2_ACK)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_EC_BUF_INT_PERIOD)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_US_BUF_INT_PERIOD)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_US_EC_MUX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_MAD_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_CPAR_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_TX_PP_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_DMIC0_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_DMIC1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_DMIC2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_DMIC_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_SVA_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_CPAR_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_WDOG_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_BACKUP_INT)] = 0,
-	[WCD9335_REG(WCD9335_CPE_SS_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_CPE_OCD_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_SS_ERROR_INT_MASK)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_SS_ERROR_INT_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CPE_SS_SS_ERROR_INT_CLEAR)] = 0,
-	[WCD9335_REG(WCD9335_SOC_MAD_MAIN_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_MAIN_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_CTL_8)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_ULTR_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_4)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_5)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_6)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_7)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_CTL_8)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL)] = 1,
-	[WCD9335_REG(WCD9335_SOC_MAD_INP_SEL)] = 1,
-};
-
-const u8 wcd9335_page6_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE6_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_ANA_BIAS)] = 1,
-	[WCD9335_REG(WCD9335_ANA_CLK_TOP)] = 1,
-	[WCD9335_REG(WCD9335_ANA_RCO)] = 1,
-	[WCD9335_REG(WCD9335_ANA_BUCK_VOUT_A)] = 1,
-	[WCD9335_REG(WCD9335_ANA_BUCK_VOUT_D)] = 1,
-	[WCD9335_REG(WCD9335_ANA_BUCK_CTL)] = 1,
-	[WCD9335_REG(WCD9335_ANA_BUCK_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_ANA_RX_SUPPLIES)] = 1,
-	[WCD9335_REG(WCD9335_ANA_HPH)] = 1,
-	[WCD9335_REG(WCD9335_ANA_EAR)] = 1,
-	[WCD9335_REG(WCD9335_ANA_LO_1_2)] = 1,
-	[WCD9335_REG(WCD9335_ANA_LO_3_4)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MAD_SETUP)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC1)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC2)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC3)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC4)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC5)] = 1,
-	[WCD9335_REG(WCD9335_ANA_AMIC6)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_MECH)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_ELECT)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_ZDET)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_RESULT_1)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_RESULT_2)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_RESULT_3)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN0)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN1)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN2)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN3)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN4)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN5)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN6)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MBHC_BTN7)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MICB1)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MICB2)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MICB2_RAMP)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MICB3)] = 1,
-	[WCD9335_REG(WCD9335_ANA_MICB4)] = 1,
-	[WCD9335_REG(WCD9335_ANA_VBADC)] = 1,
-	[WCD9335_REG(WCD9335_BIAS_CTL)] = 1,
-	[WCD9335_REG(WCD9335_BIAS_VBG_FINE_ADJ)] = 1,
-	[WCD9335_REG(WCD9335_CLOCK_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CTRL_1)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CTRL_2)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_1)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_2)] = 1,
-	[WCD9335_REG(WCD9335_RCO_TEST_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_OUT_1)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_OUT_2)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_OUT_3)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_OUT_4)] = 1,
-	[WCD9335_REG(WCD9335_RCO_CAL_OUT_5)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_MODE_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_MODE_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_MODE_3)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_MODE_4)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_VCL_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_VCL_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_VCL_3)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_3)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_4)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_5)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_6)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_7)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_8)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_9)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CCL_10)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_FILTER_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_FILTER_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_DRIVER_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_DRIVER_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_DRIVER_3)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CAL_CODE_EXT_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CAL_CODE_EXT_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CAL_CODE_OUT_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_CAL_CODE_OUT_2)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_TEST_1)] = 1,
-	[WCD9335_REG(WCD9335_SIDO_SIDO_TEST_2)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_PLUG_DETECT_CTL)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_ZDET_ANA_CTL)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_ZDET_RAMP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_FSM_DEBUG)] = 1,
-	[WCD9335_REG(WCD9335_MBHC_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_SUBBLOCK_EN)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_IBIAS_FE)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_BIAS_ADC)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_FE_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_ADC_REF)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_ADC_IO)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_ADC_SAR)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_DEBUG)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_ADC_DOUTMSB)] = 1,
-	[WCD9335_REG(WCD9335_VBADC_ADC_DOUTLSB)] = 1,
-	[WCD9335_REG(WCD9335_LDOH_MODE)] = 1,
-	[WCD9335_REG(WCD9335_LDOH_BIAS)] = 1,
-	[WCD9335_REG(WCD9335_LDOH_STB_LOADS)] = 1,
-	[WCD9335_REG(WCD9335_LDOH_SLOWRAMP)] = 1,
-	[WCD9335_REG(WCD9335_MICB1_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_MICB1_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_MICB1_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_MICB2_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_MICB2_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_MICB2_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_MICB3_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_MICB3_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_MICB3_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_MICB4_TEST_CTL_1)] = 1,
-	[WCD9335_REG(WCD9335_MICB4_TEST_CTL_2)] = 1,
-	[WCD9335_REG(WCD9335_MICB4_TEST_CTL_3)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_ADC_VCM)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_BIAS_ATEST)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_ADC_INT1_IB)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_ADC_INT2_IB)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_TXFE_DIV_CTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_TXFE_DIV_START)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_TXFE_DIV_STOP_9P6M)] = 1,
-	[WCD9335_REG(WCD9335_TX_COM_TXFE_DIV_STOP_12P288M)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_TEST_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_ADC_IB)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_ATEST_REFCTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_TEST_BLK_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_TXFE_CLKDIV)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_SAR1_ERR)] = 1,
-	[WCD9335_REG(WCD9335_TX_1_2_SAR2_ERR)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_TEST_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_ADC_IB)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_ATEST_REFCTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_TEST_BLK_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_TXFE_CLKDIV)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_SAR1_ERR)] = 1,
-	[WCD9335_REG(WCD9335_TX_3_4_SAR2_ERR)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_TEST_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_ADC_IB)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_ATEST_REFCTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_TEST_BLK_EN)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_TXFE_CLKDIV)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_SAR1_ERR)] = 1,
-	[WCD9335_REG(WCD9335_TX_5_6_SAR2_ERR)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_MODE_1)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_MODE_2)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_MODE_3)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_VCL_1)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_VCL_2)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_CCL_1)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_CCL_2)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_CCL_3)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_CCL_4)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_CTRL_CCL_5)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_BUCK_TMUX_A_D)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_BUCK_SW_DRV_CNTL)] = 1,
-	[WCD9335_REG(WCD9335_CLASSH_SPARE)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_EN)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_1)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_2)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_3)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_4)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_5)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_6)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_7)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_8)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_CTRL_9)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_DAC_CTRL_1)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_DAC_CTRL_2)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_DAC_CTRL_3)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_VNEG_DAC_CTRL_4)] = 1,
-	[WCD9335_REG(WCD9335_FLYBACK_TEST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_RX_AUX_SW_CTL)] = 1,
-	[WCD9335_REG(WCD9335_RX_PA_AUX_IN_CONN)] = 1,
-	[WCD9335_REG(WCD9335_RX_TIMER_DIV)] = 1,
-	[WCD9335_REG(WCD9335_RX_OCP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_RX_OCP_COUNT)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_EAR_DAC)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_EAR_AMP)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_LDO)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_PA)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_RDAC_LDO)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_CNP1)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_HPH_LOWPOWER)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_DIFFLO_PA)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_DIFFLO_REF)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_DIFFLO_LDO)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_SELO_DAC_PA)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_BUCK_RST)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_BUCK_VREF_ERRAMP)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_FLYB_ERRAMP)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_FLYB_BUFF)] = 1,
-	[WCD9335_REG(WCD9335_RX_BIAS_FLYB_MID_RST)] = 1,
-	[WCD9335_REG(WCD9335_HPH_L_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_HPH_R_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_HPH_CNP_EN)] = 1,
-	[WCD9335_REG(WCD9335_HPH_CNP_WG_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_CNP_WG_TIME)] = 1,
-	[WCD9335_REG(WCD9335_HPH_OCP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_AUTO_CHOP)] = 1,
-	[WCD9335_REG(WCD9335_HPH_CHOP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_PA_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_HPH_PA_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_HPH_L_EN)] = 1,
-	[WCD9335_REG(WCD9335_HPH_L_TEST)] = 1,
-	[WCD9335_REG(WCD9335_HPH_L_ATEST)] = 1,
-	[WCD9335_REG(WCD9335_HPH_R_EN)] = 1,
-	[WCD9335_REG(WCD9335_HPH_R_TEST)] = 1,
-	[WCD9335_REG(WCD9335_HPH_R_ATEST)] = 1,
-	[WCD9335_REG(WCD9335_HPH_RDAC_CLK_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_HPH_RDAC_CLK_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_HPH_RDAC_LDO_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_RDAC_CHOP_CLK_LP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_REFBUFF_UHQA_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_REFBUFF_LP_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_L_DAC_CTL)] = 1,
-	[WCD9335_REG(WCD9335_HPH_R_DAC_CTL)] = 1,
-	[WCD9335_REG(WCD9335_EAR_EN_REG)] = 1,
-	[WCD9335_REG(WCD9335_EAR_CMBUFF)] = 1,
-	[WCD9335_REG(WCD9335_EAR_ICTL)] = 1,
-	[WCD9335_REG(WCD9335_EAR_EN_DBG_CTL)] = 1,
-	[WCD9335_REG(WCD9335_EAR_CNP)] = 1,
-	[WCD9335_REG(WCD9335_EAR_DAC_CTL_ATEST)] = 1,
-	[WCD9335_REG(WCD9335_EAR_STATUS_REG)] = 1,
-	[WCD9335_REG(WCD9335_EAR_OUT_SHORT)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_MISC)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_LO2_COMPANDER)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_LO1_COMPANDER)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_COMMON)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_BYPASS_EN)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_CNP)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_CORE_OUT_PROG)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_LDO_OUT_PROG)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_COM_PA_FREQ)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_RESERVED_REG)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_LO1_STATUS_1)] = 1,
-	[WCD9335_REG(WCD9335_DIFF_LO_LO1_STATUS_2)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_COM1)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_COM2)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO3_GAIN)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO3_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO4_GAIN)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO4_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO3_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_SE_LO_LO4_STATUS)] = 1,
-};
-
-const u8 wcd9335_page10_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE10_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_CLK_RESET_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_MODE_1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_MODE_2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_FF_SHIFT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_FB_SHIFT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_LPF_FF_A_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_LPF_FF_B_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_LPF_FB_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_SMLPF_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_DCFLT_SHIFT_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_IIR_ADAPT_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_IIR_COEFF_1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_IIR_COEFF_2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_FF_A_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_FF_B_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC0_FB_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_CLK_RESET_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_MODE_1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_MODE_2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_FF_SHIFT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_FB_SHIFT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_LPF_FF_A_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_LPF_FF_B_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_LPF_FB_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_SMLPF_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_DCFLT_SHIFT_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_IIR_ADAPT_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_IIR_COEFF_1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_IIR_COEFF_2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_FF_A_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_FF_B_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_ANC1_FB_GAIN_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX0_TX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX1_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX2_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX3_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX4_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX5_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX6_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX7_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_192_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_192_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX8_TX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0)] = 1,
-};
-
-const u8 wcd9335_page11_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE11_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER1_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER2_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER3_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER4_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER5_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER6_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER7_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_COMPANDER8_CTL7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX0_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX1_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX2_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX3_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX4_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX5_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX6_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX7_RX_PATH_MIX_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_VOL_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_MIX_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_VOL_MIX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_SEC7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_MIX_SEC0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX8_RX_PATH_MIX_SEC1)] = 1,
-};
-
-const u8 wcd9335_page12_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE12_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_CRC)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_DLY_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_DECAY_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_HPH_V_PA)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_EAR_V_PA)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_HPH_V_HD)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_EAR_V_HD)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_K1_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_K1_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_K2_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_K2_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_IDLE_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_IDLE_HPH)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_IDLE_EAR)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_TEST0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_TEST1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLSH_OVR_VREF)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST0_BOOST_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST0_BOOST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST0_BOOST_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST0_BOOST_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST1_BOOST_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST1_BOOST_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST1_BOOST_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_BOOST1_BOOST_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_DATA_0)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_DATA_1)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_DATA_2)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_DATA_3)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_ADDR_1)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_ADDR_2)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_WR_ADDR_3)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_ADDR_1)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_ADDR_2)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_ADDR_3)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_DATA_0)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_DATA_1)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_DATA_2)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_RD_DATA_3)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_ACCESS_CFG)] = 1,
-	[WCD9335_REG(WCD9335_SWR_AHB_BRIDGE_ACCESS_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_CFG)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_ADC_CAL1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_ADC_CAL2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_ADC_CAL3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_PK_EST1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_PK_EST2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_PK_EST3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_RF_PROC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_RF_PROC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_TAC1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_TAC2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_TAC3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_TAC4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_UPD1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_UPD2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_UPD3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_UPD4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_DEBUG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_UPD_MON)] = 0,
-	[WCD9335_REG(WCD9335_CDC_VBAT_VBAT_GAIN_MON_VAL)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC0_CLK_RST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC0_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC1_CLK_RST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC1_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC2_CLK_RST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC2_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC3_CLK_RST_CTL_0)] = 1,
-	[WCD9335_REG(WCD9335_SPLINE_SRC3_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1)] = 1,
-};
-
-const u8 wcd9335_page13_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE13_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_ANC_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_TEST_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD)] = 1,
-	[WCD9335_REG(WCD9335_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG0)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG1)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG2)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG3)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG4)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG5)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG6)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_TOP_CFG7)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHL_COMP_WR_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHL_COMP_WR_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHL_COMP_LUT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHL_COMP_RD_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHL_COMP_RD_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHR_COMP_WR_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHR_COMP_WR_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHR_COMP_LUT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHR_COMP_RD_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_HPHR_COMP_RD_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFL_COMP_WR_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFL_COMP_WR_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFL_COMP_LUT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFL_COMP_RD_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFL_COMP_RD_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFR_COMP_WR_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFR_COMP_WR_MSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFR_COMP_LUT)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFR_COMP_RD_LSB)] = 1,
-	[WCD9335_REG(WCD9335_CDC_TOP_DIFFR_COMP_RD_MSB)] = 1,
-};
-
-const u8 wcd9335_page_0x80_reg_readable[WCD9335_PAGE_SIZE] = {
-	[WCD9335_REG(WCD9335_PAGE80_PAGE_REGISTER)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_BIST_MODE_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_RF_PA_ON_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_INTR1_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_INTR2_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_SWR_DATA_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_SWR_CLK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_SLIMBUS_DATA2_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2C_CLK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2C_DATA_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_RX_SD0_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_RX_SD1_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_RX_SCK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_RX_WS_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_TX_SD0_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_TX_SD1_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_TX_SCK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_I2S_TX_WS_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC1_CLK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC1_DATA_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC2_CLK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC2_DATA_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC3_CLK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_DMIC3_DATA_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_JTDI_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_JTDO_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_JTMS_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_JTCK_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TLMM_JTRST_PINCFG)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_OE_0)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_OE_1)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_OE_2)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_OE_3)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_DATA_0)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_DATA_1)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_DATA_2)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_CTL_DATA_3)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PAD_DRVCTL)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_PIN_STATUS)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_NPL_DLY_TEST_1)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_NPL_DLY_TEST_2)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_MEM_CTRL)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_DEBUG_BUS_SEL)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_DEBUG_JTAG)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_DEBUG_EN_1)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_DEBUG_EN_2)] = 1,
-	[WCD9335_REG(WCD9335_TEST_DEBUG_DEBUG_EN_3)] = 1,
-};
-
-const u8 *wcd9335_reg[WCD9335_NUM_PAGES] = {
-	[PAGE_0] = wcd9335_page0_reg_readable,
-	[PAGE_1] = wcd9335_page1_reg_readable,
-	[PAGE_2] = wcd9335_page2_reg_readable,
-	[PAGE_6] = wcd9335_page6_reg_readable,
-	[PAGE_10] = wcd9335_page10_reg_readable,
-	[PAGE_11] = wcd9335_page11_reg_readable,
-	[PAGE_12] = wcd9335_page12_reg_readable,
-	[PAGE_13] = wcd9335_page13_reg_readable,
-	[PAGE_0X80] = wcd9335_page_0x80_reg_readable,
-};
diff --git a/drivers/mfd/wcd934x-regmap.c b/drivers/mfd/wcd934x-regmap.c
deleted file mode 100644
index 27249ee..0000000
--- a/drivers/mfd/wcd934x-regmap.c
+++ /dev/null
@@ -1,1957 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <linux/regmap.h>
-#include <linux/device.h>
-#include "wcd9xxx-regmap.h"
-
-
-static const struct reg_sequence wcd934x_1_1_defaults[] = {
-	{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0,             0x01 },
-	{ WCD934X_BIAS_VBG_FINE_ADJ,                        0x75 },
-	{ WCD934X_HPH_REFBUFF_LP_CTL,                       0x0E },
-	{ WCD934X_EAR_DAC_CTL_ATEST,                        0x08 },
-	{ WCD934X_SIDO_NEW_VOUT_A_STARTUP,                  0x17 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,                0x40 },
-	{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L,               0x81 },
-	{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R,               0x81 },
-};
-
-static const struct reg_default wcd934x_defaults[] = {
-	{ WCD934X_PAGE0_PAGE_REGISTER,                      0x00 },
-	{ WCD934X_CODEC_RPM_CLK_BYPASS,                     0x00 },
-	{ WCD934X_CODEC_RPM_CLK_GATE,                       0x1f },
-	{ WCD934X_CODEC_RPM_CLK_MCLK_CFG,                   0x00 },
-	{ WCD934X_CODEC_RPM_CLK_MCLK2_CFG,                  0x02 },
-	{ WCD934X_CODEC_RPM_I2S_DSD_CLK_SEL,                0x00 },
-	{ WCD934X_CODEC_RPM_RST_CTL,                        0x00 },
-	{ WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL,             0x04 },
-	{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0,             0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE1,             0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE2,             0x08 },
-	{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE3,             0x01 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_CTL,                 0x10 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_TEST0,               0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_TEST1,               0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT0,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT3,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT4,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT5,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT6,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT7,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT8,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT9,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT10,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT11,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT12,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT13,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15,           0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS,              0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO,      0x0d },
-	{ WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_1,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_2,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_3,            0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL,        0xcc },
-	{ WCD934X_CHIP_TIER_CTRL_SLNQ_WAIT_STATE_CTL,       0xcc },
-	{ WCD934X_CHIP_TIER_CTRL_I2C_ACTIVE,                0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_ALT_FUNC_EN,               0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_GPIO_CTL_OE,               0x00 },
-	{ WCD934X_CHIP_TIER_CTRL_GPIO_CTL_DATA,             0x00 },
-	{ WCD934X_DATA_HUB_RX0_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX1_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX2_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX3_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX4_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX5_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX6_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_RX7_CFG,                         0x00 },
-	{ WCD934X_DATA_HUB_SB_TX0_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX1_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX2_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX3_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX4_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX5_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX6_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX7_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX8_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX9_INP_CFG,                  0x00 },
-	{ WCD934X_DATA_HUB_SB_TX10_INP_CFG,                 0x00 },
-	{ WCD934X_DATA_HUB_SB_TX11_INP_CFG,                 0x00 },
-	{ WCD934X_DATA_HUB_SB_TX13_INP_CFG,                 0x00 },
-	{ WCD934X_DATA_HUB_SB_TX14_INP_CFG,                 0x00 },
-	{ WCD934X_DATA_HUB_SB_TX15_INP_CFG,                 0x00 },
-	{ WCD934X_DATA_HUB_I2S_TX0_CFG,                     0x00 },
-	{ WCD934X_DATA_HUB_I2S_TX1_0_CFG,                   0x00 },
-	{ WCD934X_DATA_HUB_I2S_TX1_1_CFG,                   0x00 },
-	{ WCD934X_DATA_HUB_I2S_0_CTL,                       0x0c },
-	{ WCD934X_DATA_HUB_I2S_1_CTL,                       0x0c },
-	{ WCD934X_DATA_HUB_I2S_2_CTL,                       0x0c },
-	{ WCD934X_DATA_HUB_I2S_3_CTL,                       0x0c },
-	{ WCD934X_DATA_HUB_I2S_CLKSRC_CTL,                  0x00 },
-	{ WCD934X_DATA_HUB_I2S_COMMON_CTL,                  0x00 },
-	{ WCD934X_DATA_HUB_I2S_0_TDM_CTL,                   0x00 },
-	{ WCD934X_DATA_HUB_I2S_STATUS,                      0x00 },
-	{ WCD934X_DMA_RDMA_CTL_0,                           0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_RDMA_0,                    0xff },
-	{ WCD934X_DMA_CH_0_1_CFG_RDMA_0,                    0xff },
-	{ WCD934X_DMA_RDMA_CTL_1,                           0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_RDMA_1,                    0xff },
-	{ WCD934X_DMA_CH_0_1_CFG_RDMA_1,                    0xff },
-	{ WCD934X_DMA_RDMA_CTL_2,                           0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_RDMA_2,                    0xff },
-	{ WCD934X_DMA_CH_0_1_CFG_RDMA_2,                    0xff },
-	{ WCD934X_DMA_RDMA_CTL_3,                           0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_RDMA_3,                    0xff },
-	{ WCD934X_DMA_CH_0_1_CFG_RDMA_3,                    0xff },
-	{ WCD934X_DMA_RDMA_CTL_4,                           0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_RDMA_4,                    0xff },
-	{ WCD934X_DMA_CH_0_1_CFG_RDMA_4,                    0xff },
-	{ WCD934X_DMA_RDMA4_PRT_CFG,                       0x00 },
-	{ WCD934X_DMA_RDMA_SBTX0_7_CFG,                    0x00 },
-	{ WCD934X_DMA_RDMA_SBTX8_11_CFG,                   0x00 },
-	{ WCD934X_DMA_WDMA_CTL_0,                          0x00 },
-	{ WCD934X_DMA_CH_4_5_CFG_WDMA_0,                   0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_WDMA_0,                   0x00 },
-	{ WCD934X_DMA_CH_0_1_CFG_WDMA_0,                   0x00 },
-	{ WCD934X_DMA_WDMA_CTL_1,                          0x00 },
-	{ WCD934X_DMA_CH_4_5_CFG_WDMA_1,                   0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_WDMA_1,                   0x00 },
-	{ WCD934X_DMA_CH_0_1_CFG_WDMA_1,                   0x00 },
-	{ WCD934X_DMA_WDMA_CTL_2,                          0x00 },
-	{ WCD934X_DMA_CH_4_5_CFG_WDMA_2,                   0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_WDMA_2,                   0x00 },
-	{ WCD934X_DMA_CH_0_1_CFG_WDMA_2,                   0x00 },
-	{ WCD934X_DMA_WDMA_CTL_3,                          0x00 },
-	{ WCD934X_DMA_CH_4_5_CFG_WDMA_3,                   0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_WDMA_3,                   0x00 },
-	{ WCD934X_DMA_CH_0_1_CFG_WDMA_3,                   0x00 },
-	{ WCD934X_DMA_WDMA_CTL_4,                          0x00 },
-	{ WCD934X_DMA_CH_4_5_CFG_WDMA_4,                   0x00 },
-	{ WCD934X_DMA_CH_2_3_CFG_WDMA_4,                   0x00 },
-	{ WCD934X_DMA_CH_0_1_CFG_WDMA_4,                   0x00 },
-	{ WCD934X_DMA_WDMA0_PRT_CFG,                       0x00 },
-	{ WCD934X_DMA_WDMA3_PRT_CFG,                       0x00 },
-	{ WCD934X_DMA_WDMA4_PRT0_3_CFG,                    0x00 },
-	{ WCD934X_DMA_WDMA4_PRT4_7_CFG,                    0x00 },
-	{ WCD934X_PAGE1_PAGE_REGISTER,                     0x00 },
-	{ WCD934X_CPE_FLL_USER_CTL_0,                      0x71 },
-	{ WCD934X_CPE_FLL_USER_CTL_1,                      0x34 },
-	{ WCD934X_CPE_FLL_USER_CTL_2,                      0x0b },
-	{ WCD934X_CPE_FLL_USER_CTL_3,                      0x02 },
-	{ WCD934X_CPE_FLL_USER_CTL_4,                      0x04 },
-	{ WCD934X_CPE_FLL_USER_CTL_5,                      0x02 },
-	{ WCD934X_CPE_FLL_USER_CTL_6,                      0x6e },
-	{ WCD934X_CPE_FLL_USER_CTL_7,                      0x00 },
-	{ WCD934X_CPE_FLL_USER_CTL_8,                      0x94 },
-	{ WCD934X_CPE_FLL_USER_CTL_9,                      0x50 },
-	{ WCD934X_CPE_FLL_L_VAL_CTL_0,                     0x53 },
-	{ WCD934X_CPE_FLL_L_VAL_CTL_1,                     0x00 },
-	{ WCD934X_CPE_FLL_DSM_FRAC_CTL_0,                  0x00 },
-	{ WCD934X_CPE_FLL_DSM_FRAC_CTL_1,                  0xff },
-	{ WCD934X_CPE_FLL_CONFIG_CTL_0,                    0x6b },
-	{ WCD934X_CPE_FLL_CONFIG_CTL_1,                    0x05 },
-	{ WCD934X_CPE_FLL_CONFIG_CTL_2,                    0x08 },
-	{ WCD934X_CPE_FLL_CONFIG_CTL_3,                    0x00 },
-	{ WCD934X_CPE_FLL_CONFIG_CTL_4,                    0x10 },
-	{ WCD934X_CPE_FLL_TEST_CTL_0,                      0x80 },
-	{ WCD934X_CPE_FLL_TEST_CTL_1,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_2,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_3,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_4,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_5,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_6,                      0x00 },
-	{ WCD934X_CPE_FLL_TEST_CTL_7,                      0x33 },
-	{ WCD934X_CPE_FLL_FREQ_CTL_0,                      0x00 },
-	{ WCD934X_CPE_FLL_FREQ_CTL_1,                      0x00 },
-	{ WCD934X_CPE_FLL_FREQ_CTL_2,                      0x00 },
-	{ WCD934X_CPE_FLL_FREQ_CTL_3,                      0x00 },
-	{ WCD934X_CPE_FLL_SSC_CTL_0,                       0x00 },
-	{ WCD934X_CPE_FLL_SSC_CTL_1,                       0x00 },
-	{ WCD934X_CPE_FLL_SSC_CTL_2,                       0x00 },
-	{ WCD934X_CPE_FLL_SSC_CTL_3,                       0x00 },
-	{ WCD934X_CPE_FLL_FLL_MODE,                        0x20 },
-	{ WCD934X_CPE_FLL_STATUS_0,                        0x00 },
-	{ WCD934X_CPE_FLL_STATUS_1,                        0x00 },
-	{ WCD934X_CPE_FLL_STATUS_2,                        0x00 },
-	{ WCD934X_CPE_FLL_STATUS_3,                        0x00 },
-	{ WCD934X_I2S_FLL_USER_CTL_0,                      0x41 },
-	{ WCD934X_I2S_FLL_USER_CTL_1,                      0x94 },
-	{ WCD934X_I2S_FLL_USER_CTL_2,                      0x08 },
-	{ WCD934X_I2S_FLL_USER_CTL_3,                      0x02 },
-	{ WCD934X_I2S_FLL_USER_CTL_4,                      0x04 },
-	{ WCD934X_I2S_FLL_USER_CTL_5,                      0x02 },
-	{ WCD934X_I2S_FLL_USER_CTL_6,                      0x40 },
-	{ WCD934X_I2S_FLL_USER_CTL_7,                      0x00 },
-	{ WCD934X_I2S_FLL_USER_CTL_8,                      0x5f },
-	{ WCD934X_I2S_FLL_USER_CTL_9,                      0x02 },
-	{ WCD934X_I2S_FLL_L_VAL_CTL_0,                     0x40 },
-	{ WCD934X_I2S_FLL_L_VAL_CTL_1,                     0x00 },
-	{ WCD934X_I2S_FLL_DSM_FRAC_CTL_0,                  0x00 },
-	{ WCD934X_I2S_FLL_DSM_FRAC_CTL_1,                  0xff },
-	{ WCD934X_I2S_FLL_CONFIG_CTL_0,                    0x6b },
-	{ WCD934X_I2S_FLL_CONFIG_CTL_1,                    0x05 },
-	{ WCD934X_I2S_FLL_CONFIG_CTL_2,                    0x08 },
-	{ WCD934X_I2S_FLL_CONFIG_CTL_3,                    0x00 },
-	{ WCD934X_I2S_FLL_CONFIG_CTL_4,                    0x30 },
-	{ WCD934X_I2S_FLL_TEST_CTL_0,                      0x80 },
-	{ WCD934X_I2S_FLL_TEST_CTL_1,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_2,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_3,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_4,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_5,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_6,                      0x00 },
-	{ WCD934X_I2S_FLL_TEST_CTL_7,                      0xff },
-	{ WCD934X_I2S_FLL_FREQ_CTL_0,                      0x00 },
-	{ WCD934X_I2S_FLL_FREQ_CTL_1,                      0x00 },
-	{ WCD934X_I2S_FLL_FREQ_CTL_2,                      0x00 },
-	{ WCD934X_I2S_FLL_FREQ_CTL_3,                      0x00 },
-	{ WCD934X_I2S_FLL_SSC_CTL_0,                       0x00 },
-	{ WCD934X_I2S_FLL_SSC_CTL_1,                       0x00 },
-	{ WCD934X_I2S_FLL_SSC_CTL_2,                       0x00 },
-	{ WCD934X_I2S_FLL_SSC_CTL_3,                       0x00 },
-	{ WCD934X_I2S_FLL_FLL_MODE,                        0x00 },
-	{ WCD934X_I2S_FLL_STATUS_0,                        0x00 },
-	{ WCD934X_I2S_FLL_STATUS_1,                        0x00 },
-	{ WCD934X_I2S_FLL_STATUS_2,                        0x00 },
-	{ WCD934X_I2S_FLL_STATUS_3,                        0x00 },
-	{ WCD934X_SB_FLL_USER_CTL_0,                       0x41 },
-	{ WCD934X_SB_FLL_USER_CTL_1,                       0x94 },
-	{ WCD934X_SB_FLL_USER_CTL_2,                       0x08 },
-	{ WCD934X_SB_FLL_USER_CTL_3,                       0x02 },
-	{ WCD934X_SB_FLL_USER_CTL_4,                       0x04 },
-	{ WCD934X_SB_FLL_USER_CTL_5,                       0x02 },
-	{ WCD934X_SB_FLL_USER_CTL_6,                       0x40 },
-	{ WCD934X_SB_FLL_USER_CTL_7,                       0x00 },
-	{ WCD934X_SB_FLL_USER_CTL_8,                       0x5e },
-	{ WCD934X_SB_FLL_USER_CTL_9,                       0x01 },
-	{ WCD934X_SB_FLL_L_VAL_CTL_0,                      0x40 },
-	{ WCD934X_SB_FLL_L_VAL_CTL_1,                      0x00 },
-	{ WCD934X_SB_FLL_DSM_FRAC_CTL_0,                   0x00 },
-	{ WCD934X_SB_FLL_DSM_FRAC_CTL_1,                   0xff },
-	{ WCD934X_SB_FLL_CONFIG_CTL_0,                     0x6b },
-	{ WCD934X_SB_FLL_CONFIG_CTL_1,                     0x05 },
-	{ WCD934X_SB_FLL_CONFIG_CTL_2,                     0x08 },
-	{ WCD934X_SB_FLL_CONFIG_CTL_3,                     0x00 },
-	{ WCD934X_SB_FLL_CONFIG_CTL_4,                     0x10 },
-	{ WCD934X_SB_FLL_TEST_CTL_0,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_1,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_2,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_3,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_4,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_5,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_6,                       0x00 },
-	{ WCD934X_SB_FLL_TEST_CTL_7,                       0xff },
-	{ WCD934X_SB_FLL_FREQ_CTL_0,                       0x00 },
-	{ WCD934X_SB_FLL_FREQ_CTL_1,                       0x00 },
-	{ WCD934X_SB_FLL_FREQ_CTL_2,                       0x00 },
-	{ WCD934X_SB_FLL_FREQ_CTL_3,                       0x00 },
-	{ WCD934X_SB_FLL_SSC_CTL_0,                        0x00 },
-	{ WCD934X_SB_FLL_SSC_CTL_1,                        0x00 },
-	{ WCD934X_SB_FLL_SSC_CTL_2,                        0x00 },
-	{ WCD934X_SB_FLL_SSC_CTL_3,                        0x00 },
-	{ WCD934X_SB_FLL_FLL_MODE,                         0x00 },
-	{ WCD934X_SB_FLL_STATUS_0,                         0x00 },
-	{ WCD934X_SB_FLL_STATUS_1,                         0x00 },
-	{ WCD934X_SB_FLL_STATUS_2,                         0x00 },
-	{ WCD934X_SB_FLL_STATUS_3,                         0x00 },
-	{ WCD934X_PAGE2_PAGE_REGISTER,                     0x00 },
-	{ WCD934X_CPE_SS_CPE_CTL,                          0x05 },
-	{ WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0,             0x01 },
-	{ WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_1,             0x00 },
-	{ WCD934X_CPE_SS_PWR_CPEFLL_CTL,                   0x02 },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0,         0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1,         0x0f },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_OVERRIDE,  0x00 },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_4,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_5,        0xff },
-	{ WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN,           0x07 },
-	{ WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL,              0x00 },
-	{ WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL,     0x20 },
-	{ WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL1,    0x00 },
-	{ WCD934X_CPE_SS_US_BUF_INT_PERIOD,                0x60 },
-	{ WCD934X_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD,        0x13 },
-	{ WCD934X_CPE_SS_SVA_CFG,                          0x41 },
-	{ WCD934X_CPE_SS_US_CFG,                           0x00 },
-	{ WCD934X_CPE_SS_MAD_CTL,                          0x00 },
-	{ WCD934X_CPE_SS_CPAR_CTL,                         0x00 },
-	{ WCD934X_CPE_SS_DMIC0_CTL,                        0x00 },
-	{ WCD934X_CPE_SS_DMIC1_CTL,                        0x00 },
-	{ WCD934X_CPE_SS_DMIC2_CTL,                        0x00 },
-	{ WCD934X_CPE_SS_DMIC_CFG,                         0x80 },
-	{ WCD934X_CPE_SS_CPAR_CFG,                         0x00 },
-	{ WCD934X_CPE_SS_WDOG_CFG,                         0x01 },
-	{ WCD934X_CPE_SS_BACKUP_INT,                       0x00 },
-	{ WCD934X_CPE_SS_STATUS,                           0x00 },
-	{ WCD934X_CPE_SS_CPE_OCD_CFG,                      0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A,             0xff },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B,             0x3f },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_MASK_1A,             0xff },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_MASK_1B,             0x3f },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A,           0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B,           0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1A,           0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1B,           0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A,            0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B,            0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1A,            0x00 },
-	{ WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1B,            0x00 },
-	{ WCD934X_SOC_MAD_MAIN_CTL_1,                      0x00 },
-	{ WCD934X_SOC_MAD_MAIN_CTL_2,                      0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_1,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_2,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_3,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_4,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_5,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_6,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_7,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_CTL_8,                     0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR,               0x00 },
-	{ WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL,               0x40 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_1,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_2,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_3,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_4,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_5,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_6,                      0x00 },
-	{ WCD934X_SOC_MAD_ULTR_CTL_7,                      0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_1,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_2,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_3,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_4,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_5,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_6,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_7,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_CTL_8,                    0x00 },
-	{ WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR,              0x00 },
-	{ WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL,              0x00 },
-	{ WCD934X_SOC_MAD_INP_SEL,                         0x00 },
-	{ WCD934X_PAGE4_PAGE_REGISTER,                     0x00 },
-	{ WCD934X_INTR_CFG,                                0x00 },
-	{ WCD934X_INTR_CLR_COMMIT,                         0x00 },
-	{ WCD934X_INTR_PIN1_MASK0,                         0xff },
-	{ WCD934X_INTR_PIN1_MASK1,                         0xff },
-	{ WCD934X_INTR_PIN1_MASK2,                         0xff },
-	{ WCD934X_INTR_PIN1_MASK3,                         0xff },
-	{ WCD934X_INTR_PIN1_STATUS0,                       0x00 },
-	{ WCD934X_INTR_PIN1_STATUS1,                       0x00 },
-	{ WCD934X_INTR_PIN1_STATUS2,                       0x00 },
-	{ WCD934X_INTR_PIN1_STATUS3,                       0x00 },
-	{ WCD934X_INTR_PIN1_CLEAR0,                        0x00 },
-	{ WCD934X_INTR_PIN1_CLEAR1,                        0x00 },
-	{ WCD934X_INTR_PIN1_CLEAR2,                        0x00 },
-	{ WCD934X_INTR_PIN1_CLEAR3,                        0x00 },
-	{ WCD934X_INTR_PIN2_MASK3,                         0xff },
-	{ WCD934X_INTR_PIN2_STATUS3,                       0x00 },
-	{ WCD934X_INTR_PIN2_CLEAR3,                        0x00 },
-	{ WCD934X_INTR_CPESS_SUMRY_MASK2,                  0xff },
-	{ WCD934X_INTR_CPESS_SUMRY_MASK3,                  0xff },
-	{ WCD934X_INTR_CPESS_SUMRY_STATUS2,                0x00 },
-	{ WCD934X_INTR_CPESS_SUMRY_STATUS3,                0x00 },
-	{ WCD934X_INTR_CPESS_SUMRY_CLEAR2,                 0x00 },
-	{ WCD934X_INTR_CPESS_SUMRY_CLEAR3,                 0x00 },
-	{ WCD934X_INTR_LEVEL0,                             0x03 },
-	{ WCD934X_INTR_LEVEL1,                             0xe0 },
-	{ WCD934X_INTR_LEVEL2,                             0x94 },
-	{ WCD934X_INTR_LEVEL3,                             0x80 },
-	{ WCD934X_INTR_BYPASS0,                            0x00 },
-	{ WCD934X_INTR_BYPASS1,                            0x00 },
-	{ WCD934X_INTR_BYPASS2,                            0x00 },
-	{ WCD934X_INTR_BYPASS3,                            0x00 },
-	{ WCD934X_INTR_SET0,                               0x00 },
-	{ WCD934X_INTR_SET1,                               0x00 },
-	{ WCD934X_INTR_SET2,                               0x00 },
-	{ WCD934X_INTR_SET3,                               0x00 },
-	{ WCD934X_INTR_CODEC_MISC_MASK,                    0x7f },
-	{ WCD934X_INTR_CODEC_MISC_STATUS,                  0x00 },
-	{ WCD934X_INTR_CODEC_MISC_CLEAR,                   0x00 },
-	{ WCD934X_PAGE5_PAGE_REGISTER,                     0x00 },
-	{ WCD934X_SLNQ_DIG_DEVICE,                         0x49 },
-	{ WCD934X_SLNQ_DIG_REVISION,                       0x01 },
-	{ WCD934X_SLNQ_DIG_H_COMMAND,                      0x00 },
-	{ WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_MSB,             0x00 },
-	{ WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_LSB,             0x00 },
-	{ WCD934X_SLNQ_DIG_MASTER_ADDRESS_MSB,             0x00 },
-	{ WCD934X_SLNQ_DIG_MASTER_ADDRESS_LSB,             0x00 },
-	{ WCD934X_SLNQ_DIG_SLAVE_ADDRESS_MSB,              0x00 },
-	{ WCD934X_SLNQ_DIG_SLAVE_ADDRESS_LSB,              0x00 },
-	{ WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_MSB,           0x40 },
-	{ WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_LSB,           0x00 },
-	{ WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_MSB,           0x40 },
-	{ WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_LSB,           0x00 },
-	{ WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_MSB,           0x40 },
-	{ WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_LSB,           0x00 },
-	{ WCD934X_SLNQ_DIG_COMM_CTL,                       0x00 },
-	{ WCD934X_SLNQ_DIG_FRAME_CTRL,                     0x01 },
-	{ WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH1_2,             0x77 },
-	{ WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH3_4,             0x77 },
-	{ WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH5,               0x70 },
-	{ WCD934X_SLNQ_DIG_SW_EVENT_RD,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SW_EVENT_CTRL,                  0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_SELECT_1,                   0x12 },
-	{ WCD934X_SLNQ_DIG_PDM_SELECT_2,                   0x34 },
-	{ WCD934X_SLNQ_DIG_PDM_SELECT_3,                   0x55 },
-	{ WCD934X_SLNQ_DIG_PDM_SAMPLING_FREQ,              0x01 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_CTL,          0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_SEL,          0x11 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_MSB,            0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_LSB,            0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_MSB,            0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_LSB,            0x00 },
-	{ WCD934X_SLNQ_DIG_RAM_CNTRL,                      0x01 },
-	{ WCD934X_SLNQ_DIG_SRAM_BANK,                      0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_0,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_4,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_5,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_6,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_7,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_8,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_9,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_A,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_B,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_C,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_D,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_E,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_F,                    0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_10,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_11,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_12,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_13,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_14,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_15,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_16,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_17,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_18,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_19,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1A,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1B,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1C,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1D,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1E,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_1F,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_20,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_21,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_22,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_23,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_24,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_25,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_26,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_27,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_28,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_29,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2A,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2B,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2C,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2D,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2E,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_2F,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_30,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_31,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_32,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_33,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_34,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_35,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_36,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_37,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_38,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_39,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3A,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3B,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3C,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3D,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3E,                   0x00 },
-	{ WCD934X_SLNQ_DIG_SRAM_BYTE_3F,                   0x00 },
-	{ WCD934X_SLNQ_DIG_TOP_CTRL1,                      0x00 },
-	{ WCD934X_SLNQ_DIG_TOP_CTRL2,                      0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_CTRL,                       0x00 },
-	{ WCD934X_SLNQ_DIG_PDM_MUTE_CTRL,                  0x20 },
-	{ WCD934X_SLNQ_DIG_DEC_BYPASS_CTRL,                0x00 },
-	{ WCD934X_SLNQ_DIG_DEC_BYPASS_STATUS,              0x00 },
-	{ WCD934X_SLNQ_DIG_DEC_BYPASS_FS,                  0x00 },
-	{ WCD934X_SLNQ_DIG_DEC_BYPASS_IN_SEL,              0x00 },
-	{ WCD934X_SLNQ_DIG_GPOUT_ENABLE,                   0x00 },
-	{ WCD934X_SLNQ_DIG_GPOUT_VAL,                      0x00 },
-	{ WCD934X_SLNQ_DIG_ANA_INTERRUPT_MASK,             0x00 },
-	{ WCD934X_SLNQ_DIG_ANA_INTERRUPT_STATUS,           0x00 },
-	{ WCD934X_SLNQ_DIG_ANA_INTERRUPT_CLR,              0x00 },
-	{ WCD934X_SLNQ_DIG_IP_TESTING,                     0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CNTRL,                0x0f },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CNT,                  0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CNT_MSB,              0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CNT_LSB,              0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_MASK0,                0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_MASK1,                0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_MASK2,                0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_MASK3,                0xff },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_MASK4,                0x1f },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_STATUS0,              0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_STATUS1,              0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_STATUS2,              0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_STATUS3,              0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_STATUS4,              0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CLR0,                 0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CLR1,                 0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CLR2,                 0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CLR3,                 0x00 },
-	{ WCD934X_SLNQ_DIG_INTERRUPT_CLR4,                 0x00 },
-	{ WCD934X_ANA_PAGE_REGISTER,                       0x00 },
-	{ WCD934X_ANA_BIAS,                                0x00 },
-	{ WCD934X_ANA_RCO,                                 0x00 },
-	{ WCD934X_ANA_PAGE6_SPARE2,                        0x00 },
-	{ WCD934X_ANA_PAGE6_SPARE3,                        0x00 },
-	{ WCD934X_ANA_BUCK_CTL,                            0x00 },
-	{ WCD934X_ANA_BUCK_STATUS,                         0x00 },
-	{ WCD934X_ANA_RX_SUPPLIES,                         0x00 },
-	{ WCD934X_ANA_HPH,                                 0x0c },
-	{ WCD934X_ANA_EAR,                                 0x00 },
-	{ WCD934X_ANA_LO_1_2,                              0x3c },
-	{ WCD934X_ANA_MAD_SETUP,                           0x01 },
-	{ WCD934X_ANA_AMIC1,                               0x20 },
-	{ WCD934X_ANA_AMIC2,                               0x00 },
-	{ WCD934X_ANA_AMIC3,                               0x20 },
-	{ WCD934X_ANA_AMIC4,                               0x00 },
-	{ WCD934X_ANA_MBHC_MECH,                           0x39 },
-	{ WCD934X_ANA_MBHC_ELECT,                          0x08 },
-	{ WCD934X_ANA_MBHC_ZDET,                           0x00 },
-	{ WCD934X_ANA_MBHC_RESULT_1,                       0x00 },
-	{ WCD934X_ANA_MBHC_RESULT_2,                       0x00 },
-	{ WCD934X_ANA_MBHC_RESULT_3,                       0x00 },
-	{ WCD934X_ANA_MBHC_BTN0,                           0x00 },
-	{ WCD934X_ANA_MBHC_BTN1,                           0x10 },
-	{ WCD934X_ANA_MBHC_BTN2,                           0x20 },
-	{ WCD934X_ANA_MBHC_BTN3,                           0x30 },
-	{ WCD934X_ANA_MBHC_BTN4,                           0x40 },
-	{ WCD934X_ANA_MBHC_BTN5,                           0x50 },
-	{ WCD934X_ANA_MBHC_BTN6,                           0x60 },
-	{ WCD934X_ANA_MBHC_BTN7,                           0x70 },
-	{ WCD934X_ANA_MICB1,                               0x10 },
-	{ WCD934X_ANA_MICB2,                               0x10 },
-	{ WCD934X_ANA_MICB2_RAMP,                          0x00 },
-	{ WCD934X_ANA_MICB3,                               0x10 },
-	{ WCD934X_ANA_MICB4,                               0x10 },
-	{ WCD934X_ANA_VBADC,                               0x00 },
-	{ WCD934X_BIAS_CTL,                                0x28 },
-	{ WCD934X_BIAS_VBG_FINE_ADJ,                       0x65 },
-	{ WCD934X_RCO_CTRL_1,                              0x44 },
-	{ WCD934X_RCO_CTRL_2,                              0x48 },
-	{ WCD934X_RCO_CAL,                                 0x00 },
-	{ WCD934X_RCO_CAL_1,                               0x00 },
-	{ WCD934X_RCO_CAL_2,                               0x00 },
-	{ WCD934X_RCO_TEST_CTRL,                           0x00 },
-	{ WCD934X_RCO_CAL_OUT_1,                           0x00 },
-	{ WCD934X_RCO_CAL_OUT_2,                           0x00 },
-	{ WCD934X_RCO_CAL_OUT_3,                           0x00 },
-	{ WCD934X_RCO_CAL_OUT_4,                           0x00 },
-	{ WCD934X_RCO_CAL_OUT_5,                           0x00 },
-	{ WCD934X_SIDO_MODE_1,                             0x84 },
-	{ WCD934X_SIDO_MODE_2,                             0xfe },
-	{ WCD934X_SIDO_MODE_3,                             0xf6 },
-	{ WCD934X_SIDO_MODE_4,                             0x56 },
-	{ WCD934X_SIDO_VCL_1,                              0x00 },
-	{ WCD934X_SIDO_VCL_2,                              0x6c },
-	{ WCD934X_SIDO_VCL_3,                              0x44 },
-	{ WCD934X_SIDO_CCL_1,                              0x57 },
-	{ WCD934X_SIDO_CCL_2,                              0x92 },
-	{ WCD934X_SIDO_CCL_3,                              0x35 },
-	{ WCD934X_SIDO_CCL_4,                              0x61 },
-	{ WCD934X_SIDO_CCL_5,                              0x6d },
-	{ WCD934X_SIDO_CCL_6,                              0x60 },
-	{ WCD934X_SIDO_CCL_7,                              0x6f },
-	{ WCD934X_SIDO_CCL_8,                              0x6f },
-	{ WCD934X_SIDO_CCL_9,                              0x6e },
-	{ WCD934X_SIDO_CCL_10,                             0x26 },
-	{ WCD934X_SIDO_FILTER_1,                           0x92 },
-	{ WCD934X_SIDO_FILTER_2,                           0x54 },
-	{ WCD934X_SIDO_DRIVER_1,                           0x77 },
-	{ WCD934X_SIDO_DRIVER_2,                           0x55 },
-	{ WCD934X_SIDO_DRIVER_3,                           0x55 },
-	{ WCD934X_SIDO_CAL_CODE_EXT_1,                     0x9c },
-	{ WCD934X_SIDO_CAL_CODE_EXT_2,                     0x82 },
-	{ WCD934X_SIDO_CAL_CODE_OUT_1,                     0x00 },
-	{ WCD934X_SIDO_CAL_CODE_OUT_2,                     0x00 },
-	{ WCD934X_SIDO_TEST_1,                             0x00 },
-	{ WCD934X_SIDO_TEST_2,                             0x00 },
-	{ WCD934X_MBHC_CTL_CLK,                            0x30 },
-	{ WCD934X_MBHC_CTL_ANA,                            0x00 },
-	{ WCD934X_MBHC_CTL_SPARE_1,                        0x00 },
-	{ WCD934X_MBHC_CTL_SPARE_2,                        0x00 },
-	{ WCD934X_MBHC_CTL_BCS,                            0x00 },
-	{ WCD934X_MBHC_STATUS_SPARE_1,                     0x00 },
-	{ WCD934X_MBHC_TEST_CTL,                           0x00 },
-	{ WCD934X_VBADC_SUBBLOCK_EN,                       0xde },
-	{ WCD934X_VBADC_IBIAS_FE,                          0x58 },
-	{ WCD934X_VBADC_BIAS_ADC,                          0x51 },
-	{ WCD934X_VBADC_FE_CTRL,                           0x1c },
-	{ WCD934X_VBADC_ADC_REF,                           0x20 },
-	{ WCD934X_VBADC_ADC_IO,                            0x80 },
-	{ WCD934X_VBADC_ADC_SAR,                           0xff },
-	{ WCD934X_VBADC_DEBUG,                             0x00 },
-	{ WCD934X_LDOH_MODE,                               0x2b },
-	{ WCD934X_LDOH_BIAS,                               0x68 },
-	{ WCD934X_LDOH_STB_LOADS,                          0x00 },
-	{ WCD934X_LDOH_SLOWRAMP,                           0x50 },
-	{ WCD934X_MICB1_TEST_CTL_1,                        0x1a },
-	{ WCD934X_MICB1_TEST_CTL_2,                        0x18 },
-	{ WCD934X_MICB1_TEST_CTL_3,                        0xa4 },
-	{ WCD934X_MICB2_TEST_CTL_1,                        0x1a },
-	{ WCD934X_MICB2_TEST_CTL_2,                        0x18 },
-	{ WCD934X_MICB2_TEST_CTL_3,                        0xa4 },
-	{ WCD934X_MICB3_TEST_CTL_1,                        0x1a },
-	{ WCD934X_MICB3_TEST_CTL_2,                        0x18 },
-	{ WCD934X_MICB3_TEST_CTL_3,                        0xa4 },
-	{ WCD934X_MICB4_TEST_CTL_1,                        0x1a },
-	{ WCD934X_MICB4_TEST_CTL_2,                        0x18 },
-	{ WCD934X_MICB4_TEST_CTL_3,                        0xa4 },
-	{ WCD934X_TX_COM_ADC_VCM,                          0x39 },
-	{ WCD934X_TX_COM_BIAS_ATEST,                       0xc0 },
-	{ WCD934X_TX_COM_ADC_INT1_IB,                      0x6f },
-	{ WCD934X_TX_COM_ADC_INT2_IB,                      0x4f },
-	{ WCD934X_TX_COM_TXFE_DIV_CTL,                     0x2e },
-	{ WCD934X_TX_COM_TXFE_DIV_START,                   0x00 },
-	{ WCD934X_TX_COM_TXFE_DIV_STOP_9P6M,               0xc7 },
-	{ WCD934X_TX_COM_TXFE_DIV_STOP_12P288M,            0xff },
-	{ WCD934X_TX_1_2_TEST_EN,                          0xcc },
-	{ WCD934X_TX_1_2_ADC_IB,                           0x09 },
-	{ WCD934X_TX_1_2_ATEST_REFCTL,                     0x0a },
-	{ WCD934X_TX_1_2_TEST_CTL,                         0x38 },
-	{ WCD934X_TX_1_2_TEST_BLK_EN,                      0xff },
-	{ WCD934X_TX_1_2_TXFE_CLKDIV,                      0x00 },
-	{ WCD934X_TX_1_2_SAR1_ERR,                         0x00 },
-	{ WCD934X_TX_1_2_SAR2_ERR,                         0x00 },
-	{ WCD934X_TX_3_4_TEST_EN,                          0xcc },
-	{ WCD934X_TX_3_4_ADC_IB,                           0x09 },
-	{ WCD934X_TX_3_4_ATEST_REFCTL,                     0x0a },
-	{ WCD934X_TX_3_4_TEST_CTL,                         0x38 },
-	{ WCD934X_TX_3_4_TEST_BLK_EN,                      0xff },
-	{ WCD934X_TX_3_4_TXFE_CLKDIV,                      0x00 },
-	{ WCD934X_TX_3_4_SAR1_ERR,                         0x00 },
-	{ WCD934X_TX_3_4_SAR2_ERR,                         0x00 },
-	{ WCD934X_CLASSH_MODE_1,                           0x40 },
-	{ WCD934X_CLASSH_MODE_2,                           0x3a },
-	{ WCD934X_CLASSH_MODE_3,                           0x00 },
-	{ WCD934X_CLASSH_CTRL_VCL_1,                       0x70 },
-	{ WCD934X_CLASSH_CTRL_VCL_2,                       0x82 },
-	{ WCD934X_CLASSH_CTRL_CCL_1,                       0x31 },
-	{ WCD934X_CLASSH_CTRL_CCL_2,                       0x80 },
-	{ WCD934X_CLASSH_CTRL_CCL_3,                       0x80 },
-	{ WCD934X_CLASSH_CTRL_CCL_4,                       0x51 },
-	{ WCD934X_CLASSH_CTRL_CCL_5,                       0x00 },
-	{ WCD934X_CLASSH_BUCK_TMUX_A_D,                    0x00 },
-	{ WCD934X_CLASSH_BUCK_SW_DRV_CNTL,                 0x77 },
-	{ WCD934X_CLASSH_SPARE,                            0x00 },
-	{ WCD934X_FLYBACK_EN,                              0x4e },
-	{ WCD934X_FLYBACK_VNEG_CTRL_1,                     0x0b },
-	{ WCD934X_FLYBACK_VNEG_CTRL_2,                     0x45 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_3,                     0x74 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_4,                     0x7f },
-	{ WCD934X_FLYBACK_VNEG_CTRL_5,                     0x83 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_6,                     0x98 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_7,                     0xa9 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_8,                     0x68 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_9,                     0x64 },
-	{ WCD934X_FLYBACK_VNEGDAC_CTRL_1,                  0xed },
-	{ WCD934X_FLYBACK_VNEGDAC_CTRL_2,                  0xf0 },
-	{ WCD934X_FLYBACK_VNEGDAC_CTRL_3,                  0xa6 },
-	{ WCD934X_FLYBACK_CTRL_1,                          0x65 },
-	{ WCD934X_FLYBACK_TEST_CTL,                        0x00 },
-	{ WCD934X_RX_AUX_SW_CTL,                           0x00 },
-	{ WCD934X_RX_PA_AUX_IN_CONN,                       0x00 },
-	{ WCD934X_RX_TIMER_DIV,                            0x32 },
-	{ WCD934X_RX_OCP_CTL,                              0x1f },
-	{ WCD934X_RX_OCP_COUNT,                            0x77 },
-	{ WCD934X_RX_BIAS_EAR_DAC,                         0xa0 },
-	{ WCD934X_RX_BIAS_EAR_AMP,                         0xaa },
-	{ WCD934X_RX_BIAS_HPH_LDO,                         0xa9 },
-	{ WCD934X_RX_BIAS_HPH_PA,                          0xaa },
-	{ WCD934X_RX_BIAS_HPH_RDACBUFF_CNP2,               0x8a },
-	{ WCD934X_RX_BIAS_HPH_RDAC_LDO,                    0x88 },
-	{ WCD934X_RX_BIAS_HPH_CNP1,                        0x82 },
-	{ WCD934X_RX_BIAS_HPH_LOWPOWER,                    0x82 },
-	{ WCD934X_RX_BIAS_DIFFLO_PA,                       0x80 },
-	{ WCD934X_RX_BIAS_DIFFLO_REF,                      0x88 },
-	{ WCD934X_RX_BIAS_DIFFLO_LDO,                      0x88 },
-	{ WCD934X_RX_BIAS_SELO_DAC_PA,                     0xa8 },
-	{ WCD934X_RX_BIAS_BUCK_RST,                        0x08 },
-	{ WCD934X_RX_BIAS_BUCK_VREF_ERRAMP,                0x44 },
-	{ WCD934X_RX_BIAS_FLYB_ERRAMP,                     0x40 },
-	{ WCD934X_RX_BIAS_FLYB_BUFF,                       0xaa },
-	{ WCD934X_RX_BIAS_FLYB_MID_RST,                    0x14 },
-	{ WCD934X_HPH_L_STATUS,                            0x04 },
-	{ WCD934X_HPH_R_STATUS,                            0x04 },
-	{ WCD934X_HPH_CNP_EN,                              0x80 },
-	{ WCD934X_HPH_CNP_WG_CTL,                          0x9a },
-	{ WCD934X_HPH_CNP_WG_TIME,                         0x14 },
-	{ WCD934X_HPH_OCP_CTL,                             0x28 },
-	{ WCD934X_HPH_AUTO_CHOP,                           0x16 },
-	{ WCD934X_HPH_CHOP_CTL,                            0x83 },
-	{ WCD934X_HPH_PA_CTL1,                             0x46 },
-	{ WCD934X_HPH_PA_CTL2,                             0x50 },
-	{ WCD934X_HPH_L_EN,                                0x80 },
-	{ WCD934X_HPH_L_TEST,                              0xe0 },
-	{ WCD934X_HPH_L_ATEST,                             0x50 },
-	{ WCD934X_HPH_R_EN,                                0x80 },
-	{ WCD934X_HPH_R_TEST,                              0xe0 },
-	{ WCD934X_HPH_R_ATEST,                             0x54 },
-	{ WCD934X_HPH_RDAC_CLK_CTL1,                       0x99 },
-	{ WCD934X_HPH_RDAC_CLK_CTL2,                       0x9b },
-	{ WCD934X_HPH_RDAC_LDO_CTL,                        0x33 },
-	{ WCD934X_HPH_RDAC_CHOP_CLK_LP_CTL,                0x00 },
-	{ WCD934X_HPH_REFBUFF_UHQA_CTL,                    0xa8 },
-	{ WCD934X_HPH_REFBUFF_LP_CTL,                      0x0a },
-	{ WCD934X_HPH_L_DAC_CTL,                           0x00 },
-	{ WCD934X_HPH_R_DAC_CTL,                           0x00 },
-	{ WCD934X_EAR_EN_REG,                              0x60 },
-	{ WCD934X_EAR_CMBUFF,                              0x05 },
-	{ WCD934X_EAR_ICTL,                                0x40 },
-	{ WCD934X_EAR_EN_DBG_CTL,                          0x00 },
-	{ WCD934X_EAR_CNP,                                 0xe0 },
-	{ WCD934X_EAR_DAC_CTL_ATEST,                       0x00 },
-	{ WCD934X_EAR_STATUS_REG,                          0x04 },
-	{ WCD934X_EAR_EAR_MISC,                            0x28 },
-	{ WCD934X_DIFF_LO_MISC,                            0x03 },
-	{ WCD934X_DIFF_LO_LO2_COMPANDER,                   0x00 },
-	{ WCD934X_DIFF_LO_LO1_COMPANDER,                   0x00 },
-	{ WCD934X_DIFF_LO_COMMON,                          0x40 },
-	{ WCD934X_DIFF_LO_BYPASS_EN,                       0x00 },
-	{ WCD934X_DIFF_LO_CNP,                             0x20 },
-	{ WCD934X_DIFF_LO_CORE_OUT_PROG,                   0xa0 },
-	{ WCD934X_DIFF_LO_LDO_OUT_PROG,                    0x00 },
-	{ WCD934X_DIFF_LO_COM_SWCAP_REFBUF_FREQ,           0x8b },
-	{ WCD934X_DIFF_LO_COM_PA_FREQ,                     0xb0 },
-	{ WCD934X_DIFF_LO_RESERVED_REG,                    0x60 },
-	{ WCD934X_DIFF_LO_LO1_STATUS_1,                    0x00 },
-	{ WCD934X_DIFF_LO_LO1_STATUS_2,                    0x00 },
-	{ WCD934X_ANA_NEW_PAGE_REGISTER,                   0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH2,                        0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH3,                        0x00 },
-	{ WCD934X_SLNQ_ANA_EN,                             0x02 },
-	{ WCD934X_SLNQ_ANA_STATUS,                         0x00 },
-	{ WCD934X_SLNQ_ANA_LDO_CONFIG,                     0xea },
-	{ WCD934X_SLNQ_ANA_LDO_OCP_CONFIG,                 0x95 },
-	{ WCD934X_SLNQ_ANA_TX_LDO_CONFIG,                  0xb6 },
-	{ WCD934X_SLNQ_ANA_TX_DRV_CONFIG,                  0x26 },
-	{ WCD934X_SLNQ_ANA_RX_CONFIG_1,                    0x64 },
-	{ WCD934X_SLNQ_ANA_RX_CONFIG_2,                    0x40 },
-	{ WCD934X_SLNQ_ANA_PLL_ENABLES,                    0x00 },
-	{ WCD934X_SLNQ_ANA_PLL_PRESET,                     0x08 },
-	{ WCD934X_SLNQ_ANA_PLL_STATUS,                     0x00 },
-	{ WCD934X_CLK_SYS_PLL_ENABLES,                     0x00 },
-	{ WCD934X_CLK_SYS_PLL_PRESET,                      0x00 },
-	{ WCD934X_CLK_SYS_PLL_STATUS,                      0x00 },
-	{ WCD934X_CLK_SYS_MCLK_PRG,                        0x00 },
-	{ WCD934X_CLK_SYS_MCLK2_PRG1,                      0x00 },
-	{ WCD934X_CLK_SYS_MCLK2_PRG2,                      0x00 },
-	{ WCD934X_CLK_SYS_XO_PRG,                          0x00 },
-	{ WCD934X_CLK_SYS_XO_CAP_XTP,                      0x00 },
-	{ WCD934X_CLK_SYS_XO_CAP_XTM,                      0x00 },
-	{ WCD934X_BOOST_BST_EN_DLY,                        0x40 },
-	{ WCD934X_BOOST_CTRL_ILIM,                         0x9c },
-	{ WCD934X_BOOST_VOUT_SETTING,                      0xca },
-	{ WCD934X_SIDO_NEW_VOUT_A_STARTUP,                 0x05 },
-	{ WCD934X_SIDO_NEW_VOUT_D_STARTUP,                 0x0d },
-	{ WCD934X_SIDO_NEW_VOUT_D_FREQ1,                   0x07 },
-	{ WCD934X_SIDO_NEW_VOUT_D_FREQ2,                   0x00 },
-	{ WCD934X_MBHC_NEW_ELECT_REM_CLAMP_CTL,            0x00 },
-	{ WCD934X_MBHC_NEW_CTL_1,                          0x02 },
-	{ WCD934X_MBHC_NEW_CTL_2,                          0x05 },
-	{ WCD934X_MBHC_NEW_PLUG_DETECT_CTL,                0xe9 },
-	{ WCD934X_MBHC_NEW_ZDET_ANA_CTL,                   0x0f },
-	{ WCD934X_MBHC_NEW_ZDET_RAMP_CTL,                  0x00 },
-	{ WCD934X_MBHC_NEW_FSM_STATUS,                     0x00 },
-	{ WCD934X_MBHC_NEW_ADC_RESULT,                     0x00 },
-	{ WCD934X_TX_NEW_AMIC_4_5_SEL,                     0x00 },
-	{ WCD934X_VBADC_NEW_ADC_MODE,                      0x10 },
-	{ WCD934X_VBADC_NEW_ADC_DOUTMSB,                   0x00 },
-	{ WCD934X_VBADC_NEW_ADC_DOUTLSB,                   0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,               0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL,                0xa0 },
-	{ WCD934X_HPH_NEW_INT_RDAC_VREF_CTL,               0x10 },
-	{ WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL,           0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_MISC1,                  0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC1,                    0x22 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC2,                    0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC,                0x00 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1,                  0xfe },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER2,                  0x02 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER3,                  0x4e },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER4,                  0x54 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC2,               0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC3,               0x00 },
-	{ WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI,         0x62 },
-	{ WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_ULP,            0x01 },
-	{ WCD934X_RX_NEW_INT_HPH_RDAC_LDO_LP,              0x11 },
-	{ WCD934X_SLNQ_INT_ANA_INT_LDO_TEST,               0x0d },
-	{ WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_1,            0x85 },
-	{ WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_2,            0xb4 },
-	{ WCD934X_SLNQ_INT_ANA_INT_TX_LDO_TEST,            0x16 },
-	{ WCD934X_SLNQ_INT_ANA_INT_TX_DRV_TEST,            0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RX_TEST,                0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RX_TEST_STATUS,         0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_1,             0x50 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_2,             0x04 },
-	{ WCD934X_SLNQ_INT_ANA_INT_CLK_CTRL,               0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RESERVED_1,             0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_RESERVED_2,             0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG0,      0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG1,      0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG0,       0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG1,       0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG0,        0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG1,        0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_L_VAL,              0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_M_VAL,              0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_N_VAL,              0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG0,          0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_PFD_CP_DSM_PROG,    0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_VCO_PROG,           0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG1,          0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_LDO_LOCK_CFG,       0x00 },
-	{ WCD934X_SLNQ_INT_ANA_INT_PLL_DIG_LOCK_DET_CFG,   0x00 },
-	{ WCD934X_CLK_SYS_INT_POST_DIV_REG0,               0x00 },
-	{ WCD934X_CLK_SYS_INT_POST_DIV_REG1,               0x00 },
-	{ WCD934X_CLK_SYS_INT_REF_DIV_REG0,                0x00 },
-	{ WCD934X_CLK_SYS_INT_REF_DIV_REG1,                0x00 },
-	{ WCD934X_CLK_SYS_INT_FILTER_REG0,                 0x00 },
-	{ WCD934X_CLK_SYS_INT_FILTER_REG1,                 0x00 },
-	{ WCD934X_CLK_SYS_INT_PLL_L_VAL,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_PLL_M_VAL,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_PLL_N_VAL,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_TEST_REG0,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_PFD_CP_DSM_PROG,             0x00 },
-	{ WCD934X_CLK_SYS_INT_VCO_PROG,                    0x00 },
-	{ WCD934X_CLK_SYS_INT_TEST_REG1,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_LDO_LOCK_CFG,                0x00 },
-	{ WCD934X_CLK_SYS_INT_DIG_LOCK_DET_CFG,            0x00 },
-	{ WCD934X_CLK_SYS_INT_CLK_TEST1,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_CLK_TEST2,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_CLK_TEST3,                   0x00 },
-	{ WCD934X_CLK_SYS_INT_XO_TEST1,                    0x98 },
-	{ WCD934X_CLK_SYS_INT_XO_TEST2,                    0x00 },
-	{ WCD934X_BOOST_INT_VCOMP_HYST,                    0x02 },
-	{ WCD934X_BOOST_INT_VLOOP_FILTER,                  0xef },
-	{ WCD934X_BOOST_INT_CTRL_IDELTA,                   0xa8 },
-	{ WCD934X_BOOST_INT_CTRL_ILIM_STARTUP,             0x17 },
-	{ WCD934X_BOOST_INT_CTRL_MIN_ONTIME,               0x5f },
-	{ WCD934X_BOOST_INT_CTRL_MAX_ONTIME,               0x88 },
-	{ WCD934X_BOOST_INT_CTRL_TIMING,                   0x0a },
-	{ WCD934X_BOOST_INT_TMUX_A_D,                      0x00 },
-	{ WCD934X_BOOST_INT_SW_DRV_CNTL,                   0xf8 },
-	{ WCD934X_BOOST_INT_SPARE1,                        0x00 },
-	{ WCD934X_BOOST_INT_SPARE2,                        0x00 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_STATUS,                0x00 },
-	{ WCD934X_SIDO_NEW_INT_SPARE_1,                    0x00 },
-	{ WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_A,       0x64 },
-	{ WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_D,       0x40 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_INC_WAIT,              0x24 },
-	{ WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_CTL,          0x09 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_IBLEED_CTL,            0x7d },
-	{ WCD934X_SIDO_NEW_INT_DEBUG_CPROVR_TEST,          0x00 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_CTL_A,                 0x14 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_CTL_D,                 0x14 },
-	{ WCD934X_SIDO_NEW_INT_RAMP_TIMEOUT_PERIOD,        0x33 },
-	{ WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING1,     0x3f },
-	{ WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING2,     0x74 },
-	{ WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING3,     0x33 },
-	{ WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL1,        0x1d },
-	{ WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL2,        0x0a },
-	{ WCD934X_MBHC_NEW_INT_SLNQ_HPF,                   0x50 },
-	{ WCD934X_MBHC_NEW_INT_SLNQ_REF,                   0x24 },
-	{ WCD934X_MBHC_NEW_INT_SLNQ_COMP,                  0x50 },
-	{ WCD934X_MBHC_NEW_INT_SPARE_2,                    0x00 },
-	{ WCD934X_PAGE10_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CDC_ANC0_CLK_RESET_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC0_MODE_1_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC0_MODE_2_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC0_FF_SHIFT,                       0x00 },
-	{ WCD934X_CDC_ANC0_FB_SHIFT,                       0x00 },
-	{ WCD934X_CDC_ANC0_LPF_FF_A_CTL,                   0x00 },
-	{ WCD934X_CDC_ANC0_LPF_FF_B_CTL,                   0x00 },
-	{ WCD934X_CDC_ANC0_LPF_FB_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC0_SMLPF_CTL,                      0x00 },
-	{ WCD934X_CDC_ANC0_DCFLT_SHIFT_CTL,                0x00 },
-	{ WCD934X_CDC_ANC0_IIR_ADAPT_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC0_IIR_COEFF_1_CTL,                0x00 },
-	{ WCD934X_CDC_ANC0_IIR_COEFF_2_CTL,                0x00 },
-	{ WCD934X_CDC_ANC0_FF_A_GAIN_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC0_FF_B_GAIN_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC0_FB_GAIN_CTL,                    0x00 },
-	{ WCD934X_CDC_ANC0_RC_COMMON_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC0_FIFO_COMMON_CTL,                0x88 },
-	{ WCD934X_CDC_ANC0_RC0_STATUS_FMIN_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC0_RC1_STATUS_FMIN_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC0_RC0_STATUS_FMAX_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC0_RC1_STATUS_FMAX_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC0_STATUS_FIFO,                    0x00 },
-	{ WCD934X_CDC_ANC1_CLK_RESET_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC1_MODE_1_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC1_MODE_2_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC1_FF_SHIFT,                       0x00 },
-	{ WCD934X_CDC_ANC1_FB_SHIFT,                       0x00 },
-	{ WCD934X_CDC_ANC1_LPF_FF_A_CTL,                   0x00 },
-	{ WCD934X_CDC_ANC1_LPF_FF_B_CTL,                   0x00 },
-	{ WCD934X_CDC_ANC1_LPF_FB_CTL,                     0x00 },
-	{ WCD934X_CDC_ANC1_SMLPF_CTL,                      0x00 },
-	{ WCD934X_CDC_ANC1_DCFLT_SHIFT_CTL,                0x00 },
-	{ WCD934X_CDC_ANC1_IIR_ADAPT_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC1_IIR_COEFF_1_CTL,                0x00 },
-	{ WCD934X_CDC_ANC1_IIR_COEFF_2_CTL,                0x00 },
-	{ WCD934X_CDC_ANC1_FF_A_GAIN_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC1_FF_B_GAIN_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC1_FB_GAIN_CTL,                    0x00 },
-	{ WCD934X_CDC_ANC1_RC_COMMON_CTL,                  0x00 },
-	{ WCD934X_CDC_ANC1_FIFO_COMMON_CTL,                0x88 },
-	{ WCD934X_CDC_ANC1_RC0_STATUS_FMIN_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC1_RC1_STATUS_FMIN_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC1_RC0_STATUS_FMAX_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC1_RC1_STATUS_FMAX_CNTR,           0x00 },
-	{ WCD934X_CDC_ANC1_STATUS_FIFO,                    0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX0_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX0_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX0_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX0_TX_PATH_SEC7,                    0x25 },
-	{ WCD934X_CDC_TX1_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX1_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX1_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX1_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX1_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX2_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX2_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX2_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX2_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX3_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX3_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX3_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX3_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX4_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX4_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX4_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX4_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX5_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX5_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX5_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX5_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX6_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX6_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX6_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX6_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX7_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX7_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX7_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX7_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_TX8_TX_PATH_CFG0,                    0x10 },
-	{ WCD934X_CDC_TX8_TX_PATH_CFG1,                    0x03 },
-	{ WCD934X_CDC_TX8_TX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_192_CTL,                 0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_192_CFG,                 0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC0,                    0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC1,                    0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC2,                    0x01 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC3,                    0x3c },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC4,                    0x20 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_TX8_TX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL,              0x02 },
-	{ WCD934X_CDC_TX9_SPKR_PROT_PATH_CFG0,             0x00 },
-	{ WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL,             0x02 },
-	{ WCD934X_CDC_TX10_SPKR_PROT_PATH_CFG0,            0x00 },
-	{ WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL,             0x02 },
-	{ WCD934X_CDC_TX11_SPKR_PROT_PATH_CFG0,            0x00 },
-	{ WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL,             0x02 },
-	{ WCD934X_CDC_TX12_SPKR_PROT_PATH_CFG0,            0x00 },
-	{ WCD934X_PAGE11_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CDC_COMPANDER1_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER1_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER1_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER1_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER1_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER1_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER1_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER1_CTL7,                     0x08 },
-	{ WCD934X_CDC_COMPANDER2_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER2_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER2_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER2_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER2_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER2_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER2_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER2_CTL7,                     0x08 },
-	{ WCD934X_CDC_COMPANDER3_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER3_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER3_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER3_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER3_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER3_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER3_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER3_CTL7,                     0x08 },
-	{ WCD934X_CDC_COMPANDER4_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER4_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER4_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER4_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER4_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER4_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER4_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER4_CTL7,                     0x08 },
-	{ WCD934X_CDC_COMPANDER7_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER7_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER7_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER7_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER7_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER7_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER7_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER7_CTL7,                     0x08 },
-	{ WCD934X_CDC_COMPANDER8_CTL0,                     0x60 },
-	{ WCD934X_CDC_COMPANDER8_CTL1,                     0xdb },
-	{ WCD934X_CDC_COMPANDER8_CTL2,                     0xff },
-	{ WCD934X_CDC_COMPANDER8_CTL3,                     0x35 },
-	{ WCD934X_CDC_COMPANDER8_CTL4,                     0xff },
-	{ WCD934X_CDC_COMPANDER8_CTL5,                     0x00 },
-	{ WCD934X_CDC_COMPANDER8_CTL6,                     0x01 },
-	{ WCD934X_CDC_COMPANDER8_CTL7,                     0x08 },
-	{ WCD934X_CDC_RX0_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX0_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX0_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX0_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX0_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX0_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC0,                    0xfc },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX0_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX1_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX1_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX1_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX1_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX1_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC0,                    0xfc },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC4,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX1_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX2_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX2_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX2_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX2_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX2_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC0,                    0xfc },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC4,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX2_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX3_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX3_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX3_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX3_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX3_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC0,                    0xfc },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX3_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX4_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX4_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX4_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX4_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX4_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC0,                    0xfc },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX4_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX7_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX7_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX7_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX7_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX7_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC0,                    0x04 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX7_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_CTL,                     0x04 },
-	{ WCD934X_CDC_RX8_RX_PATH_CFG0,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_CFG1,                    0x64 },
-	{ WCD934X_CDC_RX8_RX_PATH_CFG2,                    0x8f },
-	{ WCD934X_CDC_RX8_RX_VOL_CTL,                      0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_MIX_CTL,                 0x04 },
-	{ WCD934X_CDC_RX8_RX_PATH_MIX_CFG,                 0x7e },
-	{ WCD934X_CDC_RX8_RX_VOL_MIX_CTL,                  0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC0,                    0x04 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC1,                    0x08 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC2,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC3,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC5,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC6,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_SEC7,                    0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_MIX_SEC0,                0x08 },
-	{ WCD934X_CDC_RX8_RX_PATH_MIX_SEC1,                0x00 },
-	{ WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL,              0x00 },
-	{ WCD934X_PAGE12_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CDC_CLSH_CRC,                            0x00 },
-	{ WCD934X_CDC_CLSH_DLY_CTRL,                       0x03 },
-	{ WCD934X_CDC_CLSH_DECAY_CTRL,                     0x02 },
-	{ WCD934X_CDC_CLSH_HPH_V_PA,                       0x1c },
-	{ WCD934X_CDC_CLSH_EAR_V_PA,                       0x39 },
-	{ WCD934X_CDC_CLSH_HPH_V_HD,                       0x0c },
-	{ WCD934X_CDC_CLSH_EAR_V_HD,                       0x0c },
-	{ WCD934X_CDC_CLSH_K1_MSB,                         0x01 },
-	{ WCD934X_CDC_CLSH_K1_LSB,                         0x00 },
-	{ WCD934X_CDC_CLSH_K2_MSB,                         0x00 },
-	{ WCD934X_CDC_CLSH_K2_LSB,                         0x80 },
-	{ WCD934X_CDC_CLSH_IDLE_CTRL,                      0x00 },
-	{ WCD934X_CDC_CLSH_IDLE_HPH,                       0x00 },
-	{ WCD934X_CDC_CLSH_IDLE_EAR,                       0x00 },
-	{ WCD934X_CDC_CLSH_TEST0,                          0x07 },
-	{ WCD934X_CDC_CLSH_TEST1,                          0x00 },
-	{ WCD934X_CDC_CLSH_OVR_VREF,                       0x00 },
-	{ WCD934X_CDC_BOOST0_BOOST_PATH_CTL,               0x00 },
-	{ WCD934X_CDC_BOOST0_BOOST_CTL,                    0xb2 },
-	{ WCD934X_CDC_BOOST0_BOOST_CFG1,                   0x00 },
-	{ WCD934X_CDC_BOOST0_BOOST_CFG2,                   0x00 },
-	{ WCD934X_CDC_BOOST1_BOOST_PATH_CTL,               0x00 },
-	{ WCD934X_CDC_BOOST1_BOOST_CTL,                    0xb2 },
-	{ WCD934X_CDC_BOOST1_BOOST_CFG1,                   0x00 },
-	{ WCD934X_CDC_BOOST1_BOOST_CFG2,                   0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_PATH_CTL,                  0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_CFG,                       0x1a },
-	{ WCD934X_CDC_VBAT_VBAT_ADC_CAL1,                  0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_ADC_CAL2,                  0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_ADC_CAL3,                  0x04 },
-	{ WCD934X_CDC_VBAT_VBAT_PK_EST1,                   0xe0 },
-	{ WCD934X_CDC_VBAT_VBAT_PK_EST2,                   0x01 },
-	{ WCD934X_CDC_VBAT_VBAT_PK_EST3,                   0x40 },
-	{ WCD934X_CDC_VBAT_VBAT_RF_PROC1,                  0x2a },
-	{ WCD934X_CDC_VBAT_VBAT_RF_PROC2,                  0x86 },
-	{ WCD934X_CDC_VBAT_VBAT_TAC1,                      0x70 },
-	{ WCD934X_CDC_VBAT_VBAT_TAC2,                      0x18 },
-	{ WCD934X_CDC_VBAT_VBAT_TAC3,                      0x18 },
-	{ WCD934X_CDC_VBAT_VBAT_TAC4,                      0x03 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_UPD1,                 0x01 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_UPD2,                 0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_UPD3,                 0x64 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_UPD4,                 0x01 },
-	{ WCD934X_CDC_VBAT_VBAT_DEBUG1,                    0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_UPD_MON,              0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_GAIN_MON_VAL,              0x00 },
-	{ WCD934X_CDC_VBAT_VBAT_BAN,                       0x0c },
-	{ WCD934X_MIXING_ASRC0_CLK_RST_CTL,                0x00 },
-	{ WCD934X_MIXING_ASRC0_CTL0,                       0x00 },
-	{ WCD934X_MIXING_ASRC0_CTL1,                       0x00 },
-	{ WCD934X_MIXING_ASRC0_FIFO_CTL,                   0xa8 },
-	{ WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC0_STATUS_FIFO,                0x00 },
-	{ WCD934X_MIXING_ASRC1_CLK_RST_CTL,                0x00 },
-	{ WCD934X_MIXING_ASRC1_CTL0,                       0x00 },
-	{ WCD934X_MIXING_ASRC1_CTL1,                       0x00 },
-	{ WCD934X_MIXING_ASRC1_FIFO_CTL,                   0xa8 },
-	{ WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC1_STATUS_FIFO,                0x00 },
-	{ WCD934X_MIXING_ASRC2_CLK_RST_CTL,                0x00 },
-	{ WCD934X_MIXING_ASRC2_CTL0,                       0x00 },
-	{ WCD934X_MIXING_ASRC2_CTL1,                       0x00 },
-	{ WCD934X_MIXING_ASRC2_FIFO_CTL,                   0xa8 },
-	{ WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC2_STATUS_FIFO,                0x00 },
-	{ WCD934X_MIXING_ASRC3_CLK_RST_CTL,                0x00 },
-	{ WCD934X_MIXING_ASRC3_CTL0,                       0x00 },
-	{ WCD934X_MIXING_ASRC3_CTL1,                       0x00 },
-	{ WCD934X_MIXING_ASRC3_FIFO_CTL,                   0xa8 },
-	{ WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_LSB,       0x00 },
-	{ WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_MSB,       0x00 },
-	{ WCD934X_MIXING_ASRC3_STATUS_FIFO,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_DATA_0,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_DATA_1,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_DATA_2,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_DATA_3,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_ADDR_0,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_ADDR_1,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_ADDR_2,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_WR_ADDR_3,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_ADDR_0,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_ADDR_1,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_ADDR_2,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_ADDR_3,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_DATA_0,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_DATA_1,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_DATA_2,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_RD_DATA_3,                0x00 },
-	{ WCD934X_SWR_AHB_BRIDGE_ACCESS_CFG,               0x0f },
-	{ WCD934X_SWR_AHB_BRIDGE_ACCESS_STATUS,            0x03 },
-	{ WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,       0x04 },
-	{ WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1,      0x00 },
-	{ WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,       0x04 },
-	{ WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1,      0x00 },
-	{ WCD934X_SIDETONE_ASRC0_CLK_RST_CTL,              0x00 },
-	{ WCD934X_SIDETONE_ASRC0_CTL0,                     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_CTL1,                     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_FIFO_CTL,                 0xa8 },
-	{ WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_LSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_MSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_LSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_MSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC0_STATUS_FIFO,              0x00 },
-	{ WCD934X_SIDETONE_ASRC1_CLK_RST_CTL,              0x00 },
-	{ WCD934X_SIDETONE_ASRC1_CTL0,                     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_CTL1,                     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_FIFO_CTL,                 0xa8 },
-	{ WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_LSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_MSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_LSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_MSB,     0x00 },
-	{ WCD934X_SIDETONE_ASRC1_STATUS_FIFO,              0x00 },
-	{ WCD934X_EC_REF_HQ0_EC_REF_HQ_PATH_CTL,           0x00 },
-	{ WCD934X_EC_REF_HQ0_EC_REF_HQ_CFG0,               0x01 },
-	{ WCD934X_EC_REF_HQ1_EC_REF_HQ_PATH_CTL,           0x00 },
-	{ WCD934X_EC_REF_HQ1_EC_REF_HQ_CFG0,               0x01 },
-	{ WCD934X_EC_ASRC0_CLK_RST_CTL,                    0x00 },
-	{ WCD934X_EC_ASRC0_CTL0,                           0x00 },
-	{ WCD934X_EC_ASRC0_CTL1,                           0x00 },
-	{ WCD934X_EC_ASRC0_FIFO_CTL,                       0xa8 },
-	{ WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_LSB,           0x00 },
-	{ WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_MSB,           0x00 },
-	{ WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_LSB,           0x00 },
-	{ WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_MSB,           0x00 },
-	{ WCD934X_EC_ASRC0_STATUS_FIFO,                    0x00 },
-	{ WCD934X_EC_ASRC1_CLK_RST_CTL,                    0x00 },
-	{ WCD934X_EC_ASRC1_CTL0,                           0x00 },
-	{ WCD934X_EC_ASRC1_CTL1,                           0x00 },
-	{ WCD934X_EC_ASRC1_FIFO_CTL,                       0xa8 },
-	{ WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_LSB,           0x00 },
-	{ WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_MSB,           0x00 },
-	{ WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_LSB,           0x00 },
-	{ WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_MSB,           0x00 },
-	{ WCD934X_EC_ASRC1_STATUS_FIFO,                    0x00 },
-	{ WCD934X_PAGE13_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1,             0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG0,              0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG1,              0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG2,              0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG3,              0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG4,              0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0,        0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1,        0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_ANC_CFG0,                 0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0,         0x00 },
-	{ WCD934X_CDC_RX_INP_MUX_EC_REF_HQ_CFG0,           0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0,            0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX10_CFG0,           0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX11_CFG0,           0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX12_CFG0,           0x00 },
-	{ WCD934X_CDC_TX_INP_MUX_ADC_MUX13_CFG0,           0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2,  0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3,  0x00 },
-	{ WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0,               0x00 },
-	{ WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1,               0x00 },
-	{ WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2,               0x00 },
-	{ WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3,               0x00 },
-	{ WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL,           0x00 },
-	{ WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,         0x0c },
-	{ WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL,            0x00 },
-	{ WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL,            0x00 },
-	{ WCD934X_CDC_CLK_RST_CTRL_ASRC_SHARE_CONTROL,     0x0f },
-	{ WCD934X_CDC_CLK_RST_CTRL_GFM_CONTROL,            0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_CTL,                0x08 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD0,       0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD1,       0x4b },
-	{ WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB,    0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB,    0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_STATUS,             0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_TEST_CTRL,          0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB,      0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB,      0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD,   0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD,   0x00 },
-	{ WCD934X_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT,     0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_PATH_CTL,          0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_CTL,               0x40 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL,    0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_PATH_CTL,          0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_CTL,               0x40 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL,    0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL,       0x00 },
-	{ WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL,       0x00 },
-	{ WCD934X_CDC_TOP_TOP_CFG0,                        0x00 },
-	{ WCD934X_CDC_TOP_TOP_CFG1,                        0x00 },
-	{ WCD934X_CDC_TOP_TOP_CFG7,                        0x00 },
-	{ WCD934X_CDC_TOP_HPHL_COMP_WR_LSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHL_COMP_WR_MSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHL_COMP_LUT,                   0x00 },
-	{ WCD934X_CDC_TOP_HPHL_COMP_RD_LSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHL_COMP_RD_MSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHR_COMP_WR_LSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHR_COMP_WR_MSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHR_COMP_LUT,                   0x00 },
-	{ WCD934X_CDC_TOP_HPHR_COMP_RD_LSB,                0x00 },
-	{ WCD934X_CDC_TOP_HPHR_COMP_RD_MSB,                0x00 },
-	{ WCD934X_CDC_TOP_DIFFL_COMP_WR_LSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFL_COMP_WR_MSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFL_COMP_LUT,                  0x00 },
-	{ WCD934X_CDC_TOP_DIFFL_COMP_RD_LSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFL_COMP_RD_MSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFR_COMP_WR_LSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFR_COMP_WR_MSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFR_COMP_LUT,                  0x00 },
-	{ WCD934X_CDC_TOP_DIFFR_COMP_RD_LSB,               0x00 },
-	{ WCD934X_CDC_TOP_DIFFR_COMP_RD_MSB,               0x00 },
-	{ WCD934X_CDC_DSD0_PATH_CTL,                       0x00 },
-	{ WCD934X_CDC_DSD0_CFG0,                           0x00 },
-	{ WCD934X_CDC_DSD0_CFG1,                           0x00 },
-	{ WCD934X_CDC_DSD0_CFG2,                           0x42 },
-	{ WCD934X_CDC_DSD0_CFG3,                           0x00 },
-	{ WCD934X_CDC_DSD0_CFG4,                           0x02 },
-	{ WCD934X_CDC_DSD0_CFG5,                           0x00 },
-	{ WCD934X_CDC_DSD1_PATH_CTL,                       0x00 },
-	{ WCD934X_CDC_DSD1_CFG0,                           0x00 },
-	{ WCD934X_CDC_DSD1_CFG1,                           0x00 },
-	{ WCD934X_CDC_DSD1_CFG2,                           0x42 },
-	{ WCD934X_CDC_DSD1_CFG3,                           0x00 },
-	{ WCD934X_CDC_DSD1_CFG4,                           0x02 },
-	{ WCD934X_CDC_DSD1_CFG5,                           0x00 },
-	{ WCD934X_CDC_RX_IDLE_DET_PATH_CTL,                0x00 },
-	{ WCD934X_CDC_RX_IDLE_DET_CFG0,                    0x07 },
-	{ WCD934X_CDC_RX_IDLE_DET_CFG1,                    0x3c },
-	{ WCD934X_CDC_RX_IDLE_DET_CFG2,                    0x00 },
-	{ WCD934X_CDC_RX_IDLE_DET_CFG3,                    0x00 },
-	{ WCD934X_PAGE14_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_CLK_RST_CTL,            0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_CTL,                    0x09 },
-	{ WCD934X_CDC_RATE_EST0_RE_PULSE_SUPR_CTL,         0x06 },
-	{ WCD934X_CDC_RATE_EST0_RE_TIMER,                  0x01 },
-	{ WCD934X_CDC_RATE_EST0_RE_BW_SW,                  0x20 },
-	{ WCD934X_CDC_RATE_EST0_RE_THRESH,                 0xa0 },
-	{ WCD934X_CDC_RATE_EST0_RE_STATUS,                 0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_CTRL,              0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_TIMER2,            0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW1,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW2,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW3,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW4,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW5,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW1,         0x08 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW2,         0x07 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW3,         0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW4,         0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW5,         0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW1,       0x08 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW2,       0x07 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW3,       0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW4,       0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW5,       0x05 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW1,          0x03 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW2,          0x03 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW3,          0x03 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW4,          0x03 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW5,          0x03 },
-	{ WCD934X_CDC_RATE_EST0_RE_RMAX_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RMIN_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_PH_DET,                 0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_DIAG_CLR,               0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_MB_SW_STATE,            0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_MAST_DIAG_STATE,        0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_7_0,           0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_15_8,          0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_23_16,         0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_31_24,         0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_39_32,         0x00 },
-	{ WCD934X_CDC_RATE_EST0_RE_RATE_OUT_40_43,         0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_CLK_RST_CTL,            0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_CTL,                    0x09 },
-	{ WCD934X_CDC_RATE_EST1_RE_PULSE_SUPR_CTL,         0x06 },
-	{ WCD934X_CDC_RATE_EST1_RE_TIMER,                  0x01 },
-	{ WCD934X_CDC_RATE_EST1_RE_BW_SW,                  0x20 },
-	{ WCD934X_CDC_RATE_EST1_RE_THRESH,                 0xa0 },
-	{ WCD934X_CDC_RATE_EST1_RE_STATUS,                 0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_CTRL,              0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_TIMER2,            0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW1,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW2,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW3,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW4,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW5,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW1,         0x08 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW2,         0x07 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW3,         0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW4,         0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW5,         0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW1,       0x08 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW2,       0x07 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW3,       0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW4,       0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW5,       0x05 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW1,          0x03 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW2,          0x03 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW3,          0x03 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW4,          0x03 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW5,          0x03 },
-	{ WCD934X_CDC_RATE_EST1_RE_RMAX_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RMIN_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_PH_DET,                 0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_DIAG_CLR,               0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_MB_SW_STATE,            0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_MAST_DIAG_STATE,        0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_7_0,           0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_15_8,          0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_23_16,         0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_31_24,         0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_39_32,         0x00 },
-	{ WCD934X_CDC_RATE_EST1_RE_RATE_OUT_40_43,         0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_CLK_RST_CTL,            0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_CTL,                    0x09 },
-	{ WCD934X_CDC_RATE_EST2_RE_PULSE_SUPR_CTL,         0x06 },
-	{ WCD934X_CDC_RATE_EST2_RE_TIMER,                  0x01 },
-	{ WCD934X_CDC_RATE_EST2_RE_BW_SW,                  0x20 },
-	{ WCD934X_CDC_RATE_EST2_RE_THRESH,                 0xa0 },
-	{ WCD934X_CDC_RATE_EST2_RE_STATUS,                 0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_CTRL,              0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_TIMER2,            0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW1,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW2,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW3,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW4,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW5,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW1,         0x08 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW2,         0x07 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW3,         0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW4,         0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW5,         0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW1,       0x08 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW2,       0x07 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW3,       0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW4,       0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW5,       0x05 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW1,          0x03 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW2,          0x03 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW3,          0x03 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW4,          0x03 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW5,          0x03 },
-	{ WCD934X_CDC_RATE_EST2_RE_RMAX_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RMIN_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_PH_DET,                 0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_DIAG_CLR,               0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_MB_SW_STATE,            0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_MAST_DIAG_STATE,        0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_7_0,           0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_15_8,          0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_23_16,         0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_31_24,         0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_39_32,         0x00 },
-	{ WCD934X_CDC_RATE_EST2_RE_RATE_OUT_40_43,         0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_CLK_RST_CTL,            0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_CTL,                    0x09 },
-	{ WCD934X_CDC_RATE_EST3_RE_PULSE_SUPR_CTL,         0x06 },
-	{ WCD934X_CDC_RATE_EST3_RE_TIMER,                  0x01 },
-	{ WCD934X_CDC_RATE_EST3_RE_BW_SW,                  0x20 },
-	{ WCD934X_CDC_RATE_EST3_RE_THRESH,                 0xa0 },
-	{ WCD934X_CDC_RATE_EST3_RE_STATUS,                 0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_CTRL,              0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_TIMER2,            0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW1,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW2,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW3,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW4,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW5,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW1,         0x08 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW2,         0x07 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW3,         0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW4,         0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW5,         0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW1,       0x08 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW2,       0x07 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW3,       0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW4,       0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW5,       0x05 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW1,          0x03 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW2,          0x03 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW3,          0x03 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW4,          0x03 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW5,          0x03 },
-	{ WCD934X_CDC_RATE_EST3_RE_RMAX_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RMIN_DIAG,              0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_PH_DET,                 0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_DIAG_CLR,               0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_MB_SW_STATE,            0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_MAST_DIAG_STATE,        0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_7_0,           0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_15_8,          0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_23_16,         0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_31_24,         0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_39_32,         0x00 },
-	{ WCD934X_CDC_RATE_EST3_RE_RATE_OUT_40_43,         0x00 },
-	{ WCD934X_PAGE15_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_SPLINE_SRC0_CLK_RST_CTL_0,               0x20 },
-	{ WCD934X_SPLINE_SRC0_STATUS,                      0x00 },
-	{ WCD934X_SPLINE_SRC1_CLK_RST_CTL_0,               0x20 },
-	{ WCD934X_SPLINE_SRC1_STATUS,                      0x00 },
-	{ WCD934X_SPLINE_SRC2_CLK_RST_CTL_0,               0x20 },
-	{ WCD934X_SPLINE_SRC2_STATUS,                      0x00 },
-	{ WCD934X_SPLINE_SRC3_CLK_RST_CTL_0,               0x20 },
-	{ WCD934X_SPLINE_SRC3_STATUS,                      0x00 },
-	{ WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0,               0x11 },
-	{ WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1,               0x20 },
-	{ WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG2,               0x00 },
-	{ WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3,               0x08 },
-	{ WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0,               0x11 },
-	{ WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1,               0x20 },
-	{ WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG2,               0x00 },
-	{ WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3,               0x08 },
-	{ WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG0,         0x00 },
-	{ WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG1,         0x00 },
-	{ WCD934X_CDC_DEBUG_RC_RE_ASRC_DEBUG_CFG0,         0x00 },
-	{ WCD934X_CDC_DEBUG_ANC0_RC0_FIFO_CTL,             0x4c },
-	{ WCD934X_CDC_DEBUG_ANC0_RC1_FIFO_CTL,             0x4c },
-	{ WCD934X_CDC_DEBUG_ANC1_RC0_FIFO_CTL,             0x4c },
-	{ WCD934X_CDC_DEBUG_ANC1_RC1_FIFO_CTL,             0x4c },
-	{ WCD934X_CDC_DEBUG_ANC_RC_RST_DBG_CNTR,           0x00 },
-	{ WCD934X_PAGE80_PAGE_REGISTER,                    0x00 },
-	{ WCD934X_CODEC_CPR_WR_DATA_0,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_DATA_1,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_DATA_2,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_DATA_3,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_ADDR_0,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_ADDR_1,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_ADDR_2,                     0x00 },
-	{ WCD934X_CODEC_CPR_WR_ADDR_3,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_ADDR_0,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_ADDR_1,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_ADDR_2,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_ADDR_3,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_DATA_0,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_DATA_1,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_DATA_2,                     0x00 },
-	{ WCD934X_CODEC_CPR_RD_DATA_3,                     0x00 },
-	{ WCD934X_CODEC_CPR_ACCESS_CFG,                    0x0f },
-	{ WCD934X_CODEC_CPR_ACCESS_STATUS,                 0x03 },
-	{ WCD934X_CODEC_CPR_NOM_CX_VDD,                    0xb4 },
-	{ WCD934X_CODEC_CPR_SVS_CX_VDD,                    0x5c },
-	{ WCD934X_CODEC_CPR_SVS2_CX_VDD,                   0x40 },
-	{ WCD934X_CODEC_CPR_NOM_MX_VDD,                    0xb4 },
-	{ WCD934X_CODEC_CPR_SVS_MX_VDD,                    0xb4 },
-	{ WCD934X_CODEC_CPR_SVS2_MX_VDD,                   0xa0 },
-	{ WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD,               0x28 },
-	{ WCD934X_CODEC_CPR_MAX_SVS2_STEP,                 0x08 },
-	{ WCD934X_CODEC_CPR_CTL,                           0x00 },
-	{ WCD934X_CODEC_CPR_SW_MODECHNG_STATUS,            0x00 },
-	{ WCD934X_CODEC_CPR_SW_MODECHNG_START,             0x00 },
-	{ WCD934X_CODEC_CPR_CPR_STATUS,                    0x00 },
-	{ WCD934X_PAGE128_PAGE_REGISTER,                   0x00 },
-	{ WCD934X_TLMM_BIST_MODE_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_RF_PA_ON_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_INTR1_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_INTR2_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_SWR_DATA_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_SWR_CLK_PINCFG,                     0x00 },
-	{ WCD934X_TLMM_I2S_2_SCK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_SLIMBUS_DATA1_PINCFG,               0x00 },
-	{ WCD934X_TLMM_SLIMBUS_DATA2_PINCFG,               0x00 },
-	{ WCD934X_TLMM_SLIMBUS_CLK_PINCFG,                 0x00 },
-	{ WCD934X_TLMM_I2C_CLK_PINCFG,                     0x00 },
-	{ WCD934X_TLMM_I2C_DATA_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_0_RX_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_0_TX_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_0_SCK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_I2S_0_WS_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_1_RX_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_1_TX_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_1_SCK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_I2S_1_WS_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_DMIC1_CLK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_DMIC1_DATA_PINCFG,                  0x00 },
-	{ WCD934X_TLMM_DMIC2_CLK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_DMIC2_DATA_PINCFG,                  0x00 },
-	{ WCD934X_TLMM_DMIC3_CLK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_DMIC3_DATA_PINCFG,                  0x00 },
-	{ WCD934X_TLMM_JTCK_PINCFG,                        0x00 },
-	{ WCD934X_TLMM_GPIO1_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_GPIO2_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_GPIO3_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_GPIO4_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_SPI_S_CSN_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_SPI_S_CLK_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_SPI_S_DOUT_PINCFG,                  0x00 },
-	{ WCD934X_TLMM_SPI_S_DIN_PINCFG,                   0x00 },
-	{ WCD934X_TLMM_BA_N_PINCFG,                        0x00 },
-	{ WCD934X_TLMM_GPIO0_PINCFG,                       0x00 },
-	{ WCD934X_TLMM_I2S_2_RX_PINCFG,                    0x00 },
-	{ WCD934X_TLMM_I2S_2_WS_PINCFG,                    0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_OE_0,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_OE_1,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_OE_2,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_OE_3,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_OE_4,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_DATA_0,               0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_DATA_1,               0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_DATA_2,               0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_DATA_3,               0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_CTL_DATA_4,               0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_DRVCTL_0,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_DRVCTL_1,                 0x00 },
-	{ WCD934X_TEST_DEBUG_PIN_STATUS,                   0x00 },
-	{ WCD934X_TEST_DEBUG_NPL_DLY_TEST_1,               0x10 },
-	{ WCD934X_TEST_DEBUG_NPL_DLY_TEST_2,               0x60 },
-	{ WCD934X_TEST_DEBUG_MEM_CTRL,                     0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_BUS_SEL,                0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_JTAG,                   0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_EN_1,                   0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_EN_2,                   0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_EN_3,                   0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_EN_4,                   0x00 },
-	{ WCD934X_TEST_DEBUG_DEBUG_EN_5,                   0x00 },
-	{ WCD934X_TEST_DEBUG_ANA_DTEST_DIR,                0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_INP_DISABLE_0,            0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_INP_DISABLE_1,            0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_INP_DISABLE_2,            0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_INP_DISABLE_3,            0x00 },
-	{ WCD934X_TEST_DEBUG_PAD_INP_DISABLE_4,            0x00 },
-	{ WCD934X_TEST_DEBUG_SYSMEM_CTRL,                  0x00 },
-	{ WCD934X_TEST_DEBUG_SOC_SW_PWR_SEQ_DELAY,         0x00 },
-	{ WCD934X_TEST_DEBUG_LVAL_NOM_LOW,                 0x96 },
-	{ WCD934X_TEST_DEBUG_LVAL_NOM_HIGH,                0x00 },
-	{ WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW,            0x53 },
-	{ WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH,           0x00 },
-	{ WCD934X_TEST_DEBUG_SPI_SLAVE_CHAR,               0x00 },
-	{ WCD934X_TEST_DEBUG_CODEC_DIAGS,                  0x00 },
-};
-
-/*
- * wcd934x_regmap_register_patch: Update register defaults based on version
- * @regmap: handle to wcd9xxx regmap
- * @version: wcd934x version
- *
- * Returns error code in case of failure or 0 for success
- */
-int wcd934x_regmap_register_patch(struct regmap *regmap, int revision)
-{
-	int rc = 0;
-
-	if (!regmap) {
-		pr_err("%s: regmap struct is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (revision) {
-	case TAVIL_VERSION_1_1:
-	case TAVIL_VERSION_WCD9340_1_1:
-	case TAVIL_VERSION_WCD9341_1_1:
-		regcache_cache_only(regmap, true);
-		rc = regmap_multi_reg_write(regmap, wcd934x_1_1_defaults,
-					    ARRAY_SIZE(wcd934x_1_1_defaults));
-		regcache_cache_only(regmap, false);
-		break;
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd934x_regmap_register_patch);
-
-static bool wcd934x_is_readable_register(struct device *dev, unsigned int reg)
-{
-	u8 pg_num, reg_offset;
-	const u8 *reg_tbl = NULL;
-
-	/*
-	 * Get the page number from MSB of codec register. If its 0x80, assign
-	 * the corresponding page index PAGE_0x80.
-	 */
-	pg_num = reg >> 0x8;
-	if (pg_num == 0x80)
-		pg_num = WCD934X_PAGE_0X80;
-	else if (pg_num == 0x50)
-		pg_num = WCD934X_PAGE_0x50;
-	else if (pg_num > 0xF)
-		return false;
-
-	reg_tbl = wcd934x_reg[pg_num];
-	reg_offset = reg & 0xFF;
-
-	if (reg_tbl && reg_tbl[reg_offset])
-		return true;
-	else
-		return false;
-}
-
-static bool wcd934x_is_volatile_register(struct device *dev, unsigned int reg)
-{
-	u8 pg_num, reg_offset;
-	const u8 *reg_tbl = NULL;
-
-	pg_num = reg >> 0x8;
-	if (pg_num == 0x80)
-		pg_num = WCD934X_PAGE_0X80;
-	else if (pg_num == 0x50)
-		pg_num = WCD934X_PAGE_0x50;
-	else if (pg_num > 0xF)
-		return false;
-
-	reg_tbl = wcd934x_reg[pg_num];
-	reg_offset = reg & 0xFF;
-
-	if (reg_tbl && reg_tbl[reg_offset] == WCD934X_READ)
-		return true;
-
-	/* IIR Coeff registers are not cacheable */
-	if ((reg >= WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL) &&
-	    (reg <= WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL))
-		return true;
-
-	if ((reg >= WCD934X_CDC_ANC0_IIR_COEFF_1_CTL) &&
-	    (reg <= WCD934X_CDC_ANC0_FB_GAIN_CTL))
-		return true;
-
-	if ((reg >= WCD934X_CDC_ANC1_IIR_COEFF_1_CTL) &&
-	    (reg <= WCD934X_CDC_ANC1_FB_GAIN_CTL))
-		return true;
-
-	if ((reg >= WCD934X_CODEC_CPR_WR_DATA_0) &&
-	    (reg <= WCD934X_CODEC_CPR_RD_DATA_3))
-		return true;
-
-	/*
-	 * Need to mark volatile for registers that are writable but
-	 * only few bits are read-only
-	 */
-	switch (reg) {
-	case WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL:
-	case WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0:
-	case WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_1:
-	case WCD934X_CPE_SS_CPAR_CTL:
-	case WCD934X_CPE_SS_STATUS:
-	case WCD934X_CODEC_RPM_RST_CTL:
-	case WCD934X_SIDO_NEW_VOUT_A_STARTUP:
-	case WCD934X_SIDO_NEW_VOUT_D_STARTUP:
-	case WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL:
-	case WCD934X_ANA_MBHC_MECH:
-	case WCD934X_ANA_MBHC_ELECT:
-	case WCD934X_ANA_MBHC_ZDET:
-	case WCD934X_ANA_MICB2:
-	case WCD934X_CODEC_RPM_CLK_MCLK_CFG:
-	case WCD934X_CLK_SYS_MCLK_PRG:
-	case WCD934X_CHIP_TIER_CTRL_EFUSE_CTL:
-	case WCD934X_ANA_BIAS:
-	case WCD934X_ANA_BUCK_CTL:
-	case WCD934X_ANA_RCO:
-	case WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL:
-	case WCD934X_CODEC_RPM_CLK_GATE:
-	case WCD934X_BIAS_VBG_FINE_ADJ:
-	case WCD934X_CODEC_CPR_SVS_CX_VDD:
-	case WCD934X_CODEC_CPR_SVS2_CX_VDD:
-	case WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL:
-		return true;
-	}
-
-	return false;
-}
-
-struct regmap_config wcd934x_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.cache_type = REGCACHE_RBTREE,
-	.reg_defaults = wcd934x_defaults,
-	.num_reg_defaults = ARRAY_SIZE(wcd934x_defaults),
-	.max_register = WCD934X_MAX_REGISTER,
-	.volatile_reg = wcd934x_is_volatile_register,
-	.readable_reg = wcd934x_is_readable_register,
-	.can_multi_write = true,
-};
diff --git a/drivers/mfd/wcd934x-tables.c b/drivers/mfd/wcd934x-tables.c
deleted file mode 100644
index db963d0..0000000
--- a/drivers/mfd/wcd934x-tables.c
+++ /dev/null
@@ -1,2155 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include <linux/mfd/wcd934x/registers.h>
-
-#define WCD934X_REG(reg)  ((reg) & 0xFF)
-
-const u8 wcd934x_page0_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE0_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_CLK_BYPASS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_CLK_GATE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_CLK_MCLK_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_CLK_MCLK2_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_I2S_DSD_CLK_SEL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_TEST0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_TEST1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT4)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT5)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT7)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT8)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT9)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT10)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT11)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT12)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT13)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO)] =
-								WCD934X_READ,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_SLNQ_WAIT_STATE_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_I2C_ACTIVE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_ALT_FUNC_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_GPIO_CTL_OE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CHIP_TIER_CTRL_GPIO_CTL_DATA)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX0_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX1_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX2_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX3_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX4_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX5_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX6_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_RX7_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX0_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX1_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX2_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX3_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX4_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX5_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX6_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX7_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX8_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX9_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX10_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX11_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX13_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX14_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_SB_TX15_INP_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_TX0_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_TX1_0_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_TX1_1_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_0_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_3_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_CLKSRC_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_COMMON_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_0_TDM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DATA_HUB_I2S_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_DMA_RDMA_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_RDMA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_RDMA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_RDMA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_RDMA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_RDMA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_RDMA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_RDMA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_RDMA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_RDMA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_RDMA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA4_PRT_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_SBTX0_7_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_RDMA_SBTX8_11_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_4_5_CFG_WDMA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_WDMA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_WDMA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_4_5_CFG_WDMA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_WDMA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_WDMA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_4_5_CFG_WDMA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_WDMA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_WDMA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_4_5_CFG_WDMA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_WDMA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_WDMA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_4_5_CFG_WDMA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_2_3_CFG_WDMA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_CH_0_1_CFG_WDMA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA0_PRT_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA3_PRT_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA4_PRT0_3_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DMA_WDMA4_PRT4_7_CFG)] = WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page1_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE1_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_USER_CTL_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_L_VAL_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_L_VAL_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_DSM_FRAC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_DSM_FRAC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_CONFIG_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_CONFIG_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_CONFIG_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_CONFIG_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_CONFIG_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_TEST_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_FREQ_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_FREQ_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_FREQ_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_FREQ_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_SSC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_SSC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_SSC_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_SSC_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_FLL_MODE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_FLL_STATUS_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_FLL_STATUS_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_FLL_STATUS_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_FLL_STATUS_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_USER_CTL_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_L_VAL_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_L_VAL_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_DSM_FRAC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_DSM_FRAC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_CONFIG_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_CONFIG_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_CONFIG_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_CONFIG_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_CONFIG_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_TEST_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_FREQ_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_FREQ_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_FREQ_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_FREQ_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_SSC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_SSC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_SSC_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_SSC_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_FLL_MODE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_I2S_FLL_STATUS_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_I2S_FLL_STATUS_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_I2S_FLL_STATUS_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_I2S_FLL_STATUS_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_USER_CTL_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_L_VAL_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_L_VAL_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_DSM_FRAC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_DSM_FRAC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_CONFIG_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_CONFIG_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_CONFIG_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_CONFIG_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_CONFIG_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_TEST_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_FREQ_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_FREQ_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_FREQ_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_FREQ_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_SSC_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_SSC_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_SSC_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_SSC_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_FLL_MODE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SB_FLL_STATUS_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SB_FLL_STATUS_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SB_FLL_STATUS_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SB_FLL_STATUS_3)] = WCD934X_READ,
-};
-
-const u8 wcd934x_page2_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE2_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_CPE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPEFLL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_OVERRIDE)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_US_BUF_INT_PERIOD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SVA_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_US_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_MAD_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_CPAR_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_DMIC0_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_DMIC1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_DMIC2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_DMIC_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_CPAR_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_WDOG_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_BACKUP_INT)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_STATUS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_CPE_OCD_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_MASK_1A)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_MASK_1B)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1A)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1B)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1A)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1B)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_MAIN_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_MAIN_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_CTL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_ULTR_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_CTL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SOC_MAD_INP_SEL)] = WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page4_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE4_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CLR_COMMIT)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_MASK0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_MASK1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_MASK2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_MASK3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_STATUS0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_PIN1_STATUS1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_PIN1_STATUS2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_PIN1_STATUS3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_PIN1_CLEAR0)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_CLEAR1)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_CLEAR2)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN1_CLEAR3)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN2_MASK3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_PIN2_STATUS3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_PIN2_CLEAR3)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_MASK2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_MASK3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_STATUS2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_STATUS3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_CLEAR2)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CPESS_SUMRY_CLEAR3)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_INTR_LEVEL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_LEVEL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_LEVEL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_LEVEL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_BYPASS0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_BYPASS1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_BYPASS2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_BYPASS3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_SET0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_SET1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_SET2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_SET3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CODEC_MISC_MASK)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_INTR_CODEC_MISC_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_INTR_CODEC_MISC_CLEAR)] = WCD934X_WRITE,
-};
-
-const u8 wcd934x_page5_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE5_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_DEVICE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_REVISION)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_H_COMMAND)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_MASTER_ADDRESS_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_MASTER_ADDRESS_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SLAVE_ADDRESS_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SLAVE_ADDRESS_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_MSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_LSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_MSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_LSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_MSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_LSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_COMM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_FRAME_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH1_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH3_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SW_EVENT_RD)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SW_EVENT_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_SELECT_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_SELECT_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_SELECT_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_SAMPLING_FREQ)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_SEL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_RAM_CNTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BANK)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_A)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_B)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_C)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_E)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_F)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_10)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_11)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_12)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_13)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_14)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_15)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_16)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_17)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_18)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_19)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1A)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1B)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1C)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1E)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_1F)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_20)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_21)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_22)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_23)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_24)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_25)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_26)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_27)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_28)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_29)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2A)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2B)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2C)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2E)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_2F)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_30)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_31)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_32)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_33)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_34)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_35)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_36)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_37)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_38)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_39)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3A)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3B)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3C)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3E)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_SRAM_BYTE_3F)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TOP_CTRL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_TOP_CTRL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_PDM_MUTE_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_DEC_BYPASS_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_DEC_BYPASS_STATUS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_DEC_BYPASS_FS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_DEC_BYPASS_IN_SEL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_GPOUT_ENABLE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_GPOUT_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_ANA_INTERRUPT_MASK)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_ANA_INTERRUPT_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_ANA_INTERRUPT_CLR)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_IP_TESTING)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CNTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CNT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CNT_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CNT_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_MASK0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_MASK1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_MASK2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_MASK3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_MASK4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_STATUS0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_STATUS1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_STATUS2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_STATUS3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_STATUS4)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CLR0)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CLR1)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CLR2)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CLR3)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_DIG_INTERRUPT_CLR4)] = WCD934X_WRITE,
-};
-
-const u8 wcd934x_page6_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_ANA_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_BIAS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_RCO)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_PAGE6_SPARE2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_PAGE6_SPARE3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_BUCK_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_BUCK_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_ANA_RX_SUPPLIES)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_HPH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_EAR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_LO_1_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MAD_SETUP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_AMIC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_AMIC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_AMIC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_AMIC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_MECH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_ELECT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_ZDET)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_RESULT_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_ANA_MBHC_RESULT_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_ANA_MBHC_RESULT_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MBHC_BTN7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MICB1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MICB2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MICB2_RAMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MICB3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_MICB4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_ANA_VBADC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BIAS_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BIAS_VBG_FINE_ADJ)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CTRL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CTRL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CAL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CAL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_TEST_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RCO_CAL_OUT_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_RCO_CAL_OUT_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_RCO_CAL_OUT_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_RCO_CAL_OUT_4)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_RCO_CAL_OUT_5)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDO_MODE_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_MODE_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_MODE_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_MODE_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_VCL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_VCL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_VCL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CCL_10)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_FILTER_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_FILTER_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_DRIVER_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_DRIVER_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_DRIVER_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CAL_CODE_EXT_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CAL_CODE_EXT_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_CAL_CODE_OUT_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDO_CAL_CODE_OUT_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDO_TEST_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_TEST_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_CTL_CLK)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_CTL_ANA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_CTL_SPARE_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_CTL_SPARE_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_CTL_BCS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_STATUS_SPARE_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MBHC_TEST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_SUBBLOCK_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_IBIAS_FE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_BIAS_ADC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_FE_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_ADC_REF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_ADC_IO)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_ADC_SAR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_DEBUG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_LDOH_MODE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_LDOH_BIAS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_LDOH_STB_LOADS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_LDOH_SLOWRAMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB1_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB1_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB1_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB2_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB2_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB2_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB3_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB3_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB3_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB4_TEST_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB4_TEST_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MICB4_TEST_CTL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_ADC_VCM)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_BIAS_ATEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_ADC_INT1_IB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_ADC_INT2_IB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_TXFE_DIV_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_TXFE_DIV_START)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_TXFE_DIV_STOP_9P6M)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_COM_TXFE_DIV_STOP_12P288M)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_TEST_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_ADC_IB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_ATEST_REFCTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_TEST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_TEST_BLK_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_TXFE_CLKDIV)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_1_2_SAR1_ERR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_TX_1_2_SAR2_ERR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_TX_3_4_TEST_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_ADC_IB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_ATEST_REFCTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_TEST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_TEST_BLK_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_TXFE_CLKDIV)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TX_3_4_SAR1_ERR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_TX_3_4_SAR2_ERR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CLASSH_MODE_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_MODE_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_MODE_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_VCL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_VCL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_CCL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_CCL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_CCL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_CCL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_CTRL_CCL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_BUCK_TMUX_A_D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_BUCK_SW_DRV_CNTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLASSH_SPARE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_8)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEG_CTRL_9)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEGDAC_CTRL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEGDAC_CTRL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_VNEGDAC_CTRL_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_CTRL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_FLYBACK_TEST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_AUX_SW_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_PA_AUX_IN_CONN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_TIMER_DIV)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_OCP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_OCP_COUNT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_EAR_DAC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_EAR_AMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_LDO)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_PA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_RDACBUFF_CNP2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_RDAC_LDO)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_CNP1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_HPH_LOWPOWER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_DIFFLO_PA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_DIFFLO_REF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_DIFFLO_LDO)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_SELO_DAC_PA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_BUCK_RST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_BUCK_VREF_ERRAMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_FLYB_ERRAMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_FLYB_BUFF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_BIAS_FLYB_MID_RST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_L_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_HPH_R_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_HPH_CNP_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_CNP_WG_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_CNP_WG_TIME)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_OCP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_AUTO_CHOP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_CHOP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_PA_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_PA_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_L_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_L_TEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_L_ATEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_R_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_R_TEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_R_ATEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_RDAC_CLK_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_RDAC_CLK_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_RDAC_LDO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_RDAC_CHOP_CLK_LP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_REFBUFF_UHQA_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_REFBUFF_LP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_L_DAC_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_R_DAC_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_EN_REG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_CMBUFF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_ICTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_EN_DBG_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_CNP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_DAC_CTL_ATEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EAR_STATUS_REG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EAR_EAR_MISC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_MISC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_LO2_COMPANDER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_LO1_COMPANDER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_COMMON)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_BYPASS_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_CNP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_CORE_OUT_PROG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_LDO_OUT_PROG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_COM_SWCAP_REFBUF_FREQ)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_COM_PA_FREQ)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_RESERVED_REG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_DIFF_LO_LO1_STATUS_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_DIFF_LO_LO1_STATUS_2)] = WCD934X_READ,
-};
-
-const u8 wcd934x_page7_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_ANA_NEW_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_ANA_HPH2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_ANA_HPH3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_EN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_LDO_CONFIG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_LDO_OCP_CONFIG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_TX_LDO_CONFIG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_TX_DRV_CONFIG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_RX_CONFIG_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_RX_CONFIG_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_PLL_ENABLES)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_PLL_PRESET)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_ANA_PLL_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CLK_SYS_PLL_ENABLES)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_PLL_PRESET)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_PLL_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CLK_SYS_MCLK_PRG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_MCLK2_PRG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_MCLK2_PRG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_XO_PRG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_XO_CAP_XTP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_XO_CAP_XTM)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_BST_EN_DLY)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_CTRL_ILIM)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_VOUT_SETTING)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_VOUT_A_STARTUP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_VOUT_D_STARTUP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_VOUT_D_FREQ1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_VOUT_D_FREQ2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_ELECT_REM_CLAMP_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_CTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_CTL_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_PLUG_DETECT_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_ZDET_ANA_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_ZDET_RAMP_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_FSM_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MBHC_NEW_ADC_RESULT)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_TX_NEW_AMIC_4_5_SEL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_NEW_ADC_MODE)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_VBADC_NEW_ADC_DOUTMSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_VBADC_NEW_ADC_DOUTLSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_RDAC_HD2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_RDAC_VREF_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_RDAC_MISC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_PA_MISC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_PA_MISC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_PA_RDAC_MISC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_HPH_TIMER1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_HPH_TIMER2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_HPH_TIMER3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_HPH_TIMER4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_PA_RDAC_MISC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_HPH_NEW_INT_PA_RDAC_MISC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_ULP)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_RX_NEW_INT_HPH_RDAC_LDO_LP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_LDO_TEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_TX_LDO_TEST)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_TX_DRV_TEST)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RX_TEST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RX_TEST_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_CLK_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RESERVED_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_RESERVED_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_L_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_M_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_N_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_PFD_CP_DSM_PROG)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_VCO_PROG)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_LDO_LOCK_CFG)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SLNQ_INT_ANA_INT_PLL_DIG_LOCK_DET_CFG)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_POST_DIV_REG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_POST_DIV_REG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_REF_DIV_REG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_REF_DIV_REG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_FILTER_REG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_FILTER_REG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_PLL_L_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_PLL_M_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_PLL_N_VAL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_TEST_REG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_PFD_CP_DSM_PROG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_VCO_PROG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_TEST_REG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_LDO_LOCK_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_DIG_LOCK_DET_CFG)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_CLK_TEST1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_CLK_TEST2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_CLK_TEST3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_XO_TEST1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CLK_SYS_INT_XO_TEST2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_VCOMP_HYST)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_VLOOP_FILTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_CTRL_IDELTA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_CTRL_ILIM_STARTUP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_CTRL_MIN_ONTIME)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_CTRL_MAX_ONTIME)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_CTRL_TIMING)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_TMUX_A_D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_SW_DRV_CNTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_SPARE1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_BOOST_INT_SPARE2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_SPARE_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_A)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_D)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_INC_WAIT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_IBLEED_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DEBUG_CPROVR_TEST)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_CTL_A)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_CTL_D)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_RAMP_TIMEOUT_PERIOD)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_INT_SLNQ_HPF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_INT_SLNQ_REF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_INT_SLNQ_COMP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MBHC_NEW_INT_SPARE_2)] = WCD934X_READ_WRITE,
-
-};
-
-const u8 wcd934x_page10_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE10_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_CLK_RESET_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_MODE_1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_MODE_2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FF_SHIFT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FB_SHIFT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_LPF_FF_A_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_LPF_FF_B_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_LPF_FB_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_SMLPF_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_DCFLT_SHIFT_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_IIR_ADAPT_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_IIR_COEFF_1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_IIR_COEFF_2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FF_A_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FF_B_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FB_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_RC_COMMON_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_FIFO_COMMON_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC0_RC0_STATUS_FMIN_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC0_RC1_STATUS_FMIN_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC0_RC0_STATUS_FMAX_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC0_RC1_STATUS_FMAX_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC0_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC1_CLK_RESET_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_MODE_1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_MODE_2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FF_SHIFT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FB_SHIFT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_LPF_FF_A_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_LPF_FF_B_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_LPF_FB_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_SMLPF_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_DCFLT_SHIFT_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_IIR_ADAPT_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_IIR_COEFF_1_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_IIR_COEFF_2_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FF_A_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FF_B_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FB_GAIN_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_RC_COMMON_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_FIFO_COMMON_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_ANC1_RC0_STATUS_FMIN_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC1_RC1_STATUS_FMIN_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC1_RC0_STATUS_FMAX_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC1_RC1_STATUS_FMAX_CNTR)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_ANC1_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX0_TX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX1_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX2_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX3_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX4_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX5_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX6_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX7_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_192_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_192_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX8_TX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX9_SPKR_PROT_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX10_SPKR_PROT_PATH_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX11_SPKR_PROT_PATH_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX12_SPKR_PROT_PATH_CFG0)] =
-							WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page11_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE11_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER1_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER2_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER3_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER4_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER7_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL6)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_COMPANDER8_CTL7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_VOL_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_MIX_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_VOL_MIX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC6)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_SEC7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_MIX_SEC0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_MIX_SEC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL)] = WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page12_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE12_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_CRC)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_DLY_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_DECAY_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_HPH_V_PA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_EAR_V_PA)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_HPH_V_HD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_EAR_V_HD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_K1_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_K1_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_K2_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_K2_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_IDLE_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_IDLE_HPH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_IDLE_EAR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_TEST0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_TEST1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLSH_OVR_VREF)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST0_BOOST_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST0_BOOST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST0_BOOST_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST0_BOOST_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST1_BOOST_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST1_BOOST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST1_BOOST_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_BOOST1_BOOST_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_ADC_CAL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_ADC_CAL2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_ADC_CAL3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_PK_EST1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_PK_EST2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_PK_EST3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_RF_PROC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_RF_PROC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_TAC1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_TAC2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_TAC3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_TAC4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_UPD1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_UPD2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_UPD3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_UPD4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_DEBUG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_UPD_MON)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_GAIN_MON_VAL)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_VBAT_VBAT_BAN)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC0_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC1_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC2_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_MIXING_ASRC3_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_DATA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_DATA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_DATA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_DATA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_WR_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_DATA_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_DATA_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_DATA_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_RD_DATA_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_ACCESS_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SWR_AHB_BRIDGE_ACCESS_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_LSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_MSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_LSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_MSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC0_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_LSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_MSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_LSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_MSB)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_SIDETONE_ASRC1_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_REF_HQ0_EC_REF_HQ_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_REF_HQ0_EC_REF_HQ_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_REF_HQ1_EC_REF_HQ_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_REF_HQ1_EC_REF_HQ_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC0_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC0_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC0_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC0_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC0_STATUS_FIFO)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC1_CLK_RST_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC1_CTL0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC1_CTL1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC1_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_EC_ASRC1_STATUS_FIFO)] = WCD934X_READ,
-};
-
-const u8 wcd934x_page13_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE13_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_ANC_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_INP_MUX_EC_REF_HQ_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX10_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX11_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX12_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TX_INP_MUX_ADC_MUX13_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_ASRC_SHARE_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_CLK_RST_CTRL_GFM_CONTROL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_TEST_CTRL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD)] =
-							WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_PATH_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_TOP_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_TOP_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_TOP_CFG7)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHL_COMP_WR_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHL_COMP_WR_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHL_COMP_LUT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHL_COMP_RD_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHL_COMP_RD_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHR_COMP_WR_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHR_COMP_WR_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHR_COMP_LUT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHR_COMP_RD_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_HPHR_COMP_RD_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFL_COMP_WR_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFL_COMP_WR_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFL_COMP_LUT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFL_COMP_RD_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFL_COMP_RD_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFR_COMP_WR_LSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFR_COMP_WR_MSB)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFR_COMP_LUT)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFR_COMP_RD_LSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_TOP_DIFFR_COMP_RD_MSB)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_DSD0_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD0_CFG5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DSD1_CFG5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_IDLE_DET_PATH_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_IDLE_DET_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_IDLE_DET_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_IDLE_DET_CFG2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RX_IDLE_DET_CFG3)] = WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page14_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE14_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_CLK_RST_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_PULSE_SUPR_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_TIMER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_BW_SW)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_THRESH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_TIMER2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RMAX_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RMIN_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_PH_DET)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_DIAG_CLR)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_MB_SW_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_MAST_DIAG_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_7_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_15_8)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_23_16)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_31_24)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_39_32)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST0_RE_RATE_OUT_40_43)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_CLK_RST_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_PULSE_SUPR_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_TIMER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_BW_SW)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_THRESH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_TIMER2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RMAX_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RMIN_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_PH_DET)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_DIAG_CLR)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_MB_SW_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_MAST_DIAG_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_7_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_15_8)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_23_16)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_31_24)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_39_32)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST1_RE_RATE_OUT_40_43)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_CLK_RST_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_PULSE_SUPR_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_TIMER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_BW_SW)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_THRESH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_TIMER2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RMAX_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RMIN_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_PH_DET)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_DIAG_CLR)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_MB_SW_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_MAST_DIAG_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_7_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_15_8)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_23_16)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_31_24)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_39_32)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST2_RE_RATE_OUT_40_43)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_CLK_RST_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_PULSE_SUPR_CTL)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_TIMER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_BW_SW)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_THRESH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_TIMER2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW5)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RMAX_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RMIN_DIAG)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_PH_DET)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_DIAG_CLR)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_MB_SW_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_MAST_DIAG_STATE)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_7_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_15_8)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_23_16)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_31_24)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_39_32)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_RATE_EST3_RE_RATE_OUT_40_43)] = WCD934X_READ,
-};
-
-const u8 wcd934x_page15_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE15_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SPLINE_SRC0_CLK_RST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SPLINE_SRC0_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SPLINE_SRC1_CLK_RST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SPLINE_SRC1_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SPLINE_SRC2_CLK_RST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SPLINE_SRC2_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_SPLINE_SRC3_CLK_RST_CTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_SPLINE_SRC3_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_RC_RE_ASRC_DEBUG_CFG0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_ANC0_RC0_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_ANC0_RC1_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_ANC1_RC0_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_ANC1_RC1_FIFO_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CDC_DEBUG_ANC_RC_RST_DBG_CNTR)] =
-							WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page_0x50_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE80_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_ACCESS_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_ACCESS_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_NOM_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_NOM_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_MAX_SVS2_STEP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SW_MODECHNG_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SW_MODECHNG_START)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_CPR_STATUS)] = WCD934X_READ_WRITE,
-};
-
-const u8 wcd934x_page_0x80_reg_access[WCD934X_PAGE_SIZE] = {
-	[WCD934X_REG(WCD934X_PAGE80_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_DATA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_WR_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_ADDR_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_0)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_1)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_2)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_RD_DATA_3)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_ACCESS_CFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_ACCESS_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_NOM_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_NOM_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_MX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_MAX_SVS2_STEP)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_CTL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SW_MODECHNG_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_CODEC_CPR_SW_MODECHNG_START)] = WCD934X_WRITE,
-	[WCD934X_REG(WCD934X_CODEC_CPR_CPR_STATUS)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_PAGE128_PAGE_REGISTER)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_BIST_MODE_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_RF_PA_ON_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_INTR1_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_INTR2_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SWR_DATA_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SWR_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_2_SCK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SLIMBUS_DATA1_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SLIMBUS_DATA2_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SLIMBUS_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2C_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2C_DATA_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_0_RX_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_0_TX_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_0_SCK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_0_WS_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_1_RX_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_1_TX_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_1_SCK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_1_WS_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC1_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC1_DATA_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC2_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC2_DATA_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC3_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_DMIC3_DATA_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_JTCK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_GPIO1_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_GPIO2_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_GPIO3_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_GPIO4_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SPI_S_CSN_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SPI_S_CLK_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SPI_S_DOUT_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_SPI_S_DIN_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_BA_N_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_GPIO0_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_2_RX_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TLMM_I2S_2_WS_PINCFG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_OE_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_OE_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_OE_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_OE_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_OE_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_DATA_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_DATA_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_DATA_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_DATA_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_CTL_DATA_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_DRVCTL_0)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_DRVCTL_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PIN_STATUS)] = WCD934X_READ,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_NPL_DLY_TEST_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_NPL_DLY_TEST_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_MEM_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_BUS_SEL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_JTAG)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_EN_1)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_EN_2)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_EN_3)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_EN_4)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_DEBUG_EN_5)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_ANA_DTEST_DIR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_INP_DISABLE_0)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_INP_DISABLE_1)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_INP_DISABLE_2)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_INP_DISABLE_3)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_PAD_INP_DISABLE_4)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_SYSMEM_CTRL)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_SOC_SW_PWR_SEQ_DELAY)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_LVAL_NOM_LOW)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_LVAL_NOM_HIGH)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH)] =
-							WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_SPI_SLAVE_CHAR)] = WCD934X_READ_WRITE,
-	[WCD934X_REG(WCD934X_TEST_DEBUG_CODEC_DIAGS)] = WCD934X_READ,
-};
-
-const u8 * const wcd934x_reg[WCD934X_NUM_PAGES] = {
-	[WCD934X_PAGE_0] = wcd934x_page0_reg_access,
-	[WCD934X_PAGE_1] = wcd934x_page1_reg_access,
-	[WCD934X_PAGE_2] = wcd934x_page2_reg_access,
-	[WCD934X_PAGE_4] = wcd934x_page4_reg_access,
-	[WCD934X_PAGE_5] = wcd934x_page5_reg_access,
-	[WCD934X_PAGE_6] = wcd934x_page6_reg_access,
-	[WCD934X_PAGE_7] = wcd934x_page7_reg_access,
-	[WCD934X_PAGE_10] = wcd934x_page10_reg_access,
-	[WCD934X_PAGE_11] = wcd934x_page11_reg_access,
-	[WCD934X_PAGE_12] = wcd934x_page12_reg_access,
-	[WCD934X_PAGE_13] = wcd934x_page13_reg_access,
-	[WCD934X_PAGE_14] = wcd934x_page14_reg_access,
-	[WCD934X_PAGE_15] = wcd934x_page15_reg_access,
-	[WCD934X_PAGE_0x50] = wcd934x_page_0x50_reg_access,
-	[WCD934X_PAGE_0X80] = wcd934x_page_0x80_reg_access,
-};
diff --git a/drivers/mfd/wcd9xxx-core-init.c b/drivers/mfd/wcd9xxx-core-init.c
deleted file mode 100644
index 7f93399..0000000
--- a/drivers/mfd/wcd9xxx-core-init.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd9xxx/core.h>
-
-#define NUM_DRIVERS_REG_RET 3
-
-static int __init wcd9xxx_core_init(void)
-{
-	int ret[NUM_DRIVERS_REG_RET] = {0};
-	int i = 0;
-
-	ret[0] = msm_cdc_pinctrl_drv_init();
-	if (ret[0])
-		pr_err("%s: Failed init pinctrl drv: %d\n", __func__, ret[0]);
-
-	ret[1] = wcd9xxx_irq_drv_init();
-	if (ret[1])
-		pr_err("%s: Failed init irq drv: %d\n", __func__, ret[1]);
-
-	ret[2] = wcd9xxx_init();
-	if (ret[2])
-		pr_err("%s: Failed wcd core drv: %d\n", __func__, ret[2]);
-
-	for (i = 0; i < NUM_DRIVERS_REG_RET; i++) {
-		if (ret[i])
-			return ret[i];
-	}
-
-	return 0;
-}
-module_init(wcd9xxx_core_init);
-
-static void __exit wcd9xxx_core_exit(void)
-{
-	wcd9xxx_exit();
-	wcd9xxx_irq_drv_exit();
-	msm_cdc_pinctrl_drv_exit();
-}
-module_exit(wcd9xxx_core_exit);
-
-MODULE_DESCRIPTION("WCD9XXX CODEC core init driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/wcd9xxx-core.c b/drivers/mfd/wcd9xxx-core.c
deleted file mode 100644
index 176d3dc..0000000
--- a/drivers/mfd/wcd9xxx-core.c
+++ /dev/null
@@ -1,1736 +0,0 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/of_device.h>
-#include <linux/slab.h>
-#include <linux/ratelimit.h>
-#include <linux/mfd/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-utils.h>
-#include <linux/mfd/msm-cdc-supply.h>
-#include <linux/delay.h>
-#include <linux/gpio.h>
-#include <linux/debugfs.h>
-#include <linux/i2c.h>
-#include <linux/regmap.h>
-#include <sound/soc.h>
-#include "wcd9xxx-regmap.h"
-
-#define WCD9XXX_REGISTER_START_OFFSET 0x800
-#define WCD9XXX_SLIM_RW_MAX_TRIES 3
-#define SLIMBUS_PRESENT_TIMEOUT 100
-
-#define MAX_WCD9XXX_DEVICE	4
-#define WCD9XXX_I2C_GSBI_SLAVE_ID "3-000d"
-#define WCD9XXX_I2C_TOP_SLAVE_ADDR	0x0d
-#define WCD9XXX_ANALOG_I2C_SLAVE_ADDR	0x77
-#define WCD9XXX_DIGITAL1_I2C_SLAVE_ADDR	0x66
-#define WCD9XXX_DIGITAL2_I2C_SLAVE_ADDR	0x55
-#define WCD9XXX_I2C_TOP_LEVEL	0
-#define WCD9XXX_I2C_ANALOG	1
-#define WCD9XXX_I2C_DIGITAL_1	2
-#define WCD9XXX_I2C_DIGITAL_2	3
-
-/*
- * Number of return values needs to be checked for each
- * registration of Slimbus of I2C bus for each codec
- */
-#define NUM_WCD9XXX_REG_RET	4
-
-#define SLIM_USR_MC_REPEAT_CHANGE_VALUE 0x0
-#define SLIM_REPEAT_WRITE_MAX_SLICE 16
-#define REG_BYTES 2
-#define VAL_BYTES 1
-#define WCD9XXX_PAGE_NUM(reg)    (((reg) >> 8) & 0xff)
-#define WCD9XXX_PAGE_SIZE 256
-
-struct wcd9xxx_i2c {
-	struct i2c_client *client;
-	struct i2c_msg xfer_msg[2];
-	struct mutex xfer_lock;
-	int mod_id;
-};
-
-static struct regmap_config wcd9xxx_base_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.can_multi_write = true,
-};
-
-static struct regmap_config wcd9xxx_i2c_base_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.can_multi_write = false,
-	.use_single_rw = true,
-};
-
-static u8 wcd9xxx_pgd_la;
-static u8 wcd9xxx_inf_la;
-
-static const int wcd9xxx_cdc_types[] = {
-	[WCD9XXX] = WCD9XXX,
-	[WCD9330] = WCD9330,
-	[WCD9335] = WCD9335,
-	[WCD934X] = WCD934X,
-};
-
-static const struct of_device_id wcd9xxx_of_match[] = {
-	{ .compatible = "qcom,tasha-i2c-pgd",
-	  .data = (void *)&wcd9xxx_cdc_types[WCD9335]},
-	{ .compatible = "qcom,wcd9xxx-i2c",
-	  .data = (void *)&wcd9xxx_cdc_types[WCD9330]},
-	{ }
-};
-MODULE_DEVICE_TABLE(of, wcd9xxx_of_match);
-
-static int wcd9xxx_slim_device_up(struct slim_device *sldev);
-static int wcd9xxx_slim_device_down(struct slim_device *sldev);
-
-struct wcd9xxx_i2c wcd9xxx_modules[MAX_WCD9XXX_DEVICE];
-
-static int wcd9xxx_slim_multi_reg_write(struct wcd9xxx *wcd9xxx,
-					const void *data, size_t count)
-{
-	unsigned int reg;
-	struct device *dev;
-	u8 val[WCD9XXX_PAGE_SIZE];
-	int ret = 0;
-	int i = 0;
-	int n = 0;
-	unsigned int page_num;
-	size_t num_regs = (count / (REG_BYTES + VAL_BYTES));
-	struct wcd9xxx_reg_val *bulk_reg;
-	u8 *buf;
-
-	dev = wcd9xxx->dev;
-	if (!data) {
-		dev_err(dev, "%s: data is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (num_regs == 0)
-		return -EINVAL;
-
-	bulk_reg = kzalloc(num_regs * (sizeof(struct wcd9xxx_reg_val)),
-			   GFP_KERNEL);
-	if (!bulk_reg)
-		return -ENOMEM;
-
-	buf = (u8 *)data;
-	reg = *(u16 *)buf;
-	page_num = WCD9XXX_PAGE_NUM(reg);
-	for (i = 0, n = 0; n < num_regs; i++, n++) {
-		reg = *(u16 *)buf;
-		if (page_num != WCD9XXX_PAGE_NUM(reg)) {
-			ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
-						      i, false);
-			page_num = WCD9XXX_PAGE_NUM(reg);
-			i = 0;
-		}
-		buf += REG_BYTES;
-		val[i] = *buf;
-		buf += VAL_BYTES;
-		bulk_reg[i].reg = reg;
-		bulk_reg[i].buf = &val[i];
-		bulk_reg[i].bytes = 1;
-	}
-	ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
-				      i, false);
-	if (ret)
-		dev_err(dev, "%s: error writing bulk regs\n",
-			__func__);
-
-	kfree(bulk_reg);
-	return ret;
-}
-
-/*
- * wcd9xxx_interface_reg_read: Read slim interface registers
- *
- * @wcd9xxx: Pointer to wcd9xxx structure
- * @reg: register adderss
- *
- * Returns register value in success and negative error code in case of failure
- */
-int wcd9xxx_interface_reg_read(struct wcd9xxx *wcd9xxx, unsigned short reg)
-{
-	u8 val;
-	int ret;
-
-	mutex_lock(&wcd9xxx->io_lock);
-	ret = wcd9xxx->read_dev(wcd9xxx, reg, 1, (void *)&val,
-				true);
-	if (ret < 0)
-		dev_err(wcd9xxx->dev, "%s: Codec read 0x%x failed\n",
-			__func__, reg);
-	else
-		dev_dbg(wcd9xxx->dev, "%s: Read 0x%02x from 0x%x\n",
-			__func__, val, reg);
-
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	if (ret < 0)
-		return ret;
-	else
-		return val;
-}
-EXPORT_SYMBOL(wcd9xxx_interface_reg_read);
-
-/*
- * wcd9xxx_interface_reg_write: Write slim interface registers
- *
- * @wcd9xxx: Pointer to wcd9xxx structure
- * @reg: register adderss
- * @val: value of the register to be written
- *
- * Returns 0 for success and negative error code in case of failure
- */
-int wcd9xxx_interface_reg_write(struct wcd9xxx *wcd9xxx, unsigned short reg,
-		     u8 val)
-{
-	int ret;
-
-	mutex_lock(&wcd9xxx->io_lock);
-	ret = wcd9xxx->write_dev(wcd9xxx, reg, 1, (void *)&val, true);
-	dev_dbg(wcd9xxx->dev, "%s: Write %02x to 0x%x ret(%d)\n",
-		__func__, val, reg, ret);
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_interface_reg_write);
-
-static int wcd9xxx_slim_read_device(struct wcd9xxx *wcd9xxx, unsigned short reg,
-				int bytes, void *dest, bool interface)
-{
-	int ret;
-	struct slim_ele_access msg;
-	int slim_read_tries = WCD9XXX_SLIM_RW_MAX_TRIES;
-
-	msg.start_offset = WCD9XXX_REGISTER_START_OFFSET + reg;
-	msg.num_bytes = bytes;
-	msg.comp = NULL;
-
-	if (!wcd9xxx->dev_up) {
-		dev_dbg_ratelimited(
-			wcd9xxx->dev, "%s: No read allowed. dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-		return 0;
-	}
-
-	while (1) {
-		mutex_lock(&wcd9xxx->xfer_lock);
-		ret = slim_request_val_element(interface ?
-			       wcd9xxx->slim_slave : wcd9xxx->slim,
-			       &msg, dest, bytes);
-		mutex_unlock(&wcd9xxx->xfer_lock);
-		if (likely(ret == 0) || (--slim_read_tries == 0))
-			break;
-		usleep_range(5000, 5100);
-	}
-
-	if (ret)
-		dev_err(wcd9xxx->dev, "%s: Error, Codec read failed (%d)\n",
-			__func__, ret);
-
-	return ret;
-}
-
-/*
- * Interface specifies whether the write is to the interface or general
- * registers.
- */
-static int wcd9xxx_slim_write_device(struct wcd9xxx *wcd9xxx,
-		unsigned short reg, int bytes, void *src, bool interface)
-{
-	int ret;
-	struct slim_ele_access msg;
-	int slim_write_tries = WCD9XXX_SLIM_RW_MAX_TRIES;
-
-	msg.start_offset = WCD9XXX_REGISTER_START_OFFSET + reg;
-	msg.num_bytes = bytes;
-	msg.comp = NULL;
-
-	if (!wcd9xxx->dev_up) {
-		dev_dbg_ratelimited(
-			wcd9xxx->dev, "%s: No write allowed. dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-		return 0;
-	}
-
-	while (1) {
-		mutex_lock(&wcd9xxx->xfer_lock);
-		ret = slim_change_val_element(interface ?
-			      wcd9xxx->slim_slave : wcd9xxx->slim,
-			      &msg, src, bytes);
-		mutex_unlock(&wcd9xxx->xfer_lock);
-		if (likely(ret == 0) || (--slim_write_tries == 0))
-			break;
-		usleep_range(5000, 5100);
-	}
-
-	if (ret)
-		pr_err("%s: Error, Codec write failed (%d)\n", __func__, ret);
-
-	return ret;
-}
-
-static int wcd9xxx_slim_get_allowed_slice(struct wcd9xxx *wcd9xxx,
-					  int bytes)
-{
-	int allowed_sz = bytes;
-
-	if (likely(bytes == SLIM_REPEAT_WRITE_MAX_SLICE))
-		allowed_sz = 16;
-	else if (bytes >= 12)
-		allowed_sz = 12;
-	else if (bytes >= 8)
-		allowed_sz = 8;
-	else if (bytes >= 6)
-		allowed_sz = 6;
-	else if (bytes >= 4)
-		allowed_sz = 4;
-	else
-		allowed_sz = bytes;
-
-	return allowed_sz;
-}
-
-/*
- * wcd9xxx_slim_write_repeat: Write the same register with multiple values
- * @wcd9xxx: handle to wcd core
- * @reg: register to be written
- * @bytes: number of bytes to be written to reg
- * @src: buffer with data content to be written to reg
- * This API will write reg with bytes from src in a single slimbus
- * transaction. All values from 1 to 16 are supported by this API.
- */
-int wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			      int bytes, void *src)
-{
-	int ret = 0, bytes_to_write = bytes, bytes_allowed;
-	struct slim_ele_access slim_msg;
-
-	mutex_lock(&wcd9xxx->io_lock);
-	if (wcd9xxx->type == WCD9335 || wcd9xxx->type == WCD934X) {
-		ret = wcd9xxx_page_write(wcd9xxx, &reg);
-		if (ret)
-			goto done;
-	}
-
-	slim_msg.start_offset = WCD9XXX_REGISTER_START_OFFSET + reg;
-	slim_msg.comp = NULL;
-
-	if (unlikely(bytes > SLIM_REPEAT_WRITE_MAX_SLICE)) {
-		dev_err(wcd9xxx->dev, "%s: size %d not supported\n",
-			__func__, bytes);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!wcd9xxx->dev_up) {
-		dev_dbg_ratelimited(
-			wcd9xxx->dev, "%s: No write allowed. dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-		ret = 0;
-		goto done;
-	}
-
-	while (bytes_to_write > 0) {
-		bytes_allowed = wcd9xxx_slim_get_allowed_slice(wcd9xxx,
-				       bytes_to_write);
-
-		slim_msg.num_bytes = bytes_allowed;
-		mutex_lock(&wcd9xxx->xfer_lock);
-		ret = slim_user_msg(wcd9xxx->slim, wcd9xxx->slim->laddr,
-				    SLIM_MSG_MT_DEST_REFERRED_USER,
-				    SLIM_USR_MC_REPEAT_CHANGE_VALUE,
-				    &slim_msg, src, bytes_allowed);
-		mutex_unlock(&wcd9xxx->xfer_lock);
-
-		if (ret) {
-			dev_err(wcd9xxx->dev, "%s: failed, ret = %d\n",
-				__func__, ret);
-			break;
-		}
-
-		bytes_to_write = bytes_to_write - bytes_allowed;
-		src = ((u8 *)src) + bytes_allowed;
-	}
-
-done:
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_slim_write_repeat);
-
-/*
- * wcd9xxx_slim_reserve_bw: API to reserve the slimbus bandwidth
- * @wcd9xxx: Handle to the wcd9xxx core
- * @bw_ops: value of the bandwidth that is requested
- * @commit: Flag to indicate if bandwidth change is to be committed
- *	    right away
- */
-int wcd9xxx_slim_reserve_bw(struct wcd9xxx *wcd9xxx,
-		u32 bw_ops, bool commit)
-{
-	if (!wcd9xxx || !wcd9xxx->slim) {
-		pr_err("%s: Invalid handle to %s\n",
-			__func__,
-			(!wcd9xxx) ? "wcd9xxx" : "slim_device");
-		return -EINVAL;
-	}
-
-	return slim_reservemsg_bw(wcd9xxx->slim, bw_ops, commit);
-}
-EXPORT_SYMBOL(wcd9xxx_slim_reserve_bw);
-
-/*
- * wcd9xxx_slim_bulk_write: API to write multiple registers with one descriptor
- * @wcd9xxx: Handle to the wcd9xxx core
- * @wcd9xxx_reg_val: structure holding register and values to be written
- * @size: Indicates number of messages to be written with one descriptor
- * @is_interface: Indicates whether the register is for slim interface or for
- *	       general registers.
- * @return: returns 0 if success or error information to the caller in case
- *	    of failure.
- */
-int wcd9xxx_slim_bulk_write(struct wcd9xxx *wcd9xxx,
-			    struct wcd9xxx_reg_val *bulk_reg,
-			    unsigned int size, bool is_interface)
-{
-	int ret, i;
-	struct slim_val_inf *msgs;
-	unsigned short reg;
-
-	if (!bulk_reg || !size || !wcd9xxx) {
-		pr_err("%s: Invalid parameters\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!wcd9xxx->dev_up) {
-		dev_dbg_ratelimited(
-			wcd9xxx->dev, "%s: No write allowed. dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-		return 0;
-	}
-
-	msgs = kzalloc(size * (sizeof(struct slim_val_inf)), GFP_KERNEL);
-	if (!msgs) {
-		ret = -ENOMEM;
-		goto mem_fail;
-	}
-
-	mutex_lock(&wcd9xxx->io_lock);
-	reg = bulk_reg->reg;
-	for (i = 0; i < size; i++) {
-		msgs[i].start_offset = WCD9XXX_REGISTER_START_OFFSET +
-					(bulk_reg->reg & 0xFF);
-		msgs[i].num_bytes = bulk_reg->bytes;
-		msgs[i].wbuf = bulk_reg->buf;
-		bulk_reg++;
-	}
-	ret = wcd9xxx_page_write(wcd9xxx, &reg);
-	if (ret) {
-		pr_err("%s: Page write error for reg: 0x%x\n",
-			__func__, reg);
-		goto err;
-	}
-
-	ret = slim_bulk_msg_write(is_interface ?
-				  wcd9xxx->slim_slave : wcd9xxx->slim,
-				  SLIM_MSG_MT_CORE,
-				  SLIM_MSG_MC_CHANGE_VALUE, msgs, size,
-				  NULL, NULL);
-	if (ret)
-		pr_err("%s: Error, Codec bulk write failed (%d)\n",
-			__func__, ret);
-	/* 100 usec sleep is needed as per HW requirement */
-	usleep_range(100, 110);
-err:
-	mutex_unlock(&wcd9xxx->io_lock);
-	kfree(msgs);
-mem_fail:
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_slim_bulk_write);
-
-static int wcd9xxx_num_irq_regs(const struct wcd9xxx *wcd9xxx)
-{
-	return (wcd9xxx->codec_type->num_irqs / 8) +
-		((wcd9xxx->codec_type->num_irqs % 8) ? 1 : 0);
-}
-
-static int wcd9xxx_regmap_init_cache(struct wcd9xxx *wcd9xxx)
-{
-	struct regmap_config *regmap_config;
-	int rc;
-
-	regmap_config = wcd9xxx_get_regmap_config(wcd9xxx->type);
-	if (!regmap_config) {
-		dev_err(wcd9xxx->dev, "regmap config is not defined\n");
-		return -EINVAL;
-	}
-
-	rc = regmap_reinit_cache(wcd9xxx->regmap, regmap_config);
-	if (rc != 0) {
-		dev_err(wcd9xxx->dev, "%s:Failed to reinit register cache: %d\n",
-			__func__, rc);
-	}
-
-	return rc;
-}
-
-static int wcd9xxx_device_init(struct wcd9xxx *wcd9xxx)
-{
-	int ret = 0, i;
-	struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
-	regmap_patch_fptr regmap_apply_patch = NULL;
-
-	mutex_init(&wcd9xxx->io_lock);
-	mutex_init(&wcd9xxx->xfer_lock);
-	mutex_init(&wcd9xxx->reset_lock);
-
-	ret = wcd9xxx_bringup(wcd9xxx->dev);
-	if (ret) {
-		ret = -EPROBE_DEFER;
-		goto err_bring_up;
-	}
-
-	wcd9xxx->codec_type = devm_kzalloc(wcd9xxx->dev,
-			sizeof(struct wcd9xxx_codec_type), GFP_KERNEL);
-	if (!wcd9xxx->codec_type) {
-		ret = -ENOMEM;
-		goto err_bring_up;
-	}
-	ret = wcd9xxx_get_codec_info(wcd9xxx->dev);
-	if (ret) {
-		ret = -EPROBE_DEFER;
-		goto fail_cdc_fill;
-	}
-	wcd9xxx->version = wcd9xxx->codec_type->version;
-	if (!wcd9xxx->codec_type->dev || !wcd9xxx->codec_type->size)
-		goto fail_cdc_fill;
-
-	core_res->parent = wcd9xxx;
-	core_res->dev = wcd9xxx->dev;
-	core_res->intr_table = wcd9xxx->codec_type->intr_tbl;
-	core_res->intr_table_size = wcd9xxx->codec_type->intr_tbl_size;
-
-	for (i = 0; i < WCD9XXX_INTR_REG_MAX; i++)
-		wcd9xxx->core_res.intr_reg[i] =
-			wcd9xxx->codec_type->intr_reg[i];
-
-	wcd9xxx_core_res_init(&wcd9xxx->core_res,
-			      wcd9xxx->codec_type->num_irqs,
-			      wcd9xxx_num_irq_regs(wcd9xxx),
-			      wcd9xxx->regmap);
-
-	if (wcd9xxx_core_irq_init(&wcd9xxx->core_res))
-		goto err;
-
-	ret = wcd9xxx_regmap_init_cache(wcd9xxx);
-	if (ret)
-		goto err_irq;
-
-	regmap_apply_patch = wcd9xxx_get_regmap_reg_patch(
-			wcd9xxx->type);
-	if (regmap_apply_patch) {
-		ret = regmap_apply_patch(wcd9xxx->regmap,
-				wcd9xxx->version);
-		if (ret)
-			dev_err(wcd9xxx->dev,
-					"Failed to register patch: %d\n", ret);
-	}
-
-	ret = mfd_add_devices(wcd9xxx->dev, -1, wcd9xxx->codec_type->dev,
-			      wcd9xxx->codec_type->size, NULL, 0, NULL);
-	if (ret != 0) {
-		dev_err(wcd9xxx->dev, "Failed to add children: %d\n", ret);
-		goto err_irq;
-	}
-
-	ret = device_init_wakeup(wcd9xxx->dev, true);
-	if (ret) {
-		dev_err(wcd9xxx->dev, "Device wakeup init failed: %d\n", ret);
-		goto err_irq;
-	}
-
-	return ret;
-err_irq:
-	wcd9xxx_irq_exit(&wcd9xxx->core_res);
-fail_cdc_fill:
-	devm_kfree(wcd9xxx->dev, wcd9xxx->codec_type);
-	wcd9xxx->codec_type = NULL;
-err:
-	wcd9xxx_bringdown(wcd9xxx->dev);
-	wcd9xxx_core_res_deinit(&wcd9xxx->core_res);
-err_bring_up:
-	mutex_destroy(&wcd9xxx->io_lock);
-	mutex_destroy(&wcd9xxx->xfer_lock);
-	mutex_destroy(&wcd9xxx->reset_lock);
-	return ret;
-}
-
-static void wcd9xxx_device_exit(struct wcd9xxx *wcd9xxx)
-{
-	device_init_wakeup(wcd9xxx->dev, false);
-	wcd9xxx_irq_exit(&wcd9xxx->core_res);
-	mfd_remove_devices(wcd9xxx->dev);
-	wcd9xxx_bringdown(wcd9xxx->dev);
-	wcd9xxx_reset_low(wcd9xxx->dev);
-	wcd9xxx_core_res_deinit(&wcd9xxx->core_res);
-	mutex_destroy(&wcd9xxx->io_lock);
-	mutex_destroy(&wcd9xxx->xfer_lock);
-	mutex_destroy(&wcd9xxx->reset_lock);
-	if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-		slim_remove_device(wcd9xxx->slim_slave);
-}
-
-
-#ifdef CONFIG_DEBUG_FS
-struct wcd9xxx *debugCodec;
-
-static struct dentry *debugfs_wcd9xxx_dent;
-static struct dentry *debugfs_peek;
-static struct dentry *debugfs_poke;
-static struct dentry *debugfs_power_state;
-static struct dentry *debugfs_reg_dump;
-
-static unsigned char read_data;
-
-static int codec_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static int get_parameters(char *buf, long int *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token != NULL) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (kstrtoul(token, base, &param1[cnt]) != 0)
-				return -EINVAL;
-
-			token = strsep(&buf, " ");
-		} else
-			return -EINVAL;
-	}
-	return 0;
-}
-
-static ssize_t wcd9xxx_slimslave_reg_show(char __user *ubuf, size_t count,
-					  loff_t *ppos)
-{
-	int i, reg_val, len;
-	ssize_t total = 0;
-	char tmp_buf[25]; /* each line is 12 bytes but 25 for margin of error */
-
-	for (i = (int) *ppos / 12; i <= SLIM_MAX_REG_ADDR; i++) {
-		reg_val = wcd9xxx_interface_reg_read(debugCodec, i);
-		len = snprintf(tmp_buf, sizeof(tmp_buf),
-			"0x%.3x: 0x%.2x\n", i, reg_val);
-
-		if ((total + len) >= count - 1)
-			break;
-		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
-			total = -EFAULT;
-			goto copy_err;
-		}
-		*ppos += len;
-		total += len;
-	}
-
-copy_err:
-	return total;
-}
-
-static ssize_t codec_debug_read(struct file *file, char __user *ubuf,
-				size_t count, loff_t *ppos)
-{
-	char lbuf[8];
-	char *access_str = file->private_data;
-	ssize_t ret_cnt;
-
-	if (*ppos < 0 || !count)
-		return -EINVAL;
-
-	if (!strcmp(access_str, "slimslave_peek")) {
-		snprintf(lbuf, sizeof(lbuf), "0x%x\n", read_data);
-		ret_cnt = simple_read_from_buffer(ubuf, count, ppos, lbuf,
-					       strnlen(lbuf, 7));
-	} else if (!strcmp(access_str, "slimslave_reg_dump")) {
-		ret_cnt = wcd9xxx_slimslave_reg_show(ubuf, count, ppos);
-	} else {
-		pr_err("%s: %s not permitted to read\n", __func__, access_str);
-		ret_cnt = -EPERM;
-	}
-
-	return ret_cnt;
-}
-
-static void wcd9xxx_set_reset_pin_state(struct wcd9xxx *wcd9xxx,
-					struct wcd9xxx_pdata *pdata,
-					bool active)
-{
-	if (wcd9xxx->wcd_rst_np) {
-		if (active)
-			msm_cdc_pinctrl_select_active_state(
-						wcd9xxx->wcd_rst_np);
-		else
-			msm_cdc_pinctrl_select_sleep_state(
-						wcd9xxx->wcd_rst_np);
-
-		return;
-	} else if (gpio_is_valid(wcd9xxx->reset_gpio)) {
-		gpio_direction_output(wcd9xxx->reset_gpio,
-				      (active == true ? 1 : 0));
-	}
-}
-
-static int codec_debug_process_cdc_power(char *lbuf)
-{
-	long int param;
-	int rc;
-	struct wcd9xxx_pdata *pdata;
-
-	if (wcd9xxx_get_intf_type() != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		pr_err("%s: CODEC is not in SLIMBUS mode\n", __func__);
-		rc = -EPERM;
-		goto error_intf;
-	}
-
-	rc = get_parameters(lbuf, &param, 1);
-
-	if (likely(!rc)) {
-		pdata = debugCodec->slim->dev.platform_data;
-		if (param == 0) {
-			wcd9xxx_slim_device_down(debugCodec->slim);
-			msm_cdc_disable_static_supplies(debugCodec->dev,
-							debugCodec->supplies,
-							pdata->regulator,
-							pdata->num_supplies);
-			wcd9xxx_set_reset_pin_state(debugCodec, pdata, false);
-		} else if (param == 1) {
-			msm_cdc_enable_static_supplies(debugCodec->dev,
-						       debugCodec->supplies,
-						       pdata->regulator,
-						       pdata->num_supplies);
-			usleep_range(1000, 2000);
-			wcd9xxx_set_reset_pin_state(debugCodec, pdata, false);
-			usleep_range(1000, 2000);
-			wcd9xxx_set_reset_pin_state(debugCodec, pdata, true);
-			usleep_range(1000, 2000);
-			wcd9xxx_slim_device_up(debugCodec->slim);
-		} else {
-			pr_err("%s: invalid command %ld\n", __func__, param);
-		}
-	}
-
-error_intf:
-	return rc;
-}
-
-static ssize_t codec_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *access_str = filp->private_data;
-	char lbuf[32];
-	int rc;
-	long int param[5];
-
-	if (cnt > sizeof(lbuf) - 1)
-		return -EINVAL;
-
-	rc = copy_from_user(lbuf, ubuf, cnt);
-	if (rc)
-		return -EFAULT;
-
-	lbuf[cnt] = '\0';
-
-	if (!strcmp(access_str, "slimslave_poke")) {
-		/* write */
-		rc = get_parameters(lbuf, param, 2);
-		if ((param[0] <= 0x3FF) && (param[1] <= 0xFF) &&
-			(rc == 0))
-			wcd9xxx_interface_reg_write(debugCodec, param[0],
-				param[1]);
-		else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "slimslave_peek")) {
-		/* read */
-		rc = get_parameters(lbuf, param, 1);
-		if ((param[0] <= 0x3FF) && (rc == 0))
-			read_data = wcd9xxx_interface_reg_read(debugCodec,
-				param[0]);
-		else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "power_state")) {
-		rc = codec_debug_process_cdc_power(lbuf);
-	}
-
-	if (rc == 0)
-		rc = cnt;
-	else
-		pr_err("%s: rc = %d\n", __func__, rc);
-
-	return rc;
-}
-
-static const struct file_operations codec_debug_ops = {
-	.open = codec_debug_open,
-	.write = codec_debug_write,
-	.read = codec_debug_read
-};
-#endif
-
-static struct wcd9xxx_i2c *wcd9xxx_i2c_get_device_info(struct wcd9xxx *wcd9xxx,
-						u16 reg)
-{
-	u16 mask = 0x0f00;
-	int value = 0;
-	struct wcd9xxx_i2c *wcd9xxx_i2c = NULL;
-
-	if (wcd9xxx->type == WCD9335) {
-		wcd9xxx_i2c = &wcd9xxx_modules[0];
-	} else {
-		value = ((reg & mask) >> 8) & 0x000f;
-		switch (value) {
-		case 0:
-			wcd9xxx_i2c = &wcd9xxx_modules[0];
-			break;
-		case 1:
-			wcd9xxx_i2c = &wcd9xxx_modules[1];
-			break;
-		case 2:
-			wcd9xxx_i2c = &wcd9xxx_modules[2];
-			break;
-		case 3:
-			wcd9xxx_i2c = &wcd9xxx_modules[3];
-			break;
-
-		default:
-			break;
-		}
-	}
-	return wcd9xxx_i2c;
-}
-
-static int wcd9xxx_i2c_write_device(struct wcd9xxx *wcd9xxx, u16 reg, u8 *value,
-				u32 bytes)
-{
-
-	struct i2c_msg *msg;
-	int ret = 0;
-	u8 reg_addr = 0;
-	u8 data[bytes + 1];
-	struct wcd9xxx_i2c *wcd9xxx_i2c;
-
-	wcd9xxx_i2c = wcd9xxx_i2c_get_device_info(wcd9xxx, reg);
-	if (wcd9xxx_i2c == NULL || wcd9xxx_i2c->client == NULL) {
-		pr_err("failed to get device info\n");
-		return -ENODEV;
-	}
-	reg_addr = (u8)reg;
-	msg = &wcd9xxx_i2c->xfer_msg[0];
-	msg->addr = wcd9xxx_i2c->client->addr;
-	msg->len = bytes + 1;
-	msg->flags = 0;
-	data[0] = reg;
-	data[1] = *value;
-	msg->buf = data;
-	ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
-			   wcd9xxx_i2c->xfer_msg, 1);
-	/* Try again if the write fails */
-	if (ret != 1) {
-		ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
-						wcd9xxx_i2c->xfer_msg, 1);
-		if (ret != 1) {
-			pr_err("failed to write the device\n");
-			return ret;
-		}
-	}
-	pr_debug("write success register = %x val = %x\n", reg, data[1]);
-	return 0;
-}
-
-
-static int wcd9xxx_i2c_read_device(struct wcd9xxx *wcd9xxx, unsigned short reg,
-				  int bytes, unsigned char *dest)
-{
-	struct i2c_msg *msg;
-	int ret = 0;
-	u8 reg_addr = 0;
-	struct wcd9xxx_i2c *wcd9xxx_i2c;
-	u8 i = 0;
-
-	wcd9xxx_i2c = wcd9xxx_i2c_get_device_info(wcd9xxx, reg);
-	if (wcd9xxx_i2c == NULL || wcd9xxx_i2c->client == NULL) {
-		pr_err("failed to get device info\n");
-		return -ENODEV;
-	}
-	for (i = 0; i < bytes; i++) {
-		reg_addr = (u8)reg++;
-		msg = &wcd9xxx_i2c->xfer_msg[0];
-		msg->addr = wcd9xxx_i2c->client->addr;
-		msg->len = 1;
-		msg->flags = 0;
-		msg->buf = &reg_addr;
-
-		msg = &wcd9xxx_i2c->xfer_msg[1];
-		msg->addr = wcd9xxx_i2c->client->addr;
-		msg->len = 1;
-		msg->flags = I2C_M_RD;
-		msg->buf = dest++;
-		ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
-				wcd9xxx_i2c->xfer_msg, 2);
-
-		/* Try again if read fails first time */
-		if (ret != 2) {
-			ret = i2c_transfer(wcd9xxx_i2c->client->adapter,
-					   wcd9xxx_i2c->xfer_msg, 2);
-			if (ret != 2) {
-				pr_err("failed to read wcd9xxx register\n");
-				return ret;
-			}
-		}
-	}
-	return 0;
-}
-
-int wcd9xxx_i2c_read(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			int bytes, void *dest, bool interface_reg)
-{
-	return wcd9xxx_i2c_read_device(wcd9xxx, reg, bytes, dest);
-}
-
-int wcd9xxx_i2c_write(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			 int bytes, void *src, bool interface_reg)
-{
-	return wcd9xxx_i2c_write_device(wcd9xxx, reg, src, bytes);
-}
-
-static int wcd9xxx_i2c_get_client_index(struct i2c_client *client,
-					int *wcd9xx_index)
-{
-	int ret = 0;
-
-	switch (client->addr) {
-	case WCD9XXX_I2C_TOP_SLAVE_ADDR:
-		*wcd9xx_index = WCD9XXX_I2C_TOP_LEVEL;
-	break;
-	case WCD9XXX_ANALOG_I2C_SLAVE_ADDR:
-		*wcd9xx_index = WCD9XXX_I2C_ANALOG;
-	break;
-	case WCD9XXX_DIGITAL1_I2C_SLAVE_ADDR:
-		*wcd9xx_index = WCD9XXX_I2C_DIGITAL_1;
-	break;
-	case WCD9XXX_DIGITAL2_I2C_SLAVE_ADDR:
-		*wcd9xx_index = WCD9XXX_I2C_DIGITAL_2;
-	break;
-	default:
-		ret = -EINVAL;
-	break;
-	}
-	return ret;
-}
-
-static int wcd9xxx_i2c_probe(struct i2c_client *client,
-			const struct i2c_device_id *id)
-{
-	struct wcd9xxx *wcd9xxx = NULL;
-	struct wcd9xxx_pdata *pdata = NULL;
-	int val = 0;
-	int ret = 0;
-	int wcd9xx_index = 0;
-	struct device *dev;
-	int intf_type;
-	const struct of_device_id *of_id;
-
-	intf_type = wcd9xxx_get_intf_type();
-
-	pr_debug("%s: interface status %d\n", __func__, intf_type);
-	if (intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		dev_dbg(&client->dev, "%s:Codec is detected in slimbus mode\n",
-			__func__);
-		return -ENODEV;
-	} else if (intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-		ret = wcd9xxx_i2c_get_client_index(client, &wcd9xx_index);
-		if (ret != 0)
-			dev_err(&client->dev, "%s: I2C set codec I2C\n"
-				"client failed\n", __func__);
-		else {
-			dev_err(&client->dev, "%s:probe for other slaves\n"
-				"devices of codec I2C slave Addr = %x\n",
-				__func__, client->addr);
-			wcd9xxx_modules[wcd9xx_index].client = client;
-		}
-		return ret;
-	} else if (intf_type == WCD9XXX_INTERFACE_TYPE_PROBING) {
-		dev = &client->dev;
-		if (client->dev.of_node) {
-			dev_dbg(&client->dev, "%s:Platform data\n"
-				"from device tree\n", __func__);
-			pdata = wcd9xxx_populate_dt_data(&client->dev);
-			if (!pdata) {
-				dev_err(&client->dev,
-					"%s: Fail to obtain pdata from device tree\n",
-					__func__);
-				ret = -EINVAL;
-				goto fail;
-			}
-			client->dev.platform_data = pdata;
-		} else {
-			dev_dbg(&client->dev, "%s:Platform data from\n"
-				"board file\n", __func__);
-			pdata = client->dev.platform_data;
-		}
-		wcd9xxx = devm_kzalloc(&client->dev, sizeof(struct wcd9xxx),
-				       GFP_KERNEL);
-		if (!wcd9xxx) {
-			ret = -ENOMEM;
-			goto fail;
-		}
-
-		if (!pdata) {
-			dev_dbg(&client->dev, "no platform data?\n");
-			ret = -EINVAL;
-			goto fail;
-		}
-		wcd9xxx->type = WCD9XXX;
-		if (client->dev.of_node) {
-			of_id = of_match_device(wcd9xxx_of_match, &client->dev);
-			if (of_id) {
-				wcd9xxx->type = *((int *)of_id->data);
-				dev_info(&client->dev, "%s: codec type is %d\n",
-					 __func__, wcd9xxx->type);
-			}
-		} else {
-			dev_info(&client->dev, "%s: dev.of_node is NULL, default to WCD9XXX\n",
-				 __func__);
-			wcd9xxx->type = WCD9XXX;
-		}
-		wcd9xxx->regmap = wcd9xxx_regmap_init(&client->dev,
-				&wcd9xxx_i2c_base_regmap_config);
-		if (IS_ERR(wcd9xxx->regmap)) {
-			ret = PTR_ERR(wcd9xxx->regmap);
-			dev_err(&client->dev, "%s: Failed to allocate register map: %d\n",
-					__func__, ret);
-			goto err_codec;
-		}
-		wcd9xxx->reset_gpio = pdata->reset_gpio;
-		wcd9xxx->wcd_rst_np = pdata->wcd_rst_np;
-
-		if (!wcd9xxx->wcd_rst_np) {
-			pdata->use_pinctrl = false;
-			dev_err(&client->dev, "%s: pinctrl not used for rst_n\n",
-				__func__);
-			goto err_codec;
-		}
-
-		if (i2c_check_functionality(client->adapter,
-					    I2C_FUNC_I2C) == 0) {
-			dev_dbg(&client->dev, "can't talk I2C?\n");
-			ret = -EIO;
-			goto fail;
-		}
-		dev_set_drvdata(&client->dev, wcd9xxx);
-		wcd9xxx->dev = &client->dev;
-		wcd9xxx->dev_up = true;
-		if (client->dev.of_node)
-			wcd9xxx->mclk_rate = pdata->mclk_rate;
-
-		wcd9xxx->num_of_supplies = pdata->num_supplies;
-		ret = msm_cdc_init_supplies(wcd9xxx->dev, &wcd9xxx->supplies,
-					    pdata->regulator,
-					    pdata->num_supplies);
-		if (!wcd9xxx->supplies) {
-			dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n",
-				__func__);
-			goto err_codec;
-		}
-		ret = msm_cdc_enable_static_supplies(wcd9xxx->dev,
-						     wcd9xxx->supplies,
-						     pdata->regulator,
-						     pdata->num_supplies);
-		if (ret) {
-			dev_err(wcd9xxx->dev, "%s: wcd static supply enable failed!\n",
-				__func__);
-			goto err_codec;
-		}
-		/* For WCD9335, it takes about 600us for the Vout_A and
-		 * Vout_D to be ready after BUCK_SIDO is powered up\
-		 * SYS_RST_N shouldn't be pulled high during this time
-		 */
-		if (wcd9xxx->type == WCD9335)
-			usleep_range(600, 650);
-		else
-			usleep_range(5, 10);
-
-		ret = wcd9xxx_reset(wcd9xxx->dev);
-		if (ret) {
-			pr_err("%s: Resetting Codec failed\n", __func__);
-			goto err_supplies;
-		}
-
-		ret = wcd9xxx_i2c_get_client_index(client, &wcd9xx_index);
-		if (ret != 0) {
-			pr_err("%s:Set codec I2C client failed\n", __func__);
-			goto err_supplies;
-		}
-
-		wcd9xxx_modules[wcd9xx_index].client = client;
-		wcd9xxx->read_dev = wcd9xxx_i2c_read;
-		wcd9xxx->write_dev = wcd9xxx_i2c_write;
-		if (!wcd9xxx->dev->of_node)
-			wcd9xxx_assign_irq(&wcd9xxx->core_res,
-					pdata->irq, pdata->irq_base);
-
-		ret = wcd9xxx_device_init(wcd9xxx);
-		if (ret) {
-			pr_err("%s: error, initializing device failed (%d)\n",
-			       __func__, ret);
-			goto err_device_init;
-		}
-
-		ret = wcd9xxx_i2c_read(wcd9xxx, WCD9XXX_A_CHIP_STATUS, 1,
-				       &val, 0);
-		if (ret < 0)
-			pr_err("%s: failed to read the wcd9xxx status (%d)\n",
-			       __func__, ret);
-		if (val != wcd9xxx->codec_type->i2c_chip_status)
-			pr_err("%s: unknown chip status 0x%x\n", __func__, val);
-
-		wcd9xxx_set_intf_type(WCD9XXX_INTERFACE_TYPE_I2C);
-
-		return ret;
-	}
-
-	pr_err("%s: I2C probe in wrong state\n", __func__);
-
-
-err_device_init:
-	wcd9xxx_reset_low(wcd9xxx->dev);
-err_supplies:
-	msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
-				 pdata->regulator,
-				 pdata->num_supplies);
-	pdata->regulator = NULL;
-	pdata->num_supplies = 0;
-err_codec:
-	devm_kfree(&client->dev, wcd9xxx);
-	dev_set_drvdata(&client->dev, NULL);
-fail:
-	return ret;
-}
-
-static int wcd9xxx_i2c_remove(struct i2c_client *client)
-{
-	struct wcd9xxx *wcd9xxx;
-	struct wcd9xxx_pdata *pdata = client->dev.platform_data;
-
-	wcd9xxx = dev_get_drvdata(&client->dev);
-	msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
-				 pdata->regulator,
-				 pdata->num_supplies);
-	wcd9xxx_device_exit(wcd9xxx);
-	dev_set_drvdata(&client->dev, NULL);
-	return 0;
-}
-
-static int wcd9xxx_dt_parse_slim_interface_dev_info(struct device *dev,
-						struct slim_device *slim_ifd)
-{
-	int ret = 0;
-	struct property *prop;
-
-	ret = of_property_read_string(dev->of_node, "qcom,cdc-slim-ifd",
-				      &slim_ifd->name);
-	if (ret) {
-		dev_err(dev, "Looking up %s property in node %s failed",
-			"qcom,cdc-slim-ifd-dev", dev->of_node->full_name);
-		return -ENODEV;
-	}
-	prop = of_find_property(dev->of_node,
-			"qcom,cdc-slim-ifd-elemental-addr", NULL);
-	if (!prop) {
-		dev_err(dev, "Looking up %s property in node %s failed",
-			"qcom,cdc-slim-ifd-elemental-addr",
-			dev->of_node->full_name);
-		return -ENODEV;
-	} else if (prop->length != 6) {
-		dev_err(dev, "invalid codec slim ifd addr. addr length = %d\n",
-			      prop->length);
-		return -ENODEV;
-	}
-	memcpy(slim_ifd->e_addr, prop->value, 6);
-
-	return 0;
-}
-
-static int wcd9xxx_slim_get_laddr(struct slim_device *sb,
-				  const u8 *e_addr, u8 e_len, u8 *laddr)
-{
-	int ret;
-	const unsigned long timeout = jiffies +
-				      msecs_to_jiffies(SLIMBUS_PRESENT_TIMEOUT);
-
-	do {
-		ret = slim_get_logical_addr(sb, e_addr, e_len, laddr);
-		if (!ret)
-			break;
-		/* Give SLIMBUS time to report present and be ready. */
-		usleep_range(1000, 1100);
-		pr_debug_ratelimited("%s: retyring get logical addr\n",
-				     __func__);
-	} while time_before(jiffies, timeout);
-
-	return ret;
-}
-
-static int wcd9xxx_slim_probe(struct slim_device *slim)
-{
-	struct wcd9xxx *wcd9xxx;
-	struct wcd9xxx_pdata *pdata;
-	const struct slim_device_id *device_id;
-	int ret = 0;
-	int intf_type;
-
-	intf_type = wcd9xxx_get_intf_type();
-
-	wcd9xxx = devm_kzalloc(&slim->dev, sizeof(struct wcd9xxx),
-				GFP_KERNEL);
-	if (!wcd9xxx) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	if (!slim) {
-		ret = -EINVAL;
-		goto err;
-	}
-
-	if (intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-		dev_dbg(&slim->dev, "%s:Codec is detected in I2C mode\n",
-			__func__);
-		ret = -ENODEV;
-		goto err;
-	}
-	if (slim->dev.of_node) {
-		dev_info(&slim->dev, "Platform data from device tree\n");
-		pdata = wcd9xxx_populate_dt_data(&slim->dev);
-		if (!pdata) {
-			dev_err(&slim->dev,
-				"%s: Fail to obtain pdata from device tree\n",
-				__func__);
-			ret = -EINVAL;
-			goto err;
-		}
-
-		ret = wcd9xxx_dt_parse_slim_interface_dev_info(&slim->dev,
-				&pdata->slimbus_slave_device);
-		if (ret) {
-			dev_err(&slim->dev, "Error, parsing slim interface\n");
-			devm_kfree(&slim->dev, pdata);
-			ret = -EINVAL;
-			goto err;
-		}
-		slim->dev.platform_data = pdata;
-
-	} else {
-		dev_info(&slim->dev, "Platform data from board file\n");
-		pdata = slim->dev.platform_data;
-	}
-
-	if (!pdata) {
-		dev_err(&slim->dev, "Error, no platform data\n");
-		ret = -EINVAL;
-		goto err;
-	}
-
-	if (!slim->ctrl) {
-		dev_err(&slim->dev, "%s: Error, no SLIMBUS control data\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_codec;
-	}
-
-	if (pdata->has_buck_vsel_gpio)
-		msm_cdc_pinctrl_select_active_state(pdata->buck_vsel_ctl_np);
-
-	device_id = slim_get_device_id(slim);
-	if (!device_id) {
-		dev_err(&slim->dev, "%s: Error, no device id\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	wcd9xxx->type = device_id->driver_data;
-	dev_info(&slim->dev, "%s: probing for wcd type: %d, name: %s\n",
-		 __func__, wcd9xxx->type, device_id->name);
-
-	/* wcd9xxx members init */
-	wcd9xxx->multi_reg_write = wcd9xxx_slim_multi_reg_write;
-	wcd9xxx->slim = slim;
-	slim_set_clientdata(slim, wcd9xxx);
-	wcd9xxx->reset_gpio = pdata->reset_gpio;
-	wcd9xxx->dev = &slim->dev;
-	wcd9xxx->mclk_rate = pdata->mclk_rate;
-	wcd9xxx->dev_up = true;
-	wcd9xxx->wcd_rst_np = pdata->wcd_rst_np;
-
-	wcd9xxx->regmap = wcd9xxx_regmap_init(&slim->dev,
-					      &wcd9xxx_base_regmap_config);
-	if (IS_ERR(wcd9xxx->regmap)) {
-		ret = PTR_ERR(wcd9xxx->regmap);
-		dev_err(&slim->dev, "%s: Failed to allocate register map: %d\n",
-			__func__, ret);
-		goto err_codec;
-	}
-
-	if (!wcd9xxx->wcd_rst_np) {
-		pdata->use_pinctrl = false;
-		dev_err(&slim->dev, "%s: pinctrl not used for rst_n\n",
-			__func__);
-		goto err_codec;
-	}
-
-	wcd9xxx->num_of_supplies = pdata->num_supplies;
-	ret = msm_cdc_init_supplies(&slim->dev, &wcd9xxx->supplies,
-				    pdata->regulator,
-				    pdata->num_supplies);
-	if (!wcd9xxx->supplies) {
-		dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n",
-			__func__);
-		goto err_codec;
-	}
-	ret = msm_cdc_enable_static_supplies(wcd9xxx->dev,
-					     wcd9xxx->supplies,
-					     pdata->regulator,
-					     pdata->num_supplies);
-	if (ret) {
-		dev_err(wcd9xxx->dev, "%s: wcd static supply enable failed!\n",
-			__func__);
-		goto err_codec;
-	}
-
-	/*
-	 * For WCD9335, it takes about 600us for the Vout_A and
-	 * Vout_D to be ready after BUCK_SIDO is powered up.
-	 * SYS_RST_N shouldn't be pulled high during this time
-	 */
-	if (wcd9xxx->type == WCD9335 || wcd9xxx->type == WCD934X)
-		usleep_range(600, 650);
-	else
-		usleep_range(5, 10);
-
-	ret = wcd9xxx_reset(&slim->dev);
-	if (ret) {
-		dev_err(&slim->dev, "%s: Resetting Codec failed\n", __func__);
-		goto err_supplies;
-	}
-
-	ret = wcd9xxx_slim_get_laddr(wcd9xxx->slim, wcd9xxx->slim->e_addr,
-				     ARRAY_SIZE(wcd9xxx->slim->e_addr),
-				     &wcd9xxx->slim->laddr);
-	if (ret) {
-		dev_err(&slim->dev, "%s: failed to get slimbus %s logical address: %d\n",
-		       __func__, wcd9xxx->slim->name, ret);
-		goto err_reset;
-	}
-	wcd9xxx->read_dev = wcd9xxx_slim_read_device;
-	wcd9xxx->write_dev = wcd9xxx_slim_write_device;
-	wcd9xxx_pgd_la = wcd9xxx->slim->laddr;
-	wcd9xxx->slim_slave = &pdata->slimbus_slave_device;
-	if (!wcd9xxx->dev->of_node)
-		wcd9xxx_assign_irq(&wcd9xxx->core_res,
-					pdata->irq, pdata->irq_base);
-
-	ret = slim_add_device(slim->ctrl, wcd9xxx->slim_slave);
-	if (ret) {
-		dev_err(&slim->dev, "%s: error, adding SLIMBUS device failed\n",
-			__func__);
-		goto err_reset;
-	}
-
-	ret = wcd9xxx_slim_get_laddr(wcd9xxx->slim_slave,
-				     wcd9xxx->slim_slave->e_addr,
-				     ARRAY_SIZE(wcd9xxx->slim_slave->e_addr),
-				     &wcd9xxx->slim_slave->laddr);
-	if (ret) {
-		dev_err(&slim->dev, "%s: failed to get slimbus %s logical address: %d\n",
-		       __func__, wcd9xxx->slim->name, ret);
-		goto err_slim_add;
-	}
-	wcd9xxx_inf_la = wcd9xxx->slim_slave->laddr;
-	wcd9xxx_set_intf_type(WCD9XXX_INTERFACE_TYPE_SLIMBUS);
-
-	ret = wcd9xxx_device_init(wcd9xxx);
-	if (ret) {
-		dev_err(&slim->dev, "%s: error, initializing device failed (%d)\n",
-			__func__, ret);
-		goto err_slim_add;
-	}
-#ifdef CONFIG_DEBUG_FS
-	debugCodec = wcd9xxx;
-
-	debugfs_wcd9xxx_dent = debugfs_create_dir
-		("wcd9xxx_core", 0);
-	if (!IS_ERR(debugfs_wcd9xxx_dent)) {
-		debugfs_peek = debugfs_create_file("slimslave_peek",
-		S_IFREG | 0444, debugfs_wcd9xxx_dent,
-		(void *) "slimslave_peek", &codec_debug_ops);
-
-		debugfs_poke = debugfs_create_file("slimslave_poke",
-		S_IFREG | 0444, debugfs_wcd9xxx_dent,
-		(void *) "slimslave_poke", &codec_debug_ops);
-
-		debugfs_power_state = debugfs_create_file("power_state",
-		S_IFREG | 0444, debugfs_wcd9xxx_dent,
-		(void *) "power_state", &codec_debug_ops);
-
-		debugfs_reg_dump = debugfs_create_file("slimslave_reg_dump",
-		S_IFREG | 0444, debugfs_wcd9xxx_dent,
-		(void *) "slimslave_reg_dump", &codec_debug_ops);
-	}
-#endif
-
-	return ret;
-
-err_slim_add:
-	slim_remove_device(wcd9xxx->slim_slave);
-err_reset:
-	wcd9xxx_reset_low(wcd9xxx->dev);
-err_supplies:
-	msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
-				 pdata->regulator,
-				 pdata->num_supplies);
-err_codec:
-	slim_set_clientdata(slim, NULL);
-err:
-	devm_kfree(&slim->dev, wcd9xxx);
-	return ret;
-}
-static int wcd9xxx_slim_remove(struct slim_device *pdev)
-{
-	struct wcd9xxx *wcd9xxx;
-	struct wcd9xxx_pdata *pdata = pdev->dev.platform_data;
-
-#ifdef CONFIG_DEBUG_FS
-	debugfs_remove_recursive(debugfs_wcd9xxx_dent);
-#endif
-	wcd9xxx = slim_get_devicedata(pdev);
-	wcd9xxx_deinit_slimslave(wcd9xxx);
-	slim_remove_device(wcd9xxx->slim_slave);
-	msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
-				 pdata->regulator,
-				 pdata->num_supplies);
-	wcd9xxx_device_exit(wcd9xxx);
-	slim_set_clientdata(pdev, NULL);
-	return 0;
-}
-
-static int wcd9xxx_device_up(struct wcd9xxx *wcd9xxx)
-{
-	int ret = 0;
-	struct wcd9xxx_core_resource *wcd9xxx_res = &wcd9xxx->core_res;
-
-	dev_info(wcd9xxx->dev, "%s: codec bring up\n", __func__);
-	wcd9xxx_bringup(wcd9xxx->dev);
-	ret = wcd9xxx_irq_init(wcd9xxx_res);
-	if (ret) {
-		pr_err("%s: wcd9xx_irq_init failed : %d\n", __func__, ret);
-	} else {
-		if (wcd9xxx->post_reset)
-			ret = wcd9xxx->post_reset(wcd9xxx);
-	}
-	return ret;
-}
-
-static int wcd9xxx_slim_device_reset(struct slim_device *sldev)
-{
-	int ret;
-	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
-
-	if (!wcd9xxx) {
-		pr_err("%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	/*
-	 * Wait for 500 ms for device down to complete. Observed delay
-	 *  of ~200ms for device down to complete after being called,
-	 * due to context switch issue.
-	 */
-	ret = wait_on_bit_timeout(&wcd9xxx->dev_up, 0,
-				  TASK_INTERRUPTIBLE,
-				  msecs_to_jiffies(500));
-	if (ret)
-		pr_err("%s: slim device down not complete in 500 msec\n",
-				__func__);
-
-	mutex_lock(&wcd9xxx->reset_lock);
-
-	dev_info(wcd9xxx->dev, "%s: device reset, dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-	if (wcd9xxx->dev_up) {
-		mutex_unlock(&wcd9xxx->reset_lock);
-		return 0;
-	}
-
-	ret = wcd9xxx_reset(wcd9xxx->dev);
-	if (ret)
-		dev_err(wcd9xxx->dev, "%s: Resetting Codec failed\n", __func__);
-	mutex_unlock(&wcd9xxx->reset_lock);
-
-	return ret;
-}
-
-static int wcd9xxx_slim_device_up(struct slim_device *sldev)
-{
-	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
-	int ret = 0;
-
-	if (!wcd9xxx) {
-		pr_err("%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_info(wcd9xxx->dev, "%s: slim device up, dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-	if (wcd9xxx->dev_up)
-		return 0;
-
-	wcd9xxx->dev_up = true;
-
-	mutex_lock(&wcd9xxx->reset_lock);
-	ret = wcd9xxx_device_up(wcd9xxx);
-	mutex_unlock(&wcd9xxx->reset_lock);
-
-	return ret;
-}
-
-static int wcd9xxx_slim_device_down(struct slim_device *sldev)
-{
-	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
-
-	if (!wcd9xxx) {
-		pr_err("%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&wcd9xxx->reset_lock);
-
-	dev_info(wcd9xxx->dev, "%s: device down, dev_up = %lu\n",
-			__func__, wcd9xxx->dev_up);
-	if (!wcd9xxx->dev_up) {
-		mutex_unlock(&wcd9xxx->reset_lock);
-		return 0;
-	}
-
-	if (wcd9xxx->dev_down)
-		wcd9xxx->dev_down(wcd9xxx);
-	wcd9xxx_irq_exit(&wcd9xxx->core_res);
-	wcd9xxx_reset_low(wcd9xxx->dev);
-	wcd9xxx->dev_up = false;
-	mutex_unlock(&wcd9xxx->reset_lock);
-
-	return 0;
-}
-
-static int wcd9xxx_slim_resume(struct slim_device *sldev)
-{
-	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
-
-	return wcd9xxx_core_res_resume(&wcd9xxx->core_res);
-}
-
-static int wcd9xxx_i2c_resume(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
-
-	if (wcd9xxx)
-		return wcd9xxx_core_res_resume(&wcd9xxx->core_res);
-	else
-		return 0;
-}
-
-static int wcd9xxx_slim_suspend(struct slim_device *sldev, pm_message_t pmesg)
-{
-	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
-
-	return wcd9xxx_core_res_suspend(&wcd9xxx->core_res, pmesg);
-}
-
-static int wcd9xxx_i2c_suspend(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
-	pm_message_t pmesg = {0};
-
-	if (wcd9xxx)
-		return wcd9xxx_core_res_suspend(&wcd9xxx->core_res, pmesg);
-	else
-		return 0;
-}
-
-static const struct slim_device_id wcd_slim_device_id[] = {
-	{"sitar-slim", 0},
-	{"sitar1p1-slim", 0},
-	{"tabla-slim", 0},
-	{"tabla2x-slim", 0},
-	{"taiko-slim-pgd", 0},
-	{"tapan-slim-pgd", 0},
-	{"tomtom-slim-pgd", WCD9330},
-	{"tasha-slim-pgd", WCD9335},
-	{"tavil-slim-pgd", WCD934X},
-	{}
-};
-
-static struct slim_driver wcd_slim_driver = {
-	.driver = {
-		.name = "wcd-slim",
-		.owner = THIS_MODULE,
-	},
-	.probe = wcd9xxx_slim_probe,
-	.remove = wcd9xxx_slim_remove,
-	.id_table = wcd_slim_device_id,
-	.resume = wcd9xxx_slim_resume,
-	.suspend = wcd9xxx_slim_suspend,
-	.device_up = wcd9xxx_slim_device_up,
-	.reset_device = wcd9xxx_slim_device_reset,
-	.device_down = wcd9xxx_slim_device_down,
-};
-
-static struct i2c_device_id wcd9xxx_id_table[] = {
-	{"wcd9xxx-i2c", WCD9XXX_I2C_TOP_LEVEL},
-	{"wcd9xxx-i2c", WCD9XXX_I2C_ANALOG},
-	{"wcd9xxx-i2c", WCD9XXX_I2C_DIGITAL_1},
-	{"wcd9xxx-i2c", WCD9XXX_I2C_DIGITAL_2},
-	{}
-};
-
-static struct i2c_device_id tasha_id_table[] = {
-	{"tasha-i2c-pgd", WCD9XXX_I2C_TOP_LEVEL},
-	{}
-};
-
-static struct i2c_device_id tabla_id_table[] = {
-	{"tabla top level", WCD9XXX_I2C_TOP_LEVEL},
-	{"tabla analog", WCD9XXX_I2C_ANALOG},
-	{"tabla digital1", WCD9XXX_I2C_DIGITAL_1},
-	{"tabla digital2", WCD9XXX_I2C_DIGITAL_2},
-	{}
-};
-MODULE_DEVICE_TABLE(i2c, tabla_id_table);
-
-static const struct dev_pm_ops wcd9xxx_i2c_pm_ops = {
-	.suspend = wcd9xxx_i2c_suspend,
-	.resume	= wcd9xxx_i2c_resume,
-};
-
-static struct i2c_driver tabla_i2c_driver = {
-	.driver                 = {
-		.owner          =       THIS_MODULE,
-		.name           =       "tabla-i2c-core",
-		.pm		=	&wcd9xxx_i2c_pm_ops,
-	},
-	.id_table               =       tabla_id_table,
-	.probe                  =       wcd9xxx_i2c_probe,
-	.remove                 =       wcd9xxx_i2c_remove,
-};
-
-static struct i2c_driver wcd9xxx_i2c_driver = {
-	.driver                 = {
-		.owner          =       THIS_MODULE,
-		.name           =       "wcd9xxx-i2c-core",
-		.pm		=	&wcd9xxx_i2c_pm_ops,
-	},
-	.id_table               =       wcd9xxx_id_table,
-	.probe                  =       wcd9xxx_i2c_probe,
-	.remove                 =       wcd9xxx_i2c_remove,
-};
-
-static struct i2c_driver wcd9335_i2c_driver = {
-	.driver	                = {
-		.owner	        =       THIS_MODULE,
-		.name           =       "tasha-i2c-core",
-		.pm		=	&wcd9xxx_i2c_pm_ops,
-	},
-	.id_table               =       tasha_id_table,
-	.probe                  =       wcd9xxx_i2c_probe,
-	.remove                 =       wcd9xxx_i2c_remove,
-};
-
-int wcd9xxx_init(void)
-{
-	int ret[NUM_WCD9XXX_REG_RET] = {0};
-	int i = 0;
-
-	wcd9xxx_set_intf_type(WCD9XXX_INTERFACE_TYPE_PROBING);
-
-	ret[0] = i2c_add_driver(&tabla_i2c_driver);
-	if (ret[0])
-		pr_err("%s: Failed to add the tabla2x I2C driver: %d\n",
-			__func__, ret[0]);
-
-	ret[1] = i2c_add_driver(&wcd9xxx_i2c_driver);
-	if (ret[1])
-		pr_err("%s: Failed to add the wcd9xxx I2C driver: %d\n",
-			__func__, ret[1]);
-
-	ret[2] = i2c_add_driver(&wcd9335_i2c_driver);
-	if (ret[2])
-		pr_err("%s: Failed to add the wcd9335 I2C driver: %d\n",
-			__func__, ret[2]);
-
-	ret[3] = slim_driver_register(&wcd_slim_driver);
-	if (ret[3])
-		pr_err("%s: Failed to register wcd SB driver: %d\n",
-			__func__, ret[3]);
-
-	for (i = 0; i < NUM_WCD9XXX_REG_RET; i++) {
-		if (ret[i])
-			return ret[i];
-	}
-
-	return 0;
-}
-
-void wcd9xxx_exit(void)
-{
-	wcd9xxx_set_intf_type(WCD9XXX_INTERFACE_TYPE_PROBING);
-
-	i2c_del_driver(&tabla_i2c_driver);
-	i2c_del_driver(&wcd9xxx_i2c_driver);
-	i2c_del_driver(&wcd9335_i2c_driver);
-	slim_driver_unregister(&wcd_slim_driver);
-}
-
-MODULE_DESCRIPTION("Codec core driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/wcd9xxx-irq.c b/drivers/mfd/wcd9xxx-irq.c
deleted file mode 100644
index cb98083..0000000
--- a/drivers/mfd/wcd9xxx-irq.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/bitops.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/irq.h>
-#include <linux/mfd/core.h>
-#include <linux/regmap.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/delay.h>
-#include <linux/irqdomain.h>
-#include <linux/interrupt.h>
-#include <linux/of.h>
-#include <linux/of_irq.h>
-#include <linux/slab.h>
-#include <linux/ratelimit.h>
-#include <soc/qcom/pm.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-
-#define BYTE_BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_BYTE))
-#define BIT_BYTE(nr)			((nr) / BITS_PER_BYTE)
-
-#define WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS 100
-
-#ifndef NO_IRQ
-#define NO_IRQ	(-1)
-#endif
-
-#ifdef CONFIG_OF
-struct wcd9xxx_irq_drv_data {
-	struct irq_domain *domain;
-	int irq;
-};
-#endif
-
-static int virq_to_phyirq(
-	struct wcd9xxx_core_resource *wcd9xxx_res, int virq);
-static int phyirq_to_virq(
-	struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
-static unsigned int wcd9xxx_irq_get_upstream_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res);
-static void wcd9xxx_irq_put_downstream_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res);
-static void wcd9xxx_irq_put_upstream_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res);
-static int wcd9xxx_map_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
-
-static void wcd9xxx_irq_lock(struct irq_data *data)
-{
-	struct wcd9xxx_core_resource *wcd9xxx_res =
-			irq_data_get_irq_chip_data(data);
-	mutex_lock(&wcd9xxx_res->irq_lock);
-}
-
-static void wcd9xxx_irq_sync_unlock(struct irq_data *data)
-{
-	struct wcd9xxx_core_resource *wcd9xxx_res =
-			irq_data_get_irq_chip_data(data);
-	int i;
-
-	if ((ARRAY_SIZE(wcd9xxx_res->irq_masks_cur) >
-	     WCD9XXX_MAX_IRQ_REGS) ||
-	     (ARRAY_SIZE(wcd9xxx_res->irq_masks_cache) >
-	      WCD9XXX_MAX_IRQ_REGS)) {
-		pr_err("%s: Array Size out of bound\n", __func__);
-		return;
-	}
-	if (!wcd9xxx_res->wcd_core_regmap) {
-		pr_err("%s: Codec core regmap not defined\n",
-			__func__);
-		return;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(wcd9xxx_res->irq_masks_cur); i++) {
-		/* If there's been a change in the mask write it back
-		 * to the hardware.
-		 */
-		if (wcd9xxx_res->irq_masks_cur[i] !=
-					wcd9xxx_res->irq_masks_cache[i]) {
-
-			wcd9xxx_res->irq_masks_cache[i] =
-					wcd9xxx_res->irq_masks_cur[i];
-			regmap_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_MASK_BASE] + i,
-			wcd9xxx_res->irq_masks_cur[i]);
-		}
-	}
-
-	mutex_unlock(&wcd9xxx_res->irq_lock);
-}
-
-static void wcd9xxx_irq_enable(struct irq_data *data)
-{
-	struct wcd9xxx_core_resource *wcd9xxx_res =
-			irq_data_get_irq_chip_data(data);
-	int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
-	int byte = BIT_BYTE(wcd9xxx_irq);
-	int size = ARRAY_SIZE(wcd9xxx_res->irq_masks_cur);
-
-	if ((byte < size) && (byte >= 0)) {
-		wcd9xxx_res->irq_masks_cur[byte] &=
-			~(BYTE_BIT_MASK(wcd9xxx_irq));
-	} else {
-		pr_err("%s: Array size is %d but index is %d: Out of range\n",
-			__func__, size, byte);
-	}
-}
-
-static void wcd9xxx_irq_disable(struct irq_data *data)
-{
-	struct wcd9xxx_core_resource *wcd9xxx_res =
-			irq_data_get_irq_chip_data(data);
-	int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
-	int byte = BIT_BYTE(wcd9xxx_irq);
-	int size = ARRAY_SIZE(wcd9xxx_res->irq_masks_cur);
-
-	if ((byte < size) && (byte >= 0)) {
-		wcd9xxx_res->irq_masks_cur[byte]
-			|= BYTE_BIT_MASK(wcd9xxx_irq);
-	} else {
-		pr_err("%s: Array size is %d but index is %d: Out of range\n",
-			__func__, size, byte);
-	}
-}
-
-static void wcd9xxx_irq_ack(struct irq_data *data)
-{
-	int wcd9xxx_irq = 0;
-	struct wcd9xxx_core_resource *wcd9xxx_res =
-			irq_data_get_irq_chip_data(data);
-
-	if (wcd9xxx_res == NULL) {
-		pr_err("%s: wcd9xxx_res is NULL\n", __func__);
-		return;
-	}
-	wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
-	pr_debug("%s: IRQ_ACK called for WCD9XXX IRQ: %d\n",
-				__func__, wcd9xxx_irq);
-}
-
-static void wcd9xxx_irq_mask(struct irq_data *d)
-{
-	/* do nothing but required as linux calls irq_mask without NULL check */
-}
-
-static struct irq_chip wcd9xxx_irq_chip = {
-	.name = "wcd9xxx",
-	.irq_bus_lock = wcd9xxx_irq_lock,
-	.irq_bus_sync_unlock = wcd9xxx_irq_sync_unlock,
-	.irq_disable = wcd9xxx_irq_disable,
-	.irq_enable = wcd9xxx_irq_enable,
-	.irq_mask = wcd9xxx_irq_mask,
-	.irq_ack = wcd9xxx_irq_ack,
-};
-
-bool wcd9xxx_lock_sleep(
-	struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	enum wcd9xxx_pm_state os;
-
-	/*
-	 * wcd9xxx_{lock/unlock}_sleep will be called by wcd9xxx_irq_thread
-	 * and its subroutines only motly.
-	 * but btn0_lpress_fn is not wcd9xxx_irq_thread's subroutine and
-	 * It can race with wcd9xxx_irq_thread.
-	 * So need to embrace wlock_holders with mutex.
-	 *
-	 * If system didn't resume, we can simply return false so codec driver's
-	 * IRQ handler can return without handling IRQ.
-	 * As interrupt line is still active, codec will have another IRQ to
-	 * retry shortly.
-	 */
-	mutex_lock(&wcd9xxx_res->pm_lock);
-	if (wcd9xxx_res->wlock_holders++ == 0) {
-		pr_debug("%s: holding wake lock\n", __func__);
-		pm_qos_update_request(&wcd9xxx_res->pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-		pm_stay_awake(wcd9xxx_res->dev);
-	}
-	mutex_unlock(&wcd9xxx_res->pm_lock);
-
-	if (!wait_event_timeout(wcd9xxx_res->pm_wq,
-				((os =  wcd9xxx_pm_cmpxchg(wcd9xxx_res,
-						  WCD9XXX_PM_SLEEPABLE,
-						  WCD9XXX_PM_AWAKE)) ==
-							WCD9XXX_PM_SLEEPABLE ||
-					(os == WCD9XXX_PM_AWAKE)),
-				msecs_to_jiffies(
-					WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) {
-		pr_warn("%s: system didn't resume within %dms, s %d, w %d\n",
-			__func__,
-			WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS, wcd9xxx_res->pm_state,
-			wcd9xxx_res->wlock_holders);
-		wcd9xxx_unlock_sleep(wcd9xxx_res);
-		return false;
-	}
-	wake_up_all(&wcd9xxx_res->pm_wq);
-	return true;
-}
-EXPORT_SYMBOL(wcd9xxx_lock_sleep);
-
-void wcd9xxx_unlock_sleep(
-	struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	mutex_lock(&wcd9xxx_res->pm_lock);
-	if (--wcd9xxx_res->wlock_holders == 0) {
-		pr_debug("%s: releasing wake lock pm_state %d -> %d\n",
-			 __func__, wcd9xxx_res->pm_state, WCD9XXX_PM_SLEEPABLE);
-		/*
-		 * if wcd9xxx_lock_sleep failed, pm_state would be still
-		 * WCD9XXX_PM_ASLEEP, don't overwrite
-		 */
-		if (likely(wcd9xxx_res->pm_state == WCD9XXX_PM_AWAKE))
-			wcd9xxx_res->pm_state = WCD9XXX_PM_SLEEPABLE;
-		pm_qos_update_request(&wcd9xxx_res->pm_qos_req,
-				PM_QOS_DEFAULT_VALUE);
-		pm_relax(wcd9xxx_res->dev);
-	}
-	mutex_unlock(&wcd9xxx_res->pm_lock);
-	wake_up_all(&wcd9xxx_res->pm_wq);
-}
-EXPORT_SYMBOL(wcd9xxx_unlock_sleep);
-
-void wcd9xxx_nested_irq_lock(struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	mutex_lock(&wcd9xxx_res->nested_irq_lock);
-}
-
-void wcd9xxx_nested_irq_unlock(struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	mutex_unlock(&wcd9xxx_res->nested_irq_lock);
-}
-
-
-static void wcd9xxx_irq_dispatch(struct wcd9xxx_core_resource *wcd9xxx_res,
-			struct intr_data *irqdata)
-{
-	int irqbit = irqdata->intr_num;
-
-	if (!wcd9xxx_res->wcd_core_regmap) {
-		pr_err("%s: codec core regmap not defined\n",
-			__func__);
-		return;
-	}
-
-	if (irqdata->clear_first) {
-		wcd9xxx_nested_irq_lock(wcd9xxx_res);
-		regmap_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLEAR_BASE] +
-					      BIT_BYTE(irqbit),
-			BYTE_BIT_MASK(irqbit));
-
-		if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
-			regmap_write(wcd9xxx_res->wcd_core_regmap,
-				wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLR_COMMIT],
-				0x02);
-		handle_nested_irq(phyirq_to_virq(wcd9xxx_res, irqbit));
-		wcd9xxx_nested_irq_unlock(wcd9xxx_res);
-	} else {
-		wcd9xxx_nested_irq_lock(wcd9xxx_res);
-		handle_nested_irq(phyirq_to_virq(wcd9xxx_res, irqbit));
-		regmap_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLEAR_BASE] +
-					      BIT_BYTE(irqbit),
-			BYTE_BIT_MASK(irqbit));
-		if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
-			regmap_write(wcd9xxx_res->wcd_core_regmap,
-				wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLR_COMMIT],
-				0x02);
-
-		wcd9xxx_nested_irq_unlock(wcd9xxx_res);
-	}
-}
-
-static irqreturn_t wcd9xxx_irq_thread(int irq, void *data)
-{
-	int ret;
-	int i;
-	struct intr_data irqdata;
-	char linebuf[128];
-	static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 1);
-	struct wcd9xxx_core_resource *wcd9xxx_res = data;
-	int num_irq_regs = wcd9xxx_res->num_irq_regs;
-	u8 status[4], status1[4] = {0}, unmask_status[4] = {0};
-
-	if (unlikely(wcd9xxx_lock_sleep(wcd9xxx_res) == false)) {
-		dev_err(wcd9xxx_res->dev, "Failed to hold suspend\n");
-		return IRQ_NONE;
-	}
-
-	if (!wcd9xxx_res->wcd_core_regmap) {
-		dev_err(wcd9xxx_res->dev,
-			"%s: Codec core regmap not supplied\n",
-			   __func__);
-		goto err_disable_irq;
-	}
-
-	memset(status, 0, sizeof(status));
-	ret = regmap_bulk_read(wcd9xxx_res->wcd_core_regmap,
-		wcd9xxx_res->intr_reg[WCD9XXX_INTR_STATUS_BASE],
-		status, num_irq_regs);
-
-	if (ret < 0) {
-		dev_err(wcd9xxx_res->dev,
-				"Failed to read interrupt status: %d\n", ret);
-		goto err_disable_irq;
-	}
-	/*
-	 * If status is 0 return without clearing.
-	 * status contains: HW status - masked interrupts
-	 * status1 contains: unhandled interrupts - masked interrupts
-	 * unmasked_status contains: unhandled interrupts
-	 */
-	if (unlikely(!memcmp(status, status1, sizeof(status)))) {
-		pr_debug("%s: status is 0\n", __func__);
-		wcd9xxx_unlock_sleep(wcd9xxx_res);
-		return IRQ_HANDLED;
-	}
-
-	/*
-	 * Copy status to unmask_status before masking, otherwise SW may miss
-	 * to clear masked interrupt in corner case.
-	 */
-	memcpy(unmask_status, status, sizeof(unmask_status));
-
-	/* Apply masking */
-	for (i = 0; i < num_irq_regs; i++)
-		status[i] &= ~wcd9xxx_res->irq_masks_cur[i];
-
-	memcpy(status1, status, sizeof(status1));
-
-	/* Find out which interrupt was triggered and call that interrupt's
-	 * handler function
-	 *
-	 * Since codec has only one hardware irq line which is shared by
-	 * codec's different internal interrupts, so it's possible master irq
-	 * handler dispatches multiple nested irq handlers after breaking
-	 * order.  Dispatch interrupts in the order that is maintained by
-	 * the interrupt table.
-	 */
-	for (i = 0; i < wcd9xxx_res->intr_table_size; i++) {
-		irqdata = wcd9xxx_res->intr_table[i];
-		if (status[BIT_BYTE(irqdata.intr_num)] &
-			BYTE_BIT_MASK(irqdata.intr_num)) {
-			wcd9xxx_irq_dispatch(wcd9xxx_res, &irqdata);
-			status1[BIT_BYTE(irqdata.intr_num)] &=
-					~BYTE_BIT_MASK(irqdata.intr_num);
-			unmask_status[BIT_BYTE(irqdata.intr_num)] &=
-					~BYTE_BIT_MASK(irqdata.intr_num);
-		}
-	}
-
-	/*
-	 * As a failsafe if unhandled irq is found, clear it to prevent
-	 * interrupt storm.
-	 * Note that we can say there was an unhandled irq only when no irq
-	 * handled by nested irq handler since Taiko supports qdsp as irqs'
-	 * destination for few irqs.  Therefore driver shouldn't clear pending
-	 * irqs when few handled while few others not.
-	 */
-	if (unlikely(!memcmp(status, status1, sizeof(status)))) {
-		if (__ratelimit(&ratelimit)) {
-			pr_warn("%s: Unhandled irq found\n", __func__);
-			hex_dump_to_buffer(status, sizeof(status), 16, 1,
-					   linebuf, sizeof(linebuf), false);
-			pr_warn("%s: status0 : %s\n", __func__, linebuf);
-			hex_dump_to_buffer(status1, sizeof(status1), 16, 1,
-					   linebuf, sizeof(linebuf), false);
-			pr_warn("%s: status1 : %s\n", __func__, linebuf);
-		}
-		/*
-		 * unmask_status contains unhandled interrupts, hence clear all
-		 * unhandled interrupts.
-		 */
-		ret = regmap_bulk_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLEAR_BASE],
-			unmask_status, num_irq_regs);
-		if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
-			regmap_write(wcd9xxx_res->wcd_core_regmap,
-				wcd9xxx_res->intr_reg[WCD9XXX_INTR_CLR_COMMIT],
-				0x02);
-	}
-	wcd9xxx_unlock_sleep(wcd9xxx_res);
-
-	return IRQ_HANDLED;
-
-err_disable_irq:
-		dev_err(wcd9xxx_res->dev,
-				"Disable irq %d\n", wcd9xxx_res->irq);
-
-		disable_irq_wake(wcd9xxx_res->irq);
-		disable_irq_nosync(wcd9xxx_res->irq);
-		wcd9xxx_unlock_sleep(wcd9xxx_res);
-		return IRQ_NONE;
-}
-
-/**
- * wcd9xxx_free_irq
- *
- * @wcd9xxx_res: pointer to core resource
- * irq: irq number
- * @data: data pointer
- *
- */
-void wcd9xxx_free_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
-			int irq, void *data)
-{
-	free_irq(phyirq_to_virq(wcd9xxx_res, irq), data);
-}
-EXPORT_SYMBOL(wcd9xxx_free_irq);
-
-/**
- * wcd9xxx_enable_irq
- *
- * @wcd9xxx_res: pointer to core resource
- * irq: irq number
- *
- */
-void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
-{
-	if (wcd9xxx_res->irq)
-		enable_irq(phyirq_to_virq(wcd9xxx_res, irq));
-}
-EXPORT_SYMBOL(wcd9xxx_enable_irq);
-
-/**
- * wcd9xxx_disable_irq
- *
- * @wcd9xxx_res: pointer to core resource
- * irq: irq number
- *
- */
-void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
-{
-	if (wcd9xxx_res->irq)
-		disable_irq_nosync(phyirq_to_virq(wcd9xxx_res, irq));
-}
-EXPORT_SYMBOL(wcd9xxx_disable_irq);
-
-/**
- * wcd9xxx_disable_irq_sync
- *
- * @wcd9xxx_res: pointer to core resource
- * irq: irq number
- *
- */
-void wcd9xxx_disable_irq_sync(
-			struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
-{
-	if (wcd9xxx_res->irq)
-		disable_irq(phyirq_to_virq(wcd9xxx_res, irq));
-}
-EXPORT_SYMBOL(wcd9xxx_disable_irq_sync);
-
-static int wcd9xxx_irq_setup_downstream_irq(
-			struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	int irq, virq, ret;
-
-	pr_debug("%s: enter\n", __func__);
-
-	for (irq = 0; irq < wcd9xxx_res->num_irqs; irq++) {
-		/* Map OF irq */
-		virq = wcd9xxx_map_irq(wcd9xxx_res, irq);
-		pr_debug("%s: irq %d -> %d\n", __func__, irq, virq);
-		if (virq == NO_IRQ) {
-			pr_err("%s, No interrupt specifier for irq %d\n",
-			       __func__, irq);
-			return NO_IRQ;
-		}
-
-		ret = irq_set_chip_data(virq, wcd9xxx_res);
-		if (ret) {
-			pr_err("%s: Failed to configure irq %d (%d)\n",
-			       __func__, irq, ret);
-			return ret;
-		}
-
-		if (wcd9xxx_res->irq_level_high[irq])
-			irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip,
-						 handle_level_irq);
-		else
-			irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip,
-						 handle_edge_irq);
-
-		irq_set_nested_thread(virq, 1);
-	}
-
-	pr_debug("%s: leave\n", __func__);
-
-	return 0;
-}
-
-/**
- * wcd9xxx_irq_init
- *
- * @wcd9xxx_res: pointer to core resource
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int wcd9xxx_irq_init(struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	int i, ret;
-	u8 irq_level[wcd9xxx_res->num_irq_regs];
-	struct irq_domain *domain;
-	struct device_node *pnode;
-
-	mutex_init(&wcd9xxx_res->irq_lock);
-	mutex_init(&wcd9xxx_res->nested_irq_lock);
-
-	pnode = of_irq_find_parent(wcd9xxx_res->dev->of_node);
-	if (unlikely(!pnode))
-		return -EINVAL;
-
-	domain = irq_find_host(pnode);
-	if (unlikely(!domain))
-		return -EINVAL;
-
-	wcd9xxx_res->domain = domain;
-
-	wcd9xxx_res->irq = wcd9xxx_irq_get_upstream_irq(wcd9xxx_res);
-	if (!wcd9xxx_res->irq) {
-		pr_warn("%s: irq driver is not yet initialized\n", __func__);
-		mutex_destroy(&wcd9xxx_res->irq_lock);
-		mutex_destroy(&wcd9xxx_res->nested_irq_lock);
-		return -EPROBE_DEFER;
-	}
-	pr_debug("%s: probed irq %d\n", __func__, wcd9xxx_res->irq);
-
-	/* Setup downstream IRQs */
-	ret = wcd9xxx_irq_setup_downstream_irq(wcd9xxx_res);
-	if (ret) {
-		pr_err("%s: Failed to setup downstream IRQ\n", __func__);
-		wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
-		mutex_destroy(&wcd9xxx_res->irq_lock);
-		mutex_destroy(&wcd9xxx_res->nested_irq_lock);
-		return ret;
-	}
-
-	/* All other wcd9xxx interrupts are edge triggered */
-	wcd9xxx_res->irq_level_high[0] = true;
-
-	/* mask all the interrupts */
-	memset(irq_level, 0, wcd9xxx_res->num_irq_regs);
-	for (i = 0; i < wcd9xxx_res->num_irqs; i++) {
-		wcd9xxx_res->irq_masks_cur[BIT_BYTE(i)] |= BYTE_BIT_MASK(i);
-		wcd9xxx_res->irq_masks_cache[BIT_BYTE(i)] |= BYTE_BIT_MASK(i);
-		irq_level[BIT_BYTE(i)] |=
-		    wcd9xxx_res->irq_level_high[i] << (i % BITS_PER_BYTE);
-	}
-
-	if (!wcd9xxx_res->wcd_core_regmap) {
-		dev_err(wcd9xxx_res->dev,
-			"%s: Codec core regmap not defined\n",
-			   __func__);
-		ret = -EINVAL;
-		goto fail_irq_init;
-	}
-
-	for (i = 0; i < wcd9xxx_res->num_irq_regs; i++) {
-		/* Initialize interrupt mask and level registers */
-		regmap_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_LEVEL_BASE] + i,
-					irq_level[i]);
-		regmap_write(wcd9xxx_res->wcd_core_regmap,
-			wcd9xxx_res->intr_reg[WCD9XXX_INTR_MASK_BASE] + i,
-			wcd9xxx_res->irq_masks_cur[i]);
-	}
-
-	ret = request_threaded_irq(wcd9xxx_res->irq, NULL, wcd9xxx_irq_thread,
-				   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-				   "wcd9xxx", wcd9xxx_res);
-	if (ret != 0)
-		dev_err(wcd9xxx_res->dev, "Failed to request IRQ %d: %d\n",
-			wcd9xxx_res->irq, ret);
-	else {
-		ret = enable_irq_wake(wcd9xxx_res->irq);
-		if (ret)
-			dev_err(wcd9xxx_res->dev,
-				"Failed to set wake interrupt on IRQ %d: %d\n",
-				wcd9xxx_res->irq, ret);
-		if (ret)
-			free_irq(wcd9xxx_res->irq, wcd9xxx_res);
-	}
-
-	if (ret)
-		goto fail_irq_init;
-
-	return ret;
-
-fail_irq_init:
-	dev_err(wcd9xxx_res->dev,
-			"%s: Failed to init wcd9xxx irq\n", __func__);
-	wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
-	mutex_destroy(&wcd9xxx_res->irq_lock);
-	mutex_destroy(&wcd9xxx_res->nested_irq_lock);
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_irq_init);
-
-int wcd9xxx_request_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
-			int irq, irq_handler_t handler,
-			const char *name, void *data)
-{
-	int virq;
-
-	virq = phyirq_to_virq(wcd9xxx_res, irq);
-
-	return request_threaded_irq(virq, NULL, handler, IRQF_TRIGGER_RISING,
-				    name, data);
-}
-EXPORT_SYMBOL(wcd9xxx_request_irq);
-
-void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	dev_dbg(wcd9xxx_res->dev, "%s: Cleaning up irq %d\n", __func__,
-		wcd9xxx_res->irq);
-
-	if (wcd9xxx_res->irq) {
-		disable_irq_wake(wcd9xxx_res->irq);
-		free_irq(wcd9xxx_res->irq, wcd9xxx_res);
-		wcd9xxx_res->irq = 0;
-		wcd9xxx_irq_put_downstream_irq(wcd9xxx_res);
-		wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
-	}
-	mutex_destroy(&wcd9xxx_res->irq_lock);
-	mutex_destroy(&wcd9xxx_res->nested_irq_lock);
-}
-
-#ifndef CONFIG_OF
-static int phyirq_to_virq(
-	struct wcd9xxx_core_resource *wcd9xxx_res,
-	int offset)
-{
-	return wcd9xxx_res->irq_base + offset;
-}
-
-static int virq_to_phyirq(
-	struct wcd9xxx_core_resource *wcd9xxx_res,
-	int virq)
-{
-	return virq - wcd9xxx_res->irq_base;
-}
-
-static unsigned int wcd9xxx_irq_get_upstream_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	return wcd9xxx_res->irq;
-}
-
-static void wcd9xxx_irq_put_upstream_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	/* Do nothing */
-}
-
-static int wcd9xxx_map_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res, int irq)
-{
-	return phyirq_to_virq(wcd9xxx_core_res, irq);
-}
-#else
-static struct wcd9xxx_irq_drv_data *
-wcd9xxx_irq_add_domain(struct device_node *node,
-			       struct device_node *parent)
-{
-	struct wcd9xxx_irq_drv_data *data = NULL;
-
-	pr_debug("%s: node %s, node parent %s\n", __func__,
-		 node->name, node->parent->name);
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return NULL;
-
-	/*
-	 * wcd9xxx_intc interrupt controller supports N to N irq mapping with
-	 * single cell binding with irq numbers(offsets) only.
-	 * Use irq_domain_simple_ops that has irq_domain_simple_map and
-	 * irq_domain_xlate_onetwocell.
-	 */
-	data->domain = irq_domain_add_linear(node, WCD9XXX_MAX_NUM_IRQS,
-					     &irq_domain_simple_ops, data);
-	if (!data->domain) {
-		kfree(data);
-		return NULL;
-	}
-
-	return data;
-}
-
-static struct wcd9xxx_irq_drv_data *
-wcd9xxx_get_irq_drv_d(const struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	struct irq_domain *domain;
-
-	domain = wcd9xxx_res->domain;
-
-	if (domain)
-		return domain->host_data;
-	else
-		return NULL;
-}
-
-static int phyirq_to_virq(struct wcd9xxx_core_resource *wcd9xxx_res, int offset)
-{
-	struct wcd9xxx_irq_drv_data *data;
-
-	data = wcd9xxx_get_irq_drv_d(wcd9xxx_res);
-	if (!data) {
-		pr_warn("%s: not registered to interrupt controller\n",
-			__func__);
-		return -EINVAL;
-	}
-	return irq_linear_revmap(data->domain, offset);
-}
-
-static int virq_to_phyirq(struct wcd9xxx_core_resource *wcd9xxx_res, int virq)
-{
-	struct irq_data *irq_data = irq_get_irq_data(virq);
-
-	if (unlikely(!irq_data)) {
-		pr_err("%s: irq_data is NULL", __func__);
-		return -EINVAL;
-	}
-	return irq_data->hwirq;
-}
-
-static unsigned int wcd9xxx_irq_get_upstream_irq(
-				struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	struct wcd9xxx_irq_drv_data *data;
-
-	data = wcd9xxx_get_irq_drv_d(wcd9xxx_res);
-	if (!data) {
-		pr_err("%s: interrupt controller is not registered\n",
-			__func__);
-		return 0;
-	}
-
-	/* Make sure data is updated before return. */
-	rmb();
-	return data->irq;
-}
-
-static void wcd9xxx_irq_put_downstream_irq(
-			struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	int irq, virq, ret;
-
-	/*
-	 * IRQ migration hits error if the chip data and handles
-	 * are not made NULL. make associated data and handles
-	 * to NULL at irq_exit
-	 */
-	for (irq = 0; irq < wcd9xxx_res->num_irqs; irq++) {
-		virq = wcd9xxx_map_irq(wcd9xxx_res, irq);
-		pr_debug("%s: irq %d -> %d\n", __func__, irq, virq);
-		ret = irq_set_chip_data(virq, NULL);
-		if (ret) {
-			pr_err("%s: Failed to configure irq %d (%d)\n",
-				__func__, irq, ret);
-			return;
-		}
-		irq_set_chip_and_handler(virq, NULL, NULL);
-	}
-}
-
-static void wcd9xxx_irq_put_upstream_irq(
-			struct wcd9xxx_core_resource *wcd9xxx_res)
-{
-	wcd9xxx_res->domain = NULL;
-}
-
-static int wcd9xxx_map_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
-{
-	return of_irq_to_resource(wcd9xxx_res->dev->of_node, irq, NULL);
-}
-
-static int wcd9xxx_irq_probe(struct platform_device *pdev)
-{
-	int irq, dir_apps_irq = -EINVAL;
-	struct wcd9xxx_irq_drv_data *data;
-	struct device_node *node = pdev->dev.of_node;
-	int ret = -EINVAL;
-
-	irq = of_get_named_gpio(node, "qcom,gpio-connect", 0);
-	if (!gpio_is_valid(irq))
-		dir_apps_irq = platform_get_irq_byname(pdev, "wcd_irq");
-
-	if (!gpio_is_valid(irq) && dir_apps_irq < 0) {
-		dev_err(&pdev->dev, "TLMM connect gpio not found\n");
-		return -EPROBE_DEFER;
-	}
-	if (dir_apps_irq > 0) {
-		irq = dir_apps_irq;
-	} else {
-		irq = gpio_to_irq(irq);
-		if (irq < 0) {
-			dev_err(&pdev->dev, "Unable to configure irq\n");
-			return irq;
-		}
-	}
-	dev_dbg(&pdev->dev, "%s: virq = %d\n", __func__, irq);
-	data = wcd9xxx_irq_add_domain(node, node->parent);
-	if (!data) {
-		pr_err("%s: irq_add_domain failed\n", __func__);
-		return -EINVAL;
-	}
-	data->irq = irq;
-
-	/* Make sure irq is saved before return. */
-	wmb();
-	ret = 0;
-
-	return ret;
-}
-
-static int wcd9xxx_irq_remove(struct platform_device *pdev)
-{
-	struct irq_domain *domain;
-	struct wcd9xxx_irq_drv_data *data;
-
-	domain = irq_find_host(pdev->dev.of_node);
-	if (unlikely(!domain)) {
-		pr_err("%s: domain is NULL", __func__);
-		return -EINVAL;
-	}
-	data = (struct wcd9xxx_irq_drv_data *)domain->host_data;
-	data->irq = 0;
-
-	/* Make sure irq variable is updated in data, before irq removal. */
-	wmb();
-	irq_domain_remove(data->domain);
-	kfree(data);
-
-	return 0;
-}
-
-static const struct of_device_id of_match[] = {
-	{ .compatible = "qcom,wcd9xxx-irq" },
-	{ }
-};
-
-static struct platform_driver wcd9xxx_irq_driver = {
-	.probe = wcd9xxx_irq_probe,
-	.remove = wcd9xxx_irq_remove,
-	.driver = {
-		.name = "wcd9xxx_intc",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(of_match),
-	},
-};
-
-int wcd9xxx_irq_drv_init(void)
-{
-	return platform_driver_register(&wcd9xxx_irq_driver);
-}
-
-void wcd9xxx_irq_drv_exit(void)
-{
-	platform_driver_unregister(&wcd9xxx_irq_driver);
-}
-#endif /* CONFIG_OF */
diff --git a/drivers/mfd/wcd9xxx-regmap.h b/drivers/mfd/wcd9xxx-regmap.h
deleted file mode 100644
index f44e8b1..0000000
--- a/drivers/mfd/wcd9xxx-regmap.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _WCD9XXX_REGMAP_
-#define _WCD9XXX_REGMAP_
-
-#include <linux/regmap.h>
-#include <linux/mfd/wcd9xxx/core.h>
-
-typedef int (*regmap_patch_fptr)(struct regmap *, int);
-
-extern struct regmap_config wcd934x_regmap_config;
-extern int wcd934x_regmap_register_patch(struct regmap *regmap,
-					 int version);
-
-extern struct regmap_config wcd9335_regmap_config;
-extern int wcd9335_regmap_register_patch(struct regmap *regmap,
-					 int version);
-
-static inline struct regmap_config *wcd9xxx_get_regmap_config(int type)
-{
-	struct regmap_config *regmap_config;
-
-	switch (type) {
-	case WCD934X:
-		regmap_config = &wcd934x_regmap_config;
-		break;
-	case WCD9335:
-		regmap_config = &wcd9335_regmap_config;
-		break;
-	default:
-		regmap_config = NULL;
-		break;
-	};
-
-	return regmap_config;
-}
-
-static inline regmap_patch_fptr wcd9xxx_get_regmap_reg_patch(int type)
-{
-	regmap_patch_fptr apply_patch;
-
-	switch (type) {
-	case WCD9335:
-		apply_patch = wcd9335_regmap_register_patch;
-		break;
-	case WCD934X:
-		apply_patch = wcd934x_regmap_register_patch;
-		break;
-	default:
-		apply_patch = NULL;
-		break;
-	}
-
-	return apply_patch;
-}
-
-#endif
diff --git a/drivers/mfd/wcd9xxx-rst.c b/drivers/mfd/wcd9xxx-rst.c
deleted file mode 100644
index c8e0b34..0000000
--- a/drivers/mfd/wcd9xxx-rst.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/regmap.h>
-#include <linux/delay.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-utils.h>
-#include <linux/mfd/wcd9335/registers.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <linux/mfd/wcd9335/irq.h>
-#include <linux/mfd/wcd934x/irq.h>
-
-/* wcd9335 interrupt table  */
-static const struct intr_data wcd9335_intr_table[] = {
-	{WCD9XXX_IRQ_SLIMBUS, false},
-	{WCD9335_IRQ_MBHC_SW_DET, true},
-	{WCD9335_IRQ_MBHC_BUTTON_PRESS_DET, true},
-	{WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET, true},
-	{WCD9335_IRQ_MBHC_ELECT_INS_REM_DET, true},
-	{WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET, true},
-	{WCD9335_IRQ_FLL_LOCK_LOSS, false},
-	{WCD9335_IRQ_HPH_PA_CNPL_COMPLETE, false},
-	{WCD9335_IRQ_HPH_PA_CNPR_COMPLETE, false},
-	{WCD9335_IRQ_EAR_PA_CNP_COMPLETE, false},
-	{WCD9335_IRQ_LINE_PA1_CNP_COMPLETE, false},
-	{WCD9335_IRQ_LINE_PA2_CNP_COMPLETE, false},
-	{WCD9335_IRQ_LINE_PA3_CNP_COMPLETE, false},
-	{WCD9335_IRQ_LINE_PA4_CNP_COMPLETE, false},
-	{WCD9335_IRQ_HPH_PA_OCPL_FAULT, false},
-	{WCD9335_IRQ_HPH_PA_OCPR_FAULT, false},
-	{WCD9335_IRQ_EAR_PA_OCP_FAULT, false},
-	{WCD9335_IRQ_SOUNDWIRE, false},
-	{WCD9335_IRQ_VDD_DIG_RAMP_COMPLETE, false},
-	{WCD9335_IRQ_RCO_ERROR, false},
-	{WCD9335_IRQ_SVA_ERROR, false},
-	{WCD9335_IRQ_MAD_AUDIO, false},
-	{WCD9335_IRQ_MAD_BEACON, false},
-	{WCD9335_IRQ_SVA_OUTBOX1, true},
-	{WCD9335_IRQ_SVA_OUTBOX2, true},
-	{WCD9335_IRQ_MAD_ULTRASOUND, false},
-	{WCD9335_IRQ_VBAT_ATTACK, false},
-	{WCD9335_IRQ_VBAT_RESTORE, false},
-};
-
-static const struct intr_data wcd934x_intr_table[] = {
-	{WCD9XXX_IRQ_SLIMBUS, false},
-	{WCD934X_IRQ_MBHC_SW_DET, true},
-	{WCD934X_IRQ_MBHC_BUTTON_PRESS_DET, true},
-	{WCD934X_IRQ_MBHC_BUTTON_RELEASE_DET, true},
-	{WCD934X_IRQ_MBHC_ELECT_INS_REM_DET, true},
-	{WCD934X_IRQ_MBHC_ELECT_INS_REM_LEG_DET, true},
-	{WCD934X_IRQ_MISC, false},
-	{WCD934X_IRQ_HPH_PA_CNPL_COMPLETE, false},
-	{WCD934X_IRQ_HPH_PA_CNPR_COMPLETE, false},
-	{WCD934X_IRQ_EAR_PA_CNP_COMPLETE, false},
-	{WCD934X_IRQ_LINE_PA1_CNP_COMPLETE, false},
-	{WCD934X_IRQ_LINE_PA2_CNP_COMPLETE, false},
-	{WCD934X_IRQ_SLNQ_ANALOG_ERROR, false},
-	{WCD934X_IRQ_RESERVED_3, false},
-	{WCD934X_IRQ_HPH_PA_OCPL_FAULT, false},
-	{WCD934X_IRQ_HPH_PA_OCPR_FAULT, false},
-	{WCD934X_IRQ_EAR_PA_OCP_FAULT, false},
-	{WCD934X_IRQ_SOUNDWIRE, false},
-	{WCD934X_IRQ_VDD_DIG_RAMP_COMPLETE, false},
-	{WCD934X_IRQ_RCO_ERROR, false},
-	{WCD934X_IRQ_CPE_ERROR, false},
-	{WCD934X_IRQ_MAD_AUDIO, false},
-	{WCD934X_IRQ_MAD_BEACON, false},
-	{WCD934X_IRQ_CPE1_INTR, true},
-	{WCD934X_IRQ_RESERVED_4, false},
-	{WCD934X_IRQ_MAD_ULTRASOUND, false},
-	{WCD934X_IRQ_VBAT_ATTACK, false},
-	{WCD934X_IRQ_VBAT_RESTORE, false},
-};
-
-/*
- * wcd9335_bring_down: Bringdown WCD Codec
- *
- * @wcd9xxx: Pointer to wcd9xxx structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd9335_bring_down(struct wcd9xxx *wcd9xxx)
-{
-	if (!wcd9xxx || !wcd9xxx->regmap)
-		return -EINVAL;
-
-	regmap_write(wcd9xxx->regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-		     0x04);
-
-	return 0;
-}
-
-/*
- * wcd9335_bring_up: Bringup WCD Codec
- *
- * @wcd9xxx: Pointer to the wcd9xxx structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd9335_bring_up(struct wcd9xxx *wcd9xxx)
-{
-	int ret = 0;
-	int val, byte0;
-	struct regmap *wcd_regmap;
-
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	if (!wcd9xxx->regmap) {
-		dev_err(wcd9xxx->dev, "%s: wcd9xxx regmap is null!\n",
-			__func__);
-		return -EINVAL;
-	}
-	wcd_regmap = wcd9xxx->regmap;
-
-	regmap_read(wcd_regmap, WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0, &val);
-	regmap_read(wcd_regmap, WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0, &byte0);
-
-	if ((val < 0) || (byte0 < 0)) {
-		dev_err(wcd9xxx->dev, "%s: tasha codec version detection fail!\n",
-			__func__);
-		return -EINVAL;
-	}
-	if ((val & 0x80) && (byte0 == 0x0)) {
-		dev_info(wcd9xxx->dev, "%s: wcd9335 codec version is v1.1\n",
-			 __func__);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x01);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_CCL_2, 0xFC);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_CCL_4, 0x21);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x5);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x7);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x3);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x3);
-	} else if (byte0 == 0x1) {
-		dev_info(wcd9xxx->dev, "%s: wcd9335 codec version is v2.0\n",
-			 __func__);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x01);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_TEST_2, 0x00);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_CCL_8, 0x6F);
-		regmap_write(wcd_regmap, WCD9335_BIAS_VBG_FINE_ADJ, 0x65);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x5);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x7);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x3);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x3);
-	} else if ((byte0 == 0) && (!(val & 0x80))) {
-		dev_info(wcd9xxx->dev, "%s: wcd9335 codec version is v1.0\n",
-			 __func__);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x01);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_CCL_2, 0xFC);
-		regmap_write(wcd_regmap, WCD9335_SIDO_SIDO_CCL_4, 0x21);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			     0x3);
-		regmap_write(wcd_regmap, WCD9335_CODEC_RPM_RST_CTL, 0x3);
-	} else {
-		dev_err(wcd9xxx->dev, "%s: tasha codec version unknown\n",
-			__func__);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-/*
- * wcd9335_get_cdc_info: Get codec specific information
- *
- * @wcd9xxx: pointer to wcd9xxx structure
- * @wcd_type: pointer to wcd9xxx_codec_type structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd9335_get_cdc_info(struct wcd9xxx *wcd9xxx,
-			   struct wcd9xxx_codec_type *wcd_type)
-{
-	u16 id_minor, id_major;
-	struct regmap *wcd_regmap;
-	int rc, val, version = 0;
-
-	if (!wcd9xxx || !wcd_type)
-		return -EINVAL;
-
-	if (!wcd9xxx->regmap) {
-		dev_err(wcd9xxx->dev, "%s: wcd9xxx regmap is null!\n",
-			__func__);
-		return -EINVAL;
-	}
-	wcd_regmap = wcd9xxx->regmap;
-
-	rc = regmap_bulk_read(wcd_regmap, WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0,
-			(u8 *)&id_minor, sizeof(u16));
-	if (rc)
-		return -EINVAL;
-
-	rc = regmap_bulk_read(wcd_regmap, WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE2,
-			      (u8 *)&id_major, sizeof(u16));
-	if (rc)
-		return -EINVAL;
-
-	dev_info(wcd9xxx->dev, "%s: wcd9xxx chip id major 0x%x, minor 0x%x\n",
-		 __func__, id_major, id_minor);
-
-	/* Version detection */
-	if (id_major == TASHA_MAJOR) {
-		regmap_read(wcd_regmap, WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0,
-			    &val);
-		version = ((u8)val & 0x80) >> 7;
-	} else if (id_major == TASHA2P0_MAJOR)
-		version = 2;
-	else
-		dev_err(wcd9xxx->dev, "%s: wcd9335 version unknown (major 0x%x, minor 0x%x)\n",
-			__func__, id_major, id_minor);
-
-	/* Fill codec type info */
-	wcd_type->id_major = id_major;
-	wcd_type->id_minor = id_minor;
-	wcd_type->num_irqs = WCD9335_NUM_IRQS;
-	wcd_type->version = version;
-	wcd_type->slim_slave_type = WCD9XXX_SLIM_SLAVE_ADDR_TYPE_1;
-	wcd_type->i2c_chip_status = 0x01;
-	wcd_type->intr_tbl = wcd9335_intr_table;
-	wcd_type->intr_tbl_size = ARRAY_SIZE(wcd9335_intr_table);
-
-	wcd_type->intr_reg[WCD9XXX_INTR_STATUS_BASE] =
-						WCD9335_INTR_PIN1_STATUS0;
-	wcd_type->intr_reg[WCD9XXX_INTR_CLEAR_BASE] =
-						WCD9335_INTR_PIN1_CLEAR0;
-	wcd_type->intr_reg[WCD9XXX_INTR_MASK_BASE] =
-						WCD9335_INTR_PIN1_MASK0;
-	wcd_type->intr_reg[WCD9XXX_INTR_LEVEL_BASE] =
-						WCD9335_INTR_LEVEL0;
-	wcd_type->intr_reg[WCD9XXX_INTR_CLR_COMMIT] =
-						WCD9335_INTR_CLR_COMMIT;
-
-	return rc;
-}
-
-/*
- * wcd934x_bring_down: Bringdown WCD Codec
- *
- * @wcd9xxx: Pointer to wcd9xxx structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd934x_bring_down(struct wcd9xxx *wcd9xxx)
-{
-	if (!wcd9xxx || !wcd9xxx->regmap)
-		return -EINVAL;
-
-	regmap_write(wcd9xxx->regmap, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-		     0x04);
-
-	return 0;
-}
-
-/*
- * wcd934x_bring_up: Bringup WCD Codec
- *
- * @wcd9xxx: Pointer to the wcd9xxx structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd934x_bring_up(struct wcd9xxx *wcd9xxx)
-{
-	struct regmap *wcd_regmap;
-
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	if (!wcd9xxx->regmap) {
-		dev_err(wcd9xxx->dev, "%s: wcd9xxx regmap is null!\n",
-			__func__);
-		return -EINVAL;
-	}
-	wcd_regmap = wcd9xxx->regmap;
-
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_RST_CTL, 0x01);
-	regmap_write(wcd_regmap, WCD934X_SIDO_NEW_VOUT_A_STARTUP, 0x19);
-	regmap_write(wcd_regmap, WCD934X_SIDO_NEW_VOUT_D_STARTUP, 0x15);
-	/* Add 1msec delay for VOUT to settle */
-	usleep_range(1000, 1100);
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_RST_CTL, 0x3);
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_RST_CTL, 0x7);
-	regmap_write(wcd_regmap, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
-
-	return 0;
-}
-
-/*
- * wcd934x_get_cdc_info: Get codec specific information
- *
- * @wcd9xxx: pointer to wcd9xxx structure
- * @wcd_type: pointer to wcd9xxx_codec_type structure
- *
- * Returns 0 for success or negative error code for failure
- */
-static int wcd934x_get_cdc_info(struct wcd9xxx *wcd9xxx,
-			   struct wcd9xxx_codec_type *wcd_type)
-{
-	u16 id_minor, id_major;
-	struct regmap *wcd_regmap;
-	int rc, version = -1;
-
-	if (!wcd9xxx || !wcd_type)
-		return -EINVAL;
-
-	if (!wcd9xxx->regmap) {
-		dev_err(wcd9xxx->dev, "%s: wcd9xxx regmap is null\n", __func__);
-		return -EINVAL;
-	}
-	wcd_regmap = wcd9xxx->regmap;
-
-	rc = regmap_bulk_read(wcd_regmap, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0,
-			      (u8 *)&id_minor, sizeof(u16));
-	if (rc)
-		return -EINVAL;
-
-	rc = regmap_bulk_read(wcd_regmap, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE2,
-			      (u8 *)&id_major, sizeof(u16));
-	if (rc)
-		return -EINVAL;
-
-	dev_info(wcd9xxx->dev, "%s: wcd9xxx chip id major 0x%x, minor 0x%x\n",
-		 __func__, id_major, id_minor);
-
-	if (id_major != TAVIL_MAJOR)
-		goto version_unknown;
-
-	/*
-	 * As fine version info cannot be retrieved before tavil probe.
-	 * Assign coarse versions for possible future use before tavil probe.
-	 */
-	if (id_minor == cpu_to_le16(0))
-		version = TAVIL_VERSION_1_0;
-	else if (id_minor == cpu_to_le16(0x01))
-		version = TAVIL_VERSION_1_1;
-
-version_unknown:
-	if (version < 0)
-		dev_err(wcd9xxx->dev, "%s: wcd934x version unknown\n",
-			__func__);
-
-	/* Fill codec type info */
-	wcd_type->id_major = id_major;
-	wcd_type->id_minor = id_minor;
-	wcd_type->num_irqs = WCD934X_NUM_IRQS;
-	wcd_type->version = version;
-	wcd_type->slim_slave_type = WCD9XXX_SLIM_SLAVE_ADDR_TYPE_1;
-	wcd_type->i2c_chip_status = 0x01;
-	wcd_type->intr_tbl = wcd934x_intr_table;
-	wcd_type->intr_tbl_size = ARRAY_SIZE(wcd934x_intr_table);
-
-	wcd_type->intr_reg[WCD9XXX_INTR_STATUS_BASE] =
-						WCD934X_INTR_PIN1_STATUS0;
-	wcd_type->intr_reg[WCD9XXX_INTR_CLEAR_BASE] =
-						WCD934X_INTR_PIN1_CLEAR0;
-	wcd_type->intr_reg[WCD9XXX_INTR_MASK_BASE] =
-						WCD934X_INTR_PIN1_MASK0;
-	wcd_type->intr_reg[WCD9XXX_INTR_LEVEL_BASE] =
-						WCD934X_INTR_LEVEL0;
-	wcd_type->intr_reg[WCD9XXX_INTR_CLR_COMMIT] =
-						WCD934X_INTR_CLR_COMMIT;
-
-	return rc;
-}
-
-codec_bringdown_fn wcd9xxx_bringdown_fn(int type)
-{
-	codec_bringdown_fn cdc_bdown_fn;
-
-	switch (type) {
-	case WCD934X:
-		cdc_bdown_fn = wcd934x_bring_down;
-		break;
-	case WCD9335:
-		cdc_bdown_fn = wcd9335_bring_down;
-		break;
-	default:
-		cdc_bdown_fn = NULL;
-		break;
-	}
-
-	return cdc_bdown_fn;
-}
-
-codec_bringup_fn wcd9xxx_bringup_fn(int type)
-{
-	codec_bringup_fn cdc_bup_fn;
-
-	switch (type) {
-	case WCD934X:
-		cdc_bup_fn = wcd934x_bring_up;
-		break;
-	case WCD9335:
-		cdc_bup_fn = wcd9335_bring_up;
-		break;
-	default:
-		cdc_bup_fn = NULL;
-		break;
-	}
-
-	return cdc_bup_fn;
-}
-
-codec_type_fn wcd9xxx_get_codec_info_fn(int type)
-{
-	codec_type_fn cdc_type_fn;
-
-	switch (type) {
-	case WCD934X:
-		cdc_type_fn = wcd934x_get_cdc_info;
-		break;
-	case WCD9335:
-		cdc_type_fn = wcd9335_get_cdc_info;
-		break;
-	default:
-		cdc_type_fn = NULL;
-		break;
-	}
-
-	return cdc_type_fn;
-}
-
diff --git a/drivers/mfd/wcd9xxx-slimslave.c b/drivers/mfd/wcd9xxx-slimslave.c
deleted file mode 100644
index a99ad5a..0000000
--- a/drivers/mfd/wcd9xxx-slimslave.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/slab.h>
-#include <linux/mutex.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-
-struct wcd9xxx_slim_sch {
-	u16 rx_port_ch_reg_base;
-	u16 port_tx_cfg_reg_base;
-	u16 port_rx_cfg_reg_base;
-};
-
-static struct wcd9xxx_slim_sch sh_ch;
-
-static int wcd9xxx_alloc_slim_sh_ch(struct wcd9xxx *wcd9xxx,
-				    u8 wcd9xxx_pgd_la, u32 cnt,
-				    struct wcd9xxx_ch *channels, u32 path);
-
-static int wcd9xxx_dealloc_slim_sh_ch(struct slim_device *slim,
-				      u32 cnt, struct wcd9xxx_ch *channels);
-
-static int wcd9xxx_configure_ports(struct wcd9xxx *wcd9xxx)
-{
-	if (wcd9xxx->codec_type->slim_slave_type ==
-	    WCD9XXX_SLIM_SLAVE_ADDR_TYPE_0) {
-		sh_ch.rx_port_ch_reg_base = 0x180;
-		sh_ch.port_rx_cfg_reg_base = 0x040;
-		sh_ch.port_tx_cfg_reg_base = 0x040;
-	} else {
-		sh_ch.rx_port_ch_reg_base =
-			0x180 - (TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS * 4);
-		sh_ch.port_rx_cfg_reg_base =
-			0x040 - TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS;
-		sh_ch.port_tx_cfg_reg_base = 0x050;
-	}
-
-	return 0;
-}
-
-/**
- * wcd9xxx_init_slimslave
- *
- * @wcd9xxx: pointer to wcd9xxx struct
- * @wcd9xxx_pgd_la: pgd_la value
- * @tx_num: tx number
- * @rx_num: rx number
- * @tx_slot: pointer to tx slot
- * @rx_slot: pointer to rx slot
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx, u8 wcd9xxx_pgd_la,
-			   unsigned int tx_num, unsigned int *tx_slot,
-			   unsigned int rx_num, unsigned int *rx_slot)
-{
-	int ret = 0;
-	int i;
-
-	ret = wcd9xxx_configure_ports(wcd9xxx);
-	if (ret) {
-		pr_err("%s: Failed to configure register address offset\n",
-		       __func__);
-		goto err;
-	}
-
-	if (!rx_num || rx_num > wcd9xxx->num_rx_port) {
-		pr_err("%s: invalid rx num %d\n", __func__, rx_num);
-		return -EINVAL;
-	}
-	if (wcd9xxx->rx_chs) {
-		wcd9xxx->num_rx_port = rx_num;
-		for (i = 0; i < rx_num; i++) {
-			wcd9xxx->rx_chs[i].ch_num = rx_slot[i];
-			INIT_LIST_HEAD(&wcd9xxx->rx_chs[i].list);
-		}
-		ret = wcd9xxx_alloc_slim_sh_ch(wcd9xxx, wcd9xxx_pgd_la,
-						wcd9xxx->num_rx_port,
-						wcd9xxx->rx_chs,
-						SLIM_SINK);
-		if (ret) {
-			pr_err("%s: Failed to alloc %d rx slimbus channels\n",
-				__func__, wcd9xxx->num_rx_port);
-			kfree(wcd9xxx->rx_chs);
-			wcd9xxx->rx_chs = NULL;
-			wcd9xxx->num_rx_port = 0;
-		}
-	} else {
-		pr_err("Not able to allocate memory for %d slimbus rx ports\n",
-			wcd9xxx->num_rx_port);
-	}
-
-	if (!tx_num || tx_num > wcd9xxx->num_tx_port) {
-		pr_err("%s: invalid tx num %d\n", __func__, tx_num);
-		return -EINVAL;
-	}
-	if (wcd9xxx->tx_chs) {
-		wcd9xxx->num_tx_port = tx_num;
-		for (i = 0; i < tx_num; i++) {
-			wcd9xxx->tx_chs[i].ch_num = tx_slot[i];
-			INIT_LIST_HEAD(&wcd9xxx->tx_chs[i].list);
-		}
-		ret = wcd9xxx_alloc_slim_sh_ch(wcd9xxx, wcd9xxx_pgd_la,
-						wcd9xxx->num_tx_port,
-						wcd9xxx->tx_chs,
-						SLIM_SRC);
-		if (ret) {
-			pr_err("%s: Failed to alloc %d tx slimbus channels\n",
-				__func__, wcd9xxx->num_tx_port);
-			kfree(wcd9xxx->tx_chs);
-			wcd9xxx->tx_chs = NULL;
-			wcd9xxx->num_tx_port = 0;
-		}
-	} else {
-		pr_err("Not able to allocate memory for %d slimbus tx ports\n",
-			wcd9xxx->num_tx_port);
-	}
-	return 0;
-err:
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_init_slimslave);
-
-int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx)
-{
-	if (wcd9xxx->num_rx_port) {
-		wcd9xxx_dealloc_slim_sh_ch(wcd9xxx->slim,
-					wcd9xxx->num_rx_port,
-					wcd9xxx->rx_chs);
-		wcd9xxx->num_rx_port = 0;
-	}
-	if (wcd9xxx->num_tx_port) {
-		wcd9xxx_dealloc_slim_sh_ch(wcd9xxx->slim,
-					wcd9xxx->num_tx_port,
-					wcd9xxx->tx_chs);
-		wcd9xxx->num_tx_port = 0;
-	}
-	return 0;
-}
-
-
-static int wcd9xxx_alloc_slim_sh_ch(struct wcd9xxx *wcd9xxx,
-				    u8 wcd9xxx_pgd_la, u32 cnt,
-				    struct wcd9xxx_ch *channels, u32 path)
-{
-	int ret = 0;
-	u32 ch_idx;
-
-	/* The slimbus channel allocation seem take longer time
-	 * so do the allocation up front to avoid delay in start of
-	 * playback
-	 */
-	pr_debug("%s: pgd_la[%d]\n", __func__, wcd9xxx_pgd_la);
-	for (ch_idx = 0; ch_idx < cnt; ch_idx++) {
-		ret = slim_get_slaveport(wcd9xxx_pgd_la,
-					channels[ch_idx].port,
-					&channels[ch_idx].sph, path);
-		pr_debug("%s: pgd_la[%d] channels[%d].port[%d]\n"
-			"channels[%d].sph[%d] path[%d]\n",
-			__func__, wcd9xxx_pgd_la, ch_idx,
-			channels[ch_idx].port,
-			ch_idx, channels[ch_idx].sph, path);
-		if (ret < 0) {
-			pr_err("%s: slave port failure id[%d] ret[%d]\n",
-				__func__, channels[ch_idx].ch_num, ret);
-			goto err;
-		}
-
-		ret = slim_query_ch(wcd9xxx->slim,
-				    channels[ch_idx].ch_num,
-				    &channels[ch_idx].ch_h);
-		if (ret < 0) {
-			pr_err("%s: slim_query_ch failed ch-num[%d] ret[%d]\n",
-				__func__, channels[ch_idx].ch_num, ret);
-			goto err;
-		}
-	}
-err:
-	return ret;
-}
-
-static int wcd9xxx_dealloc_slim_sh_ch(struct slim_device *slim,
-			u32 cnt, struct wcd9xxx_ch *channels)
-{
-	int idx = 0;
-	int ret = 0;
-	/* slim_dealloc_ch */
-	for (idx = 0; idx < cnt; idx++) {
-		ret = slim_dealloc_ch(slim, channels[idx].ch_h);
-		if (ret < 0) {
-			pr_err("%s: slim_dealloc_ch fail ret[%d] ch_h[%d]\n",
-				__func__, ret, channels[idx].ch_h);
-		}
-	}
-	return ret;
-}
-
-/* Enable slimbus slave device for RX path */
-int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list,
-			    unsigned int rate, unsigned int bit_width,
-			    u16 *grph)
-{
-	u8 ch_cnt = 0;
-	u16 ch_h[SLIM_MAX_RX_PORTS] = {0};
-	u8  payload = 0;
-	u16 codec_port = 0;
-	int ret;
-	struct slim_ch prop;
-	struct wcd9xxx_ch *rx;
-	int size = ARRAY_SIZE(ch_h);
-
-	/* Configure slave interface device */
-
-	list_for_each_entry(rx, wcd9xxx_ch_list, list) {
-		payload |= 1 << rx->shift;
-		if (ch_cnt < size) {
-			ch_h[ch_cnt] = rx->ch_h;
-			ch_cnt++;
-			pr_debug("list ch->ch_h %d ch->sph %d\n",
-				 rx->ch_h, rx->sph);
-		} else {
-			pr_err("%s: allocated channel number %u is out of max rangae %d\n",
-			       __func__, ch_cnt,
-			       size);
-			ret = EINVAL;
-			goto err;
-		}
-	}
-	pr_debug("%s: ch_cnt[%d] rate=%d WATER_MARK_VAL %d\n",
-		 __func__, ch_cnt, rate, WATER_MARK_VAL);
-	/* slim_define_ch api */
-	prop.prot = SLIM_AUTO_ISO;
-	if ((rate == 44100) || (rate == 88200) || (rate == 176400) ||
-	    (rate == 352800)) {
-		prop.baser = SLIM_RATE_11025HZ;
-		prop.ratem = (rate/11025);
-	} else {
-		prop.baser = SLIM_RATE_4000HZ;
-		prop.ratem = (rate/4000);
-	}
-	prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
-	prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
-	prop.sampleszbits = bit_width;
-
-	pr_debug("Before slim_define_ch:\n"
-		 "ch_cnt %d,ch_h[0] %d ch_h[1] %d, grph %d\n",
-		 ch_cnt, ch_h[0], ch_h[1], *grph);
-	ret = slim_define_ch(wcd9xxx->slim, &prop, ch_h, ch_cnt,
-			     true, grph);
-	if (ret < 0) {
-		pr_err("%s: slim_define_ch failed ret[%d]\n",
-		       __func__, ret);
-		goto err;
-	}
-
-	list_for_each_entry(rx, wcd9xxx_ch_list, list) {
-		codec_port = rx->port;
-		pr_debug("%s: codec_port %d rx 0x%p, payload %d\n"
-			 "sh_ch.rx_port_ch_reg_base0 0x%x\n"
-			 "sh_ch.port_rx_cfg_reg_base 0x%x\n",
-			 __func__, codec_port, rx, payload,
-			 sh_ch.rx_port_ch_reg_base,
-			sh_ch.port_rx_cfg_reg_base);
-
-		/* look for the valid port range and chose the
-		 * payload accordingly
-		 */
-		/* write to interface device */
-		ret = wcd9xxx_interface_reg_write(wcd9xxx,
-				SB_PGD_RX_PORT_MULTI_CHANNEL_0(
-				sh_ch.rx_port_ch_reg_base, codec_port),
-				payload);
-
-		if (ret < 0) {
-			pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
-				__func__,
-				SB_PGD_RX_PORT_MULTI_CHANNEL_0(
-				sh_ch.rx_port_ch_reg_base, codec_port),
-				payload, ret);
-			goto err;
-		}
-		/* configure the slave port for water mark and enable*/
-		ret = wcd9xxx_interface_reg_write(wcd9xxx,
-				SB_PGD_PORT_CFG_BYTE_ADDR(
-				sh_ch.port_rx_cfg_reg_base, codec_port),
-				WATER_MARK_VAL);
-		if (ret < 0) {
-			pr_err("%s:watermark set failure for port[%d] ret[%d]",
-				__func__, codec_port, ret);
-		}
-
-		ret = slim_connect_sink(wcd9xxx->slim, &rx->sph, 1, rx->ch_h);
-		if (ret < 0) {
-			pr_err("%s: slim_connect_sink failed ret[%d]\n",
-				__func__, ret);
-			goto err_close_slim_sch;
-		}
-	}
-	/* slim_control_ch */
-	ret = slim_control_ch(wcd9xxx->slim, *grph, SLIM_CH_ACTIVATE,
-			      true);
-	if (ret < 0) {
-		pr_err("%s: slim_control_ch failed ret[%d]\n",
-			__func__, ret);
-		goto err_close_slim_sch;
-	}
-	return 0;
-
-err_close_slim_sch:
-	/*  release all acquired handles */
-	wcd9xxx_close_slim_sch_rx(wcd9xxx, wcd9xxx_ch_list, *grph);
-err:
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_cfg_slim_sch_rx);
-
-/* Enable slimbus slave device for RX path */
-int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list,
-			    unsigned int rate, unsigned int bit_width,
-			    u16 *grph)
-{
-	u16 ch_cnt = 0;
-	u16 payload = 0;
-	u16 ch_h[SLIM_MAX_TX_PORTS] = {0};
-	u16 codec_port;
-	int ret = 0;
-	struct wcd9xxx_ch *tx;
-	int size = ARRAY_SIZE(ch_h);
-
-	struct slim_ch prop;
-
-	list_for_each_entry(tx, wcd9xxx_ch_list, list) {
-		payload |= 1 << tx->shift;
-		if (ch_cnt < size) {
-			ch_h[ch_cnt] = tx->ch_h;
-			ch_cnt++;
-		} else {
-			pr_err("%s: allocated channel number %u is out of max rangae %d\n",
-			       __func__, ch_cnt,
-			       size);
-			ret = EINVAL;
-			goto err;
-		}
-	}
-
-	/* slim_define_ch api */
-	prop.prot = SLIM_AUTO_ISO;
-	prop.baser = SLIM_RATE_4000HZ;
-	prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
-	prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
-	prop.ratem = (rate/4000);
-	prop.sampleszbits = bit_width;
-	ret = slim_define_ch(wcd9xxx->slim, &prop, ch_h, ch_cnt,
-			     true, grph);
-	if (ret < 0) {
-		pr_err("%s: slim_define_ch failed ret[%d]\n",
-		       __func__, ret);
-		goto err;
-	}
-
-	pr_debug("%s: ch_cnt[%d] rate[%d] bitwidth[%u]\n", __func__, ch_cnt,
-		 rate, bit_width);
-	list_for_each_entry(tx, wcd9xxx_ch_list, list) {
-		codec_port = tx->port;
-		pr_debug("%s: codec_port %d tx 0x%p, payload 0x%x\n",
-			 __func__, codec_port, tx, payload);
-		/* write to interface device */
-		ret = wcd9xxx_interface_reg_write(wcd9xxx,
-				SB_PGD_TX_PORT_MULTI_CHANNEL_0(codec_port),
-				payload & 0x00FF);
-		if (ret < 0) {
-			pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
-				__func__,
-				SB_PGD_TX_PORT_MULTI_CHANNEL_0(codec_port),
-				payload, ret);
-			goto err;
-		}
-		/* ports 8,9 */
-		ret = wcd9xxx_interface_reg_write(wcd9xxx,
-				SB_PGD_TX_PORT_MULTI_CHANNEL_1(codec_port),
-				(payload & 0xFF00)>>8);
-		if (ret < 0) {
-			pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
-				__func__,
-				SB_PGD_TX_PORT_MULTI_CHANNEL_1(codec_port),
-				payload, ret);
-			goto err;
-		}
-		/* configure the slave port for water mark and enable*/
-		ret = wcd9xxx_interface_reg_write(wcd9xxx,
-				SB_PGD_PORT_CFG_BYTE_ADDR(
-				sh_ch.port_tx_cfg_reg_base, codec_port),
-				WATER_MARK_VAL);
-		if (ret < 0) {
-			pr_err("%s:watermark set failure for port[%d] ret[%d]",
-				__func__, codec_port, ret);
-		}
-
-		ret = slim_connect_src(wcd9xxx->slim, tx->sph, tx->ch_h);
-
-		if (ret < 0) {
-			pr_err("%s: slim_connect_src failed ret[%d]\n",
-			       __func__, ret);
-			goto err;
-		}
-	}
-	/* slim_control_ch */
-	ret = slim_control_ch(wcd9xxx->slim, *grph, SLIM_CH_ACTIVATE,
-			      true);
-	if (ret < 0) {
-		pr_err("%s: slim_control_ch failed ret[%d]\n",
-			__func__, ret);
-		goto err;
-	}
-	return 0;
-err:
-	/* release all acquired handles */
-	wcd9xxx_close_slim_sch_tx(wcd9xxx, wcd9xxx_ch_list, *grph);
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_cfg_slim_sch_tx);
-
-int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
-			      struct list_head *wcd9xxx_ch_list, u16 grph)
-{
-	u32 sph[SLIM_MAX_RX_PORTS] = {0};
-	int ch_cnt = 0;
-	int ret = 0;
-	struct wcd9xxx_ch *rx;
-
-	list_for_each_entry(rx, wcd9xxx_ch_list, list)
-		sph[ch_cnt++] = rx->sph;
-
-	pr_debug("%s ch_cht %d, sph[0] %d sph[1] %d\n", __func__, ch_cnt,
-		sph[0], sph[1]);
-
-	/* slim_control_ch (REMOVE) */
-	pr_debug("%s before slim_control_ch grph %d\n", __func__, grph);
-	ret = slim_control_ch(wcd9xxx->slim, grph, SLIM_CH_REMOVE, true);
-	if (ret < 0) {
-		pr_err("%s: slim_control_ch failed ret[%d]\n", __func__, ret);
-		goto err;
-	}
-err:
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_close_slim_sch_rx);
-
-int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
-			      struct list_head *wcd9xxx_ch_list,
-			      u16 grph)
-{
-	u32 sph[SLIM_MAX_TX_PORTS] = {0};
-	int ret = 0;
-	int ch_cnt = 0;
-	struct wcd9xxx_ch *tx;
-
-	pr_debug("%s\n", __func__);
-	list_for_each_entry(tx, wcd9xxx_ch_list, list)
-		sph[ch_cnt++] = tx->sph;
-
-	pr_debug("%s ch_cht %d, sph[0] %d sph[1] %d\n",
-		__func__, ch_cnt, sph[0], sph[1]);
-	/* slim_control_ch (REMOVE) */
-	ret = slim_control_ch(wcd9xxx->slim, grph, SLIM_CH_REMOVE, true);
-	if (ret < 0) {
-		pr_err("%s: slim_control_ch failed ret[%d]\n",
-			__func__, ret);
-		goto err;
-	}
-err:
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_close_slim_sch_tx);
-
-int wcd9xxx_get_slave_port(unsigned int ch_num)
-{
-	int ret = 0;
-
-	ret = (ch_num - BASE_CH_NUM);
-	pr_debug("%s: ch_num[%d] slave port[%d]\n", __func__, ch_num, ret);
-	if (ret < 0) {
-		pr_err("%s: Error:- Invalid slave port found = %d\n",
-			__func__, ret);
-		return -EINVAL;
-	}
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_get_slave_port);
-
-int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list, u16 grph)
-{
-	u32 sph[SLIM_MAX_TX_PORTS + SLIM_MAX_RX_PORTS] = {0};
-	int ch_cnt = 0;
-	int ret = 0;
-	struct wcd9xxx_ch *slim_ch;
-
-	list_for_each_entry(slim_ch, wcd9xxx_ch_list, list)
-		sph[ch_cnt++] = slim_ch->sph;
-
-	/* slim_disconnect_port */
-	ret = slim_disconnect_ports(wcd9xxx->slim, sph, ch_cnt);
-	if (ret < 0) {
-		pr_err("%s: slim_disconnect_ports failed ret[%d]\n",
-			__func__, ret);
-	}
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_disconnect_port);
-
-/* This function is called with mutex acquired */
-int wcd9xxx_rx_vport_validation(u32 port_id,
-				struct list_head *codec_dai_list)
-{
-	struct wcd9xxx_ch *ch;
-	int ret = 0;
-
-	pr_debug("%s: port_id %u\n", __func__, port_id);
-
-	list_for_each_entry(ch,
-		codec_dai_list, list) {
-		pr_debug("%s: ch->port %u\n", __func__, ch->port);
-		if (ch->port == port_id) {
-			ret = -EINVAL;
-			break;
-		}
-	}
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_rx_vport_validation);
-
-
-/* This function is called with mutex acquired */
-int wcd9xxx_tx_vport_validation(u32 table, u32 port_id,
-				struct wcd9xxx_codec_dai_data *codec_dai,
-				u32 num_codec_dais)
-{
-	struct wcd9xxx_ch *ch;
-	int ret = 0;
-	u32 index;
-	unsigned long vtable = table;
-	u32 size = sizeof(table) * BITS_PER_BYTE;
-
-	pr_debug("%s: vtable 0x%lx port_id %u size %d\n", __func__,
-		 vtable, port_id, size);
-	for_each_set_bit(index, &vtable, size) {
-		if (index < num_codec_dais) {
-			list_for_each_entry(ch,
-					&codec_dai[index].wcd9xxx_ch_list,
-					list) {
-				pr_debug("%s: index %u ch->port %u vtable 0x%lx\n",
-						__func__, index, ch->port,
-						vtable);
-				if (ch->port == port_id) {
-					pr_err("%s: TX%u is used by AIF%u_CAP Mixer\n",
-							__func__, port_id + 1,
-							(index + 1)/2);
-					ret = -EINVAL;
-					break;
-				}
-			}
-		} else {
-			pr_err("%s: Invalid index %d of codec dai",
-					__func__, index);
-			ret = -EINVAL;
-		}
-		if (ret)
-			break;
-	}
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_tx_vport_validation);
diff --git a/drivers/mfd/wcd9xxx-utils.c b/drivers/mfd/wcd9xxx-utils.c
deleted file mode 100644
index f72585a..0000000
--- a/drivers/mfd/wcd9xxx-utils.c
+++ /dev/null
@@ -1,1211 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/of_gpio.h>
-#include <linux/of_irq.h>
-#include <linux/of_device.h>
-#include <linux/slab.h>
-#include <linux/regmap.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/mfd/core.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/msm-cdc-supply.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-utils.h>
-
-#define REG_BYTES 2
-#define VAL_BYTES 1
-/*
- * Page Register Address that APP Proc uses to
- * access WCD9335 Codec registers is identified
- * as 0x00
- */
-#define PAGE_REG_ADDR 0x00
-
-static enum wcd9xxx_intf_status wcd9xxx_intf = -1;
-
-static struct mfd_cell tavil_devs[] = {
-	{
-		.name = "qcom-wcd-pinctrl",
-		.of_compatible = "qcom,wcd-pinctrl",
-	},
-	{
-		.name = "tavil_codec",
-	},
-};
-
-static struct mfd_cell tasha_devs[] = {
-	{
-		.name = "tasha_codec",
-	},
-};
-
-static struct mfd_cell tomtom_devs[] = {
-	{
-		.name = "tomtom_codec",
-	},
-};
-
-static int wcd9xxx_read_of_property_u32(struct device *dev, const char *name,
-					u32 *val)
-{
-	int rc = 0;
-
-	rc = of_property_read_u32(dev->of_node, name, val);
-	if (rc)
-		dev_err(dev, "%s: Looking up %s property in node %s failed",
-			__func__, name, dev->of_node->full_name);
-
-	return rc;
-}
-
-static void wcd9xxx_dt_parse_micbias_info(struct device *dev,
-					  struct wcd9xxx_micbias_setting *mb)
-{
-	u32 prop_val;
-	int rc;
-
-	if (of_find_property(dev->of_node, "qcom,cdc-micbias-ldoh-v", NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias-ldoh-v",
-						  &prop_val);
-		if (!rc)
-			mb->ldoh_v  =  (u8)prop_val;
-	}
-
-	/* MB1 */
-	if (of_find_property(dev->of_node, "qcom,cdc-micbias-cfilt1-mv",
-			     NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias-cfilt1-mv",
-						   &prop_val);
-		if (!rc)
-			mb->cfilt1_mv = prop_val;
-
-		rc = wcd9xxx_read_of_property_u32(dev,
-						"qcom,cdc-micbias1-cfilt-sel",
-						&prop_val);
-		if (!rc)
-			mb->bias1_cfilt_sel = (u8)prop_val;
-
-	} else if (of_find_property(dev->of_node, "qcom,cdc-micbias1-mv",
-				    NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias1-mv",
-						  &prop_val);
-		if (!rc)
-			mb->micb1_mv = prop_val;
-	} else {
-		dev_info(dev, "%s: Micbias1 DT property not found\n",
-			__func__);
-	}
-
-	/* MB2 */
-	if (of_find_property(dev->of_node, "qcom,cdc-micbias-cfilt2-mv",
-			     NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias-cfilt2-mv",
-						   &prop_val);
-		if (!rc)
-			mb->cfilt2_mv = prop_val;
-
-		rc = wcd9xxx_read_of_property_u32(dev,
-						"qcom,cdc-micbias2-cfilt-sel",
-						&prop_val);
-		if (!rc)
-			mb->bias2_cfilt_sel = (u8)prop_val;
-
-	} else if (of_find_property(dev->of_node, "qcom,cdc-micbias2-mv",
-				    NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias2-mv",
-						  &prop_val);
-		if (!rc)
-			mb->micb2_mv = prop_val;
-	} else {
-		dev_info(dev, "%s: Micbias2 DT property not found\n",
-			__func__);
-	}
-
-	/* MB3 */
-	if (of_find_property(dev->of_node, "qcom,cdc-micbias-cfilt3-mv",
-			     NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias-cfilt3-mv",
-						   &prop_val);
-		if (!rc)
-			mb->cfilt3_mv = prop_val;
-
-		rc = wcd9xxx_read_of_property_u32(dev,
-						"qcom,cdc-micbias3-cfilt-sel",
-						&prop_val);
-		if (!rc)
-			mb->bias3_cfilt_sel = (u8)prop_val;
-
-	} else if (of_find_property(dev->of_node, "qcom,cdc-micbias3-mv",
-				    NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias3-mv",
-						  &prop_val);
-		if (!rc)
-			mb->micb3_mv = prop_val;
-	} else {
-		dev_info(dev, "%s: Micbias3 DT property not found\n",
-			__func__);
-	}
-
-	/* MB4 */
-	if (of_find_property(dev->of_node, "qcom,cdc-micbias4-cfilt-sel",
-			     NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						"qcom,cdc-micbias4-cfilt-sel",
-						&prop_val);
-		if (!rc)
-			mb->bias4_cfilt_sel = (u8)prop_val;
-
-	} else if (of_find_property(dev->of_node, "qcom,cdc-micbias4-mv",
-				    NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-micbias4-mv",
-						  &prop_val);
-		if (!rc)
-			mb->micb4_mv = prop_val;
-	} else {
-		dev_info(dev, "%s: Micbias4 DT property not found\n",
-			__func__);
-	}
-
-	mb->bias1_cap_mode =
-	   (of_property_read_bool(dev->of_node, "qcom,cdc-micbias1-ext-cap") ?
-	 MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-	mb->bias2_cap_mode =
-	   (of_property_read_bool(dev->of_node, "qcom,cdc-micbias2-ext-cap") ?
-	    MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-	mb->bias3_cap_mode =
-	   (of_property_read_bool(dev->of_node, "qcom,cdc-micbias3-ext-cap") ?
-	    MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-	mb->bias4_cap_mode =
-	   (of_property_read_bool(dev->of_node, "qcom,cdc-micbias4-ext-cap") ?
-	    MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-
-	mb->bias2_is_headset_only =
-		of_property_read_bool(dev->of_node,
-				      "qcom,cdc-micbias2-headset-only");
-
-	/* Print micbias info */
-	dev_dbg(dev, "%s: ldoh_v  %u cfilt1_mv %u cfilt2_mv %u cfilt3_mv %u",
-		__func__, (u32)mb->ldoh_v, (u32)mb->cfilt1_mv,
-		(u32)mb->cfilt2_mv, (u32)mb->cfilt3_mv);
-
-	dev_dbg(dev, "%s: micb1_mv %u micb2_mv %u micb3_mv %u micb4_mv %u",
-		__func__, mb->micb1_mv, mb->micb2_mv,
-		mb->micb3_mv, mb->micb4_mv);
-
-	dev_dbg(dev, "%s: bias1_cfilt_sel %u bias2_cfilt_sel %u\n",
-		__func__, (u32)mb->bias1_cfilt_sel, (u32)mb->bias2_cfilt_sel);
-
-	dev_dbg(dev, "%s: bias3_cfilt_sel %u bias4_cfilt_sel %u\n",
-		__func__, (u32)mb->bias3_cfilt_sel, (u32)mb->bias4_cfilt_sel);
-
-	dev_dbg(dev, "%s: bias1_ext_cap %d bias2_ext_cap %d\n",
-		__func__, mb->bias1_cap_mode, mb->bias2_cap_mode);
-
-	dev_dbg(dev, "%s: bias3_ext_cap %d bias4_ext_cap %d\n",
-		__func__, mb->bias3_cap_mode, mb->bias4_cap_mode);
-
-	dev_dbg(dev, "%s: bias2_is_headset_only %d\n",
-		__func__, mb->bias2_is_headset_only);
-}
-
-/*
- * wcd9xxx_validate_dmic_sample_rate:
- *	Given the dmic_sample_rate and mclk rate, validate the
- *	dmic_sample_rate. If dmic rate is found to be invalid,
- *	assign the dmic rate as undefined, so individual codec
- *	drivers can use their own defaults
- * @dev: the device for which the dmic is to be configured
- * @dmic_sample_rate: The input dmic_sample_rate
- * @mclk_rate: The input codec mclk rate
- * @dmic_rate_type: String to indicate the type of dmic sample
- *		    rate, used for debug/error logging.
- */
-static u32 wcd9xxx_validate_dmic_sample_rate(struct device *dev,
-		u32 dmic_sample_rate, u32 mclk_rate,
-		const char *dmic_rate_type)
-{
-	u32 div_factor;
-
-	if (dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED ||
-	    mclk_rate % dmic_sample_rate != 0)
-		goto undefined_rate;
-
-	div_factor = mclk_rate / dmic_sample_rate;
-
-	switch (div_factor) {
-	case 2:
-	case 3:
-	case 4:
-	case 8:
-	case 16:
-		/* Valid dmic DIV factors */
-		dev_dbg(dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
-			__func__, div_factor, mclk_rate);
-		break;
-	case 6:
-		/*
-		 * DIV 6 is valid for both 9.6MHz and 12.288MHz
-		 * MCLK on Tavil. Older codecs support DIV6 only
-		 * for 12.288MHz MCLK.
-		 */
-		if ((mclk_rate == WCD9XXX_MCLK_CLK_9P6HZ) &&
-		    (of_device_is_compatible(dev->of_node,
-					     "qcom,tavil-slim-pgd")))
-			dev_dbg(dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
-				__func__, div_factor, mclk_rate);
-		else if (mclk_rate != WCD9XXX_MCLK_CLK_12P288MHZ)
-			goto undefined_rate;
-		break;
-	default:
-		/* Any other DIV factor is invalid */
-		goto undefined_rate;
-	}
-
-	return dmic_sample_rate;
-
-undefined_rate:
-	dev_dbg(dev, "%s: Invalid %s = %d, for mclk %d\n",
-		 __func__, dmic_rate_type, dmic_sample_rate, mclk_rate);
-	dmic_sample_rate = WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED;
-
-	return dmic_sample_rate;
-}
-
-/*
- * wcd9xxx_populate_dt_data:
- *	Parse device tree properties for the given codec device
- *
- * @dev: pointer to codec device
- *
- * Returns pointer to the platform data resulting from parsing
- * device tree.
- */
-struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev)
-{
-	struct wcd9xxx_pdata *pdata;
-	u32 dmic_sample_rate = WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED;
-	u32 mad_dmic_sample_rate = WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED;
-	u32 ecpp_dmic_sample_rate = WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED;
-	u32 dmic_clk_drive = WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED;
-	u32 prop_val;
-	int rc = 0;
-
-	if (!dev || !dev->of_node)
-		return NULL;
-
-	pdata = devm_kzalloc(dev, sizeof(struct wcd9xxx_pdata),
-			     GFP_KERNEL);
-	if (!pdata)
-		return NULL;
-
-	/* Parse power supplies */
-	msm_cdc_get_power_supplies(dev, &pdata->regulator,
-				   &pdata->num_supplies);
-	if (!pdata->regulator || (pdata->num_supplies <= 0)) {
-		dev_err(dev, "%s: no power supplies defined for codec\n",
-			__func__);
-		goto err_power_sup;
-	}
-
-	/* Parse micbias info */
-	wcd9xxx_dt_parse_micbias_info(dev, &pdata->micbias);
-
-	pdata->wcd_rst_np = of_parse_phandle(dev->of_node,
-					     "qcom,wcd-rst-gpio-node", 0);
-	if (!pdata->wcd_rst_np) {
-		dev_err(dev, "%s: Looking up %s property in node %s failed\n",
-			__func__, "qcom,wcd-rst-gpio-node",
-			dev->of_node->full_name);
-		goto err_parse_dt_prop;
-	}
-
-	pdata->has_buck_vsel_gpio = of_property_read_bool(dev->of_node,
-						"qcom,has-buck-vsel-gpio");
-	if (pdata->has_buck_vsel_gpio) {
-		pdata->buck_vsel_ctl_np = of_parse_phandle(dev->of_node,
-				"qcom,buck-vsel-gpio-node", 0);
-		if (!pdata->buck_vsel_ctl_np) {
-			dev_err(dev, "%s No entry for %s property in node %s\n",
-				__func__, "qcom,buck-vsel-gpio-node",
-				dev->of_node->full_name);
-			goto err_parse_dt_prop;
-		}
-	}
-
-	if (!(wcd9xxx_read_of_property_u32(dev, "qcom,cdc-mclk-clk-rate",
-					   &prop_val)))
-		pdata->mclk_rate = prop_val;
-
-	if (pdata->mclk_rate != WCD9XXX_MCLK_CLK_9P6HZ &&
-	    pdata->mclk_rate != WCD9XXX_MCLK_CLK_12P288MHZ) {
-		dev_err(dev, "%s: Invalid mclk_rate = %u\n", __func__,
-			pdata->mclk_rate);
-		goto err_parse_dt_prop;
-	}
-
-	if (!(wcd9xxx_read_of_property_u32(dev, "qcom,cdc-dmic-sample-rate",
-					   &prop_val)))
-		dmic_sample_rate = prop_val;
-
-	pdata->dmic_sample_rate = wcd9xxx_validate_dmic_sample_rate(dev,
-							dmic_sample_rate,
-							pdata->mclk_rate,
-							"audio_dmic_rate");
-	if (!(wcd9xxx_read_of_property_u32(dev, "qcom,cdc-mad-dmic-rate",
-					   &prop_val)))
-		mad_dmic_sample_rate = prop_val;
-
-	pdata->mad_dmic_sample_rate = wcd9xxx_validate_dmic_sample_rate(dev,
-							mad_dmic_sample_rate,
-							pdata->mclk_rate,
-							"mad_dmic_rate");
-
-	if (of_find_property(dev->of_node, "qcom,cdc-ecpp-dmic-rate", NULL)) {
-		rc = wcd9xxx_read_of_property_u32(dev,
-						  "qcom,cdc-ecpp-dmic-rate",
-						  &prop_val);
-		if (!rc)
-			ecpp_dmic_sample_rate = prop_val;
-	}
-
-	pdata->ecpp_dmic_sample_rate = wcd9xxx_validate_dmic_sample_rate(dev,
-							ecpp_dmic_sample_rate,
-							pdata->mclk_rate,
-							"ecpp_dmic_rate");
-
-	if (!(of_property_read_u32(dev->of_node,
-				   "qcom,cdc-dmic-clk-drv-strength",
-				   &prop_val))) {
-		dmic_clk_drive = prop_val;
-
-		if (dmic_clk_drive != 2 && dmic_clk_drive != 4 &&
-		    dmic_clk_drive != 8 && dmic_clk_drive != 16)
-			dev_err(dev, "Invalid cdc-dmic-clk-drv-strength %d\n",
-				dmic_clk_drive);
-	}
-
-	pdata->dmic_clk_drv = dmic_clk_drive;
-
-	return pdata;
-
-err_parse_dt_prop:
-	devm_kfree(dev, pdata->regulator);
-	pdata->regulator = NULL;
-	pdata->num_supplies = 0;
-err_power_sup:
-	devm_kfree(dev, pdata);
-	return NULL;
-}
-EXPORT_SYMBOL(wcd9xxx_populate_dt_data);
-
-static bool is_wcd9xxx_reg_power_down(struct wcd9xxx *wcd9xxx, u16 rreg)
-{
-	bool ret = false;
-	int i;
-	struct wcd9xxx_power_region *wcd9xxx_pwr;
-
-	if (!wcd9xxx)
-		return ret;
-
-	for (i = 0; i < WCD9XXX_MAX_PWR_REGIONS; i++) {
-		wcd9xxx_pwr = wcd9xxx->wcd9xxx_pwr[i];
-		if (!wcd9xxx_pwr)
-			continue;
-		if (((wcd9xxx_pwr->pwr_collapse_reg_min == 0) &&
-		     (wcd9xxx_pwr->pwr_collapse_reg_max == 0)) ||
-		    (wcd9xxx_pwr->power_state ==
-		     WCD_REGION_POWER_COLLAPSE_REMOVE))
-			ret = false;
-		else if (((wcd9xxx_pwr->power_state ==
-			   WCD_REGION_POWER_DOWN) ||
-			  (wcd9xxx_pwr->power_state ==
-			   WCD_REGION_POWER_COLLAPSE_BEGIN)) &&
-			 (rreg >= wcd9xxx_pwr->pwr_collapse_reg_min) &&
-			 (rreg <= wcd9xxx_pwr->pwr_collapse_reg_max))
-			ret = true;
-	}
-	return ret;
-}
-
-/*
- * wcd9xxx_page_write:
- *	Retrieve page number from register and
- *	write that page number to the page address.
- *	Called under io_lock acquisition.
- *
- * @wcd9xxx: pointer to wcd9xxx
- * @reg: Register address from which page number is retrieved
- *
- * Returns 0 for success and negative error code for failure.
- */
-int wcd9xxx_page_write(struct wcd9xxx *wcd9xxx, unsigned short *reg)
-{
-	int ret = 0;
-	unsigned short c_reg, reg_addr;
-	u8 pg_num, prev_pg_num;
-
-	if (wcd9xxx->type != WCD9335 && wcd9xxx->type != WCD934X)
-		return ret;
-
-	c_reg = *reg;
-	pg_num = c_reg >> 8;
-	reg_addr = c_reg & 0xff;
-	if (wcd9xxx->prev_pg_valid) {
-		prev_pg_num = wcd9xxx->prev_pg;
-		if (prev_pg_num != pg_num) {
-			ret = wcd9xxx->write_dev(
-					wcd9xxx, PAGE_REG_ADDR, 1,
-					(void *) &pg_num, false);
-			if (ret < 0)
-				pr_err("page write error, pg_num: 0x%x\n",
-					pg_num);
-			else {
-				wcd9xxx->prev_pg = pg_num;
-				dev_dbg(wcd9xxx->dev, "%s: Page 0x%x Write to 0x00\n",
-					__func__, pg_num);
-			}
-		}
-	} else {
-		ret = wcd9xxx->write_dev(
-				wcd9xxx, PAGE_REG_ADDR, 1, (void *) &pg_num,
-				false);
-		if (ret < 0)
-			pr_err("page write error, pg_num: 0x%x\n", pg_num);
-		else {
-			wcd9xxx->prev_pg = pg_num;
-			wcd9xxx->prev_pg_valid = true;
-			dev_dbg(wcd9xxx->dev, "%s: Page 0x%x Write to 0x00\n",
-				__func__, pg_num);
-		}
-	}
-	*reg = reg_addr;
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_page_write);
-
-static int regmap_bus_read(void *context, const void *reg, size_t reg_size,
-			   void *val, size_t val_size)
-{
-	struct device *dev = context;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
-	unsigned short c_reg, rreg;
-	int ret, i;
-
-	if (!wcd9xxx) {
-		dev_err(dev, "%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-
-	mutex_lock(&wcd9xxx->io_lock);
-	c_reg = *(u16 *)reg;
-	rreg = c_reg;
-
-	if (is_wcd9xxx_reg_power_down(wcd9xxx, rreg)) {
-		ret = 0;
-		for (i = 0; i < val_size; i++)
-			((u8 *)val)[i] = 0;
-		goto err;
-	}
-	ret = wcd9xxx_page_write(wcd9xxx, &c_reg);
-	if (ret)
-		goto err;
-	ret = wcd9xxx->read_dev(wcd9xxx, c_reg, val_size, val, false);
-	if (ret < 0)
-		dev_err(dev, "%s: Codec read failed (%d), reg: 0x%x, size:%zd\n",
-			__func__, ret, rreg, val_size);
-	else {
-		for (i = 0; i < val_size; i++)
-			dev_dbg(dev, "%s: Read 0x%02x from 0x%x\n",
-				__func__, ((u8 *)val)[i], rreg + i);
-	}
-err:
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	return ret;
-}
-
-static int regmap_bus_gather_write(void *context,
-				   const void *reg, size_t reg_size,
-				   const void *val, size_t val_size)
-{
-	struct device *dev = context;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
-	unsigned short c_reg, rreg;
-	int ret, i;
-
-	if (!wcd9xxx) {
-		dev_err(dev, "%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-	mutex_lock(&wcd9xxx->io_lock);
-	c_reg = *(u16 *)reg;
-	rreg = c_reg;
-
-	if (is_wcd9xxx_reg_power_down(wcd9xxx, rreg)) {
-		ret = 0;
-		goto err;
-	}
-	ret = wcd9xxx_page_write(wcd9xxx, &c_reg);
-	if (ret)
-		goto err;
-
-	for (i = 0; i < val_size; i++)
-		dev_dbg(dev, "Write %02x to 0x%x\n", ((u8 *)val)[i],
-			rreg + i);
-
-	ret = wcd9xxx->write_dev(wcd9xxx, c_reg, val_size, (void *) val,
-				 false);
-	if (ret < 0)
-		dev_err(dev, "%s: Codec write failed (%d), reg:0x%x, size:%zd\n",
-			__func__, ret, rreg, val_size);
-
-err:
-	mutex_unlock(&wcd9xxx->io_lock);
-	return ret;
-}
-
-static int regmap_bus_write(void *context, const void *data, size_t count)
-{
-	struct device *dev = context;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
-
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	WARN_ON(count < REG_BYTES);
-
-	if (count > (REG_BYTES + VAL_BYTES)) {
-		if (wcd9xxx->multi_reg_write)
-			return wcd9xxx->multi_reg_write(wcd9xxx,
-							data, count);
-	} else
-		return regmap_bus_gather_write(context, data, REG_BYTES,
-					       data + REG_BYTES,
-					       count - REG_BYTES);
-
-	dev_err(dev, "%s: bus multi reg write failure\n", __func__);
-
-	return -EINVAL;
-}
-
-static struct regmap_bus regmap_bus_config = {
-	.write = regmap_bus_write,
-	.gather_write = regmap_bus_gather_write,
-	.read = regmap_bus_read,
-	.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
-};
-
-/*
- * wcd9xxx_regmap_init:
- *	Initialize wcd9xxx register map
- *
- * @dev: pointer to wcd device
- * @config: pointer to register map config
- *
- * Returns pointer to regmap structure for success
- * or NULL in case of failure.
- */
-struct regmap *wcd9xxx_regmap_init(struct device *dev,
-				   const struct regmap_config *config)
-{
-	return devm_regmap_init(dev, &regmap_bus_config, dev, config);
-}
-EXPORT_SYMBOL(wcd9xxx_regmap_init);
-
-/*
- * wcd9xxx_reset:
- *	Reset wcd9xxx codec
- *
- * @dev: pointer to wcd device
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_reset(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx;
-	int rc;
-	int value;
-
-	if (!dev)
-		return -ENODEV;
-
-	wcd9xxx = dev_get_drvdata(dev);
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	if (!wcd9xxx->wcd_rst_np) {
-		dev_err(dev, "%s: reset gpio device node not specified\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	value = msm_cdc_pinctrl_get_state(wcd9xxx->wcd_rst_np);
-	if (value > 0) {
-		wcd9xxx->avoid_cdc_rstlow = 1;
-		return 0;
-	}
-
-	rc = msm_cdc_pinctrl_select_sleep_state(wcd9xxx->wcd_rst_np);
-	if (rc) {
-		dev_err(dev, "%s: wcd sleep state request fail!\n",
-			__func__);
-		return rc;
-	}
-
-	/* 20ms sleep required after pulling the reset gpio to LOW */
-	msleep(20);
-
-	rc = msm_cdc_pinctrl_select_active_state(wcd9xxx->wcd_rst_np);
-	if (rc) {
-		dev_err(dev, "%s: wcd active state request fail!\n",
-			__func__);
-		return rc;
-	}
-	msleep(20);
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9xxx_reset);
-
-/*
- * wcd9xxx_reset_low:
- *	Pull the wcd9xxx codec reset_n to low
- *
- * @dev: pointer to wcd device
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_reset_low(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx;
-	int rc;
-
-	if (!dev)
-		return -ENODEV;
-
-	wcd9xxx = dev_get_drvdata(dev);
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	if (!wcd9xxx->wcd_rst_np) {
-		dev_err(dev, "%s: reset gpio device node not specified\n",
-			__func__);
-		return -EINVAL;
-	}
-	if (wcd9xxx->avoid_cdc_rstlow) {
-		wcd9xxx->avoid_cdc_rstlow = 0;
-		dev_dbg(dev, "%s: avoid pull down of reset GPIO\n", __func__);
-		return 0;
-	}
-
-	rc = msm_cdc_pinctrl_select_sleep_state(wcd9xxx->wcd_rst_np);
-	if (rc)
-		dev_err(dev, "%s: wcd sleep state request fail!\n",
-			__func__);
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9xxx_reset_low);
-
-/*
- * wcd9xxx_bringup:
- *	Toggle reset analog and digital cores of wcd9xxx codec
- *
- * @dev: pointer to wcd device
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_bringup(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx;
-	int rc;
-	codec_bringup_fn cdc_bup_fn;
-
-	if (!dev)
-		return -ENODEV;
-
-	wcd9xxx = dev_get_drvdata(dev);
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	cdc_bup_fn = wcd9xxx_bringup_fn(wcd9xxx->type);
-	if (!cdc_bup_fn) {
-		dev_err(dev, "%s: Codec bringup fn NULL!\n",
-			__func__);
-		return -EINVAL;
-	}
-	rc = cdc_bup_fn(wcd9xxx);
-	if (rc)
-		dev_err(dev, "%s: Codec bringup error, rc: %d\n",
-			__func__, rc);
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9xxx_bringup);
-
-/*
- * wcd9xxx_bringup:
- *	Set analog and digital cores of wcd9xxx codec in reset state
- *
- * @dev: pointer to wcd device
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_bringdown(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx;
-	int rc;
-	codec_bringdown_fn cdc_bdown_fn;
-
-	if (!dev)
-		return -ENODEV;
-
-	wcd9xxx = dev_get_drvdata(dev);
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	cdc_bdown_fn = wcd9xxx_bringdown_fn(wcd9xxx->type);
-	if (!cdc_bdown_fn) {
-		dev_err(dev, "%s: Codec bring down fn NULL!\n",
-			__func__);
-		return -EINVAL;
-	}
-	rc = cdc_bdown_fn(wcd9xxx);
-	if (rc)
-		dev_err(dev, "%s: Codec bring down error, rc: %d\n",
-			__func__, rc);
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9xxx_bringdown);
-
-/*
- * wcd9xxx_get_codec_info:
- *	Fill codec specific information like interrupts, version
- *
- * @dev: pointer to wcd device
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_get_codec_info(struct device *dev)
-{
-	struct wcd9xxx *wcd9xxx;
-	int rc;
-	codec_type_fn cdc_type_fn;
-	struct wcd9xxx_codec_type *cinfo;
-
-	if (!dev)
-		return -ENODEV;
-
-	wcd9xxx = dev_get_drvdata(dev);
-	if (!wcd9xxx)
-		return -EINVAL;
-
-	cdc_type_fn = wcd9xxx_get_codec_info_fn(wcd9xxx->type);
-	if (!cdc_type_fn) {
-		dev_err(dev, "%s: Codec fill type fn NULL!\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	cinfo = wcd9xxx->codec_type;
-	if (!cinfo)
-		return -EINVAL;
-
-	rc = cdc_type_fn(wcd9xxx, cinfo);
-	if (rc) {
-		dev_err(dev, "%s: Codec type fill failed, rc:%d\n",
-			__func__, rc);
-		return rc;
-
-	}
-
-	switch (wcd9xxx->type) {
-	case WCD934X:
-		cinfo->dev = tavil_devs;
-		cinfo->size = ARRAY_SIZE(tavil_devs);
-		break;
-	case WCD9335:
-		cinfo->dev = tasha_devs;
-		cinfo->size = ARRAY_SIZE(tasha_devs);
-		break;
-	case WCD9330:
-		cinfo->dev = tomtom_devs;
-		cinfo->size = ARRAY_SIZE(tomtom_devs);
-		break;
-	default:
-		cinfo->dev = NULL;
-		cinfo->size = 0;
-		break;
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(wcd9xxx_get_codec_info);
-
-/*
- * wcd9xxx_core_irq_init:
- *	Initialize wcd9xxx codec irq instance
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_core_irq_init(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res)
-{
-	int ret = 0;
-
-	if (!wcd9xxx_core_res)
-		return -EINVAL;
-
-	if (wcd9xxx_core_res->irq != 1) {
-		ret = wcd9xxx_irq_init(wcd9xxx_core_res);
-		if (ret)
-			pr_err("IRQ initialization failed\n");
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_core_irq_init);
-
-/*
- * wcd9xxx_assign_irq:
- *	Assign irq and irq_base to wcd9xxx core resource
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- * @irq: irq number
- * @irq_base: base irq number
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_assign_irq(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res,
-	unsigned int irq,
-	unsigned int irq_base)
-{
-	if (!wcd9xxx_core_res)
-		return -EINVAL;
-
-	wcd9xxx_core_res->irq = irq;
-	wcd9xxx_core_res->irq_base = irq_base;
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd9xxx_assign_irq);
-
-/*
- * wcd9xxx_core_res_init:
- *	Initialize wcd core resource instance
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- * @num_irqs: number of irqs for wcd9xxx core
- * @num_irq_regs: number of irq registers
- * @wcd_regmap: pointer to the wcd register map
- *
- * Returns 0 for success or negative error code in case of failure
- */
-int wcd9xxx_core_res_init(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res,
-	int num_irqs, int num_irq_regs, struct regmap *wcd_regmap)
-{
-	if (!wcd9xxx_core_res || !wcd_regmap)
-		return -EINVAL;
-
-	mutex_init(&wcd9xxx_core_res->pm_lock);
-	wcd9xxx_core_res->wlock_holders = 0;
-	wcd9xxx_core_res->pm_state = WCD9XXX_PM_SLEEPABLE;
-	init_waitqueue_head(&wcd9xxx_core_res->pm_wq);
-	pm_qos_add_request(&wcd9xxx_core_res->pm_qos_req,
-				PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-
-	wcd9xxx_core_res->num_irqs = num_irqs;
-	wcd9xxx_core_res->num_irq_regs = num_irq_regs;
-	wcd9xxx_core_res->wcd_core_regmap = wcd_regmap;
-
-	pr_info("%s: num_irqs = %d, num_irq_regs = %d\n",
-			__func__, wcd9xxx_core_res->num_irqs,
-			wcd9xxx_core_res->num_irq_regs);
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd9xxx_core_res_init);
-
-/*
- * wcd9xxx_core_res_deinit:
- *	Deinit wcd core resource instance
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- */
-void wcd9xxx_core_res_deinit(struct wcd9xxx_core_resource *wcd9xxx_core_res)
-{
-	if (!wcd9xxx_core_res)
-		return;
-
-	pm_qos_remove_request(&wcd9xxx_core_res->pm_qos_req);
-	mutex_destroy(&wcd9xxx_core_res->pm_lock);
-}
-EXPORT_SYMBOL(wcd9xxx_core_res_deinit);
-
-/*
- * wcd9xxx_pm_cmpxchg:
- *	Check old state and exchange with pm new state
- *	if old state matches with current state
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- * @o: pm old state
- * @n: pm new state
- *
- * Returns old state
- */
-enum wcd9xxx_pm_state wcd9xxx_pm_cmpxchg(
-		struct wcd9xxx_core_resource *wcd9xxx_core_res,
-		enum wcd9xxx_pm_state o,
-		enum wcd9xxx_pm_state n)
-{
-	enum wcd9xxx_pm_state old;
-
-	if (!wcd9xxx_core_res)
-		return o;
-
-	mutex_lock(&wcd9xxx_core_res->pm_lock);
-	old = wcd9xxx_core_res->pm_state;
-	if (old == o)
-		wcd9xxx_core_res->pm_state = n;
-	mutex_unlock(&wcd9xxx_core_res->pm_lock);
-
-	return old;
-}
-EXPORT_SYMBOL(wcd9xxx_pm_cmpxchg);
-
-/*
- * wcd9xxx_core_res_suspend:
- *	Suspend callback function for wcd9xxx core
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- * @pm_message_t: pm message
- *
- * Returns 0 for success or negative error code for failure/busy
- */
-int wcd9xxx_core_res_suspend(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res,
-	pm_message_t pmesg)
-{
-	int ret = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	/*
-	 * pm_qos_update_request() can be called after this suspend chain call
-	 * started. thus suspend can be called while lock is being held
-	 */
-	mutex_lock(&wcd9xxx_core_res->pm_lock);
-	if (wcd9xxx_core_res->pm_state == WCD9XXX_PM_SLEEPABLE) {
-		pr_debug("%s: suspending system, state %d, wlock %d\n",
-			 __func__, wcd9xxx_core_res->pm_state,
-			 wcd9xxx_core_res->wlock_holders);
-		wcd9xxx_core_res->pm_state = WCD9XXX_PM_ASLEEP;
-	} else if (wcd9xxx_core_res->pm_state == WCD9XXX_PM_AWAKE) {
-		/*
-		 * unlock to wait for pm_state == WCD9XXX_PM_SLEEPABLE
-		 * then set to WCD9XXX_PM_ASLEEP
-		 */
-		pr_debug("%s: waiting to suspend system, state %d, wlock %d\n",
-			 __func__, wcd9xxx_core_res->pm_state,
-			 wcd9xxx_core_res->wlock_holders);
-		mutex_unlock(&wcd9xxx_core_res->pm_lock);
-		if (!(wait_event_timeout(wcd9xxx_core_res->pm_wq,
-					 wcd9xxx_pm_cmpxchg(wcd9xxx_core_res,
-						  WCD9XXX_PM_SLEEPABLE,
-						  WCD9XXX_PM_ASLEEP) ==
-							WCD9XXX_PM_SLEEPABLE,
-					 HZ))) {
-			pr_debug("%s: suspend failed state %d, wlock %d\n",
-				 __func__, wcd9xxx_core_res->pm_state,
-				 wcd9xxx_core_res->wlock_holders);
-			ret = -EBUSY;
-		} else {
-			pr_debug("%s: done, state %d, wlock %d\n", __func__,
-				 wcd9xxx_core_res->pm_state,
-				 wcd9xxx_core_res->wlock_holders);
-		}
-		mutex_lock(&wcd9xxx_core_res->pm_lock);
-	} else if (wcd9xxx_core_res->pm_state == WCD9XXX_PM_ASLEEP) {
-		pr_warn("%s: system is already suspended, state %d, wlock %dn",
-			__func__, wcd9xxx_core_res->pm_state,
-			wcd9xxx_core_res->wlock_holders);
-	}
-	mutex_unlock(&wcd9xxx_core_res->pm_lock);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_core_res_suspend);
-
-/*
- * wcd9xxx_core_res_resume:
- *	Resume callback function for wcd9xxx core
- *
- * @wcd9xxx_core_res: pointer to wcd core resource
- *
- * Returns 0 for success or negative error code for failure/busy
- */
-int wcd9xxx_core_res_resume(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res)
-{
-	int ret = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	mutex_lock(&wcd9xxx_core_res->pm_lock);
-	if (wcd9xxx_core_res->pm_state == WCD9XXX_PM_ASLEEP) {
-		pr_debug("%s: resuming system, state %d, wlock %d\n", __func__,
-				wcd9xxx_core_res->pm_state,
-				wcd9xxx_core_res->wlock_holders);
-		wcd9xxx_core_res->pm_state = WCD9XXX_PM_SLEEPABLE;
-	} else {
-		pr_warn("%s: system is already awake, state %d wlock %d\n",
-				__func__, wcd9xxx_core_res->pm_state,
-				wcd9xxx_core_res->wlock_holders);
-	}
-	mutex_unlock(&wcd9xxx_core_res->pm_lock);
-	wake_up_all(&wcd9xxx_core_res->pm_wq);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_core_res_resume);
-
-/*
- * wcd9xxx_get_intf_type:
- *	Get interface type of wcd9xxx core
- *
- * Returns interface type
- */
-enum wcd9xxx_intf_status wcd9xxx_get_intf_type(void)
-{
-	return wcd9xxx_intf;
-}
-EXPORT_SYMBOL(wcd9xxx_get_intf_type);
-
-/*
- * wcd9xxx_set_intf_type:
- *	Set interface type of wcd9xxx core
- *
- */
-void wcd9xxx_set_intf_type(enum wcd9xxx_intf_status intf_status)
-{
-	wcd9xxx_intf = intf_status;
-}
-EXPORT_SYMBOL(wcd9xxx_set_intf_type);
-
-/*
- * wcd9xxx_set_power_state: set power state for the region
- * @wcd9xxx: handle to wcd core
- * @state: power state to be set
- * @region: region index
- *
- * Returns error code in case of failure or 0 for success
- */
-int wcd9xxx_set_power_state(struct wcd9xxx *wcd9xxx,
-			    enum codec_power_states state,
-			    enum wcd_power_regions region)
-{
-	if (!wcd9xxx) {
-		pr_err("%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if ((region < 0) || (region >= WCD9XXX_MAX_PWR_REGIONS)) {
-		dev_err(wcd9xxx->dev, "%s: region index %d out of bounds\n",
-			__func__, region);
-		return -EINVAL;
-	}
-	if (!wcd9xxx->wcd9xxx_pwr[region]) {
-		dev_err(wcd9xxx->dev, "%s: memory not created for region: %d\n",
-			__func__, region);
-		return -EINVAL;
-	}
-	mutex_lock(&wcd9xxx->io_lock);
-	wcd9xxx->wcd9xxx_pwr[region]->power_state = state;
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd9xxx_set_power_state);
-
-/*
- * wcd9xxx_get_current_power_state: Get power state of the region
- * @wcd9xxx: handle to wcd core
- * @region: region index
- *
- * Returns current power state of the region or error code for failure
- */
-int wcd9xxx_get_current_power_state(struct wcd9xxx *wcd9xxx,
-				    enum wcd_power_regions region)
-{
-	int state;
-
-	if (!wcd9xxx) {
-		pr_err("%s: wcd9xxx is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if ((region < 0) || (region >= WCD9XXX_MAX_PWR_REGIONS)) {
-		dev_err(wcd9xxx->dev, "%s: region index %d out of bounds\n",
-			__func__, region);
-		return -EINVAL;
-	}
-	if (!wcd9xxx->wcd9xxx_pwr[region]) {
-		dev_err(wcd9xxx->dev, "%s: memory not created for region: %d\n",
-			__func__, region);
-		return -EINVAL;
-	}
-
-	mutex_lock(&wcd9xxx->io_lock);
-	state = wcd9xxx->wcd9xxx_pwr[region]->power_state;
-	mutex_unlock(&wcd9xxx->io_lock);
-
-	return state;
-}
-EXPORT_SYMBOL(wcd9xxx_get_current_power_state);
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2e5da54..e3f4c39 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -791,6 +791,13 @@
 	  Per UID based io statistics exported to /proc/uid_io
 	  Per UID based procstat control in /proc/uid_procstat
 
+config UID_SYS_STATS_DEBUG
+	bool "Per-TASK statistics"
+	depends on UID_SYS_STATS
+	default n
+	help
+	  Per TASK based io statistics exported to /proc/uid_io
+
 config MEMORY_STATE_TIME
 	tristate "Memory freq/bandwidth time statistics"
 	depends on PROFILING
@@ -814,7 +821,6 @@
 source "drivers/misc/altera-stapl/Kconfig"
 source "drivers/misc/mei/Kconfig"
 source "drivers/misc/vmw_vmci/Kconfig"
-source "drivers/misc/qcom/Kconfig"
 source "drivers/misc/mic/Kconfig"
 source "drivers/misc/genwqe/Kconfig"
 source "drivers/misc/echo/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index cfea4a5..744001a 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,7 +56,6 @@
 obj-$(CONFIG_CXL_BASE)		+= cxl/
 obj-$(CONFIG_PANEL)             += panel.o
 obj-$(CONFIG_QPNP_MISC) 	+= qpnp-misc.o
-obj-y				+= qcom/
 obj-$(CONFIG_MEMORY_STATE_TIME)	+= memory_state_time.o
 
 obj-$(CONFIG_UID_SYS_STATS)	+= uid_sys_stats.o
diff --git a/drivers/misc/qcom/Kconfig b/drivers/misc/qcom/Kconfig
deleted file mode 100644
index e8a7960..0000000
--- a/drivers/misc/qcom/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-config MSM_QDSP6V2_CODECS
-	bool "Audio QDSP6V2 APR support"
-	select SND_SOC_QDSP6V2
-	help
-	  Enable Audio codecs with APR IPC protocol support between
-	  application processor and QDSP6 for B-family. APR is
-	  used by audio driver to configure QDSP6's
-	  ASM, ADM and AFE.
-
-config MSM_ULTRASOUND
-	bool "QDSP6V2 HW Ultrasound support"
-	select SND_SOC_QDSP6V2
-	help
-	  Enable HW Ultrasound support in QDSP6V2.
-	  QDSP6V2 can support HW encoder & decoder and
-	  ultrasound processing. It will enable
-	  ultrasound data paths between
-	  HW and services, calculating input events
-	  upon the ultrasound data.
diff --git a/drivers/misc/qcom/Makefile b/drivers/misc/qcom/Makefile
deleted file mode 100644
index 120bddd..0000000
--- a/drivers/misc/qcom/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-y		+= qdsp6v2/
diff --git a/drivers/misc/qcom/qdsp6v2/Makefile b/drivers/misc/qcom/qdsp6v2/Makefile
deleted file mode 100644
index 90a123a..0000000
--- a/drivers/misc/qcom/qdsp6v2/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-obj-$(CONFIG_MSM_QDSP6V2_CODECS) += aac_in.o qcelp_in.o evrc_in.o amrnb_in.o g711mlaw_in.o g711alaw_in.o audio_utils.o
-obj-$(CONFIG_MSM_QDSP6V2_CODECS) += audio_wma.o audio_wmapro.o audio_aac.o audio_multi_aac.o audio_alac.o audio_ape.o audio_utils_aio.o
-obj-$(CONFIG_MSM_QDSP6V2_CODECS) += q6audio_v2.o q6audio_v2_aio.o
-obj-$(CONFIG_MSM_QDSP6V2_CODECS) += audio_g711mlaw.o audio_g711alaw.o
-obj-$(CONFIG_MSM_QDSP6V2_CODECS)  += audio_mp3.o audio_amrnb.o audio_amrwb.o audio_amrwbplus.o audio_evrc.o audio_qcelp.o amrwb_in.o audio_hwacc_effects.o
-obj-$(CONFIG_MSM_ULTRASOUND) += ultrasound/
diff --git a/drivers/misc/qcom/qdsp6v2/aac_in.c b/drivers/misc/qcom/qdsp6v2/aac_in.c
deleted file mode 100644
index c0828dc..0000000
--- a/drivers/misc/qcom/qdsp6v2/aac_in.c
+++ /dev/null
@@ -1,709 +0,0 @@
-/*
- * Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_aac.h>
-#include <linux/compat.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 5 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((1536+sizeof(struct meta_out_dsp)) * 5))
-
-#define AAC_FORMAT_ADTS 65535
-
-#define MAX_SAMPLE_RATE_384K 384000
-
-static long aac_in_ioctl_shared(struct file *file, unsigned int cmd, void *arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_aac_enc_config *enc_cfg;
-		struct msm_audio_aac_config *aac_config;
-		uint32_t aac_mode = AAC_ENC_MODE_AAC_LC;
-
-		enc_cfg = audio->enc_cfg;
-		aac_config = audio->codec_cfg;
-		/* ENCODE CFG (after new set of API's are published )bharath*/
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			pr_info("%s:AUDIO_START already over\n", __func__);
-			rc = 0;
-			break;
-		}
-
-		if (audio->opened) {
-			rc = audio_in_buf_alloc(audio);
-			if (rc < 0) {
-				pr_err("%s:session id %d: buffer allocation failed\n",
-					 __func__, audio->ac->session);
-				break;
-			}
-		} else {
-			if (audio->feedback == NON_TUNNEL_MODE) {
-				pr_debug("%s: starting in non_tunnel mode",
-					__func__);
-				rc = q6asm_open_read_write(audio->ac,
-					FORMAT_MPEG4_AAC, FORMAT_LINEAR_PCM);
-				if (rc < 0) {
-					pr_err("%s:open read write failed\n",
-						__func__);
-					break;
-				}
-			}
-			if (audio->feedback == TUNNEL_MODE) {
-				pr_debug("%s: starting in tunnel mode",
-					__func__);
-				rc = q6asm_open_read(audio->ac,
-							FORMAT_MPEG4_AAC);
-
-				if (rc < 0) {
-					pr_err("%s:open read failed\n",
-							__func__);
-					break;
-				}
-			}
-			audio->stopped = 0;
-		}
-
-		pr_debug("%s:sbr_ps_flag = %d, sbr_flag = %d\n", __func__,
-			aac_config->sbr_ps_on_flag, aac_config->sbr_on_flag);
-		if (aac_config->sbr_ps_on_flag)
-			aac_mode = AAC_ENC_MODE_EAAC_P;
-		else if (aac_config->sbr_on_flag)
-			aac_mode = AAC_ENC_MODE_AAC_P;
-		else
-			aac_mode = AAC_ENC_MODE_AAC_LC;
-
-		rc = q6asm_enc_cfg_blk_aac(audio->ac,
-					audio->buf_cfg.frames_per_buf,
-					enc_cfg->sample_rate,
-					enc_cfg->channels,
-					enc_cfg->bit_rate,
-					aac_mode,
-					enc_cfg->stream_format);
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd media format block failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-						audio->pcm_cfg.sample_rate,
-						audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed\n",
-				__func__, audio->ac->session);
-				break;
-			}
-		}
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac);
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:session id %d: Rxed AUDIO_STOP\n", __func__,
-				audio->ac->session);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config *cfg;
-		struct msm_audio_aac_enc_config *enc_cfg;
-
-		cfg = (struct msm_audio_aac_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer for %s\n",
-			__func__, "AUDIO_GET_AAC_CONFIG");
-			rc = -EINVAL;
-			break;
-		}
-		memset(cfg, 0, sizeof(*cfg));
-		enc_cfg = audio->enc_cfg;
-		if (enc_cfg->channels == CH_MODE_MONO)
-			cfg->channels = 1;
-		else
-			cfg->channels = 2;
-
-		cfg->sample_rate = enc_cfg->sample_rate;
-		cfg->bit_rate = enc_cfg->bit_rate;
-		switch (enc_cfg->stream_format) {
-		case 0x00:
-			cfg->stream_format = AUDIO_AAC_FORMAT_ADTS;
-			break;
-		case 0x01:
-			cfg->stream_format = AUDIO_AAC_FORMAT_LOAS;
-			break;
-		case 0x02:
-			cfg->stream_format = AUDIO_AAC_FORMAT_ADIF;
-			break;
-		default:
-		case 0x03:
-			cfg->stream_format = AUDIO_AAC_FORMAT_RAW;
-		}
-		pr_debug("%s:session id %d: Get-aac-cfg: format=%d sr=%d bitrate=%d\n",
-			__func__, audio->ac->session,
-			cfg->stream_format, cfg->sample_rate, cfg->bit_rate);
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config *cfg;
-		struct msm_audio_aac_enc_config *enc_cfg;
-		uint32_t min_bitrate, max_bitrate;
-
-		cfg = (struct msm_audio_aac_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer for %s\n",
-			"AUDIO_SET_AAC_ENC_CONFIG", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg = audio->enc_cfg;
-		pr_debug("%s:session id %d: Set-aac-cfg: stream=%d\n", __func__,
-			audio->ac->session, cfg->stream_format);
-
-		switch (cfg->stream_format) {
-		case AUDIO_AAC_FORMAT_ADTS:
-			enc_cfg->stream_format = 0x00;
-			break;
-		case AUDIO_AAC_FORMAT_LOAS:
-			enc_cfg->stream_format = 0x01;
-			break;
-		case AUDIO_AAC_FORMAT_ADIF:
-			enc_cfg->stream_format = 0x02;
-			break;
-		case AUDIO_AAC_FORMAT_RAW:
-			enc_cfg->stream_format = 0x03;
-			break;
-		default:
-			pr_err("%s:session id %d: unsupported AAC format %d\n",
-				__func__, audio->ac->session,
-				cfg->stream_format);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (cfg->channels == 1) {
-			cfg->channels = CH_MODE_MONO;
-		} else if (cfg->channels == 2) {
-			cfg->channels = CH_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-
-		if (cfg->sample_rate > MAX_SAMPLE_RATE_384K) {
-			pr_err("%s: ERROR: invalid sample rate = %u",
-				__func__, cfg->sample_rate);
-			rc = -EINVAL;
-			break;
-		}
-
-		min_bitrate = ((cfg->sample_rate)*(cfg->channels))/2;
-		/* This calculation should be based on AAC mode. But we cannot
-		 * get AAC mode in this setconfig. min_bitrate's logical max
-		 * value is 24000. So if min_bitrate is higher than 24000,
-		 * choose 24000.
-		 */
-		if (min_bitrate > 24000)
-			min_bitrate = 24000;
-		max_bitrate = 6*(cfg->sample_rate)*(cfg->channels);
-		if (max_bitrate > 192000)
-			max_bitrate = 192000;
-		if ((cfg->bit_rate < min_bitrate) ||
-			(cfg->bit_rate > max_bitrate)) {
-			pr_err("%s: bitrate permissible: max=%d, min=%d\n",
-				__func__, max_bitrate, min_bitrate);
-			pr_err("%s: ERROR in setting bitrate = %d\n",
-				__func__, cfg->bit_rate);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg->sample_rate = cfg->sample_rate;
-		enc_cfg->channels = cfg->channels;
-		enc_cfg->bit_rate = cfg->bit_rate;
-		pr_debug("%s:session id %d: Set-aac-cfg:SR= 0x%x ch=0x%x bitrate=0x%x, format(adts/raw) = %d\n",
-			__func__, audio->ac->session, enc_cfg->sample_rate,
-			enc_cfg->channels, enc_cfg->bit_rate,
-			enc_cfg->stream_format);
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config *aac_cfg;
-		struct msm_audio_aac_config *audio_aac_cfg;
-		struct msm_audio_aac_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		audio_aac_cfg = audio->codec_cfg;
-		aac_cfg = (struct msm_audio_aac_config *)arg;
-
-		if (aac_cfg == NULL) {
-			pr_err("%s: NULL config pointer %s\n",
-				__func__, "AUDIO_SET_AAC_CONFIG");
-			rc = -EINVAL;
-			break;
-		}
-		pr_debug("%s:session id %d: AUDIO_SET_AAC_CONFIG: sbr_flag = %d sbr_ps_flag = %d\n",
-			 __func__, audio->ac->session, aac_cfg->sbr_on_flag,
-			 aac_cfg->sbr_ps_on_flag);
-		audio_aac_cfg->sbr_on_flag = aac_cfg->sbr_on_flag;
-		audio_aac_cfg->sbr_ps_on_flag = aac_cfg->sbr_ps_on_flag;
-		if ((audio_aac_cfg->sbr_on_flag == 1) ||
-			 (audio_aac_cfg->sbr_ps_on_flag == 1)) {
-			if (enc_cfg->sample_rate < 24000) {
-				pr_err("%s: ERROR in setting samplerate = %d\n",
-					__func__, enc_cfg->sample_rate);
-				rc = -EINVAL;
-				break;
-			}
-		}
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long aac_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = aac_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-
-		rc = aac_in_ioctl_shared(file, cmd, &cfg);
-		if (rc) {
-			pr_err("%s:AUDIO_GET_AAC_ENC_CONFIG failed. rc=%d\n",
-				__func__, rc);
-			break;
-		}
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = aac_in_ioctl_shared(file, cmd, &cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_ENC_CONFIG failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG: {
-		if (copy_to_user((void *)arg, &audio->codec_cfg,
-				 sizeof(struct msm_audio_aac_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config aac_cfg;
-
-		if (copy_from_user(&aac_cfg, (void *)arg,
-				 sizeof(struct msm_audio_aac_config))) {
-			pr_err("%s: copy_to_user for AUDIO_SET_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = aac_in_ioctl_shared(file, cmd, &aac_cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd=%d\n", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_aac_enc_config32 {
-	u32 channels;
-	u32 sample_rate;
-	u32 bit_rate;
-	u32 stream_format;
-};
-
-struct msm_audio_aac_config32 {
-	s16 format;
-	u16 audio_object;
-	u16 ep_config;       /* 0 ~ 3 useful only obj = ERLC */
-	u16 aac_section_data_resilience_flag;
-	u16 aac_scalefactor_data_resilience_flag;
-	u16 aac_spectral_data_resilience_flag;
-	u16 sbr_on_flag;
-	u16 sbr_ps_on_flag;
-	u16 dual_mono_mode;
-	u16 channel_configuration;
-	u16 sample_rate;
-};
-
-enum {
-	AUDIO_SET_AAC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_aac_config32),
-	AUDIO_GET_AAC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_aac_config32),
-	AUDIO_SET_AAC_ENC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+3), struct msm_audio_aac_enc_config32),
-	AUDIO_GET_AAC_ENC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+4), struct msm_audio_aac_enc_config32)
-};
-
-static long aac_in_compat_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = aac_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG_32: {
-		struct msm_audio_aac_enc_config cfg;
-		struct msm_audio_aac_enc_config32 cfg_32;
-
-		memset(&cfg_32, 0, sizeof(cfg_32));
-
-		cmd = AUDIO_GET_AAC_ENC_CONFIG;
-		rc = aac_in_ioctl_shared(file, cmd, &cfg);
-		if (rc) {
-			pr_err("%s:AUDIO_GET_AAC_ENC_CONFIG_32 failed. Rc= %d\n",
-				__func__, rc);
-			break;
-		}
-		cfg_32.channels = cfg.channels;
-		cfg_32.sample_rate = cfg.sample_rate;
-		cfg_32.bit_rate = cfg.bit_rate;
-		cfg_32.stream_format = cfg.stream_format;
-		if (copy_to_user((void *)arg, &cfg_32, sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG_32: {
-		struct msm_audio_aac_enc_config cfg;
-		struct msm_audio_aac_enc_config32 cfg_32;
-
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_GET_AAC_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.channels = cfg_32.channels;
-		cfg.sample_rate = cfg_32.sample_rate;
-		cfg.bit_rate = cfg_32.bit_rate;
-		cfg.stream_format = cfg_32.stream_format;
-		/* The command should be converted from 32 bit to normal
-		 * before the shared ioctl is called as shared ioctl
-		 * can process only normal commands
-		 */
-		cmd = AUDIO_SET_AAC_ENC_CONFIG;
-		rc = aac_in_ioctl_shared(file, cmd, &cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_ENC_CONFIG_32 failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config *aac_config;
-		struct msm_audio_aac_config32 aac_config_32;
-
-		aac_config = (struct msm_audio_aac_config *)audio->codec_cfg;
-		aac_config_32.format = aac_config->format;
-		aac_config_32.audio_object = aac_config->audio_object;
-		aac_config_32.ep_config = aac_config->ep_config;
-		aac_config_32.aac_section_data_resilience_flag =
-			aac_config->aac_section_data_resilience_flag;
-		aac_config_32.aac_scalefactor_data_resilience_flag =
-			aac_config->aac_scalefactor_data_resilience_flag;
-		aac_config_32.aac_spectral_data_resilience_flag =
-			aac_config->aac_spectral_data_resilience_flag;
-		aac_config_32.sbr_on_flag = aac_config->sbr_on_flag;
-		aac_config_32.sbr_ps_on_flag = aac_config->sbr_ps_on_flag;
-		aac_config_32.dual_mono_mode = aac_config->dual_mono_mode;
-		aac_config_32.channel_configuration =
-				aac_config->channel_configuration;
-		aac_config_32.sample_rate = aac_config->sample_rate;
-
-		if (copy_to_user((void *)arg, &aac_config_32,
-				 sizeof(aac_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config aac_cfg;
-		struct msm_audio_aac_config32 aac_cfg_32;
-
-		if (copy_from_user(&aac_cfg_32, (void *)arg,
-					sizeof(aac_cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		aac_cfg.format = aac_cfg_32.format;
-		aac_cfg.audio_object = aac_cfg_32.audio_object;
-		aac_cfg.ep_config = aac_cfg_32.ep_config;
-		aac_cfg.aac_section_data_resilience_flag =
-			aac_cfg_32.aac_section_data_resilience_flag;
-		aac_cfg.aac_scalefactor_data_resilience_flag =
-			aac_cfg_32.aac_scalefactor_data_resilience_flag;
-		aac_cfg.aac_spectral_data_resilience_flag =
-			aac_cfg_32.aac_spectral_data_resilience_flag;
-		aac_cfg.sbr_on_flag = aac_cfg_32.sbr_on_flag;
-		aac_cfg.sbr_ps_on_flag = aac_cfg_32.sbr_ps_on_flag;
-		aac_cfg.dual_mono_mode = aac_cfg_32.dual_mono_mode;
-		aac_cfg.channel_configuration =
-				aac_cfg_32.channel_configuration;
-		aac_cfg.sample_rate = aac_cfg_32.sample_rate;
-
-		cmd = AUDIO_SET_AAC_CONFIG;
-		rc = aac_in_ioctl_shared(file, cmd, &aac_cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d\n", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-#else
-#define aac_in_compat_ioctl NULL
-#endif
-
-static int aac_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_aac_enc_config *enc_cfg;
-	struct msm_audio_aac_config *aac_config;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_aac_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_aac_config),
-				GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	aac_config = audio->codec_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 1536;
-	audio->max_frames_per_buf = 5;
-	enc_cfg->sample_rate = 8000;
-	enc_cfg->channels = 1;
-	enc_cfg->bit_rate = 16000;
-	enc_cfg->stream_format = 0x00;/* 0:ADTS, 3:RAW */
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf   = 0x01;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	audio->pcm_cfg.buffer_size  = PCM_BUF_SIZE;
-	aac_config->format = AUDIO_AAC_FORMAT_ADTS;
-	aac_config->audio_object = AUDIO_AAC_OBJECT_LC;
-	aac_config->sbr_on_flag = 0;
-	aac_config->sbr_ps_on_flag = 0;
-	aac_config->channel_configuration = 1;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-							(void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-			__func__);
-		kfree(audio->enc_cfg);
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	/* open aac encoder in tunnel mode */
-	audio->buf_cfg.frames_per_buf = 0x01;
-
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_MPEG4_AAC,
-						FORMAT_LINEAR_PCM);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->buf_cfg.meta_info_enable = 0x01;
-		pr_info("%s:session id %d: NT mode encoder success\n", __func__,
-				audio->ac->session);
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_MPEG4_AAC);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: Tunnel Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__,
-				audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->buf_cfg.meta_info_enable = 0x00;
-		pr_info("%s:session id %d: T mode encoder success\n", __func__,
-			audio->ac->session);
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-	audio->opened = 1;
-	audio->reset_event = false;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = aac_in_compat_ioctl;
-	audio->enc_ioctl = aac_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= aac_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-	.compat_ioctl	= audio_in_compat_ioctl
-};
-
-struct miscdevice audio_aac_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aac_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init aac_in_init(void)
-{
-	return misc_register(&audio_aac_in_misc);
-}
-device_initcall(aac_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/amrnb_in.c b/drivers/misc/qcom/qdsp6v2/amrnb_in.c
deleted file mode 100644
index bdafde0..0000000
--- a/drivers/misc/qcom/qdsp6v2/amrnb_in.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/* Copyright (c) 2010-2012, 2014, 2016-2017 The Linux Foundation.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_amrnb.h>
-#include <linux/compat.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((32+sizeof(struct meta_out_dsp)) * 10))
-
-static long amrnb_in_ioctl_shared(struct file *file,
-				unsigned int cmd, void *arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_amrnb_enc_config_v2 *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			pr_info("%s:AUDIO_START already over\n", __func__);
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-
-		rc = q6asm_enc_cfg_blk_amrnb(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->band_mode,
-			enc_cfg->dtx_enable);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd amrnb media format block failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed\n",
-				__func__, audio->ac->session);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n",
-				__func__, audio->ac->session,
-				audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:AUDIO_STOP\n", __func__);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRNB_ENC_CONFIG_V2: {
-		struct msm_audio_amrnb_enc_config_v2 *cfg;
-		struct msm_audio_amrnb_enc_config_v2 *enc_cfg;
-
-		cfg = (struct msm_audio_amrnb_enc_config_v2 *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer for %s\n",
-					__func__,
-					"AUDIO_SET_AMRNB_ENC_CONFIG_V2");
-			rc = -EINVAL;
-			break;
-		}
-
-		enc_cfg = audio->enc_cfg;
-		if (cfg->band_mode > 8 ||
-			 cfg->band_mode < 1) {
-			pr_err("%s:session id %d: invalid band mode\n",
-				__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		/* AMR NB encoder accepts values between 0-7
-		 * while openmax provides value between 1-8
-		 * as per spec
-		 */
-		enc_cfg->band_mode = (cfg->band_mode - 1);
-		enc_cfg->dtx_enable = (cfg->dtx_enable ? 1 : 0);
-		enc_cfg->frame_format = 0;
-		pr_debug("%s:session id %d: band_mode = 0x%x dtx_enable=0x%x\n",
-				__func__, audio->ac->session,
-				enc_cfg->band_mode, enc_cfg->dtx_enable);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long amrnb_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc =  amrnb_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AMRNB_ENC_CONFIG_V2: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-			sizeof(struct msm_audio_amrnb_enc_config_v2))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AMRNB_ENC_CONFIG_V2 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRNB_ENC_CONFIG_V2: {
-		struct msm_audio_amrnb_enc_config_v2 cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(cfg))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AMRNB_ENC_CONFIG_V2 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = amrnb_in_ioctl_shared(file, cmd, &cfg);
-		if (rc)
-			pr_err("%s: AUDIO_SET_AMRNB_ENC_CONFIG_V2 failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd=%d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_amrnb_enc_config_v2_32 {
-	u32 band_mode;
-	u32 dtx_enable;
-	u32 frame_format;
-};
-
-enum {
-	AUDIO_GET_AMRNB_ENC_CONFIG_V2_32 = _IOW(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+2),
-		struct msm_audio_amrnb_enc_config_v2_32),
-	AUDIO_SET_AMRNB_ENC_CONFIG_V2_32 = _IOR(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+3),
-		struct msm_audio_amrnb_enc_config_v2_32)
-};
-
-static long amrnb_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc =  amrnb_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AMRNB_ENC_CONFIG_V2_32: {
-		struct msm_audio_amrnb_enc_config_v2 *amrnb_config;
-		struct msm_audio_amrnb_enc_config_v2_32 amrnb_config_32;
-
-		memset(&amrnb_config_32, 0, sizeof(amrnb_config_32));
-
-		amrnb_config =
-		(struct msm_audio_amrnb_enc_config_v2 *)audio->enc_cfg;
-		amrnb_config_32.band_mode = amrnb_config->band_mode;
-		amrnb_config_32.dtx_enable = amrnb_config->dtx_enable;
-		amrnb_config_32.frame_format = amrnb_config->frame_format;
-
-		if (copy_to_user((void *)arg, &amrnb_config_32,
-			sizeof(amrnb_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AMRNB_ENC_CONFIG_V2_32 failed",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRNB_ENC_CONFIG_V2_32: {
-		struct msm_audio_amrnb_enc_config_v2_32 cfg_32;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AMRNB_ENC_CONFIG_V2_32 failed\n",
-					__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cmd = AUDIO_SET_AMRNB_ENC_CONFIG_V2;
-		rc = amrnb_in_ioctl_shared(file, cmd, &cfg_32);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AMRNB_ENC_CONFIG_V2 failed rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-#else
-#define amrnb_in_compat_ioctl NULL
-#endif
-
-static int amrnb_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_amrnb_enc_config_v2 *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_amrnb_enc_config_v2),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 32;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->band_mode = 7;
-	enc_cfg->dtx_enable = 0;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-			__func__);
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open amrnb encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_AMRNB,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: NT mode encoder success\n",
-				__func__, audio->ac->session);
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_AMRNB);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__, audio->ac->session,
-				rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: T mode encoder success\n",
-				__func__, audio->ac->session);
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = amrnb_in_compat_ioctl;
-	audio->enc_ioctl = amrnb_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= amrnb_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-	.compat_ioctl   = audio_in_compat_ioctl
-};
-
-struct miscdevice audio_amrnb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amrnb_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init amrnb_in_init(void)
-{
-	return misc_register(&audio_amrnb_in_misc);
-}
-
-device_initcall(amrnb_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/amrwb_in.c b/drivers/misc/qcom/qdsp6v2/amrwb_in.c
deleted file mode 100644
index 98c1911..0000000
--- a/drivers/misc/qcom/qdsp6v2/amrwb_in.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/* Copyright (c) 2011-2012, 2014, 2016-2017 The Linux Foundation.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/msm_audio_amrwb.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/compat.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((61+sizeof(struct meta_out_dsp)) * 10))
-
-static long amrwb_in_ioctl_shared(struct file *file,
-				  unsigned int cmd, void *arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_amrwb_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			pr_info("%s:AUDIO_START already over\n", __func__);
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-
-		rc = q6asm_enc_cfg_blk_amrwb(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->band_mode,
-			enc_cfg->dtx_enable);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd amrwb media format block failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed\n",
-				__func__, audio->ac->session);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n",
-				__func__, audio->ac->session,
-				audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:AUDIO_STOP\n", __func__);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRWB_ENC_CONFIG: {
-		struct msm_audio_amrwb_enc_config *cfg;
-		struct msm_audio_amrwb_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		cfg = (struct msm_audio_amrwb_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer for %s\n",
-					__func__, "AUDIO_SET_AMRWB_ENC_CONFIG");
-			rc = -EINVAL;
-			break;
-		}
-
-		if (cfg->band_mode > 8) {
-			pr_err("%s:session id %d: invalid band mode\n",
-				__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		/* ToDo: AMR WB encoder accepts values between 0-8
-		 * while openmax provides value between 9-17
-		 * as per spec
-		 */
-		enc_cfg->band_mode = cfg->band_mode;
-		enc_cfg->dtx_enable = (cfg->dtx_enable ? 1 : 0);
-		/* Currently DSP does not support different frameformat */
-		enc_cfg->frame_format = 0;
-		pr_debug("%s:session id %d: band_mode = 0x%x dtx_enable=0x%x\n",
-				__func__, audio->ac->session,
-				enc_cfg->band_mode, enc_cfg->dtx_enable);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long amrwb_in_ioctl(struct file *file,
-				  unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = amrwb_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AMRWB_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-				sizeof(struct msm_audio_amrwb_enc_config)))
-			pr_err("%s: copy_to_user for AUDIO_GET_AMRWB_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_AMRWB_ENC_CONFIG: {
-		struct msm_audio_amrwb_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(cfg))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AMRWB_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = amrwb_in_ioctl_shared(file, cmd, &cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_ENC_CONFIG failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_amrwb_enc_config_32 {
-	u32 band_mode;
-	u32 dtx_enable;
-	u32 frame_format;
-};
-
-enum {
-	AUDIO_GET_AMRWB_ENC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+0),
-		struct msm_audio_amrwb_enc_config_32),
-	AUDIO_SET_AMRWB_ENC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+1),
-		struct msm_audio_amrwb_enc_config_32)
-};
-
-static long amrwb_in_compat_ioctl(struct file *file,
-				  unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = amrwb_in_ioctl_shared(file, cmd, NULL);
-		break;
-	}
-	case AUDIO_GET_AMRWB_ENC_CONFIG_32: {
-		struct msm_audio_amrwb_enc_config *amrwb_config;
-		struct msm_audio_amrwb_enc_config_32 amrwb_config_32;
-
-		memset(&amrwb_config_32, 0, sizeof(amrwb_config_32));
-
-		amrwb_config =
-		(struct msm_audio_amrwb_enc_config *)audio->enc_cfg;
-		amrwb_config_32.band_mode = amrwb_config->band_mode;
-		amrwb_config_32.dtx_enable = amrwb_config->dtx_enable;
-		amrwb_config_32.frame_format = amrwb_config->frame_format;
-
-		if (copy_to_user((void *)arg, &amrwb_config_32,
-			sizeof(struct msm_audio_amrwb_enc_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AMRWB_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRWB_ENC_CONFIG_32: {
-		struct msm_audio_amrwb_enc_config cfg_32;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AMRWB_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cmd = AUDIO_SET_AMRWB_ENC_CONFIG;
-		rc = amrwb_in_ioctl_shared(file, cmd, &cfg_32);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_ENC_CONFIG failed. rc=%d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-#else
-#define amrwb_in_compat_ioctl NULL
-#endif
-
-static int amrwb_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_amrwb_enc_config *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_amrwb_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 32;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->band_mode = 8;
-	enc_cfg->dtx_enable = 0;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 16000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s:audio[%pK]: Could not allocate memory for audio client\n",
-			__func__, audio);
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open amrwb encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_AMRWB,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: NT mode encoder success\n",
-				__func__, audio->ac->session);
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_AMRWB);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__, audio->ac->session,
-				rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: T mode encoder success\n",
-				__func__, audio->ac->session);
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = amrwb_in_compat_ioctl;
-	audio->enc_ioctl = amrwb_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= amrwb_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-	.compat_ioctl   = audio_in_compat_ioctl
-};
-
-struct miscdevice audio_amrwb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amrwb_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init amrwb_in_init(void)
-{
-	return misc_register(&audio_amrwb_in_misc);
-}
-
-device_initcall(amrwb_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_aac.c b/drivers/misc/qcom/qdsp6v2/audio_aac.c
deleted file mode 100644
index 0f371fd..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_aac.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/* aac audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/msm_audio_aac.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-#define AUDIO_AAC_DUAL_MONO_INVALID -1
-#define PCM_BUFSZ_MIN_AAC	((8*1024) + sizeof(struct dec_meta_out))
-
-static struct miscdevice audio_aac_misc;
-static struct ws_mgr audio_aac_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_aac_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-				void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_aac_cfg aac_cfg;
-		struct msm_audio_aac_config *aac_config;
-		uint32_t sbr_ps = 0x00;
-
-		pr_debug("%s: AUDIO_START session_id[%d]\n", __func__,
-							audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac, 0, 0);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		/* turn on both sbr and ps */
-		rc = q6asm_enable_sbrps(audio->ac, sbr_ps);
-		if (rc < 0)
-			pr_err("sbr-ps enable failed\n");
-		aac_config = (struct msm_audio_aac_config *)audio->codec_cfg;
-		if (aac_config->sbr_ps_on_flag)
-			aac_cfg.aot = AAC_ENC_MODE_EAAC_P;
-		else if (aac_config->sbr_on_flag)
-			aac_cfg.aot = AAC_ENC_MODE_AAC_P;
-		else
-			aac_cfg.aot = AAC_ENC_MODE_AAC_LC;
-
-		switch (aac_config->format) {
-		case AUDIO_AAC_FORMAT_ADTS:
-			aac_cfg.format = 0x00;
-			break;
-		case AUDIO_AAC_FORMAT_LOAS:
-			aac_cfg.format = 0x01;
-			break;
-		case AUDIO_AAC_FORMAT_ADIF:
-			aac_cfg.format = 0x02;
-			break;
-		default:
-		case AUDIO_AAC_FORMAT_RAW:
-			aac_cfg.format = 0x03;
-		}
-		aac_cfg.ep_config = aac_config->ep_config;
-		aac_cfg.section_data_resilience =
-			aac_config->aac_section_data_resilience_flag;
-		aac_cfg.scalefactor_data_resilience =
-			aac_config->aac_scalefactor_data_resilience_flag;
-		aac_cfg.spectral_data_resilience =
-			aac_config->aac_spectral_data_resilience_flag;
-		aac_cfg.ch_cfg = audio->pcm_cfg.channel_count;
-		if (audio->feedback == TUNNEL_MODE) {
-			aac_cfg.sample_rate = aac_config->sample_rate;
-			aac_cfg.ch_cfg = aac_config->channel_configuration;
-		} else {
-			aac_cfg.sample_rate =  audio->pcm_cfg.sample_rate;
-			aac_cfg.ch_cfg = audio->pcm_cfg.channel_count;
-		}
-
-		pr_debug("%s:format=%x aot=%d  ch=%d sr=%d\n",
-			__func__, aac_cfg.format,
-			aac_cfg.aot, aac_cfg.ch_cfg,
-			aac_cfg.sample_rate);
-
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_aac(audio->ac, &aac_cfg);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			rc = enable_volume_ramp(audio);
-			if (rc < 0) {
-				pr_err("%s: Failed to enable volume ramp\n",
-					__func__);
-			}
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_info("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config *aac_config;
-		uint16_t sce_left = 1, sce_right = 2;
-
-		pr_debug("%s: AUDIO_SET_AAC_CONFIG\n", __func__);
-		aac_config = (struct msm_audio_aac_config *)arg;
-		if (aac_config == NULL) {
-			pr_err("%s: Invalid config pointer\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		memcpy(audio->codec_cfg, aac_config,
-				sizeof(struct msm_audio_aac_config));
-		/* PL_PR is 0 only need to check PL_SR */
-		if (aac_config->dual_mono_mode >
-		    AUDIO_AAC_DUAL_MONO_PL_SR) {
-			pr_err("%s:Invalid dual_mono mode =%d\n", __func__,
-			aac_config->dual_mono_mode);
-		} else {
-			/* convert the data from user into sce_left
-			 * and sce_right based on the definitions
-			 */
-			pr_debug("%s: modify dual_mono mode =%d\n", __func__,
-				 aac_config->dual_mono_mode);
-			switch (aac_config->dual_mono_mode) {
-			case AUDIO_AAC_DUAL_MONO_PL_PR:
-				sce_left = 1;
-				sce_right = 1;
-				break;
-			case AUDIO_AAC_DUAL_MONO_SL_SR:
-				sce_left = 2;
-				sce_right = 2;
-				break;
-			case AUDIO_AAC_DUAL_MONO_SL_PR:
-				sce_left = 2;
-				sce_right = 1;
-				break;
-			case AUDIO_AAC_DUAL_MONO_PL_SR:
-			default:
-				sce_left = 1;
-				sce_right = 2;
-				break;
-			}
-			rc = q6asm_cfg_dual_mono_aac(audio->ac,
-						sce_left, sce_right);
-			if (rc < 0)
-				pr_err("%s:asm cmd dualmono failed rc=%d\n",
-					 __func__, rc);
-		}
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_aac_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config aac_config;
-
-		pr_debug("%s: AUDIO_SET_AAC_CONFIG\n", __func__);
-		if (copy_from_user(&aac_config, (void *)arg,
-			sizeof(aac_config))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = audio_ioctl_shared(file, cmd, &aac_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-						__func__, rc);
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s[%pK]:Failed in utils_ioctl: %d\n",
-				__func__, audio, rc);
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_aac_config32 {
-	s16 format;
-	u16 audio_object;
-	u16 ep_config;	/* 0 ~ 3 useful only obj = ERLC */
-	u16 aac_section_data_resilience_flag;
-	u16 aac_scalefactor_data_resilience_flag;
-	u16 aac_spectral_data_resilience_flag;
-	u16 sbr_on_flag;
-	u16 sbr_ps_on_flag;
-	u16 dual_mono_mode;
-	u16 channel_configuration;
-	u16 sample_rate;
-};
-
-enum {
-	AUDIO_SET_AAC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_aac_config32),
-	AUDIO_GET_AAC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_aac_config32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config *aac_config;
-		struct msm_audio_aac_config32 aac_config_32;
-
-		aac_config = (struct msm_audio_aac_config *)audio->codec_cfg;
-		aac_config_32.format = aac_config->format;
-		aac_config_32.audio_object = aac_config->audio_object;
-		aac_config_32.ep_config = aac_config->ep_config;
-		aac_config_32.aac_section_data_resilience_flag =
-			aac_config->aac_section_data_resilience_flag;
-		aac_config_32.aac_scalefactor_data_resilience_flag =
-			 aac_config->aac_scalefactor_data_resilience_flag;
-		aac_config_32.aac_spectral_data_resilience_flag =
-			aac_config->aac_spectral_data_resilience_flag;
-		aac_config_32.sbr_on_flag = aac_config->sbr_on_flag;
-		aac_config_32.sbr_ps_on_flag = aac_config->sbr_ps_on_flag;
-		aac_config_32.dual_mono_mode = aac_config->dual_mono_mode;
-		aac_config_32.channel_configuration =
-					aac_config->channel_configuration;
-		aac_config_32.sample_rate = aac_config->sample_rate;
-
-		if (copy_to_user((void *)arg, &aac_config_32,
-			sizeof(aac_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config aac_config;
-		struct msm_audio_aac_config32 aac_config_32;
-
-		pr_debug("%s: AUDIO_SET_AAC_CONFIG\n", __func__);
-		if (copy_from_user(&aac_config_32, (void *)arg,
-			sizeof(aac_config_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		aac_config.format = aac_config_32.format;
-		aac_config.audio_object = aac_config_32.audio_object;
-		aac_config.ep_config = aac_config_32.ep_config;
-		aac_config.aac_section_data_resilience_flag =
-			aac_config_32.aac_section_data_resilience_flag;
-		aac_config.aac_scalefactor_data_resilience_flag =
-			aac_config_32.aac_scalefactor_data_resilience_flag;
-		aac_config.aac_spectral_data_resilience_flag =
-			aac_config_32.aac_spectral_data_resilience_flag;
-		aac_config.sbr_on_flag = aac_config_32.sbr_on_flag;
-		aac_config.sbr_ps_on_flag = aac_config_32.sbr_ps_on_flag;
-		aac_config.dual_mono_mode = aac_config_32.dual_mono_mode;
-		aac_config.channel_configuration =
-				aac_config_32.channel_configuration;
-		aac_config.sample_rate = aac_config_32.sample_rate;
-
-		cmd = AUDIO_SET_AAC_CONFIG;
-		rc = audio_ioctl_shared(file, cmd, &aac_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s[%pK]:Failed in utils_ioctl: %d\n",
-				__func__, audio, rc);
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-	struct msm_audio_aac_config *aac_config = NULL;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_aac_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_aac_config),
-					GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	aac_config = audio->codec_cfg;
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN_AAC;
-	audio->miscdevice = &audio_aac_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_aac_ws_mgr;
-	aac_config->dual_mono_mode = AUDIO_AAC_DUAL_MONO_INVALID;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_MPEG4_AAC);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open AAC decoder, expected frames is always 1
-		 * audio->buf_cfg.frames_per_buf = 0x01;
-		 */
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_MPEG4_AAC);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_aac_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_aac_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:aacdec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_aac_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_aac_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_aac",
-	.fops = &audio_aac_fops,
-};
-
-static int __init audio_aac_init(void)
-{
-	int ret = misc_register(&audio_aac_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_aac_misc.this_device, true);
-	audio_aac_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_aac_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_aac_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_alac.c b/drivers/misc/qcom/qdsp6v2/audio_alac.c
deleted file mode 100644
index d0b86c6..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_alac.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/types.h>
-#include <linux/msm_audio_alac.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_alac_misc;
-static struct ws_mgr audio_alac_ws_mgr;
-
-static const struct file_operations audio_alac_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-
-static struct dentry *config_debugfs_create_file(const char *name, void *data)
-{
-	return debugfs_create_file(name, S_IFREG | 0444,
-				NULL, (void *)data, &audio_alac_debug_fops);
-}
-
-static int alac_channel_map(u8 *channel_mapping, uint32_t channels);
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_alac_cfg alac_cfg;
-		struct msm_audio_alac_config *alac_config;
-		u8 channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL];
-
-		memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-		if (alac_channel_map(channel_mapping,
-			audio->pcm_cfg.channel_count)) {
-			pr_err("%s: setting channel map failed %d\n",
-					__func__, audio->pcm_cfg.channel_count);
-		}
-
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm_v2(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count,
-					16, /*bits per sample*/
-					false, false, channel_mapping);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		alac_config = (struct msm_audio_alac_config *)audio->codec_cfg;
-		alac_cfg.frame_length = alac_config->frameLength;
-		alac_cfg.compatible_version = alac_config->compatVersion;
-		alac_cfg.bit_depth = alac_config->bitDepth;
-		alac_cfg.pb = alac_config->pb;
-		alac_cfg.mb = alac_config->mb;
-		alac_cfg.kb = alac_config->kb;
-		alac_cfg.num_channels = alac_config->channelCount;
-		alac_cfg.max_run = alac_config->maxRun;
-		alac_cfg.max_frame_bytes = alac_config->maxSize;
-		alac_cfg.avg_bit_rate = alac_config->averageBitRate;
-		alac_cfg.sample_rate = alac_config->sampleRate;
-		alac_cfg.channel_layout_tag = alac_config->channelLayout;
-		pr_debug("%s: frame_length %d compatible_version %d bit_depth %d pb %d mb %d kb %d num_channels %d max_run %d max_frame_bytes %d avg_bit_rate %d sample_rate %d channel_layout_tag %d\n",
-				__func__, alac_config->frameLength,
-				alac_config->compatVersion,
-				alac_config->bitDepth, alac_config->pb,
-				alac_config->mb, alac_config->kb,
-				alac_config->channelCount, alac_config->maxRun,
-				alac_config->maxSize,
-				alac_config->averageBitRate,
-				alac_config->sampleRate,
-				alac_config->channelLayout);
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_alac(audio->ac, &alac_cfg,
-							audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_ALAC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_alac_config))) {
-			pr_err("%s:copy_to_user for AUDIO_GET_ALAC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_ALAC_CONFIG: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_alac_config))) {
-			pr_err("%s:copy_from_user for AUDIO_SET_ALAC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	default: {
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_alac_config_32 {
-	u32 frameLength;
-	u8 compatVersion;
-	u8 bitDepth;
-	u8 pb;
-	u8 mb;
-	u8 kb;
-	u8 channelCount;
-	u16 maxRun;
-	u32 maxSize;
-	u32 averageBitRate;
-	u32 sampleRate;
-	u32 channelLayout;
-};
-
-enum {
-	AUDIO_GET_ALAC_CONFIG_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_alac_config_32),
-	AUDIO_SET_ALAC_CONFIG_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_alac_config_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_ALAC_CONFIG_32: {
-		struct msm_audio_alac_config *alac_config;
-		struct msm_audio_alac_config_32 alac_config_32;
-
-		memset(&alac_config_32, 0, sizeof(alac_config_32));
-
-		alac_config = (struct msm_audio_alac_config *)audio->codec_cfg;
-		alac_config_32.frameLength = alac_config->frameLength;
-		alac_config_32.compatVersion =
-				alac_config->compatVersion;
-		alac_config_32.bitDepth = alac_config->bitDepth;
-		alac_config_32.pb = alac_config->pb;
-		alac_config_32.mb = alac_config->mb;
-		alac_config_32.kb = alac_config->kb;
-		alac_config_32.channelCount = alac_config->channelCount;
-		alac_config_32.maxRun = alac_config->maxRun;
-		alac_config_32.maxSize = alac_config->maxSize;
-		alac_config_32.averageBitRate = alac_config->averageBitRate;
-		alac_config_32.sampleRate = alac_config->sampleRate;
-		alac_config_32.channelLayout = alac_config->channelLayout;
-
-		if (copy_to_user((void *)arg, &alac_config_32,
-			sizeof(alac_config_32))) {
-			pr_err("%s: copy_to_user for GET_ALAC_CONFIG_32 failed\n",
-				 __func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_ALAC_CONFIG_32: {
-		struct msm_audio_alac_config *alac_config;
-		struct msm_audio_alac_config_32 alac_config_32;
-
-		if (copy_from_user(&alac_config_32, (void *)arg,
-			sizeof(alac_config_32))) {
-			pr_err("%s: copy_from_user for SET_ALAC_CONFIG_32 failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		alac_config = (struct msm_audio_alac_config *)audio->codec_cfg;
-		alac_config->frameLength = alac_config_32.frameLength;
-		alac_config->compatVersion =
-				alac_config_32.compatVersion;
-		alac_config->bitDepth = alac_config_32.bitDepth;
-		alac_config->pb = alac_config_32.pb;
-		alac_config->mb = alac_config_32.mb;
-		alac_config->kb = alac_config_32.kb;
-		alac_config->channelCount = alac_config_32.channelCount;
-		alac_config->maxRun = alac_config_32.maxRun;
-		alac_config->maxSize = alac_config_32.maxSize;
-		alac_config->averageBitRate = alac_config_32.averageBitRate;
-		alac_config->sampleRate = alac_config_32.sampleRate;
-		alac_config->channelLayout = alac_config_32.channelLayout;
-
-		break;
-	}
-	default: {
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_alac_" + 5];
-
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-	if (!audio)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_alac_config),
-					GFP_KERNEL);
-	if (!audio->codec_cfg) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_alac_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_alac_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_ALAC);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open ALAC decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_ALAC);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-	snprintf(name, sizeof(name), "msm_alac_%04x", audio->ac->session);
-	audio->dentry = config_debugfs_create_file(name, (void *)audio);
-
-	if (IS_ERR_OR_NULL(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-	pr_debug("%s:alacdec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static int alac_channel_map(u8 *channel_mapping, uint32_t channels)
-{
-	u8 *lchannel_mapping;
-
-	lchannel_mapping = channel_mapping;
-	pr_debug("%s:  channels passed: %d\n", __func__, channels);
-	if (channels == 1)  {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-	} else if (channels == 2) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-	} else if (channels == 3) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-	} else if (channels == 4) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_CS;
-	} else if (channels == 5) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-	} else if (channels == 6) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_LFE;
-	} else if (channels == 7) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_CS;
-		lchannel_mapping[6] = PCM_CHANNEL_LFE;
-	} else if (channels == 8) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FLC;
-		lchannel_mapping[2] = PCM_CHANNEL_FRC;
-		lchannel_mapping[3] = PCM_CHANNEL_FL;
-		lchannel_mapping[4] = PCM_CHANNEL_FR;
-		lchannel_mapping[5] = PCM_CHANNEL_LS;
-		lchannel_mapping[6] = PCM_CHANNEL_RS;
-		lchannel_mapping[7] = PCM_CHANNEL_LFE;
-	} else {
-		pr_err("%s: ERROR.unsupported num_ch = %u\n",
-				__func__, channels);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static const struct file_operations audio_alac_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_alac_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_alac",
-	.fops = &audio_alac_fops,
-};
-
-static int __init audio_alac_init(void)
-{
-	int ret = misc_register(&audio_alac_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_alac_misc.this_device, true);
-	audio_alac_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_alac_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_alac_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_amrnb.c b/drivers/misc/qcom/qdsp6v2/audio_amrnb.c
deleted file mode 100644
index 950098b..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_amrnb.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* amrnb audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/types.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_amrnb_misc;
-static struct ws_mgr audio_amrnb_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_amrnb_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-			       unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-				audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("%s: pcm output block config failed rc=%d\n",
-					__func__, rc);
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s: Audio Start procedure failed rc=%d\n",
-				__func__, rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling compat ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrnb_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_amrnb_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_amrnb_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_AMRNB);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_AMRNB);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_amrnb_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_amrnb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:amrnb decoder open success, session_id = %d\n", __func__,
-				audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrnb_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl,
-};
-
-static struct miscdevice audio_amrnb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrnb",
-	.fops = &audio_amrnb_fops,
-};
-
-static int __init audio_amrnb_init(void)
-{
-	int ret = misc_register(&audio_amrnb_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_amrnb_misc.this_device, true);
-	audio_amrnb_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_amrnb_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_amrnb_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_amrwb.c b/drivers/misc/qcom/qdsp6v2/audio_amrwb.c
deleted file mode 100644
index cb5db0d..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_amrwb.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* amrwb audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/compat.h>
-#include <linux/types.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_amrwb_misc;
-static struct ws_mgr audio_amrwb_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_amrwb_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-			       unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-				audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("%s: pcm output block config failed rc=%d\n",
-					__func__, rc);
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s: Audio Start procedure failed rc=%d\n",
-				__func__, rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-				audio->ac->session,
-				audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling compat ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrwb_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_amrwb_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_amrwb_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_AMRWB);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_AMRWB);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_amrwb_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_amrwb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s: AMRWB dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrwb_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl,
-};
-
-static struct miscdevice audio_amrwb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrwb",
-	.fops = &audio_amrwb_fops,
-};
-
-static int __init audio_amrwb_init(void)
-{
-	int ret = misc_register(&audio_amrwb_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_amrwb_misc.this_device, true);
-	audio_amrwb_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_amrwb_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_amrwb_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_amrwbplus.c b/drivers/misc/qcom/qdsp6v2/audio_amrwbplus.c
deleted file mode 100644
index 458a80c..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_amrwbplus.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/* amr-wbplus audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/msm_audio_amrwbplus.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_amrwbplus_misc;
-static struct ws_mgr audio_amrwbplus_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_amrwbplus_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-static void config_debug_fs(struct q6audio_aio *audio)
-{
-	if (audio != NULL) {
-		char name[sizeof("msm_amrwbplus_") + 5];
-
-		snprintf(name, sizeof(name), "msm_amrwbplus_%04x",
-			audio->ac->session);
-		audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-						NULL, (void *)audio,
-						&audio_amrwbplus_debug_fops);
-		if (IS_ERR(audio->dentry))
-			pr_debug("debugfs_create_file failed\n");
-	}
-}
-#else
-static void config_debug_fs(struct q6audio_aio *audio)
-{
-}
-#endif
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-					void *arg)
-{
-	struct asm_amrwbplus_cfg q6_amrwbplus_cfg;
-	struct msm_audio_amrwbplus_config_v2 *amrwbplus_drv_config;
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-		pr_err("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-			audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-			audio->pcm_cfg.sample_rate,
-			audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		amrwbplus_drv_config =
-		(struct msm_audio_amrwbplus_config_v2 *)audio->codec_cfg;
-
-		q6_amrwbplus_cfg.size_bytes     =
-			amrwbplus_drv_config->size_bytes;
-		q6_amrwbplus_cfg.version        =
-			amrwbplus_drv_config->version;
-		q6_amrwbplus_cfg.num_channels   =
-			amrwbplus_drv_config->num_channels;
-		q6_amrwbplus_cfg.amr_band_mode  =
-			amrwbplus_drv_config->amr_band_mode;
-		q6_amrwbplus_cfg.amr_dtx_mode   =
-			amrwbplus_drv_config->amr_dtx_mode;
-		q6_amrwbplus_cfg.amr_frame_fmt  =
-			amrwbplus_drv_config->amr_frame_fmt;
-		q6_amrwbplus_cfg.amr_lsf_idx    =
-			amrwbplus_drv_config->amr_lsf_idx;
-
-		rc = q6asm_media_format_block_amrwbplus(audio->ac,
-							&q6_amrwbplus_cfg);
-		if (rc < 0) {
-			pr_err("q6asm_media_format_block_amrwb+ failed...\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("%s:AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-			audio->ac->session,
-			audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-
-		break;
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AMRWBPLUS_CONFIG_V2: {
-		if ((audio) && (arg) && (audio->codec_cfg)) {
-			if (copy_to_user((void *)arg, audio->codec_cfg,
-				sizeof(struct msm_audio_amrwbplus_config_v2))) {
-				rc = -EFAULT;
-				pr_err("%s: copy_to_user for AUDIO_GET_AMRWBPLUS_CONFIG_V2 failed\n",
-					__func__);
-				break;
-			}
-			} else {
-				pr_err("%s: wb+ config v2 invalid parameters\n"
-					, __func__);
-				rc = -EFAULT;
-				break;
-			}
-		break;
-	}
-	case AUDIO_SET_AMRWBPLUS_CONFIG_V2: {
-		if ((audio) && (arg) && (audio->codec_cfg)) {
-			if (copy_from_user(audio->codec_cfg, (void *)arg,
-				sizeof(struct msm_audio_amrwbplus_config_v2))) {
-				rc = -EFAULT;
-				pr_err("%s: copy_from_user for AUDIO_SET_AMRWBPLUS_CONFIG_V2 failed\n",
-					__func__);
-				break;
-			}
-			} else {
-				pr_err("%s: wb+ config invalid parameters\n",
-					__func__);
-				rc = -EFAULT;
-				break;
-			}
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-		break;
-	}
-	}
-	return rc;
-}
-#ifdef CONFIG_COMPAT
-struct msm_audio_amrwbplus_config_v2_32 {
-	u32 size_bytes;
-	u32 version;
-	u32 num_channels;
-	u32 amr_band_mode;
-	u32 amr_dtx_mode;
-	u32 amr_frame_fmt;
-	u32 amr_lsf_idx;
-};
-
-enum {
-	AUDIO_GET_AMRWBPLUS_CONFIG_V2_32 = _IOR(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+2),
-		struct msm_audio_amrwbplus_config_v2_32),
-	AUDIO_SET_AMRWBPLUS_CONFIG_V2_32 = _IOW(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+3),
-		struct msm_audio_amrwbplus_config_v2_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-					unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AMRWBPLUS_CONFIG_V2_32: {
-		if (audio && arg && (audio->codec_cfg)) {
-			struct msm_audio_amrwbplus_config_v2 *amrwbplus_config;
-			struct msm_audio_amrwbplus_config_v2_32
-						amrwbplus_config_32;
-
-			memset(&amrwbplus_config_32, 0,
-					sizeof(amrwbplus_config_32));
-
-			amrwbplus_config =
-				(struct msm_audio_amrwbplus_config_v2 *)
-				audio->codec_cfg;
-			amrwbplus_config_32.size_bytes =
-					amrwbplus_config->size_bytes;
-			amrwbplus_config_32.version =
-					amrwbplus_config->version;
-			amrwbplus_config_32.num_channels =
-					amrwbplus_config->num_channels;
-			amrwbplus_config_32.amr_band_mode =
-					amrwbplus_config->amr_band_mode;
-			amrwbplus_config_32.amr_dtx_mode =
-					amrwbplus_config->amr_dtx_mode;
-			amrwbplus_config_32.amr_frame_fmt =
-					amrwbplus_config->amr_frame_fmt;
-			amrwbplus_config_32.amr_lsf_idx =
-					amrwbplus_config->amr_lsf_idx;
-
-			if (copy_to_user((void *)arg, &amrwbplus_config_32,
-				sizeof(amrwbplus_config_32))) {
-				rc = -EFAULT;
-				pr_err("%s: copy_to_user for AUDIO_GET_AMRWBPLUS_CONFIG_V2_32 failed\n"
-					, __func__);
-			}
-		} else {
-			pr_err("%s: wb+ Get config v2 invalid parameters\n"
-				, __func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_AMRWBPLUS_CONFIG_V2_32: {
-		if ((audio) && (arg) && (audio->codec_cfg)) {
-			struct msm_audio_amrwbplus_config_v2 *amrwbplus_config;
-			struct msm_audio_amrwbplus_config_v2_32
-							amrwbplus_config_32;
-
-			if (copy_from_user(&amrwbplus_config_32, (void *)arg,
-			sizeof(struct msm_audio_amrwbplus_config_v2_32))) {
-				rc = -EFAULT;
-				pr_err("%s: copy_from_user for AUDIO_SET_AMRWBPLUS_CONFIG_V2_32 failed\n"
-					, __func__);
-				break;
-			}
-			amrwbplus_config =
-			 (struct msm_audio_amrwbplus_config_v2 *)
-						audio->codec_cfg;
-			amrwbplus_config->size_bytes =
-					amrwbplus_config_32.size_bytes;
-			amrwbplus_config->version =
-					amrwbplus_config_32.version;
-			amrwbplus_config->num_channels =
-					amrwbplus_config_32.num_channels;
-			amrwbplus_config->amr_band_mode =
-					amrwbplus_config_32.amr_band_mode;
-			amrwbplus_config->amr_dtx_mode =
-					amrwbplus_config_32.amr_dtx_mode;
-			amrwbplus_config->amr_frame_fmt =
-					amrwbplus_config_32.amr_frame_fmt;
-			amrwbplus_config->amr_lsf_idx =
-					amrwbplus_config_32.amr_lsf_idx;
-		} else {
-			pr_err("%s: wb+ config invalid parameters\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->codec_cfg =
-	kzalloc(sizeof(struct msm_audio_amrwbplus_config_v2), GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_amrwbplus_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_amrwbplus_ws_mgr;
-
-	audio->ac =
-	q6asm_audio_client_alloc((app_cb) q6_audio_cb, (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					FORMAT_AMR_WB_PLUS);
-		if (rc < 0) {
-			pr_err("amrwbplus NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_AMR_WB_PLUS);
-		if (rc < 0) {
-			pr_err("wb+ T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("audio_amrwbplus Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-	config_debug_fs(audio);
-	pr_debug("%s: AMRWBPLUS dec success mode[%d]session[%d]\n", __func__,
-		audio->feedback,
-		audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrwbplus_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_amrwbplus_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrwbplus",
-	.fops = &audio_amrwbplus_fops,
-};
-
-static int __init audio_amrwbplus_init(void)
-{
-	int ret = misc_register(&audio_amrwbplus_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_amrwbplus_misc.this_device, true);
-	audio_amrwbplus_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_amrwbplus_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_amrwbplus_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_ape.c b/drivers/misc/qcom/qdsp6v2/audio_ape.c
deleted file mode 100644
index d7dc064..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_ape.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/types.h>
-#include <linux/msm_audio_ape.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_ape_misc;
-static struct ws_mgr audio_ape_ws_mgr;
-
-static const struct file_operations audio_ape_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-static struct dentry *config_debugfs_create_file(const char *name, void *data)
-{
-	return debugfs_create_file(name, S_IFREG | 0444,
-			NULL, (void *)data, &audio_ape_debug_fops);
-}
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_ape_cfg ape_cfg;
-		struct msm_audio_ape_config *ape_config;
-
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		ape_config = (struct msm_audio_ape_config *)audio->codec_cfg;
-		ape_cfg.compatible_version = ape_config->compatibleVersion;
-		ape_cfg.compression_level = ape_config->compressionLevel;
-		ape_cfg.format_flags = ape_config->formatFlags;
-		ape_cfg.blocks_per_frame = ape_config->blocksPerFrame;
-		ape_cfg.final_frame_blocks = ape_config->finalFrameBlocks;
-		ape_cfg.total_frames = ape_config->totalFrames;
-		ape_cfg.bits_per_sample = ape_config->bitsPerSample;
-		ape_cfg.num_channels = ape_config->numChannels;
-		ape_cfg.sample_rate = ape_config->sampleRate;
-		ape_cfg.seek_table_present = ape_config->seekTablePresent;
-		pr_debug("%s: compatibleVersion %d compressionLevel %d formatFlags %d blocksPerFrame %d finalFrameBlocks %d totalFrames %d bitsPerSample %d numChannels %d sampleRate %d seekTablePresent %d\n",
-				__func__, ape_config->compatibleVersion,
-				ape_config->compressionLevel,
-				ape_config->formatFlags,
-				ape_config->blocksPerFrame,
-				ape_config->finalFrameBlocks,
-				ape_config->totalFrames,
-				ape_config->bitsPerSample,
-				ape_config->numChannels,
-				ape_config->sampleRate,
-				ape_config->seekTablePresent);
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_ape(audio->ac, &ape_cfg,
-							audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_APE_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_ape_config))) {
-			pr_err("%s:copy_to_user for AUDIO_GET_APE_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_APE_CONFIG: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_ape_config))) {
-			pr_err("%s:copy_from_user for AUDIO_SET_APE_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_ape_config_32 {
-	u16 compatibleVersion;
-	u16 compressionLevel;
-	u32 formatFlags;
-	u32 blocksPerFrame;
-	u32 finalFrameBlocks;
-	u32 totalFrames;
-	u16 bitsPerSample;
-	u16 numChannels;
-	u32 sampleRate;
-	u32 seekTablePresent;
-
-};
-
-enum {
-	AUDIO_GET_APE_CONFIG_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_ape_config_32),
-	AUDIO_SET_APE_CONFIG_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_ape_config_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_APE_CONFIG_32: {
-		struct msm_audio_ape_config *ape_config;
-		struct msm_audio_ape_config_32 ape_config_32;
-
-		memset(&ape_config_32, 0, sizeof(ape_config_32));
-
-		ape_config = (struct msm_audio_ape_config *)audio->codec_cfg;
-		ape_config_32.compatibleVersion = ape_config->compatibleVersion;
-		ape_config_32.compressionLevel =
-				ape_config->compressionLevel;
-		ape_config_32.formatFlags = ape_config->formatFlags;
-		ape_config_32.blocksPerFrame = ape_config->blocksPerFrame;
-		ape_config_32.finalFrameBlocks = ape_config->finalFrameBlocks;
-		ape_config_32.totalFrames = ape_config->totalFrames;
-		ape_config_32.bitsPerSample = ape_config->bitsPerSample;
-		ape_config_32.numChannels = ape_config->numChannels;
-		ape_config_32.sampleRate = ape_config->sampleRate;
-		ape_config_32.seekTablePresent = ape_config->seekTablePresent;
-
-		if (copy_to_user((void *)arg, &ape_config_32,
-			sizeof(ape_config_32))) {
-			pr_err("%s: copy_to_user for GET_APE_CONFIG_32 failed\n",
-				 __func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_APE_CONFIG_32: {
-		struct msm_audio_ape_config *ape_config;
-		struct msm_audio_ape_config_32 ape_config_32;
-
-		if (copy_from_user(&ape_config_32, (void *)arg,
-			sizeof(ape_config_32))) {
-			pr_err("%s: copy_from_user for SET_APE_CONFIG_32 failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		ape_config = (struct msm_audio_ape_config *)audio->codec_cfg;
-		ape_config->compatibleVersion = ape_config_32.compatibleVersion;
-		ape_config->compressionLevel =
-				ape_config_32.compressionLevel;
-		ape_config->formatFlags = ape_config_32.formatFlags;
-		ape_config->blocksPerFrame = ape_config_32.blocksPerFrame;
-		ape_config->finalFrameBlocks = ape_config_32.finalFrameBlocks;
-		ape_config->totalFrames = ape_config_32.totalFrames;
-		ape_config->bitsPerSample = ape_config_32.bitsPerSample;
-		ape_config->numChannels = ape_config_32.numChannels;
-		ape_config->sampleRate = ape_config_32.sampleRate;
-		ape_config->seekTablePresent = ape_config_32.seekTablePresent;
-
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_ape_" + 5];
-
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-	if (!audio)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_ape_config),
-					GFP_KERNEL);
-	if (!audio->codec_cfg) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_ape_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_ape_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_APE);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open APE decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_APE);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-	snprintf(name, sizeof(name), "msm_ape_%04x", audio->ac->session);
-	audio->dentry = config_debugfs_create_file(name, (void *)audio);
-
-	if (IS_ERR_OR_NULL(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-	pr_debug("%s:apedec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_ape_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_ape_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_ape",
-	.fops = &audio_ape_fops,
-};
-
-static int __init audio_ape_init(void)
-{
-	int ret = misc_register(&audio_ape_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_ape_misc.this_device, true);
-	audio_ape_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_ape_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_ape_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_evrc.c b/drivers/misc/qcom/qdsp6v2/audio_evrc.c
deleted file mode 100644
index 8776231..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_evrc.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* evrc audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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 "audio_utils_aio.h"
-
-static struct miscdevice audio_evrc_misc;
-static struct ws_mgr audio_evrc_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_evrc_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_evrc_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_evrc_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_evrc_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_EVRC);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_EVRC);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_evrc_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_evrc_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_evrc_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-};
-
-static struct miscdevice audio_evrc_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_evrc",
-	.fops = &audio_evrc_fops,
-};
-
-static int __init audio_evrc_init(void)
-{
-	int ret = misc_register(&audio_evrc_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_evrc_misc.this_device, true);
-	audio_evrc_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_evrc_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_evrc_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_g711alaw.c b/drivers/misc/qcom/qdsp6v2/audio_g711alaw.c
deleted file mode 100644
index 24f87e4..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_g711alaw.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/types.h>
-#include <linux/msm_audio_g711_dec.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_g711alaw_misc;
-static struct ws_mgr audio_g711_ws_mgr;
-
-static const struct file_operations audio_g711_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-
-static struct dentry *config_debugfs_create_file(const char *name, void *data)
-{
-	return debugfs_create_file(name, S_IFREG | 0444,
-				NULL, (void *)data, &audio_g711_debug_fops);
-}
-
-static int g711_channel_map(u8 *channel_mapping, uint32_t channels);
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_g711_dec_cfg g711_dec_cfg;
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		u8 channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL];
-
-		memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-		memset(&g711_dec_cfg, 0, sizeof(g711_dec_cfg));
-
-		if (g711_channel_map(channel_mapping,
-			audio->pcm_cfg.channel_count)) {
-			pr_err("%s: setting channel map failed %d\n",
-					__func__, audio->pcm_cfg.channel_count);
-		}
-
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm_v2(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count,
-					16, /*bits per sample*/
-					false, false, channel_mapping);
-			if (rc < 0) {
-				pr_err("%s: pcm output block config failed rc=%d\n",
-						 __func__, rc);
-				break;
-			}
-		}
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_cfg.sample_rate = g711_dec_config->sample_rate;
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_g711(audio->ac, &g711_dec_cfg,
-							audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("%s: cmd media format block failed rc=%d\n",
-				__func__, rc);
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s: Audio Start procedure failed rc=%d\n",
-						__func__, rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START success enable[%d]\n",
-					 __func__, audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_G711_DEC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_g711_dec_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_G711_DEC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_DEC_CONFIG: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_g711_dec_config))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_G711_DEC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default: {
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s: Failed in audio_aio_ioctl: %d cmd=%d\n",
-				__func__, rc, cmd);
-		break;
-	}
-	}
-	return  rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_g711_dec_config_32 {
-	u32 sample_rate;
-};
-
-enum {
-	AUDIO_SET_G711_DEC_CONFIG_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_dec_config_32),
-	AUDIO_GET_G711_DEC_CONFIG_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_dec_config_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_G711_DEC_CONFIG_32: {
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		struct msm_audio_g711_dec_config_32 g711_dec_config_32;
-
-		memset(&g711_dec_config_32, 0, sizeof(g711_dec_config_32));
-
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_config_32.sample_rate = g711_dec_config->sample_rate;
-
-		if (copy_to_user((void *)arg, &g711_dec_config_32,
-			sizeof(g711_dec_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_G711_DEC_CONFIG_32 failed\n",
-				 __func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_DEC_CONFIG_32: {
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		struct msm_audio_g711_dec_config_32 g711_dec_config_32;
-
-		memset(&g711_dec_config_32, 0, sizeof(g711_dec_config_32));
-
-		if (copy_from_user(&g711_dec_config_32, (void *)arg,
-			sizeof(g711_dec_config_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_G711_DEC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_config->sample_rate = g711_dec_config_32.sample_rate;
-
-		break;
-	}
-	default: {
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s: Failed in audio_aio_compat_ioctl: %d cmd=%d\n",
-				__func__, rc, cmd);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_g711_" + 5];
-
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (!audio)
-		return -ENOMEM;
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_g711_dec_config),
-					GFP_KERNEL);
-	if (!audio->codec_cfg) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_g711alaw_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_g711_ws_mgr;
-
-	init_waitqueue_head(&audio->event_wait);
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-					 __func__);
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */ /*foramt:G711_ALAW*/
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_G711_ALAW_FS);
-		if (rc < 0) {
-			pr_err("%s: NT mode Open failed rc=%d\n", __func__, rc);
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open G711 decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_G711_ALAW_FS);
-		if (rc < 0) {
-			pr_err("%s: T mode Open failed rc=%d\n", __func__, rc);
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("%s: %d mode is not supported mode\n",
-				__func__, file->f_mode);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	snprintf(name, sizeof(name), "msm_g711_%04x", audio->ac->session);
-	audio->dentry = config_debugfs_create_file(name, (void *)audio);
-
-	if (IS_ERR_OR_NULL(audio->dentry))
-		pr_debug("%s: debugfs_create_file failed\n", __func__);
-	pr_debug("%s: g711dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static int g711_channel_map(u8 *channel_mapping, uint32_t channels)
-{
-	u8 *lchannel_mapping;
-
-	lchannel_mapping = channel_mapping;
-	pr_debug("%s: channels passed: %d\n", __func__, channels);
-	if (channels == 1)  {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-	} else if (channels == 2) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-	} else if (channels == 3) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-	} else if (channels == 4) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_CS;
-	} else if (channels == 5) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-	} else if (channels == 6) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_LFE;
-	} else if (channels == 7) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_CS;
-		lchannel_mapping[6] = PCM_CHANNEL_LFE;
-	} else if (channels == 8) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FLC;
-		lchannel_mapping[2] = PCM_CHANNEL_FRC;
-		lchannel_mapping[3] = PCM_CHANNEL_FL;
-		lchannel_mapping[4] = PCM_CHANNEL_FR;
-		lchannel_mapping[5] = PCM_CHANNEL_LS;
-		lchannel_mapping[6] = PCM_CHANNEL_RS;
-		lchannel_mapping[7] = PCM_CHANNEL_LFE;
-	} else {
-		pr_err("%s: ERROR.unsupported num_ch = %u\n",
-				__func__, channels);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static const struct file_operations audio_g711_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.compat_ioctl = audio_compat_ioctl,
-	.fsync = audio_aio_fsync,
-};
-
-static struct miscdevice audio_g711alaw_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_g711alaw",
-	.fops = &audio_g711_fops,
-};
-
-static int __init audio_g711alaw_init(void)
-{
-	int ret = misc_register(&audio_g711alaw_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_g711alaw_misc.this_device, true);
-	audio_g711_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_g711_ws_mgr.ws_lock);
-
-	return ret;
-}
-static void __exit audio_g711alaw_exit(void)
-{
-	misc_deregister(&audio_g711alaw_misc);
-	mutex_destroy(&audio_g711_ws_mgr.ws_lock);
-}
-
-device_initcall(audio_g711alaw_init);
-__exitcall(audio_g711alaw_exit);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_g711mlaw.c b/drivers/misc/qcom/qdsp6v2/audio_g711mlaw.c
deleted file mode 100644
index 10d3680..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_g711mlaw.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/types.h>
-#include <linux/msm_audio_g711_dec.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_g711mlaw_misc;
-static struct ws_mgr audio_g711_ws_mgr;
-
-static const struct file_operations audio_g711_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-
-static struct dentry *config_debugfs_create_file(const char *name, void *data)
-{
-	return debugfs_create_file(name, S_IFREG | 0444,
-				NULL, (void *)data, &audio_g711_debug_fops);
-}
-
-static int g711_channel_map(u8 *channel_mapping, uint32_t channels);
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_g711_dec_cfg g711_dec_cfg;
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		u8 channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL];
-
-		memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-		memset(&g711_dec_cfg, 0, sizeof(g711_dec_cfg));
-
-		if (g711_channel_map(channel_mapping,
-			audio->pcm_cfg.channel_count)) {
-			pr_err("%s: setting channel map failed %d\n",
-					__func__, audio->pcm_cfg.channel_count);
-		}
-
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm_v2(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count,
-					16, /*bits per sample*/
-					false, false, channel_mapping);
-			if (rc < 0) {
-				pr_err("%s: pcm output block config failed rc=%d\n",
-						 __func__, rc);
-				break;
-			}
-		}
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_cfg.sample_rate = g711_dec_config->sample_rate;
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_g711(audio->ac, &g711_dec_cfg,
-							audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("%s: cmd media format block failed rc=%d\n",
-				__func__, rc);
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s: Audio Start procedure failed rc=%d\n",
-						__func__, rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START success enable[%d]\n",
-						__func__, audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_G711_DEC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_g711_dec_config))) {
-			pr_err("%s: AUDIO_GET_G711_DEC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_DEC_CONFIG: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_g711_dec_config))) {
-			pr_err("%s: AUDIO_SET_G711_DEC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default: {
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s: Failed in audio_aio_ioctl: %d cmd=%d\n",
-				__func__, rc, cmd);
-		break;
-	}
-	}
-	return  rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_g711_dec_config_32 {
-	u32 sample_rate;
-};
-
-enum {
-	AUDIO_SET_G711_DEC_CONFIG_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_dec_config_32),
-	AUDIO_GET_G711_DEC_CONFIG_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_dec_config_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_G711_DEC_CONFIG_32: {
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		struct msm_audio_g711_dec_config_32 g711_dec_config_32;
-
-		memset(&g711_dec_config_32, 0, sizeof(g711_dec_config_32));
-
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_config_32.sample_rate = g711_dec_config->sample_rate;
-
-		if (copy_to_user((void *)arg, &g711_dec_config_32,
-			sizeof(g711_dec_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_G711_DEC_CONFIG failed\n",
-				 __func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_DEC_CONFIG_32: {
-		struct msm_audio_g711_dec_config *g711_dec_config;
-		struct msm_audio_g711_dec_config_32 g711_dec_config_32;
-
-		memset(&g711_dec_config_32, 0, sizeof(g711_dec_config_32));
-
-		if (copy_from_user(&g711_dec_config_32, (void *)arg,
-			sizeof(g711_dec_config_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_G711_DEC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		g711_dec_config =
-			(struct msm_audio_g711_dec_config *)audio->codec_cfg;
-		g711_dec_config->sample_rate = g711_dec_config_32.sample_rate;
-
-		break;
-	}
-	default: {
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("%s: Failed in audio_aio_compat_ioctl: %d cmd=%d\n",
-				__func__, rc, cmd);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_g711_" + 5];
-
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (!audio)
-		return -ENOMEM;
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_g711_dec_config),
-					GFP_KERNEL);
-	if (!audio->codec_cfg) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_g711mlaw_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_g711_ws_mgr;
-
-	init_waitqueue_head(&audio->event_wait);
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-					__func__);
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */ /*foramt:G711_ALAW*/
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_G711_MLAW_FS);
-		if (rc < 0) {
-			pr_err("%s: NT mode Open failed rc=%d\n", __func__, rc);
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open G711 decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_G711_MLAW_FS);
-		if (rc < 0) {
-			pr_err("%s: T mode Open failed rc=%d\n", __func__, rc);
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("%s: %d mode is not supported\n", __func__,
-					file->f_mode);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	snprintf(name, sizeof(name), "msm_g711_%04x", audio->ac->session);
-	audio->dentry = config_debugfs_create_file(name, (void *)audio);
-
-	if (IS_ERR_OR_NULL(audio->dentry))
-		pr_debug("%s: debugfs_create_file failed\n", __func__);
-	pr_debug("%s: g711dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static int g711_channel_map(u8 *channel_mapping, uint32_t channels)
-{
-	u8 *lchannel_mapping;
-
-	lchannel_mapping = channel_mapping;
-	pr_debug("%s: channels passed: %d\n", __func__, channels);
-	if (channels == 1)  {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-	} else if (channels == 2) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-	} else if (channels == 3) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-	} else if (channels == 4) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_CS;
-	} else if (channels == 5) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-	} else if (channels == 6) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_LFE;
-	} else if (channels == 7) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FL;
-		lchannel_mapping[2] = PCM_CHANNEL_FR;
-		lchannel_mapping[3] = PCM_CHANNEL_LS;
-		lchannel_mapping[4] = PCM_CHANNEL_RS;
-		lchannel_mapping[5] = PCM_CHANNEL_CS;
-		lchannel_mapping[6] = PCM_CHANNEL_LFE;
-	} else if (channels == 8) {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-		lchannel_mapping[1] = PCM_CHANNEL_FLC;
-		lchannel_mapping[2] = PCM_CHANNEL_FRC;
-		lchannel_mapping[3] = PCM_CHANNEL_FL;
-		lchannel_mapping[4] = PCM_CHANNEL_FR;
-		lchannel_mapping[5] = PCM_CHANNEL_LS;
-		lchannel_mapping[6] = PCM_CHANNEL_RS;
-		lchannel_mapping[7] = PCM_CHANNEL_LFE;
-	} else {
-		pr_err("%s: ERROR.unsupported num_ch = %u\n",
-				__func__, channels);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static const struct file_operations audio_g711_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.compat_ioctl = audio_compat_ioctl,
-	.fsync = audio_aio_fsync,
-};
-
-static struct miscdevice audio_g711mlaw_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_g711mlaw",
-	.fops = &audio_g711_fops,
-};
-
-static int __init audio_g711mlaw_init(void)
-{
-	int ret = misc_register(&audio_g711mlaw_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_g711mlaw_misc.this_device, true);
-	audio_g711_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_g711_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-static void __exit audio_g711mlaw_exit(void)
-{
-	misc_deregister(&audio_g711mlaw_misc);
-	mutex_destroy(&audio_g711_ws_mgr.ws_lock);
-}
-
-device_initcall(audio_g711mlaw_init);
-__exitcall(audio_g711mlaw_exit);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_hwacc_effects.c b/drivers/misc/qcom/qdsp6v2/audio_hwacc_effects.c
deleted file mode 100644
index d20b518..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_hwacc_effects.c
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/msm_audio.h>
-#include <linux/compat.h>
-#include "q6audio_common.h"
-#include "audio_utils_aio.h"
-#include <sound/msm-audio-effects-q6-v2.h>
-
-#define MAX_CHANNELS_SUPPORTED		8
-#define WAIT_TIMEDOUT_DURATION_SECS	1
-
-struct q6audio_effects {
-	wait_queue_head_t		read_wait;
-	wait_queue_head_t		write_wait;
-
-	struct audio_client             *ac;
-	struct msm_hwacc_effects_config  config;
-
-	struct mutex			lock;
-
-	atomic_t			in_count;
-	atomic_t			out_count;
-
-	int				opened;
-	int				started;
-	int				buf_alloc;
-	struct msm_nt_eff_all_config audio_effects;
-};
-
-static void audio_effects_init_pp(struct audio_client *ac)
-{
-	int ret = 0;
-	struct asm_softvolume_params softvol = {
-		.period = SOFT_VOLUME_PERIOD,
-		.step = SOFT_VOLUME_STEP,
-		.rampingcurve = SOFT_VOLUME_CURVE_LINEAR,
-	};
-
-	if (!ac) {
-		pr_err("%s: audio client null to init pp\n", __func__);
-		return;
-	}
-	ret = q6asm_set_softvolume_v2(ac, &softvol,
-				      SOFT_VOLUME_INSTANCE_1);
-	if (ret < 0)
-		pr_err("%s: Send SoftVolume Param failed ret=%d\n",
-			__func__, ret);
-}
-
-static void audio_effects_deinit_pp(struct audio_client *ac)
-{
-	if (!ac) {
-		pr_err("%s: audio client null to deinit pp\n", __func__);
-		return;
-	}
-}
-
-static void audio_effects_event_handler(uint32_t opcode, uint32_t token,
-				 uint32_t *payload,  void *priv)
-{
-	struct q6audio_effects *effects;
-
-	if (!payload || !priv) {
-		pr_err("%s: invalid data to handle events, payload: %pK, priv: %pK\n",
-			__func__, payload, priv);
-		return;
-	}
-
-	effects = (struct q6audio_effects *)priv;
-	switch (opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2: {
-		atomic_inc(&effects->out_count);
-		wake_up(&effects->write_wait);
-		break;
-	}
-	case ASM_DATA_EVENT_READ_DONE_V2: {
-		atomic_inc(&effects->in_count);
-		wake_up(&effects->read_wait);
-		break;
-	}
-	case APR_BASIC_RSP_RESULT: {
-		pr_debug("%s: APR_BASIC_RSP_RESULT Cmd[0x%x] Status[0x%x]\n",
-			 __func__, payload[0], payload[1]);
-		switch (payload[0]) {
-		case ASM_SESSION_CMD_RUN_V2:
-			pr_debug("ASM_SESSION_CMD_RUN_V2\n");
-			break;
-		default:
-			pr_debug("%s: Payload = [0x%x] stat[0x%x]\n",
-				 __func__, payload[0], payload[1]);
-			break;
-		}
-		break;
-	}
-	default:
-		pr_debug("%s: Unhandled Event 0x%x token = 0x%x\n",
-			 __func__, opcode, token);
-		break;
-	}
-}
-
-static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
-				      unsigned long arg)
-{
-	struct q6audio_effects *effects = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s: AUDIO_START\n", __func__);
-
-		mutex_lock(&effects->lock);
-
-		rc = q6asm_open_read_write_v2(effects->ac,
-					FORMAT_LINEAR_PCM,
-					FORMAT_MULTI_CHANNEL_LINEAR_PCM,
-					effects->config.meta_mode_enabled,
-					effects->config.output.bits_per_sample,
-					true /*overwrite topology*/,
-					ASM_STREAM_POSTPROC_TOPO_ID_HPX_MASTER);
-		if (rc < 0) {
-			pr_err("%s: Open failed for hw accelerated effects:rc=%d\n",
-				__func__, rc);
-			rc = -EINVAL;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-		effects->opened = 1;
-
-		pr_debug("%s: dec buf size: %d, num_buf: %d, enc buf size: %d, num_buf: %d\n",
-			 __func__, effects->config.output.buf_size,
-			 effects->config.output.num_buf,
-			 effects->config.input.buf_size,
-			 effects->config.input.num_buf);
-		rc = q6asm_audio_client_buf_alloc_contiguous(IN, effects->ac,
-					effects->config.output.buf_size,
-					effects->config.output.num_buf);
-		if (rc < 0) {
-			pr_err("%s: Write buffer Allocation failed rc = %d\n",
-				__func__, rc);
-			rc = -ENOMEM;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-		atomic_set(&effects->in_count, effects->config.input.num_buf);
-		rc = q6asm_audio_client_buf_alloc_contiguous(OUT, effects->ac,
-					effects->config.input.buf_size,
-					effects->config.input.num_buf);
-		if (rc < 0) {
-			pr_err("%s: Read buffer Allocation failed rc = %d\n",
-				__func__, rc);
-			rc = -ENOMEM;
-			mutex_unlock(&effects->lock);
-			goto readbuf_fail;
-		}
-		atomic_set(&effects->out_count, effects->config.output.num_buf);
-		effects->buf_alloc = 1;
-
-		pr_debug("%s: enc: sample_rate: %d, num_channels: %d\n",
-			 __func__, effects->config.input.sample_rate,
-			effects->config.input.num_channels);
-		rc = q6asm_enc_cfg_blk_pcm(effects->ac,
-					   effects->config.input.sample_rate,
-					   effects->config.input.num_channels);
-		if (rc < 0) {
-			pr_err("%s: pcm read block config failed\n", __func__);
-			rc = -EINVAL;
-			mutex_unlock(&effects->lock);
-			goto cfg_fail;
-		}
-		pr_debug("%s: dec: sample_rate: %d, num_channels: %d, bit_width: %d\n",
-			 __func__, effects->config.output.sample_rate,
-			effects->config.output.num_channels,
-			effects->config.output.bits_per_sample);
-		rc = q6asm_media_format_block_pcm_format_support(
-				effects->ac, effects->config.output.sample_rate,
-				effects->config.output.num_channels,
-				effects->config.output.bits_per_sample);
-		if (rc < 0) {
-			pr_err("%s: pcm write format block config failed\n",
-				__func__);
-			rc = -EINVAL;
-			mutex_unlock(&effects->lock);
-			goto cfg_fail;
-		}
-
-		audio_effects_init_pp(effects->ac);
-
-		rc = q6asm_run(effects->ac, 0x00, 0x00, 0x00);
-		if (!rc)
-			effects->started = 1;
-		else {
-			effects->started = 0;
-			pr_err("%s: ASM run state failed\n", __func__);
-		}
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_WRITE: {
-		char *bufptr = NULL;
-		uint32_t idx = 0;
-		uint32_t size = 0;
-
-		mutex_lock(&effects->lock);
-
-		if (!effects->started) {
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-
-		rc = wait_event_timeout(effects->write_wait,
-					atomic_read(&effects->out_count),
-					WAIT_TIMEDOUT_DURATION_SECS * HZ);
-		if (!rc) {
-			pr_err("%s: write wait_event_timeout\n", __func__);
-			rc = -EFAULT;
-			 mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-		if (!atomic_read(&effects->out_count)) {
-			pr_err("%s: pcm stopped out_count 0\n", __func__);
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-
-		bufptr = q6asm_is_cpu_buf_avail(IN, effects->ac, &size, &idx);
-		if (bufptr) {
-			if ((effects->config.buf_cfg.output_len > size) ||
-				copy_from_user(bufptr, (void *)arg,
-					effects->config.buf_cfg.output_len)) {
-				rc = -EFAULT;
-				mutex_unlock(&effects->lock);
-				goto ioctl_fail;
-			}
-			rc = q6asm_write(effects->ac,
-					 effects->config.buf_cfg.output_len,
-					 0, 0, NO_TIMESTAMP);
-			if (rc < 0) {
-				rc = -EFAULT;
-				mutex_unlock(&effects->lock);
-				goto ioctl_fail;
-			}
-			atomic_dec(&effects->out_count);
-		} else {
-			pr_err("%s: AUDIO_EFFECTS_WRITE: Buffer dropped\n",
-				__func__);
-		}
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_READ: {
-		char *bufptr = NULL;
-		uint32_t idx = 0;
-		uint32_t size = 0;
-
-		mutex_lock(&effects->lock);
-
-		if (!effects->started) {
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-
-		atomic_set(&effects->in_count, 0);
-
-		q6asm_read_v2(effects->ac, effects->config.buf_cfg.input_len);
-		/* Read might fail initially, don't error out */
-		if (rc < 0)
-			pr_err("%s: read failed\n", __func__);
-
-		rc = wait_event_timeout(effects->read_wait,
-					atomic_read(&effects->in_count),
-					WAIT_TIMEDOUT_DURATION_SECS * HZ);
-		if (!rc) {
-			pr_err("%s: read wait_event_timeout\n", __func__);
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-		if (!atomic_read(&effects->in_count)) {
-			pr_err("%s: pcm stopped in_count 0\n", __func__);
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			goto ioctl_fail;
-		}
-
-		bufptr = q6asm_is_cpu_buf_avail(OUT, effects->ac, &size, &idx);
-		if (bufptr) {
-			if (!((void *)arg)) {
-				rc = -EFAULT;
-				mutex_unlock(&effects->lock);
-				goto ioctl_fail;
-			}
-			if ((effects->config.buf_cfg.input_len > size) ||
-				copy_to_user((void *)arg, bufptr,
-					  effects->config.buf_cfg.input_len)) {
-				rc = -EFAULT;
-				mutex_unlock(&effects->lock);
-				goto ioctl_fail;
-			}
-		}
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	default:
-		pr_err("%s: Invalid effects config module\n", __func__);
-		rc = -EINVAL;
-		break;
-	}
-ioctl_fail:
-	return rc;
-readbuf_fail:
-	q6asm_audio_client_buf_free_contiguous(IN,
-					effects->ac);
-	return rc;
-cfg_fail:
-	q6asm_audio_client_buf_free_contiguous(IN,
-					effects->ac);
-	q6asm_audio_client_buf_free_contiguous(OUT,
-					effects->ac);
-	effects->buf_alloc = 0;
-	return rc;
-}
-
-static long audio_effects_set_pp_param(struct q6audio_effects *effects,
-				long *values)
-{
-	int rc = 0;
-	int effects_module = values[0];
-
-	switch (effects_module) {
-	case VIRTUALIZER_MODULE:
-		pr_debug("%s: VIRTUALIZER_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_virtualizer_handler(
-				effects->ac,
-				&(effects->audio_effects.virtualizer),
-				(long *)&values[1]);
-		break;
-	case REVERB_MODULE:
-		pr_debug("%s: REVERB_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_reverb_handler(effects->ac,
-				 &(effects->audio_effects.reverb),
-				 (long *)&values[1]);
-		break;
-	case BASS_BOOST_MODULE:
-		pr_debug("%s: BASS_BOOST_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_bass_boost_handler(
-				effects->ac,
-				&(effects->audio_effects.bass_boost),
-				(long *)&values[1]);
-		break;
-	case PBE_MODULE:
-		pr_debug("%s: PBE_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_pbe_handler(
-				effects->ac,
-				&(effects->audio_effects.pbe),
-				(long *)&values[1]);
-		break;
-	case EQ_MODULE:
-		pr_debug("%s: EQ_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_popless_eq_handler(
-				effects->ac,
-				&(effects->audio_effects.equalizer),
-				(long *)&values[1]);
-		break;
-	case SOFT_VOLUME_MODULE:
-		pr_debug("%s: SA PLUS VOLUME_MODULE\n", __func__);
-		msm_audio_effects_volume_handler_v2(effects->ac,
-				&(effects->audio_effects.saplus_vol),
-				(long *)&values[1], SOFT_VOLUME_INSTANCE_1);
-		break;
-	case SOFT_VOLUME2_MODULE:
-		pr_debug("%s: TOPOLOGY SWITCH VOLUME MODULE\n",
-			 __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(
-			effects_module, effects->ac->topology))
-			msm_audio_effects_volume_handler_v2(effects->ac,
-			      &(effects->audio_effects.topo_switch_vol),
-			      (long *)&values[1], SOFT_VOLUME_INSTANCE_2);
-		break;
-	default:
-		pr_err("%s: Invalid effects config module\n", __func__);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long audio_effects_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct q6audio_effects *effects = file->private_data;
-	int rc = 0;
-	long argvalues[MAX_PP_PARAMS_SZ] = {0};
-
-	switch (cmd) {
-	case AUDIO_SET_EFFECTS_CONFIG: {
-		pr_debug("%s: AUDIO_SET_EFFECTS_CONFIG\n", __func__);
-		mutex_lock(&effects->lock);
-		memset(&effects->config, 0, sizeof(effects->config));
-		if (copy_from_user(&effects->config, (void *)arg,
-				   sizeof(effects->config))) {
-			pr_err("%s: copy from user for AUDIO_SET_EFFECTS_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		pr_debug("%s: write buf_size: %d, num_buf: %d, sample_rate: %d, channel: %d\n",
-			 __func__, effects->config.output.buf_size,
-			 effects->config.output.num_buf,
-			 effects->config.output.sample_rate,
-			 effects->config.output.num_channels);
-		pr_debug("%s: read buf_size: %d, num_buf: %d, sample_rate: %d, channel: %d\n",
-			 __func__, effects->config.input.buf_size,
-			 effects->config.input.num_buf,
-			 effects->config.input.sample_rate,
-			 effects->config.input.num_channels);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_SET_BUF_LEN: {
-		mutex_lock(&effects->lock);
-		if (copy_from_user(&effects->config.buf_cfg, (void *)arg,
-				   sizeof(effects->config.buf_cfg))) {
-			pr_err("%s: copy from user for AUDIO_EFFECTS_SET_BUF_LEN failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		pr_debug("%s: write buf len: %d, read buf len: %d\n",
-			 __func__, effects->config.buf_cfg.output_len,
-			 effects->config.buf_cfg.input_len);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_GET_BUF_AVAIL: {
-		struct msm_hwacc_buf_avail buf_avail;
-
-		buf_avail.input_num_avail = atomic_read(&effects->in_count);
-		buf_avail.output_num_avail = atomic_read(&effects->out_count);
-		mutex_lock(&effects->lock);
-		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
-			 __func__, buf_avail.output_num_avail,
-			 buf_avail.input_num_avail);
-		if (copy_to_user((void *)arg, &buf_avail,
-				   sizeof(buf_avail))) {
-			pr_err("%s: copy to user for AUDIO_EFFECTS_GET_NUM_BUF_AVAIL failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_SET_PP_PARAMS: {
-		mutex_lock(&effects->lock);
-		if (copy_from_user(argvalues, (void *)arg,
-				   MAX_PP_PARAMS_SZ*sizeof(long))) {
-			pr_err("%s: copy from user for pp params failed\n",
-				__func__);
-			mutex_unlock(&effects->lock);
-			return -EFAULT;
-		}
-		rc = audio_effects_set_pp_param(effects, argvalues);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	default:
-		pr_debug("%s: Calling shared ioctl\n", __func__);
-		rc = audio_effects_shared_ioctl(file, cmd, arg);
-		break;
-	}
-	if (rc)
-		pr_err("%s: cmd 0x%x failed\n", __func__, cmd);
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_hwacc_data_config32 {
-	__u32 buf_size;
-	__u32 num_buf;
-	__u32 num_channels;
-	__u8 channel_map[MAX_CHANNELS_SUPPORTED];
-	__u32 sample_rate;
-	__u32 bits_per_sample;
-};
-
-struct msm_hwacc_buf_cfg32 {
-	__u32 input_len;
-	__u32 output_len;
-};
-
-struct msm_hwacc_buf_avail32 {
-	__u32 input_num_avail;
-	__u32 output_num_avail;
-};
-
-struct msm_hwacc_effects_config32 {
-	struct msm_hwacc_data_config32 input;
-	struct msm_hwacc_data_config32 output;
-	struct msm_hwacc_buf_cfg32 buf_cfg;
-	__u32 meta_mode_enabled;
-	__u32 overwrite_topology;
-	__s32 topology;
-};
-
-enum {
-	AUDIO_SET_EFFECTS_CONFIG32 = _IOW(AUDIO_IOCTL_MAGIC, 99,
-					  struct msm_hwacc_effects_config32),
-	AUDIO_EFFECTS_SET_BUF_LEN32 = _IOW(AUDIO_IOCTL_MAGIC, 100,
-					   struct msm_hwacc_buf_cfg32),
-	AUDIO_EFFECTS_GET_BUF_AVAIL32 = _IOW(AUDIO_IOCTL_MAGIC, 101,
-					     struct msm_hwacc_buf_avail32),
-	AUDIO_EFFECTS_WRITE32 = _IOW(AUDIO_IOCTL_MAGIC, 102, compat_uptr_t),
-	AUDIO_EFFECTS_READ32 = _IOWR(AUDIO_IOCTL_MAGIC, 103, compat_uptr_t),
-	AUDIO_EFFECTS_SET_PP_PARAMS32 = _IOW(AUDIO_IOCTL_MAGIC, 104,
-					   compat_uptr_t),
-	AUDIO_START32 = _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned int),
-};
-
-static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,
-					unsigned long arg)
-{
-	struct q6audio_effects *effects = file->private_data;
-	int rc = 0, i;
-
-	switch (cmd) {
-	case AUDIO_SET_EFFECTS_CONFIG32: {
-		struct msm_hwacc_effects_config32 config32;
-		struct msm_hwacc_effects_config *config = &effects->config;
-
-		mutex_lock(&effects->lock);
-		memset(&effects->config, 0, sizeof(effects->config));
-		if (copy_from_user(&config32, (void *)arg,
-				   sizeof(config32))) {
-			pr_err("%s: copy to user for AUDIO_SET_EFFECTS_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			break;
-		}
-		config->input.buf_size = config32.input.buf_size;
-		config->input.num_buf = config32.input.num_buf;
-		config->input.num_channels = config32.input.num_channels;
-		config->input.sample_rate = config32.input.sample_rate;
-		config->input.bits_per_sample = config32.input.bits_per_sample;
-		config->input.buf_size = config32.input.buf_size;
-		for (i = 0; i < MAX_CHANNELS_SUPPORTED; i++)
-			config->input.channel_map[i] =
-						config32.input.channel_map[i];
-		config->output.buf_size = config32.output.buf_size;
-		config->output.num_buf = config32.output.num_buf;
-		config->output.num_channels = config32.output.num_channels;
-		config->output.sample_rate = config32.output.sample_rate;
-		config->output.bits_per_sample =
-					 config32.output.bits_per_sample;
-		config->output.buf_size = config32.output.buf_size;
-		for (i = 0; i < MAX_CHANNELS_SUPPORTED; i++)
-			config->output.channel_map[i] =
-						config32.output.channel_map[i];
-		config->buf_cfg.input_len = config32.buf_cfg.input_len;
-		config->buf_cfg.output_len = config32.buf_cfg.output_len;
-		config->meta_mode_enabled = config32.meta_mode_enabled;
-		config->overwrite_topology = config32.overwrite_topology;
-		config->topology = config32.topology;
-		pr_debug("%s: write buf_size: %d, num_buf: %d, sample_rate: %d, channels: %d\n",
-			 __func__, effects->config.output.buf_size,
-			 effects->config.output.num_buf,
-			 effects->config.output.sample_rate,
-			 effects->config.output.num_channels);
-		pr_debug("%s: read buf_size: %d, num_buf: %d, sample_rate: %d, channels: %d\n",
-			 __func__, effects->config.input.buf_size,
-			 effects->config.input.num_buf,
-			 effects->config.input.sample_rate,
-			 effects->config.input.num_channels);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_SET_BUF_LEN32: {
-		struct msm_hwacc_buf_cfg32 buf_cfg32;
-		struct msm_hwacc_effects_config *config = &effects->config;
-
-		mutex_lock(&effects->lock);
-		if (copy_from_user(&buf_cfg32, (void *)arg,
-				   sizeof(buf_cfg32))) {
-			pr_err("%s: copy from user for AUDIO_EFFECTS_SET_BUF_LEN failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&effects->lock);
-			break;
-		}
-		config->buf_cfg.input_len = buf_cfg32.input_len;
-		config->buf_cfg.output_len = buf_cfg32.output_len;
-		pr_debug("%s: write buf len: %d, read buf len: %d\n",
-			 __func__, effects->config.buf_cfg.output_len,
-			 effects->config.buf_cfg.input_len);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_GET_BUF_AVAIL32: {
-		struct msm_hwacc_buf_avail32 buf_avail;
-
-		memset(&buf_avail, 0, sizeof(buf_avail));
-
-		mutex_lock(&effects->lock);
-		buf_avail.input_num_avail = atomic_read(&effects->in_count);
-		buf_avail.output_num_avail = atomic_read(&effects->out_count);
-		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
-			 __func__, buf_avail.output_num_avail,
-			 buf_avail.input_num_avail);
-		if (copy_to_user((void *)arg, &buf_avail,
-				   sizeof(buf_avail))) {
-			pr_err("%s: copy to user for AUDIO_EFFECTS_GET_NUM_BUF_AVAIL failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_EFFECTS_SET_PP_PARAMS32: {
-		long argvalues[MAX_PP_PARAMS_SZ] = {0};
-		int argvalues32[MAX_PP_PARAMS_SZ] = {0};
-
-		mutex_lock(&effects->lock);
-		if (copy_from_user(argvalues32, (void *)arg,
-				   MAX_PP_PARAMS_SZ*sizeof(int))) {
-			pr_err("%s: copy from user failed for pp params\n",
-				__func__);
-			mutex_unlock(&effects->lock);
-			return -EFAULT;
-		}
-		for (i = 0; i < MAX_PP_PARAMS_SZ; i++)
-			argvalues[i] = argvalues32[i];
-
-		rc = audio_effects_set_pp_param(effects, argvalues);
-		mutex_unlock(&effects->lock);
-		break;
-	}
-	case AUDIO_START32: {
-		rc = audio_effects_shared_ioctl(file, AUDIO_START, arg);
-		break;
-	}
-	case AUDIO_EFFECTS_WRITE32: {
-		rc = audio_effects_shared_ioctl(file, AUDIO_EFFECTS_WRITE, arg);
-		break;
-	}
-	case AUDIO_EFFECTS_READ32: {
-		rc = audio_effects_shared_ioctl(file, AUDIO_EFFECTS_READ, arg);
-		break;
-	}
-	default:
-		pr_debug("%s: unhandled ioctl\n", __func__);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-#endif
-
-static int audio_effects_release(struct inode *inode, struct file *file)
-{
-	struct q6audio_effects *effects = file->private_data;
-	int rc = 0;
-
-	if (!effects) {
-		pr_err("%s: effect is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (effects->opened) {
-		rc = wait_event_timeout(effects->write_wait,
-					atomic_read(&effects->out_count),
-					WAIT_TIMEDOUT_DURATION_SECS * HZ);
-		if (!rc)
-			pr_err("%s: write wait_event_timeout failed\n",
-				__func__);
-		rc = wait_event_timeout(effects->read_wait,
-					atomic_read(&effects->in_count),
-					WAIT_TIMEDOUT_DURATION_SECS * HZ);
-		if (!rc)
-			pr_err("%s: read wait_event_timeout failed\n",
-				__func__);
-		rc = q6asm_cmd(effects->ac, CMD_CLOSE);
-		if (rc < 0)
-			pr_err("%s[%pK]:Failed to close the session rc=%d\n",
-				__func__, effects, rc);
-		effects->opened = 0;
-		effects->started = 0;
-
-		audio_effects_deinit_pp(effects->ac);
-	}
-
-	if (effects->buf_alloc) {
-		q6asm_audio_client_buf_free_contiguous(IN, effects->ac);
-		q6asm_audio_client_buf_free_contiguous(OUT, effects->ac);
-	}
-	q6asm_audio_client_free(effects->ac);
-
-	mutex_destroy(&effects->lock);
-	kfree(effects);
-
-	pr_debug("%s: close session success\n", __func__);
-	return rc;
-}
-
-static int audio_effects_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_effects *effects;
-	int rc = 0;
-
-	effects = kzalloc(sizeof(struct q6audio_effects), GFP_KERNEL);
-	if (!effects)
-		return -ENOMEM;
-
-	effects->ac = q6asm_audio_client_alloc(
-					(app_cb)audio_effects_event_handler,
-					(void *)effects);
-	if (!effects->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-			__func__);
-		kfree(effects);
-		return -ENOMEM;
-	}
-
-	init_waitqueue_head(&effects->read_wait);
-	init_waitqueue_head(&effects->write_wait);
-	mutex_init(&effects->lock);
-
-	effects->opened = 0;
-	effects->started = 0;
-	effects->buf_alloc = 0;
-	file->private_data = effects;
-	pr_debug("%s: open session success\n", __func__);
-	return rc;
-}
-
-static const struct file_operations audio_effects_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_effects_open,
-	.release = audio_effects_release,
-	.unlocked_ioctl = audio_effects_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl = audio_effects_compat_ioctl,
-#endif
-};
-
-struct miscdevice audio_effects_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_hweffects",
-	.fops = &audio_effects_fops,
-};
-
-static int __init audio_effects_init(void)
-{
-	return misc_register(&audio_effects_misc);
-}
-
-device_initcall(audio_effects_init);
-MODULE_DESCRIPTION("Audio hardware accelerated effects driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/qcom/qdsp6v2/audio_mp3.c b/drivers/misc/qcom/qdsp6v2/audio_mp3.c
deleted file mode 100644
index 0b10c7a..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_mp3.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* mp3 audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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 "audio_utils_aio.h"
-
-static struct miscdevice audio_mp3_misc;
-static struct ws_mgr audio_mp3_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_mp3_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			rc = enable_volume_ramp(audio);
-			if (rc < 0) {
-				pr_err("%s: Failed to enable volume ramp\n",
-					__func__);
-			}
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_info("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_mp3_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_mp3_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_mp3_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_MP3);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open MP3 decoder, expected frames is always 1
-		 * audio->buf_cfg.frames_per_buf = 0x01;
-		 */
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_MP3);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_mp3_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_mp3_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:mp3dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_mp3_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-};
-
-static struct miscdevice audio_mp3_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_mp3",
-	.fops = &audio_mp3_fops,
-};
-
-static int __init audio_mp3_init(void)
-{
-	int ret = misc_register(&audio_mp3_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_mp3_misc.this_device, true);
-	audio_mp3_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_mp3_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_mp3_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_multi_aac.c b/drivers/misc/qcom/qdsp6v2/audio_multi_aac.c
deleted file mode 100644
index 01c3dc5a..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_multi_aac.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/* aac audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/msm_audio_aac.h>
-#include <linux/compat.h>
-#include <soc/qcom/socinfo.h>
-#include "audio_utils_aio.h"
-
-#define AUDIO_AAC_DUAL_MONO_INVALID -1
-
-
-/* Default number of pre-allocated event packets */
-#define PCM_BUFSZ_MIN_AACM	((8*1024) + sizeof(struct dec_meta_out))
-static struct miscdevice audio_multiaac_misc;
-static struct ws_mgr audio_multiaac_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_aac_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_aac_cfg aac_cfg;
-		struct msm_audio_aac_config *aac_config;
-		uint32_t sbr_ps = 0x00;
-
-		aac_config = (struct msm_audio_aac_config *)audio->codec_cfg;
-		if (audio->feedback == TUNNEL_MODE) {
-			aac_cfg.sample_rate = aac_config->sample_rate;
-			aac_cfg.ch_cfg = aac_config->channel_configuration;
-		} else {
-			aac_cfg.sample_rate =  audio->pcm_cfg.sample_rate;
-			aac_cfg.ch_cfg = audio->pcm_cfg.channel_count;
-		}
-		pr_debug("%s: AUDIO_START session_id[%d]\n", __func__,
-						audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm_native(audio->ac,
-				aac_cfg.sample_rate,
-				aac_cfg.ch_cfg);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		/* turn on both sbr and ps */
-		rc = q6asm_enable_sbrps(audio->ac, sbr_ps);
-		if (rc < 0)
-			pr_err("sbr-ps enable failed\n");
-		if (aac_config->sbr_ps_on_flag)
-			aac_cfg.aot = AAC_ENC_MODE_EAAC_P;
-		else if (aac_config->sbr_on_flag)
-			aac_cfg.aot = AAC_ENC_MODE_AAC_P;
-		else
-			aac_cfg.aot = AAC_ENC_MODE_AAC_LC;
-
-		switch (aac_config->format) {
-		case AUDIO_AAC_FORMAT_ADTS:
-			aac_cfg.format = 0x00;
-			break;
-		case AUDIO_AAC_FORMAT_LOAS:
-			aac_cfg.format = 0x01;
-			break;
-		case AUDIO_AAC_FORMAT_ADIF:
-			aac_cfg.format = 0x02;
-			break;
-		default:
-		case AUDIO_AAC_FORMAT_RAW:
-			aac_cfg.format = 0x03;
-		}
-		aac_cfg.ep_config = aac_config->ep_config;
-		aac_cfg.section_data_resilience =
-			aac_config->aac_section_data_resilience_flag;
-		aac_cfg.scalefactor_data_resilience =
-			aac_config->aac_scalefactor_data_resilience_flag;
-		aac_cfg.spectral_data_resilience =
-			aac_config->aac_spectral_data_resilience_flag;
-
-		pr_debug("%s:format=%x aot=%d  ch=%d sr=%d\n",
-			__func__, aac_cfg.format,
-			aac_cfg.aot, aac_cfg.ch_cfg,
-			aac_cfg.sample_rate);
-
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_multi_aac(audio->ac, &aac_cfg);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = q6asm_set_encdec_chan_map(audio->ac, 2);
-		if (rc < 0) {
-			pr_err("%s: cmd set encdec_chan_map failed\n",
-				__func__);
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_info("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config *aac_config;
-		uint16_t sce_left = 1, sce_right = 2;
-
-		if (arg == NULL) {
-			pr_err("%s: NULL config pointer\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		memcpy(audio->codec_cfg, arg,
-				sizeof(struct msm_audio_aac_config));
-		aac_config = audio->codec_cfg;
-		if (aac_config->dual_mono_mode >
-		    AUDIO_AAC_DUAL_MONO_PL_SR) {
-			pr_err("%s:AUDIO_SET_AAC_CONFIG: Invalid dual_mono mode =%d\n",
-				 __func__, aac_config->dual_mono_mode);
-		} else {
-			/* convert the data from user into sce_left
-			 * and sce_right based on the definitions
-			 */
-			pr_debug("%s: AUDIO_SET_AAC_CONFIG: modify dual_mono mode =%d\n",
-				 __func__, aac_config->dual_mono_mode);
-			switch (aac_config->dual_mono_mode) {
-			case AUDIO_AAC_DUAL_MONO_PL_PR:
-				sce_left = 1;
-				sce_right = 1;
-				break;
-			case AUDIO_AAC_DUAL_MONO_SL_SR:
-				sce_left = 2;
-				sce_right = 2;
-				break;
-			case AUDIO_AAC_DUAL_MONO_SL_PR:
-				sce_left = 2;
-				sce_right = 1;
-				break;
-			case AUDIO_AAC_DUAL_MONO_PL_SR:
-			default:
-				sce_left = 1;
-				sce_right = 2;
-				break;
-			}
-			rc = q6asm_cfg_dual_mono_aac(audio->ac,
-						sce_left, sce_right);
-			if (rc < 0)
-				pr_err("%s: asm cmd dualmono failed rc=%d\n",
-							 __func__, rc);
-		}			break;
-		break;
-	}
-	case AUDIO_SET_AAC_MIX_CONFIG:	{
-		u32 *mix_coeff = (u32 *)arg;
-
-		if (!arg) {
-			pr_err("%s: Invalid param for %s\n",
-				__func__, "AUDIO_SET_AAC_MIX_CONFIG");
-			rc = -EINVAL;
-			break;
-		}
-		pr_debug("%s, AUDIO_SET_AAC_MIX_CONFIG", __func__);
-		pr_debug("%s, value of coeff = %d",
-					__func__, *mix_coeff);
-		q6asm_cfg_aac_sel_mix_coef(audio->ac, *mix_coeff);
-		if (rc < 0)
-			pr_err("%s asm aac_sel_mix_coef failed rc=%d\n",
-				 __func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_aac_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG: {
-		struct msm_audio_aac_config aac_config;
-
-		if (copy_from_user(&aac_config, (void *)arg,
-			sizeof(aac_config))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_CONFIG failed\n"
-				, __func__);
-			rc = -EFAULT;
-		}
-		rc = audio_ioctl_shared(file, cmd, &aac_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	case AUDIO_SET_AAC_MIX_CONFIG:	{
-		u32 mix_config;
-
-		pr_debug("%s, AUDIO_SET_AAC_MIX_CONFIG", __func__);
-		if (copy_from_user(&mix_config, (void *)arg,
-			sizeof(u32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_MIX_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = audio_ioctl_shared(file, cmd, &mix_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-			__func__, rc);
-		break;
-	}
-	default: {
-		pr_debug("Calling utils ioctl\n");
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_aac_config32 {
-	s16 format;
-	u16 audio_object;
-	u16 ep_config;  /* 0 ~ 3 useful only obj = ERLC */
-	u16 aac_section_data_resilience_flag;
-	u16 aac_scalefactor_data_resilience_flag;
-	u16 aac_spectral_data_resilience_flag;
-	u16 sbr_on_flag;
-	u16 sbr_ps_on_flag;
-	u16 dual_mono_mode;
-	u16 channel_configuration;
-	u16 sample_rate;
-};
-
-enum {
-	AUDIO_SET_AAC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_aac_config32),
-	AUDIO_GET_AAC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-		(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_aac_config32),
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-							unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config *aac_config;
-		struct msm_audio_aac_config32 aac_config_32;
-
-		memset(&aac_config_32, 0, sizeof(aac_config_32));
-
-		aac_config = (struct msm_audio_aac_config *)audio->codec_cfg;
-		aac_config_32.format = aac_config->format;
-		aac_config_32.audio_object = aac_config->audio_object;
-		aac_config_32.ep_config = aac_config->ep_config;
-		aac_config_32.aac_section_data_resilience_flag =
-			aac_config->aac_section_data_resilience_flag;
-		aac_config_32.aac_scalefactor_data_resilience_flag =
-			aac_config->aac_scalefactor_data_resilience_flag;
-		aac_config_32.aac_spectral_data_resilience_flag =
-			aac_config->aac_spectral_data_resilience_flag;
-		aac_config_32.sbr_on_flag = aac_config->sbr_on_flag;
-		aac_config_32.sbr_ps_on_flag = aac_config->sbr_ps_on_flag;
-		aac_config_32.dual_mono_mode = aac_config->dual_mono_mode;
-		aac_config_32.channel_configuration =
-			aac_config->channel_configuration;
-		aac_config_32.sample_rate = aac_config->sample_rate;
-
-		if (copy_to_user((void *)arg, &aac_config_32,
-			sizeof(aac_config_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_AAC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_AAC_CONFIG_32: {
-		struct msm_audio_aac_config aac_config;
-		struct msm_audio_aac_config32 aac_config_32;
-
-		pr_debug("%s: AUDIO_SET_AAC_CONFIG\n", __func__);
-		if (copy_from_user(&aac_config_32, (void *)arg,
-			sizeof(aac_config_32))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_SET_AAC_CONFIG_32 failed",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		aac_config.format = aac_config_32.format;
-		aac_config.audio_object = aac_config_32.audio_object;
-		aac_config.ep_config = aac_config_32.ep_config;
-		aac_config.aac_section_data_resilience_flag =
-			aac_config_32.aac_section_data_resilience_flag;
-		aac_config.aac_scalefactor_data_resilience_flag =
-			aac_config_32.aac_scalefactor_data_resilience_flag;
-		aac_config.aac_spectral_data_resilience_flag =
-			aac_config_32.aac_spectral_data_resilience_flag;
-		aac_config.sbr_on_flag = aac_config_32.sbr_on_flag;
-		aac_config.sbr_ps_on_flag = aac_config_32.sbr_ps_on_flag;
-		aac_config.dual_mono_mode = aac_config_32.dual_mono_mode;
-		aac_config.channel_configuration =
-				aac_config_32.channel_configuration;
-		aac_config.sample_rate = aac_config_32.sample_rate;
-
-		cmd = AUDIO_SET_AAC_CONFIG;
-		rc = audio_ioctl_shared(file, cmd, &aac_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	case AUDIO_SET_AAC_MIX_CONFIG: {
-		u32 mix_config;
-
-		pr_debug("%s, AUDIO_SET_AAC_MIX_CONFIG\n", __func__);
-		if (copy_from_user(&mix_config, (void *)arg,
-			sizeof(u32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_AAC_MIX_CONFIG failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = audio_ioctl_shared(file, cmd, &mix_config);
-		if (rc)
-			pr_err("%s:AUDIO_SET_AAC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default: {
-		pr_debug("Calling utils ioctl\n");
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-	struct msm_audio_aac_config *aac_config = NULL;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_multi_aac_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_aac_config),
-					GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	aac_config = audio->codec_cfg;
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN_AACM;
-	audio->miscdevice = &audio_multiaac_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_multiaac_ws_mgr;
-	aac_config->dual_mono_mode = AUDIO_AAC_DUAL_MONO_INVALID;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_MPEG4_MULTI_AAC);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open AAC decoder, expected frames is always 1
-		 * audio->buf_cfg.frames_per_buf = 0x01;
-		 */
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_MPEG4_MULTI_AAC);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_multi_aac_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_aac_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:AAC 5.1 Decoder OPEN success mode[%d]session[%d]\n",
-		__func__, audio->feedback, audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_aac_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_multiaac_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_multi_aac",
-	.fops = &audio_aac_fops,
-};
-
-static int __init audio_aac_init(void)
-{
-	int ret = misc_register(&audio_multiaac_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_multiaac_misc.this_device, true);
-	audio_multiaac_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_multiaac_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_aac_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_qcelp.c b/drivers/misc/qcom/qdsp6v2/audio_qcelp.c
deleted file mode 100644
index 8f2511c..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_qcelp.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* qcelp(v13k) audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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 "audio_utils_aio.h"
-
-#define FRAME_SIZE_DEC_QCELP  ((32) + sizeof(struct dec_meta_in))
-
-static struct miscdevice audio_qcelp_misc;
-static struct ws_mgr audio_qcelp_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_qcelp_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("%s: AUDIO_START sessionid[%d]enable[%d]\n", __func__,
-						audio->ac->session,
-						audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-	}
-	return rc;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_qcelp_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE_DEC_QCELP;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->pcm_cfg.channel_count = 1;
-	audio->miscdevice = &audio_qcelp_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_qcelp_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_V13K);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_V13K);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_qcelp_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_qcelp_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:dec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_qcelp_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-};
-
-static struct miscdevice audio_qcelp_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_qcelp",
-	.fops = &audio_qcelp_fops,
-};
-
-static int __init audio_qcelp_init(void)
-{
-	int ret = misc_register(&audio_qcelp_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_qcelp_misc.this_device, true);
-	audio_qcelp_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_qcelp_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_qcelp_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_utils.c b/drivers/misc/qcom/qdsp6v2/audio_utils.c
deleted file mode 100644
index 15ee9f5..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_utils.c
+++ /dev/null
@@ -1,954 +0,0 @@
-/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/atomic.h>
-#include <linux/compat.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/*
- * Define maximum buffer size. Below values are chosen considering the higher
- * values used among all native drivers.
- */
-#define MAX_FRAME_SIZE	1536
-#define MAX_FRAMES	5
-#define META_SIZE	(sizeof(struct meta_out_dsp))
-#define MAX_BUFFER_SIZE	(1 + ((MAX_FRAME_SIZE + META_SIZE) * MAX_FRAMES))
-
-static int audio_in_pause(struct q6audio_in  *audio)
-{
-	int rc;
-
-	rc = q6asm_cmd(audio->ac, CMD_PAUSE);
-	if (rc < 0)
-		pr_err("%s:session id %d: pause cmd failed rc=%d\n", __func__,
-				audio->ac->session, rc);
-
-	return rc;
-}
-
-static int audio_in_flush(struct q6audio_in  *audio)
-{
-	int rc;
-
-	pr_debug("%s:session id %d: flush\n", __func__, audio->ac->session);
-	/* Flush if session running */
-	if (audio->enabled) {
-		/* Implicitly issue a pause to the encoder before flushing */
-		rc = audio_in_pause(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: pause cmd failed rc=%d\n",
-				 __func__, audio->ac->session, rc);
-			return rc;
-		}
-
-		rc = q6asm_cmd(audio->ac, CMD_FLUSH);
-		if (rc < 0) {
-			pr_err("%s:session id %d: flush cmd failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			return rc;
-		}
-		/* 2nd arg: 0 -> run immediately
-		 * 3rd arg: 0 -> msw_ts,
-		 * 4th arg: 0 ->lsw_ts
-		 */
-		q6asm_run(audio->ac, 0x00, 0x00, 0x00);
-		pr_debug("Rerun the session\n");
-	}
-	audio->rflush = 1;
-	audio->wflush = 1;
-	memset(audio->out_frame_info, 0, sizeof(audio->out_frame_info));
-	wake_up(&audio->read_wait);
-	/* get read_lock to ensure no more waiting read thread */
-	mutex_lock(&audio->read_lock);
-	audio->rflush = 0;
-	mutex_unlock(&audio->read_lock);
-	wake_up(&audio->write_wait);
-	/* get write_lock to ensure no more waiting write thread */
-	mutex_lock(&audio->write_lock);
-	audio->wflush = 0;
-	mutex_unlock(&audio->write_lock);
-	pr_debug("%s:session id %d: in_bytes %d\n", __func__,
-			audio->ac->session, atomic_read(&audio->in_bytes));
-	pr_debug("%s:session id %d: in_samples %d\n", __func__,
-			audio->ac->session, atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-	atomic_set(&audio->out_count, 0);
-	return 0;
-}
-
-/* must be called with audio->lock held */
-int audio_in_enable(struct q6audio_in  *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	/* 2nd arg: 0 -> run immediately
-	 * 3rd arg: 0 -> msw_ts,
-	 * 4th arg: 0 ->lsw_ts
-	 */
-	return q6asm_run(audio->ac, 0x00, 0x00, 0x00);
-}
-
-/* must be called with audio->lock held */
-int audio_in_disable(struct q6audio_in  *audio)
-{
-	int rc = 0;
-
-	if (!audio->stopped) {
-		audio->enabled = 0;
-		audio->opened = 0;
-		pr_debug("%s:session id %d: inbytes[%d] insamples[%d]\n",
-				__func__, audio->ac->session,
-				atomic_read(&audio->in_bytes),
-				atomic_read(&audio->in_samples));
-
-		rc = q6asm_cmd(audio->ac, CMD_CLOSE);
-		if (rc < 0)
-			pr_err("%s:session id %d: Failed to close the session rc=%d\n",
-				__func__, audio->ac->session,
-				rc);
-		audio->stopped = 1;
-		memset(audio->out_frame_info, 0,
-				sizeof(audio->out_frame_info));
-		wake_up(&audio->read_wait);
-		wake_up(&audio->write_wait);
-	}
-	pr_debug("%s:session id %d: enabled[%d]\n", __func__,
-			audio->ac->session, audio->enabled);
-	return rc;
-}
-
-int audio_in_buf_alloc(struct q6audio_in *audio)
-{
-	int rc = 0;
-
-	switch (audio->buf_alloc) {
-	case NO_BUF_ALLOC:
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_audio_client_buf_alloc(IN,
-				audio->ac,
-				ALIGN_BUF_SIZE(audio->pcm_cfg.buffer_size),
-				audio->pcm_cfg.buffer_count);
-			if (rc < 0) {
-				pr_err("%s:session id %d: Buffer Alloc failed\n",
-						__func__,
-						audio->ac->session);
-				rc = -ENOMEM;
-				break;
-			}
-			audio->buf_alloc |= BUF_ALLOC_IN;
-		}
-		rc = q6asm_audio_client_buf_alloc(OUT, audio->ac,
-				ALIGN_BUF_SIZE(audio->str_cfg.buffer_size),
-				audio->str_cfg.buffer_count);
-		if (rc < 0) {
-			pr_err("%s:session id %d: Buffer Alloc failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			rc = -ENOMEM;
-			break;
-		}
-		audio->buf_alloc |= BUF_ALLOC_OUT;
-		break;
-	case BUF_ALLOC_IN:
-		rc = q6asm_audio_client_buf_alloc(OUT, audio->ac,
-				ALIGN_BUF_SIZE(audio->str_cfg.buffer_size),
-				audio->str_cfg.buffer_count);
-		if (rc < 0) {
-			pr_err("%s:session id %d: Buffer Alloc failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			rc = -ENOMEM;
-			break;
-		}
-		audio->buf_alloc |= BUF_ALLOC_OUT;
-		break;
-	case BUF_ALLOC_OUT:
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_audio_client_buf_alloc(IN, audio->ac,
-				ALIGN_BUF_SIZE(audio->pcm_cfg.buffer_size),
-				audio->pcm_cfg.buffer_count);
-			if (rc < 0) {
-				pr_err("%s:session id %d: Buffer Alloc failed\n",
-					__func__,
-					audio->ac->session);
-				rc = -ENOMEM;
-				break;
-			}
-			audio->buf_alloc |= BUF_ALLOC_IN;
-		}
-		break;
-	default:
-		pr_debug("%s:session id %d: buf[%d]\n", __func__,
-					audio->ac->session, audio->buf_alloc);
-	}
-
-	return rc;
-}
-
-int audio_in_set_config(struct file *file,
-		struct msm_audio_config *cfg)
-{
-	int rc = 0;
-	struct q6audio_in  *audio = file->private_data;
-
-	if (audio->feedback != NON_TUNNEL_MODE) {
-		pr_err("%s:session id %d: Not sufficient permission to change the record mode\n",
-			__func__, audio->ac->session);
-		rc = -EACCES;
-		goto ret;
-	}
-	if ((cfg->buffer_count > PCM_BUF_COUNT) ||
-		(cfg->buffer_count == 1))
-		cfg->buffer_count = PCM_BUF_COUNT;
-
-	audio->pcm_cfg.buffer_count = cfg->buffer_count;
-	audio->pcm_cfg.buffer_size  = cfg->buffer_size;
-	audio->pcm_cfg.channel_count = cfg->channel_count;
-	audio->pcm_cfg.sample_rate = cfg->sample_rate;
-	if (audio->opened && audio->feedback == NON_TUNNEL_MODE) {
-		rc = q6asm_audio_client_buf_alloc(IN, audio->ac,
-			ALIGN_BUF_SIZE(audio->pcm_cfg.buffer_size),
-			audio->pcm_cfg.buffer_count);
-		if (rc < 0) {
-			pr_err("%s:session id %d: Buffer Alloc failed\n",
-				__func__, audio->ac->session);
-			rc = -ENOMEM;
-			goto ret;
-		}
-	}
-	audio->buf_alloc |= BUF_ALLOC_IN;
-	rc = 0;
-	pr_debug("%s:session id %d: AUDIO_SET_CONFIG %d %d\n", __func__,
-			audio->ac->session, audio->pcm_cfg.buffer_count,
-			audio->pcm_cfg.buffer_size);
-ret:
-	return rc;
-}
-/* ------------------- device --------------------- */
-static long audio_in_ioctl_shared(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_FLUSH: {
-		/* Make sure we're stopped and we wake any threads
-		 * that might be blocked holding the read_lock.
-		 * While audio->stopped read threads will always
-		 * exit immediately.
-		 */
-		rc = audio_in_flush(audio);
-		if (rc < 0)
-			pr_err("%s:session id %d: Flush Fail rc=%d\n",
-				__func__, audio->ac->session, rc);
-		else { /* Register back the flushed read buffer with DSP */
-			int cnt = 0;
-
-			while (cnt++ < audio->str_cfg.buffer_count)
-				q6asm_read(audio->ac); /* Push buffer to DSP */
-			pr_debug("register the read buffer\n");
-		}
-		break;
-	}
-	case AUDIO_PAUSE: {
-		pr_debug("%s:session id %d: AUDIO_PAUSE\n", __func__,
-					audio->ac->session);
-		if (audio->enabled)
-			audio_in_pause(audio);
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->ac->session,
-			sizeof(u16))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_SESSION_ID failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-long audio_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		memset(&stats, 0, sizeof(stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_FLUSH:
-	case AUDIO_PAUSE:
-	case AUDIO_GET_SESSION_ID:
-		rc = audio_in_ioctl_shared(file, cmd, arg);
-		break;
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->str_cfg.buffer_size;
-		cfg.buffer_count = audio->str_cfg.buffer_count;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		pr_debug("%s:session id %d: AUDIO_GET_STREAM_CONFIG %d %d\n",
-				__func__, audio->ac->session, cfg.buffer_size,
-				cfg.buffer_count);
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_STREAM_CONFIG failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		/* Minimum single frame size,
-		 * but with in maximum frames number
-		 */
-		if ((cfg.buffer_size < (audio->min_frame_size +
-			sizeof(struct meta_out_dsp))) ||
-			(cfg.buffer_count < FRAME_NUM)) {
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg.buffer_size > MAX_BUFFER_SIZE) {
-			rc = -EINVAL;
-			break;
-		}
-		audio->str_cfg.buffer_size = cfg.buffer_size;
-		audio->str_cfg.buffer_count = cfg.buffer_count;
-		if (audio->opened) {
-			rc = q6asm_audio_client_buf_alloc(OUT, audio->ac,
-				ALIGN_BUF_SIZE(audio->str_cfg.buffer_size),
-				audio->str_cfg.buffer_count);
-			if (rc < 0) {
-				pr_err("%s: session id %d: Buffer Alloc failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-		audio->buf_alloc |= BUF_ALLOC_OUT;
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_SET_STREAM_CONFIG %d %d\n",
-				__func__, audio->ac->session,
-				audio->str_cfg.buffer_size,
-				audio->str_cfg.buffer_count);
-		break;
-	}
-	case AUDIO_SET_BUF_CFG: {
-		struct msm_audio_buf_cfg  cfg;
-
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if ((audio->feedback == NON_TUNNEL_MODE) &&
-			!cfg.meta_info_enable) {
-			rc = -EFAULT;
-			break;
-		}
-
-		/* Restrict the num of frames per buf to coincide with
-		 * default buf size
-		 */
-		if (cfg.frames_per_buf > audio->max_frames_per_buf) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->buf_cfg.meta_info_enable = cfg.meta_info_enable;
-		audio->buf_cfg.frames_per_buf = cfg.frames_per_buf;
-		pr_debug("%s:session id %d: Set-buf-cfg: meta[%d] framesperbuf[%d]\n",
-				__func__,
-				audio->ac->session, cfg.meta_info_enable,
-				cfg.frames_per_buf);
-		break;
-	}
-	case AUDIO_GET_BUF_CFG: {
-		pr_debug("%s:session id %d: Get-buf-cfg: meta[%d] framesperbuf[%d]\n",
-			__func__,
-			audio->ac->session, audio->buf_cfg.meta_info_enable,
-			audio->buf_cfg.frames_per_buf);
-
-		if (copy_to_user((void *)arg, &audio->buf_cfg,
-					sizeof(struct msm_audio_buf_cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		if (copy_to_user((void *)arg, &audio->pcm_cfg,
-					sizeof(struct msm_audio_config)))
-			rc = -EFAULT;
-		break;
-
-	}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config cfg;
-
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = audio_in_set_config(file, &cfg);
-		break;
-	}
-	default:
-		/* call codec specific ioctl */
-		rc = audio->enc_ioctl(file, cmd, arg);
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_stats32 {
-	u32 byte_count;
-	u32 sample_count;
-	u32 unused[2];
-};
-
-struct msm_audio_stream_config32 {
-	u32 buffer_size;
-	u32 buffer_count;
-};
-
-struct msm_audio_config32 {
-	u32 buffer_size;
-	u32 buffer_count;
-	u32 channel_count;
-	u32 sample_rate;
-	u32 type;
-	u32 meta_field;
-	u32 bits;
-	u32 unused[3];
-};
-
-struct msm_audio_buf_cfg32 {
-	u32 meta_info_enable;
-	u32 frames_per_buf;
-};
-
-enum {
-	AUDIO_GET_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC, 3,
-			struct msm_audio_config32),
-	AUDIO_SET_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC, 4,
-			struct msm_audio_config32),
-	AUDIO_GET_STATS_32 = _IOR(AUDIO_IOCTL_MAGIC, 5,
-			struct msm_audio_stats32),
-	AUDIO_SET_STREAM_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC, 80,
-			struct msm_audio_stream_config32),
-	AUDIO_GET_STREAM_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC, 81,
-			struct msm_audio_stream_config32),
-	AUDIO_SET_BUF_CFG_32 = _IOW(AUDIO_IOCTL_MAGIC, 94,
-			struct msm_audio_buf_cfg32),
-	AUDIO_GET_BUF_CFG_32 = _IOW(AUDIO_IOCTL_MAGIC, 93,
-			struct msm_audio_buf_cfg32),
-};
-
-long audio_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS_32) {
-		struct msm_audio_stats32 stats_32;
-
-		memset(&stats_32, 0, sizeof(stats_32));
-		stats_32.byte_count = atomic_read(&audio->in_bytes);
-		stats_32.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats_32, sizeof(stats_32))) {
-			pr_err("%s: copy_to_user failed for AUDIO_GET_STATS_32\n",
-				__func__);
-			return -EFAULT;
-		}
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_FLUSH:
-	case AUDIO_PAUSE:
-	case AUDIO_GET_SESSION_ID:
-		rc = audio_in_ioctl_shared(file, cmd, arg);
-		break;
-	case AUDIO_GET_STREAM_CONFIG_32: {
-		struct msm_audio_stream_config32 cfg_32;
-
-		memset(&cfg_32, 0, sizeof(cfg_32));
-		cfg_32.buffer_size = audio->str_cfg.buffer_size;
-		cfg_32.buffer_count = audio->str_cfg.buffer_count;
-		if (copy_to_user((void *)arg, &cfg_32, sizeof(cfg_32))) {
-			pr_err("%s: Copy to user failed\n", __func__);
-			rc = -EFAULT;
-		}
-		pr_debug("%s:session id %d: AUDIO_GET_STREAM_CONFIG %d %d\n",
-				__func__, audio->ac->session,
-				cfg_32.buffer_size,
-				cfg_32.buffer_count);
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG_32: {
-		struct msm_audio_stream_config32 cfg_32;
-		struct msm_audio_stream_config cfg;
-
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_STREAM_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.buffer_size = cfg_32.buffer_size;
-		cfg.buffer_count = cfg_32.buffer_count;
-		/* Minimum single frame size,
-		 * but with in maximum frames number
-		 */
-		if ((cfg.buffer_size < (audio->min_frame_size +
-			sizeof(struct meta_out_dsp))) ||
-			(cfg.buffer_count < FRAME_NUM)) {
-			rc = -EINVAL;
-			break;
-		}
-		audio->str_cfg.buffer_size = cfg.buffer_size;
-		audio->str_cfg.buffer_count = cfg.buffer_count;
-		if (audio->opened) {
-			rc = q6asm_audio_client_buf_alloc(OUT, audio->ac,
-				ALIGN_BUF_SIZE(audio->str_cfg.buffer_size),
-				audio->str_cfg.buffer_count);
-			if (rc < 0) {
-				pr_err("%s: session id %d:\n",
-					__func__, audio->ac->session);
-				pr_err("Buffer Alloc failed rc=%d\n", rc);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-		audio->buf_alloc |= BUF_ALLOC_OUT;
-		pr_debug("%s:session id %d: AUDIO_SET_STREAM_CONFIG %d %d\n",
-				__func__, audio->ac->session,
-				audio->str_cfg.buffer_size,
-				audio->str_cfg.buffer_count);
-		break;
-	}
-	case AUDIO_SET_BUF_CFG_32: {
-		struct msm_audio_buf_cfg32 cfg_32;
-		struct msm_audio_buf_cfg cfg;
-
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_BUG_CFG_32 failed",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.meta_info_enable = cfg_32.meta_info_enable;
-		cfg.frames_per_buf = cfg_32.frames_per_buf;
-
-		if ((audio->feedback == NON_TUNNEL_MODE) &&
-			!cfg.meta_info_enable) {
-			rc = -EFAULT;
-			break;
-		}
-
-		/* Restrict the num of frames per buf to coincide with
-		 * default buf size
-		 */
-		if (cfg.frames_per_buf > audio->max_frames_per_buf) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->buf_cfg.meta_info_enable = cfg.meta_info_enable;
-		audio->buf_cfg.frames_per_buf = cfg.frames_per_buf;
-		pr_debug("%s:session id %d: Set-buf-cfg: meta[%d] framesperbuf[%d]\n",
-			__func__, audio->ac->session, cfg.meta_info_enable,
-			cfg.frames_per_buf);
-		break;
-	}
-	case AUDIO_GET_BUF_CFG_32: {
-		struct msm_audio_buf_cfg32 cfg_32;
-
-		pr_debug("%s:session id %d: Get-buf-cfg: meta[%d] framesperbuf[%d]\n",
-			__func__,
-			audio->ac->session, audio->buf_cfg.meta_info_enable,
-			audio->buf_cfg.frames_per_buf);
-		cfg_32.meta_info_enable = audio->buf_cfg.meta_info_enable;
-		cfg_32.frames_per_buf = audio->buf_cfg.frames_per_buf;
-
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(struct msm_audio_buf_cfg32))) {
-			pr_err("%s: Copy to user failed\n", __func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_GET_CONFIG_32: {
-		struct msm_audio_config32 cfg_32;
-
-		memset(&cfg_32, 0, sizeof(cfg_32));
-		cfg_32.buffer_size = audio->pcm_cfg.buffer_size;
-		cfg_32.buffer_count = audio->pcm_cfg.buffer_count;
-		cfg_32.channel_count = audio->pcm_cfg.channel_count;
-		cfg_32.sample_rate = audio->pcm_cfg.sample_rate;
-		cfg_32.type = audio->pcm_cfg.type;
-		cfg_32.meta_field = audio->pcm_cfg.meta_field;
-		cfg_32.bits = audio->pcm_cfg.bits;
-
-		if (copy_to_user((void *)arg, &cfg_32,
-					sizeof(struct msm_audio_config32))) {
-			pr_err("%s: Copy to user failed\n", __func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_CONFIG_32: {
-		struct msm_audio_config32 cfg_32;
-		struct msm_audio_config cfg;
-
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.buffer_size = cfg_32.buffer_size;
-		cfg.buffer_count = cfg_32.buffer_count;
-		cfg.channel_count = cfg_32.channel_count;
-		cfg.sample_rate = cfg_32.sample_rate;
-		cfg.type = cfg_32.type;
-		cfg.meta_field = cfg_32.meta_field;
-		cfg.bits = cfg_32.bits;
-		rc = audio_in_set_config(file, &cfg);
-		break;
-	}
-	default:
-		  /* call codec specific ioctl */
-		  rc = audio->enc_compat_ioctl(file, cmd, arg);
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-#endif
-
-ssize_t audio_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct q6audio_in  *audio = file->private_data;
-	const char __user *start = buf;
-	unsigned char *data;
-	uint32_t offset = 0;
-	uint32_t size = 0;
-	int rc = 0;
-	uint32_t idx;
-	struct meta_out_dsp meta;
-	uint32_t bytes_to_copy = 0;
-	uint32_t mfield_size = (audio->buf_cfg.meta_info_enable == 0) ? 0 :
-		(sizeof(unsigned char) +
-		(sizeof(struct meta_out_dsp)*(audio->buf_cfg.frames_per_buf)));
-
-	memset(&meta, 0, sizeof(meta));
-	pr_debug("%s:session id %d: read - %zd\n", __func__, audio->ac->session,
-			count);
-	if (audio->reset_event)
-		return -ENETRESET;
-
-	if (!audio->enabled)
-		return -EFAULT;
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->read_wait,
-			((atomic_read(&audio->out_count) > 0) ||
-			(audio->stopped) ||
-			 audio->rflush || audio->eos_rsp ||
-			audio->event_abort));
-
-		if (audio->event_abort) {
-			rc = -EIO;
-			break;
-		}
-
-
-		if (rc < 0)
-			break;
-
-		if ((audio->stopped && !(atomic_read(&audio->out_count))) ||
-			audio->rflush) {
-			pr_debug("%s:session id %d: driver in stop state or flush,No more buf to read",
-				__func__,
-				audio->ac->session);
-			rc = 0;/* End of File */
-			break;
-		}
-		if (!(atomic_read(&audio->out_count)) &&
-			(audio->eos_rsp == 1) &&
-			(count >= (sizeof(unsigned char) +
-				sizeof(struct meta_out_dsp)))) {
-			unsigned char num_of_frames;
-
-			pr_info("%s:session id %d: eos %d at output\n",
-				__func__, audio->ac->session, audio->eos_rsp);
-			if (buf != start)
-				break;
-			num_of_frames = 0xFF;
-			if (copy_to_user(buf, &num_of_frames,
-					sizeof(unsigned char))) {
-				rc = -EFAULT;
-				break;
-			}
-			buf += sizeof(unsigned char);
-			meta.frame_size = 0xFFFF;
-			meta.encoded_pcm_samples = 0xFFFF;
-			meta.msw_ts = 0x00;
-			meta.lsw_ts = 0x00;
-			meta.nflags = AUD_EOS_SET;
-			audio->eos_rsp = 0;
-			if (copy_to_user(buf, &meta, sizeof(meta))) {
-				rc = -EFAULT;
-				break;
-			}
-			buf += sizeof(meta);
-			break;
-		}
-		data = (unsigned char *)q6asm_is_cpu_buf_avail(OUT, audio->ac,
-						&size, &idx);
-		if ((count >= (size + mfield_size)) && data) {
-			if (audio->buf_cfg.meta_info_enable) {
-				if (copy_to_user(buf,
-					&audio->out_frame_info[idx][0],
-					sizeof(unsigned char))) {
-					rc = -EFAULT;
-					break;
-				}
-				bytes_to_copy =
-					(size + audio->out_frame_info[idx][1]);
-				/* Number of frames information copied */
-				buf += sizeof(unsigned char);
-				count -= sizeof(unsigned char);
-			} else {
-				offset = audio->out_frame_info[idx][1];
-				bytes_to_copy = size;
-			}
-
-			pr_debug("%s:session id %d: offset=%d nr of frames= %d\n",
-					__func__, audio->ac->session,
-					audio->out_frame_info[idx][1],
-					audio->out_frame_info[idx][0]);
-
-			if (copy_to_user(buf, &data[offset], bytes_to_copy)) {
-				rc = -EFAULT;
-				break;
-			}
-			count -= bytes_to_copy;
-			buf += bytes_to_copy;
-		} else {
-			pr_err("%s:session id %d: short read data[%pK] bytesavail[%d]bytesrequest[%zd]\n",
-				__func__,
-				audio->ac->session,
-				data, size, count);
-		}
-		atomic_dec(&audio->out_count);
-		q6asm_read(audio->ac);
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	pr_debug("%s:session id %d: read: %zd bytes\n", __func__,
-			audio->ac->session, (buf-start));
-	if (buf > start)
-		return buf - start;
-	return rc;
-}
-
-static int extract_meta_info(char *buf, unsigned long *msw_ts,
-		unsigned long *lsw_ts, unsigned int *flags)
-{
-	struct meta_in *meta = (struct meta_in *)buf;
-	*msw_ts = meta->ntimestamp.highpart;
-	*lsw_ts = meta->ntimestamp.lowpart;
-	*flags = meta->nflags;
-	return 0;
-}
-
-ssize_t audio_in_write(struct file *file,
-		const char __user *buf,
-		size_t count, loff_t *pos)
-{
-	struct q6audio_in *audio = file->private_data;
-	const char __user *start = buf;
-	size_t xfer = 0;
-	char *cpy_ptr;
-	int rc = 0;
-	unsigned char *data;
-	uint32_t size = 0;
-	uint32_t idx = 0;
-	uint32_t nflags = 0;
-	unsigned long msw_ts = 0;
-	unsigned long lsw_ts = 0;
-	uint32_t mfield_size = (audio->buf_cfg.meta_info_enable == 0) ? 0 :
-			sizeof(struct meta_in);
-
-	pr_debug("%s:session id %d: to write[%zd]\n", __func__,
-			audio->ac->session, count);
-	if (audio->reset_event)
-		return -ENETRESET;
-
-	if (!audio->enabled)
-		return -EFAULT;
-	mutex_lock(&audio->write_lock);
-
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->write_wait,
-				     ((atomic_read(&audio->in_count) > 0) ||
-				      (audio->stopped) ||
-				      (audio->wflush) || (audio->event_abort)));
-
-		if (audio->event_abort) {
-			rc = -EIO;
-			break;
-		}
-
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			pr_debug("%s: session id %d: stop or flush\n", __func__,
-					audio->ac->session);
-			rc = -EBUSY;
-			break;
-		}
-		/* if no PCM data, might have only eos buffer
-		 * such case do not hold cpu buffer
-		 */
-		if ((buf == start) && (count == mfield_size)) {
-			char eos_buf[sizeof(struct meta_in)];
-			/* Processing beginning of user buffer */
-			if (copy_from_user(eos_buf, buf, mfield_size)) {
-				rc = -EFAULT;
-				break;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			extract_meta_info(eos_buf, &msw_ts, &lsw_ts,
-						&nflags);
-			buf += mfield_size;
-			/* send the EOS and return */
-			pr_debug("%s:session id %d: send EOS 0x%8x\n",
-				__func__,
-				audio->ac->session, nflags);
-			break;
-		}
-		data = (unsigned char *)q6asm_is_cpu_buf_avail(IN, audio->ac,
-						&size, &idx);
-		if (!data) {
-			pr_debug("%s:session id %d: No buf available\n",
-				__func__, audio->ac->session);
-			continue;
-		}
-		cpy_ptr = data;
-		if (audio->buf_cfg.meta_info_enable) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				extract_meta_info(cpy_ptr, &msw_ts, &lsw_ts,
-						&nflags);
-				buf += mfield_size;
-				count -= mfield_size;
-			} else {
-				pr_debug("%s:session id %d: continuous buffer\n",
-						__func__, audio->ac->session);
-			}
-		}
-		xfer = (count > (audio->pcm_cfg.buffer_size)) ?
-				(audio->pcm_cfg.buffer_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = q6asm_write(audio->ac, xfer, msw_ts, lsw_ts, 0x00);
-		if (rc < 0) {
-			rc = -EFAULT;
-			break;
-		}
-		atomic_dec(&audio->in_count);
-		count -= xfer;
-		buf += xfer;
-	}
-	mutex_unlock(&audio->write_lock);
-	pr_debug("%s:session id %d: eos_condition 0x%x buf[0x%pK] start[0x%pK]\n",
-				__func__, audio->ac->session,
-				nflags, buf, start);
-	if (nflags & AUD_EOS_SET) {
-		rc = q6asm_cmd(audio->ac, CMD_EOS);
-		pr_info("%s:session id %d: eos %d at input\n", __func__,
-				audio->ac->session, audio->eos_rsp);
-	}
-	pr_debug("%s:session id %d: Written %zd Avail Buf[%d]", __func__,
-			audio->ac->session, (buf - start - mfield_size),
-			atomic_read(&audio->in_count));
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-int audio_in_release(struct inode *inode, struct file *file)
-{
-	struct q6audio_in  *audio = file->private_data;
-
-	pr_info("%s: session id %d\n", __func__, audio->ac->session);
-	mutex_lock(&audio->lock);
-	audio_in_disable(audio);
-	q6asm_audio_client_free(audio->ac);
-	mutex_unlock(&audio->lock);
-	kfree(audio->enc_cfg);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return 0;
-}
diff --git a/drivers/misc/qcom/qdsp6v2/audio_utils.h b/drivers/misc/qcom/qdsp6v2/audio_utils.h
deleted file mode 100644
index f5517d8..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_utils.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Copyright (c) 2010-2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/msm_audio.h>
-#include <linux/compat.h>
-#include "q6audio_common.h"
-
-#define FRAME_NUM	(8)
-
-#define PCM_BUF_COUNT		(2)
-
-#define AUD_EOS_SET  0x01
-#define TUNNEL_MODE     0x0000
-#define NON_TUNNEL_MODE 0x0001
-
-#define NO_BUF_ALLOC	0x00
-#define BUF_ALLOC_IN    0x01
-#define BUF_ALLOC_OUT   0x02
-#define BUF_ALLOC_INOUT 0x03
-#define ALIGN_BUF_SIZE(size) ((size + 4095) & (~4095))
-
-struct timestamp {
-	u32 lowpart;
-	u32 highpart;
-} __packed;
-
-struct meta_in {
-	unsigned short offset;
-	struct timestamp ntimestamp;
-	unsigned int nflags;
-} __packed;
-
-struct meta_out_dsp {
-	u32 offset_to_frame;
-	u32 frame_size;
-	u32 encoded_pcm_samples;
-	u32 msw_ts;
-	u32 lsw_ts;
-	u32 nflags;
-} __packed;
-
-struct meta_out {
-	unsigned char num_of_frames;
-	struct meta_out_dsp meta_out_dsp[];
-} __packed;
-
-struct q6audio_in {
-	spinlock_t			dsp_lock;
-	atomic_t			in_bytes;
-	atomic_t			in_samples;
-
-	struct mutex			lock;
-	struct mutex			read_lock;
-	struct mutex			write_lock;
-	wait_queue_head_t		read_wait;
-	wait_queue_head_t		write_wait;
-
-	struct audio_client             *ac;
-	struct msm_audio_stream_config  str_cfg;
-	void				*enc_cfg;
-	struct msm_audio_buf_cfg        buf_cfg;
-	struct msm_audio_config		pcm_cfg;
-	void				*codec_cfg;
-
-	/* number of buffers available to read/write */
-	atomic_t			in_count;
-	atomic_t			out_count;
-
-	/* first idx: num of frames per buf, second idx: offset to frame */
-	uint32_t			out_frame_info[FRAME_NUM][2];
-	int				eos_rsp;
-	int				opened;
-	int				enabled;
-	int				stopped;
-	int				event_abort;
-	int				feedback; /* Flag indicates whether used
-						   * in Non Tunnel mode
-						   */
-	int				rflush;
-	int				wflush;
-	int				buf_alloc;
-	uint16_t			min_frame_size;
-	uint16_t			max_frames_per_buf;
-	bool				reset_event;
-	long (*enc_ioctl)(struct file *, unsigned int, unsigned long);
-	long (*enc_compat_ioctl)(struct file *, unsigned int, unsigned long);
-};
-
-int audio_in_enable(struct q6audio_in  *audio);
-int audio_in_disable(struct q6audio_in  *audio);
-int audio_in_buf_alloc(struct q6audio_in *audio);
-long audio_in_ioctl(struct file *file,
-		unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-long audio_in_compat_ioctl(struct file *file,
-		unsigned int cmd, unsigned long arg);
-#else
-#define audio_in_compat_ioctl NULL
-#endif
-ssize_t audio_in_read(struct file *file, char __user *buf,
-		size_t count, loff_t *pos);
-ssize_t audio_in_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *pos);
-int audio_in_release(struct inode *inode, struct file *file);
-int audio_in_set_config(struct file *file, struct msm_audio_config *cfg);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_utils_aio.c b/drivers/misc/qcom/qdsp6v2/audio_utils_aio.c
deleted file mode 100644
index 501d4a4..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_utils_aio.c
+++ /dev/null
@@ -1,2158 +0,0 @@
-/* Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include <linux/debugfs.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/compat.h>
-#include <linux/mutex.h>
-#include "audio_utils_aio.h"
-#ifdef CONFIG_USE_DEV_CTRL_VOLUME
-#include <linux/qdsp6v2/audio_dev_ctl.h>
-#endif /*CONFIG_USE_DEV_CTRL_VOLUME*/
-static DEFINE_MUTEX(lock);
-#ifdef CONFIG_DEBUG_FS
-
-int audio_aio_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-ssize_t audio_aio_debug_read(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0;
-	struct q6audio_aio *audio;
-
-	mutex_lock(&lock);
-	if (file->private_data != NULL) {
-		audio = file->private_data;
-		mutex_lock(&audio->lock);
-		n = scnprintf(buffer, debug_bufmax, "opened %d\n",
-				audio->opened);
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"enabled %d\n", audio->enabled);
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"stopped %d\n", audio->stopped);
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"feedback %d\n", audio->feedback);
-		mutex_unlock(&audio->lock);
-		/* Following variables are only useful for debugging when
-		 * when playback halts unexpectedly. Thus, no mutual exclusion
-		 * enforced
-		 */
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"wflush %d\n", audio->wflush);
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"rflush %d\n", audio->rflush);
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"inqueue empty %d\n",
-				list_empty(&audio->in_queue));
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"outqueue empty %d\n",
-				list_empty(&audio->out_queue));
-	}
-	mutex_unlock(&lock);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-#endif
-
-static long audio_aio_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg);
-#ifdef CONFIG_COMPAT
-static long audio_aio_compat_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg);
-#else
-#define audio_aio_compat_ioctl NULL
-#endif
-int insert_eos_buf(struct q6audio_aio *audio,
-		struct audio_aio_buffer_node *buf_node)
-{
-	struct dec_meta_out *eos_buf = buf_node->kvaddr;
-
-	pr_debug("%s[%pK]:insert_eos_buf\n", __func__, audio);
-	eos_buf->num_of_frames = 0xFFFFFFFF;
-	eos_buf->meta_out_dsp[0].offset_to_frame = 0x0;
-	eos_buf->meta_out_dsp[0].nflags = AUDIO_DEC_EOS_SET;
-	return sizeof(struct dec_meta_out) +
-		sizeof(eos_buf->meta_out_dsp[0]);
-}
-
-/* Routine which updates read buffers of driver/dsp,
- * for flush operation as DSP output might not have proper
- * value set
- */
-static int insert_meta_data_flush(struct q6audio_aio *audio,
-	struct audio_aio_buffer_node *buf_node)
-{
-	struct dec_meta_out *meta_data = buf_node->kvaddr;
-
-	meta_data->num_of_frames = 0x0;
-	meta_data->meta_out_dsp[0].offset_to_frame = 0x0;
-	meta_data->meta_out_dsp[0].nflags = 0x0;
-	return sizeof(struct dec_meta_out) +
-		sizeof(meta_data->meta_out_dsp[0]);
-}
-
-static int audio_aio_ion_lookup_vaddr(struct q6audio_aio *audio, void *addr,
-					unsigned long len,
-					struct audio_aio_ion_region **region)
-{
-	struct audio_aio_ion_region *region_elt;
-
-	int match_count = 0;
-
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (addr >= region_elt->vaddr &&
-			addr < region_elt->vaddr + region_elt->len &&
-			addr + len <= region_elt->vaddr + region_elt->len &&
-			addr + len > addr) {
-			/* to avoid integer addition overflow */
-
-			/* offset since we could pass vaddr inside a registered
-			 * ion buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		pr_err("%s[%pK]:multiple hits for vaddr %pK, len %ld\n",
-			__func__, audio, addr, len);
-		list_for_each_entry(region_elt, &audio->ion_region_queue,
-					list) {
-			if (addr >= region_elt->vaddr &&
-			addr < region_elt->vaddr + region_elt->len &&
-			addr + len <= region_elt->vaddr + region_elt->len &&
-			addr + len > addr)
-				pr_err("\t%s[%pK]:%pK, %ld --> %pK\n",
-					__func__, audio,
-					region_elt->vaddr,
-					region_elt->len,
-					&region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-
-static phys_addr_t audio_aio_ion_fixup(struct q6audio_aio *audio, void *addr,
-				unsigned long len, int ref_up, void **kvaddr)
-{
-	struct audio_aio_ion_region *region;
-	phys_addr_t paddr;
-	int ret;
-
-	ret = audio_aio_ion_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		pr_err("%s[%pK]:lookup (%pK, %ld) failed\n",
-				__func__, audio, addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	pr_debug("%s[%pK]:found region %pK ref_cnt %d\n",
-			__func__, audio, region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	/* provide kernel virtual address for accessing meta information */
-	if (kvaddr)
-		*kvaddr = (void *) (region->kvaddr + (addr - region->vaddr));
-	return paddr;
-}
-
-static int audio_aio_pause(struct q6audio_aio  *audio)
-{
-	int rc = -EINVAL;
-
-	pr_debug("%s[%pK], enabled = %d\n", __func__, audio,
-			audio->enabled);
-	if (audio->enabled) {
-		rc = q6asm_cmd(audio->ac, CMD_PAUSE);
-		if (rc < 0)
-			pr_err("%s[%pK]: pause cmd failed rc=%d\n",
-				__func__, audio, rc);
-
-		if (rc == 0) {
-			/* Send suspend only if pause was successful */
-			rc = q6asm_cmd(audio->ac, CMD_SUSPEND);
-			if (rc < 0)
-				pr_err("%s[%pK]: suspend cmd failed rc=%d\n",
-					__func__, audio, rc);
-		} else
-			pr_err("%s[%pK]: not sending suspend since pause failed\n",
-				__func__, audio);
-
-	} else
-		pr_err("%s[%pK]: Driver not enabled\n", __func__, audio);
-	return rc;
-}
-
-static int audio_aio_flush(struct q6audio_aio  *audio)
-{
-	int rc = 0;
-
-	if (audio->enabled) {
-		/* Implicitly issue a pause to the decoder before flushing if
-		 * it is not in pause state
-		 */
-		if (!(audio->drv_status & ADRV_STATUS_PAUSE)) {
-			rc = audio_aio_pause(audio);
-			if (rc < 0)
-				pr_err("%s[%pK}: pause cmd failed rc=%d\n",
-					__func__, audio,
-					rc);
-			else
-				audio->drv_status |= ADRV_STATUS_PAUSE;
-		}
-		rc = q6asm_cmd(audio->ac, CMD_FLUSH);
-		if (rc < 0)
-			pr_err("%s[%pK]: flush cmd failed rc=%d\n",
-				__func__, audio, rc);
-		/* Not in stop state, reenable the stream */
-		if (audio->stopped == 0) {
-			rc = audio_aio_enable(audio);
-			if (rc)
-				pr_err("%s[%pK]:audio re-enable failed\n",
-					__func__, audio);
-			else {
-				audio->enabled = 1;
-				if (audio->drv_status & ADRV_STATUS_PAUSE)
-					audio->drv_status &= ~ADRV_STATUS_PAUSE;
-			}
-		}
-	}
-	pr_debug("%s[%pK]:in_bytes %d\n",
-			__func__, audio, atomic_read(&audio->in_bytes));
-	pr_debug("%s[%pK]:in_samples %d\n",
-			__func__, audio, atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-	return rc;
-}
-
-static int audio_aio_outport_flush(struct q6audio_aio *audio)
-{
-	int rc;
-
-	rc = q6asm_cmd(audio->ac, CMD_OUT_FLUSH);
-	if (rc < 0)
-		pr_err("%s[%pK}: output port flush cmd failed rc=%d\n",
-			__func__, audio, rc);
-	return rc;
-}
-
-/* Write buffer to DSP / Handle Ack from DSP */
-void audio_aio_async_write_ack(struct q6audio_aio *audio, uint32_t token,
-				uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload event_payload;
-	struct audio_aio_buffer_node *used_buf;
-
-	/* No active flush in progress */
-	if (audio->wflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (list_empty(&audio->out_queue)) {
-		pr_warn("%s: ignore unexpected event from dsp\n", __func__);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return;
-	}
-	used_buf = list_first_entry(&audio->out_queue,
-					struct audio_aio_buffer_node, list);
-	if (token == used_buf->token) {
-		list_del(&used_buf->list);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		pr_debug("%s[%pK]:consumed buffer\n", __func__, audio);
-		event_payload.aio_buf = used_buf->buf;
-		audio_aio_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-					event_payload);
-		kfree(used_buf);
-		if (list_empty(&audio->out_queue) &&
-			(audio->drv_status & ADRV_STATUS_FSYNC)) {
-			pr_debug("%s[%pK]: list is empty, reached EOS in Tunnel\n",
-				 __func__, audio);
-			wake_up(&audio->write_wait);
-		}
-	} else {
-		pr_err("%s[%pK]:expected=%x ret=%x\n",
-			__func__, audio, used_buf->token, token);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-}
-
-/* ------------------- device --------------------- */
-void audio_aio_async_out_flush(struct q6audio_aio *audio)
-{
-	struct audio_aio_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-	unsigned long flags;
-
-	pr_debug("%s[%pK}\n", __func__, audio);
-	/* EOS followed by flush, EOS response not guranteed, free EOS i/p
-	 * buffer
-	 */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (audio->eos_flag && (audio->eos_write_payload.aio_buf.buf_addr)) {
-		pr_debug("%s[%pK]: EOS followed by flush received,acknowledge eos i/p buffer immediately\n",
-			__func__, audio);
-		audio_aio_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				audio->eos_write_payload);
-		memset(&audio->eos_write_payload, 0,
-			sizeof(union msm_audio_event_payload));
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audio_aio_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audio_aio_post_event(audio, AUDIO_EVENT_WRITE_DONE, payload);
-		kfree(buf_node);
-		pr_debug("%s[%pK]: Propagate WRITE_DONE during flush\n",
-				__func__, audio);
-	}
-}
-
-void audio_aio_async_in_flush(struct q6audio_aio *audio)
-{
-	struct audio_aio_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	pr_debug("%s[%pK]\n", __func__, audio);
-	list_for_each_safe(ptr, next, &audio->in_queue) {
-		buf_node = list_entry(ptr, struct audio_aio_buffer_node, list);
-		list_del(&buf_node->list);
-		/* Forcefull send o/p eos buffer after flush, if no eos response
-		 * received by dsp even after sending eos command
-		 */
-		if ((audio->eos_rsp != 1) && audio->eos_flag) {
-			pr_debug("%s[%pK]: send eos on o/p buffer during flush\n",
-				 __func__, audio);
-			payload.aio_buf = buf_node->buf;
-			payload.aio_buf.data_len =
-					insert_eos_buf(audio, buf_node);
-			audio->eos_flag = 0;
-		} else {
-			payload.aio_buf = buf_node->buf;
-			payload.aio_buf.data_len =
-					insert_meta_data_flush(audio, buf_node);
-		}
-		audio_aio_post_event(audio, AUDIO_EVENT_READ_DONE, payload);
-		kfree(buf_node);
-		pr_debug("%s[%pK]: Propagate READ_DONE during flush\n",
-				__func__, audio);
-	}
-}
-
-int audio_aio_enable(struct q6audio_aio  *audio)
-{
-	/* 2nd arg: 0 -> run immediately
-	 * 3rd arg: 0 -> msw_ts,
-	 * 4th arg: 0 ->lsw_ts
-	 */
-	return q6asm_run(audio->ac, 0x00, 0x00, 0x00);
-}
-
-int audio_aio_disable(struct q6audio_aio *audio)
-{
-	int rc = 0;
-
-	if (audio->opened) {
-		audio->enabled = 0;
-		audio->opened = 0;
-		pr_debug("%s[%pK]: inbytes[%d] insamples[%d]\n", __func__,
-			audio, atomic_read(&audio->in_bytes),
-			atomic_read(&audio->in_samples));
-		/* Close the session */
-		rc = q6asm_cmd(audio->ac, CMD_CLOSE);
-		if (rc < 0)
-			pr_err("%s[%pK]:Failed to close the session rc=%d\n",
-				__func__, audio, rc);
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->cmd_wait);
-	}
-	pr_debug("%s[%pK]:enabled[%d]\n", __func__, audio, audio->enabled);
-	return rc;
-}
-
-void audio_aio_reset_ion_region(struct q6audio_aio *audio)
-{
-	struct audio_aio_ion_region *region;
-	struct list_head *ptr, *next;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audio_aio_ion_region, list);
-		list_del(&region->list);
-		msm_audio_ion_free_legacy(audio->client, region->handle);
-		kfree(region);
-	}
-}
-
-void audio_aio_reset_event_queue(struct q6audio_aio *audio)
-{
-	unsigned long flags;
-	struct audio_aio_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				   struct audio_aio_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				   struct audio_aio_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-}
-
-static void audio_aio_unmap_ion_region(struct q6audio_aio *audio)
-{
-	struct audio_aio_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	pr_debug("%s[%pK]:\n", __func__, audio);
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audio_aio_ion_region, list);
-		if (region != NULL) {
-			pr_debug("%s[%pK]: phy_address = 0x%pK\n",
-				__func__, audio, &region->paddr);
-			rc = q6asm_memory_unmap(audio->ac,
-						region->paddr, IN);
-			if (rc < 0)
-				pr_err("%s[%pK]: memory unmap failed\n",
-					__func__, audio);
-		}
-	}
-}
-
-#ifdef CONFIG_USE_DEV_CTRL_VOLUME
-
-static void audio_aio_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct q6audio_aio *audio = (struct q6audio_aio *) private_data;
-	int rc  = 0;
-
-	switch (evt_id) {
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->volume = evt_payload->session_vol;
-		pr_debug("%s[%pK]: AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d, enabled = %d\n",
-			__func__, audio, audio->volume, audio->enabled);
-		if (audio->enabled == 1) {
-			if (audio->ac) {
-				rc = q6asm_set_volume(audio->ac, audio->volume);
-				if (rc < 0) {
-					pr_err("%s[%pK]: Send Volume command failed rc=%d\n",
-						__func__, audio, rc);
-				}
-			}
-		}
-		break;
-	default:
-		pr_err("%s[%pK]:ERROR:wrong event\n", __func__, audio);
-		break;
-	}
-}
-
-int register_volume_listener(struct q6audio_aio *audio)
-{
-	int rc  = 0;
-
-	audio->device_events = AUDDEV_EVT_STREAM_VOL_CHG;
-	audio->drv_status &= ~ADRV_STATUS_PAUSE;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->ac->session,
-					audio_aio_listner,
-					(void *)audio);
-	if (rc < 0) {
-		pr_err("%s[%pK]: Event listener failed\n", __func__, audio);
-		rc = -EACCES;
-	}
-	return rc;
-}
-void unregister_volume_listener(struct q6audio_aio *audio)
-{
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->ac->session);
-}
-
-int enable_volume_ramp(struct q6audio_aio *audio)
-{
-	int rc = 0;
-	struct asm_softpause_params softpause;
-	struct asm_softvolume_params softvol;
-
-	if (audio->ac == NULL)
-		return -EINVAL;
-	pr_debug("%s[%pK]\n", __func__, audio);
-	softpause.enable = SOFT_PAUSE_ENABLE;
-	softpause.period = SOFT_PAUSE_PERIOD;
-	softpause.step = SOFT_PAUSE_STEP;
-	softpause.rampingcurve = SOFT_PAUSE_CURVE_LINEAR;
-
-	softvol.period = SOFT_VOLUME_PERIOD;
-	softvol.step = SOFT_VOLUME_STEP;
-	softvol.rampingcurve = SOFT_VOLUME_CURVE_LINEAR;
-
-	if (softpause.rampingcurve == SOFT_PAUSE_CURVE_LINEAR)
-		softpause.step = SOFT_PAUSE_STEP_LINEAR;
-	if (softvol.rampingcurve == SOFT_VOLUME_CURVE_LINEAR)
-		softvol.step = SOFT_VOLUME_STEP_LINEAR;
-	rc = q6asm_set_volume(audio->ac, audio->volume);
-	if (rc < 0) {
-		pr_err("%s: Send Volume command failed rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-	rc = q6asm_set_softpause(audio->ac, &softpause);
-	if (rc < 0) {
-		pr_err("%s: Send SoftPause Param failed rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-	rc = q6asm_set_softvolume(audio->ac, &softvol);
-	if (rc < 0) {
-		pr_err("%s: Send SoftVolume Param failed rc=%d\n",
-		__func__, rc);
-		return rc;
-	}
-	/* disable mute by default */
-	rc = q6asm_set_mute(audio->ac, 0);
-	if (rc < 0) {
-		pr_err("%s: Send mute command failed rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-	return rc;
-}
-
-#else /*CONFIG_USE_DEV_CTRL_VOLUME*/
-int register_volume_listener(struct q6audio_aio *audio)
-{
-	return 0;/* do nothing */
-}
-void unregister_volume_listener(struct q6audio_aio *audio)
-{
-	return;/* do nothing */
-}
-int enable_volume_ramp(struct q6audio_aio *audio)
-{
-	return 0; /* do nothing */
-}
-#endif /*CONFIG_USE_DEV_CTRL_VOLUME*/
-
-int audio_aio_release(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = file->private_data;
-
-	pr_debug("%s[%pK]\n", __func__, audio);
-	mutex_lock(&lock);
-	mutex_lock(&audio->lock);
-	mutex_lock(&audio->read_lock);
-	mutex_lock(&audio->write_lock);
-	audio->wflush = 1;
-	if (audio->wakelock_voted &&
-		(audio->audio_ws_mgr != NULL) &&
-		(audio->miscdevice != NULL)) {
-		audio->wakelock_voted = false;
-		mutex_lock(&audio->audio_ws_mgr->ws_lock);
-		if ((audio->audio_ws_mgr->ref_cnt > 0) &&
-				(--audio->audio_ws_mgr->ref_cnt == 0)) {
-			pm_relax(audio->miscdevice->this_device);
-		}
-		mutex_unlock(&audio->audio_ws_mgr->ws_lock);
-	}
-	if (audio->enabled)
-		audio_aio_flush(audio);
-	audio->wflush = 0;
-	audio->drv_ops.out_flush(audio);
-	audio->drv_ops.in_flush(audio);
-	audio_aio_disable(audio);
-	audio_aio_unmap_ion_region(audio);
-	audio_aio_reset_ion_region(audio);
-	msm_audio_ion_client_destroy(audio->client);
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audio_aio_reset_event_queue(audio);
-	q6asm_audio_client_free(audio->ac);
-	mutex_unlock(&audio->write_lock);
-	mutex_unlock(&audio->read_lock);
-	mutex_unlock(&audio->lock);
-	mutex_destroy(&audio->lock);
-	mutex_destroy(&audio->read_lock);
-	mutex_destroy(&audio->write_lock);
-	mutex_destroy(&audio->get_event_lock);
-	unregister_volume_listener(audio);
-
-#ifdef CONFIG_DEBUG_FS
-	debugfs_remove(audio->dentry);
-#endif
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	file->private_data = NULL;
-	mutex_unlock(&lock);
-	return 0;
-}
-
-int audio_aio_fsync(struct file *file, loff_t start, loff_t end, int datasync)
-{
-	int rc = 0;
-	struct q6audio_aio *audio = file->private_data;
-
-	if (!audio->enabled || audio->feedback)
-		return -EINVAL;
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	pr_debug("%s[%pK]:\n", __func__, audio);
-
-	audio->eos_rsp = 0;
-
-	pr_debug("%s[%pK]Wait for write done from DSP\n", __func__, audio);
-	rc = wait_event_interruptible(audio->write_wait,
-					(list_empty(&audio->out_queue)) ||
-					audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush) {
-		pr_debug("%s[%pK]: Audio Flushed or Stopped,this is not EOS\n"
-			, __func__, audio);
-		audio->wflush = 0;
-		rc = -EBUSY;
-	}
-
-	if (rc < 0) {
-		pr_err("%s[%pK]: wait event for list_empty failed, rc = %d\n",
-			__func__, audio, rc);
-		goto done;
-	}
-
-	rc = q6asm_cmd(audio->ac, CMD_EOS);
-	pr_debug("%s[%pK]: EOS cmd sent to DSP\n", __func__, audio);
-
-	if (rc < 0)
-		pr_err("%s[%pK]: q6asm_cmd failed, rc = %d",
-			__func__, audio, rc);
-
-	pr_debug("%s[%pK]: wait for RENDERED_EOS from DSP\n"
-		, __func__, audio);
-	rc = wait_event_interruptible(audio->write_wait,
-					(audio->eos_rsp || audio->wflush ||
-					audio->stopped));
-
-	if (rc < 0) {
-		pr_err("%s[%pK]: wait event for eos_rsp failed, rc = %d\n",
-			__func__, audio, rc);
-		goto done;
-	}
-
-	if (audio->stopped || audio->wflush) {
-		audio->wflush = 0;
-		pr_debug("%s[%pK]: Audio Flushed or Stopped,this is not EOS\n"
-			, __func__, audio);
-		rc = -EBUSY;
-	}
-
-	if (audio->eos_rsp == 1)
-		pr_debug("%s[%pK]: EOS\n", __func__, audio);
-
-
-done:
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-static int audio_aio_events_pending(struct q6audio_aio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort || audio->reset_event;
-}
-
-static long audio_aio_process_event_req_common(struct q6audio_aio *audio,
-					struct msm_audio_event *usr_evt)
-{
-	long rc;
-	struct audio_aio_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	timeout = usr_evt->timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(audio->event_wait,
-						audio_aio_events_pending
-						(audio),
-						msecs_to_jiffies
-						(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(audio->event_wait,
-		audio_aio_events_pending(audio));
-	}
-	if (rc < 0)
-		return rc;
-
-	if (audio->reset_event) {
-		audio->reset_event = false;
-		pr_err("In SSR, post ENETRESET err\n");
-		return -ENETRESET;
-	}
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-		   struct audio_aio_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt->event_type = drv_evt->event_type;
-		usr_evt->event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else {
-		pr_err("%s[%pK]:Unexpected path\n", __func__, audio);
-		spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-		return -EPERM;
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt->event_type == AUDIO_EVENT_WRITE_DONE) {
-		pr_debug("%s[%pK]:posted AUDIO_EVENT_WRITE_DONE to user\n",
-			__func__, audio);
-		mutex_lock(&audio->write_lock);
-		audio_aio_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-		drv_evt->payload.aio_buf.buf_len, 0, 0);
-		mutex_unlock(&audio->write_lock);
-	} else if (drv_evt->event_type == AUDIO_EVENT_READ_DONE) {
-		pr_debug("%s[%pK]:posted AUDIO_EVENT_READ_DONE to user\n",
-			__func__, audio);
-		mutex_lock(&audio->read_lock);
-		audio_aio_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-		drv_evt->payload.aio_buf.buf_len, 0, 0);
-		mutex_unlock(&audio->read_lock);
-	}
-
-	/* Some read buffer might be held up in DSP,release all
-	 * Once EOS indicated
-	 */
-	if (audio->eos_rsp && !list_empty(&audio->in_queue)) {
-		pr_debug("%s[%pK]:Send flush command to release read buffers held up in DSP\n",
-			__func__, audio);
-		mutex_lock(&audio->lock);
-		audio_aio_flush(audio);
-		mutex_unlock(&audio->lock);
-	}
-
-	return rc;
-}
-
-static long audio_aio_process_event_req(struct q6audio_aio *audio,
-					void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event))) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return -EFAULT;
-	}
-
-	rc = audio_aio_process_event_req_common(audio, &usr_evt);
-
-	if (copy_to_user(arg, &usr_evt, sizeof(usr_evt))) {
-		pr_err("%s: copy_to_user failed\n", __func__);
-		rc = -EFAULT;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-
-struct msm_audio_aio_buf32 {
-	compat_uptr_t buf_addr;
-	u32 buf_len;
-	u32 data_len;
-	compat_uptr_t private_data;
-	u16 mfield_sz; /*only useful for data has meta field */
-};
-
-struct msm_audio_bitstream_info32 {
-	u32 codec_type;
-	u32 chan_info;
-	u32 sample_rate;
-	u32 bit_stream_info;
-	u32 bit_rate;
-	u32 unused[3];
-};
-
-struct msm_audio_bitstream_error_info32 {
-	u32 dec_id;
-	u32 err_msg_indicator;
-	u32 err_type;
-};
-
-union msm_audio_event_payload32 {
-	struct msm_audio_aio_buf32 aio_buf;
-	struct msm_audio_bitstream_info32 stream_info;
-	struct msm_audio_bitstream_error_info32 error_info;
-	s32 reserved;
-};
-
-struct msm_audio_event32 {
-	s32 event_type;
-	s32 timeout_ms;
-	union msm_audio_event_payload32 event_payload;
-};
-
-static long audio_aio_process_event_req_compat(struct q6audio_aio *audio,
-					void __user *arg)
-{
-	long rc;
-	struct msm_audio_event32 usr_evt_32;
-	struct msm_audio_event usr_evt;
-	memset(&usr_evt, 0, sizeof(struct msm_audio_event));
-
-	if (copy_from_user(&usr_evt_32, arg,
-				sizeof(struct msm_audio_event32))) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return -EFAULT;
-	}
-	usr_evt.timeout_ms = usr_evt_32.timeout_ms;
-
-	rc = audio_aio_process_event_req_common(audio, &usr_evt);
-	if (rc < 0) {
-		pr_err("%s: audio process event failed, rc = %ld",
-			__func__, rc);
-		return rc;
-	}
-
-	usr_evt_32.event_type = usr_evt.event_type;
-	switch (usr_evt_32.event_type) {
-	case AUDIO_EVENT_SUSPEND:
-	case AUDIO_EVENT_RESUME:
-	case AUDIO_EVENT_WRITE_DONE:
-	case AUDIO_EVENT_READ_DONE:
-		usr_evt_32.event_payload.aio_buf.buf_addr =
-			ptr_to_compat(usr_evt.event_payload.aio_buf.buf_addr);
-		usr_evt_32.event_payload.aio_buf.buf_len =
-			usr_evt.event_payload.aio_buf.buf_len;
-		usr_evt_32.event_payload.aio_buf.data_len =
-			usr_evt.event_payload.aio_buf.data_len;
-		usr_evt_32.event_payload.aio_buf.private_data =
-		ptr_to_compat(usr_evt.event_payload.aio_buf.private_data);
-		usr_evt_32.event_payload.aio_buf.mfield_sz =
-			usr_evt.event_payload.aio_buf.mfield_sz;
-		break;
-	case AUDIO_EVENT_STREAM_INFO:
-		usr_evt_32.event_payload.stream_info.codec_type =
-			usr_evt.event_payload.stream_info.codec_type;
-		usr_evt_32.event_payload.stream_info.chan_info =
-			usr_evt.event_payload.stream_info.chan_info;
-		usr_evt_32.event_payload.stream_info.sample_rate =
-			usr_evt.event_payload.stream_info.sample_rate;
-		usr_evt_32.event_payload.stream_info.bit_stream_info =
-			usr_evt.event_payload.stream_info.bit_stream_info;
-		usr_evt_32.event_payload.stream_info.bit_rate =
-			usr_evt.event_payload.stream_info.bit_rate;
-		break;
-	case AUDIO_EVENT_BITSTREAM_ERROR_INFO:
-		usr_evt_32.event_payload.error_info.dec_id =
-			usr_evt.event_payload.error_info.dec_id;
-		usr_evt_32.event_payload.error_info.err_msg_indicator =
-			usr_evt.event_payload.error_info.err_msg_indicator;
-		usr_evt_32.event_payload.error_info.err_type =
-			usr_evt.event_payload.error_info.err_type;
-		break;
-	default:
-		pr_debug("%s: unknown audio event type = %d rc = %ld",
-			 __func__, usr_evt_32.event_type, rc);
-		return rc;
-	}
-	if (copy_to_user(arg, &usr_evt_32, sizeof(usr_evt_32))) {
-		pr_err("%s: copy_to_user failed\n", __func__);
-		rc = -EFAULT;
-	}
-	return rc;
-}
-#endif
-
-static int audio_aio_ion_check(struct q6audio_aio *audio,
-				void *vaddr, unsigned long len)
-{
-	struct audio_aio_ion_region *region_elt;
-	struct audio_aio_ion_region t = {.vaddr = vaddr, .len = len };
-
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-			OVERLAPS(region_elt, &t)) {
-			pr_err("%s[%pK]:region (vaddr %pK len %ld) clashes with registered region (vaddr %pK paddr %pK len %ld)\n",
-				__func__, audio, vaddr, len,
-				region_elt->vaddr,
-				&region_elt->paddr, region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
-static int audio_aio_ion_add(struct q6audio_aio *audio,
-				struct msm_audio_ion_info *info)
-{
-	ion_phys_addr_t paddr = 0;
-	size_t len = 0;
-	struct audio_aio_ion_region *region;
-	int rc = -EINVAL;
-	struct ion_handle *handle = NULL;
-	unsigned long ionflag;
-	void *kvaddr = NULL;
-
-	pr_debug("%s[%pK]:\n", __func__, audio);
-	region = kmalloc(sizeof(*region), GFP_KERNEL);
-
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	rc = msm_audio_ion_import_legacy("Audio_Dec_Client", audio->client,
-				&handle, info->fd, &ionflag,
-				0, &paddr, &len, &kvaddr);
-	if (rc) {
-		pr_err("%s: msm audio ion alloc failed\n", __func__);
-		goto import_error;
-	}
-
-	rc = audio_aio_ion_check(audio, info->vaddr, len);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_ion_check failed\n", __func__);
-		goto ion_error;
-	}
-
-	region->handle = handle;
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->paddr = paddr;
-	region->kvaddr = kvaddr;
-	region->len = len;
-	region->ref_cnt = 0;
-	pr_debug("%s[%pK]:add region paddr %pK vaddr %pK, len %lu kvaddr %pK\n",
-		__func__, audio,
-		&region->paddr, region->vaddr, region->len,
-		region->kvaddr);
-	list_add_tail(&region->list, &audio->ion_region_queue);
-	rc = q6asm_memory_map(audio->ac,  paddr, IN, len, 1);
-	if (rc < 0) {
-		pr_err("%s[%pK]: memory map failed\n", __func__, audio);
-		goto mmap_error;
-	} else {
-		goto end;
-	}
-mmap_error:
-	list_del(&region->list);
-ion_error:
-	msm_audio_ion_free_legacy(audio->client, handle);
-import_error:
-	kfree(region);
-end:
-	return rc;
-}
-
-static int audio_aio_ion_remove(struct q6audio_aio *audio,
-				struct msm_audio_ion_info *info)
-{
-	struct audio_aio_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	pr_debug("%s[%pK]:info fd %d vaddr %pK\n",
-		__func__, audio, info->fd, info->vaddr);
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audio_aio_ion_region, list);
-
-		if ((region->fd == info->fd) &&
-			(region->vaddr == info->vaddr)) {
-			if (region->ref_cnt) {
-				pr_debug("%s[%pK]:region %pK in use ref_cnt %d\n",
-					__func__, audio, region,
-					region->ref_cnt);
-				break;
-			}
-			pr_debug("%s[%pK]:remove region fd %d vaddr %pK\n",
-				__func__, audio, info->fd, info->vaddr);
-			rc = q6asm_memory_unmap(audio->ac,
-						region->paddr, IN);
-			if (rc < 0)
-				pr_err("%s[%pK]: memory unmap failed\n",
-					__func__, audio);
-
-			list_del(&region->list);
-			msm_audio_ion_free_legacy(audio->client,
-						 region->handle);
-			kfree(region);
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int audio_aio_async_write(struct q6audio_aio *audio,
-				struct audio_aio_buffer_node *buf_node)
-{
-	int rc;
-	struct audio_client *ac;
-	struct audio_aio_write_param param;
-
-	memset(&param, 0, sizeof(param));
-
-	if (!audio || !buf_node) {
-		pr_err("%s NULL pointer audio=[0x%pK], buf_node=[0x%pK]\n",
-			__func__, audio, buf_node);
-		return -EINVAL;
-	}
-	pr_debug("%s[%pK]: Send write buff %pK phy %pK len %d meta_enable = %d\n",
-		__func__, audio, buf_node, &buf_node->paddr,
-		buf_node->buf.data_len,
-		audio->buf_cfg.meta_info_enable);
-	pr_debug("%s[%pK]: flags = 0x%x\n", __func__, audio,
-		buf_node->meta_info.meta_in.nflags);
-
-	ac = audio->ac;
-	/* Offset with  appropriate meta */
-	if (audio->feedback) {
-		/* Non Tunnel mode */
-		param.paddr = buf_node->paddr + sizeof(struct dec_meta_in);
-		param.len = buf_node->buf.data_len - sizeof(struct dec_meta_in);
-	} else {
-		/* Tunnel mode */
-		param.paddr = buf_node->paddr;
-		param.len = buf_node->buf.data_len;
-	}
-	param.msw_ts = buf_node->meta_info.meta_in.ntimestamp.highpart;
-	param.lsw_ts = buf_node->meta_info.meta_in.ntimestamp.lowpart;
-	param.flags  = buf_node->meta_info.meta_in.nflags;
-	/* If no meta_info enaled, indicate no time stamp valid */
-	if (!audio->buf_cfg.meta_info_enable)
-		param.flags = 0xFF00;
-
-	if (buf_node->meta_info.meta_in.nflags & AUDIO_DEC_EOF_SET)
-		param.flags |= AUDIO_DEC_EOF_SET;
-
-	param.uid = ac->session;
-	/* Read command will populate session id as token */
-	buf_node->token = ac->session;
-	rc = q6asm_async_write(ac, &param);
-	if (rc < 0)
-		pr_err("%s[%pK]:failed\n", __func__, audio);
-	return rc;
-}
-
-void audio_aio_post_event(struct q6audio_aio *audio, int type,
-			union msm_audio_event_payload payload)
-{
-	struct audio_aio_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-					struct audio_aio_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audio_aio_event), GFP_ATOMIC);
-		if (!e_node) {
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static int audio_aio_async_read(struct q6audio_aio *audio,
-				struct audio_aio_buffer_node *buf_node)
-{
-	struct audio_client *ac;
-	struct audio_aio_read_param param;
-	int rc;
-
-	pr_debug("%s[%pK]: Send read buff %pK phy %pK len %d\n",
-		__func__, audio, buf_node,
-		&buf_node->paddr, buf_node->buf.buf_len);
-	ac = audio->ac;
-	/* Provide address so driver can append nr frames information */
-	param.paddr = buf_node->paddr +
-		sizeof(struct dec_meta_out);
-	param.len = buf_node->buf.buf_len -
-		sizeof(struct dec_meta_out);
-	param.uid = ac->session;
-	/* Write command will populate session_id as token */
-	buf_node->token = ac->session;
-	rc = q6asm_async_read(ac, &param);
-	if (rc < 0)
-		pr_err("%s[%pK]:failed\n", __func__, audio);
-	return rc;
-}
-
-static int audio_aio_buf_add_shared(struct q6audio_aio *audio, u32 dir,
-				struct audio_aio_buffer_node *buf_node)
-{
-	unsigned long flags;
-	int ret = 0;
-
-	pr_debug("%s[%pK]:node %pK dir %x buf_addr %pK buf_len %d data_len %d\n",
-		 __func__, audio, buf_node, dir, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, buf_node->buf.data_len);
-	buf_node->paddr = audio_aio_ion_fixup(audio, buf_node->buf.buf_addr,
-						buf_node->buf.buf_len, 1,
-						&buf_node->kvaddr);
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-			(buf_node->paddr & 0x1) ||
-			(!audio->feedback && !buf_node->buf.data_len)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		extract_meta_out_info(audio, buf_node, 1);
-		/* Not a EOS buffer */
-		if (!(buf_node->meta_info.meta_in.nflags & AUDIO_DEC_EOS_SET)) {
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			ret = audio_aio_async_write(audio, buf_node);
-			/* EOS buffer handled in driver */
-			list_add_tail(&buf_node->list, &audio->out_queue);
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		} else if (buf_node->meta_info.meta_in.nflags
-				   & AUDIO_DEC_EOS_SET) {
-			if (!audio->wflush) {
-				pr_debug("%s[%pK]:Send EOS cmd at i/p\n",
-					__func__, audio);
-				/* Driver will forcefully post writedone event
-				 * once eos ack recived from DSP
-				 */
-				audio->eos_write_payload.aio_buf =
-					buf_node->buf;
-				audio->eos_flag = 1;
-				audio->eos_rsp = 0;
-				q6asm_cmd(audio->ac, CMD_EOS);
-				kfree(buf_node);
-			} else { /* Flush in progress, send back i/p
-				  * EOS buffer as is
-				  */
-				union msm_audio_event_payload event_payload;
-
-				event_payload.aio_buf = buf_node->buf;
-				audio_aio_post_event(audio,
-						AUDIO_EVENT_WRITE_DONE,
-						event_payload);
-				kfree(buf_node);
-			}
-		}
-	} else {
-		/* read */
-		if (!buf_node->paddr ||
-			(buf_node->paddr & 0x1) ||
-			(buf_node->buf.buf_len < PCM_BUFSZ_MIN)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		/* No EOS reached */
-		if (!audio->eos_rsp) {
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			ret = audio_aio_async_read(audio, buf_node);
-			/* EOS buffer handled in driver */
-			list_add_tail(&buf_node->list, &audio->in_queue);
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		}
-		/* EOS reached at input side fake all upcoming read buffer to
-		 * indicate the same
-		 */
-		else {
-			union msm_audio_event_payload event_payload;
-
-			event_payload.aio_buf = buf_node->buf;
-			event_payload.aio_buf.data_len =
-				insert_eos_buf(audio, buf_node);
-			pr_debug("%s[%pK]: propagate READ_DONE as EOS done\n",
-				__func__, audio);
-			audio_aio_post_event(audio, AUDIO_EVENT_READ_DONE,
-					event_payload);
-			kfree(buf_node);
-		}
-	}
-	return ret;
-}
-#ifdef CONFIG_COMPAT
-static int audio_aio_buf_add_compat(struct q6audio_aio *audio, u32 dir,
-				void __user *arg)
-{
-	struct audio_aio_buffer_node *buf_node;
-	struct msm_audio_aio_buf32 aio_buf_32;
-
-	buf_node = kzalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&aio_buf_32, arg, sizeof(aio_buf_32))) {
-		kfree(buf_node);
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return -EFAULT;
-	}
-
-	buf_node->buf.buf_addr = compat_ptr(aio_buf_32.buf_addr);
-	buf_node->buf.buf_len = aio_buf_32.buf_len;
-	buf_node->buf.data_len = aio_buf_32.data_len;
-	buf_node->buf.private_data = compat_ptr(aio_buf_32.private_data);
-	buf_node->buf.mfield_sz = aio_buf_32.mfield_sz;
-
-	return audio_aio_buf_add_shared(audio, dir, buf_node);
-}
-#endif
-
-static int audio_aio_buf_add(struct q6audio_aio *audio, u32 dir,
-				void __user *arg)
-{
-	struct audio_aio_buffer_node *buf_node;
-
-	buf_node = kzalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return -EFAULT;
-	}
-
-	return audio_aio_buf_add_shared(audio, dir, buf_node);
-}
-
-void audio_aio_ioport_reset(struct q6audio_aio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			pr_debug("%s[%pK]:fsync in progress\n",
-				 __func__, audio);
-			audio->drv_ops.out_flush(audio);
-		} else
-			audio->drv_ops.out_flush(audio);
-		if (audio->feedback == NON_TUNNEL_MODE)
-			audio->drv_ops.in_flush(audio);
-	}
-}
-
-int audio_aio_open(struct q6audio_aio *audio, struct file *file)
-{
-	int rc = 0;
-	int i;
-	struct audio_aio_event *e_node = NULL;
-	struct list_head *ptr, *next;
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	audio->pcm_cfg.sample_rate = 48000;
-	audio->pcm_cfg.channel_count = 2;
-
-	/* Only AIO interface */
-	if (file->f_flags & O_NONBLOCK) {
-		pr_debug("%s[%pK]:set to aio interface\n", __func__, audio);
-		audio->drv_status |= ADRV_STATUS_AIO_INTF;
-		audio->drv_ops.out_flush = audio_aio_async_out_flush;
-		audio->drv_ops.in_flush = audio_aio_async_in_flush;
-		q6asm_set_io_mode(audio->ac, ASYNC_IO_MODE);
-	} else {
-		pr_err("%s[%pK]:SIO interface not supported\n",
-			__func__, audio);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->cmd_wait);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->event_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->in_queue);
-	INIT_LIST_HEAD(&audio->ion_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-
-	audio->drv_ops.out_flush(audio);
-	audio->opened = 1;
-	audio->reset_event = false;
-	file->private_data = audio;
-	audio->codec_ioctl = audio_aio_ioctl;
-	audio->codec_compat_ioctl = audio_aio_compat_ioctl;
-	for (i = 0; i < AUDIO_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audio_aio_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			rc = -ENOMEM;
-			goto cleanup;
-		}
-	}
-	audio->client = msm_audio_ion_client_create("Audio_Dec_Client");
-	if (IS_ERR_OR_NULL(audio->client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto cleanup;
-	}
-	pr_debug("Ion client create in audio_aio_open %pK", audio->client);
-
-	rc = register_volume_listener(audio);
-	if (rc < 0)
-		goto ion_cleanup;
-
-	return 0;
-ion_cleanup:
-	msm_audio_ion_client_destroy(audio->client);
-	audio->client = NULL;
-cleanup:
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				   struct audio_aio_event, list);
-		list_del(&e_node->list);
-		kfree(e_node);
-	}
-fail:
-	return rc;
-}
-
-static long audio_aio_shared_ioctl(struct file *file, unsigned int cmd,
-			unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_ABORT_GET_EVENT: {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		break;
-	}
-	case AUDIO_OUTPORT_FLUSH: {
-		pr_debug("%s[%pK]:AUDIO_OUTPORT_FLUSH\n", __func__, audio);
-		mutex_lock(&audio->read_lock);
-		rc = audio_aio_outport_flush(audio);
-		if (rc < 0) {
-			pr_err("%s[%pK]: AUDIO_OUTPORT_FLUSH failed\n",
-				__func__, audio);
-			rc = -EINTR;
-		}
-		mutex_unlock(&audio->read_lock);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s[%pK]: AUDIO_STOP session_id[%d]\n", __func__,
-				audio, audio->ac->session);
-		mutex_lock(&audio->lock);
-		audio->stopped = 1;
-		rc = audio_aio_flush(audio);
-		if (rc < 0) {
-			pr_err("%s[%pK]:Audio Stop procedure failed rc=%d\n",
-				__func__, audio, rc);
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		audio->enabled = 0;
-		audio->drv_status &= ~ADRV_STATUS_PAUSE;
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			pr_debug("%s[%pK] Waking up the audio_aio_fsync\n",
-					__func__, audio);
-			wake_up(&audio->write_wait);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_PAUSE: {
-		pr_debug("%s[%pK]:AUDIO_PAUSE %ld\n", __func__, audio, arg);
-		mutex_lock(&audio->lock);
-		if (arg == 1) {
-			rc = audio_aio_pause(audio);
-			if (rc < 0) {
-				pr_err("%s[%pK]: pause FAILED rc=%d\n",
-					__func__, audio, rc);
-				mutex_unlock(&audio->lock);
-				break;
-			}
-			audio->drv_status |= ADRV_STATUS_PAUSE;
-		} else if (arg == 0) {
-			if (audio->drv_status & ADRV_STATUS_PAUSE) {
-				rc = audio_aio_enable(audio);
-				if (rc)
-					pr_err("%s[%pK]: audio enable failed\n",
-					__func__, audio);
-				else {
-					audio->drv_status &= ~ADRV_STATUS_PAUSE;
-					audio->enabled = 1;
-				}
-			}
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_FLUSH: {
-		pr_debug("%s[%pK]: AUDIO_FLUSH sessionid[%d]\n", __func__,
-			audio, audio->ac->session);
-		mutex_lock(&audio->lock);
-		audio->rflush = 1;
-		audio->wflush = 1;
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			pr_debug("%s[%pK] Waking up the audio_aio_fsync\n",
-				__func__, audio);
-			wake_up(&audio->write_wait);
-		}
-		/* Flush DSP */
-		rc = audio_aio_flush(audio);
-		/* Flush input / Output buffer in software*/
-		audio_aio_ioport_reset(audio);
-		if (rc < 0) {
-			pr_err("%s[%pK]:AUDIO_FLUSH interrupted\n",
-				__func__, audio);
-			rc = -EINTR;
-		} else {
-			audio->rflush = 0;
-			if (audio->drv_status & ADRV_STATUS_FSYNC)
-				wake_up(&audio->write_wait);
-			else
-				audio->wflush = 0;
-
-		}
-		audio->eos_flag = 0;
-		audio->eos_rsp = 0;
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		mutex_lock(&audio->lock);
-		if (copy_to_user((void *)arg, &audio->ac->session,
-			sizeof(u16))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_SESSION_ID failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_PM_AWAKE: {
-		if ((audio->audio_ws_mgr ==  NULL) ||
-				(audio->miscdevice == NULL)) {
-			pr_err("%s[%pK]: invalid ws_mgr or miscdevice",
-					__func__, audio);
-			rc = -EACCES;
-			break;
-		}
-		pr_debug("%s[%pK]:AUDIO_PM_AWAKE\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (!audio->wakelock_voted) {
-			audio->wakelock_voted = true;
-			mutex_lock(&audio->audio_ws_mgr->ws_lock);
-			if (audio->audio_ws_mgr->ref_cnt++ == 0)
-				pm_stay_awake(audio->miscdevice->this_device);
-			mutex_unlock(&audio->audio_ws_mgr->ws_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_PM_RELAX: {
-		if ((audio->audio_ws_mgr ==  NULL) ||
-				(audio->miscdevice == NULL)) {
-			pr_err("%s[%pK]: invalid ws_mgr or miscdevice",
-					__func__, audio);
-			rc = -EACCES;
-			break;
-		}
-		pr_debug("%s[%pK]:AUDIO_PM_RELAX\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (audio->wakelock_voted) {
-			audio->wakelock_voted = false;
-			mutex_lock(&audio->audio_ws_mgr->ws_lock);
-			if ((audio->audio_ws_mgr->ref_cnt > 0) &&
-					(--audio->audio_ws_mgr->ref_cnt == 0)) {
-				pm_relax(audio->miscdevice->this_device);
-			}
-			mutex_unlock(&audio->audio_ws_mgr->ws_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc =  -EINVAL;
-	}
-	return rc;
-
-
-}
-
-static long audio_aio_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_ABORT_GET_EVENT:
-	case AUDIO_OUTPORT_FLUSH:
-	case AUDIO_STOP:
-	case AUDIO_PAUSE:
-	case AUDIO_FLUSH:
-	case AUDIO_GET_SESSION_ID:
-	case AUDIO_PM_AWAKE:
-	case AUDIO_PM_RELAX:
-		rc = audio_aio_shared_ioctl(file, cmd, arg);
-		break;
-	case AUDIO_GET_STATS: {
-		struct msm_audio_stats stats;
-		uint64_t timestamp;
-
-		memset(&stats, 0, sizeof(struct msm_audio_stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		rc = q6asm_get_session_time(audio->ac, &timestamp);
-		if (rc >= 0)
-			memcpy(&stats.unused[0], &timestamp, sizeof(timestamp));
-		else
-			pr_debug("Error while getting timestamp\n");
-		if (copy_to_user((void *)arg, &stats, sizeof(stats))) {
-			pr_err("%s: copy_frm_user for AUDIO_GET_STATS failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_GET_EVENT: {
-		pr_debug("%s[%pK]:AUDIO_GET_EVENT\n", __func__, audio);
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audio_aio_process_event_req(audio,
-						(void __user *)arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		break;
-	}
-	case AUDIO_ASYNC_WRITE: {
-		mutex_lock(&audio->write_lock);
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else {
-			if (audio->enabled)
-				rc = audio_aio_buf_add(audio, 1,
-						(void __user *)arg);
-			else
-				rc = -EPERM;
-		}
-		mutex_unlock(&audio->write_lock);
-		break;
-	}
-	case AUDIO_ASYNC_READ: {
-		mutex_lock(&audio->read_lock);
-		if (audio->feedback)
-			rc = audio_aio_buf_add(audio, 0,
-					(void __user *)arg);
-		else
-			rc = -EPERM;
-		mutex_unlock(&audio->read_lock);
-		break;
-	}
-
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-
-		mutex_lock(&audio->lock);
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->str_cfg.buffer_size;
-		cfg.buffer_count = audio->str_cfg.buffer_count;
-		pr_debug("%s[%pK]:GET STREAM CFG %d %d\n",
-			__func__, audio, cfg.buffer_size, cfg.buffer_count);
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_STREAM_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-
-		pr_debug("%s[%pK]:SET STREAM CONFIG\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_SET_STREAM_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		audio->str_cfg.buffer_size = FRAME_SIZE;
-		audio->str_cfg.buffer_count = FRAME_NUM;
-		rc = 0;
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-
-		mutex_lock(&audio->lock);
-		if (copy_to_user((void *)arg, &audio->pcm_cfg, sizeof(cfg))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-
-		pr_err("%s[%pK]:AUDIO_SET_CONFIG\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&config, (void *)arg, sizeof(config))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_SET_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		if (audio->feedback != NON_TUNNEL_MODE) {
-			pr_err("%s[%pK]:Not sufficient permission to change the playback mode\n",
-				 __func__, audio);
-			rc = -EACCES;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		if ((config.buffer_count > PCM_BUF_COUNT) ||
-			(config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-		audio->pcm_cfg.buffer_count = config.buffer_count;
-		audio->pcm_cfg.buffer_size = config.buffer_size;
-		audio->pcm_cfg.channel_count = config.channel_count;
-		audio->pcm_cfg.sample_rate = config.sample_rate;
-		rc = 0;
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_BUF_CFG: {
-		struct msm_audio_buf_cfg  cfg;
-
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_GET_BUF CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		if ((audio->feedback == NON_TUNNEL_MODE) &&
-			!cfg.meta_info_enable) {
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-
-		audio->buf_cfg.meta_info_enable = cfg.meta_info_enable;
-		pr_debug("%s[%pK]:session id %d: Set-buf-cfg: meta[%d]",
-				__func__, audio,
-				audio->ac->session, cfg.meta_info_enable);
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_GET_BUF_CFG: {
-		pr_debug("%s[%pK]:session id %d: Get-buf-cfg: meta[%d] framesperbuf[%d]\n",
-			 __func__, audio,
-			audio->ac->session, audio->buf_cfg.meta_info_enable,
-			audio->buf_cfg.frames_per_buf);
-
-		mutex_lock(&audio->lock);
-		if (copy_to_user((void *)arg, &audio->buf_cfg,
-			sizeof(struct msm_audio_buf_cfg))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_BUF_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_REGISTER_ION: {
-		struct msm_audio_ion_info info;
-
-		pr_debug("%s[%pK]:AUDIO_REGISTER_ION\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&info, (void *)arg, sizeof(info))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_REGISTER_ION failed\n",
-				__func__);
-			rc = -EFAULT;
-		} else {
-			mutex_lock(&audio->read_lock);
-			mutex_lock(&audio->write_lock);
-			rc = audio_aio_ion_add(audio, &info);
-			mutex_unlock(&audio->write_lock);
-			mutex_unlock(&audio->read_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_DEREGISTER_ION: {
-		struct msm_audio_ion_info info;
-
-		mutex_lock(&audio->lock);
-		pr_debug("%s[%pK]:AUDIO_DEREGISTER_ION\n", __func__, audio);
-		if (copy_from_user(&info, (void *)arg, sizeof(info))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_DEREGISTER_ION failed\n",
-				__func__);
-			rc = -EFAULT;
-		} else {
-			mutex_lock(&audio->read_lock);
-			mutex_lock(&audio->write_lock);
-			rc = audio_aio_ion_remove(audio, &info);
-			mutex_unlock(&audio->write_lock);
-			mutex_unlock(&audio->read_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc =  -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_stream_config32 {
-	u32 buffer_size;
-	u32 buffer_count;
-};
-
-struct msm_audio_stats32 {
-	u32 byte_count;
-	u32 sample_count;
-	u32 unused[2];
-};
-
-struct msm_audio_config32 {
-	u32 buffer_size;
-	u32 buffer_count;
-	u32 channel_count;
-	u32 sample_rate;
-	u32 type;
-	u32 meta_field;
-	u32 bits;
-	u32 unused[3];
-};
-
-struct msm_audio_buf_cfg32 {
-	u32 meta_info_enable;
-	u32 frames_per_buf;
-};
-
-struct msm_audio_ion_info32 {
-	int fd;
-	compat_uptr_t vaddr;
-};
-
-enum {
-	AUDIO_GET_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC, 3,
-			struct msm_audio_config32),
-	AUDIO_SET_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC, 4,
-			struct msm_audio_config32),
-	AUDIO_GET_STATS_32 = _IOR(AUDIO_IOCTL_MAGIC, 5,
-			struct msm_audio_stats32),
-	AUDIO_GET_EVENT_32 = _IOR(AUDIO_IOCTL_MAGIC, 13,
-			struct msm_audio_event32),
-	AUDIO_ASYNC_WRITE_32 = _IOW(AUDIO_IOCTL_MAGIC, 17,
-			struct msm_audio_aio_buf32),
-	AUDIO_ASYNC_READ_32 = _IOW(AUDIO_IOCTL_MAGIC, 18,
-			struct msm_audio_aio_buf32),
-	AUDIO_SET_STREAM_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC, 80,
-			struct msm_audio_stream_config32),
-	AUDIO_GET_STREAM_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC, 81,
-			struct msm_audio_stream_config32),
-	AUDIO_GET_BUF_CFG_32 = _IOW(AUDIO_IOCTL_MAGIC, 93,
-			struct msm_audio_buf_cfg32),
-	AUDIO_SET_BUF_CFG_32 = _IOW(AUDIO_IOCTL_MAGIC, 94,
-			struct msm_audio_buf_cfg32),
-	AUDIO_REGISTER_ION_32 = _IOW(AUDIO_IOCTL_MAGIC, 97,
-			struct msm_audio_ion_info32),
-	AUDIO_DEREGISTER_ION_32 = _IOW(AUDIO_IOCTL_MAGIC, 98,
-			struct msm_audio_ion_info32),
-};
-
-static long audio_aio_compat_ioctl(struct file *file, unsigned int cmd,
-			unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_ABORT_GET_EVENT:
-	case AUDIO_OUTPORT_FLUSH:
-	case AUDIO_STOP:
-	case AUDIO_PAUSE:
-	case AUDIO_FLUSH:
-	case AUDIO_GET_SESSION_ID:
-	case AUDIO_PM_AWAKE:
-	case AUDIO_PM_RELAX:
-		rc = audio_aio_shared_ioctl(file, cmd, arg);
-		break;
-	case AUDIO_GET_STATS_32: {
-		struct msm_audio_stats32 stats;
-		uint64_t timestamp;
-
-		memset(&stats, 0, sizeof(struct msm_audio_stats32));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		rc = q6asm_get_session_time(audio->ac, &timestamp);
-		if (rc >= 0)
-			memcpy(&stats.unused[0], &timestamp, sizeof(timestamp));
-		else
-			pr_debug("Error while getting timestamp\n");
-		if (copy_to_user((void *)arg, &stats, sizeof(stats))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_STATS_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_GET_EVENT_32: {
-		pr_debug("%s[%pK]:AUDIO_GET_EVENT\n", __func__, audio);
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audio_aio_process_event_req_compat(audio,
-						(void __user *)arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		break;
-	}
-	case AUDIO_ASYNC_WRITE_32: {
-		mutex_lock(&audio->write_lock);
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else {
-			if (audio->enabled)
-				rc = audio_aio_buf_add_compat(audio, 1,
-						(void __user *)arg);
-			else
-				rc = -EPERM;
-		}
-		mutex_unlock(&audio->write_lock);
-		break;
-	}
-	case AUDIO_ASYNC_READ_32: {
-		mutex_lock(&audio->read_lock);
-		if (audio->feedback)
-			rc = audio_aio_buf_add_compat(audio, 0,
-					(void __user *)arg);
-		else
-			rc = -EPERM;
-		mutex_unlock(&audio->read_lock);
-		break;
-	}
-
-	case AUDIO_GET_STREAM_CONFIG_32: {
-		struct msm_audio_stream_config32 cfg;
-
-		mutex_lock(&audio->lock);
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->str_cfg.buffer_size;
-		cfg.buffer_count = audio->str_cfg.buffer_count;
-		pr_debug("%s[%pK]:GET STREAM CFG %d %d\n",
-			__func__, audio, cfg.buffer_size, cfg.buffer_count);
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_STREAM_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG_32: {
-		struct msm_audio_stream_config32 cfg_32;
-		struct msm_audio_stream_config cfg;
-
-		pr_debug("%s[%pK]:SET STREAM CONFIG\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_STREAM_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		cfg.buffer_size = cfg_32.buffer_size;
-		cfg.buffer_count = cfg_32.buffer_count;
-
-		audio->str_cfg.buffer_size = FRAME_SIZE;
-		audio->str_cfg.buffer_count = FRAME_NUM;
-		rc = 0;
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_GET_CONFIG_32: {
-		struct msm_audio_config32 cfg_32;
-
-		mutex_lock(&audio->lock);
-		memset(&cfg_32, 0, sizeof(cfg_32));
-		cfg_32.buffer_size = audio->pcm_cfg.buffer_size;
-		cfg_32.buffer_count = audio->pcm_cfg.buffer_count;
-		cfg_32.channel_count = audio->pcm_cfg.channel_count;
-		cfg_32.sample_rate = audio->pcm_cfg.sample_rate;
-		cfg_32.type = audio->pcm_cfg.type;
-		cfg_32.meta_field = audio->pcm_cfg.meta_field;
-		cfg_32.bits = audio->pcm_cfg.bits;
-
-		if (copy_to_user((void *)arg, &cfg_32, sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_CONFIG_32: {
-		struct msm_audio_config config;
-		struct msm_audio_config32 config_32;
-
-		mutex_lock(&audio->lock);
-
-		if (audio->feedback != NON_TUNNEL_MODE) {
-			pr_err("%s[%pK]:Not sufficient permission to change the playback mode\n",
-				 __func__, audio);
-			rc = -EACCES;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		pr_err("%s[%pK]:AUDIO_SET_CONFIG\n", __func__, audio);
-		if (copy_from_user(&config_32, (void *)arg,
-					sizeof(config_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		config.buffer_size = config_32.buffer_size;
-		config.buffer_count = config_32.buffer_count;
-		config.channel_count = config_32.channel_count;
-		config.sample_rate = config_32.sample_rate;
-		config.type = config_32.type;
-		config.meta_field = config_32.meta_field;
-		config.bits = config_32.bits;
-
-		if ((config.buffer_count > PCM_BUF_COUNT) ||
-			(config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-		audio->pcm_cfg.buffer_count = config.buffer_count;
-		audio->pcm_cfg.buffer_size = config.buffer_size;
-		audio->pcm_cfg.channel_count = config.channel_count;
-		audio->pcm_cfg.sample_rate = config.sample_rate;
-		rc = 0;
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_SET_BUF_CFG_32: {
-		struct msm_audio_buf_cfg cfg;
-		struct msm_audio_buf_cfg32 cfg_32;
-
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&cfg_32, (void *)arg, sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-		cfg.meta_info_enable = cfg_32.meta_info_enable;
-		cfg.frames_per_buf = cfg_32.frames_per_buf;
-
-		if ((audio->feedback == NON_TUNNEL_MODE) &&
-			!cfg.meta_info_enable) {
-			rc = -EFAULT;
-			mutex_unlock(&audio->lock);
-			break;
-		}
-
-		audio->buf_cfg.meta_info_enable = cfg.meta_info_enable;
-		pr_debug("%s[%pK]:session id %d: Set-buf-cfg: meta[%d]",
-				__func__, audio,
-				audio->ac->session, cfg.meta_info_enable);
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_GET_BUF_CFG_32: {
-		struct msm_audio_buf_cfg32 cfg_32;
-
-		pr_debug("%s[%pK]:session id %d: Get-buf-cfg: meta[%d] framesperbuf[%d]\n",
-			 __func__, audio,
-			audio->ac->session, audio->buf_cfg.meta_info_enable,
-			audio->buf_cfg.frames_per_buf);
-		mutex_lock(&audio->lock);
-		memset(&cfg_32, 0, sizeof(cfg_32));
-		cfg_32.meta_info_enable = audio->buf_cfg.meta_info_enable;
-		cfg_32.frames_per_buf = audio->buf_cfg.frames_per_buf;
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(struct msm_audio_buf_cfg32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_BUF_CFG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_REGISTER_ION_32: {
-		struct msm_audio_ion_info32 info_32;
-		struct msm_audio_ion_info info;
-
-		pr_debug("%s[%pK]:AUDIO_REGISTER_ION\n", __func__, audio);
-		mutex_lock(&audio->lock);
-		if (copy_from_user(&info_32, (void *)arg, sizeof(info_32))) {
-			pr_err("%s: copy_from_user for AUDIO_REGISTER_ION_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		} else {
-			info.fd = info_32.fd;
-			info.vaddr = compat_ptr(info_32.vaddr);
-			mutex_lock(&audio->read_lock);
-			mutex_lock(&audio->write_lock);
-			rc = audio_aio_ion_add(audio, &info);
-			mutex_unlock(&audio->write_lock);
-			mutex_unlock(&audio->read_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	case AUDIO_DEREGISTER_ION_32: {
-		struct msm_audio_ion_info32 info_32;
-		struct msm_audio_ion_info info;
-
-		mutex_lock(&audio->lock);
-		pr_debug("%s[%pK]:AUDIO_DEREGISTER_ION\n", __func__, audio);
-		if (copy_from_user(&info_32, (void *)arg, sizeof(info_32))) {
-			pr_err("%s: copy_from_user for	AUDIO_DEREGISTER_ION_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		} else {
-			info.fd = info_32.fd;
-			info.vaddr = compat_ptr(info_32.vaddr);
-			mutex_lock(&audio->read_lock);
-			mutex_lock(&audio->write_lock);
-			rc = audio_aio_ion_remove(audio, &info);
-			mutex_unlock(&audio->write_lock);
-			mutex_unlock(&audio->read_lock);
-		}
-		mutex_unlock(&audio->lock);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc =  -EINVAL;
-	}
-	return rc;
-}
-#endif
diff --git a/drivers/misc/qcom/qdsp6v2/audio_utils_aio.h b/drivers/misc/qcom/qdsp6v2/audio_utils_aio.h
deleted file mode 100644
index 82374f9..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_utils_aio.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/* Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/wakelock.h>
-#include <linux/msm_audio.h>
-#include <linux/debugfs.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/msm_ion.h>
-#include <asm/ioctls.h>
-#include <linux/atomic.h>
-#include "q6audio_common.h"
-
-#define TUNNEL_MODE     0x0000
-#define NON_TUNNEL_MODE 0x0001
-
-#define ADRV_STATUS_AIO_INTF 0x00000001 /* AIO interface */
-#define ADRV_STATUS_FSYNC 0x00000008
-#define ADRV_STATUS_PAUSE 0x00000010
-#define AUDIO_DEC_EOS_SET  0x00000001
-#define AUDIO_DEC_EOF_SET  0x00000010
-#define AUDIO_EVENT_NUM		10
-
-#define __CONTAINS(r, v, l) ({                                  \
-	typeof(r) __r = r;                                      \
-	typeof(v) __v = v;                                      \
-	typeof(v) __e = __v + l;                                \
-	int res = ((__v >= __r->vaddr) &&                       \
-		(__e <= __r->vaddr + __r->len));                \
-	res;                                                    \
-})
-
-#define CONTAINS(r1, r2) ({                                     \
-	typeof(r2) __r2 = r2;                                   \
-	__CONTAINS(r1, __r2->vaddr, __r2->len);                 \
-})
-
-#define IN_RANGE(r, v) ({                                       \
-	typeof(r) __r = r;                                      \
-	typeof(v) __vv = v;                                     \
-	int res = ((__vv >= __r->vaddr) &&                      \
-		(__vv < (__r->vaddr + __r->len)));              \
-	res;                                                    \
-})
-
-#define OVERLAPS(r1, r2) ({                                     \
-	typeof(r1) __r1 = r1;                                   \
-	typeof(r2) __r2 = r2;                                   \
-	typeof(__r2->vaddr) __v = __r2->vaddr;                  \
-	typeof(__v) __e = __v + __r2->len - 1;                  \
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e)); \
-	res;                                                    \
-})
-
-struct timestamp {
-	u32 lowpart;
-	u32 highpart;
-} __packed;
-
-struct meta_out_dsp {
-	u32 offset_to_frame;
-	u32 frame_size;
-	u32 encoded_pcm_samples;
-	u32 msw_ts;
-	u32 lsw_ts;
-	u32 nflags;
-} __packed;
-
-struct dec_meta_in {
-	unsigned char reserved[18];
-	unsigned short offset;
-	struct timestamp ntimestamp;
-	unsigned int nflags;
-} __packed;
-
-struct dec_meta_out {
-	unsigned int reserved[7];
-	unsigned int num_of_frames;
-	struct meta_out_dsp meta_out_dsp[];
-} __packed;
-
-/* General meta field to store meta info locally */
-union  meta_data {
-	struct dec_meta_out meta_out;
-	struct dec_meta_in meta_in;
-} __packed;
-
-/* per device wakeup source manager */
-struct ws_mgr {
-	struct mutex       ws_lock;
-	uint32_t           ref_cnt;
-};
-
-#define PCM_BUF_COUNT           (2)
-/* Buffer with meta */
-#define PCM_BUFSZ_MIN           ((4*1024) + sizeof(struct dec_meta_out))
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM               (2)
-#define FRAME_SIZE	((4*1536) + sizeof(struct dec_meta_in))
-
-struct audio_aio_ion_region {
-	struct list_head list;
-	struct ion_handle *handle;
-	int fd;
-	void *vaddr;
-	phys_addr_t paddr;
-	void *kvaddr;
-	unsigned long len;
-	unsigned int ref_cnt;
-};
-
-struct audio_aio_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio_aio_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-	uint32_t token;
-	void            *kvaddr;
-	union meta_data meta_info;
-};
-
-struct q6audio_aio;
-struct audio_aio_drv_operations {
-	void (*out_flush)(struct q6audio_aio *);
-	void (*in_flush)(struct q6audio_aio *);
-};
-
-struct q6audio_aio {
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct msm_audio_stream_config str_cfg;
-	struct msm_audio_buf_cfg        buf_cfg;
-	struct msm_audio_config pcm_cfg;
-	void *codec_cfg;
-
-	struct audio_client *ac;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	struct mutex write_lock;
-	struct mutex get_event_lock;
-	wait_queue_head_t cmd_wait;
-	wait_queue_head_t write_wait;
-	wait_queue_head_t event_wait;
-	spinlock_t dsp_lock;
-	spinlock_t event_queue_lock;
-
-	struct miscdevice *miscdevice;
-	uint32_t wakelock_voted;
-	struct ws_mgr *audio_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-	struct list_head out_queue;     /* queue to retain output buffers */
-	struct list_head in_queue;      /* queue to retain input buffers */
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	struct list_head ion_region_queue;     /* protected by lock */
-	struct ion_client *client;
-	struct audio_aio_drv_operations drv_ops;
-	union msm_audio_event_payload eos_write_payload;
-	uint32_t device_events;
-	uint16_t volume;
-	uint32_t drv_status;
-	int event_abort;
-	int eos_rsp;
-	int eos_flag;
-	int opened;
-	int enabled;
-	int stopped;
-	int feedback;
-	int rflush;             /* Read  flush */
-	int wflush;             /* Write flush */
-	bool reset_event;
-	long (*codec_ioctl)(struct file *, unsigned int, unsigned long);
-	long (*codec_compat_ioctl)(struct file *, unsigned int, unsigned long);
-};
-
-void audio_aio_async_write_ack(struct q6audio_aio *audio, uint32_t token,
-				uint32_t *payload);
-
-void audio_aio_async_read_ack(struct q6audio_aio *audio, uint32_t token,
-			uint32_t *payload);
-
-int insert_eos_buf(struct q6audio_aio *audio,
-		struct audio_aio_buffer_node *buf_node);
-
-void extract_meta_out_info(struct q6audio_aio *audio,
-		struct audio_aio_buffer_node *buf_node, int dir);
-
-int audio_aio_open(struct q6audio_aio *audio, struct file *file);
-int audio_aio_enable(struct q6audio_aio  *audio);
-void audio_aio_post_event(struct q6audio_aio *audio, int type,
-		union msm_audio_event_payload payload);
-int audio_aio_release(struct inode *inode, struct file *file);
-int audio_aio_fsync(struct file *file, loff_t start, loff_t end, int datasync);
-void audio_aio_async_out_flush(struct q6audio_aio *audio);
-void audio_aio_async_in_flush(struct q6audio_aio *audio);
-void audio_aio_ioport_reset(struct q6audio_aio *audio);
-int enable_volume_ramp(struct q6audio_aio *audio);
-#ifdef CONFIG_DEBUG_FS
-int audio_aio_debug_open(struct inode *inode, struct file *file);
-ssize_t audio_aio_debug_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos);
-#endif
diff --git a/drivers/misc/qcom/qdsp6v2/audio_wma.c b/drivers/misc/qcom/qdsp6v2/audio_wma.c
deleted file mode 100644
index e35334a..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_wma.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/* wma audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/types.h>
-#include <linux/msm_audio_wma.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_wma_misc;
-static struct ws_mgr audio_wma_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_wma_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_wma_cfg wma_cfg;
-		struct msm_audio_wma_config_v2 *wma_config;
-
-		pr_debug("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
-						audio, audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		wma_config = (struct msm_audio_wma_config_v2 *)audio->codec_cfg;
-		wma_cfg.format_tag = wma_config->format_tag;
-		wma_cfg.ch_cfg = wma_config->numchannels;
-		wma_cfg.sample_rate =  wma_config->samplingrate;
-		wma_cfg.avg_bytes_per_sec = wma_config->avgbytespersecond;
-		wma_cfg.block_align = wma_config->block_align;
-		wma_cfg.valid_bits_per_sample =
-				wma_config->validbitspersample;
-		wma_cfg.ch_mask =  wma_config->channelmask;
-		wma_cfg.encode_opt = wma_config->encodeopt;
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_wma(audio->ac, &wma_cfg,
-				audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_WMA_CONFIG_V2: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			sizeof(struct msm_audio_wma_config_v2))) {
-			pr_err("%s:copy_to_user for AUDIO_SET_WMA_CONFIG_V2 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_WMA_CONFIG_V2: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_wma_config_v2))) {
-			pr_err("%s:copy_from_user for AUDIO_SET_WMA_CONFIG_V2 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_wma_config_v2_32 {
-	u16 format_tag;
-	u16 numchannels;
-	u32 samplingrate;
-	u32 avgbytespersecond;
-	u16 block_align;
-	u16 validbitspersample;
-	u32 channelmask;
-	u16 encodeopt;
-};
-
-enum {
-	AUDIO_GET_WMA_CONFIG_V2_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+2), struct msm_audio_wma_config_v2_32),
-	AUDIO_SET_WMA_CONFIG_V2_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-	(AUDIO_MAX_COMMON_IOCTL_NUM+3), struct msm_audio_wma_config_v2_32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-						unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	case AUDIO_GET_WMA_CONFIG_V2_32: {
-		struct msm_audio_wma_config_v2 *wma_config;
-		struct msm_audio_wma_config_v2_32 wma_config_32;
-
-		memset(&wma_config_32, 0, sizeof(wma_config_32));
-
-		wma_config = (struct msm_audio_wma_config_v2 *)audio->codec_cfg;
-		wma_config_32.format_tag = wma_config->format_tag;
-		wma_config_32.numchannels = wma_config->numchannels;
-		wma_config_32.samplingrate = wma_config->samplingrate;
-		wma_config_32.avgbytespersecond = wma_config->avgbytespersecond;
-		wma_config_32.block_align = wma_config->block_align;
-		wma_config_32.validbitspersample =
-					wma_config->validbitspersample;
-		wma_config_32.channelmask = wma_config->channelmask;
-		wma_config_32.encodeopt = wma_config->encodeopt;
-		if (copy_to_user((void *)arg, &wma_config_32,
-			sizeof(wma_config_32))) {
-			pr_err("%s: copy_to_user for GET_WMA_CONFIG_V2_32 failed\n",
-				 __func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_WMA_CONFIG_V2_32: {
-		struct msm_audio_wma_config_v2 *wma_config;
-		struct msm_audio_wma_config_v2_32 wma_config_32;
-
-		if (copy_from_user(&wma_config_32, (void *)arg,
-			sizeof(wma_config_32))) {
-			pr_err("%s: copy_from_user for SET_WMA_CONFIG_V2_32 failed\n"
-				, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		wma_config = (struct msm_audio_wma_config_v2 *)audio->codec_cfg;
-		wma_config->format_tag = wma_config_32.format_tag;
-		wma_config->numchannels = wma_config_32.numchannels;
-		wma_config->samplingrate = wma_config_32.samplingrate;
-		wma_config->avgbytespersecond = wma_config_32.avgbytespersecond;
-		wma_config->block_align = wma_config_32.block_align;
-		wma_config->validbitspersample =
-				wma_config_32.validbitspersample;
-		wma_config->channelmask = wma_config_32.channelmask;
-		wma_config->encodeopt = wma_config_32.encodeopt;
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wma_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_wma_config_v2),
-					GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_wma_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_wma_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_WMA_V9);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open WMA decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_WMA_V9);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_wma_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_wma_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:wmadec success mode[%d]session[%d]\n", __func__,
-						audio->feedback,
-						audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wma_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_wma_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_wma",
-	.fops = &audio_wma_fops,
-};
-
-static int __init audio_wma_init(void)
-{
-	int ret = misc_register(&audio_wma_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_wma_misc.this_device, true);
-	audio_wma_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_wma_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_wma_init);
diff --git a/drivers/misc/qcom/qdsp6v2/audio_wmapro.c b/drivers/misc/qcom/qdsp6v2/audio_wmapro.c
deleted file mode 100644
index 3cb9db1..0000000
--- a/drivers/misc/qcom/qdsp6v2/audio_wmapro.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* wmapro audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/types.h>
-#include <linux/msm_audio_wmapro.h>
-#include <linux/compat.h>
-#include "audio_utils_aio.h"
-
-static struct miscdevice audio_wmapro_misc;
-static struct ws_mgr audio_wmapro_ws_mgr;
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations audio_wmapro_debug_fops = {
-	.read = audio_aio_debug_read,
-	.open = audio_aio_debug_open,
-};
-#endif
-
-static long audio_ioctl_shared(struct file *file, unsigned int cmd,
-						void *arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct asm_wmapro_cfg wmapro_cfg;
-		struct msm_audio_wmapro_config *wmapro_config;
-
-		pr_debug("%s: AUDIO_START session_id[%d]\n", __func__,
-						audio->ac->session);
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			/* Configure PCM output block */
-			rc = q6asm_enc_cfg_blk_pcm_v2(audio->ac,
-					audio->pcm_cfg.sample_rate,
-					audio->pcm_cfg.channel_count,
-					16, /* bits per sample */
-					true, /* use default channel map */
-					true, /* use back channel map flavor */
-					NULL);
-			if (rc < 0) {
-				pr_err("pcm output block config failed\n");
-				break;
-			}
-		}
-		wmapro_config = (struct msm_audio_wmapro_config *)
-				audio->codec_cfg;
-		if ((wmapro_config->formattag == 0x162) ||
-		(wmapro_config->formattag == 0x163) ||
-		(wmapro_config->formattag == 0x166) ||
-		(wmapro_config->formattag == 0x167)) {
-			wmapro_cfg.format_tag = wmapro_config->formattag;
-		} else {
-			pr_err("%s:AUDIO_START failed: formattag = %d\n",
-				__func__, wmapro_config->formattag);
-			rc = -EINVAL;
-			break;
-		}
-		if (wmapro_config->numchannels > 0) {
-			wmapro_cfg.ch_cfg = wmapro_config->numchannels;
-		} else {
-			pr_err("%s:AUDIO_START failed: channels = %d\n",
-				__func__, wmapro_config->numchannels);
-			rc = -EINVAL;
-			break;
-		}
-		if (wmapro_config->samplingrate > 0) {
-			wmapro_cfg.sample_rate = wmapro_config->samplingrate;
-		} else {
-			pr_err("%s:AUDIO_START failed: sample_rate = %d\n",
-				__func__, wmapro_config->samplingrate);
-			rc = -EINVAL;
-			break;
-		}
-		wmapro_cfg.avg_bytes_per_sec =
-				wmapro_config->avgbytespersecond;
-		if ((wmapro_config->asfpacketlength <= 13376) ||
-		(wmapro_config->asfpacketlength > 0)) {
-			wmapro_cfg.block_align =
-				wmapro_config->asfpacketlength;
-		} else {
-			pr_err("%s:AUDIO_START failed: block_align = %d\n",
-				__func__, wmapro_config->asfpacketlength);
-			rc = -EINVAL;
-			break;
-		}
-		if ((wmapro_config->validbitspersample == 16) ||
-			(wmapro_config->validbitspersample == 24)) {
-			wmapro_cfg.valid_bits_per_sample =
-				wmapro_config->validbitspersample;
-		} else {
-			pr_err("%s:AUDIO_START failed: bitspersample = %d\n",
-				__func__, wmapro_config->validbitspersample);
-			rc = -EINVAL;
-			break;
-		}
-		wmapro_cfg.ch_mask = wmapro_config->channelmask;
-		wmapro_cfg.encode_opt = wmapro_config->encodeopt;
-		wmapro_cfg.adv_encode_opt =
-				wmapro_config->advancedencodeopt;
-		wmapro_cfg.adv_encode_opt2 =
-				wmapro_config->advancedencodeopt2;
-		/* Configure Media format block */
-		rc = q6asm_media_format_block_wmapro(audio->ac, &wmapro_cfg,
-				audio->ac->stream_id);
-		if (rc < 0) {
-			pr_err("cmd media format block failed\n");
-			break;
-		}
-		rc = audio_aio_enable(audio);
-		audio->eos_rsp = 0;
-		audio->eos_flag = 0;
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("Audio Start procedure failed rc=%d\n", rc);
-			break;
-		}
-		pr_debug("AUDIO_START success enable[%d]\n", audio->enabled);
-		if (audio->stopped == 1)
-			audio->stopped = 0;
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd %d\n", __func__, cmd);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_GET_WMAPRO_CONFIG: {
-		if (copy_to_user((void *)arg, audio->codec_cfg,
-			 sizeof(struct msm_audio_wmapro_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_WMAPRO_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_WMAPRO_CONFIG: {
-		if (copy_from_user(audio->codec_cfg, (void *)arg,
-			sizeof(struct msm_audio_wmapro_config))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_WMAPRO_CONFIG_V2 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	}
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-
-struct msm_audio_wmapro_config32 {
-	u16 armdatareqthr;
-	u8  validbitspersample;
-	u8  numchannels;
-	u16 formattag;
-	u32 samplingrate;
-	u32 avgbytespersecond;
-	u16 asfpacketlength;
-	u32 channelmask;
-	u16 encodeopt;
-	u16 advancedencodeopt;
-	u32 advancedencodeopt2;
-};
-
-enum {
-	AUDIO_GET_WMAPRO_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_wmapro_config32),
-	AUDIO_SET_WMAPRO_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_wmapro_config32)
-};
-
-static long audio_compat_ioctl(struct file *file, unsigned int cmd,
-					unsigned long arg)
-{
-	struct q6audio_aio *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_GET_WMAPRO_CONFIG_32: {
-		struct msm_audio_wmapro_config *wmapro_config;
-		struct msm_audio_wmapro_config32 wmapro_config_32;
-
-		memset(&wmapro_config_32, 0, sizeof(wmapro_config_32));
-
-		wmapro_config =
-			(struct msm_audio_wmapro_config *)audio->codec_cfg;
-		wmapro_config_32.armdatareqthr = wmapro_config->armdatareqthr;
-		wmapro_config_32.validbitspersample =
-					wmapro_config->validbitspersample;
-		wmapro_config_32.numchannels = wmapro_config->numchannels;
-		wmapro_config_32.formattag = wmapro_config->formattag;
-		wmapro_config_32.samplingrate = wmapro_config->samplingrate;
-		wmapro_config_32.avgbytespersecond =
-					wmapro_config->avgbytespersecond;
-		wmapro_config_32.asfpacketlength =
-					wmapro_config->asfpacketlength;
-		wmapro_config_32.channelmask = wmapro_config->channelmask;
-		wmapro_config_32.encodeopt = wmapro_config->encodeopt;
-		wmapro_config_32.advancedencodeopt =
-					wmapro_config->advancedencodeopt;
-		wmapro_config_32.advancedencodeopt2 =
-					wmapro_config->advancedencodeopt2;
-
-		if (copy_to_user((void *)arg, &wmapro_config_32,
-			 sizeof(struct msm_audio_wmapro_config32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_WMAPRO_CONFIG_V2_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_WMAPRO_CONFIG_32: {
-		struct msm_audio_wmapro_config *wmapro_config;
-		struct msm_audio_wmapro_config32 wmapro_config_32;
-
-		if (copy_from_user(&wmapro_config_32, (void *)arg,
-			sizeof(struct msm_audio_wmapro_config32))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_SET_WMAPRO_CONFG_V2_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		wmapro_config =
-			(struct msm_audio_wmapro_config *)audio->codec_cfg;
-		wmapro_config->armdatareqthr = wmapro_config_32.armdatareqthr;
-		wmapro_config->validbitspersample =
-					wmapro_config_32.validbitspersample;
-		wmapro_config->numchannels = wmapro_config_32.numchannels;
-		wmapro_config->formattag = wmapro_config_32.formattag;
-		wmapro_config->samplingrate = wmapro_config_32.samplingrate;
-		wmapro_config->avgbytespersecond =
-					wmapro_config_32.avgbytespersecond;
-		wmapro_config->asfpacketlength =
-					wmapro_config_32.asfpacketlength;
-		wmapro_config->channelmask = wmapro_config_32.channelmask;
-		wmapro_config->encodeopt = wmapro_config_32.encodeopt;
-		wmapro_config->advancedencodeopt =
-					wmapro_config_32.advancedencodeopt;
-		wmapro_config->advancedencodeopt2 =
-					wmapro_config_32.advancedencodeopt2;
-		break;
-	}
-	case AUDIO_START: {
-		rc = audio_ioctl_shared(file, cmd, (void *)arg);
-		break;
-	}
-	default: {
-		pr_debug("%s[%pK]: Calling utils ioctl\n", __func__, audio);
-		rc = audio->codec_compat_ioctl(file, cmd, arg);
-		if (rc)
-			pr_err("Failed in utils_ioctl: %d\n", rc);
-		break;
-	}
-	}
-	return rc;
-}
-#else
-#define audio_compat_ioctl NULL
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_aio *audio = NULL;
-	int rc = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wmapro_" + 5];
-#endif
-	audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	audio->codec_cfg = kzalloc(sizeof(struct msm_audio_wmapro_config),
-					GFP_KERNEL);
-	if (audio->codec_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-
-	audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN;
-	audio->miscdevice = &audio_wmapro_misc;
-	audio->wakelock_voted = false;
-	audio->audio_ws_mgr = &audio_wmapro_ws_mgr;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb) q6_audio_cb,
-					     (void *)audio);
-
-	if (!audio->ac) {
-		pr_err("Could not allocate memory for audio client\n");
-		kfree(audio->codec_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	rc = audio_aio_open(audio, file);
-	if (rc < 0) {
-		pr_err("%s: audio_aio_open rc=%d\n",
-			__func__, rc);
-		goto fail;
-	}
-	/* open in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,
-					   FORMAT_WMA_V10PRO);
-		if (rc < 0) {
-			pr_err("NT mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = NON_TUNNEL_MODE;
-		/* open WMA decoder, expected frames is always 1*/
-		audio->buf_cfg.frames_per_buf = 0x01;
-		audio->buf_cfg.meta_info_enable = 0x01;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		rc = q6asm_open_write(audio->ac, FORMAT_WMA_V10PRO);
-		if (rc < 0) {
-			pr_err("T mode Open failed rc=%d\n", rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		audio->feedback = TUNNEL_MODE;
-		audio->buf_cfg.meta_info_enable = 0x00;
-	} else {
-		pr_err("Not supported mode\n");
-		rc = -EACCES;
-		goto fail;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof(name), "msm_wmapro_%04x", audio->ac->session);
-	audio->dentry = debugfs_create_file(name, S_IFREG | 0444,
-					    NULL, (void *)audio,
-					    &audio_wmapro_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		pr_debug("debugfs_create_file failed\n");
-#endif
-	pr_info("%s:wmapro decoder open success, session_id = %d\n", __func__,
-				audio->ac->session);
-	return rc;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->codec_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wmapro_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_aio_release,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audio_aio_fsync,
-	.compat_ioctl = audio_compat_ioctl
-};
-
-static struct miscdevice audio_wmapro_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_wmapro",
-	.fops = &audio_wmapro_fops,
-};
-
-static int __init audio_wmapro_init(void)
-{
-	int ret = misc_register(&audio_wmapro_misc);
-
-	if (ret == 0)
-		device_init_wakeup(audio_wmapro_misc.this_device, true);
-	audio_wmapro_ws_mgr.ref_cnt = 0;
-	mutex_init(&audio_wmapro_ws_mgr.ws_lock);
-
-	return ret;
-}
-
-device_initcall(audio_wmapro_init);
diff --git a/drivers/misc/qcom/qdsp6v2/evrc_in.c b/drivers/misc/qcom/qdsp6v2/evrc_in.c
deleted file mode 100644
index e30271d..0000000
--- a/drivers/misc/qcom/qdsp6v2/evrc_in.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_qcp.h>
-#include <linux/atomic.h>
-#include <linux/compat.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((23+sizeof(struct meta_out_dsp)) * 10))
-
-static long evrc_in_ioctl_shared(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_evrc_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			pr_info("%s:AUDIO_START already over\n", __func__);
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-
-		/* rate_modulation_cmd set to zero
-		 * currently not configurable from user space
-		 */
-		rc = q6asm_enc_cfg_blk_evrc(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->min_bit_rate,
-			enc_cfg->max_bit_rate, 0);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd evrc media format block failed\n",
-					__func__, audio->ac->session);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed\n",
-					__func__, audio->ac->session);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:session id %d: AUDIO_STOP\n", __func__,
-				audio->ac->session);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_EVRC_ENC_CONFIG: {
-		struct msm_audio_evrc_enc_config *cfg;
-		struct msm_audio_evrc_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		cfg = (struct msm_audio_evrc_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer for %s\n",
-					__func__, "AUDIO_SET_EVRC_ENC_CONFIG");
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->min_bit_rate > 4 ||
-			 cfg->min_bit_rate < 1 ||
-			 (cfg->min_bit_rate == 2)) {
-			pr_err("%s:session id %d: invalid min bitrate\n",
-					__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->max_bit_rate > 4 ||
-			 cfg->max_bit_rate < 1 ||
-			 (cfg->max_bit_rate == 2)) {
-			pr_err("%s:session id %d: invalid max bitrate\n",
-				__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg->min_bit_rate = cfg->min_bit_rate;
-		enc_cfg->max_bit_rate = cfg->max_bit_rate;
-		pr_debug("%s:session id %d: min_bit_rate= 0x%x max_bit_rate=0x%x\n",
-			__func__,
-			audio->ac->session, enc_cfg->min_bit_rate,
-			enc_cfg->max_bit_rate);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long evrc_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = evrc_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_EVRC_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-			sizeof(struct msm_audio_evrc_enc_config))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_EVRC_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_EVRC_ENC_CONFIG: {
-		struct msm_audio_evrc_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(struct msm_audio_evrc_enc_config))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_EVRC_ENC_CONFIG failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = evrc_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_EVRC_ENC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_evrc_enc_config32 {
-	u32 cdma_rate;
-	u32 min_bit_rate;
-	u32 max_bit_rate;
-};
-
-enum {
-	AUDIO_SET_EVRC_ENC_CONFIG_32 =  _IOW(AUDIO_IOCTL_MAGIC,
-		2, struct msm_audio_evrc_enc_config32),
-	AUDIO_GET_EVRC_ENC_CONFIG_32 =  _IOR(AUDIO_IOCTL_MAGIC,
-		3, struct msm_audio_evrc_enc_config32)
-};
-
-static long evrc_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = evrc_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_EVRC_ENC_CONFIG_32: {
-		struct msm_audio_evrc_enc_config32 cfg_32;
-		struct msm_audio_evrc_enc_config *enc_cfg;
-
-		memset(&cfg_32, 0, sizeof(cfg_32));
-
-		enc_cfg = audio->enc_cfg;
-		cfg_32.cdma_rate = enc_cfg->cdma_rate;
-		cfg_32.min_bit_rate = enc_cfg->min_bit_rate;
-		cfg_32.max_bit_rate = enc_cfg->max_bit_rate;
-
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_EVRC_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_EVRC_ENC_CONFIG_32: {
-		struct msm_audio_evrc_enc_config cfg;
-		struct msm_audio_evrc_enc_config32 cfg_32;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_EVRC_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.cdma_rate = cfg_32.cdma_rate;
-		cfg.min_bit_rate = cfg_32.min_bit_rate;
-		cfg.max_bit_rate = cfg_32.max_bit_rate;
-		cmd = AUDIO_SET_EVRC_ENC_CONFIG;
-		rc = evrc_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_EVRC_ENC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-#else
-#define evrc_in_compat_ioctl NULL
-#endif
-
-static int evrc_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_evrc_enc_config *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_evrc_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 23;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->min_bit_rate = 4;
-	enc_cfg->max_bit_rate = 4;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-	audio->event_abort = 0;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-				__func__);
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open evrc encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_EVRC,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: NT mode encoder success\n",
-				__func__, audio->ac->session);
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_EVRC);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__,
-				audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: T mode encoder success\n", __func__,
-				audio->ac->session);
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	audio->reset_event = false;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = evrc_in_compat_ioctl;
-	audio->enc_ioctl = evrc_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= evrc_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-	.compat_ioctl   = audio_in_compat_ioctl
-};
-
-struct miscdevice audio_evrc_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_evrc_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init evrc_in_init(void)
-{
-	return misc_register(&audio_evrc_in_misc);
-}
-
-device_initcall(evrc_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/g711alaw_in.c b/drivers/misc/qcom/qdsp6v2/g711alaw_in.c
deleted file mode 100644
index bc8c0a3..0000000
--- a/drivers/misc/qcom/qdsp6v2/g711alaw_in.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_g711.h>
-#include <linux/atomic.h>
-#include <linux/compat.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((320+sizeof(struct meta_out_dsp)) * 10))
-static long g711_in_ioctl_shared(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_g711_enc_config *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config *)audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		pr_debug("%s: sample rate %d", __func__, enc_cfg->sample_rate);
-		rc = q6asm_enc_cfg_blk_g711(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->sample_rate);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd g711 media format block failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n", __func__,
-				audio->ac->session, audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:session id %d: AUDIO_STOP\n", __func__,
-				audio->ac->session);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session,
-					rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG: {
-		struct msm_audio_g711_enc_config *cfg;
-		struct msm_audio_g711_enc_config *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config *)audio->enc_cfg;
-
-		cfg = (struct msm_audio_g711_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->sample_rate != 8000 &&
-			 cfg->sample_rate != 16000) {
-			pr_err("%s:session id %d: invalid sample rate\n",
-					__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg->sample_rate = cfg->sample_rate;
-		pr_debug("%s:session id %d: sample_rate= 0x%x",
-			__func__,
-			audio->ac->session, enc_cfg->sample_rate);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-
-static long g711_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = g711_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_G711_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-			sizeof(struct msm_audio_g711_enc_config))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_g711_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG: {
-		struct msm_audio_g711_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(cfg))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_GET_G711_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = g711_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_GET_G711_ENC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_g711_enc_config32 {
-	uint32_t sample_rate;
-};
-
-enum {
-	AUDIO_SET_G711_ENC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_enc_config32),
-	AUDIO_GET_G711_ENC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_enc_config32)
-};
-
-static long g711_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = g711_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_G711_ENC_CONFIG_32: {
-		struct msm_audio_g711_enc_config32 cfg_32;
-		struct msm_audio_g711_enc_config32 *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config32 *)audio->enc_cfg;
-		cfg_32.sample_rate = enc_cfg->sample_rate;
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_G711_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG_32: {
-		struct msm_audio_g711_enc_config32 cfg_32;
-		struct msm_audio_g711_enc_config32 cfg;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_G711_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.sample_rate = cfg_32.sample_rate;
-		cmd = AUDIO_SET_G711_ENC_CONFIG;
-		rc = g711_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_G711_ENC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-#else
-#define g711_in_compat_ioctl NULL
-#endif
-
-static int g711_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_g711_enc_config *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_g711_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/*
-	 * Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 320;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->sample_rate = 8000;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-	audio->event_abort = 0;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open g711 encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_G711_ALAW_FS,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_G711_ALAW_FS);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	audio->reset_event = false;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = g711_in_compat_ioctl;
-	audio->enc_ioctl = g711_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= g711_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl   = audio_in_compat_ioctl,
-#endif
-};
-
-struct miscdevice audio_g711alaw_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_g711alaw_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init g711alaw_in_init(void)
-{
-	return misc_register(&audio_g711alaw_in_misc);
-}
-
-device_initcall(g711alaw_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/g711mlaw_in.c b/drivers/misc/qcom/qdsp6v2/g711mlaw_in.c
deleted file mode 100644
index b92c449..0000000
--- a/drivers/misc/qcom/qdsp6v2/g711mlaw_in.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_g711.h>
-#include <linux/atomic.h>
-#include <linux/compat.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-#ifdef CONFIG_COMPAT
-#undef PROC_ADD
-#endif
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((320+sizeof(struct meta_out_dsp)) * 10))
-static long g711_in_ioctl_shared(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_g711_enc_config *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config *)audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			break;
-		}
-		pr_debug("%s: sample rate %d", __func__, enc_cfg->sample_rate);
-		rc = q6asm_enc_cfg_blk_g711(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->sample_rate);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd g711 media format block failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n", __func__,
-				audio->ac->session, audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:session id %d: AUDIO_STOP\n", __func__,
-				audio->ac->session);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session,
-					rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG: {
-		struct msm_audio_g711_enc_config *cfg;
-		struct msm_audio_g711_enc_config *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config *)audio->enc_cfg;
-
-		cfg = (struct msm_audio_g711_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->sample_rate != 8000 &&
-			 cfg->sample_rate != 16000) {
-			pr_err("%s:session id %d: invalid sample rate\n",
-					__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg->sample_rate = cfg->sample_rate;
-		pr_debug("%s:session id %d: sample_rate= 0x%x",
-			__func__,
-			audio->ac->session, enc_cfg->sample_rate);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-
-static long g711_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = g711_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_G711_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-			sizeof(struct msm_audio_g711_enc_config))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_g711_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG: {
-		struct msm_audio_g711_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(cfg))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_GET_G711_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = g711_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_GET_G711_ENC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_g711_enc_config32 {
-	uint32_t sample_rate;
-};
-
-enum {
-	AUDIO_SET_G711_ENC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_enc_config32),
-	AUDIO_GET_G711_ENC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_enc_config32)
-};
-
-static long g711_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = g711_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_G711_ENC_CONFIG_32: {
-		struct msm_audio_g711_enc_config32 cfg_32;
-		struct msm_audio_g711_enc_config32 *enc_cfg;
-
-		enc_cfg = (struct msm_audio_g711_enc_config32 *)audio->enc_cfg;
-		cfg_32.sample_rate = enc_cfg->sample_rate;
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_G711_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_G711_ENC_CONFIG_32: {
-		struct msm_audio_g711_enc_config32 cfg_32;
-		struct msm_audio_g711_enc_config32 cfg;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_G711_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.sample_rate = cfg_32.sample_rate;
-		cmd = AUDIO_SET_G711_ENC_CONFIG;
-		rc = g711_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_G711_ENC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -ENOIOCTLCMD;
-	}
-	return rc;
-}
-#else
-#define g711_in_compat_ioctl NULL
-#endif
-
-static int g711_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_g711_enc_config *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_g711_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/*
-	 * Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 320;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->sample_rate = 8000;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-	audio->event_abort = 0;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open g711 encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_G711_MLAW_FS,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_G711_MLAW_FS);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	audio->reset_event = false;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = g711_in_compat_ioctl;
-	audio->enc_ioctl = g711_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= g711_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl = audio_in_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl   = audio_in_compat_ioctl,
-#endif
-};
-
-struct miscdevice audio_g711mlaw_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_g711mlaw_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init g711mlaw_in_init(void)
-{
-	return misc_register(&audio_g711mlaw_in_misc);
-}
-
-device_initcall(g711mlaw_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/q6audio_common.h b/drivers/misc/qcom/qdsp6v2/q6audio_common.h
deleted file mode 100644
index 49b88b7..0000000
--- a/drivers/misc/qcom/qdsp6v2/q6audio_common.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (c) 2012-2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-
-/* For Decoders */
-#ifndef __Q6_AUDIO_COMMON_H__
-#define __Q6_AUDIO_COMMON_H__
-
-#include <sound/apr_audio-v2.h>
-#include <sound/q6asm-v2.h>
-
-
-void q6_audio_cb(uint32_t opcode, uint32_t token,
-		uint32_t *payload, void *priv);
-
-void audio_aio_cb(uint32_t opcode, uint32_t token,
-			uint32_t *payload,  void *audio);
-
-
-/* For Encoders */
-void q6asm_in_cb(uint32_t opcode, uint32_t token,
-		uint32_t *payload, void *priv);
-
-void  audio_in_get_dsp_frames(void *audio,
-		uint32_t token,	uint32_t *payload);
-
-#endif /*__Q6_AUDIO_COMMON_H__*/
diff --git a/drivers/misc/qcom/qdsp6v2/q6audio_v2.c b/drivers/misc/qcom/qdsp6v2/q6audio_v2.c
deleted file mode 100644
index 6c05165..0000000
--- a/drivers/misc/qcom/qdsp6v2/q6audio_v2.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright (c) 2012-2013, 2015-2017, The Linux Foundation. All rights
- * reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-void q6asm_in_cb(uint32_t opcode, uint32_t token,
-		uint32_t *payload, void *priv)
-{
-	struct q6audio_in *audio = (struct q6audio_in *)priv;
-	unsigned long flags;
-
-	pr_debug("%s:session id %d: opcode[0x%x]\n", __func__,
-			audio->ac->session, opcode);
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	switch (opcode) {
-	case ASM_DATA_EVENT_READ_DONE_V2:
-		audio_in_get_dsp_frames(audio, token, payload);
-		break;
-	case ASM_DATA_EVENT_WRITE_DONE_V2:
-		atomic_inc(&audio->in_count);
-		wake_up(&audio->write_wait);
-		break;
-	case ASM_DATA_EVENT_RENDERED_EOS:
-		audio->eos_rsp = 1;
-		wake_up(&audio->read_wait);
-		break;
-	case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2:
-		break;
-	case ASM_SESSION_EVENTX_OVERFLOW:
-		pr_err("%s:session id %d: ASM_SESSION_EVENT_TX_OVERFLOW\n",
-			__func__, audio->ac->session);
-		break;
-	case RESET_EVENTS:
-		pr_debug("%s:received RESET EVENTS\n", __func__);
-		audio->enabled = 0;
-		audio->stopped = 1;
-		audio->event_abort = 1;
-		audio->reset_event = true;
-		wake_up(&audio->read_wait);
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		pr_debug("%s:session id %d: Ignore opcode[0x%x]\n", __func__,
-			audio->ac->session, opcode);
-		break;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-void  audio_in_get_dsp_frames(void *priv,
-	uint32_t token,	uint32_t *payload)
-{
-	struct q6audio_in *audio = (struct q6audio_in *)priv;
-	uint32_t index;
-
-	index = q6asm_get_buf_index_from_token(token);
-	pr_debug("%s:session id %d: index=%d nr frames=%d offset[%d]\n",
-			__func__, audio->ac->session, token, payload[9],
-			payload[5]);
-	pr_debug("%s:session id %d: timemsw=%d lsw=%d\n", __func__,
-			audio->ac->session, payload[7], payload[6]);
-	pr_debug("%s:session id %d: uflags=0x%8x uid=0x%8x\n", __func__,
-			audio->ac->session, payload[8], payload[10]);
-	pr_debug("%s:session id %d: enc_framesotal_size=0x%8x\n", __func__,
-			audio->ac->session, payload[4]);
-
-	/* Ensure the index is within max array size: FRAME_NUM */
-	if (index >= FRAME_NUM) {
-		pr_err("%s: Invalid index %d\n",
-			__func__, index);
-		return;
-	}
-
-	audio->out_frame_info[index][0] = payload[9];
-	audio->out_frame_info[index][1] = payload[5];
-
-	/* statistics of read */
-	atomic_add(payload[4], &audio->in_bytes);
-	atomic_add(payload[9], &audio->in_samples);
-
-	if (atomic_read(&audio->out_count) <= audio->str_cfg.buffer_count) {
-		atomic_inc(&audio->out_count);
-		wake_up(&audio->read_wait);
-	}
-}
diff --git a/drivers/misc/qcom/qdsp6v2/q6audio_v2_aio.c b/drivers/misc/qcom/qdsp6v2/q6audio_v2_aio.c
deleted file mode 100644
index 9f76458..0000000
--- a/drivers/misc/qcom/qdsp6v2/q6audio_v2_aio.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/atomic.h>
-#include <asm/ioctls.h>
-#include "audio_utils_aio.h"
-
-void q6_audio_cb(uint32_t opcode, uint32_t token,
-		uint32_t *payload, void *priv)
-{
-	struct q6audio_aio *audio = (struct q6audio_aio *)priv;
-
-	pr_debug("%s:opcode = %x token = 0x%x\n", __func__, opcode, token);
-	switch (opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2:
-	case ASM_DATA_EVENT_READ_DONE_V2:
-	case ASM_DATA_EVENT_RENDERED_EOS:
-	case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
-	case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
-	case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
-	case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY:
-	case RESET_EVENTS:
-		audio_aio_cb(opcode, token, payload, audio);
-		break;
-	default:
-		pr_debug("%s:Unhandled event = 0x%8x\n", __func__, opcode);
-		break;
-	}
-}
-
-void audio_aio_cb(uint32_t opcode, uint32_t token,
-		uint32_t *payload,  void *priv/*struct q6audio_aio *audio*/)
-{
-	struct q6audio_aio *audio = (struct q6audio_aio *)priv;
-	union msm_audio_event_payload e_payload;
-
-	switch (opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2:
-		pr_debug("%s[%pK]:ASM_DATA_EVENT_WRITE_DONE token = 0x%x\n",
-			__func__, audio, token);
-		audio_aio_async_write_ack(audio, token, payload);
-		break;
-	case ASM_DATA_EVENT_READ_DONE_V2:
-		pr_debug("%s[%pK]:ASM_DATA_EVENT_READ_DONE token = 0x%x\n",
-			__func__, audio, token);
-		audio_aio_async_read_ack(audio, token, payload);
-		break;
-	case ASM_DATA_EVENT_RENDERED_EOS:
-		/* EOS Handle */
-		pr_debug("%s[%pK]:ASM_DATA_CMDRSP_EOS\n", __func__, audio);
-		if (audio->feedback) { /* Non-Tunnel mode */
-			audio->eos_rsp = 1;
-			/* propagate input EOS i/p buffer,
-			 * after receiving DSP acknowledgment
-			 */
-			if (audio->eos_flag &&
-				(audio->eos_write_payload.aio_buf.buf_addr)) {
-				audio_aio_post_event(audio,
-						AUDIO_EVENT_WRITE_DONE,
-						audio->eos_write_payload);
-				memset(&audio->eos_write_payload, 0,
-					sizeof(union msm_audio_event_payload));
-				audio->eos_flag = 0;
-			}
-		} else { /* Tunnel mode */
-			audio->eos_rsp = 1;
-			wake_up(&audio->write_wait);
-			wake_up(&audio->cmd_wait);
-		}
-		break;
-	case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
-	case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
-		pr_debug("%s[%pK]:payload0[%x] payloa1d[%x]opcode= 0x%x\n",
-			__func__, audio, payload[0], payload[1], opcode);
-		break;
-	case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
-	case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY:
-		pr_debug("%s[%pK]: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, payload[0]-sr = %d, payload[1]-chl = %d, payload[2] = %d, payload[3] = %d\n",
-					 __func__, audio, payload[0],
-					 payload[1], payload[2], payload[3]);
-
-		pr_debug("%s[%pK]: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, sr(prev) = %d, chl(prev) = %d,",
-		__func__, audio, audio->pcm_cfg.sample_rate,
-		audio->pcm_cfg.channel_count);
-
-		audio->pcm_cfg.sample_rate = payload[0];
-		audio->pcm_cfg.channel_count = payload[1] & 0xFFFF;
-		e_payload.stream_info.chan_info = audio->pcm_cfg.channel_count;
-		e_payload.stream_info.sample_rate = audio->pcm_cfg.sample_rate;
-		audio_aio_post_event(audio, AUDIO_EVENT_STREAM_INFO, e_payload);
-		break;
-	case RESET_EVENTS:
-		pr_err("%s: Received opcode:0x%x\n", __func__, opcode);
-		audio->stopped = 1;
-		audio->reset_event = true;
-		wake_up(&audio->event_wait);
-		break;
-	default:
-		break;
-	}
-}
-
-void extract_meta_out_info(struct q6audio_aio *audio,
-		struct audio_aio_buffer_node *buf_node, int dir)
-{
-	struct dec_meta_out *meta_data = buf_node->kvaddr;
-	uint32_t temp;
-
-	if (dir) { /* input buffer - Write */
-		if (audio->buf_cfg.meta_info_enable)
-			memcpy(&buf_node->meta_info.meta_in,
-			(char *)buf_node->kvaddr, sizeof(struct dec_meta_in));
-		else
-			memset(&buf_node->meta_info.meta_in,
-			0, sizeof(struct dec_meta_in));
-		pr_debug("%s[%pK]:i/p: msw_ts %d lsw_ts %d nflags 0x%8x\n",
-			__func__, audio,
-			buf_node->meta_info.meta_in.ntimestamp.highpart,
-			buf_node->meta_info.meta_in.ntimestamp.lowpart,
-			buf_node->meta_info.meta_in.nflags);
-	} else { /* output buffer - Read */
-		memcpy((char *)buf_node->kvaddr,
-			&buf_node->meta_info.meta_out,
-			sizeof(struct dec_meta_out));
-		meta_data->meta_out_dsp[0].nflags = 0x00000000;
-		temp = meta_data->meta_out_dsp[0].msw_ts;
-		meta_data->meta_out_dsp[0].msw_ts =
-				meta_data->meta_out_dsp[0].lsw_ts;
-		meta_data->meta_out_dsp[0].lsw_ts = temp;
-
-		pr_debug("%s[%pK]:o/p: msw_ts %d lsw_ts %d nflags 0x%8x, num_frames = %d\n",
-		__func__, audio,
-		((struct dec_meta_out *)buf_node->kvaddr)->
-			meta_out_dsp[0].msw_ts,
-		((struct dec_meta_out *)buf_node->kvaddr)->
-			meta_out_dsp[0].lsw_ts,
-		((struct dec_meta_out *)buf_node->kvaddr)->
-			meta_out_dsp[0].nflags,
-		((struct dec_meta_out *)buf_node->kvaddr)->num_of_frames);
-	}
-}
-
-/* Read buffer from DSP / Handle Ack from DSP */
-void audio_aio_async_read_ack(struct q6audio_aio *audio, uint32_t token,
-			uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload event_payload;
-	struct audio_aio_buffer_node *filled_buf;
-
-	pr_debug("%s\n", __func__);
-
-	/* No active flush in progress */
-	if (audio->rflush)
-		return;
-
-	/* Statistics of read */
-	atomic_add(payload[4], &audio->in_bytes);
-	atomic_add(payload[9], &audio->in_samples);
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (list_empty(&audio->in_queue)) {
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		pr_warn("%s unexpected ack from dsp\n", __func__);
-		return;
-	}
-	filled_buf = list_first_entry(&audio->in_queue,
-					struct audio_aio_buffer_node, list);
-
-	pr_debug("%s token: 0x[%x], filled_buf->token: 0x[%x]",
-				 __func__, token, filled_buf->token);
-	if (token == (filled_buf->token)) {
-		list_del(&filled_buf->list);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		event_payload.aio_buf = filled_buf->buf;
-		/* Read done Buffer due to flush/normal condition
-		 * after EOS event, so append EOS buffer
-		 */
-		if (audio->eos_rsp == 0x1) {
-			event_payload.aio_buf.data_len =
-			insert_eos_buf(audio, filled_buf);
-			/* Reset flag back to indicate eos intimated */
-			audio->eos_rsp = 0;
-		} else {
-			filled_buf->meta_info.meta_out.num_of_frames
-							 = payload[9];
-			event_payload.aio_buf.data_len = payload[4]
-				 + payload[5] + sizeof(struct dec_meta_out);
-			pr_debug("%s[%pK]:nr of frames 0x%8x len=%d\n",
-				__func__, audio,
-				filled_buf->meta_info.meta_out.num_of_frames,
-				event_payload.aio_buf.data_len);
-			extract_meta_out_info(audio, filled_buf, 0);
-			audio->eos_rsp = 0;
-		}
-		pr_debug("%s, posting read done to the app here\n", __func__);
-		audio_aio_post_event(audio, AUDIO_EVENT_READ_DONE,
-					event_payload);
-		kfree(filled_buf);
-	} else {
-		pr_err("%s[%pK]:expected=%x ret=%x\n",
-			__func__, audio, filled_buf->token, token);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-}
diff --git a/drivers/misc/qcom/qdsp6v2/qcelp_in.c b/drivers/misc/qcom/qdsp6v2/qcelp_in.c
deleted file mode 100644
index da5520f..0000000
--- a/drivers/misc/qcom/qdsp6v2/qcelp_in.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_qcp.h>
-#include <linux/atomic.h>
-#include <linux/compat.h>
-#include <asm/ioctls.h>
-#include "audio_utils.h"
-
-/* Buffer with meta*/
-#define PCM_BUF_SIZE		(4096 + sizeof(struct meta_in))
-
-/* Maximum 10 frames in buffer with meta */
-#define FRAME_SIZE		(1 + ((35+sizeof(struct meta_out_dsp)) * 10))
-
-static long qcelp_in_ioctl_shared(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-	int cnt = 0;
-
-	switch (cmd) {
-	case AUDIO_START: {
-		struct msm_audio_qcelp_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		pr_debug("%s:session id %d: default buf alloc[%d]\n", __func__,
-				audio->ac->session, audio->buf_alloc);
-		if (audio->enabled == 1) {
-			pr_info("%s:AUDIO_START already over\n", __func__);
-			rc = 0;
-			break;
-		}
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed\n",
-				__func__, audio->ac->session);
-			break;
-		}
-
-		/* reduced_rate_level, rate_modulation_cmd set to zero
-		 * currently not configurable from user space
-		 */
-		rc = q6asm_enc_cfg_blk_qcelp(audio->ac,
-			audio->buf_cfg.frames_per_buf,
-			enc_cfg->min_bit_rate,
-			enc_cfg->max_bit_rate, 0, 0);
-
-		if (rc < 0) {
-			pr_err("%s:session id %d: cmd qcelp media format block failed\n",
-					__func__, audio->ac->session);
-			break;
-		}
-		if (audio->feedback == NON_TUNNEL_MODE) {
-			rc = q6asm_media_format_block_pcm(audio->ac,
-				audio->pcm_cfg.sample_rate,
-				audio->pcm_cfg.channel_count);
-
-			if (rc < 0) {
-				pr_err("%s:session id %d: media format block failed\n",
-					__func__, audio->ac->session);
-				break;
-			}
-		}
-		pr_debug("%s:session id %d: AUDIO_START enable[%d]\n", __func__,
-				audio->ac->session, audio->enabled);
-		rc = audio_in_enable(audio);
-		if (!rc) {
-			audio->enabled = 1;
-		} else {
-			audio->enabled = 0;
-			pr_err("%s:session id %d: Audio Start procedure failed rc=%d\n",
-					__func__, audio->ac->session, rc);
-			break;
-		}
-		while (cnt++ < audio->str_cfg.buffer_count)
-			q6asm_read(audio->ac); /* Push buffer to DSP */
-		rc = 0;
-		pr_debug("%s:session id %d: AUDIO_START success enable[%d]\n",
-				__func__, audio->ac->session, audio->enabled);
-		break;
-	}
-	case AUDIO_STOP: {
-		pr_debug("%s:session id %d: AUDIO_STOP\n", __func__,
-				audio->ac->session);
-		rc = audio_in_disable(audio);
-		if (rc  < 0) {
-			pr_err("%s:session id %d: Audio Stop procedure failed rc=%d\n",
-				__func__, audio->ac->session,
-					rc);
-			break;
-		}
-		break;
-	}
-	case AUDIO_SET_QCELP_ENC_CONFIG: {
-		struct msm_audio_qcelp_enc_config *cfg;
-		struct msm_audio_qcelp_enc_config *enc_cfg;
-
-		enc_cfg = audio->enc_cfg;
-		cfg = (struct msm_audio_qcelp_enc_config *)arg;
-		if (cfg == NULL) {
-			pr_err("%s: NULL config pointer\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->min_bit_rate > 4 ||
-			 cfg->min_bit_rate < 1) {
-			pr_err("%s:session id %d: invalid min bitrate\n",
-					__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg->max_bit_rate > 4 ||
-			 cfg->max_bit_rate < 1) {
-			pr_err("%s:session id %d: invalid max bitrate\n",
-					__func__, audio->ac->session);
-			rc = -EINVAL;
-			break;
-		}
-		enc_cfg->cdma_rate = cfg->cdma_rate;
-		enc_cfg->min_bit_rate = cfg->min_bit_rate;
-		enc_cfg->max_bit_rate = cfg->max_bit_rate;
-		pr_debug("%s:session id %d: min_bit_rate= 0x%x max_bit_rate=0x%x\n",
-			__func__,
-			audio->ac->session, enc_cfg->min_bit_rate,
-			enc_cfg->max_bit_rate);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long qcelp_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = qcelp_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_QCELP_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, audio->enc_cfg,
-			sizeof(struct msm_audio_qcelp_enc_config))) {
-			pr_err(
-				"%s: copy_to_user for AUDIO_GET_QCELP_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-		}
-		break;
-	}
-	case AUDIO_SET_QCELP_ENC_CONFIG: {
-		struct msm_audio_qcelp_enc_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg,
-				sizeof(cfg))) {
-			pr_err(
-				"%s: copy_from_user for AUDIO_SET_QCELP_ENC_CONFIG failed",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = qcelp_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_QCELP_ENC_CONFIG failed. Rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_audio_qcelp_enc_config32 {
-	u32 cdma_rate;
-	u32 min_bit_rate;
-	u32 max_bit_rate;
-};
-
-enum {
-	AUDIO_SET_QCELP_ENC_CONFIG_32 = _IOW(AUDIO_IOCTL_MAGIC,
-		0, struct msm_audio_qcelp_enc_config32),
-	AUDIO_GET_QCELP_ENC_CONFIG_32 = _IOR(AUDIO_IOCTL_MAGIC,
-		1, struct msm_audio_qcelp_enc_config32)
-};
-
-static long qcelp_in_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct q6audio_in  *audio = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_START:
-	case AUDIO_STOP: {
-		rc = qcelp_in_ioctl_shared(file, cmd, arg);
-		break;
-	}
-	case AUDIO_GET_QCELP_ENC_CONFIG_32: {
-		struct msm_audio_qcelp_enc_config32 cfg_32;
-		struct msm_audio_qcelp_enc_config *enc_cfg;
-
-		memset(&cfg_32, 0, sizeof(cfg_32));
-
-		enc_cfg = (struct msm_audio_qcelp_enc_config *)audio->enc_cfg;
-		cfg_32.cdma_rate = enc_cfg->cdma_rate;
-		cfg_32.min_bit_rate = enc_cfg->min_bit_rate;
-		cfg_32.max_bit_rate = enc_cfg->max_bit_rate;
-		if (copy_to_user((void *)arg, &cfg_32,
-			sizeof(cfg_32))) {
-			pr_err("%s: copy_to_user for AUDIO_GET_QCELP_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-}
-		break;
-	}
-	case AUDIO_SET_QCELP_ENC_CONFIG_32: {
-		struct msm_audio_qcelp_enc_config32 cfg_32;
-		struct msm_audio_qcelp_enc_config cfg;
-
-		if (copy_from_user(&cfg_32, (void *) arg,
-				sizeof(cfg_32))) {
-			pr_err("%s: copy_from_user for AUDIO_SET_QCELP_ENC_CONFIG_32 failed\n",
-				__func__);
-			rc = -EFAULT;
-			break;
-		}
-		cfg.cdma_rate = cfg_32.cdma_rate;
-		cfg.min_bit_rate = cfg_32.min_bit_rate;
-		cfg.max_bit_rate = cfg_32.max_bit_rate;
-		cmd = AUDIO_SET_QCELP_ENC_CONFIG;
-		rc = qcelp_in_ioctl_shared(file, cmd, (unsigned long)&cfg);
-		if (rc)
-			pr_err("%s:AUDIO_SET_QCELP_ENC_CONFIG failed. rc= %d\n",
-				__func__, rc);
-		break;
-	}
-	default:
-		pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-#else
-#define qcelp_in_compat_ioctl NULL
-#endif
-
-static int qcelp_in_open(struct inode *inode, struct file *file)
-{
-	struct q6audio_in *audio = NULL;
-	struct msm_audio_qcelp_enc_config *enc_cfg;
-	int rc = 0;
-
-	audio = kzalloc(sizeof(struct q6audio_in), GFP_KERNEL);
-
-	if (audio == NULL)
-		return -ENOMEM;
-
-	/* Allocate memory for encoder config param */
-	audio->enc_cfg = kzalloc(sizeof(struct msm_audio_qcelp_enc_config),
-				GFP_KERNEL);
-	if (audio->enc_cfg == NULL) {
-		kfree(audio);
-		return -ENOMEM;
-	}
-	enc_cfg = audio->enc_cfg;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->write_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->write_wait);
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->str_cfg.buffer_size = FRAME_SIZE;
-	audio->str_cfg.buffer_count = FRAME_NUM;
-	audio->min_frame_size = 35;
-	audio->max_frames_per_buf = 10;
-	audio->pcm_cfg.buffer_size = PCM_BUF_SIZE;
-	audio->pcm_cfg.buffer_count = PCM_BUF_COUNT;
-	enc_cfg->min_bit_rate = 4;
-	enc_cfg->max_bit_rate = 4;
-	audio->pcm_cfg.channel_count = 1;
-	audio->pcm_cfg.sample_rate = 8000;
-	audio->buf_cfg.meta_info_enable = 0x01;
-	audio->buf_cfg.frames_per_buf = 0x01;
-	audio->event_abort = 0;
-
-	audio->ac = q6asm_audio_client_alloc((app_cb)q6asm_in_cb,
-				(void *)audio);
-
-	if (!audio->ac) {
-		pr_err("%s: Could not allocate memory for audio client\n",
-				__func__);
-		kfree(audio->enc_cfg);
-		kfree(audio);
-		return -ENOMEM;
-	}
-
-	/* open qcelp encoder in T/NT mode */
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->feedback = NON_TUNNEL_MODE;
-		rc = q6asm_open_read_write(audio->ac, FORMAT_V13K,
-					FORMAT_LINEAR_PCM);
-		if (rc < 0) {
-			pr_err("%s:session id %d: NT mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: NT mode encoder success\n", __func__,
-				audio->ac->session);
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->feedback = TUNNEL_MODE;
-		rc = q6asm_open_read(audio->ac, FORMAT_V13K);
-		if (rc < 0) {
-			pr_err("%s:session id %d: T mode Open failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		/* register for tx overflow (valid for tunnel mode only) */
-		rc = q6asm_reg_tx_overflow(audio->ac, 0x01);
-		if (rc < 0) {
-			pr_err("%s:session id %d: TX Overflow registration failed rc=%d\n",
-				__func__, audio->ac->session, rc);
-			rc = -ENODEV;
-			goto fail;
-		}
-		pr_info("%s:session id %d: T mode encoder success\n", __func__,
-				audio->ac->session);
-	} else {
-		pr_err("%s:session id %d: Unexpected mode\n", __func__,
-				audio->ac->session);
-		rc = -EACCES;
-		goto fail;
-	}
-
-	audio->opened = 1;
-	audio->reset_event = false;
-	atomic_set(&audio->in_count, PCM_BUF_COUNT);
-	atomic_set(&audio->out_count, 0x00);
-	audio->enc_compat_ioctl = qcelp_in_compat_ioctl;
-	audio->enc_ioctl = qcelp_in_ioctl;
-	file->private_data = audio;
-
-	pr_info("%s:session id %d: success\n", __func__, audio->ac->session);
-	return 0;
-fail:
-	q6asm_audio_client_free(audio->ac);
-	kfree(audio->enc_cfg);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= qcelp_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-	.compat_ioctl   = audio_in_compat_ioctl
-};
-
-struct miscdevice audio_qcelp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_qcelp_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init qcelp_in_init(void)
-{
-	return misc_register(&audio_qcelp_in_misc);
-}
-
-device_initcall(qcelp_in_init);
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/Makefile b/drivers/misc/qcom/qdsp6v2/ultrasound/Makefile
deleted file mode 100644
index 41f614a..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-ccflags-y := -I$(src)/..
-obj-$(CONFIG_MSM_ULTRASOUND) += usf.o usfcdev.o q6usm.o
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.c b/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.c
deleted file mode 100644
index f20f335..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.c
+++ /dev/null
@@ -1,1467 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/mutex.h>
-#include <linux/wait.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <sound/apr_audio-v2.h>
-#include <linux/qdsp6v2/apr_us.h>
-#include "q6usm.h"
-
-#define ADSP_MEMORY_MAP_SHMEM8_4K_POOL 3
-
-#define MEM_4K_OFFSET 4095
-#define MEM_4K_MASK 0xfffff000
-
-#define USM_SESSION_MAX 0x02 /* aDSP:USM limit */
-
-#define READDONE_IDX_STATUS     0
-
-#define WRITEDONE_IDX_STATUS    0
-
-/* Standard timeout in the asynchronous ops */
-#define Q6USM_TIMEOUT_JIFFIES	(1*HZ) /* 1 sec */
-
-static DEFINE_MUTEX(session_lock);
-
-static struct us_client *session[USM_SESSION_MAX];
-static int32_t q6usm_mmapcallback(struct apr_client_data *data, void *priv);
-static int32_t q6usm_callback(struct apr_client_data *data, void *priv);
-static void q6usm_add_hdr(struct us_client *usc, struct apr_hdr *hdr,
-			  uint32_t pkt_size, bool cmd_flg);
-
-struct usm_mmap {
-	atomic_t ref_cnt;
-	atomic_t cmd_state;
-	wait_queue_head_t cmd_wait;
-	void *apr;
-	int mem_handle;
-};
-
-static struct usm_mmap this_mmap;
-
-static void q6usm_add_mmaphdr(struct apr_hdr *hdr,
-			      uint32_t pkt_size, bool cmd_flg, u32 token)
-{
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				       APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	hdr->src_port = 0;
-	hdr->dest_port = 0;
-	if (cmd_flg) {
-		hdr->token = token;
-		atomic_set(&this_mmap.cmd_state, 1);
-	}
-	hdr->pkt_size  = pkt_size;
-}
-
-static int q6usm_memory_map(phys_addr_t buf_add, int dir, uint32_t bufsz,
-		uint32_t bufcnt, uint32_t session, uint32_t *mem_handle)
-{
-	struct usm_cmd_memory_map_region mem_region_map;
-	int rc = 0;
-
-	if (this_mmap.apr == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6usm_add_mmaphdr(&mem_region_map.hdr,
-			  sizeof(struct usm_cmd_memory_map_region), true,
-			  ((session << 8) | dir));
-
-	mem_region_map.hdr.opcode = USM_CMD_SHARED_MEM_MAP_REGION;
-	mem_region_map.mempool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-
-	mem_region_map.num_regions = 1;
-	mem_region_map.flags = 0;
-
-	mem_region_map.shm_addr_lsw = lower_32_bits(buf_add);
-	mem_region_map.shm_addr_msw =
-			msm_audio_populate_upper_32_bits(buf_add);
-	mem_region_map.mem_size_bytes = bufsz * bufcnt;
-
-	rc = apr_send_pkt(this_mmap.apr, (uint32_t *) &mem_region_map);
-	if (rc < 0) {
-		pr_err("%s: mem_map op[0x%x]rc[%d]\n",
-		       __func__, mem_region_map.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(this_mmap.cmd_wait,
-				(atomic_read(&this_mmap.cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout. waited for memory_map\n", __func__);
-	} else {
-		*mem_handle = this_mmap.mem_handle;
-		rc = 0;
-	}
-fail_cmd:
-	return rc;
-}
-
-int q6usm_memory_unmap(phys_addr_t buf_add, int dir, uint32_t session,
-			uint32_t mem_handle)
-{
-	struct usm_cmd_memory_unmap_region mem_unmap;
-	int rc = 0;
-
-	if (this_mmap.apr == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6usm_add_mmaphdr(&mem_unmap.hdr,
-			  sizeof(struct usm_cmd_memory_unmap_region), true,
-			  ((session << 8) | dir));
-	mem_unmap.hdr.opcode = USM_CMD_SHARED_MEM_UNMAP_REGION;
-	mem_unmap.mem_map_handle = mem_handle;
-
-	rc = apr_send_pkt(this_mmap.apr, (uint32_t *) &mem_unmap);
-	if (rc < 0) {
-		pr_err("%s: mem_unmap op[0x%x] rc[%d]\n",
-		       __func__, mem_unmap.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(this_mmap.cmd_wait,
-				(atomic_read(&this_mmap.cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout. waited for memory_unmap\n", __func__);
-	} else
-		rc = 0;
-fail_cmd:
-	return rc;
-}
-
-static int q6usm_session_alloc(struct us_client *usc)
-{
-	int ind = 0;
-
-	mutex_lock(&session_lock);
-	for (ind = 0; ind < USM_SESSION_MAX; ++ind) {
-		if (!session[ind]) {
-			session[ind] = usc;
-			mutex_unlock(&session_lock);
-			++ind; /* session id: 0 reserved */
-			pr_debug("%s: session[%d] was allocated\n",
-				  __func__, ind);
-			return ind;
-		}
-	}
-	mutex_unlock(&session_lock);
-	return -ENOMEM;
-}
-
-static void q6usm_session_free(struct us_client *usc)
-{
-	/* Session index was incremented during allocation */
-	uint16_t ind = (uint16_t)usc->session - 1;
-
-	pr_debug("%s: to free session[%d]\n", __func__, ind);
-	if (ind < USM_SESSION_MAX) {
-		mutex_lock(&session_lock);
-		session[ind] = NULL;
-		mutex_unlock(&session_lock);
-	}
-}
-
-static int q6usm_us_client_buf_free(unsigned int dir,
-			     struct us_client *usc)
-{
-	struct us_port_data *port;
-	int rc = 0;
-
-	if ((usc == NULL) ||
-	    ((dir != IN) && (dir != OUT)))
-		return -EINVAL;
-
-	mutex_lock(&usc->cmd_lock);
-	port = &usc->port[dir];
-	if (port == NULL) {
-		mutex_unlock(&usc->cmd_lock);
-		return -EINVAL;
-	}
-
-	if (port->data == NULL) {
-		mutex_unlock(&usc->cmd_lock);
-		return 0;
-	}
-
-	rc = q6usm_memory_unmap(port->phys, dir, usc->session,
-				*((uint32_t *)port->ext));
-	pr_debug("%s: data[%pK]phys[%llx][%pK]\n", __func__,
-		 (void *)port->data, (u64)port->phys, (void *)&port->phys);
-
-	msm_audio_ion_free(port->client, port->handle);
-
-	port->data = NULL;
-	port->phys = 0;
-	port->buf_size = 0;
-	port->buf_cnt = 0;
-	port->client = NULL;
-	port->handle = NULL;
-
-	mutex_unlock(&usc->cmd_lock);
-	return rc;
-}
-
-int q6usm_us_param_buf_free(unsigned int dir,
-			struct us_client *usc)
-{
-	struct us_port_data *port;
-	int rc = 0;
-
-	if ((usc == NULL) ||
-		((dir != IN) && (dir != OUT)))
-		return -EINVAL;
-
-	mutex_lock(&usc->cmd_lock);
-	port = &usc->port[dir];
-	if (port == NULL) {
-		mutex_unlock(&usc->cmd_lock);
-		return -EINVAL;
-	}
-
-	if (port->param_buf == NULL) {
-		mutex_unlock(&usc->cmd_lock);
-		return 0;
-	}
-
-	rc = q6usm_memory_unmap(port->param_phys, dir, usc->session,
-				*((uint32_t *)port->param_buf_mem_handle));
-	pr_debug("%s: data[%pK]phys[%llx][%pK]\n", __func__,
-		 (void *)port->param_buf, (u64)port->param_phys,
-		 (void *)&port->param_phys);
-
-	msm_audio_ion_free(port->param_client, port->param_handle);
-
-	port->param_buf = NULL;
-	port->param_phys = 0;
-	port->param_buf_size = 0;
-	port->param_client = NULL;
-	port->param_handle = NULL;
-
-	mutex_unlock(&usc->cmd_lock);
-	return rc;
-}
-
-void q6usm_us_client_free(struct us_client *usc)
-{
-	int loopcnt = 0;
-	struct us_port_data *port;
-	uint32_t *p_mem_handle = NULL;
-
-	if ((usc == NULL) ||
-	    !(usc->session))
-		return;
-
-	for (loopcnt = 0; loopcnt <= OUT; ++loopcnt) {
-		port = &usc->port[loopcnt];
-		if (port->data == NULL)
-			continue;
-		pr_debug("%s: loopcnt = %d\n", __func__, loopcnt);
-		q6usm_us_client_buf_free(loopcnt, usc);
-		q6usm_us_param_buf_free(loopcnt, usc);
-	}
-	q6usm_session_free(usc);
-	apr_deregister(usc->apr);
-
-	pr_debug("%s: APR De-Register\n", __func__);
-
-	if (atomic_read(&this_mmap.ref_cnt) <= 0) {
-		pr_err("%s: APR Common Port Already Closed\n", __func__);
-		goto done;
-	}
-
-	atomic_dec(&this_mmap.ref_cnt);
-	if (atomic_read(&this_mmap.ref_cnt) == 0) {
-		apr_deregister(this_mmap.apr);
-		pr_debug("%s: APR De-Register common port\n", __func__);
-	}
-
-done:
-	p_mem_handle = (uint32_t *)usc->port[IN].ext;
-	kfree(p_mem_handle);
-	kfree(usc);
-	pr_debug("%s:\n", __func__);
-}
-
-struct us_client *q6usm_us_client_alloc(
-	void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
-	void *priv)
-{
-	struct us_client *usc;
-	uint32_t *p_mem_handle = NULL;
-	int n;
-	int lcnt = 0;
-
-	usc = kzalloc(sizeof(struct us_client), GFP_KERNEL);
-	if (usc == NULL)
-		return NULL;
-
-	p_mem_handle = kzalloc(sizeof(uint32_t) * 4, GFP_KERNEL);
-	if (p_mem_handle == NULL) {
-		kfree(usc);
-		return NULL;
-	}
-
-	n = q6usm_session_alloc(usc);
-	if (n <= 0)
-		goto fail_session;
-	usc->session = n;
-	usc->cb = cb;
-	usc->priv = priv;
-	usc->apr = apr_register("ADSP", "USM",
-				(apr_fn)q6usm_callback,
-				((usc->session) << 8 | 0x0001),
-				usc);
-
-	if (usc->apr == NULL) {
-		pr_err("%s: Registration with APR failed\n", __func__);
-		goto fail;
-	}
-	pr_debug("%s: Registering the common port with APR\n", __func__);
-	if (atomic_read(&this_mmap.ref_cnt) == 0) {
-		this_mmap.apr = apr_register("ADSP", "USM",
-					     (apr_fn)q6usm_mmapcallback,
-					     0x0FFFFFFFF, &this_mmap);
-		if (this_mmap.apr == NULL) {
-			pr_err("%s: USM port registration failed\n",
-			       __func__);
-			goto fail;
-		}
-	}
-
-	atomic_inc(&this_mmap.ref_cnt);
-	init_waitqueue_head(&usc->cmd_wait);
-	mutex_init(&usc->cmd_lock);
-	for (lcnt = 0; lcnt <= OUT; ++lcnt) {
-		mutex_init(&usc->port[lcnt].lock);
-		spin_lock_init(&usc->port[lcnt].dsp_lock);
-		usc->port[lcnt].ext = (void *)p_mem_handle++;
-		usc->port[lcnt].param_buf_mem_handle = (void *)p_mem_handle++;
-		pr_err("%s: usc->port[%d].ext=%pK;\n",
-		       __func__, lcnt, usc->port[lcnt].ext);
-	}
-	atomic_set(&usc->cmd_state, 0);
-
-	return usc;
-fail:
-	kfree(p_mem_handle);
-	q6usm_us_client_free(usc);
-	return NULL;
-fail_session:
-	kfree(p_mem_handle);
-	kfree(usc);
-	return NULL;
-}
-
-int q6usm_us_client_buf_alloc(unsigned int dir,
-			      struct us_client *usc,
-			      unsigned int bufsz,
-			      unsigned int bufcnt)
-{
-	int rc = 0;
-	struct us_port_data *port = NULL;
-	unsigned int size = bufsz*bufcnt;
-	size_t len;
-
-	if ((usc == NULL) ||
-	    ((dir != IN) && (dir != OUT)) || (size == 0) ||
-	    (usc->session <= 0 || usc->session > USM_SESSION_MAX)) {
-		pr_err("%s: wrong parameters: size=%d; bufcnt=%d\n",
-		       __func__, size, bufcnt);
-		return -EINVAL;
-	}
-
-	mutex_lock(&usc->cmd_lock);
-
-	port = &usc->port[dir];
-
-	/* The size to allocate should be multiple of 4K bytes */
-	size = PAGE_ALIGN(size);
-
-	rc = msm_audio_ion_alloc("ultrasound_client",
-		&port->client, &port->handle,
-		size, &port->phys,
-		&len, &port->data);
-
-	if (rc) {
-		pr_err("%s: US ION allocation failed, rc = %d\n",
-			__func__, rc);
-		mutex_unlock(&usc->cmd_lock);
-		return -ENOMEM;
-	}
-
-	port->buf_cnt = bufcnt;
-	port->buf_size = bufsz;
-	pr_debug("%s: data[%pK]; phys[%llx]; [%pK]\n", __func__,
-		 (void *)port->data,
-		 (u64)port->phys,
-		 (void *)&port->phys);
-
-	rc = q6usm_memory_map(port->phys, dir, size, 1, usc->session,
-				(uint32_t *)port->ext);
-	if (rc < 0) {
-		pr_err("%s: CMD Memory_map failed\n", __func__);
-		mutex_unlock(&usc->cmd_lock);
-		q6usm_us_client_buf_free(dir, usc);
-		q6usm_us_param_buf_free(dir, usc);
-	} else {
-		mutex_unlock(&usc->cmd_lock);
-		rc = 0;
-	}
-
-	return rc;
-}
-
-int q6usm_us_param_buf_alloc(unsigned int dir,
-			struct us_client *usc,
-			unsigned int bufsz)
-{
-	int rc = 0;
-	struct us_port_data *port = NULL;
-	unsigned int size = bufsz;
-	size_t len;
-
-	if ((usc == NULL) ||
-		((dir != IN) && (dir != OUT)) ||
-		(usc->session <= 0 || usc->session > USM_SESSION_MAX)) {
-		pr_err("%s: wrong parameters: direction=%d, bufsz=%d\n",
-			__func__, dir, bufsz);
-		return -EINVAL;
-	}
-
-	mutex_lock(&usc->cmd_lock);
-
-	port = &usc->port[dir];
-
-	if (bufsz == 0) {
-		pr_debug("%s: bufsz=0, get/set param commands are forbidden\n",
-			__func__);
-		port->param_buf = NULL;
-		mutex_unlock(&usc->cmd_lock);
-		return rc;
-	}
-
-	/* The size to allocate should be multiple of 4K bytes */
-	size = PAGE_ALIGN(size);
-
-	rc = msm_audio_ion_alloc("ultrasound_client",
-		&port->param_client, &port->param_handle,
-		size, &port->param_phys,
-		&len, &port->param_buf);
-
-	if (rc) {
-		pr_err("%s: US ION allocation failed, rc = %d\n",
-			__func__, rc);
-		mutex_unlock(&usc->cmd_lock);
-		return -ENOMEM;
-	}
-
-	port->param_buf_size = bufsz;
-	pr_debug("%s: param_buf[%pK]; param_phys[%llx]; [%pK]\n", __func__,
-		 (void *)port->param_buf,
-		 (u64)port->param_phys,
-		 (void *)&port->param_phys);
-
-	rc = q6usm_memory_map(port->param_phys, (IN | OUT), size, 1,
-			usc->session, (uint32_t *)port->param_buf_mem_handle);
-	if (rc < 0) {
-		pr_err("%s: CMD Memory_map failed\n", __func__);
-		mutex_unlock(&usc->cmd_lock);
-		q6usm_us_client_buf_free(dir, usc);
-		q6usm_us_param_buf_free(dir, usc);
-	} else {
-		mutex_unlock(&usc->cmd_lock);
-		rc = 0;
-	}
-
-	return rc;
-}
-
-static int32_t q6usm_mmapcallback(struct apr_client_data *data, void *priv)
-{
-	uint32_t token;
-	uint32_t *payload = data->payload;
-
-	pr_debug("%s: ptr0[0x%x]; ptr1[0x%x]; opcode[0x%x]\n",
-		 __func__, payload[0], payload[1], data->opcode);
-	pr_debug("%s: token[0x%x]; payload_size[%d]; src[%d]; dest[%d];\n",
-		 __func__, data->token, data->payload_size,
-		 data->src_port, data->dest_port);
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		/* status field check */
-		if (payload[1]) {
-			pr_err("%s: wrong response[%d] on cmd [%d]\n",
-			       __func__, payload[1], payload[0]);
-		} else {
-			token = data->token;
-			switch (payload[0]) {
-			case USM_CMD_SHARED_MEM_UNMAP_REGION:
-				if (atomic_read(&this_mmap.cmd_state)) {
-					atomic_set(&this_mmap.cmd_state, 0);
-					wake_up(&this_mmap.cmd_wait);
-				}
-				/* fallthrough */
-			case USM_CMD_SHARED_MEM_MAP_REGION:
-				/* For MEM_MAP, additional answer is waited, */
-				/* therfore, no wake-up here */
-				pr_debug("%s: cmd[0x%x]; result[0x%x]\n",
-					 __func__, payload[0], payload[1]);
-				break;
-			default:
-				pr_debug("%s: wrong command[0x%x]\n",
-					 __func__, payload[0]);
-				break;
-			}
-		}
-	} else {
-		if (data->opcode == USM_CMDRSP_SHARED_MEM_MAP_REGION) {
-			this_mmap.mem_handle = payload[0];
-			pr_debug("%s: memory map handle = 0x%x",
-				__func__, payload[0]);
-			if (atomic_read(&this_mmap.cmd_state)) {
-				atomic_set(&this_mmap.cmd_state, 0);
-				wake_up(&this_mmap.cmd_wait);
-			}
-		}
-	}
-	return 0;
-}
-
-
-static int32_t q6usm_callback(struct apr_client_data *data, void *priv)
-{
-	struct us_client *usc = (struct us_client *)priv;
-	unsigned long dsp_flags;
-	uint32_t *payload = data->payload;
-	uint32_t token = data->token;
-	uint32_t opcode = Q6USM_EVENT_UNDEF;
-
-	if (usc == NULL) {
-		pr_err("%s: client info is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		/* status field check */
-		if (payload[1]) {
-			pr_err("%s: wrong response[%d] on cmd [%d]\n",
-			       __func__, payload[1], payload[0]);
-			if (usc->cb)
-				usc->cb(data->opcode, token,
-					(uint32_t *)data->payload, usc->priv);
-		} else {
-			switch (payload[0]) {
-			case USM_SESSION_CMD_RUN:
-			case USM_STREAM_CMD_CLOSE:
-				if (token != usc->session) {
-					pr_err("%s: wrong token[%d]",
-					       __func__, token);
-					break;
-				}
-			case USM_STREAM_CMD_OPEN_READ:
-			case USM_STREAM_CMD_OPEN_WRITE:
-			case USM_STREAM_CMD_SET_ENC_PARAM:
-			case USM_DATA_CMD_MEDIA_FORMAT_UPDATE:
-			case USM_SESSION_CMD_SIGNAL_DETECT_MODE:
-			case USM_STREAM_CMD_SET_PARAM:
-			case USM_STREAM_CMD_GET_PARAM:
-				if (atomic_read(&usc->cmd_state)) {
-					atomic_set(&usc->cmd_state, 0);
-					wake_up(&usc->cmd_wait);
-				}
-				if (usc->cb)
-					usc->cb(data->opcode, token,
-						(uint32_t *)data->payload,
-						usc->priv);
-				break;
-			default:
-				break;
-			}
-		}
-		return 0;
-	}
-
-	switch (data->opcode) {
-	case RESET_EVENTS: {
-		pr_err("%s: Reset event is received: %d %d\n",
-				__func__,
-				data->reset_event,
-				data->reset_proc);
-
-		opcode = RESET_EVENTS;
-
-		apr_reset(this_mmap.apr);
-		this_mmap.apr = NULL;
-
-		apr_reset(usc->apr);
-		usc->apr = NULL;
-
-		break;
-	}
-
-
-	case USM_DATA_EVENT_READ_DONE: {
-		struct us_port_data *port = &usc->port[OUT];
-
-		opcode = Q6USM_EVENT_READ_DONE;
-		spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-		if (payload[READDONE_IDX_STATUS]) {
-			pr_err("%s: wrong READDONE[%d]; token[%d]\n",
-			       __func__,
-			       payload[READDONE_IDX_STATUS],
-			       token);
-			token = USM_WRONG_TOKEN;
-			spin_unlock_irqrestore(&port->dsp_lock,
-					       dsp_flags);
-			break;
-		}
-
-		if (port->expected_token != token) {
-			u32 cpu_buf = port->cpu_buf;
-
-			pr_err("%s: expected[%d] != token[%d]\n",
-				__func__, port->expected_token, token);
-			pr_debug("%s: dsp_buf=%d; cpu_buf=%d;\n",
-				__func__,   port->dsp_buf, cpu_buf);
-
-			token = USM_WRONG_TOKEN;
-			/* To prevent data handle continiue */
-			port->expected_token = USM_WRONG_TOKEN;
-			spin_unlock_irqrestore(&port->dsp_lock,
-					       dsp_flags);
-			break;
-		} /* port->expected_token != data->token */
-
-		port->expected_token = token + 1;
-		if (port->expected_token == port->buf_cnt)
-			port->expected_token = 0;
-
-		/* gap support */
-		if (port->expected_token != port->cpu_buf) {
-			port->dsp_buf = port->expected_token;
-			token = port->dsp_buf; /* for callback */
-		} else
-			port->dsp_buf = token;
-
-		spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-		break;
-	} /* case USM_DATA_EVENT_READ_DONE */
-
-	case USM_DATA_EVENT_WRITE_DONE: {
-		struct us_port_data *port = &usc->port[IN];
-
-		opcode = Q6USM_EVENT_WRITE_DONE;
-		if (payload[WRITEDONE_IDX_STATUS]) {
-			pr_err("%s: wrong WRITEDONE_IDX_STATUS[%d]\n",
-			       __func__,
-			       payload[WRITEDONE_IDX_STATUS]);
-			break;
-		}
-
-		spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-		port->dsp_buf = token + 1;
-		if (port->dsp_buf == port->buf_cnt)
-			port->dsp_buf = 0;
-		spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-
-		break;
-	} /* case USM_DATA_EVENT_WRITE_DONE */
-
-	case USM_SESSION_EVENT_SIGNAL_DETECT_RESULT: {
-		pr_debug("%s: US detect result: result=%d",
-			 __func__,
-			 payload[0]);
-		opcode = Q6USM_EVENT_SIGNAL_DETECT_RESULT;
-
-		break;
-	} /* case USM_SESSION_EVENT_SIGNAL_DETECT_RESULT */
-
-	default:
-		return 0;
-
-	} /* switch */
-
-	if (usc->cb)
-		usc->cb(opcode, token,
-			data->payload, usc->priv);
-
-	return 0;
-}
-
-uint32_t q6usm_get_virtual_address(int dir,
-				   struct us_client *usc,
-				   struct vm_area_struct *vms)
-{
-	uint32_t ret = 0xffffffff;
-
-	if (vms && (usc != NULL) && ((dir == IN) || (dir == OUT))) {
-		struct us_port_data *port = &usc->port[dir];
-		int size = PAGE_ALIGN(port->buf_size * port->buf_cnt);
-		struct audio_buffer ab;
-
-		ab.phys = port->phys;
-		ab.data = port->data;
-		ab.used = 1;
-		ab.size = size;
-		ab.actual_size = size;
-		ab.handle = port->handle;
-		ab.client = port->client;
-
-		ret = msm_audio_ion_mmap(&ab, vms);
-
-	}
-	return ret;
-}
-
-static void q6usm_add_hdr(struct us_client *usc, struct apr_hdr *hdr,
-			  uint32_t pkt_size, bool cmd_flg)
-{
-	mutex_lock(&usc->cmd_lock);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				       APR_HDR_LEN(sizeof(struct apr_hdr)),
-				       APR_PKT_VER);
-	hdr->src_svc = ((struct apr_svc *)usc->apr)->id;
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->dest_svc = APR_SVC_USM;
-	hdr->dest_domain = APR_DOMAIN_ADSP;
-	hdr->src_port = (usc->session << 8) | 0x0001;
-	hdr->dest_port = (usc->session << 8) | 0x0001;
-	if (cmd_flg) {
-		hdr->token = usc->session;
-		atomic_set(&usc->cmd_state, 1);
-	}
-	hdr->pkt_size  = pkt_size;
-	mutex_unlock(&usc->cmd_lock);
-}
-
-static uint32_t q6usm_ext2int_format(uint32_t ext_format)
-{
-	uint32_t int_format = INVALID_FORMAT;
-
-	switch (ext_format) {
-	case FORMAT_USPS_EPOS:
-		int_format = US_POINT_EPOS_FORMAT_V2;
-		break;
-	case FORMAT_USRAW:
-		int_format = US_RAW_FORMAT_V2;
-		break;
-	case FORMAT_USPROX:
-		int_format = US_PROX_FORMAT_V4;
-		break;
-	case FORMAT_USGES_SYNC:
-		int_format = US_GES_SYNC_FORMAT;
-		break;
-	case FORMAT_USRAW_SYNC:
-		int_format = US_RAW_SYNC_FORMAT;
-		break;
-	default:
-		pr_err("%s: Invalid format[%d]\n", __func__, ext_format);
-		break;
-	}
-
-	return int_format;
-}
-
-int q6usm_open_read(struct us_client *usc,
-		    uint32_t format)
-{
-	uint32_t int_format = INVALID_FORMAT;
-	int rc = 0x00;
-	struct usm_stream_cmd_open_read open;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: client or its apr is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: session[%d]", __func__, usc->session);
-
-	q6usm_add_hdr(usc, &open.hdr, sizeof(open), true);
-	open.hdr.opcode = USM_STREAM_CMD_OPEN_READ;
-	open.src_endpoint = 0; /* AFE */
-	open.pre_proc_top = 0; /* No preprocessing required */
-
-	int_format = q6usm_ext2int_format(format);
-	if (int_format == INVALID_FORMAT)
-		return -EINVAL;
-
-	open.uMode = STREAM_PRIORITY_NORMAL;
-	open.format = int_format;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-		       __func__, open.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout, waited for OPEN_READ rc[%d]\n",
-		       __func__, rc);
-		goto fail_cmd;
-	} else
-		rc = 0;
-fail_cmd:
-	return rc;
-}
-
-
-int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg)
-{
-	uint32_t int_format = INVALID_FORMAT;
-	struct usm_stream_cmd_encdec_cfg_blk  enc_cfg_obj;
-	struct usm_stream_cmd_encdec_cfg_blk  *enc_cfg = &enc_cfg_obj;
-	int rc = 0;
-	uint32_t total_cfg_size =
-		sizeof(struct usm_stream_cmd_encdec_cfg_blk);
-	uint32_t round_params_size = 0;
-	uint8_t  is_allocated = 0;
-
-
-	if ((usc == NULL) || (us_cfg == NULL)) {
-		pr_err("%s: wrong input", __func__);
-		return -EINVAL;
-	}
-
-	int_format = q6usm_ext2int_format(us_cfg->format_id);
-	if (int_format == INVALID_FORMAT) {
-		pr_err("%s: wrong input format[%d]",
-		       __func__, us_cfg->format_id);
-		return -EINVAL;
-	}
-
-	/* Transparent configuration data is after enc_cfg */
-	/* Integer number of u32s is required */
-	round_params_size = ((us_cfg->params_size + 3)/4) * 4;
-	if (round_params_size > USM_MAX_CFG_DATA_SIZE) {
-		/* Dynamic allocated encdec_cfg_blk is required */
-		/* static part use */
-		round_params_size -= USM_MAX_CFG_DATA_SIZE;
-		total_cfg_size += round_params_size;
-		enc_cfg = kzalloc(total_cfg_size, GFP_KERNEL);
-		if (enc_cfg == NULL) {
-			pr_err("%s: enc_cfg[%d] allocation failed\n",
-			       __func__, total_cfg_size);
-			return -ENOMEM;
-		}
-		is_allocated = 1;
-	} else
-		round_params_size = 0;
-
-	q6usm_add_hdr(usc, &enc_cfg->hdr, total_cfg_size, true);
-
-	enc_cfg->hdr.opcode = USM_STREAM_CMD_SET_ENC_PARAM;
-	enc_cfg->param_id = USM_PARAM_ID_ENCDEC_ENC_CFG_BLK;
-	enc_cfg->param_size = sizeof(struct usm_encode_cfg_blk)+
-				round_params_size;
-	enc_cfg->enc_blk.frames_per_buf = 1;
-	enc_cfg->enc_blk.format_id = int_format;
-	enc_cfg->enc_blk.cfg_size = sizeof(struct usm_cfg_common)+
-				    USM_MAX_CFG_DATA_SIZE +
-				    round_params_size;
-	memcpy(&(enc_cfg->enc_blk.cfg_common), &(us_cfg->cfg_common),
-	       sizeof(struct usm_cfg_common));
-
-	/* Transparent data copy */
-	memcpy(enc_cfg->enc_blk.transp_data, us_cfg->params,
-	       us_cfg->params_size);
-	pr_debug("%s: cfg_size[%d], params_size[%d]\n",
-		__func__,
-		enc_cfg->enc_blk.cfg_size,
-		us_cfg->params_size);
-	pr_debug("%s: params[%d,%d,%d,%d, %d,%d,%d,%d]\n",
-		__func__,
-		enc_cfg->enc_blk.transp_data[0],
-		enc_cfg->enc_blk.transp_data[1],
-		enc_cfg->enc_blk.transp_data[2],
-		enc_cfg->enc_blk.transp_data[3],
-		enc_cfg->enc_blk.transp_data[4],
-		enc_cfg->enc_blk.transp_data[5],
-		enc_cfg->enc_blk.transp_data[6],
-		enc_cfg->enc_blk.transp_data[7]
-	       );
-	pr_debug("%s: srate:%d, ch=%d, bps= %d;\n",
-		__func__, enc_cfg->enc_blk.cfg_common.sample_rate,
-		enc_cfg->enc_blk.cfg_common.ch_cfg,
-		enc_cfg->enc_blk.cfg_common.bits_per_sample);
-	pr_debug("dmap:[0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x]; dev_id=0x%x\n",
-		enc_cfg->enc_blk.cfg_common.data_map[0],
-		enc_cfg->enc_blk.cfg_common.data_map[1],
-		enc_cfg->enc_blk.cfg_common.data_map[2],
-		enc_cfg->enc_blk.cfg_common.data_map[3],
-		enc_cfg->enc_blk.cfg_common.data_map[4],
-		enc_cfg->enc_blk.cfg_common.data_map[5],
-		enc_cfg->enc_blk.cfg_common.data_map[6],
-		enc_cfg->enc_blk.cfg_common.data_map[7],
-		enc_cfg->enc_blk.cfg_common.dev_id);
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) enc_cfg);
-	if (rc < 0) {
-		pr_err("%s:Comamnd open failed\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout opcode[0x%x]\n",
-		       __func__, enc_cfg->hdr.opcode);
-	} else
-		rc = 0;
-
-fail_cmd:
-	if (is_allocated == 1)
-		kfree(enc_cfg);
-
-	return rc;
-}
-
-int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg)
-{
-
-	uint32_t int_format = INVALID_FORMAT;
-	struct usm_stream_media_format_update dec_cfg_obj;
-	struct usm_stream_media_format_update *dec_cfg = &dec_cfg_obj;
-
-	int rc = 0;
-	uint32_t total_cfg_size = sizeof(struct usm_stream_media_format_update);
-	uint32_t round_params_size = 0;
-	uint8_t  is_allocated = 0;
-
-
-	if ((usc == NULL) || (us_cfg == NULL)) {
-		pr_err("%s: wrong input", __func__);
-		return -EINVAL;
-	}
-
-	int_format = q6usm_ext2int_format(us_cfg->format_id);
-	if (int_format == INVALID_FORMAT) {
-		pr_err("%s: wrong input format[%d]",
-		       __func__, us_cfg->format_id);
-		return -EINVAL;
-	}
-
-	/* Transparent configuration data is after enc_cfg */
-	/* Integer number of u32s is required */
-	round_params_size = ((us_cfg->params_size + 3)/4) * 4;
-	if (round_params_size > USM_MAX_CFG_DATA_SIZE) {
-		/* Dynamic allocated encdec_cfg_blk is required */
-		/* static part use */
-		round_params_size -= USM_MAX_CFG_DATA_SIZE;
-		total_cfg_size += round_params_size;
-		dec_cfg = kzalloc(total_cfg_size, GFP_KERNEL);
-		if (dec_cfg == NULL) {
-			pr_err("%s:dec_cfg[%d] allocation failed\n",
-			       __func__, total_cfg_size);
-			return -ENOMEM;
-		}
-		is_allocated = 1;
-	} else { /* static transp_data is enough */
-		round_params_size = 0;
-	}
-
-	q6usm_add_hdr(usc, &dec_cfg->hdr, total_cfg_size, true);
-
-	dec_cfg->hdr.opcode = USM_DATA_CMD_MEDIA_FORMAT_UPDATE;
-	dec_cfg->format_id = int_format;
-	dec_cfg->cfg_size = sizeof(struct usm_cfg_common) +
-			    USM_MAX_CFG_DATA_SIZE +
-			    round_params_size;
-	memcpy(&(dec_cfg->cfg_common), &(us_cfg->cfg_common),
-	       sizeof(struct usm_cfg_common));
-	/* Transparent data copy */
-	memcpy(dec_cfg->transp_data, us_cfg->params, us_cfg->params_size);
-	pr_debug("%s: cfg_size[%d], params_size[%d]; parambytes[%d,%d,%d,%d]\n",
-		__func__,
-		dec_cfg->cfg_size,
-		us_cfg->params_size,
-		dec_cfg->transp_data[0],
-		dec_cfg->transp_data[1],
-		dec_cfg->transp_data[2],
-		dec_cfg->transp_data[3]
-	       );
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) dec_cfg);
-	if (rc < 0) {
-		pr_err("%s:Comamnd open failed\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout opcode[0x%x]\n",
-		       __func__, dec_cfg->hdr.opcode);
-	} else
-		rc = 0;
-
-fail_cmd:
-	if (is_allocated == 1)
-		kfree(dec_cfg);
-
-	return rc;
-}
-
-int q6usm_open_write(struct us_client *usc,
-		     uint32_t format)
-{
-	int rc = 0;
-	uint32_t int_format = INVALID_FORMAT;
-	struct usm_stream_cmd_open_write open;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: session[%d]", __func__, usc->session);
-
-	q6usm_add_hdr(usc, &open.hdr, sizeof(open), true);
-	open.hdr.opcode = USM_STREAM_CMD_OPEN_WRITE;
-
-	int_format = q6usm_ext2int_format(format);
-	if (int_format == INVALID_FORMAT) {
-		pr_err("%s: wrong format[%d]", __func__, format);
-		return -EINVAL;
-	}
-
-	open.format = int_format;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s:open failed op[0x%x]rc[%d]\n",
-		       __func__, open.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s:timeout. waited for OPEN_WRITR rc[%d]\n",
-		       __func__, rc);
-		goto fail_cmd;
-	} else
-		rc = 0;
-
-fail_cmd:
-	return rc;
-}
-
-int q6usm_run(struct us_client *usc, uint32_t flags,
-	      uint32_t msw_ts, uint32_t lsw_ts)
-{
-	struct usm_stream_cmd_run run;
-	int rc = 0;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	q6usm_add_hdr(usc, &run.hdr, sizeof(run), true);
-
-	run.hdr.opcode = USM_SESSION_CMD_RUN;
-	run.flags    = flags;
-	run.msw_ts   = msw_ts;
-	run.lsw_ts   = lsw_ts;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &run);
-	if (rc < 0) {
-		pr_err("%s: Commmand run failed[%d]\n", __func__, rc);
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: timeout. waited for run success rc[%d]\n",
-		       __func__, rc);
-	} else
-		rc = 0;
-
-fail_cmd:
-	return rc;
-}
-
-
-
-int q6usm_read(struct us_client *usc, uint32_t read_ind)
-{
-	struct usm_stream_cmd_read read;
-	struct us_port_data *port = NULL;
-	int rc = 0;
-	u32 read_counter = 0;
-	u32 loop_ind = 0;
-	u64 buf_addr = 0;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	port = &usc->port[OUT];
-
-	if (read_ind > port->buf_cnt) {
-		pr_err("%s: wrong read_ind[%d]\n",
-		       __func__, read_ind);
-		return -EINVAL;
-	}
-	if (read_ind == port->cpu_buf) {
-		pr_err("%s: no free region\n", __func__);
-		return 0;
-	}
-
-	if (read_ind > port->cpu_buf) { /* 1 range */
-		read_counter = read_ind - port->cpu_buf;
-	} else { /* 2 ranges */
-		read_counter = (port->buf_cnt - port->cpu_buf) + read_ind;
-	}
-
-	q6usm_add_hdr(usc, &read.hdr, sizeof(read), false);
-
-	read.hdr.opcode = USM_DATA_CMD_READ;
-	read.buf_size = port->buf_size;
-	buf_addr = (u64)(port->phys) + port->buf_size * (port->cpu_buf);
-	read.buf_addr_lsw = lower_32_bits(buf_addr);
-	read.buf_addr_msw = msm_audio_populate_upper_32_bits(buf_addr);
-	read.mem_map_handle = *((uint32_t *)(port->ext));
-
-	for (loop_ind = 0; loop_ind < read_counter; ++loop_ind) {
-		u32 temp_cpu_buf = port->cpu_buf;
-
-		buf_addr = (u64)(port->phys) +
-				port->buf_size * (port->cpu_buf);
-		read.buf_addr_lsw = lower_32_bits(buf_addr);
-		read.buf_addr_msw = msm_audio_populate_upper_32_bits(buf_addr);
-		read.seq_id = port->cpu_buf;
-		read.hdr.token = port->cpu_buf;
-		read.counter = 1;
-
-		++(port->cpu_buf);
-		if (port->cpu_buf == port->buf_cnt)
-			port->cpu_buf = 0;
-
-		rc = apr_send_pkt(usc->apr, (uint32_t *) &read);
-
-		if (rc < 0) {
-			port->cpu_buf = temp_cpu_buf;
-
-			pr_err("%s:read op[0x%x]rc[%d]\n",
-			       __func__, read.hdr.opcode, rc);
-			break;
-		}
-
-		rc = 0;
-	} /* bufs loop */
-
-	return rc;
-}
-
-int q6usm_write(struct us_client *usc, uint32_t write_ind)
-{
-	int rc = 0;
-	struct usm_stream_cmd_write cmd_write;
-	struct us_port_data *port = NULL;
-	u32 current_dsp_buf = 0;
-	u64 buf_addr = 0;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	port = &usc->port[IN];
-
-	current_dsp_buf = port->dsp_buf;
-	/* free region, caused by new dsp_buf report from DSP, */
-	/* can be only extended */
-	if (port->cpu_buf >= current_dsp_buf) {
-		/* 2 -part free region, including empty buffer */
-		if ((write_ind <= port->cpu_buf)  &&
-		    (write_ind > current_dsp_buf)) {
-			pr_err("%s: wrong w_ind[%d]; d_buf=%d; c_buf=%d\n",
-			       __func__, write_ind,
-			       current_dsp_buf, port->cpu_buf);
-			return -EINVAL;
-		}
-	} else {
-		/* 1 -part free region */
-		if ((write_ind <= port->cpu_buf)  ||
-		    (write_ind > current_dsp_buf)) {
-			pr_err("%s: wrong w_ind[%d]; d_buf=%d; c_buf=%d\n",
-			       __func__, write_ind,
-			       current_dsp_buf, port->cpu_buf);
-			return -EINVAL;
-		}
-	}
-
-	q6usm_add_hdr(usc, &cmd_write.hdr, sizeof(cmd_write), false);
-
-	cmd_write.hdr.opcode = USM_DATA_CMD_WRITE;
-	cmd_write.buf_size = port->buf_size;
-	buf_addr = (u64)(port->phys) + port->buf_size * (port->cpu_buf);
-	cmd_write.buf_addr_lsw = lower_32_bits(buf_addr);
-	cmd_write.buf_addr_msw = msm_audio_populate_upper_32_bits(buf_addr);
-	cmd_write.mem_map_handle = *((uint32_t *)(port->ext));
-	cmd_write.res0 = 0;
-	cmd_write.res1 = 0;
-	cmd_write.res2 = 0;
-
-	while (port->cpu_buf != write_ind) {
-		u32 temp_cpu_buf = port->cpu_buf;
-
-		buf_addr = (u64)(port->phys) +
-				port->buf_size * (port->cpu_buf);
-		cmd_write.buf_addr_lsw = lower_32_bits(buf_addr);
-		cmd_write.buf_addr_msw =
-				msm_audio_populate_upper_32_bits(buf_addr);
-		cmd_write.seq_id = port->cpu_buf;
-		cmd_write.hdr.token = port->cpu_buf;
-
-		++(port->cpu_buf);
-		if (port->cpu_buf == port->buf_cnt)
-			port->cpu_buf = 0;
-
-		rc = apr_send_pkt(usc->apr, (uint32_t *) &cmd_write);
-
-		if (rc < 0) {
-			port->cpu_buf = temp_cpu_buf;
-			pr_err("%s:write op[0x%x];rc[%d];cpu_buf[%d]\n",
-			       __func__, cmd_write.hdr.opcode,
-			       rc, port->cpu_buf);
-			break;
-		}
-
-		rc = 0;
-	}
-
-	return rc;
-}
-
-bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region)
-{
-	struct us_port_data *port = NULL;
-	u32 cpu_buf = 0;
-
-	if ((usc == NULL) || !free_region) {
-		pr_err("%s: input data wrong\n", __func__);
-		return false;
-	}
-	port = &usc->port[IN];
-	cpu_buf = port->cpu_buf + 1;
-	if (cpu_buf == port->buf_cnt)
-		cpu_buf = 0;
-
-	*free_region = port->dsp_buf;
-
-	return cpu_buf == *free_region;
-}
-
-int q6usm_cmd(struct us_client *usc, int cmd)
-{
-	struct apr_hdr hdr;
-	int rc = 0;
-	atomic_t *state;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	q6usm_add_hdr(usc, &hdr, sizeof(hdr), true);
-	switch (cmd) {
-	case CMD_CLOSE:
-		hdr.opcode = USM_STREAM_CMD_CLOSE;
-		state = &usc->cmd_state;
-		break;
-
-	default:
-		pr_err("%s:Invalid format[%d]\n", __func__, cmd);
-		goto fail_cmd;
-	}
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &hdr);
-	if (rc < 0) {
-		pr_err("%s: Command 0x%x failed\n", __func__, hdr.opcode);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(usc->cmd_wait, (atomic_read(state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s:timeout. waited for response opcode[0x%x]\n",
-		       __func__, hdr.opcode);
-	} else
-		rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int q6usm_set_us_detection(struct us_client *usc,
-			   struct usm_session_cmd_detect_info *detect_info,
-			   uint16_t detect_info_size)
-{
-	int rc = 0;
-
-	if ((usc == NULL) ||
-	    (detect_info_size == 0) ||
-	    (detect_info == NULL)) {
-		pr_err("%s: wrong input: usc=0x%pK, inf_size=%d; info=0x%pK",
-		       __func__,
-		       usc,
-		       detect_info_size,
-		       detect_info);
-		return -EINVAL;
-	}
-
-	q6usm_add_hdr(usc, &detect_info->hdr, detect_info_size, true);
-
-	detect_info->hdr.opcode = USM_SESSION_CMD_SIGNAL_DETECT_MODE;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *)detect_info);
-	if (rc < 0) {
-		pr_err("%s:Comamnd signal detect failed\n", __func__);
-		return -EINVAL;
-	}
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: CMD_SIGNAL_DETECT_MODE: timeout=%d\n",
-		       __func__, Q6USM_TIMEOUT_JIFFIES);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-int q6usm_set_us_stream_param(int dir, struct us_client *usc,
-		uint32_t module_id, uint32_t param_id, uint32_t buf_size)
-{
-	int rc = 0;
-	struct usm_stream_cmd_set_param cmd_set_param;
-	struct us_port_data *port = NULL;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	port = &usc->port[dir];
-
-	q6usm_add_hdr(usc, &cmd_set_param.hdr, sizeof(cmd_set_param), true);
-
-	cmd_set_param.hdr.opcode = USM_STREAM_CMD_SET_PARAM;
-	cmd_set_param.buf_size = buf_size;
-	cmd_set_param.buf_addr_msw =
-			msm_audio_populate_upper_32_bits(port->param_phys);
-	cmd_set_param.buf_addr_lsw = lower_32_bits(port->param_phys);
-	cmd_set_param.mem_map_handle =
-			*((uint32_t *)(port->param_buf_mem_handle));
-	cmd_set_param.module_id = module_id;
-	cmd_set_param.param_id = param_id;
-	cmd_set_param.hdr.token = 0;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &cmd_set_param);
-
-	if (rc < 0) {
-		pr_err("%s:write op[0x%x];rc[%d]\n",
-			__func__, cmd_set_param.hdr.opcode, rc);
-	}
-
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: CMD_SET_PARAM: timeout=%d\n",
-			__func__, Q6USM_TIMEOUT_JIFFIES);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-int q6usm_get_us_stream_param(int dir, struct us_client *usc,
-		uint32_t module_id, uint32_t param_id, uint32_t buf_size)
-{
-	int rc = 0;
-	struct usm_stream_cmd_get_param cmd_get_param;
-	struct us_port_data *port = NULL;
-
-	if ((usc == NULL) || (usc->apr == NULL)) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	port = &usc->port[dir];
-
-	q6usm_add_hdr(usc, &cmd_get_param.hdr, sizeof(cmd_get_param), true);
-
-	cmd_get_param.hdr.opcode = USM_STREAM_CMD_GET_PARAM;
-	cmd_get_param.buf_size = buf_size;
-	cmd_get_param.buf_addr_msw =
-			msm_audio_populate_upper_32_bits(port->param_phys);
-	cmd_get_param.buf_addr_lsw = lower_32_bits(port->param_phys);
-	cmd_get_param.mem_map_handle =
-			*((uint32_t *)(port->param_buf_mem_handle));
-	cmd_get_param.module_id = module_id;
-	cmd_get_param.param_id = param_id;
-	cmd_get_param.hdr.token = 0;
-
-	rc = apr_send_pkt(usc->apr, (uint32_t *) &cmd_get_param);
-
-	if (rc < 0) {
-		pr_err("%s:write op[0x%x];rc[%d]\n",
-			__func__, cmd_get_param.hdr.opcode, rc);
-	}
-
-	rc = wait_event_timeout(usc->cmd_wait,
-				(atomic_read(&usc->cmd_state) == 0),
-				Q6USM_TIMEOUT_JIFFIES);
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s: CMD_GET_PARAM: timeout=%d\n",
-			__func__, Q6USM_TIMEOUT_JIFFIES);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-static int __init q6usm_init(void)
-{
-	pr_debug("%s\n", __func__);
-	init_waitqueue_head(&this_mmap.cmd_wait);
-	memset(session, 0, sizeof(session));
-	return 0;
-}
-
-device_initcall(q6usm_init);
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.h b/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.h
deleted file mode 100644
index d45d165..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/q6usm.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6_USM_H__
-#define __Q6_USM_H__
-
-#include <linux/qdsp6v2/apr_us.h>
-
-#define Q6USM_EVENT_UNDEF                0
-#define Q6USM_EVENT_READ_DONE            1
-#define Q6USM_EVENT_WRITE_DONE           2
-#define Q6USM_EVENT_SIGNAL_DETECT_RESULT 3
-
-/* cyclic buffer with 1 gap support */
-#define USM_MIN_BUF_CNT 3
-
-#define FORMAT_USPS_EPOS	0x00000000
-#define FORMAT_USRAW		0x00000001
-#define FORMAT_USPROX		0x00000002
-#define FORMAT_USGES_SYNC	0x00000003
-#define FORMAT_USRAW_SYNC	0x00000004
-#define INVALID_FORMAT		0xffffffff
-
-#define IN			0x000
-#define OUT			0x001
-
-#define USM_WRONG_TOKEN		0xffffffff
-#define USM_UNDEF_TOKEN		0xfffffffe
-
-#define CMD_CLOSE		0x0004
-
-/* bit 0:1 represents priority of stream */
-#define STREAM_PRIORITY_NORMAL	0x0000
-#define STREAM_PRIORITY_LOW	0x0001
-#define STREAM_PRIORITY_HIGH	0x0002
-
-/* bit 4 represents META enable of encoded data buffer */
-#define BUFFER_META_ENABLE	0x0010
-
-struct us_port_data {
-	dma_addr_t	phys;
-	/* cyclic region of buffers with 1 gap */
-	void		*data;
-	/* number of buffers in the region */
-	uint32_t	buf_cnt;
-	/* size of buffer */
-	size_t		buf_size;
-	/* write index */
-	uint32_t	dsp_buf;
-	/* read index */
-	uint32_t	cpu_buf;
-	/* expected token from dsp */
-	uint32_t	expected_token;
-	/* read or write locks */
-	struct mutex	lock;
-	spinlock_t	dsp_lock;
-	/* ION memory handle */
-	struct      ion_handle *handle;
-	/* ION memory client */
-	struct      ion_client *client;
-	/* extended parameters, related to q6 variants */
-	void		*ext;
-	/* physical address of parameter buffer */
-	dma_addr_t	param_phys;
-	/* buffer which stores the parameter data */
-	void		*param_buf;
-	/* size of parameter buffer */
-	uint32_t	param_buf_size;
-	/* parameter buffer memory handle */
-	void		*param_buf_mem_handle;
-	/* ION memory handle for parameter buffer */
-	struct      ion_handle *param_handle;
-	/* ION memory client for parameter buffer */
-	struct      ion_client *param_client;
-};
-
-struct us_client {
-	int			session;
-	/* idx:1 out port, 0: in port*/
-	struct us_port_data	port[2];
-
-	struct apr_svc		*apr;
-	struct mutex		cmd_lock;
-
-	atomic_t		cmd_state;
-	atomic_t		eos_state;
-	wait_queue_head_t	cmd_wait;
-
-	void (*cb)(uint32_t, uint32_t, uint32_t *, void *);
-	void			*priv;
-};
-
-int q6usm_run(struct us_client *usc, uint32_t flags,
-	      uint32_t msw_ts, uint32_t lsw_ts);
-int q6usm_cmd(struct us_client *usc, int cmd);
-int q6usm_us_client_buf_alloc(unsigned int dir, struct us_client *usc,
-			      unsigned int bufsz, unsigned int bufcnt);
-int q6usm_us_param_buf_alloc(unsigned int dir, struct us_client *usc,
-			      unsigned int bufsz);
-int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
-int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
-int q6usm_read(struct us_client *usc, uint32_t read_ind);
-struct us_client *q6usm_us_client_alloc(
-	void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
-	void *priv);
-int q6usm_open_read(struct us_client *usc, uint32_t format);
-void q6usm_us_client_free(struct us_client *usc);
-uint32_t q6usm_get_virtual_address(int dir, struct us_client *usc,
-				   struct vm_area_struct *vms);
-int q6usm_open_write(struct us_client *usc,  uint32_t format);
-int q6usm_write(struct us_client *usc, uint32_t write_ind);
-bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region);
-int q6usm_set_us_detection(struct us_client *usc,
-			   struct usm_session_cmd_detect_info *detect_info,
-			   uint16_t detect_info_size);
-int q6usm_set_us_stream_param(int dir, struct us_client *usc,
-		uint32_t module_id, uint32_t param_id, uint32_t buf_size);
-int q6usm_get_us_stream_param(int dir, struct us_client *usc,
-		uint32_t module_id, uint32_t param_id, uint32_t buf_size);
-
-#endif /* __Q6_USM_H__ */
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/usf.c b/drivers/misc/qcom/qdsp6v2/ultrasound/usf.c
deleted file mode 100644
index 3da46b6..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/usf.c
+++ /dev/null
@@ -1,2465 +0,0 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/compat.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/input.h>
-#include <linux/uaccess.h>
-#include <linux/time.h>
-#include <linux/kmemleak.h>
-#include <linux/wakelock.h>
-#include <linux/mutex.h>
-#include <sound/apr_audio.h>
-#include <linux/qdsp6v2/usf.h>
-#include "q6usm.h"
-#include "usfcdev.h"
-
-/* The driver version*/
-#define DRV_VERSION "1.7.1"
-#define USF_VERSION_ID 0x0171
-
-/* Standard timeout in the asynchronous ops */
-#define USF_TIMEOUT_JIFFIES (1*HZ) /* 1 sec */
-
-/* Undefined USF device */
-#define USF_UNDEF_DEV_ID 0xffff
-
-/* TX memory mapping flag */
-#define USF_VM_READ 1
-/* RX memory mapping flag */
-#define USF_VM_WRITE 2
-
-/* Number of events, copied from the user space to kernel one */
-#define USF_EVENTS_PORTION_SIZE 20
-
-/* Indexes in range definitions */
-#define MIN_IND 0
-#define MAX_IND 1
-
-/* The coordinates indexes */
-#define X_IND 0
-#define Y_IND 1
-#define Z_IND 2
-
-/* Shared memory limits */
-/* max_buf_size = (port_size(65535*2) * port_num(8) * group_size(3) */
-#define USF_MAX_BUF_SIZE 3145680
-#define USF_MAX_BUF_NUM  32
-
-/* max size for buffer set from user space */
-#define USF_MAX_USER_BUF_SIZE 100000
-
-/* Place for opreation result, received from QDSP6 */
-#define APR_RESULT_IND 1
-
-/* Place for US detection result, received from QDSP6 */
-#define APR_US_DETECT_RESULT_IND 0
-
-#define BITS_IN_BYTE 8
-
-/* Time to stay awake after tx read event (e.g., proximity) */
-#define STAY_AWAKE_AFTER_READ_MSECS 3000
-
-/* The driver states */
-enum usf_state_type {
-	USF_IDLE_STATE,
-	USF_OPENED_STATE,
-	USF_CONFIGURED_STATE,
-	USF_WORK_STATE,
-	USF_ADSP_RESTART_STATE,
-	USF_ERROR_STATE
-};
-
-/* The US detection status upon FW/HW based US detection results */
-enum usf_us_detect_type {
-	USF_US_DETECT_UNDEF,
-	USF_US_DETECT_YES,
-	USF_US_DETECT_NO
-};
-
-struct usf_xx_type {
-	/* Name of the client - event calculator */
-	char client_name[USF_MAX_CLIENT_NAME_SIZE];
-	/* The driver state in TX or RX direction */
-	enum usf_state_type usf_state;
-	/* wait for q6 events mechanism */
-	wait_queue_head_t wait;
-	/* IF with q6usm info */
-	struct us_client *usc;
-	/* Q6:USM' Encoder/decoder configuration */
-	struct us_encdec_cfg encdec_cfg;
-	/* Shared buffer (with Q6:USM) size */
-	uint32_t buffer_size;
-	/* Number of the shared buffers (with Q6:USM) */
-	uint32_t buffer_count;
-	/* Shared memory (Cyclic buffer with 1 gap) control */
-	uint32_t new_region;
-	uint32_t prev_region;
-	/* Q6:USM's events handler */
-	void (*cb)(uint32_t, uint32_t, uint32_t *, void *);
-	/* US detection result */
-	enum usf_us_detect_type us_detect_type;
-	/* User's update info isn't acceptable */
-	u8 user_upd_info_na;
-};
-
-struct usf_type {
-	/* TX device component configuration & control */
-	struct usf_xx_type usf_tx;
-	/* RX device component configuration & control */
-	struct usf_xx_type usf_rx;
-	/* Index into the opened device container */
-	/* To prevent mutual usage of the same device */
-	uint16_t dev_ind;
-	/* Event types, supported by device */
-	uint16_t event_types;
-	/*  The input devices are "input" module registered clients */
-	struct input_dev *input_ifs[USF_MAX_EVENT_IND];
-	/* Bitmap of types of events, conflicting to USF's ones */
-	uint16_t conflicting_event_types;
-	/* Bitmap of types of events from devs, conflicting with USF */
-	uint16_t conflicting_event_filters;
-	/* The requested buttons bitmap */
-	uint16_t req_buttons_bitmap;
-	/* Mutex for exclusive operations (all public APIs) */
-	struct mutex mutex;
-};
-
-struct usf_input_dev_type {
-	/* Input event type, supported by the input device */
-	uint16_t event_type;
-	/* Input device name */
-	const char *input_dev_name;
-	/* Input device registration function */
-	int (*prepare_dev)(uint16_t, struct usf_type *,
-			    struct us_input_info_type *,
-			   const char *);
-	/* Input event notification function */
-	void (*notify_event)(struct usf_type *,
-			     uint16_t,
-			     struct usf_event_type *
-			     );
-};
-
-
-/* The MAX number of the supported devices */
-#define MAX_DEVS_NUMBER	1
-
-/*
- * code for a special button that is used to show/hide a
- * hovering cursor in the input framework. Must be in
- * sync with the button code definition in the framework
- * (EventHub.h)
- */
-#define BTN_USF_HOVERING_CURSOR         0x230
-
-/* Supported buttons container */
-static const int s_button_map[] = {
-	BTN_STYLUS,
-	BTN_STYLUS2,
-	BTN_TOOL_PEN,
-	BTN_TOOL_RUBBER,
-	BTN_TOOL_FINGER,
-	BTN_USF_HOVERING_CURSOR
-};
-
-/* The opened devices container */
-static atomic_t s_opened_devs[MAX_DEVS_NUMBER];
-
-static struct wakeup_source usf_wakeup_source;
-
-#define USF_NAME_PREFIX "usf_"
-#define USF_NAME_PREFIX_SIZE 4
-
-
-static struct input_dev *allocate_dev(uint16_t ind, const char *name)
-{
-	struct input_dev *in_dev = input_allocate_device();
-
-	if (in_dev == NULL) {
-		pr_err("%s: input_allocate_device() failed\n", __func__);
-	} else {
-		/* Common part configuration */
-		in_dev->name = name;
-		in_dev->phys = NULL;
-		in_dev->id.bustype = BUS_HOST;
-		in_dev->id.vendor  = 0x0001;
-		in_dev->id.product = 0x0001;
-		in_dev->id.version = USF_VERSION_ID;
-	}
-	return in_dev;
-}
-
-static int prepare_tsc_input_device(uint16_t ind,
-				struct usf_type *usf_info,
-				struct us_input_info_type *input_info,
-				const char *name)
-{
-	int i = 0;
-
-	int num_buttons = min(ARRAY_SIZE(s_button_map),
-		sizeof(input_info->req_buttons_bitmap) *
-		BITS_IN_BYTE);
-	uint16_t max_buttons_bitmap = ((1 << ARRAY_SIZE(s_button_map)) - 1);
-
-	struct input_dev *in_dev = allocate_dev(ind, name);
-
-	if (in_dev == NULL)
-		return -ENOMEM;
-
-	if (input_info->req_buttons_bitmap > max_buttons_bitmap) {
-		pr_err("%s: Requested buttons[%d] exceeds max buttons available[%d]\n",
-		__func__,
-		input_info->req_buttons_bitmap,
-		max_buttons_bitmap);
-		input_free_device(in_dev);
-		return -EINVAL;
-	}
-
-	usf_info->input_ifs[ind] = in_dev;
-	usf_info->req_buttons_bitmap =
-		input_info->req_buttons_bitmap;
-	in_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-	in_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
-
-	for (i = 0; i < num_buttons; i++)
-		if (input_info->req_buttons_bitmap & (1 << i))
-			in_dev->keybit[BIT_WORD(s_button_map[i])] |=
-			BIT_MASK(s_button_map[i]);
-
-	input_set_abs_params(in_dev, ABS_X,
-			     input_info->tsc_x_dim[MIN_IND],
-			     input_info->tsc_x_dim[MAX_IND],
-			     0, 0);
-	input_set_abs_params(in_dev, ABS_Y,
-			     input_info->tsc_y_dim[MIN_IND],
-			     input_info->tsc_y_dim[MAX_IND],
-			     0, 0);
-	input_set_abs_params(in_dev, ABS_DISTANCE,
-			     input_info->tsc_z_dim[MIN_IND],
-			     input_info->tsc_z_dim[MAX_IND],
-			     0, 0);
-
-	input_set_abs_params(in_dev, ABS_PRESSURE,
-			     input_info->tsc_pressure[MIN_IND],
-			     input_info->tsc_pressure[MAX_IND],
-			     0, 0);
-
-	input_set_abs_params(in_dev, ABS_TILT_X,
-			     input_info->tsc_x_tilt[MIN_IND],
-			     input_info->tsc_x_tilt[MAX_IND],
-			     0, 0);
-	input_set_abs_params(in_dev, ABS_TILT_Y,
-			     input_info->tsc_y_tilt[MIN_IND],
-			     input_info->tsc_y_tilt[MAX_IND],
-			     0, 0);
-
-	return 0;
-}
-
-static int prepare_mouse_input_device(uint16_t ind, struct usf_type *usf_info,
-			struct us_input_info_type *input_info,
-			const char *name)
-{
-	struct input_dev *in_dev = allocate_dev(ind, name);
-
-	if (in_dev == NULL)
-		return -ENOMEM;
-
-	usf_info->input_ifs[ind] = in_dev;
-	in_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
-
-	in_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
-						BIT_MASK(BTN_RIGHT) |
-						BIT_MASK(BTN_MIDDLE);
-	in_dev->relbit[0] =  BIT_MASK(REL_X) |
-				BIT_MASK(REL_Y) |
-				BIT_MASK(REL_Z);
-
-	return 0;
-}
-
-static int prepare_keyboard_input_device(
-					uint16_t ind,
-					struct usf_type *usf_info,
-					struct us_input_info_type *input_info,
-					const char *name)
-{
-	struct input_dev *in_dev = allocate_dev(ind, name);
-
-	if (in_dev == NULL)
-		return -ENOMEM;
-
-	usf_info->input_ifs[ind] = in_dev;
-	in_dev->evbit[0] |= BIT_MASK(EV_KEY);
-	/* All keys are permitted */
-	memset(in_dev->keybit, 0xff, sizeof(in_dev->keybit));
-
-	return 0;
-}
-
-static void notify_tsc_event(struct usf_type *usf_info,
-			     uint16_t if_ind,
-			     struct usf_event_type *event)
-
-{
-	int i = 0;
-	int num_buttons = min(ARRAY_SIZE(s_button_map),
-		sizeof(usf_info->req_buttons_bitmap) *
-		BITS_IN_BYTE);
-
-	struct input_dev *input_if = usf_info->input_ifs[if_ind];
-	struct point_event_type *pe = &(event->event_data.point_event);
-
-	input_report_abs(input_if, ABS_X, pe->coordinates[X_IND]);
-	input_report_abs(input_if, ABS_Y, pe->coordinates[Y_IND]);
-	input_report_abs(input_if, ABS_DISTANCE, pe->coordinates[Z_IND]);
-
-	input_report_abs(input_if, ABS_TILT_X, pe->inclinations[X_IND]);
-	input_report_abs(input_if, ABS_TILT_Y, pe->inclinations[Y_IND]);
-
-	input_report_abs(input_if, ABS_PRESSURE, pe->pressure);
-	input_report_key(input_if, BTN_TOUCH, !!(pe->pressure));
-
-	for (i = 0; i < num_buttons; i++) {
-		uint16_t mask = (1 << i),
-		btn_state = !!(pe->buttons_state_bitmap & mask);
-		if (usf_info->req_buttons_bitmap & mask)
-			input_report_key(input_if, s_button_map[i], btn_state);
-	}
-
-	input_sync(input_if);
-
-	pr_debug("%s: TSC event: xyz[%d;%d;%d], incl[%d;%d], pressure[%d], buttons[%d]\n",
-		 __func__,
-		 pe->coordinates[X_IND],
-		 pe->coordinates[Y_IND],
-		 pe->coordinates[Z_IND],
-		 pe->inclinations[X_IND],
-		 pe->inclinations[Y_IND],
-		 pe->pressure,
-		 pe->buttons_state_bitmap);
-}
-
-static void notify_mouse_event(struct usf_type *usf_info,
-			       uint16_t if_ind,
-			       struct usf_event_type *event)
-{
-	struct input_dev *input_if = usf_info->input_ifs[if_ind];
-	struct mouse_event_type *me = &(event->event_data.mouse_event);
-
-	input_report_rel(input_if, REL_X, me->rels[X_IND]);
-	input_report_rel(input_if, REL_Y, me->rels[Y_IND]);
-	input_report_rel(input_if, REL_Z, me->rels[Z_IND]);
-
-	input_report_key(input_if, BTN_LEFT,
-			 me->buttons_states & USF_BUTTON_LEFT_MASK);
-	input_report_key(input_if, BTN_MIDDLE,
-			 me->buttons_states & USF_BUTTON_MIDDLE_MASK);
-	input_report_key(input_if, BTN_RIGHT,
-			 me->buttons_states & USF_BUTTON_RIGHT_MASK);
-
-	input_sync(input_if);
-
-	pr_debug("%s: mouse event: dx[%d], dy[%d], buttons_states[%d]\n",
-		 __func__, me->rels[X_IND],
-		 me->rels[Y_IND], me->buttons_states);
-}
-
-static void notify_key_event(struct usf_type *usf_info,
-			     uint16_t if_ind,
-			     struct usf_event_type *event)
-{
-	struct input_dev *input_if = usf_info->input_ifs[if_ind];
-	struct key_event_type *ke = &(event->event_data.key_event);
-
-	input_report_key(input_if, ke->key, ke->key_state);
-	input_sync(input_if);
-	pr_debug("%s: key event: key[%d], state[%d]\n",
-		 __func__,
-		 ke->key,
-		 ke->key_state);
-
-}
-
-static struct usf_input_dev_type s_usf_input_devs[] = {
-	{USF_TSC_EVENT, "usf_tsc",
-		prepare_tsc_input_device, notify_tsc_event},
-	{USF_TSC_PTR_EVENT, "usf_tsc_ptr",
-		prepare_tsc_input_device, notify_tsc_event},
-	{USF_MOUSE_EVENT, "usf_mouse",
-		prepare_mouse_input_device, notify_mouse_event},
-	{USF_KEYBOARD_EVENT, "usf_kb",
-		prepare_keyboard_input_device, notify_key_event},
-	{USF_TSC_EXT_EVENT, "usf_tsc_ext",
-		prepare_tsc_input_device, notify_tsc_event},
-};
-
-static void usf_rx_cb(uint32_t opcode, uint32_t token,
-		      uint32_t *payload, void *priv)
-{
-	struct usf_xx_type *usf_xx = (struct usf_xx_type *) priv;
-
-	if (usf_xx == NULL) {
-		pr_err("%s: the private data is NULL\n", __func__);
-		return;
-	}
-
-	switch (opcode) {
-	case Q6USM_EVENT_WRITE_DONE:
-		wake_up(&usf_xx->wait);
-		break;
-
-	case RESET_EVENTS:
-		pr_err("%s: received RESET_EVENTS\n", __func__);
-		usf_xx->usf_state = USF_ADSP_RESTART_STATE;
-		wake_up(&usf_xx->wait);
-		break;
-
-	default:
-		break;
-	}
-}
-
-static void usf_tx_cb(uint32_t opcode, uint32_t token,
-		      uint32_t *payload, void *priv)
-{
-	struct usf_xx_type *usf_xx = (struct usf_xx_type *) priv;
-
-	if (usf_xx == NULL) {
-		pr_err("%s: the private data is NULL\n", __func__);
-		return;
-	}
-
-	switch (opcode) {
-	case Q6USM_EVENT_READ_DONE:
-		pr_debug("%s: acquiring %d msec wake lock\n", __func__,
-				STAY_AWAKE_AFTER_READ_MSECS);
-		__pm_wakeup_event(&usf_wakeup_source,
-				  STAY_AWAKE_AFTER_READ_MSECS);
-		if (token == USM_WRONG_TOKEN)
-			usf_xx->usf_state = USF_ERROR_STATE;
-		usf_xx->new_region = token;
-		wake_up(&usf_xx->wait);
-		break;
-
-	case Q6USM_EVENT_SIGNAL_DETECT_RESULT:
-		usf_xx->us_detect_type = (payload[APR_US_DETECT_RESULT_IND]) ?
-					USF_US_DETECT_YES :
-					USF_US_DETECT_NO;
-
-		wake_up(&usf_xx->wait);
-		break;
-
-	case APR_BASIC_RSP_RESULT:
-		if (payload[APR_RESULT_IND]) {
-			usf_xx->usf_state = USF_ERROR_STATE;
-			usf_xx->new_region = USM_WRONG_TOKEN;
-			wake_up(&usf_xx->wait);
-		}
-		break;
-
-	case RESET_EVENTS:
-		pr_err("%s: received RESET_EVENTS\n", __func__);
-		usf_xx->usf_state = USF_ADSP_RESTART_STATE;
-		wake_up(&usf_xx->wait);
-		break;
-
-	default:
-		break;
-	}
-}
-
-static void release_xx(struct usf_xx_type *usf_xx)
-{
-	if (usf_xx != NULL) {
-		if (usf_xx->usc) {
-			q6usm_us_client_free(usf_xx->usc);
-			usf_xx->usc = NULL;
-		}
-
-		if (usf_xx->encdec_cfg.params != NULL) {
-			kfree(usf_xx->encdec_cfg.params);
-			usf_xx->encdec_cfg.params = NULL;
-		}
-	}
-}
-
-static void usf_disable(struct usf_xx_type *usf_xx)
-{
-	if (usf_xx != NULL) {
-		if ((usf_xx->usf_state != USF_IDLE_STATE) &&
-		    (usf_xx->usf_state != USF_OPENED_STATE)) {
-			(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-			usf_xx->usf_state = USF_OPENED_STATE;
-			wake_up(&usf_xx->wait);
-		}
-		release_xx(usf_xx);
-	}
-}
-
-static int config_xx(struct usf_xx_type *usf_xx, struct us_xx_info_type *config)
-{
-	int rc = 0;
-	uint16_t data_map_size = 0;
-	uint16_t min_map_size = 0;
-
-	if ((usf_xx == NULL) ||
-	    (config == NULL))
-		return -EINVAL;
-
-	if ((config->buf_size == 0) ||
-	    (config->buf_size > USF_MAX_BUF_SIZE) ||
-	    (config->buf_num == 0) ||
-	    (config->buf_num > USF_MAX_BUF_NUM)) {
-		pr_err("%s: wrong params: buf_size=%d; buf_num=%d\n",
-		       __func__, config->buf_size, config->buf_num);
-		return -EINVAL;
-	}
-
-	data_map_size = sizeof(usf_xx->encdec_cfg.cfg_common.data_map);
-	min_map_size = min(data_map_size, config->port_cnt);
-
-	if (config->client_name != NULL) {
-		if (strncpy_from_user(usf_xx->client_name,
-				      (char __user *)config->client_name,
-				      sizeof(usf_xx->client_name) - 1) < 0) {
-			pr_err("%s: get client name failed\n", __func__);
-			return -EINVAL;
-		}
-	}
-
-	pr_debug("%s: name=%s; buf_size:%d; dev_id:0x%x; sample_rate:%d\n",
-		__func__, usf_xx->client_name, config->buf_size,
-		config->dev_id, config->sample_rate);
-
-	pr_debug("%s: buf_num:%d; format:%d; port_cnt:%d; data_size=%d\n",
-		__func__, config->buf_num, config->stream_format,
-		config->port_cnt, config->params_data_size);
-
-	pr_debug("%s: id[0]=%d, id[1]=%d, id[2]=%d, id[3]=%d, id[4]=%d,\n",
-		__func__,
-		config->port_id[0],
-		config->port_id[1],
-		config->port_id[2],
-		config->port_id[3],
-		config->port_id[4]);
-
-	pr_debug("id[5]=%d, id[6]=%d, id[7]=%d\n",
-		config->port_id[5],
-		config->port_id[6],
-		config->port_id[7]);
-
-	/* q6usm allocation & configuration */
-	usf_xx->buffer_size = config->buf_size;
-	usf_xx->buffer_count = config->buf_num;
-	usf_xx->encdec_cfg.cfg_common.bits_per_sample =
-				config->bits_per_sample;
-	usf_xx->encdec_cfg.cfg_common.sample_rate = config->sample_rate;
-	/* AFE port e.g. AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX */
-	usf_xx->encdec_cfg.cfg_common.dev_id = config->dev_id;
-
-	usf_xx->encdec_cfg.cfg_common.ch_cfg = config->port_cnt;
-	memcpy((void *)&usf_xx->encdec_cfg.cfg_common.data_map,
-	       (void *)config->port_id,
-	       min_map_size);
-
-	usf_xx->encdec_cfg.format_id = config->stream_format;
-	usf_xx->encdec_cfg.params_size = config->params_data_size;
-	usf_xx->user_upd_info_na = 1; /* it's used in US_GET_TX_UPDATE */
-
-	if (config->params_data_size > 0) { /* transparent data copy */
-		usf_xx->encdec_cfg.params = kzalloc(config->params_data_size,
-						    GFP_KERNEL);
-		/* False memory leak here - pointer in packed struct
-		 * is undetected by kmemleak tool
-		 */
-		kmemleak_ignore(usf_xx->encdec_cfg.params);
-		if (usf_xx->encdec_cfg.params == NULL) {
-			pr_err("%s: params memory alloc[%d] failure\n",
-				__func__,
-				config->params_data_size);
-			return -ENOMEM;
-		}
-		rc = copy_from_user(usf_xx->encdec_cfg.params,
-				    (uint8_t __user *)config->params_data,
-				    config->params_data_size);
-		if (rc) {
-			pr_err("%s: transparent data copy failure\n",
-			       __func__);
-			kfree(usf_xx->encdec_cfg.params);
-			usf_xx->encdec_cfg.params = NULL;
-			return -EFAULT;
-		}
-		pr_debug("%s: params_size[%d]; params[%d,%d,%d,%d, %d]\n",
-			 __func__,
-			 config->params_data_size,
-			 usf_xx->encdec_cfg.params[0],
-			 usf_xx->encdec_cfg.params[1],
-			 usf_xx->encdec_cfg.params[2],
-			 usf_xx->encdec_cfg.params[3],
-			 usf_xx->encdec_cfg.params[4]
-			);
-	}
-
-	usf_xx->usc = q6usm_us_client_alloc(usf_xx->cb, (void *)usf_xx);
-	if (!usf_xx->usc) {
-		pr_err("%s: Could not allocate q6usm client\n", __func__);
-		rc = -EFAULT;
-	}
-
-	return rc;
-}
-
-static bool usf_match(uint16_t event_type_ind, struct input_dev *dev)
-{
-	bool rc = false;
-
-	rc = (event_type_ind < MAX_EVENT_TYPE_NUM) &&
-		((dev->name == NULL) ||
-		strcmp(dev->name, USF_NAME_PREFIX));
-	pr_debug("%s: name=[%s]; rc=%d\n",
-		 __func__, dev->name, rc);
-
-	return rc;
-}
-
-static bool usf_register_conflicting_events(uint16_t event_types)
-{
-	bool rc = true;
-	uint16_t ind = 0;
-	uint16_t mask = 1;
-
-	for (ind = 0; ind < MAX_EVENT_TYPE_NUM; ++ind) {
-		if (event_types & mask) {
-			rc = usfcdev_register(ind, usf_match);
-			if (!rc)
-				break;
-		}
-		mask = mask << 1;
-	}
-
-	return rc;
-}
-
-static void usf_unregister_conflicting_events(uint16_t event_types)
-{
-	uint16_t ind = 0;
-	uint16_t mask = 1;
-
-	for (ind = 0; ind < MAX_EVENT_TYPE_NUM; ++ind) {
-		if (event_types & mask)
-			usfcdev_unregister(ind);
-		mask = mask << 1;
-	}
-}
-
-static void usf_set_event_filters(struct usf_type *usf, uint16_t event_filters)
-{
-	uint16_t ind = 0;
-	uint16_t mask = 1;
-
-	if (usf->conflicting_event_filters != event_filters) {
-		for (ind = 0; ind < MAX_EVENT_TYPE_NUM; ++ind) {
-			if (usf->conflicting_event_types & mask)
-				usfcdev_set_filter(ind, event_filters&mask);
-			mask = mask << 1;
-		}
-		usf->conflicting_event_filters = event_filters;
-	}
-}
-
-static int register_input_device(struct usf_type *usf_info,
-				 struct us_input_info_type *input_info)
-{
-	int rc = 0;
-	bool ret = true;
-	uint16_t ind = 0;
-
-	if ((usf_info == NULL) ||
-	    (input_info == NULL) ||
-	    !(input_info->event_types & USF_ALL_EVENTS)) {
-		pr_err("%s: wrong input parameter(s)\n", __func__);
-		return -EINVAL;
-	}
-
-	for (ind = 0; ind < USF_MAX_EVENT_IND; ++ind) {
-		if (usf_info->input_ifs[ind] != NULL) {
-			pr_err("%s: input_if[%d] is already allocated\n",
-				__func__, ind);
-			return -EFAULT;
-		}
-		if ((input_info->event_types &
-			s_usf_input_devs[ind].event_type) &&
-		     s_usf_input_devs[ind].prepare_dev) {
-			rc = (*s_usf_input_devs[ind].prepare_dev)(
-				ind,
-				usf_info,
-				input_info,
-				s_usf_input_devs[ind].input_dev_name);
-			if (rc)
-				return rc;
-
-			rc = input_register_device(usf_info->input_ifs[ind]);
-			if (rc) {
-				pr_err("%s: input_reg_dev() failed; rc=%d\n",
-					__func__, rc);
-				input_free_device(usf_info->input_ifs[ind]);
-				usf_info->input_ifs[ind] = NULL;
-			} else {
-				usf_info->event_types |=
-					s_usf_input_devs[ind].event_type;
-				pr_debug("%s: input device[%s] was registered\n",
-					__func__,
-					s_usf_input_devs[ind].input_dev_name);
-			}
-		} /* supported event */
-	} /* event types loop */
-
-	ret = usf_register_conflicting_events(
-			input_info->conflicting_event_types);
-	if (ret)
-		usf_info->conflicting_event_types =
-			input_info->conflicting_event_types;
-
-	return 0;
-}
-
-
-static void handle_input_event(struct usf_type *usf_info,
-			       uint16_t event_counter,
-			       struct usf_event_type __user *event)
-{
-	uint16_t ind = 0;
-	uint16_t events_num = 0;
-	struct usf_event_type usf_events[USF_EVENTS_PORTION_SIZE];
-	int rc = 0;
-
-	if ((usf_info == NULL) ||
-	    (event == NULL) || (!event_counter)) {
-		return;
-	}
-
-	while (event_counter > 0) {
-		if (event_counter > USF_EVENTS_PORTION_SIZE) {
-			events_num = USF_EVENTS_PORTION_SIZE;
-			event_counter -= USF_EVENTS_PORTION_SIZE;
-		} else {
-			events_num = event_counter;
-			event_counter = 0;
-		}
-		rc = copy_from_user(usf_events,
-				(struct usf_event_type __user *)event,
-				events_num * sizeof(struct usf_event_type));
-		if (rc) {
-			pr_err("%s: copy upd_rx_info from user; rc=%d\n",
-				__func__, rc);
-			return;
-		}
-		for (ind = 0; ind < events_num; ++ind) {
-			struct usf_event_type *p_event = &usf_events[ind];
-			uint16_t if_ind = p_event->event_type_ind;
-
-			if ((if_ind >= USF_MAX_EVENT_IND) ||
-			    (usf_info->input_ifs[if_ind] == NULL))
-				continue; /* event isn't supported */
-
-			if (s_usf_input_devs[if_ind].notify_event)
-				(*s_usf_input_devs[if_ind].notify_event)(
-								usf_info,
-								if_ind,
-								p_event);
-		} /* loop in the portion */
-	} /* all events loop */
-}
-
-static int usf_start_tx(struct usf_xx_type *usf_xx)
-{
-	int rc = q6usm_run(usf_xx->usc, 0, 0, 0);
-
-	pr_debug("%s: tx: q6usm_run; rc=%d\n", __func__, rc);
-	if (!rc) {
-		if (usf_xx->buffer_count >= USM_MIN_BUF_CNT) {
-			/* supply all buffers */
-			rc = q6usm_read(usf_xx->usc,
-					usf_xx->buffer_count);
-			pr_debug("%s: q6usm_read[%d]\n",
-				 __func__, rc);
-
-			if (rc)
-				pr_err("%s: buf read failed",
-				       __func__);
-			else
-				usf_xx->usf_state =
-					USF_WORK_STATE;
-		} else
-			usf_xx->usf_state =
-				USF_WORK_STATE;
-	}
-
-	return rc;
-} /* usf_start_tx */
-
-static int usf_start_rx(struct usf_xx_type *usf_xx)
-{
-	int rc = q6usm_run(usf_xx->usc, 0, 0, 0);
-
-	pr_debug("%s: rx: q6usm_run; rc=%d\n",
-		 __func__, rc);
-	if (!rc)
-		usf_xx->usf_state = USF_WORK_STATE;
-
-	return rc;
-} /* usf_start_rx */
-
-static int __usf_set_us_detection(struct usf_type *usf,
-				  struct us_detect_info_type *detect_info)
-{
-	uint32_t timeout = 0;
-	struct usm_session_cmd_detect_info *p_allocated_memory = NULL;
-	struct usm_session_cmd_detect_info usm_detect_info;
-	struct usm_session_cmd_detect_info *p_usm_detect_info =
-						&usm_detect_info;
-	uint32_t detect_info_size = sizeof(struct usm_session_cmd_detect_info);
-	struct usf_xx_type *usf_xx =  &usf->usf_tx;
-	int rc = 0;
-
-	if (detect_info->us_detector != US_DETECT_FW) {
-		pr_err("%s: unsupported detector: %d\n",
-			__func__, detect_info->us_detector);
-		return -EINVAL;
-	}
-
-	if ((detect_info->params_data_size != 0) &&
-	    (detect_info->params_data != NULL)) {
-		uint8_t *p_data = NULL;
-
-		detect_info_size += detect_info->params_data_size;
-		 p_allocated_memory = kzalloc(detect_info_size, GFP_KERNEL);
-		if (p_allocated_memory == NULL) {
-			pr_err("%s: detect_info[%d] allocation failed\n",
-			       __func__, detect_info_size);
-			return -ENOMEM;
-		}
-		p_usm_detect_info = p_allocated_memory;
-		p_data = (uint8_t *)p_usm_detect_info +
-			sizeof(struct usm_session_cmd_detect_info);
-
-		rc = copy_from_user(p_data,
-			(uint8_t __user *)(detect_info->params_data),
-			detect_info->params_data_size);
-		if (rc) {
-			pr_err("%s: copy params from user; rc=%d\n",
-				__func__, rc);
-			kfree(p_allocated_memory);
-			return -EFAULT;
-		}
-		p_usm_detect_info->algorithm_cfg_size =
-				detect_info->params_data_size;
-	} else
-		usm_detect_info.algorithm_cfg_size = 0;
-
-	p_usm_detect_info->detect_mode = detect_info->us_detect_mode;
-	p_usm_detect_info->skip_interval = detect_info->skip_time;
-
-	usf_xx->us_detect_type = USF_US_DETECT_UNDEF;
-
-	rc = q6usm_set_us_detection(usf_xx->usc,
-				    p_usm_detect_info,
-				    detect_info_size);
-	if (rc || (detect_info->detect_timeout == USF_NO_WAIT_TIMEOUT)) {
-		kfree(p_allocated_memory);
-		return rc;
-	}
-
-	/* Get US detection result */
-	if (detect_info->detect_timeout == USF_INFINITIVE_TIMEOUT) {
-		rc = wait_event_interruptible(usf_xx->wait,
-						(usf_xx->us_detect_type !=
-						USF_US_DETECT_UNDEF) ||
-						(usf_xx->usf_state ==
-						USF_ADSP_RESTART_STATE));
-	} else {
-		if (detect_info->detect_timeout == USF_DEFAULT_TIMEOUT)
-			timeout = USF_TIMEOUT_JIFFIES;
-		else
-			timeout = detect_info->detect_timeout * HZ;
-	}
-	rc = wait_event_interruptible_timeout(usf_xx->wait,
-					(usf_xx->us_detect_type !=
-					USF_US_DETECT_UNDEF) ||
-					(usf_xx->usf_state ==
-					USF_ADSP_RESTART_STATE), timeout);
-
-	/* In the case of aDSP restart, "no US" is assumed */
-	if (usf_xx->usf_state == USF_ADSP_RESTART_STATE)
-		rc = -EFAULT;
-
-	/* In the case of timeout, "no US" is assumed */
-	if (rc < 0)
-		pr_err("%s: Getting US detection failed rc[%d]\n",
-		       __func__, rc);
-	else {
-		usf->usf_rx.us_detect_type = usf->usf_tx.us_detect_type;
-		detect_info->is_us =
-			(usf_xx->us_detect_type == USF_US_DETECT_YES);
-	}
-
-	kfree(p_allocated_memory);
-
-	return rc;
-} /* __usf_set_us_detection */
-
-static int usf_set_us_detection(struct usf_type *usf, unsigned long arg)
-{
-	struct us_detect_info_type detect_info;
-
-	int rc = copy_from_user(&detect_info,
-				(struct us_detect_info_type __user *) arg,
-				sizeof(detect_info));
-
-	if (rc) {
-		pr_err("%s: copy detect_info from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	if (detect_info.params_data_size > USF_MAX_USER_BUF_SIZE) {
-		pr_err("%s: user buffer size exceeds maximum\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	rc = __usf_set_us_detection(usf, &detect_info);
-	if (rc < 0) {
-		pr_err("%s: set us detection failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = copy_to_user((void __user *)arg,
-			  &detect_info,
-			  sizeof(detect_info));
-	if (rc) {
-		pr_err("%s: copy detect_info to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_set_us_detection */
-
-static int __usf_set_tx_info(struct usf_type *usf,
-			     struct us_tx_info_type *config_tx)
-{
-	struct usf_xx_type *usf_xx =  &usf->usf_tx;
-	int rc = 0;
-
-	usf_xx->new_region = USM_UNDEF_TOKEN;
-	usf_xx->prev_region = USM_UNDEF_TOKEN;
-	usf_xx->cb = usf_tx_cb;
-
-	init_waitqueue_head(&usf_xx->wait);
-
-	if (config_tx->us_xx_info.client_name != NULL) {
-		int res = strncpy_from_user(
-			usf_xx->client_name,
-			(char __user *)(config_tx->us_xx_info.client_name),
-			sizeof(usf_xx->client_name)-1);
-		if (res < 0) {
-			pr_err("%s: get client name failed\n",
-			       __func__);
-			return -EINVAL;
-		}
-	}
-
-	rc = config_xx(usf_xx, &(config_tx->us_xx_info));
-	if (rc)
-		return rc;
-
-	rc = q6usm_open_read(usf_xx->usc,
-			     usf_xx->encdec_cfg.format_id);
-	if (rc)
-		return rc;
-
-	rc = q6usm_us_client_buf_alloc(OUT, usf_xx->usc,
-				       usf_xx->buffer_size,
-				       usf_xx->buffer_count);
-	if (rc) {
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-		return rc;
-	}
-
-	rc = q6usm_us_param_buf_alloc(OUT, usf_xx->usc,
-			config_tx->us_xx_info.max_get_set_param_buf_size);
-	if (rc) {
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-		return rc;
-	}
-
-	rc = q6usm_enc_cfg_blk(usf_xx->usc,
-			       &usf_xx->encdec_cfg);
-	if (!rc &&
-	     (config_tx->input_info.event_types != USF_NO_EVENT)) {
-		rc = register_input_device(usf,
-					   &(config_tx->input_info));
-	}
-
-	if (rc)
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-	else
-		usf_xx->usf_state = USF_CONFIGURED_STATE;
-
-	return rc;
-} /* __usf_set_tx_info */
-
-static int usf_set_tx_info(struct usf_type *usf, unsigned long arg)
-{
-	struct us_tx_info_type config_tx;
-
-	int rc = copy_from_user(&config_tx,
-			    (struct us_tx_info_type __user *) arg,
-			    sizeof(config_tx));
-
-	if (rc) {
-		pr_err("%s: copy config_tx from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	if (config_tx.us_xx_info.params_data_size > USF_MAX_USER_BUF_SIZE) {
-		pr_err("%s: user buffer size exceeds maximum\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	return __usf_set_tx_info(usf, &config_tx);
-} /* usf_set_tx_info */
-
-static int __usf_set_rx_info(struct usf_type *usf,
-			     struct us_rx_info_type *config_rx)
-{
-	struct usf_xx_type *usf_xx =  &usf->usf_rx;
-	int rc = 0;
-
-	usf_xx->new_region = USM_UNDEF_TOKEN;
-	usf_xx->prev_region = USM_UNDEF_TOKEN;
-
-	usf_xx->cb = usf_rx_cb;
-
-	rc = config_xx(usf_xx, &(config_rx->us_xx_info));
-	if (rc)
-		return rc;
-
-	rc = q6usm_open_write(usf_xx->usc,
-			      usf_xx->encdec_cfg.format_id);
-	if (rc)
-		return rc;
-
-	rc = q6usm_us_client_buf_alloc(
-				IN,
-				usf_xx->usc,
-				usf_xx->buffer_size,
-				usf_xx->buffer_count);
-	if (rc) {
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-		return rc;
-	}
-
-	rc = q6usm_us_param_buf_alloc(IN, usf_xx->usc,
-			config_rx->us_xx_info.max_get_set_param_buf_size);
-	if (rc) {
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-		return rc;
-	}
-
-	rc = q6usm_dec_cfg_blk(usf_xx->usc,
-			       &usf_xx->encdec_cfg);
-	if (rc)
-		(void)q6usm_cmd(usf_xx->usc, CMD_CLOSE);
-	else {
-		init_waitqueue_head(&usf_xx->wait);
-		usf_xx->usf_state = USF_CONFIGURED_STATE;
-	}
-
-	return rc;
-} /* __usf_set_rx_info */
-
-static int usf_set_rx_info(struct usf_type *usf, unsigned long arg)
-{
-	struct us_rx_info_type config_rx;
-
-	int rc = copy_from_user(&config_rx,
-				(struct us_rx_info_type __user *) arg,
-				sizeof(config_rx));
-
-	if (rc) {
-		pr_err("%s: copy config_rx from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	if (config_rx.us_xx_info.params_data_size > USF_MAX_USER_BUF_SIZE) {
-		pr_err("%s: user buffer size exceeds maximum\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	return __usf_set_rx_info(usf, &config_rx);
-} /* usf_set_rx_info */
-
-static int __usf_get_tx_update(struct usf_type *usf,
-			struct us_tx_update_info_type *upd_tx_info)
-{
-	unsigned long prev_jiffies = 0;
-	uint32_t timeout = 0;
-	struct usf_xx_type *usf_xx =  &usf->usf_tx;
-	int rc = 0;
-
-	if (!usf_xx->user_upd_info_na) {
-		usf_set_event_filters(usf, upd_tx_info->event_filters);
-		handle_input_event(usf,
-				   upd_tx_info->event_counter,
-				   upd_tx_info->event);
-
-		/* Release available regions */
-		rc = q6usm_read(usf_xx->usc,
-				upd_tx_info->free_region);
-		if (rc)
-			return rc;
-	} else
-		usf_xx->user_upd_info_na = 0;
-
-	/* Get data ready regions */
-	if (upd_tx_info->timeout == USF_INFINITIVE_TIMEOUT) {
-		rc = wait_event_interruptible(usf_xx->wait,
-			   (usf_xx->prev_region !=
-			    usf_xx->new_region) ||
-			   (usf_xx->usf_state !=
-			    USF_WORK_STATE));
-	} else {
-		if (upd_tx_info->timeout == USF_NO_WAIT_TIMEOUT)
-			rc = (usf_xx->prev_region != usf_xx->new_region);
-		else {
-			prev_jiffies = jiffies;
-			if (upd_tx_info->timeout == USF_DEFAULT_TIMEOUT) {
-				timeout = USF_TIMEOUT_JIFFIES;
-				rc = wait_event_timeout(
-						usf_xx->wait,
-						(usf_xx->prev_region !=
-						 usf_xx->new_region) ||
-						(usf_xx->usf_state !=
-						 USF_WORK_STATE),
-						timeout);
-			} else {
-				timeout = upd_tx_info->timeout * HZ;
-				rc = wait_event_interruptible_timeout(
-						usf_xx->wait,
-						(usf_xx->prev_region !=
-						 usf_xx->new_region) ||
-						(usf_xx->usf_state !=
-						 USF_WORK_STATE),
-						timeout);
-			}
-		}
-		if (!rc) {
-			pr_debug("%s: timeout. prev_j=%lu; j=%lu\n",
-				__func__, prev_jiffies, jiffies);
-			pr_debug("%s: timeout. prev=%d; new=%d\n",
-				__func__, usf_xx->prev_region,
-				usf_xx->new_region);
-			pr_debug("%s: timeout. free_region=%d;\n",
-				__func__, upd_tx_info->free_region);
-			if (usf_xx->prev_region ==
-			    usf_xx->new_region) {
-				pr_err("%s:read data: timeout\n",
-				       __func__);
-				return -ETIME;
-			}
-		}
-	}
-
-	if ((usf_xx->usf_state != USF_WORK_STATE) ||
-	    (rc == -ERESTARTSYS)) {
-		pr_err("%s: Get ready region failure; state[%d]; rc[%d]\n",
-		       __func__, usf_xx->usf_state, rc);
-		return -EINTR;
-	}
-
-	upd_tx_info->ready_region = usf_xx->new_region;
-	usf_xx->prev_region = upd_tx_info->ready_region;
-
-	if (upd_tx_info->ready_region == USM_WRONG_TOKEN) {
-		pr_err("%s: TX path corrupted; prev=%d\n",
-		       __func__, usf_xx->prev_region);
-		return -EIO;
-	}
-
-	return rc;
-} /* __usf_get_tx_update */
-
-static int usf_get_tx_update(struct usf_type *usf, unsigned long arg)
-{
-	struct us_tx_update_info_type upd_tx_info;
-
-	int rc = copy_from_user(&upd_tx_info,
-				(struct us_tx_update_info_type __user *) arg,
-				sizeof(upd_tx_info));
-
-	if (rc < 0) {
-		pr_err("%s: copy upd_tx_info from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	rc = __usf_get_tx_update(usf, &upd_tx_info);
-	if (rc < 0) {
-		pr_err("%s: get tx update failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = copy_to_user((void __user *)arg,
-			  &upd_tx_info,
-			  sizeof(upd_tx_info));
-	if (rc) {
-		pr_err("%s: copy upd_tx_info to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_get_tx_update */
-
-static int __usf_set_rx_update(struct usf_xx_type *usf_xx,
-			       struct us_rx_update_info_type *upd_rx_info)
-{
-	int rc = 0;
-
-	/* Send available data regions */
-	if (upd_rx_info->ready_region !=
-	    usf_xx->buffer_count) {
-		rc = q6usm_write(
-			usf_xx->usc,
-			upd_rx_info->ready_region);
-		if (rc)
-			return rc;
-	}
-
-	/* Get free regions */
-	rc = wait_event_timeout(
-		usf_xx->wait,
-		!q6usm_is_write_buf_full(
-			usf_xx->usc,
-			&(upd_rx_info->free_region)) ||
-		(usf_xx->usf_state == USF_IDLE_STATE),
-		USF_TIMEOUT_JIFFIES);
-
-	if (!rc) {
-		rc = -ETIME;
-		pr_err("%s:timeout. wait for write buf not full\n",
-		       __func__);
-	} else {
-		if (usf_xx->usf_state !=
-		    USF_WORK_STATE) {
-			pr_err("%s: RX: state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EINTR;
-		}
-	}
-
-	return rc;
-} /* __usf_set_rx_update */
-
-static int usf_set_rx_update(struct usf_xx_type *usf_xx, unsigned long arg)
-{
-	struct us_rx_update_info_type upd_rx_info;
-
-	int rc = copy_from_user(&upd_rx_info,
-				(struct us_rx_update_info_type __user *) arg,
-				sizeof(upd_rx_info));
-
-	if (rc) {
-		pr_err("%s: copy upd_rx_info from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	rc = __usf_set_rx_update(usf_xx, &upd_rx_info);
-	if (rc < 0) {
-		pr_err("%s: set rx update failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = copy_to_user((void __user *)arg,
-			&upd_rx_info,
-			sizeof(upd_rx_info));
-	if (rc) {
-		pr_err("%s: copy rx_info to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_set_rx_update */
-
-static void usf_release_input(struct usf_type *usf)
-{
-	uint16_t ind = 0;
-
-	usf_unregister_conflicting_events(
-					usf->conflicting_event_types);
-	usf->conflicting_event_types = 0;
-	for (ind = 0; ind < USF_MAX_EVENT_IND; ++ind) {
-		if (usf->input_ifs[ind] == NULL)
-			continue;
-		input_unregister_device(usf->input_ifs[ind]);
-		usf->input_ifs[ind] = NULL;
-		pr_debug("%s input_unregister_device[%s]\n",
-			 __func__,
-			 s_usf_input_devs[ind].input_dev_name);
-	}
-} /* usf_release_input */
-
-static int usf_stop_tx(struct usf_type *usf)
-{
-	struct usf_xx_type *usf_xx =  &usf->usf_tx;
-
-	usf_release_input(usf);
-	usf_disable(usf_xx);
-
-	return 0;
-} /* usf_stop_tx */
-
-static int __usf_get_version(struct us_version_info_type *version_info)
-{
-	int rc = 0;
-
-	if (version_info->buf_size < sizeof(DRV_VERSION)) {
-		pr_err("%s: buf_size (%d) < version string size (%zu)\n",
-			__func__, version_info->buf_size, sizeof(DRV_VERSION));
-		return -EINVAL;
-	}
-
-	rc = copy_to_user((void __user *)(version_info->pbuf),
-			  DRV_VERSION,
-			  sizeof(DRV_VERSION));
-	if (rc) {
-		pr_err("%s: copy to version_info.pbuf; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* __usf_get_version */
-
-static int usf_get_version(unsigned long arg)
-{
-	struct us_version_info_type version_info;
-
-	int rc = copy_from_user(&version_info,
-				(struct us_version_info_type __user *) arg,
-				sizeof(version_info));
-
-	if (rc) {
-		pr_err("%s: copy version_info from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	rc = __usf_get_version(&version_info);
-	if (rc < 0) {
-		pr_err("%s: get version failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = copy_to_user((void __user *)arg,
-			  &version_info,
-			  sizeof(version_info));
-	if (rc) {
-		pr_err("%s: copy version_info to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_get_version */
-
-static int __usf_set_stream_param(struct usf_xx_type *usf_xx,
-				struct us_stream_param_type *set_stream_param,
-				int dir)
-{
-	struct us_client *usc = usf_xx->usc;
-	struct us_port_data *port;
-	int rc = 0;
-
-	if (usc == NULL) {
-		pr_err("%s: usc is null\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	port = &usc->port[dir];
-	if (port == NULL) {
-		pr_err("%s: port is null\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	if (port->param_buf == NULL) {
-		pr_err("%s: parameter buffer is null\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	if (set_stream_param->buf_size > port->param_buf_size) {
-		pr_err("%s: buf_size (%d) > maximum buf size (%d)\n",
-			__func__, set_stream_param->buf_size,
-			port->param_buf_size);
-		return -EINVAL;
-	}
-
-	if (set_stream_param->buf_size == 0) {
-		pr_err("%s: buf_size is 0\n", __func__);
-		return -EINVAL;
-	}
-
-	rc = copy_from_user(port->param_buf,
-			(uint8_t __user *) set_stream_param->pbuf,
-			set_stream_param->buf_size);
-	if (rc) {
-		pr_err("%s: copy param buf from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	rc = q6usm_set_us_stream_param(dir, usc, set_stream_param->module_id,
-					set_stream_param->param_id,
-					set_stream_param->buf_size);
-	if (rc) {
-		pr_err("%s: q6usm_set_us_stream_param failed; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	return rc;
-}
-
-static int usf_set_stream_param(struct usf_xx_type *usf_xx,
-				unsigned long arg, int dir)
-{
-	struct us_stream_param_type set_stream_param;
-	int rc = 0;
-
-	rc = copy_from_user(&set_stream_param,
-			(struct us_stream_param_type __user *) arg,
-			sizeof(set_stream_param));
-
-	if (rc) {
-		pr_err("%s: copy set_stream_param from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	return __usf_set_stream_param(usf_xx, &set_stream_param, dir);
-} /* usf_set_stream_param */
-
-static int __usf_get_stream_param(struct usf_xx_type *usf_xx,
-				struct us_stream_param_type *get_stream_param,
-				int dir)
-{
-	struct us_client *usc = usf_xx->usc;
-	struct us_port_data *port;
-	int rc = 0;
-
-	if (usc == NULL) {
-		pr_err("%s: us_client is null\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	port = &usc->port[dir];
-
-	if (port->param_buf == NULL) {
-		pr_err("%s: parameter buffer is null\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	if (get_stream_param->buf_size > port->param_buf_size) {
-		pr_err("%s: buf_size (%d) > maximum buf size (%d)\n",
-			__func__, get_stream_param->buf_size,
-			port->param_buf_size);
-		return -EINVAL;
-	}
-
-	if (get_stream_param->buf_size == 0) {
-		pr_err("%s: buf_size is 0\n", __func__);
-		return -EINVAL;
-	}
-
-	rc = q6usm_get_us_stream_param(dir, usc, get_stream_param->module_id,
-					get_stream_param->param_id,
-					get_stream_param->buf_size);
-	if (rc) {
-		pr_err("%s: q6usm_get_us_stream_param failed; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	rc = copy_to_user((uint8_t __user *) get_stream_param->pbuf,
-			port->param_buf,
-			get_stream_param->buf_size);
-	if (rc) {
-		pr_err("%s: copy param buf to user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	return rc;
-}
-
-static int usf_get_stream_param(struct usf_xx_type *usf_xx,
-				unsigned long arg, int dir)
-{
-	struct us_stream_param_type get_stream_param;
-	int rc = 0;
-
-	rc = copy_from_user(&get_stream_param,
-			(struct us_stream_param_type __user *) arg,
-			sizeof(get_stream_param));
-
-	if (rc) {
-		pr_err("%s: copy get_stream_param from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	return __usf_get_stream_param(usf_xx, &get_stream_param, dir);
-} /* usf_get_stream_param */
-
-static long __usf_ioctl(struct usf_type *usf,
-		unsigned int cmd,
-		unsigned long arg)
-{
-
-	int rc = 0;
-	struct usf_xx_type *usf_xx = NULL;
-
-	switch (cmd) {
-	case US_START_TX: {
-		usf_xx = &usf->usf_tx;
-		if (usf_xx->usf_state == USF_CONFIGURED_STATE)
-			rc = usf_start_tx(usf_xx);
-		else {
-			pr_err("%s: start_tx: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			return -EBADFD;
-		}
-		break;
-	}
-
-	case US_START_RX: {
-		usf_xx = &usf->usf_rx;
-		if (usf_xx->usf_state == USF_CONFIGURED_STATE)
-			rc = usf_start_rx(usf_xx);
-		else {
-			pr_err("%s: start_rx: wrong state[%d]\n",
-				__func__,
-				usf_xx->usf_state);
-			return -EBADFD;
-		}
-		break;
-	}
-
-	case US_SET_TX_INFO: {
-		usf_xx = &usf->usf_tx;
-		if (usf_xx->usf_state == USF_OPENED_STATE)
-			rc = usf_set_tx_info(usf, arg);
-		else {
-			pr_err("%s: set_tx_info: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			return -EBADFD;
-		}
-
-		break;
-	} /* US_SET_TX_INFO */
-
-	case US_SET_RX_INFO: {
-		usf_xx = &usf->usf_rx;
-		if (usf_xx->usf_state == USF_OPENED_STATE)
-			rc = usf_set_rx_info(usf, arg);
-		else {
-			pr_err("%s: set_rx_info: wrong state[%d]\n",
-				__func__,
-				usf_xx->usf_state);
-			return -EBADFD;
-		}
-
-		break;
-	} /* US_SET_RX_INFO */
-
-	case US_GET_TX_UPDATE: {
-		struct usf_xx_type *usf_xx = &usf->usf_tx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_get_tx_update(usf, arg);
-		else {
-			pr_err("%s: get_tx_update: wrong state[%d]\n", __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_GET_TX_UPDATE */
-
-	case US_SET_RX_UPDATE: {
-		struct usf_xx_type *usf_xx = &usf->usf_rx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_set_rx_update(usf_xx, arg);
-		else {
-			pr_err("%s: set_rx_update: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_SET_RX_UPDATE */
-
-	case US_STOP_TX: {
-		usf_xx = &usf->usf_tx;
-		if ((usf_xx->usf_state == USF_WORK_STATE)
-			|| (usf_xx->usf_state == USF_ADSP_RESTART_STATE))
-			rc = usf_stop_tx(usf);
-		else {
-			pr_err("%s: stop_tx: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			return -EBADFD;
-		}
-		break;
-	} /* US_STOP_TX */
-
-	case US_STOP_RX: {
-		usf_xx = &usf->usf_rx;
-		if ((usf_xx->usf_state == USF_WORK_STATE)
-			|| (usf_xx->usf_state == USF_ADSP_RESTART_STATE))
-			usf_disable(usf_xx);
-		else {
-			pr_err("%s: stop_rx: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			return -EBADFD;
-		}
-		break;
-	} /* US_STOP_RX */
-
-	case US_SET_DETECTION: {
-		struct usf_xx_type *usf_xx = &usf->usf_tx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_set_us_detection(usf, arg);
-		else {
-			pr_err("%s: set us detection: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_SET_DETECTION */
-
-	case US_GET_VERSION: {
-		rc = usf_get_version(arg);
-		break;
-	} /* US_GET_VERSION */
-
-	case US_SET_TX_STREAM_PARAM: {
-		rc = usf_set_stream_param(&usf->usf_tx, arg, OUT);
-		break;
-	} /* US_SET_TX_STREAM_PARAM */
-
-	case US_GET_TX_STREAM_PARAM: {
-		rc = usf_get_stream_param(&usf->usf_tx, arg, OUT);
-		break;
-	} /* US_GET_TX_STREAM_PARAM */
-
-	case US_SET_RX_STREAM_PARAM: {
-		rc = usf_set_stream_param(&usf->usf_rx, arg, IN);
-		break;
-	} /* US_SET_RX_STREAM_PARAM */
-
-	case US_GET_RX_STREAM_PARAM: {
-		rc = usf_get_stream_param(&usf->usf_rx, arg, IN);
-		break;
-	} /* US_GET_RX_STREAM_PARAM */
-
-	default:
-		pr_err("%s: unsupported IOCTL command [%d]\n",
-		       __func__,
-		       cmd);
-		rc = -ENOTTY;
-		break;
-	}
-
-	if (rc &&
-	    ((cmd == US_SET_TX_INFO) ||
-	     (cmd == US_SET_RX_INFO)))
-		release_xx(usf_xx);
-
-	return rc;
-} /* __usf_ioctl */
-
-static long usf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct usf_type *usf = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&usf->mutex);
-	rc = __usf_ioctl(usf, cmd, arg);
-	mutex_unlock(&usf->mutex);
-
-	return rc;
-} /* usf_ioctl */
-
-#ifdef CONFIG_COMPAT
-
-#define US_SET_TX_INFO32   _IOW(USF_IOCTL_MAGIC, 0, \
-				struct us_tx_info_type32)
-#define US_GET_TX_UPDATE32 _IOWR(USF_IOCTL_MAGIC, 2, \
-				struct us_tx_update_info_type32)
-#define US_SET_RX_INFO32   _IOW(USF_IOCTL_MAGIC, 3, \
-				struct us_rx_info_type32)
-#define US_SET_RX_UPDATE32 _IOWR(USF_IOCTL_MAGIC, 4, \
-				struct us_rx_update_info_type32)
-#define US_SET_DETECTION32 _IOWR(USF_IOCTL_MAGIC, 8, \
-				struct us_detect_info_type32)
-#define US_GET_VERSION32  _IOWR(USF_IOCTL_MAGIC, 9, \
-				struct us_version_info_type32)
-#define US_SET_TX_STREAM_PARAM32   _IOW(USF_IOCTL_MAGIC, 10, \
-				struct us_stream_param_type32)
-#define US_GET_TX_STREAM_PARAM32  _IOWR(USF_IOCTL_MAGIC, 11, \
-				struct us_stream_param_type32)
-#define US_SET_RX_STREAM_PARAM32   _IOW(USF_IOCTL_MAGIC, 12, \
-				struct us_stream_param_type32)
-#define US_GET_RX_STREAM_PARAM32  _IOWR(USF_IOCTL_MAGIC, 13, \
-				struct us_stream_param_type32)
-
-/* Info structure common for TX and RX */
-struct us_xx_info_type32 {
-/* Input:  general info */
-/* Name of the client - event calculator, ptr to char */
-	const compat_uptr_t client_name;
-/* Selected device identification, accepted in the kernel's CAD */
-	uint32_t dev_id;
-/* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
-	uint32_t stream_format;
-/* Required sample rate in Hz */
-	uint32_t sample_rate;
-/* Size of a buffer (bytes) for US data transfer between the module and USF */
-	uint32_t buf_size;
-/* Number of the buffers for the US data transfer */
-	uint16_t buf_num;
-/* Number of the microphones (TX) or speakers(RX) */
-	uint16_t port_cnt;
-/* Microphones(TX) or speakers(RX) indexes in their enumeration */
-	uint8_t  port_id[USF_MAX_PORT_NUM];
-/* Bits per sample 16 or 32 */
-	uint16_t bits_per_sample;
-/* Input:  Transparent info for encoder in the LPASS */
-/* Parameters data size in bytes */
-	uint16_t params_data_size;
-/* Pointer to the parameters, ptr to uint8_t */
-	compat_uptr_t params_data;
-/* Max size of buffer for get and set parameter */
-	uint32_t max_get_set_param_buf_size;
-};
-
-struct us_tx_info_type32 {
-/* Common info. This struct includes ptr and therefore the 32 version */
-	struct us_xx_info_type32 us_xx_info;
-/* Info specific for TX. This struct doesn't include long or ptr
- * and therefore no 32 version
- */
-	struct us_input_info_type input_info;
-};
-
-struct us_tx_update_info_type32 {
-/* Input  general: */
-/* Number of calculated events */
-	uint16_t event_counter;
-/* Calculated events or NULL, ptr to struct usf_event_type */
-	compat_uptr_t event;
-/* Pointer (read index) to the end of available region */
-/* in the shared US data memory */
-	uint32_t free_region;
-/* Time (sec) to wait for data or special values: */
-/* USF_NO_WAIT_TIMEOUT, USF_INFINITIVE_TIMEOUT, USF_DEFAULT_TIMEOUT */
-	uint32_t timeout;
-/* Events (from conflicting devs) to be disabled/enabled */
-	uint16_t event_filters;
-
-/* Input  transparent data: */
-/* Parameters size */
-	uint16_t params_data_size;
-/* Pointer to the parameters, ptr to uint8_t */
-	compat_uptr_t params_data;
-/* Output parameters: */
-/* Pointer (write index) to the end of ready US data region */
-/* in the shared memory */
-	uint32_t ready_region;
-};
-
-struct us_rx_info_type32 {
-	/* Common info */
-	struct us_xx_info_type32 us_xx_info;
-	/* Info specific for RX*/
-};
-
-struct us_rx_update_info_type32 {
-/* Input  general: */
-/* Pointer (write index) to the end of ready US data region */
-/* in the shared memory */
-	uint32_t ready_region;
-/* Input  transparent data: */
-/* Parameters size */
-	uint16_t params_data_size;
-/* pPointer to the parameters, ptr to uint8_t */
-	compat_uptr_t params_data;
-/* Output parameters: */
-/* Pointer (read index) to the end of available region */
-/* in the shared US data memory */
-	uint32_t free_region;
-};
-
-struct us_detect_info_type32 {
-/* US detection place (HW|FW) */
-/* NA in the Active and OFF states */
-	enum us_detect_place_enum us_detector;
-/* US detection mode */
-	enum us_detect_mode_enum  us_detect_mode;
-/* US data dropped during this time (msec) */
-	uint32_t skip_time;
-/* Transparent data size */
-	uint16_t params_data_size;
-/* Pointer to the transparent data, ptr to uint8_t */
-	compat_uptr_t params_data;
-/* Time (sec) to wait for US presence event */
-	uint32_t detect_timeout;
-/* Out parameter: US presence */
-	bool is_us;
-};
-
-struct us_version_info_type32 {
-/* Size of memory for the version string */
-	uint16_t buf_size;
-/* Pointer to the memory for the version string, ptr to char */
-	compat_uptr_t pbuf;
-};
-
-struct us_stream_param_type32 {
-/* Id of module */
-	uint32_t module_id;
-/* Id of parameter */
-	uint32_t param_id;
-/* Size of memory of the parameter buffer */
-	uint32_t buf_size;
-/* Pointer to the memory of the parameter buffer */
-	compat_uptr_t pbuf;
-};
-
-static void usf_compat_xx_info_type(struct us_xx_info_type32 *us_xx_info32,
-				   struct us_xx_info_type *us_xx_info)
-{
-	int i = 0;
-
-	us_xx_info->client_name = compat_ptr(us_xx_info32->client_name);
-	us_xx_info->dev_id = us_xx_info32->dev_id;
-	us_xx_info->stream_format = us_xx_info32->stream_format;
-	us_xx_info->sample_rate = us_xx_info32->sample_rate;
-	us_xx_info->buf_size = us_xx_info32->buf_size;
-	us_xx_info->buf_num = us_xx_info32->buf_num;
-	us_xx_info->port_cnt = us_xx_info32->port_cnt;
-	for (i = 0; i < USF_MAX_PORT_NUM; i++)
-		us_xx_info->port_id[i] = us_xx_info32->port_id[i];
-	us_xx_info->bits_per_sample = us_xx_info32->bits_per_sample;
-	us_xx_info->params_data_size = us_xx_info32->params_data_size;
-	us_xx_info->params_data = compat_ptr(us_xx_info32->params_data);
-	us_xx_info->max_get_set_param_buf_size =
-			    us_xx_info32->max_get_set_param_buf_size;
-}
-
-static int usf_set_tx_info32(struct usf_type *usf, unsigned long arg)
-{
-	struct us_tx_info_type32 config_tx32;
-	struct us_tx_info_type config_tx;
-
-	int rc = copy_from_user(&config_tx32,
-			    (struct us_tx_info_type32 __user *) arg,
-			    sizeof(config_tx32));
-
-	if (rc) {
-		pr_err("%s: copy config_tx from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-	memset(&config_tx, 0, sizeof(config_tx));
-	usf_compat_xx_info_type(&(config_tx32.us_xx_info),
-				&(config_tx.us_xx_info));
-	config_tx.input_info = config_tx32.input_info;
-
-	return __usf_set_tx_info(usf, &config_tx);
-} /* usf_set_tx_info 32*/
-
-static int usf_set_rx_info32(struct usf_type *usf, unsigned long arg)
-{
-	struct us_rx_info_type32 config_rx32;
-	struct us_rx_info_type config_rx;
-
-	int rc = copy_from_user(&config_rx32,
-				(struct us_rx_info_type32 __user *) arg,
-				sizeof(config_rx32));
-
-	if (rc) {
-		pr_err("%s: copy config_rx from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-	memset(&config_rx, 0, sizeof(config_rx));
-	usf_compat_xx_info_type(&(config_rx32.us_xx_info),
-				&(config_rx.us_xx_info));
-
-	return __usf_set_rx_info(usf, &config_rx);
-} /* usf_set_rx_info32 */
-
-static int usf_get_tx_update32(struct usf_type *usf, unsigned long arg)
-{
-	struct us_tx_update_info_type32 upd_tx_info32;
-	struct us_tx_update_info_type upd_tx_info;
-
-	int rc = copy_from_user(&upd_tx_info32,
-				(struct us_tx_update_info_type32 __user *) arg,
-				sizeof(upd_tx_info32));
-
-	if (rc) {
-		pr_err("%s: copy upd_tx_info32 from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	memset(&upd_tx_info, 0, sizeof(upd_tx_info));
-	upd_tx_info.event_counter = upd_tx_info32.event_counter;
-	upd_tx_info.event = compat_ptr(upd_tx_info32.event);
-	upd_tx_info.free_region = upd_tx_info32.free_region;
-	upd_tx_info.timeout = upd_tx_info32.timeout;
-	upd_tx_info.event_filters = upd_tx_info32.event_filters;
-	upd_tx_info.params_data_size = upd_tx_info32.params_data_size;
-	upd_tx_info.params_data = compat_ptr(upd_tx_info32.params_data);
-	upd_tx_info.ready_region = upd_tx_info32.ready_region;
-
-	rc = __usf_get_tx_update(usf, &upd_tx_info);
-	if (rc < 0) {
-		pr_err("%s: get tx update failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	/* Update only the fields that were changed */
-	upd_tx_info32.ready_region = upd_tx_info.ready_region;
-
-	rc = copy_to_user((void __user *)arg, &upd_tx_info32,
-			  sizeof(upd_tx_info32));
-	if (rc) {
-		pr_err("%s: copy upd_tx_info32 to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_get_tx_update */
-
-static int usf_set_rx_update32(struct usf_xx_type *usf_xx, unsigned long arg)
-{
-	struct us_rx_update_info_type32 upd_rx_info32;
-	struct us_rx_update_info_type upd_rx_info;
-
-	int rc = copy_from_user(&upd_rx_info32,
-				(struct us_rx_update_info_type32 __user *) arg,
-				sizeof(upd_rx_info32));
-
-	if (rc) {
-		pr_err("%s: copy upd_rx_info32 from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	memset(&upd_rx_info, 0, sizeof(upd_rx_info));
-	upd_rx_info.ready_region = upd_rx_info32.ready_region;
-	upd_rx_info.params_data_size = upd_rx_info32.params_data_size;
-	upd_rx_info.params_data = compat_ptr(upd_rx_info32.params_data);
-	upd_rx_info.free_region = upd_rx_info32.free_region;
-
-	rc = __usf_set_rx_update(usf_xx, &upd_rx_info);
-	if (rc < 0) {
-		pr_err("%s: set rx update failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	/* Update only the fields that were changed */
-	upd_rx_info32.free_region = upd_rx_info.free_region;
-
-	rc = copy_to_user((void __user *)arg,
-			&upd_rx_info32,
-			sizeof(upd_rx_info32));
-	if (rc) {
-		pr_err("%s: copy rx_info32 to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_set_rx_update32 */
-
-static int usf_set_us_detection32(struct usf_type *usf, unsigned long arg)
-{
-	struct us_detect_info_type32 detect_info32;
-	struct us_detect_info_type detect_info;
-
-	int rc = copy_from_user(&detect_info32,
-				(struct us_detect_info_type32 __user *) arg,
-				sizeof(detect_info32));
-
-	if (rc) {
-		pr_err("%s: copy detect_info32 from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	if (detect_info32.params_data_size > USF_MAX_USER_BUF_SIZE) {
-		pr_err("%s: user buffer size exceeds maximum\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	memset(&detect_info, 0, sizeof(detect_info));
-	detect_info.us_detector = detect_info32.us_detector;
-	detect_info.us_detect_mode = detect_info32.us_detect_mode;
-	detect_info.skip_time = detect_info32.skip_time;
-	detect_info.params_data_size = detect_info32.params_data_size;
-	detect_info.params_data = compat_ptr(detect_info32.params_data);
-	detect_info.detect_timeout = detect_info32.detect_timeout;
-	detect_info.is_us = detect_info32.is_us;
-
-	rc = __usf_set_us_detection(usf, &detect_info);
-	if (rc < 0) {
-		pr_err("%s: set us detection failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	/* Update only the fields that were changed */
-	detect_info32.is_us = detect_info.is_us;
-
-	rc = copy_to_user((void __user *)arg,
-			  &detect_info32,
-			  sizeof(detect_info32));
-	if (rc) {
-		pr_err("%s: copy detect_info32 to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_set_us_detection32 */
-
-static int usf_get_version32(unsigned long arg)
-{
-	struct us_version_info_type32 version_info32;
-	struct us_version_info_type version_info;
-
-	int rc = copy_from_user(&version_info32,
-				(struct us_version_info_type32 __user *) arg,
-				sizeof(version_info32));
-
-	if (rc) {
-		pr_err("%s: copy version_info32 from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	memset(&version_info, 0, sizeof(version_info));
-	version_info.buf_size = version_info32.buf_size;
-	version_info.pbuf = compat_ptr(version_info32.pbuf);
-
-	rc = __usf_get_version(&version_info);
-	if (rc < 0) {
-		pr_err("%s: get version failed; rc=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	/* None of the fields were changed */
-
-	rc = copy_to_user((void __user *)arg,
-			  &version_info32,
-			  sizeof(version_info32));
-	if (rc) {
-		pr_err("%s: copy version_info32 to user; rc=%d\n",
-			__func__, rc);
-		rc = -EFAULT;
-	}
-
-	return rc;
-} /* usf_get_version32 */
-
-static int usf_set_stream_param32(struct usf_xx_type *usf_xx,
-				unsigned long arg, int dir)
-{
-	struct us_stream_param_type32 set_stream_param32;
-	struct us_stream_param_type set_stream_param;
-	int rc = 0;
-
-	rc = copy_from_user(&set_stream_param32,
-			(struct us_stream_param_type32 __user *) arg,
-			sizeof(set_stream_param32));
-
-	if (rc) {
-		pr_err("%s: copy set_stream_param from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	memset(&set_stream_param, 0, sizeof(set_stream_param));
-	set_stream_param.module_id = set_stream_param32.module_id;
-	set_stream_param.param_id = set_stream_param32.param_id;
-	set_stream_param.buf_size = set_stream_param32.buf_size;
-	set_stream_param.pbuf = compat_ptr(set_stream_param32.pbuf);
-
-	return __usf_set_stream_param(usf_xx, &set_stream_param, dir);
-} /* usf_set_stream_param32 */
-
-static int usf_get_stream_param32(struct usf_xx_type *usf_xx,
-				unsigned long arg, int dir)
-{
-	struct us_stream_param_type32 get_stream_param32;
-	struct us_stream_param_type get_stream_param;
-	int rc = 0;
-
-	rc = copy_from_user(&get_stream_param32,
-			(struct us_stream_param_type32 __user *) arg,
-			sizeof(get_stream_param32));
-
-	if (rc) {
-		pr_err("%s: copy get_stream_param from user; rc=%d\n",
-			__func__, rc);
-		return -EFAULT;
-	}
-
-	memset(&get_stream_param, 0, sizeof(get_stream_param));
-	get_stream_param.module_id = get_stream_param32.module_id;
-	get_stream_param.param_id = get_stream_param32.param_id;
-	get_stream_param.buf_size = get_stream_param32.buf_size;
-	get_stream_param.pbuf = compat_ptr(get_stream_param32.pbuf);
-
-	return __usf_get_stream_param(usf_xx, &get_stream_param, dir);
-} /* usf_get_stream_param32 */
-
-static long __usf_compat_ioctl(struct usf_type *usf,
-			     unsigned int cmd,
-			     unsigned long arg)
-{
-	int rc = 0;
-	struct usf_xx_type *usf_xx = NULL;
-
-	switch (cmd) {
-	case US_START_TX:
-	case US_START_RX:
-	case US_STOP_TX:
-	case US_STOP_RX: {
-		return __usf_ioctl(usf, cmd, arg);
-	}
-
-	case US_SET_TX_INFO32: {
-		usf_xx = &usf->usf_tx;
-		if (usf_xx->usf_state == USF_OPENED_STATE)
-			rc = usf_set_tx_info32(usf, arg);
-		else {
-			pr_err("%s: set_tx_info32: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			return -EBADFD;
-		}
-
-		break;
-	} /* US_SET_TX_INFO32 */
-
-	case US_SET_RX_INFO32: {
-		usf_xx = &usf->usf_rx;
-		if (usf_xx->usf_state == USF_OPENED_STATE)
-			rc = usf_set_rx_info32(usf, arg);
-		else {
-			pr_err("%s: set_rx_info32: wrong state[%d]\n",
-				__func__,
-				usf_xx->usf_state);
-			return -EBADFD;
-		}
-
-		break;
-	} /* US_SET_RX_INFO32 */
-
-	case US_GET_TX_UPDATE32: {
-		struct usf_xx_type *usf_xx = &usf->usf_tx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_get_tx_update32(usf, arg);
-		else {
-			pr_err("%s: get_tx_update32: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_GET_TX_UPDATE32 */
-
-	case US_SET_RX_UPDATE32: {
-		struct usf_xx_type *usf_xx = &usf->usf_rx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_set_rx_update32(usf_xx, arg);
-		else {
-			pr_err("%s: set_rx_update: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_SET_RX_UPDATE32 */
-
-	case US_SET_DETECTION32: {
-		struct usf_xx_type *usf_xx = &usf->usf_tx;
-
-		if (usf_xx->usf_state == USF_WORK_STATE)
-			rc = usf_set_us_detection32(usf, arg);
-		else {
-			pr_err("%s: set us detection: wrong state[%d]\n",
-			       __func__,
-			       usf_xx->usf_state);
-			rc = -EBADFD;
-		}
-		break;
-	} /* US_SET_DETECTION32 */
-
-	case US_GET_VERSION32: {
-		rc = usf_get_version32(arg);
-		break;
-	} /* US_GET_VERSION32 */
-
-	case US_SET_TX_STREAM_PARAM32: {
-		rc = usf_set_stream_param32(&usf->usf_tx, arg, OUT);
-		break;
-	} /* US_SET_TX_STREAM_PARAM32 */
-
-	case US_GET_TX_STREAM_PARAM32: {
-		rc = usf_get_stream_param32(&usf->usf_tx, arg, OUT);
-		break;
-	} /* US_GET_TX_STREAM_PARAM32 */
-
-	case US_SET_RX_STREAM_PARAM32: {
-		rc = usf_set_stream_param32(&usf->usf_rx, arg, IN);
-		break;
-	} /* US_SET_RX_STREAM_PARAM32 */
-
-	case US_GET_RX_STREAM_PARAM32: {
-		rc = usf_get_stream_param32(&usf->usf_rx, arg, IN);
-		break;
-	} /* US_GET_RX_STREAM_PARAM32 */
-
-	default:
-		pr_err("%s: unsupported IOCTL command [%d]\n",
-		       __func__,
-		       cmd);
-		rc = -ENOTTY;
-		break;
-	}
-
-	if (rc &&
-	    ((cmd == US_SET_TX_INFO) ||
-	     (cmd == US_SET_RX_INFO)))
-		release_xx(usf_xx);
-
-	return rc;
-} /* __usf_compat_ioctl */
-
-static long usf_compat_ioctl(struct file *file,
-			     unsigned int cmd,
-			     unsigned long arg)
-{
-	struct usf_type *usf = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&usf->mutex);
-	rc = __usf_compat_ioctl(usf, cmd, arg);
-	mutex_unlock(&usf->mutex);
-
-	return rc;
-} /* usf_compat_ioctl */
-#endif /* CONFIG_COMPAT */
-
-static int usf_mmap(struct file *file, struct vm_area_struct *vms)
-{
-	struct usf_type *usf = file->private_data;
-	int dir = OUT;
-	struct usf_xx_type *usf_xx = &usf->usf_tx;
-	int rc = 0;
-
-	mutex_lock(&usf->mutex);
-	if (vms->vm_flags & USF_VM_WRITE) { /* RX buf mapping */
-		dir = IN;
-		usf_xx = &usf->usf_rx;
-	}
-	rc = q6usm_get_virtual_address(dir, usf_xx->usc, vms);
-	mutex_unlock(&usf->mutex);
-
-	return rc;
-}
-
-static uint16_t add_opened_dev(int minor)
-{
-	uint16_t ind = 0;
-
-	for (ind = 0; ind < MAX_DEVS_NUMBER; ++ind) {
-		if (minor == atomic_cmpxchg(&s_opened_devs[ind], 0, minor)) {
-			pr_err("%s: device %d is already opened\n",
-			       __func__, minor);
-			return USF_UNDEF_DEV_ID;
-		} else {
-			pr_debug("%s: device %d is added; ind=%d\n",
-				__func__, minor, ind);
-			return ind;
-		}
-	}
-
-	pr_err("%s: there is no place for device %d\n",
-	       __func__, minor);
-	return USF_UNDEF_DEV_ID;
-}
-
-static int usf_open(struct inode *inode, struct file *file)
-{
-	struct usf_type *usf =  NULL;
-	uint16_t dev_ind = 0;
-	int minor = MINOR(inode->i_rdev);
-
-	dev_ind = add_opened_dev(minor);
-	if (dev_ind == USF_UNDEF_DEV_ID)
-		return -EBUSY;
-
-	usf = kzalloc(sizeof(struct usf_type), GFP_KERNEL);
-	if (usf == NULL)
-		return -ENOMEM;
-
-	wakeup_source_init(&usf_wakeup_source, "usf");
-
-	file->private_data = usf;
-	usf->dev_ind = dev_ind;
-
-	usf->usf_tx.usf_state = USF_OPENED_STATE;
-	usf->usf_rx.usf_state = USF_OPENED_STATE;
-
-	usf->usf_tx.us_detect_type = USF_US_DETECT_UNDEF;
-	usf->usf_rx.us_detect_type = USF_US_DETECT_UNDEF;
-
-	mutex_init(&usf->mutex);
-
-	pr_debug("%s:usf in open\n", __func__);
-	return 0;
-}
-
-static int usf_release(struct inode *inode, struct file *file)
-{
-	struct usf_type *usf = file->private_data;
-
-	pr_debug("%s: release entry\n", __func__);
-
-	mutex_lock(&usf->mutex);
-	usf_release_input(usf);
-
-	usf_disable(&usf->usf_tx);
-	usf_disable(&usf->usf_rx);
-
-	atomic_set(&s_opened_devs[usf->dev_ind], 0);
-
-	wakeup_source_trash(&usf_wakeup_source);
-	mutex_unlock(&usf->mutex);
-	mutex_destroy(&usf->mutex);
-	kfree(usf);
-	pr_debug("%s: release exit\n", __func__);
-	return 0;
-}
-
-extern long usf_compat_ioctl(struct file *file,
-			     unsigned int cmd,
-			     unsigned long arg);
-
-static const struct file_operations usf_fops = {
-	.owner                  = THIS_MODULE,
-	.open                   = usf_open,
-	.release                = usf_release,
-	.unlocked_ioctl = usf_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl = usf_compat_ioctl,
-#endif /* CONFIG_COMPAT */
-	.mmap                   = usf_mmap,
-};
-
-static struct miscdevice usf_misc[MAX_DEVS_NUMBER] = {
-	{
-		.minor  = MISC_DYNAMIC_MINOR,
-		.name   = "usf1",
-		.fops   = &usf_fops,
-	},
-};
-
-static int __init usf_init(void)
-{
-	int rc = 0;
-	uint16_t ind = 0;
-
-	pr_debug("%s: USF SW version %s.\n", __func__, DRV_VERSION);
-	pr_debug("%s: Max %d devs registration\n", __func__, MAX_DEVS_NUMBER);
-
-	for (ind = 0; ind < MAX_DEVS_NUMBER; ++ind) {
-		rc = misc_register(&usf_misc[ind]);
-		if (rc) {
-			pr_err("%s: misc_register() failed ind=%d; rc = %d\n",
-			       __func__, ind, rc);
-			break;
-		}
-	}
-
-	return rc;
-}
-
-device_initcall(usf_init);
-
-MODULE_DESCRIPTION("Ultrasound framework driver");
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.c b/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.c
deleted file mode 100644
index 6b8aae0..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/* Copyright (c) 2012-2013, 2016-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input/mt.h>
-#include <linux/syscalls.h>
-#include "usfcdev.h"
-
-#define UNDEF_ID    0xffffffff
-#define SLOT_CMD_ID 0
-#define MAX_RETRIES 10
-
-enum usdev_event_status {
-	USFCDEV_EVENT_ENABLED,
-	USFCDEV_EVENT_DISABLING,
-	USFCDEV_EVENT_DISABLED,
-};
-
-struct usfcdev_event {
-	bool (*match_cb)(uint16_t, struct input_dev *dev);
-	bool registered_event;
-	bool interleaved;
-	enum usdev_event_status event_status;
-};
-static struct usfcdev_event s_usfcdev_events[MAX_EVENT_TYPE_NUM];
-
-struct usfcdev_input_command {
-	unsigned int type;
-	unsigned int code;
-	unsigned int value;
-};
-
-static long  s_usf_pid;
-
-static bool usfcdev_filter(struct input_handle *handle,
-			 unsigned int type, unsigned int code, int value);
-static bool usfcdev_match(struct input_handler *handler,
-				struct input_dev *dev);
-static int usfcdev_connect(struct input_handler *handler,
-				struct input_dev *dev,
-				const struct input_device_id *id);
-static void usfcdev_disconnect(struct input_handle *handle);
-
-static const struct input_device_id usfc_tsc_ids[] = {
-	{
-		.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
-			INPUT_DEVICE_ID_MATCH_KEYBIT |
-			INPUT_DEVICE_ID_MATCH_ABSBIT,
-		.evbit = { BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY) },
-		.keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
-		/* assumption: ABS_X & ABS_Y are in the same long */
-		.absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) |
-						BIT_MASK(ABS_Y) },
-	},
-	{
-		.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
-			INPUT_DEVICE_ID_MATCH_KEYBIT |
-			INPUT_DEVICE_ID_MATCH_ABSBIT,
-		.evbit = { BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY) },
-		.keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
-		/* assumption: MT_.._X & MT_.._Y are in the same long */
-		.absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
-			BIT_MASK(ABS_MT_POSITION_X) |
-			BIT_MASK(ABS_MT_POSITION_Y) },
-	},
-	{ } /* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(input, usfc_tsc_ids);
-
-static struct input_handler s_usfc_handlers[MAX_EVENT_TYPE_NUM] = {
-	{ /* TSC handler */
-		.filter         = usfcdev_filter,
-		.match          = usfcdev_match,
-		.connect        = usfcdev_connect,
-		.disconnect     = usfcdev_disconnect,
-		/* .minor can be used as index in the container, */
-		/*  because .fops isn't supported */
-		.minor          = TSC_EVENT_TYPE_IND,
-		.name           = "usfc_tsc_handler",
-		.id_table       = usfc_tsc_ids,
-	},
-};
-
-/*
- * For each event type, there are a number conflicting devices (handles)
- * The first registered device (primary) is real TSC device; it's mandatory
- * Optionally, later registered devices are simulated ones.
- * They are dynamically managed
- * The primary device's handles are stored in the below static array
- */
-static struct input_handle s_usfc_primary_handles[MAX_EVENT_TYPE_NUM] = {
-	{ /* TSC handle */
-		.handler	= &s_usfc_handlers[TSC_EVENT_TYPE_IND],
-		.name		= "usfc_tsc_handle",
-	},
-};
-
-static struct usfcdev_input_command initial_clear_cmds[] = {
-	{EV_ABS, ABS_PRESSURE,               0},
-	{EV_KEY, BTN_TOUCH,                  0},
-};
-
-static struct usfcdev_input_command slot_clear_cmds[] = {
-	{EV_ABS, ABS_MT_SLOT,               0},
-	{EV_ABS, ABS_MT_TRACKING_ID, UNDEF_ID},
-};
-
-static struct usfcdev_input_command no_filter_cmds[] = {
-	{EV_ABS, ABS_MT_SLOT,               0},
-	{EV_ABS, ABS_MT_TRACKING_ID, UNDEF_ID},
-	{EV_SYN, SYN_REPORT,                0},
-};
-
-static bool usfcdev_match(struct input_handler *handler, struct input_dev *dev)
-{
-	bool rc = false;
-	int ind = handler->minor;
-
-	pr_debug("%s: name=[%s]; ind=%d\n", __func__, dev->name, ind);
-
-	if (s_usfcdev_events[ind].registered_event &&
-		s_usfcdev_events[ind].match_cb) {
-		rc = (*s_usfcdev_events[ind].match_cb)((uint16_t)ind, dev);
-		pr_debug("%s: [%s]; rc=%d\n", __func__, dev->name, rc);
-	}
-	return rc;
-}
-
-static int usfcdev_connect(struct input_handler *handler, struct input_dev *dev,
-				const struct input_device_id *id)
-{
-	int ret = 0;
-	uint16_t ind = handler->minor;
-	struct input_handle *usfc_handle = NULL;
-
-	if (s_usfc_primary_handles[ind].dev == NULL) {
-		pr_debug("%s: primary device; ind=%d\n",
-			__func__,
-			ind);
-		usfc_handle = &s_usfc_primary_handles[ind];
-	} else {
-		pr_debug("%s: secondary device; ind=%d\n",
-			__func__,
-			ind);
-		usfc_handle = kzalloc(sizeof(struct input_handle),
-					GFP_KERNEL);
-		if (!usfc_handle)
-			return -ENOMEM;
-
-		usfc_handle->handler = &s_usfc_handlers[ind];
-		usfc_handle->name = s_usfc_primary_handles[ind].name;
-	}
-	usfc_handle->dev = dev;
-	ret = input_register_handle(usfc_handle);
-	pr_debug("%s: name=[%s]; ind=%d; dev=0x%pK\n",
-		 __func__,
-		dev->name,
-		ind,
-		usfc_handle->dev);
-	if (ret)
-		pr_err("%s: input_register_handle[%d] failed: ret=%d\n",
-			__func__,
-			ind,
-			ret);
-	else {
-		ret = input_open_device(usfc_handle);
-		if (ret) {
-			pr_err("%s: input_open_device[%d] failed: ret=%d\n",
-				__func__,
-				ind,
-				ret);
-			input_unregister_handle(usfc_handle);
-		} else
-			pr_debug("%s: device[%d] is opened\n",
-				__func__,
-				ind);
-	}
-
-	return ret;
-}
-
-static void usfcdev_disconnect(struct input_handle *handle)
-{
-	int ind = handle->handler->minor;
-
-	input_close_device(handle);
-	input_unregister_handle(handle);
-	pr_debug("%s: handle[%d], name=[%s] is disconnected\n",
-		__func__,
-		ind,
-		handle->dev->name);
-	if (s_usfc_primary_handles[ind].dev == handle->dev)
-		s_usfc_primary_handles[ind].dev = NULL;
-	else
-		kfree(handle);
-}
-
-static bool usfcdev_filter(struct input_handle *handle,
-			unsigned int type, unsigned int code, int value)
-{
-	uint16_t i = 0;
-	uint16_t ind = (uint16_t)handle->handler->minor;
-	bool rc = (s_usfcdev_events[ind].event_status != USFCDEV_EVENT_ENABLED);
-
-	if (s_usf_pid == sys_getpid()) {
-		/* Pass events from usfcdev driver */
-		rc = false;
-		pr_debug("%s: event_type=%d; type=%d; code=%d; val=%d",
-			__func__,
-			ind,
-			type,
-			code,
-			value);
-	} else if (s_usfcdev_events[ind].event_status ==
-						USFCDEV_EVENT_DISABLING) {
-		uint32_t u_value = value;
-
-		s_usfcdev_events[ind].interleaved = true;
-		/* Pass events for freeing slots from TSC driver */
-		for (i = 0; i < ARRAY_SIZE(no_filter_cmds); ++i) {
-			if ((no_filter_cmds[i].type == type) &&
-			    (no_filter_cmds[i].code == code) &&
-			    (no_filter_cmds[i].value <= u_value)) {
-				rc = false;
-				pr_debug("%s: no_filter_cmds[%d]; %d",
-					__func__,
-					i,
-					no_filter_cmds[i].value);
-				break;
-			}
-		}
-	}
-
-	return rc;
-}
-
-bool usfcdev_register(
-	uint16_t event_type_ind,
-	bool (*match_cb)(uint16_t, struct input_dev *dev))
-{
-	int ret = 0;
-	bool rc = false;
-
-	if ((event_type_ind >= MAX_EVENT_TYPE_NUM) || !match_cb) {
-		pr_err("%s: wrong input: event_type_ind=%d; match_cb=0x%pK\n",
-			__func__,
-			event_type_ind,
-			match_cb);
-		return false;
-	}
-
-	if (s_usfcdev_events[event_type_ind].registered_event) {
-		pr_info("%s: handler[%d] was already registered\n",
-			__func__,
-			event_type_ind);
-		return true;
-	}
-
-	s_usfcdev_events[event_type_ind].registered_event = true;
-	s_usfcdev_events[event_type_ind].match_cb = match_cb;
-	s_usfcdev_events[event_type_ind].event_status = USFCDEV_EVENT_ENABLED;
-	ret = input_register_handler(&s_usfc_handlers[event_type_ind]);
-	if (!ret) {
-		rc = true;
-		pr_debug("%s: handler[%d] was registered\n",
-			__func__,
-			event_type_ind);
-	} else {
-		s_usfcdev_events[event_type_ind].registered_event = false;
-		s_usfcdev_events[event_type_ind].match_cb = NULL;
-		pr_err("%s: handler[%d] registration failed: ret=%d\n",
-			__func__,
-			event_type_ind,
-			ret);
-	}
-
-	return rc;
-}
-
-void usfcdev_unregister(uint16_t event_type_ind)
-{
-	if (event_type_ind >= MAX_EVENT_TYPE_NUM) {
-		pr_err("%s: wrong input: event_type_ind=%d\n",
-			__func__,
-			event_type_ind);
-		return;
-	}
-	if (s_usfcdev_events[event_type_ind].registered_event) {
-		input_unregister_handler(&s_usfc_handlers[event_type_ind]);
-		pr_debug("%s: handler[%d] was unregistered\n",
-			__func__,
-			event_type_ind);
-		s_usfcdev_events[event_type_ind].registered_event = false;
-		s_usfcdev_events[event_type_ind].match_cb = NULL;
-		s_usfcdev_events[event_type_ind].event_status =
-							USFCDEV_EVENT_ENABLED;
-
-	}
-}
-
-static inline void usfcdev_send_cmd(
-	struct input_dev *dev,
-	struct usfcdev_input_command cmd)
-{
-	input_event(dev, cmd.type, cmd.code, cmd.value);
-}
-
-static void usfcdev_clean_dev(uint16_t event_type_ind)
-{
-	struct input_dev *dev = NULL;
-	int i;
-	int j;
-	int retries = 0;
-
-	if (event_type_ind >= MAX_EVENT_TYPE_NUM) {
-		pr_err("%s: wrong input: event_type_ind=%d\n",
-			__func__,
-			event_type_ind);
-		return;
-	}
-	/* Only primary device must exist */
-	dev = s_usfc_primary_handles[event_type_ind].dev;
-	if (dev == NULL) {
-		pr_err("%s: NULL primary device\n",
-		__func__);
-		return;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(initial_clear_cmds); i++)
-		usfcdev_send_cmd(dev, initial_clear_cmds[i]);
-	input_sync(dev);
-
-	/* Send commands to free all slots */
-	for (i = 0; i < dev->mt->num_slots; i++) {
-		s_usfcdev_events[event_type_ind].interleaved = false;
-		if (input_mt_get_value(&dev->mt->slots[i],
-					ABS_MT_TRACKING_ID) < 0) {
-			pr_debug("%s: skipping slot %d",
-				__func__, i);
-			continue;
-		}
-		slot_clear_cmds[SLOT_CMD_ID].value = i;
-		for (j = 0; j < ARRAY_SIZE(slot_clear_cmds); j++)
-			usfcdev_send_cmd(dev, slot_clear_cmds[j]);
-
-		if (s_usfcdev_events[event_type_ind].interleaved) {
-			pr_debug("%s: interleaved(%d): slot(%d)",
-				__func__, i, dev->mt->slot);
-			if (retries++ < MAX_RETRIES) {
-				--i;
-				continue;
-			}
-			pr_warn("%s: index(%d) reached max retires",
-				__func__, i);
-		}
-
-		retries = 0;
-		input_sync(dev);
-	}
-}
-
-bool usfcdev_set_filter(uint16_t event_type_ind, bool filter)
-{
-	bool rc = true;
-
-	if (event_type_ind >= MAX_EVENT_TYPE_NUM) {
-		pr_err("%s: wrong input: event_type_ind=%d\n",
-			__func__,
-			event_type_ind);
-		return false;
-	}
-
-	if (s_usfcdev_events[event_type_ind].registered_event) {
-
-		pr_debug("%s: event_type[%d]; filter=%d\n",
-			__func__,
-			event_type_ind,
-			filter
-			);
-		if (filter) {
-			s_usfcdev_events[event_type_ind].event_status =
-						USFCDEV_EVENT_DISABLING;
-			s_usf_pid = sys_getpid();
-			usfcdev_clean_dev(event_type_ind);
-			s_usfcdev_events[event_type_ind].event_status =
-						USFCDEV_EVENT_DISABLED;
-		} else
-			s_usfcdev_events[event_type_ind].event_status =
-						USFCDEV_EVENT_ENABLED;
-	} else {
-		pr_err("%s: event_type[%d] isn't registered\n",
-			__func__,
-			event_type_ind);
-		rc = false;
-	}
-
-	return rc;
-}
-
-static int __init usfcdev_init(void)
-{
-	return 0;
-}
-
-device_initcall(usfcdev_init);
-
-MODULE_DESCRIPTION("Handle of events from devices, conflicting with USF");
diff --git a/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.h b/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.h
deleted file mode 100644
index 03b62c5..0000000
--- a/drivers/misc/qcom/qdsp6v2/ultrasound/usfcdev.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __USFCDEV_H__
-#define __USFCDEV_H__
-
-#include <linux/input.h>
-
-/* TSC event type index in the containers of the handlers & handles */
-#define TSC_EVENT_TYPE_IND 0
-/* Number of supported event types to be filtered */
-#define MAX_EVENT_TYPE_NUM 1
-
-bool usfcdev_register(
-	uint16_t event_type_ind,
-	bool (*match_cb)(uint16_t, struct input_dev *dev));
-void usfcdev_unregister(uint16_t event_type_ind);
-bool usfcdev_set_filter(uint16_t event_type_ind, bool filter);
-#endif /* __USFCDEV_H__ */
diff --git a/drivers/misc/qpnp-misc.c b/drivers/misc/qpnp-misc.c
index 3c11de0..690b28b 100644
--- a/drivers/misc/qpnp-misc.c
+++ b/drivers/misc/qpnp-misc.c
@@ -135,7 +135,7 @@
 	struct qpnp_misc_dev *mdev = NULL;
 	struct qpnp_misc_dev *mdev_found = NULL;
 	int rc;
-	u8 temp;
+	u8 temp = 0;
 
 	if (IS_ERR_OR_NULL(node)) {
 		pr_err("Invalid device node pointer\n");
diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c
index 7077b30..7567f86 100644
--- a/drivers/misc/qseecom.c
+++ b/drivers/misc/qseecom.c
@@ -3126,6 +3126,7 @@
 				struct qseecom_send_cmd_req *req)
 {
 	int ret = 0;
+	int ret2 = 0;
 	u32 reqd_len_sb_in = 0;
 	struct qseecom_client_send_data_ireq send_data_req = {0};
 	struct qseecom_client_send_data_64bit_ireq send_data_req_64bit = {0};
@@ -3224,32 +3225,38 @@
 	if (ret) {
 		pr_err("scm_call() failed with err: %d (app_id = %d)\n",
 					ret, data->client.app_id);
-		return ret;
+		goto exit;
 	}
 
 	if (qseecom.qsee_reentrancy_support) {
 		ret = __qseecom_process_reentrancy(&resp, ptr_app, data);
+		if (ret)
+			goto exit;
 	} else {
 		if (resp.result == QSEOS_RESULT_INCOMPLETE) {
 			ret = __qseecom_process_incomplete_cmd(data, &resp);
 			if (ret) {
 				pr_err("process_incomplete_cmd failed err: %d\n",
 						ret);
-				return ret;
+				goto exit;
 			}
 		} else {
 			if (resp.result != QSEOS_RESULT_SUCCESS) {
 				pr_err("Response result %d not supported\n",
 								resp.result);
 				ret = -EINVAL;
+				goto exit;
 			}
 		}
 	}
-	ret = msm_ion_do_cache_op(qseecom.ion_clnt, data->client.ihandle,
+exit:
+	ret2 = msm_ion_do_cache_op(qseecom.ion_clnt, data->client.ihandle,
 				data->client.sb_virt, data->client.sb_length,
 				ION_IOC_INV_CACHES);
-	if (ret)
-		pr_err("cache operation failed %d\n", ret);
+	if (ret2) {
+		pr_err("cache operation failed %d\n", ret2);
+		return ret2;
+	}
 	return ret;
 }
 
@@ -6575,6 +6582,7 @@
 	bool found_app = false;
 	unsigned long flags;
 	int ret = 0;
+	int ret2 = 0;
 	uint32_t reqd_len_sb_in = 0;
 	void *cmd_buf = NULL;
 	size_t cmd_len;
@@ -6684,43 +6692,47 @@
 	if (ret) {
 		pr_err("scm_call() failed with err: %d (app_id = %d)\n",
 					ret, data->client.app_id);
-		return ret;
+		goto exit;
 	}
 
 	if (qseecom.qsee_reentrancy_support) {
 		ret = __qseecom_process_reentrancy(&resp, ptr_app, data);
+		if (ret)
+			goto exit;
 	} else {
 		if (resp.result == QSEOS_RESULT_INCOMPLETE) {
 			ret = __qseecom_process_incomplete_cmd(data, &resp);
 			if (ret) {
 				pr_err("process_incomplete_cmd failed err: %d\n",
 						ret);
-				return ret;
+				goto exit;
 			}
 		} else {
 			if (resp.result != QSEOS_RESULT_SUCCESS) {
 				pr_err("Response result %d not supported\n",
 								resp.result);
 				ret = -EINVAL;
+				goto exit;
 			}
 		}
 	}
-	ret = msm_ion_do_cache_op(qseecom.ion_clnt, data->client.ihandle,
+exit:
+	ret2 = msm_ion_do_cache_op(qseecom.ion_clnt, data->client.ihandle,
 				data->client.sb_virt, data->client.sb_length,
 				ION_IOC_INV_CACHES);
-	if (ret) {
+	if (ret2) {
 		pr_err("cache operation failed %d\n", ret);
-		return ret;
+		return ret2;
 	}
 
 	if ((cmd_id == QSEOS_TEE_OPEN_SESSION) ||
 			(cmd_id == QSEOS_TEE_REQUEST_CANCELLATION)) {
-		ret = __qseecom_update_qteec_req_buf(
+		ret2 = __qseecom_update_qteec_req_buf(
 			(struct qseecom_qteec_modfd_req *)req, data, true);
-		if (ret)
-			return ret;
+		if (ret2)
+			return ret2;
 	}
-	return 0;
+	return ret;
 }
 
 static int qseecom_qteec_open_session(struct qseecom_dev_handle *data,
diff --git a/drivers/misc/uid_sys_stats.c b/drivers/misc/uid_sys_stats.c
index 8bf4c57..7d69dd5 100644
--- a/drivers/misc/uid_sys_stats.c
+++ b/drivers/misc/uid_sys_stats.c
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/profile.h>
 #include <linux/rtmutex.h>
@@ -53,6 +54,15 @@
 #define UID_STATE_DEAD_TASKS	4
 #define UID_STATE_SIZE		5
 
+#define MAX_TASK_COMM_LEN 256
+
+struct task_entry {
+	char comm[MAX_TASK_COMM_LEN];
+	pid_t pid;
+	struct io_stats io[UID_STATE_SIZE];
+	struct hlist_node hash;
+};
+
 struct uid_entry {
 	uid_t uid;
 	cputime_t utime;
@@ -62,8 +72,231 @@
 	int state;
 	struct io_stats io[UID_STATE_SIZE];
 	struct hlist_node hash;
+#ifdef CONFIG_UID_SYS_STATS_DEBUG
+	DECLARE_HASHTABLE(task_entries, UID_HASH_BITS);
+#endif
 };
 
+static u64 compute_write_bytes(struct task_struct *task)
+{
+	if (task->ioac.write_bytes <= task->ioac.cancelled_write_bytes)
+		return 0;
+
+	return task->ioac.write_bytes - task->ioac.cancelled_write_bytes;
+}
+
+static void compute_io_bucket_stats(struct io_stats *io_bucket,
+					struct io_stats *io_curr,
+					struct io_stats *io_last,
+					struct io_stats *io_dead)
+{
+	/* tasks could switch to another uid group, but its io_last in the
+	 * previous uid group could still be positive.
+	 * therefore before each update, do an overflow check first
+	 */
+	int64_t delta;
+
+	delta = io_curr->read_bytes + io_dead->read_bytes -
+		io_last->read_bytes;
+	io_bucket->read_bytes += delta > 0 ? delta : 0;
+	delta = io_curr->write_bytes + io_dead->write_bytes -
+		io_last->write_bytes;
+	io_bucket->write_bytes += delta > 0 ? delta : 0;
+	delta = io_curr->rchar + io_dead->rchar - io_last->rchar;
+	io_bucket->rchar += delta > 0 ? delta : 0;
+	delta = io_curr->wchar + io_dead->wchar - io_last->wchar;
+	io_bucket->wchar += delta > 0 ? delta : 0;
+	delta = io_curr->fsync + io_dead->fsync - io_last->fsync;
+	io_bucket->fsync += delta > 0 ? delta : 0;
+
+	io_last->read_bytes = io_curr->read_bytes;
+	io_last->write_bytes = io_curr->write_bytes;
+	io_last->rchar = io_curr->rchar;
+	io_last->wchar = io_curr->wchar;
+	io_last->fsync = io_curr->fsync;
+
+	memset(io_dead, 0, sizeof(struct io_stats));
+}
+
+#ifdef CONFIG_UID_SYS_STATS_DEBUG
+static void get_full_task_comm(struct task_entry *task_entry,
+		struct task_struct *task)
+{
+	int i = 0, offset = 0, len = 0;
+	/* save one byte for terminating null character */
+	int unused_len = MAX_TASK_COMM_LEN - TASK_COMM_LEN - 1;
+	char buf[unused_len];
+	struct mm_struct *mm = task->mm;
+
+	/* fill the first TASK_COMM_LEN bytes with thread name */
+	get_task_comm(task_entry->comm, task);
+	i = strlen(task_entry->comm);
+	while (i < TASK_COMM_LEN)
+		task_entry->comm[i++] = ' ';
+
+	/* next the executable file name */
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file) {
+			char *pathname = d_path(&mm->exe_file->f_path, buf,
+					unused_len);
+
+			if (!IS_ERR(pathname)) {
+				len = strlcpy(task_entry->comm + i, pathname,
+						unused_len);
+				i += len;
+				task_entry->comm[i++] = ' ';
+				unused_len--;
+			}
+		}
+		up_read(&mm->mmap_sem);
+	}
+	unused_len -= len;
+
+	/* fill the rest with command line argument
+	 * replace each null or new line character
+	 * between args in argv with whitespace */
+	len = get_cmdline(task, buf, unused_len);
+	while (offset < len) {
+		if (buf[offset] != '\0' && buf[offset] != '\n')
+			task_entry->comm[i++] = buf[offset];
+		else
+			task_entry->comm[i++] = ' ';
+		offset++;
+	}
+
+	/* get rid of trailing whitespaces in case when arg is memset to
+	 * zero before being reset in userspace
+	 */
+	while (task_entry->comm[i-1] == ' ')
+		i--;
+	task_entry->comm[i] = '\0';
+}
+
+static struct task_entry *find_task_entry(struct uid_entry *uid_entry,
+		struct task_struct *task)
+{
+	struct task_entry *task_entry;
+
+	hash_for_each_possible(uid_entry->task_entries, task_entry, hash,
+			task->pid) {
+		if (task->pid == task_entry->pid) {
+			/* if thread name changed, update the entire command */
+			int len = strnchr(task_entry->comm, ' ', TASK_COMM_LEN)
+				- task_entry->comm;
+
+			if (strncmp(task_entry->comm, task->comm, len))
+				get_full_task_comm(task_entry, task);
+			return task_entry;
+		}
+	}
+	return NULL;
+}
+
+static struct task_entry *find_or_register_task(struct uid_entry *uid_entry,
+		struct task_struct *task)
+{
+	struct task_entry *task_entry;
+	pid_t pid = task->pid;
+
+	task_entry = find_task_entry(uid_entry, task);
+	if (task_entry)
+		return task_entry;
+
+	task_entry = kzalloc(sizeof(struct task_entry), GFP_ATOMIC);
+	if (!task_entry)
+		return NULL;
+
+	get_full_task_comm(task_entry, task);
+
+	task_entry->pid = pid;
+	hash_add(uid_entry->task_entries, &task_entry->hash, (unsigned int)pid);
+
+	return task_entry;
+}
+
+static void remove_uid_tasks(struct uid_entry *uid_entry)
+{
+	struct task_entry *task_entry;
+	unsigned long bkt_task;
+	struct hlist_node *tmp_task;
+
+	hash_for_each_safe(uid_entry->task_entries, bkt_task,
+			tmp_task, task_entry, hash) {
+		hash_del(&task_entry->hash);
+		kfree(task_entry);
+	}
+}
+
+static void set_io_uid_tasks_zero(struct uid_entry *uid_entry)
+{
+	struct task_entry *task_entry;
+	unsigned long bkt_task;
+
+	hash_for_each(uid_entry->task_entries, bkt_task, task_entry, hash) {
+		memset(&task_entry->io[UID_STATE_TOTAL_CURR], 0,
+			sizeof(struct io_stats));
+	}
+}
+
+static void add_uid_tasks_io_stats(struct uid_entry *uid_entry,
+		struct task_struct *task, int slot)
+{
+	struct task_entry *task_entry = find_or_register_task(uid_entry, task);
+	struct io_stats *task_io_slot = &task_entry->io[slot];
+
+	task_io_slot->read_bytes += task->ioac.read_bytes;
+	task_io_slot->write_bytes += compute_write_bytes(task);
+	task_io_slot->rchar += task->ioac.rchar;
+	task_io_slot->wchar += task->ioac.wchar;
+	task_io_slot->fsync += task->ioac.syscfs;
+}
+
+static void compute_io_uid_tasks(struct uid_entry *uid_entry)
+{
+	struct task_entry *task_entry;
+	unsigned long bkt_task;
+
+	hash_for_each(uid_entry->task_entries, bkt_task, task_entry, hash) {
+		compute_io_bucket_stats(&task_entry->io[uid_entry->state],
+					&task_entry->io[UID_STATE_TOTAL_CURR],
+					&task_entry->io[UID_STATE_TOTAL_LAST],
+					&task_entry->io[UID_STATE_DEAD_TASKS]);
+	}
+}
+
+static void show_io_uid_tasks(struct seq_file *m, struct uid_entry *uid_entry)
+{
+	struct task_entry *task_entry;
+	unsigned long bkt_task;
+
+	hash_for_each(uid_entry->task_entries, bkt_task, task_entry, hash) {
+		/* Separated by comma because space exists in task comm */
+		seq_printf(m, "task,%s,%lu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu\n",
+				task_entry->comm,
+				(unsigned long)task_entry->pid,
+				task_entry->io[UID_STATE_FOREGROUND].rchar,
+				task_entry->io[UID_STATE_FOREGROUND].wchar,
+				task_entry->io[UID_STATE_FOREGROUND].read_bytes,
+				task_entry->io[UID_STATE_FOREGROUND].write_bytes,
+				task_entry->io[UID_STATE_BACKGROUND].rchar,
+				task_entry->io[UID_STATE_BACKGROUND].wchar,
+				task_entry->io[UID_STATE_BACKGROUND].read_bytes,
+				task_entry->io[UID_STATE_BACKGROUND].write_bytes,
+				task_entry->io[UID_STATE_FOREGROUND].fsync,
+				task_entry->io[UID_STATE_BACKGROUND].fsync);
+	}
+}
+#else
+static void remove_uid_tasks(struct uid_entry *uid_entry) {};
+static void set_io_uid_tasks_zero(struct uid_entry *uid_entry) {};
+static void add_uid_tasks_io_stats(struct uid_entry *uid_entry,
+		struct task_struct *task, int slot) {};
+static void compute_io_uid_tasks(struct uid_entry *uid_entry) {};
+static void show_io_uid_tasks(struct seq_file *m,
+		struct uid_entry *uid_entry) {}
+#endif
+
 static struct uid_entry *find_uid_entry(uid_t uid)
 {
 	struct uid_entry *uid_entry;
@@ -87,7 +320,9 @@
 		return NULL;
 
 	uid_entry->uid = uid;
-
+#ifdef CONFIG_UID_SYS_STATS_DEBUG
+	hash_init(uid_entry->task_entries);
+#endif
 	hash_add(hash_table, &uid_entry->hash, uid);
 
 	return uid_entry;
@@ -193,6 +428,7 @@
 		hash_for_each_possible_safe(hash_table, uid_entry, tmp,
 							hash, (uid_t)uid_start) {
 			if (uid_start == uid_entry->uid) {
+				remove_uid_tasks(uid_entry);
 				hash_del(&uid_entry->hash);
 				kfree(uid_entry);
 			}
@@ -209,13 +445,6 @@
 	.write		= uid_remove_write,
 };
 
-static u64 compute_write_bytes(struct task_struct *task)
-{
-	if (task->ioac.write_bytes <= task->ioac.cancelled_write_bytes)
-		return 0;
-
-	return task->ioac.write_bytes - task->ioac.cancelled_write_bytes;
-}
 
 static void add_uid_io_stats(struct uid_entry *uid_entry,
 			struct task_struct *task, int slot)
@@ -227,28 +456,8 @@
 	io_slot->rchar += task->ioac.rchar;
 	io_slot->wchar += task->ioac.wchar;
 	io_slot->fsync += task->ioac.syscfs;
-}
 
-static void compute_uid_io_bucket_stats(struct io_stats *io_bucket,
-					struct io_stats *io_curr,
-					struct io_stats *io_last,
-					struct io_stats *io_dead)
-{
-	io_bucket->read_bytes += io_curr->read_bytes + io_dead->read_bytes -
-		io_last->read_bytes;
-	io_bucket->write_bytes += io_curr->write_bytes + io_dead->write_bytes -
-		io_last->write_bytes;
-	io_bucket->rchar += io_curr->rchar + io_dead->rchar - io_last->rchar;
-	io_bucket->wchar += io_curr->wchar + io_dead->wchar - io_last->wchar;
-	io_bucket->fsync += io_curr->fsync + io_dead->fsync - io_last->fsync;
-
-	io_last->read_bytes = io_curr->read_bytes;
-	io_last->write_bytes = io_curr->write_bytes;
-	io_last->rchar = io_curr->rchar;
-	io_last->wchar = io_curr->wchar;
-	io_last->fsync = io_curr->fsync;
-
-	memset(io_dead, 0, sizeof(struct io_stats));
+	add_uid_tasks_io_stats(uid_entry, task, slot);
 }
 
 static void update_io_stats_all_locked(void)
@@ -259,9 +468,11 @@
 	unsigned long bkt;
 	uid_t uid;
 
-	hash_for_each(hash_table, bkt, uid_entry, hash)
+	hash_for_each(hash_table, bkt, uid_entry, hash) {
 		memset(&uid_entry->io[UID_STATE_TOTAL_CURR], 0,
 			sizeof(struct io_stats));
+		set_io_uid_tasks_zero(uid_entry);
+	}
 
 	rcu_read_lock();
 	do_each_thread(temp, task) {
@@ -275,10 +486,11 @@
 	rcu_read_unlock();
 
 	hash_for_each(hash_table, bkt, uid_entry, hash) {
-		compute_uid_io_bucket_stats(&uid_entry->io[uid_entry->state],
+		compute_io_bucket_stats(&uid_entry->io[uid_entry->state],
 					&uid_entry->io[UID_STATE_TOTAL_CURR],
 					&uid_entry->io[UID_STATE_TOTAL_LAST],
 					&uid_entry->io[UID_STATE_DEAD_TASKS]);
+		compute_io_uid_tasks(uid_entry);
 	}
 }
 
@@ -289,6 +501,7 @@
 
 	memset(&uid_entry->io[UID_STATE_TOTAL_CURR], 0,
 		sizeof(struct io_stats));
+	set_io_uid_tasks_zero(uid_entry);
 
 	rcu_read_lock();
 	do_each_thread(temp, task) {
@@ -298,12 +511,14 @@
 	} while_each_thread(temp, task);
 	rcu_read_unlock();
 
-	compute_uid_io_bucket_stats(&uid_entry->io[uid_entry->state],
+	compute_io_bucket_stats(&uid_entry->io[uid_entry->state],
 				&uid_entry->io[UID_STATE_TOTAL_CURR],
 				&uid_entry->io[UID_STATE_TOTAL_LAST],
 				&uid_entry->io[UID_STATE_DEAD_TASKS]);
+	compute_io_uid_tasks(uid_entry);
 }
 
+
 static int uid_io_show(struct seq_file *m, void *v)
 {
 	struct uid_entry *uid_entry;
@@ -315,21 +530,22 @@
 
 	hash_for_each(hash_table, bkt, uid_entry, hash) {
 		seq_printf(m, "%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
-			uid_entry->uid,
-			uid_entry->io[UID_STATE_FOREGROUND].rchar,
-			uid_entry->io[UID_STATE_FOREGROUND].wchar,
-			uid_entry->io[UID_STATE_FOREGROUND].read_bytes,
-			uid_entry->io[UID_STATE_FOREGROUND].write_bytes,
-			uid_entry->io[UID_STATE_BACKGROUND].rchar,
-			uid_entry->io[UID_STATE_BACKGROUND].wchar,
-			uid_entry->io[UID_STATE_BACKGROUND].read_bytes,
-			uid_entry->io[UID_STATE_BACKGROUND].write_bytes,
-			uid_entry->io[UID_STATE_FOREGROUND].fsync,
-			uid_entry->io[UID_STATE_BACKGROUND].fsync);
+				uid_entry->uid,
+				uid_entry->io[UID_STATE_FOREGROUND].rchar,
+				uid_entry->io[UID_STATE_FOREGROUND].wchar,
+				uid_entry->io[UID_STATE_FOREGROUND].read_bytes,
+				uid_entry->io[UID_STATE_FOREGROUND].write_bytes,
+				uid_entry->io[UID_STATE_BACKGROUND].rchar,
+				uid_entry->io[UID_STATE_BACKGROUND].wchar,
+				uid_entry->io[UID_STATE_BACKGROUND].read_bytes,
+				uid_entry->io[UID_STATE_BACKGROUND].write_bytes,
+				uid_entry->io[UID_STATE_FOREGROUND].fsync,
+				uid_entry->io[UID_STATE_BACKGROUND].fsync);
+
+		show_io_uid_tasks(m, uid_entry);
 	}
 
 	rt_mutex_unlock(&uid_lock);
-
 	return 0;
 }
 
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 120fd54..eb14f0f 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -3518,15 +3518,23 @@
 	/* RED error - Fatal: requires reset */
 	if (mrq->cmdq_req->resp_err) {
 		err = mrq->cmdq_req->resp_err;
+		goto reset;
+	}
+
+	/*
+	 * TIMEOUT errrors can happen because of execution error
+	 * in the last command. So send cmd 13 to get device status
+	 */
+	if ((mrq->cmd && (mrq->cmd->error == -ETIMEDOUT)) ||
+			(mrq->data && (mrq->data->error == -ETIMEDOUT))) {
 		if (mmc_host_halt(host) || mmc_host_cq_disable(host)) {
 			ret = get_card_status(host->card, &status, 0);
 			if (ret)
 				pr_err("%s: CMD13 failed with err %d\n",
 						mmc_hostname(host), ret);
 		}
-		pr_err("%s: Response error detected with device status 0x%08x\n",
+		pr_err("%s: Timeout error detected with device status 0x%08x\n",
 			mmc_hostname(host), status);
-		goto reset;
 	}
 
 	/*
@@ -3572,7 +3580,7 @@
 	else if (mrq->data && mrq->data->error)
 		err = mrq->data->error;
 
-	if (err || cmdq_req->resp_err) {
+	if ((err || cmdq_req->resp_err) && !cmdq_req->skip_err_handling) {
 		pr_err("%s: %s: txfr error(%d)/resp_err(%d)\n",
 				mmc_hostname(mrq->host), __func__, err,
 				cmdq_req->resp_err);
@@ -3609,6 +3617,17 @@
 		blk_end_request_all(rq, err);
 		goto out;
 	}
+	/*
+	 * In case of error, cmdq_req->data.bytes_xfered is set to 0.
+	 * If we call blk_end_request() with nr_bytes as 0 then the request
+	 * never gets completed. So in case of error, to complete a request
+	 * with error we should use blk_end_request_all().
+	 */
+	if (err && cmdq_req->skip_err_handling) {
+		cmdq_req->skip_err_handling = false;
+		blk_end_request_all(rq, err);
+		goto out;
+	}
 
 	blk_end_request(rq, err, cmdq_req->data.bytes_xfered);
 
@@ -3889,6 +3908,7 @@
 	struct mmc_host *host = card->host;
 	struct mmc_cmdq_context_info *ctx = &host->cmdq_ctx;
 	u8 part_config = card->ext_csd.part_config;
+	int ret = 0, err = 0;
 
 	if ((main_md->part_curr == md->part_type) &&
 	    (card->part_curr == md->part_type))
@@ -3898,40 +3918,70 @@
 		 card->ext_csd.cmdq_support &&
 		 (md->flags & MMC_BLK_CMD_QUEUE)));
 
-	if (!test_bit(CMDQ_STATE_HALT, &ctx->curr_state))
-		WARN_ON(mmc_cmdq_halt(host, true));
+	if (!test_bit(CMDQ_STATE_HALT, &ctx->curr_state)) {
+		ret = mmc_cmdq_halt(host, true);
+		if (ret) {
+			pr_err("%s: %s: halt: failed: %d\n",
+				mmc_hostname(host), __func__,  ret);
+			goto out;
+		}
+	}
 
 	/* disable CQ mode in card */
 	if (mmc_card_cmdq(card)) {
-		WARN_ON(mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+		ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 				 EXT_CSD_CMDQ, 0,
-				  card->ext_csd.generic_cmd6_time));
+				 card->ext_csd.generic_cmd6_time);
+		if (ret) {
+			pr_err("%s: %s: cmdq mode disable failed %d\n",
+				mmc_hostname(host), __func__, ret);
+			goto cmdq_unhalt;
+		}
 		mmc_card_clr_cmdq(card);
 	}
 
 	part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK;
 	part_config |= md->part_type;
 
-	WARN_ON(mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+	ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 			 EXT_CSD_PART_CONFIG, part_config,
-			  card->ext_csd.part_time));
+			 card->ext_csd.part_time);
+	if (ret) {
+		pr_err("%s: %s: mmc_switch failure, %d -> %d , err = %d\n",
+			mmc_hostname(host), __func__, main_md->part_curr,
+			md->part_type, ret);
+		goto cmdq_switch;
+	}
 
 	card->ext_csd.part_config = part_config;
 	card->part_curr = md->part_type;
 
 	main_md->part_curr = md->part_type;
 
-	WARN_ON(mmc_blk_cmdq_switch(card, md, true));
-	WARN_ON(mmc_cmdq_halt(host, false));
-
-	return 0;
+cmdq_switch:
+	err = mmc_blk_cmdq_switch(card, md, true);
+	if (err) {
+		pr_err("%s: %s: mmc_blk_cmdq_switch failed: %d\n",
+			mmc_hostname(host), __func__,  err);
+		ret = err;
+	}
+cmdq_unhalt:
+	err = mmc_cmdq_halt(host, false);
+	if (err) {
+		pr_err("%s: %s: unhalt: failed: %d\n",
+			mmc_hostname(host), __func__,  err);
+		ret = err;
+	}
+out:
+	return ret;
 }
 
 static int mmc_blk_cmdq_issue_rq(struct mmc_queue *mq, struct request *req)
 {
-	int ret;
+	int ret, err = 0;
 	struct mmc_blk_data *md = mq->data;
 	struct mmc_card *card = md->queue.card;
+	struct mmc_host *host = card->host;
 
 	mmc_get_card(card);
 
@@ -3952,9 +4002,20 @@
 
 	ret = mmc_blk_cmdq_part_switch(card, md);
 	if (ret) {
-		pr_err("%s: %s: partition switch failed %d\n",
+		pr_err("%s: %s: partition switch failed %d, resetting cmdq\n",
 				md->disk->disk_name, __func__, ret);
-		goto out;
+
+		mmc_blk_cmdq_reset(host, false);
+		err = mmc_blk_cmdq_part_switch(card, md);
+		if (!err) {
+			pr_err("%s: %s: partition switch success err = %d\n",
+				md->disk->disk_name, __func__, err);
+		} else {
+			pr_err("%s: %s: partition switch failed err = %d\n",
+				md->disk->disk_name, __func__, err);
+			ret = err;
+			goto out;
+		}
 	}
 
 	if (req) {
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index a531cb4..a378b8c 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -403,6 +403,7 @@
 		return ret;
 
 	mmc_card_set_present(card);
+	device_enable_async_suspend(&card->dev);
 
 	return 0;
 }
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 978dd9a..727b301 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -3407,6 +3407,13 @@
 		pm_wakeup_event(mmc_dev(host), 5000);
 
 	host->detect_change = 1;
+	/*
+	 * Change in cd_gpio state, so make sure detection part is
+	 * not overided because of manual resume.
+	 */
+	if (cd_irq && mmc_bus_manual_resume(host))
+		host->ignore_bus_resume_flags = true;
+
 	mmc_schedule_delayed_work(&host->detect, delay);
 }
 
@@ -4387,6 +4394,8 @@
 		host->bus_ops->detect(host);
 
 	host->detect_change = 0;
+	if (host->ignore_bus_resume_flags)
+		host->ignore_bus_resume_flags = false;
 
 	/*
 	 * Let mmc_bus_put() free the bus/bus_ops if we've found that
@@ -4643,7 +4652,8 @@
 
 		spin_lock_irqsave(&host->lock, flags);
 		host->rescan_disable = 0;
-		if (mmc_bus_manual_resume(host)) {
+		if (mmc_bus_manual_resume(host) &&
+				!host->ignore_bus_resume_flags) {
 			spin_unlock_irqrestore(&host->lock, flags);
 			break;
 		}
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 127ab0f..64c8743 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -482,19 +482,17 @@
  */
 int mmc_of_parse(struct mmc_host *host)
 {
-	struct device_node *np;
+	struct device *dev = host->parent;
 	u32 bus_width;
 	int ret;
 	bool cd_cap_invert, cd_gpio_invert = false;
 	bool ro_cap_invert, ro_gpio_invert = false;
 
-	if (!host->parent || !host->parent->of_node)
+	if (!dev || !dev_fwnode(dev))
 		return 0;
 
-	np = host->parent->of_node;
-
 	/* "bus-width" is translated to MMC_CAP_*_BIT_DATA flags */
-	if (of_property_read_u32(np, "bus-width", &bus_width) < 0) {
+	if (device_property_read_u32(dev, "bus-width", &bus_width) < 0) {
 		dev_dbg(host->parent,
 			"\"bus-width\" property is missing, assuming 1 bit.\n");
 		bus_width = 1;
@@ -516,7 +514,7 @@
 	}
 
 	/* f_max is obtained from the optional "max-frequency" property */
-	of_property_read_u32(np, "max-frequency", &host->f_max);
+	device_property_read_u32(dev, "max-frequency", &host->f_max);
 
 	/*
 	 * Configure CD and WP pins. They are both by default active low to
@@ -531,12 +529,12 @@
 	 */
 
 	/* Parse Card Detection */
-	if (of_property_read_bool(np, "non-removable")) {
+	if (device_property_read_bool(dev, "non-removable")) {
 		host->caps |= MMC_CAP_NONREMOVABLE;
 	} else {
-		cd_cap_invert = of_property_read_bool(np, "cd-inverted");
+		cd_cap_invert = device_property_read_bool(dev, "cd-inverted");
 
-		if (of_property_read_bool(np, "broken-cd"))
+		if (device_property_read_bool(dev, "broken-cd"))
 			host->caps |= MMC_CAP_NEEDS_POLL;
 
 		ret = mmc_gpiod_request_cd(host, "cd", 0, true,
@@ -562,7 +560,7 @@
 	}
 
 	/* Parse Write Protection */
-	ro_cap_invert = of_property_read_bool(np, "wp-inverted");
+	ro_cap_invert = device_property_read_bool(dev, "wp-inverted");
 
 	ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert);
 	if (!ret)
@@ -570,62 +568,62 @@
 	else if (ret != -ENOENT && ret != -ENOSYS)
 		return ret;
 
-	if (of_property_read_bool(np, "disable-wp"))
+	if (device_property_read_bool(dev, "disable-wp"))
 		host->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
 
 	/* See the comment on CD inversion above */
 	if (ro_cap_invert ^ ro_gpio_invert)
 		host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
 
-	if (of_property_read_bool(np, "cap-sd-highspeed"))
+	if (device_property_read_bool(dev, "cap-sd-highspeed"))
 		host->caps |= MMC_CAP_SD_HIGHSPEED;
-	if (of_property_read_bool(np, "cap-mmc-highspeed"))
+	if (device_property_read_bool(dev, "cap-mmc-highspeed"))
 		host->caps |= MMC_CAP_MMC_HIGHSPEED;
-	if (of_property_read_bool(np, "sd-uhs-sdr12"))
+	if (device_property_read_bool(dev, "sd-uhs-sdr12"))
 		host->caps |= MMC_CAP_UHS_SDR12;
-	if (of_property_read_bool(np, "sd-uhs-sdr25"))
+	if (device_property_read_bool(dev, "sd-uhs-sdr25"))
 		host->caps |= MMC_CAP_UHS_SDR25;
-	if (of_property_read_bool(np, "sd-uhs-sdr50"))
+	if (device_property_read_bool(dev, "sd-uhs-sdr50"))
 		host->caps |= MMC_CAP_UHS_SDR50;
-	if (of_property_read_bool(np, "sd-uhs-sdr104"))
+	if (device_property_read_bool(dev, "sd-uhs-sdr104"))
 		host->caps |= MMC_CAP_UHS_SDR104;
-	if (of_property_read_bool(np, "sd-uhs-ddr50"))
+	if (device_property_read_bool(dev, "sd-uhs-ddr50"))
 		host->caps |= MMC_CAP_UHS_DDR50;
-	if (of_property_read_bool(np, "cap-power-off-card"))
+	if (device_property_read_bool(dev, "cap-power-off-card"))
 		host->caps |= MMC_CAP_POWER_OFF_CARD;
-	if (of_property_read_bool(np, "cap-mmc-hw-reset"))
+	if (device_property_read_bool(dev, "cap-mmc-hw-reset"))
 		host->caps |= MMC_CAP_HW_RESET;
-	if (of_property_read_bool(np, "cap-sdio-irq"))
+	if (device_property_read_bool(dev, "cap-sdio-irq"))
 		host->caps |= MMC_CAP_SDIO_IRQ;
-	if (of_property_read_bool(np, "full-pwr-cycle"))
+	if (device_property_read_bool(dev, "full-pwr-cycle"))
 		host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;
-	if (of_property_read_bool(np, "keep-power-in-suspend"))
+	if (device_property_read_bool(dev, "keep-power-in-suspend"))
 		host->pm_caps |= MMC_PM_KEEP_POWER;
-	if (of_property_read_bool(np, "wakeup-source") ||
-	    of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */
+	if (device_property_read_bool(dev, "wakeup-source") ||
+	    device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */
 		host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
-	if (of_property_read_bool(np, "mmc-ddr-1_8v"))
+	if (device_property_read_bool(dev, "mmc-ddr-1_8v"))
 		host->caps |= MMC_CAP_1_8V_DDR;
-	if (of_property_read_bool(np, "mmc-ddr-1_2v"))
+	if (device_property_read_bool(dev, "mmc-ddr-1_2v"))
 		host->caps |= MMC_CAP_1_2V_DDR;
-	if (of_property_read_bool(np, "mmc-hs200-1_8v"))
+	if (device_property_read_bool(dev, "mmc-hs200-1_8v"))
 		host->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
-	if (of_property_read_bool(np, "mmc-hs200-1_2v"))
+	if (device_property_read_bool(dev, "mmc-hs200-1_2v"))
 		host->caps2 |= MMC_CAP2_HS200_1_2V_SDR;
-	if (of_property_read_bool(np, "mmc-hs400-1_8v"))
+	if (device_property_read_bool(dev, "mmc-hs400-1_8v"))
 		host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR;
-	if (of_property_read_bool(np, "mmc-hs400-1_2v"))
+	if (device_property_read_bool(dev, "mmc-hs400-1_2v"))
 		host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR;
-	if (of_property_read_bool(np, "mmc-hs400-enhanced-strobe"))
+	if (device_property_read_bool(dev, "mmc-hs400-enhanced-strobe"))
 		host->caps2 |= MMC_CAP2_HS400_ES;
-	if (of_property_read_bool(np, "no-sdio"))
+	if (device_property_read_bool(dev, "no-sdio"))
 		host->caps2 |= MMC_CAP2_NO_SDIO;
-	if (of_property_read_bool(np, "no-sd"))
+	if (device_property_read_bool(dev, "no-sd"))
 		host->caps2 |= MMC_CAP2_NO_SD;
-	if (of_property_read_bool(np, "no-mmc"))
+	if (device_property_read_bool(dev, "no-mmc"))
 		host->caps2 |= MMC_CAP2_NO_MMC;
 
-	host->dsr_req = !of_property_read_u32(np, "dsr", &host->dsr);
+	host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr);
 	if (host->dsr_req && (host->dsr & ~0xffff)) {
 		dev_err(host->parent,
 			"device tree specified broken value for DSR: 0x%x, ignoring\n",
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 409718b..36295f5 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1357,10 +1357,6 @@
 	int err;
 	u8 val;
 
-	/* Reduce frequency to HS */
-	max_dtr = card->ext_csd.hs_max_dtr;
-	mmc_set_clock(host, max_dtr);
-
 	/* Switch HS400 to HS DDR */
 	val = EXT_CSD_TIMING_HS;
 	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
@@ -1371,6 +1367,10 @@
 
 	mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
 
+	/* Reduce frequency to HS */
+	max_dtr = card->ext_csd.hs_max_dtr;
+	mmc_set_clock(host, max_dtr);
+
 	err = mmc_switch_status(card, false);
 	if (err)
 		goto out_err;
@@ -1416,7 +1416,7 @@
 static int mmc_select_hs400es(struct mmc_card *card)
 {
 	struct mmc_host *host = card->host;
-	int err = 0;
+	int err = -EINVAL;
 	u8 val;
 
 	if (!(host->caps & MMC_CAP_8_BIT_DATA)) {
@@ -2148,7 +2148,7 @@
 		err = mmc_select_hs400(card);
 		if (err)
 			goto free_card;
-	} else {
+	} else if (!mmc_card_hs400es(card)) {
 		/* Select the desired bus width optionally */
 		err = mmc_select_bus_width(card);
 		if (err > 0 && mmc_card_hs(card)) {
@@ -2159,11 +2159,11 @@
 	}
 
 	card->clk_scaling_lowest = host->f_min;
-	if ((card->mmc_avail_type | EXT_CSD_CARD_TYPE_HS400) ||
-			(card->mmc_avail_type | EXT_CSD_CARD_TYPE_HS200))
+	if ((card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400) ||
+			(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200))
 		card->clk_scaling_highest = card->ext_csd.hs200_max_dtr;
-	else if ((card->mmc_avail_type | EXT_CSD_CARD_TYPE_HS) ||
-			(card->mmc_avail_type | EXT_CSD_CARD_TYPE_DDR_52))
+	else if ((card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS) ||
+			(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52))
 		card->clk_scaling_highest = card->ext_csd.hs_max_dtr;
 	else
 		card->clk_scaling_highest = card->csd.max_dtr;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 650f658..d591ded 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1275,7 +1275,10 @@
 	if (!err) {
 		pm_runtime_disable(&host->card->dev);
 		pm_runtime_set_suspended(&host->card->dev);
-	}
+	/* if suspend fails, force mmc_detect_change during resume */
+	} else if (mmc_bus_manual_resume(host))
+		host->ignore_bus_resume_flags = true;
+
 	MMC_TRACE(host, "%s: Exit err: %d\n", __func__, err);
 
 	return err;
diff --git a/drivers/mmc/host/cmdq_hci.c b/drivers/mmc/host/cmdq_hci.c
index 7c3638c..591d6b2 100644
--- a/drivers/mmc/host/cmdq_hci.c
+++ b/drivers/mmc/host/cmdq_hci.c
@@ -145,6 +145,29 @@
 	mb();
 }
 
+static int cmdq_clear_task_poll(struct cmdq_host *cq_host, unsigned int tag)
+{
+	int retries = 100;
+
+	cmdq_clear_set_irqs(cq_host, CQIS_TCL, 0);
+	cmdq_writel(cq_host, 1<<tag, CQTCLR);
+	while (retries) {
+		/*
+		 * Task Clear register and doorbell,
+		 * both should indicate that task is cleared
+		 */
+		if ((cmdq_readl(cq_host, CQTCLR) & 1<<tag) ||
+			(cmdq_readl(cq_host, CQTDBR) & 1<<tag)) {
+			udelay(5);
+			retries--;
+			continue;
+		} else
+			break;
+	}
+
+	cmdq_clear_set_irqs(cq_host, 0, CQIS_TCL);
+	return retries ? 0 : -ETIMEDOUT;
+}
 
 #define DRV_NAME "cmdq-host"
 
@@ -197,6 +220,10 @@
 static void cmdq_dumpregs(struct cmdq_host *cq_host)
 {
 	struct mmc_host *mmc = cq_host->mmc;
+	int offset = 0;
+
+	if (cq_host->offset_changed)
+		offset = CQ_V5_VENDOR_CFG;
 
 	MMC_TRACE(mmc,
 	"%s: 0x0C=0x%08x 0x10=0x%08x 0x14=0x%08x 0x18=0x%08x 0x28=0x%08x 0x2C=0x%08x 0x30=0x%08x 0x34=0x%08x 0x54=0x%08x 0x58=0x%08x 0x5C=0x%08x 0x48=0x%08x\n",
@@ -243,7 +270,7 @@
 		cmdq_readl(cq_host, CQCRI),
 		cmdq_readl(cq_host, CQCRA));
 	pr_err(DRV_NAME": Vendor cfg 0x%08x\n",
-	       cmdq_readl(cq_host, CQ_VENDOR_CFG));
+	       cmdq_readl(cq_host, CQ_VENDOR_CFG + offset));
 	pr_err(DRV_NAME ": ===========================================\n");
 
 	cmdq_dump_task_history(cq_host);
@@ -345,6 +372,7 @@
 {
 	int err = 0;
 	u32 cqcfg;
+	u32 cqcap = 0;
 	bool dcmd_enable;
 	struct cmdq_host *cq_host = mmc_cmdq_private(mmc);
 
@@ -373,6 +401,24 @@
 	cqcfg = ((cq_host->caps & CMDQ_TASK_DESC_SZ_128 ? CQ_TASK_DESC_SZ : 0) |
 			(dcmd_enable ? CQ_DCMD : 0));
 
+	cqcap = cmdq_readl(cq_host, CQCAP);
+	if (cqcap & CQCAP_CS) {
+		/*
+		 * In case host controller supports cryptographic operations
+		 * then, it uses 128bit task descriptor. Upper 64 bits of task
+		 * descriptor would be used to pass crypto specific informaton.
+		 */
+		cq_host->caps |= CMDQ_CAP_CRYPTO_SUPPORT |
+				 CMDQ_TASK_DESC_SZ_128;
+		cqcfg |= CQ_ICE_ENABLE;
+		/*
+		 * For SDHC v5.0 onwards, ICE 3.0 specific registers are added
+		 * in CQ register space, due to which few CQ registers are
+		 * shifted. Set offset_changed boolean to use updated address.
+		 */
+		cq_host->offset_changed = true;
+	}
+
 	cmdq_writel(cq_host, cqcfg, CQCFG);
 	/* enable CQ_HOST */
 	cmdq_writel(cq_host, cmdq_readl(cq_host, CQCFG) | CQ_ENABLE,
@@ -688,6 +734,30 @@
 		upper_32_bits(*task_desc));
 }
 
+static inline
+void cmdq_prep_crypto_desc(struct cmdq_host *cq_host, u64 *task_desc,
+			u64 ice_ctx)
+{
+	u64 *ice_desc = NULL;
+
+	if (cq_host->caps & CMDQ_CAP_CRYPTO_SUPPORT) {
+		/*
+		 * Get the address of ice context for the given task descriptor.
+		 * ice context is present in the upper 64bits of task descriptor
+		 * ice_conext_base_address = task_desc + 8-bytes
+		 */
+		ice_desc = (__le64 *)((u8 *)task_desc +
+						CQ_TASK_DESC_TASK_PARAMS_SIZE);
+		memset(ice_desc, 0, CQ_TASK_DESC_ICE_PARAMS_SIZE);
+
+		/*
+		 *  Assign upper 64bits data of task descritor with ice context
+		 */
+		if (ice_ctx)
+			*ice_desc = cpu_to_le64(ice_ctx);
+	}
+}
+
 static void cmdq_pm_qos_vote(struct sdhci_host *host, struct mmc_request *mrq)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -711,6 +781,7 @@
 	u32 tag = mrq->cmdq_req->tag;
 	struct cmdq_host *cq_host = (struct cmdq_host *)mmc_cmdq_private(mmc);
 	struct sdhci_host *host = mmc_priv(mmc);
+	u64 ice_ctx = 0;
 
 	if (!cq_host->enabled) {
 		pr_err("%s: CMDQ host not enabled yet !!!\n",
@@ -730,7 +801,7 @@
 	}
 
 	if (cq_host->ops->crypto_cfg) {
-		err = cq_host->ops->crypto_cfg(mmc, mrq, tag);
+		err = cq_host->ops->crypto_cfg(mmc, mrq, tag, &ice_ctx);
 		if (err) {
 			pr_err("%s: failed to configure crypto: err %d tag %d\n",
 					mmc_hostname(mmc), err, tag);
@@ -743,6 +814,9 @@
 	cmdq_prep_task_desc(mrq, &data, 1,
 			    (mrq->cmdq_req->cmdq_req_flags & QBR));
 	*task_desc = cpu_to_le64(data);
+
+	cmdq_prep_crypto_desc(cq_host, task_desc, ice_ctx);
+
 	cmdq_log_task_desc_history(cq_host, *task_desc, false);
 
 	err = cmdq_prep_tran_desc(mrq, cq_host, tag);
@@ -777,17 +851,31 @@
 {
 	struct mmc_request *mrq;
 	struct cmdq_host *cq_host = (struct cmdq_host *)mmc_cmdq_private(mmc);
+	int offset = 0;
+	int err = 0;
 
+	if (cq_host->offset_changed)
+		offset = CQ_V5_VENDOR_CFG;
 	mrq = get_req_by_tag(cq_host, tag);
 	if (tag == cq_host->dcmd_slot)
 		mrq->cmd->resp[0] = cmdq_readl(cq_host, CQCRDCT);
 
 	if (mrq->cmdq_req->cmdq_req_flags & DCMD)
-		cmdq_writel(cq_host, cmdq_readl(cq_host, CQ_VENDOR_CFG) |
-			    CMDQ_SEND_STATUS_TRIGGER, CQ_VENDOR_CFG);
+		cmdq_writel(cq_host,
+			cmdq_readl(cq_host, CQ_VENDOR_CFG + offset) |
+			CMDQ_SEND_STATUS_TRIGGER, CQ_VENDOR_CFG + offset);
 
 	cmdq_runtime_pm_put(cq_host);
-	if (cq_host->ops->crypto_cfg_reset)
+
+	if (cq_host->ops->crypto_cfg_end) {
+		err = cq_host->ops->crypto_cfg_end(mmc, mrq);
+		if (err) {
+			pr_err("%s: failed to end ice config: err %d tag %d\n",
+					mmc_hostname(mmc), err, tag);
+		}
+	}
+	if (!(cq_host->caps & CMDQ_CAP_CRYPTO_SUPPORT) &&
+			cq_host->ops->crypto_cfg_reset)
 		cq_host->ops->crypto_cfg_reset(mmc, tag);
 	mrq->done(mrq);
 }
@@ -801,6 +889,8 @@
 	struct mmc_request *mrq;
 	int ret;
 	u32 dbr_set = 0;
+	u32 dev_pend_set = 0;
+	int stat_err = 0;
 
 	status = cmdq_readl(cq_host, CQIS);
 
@@ -809,7 +899,9 @@
 	MMC_TRACE(mmc, "%s: CQIS: 0x%x err: %d\n",
 		__func__, status, err);
 
-	if (err || (status & CQIS_RED)) {
+	stat_err = status & (CQIS_RED | CQIS_GCE | CQIS_ICCE);
+
+	if (err || stat_err) {
 		err_info = cmdq_readl(cq_host, CQTERRI);
 		pr_err("%s: err: %d status: 0x%08x task-err-info (0x%08lx)\n",
 		       mmc_hostname(mmc), err, status, err_info);
@@ -912,7 +1004,7 @@
 		 * CQE detected a response error from device
 		 * In most cases, this would require a reset.
 		 */
-		if (status & CQIS_RED) {
+		if (stat_err & CQIS_RED) {
 			/*
 			 * will check if the RED error is due to a bkops
 			 * exception once the queue is empty
@@ -931,6 +1023,62 @@
 			mrq->cmdq_req->resp_arg = cmdq_readl(cq_host, CQCRA);
 		}
 
+		/*
+		 * Generic Crypto error detected by CQE.
+		 * Its a fatal, would require cmdq reset.
+		 */
+		if (stat_err & CQIS_GCE) {
+			if (mrq->data)
+				mrq->data->error = -EIO;
+			pr_err("%s: Crypto generic error while processing task %lu!",
+				mmc_hostname(mmc), tag);
+			MMC_TRACE(mmc, "%s: GCE error detected with tag %lu\n",
+					__func__, tag);
+		}
+		/*
+		 * Invalid crypto config error detected by CQE, clear the task.
+		 * Task can be cleared only when CQE is halt state.
+		 */
+		if (stat_err & CQIS_ICCE) {
+			/*
+			 * Invalid Crypto Config Error is detected at the
+			 * beginning of the transfer before the actual execution
+			 * started. So just clear the task in CQE. No need to
+			 * clear in device. Only the task which caused ICCE has
+			 * to be cleared. Other tasks can be continue processing
+			 * The first task which is about to be prepared would
+			 * cause ICCE Error.
+			 */
+			dbr_set = cmdq_readl(cq_host, CQTDBR);
+			dev_pend_set = cmdq_readl(cq_host, CQDPT);
+			if (dbr_set ^ dev_pend_set)
+				tag = ffs(dbr_set ^ dev_pend_set) - 1;
+			mrq = get_req_by_tag(cq_host, tag);
+			pr_err("%s: Crypto config error while processing task %lu!",
+				mmc_hostname(mmc), tag);
+			MMC_TRACE(mmc, "%s: ICCE error with tag %lu\n",
+						__func__, tag);
+			if (mrq->data)
+				mrq->data->error = -EIO;
+			else if (mrq->cmd)
+				mrq->cmd->error = -EIO;
+			/*
+			 * If CQE is halted and tag is valid then clear the task
+			 * then un-halt CQE and set flag to skip error recovery.
+			 * If any of the condtions is not met thene it will
+			 * enter into default error recovery path.
+			 */
+			if (!ret && (dbr_set ^ dev_pend_set)) {
+				ret = cmdq_clear_task_poll(cq_host, tag);
+				if (ret) {
+					pr_err("%s: %s: task[%lu] clear failed ret=%d\n",
+						mmc_hostname(mmc),
+						__func__, tag, ret);
+				} else if (!cmdq_halt_poll(mmc, false)) {
+					mrq->cmdq_req->skip_err_handling = true;
+				}
+			}
+		}
 		cmdq_finish_data(mmc, tag);
 	} else {
 		cmdq_writel(cq_host, status, CQIS);
@@ -1001,6 +1149,7 @@
 			cq_host->ops->clear_set_irqs(mmc, true);
 		cmdq_writel(cq_host, cmdq_readl(cq_host, CQCTL) & ~HALT,
 			    CQCTL);
+		mmc_host_clr_halt(mmc);
 		return 0;
 	}
 
diff --git a/drivers/mmc/host/cmdq_hci.h b/drivers/mmc/host/cmdq_hci.h
index 8e9f765..1aabce9 100644
--- a/drivers/mmc/host/cmdq_hci.h
+++ b/drivers/mmc/host/cmdq_hci.h
@@ -18,11 +18,13 @@
 #define CQVER		0x00
 /* capabilities */
 #define CQCAP		0x04
+#define CQCAP_CS	(1 << 28)
 /* configuration */
 #define CQCFG		0x08
 #define CQ_DCMD		0x00001000
 #define CQ_TASK_DESC_SZ 0x00000100
 #define CQ_ENABLE	0x00000001
+#define CQ_ICE_ENABLE	0x00000002
 
 /* control */
 #define CQCTL		0x0C
@@ -35,6 +37,8 @@
 #define CQIS_TCC	(1 << 1)
 #define CQIS_RED	(1 << 2)
 #define CQIS_TCL	(1 << 3)
+#define CQIS_GCE	(1 << 4)
+#define CQIS_ICCE	(1 << 5)
 
 /* interrupt status enable */
 #define CQISTE		0x14
@@ -110,7 +114,7 @@
 /* command response argument */
 #define CQCRA		0x5C
 
-#define CQ_INT_ALL	0xF
+#define CQ_INT_ALL	0x3F
 #define CQIC_DEFAULT_ICCTH 31
 #define CQIC_DEFAULT_ICTOVAL 1
 
@@ -141,9 +145,17 @@
 #define DAT_ADDR_LO(x)	((x & 0xFFFFFFFF) << 32)
 #define DAT_ADDR_HI(x)	((x & 0xFFFFFFFF) << 0)
 
+/*
+ * Add new macro for updated CQ vendor specific
+ * register address for SDHC v5.0 onwards.
+ */
+#define CQ_V5_VENDOR_CFG	0x900
 #define CQ_VENDOR_CFG	0x100
 #define CMDQ_SEND_STATUS_TRIGGER (1 << 31)
 
+#define CQ_TASK_DESC_TASK_PARAMS_SIZE	8
+#define CQ_TASK_DESC_ICE_PARAMS_SIZE	8
+
 struct task_history {
 	u64 task;
 	bool is_dcmd;
@@ -161,6 +173,7 @@
 	u32 dcmd_slot;
 	u32 caps;
 #define CMDQ_TASK_DESC_SZ_128 0x1
+#define CMDQ_CAP_CRYPTO_SUPPORT 0x2
 
 	u32 quirks;
 #define CMDQ_QUIRK_SHORT_TXFR_DESC_SZ 0x1
@@ -169,6 +182,7 @@
 	bool enabled;
 	bool halted;
 	bool init_done;
+	bool offset_changed;
 
 	u8 *desc_base;
 
@@ -209,7 +223,8 @@
 	int (*reset)(struct mmc_host *mmc);
 	void (*post_cqe_halt)(struct mmc_host *mmc);
 	int (*crypto_cfg)(struct mmc_host *mmc, struct mmc_request *mrq,
-				u32 slot);
+				u32 slot, u64 *ice_ctx);
+	int (*crypto_cfg_end)(struct mmc_host *mmc, struct mmc_request *mrq);
 	void (*crypto_cfg_reset)(struct mmc_host *mmc, unsigned int slot);
 };
 
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index df478ae..f81f417 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2610,8 +2610,8 @@
 	host->slot[id] = slot;
 
 	mmc->ops = &dw_mci_ops;
-	if (of_property_read_u32_array(host->dev->of_node,
-				       "clock-freq-min-max", freq, 2)) {
+	if (device_property_read_u32_array(host->dev, "clock-freq-min-max",
+					   freq, 2)) {
 		mmc->f_min = DW_MCI_FREQ_MIN;
 		mmc->f_max = DW_MCI_FREQ_MAX;
 	} else {
@@ -2709,7 +2709,6 @@
 {
 	int addr_config;
 	struct device *dev = host->dev;
-	struct device_node *np = dev->of_node;
 
 	/*
 	* Check tansfer mode from HCON[17:16]
@@ -2770,8 +2769,9 @@
 		dev_info(host->dev, "Using internal DMA controller.\n");
 	} else {
 		/* TRANS_MODE_EDMAC: check dma bindings again */
-		if ((of_property_count_strings(np, "dma-names") < 0) ||
-		    (!of_find_property(np, "dmas", NULL))) {
+		if ((device_property_read_string_array(dev, "dma-names",
+						       NULL, 0) < 0) ||
+		    !device_property_present(dev, "dmas")) {
 			goto no_dma;
 		}
 		host->dma_ops = &dw_mci_edmac_ops;
@@ -2931,7 +2931,6 @@
 {
 	struct dw_mci_board *pdata;
 	struct device *dev = host->dev;
-	struct device_node *np = dev->of_node;
 	const struct dw_mci_drv_data *drv_data = host->drv_data;
 	int ret;
 	u32 clock_frequency;
@@ -2948,15 +2947,16 @@
 	}
 
 	/* find out number of slots supported */
-	of_property_read_u32(np, "num-slots", &pdata->num_slots);
+	device_property_read_u32(dev, "num-slots", &pdata->num_slots);
 
-	if (of_property_read_u32(np, "fifo-depth", &pdata->fifo_depth))
+	if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth))
 		dev_info(dev,
 			 "fifo-depth property not found, using value of FIFOTH register as default\n");
 
-	of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);
+	device_property_read_u32(dev, "card-detect-delay",
+				 &pdata->detect_delay_ms);
 
-	if (!of_property_read_u32(np, "clock-frequency", &clock_frequency))
+	if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
 		pdata->bus_hz = clock_frequency;
 
 	if (drv_data && drv_data->parse_dt) {
diff --git a/drivers/mmc/host/sdhci-msm-ice.c b/drivers/mmc/host/sdhci-msm-ice.c
index d624b48..f86ce5b 100644
--- a/drivers/mmc/host/sdhci-msm-ice.c
+++ b/drivers/mmc/host/sdhci-msm-ice.c
@@ -276,6 +276,58 @@
 	mb();
 }
 
+static inline
+void sdhci_msm_ice_hci_update_cmdq_cfg(u64 dun, unsigned int bypass,
+				short key_index, u64 *ice_ctx)
+{
+	/*
+	 * The naming convention got changed between ICE2.0 and ICE3.0
+	 * registers fields. Below is the equivalent names for
+	 * ICE3.0 Vs ICE2.0:
+	 *   Data Unit Number(DUN) == Logical Base address(LBA)
+	 *   Crypto Configuration index (CCI) == Key Index
+	 *   Crypto Enable (CE) == !BYPASS
+	 */
+	if (ice_ctx)
+		*ice_ctx = DATA_UNIT_NUM(dun) |
+			CRYPTO_CONFIG_INDEX(key_index) |
+			CRYPTO_ENABLE(!bypass);
+}
+
+static
+void sdhci_msm_ice_hci_update_noncq_cfg(struct sdhci_host *host,
+		u64 dun, unsigned int bypass, short key_index)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = pltfm_host->priv;
+	unsigned int crypto_params = 0;
+	/*
+	 * The naming convention got changed between ICE2.0 and ICE3.0
+	 * registers fields. Below is the equivalent names for
+	 * ICE3.0 Vs ICE2.0:
+	 *   Data Unit Number(DUN) == Logical Base address(LBA)
+	 *   Crypto Configuration index (CCI) == Key Index
+	 *   Crypto Enable (CE) == !BYPASS
+	 */
+	/* Configure ICE bypass mode */
+	crypto_params |=
+		(!bypass & MASK_SDHCI_MSM_ICE_HCI_PARAM_CE)
+			<< OFFSET_SDHCI_MSM_ICE_HCI_PARAM_CE;
+	/* Configure Crypto Configure Index (CCI) */
+	crypto_params |= (key_index &
+			 MASK_SDHCI_MSM_ICE_HCI_PARAM_CCI)
+			 << OFFSET_SDHCI_MSM_ICE_HCI_PARAM_CCI;
+
+	writel_relaxed((crypto_params & 0xFFFFFFFF),
+		msm_host->cryptoio + ICE_NONCQ_CRYPTO_PARAMS);
+
+	/* Update DUN */
+	writel_relaxed((dun & 0xFFFFFFFF),
+		msm_host->cryptoio + ICE_NONCQ_CRYPTO_DUN);
+	/* Ensure ICE registers are configured before issuing SDHCI request */
+	mb();
+}
+
 int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
 			u32 slot)
 {
@@ -308,7 +360,88 @@
 				slot, bypass, key_index);
 	}
 
-	sdhci_msm_ice_update_cfg(host, lba, slot, bypass, key_index);
+	if (msm_host->ice_hci_support) {
+		/* For ICE HCI / ICE3.0 */
+		sdhci_msm_ice_hci_update_noncq_cfg(host, lba, bypass,
+						key_index);
+	} else {
+		/* For ICE versions earlier to ICE3.0 */
+		sdhci_msm_ice_update_cfg(host, lba, slot, bypass, key_index);
+	}
+	return 0;
+}
+
+int sdhci_msm_ice_cmdq_cfg(struct sdhci_host *host,
+			struct mmc_request *mrq, u32 slot, u64 *ice_ctx)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = pltfm_host->priv;
+	int err = 0;
+	short key_index = 0;
+	sector_t lba = 0;
+	unsigned int bypass = SDHCI_MSM_ICE_ENABLE_BYPASS;
+	struct request *req;
+
+	if (msm_host->ice.state != SDHCI_MSM_ICE_STATE_ACTIVE) {
+		pr_err("%s: ice is in invalid state %d\n",
+			mmc_hostname(host->mmc), msm_host->ice.state);
+		return -EINVAL;
+	}
+
+	WARN_ON(!mrq);
+	if (!mrq)
+		return -EINVAL;
+	req = mrq->req;
+	if (req) {
+		lba = req->__sector;
+		err = sdhci_msm_ice_get_cfg(msm_host, req, &bypass, &key_index);
+		if (err)
+			return err;
+		pr_debug("%s: %s: slot %d bypass %d key_index %d\n",
+				mmc_hostname(host->mmc),
+				(rq_data_dir(req) == WRITE) ? "WRITE" : "READ",
+				slot, bypass, key_index);
+	}
+
+	if (msm_host->ice_hci_support) {
+		/* For ICE HCI / ICE3.0 */
+		sdhci_msm_ice_hci_update_cmdq_cfg(lba, bypass, key_index,
+						ice_ctx);
+	} else {
+		/* For ICE versions earlier to ICE3.0 */
+		sdhci_msm_ice_update_cfg(host, lba, slot, bypass, key_index);
+	}
+	return 0;
+}
+
+int sdhci_msm_ice_cfg_end(struct sdhci_host *host, struct mmc_request *mrq)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = pltfm_host->priv;
+	int err = 0;
+	struct request *req;
+
+	if (!host->is_crypto_en)
+		return 0;
+
+	if (msm_host->ice.state != SDHCI_MSM_ICE_STATE_ACTIVE) {
+		pr_err("%s: ice is in invalid state %d\n",
+			mmc_hostname(host->mmc), msm_host->ice.state);
+		return -EINVAL;
+	}
+
+	req = mrq->req;
+	if (req) {
+		if (msm_host->ice.vops->config_end) {
+			err = msm_host->ice.vops->config_end(req);
+			if (err) {
+				pr_err("%s: ice config end failed %d\n",
+						mmc_hostname(host->mmc), err);
+				return err;
+			}
+		}
+	}
+
 	return 0;
 }
 
diff --git a/drivers/mmc/host/sdhci-msm-ice.h b/drivers/mmc/host/sdhci-msm-ice.h
index 23922cf..6296174 100644
--- a/drivers/mmc/host/sdhci-msm-ice.h
+++ b/drivers/mmc/host/sdhci-msm-ice.h
@@ -42,6 +42,8 @@
 #define ICE_HCI_SUPPORT		(1 << 28)
 #define ICE_CQ_CONFIG		0x08
 #define CRYPTO_GENERAL_ENABLE	(1 << 1)
+#define ICE_NONCQ_CRYPTO_PARAMS	0x70
+#define ICE_NONCQ_CRYPTO_DUN	0x74
 
 /* ICE3.0 register which got added hc reg space */
 #define HC_VENDOR_SPECIFIC_FUNC4	0x260
@@ -52,8 +54,10 @@
 /* SDHCI MSM ICE CTRL Info register offset */
 enum {
 	OFFSET_SDHCI_MSM_ICE_CTRL_INFO_BYPASS     = 0,
-	OFFSET_SDHCI_MSM_ICE_CTRL_INFO_KEY_INDEX  = 0x1,
-	OFFSET_SDHCI_MSM_ICE_CTRL_INFO_CDU        = 0x6,
+	OFFSET_SDHCI_MSM_ICE_CTRL_INFO_KEY_INDEX  = 1,
+	OFFSET_SDHCI_MSM_ICE_CTRL_INFO_CDU        = 6,
+	OFFSET_SDHCI_MSM_ICE_HCI_PARAM_CCI	  = 0,
+	OFFSET_SDHCI_MSM_ICE_HCI_PARAM_CE	  = 8,
 };
 
 /* SDHCI MSM ICE CTRL Info register masks */
@@ -61,6 +65,8 @@
 	MASK_SDHCI_MSM_ICE_CTRL_INFO_BYPASS     = 0x1,
 	MASK_SDHCI_MSM_ICE_CTRL_INFO_KEY_INDEX  = 0x1F,
 	MASK_SDHCI_MSM_ICE_CTRL_INFO_CDU        = 0x7,
+	MASK_SDHCI_MSM_ICE_HCI_PARAM_CE		= 0x1,
+	MASK_SDHCI_MSM_ICE_HCI_PARAM_CCI	= 0xff
 };
 
 /* SDHCI MSM ICE encryption/decryption bypass state */
@@ -99,6 +105,9 @@
 void sdhci_msm_ice_cfg_reset(struct sdhci_host *host, u32 slot);
 int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
 			u32 slot);
+int sdhci_msm_ice_cmdq_cfg(struct sdhci_host *host,
+			struct mmc_request *mrq, u32 slot, u64 *ice_ctx);
+int sdhci_msm_ice_cfg_end(struct sdhci_host *host, struct mmc_request *mrq);
 int sdhci_msm_ice_reset(struct sdhci_host *host);
 int sdhci_msm_ice_resume(struct sdhci_host *host);
 int sdhci_msm_ice_suspend(struct sdhci_host *host);
@@ -130,6 +139,16 @@
 {
 	return 0;
 }
+static inline int sdhci_msm_ice_cmdq_cfg(struct sdhci_host *host,
+		struct mmc_request *mrq, u32 slot, u64 *ice_ctx)
+{
+	return 0;
+}
+static inline int sdhci_msm_ice_cfg_end(struct sdhci_host *host,
+			struct mmc_request *mrq)
+{
+	return 0;
+}
 inline int sdhci_msm_ice_reset(struct sdhci_host *host)
 {
 	return 0;
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 1e25b31..55d9cf5 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -146,6 +146,7 @@
 #define CORE_START_CDC_TRAFFIC		(1 << 6)
 
 #define CORE_PWRSAVE_DLL	(1 << 3)
+#define CORE_FIFO_ALT_EN	(1 << 10)
 #define CORE_CMDEN_HS400_INPUT_MASK_CNT (1 << 13)
 
 #define CORE_DDR_CAL_EN		(1 << 0)
@@ -1143,6 +1144,7 @@
 	bool drv_type_changed = false;
 	struct mmc_card *card = host->mmc->card;
 	int sts_retry;
+	u8 last_good_phase = 0;
 
 	/*
 	 * Tuning is required for SDR104, HS200 and HS400 cards and
@@ -1228,6 +1230,22 @@
 		mmc_wait_for_req(mmc, &mrq);
 
 		if (card && (cmd.error || data.error)) {
+			/*
+			 * Set the dll to last known good phase while sending
+			 * status command to ensure that status command won't
+			 * fail due to bad phase.
+			 */
+			if (tuned_phase_cnt)
+				last_good_phase =
+					tuned_phases[tuned_phase_cnt-1];
+			else if (msm_host->saved_tuning_phase !=
+					INVALID_TUNING_PHASE)
+				last_good_phase = msm_host->saved_tuning_phase;
+
+			rc = msm_config_cm_dll_phase(host, last_good_phase);
+			if (rc)
+				goto kfree;
+
 			sts_cmd.opcode = MMC_SEND_STATUS;
 			sts_cmd.arg = card->rca << 16;
 			sts_cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -1884,8 +1902,16 @@
 			dev_err(dev, "Invalid clock table\n");
 			goto out;
 		}
+		if (ice_clk_table_len != 2) {
+			dev_err(dev, "Need max and min frequencies in the table\n");
+			goto out;
+		}
 		pdata->sup_ice_clk_table = ice_clk_table;
 		pdata->sup_ice_clk_cnt = ice_clk_table_len;
+		pdata->ice_clk_max = pdata->sup_ice_clk_table[0];
+		pdata->ice_clk_min = pdata->sup_ice_clk_table[1];
+		dev_dbg(dev, "supported ICE clock rates (Hz): max: %u min: %u\n",
+				pdata->ice_clk_max, pdata->ice_clk_min);
 	}
 
 	pdata->vreg_data = devm_kzalloc(dev, sizeof(struct
@@ -3390,6 +3416,8 @@
 	/* registers offset changed starting from 4.2.0 */
 	int offset = minor >= SDHCI_MSM_VER_420 ? 0 : 0x48;
 
+	if (cq_host->offset_changed)
+		offset += CQ_V5_VENDOR_CFG;
 	pr_err("---- Debug RAM dump ----\n");
 	pr_err(DRV_NAME ": Debug RAM wrap-around: 0x%08x | Debug RAM overlap: 0x%08x\n",
 	       cmdq_readl(cq_host, CQ_CMD_DBG_RAM_WA + offset),
@@ -4095,8 +4123,37 @@
 	return max_curr;
 }
 
+static int sdhci_msm_notify_load(struct sdhci_host *host, enum mmc_load state)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = pltfm_host->priv;
+	int ret = 0;
+	u32 clk_rate = 0;
+
+	if (!IS_ERR(msm_host->ice_clk)) {
+		clk_rate = (state == MMC_LOAD_LOW) ?
+			msm_host->pdata->ice_clk_min :
+			msm_host->pdata->ice_clk_max;
+		if (msm_host->ice_clk_rate == clk_rate)
+			return 0;
+		pr_debug("%s: changing ICE clk rate to %u\n",
+				mmc_hostname(host->mmc), clk_rate);
+		ret = clk_set_rate(msm_host->ice_clk, clk_rate);
+		if (ret) {
+			pr_err("%s: ICE_CLK rate set failed (%d) for %u\n",
+				mmc_hostname(host->mmc), ret, clk_rate);
+			return ret;
+		}
+		msm_host->ice_clk_rate = clk_rate;
+	}
+	return 0;
+}
+
 static struct sdhci_ops sdhci_msm_ops = {
 	.crypto_engine_cfg = sdhci_msm_ice_cfg,
+	.crypto_engine_cmdq_cfg = sdhci_msm_ice_cmdq_cfg,
+	.crypto_engine_cfg_end = sdhci_msm_ice_cfg_end,
+	.crypto_cfg_reset = sdhci_msm_ice_cfg_reset,
 	.crypto_engine_reset = sdhci_msm_ice_reset,
 	.set_uhs_signaling = sdhci_msm_set_uhs_signaling,
 	.check_power_status = sdhci_msm_check_power_status,
@@ -4119,6 +4176,7 @@
 	.pre_req = sdhci_msm_pre_req,
 	.post_req = sdhci_msm_post_req,
 	.get_current_limit = sdhci_msm_get_current_limit,
+	.notify_load = sdhci_msm_notify_load,
 };
 
 static void sdhci_set_default_hw_caps(struct sdhci_msm_host *msm_host,
@@ -4196,7 +4254,7 @@
 	 * starts coming.
 	 */
 	if ((major == 1) && ((minor == 0x42) || (minor == 0x46) ||
-				(minor == 0x49)))
+				(minor == 0x49) || (minor >= 0x6b)))
 		msm_host->use_14lpp_dll = true;
 
 	/* Fake 3.0V support for SDIO devices which requires such voltage */
@@ -4221,8 +4279,10 @@
 	/* keep track of the value in SDHCI_CAPABILITIES */
 	msm_host->caps_0 = caps;
 
-	if ((major == 1) && (minor >= 0x6b))
+	if ((major == 1) && (minor >= 0x6b)) {
 		msm_host->ice_hci_support = true;
+		host->cdr_support = true;
+	}
 }
 
 #ifdef CONFIG_MMC_CQ_HCI
@@ -4289,6 +4349,7 @@
 	struct resource *tlmm_memres = NULL;
 	void __iomem *tlmm_mem;
 	unsigned long flags;
+	bool force_probe;
 
 	pr_debug("%s: Enter %s\n", dev_name(&pdev->dev), __func__);
 	msm_host = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_msm_host),
@@ -4328,7 +4389,7 @@
 		 */
 		dev_err(&pdev->dev, "%s: required ICE device not probed yet err = %d\n",
 			__func__, ret);
-		goto out_host_free;
+		goto pltfm_free;
 
 	} else if (ret == -ENODEV) {
 		/*
@@ -4340,7 +4401,7 @@
 	} else if (ret) {
 		dev_err(&pdev->dev, "%s: sdhci_msm_ice_get_dev failed %d\n",
 			__func__, ret);
-		goto out_host_free;
+		goto pltfm_free;
 	}
 
 	/* Extract platform data */
@@ -4352,8 +4413,13 @@
 			goto pltfm_free;
 		}
 
+		/* Read property to determine if the probe is forced */
+		force_probe = of_find_property(pdev->dev.of_node,
+			"qcom,force-sdhc1-probe", NULL);
+
 		/* skip the probe if eMMC isn't a boot device */
-		if ((ret == 1) && !sdhci_msm_is_bootdevice(&pdev->dev)) {
+		if ((ret == 1) && !sdhci_msm_is_bootdevice(&pdev->dev)
+		    && !force_probe) {
 			ret = -ENODEV;
 			goto pltfm_free;
 		}
@@ -4408,11 +4474,11 @@
 		if (!IS_ERR(msm_host->ice_clk)) {
 			/* ICE core has only one clock frequency for now */
 			ret = clk_set_rate(msm_host->ice_clk,
-					msm_host->pdata->sup_ice_clk_table[0]);
+					msm_host->pdata->ice_clk_max);
 			if (ret) {
 				dev_err(&pdev->dev, "ICE_CLK rate set failed (%d) for %u\n",
 					ret,
-					msm_host->pdata->sup_ice_clk_table[0]);
+					msm_host->pdata->ice_clk_max);
 				goto pclk_disable;
 			}
 			ret = clk_prepare_enable(msm_host->ice_clk);
@@ -4420,7 +4486,7 @@
 				goto pclk_disable;
 
 			msm_host->ice_clk_rate =
-				msm_host->pdata->sup_clk_table[0];
+				msm_host->pdata->ice_clk_max;
 		}
 	}
 
@@ -4518,6 +4584,14 @@
 	writel_relaxed(CORE_VENDOR_SPEC_POR_VAL,
 	host->ioaddr + msm_host_offset->CORE_VENDOR_SPEC);
 
+	/*
+	 * Ensure SDHCI FIFO is enabled by disabling alternative FIFO
+	 */
+	writel_relaxed((readl_relaxed(host->ioaddr +
+			msm_host_offset->CORE_VENDOR_SPEC3) &
+			~CORE_FIFO_ALT_EN), host->ioaddr +
+			msm_host_offset->CORE_VENDOR_SPEC3);
+
 	if (!msm_host->mci_removed) {
 		/* Set HC_MODE_EN bit in HC_MODE register */
 		writel_relaxed(HC_MODE_EN, (msm_host->core_mem + CORE_HC_MODE));
@@ -4914,8 +4988,6 @@
 		if (msm_host->msm_bus_vote.client_handle)
 			sdhci_msm_bus_cancel_work_and_set_vote(host, 0);
 	}
-	trace_sdhci_msm_runtime_suspend(mmc_hostname(host->mmc), 0,
-			ktime_to_us(ktime_sub(ktime_get(), start)));
 
 	if (host->is_crypto_en) {
 		ret = sdhci_msm_ice_suspend(host);
@@ -4923,6 +4995,8 @@
 			pr_err("%s: failed to suspend crypto engine %d\n",
 					mmc_hostname(host->mmc), ret);
 	}
+	trace_sdhci_msm_runtime_suspend(mmc_hostname(host->mmc), 0,
+			ktime_to_us(ktime_sub(ktime_get(), start)));
 	return 0;
 }
 
@@ -5050,7 +5124,7 @@
 }
 
 static const struct dev_pm_ops sdhci_msm_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_msm_suspend, sdhci_msm_resume)
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(sdhci_msm_suspend, sdhci_msm_resume)
 	SET_RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, sdhci_msm_runtime_resume,
 			   NULL)
 	.suspend_noirq = sdhci_msm_suspend_noirq,
@@ -5074,6 +5148,7 @@
 	.driver		= {
 		.name	= "sdhci_msm",
 		.owner	= THIS_MODULE,
+		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_msm_dt_match,
 		.pm	= SDHCI_MSM_PMOPS,
 	},
diff --git a/drivers/mmc/host/sdhci-msm.h b/drivers/mmc/host/sdhci-msm.h
index cdbaaa9..7c0b873 100644
--- a/drivers/mmc/host/sdhci-msm.h
+++ b/drivers/mmc/host/sdhci-msm.h
@@ -151,6 +151,8 @@
 	unsigned char sup_ice_clk_cnt;
 	struct sdhci_msm_pm_qos_data pm_qos_data;
 	bool sdr104_wa;
+	u32 ice_clk_max;
+	u32 ice_clk_min;
 };
 
 struct sdhci_msm_bus_vote {
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index a8b430f..83b84ff 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -31,6 +31,7 @@
 
 #define SDMMC_MC1R	0x204
 #define		SDMMC_MC1R_DDR		BIT(3)
+#define		SDMMC_MC1R_FCD		BIT(7)
 #define SDMMC_CACR	0x230
 #define		SDMMC_CACR_CAPWREN	BIT(0)
 #define		SDMMC_CACR_KEY		(0x46 << 8)
@@ -43,6 +44,15 @@
 	struct clk *mainck;
 };
 
+static void sdhci_at91_set_force_card_detect(struct sdhci_host *host)
+{
+	u8 mc1r;
+
+	mc1r = readb(host->ioaddr + SDMMC_MC1R);
+	mc1r |= SDMMC_MC1R_FCD;
+	writeb(mc1r, host->ioaddr + SDMMC_MC1R);
+}
+
 static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
 {
 	u16 clk;
@@ -112,10 +122,18 @@
 	sdhci_set_uhs_signaling(host, timing);
 }
 
+static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
+{
+	sdhci_reset(host, mask);
+
+	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
+		sdhci_at91_set_force_card_detect(host);
+}
+
 static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
 	.set_clock		= sdhci_at91_set_clock,
 	.set_bus_width		= sdhci_set_bus_width,
-	.reset			= sdhci_reset,
+	.reset			= sdhci_at91_reset,
 	.set_uhs_signaling	= sdhci_at91_set_uhs_signaling,
 	.set_power		= sdhci_at91_set_power,
 };
@@ -322,6 +340,21 @@
 		host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
 	}
 
+	/*
+	 * If the device attached to the MMC bus is not removable, it is safer
+	 * to set the Force Card Detect bit. People often don't connect the
+	 * card detect signal and use this pin for another purpose. If the card
+	 * detect pin is not muxed to SDHCI controller, a default value is
+	 * used. This value can be different from a SoC revision to another
+	 * one. Problems come when this default value is not card present. To
+	 * avoid this case, if the device is non removable then the card
+	 * detection procedure using the SDMCC_CD signal is bypassed.
+	 * This bit is reset when a software reset for all command is performed
+	 * so we need to implement our own reset function to set back this bit.
+	 */
+	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
+		sdhci_at91_set_force_card_detect(host);
+
 	pm_runtime_put_autosuspend(&pdev->dev);
 
 	return 0;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 68e49bb..4476e51 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1785,6 +1785,22 @@
 	return err;
 }
 
+static int sdhci_crypto_cfg_end(struct sdhci_host *host,
+				struct mmc_request *mrq)
+{
+	int err = 0;
+
+	if (host->ops->crypto_engine_cfg_end) {
+		err = host->ops->crypto_engine_cfg_end(host, mrq);
+		if (err) {
+			pr_err("%s: failed to configure crypto\n",
+					mmc_hostname(host->mmc));
+			return err;
+		}
+	}
+	return 0;
+}
+
 static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
 	struct sdhci_host *host;
@@ -2876,6 +2892,7 @@
 	mmiowb();
 	spin_unlock_irqrestore(&host->lock, flags);
 
+	sdhci_crypto_cfg_end(host, mrq);
 	mmc_request_done(host->mmc, mrq);
 
 	return false;
@@ -3088,12 +3105,6 @@
 		 * above in sdhci_cmd_irq().
 		 */
 		if (data_cmd && (data_cmd->flags & MMC_RSP_BUSY)) {
-			if (intmask & SDHCI_INT_DATA_TIMEOUT) {
-				host->data_cmd = NULL;
-				data_cmd->error = -ETIMEDOUT;
-				sdhci_finish_mrq(host, data_cmd->mrq);
-				return;
-			}
 			if (intmask & SDHCI_INT_DATA_END) {
 				host->data_cmd = NULL;
 				/*
@@ -3108,8 +3119,21 @@
 				return;
 			}
 			if (host->quirks2 &
-				SDHCI_QUIRK2_IGNORE_DATATOUT_FOR_R1BCMD)
+				SDHCI_QUIRK2_IGNORE_DATATOUT_FOR_R1BCMD) {
+				pr_err_ratelimited("%s: %s: ignoring interrupt: 0x%08x due to DATATOUT_FOR_R1B quirk\n",
+						mmc_hostname(host->mmc),
+						__func__, intmask);
+				MMC_TRACE(host->mmc,
+					"%s: Quirk ignoring intr: 0x%08x\n",
+						__func__, intmask);
 				return;
+			}
+			if (intmask & SDHCI_INT_DATA_TIMEOUT) {
+				host->data_cmd = NULL;
+				data_cmd->error = -ETIMEDOUT;
+				sdhci_finish_mrq(host, data_cmd->mrq);
+				return;
+			}
 		}
 
 		/*
@@ -3689,7 +3713,7 @@
 			ctrl |= SDHCI_CTRL_ADMA32;
 		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 	}
-	if (host->ops->toggle_cdr)
+	if (host->ops->toggle_cdr && !host->cdr_support)
 		host->ops->toggle_cdr(host, false);
 }
 
@@ -3768,14 +3792,46 @@
 	sdhci_writel(host, SDHCI_INT_RESPONSE, SDHCI_INT_STATUS);
 }
 static int sdhci_cmdq_crypto_cfg(struct mmc_host *mmc,
-		struct mmc_request *mrq, u32 slot)
+		struct mmc_request *mrq, u32 slot, u64 *ice_ctx)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	int err = 0;
+
+	if (!host->is_crypto_en)
+		return 0;
+
+	if (host->crypto_reset_reqd && host->ops->crypto_engine_reset) {
+		err = host->ops->crypto_engine_reset(host);
+		if (err) {
+			pr_err("%s: crypto reset failed\n",
+					mmc_hostname(host->mmc));
+			goto out;
+		}
+		host->crypto_reset_reqd = false;
+	}
+
+	if (host->ops->crypto_engine_cmdq_cfg) {
+		err = host->ops->crypto_engine_cmdq_cfg(host, mrq,
+				slot, ice_ctx);
+		if (err) {
+			pr_err("%s: failed to configure crypto\n",
+					mmc_hostname(host->mmc));
+			goto out;
+		}
+	}
+out:
+	return err;
+}
+
+static int sdhci_cmdq_crypto_cfg_end(struct mmc_host *mmc,
+					struct mmc_request *mrq)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
 
 	if (!host->is_crypto_en)
 		return 0;
 
-	return sdhci_crypto_cfg(host, mrq, slot);
+	return sdhci_crypto_cfg_end(host, mrq);
 }
 
 static void sdhci_cmdq_crypto_cfg_reset(struct mmc_host *mmc, unsigned int slot)
@@ -3835,7 +3891,13 @@
 }
 
 static int sdhci_cmdq_crypto_cfg(struct mmc_host *mmc,
-		struct mmc_request *mrq, u32 slot)
+		struct mmc_request *mrq, u32 slot, u64 *ice_ctx)
+{
+	return 0;
+}
+
+static int sdhci_cmdq_crypto_cfg_end(struct mmc_host *mmc,
+				struct mmc_request *mrq)
 {
 	return 0;
 }
@@ -3856,6 +3918,7 @@
 	.post_cqe_halt = sdhci_cmdq_post_cqe_halt,
 	.set_transfer_params = sdhci_cmdq_set_transfer_params,
 	.crypto_cfg	= sdhci_cmdq_crypto_cfg,
+	.crypto_cfg_end	= sdhci_cmdq_crypto_cfg_end,
 	.crypto_cfg_reset	= sdhci_cmdq_crypto_cfg_reset,
 };
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 04e806c..2b67d0a 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -518,7 +518,7 @@
  * Some controllers may use PIO mode to workaround HW issues in ADMA for
  * eMMC tuning commands.
  */
-#define SDHCI_QUIRK2_USE_PIO_FOR_EMMC_TUNING (1 << 23)
+#define SDHCI_QUIRK2_USE_PIO_FOR_EMMC_TUNING (1 << 29)
 
 
 	int irq;		/* Device IRQ */
@@ -569,6 +569,7 @@
 	bool bus_on;		/* Bus power prevents runtime suspend */
 	bool preset_enabled;	/* Preset is enabled */
 	bool pending_reset;	/* Cmd/data reset is pending */
+	bool cdr_support;
 
 	struct mmc_request *mrqs_done[SDHCI_MAX_MRQS];	/* Requests done */
 	struct mmc_request *mrq;	/* Current request */
@@ -670,6 +671,10 @@
 	int	(*platform_execute_tuning)(struct sdhci_host *host, u32 opcode);
 	int	(*crypto_engine_cfg)(struct sdhci_host *host,
 				struct mmc_request *mrq, u32 slot);
+	int	(*crypto_engine_cmdq_cfg)(struct sdhci_host *host,
+			struct mmc_request *mrq, u32 slot, u64 *ice_ctx);
+	int	(*crypto_engine_cfg_end)(struct sdhci_host *host,
+					struct mmc_request *mrq);
 	int	(*crypto_engine_reset)(struct sdhci_host *host);
 	void	(*crypto_cfg_reset)(struct sdhci_host *host, unsigned int slot);
 	void	(*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs);
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index d7f724b..0c84ee8 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -877,6 +877,8 @@
 	}
 }
 
+#define MXC_V1_ECCBYTES		5
+
 static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section,
 				struct mtd_oob_region *oobregion)
 {
@@ -886,7 +888,7 @@
 		return -ERANGE;
 
 	oobregion->offset = (section * 16) + 6;
-	oobregion->length = nand_chip->ecc.bytes;
+	oobregion->length = MXC_V1_ECCBYTES;
 
 	return 0;
 }
@@ -908,8 +910,7 @@
 			oobregion->length = 4;
 		}
 	} else {
-		oobregion->offset = ((section - 1) * 16) +
-				    nand_chip->ecc.bytes + 6;
+		oobregion->offset = ((section - 1) * 16) + MXC_V1_ECCBYTES + 6;
 		if (section < nand_chip->ecc.steps)
 			oobregion->length = (section * 16) + 6 -
 					    oobregion->offset;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f222f8a..31a6ee3 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -64,8 +64,14 @@
 
 	if (!section) {
 		oobregion->offset = 0;
-		oobregion->length = 4;
+		if (mtd->oobsize == 16)
+			oobregion->length = 4;
+		else
+			oobregion->length = 3;
 	} else {
+		if (mtd->oobsize == 8)
+			return -ERANGE;
+
 		oobregion->offset = 6;
 		oobregion->length = ecc->total - 4;
 	}
@@ -1081,7 +1087,9 @@
 	 * Ensure the timing mode has been changed on the chip side
 	 * before changing timings on the controller side.
 	 */
-	if (chip->onfi_version) {
+	if (chip->onfi_version &&
+	    (le16_to_cpu(chip->onfi_params.opt_cmd) &
+	     ONFI_OPT_CMD_SET_GET_FEATURES)) {
 		u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
 			chip->onfi_timing_mode_default,
 		};
diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 57d483a..6f0fd15 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -109,7 +109,11 @@
 #define	READ_ADDR			0
 
 /* NAND_DEV_CMD_VLD bits */
-#define	READ_START_VLD			0
+#define	READ_START_VLD			BIT(0)
+#define	READ_STOP_VLD			BIT(1)
+#define	WRITE_START_VLD			BIT(2)
+#define	ERASE_START_VLD			BIT(3)
+#define	SEQ_READ_START_VLD		BIT(4)
 
 /* NAND_EBI2_ECC_BUF_CFG bits */
 #define	NUM_STEPS			0
@@ -148,6 +152,10 @@
 #define	FETCH_ID			0xb
 #define	RESET_DEVICE			0xd
 
+/* Default Value for NAND_DEV_CMD_VLD */
+#define NAND_DEV_CMD_VLD_VAL		(READ_START_VLD | WRITE_START_VLD | \
+					 ERASE_START_VLD | SEQ_READ_START_VLD)
+
 /*
  * the NAND controller performs reads/writes with ECC in 516 byte chunks.
  * the driver calls the chunks 'step' or 'codeword' interchangeably
@@ -672,8 +680,7 @@
 
 	/* configure CMD1 and VLD for ONFI param probing */
 	nandc_set_reg(nandc, NAND_DEV_CMD_VLD,
-		      (nandc->vld & ~(1 << READ_START_VLD))
-		      | 0 << READ_START_VLD);
+		      (nandc->vld & ~READ_START_VLD));
 	nandc_set_reg(nandc, NAND_DEV_CMD1,
 		      (nandc->cmd1 & ~(0xFF << READ_ADDR))
 		      | NAND_CMD_PARAM << READ_ADDR);
@@ -1893,7 +1900,7 @@
 				| wide_bus << WIDE_FLASH
 				| 1 << DEV0_CFG1_ECC_DISABLE;
 
-	host->ecc_bch_cfg = host->bch_enabled << ECC_CFG_ECC_DISABLE
+	host->ecc_bch_cfg = !host->bch_enabled << ECC_CFG_ECC_DISABLE
 				| 0 << ECC_SW_RESET
 				| host->cw_data << ECC_NUM_DATA_BYTES
 				| 1 << ECC_FORCE_CLK_OPEN
@@ -1972,13 +1979,14 @@
 {
 	/* kill onenand */
 	nandc_write(nandc, SFLASHC_BURST_CFG, 0);
+	nandc_write(nandc, NAND_DEV_CMD_VLD, NAND_DEV_CMD_VLD_VAL);
 
 	/* enable ADM DMA */
 	nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
 
 	/* save the original values of these registers */
 	nandc->cmd1 = nandc_read(nandc, NAND_DEV_CMD1);
-	nandc->vld = nandc_read(nandc, NAND_DEV_CMD_VLD);
+	nandc->vld = NAND_DEV_CMD_VLD_VAL;
 
 	return 0;
 }
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 947adda..3ec573c 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1558,6 +1558,7 @@
 		.dev_name = "BCM53125",
 		.vlans = 4096,
 		.enabled_ports = 0xff,
+		.arl_entries = 4,
 		.cpu_port = B53_CPU_PORT,
 		.vta_regs = B53_VTA_REGS,
 		.duplex_reg = B53_DUPLEX_STAT_GE,
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
index e078d8d..29d29af 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -609,7 +609,7 @@
 		mac_mode |= HALF_DUPLEX;
 
 	if (gigabit) {
-		if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII)
+		if (phy_interface_is_rgmii(dev->phydev))
 			mac_mode |= RGMII_MODE;
 
 		mac_mode |= GMAC_MODE;
@@ -1277,11 +1277,10 @@
 		break;
 
 	case PHY_INTERFACE_MODE_RGMII:
-		pad_mode = PAD_MODE_RGMII;
-		break;
-
+	case PHY_INTERFACE_MODE_RGMII_ID:
+	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
-		pad_mode = PAD_MODE_RGMII | PAD_MODE_GTX_CLK_DELAY;
+		pad_mode = PAD_MODE_RGMII;
 		break;
 
 	default:
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index a927a73..edae2dc 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8720,11 +8720,14 @@
 	tg3_mem_rx_release(tp);
 	tg3_mem_tx_release(tp);
 
+	/* Protect tg3_get_stats64() from reading freed tp->hw_stats. */
+	tg3_full_lock(tp, 0);
 	if (tp->hw_stats) {
 		dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats),
 				  tp->hw_stats, tp->stats_mapping);
 		tp->hw_stats = NULL;
 	}
+	tg3_full_unlock(tp);
 }
 
 /*
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index e813951..9e073fb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -317,12 +317,12 @@
 
 	if (v != MBOX_OWNER_DRV) {
 		ret = (v == MBOX_OWNER_FW) ? -EBUSY : -ETIMEDOUT;
-		t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
+		t4_record_mbox(adap, cmd, size, access, ret);
 		return ret;
 	}
 
 	/* Copy in the new mailbox command and send it on its way ... */
-	t4_record_mbox(adap, cmd, MBOX_LEN, access, 0);
+	t4_record_mbox(adap, cmd, size, access, 0);
 	for (i = 0; i < size; i += 8)
 		t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
 
@@ -371,7 +371,7 @@
 	}
 
 	ret = (pcie_fw & PCIE_FW_ERR_F) ? -ENXIO : -ETIMEDOUT;
-	t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
+	t4_record_mbox(adap, cmd, size, access, ret);
 	dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
 		*(const u8 *)cmd, mbox);
 	t4_report_fw_error(adap);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index b3c9cbe..5626908 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5186,7 +5186,9 @@
 	    skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
 	    skb->inner_protocol != htons(ETH_P_TEB) ||
 	    skb_inner_mac_header(skb) - skb_transport_header(skb) !=
-	    sizeof(struct udphdr) + sizeof(struct vxlanhdr))
+		sizeof(struct udphdr) + sizeof(struct vxlanhdr) ||
+	    !adapter->vxlan_port ||
+	    udp_hdr(skb)->dest != adapter->vxlan_port)
 		return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
 
 	return features;
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 736db9d..81021f8 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -622,6 +622,9 @@
 		goto no_mem;
 	}
 
+	pdev->dev.of_node = node;
+	pdev->dev.parent = priv->dev;
+
 	ret = platform_device_add_data(pdev, &data, sizeof(data));
 	if (ret)
 		goto err;
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 3f4e711..fd20688 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3690,7 +3690,7 @@
 		u32 tempval1 = gfar_read(&regs->maccfg1);
 		u32 tempval = gfar_read(&regs->maccfg2);
 		u32 ecntrl = gfar_read(&regs->ecntrl);
-		u32 tx_flow_oldval = (tempval & MACCFG1_TX_FLOW);
+		u32 tx_flow_oldval = (tempval1 & MACCFG1_TX_FLOW);
 
 		if (phydev->duplex != priv->oldduplex) {
 			if (!(phydev->duplex))
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 5d48458..bcbb80f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -724,16 +724,21 @@
  * header, the HW adds it. To address that, we are subtracting the pseudo
  * header checksum from the checksum value provided by the HW.
  */
-static void get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
-				struct iphdr *iph)
+static int get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
+			       struct iphdr *iph)
 {
 	__u16 length_for_csum = 0;
 	__wsum csum_pseudo_header = 0;
+	__u8 ipproto = iph->protocol;
+
+	if (unlikely(ipproto == IPPROTO_SCTP))
+		return -1;
 
 	length_for_csum = (be16_to_cpu(iph->tot_len) - (iph->ihl << 2));
 	csum_pseudo_header = csum_tcpudp_nofold(iph->saddr, iph->daddr,
-						length_for_csum, iph->protocol, 0);
+						length_for_csum, ipproto, 0);
 	skb->csum = csum_sub(hw_checksum, csum_pseudo_header);
+	return 0;
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
@@ -744,17 +749,20 @@
 static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
 			       struct ipv6hdr *ipv6h)
 {
+	__u8 nexthdr = ipv6h->nexthdr;
 	__wsum csum_pseudo_hdr = 0;
 
-	if (unlikely(ipv6h->nexthdr == IPPROTO_FRAGMENT ||
-		     ipv6h->nexthdr == IPPROTO_HOPOPTS))
+	if (unlikely(nexthdr == IPPROTO_FRAGMENT ||
+		     nexthdr == IPPROTO_HOPOPTS ||
+		     nexthdr == IPPROTO_SCTP))
 		return -1;
-	hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(ipv6h->nexthdr));
+	hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(nexthdr));
 
 	csum_pseudo_hdr = csum_partial(&ipv6h->saddr,
 				       sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0);
 	csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ipv6h->payload_len);
-	csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ntohs(ipv6h->nexthdr));
+	csum_pseudo_hdr = csum_add(csum_pseudo_hdr,
+				   (__force __wsum)htons(nexthdr));
 
 	skb->csum = csum_sub(hw_checksum, csum_pseudo_hdr);
 	skb->csum = csum_add(skb->csum, csum_partial(ipv6h, sizeof(struct ipv6hdr), 0));
@@ -777,11 +785,10 @@
 	}
 
 	if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV4))
-		get_fixed_ipv4_csum(hw_checksum, skb, hdr);
+		return get_fixed_ipv4_csum(hw_checksum, skb, hdr);
 #if IS_ENABLED(CONFIG_IPV6)
-	else if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
-		if (unlikely(get_fixed_ipv6_csum(hw_checksum, skb, hdr)))
-			return -1;
+	if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
+		return get_fixed_ipv6_csum(hw_checksum, skb, hdr);
 #endif
 	return 0;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
index 2a9dd46..e1f9e7c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
@@ -118,8 +118,13 @@
 	if (!buf)
 		return -ENOMEM;
 
+	if (offset_in_page(buf)) {
+		dma_free_coherent(dev, PAGE_SIZE << order,
+				  buf, sg_dma_address(mem));
+		return -ENOMEM;
+	}
+
 	sg_set_buf(mem, buf, PAGE_SIZE << order);
-	BUG_ON(mem->offset);
 	sg_dma_len(mem) = PAGE_SIZE << order;
 	return 0;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index b2ca8a6..ba652d8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -42,6 +42,7 @@
 #include <linux/io-mapping.h>
 #include <linux/delay.h>
 #include <linux/kmod.h>
+#include <linux/etherdevice.h>
 #include <net/devlink.h>
 
 #include <linux/mlx4/device.h>
@@ -429,7 +430,7 @@
 		/* Virtual PCI function needs to determine UAR page size from
 		 * firmware. Only master PCI function can set the uar page size
 		 */
-		if (enable_4k_uar)
+		if (enable_4k_uar || !dev->persist->num_vfs)
 			dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT;
 		else
 			dev->uar_page_shift = PAGE_SHIFT;
@@ -782,6 +783,23 @@
 }
 EXPORT_SYMBOL(mlx4_is_slave_active);
 
+void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
+				       struct _rule_hw *eth_header)
+{
+	if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
+	    is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
+		struct mlx4_net_trans_rule_hw_eth *eth =
+			(struct mlx4_net_trans_rule_hw_eth *)eth_header;
+		struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
+		bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
+			next_rule->rsvd == 0;
+
+		if (last_rule)
+			ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
+	}
+}
+EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
+
 static void slave_adjust_steering_mode(struct mlx4_dev *dev,
 				       struct mlx4_dev_cap *dev_cap,
 				       struct mlx4_init_hca_param *hca_param)
@@ -2251,7 +2269,7 @@
 
 		dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
 
-		if (enable_4k_uar) {
+		if (enable_4k_uar || !dev->persist->num_vfs) {
 			init_hca.log_uar_sz = ilog2(dev->caps.num_uars) +
 						    PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT;
 			init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12;
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 32f76bf..1822382 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -4165,22 +4165,6 @@
 	return 0;
 }
 
-static void handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
-					 struct _rule_hw *eth_header)
-{
-	if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
-	    is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
-		struct mlx4_net_trans_rule_hw_eth *eth =
-			(struct mlx4_net_trans_rule_hw_eth *)eth_header;
-		struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
-		bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
-			next_rule->rsvd == 0;
-
-		if (last_rule)
-			ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
-	}
-}
-
 /*
  * In case of missing eth header, append eth header with a MAC address
  * assigned to the VF.
@@ -4364,10 +4348,7 @@
 	header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
 
 	if (header_id == MLX4_NET_TRANS_RULE_ID_ETH)
-		handle_eth_header_mcast_prio(ctrl, rule_header);
-
-	if (slave == dev->caps.function)
-		goto execute;
+		mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
 
 	switch (header_id) {
 	case MLX4_NET_TRANS_RULE_ID_ETH:
@@ -4395,7 +4376,6 @@
 		goto err_put_qp;
 	}
 
-execute:
 	err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
 			   vhcr->in_modifier, 0,
 			   MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
@@ -4474,6 +4454,7 @@
 	struct res_qp *rqp;
 	struct res_fs_rule *rrule;
 	u64 mirr_reg_id;
+	int qpn;
 
 	if (dev->caps.steering_mode !=
 	    MLX4_STEERING_MODE_DEVICE_MANAGED)
@@ -4490,10 +4471,11 @@
 	}
 	mirr_reg_id = rrule->mirr_rule_id;
 	kfree(rrule->mirr_mbox);
+	qpn = rrule->qpn;
 
 	/* Release the rule form busy state before removal */
 	put_res(dev, slave, vhcr->in_param, RES_FS_RULE);
-	err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp);
+	err = get_res(dev, slave, qpn, RES_QP, &rqp);
 	if (err)
 		return err;
 
@@ -4518,7 +4500,7 @@
 	if (!err)
 		atomic_dec(&rqp->ref_count);
 out:
-	put_res(dev, slave, rrule->qpn, RES_QP);
+	put_res(dev, slave, qpn, RES_QP);
 	return err;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index cb45390..f7fabec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -770,6 +770,10 @@
 	mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
 }
 
+static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg);
+static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
+			      struct mlx5_cmd_msg *msg);
+
 static void cmd_work_handler(struct work_struct *work)
 {
 	struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
@@ -779,16 +783,27 @@
 	struct mlx5_cmd_layout *lay;
 	struct semaphore *sem;
 	unsigned long flags;
+	int alloc_ret;
 
 	sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem;
 	down(sem);
 	if (!ent->page_queue) {
-		ent->idx = alloc_ent(cmd);
-		if (ent->idx < 0) {
+		alloc_ret = alloc_ent(cmd);
+		if (alloc_ret < 0) {
+			if (ent->callback) {
+				ent->callback(-EAGAIN, ent->context);
+				mlx5_free_cmd_msg(dev, ent->out);
+				free_msg(dev, ent->in);
+				free_cmd(ent);
+			} else {
+				ent->ret = -EAGAIN;
+				complete(&ent->done);
+			}
 			mlx5_core_err(dev, "failed to allocate command entry\n");
 			up(sem);
 			return;
 		}
+		ent->idx = alloc_ret;
 	} else {
 		ent->idx = cmd->max_reg_cmds;
 		spin_lock_irqsave(&cmd->alloc_lock, flags);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
index 13dc388..1612ec0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
@@ -62,12 +62,14 @@
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp,
 						   overflow_work);
+	struct mlx5e_priv *priv = container_of(tstamp, struct mlx5e_priv, tstamp);
 	unsigned long flags;
 
 	write_lock_irqsave(&tstamp->lock, flags);
 	timecounter_read(&tstamp->clock);
 	write_unlock_irqrestore(&tstamp->lock, flags);
-	schedule_delayed_work(&tstamp->overflow_work, tstamp->overflow_period);
+	queue_delayed_work(priv->wq, &tstamp->overflow_work,
+			   msecs_to_jiffies(tstamp->overflow_period * 1000));
 }
 
 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
@@ -263,7 +265,7 @@
 
 	INIT_DELAYED_WORK(&tstamp->overflow_work, mlx5e_timestamp_overflow);
 	if (tstamp->overflow_period)
-		schedule_delayed_work(&tstamp->overflow_work, 0);
+		queue_delayed_work(priv->wq, &tstamp->overflow_work, 0);
 	else
 		mlx5_core_warn(priv->mdev, "invalid overflow period, overflow_work is not scheduled\n");
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index e034dbc..cf070fc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -276,7 +276,7 @@
 
 static bool outer_header_zero(u32 *match_criteria)
 {
-	int size = MLX5_ST_SZ_BYTES(fte_match_param);
+	int size = MLX5_FLD_SZ_BYTES(fte_match_param, outer_headers);
 	char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria,
 					     outer_headers);
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index b08b9e2..52a3810 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -651,9 +651,14 @@
 	int vport;
 	int err;
 
+	/* disable PF RoCE so missed packets don't go through RoCE steering */
+	mlx5_dev_list_lock();
+	mlx5_remove_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
+	mlx5_dev_list_unlock();
+
 	err = esw_create_offloads_fdb_table(esw, nvports);
 	if (err)
-		return err;
+		goto create_fdb_err;
 
 	err = esw_create_offloads_table(esw);
 	if (err)
@@ -672,6 +677,7 @@
 		if (err)
 			goto err_reps;
 	}
+
 	return 0;
 
 err_reps:
@@ -688,6 +694,13 @@
 
 create_ft_err:
 	esw_destroy_offloads_fdb_table(esw);
+
+create_fdb_err:
+	/* enable back PF RoCE */
+	mlx5_dev_list_lock();
+	mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
+	mlx5_dev_list_unlock();
+
 	return err;
 }
 
@@ -704,6 +717,11 @@
 			esw_warn(esw->dev, "Failed setting eswitch back to offloads, err %d\n", err);
 	}
 
+	/* enable back PF RoCE */
+	mlx5_dev_list_lock();
+	mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
+	mlx5_dev_list_unlock();
+
 	return err;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
index b5d5519..0ca4623 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
@@ -157,22 +157,17 @@
 static void mlx5_infer_tx_affinity_mapping(struct lag_tracker *tracker,
 					   u8 *port1, u8 *port2)
 {
-	if (tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP) {
-		if (tracker->netdev_state[0].tx_enabled) {
-			*port1 = 1;
-			*port2 = 1;
-		} else {
-			*port1 = 2;
-			*port2 = 2;
-		}
-	} else {
-		*port1 = 1;
-		*port2 = 2;
-		if (!tracker->netdev_state[0].link_up)
-			*port1 = 2;
-		else if (!tracker->netdev_state[1].link_up)
-			*port2 = 1;
+	*port1 = 1;
+	*port2 = 2;
+	if (!tracker->netdev_state[0].tx_enabled ||
+	    !tracker->netdev_state[0].link_up) {
+		*port1 = 2;
+		return;
 	}
+
+	if (!tracker->netdev_state[1].tx_enabled ||
+	    !tracker->netdev_state[1].link_up)
+		*port2 = 1;
 }
 
 static void mlx5_activate_lag(struct mlx5_lag *ldev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index f902c4d..1806b1f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4172,6 +4172,8 @@
 			return -EINVAL;
 		if (!info->linking)
 			break;
+		if (netdev_has_any_upper_dev(upper_dev))
+			return -EINVAL;
 		/* HW limitation forbids to put ports to multiple bridges. */
 		if (netif_is_bridge_master(upper_dev) &&
 		    !mlxsw_sp_master_bridge_check(mlxsw_sp, upper_dev))
@@ -4185,6 +4187,10 @@
 		if (netif_is_lag_port(dev) && is_vlan_dev(upper_dev) &&
 		    !netif_is_lag_master(vlan_dev_real_dev(upper_dev)))
 			return -EINVAL;
+		if (!info->linking)
+			break;
+		if (netdev_has_any_upper_dev(upper_dev))
+			return -EINVAL;
 		break;
 	case NETDEV_CHANGEUPPER:
 		upper_dev = info->upper_dev;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index aee3fd2..4ca82bd 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -871,8 +871,7 @@
 	return NETDEV_TX_OK;
 
 err_unmap:
-	--f;
-	while (f >= 0) {
+	while (--f >= 0) {
 		frag = &skb_shinfo(skb)->frags[f];
 		dma_unmap_page(&nn->pdev->dev,
 			       tx_ring->txbufs[wr_idx].dma_addr,
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
index 829be21..be258d9 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
@@ -724,7 +724,7 @@
 	seg_hdr->cookie = MPI_COREDUMP_COOKIE;
 	seg_hdr->segNum = seg_number;
 	seg_hdr->segSize = seg_size;
-	memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
+	strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
 }
 
 /*
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index bf000d8..2c4350a 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -326,6 +326,7 @@
 static const struct pci_device_id rtl8169_pci_tbl[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8129), 0, 0, RTL_CFG_0 },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8136), 0, 0, RTL_CFG_2 },
+	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8161), 0, 0, RTL_CFG_1 },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8167), 0, 0, RTL_CFG_0 },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8168), 0, 0, RTL_CFG_1 },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	0x8169), 0, 0, RTL_CFG_0 },
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index a2d218b..2140ded 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -574,6 +574,7 @@
 	.rpadir_value   = 2 << 16,
 	.no_trimd	= 1,
 	.no_ade		= 1,
+	.hw_crc		= 1,
 	.tsu		= 1,
 	.select_mii	= 1,
 	.shift_rd0	= 1,
@@ -802,7 +803,7 @@
 
 	.ecsr_value	= ECSR_ICD | ECSR_MPD,
 	.ecsipr_value	= ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
-	.eesipr_value	= DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
+	.eesipr_value	= DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
 
 	.tx_check	= EESR_TC1 | EESR_FTC,
 	.eesr_err_check	= EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
@@ -819,6 +820,7 @@
 	.tsu		= 1,
 	.hw_crc		= 1,
 	.select_mii	= 1,
+	.shift_rd0	= 1,
 };
 
 /* SH7763 */
@@ -831,7 +833,7 @@
 
 	.ecsr_value	= ECSR_ICD | ECSR_MPD,
 	.ecsipr_value	= ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
-	.eesipr_value	= DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
+	.eesipr_value	= DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
 
 	.tx_check	= EESR_TC1 | EESR_FTC,
 	.eesr_err_check	= EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index ff038e5..36a04e1 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1084,7 +1084,12 @@
 	bool notify = false, reschedule = false;
 	unsigned long flags, next_reconfig, delay;
 
-	rtnl_lock();
+	/* if changes are happening, comeback later */
+	if (!rtnl_trylock()) {
+		schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
+		return;
+	}
+
 	if (ndev_ctx->start_remove)
 		goto out_unlock;
 
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index bca6a1e..e1bb802 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -141,9 +141,19 @@
 static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val)
 {
 	struct usb_device *dev = mcs->usbdev;
-	int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
-				  MCS_RD_RTYPE, 0, reg, val, 2,
-				  msecs_to_jiffies(MCS_CTRL_TIMEOUT));
+	void *dmabuf;
+	int ret;
+
+	dmabuf = kmalloc(sizeof(__u16), GFP_KERNEL);
+	if (!dmabuf)
+		return -ENOMEM;
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
+			      MCS_RD_RTYPE, 0, reg, dmabuf, 2,
+			      msecs_to_jiffies(MCS_CTRL_TIMEOUT));
+
+	memcpy(val, dmabuf, sizeof(__u16));
+	kfree(dmabuf);
 
 	return ret;
 }
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index a5d66e2..2caac0c 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3510,6 +3510,7 @@
 module_exit(macsec_exit);
 
 MODULE_ALIAS_RTNL_LINK("macsec");
+MODULE_ALIAS_GENL_FAMILY("macsec");
 
 MODULE_DESCRIPTION("MACsec IEEE 802.1AE");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 4cad955..01cf094 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -29,6 +29,7 @@
 #define MII_DP83867_MICR	0x12
 #define MII_DP83867_ISR		0x13
 #define DP83867_CTRL		0x1f
+#define DP83867_CFG3		0x1e
 
 /* Extended Registers */
 #define DP83867_RGMIICTL	0x0032
@@ -90,6 +91,8 @@
 		micr_status |=
 			(MII_DP83867_MICR_AN_ERR_INT_EN |
 			MII_DP83867_MICR_SPEED_CHNG_INT_EN |
+			MII_DP83867_MICR_AUTONEG_COMP_INT_EN |
+			MII_DP83867_MICR_LINK_STS_CHNG_INT_EN |
 			MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN |
 			MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN);
 
@@ -190,6 +193,13 @@
 				       DP83867_DEVADDR, delay);
 	}
 
+	/* Enable Interrupt output INT_OE in CFG3 register */
+	if (phy_interrupt_is_valid(phydev)) {
+		val = phy_read(phydev, DP83867_CFG3);
+		val |= BIT(7);
+		phy_write(phydev, DP83867_CFG3, val);
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index edd30eb..6e12401 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1060,6 +1060,15 @@
 			if (old_link != phydev->link)
 				phydev->state = PHY_CHANGELINK;
 		}
+		/*
+		 * Failsafe: check that nobody set phydev->link=0 between two
+		 * poll cycles, otherwise we won't leave RUNNING state as long
+		 * as link remains down.
+		 */
+		if (!phydev->link && phydev->state == PHY_RUNNING) {
+			phydev->state = PHY_CHANGELINK;
+			phydev_err(phydev, "no link in PHY_RUNNING\n");
+		}
 		break;
 	case PHY_CHANGELINK:
 		err = phy_read_status(phydev);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 32b555a..bf02f8e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1714,6 +1714,8 @@
 {
 	struct phy_device *phydev = to_phy_device(dev);
 
+	cancel_delayed_work_sync(&phydev->state_queue);
+
 	mutex_lock(&phydev->lock);
 	phydev->state = PHY_DOWN;
 	mutex_unlock(&phydev->lock);
@@ -1792,7 +1794,7 @@
 	.phy_id		= 0xffffffff,
 	.phy_id_mask	= 0xffffffff,
 	.name		= "Generic PHY",
-	.soft_reset	= genphy_soft_reset,
+	.soft_reset	= genphy_no_soft_reset,
 	.config_init	= genphy_config_init,
 	.features	= PHY_GBIT_FEATURES | SUPPORTED_MII |
 			  SUPPORTED_AUI | SUPPORTED_FIBRE |
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 5489c0e..96fa0e6 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -119,6 +119,7 @@
 	int		n_channels;	/* how many channels are attached 54 */
 	spinlock_t	rlock;		/* lock for receive side 58 */
 	spinlock_t	wlock;		/* lock for transmit side 5c */
+	int		*xmit_recursion __percpu; /* xmit recursion detect */
 	int		mru;		/* max receive unit 60 */
 	unsigned int	flags;		/* control bits 64 */
 	unsigned int	xstate;		/* transmit state bits 68 */
@@ -1024,6 +1025,7 @@
 	struct ppp *ppp = netdev_priv(dev);
 	int indx;
 	int err;
+	int cpu;
 
 	ppp->dev = dev;
 	ppp->ppp_net = src_net;
@@ -1038,6 +1040,15 @@
 	INIT_LIST_HEAD(&ppp->channels);
 	spin_lock_init(&ppp->rlock);
 	spin_lock_init(&ppp->wlock);
+
+	ppp->xmit_recursion = alloc_percpu(int);
+	if (!ppp->xmit_recursion) {
+		err = -ENOMEM;
+		goto err1;
+	}
+	for_each_possible_cpu(cpu)
+		(*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0;
+
 #ifdef CONFIG_PPP_MULTILINK
 	ppp->minseq = -1;
 	skb_queue_head_init(&ppp->mrq);
@@ -1049,11 +1060,15 @@
 
 	err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set);
 	if (err < 0)
-		return err;
+		goto err2;
 
 	conf->file->private_data = &ppp->file;
 
 	return 0;
+err2:
+	free_percpu(ppp->xmit_recursion);
+err1:
+	return err;
 }
 
 static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = {
@@ -1399,18 +1414,16 @@
 	ppp_xmit_unlock(ppp);
 }
 
-static DEFINE_PER_CPU(int, ppp_xmit_recursion);
-
 static void ppp_xmit_process(struct ppp *ppp)
 {
 	local_bh_disable();
 
-	if (unlikely(__this_cpu_read(ppp_xmit_recursion)))
+	if (unlikely(*this_cpu_ptr(ppp->xmit_recursion)))
 		goto err;
 
-	__this_cpu_inc(ppp_xmit_recursion);
+	(*this_cpu_ptr(ppp->xmit_recursion))++;
 	__ppp_xmit_process(ppp);
-	__this_cpu_dec(ppp_xmit_recursion);
+	(*this_cpu_ptr(ppp->xmit_recursion))--;
 
 	local_bh_enable();
 
@@ -1901,23 +1914,23 @@
 	spin_unlock_bh(&pch->downl);
 	/* see if there is anything from the attached unit to be sent */
 	if (skb_queue_empty(&pch->file.xq)) {
-		read_lock_bh(&pch->upl);
 		ppp = pch->ppp;
 		if (ppp)
 			__ppp_xmit_process(ppp);
-		read_unlock_bh(&pch->upl);
 	}
 }
 
 static void ppp_channel_push(struct channel *pch)
 {
-	local_bh_disable();
-
-	__this_cpu_inc(ppp_xmit_recursion);
-	__ppp_channel_push(pch);
-	__this_cpu_dec(ppp_xmit_recursion);
-
-	local_bh_enable();
+	read_lock_bh(&pch->upl);
+	if (pch->ppp) {
+		(*this_cpu_ptr(pch->ppp->xmit_recursion))++;
+		__ppp_channel_push(pch);
+		(*this_cpu_ptr(pch->ppp->xmit_recursion))--;
+	} else {
+		__ppp_channel_push(pch);
+	}
+	read_unlock_bh(&pch->upl);
 }
 
 /*
@@ -3056,6 +3069,7 @@
 #endif /* CONFIG_PPP_FILTER */
 
 	kfree_skb(ppp->xmit_pending);
+	free_percpu(ppp->xmit_recursion);
 
 	free_netdev(ppp->dev);
 }
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index dc7b639..50737de 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -1369,6 +1369,7 @@
 	.probe =	usbnet_probe,
 	.suspend =	asix_suspend,
 	.resume =	asix_resume,
+	.reset_resume =	asix_resume,
 	.disconnect =	usbnet_disconnect,
 	.supports_autosuspend = 1,
 	.disable_hub_initiated_lpm = 1,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 2f260c6..49a27dc 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -876,6 +876,7 @@
 	{QMI_FIXED_INTF(0x19d2, 0x1428, 2)},	/* Telewell TW-LTE 4G v2 */
 	{QMI_FIXED_INTF(0x19d2, 0x2002, 4)},	/* ZTE (Vodafone) K3765-Z */
 	{QMI_FIXED_INTF(0x2001, 0x7e19, 4)},	/* D-Link DWM-221 B1 */
+	{QMI_FIXED_INTF(0x2001, 0x7e35, 4)},	/* D-Link DWM-222 */
 	{QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
 	{QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
 	{QMI_FIXED_INTF(0x1199, 0x68a2, 8)},	/* Sierra Wireless MC7710 in QMI mode */
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 972b5e2..366d3dc 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1852,6 +1852,12 @@
 		goto err_wmi_detach;
 	}
 
+	/* If firmware indicates Full Rx Reorder support it must be used in a
+	 * slightly different manner. Let HTT code know.
+	 */
+	ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
+						ar->wmi.svc_map));
+
 	status = ath10k_htt_rx_alloc(&ar->htt);
 	if (status) {
 		ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
@@ -1964,12 +1970,6 @@
 		}
 	}
 
-	/* If firmware indicates Full Rx Reorder support it must be used in a
-	 * slightly different manner. Let HTT code know.
-	 */
-	ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
-						ar->wmi.svc_map));
-
 	status = ath10k_htt_rx_ring_refill(ar);
 	if (status) {
 		ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);
diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h
index c9a8bb1..c7956e1 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -660,6 +660,9 @@
 	struct sk_buff *skb;
 	u32 cmd_id;
 
+	if (!ar->wmi.ops->gen_vdev_spectral_conf)
+		return -EOPNOTSUPP;
+
 	skb = ar->wmi.ops->gen_vdev_spectral_conf(ar, arg);
 	if (IS_ERR(skb))
 		return PTR_ERR(skb);
@@ -675,6 +678,9 @@
 	struct sk_buff *skb;
 	u32 cmd_id;
 
+	if (!ar->wmi.ops->gen_vdev_spectral_enable)
+		return -EOPNOTSUPP;
+
 	skb = ar->wmi.ops->gen_vdev_spectral_enable(ar, vdev_id, trigger,
 						    enable);
 	if (IS_ERR(skb))
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index b7fe0af..63754ee 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -807,9 +807,15 @@
 					WLAN_STATUS_SUCCESS, GFP_KERNEL);
 		cfg80211_put_bss(ar->wiphy, bss);
 	} else if (vif->sme_state == SME_CONNECTED) {
+		struct cfg80211_roam_info roam_info = {
+			.bss = bss,
+			.req_ie = assoc_req_ie,
+			.req_ie_len = assoc_req_len,
+			.resp_ie = assoc_resp_ie,
+			.resp_ie_len = assoc_resp_len,
+		};
 		/* inform roam event to cfg80211 */
-		cfg80211_roamed_bss(vif->ndev, bss, assoc_req_ie, assoc_req_len,
-				    assoc_resp_ie, assoc_resp_len, GFP_KERNEL);
+		cfg80211_roamed(vif->ndev, &roam_info, GFP_KERNEL);
 	}
 }
 
diff --git a/drivers/net/wireless/ath/wil6210/Kconfig b/drivers/net/wireless/ath/wil6210/Kconfig
index 0e66348..2ab6c59 100644
--- a/drivers/net/wireless/ath/wil6210/Kconfig
+++ b/drivers/net/wireless/ath/wil6210/Kconfig
@@ -60,3 +60,15 @@
 	---help---
 	  Say Y here to enable wil6210 driver support for MSM
 	  platform specific features
+
+config WIL6210_DEBUGFS
+	bool "wil6210 debugfs support"
+	depends on WIL6210
+	depends on DEBUG_FS
+	default y
+	---help---
+	  Say Y here to enable wil6210 debugfs support, using the
+	  kernel debugfs infrastructure. Select this
+	  option if you are interested in debugging the driver.
+
+	  If unsure, say Y to make it easier to debug problems.
diff --git a/drivers/net/wireless/ath/wil6210/Makefile b/drivers/net/wireless/ath/wil6210/Makefile
index 4874c5b..94df1de 100644
--- a/drivers/net/wireless/ath/wil6210/Makefile
+++ b/drivers/net/wireless/ath/wil6210/Makefile
@@ -4,7 +4,7 @@
 wil6210-y += netdev.o
 wil6210-y += cfg80211.o
 wil6210-y += pcie_bus.o
-wil6210-y += debugfs.o
+wil6210-$(CONFIG_WIL6210_DEBUGFS) += debugfs.o
 wil6210-y += sysfs.o
 wil6210-y += wmi.o
 wil6210-y += interrupt.o
diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 70379c8..e2a459e 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -350,12 +350,12 @@
 
 	wil_dbg_wmi(wil, "Link status for CID %d: {\n"
 		    "  MCS %d TSF 0x%016llx\n"
-		    "  BF status 0x%08x SNR 0x%08x SQI %d%%\n"
+		    "  BF status 0x%08x RSSI %d SQI %d%%\n"
 		    "  Tx Tpt %d goodput %d Rx goodput %d\n"
 		    "  Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n",
 		    cid, le16_to_cpu(reply.evt.bf_mcs),
 		    le64_to_cpu(reply.evt.tsf), reply.evt.status,
-		    le32_to_cpu(reply.evt.snr_val),
+		    reply.evt.rssi,
 		    reply.evt.sqi,
 		    le32_to_cpu(reply.evt.tx_tpt),
 		    le32_to_cpu(reply.evt.tx_goodput),
@@ -389,7 +389,11 @@
 
 	if (test_bit(wil_status_fwconnected, wil->status)) {
 		sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
-		sinfo->signal = reply.evt.sqi;
+		if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING,
+			     wil->fw_capabilities))
+			sinfo->signal = reply.evt.rssi;
+		else
+			sinfo->signal = reply.evt.sqi;
 	}
 
 	return rc;
@@ -450,6 +454,34 @@
 	return rc;
 }
 
+static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
+					 struct wireless_dev *wdev)
+{
+	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+
+	wil_dbg_misc(wil, "start_p2p_device: entered\n");
+	wil->p2p.p2p_dev_started = 1;
+	return 0;
+}
+
+static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
+					 struct wireless_dev *wdev)
+{
+	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+	struct wil_p2p_info *p2p = &wil->p2p;
+
+	if (!p2p->p2p_dev_started)
+		return;
+
+	wil_dbg_misc(wil, "stop_p2p_device: entered\n");
+	mutex_lock(&wil->mutex);
+	mutex_lock(&wil->p2p_wdev_mutex);
+	wil_p2p_stop_radio_operations(wil);
+	p2p->p2p_dev_started = 0;
+	mutex_unlock(&wil->p2p_wdev_mutex);
+	mutex_unlock(&wil->mutex);
+}
+
 static struct wireless_dev *
 wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name,
 		       unsigned char name_assign_type,
@@ -498,6 +530,7 @@
 		return -EINVAL;
 	}
 
+	wil_cfg80211_stop_p2p_device(wiphy, wdev);
 	wil_p2p_wdev_free(wil);
 
 	return 0;
@@ -882,7 +915,7 @@
 		wil->bss = bss;
 		/* Connect can take lots of time */
 		mod_timer(&wil->connect_timer,
-			  jiffies + msecs_to_jiffies(2000));
+			  jiffies + msecs_to_jiffies(5000));
 	} else {
 		clear_bit(wil_status_fwconnecting, wil->status);
 	}
@@ -1732,34 +1765,6 @@
 	return 0;
 }
 
-static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
-					 struct wireless_dev *wdev)
-{
-	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
-
-	wil_dbg_misc(wil, "start_p2p_device: entered\n");
-	wil->p2p.p2p_dev_started = 1;
-	return 0;
-}
-
-static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
-					 struct wireless_dev *wdev)
-{
-	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
-	struct wil_p2p_info *p2p = &wil->p2p;
-
-	if (!p2p->p2p_dev_started)
-		return;
-
-	wil_dbg_misc(wil, "stop_p2p_device: entered\n");
-	mutex_lock(&wil->mutex);
-	mutex_lock(&wil->p2p_wdev_mutex);
-	wil_p2p_stop_radio_operations(wil);
-	p2p->p2p_dev_started = 0;
-	mutex_unlock(&wil->p2p_wdev_mutex);
-	mutex_unlock(&wil->mutex);
-}
-
 static int wil_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 				       struct net_device *dev,
 				       bool enabled, int timeout)
@@ -1797,9 +1802,13 @@
 
 	wil_dbg_pm(wil, "suspending\n");
 
+	mutex_lock(&wil->mutex);
 	wil_p2p_stop_discovery(wil);
 
+	mutex_lock(&wil->p2p_wdev_mutex);
 	wil_abort_scan(wil, true);
+	mutex_unlock(&wil->p2p_wdev_mutex);
+	mutex_unlock(&wil->mutex);
 
 out:
 	return rc;
@@ -1875,7 +1884,7 @@
 
 	wiphy->bands[NL80211_BAND_60GHZ] = &wil_band_60ghz;
 
-	/* TODO: figure this out */
+	/* may change after reading FW capabilities */
 	wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
 
 	wiphy->cipher_suites = wil_cipher_suites;
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index a0a676b..831780a 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -20,7 +20,6 @@
 #include <linux/pci.h>
 #include <linux/rtnetlink.h>
 #include <linux/power_supply.h>
-
 #include "wil6210.h"
 #include "wmi.h"
 #include "txrx.h"
@@ -30,7 +29,6 @@
 static u32 mem_addr;
 static u32 dbg_txdesc_index;
 static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
-u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */
 
 enum dbg_off_type {
 	doff_u32 = 0,
@@ -244,12 +242,19 @@
 static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
 {
 	struct wil6210_priv *wil = s->private;
+	int ret;
+
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
 
 	wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
 		       offsetof(struct wil6210_mbox_ctl, tx));
 	wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
 		       offsetof(struct wil6210_mbox_ctl, rx));
 
+	wil_pm_runtime_put(wil);
+
 	return 0;
 }
 
@@ -267,15 +272,38 @@
 
 static int wil_debugfs_iomem_x32_set(void *data, u64 val)
 {
-	writel(val, (void __iomem *)data);
+	struct wil_debugfs_iomem_data *d = (struct
+					    wil_debugfs_iomem_data *)data;
+	struct wil6210_priv *wil = d->wil;
+	int ret;
+
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
+	writel_relaxed(val, (void __iomem *)d->offset);
+
 	wmb(); /* make sure write propagated to HW */
 
+	wil_pm_runtime_put(wil);
+
 	return 0;
 }
 
 static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
 {
-	*val = readl((void __iomem *)data);
+	struct wil_debugfs_iomem_data *d = (struct
+					    wil_debugfs_iomem_data *)data;
+	struct wil6210_priv *wil = d->wil;
+	int ret;
+
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
+	*val = readl_relaxed((void __iomem *)d->offset);
+
+	wil_pm_runtime_put(wil);
 
 	return 0;
 }
@@ -286,10 +314,21 @@
 static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
 						   umode_t mode,
 						   struct dentry *parent,
-						   void *value)
+						   void *value,
+						   struct wil6210_priv *wil)
 {
-	return debugfs_create_file(name, mode, parent, value,
-				   &fops_iomem_x32);
+	struct dentry *file;
+	struct wil_debugfs_iomem_data *data = &wil->dbg_data.data_arr[
+					      wil->dbg_data.iomem_data_count];
+
+	data->wil = wil;
+	data->offset = value;
+
+	file = debugfs_create_file(name, mode, parent, data, &fops_iomem_x32);
+	if (!IS_ERR_OR_NULL(file))
+		wil->dbg_data.iomem_data_count++;
+
+	return file;
 }
 
 static int wil_debugfs_ulong_set(void *data, u64 val)
@@ -348,7 +387,8 @@
 		case doff_io32:
 			f = wil_debugfs_create_iomem_x32(tbl[i].name,
 							 tbl[i].mode, dbg,
-							 base + tbl[i].off);
+							 base + tbl[i].off,
+							 wil);
 			break;
 		case doff_u8:
 			f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg,
@@ -477,13 +517,22 @@
 static int wil_memread_debugfs_show(struct seq_file *s, void *data)
 {
 	struct wil6210_priv *wil = s->private;
-	void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
+	void __iomem *a;
+	int ret;
+
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
+	a = wmi_buffer(wil, cpu_to_le32(mem_addr));
 
 	if (a)
 		seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, readl(a));
 	else
 		seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
 
+	wil_pm_runtime_put(wil);
+
 	return 0;
 }
 
@@ -504,10 +553,12 @@
 {
 	enum { max_count = 4096 };
 	struct wil_blob_wrapper *wil_blob = file->private_data;
+	struct wil6210_priv *wil = wil_blob->wil;
 	loff_t pos = *ppos;
 	size_t available = wil_blob->blob.size;
 	void *buf;
 	size_t ret;
+	int rc;
 
 	if (test_bit(wil_status_suspending, wil_blob->wil->status) ||
 	    test_bit(wil_status_suspended, wil_blob->wil->status))
@@ -528,10 +579,19 @@
 	if (!buf)
 		return -ENOMEM;
 
+	rc = wil_pm_runtime_get(wil);
+	if (rc < 0) {
+		kfree(buf);
+		return rc;
+	}
+
 	wil_memcpy_fromio_32(buf, (const void __iomem *)
 			     wil_blob->blob.data + pos, count);
 
 	ret = copy_to_user(user_buf, buf, count);
+
+	wil_pm_runtime_put(wil);
+
 	kfree(buf);
 	if (ret == count)
 		return -EFAULT;
@@ -1021,6 +1081,7 @@
 			   "  TSF = 0x%016llx\n"
 			   "  TxMCS = %2d TxTpt = %4d\n"
 			   "  SQI = %4d\n"
+			   "  RSSI = %4d\n"
 			   "  Status = 0x%08x %s\n"
 			   "  Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
 			   "  Goodput(rx:tx) %4d:%4d\n"
@@ -1030,6 +1091,7 @@
 			   le16_to_cpu(reply.evt.bf_mcs),
 			   le32_to_cpu(reply.evt.tx_tpt),
 			   reply.evt.sqi,
+			   reply.evt.rssi,
 			   status, wil_bfstatus_str(status),
 			   le16_to_cpu(reply.evt.my_rx_sector),
 			   le16_to_cpu(reply.evt.my_tx_sector),
@@ -1620,6 +1682,8 @@
 	struct wil6210_priv *wil = file->private_data;
 
 	memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
+	wil->suspend_stats.min_suspend_time = ULONG_MAX;
+	wil->suspend_stats.collection_start = ktime_get();
 
 	return len;
 }
@@ -1631,18 +1695,27 @@
 	struct wil6210_priv *wil = file->private_data;
 	static char text[400];
 	int n;
+	unsigned long long stats_collection_time =
+		ktime_to_us(ktime_sub(ktime_get(),
+				      wil->suspend_stats.collection_start));
 
 	n = snprintf(text, sizeof(text),
 		     "Suspend statistics:\n"
 		     "successful suspends:%ld failed suspends:%ld\n"
 		     "successful resumes:%ld failed resumes:%ld\n"
-		     "rejected by host:%ld rejected by device:%ld\n",
+		     "rejected by host:%ld rejected by device:%ld\n"
+		     "total suspend time:%lld min suspend time:%lld\n"
+		     "max suspend time:%lld stats collection time: %lld\n",
 		     wil->suspend_stats.successful_suspends,
 		     wil->suspend_stats.failed_suspends,
 		     wil->suspend_stats.successful_resumes,
 		     wil->suspend_stats.failed_resumes,
 		     wil->suspend_stats.rejected_by_host,
-		     wil->suspend_stats.rejected_by_device);
+		     wil->suspend_stats.rejected_by_device,
+		     wil->suspend_stats.total_suspend_time,
+		     wil->suspend_stats.min_suspend_time,
+		     wil->suspend_stats.max_suspend_time,
+		     stats_collection_time);
 
 	n = min_t(int, n, sizeof(text));
 
@@ -1755,6 +1828,7 @@
 	WIL_FIELD(chip_revision, 0444,	doff_u8),
 	WIL_FIELD(abft_len, 0644,		doff_u8),
 	WIL_FIELD(wakeup_trigger, 0644,		doff_u8),
+	WIL_FIELD(vring_idle_trsh, 0644,	doff_u32),
 	{},
 };
 
@@ -1770,12 +1844,17 @@
 	{"desc_index",	0644, (ulong)&dbg_txdesc_index, doff_u32},
 	{"vring_index",	0644, (ulong)&dbg_vring_index, doff_u32},
 	{"mem_addr",	0644, (ulong)&mem_addr, doff_u32},
-	{"vring_idle_trsh", 0644, (ulong)&vring_idle_trsh,
-	 doff_u32},
 	{"led_polarity", 0644, (ulong)&led_polarity, doff_u8},
 	{},
 };
 
+static const int dbg_off_count = 4 * (ARRAY_SIZE(isr_off) - 1) +
+				ARRAY_SIZE(dbg_wil_regs) - 1 +
+				ARRAY_SIZE(pseudo_isr_off) - 1 +
+				ARRAY_SIZE(lgc_itr_cnt_off) - 1 +
+				ARRAY_SIZE(tx_itr_cnt_off) - 1 +
+				ARRAY_SIZE(rx_itr_cnt_off) - 1;
+
 int wil6210_debugfs_init(struct wil6210_priv *wil)
 {
 	struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
@@ -1784,6 +1863,17 @@
 	if (IS_ERR_OR_NULL(dbg))
 		return -ENODEV;
 
+	wil->dbg_data.data_arr = kcalloc(dbg_off_count,
+					 sizeof(struct wil_debugfs_iomem_data),
+					 GFP_KERNEL);
+	if (!wil->dbg_data.data_arr) {
+		debugfs_remove_recursive(dbg);
+		wil->debug = NULL;
+		return -ENOMEM;
+	}
+
+	wil->dbg_data.iomem_data_count = 0;
+
 	wil_pmc_init(wil);
 
 	wil6210_debugfs_init_files(wil, dbg);
@@ -1798,6 +1888,8 @@
 
 	wil6210_debugfs_create_ITR_CNT(wil, dbg);
 
+	wil->suspend_stats.collection_start = ktime_get();
+
 	return 0;
 }
 
@@ -1806,6 +1898,8 @@
 	debugfs_remove_recursive(wil->debug);
 	wil->debug = NULL;
 
+	kfree(wil->dbg_data.data_arr);
+
 	/* free pmc memory without sending command to fw, as it will
 	 * be reset on the way down anyway
 	 */
diff --git a/drivers/net/wireless/ath/wil6210/ethtool.c b/drivers/net/wireless/ath/wil6210/ethtool.c
index adcfef4..66200f6 100644
--- a/drivers/net/wireless/ath/wil6210/ethtool.c
+++ b/drivers/net/wireless/ath/wil6210/ethtool.c
@@ -47,9 +47,14 @@
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
 	u32 tx_itr_en, tx_itr_val = 0;
 	u32 rx_itr_en, rx_itr_val = 0;
+	int ret;
 
 	wil_dbg_misc(wil, "ethtoolops_get_coalesce\n");
 
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
 	tx_itr_en = wil_r(wil, RGF_DMA_ITR_TX_CNT_CTL);
 	if (tx_itr_en & BIT_DMA_ITR_TX_CNT_CTL_EN)
 		tx_itr_val = wil_r(wil, RGF_DMA_ITR_TX_CNT_TRSH);
@@ -58,6 +63,8 @@
 	if (rx_itr_en & BIT_DMA_ITR_RX_CNT_CTL_EN)
 		rx_itr_val = wil_r(wil, RGF_DMA_ITR_RX_CNT_TRSH);
 
+	wil_pm_runtime_put(wil);
+
 	cp->tx_coalesce_usecs = tx_itr_val;
 	cp->rx_coalesce_usecs = rx_itr_val;
 	return 0;
@@ -67,6 +74,7 @@
 				       struct ethtool_coalesce *cp)
 {
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
+	int ret;
 
 	wil_dbg_misc(wil, "ethtoolops_set_coalesce: rx %d usec, tx %d usec\n",
 		     cp->rx_coalesce_usecs, cp->tx_coalesce_usecs);
@@ -86,8 +94,15 @@
 
 	wil->tx_max_burst_duration = cp->tx_coalesce_usecs;
 	wil->rx_max_burst_duration = cp->rx_coalesce_usecs;
+
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
 	wil_configure_interrupt_moderation(wil);
 
+	wil_pm_runtime_put(wil);
+
 	return 0;
 
 out_bad:
diff --git a/drivers/net/wireless/ath/wil6210/ftm.c b/drivers/net/wireless/ath/wil6210/ftm.c
index f94c894..6de8e0e 100644
--- a/drivers/net/wireless/ath/wil6210/ftm.c
+++ b/drivers/net/wireless/ath/wil6210/ftm.c
@@ -683,6 +683,10 @@
 	int data_len = len - offsetof(struct wmi_aoa_meas_event, meas_data);
 	struct wil_aoa_meas_result *res;
 
+	if (data_len < 0) {
+		wil_err(wil, "AOA event too short (%d)\n", len);
+		return;
+	}
 	data_len = min_t(int, le16_to_cpu(evt->length), data_len);
 
 	res = kmalloc(sizeof(*res) + data_len, GFP_KERNEL);
diff --git a/drivers/net/wireless/ath/wil6210/fw_inc.c b/drivers/net/wireless/ath/wil6210/fw_inc.c
index e01acac..7a33792 100644
--- a/drivers/net/wireless/ath/wil6210/fw_inc.c
+++ b/drivers/net/wireless/ath/wil6210/fw_inc.c
@@ -124,24 +124,19 @@
 	return 0;
 }
 
-static int fw_handle_comment(struct wil6210_priv *wil, const void *data,
-			     size_t size)
-{
-	wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1, data, size, true);
-
-	return 0;
-}
-
 static int
-fw_handle_capabilities(struct wil6210_priv *wil, const void *data,
-		       size_t size)
+fw_handle_comment(struct wil6210_priv *wil, const void *data,
+		  size_t size)
 {
 	const struct wil_fw_record_capabilities *rec = data;
 	size_t capa_size;
 
 	if (size < sizeof(*rec) ||
-	    le32_to_cpu(rec->magic) != WIL_FW_CAPABILITIES_MAGIC)
+	    le32_to_cpu(rec->magic) != WIL_FW_CAPABILITIES_MAGIC) {
+		wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1,
+				data, size, true);
 		return 0;
+	}
 
 	capa_size = size - offsetof(struct wil_fw_record_capabilities,
 				    capabilities);
@@ -422,7 +417,7 @@
 	int (*parse_handler)(struct wil6210_priv *wil, const void *data,
 			     size_t size);
 } wil_fw_handlers[] = {
-	{wil_fw_type_comment, fw_handle_comment, fw_handle_capabilities},
+	{wil_fw_type_comment, fw_handle_comment, fw_handle_comment},
 	{wil_fw_type_data, fw_handle_data, fw_ignore_section},
 	{wil_fw_type_fill, fw_handle_fill, fw_ignore_section},
 	/* wil_fw_type_action */
@@ -517,7 +512,7 @@
 
 	rc = request_firmware(&fw, name, wil_to_dev(wil));
 	if (rc) {
-		wil_err_fw(wil, "Failed to load firmware %s\n", name);
+		wil_err_fw(wil, "Failed to load firmware %s rc %d\n", name, rc);
 		return rc;
 	}
 	wil_dbg_fw(wil, "Loading <%s>, %zu bytes\n", name, fw->size);
diff --git a/drivers/net/wireless/ath/wil6210/interrupt.c b/drivers/net/wireless/ath/wil6210/interrupt.c
index cad8a95c4..59def4f 100644
--- a/drivers/net/wireless/ath/wil6210/interrupt.c
+++ b/drivers/net/wireless/ath/wil6210/interrupt.c
@@ -244,7 +244,7 @@
 	wil_dbg_irq(wil, "ISR RX 0x%08x\n", isr);
 
 	if (unlikely(!isr)) {
-		wil_err(wil, "spurious IRQ: RX\n");
+		wil_err_ratelimited(wil, "spurious IRQ: RX\n");
 		return IRQ_NONE;
 	}
 
@@ -269,11 +269,12 @@
 				need_unmask = false;
 				napi_schedule(&wil->napi_rx);
 			} else {
-				wil_err(wil,
+				wil_err_ratelimited(
+					wil,
 					"Got Rx interrupt while stopping interface\n");
 			}
 		} else {
-			wil_err(wil, "Got Rx interrupt while in reset\n");
+			wil_err_ratelimited(wil, "Got Rx interrupt while in reset\n");
 		}
 	}
 
@@ -302,7 +303,7 @@
 	wil_dbg_irq(wil, "ISR TX 0x%08x\n", isr);
 
 	if (unlikely(!isr)) {
-		wil_err(wil, "spurious IRQ: TX\n");
+		wil_err_ratelimited(wil, "spurious IRQ: TX\n");
 		return IRQ_NONE;
 	}
 
@@ -318,12 +319,13 @@
 			need_unmask = false;
 			napi_schedule(&wil->napi_tx);
 		} else {
-			wil_err(wil, "Got Tx interrupt while in reset\n");
+			wil_err_ratelimited(wil, "Got Tx interrupt while in reset\n");
 		}
 	}
 
 	if (unlikely(isr))
-		wil_err(wil, "un-handled TX ISR bits 0x%08x\n", isr);
+		wil_err_ratelimited(wil, "un-handled TX ISR bits 0x%08x\n",
+				    isr);
 
 	/* Tx IRQ will be enabled when NAPI processing finished */
 
diff --git a/drivers/net/wireless/ath/wil6210/ioctl.c b/drivers/net/wireless/ath/wil6210/ioctl.c
index f8d2c20..25bc439 100644
--- a/drivers/net/wireless/ath/wil6210/ioctl.c
+++ b/drivers/net/wireless/ath/wil6210/ioctl.c
@@ -221,6 +221,10 @@
 {
 	int ret;
 
+	ret = wil_pm_runtime_get(wil);
+	if (ret < 0)
+		return ret;
+
 	switch (cmd) {
 	case WIL_IOCTL_MEMIO:
 		ret = wil_ioc_memio_dword(wil, data);
@@ -233,9 +237,12 @@
 		break;
 	default:
 		wil_dbg_ioctl(wil, "Unsupported IOCTL 0x%04x\n", cmd);
+		wil_pm_runtime_put(wil);
 		return -ENOIOCTLCMD;
 	}
 
+	wil_pm_runtime_put(wil);
+
 	wil_dbg_ioctl(wil, "ioctl(0x%04x) -> %d\n", cmd, ret);
 	return ret;
 }
diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
index aff8b1b..c4faa2c 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -395,10 +395,11 @@
 	struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
 						fw_error_worker);
 	struct wireless_dev *wdev = wil->wdev;
+	struct net_device *ndev = wil_to_ndev(wil);
 
 	wil_dbg_misc(wil, "fw error worker\n");
 
-	if (!netif_running(wil_to_ndev(wil))) {
+	if (!(ndev->flags & IFF_UP)) {
 		wil_info(wil, "No recovery - interface is down\n");
 		return;
 	}
@@ -581,6 +582,9 @@
 
 	wil->wakeup_trigger = WMI_WAKEUP_TRIGGER_UCAST |
 			      WMI_WAKEUP_TRIGGER_BCAST;
+	memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
+	wil->suspend_stats.min_suspend_time = ULONG_MAX;
+	wil->vring_idle_trsh = 16;
 
 	return 0;
 
@@ -761,6 +765,8 @@
 	u8 retry_short;
 	int rc;
 
+	wil_refresh_fw_capabilities(wil);
+
 	rc = wmi_get_mgmt_retry(wil, &retry_short);
 	if (!rc) {
 		wiphy->retry_short = retry_short;
@@ -768,6 +774,25 @@
 	}
 }
 
+void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
+{
+	struct wiphy *wiphy = wil_to_wiphy(wil);
+
+	wil->keep_radio_on_during_sleep =
+		wil->platform_ops.keep_radio_on_during_sleep &&
+		wil->platform_ops.keep_radio_on_during_sleep(
+			wil->platform_handle) &&
+		test_bit(WMI_FW_CAPABILITY_D3_SUSPEND, wil->fw_capabilities);
+
+	wil_info(wil, "keep_radio_on_during_sleep (%d)\n",
+		 wil->keep_radio_on_during_sleep);
+
+	if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
+		wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+	else
+		wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
+}
+
 void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r)
 {
 	le32_to_cpus(&r->base);
@@ -930,6 +955,29 @@
 	return rc;
 }
 
+static void wil_pre_fw_config(struct wil6210_priv *wil)
+{
+	/* Mark FW as loaded from host */
+	wil_s(wil, RGF_USER_USAGE_6, 1);
+
+	/* clear any interrupts which on-card-firmware
+	 * may have set
+	 */
+	wil6210_clear_irq(wil);
+	/* CAF_ICR - clear and mask */
+	/* it is W1C, clear by writing back same value */
+	wil_s(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, ICR), 0);
+	wil_w(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, IMV), ~0);
+	/* clear PAL_UNIT_ICR (potential D0->D3 leftover) */
+	wil_s(wil, RGF_PAL_UNIT_ICR + offsetof(struct RGF_ICR, ICR), 0);
+
+	if (wil->fw_calib_result > 0) {
+		__le32 val = cpu_to_le32(wil->fw_calib_result |
+						(CALIB_RESULT_SIGNATURE << 8));
+		wil_w(wil, RGF_USER_FW_CALIB_RESULT, (u32 __force)val);
+	}
+}
+
 /*
  * We reset all the structures, and we reset the UMAC.
  * After calling this routine, you're expected to reload
@@ -1027,18 +1075,7 @@
 		if (rc)
 			return rc;
 
-		/* Mark FW as loaded from host */
-		wil_s(wil, RGF_USER_USAGE_6, 1);
-
-		/* clear any interrupts which on-card-firmware
-		 * may have set
-		 */
-		wil6210_clear_irq(wil);
-		/* CAF_ICR - clear and mask */
-		/* it is W1C, clear by writing back same value */
-		wil_s(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, ICR), 0);
-		wil_w(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, IMV), ~0);
-
+		wil_pre_fw_config(wil);
 		wil_release_cpu(wil);
 	}
 
@@ -1064,14 +1101,14 @@
 			return rc;
 		}
 
+		wil_collect_fw_info(wil);
+
 		if (wil->ps_profile != WMI_PS_PROFILE_TYPE_DEFAULT)
 			wil_ps_update(wil, wil->ps_profile);
 
 		if (wil->tt_data_set)
 			wmi_set_tt_cfg(wil, &wil->tt_data);
 
-		wil_collect_fw_info(wil);
-
 		if (wil->platform_ops.notify) {
 			rc = wil->platform_ops.notify(wil->platform_handle,
 						      WIL_PLATFORM_EVT_FW_RDY);
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index d80e7f4..40cd32a 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -26,6 +26,7 @@
 static int wil_open(struct net_device *ndev)
 {
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
+	int rc;
 
 	wil_dbg_misc(wil, "open\n");
 
@@ -35,16 +36,29 @@
 		return -EINVAL;
 	}
 
-	return wil_up(wil);
+	rc = wil_pm_runtime_get(wil);
+	if (rc < 0)
+		return rc;
+
+	rc = wil_up(wil);
+	if (rc)
+		wil_pm_runtime_put(wil);
+
+	return rc;
 }
 
 static int wil_stop(struct net_device *ndev)
 {
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
+	int rc;
 
 	wil_dbg_misc(wil, "stop\n");
 
-	return wil_down(wil);
+	rc = wil_down(wil);
+	if (!rc)
+		wil_pm_runtime_put(wil);
+
+	return rc;
 }
 
 static int wil_change_mtu(struct net_device *ndev, int new_mtu)
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index cf3fadc..663e163 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -21,6 +21,7 @@
 #include <linux/suspend.h>
 #include "wil6210.h"
 #include <linux/rtnetlink.h>
+#include <linux/pm_runtime.h>
 
 static bool use_msi = true;
 module_param(use_msi, bool, 0444);
@@ -84,6 +85,7 @@
 
 	/* extract FW capabilities from file without loading the FW */
 	wil_request_firmware(wil, wil->wil_fw_name, false);
+	wil_refresh_fw_capabilities(wil);
 }
 
 void wil_disable_irq(struct wil6210_priv *wil)
@@ -286,15 +288,6 @@
 	wil_set_capabilities(wil);
 	wil6210_clear_irq(wil);
 
-	wil->keep_radio_on_during_sleep =
-		wil->platform_ops.keep_radio_on_during_sleep &&
-		wil->platform_ops.keep_radio_on_during_sleep(
-			wil->platform_handle) &&
-		test_bit(WMI_FW_CAPABILITY_D3_SUSPEND, wil->fw_capabilities);
-
-	wil_info(wil, "keep_radio_on_during_sleep (%d)\n",
-		 wil->keep_radio_on_during_sleep);
-
 	/* FW should raise IRQ when ready */
 	rc = wil_if_pcie_enable(wil);
 	if (rc) {
@@ -324,6 +317,8 @@
 	wil6210_debugfs_init(wil);
 	wil6210_sysfs_init(wil);
 
+	wil_pm_runtime_allow(wil);
+
 	return 0;
 
 bus_disable:
@@ -356,6 +351,8 @@
 #endif /* CONFIG_PM_SLEEP */
 #endif /* CONFIG_PM */
 
+	wil_pm_runtime_forbid(wil);
+
 	wil6210_sysfs_remove(wil);
 	wil6210_debugfs_remove(wil);
 	rtnl_lock();
@@ -485,10 +482,40 @@
 }
 #endif /* CONFIG_PM_SLEEP */
 
+static int wil6210_pm_runtime_idle(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct wil6210_priv *wil = pci_get_drvdata(pdev);
+
+	wil_dbg_pm(wil, "Runtime idle\n");
+
+	return wil_can_suspend(wil, true);
+}
+
+static int wil6210_pm_runtime_resume(struct device *dev)
+{
+	return wil6210_resume(dev, true);
+}
+
+static int wil6210_pm_runtime_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct wil6210_priv *wil = pci_get_drvdata(pdev);
+
+	if (test_bit(wil_status_suspended, wil->status)) {
+		wil_dbg_pm(wil, "trying to suspend while suspended\n");
+		return 1;
+	}
+
+	return wil6210_suspend(dev, true);
+}
 #endif /* CONFIG_PM */
 
 static const struct dev_pm_ops wil6210_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(wil6210_pm_suspend, wil6210_pm_resume)
+	SET_RUNTIME_PM_OPS(wil6210_pm_runtime_suspend,
+			   wil6210_pm_runtime_resume,
+			   wil6210_pm_runtime_idle)
 };
 
 static struct pci_driver wil6210_driver = {
diff --git a/drivers/net/wireless/ath/wil6210/pm.c b/drivers/net/wireless/ath/wil6210/pm.c
index ce1f384..2ef2f34 100644
--- a/drivers/net/wireless/ath/wil6210/pm.c
+++ b/drivers/net/wireless/ath/wil6210/pm.c
@@ -16,15 +16,27 @@
 
 #include "wil6210.h"
 #include <linux/jiffies.h>
+#include <linux/pm_runtime.h>
+
+#define WIL6210_AUTOSUSPEND_DELAY_MS (1000)
 
 int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
 {
 	int rc = 0;
 	struct wireless_dev *wdev = wil->wdev;
+	struct net_device *ndev = wil_to_ndev(wil);
+	bool wmi_only = test_bit(WMI_FW_CAPABILITY_WMI_ONLY,
+				 wil->fw_capabilities);
 
 	wil_dbg_pm(wil, "can_suspend: %s\n", is_runtime ? "runtime" : "system");
 
-	if (!netif_running(wil_to_ndev(wil))) {
+	if (wmi_only || debug_fw) {
+		wil_dbg_pm(wil, "Deny any suspend - %s mode\n",
+			   wmi_only ? "wmi_only" : "debug_fw");
+		rc = -EPERM;
+		goto out;
+	}
+	if (!(ndev->flags & IFF_UP)) {
 		/* can always sleep when down */
 		wil_dbg_pm(wil, "Interface is down\n");
 		goto out;
@@ -43,6 +55,10 @@
 	/* interface is running */
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_MONITOR:
+		wil_dbg_pm(wil, "Sniffer\n");
+		rc = -EBUSY;
+		goto out;
+	/* for STA-like interface, don't runtime suspend */
 	case NL80211_IFTYPE_STATION:
 	case NL80211_IFTYPE_P2P_CLIENT:
 		if (test_bit(wil_status_fwconnecting, wil->status)) {
@@ -50,6 +66,12 @@
 			rc = -EBUSY;
 			goto out;
 		}
+		/* Runtime pm not supported in case the interface is up */
+		if (is_runtime) {
+			wil_dbg_pm(wil, "STA-like interface\n");
+			rc = -EBUSY;
+			goto out;
+		}
 		break;
 	/* AP-like interface - can't suspend */
 	default:
@@ -85,7 +107,9 @@
 	/* Send WMI resume request to the device */
 	rc = wmi_resume(wil);
 	if (rc) {
-		wil_err(wil, "device failed to resume (%d), resetting\n", rc);
+		wil_err(wil, "device failed to resume (%d)\n", rc);
+		if (no_fw_recovery)
+			goto out;
 		rc = wil_down(wil);
 		if (rc) {
 			wil_err(wil, "wil_down failed (%d)\n", rc);
@@ -298,6 +322,9 @@
 	wil_dbg_pm(wil, "suspend: %s => %d\n",
 		   is_runtime ? "runtime" : "system", rc);
 
+	if (!rc)
+		wil->suspend_stats.suspend_start_time = ktime_get();
+
 	return rc;
 }
 
@@ -307,6 +334,7 @@
 	struct net_device *ndev = wil_to_ndev(wil);
 	bool keep_radio_on = ndev->flags & IFF_UP &&
 			     wil->keep_radio_on_during_sleep;
+	unsigned long long suspend_time_usec = 0;
 
 	wil_dbg_pm(wil, "resume: %s\n", is_runtime ? "runtime" : "system");
 
@@ -324,8 +352,61 @@
 	else
 		rc = wil_resume_radio_off(wil);
 
+	if (rc)
+		goto out;
+
+	suspend_time_usec =
+		ktime_to_us(ktime_sub(ktime_get(),
+				      wil->suspend_stats.suspend_start_time));
+	wil->suspend_stats.total_suspend_time += suspend_time_usec;
+	if (suspend_time_usec < wil->suspend_stats.min_suspend_time)
+		wil->suspend_stats.min_suspend_time = suspend_time_usec;
+	if (suspend_time_usec > wil->suspend_stats.max_suspend_time)
+		wil->suspend_stats.max_suspend_time = suspend_time_usec;
+
 out:
-	wil_dbg_pm(wil, "resume: %s => %d\n",
-		   is_runtime ? "runtime" : "system", rc);
+	wil_dbg_pm(wil, "resume: %s => %d, suspend time %lld usec\n",
+		   is_runtime ? "runtime" : "system", rc, suspend_time_usec);
 	return rc;
 }
+
+void wil_pm_runtime_allow(struct wil6210_priv *wil)
+{
+	struct device *dev = wil_to_dev(wil);
+
+	pm_runtime_put_noidle(dev);
+	pm_runtime_set_autosuspend_delay(dev, WIL6210_AUTOSUSPEND_DELAY_MS);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_allow(dev);
+}
+
+void wil_pm_runtime_forbid(struct wil6210_priv *wil)
+{
+	struct device *dev = wil_to_dev(wil);
+
+	pm_runtime_forbid(dev);
+	pm_runtime_get_noresume(dev);
+}
+
+int wil_pm_runtime_get(struct wil6210_priv *wil)
+{
+	int rc;
+	struct device *dev = wil_to_dev(wil);
+
+	rc = pm_runtime_get_sync(dev);
+	if (rc < 0) {
+		wil_err(wil, "pm_runtime_get_sync() failed, rc = %d\n", rc);
+		pm_runtime_put_noidle(dev);
+		return rc;
+	}
+
+	return 0;
+}
+
+void wil_pm_runtime_put(struct wil6210_priv *wil)
+{
+	struct device *dev = wil_to_dev(wil);
+
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
+}
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
index 8f1e79b4..8fe2239 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -1666,7 +1666,7 @@
 
 	/* performance monitoring */
 	used = wil_vring_used_tx(vring);
-	if (wil_val_in_range(vring_idle_trsh,
+	if (wil_val_in_range(wil->vring_idle_trsh,
 			     used, used + descs_used)) {
 		txdata->idle += get_cycles() - txdata->last_idle;
 		wil_dbg_txrx(wil,  "Ring[%2d] not idle %d -> %d\n",
@@ -1813,7 +1813,7 @@
 
 	/* performance monitoring */
 	used = wil_vring_used_tx(vring);
-	if (wil_val_in_range(vring_idle_trsh,
+	if (wil_val_in_range(wil->vring_idle_trsh,
 			     used, used + nr_frags + 1)) {
 		txdata->idle += get_cycles() - txdata->last_idle;
 		wil_dbg_txrx(wil,  "Ring[%2d] not idle %d -> %d\n",
@@ -2175,7 +2175,7 @@
 
 	/* performance monitoring */
 	used_new = wil_vring_used_tx(vring);
-	if (wil_val_in_range(vring_idle_trsh,
+	if (wil_val_in_range(wil->vring_idle_trsh,
 			     used_new, used_before_complete)) {
 		wil_dbg_txrx(wil, "Ring[%2d] idle %d -> %d\n",
 			     ringid, used_before_complete, used_new);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index eca5685..8616f86 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -31,7 +31,6 @@
 extern unsigned int mtu_max;
 extern unsigned short rx_ring_overflow_thrsh;
 extern int agg_wsize;
-extern u32 vring_idle_trsh;
 extern bool rx_align_2;
 extern bool rx_large_buf;
 extern bool debug_fw;
@@ -91,6 +90,11 @@
 	unsigned long failed_resumes;
 	unsigned long rejected_by_device;
 	unsigned long rejected_by_host;
+	unsigned long long total_suspend_time;
+	unsigned long long min_suspend_time;
+	unsigned long long max_suspend_time;
+	ktime_t collection_start;
+	ktime_t suspend_start_time;
 };
 
 /* Calculate MAC buffer size for the firmware. It includes all overhead,
@@ -170,6 +174,10 @@
 #define RGF_USER_USER_SCRATCH_PAD	(0x8802bc)
 #define RGF_USER_BL			(0x880A3C) /* Boot Loader */
 #define RGF_USER_FW_REV_ID		(0x880a8c) /* chip revision */
+#define RGF_USER_FW_CALIB_RESULT	(0x880a90) /* b0-7:result
+						    * b8-15:signature
+						    */
+	#define CALIB_RESULT_SIGNATURE	(0x11)
 #define RGF_USER_CLKS_CTL_0		(0x880abc)
 	#define BIT_USER_CLKS_CAR_AHB_SW_SEL	BIT(1) /* ref clk/PLL */
 	#define BIT_USER_CLKS_RST_PWGD	BIT(11) /* reset on "power good" */
@@ -264,6 +272,7 @@
 	#define BIT_DMA_PSEUDO_CAUSE_MISC	BIT(2)
 
 #define RGF_HP_CTRL			(0x88265c)
+#define RGF_PAL_UNIT_ICR		(0x88266c) /* struct RGF_ICR */
 #define RGF_PCIE_LOS_COUNTER_CTL	(0x882dc4)
 
 /* MAC timer, usec, for packet lifetime */
@@ -612,6 +621,16 @@
 	u32 off_ms;
 };
 
+struct wil_debugfs_iomem_data {
+	void *offset;
+	struct wil6210_priv *wil;
+};
+
+struct wil_debugfs_data {
+	struct wil_debugfs_iomem_data *data_arr;
+	int iomem_data_count;
+};
+
 extern struct blink_on_off_time led_blink_time[WIL_LED_TIME_LAST];
 extern u8 led_id;
 extern u8 led_polarity;
@@ -689,6 +708,7 @@
 	u8 vring2cid_tid[WIL6210_MAX_TX_RINGS][2]; /* [0] - CID, [1] - TID */
 	struct wil_sta_info sta[WIL6210_MAX_CID];
 	int bcast_vring;
+	u32 vring_idle_trsh; /* HW fetches up to 16 descriptors at once  */
 	bool use_extended_dma_addr; /* indicates whether we are using 48 bits */
 	/* scan */
 	struct cfg80211_scan_request *scan_request;
@@ -703,6 +723,7 @@
 	u8 abft_len;
 	u8 wakeup_trigger;
 	struct wil_suspend_stats suspend_stats;
+	struct wil_debugfs_data dbg_data;
 
 	void *platform_handle;
 	struct wil_platform_ops platform_ops;
@@ -728,6 +749,8 @@
 	bool tt_data_set;
 	struct wmi_tt_data tt_data;
 
+	int fw_calib_result;
+
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
 	struct notifier_block pm_notify;
@@ -858,6 +881,7 @@
 int __wil_up(struct wil6210_priv *wil);
 int wil_down(struct wil6210_priv *wil);
 int __wil_down(struct wil6210_priv *wil);
+void wil_refresh_fw_capabilities(struct wil6210_priv *wil);
 void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
 int wil_find_cid(struct wil6210_priv *wil, const u8 *mac);
 void wil_set_ethtoolops(struct net_device *ndev);
@@ -940,8 +964,13 @@
 			 struct cfg80211_mgmt_tx_params *params,
 			 u64 *cookie);
 
+#if defined(CONFIG_WIL6210_DEBUGFS)
 int wil6210_debugfs_init(struct wil6210_priv *wil);
 void wil6210_debugfs_remove(struct wil6210_priv *wil);
+#else
+static inline int wil6210_debugfs_init(struct wil6210_priv *wil) { return 0; }
+static inline void wil6210_debugfs_remove(struct wil6210_priv *wil) {}
+#endif
 int wil6210_sysfs_init(struct wil6210_priv *wil);
 void wil6210_sysfs_remove(struct wil6210_priv *wil);
 int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
@@ -997,6 +1026,11 @@
 			 bool load);
 bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);
 
+void wil_pm_runtime_allow(struct wil6210_priv *wil);
+void wil_pm_runtime_forbid(struct wil6210_priv *wil);
+int wil_pm_runtime_get(struct wil6210_priv *wil);
+void wil_pm_runtime_put(struct wil6210_priv *wil);
+
 int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
 int wil_suspend(struct wil6210_priv *wil, bool is_runtime);
 int wil_resume(struct wil6210_priv *wil, bool is_runtime);
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c
index 3028f18..43cdaef 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -345,6 +345,11 @@
 	strlcpy(wdev->wiphy->fw_version, wil->fw_version,
 		sizeof(wdev->wiphy->fw_version));
 
+	if (len > offsetof(struct wmi_ready_event, rfc_read_calib_result)) {
+		wil_dbg_wmi(wil, "rfc calibration result %d\n",
+			    evt->rfc_read_calib_result);
+		wil->fw_calib_result = evt->rfc_read_calib_result;
+	}
 	wil_set_recovery_state(wil, fw_recovery_idle);
 	set_bit(wil_status_fwready, wil->status);
 	/* let the reset sequence continue */
@@ -382,12 +387,15 @@
 	ch_no = data->info.channel + 1;
 	freq = ieee80211_channel_to_frequency(ch_no, NL80211_BAND_60GHZ);
 	channel = ieee80211_get_channel(wiphy, freq);
-	signal = data->info.sqi;
+	if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
+		signal = 100 * data->info.rssi;
+	else
+		signal = data->info.sqi;
 	d_status = le16_to_cpu(data->info.status);
 	fc = rx_mgmt_frame->frame_control;
 
-	wil_dbg_wmi(wil, "MGMT Rx: channel %d MCS %d SNR %d SQI %d%%\n",
-		    data->info.channel, data->info.mcs, data->info.snr,
+	wil_dbg_wmi(wil, "MGMT Rx: channel %d MCS %d RSSI %d SQI %d%%\n",
+		    data->info.channel, data->info.mcs, data->info.rssi,
 		    data->info.sqi);
 	wil_dbg_wmi(wil, "status 0x%04x len %d fc 0x%04x\n", d_status, d_len,
 		    le16_to_cpu(fc));
diff --git a/drivers/net/wireless/ath/wil6210/wmi.h b/drivers/net/wireless/ath/wil6210/wmi.h
index 256f63c..5263ee7 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.h
+++ b/drivers/net/wireless/ath/wil6210/wmi.h
@@ -36,6 +36,11 @@
 #define WMI_PROX_RANGE_NUM		(3)
 #define WMI_MAX_LOSS_DMG_BEACONS	(20)
 #define MAX_NUM_OF_SECTORS		(128)
+#define WMI_SCHED_MAX_ALLOCS_PER_CMD	(4)
+#define WMI_RF_DTYPE_LENGTH		(3)
+#define WMI_RF_ETYPE_LENGTH		(3)
+#define WMI_RF_RX2TX_LENGTH		(3)
+#define WMI_RF_ETYPE_VAL_PER_RANGE	(5)
 
 /* Mailbox interface
  * used for commands and events
@@ -52,14 +57,20 @@
  * the host
  */
 enum wmi_fw_capability {
-	WMI_FW_CAPABILITY_FTM			= 0,
-	WMI_FW_CAPABILITY_PS_CONFIG		= 1,
-	WMI_FW_CAPABILITY_RF_SECTORS		= 2,
-	WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT	= 3,
-	WMI_FW_CAPABILITY_DISABLE_AP_SME	= 4,
-	WMI_FW_CAPABILITY_WMI_ONLY		= 5,
-	WMI_FW_CAPABILITY_THERMAL_THROTTLING	= 7,
-	WMI_FW_CAPABILITY_D3_SUSPEND		= 8,
+	WMI_FW_CAPABILITY_FTM				= 0,
+	WMI_FW_CAPABILITY_PS_CONFIG			= 1,
+	WMI_FW_CAPABILITY_RF_SECTORS			= 2,
+	WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT		= 3,
+	WMI_FW_CAPABILITY_DISABLE_AP_SME		= 4,
+	WMI_FW_CAPABILITY_WMI_ONLY			= 5,
+	WMI_FW_CAPABILITY_THERMAL_THROTTLING		= 7,
+	WMI_FW_CAPABILITY_D3_SUSPEND			= 8,
+	WMI_FW_CAPABILITY_LONG_RANGE			= 9,
+	WMI_FW_CAPABILITY_FIXED_SCHEDULING		= 10,
+	WMI_FW_CAPABILITY_MULTI_DIRECTED_OMNIS		= 11,
+	WMI_FW_CAPABILITY_RSSI_REPORTING		= 12,
+	WMI_FW_CAPABILITY_SET_SILENT_RSSI_TABLE		= 13,
+	WMI_FW_CAPABILITY_LO_POWER_CALIB_FROM_OTP	= 14,
 	WMI_FW_CAPABILITY_MAX,
 };
 
@@ -79,6 +90,7 @@
 	WMI_START_SCAN_CMDID				= 0x07,
 	WMI_SET_BSS_FILTER_CMDID			= 0x09,
 	WMI_SET_PROBED_SSID_CMDID			= 0x0A,
+	/* deprecated */
 	WMI_SET_LISTEN_INT_CMDID			= 0x0B,
 	WMI_BCON_CTRL_CMDID				= 0x0F,
 	WMI_ADD_CIPHER_KEY_CMDID			= 0x16,
@@ -93,26 +105,28 @@
 	WMI_ECHO_CMDID					= 0x803,
 	WMI_DEEP_ECHO_CMDID				= 0x804,
 	WMI_CONFIG_MAC_CMDID				= 0x805,
+	/* deprecated */
 	WMI_CONFIG_PHY_DEBUG_CMDID			= 0x806,
 	WMI_ADD_DEBUG_TX_PCKT_CMDID			= 0x808,
 	WMI_PHY_GET_STATISTICS_CMDID			= 0x809,
+	/* deprecated */
 	WMI_FS_TUNE_CMDID				= 0x80A,
+	/* deprecated */
 	WMI_CORR_MEASURE_CMDID				= 0x80B,
 	WMI_READ_RSSI_CMDID				= 0x80C,
 	WMI_TEMP_SENSE_CMDID				= 0x80E,
 	WMI_DC_CALIB_CMDID				= 0x80F,
+	/* deprecated */
 	WMI_SEND_TONE_CMDID				= 0x810,
+	/* deprecated */
 	WMI_IQ_TX_CALIB_CMDID				= 0x811,
+	/* deprecated */
 	WMI_IQ_RX_CALIB_CMDID				= 0x812,
-	WMI_SET_UCODE_IDLE_CMDID			= 0x813,
 	WMI_SET_WORK_MODE_CMDID				= 0x815,
 	WMI_LO_LEAKAGE_CALIB_CMDID			= 0x816,
-	WMI_MARLON_R_READ_CMDID				= 0x818,
-	WMI_MARLON_R_WRITE_CMDID			= 0x819,
-	WMI_MARLON_R_TXRX_SEL_CMDID			= 0x81A,
-	MAC_IO_STATIC_PARAMS_CMDID			= 0x81B,
-	MAC_IO_DYNAMIC_PARAMS_CMDID			= 0x81C,
+	WMI_LO_POWER_CALIB_FROM_OTP_CMDID		= 0x817,
 	WMI_SILENT_RSSI_CALIB_CMDID			= 0x81D,
+	/* deprecated */
 	WMI_RF_RX_TEST_CMDID				= 0x81E,
 	WMI_CFG_RX_CHAIN_CMDID				= 0x820,
 	WMI_VRING_CFG_CMDID				= 0x821,
@@ -126,11 +140,6 @@
 	WMI_SET_PCP_CHANNEL_CMDID			= 0x829,
 	WMI_GET_PCP_CHANNEL_CMDID			= 0x82A,
 	WMI_SW_TX_REQ_CMDID				= 0x82B,
-	WMI_READ_MAC_RXQ_CMDID				= 0x830,
-	WMI_READ_MAC_TXQ_CMDID				= 0x831,
-	WMI_WRITE_MAC_RXQ_CMDID				= 0x832,
-	WMI_WRITE_MAC_TXQ_CMDID				= 0x833,
-	WMI_WRITE_MAC_XQ_FIELD_CMDID			= 0x834,
 	WMI_MLME_PUSH_CMDID				= 0x835,
 	WMI_BEAMFORMING_MGMT_CMDID			= 0x836,
 	WMI_BF_TXSS_MGMT_CMDID				= 0x837,
@@ -144,9 +153,13 @@
 	WMI_MAINTAIN_RESUME_CMDID			= 0x851,
 	WMI_RS_MGMT_CMDID				= 0x852,
 	WMI_RF_MGMT_CMDID				= 0x853,
-	WMI_OTP_READ_CMDID				= 0x856,
-	WMI_OTP_WRITE_CMDID				= 0x857,
+	WMI_RF_XPM_READ_CMDID				= 0x856,
+	WMI_RF_XPM_WRITE_CMDID				= 0x857,
 	WMI_LED_CFG_CMDID				= 0x858,
+	WMI_SET_CONNECT_SNR_THR_CMDID			= 0x85B,
+	WMI_SET_ACTIVE_SILENT_RSSI_TABLE_CMDID		= 0x85C,
+	WMI_RF_PWR_ON_DELAY_CMDID			= 0x85D,
+	WMI_SET_HIGH_POWER_TABLE_PARAMS_CMDID		= 0x85E,
 	/* Performance monitoring commands */
 	WMI_BF_CTRL_CMDID				= 0x862,
 	WMI_NOTIFY_REQ_CMDID				= 0x863,
@@ -154,7 +167,6 @@
 	WMI_GET_RF_STATUS_CMDID				= 0x866,
 	WMI_GET_BASEBAND_TYPE_CMDID			= 0x867,
 	WMI_UNIT_TEST_CMDID				= 0x900,
-	WMI_HICCUP_CMDID				= 0x901,
 	WMI_FLASH_READ_CMDID				= 0x902,
 	WMI_FLASH_WRITE_CMDID				= 0x903,
 	/* Power management */
@@ -174,16 +186,6 @@
 	WMI_GET_PCP_FACTOR_CMDID			= 0x91B,
 	/* Power Save Configuration Commands */
 	WMI_PS_DEV_PROFILE_CFG_CMDID			= 0x91C,
-	/* Not supported yet */
-	WMI_PS_DEV_CFG_CMDID				= 0x91D,
-	/* Not supported yet */
-	WMI_PS_DEV_CFG_READ_CMDID			= 0x91E,
-	/* Per MAC Power Save Configuration commands
-	 * Not supported yet
-	 */
-	WMI_PS_MID_CFG_CMDID				= 0x91F,
-	/* Not supported yet */
-	WMI_PS_MID_CFG_READ_CMDID			= 0x920,
 	WMI_RS_CFG_CMDID				= 0x921,
 	WMI_GET_DETAILED_RS_RES_CMDID			= 0x922,
 	WMI_AOA_MEAS_CMDID				= 0x923,
@@ -194,13 +196,16 @@
 	WMI_DEL_STA_CMDID				= 0x936,
 	WMI_SET_THERMAL_THROTTLING_CFG_CMDID		= 0x940,
 	WMI_GET_THERMAL_THROTTLING_CFG_CMDID		= 0x941,
+	/* Read Power Save profile type */
+	WMI_PS_DEV_PROFILE_CFG_READ_CMDID		= 0x942,
 	WMI_TOF_SESSION_START_CMDID			= 0x991,
 	WMI_TOF_GET_CAPABILITIES_CMDID			= 0x992,
 	WMI_TOF_SET_LCR_CMDID				= 0x993,
 	WMI_TOF_SET_LCI_CMDID				= 0x994,
-	WMI_TOF_CHANNEL_INFO_CMDID			= 0x995,
+	WMI_TOF_CFG_RESPONDER_CMDID			= 0x996,
 	WMI_TOF_SET_TX_RX_OFFSET_CMDID			= 0x997,
 	WMI_TOF_GET_TX_RX_OFFSET_CMDID			= 0x998,
+	WMI_TOF_CHANNEL_INFO_CMDID			= 0x999,
 	WMI_GET_RF_SECTOR_PARAMS_CMDID			= 0x9A0,
 	WMI_SET_RF_SECTOR_PARAMS_CMDID			= 0x9A1,
 	WMI_GET_SELECTED_RF_SECTOR_INDEX_CMDID		= 0x9A2,
@@ -209,12 +214,20 @@
 	WMI_PRIO_TX_SECTORS_ORDER_CMDID			= 0x9A5,
 	WMI_PRIO_TX_SECTORS_NUMBER_CMDID		= 0x9A6,
 	WMI_PRIO_TX_SECTORS_SET_DEFAULT_CFG_CMDID	= 0x9A7,
+	WMI_SCHEDULING_SCHEME_CMDID			= 0xA01,
+	WMI_FIXED_SCHEDULING_CONFIG_CMDID		= 0xA02,
+	WMI_ENABLE_FIXED_SCHEDULING_CMDID		= 0xA03,
+	WMI_SET_MULTI_DIRECTED_OMNIS_CONFIG_CMDID	= 0xA04,
+	WMI_SET_LONG_RANGE_CONFIG_CMDID			= 0xA05,
 	WMI_SET_MAC_ADDRESS_CMDID			= 0xF003,
 	WMI_ABORT_SCAN_CMDID				= 0xF007,
 	WMI_SET_PROMISCUOUS_MODE_CMDID			= 0xF041,
+	/* deprecated */
 	WMI_GET_PMK_CMDID				= 0xF048,
 	WMI_SET_PASSPHRASE_CMDID			= 0xF049,
+	/* deprecated */
 	WMI_SEND_ASSOC_RES_CMDID			= 0xF04A,
+	/* deprecated */
 	WMI_SET_ASSOC_REQ_RELAY_CMDID			= 0xF04B,
 	WMI_MAC_ADDR_REQ_CMDID				= 0xF04D,
 	WMI_FW_VER_CMDID				= 0xF04E,
@@ -440,11 +453,6 @@
 	__le32 rf_mgmt_type;
 } __packed;
 
-/* WMI_RF_RX_TEST_CMDID */
-struct wmi_rf_rx_test_cmd {
-	__le32 sector;
-} __packed;
-
 /* WMI_CORR_MEASURE_CMDID */
 struct wmi_corr_measure_cmd {
 	__le32 freq_mhz;
@@ -657,6 +665,20 @@
 	struct wmi_bcast_vring_cfg vring_cfg;
 } __packed;
 
+/* WMI_LO_POWER_CALIB_FROM_OTP_CMDID */
+struct wmi_lo_power_calib_from_otp_cmd {
+	/* index to read from OTP. zero based */
+	u8 index;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_LO_POWER_CALIB_FROM_OTP_EVENTID */
+struct wmi_lo_power_calib_from_otp_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
 /* WMI_VRING_BA_EN_CMDID */
 struct wmi_vring_ba_en_cmd {
 	u8 ringid;
@@ -692,6 +714,24 @@
 	WMI_SNIFFER_ON	= 0x01,
 };
 
+/* WMI_SILENT_RSSI_TABLE */
+enum wmi_silent_rssi_table {
+	RF_TEMPERATURE_CALIB_DEFAULT_DB		= 0x00,
+	RF_TEMPERATURE_CALIB_HIGH_POWER_DB	= 0x01,
+};
+
+/* WMI_SILENT_RSSI_STATUS */
+enum wmi_silent_rssi_status {
+	SILENT_RSSI_SUCCESS	= 0x00,
+	SILENT_RSSI_FAILURE	= 0x01,
+};
+
+/* WMI_SET_ACTIVE_SILENT_RSSI_TABLE_CMDID */
+struct wmi_set_active_silent_rssi_table_cmd {
+	/* enum wmi_silent_rssi_table */
+	__le32 table;
+} __packed;
+
 enum wmi_sniffer_cfg_phy_info_mode {
 	WMI_SNIFFER_PHY_INFO_DISABLED	= 0x00,
 	WMI_SNIFFER_PHY_INFO_ENABLED	= 0x01,
@@ -835,18 +875,85 @@
 	__le32 value;
 } __packed;
 
-/* WMI_OTP_READ_CMDID */
-struct wmi_otp_read_cmd {
-	__le32 addr;
-	__le32 size;
-	__le32 values;
+/* WMI_RF_PWR_ON_DELAY_CMDID
+ * set FW time parameters used through RF resetting
+ *  RF reset consists of bringing its power down for a period of time, then
+ * bringing the power up
+ * Returned event: WMI_RF_PWR_ON_DELAY_RSP_EVENTID
+ */
+struct wmi_rf_pwr_on_delay_cmd {
+	/* time in usec the FW waits after bringing the RF PWR down,
+	 * set 0 for default
+	 */
+	__le16 down_delay_usec;
+	/* time in usec the FW waits after bringing the RF PWR up,
+	 * set 0 for default
+	 */
+	__le16 up_delay_usec;
 } __packed;
 
-/* WMI_OTP_WRITE_CMDID */
-struct wmi_otp_write_cmd {
-	__le32 addr;
-	__le32 size;
-	__le32 values;
+/* \WMI_SET_HIGH_POWER_TABLE_PARAMS_CMDID
+ * This API controls the Tx and Rx gain over temperature.
+ * It controls the Tx D-type, Rx D-type and Rx E-type amplifiers.
+ * It also controls the Tx gain index, by controlling the Rx to Tx gain index
+ * offset.
+ * The control is divided by 3 temperature values to 4 temperature ranges.
+ * Each parameter uses its own temperature values.
+ * Returned event: WMI_SET_HIGH_POWER_TABLE_PARAMS_EVENTID
+ */
+struct wmi_set_high_power_table_params_cmd {
+	/* Temperature range for Tx D-type parameters */
+	u8 tx_dtype_temp[WMI_RF_DTYPE_LENGTH];
+	u8 reserved0;
+	/* Tx D-type values to be used for each temperature range */
+	__le32 tx_dtype_conf[WMI_RF_DTYPE_LENGTH + 1];
+	/* Temperature range for Rx D-type parameters */
+	u8 rx_dtype_temp[WMI_RF_DTYPE_LENGTH];
+	u8 reserved1;
+	/* Rx D-type values to be used for each temperature range */
+	__le32 rx_dtype_conf[WMI_RF_DTYPE_LENGTH + 1];
+	/* Temperature range for Rx E-type parameters */
+	u8 rx_etype_temp[WMI_RF_ETYPE_LENGTH];
+	u8 reserved2;
+	/* Rx E-type values to be used for each temperature range.
+	 * The last 4 values of any range are the first 4 values of the next
+	 * range and so on
+	 */
+	__le32 rx_etype_conf[WMI_RF_ETYPE_VAL_PER_RANGE + WMI_RF_ETYPE_LENGTH];
+	/* Temperature range for rx_2_tx_offs parameters */
+	u8 rx_2_tx_temp[WMI_RF_RX2TX_LENGTH];
+	u8 reserved3;
+	/* Rx to Tx gain index offset */
+	s8 rx_2_tx_offs[WMI_RF_RX2TX_LENGTH + 1];
+} __packed;
+
+/* CMD: WMI_RF_XPM_READ_CMDID */
+struct wmi_rf_xpm_read_cmd {
+	u8 rf_id;
+	u8 reserved[3];
+	/* XPM bit start address in range [0,8191]bits - rounded by FW to
+	 * multiple of 8bits
+	 */
+	__le32 xpm_bit_address;
+	__le32 num_bytes;
+} __packed;
+
+/* CMD: WMI_RF_XPM_WRITE_CMDID */
+struct wmi_rf_xpm_write_cmd {
+	u8 rf_id;
+	u8 reserved0[3];
+	/* XPM bit start address in range [0,8191]bits - rounded by FW to
+	 * multiple of 8bits
+	 */
+	__le32 xpm_bit_address;
+	__le32 num_bytes;
+	/* boolean flag indicating whether FW should verify the write
+	 * operation
+	 */
+	u8 verify;
+	u8 reserved1[3];
+	/* actual size=num_bytes */
+	u8 data_bytes[0];
 } __packed;
 
 /* WMI_TEMP_SENSE_CMDID
@@ -989,19 +1096,26 @@
 	 */
 	__le16 burst_period;
 	u8 dst_mac[WMI_MAC_LEN];
-	__le16 reserved;
+	u8 reserved;
+	u8 num_burst_per_aoa_meas;
 } __packed;
 
 /* WMI_TOF_SESSION_START_CMDID */
 struct wmi_tof_session_start_cmd {
 	__le32 session_id;
-	u8 num_of_aoa_measures;
+	u8 reserved1;
 	u8 aoa_type;
 	__le16 num_of_dest;
 	u8 reserved[4];
 	struct wmi_ftm_dest_info ftm_dest_info[0];
 } __packed;
 
+/* WMI_TOF_CFG_RESPONDER_CMDID */
+struct wmi_tof_cfg_responder_cmd {
+	u8 enable;
+	u8 reserved[3];
+} __packed;
+
 enum wmi_tof_channel_info_report_type {
 	WMI_TOF_CHANNEL_INFO_TYPE_CIR			= 0x1,
 	WMI_TOF_CHANNEL_INFO_TYPE_RSSI			= 0x2,
@@ -1022,7 +1136,99 @@
 	__le32 tx_offset;
 	/* RX delay offset */
 	__le32 rx_offset;
-	__le32 reserved[2];
+	/* Mask to define which RFs to configure. 0 means all RFs */
+	__le32 rf_mask;
+	/* Offset to strongest tap of CIR */
+	__le32 precursor;
+} __packed;
+
+/* WMI_TOF_GET_TX_RX_OFFSET_CMDID */
+struct wmi_tof_get_tx_rx_offset_cmd {
+	/* rf index to read offsets from */
+	u8 rf_index;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_FIXED_SCHEDULING_CONFIG_CMDID */
+struct wmi_map_mcs_to_schd_params {
+	u8 mcs;
+	/* time in usec from start slot to start tx flow - default 15 */
+	u8 time_in_usec_before_initiate_tx;
+	/* RD enable - if yes consider RD according to STA mcs */
+	u8 rd_enabled;
+	u8 reserved;
+	/* time in usec from start slot to stop vring */
+	__le16 time_in_usec_to_stop_vring;
+	/* timeout to force flush from start of slot */
+	__le16 flush_to_in_usec;
+	/* per mcs the mac buffer limit size in bytes */
+	__le32 mac_buff_size_in_bytes;
+} __packed;
+
+/* WMI_FIXED_SCHEDULING_CONFIG_COMPLETE_EVENTID */
+struct wmi_fixed_scheduling_config_complete_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+#define WMI_NUM_MCS	(13)
+
+/* WMI_FIXED_SCHEDULING_CONFIG_CMDID */
+struct wmi_fixed_scheduling_config_cmd {
+	/* defaults in the SAS table */
+	struct wmi_map_mcs_to_schd_params mcs_to_schd_params_map[WMI_NUM_MCS];
+	/* default 150 uSec */
+	__le16 max_sta_rd_ppdu_duration_in_usec;
+	/* default 300 uSec */
+	__le16 max_sta_grant_ppdu_duration_in_usec;
+	/* default 1000 uSec */
+	__le16 assoc_slot_duration_in_usec;
+	/* default 360 uSec */
+	__le16 virtual_slot_duration_in_usec;
+	/* each this field value slots start with grant frame to the station
+	 * - default 2
+	 */
+	u8 number_of_ap_slots_for_initiate_grant;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_ENABLE_FIXED_SCHEDULING_CMDID */
+struct wmi_enable_fixed_scheduling_cmd {
+	__le32 reserved;
+} __packed;
+
+/* WMI_ENABLE_FIXED_SCHEDULING_COMPLETE_EVENTID */
+struct wmi_enable_fixed_scheduling_complete_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_SET_MULTI_DIRECTED_OMNIS_CONFIG_CMDID */
+struct wmi_set_multi_directed_omnis_config_cmd {
+	/* number of directed omnis at destination AP */
+	u8 dest_ap_num_directed_omnis;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_SET_MULTI_DIRECTED_OMNIS_CONFIG_EVENTID */
+struct wmi_set_multi_directed_omnis_config_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_SET_LONG_RANGE_CONFIG_CMDID */
+struct wmi_set_long_range_config_cmd {
+	__le32 reserved;
+} __packed;
+
+/* WMI_SET_LONG_RANGE_CONFIG_COMPLETE_EVENTID */
+struct wmi_set_long_range_config_complete_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
 } __packed;
 
 /* WMI Events
@@ -1038,19 +1244,22 @@
 	WMI_FW_READY_EVENTID				= 0x1801,
 	WMI_EXIT_FAST_MEM_ACC_MODE_EVENTID		= 0x200,
 	WMI_ECHO_RSP_EVENTID				= 0x1803,
+	/* deprecated */
 	WMI_FS_TUNE_DONE_EVENTID			= 0x180A,
+	/* deprecated */
 	WMI_CORR_MEASURE_EVENTID			= 0x180B,
 	WMI_READ_RSSI_EVENTID				= 0x180C,
 	WMI_TEMP_SENSE_DONE_EVENTID			= 0x180E,
 	WMI_DC_CALIB_DONE_EVENTID			= 0x180F,
+	/* deprecated */
 	WMI_IQ_TX_CALIB_DONE_EVENTID			= 0x1811,
+	/* deprecated */
 	WMI_IQ_RX_CALIB_DONE_EVENTID			= 0x1812,
 	WMI_SET_WORK_MODE_DONE_EVENTID			= 0x1815,
 	WMI_LO_LEAKAGE_CALIB_DONE_EVENTID		= 0x1816,
-	WMI_MARLON_R_READ_DONE_EVENTID			= 0x1818,
-	WMI_MARLON_R_WRITE_DONE_EVENTID			= 0x1819,
-	WMI_MARLON_R_TXRX_SEL_DONE_EVENTID		= 0x181A,
+	WMI_LO_POWER_CALIB_FROM_OTP_EVENTID		= 0x1817,
 	WMI_SILENT_RSSI_CALIB_DONE_EVENTID		= 0x181D,
+	/* deprecated */
 	WMI_RF_RX_TEST_DONE_EVENTID			= 0x181E,
 	WMI_CFG_RX_CHAIN_DONE_EVENTID			= 0x1820,
 	WMI_VRING_CFG_DONE_EVENTID			= 0x1821,
@@ -1061,11 +1270,6 @@
 	WMI_GET_SSID_EVENTID				= 0x1828,
 	WMI_GET_PCP_CHANNEL_EVENTID			= 0x182A,
 	WMI_SW_TX_COMPLETE_EVENTID			= 0x182B,
-	WMI_READ_MAC_RXQ_EVENTID			= 0x1830,
-	WMI_READ_MAC_TXQ_EVENTID			= 0x1831,
-	WMI_WRITE_MAC_RXQ_EVENTID			= 0x1832,
-	WMI_WRITE_MAC_TXQ_EVENTID			= 0x1833,
-	WMI_WRITE_MAC_XQ_FIELD_EVENTID			= 0x1834,
 	WMI_BEAMFORMING_MGMT_DONE_EVENTID		= 0x1836,
 	WMI_BF_TXSS_MGMT_DONE_EVENTID			= 0x1837,
 	WMI_BF_RXSS_MGMT_DONE_EVENTID			= 0x1839,
@@ -1076,8 +1280,12 @@
 	WMI_TX_MGMT_PACKET_EVENTID			= 0x1841,
 	WMI_LINK_MAINTAIN_CFG_WRITE_DONE_EVENTID	= 0x1842,
 	WMI_LINK_MAINTAIN_CFG_READ_DONE_EVENTID		= 0x1843,
-	WMI_OTP_READ_RESULT_EVENTID			= 0x1856,
+	WMI_RF_XPM_READ_RESULT_EVENTID			= 0x1856,
+	WMI_RF_XPM_WRITE_RESULT_EVENTID			= 0x1857,
 	WMI_LED_CFG_DONE_EVENTID			= 0x1858,
+	WMI_SET_SILENT_RSSI_TABLE_DONE_EVENTID		= 0x185C,
+	WMI_RF_PWR_ON_DELAY_RSP_EVENTID			= 0x185D,
+	WMI_SET_HIGH_POWER_TABLE_PARAMS_EVENTID		= 0x185E,
 	/* Performance monitoring events */
 	WMI_DATA_PORT_OPEN_EVENTID			= 0x1860,
 	WMI_WBE_LINK_DOWN_EVENTID			= 0x1861,
@@ -1106,14 +1314,6 @@
 	WMI_PCP_FACTOR_EVENTID				= 0x191A,
 	/* Power Save Configuration Events */
 	WMI_PS_DEV_PROFILE_CFG_EVENTID			= 0x191C,
-	/* Not supported yet */
-	WMI_PS_DEV_CFG_EVENTID				= 0x191D,
-	/* Not supported yet */
-	WMI_PS_DEV_CFG_READ_EVENTID			= 0x191E,
-	/* Not supported yet */
-	WMI_PS_MID_CFG_EVENTID				= 0x191F,
-	/* Not supported yet */
-	WMI_PS_MID_CFG_READ_EVENTID			= 0x1920,
 	WMI_RS_CFG_DONE_EVENTID				= 0x1921,
 	WMI_GET_DETAILED_RS_RES_EVENTID			= 0x1922,
 	WMI_AOA_MEAS_EVENTID				= 0x1923,
@@ -1122,14 +1322,17 @@
 	WMI_GET_MGMT_RETRY_LIMIT_EVENTID		= 0x1931,
 	WMI_SET_THERMAL_THROTTLING_CFG_EVENTID		= 0x1940,
 	WMI_GET_THERMAL_THROTTLING_CFG_EVENTID		= 0x1941,
+	/* return the Power Save profile */
+	WMI_PS_DEV_PROFILE_CFG_READ_EVENTID		= 0x1942,
 	WMI_TOF_SESSION_END_EVENTID			= 0x1991,
 	WMI_TOF_GET_CAPABILITIES_EVENTID		= 0x1992,
 	WMI_TOF_SET_LCR_EVENTID				= 0x1993,
 	WMI_TOF_SET_LCI_EVENTID				= 0x1994,
 	WMI_TOF_FTM_PER_DEST_RES_EVENTID		= 0x1995,
-	WMI_TOF_CHANNEL_INFO_EVENTID			= 0x1996,
+	WMI_TOF_CFG_RESPONDER_EVENTID			= 0x1996,
 	WMI_TOF_SET_TX_RX_OFFSET_EVENTID		= 0x1997,
 	WMI_TOF_GET_TX_RX_OFFSET_EVENTID		= 0x1998,
+	WMI_TOF_CHANNEL_INFO_EVENTID			= 0x1999,
 	WMI_GET_RF_SECTOR_PARAMS_DONE_EVENTID		= 0x19A0,
 	WMI_SET_RF_SECTOR_PARAMS_DONE_EVENTID		= 0x19A1,
 	WMI_GET_SELECTED_RF_SECTOR_INDEX_DONE_EVENTID	= 0x19A2,
@@ -1138,12 +1341,18 @@
 	WMI_PRIO_TX_SECTORS_ORDER_EVENTID		= 0x19A5,
 	WMI_PRIO_TX_SECTORS_NUMBER_EVENTID		= 0x19A6,
 	WMI_PRIO_TX_SECTORS_SET_DEFAULT_CFG_EVENTID	= 0x19A7,
+	WMI_SCHEDULING_SCHEME_EVENTID			= 0x1A01,
+	WMI_FIXED_SCHEDULING_CONFIG_COMPLETE_EVENTID	= 0x1A02,
+	WMI_ENABLE_FIXED_SCHEDULING_COMPLETE_EVENTID	= 0x1A03,
+	WMI_SET_MULTI_DIRECTED_OMNIS_CONFIG_EVENTID	= 0x1A04,
+	WMI_SET_LONG_RANGE_CONFIG_COMPLETE_EVENTID	= 0x1A05,
 	WMI_SET_CHANNEL_EVENTID				= 0x9000,
 	WMI_ASSOC_REQ_EVENTID				= 0x9001,
 	WMI_EAPOL_RX_EVENTID				= 0x9002,
 	WMI_MAC_ADDR_RESP_EVENTID			= 0x9003,
 	WMI_FW_VER_EVENTID				= 0x9004,
 	WMI_ACS_PASSIVE_SCAN_COMPLETE_EVENTID		= 0x9005,
+	WMI_COMMAND_NOT_SUPPORTED_EVENTID		= 0xFFFF,
 };
 
 /* Events data structures */
@@ -1200,7 +1409,7 @@
 	__le32 bl_minor;
 	__le32 bl_subminor;
 	__le32 bl_build;
-	/* The number of entries in the FW capabilies array */
+	/* The number of entries in the FW capabilities array */
 	u8 fw_capabilities_len;
 	u8 reserved[3];
 	/* FW capabilities info
@@ -1245,7 +1454,9 @@
 	__le32 board_file_platform_type;
 	/* board file version */
 	__le32 board_file_version;
-	__le32 reserved[2];
+	/* enabled XIFs bit vector */
+	__le32 enabled_xif_vector;
+	__le32 reserved;
 } __packed;
 
 /* WMI_GET_BASEBAND_TYPE_EVENTID */
@@ -1299,6 +1510,9 @@
 	/* enum wmi_phy_capability */
 	u8 phy_capability;
 	u8 numof_additional_mids;
+	/* rfc read calibration result. 5..15 */
+	u8 rfc_read_calib_result;
+	u8 reserved[3];
 } __packed;
 
 /* WMI_NOTIFY_REQ_DONE_EVENTID */
@@ -1306,7 +1520,8 @@
 	/* beamforming status, 0: fail; 1: OK; 2: retrying */
 	__le32 status;
 	__le64 tsf;
-	__le32 snr_val;
+	s8 rssi;
+	u8 reserved0[3];
 	__le32 tx_tpt;
 	__le32 tx_goodput;
 	__le32 rx_goodput;
@@ -1576,7 +1791,7 @@
 	u8 reserved[3];
 } __packed;
 
-/* WMI_CORR_MEASURE_EVENTID */
+/* WMI_CORR_MEASURE_EVENTID - deprecated */
 struct wmi_corr_measure_event {
 	/* signed */
 	__le32 i;
@@ -1602,31 +1817,35 @@
 /* wmi_rx_mgmt_info */
 struct wmi_rx_mgmt_info {
 	u8 mcs;
-	s8 snr;
+	s8 rssi;
 	u8 range;
 	u8 sqi;
 	__le16 stype;
 	__le16 status;
 	__le32 len;
-	/* Not resolved when == 0xFFFFFFFF  ==> Broadcast to all MIDS */
+	/* Not resolved when == 0xFFFFFFFF == > Broadcast to all MIDS */
 	u8 qid;
-	/* Not resolved when == 0xFFFFFFFF  ==> Broadcast to all MIDS */
+	/* Not resolved when == 0xFFFFFFFF == > Broadcast to all MIDS */
 	u8 mid;
 	u8 cid;
 	/* From Radio MNGR */
 	u8 channel;
 } __packed;
 
-/* wmi_otp_read_write_cmd */
-struct wmi_otp_read_write_cmd {
-	__le32 addr;
-	__le32 size;
-	u8 values[0];
+/* EVENT: WMI_RF_XPM_READ_RESULT_EVENTID */
+struct wmi_rf_xpm_read_result_event {
+	/* enum wmi_fw_status_e - success=0 or fail=1 */
+	u8 status;
+	u8 reserved[3];
+	/* requested num_bytes of data */
+	u8 data_bytes[0];
 } __packed;
 
-/* WMI_OTP_READ_RESULT_EVENTID */
-struct wmi_otp_read_result_event {
-	u8 payload[0];
+/* EVENT: WMI_RF_XPM_WRITE_RESULT_EVENTID */
+struct wmi_rf_xpm_write_result_event {
+	/* enum wmi_fw_status_e - success=0 or fail=1 */
+	u8 status;
+	u8 reserved[3];
 } __packed;
 
 /* WMI_TX_MGMT_PACKET_EVENTID */
@@ -1645,6 +1864,20 @@
 	__le32 echoed_value;
 } __packed;
 
+/* WMI_RF_PWR_ON_DELAY_RSP_EVENTID */
+struct wmi_rf_pwr_on_delay_rsp_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_SET_HIGH_POWER_TABLE_PARAMS_EVENTID */
+struct wmi_set_high_power_table_params_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
 /* WMI_TEMP_SENSE_DONE_EVENTID
  *
  * Measure MAC and radio temperatures
@@ -1722,14 +1955,22 @@
 	u8 reserved;
 } __packed;
 
+/* \WMI_SET_CONNECT_SNR_THR_CMDID */
+struct wmi_set_connect_snr_thr_cmd {
+	u8 enable;
+	u8 reserved;
+	/* 1/4 Db units */
+	__le16 omni_snr_thr;
+	/* 1/4 Db units */
+	__le16 direct_snr_thr;
+} __packed;
+
 /* WMI_LED_CFG_DONE_EVENTID */
 struct wmi_led_cfg_done_event {
 	/* led config status */
 	__le32 status;
 } __packed;
 
-#define WMI_NUM_MCS	(13)
-
 /* Rate search parameters configuration per connection */
 struct wmi_rs_cfg {
 	/* The maximal allowed PER for each MCS
@@ -1754,6 +1995,98 @@
 	__le32 mcs_en_vec;
 } __packed;
 
+/* Slot types */
+enum wmi_sched_scheme_slot_type {
+	WMI_SCHED_SLOT_SP		= 0x0,
+	WMI_SCHED_SLOT_CBAP		= 0x1,
+	WMI_SCHED_SLOT_IDLE		= 0x2,
+	WMI_SCHED_SLOT_ANNOUNCE_NO_ACK	= 0x3,
+	WMI_SCHED_SLOT_DISCOVERY	= 0x4,
+};
+
+enum wmi_sched_scheme_slot_flags {
+	WMI_SCHED_SCHEME_SLOT_PERIODIC	= 0x1,
+};
+
+struct wmi_sched_scheme_slot {
+	/* in microsecond */
+	__le32 tbtt_offset;
+	/* wmi_sched_scheme_slot_flags */
+	u8 flags;
+	/* wmi_sched_scheme_slot_type */
+	u8 type;
+	/* in microsecond */
+	__le16 duration;
+	/* frame_exchange_sequence_duration */
+	__le16 tx_op;
+	/* time in microseconds between two consecutive slots
+	 * relevant only if flag WMI_SCHED_SCHEME_SLOT_PERIODIC set
+	 */
+	__le16 period;
+	/* relevant only if flag WMI_SCHED_SCHEME_SLOT_PERIODIC set
+	 * number of times to repeat allocation
+	 */
+	u8 num_of_blocks;
+	/* relevant only if flag WMI_SCHED_SCHEME_SLOT_PERIODIC set
+	 * every idle_period allocation will be idle
+	 */
+	u8 idle_period;
+	u8 src_aid;
+	u8 dest_aid;
+	__le32 reserved;
+} __packed;
+
+enum wmi_sched_scheme_flags {
+	/* should not be set when clearing scheduling scheme */
+	WMI_SCHED_SCHEME_ENABLE		= 0x01,
+	WMI_SCHED_PROTECTED_SP		= 0x02,
+	/* should be set only on first WMI fragment of scheme */
+	WMI_SCHED_FIRST			= 0x04,
+	/* should be set only on last WMI fragment of scheme */
+	WMI_SCHED_LAST			= 0x08,
+	WMI_SCHED_IMMEDIATE_START	= 0x10,
+};
+
+enum wmi_sched_scheme_advertisment {
+	/* ESE is not advertised at all, STA has to be configured with WMI
+	 * also
+	 */
+	WMI_ADVERTISE_ESE_DISABLED		= 0x0,
+	WMI_ADVERTISE_ESE_IN_BEACON		= 0x1,
+	WMI_ADVERTISE_ESE_IN_ANNOUNCE_FRAME	= 0x2,
+};
+
+/* WMI_SCHEDULING_SCHEME_CMD */
+struct wmi_scheduling_scheme_cmd {
+	u8 serial_num;
+	/* wmi_sched_scheme_advertisment */
+	u8 ese_advertisment;
+	/* wmi_sched_scheme_flags */
+	__le16 flags;
+	u8 num_allocs;
+	u8 reserved[3];
+	__le64 start_tbtt;
+	/* allocations list */
+	struct wmi_sched_scheme_slot allocs[WMI_SCHED_MAX_ALLOCS_PER_CMD];
+} __packed;
+
+enum wmi_sched_scheme_failure_type {
+	WMI_SCHED_SCHEME_FAILURE_NO_ERROR		= 0x00,
+	WMI_SCHED_SCHEME_FAILURE_OLD_START_TSF_ERR	= 0x01,
+};
+
+/* WMI_SCHEDULING_SCHEME_EVENTID */
+struct wmi_scheduling_scheme_event {
+	/* wmi_fw_status_e */
+	u8 status;
+	/* serial number given in command */
+	u8 serial_num;
+	/* wmi_sched_scheme_failure_type */
+	u8 failure_type;
+	/* alignment to 32b */
+	u8 reserved[1];
+} __packed;
+
 /* WMI_RS_CFG_CMDID */
 struct wmi_rs_cfg_cmd {
 	/* connection id */
@@ -1971,6 +2304,19 @@
 	WMI_PS_PROFILE_TYPE_LOW_LATENCY_PS	= 0x03,
 };
 
+/* WMI_PS_DEV_PROFILE_CFG_READ_CMDID */
+struct wmi_ps_dev_profile_cfg_read_cmd {
+	/* reserved */
+	__le32 reserved;
+} __packed;
+
+/* WMI_PS_DEV_PROFILE_CFG_READ_EVENTID */
+struct wmi_ps_dev_profile_cfg_read_event {
+	/* wmi_ps_profile_type_e */
+	u8 ps_profile;
+	u8 reserved[3];
+} __packed;
+
 /* WMI_PS_DEV_PROFILE_CFG_CMDID
  *
  * Power save profile to be used by the device
@@ -2019,157 +2365,6 @@
 	WMI_PS_D3_RESP_POLICY_APPROVED	= 0x02,
 };
 
-/* Device common power save configurations */
-struct wmi_ps_dev_cfg {
-	/* lowest level of PS allowed while unassociated, enum wmi_ps_level_e
-	 */
-	u8 ps_unassoc_min_level;
-	/* lowest deep sleep clock level while nonassoc, enum
-	 * wmi_ps_deep_sleep_clk_level_e
-	 */
-	u8 ps_unassoc_deep_sleep_min_level;
-	/* lowest level of PS allowed while associated, enum wmi_ps_level_e */
-	u8 ps_assoc_min_level;
-	/* lowest deep sleep clock level while assoc, enum
-	 * wmi_ps_deep_sleep_clk_level_e
-	 */
-	u8 ps_assoc_deep_sleep_min_level;
-	/* enum wmi_ps_deep_sleep_clk_level_e */
-	u8 ps_assoc_low_latency_ds_min_level;
-	/* enum wmi_ps_d3_resp_policy_e */
-	u8 ps_D3_response_policy;
-	/* BOOL */
-	u8 ps_D3_pm_pme_enabled;
-	/* BOOL */
-	u8 ps_halp_enable;
-	u8 ps_deep_sleep_enter_thresh_msec;
-	/* BOOL */
-	u8 ps_voltage_scaling_en;
-} __packed;
-
-/* WMI_PS_DEV_CFG_CMDID
- *
- * Configure common Power Save parameters of the device and all MIDs.
- *
- * Returned event:
- * - WMI_PS_DEV_CFG_EVENTID
- */
-struct wmi_ps_dev_cfg_cmd {
-	/* Device Power Save configuration to be applied */
-	struct wmi_ps_dev_cfg ps_dev_cfg;
-	/* alignment to 32b */
-	u8 reserved[2];
-} __packed;
-
-/* WMI_PS_DEV_CFG_EVENTID */
-struct wmi_ps_dev_cfg_event {
-	/* wmi_ps_cfg_cmd_status_e */
-	__le32 status;
-} __packed;
-
-/* WMI_PS_DEV_CFG_READ_CMDID
- *
- * request to retrieve  device Power Save configuration
- * (WMI_PS_DEV_CFG_CMD params)
- *
- * Returned event:
- * - WMI_PS_DEV_CFG_READ_EVENTID
- */
-struct wmi_ps_dev_cfg_read_cmd {
-	__le32 reserved;
-} __packed;
-
-/* WMI_PS_DEV_CFG_READ_EVENTID */
-struct wmi_ps_dev_cfg_read_event {
-	/* wmi_ps_cfg_cmd_status_e */
-	__le32 status;
-	/* Retrieved device Power Save configuration (WMI_PS_DEV_CFG_CMD
-	 * params)
-	 */
-	struct wmi_ps_dev_cfg dev_ps_cfg;
-	/* alignment to 32b */
-	u8 reserved[2];
-} __packed;
-
-/* Per Mac Power Save configurations */
-struct wmi_ps_mid_cfg {
-	/* Low power RX in BTI is enabled, BOOL */
-	u8 beacon_lprx_enable;
-	/* Sync to sector ID enabled, BOOL */
-	u8 beacon_sync_to_sectorId_enable;
-	/* Low power RX in DTI is enabled, BOOL */
-	u8 frame_exchange_lprx_enable;
-	/* Sleep Cycle while in scheduled PS, 1-31 */
-	u8 scheduled_sleep_cycle_pow2;
-	/* Stay Awake for k BIs every (sleep_cycle - k) BIs, 1-31 */
-	u8 scheduled_num_of_awake_bis;
-	u8 am_to_traffic_load_thresh_mbp;
-	u8 traffic_to_am_load_thresh_mbps;
-	u8 traffic_to_am_num_of_no_traffic_bis;
-	/* BOOL */
-	u8 continuous_traffic_psm;
-	__le16 no_traffic_to_min_usec;
-	__le16 no_traffic_to_max_usec;
-	__le16 snoozing_sleep_interval_milisec;
-	u8 max_no_data_awake_events;
-	/* Trigger WEB after k failed beacons */
-	u8 num_of_failed_beacons_rx_to_trigger_web;
-	/* Trigger BF after k failed beacons */
-	u8 num_of_failed_beacons_rx_to_trigger_bf;
-	/* Trigger SOB after k successful beacons */
-	u8 num_of_successful_beacons_rx_to_trigger_sob;
-} __packed;
-
-/* WMI_PS_MID_CFG_CMDID
- *
- * Configure Power Save parameters of a specific MID.
- * These parameters are relevant for the specific BSS this MID belongs to.
- *
- * Returned event:
- * - WMI_PS_MID_CFG_EVENTID
- */
-struct wmi_ps_mid_cfg_cmd {
-	/* MAC ID */
-	u8 mid;
-	/* mid PS configuration to be applied */
-	struct wmi_ps_mid_cfg ps_mid_cfg;
-} __packed;
-
-/* WMI_PS_MID_CFG_EVENTID */
-struct wmi_ps_mid_cfg_event {
-	/* MAC ID */
-	u8 mid;
-	/* alignment to 32b */
-	u8 reserved[3];
-	/* wmi_ps_cfg_cmd_status_e */
-	__le32 status;
-} __packed;
-
-/* WMI_PS_MID_CFG_READ_CMDID
- *
- * request to retrieve Power Save configuration of mid
- * (WMI_PS_MID_CFG_CMD params)
- *
- * Returned event:
- * - WMI_PS_MID_CFG_READ_EVENTID
- */
-struct wmi_ps_mid_cfg_read_cmd {
-	/* MAC ID */
-	u8 mid;
-	/* alignment to 32b */
-	u8 reserved[3];
-} __packed;
-
-/* WMI_PS_MID_CFG_READ_EVENTID */
-struct wmi_ps_mid_cfg_read_event {
-	/* MAC ID */
-	u8 mid;
-	/* Retrieved MID Power Save configuration(WMI_PS_MID_CFG_CMD params) */
-	struct wmi_ps_mid_cfg mid_ps_cfg;
-	/* wmi_ps_cfg_cmd_status_e */
-	__le32 status;
-} __packed;
-
 #define WMI_AOA_MAX_DATA_SIZE	(128)
 
 enum wmi_aoa_meas_status {
@@ -2260,6 +2455,20 @@
 	u8 reserved[3];
 } __packed;
 
+/* WMI_TOF_SET_LCI_EVENTID */
+struct wmi_tof_set_lci_event {
+	/* enum wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_TOF_SET_LCR_EVENTID */
+struct wmi_tof_set_lcr_event {
+	/* enum wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
 /* Responder FTM Results */
 struct wmi_responder_ftm_res {
 	u8 t1[6];
@@ -2313,10 +2522,19 @@
 	__le32 tsf_sync;
 	/* actual received ftm per burst */
 	u8 actual_ftm_per_burst;
-	u8 reserved0[7];
+	/* Measurments are from RFs, defined by the mask */
+	__le32 meas_rf_mask;
+	u8 reserved0[3];
 	struct wmi_responder_ftm_res responder_ftm_res[0];
 } __packed;
 
+/* WMI_TOF_CFG_RESPONDER_EVENTID */
+struct wmi_tof_cfg_responder_event {
+	/* enum wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
 enum wmi_tof_channel_info_type {
 	WMI_TOF_CHANNEL_INFO_AOA		= 0x00,
 	WMI_TOF_CHANNEL_INFO_LCI		= 0x01,
@@ -2353,12 +2571,15 @@
 struct wmi_tof_get_tx_rx_offset_event {
 	/* enum wmi_fw_status */
 	u8 status;
-	u8 reserved1[3];
+	/* RF index used to read the offsets */
+	u8 rf_index;
+	u8 reserved1[2];
 	/* TX delay offset */
 	__le32 tx_offset;
 	/* RX delay offset */
 	__le32 rx_offset;
-	__le32 reserved2[2];
+	/* Offset to strongest tap of CIR */
+	__le32 precursor;
 } __packed;
 
 /* Result status codes for WMI commands */
@@ -2621,4 +2842,23 @@
 	u8 reserved[3];
 } __packed;
 
+/* WMI_SET_SILENT_RSSI_TABLE_DONE_EVENTID */
+struct wmi_set_silent_rssi_table_done_event {
+	/* enum wmi_silent_rssi_status */
+	__le32 status;
+	/* enum wmi_silent_rssi_table */
+	__le32 table;
+} __packed;
+
+/* \WMI_COMMAND_NOT_SUPPORTED_EVENTID */
+struct wmi_command_not_supported_event {
+	/* device id */
+	u8 mid;
+	u8 reserved0;
+	__le16 command_id;
+	/* for UT command only, otherwise reserved */
+	__le16 command_subtype;
+	__le16 reserved1;
+} __packed;
+
 #endif /* __WILOCITY_WMI_H__ */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index b85398c..261a0da 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5419,6 +5419,7 @@
 	struct ieee80211_supported_band *band;
 	struct brcmf_bss_info_le *bi;
 	struct brcmu_chan ch;
+	struct cfg80211_roam_info roam_info = {};
 	u32 freq;
 	s32 err = 0;
 	u8 *buf;
@@ -5457,9 +5458,15 @@
 
 done:
 	kfree(buf);
-	cfg80211_roamed(ndev, notify_channel, (u8 *)profile->bssid,
-			conn_info->req_ie, conn_info->req_ie_len,
-			conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
+
+	roam_info.channel = notify_channel;
+	roam_info.bssid = profile->bssid;
+	roam_info.req_ie = conn_info->req_ie;
+	roam_info.req_ie_len = conn_info->req_ie_len;
+	roam_info.resp_ie = conn_info->resp_ie;
+	roam_info.resp_ie_len = conn_info->resp_ie_len;
+
+	cfg80211_roamed(ndev, &roam_info, GFP_KERNEL);
 	brcmf_dbg(CONN, "Report roaming result\n");
 
 	set_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 8744b9b..8e3c6f4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4161,11 +4161,6 @@
 		goto fail;
 	}
 
-	/* allocate scatter-gather table. sg support
-	 * will be disabled upon allocation failure.
-	 */
-	brcmf_sdiod_sgtable_alloc(bus->sdiodev);
-
 	/* Query the F2 block size, set roundup accordingly */
 	bus->blocksize = bus->sdiodev->func[2]->cur_blksize;
 	bus->roundup = min(max_roundup, bus->blocksize);
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
index 4b97371..838946d 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c
@@ -1190,11 +1190,11 @@
 				next_reclaimed;
 			IWL_DEBUG_TX_REPLY(priv, "Next reclaimed packet:%d\n",
 						  next_reclaimed);
+			iwlagn_check_ratid_empty(priv, sta_id, tid);
 		}
 
 		iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs);
 
-		iwlagn_check_ratid_empty(priv, sta_id, tid);
 		freed = 0;
 
 		/* process frames */
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 2f8134b..177fd5b 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -429,6 +429,7 @@
 	{IWL_PCI_DEVICE(0x095B, 0x520A, iwl7265_2ac_cfg)},
 	{IWL_PCI_DEVICE(0x095A, 0x9000, iwl7265_2ac_cfg)},
 	{IWL_PCI_DEVICE(0x095A, 0x9400, iwl7265_2ac_cfg)},
+	{IWL_PCI_DEVICE(0x095A, 0x9E10, iwl7265_2ac_cfg)},
 
 /* 8000 Series */
 	{IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)},
diff --git a/drivers/net/wireless/intersil/p54/fwio.c b/drivers/net/wireless/intersil/p54/fwio.c
index 257a9ea..4ac6764 100644
--- a/drivers/net/wireless/intersil/p54/fwio.c
+++ b/drivers/net/wireless/intersil/p54/fwio.c
@@ -488,7 +488,7 @@
 
 			entry += sizeof(__le16);
 			chan->pa_points_per_curve = 8;
-			memset(chan->curve_data, 0, sizeof(*chan->curve_data));
+			memset(chan->curve_data, 0, sizeof(chan->curve_data));
 			memcpy(chan->curve_data, entry,
 			       sizeof(struct p54_pa_curve_data_sample) *
 			       min((u8)8, curve_data->points_per_channel));
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index afdbbf5..8677a53 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -4188,7 +4188,7 @@
 	if (adapter->config_bands & BAND_A)
 		n_channels_a = mwifiex_band_5ghz.n_channels;
 
-	adapter->num_in_chan_stats = max_t(u32, n_channels_bg, n_channels_a);
+	adapter->num_in_chan_stats = n_channels_bg + n_channels_a;
 	adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) *
 				      adapter->num_in_chan_stats);
 
diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index 97c9765..78d59a6 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2479,6 +2479,12 @@
 					      sizeof(struct mwifiex_chan_stats);
 
 	for (i = 0 ; i < num_chan; i++) {
+		if (adapter->survey_idx >= adapter->num_in_chan_stats) {
+			mwifiex_dbg(adapter, WARN,
+				    "FW reported too many channel results (max %d)\n",
+				    adapter->num_in_chan_stats);
+			return;
+		}
 		chan_stats.chan_num = fw_chan_stats->chan_num;
 		chan_stats.bandcfg = fw_chan_stats->bandcfg;
 		chan_stats.flags = fw_chan_stats->flags;
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 5be4fc9..75ffeaa 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -2269,7 +2269,7 @@
 	/* find adapter */
 	if (!_rtl_pci_find_adapter(pdev, hw)) {
 		err = -ENODEV;
-		goto fail3;
+		goto fail2;
 	}
 
 	/* Init IO handler */
@@ -2339,10 +2339,10 @@
 	pci_set_drvdata(pdev, NULL);
 	rtl_deinit_core(hw);
 
+fail2:
 	if (rtlpriv->io.pci_mem_start != 0)
 		pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start);
 
-fail2:
 	pci_release_regions(pdev);
 	complete(&rtlpriv->firmware_loading_complete);
 
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 603c904..280196a 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2830,15 +2830,22 @@
 	}
 
 	if (priv->infra_mode == NDIS_80211_INFRA_INFRA) {
-		if (!roamed)
+		if (!roamed) {
 			cfg80211_connect_result(usbdev->net, bssid, req_ie,
 						req_ie_len, resp_ie,
 						resp_ie_len, 0, GFP_KERNEL);
-		else
-			cfg80211_roamed(usbdev->net,
-					get_current_channel(usbdev, NULL),
-					bssid, req_ie, req_ie_len,
-					resp_ie, resp_ie_len, GFP_KERNEL);
+		} else {
+			struct cfg80211_roam_info roam_info = {
+				.channel = get_current_channel(usbdev, NULL),
+				.bssid = bssid,
+				.req_ie = req_ie,
+				.req_ie_len = req_ie_len,
+				.resp_ie = resp_ie,
+				.resp_ie_len = resp_ie_len,
+			};
+
+			cfg80211_roamed(usbdev->net, &roam_info, GFP_KERNEL);
+		}
 	} else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC)
 		cfg80211_ibss_joined(usbdev->net, bssid,
 				     get_current_channel(usbdev, NULL),
diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c
index bbf7604..1c539c8 100644
--- a/drivers/net/wireless/ti/wl1251/main.c
+++ b/drivers/net/wireless/ti/wl1251/main.c
@@ -1571,6 +1571,7 @@
 
 	wl->state = WL1251_STATE_OFF;
 	mutex_init(&wl->mutex);
+	spin_lock_init(&wl->wl_lock);
 
 	wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
 	wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 3ce1f7d..cb7365b 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -199,6 +199,7 @@
 	unsigned long   remaining_credit;
 	struct timer_list credit_timeout;
 	u64 credit_window_start;
+	bool rate_limited;
 
 	/* Statistics */
 	struct xenvif_stats stats;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index b009d79..5bfaf55 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -105,7 +105,11 @@
 
 	if (work_done < budget) {
 		napi_complete(napi);
-		xenvif_napi_schedule_or_enable_events(queue);
+		/* If the queue is rate-limited, it shall be
+		 * rescheduled in the timer callback.
+		 */
+		if (likely(!queue->rate_limited))
+			xenvif_napi_schedule_or_enable_events(queue);
 	}
 
 	return work_done;
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 47b4810..d9b5b73 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -179,6 +179,7 @@
 		max_credit = ULONG_MAX; /* wrapped: clamp to ULONG_MAX */
 
 	queue->remaining_credit = min(max_credit, max_burst);
+	queue->rate_limited = false;
 }
 
 void xenvif_tx_credit_callback(unsigned long data)
@@ -685,8 +686,10 @@
 		msecs_to_jiffies(queue->credit_usec / 1000);
 
 	/* Timer could already be pending in rare cases. */
-	if (timer_pending(&queue->credit_timeout))
+	if (timer_pending(&queue->credit_timeout)) {
+		queue->rate_limited = true;
 		return true;
+	}
 
 	/* Passed the point where we can replenish credit? */
 	if (time_after_eq64(now, next_credit)) {
@@ -701,6 +704,7 @@
 		mod_timer(&queue->credit_timeout,
 			  next_credit);
 		queue->credit_window_start = next_credit;
+		queue->rate_limited = true;
 
 		return true;
 	}
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 5e797d5..fbd26ec 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -177,6 +177,16 @@
 		/* Packet that contains a length */
 		if (tmp[0] == 0 && tmp[1] == 0) {
 			phy->next_read_size = (tmp[2] << 8) + tmp[3] + 3;
+			/*
+			 * Ensure next_read_size does not exceed sizeof(tmp)
+			 * for reading that many bytes during next iteration
+			 */
+			if (phy->next_read_size > FDP_NCI_I2C_MAX_PAYLOAD) {
+				dev_dbg(&client->dev, "%s: corrupted packet\n",
+					__func__);
+				phy->next_read_size = 5;
+				goto flush;
+			}
 		} else {
 			phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
 
@@ -210,14 +220,14 @@
 	struct sk_buff *skb;
 	int r;
 
-	client = phy->i2c_dev;
-	dev_dbg(&client->dev, "%s\n", __func__);
-
 	if (!phy || irq != phy->i2c_dev->irq) {
 		WARN_ON_ONCE(1);
 		return IRQ_NONE;
 	}
 
+	client = phy->i2c_dev;
+	dev_dbg(&client->dev, "%s\n", __func__);
+
 	r = fdp_nci_i2c_read(phy, &skb);
 
 	if (r == -EREMOTEIO)
diff --git a/drivers/nfc/nq-nci.c b/drivers/nfc/nq-nci.c
index baa4f94..ea4bedf 100644
--- a/drivers/nfc/nq-nci.c
+++ b/drivers/nfc/nq-nci.c
@@ -354,6 +354,7 @@
 				usleep_range(1000, 1100);
 			}
 			gpio_set_value(nqx_dev->ese_gpio, 1);
+			usleep_range(1000, 1100);
 			if (gpio_get_value(nqx_dev->ese_gpio)) {
 				dev_dbg(&nqx_dev->client->dev, "ese_gpio is enabled\n");
 				r = 0;
@@ -406,6 +407,7 @@
 			 * there's no need to send the i2c commands
 			 */
 			gpio_set_value(nqx_dev->ese_gpio, 0);
+			usleep_range(1000, 1100);
 		}
 
 		if (!gpio_get_value(nqx_dev->ese_gpio)) {
diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index 2b2330b..073e4a4 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -725,23 +725,33 @@
 
 static int port100_send_ack(struct port100 *dev)
 {
-	int rc;
+	int rc = 0;
 
 	mutex_lock(&dev->out_urb_lock);
 
-	init_completion(&dev->cmd_cancel_done);
-
-	usb_kill_urb(dev->out_urb);
-
-	dev->out_urb->transfer_buffer = ack_frame;
-	dev->out_urb->transfer_buffer_length = sizeof(ack_frame);
-	rc = usb_submit_urb(dev->out_urb, GFP_KERNEL);
-
-	/* Set the cmd_cancel flag only if the URB has been successfully
-	 * submitted. It will be reset by the out URB completion callback
-	 * port100_send_complete().
+	/*
+	 * If prior cancel is in-flight (dev->cmd_cancel == true), we
+	 * can skip to send cancel. Then this will wait the prior
+	 * cancel, or merged into the next cancel rarely if next
+	 * cancel was started before waiting done. In any case, this
+	 * will be waked up soon or later.
 	 */
-	dev->cmd_cancel = !rc;
+	if (!dev->cmd_cancel) {
+		reinit_completion(&dev->cmd_cancel_done);
+
+		usb_kill_urb(dev->out_urb);
+
+		dev->out_urb->transfer_buffer = ack_frame;
+		dev->out_urb->transfer_buffer_length = sizeof(ack_frame);
+		rc = usb_submit_urb(dev->out_urb, GFP_KERNEL);
+
+		/*
+		 * Set the cmd_cancel flag only if the URB has been
+		 * successfully submitted. It will be reset by the out
+		 * URB completion callback port100_send_complete().
+		 */
+		dev->cmd_cancel = !rc;
+	}
 
 	mutex_unlock(&dev->out_urb_lock);
 
@@ -928,8 +938,8 @@
 	struct port100 *dev = urb->context;
 
 	if (dev->cmd_cancel) {
+		complete_all(&dev->cmd_cancel_done);
 		dev->cmd_cancel = false;
-		complete(&dev->cmd_cancel_done);
 	}
 
 	switch (urb->status) {
@@ -1543,6 +1553,7 @@
 			    PORT100_COMM_RF_HEAD_MAX_LEN;
 	dev->skb_tailroom = PORT100_FRAME_TAIL_LEN;
 
+	init_completion(&dev->cmd_cancel_done);
 	INIT_WORK(&dev->cmd_complete_work, port100_wq_cmd_complete);
 
 	/* The first thing to do with the Port-100 is to set the command type
diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c
index 798a32b..2062852 100644
--- a/drivers/nfc/st21nfca/dep.c
+++ b/drivers/nfc/st21nfca/dep.c
@@ -217,7 +217,8 @@
 
 	atr_req = (struct st21nfca_atr_req *)skb->data;
 
-	if (atr_req->length < sizeof(struct st21nfca_atr_req)) {
+	if (atr_req->length < sizeof(struct st21nfca_atr_req) ||
+	    atr_req->length > skb->len) {
 		r = -EPROTO;
 		goto exit;
 	}
diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c
index 3a98563..6e84e12 100644
--- a/drivers/nfc/st21nfca/se.c
+++ b/drivers/nfc/st21nfca/se.c
@@ -320,23 +320,33 @@
 		 * AID		81	5 to 16
 		 * PARAMETERS	82	0 to 255
 		 */
-		if (skb->len < NFC_MIN_AID_LENGTH + 2 &&
+		if (skb->len < NFC_MIN_AID_LENGTH + 2 ||
 		    skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)
 			return -EPROTO;
 
+		/*
+		 * Buffer should have enough space for at least
+		 * two tag fields + two length fields + aid_len (skb->data[1])
+		 */
+		if (skb->len < skb->data[1] + 4)
+			return -EPROTO;
+
 		transaction = (struct nfc_evt_transaction *)devm_kzalloc(dev,
 						   skb->len - 2, GFP_KERNEL);
 
 		transaction->aid_len = skb->data[1];
 		memcpy(transaction->aid, &skb->data[2],
 		       transaction->aid_len);
-
-		/* Check next byte is PARAMETERS tag (82) */
-		if (skb->data[transaction->aid_len + 2] !=
-		    NFC_EVT_TRANSACTION_PARAMS_TAG)
-			return -EPROTO;
-
 		transaction->params_len = skb->data[transaction->aid_len + 3];
+
+		/* Check next byte is PARAMETERS tag (82) and the length field */
+		if (skb->data[transaction->aid_len + 2] !=
+		    NFC_EVT_TRANSACTION_PARAMS_TAG ||
+		    skb->len < transaction->aid_len + transaction->params_len + 4) {
+			devm_kfree(dev, transaction);
+			return -EPROTO;
+		}
+
 		memcpy(transaction->params, skb->data +
 		       transaction->aid_len + 4, transaction->params_len);
 
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index c234ee43..24222a5 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -176,14 +176,12 @@
 	u64 rx_err_ver;
 	u64 rx_memcpy;
 	u64 rx_async;
-	u64 dma_rx_prep_err;
 	u64 tx_bytes;
 	u64 tx_pkts;
 	u64 tx_ring_full;
 	u64 tx_err_no_buf;
 	u64 tx_memcpy;
 	u64 tx_async;
-	u64 dma_tx_prep_err;
 };
 
 struct ntb_transport_mw {
@@ -256,8 +254,6 @@
 #define QP_TO_MW(nt, qp)	((qp) % nt->mw_count)
 #define NTB_QP_DEF_NUM_ENTRIES	100
 #define NTB_LINK_DOWN_TIMEOUT	10
-#define DMA_RETRIES		20
-#define DMA_OUT_RESOURCE_TO	msecs_to_jiffies(50)
 
 static void ntb_transport_rxc_db(unsigned long data);
 static const struct ntb_ctx_ops ntb_transport_ops;
@@ -518,12 +514,6 @@
 	out_offset += snprintf(buf + out_offset, out_count - out_offset,
 			       "free tx - \t%u\n",
 			       ntb_transport_tx_free_entry(qp));
-	out_offset += snprintf(buf + out_offset, out_count - out_offset,
-			       "DMA tx prep err - \t%llu\n",
-			       qp->dma_tx_prep_err);
-	out_offset += snprintf(buf + out_offset, out_count - out_offset,
-			       "DMA rx prep err - \t%llu\n",
-			       qp->dma_rx_prep_err);
 
 	out_offset += snprintf(buf + out_offset, out_count - out_offset,
 			       "\n");
@@ -625,7 +615,7 @@
 	if (!mw->virt_addr)
 		return -ENOMEM;
 
-	if (qp_count % mw_count && mw_num + 1 < qp_count / mw_count)
+	if (mw_num < qp_count % mw_count)
 		num_qps_mw = qp_count / mw_count + 1;
 	else
 		num_qps_mw = qp_count / mw_count;
@@ -770,8 +760,6 @@
 	qp->tx_err_no_buf = 0;
 	qp->tx_memcpy = 0;
 	qp->tx_async = 0;
-	qp->dma_tx_prep_err = 0;
-	qp->dma_rx_prep_err = 0;
 }
 
 static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
@@ -933,10 +921,8 @@
 		ntb_free_mw(nt, i);
 
 	/* if there's an actual failure, we should just bail */
-	if (rc < 0) {
-		ntb_link_disable(ndev);
+	if (rc < 0)
 		return;
-	}
 
 out:
 	if (ntb_link_is_up(ndev, NULL, NULL) == 1)
@@ -1002,7 +988,7 @@
 	qp->event_handler = NULL;
 	ntb_qp_link_down_reset(qp);
 
-	if (qp_count % mw_count && mw_num + 1 < qp_count / mw_count)
+	if (mw_num < qp_count % mw_count)
 		num_qps_mw = qp_count / mw_count + 1;
 	else
 		num_qps_mw = qp_count / mw_count;
@@ -1125,8 +1111,8 @@
 	qp_count = ilog2(qp_bitmap);
 	if (max_num_clients && max_num_clients < qp_count)
 		qp_count = max_num_clients;
-	else if (mw_count < qp_count)
-		qp_count = mw_count;
+	else if (nt->mw_count < qp_count)
+		qp_count = nt->mw_count;
 
 	qp_bitmap &= BIT_ULL(qp_count) - 1;
 
@@ -1314,7 +1300,6 @@
 	struct dmaengine_unmap_data *unmap;
 	dma_cookie_t cookie;
 	void *buf = entry->buf;
-	int retries = 0;
 
 	len = entry->len;
 	device = chan->device;
@@ -1343,22 +1328,11 @@
 
 	unmap->from_cnt = 1;
 
-	for (retries = 0; retries < DMA_RETRIES; retries++) {
-		txd = device->device_prep_dma_memcpy(chan,
-						     unmap->addr[1],
-						     unmap->addr[0], len,
-						     DMA_PREP_INTERRUPT);
-		if (txd)
-			break;
-
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(DMA_OUT_RESOURCE_TO);
-	}
-
-	if (!txd) {
-		qp->dma_rx_prep_err++;
+	txd = device->device_prep_dma_memcpy(chan, unmap->addr[1],
+					     unmap->addr[0], len,
+					     DMA_PREP_INTERRUPT);
+	if (!txd)
 		goto err_get_unmap;
-	}
 
 	txd->callback_result = ntb_rx_copy_callback;
 	txd->callback_param = entry;
@@ -1603,7 +1577,6 @@
 	struct dmaengine_unmap_data *unmap;
 	dma_addr_t dest;
 	dma_cookie_t cookie;
-	int retries = 0;
 
 	device = chan->device;
 	dest = qp->tx_mw_phys + qp->tx_max_frame * entry->tx_index;
@@ -1625,21 +1598,10 @@
 
 	unmap->to_cnt = 1;
 
-	for (retries = 0; retries < DMA_RETRIES; retries++) {
-		txd = device->device_prep_dma_memcpy(chan, dest,
-						     unmap->addr[0], len,
-						     DMA_PREP_INTERRUPT);
-		if (txd)
-			break;
-
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(DMA_OUT_RESOURCE_TO);
-	}
-
-	if (!txd) {
-		qp->dma_tx_prep_err++;
+	txd = device->device_prep_dma_memcpy(chan, dest, unmap->addr[0], len,
+					     DMA_PREP_INTERRUPT);
+	if (!txd)
 		goto err_get_unmap;
-	}
 
 	txd->callback_result = ntb_tx_copy_callback;
 	txd->callback_param = entry;
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 5a3f008..eef1a68 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -77,7 +77,7 @@
 	kref_init(&host->ref);
 	uuid_be_gen(&host->id);
 	snprintf(host->nqn, NVMF_NQN_SIZE,
-		"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
+		"nqn.2014-08.org.nvmexpress:uuid:%pUb", &host->id);
 
 	mutex_lock(&nvmf_hosts_mutex);
 	list_add_tail(&host->list, &nvmf_hosts);
diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index ac27b9b..8e7b120 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -71,7 +71,7 @@
 
 static const struct of_device_id imx_ocotp_dt_ids[] = {
 	{ .compatible = "fsl,imx6q-ocotp",  (void *)128 },
-	{ .compatible = "fsl,imx6sl-ocotp", (void *)32 },
+	{ .compatible = "fsl,imx6sl-ocotp", (void *)64 },
 	{ .compatible = "fsl,imx6sx-ocotp", (void *)128 },
 	{ },
 };
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 5c63b92..ed92c12 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -956,7 +956,7 @@
 
 	dino_dev->hba.dev = dev;
 	dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096);
-	dino_dev->hba.lmmio_space_offset = 0;	/* CPU addrs == bus addrs */
+	dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
 	spin_lock_init(&dino_dev->dinosaur_pen);
 	dino_dev->hba.iommu = ccio_get_iommu(dev);
 
diff --git a/drivers/pci/host/pci-msm.c b/drivers/pci/host/pci-msm.c
index 0491a86..57dc4a0 100644
--- a/drivers/pci/host/pci-msm.c
+++ b/drivers/pci/host/pci-msm.c
@@ -57,15 +57,19 @@
 
 #define PCS_BASE 0x800
 
-#define PCS_PORT(n, m) (PCS_BASE + n * m * 0x1000)
+#define PCS_PORT(n) (PCS_BASE + n * 0x1000)
 
-#define PCIE_N_SW_RESET(n, m)			(PCS_PORT(n, m) + 0x00)
-#define PCIE_N_POWER_DOWN_CONTROL(n, m)		(PCS_PORT(n, m) + 0x04)
-#define PCIE_N_PCS_STATUS(n, m)			(PCS_PORT(n, m) + 0x174)
+#define PCIE_N_SW_RESET(n)			(PCS_PORT(n) + 0x00)
+#define PCIE_N_POWER_DOWN_CONTROL(n)		(PCS_PORT(n) + 0x04)
+#define PCIE_N_PCS_STATUS(n)			(PCS_PORT(n) + 0x174)
 
-#define PCIE_COM_SW_RESET		0x400
-#define PCIE_COM_POWER_DOWN_CONTROL	0x404
-#define PCIE_COM_PCS_READY_STATUS	0x448
+#define PCIE_GEN3_COM_INTEGLOOP_GAIN1_MODE0	0x0154
+#define PCIE_GEN3_L0_DRVR_CTRL0			0x080c
+#define PCIE_GEN3_L0_RESET_GEN			0x0890
+#define PCIE_GEN3_L0_BIST_ERR_CNT1_STATUS	0x08a8
+#define PCIE_GEN3_L0_BIST_ERR_CNT2_STATUS	0x08ac
+#define PCIE_GEN3_L0_DEBUG_BUS_STATUS4		0x08bc
+#define PCIE_GEN3_PCIE_PHY_PCS_STATUS		0x1aac
 
 #define PCIE20_PARF_SYS_CTRL	     0x00
 #define PCIE20_PARF_PM_CTRL		0x20
@@ -151,6 +155,10 @@
 #define LINKDOWN_WAITING_US_MAX	   5100
 #define LINKDOWN_WAITING_COUNT	    200
 
+#define GEN1_SPEED 0x1
+#define GEN2_SPEED 0x2
+#define GEN3_SPEED 0x3
+
 #define PHY_READY_TIMEOUT_COUNT		   10
 #define XMLH_LINK_UP				  0x400
 #define MAX_LINK_RETRIES 5
@@ -481,10 +489,11 @@
 	bool				smmu_exist;
 	uint32_t			smmu_sid_base;
 	uint32_t			   n_fts;
+	uint32_t			max_link_speed;
 	bool				 ext_ref_clk;
-	bool				common_phy;
 	uint32_t			   ep_latency;
 	uint32_t			wr_halt_size;
+	uint32_t			slv_addr_space_size;
 	uint32_t			cpl_timeout;
 	uint32_t			current_bdf;
 	uint32_t			perst_delay_us_min;
@@ -518,9 +527,7 @@
 	u32				num_ep;
 	bool				pending_ep_reg;
 	u32				phy_len;
-	u32				port_phy_len;
 	struct msm_pcie_phy_info_t	*phy_sequence;
-	struct msm_pcie_phy_info_t	*port_phy_sequence;
 	u32		ep_shadow[MAX_DEVICE_NUM][PCIE_CONF_SPACE_DW];
 	u32				  rc_shadow[PCIE_CONF_SPACE_DW];
 	bool				 shadow_en;
@@ -553,12 +560,6 @@
 static u32 wr_value;
 static ulong corr_counter_limit = 5;
 
-/* counter to keep track if common PHY needs to be configured */
-static u32 num_rc_on;
-
-/* global lock for PCIe common PHY */
-static struct mutex com_phy_lock;
-
 /* Table to track info of PCIe devices */
 static struct msm_pcie_device_info
 	msm_pcie_dev_tbl[MAX_RC_NUM * MAX_DEVICE_NUM];
@@ -853,41 +854,13 @@
 	}
 }
 
-static void pcie_pcs_port_phy_init(struct msm_pcie_dev_t *dev)
-{
-	int i;
-	struct msm_pcie_phy_info_t *phy_seq;
-
-	PCIE_DBG(dev, "RC%d: Initializing PCIe PHY Port\n", dev->rc_idx);
-
-	if (dev->port_phy_sequence) {
-		i =  dev->port_phy_len;
-		phy_seq = dev->port_phy_sequence;
-		while (i--) {
-			msm_pcie_write_reg(dev->phy,
-				phy_seq->offset,
-				phy_seq->val);
-			if (phy_seq->delay)
-				usleep_range(phy_seq->delay,
-					phy_seq->delay + 1);
-			phy_seq++;
-		}
-	}
-
-}
-
 static bool pcie_phy_is_ready(struct msm_pcie_dev_t *dev)
 {
-	if (dev->phy_ver >= 0x20) {
-		if (readl_relaxed(dev->phy +
-			PCIE_N_PCS_STATUS(dev->rc_idx, dev->common_phy)) &
-					BIT(6))
-			return false;
-		else
-			return true;
-	}
+	u32 pos = (dev->max_link_speed == GEN2_SPEED) ?
+		PCIE_N_PCS_STATUS(dev->rc_idx) :
+		PCIE_GEN3_PCIE_PHY_PCS_STATUS;
 
-	if (!(readl_relaxed(dev->phy + PCIE_COM_PCS_READY_STATUS) & 0x1))
+	if (readl_relaxed(dev->phy + pos) & BIT(6))
 		return false;
 	else
 		return true;
@@ -1093,8 +1066,6 @@
 		dev->pending_ep_reg ? "true" : "false");
 	PCIE_DBG_FS(dev, "phy_len is %d",
 		dev->phy_len);
-	PCIE_DBG_FS(dev, "port_phy_len is %d",
-		dev->port_phy_len);
 	PCIE_DBG_FS(dev, "disable_pc is %d",
 		dev->disable_pc);
 	PCIE_DBG_FS(dev, "l0s_supported is %s supported\n",
@@ -1139,12 +1110,12 @@
 		dev->smmu_sid_base);
 	PCIE_DBG_FS(dev, "n_fts: %d\n",
 		dev->n_fts);
-	PCIE_DBG_FS(dev, "common_phy: %d\n",
-		dev->common_phy);
 	PCIE_DBG_FS(dev, "ep_latency: %dms\n",
 		dev->ep_latency);
 	PCIE_DBG_FS(dev, "wr_halt_size: 0x%x\n",
 		dev->wr_halt_size);
+	PCIE_DBG_FS(dev, "slv_addr_space_size: 0x%x\n",
+		dev->slv_addr_space_size);
 	PCIE_DBG_FS(dev, "cpl_timeout: 0x%x\n",
 		dev->cpl_timeout);
 	PCIE_DBG_FS(dev, "current_bdf: 0x%x\n",
@@ -1171,6 +1142,8 @@
 		dev->linkdown_counter);
 	PCIE_DBG_FS(dev, "wake_counter: %lu\n",
 		dev->wake_counter);
+	PCIE_DBG_FS(dev, "max_link_speed: 0x%x\n",
+		dev->max_link_speed);
 	PCIE_DBG_FS(dev, "link_turned_on_counter: %lu\n",
 		dev->link_turned_on_counter);
 	PCIE_DBG_FS(dev, "link_turned_off_counter: %lu\n",
@@ -3400,31 +3373,6 @@
 			dev->rc_idx);
 	}
 
-	of_get_property(pdev->dev.of_node, "qcom,port-phy-sequence", &size);
-	if (size) {
-		dev->port_phy_sequence = (struct msm_pcie_phy_info_t *)
-			devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
-
-		if (dev->port_phy_sequence) {
-			dev->port_phy_len =
-				size / sizeof(*dev->port_phy_sequence);
-
-			of_property_read_u32_array(pdev->dev.of_node,
-				"qcom,port-phy-sequence",
-				(unsigned int *)dev->port_phy_sequence,
-				size / sizeof(dev->port_phy_sequence->offset));
-		} else {
-			PCIE_ERR(dev,
-				"RC%d: Could not allocate memory for port phy init sequence.\n",
-				dev->rc_idx);
-			ret = -ENOMEM;
-			goto out;
-		}
-	} else {
-		PCIE_DBG(dev, "RC%d: port phy sequence is not present in DT\n",
-			dev->rc_idx);
-	}
-
 	for (i = 0; i < MSM_PCIE_MAX_CLK; i++) {
 		clk_info = &dev->clk[i];
 
@@ -3638,6 +3586,36 @@
 	dev->dev_io_res = NULL;
 }
 
+static void msm_pcie_setup_gen3(struct msm_pcie_dev_t *dev)
+{
+	PCIE_DBG(dev, "PCIe: RC%d: Setting up Gen3\n", dev->rc_idx);
+
+	msm_pcie_write_reg_field(dev->dm_core,
+		PCIE_GEN3_L0_DRVR_CTRL0, 0x1ff00, BIT(0));
+
+	msm_pcie_write_reg(dev->dm_core,
+		PCIE_GEN3_L0_BIST_ERR_CNT2_STATUS,
+		(0x05 << 14) | (0x05 << 10) | (0x0d <<  5));
+
+	msm_pcie_write_mask(dev->dm_core +
+		PCIE_GEN3_L0_BIST_ERR_CNT1_STATUS, BIT(4), 0);
+
+	msm_pcie_write_mask(dev->dm_core +
+		PCIE_GEN3_L0_RESET_GEN, BIT(0), 0);
+
+	/* configure PCIe preset */
+	msm_pcie_write_reg(dev->dm_core,
+		PCIE_GEN3_L0_DEBUG_BUS_STATUS4, 1);
+	msm_pcie_write_reg(dev->dm_core,
+		PCIE_GEN3_COM_INTEGLOOP_GAIN1_MODE0, 0x77777777);
+	msm_pcie_write_reg(dev->dm_core,
+		PCIE_GEN3_L0_DEBUG_BUS_STATUS4, 1);
+
+	msm_pcie_write_reg_field(dev->dm_core,
+		PCIE20_CAP + PCI_EXP_LNKCTL2,
+		PCI_EXP_LNKCAP_SLS, GEN3_SPEED);
+}
+
 static int msm_pcie_enable(struct msm_pcie_dev_t *dev, u32 options)
 {
 	int ret = 0;
@@ -3726,15 +3704,8 @@
 			readl_relaxed(dev->parf + PCIE20_PARF_INT_ALL_MASK));
 	}
 
-	if (dev->dev_mem_res->end - dev->dev_mem_res->start > SZ_16M)
-		writel_relaxed(SZ_32M, dev->parf +
-			PCIE20_PARF_SLV_ADDR_SPACE_SIZE);
-	else if (dev->dev_mem_res->end - dev->dev_mem_res->start > SZ_8M)
-		writel_relaxed(SZ_16M, dev->parf +
-			PCIE20_PARF_SLV_ADDR_SPACE_SIZE);
-	else
-		writel_relaxed(SZ_8M, dev->parf +
-			PCIE20_PARF_SLV_ADDR_SPACE_SIZE);
+	writel_relaxed(dev->slv_addr_space_size, dev->parf +
+		PCIE20_PARF_SLV_ADDR_SPACE_SIZE);
 
 	if (dev->use_msi) {
 		PCIE_DBG(dev, "RC%d: enable WR halt.\n", dev->rc_idx);
@@ -3753,13 +3724,8 @@
 				PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT));
 	}
 
-	mutex_lock(&com_phy_lock);
 	/* init PCIe PHY */
-	if (!num_rc_on)
-		pcie_phy_init(dev);
-
-	num_rc_on++;
-	mutex_unlock(&com_phy_lock);
+	pcie_phy_init(dev);
 
 	if (options & PM_PIPE_CLK) {
 		usleep_range(PHY_STABILIZATION_DELAY_US_MIN,
@@ -3772,6 +3738,12 @@
 			goto link_fail;
 	}
 
+	/* check capability for max link speed */
+	if (!dev->max_link_speed) {
+		val = readl_relaxed(dev->dm_core + PCIE20_CAP + PCI_EXP_LNKCAP);
+		dev->max_link_speed = val & PCI_EXP_LNKCAP_SLS;
+	}
+
 	PCIE_DBG(dev, "RC%d: waiting for phy ready...\n", dev->rc_idx);
 
 	do {
@@ -3795,8 +3767,6 @@
 		goto link_fail;
 	}
 
-	pcie_pcs_port_phy_init(dev);
-
 	if (dev->ep_latency)
 		usleep_range(dev->ep_latency * 1000, dev->ep_latency * 1000);
 
@@ -3812,6 +3782,10 @@
 				1 - dev->gpio[MSM_PCIE_GPIO_PERST].on);
 	usleep_range(dev->perst_delay_us_min, dev->perst_delay_us_max);
 
+	/* setup Gen3 specific configurations */
+	if (dev->max_link_speed == GEN3_SPEED)
+		msm_pcie_setup_gen3(dev);
+
 	/* set max tlp read size */
 	msm_pcie_write_reg_field(dev->dm_core, PCIE20_DEVICE_CONTROL_STATUS,
 				0x7000, dev->tlp_rd_size);
@@ -3868,20 +3842,13 @@
 	if (dev->gpio[MSM_PCIE_GPIO_EP].num)
 		gpio_set_value(dev->gpio[MSM_PCIE_GPIO_EP].num,
 				1 - dev->gpio[MSM_PCIE_GPIO_EP].on);
-	msm_pcie_write_reg(dev->phy,
-		PCIE_N_SW_RESET(dev->rc_idx, dev->common_phy), 0x1);
-	msm_pcie_write_reg(dev->phy,
-		PCIE_N_POWER_DOWN_CONTROL(dev->rc_idx, dev->common_phy), 0);
 
-	mutex_lock(&com_phy_lock);
-	num_rc_on--;
-	if (!num_rc_on && dev->common_phy) {
-		PCIE_DBG(dev, "PCIe: RC%d is powering down the common phy\n",
-			dev->rc_idx);
-		msm_pcie_write_reg(dev->phy, PCIE_COM_SW_RESET, 0x1);
-		msm_pcie_write_reg(dev->phy, PCIE_COM_POWER_DOWN_CONTROL, 0);
+	if (dev->max_link_speed != GEN3_SPEED) {
+		msm_pcie_write_reg(dev->phy,
+			PCIE_N_SW_RESET(dev->rc_idx), 0x1);
+		msm_pcie_write_reg(dev->phy,
+			PCIE_N_POWER_DOWN_CONTROL(dev->rc_idx), 0);
 	}
-	mutex_unlock(&com_phy_lock);
 
 	msm_pcie_pipe_clk_deinit(dev);
 	msm_pcie_clk_deinit(dev);
@@ -3919,20 +3886,12 @@
 	gpio_set_value(dev->gpio[MSM_PCIE_GPIO_PERST].num,
 				dev->gpio[MSM_PCIE_GPIO_PERST].on);
 
-	msm_pcie_write_reg(dev->phy,
-		PCIE_N_SW_RESET(dev->rc_idx, dev->common_phy), 0x1);
-	msm_pcie_write_reg(dev->phy,
-		PCIE_N_POWER_DOWN_CONTROL(dev->rc_idx, dev->common_phy), 0);
-
-	mutex_lock(&com_phy_lock);
-	num_rc_on--;
-	if (!num_rc_on && dev->common_phy) {
-		PCIE_DBG(dev, "PCIe: RC%d is powering down the common phy\n",
-			dev->rc_idx);
-		msm_pcie_write_reg(dev->phy, PCIE_COM_SW_RESET, 0x1);
-		msm_pcie_write_reg(dev->phy, PCIE_COM_POWER_DOWN_CONTROL, 0);
+	if (dev->max_link_speed != GEN3_SPEED) {
+		msm_pcie_write_reg(dev->phy,
+			PCIE_N_SW_RESET(dev->rc_idx), 0x1);
+		msm_pcie_write_reg(dev->phy,
+			PCIE_N_POWER_DOWN_CONTROL(dev->rc_idx), 0);
 	}
-	mutex_unlock(&com_phy_lock);
 
 	if (options & PM_CLK) {
 		msm_pcie_write_mask(dev->parf + PCIE20_PARF_PHY_CTRL, 0,
@@ -5382,12 +5341,12 @@
 		PCIE_DBG(&msm_pcie_dev[rc_idx], "n-fts: 0x%x.\n",
 				msm_pcie_dev[rc_idx].n_fts);
 
-	msm_pcie_dev[rc_idx].common_phy =
-		of_property_read_bool((&pdev->dev)->of_node,
-				"qcom,common-phy");
-	PCIE_DBG(&msm_pcie_dev[rc_idx],
-		"PCIe: RC%d: Common PHY does %s exist.\n",
-		rc_idx, msm_pcie_dev[rc_idx].common_phy ? "" : "not");
+	msm_pcie_dev[rc_idx].max_link_speed = GEN2_SPEED;
+	ret = of_property_read_u32(pdev->dev.of_node,
+				"qcom,max-link-speed",
+				&msm_pcie_dev[rc_idx].max_link_speed);
+	PCIE_DBG(&msm_pcie_dev[rc_idx], "PCIe: RC%d: max-link-speed: 0x%x.\n",
+		rc_idx, msm_pcie_dev[rc_idx].max_link_speed);
 
 	msm_pcie_dev[rc_idx].ext_ref_clk =
 		of_property_read_bool((&pdev->dev)->of_node,
@@ -5419,6 +5378,14 @@
 		PCIE_DBG(&msm_pcie_dev[rc_idx], "RC%d: wr-halt-size: 0x%x.\n",
 			rc_idx, msm_pcie_dev[rc_idx].wr_halt_size);
 
+	msm_pcie_dev[rc_idx].slv_addr_space_size = SZ_16M;
+	ret = of_property_read_u32(pdev->dev.of_node,
+				"qcom,slv-addr-space-size",
+				&msm_pcie_dev[rc_idx].slv_addr_space_size);
+	PCIE_DBG(&msm_pcie_dev[rc_idx],
+		"RC%d: slv-addr-space-size: 0x%x.\n",
+		rc_idx, msm_pcie_dev[rc_idx].slv_addr_space_size);
+
 	msm_pcie_dev[rc_idx].cpl_timeout = 0;
 	ret = of_property_read_u32((&pdev->dev)->of_node,
 				"qcom,cpl-timeout",
@@ -5519,9 +5486,7 @@
 	msm_pcie_dev[rc_idx].num_ep = 0;
 	msm_pcie_dev[rc_idx].pending_ep_reg = false;
 	msm_pcie_dev[rc_idx].phy_len = 0;
-	msm_pcie_dev[rc_idx].port_phy_len = 0;
 	msm_pcie_dev[rc_idx].phy_sequence = NULL;
-	msm_pcie_dev[rc_idx].port_phy_sequence = NULL;
 	msm_pcie_dev[rc_idx].event_reg = NULL;
 	msm_pcie_dev[rc_idx].linkdown_counter = 0;
 	msm_pcie_dev[rc_idx].link_turned_on_counter = 0;
@@ -5730,7 +5695,6 @@
 
 	pcie_drv.rc_num = 0;
 	mutex_init(&pcie_drv.drv_lock);
-	mutex_init(&com_phy_lock);
 
 	for (i = 0; i < MAX_RC_NUM; i++) {
 		snprintf(rc_name, MAX_RC_NAME_LEN, "pcie%d-short", i);
diff --git a/drivers/pinctrl/intel/pinctrl-merrifield.c b/drivers/pinctrl/intel/pinctrl-merrifield.c
index 9931be6..04d6fd2 100644
--- a/drivers/pinctrl/intel/pinctrl-merrifield.c
+++ b/drivers/pinctrl/intel/pinctrl-merrifield.c
@@ -343,9 +343,9 @@
 
 static const unsigned int mrfld_sdio_pins[] = { 50, 51, 52, 53, 54, 55, 56 };
 static const unsigned int mrfld_spi5_pins[] = { 90, 91, 92, 93, 94, 95, 96 };
-static const unsigned int mrfld_uart0_pins[] = { 124, 125, 126, 127 };
-static const unsigned int mrfld_uart1_pins[] = { 128, 129, 130, 131 };
-static const unsigned int mrfld_uart2_pins[] = { 132, 133, 134, 135 };
+static const unsigned int mrfld_uart0_pins[] = { 115, 116, 117, 118 };
+static const unsigned int mrfld_uart1_pins[] = { 119, 120, 121, 122 };
+static const unsigned int mrfld_uart2_pins[] = { 123, 124, 125, 126 };
 static const unsigned int mrfld_pwm0_pins[] = { 144 };
 static const unsigned int mrfld_pwm1_pins[] = { 145 };
 static const unsigned int mrfld_pwm2_pins[] = { 132 };
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index c3928aa..7511723 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -85,6 +85,7 @@
 	MESON_PIN(GPIODV_15, EE_OFF),
 	MESON_PIN(GPIODV_16, EE_OFF),
 	MESON_PIN(GPIODV_17, EE_OFF),
+	MESON_PIN(GPIODV_18, EE_OFF),
 	MESON_PIN(GPIODV_19, EE_OFF),
 	MESON_PIN(GPIODV_20, EE_OFF),
 	MESON_PIN(GPIODV_21, EE_OFF),
diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 02b28bd..d39a17f 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -79,6 +79,16 @@
 	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
 	  Qualcomm TLMM block found on the Qualcomm 8916 platform.
 
+config PINCTRL_MSM8953
+	tristate "Qualcomm Technologies Inc MSM8953 pin controller driver"
+	depends on GPIOLIB && OF
+	select PINCTRL_MSM
+	help
+	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
+	  Qualcomm Technologies Inc TLMM block found on the Qualcomm
+	  Technologies Inc MSM8953 platform.
+	  If unsure say N.
+
 config PINCTRL_SDM845
 	tristate "Qualcomm Technologies Inc SDM845 pin controller driver"
 	depends on GPIOLIB && OF
@@ -148,18 +158,4 @@
          which are using SSBI for communication with SoC. Example PMIC's
          devices are pm8058 and pm8921.
 
-config PINCTRL_WCD
-	tristate "Qualcomm Technologies, Inc WCD pin controller driver"
-	depends on WCD9XXX_CODEC_CORE
-	help
-	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
-	  WCD gpio controller block.
-
-config PINCTRL_LPI
-	tristate "Qualcomm Technologies, Inc LPI pin controller driver"
-	depends on GPIOLIB && OF
-	help
-	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
-	  LPI gpio controller block.
-
 endif
diff --git a/drivers/pinctrl/qcom/Makefile b/drivers/pinctrl/qcom/Makefile
index 6a49671..d92db11 100644
--- a/drivers/pinctrl/qcom/Makefile
+++ b/drivers/pinctrl/qcom/Makefile
@@ -11,12 +11,11 @@
 obj-$(CONFIG_PINCTRL_MSM8996)   += pinctrl-msm8996.o
 obj-$(CONFIG_PINCTRL_QDF2XXX)	+= pinctrl-qdf2xxx.o
 obj-$(CONFIG_PINCTRL_MDM9615)	+= pinctrl-mdm9615.o
+obj-$(CONFIG_PINCTRL_MSM8953)   += pinctrl-msm8953.o
 obj-$(CONFIG_PINCTRL_QCOM_SPMI_PMIC) += pinctrl-spmi-gpio.o
 obj-$(CONFIG_PINCTRL_QCOM_SPMI_PMIC) += pinctrl-spmi-mpp.o
 obj-$(CONFIG_PINCTRL_QCOM_SSBI_PMIC) += pinctrl-ssbi-gpio.o
 obj-$(CONFIG_PINCTRL_QCOM_SSBI_PMIC) += pinctrl-ssbi-mpp.o
-obj-$(CONFIG_PINCTRL_SDM845) += pinctrl-sdm845.o
+obj-$(CONFIG_PINCTRL_SDM845) += pinctrl-sdm845.o pinctrl-sdm845-v2.o
 obj-$(CONFIG_PINCTRL_SDM670) += pinctrl-sdm670.o
 obj-$(CONFIG_PINCTRL_SDXPOORWILLS)	+= pinctrl-sdxpoorwills.o
-obj-$(CONFIG_PINCTRL_WCD)	+= pinctrl-wcd.o
-obj-$(CONFIG_PINCTRL_LPI)	+= pinctrl-lpi.o
diff --git a/drivers/pinctrl/qcom/pinctrl-lpi.c b/drivers/pinctrl/qcom/pinctrl-lpi.c
deleted file mode 100644
index 39c35b7..0000000
--- a/drivers/pinctrl/qcom/pinctrl-lpi.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/gpio.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/pinctrl/pinconf-generic.h>
-#include <linux/pinctrl/pinconf.h>
-#include <linux/pinctrl/pinmux.h>
-#include <linux/platform_device.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-
-#include "../core.h"
-#include "../pinctrl-utils.h"
-
-#define LPI_ADDRESS_SIZE			0x20000
-
-#define LPI_GPIO_REG_VAL_CTL			0x00
-#define LPI_GPIO_REG_DIR_CTL			0x04
-
-#define LPI_GPIO_REG_PULL_SHIFT			0x0
-#define LPI_GPIO_REG_PULL_MASK			0x3
-
-#define LPI_GPIO_REG_FUNCTION_SHIFT		0x2
-#define LPI_GPIO_REG_FUNCTION_MASK		0x3C
-
-#define LPI_GPIO_REG_OUT_STRENGTH_SHIFT		0x6
-#define LPI_GPIO_REG_OUT_STRENGTH_MASK		0x1C0
-
-#define LPI_GPIO_REG_OE_SHIFT			0x9
-#define LPI_GPIO_REG_OE_MASK			0x200
-
-#define LPI_GPIO_REG_DIR_SHIFT			0x1
-#define LPI_GPIO_REG_DIR_MASK			0x2
-
-#define LPI_GPIO_BIAS_DISABLE			0x0
-#define LPI_GPIO_PULL_DOWN			0x1
-#define LPI_GPIO_KEEPER				0x2
-#define LPI_GPIO_PULL_UP			0x3
-
-#define LPI_GPIO_FUNC_GPIO			"gpio"
-#define LPI_GPIO_FUNC_FUNC1			"func1"
-#define LPI_GPIO_FUNC_FUNC2			"func2"
-#define LPI_GPIO_FUNC_FUNC3			"func3"
-#define LPI_GPIO_FUNC_FUNC4			"func4"
-#define LPI_GPIO_FUNC_FUNC5			"func5"
-
-static bool lpi_dev_up;
-
-/* The index of each function in lpi_gpio_functions[] array */
-enum lpi_gpio_func_index {
-	LPI_GPIO_FUNC_INDEX_GPIO	= 0x00,
-	LPI_GPIO_FUNC_INDEX_FUNC1	= 0x01,
-	LPI_GPIO_FUNC_INDEX_FUNC2	= 0x02,
-	LPI_GPIO_FUNC_INDEX_FUNC3	= 0x03,
-	LPI_GPIO_FUNC_INDEX_FUNC4	= 0x04,
-	LPI_GPIO_FUNC_INDEX_FUNC5	= 0x05,
-};
-
-/**
- * struct lpi_gpio_pad - keep current GPIO settings
- * @offset: Nth GPIO in supported GPIOs.
- * @output_enabled: Set to true if GPIO output logic is enabled.
- * @value: value of a pin
- * @base: Address base of LPI GPIO PAD.
- * @pullup: Constant current which flow through GPIO output buffer.
- * @strength: No, Low, Medium, High
- * @function: See lpi_gpio_functions[]
- */
-struct lpi_gpio_pad {
-	u16		offset;
-	bool		output_enabled;
-	bool		value;
-	char __iomem	*base;
-	unsigned int	pullup;
-	unsigned int	strength;
-	unsigned int	function;
-};
-
-struct lpi_gpio_state {
-	struct device	*dev;
-	struct pinctrl_dev *ctrl;
-	struct gpio_chip chip;
-	char __iomem	*base;
-};
-
-static const char *const lpi_gpio_groups[] = {
-	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
-	"gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
-	"gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
-	"gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
-	"gpio29", "gpio30", "gpio31",
-};
-
-static const u32 lpi_offset[] = {
-	0x00000000,
-	0x00001000,
-	0x00002000,
-	0x00003000,
-	0x00004000,
-	0x00005000,
-	0x00006000,
-	0x00007000,
-	0x00008000,
-	0x00009000,
-	0x0000A000,
-	0x0000B000,
-	0x0000C000,
-	0x0000D000,
-	0x0000E000,
-	0x0000F000,
-	0x00010000,
-	0x00011000,
-	0x00012000,
-	0x00013000,
-	0x00014000,
-	0x00015000,
-	0x00016000,
-	0x00017000,
-	0x00018000,
-	0x00019000,
-	0x0001A000,
-	0x0001B000,
-	0x0001C000,
-	0x0001D000,
-	0x0001E000,
-	0x0001F000,
-};
-
-static const char *const lpi_gpio_functions[] = {
-	[LPI_GPIO_FUNC_INDEX_GPIO]	= LPI_GPIO_FUNC_GPIO,
-	[LPI_GPIO_FUNC_INDEX_FUNC1]	= LPI_GPIO_FUNC_FUNC1,
-	[LPI_GPIO_FUNC_INDEX_FUNC2]	= LPI_GPIO_FUNC_FUNC2,
-	[LPI_GPIO_FUNC_INDEX_FUNC3]	= LPI_GPIO_FUNC_FUNC3,
-	[LPI_GPIO_FUNC_INDEX_FUNC4]	= LPI_GPIO_FUNC_FUNC4,
-	[LPI_GPIO_FUNC_INDEX_FUNC5]	= LPI_GPIO_FUNC_FUNC5,
-};
-
-static int lpi_gpio_read(struct lpi_gpio_pad *pad, unsigned int addr)
-{
-	int ret;
-
-	if (!lpi_dev_up) {
-		pr_err_ratelimited("%s: ADSP is down due to SSR, return\n",
-				   __func__);
-		return 0;
-	}
-
-	ret = ioread32(pad->base + pad->offset + addr);
-	if (ret < 0)
-		pr_err("%s: read 0x%x failed\n", __func__, addr);
-
-	return ret;
-}
-
-static int lpi_gpio_write(struct lpi_gpio_pad *pad, unsigned int addr,
-			  unsigned int val)
-{
-	if (!lpi_dev_up) {
-		pr_err_ratelimited("%s: ADSP is down due to SSR, return\n",
-				   __func__);
-		return 0;
-	}
-
-	iowrite32(val, pad->base + pad->offset + addr);
-	return 0;
-}
-
-static int lpi_gpio_get_groups_count(struct pinctrl_dev *pctldev)
-{
-	/* Every PIN is a group */
-	return pctldev->desc->npins;
-}
-
-static const char *lpi_gpio_get_group_name(struct pinctrl_dev *pctldev,
-					   unsigned int pin)
-{
-	return pctldev->desc->pins[pin].name;
-}
-
-static int lpi_gpio_get_group_pins(struct pinctrl_dev *pctldev,
-				   unsigned int pin,
-				   const unsigned int **pins,
-				   unsigned int *num_pins)
-{
-	*pins = &pctldev->desc->pins[pin].number;
-	*num_pins = 1;
-	return 0;
-}
-
-static const struct pinctrl_ops lpi_gpio_pinctrl_ops = {
-	.get_groups_count	= lpi_gpio_get_groups_count,
-	.get_group_name		= lpi_gpio_get_group_name,
-	.get_group_pins		= lpi_gpio_get_group_pins,
-	.dt_node_to_map		= pinconf_generic_dt_node_to_map_group,
-	.dt_free_map		= pinctrl_utils_free_map,
-};
-
-static int lpi_gpio_get_functions_count(struct pinctrl_dev *pctldev)
-{
-	return ARRAY_SIZE(lpi_gpio_functions);
-}
-
-static const char *lpi_gpio_get_function_name(struct pinctrl_dev *pctldev,
-					      unsigned int function)
-{
-	return lpi_gpio_functions[function];
-}
-
-static int lpi_gpio_get_function_groups(struct pinctrl_dev *pctldev,
-					unsigned int function,
-					const char *const **groups,
-					unsigned *const num_qgroups)
-{
-	*groups = lpi_gpio_groups;
-	*num_qgroups = pctldev->desc->npins;
-	return 0;
-}
-
-static int lpi_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned int function,
-			    unsigned int pin)
-{
-	struct lpi_gpio_pad *pad;
-	unsigned int val;
-
-	pad = pctldev->desc->pins[pin].drv_data;
-
-	pad->function = function;
-
-	val = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL);
-	val &= ~(LPI_GPIO_REG_FUNCTION_MASK);
-	val |= pad->function << LPI_GPIO_REG_FUNCTION_SHIFT;
-	lpi_gpio_write(pad, LPI_GPIO_REG_VAL_CTL, val);
-	return 0;
-}
-
-static const struct pinmux_ops lpi_gpio_pinmux_ops = {
-	.get_functions_count	= lpi_gpio_get_functions_count,
-	.get_function_name	= lpi_gpio_get_function_name,
-	.get_function_groups	= lpi_gpio_get_function_groups,
-	.set_mux		= lpi_gpio_set_mux,
-};
-
-static int lpi_config_get(struct pinctrl_dev *pctldev,
-			  unsigned int pin, unsigned long *config)
-{
-	unsigned int param = pinconf_to_config_param(*config);
-	struct lpi_gpio_pad *pad;
-	unsigned int arg;
-
-	pad = pctldev->desc->pins[pin].drv_data;
-
-	switch (param) {
-	case PIN_CONFIG_BIAS_DISABLE:
-		arg = pad->pullup = LPI_GPIO_BIAS_DISABLE;
-		break;
-	case PIN_CONFIG_BIAS_PULL_DOWN:
-		arg = pad->pullup == LPI_GPIO_PULL_DOWN;
-		break;
-	case PIN_CONFIG_BIAS_BUS_HOLD:
-		arg = pad->pullup = LPI_GPIO_KEEPER;
-		break;
-	case PIN_CONFIG_BIAS_PULL_UP:
-		arg = pad->pullup == LPI_GPIO_PULL_UP;
-		break;
-	case PIN_CONFIG_INPUT_ENABLE:
-	case PIN_CONFIG_OUTPUT:
-		arg = pad->output_enabled;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	*config = pinconf_to_config_packed(param, arg);
-	return 0;
-}
-
-static unsigned int lpi_drive_to_regval(u32 arg)
-{
-	return (arg/2 - 1);
-}
-
-static int lpi_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
-			  unsigned long *configs, unsigned int nconfs)
-{
-	struct lpi_gpio_pad *pad;
-	unsigned int param, arg;
-	int i, ret = 0, val;
-
-	pad = pctldev->desc->pins[pin].drv_data;
-
-	for (i = 0; i < nconfs; i++) {
-		param = pinconf_to_config_param(configs[i]);
-		arg = pinconf_to_config_argument(configs[i]);
-
-		dev_dbg(pctldev->dev, "%s: param: %d arg: %d pin: %d\n",
-			__func__, param, arg, pin);
-
-		switch (param) {
-		case PIN_CONFIG_BIAS_DISABLE:
-			pad->pullup = LPI_GPIO_BIAS_DISABLE;
-			break;
-		case PIN_CONFIG_BIAS_PULL_DOWN:
-			pad->pullup = LPI_GPIO_PULL_DOWN;
-			break;
-		case PIN_CONFIG_BIAS_BUS_HOLD:
-			pad->pullup = LPI_GPIO_KEEPER;
-			break;
-		case PIN_CONFIG_BIAS_PULL_UP:
-			pad->pullup = LPI_GPIO_PULL_UP;
-			break;
-		case PIN_CONFIG_INPUT_ENABLE:
-			pad->output_enabled = false;
-			break;
-		case PIN_CONFIG_OUTPUT:
-			pad->output_enabled = true;
-			pad->value = arg;
-			break;
-		case PIN_CONFIG_DRIVE_STRENGTH:
-			pad->strength = arg;
-			break;
-		default:
-			ret = -EINVAL;
-			goto done;
-		}
-	}
-
-	val = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL);
-	val &= ~(LPI_GPIO_REG_PULL_MASK | LPI_GPIO_REG_OUT_STRENGTH_MASK |
-		 LPI_GPIO_REG_OE_MASK);
-	val |= pad->pullup << LPI_GPIO_REG_PULL_SHIFT;
-	val |= lpi_drive_to_regval(pad->strength) <<
-		LPI_GPIO_REG_OUT_STRENGTH_SHIFT;
-	if (pad->output_enabled)
-		val |= pad->value << LPI_GPIO_REG_OE_SHIFT;
-
-	lpi_gpio_write(pad, LPI_GPIO_REG_VAL_CTL, val);
-	lpi_gpio_write(pad, LPI_GPIO_REG_DIR_CTL,
-		       pad->output_enabled << LPI_GPIO_REG_DIR_SHIFT);
-done:
-	return ret;
-}
-
-static const struct pinconf_ops lpi_gpio_pinconf_ops = {
-	.is_generic			= true,
-	.pin_config_group_get		= lpi_config_get,
-	.pin_config_group_set		= lpi_config_set,
-};
-
-static int lpi_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
-{
-	struct lpi_gpio_state *state = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1);
-
-	return lpi_config_set(state->ctrl, pin, &config, 1);
-}
-
-static int lpi_gpio_direction_output(struct gpio_chip *chip,
-				     unsigned int pin, int val)
-{
-	struct lpi_gpio_state *state = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val);
-
-	return lpi_config_set(state->ctrl, pin, &config, 1);
-}
-
-static int lpi_gpio_get(struct gpio_chip *chip, unsigned int pin)
-{
-	struct lpi_gpio_state *state = gpiochip_get_data(chip);
-	struct lpi_gpio_pad *pad;
-	int value;
-
-	pad = state->ctrl->desc->pins[pin].drv_data;
-
-	value = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL);
-	return value;
-}
-
-static void lpi_gpio_set(struct gpio_chip *chip, unsigned int pin, int value)
-{
-	struct lpi_gpio_state *state = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value);
-
-	lpi_config_set(state->ctrl, pin, &config, 1);
-}
-
-static int lpi_notifier_service_cb(struct notifier_block *this,
-				   unsigned long opcode, void *ptr)
-{
-	static bool initial_boot = true;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		if (initial_boot) {
-			initial_boot = false;
-			break;
-		}
-		lpi_dev_up = false;
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (initial_boot)
-			initial_boot = false;
-		lpi_dev_up = true;
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block service_nb = {
-	.notifier_call  = lpi_notifier_service_cb,
-	.priority = -INT_MAX,
-};
-
-#ifdef CONFIG_DEBUG_FS
-#include <linux/seq_file.h>
-
-static unsigned int lpi_regval_to_drive(u32 val)
-{
-	return (val + 1) * 2;
-}
-
-static void lpi_gpio_dbg_show_one(struct seq_file *s,
-				  struct pinctrl_dev *pctldev,
-				  struct gpio_chip *chip,
-				  unsigned int offset,
-				  unsigned int gpio)
-{
-	struct lpi_gpio_state *state = gpiochip_get_data(chip);
-	struct pinctrl_pin_desc pindesc;
-	struct lpi_gpio_pad *pad;
-	unsigned int func;
-	int is_out;
-	int drive;
-	int pull;
-	u32 ctl_reg;
-
-	static const char * const pulls[] = {
-		"no pull",
-		"pull down",
-		"keeper",
-		"pull up"
-	};
-
-	pctldev = pctldev ? : state->ctrl;
-	pindesc = pctldev->desc->pins[offset];
-	pad = pctldev->desc->pins[offset].drv_data;
-	ctl_reg = lpi_gpio_read(pad, LPI_GPIO_REG_DIR_CTL);
-	is_out = (ctl_reg & LPI_GPIO_REG_DIR_MASK) >> LPI_GPIO_REG_DIR_SHIFT;
-	ctl_reg = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL);
-
-	func = (ctl_reg & LPI_GPIO_REG_FUNCTION_MASK) >>
-		LPI_GPIO_REG_FUNCTION_SHIFT;
-	drive = (ctl_reg & LPI_GPIO_REG_OUT_STRENGTH_MASK) >>
-		 LPI_GPIO_REG_OUT_STRENGTH_SHIFT;
-	pull = (ctl_reg & LPI_GPIO_REG_PULL_MASK) >> LPI_GPIO_REG_PULL_SHIFT;
-
-	seq_printf(s, " %-8s: %-3s %d",
-		   pindesc.name, is_out ? "out" : "in", func);
-	seq_printf(s, " %dmA", lpi_regval_to_drive(drive));
-	seq_printf(s, " %s", pulls[pull]);
-}
-
-static void lpi_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
-{
-	unsigned int gpio = chip->base;
-	unsigned int i;
-
-	for (i = 0; i < chip->ngpio; i++, gpio++) {
-		lpi_gpio_dbg_show_one(s, NULL, chip, i, gpio);
-		seq_puts(s, "\n");
-	}
-}
-
-#else
-#define lpi_gpio_dbg_show NULL
-#endif
-
-static const struct gpio_chip lpi_gpio_template = {
-	.direction_input	= lpi_gpio_direction_input,
-	.direction_output	= lpi_gpio_direction_output,
-	.get			= lpi_gpio_get,
-	.set			= lpi_gpio_set,
-	.request		= gpiochip_generic_request,
-	.free			= gpiochip_generic_free,
-	.dbg_show		= lpi_gpio_dbg_show,
-};
-
-static int lpi_pinctrl_probe(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct pinctrl_pin_desc *pindesc;
-	struct pinctrl_desc *pctrldesc;
-	struct lpi_gpio_pad *pad, *pads;
-	struct lpi_gpio_state *state;
-	int ret, npins, i;
-	char __iomem *lpi_base;
-	u32 reg;
-
-	ret = of_property_read_u32(dev->of_node, "reg", &reg);
-	if (ret < 0) {
-		dev_err(dev, "missing base address\n");
-		return ret;
-	}
-
-	ret = of_property_read_u32(dev->of_node, "qcom,num-gpios", &npins);
-	if (ret < 0)
-		return ret;
-
-	WARN_ON(npins > ARRAY_SIZE(lpi_gpio_groups));
-
-	state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
-	if (!state)
-		return -ENOMEM;
-
-	platform_set_drvdata(pdev, state);
-
-	state->dev = &pdev->dev;
-
-	pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL);
-	if (!pindesc)
-		return -ENOMEM;
-
-	pads = devm_kcalloc(dev, npins, sizeof(*pads), GFP_KERNEL);
-	if (!pads)
-		return -ENOMEM;
-
-	pctrldesc = devm_kzalloc(dev, sizeof(*pctrldesc), GFP_KERNEL);
-	if (!pctrldesc)
-		return -ENOMEM;
-
-	pctrldesc->pctlops = &lpi_gpio_pinctrl_ops;
-	pctrldesc->pmxops = &lpi_gpio_pinmux_ops;
-	pctrldesc->confops = &lpi_gpio_pinconf_ops;
-	pctrldesc->owner = THIS_MODULE;
-	pctrldesc->name = dev_name(dev);
-	pctrldesc->pins = pindesc;
-	pctrldesc->npins = npins;
-
-	lpi_base = devm_ioremap(dev, reg, LPI_ADDRESS_SIZE);
-	if (lpi_base == NULL) {
-		dev_err(dev, "%s devm_ioremap failed\n", __func__);
-		return -ENOMEM;
-	}
-
-	state->base = lpi_base;
-
-	for (i = 0; i < npins; i++, pindesc++) {
-		pad = &pads[i];
-		pindesc->drv_data = pad;
-		pindesc->number = i;
-		pindesc->name = lpi_gpio_groups[i];
-
-		pad->base = lpi_base;
-		pad->offset = lpi_offset[i];
-	}
-
-	state->chip = lpi_gpio_template;
-	state->chip.parent = dev;
-	state->chip.base = -1;
-	state->chip.ngpio = npins;
-	state->chip.label = dev_name(dev);
-	state->chip.of_gpio_n_cells = 2;
-	state->chip.can_sleep = false;
-
-	state->ctrl = devm_pinctrl_register(dev, pctrldesc, state);
-	if (IS_ERR(state->ctrl))
-		return PTR_ERR(state->ctrl);
-
-	ret = gpiochip_add_data(&state->chip, state);
-	if (ret) {
-		dev_err(state->dev, "can't add gpio chip\n");
-		goto err_chip;
-	}
-
-	ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
-	if (ret) {
-		dev_err(dev, "failed to add pin range\n");
-		goto err_range;
-	}
-
-	lpi_dev_up = true;
-	ret = audio_notifier_register("lpi_tlmm", AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &service_nb);
-	if (ret < 0) {
-		pr_err("%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-		goto err_range;
-	}
-
-	return 0;
-
-err_range:
-	gpiochip_remove(&state->chip);
-err_chip:
-	return ret;
-}
-
-static int lpi_pinctrl_remove(struct platform_device *pdev)
-{
-	struct lpi_gpio_state *state = platform_get_drvdata(pdev);
-
-	gpiochip_remove(&state->chip);
-	return 0;
-}
-
-static const struct of_device_id lpi_pinctrl_of_match[] = {
-	{ .compatible = "qcom,lpi-pinctrl" }, /* Generic */
-	{ },
-};
-
-MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);
-
-static struct platform_driver lpi_pinctrl_driver = {
-	.driver = {
-		   .name = "qcom-lpi-pinctrl",
-		   .of_match_table = lpi_pinctrl_of_match,
-	},
-	.probe = lpi_pinctrl_probe,
-	.remove = lpi_pinctrl_remove,
-};
-
-module_platform_driver(lpi_pinctrl_driver);
-
-MODULE_DESCRIPTION("QTI LPI GPIO pin control driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 166935ec..13e9a0d 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -39,7 +39,6 @@
 
 #define MAX_NR_GPIO 300
 #define PS_HOLD_OFFSET 0x820
-#define STATUS_OFFSET 0x10
 
 /**
  * struct msm_pinctrl - state for a pinctrl-msm device
@@ -72,35 +71,6 @@
 	void __iomem *regs;
 };
 
-static u32 msm_pinctrl_find_base(const struct msm_pinctrl *pctrl, u32 gpio_id)
-{
-	int i;
-	u32 val;
-	const struct msm_pinctrl_soc_data *soc_data = pctrl->soc;
-
-	if (gpio_id >= soc_data->ngpios || !soc_data->pin_base)
-		return 0;
-
-	if (soc_data->pin_base[gpio_id])
-		return soc_data->pin_base[gpio_id];
-
-	for (i = 0; i < soc_data->n_tile_offsets; i++) {
-		val = readl_relaxed(pctrl->regs +
-			soc_data->tile_offsets[i] + STATUS_OFFSET
-			+ soc_data->reg_size * gpio_id);
-		if (val) {
-			soc_data->pin_base[gpio_id] = soc_data->tile_offsets[i];
-			return soc_data->tile_offsets[i];
-		}
-	}
-
-	/* In the case that the soc_data does not support dynamic base
-	 * detection, we return 0 here.
-	 */
-	WARN_ONCE(1, "%s:Dynamic base detection is not supported\n", __func__);
-	return 0;
-}
-
 static int msm_get_groups_count(struct pinctrl_dev *pctldev)
 {
 	struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
@@ -170,11 +140,10 @@
 	struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
 	const struct msm_pingroup *g;
 	unsigned long flags;
-	u32 val, mask, base;
+	u32 val, mask;
 	int i;
 
 	g = &pctrl->soc->groups[group];
-	base = msm_pinctrl_find_base(pctrl, group);
 	mask = GENMASK(g->mux_bit + order_base_2(g->nfuncs) - 1, g->mux_bit);
 
 	for (i = 0; i < g->nfuncs; i++) {
@@ -187,10 +156,10 @@
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->ctl_reg);
+	val = readl(pctrl->regs + g->ctl_reg);
 	val &= ~mask;
 	val |= i << g->mux_bit;
-	writel(val, pctrl->regs + base + g->ctl_reg);
+	writel(val, pctrl->regs + g->ctl_reg);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 
@@ -255,16 +224,15 @@
 	unsigned arg;
 	unsigned bit;
 	int ret;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[group];
-	base = msm_pinctrl_find_base(pctrl, group);
 
 	ret = msm_config_reg(pctrl, g, param, &mask, &bit);
 	if (ret < 0)
 		return ret;
 
-	val = readl(pctrl->regs + base + g->ctl_reg);
+	val = readl(pctrl->regs + g->ctl_reg);
 	arg = (val >> bit) & mask;
 
 	/* Convert register value to pinconf value */
@@ -289,7 +257,7 @@
 		if (!arg)
 			return -EINVAL;
 
-		val = readl(pctrl->regs + base + g->io_reg);
+		val = readl(pctrl->regs + g->io_reg);
 		arg = !!(val & BIT(g->in_bit));
 		break;
 	case PIN_CONFIG_INPUT_ENABLE:
@@ -320,12 +288,11 @@
 	unsigned arg;
 	unsigned bit;
 	int ret;
-	u32 val, base;
+	u32 val;
 	int i;
 
 	g = &pctrl->soc->groups[group];
 
-	base = msm_pinctrl_find_base(pctrl, group);
 	for (i = 0; i < num_configs; i++) {
 		param = pinconf_to_config_param(configs[i]);
 		arg = pinconf_to_config_argument(configs[i]);
@@ -358,12 +325,12 @@
 		case PIN_CONFIG_OUTPUT:
 			/* set output value */
 			spin_lock_irqsave(&pctrl->lock, flags);
-			val = readl(pctrl->regs + base + g->io_reg);
+			val = readl(pctrl->regs + g->io_reg);
 			if (arg)
 				val |= BIT(g->out_bit);
 			else
 				val &= ~BIT(g->out_bit);
-			writel(val, pctrl->regs + base + g->io_reg);
+			writel(val, pctrl->regs + g->io_reg);
 			spin_unlock_irqrestore(&pctrl->lock, flags);
 
 			/* enable output */
@@ -386,10 +353,10 @@
 		}
 
 		spin_lock_irqsave(&pctrl->lock, flags);
-		val = readl(pctrl->regs + base + g->ctl_reg);
+		val = readl(pctrl->regs + g->ctl_reg);
 		val &= ~(mask << bit);
 		val |= arg << bit;
-		writel(val, pctrl->regs + base + g->ctl_reg);
+		writel(val, pctrl->regs + g->ctl_reg);
 		spin_unlock_irqrestore(&pctrl->lock, flags);
 	}
 
@@ -414,16 +381,15 @@
 	const struct msm_pingroup *g;
 	struct msm_pinctrl *pctrl = gpiochip_get_data(chip);
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[offset];
-	base = msm_pinctrl_find_base(pctrl, offset);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->ctl_reg);
+	val = readl(pctrl->regs + g->ctl_reg);
 	val &= ~BIT(g->oe_bit);
-	writel(val, pctrl->regs + base + g->ctl_reg);
+	writel(val, pctrl->regs + g->ctl_reg);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 
@@ -435,23 +401,22 @@
 	const struct msm_pingroup *g;
 	struct msm_pinctrl *pctrl = gpiochip_get_data(chip);
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[offset];
-	base = msm_pinctrl_find_base(pctrl, offset);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->io_reg);
+	val = readl(pctrl->regs + g->io_reg);
 	if (value)
 		val |= BIT(g->out_bit);
 	else
 		val &= ~BIT(g->out_bit);
-	writel(val, pctrl->regs + base + g->io_reg);
+	writel(val, pctrl->regs + g->io_reg);
 
-	val = readl(pctrl->regs + base + g->ctl_reg);
+	val = readl(pctrl->regs + g->ctl_reg);
 	val |= BIT(g->oe_bit);
-	writel(val, pctrl->regs + base + g->ctl_reg);
+	writel(val, pctrl->regs + g->ctl_reg);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 
@@ -462,12 +427,11 @@
 {
 	const struct msm_pingroup *g;
 	struct msm_pinctrl *pctrl = gpiochip_get_data(chip);
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[offset];
-	base = msm_pinctrl_find_base(pctrl, offset);
 
-	val = readl(pctrl->regs + base + g->io_reg);
+	val = readl(pctrl->regs + g->io_reg);
 	return !!(val & BIT(g->in_bit));
 }
 
@@ -476,19 +440,18 @@
 	const struct msm_pingroup *g;
 	struct msm_pinctrl *pctrl = gpiochip_get_data(chip);
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[offset];
-	base = msm_pinctrl_find_base(pctrl, offset);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->io_reg);
+	val = readl(pctrl->regs + g->io_reg);
 	if (value)
 		val |= BIT(g->out_bit);
 	else
 		val &= ~BIT(g->out_bit);
-	writel(val, pctrl->regs + base + g->io_reg);
+	writel(val, pctrl->regs + g->io_reg);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 }
@@ -508,7 +471,7 @@
 	int is_out;
 	int drive;
 	int pull;
-	u32 ctl_reg, base;
+	u32 ctl_reg;
 
 	static const char * const pulls[] = {
 		"no pull",
@@ -518,9 +481,7 @@
 	};
 
 	g = &pctrl->soc->groups[offset];
-	base = msm_pinctrl_find_base(pctrl, offset);
-
-	ctl_reg = readl(pctrl->regs + base + g->ctl_reg);
+	ctl_reg = readl(pctrl->regs + g->ctl_reg);
 
 	is_out = !!(ctl_reg & BIT(g->oe_bit));
 	func = (ctl_reg >> g->mux_bit) & 7;
@@ -579,21 +540,21 @@
  */
 static void msm_gpio_update_dual_edge_pos(struct msm_pinctrl *pctrl,
 					  const struct msm_pingroup *g,
-					  struct irq_data *d, u32 base)
+					  struct irq_data *d)
 {
 	int loop_limit = 100;
 	unsigned val, val2, intstat;
 	unsigned pol;
 
 	do {
-		val = readl(pctrl->regs + base + g->io_reg) & BIT(g->in_bit);
+		val = readl(pctrl->regs + g->io_reg) & BIT(g->in_bit);
 
-		pol = readl(pctrl->regs + base + g->intr_cfg_reg);
+		pol = readl(pctrl->regs + g->intr_cfg_reg);
 		pol ^= BIT(g->intr_polarity_bit);
-		writel(pol, pctrl->regs + base + g->intr_cfg_reg);
+		writel(pol, pctrl->regs + g->intr_cfg_reg);
 
-		val2 = readl(pctrl->regs + base + g->io_reg) & BIT(g->in_bit);
-		intstat = readl(pctrl->regs + base + g->intr_status_reg);
+		val2 = readl(pctrl->regs + g->io_reg) & BIT(g->in_bit);
+		intstat = readl(pctrl->regs + g->intr_status_reg);
 		if (intstat || (val == val2))
 			return;
 	} while (loop_limit-- > 0);
@@ -607,16 +568,15 @@
 	struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
 	const struct msm_pingroup *g;
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[d->hwirq];
-	base = msm_pinctrl_find_base(pctrl, d->hwirq);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->intr_cfg_reg);
+	val = readl(pctrl->regs + g->intr_cfg_reg);
 	val &= ~BIT(g->intr_enable_bit);
-	writel(val, pctrl->regs + base + g->intr_cfg_reg);
+	writel(val, pctrl->regs + g->intr_cfg_reg);
 
 	clear_bit(d->hwirq, pctrl->enabled_irqs);
 
@@ -629,16 +589,15 @@
 	struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
 	const struct msm_pingroup *g;
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[d->hwirq];
-	base = msm_pinctrl_find_base(pctrl, d->hwirq);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->intr_cfg_reg);
+	val = readl(pctrl->regs + g->intr_cfg_reg);
 	val |= BIT(g->intr_enable_bit);
-	writel(val, pctrl->regs + base + g->intr_cfg_reg);
+	writel(val, pctrl->regs + g->intr_cfg_reg);
 
 	set_bit(d->hwirq, pctrl->enabled_irqs);
 
@@ -651,22 +610,21 @@
 	struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
 	const struct msm_pingroup *g;
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[d->hwirq];
-	base = msm_pinctrl_find_base(pctrl, d->hwirq);
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	val = readl(pctrl->regs + base + g->intr_status_reg);
+	val = readl(pctrl->regs + g->intr_status_reg);
 	if (g->intr_ack_high)
 		val |= BIT(g->intr_status_bit);
 	else
 		val &= ~BIT(g->intr_status_bit);
-	writel(val, pctrl->regs + base + g->intr_status_reg);
+	writel(val, pctrl->regs + g->intr_status_reg);
 
 	if (test_bit(d->hwirq, pctrl->dual_edge_irqs))
-		msm_gpio_update_dual_edge_pos(pctrl, g, d, base);
+		msm_gpio_update_dual_edge_pos(pctrl, g, d);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 }
@@ -677,10 +635,10 @@
 	struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
 	const struct msm_pingroup *g;
 	unsigned long flags;
-	u32 val, base;
+	u32 val;
 
 	g = &pctrl->soc->groups[d->hwirq];
-	base = msm_pinctrl_find_base(pctrl, d->hwirq);
+
 	spin_lock_irqsave(&pctrl->lock, flags);
 
 	/*
@@ -692,17 +650,17 @@
 		clear_bit(d->hwirq, pctrl->dual_edge_irqs);
 
 	/* Route interrupts to application cpu */
-	val = readl(pctrl->regs + base + g->intr_target_reg);
+	val = readl(pctrl->regs + g->intr_target_reg);
 	val &= ~(7 << g->intr_target_bit);
 	val |= g->intr_target_kpss_val << g->intr_target_bit;
-	writel(val, pctrl->regs + base + g->intr_target_reg);
+	writel(val, pctrl->regs + g->intr_target_reg);
 
 	/* Update configuration for gpio.
 	 * RAW_STATUS_EN is left on for all gpio irqs. Due to the
 	 * internal circuitry of TLMM, toggling the RAW_STATUS
 	 * could cause the INTR_STATUS to be set for EDGE interrupts.
 	 */
-	val = readl(pctrl->regs + base + g->intr_cfg_reg);
+	val = readl(pctrl->regs + g->intr_cfg_reg);
 	val |= BIT(g->intr_raw_status_bit);
 	if (g->intr_detection_width == 2) {
 		val &= ~(3 << g->intr_detection_bit);
@@ -750,10 +708,10 @@
 	} else {
 		BUG();
 	}
-	writel(val, pctrl->regs + base + g->intr_cfg_reg);
+	writel(val, pctrl->regs + g->intr_cfg_reg);
 
 	if (test_bit(d->hwirq, pctrl->dual_edge_irqs))
-		msm_gpio_update_dual_edge_pos(pctrl, g, d, base);
+		msm_gpio_update_dual_edge_pos(pctrl, g, d);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
 
@@ -882,7 +840,7 @@
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	int irq_pin;
 	int handled = 0;
-	u32 val, base;
+	u32 val;
 	int i;
 
 	chained_irq_enter(chip, desc);
@@ -893,8 +851,7 @@
 	 */
 	for_each_set_bit(i, pctrl->enabled_irqs, pctrl->chip.ngpio) {
 		g = &pctrl->soc->groups[i];
-		base = msm_pinctrl_find_base(pctrl, i);
-		val = readl(pctrl->regs + base + g->intr_status_reg);
+		val = readl(pctrl->regs + g->intr_status_reg);
 		if (val & BIT(g->intr_status_bit)) {
 			irq_pin = irq_find_mapping(gc->irqdomain, i);
 			generic_handle_irq(irq_pin);
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
index 7ffc2e3..988b7ca 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.h
+++ b/drivers/pinctrl/qcom/pinctrl-msm.h
@@ -129,10 +129,6 @@
 	unsigned ngpios;
 	const struct msm_dir_conn *dir_conn;
 	unsigned int n_dir_conns;
-	const u32 *tile_offsets;
-	unsigned int n_tile_offsets;
-	u32 *pin_base;
-	unsigned int reg_size;
 };
 
 int msm_pinctrl_probe(struct platform_device *pdev,
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8953.c b/drivers/pinctrl/qcom/pinctrl-msm8953.c
new file mode 100644
index 0000000..ba1cad0
--- /dev/null
+++ b/drivers/pinctrl/qcom/pinctrl-msm8953.c
@@ -0,0 +1,1686 @@
+/*
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pinctrl/pinctrl.h>
+
+#include "pinctrl-msm.h"
+
+#define FUNCTION(fname)			                \
+	[msm_mux_##fname] = {		                \
+		.name = #fname,				\
+		.groups = fname##_groups,               \
+		.ngroups = ARRAY_SIZE(fname##_groups),	\
+	}
+
+#define REG_SIZE 0x1000
+#define PINGROUP(id, f1, f2, f3, f4, f5, f6, f7, f8, f9)	\
+	{					        \
+		.name = "gpio" #id,			\
+		.pins = gpio##id##_pins,		\
+		.npins = (unsigned int)ARRAY_SIZE(gpio##id##_pins),	\
+		.funcs = (int[]){			\
+			msm_mux_gpio, /* gpio mode */	\
+			msm_mux_##f1,			\
+			msm_mux_##f2,			\
+			msm_mux_##f3,			\
+			msm_mux_##f4,			\
+			msm_mux_##f5,			\
+			msm_mux_##f6,			\
+			msm_mux_##f7,			\
+			msm_mux_##f8,			\
+			msm_mux_##f9			\
+		},				        \
+		.nfuncs = 10,				\
+		.ctl_reg = REG_SIZE * id,			\
+		.io_reg = 0x4 + REG_SIZE * id,		\
+		.intr_cfg_reg = 0x8 + REG_SIZE * id,		\
+		.intr_status_reg = 0xc + REG_SIZE * id,	\
+		.intr_target_reg = 0x8 + REG_SIZE * id,	\
+		.mux_bit = 2,			\
+		.pull_bit = 0,			\
+		.drv_bit = 6,			\
+		.oe_bit = 9,			\
+		.in_bit = 0,			\
+		.out_bit = 1,			\
+		.intr_enable_bit = 0,		\
+		.intr_status_bit = 0,		\
+		.intr_target_bit = 5,		\
+		.intr_target_kpss_val = 4,	\
+		.intr_raw_status_bit = 4,	\
+		.intr_polarity_bit = 1,		\
+		.intr_detection_bit = 2,	\
+		.intr_detection_width = 2,	\
+	}
+
+#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv)	\
+	{					        \
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = (unsigned int)ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = ctl,				\
+		.io_reg = 0,				\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = pull,			\
+		.drv_bit = drv,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = -1,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+static const struct pinctrl_pin_desc msm8953_pins[] = {
+	PINCTRL_PIN(0, "GPIO_0"),
+	PINCTRL_PIN(1, "GPIO_1"),
+	PINCTRL_PIN(2, "GPIO_2"),
+	PINCTRL_PIN(3, "GPIO_3"),
+	PINCTRL_PIN(4, "GPIO_4"),
+	PINCTRL_PIN(5, "GPIO_5"),
+	PINCTRL_PIN(6, "GPIO_6"),
+	PINCTRL_PIN(7, "GPIO_7"),
+	PINCTRL_PIN(8, "GPIO_8"),
+	PINCTRL_PIN(9, "GPIO_9"),
+	PINCTRL_PIN(10, "GPIO_10"),
+	PINCTRL_PIN(11, "GPIO_11"),
+	PINCTRL_PIN(12, "GPIO_12"),
+	PINCTRL_PIN(13, "GPIO_13"),
+	PINCTRL_PIN(14, "GPIO_14"),
+	PINCTRL_PIN(15, "GPIO_15"),
+	PINCTRL_PIN(16, "GPIO_16"),
+	PINCTRL_PIN(17, "GPIO_17"),
+	PINCTRL_PIN(18, "GPIO_18"),
+	PINCTRL_PIN(19, "GPIO_19"),
+	PINCTRL_PIN(20, "GPIO_20"),
+	PINCTRL_PIN(21, "GPIO_21"),
+	PINCTRL_PIN(22, "GPIO_22"),
+	PINCTRL_PIN(23, "GPIO_23"),
+	PINCTRL_PIN(24, "GPIO_24"),
+	PINCTRL_PIN(25, "GPIO_25"),
+	PINCTRL_PIN(26, "GPIO_26"),
+	PINCTRL_PIN(27, "GPIO_27"),
+	PINCTRL_PIN(28, "GPIO_28"),
+	PINCTRL_PIN(29, "GPIO_29"),
+	PINCTRL_PIN(30, "GPIO_30"),
+	PINCTRL_PIN(31, "GPIO_31"),
+	PINCTRL_PIN(32, "GPIO_32"),
+	PINCTRL_PIN(33, "GPIO_33"),
+	PINCTRL_PIN(34, "GPIO_34"),
+	PINCTRL_PIN(35, "GPIO_35"),
+	PINCTRL_PIN(36, "GPIO_36"),
+	PINCTRL_PIN(37, "GPIO_37"),
+	PINCTRL_PIN(38, "GPIO_38"),
+	PINCTRL_PIN(39, "GPIO_39"),
+	PINCTRL_PIN(40, "GPIO_40"),
+	PINCTRL_PIN(41, "GPIO_41"),
+	PINCTRL_PIN(42, "GPIO_42"),
+	PINCTRL_PIN(43, "GPIO_43"),
+	PINCTRL_PIN(44, "GPIO_44"),
+	PINCTRL_PIN(45, "GPIO_45"),
+	PINCTRL_PIN(46, "GPIO_46"),
+	PINCTRL_PIN(47, "GPIO_47"),
+	PINCTRL_PIN(48, "GPIO_48"),
+	PINCTRL_PIN(49, "GPIO_49"),
+	PINCTRL_PIN(50, "GPIO_50"),
+	PINCTRL_PIN(51, "GPIO_51"),
+	PINCTRL_PIN(52, "GPIO_52"),
+	PINCTRL_PIN(53, "GPIO_53"),
+	PINCTRL_PIN(54, "GPIO_54"),
+	PINCTRL_PIN(55, "GPIO_55"),
+	PINCTRL_PIN(56, "GPIO_56"),
+	PINCTRL_PIN(57, "GPIO_57"),
+	PINCTRL_PIN(58, "GPIO_58"),
+	PINCTRL_PIN(59, "GPIO_59"),
+	PINCTRL_PIN(60, "GPIO_60"),
+	PINCTRL_PIN(61, "GPIO_61"),
+	PINCTRL_PIN(62, "GPIO_62"),
+	PINCTRL_PIN(63, "GPIO_63"),
+	PINCTRL_PIN(64, "GPIO_64"),
+	PINCTRL_PIN(65, "GPIO_65"),
+	PINCTRL_PIN(66, "GPIO_66"),
+	PINCTRL_PIN(67, "GPIO_67"),
+	PINCTRL_PIN(68, "GPIO_68"),
+	PINCTRL_PIN(69, "GPIO_69"),
+	PINCTRL_PIN(70, "GPIO_70"),
+	PINCTRL_PIN(71, "GPIO_71"),
+	PINCTRL_PIN(72, "GPIO_72"),
+	PINCTRL_PIN(73, "GPIO_73"),
+	PINCTRL_PIN(74, "GPIO_74"),
+	PINCTRL_PIN(75, "GPIO_75"),
+	PINCTRL_PIN(76, "GPIO_76"),
+	PINCTRL_PIN(77, "GPIO_77"),
+	PINCTRL_PIN(78, "GPIO_78"),
+	PINCTRL_PIN(79, "GPIO_79"),
+	PINCTRL_PIN(80, "GPIO_80"),
+	PINCTRL_PIN(81, "GPIO_81"),
+	PINCTRL_PIN(82, "GPIO_82"),
+	PINCTRL_PIN(83, "GPIO_83"),
+	PINCTRL_PIN(84, "GPIO_84"),
+	PINCTRL_PIN(85, "GPIO_85"),
+	PINCTRL_PIN(86, "GPIO_86"),
+	PINCTRL_PIN(87, "GPIO_87"),
+	PINCTRL_PIN(88, "GPIO_88"),
+	PINCTRL_PIN(89, "GPIO_89"),
+	PINCTRL_PIN(90, "GPIO_90"),
+	PINCTRL_PIN(91, "GPIO_91"),
+	PINCTRL_PIN(92, "GPIO_92"),
+	PINCTRL_PIN(93, "GPIO_93"),
+	PINCTRL_PIN(94, "GPIO_94"),
+	PINCTRL_PIN(95, "GPIO_95"),
+	PINCTRL_PIN(96, "GPIO_96"),
+	PINCTRL_PIN(97, "GPIO_97"),
+	PINCTRL_PIN(98, "GPIO_98"),
+	PINCTRL_PIN(99, "GPIO_99"),
+	PINCTRL_PIN(100, "GPIO_100"),
+	PINCTRL_PIN(101, "GPIO_101"),
+	PINCTRL_PIN(102, "GPIO_102"),
+	PINCTRL_PIN(103, "GPIO_103"),
+	PINCTRL_PIN(104, "GPIO_104"),
+	PINCTRL_PIN(105, "GPIO_105"),
+	PINCTRL_PIN(106, "GPIO_106"),
+	PINCTRL_PIN(107, "GPIO_107"),
+	PINCTRL_PIN(108, "GPIO_108"),
+	PINCTRL_PIN(109, "GPIO_109"),
+	PINCTRL_PIN(110, "GPIO_110"),
+	PINCTRL_PIN(111, "GPIO_111"),
+	PINCTRL_PIN(112, "GPIO_112"),
+	PINCTRL_PIN(113, "GPIO_113"),
+	PINCTRL_PIN(114, "GPIO_114"),
+	PINCTRL_PIN(115, "GPIO_115"),
+	PINCTRL_PIN(116, "GPIO_116"),
+	PINCTRL_PIN(117, "GPIO_117"),
+	PINCTRL_PIN(118, "GPIO_118"),
+	PINCTRL_PIN(119, "GPIO_119"),
+	PINCTRL_PIN(120, "GPIO_120"),
+	PINCTRL_PIN(121, "GPIO_121"),
+	PINCTRL_PIN(122, "GPIO_122"),
+	PINCTRL_PIN(123, "GPIO_123"),
+	PINCTRL_PIN(124, "GPIO_124"),
+	PINCTRL_PIN(125, "GPIO_125"),
+	PINCTRL_PIN(126, "GPIO_126"),
+	PINCTRL_PIN(127, "GPIO_127"),
+	PINCTRL_PIN(128, "GPIO_128"),
+	PINCTRL_PIN(129, "GPIO_129"),
+	PINCTRL_PIN(130, "GPIO_130"),
+	PINCTRL_PIN(131, "GPIO_131"),
+	PINCTRL_PIN(132, "GPIO_132"),
+	PINCTRL_PIN(133, "GPIO_133"),
+	PINCTRL_PIN(134, "GPIO_134"),
+	PINCTRL_PIN(135, "GPIO_135"),
+	PINCTRL_PIN(136, "GPIO_136"),
+	PINCTRL_PIN(137, "GPIO_137"),
+	PINCTRL_PIN(138, "GPIO_138"),
+	PINCTRL_PIN(139, "GPIO_139"),
+	PINCTRL_PIN(140, "GPIO_140"),
+	PINCTRL_PIN(141, "GPIO_141"),
+	PINCTRL_PIN(142, "SDC1_CLK"),
+	PINCTRL_PIN(143, "SDC1_CMD"),
+	PINCTRL_PIN(144, "SDC1_DATA"),
+	PINCTRL_PIN(145, "SDC1_RCLK"),
+	PINCTRL_PIN(146, "SDC2_CLK"),
+	PINCTRL_PIN(147, "SDC2_CMD"),
+	PINCTRL_PIN(148, "SDC2_DATA"),
+	PINCTRL_PIN(149, "QDSD_CLK"),
+	PINCTRL_PIN(150, "QDSD_CMD"),
+	PINCTRL_PIN(151, "QDSD_DATA0"),
+	PINCTRL_PIN(152, "QDSD_DATA1"),
+	PINCTRL_PIN(153, "QDSD_DATA2"),
+	PINCTRL_PIN(154, "QDSD_DATA3"),
+};
+
+#define DECLARE_MSM_GPIO_PINS(pin) \
+	static const unsigned int gpio##pin##_pins[] = { pin }
+DECLARE_MSM_GPIO_PINS(0);
+DECLARE_MSM_GPIO_PINS(1);
+DECLARE_MSM_GPIO_PINS(2);
+DECLARE_MSM_GPIO_PINS(3);
+DECLARE_MSM_GPIO_PINS(4);
+DECLARE_MSM_GPIO_PINS(5);
+DECLARE_MSM_GPIO_PINS(6);
+DECLARE_MSM_GPIO_PINS(7);
+DECLARE_MSM_GPIO_PINS(8);
+DECLARE_MSM_GPIO_PINS(9);
+DECLARE_MSM_GPIO_PINS(10);
+DECLARE_MSM_GPIO_PINS(11);
+DECLARE_MSM_GPIO_PINS(12);
+DECLARE_MSM_GPIO_PINS(13);
+DECLARE_MSM_GPIO_PINS(14);
+DECLARE_MSM_GPIO_PINS(15);
+DECLARE_MSM_GPIO_PINS(16);
+DECLARE_MSM_GPIO_PINS(17);
+DECLARE_MSM_GPIO_PINS(18);
+DECLARE_MSM_GPIO_PINS(19);
+DECLARE_MSM_GPIO_PINS(20);
+DECLARE_MSM_GPIO_PINS(21);
+DECLARE_MSM_GPIO_PINS(22);
+DECLARE_MSM_GPIO_PINS(23);
+DECLARE_MSM_GPIO_PINS(24);
+DECLARE_MSM_GPIO_PINS(25);
+DECLARE_MSM_GPIO_PINS(26);
+DECLARE_MSM_GPIO_PINS(27);
+DECLARE_MSM_GPIO_PINS(28);
+DECLARE_MSM_GPIO_PINS(29);
+DECLARE_MSM_GPIO_PINS(30);
+DECLARE_MSM_GPIO_PINS(31);
+DECLARE_MSM_GPIO_PINS(32);
+DECLARE_MSM_GPIO_PINS(33);
+DECLARE_MSM_GPIO_PINS(34);
+DECLARE_MSM_GPIO_PINS(35);
+DECLARE_MSM_GPIO_PINS(36);
+DECLARE_MSM_GPIO_PINS(37);
+DECLARE_MSM_GPIO_PINS(38);
+DECLARE_MSM_GPIO_PINS(39);
+DECLARE_MSM_GPIO_PINS(40);
+DECLARE_MSM_GPIO_PINS(41);
+DECLARE_MSM_GPIO_PINS(42);
+DECLARE_MSM_GPIO_PINS(43);
+DECLARE_MSM_GPIO_PINS(44);
+DECLARE_MSM_GPIO_PINS(45);
+DECLARE_MSM_GPIO_PINS(46);
+DECLARE_MSM_GPIO_PINS(47);
+DECLARE_MSM_GPIO_PINS(48);
+DECLARE_MSM_GPIO_PINS(49);
+DECLARE_MSM_GPIO_PINS(50);
+DECLARE_MSM_GPIO_PINS(51);
+DECLARE_MSM_GPIO_PINS(52);
+DECLARE_MSM_GPIO_PINS(53);
+DECLARE_MSM_GPIO_PINS(54);
+DECLARE_MSM_GPIO_PINS(55);
+DECLARE_MSM_GPIO_PINS(56);
+DECLARE_MSM_GPIO_PINS(57);
+DECLARE_MSM_GPIO_PINS(58);
+DECLARE_MSM_GPIO_PINS(59);
+DECLARE_MSM_GPIO_PINS(60);
+DECLARE_MSM_GPIO_PINS(61);
+DECLARE_MSM_GPIO_PINS(62);
+DECLARE_MSM_GPIO_PINS(63);
+DECLARE_MSM_GPIO_PINS(64);
+DECLARE_MSM_GPIO_PINS(65);
+DECLARE_MSM_GPIO_PINS(66);
+DECLARE_MSM_GPIO_PINS(67);
+DECLARE_MSM_GPIO_PINS(68);
+DECLARE_MSM_GPIO_PINS(69);
+DECLARE_MSM_GPIO_PINS(70);
+DECLARE_MSM_GPIO_PINS(71);
+DECLARE_MSM_GPIO_PINS(72);
+DECLARE_MSM_GPIO_PINS(73);
+DECLARE_MSM_GPIO_PINS(74);
+DECLARE_MSM_GPIO_PINS(75);
+DECLARE_MSM_GPIO_PINS(76);
+DECLARE_MSM_GPIO_PINS(77);
+DECLARE_MSM_GPIO_PINS(78);
+DECLARE_MSM_GPIO_PINS(79);
+DECLARE_MSM_GPIO_PINS(80);
+DECLARE_MSM_GPIO_PINS(81);
+DECLARE_MSM_GPIO_PINS(82);
+DECLARE_MSM_GPIO_PINS(83);
+DECLARE_MSM_GPIO_PINS(84);
+DECLARE_MSM_GPIO_PINS(85);
+DECLARE_MSM_GPIO_PINS(86);
+DECLARE_MSM_GPIO_PINS(87);
+DECLARE_MSM_GPIO_PINS(88);
+DECLARE_MSM_GPIO_PINS(89);
+DECLARE_MSM_GPIO_PINS(90);
+DECLARE_MSM_GPIO_PINS(91);
+DECLARE_MSM_GPIO_PINS(92);
+DECLARE_MSM_GPIO_PINS(93);
+DECLARE_MSM_GPIO_PINS(94);
+DECLARE_MSM_GPIO_PINS(95);
+DECLARE_MSM_GPIO_PINS(96);
+DECLARE_MSM_GPIO_PINS(97);
+DECLARE_MSM_GPIO_PINS(98);
+DECLARE_MSM_GPIO_PINS(99);
+DECLARE_MSM_GPIO_PINS(100);
+DECLARE_MSM_GPIO_PINS(101);
+DECLARE_MSM_GPIO_PINS(102);
+DECLARE_MSM_GPIO_PINS(103);
+DECLARE_MSM_GPIO_PINS(104);
+DECLARE_MSM_GPIO_PINS(105);
+DECLARE_MSM_GPIO_PINS(106);
+DECLARE_MSM_GPIO_PINS(107);
+DECLARE_MSM_GPIO_PINS(108);
+DECLARE_MSM_GPIO_PINS(109);
+DECLARE_MSM_GPIO_PINS(110);
+DECLARE_MSM_GPIO_PINS(111);
+DECLARE_MSM_GPIO_PINS(112);
+DECLARE_MSM_GPIO_PINS(113);
+DECLARE_MSM_GPIO_PINS(114);
+DECLARE_MSM_GPIO_PINS(115);
+DECLARE_MSM_GPIO_PINS(116);
+DECLARE_MSM_GPIO_PINS(117);
+DECLARE_MSM_GPIO_PINS(118);
+DECLARE_MSM_GPIO_PINS(119);
+DECLARE_MSM_GPIO_PINS(120);
+DECLARE_MSM_GPIO_PINS(121);
+DECLARE_MSM_GPIO_PINS(122);
+DECLARE_MSM_GPIO_PINS(123);
+DECLARE_MSM_GPIO_PINS(124);
+DECLARE_MSM_GPIO_PINS(125);
+DECLARE_MSM_GPIO_PINS(126);
+DECLARE_MSM_GPIO_PINS(127);
+DECLARE_MSM_GPIO_PINS(128);
+DECLARE_MSM_GPIO_PINS(129);
+DECLARE_MSM_GPIO_PINS(130);
+DECLARE_MSM_GPIO_PINS(131);
+DECLARE_MSM_GPIO_PINS(132);
+DECLARE_MSM_GPIO_PINS(133);
+DECLARE_MSM_GPIO_PINS(134);
+DECLARE_MSM_GPIO_PINS(135);
+DECLARE_MSM_GPIO_PINS(136);
+DECLARE_MSM_GPIO_PINS(137);
+DECLARE_MSM_GPIO_PINS(138);
+DECLARE_MSM_GPIO_PINS(139);
+DECLARE_MSM_GPIO_PINS(140);
+DECLARE_MSM_GPIO_PINS(141);
+
+static const unsigned int sdc1_clk_pins[] = { 142 };
+static const unsigned int sdc1_cmd_pins[] = { 143 };
+static const unsigned int sdc1_data_pins[] = { 144 };
+static const unsigned int sdc1_rclk_pins[] = { 145 };
+static const unsigned int sdc2_clk_pins[] = { 146 };
+static const unsigned int sdc2_cmd_pins[] = { 147 };
+static const unsigned int sdc2_data_pins[] = { 148 };
+static const unsigned int qdsd_clk_pins[] = { 149 };
+static const unsigned int qdsd_cmd_pins[] = { 150 };
+static const unsigned int qdsd_data0_pins[] = { 151 };
+static const unsigned int qdsd_data1_pins[] = { 152 };
+static const unsigned int qdsd_data2_pins[] = { 153 };
+static const unsigned int qdsd_data3_pins[] = { 154 };
+
+enum msm8953_functions {
+	msm_mux_gpio,
+	msm_mux_blsp_spi1,
+	msm_mux_smb_int,
+	msm_mux_adsp_ext,
+	msm_mux_prng_rosc,
+	msm_mux_blsp_i2c1,
+	msm_mux_qdss_cti_trig_out_b0,
+	msm_mux_qdss_cti_trig_out_a1,
+	msm_mux_blsp_spi2,
+	msm_mux_blsp_uart2,
+	msm_mux_ldo_update,
+	msm_mux_dac_calib0,
+	msm_mux_ldo_en,
+	msm_mux_blsp_i2c2,
+	msm_mux_gcc_gp1_clk_b,
+	msm_mux_atest_gpsadc_dtest0_native,
+	msm_mux_blsp_spi3,
+	msm_mux_qdss_tracedata_b,
+	msm_mux_pwr_modem_enabled_b,
+	msm_mux_blsp_i2c3,
+	msm_mux_gcc_gp2_clk_b,
+	msm_mux_gcc_gp3_clk_b,
+	msm_mux_hall_int,
+	msm_mux_blsp_spi4,
+	msm_mux_blsp_uart4,
+	msm_mux_pwr_nav_enabled_b,
+	msm_mux_dac_calib1,
+	msm_mux_cap_int,
+	msm_mux_pwr_crypto_enabled_b,
+	msm_mux_dac_calib2,
+	msm_mux_blsp_i2c4,
+	msm_mux_nfc_disable,
+	msm_mux_blsp_spi5,
+	msm_mux_blsp_uart5,
+	msm_mux_qdss_traceclk_a,
+	msm_mux_atest_bbrx1,
+	msm_mux_nfc_irq,
+	msm_mux_m_voc,
+	msm_mux_qdss_cti_trig_in_a0,
+	msm_mux_atest_bbrx0,
+	msm_mux_blsp_i2c5,
+	msm_mux_qdss_tracectl_a,
+	msm_mux_atest_gpsadc_dtest1_native,
+	msm_mux_qdss_tracedata_a,
+	msm_mux_blsp_spi6,
+	msm_mux_blsp_uart6,
+	msm_mux_qdss_tracectl_b,
+	msm_mux_dac_calib15,
+	msm_mux_qdss_cti_trig_in_b0,
+	msm_mux_dac_calib16,
+	msm_mux_blsp_i2c6,
+	msm_mux_qdss_traceclk_b,
+	msm_mux_atest_wlan0,
+	msm_mux_atest_wlan1,
+	msm_mux_mdp_vsync,
+	msm_mux_pri_mi2s_mclk_a,
+	msm_mux_sec_mi2s_mclk_a,
+	msm_mux_qdss_cti_trig_out_b1,
+	msm_mux_cam_mclk,
+	msm_mux_dac_calib3,
+	msm_mux_cci_i2c,
+	msm_mux_pwr_modem_enabled_a,
+	msm_mux_dac_calib4,
+	msm_mux_dac_calib19,
+	msm_mux_flash_strobe,
+	msm_mux_cci_timer0,
+	msm_mux_cci_timer1,
+	msm_mux_cam_irq,
+	msm_mux_cci_timer2,
+	msm_mux_blsp1_spi,
+	msm_mux_pwr_nav_enabled_a,
+	msm_mux_ois_sync,
+	msm_mux_cci_timer3,
+	msm_mux_cci_timer4,
+	msm_mux_blsp3_spi,
+	msm_mux_qdss_cti_trig_out_a0,
+	msm_mux_dac_calib7,
+	msm_mux_accel_int,
+	msm_mux_gcc_gp1_clk_a,
+	msm_mux_dac_calib8,
+	msm_mux_alsp_int,
+	msm_mux_gcc_gp2_clk_a,
+	msm_mux_dac_calib9,
+	msm_mux_mag_int,
+	msm_mux_gcc_gp3_clk_a,
+	msm_mux_pwr_crypto_enabled_a,
+	msm_mux_cci_async,
+	msm_mux_cam1_standby,
+	msm_mux_dac_calib5,
+	msm_mux_cam1_rst,
+	msm_mux_dac_calib6,
+	msm_mux_dac_calib10,
+	msm_mux_gyro_int,
+	msm_mux_dac_calib11,
+	msm_mux_pressure_int,
+	msm_mux_dac_calib12,
+	msm_mux_blsp6_spi,
+	msm_mux_dac_calib13,
+	msm_mux_fp_int,
+	msm_mux_qdss_cti_trig_in_b1,
+	msm_mux_dac_calib14,
+	msm_mux_uim_batt,
+	msm_mux_cam0_ldo,
+	msm_mux_sd_write,
+	msm_mux_uim1_data,
+	msm_mux_uim1_clk,
+	msm_mux_uim1_reset,
+	msm_mux_uim1_present,
+	msm_mux_uim2_data,
+	msm_mux_uim2_clk,
+	msm_mux_uim2_reset,
+	msm_mux_uim2_present,
+	msm_mux_ts_xvdd,
+	msm_mux_mipi_dsi0,
+	msm_mux_nfc_dwl,
+	msm_mux_us_euro,
+	msm_mux_atest_char3,
+	msm_mux_dbg_out,
+	msm_mux_bimc_dte0,
+	msm_mux_ts_resout,
+	msm_mux_ts_sample,
+	msm_mux_sec_mi2s_mclk_b,
+	msm_mux_pri_mi2s,
+	msm_mux_codec_reset,
+	msm_mux_cdc_pdm0,
+	msm_mux_atest_char1,
+	msm_mux_ebi_cdc,
+	msm_mux_dac_calib17,
+	msm_mux_us_emitter,
+	msm_mux_atest_char0,
+	msm_mux_pri_mi2s_mclk_b,
+	msm_mux_lpass_slimbus,
+	msm_mux_lpass_slimbus0,
+	msm_mux_lpass_slimbus1,
+	msm_mux_codec_int1,
+	msm_mux_codec_int2,
+	msm_mux_wcss_bt,
+	msm_mux_atest_char2,
+	msm_mux_ebi_ch0,
+	msm_mux_wcss_wlan2,
+	msm_mux_wcss_wlan1,
+	msm_mux_wcss_wlan0,
+	msm_mux_wcss_wlan,
+	msm_mux_wcss_fm,
+	msm_mux_ext_lpass,
+	msm_mux_mss_lte,
+	msm_mux_key_volp,
+	msm_mux_pbs0,
+	msm_mux_cri_trng0,
+	msm_mux_key_snapshot,
+	msm_mux_pbs1,
+	msm_mux_cri_trng1,
+	msm_mux_key_focus,
+	msm_mux_pbs2,
+	msm_mux_cri_trng,
+	msm_mux_gcc_tlmm,
+	msm_mux_key_home,
+	msm_mux_pwr_down,
+	msm_mux_dmic0_clk,
+	msm_mux_blsp7_spi,
+	msm_mux_hdmi_int,
+	msm_mux_dmic0_data,
+	msm_mux_qdss_cti_trig_in_a1,
+	msm_mux_pri_mi2s_ws,
+	msm_mux_wsa_io,
+	msm_mux_wsa_en,
+	msm_mux_blsp_spi8,
+	msm_mux_wsa_irq,
+	msm_mux_blsp_i2c8,
+	msm_mux_gcc_plltest,
+	msm_mux_nav_pps_in_a,
+	msm_mux_pa_indicator,
+	msm_mux_nav_pps_in_b,
+	msm_mux_nav_pps,
+	msm_mux_modem_tsync,
+	msm_mux_nav_tsync,
+	msm_mux_ssbi_wtr1,
+	msm_mux_gsm1_tx,
+	msm_mux_dac_calib18,
+	msm_mux_gsm0_tx,
+	msm_mux_atest_char,
+	msm_mux_atest_tsens,
+	msm_mux_bimc_dte1,
+	msm_mux_dac_calib20,
+	msm_mux_cam2_rst,
+	msm_mux_ddr_bist,
+	msm_mux_dac_calib21,
+	msm_mux_cam2_standby,
+	msm_mux_dac_calib22,
+	msm_mux_cam3_rst,
+	msm_mux_dac_calib23,
+	msm_mux_cam3_standby,
+	msm_mux_dac_calib24,
+	msm_mux_sdcard_det,
+	msm_mux_dac_calib25,
+	msm_mux_cam1_ldo,
+	msm_mux_sec_mi2s,
+	msm_mux_blsp_spi7,
+	msm_mux_blsp_i2c7,
+	msm_mux_ss_switch,
+	msm_mux_tsens_max,
+	msm_mux_NA,
+};
+
+static const char * const gpio_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
+	"gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
+	"gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
+	"gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
+	"gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35",
+	"gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42",
+	"gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49",
+	"gpio50", "gpio51", "gpio52", "gpio53", "gpio54", "gpio55", "gpio56",
+	"gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
+	"gpio64", "gpio65", "gpio66", "gpio67", "gpio68", "gpio69", "gpio70",
+	"gpio71", "gpio72", "gpio73", "gpio74", "gpio75", "gpio76", "gpio77",
+	"gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
+	"gpio85", "gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91",
+	"gpio92", "gpio93", "gpio94", "gpio95", "gpio96", "gpio97", "gpio98",
+	"gpio99", "gpio100", "gpio101", "gpio102", "gpio103", "gpio104",
+	"gpio105", "gpio106", "gpio107", "gpio108", "gpio109", "gpio110",
+	"gpio111", "gpio112", "gpio113", "gpio114", "gpio115", "gpio116",
+	"gpio117", "gpio118", "gpio119", "gpio120", "gpio121", "gpio122",
+	"gpio123", "gpio124", "gpio125", "gpio126", "gpio127", "gpio128",
+	"gpio129", "gpio130", "gpio131", "gpio132", "gpio133", "gpio134",
+	"gpio135", "gpio136", "gpio137", "gpio138", "gpio139", "gpio140",
+	"gpio141",
+};
+static const char * const blsp_spi1_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3",
+};
+static const char * const smb_int_groups[] = {
+	"gpio1",
+};
+static const char * const adsp_ext_groups[] = {
+	"gpio1",
+};
+static const char * const prng_rosc_groups[] = {
+	"gpio2",
+};
+static const char * const blsp_i2c1_groups[] = {
+	"gpio2", "gpio3",
+};
+static const char * const qdss_cti_trig_out_b0_groups[] = {
+	"gpio2",
+};
+static const char * const qdss_cti_trig_out_a1_groups[] = {
+	"gpio3",
+};
+static const char * const blsp_spi2_groups[] = {
+	"gpio4", "gpio5", "gpio6", "gpio7",
+};
+static const char * const blsp_uart2_groups[] = {
+	"gpio4", "gpio5", "gpio6", "gpio7",
+};
+static const char * const ldo_update_groups[] = {
+	"gpio4",
+};
+static const char * const dac_calib0_groups[] = {
+	"gpio4",
+};
+static const char * const ldo_en_groups[] = {
+	"gpio5",
+};
+static const char * const blsp_i2c2_groups[] = {
+	"gpio6", "gpio7",
+};
+static const char * const gcc_gp1_clk_b_groups[] = {
+	"gpio6", "gpio41",
+};
+static const char * const atest_gpsadc_dtest0_native_groups[] = {
+	"gpio7",
+};
+static const char * const blsp_spi3_groups[] = {
+	"gpio8", "gpio9", "gpio10", "gpio11",
+};
+static const char * const qdss_tracedata_b_groups[] = {
+	"gpio8", "gpio9", "gpio12", "gpio13", "gpio23", "gpio42", "gpio43",
+	"gpio44", "gpio45", "gpio46", "gpio47", "gpio66", "gpio86", "gpio87",
+	"gpio88", "gpio92",
+};
+static const char * const pwr_modem_enabled_b_groups[] = {
+	"gpio9",
+};
+static const char * const blsp_i2c3_groups[] = {
+	"gpio10", "gpio11",
+};
+static const char * const gcc_gp2_clk_b_groups[] = {
+	"gpio10",
+};
+static const char * const gcc_gp3_clk_b_groups[] = {
+	"gpio11",
+};
+static const char * const hall_int_groups[] = {
+	"gpio12",
+};
+static const char * const blsp_spi4_groups[] = {
+	"gpio12", "gpio13", "gpio14", "gpio15",
+};
+static const char * const blsp_uart4_groups[] = {
+	"gpio12", "gpio13", "gpio14", "gpio15",
+};
+static const char * const pwr_nav_enabled_b_groups[] = {
+	"gpio12",
+};
+static const char * const dac_calib1_groups[] = {
+	"gpio12",
+};
+static const char * const cap_int_groups[] = {
+	"gpio13",
+};
+static const char * const pwr_crypto_enabled_b_groups[] = {
+	"gpio13",
+};
+static const char * const dac_calib2_groups[] = {
+	"gpio13",
+};
+static const char * const blsp_i2c4_groups[] = {
+	"gpio14", "gpio15",
+};
+static const char * const nfc_disable_groups[] = {
+	"gpio16",
+};
+static const char * const blsp_spi5_groups[] = {
+	"gpio16", "gpio17", "gpio18", "gpio19",
+};
+static const char * const blsp_uart5_groups[] = {
+	"gpio16", "gpio17", "gpio18", "gpio19",
+};
+static const char * const qdss_traceclk_a_groups[] = {
+	"gpio16",
+};
+static const char * const atest_bbrx1_groups[] = {
+	"gpio16",
+};
+static const char * const nfc_irq_groups[] = {
+	"gpio17",
+};
+static const char * const m_voc_groups[] = {
+	"gpio17", "gpio21",
+};
+static const char * const qdss_cti_trig_in_a0_groups[] = {
+	"gpio17",
+};
+static const char * const atest_bbrx0_groups[] = {
+	"gpio17",
+};
+static const char * const blsp_i2c5_groups[] = {
+	"gpio18", "gpio19",
+};
+static const char * const qdss_tracectl_a_groups[] = {
+	"gpio18",
+};
+static const char * const atest_gpsadc_dtest1_native_groups[] = {
+	"gpio18",
+};
+static const char * const qdss_tracedata_a_groups[] = {
+	"gpio19", "gpio26", "gpio27", "gpio28", "gpio29", "gpio30", "gpio31",
+	"gpio32", "gpio33", "gpio34", "gpio35", "gpio36", "gpio38", "gpio39",
+	"gpio40", "gpio50",
+};
+static const char * const blsp_spi6_groups[] = {
+	"gpio20", "gpio21", "gpio22", "gpio23",
+};
+static const char * const blsp_uart6_groups[] = {
+	"gpio20", "gpio21", "gpio22", "gpio23",
+};
+static const char * const qdss_tracectl_b_groups[] = {
+	"gpio20",
+};
+static const char * const dac_calib15_groups[] = {
+	"gpio20",
+};
+static const char * const qdss_cti_trig_in_b0_groups[] = {
+	"gpio21",
+};
+static const char * const dac_calib16_groups[] = {
+	"gpio21",
+};
+static const char * const blsp_i2c6_groups[] = {
+	"gpio22", "gpio23",
+};
+static const char * const qdss_traceclk_b_groups[] = {
+	"gpio22",
+};
+static const char * const atest_wlan0_groups[] = {
+	"gpio22",
+};
+static const char * const atest_wlan1_groups[] = {
+	"gpio23",
+};
+static const char * const mdp_vsync_groups[] = {
+	"gpio24", "gpio25",
+};
+static const char * const pri_mi2s_mclk_a_groups[] = {
+	"gpio25",
+};
+static const char * const sec_mi2s_mclk_a_groups[] = {
+	"gpio25",
+};
+static const char * const qdss_cti_trig_out_b1_groups[] = {
+	"gpio25",
+};
+static const char * const cam_mclk_groups[] = {
+	"gpio26", "gpio27", "gpio28", "gpio128",
+};
+static const char * const dac_calib3_groups[] = {
+	"gpio28",
+};
+static const char * const cci_i2c_groups[] = {
+	"gpio29", "gpio30", "gpio31", "gpio32",
+};
+static const char * const pwr_modem_enabled_a_groups[] = {
+	"gpio29",
+};
+static const char * const dac_calib4_groups[] = {
+	"gpio29",
+};
+static const char * const dac_calib19_groups[] = {
+	"gpio30",
+};
+static const char * const flash_strobe_groups[] = {
+	"gpio33", "gpio34",
+};
+static const char * const cci_timer0_groups[] = {
+	"gpio33",
+};
+static const char * const cci_timer1_groups[] = {
+	"gpio34",
+};
+static const char * const cam_irq_groups[] = {
+	"gpio35",
+};
+static const char * const cci_timer2_groups[] = {
+	"gpio35",
+};
+static const char * const blsp1_spi_groups[] = {
+	"gpio35", "gpio36",
+};
+static const char * const pwr_nav_enabled_a_groups[] = {
+	"gpio35",
+};
+static const char * const ois_sync_groups[] = {
+	"gpio36",
+};
+static const char * const cci_timer3_groups[] = {
+	"gpio36",
+};
+static const char * const cci_timer4_groups[] = {
+	"gpio41",
+};
+static const char * const blsp3_spi_groups[] = {
+	"gpio41", "gpio50",
+};
+static const char * const qdss_cti_trig_out_a0_groups[] = {
+	"gpio41",
+};
+static const char * const dac_calib7_groups[] = {
+	"gpio41",
+};
+static const char * const accel_int_groups[] = {
+	"gpio42",
+};
+static const char * const gcc_gp1_clk_a_groups[] = {
+	"gpio42",
+};
+static const char * const dac_calib8_groups[] = {
+	"gpio42",
+};
+static const char * const alsp_int_groups[] = {
+	"gpio43",
+};
+static const char * const gcc_gp2_clk_a_groups[] = {
+	"gpio43",
+};
+static const char * const dac_calib9_groups[] = {
+	"gpio43",
+};
+static const char * const mag_int_groups[] = {
+	"gpio44",
+};
+static const char * const gcc_gp3_clk_a_groups[] = {
+	"gpio44",
+};
+static const char * const pwr_crypto_enabled_a_groups[] = {
+	"gpio36",
+};
+static const char * const cci_async_groups[] = {
+	"gpio38",
+};
+static const char * const cam1_standby_groups[] = {
+	"gpio39",
+};
+static const char * const dac_calib5_groups[] = {
+	"gpio39",
+};
+static const char * const cam1_rst_groups[] = {
+	"gpio40",
+};
+static const char * const dac_calib6_groups[] = {
+	"gpio40",
+};
+static const char * const dac_calib10_groups[] = {
+	"gpio44",
+};
+static const char * const gyro_int_groups[] = {
+	"gpio45",
+};
+static const char * const dac_calib11_groups[] = {
+	"gpio45",
+};
+static const char * const pressure_int_groups[] = {
+	"gpio46",
+};
+static const char * const dac_calib12_groups[] = {
+	"gpio46",
+};
+static const char * const blsp6_spi_groups[] = {
+	"gpio47", "gpio48",
+};
+static const char * const dac_calib13_groups[] = {
+	"gpio47",
+};
+static const char * const fp_int_groups[] = {
+	"gpio48",
+};
+static const char * const qdss_cti_trig_in_b1_groups[] = {
+	"gpio48",
+};
+static const char * const dac_calib14_groups[] = {
+	"gpio48",
+};
+static const char * const uim_batt_groups[] = {
+	"gpio49",
+};
+static const char * const cam0_ldo_groups[] = {
+	"gpio50",
+};
+static const char * const sd_write_groups[] = {
+	"gpio50",
+};
+static const char * const uim1_data_groups[] = {
+	"gpio51",
+};
+static const char * const uim1_clk_groups[] = {
+	"gpio52",
+};
+static const char * const uim1_reset_groups[] = {
+	"gpio53",
+};
+static const char * const uim1_present_groups[] = {
+	"gpio54",
+};
+static const char * const uim2_data_groups[] = {
+	"gpio55",
+};
+static const char * const uim2_clk_groups[] = {
+	"gpio56",
+};
+static const char * const uim2_reset_groups[] = {
+	"gpio57",
+};
+static const char * const uim2_present_groups[] = {
+	"gpio58",
+};
+static const char * const ts_xvdd_groups[] = {
+	"gpio60",
+};
+static const char * const mipi_dsi0_groups[] = {
+	"gpio61",
+};
+static const char * const nfc_dwl_groups[] = {
+	"gpio62",
+};
+static const char * const us_euro_groups[] = {
+	"gpio63",
+};
+static const char * const atest_char3_groups[] = {
+	"gpio63",
+};
+static const char * const dbg_out_groups[] = {
+	"gpio63",
+};
+static const char * const bimc_dte0_groups[] = {
+	"gpio63", "gpio65",
+};
+static const char * const ts_resout_groups[] = {
+	"gpio64",
+};
+static const char * const ts_sample_groups[] = {
+	"gpio65",
+};
+static const char * const sec_mi2s_mclk_b_groups[] = {
+	"gpio66",
+};
+static const char * const pri_mi2s_groups[] = {
+	"gpio66", "gpio88", "gpio91", "gpio93", "gpio94", "gpio95",
+};
+static const char * const codec_reset_groups[] = {
+	"gpio67",
+};
+static const char * const cdc_pdm0_groups[] = {
+	"gpio67", "gpio68", "gpio69", "gpio70", "gpio71", "gpio72", "gpio73",
+	"gpio74",
+};
+static const char * const atest_char1_groups[] = {
+	"gpio67",
+};
+static const char * const ebi_cdc_groups[] = {
+	"gpio67", "gpio69", "gpio118", "gpio119", "gpio120", "gpio123",
+};
+static const char * const dac_calib17_groups[] = {
+	"gpio67",
+};
+static const char * const us_emitter_groups[] = {
+	"gpio68",
+};
+static const char * const atest_char0_groups[] = {
+	"gpio68",
+};
+static const char * const pri_mi2s_mclk_b_groups[] = {
+	"gpio69",
+};
+static const char * const lpass_slimbus_groups[] = {
+	"gpio70",
+};
+static const char * const lpass_slimbus0_groups[] = {
+	"gpio71",
+};
+static const char * const lpass_slimbus1_groups[] = {
+	"gpio72",
+};
+static const char * const codec_int1_groups[] = {
+	"gpio73",
+};
+static const char * const codec_int2_groups[] = {
+	"gpio74",
+};
+static const char * const wcss_bt_groups[] = {
+	"gpio75", "gpio83", "gpio84",
+};
+static const char * const atest_char2_groups[] = {
+	"gpio75",
+};
+static const char * const ebi_ch0_groups[] = {
+	"gpio75",
+};
+static const char * const wcss_wlan2_groups[] = {
+	"gpio76",
+};
+static const char * const wcss_wlan1_groups[] = {
+	"gpio77",
+};
+static const char * const wcss_wlan0_groups[] = {
+	"gpio78",
+};
+static const char * const wcss_wlan_groups[] = {
+	"gpio79", "gpio80",
+};
+static const char * const wcss_fm_groups[] = {
+	"gpio81", "gpio82",
+};
+static const char * const ext_lpass_groups[] = {
+	"gpio81",
+};
+static const char * const mss_lte_groups[] = {
+	"gpio82", "gpio83",
+};
+static const char * const key_volp_groups[] = {
+	"gpio85",
+};
+static const char * const pbs0_groups[] = {
+	"gpio85",
+};
+static const char * const cri_trng0_groups[] = {
+	"gpio85",
+};
+static const char * const key_snapshot_groups[] = {
+	"gpio86",
+};
+static const char * const pbs1_groups[] = {
+	"gpio86",
+};
+static const char * const cri_trng1_groups[] = {
+	"gpio86",
+};
+static const char * const key_focus_groups[] = {
+	"gpio87",
+};
+static const char * const pbs2_groups[] = {
+	"gpio87",
+};
+static const char * const cri_trng_groups[] = {
+	"gpio87",
+};
+static const char * const gcc_tlmm_groups[] = {
+	"gpio87",
+};
+static const char * const key_home_groups[] = {
+	"gpio88",
+};
+static const char * const pwr_down_groups[] = {
+	"gpio89",
+};
+static const char * const dmic0_clk_groups[] = {
+	"gpio89",
+};
+static const char * const blsp7_spi_groups[] = {
+	"gpio89", "gpio90",
+};
+static const char * const hdmi_int_groups[] = {
+	"gpio90",
+};
+static const char * const dmic0_data_groups[] = {
+	"gpio90",
+};
+static const char * const qdss_cti_trig_in_a1_groups[] = {
+	"gpio91",
+};
+static const char * const pri_mi2s_ws_groups[] = {
+	"gpio92",
+};
+static const char * const wsa_io_groups[] = {
+	"gpio94", "gpio95",
+};
+static const char * const wsa_en_groups[] = {
+	"gpio96",
+};
+static const char * const blsp_spi8_groups[] = {
+	"gpio96", "gpio97", "gpio98", "gpio99",
+};
+static const char * const wsa_irq_groups[] = {
+	"gpio97",
+};
+static const char * const blsp_i2c8_groups[] = {
+	"gpio98", "gpio99",
+};
+static const char * const gcc_plltest_groups[] = {
+	"gpio98", "gpio99",
+};
+static const char * const nav_pps_in_a_groups[] = {
+	"gpio111",
+};
+static const char * const pa_indicator_groups[] = {
+	"gpio112",
+};
+static const char * const nav_pps_in_b_groups[] = {
+	"gpio113",
+};
+static const char * const nav_pps_groups[] = {
+	"gpio113",
+};
+static const char * const modem_tsync_groups[] = {
+	"gpio113",
+};
+static const char * const nav_tsync_groups[] = {
+	"gpio113",
+};
+static const char * const ssbi_wtr1_groups[] = {
+	"gpio114", "gpio123",
+};
+static const char * const gsm1_tx_groups[] = {
+	"gpio115",
+};
+static const char * const dac_calib18_groups[] = {
+	"gpio115",
+};
+static const char * const gsm0_tx_groups[] = {
+	"gpio117",
+};
+static const char * const atest_char_groups[] = {
+	"gpio120",
+};
+static const char * const atest_tsens_groups[] = {
+	"gpio120",
+};
+static const char * const bimc_dte1_groups[] = {
+	"gpio121", "gpio122",
+};
+static const char * const dac_calib20_groups[] = {
+	"gpio128",
+};
+static const char * const cam2_rst_groups[] = {
+	"gpio129",
+};
+static const char * const ddr_bist_groups[] = {
+	"gpio129", "gpio130", "gpio131", "gpio132",
+};
+static const char * const dac_calib21_groups[] = {
+	"gpio129",
+};
+static const char * const cam2_standby_groups[] = {
+	"gpio130",
+};
+static const char * const dac_calib22_groups[] = {
+	"gpio130",
+};
+static const char * const cam3_rst_groups[] = {
+	"gpio131",
+};
+static const char * const dac_calib23_groups[] = {
+	"gpio131",
+};
+static const char * const cam3_standby_groups[] = {
+	"gpio132",
+};
+static const char * const dac_calib24_groups[] = {
+	"gpio132",
+};
+static const char * const sdcard_det_groups[] = {
+	"gpio133",
+};
+static const char * const dac_calib25_groups[] = {
+	"gpio133",
+};
+static const char * const cam1_ldo_groups[] = {
+	"gpio134",
+};
+static const char * const sec_mi2s_groups[] = {
+	"gpio135", "gpio136", "gpio137", "gpio138",
+};
+static const char * const blsp_spi7_groups[] = {
+	"gpio135", "gpio136", "gpio137", "gpio138",
+};
+static const char * const blsp_i2c7_groups[] = {
+	"gpio135", "gpio136",
+};
+static const char * const ss_switch_groups[] = {
+	"gpio139",
+};
+static const char * const tsens_max_groups[] = {
+	"gpio139",
+};
+
+static const struct msm_function msm8953_functions[] = {
+	FUNCTION(gpio),
+	FUNCTION(blsp_spi1),
+	FUNCTION(smb_int),
+	FUNCTION(adsp_ext),
+	FUNCTION(prng_rosc),
+	FUNCTION(blsp_i2c1),
+	FUNCTION(qdss_cti_trig_out_b0),
+	FUNCTION(qdss_cti_trig_out_a1),
+	FUNCTION(blsp_spi2),
+	FUNCTION(blsp_uart2),
+	FUNCTION(ldo_update),
+	FUNCTION(dac_calib0),
+	FUNCTION(ldo_en),
+	FUNCTION(blsp_i2c2),
+	FUNCTION(gcc_gp1_clk_b),
+	FUNCTION(atest_gpsadc_dtest0_native),
+	FUNCTION(blsp_spi3),
+	FUNCTION(qdss_tracedata_b),
+	FUNCTION(pwr_modem_enabled_b),
+	FUNCTION(blsp_i2c3),
+	FUNCTION(gcc_gp2_clk_b),
+	FUNCTION(gcc_gp3_clk_b),
+	FUNCTION(hall_int),
+	FUNCTION(blsp_spi4),
+	FUNCTION(blsp_uart4),
+	FUNCTION(pwr_nav_enabled_b),
+	FUNCTION(dac_calib1),
+	FUNCTION(cap_int),
+	FUNCTION(pwr_crypto_enabled_b),
+	FUNCTION(dac_calib2),
+	FUNCTION(blsp_i2c4),
+	FUNCTION(nfc_disable),
+	FUNCTION(blsp_spi5),
+	FUNCTION(blsp_uart5),
+	FUNCTION(qdss_traceclk_a),
+	FUNCTION(atest_bbrx1),
+	FUNCTION(nfc_irq),
+	FUNCTION(m_voc),
+	FUNCTION(qdss_cti_trig_in_a0),
+	FUNCTION(atest_bbrx0),
+	FUNCTION(blsp_i2c5),
+	FUNCTION(qdss_tracectl_a),
+	FUNCTION(atest_gpsadc_dtest1_native),
+	FUNCTION(qdss_tracedata_a),
+	FUNCTION(blsp_spi6),
+	FUNCTION(blsp_uart6),
+	FUNCTION(qdss_tracectl_b),
+	FUNCTION(dac_calib15),
+	FUNCTION(qdss_cti_trig_in_b0),
+	FUNCTION(dac_calib16),
+	FUNCTION(blsp_i2c6),
+	FUNCTION(qdss_traceclk_b),
+	FUNCTION(atest_wlan0),
+	FUNCTION(atest_wlan1),
+	FUNCTION(mdp_vsync),
+	FUNCTION(pri_mi2s_mclk_a),
+	FUNCTION(sec_mi2s_mclk_a),
+	FUNCTION(qdss_cti_trig_out_b1),
+	FUNCTION(cam_mclk),
+	FUNCTION(dac_calib3),
+	FUNCTION(cci_i2c),
+	FUNCTION(pwr_modem_enabled_a),
+	FUNCTION(dac_calib4),
+	FUNCTION(dac_calib19),
+	FUNCTION(flash_strobe),
+	FUNCTION(cci_timer0),
+	FUNCTION(cci_timer1),
+	FUNCTION(cam_irq),
+	FUNCTION(cci_timer2),
+	FUNCTION(blsp1_spi),
+	FUNCTION(pwr_nav_enabled_a),
+	FUNCTION(ois_sync),
+	FUNCTION(cci_timer3),
+	FUNCTION(cci_timer4),
+	FUNCTION(blsp3_spi),
+	FUNCTION(qdss_cti_trig_out_a0),
+	FUNCTION(dac_calib7),
+	FUNCTION(accel_int),
+	FUNCTION(gcc_gp1_clk_a),
+	FUNCTION(dac_calib8),
+	FUNCTION(alsp_int),
+	FUNCTION(gcc_gp2_clk_a),
+	FUNCTION(dac_calib9),
+	FUNCTION(mag_int),
+	FUNCTION(gcc_gp3_clk_a),
+	FUNCTION(pwr_crypto_enabled_a),
+	FUNCTION(cci_async),
+	FUNCTION(cam1_standby),
+	FUNCTION(dac_calib5),
+	FUNCTION(cam1_rst),
+	FUNCTION(dac_calib6),
+	FUNCTION(dac_calib10),
+	FUNCTION(gyro_int),
+	FUNCTION(dac_calib11),
+	FUNCTION(pressure_int),
+	FUNCTION(dac_calib12),
+	FUNCTION(blsp6_spi),
+	FUNCTION(dac_calib13),
+	FUNCTION(fp_int),
+	FUNCTION(qdss_cti_trig_in_b1),
+	FUNCTION(dac_calib14),
+	FUNCTION(uim_batt),
+	FUNCTION(cam0_ldo),
+	FUNCTION(sd_write),
+	FUNCTION(uim1_data),
+	FUNCTION(uim1_clk),
+	FUNCTION(uim1_reset),
+	FUNCTION(uim1_present),
+	FUNCTION(uim2_data),
+	FUNCTION(uim2_clk),
+	FUNCTION(uim2_reset),
+	FUNCTION(uim2_present),
+	FUNCTION(ts_xvdd),
+	FUNCTION(mipi_dsi0),
+	FUNCTION(nfc_dwl),
+	FUNCTION(us_euro),
+	FUNCTION(atest_char3),
+	FUNCTION(dbg_out),
+	FUNCTION(bimc_dte0),
+	FUNCTION(ts_resout),
+	FUNCTION(ts_sample),
+	FUNCTION(sec_mi2s_mclk_b),
+	FUNCTION(pri_mi2s),
+	FUNCTION(codec_reset),
+	FUNCTION(cdc_pdm0),
+	FUNCTION(atest_char1),
+	FUNCTION(ebi_cdc),
+	FUNCTION(dac_calib17),
+	FUNCTION(us_emitter),
+	FUNCTION(atest_char0),
+	FUNCTION(pri_mi2s_mclk_b),
+	FUNCTION(lpass_slimbus),
+	FUNCTION(lpass_slimbus0),
+	FUNCTION(lpass_slimbus1),
+	FUNCTION(codec_int1),
+	FUNCTION(codec_int2),
+	FUNCTION(wcss_bt),
+	FUNCTION(atest_char2),
+	FUNCTION(ebi_ch0),
+	FUNCTION(wcss_wlan2),
+	FUNCTION(wcss_wlan1),
+	FUNCTION(wcss_wlan0),
+	FUNCTION(wcss_wlan),
+	FUNCTION(wcss_fm),
+	FUNCTION(ext_lpass),
+	FUNCTION(mss_lte),
+	FUNCTION(key_volp),
+	FUNCTION(pbs0),
+	FUNCTION(cri_trng0),
+	FUNCTION(key_snapshot),
+	FUNCTION(pbs1),
+	FUNCTION(cri_trng1),
+	FUNCTION(key_focus),
+	FUNCTION(pbs2),
+	FUNCTION(cri_trng),
+	FUNCTION(gcc_tlmm),
+	FUNCTION(key_home),
+	FUNCTION(pwr_down),
+	FUNCTION(dmic0_clk),
+	FUNCTION(blsp7_spi),
+	FUNCTION(hdmi_int),
+	FUNCTION(dmic0_data),
+	FUNCTION(qdss_cti_trig_in_a1),
+	FUNCTION(pri_mi2s_ws),
+	FUNCTION(wsa_io),
+	FUNCTION(wsa_en),
+	FUNCTION(blsp_spi8),
+	FUNCTION(wsa_irq),
+	FUNCTION(blsp_i2c8),
+	FUNCTION(gcc_plltest),
+	FUNCTION(nav_pps_in_a),
+	FUNCTION(pa_indicator),
+	FUNCTION(nav_pps_in_b),
+	FUNCTION(nav_pps),
+	FUNCTION(modem_tsync),
+	FUNCTION(nav_tsync),
+	FUNCTION(ssbi_wtr1),
+	FUNCTION(gsm1_tx),
+	FUNCTION(dac_calib18),
+	FUNCTION(gsm0_tx),
+	FUNCTION(atest_char),
+	FUNCTION(atest_tsens),
+	FUNCTION(bimc_dte1),
+	FUNCTION(dac_calib20),
+	FUNCTION(cam2_rst),
+	FUNCTION(ddr_bist),
+	FUNCTION(dac_calib21),
+	FUNCTION(cam2_standby),
+	FUNCTION(dac_calib22),
+	FUNCTION(cam3_rst),
+	FUNCTION(dac_calib23),
+	FUNCTION(cam3_standby),
+	FUNCTION(dac_calib24),
+	FUNCTION(sdcard_det),
+	FUNCTION(dac_calib25),
+	FUNCTION(cam1_ldo),
+	FUNCTION(sec_mi2s),
+	FUNCTION(blsp_spi7),
+	FUNCTION(blsp_i2c7),
+	FUNCTION(ss_switch),
+	FUNCTION(tsens_max),
+};
+
+static const struct msm_pingroup msm8953_groups[] = {
+	PINGROUP(0, blsp_spi1, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(1, blsp_spi1, adsp_ext, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(2, blsp_spi1, blsp_i2c1, prng_rosc, NA, NA, NA,
+		 qdss_cti_trig_out_b0, NA, NA),
+	PINGROUP(3, blsp_spi1, blsp_i2c1, NA, NA, NA, qdss_cti_trig_out_a1, NA,
+		 NA, NA),
+	PINGROUP(4, blsp_spi2, blsp_uart2, ldo_update, NA, dac_calib0, NA, NA,
+		 NA, NA),
+	PINGROUP(5, blsp_spi2, blsp_uart2, ldo_en, NA, NA, NA, NA, NA, NA),
+	PINGROUP(6, blsp_spi2, blsp_uart2, blsp_i2c2, gcc_gp1_clk_b, NA, NA,
+		 NA, NA, NA),
+	PINGROUP(7, blsp_spi2, blsp_uart2, blsp_i2c2, NA,
+		 atest_gpsadc_dtest0_native, NA, NA, NA, NA),
+	PINGROUP(8, blsp_spi3, NA, NA, qdss_tracedata_b, NA, NA, NA, NA, NA),
+	PINGROUP(9, blsp_spi3, pwr_modem_enabled_b, NA, NA, qdss_tracedata_b,
+		 NA, NA, NA, NA),
+	PINGROUP(10, blsp_spi3, blsp_i2c3, gcc_gp2_clk_b, NA, NA, NA, NA, NA,
+		 NA),
+	PINGROUP(11, blsp_spi3, blsp_i2c3, gcc_gp3_clk_b, NA, NA, NA, NA, NA,
+		 NA),
+	PINGROUP(12, blsp_spi4, blsp_uart4, pwr_nav_enabled_b, NA, NA,
+		 qdss_tracedata_b, NA, dac_calib1, NA),
+	PINGROUP(13, blsp_spi4, blsp_uart4, pwr_crypto_enabled_b, NA, NA, NA,
+		 qdss_tracedata_b, NA, dac_calib2),
+	PINGROUP(14, blsp_spi4, blsp_uart4, blsp_i2c4, NA, NA, NA, NA, NA, NA),
+	PINGROUP(15, blsp_spi4, blsp_uart4, blsp_i2c4, NA, NA, NA, NA, NA, NA),
+	PINGROUP(16, blsp_spi5, blsp_uart5, NA, NA, qdss_traceclk_a, NA,
+		 atest_bbrx1, NA, NA),
+	PINGROUP(17, blsp_spi5, blsp_uart5, m_voc, qdss_cti_trig_in_a0, NA,
+		 atest_bbrx0, NA, NA, NA),
+	PINGROUP(18, blsp_spi5, blsp_uart5, blsp_i2c5, qdss_tracectl_a, NA,
+		 atest_gpsadc_dtest1_native, NA, NA, NA),
+	PINGROUP(19, blsp_spi5, blsp_uart5, blsp_i2c5, qdss_tracedata_a, NA,
+		 NA, NA, NA, NA),
+	PINGROUP(20, blsp_spi6, blsp_uart6, NA, NA, NA, qdss_tracectl_b, NA,
+		 dac_calib15, NA),
+	PINGROUP(21, blsp_spi6, blsp_uart6, m_voc, NA, NA, NA,
+		 qdss_cti_trig_in_b0, NA, dac_calib16),
+	PINGROUP(22, blsp_spi6, blsp_uart6, blsp_i2c6, qdss_traceclk_b, NA,
+		 atest_wlan0, NA, NA, NA),
+	PINGROUP(23, blsp_spi6, blsp_uart6, blsp_i2c6, qdss_tracedata_b, NA,
+		 atest_wlan1, NA, NA, NA),
+	PINGROUP(24, mdp_vsync, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(25, mdp_vsync, pri_mi2s_mclk_a, sec_mi2s_mclk_a,
+		 qdss_cti_trig_out_b1, NA, NA, NA, NA, NA),
+	PINGROUP(26, cam_mclk, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA),
+	PINGROUP(27, cam_mclk, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA),
+	PINGROUP(28, cam_mclk, NA, NA, NA, qdss_tracedata_a, NA, dac_calib3,
+		 NA, NA),
+	PINGROUP(29, cci_i2c, pwr_modem_enabled_a, NA, NA, NA,
+		 qdss_tracedata_a, NA, dac_calib4, NA),
+	PINGROUP(30, cci_i2c, NA, NA, NA, qdss_tracedata_a, NA, dac_calib19,
+		 NA, NA),
+	PINGROUP(31, cci_i2c, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA),
+	PINGROUP(32, cci_i2c, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA),
+	PINGROUP(33, cci_timer0, NA, NA, NA, NA, qdss_tracedata_a, NA, NA, NA),
+	PINGROUP(34, cci_timer1, NA, NA, NA, NA, qdss_tracedata_a, NA, NA, NA),
+	PINGROUP(35, cci_timer2, blsp1_spi, pwr_nav_enabled_a, NA, NA, NA,
+		 qdss_tracedata_a, NA, NA),
+	PINGROUP(36, cci_timer3, blsp1_spi, NA, pwr_crypto_enabled_a, NA, NA,
+		 NA, qdss_tracedata_a, NA),
+	PINGROUP(37, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(38, cci_async, NA, qdss_tracedata_a, NA, NA, NA, NA, NA, NA),
+	PINGROUP(39, NA, NA, NA, qdss_tracedata_a, NA, dac_calib5, NA, NA, NA),
+	PINGROUP(40, NA, NA, qdss_tracedata_a, NA, dac_calib6, NA, NA, NA, NA),
+	PINGROUP(41, cci_timer4, blsp3_spi, gcc_gp1_clk_b, NA, NA,
+		 qdss_cti_trig_out_a0, NA, dac_calib7, NA),
+	PINGROUP(42, gcc_gp1_clk_a, qdss_tracedata_b, NA, dac_calib8, NA, NA,
+		 NA, NA, NA),
+	PINGROUP(43, gcc_gp2_clk_a, qdss_tracedata_b, NA, dac_calib9, NA, NA,
+		 NA, NA, NA),
+	PINGROUP(44, gcc_gp3_clk_a, qdss_tracedata_b, NA, dac_calib10, NA, NA,
+		 NA, NA, NA),
+	PINGROUP(45, NA, qdss_tracedata_b, NA, dac_calib11, NA, NA, NA, NA, NA),
+	PINGROUP(46, qdss_tracedata_b, NA, dac_calib12, NA, NA, NA, NA, NA, NA),
+	PINGROUP(47, blsp6_spi, qdss_tracedata_b, NA, dac_calib13, NA, NA, NA,
+		 NA, NA),
+	PINGROUP(48, blsp6_spi, NA, qdss_cti_trig_in_b1, NA, dac_calib14, NA,
+		 NA, NA, NA),
+	PINGROUP(49, uim_batt, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(50, blsp3_spi, sd_write, NA, NA, NA, qdss_tracedata_a, NA, NA,
+		 NA),
+	PINGROUP(51, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(52, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(53, uim1_reset, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(54, uim1_present, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(55, uim2_data, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(56, uim2_clk, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(57, uim2_reset, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(58, uim2_present, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(59, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(60, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(61, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(62, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(63, atest_char3, dbg_out, bimc_dte0, NA, NA, NA, NA, NA, NA),
+	PINGROUP(64, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(65, bimc_dte0, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(66, sec_mi2s_mclk_b, pri_mi2s, NA, qdss_tracedata_b, NA, NA,
+		 NA, NA, NA),
+	PINGROUP(67, cdc_pdm0, atest_char1, ebi_cdc, NA, dac_calib17, NA, NA,
+		 NA, NA),
+	PINGROUP(68, cdc_pdm0, atest_char0, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(69, cdc_pdm0, pri_mi2s_mclk_b, ebi_cdc, NA, NA, NA, NA, NA,
+		 NA),
+	PINGROUP(70, lpass_slimbus, cdc_pdm0, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(71, lpass_slimbus0, cdc_pdm0, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(72, lpass_slimbus1, cdc_pdm0, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(73, cdc_pdm0, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(74, cdc_pdm0, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(75, wcss_bt, atest_char2, NA, ebi_ch0, NA, NA, NA, NA, NA),
+	PINGROUP(76, wcss_wlan2, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(77, wcss_wlan1, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(78, wcss_wlan0, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(79, wcss_wlan, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(80, wcss_wlan, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(81, wcss_fm, ext_lpass, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(82, wcss_fm, mss_lte, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(83, wcss_bt, mss_lte, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(84, wcss_bt, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(85, pbs0, cri_trng0, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(86, pbs1, cri_trng1, qdss_tracedata_b, NA, NA, NA, NA, NA, NA),
+	PINGROUP(87, pbs2, cri_trng, qdss_tracedata_b, gcc_tlmm, NA, NA, NA,
+		 NA, NA),
+	PINGROUP(88, pri_mi2s, NA, NA, NA, qdss_tracedata_b, NA, NA, NA, NA),
+	PINGROUP(89, dmic0_clk, blsp7_spi, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(90, dmic0_data, blsp7_spi, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(91, pri_mi2s, NA, NA, NA, qdss_cti_trig_in_a1, NA, NA, NA, NA),
+	PINGROUP(92, pri_mi2s_ws, NA, NA, NA, qdss_tracedata_b, NA, NA, NA, NA),
+	PINGROUP(93, pri_mi2s, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(94, wsa_io, pri_mi2s, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(95, wsa_io, pri_mi2s, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(96, blsp_spi8, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(97, blsp_spi8, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(98, blsp_i2c8, blsp_spi8, gcc_plltest, NA, NA, NA, NA, NA, NA),
+	PINGROUP(99, blsp_i2c8, blsp_spi8, gcc_plltest, NA, NA, NA, NA, NA, NA),
+	PINGROUP(100, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(101, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(102, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(103, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(104, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(105, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(106, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(107, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(108, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(109, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(110, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(111, NA, NA, nav_pps_in_a, NA, NA, NA, NA, NA, NA),
+	PINGROUP(112, NA, pa_indicator, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(113, NA, nav_pps_in_b, nav_pps, modem_tsync, nav_tsync, NA,
+		 NA, NA, NA),
+	PINGROUP(114, NA, ssbi_wtr1, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(115, NA, gsm1_tx, NA, dac_calib18, NA, NA, NA, NA, NA),
+	PINGROUP(116, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(117, gsm0_tx, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(118, NA, ebi_cdc, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(119, NA, ebi_cdc, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(120, NA, atest_char, ebi_cdc, NA, atest_tsens, NA, NA, NA, NA),
+	PINGROUP(121, NA, NA, NA, bimc_dte1, NA, NA, NA, NA, NA),
+	PINGROUP(122, NA, NA, NA, bimc_dte1, NA, NA, NA, NA, NA),
+	PINGROUP(123, NA, ssbi_wtr1, ebi_cdc, NA, NA, NA, NA, NA, NA),
+	PINGROUP(124, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(125, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(126, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(127, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(128, cam_mclk, NA, dac_calib20, NA, NA, NA, NA, NA, NA),
+	PINGROUP(129, ddr_bist, NA, dac_calib21, NA, NA, NA, NA, NA, NA),
+	PINGROUP(130, ddr_bist, NA, dac_calib22, NA, NA, NA, NA, NA, NA),
+	PINGROUP(131, ddr_bist, NA, dac_calib23, NA, NA, NA, NA, NA, NA),
+	PINGROUP(132, ddr_bist, NA, dac_calib24, NA, NA, NA, NA, NA, NA),
+	PINGROUP(133, NA, dac_calib25, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(134, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(135, sec_mi2s, blsp_spi7, blsp_i2c7, NA, NA, NA, NA, NA, NA),
+	PINGROUP(136, sec_mi2s, blsp_spi7, blsp_i2c7, NA, NA, NA, NA, NA, NA),
+	PINGROUP(137, sec_mi2s, blsp_spi7, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(138, sec_mi2s, blsp_spi7, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(139, tsens_max, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(140, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(141, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	SDC_QDSD_PINGROUP(sdc1_clk, 0x10a000, 13, 6),
+	SDC_QDSD_PINGROUP(sdc1_cmd, 0x10a000, 11, 3),
+	SDC_QDSD_PINGROUP(sdc1_data, 0x10a000, 9, 0),
+	SDC_QDSD_PINGROUP(sdc1_rclk, 0x10a000, 15, 0),
+	SDC_QDSD_PINGROUP(sdc2_clk, 0x109000, 14, 6),
+	SDC_QDSD_PINGROUP(sdc2_cmd, 0x109000, 11, 3),
+	SDC_QDSD_PINGROUP(sdc2_data, 0x109000, 9, 0),
+	SDC_QDSD_PINGROUP(qdsd_clk, 0x19c000, 3, 0),
+	SDC_QDSD_PINGROUP(qdsd_cmd, 0x19c000, 8, 5),
+	SDC_QDSD_PINGROUP(qdsd_data0, 0x19c000, 13, 10),
+	SDC_QDSD_PINGROUP(qdsd_data1, 0x19c000, 18, 15),
+	SDC_QDSD_PINGROUP(qdsd_data2, 0x19c000, 23, 20),
+	SDC_QDSD_PINGROUP(qdsd_data3, 0x19c000, 28, 25),
+};
+
+static const struct msm_pinctrl_soc_data msm8953_pinctrl = {
+	.pins = msm8953_pins,
+	.npins = ARRAY_SIZE(msm8953_pins),
+	.functions = msm8953_functions,
+	.nfunctions = ARRAY_SIZE(msm8953_functions),
+	.groups = msm8953_groups,
+	.ngroups = ARRAY_SIZE(msm8953_groups),
+	.ngpios = 142,
+};
+
+static int msm8953_pinctrl_probe(struct platform_device *pdev)
+{
+	return msm_pinctrl_probe(pdev, &msm8953_pinctrl);
+}
+
+static const struct of_device_id msm8953_pinctrl_of_match[] = {
+	{ .compatible = "qcom,msm8953-pinctrl", },
+	{ },
+};
+
+static struct platform_driver msm8953_pinctrl_driver = {
+	.driver = {
+		.name = "msm8953-pinctrl",
+		.owner = THIS_MODULE,
+		.of_match_table = msm8953_pinctrl_of_match,
+	},
+	.probe = msm8953_pinctrl_probe,
+	.remove = msm_pinctrl_remove,
+};
+
+static int __init msm8953_pinctrl_init(void)
+{
+	return platform_driver_register(&msm8953_pinctrl_driver);
+}
+arch_initcall(msm8953_pinctrl_init);
+
+static void __exit msm8953_pinctrl_exit(void)
+{
+	platform_driver_unregister(&msm8953_pinctrl_driver);
+}
+module_exit(msm8953_pinctrl_exit);
+
+MODULE_DESCRIPTION("QTI msm8953 pinctrl driver");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(of, msm8953_pinctrl_of_match);
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm670.c b/drivers/pinctrl/qcom/pinctrl-sdm670.c
index b454cc442..8749653 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm670.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm670.c
@@ -25,8 +25,13 @@
 		.ngroups = ARRAY_SIZE(fname##_groups),	\
 	}
 
+#define NORTH	0x00500000
+#define SOUTH	0x00900000
+#define WEST	0x00100000
+
+#define DUMMY	0x0
 #define REG_SIZE 0x1000
-#define PINGROUP(id, f1, f2, f3, f4, f5, f6, f7, f8, f9)	\
+#define PINGROUP(id, base, f1, f2, f3, f4, f5, f6, f7, f8, f9)	\
 	{						\
 		.name = "gpio" #id,			\
 		.pins = gpio##id##_pins,		\
@@ -44,11 +49,11 @@
 			msm_mux_##f9			\
 		},					\
 		.nfuncs = 10,				\
-		.ctl_reg = REG_SIZE * id,		\
-		.io_reg = 0x4 + REG_SIZE * id,		\
-		.intr_cfg_reg = 0x8 + REG_SIZE * id,	\
-		.intr_status_reg = 0xc + REG_SIZE * id,	\
-		.intr_target_reg = 0x8 + REG_SIZE * id,	\
+		.ctl_reg = base + REG_SIZE * id,		\
+		.io_reg = base + 0x4 + REG_SIZE * id,		\
+		.intr_cfg_reg = base + 0x8 + REG_SIZE * id,	\
+		.intr_status_reg = base + 0xc + REG_SIZE * id,	\
+		.intr_target_reg = base + 0x8 + REG_SIZE * id,	\
 		.mux_bit = 2,			\
 		.pull_bit = 0,			\
 		.drv_bit = 6,			\
@@ -114,10 +119,6 @@
 		.intr_detection_bit = -1,		\
 		.intr_detection_width = -1,		\
 	}
-
-static const u32 sdm670_tile_offsets[] = {0x100000, 0x500000, 0x900000};
-static u32 sdm670_pin_base[150];
-
 static const struct pinctrl_pin_desc sdm670_pins[] = {
 	PINCTRL_PIN(0, "GPIO_0"),
 	PINCTRL_PIN(1, "GPIO_1"),
@@ -1332,259 +1333,258 @@
  * Clients would not be able to request these dummy pin groups.
  */
 static const struct msm_pingroup sdm670_groups[] = {
-	[0] = PINGROUP(0, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[1] = PINGROUP(1, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[2] = PINGROUP(2, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[3] = PINGROUP(3, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[4] = PINGROUP(4, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[5] = PINGROUP(5, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[6] = PINGROUP(6, qup9, NA, ddr_pxi0, NA, NA, NA, NA, NA, NA),
-	[7] = PINGROUP(7, qup9, ddr_bist, NA, atest_tsens2,
+	[0] = PINGROUP(0, SOUTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
+	[1] = PINGROUP(1, SOUTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
+	[2] = PINGROUP(2, SOUTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
+	[3] = PINGROUP(3, SOUTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
+	[4] = PINGROUP(4, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[5] = PINGROUP(5, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[6] = PINGROUP(6, NORTH, qup9, NA, ddr_pxi0, NA, NA, NA, NA, NA, NA),
+	[7] = PINGROUP(7, NORTH, qup9, ddr_bist, NA, atest_tsens2,
 		       vsense_trigger, atest_usb1, ddr_pxi0, NA, NA),
-	[8] = PINGROUP(8, qup_l4, GP_PDM1, ddr_bist, NA, NA, NA, NA, NA,
+	[8] = PINGROUP(8, WEST, qup_l4, GP_PDM1, ddr_bist, NA, NA, NA, NA, NA,
 		       NA),
-	[9] = PINGROUP(9, qup_l5, ddr_bist, NA, NA, NA, NA, NA, NA, NA),
-	[10] = PINGROUP(10, mdp_vsync, qup_l6, ddr_bist, wlan2_adc1,
+	[9] = PINGROUP(9, WEST, qup_l5, ddr_bist, NA, NA, NA, NA, NA, NA, NA),
+	[10] = PINGROUP(10, NORTH, mdp_vsync, qup_l6, ddr_bist, wlan2_adc1,
 			atest_usb11, ddr_pxi2, NA, NA, NA),
-	[11] = PINGROUP(11, mdp_vsync, edp_lcd, dbg_out, wlan2_adc0,
+	[11] = PINGROUP(11, NORTH, mdp_vsync, edp_lcd, dbg_out, wlan2_adc0,
 			atest_usb10, ddr_pxi2, NA, NA, NA),
-	[12] = PINGROUP(12, mdp_vsync, m_voc, tsif1_sync, ddr_pxi3, NA,
+	[12] = PINGROUP(12, SOUTH, mdp_vsync, m_voc, tsif1_sync, ddr_pxi3, NA,
 			NA, NA, NA, NA),
-	[13] = PINGROUP(13, cam_mclk, pll_bypassnl, qdss_gpio0, ddr_pxi3,
+	[13] = PINGROUP(13, WEST, cam_mclk, pll_bypassnl, qdss_gpio0, ddr_pxi3,
 			NA, NA, NA, NA, NA),
-	[14] = PINGROUP(14, cam_mclk, pll_reset, qdss_gpio1, NA, NA, NA,
+	[14] = PINGROUP(14, WEST, cam_mclk, pll_reset, qdss_gpio1, NA, NA, NA,
 			NA, NA, NA),
-	[15] = PINGROUP(15, cam_mclk, qdss_gpio2, NA, NA, NA, NA, NA, NA,
+	[15] = PINGROUP(15, WEST, cam_mclk, qdss_gpio2, NA, NA, NA, NA, NA, NA,
 			NA),
-	[16] = PINGROUP(16, cam_mclk, qdss_gpio3, NA, NA, NA, NA, NA, NA,
+	[16] = PINGROUP(16, WEST, cam_mclk, qdss_gpio3, NA, NA, NA, NA, NA, NA,
 			NA),
-	[17] = PINGROUP(17, cci_i2c, qup1, qdss_gpio4, NA, NA, NA, NA,
+	[17] = PINGROUP(17, WEST, cci_i2c, qup1, qdss_gpio4, NA, NA, NA, NA,
 			NA, NA),
-	[18] = PINGROUP(18, cci_i2c, qup1, NA, qdss_gpio5, NA, NA, NA,
+	[18] = PINGROUP(18, WEST, cci_i2c, qup1, NA, qdss_gpio5, NA, NA, NA,
 			NA, NA),
-	[19] = PINGROUP(19, cci_i2c, qup1, NA, qdss_gpio6, NA, NA, NA,
+	[19] = PINGROUP(19, WEST, cci_i2c, qup1, NA, qdss_gpio6, NA, NA, NA,
 			NA, NA),
-	[20] = PINGROUP(20, cci_i2c, qup1, NA, qdss_gpio7, NA, NA, NA,
+	[20] = PINGROUP(20, WEST, cci_i2c, qup1, NA, qdss_gpio7, NA, NA, NA,
 			NA, NA),
-	[21] = PINGROUP(21, cci_timer0, gcc_gp2, qdss_gpio8, NA, NA, NA,
+	[21] = PINGROUP(21, WEST, cci_timer0, gcc_gp2, qdss_gpio8, NA, NA, NA,
 			NA, NA, NA),
-	[22] = PINGROUP(22, cci_timer1, gcc_gp3, qdss_gpio, NA, NA, NA,
+	[22] = PINGROUP(22, WEST, cci_timer1, gcc_gp3, qdss_gpio, NA, NA, NA,
 			NA, NA, NA),
-	[23] = PINGROUP(23, cci_timer2, qdss_gpio9, NA, NA, NA, NA, NA,
+	[23] = PINGROUP(23, WEST, cci_timer2, qdss_gpio9, NA, NA, NA, NA, NA,
 			NA, NA),
-	[24] = PINGROUP(24, cci_timer3, cci_async, qdss_gpio10, NA, NA,
+	[24] = PINGROUP(24, WEST, cci_timer3, cci_async, qdss_gpio10, NA, NA,
 			NA, NA, NA, NA),
-	[25] = PINGROUP(25, cci_timer4, cci_async, qdss_gpio11, NA, NA,
+	[25] = PINGROUP(25, WEST, cci_timer4, cci_async, qdss_gpio11, NA, NA,
 			NA, NA, NA, NA),
-	[26] = PINGROUP(26, cci_async, qdss_gpio12, JITTER_BIST, NA, NA,
+	[26] = PINGROUP(26, WEST, cci_async, qdss_gpio12, JITTER_BIST, NA, NA,
 			NA, NA, NA, NA),
-	[27] = PINGROUP(27, qup2, qdss_gpio13, PLL_BIST, NA, NA, NA, NA,
+	[27] = PINGROUP(27, WEST, qup2, qdss_gpio13, PLL_BIST, NA, NA, NA, NA,
 			NA, NA),
-	[28] = PINGROUP(28, qup2, qdss_gpio14, AGERA_PLL, NA, NA, NA, NA,
+	[28] = PINGROUP(28, WEST, qup2, qdss_gpio14, AGERA_PLL, NA, NA, NA, NA,
 			NA, NA),
-	[29] = PINGROUP(29, qup2, NA, phase_flag1, qdss_gpio15,
+	[29] = PINGROUP(29, WEST, qup2, NA, phase_flag1, qdss_gpio15,
 			atest_tsens, NA, NA, NA, NA),
-	[30] = PINGROUP(30, qup2, phase_flag2, qdss_gpio, NA, NA, NA, NA,
+	[30] = PINGROUP(30, WEST, qup2, phase_flag2, qdss_gpio, NA, NA, NA, NA,
 			NA, NA),
-	[31] = PINGROUP(31, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[32] = PINGROUP(32, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[33] = PINGROUP(33, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[34] = PINGROUP(34, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[35] = PINGROUP(35, pci_e0, QUP_L4, JITTER_BIST, NA, NA, NA, NA,
+	[31] = PINGROUP(31, WEST, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
+	[32] = PINGROUP(32, WEST, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
+	[33] = PINGROUP(33, WEST, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
+	[34] = PINGROUP(34, WEST, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
+	[35] = PINGROUP(35, NORTH, pci_e0, QUP_L4, JITTER_BIST, NA, NA, NA, NA,
 			NA, NA),
-	[36] = PINGROUP(36, pci_e0, QUP_L5, PLL_BIST, NA, NA, NA, NA,
+	[36] = PINGROUP(36, NORTH, pci_e0, QUP_L5, PLL_BIST, NA, NA, NA, NA,
 			NA, NA),
-	[37] = PINGROUP(37, QUP_L6, AGERA_PLL, NA, NA, NA, NA, NA, NA,
+	[37] = PINGROUP(37, NORTH, QUP_L6, AGERA_PLL, NA, NA, NA, NA, NA, NA,
 			NA),
-	[38] = PINGROUP(38, usb_phy, NA, NA, NA, NA, NA, NA, NA, NA),
-	[39] = PINGROUP(39, lpass_slimbus, NA, NA, NA, NA, NA, NA, NA,
+	[38] = PINGROUP(38, NORTH, usb_phy, NA, NA, NA, NA, NA, NA, NA, NA),
+	[39] = PINGROUP(39, NORTH, lpass_slimbus, NA, NA, NA, NA, NA, NA, NA,
 			NA),
-	[40] = PINGROUP(40, sd_write, tsif1_error, NA, NA, NA, NA, NA,
+	[40] = PINGROUP(40, NORTH, sd_write, tsif1_error, NA, NA, NA, NA, NA,
 			NA, NA),
-	[41] = PINGROUP(41, qup3, NA, qdss_gpio6, NA, NA, NA, NA, NA,
+	[41] = PINGROUP(41, SOUTH, qup3, NA, qdss_gpio6, NA, NA, NA, NA, NA,
 			NA),
-	[42] = PINGROUP(42, qup3, NA, qdss_gpio7, NA, NA, NA, NA, NA,
+	[42] = PINGROUP(42, SOUTH, qup3, NA, qdss_gpio7, NA, NA, NA, NA, NA,
 			NA),
-	[43] = PINGROUP(43, qup3, NA, qdss_gpio14, NA, NA, NA, NA, NA,
+	[43] = PINGROUP(43, SOUTH, qup3, NA, qdss_gpio14, NA, NA, NA, NA, NA,
 			NA),
-	[44] = PINGROUP(44, qup3, NA, qdss_gpio15, NA, NA, NA, NA, NA,
+	[44] = PINGROUP(44, SOUTH, qup3, NA, qdss_gpio15, NA, NA, NA, NA, NA,
 			NA),
-	[45] = PINGROUP(45, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[46] = PINGROUP(46, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[47] = PINGROUP(47, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[48] = PINGROUP(48, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[49] = PINGROUP(49, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
-	[50] = PINGROUP(50, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
-	[51] = PINGROUP(51, qup12, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[52] = PINGROUP(52, qup12, phase_flag16, qdss_cti, NA, NA, NA,
+	[45] = PINGROUP(45, SOUTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
+	[46] = PINGROUP(46, SOUTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
+	[47] = PINGROUP(47, SOUTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
+	[48] = PINGROUP(48, SOUTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
+	[49] = PINGROUP(49, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
+	[50] = PINGROUP(50, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
+	[51] = PINGROUP(51, NORTH, qup12, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[52] = PINGROUP(52, NORTH, qup12, phase_flag16, qdss_cti, NA, NA, NA,
 			NA, NA, NA),
-	[53] = PINGROUP(53, qup10, phase_flag11, NA, NA, NA, NA, NA, NA,
+	[53] = PINGROUP(53, NORTH, qup10, phase_flag11, NA, NA, NA, NA, NA, NA,
 			NA),
-	[54] = PINGROUP(54, qup10, GP_PDM0, phase_flag12, NA,
+	[54] = PINGROUP(54, NORTH, qup10, GP_PDM0, phase_flag12, NA,
 			wlan1_adc1, atest_usb13, ddr_pxi1, NA, NA),
-	[55] = PINGROUP(55, qup10, phase_flag13, NA, wlan1_adc0,
+	[55] = PINGROUP(55, NORTH, qup10, phase_flag13, NA, wlan1_adc0,
 			atest_usb12, ddr_pxi1, NA, NA, NA),
-	[56] = PINGROUP(56, qup10, phase_flag17, NA, NA, NA, NA, NA, NA,
+	[56] = PINGROUP(56, NORTH, qup10, phase_flag17, NA, NA, NA, NA, NA, NA,
 			NA),
-	[57] = PINGROUP(57, qua_mi2s, gcc_gp1, phase_flag18, NA, NA, NA,
+	[57] = PINGROUP(57, NORTH, qua_mi2s, gcc_gp1, phase_flag18, NA, NA, NA,
 			NA, NA, NA),
-	[58] = PINGROUP(58, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[59] = PINGROUP(59, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[60] = PINGROUP(60, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[61] = PINGROUP(61, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[62] = PINGROUP(62, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[63] = PINGROUP(63, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[64] = PINGROUP(64, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[65] = PINGROUP(65, pri_mi2s, qup8, wsa_clk, NA, NA, NA, NA, NA,
+	[58] = PINGROUP(58, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[59] = PINGROUP(59, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[60] = PINGROUP(60, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[61] = PINGROUP(61, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[62] = PINGROUP(62, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[63] = PINGROUP(63, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[64] = PINGROUP(64, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[65] = PINGROUP(65, NORTH, pri_mi2s, qup8, wsa_clk, NA, NA, NA, NA, NA,
 			NA),
-	[66] = PINGROUP(66, pri_mi2s_ws, qup8, wsa_data, GP_PDM1, NA,
+	[66] = PINGROUP(66, NORTH, pri_mi2s_ws, qup8, wsa_data, GP_PDM1, NA,
 			NA, NA, NA, NA),
-	[67] = PINGROUP(67, pri_mi2s, qup8, NA, atest_usb2, NA, NA, NA,
+	[67] = PINGROUP(67, NORTH, pri_mi2s, qup8, NA, atest_usb2, NA, NA, NA,
 			NA, NA),
-	[68] = PINGROUP(68, pri_mi2s, qup8, NA, atest_usb23, NA, NA, NA,
+	[68] = PINGROUP(68, NORTH, pri_mi2s, qup8, NA, atest_usb23, NA, NA, NA,
 			NA, NA),
-	[69] = PINGROUP(69, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[70] = PINGROUP(70, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[71] = PINGROUP(71, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[72] = PINGROUP(72, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[73] = PINGROUP(73, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[74] = PINGROUP(74, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[75] = PINGROUP(75, ter_mi2s, phase_flag8, qdss_gpio8,
+	[69] = PINGROUP(69, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[70] = PINGROUP(70, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[71] = PINGROUP(71, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[72] = PINGROUP(72, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[73] = PINGROUP(73, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[74] = PINGROUP(74, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[75] = PINGROUP(75, NORTH, ter_mi2s, phase_flag8, qdss_gpio8,
 			atest_usb22, QUP_L4, NA, NA, NA, NA),
-	[76] = PINGROUP(76, ter_mi2s, phase_flag9, qdss_gpio9,
+	[76] = PINGROUP(76, NORTH, ter_mi2s, phase_flag9, qdss_gpio9,
 			atest_usb21, QUP_L5, NA, NA, NA, NA),
-	[77] = PINGROUP(77, ter_mi2s, phase_flag4, qdss_gpio10,
+	[77] = PINGROUP(77, NORTH, ter_mi2s, phase_flag4, qdss_gpio10,
 			atest_usb20, QUP_L6, NA, NA, NA, NA),
-	[78] = PINGROUP(78, ter_mi2s, gcc_gp1, NA, NA, NA, NA, NA, NA,
+	[78] = PINGROUP(78, NORTH, ter_mi2s, gcc_gp1, NA, NA, NA, NA, NA, NA,
 			NA),
-	[79] = PINGROUP(79, sec_mi2s, GP_PDM2, NA, qdss_gpio11, NA, NA,
+	[79] = PINGROUP(79, NORTH, sec_mi2s, GP_PDM2, NA, qdss_gpio11, NA, NA,
 			NA, NA, NA),
-	[80] = PINGROUP(80, sec_mi2s, NA, qdss_gpio12, NA, NA, NA, NA,
+	[80] = PINGROUP(80, NORTH, sec_mi2s, NA, qdss_gpio12, NA, NA, NA, NA,
 			NA, NA),
-	[81] = PINGROUP(81, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[82] = PINGROUP(82, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[83] = PINGROUP(83, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[84] = PINGROUP(84, qup15, NA, NA, NA, NA, NA, NA, NA, NA),
-	[85] = PINGROUP(85, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[86] = PINGROUP(86, qup5, copy_gp, NA, NA, NA, NA, NA, NA, NA),
-	[87] = PINGROUP(87, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[88] = PINGROUP(88, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[89] = PINGROUP(89, tsif1_clk, qup4, tgu_ch3, phase_flag10, NA,
+	[81] = PINGROUP(81, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
+	[82] = PINGROUP(82, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
+	[83] = PINGROUP(83, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
+	[84] = PINGROUP(84, NORTH, qup15, NA, NA, NA, NA, NA, NA, NA, NA),
+	[85] = PINGROUP(85, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
+	[86] = PINGROUP(86, SOUTH, qup5, copy_gp, NA, NA, NA, NA, NA, NA, NA),
+	[87] = PINGROUP(87, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
+	[88] = PINGROUP(88, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
+	[89] = PINGROUP(89, SOUTH, tsif1_clk, qup4, tgu_ch3, phase_flag10, NA,
 			NA, NA, NA, NA),
-	[90] = PINGROUP(90, tsif1_en, mdp_vsync0, qup4, mdp_vsync1,
+	[90] = PINGROUP(90, SOUTH, tsif1_en, mdp_vsync0, qup4, mdp_vsync1,
 			mdp_vsync2, mdp_vsync3, tgu_ch0, phase_flag0, qdss_cti),
-	[91] = PINGROUP(91, tsif1_data, sdc4_cmd, qup4, tgu_ch1, NA,
+	[91] = PINGROUP(91, SOUTH, tsif1_data, sdc4_cmd, qup4, tgu_ch1, NA,
 			qdss_cti, NA, NA, NA),
-	[92] = PINGROUP(92, tsif2_error, sdc43, qup4, vfr_1, tgu_ch2,
+	[92] = PINGROUP(92, SOUTH, tsif2_error, sdc43, qup4, vfr_1, tgu_ch2,
 			NA, NA, NA, NA),
-	[93] = PINGROUP(93, tsif2_clk, sdc4_clk, qup7, NA, qdss_gpio13,
+	[93] = PINGROUP(93, SOUTH, tsif2_clk, sdc4_clk, qup7, NA, qdss_gpio13,
 			NA, NA, NA, NA),
-	[94] = PINGROUP(94, tsif2_en, sdc42, qup7, NA, NA, NA, NA, NA,
+	[94] = PINGROUP(94, SOUTH, tsif2_en, sdc42, qup7, NA, NA, NA, NA, NA,
 			NA),
-	[95] = PINGROUP(95, tsif2_data, sdc41, qup7, GP_PDM0, NA, NA,
+	[95] = PINGROUP(95, SOUTH, tsif2_data, sdc41, qup7, GP_PDM0, NA, NA,
 			NA, NA, NA),
-	[96] = PINGROUP(96, tsif2_sync, sdc40, qup7, phase_flag3, NA,
+	[96] = PINGROUP(96, SOUTH, tsif2_sync, sdc40, qup7, phase_flag3, NA,
 			NA, NA, NA, NA),
-	[97] = PINGROUP(97, NA, NA, mdp_vsync, ldo_en, NA, NA, NA, NA,
+	[97] = PINGROUP(97, WEST, NA, NA, mdp_vsync, ldo_en, NA, NA, NA, NA,
 			NA),
-	[98] = PINGROUP(98, NA, mdp_vsync, ldo_update, NA, NA, NA, NA,
+	[98] = PINGROUP(98, WEST, NA, mdp_vsync, ldo_update, NA, NA, NA, NA,
 			NA, NA),
-	[99] = PINGROUP(99, phase_flag14, prng_rosc, NA, NA, NA, NA, NA,
+	[99] = PINGROUP(99, NORTH, phase_flag14, prng_rosc, NA, NA, NA, NA, NA,
 			NA, NA),
-	[100] = PINGROUP(100, phase_flag15, NA, NA, NA, NA, NA, NA, NA,
+	[100] = PINGROUP(100, WEST, phase_flag15, NA, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[101] = PINGROUP(101, NA, phase_flag5, NA, NA, NA, NA, NA, NA,
+	[101] = PINGROUP(101, WEST, NA, phase_flag5, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[102] = PINGROUP(102, pci_e1, prng_rosc, NA, NA, NA, NA, NA, NA,
+	[102] = PINGROUP(102, WEST, pci_e1, prng_rosc, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[103] = PINGROUP(103, pci_e1, COPY_PHASE, NA, NA, NA, NA, NA, NA,
+	[103] = PINGROUP(103, WEST, pci_e1, COPY_PHASE, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[104] = PINGROUP(104, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[105] = PINGROUP(105, uim2_data, qup13, qup_l4, NA, NA, NA, NA,
+	[104] = PINGROUP(104, DUMMY, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[105] = PINGROUP(105, NORTH, uim2_data, qup13, qup_l4, NA, NA, NA, NA,
 			 NA, NA),
-	[106] = PINGROUP(106, uim2_clk, qup13, qup_l5, NA, NA, NA, NA,
+	[106] = PINGROUP(106, NORTH, uim2_clk, qup13, qup_l5, NA, NA, NA, NA,
 			 NA, NA),
-	[107] = PINGROUP(107, uim2_reset, qup13, qup_l6, NA, NA, NA, NA,
+	[107] = PINGROUP(107, NORTH, uim2_reset, qup13, qup_l6, NA, NA, NA, NA,
 			 NA, NA),
-	[108] = PINGROUP(108, uim2_present, qup13, NA, NA, NA, NA, NA,
+	[108] = PINGROUP(108, NORTH, uim2_present, qup13, NA, NA, NA, NA, NA,
 			 NA, NA),
-	[109] = PINGROUP(109, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA),
-	[110] = PINGROUP(110, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA),
-	[111] = PINGROUP(111, uim1_reset, NA, NA, NA, NA, NA, NA, NA,
+	[109] = PINGROUP(109, NORTH, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA),
+	[110] = PINGROUP(110, NORTH, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA),
+	[111] = PINGROUP(111, NORTH, uim1_reset, NA, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[112] = PINGROUP(112, uim1_present, NA, NA, NA, NA, NA, NA, NA,
+	[112] = PINGROUP(112, NORTH, uim1_present, NA, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[113] = PINGROUP(113, uim_batt, edp_hot, NA, NA, NA, NA, NA, NA,
+	[113] = PINGROUP(113, NORTH, uim_batt, edp_hot, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[114] = PINGROUP(114, NA, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA,
+	[114] = PINGROUP(114, WEST, NA, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA,
 			 NA, NA),
-	[115] = PINGROUP(115, NA, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA,
+	[115] = PINGROUP(115, WEST, NA, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA,
 			 NA, NA),
-	[116] = PINGROUP(116, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[117] = PINGROUP(117, NA, qdss_gpio0, atest_char, NA, NA, NA,
+	[116] = PINGROUP(116, SOUTH, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[117] = PINGROUP(117, NORTH, NA, qdss_gpio0, atest_char, NA, NA, NA,
 			 NA, NA, NA),
-	[118] = PINGROUP(118, adsp_ext, NA, qdss_gpio1, atest_char3, NA,
+	[118] = PINGROUP(118, NORTH, adsp_ext, NA, qdss_gpio1, atest_char3, NA,
 			 NA, NA, NA, NA),
-	[119] = PINGROUP(119, NA, qdss_gpio2, atest_char2, NA, NA, NA,
+	[119] = PINGROUP(119, NORTH, NA, qdss_gpio2, atest_char2, NA, NA, NA,
 			 NA, NA, NA),
-	[120] = PINGROUP(120, NA, qdss_gpio3, atest_char1, NA, NA, NA,
+	[120] = PINGROUP(120, NORTH, NA, qdss_gpio3, atest_char1, NA, NA, NA,
 			 NA, NA, NA),
-	[121] = PINGROUP(121, NA, qdss_gpio4, atest_char0, NA, NA, NA,
+	[121] = PINGROUP(121, NORTH, NA, qdss_gpio4, atest_char0, NA, NA, NA,
 			 NA, NA, NA),
-	[122] = PINGROUP(122, NA, qdss_gpio5, NA, NA, NA, NA, NA, NA,
+	[122] = PINGROUP(122, NORTH, NA, qdss_gpio5, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[123] = PINGROUP(123, qup_l4, NA, qdss_gpio, NA, NA, NA, NA, NA,
+	[123] = PINGROUP(123, NORTH, qup_l4, NA, qdss_gpio, NA, NA, NA, NA, NA,
 			 NA),
-	[124] = PINGROUP(124, qup_l5, NA, qdss_gpio, NA, NA, NA, NA, NA,
+	[124] = PINGROUP(124, NORTH, qup_l5, NA, qdss_gpio, NA, NA, NA, NA, NA,
 			 NA),
-	[125] = PINGROUP(125, qup_l6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[126] = PINGROUP(126, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[127] = PINGROUP(127, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[128] = PINGROUP(128, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA, NA,
+	[125] = PINGROUP(125, NORTH, qup_l6, NA, NA, NA, NA, NA, NA, NA, NA),
+	[126] = PINGROUP(126, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[127] = PINGROUP(127, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[128] = PINGROUP(128, WEST, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA, NA,
 			 NA, NA),
-	[129] = PINGROUP(129, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA, NA,
+	[129] = PINGROUP(129, WEST, NAV_PPS, NAV_PPS, GPS_TX, NA, NA, NA, NA,
 			 NA, NA),
-	[130] = PINGROUP(130, qlink_request, NA, NA, NA, NA, NA, NA, NA,
+	[130] = PINGROUP(130, WEST, qlink_request, NA, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[131] = PINGROUP(131, qlink_enable, NA, NA, NA, NA, NA, NA, NA,
+	[131] = PINGROUP(131, WEST, qlink_enable, NA, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[132] = PINGROUP(132, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[133] = PINGROUP(133, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[134] = PINGROUP(134, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[135] = PINGROUP(135, NA, pa_indicator, NA, NA, NA, NA, NA, NA,
+	[132] = PINGROUP(132, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[133] = PINGROUP(133, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[134] = PINGROUP(134, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[135] = PINGROUP(135, WEST, NA, pa_indicator, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[136] = PINGROUP(136, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[137] = PINGROUP(137, NA, NA, phase_flag26, NA, NA, NA, NA, NA,
+	[136] = PINGROUP(136, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[137] = PINGROUP(137, WEST, NA, NA, phase_flag26, NA, NA, NA, NA, NA,
 			 NA),
-	[138] = PINGROUP(138, NA, NA, phase_flag27, NA, NA, NA, NA, NA,
+	[138] = PINGROUP(138, WEST, NA, NA, phase_flag27, NA, NA, NA, NA, NA,
 			 NA),
-	[139] = PINGROUP(139, NA, phase_flag28, NA, NA, NA, NA, NA, NA,
+	[139] = PINGROUP(139, WEST, NA, phase_flag28, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[140] = PINGROUP(140, NA, NA, phase_flag6, NA, NA, NA, NA, NA,
+	[140] = PINGROUP(140, WEST, NA, NA, phase_flag6, NA, NA, NA, NA, NA,
 			 NA),
-	[141] = PINGROUP(141, NA, phase_flag29, NA, NA, NA, NA, NA, NA,
+	[141] = PINGROUP(141, WEST, NA, phase_flag29, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[142] = PINGROUP(142, NA, phase_flag30, NA, NA, NA, NA, NA, NA,
+	[142] = PINGROUP(142, WEST, NA, phase_flag30, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[143] = PINGROUP(143, NA, NAV_PPS, NAV_PPS, GPS_TX, phase_flag31,
+	[143] = PINGROUP(143, WEST, NA, NAV_PPS, NAV_PPS, GPS_TX, phase_flag31,
 			 NA, NA, NA, NA),
-	[144] = PINGROUP(144, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA),
-	[145] = PINGROUP(145, mss_lte, GPS_TX, NA, NA, NA, NA, NA, NA,
+	[144] = PINGROUP(144, SOUTH, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA),
+	[145] = PINGROUP(145, SOUTH, mss_lte, GPS_TX, NA, NA, NA, NA, NA, NA,
 			 NA),
-	[146] = PINGROUP(146, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[147] = PINGROUP(147, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[148] = PINGROUP(148, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[149] = PINGROUP(149, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[150] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x599000, 15, 0),
-	[151] = SDC_QDSD_PINGROUP(sdc1_clk, 0x599000, 13, 6),
-	[152] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x599000, 11, 3),
-	[153] = SDC_QDSD_PINGROUP(sdc1_data, 0x599000, 9, 0),
-	[154] = SDC_QDSD_PINGROUP(sdc2_clk, 0x99a000, 14, 6),
-	[155] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x99a000, 11, 3),
-	[156] = SDC_QDSD_PINGROUP(sdc2_data, 0x99a000, 9, 0),
-	[157] = UFS_RESET(ufs_reset, 0x99f000),
+	[146] = PINGROUP(146, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[147] = PINGROUP(147, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[148] = PINGROUP(148, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[149] = PINGROUP(149, WEST, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[150] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x99000, 15, 0),
+	[151] = SDC_QDSD_PINGROUP(sdc1_clk, 0x99000, 13, 6),
+	[152] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x99000, 11, 3),
+	[153] = SDC_QDSD_PINGROUP(sdc1_data, 0x99000, 9, 0),
+	[154] = SDC_QDSD_PINGROUP(sdc2_clk, 0x9a000, 14, 6),
+	[155] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x9a000, 11, 3),
+	[156] = SDC_QDSD_PINGROUP(sdc2_data, 0x9a000, 9, 0),
+	[157] = UFS_RESET(ufs_reset, 0x9f000),
 };
-
 static const struct msm_dir_conn sdm670_dir_conn[] = {
 	{1, 510},
 	{3, 511},
@@ -1663,10 +1663,6 @@
 	.ngpios = 150,
 	.dir_conn = sdm670_dir_conn,
 	.n_dir_conns = ARRAY_SIZE(sdm670_dir_conn),
-	.tile_offsets = sdm670_tile_offsets,
-	.n_tile_offsets = ARRAY_SIZE(sdm670_tile_offsets),
-	.pin_base = sdm670_pin_base,
-	.reg_size = REG_SIZE,
 };
 
 static int sdm670_pinctrl_probe(struct platform_device *pdev)
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845-v2.c b/drivers/pinctrl/qcom/pinctrl-sdm845-v2.c
new file mode 100644
index 0000000..f7d551e
--- /dev/null
+++ b/drivers/pinctrl/qcom/pinctrl-sdm845-v2.c
@@ -0,0 +1,1805 @@
+/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pinctrl/pinctrl.h>
+
+#include "pinctrl-msm.h"
+
+#define FUNCTION(fname)					\
+	[msm_mux_##fname] = {				\
+		.name = #fname,				\
+		.groups = fname##_groups,		\
+		.ngroups = ARRAY_SIZE(fname##_groups),	\
+	}
+
+#define NORTH	0x00500000
+#define SOUTH	0x00900000
+#define EAST	0x00100000
+#define REG_SIZE 0x1000
+#define PINGROUP(id, base, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10)	\
+	{						\
+		.name = "gpio" #id,			\
+		.pins = gpio##id##_pins,		\
+		.npins = (unsigned int)ARRAY_SIZE(gpio##id##_pins),	\
+		.funcs = (int[]){			\
+			msm_mux_gpio, /* gpio mode */	\
+			msm_mux_##f1,			\
+			msm_mux_##f2,			\
+			msm_mux_##f3,			\
+			msm_mux_##f4,			\
+			msm_mux_##f5,			\
+			msm_mux_##f6,			\
+			msm_mux_##f7,			\
+			msm_mux_##f8,			\
+			msm_mux_##f9,			\
+			msm_mux_##f10			\
+		},					\
+		.nfuncs = 11,				\
+		.ctl_reg = base + REG_SIZE * id,		\
+		.io_reg = base + 0x4 + REG_SIZE * id,		\
+		.intr_cfg_reg = base + 0x8 + REG_SIZE * id,	\
+		.intr_status_reg = base + 0xc + REG_SIZE * id,	\
+		.intr_target_reg = base + 0x8 + REG_SIZE * id,	\
+		.mux_bit = 2,			\
+		.pull_bit = 0,			\
+		.drv_bit = 6,			\
+		.oe_bit = 9,			\
+		.in_bit = 0,			\
+		.out_bit = 1,			\
+		.intr_enable_bit = 0,		\
+		.intr_status_bit = 0,		\
+		.intr_target_bit = 5,		\
+		.intr_target_kpss_val = 3,	\
+		.intr_raw_status_bit = 4,	\
+		.intr_polarity_bit = 1,		\
+		.intr_detection_bit = 2,	\
+		.intr_detection_width = 2,	\
+	}
+
+#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv)	\
+	{						\
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = (unsigned int)ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = ctl,				\
+		.io_reg = 0,				\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = pull,			\
+		.drv_bit = drv,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = -1,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+
+#define UFS_RESET(pg_name, offset)				\
+	{						\
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = (unsigned int)ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = offset,			\
+		.io_reg = offset + 0x4,			\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = 3,				\
+		.drv_bit = 0,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = 0,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+static const struct pinctrl_pin_desc sdm845_pins[] = {
+	PINCTRL_PIN(0, "GPIO_0"),
+	PINCTRL_PIN(1, "GPIO_1"),
+	PINCTRL_PIN(2, "GPIO_2"),
+	PINCTRL_PIN(3, "GPIO_3"),
+	PINCTRL_PIN(4, "GPIO_4"),
+	PINCTRL_PIN(5, "GPIO_5"),
+	PINCTRL_PIN(6, "GPIO_6"),
+	PINCTRL_PIN(7, "GPIO_7"),
+	PINCTRL_PIN(8, "GPIO_8"),
+	PINCTRL_PIN(9, "GPIO_9"),
+	PINCTRL_PIN(10, "GPIO_10"),
+	PINCTRL_PIN(11, "GPIO_11"),
+	PINCTRL_PIN(12, "GPIO_12"),
+	PINCTRL_PIN(13, "GPIO_13"),
+	PINCTRL_PIN(14, "GPIO_14"),
+	PINCTRL_PIN(15, "GPIO_15"),
+	PINCTRL_PIN(16, "GPIO_16"),
+	PINCTRL_PIN(17, "GPIO_17"),
+	PINCTRL_PIN(18, "GPIO_18"),
+	PINCTRL_PIN(19, "GPIO_19"),
+	PINCTRL_PIN(20, "GPIO_20"),
+	PINCTRL_PIN(21, "GPIO_21"),
+	PINCTRL_PIN(22, "GPIO_22"),
+	PINCTRL_PIN(23, "GPIO_23"),
+	PINCTRL_PIN(24, "GPIO_24"),
+	PINCTRL_PIN(25, "GPIO_25"),
+	PINCTRL_PIN(26, "GPIO_26"),
+	PINCTRL_PIN(27, "GPIO_27"),
+	PINCTRL_PIN(28, "GPIO_28"),
+	PINCTRL_PIN(29, "GPIO_29"),
+	PINCTRL_PIN(30, "GPIO_30"),
+	PINCTRL_PIN(31, "GPIO_31"),
+	PINCTRL_PIN(32, "GPIO_32"),
+	PINCTRL_PIN(33, "GPIO_33"),
+	PINCTRL_PIN(34, "GPIO_34"),
+	PINCTRL_PIN(35, "GPIO_35"),
+	PINCTRL_PIN(36, "GPIO_36"),
+	PINCTRL_PIN(37, "GPIO_37"),
+	PINCTRL_PIN(38, "GPIO_38"),
+	PINCTRL_PIN(39, "GPIO_39"),
+	PINCTRL_PIN(40, "GPIO_40"),
+	PINCTRL_PIN(41, "GPIO_41"),
+	PINCTRL_PIN(42, "GPIO_42"),
+	PINCTRL_PIN(43, "GPIO_43"),
+	PINCTRL_PIN(44, "GPIO_44"),
+	PINCTRL_PIN(45, "GPIO_45"),
+	PINCTRL_PIN(46, "GPIO_46"),
+	PINCTRL_PIN(47, "GPIO_47"),
+	PINCTRL_PIN(48, "GPIO_48"),
+	PINCTRL_PIN(49, "GPIO_49"),
+	PINCTRL_PIN(50, "GPIO_50"),
+	PINCTRL_PIN(51, "GPIO_51"),
+	PINCTRL_PIN(52, "GPIO_52"),
+	PINCTRL_PIN(53, "GPIO_53"),
+	PINCTRL_PIN(54, "GPIO_54"),
+	PINCTRL_PIN(55, "GPIO_55"),
+	PINCTRL_PIN(56, "GPIO_56"),
+	PINCTRL_PIN(57, "GPIO_57"),
+	PINCTRL_PIN(58, "GPIO_58"),
+	PINCTRL_PIN(59, "GPIO_59"),
+	PINCTRL_PIN(60, "GPIO_60"),
+	PINCTRL_PIN(61, "GPIO_61"),
+	PINCTRL_PIN(62, "GPIO_62"),
+	PINCTRL_PIN(63, "GPIO_63"),
+	PINCTRL_PIN(64, "GPIO_64"),
+	PINCTRL_PIN(65, "GPIO_65"),
+	PINCTRL_PIN(66, "GPIO_66"),
+	PINCTRL_PIN(67, "GPIO_67"),
+	PINCTRL_PIN(68, "GPIO_68"),
+	PINCTRL_PIN(69, "GPIO_69"),
+	PINCTRL_PIN(70, "GPIO_70"),
+	PINCTRL_PIN(71, "GPIO_71"),
+	PINCTRL_PIN(72, "GPIO_72"),
+	PINCTRL_PIN(73, "GPIO_73"),
+	PINCTRL_PIN(74, "GPIO_74"),
+	PINCTRL_PIN(75, "GPIO_75"),
+	PINCTRL_PIN(76, "GPIO_76"),
+	PINCTRL_PIN(77, "GPIO_77"),
+	PINCTRL_PIN(78, "GPIO_78"),
+	PINCTRL_PIN(79, "GPIO_79"),
+	PINCTRL_PIN(80, "GPIO_80"),
+	PINCTRL_PIN(81, "GPIO_81"),
+	PINCTRL_PIN(82, "GPIO_82"),
+	PINCTRL_PIN(83, "GPIO_83"),
+	PINCTRL_PIN(84, "GPIO_84"),
+	PINCTRL_PIN(85, "GPIO_85"),
+	PINCTRL_PIN(86, "GPIO_86"),
+	PINCTRL_PIN(87, "GPIO_87"),
+	PINCTRL_PIN(88, "GPIO_88"),
+	PINCTRL_PIN(89, "GPIO_89"),
+	PINCTRL_PIN(90, "GPIO_90"),
+	PINCTRL_PIN(91, "GPIO_91"),
+	PINCTRL_PIN(92, "GPIO_92"),
+	PINCTRL_PIN(93, "GPIO_93"),
+	PINCTRL_PIN(94, "GPIO_94"),
+	PINCTRL_PIN(95, "GPIO_95"),
+	PINCTRL_PIN(96, "GPIO_96"),
+	PINCTRL_PIN(97, "GPIO_97"),
+	PINCTRL_PIN(98, "GPIO_98"),
+	PINCTRL_PIN(99, "GPIO_99"),
+	PINCTRL_PIN(100, "GPIO_100"),
+	PINCTRL_PIN(101, "GPIO_101"),
+	PINCTRL_PIN(102, "GPIO_102"),
+	PINCTRL_PIN(103, "GPIO_103"),
+	PINCTRL_PIN(104, "GPIO_104"),
+	PINCTRL_PIN(105, "GPIO_105"),
+	PINCTRL_PIN(106, "GPIO_106"),
+	PINCTRL_PIN(107, "GPIO_107"),
+	PINCTRL_PIN(108, "GPIO_108"),
+	PINCTRL_PIN(109, "GPIO_109"),
+	PINCTRL_PIN(110, "GPIO_110"),
+	PINCTRL_PIN(111, "GPIO_111"),
+	PINCTRL_PIN(112, "GPIO_112"),
+	PINCTRL_PIN(113, "GPIO_113"),
+	PINCTRL_PIN(114, "GPIO_114"),
+	PINCTRL_PIN(115, "GPIO_115"),
+	PINCTRL_PIN(116, "GPIO_116"),
+	PINCTRL_PIN(117, "GPIO_117"),
+	PINCTRL_PIN(118, "GPIO_118"),
+	PINCTRL_PIN(119, "GPIO_119"),
+	PINCTRL_PIN(120, "GPIO_120"),
+	PINCTRL_PIN(121, "GPIO_121"),
+	PINCTRL_PIN(122, "GPIO_122"),
+	PINCTRL_PIN(123, "GPIO_123"),
+	PINCTRL_PIN(124, "GPIO_124"),
+	PINCTRL_PIN(125, "GPIO_125"),
+	PINCTRL_PIN(126, "GPIO_126"),
+	PINCTRL_PIN(127, "GPIO_127"),
+	PINCTRL_PIN(128, "GPIO_128"),
+	PINCTRL_PIN(129, "GPIO_129"),
+	PINCTRL_PIN(130, "GPIO_130"),
+	PINCTRL_PIN(131, "GPIO_131"),
+	PINCTRL_PIN(132, "GPIO_132"),
+	PINCTRL_PIN(133, "GPIO_133"),
+	PINCTRL_PIN(134, "GPIO_134"),
+	PINCTRL_PIN(135, "GPIO_135"),
+	PINCTRL_PIN(136, "GPIO_136"),
+	PINCTRL_PIN(137, "GPIO_137"),
+	PINCTRL_PIN(138, "GPIO_138"),
+	PINCTRL_PIN(139, "GPIO_139"),
+	PINCTRL_PIN(140, "GPIO_140"),
+	PINCTRL_PIN(141, "GPIO_141"),
+	PINCTRL_PIN(142, "GPIO_142"),
+	PINCTRL_PIN(143, "GPIO_143"),
+	PINCTRL_PIN(144, "GPIO_144"),
+	PINCTRL_PIN(145, "GPIO_145"),
+	PINCTRL_PIN(146, "GPIO_146"),
+	PINCTRL_PIN(147, "GPIO_147"),
+	PINCTRL_PIN(148, "GPIO_148"),
+	PINCTRL_PIN(149, "GPIO_149"),
+	PINCTRL_PIN(150, "SDC2_CLK"),
+	PINCTRL_PIN(151, "SDC2_CMD"),
+	PINCTRL_PIN(152, "SDC2_DATA"),
+	PINCTRL_PIN(153, "UFS_RESET"),
+};
+
+#define DECLARE_MSM_GPIO_PINS(pin) \
+	static const unsigned int gpio##pin##_pins[] = { pin }
+DECLARE_MSM_GPIO_PINS(0);
+DECLARE_MSM_GPIO_PINS(1);
+DECLARE_MSM_GPIO_PINS(2);
+DECLARE_MSM_GPIO_PINS(3);
+DECLARE_MSM_GPIO_PINS(4);
+DECLARE_MSM_GPIO_PINS(5);
+DECLARE_MSM_GPIO_PINS(6);
+DECLARE_MSM_GPIO_PINS(7);
+DECLARE_MSM_GPIO_PINS(8);
+DECLARE_MSM_GPIO_PINS(9);
+DECLARE_MSM_GPIO_PINS(10);
+DECLARE_MSM_GPIO_PINS(11);
+DECLARE_MSM_GPIO_PINS(12);
+DECLARE_MSM_GPIO_PINS(13);
+DECLARE_MSM_GPIO_PINS(14);
+DECLARE_MSM_GPIO_PINS(15);
+DECLARE_MSM_GPIO_PINS(16);
+DECLARE_MSM_GPIO_PINS(17);
+DECLARE_MSM_GPIO_PINS(18);
+DECLARE_MSM_GPIO_PINS(19);
+DECLARE_MSM_GPIO_PINS(20);
+DECLARE_MSM_GPIO_PINS(21);
+DECLARE_MSM_GPIO_PINS(22);
+DECLARE_MSM_GPIO_PINS(23);
+DECLARE_MSM_GPIO_PINS(24);
+DECLARE_MSM_GPIO_PINS(25);
+DECLARE_MSM_GPIO_PINS(26);
+DECLARE_MSM_GPIO_PINS(27);
+DECLARE_MSM_GPIO_PINS(28);
+DECLARE_MSM_GPIO_PINS(29);
+DECLARE_MSM_GPIO_PINS(30);
+DECLARE_MSM_GPIO_PINS(31);
+DECLARE_MSM_GPIO_PINS(32);
+DECLARE_MSM_GPIO_PINS(33);
+DECLARE_MSM_GPIO_PINS(34);
+DECLARE_MSM_GPIO_PINS(35);
+DECLARE_MSM_GPIO_PINS(36);
+DECLARE_MSM_GPIO_PINS(37);
+DECLARE_MSM_GPIO_PINS(38);
+DECLARE_MSM_GPIO_PINS(39);
+DECLARE_MSM_GPIO_PINS(40);
+DECLARE_MSM_GPIO_PINS(41);
+DECLARE_MSM_GPIO_PINS(42);
+DECLARE_MSM_GPIO_PINS(43);
+DECLARE_MSM_GPIO_PINS(44);
+DECLARE_MSM_GPIO_PINS(45);
+DECLARE_MSM_GPIO_PINS(46);
+DECLARE_MSM_GPIO_PINS(47);
+DECLARE_MSM_GPIO_PINS(48);
+DECLARE_MSM_GPIO_PINS(49);
+DECLARE_MSM_GPIO_PINS(50);
+DECLARE_MSM_GPIO_PINS(51);
+DECLARE_MSM_GPIO_PINS(52);
+DECLARE_MSM_GPIO_PINS(53);
+DECLARE_MSM_GPIO_PINS(54);
+DECLARE_MSM_GPIO_PINS(55);
+DECLARE_MSM_GPIO_PINS(56);
+DECLARE_MSM_GPIO_PINS(57);
+DECLARE_MSM_GPIO_PINS(58);
+DECLARE_MSM_GPIO_PINS(59);
+DECLARE_MSM_GPIO_PINS(60);
+DECLARE_MSM_GPIO_PINS(61);
+DECLARE_MSM_GPIO_PINS(62);
+DECLARE_MSM_GPIO_PINS(63);
+DECLARE_MSM_GPIO_PINS(64);
+DECLARE_MSM_GPIO_PINS(65);
+DECLARE_MSM_GPIO_PINS(66);
+DECLARE_MSM_GPIO_PINS(67);
+DECLARE_MSM_GPIO_PINS(68);
+DECLARE_MSM_GPIO_PINS(69);
+DECLARE_MSM_GPIO_PINS(70);
+DECLARE_MSM_GPIO_PINS(71);
+DECLARE_MSM_GPIO_PINS(72);
+DECLARE_MSM_GPIO_PINS(73);
+DECLARE_MSM_GPIO_PINS(74);
+DECLARE_MSM_GPIO_PINS(75);
+DECLARE_MSM_GPIO_PINS(76);
+DECLARE_MSM_GPIO_PINS(77);
+DECLARE_MSM_GPIO_PINS(78);
+DECLARE_MSM_GPIO_PINS(79);
+DECLARE_MSM_GPIO_PINS(80);
+DECLARE_MSM_GPIO_PINS(81);
+DECLARE_MSM_GPIO_PINS(82);
+DECLARE_MSM_GPIO_PINS(83);
+DECLARE_MSM_GPIO_PINS(84);
+DECLARE_MSM_GPIO_PINS(85);
+DECLARE_MSM_GPIO_PINS(86);
+DECLARE_MSM_GPIO_PINS(87);
+DECLARE_MSM_GPIO_PINS(88);
+DECLARE_MSM_GPIO_PINS(89);
+DECLARE_MSM_GPIO_PINS(90);
+DECLARE_MSM_GPIO_PINS(91);
+DECLARE_MSM_GPIO_PINS(92);
+DECLARE_MSM_GPIO_PINS(93);
+DECLARE_MSM_GPIO_PINS(94);
+DECLARE_MSM_GPIO_PINS(95);
+DECLARE_MSM_GPIO_PINS(96);
+DECLARE_MSM_GPIO_PINS(97);
+DECLARE_MSM_GPIO_PINS(98);
+DECLARE_MSM_GPIO_PINS(99);
+DECLARE_MSM_GPIO_PINS(100);
+DECLARE_MSM_GPIO_PINS(101);
+DECLARE_MSM_GPIO_PINS(102);
+DECLARE_MSM_GPIO_PINS(103);
+DECLARE_MSM_GPIO_PINS(104);
+DECLARE_MSM_GPIO_PINS(105);
+DECLARE_MSM_GPIO_PINS(106);
+DECLARE_MSM_GPIO_PINS(107);
+DECLARE_MSM_GPIO_PINS(108);
+DECLARE_MSM_GPIO_PINS(109);
+DECLARE_MSM_GPIO_PINS(110);
+DECLARE_MSM_GPIO_PINS(111);
+DECLARE_MSM_GPIO_PINS(112);
+DECLARE_MSM_GPIO_PINS(113);
+DECLARE_MSM_GPIO_PINS(114);
+DECLARE_MSM_GPIO_PINS(115);
+DECLARE_MSM_GPIO_PINS(116);
+DECLARE_MSM_GPIO_PINS(117);
+DECLARE_MSM_GPIO_PINS(118);
+DECLARE_MSM_GPIO_PINS(119);
+DECLARE_MSM_GPIO_PINS(120);
+DECLARE_MSM_GPIO_PINS(121);
+DECLARE_MSM_GPIO_PINS(122);
+DECLARE_MSM_GPIO_PINS(123);
+DECLARE_MSM_GPIO_PINS(124);
+DECLARE_MSM_GPIO_PINS(125);
+DECLARE_MSM_GPIO_PINS(126);
+DECLARE_MSM_GPIO_PINS(127);
+DECLARE_MSM_GPIO_PINS(128);
+DECLARE_MSM_GPIO_PINS(129);
+DECLARE_MSM_GPIO_PINS(130);
+DECLARE_MSM_GPIO_PINS(131);
+DECLARE_MSM_GPIO_PINS(132);
+DECLARE_MSM_GPIO_PINS(133);
+DECLARE_MSM_GPIO_PINS(134);
+DECLARE_MSM_GPIO_PINS(135);
+DECLARE_MSM_GPIO_PINS(136);
+DECLARE_MSM_GPIO_PINS(137);
+DECLARE_MSM_GPIO_PINS(138);
+DECLARE_MSM_GPIO_PINS(139);
+DECLARE_MSM_GPIO_PINS(140);
+DECLARE_MSM_GPIO_PINS(141);
+DECLARE_MSM_GPIO_PINS(142);
+DECLARE_MSM_GPIO_PINS(143);
+DECLARE_MSM_GPIO_PINS(144);
+DECLARE_MSM_GPIO_PINS(145);
+DECLARE_MSM_GPIO_PINS(146);
+DECLARE_MSM_GPIO_PINS(147);
+DECLARE_MSM_GPIO_PINS(148);
+DECLARE_MSM_GPIO_PINS(149);
+
+static const unsigned int sdc2_clk_pins[] = { 150 };
+static const unsigned int sdc2_cmd_pins[] = { 151 };
+static const unsigned int sdc2_data_pins[] = { 152 };
+static const unsigned int ufs_reset_pins[] = { 153 };
+
+enum sdm845_functions {
+	msm_mux_ddr_pxi3,
+	msm_mux_cam_mclk,
+	msm_mux_pll_bypassnl,
+	msm_mux_qdss_gpio0,
+	msm_mux_pll_reset,
+	msm_mux_qdss_gpio1,
+	msm_mux_qdss_gpio2,
+	msm_mux_qdss_gpio3,
+	msm_mux_cci_i2c,
+	msm_mux_qup1,
+	msm_mux_qdss_gpio4,
+	msm_mux_qdss_gpio5,
+	msm_mux_qdss_gpio6,
+	msm_mux_qdss_gpio7,
+	msm_mux_cci_timer0,
+	msm_mux_gcc_gp2,
+	msm_mux_qdss_gpio8,
+	msm_mux_cci_timer1,
+	msm_mux_gcc_gp3,
+	msm_mux_qdss_gpio,
+	msm_mux_cci_timer2,
+	msm_mux_qdss_gpio9,
+	msm_mux_cci_timer3,
+	msm_mux_cci_async,
+	msm_mux_qdss_gpio10,
+	msm_mux_cci_timer4,
+	msm_mux_qdss_gpio11,
+	msm_mux_qdss_gpio12,
+	msm_mux_qup2,
+	msm_mux_qdss_gpio13,
+	msm_mux_qdss_gpio14,
+	msm_mux_phase_flag1,
+	msm_mux_qdss_gpio15,
+	msm_mux_phase_flag2,
+	msm_mux_qup11,
+	msm_mux_qup14,
+	msm_mux_pci_e0,
+	msm_mux_jitter_bist,
+	msm_mux_pll_bist,
+	msm_mux_atest_tsens,
+	msm_mux_agera_pll,
+	msm_mux_usb_phy,
+	msm_mux_lpass_slimbus,
+	msm_mux_sd_write,
+	msm_mux_tsif1_error,
+	msm_mux_qup3,
+	msm_mux_qup6,
+	msm_mux_qup12,
+	msm_mux_phase_flag16,
+	msm_mux_qup10,
+	msm_mux_phase_flag11,
+	msm_mux_phase_flag12,
+	msm_mux_phase_flag13,
+	msm_mux_phase_flag17,
+	msm_mux_qua_mi2s,
+	msm_mux_gcc_gp1,
+	msm_mux_phase_flag18,
+	msm_mux_phase_flag19,
+	msm_mux_phase_flag20,
+	msm_mux_cri_trng0,
+	msm_mux_phase_flag21,
+	msm_mux_cri_trng1,
+	msm_mux_phase_flag22,
+	msm_mux_cri_trng,
+	msm_mux_phase_flag23,
+	msm_mux_phase_flag24,
+	msm_mux_pri_mi2s,
+	msm_mux_sp_cmu,
+	msm_mux_phase_flag25,
+	msm_mux_qup8,
+	msm_mux_pri_mi2s_ws,
+	msm_mux_spkr_i2s,
+	msm_mux_audio_ref,
+	msm_mux_tsense_pwm1,
+	msm_mux_tsense_pwm2,
+	msm_mux_btfm_slimbus,
+	msm_mux_atest_usb2,
+	msm_mux_ter_mi2s,
+	msm_mux_phase_flag7,
+	msm_mux_atest_usb23,
+	msm_mux_phase_flag8,
+	msm_mux_atest_usb22,
+	msm_mux_phase_flag9,
+	msm_mux_atest_usb21,
+	msm_mux_phase_flag4,
+	msm_mux_atest_usb20,
+	msm_mux_sec_mi2s,
+	msm_mux_qup15,
+	msm_mux_qup5,
+	msm_mux_tsif1_clk,
+	msm_mux_qup4,
+	msm_mux_qspi_cs,
+	msm_mux_tgu_ch3,
+	msm_mux_phase_flag10,
+	msm_mux_tsif1_en,
+	msm_mux_mdp_vsync0,
+	msm_mux_mdp_vsync1,
+	msm_mux_mdp_vsync2,
+	msm_mux_mdp_vsync3,
+	msm_mux_tgu_ch0,
+	msm_mux_phase_flag0,
+	msm_mux_tsif1_data,
+	msm_mux_sdc4_cmd,
+	msm_mux_qspi0,
+	msm_mux_tgu_ch1,
+	msm_mux_tsif2_error,
+	msm_mux_sdc43,
+	msm_mux_qspi1,
+	msm_mux_vfr_1,
+	msm_mux_tgu_ch2,
+	msm_mux_tsif2_clk,
+	msm_mux_sdc4_clk,
+	msm_mux_qup7,
+	msm_mux_qspi2,
+	msm_mux_tsif2_en,
+	msm_mux_sdc42,
+	msm_mux_qspi3,
+	msm_mux_tsif2_data,
+	msm_mux_sdc41,
+	msm_mux_qspi_clk,
+	msm_mux_tsif2_sync,
+	msm_mux_sdc40,
+	msm_mux_phase_flag3,
+	msm_mux_ldo_en,
+	msm_mux_ldo_update,
+	msm_mux_phase_flag14,
+	msm_mux_phase_flag15,
+	msm_mux_pci_e1,
+	msm_mux_prng_rosc,
+	msm_mux_phase_flag5,
+	msm_mux_uim2_data,
+	msm_mux_qup13,
+	msm_mux_uim2_clk,
+	msm_mux_uim2_reset,
+	msm_mux_uim2_present,
+	msm_mux_uim1_data,
+	msm_mux_uim1_clk,
+	msm_mux_uim1_reset,
+	msm_mux_uim1_present,
+	msm_mux_uim_batt,
+	msm_mux_edp_hot,
+	msm_mux_nav_pps,
+	msm_mux_atest_char,
+	msm_mux_adsp_ext,
+	msm_mux_atest_char3,
+	msm_mux_atest_char2,
+	msm_mux_atest_char1,
+	msm_mux_atest_char0,
+	msm_mux_qlink_request,
+	msm_mux_qlink_enable,
+	msm_mux_pa_indicator,
+	msm_mux_phase_flag26,
+	msm_mux_phase_flag27,
+	msm_mux_phase_flag28,
+	msm_mux_phase_flag6,
+	msm_mux_phase_flag29,
+	msm_mux_phase_flag30,
+	msm_mux_phase_flag31,
+	msm_mux_mss_lte,
+	msm_mux_qup0,
+	msm_mux_gpio,
+	msm_mux_qup9,
+	msm_mux_qdss_cti,
+	msm_mux_ddr_pxi0,
+	msm_mux_ddr_bist,
+	msm_mux_atest_tsens2,
+	msm_mux_vsense_trigger,
+	msm_mux_atest_usb1,
+	msm_mux_qup_l4,
+	msm_mux_wlan1_adc1,
+	msm_mux_atest_usb13,
+	msm_mux_ddr_pxi1,
+	msm_mux_qup_l5,
+	msm_mux_wlan1_adc0,
+	msm_mux_atest_usb12,
+	msm_mux_mdp_vsync,
+	msm_mux_qup_l6,
+	msm_mux_wlan2_adc1,
+	msm_mux_atest_usb11,
+	msm_mux_ddr_pxi2,
+	msm_mux_edp_lcd,
+	msm_mux_dbg_out,
+	msm_mux_wlan2_adc0,
+	msm_mux_atest_usb10,
+	msm_mux_m_voc,
+	msm_mux_tsif1_sync,
+	msm_mux_NA,
+};
+
+static const char * const ddr_pxi3_groups[] = {
+	"gpio12", "gpio13",
+};
+static const char * const cam_mclk_groups[] = {
+	"gpio13", "gpio14", "gpio15", "gpio16",
+};
+static const char * const pll_bypassnl_groups[] = {
+	"gpio13",
+};
+static const char * const qdss_gpio0_groups[] = {
+	"gpio13", "gpio117",
+};
+static const char * const pll_reset_groups[] = {
+	"gpio14",
+};
+static const char * const qdss_gpio1_groups[] = {
+	"gpio14", "gpio118",
+};
+static const char * const qdss_gpio2_groups[] = {
+	"gpio15", "gpio119",
+};
+static const char * const qdss_gpio3_groups[] = {
+	"gpio16", "gpio120",
+};
+static const char * const cci_i2c_groups[] = {
+	"gpio17", "gpio18", "gpio19", "gpio20",
+};
+static const char * const qup1_groups[] = {
+	"gpio17", "gpio18", "gpio19", "gpio20",
+};
+static const char * const qdss_gpio4_groups[] = {
+	"gpio17", "gpio121",
+};
+static const char * const qdss_gpio5_groups[] = {
+	"gpio18", "gpio122",
+};
+static const char * const qdss_gpio6_groups[] = {
+	"gpio19", "gpio41",
+};
+static const char * const qdss_gpio7_groups[] = {
+	"gpio20", "gpio42",
+};
+static const char * const cci_timer0_groups[] = {
+	"gpio21",
+};
+static const char * const gcc_gp2_groups[] = {
+	"gpio21", "gpio58",
+};
+static const char * const qdss_gpio8_groups[] = {
+	"gpio21", "gpio75",
+};
+static const char * const cci_timer1_groups[] = {
+	"gpio22",
+};
+static const char * const gcc_gp3_groups[] = {
+	"gpio22", "gpio59",
+};
+static const char * const qdss_gpio_groups[] = {
+	"gpio22", "gpio30", "gpio123", "gpio124",
+};
+static const char * const cci_timer2_groups[] = {
+	"gpio23",
+};
+static const char * const qdss_gpio9_groups[] = {
+	"gpio23", "gpio76",
+};
+static const char * const cci_timer3_groups[] = {
+	"gpio24",
+};
+static const char * const cci_async_groups[] = {
+	"gpio24", "gpio25", "gpio26",
+};
+static const char * const qdss_gpio10_groups[] = {
+	"gpio24", "gpio77",
+};
+static const char * const cci_timer4_groups[] = {
+	"gpio25",
+};
+static const char * const qdss_gpio11_groups[] = {
+	"gpio25", "gpio79",
+};
+static const char * const qdss_gpio12_groups[] = {
+	"gpio26", "gpio80",
+};
+static const char * const qup2_groups[] = {
+	"gpio27", "gpio28", "gpio29", "gpio30",
+};
+static const char * const qdss_gpio13_groups[] = {
+	"gpio27", "gpio93",
+};
+static const char * const qdss_gpio14_groups[] = {
+	"gpio28", "gpio43",
+};
+static const char * const phase_flag1_groups[] = {
+	"gpio29",
+};
+static const char * const qdss_gpio15_groups[] = {
+	"gpio29", "gpio44",
+};
+static const char * const phase_flag2_groups[] = {
+	"gpio30",
+};
+static const char * const qup11_groups[] = {
+	"gpio31", "gpio32", "gpio33", "gpio34",
+};
+static const char * const qup14_groups[] = {
+	"gpio31", "gpio32", "gpio33", "gpio34",
+};
+static const char * const pci_e0_groups[] = {
+	"gpio35", "gpio36",
+};
+static const char * const jitter_bist_groups[] = {
+	"gpio35",
+};
+static const char * const pll_bist_groups[] = {
+	"gpio36",
+};
+static const char * const atest_tsens_groups[] = {
+	"gpio36",
+};
+static const char * const agera_pll_groups[] = {
+	"gpio37",
+};
+static const char * const usb_phy_groups[] = {
+	"gpio38",
+};
+static const char * const lpass_slimbus_groups[] = {
+	"gpio39", "gpio70", "gpio71", "gpio72",
+};
+static const char * const sd_write_groups[] = {
+	"gpio40",
+};
+static const char * const tsif1_error_groups[] = {
+	"gpio40",
+};
+static const char * const qup3_groups[] = {
+	"gpio41", "gpio42", "gpio43", "gpio44",
+};
+static const char * const qup6_groups[] = {
+	"gpio45", "gpio46", "gpio47", "gpio48",
+};
+static const char * const qup12_groups[] = {
+	"gpio49", "gpio50", "gpio51", "gpio52",
+};
+static const char * const phase_flag16_groups[] = {
+	"gpio52",
+};
+static const char * const qup10_groups[] = {
+	"gpio53", "gpio54", "gpio55", "gpio56",
+};
+static const char * const phase_flag11_groups[] = {
+	"gpio53",
+};
+static const char * const phase_flag12_groups[] = {
+	"gpio54",
+};
+static const char * const phase_flag13_groups[] = {
+	"gpio55",
+};
+static const char * const phase_flag17_groups[] = {
+	"gpio56",
+};
+static const char * const qua_mi2s_groups[] = {
+	"gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
+};
+static const char * const gcc_gp1_groups[] = {
+	"gpio57", "gpio78",
+};
+static const char * const phase_flag18_groups[] = {
+	"gpio57",
+};
+static const char * const phase_flag19_groups[] = {
+	"gpio58",
+};
+static const char * const phase_flag20_groups[] = {
+	"gpio59",
+};
+static const char * const cri_trng0_groups[] = {
+	"gpio60",
+};
+static const char * const phase_flag21_groups[] = {
+	"gpio60",
+};
+static const char * const cri_trng1_groups[] = {
+	"gpio61",
+};
+static const char * const phase_flag22_groups[] = {
+	"gpio61",
+};
+static const char * const cri_trng_groups[] = {
+	"gpio62",
+};
+static const char * const phase_flag23_groups[] = {
+	"gpio62",
+};
+static const char * const phase_flag24_groups[] = {
+	"gpio63",
+};
+static const char * const pri_mi2s_groups[] = {
+	"gpio64", "gpio65", "gpio67", "gpio68",
+};
+static const char * const sp_cmu_groups[] = {
+	"gpio64",
+};
+static const char * const phase_flag25_groups[] = {
+	"gpio64",
+};
+static const char * const qup8_groups[] = {
+	"gpio65", "gpio66", "gpio67", "gpio68",
+};
+static const char * const pri_mi2s_ws_groups[] = {
+	"gpio66",
+};
+static const char * const spkr_i2s_groups[] = {
+	"gpio69", "gpio70", "gpio71", "gpio72",
+};
+static const char * const audio_ref_groups[] = {
+	"gpio69",
+};
+static const char * const tsense_pwm1_groups[] = {
+	"gpio71",
+};
+static const char * const tsense_pwm2_groups[] = {
+	"gpio71",
+};
+static const char * const btfm_slimbus_groups[] = {
+	"gpio73", "gpio74",
+};
+static const char * const atest_usb2_groups[] = {
+	"gpio73",
+};
+static const char * const ter_mi2s_groups[] = {
+	"gpio74", "gpio75", "gpio76", "gpio77", "gpio78",
+};
+static const char * const phase_flag7_groups[] = {
+	"gpio74",
+};
+static const char * const atest_usb23_groups[] = {
+	"gpio74",
+};
+static const char * const phase_flag8_groups[] = {
+	"gpio75",
+};
+static const char * const atest_usb22_groups[] = {
+	"gpio75",
+};
+static const char * const phase_flag9_groups[] = {
+	"gpio76",
+};
+static const char * const atest_usb21_groups[] = {
+	"gpio76",
+};
+static const char * const phase_flag4_groups[] = {
+	"gpio77",
+};
+static const char * const atest_usb20_groups[] = {
+	"gpio77",
+};
+static const char * const sec_mi2s_groups[] = {
+	"gpio79", "gpio80", "gpio81", "gpio82", "gpio83",
+};
+static const char * const qup15_groups[] = {
+	"gpio81", "gpio82", "gpio83", "gpio84",
+};
+static const char * const qup5_groups[] = {
+	"gpio85", "gpio86", "gpio87", "gpio88",
+};
+static const char * const tsif1_clk_groups[] = {
+	"gpio89",
+};
+static const char * const qup4_groups[] = {
+	"gpio89", "gpio90", "gpio91", "gpio92",
+};
+static const char * const qspi_cs_groups[] = {
+	"gpio89", "gpio90",
+};
+static const char * const tgu_ch3_groups[] = {
+	"gpio89",
+};
+static const char * const phase_flag10_groups[] = {
+	"gpio89",
+};
+static const char * const tsif1_en_groups[] = {
+	"gpio90",
+};
+static const char * const mdp_vsync0_groups[] = {
+	"gpio90",
+};
+static const char * const mdp_vsync1_groups[] = {
+	"gpio90",
+};
+static const char * const mdp_vsync2_groups[] = {
+	"gpio90",
+};
+static const char * const mdp_vsync3_groups[] = {
+	"gpio90",
+};
+static const char * const tgu_ch0_groups[] = {
+	"gpio90",
+};
+static const char * const phase_flag0_groups[] = {
+	"gpio90",
+};
+static const char * const tsif1_data_groups[] = {
+	"gpio91",
+};
+static const char * const sdc4_cmd_groups[] = {
+	"gpio91",
+};
+static const char * const qspi0_groups[] = {
+	"gpio91",
+};
+static const char * const tgu_ch1_groups[] = {
+	"gpio91",
+};
+static const char * const tsif2_error_groups[] = {
+	"gpio92",
+};
+static const char * const sdc43_groups[] = {
+	"gpio92",
+};
+static const char * const qspi1_groups[] = {
+	"gpio92",
+};
+static const char * const vfr_1_groups[] = {
+	"gpio92",
+};
+static const char * const tgu_ch2_groups[] = {
+	"gpio92",
+};
+static const char * const tsif2_clk_groups[] = {
+	"gpio93",
+};
+static const char * const sdc4_clk_groups[] = {
+	"gpio93",
+};
+static const char * const qup7_groups[] = {
+	"gpio93", "gpio94", "gpio95", "gpio96",
+};
+static const char * const qspi2_groups[] = {
+	"gpio93",
+};
+static const char * const tsif2_en_groups[] = {
+	"gpio94",
+};
+static const char * const sdc42_groups[] = {
+	"gpio94",
+};
+static const char * const qspi3_groups[] = {
+	"gpio94",
+};
+static const char * const tsif2_data_groups[] = {
+	"gpio95",
+};
+static const char * const sdc41_groups[] = {
+	"gpio95",
+};
+static const char * const qspi_clk_groups[] = {
+	"gpio95",
+};
+static const char * const tsif2_sync_groups[] = {
+	"gpio96",
+};
+static const char * const sdc40_groups[] = {
+	"gpio96",
+};
+static const char * const phase_flag3_groups[] = {
+	"gpio96",
+};
+static const char * const ldo_en_groups[] = {
+	"gpio97",
+};
+static const char * const ldo_update_groups[] = {
+	"gpio98",
+};
+static const char * const phase_flag14_groups[] = {
+	"gpio99",
+};
+static const char * const phase_flag15_groups[] = {
+	"gpio100",
+};
+static const char * const pci_e1_groups[] = {
+	"gpio102", "gpio103",
+};
+static const char * const prng_rosc_groups[] = {
+	"gpio102",
+};
+static const char * const phase_flag5_groups[] = {
+	"gpio103",
+};
+static const char * const uim2_data_groups[] = {
+	"gpio105",
+};
+static const char * const qup13_groups[] = {
+	"gpio105", "gpio106", "gpio107", "gpio108",
+};
+static const char * const uim2_clk_groups[] = {
+	"gpio106",
+};
+static const char * const uim2_reset_groups[] = {
+	"gpio107",
+};
+static const char * const uim2_present_groups[] = {
+	"gpio108",
+};
+static const char * const uim1_data_groups[] = {
+	"gpio109",
+};
+static const char * const uim1_clk_groups[] = {
+	"gpio110",
+};
+static const char * const uim1_reset_groups[] = {
+	"gpio111",
+};
+static const char * const uim1_present_groups[] = {
+	"gpio112",
+};
+static const char * const uim_batt_groups[] = {
+	"gpio113",
+};
+static const char * const edp_hot_groups[] = {
+	"gpio113",
+};
+static const char * const nav_pps_groups[] = {
+	"gpio114", "gpio114", "gpio115", "gpio115", "gpio128", "gpio128",
+	"gpio129", "gpio129", "gpio143", "gpio143",
+};
+static const char * const atest_char_groups[] = {
+	"gpio117",
+};
+static const char * const adsp_ext_groups[] = {
+	"gpio118",
+};
+static const char * const atest_char3_groups[] = {
+	"gpio118",
+};
+static const char * const atest_char2_groups[] = {
+	"gpio119",
+};
+static const char * const atest_char1_groups[] = {
+	"gpio120",
+};
+static const char * const atest_char0_groups[] = {
+	"gpio121",
+};
+static const char * const qlink_request_groups[] = {
+	"gpio130",
+};
+static const char * const qlink_enable_groups[] = {
+	"gpio131",
+};
+static const char * const pa_indicator_groups[] = {
+	"gpio135",
+};
+static const char * const phase_flag26_groups[] = {
+	"gpio137",
+};
+static const char * const phase_flag27_groups[] = {
+	"gpio138",
+};
+static const char * const phase_flag28_groups[] = {
+	"gpio139",
+};
+static const char * const phase_flag6_groups[] = {
+	"gpio140",
+};
+static const char * const phase_flag29_groups[] = {
+	"gpio141",
+};
+static const char * const phase_flag30_groups[] = {
+	"gpio142",
+};
+static const char * const phase_flag31_groups[] = {
+	"gpio143",
+};
+static const char * const mss_lte_groups[] = {
+	"gpio144", "gpio145",
+};
+static const char * const qup0_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3",
+};
+static const char * const gpio_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
+	"gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
+	"gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
+	"gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
+	"gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35",
+	"gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42",
+	"gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49",
+	"gpio50", "gpio51", "gpio52", "gpio53", "gpio54", "gpio55", "gpio56",
+	"gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
+	"gpio64", "gpio65", "gpio66", "gpio67", "gpio68", "gpio69", "gpio70",
+	"gpio71", "gpio72", "gpio73", "gpio74", "gpio75", "gpio76", "gpio77",
+	"gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
+	"gpio85", "gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91",
+	"gpio92", "gpio93", "gpio94", "gpio95", "gpio96", "gpio97", "gpio98",
+	"gpio99", "gpio100", "gpio101", "gpio102", "gpio103", "gpio104",
+	"gpio105", "gpio106", "gpio107", "gpio108", "gpio109", "gpio110",
+	"gpio111", "gpio112", "gpio113", "gpio114", "gpio115", "gpio116",
+	"gpio117", "gpio118", "gpio119", "gpio120", "gpio121", "gpio122",
+	"gpio123", "gpio124", "gpio125", "gpio126", "gpio127", "gpio128",
+	"gpio129", "gpio130", "gpio131", "gpio132", "gpio133", "gpio134",
+	"gpio135", "gpio136", "gpio137", "gpio138", "gpio139", "gpio140",
+	"gpio141", "gpio142", "gpio143", "gpio144", "gpio145", "gpio146",
+	"gpio147", "gpio148", "gpio149",
+};
+static const char * const qup9_groups[] = {
+	"gpio4", "gpio5", "gpio6", "gpio7",
+};
+static const char * const qdss_cti_groups[] = {
+	"gpio4", "gpio5", "gpio51", "gpio52", "gpio62", "gpio63", "gpio90",
+	"gpio91",
+};
+static const char * const ddr_pxi0_groups[] = {
+	"gpio6", "gpio7",
+};
+static const char * const ddr_bist_groups[] = {
+	"gpio7", "gpio8", "gpio9", "gpio10",
+};
+static const char * const atest_tsens2_groups[] = {
+	"gpio7",
+};
+static const char * const vsense_trigger_groups[] = {
+	"gpio7",
+};
+static const char * const atest_usb1_groups[] = {
+	"gpio7",
+};
+static const char * const qup_l4_groups[] = {
+	"gpio8", "gpio35", "gpio105", "gpio123",
+};
+static const char * const wlan1_adc1_groups[] = {
+	"gpio8",
+};
+static const char * const atest_usb13_groups[] = {
+	"gpio8",
+};
+static const char * const ddr_pxi1_groups[] = {
+	"gpio8", "gpio9",
+};
+static const char * const qup_l5_groups[] = {
+	"gpio9", "gpio36", "gpio106", "gpio124",
+};
+static const char * const wlan1_adc0_groups[] = {
+	"gpio9",
+};
+static const char * const atest_usb12_groups[] = {
+	"gpio9",
+};
+static const char * const mdp_vsync_groups[] = {
+	"gpio10", "gpio11", "gpio12", "gpio97", "gpio98",
+};
+static const char * const qup_l6_groups[] = {
+	"gpio10", "gpio37", "gpio107", "gpio125",
+};
+static const char * const wlan2_adc1_groups[] = {
+	"gpio10",
+};
+static const char * const atest_usb11_groups[] = {
+	"gpio10",
+};
+static const char * const ddr_pxi2_groups[] = {
+	"gpio10", "gpio11",
+};
+static const char * const edp_lcd_groups[] = {
+	"gpio11",
+};
+static const char * const dbg_out_groups[] = {
+	"gpio11",
+};
+static const char * const wlan2_adc0_groups[] = {
+	"gpio11",
+};
+static const char * const atest_usb10_groups[] = {
+	"gpio11",
+};
+static const char * const m_voc_groups[] = {
+	"gpio12",
+};
+static const char * const tsif1_sync_groups[] = {
+	"gpio12",
+};
+
+static const struct msm_function sdm845_functions[] = {
+	FUNCTION(ddr_pxi3),
+	FUNCTION(cam_mclk),
+	FUNCTION(pll_bypassnl),
+	FUNCTION(qdss_gpio0),
+	FUNCTION(pll_reset),
+	FUNCTION(qdss_gpio1),
+	FUNCTION(qdss_gpio2),
+	FUNCTION(qdss_gpio3),
+	FUNCTION(cci_i2c),
+	FUNCTION(qup1),
+	FUNCTION(qdss_gpio4),
+	FUNCTION(qdss_gpio5),
+	FUNCTION(qdss_gpio6),
+	FUNCTION(qdss_gpio7),
+	FUNCTION(cci_timer0),
+	FUNCTION(gcc_gp2),
+	FUNCTION(qdss_gpio8),
+	FUNCTION(cci_timer1),
+	FUNCTION(gcc_gp3),
+	FUNCTION(qdss_gpio),
+	FUNCTION(cci_timer2),
+	FUNCTION(qdss_gpio9),
+	FUNCTION(cci_timer3),
+	FUNCTION(cci_async),
+	FUNCTION(qdss_gpio10),
+	FUNCTION(cci_timer4),
+	FUNCTION(qdss_gpio11),
+	FUNCTION(qdss_gpio12),
+	FUNCTION(qup2),
+	FUNCTION(qdss_gpio13),
+	FUNCTION(qdss_gpio14),
+	FUNCTION(phase_flag1),
+	FUNCTION(qdss_gpio15),
+	FUNCTION(phase_flag2),
+	FUNCTION(qup11),
+	FUNCTION(qup14),
+	FUNCTION(pci_e0),
+	FUNCTION(jitter_bist),
+	FUNCTION(pll_bist),
+	FUNCTION(atest_tsens),
+	FUNCTION(agera_pll),
+	FUNCTION(usb_phy),
+	FUNCTION(lpass_slimbus),
+	FUNCTION(sd_write),
+	FUNCTION(tsif1_error),
+	FUNCTION(qup3),
+	FUNCTION(qup6),
+	FUNCTION(qup12),
+	FUNCTION(phase_flag16),
+	FUNCTION(qup10),
+	FUNCTION(phase_flag11),
+	FUNCTION(phase_flag12),
+	FUNCTION(phase_flag13),
+	FUNCTION(phase_flag17),
+	FUNCTION(qua_mi2s),
+	FUNCTION(gcc_gp1),
+	FUNCTION(phase_flag18),
+	FUNCTION(phase_flag19),
+	FUNCTION(phase_flag20),
+	FUNCTION(cri_trng0),
+	FUNCTION(phase_flag21),
+	FUNCTION(cri_trng1),
+	FUNCTION(phase_flag22),
+	FUNCTION(cri_trng),
+	FUNCTION(phase_flag23),
+	FUNCTION(phase_flag24),
+	FUNCTION(pri_mi2s),
+	FUNCTION(sp_cmu),
+	FUNCTION(phase_flag25),
+	FUNCTION(qup8),
+	FUNCTION(pri_mi2s_ws),
+	FUNCTION(spkr_i2s),
+	FUNCTION(audio_ref),
+	FUNCTION(tsense_pwm1),
+	FUNCTION(tsense_pwm2),
+	FUNCTION(btfm_slimbus),
+	FUNCTION(atest_usb2),
+	FUNCTION(ter_mi2s),
+	FUNCTION(phase_flag7),
+	FUNCTION(atest_usb23),
+	FUNCTION(phase_flag8),
+	FUNCTION(atest_usb22),
+	FUNCTION(phase_flag9),
+	FUNCTION(atest_usb21),
+	FUNCTION(phase_flag4),
+	FUNCTION(atest_usb20),
+	FUNCTION(sec_mi2s),
+	FUNCTION(qup15),
+	FUNCTION(qup5),
+	FUNCTION(tsif1_clk),
+	FUNCTION(qup4),
+	FUNCTION(qspi_cs),
+	FUNCTION(tgu_ch3),
+	FUNCTION(phase_flag10),
+	FUNCTION(tsif1_en),
+	FUNCTION(mdp_vsync0),
+	FUNCTION(mdp_vsync1),
+	FUNCTION(mdp_vsync2),
+	FUNCTION(mdp_vsync3),
+	FUNCTION(tgu_ch0),
+	FUNCTION(phase_flag0),
+	FUNCTION(tsif1_data),
+	FUNCTION(sdc4_cmd),
+	FUNCTION(qspi0),
+	FUNCTION(tgu_ch1),
+	FUNCTION(tsif2_error),
+	FUNCTION(sdc43),
+	FUNCTION(qspi1),
+	FUNCTION(vfr_1),
+	FUNCTION(tgu_ch2),
+	FUNCTION(tsif2_clk),
+	FUNCTION(sdc4_clk),
+	FUNCTION(qup7),
+	FUNCTION(qspi2),
+	FUNCTION(tsif2_en),
+	FUNCTION(sdc42),
+	FUNCTION(qspi3),
+	FUNCTION(tsif2_data),
+	FUNCTION(sdc41),
+	FUNCTION(qspi_clk),
+	FUNCTION(tsif2_sync),
+	FUNCTION(sdc40),
+	FUNCTION(phase_flag3),
+	FUNCTION(ldo_en),
+	FUNCTION(ldo_update),
+	FUNCTION(phase_flag14),
+	FUNCTION(phase_flag15),
+	FUNCTION(pci_e1),
+	FUNCTION(prng_rosc),
+	FUNCTION(phase_flag5),
+	FUNCTION(uim2_data),
+	FUNCTION(qup13),
+	FUNCTION(uim2_clk),
+	FUNCTION(uim2_reset),
+	FUNCTION(uim2_present),
+	FUNCTION(uim1_data),
+	FUNCTION(uim1_clk),
+	FUNCTION(uim1_reset),
+	FUNCTION(uim1_present),
+	FUNCTION(uim_batt),
+	FUNCTION(edp_hot),
+	FUNCTION(nav_pps),
+	FUNCTION(atest_char),
+	FUNCTION(adsp_ext),
+	FUNCTION(atest_char3),
+	FUNCTION(atest_char2),
+	FUNCTION(atest_char1),
+	FUNCTION(atest_char0),
+	FUNCTION(qlink_request),
+	FUNCTION(qlink_enable),
+	FUNCTION(pa_indicator),
+	FUNCTION(phase_flag26),
+	FUNCTION(phase_flag27),
+	FUNCTION(phase_flag28),
+	FUNCTION(phase_flag6),
+	FUNCTION(phase_flag29),
+	FUNCTION(phase_flag30),
+	FUNCTION(phase_flag31),
+	FUNCTION(mss_lte),
+	FUNCTION(qup0),
+	FUNCTION(gpio),
+	FUNCTION(qup9),
+	FUNCTION(qdss_cti),
+	FUNCTION(ddr_pxi0),
+	FUNCTION(ddr_bist),
+	FUNCTION(atest_tsens2),
+	FUNCTION(vsense_trigger),
+	FUNCTION(atest_usb1),
+	FUNCTION(qup_l4),
+	FUNCTION(wlan1_adc1),
+	FUNCTION(atest_usb13),
+	FUNCTION(ddr_pxi1),
+	FUNCTION(qup_l5),
+	FUNCTION(wlan1_adc0),
+	FUNCTION(atest_usb12),
+	FUNCTION(mdp_vsync),
+	FUNCTION(qup_l6),
+	FUNCTION(wlan2_adc1),
+	FUNCTION(atest_usb11),
+	FUNCTION(ddr_pxi2),
+	FUNCTION(edp_lcd),
+	FUNCTION(dbg_out),
+	FUNCTION(wlan2_adc0),
+	FUNCTION(atest_usb10),
+	FUNCTION(m_voc),
+	FUNCTION(tsif1_sync),
+};
+
+/* Every pin is maintained as a single group, and missing or non-existing pin
+ * would be maintained as dummy group to synchronize pin group index with
+ * pin descriptor registered with pinctrl core.
+ * Clients would not be able to request these dummy pin groups.
+ */
+static const struct msm_pingroup sdm845_groups[] = {
+	[0] = PINGROUP(0, EAST, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[1] = PINGROUP(1, EAST, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[2] = PINGROUP(2, EAST, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[3] = PINGROUP(3, EAST, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[4] = PINGROUP(4, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[5] = PINGROUP(5, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[6] = PINGROUP(6, NORTH, qup9, NA, ddr_pxi0, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[7] = PINGROUP(7, NORTH, qup9, ddr_bist, NA, atest_tsens2,
+		       vsense_trigger, atest_usb1, ddr_pxi0, NA, NA, NA),
+	[8] = PINGROUP(8, EAST, qup_l4, NA, ddr_bist, NA, NA, wlan1_adc1,
+		       atest_usb13, ddr_pxi1, NA, NA),
+	[9] = PINGROUP(9, EAST, qup_l5, ddr_bist, NA, wlan1_adc0, atest_usb12,
+		       ddr_pxi1, NA, NA, NA, NA),
+	[10] = PINGROUP(10, EAST, mdp_vsync, qup_l6, ddr_bist, wlan2_adc1,
+			atest_usb11, ddr_pxi2, NA, NA, NA, NA),
+	[11] = PINGROUP(11, EAST, mdp_vsync, edp_lcd, dbg_out, wlan2_adc0,
+			atest_usb10, ddr_pxi2, NA, NA, NA, NA),
+	[12] = PINGROUP(12, SOUTH, mdp_vsync, m_voc, tsif1_sync, ddr_pxi3, NA,
+			NA, NA, NA, NA, NA),
+	[13] = PINGROUP(13, SOUTH, cam_mclk, pll_bypassnl, qdss_gpio0,
+			ddr_pxi3, NA, NA, NA, NA, NA, NA),
+	[14] = PINGROUP(14, SOUTH, cam_mclk, pll_reset, qdss_gpio1, NA, NA, NA,
+			NA, NA, NA, NA),
+	[15] = PINGROUP(15, SOUTH, cam_mclk, qdss_gpio2, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[16] = PINGROUP(16, SOUTH, cam_mclk, qdss_gpio3, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[17] = PINGROUP(17, SOUTH, cci_i2c, qup1, qdss_gpio4, NA, NA, NA, NA,
+			NA, NA, NA),
+	[18] = PINGROUP(18, SOUTH, cci_i2c, qup1, NA, qdss_gpio5, NA, NA, NA,
+			NA, NA, NA),
+	[19] = PINGROUP(19, SOUTH, cci_i2c, qup1, NA, qdss_gpio6, NA, NA, NA,
+			NA, NA, NA),
+	[20] = PINGROUP(20, SOUTH, cci_i2c, qup1, NA, qdss_gpio7, NA, NA, NA,
+			NA, NA, NA),
+	[21] = PINGROUP(21, SOUTH, cci_timer0, gcc_gp2, qdss_gpio8, NA, NA, NA,
+			NA, NA, NA, NA),
+	[22] = PINGROUP(22, SOUTH, cci_timer1, gcc_gp3, qdss_gpio, NA, NA, NA,
+			NA, NA, NA, NA),
+	[23] = PINGROUP(23, SOUTH, cci_timer2, qdss_gpio9, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[24] = PINGROUP(24, SOUTH, cci_timer3, cci_async, qdss_gpio10, NA, NA,
+			NA, NA, NA, NA, NA),
+	[25] = PINGROUP(25, SOUTH, cci_timer4, cci_async, qdss_gpio11, NA, NA,
+			NA, NA, NA, NA, NA),
+	[26] = PINGROUP(26, SOUTH, cci_async, qdss_gpio12, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[27] = PINGROUP(27, EAST, qup2, qdss_gpio13, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[28] = PINGROUP(28, EAST, qup2, qdss_gpio14, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[29] = PINGROUP(29, EAST, qup2, NA, phase_flag1, qdss_gpio15, NA, NA,
+			NA, NA, NA, NA),
+	[30] = PINGROUP(30, EAST, qup2, phase_flag2, qdss_gpio, NA, NA, NA, NA,
+			NA, NA, NA),
+	[31] = PINGROUP(31, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[32] = PINGROUP(32, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[33] = PINGROUP(33, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[34] = PINGROUP(34, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[35] = PINGROUP(35, SOUTH, pci_e0, qup_l4, jitter_bist, NA, NA, NA, NA,
+			NA, NA, NA),
+	[36] = PINGROUP(36, SOUTH, pci_e0, qup_l5, pll_bist, NA, atest_tsens,
+			NA, NA, NA, NA, NA),
+	[37] = PINGROUP(37, SOUTH, qup_l6, agera_pll, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[38] = PINGROUP(38, NORTH, usb_phy, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[39] = PINGROUP(39, EAST, lpass_slimbus, NA, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[40] = PINGROUP(40, SOUTH, sd_write, tsif1_error, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[41] = PINGROUP(41, EAST, qup3, NA, qdss_gpio6, NA, NA, NA, NA, NA, NA,
+			NA),
+	[42] = PINGROUP(42, EAST, qup3, NA, qdss_gpio7, NA, NA, NA, NA, NA, NA,
+			NA),
+	[43] = PINGROUP(43, EAST, qup3, NA, qdss_gpio14, NA, NA, NA, NA, NA,
+			NA, NA),
+	[44] = PINGROUP(44, EAST, qup3, NA, qdss_gpio15, NA, NA, NA, NA, NA,
+			NA, NA),
+	[45] = PINGROUP(45, EAST, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[46] = PINGROUP(46, EAST, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[47] = PINGROUP(47, EAST, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[48] = PINGROUP(48, EAST, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[49] = PINGROUP(49, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[50] = PINGROUP(50, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[51] = PINGROUP(51, NORTH, qup12, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[52] = PINGROUP(52, NORTH, qup12, phase_flag16, qdss_cti, NA, NA, NA,
+			NA, NA, NA, NA),
+	[53] = PINGROUP(53, NORTH, qup10, phase_flag11, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[54] = PINGROUP(54, NORTH, qup10, NA, phase_flag12, NA, NA, NA, NA, NA,
+			NA, NA),
+	[55] = PINGROUP(55, NORTH, qup10, phase_flag13, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[56] = PINGROUP(56, NORTH, qup10, phase_flag17, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[57] = PINGROUP(57, NORTH, qua_mi2s, gcc_gp1, phase_flag18, NA, NA, NA,
+			NA, NA, NA, NA),
+	[58] = PINGROUP(58, NORTH, qua_mi2s, gcc_gp2, phase_flag19, NA, NA, NA,
+			NA, NA, NA, NA),
+	[59] = PINGROUP(59, NORTH, qua_mi2s, gcc_gp3, phase_flag20, NA, NA, NA,
+			NA, NA, NA, NA),
+	[60] = PINGROUP(60, NORTH, qua_mi2s, cri_trng0, phase_flag21, NA, NA,
+			NA, NA, NA, NA, NA),
+	[61] = PINGROUP(61, NORTH, qua_mi2s, cri_trng1, phase_flag22, NA, NA,
+			NA, NA, NA, NA, NA),
+	[62] = PINGROUP(62, NORTH, qua_mi2s, cri_trng, phase_flag23, qdss_cti,
+			NA, NA, NA, NA, NA, NA),
+	[63] = PINGROUP(63, NORTH, qua_mi2s, NA, phase_flag24, qdss_cti, NA,
+			NA, NA, NA, NA, NA),
+	[64] = PINGROUP(64, NORTH, pri_mi2s, sp_cmu, phase_flag25, NA, NA, NA,
+			NA, NA, NA, NA),
+	[65] = PINGROUP(65, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[66] = PINGROUP(66, NORTH, pri_mi2s_ws, qup8, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[67] = PINGROUP(67, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[68] = PINGROUP(68, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[69] = PINGROUP(69, EAST, spkr_i2s, audio_ref, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[70] = PINGROUP(70, EAST, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[71] = PINGROUP(71, EAST, lpass_slimbus, spkr_i2s, tsense_pwm1,
+			tsense_pwm2, NA, NA, NA, NA, NA, NA),
+	[72] = PINGROUP(72, EAST, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[73] = PINGROUP(73, EAST, btfm_slimbus, atest_usb2, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[74] = PINGROUP(74, EAST, btfm_slimbus, ter_mi2s, phase_flag7,
+			atest_usb23, NA, NA, NA, NA, NA, NA),
+	[75] = PINGROUP(75, EAST, ter_mi2s, phase_flag8, qdss_gpio8,
+			atest_usb22, NA, NA, NA, NA, NA, NA),
+	[76] = PINGROUP(76, EAST, ter_mi2s, phase_flag9, qdss_gpio9,
+			atest_usb21, NA, NA, NA, NA, NA, NA),
+	[77] = PINGROUP(77, EAST, ter_mi2s, phase_flag4, qdss_gpio10,
+			atest_usb20, NA, NA, NA, NA, NA, NA),
+	[78] = PINGROUP(78, EAST, ter_mi2s, gcc_gp1, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[79] = PINGROUP(79, NORTH, sec_mi2s, NA, NA, qdss_gpio11, NA, NA, NA,
+			NA, NA, NA),
+	[80] = PINGROUP(80, NORTH, sec_mi2s, NA, qdss_gpio12, NA, NA, NA, NA,
+			NA, NA, NA),
+	[81] = PINGROUP(81, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[82] = PINGROUP(82, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[83] = PINGROUP(83, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[84] = PINGROUP(84, NORTH, qup15, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[85] = PINGROUP(85, EAST, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[86] = PINGROUP(86, EAST, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[87] = PINGROUP(87, EAST, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[88] = PINGROUP(88, EAST, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[89] = PINGROUP(89, SOUTH, tsif1_clk, qup4, qspi_cs, tgu_ch3,
+			phase_flag10, NA, NA, NA, NA, NA),
+	[90] = PINGROUP(90, SOUTH, tsif1_en, mdp_vsync0, qup4, qspi_cs,
+			mdp_vsync1, mdp_vsync2, mdp_vsync3, tgu_ch0,
+			phase_flag0, qdss_cti),
+	[91] = PINGROUP(91, SOUTH, tsif1_data, sdc4_cmd, qup4, qspi0, tgu_ch1,
+			NA, qdss_cti, NA, NA, NA),
+	[92] = PINGROUP(92, SOUTH, tsif2_error, sdc43, qup4, qspi1, vfr_1,
+			tgu_ch2, NA, NA, NA, NA),
+	[93] = PINGROUP(93, SOUTH, tsif2_clk, sdc4_clk, qup7, qspi2, NA,
+			qdss_gpio13, NA, NA, NA, NA),
+	[94] = PINGROUP(94, SOUTH, tsif2_en, sdc42, qup7, qspi3, NA, NA, NA,
+			NA, NA, NA),
+	[95] = PINGROUP(95, SOUTH, tsif2_data, sdc41, qup7, qspi_clk, NA, NA,
+			NA, NA, NA, NA),
+	[96] = PINGROUP(96, SOUTH, tsif2_sync, sdc40, qup7, phase_flag3, NA,
+			NA, NA, NA, NA, NA),
+	[97] = PINGROUP(97, NORTH, NA, NA, mdp_vsync, ldo_en, NA, NA, NA, NA,
+			NA, NA),
+	[98] = PINGROUP(98, NORTH, NA, mdp_vsync, ldo_update, NA, NA, NA, NA,
+			NA, NA, NA),
+	[99] = PINGROUP(99, NORTH, phase_flag14, NA, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[100] = PINGROUP(100, NORTH, phase_flag15, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[101] = PINGROUP(101, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[102] = PINGROUP(102, NORTH, pci_e1, prng_rosc, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[103] = PINGROUP(103, NORTH, pci_e1, phase_flag5, NA, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[104] = PINGROUP(104, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[105] = PINGROUP(105, NORTH, uim2_data, qup13, qup_l4, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[106] = PINGROUP(106, NORTH, uim2_clk, qup13, qup_l5, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[107] = PINGROUP(107, NORTH, uim2_reset, qup13, qup_l6, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[108] = PINGROUP(108, NORTH, uim2_present, qup13, NA, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[109] = PINGROUP(109, NORTH, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[110] = PINGROUP(110, NORTH, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[111] = PINGROUP(111, NORTH, uim1_reset, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[112] = PINGROUP(112, NORTH, uim1_present, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[113] = PINGROUP(113, NORTH, uim_batt, edp_hot, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[114] = PINGROUP(114, NORTH, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[115] = PINGROUP(115, NORTH, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[116] = PINGROUP(116, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[117] = PINGROUP(117, NORTH, NA, qdss_gpio0, atest_char, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[118] = PINGROUP(118, NORTH, adsp_ext, NA, qdss_gpio1, atest_char3, NA,
+			 NA, NA, NA, NA, NA),
+	[119] = PINGROUP(119, NORTH, NA, qdss_gpio2, atest_char2, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[120] = PINGROUP(120, NORTH, NA, qdss_gpio3, atest_char1, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[121] = PINGROUP(121, NORTH, NA, qdss_gpio4, atest_char0, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[122] = PINGROUP(122, EAST, NA, qdss_gpio5, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[123] = PINGROUP(123, EAST, qup_l4, NA, qdss_gpio, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[124] = PINGROUP(124, EAST, qup_l5, NA, qdss_gpio, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[125] = PINGROUP(125, EAST, qup_l6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[126] = PINGROUP(126, EAST, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[127] = PINGROUP(127, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[128] = PINGROUP(128, NORTH, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[129] = PINGROUP(129, NORTH, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[130] = PINGROUP(130, NORTH, qlink_request, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[131] = PINGROUP(131, NORTH, qlink_enable, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[132] = PINGROUP(132, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[133] = PINGROUP(133, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[134] = PINGROUP(134, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[135] = PINGROUP(135, NORTH, NA, pa_indicator, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[136] = PINGROUP(136, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[137] = PINGROUP(137, NORTH, NA, NA, phase_flag26, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[138] = PINGROUP(138, NORTH, NA, NA, phase_flag27, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[139] = PINGROUP(139, NORTH, NA, phase_flag28, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[140] = PINGROUP(140, NORTH, NA, NA, phase_flag6, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[141] = PINGROUP(141, NORTH, NA, phase_flag29, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[142] = PINGROUP(142, NORTH, NA, phase_flag30, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[143] = PINGROUP(143, NORTH, NA, nav_pps, nav_pps, NA, phase_flag31,
+			 NA, NA, NA, NA, NA),
+	[144] = PINGROUP(144, NORTH, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[145] = PINGROUP(145, NORTH, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[146] = PINGROUP(146, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[147] = PINGROUP(147, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[148] = PINGROUP(148, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[149] = PINGROUP(149, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[150] = SDC_QDSD_PINGROUP(sdc2_clk, 0x99a000, 14, 6),
+	[151] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x99a000, 11, 3),
+	[152] = SDC_QDSD_PINGROUP(sdc2_data, 0x99a000, 9, 0),
+	[153] = UFS_RESET(ufs_reset, 0x99f000),
+};
+
+static const struct msm_dir_conn sdm845_dir_conn[] = {
+	{1, 510},
+	{3, 511},
+	{5, 512},
+	{10, 513},
+	{11, 514},
+	{20, 515},
+	{22, 516},
+	{24, 517},
+	{26, 518},
+	{30, 519},
+	{31, 639},
+	{32, 521},
+	{34, 522},
+	{36, 523},
+	{37, 524},
+	{38, 525},
+	{39, 526},
+	{40, 527},
+	{41, 637},
+	{43, 529},
+	{44, 530},
+	{46, 531},
+	{48, 532},
+	{49, 640},
+	{52, 534},
+	{53, 535},
+	{54, 536},
+	{56, 537},
+	{57, 538},
+	{58, 539},
+	{59, 540},
+	{60, 541},
+	{61, 542},
+	{62, 543},
+	{63, 544},
+	{64, 545},
+	{66, 546},
+	{68, 547},
+	{71, 548},
+	{73, 549},
+	{77, 550},
+	{78, 551},
+	{79, 552},
+	{80, 553},
+	{84, 554},
+	{85, 555},
+	{86, 556},
+	{88, 557},
+	{89, 638},
+	{91, 559},
+	{92, 560},
+	{95, 561},
+	{96, 562},
+	{97, 563},
+	{101, 564},
+	{103, 565},
+	{104, 566},
+	{115, 570},
+	{116, 571},
+	{117, 572},
+	{118, 573},
+	{119, 609},
+	{120, 610},
+	{121, 611},
+	{122, 612},
+	{123, 613},
+	{124, 614},
+	{125, 615},
+	{127, 617},
+	{128, 618},
+	{129, 619},
+	{130, 620},
+	{132, 621},
+	{133, 622},
+	{145, 623},
+};
+
+static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
+	.pins = sdm845_pins,
+	.npins = ARRAY_SIZE(sdm845_pins),
+	.functions = sdm845_functions,
+	.nfunctions = ARRAY_SIZE(sdm845_functions),
+	.groups = sdm845_groups,
+	.ngroups = ARRAY_SIZE(sdm845_groups),
+	.ngpios = 150,
+	.dir_conn = sdm845_dir_conn,
+	.n_dir_conns = ARRAY_SIZE(sdm845_dir_conn),
+};
+
+static int sdm845_pinctrl_probe(struct platform_device *pdev)
+{
+	return msm_pinctrl_probe(pdev, &sdm845_pinctrl);
+}
+
+static const struct of_device_id sdm845_pinctrl_of_match[] = {
+	{ .compatible = "qcom,sdm845-pinctrl-v2", },
+	{ },
+};
+
+static struct platform_driver sdm845_pinctrl_driver = {
+	.driver = {
+		.name = "sdm845-v2-pinctrl",
+		.owner = THIS_MODULE,
+		.of_match_table = sdm845_pinctrl_of_match,
+	},
+	.probe = sdm845_pinctrl_probe,
+	.remove = msm_pinctrl_remove,
+};
+
+static int __init sdm845_pinctrl_init(void)
+{
+	return platform_driver_register(&sdm845_pinctrl_driver);
+}
+arch_initcall(sdm845_pinctrl_init);
+
+static void __exit sdm845_pinctrl_exit(void)
+{
+	platform_driver_unregister(&sdm845_pinctrl_driver);
+}
+module_exit(sdm845_pinctrl_exit);
+
+MODULE_DESCRIPTION("QTI sdm845-v2 pinctrl driver");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(of, sdm845_pinctrl_of_match);
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
index 8faabb0..b7e06b6 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -25,8 +25,10 @@
 		.ngroups = ARRAY_SIZE(fname##_groups),	\
 	}
 
+#define NORTH	0x00500000
+#define SOUTH	0x00900000
 #define REG_SIZE 0x1000
-#define PINGROUP(id, f1, f2, f3, f4, f5, f6, f7, f8, f9)	\
+#define PINGROUP(id, base, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10)	\
 	{						\
 		.name = "gpio" #id,			\
 		.pins = gpio##id##_pins,		\
@@ -41,14 +43,15 @@
 			msm_mux_##f6,			\
 			msm_mux_##f7,			\
 			msm_mux_##f8,			\
-			msm_mux_##f9			\
+			msm_mux_##f9,			\
+			msm_mux_##f10			\
 		},					\
-		.nfuncs = 10,				\
-		.ctl_reg = REG_SIZE * id,		\
-		.io_reg = 0x4 + REG_SIZE * id,		\
-		.intr_cfg_reg = 0x8 + REG_SIZE * id,	\
-		.intr_status_reg = 0xc + REG_SIZE * id,	\
-		.intr_target_reg = 0x8 + REG_SIZE * id,	\
+		.nfuncs = 11,				\
+		.ctl_reg = base + REG_SIZE * id,		\
+		.io_reg = base + 0x4 + REG_SIZE * id,		\
+		.intr_cfg_reg = base + 0x8 + REG_SIZE * id,	\
+		.intr_status_reg = base + 0xc + REG_SIZE * id,	\
+		.intr_target_reg = base + 0x8 + REG_SIZE * id,	\
 		.mux_bit = 2,			\
 		.pull_bit = 0,			\
 		.drv_bit = 6,			\
@@ -114,10 +117,6 @@
 		.intr_detection_bit = -1,		\
 		.intr_detection_width = -1,		\
 	}
-
-static const u32 sdm845_tile_offsets[] = {0x500000, 0x900000, 0x100000};
-static u32 sdm845_pin_base[150];
-
 static const struct pinctrl_pin_desc sdm845_pins[] = {
 	PINCTRL_PIN(0, "GPIO_0"),
 	PINCTRL_PIN(1, "GPIO_1"),
@@ -1371,255 +1370,278 @@
  * Clients would not be able to request these dummy pin groups.
  */
 static const struct msm_pingroup sdm845_groups[] = {
-	[0] = PINGROUP(0, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[1] = PINGROUP(1, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[2] = PINGROUP(2, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[3] = PINGROUP(3, qup0, NA, NA, NA, NA, NA, NA, NA, NA),
-	[4] = PINGROUP(4, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[5] = PINGROUP(5, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[6] = PINGROUP(6, qup9, NA, ddr_pxi0, NA, NA, NA, NA, NA, NA),
-	[7] = PINGROUP(7, qup9, ddr_bist, NA, atest_tsens2,
-		       vsense_trigger, atest_usb1, ddr_pxi0, NA, NA),
-	[8] = PINGROUP(8, qup_l4, NA, ddr_bist, NA, NA, wlan1_adc1,
-		       atest_usb13, ddr_pxi1, NA),
-	[9] = PINGROUP(9, qup_l5, ddr_bist, NA, wlan1_adc0, atest_usb12,
-		       ddr_pxi1, NA, NA, NA),
-	[10] = PINGROUP(10, mdp_vsync, qup_l6, ddr_bist, wlan2_adc1,
-			atest_usb11, ddr_pxi2, NA, NA, NA),
-	[11] = PINGROUP(11, mdp_vsync, edp_lcd, dbg_out, wlan2_adc0,
-			atest_usb10, ddr_pxi2, NA, NA, NA),
-	[12] = PINGROUP(12, mdp_vsync, m_voc, tsif1_sync, ddr_pxi3, NA,
-			NA, NA, NA, NA),
-	[13] = PINGROUP(13, cam_mclk, pll_bypassnl, qdss_gpio0,
-			ddr_pxi3, NA, NA, NA, NA, NA),
-	[14] = PINGROUP(14, cam_mclk, pll_reset, qdss_gpio1, NA, NA, NA,
-			NA, NA, NA),
-	[15] = PINGROUP(15, cam_mclk, qdss_gpio2, NA, NA, NA, NA, NA,
-			NA, NA),
-	[16] = PINGROUP(16, cam_mclk, qdss_gpio3, NA, NA, NA, NA, NA,
-			NA, NA),
-	[17] = PINGROUP(17, cci_i2c, qup1, qdss_gpio4, NA, NA, NA, NA,
-			NA, NA),
-	[18] = PINGROUP(18, cci_i2c, qup1, NA, qdss_gpio5, NA, NA, NA,
-			NA, NA),
-	[19] = PINGROUP(19, cci_i2c, qup1, NA, qdss_gpio6, NA, NA, NA,
-			NA, NA),
-	[20] = PINGROUP(20, cci_i2c, qup1, NA, qdss_gpio7, NA, NA, NA,
-			NA, NA),
-	[21] = PINGROUP(21, cci_timer0, gcc_gp2, qdss_gpio8, NA, NA, NA,
-			NA, NA, NA),
-	[22] = PINGROUP(22, cci_timer1, gcc_gp3, qdss_gpio, NA, NA, NA,
-			NA, NA, NA),
-	[23] = PINGROUP(23, cci_timer2, qdss_gpio9, NA, NA, NA, NA, NA,
-			NA, NA),
-	[24] = PINGROUP(24, cci_timer3, cci_async, qdss_gpio10, NA, NA,
-			NA, NA, NA, NA),
-	[25] = PINGROUP(25, cci_timer4, cci_async, qdss_gpio11, NA, NA,
-			NA, NA, NA, NA),
-	[26] = PINGROUP(26, cci_async, qdss_gpio12, NA, NA, NA, NA, NA,
-			NA, NA),
-	[27] = PINGROUP(27, qup2, qdss_gpio13, NA, NA, NA, NA, NA, NA,
-			NA),
-	[28] = PINGROUP(28, qup2, qdss_gpio14, NA, NA, NA, NA, NA, NA,
-			NA),
-	[29] = PINGROUP(29, qup2, NA, phase_flag1, qdss_gpio15, NA, NA,
-			NA, NA, NA),
-	[30] = PINGROUP(30, qup2, phase_flag2, qdss_gpio, NA, NA, NA, NA,
-			NA, NA),
-	[31] = PINGROUP(31, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[32] = PINGROUP(32, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[33] = PINGROUP(33, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[34] = PINGROUP(34, qup11, qup14, NA, NA, NA, NA, NA, NA, NA),
-	[35] = PINGROUP(35, pci_e0, qup_l4, jitter_bist, NA, NA, NA, NA,
-			NA, NA),
-	[36] = PINGROUP(36, pci_e0, qup_l5, pll_bist, NA, atest_tsens,
-			NA, NA, NA, NA),
-	[37] = PINGROUP(37, qup_l6, agera_pll, NA, NA, NA, NA, NA, NA,
-			NA),
-	[38] = PINGROUP(38, usb_phy, NA, NA, NA, NA, NA, NA, NA, NA),
-	[39] = PINGROUP(39, lpass_slimbus, NA, NA, NA, NA, NA, NA, NA,
-			NA),
-	[40] = PINGROUP(40, sd_write, tsif1_error, NA, NA, NA, NA, NA,
-			NA, NA),
-	[41] = PINGROUP(41, qup3, NA, qdss_gpio6, NA, NA, NA, NA, NA, NA),
-	[42] = PINGROUP(42, qup3, NA, qdss_gpio7, NA, NA, NA, NA, NA, NA),
-	[43] = PINGROUP(43, qup3, NA, qdss_gpio14, NA, NA, NA, NA, NA,
-			NA),
-	[44] = PINGROUP(44, qup3, NA, qdss_gpio15, NA, NA, NA, NA, NA,
-			NA),
-	[45] = PINGROUP(45, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[46] = PINGROUP(46, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[47] = PINGROUP(47, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[48] = PINGROUP(48, qup6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[49] = PINGROUP(49, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
-	[50] = PINGROUP(50, qup12, NA, NA, NA, NA, NA, NA, NA, NA),
-	[51] = PINGROUP(51, qup12, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	[52] = PINGROUP(52, qup12, phase_flag16, qdss_cti, NA, NA, NA,
-			NA, NA, NA),
-	[53] = PINGROUP(53, qup10, phase_flag11, NA, NA, NA, NA, NA, NA,
-			NA),
-	[54] = PINGROUP(54, qup10, NA, phase_flag12, NA, NA, NA, NA, NA,
-			NA),
-	[55] = PINGROUP(55, qup10, phase_flag13, NA, NA, NA, NA, NA, NA,
-			NA),
-	[56] = PINGROUP(56, qup10, phase_flag17, NA, NA, NA, NA, NA, NA,
-			NA),
-	[57] = PINGROUP(57, qua_mi2s, gcc_gp1, phase_flag18, NA, NA, NA,
-			NA, NA, NA),
-	[58] = PINGROUP(58, qua_mi2s, gcc_gp2, phase_flag19, NA, NA, NA,
-			NA, NA, NA),
-	[59] = PINGROUP(59, qua_mi2s, gcc_gp3, phase_flag20, NA, NA, NA,
-			NA, NA, NA),
-	[60] = PINGROUP(60, qua_mi2s, cri_trng0, phase_flag21, NA, NA,
-			NA, NA, NA, NA),
-	[61] = PINGROUP(61, qua_mi2s, cri_trng1, phase_flag22, NA, NA,
-			NA, NA, NA, NA),
-	[62] = PINGROUP(62, qua_mi2s, cri_trng, phase_flag23, qdss_cti,
+	[0] = PINGROUP(0, NORTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[1] = PINGROUP(1, NORTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[2] = PINGROUP(2, NORTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[3] = PINGROUP(3, NORTH, qup0, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[4] = PINGROUP(4, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[5] = PINGROUP(5, NORTH, qup9, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[6] = PINGROUP(6, NORTH, qup9, NA, ddr_pxi0, NA, NA, NA, NA, NA, NA,
+		       NA),
+	[7] = PINGROUP(7, NORTH, qup9, ddr_bist, NA, atest_tsens2,
+		       vsense_trigger, atest_usb1, ddr_pxi0, NA, NA, NA),
+	[8] = PINGROUP(8, NORTH, qup_l4, NA, ddr_bist, NA, NA, wlan1_adc1,
+		       atest_usb13, ddr_pxi1, NA, NA),
+	[9] = PINGROUP(9, NORTH, qup_l5, ddr_bist, NA, wlan1_adc0, atest_usb12,
+		       ddr_pxi1, NA, NA, NA, NA),
+	[10] = PINGROUP(10, NORTH, mdp_vsync, qup_l6, ddr_bist, wlan2_adc1,
+			atest_usb11, ddr_pxi2, NA, NA, NA, NA),
+	[11] = PINGROUP(11, NORTH, mdp_vsync, edp_lcd, dbg_out, wlan2_adc0,
+			atest_usb10, ddr_pxi2, NA, NA, NA, NA),
+	[12] = PINGROUP(12, SOUTH, mdp_vsync, m_voc, tsif1_sync, ddr_pxi3, NA,
 			NA, NA, NA, NA, NA),
-	[63] = PINGROUP(63, qua_mi2s, NA, phase_flag24, qdss_cti, NA,
+	[13] = PINGROUP(13, SOUTH, cam_mclk, pll_bypassnl, qdss_gpio0,
+			ddr_pxi3, NA, NA, NA, NA, NA, NA),
+	[14] = PINGROUP(14, SOUTH, cam_mclk, pll_reset, qdss_gpio1, NA, NA, NA,
 			NA, NA, NA, NA),
-	[64] = PINGROUP(64, pri_mi2s, sp_cmu, phase_flag25, NA, NA, NA,
+	[15] = PINGROUP(15, SOUTH, cam_mclk, qdss_gpio2, NA, NA, NA, NA, NA,
 			NA, NA, NA),
-	[65] = PINGROUP(65, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA),
-	[66] = PINGROUP(66, pri_mi2s_ws, qup8, NA, NA, NA, NA, NA, NA,
-			NA),
-	[67] = PINGROUP(67, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA),
-	[68] = PINGROUP(68, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA),
-	[69] = PINGROUP(69, spkr_i2s, audio_ref, NA, NA, NA, NA, NA, NA,
-			NA),
-	[70] = PINGROUP(70, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
-			NA, NA),
-	[71] = PINGROUP(71, lpass_slimbus, spkr_i2s, tsense_pwm1,
-			tsense_pwm2, NA, NA, NA, NA, NA),
-	[72] = PINGROUP(72, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
-			NA, NA),
-	[73] = PINGROUP(73, btfm_slimbus, atest_usb2, NA, NA, NA, NA, NA,
-			NA, NA),
-	[74] = PINGROUP(74, btfm_slimbus, ter_mi2s, phase_flag7,
-			atest_usb23, NA, NA, NA, NA, NA),
-	[75] = PINGROUP(75, ter_mi2s, phase_flag8, qdss_gpio8,
-			atest_usb22, NA, NA, NA, NA, NA),
-	[76] = PINGROUP(76, ter_mi2s, phase_flag9, qdss_gpio9,
-			atest_usb21, NA, NA, NA, NA, NA),
-	[77] = PINGROUP(77, ter_mi2s, phase_flag4, qdss_gpio10,
-			atest_usb20, NA, NA, NA, NA, NA),
-	[78] = PINGROUP(78, ter_mi2s, gcc_gp1, NA, NA, NA, NA, NA, NA,
-			NA),
-	[79] = PINGROUP(79, sec_mi2s, NA, NA, qdss_gpio11, NA, NA, NA,
-			NA, NA),
-	[80] = PINGROUP(80, sec_mi2s, NA, qdss_gpio12, NA, NA, NA, NA,
-			NA, NA),
-	[81] = PINGROUP(81, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[82] = PINGROUP(82, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[83] = PINGROUP(83, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA),
-	[84] = PINGROUP(84, qup15, NA, NA, NA, NA, NA, NA, NA, NA),
-	[85] = PINGROUP(85, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[86] = PINGROUP(86, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[87] = PINGROUP(87, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[88] = PINGROUP(88, qup5, NA, NA, NA, NA, NA, NA, NA, NA),
-	[89] = PINGROUP(89, tsif1_clk, qup4, tgu_ch3, phase_flag10, NA,
+	[16] = PINGROUP(16, SOUTH, cam_mclk, qdss_gpio3, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[17] = PINGROUP(17, SOUTH, cci_i2c, qup1, qdss_gpio4, NA, NA, NA, NA,
+			NA, NA, NA),
+	[18] = PINGROUP(18, SOUTH, cci_i2c, qup1, NA, qdss_gpio5, NA, NA, NA,
+			NA, NA, NA),
+	[19] = PINGROUP(19, SOUTH, cci_i2c, qup1, NA, qdss_gpio6, NA, NA, NA,
+			NA, NA, NA),
+	[20] = PINGROUP(20, SOUTH, cci_i2c, qup1, NA, qdss_gpio7, NA, NA, NA,
+			NA, NA, NA),
+	[21] = PINGROUP(21, SOUTH, cci_timer0, gcc_gp2, qdss_gpio8, NA, NA, NA,
 			NA, NA, NA, NA),
-	[90] = PINGROUP(90, tsif1_en, mdp_vsync0, qup4, mdp_vsync1,
-			mdp_vsync2, mdp_vsync3, tgu_ch0, phase_flag0, qdss_cti),
-	[91] = PINGROUP(91, tsif1_data, sdc4_cmd, qup4, tgu_ch1, NA,
-			qdss_cti, NA, NA, NA),
-	[92] = PINGROUP(92, tsif2_error, sdc43, qup4, vfr_1, tgu_ch2,
+	[22] = PINGROUP(22, SOUTH, cci_timer1, gcc_gp3, qdss_gpio, NA, NA, NA,
 			NA, NA, NA, NA),
-	[93] = PINGROUP(93, tsif2_clk, sdc4_clk, qup7, NA, qdss_gpio13,
-			NA, NA, NA, NA),
-	[94] = PINGROUP(94, tsif2_en, sdc42, qup7, NA, NA, NA, NA, NA,
-			NA),
-	[95] = PINGROUP(95, tsif2_data, sdc41, qup7, NA, NA, NA, NA, NA,
-			NA),
-	[96] = PINGROUP(96, tsif2_sync, sdc40, qup7, phase_flag3, NA,
-			NA, NA, NA, NA),
-	[97] = PINGROUP(97, NA, NA, mdp_vsync, ldo_en, NA, NA, NA, NA,
-			NA),
-	[98] = PINGROUP(98, NA, mdp_vsync, ldo_update, NA, NA, NA, NA,
+	[23] = PINGROUP(23, SOUTH, cci_timer2, qdss_gpio9, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[24] = PINGROUP(24, SOUTH, cci_timer3, cci_async, qdss_gpio10, NA, NA,
+			NA, NA, NA, NA, NA),
+	[25] = PINGROUP(25, SOUTH, cci_timer4, cci_async, qdss_gpio11, NA, NA,
+			NA, NA, NA, NA, NA),
+	[26] = PINGROUP(26, SOUTH, cci_async, qdss_gpio12, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[27] = PINGROUP(27, NORTH, qup2, qdss_gpio13, NA, NA, NA, NA, NA, NA,
 			NA, NA),
-	[99] = PINGROUP(99, phase_flag14, NA, NA, NA, NA, NA, NA, NA,
+	[28] = PINGROUP(28, NORTH, qup2, qdss_gpio14, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[29] = PINGROUP(29, NORTH, qup2, NA, phase_flag1, qdss_gpio15, NA, NA,
+			NA, NA, NA, NA),
+	[30] = PINGROUP(30, NORTH, qup2, phase_flag2, qdss_gpio, NA, NA, NA,
+			NA, NA, NA, NA),
+	[31] = PINGROUP(31, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
 			NA),
-	[100] = PINGROUP(100, phase_flag15, NA, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[101] = PINGROUP(101, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[102] = PINGROUP(102, pci_e1, prng_rosc, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[103] = PINGROUP(103, pci_e1, phase_flag5, NA, NA, NA, NA, NA,
+	[32] = PINGROUP(32, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[33] = PINGROUP(33, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[34] = PINGROUP(34, NORTH, qup11, qup14, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[35] = PINGROUP(35, SOUTH, pci_e0, qup_l4, jitter_bist, NA, NA, NA, NA,
+			NA, NA, NA),
+	[36] = PINGROUP(36, SOUTH, pci_e0, qup_l5, pll_bist, NA, atest_tsens,
+			NA, NA, NA, NA, NA),
+	[37] = PINGROUP(37, SOUTH, qup_l6, agera_pll, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[38] = PINGROUP(38, NORTH, usb_phy, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[39] = PINGROUP(39, NORTH, lpass_slimbus, NA, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[40] = PINGROUP(40, SOUTH, sd_write, tsif1_error, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[41] = PINGROUP(41, SOUTH, qup3, NA, qdss_gpio6, NA, NA, NA, NA, NA,
+			NA, NA),
+	[42] = PINGROUP(42, SOUTH, qup3, NA, qdss_gpio7, NA, NA, NA, NA, NA,
+			NA, NA),
+	[43] = PINGROUP(43, SOUTH, qup3, NA, qdss_gpio14, NA, NA, NA, NA, NA,
+			NA, NA),
+	[44] = PINGROUP(44, SOUTH, qup3, NA, qdss_gpio15, NA, NA, NA, NA, NA,
+			NA, NA),
+	[45] = PINGROUP(45, NORTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[46] = PINGROUP(46, NORTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[47] = PINGROUP(47, NORTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[48] = PINGROUP(48, NORTH, qup6, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[49] = PINGROUP(49, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[50] = PINGROUP(50, NORTH, qup12, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[51] = PINGROUP(51, NORTH, qup12, qdss_cti, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[52] = PINGROUP(52, NORTH, qup12, phase_flag16, qdss_cti, NA, NA, NA,
+			NA, NA, NA, NA),
+	[53] = PINGROUP(53, NORTH, qup10, phase_flag11, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[54] = PINGROUP(54, NORTH, qup10, NA, phase_flag12, NA, NA, NA, NA, NA,
+			NA, NA),
+	[55] = PINGROUP(55, NORTH, qup10, phase_flag13, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[56] = PINGROUP(56, NORTH, qup10, phase_flag17, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[57] = PINGROUP(57, NORTH, qua_mi2s, gcc_gp1, phase_flag18, NA, NA, NA,
+			NA, NA, NA, NA),
+	[58] = PINGROUP(58, NORTH, qua_mi2s, gcc_gp2, phase_flag19, NA, NA, NA,
+			NA, NA, NA, NA),
+	[59] = PINGROUP(59, NORTH, qua_mi2s, gcc_gp3, phase_flag20, NA, NA, NA,
+			NA, NA, NA, NA),
+	[60] = PINGROUP(60, NORTH, qua_mi2s, cri_trng0, phase_flag21, NA, NA,
+			NA, NA, NA, NA, NA),
+	[61] = PINGROUP(61, NORTH, qua_mi2s, cri_trng1, phase_flag22, NA, NA,
+			NA, NA, NA, NA, NA),
+	[62] = PINGROUP(62, NORTH, qua_mi2s, cri_trng, phase_flag23, qdss_cti,
+			NA, NA, NA, NA, NA, NA),
+	[63] = PINGROUP(63, NORTH, qua_mi2s, NA, phase_flag24, qdss_cti, NA,
+			NA, NA, NA, NA, NA),
+	[64] = PINGROUP(64, NORTH, pri_mi2s, sp_cmu, phase_flag25, NA, NA, NA,
+			NA, NA, NA, NA),
+	[65] = PINGROUP(65, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[66] = PINGROUP(66, NORTH, pri_mi2s_ws, qup8, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[67] = PINGROUP(67, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[68] = PINGROUP(68, NORTH, pri_mi2s, qup8, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[69] = PINGROUP(69, NORTH, spkr_i2s, audio_ref, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[70] = PINGROUP(70, NORTH, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[71] = PINGROUP(71, NORTH, lpass_slimbus, spkr_i2s, tsense_pwm1,
+			tsense_pwm2, NA, NA, NA, NA, NA, NA),
+	[72] = PINGROUP(72, NORTH, lpass_slimbus, spkr_i2s, NA, NA, NA, NA, NA,
+			NA, NA, NA),
+	[73] = PINGROUP(73, NORTH, btfm_slimbus, atest_usb2, NA, NA, NA, NA,
+			NA, NA, NA, NA),
+	[74] = PINGROUP(74, NORTH, btfm_slimbus, ter_mi2s, phase_flag7,
+			atest_usb23, NA, NA, NA, NA, NA, NA),
+	[75] = PINGROUP(75, NORTH, ter_mi2s, phase_flag8, qdss_gpio8,
+			atest_usb22, NA, NA, NA, NA, NA, NA),
+	[76] = PINGROUP(76, NORTH, ter_mi2s, phase_flag9, qdss_gpio9,
+			atest_usb21, NA, NA, NA, NA, NA, NA),
+	[77] = PINGROUP(77, NORTH, ter_mi2s, phase_flag4, qdss_gpio10,
+			atest_usb20, NA, NA, NA, NA, NA, NA),
+	[78] = PINGROUP(78, NORTH, ter_mi2s, gcc_gp1, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[79] = PINGROUP(79, NORTH, sec_mi2s, NA, NA, qdss_gpio11, NA, NA, NA,
+			NA, NA, NA),
+	[80] = PINGROUP(80, NORTH, sec_mi2s, NA, qdss_gpio12, NA, NA, NA, NA,
+			NA, NA, NA),
+	[81] = PINGROUP(81, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[82] = PINGROUP(82, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[83] = PINGROUP(83, NORTH, sec_mi2s, qup15, NA, NA, NA, NA, NA, NA, NA,
+			NA),
+	[84] = PINGROUP(84, NORTH, qup15, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[85] = PINGROUP(85, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[86] = PINGROUP(86, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[87] = PINGROUP(87, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[88] = PINGROUP(88, SOUTH, qup5, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[89] = PINGROUP(89, SOUTH, tsif1_clk, qup4, tgu_ch3, phase_flag10, NA,
+			NA, NA, NA, NA, NA),
+	[90] = PINGROUP(90, SOUTH, tsif1_en, mdp_vsync0, qup4, mdp_vsync1,
+			mdp_vsync2, mdp_vsync3, tgu_ch0, phase_flag0, qdss_cti,
+			NA),
+	[91] = PINGROUP(91, SOUTH, tsif1_data, sdc4_cmd, qup4, tgu_ch1, NA,
+			qdss_cti, NA, NA, NA, NA),
+	[92] = PINGROUP(92, SOUTH, tsif2_error, sdc43, qup4, vfr_1, tgu_ch2,
+			NA, NA, NA, NA, NA),
+	[93] = PINGROUP(93, SOUTH, tsif2_clk, sdc4_clk, qup7, NA, qdss_gpio13,
+			NA, NA, NA, NA, NA),
+	[94] = PINGROUP(94, SOUTH, tsif2_en, sdc42, qup7, NA, NA, NA, NA, NA,
+			NA, NA),
+	[95] = PINGROUP(95, SOUTH, tsif2_data, sdc41, qup7, NA, NA, NA, NA, NA,
+			NA, NA),
+	[96] = PINGROUP(96, SOUTH, tsif2_sync, sdc40, qup7, phase_flag3, NA,
+			NA, NA, NA, NA, NA),
+	[97] = PINGROUP(97, NORTH, NA, NA, mdp_vsync, ldo_en, NA, NA, NA, NA,
+			NA, NA),
+	[98] = PINGROUP(98, NORTH, NA, mdp_vsync, ldo_update, NA, NA, NA, NA,
+			NA, NA, NA),
+	[99] = PINGROUP(99, NORTH, phase_flag14, NA, NA, NA, NA, NA, NA, NA,
+			NA, NA),
+	[100] = PINGROUP(100, NORTH, phase_flag15, NA, NA, NA, NA, NA, NA, NA,
 			 NA, NA),
-	[104] = PINGROUP(104, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[105] = PINGROUP(105, uim2_data, qup13, qup_l4, NA, NA, NA, NA,
+	[101] = PINGROUP(101, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[102] = PINGROUP(102, NORTH, pci_e1, prng_rosc, NA, NA, NA, NA, NA, NA,
 			 NA, NA),
-	[106] = PINGROUP(106, uim2_clk, qup13, qup_l5, NA, NA, NA, NA,
-			 NA, NA),
-	[107] = PINGROUP(107, uim2_reset, qup13, qup_l6, NA, NA, NA, NA,
-			 NA, NA),
-	[108] = PINGROUP(108, uim2_present, qup13, NA, NA, NA, NA, NA,
-			 NA, NA),
-	[109] = PINGROUP(109, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA),
-	[110] = PINGROUP(110, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA),
-	[111] = PINGROUP(111, uim1_reset, NA, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[112] = PINGROUP(112, uim1_present, NA, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[113] = PINGROUP(113, uim_batt, edp_hot, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[114] = PINGROUP(114, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
-			 NA),
-	[115] = PINGROUP(115, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
-			 NA),
-	[116] = PINGROUP(116, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[117] = PINGROUP(117, NA, qdss_gpio0, atest_char, NA, NA, NA,
+	[103] = PINGROUP(103, NORTH, pci_e1, phase_flag5, NA, NA, NA, NA, NA,
 			 NA, NA, NA),
-	[118] = PINGROUP(118, adsp_ext, NA, qdss_gpio1, atest_char3, NA,
+	[104] = PINGROUP(104, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[105] = PINGROUP(105, NORTH, uim2_data, qup13, qup_l4, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[106] = PINGROUP(106, NORTH, uim2_clk, qup13, qup_l5, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[107] = PINGROUP(107, NORTH, uim2_reset, qup13, qup_l6, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[108] = PINGROUP(108, NORTH, uim2_present, qup13, NA, NA, NA, NA, NA,
+			 NA, NA, NA),
+	[109] = PINGROUP(109, NORTH, uim1_data, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[110] = PINGROUP(110, NORTH, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[111] = PINGROUP(111, NORTH, uim1_reset, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[112] = PINGROUP(112, NORTH, uim1_present, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[113] = PINGROUP(113, NORTH, uim_batt, edp_hot, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[114] = PINGROUP(114, NORTH, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[115] = PINGROUP(115, NORTH, NA, nav_pps, nav_pps, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[116] = PINGROUP(116, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[117] = PINGROUP(117, NORTH, NA, qdss_gpio0, atest_char, NA, NA, NA,
 			 NA, NA, NA, NA),
-	[119] = PINGROUP(119, NA, qdss_gpio2, atest_char2, NA, NA, NA,
-			 NA, NA, NA),
-	[120] = PINGROUP(120, NA, qdss_gpio3, atest_char1, NA, NA, NA,
-			 NA, NA, NA),
-	[121] = PINGROUP(121, NA, qdss_gpio4, atest_char0, NA, NA, NA,
-			 NA, NA, NA),
-	[122] = PINGROUP(122, NA, qdss_gpio5, NA, NA, NA, NA, NA, NA, NA),
-	[123] = PINGROUP(123, qup_l4, NA, qdss_gpio, NA, NA, NA, NA, NA,
-			 NA),
-	[124] = PINGROUP(124, qup_l5, NA, qdss_gpio, NA, NA, NA, NA, NA,
-			 NA),
-	[125] = PINGROUP(125, qup_l6, NA, NA, NA, NA, NA, NA, NA, NA),
-	[126] = PINGROUP(126, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[127] = PINGROUP(127, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[128] = PINGROUP(128, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[129] = PINGROUP(129, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[130] = PINGROUP(130, qlink_request, NA, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[131] = PINGROUP(131, qlink_enable, NA, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[132] = PINGROUP(132, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[133] = PINGROUP(133, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[134] = PINGROUP(134, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[135] = PINGROUP(135, NA, pa_indicator, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[136] = PINGROUP(136, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[137] = PINGROUP(137, NA, NA, phase_flag26, NA, NA, NA, NA, NA,
-			 NA),
-	[138] = PINGROUP(138, NA, NA, phase_flag27, NA, NA, NA, NA, NA,
-			 NA),
-	[139] = PINGROUP(139, NA, phase_flag28, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[140] = PINGROUP(140, NA, NA, phase_flag6, NA, NA, NA, NA, NA,
-			 NA),
-	[141] = PINGROUP(141, NA, phase_flag29, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[142] = PINGROUP(142, NA, phase_flag30, NA, NA, NA, NA, NA, NA,
-			 NA),
-	[143] = PINGROUP(143, NA, nav_pps, nav_pps, NA, phase_flag31,
+	[118] = PINGROUP(118, NORTH, adsp_ext, NA, qdss_gpio1, atest_char3, NA,
+			 NA, NA, NA, NA, NA),
+	[119] = PINGROUP(119, NORTH, NA, qdss_gpio2, atest_char2, NA, NA, NA,
 			 NA, NA, NA, NA),
-	[144] = PINGROUP(144, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA),
-	[145] = PINGROUP(145, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA),
-	[146] = PINGROUP(146, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[147] = PINGROUP(147, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[148] = PINGROUP(148, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	[149] = PINGROUP(149, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[120] = PINGROUP(120, NORTH, NA, qdss_gpio3, atest_char1, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[121] = PINGROUP(121, NORTH, NA, qdss_gpio4, atest_char0, NA, NA, NA,
+			 NA, NA, NA, NA),
+	[122] = PINGROUP(122, NORTH, NA, qdss_gpio5, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[123] = PINGROUP(123, NORTH, qup_l4, NA, qdss_gpio, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[124] = PINGROUP(124, NORTH, qup_l5, NA, qdss_gpio, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[125] = PINGROUP(125, NORTH, qup_l6, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[126] = PINGROUP(126, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[127] = PINGROUP(127, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[128] = PINGROUP(128, NORTH, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[129] = PINGROUP(129, NORTH, nav_pps, nav_pps, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[130] = PINGROUP(130, NORTH, qlink_request, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[131] = PINGROUP(131, NORTH, qlink_enable, NA, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[132] = PINGROUP(132, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[133] = PINGROUP(133, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[134] = PINGROUP(134, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[135] = PINGROUP(135, NORTH, NA, pa_indicator, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[136] = PINGROUP(136, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[137] = PINGROUP(137, NORTH, NA, NA, phase_flag26, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[138] = PINGROUP(138, NORTH, NA, NA, phase_flag27, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[139] = PINGROUP(139, NORTH, NA, phase_flag28, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[140] = PINGROUP(140, NORTH, NA, NA, phase_flag6, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[141] = PINGROUP(141, NORTH, NA, phase_flag29, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[142] = PINGROUP(142, NORTH, NA, phase_flag30, NA, NA, NA, NA, NA, NA,
+			 NA, NA),
+	[143] = PINGROUP(143, NORTH, NA, nav_pps, nav_pps, NA, phase_flag31,
+			 NA, NA, NA, NA, NA),
+	[144] = PINGROUP(144, NORTH, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[145] = PINGROUP(145, NORTH, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA,
+			 NA),
+	[146] = PINGROUP(146, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[147] = PINGROUP(147, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[148] = PINGROUP(148, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[149] = PINGROUP(149, NORTH, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	[150] = SDC_QDSD_PINGROUP(sdc2_clk, 0x99a000, 14, 6),
 	[151] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x99a000, 11, 3),
 	[152] = SDC_QDSD_PINGROUP(sdc2_data, 0x99a000, 9, 0),
@@ -1714,10 +1736,6 @@
 	.ngpios = 150,
 	.dir_conn = sdm845_dir_conn,
 	.n_dir_conns = ARRAY_SIZE(sdm845_dir_conn),
-	.tile_offsets = sdm845_tile_offsets,
-	.n_tile_offsets = ARRAY_SIZE(sdm845_tile_offsets),
-	.pin_base = sdm845_pin_base,
-	.reg_size = REG_SIZE,
 };
 
 static int sdm845_pinctrl_probe(struct platform_device *pdev)
diff --git a/drivers/pinctrl/qcom/pinctrl-sdxpoorwills.c b/drivers/pinctrl/qcom/pinctrl-sdxpoorwills.c
index 4a21eb6..6ceb39a 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdxpoorwills.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdxpoorwills.c
@@ -85,6 +85,32 @@
 		.intr_enable_bit = -1,			\
 		.intr_status_bit = -1,			\
 		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+
+#define UFS_RESET(pg_name, offset)				\
+	{					        \
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = (unsigned int)ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = offset,			\
+		.io_reg = offset + 0x4,			\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = 3,				\
+		.drv_bit = 0,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = 0,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
 		.intr_polarity_bit = -1,		\
 		.intr_detection_bit = -1,		\
 		.intr_detection_width = -1,		\
@@ -190,12 +216,13 @@
 	PINCTRL_PIN(97, "GPIO_97"),
 	PINCTRL_PIN(98, "GPIO_98"),
 	PINCTRL_PIN(99, "GPIO_99"),
-	PINCTRL_PIN(100, "SDC1_CLK"),
-	PINCTRL_PIN(101, "SDC1_CMD"),
-	PINCTRL_PIN(102, "SDC1_DATA"),
-	PINCTRL_PIN(103, "SDC2_CLK"),
-	PINCTRL_PIN(104, "SDC2_CMD"),
-	PINCTRL_PIN(105, "SDC2_DATA"),
+	PINCTRL_PIN(100, "SDC1_RCLK"),
+	PINCTRL_PIN(101, "SDC1_CLK"),
+	PINCTRL_PIN(102, "SDC1_CMD"),
+	PINCTRL_PIN(103, "SDC1_DATA"),
+	PINCTRL_PIN(104, "SDC2_CLK"),
+	PINCTRL_PIN(105, "SDC2_CMD"),
+	PINCTRL_PIN(106, "SDC2_DATA"),
 };
 
 #define DECLARE_MSM_GPIO_PINS(pin) \
@@ -301,21 +328,22 @@
 DECLARE_MSM_GPIO_PINS(98);
 DECLARE_MSM_GPIO_PINS(99);
 
-static const unsigned int sdc1_clk_pins[] = { 100 };
-static const unsigned int sdc1_cmd_pins[] = { 101 };
-static const unsigned int sdc1_data_pins[] = { 102 };
-static const unsigned int sdc2_clk_pins[] = { 103 };
-static const unsigned int sdc2_cmd_pins[] = { 104 };
-static const unsigned int sdc2_data_pins[] = { 105 };
+static const unsigned int sdc1_rclk_pins[] = { 100 };
+static const unsigned int sdc1_clk_pins[] = { 101 };
+static const unsigned int sdc1_cmd_pins[] = { 102 };
+static const unsigned int sdc1_data_pins[] = { 103 };
+static const unsigned int sdc2_clk_pins[] = { 104 };
+static const unsigned int sdc2_cmd_pins[] = { 105 };
+static const unsigned int sdc2_data_pins[] = { 106 };
 
 enum sdxpoorwills_functions {
-	msm_mux_qdss_stm31,
-	msm_mux_blsp_uart1,
-	msm_mux_gpio,
 	msm_mux_uim2_data,
+	msm_mux_gpio,
+	msm_mux_qdss_stm31,
 	msm_mux_ebi0_wrcdc,
 	msm_mux_uim2_present,
 	msm_mux_qdss_stm30,
+	msm_mux_blsp_uart1,
 	msm_mux_uim2_reset,
 	msm_mux_blsp_i2c1,
 	msm_mux_qdss_stm29,
@@ -340,14 +368,22 @@
 	msm_mux_blsp_i2c3,
 	msm_mux_gcc_gp3,
 	msm_mux_qdss_stm19,
-	msm_mux_qdss12,
+	msm_mux_qdss4,
 	msm_mux_qdss_stm18,
-	msm_mux_qdss13,
+	msm_mux_qdss5,
 	msm_mux_qdss_stm17,
-	msm_mux_qdss14,
+	msm_mux_qdss6,
 	msm_mux_bimc_dte0,
 	msm_mux_native_tsens,
-	msm_mux_vsense_trigger,
+	msm_mux_qdss_stm16,
+	msm_mux_qdss7,
+	msm_mux_bimc_dte1,
+	msm_mux_sec_mi2s,
+	msm_mux_blsp_spi4,
+	msm_mux_blsp_uart4,
+	msm_mux_qdss_cti,
+	msm_mux_qdss_stm27,
+	msm_mux_qdss8,
 	msm_mux_qdss_stm26,
 	msm_mux_qdss9,
 	msm_mux_blsp_i2c4,
@@ -358,26 +394,19 @@
 	msm_mux_gcc_gp2,
 	msm_mux_qdss_stm24,
 	msm_mux_qdss11,
-	msm_mux_qdss_stm16,
-	msm_mux_qdss15,
-	msm_mux_bimc_dte1,
-	msm_mux_sec_mi2s,
-	msm_mux_blsp_spi4,
-	msm_mux_blsp_uart4,
-	msm_mux_qdss_cti,
-	msm_mux_qdss_stm27,
-	msm_mux_qdss8,
 	msm_mux_ebi2_a,
-	msm_mux_qdss_stm3,
 	msm_mux_ebi2_lcd,
-	msm_mux_qdss_stm2,
 	msm_mux_pll_bist,
-	msm_mux_qdss_stm1,
-	msm_mux_qdss_stm0,
 	msm_mux_adsp_ext,
-	msm_mux_epm1,
+	msm_mux_qdss_stm11,
 	msm_mux_m_voc,
+	msm_mux_qdss_stm10,
 	msm_mux_native_char,
+	msm_mux_native_char3,
+	msm_mux_nav_pps,
+	msm_mux_nav_dr,
+	msm_mux_native_char2,
+	msm_mux_native_tsense,
 	msm_mux_native_char1,
 	msm_mux_pa_indicator,
 	msm_mux_qdss_traceclk,
@@ -386,92 +415,69 @@
 	msm_mux_qlink_req,
 	msm_mux_pll_test,
 	msm_mux_cri_trng,
-	msm_mux_wmss_reset,
-	msm_mux_native_char3,
-	msm_mux_nav_pps,
-	msm_mux_nav_dr,
-	msm_mux_native_char2,
-	msm_mux_native_tsense,
 	msm_mux_prng_rosc,
 	msm_mux_cri_trng0,
 	msm_mux_cri_trng1,
 	msm_mux_pll_ref,
 	msm_mux_coex_uart,
-	msm_mux_qdss_stm11,
-	msm_mux_qdss_stm10,
-	msm_mux_ddr_pxi0,
-	msm_mux_ap2mdm_status,
+	msm_mux_qdss_tracectl,
 	msm_mux_ddr_bist,
-	msm_mux_mdm2ap_status,
-	msm_mux_ap2mdm_err,
-	msm_mux_mdm2ap_err,
-	msm_mux_ap2mdm_vdd,
-	msm_mux_mdm2ap_vdd,
-	msm_mux_ap2mdm_wake,
-	msm_mux_pciehost_rst,
 	msm_mux_blsp_spi1,
-	msm_mux_qdss_stm14,
-	msm_mux_pcie_wake,
-	msm_mux_mdm2ap_wake,
 	msm_mux_pci_e,
+	msm_mux_tgu_ch0,
+	msm_mux_pcie_clkreq,
+	msm_mux_qdss_stm15,
+	msm_mux_qdss_stm14,
 	msm_mux_qdss_stm13,
+	msm_mux_mgpi_clk,
+	msm_mux_qdss_stm12,
+	msm_mux_qdss_stm9,
 	msm_mux_i2s_mclk,
 	msm_mux_audio_ref,
 	msm_mux_ldo_update,
 	msm_mux_qdss_stm8,
 	msm_mux_qdss_stm7,
-	msm_mux_qdss4,
-	msm_mux_tgu_ch0,
-	msm_mux_pcie_clkreq,
-	msm_mux_qdss_stm9,
-	msm_mux_qdss_stm15,
-	msm_mux_mgpi_clk,
-	msm_mux_qdss_stm12,
-	msm_mux_qdss_tracectl,
-	msm_mux_atest_char,
+	msm_mux_qdss12,
 	msm_mux_qdss_stm6,
-	msm_mux_qdss5,
-	msm_mux_atest_char3,
+	msm_mux_qdss13,
 	msm_mux_qdss_stm5,
-	msm_mux_qdss6,
-	msm_mux_atest_char2,
+	msm_mux_qdss14,
 	msm_mux_qdss_stm4,
-	msm_mux_qdss7,
-	msm_mux_atest_char1,
+	msm_mux_qdss15,
 	msm_mux_uim1_data,
-	msm_mux_atest_char0,
+	msm_mux_qdss_stm3,
 	msm_mux_uim1_present,
+	msm_mux_qdss_stm2,
 	msm_mux_uim1_reset,
+	msm_mux_qdss_stm1,
 	msm_mux_uim1_clk,
+	msm_mux_qdss_stm0,
 	msm_mux_dbg_out,
 	msm_mux_gcc_plltest,
-	msm_mux_usb2phy_ac,
 	msm_mux_NA,
 };
 
-static const char * const qdss_stm31_groups[] = {
+static const char * const uim2_data_groups[] = {
 	"gpio0",
 };
-static const char * const blsp_uart1_groups[] = {
-	"gpio0", "gpio1", "gpio2", "gpio3", "gpio20", "gpio21", "gpio22",
-	"gpio23",
-};
 static const char * const gpio_groups[] = {
 	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
 	"gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
 	"gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
-	"gpio22", "gpio23", "gpio24", "gpio26", "gpio27", "gpio28", "gpio29",
-	"gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35", "gpio36",
-	"gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42", "gpio43",
-	"gpio44", "gpio45", "gpio54", "gpio55", "gpio56", "gpio58", "gpio59",
-	"gpio60", "gpio61", "gpio62", "gpio63", "gpio64", "gpio65", "gpio66",
-	"gpio67", "gpio68", "gpio69", "gpio70", "gpio71", "gpio72", "gpio73",
-	"gpio74", "gpio75", "gpio76", "gpio77", "gpio78", "gpio79", "gpio80",
-	"gpio81", "gpio82", "gpio83", "gpio84", "gpio85", "gpio86", "gpio87",
-	"gpio88", "gpio89", "gpio90", "gpio91", "gpio92", "gpio93", "gpio94",
-	"gpio95", "gpio96", "gpio97", "gpio98", "gpio99",
+	"gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
+	"gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35",
+	"gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42",
+	"gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49",
+	"gpio50", "gpio51", "gpio52", "gpio52", "gpio53", "gpio53", "gpio54",
+	"gpio55", "gpio56", "gpio57", "gpio58", "gpio59", "gpio60", "gpio61",
+	"gpio62", "gpio63", "gpio64", "gpio65", "gpio66", "gpio67", "gpio68",
+	"gpio69", "gpio70", "gpio71", "gpio72", "gpio73", "gpio74", "gpio75",
+	"gpio76", "gpio77", "gpio78", "gpio79", "gpio80", "gpio81", "gpio82",
+	"gpio83", "gpio84", "gpio85", "gpio86", "gpio87", "gpio88", "gpio89",
+	"gpio90", "gpio91", "gpio92", "gpio93", "gpio94", "gpio95", "gpio96",
+	"gpio97", "gpio98", "gpio99",
 };
-static const char * const uim2_data_groups[] = {
+static const char * const qdss_stm31_groups[] = {
 	"gpio0",
 };
 static const char * const ebi0_wrcdc_groups[] = {
@@ -483,6 +489,10 @@
 static const char * const qdss_stm30_groups[] = {
 	"gpio1",
 };
+static const char * const blsp_uart1_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3", "gpio20", "gpio21", "gpio22",
+	"gpio23",
+};
 static const char * const uim2_reset_groups[] = {
 	"gpio2",
 };
@@ -557,19 +567,19 @@
 static const char * const qdss_stm19_groups[] = {
 	"gpio12",
 };
-static const char * const qdss12_groups[] = {
+static const char * const qdss4_groups[] = {
 	"gpio12",
 };
 static const char * const qdss_stm18_groups[] = {
 	"gpio13",
 };
-static const char * const qdss13_groups[] = {
+static const char * const qdss5_groups[] = {
 	"gpio13",
 };
 static const char * const qdss_stm17_groups[] = {
 	"gpio14",
 };
-static const char * const qdss14_groups[] = {
+static const char * const qdss6_groups[] = {
 	"gpio14",
 };
 static const char * const bimc_dte0_groups[] = {
@@ -578,8 +588,36 @@
 static const char * const native_tsens_groups[] = {
 	"gpio14",
 };
-static const char * const vsense_trigger_groups[] = {
-	"gpio14",
+static const char * const qdss_stm16_groups[] = {
+	"gpio15",
+};
+static const char * const qdss7_groups[] = {
+	"gpio15",
+};
+static const char * const bimc_dte1_groups[] = {
+	"gpio15", "gpio60",
+};
+static const char * const sec_mi2s_groups[] = {
+	"gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21", "gpio22",
+	"gpio23",
+};
+static const char * const blsp_spi4_groups[] = {
+	"gpio16", "gpio17", "gpio18", "gpio19", "gpio52", "gpio62", "gpio71",
+};
+static const char * const blsp_uart4_groups[] = {
+	"gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21", "gpio22",
+	"gpio23",
+};
+static const char * const qdss_cti_groups[] = {
+	"gpio16", "gpio16", "gpio17", "gpio17", "gpio22", "gpio22", "gpio23",
+	"gpio23", "gpio54", "gpio54", "gpio55", "gpio55", "gpio59", "gpio61",
+	"gpio88", "gpio88", "gpio89", "gpio89",
+};
+static const char * const qdss_stm27_groups[] = {
+	"gpio16",
+};
+static const char * const qdss8_groups[] = {
+	"gpio16",
 };
 static const char * const qdss_stm26_groups[] = {
 	"gpio17",
@@ -611,70 +649,45 @@
 static const char * const qdss11_groups[] = {
 	"gpio19",
 };
-static const char * const qdss_stm16_groups[] = {
-	"gpio15",
-};
-static const char * const qdss15_groups[] = {
-	"gpio15",
-};
-static const char * const bimc_dte1_groups[] = {
-	"gpio15", "gpio60",
-};
-static const char * const sec_mi2s_groups[] = {
-	"gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21", "gpio22",
-	"gpio23",
-};
-static const char * const blsp_spi4_groups[] = {
-	"gpio16", "gpio17", "gpio18", "gpio19", "gpio52", "gpio62", "gpio71",
-};
-static const char * const blsp_uart4_groups[] = {
-	"gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21", "gpio22",
-	"gpio23",
-};
-static const char * const qdss_cti_groups[] = {
-	"gpio16", "gpio16", "gpio17", "gpio17", "gpio22", "gpio22", "gpio23",
-	"gpio23", "gpio54", "gpio54", "gpio55", "gpio55", "gpio59", "gpio61",
-	"gpio88", "gpio88", "gpio89", "gpio89",
-};
-static const char * const qdss_stm27_groups[] = {
-	"gpio16",
-};
-static const char * const qdss8_groups[] = {
-	"gpio16",
-};
 static const char * const ebi2_a_groups[] = {
 	"gpio20",
 };
-static const char * const qdss_stm3_groups[] = {
-	"gpio20",
-};
 static const char * const ebi2_lcd_groups[] = {
 	"gpio21", "gpio22", "gpio23",
 };
-static const char * const qdss_stm2_groups[] = {
-	"gpio21",
-};
 static const char * const pll_bist_groups[] = {
 	"gpio22",
 };
-static const char * const qdss_stm1_groups[] = {
-	"gpio22",
-};
-static const char * const qdss_stm0_groups[] = {
-	"gpio23",
-};
 static const char * const adsp_ext_groups[] = {
 	"gpio24", "gpio25",
 };
-static const char * const epm1_groups[] = {
-	"gpio25",
+static const char * const qdss_stm11_groups[] = {
+	"gpio24",
 };
 static const char * const m_voc_groups[] = {
 	"gpio25", "gpio46", "gpio59", "gpio61",
 };
+static const char * const qdss_stm10_groups[] = {
+	"gpio25",
+};
 static const char * const native_char_groups[] = {
 	"gpio26",
 };
+static const char * const native_char3_groups[] = {
+	"gpio28",
+};
+static const char * const nav_pps_groups[] = {
+	"gpio29", "gpio42", "gpio62",
+};
+static const char * const nav_dr_groups[] = {
+	"gpio29", "gpio42", "gpio62",
+};
+static const char * const native_char2_groups[] = {
+	"gpio29",
+};
+static const char * const native_tsense_groups[] = {
+	"gpio29",
+};
 static const char * const native_char1_groups[] = {
 	"gpio32",
 };
@@ -699,24 +712,6 @@
 static const char * const cri_trng_groups[] = {
 	"gpio36",
 };
-static const char * const wmss_reset_groups[] = {
-	"gpio28",
-};
-static const char * const native_char3_groups[] = {
-	"gpio28",
-};
-static const char * const nav_pps_groups[] = {
-	"gpio29", "gpio42", "gpio62",
-};
-static const char * const nav_dr_groups[] = {
-	"gpio29", "gpio42", "gpio62",
-};
-static const char * const native_char2_groups[] = {
-	"gpio29",
-};
-static const char * const native_tsense_groups[] = {
-	"gpio29",
-};
 static const char * const prng_rosc_groups[] = {
 	"gpio38",
 };
@@ -732,59 +727,41 @@
 static const char * const coex_uart_groups[] = {
 	"gpio44", "gpio45",
 };
-static const char * const qdss_stm11_groups[] = {
+static const char * const qdss_tracectl_groups[] = {
 	"gpio44",
 };
-static const char * const qdss_stm10_groups[] = {
-	"gpio45",
-};
-static const char * const ddr_pxi0_groups[] = {
-	"gpio45", "gpio46",
-};
-static const char * const ap2mdm_status_groups[] = {
-	"gpio46",
-};
 static const char * const ddr_bist_groups[] = {
 	"gpio46", "gpio47", "gpio48", "gpio49",
 };
-static const char * const mdm2ap_status_groups[] = {
-	"gpio47",
-};
-static const char * const ap2mdm_err_groups[] = {
-	"gpio48",
-};
-static const char * const mdm2ap_err_groups[] = {
-	"gpio49",
-};
-static const char * const ap2mdm_vdd_groups[] = {
-	"gpio50",
-};
-static const char * const mdm2ap_vdd_groups[] = {
-	"gpio51",
-};
-static const char * const ap2mdm_wake_groups[] = {
-	"gpio52",
-};
-static const char * const pciehost_rst_groups[] = {
-	"gpio52",
-};
 static const char * const blsp_spi1_groups[] = {
 	"gpio52", "gpio62", "gpio71", "gpio72", "gpio73", "gpio74", "gpio75",
 };
-static const char * const qdss_stm14_groups[] = {
-	"gpio52",
-};
-static const char * const pcie_wake_groups[] = {
-	"gpio53",
-};
-static const char * const mdm2ap_wake_groups[] = {
-	"gpio53",
-};
 static const char * const pci_e_groups[] = {
-	"gpio53", "gpio57",
+	"gpio53",
+};
+static const char * const tgu_ch0_groups[] = {
+	"gpio55",
+};
+static const char * const pcie_clkreq_groups[] = {
+	"gpio56",
+};
+static const char * const qdss_stm15_groups[] = {
+	"gpio57",
+};
+static const char * const qdss_stm14_groups[] = {
+	"gpio58",
 };
 static const char * const qdss_stm13_groups[] = {
-	"gpio53",
+	"gpio59",
+};
+static const char * const mgpi_clk_groups[] = {
+	"gpio60", "gpio71",
+};
+static const char * const qdss_stm12_groups[] = {
+	"gpio60",
+};
+static const char * const qdss_stm9_groups[] = {
+	"gpio61",
 };
 static const char * const i2s_mclk_groups[] = {
 	"gpio62",
@@ -801,93 +778,66 @@
 static const char * const qdss_stm7_groups[] = {
 	"gpio63",
 };
-static const char * const qdss4_groups[] = {
-	"gpio63",
-};
-static const char * const tgu_ch0_groups[] = {
-	"gpio55",
-};
-static const char * const pcie_clkreq_groups[] = {
-	"gpio56",
-};
-static const char * const qdss_stm9_groups[] = {
-	"gpio56",
-};
-static const char * const qdss_stm15_groups[] = {
-	"gpio57",
-};
-static const char * const mgpi_clk_groups[] = {
-	"gpio60", "gpio71",
-};
-static const char * const qdss_stm12_groups[] = {
-	"gpio60",
-};
-static const char * const qdss_tracectl_groups[] = {
-	"gpio60",
-};
-static const char * const atest_char_groups[] = {
+static const char * const qdss12_groups[] = {
 	"gpio63",
 };
 static const char * const qdss_stm6_groups[] = {
 	"gpio64",
 };
-static const char * const qdss5_groups[] = {
-	"gpio64",
-};
-static const char * const atest_char3_groups[] = {
+static const char * const qdss13_groups[] = {
 	"gpio64",
 };
 static const char * const qdss_stm5_groups[] = {
 	"gpio65",
 };
-static const char * const qdss6_groups[] = {
-	"gpio65",
-};
-static const char * const atest_char2_groups[] = {
+static const char * const qdss14_groups[] = {
 	"gpio65",
 };
 static const char * const qdss_stm4_groups[] = {
 	"gpio66",
 };
-static const char * const qdss7_groups[] = {
-	"gpio66",
-};
-static const char * const atest_char1_groups[] = {
+static const char * const qdss15_groups[] = {
 	"gpio66",
 };
 static const char * const uim1_data_groups[] = {
 	"gpio67",
 };
-static const char * const atest_char0_groups[] = {
+static const char * const qdss_stm3_groups[] = {
 	"gpio67",
 };
 static const char * const uim1_present_groups[] = {
 	"gpio68",
 };
+static const char * const qdss_stm2_groups[] = {
+	"gpio68",
+};
 static const char * const uim1_reset_groups[] = {
 	"gpio69",
 };
+static const char * const qdss_stm1_groups[] = {
+	"gpio69",
+};
 static const char * const uim1_clk_groups[] = {
 	"gpio70",
 };
+static const char * const qdss_stm0_groups[] = {
+	"gpio70",
+};
 static const char * const dbg_out_groups[] = {
 	"gpio71",
 };
 static const char * const gcc_plltest_groups[] = {
 	"gpio73", "gpio74",
 };
-static const char * const usb2phy_ac_groups[] = {
-	"gpio87",
-};
 
 static const struct msm_function sdxpoorwills_functions[] = {
-	FUNCTION(qdss_stm31),
-	FUNCTION(blsp_uart1),
-	FUNCTION(gpio),
 	FUNCTION(uim2_data),
+	FUNCTION(gpio),
+	FUNCTION(qdss_stm31),
 	FUNCTION(ebi0_wrcdc),
 	FUNCTION(uim2_present),
 	FUNCTION(qdss_stm30),
+	FUNCTION(blsp_uart1),
 	FUNCTION(uim2_reset),
 	FUNCTION(blsp_i2c1),
 	FUNCTION(qdss_stm29),
@@ -912,14 +862,22 @@
 	FUNCTION(blsp_i2c3),
 	FUNCTION(gcc_gp3),
 	FUNCTION(qdss_stm19),
-	FUNCTION(qdss12),
+	FUNCTION(qdss4),
 	FUNCTION(qdss_stm18),
-	FUNCTION(qdss13),
+	FUNCTION(qdss5),
 	FUNCTION(qdss_stm17),
-	FUNCTION(qdss14),
+	FUNCTION(qdss6),
 	FUNCTION(bimc_dte0),
 	FUNCTION(native_tsens),
-	FUNCTION(vsense_trigger),
+	FUNCTION(qdss_stm16),
+	FUNCTION(qdss7),
+	FUNCTION(bimc_dte1),
+	FUNCTION(sec_mi2s),
+	FUNCTION(blsp_spi4),
+	FUNCTION(blsp_uart4),
+	FUNCTION(qdss_cti),
+	FUNCTION(qdss_stm27),
+	FUNCTION(qdss8),
 	FUNCTION(qdss_stm26),
 	FUNCTION(qdss9),
 	FUNCTION(blsp_i2c4),
@@ -930,26 +888,19 @@
 	FUNCTION(gcc_gp2),
 	FUNCTION(qdss_stm24),
 	FUNCTION(qdss11),
-	FUNCTION(qdss_stm16),
-	FUNCTION(qdss15),
-	FUNCTION(bimc_dte1),
-	FUNCTION(sec_mi2s),
-	FUNCTION(blsp_spi4),
-	FUNCTION(blsp_uart4),
-	FUNCTION(qdss_cti),
-	FUNCTION(qdss_stm27),
-	FUNCTION(qdss8),
 	FUNCTION(ebi2_a),
-	FUNCTION(qdss_stm3),
 	FUNCTION(ebi2_lcd),
-	FUNCTION(qdss_stm2),
 	FUNCTION(pll_bist),
-	FUNCTION(qdss_stm1),
-	FUNCTION(qdss_stm0),
 	FUNCTION(adsp_ext),
-	FUNCTION(epm1),
+	FUNCTION(qdss_stm11),
 	FUNCTION(m_voc),
+	FUNCTION(qdss_stm10),
 	FUNCTION(native_char),
+	FUNCTION(native_char3),
+	FUNCTION(nav_pps),
+	FUNCTION(nav_dr),
+	FUNCTION(native_char2),
+	FUNCTION(native_tsense),
 	FUNCTION(native_char1),
 	FUNCTION(pa_indicator),
 	FUNCTION(qdss_traceclk),
@@ -958,204 +909,200 @@
 	FUNCTION(qlink_req),
 	FUNCTION(pll_test),
 	FUNCTION(cri_trng),
-	FUNCTION(wmss_reset),
-	FUNCTION(native_char3),
-	FUNCTION(nav_pps),
-	FUNCTION(nav_dr),
-	FUNCTION(native_char2),
-	FUNCTION(native_tsense),
 	FUNCTION(prng_rosc),
 	FUNCTION(cri_trng0),
 	FUNCTION(cri_trng1),
 	FUNCTION(pll_ref),
 	FUNCTION(coex_uart),
-	FUNCTION(qdss_stm11),
-	FUNCTION(qdss_stm10),
-	FUNCTION(ddr_pxi0),
-	FUNCTION(ap2mdm_status),
+	FUNCTION(qdss_tracectl),
 	FUNCTION(ddr_bist),
-	FUNCTION(mdm2ap_status),
-	FUNCTION(ap2mdm_err),
-	FUNCTION(mdm2ap_err),
-	FUNCTION(ap2mdm_vdd),
-	FUNCTION(mdm2ap_vdd),
-	FUNCTION(ap2mdm_wake),
-	FUNCTION(pciehost_rst),
 	FUNCTION(blsp_spi1),
-	FUNCTION(qdss_stm14),
-	FUNCTION(pcie_wake),
-	FUNCTION(mdm2ap_wake),
 	FUNCTION(pci_e),
+	FUNCTION(tgu_ch0),
+	FUNCTION(pcie_clkreq),
+	FUNCTION(qdss_stm15),
+	FUNCTION(qdss_stm14),
 	FUNCTION(qdss_stm13),
+	FUNCTION(mgpi_clk),
+	FUNCTION(qdss_stm12),
+	FUNCTION(qdss_stm9),
 	FUNCTION(i2s_mclk),
 	FUNCTION(audio_ref),
 	FUNCTION(ldo_update),
 	FUNCTION(qdss_stm8),
 	FUNCTION(qdss_stm7),
-	FUNCTION(qdss4),
-	FUNCTION(tgu_ch0),
-	FUNCTION(pcie_clkreq),
-	FUNCTION(qdss_stm9),
-	FUNCTION(qdss_stm15),
-	FUNCTION(mgpi_clk),
-	FUNCTION(qdss_stm12),
-	FUNCTION(qdss_tracectl),
-	FUNCTION(atest_char),
+	FUNCTION(qdss12),
 	FUNCTION(qdss_stm6),
-	FUNCTION(qdss5),
-	FUNCTION(atest_char3),
+	FUNCTION(qdss13),
 	FUNCTION(qdss_stm5),
-	FUNCTION(qdss6),
-	FUNCTION(atest_char2),
+	FUNCTION(qdss14),
 	FUNCTION(qdss_stm4),
-	FUNCTION(qdss7),
-	FUNCTION(atest_char1),
+	FUNCTION(qdss15),
 	FUNCTION(uim1_data),
-	FUNCTION(atest_char0),
+	FUNCTION(qdss_stm3),
 	FUNCTION(uim1_present),
+	FUNCTION(qdss_stm2),
 	FUNCTION(uim1_reset),
+	FUNCTION(qdss_stm1),
 	FUNCTION(uim1_clk),
+	FUNCTION(qdss_stm0),
 	FUNCTION(dbg_out),
 	FUNCTION(gcc_plltest),
-	FUNCTION(usb2phy_ac),
 };
 
+/* Every pin is maintained as a single group, and missing or non-existing pin
+ * would be maintained as dummy group to synchronize pin group index with
+ * pin descriptor registered with pinctrl core.
+ * Clients would not be able to request these dummy pin groups.
+ */
 static const struct msm_pingroup sdxpoorwills_groups[] = {
-	PINGROUP(0, uim2_data, blsp_uart1, qdss_stm31, ebi0_wrcdc, NA, NA, NA,
-		 NA, NA),
-	PINGROUP(1, uim2_present, blsp_uart1, qdss_stm30, NA, NA, NA, NA, NA,
-		 NA),
-	PINGROUP(2, uim2_reset, blsp_uart1, blsp_i2c1, qdss_stm29, ebi0_wrcdc,
-		 NA, NA, NA, NA),
-	PINGROUP(3, uim2_clk, blsp_uart1, blsp_i2c1, qdss_stm28, NA, NA, NA,
-		 NA, NA),
-	PINGROUP(4, blsp_spi2, blsp_uart2, NA, qdss_stm23, qdss3, NA, NA, NA,
-		 NA),
-	PINGROUP(5, blsp_spi2, blsp_uart2, NA, qdss_stm22, qdss2, NA, NA, NA,
-		 NA),
-	PINGROUP(6, blsp_spi2, blsp_uart2, blsp_i2c2, NA, qdss_stm21, qdss1,
-		 NA, NA, NA),
-	PINGROUP(7, blsp_spi2, blsp_uart2, blsp_i2c2, NA, qdss_stm20, qdss0,
-		 NA, NA, NA),
-	PINGROUP(8, pri_mi2s, blsp_spi3, blsp_uart3, ext_dbg, ldo_en, NA, NA,
-		 NA, NA),
-	PINGROUP(9, pri_mi2s, blsp_spi3, blsp_uart3, ext_dbg, NA, NA, NA, NA,
-		 NA),
-	PINGROUP(10, pri_mi2s, blsp_spi3, blsp_uart3, blsp_i2c3, ext_dbg, NA,
-		 NA, NA, NA),
-	PINGROUP(11, pri_mi2s, blsp_spi3, blsp_uart3, blsp_i2c3, ext_dbg,
-		 gcc_gp3, NA, NA, NA),
-	PINGROUP(12, pri_mi2s, NA, qdss_stm19, qdss12, NA, NA, NA, NA, NA),
-	PINGROUP(13, pri_mi2s, NA, qdss_stm18, qdss13, NA, NA, NA, NA, NA),
-	PINGROUP(14, pri_mi2s, NA, NA, qdss_stm17, qdss14, bimc_dte0,
-		 native_tsens, vsense_trigger, NA),
-	PINGROUP(15, pri_mi2s, NA, NA, qdss_stm16, qdss15, NA, NA, bimc_dte1,
-		 NA),
-	PINGROUP(16, sec_mi2s, blsp_spi4, blsp_uart4, qdss_cti, qdss_cti, NA,
-		 NA, qdss_stm27, qdss8),
-	PINGROUP(17, sec_mi2s, blsp_spi4, blsp_uart4, qdss_cti, qdss_cti, NA,
-		 qdss_stm26, qdss9, NA),
-	PINGROUP(18, sec_mi2s, blsp_spi4, blsp_uart4, blsp_i2c4, gcc_gp1, NA,
-		 qdss_stm25, qdss10, NA),
-	PINGROUP(19, sec_mi2s, blsp_spi4, blsp_uart4, blsp_i2c4, jitter_bist,
-		 gcc_gp2, NA, qdss_stm24, qdss11),
-	PINGROUP(20, sec_mi2s, ebi2_a, blsp_uart1, blsp_uart4, NA, qdss_stm3,
-		 NA, NA, NA),
-	PINGROUP(21, sec_mi2s, ebi2_lcd, blsp_uart1, blsp_uart4, NA, NA,
-		 qdss_stm2, NA, NA),
-	PINGROUP(22, sec_mi2s, ebi2_lcd, blsp_uart1, qdss_cti, qdss_cti,
-		 blsp_uart4, pll_bist, NA, qdss_stm1),
-	PINGROUP(23, sec_mi2s, ebi2_lcd, qdss_cti, qdss_cti, blsp_uart1,
-		 blsp_uart4, NA, qdss_stm0, NA),
-	PINGROUP(24, adsp_ext, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(25, m_voc, adsp_ext, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(26, NA, NA, NA, native_char, NA, NA, NA, NA, NA),
-	PINGROUP(27, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(28, wmss_reset, native_char3, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(29, NA, NA, nav_pps, nav_dr, NA, native_char2, native_tsense,
-		 NA, NA),
-	PINGROUP(30, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(31, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(32, NA, native_char1, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(33, NA, pa_indicator, qdss_traceclk, native_char0, NA, NA, NA,
-		 NA, NA),
-	PINGROUP(34, qlink_en, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(35, qlink_req, pll_test, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(36, NA, NA, cri_trng, NA, NA, NA, NA, NA, NA),
-	PINGROUP(37, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(38, NA, NA, prng_rosc, NA, NA, NA, NA, NA, NA),
-	PINGROUP(39, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(40, NA, NA, cri_trng0, NA, NA, NA, NA, NA, NA),
-	PINGROUP(41, NA, NA, cri_trng1, NA, NA, NA, NA, NA, NA),
-	PINGROUP(42, nav_pps, NA, nav_dr, pll_ref, NA, NA, NA, NA, NA),
-	PINGROUP(43, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(44, coex_uart, NA, qdss_stm11, NA, NA, NA, NA, NA, NA),
-	PINGROUP(45, coex_uart, NA, qdss_stm10, ddr_pxi0, NA, NA, NA, NA, NA),
-	PINGROUP(46, m_voc, ddr_bist, ddr_pxi0, NA, NA, NA, NA, NA, NA),
-	PINGROUP(47, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(48, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(49, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(50, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(51, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(52, blsp_spi2, blsp_spi1, blsp_spi3, blsp_spi4, NA, NA,
-		 qdss_stm14, NA, NA),
-	PINGROUP(53, pci_e, NA, NA, qdss_stm13, NA, NA, NA, NA, NA),
-	PINGROUP(54, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(55, qdss_cti, qdss_cti, tgu_ch0, NA, NA, NA, NA, NA, NA),
-	PINGROUP(56, pcie_clkreq, NA, qdss_stm9, NA, NA, NA, NA, NA, NA),
-	PINGROUP(57, NA, qdss_stm15, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(58, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(59, qdss_cti, m_voc, bimc_dte0, NA, NA, NA, NA, NA, NA),
-	PINGROUP(60, mgpi_clk, NA, qdss_stm12, qdss_tracectl, bimc_dte1, NA,
-		 NA, NA, NA),
-	PINGROUP(61, qdss_cti, NA, m_voc, NA, NA, NA, NA, NA, NA),
-	PINGROUP(62, i2s_mclk, nav_pps, nav_dr, audio_ref, blsp_spi1,
-		 blsp_spi2, blsp_spi3, blsp_spi4, ldo_update),
-	PINGROUP(63, blsp_uart2, NA, qdss_stm7, qdss4, atest_char, NA, NA, NA,
-		 NA),
-	PINGROUP(64, blsp_uart2, NA, qdss_stm6, qdss5, atest_char3, NA, NA, NA,
-		 NA),
-	PINGROUP(65, blsp_uart2, blsp_i2c2, NA, qdss_stm5, qdss6, atest_char2,
-		 NA, NA, NA),
-	PINGROUP(66, blsp_uart2, blsp_i2c2, NA, qdss_stm4, qdss7, atest_char1,
-		 NA, NA, NA),
-	PINGROUP(67, uim1_data, atest_char0, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(68, uim1_present, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(69, uim1_reset, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(70, uim1_clk, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(71, mgpi_clk, blsp_spi1, blsp_spi2, blsp_spi3, blsp_spi4,
-		 dbg_out, NA, NA, NA),
-	PINGROUP(72, NA, blsp_spi1, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(73, NA, blsp_spi1, NA, gcc_plltest, NA, NA, NA, NA, NA),
-	PINGROUP(74, NA, blsp_spi1, NA, blsp_i2c1, gcc_plltest, NA, NA, NA, NA),
-	PINGROUP(75, NA, blsp_spi1, NA, blsp_i2c1, NA, NA, NA, NA, NA),
-	PINGROUP(76, blsp_i2c4, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(77, blsp_i2c4, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(78, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(79, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(80, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(81, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(82, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(83, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(84, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(85, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(86, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(87, NA, NA, usb2phy_ac, NA, NA, NA, NA, NA, NA),
-	PINGROUP(88, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(89, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(90, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(91, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(92, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(93, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(94, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(95, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(96, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(97, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(98, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(99, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	SDC_QDSD_PINGROUP(sdc1_clk, 0x9a000, 13, 6),
-	SDC_QDSD_PINGROUP(sdc1_cmd, 0x9a000, 11, 3),
-	SDC_QDSD_PINGROUP(sdc1_data, 0x9a000, 9, 0),
+	[0] = PINGROUP(0, uim2_data, blsp_uart1, qdss_stm31, ebi0_wrcdc, NA,
+		       NA, NA, NA, NA),
+	[1] = PINGROUP(1, uim2_present, blsp_uart1, qdss_stm30, NA, NA, NA, NA,
+		       NA, NA),
+	[2] = PINGROUP(2, uim2_reset, blsp_uart1, blsp_i2c1, qdss_stm29,
+		       ebi0_wrcdc, NA, NA, NA, NA),
+	[3] = PINGROUP(3, uim2_clk, blsp_uart1, blsp_i2c1, qdss_stm28, NA, NA,
+		       NA, NA, NA),
+	[4] = PINGROUP(4, blsp_spi2, blsp_uart2, NA, qdss_stm23, qdss3, NA, NA,
+		       NA, NA),
+	[5] = PINGROUP(5, blsp_spi2, blsp_uart2, NA, qdss_stm22, qdss2, NA, NA,
+		       NA, NA),
+	[6] = PINGROUP(6, blsp_spi2, blsp_uart2, blsp_i2c2, NA, qdss_stm21,
+		       qdss1, NA, NA, NA),
+	[7] = PINGROUP(7, blsp_spi2, blsp_uart2, blsp_i2c2, NA, qdss_stm20,
+		       qdss0, NA, NA, NA),
+	[8] = PINGROUP(8, pri_mi2s, blsp_spi3, blsp_uart3, ext_dbg, ldo_en, NA,
+		       NA, NA, NA),
+	[9] = PINGROUP(9, pri_mi2s, blsp_spi3, blsp_uart3, ext_dbg, NA, NA, NA,
+		       NA, NA),
+	[10] = PINGROUP(10, pri_mi2s, blsp_spi3, blsp_uart3, blsp_i2c3,
+			ext_dbg, NA, NA, NA, NA),
+	[11] = PINGROUP(11, pri_mi2s, blsp_spi3, blsp_uart3, blsp_i2c3,
+			ext_dbg, gcc_gp3, NA, NA, NA),
+	[12] = PINGROUP(12, pri_mi2s, NA, qdss_stm19, qdss4, NA, NA, NA, NA,
+			NA),
+	[13] = PINGROUP(13, pri_mi2s, NA, qdss_stm18, qdss5, NA, NA, NA, NA,
+			NA),
+	[14] = PINGROUP(14, pri_mi2s, NA, NA, qdss_stm17, qdss6, bimc_dte0,
+			native_tsens, NA, NA),
+	[15] = PINGROUP(15, pri_mi2s, NA, NA, qdss_stm16, qdss7, NA, NA,
+			bimc_dte1, NA),
+	[16] = PINGROUP(16, sec_mi2s, blsp_spi4, blsp_uart4, qdss_cti,
+			qdss_cti, NA, qdss_stm27, qdss8, NA),
+	[17] = PINGROUP(17, sec_mi2s, blsp_spi4, blsp_uart4, qdss_cti,
+			qdss_cti, qdss_stm26, qdss9, NA, NA),
+	[18] = PINGROUP(18, sec_mi2s, blsp_spi4, blsp_uart4, blsp_i2c4,
+			gcc_gp1, qdss_stm25, qdss10, NA, NA),
+	[19] = PINGROUP(19, sec_mi2s, blsp_spi4, blsp_uart4, blsp_i2c4,
+			jitter_bist, gcc_gp2, qdss_stm24, qdss11, NA),
+	[20] = PINGROUP(20, sec_mi2s, ebi2_a, blsp_uart1, blsp_uart4, NA, NA,
+			NA, NA, NA),
+	[21] = PINGROUP(21, sec_mi2s, ebi2_lcd, blsp_uart1, blsp_uart4, NA, NA,
+			NA, NA, NA),
+	[22] = PINGROUP(22, sec_mi2s, ebi2_lcd, blsp_uart1, qdss_cti, qdss_cti,
+			blsp_uart4, pll_bist, NA, NA),
+	[23] = PINGROUP(23, sec_mi2s, ebi2_lcd, qdss_cti, qdss_cti, blsp_uart1,
+			blsp_uart4, NA, NA, NA),
+	[24] = PINGROUP(24, adsp_ext, NA, qdss_stm11, NA, NA, NA, NA, NA, NA),
+	[25] = PINGROUP(25, m_voc, adsp_ext, NA, qdss_stm10, NA, NA, NA, NA,
+			NA),
+	[26] = PINGROUP(26, NA, NA, NA, native_char, NA, NA, NA, NA, NA),
+	[27] = PINGROUP(27, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[28] = PINGROUP(28, NA, native_char3, NA, NA, NA, NA, NA, NA, NA),
+	[29] = PINGROUP(29, NA, NA, nav_pps, nav_dr, NA, native_char2,
+			native_tsense, NA, NA),
+	[30] = PINGROUP(30, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[31] = PINGROUP(31, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[32] = PINGROUP(32, NA, native_char1, NA, NA, NA, NA, NA, NA, NA),
+	[33] = PINGROUP(33, NA, pa_indicator, qdss_traceclk, native_char0, NA,
+			NA, NA, NA, NA),
+	[34] = PINGROUP(34, qlink_en, NA, NA, NA, NA, NA, NA, NA, NA),
+	[35] = PINGROUP(35, qlink_req, pll_test, NA, NA, NA, NA, NA, NA, NA),
+	[36] = PINGROUP(36, NA, NA, cri_trng, NA, NA, NA, NA, NA, NA),
+	[37] = PINGROUP(37, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[38] = PINGROUP(38, NA, NA, prng_rosc, NA, NA, NA, NA, NA, NA),
+	[39] = PINGROUP(39, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[40] = PINGROUP(40, NA, NA, cri_trng0, NA, NA, NA, NA, NA, NA),
+	[41] = PINGROUP(41, NA, NA, cri_trng1, NA, NA, NA, NA, NA, NA),
+	[42] = PINGROUP(42, nav_pps, nav_dr, pll_ref, NA, NA, NA, NA, NA, NA),
+	[43] = PINGROUP(43, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[44] = PINGROUP(44, coex_uart, qdss_tracectl, NA, NA, NA, NA, NA, NA,
+			NA),
+	[45] = PINGROUP(45, coex_uart, NA, NA, NA, NA, NA, NA, NA, NA),
+	[46] = PINGROUP(46, m_voc, ddr_bist, NA, NA, NA, NA, NA, NA, NA),
+	[47] = PINGROUP(47, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
+	[48] = PINGROUP(48, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
+	[49] = PINGROUP(49, ddr_bist, NA, NA, NA, NA, NA, NA, NA, NA),
+	[50] = PINGROUP(50, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[51] = PINGROUP(51, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[52] = PINGROUP(52, blsp_spi2, blsp_spi1, blsp_spi3, blsp_spi4, NA, NA,
+			NA, NA, NA),
+	[53] = PINGROUP(53, pci_e, NA, NA, NA, NA, NA, NA, NA, NA),
+	[54] = PINGROUP(54, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[55] = PINGROUP(55, qdss_cti, qdss_cti, tgu_ch0, NA, NA, NA, NA, NA,
+			NA),
+	[56] = PINGROUP(56, pcie_clkreq, NA, NA, NA, NA, NA, NA, NA, NA),
+	[57] = PINGROUP(57, NA, qdss_stm15, NA, NA, NA, NA, NA, NA, NA),
+	[58] = PINGROUP(58, NA, qdss_stm14, NA, NA, NA, NA, NA, NA, NA),
+	[59] = PINGROUP(59, qdss_cti, m_voc, NA, qdss_stm13, bimc_dte0, NA, NA,
+			NA, NA),
+	[60] = PINGROUP(60, mgpi_clk, NA, qdss_stm12, bimc_dte1, NA, NA, NA,
+			NA, NA),
+	[61] = PINGROUP(61, qdss_cti, NA, m_voc, NA, qdss_stm9, NA, NA, NA, NA),
+	[62] = PINGROUP(62, i2s_mclk, nav_pps, nav_dr, audio_ref, blsp_spi1,
+			blsp_spi2, blsp_spi3, blsp_spi4, ldo_update),
+	[63] = PINGROUP(63, blsp_uart2, NA, qdss_stm7, qdss12, NA, NA, NA, NA,
+			NA),
+	[64] = PINGROUP(64, blsp_uart2, qdss_stm6, qdss13, NA, NA, NA, NA, NA,
+			NA),
+	[65] = PINGROUP(65, blsp_uart2, blsp_i2c2, NA, qdss_stm5, qdss14, NA,
+			NA, NA, NA),
+	[66] = PINGROUP(66, blsp_uart2, blsp_i2c2, NA, qdss_stm4, qdss15, NA,
+			NA, NA, NA),
+	[67] = PINGROUP(67, uim1_data, NA, qdss_stm3, NA, NA, NA, NA, NA, NA),
+	[68] = PINGROUP(68, uim1_present, qdss_stm2, NA, NA, NA, NA, NA, NA,
+			NA),
+	[69] = PINGROUP(69, uim1_reset, qdss_stm1, NA, NA, NA, NA, NA, NA, NA),
+	[70] = PINGROUP(70, uim1_clk, NA, qdss_stm0, NA, NA, NA, NA, NA, NA),
+	[71] = PINGROUP(71, mgpi_clk, blsp_spi1, blsp_spi2, blsp_spi3,
+			blsp_spi4, dbg_out, NA, NA, NA),
+	[72] = PINGROUP(72, NA, blsp_spi1, NA, NA, NA, NA, NA, NA, NA),
+	[73] = PINGROUP(73, NA, blsp_spi1, NA, gcc_plltest, NA, NA, NA, NA, NA),
+	[74] = PINGROUP(74, NA, blsp_spi1, NA, blsp_i2c1, gcc_plltest, NA, NA,
+			NA, NA),
+	[75] = PINGROUP(75, NA, blsp_spi1, NA, blsp_i2c1, NA, NA, NA, NA, NA),
+	[76] = PINGROUP(76, blsp_i2c4, NA, NA, NA, NA, NA, NA, NA, NA),
+	[77] = PINGROUP(77, blsp_i2c4, NA, NA, NA, NA, NA, NA, NA, NA),
+	[78] = PINGROUP(78, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[79] = PINGROUP(79, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[80] = PINGROUP(80, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[81] = PINGROUP(81, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[82] = PINGROUP(82, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[83] = PINGROUP(83, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[84] = PINGROUP(84, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[85] = PINGROUP(85, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[86] = PINGROUP(86, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[87] = PINGROUP(87, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[88] = PINGROUP(88, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[89] = PINGROUP(89, qdss_cti, qdss_cti, NA, NA, NA, NA, NA, NA, NA),
+	[90] = PINGROUP(90, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[91] = PINGROUP(91, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[92] = PINGROUP(92, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[93] = PINGROUP(93, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[94] = PINGROUP(94, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[95] = PINGROUP(95, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[96] = PINGROUP(96, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[97] = PINGROUP(97, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[98] = PINGROUP(98, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[99] = PINGROUP(99, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	[100] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x9a000, 15, 0),
+	[101] = SDC_QDSD_PINGROUP(sdc1_clk, 0x9a000, 13, 6),
+	[102] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x9a000, 11, 3),
+	[103] = SDC_QDSD_PINGROUP(sdc1_data, 0x9a000, 9, 0),
+	[104] = SDC_QDSD_PINGROUP(sdc2_clk, 0x0, 14, 6),
+	[105] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x0, 11, 3),
+	[106] = SDC_QDSD_PINGROUP(sdc2_data, 0x0, 9, 0),
 };
 
 static const struct msm_pinctrl_soc_data sdxpoorwills_pinctrl = {
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
index f06fb1f..2ecbd22 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014, 2016-2017 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -471,6 +471,7 @@
 
 	pad = pctldev->desc->pins[pin].drv_data;
 
+	pad->is_enabled = true;
 	for (i = 0; i < nconfs; i++) {
 		param = pinconf_to_config_param(configs[i]);
 		arg = pinconf_to_config_argument(configs[i]);
@@ -619,6 +620,10 @@
 			return ret;
 	}
 
+	val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT;
+
+	ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val);
+
 	return ret;
 }
 
diff --git a/drivers/pinctrl/qcom/pinctrl-wcd.c b/drivers/pinctrl/qcom/pinctrl-wcd.c
deleted file mode 100644
index 2cc68a0..0000000
--- a/drivers/pinctrl/qcom/pinctrl-wcd.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/gpio.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/pinctrl/pinconf-generic.h>
-#include <linux/pinctrl/pinconf.h>
-#include <linux/pinctrl/pinmux.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/mfd/wcd934x/registers.h>
-
-#include "../core.h"
-#include "../pinctrl-utils.h"
-
-#define WCD_REG_DIR_CTL WCD934X_CHIP_TIER_CTRL_GPIO_CTL_OE
-#define WCD_REG_VAL_CTL WCD934X_CHIP_TIER_CTRL_GPIO_CTL_DATA
-#define WCD_GPIO_PULL_UP       1
-#define WCD_GPIO_PULL_DOWN     2
-#define WCD_GPIO_BIAS_DISABLE  3
-#define WCD_GPIO_STRING_LEN    20
-
-/**
- * struct wcd_gpio_pad - keep current GPIO settings
- * @offset: offset of gpio.
- * @is_valid: Set to false, when GPIO in high Z state.
- * @value: value of a pin
- * @output_enabled: Set to true if GPIO is output and false if it is input
- * @pullup: Constant current which flow through GPIO output buffer.
- * @strength: Drive strength of a pin
- */
-struct wcd_gpio_pad {
-	u16  offset;
-	bool is_valid;
-	bool value;
-	bool output_enabled;
-	unsigned int pullup;
-	unsigned int strength;
-};
-
-struct wcd_gpio_priv {
-	struct device *dev;
-	struct regmap *map;
-	struct pinctrl_dev *ctrl;
-	struct gpio_chip chip;
-};
-
-static int wcd_gpio_read(struct wcd_gpio_priv *priv_data,
-			  struct wcd_gpio_pad *pad, unsigned int addr)
-{
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(priv_data->map, addr, &val);
-	if (ret < 0)
-		dev_err(priv_data->dev, "%s: read 0x%x failed\n",
-			__func__, addr);
-	else
-		ret = (val >> pad->offset);
-
-	return ret;
-}
-
-static int wcd_gpio_write(struct wcd_gpio_priv *priv_data,
-			   struct wcd_gpio_pad *pad, unsigned int addr,
-			   unsigned int val)
-{
-	int ret;
-
-	ret = regmap_update_bits(priv_data->map, addr, (1 << pad->offset),
-					val << pad->offset);
-	if (ret < 0)
-		dev_err(priv_data->dev, "write 0x%x failed\n", addr);
-
-	return ret;
-}
-
-static int wcd_get_groups_count(struct pinctrl_dev *pctldev)
-{
-	return pctldev->desc->npins;
-}
-
-static const char *wcd_get_group_name(struct pinctrl_dev *pctldev,
-		unsigned int pin)
-{
-	return pctldev->desc->pins[pin].name;
-}
-
-static int wcd_get_group_pins(struct pinctrl_dev *pctldev, unsigned int pin,
-		const unsigned int **pins, unsigned int *num_pins)
-{
-	*pins = &pctldev->desc->pins[pin].number;
-	*num_pins = 1;
-	return 0;
-}
-
-static const struct pinctrl_ops wcd_pinctrl_ops = {
-	.get_groups_count       = wcd_get_groups_count,
-	.get_group_name         = wcd_get_group_name,
-	.get_group_pins         = wcd_get_group_pins,
-	.dt_node_to_map         = pinconf_generic_dt_node_to_map_group,
-	.dt_free_map            = pinctrl_utils_free_map,
-};
-
-static int wcd_config_get(struct pinctrl_dev *pctldev,
-				unsigned int pin, unsigned long *config)
-{
-	unsigned int param = pinconf_to_config_param(*config);
-	struct wcd_gpio_pad *pad;
-	unsigned int arg;
-
-	pad = pctldev->desc->pins[pin].drv_data;
-
-	switch (param) {
-	case PIN_CONFIG_BIAS_PULL_DOWN:
-		arg = pad->pullup == WCD_GPIO_PULL_DOWN;
-		break;
-	case PIN_CONFIG_BIAS_DISABLE:
-		arg = pad->pullup = WCD_GPIO_BIAS_DISABLE;
-		break;
-	case PIN_CONFIG_BIAS_PULL_UP:
-		arg = pad->pullup == WCD_GPIO_PULL_UP;
-		break;
-	case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
-		arg = !pad->is_valid;
-		break;
-	case PIN_CONFIG_INPUT_ENABLE:
-		arg = pad->output_enabled;
-		break;
-	case PIN_CONFIG_OUTPUT:
-		arg = pad->value;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	*config = pinconf_to_config_packed(param, arg);
-	return 0;
-}
-
-static int wcd_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
-				unsigned long *configs, unsigned int nconfs)
-{
-	struct wcd_gpio_priv *priv_data = pinctrl_dev_get_drvdata(pctldev);
-	struct wcd_gpio_pad *pad;
-	unsigned int param, arg;
-	int i, ret;
-
-	pad = pctldev->desc->pins[pin].drv_data;
-
-	for (i = 0; i < nconfs; i++) {
-		param = pinconf_to_config_param(configs[i]);
-		arg = pinconf_to_config_argument(configs[i]);
-
-		dev_dbg(priv_data->dev, "%s: param: %d arg: %d",
-			__func__, param, arg);
-
-		switch (param) {
-		case PIN_CONFIG_BIAS_DISABLE:
-			pad->pullup = WCD_GPIO_BIAS_DISABLE;
-			break;
-		case PIN_CONFIG_BIAS_PULL_UP:
-			pad->pullup = WCD_GPIO_PULL_UP;
-			break;
-		case PIN_CONFIG_BIAS_PULL_DOWN:
-			pad->pullup = WCD_GPIO_PULL_DOWN;
-			break;
-		case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
-			pad->is_valid = false;
-			break;
-		case PIN_CONFIG_INPUT_ENABLE:
-			pad->output_enabled = false;
-			break;
-		case PIN_CONFIG_OUTPUT:
-			pad->output_enabled = true;
-			pad->value = arg;
-			break;
-		case PIN_CONFIG_DRIVE_STRENGTH:
-			pad->strength = arg;
-			break;
-		default:
-			ret = -EINVAL;
-			goto done;
-		}
-	}
-
-	if (pad->output_enabled) {
-		ret = wcd_gpio_write(priv_data, pad, WCD_REG_DIR_CTL,
-				     pad->output_enabled);
-		if (ret < 0)
-			goto done;
-		ret = wcd_gpio_write(priv_data, pad, WCD_REG_VAL_CTL,
-				     pad->value);
-	} else
-		ret = wcd_gpio_write(priv_data, pad, WCD_REG_DIR_CTL,
-				     pad->output_enabled);
-done:
-	return ret;
-}
-
-static const struct pinconf_ops wcd_pinconf_ops = {
-	.is_generic  = true,
-	.pin_config_group_get = wcd_config_get,
-	.pin_config_group_set = wcd_config_set,
-};
-
-static int wcd_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
-{
-	struct wcd_gpio_priv *priv_data = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1);
-
-	return wcd_config_set(priv_data->ctrl, pin, &config, 1);
-}
-
-static int wcd_gpio_direction_output(struct gpio_chip *chip,
-				      unsigned int pin, int val)
-{
-	struct wcd_gpio_priv *priv_data = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val);
-
-	return wcd_config_set(priv_data->ctrl, pin, &config, 1);
-}
-
-static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin)
-{
-	struct wcd_gpio_priv *priv_data = gpiochip_get_data(chip);
-	struct wcd_gpio_pad *pad;
-	int value;
-
-	pad = priv_data->ctrl->desc->pins[pin].drv_data;
-
-	if (!pad->is_valid)
-		return -EINVAL;
-
-	value = wcd_gpio_read(priv_data, pad, WCD_REG_VAL_CTL);
-	return value;
-}
-
-static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int value)
-{
-	struct wcd_gpio_priv *priv_data = gpiochip_get_data(chip);
-	unsigned long config;
-
-	config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value);
-
-	wcd_config_set(priv_data->ctrl, pin, &config, 1);
-}
-
-static const struct gpio_chip wcd_gpio_chip = {
-	.direction_input  = wcd_gpio_direction_input,
-	.direction_output = wcd_gpio_direction_output,
-	.get = wcd_gpio_get,
-	.set = wcd_gpio_set,
-};
-
-static int wcd_pinctrl_probe(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct pinctrl_pin_desc *pindesc;
-	struct pinctrl_desc *pctrldesc;
-	struct wcd_gpio_pad *pad, *pads;
-	struct wcd_gpio_priv *priv_data;
-	int ret, i, j;
-	u32 npins;
-	char **name;
-
-	ret = of_property_read_u32(dev->of_node, "qcom,num-gpios", &npins);
-	if (ret) {
-		dev_err(dev, "%s: Looking up %s property in node %s failed\n",
-			__func__, "qcom,num-gpios", dev->of_node->full_name);
-		ret = -EINVAL;
-		goto err_priv_alloc;
-	}
-	if (!npins) {
-		dev_err(dev, "%s: no.of pins are 0\n", __func__);
-		ret = -EINVAL;
-		goto err_priv_alloc;
-	}
-
-	priv_data = devm_kzalloc(dev, sizeof(*priv_data), GFP_KERNEL);
-	if (!priv_data) {
-		ret = -ENOMEM;
-		goto err_priv_alloc;
-	}
-
-	priv_data->dev = dev;
-	priv_data->map = dev_get_regmap(dev->parent, NULL);
-	if (!priv_data->map) {
-		dev_err(dev, "%s: failed to get regmap\n", __func__);
-		ret = -EINVAL;
-		goto err_regmap;
-	}
-
-	pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL);
-	if (!pindesc) {
-		ret = -ENOMEM;
-		goto err_pinsec_alloc;
-	}
-
-	pads = devm_kcalloc(dev, npins, sizeof(*pads), GFP_KERNEL);
-	if (!pads) {
-		ret = -ENOMEM;
-		goto err_pads_alloc;
-	}
-
-	pctrldesc = devm_kzalloc(dev, sizeof(*pctrldesc), GFP_KERNEL);
-	if (!pctrldesc) {
-		ret = -ENOMEM;
-		goto err_pinctrl_alloc;
-	}
-
-	pctrldesc->pctlops = &wcd_pinctrl_ops;
-	pctrldesc->confops = &wcd_pinconf_ops;
-	pctrldesc->owner = THIS_MODULE;
-	pctrldesc->name = dev_name(dev);
-	pctrldesc->pins = pindesc;
-	pctrldesc->npins = npins;
-
-	name = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
-	if (!name) {
-		ret = -ENOMEM;
-		goto err_name_alloc;
-	}
-	for (i = 0; i < npins; i++, pindesc++) {
-		name[i] = devm_kzalloc(dev, sizeof(char) * WCD_GPIO_STRING_LEN,
-				       GFP_KERNEL);
-		if (!name[i]) {
-			ret = -ENOMEM;
-			goto err_pin;
-		}
-		pad = &pads[i];
-		pindesc->drv_data = pad;
-		pindesc->number = i;
-		snprintf(name[i], (WCD_GPIO_STRING_LEN - 1), "gpio%d", (i+1));
-		pindesc->name = name[i];
-		pad->offset = i;
-		pad->is_valid  = true;
-	}
-
-	priv_data->chip = wcd_gpio_chip;
-	priv_data->chip.parent = dev;
-	priv_data->chip.base = -1;
-	priv_data->chip.ngpio = npins;
-	priv_data->chip.label = dev_name(dev);
-	priv_data->chip.of_gpio_n_cells = 2;
-	priv_data->chip.can_sleep = false;
-
-	priv_data->ctrl = devm_pinctrl_register(dev, pctrldesc, priv_data);
-	if (IS_ERR(priv_data->ctrl)) {
-		dev_err(dev, "%s: failed to register to pinctrl\n", __func__);
-		ret = PTR_ERR(priv_data->ctrl);
-		goto err_pin;
-	}
-
-	ret = gpiochip_add_data(&priv_data->chip, priv_data);
-	if (ret) {
-		dev_err(dev, "%s: can't add gpio chip\n", __func__);
-		goto err_pin;
-	}
-
-	ret = gpiochip_add_pin_range(&priv_data->chip, dev_name(dev), 0, 0,
-				     npins);
-	if (ret) {
-		dev_err(dev, "%s: failed to add pin range\n", __func__);
-		goto err_range;
-	}
-	platform_set_drvdata(pdev, priv_data);
-
-	return 0;
-
-err_range:
-	gpiochip_remove(&priv_data->chip);
-err_pin:
-	for (j = 0; j < i; j++)
-		devm_kfree(dev, name[j]);
-	devm_kfree(dev, name);
-err_name_alloc:
-	devm_kfree(dev, pctrldesc);
-err_pinctrl_alloc:
-	devm_kfree(dev, pads);
-err_pads_alloc:
-	devm_kfree(dev, pindesc);
-err_pinsec_alloc:
-err_regmap:
-	devm_kfree(dev, priv_data);
-err_priv_alloc:
-	return ret;
-}
-
-static int wcd_pinctrl_remove(struct platform_device *pdev)
-{
-	struct wcd_gpio_priv *priv_data = platform_get_drvdata(pdev);
-
-	gpiochip_remove(&priv_data->chip);
-
-	return 0;
-}
-
-static const struct of_device_id wcd_pinctrl_of_match[] = {
-	{ .compatible = "qcom,wcd-pinctrl" },
-	{ },
-};
-
-MODULE_DEVICE_TABLE(of, wcd_pinctrl_of_match);
-
-static struct platform_driver wcd_pinctrl_driver = {
-	.driver = {
-		   .name = "qcom-wcd-pinctrl",
-		   .of_match_table = wcd_pinctrl_of_match,
-	},
-	.probe = wcd_pinctrl_probe,
-	.remove = wcd_pinctrl_remove,
-};
-
-module_platform_driver(wcd_pinctrl_driver);
-
-MODULE_DESCRIPTION("Qualcomm Technologies, Inc WCD GPIO pin control driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index d32fa2b..e8aee6d 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -195,8 +195,6 @@
 
 	spin_unlock_irqrestore(&bank->slock, flags);
 
-	exynos_irq_unmask(irqd);
-
 	return 0;
 }
 
@@ -217,8 +215,6 @@
 	shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC];
 	mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
 
-	exynos_irq_mask(irqd);
-
 	spin_lock_irqsave(&bank->slock, flags);
 
 	con = readl(d->virt_base + reg_con);
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
index 862a096..be5c71d 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
@@ -811,6 +811,7 @@
 		  SUNXI_FUNCTION(0x2, "lcd1"),		/* D16 */
 		  SUNXI_FUNCTION(0x3, "pata"),		/* ATAD12 */
 		  SUNXI_FUNCTION(0x4, "keypad"),	/* IN6 */
+		  SUNXI_FUNCTION(0x5, "sim"),		/* DET */
 		  SUNXI_FUNCTION_IRQ(0x6, 16),		/* EINT16 */
 		  SUNXI_FUNCTION(0x7, "csi1")),		/* D16 */
 	SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 17),
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
index 77a0236..b190904 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
@@ -508,57 +508,71 @@
 static const int usb1_muxvals[] = {0, 0};
 static const unsigned usb2_pins[] = {50, 51};
 static const int usb2_muxvals[] = {0, 0};
-static const unsigned port_range_pins[] = {
+static const unsigned port_range0_pins[] = {
 	159, 160, 161, 162, 163, 164, 165, 166,		/* PORT0x */
 	0, 1, 2, 3, 4, 5, 6, 7,				/* PORT1x */
 	8, 9, 10, 11, 12, 13, 14, 15,			/* PORT2x */
-	16, 17, 18, -1, -1, -1, -1, -1,			/* PORT3x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT4x */
-	-1, -1, -1, 46, 47, 48, 49, 50,			/* PORT5x */
-	51, -1, -1, 54, 55, 56, 57, 58,			/* PORT6x */
+	16, 17, 18,					/* PORT30-32 */
+};
+static const int port_range0_muxvals[] = {
+	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT0x */
+	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT1x */
+	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT2x */
+	15, 15, 15,					/* PORT30-32 */
+};
+static const unsigned port_range1_pins[] = {
+	46, 47, 48, 49, 50,				/* PORT53-57 */
+	51,						/* PORT60 */
+};
+static const int port_range1_muxvals[] = {
+	15, 15, 15, 15, 15,				/* PORT53-57 */
+	15,						/* PORT60 */
+};
+static const unsigned port_range2_pins[] = {
+	54, 55, 56, 57, 58,				/* PORT63-67 */
 	59, 60, 69, 70, 71, 72, 73, 74,			/* PORT7x */
 	75, 76, 77, 78, 79, 80, 81, 82,			/* PORT8x */
 	83, 84, 85, 86, 87, 88, 89, 90,			/* PORT9x */
 	91, 92, 93, 94, 95, 96, 97, 98,			/* PORT10x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT11x */
-	99, 100, 101, 102, 103, 104, 105, 106,		/* PORT12x */
-	107, 108, 109, 110, 111, 112, 113, 114,		/* PORT13x */
-	115, 116, 117, 118, 119, 120, 121, 122,		/* PORT14x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT15x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT16x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT17x */
-	61, 62, 63, 64, 65, 66, 67, 68,			/* PORT18x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT19x */
-	123, 124, 125, 126, 127, 128, 129, 130,		/* PORT20x */
-	131, 132, 133, 134, 135, 136, 137, 138,		/* PORT21x */
-	139, 140, 141, 142, -1, -1, -1, -1,		/* PORT22x */
-	147, 148, 149, 150, 151, 152, 153, 154,		/* PORT23x */
-	155, 156, 157, 143, 144, 145, 146, 158,		/* PORT24x */
 };
-static const int port_range_muxvals[] = {
-	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT0x */
-	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT1x */
-	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT2x */
-	15, 15, 15, -1, -1, -1, -1, -1,			/* PORT3x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT4x */
-	-1, -1, -1, 15, 15, 15, 15, 15,			/* PORT5x */
-	15, -1, -1, 15, 15, 15, 15, 15,			/* PORT6x */
+static const int port_range2_muxvals[] = {
+	15, 15, 15, 15, 15,				/* PORT63-67 */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT7x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT8x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT9x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT10x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT11x */
+};
+static const unsigned port_range3_pins[] = {
+	99, 100, 101, 102, 103, 104, 105, 106,		/* PORT12x */
+	107, 108, 109, 110, 111, 112, 113, 114,		/* PORT13x */
+	115, 116, 117, 118, 119, 120, 121, 122,		/* PORT14x */
+};
+static const int port_range3_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT12x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT13x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT14x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT15x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT16x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT17x */
+};
+static const unsigned port_range4_pins[] = {
+	61, 62, 63, 64, 65, 66, 67, 68,			/* PORT18x */
+};
+static const int port_range4_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT18x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT19x */
+};
+static const unsigned port_range5_pins[] = {
+	123, 124, 125, 126, 127, 128, 129, 130,		/* PORT20x */
+	131, 132, 133, 134, 135, 136, 137, 138,		/* PORT21x */
+	139, 140, 141, 142,				/* PORT220-223 */
+};
+static const int port_range5_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT20x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT21x */
-	15, 15, 15, 15, -1, -1, -1, -1,			/* PORT22x */
+	15, 15, 15, 15,					/* PORT220-223 */
+};
+static const unsigned port_range6_pins[] = {
+	147, 148, 149, 150, 151, 152, 153, 154,		/* PORT23x */
+	155, 156, 157, 143, 144, 145, 146, 158,		/* PORT24x */
+};
+static const int port_range6_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT23x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT24x */
 };
@@ -607,147 +621,153 @@
 	UNIPHIER_PINCTRL_GROUP(usb0),
 	UNIPHIER_PINCTRL_GROUP(usb1),
 	UNIPHIER_PINCTRL_GROUP(usb2),
-	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range0),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range1),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range2),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range3),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range4),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range5),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range6),
 	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_IRQ(xirq),
 	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_IRQ(xirq_alternatives),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port00, port_range, 0),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port01, port_range, 1),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port02, port_range, 2),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port03, port_range, 3),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port04, port_range, 4),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port05, port_range, 5),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port06, port_range, 6),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port07, port_range, 7),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port10, port_range, 8),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port11, port_range, 9),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port12, port_range, 10),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port13, port_range, 11),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port14, port_range, 12),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port15, port_range, 13),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port16, port_range, 14),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port17, port_range, 15),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port20, port_range, 16),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port21, port_range, 17),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port22, port_range, 18),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port23, port_range, 19),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port24, port_range, 20),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port25, port_range, 21),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port26, port_range, 22),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port27, port_range, 23),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port30, port_range, 24),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port31, port_range, 25),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port32, port_range, 26),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port53, port_range, 43),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port54, port_range, 44),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port55, port_range, 45),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port56, port_range, 46),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port57, port_range, 47),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port60, port_range, 48),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port63, port_range, 51),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port64, port_range, 52),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port65, port_range, 53),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port66, port_range, 54),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port67, port_range, 55),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port70, port_range, 56),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port71, port_range, 57),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port72, port_range, 58),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port73, port_range, 59),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port74, port_range, 60),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port75, port_range, 61),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port76, port_range, 62),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port77, port_range, 63),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port80, port_range, 64),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port81, port_range, 65),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port82, port_range, 66),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port83, port_range, 67),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port84, port_range, 68),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port85, port_range, 69),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port86, port_range, 70),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port87, port_range, 71),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port90, port_range, 72),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port91, port_range, 73),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port92, port_range, 74),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port93, port_range, 75),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port94, port_range, 76),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port95, port_range, 77),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port96, port_range, 78),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port97, port_range, 79),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port100, port_range, 80),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port101, port_range, 81),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port102, port_range, 82),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port103, port_range, 83),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port104, port_range, 84),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port105, port_range, 85),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port106, port_range, 86),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port107, port_range, 87),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port120, port_range, 96),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port121, port_range, 97),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port122, port_range, 98),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port123, port_range, 99),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port124, port_range, 100),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port125, port_range, 101),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port126, port_range, 102),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port127, port_range, 103),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port130, port_range, 104),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port131, port_range, 105),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port132, port_range, 106),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port133, port_range, 107),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port134, port_range, 108),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port135, port_range, 109),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port136, port_range, 110),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port137, port_range, 111),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port140, port_range, 112),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port141, port_range, 113),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port142, port_range, 114),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port143, port_range, 115),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port144, port_range, 116),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port145, port_range, 117),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port146, port_range, 118),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port147, port_range, 119),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port180, port_range, 144),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port181, port_range, 145),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port182, port_range, 146),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port183, port_range, 147),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port184, port_range, 148),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port185, port_range, 149),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port186, port_range, 150),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port187, port_range, 151),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port200, port_range, 160),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port201, port_range, 161),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port202, port_range, 162),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port203, port_range, 163),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port204, port_range, 164),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port205, port_range, 165),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port206, port_range, 166),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port207, port_range, 167),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port210, port_range, 168),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port211, port_range, 169),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port212, port_range, 170),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port213, port_range, 171),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port214, port_range, 172),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port215, port_range, 173),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port216, port_range, 174),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port217, port_range, 175),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port220, port_range, 176),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port221, port_range, 177),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port222, port_range, 178),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port223, port_range, 179),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port230, port_range, 184),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port231, port_range, 185),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port232, port_range, 186),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port233, port_range, 187),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port234, port_range, 188),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port235, port_range, 189),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port236, port_range, 190),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port237, port_range, 191),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port240, port_range, 192),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port241, port_range, 193),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port242, port_range, 194),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port243, port_range, 195),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port244, port_range, 196),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port245, port_range, 197),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port246, port_range, 198),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port247, port_range, 199),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port00, port_range0, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port01, port_range0, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port02, port_range0, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port03, port_range0, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port04, port_range0, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port05, port_range0, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port06, port_range0, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port07, port_range0, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port10, port_range0, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port11, port_range0, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port12, port_range0, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port13, port_range0, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port14, port_range0, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port15, port_range0, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port16, port_range0, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port17, port_range0, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port20, port_range0, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port21, port_range0, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port22, port_range0, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port23, port_range0, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port24, port_range0, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port25, port_range0, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port26, port_range0, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port27, port_range0, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port30, port_range0, 24),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port31, port_range0, 25),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port32, port_range0, 26),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port53, port_range1, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port54, port_range1, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port55, port_range1, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port56, port_range1, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port57, port_range1, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port60, port_range1, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port63, port_range2, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port64, port_range2, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port65, port_range2, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port66, port_range2, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port67, port_range2, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port70, port_range2, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port71, port_range2, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port72, port_range2, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port73, port_range2, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port74, port_range2, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port75, port_range2, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port76, port_range2, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port77, port_range2, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port80, port_range2, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port81, port_range2, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port82, port_range2, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port83, port_range2, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port84, port_range2, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port85, port_range2, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port86, port_range2, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port87, port_range2, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port90, port_range2, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port91, port_range2, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port92, port_range2, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port93, port_range2, 24),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port94, port_range2, 25),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port95, port_range2, 26),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port96, port_range2, 27),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port97, port_range2, 28),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port100, port_range2, 29),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port101, port_range2, 30),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port102, port_range2, 31),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port103, port_range2, 32),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port104, port_range2, 33),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port105, port_range2, 34),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port106, port_range2, 35),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port107, port_range2, 36),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port120, port_range3, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port121, port_range3, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port122, port_range3, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port123, port_range3, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port124, port_range3, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port125, port_range3, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port126, port_range3, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port127, port_range3, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port130, port_range3, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port131, port_range3, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port132, port_range3, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port133, port_range3, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port134, port_range3, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port135, port_range3, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port136, port_range3, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port137, port_range3, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port140, port_range3, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port141, port_range3, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port142, port_range3, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port143, port_range3, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port144, port_range3, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port145, port_range3, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port146, port_range3, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port147, port_range3, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port180, port_range4, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port181, port_range4, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port182, port_range4, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port183, port_range4, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port184, port_range4, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port185, port_range4, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port186, port_range4, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port187, port_range4, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port200, port_range5, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port201, port_range5, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port202, port_range5, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port203, port_range5, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port204, port_range5, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port205, port_range5, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port206, port_range5, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port207, port_range5, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port210, port_range5, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port211, port_range5, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port212, port_range5, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port213, port_range5, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port214, port_range5, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port215, port_range5, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port216, port_range5, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port217, port_range5, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port220, port_range5, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port221, port_range5, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port222, port_range5, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port223, port_range5, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port230, port_range6, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port231, port_range6, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port232, port_range6, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port233, port_range6, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port234, port_range6, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port235, port_range6, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port236, port_range6, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port237, port_range6, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port240, port_range6, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port241, port_range6, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port242, port_range6, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port243, port_range6, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port244, port_range6, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port245, port_range6, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port246, port_range6, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port247, port_range6, 15),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq0, xirq, 0),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq1, xirq, 1),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq2, xirq, 2),
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
index 9668633..73b828b 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
@@ -597,7 +597,7 @@
 static const int usb2_muxvals[] = {0, 0};
 static const unsigned usb3_pins[] = {52, 53};
 static const int usb3_muxvals[] = {0, 0};
-static const unsigned port_range_pins[] = {
+static const unsigned port_range0_pins[] = {
 	168, 169, 170, 171, 172, 173, 174, 175,		/* PORT0x */
 	0, 1, 2, 3, 4, 5, 6, 7,				/* PORT1x */
 	8, 9, 10, 11, 12, 13, 14, 15,			/* PORT2x */
@@ -609,23 +609,8 @@
 	75, 76, 77, 78, 79, 80, 81, 82,			/* PORT8x */
 	83, 84, 85, 86, 87, 88, 89, 90,			/* PORT9x */
 	91, 92, 93, 94, 95, 96, 97, 98,			/* PORT10x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT11x */
-	99, 100, 101, 102, 103, 104, 105, 106,		/* PORT12x */
-	107, 108, 109, 110, 111, 112, 113, 114,		/* PORT13x */
-	115, 116, 117, 118, 119, 120, 121, 122,		/* PORT14x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT15x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT16x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT17x */
-	61, 62, 63, 64, 65, 66, 67, 68,			/* PORT18x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT19x */
-	123, 124, 125, 126, 127, 128, 129, 130,		/* PORT20x */
-	131, 132, 133, 134, 135, 136, 137, 138,		/* PORT21x */
-	139, 140, 141, 142, 143, 144, 145, 146,		/* PORT22x */
-	147, 148, 149, 150, 151, 152, 153, 154,		/* PORT23x */
-	155, 156, 157, 158, 159, 160, 161, 162,		/* PORT24x */
-	163, 164, 165, 166, 167,			/* PORT25x */
 };
-static const int port_range_muxvals[] = {
+static const int port_range0_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT0x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT1x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT2x */
@@ -637,21 +622,38 @@
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT8x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT9x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT10x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT11x */
+};
+static const unsigned port_range1_pins[] = {
+	99, 100, 101, 102, 103, 104, 105, 106,		/* PORT12x */
+	107, 108, 109, 110, 111, 112, 113, 114,		/* PORT13x */
+	115, 116, 117, 118, 119, 120, 121, 122,		/* PORT14x */
+};
+static const int port_range1_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT12x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT13x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT14x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT15x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT16x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT17x */
+};
+static const unsigned port_range2_pins[] = {
+	61, 62, 63, 64, 65, 66, 67, 68,			/* PORT18x */
+};
+static const int port_range2_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT18x */
-	-1, -1, -1, -1, -1, -1, -1, -1,			/* PORT19x */
+};
+static const unsigned port_range3_pins[] = {
+	123, 124, 125, 126, 127, 128, 129, 130,		/* PORT20x */
+	131, 132, 133, 134, 135, 136, 137, 138,		/* PORT21x */
+	139, 140, 141, 142, 143, 144, 145, 146,		/* PORT22x */
+	147, 148, 149, 150, 151, 152, 153, 154,		/* PORT23x */
+	155, 156, 157, 158, 159, 160, 161, 162,		/* PORT24x */
+	163, 164, 165, 166, 167,			/* PORT250-254 */
+};
+static const int port_range3_muxvals[] = {
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT20x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT21x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT22x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT23x */
 	15, 15, 15, 15, 15, 15, 15, 15,			/* PORT24x */
-	15, 15, 15, 15, 15,				/* PORT25x */
+	15, 15, 15, 15, 15,				/* PORT250-254 */
 };
 static const unsigned xirq_pins[] = {
 	149, 150, 151, 152, 153, 154, 155, 156,		/* XIRQ0-7 */
@@ -695,174 +697,177 @@
 	UNIPHIER_PINCTRL_GROUP(usb1),
 	UNIPHIER_PINCTRL_GROUP(usb2),
 	UNIPHIER_PINCTRL_GROUP(usb3),
-	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range0),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range1),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range2),
+	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_PORT(port_range3),
 	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_IRQ(xirq),
 	UNIPHIER_PINCTRL_GROUP_GPIO_RANGE_IRQ(xirq_alternatives),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port00, port_range, 0),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port01, port_range, 1),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port02, port_range, 2),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port03, port_range, 3),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port04, port_range, 4),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port05, port_range, 5),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port06, port_range, 6),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port07, port_range, 7),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port10, port_range, 8),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port11, port_range, 9),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port12, port_range, 10),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port13, port_range, 11),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port14, port_range, 12),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port15, port_range, 13),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port16, port_range, 14),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port17, port_range, 15),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port20, port_range, 16),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port21, port_range, 17),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port22, port_range, 18),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port23, port_range, 19),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port24, port_range, 20),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port25, port_range, 21),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port26, port_range, 22),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port27, port_range, 23),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port30, port_range, 24),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port31, port_range, 25),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port32, port_range, 26),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port33, port_range, 27),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port34, port_range, 28),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port35, port_range, 29),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port36, port_range, 30),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port37, port_range, 31),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port40, port_range, 32),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port41, port_range, 33),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port42, port_range, 34),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port43, port_range, 35),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port44, port_range, 36),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port45, port_range, 37),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port46, port_range, 38),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port47, port_range, 39),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port50, port_range, 40),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port51, port_range, 41),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port52, port_range, 42),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port53, port_range, 43),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port54, port_range, 44),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port55, port_range, 45),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port56, port_range, 46),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port57, port_range, 47),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port60, port_range, 48),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port61, port_range, 49),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port62, port_range, 50),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port63, port_range, 51),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port64, port_range, 52),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port65, port_range, 53),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port66, port_range, 54),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port67, port_range, 55),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port70, port_range, 56),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port71, port_range, 57),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port72, port_range, 58),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port73, port_range, 59),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port74, port_range, 60),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port75, port_range, 61),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port76, port_range, 62),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port77, port_range, 63),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port80, port_range, 64),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port81, port_range, 65),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port82, port_range, 66),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port83, port_range, 67),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port84, port_range, 68),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port85, port_range, 69),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port86, port_range, 70),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port87, port_range, 71),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port90, port_range, 72),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port91, port_range, 73),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port92, port_range, 74),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port93, port_range, 75),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port94, port_range, 76),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port95, port_range, 77),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port96, port_range, 78),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port97, port_range, 79),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port100, port_range, 80),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port101, port_range, 81),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port102, port_range, 82),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port103, port_range, 83),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port104, port_range, 84),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port105, port_range, 85),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port106, port_range, 86),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port107, port_range, 87),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port120, port_range, 96),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port121, port_range, 97),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port122, port_range, 98),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port123, port_range, 99),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port124, port_range, 100),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port125, port_range, 101),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port126, port_range, 102),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port127, port_range, 103),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port130, port_range, 104),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port131, port_range, 105),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port132, port_range, 106),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port133, port_range, 107),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port134, port_range, 108),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port135, port_range, 109),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port136, port_range, 110),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port137, port_range, 111),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port140, port_range, 112),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port141, port_range, 113),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port142, port_range, 114),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port143, port_range, 115),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port144, port_range, 116),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port145, port_range, 117),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port146, port_range, 118),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port147, port_range, 119),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port180, port_range, 144),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port181, port_range, 145),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port182, port_range, 146),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port183, port_range, 147),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port184, port_range, 148),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port185, port_range, 149),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port186, port_range, 150),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port187, port_range, 151),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port200, port_range, 160),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port201, port_range, 161),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port202, port_range, 162),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port203, port_range, 163),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port204, port_range, 164),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port205, port_range, 165),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port206, port_range, 166),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port207, port_range, 167),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port210, port_range, 168),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port211, port_range, 169),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port212, port_range, 170),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port213, port_range, 171),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port214, port_range, 172),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port215, port_range, 173),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port216, port_range, 174),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port217, port_range, 175),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port220, port_range, 176),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port221, port_range, 177),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port222, port_range, 178),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port223, port_range, 179),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port224, port_range, 180),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port225, port_range, 181),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port226, port_range, 182),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port227, port_range, 183),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port230, port_range, 184),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port231, port_range, 185),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port232, port_range, 186),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port233, port_range, 187),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port234, port_range, 188),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port235, port_range, 189),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port236, port_range, 190),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port237, port_range, 191),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port240, port_range, 192),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port241, port_range, 193),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port242, port_range, 194),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port243, port_range, 195),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port244, port_range, 196),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port245, port_range, 197),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port246, port_range, 198),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port247, port_range, 199),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port250, port_range, 200),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port251, port_range, 201),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port252, port_range, 202),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port253, port_range, 203),
-	UNIPHIER_PINCTRL_GROUP_SINGLE(port254, port_range, 204),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port00, port_range0, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port01, port_range0, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port02, port_range0, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port03, port_range0, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port04, port_range0, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port05, port_range0, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port06, port_range0, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port07, port_range0, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port10, port_range0, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port11, port_range0, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port12, port_range0, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port13, port_range0, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port14, port_range0, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port15, port_range0, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port16, port_range0, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port17, port_range0, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port20, port_range0, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port21, port_range0, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port22, port_range0, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port23, port_range0, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port24, port_range0, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port25, port_range0, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port26, port_range0, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port27, port_range0, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port30, port_range0, 24),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port31, port_range0, 25),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port32, port_range0, 26),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port33, port_range0, 27),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port34, port_range0, 28),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port35, port_range0, 29),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port36, port_range0, 30),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port37, port_range0, 31),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port40, port_range0, 32),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port41, port_range0, 33),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port42, port_range0, 34),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port43, port_range0, 35),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port44, port_range0, 36),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port45, port_range0, 37),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port46, port_range0, 38),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port47, port_range0, 39),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port50, port_range0, 40),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port51, port_range0, 41),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port52, port_range0, 42),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port53, port_range0, 43),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port54, port_range0, 44),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port55, port_range0, 45),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port56, port_range0, 46),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port57, port_range0, 47),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port60, port_range0, 48),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port61, port_range0, 49),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port62, port_range0, 50),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port63, port_range0, 51),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port64, port_range0, 52),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port65, port_range0, 53),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port66, port_range0, 54),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port67, port_range0, 55),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port70, port_range0, 56),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port71, port_range0, 57),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port72, port_range0, 58),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port73, port_range0, 59),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port74, port_range0, 60),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port75, port_range0, 61),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port76, port_range0, 62),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port77, port_range0, 63),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port80, port_range0, 64),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port81, port_range0, 65),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port82, port_range0, 66),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port83, port_range0, 67),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port84, port_range0, 68),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port85, port_range0, 69),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port86, port_range0, 70),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port87, port_range0, 71),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port90, port_range0, 72),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port91, port_range0, 73),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port92, port_range0, 74),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port93, port_range0, 75),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port94, port_range0, 76),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port95, port_range0, 77),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port96, port_range0, 78),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port97, port_range0, 79),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port100, port_range0, 80),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port101, port_range0, 81),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port102, port_range0, 82),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port103, port_range0, 83),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port104, port_range0, 84),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port105, port_range0, 85),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port106, port_range0, 86),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port107, port_range0, 87),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port120, port_range1, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port121, port_range1, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port122, port_range1, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port123, port_range1, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port124, port_range1, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port125, port_range1, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port126, port_range1, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port127, port_range1, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port130, port_range1, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port131, port_range1, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port132, port_range1, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port133, port_range1, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port134, port_range1, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port135, port_range1, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port136, port_range1, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port137, port_range1, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port140, port_range1, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port141, port_range1, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port142, port_range1, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port143, port_range1, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port144, port_range1, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port145, port_range1, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port146, port_range1, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port147, port_range1, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port180, port_range2, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port181, port_range2, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port182, port_range2, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port183, port_range2, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port184, port_range2, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port185, port_range2, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port186, port_range2, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port187, port_range2, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port200, port_range3, 0),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port201, port_range3, 1),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port202, port_range3, 2),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port203, port_range3, 3),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port204, port_range3, 4),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port205, port_range3, 5),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port206, port_range3, 6),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port207, port_range3, 7),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port210, port_range3, 8),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port211, port_range3, 9),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port212, port_range3, 10),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port213, port_range3, 11),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port214, port_range3, 12),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port215, port_range3, 13),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port216, port_range3, 14),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port217, port_range3, 15),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port220, port_range3, 16),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port221, port_range3, 17),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port222, port_range3, 18),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port223, port_range3, 19),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port224, port_range3, 20),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port225, port_range3, 21),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port226, port_range3, 22),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port227, port_range3, 23),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port230, port_range3, 24),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port231, port_range3, 25),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port232, port_range3, 26),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port233, port_range3, 27),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port234, port_range3, 28),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port235, port_range3, 29),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port236, port_range3, 30),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port237, port_range3, 31),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port240, port_range3, 32),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port241, port_range3, 33),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port242, port_range3, 34),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port243, port_range3, 35),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port244, port_range3, 36),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port245, port_range3, 37),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port246, port_range3, 38),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port247, port_range3, 39),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port250, port_range3, 40),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port251, port_range3, 41),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port252, port_range3, 42),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port253, port_range3, 43),
+	UNIPHIER_PINCTRL_GROUP_SINGLE(port254, port_range3, 44),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq0, xirq, 0),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq1, xirq, 1),
 	UNIPHIER_PINCTRL_GROUP_SINGLE(xirq2, xirq, 2),
diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c
index 7718257..c02881b 100644
--- a/drivers/platform/msm/gsi/gsi.c
+++ b/drivers/platform/msm/gsi/gsi.c
@@ -1113,13 +1113,14 @@
 	uint32_t val;
 	struct gsi_evt_ctx *ctx;
 	int res;
-	int ee = gsi_ctx->per.ee;
+	int ee;
 	unsigned long flags;
 
 	if (!gsi_ctx) {
 		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
 		return -GSI_STATUS_NODEV;
 	}
+	ee = gsi_ctx->per.ee;
 
 	if (!props || !evt_ring_hdl || dev_hdl != (uintptr_t)gsi_ctx) {
 		GSIERR("bad params props=%p dev_hdl=0x%lx evt_ring_hdl=%p\n",
@@ -1651,7 +1652,7 @@
 	struct gsi_chan_ctx *ctx;
 	uint32_t val;
 	int res;
-	int ee = gsi_ctx->per.ee;
+	int ee;
 	enum gsi_ch_cmd_opcode op = GSI_CH_ALLOCATE;
 	uint8_t erindex;
 	void **user_data;
@@ -1660,6 +1661,7 @@
 		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
 		return -GSI_STATUS_NODEV;
 	}
+	ee = gsi_ctx->per.ee;
 
 	if (!props || !chan_hdl || dev_hdl != (uintptr_t)gsi_ctx) {
 		GSIERR("bad params props=%p dev_hdl=0x%lx chan_hdl=%p\n",
@@ -2241,12 +2243,13 @@
 	unsigned long flags;
 	uint64_t rp;
 	uint64_t wp;
-	int ee = gsi_ctx->per.ee;
+	int ee;
 
 	if (!gsi_ctx) {
 		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
 		return -GSI_STATUS_NODEV;
 	}
+	ee = gsi_ctx->per.ee;
 
 	if (chan_hdl >= gsi_ctx->max_ch || !info) {
 		GSIERR("bad params chan_hdl=%lu info=%p\n", chan_hdl, info);
@@ -2311,12 +2314,13 @@
 	unsigned long flags;
 	uint64_t rp;
 	uint64_t wp;
-	int ee = gsi_ctx->per.ee;
+	int ee;
 
 	if (!gsi_ctx) {
 		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
 		return -GSI_STATUS_NODEV;
 	}
+	ee = gsi_ctx->per.ee;
 
 	if (chan_hdl >= gsi_ctx->max_ch || !is_empty) {
 		GSIERR("bad params chan_hdl=%lu is_empty=%p\n",
@@ -2500,13 +2504,14 @@
 {
 	struct gsi_chan_ctx *ctx;
 	uint64_t rp;
-	int ee = gsi_ctx->per.ee;
+	int ee;
 	unsigned long flags;
 
 	if (!gsi_ctx) {
 		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
 		return -GSI_STATUS_NODEV;
 	}
+	ee = gsi_ctx->per.ee;
 
 	if (chan_hdl >= gsi_ctx->max_ch || !notify) {
 		GSIERR("bad params chan_hdl=%lu notify=%p\n", chan_hdl, notify);
@@ -2593,15 +2598,16 @@
 	if (curr == GSI_CHAN_MODE_CALLBACK &&
 			mode == GSI_CHAN_MODE_POLL) {
 		__gsi_config_ieob_irq(gsi_ctx->per.ee, 1 << ctx->evtr->id, 0);
+		atomic_set(&ctx->poll_mode, mode);
 		ctx->stats.callback_to_poll++;
 	}
 
 	if (curr == GSI_CHAN_MODE_POLL &&
 			mode == GSI_CHAN_MODE_CALLBACK) {
+		atomic_set(&ctx->poll_mode, mode);
 		__gsi_config_ieob_irq(gsi_ctx->per.ee, 1 << ctx->evtr->id, ~0);
 		ctx->stats.poll_to_callback++;
 	}
-	atomic_set(&ctx->poll_mode, mode);
 	spin_unlock_irqrestore(&gsi_ctx->slock, flags);
 
 	return GSI_STATUS_SUCCESS;
@@ -2883,6 +2889,13 @@
 
 	gsi_ctx->scratch.word0.val = gsi_readl(gsi_ctx->base +
 		GSI_EE_n_CNTXT_SCRATCH_0_OFFS(gsi_ctx->per.ee));
+	if (gsi_ctx->scratch.word0.s.generic_ee_cmd_return_code ==
+		GSI_GEN_EE_CMD_RETURN_CODE_RETRY) {
+		GSIDBG("chan_idx=%u ee=%u busy try again\n", chan_idx, ee);
+		*code = GSI_GEN_EE_CMD_RETURN_CODE_RETRY;
+		res = -GSI_STATUS_AGAIN;
+		goto free_lock;
+	}
 	if (gsi_ctx->scratch.word0.s.generic_ee_cmd_return_code == 0) {
 		GSIERR("No response received\n");
 		res = -GSI_STATUS_ERROR;
diff --git a/drivers/platform/msm/gsi/gsi.h b/drivers/platform/msm/gsi/gsi.h
index 32fb178..7e10405 100644
--- a/drivers/platform/msm/gsi/gsi.h
+++ b/drivers/platform/msm/gsi/gsi.h
@@ -288,6 +288,7 @@
 	GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_DIRECTION = 0x3,
 	GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_CHANNEL_TYPE = 0x4,
 	GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_CHANNEL_INDEX = 0x5,
+	GSI_GEN_EE_CMD_RETURN_CODE_RETRY = 0x6,
 };
 
 extern struct gsi_ctx *gsi_ctx;
diff --git a/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c b/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c
index 105294a..2975192 100644
--- a/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c
+++ b/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c
@@ -19,6 +19,8 @@
 #include <linux/sched.h>
 #include <linux/atomic.h>
 #include <linux/ecm_ipa.h>
+#include "../ipa_common_i.h"
+#include "../ipa_v3/ipa_pm.h"
 
 #define DRIVER_NAME "ecm_ipa"
 #define ECM_IPA_IPV4_HDR_NAME "ecm_eth_ipv4"
@@ -120,6 +122,7 @@
  * @usb_to_ipa_client: producer client
  * @ipa_rm_resource_name_prod: IPA resource manager producer resource
  * @ipa_rm_resource_name_cons: IPA resource manager consumer resource
+ * @pm_hdl: handle for IPA PM
  */
 struct ecm_ipa_dev {
 	struct net_device *net;
@@ -137,6 +140,7 @@
 	enum ipa_client_type usb_to_ipa_client;
 	enum ipa_rm_resource_name ipa_rm_resource_name_prod;
 	enum ipa_rm_resource_name ipa_rm_resource_name_cons;
+	u32 pm_hdl;
 };
 
 static int ecm_ipa_open(struct net_device *net);
@@ -158,6 +162,8 @@
 static struct net_device_stats *ecm_ipa_get_stats(struct net_device *net);
 static int ecm_ipa_create_rm_resource(struct ecm_ipa_dev *ecm_ipa_ctx);
 static void ecm_ipa_destroy_rm_resource(struct ecm_ipa_dev *ecm_ipa_ctx);
+static int ecm_ipa_register_pm_client(struct ecm_ipa_dev *ecm_ipa_ctx);
+static void ecm_ipa_deregister_pm_client(struct ecm_ipa_dev *ecm_ipa_ctx);
 static int resource_request(struct ecm_ipa_dev *ecm_ipa_ctx);
 static void resource_release(struct ecm_ipa_dev *ecm_ipa_ctx);
 static netdev_tx_t ecm_ipa_start_xmit
@@ -403,27 +409,34 @@
 	ECM_IPA_DEBUG("usb_to_ipa_client = %d\n",
 		      ecm_ipa_ctx->usb_to_ipa_client);
 
-	ecm_ipa_ctx->ipa_rm_resource_name_cons =
-		ipa_get_rm_resource_from_ep(ipa_to_usb_hdl);
-	if (ecm_ipa_ctx->ipa_rm_resource_name_cons < 0) {
-		ECM_IPA_ERROR("Error getting CONS RM resource from handle %d\n",
+	if (ipa_pm_is_used()) {
+		retval = ecm_ipa_register_pm_client(ecm_ipa_ctx);
+	} else {
+		ecm_ipa_ctx->ipa_rm_resource_name_cons =
+			ipa_get_rm_resource_from_ep(ipa_to_usb_hdl);
+		if (ecm_ipa_ctx->ipa_rm_resource_name_cons < 0) {
+			ECM_IPA_ERROR(
+			"Error getting CONS RM resource from handle %d\n",
+				      ecm_ipa_ctx->ipa_rm_resource_name_cons);
+			return -EINVAL;
+		}
+		ECM_IPA_DEBUG("ipa_rm_resource_name_cons = %d\n",
 			      ecm_ipa_ctx->ipa_rm_resource_name_cons);
-		return -EINVAL;
-	}
-	ECM_IPA_DEBUG("ipa_rm_resource_name_cons = %d\n",
-		      ecm_ipa_ctx->ipa_rm_resource_name_cons);
 
-	ecm_ipa_ctx->ipa_rm_resource_name_prod =
-		ipa_get_rm_resource_from_ep(usb_to_ipa_hdl);
-	if (ecm_ipa_ctx->ipa_rm_resource_name_prod < 0) {
-		ECM_IPA_ERROR("Error getting PROD RM resource from handle %d\n",
+		ecm_ipa_ctx->ipa_rm_resource_name_prod =
+			ipa_get_rm_resource_from_ep(usb_to_ipa_hdl);
+		if (ecm_ipa_ctx->ipa_rm_resource_name_prod < 0) {
+			ECM_IPA_ERROR(
+			"Error getting PROD RM resource from handle %d\n",
+				      ecm_ipa_ctx->ipa_rm_resource_name_prod);
+			return -EINVAL;
+		}
+		ECM_IPA_DEBUG("ipa_rm_resource_name_prod = %d\n",
 			      ecm_ipa_ctx->ipa_rm_resource_name_prod);
-		return -EINVAL;
-	}
-	ECM_IPA_DEBUG("ipa_rm_resource_name_prod = %d\n",
-		      ecm_ipa_ctx->ipa_rm_resource_name_prod);
 
-	retval = ecm_ipa_create_rm_resource(ecm_ipa_ctx);
+		retval = ecm_ipa_create_rm_resource(ecm_ipa_ctx);
+	}
+
 	if (retval) {
 		ECM_IPA_ERROR("fail on RM create\n");
 		goto fail_create_rm;
@@ -488,7 +501,10 @@
 fail:
 	ecm_ipa_deregister_properties();
 fail_create_rm:
-	ecm_ipa_destroy_rm_resource(ecm_ipa_ctx);
+	if (ipa_pm_is_used())
+		ecm_ipa_deregister_pm_client(ecm_ipa_ctx);
+	else
+		ecm_ipa_destroy_rm_resource(ecm_ipa_ctx);
 	return retval;
 }
 EXPORT_SYMBOL(ecm_ipa_connect);
@@ -746,7 +762,10 @@
 	netif_stop_queue(ecm_ipa_ctx->net);
 	ECM_IPA_DEBUG("queue stopped\n");
 
-	ecm_ipa_destroy_rm_resource(ecm_ipa_ctx);
+	if (ipa_pm_is_used())
+		ecm_ipa_deregister_pm_client(ecm_ipa_ctx);
+	else
+		ecm_ipa_destroy_rm_resource(ecm_ipa_ctx);
 
 	outstanding_dropped_pkts =
 		atomic_read(&ecm_ipa_ctx->outstanding_pkts);
@@ -1117,15 +1136,65 @@
 	ECM_IPA_LOG_EXIT();
 }
 
+static void ecm_ipa_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	struct ecm_ipa_dev *ecm_ipa_ctx = p;
+
+	ECM_IPA_LOG_ENTRY();
+	if (event != IPA_PM_CLIENT_ACTIVATED) {
+		ECM_IPA_ERROR("unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+
+	if (netif_queue_stopped(ecm_ipa_ctx->net)) {
+		ECM_IPA_DEBUG("Resource Granted - starting queue\n");
+		netif_start_queue(ecm_ipa_ctx->net);
+	}
+	ECM_IPA_LOG_EXIT();
+}
+
+static int ecm_ipa_register_pm_client(struct ecm_ipa_dev *ecm_ipa_ctx)
+{
+	int result;
+	struct ipa_pm_register_params pm_reg;
+
+	memset(&pm_reg, 0, sizeof(pm_reg));
+	pm_reg.name = ecm_ipa_ctx->net->name;
+	pm_reg.user_data = ecm_ipa_ctx;
+	pm_reg.callback = ecm_ipa_pm_cb;
+	pm_reg.group = IPA_PM_GROUP_APPS;
+	result = ipa_pm_register(&pm_reg, &ecm_ipa_ctx->pm_hdl);
+	if (result) {
+		ECM_IPA_ERROR("failed to create IPA PM client %d\n", result);
+		return result;
+	}
+	return 0;
+}
+
+static void ecm_ipa_deregister_pm_client(struct ecm_ipa_dev *ecm_ipa_ctx)
+{
+	ipa_pm_deactivate_sync(ecm_ipa_ctx->pm_hdl);
+	ipa_pm_deregister(ecm_ipa_ctx->pm_hdl);
+	ecm_ipa_ctx->pm_hdl = ~0;
+}
+
 static int resource_request(struct ecm_ipa_dev *ecm_ipa_ctx)
 {
+	if (ipa_pm_is_used())
+		return ipa_pm_activate(ecm_ipa_ctx->pm_hdl);
+
 	return ipa_rm_inactivity_timer_request_resource(
 		IPA_RM_RESOURCE_STD_ECM_PROD);
 }
 
 static void resource_release(struct ecm_ipa_dev *ecm_ipa_ctx)
 {
-	ipa_rm_inactivity_timer_release_resource(IPA_RM_RESOURCE_STD_ECM_PROD);
+	if (ipa_pm_is_used())
+		ipa_pm_deferred_deactivate(ecm_ipa_ctx->pm_hdl);
+	else
+		ipa_rm_inactivity_timer_release_resource(
+			IPA_RM_RESOURCE_STD_ECM_PROD);
 }
 
 /**
diff --git a/drivers/platform/msm/ipa/ipa_clients/ipa_mhi_client.c b/drivers/platform/msm/ipa/ipa_clients/ipa_mhi_client.c
index 9b3b53d..4d3113f 100644
--- a/drivers/platform/msm/ipa/ipa_clients/ipa_mhi_client.c
+++ b/drivers/platform/msm/ipa/ipa_clients/ipa_mhi_client.c
@@ -19,6 +19,7 @@
 #include <linux/ipa_qmi_service_v01.h>
 #include <linux/ipa_mhi.h>
 #include "../ipa_common_i.h"
+#include "../ipa_v3/ipa_pm.h"
 
 #define IPA_MHI_DRV_NAME "ipa_mhi_client"
 #define IPA_MHI_DBG(fmt, args...) \
@@ -136,6 +137,8 @@
 	u32 use_ipadma;
 	bool assert_bit40;
 	bool test_mode;
+	u32 pm_hdl;
+	u32 modem_pm_hdl;
 };
 
 static struct ipa_mhi_client_ctx *ipa_mhi_client_ctx;
@@ -834,25 +837,38 @@
 	IPA_MHI_DBG("event_context_array_addr 0x%llx\n",
 		ipa_mhi_client_ctx->event_context_array_addr);
 
-	/* Add MHI <-> Q6 dependencies to IPA RM */
-	res = ipa_rm_add_dependency(IPA_RM_RESOURCE_MHI_PROD,
-		IPA_RM_RESOURCE_Q6_CONS);
-	if (res && res != -EINPROGRESS) {
-		IPA_MHI_ERR("failed to add dependency %d\n", res);
-		goto fail_add_mhi_q6_dep;
-	}
+	if (ipa_pm_is_used()) {
+		res = ipa_pm_activate_sync(ipa_mhi_client_ctx->pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("failed activate client %d\n", res);
+			goto fail_pm_activate;
+		}
+		res = ipa_pm_activate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("failed activate modem client %d\n", res);
+			goto fail_pm_activate_modem;
+		}
+	} else {
+		/* Add MHI <-> Q6 dependencies to IPA RM */
+		res = ipa_rm_add_dependency(IPA_RM_RESOURCE_MHI_PROD,
+			IPA_RM_RESOURCE_Q6_CONS);
+		if (res && res != -EINPROGRESS) {
+			IPA_MHI_ERR("failed to add dependency %d\n", res);
+			goto fail_add_mhi_q6_dep;
+		}
 
-	res = ipa_rm_add_dependency(IPA_RM_RESOURCE_Q6_PROD,
-		IPA_RM_RESOURCE_MHI_CONS);
-	if (res && res != -EINPROGRESS) {
-		IPA_MHI_ERR("failed to add dependency %d\n", res);
-		goto fail_add_q6_mhi_dep;
-	}
+		res = ipa_rm_add_dependency(IPA_RM_RESOURCE_Q6_PROD,
+			IPA_RM_RESOURCE_MHI_CONS);
+		if (res && res != -EINPROGRESS) {
+			IPA_MHI_ERR("failed to add dependency %d\n", res);
+			goto fail_add_q6_mhi_dep;
+		}
 
-	res = ipa_mhi_request_prod();
-	if (res) {
-		IPA_MHI_ERR("failed request prod %d\n", res);
-		goto fail_request_prod;
+		res = ipa_mhi_request_prod();
+		if (res) {
+			IPA_MHI_ERR("failed request prod %d\n", res);
+			goto fail_request_prod;
+		}
 	}
 
 	/* gsi params */
@@ -880,14 +896,23 @@
 	return 0;
 
 fail_init_engine:
-	ipa_mhi_release_prod();
+	if (!ipa_pm_is_used())
+		ipa_mhi_release_prod();
 fail_request_prod:
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
-		IPA_RM_RESOURCE_MHI_CONS);
+	if (!ipa_pm_is_used())
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
+			IPA_RM_RESOURCE_MHI_CONS);
 fail_add_q6_mhi_dep:
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_MHI_PROD,
-		IPA_RM_RESOURCE_Q6_CONS);
+	if (!ipa_pm_is_used())
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_MHI_PROD,
+			IPA_RM_RESOURCE_Q6_CONS);
 fail_add_mhi_q6_dep:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+fail_pm_activate_modem:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
+fail_pm_activate:
 	ipa_mhi_set_state(IPA_MHI_STATE_INITIALIZED);
 	return res;
 }
@@ -2095,20 +2120,32 @@
 	 */
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 
-	IPA_MHI_DBG("release prod\n");
-	res = ipa_mhi_release_prod();
-	if (res) {
-		IPA_MHI_ERR("ipa_mhi_release_prod failed %d\n", res);
-		goto fail_release_prod;
-	}
+	if (ipa_pm_is_used()) {
+		res = ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("fail to deactivate client %d\n", res);
+			goto fail_deactivate_pm;
+		}
+		res = ipa_pm_deactivate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("fail to deactivate client %d\n", res);
+			goto fail_deactivate_modem_pm;
+		}
+	} else {
+		IPA_MHI_DBG("release prod\n");
+		res = ipa_mhi_release_prod();
+		if (res) {
+			IPA_MHI_ERR("ipa_mhi_release_prod failed %d\n", res);
+			goto fail_release_prod;
+		}
 
-	IPA_MHI_DBG("wait for cons release\n");
-	res = ipa_mhi_wait_for_cons_release();
-	if (res) {
-		IPA_MHI_ERR("ipa_mhi_wait_for_cons_release failed %d\n", res);
-		goto fail_release_cons;
+		IPA_MHI_DBG("wait for cons release\n");
+		res = ipa_mhi_wait_for_cons_release();
+		if (res) {
+			IPA_MHI_ERR("ipa_mhi_wait_for_cons_release failed\n");
+			goto fail_release_cons;
+		}
 	}
-
 	usleep_range(IPA_MHI_SUSPEND_SLEEP_MIN, IPA_MHI_SUSPEND_SLEEP_MAX);
 
 	res = ipa_mhi_suspend_dl(force);
@@ -2132,8 +2169,15 @@
 
 fail_suspend_dl_channel:
 fail_release_cons:
+	if (!ipa_pm_is_used())
 	ipa_mhi_request_prod();
 fail_release_prod:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+fail_deactivate_modem_pm:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
+fail_deactivate_pm:
 	IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
 fail_suspend_ul_channel:
 	ipa_mhi_resume_channels(true, ipa_mhi_client_ctx->ul_channels);
@@ -2193,10 +2237,23 @@
 		ipa_mhi_client_ctx->rm_cons_state = IPA_MHI_RM_STATE_GRANTED;
 	}
 
-	res = ipa_mhi_request_prod();
-	if (res) {
-		IPA_MHI_ERR("ipa_mhi_request_prod failed %d\n", res);
-		goto fail_request_prod;
+	if (ipa_pm_is_used()) {
+		res = ipa_pm_activate_sync(ipa_mhi_client_ctx->pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("fail to activate client %d\n", res);
+			goto fail_pm_activate;
+		}
+		ipa_pm_activate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+		if (res) {
+			IPA_MHI_ERR("fail to activate client %d\n", res);
+			goto fail_pm_activate_modem;
+		}
+	} else {
+		res = ipa_mhi_request_prod();
+		if (res) {
+			IPA_MHI_ERR("ipa_mhi_request_prod failed %d\n", res);
+			goto fail_request_prod;
+		}
 	}
 
 	/* resume all UL channels */
@@ -2234,8 +2291,15 @@
 fail_resume_dl_channels2:
 	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->ul_channels);
 fail_resume_ul_channels:
-	ipa_mhi_release_prod();
+	if (!ipa_pm_is_used())
+		ipa_mhi_release_prod();
 fail_request_prod:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+fail_pm_activate_modem:
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
+fail_pm_activate:
 	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels);
 fail_resume_dl_channels:
 	ipa_mhi_set_state(IPA_MHI_STATE_SUSPENDED);
@@ -2319,6 +2383,85 @@
 	debugfs_remove_recursive(dent);
 }
 
+static void ipa_mhi_delete_rm_resources(void)
+{
+	int res;
+
+	if (ipa_mhi_client_ctx->state != IPA_MHI_STATE_INITIALIZED  &&
+		ipa_mhi_client_ctx->state != IPA_MHI_STATE_READY) {
+
+		IPA_MHI_DBG("release prod\n");
+		res = ipa_mhi_release_prod();
+		if (res) {
+			IPA_MHI_ERR("ipa_mhi_release_prod failed %d\n",
+				res);
+			goto fail;
+		}
+		IPA_MHI_DBG("wait for cons release\n");
+		res = ipa_mhi_wait_for_cons_release();
+		if (res) {
+			IPA_MHI_ERR("ipa_mhi_wait_for_cons_release%d\n",
+				res);
+			goto fail;
+		}
+
+		usleep_range(IPA_MHI_SUSPEND_SLEEP_MIN,
+			IPA_MHI_SUSPEND_SLEEP_MAX);
+
+		IPA_MHI_DBG("deleate dependency Q6_PROD->MHI_CONS\n");
+		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
+			IPA_RM_RESOURCE_MHI_CONS);
+		if (res) {
+			IPA_MHI_ERR(
+				"Error deleting dependency %d->%d, res=%d\n",
+				IPA_RM_RESOURCE_Q6_PROD,
+				IPA_RM_RESOURCE_MHI_CONS,
+				res);
+			goto fail;
+		}
+		IPA_MHI_DBG("deleate dependency MHI_PROD->Q6_CONS\n");
+		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_MHI_PROD,
+			IPA_RM_RESOURCE_Q6_CONS);
+		if (res) {
+			IPA_MHI_ERR(
+				"Error deleting dependency %d->%d, res=%d\n",
+				IPA_RM_RESOURCE_MHI_PROD,
+				IPA_RM_RESOURCE_Q6_CONS,
+				res);
+			goto fail;
+		}
+	}
+
+	res = ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_PROD);
+	if (res) {
+		IPA_MHI_ERR("Error deleting resource %d, res=%d\n",
+			IPA_RM_RESOURCE_MHI_PROD, res);
+		goto fail;
+	}
+
+	res = ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_CONS);
+	if (res) {
+		IPA_MHI_ERR("Error deleting resource %d, res=%d\n",
+			IPA_RM_RESOURCE_MHI_CONS, res);
+		goto fail;
+	}
+
+	return;
+fail:
+	ipa_assert();
+}
+
+static void ipa_mhi_deregister_pm(void)
+{
+	ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
+	ipa_pm_deregister(ipa_mhi_client_ctx->pm_hdl);
+	ipa_mhi_client_ctx->pm_hdl = ~0;
+
+	ipa_pm_deactivate_sync(ipa_mhi_client_ctx->modem_pm_hdl);
+	ipa_pm_deregister(ipa_mhi_client_ctx->modem_pm_hdl);
+	ipa_mhi_client_ctx->modem_pm_hdl = ~0;
+}
+
 /**
  * ipa_mhi_destroy() - Destroy MHI IPA
  *
@@ -2351,62 +2494,10 @@
 		ipa_uc_mhi_cleanup();
 	}
 
-
-	if (ipa_mhi_client_ctx->state != IPA_MHI_STATE_INITIALIZED  &&
-			ipa_mhi_client_ctx->state != IPA_MHI_STATE_READY) {
-		IPA_MHI_DBG("release prod\n");
-		res = ipa_mhi_release_prod();
-		if (res) {
-			IPA_MHI_ERR("ipa_mhi_release_prod failed %d\n", res);
-			goto fail;
-		}
-		IPA_MHI_DBG("wait for cons release\n");
-		res = ipa_mhi_wait_for_cons_release();
-		if (res) {
-			IPA_MHI_ERR("ipa_mhi_wait_for_cons_release failed %d\n",
-				res);
-			goto fail;
-		}
-		usleep_range(IPA_MHI_SUSPEND_SLEEP_MIN,
-				IPA_MHI_SUSPEND_SLEEP_MAX);
-
-		IPA_MHI_DBG("deleate dependency Q6_PROD->MHI_CONS\n");
-		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
-			IPA_RM_RESOURCE_MHI_CONS);
-		if (res) {
-			IPA_MHI_ERR(
-				"Error deleting dependency %d->%d, res=%d\n"
-				, IPA_RM_RESOURCE_Q6_PROD,
-				IPA_RM_RESOURCE_MHI_CONS,
-				res);
-			goto fail;
-		}
-		IPA_MHI_DBG("deleate dependency MHI_PROD->Q6_CONS\n");
-		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_MHI_PROD,
-			IPA_RM_RESOURCE_Q6_CONS);
-		if (res) {
-			IPA_MHI_ERR(
-				"Error deleting dependency %d->%d, res=%d\n",
-			IPA_RM_RESOURCE_MHI_PROD,
-			IPA_RM_RESOURCE_Q6_CONS,
-			res);
-			goto fail;
-		}
-	}
-
-	res = ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_PROD);
-	if (res) {
-		IPA_MHI_ERR("Error deleting resource %d, res=%d\n",
-			IPA_RM_RESOURCE_MHI_PROD, res);
-		goto fail;
-	}
-
-	res = ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_CONS);
-	if (res) {
-		IPA_MHI_ERR("Error deleting resource %d, res=%d\n",
-			IPA_RM_RESOURCE_MHI_CONS, res);
-		goto fail;
-	}
+	if (ipa_pm_is_used())
+		ipa_mhi_deregister_pm();
+	else
+		ipa_mhi_delete_rm_resources();
 
 	ipa_mhi_debugfs_destroy();
 	destroy_workqueue(ipa_mhi_client_ctx->wq);
@@ -2420,6 +2511,132 @@
 	ipa_assert();
 }
 
+static void ipa_mhi_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	unsigned long flags;
+
+	IPA_MHI_FUNC_ENTRY();
+
+	if (event != IPA_PM_REQUEST_WAKEUP) {
+		IPA_MHI_ERR("Unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+
+	IPA_MHI_DBG("%s\n", MHI_STATE_STR(ipa_mhi_client_ctx->state));
+	spin_lock_irqsave(&ipa_mhi_client_ctx->state_lock, flags);
+	if (ipa_mhi_client_ctx->state == IPA_MHI_STATE_SUSPENDED) {
+		ipa_mhi_notify_wakeup();
+	} else if (ipa_mhi_client_ctx->state ==
+		IPA_MHI_STATE_SUSPEND_IN_PROGRESS) {
+		/* wakeup event will be trigger after suspend finishes */
+		ipa_mhi_client_ctx->trigger_wakeup = true;
+	}
+	spin_unlock_irqrestore(&ipa_mhi_client_ctx->state_lock, flags);
+	IPA_MHI_DBG("EXIT");
+}
+
+static int ipa_mhi_register_pm(void)
+{
+	int res;
+	struct ipa_pm_register_params params;
+
+	memset(&params, 0, sizeof(params));
+	params.name = "MHI";
+	params.callback = ipa_mhi_pm_cb;
+	params.group = IPA_PM_GROUP_DEFAULT;
+	res = ipa_pm_register(&params, &ipa_mhi_client_ctx->pm_hdl);
+	if (res) {
+		IPA_MHI_ERR("fail to register with PM %d\n", res);
+		return res;
+	}
+
+	res = ipa_pm_associate_ipa_cons_to_client(ipa_mhi_client_ctx->pm_hdl,
+		IPA_CLIENT_MHI_CONS);
+	if (res) {
+		IPA_MHI_ERR("fail to associate cons with PM %d\n", res);
+		goto fail_pm_cons;
+	}
+
+	res = ipa_pm_set_perf_profile(ipa_mhi_client_ctx->pm_hdl, 1000);
+	if (res) {
+		IPA_MHI_ERR("fail to set perf profile to PM %d\n", res);
+		goto fail_pm_cons;
+	}
+
+	/* create a modem client for clock scaling */
+	memset(&params, 0, sizeof(params));
+	params.name = "MODEM (MHI)";
+	params.group = IPA_PM_GROUP_MODEM;
+	params.skip_clk_vote = true;
+	res = ipa_pm_register(&params, &ipa_mhi_client_ctx->modem_pm_hdl);
+	if (res) {
+		IPA_MHI_ERR("fail to register with PM %d\n", res);
+		goto fail_pm_cons;
+	}
+
+	return 0;
+
+fail_pm_cons:
+	ipa_pm_deregister(ipa_mhi_client_ctx->pm_hdl);
+	ipa_mhi_client_ctx->pm_hdl = ~0;
+	return res;
+}
+
+static int ipa_mhi_create_rm_resources(void)
+{
+	int res;
+	struct ipa_rm_create_params mhi_prod_params;
+	struct ipa_rm_create_params mhi_cons_params;
+	struct ipa_rm_perf_profile profile;
+
+	/* Create PROD in IPA RM */
+	memset(&mhi_prod_params, 0, sizeof(mhi_prod_params));
+	mhi_prod_params.name = IPA_RM_RESOURCE_MHI_PROD;
+	mhi_prod_params.floor_voltage = IPA_VOLTAGE_SVS;
+	mhi_prod_params.reg_params.notify_cb = ipa_mhi_rm_prod_notify;
+	res = ipa_rm_create_resource(&mhi_prod_params);
+	if (res) {
+		IPA_MHI_ERR("fail to create IPA_RM_RESOURCE_MHI_PROD\n");
+		goto fail_create_rm_prod;
+	}
+
+	memset(&profile, 0, sizeof(profile));
+	profile.max_supported_bandwidth_mbps = 1000;
+	res = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_MHI_PROD, &profile);
+	if (res) {
+		IPA_MHI_ERR("fail to set profile to MHI_PROD\n");
+		goto fail_perf_rm_prod;
+	}
+
+	/* Create CONS in IPA RM */
+	memset(&mhi_cons_params, 0, sizeof(mhi_cons_params));
+	mhi_cons_params.name = IPA_RM_RESOURCE_MHI_CONS;
+	mhi_cons_params.floor_voltage = IPA_VOLTAGE_SVS;
+	mhi_cons_params.request_resource = ipa_mhi_rm_cons_request;
+	mhi_cons_params.release_resource = ipa_mhi_rm_cons_release;
+	res = ipa_rm_create_resource(&mhi_cons_params);
+	if (res) {
+		IPA_MHI_ERR("fail to create IPA_RM_RESOURCE_MHI_CONS\n");
+		goto fail_create_rm_cons;
+	}
+
+	memset(&profile, 0, sizeof(profile));
+	profile.max_supported_bandwidth_mbps = 1000;
+	res = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_MHI_CONS, &profile);
+	if (res) {
+		IPA_MHI_ERR("fail to set profile to MHI_CONS\n");
+		goto fail_perf_rm_cons;
+	}
+fail_perf_rm_cons:
+	ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_CONS);
+fail_create_rm_cons:
+fail_perf_rm_prod:
+	ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_PROD);
+fail_create_rm_prod:
+	return res;
+}
+
 /**
  * ipa_mhi_init() - Initialize IPA MHI driver
  * @params: initialization params
@@ -2437,9 +2654,6 @@
 int ipa_mhi_init(struct ipa_mhi_init_params *params)
 {
 	int res;
-	struct ipa_rm_create_params mhi_prod_params;
-	struct ipa_rm_create_params mhi_cons_params;
-	struct ipa_rm_perf_profile profile;
 
 	IPA_MHI_FUNC_ENTRY();
 
@@ -2500,43 +2714,14 @@
 		goto fail_create_wq;
 	}
 
-	/* Create PROD in IPA RM */
-	memset(&mhi_prod_params, 0, sizeof(mhi_prod_params));
-	mhi_prod_params.name = IPA_RM_RESOURCE_MHI_PROD;
-	mhi_prod_params.floor_voltage = IPA_VOLTAGE_SVS;
-	mhi_prod_params.reg_params.notify_cb = ipa_mhi_rm_prod_notify;
-	res = ipa_rm_create_resource(&mhi_prod_params);
+	if (ipa_pm_is_used())
+		res = ipa_mhi_register_pm();
+	else
+		res = ipa_mhi_create_rm_resources();
 	if (res) {
-		IPA_MHI_ERR("fail to create IPA_RM_RESOURCE_MHI_PROD\n");
-		goto fail_create_rm_prod;
-	}
-
-	memset(&profile, 0, sizeof(profile));
-	profile.max_supported_bandwidth_mbps = 1000;
-	res = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_MHI_PROD, &profile);
-	if (res) {
-		IPA_MHI_ERR("fail to set profile to MHI_PROD\n");
-		goto fail_perf_rm_prod;
-	}
-
-	/* Create CONS in IPA RM */
-	memset(&mhi_cons_params, 0, sizeof(mhi_cons_params));
-	mhi_cons_params.name = IPA_RM_RESOURCE_MHI_CONS;
-	mhi_cons_params.floor_voltage = IPA_VOLTAGE_SVS;
-	mhi_cons_params.request_resource = ipa_mhi_rm_cons_request;
-	mhi_cons_params.release_resource = ipa_mhi_rm_cons_release;
-	res = ipa_rm_create_resource(&mhi_cons_params);
-	if (res) {
-		IPA_MHI_ERR("fail to create IPA_RM_RESOURCE_MHI_CONS\n");
-		goto fail_create_rm_cons;
-	}
-
-	memset(&profile, 0, sizeof(profile));
-	profile.max_supported_bandwidth_mbps = 1000;
-	res = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_MHI_CONS, &profile);
-	if (res) {
-		IPA_MHI_ERR("fail to set profile to MHI_CONS\n");
-		goto fail_perf_rm_cons;
+		IPA_MHI_ERR("failed to create RM resources\n");
+		res = -EFAULT;
+		goto fail_rm;
 	}
 
 	/* Initialize uC interface */
@@ -2551,12 +2736,7 @@
 	IPA_MHI_FUNC_EXIT();
 	return 0;
 
-fail_perf_rm_cons:
-	ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_CONS);
-fail_create_rm_cons:
-fail_perf_rm_prod:
-	ipa_rm_delete_resource(IPA_RM_RESOURCE_MHI_PROD);
-fail_create_rm_prod:
+fail_rm:
 	destroy_workqueue(ipa_mhi_client_ctx->wq);
 fail_create_wq:
 	kfree(ipa_mhi_client_ctx);
diff --git a/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c b/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c
index a15a9d8..e19d297 100644
--- a/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c
+++ b/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c
@@ -13,6 +13,7 @@
 #include <linux/ipa_uc_offload.h>
 #include <linux/msm_ipa.h>
 #include "../ipa_common_i.h"
+#include "../ipa_v3/ipa_pm.h"
 
 #define IPA_NTN_DMA_POOL_ALIGNMENT 8
 #define OFFLOAD_DRV_NAME "ipa_uc_offload"
@@ -69,6 +70,7 @@
 	char netdev_name[IPA_RESOURCE_NAME_MAX];
 	ipa_notify_cb notify;
 	struct completion ntn_completion;
+	u32 pm_hdl;
 };
 
 static struct ipa_uc_offload_ctx *ipa_uc_offload_ctx[IPA_UC_MAX_PROT_SIZE];
@@ -113,22 +115,53 @@
 	return 0;
 }
 
-static int ipa_uc_offload_ntn_reg_intf(
-	struct ipa_uc_offload_intf_params *inp,
-	struct ipa_uc_offload_out_params *outp,
+static void ipa_uc_offload_ntn_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	/* suspend/resume is not supported */
+	IPA_UC_OFFLOAD_DBG("event = %d\n", event);
+}
+
+static int ipa_uc_offload_ntn_register_pm_client(
 	struct ipa_uc_offload_ctx *ntn_ctx)
 {
-	struct ipa_ioc_add_hdr *hdr = NULL;
-	struct ipa_tx_intf tx;
-	struct ipa_rx_intf rx;
-	struct ipa_ioc_tx_intf_prop tx_prop[2];
-	struct ipa_ioc_rx_intf_prop rx_prop[2];
-	struct ipa_rm_create_params param;
-	u32 len;
-	int ret = 0;
+	int res;
+	struct ipa_pm_register_params params;
 
-	IPA_UC_OFFLOAD_DBG("register interface for netdev %s\n",
-					 inp->netdev_name);
+	memset(&params, 0, sizeof(params));
+	params.name = "ETH";
+	params.callback = ipa_uc_offload_ntn_pm_cb;
+	params.user_data = ntn_ctx;
+	params.group = IPA_PM_GROUP_DEFAULT;
+	res = ipa_pm_register(&params, &ntn_ctx->pm_hdl);
+	if (res) {
+		IPA_UC_OFFLOAD_ERR("fail to register with PM %d\n", res);
+		return res;
+	}
+
+	res = ipa_pm_associate_ipa_cons_to_client(ntn_ctx->pm_hdl,
+		IPA_CLIENT_ETHERNET_CONS);
+	if (res) {
+		IPA_UC_OFFLOAD_ERR("fail to associate cons with PM %d\n", res);
+		ipa_pm_deregister(ntn_ctx->pm_hdl);
+		ntn_ctx->pm_hdl = ~0;
+		return res;
+	}
+
+	return 0;
+}
+
+static void ipa_uc_offload_ntn_deregister_pm_client(
+	struct ipa_uc_offload_ctx *ntn_ctx)
+{
+	ipa_pm_deactivate_sync(ntn_ctx->pm_hdl);
+	ipa_pm_deregister(ntn_ctx->pm_hdl);
+}
+static int ipa_uc_offload_ntn_create_rm_resources(
+	struct ipa_uc_offload_ctx *ntn_ctx)
+{
+	int ret;
+	struct ipa_rm_create_params param;
+
 	memset(&param, 0, sizeof(param));
 	param.name = IPA_RM_RESOURCE_ETHERNET_PROD;
 	param.reg_params.user_data = ntn_ctx;
@@ -147,9 +180,37 @@
 	ret = ipa_rm_create_resource(&param);
 	if (ret) {
 		IPA_UC_OFFLOAD_ERR("fail to create ETHERNET_CONS resource\n");
-		goto fail_create_rm_cons;
+		ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
+		return -EFAULT;
 	}
 
+	return 0;
+}
+
+static int ipa_uc_offload_ntn_reg_intf(
+	struct ipa_uc_offload_intf_params *inp,
+	struct ipa_uc_offload_out_params *outp,
+	struct ipa_uc_offload_ctx *ntn_ctx)
+{
+	struct ipa_ioc_add_hdr *hdr = NULL;
+	struct ipa_tx_intf tx;
+	struct ipa_rx_intf rx;
+	struct ipa_ioc_tx_intf_prop tx_prop[2];
+	struct ipa_ioc_rx_intf_prop rx_prop[2];
+	int ret = 0;
+	u32 len;
+
+
+	IPA_UC_OFFLOAD_DBG("register interface for netdev %s\n",
+					 inp->netdev_name);
+	if (ipa_pm_is_used())
+		ret = ipa_uc_offload_ntn_register_pm_client(ntn_ctx);
+	else
+		ret = ipa_uc_offload_ntn_create_rm_resources(ntn_ctx);
+	if (ret) {
+		IPA_UC_OFFLOAD_ERR("fail to create rm resource\n");
+		return -EFAULT;
+	}
 	memcpy(ntn_ctx->netdev_name, inp->netdev_name, IPA_RESOURCE_NAME_MAX);
 	ntn_ctx->hdr_len = inp->hdr_info[0].hdr_len;
 	ntn_ctx->notify = inp->notify;
@@ -228,9 +289,12 @@
 fail:
 	kfree(hdr);
 fail_alloc:
-	ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_CONS);
-fail_create_rm_cons:
-	ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
+	if (ipa_pm_is_used()) {
+		ipa_uc_offload_ntn_deregister_pm_client(ntn_ctx);
+	} else {
+		ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_CONS);
+		ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
+	}
 	return ret;
 }
 
@@ -348,25 +412,34 @@
 		return -EINVAL;
 	}
 
-	result = ipa_rm_add_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
-		IPA_RM_RESOURCE_APPS_CONS);
-	if (result) {
-		IPA_UC_OFFLOAD_ERR("fail to add rm dependency: %d\n", result);
-		return result;
-	}
+	if (ipa_pm_is_used()) {
+		result = ipa_pm_activate_sync(ntn_ctx->pm_hdl);
+		if (result) {
+			IPA_UC_OFFLOAD_ERR("fail to activate: %d\n", result);
+			return result;
+		}
+	} else {
+		result = ipa_rm_add_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
+			IPA_RM_RESOURCE_APPS_CONS);
+		if (result) {
+			IPA_UC_OFFLOAD_ERR("fail to add rm dependency: %d\n",
+				result);
+			return result;
+		}
 
-	result = ipa_rm_request_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
-	if (result == -EINPROGRESS) {
-		if (wait_for_completion_timeout(&ntn_ctx->ntn_completion,
-			10*HZ) == 0) {
-			IPA_UC_OFFLOAD_ERR("ETH_PROD resource req time out\n");
+		result = ipa_rm_request_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
+		if (result == -EINPROGRESS) {
+			if (wait_for_completion_timeout(&ntn_ctx->ntn_completion
+				, 10*HZ) == 0) {
+				IPA_UC_OFFLOAD_ERR("ETH_PROD req timeout\n");
+				result = -EFAULT;
+				goto fail;
+			}
+		} else if (result != 0) {
+			IPA_UC_OFFLOAD_ERR("fail to request resource\n");
 			result = -EFAULT;
 			goto fail;
 		}
-	} else if (result != 0) {
-		IPA_UC_OFFLOAD_ERR("fail to request resource\n");
-		result = -EFAULT;
-		goto fail;
 	}
 
 	ntn_ctx->state = IPA_UC_OFFLOAD_STATE_UP;
@@ -383,8 +456,9 @@
 	return 0;
 
 fail:
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
-		IPA_RM_RESOURCE_APPS_CONS);
+	if (!ipa_pm_is_used())
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
+			IPA_RM_RESOURCE_APPS_CONS);
 	return result;
 }
 
@@ -455,6 +529,11 @@
 		return -EINVAL;
 	}
 
+	if (ipa_pm_is_used())
+		return ipa_pm_set_perf_profile(
+			ipa_uc_offload_ctx[IPA_UC_NTN]->pm_hdl,
+			profile->max_supported_bw_mbps);
+
 	if (ipa_rm_set_perf_profile(resource_name, &rm_profile)) {
 		IPA_UC_OFFLOAD_ERR("fail to setup rm perf profile\n");
 		return -EFAULT;
@@ -471,18 +550,27 @@
 
 	ntn_ctx->state = IPA_UC_OFFLOAD_STATE_INITIALIZED;
 
-	ret = ipa_rm_release_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
-	if (ret) {
-		IPA_UC_OFFLOAD_ERR("fail to release ETHERNET_PROD res: %d\n",
-						  ret);
-		return -EFAULT;
-	}
+	if (ipa_pm_is_used()) {
+		ret = ipa_pm_deactivate_sync(ntn_ctx->pm_hdl);
+		if (ret) {
+			IPA_UC_OFFLOAD_ERR("fail to deactivate res: %d\n",
+			ret);
+			return -EFAULT;
+		}
+	} else {
+		ret = ipa_rm_release_resource(IPA_RM_RESOURCE_ETHERNET_PROD);
+		if (ret) {
+			IPA_UC_OFFLOAD_ERR("fail release ETHERNET_PROD: %d\n",
+							ret);
+			return -EFAULT;
+		}
 
-	ret = ipa_rm_delete_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
-		IPA_RM_RESOURCE_APPS_CONS);
-	if (ret) {
-		IPA_UC_OFFLOAD_ERR("fail to del dep ETH_PROD->APPS, %d\n", ret);
-		return -EFAULT;
+		ret = ipa_rm_delete_dependency(IPA_RM_RESOURCE_ETHERNET_PROD,
+			IPA_RM_RESOURCE_APPS_CONS);
+		if (ret) {
+			IPA_UC_OFFLOAD_ERR("fail del dep ETH->APPS, %d\n", ret);
+			return -EFAULT;
+		}
 	}
 
 	ipa_ep_idx_ul = ipa_get_ep_mapping(IPA_CLIENT_ETHERNET_PROD);
@@ -539,14 +627,18 @@
 	int len, result = 0;
 	struct ipa_ioc_del_hdr *hdr;
 
-	if (ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_PROD)) {
-		IPA_UC_OFFLOAD_ERR("fail to delete ETHERNET_PROD resource\n");
-		return -EFAULT;
-	}
+	if (ipa_pm_is_used()) {
+		ipa_uc_offload_ntn_deregister_pm_client(ntn_ctx);
+	} else {
+		if (ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_PROD)) {
+			IPA_UC_OFFLOAD_ERR("fail to delete ETHERNET_PROD\n");
+			return -EFAULT;
+		}
 
-	if (ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_CONS)) {
-		IPA_UC_OFFLOAD_ERR("fail to delete ETHERNET_CONS resource\n");
-		return -EFAULT;
+		if (ipa_rm_delete_resource(IPA_RM_RESOURCE_ETHERNET_CONS)) {
+			IPA_UC_OFFLOAD_ERR("fail to delete ETHERNET_CONS\n");
+			return -EFAULT;
+		}
 	}
 
 	len = sizeof(struct ipa_ioc_del_hdr) + 2 * sizeof(struct ipa_hdr_del);
diff --git a/drivers/platform/msm/ipa/ipa_clients/ipa_usb.c b/drivers/platform/msm/ipa/ipa_clients/ipa_usb.c
index c5aaac5..745e429 100644
--- a/drivers/platform/msm/ipa/ipa_clients/ipa_usb.c
+++ b/drivers/platform/msm/ipa/ipa_clients/ipa_usb.c
@@ -119,6 +119,12 @@
 	bool cons_requested_released;
 };
 
+struct ipa3_usb_pm_context {
+	struct ipa_pm_register_params reg_params;
+	struct work_struct *remote_wakeup_work;
+	u32 hdl;
+};
+
 enum ipa3_usb_state {
 	IPA_USB_INVALID,
 	IPA_USB_INITIALIZED,
@@ -157,6 +163,7 @@
  */
 struct ipa3_usb_transport_type_ctx {
 	struct ipa3_usb_rm_context rm_ctx;
+	struct ipa3_usb_pm_context pm_ctx;
 	int (*ipa_usb_notify_cb)(enum ipa_usb_notify_event, void *user_data);
 	void *user_data;
 	enum ipa3_usb_state state;
@@ -362,7 +369,8 @@
 			ipa3_usb_state_to_string(new_state));
 	}
 
-	if (state_legal && (new_state == IPA_USB_CONNECTED)) {
+	if (!ipa_pm_is_used() &&
+		state_legal && (new_state == IPA_USB_CONNECTED)) {
 		rm_ctx = &ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx;
 		if ((rm_ctx->cons_state == IPA_USB_CONS_GRANTED) ||
 			rm_ctx->cons_requested_released) {
@@ -656,6 +664,30 @@
 	return ipa3_usb_cons_release_resource_cb_do(IPA_USB_TRANSPORT_DPL);
 }
 
+static void ipa3_usb_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	struct ipa3_usb_transport_type_ctx *ttype_ctx =
+		(struct ipa3_usb_transport_type_ctx *)p;
+	unsigned long flags;
+
+	IPA_USB_DBG_LOW("entry\n");
+
+	if (event != IPA_PM_REQUEST_WAKEUP) {
+		IPA_USB_ERR("Unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+
+	spin_lock_irqsave(&ipa3_usb_ctx->state_lock, flags);
+	IPA_USB_DBG("state is %s\n",
+		ipa3_usb_state_to_string(ttype_ctx->state));
+	if (ttype_ctx->state == IPA_USB_SUSPENDED)
+		queue_work(ipa3_usb_ctx->wq,
+			ttype_ctx->pm_ctx.remote_wakeup_work);
+	spin_unlock_irqrestore(&ipa3_usb_ctx->state_lock, flags);
+	IPA_USB_DBG_LOW("exit\n");
+}
+
 static char *ipa3_usb_teth_prot_to_string(enum ipa_usb_teth_prot teth_prot)
 {
 	switch (teth_prot) {
@@ -703,6 +735,59 @@
 	return 0;
 }
 
+static int ipa3_usb_register_pm(enum ipa3_usb_transport_type ttype)
+{
+	struct ipa3_usb_transport_type_ctx *ttype_ctx =
+		&ipa3_usb_ctx->ttype_ctx[ttype];
+	int result;
+
+	memset(&ttype_ctx->pm_ctx.reg_params, 0,
+		sizeof(ttype_ctx->pm_ctx.reg_params));
+	ttype_ctx->pm_ctx.reg_params.name = (ttype == IPA_USB_TRANSPORT_DPL) ?
+				"USB DPL" : "USB";
+	ttype_ctx->pm_ctx.reg_params.callback = ipa3_usb_pm_cb;
+	ttype_ctx->pm_ctx.reg_params.user_data = ttype_ctx;
+	ttype_ctx->pm_ctx.reg_params.group = IPA_PM_GROUP_DEFAULT;
+
+	result = ipa_pm_register(&ttype_ctx->pm_ctx.reg_params,
+		&ttype_ctx->pm_ctx.hdl);
+	if (result) {
+		IPA_USB_ERR("fail to register with PM %d\n", result);
+		goto fail_pm_reg;
+	}
+
+	result = ipa_pm_associate_ipa_cons_to_client(ttype_ctx->pm_ctx.hdl,
+		(ttype == IPA_USB_TRANSPORT_DPL) ?
+		IPA_CLIENT_USB_DPL_CONS : IPA_CLIENT_USB_CONS);
+	if (result) {
+		IPA_USB_ERR("fail to associate cons with PM %d\n", result);
+		goto fail_pm_cons;
+	}
+
+	return 0;
+
+fail_pm_cons:
+	ipa_pm_deregister(ttype_ctx->pm_ctx.hdl);
+fail_pm_reg:
+	memset(&ttype_ctx->pm_ctx.reg_params, 0,
+		sizeof(ttype_ctx->pm_ctx.reg_params));
+	return result;
+}
+
+static int ipa3_usb_deregister_pm(enum ipa3_usb_transport_type ttype)
+{
+	struct ipa3_usb_pm_context *pm_ctx =
+		&ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx;
+	int result;
+
+	result = ipa_pm_deregister(pm_ctx->hdl);
+	if (result)
+		return result;
+
+	memset(&pm_ctx->reg_params, 0, sizeof(pm_ctx->reg_params));
+	return 0;
+}
+
 static int ipa3_usb_create_rm_resources(enum ipa3_usb_transport_type ttype)
 {
 	struct ipa3_usb_rm_context *rm_ctx;
@@ -716,7 +801,7 @@
 		rm_ctx->prod_params.name = IPA3_USB_IS_TTYPE_DPL(ttype) ?
 			IPA_RM_RESOURCE_USB_DPL_DUMMY_PROD :
 			IPA_RM_RESOURCE_USB_PROD;
-		rm_ctx->prod_params.floor_voltage = IPA_VOLTAGE_SVS;
+		rm_ctx->prod_params.floor_voltage = IPA_VOLTAGE_SVS2;
 		rm_ctx->prod_params.reg_params.user_data = NULL;
 		rm_ctx->prod_params.reg_params.notify_cb =
 			IPA3_USB_IS_TTYPE_DPL(ttype) ?
@@ -741,7 +826,7 @@
 		rm_ctx->cons_params.name = IPA3_USB_IS_TTYPE_DPL(ttype) ?
 			IPA_RM_RESOURCE_USB_DPL_CONS :
 			IPA_RM_RESOURCE_USB_CONS;
-		rm_ctx->cons_params.floor_voltage = IPA_VOLTAGE_SVS;
+		rm_ctx->cons_params.floor_voltage = IPA_VOLTAGE_SVS2;
 		rm_ctx->cons_params.reg_params.user_data = NULL;
 		rm_ctx->cons_params.reg_params.notify_cb = NULL;
 		rm_ctx->cons_params.request_resource =
@@ -784,7 +869,7 @@
 
 	mutex_lock(&ipa3_usb_ctx->general_mutex);
 	IPA_USB_DBG_LOW("entry\n");
-	if (teth_prot > IPA_USB_MAX_TETH_PROT_SIZE ||
+	if (teth_prot < 0 || teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE ||
 		((teth_prot == IPA_USB_RNDIS || teth_prot == IPA_USB_ECM) &&
 		teth_params == NULL) || ipa_usb_notify_cb == NULL ||
 		user_data == NULL) {
@@ -802,7 +887,10 @@
 	}
 
 	/* Create IPA RM USB resources */
-	result = ipa3_usb_create_rm_resources(ttype);
+	if (ipa_pm_is_used())
+		result = ipa3_usb_register_pm(ttype);
+	else
+		result = ipa3_usb_create_rm_resources(ttype);
 	if (result) {
 		IPA_USB_ERR("Failed creating IPA RM USB resources\n");
 		goto bad_params;
@@ -934,12 +1022,18 @@
 teth_prot_init_fail:
 	if ((IPA3_USB_IS_TTYPE_DPL(ttype))
 		|| (ipa3_usb_ctx->num_init_prot == 0)) {
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_valid = false;
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_valid = false;
-		ipa_rm_delete_resource(
+		if (ipa_pm_is_used()) {
+			ipa3_usb_deregister_pm(ttype);
+		} else {
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_valid =
+				false;
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_valid =
+				false;
+			ipa_rm_delete_resource(
 			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_params.name);
-		ipa_rm_delete_resource(
+			ipa_rm_delete_resource(
 			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_params.name);
+		}
 	}
 bad_params:
 	mutex_unlock(&ipa3_usb_ctx->general_mutex);
@@ -987,7 +1081,8 @@
 		params->xfer_scratch.depcmd_hi_addr);
 
 	if (params->client >= IPA_CLIENT_MAX  ||
-		params->teth_prot > IPA_USB_MAX_TETH_PROT_SIZE ||
+		params->teth_prot < 0 ||
+		params->teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE ||
 		params->xfer_ring_len % GSI_CHAN_RE_SIZE_16B ||
 		params->xfer_scratch.const_buffer_size < 1 ||
 		params->xfer_scratch.const_buffer_size > 31) {
@@ -1251,7 +1346,7 @@
 	int result = 0;
 
 	IPA_USB_DBG_LOW("entry\n");
-	if (ttype > IPA_USB_TRANSPORT_MAX) {
+	if (ttype < 0 || ttype >= IPA_USB_TRANSPORT_MAX) {
 		IPA_USB_ERR("bad parameter.\n");
 		return -EINVAL;
 	}
@@ -1355,7 +1450,8 @@
 		(params->teth_prot != IPA_USB_DIAG &&
 		(params->usb_to_ipa_xferrscidx < 0 ||
 		params->usb_to_ipa_xferrscidx > 127)) ||
-		params->teth_prot > IPA_USB_MAX_TETH_PROT_SIZE) {
+		params->teth_prot < 0 ||
+		params->teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE) {
 		IPA_USB_ERR("Invalid params\n");
 		return false;
 	}
@@ -1391,6 +1487,9 @@
 {
 	int res = 0;
 
+	if (ipa_pm_is_used())
+		return 0;
+
 	/*
 	 * Add DPL dependency to RM dependency graph, first add_dependency call
 	 * is sync in order to make sure the IPA clocks are up before we
@@ -1570,6 +1669,9 @@
 {
 	int res;
 
+	if (ipa_pm_is_used())
+		return 0;
+
 	/* Remove DPL RM dependency */
 	res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_USB_DPL_DUMMY_PROD,
 				    IPA_RM_RESOURCE_Q6_CONS);
@@ -1697,32 +1799,51 @@
 		return result;
 	}
 
-	/* Set RM PROD & CONS perf profile */
-	profile.max_supported_bandwidth_mbps =
-			params->max_supported_bandwidth_mbps;
-	result = ipa_rm_set_perf_profile(
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_params.name,
-		&profile);
-	if (result) {
-		IPA_USB_ERR("failed to set %s perf profile\n",
-			ipa_rm_resource_str(ipa3_usb_ctx->ttype_ctx[ttype].
-				rm_ctx.prod_params.name));
-		return result;
-	}
-	result = ipa_rm_set_perf_profile(
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_params.name,
-		&profile);
-	if (result) {
-		IPA_USB_ERR("failed to set %s perf profile\n",
-			ipa_rm_resource_str(ipa3_usb_ctx->ttype_ctx[ttype].
-				rm_ctx.cons_params.name));
-		return result;
-	}
+	if (ipa_pm_is_used()) {
+		result = ipa_pm_set_perf_profile(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl,
+			params->max_supported_bandwidth_mbps);
+		if (result) {
+			IPA_USB_ERR("failed to set perf profile\n");
+			return result;
+		}
 
-	/* Request PROD */
-	result = ipa3_usb_request_prod(ttype);
-	if (result)
-		return result;
+		result = ipa_pm_activate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+		if (result) {
+			IPA_USB_ERR("failed to activate pm\n");
+			return result;
+		}
+	} else {
+		/* Set RM PROD & CONS perf profile */
+		profile.max_supported_bandwidth_mbps =
+				params->max_supported_bandwidth_mbps;
+		result = ipa_rm_set_perf_profile(
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_params.name,
+			&profile);
+		if (result) {
+			IPA_USB_ERR("failed to set %s perf profile\n",
+				ipa_rm_resource_str(ipa3_usb_ctx->
+					ttype_ctx[ttype].
+					rm_ctx.prod_params.name));
+			return result;
+		}
+		result = ipa_rm_set_perf_profile(
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_params.name,
+			&profile);
+		if (result) {
+			IPA_USB_ERR("failed to set %s perf profile\n",
+				ipa_rm_resource_str(ipa3_usb_ctx->
+					ttype_ctx[ttype].
+					rm_ctx.cons_params.name));
+			return result;
+		}
+
+		/* Request PROD */
+		result = ipa3_usb_request_prod(ttype);
+		if (result)
+			return result;
+	}
 
 	if (params->teth_prot != IPA_USB_DIAG) {
 		/* Start UL channel */
@@ -1773,7 +1894,11 @@
 		ipa3_reset_gsi_event_ring(params->usb_to_ipa_clnt_hdl);
 	}
 connect_ul_fail:
-	ipa3_usb_release_prod(ttype);
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		ipa3_usb_release_prod(ttype);
 	return result;
 }
 
@@ -2059,7 +2184,7 @@
 
 static int ipa3_usb_check_disconnect_prot(enum ipa_usb_teth_prot teth_prot)
 {
-	if (teth_prot > IPA_USB_MAX_TETH_PROT_SIZE) {
+	if (teth_prot < 0 || teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE) {
 		IPA_USB_ERR("bad parameter.\n");
 		return -EFAULT;
 	}
@@ -2222,7 +2347,11 @@
 		goto bad_params;
 
 	if (orig_state != IPA_USB_SUSPENDED) {
-		result = ipa3_usb_release_prod(ttype);
+		if (ipa_pm_is_used())
+			result = ipa_pm_deactivate_sync(
+				ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+		else
+			result = ipa3_usb_release_prod(ttype);
 		if (result) {
 			IPA_USB_ERR("failed to release PROD.\n");
 			goto bad_params;
@@ -2247,7 +2376,7 @@
 
 	mutex_lock(&ipa3_usb_ctx->general_mutex);
 	IPA_USB_DBG_LOW("entry\n");
-	if (teth_prot > IPA_USB_MAX_TETH_PROT_SIZE) {
+	if (teth_prot < 0 || teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE) {
 		IPA_USB_ERR("bad parameters.\n");
 		result = -EINVAL;
 		goto bad_params;
@@ -2332,13 +2461,19 @@
 		(ipa3_usb_ctx->num_init_prot == 0)) {
 		if (!ipa3_usb_set_state(IPA_USB_INVALID, false, ttype))
 			IPA_USB_ERR("failed to change state to invalid\n");
-		ipa_rm_delete_resource(
+		if (ipa_pm_is_used()) {
+			ipa3_usb_deregister_pm(ttype);
+		} else {
+			ipa_rm_delete_resource(
 			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_params.name);
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_valid = false;
-		ipa_rm_delete_resource(
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.prod_valid =
+				false;
+			ipa_rm_delete_resource(
 			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_params.name);
-		ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_valid = false;
-		ipa3_usb_ctx->ttype_ctx[ttype].ipa_usb_notify_cb = NULL;
+			ipa3_usb_ctx->ttype_ctx[ttype].rm_ctx.cons_valid =
+				false;
+			ipa3_usb_ctx->ttype_ctx[ttype].ipa_usb_notify_cb = NULL;
+		}
 	}
 
 	IPA_USB_DBG_LOW("exit\n");
@@ -2398,7 +2533,11 @@
 	if (result)
 		goto start_ul;
 
-	result = ipa3_usb_release_prod(ttype);
+	if (ipa_pm_is_used())
+		result = ipa_pm_deactivate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		result = ipa3_usb_release_prod(ttype);
 	if (result) {
 		IPA_USB_ERR("failed to release PROD.\n");
 		goto connect_teth;
@@ -2432,7 +2571,7 @@
 	mutex_lock(&ipa3_usb_ctx->general_mutex);
 	IPA_USB_DBG_LOW("entry\n");
 
-	if (teth_prot > IPA_USB_MAX_TETH_PROT_SIZE) {
+	if (teth_prot < 0 || teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE) {
 		IPA_USB_ERR("bad parameters.\n");
 		result = -EINVAL;
 		goto bad_params;
@@ -2475,7 +2614,11 @@
 	}
 	ipa3_usb_ctx->qmi_req_id++;
 
-	result = ipa3_usb_release_prod(ttype);
+	if (ipa_pm_is_used())
+		result = ipa_pm_deactivate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		result = ipa3_usb_release_prod(ttype);
 	if (result) {
 		IPA_USB_ERR("failed to release PROD\n");
 		goto release_prod_fail;
@@ -2541,7 +2684,11 @@
 		"DPL channel":"Data Tethering channels");
 
 	/* Request USB_PROD */
-	result = ipa3_usb_request_prod(ttype);
+	if (ipa_pm_is_used())
+		result = ipa_pm_activate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		result = ipa3_usb_request_prod(ttype);
 	if (result)
 		goto fail_exit;
 
@@ -2588,7 +2735,11 @@
 disconn_teth:
 	(void)ipa3_usb_disconnect_teth_prot(teth_prot);
 release_prod:
-	(void)ipa3_usb_release_prod(ttype);
+	if (ipa_pm_is_used())
+		(void)ipa_pm_deactivate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		(void)ipa3_usb_release_prod(ttype);
 fail_exit:
 	return result;
 }
@@ -2604,7 +2755,7 @@
 	mutex_lock(&ipa3_usb_ctx->general_mutex);
 	IPA_USB_DBG_LOW("entry\n");
 
-	if (teth_prot > IPA_USB_MAX_TETH_PROT_SIZE) {
+	if (teth_prot < 0 || teth_prot >= IPA_USB_MAX_TETH_PROT_SIZE) {
 		IPA_USB_ERR("bad parameters.\n");
 		result = -EINVAL;
 		goto bad_params;
@@ -2640,7 +2791,11 @@
 	}
 
 	/* Request USB_PROD */
-	result = ipa3_usb_request_prod(ttype);
+	if (ipa_pm_is_used())
+		result = ipa_pm_activate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		result = ipa3_usb_request_prod(ttype);
 	if (result)
 		goto prod_req_fail;
 
@@ -2683,7 +2838,11 @@
 			IPA_USB_ERR("Error stopping UL channel: %d\n", result);
 	}
 start_ul_fail:
-	ipa3_usb_release_prod(ttype);
+	if (ipa_pm_is_used())
+		ipa_pm_deactivate_sync(
+			ipa3_usb_ctx->ttype_ctx[ttype].pm_ctx.hdl);
+	else
+		ipa3_usb_release_prod(ttype);
 prod_req_fail:
 	/* Change state back to prev_state */
 	if (!ipa3_usb_set_state(prev_state, true, ttype))
@@ -2720,6 +2879,20 @@
 	ipa3_usb_ctx->dl_data_pending = false;
 	mutex_init(&ipa3_usb_ctx->general_mutex);
 
+	if (ipa_pm_is_used()) {
+		struct ipa3_usb_pm_context *pm_ctx;
+
+		pm_ctx =
+			&ipa3_usb_ctx->ttype_ctx[IPA_USB_TRANSPORT_TETH].pm_ctx;
+		pm_ctx->hdl = ~0;
+		pm_ctx->remote_wakeup_work =
+			&ipa3_usb_notify_remote_wakeup_work;
+		pm_ctx = &ipa3_usb_ctx->ttype_ctx[IPA_USB_TRANSPORT_DPL].pm_ctx;
+		pm_ctx->hdl = ~0;
+		pm_ctx->remote_wakeup_work =
+			&ipa3_usb_dpl_notify_remote_wakeup_work;
+	}
+
 	for (i = 0; i < IPA_USB_TRANSPORT_MAX; i++) {
 		ipa3_usb_ctx->ttype_ctx[i].rm_ctx.prod_valid = false;
 		ipa3_usb_ctx->ttype_ctx[i].rm_ctx.cons_valid = false;
diff --git a/drivers/platform/msm/ipa/ipa_clients/odu_bridge.c b/drivers/platform/msm/ipa/ipa_clients/odu_bridge.c
index a623d0b..f0d1102 100644
--- a/drivers/platform/msm/ipa/ipa_clients/odu_bridge.c
+++ b/drivers/platform/msm/ipa/ipa_clients/odu_bridge.c
@@ -27,6 +27,7 @@
 #include <linux/cdev.h>
 #include <linux/ipa_odu_bridge.h>
 #include "../ipa_common_i.h"
+#include "../ipa_v3/ipa_pm.h"
 
 #define ODU_BRIDGE_DRV_NAME "odu_ipa_bridge"
 
@@ -152,6 +153,7 @@
 	void *logbuf_low;
 	struct completion rm_comp;
 	void (*wakeup_request)(void *);
+	u32 pm_hdl;
 };
 static struct odu_bridge_ctx *odu_bridge_ctx;
 
@@ -273,20 +275,22 @@
 	memset(&odu_prod_params, 0, sizeof(odu_prod_params));
 	memset(&odu_emb_cons_params, 0, sizeof(odu_emb_cons_params));
 
-	/* Build IPA Resource manager dependency graph */
-	ODU_BRIDGE_DBG_LOW("build dependency graph\n");
-	res = ipa_rm_add_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
+	if (!ipa_pm_is_used()) {
+		/* Build IPA Resource manager dependency graph */
+		ODU_BRIDGE_DBG_LOW("build dependency graph\n");
+		res = ipa_rm_add_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
 					IPA_RM_RESOURCE_Q6_CONS);
-	if (res && res != -EINPROGRESS) {
-		ODU_BRIDGE_ERR("ipa_rm_add_dependency() failed\n");
-		goto fail_add_dependency_1;
-	}
+		if (res && res != -EINPROGRESS) {
+			ODU_BRIDGE_ERR("ipa_rm_add_dependency() failed\n");
+			goto fail_add_dependency_1;
+		}
 
-	res = ipa_rm_add_dependency(IPA_RM_RESOURCE_Q6_PROD,
+		res = ipa_rm_add_dependency(IPA_RM_RESOURCE_Q6_PROD,
 					IPA_RM_RESOURCE_ODU_ADAPT_CONS);
-	if (res && res != -EINPROGRESS) {
-		ODU_BRIDGE_ERR("ipa_rm_add_dependency() failed\n");
-		goto fail_add_dependency_2;
+		if (res && res != -EINPROGRESS) {
+			ODU_BRIDGE_ERR("ipa_rm_add_dependency() failed\n");
+			goto fail_add_dependency_2;
+		}
 	}
 
 	/* configure RX (ODU->IPA) EP */
@@ -346,10 +350,12 @@
 	ipa_teardown_sys_pipe(odu_bridge_ctx->odu_prod_hdl);
 	odu_bridge_ctx->odu_prod_hdl = 0;
 fail_odu_prod:
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
+	if (!ipa_pm_is_used())
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
 				IPA_RM_RESOURCE_ODU_ADAPT_CONS);
 fail_add_dependency_2:
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
+	if (!ipa_pm_is_used())
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
 				IPA_RM_RESOURCE_Q6_CONS);
 fail_add_dependency_1:
 	return res;
@@ -397,17 +403,19 @@
 		ODU_BRIDGE_ERR("teardown ODU EMB CONS failed\n");
 	odu_bridge_ctx->odu_emb_cons_hdl = 0;
 
-	/* Delete IPA Resource manager dependency graph */
-	ODU_BRIDGE_DBG("deleting dependency graph\n");
-	res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
-		IPA_RM_RESOURCE_Q6_CONS);
-	if (res && res != -EINPROGRESS)
-		ODU_BRIDGE_ERR("ipa_rm_delete_dependency() failed\n");
+	if (!ipa_pm_is_used()) {
+		/* Delete IPA Resource manager dependency graph */
+		ODU_BRIDGE_DBG("deleting dependency graph\n");
+		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
+			IPA_RM_RESOURCE_Q6_CONS);
+		if (res && res != -EINPROGRESS)
+			ODU_BRIDGE_ERR("ipa_rm_delete_dependency() failed\n");
 
-	res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
-		IPA_RM_RESOURCE_ODU_ADAPT_CONS);
-	if (res && res != -EINPROGRESS)
-		ODU_BRIDGE_ERR("ipa_rm_delete_dependency() failed\n");
+		res = ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
+			IPA_RM_RESOURCE_ODU_ADAPT_CONS);
+		if (res && res != -EINPROGRESS)
+			ODU_BRIDGE_ERR("ipa_rm_delete_dependency() failed\n");
+	}
 
 	return 0;
 }
@@ -1319,24 +1327,58 @@
 	return 0;
 }
 
-/* IPA Bridge API is the new API which will replaces old odu_bridge API */
-int ipa_bridge_init(struct ipa_bridge_init_params *params, u32 *hdl)
+static void ipa_br_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	ODU_BRIDGE_FUNC_ENTRY();
+	if (event != IPA_PM_REQUEST_WAKEUP) {
+		ODU_BRIDGE_ERR("Unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+
+	if (odu_bridge_ctx->is_suspended)
+		odu_bridge_ctx->wakeup_request(odu_bridge_ctx->priv);
+	ODU_BRIDGE_FUNC_EXIT();
+}
+
+static int ipa_br_register_pm(void)
+{
+	struct ipa_pm_register_params reg_params;
+	int ret;
+
+	memset(&reg_params, 0, sizeof(reg_params));
+	reg_params.name = "ODU Bridge";
+	reg_params.callback = ipa_br_pm_cb;
+	reg_params.group = IPA_PM_GROUP_DEFAULT;
+
+	ret = ipa_pm_register(&reg_params,
+		&odu_bridge_ctx->pm_hdl);
+	if (ret) {
+		ODU_BRIDGE_ERR("fail to register with PM %d\n", ret);
+		goto fail_pm_reg;
+	}
+
+	ret = ipa_pm_associate_ipa_cons_to_client(odu_bridge_ctx->pm_hdl,
+		IPA_CLIENT_ODU_EMB_CONS);
+	if (ret) {
+		ODU_BRIDGE_ERR("fail to associate cons with PM %d\n", ret);
+		goto fail_pm_cons;
+	}
+
+	return 0;
+
+fail_pm_cons:
+	ipa_pm_deregister(odu_bridge_ctx->pm_hdl);
+	odu_bridge_ctx->pm_hdl = ~0;
+fail_pm_reg:
+	return ret;
+}
+
+static int ipa_br_create_rm_resources(void)
 {
 	int ret;
 	struct ipa_rm_create_params create_params;
 
-	if (!params || !params->wakeup_request || !hdl) {
-		ODU_BRIDGE_ERR("NULL arg\n");
-		return -EINVAL;
-	}
-
-
-	ret = odu_bridge_init(&params->info);
-	if (ret)
-		return ret;
-
-	odu_bridge_ctx->wakeup_request = params->wakeup_request;
-
 	/* create IPA RM resources for power management */
 	init_completion(&odu_bridge_ctx->rm_comp);
 	memset(&create_params, 0, sizeof(create_params));
@@ -1368,9 +1410,6 @@
 		goto fail_rm_cons;
 	}
 
-	/* handle is ignored for now */
-	*hdl = 0;
-
 	return 0;
 
 fail_rm_cons:
@@ -1379,6 +1418,41 @@
 fail_add_dep:
 	ipa_rm_delete_resource(IPA_RM_RESOURCE_ODU_ADAPT_PROD);
 fail_rm_prod:
+	return ret;
+}
+
+/* IPA Bridge API is the new API which will replaces old odu_bridge API */
+int ipa_bridge_init(struct ipa_bridge_init_params *params, u32 *hdl)
+{
+	int ret;
+
+	if (!params || !params->wakeup_request || !hdl) {
+		ODU_BRIDGE_ERR("NULL arg\n");
+		return -EINVAL;
+	}
+
+
+	ret = odu_bridge_init(&params->info);
+	if (ret)
+		return ret;
+
+	odu_bridge_ctx->wakeup_request = params->wakeup_request;
+
+	if (ipa_pm_is_used())
+		ret = ipa_br_register_pm();
+	else
+		ret = ipa_br_create_rm_resources();
+	if (ret) {
+		ODU_BRIDGE_ERR("fail to register woth RM/PM %d\n", ret);
+		goto fail_pm;
+	}
+
+	/* handle is ignored for now */
+	*hdl = 0;
+
+	return 0;
+
+fail_pm:
 	odu_bridge_cleanup();
 	return ret;
 }
@@ -1398,7 +1472,10 @@
 		return -EFAULT;
 	}
 
-	ret = ipa_br_request_prod();
+	if (ipa_pm_is_used())
+		ret = ipa_pm_activate_sync(odu_bridge_ctx->pm_hdl);
+	else
+		ret = ipa_br_request_prod();
 	if (ret)
 		return ret;
 
@@ -1411,6 +1488,10 @@
 	struct ipa_rm_perf_profile profile = {0};
 	int ret;
 
+	if (ipa_pm_is_used())
+		return ipa_pm_set_perf_profile(odu_bridge_ctx->pm_hdl,
+			bandwidth);
+
 	profile.max_supported_bandwidth_mbps = bandwidth;
 	ret = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_ODU_ADAPT_PROD, &profile);
 	if (ret) {
@@ -1436,7 +1517,10 @@
 	if (ret)
 		return ret;
 
-	ret = ipa_br_release_prod();
+	if (ipa_pm_is_used())
+		ret = ipa_pm_deactivate_sync(odu_bridge_ctx->pm_hdl);
+	else
+		ret = ipa_br_release_prod();
 	if (ret)
 		return ret;
 
@@ -1470,7 +1554,10 @@
 		return ret;
 	}
 
-	ret = ipa_br_release_prod();
+	if (ipa_pm_is_used())
+		ret = ipa_pm_deactivate_sync(odu_bridge_ctx->pm_hdl);
+	else
+		ret = ipa_br_release_prod();
 	if (ret) {
 		ODU_BRIDGE_ERR("failed to release prod %d\n", ret);
 		ipa_start_gsi_channel(odu_bridge_ctx->odu_emb_cons_hdl);
@@ -1501,7 +1588,10 @@
 		return -EFAULT;
 	}
 
-	ret = ipa_br_request_prod();
+	if (ipa_pm_is_used())
+		ret = ipa_pm_activate_sync(odu_bridge_ctx->pm_hdl);
+	else
+		ret = ipa_br_request_prod();
 	if (ret)
 		return ret;
 
@@ -1523,12 +1613,27 @@
 }
 EXPORT_SYMBOL(ipa_bridge_tx_dp);
 
-int ipa_bridge_cleanup(u32 hdl)
+static void ipa_br_delete_rm_resources(void)
 {
 	ipa_rm_delete_dependency(IPA_RM_RESOURCE_ODU_ADAPT_PROD,
 		IPA_RM_RESOURCE_APPS_CONS);
 	ipa_rm_delete_resource(IPA_RM_RESOURCE_ODU_ADAPT_PROD);
 	ipa_rm_delete_resource(IPA_RM_RESOURCE_ODU_ADAPT_CONS);
+}
+
+static void ipa_br_deregister_pm(void)
+{
+	ipa_pm_deactivate_sync(odu_bridge_ctx->pm_hdl);
+	ipa_pm_deregister(odu_bridge_ctx->pm_hdl);
+	odu_bridge_ctx->pm_hdl = ~0;
+}
+
+int ipa_bridge_cleanup(u32 hdl)
+{
+	if (ipa_pm_is_used())
+		ipa_br_deregister_pm();
+	else
+		ipa_br_delete_rm_resources();
 	return odu_bridge_cleanup();
 }
 EXPORT_SYMBOL(ipa_bridge_cleanup);
diff --git a/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c b/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c
index f62cb27..1c47e69 100644
--- a/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c
+++ b/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c
@@ -9,7 +9,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
-
 #include <linux/atomic.h>
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
@@ -27,6 +26,8 @@
 #include <linux/random.h>
 #include <linux/rndis_ipa.h>
 #include <linux/workqueue.h>
+#include "../ipa_common_i.h"
+#include "../ipa_v3/ipa_pm.h"
 
 #define CREATE_TRACE_POINTS
 #include "rndis_ipa_trace.h"
@@ -160,6 +161,7 @@
  * state is changed to RNDIS_IPA_CONNECTED_AND_UP
  * @xmit_error_delayed_work: work item for cases where IPA driver Tx fails
  * @state_lock: used to protect the state variable.
+ * @pm_hdl: handle for IPA PM framework
  */
 struct rndis_ipa_dev {
 	struct net_device *net;
@@ -188,6 +190,7 @@
 	void (*device_ready_notify)(void);
 	struct delayed_work xmit_error_delayed_work;
 	spinlock_t state_lock; /* Spinlock for the state variable.*/
+	u32 pm_hdl;
 };
 
 /**
@@ -233,6 +236,8 @@
 	unsigned long data);
 static int rndis_ipa_create_rm_resource(struct rndis_ipa_dev *rndis_ipa_ctx);
 static int rndis_ipa_destroy_rm_resource(struct rndis_ipa_dev *rndis_ipa_ctx);
+static int rndis_ipa_register_pm_client(struct rndis_ipa_dev *rndis_ipa_ctx);
+static int rndis_ipa_deregister_pm_client(struct rndis_ipa_dev *rndis_ipa_ctx);
 static bool rx_filter(struct sk_buff *skb);
 static bool tx_filter(struct sk_buff *skb);
 static bool rm_enabled(struct rndis_ipa_dev *rndis_ipa_ctx);
@@ -701,7 +706,10 @@
 		return -EINVAL;
 	}
 
-	result = rndis_ipa_create_rm_resource(rndis_ipa_ctx);
+	if (ipa_pm_is_used())
+		result = rndis_ipa_register_pm_client(rndis_ipa_ctx);
+	else
+		result = rndis_ipa_create_rm_resource(rndis_ipa_ctx);
 	if (result) {
 		RNDIS_IPA_ERROR("fail on RM create\n");
 		goto fail_create_rm;
@@ -763,7 +771,10 @@
 	return 0;
 
 fail:
-	rndis_ipa_destroy_rm_resource(rndis_ipa_ctx);
+	if (ipa_pm_is_used())
+		rndis_ipa_deregister_pm_client(rndis_ipa_ctx);
+	else
+		rndis_ipa_destroy_rm_resource(rndis_ipa_ctx);
 fail_create_rm:
 	return result;
 }
@@ -1235,7 +1246,10 @@
 	rndis_ipa_ctx->net->stats.tx_dropped += outstanding_dropped_pkts;
 	atomic_set(&rndis_ipa_ctx->outstanding_pkts, 0);
 
-	retval = rndis_ipa_destroy_rm_resource(rndis_ipa_ctx);
+	if (ipa_pm_is_used())
+		retval = rndis_ipa_deregister_pm_client(rndis_ipa_ctx);
+	else
+		retval = rndis_ipa_destroy_rm_resource(rndis_ipa_ctx);
 	if (retval) {
 		RNDIS_IPA_ERROR("Fail to clean RM\n");
 		return retval;
@@ -1772,6 +1786,29 @@
 	return result;
 }
 
+static void rndis_ipa_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	struct rndis_ipa_dev *rndis_ipa_ctx = p;
+
+	RNDIS_IPA_LOG_ENTRY();
+
+	if (event != IPA_PM_CLIENT_ACTIVATED) {
+		RNDIS_IPA_ERROR("unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+	RNDIS_IPA_DEBUG("Resource Granted\n");
+
+	if (netif_queue_stopped(rndis_ipa_ctx->net)) {
+		RNDIS_IPA_DEBUG("starting queue\n");
+		netif_start_queue(rndis_ipa_ctx->net);
+	} else {
+		RNDIS_IPA_DEBUG("queue already awake\n");
+	}
+
+	RNDIS_IPA_LOG_EXIT();
+}
+
 /**
  * rndis_ipa_destroy_rm_resource() - delete the dependency and destroy
  * the resource done on rndis_ipa_create_rm_resource()
@@ -1831,6 +1868,33 @@
 	return result;
 }
 
+static int rndis_ipa_register_pm_client(struct rndis_ipa_dev *rndis_ipa_ctx)
+{
+	int result;
+	struct ipa_pm_register_params pm_reg;
+
+	memset(&pm_reg, 0, sizeof(pm_reg));
+
+	pm_reg.name = rndis_ipa_ctx->net->name;
+	pm_reg.user_data = rndis_ipa_ctx;
+	pm_reg.callback = rndis_ipa_pm_cb;
+	pm_reg.group = IPA_PM_GROUP_APPS;
+	result = ipa_pm_register(&pm_reg, &rndis_ipa_ctx->pm_hdl);
+	if (result) {
+		RNDIS_IPA_ERROR("failed to create IPA PM client %d\n", result);
+		return result;
+	}
+	return 0;
+}
+
+static int rndis_ipa_deregister_pm_client(struct rndis_ipa_dev *rndis_ipa_ctx)
+{
+	ipa_pm_deactivate_sync(rndis_ipa_ctx->pm_hdl);
+	ipa_pm_deregister(rndis_ipa_ctx->pm_hdl);
+	rndis_ipa_ctx->pm_hdl = ~0;
+	return 0;
+}
+
 /**
  * resource_request() - request for the Netdev resource
  * @rndis_ipa_ctx: main driver context
@@ -1849,11 +1913,14 @@
 	int result = 0;
 
 	if (!rm_enabled(rndis_ipa_ctx))
-		goto out;
-	result = ipa_rm_inactivity_timer_request_resource(
+		return result;
+
+	if (ipa_pm_is_used())
+		return ipa_pm_activate(rndis_ipa_ctx->pm_hdl);
+
+	return ipa_rm_inactivity_timer_request_resource(
 			DRV_RESOURCE_ID);
-out:
-	return result;
+
 }
 
 /**
@@ -1868,9 +1935,12 @@
 static void resource_release(struct rndis_ipa_dev *rndis_ipa_ctx)
 {
 	if (!rm_enabled(rndis_ipa_ctx))
-		goto out;
-	ipa_rm_inactivity_timer_release_resource(DRV_RESOURCE_ID);
-out:
+		return;
+	if (ipa_pm_is_used())
+		ipa_pm_deferred_deactivate(rndis_ipa_ctx->pm_hdl);
+	else
+		ipa_rm_inactivity_timer_release_resource(DRV_RESOURCE_ID);
+
 	return;
 }
 
diff --git a/drivers/platform/msm/ipa/ipa_common_i.h b/drivers/platform/msm/ipa/ipa_common_i.h
index 32c8b25..a487bf4 100644
--- a/drivers/platform/msm/ipa/ipa_common_i.h
+++ b/drivers/platform/msm/ipa/ipa_common_i.h
@@ -386,4 +386,6 @@
 const char *ipa_get_version_string(enum ipa_hw_type ver);
 int ipa_start_gsi_channel(u32 clnt_hdl);
 
+bool ipa_pm_is_used(void);
+
 #endif /* _IPA_COMMON_I_H_ */
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa.c b/drivers/platform/msm/ipa/ipa_v2/ipa.c
index bfd0446..6230356 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa.c
@@ -531,11 +531,12 @@
 	kfree(buff);
 }
 
-static int ipa_send_wan_msg(unsigned long usr_param, uint8_t msg_type)
+static int ipa_send_wan_msg(unsigned long usr_param, uint8_t msg_type, bool is_cache)
 {
 	int retval;
 	struct ipa_wan_msg *wan_msg;
 	struct ipa_msg_meta msg_meta;
+	struct ipa_wan_msg cache_wan_msg;
 
 	wan_msg = kzalloc(sizeof(struct ipa_wan_msg), GFP_KERNEL);
 	if (!wan_msg) {
@@ -549,6 +550,8 @@
 		return -EFAULT;
 	}
 
+	memcpy(&cache_wan_msg, wan_msg, sizeof(cache_wan_msg));
+
 	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
 	msg_meta.msg_type = msg_type;
 	msg_meta.msg_len = sizeof(struct ipa_wan_msg);
@@ -559,6 +562,25 @@
 		return retval;
 	}
 
+	if (is_cache) {
+		mutex_lock(&ipa_ctx->ipa_cne_evt_lock);
+
+		/* cache the cne event */
+		memcpy(&ipa_ctx->ipa_cne_evt_req_cache[
+			ipa_ctx->num_ipa_cne_evt_req].wan_msg,
+			&cache_wan_msg,
+			sizeof(cache_wan_msg));
+
+		memcpy(&ipa_ctx->ipa_cne_evt_req_cache[
+			ipa_ctx->num_ipa_cne_evt_req].msg_meta,
+			&msg_meta,
+			sizeof(struct ipa_msg_meta));
+
+		ipa_ctx->num_ipa_cne_evt_req++;
+		ipa_ctx->num_ipa_cne_evt_req %= IPA_MAX_NUM_REQ_CACHE;
+		mutex_unlock(&ipa_ctx->ipa_cne_evt_lock);
+	}
+
 	return 0;
 }
 
@@ -1328,21 +1350,21 @@
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD:
-		retval = ipa_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_ADD);
+		retval = ipa_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_ADD, true);
 		if (retval) {
 			IPAERR("ipa_send_wan_msg failed: %d\n", retval);
 			break;
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL:
-		retval = ipa_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_DEL);
+		retval = ipa_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_DEL, true);
 		if (retval) {
 			IPAERR("ipa_send_wan_msg failed: %d\n", retval);
 			break;
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED:
-		retval = ipa_send_wan_msg(arg, WAN_EMBMS_CONNECT);
+		retval = ipa_send_wan_msg(arg, WAN_EMBMS_CONNECT, false);
 		if (retval) {
 			IPAERR("ipa_send_wan_msg failed: %d\n", retval);
 			break;
@@ -4169,6 +4191,7 @@
 
 	mutex_init(&ipa_ctx->lock);
 	mutex_init(&ipa_ctx->nat_mem.lock);
+	mutex_init(&ipa_ctx->ipa_cne_evt_lock);
 
 	idr_init(&ipa_ctx->ipa_idr);
 	spin_lock_init(&ipa_ctx->idr_lock);
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_debugfs.c b/drivers/platform/msm/ipa/ipa_v2/ipa_debugfs.c
index 2b517a1..7aa7ffd 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_debugfs.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_debugfs.c
@@ -811,10 +811,11 @@
 			eq = true;
 		} else {
 			rt_tbl = ipa_id_find(entry->rule.rt_tbl_hdl);
-			if (rt_tbl)
-				rt_tbl_idx = rt_tbl->idx;
+			if (rt_tbl == NULL ||
+				rt_tbl->cookie != IPA_RT_TBL_COOKIE)
+				rt_tbl_idx =  ~0;
 			else
-				rt_tbl_idx = ~0;
+				rt_tbl_idx = rt_tbl->idx;
 			bitmap = entry->rule.attrib.attrib_mask;
 			eq = false;
 		}
@@ -841,10 +842,11 @@
 				eq = true;
 			} else {
 				rt_tbl = ipa_id_find(entry->rule.rt_tbl_hdl);
-				if (rt_tbl)
-					rt_tbl_idx = rt_tbl->idx;
-				else
+				if (rt_tbl == NULL ||
+					rt_tbl->cookie != IPA_RT_TBL_COOKIE)
 					rt_tbl_idx = ~0;
+				else
+					rt_tbl_idx = rt_tbl->idx;
 				bitmap = entry->rule.attrib.attrib_mask;
 				eq = false;
 			}
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_i.h b/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
index 141bff1..9bfdcdc 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
@@ -63,6 +63,9 @@
 
 #define IPA_MAX_STATUS_STAT_NUM 30
 
+
+#define IPA_MAX_NUM_REQ_CACHE 10
+
 #define IPADBG(fmt, args...) \
 	pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
 #define IPAERR(fmt, args...) \
@@ -968,6 +971,11 @@
 	bool uplink;
 };
 
+struct ipa_cne_evt {
+	struct ipa_wan_msg wan_msg;
+	struct ipa_msg_meta msg_meta;
+};
+
 /**
  * struct ipa_context - IPA context
  * @class: pointer to the struct class
@@ -1164,6 +1172,9 @@
 	u32 ipa_rx_min_timeout_usec;
 	u32 ipa_rx_max_timeout_usec;
 	u32 ipa_polling_iteration;
+	struct ipa_cne_evt ipa_cne_evt_req_cache[IPA_MAX_NUM_REQ_CACHE];
+	int num_ipa_cne_evt_req;
+	struct mutex ipa_cne_evt_lock;
 };
 
 /**
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_qmi_service.c b/drivers/platform/msm/ipa/ipa_v2/ipa_qmi_service.c
index 57e0a53..2608e1d 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_qmi_service.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_qmi_service.c
@@ -655,9 +655,8 @@
 
 	/* check if the filter rules from IPACM is valid */
 	if (req->filter_index_list_len == 0) {
-		IPAWANERR(" delete UL filter rule for pipe %d\n",
+		IPAWANDBG(" delete UL filter rule for pipe %d\n",
 		req->source_pipe_index);
-		return -EINVAL;
 	} else if (req->filter_index_list_len > QMI_IPA_MAX_FILTERS_V01) {
 		IPAWANERR(" UL filter rule for pipe %d exceed max (%u)\n",
 		req->source_pipe_index,
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
index 50930d3..bada5cc 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
@@ -53,7 +53,7 @@
 	int pipe_idx;
 
 	if (buf == NULL) {
-		memset(tmp, 0, IPA_RT_FLT_HW_RULE_BUF_SIZE);
+		memset(tmp, 0, (IPA_RT_FLT_HW_RULE_BUF_SIZE/4));
 		buf = (u8 *)tmp;
 	}
 
@@ -75,8 +75,15 @@
 	rule_hdr->u.hdr.pipe_dest_idx = pipe_idx;
 	rule_hdr->u.hdr.system = !ipa_ctx->hdr_tbl_lcl;
 	if (entry->hdr) {
-		rule_hdr->u.hdr.hdr_offset =
-			entry->hdr->offset_entry->offset >> 2;
+		if (entry->hdr->cookie == IPA_HDR_COOKIE) {
+			rule_hdr->u.hdr.hdr_offset =
+				entry->hdr->offset_entry->offset >> 2;
+		} else {
+			IPAERR("Entry hdr deleted by user = %d cookie = %u\n",
+				entry->hdr->user_deleted, entry->hdr->cookie);
+			WARN_ON(1);
+			rule_hdr->u.hdr.hdr_offset = 0;
+		}
 	} else {
 		rule_hdr->u.hdr.hdr_offset = 0;
 	}
diff --git a/drivers/platform/msm/ipa/ipa_v2/rmnet_ipa.c b/drivers/platform/msm/ipa/ipa_v2/rmnet_ipa.c
index 9c75202..2f272d2 100644
--- a/drivers/platform/msm/ipa/ipa_v2/rmnet_ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v2/rmnet_ipa.c
@@ -411,12 +411,15 @@
 {
 	int i, j;
 
+	/* prevent multi-threads accessing num_q6_rule */
+	mutex_lock(&add_mux_channel_lock);
 	if (rule_req->filter_spec_list_valid == true) {
 		num_q6_rule = rule_req->filter_spec_list_len;
 		IPAWANDBG("Received (%d) install_flt_req\n", num_q6_rule);
 	} else {
 		num_q6_rule = 0;
 		IPAWANERR("got no UL rules from modem\n");
+		mutex_unlock(&add_mux_channel_lock);
 		return -EINVAL;
 	}
 
@@ -610,9 +613,11 @@
 	num_q6_rule = 0;
 	memset(ipa_qmi_ctx->q6_ul_filter_rule, 0,
 		sizeof(ipa_qmi_ctx->q6_ul_filter_rule));
+	mutex_unlock(&add_mux_channel_lock);
 	return -EINVAL;
 
 success:
+	mutex_unlock(&add_mux_channel_lock);
 	return 0;
 }
 
@@ -1621,9 +1626,12 @@
 				/* already got Q6 UL filter rules*/
 				if (ipa_qmi_ctx &&
 					ipa_qmi_ctx->modem_cfg_emb_pipe_flt
-					== false)
+					== false) {
+					/* protect num_q6_rule */
+					mutex_lock(&add_mux_channel_lock);
 					rc = wwan_add_ul_flt_rule_to_ipa();
-				else
+					mutex_unlock(&add_mux_channel_lock);
+				} else
 					rc = 0;
 				egress_set = true;
 				if (rc)
diff --git a/drivers/platform/msm/ipa/ipa_v3/Makefile b/drivers/platform/msm/ipa/ipa_v3/Makefile
index e3f8d45..5db2545 100644
--- a/drivers/platform/msm/ipa/ipa_v3/Makefile
+++ b/drivers/platform/msm/ipa/ipa_v3/Makefile
@@ -4,6 +4,6 @@
 ipat-y := ipa.o ipa_debugfs.o ipa_hdr.o ipa_flt.o ipa_rt.o ipa_dp.o ipa_client.o \
 	ipa_utils.o ipa_nat.o ipa_intf.o teth_bridge.o ipa_interrupts.o \
 	ipa_uc.o ipa_uc_wdi.o ipa_dma.o ipa_uc_mhi.o ipa_mhi.o ipa_uc_ntn.o \
-	ipa_hw_stats.o
+	ipa_hw_stats.o ipa_pm.o
 
 obj-$(CONFIG_RMNET_IPA3) += rmnet_ipa.o ipa_qmi_service_v01.o ipa_qmi_service.o rmnet_ipa_fd_ioctl.o
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index d1766dd..e9df986 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -88,6 +88,10 @@
 
 #define IPA_SMEM_SIZE (8 * 1024)
 
+#define IPA_GSI_CHANNEL_HALT_MIN_SLEEP 5000
+#define IPA_GSI_CHANNEL_HALT_MAX_SLEEP 10000
+#define IPA_GSI_CHANNEL_HALT_MAX_TRY 10
+
 /* round addresses for closes page per SMMU requirements */
 #define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
 	do { \
@@ -536,11 +540,12 @@
 	kfree(buff);
 }
 
-static int ipa3_send_wan_msg(unsigned long usr_param, uint8_t msg_type)
+static int ipa3_send_wan_msg(unsigned long usr_param, uint8_t msg_type, bool is_cache)
 {
 	int retval;
 	struct ipa_wan_msg *wan_msg;
 	struct ipa_msg_meta msg_meta;
+	struct ipa_wan_msg cache_wan_msg;
 
 	wan_msg = kzalloc(sizeof(struct ipa_wan_msg), GFP_KERNEL);
 	if (!wan_msg) {
@@ -554,6 +559,8 @@
 		return -EFAULT;
 	}
 
+	memcpy(&cache_wan_msg, wan_msg, sizeof(cache_wan_msg));
+
 	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
 	msg_meta.msg_type = msg_type;
 	msg_meta.msg_len = sizeof(struct ipa_wan_msg);
@@ -564,6 +571,25 @@
 		return retval;
 	}
 
+	if (is_cache) {
+		mutex_lock(&ipa3_ctx->ipa_cne_evt_lock);
+
+		/* cache the cne event */
+		memcpy(&ipa3_ctx->ipa_cne_evt_req_cache[
+			ipa3_ctx->num_ipa_cne_evt_req].wan_msg,
+			&cache_wan_msg,
+			sizeof(cache_wan_msg));
+
+		memcpy(&ipa3_ctx->ipa_cne_evt_req_cache[
+			ipa3_ctx->num_ipa_cne_evt_req].msg_meta,
+			&msg_meta,
+			sizeof(struct ipa_msg_meta));
+
+		ipa3_ctx->num_ipa_cne_evt_req++;
+		ipa3_ctx->num_ipa_cne_evt_req %= IPA_MAX_NUM_REQ_CACHE;
+		mutex_unlock(&ipa3_ctx->ipa_cne_evt_lock);
+	}
+
 	return 0;
 }
 
@@ -1443,6 +1469,10 @@
 		}
 		break;
 	case IPA_IOC_RM_ADD_DEPENDENCY:
+		/* deprecate if IPA PM is used */
+		if (ipa3_ctx->use_ipa_pm)
+			return 0;
+
 		if (copy_from_user((u8 *)&rm_depend, (u8 *)arg,
 				sizeof(struct ipa_ioc_rm_dependency))) {
 			retval = -EFAULT;
@@ -1452,6 +1482,10 @@
 			rm_depend.resource_name, rm_depend.depends_on_name);
 		break;
 	case IPA_IOC_RM_DEL_DEPENDENCY:
+		/* deprecate if IPA PM is used */
+		if (ipa3_ctx->use_ipa_pm)
+			return 0;
+
 		if (copy_from_user((u8 *)&rm_depend, (u8 *)arg,
 				sizeof(struct ipa_ioc_rm_dependency))) {
 			retval = -EFAULT;
@@ -1520,21 +1554,21 @@
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD:
-		retval = ipa3_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_ADD);
+		retval = ipa3_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_ADD, true);
 		if (retval) {
 			IPAERR("ipa3_send_wan_msg failed: %d\n", retval);
 			break;
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL:
-		retval = ipa3_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_DEL);
+		retval = ipa3_send_wan_msg(arg, WAN_UPSTREAM_ROUTE_DEL, true);
 		if (retval) {
 			IPAERR("ipa3_send_wan_msg failed: %d\n", retval);
 			break;
 		}
 		break;
 	case IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED:
-		retval = ipa3_send_wan_msg(arg, WAN_EMBMS_CONNECT);
+		retval = ipa3_send_wan_msg(arg, WAN_EMBMS_CONNECT, false);
 		if (retval) {
 			IPAERR("ipa3_send_wan_msg failed: %d\n", retval);
 			break;
@@ -1969,6 +2003,7 @@
 	int ep_idx;
 	int client_idx;
 	const struct ipa_gsi_ep_config *gsi_ep_cfg;
+	int i;
 	int ret;
 	int code = 0;
 
@@ -1988,6 +2023,19 @@
 			ret = gsi_halt_channel_ee(
 				gsi_ep_cfg->ipa_gsi_chan_num, gsi_ep_cfg->ee,
 				&code);
+			for (i = 0; i < IPA_GSI_CHANNEL_STOP_MAX_RETRY &&
+				ret == -GSI_STATUS_AGAIN; i++) {
+				IPADBG(
+				"ch %d ee %d with code %d\n is busy try again",
+					gsi_ep_cfg->ipa_gsi_chan_num,
+					gsi_ep_cfg->ee,
+					code);
+				usleep_range(IPA_GSI_CHANNEL_HALT_MIN_SLEEP,
+					IPA_GSI_CHANNEL_HALT_MAX_SLEEP);
+				ret = gsi_halt_channel_ee(
+					gsi_ep_cfg->ipa_gsi_chan_num,
+					gsi_ep_cfg->ee, &code);
+			}
 			if (ret == GSI_STATUS_SUCCESS)
 				IPADBG("halted gsi ch %d ee %d with code %d\n",
 				gsi_ep_cfg->ipa_gsi_chan_num,
@@ -2313,7 +2361,6 @@
 	struct ipahal_imm_cmd_register_write reg_write;
 	struct ipahal_imm_cmd_pyld *cmd_pyld;
 	int retval;
-	struct ipahal_reg_valmask valmask;
 
 	desc = kcalloc(ipa3_ctx->ipa_num_pipes, sizeof(struct ipa3_desc),
 			GFP_KERNEL);
@@ -2328,39 +2375,10 @@
 		if (ep_idx == -1)
 			continue;
 
-		if (ipa3_ctx->ep[ep_idx].valid &&
-			ipa3_ctx->ep[ep_idx].skip_ep_cfg) {
-			BUG_ON(num_descs >= ipa3_ctx->ipa_num_pipes);
-
-			reg_write.skip_pipeline_clear = false;
-			reg_write.pipeline_clear_options =
-				IPAHAL_HPS_CLEAR;
-			reg_write.offset =
-				ipahal_get_reg_n_ofst(IPA_ENDP_STATUS_n,
-					ep_idx);
-			ipahal_get_status_ep_valmask(
-				ipa3_get_ep_mapping(IPA_CLIENT_APPS_LAN_CONS),
-				&valmask);
-			reg_write.value = valmask.val;
-			reg_write.value_mask = valmask.mask;
-			cmd_pyld = ipahal_construct_imm_cmd(
-				IPA_IMM_CMD_REGISTER_WRITE, &reg_write, false);
-			if (!cmd_pyld) {
-				IPAERR("fail construct register_write cmd\n");
-				BUG();
-			}
-
-			desc[num_descs].opcode = cmd_pyld->opcode;
-			desc[num_descs].type = IPA_IMM_CMD_DESC;
-			desc[num_descs].callback = ipa3_destroy_imm;
-			desc[num_descs].user1 = cmd_pyld;
-			desc[num_descs].pyld = cmd_pyld->data;
-			desc[num_descs].len = cmd_pyld->len;
-			num_descs++;
-		}
-
-		/* disable statuses for modem producers */
-		if (IPA_CLIENT_IS_Q6_PROD(client_idx)) {
+		/* disable statuses for all modem controlled prod pipes */
+		if (IPA_CLIENT_IS_Q6_PROD(client_idx) ||
+			(ipa3_ctx->ep[ep_idx].valid &&
+			ipa3_ctx->ep[ep_idx].skip_ep_cfg)) {
 			ipa_assert_on(num_descs >= ipa3_ctx->ipa_num_pipes);
 
 			reg_write.skip_pipeline_clear = false;
@@ -3294,21 +3312,20 @@
 {
 	unsigned int idx = 1;
 
-	if (ipa3_ctx->curr_ipa_clk_rate == ipa3_ctx->ctrl->ipa_clk_rate_svs) {
+	if (ipa3_ctx->curr_ipa_clk_rate == ipa3_ctx->ctrl->ipa_clk_rate_svs2) {
 		idx = 1;
 	} else if (ipa3_ctx->curr_ipa_clk_rate ==
-			ipa3_ctx->ctrl->ipa_clk_rate_nominal) {
-		if (ipa3_ctx->ctrl->msm_bus_data_ptr->num_usecases <= 2)
-			idx = 1;
-		else
-			idx = 2;
+		ipa3_ctx->ctrl->ipa_clk_rate_svs) {
+		idx = 2;
+	} else if (ipa3_ctx->curr_ipa_clk_rate ==
+		ipa3_ctx->ctrl->ipa_clk_rate_nominal) {
+		idx = 3;
 	} else if (ipa3_ctx->curr_ipa_clk_rate ==
 			ipa3_ctx->ctrl->ipa_clk_rate_turbo) {
 		idx = ipa3_ctx->ctrl->msm_bus_data_ptr->num_usecases - 1;
 	} else {
 		WARN_ON(1);
 	}
-
 	IPADBG("curr %d idx %d\n", ipa3_ctx->curr_ipa_clk_rate, idx);
 
 	return idx;
@@ -3676,6 +3693,53 @@
 	spin_unlock_irqrestore(&ipa3_ctx->wakelock_ref_cnt.spinlock, flags);
 }
 
+int ipa3_set_clock_plan_from_pm(int idx)
+{
+	u32 clk_rate;
+
+	IPADBG_LOW("idx = %d\n", idx);
+
+	if (idx <= 0 || idx >= ipa3_ctx->ctrl->msm_bus_data_ptr->num_usecases) {
+		IPAERR("bad voltage\n");
+		return -EINVAL;
+	}
+
+	if (idx == 1)
+		clk_rate = ipa3_ctx->ctrl->ipa_clk_rate_svs;
+	else if (idx == 2)
+		clk_rate = ipa3_ctx->ctrl->ipa_clk_rate_nominal;
+	else if (idx == 3)
+		clk_rate = ipa3_ctx->ctrl->ipa_clk_rate_turbo;
+	else {
+		IPAERR("bad voltage\n");
+		WARN_ON(1);
+		return -EFAULT;
+	}
+
+	if (clk_rate == ipa3_ctx->curr_ipa_clk_rate) {
+		IPADBG_LOW("Same voltage\n");
+		return 0;
+	}
+
+	mutex_lock(&ipa3_ctx->ipa3_active_clients.mutex);
+	ipa3_ctx->curr_ipa_clk_rate = clk_rate;
+	ipa3_ctx->ipa3_active_clients.bus_vote_idx = idx;
+	IPADBG_LOW("setting clock rate to %u\n", ipa3_ctx->curr_ipa_clk_rate);
+	if (atomic_read(&ipa3_ctx->ipa3_active_clients.cnt) > 0) {
+		if (ipa3_clk)
+			clk_set_rate(ipa3_clk, ipa3_ctx->curr_ipa_clk_rate);
+		if (msm_bus_scale_client_update_request(ipa3_ctx->ipa_bus_hdl,
+				ipa3_get_bus_vote()))
+			WARN_ON(1);
+	} else {
+		IPADBG_LOW("clocks are gated, not setting rate\n");
+	}
+	mutex_unlock(&ipa3_ctx->ipa3_active_clients.mutex);
+	IPADBG_LOW("Done\n");
+
+	return 0;
+}
+
 int ipa3_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
 				  u32 bandwidth_mbps)
 {
@@ -3699,8 +3763,11 @@
 		else if (bandwidth_mbps >=
 			ipa3_ctx->ctrl->clock_scaling_bw_threshold_nominal)
 			needed_voltage = IPA_VOLTAGE_NOMINAL;
-		else
+		else if (bandwidth_mbps >=
+			ipa3_ctx->ctrl->clock_scaling_bw_threshold_svs)
 			needed_voltage = IPA_VOLTAGE_SVS;
+		else
+			needed_voltage = IPA_VOLTAGE_SVS2;
 	} else {
 		IPADBG_LOW("Clock scaling is disabled\n");
 		needed_voltage = IPA_VOLTAGE_NOMINAL;
@@ -3708,6 +3775,9 @@
 
 	needed_voltage = max(needed_voltage, floor_voltage);
 	switch (needed_voltage) {
+	case IPA_VOLTAGE_SVS2:
+		clk_rate = ipa3_ctx->ctrl->ipa_clk_rate_svs2;
+		break;
 	case IPA_VOLTAGE_SVS:
 		clk_rate = ipa3_ctx->ctrl->ipa_clk_rate_svs;
 		break;
@@ -3772,14 +3842,19 @@
 	u32 i = 0;
 	int res;
 	struct ipa_ep_cfg_holb holb_cfg;
+	u32 pipe_bitmask = 0;
 
 	IPADBG("interrupt=%d, interrupt_data=%u\n",
 		interrupt, suspend_data);
 	memset(&holb_cfg, 0, sizeof(holb_cfg));
 	holb_cfg.tmr_val = 0;
 
-	for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
+	for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++, bmsk = bmsk << 1) {
 		if ((suspend_data & bmsk) && (ipa3_ctx->ep[i].valid)) {
+			if (ipa3_ctx->use_ipa_pm) {
+				pipe_bitmask |= bmsk;
+				continue;
+			}
 			if (IPA_CLIENT_IS_APPS_CONS(ipa3_ctx->ep[i].client)) {
 				/*
 				 * pipe will be unsuspended as part of
@@ -3818,7 +3893,13 @@
 				}
 			}
 		}
-		bmsk = bmsk << 1;
+	}
+	if (ipa3_ctx->use_ipa_pm) {
+		res = ipa_pm_handle_suspend(pipe_bitmask);
+		if (res) {
+			IPAERR("ipa_pm_handle_suspend failed %d\n", res);
+			return;
+		}
 	}
 }
 
@@ -4349,6 +4430,8 @@
 	if (IS_ERR_OR_NULL(subsystem_get_retval)) {
 		IPAERR("Unable to trigger PIL process for FW loading\n");
 		return -EINVAL;
+	} else {
+		subsystem_put(subsystem_get_retval);
 	}
 
 	IPADBG("PIL FW loading process is complete\n");
@@ -4579,6 +4662,7 @@
 	ipa3_ctx->ee = resource_p->ee;
 	ipa3_ctx->apply_rg10_wa = resource_p->apply_rg10_wa;
 	ipa3_ctx->gsi_ch20_wa = resource_p->gsi_ch20_wa;
+	ipa3_ctx->use_ipa_pm = resource_p->use_ipa_pm;
 	ipa3_ctx->ipa3_active_clients_logging.log_rdy = false;
 	if (resource_p->ipa_tz_unlock_reg) {
 		ipa3_ctx->ipa_tz_unlock_reg_num =
@@ -4853,6 +4937,8 @@
 
 	mutex_init(&ipa3_ctx->lock);
 	mutex_init(&ipa3_ctx->nat_mem.lock);
+	mutex_init(&ipa3_ctx->q6_proxy_clk_vote_mutex);
+	mutex_init(&ipa3_ctx->ipa_cne_evt_lock);
 
 	idr_init(&ipa3_ctx->ipa_idr);
 	spin_lock_init(&ipa3_ctx->idr_lock);
@@ -4890,20 +4976,30 @@
 	wakeup_source_init(&ipa3_ctx->w_lock, "IPA_WS");
 	spin_lock_init(&ipa3_ctx->wakelock_ref_cnt.spinlock);
 
-	/* Initialize IPA RM (resource manager) */
-	result = ipa_rm_initialize();
-	if (result) {
-		IPAERR("RM initialization failed (%d)\n", -result);
-		result = -ENODEV;
-		goto fail_ipa_rm_init;
-	}
-	IPADBG("IPA resource manager initialized");
+	/* Initialize Power Management framework */
+	if (ipa3_ctx->use_ipa_pm) {
+		result = ipa_pm_init(&ipa3_res.pm_init);
+		if (result) {
+			IPAERR("IPA PM initialization failed (%d)\n", -result);
+			result = -ENODEV;
+			goto fail_ipa_rm_init;
+		}
+		IPADBG("IPA resource manager initialized");
+	} else {
+		result = ipa_rm_initialize();
+		if (result) {
+			IPAERR("RM initialization failed (%d)\n", -result);
+			result = -ENODEV;
+			goto fail_ipa_rm_init;
+		}
+		IPADBG("IPA resource manager initialized");
 
-	result = ipa3_create_apps_resource();
-	if (result) {
-		IPAERR("Failed to create APPS_CONS resource\n");
-		result = -ENODEV;
-		goto fail_create_apps_resource;
+		result = ipa3_create_apps_resource();
+		if (result) {
+			IPAERR("Failed to create APPS_CONS resource\n");
+			result = -ENODEV;
+			goto fail_create_apps_resource;
+		}
 	}
 
 	result = ipa3_alloc_pkt_init();
@@ -4954,9 +5050,11 @@
 
 fail_cdev_add:
 fail_ipa_init_interrupts:
-	ipa_rm_delete_resource(IPA_RM_RESOURCE_APPS_CONS);
+	if (!ipa3_ctx->use_ipa_pm)
+		ipa_rm_delete_resource(IPA_RM_RESOURCE_APPS_CONS);
 fail_create_apps_resource:
-	ipa_rm_exit();
+	if (!ipa3_ctx->use_ipa_pm)
+		ipa_rm_exit();
 fail_ipa_rm_init:
 fail_nat_dev_add:
 	device_destroy(ipa3_ctx->class, ipa3_ctx->dev_num);
@@ -5025,6 +5123,101 @@
 	return result;
 }
 
+bool ipa_pm_is_used(void)
+{
+	return (ipa3_ctx) ? ipa3_ctx->use_ipa_pm : false;
+}
+
+static int get_ipa_dts_pm_info(struct platform_device *pdev,
+	struct ipa3_plat_drv_res *ipa_drv_res)
+{
+	int result;
+	int i, j;
+
+	ipa_drv_res->use_ipa_pm = of_property_read_bool(pdev->dev.of_node,
+		"qcom,use-ipa-pm");
+	IPADBG("use_ipa_pm=%d\n", ipa_drv_res->use_ipa_pm);
+	if (!ipa_drv_res->use_ipa_pm)
+		return 0;
+
+	result = of_property_read_u32(pdev->dev.of_node,
+		"qcom,msm-bus,num-cases",
+		&ipa_drv_res->pm_init.threshold_size);
+	/* No vote is ignored */
+	ipa_drv_res->pm_init.threshold_size -= 2;
+	if (result || ipa_drv_res->pm_init.threshold_size >
+		IPA_PM_THRESHOLD_MAX) {
+		IPAERR("invalid property qcom,msm-bus,num-cases %d\n",
+			ipa_drv_res->pm_init.threshold_size);
+		return -EFAULT;
+	}
+
+	result = of_property_read_u32_array(pdev->dev.of_node,
+		"qcom,throughput-threshold",
+		ipa_drv_res->pm_init.default_threshold,
+		ipa_drv_res->pm_init.threshold_size);
+	if (result) {
+		IPAERR("failed to read qcom,throughput-thresholds\n");
+		return -EFAULT;
+	}
+
+	result = of_property_count_strings(pdev->dev.of_node,
+		"qcom,scaling-exceptions");
+	if (result < 0) {
+		IPADBG("no exception list for ipa pm\n");
+		result = 0;
+	}
+
+	if (result % (ipa_drv_res->pm_init.threshold_size + 1)) {
+		IPAERR("failed to read qcom,scaling-exceptions\n");
+		return -EFAULT;
+	}
+
+	ipa_drv_res->pm_init.exception_size = result /
+		(ipa_drv_res->pm_init.threshold_size + 1);
+	if (ipa_drv_res->pm_init.exception_size >=
+		IPA_PM_EXCEPTION_MAX) {
+		IPAERR("exception list larger then max %d\n",
+			ipa_drv_res->pm_init.exception_size);
+		return -EFAULT;
+	}
+
+	for (i = 0; i < ipa_drv_res->pm_init.exception_size; i++) {
+		struct ipa_pm_exception *ex = ipa_drv_res->pm_init.exceptions;
+
+		result = of_property_read_string_index(pdev->dev.of_node,
+			"qcom,scaling-exceptions",
+			i * ipa_drv_res->pm_init.threshold_size,
+			&ex[i].usecase);
+		if (result) {
+			IPAERR("failed to read qcom,scaling-exceptions");
+			return -EFAULT;
+		}
+
+		for (j = 0; j < ipa_drv_res->pm_init.threshold_size; j++) {
+			const char *str;
+
+			result = of_property_read_string_index(
+				pdev->dev.of_node,
+				"qcom,scaling-exceptions",
+				i * ipa_drv_res->pm_init.threshold_size + j + 1,
+				&str);
+			if (result) {
+				IPAERR("failed to read qcom,scaling-exceptions"
+					);
+				return -EFAULT;
+			}
+
+			if (kstrtou32(str, 0, &ex[i].threshold[j])) {
+				IPAERR("error str=%s\n", str);
+				return -EFAULT;
+			}
+		}
+	}
+
+	return 0;
+}
+
 static int get_ipa_dts_configuration(struct platform_device *pdev,
 		struct ipa3_plat_drv_res *ipa_drv_res)
 {
@@ -5263,6 +5456,14 @@
 		}
 		kfree(ipa_tz_unlock_reg);
 	}
+
+	/* get IPA PM related information */
+	result = get_ipa_dts_pm_info(pdev, ipa_drv_res);
+	if (result) {
+		IPAERR("failed to get pm info from dts %d\n", result);
+		return result;
+	}
+
 	return 0;
 }
 
@@ -5800,11 +6001,16 @@
 		}
 	}
 
-	/*
-	 * Release transport IPA resource without waiting for inactivity timer
-	 */
-	atomic_set(&ipa3_ctx->transport_pm.eot_activity, 0);
-	ipa3_transport_release_resource(NULL);
+	if (ipa3_ctx->use_ipa_pm) {
+		ipa_pm_deactivate_all_deferred();
+	} else {
+		/*
+		 * Release transport IPA resource without waiting
+		 * for inactivity timer
+		 */
+		atomic_set(&ipa3_ctx->transport_pm.eot_activity, 0);
+		ipa3_transport_release_resource(NULL);
+	}
 	IPADBG("Exit\n");
 
 	return 0;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
index 153548b..f72f41c 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
@@ -910,10 +910,11 @@
 				eq = true;
 			} else {
 				rt_tbl = ipa3_id_find(entry->rule.rt_tbl_hdl);
-				if (rt_tbl)
-					rt_tbl_idx = rt_tbl->idx;
+				if (rt_tbl == NULL ||
+					rt_tbl->cookie != IPA_RT_TBL_COOKIE)
+					rt_tbl_idx =  ~0;
 				else
-					rt_tbl_idx = ~0;
+					rt_tbl_idx = rt_tbl->idx;
 				bitmap = entry->rule.attrib.attrib_mask;
 				eq = false;
 			}
@@ -1705,6 +1706,10 @@
 {
 	int result, nbytes, cnt = 0;
 
+	/* deprecate if IPA PM is used */
+	if (ipa3_ctx->use_ipa_pm)
+		return 0;
+
 	result = ipa_rm_stat(dbg_buff, IPA_MAX_MSG_LEN);
 	if (result < 0) {
 		nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
@@ -1716,6 +1721,45 @@
 	return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
 }
 
+static ssize_t ipa3_pm_read_stats(struct file *file, char __user *ubuf,
+		size_t count, loff_t *ppos)
+{
+	int result, nbytes, cnt = 0;
+
+	if (!ipa3_ctx->use_ipa_pm)
+		return 0;
+
+	result = ipa_pm_stat(dbg_buff, IPA_MAX_MSG_LEN);
+	if (result < 0) {
+		nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
+				"Error in printing PM stat %d\n", result);
+		cnt += nbytes;
+	} else
+		cnt += result;
+
+	return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
+}
+
+static ssize_t ipa3_pm_ex_read_stats(struct file *file, char __user *ubuf,
+		size_t count, loff_t *ppos)
+{
+	int result, nbytes, cnt = 0;
+
+	if (!ipa3_ctx->use_ipa_pm)
+		return 0;
+
+	result = ipa_pm_exceptions_stat(dbg_buff, IPA_MAX_MSG_LEN);
+	if (result < 0) {
+		nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
+				"Error in printing PM stat %d\n", result);
+		cnt += nbytes;
+	} else
+		cnt += result;
+
+	return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
+}
+
+
 static void ipa_dump_status(struct ipahal_pkt_status *status)
 {
 	IPA_DUMP_STATUS_FIELD(status_opcode);
@@ -1940,6 +1984,15 @@
 	.read = ipa3_rm_read_stats,
 };
 
+static const struct file_operations ipa3_pm_stats = {
+	.read = ipa3_pm_read_stats,
+};
+
+
+static const struct file_operations ipa3_pm_ex_stats = {
+	.read = ipa3_pm_ex_read_stats,
+};
+
 const struct file_operations ipa3_active_clients = {
 	.read = ipa3_print_active_clients_log,
 	.write = ipa3_clear_active_clients_log,
@@ -2131,11 +2184,27 @@
 		goto fail;
 	}
 
-	dfile_rm_stats = debugfs_create_file("rm_stats",
-			read_only_mode, dent, 0, &ipa3_rm_stats);
-	if (!dfile_rm_stats || IS_ERR(dfile_rm_stats)) {
-		IPAERR("fail to create file for debug_fs rm_stats\n");
-		goto fail;
+	if (ipa3_ctx->use_ipa_pm) {
+		file = dfile_rm_stats = debugfs_create_file("pm_stats",
+			read_only_mode, dent, NULL, &ipa3_pm_stats);
+		if (!file || IS_ERR(file)) {
+			IPAERR("fail to create file for debug_fs pm_stats\n");
+			goto fail;
+		}
+
+		file = dfile_rm_stats = debugfs_create_file("pm_ex_stats",
+			read_only_mode, dent, NULL, &ipa3_pm_ex_stats);
+		if (!file || IS_ERR(file)) {
+			IPAERR("fail to create file for debugfs pm_ex_stats\n");
+			goto fail;
+		}
+	} else {
+		dfile_rm_stats = debugfs_create_file("rm_stats",
+				read_only_mode, dent, NULL, &ipa3_rm_stats);
+		if (!dfile_rm_stats || IS_ERR(dfile_rm_stats)) {
+			IPAERR("fail to create file for debug_fs rm_stats\n");
+			goto fail;
+		}
 	}
 
 	dfile_status_stats = debugfs_create_file("status_stats",
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
index 02c5991..7f30a10 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
@@ -73,6 +73,8 @@
 
 #define IPA_TX_SEND_COMPL_NOP_DELAY_NS (2 * 1000 * 1000)
 
+#define IPA_APPS_BW_FOR_PM 700
+
 static struct sk_buff *ipa3_get_skb_ipa_rx(unsigned int len, gfp_t flags);
 static void ipa3_replenish_wlan_rx_cache(struct ipa3_sys_context *sys);
 static void ipa3_replenish_rx_cache(struct ipa3_sys_context *sys);
@@ -748,7 +750,10 @@
 	int inactive_cycles = 0;
 	int cnt;
 
-	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
+	if (ipa3_ctx->use_ipa_pm)
+		ipa_pm_activate_sync(sys->pm_hdl);
+	else
+		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	do {
 		cnt = ipa3_handle_rx_core(sys, true, true);
 		if (cnt == 0)
@@ -772,7 +777,10 @@
 
 	trace_poll_to_intr3(sys->ep->client);
 	ipa3_rx_switch_to_intr_mode(sys);
-	IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
+	if (ipa3_ctx->use_ipa_pm)
+		ipa_pm_deferred_deactivate(sys->pm_hdl);
+	else
+		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
 }
 
 static void ipa3_switch_to_intr_rx_work_func(struct work_struct *work)
@@ -799,6 +807,32 @@
 	return HRTIMER_NORESTART;
 }
 
+static void ipa_pm_sys_pipe_cb(void *p, enum ipa_pm_cb_event event)
+{
+	struct ipa3_sys_context *sys = (struct ipa3_sys_context *)p;
+
+	switch (event) {
+	case IPA_PM_CLIENT_ACTIVATED:
+		/*
+		 * this event is ignored as the sync version of activation
+		 * will be used.
+		 */
+		break;
+	case IPA_PM_REQUEST_WAKEUP:
+		/*
+		 * pipe will be unsuspended as part of
+		 * enabling IPA clocks
+		 */
+		ipa_pm_activate_sync(sys->pm_hdl);
+		ipa_pm_deferred_deactivate(sys->pm_hdl);
+		break;
+	default:
+		IPAERR("Unexpected event %d\n", event);
+		WARN_ON(1);
+		return;
+	}
+}
+
 /**
  * ipa3_setup_sys_pipe() - Setup an IPA GPI pipe and perform
  * IPA EP configuration
@@ -846,6 +880,9 @@
 	memset(ep, 0, offsetof(struct ipa3_ep_context, sys));
 
 	if (!ep->sys) {
+		struct ipa_pm_register_params pm_reg;
+
+		memset(&pm_reg, 0, sizeof(pm_reg));
 		ep->sys = kzalloc(sizeof(struct ipa3_sys_context), GFP_KERNEL);
 		if (!ep->sys) {
 			IPAERR("failed to sys ctx for client %d\n",
@@ -884,6 +921,35 @@
 		hrtimer_init(&ep->sys->db_timer, CLOCK_MONOTONIC,
 			HRTIMER_MODE_REL);
 		ep->sys->db_timer.function = ipa3_ring_doorbell_timer_fn;
+
+		/* create IPA PM resources for handling polling mode */
+		if (ipa3_ctx->use_ipa_pm &&
+			IPA_CLIENT_IS_CONS(sys_in->client)) {
+			pm_reg.name = ipa_clients_strings[sys_in->client];
+			pm_reg.callback = ipa_pm_sys_pipe_cb;
+			pm_reg.user_data = ep->sys;
+			pm_reg.group = IPA_PM_GROUP_APPS;
+			result = ipa_pm_register(&pm_reg, &ep->sys->pm_hdl);
+			if (result) {
+				IPAERR("failed to create IPA PM client %d\n",
+					result);
+				goto fail_pm;
+			}
+
+			result = ipa_pm_associate_ipa_cons_to_client(
+				ep->sys->pm_hdl, sys_in->client);
+			if (result) {
+				IPAERR("failed to associate IPA PM client\n");
+				goto fail_gen2;
+			}
+
+			result = ipa_pm_set_perf_profile(ep->sys->pm_hdl,
+				IPA_APPS_BW_FOR_PM);
+			if (result) {
+				IPAERR("failed to set profile IPA PM client\n");
+				goto fail_gen2;
+			}
+		}
 	} else {
 		memset(ep->sys, 0, offsetof(struct ipa3_sys_context, ep));
 	}
@@ -984,6 +1050,9 @@
 	return 0;
 
 fail_gen2:
+	if (ipa3_ctx->use_ipa_pm)
+		ipa_pm_deregister(ep->sys->pm_hdl);
+fail_pm:
 	destroy_workqueue(ep->sys->repl_wq);
 fail_wq2:
 	destroy_workqueue(ep->sys->wq);
@@ -1402,7 +1471,8 @@
 	sys = container_of(work, struct ipa3_sys_context, work);
 
 	if (sys->ep->napi_enabled) {
-		IPA_ACTIVE_CLIENTS_INC_SPECIAL("NAPI");
+		if (!ipa3_ctx->use_ipa_pm)
+			IPA_ACTIVE_CLIENTS_INC_SPECIAL("NAPI");
 		sys->ep->client_notify(sys->ep->priv,
 				IPA_CLIENT_START_POLL, 0);
 	} else
@@ -2683,6 +2753,21 @@
 		return 0;
 	}
 
+	if (in->client == IPA_CLIENT_APPS_WAN_PROD) {
+		sys->policy = IPA_POLICY_INTR_MODE;
+		sys->use_comm_evt_ring = true;
+		INIT_WORK(&sys->work, ipa3_send_nop_desc);
+
+		/*
+		 * enable source notification status for exception packets
+		 * (i.e. QMAP commands) to be routed to modem.
+		 */
+		sys->ep->status.status_en = true;
+		sys->ep->status.status_ep =
+			ipa3_get_ep_mapping(IPA_CLIENT_Q6_WAN_CONS);
+		return 0;
+	}
+
 	if (IPA_CLIENT_IS_MEMCPY_DMA_PROD(in->client)) {
 		sys->policy = IPA_POLICY_NOINTR_MODE;
 		return 0;
@@ -3268,11 +3353,48 @@
 	}
 }
 
+void __ipa_gsi_irq_rx_scedule_poll(struct ipa3_sys_context *sys)
+{
+	bool clk_off;
+
+	atomic_set(&sys->curr_polling_state, 1);
+	ipa3_inc_acquire_wakelock();
+
+	/*
+	 * pm deactivate is done in wq context
+	 * or after NAPI poll
+	 */
+	if (ipa3_ctx->use_ipa_pm) {
+		clk_off = ipa_pm_activate(sys->pm_hdl);
+		if (!clk_off && sys->ep->napi_enabled) {
+			sys->ep->client_notify(sys->ep->priv,
+				IPA_CLIENT_START_POLL, 0);
+			return;
+		}
+		queue_work(sys->wq, &sys->work);
+		return;
+	}
+
+	if (sys->ep->napi_enabled) {
+		struct ipa_active_client_logging_info log;
+
+		IPA_ACTIVE_CLIENTS_PREP_SPECIAL(log, "NAPI");
+		clk_off = ipa3_inc_client_enable_clks_no_block(
+			&log);
+		if (!clk_off) {
+			sys->ep->client_notify(sys->ep->priv,
+				IPA_CLIENT_START_POLL, 0);
+			return;
+		}
+	}
+
+	queue_work(sys->wq, &sys->work);
+}
+
 static void ipa_gsi_irq_rx_notify_cb(struct gsi_chan_xfer_notify *notify)
 {
 	struct ipa3_sys_context *sys;
 	struct ipa3_rx_pkt_wrapper *rx_pkt_expected, *rx_pkt_rcvd;
-	int clk_off;
 
 	if (!notify) {
 		IPAERR("gsi notify is NULL.\n");
@@ -3302,22 +3424,7 @@
 			/* put the gsi channel into polling mode */
 			gsi_config_channel_mode(sys->ep->gsi_chan_hdl,
 				GSI_CHAN_MODE_POLL);
-			ipa3_inc_acquire_wakelock();
-			atomic_set(&sys->curr_polling_state, 1);
-			if (sys->ep->napi_enabled) {
-				struct ipa_active_client_logging_info log;
-
-				IPA_ACTIVE_CLIENTS_PREP_SPECIAL(log, "NAPI");
-				clk_off = ipa3_inc_client_enable_clks_no_block(
-					&log);
-				if (!clk_off)
-					sys->ep->client_notify(sys->ep->priv,
-						IPA_CLIENT_START_POLL, 0);
-				else
-					queue_work(sys->wq, &sys->work);
-			} else {
-				queue_work(sys->wq, &sys->work);
-			}
+			__ipa_gsi_irq_rx_scedule_poll(sys);
 		}
 		break;
 	default:
@@ -3719,7 +3826,10 @@
 	if (cnt < weight) {
 		ep->client_notify(ep->priv, IPA_CLIENT_COMP_NAPI, 0);
 		ipa3_rx_switch_to_intr_mode(ep->sys);
-		ipa3_dec_client_disable_clks_no_block(&log);
+		if (ipa3_ctx->use_ipa_pm)
+			ipa_pm_deferred_deactivate(ep->sys->pm_hdl);
+		else
+			ipa3_dec_client_disable_clks_no_block(&log);
 	}
 
 	return cnt;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
index beca549..0883e6f 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
@@ -1170,6 +1170,13 @@
 		goto bail;
 	}
 
+	if (entry->cookie != IPA_FLT_COOKIE) {
+		IPAERR_RL("Invalid cookie value =  %u flt hdl id = %d\n",
+			entry->cookie, rules->add_after_hdl);
+		result = -EINVAL;
+		goto bail;
+	}
+
 	if (entry->tbl != tbl) {
 		IPAERR_RL("given entry does not match the table\n");
 		result = -EINVAL;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
index 43fd4d1..3e1d188 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
@@ -36,6 +36,7 @@
 #include "ipahal/ipahal_hw_stats.h"
 #include "../ipa_common_i.h"
 #include "ipa_uc_offload_i.h"
+#include "ipa_pm.h"
 
 #define DRV_NAME "ipa"
 #define NAT_DEV_NAME "ipaNatTable"
@@ -71,6 +72,8 @@
 
 #define IPA_IPC_LOG_PAGES 50
 
+#define IPA_MAX_NUM_REQ_CACHE 10
+
 #define IPADBG(fmt, args...) \
 	do { \
 		pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
@@ -645,6 +648,7 @@
 	struct workqueue_struct *wq;
 	struct workqueue_struct *repl_wq;
 	struct ipa3_status_stats *status_stat;
+	u32 pm_hdl;
 	/* ordering is important - other immutable fields go below */
 };
 
@@ -867,6 +871,7 @@
 struct ipa3_active_clients {
 	struct mutex mutex;
 	atomic_t cnt;
+	int bus_vote_idx;
 };
 
 struct ipa3_wakelock_ref_cnt {
@@ -1088,6 +1093,11 @@
 	struct ipa_hw_stats_drop drop;
 };
 
+struct ipa_cne_evt {
+	struct ipa_wan_msg wan_msg;
+	struct ipa_msg_meta msg_meta;
+};
+
 /**
  * struct ipa3_context - IPA context
  * @class: pointer to the struct class
@@ -1267,6 +1277,7 @@
 	u32 enable_clock_scaling;
 	u32 curr_ipa_clk_rate;
 	bool q6_proxy_clk_vote_valid;
+	struct mutex q6_proxy_clk_vote_mutex;
 	u32 ipa_num_pipes;
 	dma_addr_t pkt_init_imm[IPA3_MAX_NUM_PIPES];
 	u32 pkt_init_imm_opcode;
@@ -1303,6 +1314,10 @@
 	struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
 	struct ipa_dma_task_info dma_task_info;
 	struct ipa_hw_stats hw_stats;
+	struct ipa_cne_evt ipa_cne_evt_req_cache[IPA_MAX_NUM_REQ_CACHE];
+	int num_ipa_cne_evt_req;
+	struct mutex ipa_cne_evt_lock;
+	bool use_ipa_pm;
 };
 
 struct ipa3_plat_drv_res {
@@ -1330,6 +1345,8 @@
 	bool tethered_flow_control;
 	u32 ipa_tz_unlock_reg_num;
 	struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
+	bool use_ipa_pm;
+	struct ipa_pm_init_params pm_init;
 };
 
 /**
@@ -1560,8 +1577,10 @@
 	u32 ipa_clk_rate_turbo;
 	u32 ipa_clk_rate_nominal;
 	u32 ipa_clk_rate_svs;
+	u32 ipa_clk_rate_svs2;
 	u32 clock_scaling_bw_threshold_turbo;
 	u32 clock_scaling_bw_threshold_nominal;
+	u32 clock_scaling_bw_threshold_svs;
 	u32 ipa_reg_base_ofst;
 	u32 max_holb_tmr_val;
 	void (*ipa_sram_read_settings)(void);
@@ -2213,4 +2232,6 @@
 int ipa3_alloc_common_event_ring(void);
 int ipa3_allocate_dma_task_for_gsi(void);
 void ipa3_free_dma_task_for_gsi(void);
+int ipa3_set_clock_plan_from_pm(int idx);
+void __ipa_gsi_irq_rx_scedule_poll(struct ipa3_sys_context *sys);
 #endif /* _IPA3_I_H_ */
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_interrupts.c b/drivers/platform/msm/ipa/ipa_v3/ipa_interrupts.c
index 6d82da2..d69d6ae 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_interrupts.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_interrupts.c
@@ -336,7 +336,7 @@
 	ipa3_process_interrupts(true);
 	IPADBG_LOW("Exit\n");
 
-	ipa3_dec_client_disable_clks(&log_info);
+	ipa3_dec_client_disable_clks_no_block(&log_info);
 	return IRQ_HANDLED;
 }
 /**
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_mhi.c b/drivers/platform/msm/ipa/ipa_v3/ipa_mhi.c
index b19ef8b..08f2a8c 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_mhi.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_mhi.c
@@ -627,6 +627,8 @@
 	}
 	ep = &ipa3_ctx->ep[ipa_ep_idx];
 
+	IPA_ACTIVE_CLIENTS_INC_EP(client);
+
 	IPA_MHI_DBG("reset event ring (hdl: %lu, ep: %d)\n",
 		ep->gsi_evt_ring_hdl, ipa_ep_idx);
 
@@ -648,8 +650,10 @@
 		goto fail;
 	}
 
+	IPA_ACTIVE_CLIENTS_DEC_EP(client);
 	return 0;
 fail:
+	IPA_ACTIVE_CLIENTS_DEC_EP(client);
 	return res;
 }
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_pm.c b/drivers/platform/msm/ipa/ipa_v3/ipa_pm.c
new file mode 100644
index 0000000..3bf0327
--- /dev/null
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_pm.c
@@ -0,0 +1,1311 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/debugfs.h>
+#include "ipa_pm.h"
+#include "ipa_i.h"
+
+static const char *client_state_to_str[IPA_PM_STATE_MAX] = {
+	__stringify(IPA_PM_DEACTIVATED),
+	__stringify(IPA_PM_DEACTIVATE_IN_PROGRESS),
+	__stringify(IPA_PM_ACTIVATE_IN_PROGRESS),
+	__stringify(IPA_PM_ACTIVATED),
+	__stringify(IPA_PM_ACTIVATED_PENDING_DEACTIVATION),
+	__stringify(IPA_PM_ACTIVATED_TIMER_SET),
+	__stringify(IPA_PM_ACTIVATED_PENDING_RESCHEDULE),
+};
+
+static const char *ipa_pm_group_to_str[IPA_PM_GROUP_MAX] = {
+	__stringify(IPA_PM_GROUP_DEFAULT),
+	__stringify(IPA_PM_GROUP_APPS),
+	__stringify(IPA_PM_GROUP_MODEM),
+};
+
+
+#define IPA_PM_DRV_NAME "ipa_pm"
+
+#define IPA_PM_DBG(fmt, args...) \
+	do { \
+		pr_debug(IPA_PM_DRV_NAME " %s:%d " fmt, \
+			__func__, __LINE__, ## args); \
+		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
+			IPA_PM_DRV_NAME " %s:%d " fmt, ## args); \
+		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
+			IPA_PM_DRV_NAME " %s:%d " fmt, ## args); \
+	} while (0)
+#define IPA_PM_DBG_LOW(fmt, args...) \
+	do { \
+		pr_debug(IPA_PM_DRV_NAME " %s:%d " fmt, \
+			__func__, __LINE__, ## args); \
+		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
+			IPA_PM_DRV_NAME " %s:%d " fmt, ## args); \
+	} while (0)
+#define IPA_PM_ERR(fmt, args...) \
+	do { \
+		pr_err(IPA_PM_DRV_NAME " %s:%d " fmt, \
+			__func__, __LINE__, ## args); \
+		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
+			IPA_PM_DRV_NAME " %s:%d " fmt, ## args); \
+		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
+			IPA_PM_DRV_NAME " %s:%d " fmt, ## args); \
+	} while (0)
+#define IPA_PM_DBG_STATE(hdl, name, state) \
+	IPA_PM_DBG_LOW("Client[%d] %s: %s\n", hdl, name, \
+		client_state_to_str[state])
+
+
+#if IPA_PM_MAX_CLIENTS > 32
+#error max client greater than 32 all bitmask types should be changed
+#endif
+
+/*
+ * struct ipa_pm_exception_list - holds information about an exception
+ * @pending: number of clients in exception that have not yet been adctivated
+ * @bitmask: bitmask of the clients in the exception based on handle
+ * @threshold: the threshold values for the exception
+ */
+struct ipa_pm_exception_list {
+	char clients[IPA_PM_MAX_EX_CL];
+	int pending;
+	u32 bitmask;
+	int threshold[IPA_PM_THRESHOLD_MAX];
+};
+
+/*
+ * struct clk_scaling_db - holds information about threshholds and exceptions
+ * @lock: lock the bitmasks and thresholds
+ * @exception_list: pointer to the list of exceptions
+ * @work: work for clock scaling algorithm
+ * @active_client_bitmask: the bits represent handles in the clients array that
+ * contain non-null client
+ * @threshold_size: size of the throughput threshold
+ * @exception_size: size of the exception list
+ * @cur_vote: idx of the threshold
+ * @default_threshold: the thresholds used if no exception passes
+ * @current_threshold: the current threshold of the clock plan
+ */
+struct clk_scaling_db {
+	spinlock_t lock;
+	struct ipa_pm_exception_list exception_list[IPA_PM_EXCEPTION_MAX];
+	struct work_struct work;
+	u32 active_client_bitmask;
+	int threshold_size;
+	int exception_size;
+	int cur_vote;
+	int default_threshold[IPA_PM_THRESHOLD_MAX];
+	int *current_threshold;
+};
+
+/*
+ * ipa_pm state names
+ *
+ * Timer free states:
+ * @IPA_PM_DEACTIVATED: client starting state when registered
+ * @IPA_PM_DEACTIVATE_IN_PROGRESS: deactivate was called in progress of a client
+ *				   activating
+ * @IPA_PM_ACTIVATE_IN_PROGRESS: client is being activated by work_queue
+ * @IPA_PM_ACTIVATED: client is activated without any timers
+ *
+ * Timer set states:
+ * @IPA_PM_ACTIVATED_PENDING_DEACTIVATION: moves to deactivate once timer pass
+ * @IPA_PM_ACTIVATED_TIMER_SET: client was activated while timer was set, so
+ *			 when the timer pass, client will still be activated
+ *@IPA_PM_ACTIVATED_PENDING_RESCHEDULE: state signifying extended timer when
+ *             a client is deferred_deactivated when a time ris still active
+ */
+enum ipa_pm_state {
+	IPA_PM_DEACTIVATED,
+	IPA_PM_DEACTIVATE_IN_PROGRESS,
+	IPA_PM_ACTIVATE_IN_PROGRESS,
+	IPA_PM_ACTIVATED,
+	IPA_PM_ACTIVATED_PENDING_DEACTIVATION,
+	IPA_PM_ACTIVATED_TIMER_SET,
+	IPA_PM_ACTIVATED_PENDING_RESCHEDULE,
+};
+
+#define IPA_PM_STATE_ACTIVE(state) \
+	(state == IPA_PM_ACTIVATED ||\
+		state == IPA_PM_ACTIVATED_PENDING_DEACTIVATION ||\
+		state  == IPA_PM_ACTIVATED_TIMER_SET ||\
+		state == IPA_PM_ACTIVATED_PENDING_RESCHEDULE)
+
+#define IPA_PM_STATE_IN_PROGRESS(state) \
+	(state == IPA_PM_ACTIVATE_IN_PROGRESS \
+		|| state == IPA_PM_DEACTIVATE_IN_PROGRESS)
+
+/*
+ * struct ipa_pm_client - holds information about a specific IPA client
+ * @name: string name of the client
+ * @callback: pointer to the client's callback function
+ * @callback_params: pointer to the client's callback parameters
+ * @state: Activation state of the client
+ * @skip_clk_vote: 0 if client votes for clock when activated, 1 if no vote
+ * @group: the ipa_pm_group the client belongs to
+ * @hdl: handle of the client
+ * @throughput: the throughput of the client for clock scaling
+ * @state_lock: spinlock to lock the pm_states
+ * @activate_work: work for activate (blocking case)
+ * @deactivate work: delayed work for deferred_deactivate function
+ * @complete: generic wait-for-completion handler
+ */
+struct ipa_pm_client {
+	char name[IPA_PM_MAX_EX_CL];
+	void (*callback)(void*, enum ipa_pm_cb_event);
+	void *callback_params;
+	enum ipa_pm_state state;
+	bool skip_clk_vote;
+	int group;
+	int hdl;
+	int throughput;
+	spinlock_t state_lock;
+	struct work_struct activate_work;
+	struct delayed_work deactivate_work;
+	struct completion complete;
+};
+
+/*
+ * struct ipa_pm_ctx - global ctx that will hold the client arrays and tput info
+ * @clients: array to the clients with the handle as its index
+ * @clients_by_pipe: array to the clients with endpoint as the index
+ * @wq: work queue for deferred deactivate, activate, and clk_scaling work
+ 8 @clk_scaling: pointer to clock scaling database
+ * @client_mutex: global mutex to  lock the client arrays
+ * @aggragated_tput: aggragated tput value of all valid activated clients
+ * @group_tput: combined throughput for the groups
+ */
+struct ipa_pm_ctx {
+	struct ipa_pm_client *clients[IPA_PM_MAX_CLIENTS];
+	struct ipa_pm_client *clients_by_pipe[IPA3_MAX_NUM_PIPES];
+	struct workqueue_struct *wq;
+	struct clk_scaling_db clk_scaling;
+	struct mutex client_mutex;
+	int aggregated_tput;
+	int group_tput[IPA_PM_GROUP_MAX];
+};
+
+static struct ipa_pm_ctx *ipa_pm_ctx;
+
+/**
+ * pop_max_from_array() -pop the max and move the last element to where the
+ * max was popped
+ * @arr: array to be searched for max
+ * @n: size of the array
+ *
+ * Returns: max value of the array
+ */
+static int pop_max_from_array(int *arr, int *n)
+{
+	int i;
+	int max, max_idx;
+
+	max_idx = *n - 1;
+	max = 0;
+
+	if (*n == 0)
+		return 0;
+
+	for (i = 0; i < *n; i++) {
+		if (arr[i] > max) {
+			max = arr[i];
+			max_idx = i;
+		}
+	}
+	(*n)--;
+	arr[max_idx] = arr[*n];
+
+	return max;
+}
+
+/**
+ * calculate_throughput() - calculate the aggregated throughput
+ * based on active clients
+ *
+ * Returns: aggregated tput value
+ */
+static int calculate_throughput(void)
+{
+	int client_tput[IPA_PM_MAX_CLIENTS] = { 0 };
+	bool group_voted[IPA_PM_GROUP_MAX] = { false };
+	int i, n;
+	int max, second_max, aggregated_tput;
+	struct ipa_pm_client *client;
+
+	/* Create a basic array to hold throughputs*/
+	for (i = 0, n = 0; i < IPA_PM_MAX_CLIENTS; i++) {
+		client = ipa_pm_ctx->clients[i];
+		if (client != NULL && IPA_PM_STATE_ACTIVE(client->state)) {
+			/* default case */
+			if (client->group == IPA_PM_GROUP_DEFAULT) {
+				client_tput[n++] = client->throughput;
+			} else if (group_voted[client->group] == false) {
+				client_tput[n++] = ipa_pm_ctx->group_tput
+					[client->group];
+				group_voted[client->group] = true;
+			}
+		}
+	}
+	/*the array will only use n+1 spots. n will be the last index used*/
+
+	aggregated_tput = 0;
+
+	/**
+	 * throughput algorithm:
+	 * 1) pop the max and second_max
+	 * 2) add the 2nd max to aggregated tput
+	 * 3) insert the value of max - 2nd max
+	 * 4) repeat until array is of size 1
+	 */
+	while (n > 1) {
+		max = pop_max_from_array(client_tput, &n);
+		second_max = pop_max_from_array(client_tput, &n);
+		client_tput[n++] = max - second_max;
+		aggregated_tput += second_max;
+	}
+
+	IPA_PM_DBG_LOW("Aggregated throughput: %d\n", aggregated_tput);
+
+	return aggregated_tput;
+}
+
+/**
+ * deactivate_client() - turn off the bit in the active client bitmask based on
+ * the handle passed in
+ * @hdl: The index of the client to be deactivated
+ */
+static void deactivate_client(u32 hdl)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&ipa_pm_ctx->clk_scaling.lock, flags);
+	ipa_pm_ctx->clk_scaling.active_client_bitmask &= ~(1 << hdl);
+	spin_unlock_irqrestore(&ipa_pm_ctx->clk_scaling.lock, flags);
+	IPA_PM_DBG_LOW("active bitmask: %x\n",
+		ipa_pm_ctx->clk_scaling.active_client_bitmask);
+}
+
+/**
+ * activate_client() - turn on the bit in the active client bitmask based on
+ * the handle passed in
+ * @hdl: The index of the client to be activated
+ */
+static void activate_client(u32 hdl)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&ipa_pm_ctx->clk_scaling.lock, flags);
+	ipa_pm_ctx->clk_scaling.active_client_bitmask |= (1 << hdl);
+	spin_unlock_irqrestore(&ipa_pm_ctx->clk_scaling.lock, flags);
+	IPA_PM_DBG_LOW("active bitmask: %x\n",
+		ipa_pm_ctx->clk_scaling.active_client_bitmask);
+}
+
+/**
+ * deactivate_client() - get threshold
+ *
+ * Returns: threshold of the exception that passes or default if none pass
+ */
+static void set_current_threshold(void)
+{
+	int i;
+	struct clk_scaling_db *clk;
+	struct ipa_pm_exception_list *exception;
+	unsigned long flags;
+
+	clk = &ipa_pm_ctx->clk_scaling;
+
+	spin_lock_irqsave(&ipa_pm_ctx->clk_scaling.lock, flags);
+	for (i = 0; i < clk->exception_size; i++) {
+		exception = &clk->exception_list[i];
+		if (exception->pending == 0 && (exception->bitmask
+			& ~clk->active_client_bitmask) == 0) {
+			spin_unlock_irqrestore(&ipa_pm_ctx->clk_scaling.lock,
+				 flags);
+			clk->current_threshold = exception->threshold;
+			IPA_PM_DBG("Exception %d set\n", i);
+			return;
+		}
+	}
+	clk->current_threshold = clk->default_threshold;
+	spin_unlock_irqrestore(&ipa_pm_ctx->clk_scaling.lock, flags);
+}
+
+/**
+ * do_clk_scaling() - set the clock based on the activated clients
+ *
+ * Returns: 0 if success, negative otherwise
+ */
+static int do_clk_scaling(void)
+{
+	int i, tput;
+	int new_th_idx = 1;
+	struct clk_scaling_db *clk_scaling;
+
+	clk_scaling = &ipa_pm_ctx->clk_scaling;
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	IPA_PM_DBG("clock scaling started\n");
+	tput = calculate_throughput();
+	ipa_pm_ctx->aggregated_tput = tput;
+	set_current_threshold();
+
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	for (i = 0; i < clk_scaling->threshold_size; i++) {
+		if (tput > clk_scaling->current_threshold[i])
+			new_th_idx++;
+	}
+
+	IPA_PM_DBG("old idx was at %d\n", ipa_pm_ctx->clk_scaling.cur_vote);
+
+
+	if (ipa_pm_ctx->clk_scaling.cur_vote != new_th_idx) {
+		ipa_pm_ctx->clk_scaling.cur_vote = new_th_idx;
+		ipa3_set_clock_plan_from_pm(ipa_pm_ctx->clk_scaling.cur_vote);
+	}
+
+	IPA_PM_DBG("new idx is at %d\n", ipa_pm_ctx->clk_scaling.cur_vote);
+
+	return 0;
+}
+
+/**
+ * clock_scaling_func() - set the clock on a work queue
+ */
+static void clock_scaling_func(struct work_struct *work)
+{
+	do_clk_scaling();
+}
+
+/**
+ * activate_work_func - activate a client and vote for clock on a work queue
+ */
+static void activate_work_func(struct work_struct *work)
+{
+	struct ipa_pm_client *client;
+	bool dec_clk = false;
+	unsigned long flags;
+
+	client = container_of(work, struct ipa_pm_client, activate_work);
+	if (!client->skip_clk_vote)
+		IPA_ACTIVE_CLIENTS_INC_SPECIAL(client->name);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+	if (client->state == IPA_PM_ACTIVATE_IN_PROGRESS) {
+		client->state = IPA_PM_ACTIVATED;
+	} else if (client->state == IPA_PM_DEACTIVATE_IN_PROGRESS) {
+		client->state = IPA_PM_DEACTIVATED;
+		dec_clk = true;
+	} else {
+		IPA_PM_ERR("unexpected state %d\n", client->state);
+		WARN_ON(1);
+	}
+	spin_unlock_irqrestore(&client->state_lock, flags);
+
+	complete_all(&client->complete);
+
+	if (dec_clk) {
+		ipa_set_tag_process_before_gating(true);
+		if (!client->skip_clk_vote)
+			IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
+
+		IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+		return;
+	}
+
+	activate_client(client->hdl);
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	if (client->callback) {
+		client->callback(client->callback_params,
+			IPA_PM_CLIENT_ACTIVATED);
+	} else {
+		IPA_PM_ERR("client has no callback");
+		WARN_ON(1);
+	}
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+	do_clk_scaling();
+}
+
+/**
+ * delayed_deferred_deactivate_work_func - deferred deactivate on a work queue
+ */
+static void delayed_deferred_deactivate_work_func(struct work_struct *work)
+{
+	struct delayed_work *dwork;
+	struct ipa_pm_client *client;
+	unsigned long flags;
+
+	dwork = container_of(work, struct delayed_work, work);
+	client = container_of(dwork, struct ipa_pm_client, deactivate_work);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+	switch (client->state) {
+	case IPA_PM_ACTIVATED_TIMER_SET:
+		client->state = IPA_PM_ACTIVATED;
+		goto bail;
+	case IPA_PM_ACTIVATED_PENDING_RESCHEDULE:
+		queue_delayed_work(ipa_pm_ctx->wq, &client->deactivate_work,
+			msecs_to_jiffies(IPA_PM_DEFERRED_TIMEOUT));
+		client->state = IPA_PM_ACTIVATED_PENDING_DEACTIVATION;
+		goto bail;
+	case IPA_PM_ACTIVATED_PENDING_DEACTIVATION:
+		client->state = IPA_PM_DEACTIVATED;
+		IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		ipa_set_tag_process_before_gating(true);
+		if (!client->skip_clk_vote)
+			IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
+
+		deactivate_client(client->hdl);
+		do_clk_scaling();
+		return;
+	default:
+		IPA_PM_ERR("unexpected state %d\n", client->state);
+		WARN_ON(1);
+		goto bail;
+	}
+
+bail:
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+	spin_unlock_irqrestore(&client->state_lock, flags);
+}
+
+static int find_next_open_array_element(const char *name)
+{
+	int i, n;
+
+	n = -ENOBUFS;
+
+	for (i = IPA_PM_MAX_CLIENTS - 1; i >= 0; i--) {
+		if (ipa_pm_ctx->clients[i] == NULL) {
+			n = i;
+			continue;
+		}
+
+		if (strlen(name) == strlen(ipa_pm_ctx->clients[i]->name))
+			if (!strcmp(name, ipa_pm_ctx->clients[i]->name))
+				return -EEXIST;
+	}
+	return n;
+}
+
+/**
+ * add_client_to_exception_list() - add client to the exception list and
+ * update pending if necessary
+ * @hdl: index of the IPA client
+ *
+ * Returns: 0 if success, negative otherwise
+ */
+static int add_client_to_exception_list(u32 hdl)
+{
+	int i;
+	struct ipa_pm_exception_list *exception;
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	for (i = 0; i < ipa_pm_ctx->clk_scaling.exception_size; i++) {
+		exception = &ipa_pm_ctx->clk_scaling.exception_list[i];
+		if (strnstr(exception->clients, ipa_pm_ctx->clients[hdl]->name,
+			strlen(exception->clients))) {
+			exception->pending--;
+
+			if (exception->pending < 0) {
+				WARN_ON(1);
+				exception->pending = 0;
+				mutex_unlock(&ipa_pm_ctx->client_mutex);
+				return -EPERM;
+			}
+			exception->bitmask |= (1 << hdl);
+		}
+	}
+	IPA_PM_DBG("%s added to exception list\n",
+		ipa_pm_ctx->clients[hdl]->name);
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	return 0;
+}
+
+/**
+ * remove_client_to_exception_list() - remove client from the exception list and
+ * update pending if necessary
+ * @hdl: index of the IPA client
+ *
+ * Returns: 0 if success, negative otherwise
+ */
+static int remove_client_from_exception_list(u32 hdl)
+{
+	int i;
+	struct ipa_pm_exception_list *exception;
+
+	for (i = 0; i < ipa_pm_ctx->clk_scaling.exception_size; i++) {
+		exception = &ipa_pm_ctx->clk_scaling.exception_list[i];
+		if (exception->bitmask & (1 << hdl)) {
+			exception->pending++;
+			exception->bitmask &= ~(1 << hdl);
+		}
+	}
+	IPA_PM_DBG("Client %d removed from exception list\n", hdl);
+
+	return 0;
+}
+
+/**
+ * ipa_pm_init() - initialize  IPA PM Components
+ * @ipa_pm_init_params: parameters needed to fill exceptions and thresholds
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_init(struct ipa_pm_init_params *params)
+{
+	int i, j;
+	struct clk_scaling_db *clk_scaling;
+
+	if (params == NULL) {
+		IPA_PM_ERR("Invalid Params\n");
+		return -EINVAL;
+	}
+
+	if (params->threshold_size <= 0
+		|| params->threshold_size > IPA_PM_THRESHOLD_MAX) {
+		IPA_PM_ERR("Invalid threshold size\n");
+		return -EINVAL;
+	}
+
+	if (params->exception_size < 0
+		|| params->exception_size > IPA_PM_EXCEPTION_MAX) {
+		IPA_PM_ERR("Invalid exception size\n");
+		return -EINVAL;
+	}
+
+	IPA_PM_DBG("IPA PM initialization started\n");
+
+	if (ipa_pm_ctx != NULL) {
+		IPA_PM_ERR("Already initialized\n");
+		return -EPERM;
+	}
+
+
+	ipa_pm_ctx = kzalloc(sizeof(*ipa_pm_ctx), GFP_KERNEL);
+	if (!ipa_pm_ctx) {
+		IPA_PM_ERR(":kzalloc err.\n");
+		return -ENOMEM;
+	}
+
+	ipa_pm_ctx->wq = create_singlethread_workqueue("ipa_pm_activate");
+	if (!ipa_pm_ctx->wq) {
+		IPA_PM_ERR("create workqueue failed\n");
+		kfree(ipa_pm_ctx);
+		return -ENOMEM;
+	}
+
+	mutex_init(&ipa_pm_ctx->client_mutex);
+
+	/* Populate and init locks in clk_scaling_db */
+	clk_scaling = &ipa_pm_ctx->clk_scaling;
+	spin_lock_init(&clk_scaling->lock);
+	clk_scaling->threshold_size = params->threshold_size;
+	clk_scaling->exception_size = params->exception_size;
+	INIT_WORK(&clk_scaling->work, clock_scaling_func);
+
+	for (i = 0; i < params->threshold_size; i++)
+		clk_scaling->default_threshold[i] =
+			params->default_threshold[i];
+
+	/* Populate exception list*/
+	for (i = 0; i < params->exception_size; i++) {
+		strlcpy(clk_scaling->exception_list[i].clients,
+			params->exceptions[i].usecase, IPA_PM_MAX_EX_CL);
+		IPA_PM_DBG("Usecase: %s\n", params->exceptions[i].usecase);
+
+		/* Parse the commas to count the size of the clients */
+		for (j = 0; j < IPA_PM_MAX_EX_CL &&
+			clk_scaling->exception_list[i].clients[j]; j++) {
+			if (clk_scaling->exception_list[i].clients[j] == ',')
+				clk_scaling->exception_list[i].pending++;
+		}
+
+		clk_scaling->exception_list[i].pending++;
+		IPA_PM_DBG("Pending: %d\n", clk_scaling->
+			exception_list[i].pending);
+
+		/* populate the threshold */
+		for (j = 0; j < params->threshold_size; j++) {
+			clk_scaling->exception_list[i].threshold[j]
+			= params->exceptions[i].threshold[j];
+		}
+
+	}
+	IPA_PM_DBG("initialization success");
+
+	return 0;
+}
+
+int ipa_pm_destroy(void)
+{
+	IPA_PM_DBG("IPA PM destroy started\n");
+
+	if (ipa_pm_ctx == NULL) {
+		IPA_PM_ERR("Already destroyed\n");
+		return -EPERM;
+	}
+
+	destroy_workqueue(ipa_pm_ctx->wq);
+
+	kfree(ipa_pm_ctx);
+	ipa_pm_ctx = NULL;
+
+	return 0;
+}
+
+/**
+ * ipa_rm_delete_register() - register an IPA PM client with the PM
+ * @register_params: params for a client like throughput, callback, etc.
+ * @hdl: int pointer that will be used as an index to access the client
+ *
+ * Returns: 0 on success, negative on failure
+ *
+ * Side effects: *hdl is replaced with the client index or -EEXIST if
+ * client is already registered
+ */
+int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl)
+{
+	struct ipa_pm_client *client;
+
+	if (params == NULL || hdl == NULL || params->name == NULL) {
+		IPA_PM_ERR("Invalid Params\n");
+		return -EINVAL;
+	}
+
+	IPA_PM_DBG("IPA PM registering client\n");
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+
+	*hdl = find_next_open_array_element(params->name);
+
+	if (*hdl > IPA_CLIENT_MAX) {
+		mutex_unlock(&ipa_pm_ctx->client_mutex);
+		IPA_PM_ERR("client is already registered or array is full\n");
+		return *hdl;
+	}
+
+	ipa_pm_ctx->clients[*hdl] = kzalloc(sizeof
+		(struct ipa_pm_client), GFP_KERNEL);
+	if (!ipa_pm_ctx->clients[*hdl]) {
+		mutex_unlock(&ipa_pm_ctx->client_mutex);
+		IPA_PM_ERR(":kzalloc err.\n");
+		return -ENOMEM;
+	}
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	client = ipa_pm_ctx->clients[*hdl];
+
+	spin_lock_init(&client->state_lock);
+
+	INIT_DELAYED_WORK(&client->deactivate_work,
+		delayed_deferred_deactivate_work_func);
+
+	INIT_WORK(&client->activate_work, activate_work_func);
+
+	/* populate fields */
+	strlcpy(client->name, params->name, IPA_PM_MAX_EX_CL);
+	client->callback = params->callback;
+	client->callback_params = params->user_data;
+	client->group = params->group;
+	client->hdl = *hdl;
+	client->skip_clk_vote = params->skip_clk_vote;
+
+	/* add client to exception list */
+	if (add_client_to_exception_list(*hdl)) {
+		ipa_pm_deregister(*hdl);
+		IPA_PM_ERR("Fail to add client to exception_list\n");
+		return -EPERM;
+	}
+
+	IPA_PM_DBG("IPA PM client registered with handle %d\n", *hdl);
+	return 0;
+}
+
+/**
+ * ipa_pm_deregister() - deregister IPA client from the PM
+ * @hdl: index of the client in the array
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_deregister(u32 hdl)
+{
+	struct ipa_pm_client *client;
+	int i;
+	unsigned long flags;
+
+	if (hdl >= IPA_PM_MAX_CLIENTS) {
+		IPA_PM_ERR("Invalid Param\n");
+		return -EINVAL;
+	}
+
+	if (ipa_pm_ctx->clients[hdl] == NULL) {
+		IPA_PM_ERR("Client is Null\n");
+		return -EINVAL;
+	}
+
+	IPA_PM_DBG("IPA PM deregistering client\n");
+
+	client = ipa_pm_ctx->clients[hdl];
+	spin_lock_irqsave(&client->state_lock, flags);
+	if (IPA_PM_STATE_IN_PROGRESS(client->state)) {
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		wait_for_completion(&client->complete);
+		spin_lock_irqsave(&client->state_lock, flags);
+	}
+
+	if (IPA_PM_STATE_ACTIVE(client->state)) {
+		IPA_PM_DBG("Activated clients cannot be deregistered");
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		return -EPERM;
+	}
+	spin_unlock_irqrestore(&client->state_lock, flags);
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+
+	/* nullify pointers in pipe array */
+	for (i = 0; i < IPA3_MAX_NUM_PIPES; i++) {
+		if (ipa_pm_ctx->clients_by_pipe[i] == ipa_pm_ctx->clients[hdl])
+			ipa_pm_ctx->clients_by_pipe[i] = NULL;
+	}
+	kfree(client);
+	ipa_pm_ctx->clients[hdl] = NULL;
+
+	remove_client_from_exception_list(hdl);
+	IPA_PM_DBG("IPA PM client %d deregistered\n", hdl);
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	return 0;
+}
+
+/**
+ * ipa_pm_associate_ipa_cons_to_client() - add mapping to pipe with ipa cllent
+ * @hdl: index of the client to be mapped
+ * @consumer: the pipe/consumer name to be pipped to the client
+ *
+ * Returns: 0 on success, negative on failure
+ *
+ * Side effects: multiple pipes are allowed to be mapped to a single client
+ */
+int ipa_pm_associate_ipa_cons_to_client(u32 hdl, enum ipa_client_type consumer)
+{
+	int idx;
+
+	if (hdl >= IPA_PM_MAX_CLIENTS || consumer < 0 ||
+		consumer >= IPA_CLIENT_MAX) {
+		IPA_PM_ERR("invalid params\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	idx = ipa_get_ep_mapping(consumer);
+
+	IPA_PM_DBG("Mapping pipe %d to client %d\n", idx, hdl);
+
+	if (idx < 0) {
+		mutex_unlock(&ipa_pm_ctx->client_mutex);
+		IPA_PM_DBG("Pipe is not used\n");
+		return 0;
+	}
+
+	if (ipa_pm_ctx->clients[hdl] == NULL) {
+		mutex_unlock(&ipa_pm_ctx->client_mutex);
+		IPA_PM_ERR("Client is NULL\n");
+		return -EPERM;
+	}
+
+	if (ipa_pm_ctx->clients_by_pipe[idx] != NULL) {
+		mutex_unlock(&ipa_pm_ctx->client_mutex);
+		IPA_PM_ERR("Pipe is already mapped\n");
+		return -EPERM;
+	}
+	ipa_pm_ctx->clients_by_pipe[idx] = ipa_pm_ctx->clients[hdl];
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	IPA_PM_DBG("Pipe %d is mapped to client %d\n", idx, hdl);
+
+	return 0;
+}
+
+static int ipa_pm_activate_helper(struct ipa_pm_client *client, bool sync)
+{
+	struct ipa_active_client_logging_info log_info;
+	int result = 0;
+	unsigned long flags;
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+
+	if (IPA_PM_STATE_IN_PROGRESS(client->state)) {
+		if (sync) {
+			spin_unlock_irqrestore(&client->state_lock, flags);
+			wait_for_completion(&client->complete);
+			spin_lock_irqsave(&client->state_lock, flags);
+		} else {
+			client->state = IPA_PM_ACTIVATE_IN_PROGRESS;
+			spin_unlock_irqrestore(&client->state_lock, flags);
+			return -EINPROGRESS;
+		}
+	}
+
+	switch (client->state) {
+	case IPA_PM_ACTIVATED_PENDING_RESCHEDULE:
+	case IPA_PM_ACTIVATED_PENDING_DEACTIVATION:
+		client->state = IPA_PM_ACTIVATED_TIMER_SET;
+	case IPA_PM_ACTIVATED:
+	case IPA_PM_ACTIVATED_TIMER_SET:
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		return 0;
+	case IPA_PM_DEACTIVATED:
+		break;
+	default:
+		IPA_PM_ERR("Invalid State\n");
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		return -EPERM;
+	}
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+
+	IPA_ACTIVE_CLIENTS_PREP_SPECIAL(log_info, client->name);
+	if (!client->skip_clk_vote) {
+		if (sync) {
+			client->state = IPA_PM_ACTIVATE_IN_PROGRESS;
+			spin_unlock_irqrestore(&client->state_lock, flags);
+			IPA_ACTIVE_CLIENTS_INC_SPECIAL(client->name);
+			spin_lock_irqsave(&client->state_lock, flags);
+		} else
+			result = ipa3_inc_client_enable_clks_no_block
+				 (&log_info);
+	}
+
+	/* we got the clocks */
+	if (result == 0) {
+		client->state = IPA_PM_ACTIVATED;
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		activate_client(client->hdl);
+		if (sync)
+			do_clk_scaling();
+		else
+			queue_work(ipa_pm_ctx->wq,
+				   &ipa_pm_ctx->clk_scaling.work);
+		IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+		return 0;
+	}
+
+	client->state = IPA_PM_ACTIVATE_IN_PROGRESS;
+	init_completion(&client->complete);
+	queue_work(ipa_pm_ctx->wq, &client->activate_work);
+	spin_unlock_irqrestore(&client->state_lock, flags);
+	IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+	return -EINPROGRESS;
+}
+
+/**
+ * ipa_pm_activate(): activate ipa client to vote for clock(). Can be called
+ * from atomic context and returns -EINPROGRESS if cannot be done synchronously
+ * @hdl: index of the client in the array
+ *
+ * Returns: 0 on success, -EINPROGRESS if operation cannot be done synchronously
+ * and other negatives on failure
+ */
+int ipa_pm_activate(u32 hdl)
+{
+	if (hdl >= IPA_PM_MAX_CLIENTS || ipa_pm_ctx->clients[hdl] == NULL) {
+		IPA_PM_ERR("Invalid Param\n");
+		return -EINVAL;
+	}
+
+	return ipa_pm_activate_helper(ipa_pm_ctx->clients[hdl], false);
+}
+
+/**
+ * ipa_pm_activate(): activate ipa client to vote for clock synchronously.
+ * Cannot be called from an atomic contex.
+ * @hdl: index of the client in the array
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_activate_sync(u32 hdl)
+{
+	if (hdl >= IPA_PM_MAX_CLIENTS || ipa_pm_ctx->clients[hdl] == NULL) {
+		IPA_PM_ERR("Invalid Param\n");
+		return -EINVAL;
+	}
+
+	return ipa_pm_activate_helper(ipa_pm_ctx->clients[hdl], true);
+}
+
+/**
+ * ipa_pm_deferred_deactivate(): schedule a timer to deactivate client and
+ * devote clock. Can be called from atomic context (asynchronously)
+ * @hdl: index of the client in the array
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_deferred_deactivate(u32 hdl)
+{
+	struct ipa_pm_client *client;
+	unsigned long flags;
+
+	if (hdl >= IPA_PM_MAX_CLIENTS || ipa_pm_ctx->clients[hdl] == NULL) {
+		IPA_PM_ERR("Invalid Param\n");
+		return -EINVAL;
+	}
+
+	client = ipa_pm_ctx->clients[hdl];
+	IPA_PM_DBG_STATE(hdl, client->name, client->state);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	switch (client->state) {
+	case IPA_PM_ACTIVATE_IN_PROGRESS:
+		client->state = IPA_PM_DEACTIVATE_IN_PROGRESS;
+	case IPA_PM_DEACTIVATED:
+		IPA_PM_DBG_STATE(hdl, client->name, client->state);
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		return 0;
+	case IPA_PM_ACTIVATED:
+		client->state = IPA_PM_ACTIVATED_PENDING_DEACTIVATION;
+		queue_delayed_work(ipa_pm_ctx->wq, &client->deactivate_work,
+			msecs_to_jiffies(IPA_PM_DEFERRED_TIMEOUT));
+		break;
+	case IPA_PM_ACTIVATED_TIMER_SET:
+	case IPA_PM_ACTIVATED_PENDING_DEACTIVATION:
+		client->state = IPA_PM_ACTIVATED_PENDING_RESCHEDULE;
+	case IPA_PM_DEACTIVATE_IN_PROGRESS:
+	case IPA_PM_ACTIVATED_PENDING_RESCHEDULE:
+		break;
+	}
+	IPA_PM_DBG_STATE(hdl, client->name, client->state);
+	spin_unlock_irqrestore(&client->state_lock, flags);
+
+	return 0;
+}
+
+/**
+ * ipa_pm_deactivate_all_deferred(): Cancel the deferred deactivation timer and
+ * immediately devotes for IPA clocks
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_deactivate_all_deferred(void)
+{
+	int i;
+	bool run_algorithm = false;
+	struct ipa_pm_client *client;
+	unsigned long flags;
+
+	for (i = 0; i < IPA_PM_MAX_CLIENTS; i++) {
+		client = ipa_pm_ctx->clients[i];
+
+		if (client == NULL)
+			continue;
+
+		cancel_delayed_work_sync(&client->deactivate_work);
+
+		if (IPA_PM_STATE_IN_PROGRESS(client->state)) {
+			wait_for_completion(&client->complete);
+			continue;
+		}
+
+		spin_lock_irqsave(&client->state_lock, flags);
+		IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
+
+		if (client->state == IPA_PM_ACTIVATED_TIMER_SET) {
+			client->state = IPA_PM_ACTIVATED;
+			IPA_PM_DBG_STATE(client->hdl, client->name,
+				client->state);
+			spin_unlock_irqrestore(&client->state_lock, flags);
+		} else if (client->state ==
+			IPA_PM_ACTIVATED_PENDING_DEACTIVATION ||
+			IPA_PM_ACTIVATED_PENDING_RESCHEDULE) {
+			run_algorithm = true;
+			client->state = IPA_PM_DEACTIVATED;
+			IPA_PM_DBG_STATE(client->hdl, client->name,
+				client->state);
+			spin_unlock_irqrestore(&client->state_lock, flags);
+			ipa_set_tag_process_before_gating(true);
+			if (!client->skip_clk_vote)
+				IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
+			deactivate_client(client->hdl);
+		} else /* if activated or deactivated, we do nothing */
+			spin_unlock_irqrestore(&client->state_lock, flags);
+	}
+
+	if (run_algorithm)
+		do_clk_scaling();
+
+	return 0;
+}
+
+/**
+ * ipa_pm_deactivate_sync(): deactivate ipa client and devote clock. Cannot be
+ * called from atomic context.
+ * @hdl: index of the client in the array
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_deactivate_sync(u32 hdl)
+{
+	struct ipa_pm_client *client = ipa_pm_ctx->clients[hdl];
+	unsigned long flags;
+
+	if (hdl >= IPA_PM_MAX_CLIENTS || ipa_pm_ctx->clients[hdl] == NULL) {
+		IPA_PM_ERR("Invalid Param\n");
+		return -EINVAL;
+	}
+
+	cancel_delayed_work_sync(&client->deactivate_work);
+
+	if (IPA_PM_STATE_IN_PROGRESS(client->state))
+		wait_for_completion(&client->complete);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	IPA_PM_DBG_STATE(hdl, client->name, client->state);
+
+	if (client->state == IPA_PM_DEACTIVATED) {
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		return 0;
+	}
+
+	spin_unlock_irqrestore(&client->state_lock, flags);
+
+	/* else case (Deactivates all Activated cases)*/
+	ipa_set_tag_process_before_gating(true);
+	if (!client->skip_clk_vote)
+		IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	client->state = IPA_PM_DEACTIVATED;
+	IPA_PM_DBG_STATE(hdl, client->name, client->state);
+	spin_unlock_irqrestore(&client->state_lock, flags);
+	deactivate_client(hdl);
+	do_clk_scaling();
+
+	return 0;
+}
+
+/**
+ * ipa_pm_handle_suspend(): calls the callbacks of suspended clients to wake up
+ * @pipe_bitmask: the bits represent the indexes of the clients to be woken up
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_handle_suspend(u32 pipe_bitmask)
+{
+	int i;
+	struct ipa_pm_client *client;
+	bool client_notified[IPA_PM_MAX_CLIENTS] = { false };
+
+	IPA_PM_DBG_LOW("bitmask: %d",  pipe_bitmask);
+
+	if (pipe_bitmask == 0)
+		return 0;
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	for (i = 0; i < IPA3_MAX_NUM_PIPES; i++) {
+		if (pipe_bitmask & (1 << i)) {
+			client = ipa_pm_ctx->clients_by_pipe[i];
+			if (client && client_notified[client->hdl] == false) {
+				if (client->callback) {
+					client->callback(client->callback_params
+						, IPA_PM_REQUEST_WAKEUP);
+					client_notified[client->hdl] = true;
+				} else {
+					IPA_PM_ERR("client has no callback");
+					WARN_ON(1);
+				}
+			}
+		}
+	}
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+	return 0;
+}
+
+/**
+ * ipa_pm_set_perf_profile(): Adds/changes the throughput requirement to IPA PM
+ * to be used for clock scaling
+ * @hdl: index of the client in the array
+ * @throughput: the new throughput value to be set for that client
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int ipa_pm_set_perf_profile(u32 hdl, int throughput)
+{
+	struct ipa_pm_client *client = ipa_pm_ctx->clients[hdl];
+	unsigned long flags;
+
+	if (hdl >= IPA_PM_MAX_CLIENTS || ipa_pm_ctx->clients[hdl] == NULL
+		|| throughput < 0) {
+		IPA_PM_ERR("Invalid Params\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	if (client->group == IPA_PM_GROUP_DEFAULT)
+		IPA_PM_DBG_LOW("Old throughput: %d\n",  client->throughput);
+	else
+		IPA_PM_DBG_LOW("old Group %d throughput: %d\n",
+			client->group, ipa_pm_ctx->group_tput[client->group]);
+
+	if (client->group == IPA_PM_GROUP_DEFAULT)
+		client->throughput = throughput;
+	else
+		ipa_pm_ctx->group_tput[client->group] = throughput;
+
+	if (client->group == IPA_PM_GROUP_DEFAULT)
+		IPA_PM_DBG_LOW("New throughput: %d\n",  client->throughput);
+	else
+		IPA_PM_DBG_LOW("New Group %d throughput: %d\n",
+			client->group, ipa_pm_ctx->group_tput[client->group]);
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	spin_lock_irqsave(&client->state_lock, flags);
+	if (IPA_PM_STATE_ACTIVE(client->state) || (client->group !=
+			IPA_PM_GROUP_DEFAULT)) {
+		spin_unlock_irqrestore(&client->state_lock, flags);
+		do_clk_scaling();
+		return 0;
+	}
+	spin_unlock_irqrestore(&client->state_lock, flags);
+
+	return 0;
+}
+
+/**
+ * ipa_pm_stat() - print PM stat
+ * @buf: [in] The user buff used to print
+ * @size: [in] The size of buf
+ * Returns: number of bytes used on success, negative on failure
+ *
+ * This function is called by ipa_debugfs in order to receive
+ * a picture of the clients in the PM and the throughput, threshold and cur vote
+ */
+int ipa_pm_stat(char *buf, int size)
+{
+	struct ipa_pm_client *client;
+	struct clk_scaling_db *clk = &ipa_pm_ctx->clk_scaling;
+	int i, j, tput, cnt = 0, result = 0;
+	unsigned long flags;
+
+	if (!buf || size < 0)
+		return -EINVAL;
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+
+	result = scnprintf(buf + cnt, size - cnt, "\n\nCurrent threshold: [");
+	cnt += result;
+
+	for (i = 0; i < clk->threshold_size; i++) {
+		result = scnprintf(buf + cnt, size - cnt,
+			"%d, ", clk->current_threshold[i]);
+		cnt += result;
+	}
+
+	result = scnprintf(buf + cnt, size - cnt, "\b\b]\n");
+	cnt += result;
+
+	result = scnprintf(buf + cnt, size - cnt,
+		"Aggregated tput: %d, Cur vote: %d",
+		ipa_pm_ctx->aggregated_tput, clk->cur_vote);
+	cnt += result;
+
+	result = scnprintf(buf + cnt, size - cnt, "\n\nRegistered Clients:\n");
+	cnt += result;
+
+
+	for (i = 0; i < IPA_PM_MAX_CLIENTS; i++) {
+		client = ipa_pm_ctx->clients[i];
+
+		if (client == NULL)
+			continue;
+
+		spin_lock_irqsave(&client->state_lock, flags);
+		if (client->group == IPA_PM_GROUP_DEFAULT)
+			tput = client->throughput;
+		else
+			tput = ipa_pm_ctx->group_tput[client->group];
+
+		result = scnprintf(buf + cnt, size - cnt,
+		"Client[%d]: %s State:%s\nGroup: %s Throughput: %d Pipes: ",
+			i, client->name, client_state_to_str[client->state],
+			ipa_pm_group_to_str[client->group], tput);
+		cnt += result;
+
+		for (j = 0; j < IPA3_MAX_NUM_PIPES; j++) {
+			if (ipa_pm_ctx->clients_by_pipe[j] == client) {
+				result = scnprintf(buf + cnt, size - cnt,
+					"%d, ", j);
+				cnt += result;
+			}
+		}
+
+		result = scnprintf(buf + cnt, size - cnt, "\b\b\n\n");
+		cnt += result;
+		spin_unlock_irqrestore(&client->state_lock, flags);
+	}
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	return cnt;
+}
+
+/**
+ * ipa_pm_exceptions_stat() - print PM exceptions stat
+ * @buf: [in] The user buff used to print
+ * @size: [in] The size of buf
+ * Returns: number of bytes used on success, negative on failure
+ *
+ * This function is called by ipa_debugfs in order to receive
+ * a full picture of the exceptions in the PM
+ */
+int ipa_pm_exceptions_stat(char *buf, int size)
+{
+	int i, j, cnt = 0, result = 0;
+	struct ipa_pm_exception_list *exception;
+
+	if (!buf || size < 0)
+		return -EINVAL;
+
+	result = scnprintf(buf + cnt, size - cnt, "\n");
+	cnt += result;
+
+	mutex_lock(&ipa_pm_ctx->client_mutex);
+	for (i = 0; i < ipa_pm_ctx->clk_scaling.exception_size; i++) {
+		exception = &ipa_pm_ctx->clk_scaling.exception_list[i];
+		if (exception == NULL) {
+			result = scnprintf(buf + cnt, size - cnt,
+			"Exception %d is NULL\n\n", i);
+			cnt += result;
+			continue;
+		}
+
+		result = scnprintf(buf + cnt, size - cnt,
+			"Exception %d: %s\nPending: %d Bitmask: %d Threshold: ["
+			, i, exception->clients, exception->pending,
+			exception->bitmask);
+		cnt += result;
+		for (j = 0; j < ipa_pm_ctx->clk_scaling.threshold_size; j++) {
+			result = scnprintf(buf + cnt, size - cnt,
+				"%d, ", exception->threshold[j]);
+			cnt += result;
+		}
+		result = scnprintf(buf + cnt, size - cnt, "\b\b]\n\n");
+		cnt += result;
+	}
+	mutex_unlock(&ipa_pm_ctx->client_mutex);
+
+	return cnt;
+}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_pm.h b/drivers/platform/msm/ipa/ipa_v3/ipa_pm.h
new file mode 100644
index 0000000..ca022b5
--- /dev/null
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_pm.h
@@ -0,0 +1,110 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _IPA_PM_H_
+#define _IPA_PM_H_
+
+#include <linux/msm_ipa.h>
+
+/* internal to ipa */
+#define IPA_PM_MAX_CLIENTS 10
+#define IPA_PM_MAX_EX_CL 64
+#define IPA_PM_THRESHOLD_MAX 2
+#define IPA_PM_EXCEPTION_MAX 2
+#define IPA_PM_DEFERRED_TIMEOUT 100
+#define IPA_PM_STATE_MAX 7
+
+/*
+ * ipa_pm group names
+ *
+ * Default stands for individual clients while other groups share one throughput
+ * Some groups also have special flags like modem which do not vote for clock
+ * but is accounted for in clock scaling while activated
+ */
+enum ipa_pm_group {
+	IPA_PM_GROUP_DEFAULT,
+	IPA_PM_GROUP_APPS,
+	IPA_PM_GROUP_MODEM,
+	IPA_PM_GROUP_MAX,
+};
+
+/*
+ * ipa_pm_cb_event
+ *
+ * specifies what kind of callback is being called.
+ * IPA_PM_CLIENT_ACTIVATED: the client has completed asynchronous activation
+ * IPA_PM_REQUEST_WAKEUP: wake up the client after it has been suspended
+ */
+enum ipa_pm_cb_event {
+	IPA_PM_CLIENT_ACTIVATED,
+	IPA_PM_REQUEST_WAKEUP,
+	IPA_PM_CB_EVENT_MAX,
+};
+
+/*
+ * struct ipa_pm_exception - clients included in exception and its threshold
+ * @usecase: comma separated client names
+ * @threshold: the threshold values for the exception
+ */
+struct ipa_pm_exception {
+	const char *usecase;
+	int threshold[IPA_PM_THRESHOLD_MAX];
+};
+
+/*
+ * struct ipa_pm_init_params - parameters needed for initializng the pm
+ * @default_threshold: the thresholds used if no exception passes
+ * @threshold_size: size of the threshold
+ * @exceptions: list of exceptions  for the pm
+ * @exception_size: size of the exception_list
+ */
+struct ipa_pm_init_params {
+	int default_threshold[IPA_PM_THRESHOLD_MAX];
+	int threshold_size;
+	struct ipa_pm_exception exceptions[IPA_PM_EXCEPTION_MAX];
+	int exception_size;
+};
+
+/*
+ * struct ipa_pm_register_params - parameters needed to register a client
+ * @name: name of the client
+ * @callback: pointer to the client's callback function
+ * @user_data: pointer to the client's callback parameters
+ * @group: group number of the client
+ * @skip_clk_vote: 0 if client votes for clock when activated, 1 if no vote
+ */
+struct ipa_pm_register_params {
+	const char *name;
+	void (*callback)(void*, enum ipa_pm_cb_event);
+	void *user_data;
+	enum ipa_pm_group group;
+	bool skip_clk_vote;
+};
+
+int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl);
+int ipa_pm_associate_ipa_cons_to_client(u32 hdl, enum ipa_client_type consumer);
+int ipa_pm_activate(u32 hdl);
+int ipa_pm_activate_sync(u32 hdl);
+int ipa_pm_deferred_deactivate(u32 hdl);
+int ipa_pm_deactivate_sync(u32 hdl);
+int ipa_pm_set_perf_profile(u32 hdl, int throughput);
+int ipa_pm_deregister(u32 hdl);
+
+/* IPA Internal Functions */
+int ipa_pm_init(struct ipa_pm_init_params *params);
+int ipa_pm_destroy(void);
+int ipa_pm_handle_suspend(u32 pipe_bitmask);
+int ipa_pm_deactivate_all_deferred(void);
+int ipa_pm_stat(char *buf, int size);
+int ipa_pm_exceptions_stat(char *buf, int size);
+
+#endif /* _IPA_PM_H_ */
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
index 61bccc6..fbaa4ae 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
@@ -798,9 +798,8 @@
 
 	/* check if the filter rules from IPACM is valid */
 	if (req->rule_id_len == 0) {
-		IPAWANERR(" delete UL filter rule for pipe %d\n",
+		IPAWANDBG(" delete UL filter rule for pipe %d\n",
 		req->source_pipe_index);
-		return -EINVAL;
 	} else if (req->rule_id_len > QMI_IPA_MAX_FILTERS_V01) {
 		IPAWANERR(" UL filter rule for pipe %d exceed max (%u)\n",
 		req->source_pipe_index,
@@ -1214,7 +1213,6 @@
 /* voting for bus BW to ipa_rm*/
 int ipa3_vote_for_bus_bw(uint32_t *bw_mbps)
 {
-	struct ipa_rm_perf_profile profile;
 	int ret;
 
 	if (bw_mbps == NULL) {
@@ -1222,16 +1220,13 @@
 		return -EINVAL;
 	}
 
-	memset(&profile, 0, sizeof(profile));
-	profile.max_supported_bandwidth_mbps = *bw_mbps;
-	ret = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_Q6_PROD,
-			&profile);
+	ret = ipa3_wwan_set_modem_perf_profile(*bw_mbps);
 	if (ret)
 		IPAWANERR("Failed to set perf profile to BW %u\n",
-			profile.max_supported_bandwidth_mbps);
+			*bw_mbps);
 	else
 		IPAWANDBG("Succeeded to set perf profile to BW %u\n",
-			profile.max_supported_bandwidth_mbps);
+			*bw_mbps);
 
 	return ret;
 }
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h
index d5d8503..d3a4ba0 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h
@@ -207,6 +207,10 @@
 
 void ipa3_q6_handshake_complete(bool ssr_bootup);
 
+int ipa3_wwan_set_modem_perf_profile(int throughput);
+
+int ipa3_wwan_set_modem_state(struct wan_ioctl_notify_wan_state *state);
+
 void ipa3_qmi_init(void);
 
 void ipa3_qmi_cleanup(void);
@@ -323,6 +327,11 @@
 
 static inline void ipa3_q6_handshake_complete(bool ssr_bootup) { }
 
+static inline int ipa3_wwan_set_modem_perf_profile(int throughput)
+{
+	return -EPERM;
+}
+
 static inline void ipa3_qmi_init(void)
 {
 }
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
index ef0158e..8bd7d30 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
@@ -73,11 +73,18 @@
 		struct ipa3_hdr_proc_ctx_entry *proc_ctx;
 
 		proc_ctx = (entry->proc_ctx) ? : entry->hdr->proc_ctx;
-		gen_params.hdr_lcl = ipa3_ctx->hdr_proc_ctx_tbl_lcl;
-		gen_params.hdr_type = IPAHAL_RT_RULE_HDR_PROC_CTX;
-		gen_params.hdr_ofst = proc_ctx->offset_entry->offset +
-			ipa3_ctx->hdr_proc_ctx_tbl.start_offset;
-	} else if (entry->hdr) {
+		if ((proc_ctx == NULL) ||
+			(proc_ctx->cookie != IPA_PROC_HDR_COOKIE)) {
+			gen_params.hdr_type = IPAHAL_RT_RULE_HDR_NONE;
+			gen_params.hdr_ofst = 0;
+		} else {
+			gen_params.hdr_lcl = ipa3_ctx->hdr_proc_ctx_tbl_lcl;
+			gen_params.hdr_type = IPAHAL_RT_RULE_HDR_PROC_CTX;
+			gen_params.hdr_ofst = proc_ctx->offset_entry->offset +
+				ipa3_ctx->hdr_proc_ctx_tbl.start_offset;
+		}
+	} else if ((entry->hdr != NULL) &&
+		(entry->hdr->cookie == IPA_HDR_COOKIE)) {
 		gen_params.hdr_lcl = ipa3_ctx->hdr_tbl_lcl;
 		gen_params.hdr_type = IPAHAL_RT_RULE_HDR_RAW;
 		gen_params.hdr_ofst = entry->hdr->offset_entry->offset;
@@ -1142,6 +1149,13 @@
 		goto bail;
 	}
 
+	if (entry->cookie != IPA_RT_RULE_COOKIE) {
+		IPAERR_RL("Invalid cookie value =  %u rule %d in rt tbls\n",
+			entry->cookie, rules->add_after_hdl);
+		ret = -EINVAL;
+		goto bail;
+	}
+
 	if (entry->tbl != tbl) {
 		IPAERR_RL("given rt rule does not match the table\n");
 		ret = -EINVAL;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
index 8c55a01..f717264 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
@@ -24,14 +24,17 @@
 #include "ipahal/ipahal_hw_stats.h"
 #include "../ipa_rm_i.h"
 
+#define IPA_V3_0_CLK_RATE_SVS2 (37.5 * 1000 * 1000UL)
 #define IPA_V3_0_CLK_RATE_SVS (75 * 1000 * 1000UL)
 #define IPA_V3_0_CLK_RATE_NOMINAL (150 * 1000 * 1000UL)
 #define IPA_V3_0_CLK_RATE_TURBO (200 * 1000 * 1000UL)
 
+#define IPA_V3_5_CLK_RATE_SVS2 (100 * 1000 * 1000UL)
 #define IPA_V3_5_CLK_RATE_SVS (200 * 1000 * 1000UL)
 #define IPA_V3_5_CLK_RATE_NOMINAL (400 * 1000 * 1000UL)
 #define IPA_V3_5_CLK_RATE_TURBO (42640 * 10 * 1000UL)
 
+#define IPA_V4_0_CLK_RATE_SVS2 (60 * 1000 * 1000UL)
 #define IPA_V4_0_CLK_RATE_SVS (125 * 1000 * 1000UL)
 #define IPA_V4_0_CLK_RATE_NOMINAL (220 * 1000 * 1000UL)
 #define IPA_V4_0_CLK_RATE_TURBO (250 * 1000 * 1000UL)
@@ -40,6 +43,7 @@
 
 #define IPA_V3_0_BW_THRESHOLD_TURBO_MBPS (1000)
 #define IPA_V3_0_BW_THRESHOLD_NOMINAL_MBPS (600)
+#define IPA_V3_0_BW_THRESHOLD_SVS_MBPS (310)
 
 #define IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_BMASK 0xFF0000
 #define IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_SHFT 0x10
@@ -3733,14 +3737,17 @@
 		ctrl->ipa_clk_rate_turbo = IPA_V4_0_CLK_RATE_TURBO;
 		ctrl->ipa_clk_rate_nominal = IPA_V4_0_CLK_RATE_NOMINAL;
 		ctrl->ipa_clk_rate_svs = IPA_V4_0_CLK_RATE_SVS;
+		ctrl->ipa_clk_rate_svs2 = IPA_V4_0_CLK_RATE_SVS2;
 	} else if (hw_type >= IPA_HW_v3_5) {
 		ctrl->ipa_clk_rate_turbo = IPA_V3_5_CLK_RATE_TURBO;
 		ctrl->ipa_clk_rate_nominal = IPA_V3_5_CLK_RATE_NOMINAL;
 		ctrl->ipa_clk_rate_svs = IPA_V3_5_CLK_RATE_SVS;
+		ctrl->ipa_clk_rate_svs2 = IPA_V3_5_CLK_RATE_SVS2;
 	} else {
 		ctrl->ipa_clk_rate_turbo = IPA_V3_0_CLK_RATE_TURBO;
 		ctrl->ipa_clk_rate_nominal = IPA_V3_0_CLK_RATE_NOMINAL;
 		ctrl->ipa_clk_rate_svs = IPA_V3_0_CLK_RATE_SVS;
+		ctrl->ipa_clk_rate_svs2 = IPA_V3_0_CLK_RATE_SVS2;
 	}
 
 	ctrl->ipa_init_rt4 = _ipa_init_rt4_v3;
@@ -3754,6 +3761,8 @@
 	ctrl->ipa3_enable_clks = _ipa_enable_clks_v3_0;
 	ctrl->ipa3_disable_clks = _ipa_disable_clks_v3_0;
 	ctrl->msm_bus_data_ptr = &ipa_bus_client_pdata_v3_0;
+	ctrl->clock_scaling_bw_threshold_svs =
+		IPA_V3_0_BW_THRESHOLD_SVS_MBPS;
 	ctrl->clock_scaling_bw_threshold_nominal =
 		IPA_V3_0_BW_THRESHOLD_NOMINAL_MBPS;
 	ctrl->clock_scaling_bw_threshold_turbo =
@@ -4183,10 +4192,15 @@
  */
 void ipa3_proxy_clk_unvote(void)
 {
-	if (ipa3_is_ready() && ipa3_ctx->q6_proxy_clk_vote_valid) {
+	if (!ipa3_is_ready())
+		return;
+
+	mutex_lock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
+	if (ipa3_ctx->q6_proxy_clk_vote_valid) {
 		IPA_ACTIVE_CLIENTS_DEC_SPECIAL("PROXY_CLK_VOTE");
 		ipa3_ctx->q6_proxy_clk_vote_valid = false;
 	}
+	mutex_unlock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
 }
 
 /**
@@ -4196,10 +4210,15 @@
  */
 void ipa3_proxy_clk_vote(void)
 {
-	if (ipa3_is_ready() && !ipa3_ctx->q6_proxy_clk_vote_valid) {
+	if (!ipa3_is_ready())
+		return;
+
+	mutex_lock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
+	if (!ipa3_ctx->q6_proxy_clk_vote_valid) {
 		IPA_ACTIVE_CLIENTS_INC_SPECIAL("PROXY_CLK_VOTE");
 		ipa3_ctx->q6_proxy_clk_vote_valid = true;
 	}
+	mutex_unlock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
 }
 
 /**
@@ -4836,11 +4855,8 @@
 		IPADBG("ch %ld not empty\n", ep->gsi_chan_hdl);
 		/* queue a work to start polling if don't have one */
 		atomic_set(&ipa3_ctx->transport_pm.eot_activity, 1);
-		if (!atomic_read(&ep->sys->curr_polling_state)) {
-			ipa3_inc_acquire_wakelock();
-			atomic_set(&ep->sys->curr_polling_state, 1);
-			queue_work(ep->sys->wq, &ep->sys->work);
-		}
+		if (!atomic_read(&ep->sys->curr_polling_state))
+			__ipa_gsi_irq_rx_scedule_poll(ep->sys);
 	}
 }
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal.c b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal.c
index 56fed2a..a8d5342 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal.c
@@ -595,6 +595,15 @@
 	return pyld;
 }
 
+static struct ipahal_imm_cmd_pyld *ipa_imm_cmd_construct_dummy(
+	enum ipahal_imm_cmd_name cmd, const void *params, bool is_atomic_ctx)
+{
+	IPAHAL_ERR("no construct function for IMM_CMD=%s, IPA ver %d\n",
+		ipahal_imm_cmd_name_str(cmd), ipahal_ctx->hw_type);
+	WARN_ON(1);
+	return NULL;
+}
+
 /*
  * struct ipahal_imm_cmd_obj - immediate command H/W information for
  *  specific IPA version
@@ -668,8 +677,8 @@
 		12},
 	/* NAT_DMA was renamed to TABLE_DMA for IPAv4 */
 	[IPA_HW_v4_0][IPA_IMM_CMD_NAT_DMA] = {
-		NULL,
-		-1 },
+		ipa_imm_cmd_construct_dummy,
+		-1},
 	[IPA_HW_v4_0][IPA_IMM_CMD_TABLE_DMA] = {
 		ipa_imm_cmd_construct_table_dma_ipav4,
 		14},
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.c b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.c
index dc71414..74f5bbd 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.c
@@ -1961,20 +1961,3 @@
 
 	valmask->mask = valmask->val;
 }
-
-void ipahal_get_status_ep_valmask(int pipe_num,
-	struct ipahal_reg_valmask *valmask)
-{
-	if (!valmask) {
-		IPAHAL_ERR("Input error\n");
-		return;
-	}
-
-	valmask->val =
-		(pipe_num & IPA_ENDP_STATUS_n_STATUS_ENDP_BMSK) <<
-		IPA_ENDP_STATUS_n_STATUS_ENDP_SHFT;
-
-	valmask->mask =
-		IPA_ENDP_STATUS_n_STATUS_ENDP_BMSK <<
-		IPA_ENDP_STATUS_n_STATUS_ENDP_SHFT;
-}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.h b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.h
index a2864cd..df3c976 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.h
@@ -541,8 +541,6 @@
 void ipahal_get_fltrt_hash_flush_valmask(
 	struct ipahal_reg_fltrt_hash_flush *flush,
 	struct ipahal_reg_valmask *valmask);
-void ipahal_get_status_ep_valmask(int pipe_num,
-	struct ipahal_reg_valmask *valmask);
 
 #endif /* _IPAHAL_REG_H_ */
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c
index b119a69..f08e1e3 100644
--- a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c
@@ -142,6 +142,9 @@
 	u32 ipa3_to_apps_hdl;
 	struct mutex pipe_handle_guard;
 	struct mutex add_mux_channel_lock;
+	u32 pm_hdl;
+	u32 q6_pm_hdl;
+	u32 q6_teth_pm_hdl;
 };
 
 static struct rmnet_ipa3_context *rmnet_ipa3_ctx;
@@ -423,6 +426,8 @@
 {
 	int i, j;
 
+	/* prevent multi-threads accessing rmnet_ipa3_ctx->num_q6_rules */
+	mutex_lock(&rmnet_ipa3_ctx->add_mux_channel_lock);
 	if (rule_req->filter_spec_ex_list_valid == true) {
 		rmnet_ipa3_ctx->num_q6_rules =
 			rule_req->filter_spec_ex_list_len;
@@ -431,6 +436,8 @@
 	} else {
 		rmnet_ipa3_ctx->num_q6_rules = 0;
 		IPAWANERR("got no UL rules from modem\n");
+		mutex_unlock(&rmnet_ipa3_ctx->
+					add_mux_channel_lock);
 		return -EINVAL;
 	}
 
@@ -633,9 +640,13 @@
 	rmnet_ipa3_ctx->num_q6_rules = 0;
 	memset(ipa3_qmi_ctx->q6_ul_filter_rule, 0,
 		sizeof(ipa3_qmi_ctx->q6_ul_filter_rule));
+	mutex_unlock(&rmnet_ipa3_ctx->
+		add_mux_channel_lock);
 	return -EINVAL;
 
 success:
+	mutex_unlock(&rmnet_ipa3_ctx->
+		add_mux_channel_lock);
 	return 0;
 }
 
@@ -1086,7 +1097,6 @@
 	int ret = 0;
 	bool qmap_check;
 	struct ipa3_wwan_private *wwan_ptr = netdev_priv(dev);
-	struct ipa_tx_meta meta;
 
 	if (skb->protocol != htons(ETH_P_MAP)) {
 		IPAWANDBG_LOW
@@ -1127,8 +1137,14 @@
 
 send:
 	/* IPA_RM checking start */
-	ret = ipa_rm_inactivity_timer_request_resource(
-		IPA_RM_RESOURCE_WWAN_0_PROD);
+	if (ipa3_ctx->use_ipa_pm) {
+		/* activate the modem pm for clock scaling */
+		ipa_pm_activate(rmnet_ipa3_ctx->q6_pm_hdl);
+		ret = ipa_pm_activate(rmnet_ipa3_ctx->pm_hdl);
+	} else {
+		ret = ipa_rm_inactivity_timer_request_resource(
+			IPA_RM_RESOURCE_WWAN_0_PROD);
+	}
 	if (ret == -EINPROGRESS) {
 		netif_stop_queue(dev);
 		return NETDEV_TX_BUSY;
@@ -1142,17 +1158,11 @@
 	}
 	/* IPA_RM checking end */
 
-	if (RMNET_MAP_GET_CD_BIT(skb)) {
-		memset(&meta, 0, sizeof(meta));
-		meta.pkt_init_dst_ep_valid = true;
-		meta.pkt_init_dst_ep_remote = true;
-		meta.pkt_init_dst_ep =
-			ipa3_get_ep_mapping(IPA_CLIENT_Q6_WAN_CONS);
-		ret = ipa3_tx_dp(IPA_CLIENT_APPS_WAN_PROD, skb, &meta);
-	} else {
-		ret = ipa3_tx_dp(IPA_CLIENT_APPS_WAN_PROD, skb, NULL);
-	}
-
+	/*
+	 * both data packets and command will be routed to
+	 * IPA_CLIENT_Q6_WAN_CONS based on status configuration
+	 */
+	ret = ipa3_tx_dp(IPA_CLIENT_APPS_WAN_PROD, skb, NULL);
 	if (ret) {
 		ret = NETDEV_TX_BUSY;
 		goto out;
@@ -1163,9 +1173,15 @@
 	dev->stats.tx_bytes += skb->len;
 	ret = NETDEV_TX_OK;
 out:
-	if (atomic_read(&wwan_ptr->outstanding_pkts) == 0)
-		ipa_rm_inactivity_timer_release_resource(
-			IPA_RM_RESOURCE_WWAN_0_PROD);
+	if (atomic_read(&wwan_ptr->outstanding_pkts) == 0) {
+		if (ipa3_ctx->use_ipa_pm) {
+			ipa_pm_deferred_deactivate(rmnet_ipa3_ctx->pm_hdl);
+			ipa_pm_deferred_deactivate(rmnet_ipa3_ctx->q6_pm_hdl);
+		} else {
+			ipa_rm_inactivity_timer_release_resource(
+				IPA_RM_RESOURCE_WWAN_0_PROD);
+		}
+	}
 	return ret;
 }
 
@@ -1217,9 +1233,15 @@
 		netif_wake_queue(wwan_ptr->net);
 	}
 
-	if (atomic_read(&wwan_ptr->outstanding_pkts) == 0)
-		ipa_rm_inactivity_timer_release_resource(
+	if (atomic_read(&wwan_ptr->outstanding_pkts) == 0) {
+		if (ipa3_ctx->use_ipa_pm) {
+			ipa_pm_deferred_deactivate(rmnet_ipa3_ctx->pm_hdl);
+			ipa_pm_deferred_deactivate(rmnet_ipa3_ctx->q6_pm_hdl);
+		} else {
+			ipa_rm_inactivity_timer_release_resource(
 			IPA_RM_RESOURCE_WWAN_0_PROD);
+		}
+	}
 	__netif_tx_unlock_bh(netdev_get_tx_queue(dev, 0));
 	dev_kfree_skb_any(skb);
 }
@@ -1373,9 +1395,7 @@
 	}
 
 	if ((e->u.data) & RMNET_IOCTL_EGRESS_FORMAT_AGGREGATION) {
-		IPAWANERR("WAN UL Aggregation not supported!!\n");
-		WARN_ON(1);
-		return -EINVAL;
+		IPAWANDBG("WAN UL Aggregation enabled\n");
 		ipa_wan_ep_cfg->ipa_ep_cfg.aggr.aggr_en = IPA_ENABLE_DEAGGR;
 		ipa_wan_ep_cfg->ipa_ep_cfg.aggr.aggr = IPA_QCMAP;
 
@@ -1429,8 +1449,13 @@
 
 	if (rmnet_ipa3_ctx->num_q6_rules != 0) {
 		/* already got Q6 UL filter rules*/
-		if (ipa3_qmi_ctx->modem_cfg_emb_pipe_flt == false)
+		if (ipa3_qmi_ctx->modem_cfg_emb_pipe_flt == false) {
+			/* prevent multi-threads accessing num_q6_rules */
+			mutex_lock(&rmnet_ipa3_ctx->add_mux_channel_lock);
 			rc = ipa3_wwan_add_ul_flt_rule_to_ipa();
+			mutex_unlock(&rmnet_ipa3_ctx->
+				add_mux_channel_lock);
+		}
 		if (rc)
 			IPAWANERR("install UL rules failed\n");
 		else
@@ -1854,6 +1879,91 @@
 		return;
 	}
 }
+
+int ipa3_wwan_set_modem_state(struct wan_ioctl_notify_wan_state *state)
+{
+	if (!state)
+		return -EINVAL;
+
+	if (!ipa_pm_is_used())
+		return 0;
+
+	if (state->up)
+		return ipa_pm_activate_sync(rmnet_ipa3_ctx->q6_teth_pm_hdl);
+	else
+		return ipa_pm_deactivate_sync(rmnet_ipa3_ctx->q6_teth_pm_hdl);
+}
+
+/**
+ * ipa3_q6_register_pm - Register modem clients for PM
+ *
+ * This function will register 2 client with IPA PM to represent modem
+ * in clock scaling calculation:
+ *	- "EMB MODEM" - this client will be activated with embedded traffic
+	- "TETH MODEM" - this client we be activated by IPACM on offload to
+	  modem.
+*/
+static int ipa3_q6_register_pm(void)
+{
+	int result;
+	struct ipa_pm_register_params pm_reg;
+
+	memset(&pm_reg, 0, sizeof(pm_reg));
+	pm_reg.name = "EMB MODEM";
+	pm_reg.group = IPA_PM_GROUP_MODEM;
+	pm_reg.skip_clk_vote = true;
+	result = ipa_pm_register(&pm_reg, &rmnet_ipa3_ctx->q6_pm_hdl);
+	if (result) {
+		IPAERR("failed to create IPA PM client %d\n", result);
+		return result;
+	}
+
+	pm_reg.name = "TETH MODEM";
+	pm_reg.group = IPA_PM_GROUP_MODEM;
+	pm_reg.skip_clk_vote = true;
+	result = ipa_pm_register(&pm_reg, &rmnet_ipa3_ctx->q6_teth_pm_hdl);
+	if (result) {
+		IPAERR("failed to create IPA PM client %d\n", result);
+		return result;
+	}
+
+	return 0;
+}
+
+static void ipa3_q6_deregister_pm(void)
+{
+	ipa_pm_deactivate_sync(rmnet_ipa3_ctx->q6_pm_hdl);
+	ipa_pm_deregister(rmnet_ipa3_ctx->q6_pm_hdl);
+}
+
+int ipa3_wwan_set_modem_perf_profile(int throughput)
+{
+	struct ipa_rm_perf_profile profile;
+	int ret;
+
+	ret = ipa_pm_set_perf_profile(rmnet_ipa3_ctx->q6_pm_hdl, throughput);
+	if (ret)
+		return ret;
+	return ipa_pm_set_perf_profile(rmnet_ipa3_ctx->q6_teth_pm_hdl,
+		throughput);
+
+	if (ipa3_ctx->use_ipa_pm) {
+		ret = ipa_pm_set_perf_profile(rmnet_ipa3_ctx->q6_pm_hdl,
+			throughput);
+		if (ret)
+			return ret;
+		ret = ipa_pm_set_perf_profile(rmnet_ipa3_ctx->q6_teth_pm_hdl,
+			throughput);
+	} else {
+		memset(&profile, 0, sizeof(profile));
+		profile.max_supported_bandwidth_mbps = throughput;
+		ret = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_Q6_PROD,
+			&profile);
+	}
+
+	return ret;
+}
+
 static int ipa3_q6_initialize_rm(void)
 {
 	struct ipa_rm_create_params create_params;
@@ -2071,6 +2181,120 @@
 	schedule_work(&ipa3_scheduled_probe);
 }
 
+static void ipa_pm_wwan_pm_cb(void *p, enum ipa_pm_cb_event event)
+{
+	struct net_device *dev = (struct net_device *)p;
+	struct ipa3_wwan_private *wwan_ptr = netdev_priv(dev);
+
+	IPAWANDBG_LOW("event %d\n", event);
+	switch (event) {
+	case IPA_PM_CLIENT_ACTIVATED:
+		if (wwan_ptr->device_status == WWAN_DEVICE_INACTIVE) {
+			complete_all(&wwan_ptr->resource_granted_completion);
+			break;
+		}
+		ipa3_rm_resource_granted(dev);
+		break;
+	default:
+		pr_err("%s: unknown event %d\n", __func__, event);
+		break;
+	}
+}
+
+static int ipa3_wwan_register_netdev_pm_client(struct net_device *dev)
+{
+	int result;
+	struct ipa_pm_register_params pm_reg;
+
+	memset(&pm_reg, 0, sizeof(pm_reg));
+	pm_reg.name = IPA_NETDEV()->name;
+	pm_reg.user_data = dev;
+	pm_reg.callback = ipa_pm_wwan_pm_cb;
+	pm_reg.group = IPA_PM_GROUP_APPS;
+	result = ipa_pm_register(&pm_reg, &rmnet_ipa3_ctx->pm_hdl);
+	if (result) {
+		IPAERR("failed to create IPA PM client %d\n", result);
+			return result;
+	}
+	return 0;
+}
+
+static void ipa3_wwan_deregister_netdev_pm_client(void)
+{
+	ipa_pm_deactivate_sync(rmnet_ipa3_ctx->pm_hdl);
+	ipa_pm_deregister(rmnet_ipa3_ctx->pm_hdl);
+}
+
+static int ipa3_wwan_create_wwan_rm_resource(struct net_device *dev)
+{
+	struct ipa_rm_create_params ipa_rm_params;
+	struct ipa_rm_perf_profile profile;
+	int ret;
+
+	memset(&ipa_rm_params, 0, sizeof(struct ipa_rm_create_params));
+	ipa_rm_params.name = IPA_RM_RESOURCE_WWAN_0_PROD;
+	ipa_rm_params.reg_params.user_data = dev;
+	ipa_rm_params.reg_params.notify_cb = ipa3_rm_notify;
+	ret = ipa_rm_create_resource(&ipa_rm_params);
+	if (ret) {
+		pr_err("%s: unable to create resourse %d in IPA RM\n",
+			__func__, IPA_RM_RESOURCE_WWAN_0_PROD);
+		return ret;
+	}
+	ret = ipa_rm_inactivity_timer_init(IPA_RM_RESOURCE_WWAN_0_PROD,
+		IPA_RM_INACTIVITY_TIMER);
+	if (ret) {
+		pr_err("%s: ipa rm timer init failed %d on resourse %d\n",
+			__func__, ret, IPA_RM_RESOURCE_WWAN_0_PROD);
+		goto timer_init_err;
+	}
+	/* add dependency */
+	ret = ipa_rm_add_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
+		IPA_RM_RESOURCE_Q6_CONS);
+	if (ret)
+		goto add_dpnd_err;
+	/* setup Performance profile */
+	memset(&profile, 0, sizeof(profile));
+	profile.max_supported_bandwidth_mbps = IPA_APPS_MAX_BW_IN_MBPS;
+	ret = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_WWAN_0_PROD,
+		&profile);
+	if (ret)
+		goto set_perf_err;
+
+	return 0;
+
+set_perf_err:
+	ipa_rm_delete_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
+		IPA_RM_RESOURCE_Q6_CONS);
+add_dpnd_err:
+	ipa_rm_inactivity_timer_destroy(
+		IPA_RM_RESOURCE_WWAN_0_PROD); /* IPA_RM */
+timer_init_err:
+	ipa_rm_delete_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
+	return ret;
+}
+
+static void ipa3_wwan_delete_wwan_rm_resource(void)
+{
+	int ret;
+
+	ret = ipa_rm_delete_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
+		IPA_RM_RESOURCE_Q6_CONS);
+	if (ret < 0)
+		IPAWANERR("Error deleting dependency %d->%d, ret=%d\n",
+		IPA_RM_RESOURCE_WWAN_0_PROD, IPA_RM_RESOURCE_Q6_CONS,
+		ret);
+	ret = ipa_rm_inactivity_timer_destroy(IPA_RM_RESOURCE_WWAN_0_PROD);
+	if (ret < 0)
+		IPAWANERR(
+		"Error ipa_rm_inactivity_timer_destroy resource %d, ret=%d\n",
+		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
+	ret = ipa_rm_delete_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
+	if (ret < 0)
+		IPAWANERR("Error deleting resource %d, ret=%d\n",
+		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
+}
+
 /**
  * ipa3_wwan_probe() - Initialized the module and registers as a
  * network interface to the network stack
@@ -2088,8 +2312,6 @@
 {
 	int ret, i;
 	struct net_device *dev;
-	struct ipa_rm_create_params ipa_rm_params;	/* IPA_RM */
-	struct ipa_rm_perf_profile profile;			/* IPA_RM */
 
 	pr_info("rmnet_ipa3 started initialization\n");
 
@@ -2183,7 +2405,10 @@
 
 	if (!atomic_read(&rmnet_ipa3_ctx->is_ssr)) {
 		/* IPA_RM configuration starts */
-		ret = ipa3_q6_initialize_rm();
+		if (ipa3_ctx->use_ipa_pm)
+			ret = ipa3_q6_register_pm();
+		else
+			ret = ipa3_q6_initialize_rm();
 		if (ret) {
 			IPAWANERR("%s: ipa3_q6_initialize_rm failed, ret: %d\n",
 				__func__, ret);
@@ -2191,36 +2416,14 @@
 		}
 	}
 
-	memset(&ipa_rm_params, 0, sizeof(struct ipa_rm_create_params));
-	ipa_rm_params.name = IPA_RM_RESOURCE_WWAN_0_PROD;
-	ipa_rm_params.reg_params.user_data = dev;
-	ipa_rm_params.reg_params.notify_cb = ipa3_rm_notify;
-	ret = ipa_rm_create_resource(&ipa_rm_params);
+	if (ipa3_ctx->use_ipa_pm)
+		ret = ipa3_wwan_register_netdev_pm_client(dev);
+	else
+		ret = ipa3_wwan_create_wwan_rm_resource(dev);
 	if (ret) {
-		pr_err("%s: unable to create resourse %d in IPA RM\n",
-		       __func__, IPA_RM_RESOURCE_WWAN_0_PROD);
-		goto create_rsrc_err;
+		IPAWANERR("fail to create/register pm resources\n");
+		goto fail_pm;
 	}
-	ret = ipa_rm_inactivity_timer_init(IPA_RM_RESOURCE_WWAN_0_PROD,
-					   IPA_RM_INACTIVITY_TIMER);
-	if (ret) {
-		pr_err("%s: ipa rm timer init failed %d on resourse %d\n",
-		       __func__, ret, IPA_RM_RESOURCE_WWAN_0_PROD);
-		goto timer_init_err;
-	}
-	/* add dependency */
-	ret = ipa_rm_add_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
-			IPA_RM_RESOURCE_Q6_CONS);
-	if (ret)
-		goto add_dpnd_err;
-	/* setup Performance profile */
-	memset(&profile, 0, sizeof(profile));
-	profile.max_supported_bandwidth_mbps = IPA_APPS_MAX_BW_IN_MBPS;
-	ret = ipa_rm_set_perf_profile(IPA_RM_RESOURCE_WWAN_0_PROD,
-			&profile);
-	if (ret)
-		goto set_perf_err;
-	/* IPA_RM configuration ends */
 
 	/* Enable SG support in netdevice. */
 	if (ipa3_rmnet_res.ipa_advertise_sg_support)
@@ -2256,28 +2459,18 @@
 		netif_napi_del(&(rmnet_ipa3_ctx->wwan_priv->napi));
 	unregister_netdev(dev);
 set_perf_err:
-	ret = ipa_rm_delete_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
-		IPA_RM_RESOURCE_Q6_CONS);
-	if (ret)
-		IPAWANERR("Error deleting dependency %d->%d, ret=%d\n",
-			IPA_RM_RESOURCE_WWAN_0_PROD, IPA_RM_RESOURCE_Q6_CONS,
-			ret);
-add_dpnd_err:
-	ret = ipa_rm_inactivity_timer_destroy(
-		IPA_RM_RESOURCE_WWAN_0_PROD); /* IPA_RM */
-	if (ret)
-		IPAWANERR("Error ipa_rm_inactivity_timer_destroy %d, ret=%d\n",
-		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
-timer_init_err:
-	ret = ipa_rm_delete_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
-	if (ret)
-		IPAWANERR("Error deleting resource %d, ret=%d\n",
-		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
-create_rsrc_err:
-
-	if (!atomic_read(&rmnet_ipa3_ctx->is_ssr))
-		ipa3_q6_deinitialize_rm();
-
+	if (ipa3_ctx->use_ipa_pm)
+		ipa3_wwan_deregister_netdev_pm_client();
+	else
+		ipa3_wwan_delete_wwan_rm_resource();
+fail_pm:
+	if (ipa3_ctx->use_ipa_pm) {
+		if (!atomic_read(&rmnet_ipa3_ctx->is_ssr))
+			ipa3_q6_deregister_pm();
+	} else {
+		if (!atomic_read(&rmnet_ipa3_ctx->is_ssr))
+			ipa3_q6_deinitialize_rm();
+	}
 q6_init_err:
 	free_netdev(dev);
 	rmnet_ipa3_ctx->wwan_priv = NULL;
@@ -2313,21 +2506,10 @@
 		netif_napi_del(&(rmnet_ipa3_ctx->wwan_priv->napi));
 	mutex_unlock(&rmnet_ipa3_ctx->pipe_handle_guard);
 	unregister_netdev(IPA_NETDEV());
-	ret = ipa_rm_delete_dependency(IPA_RM_RESOURCE_WWAN_0_PROD,
-		IPA_RM_RESOURCE_Q6_CONS);
-	if (ret < 0)
-		IPAWANERR("Error deleting dependency %d->%d, ret=%d\n",
-			IPA_RM_RESOURCE_WWAN_0_PROD, IPA_RM_RESOURCE_Q6_CONS,
-			ret);
-	ret = ipa_rm_inactivity_timer_destroy(IPA_RM_RESOURCE_WWAN_0_PROD);
-	if (ret < 0)
-		IPAWANERR(
-		"Error ipa_rm_inactivity_timer_destroy resource %d, ret=%d\n",
-		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
-	ret = ipa_rm_delete_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
-	if (ret < 0)
-		IPAWANERR("Error deleting resource %d, ret=%d\n",
-		IPA_RM_RESOURCE_WWAN_0_PROD, ret);
+	if (ipa3_ctx->use_ipa_pm)
+		ipa3_wwan_deregister_netdev_pm_client();
+	else
+		ipa3_wwan_delete_wwan_rm_resource();
 	cancel_work_sync(&ipa3_tx_wakequeue_work);
 	cancel_delayed_work(&ipa_tether_stats_poll_wakequeue_work);
 	if (IPA_NETDEV())
@@ -2381,23 +2563,26 @@
 	if (wwan_ptr == NULL) {
 		IPAWANERR("wwan_ptr is NULL.\n");
 		ret = 0;
-		goto unlock_and_bail;
+		netif_tx_unlock_bh(netdev);
+		goto bail;
 	}
 
 	/* Do not allow A7 to suspend in case there are oustanding packets */
 	if (atomic_read(&wwan_ptr->outstanding_pkts) != 0) {
 		IPAWANDBG("Outstanding packets, postponing AP suspend.\n");
 		ret = -EAGAIN;
-		goto unlock_and_bail;
+		netif_tx_unlock_bh(netdev);
+		goto bail;
 	}
 
 	/* Make sure that there is no Tx operation ongoing */
 	netif_stop_queue(netdev);
-	ipa_rm_release_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
-	ret = 0;
-
-unlock_and_bail:
 	netif_tx_unlock_bh(netdev);
+	if (ipa3_ctx->use_ipa_pm)
+		ipa_pm_deactivate_sync(rmnet_ipa3_ctx->pm_hdl);
+	else
+		ipa_rm_release_resource(IPA_RM_RESOURCE_WWAN_0_PROD);
+	ret = 0;
 bail:
 	IPAWANDBG("Exit with %d\n", ret);
 	return ret;
diff --git a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa_fd_ioctl.c b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa_fd_ioctl.c
index c7a6186..2e43abf 100644
--- a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa_fd_ioctl.c
+++ b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa_fd_ioctl.c
@@ -50,6 +50,9 @@
 #define WAN_IOC_QUERY_TETHER_STATS_ALL32 _IOWR(WAN_IOC_MAGIC, \
 		WAN_IOCTL_QUERY_TETHER_STATS_ALL, \
 		compat_uptr_t)
+#define WAN_IOC_NOTIFY_WAN_STATE32 _IOWR(WAN_IOC_MAGIC, \
+		WAN_IOCTL_NOTIFY_WAN_STATE, \
+		compat_uptr_t)
 #endif
 
 static unsigned int dev_num = 1;
@@ -316,6 +319,27 @@
 		}
 		break;
 
+	case WAN_IOC_NOTIFY_WAN_STATE:
+		IPAWANDBG_LOW("device %s got WAN_IOC_NOTIFY_WAN_STATE :>>>\n",
+			DRIVER_NAME);
+		pyld_sz = sizeof(struct wan_ioctl_notify_wan_state);
+		param = kzalloc(pyld_sz, GFP_KERNEL);
+		if (!param) {
+			retval = -ENOMEM;
+			break;
+		}
+		if (copy_from_user(param, (u8 __user *)arg, pyld_sz)) {
+			retval = -EFAULT;
+			break;
+		}
+
+		if (ipa3_wwan_set_modem_state(
+			(struct wan_ioctl_notify_wan_state *)param)) {
+			IPAWANERR("WAN_IOC_NOTIFY_WAN_STATE failed\n");
+			retval = -EFAULT;
+			break;
+		}
+		break;
 	default:
 		retval = -ENOTTY;
 	}
diff --git a/drivers/platform/msm/ipa/ipa_v3/teth_bridge.c b/drivers/platform/msm/ipa/ipa_v3/teth_bridge.c
index 297f932..7496f28 100644
--- a/drivers/platform/msm/ipa/ipa_v3/teth_bridge.c
+++ b/drivers/platform/msm/ipa/ipa_v3/teth_bridge.c
@@ -50,6 +50,7 @@
 	dev_t dev_num;
 	struct device *dev;
 	struct cdev cdev;
+	u32 modem_pm_hdl;
 };
 static struct ipa3_teth_bridge_ctx *ipa3_teth_ctx;
 
@@ -118,14 +119,25 @@
 */
 int ipa3_teth_bridge_disconnect(enum ipa_client_type client)
 {
+	int res = 0;
+
 	TETH_DBG_FUNC_ENTRY();
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_USB_PROD,
-				 IPA_RM_RESOURCE_Q6_CONS);
-	ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
-				 IPA_RM_RESOURCE_USB_CONS);
+	if (ipa_pm_is_used()) {
+		res = ipa_pm_deactivate_sync(ipa3_teth_ctx->modem_pm_hdl);
+		if (res) {
+			TETH_ERR("fail to deactivate modem %d\n", res);
+			return res;
+		}
+		res = ipa_pm_destroy();
+	} else {
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_USB_PROD,
+					IPA_RM_RESOURCE_Q6_CONS);
+		ipa_rm_delete_dependency(IPA_RM_RESOURCE_Q6_PROD,
+					IPA_RM_RESOURCE_USB_CONS);
+	}
 	TETH_DBG_FUNC_EXIT();
 
-	return 0;
+	return res;
 }
 
 /**
@@ -140,9 +152,27 @@
 int ipa3_teth_bridge_connect(struct teth_bridge_connect_params *connect_params)
 {
 	int res = 0;
+	struct ipa_pm_register_params reg_params;
+
+	memset(&reg_params, 0, sizeof(reg_params));
 
 	TETH_DBG_FUNC_ENTRY();
 
+	if (ipa_pm_is_used()) {
+		reg_params.name = "MODEM (USB RMNET)";
+		reg_params.group = IPA_PM_GROUP_MODEM;
+		reg_params.skip_clk_vote = true;
+		res = ipa_pm_register(&reg_params,
+			&ipa3_teth_ctx->modem_pm_hdl);
+		if (res) {
+			TETH_ERR("fail to register with PM %d\n", res);
+			return res;
+		}
+
+		res = ipa_pm_activate_sync(ipa3_teth_ctx->modem_pm_hdl);
+		goto bail;
+	}
+
 	/* Build the dependency graph, first add_dependency call is sync
 	 * in order to make sure the IPA clocks are up before we continue
 	 * and notify the USB driver it may continue.
@@ -234,6 +264,8 @@
 		res = -ENODEV;
 		goto fail_cdev_add;
 	}
+
+	ipa3_teth_ctx->modem_pm_hdl = ~0;
 	TETH_DBG("Tethering bridge driver init OK\n");
 
 	return 0;
diff --git a/drivers/platform/msm/ipa/test/Makefile b/drivers/platform/msm/ipa/test/Makefile
index af46bf2..82bee5d 100644
--- a/drivers/platform/msm/ipa/test/Makefile
+++ b/drivers/platform/msm/ipa/test/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_IPA_UT) += ipa_ut_mod.o
-ipa_ut_mod-y := ipa_ut_framework.o ipa_test_example.o ipa_test_mhi.o ipa_test_dma.o ipa_test_hw_stats.o
+ipa_ut_mod-y := ipa_ut_framework.o ipa_test_example.o ipa_test_mhi.o ipa_test_dma.o ipa_test_hw_stats.o ipa_pm_ut.o
diff --git a/drivers/platform/msm/ipa/test/ipa_pm_ut.c b/drivers/platform/msm/ipa/test/ipa_pm_ut.c
new file mode 100644
index 0000000..e07040a
--- /dev/null
+++ b/drivers/platform/msm/ipa/test/ipa_pm_ut.c
@@ -0,0 +1,1758 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/ipa.h>
+#include "../ipa_v3/ipa_pm.h"
+#include "../ipa_v3/ipa_i.h"
+#include "ipa_ut_framework.h"
+#include <linux/delay.h>
+
+struct callback_param {
+	struct completion complete;
+	enum ipa_pm_cb_event evt;
+};
+
+static int ipa_pm_ut_setup(void **ppriv)
+{
+
+	IPA_UT_DBG("Start Setup\n");
+
+	/* decrement UT vote */
+	IPA_ACTIVE_CLIENTS_DEC_SPECIAL("IPA_UT");
+
+	return 0;
+}
+
+static int ipa_pm_ut_teardown(void *priv)
+{
+	IPA_UT_DBG("Start Teardown\n");
+
+	/* undo UT vote */
+	IPA_ACTIVE_CLIENTS_INC_SPECIAL("IPA_UT");
+	return 0;
+}
+
+/* pass completion struct as the user data/callback params */
+static void ipa_pm_call_back(void *user_data, enum ipa_pm_cb_event evt)
+{
+	struct callback_param *param;
+
+	param = (struct callback_param *) user_data;
+	param->evt = evt;
+
+	if (evt == IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_DBG("Activate callback called\n");
+		complete_all(&param->complete);
+	} else if (evt == IPA_PM_REQUEST_WAKEUP) {
+		IPA_UT_DBG("Request Wakeup callback called\n");
+		complete_all(&param->complete);
+	} else
+		IPA_UT_ERR("invalid callback - callback #%d\n", evt);
+}
+
+static int clean_up(int n, ...)
+{
+	va_list args;
+	int i, hdl, rc = 0;
+
+	va_start(args, n);
+
+	IPA_UT_DBG("n = %d\n", n);
+
+	IPA_UT_DBG("Clean up Started");
+
+	for (i = 0; i < n; i++) {
+		hdl = va_arg(args, int);
+
+		rc = ipa_pm_deactivate_sync(hdl);
+		if (rc) {
+			IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
+			IPA_UT_TEST_FAIL_REPORT("deactivate failed");
+			return -EFAULT;
+		}
+		rc = ipa_pm_deregister(hdl);
+		if (rc) {
+			IPA_UT_ERR("fail to deregister client - rc = %d\n", rc);
+			IPA_UT_TEST_FAIL_REPORT("deregister failed");
+			return -EFAULT;
+		}
+	}
+	va_end(args);
+	rc = ipa_pm_destroy();
+	if (rc) {
+		IPA_UT_ERR("fail to destroy pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("destroy failed");
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+
+/* test 1.1 */
+static int ipa_pm_ut_single_registration(void *priv)
+{
+	int rc = 0;
+	int hdl, vote;
+	struct callback_param user_data;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params register_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+	user_data.evt = IPA_PM_CB_EVENT_MAX;
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&register_params, &hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to register client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deregister(hdl);
+	if (rc == 0) {
+		IPA_UT_ERR("deregister was not unsuccesful - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deregister was not unsuccesful");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deferred deactivate client - rc = %d\n"
+			, rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to deferred deactivate client");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 0) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deregister(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deregister client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to deregister client");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc == 0) {
+		IPA_UT_ERR("activate was not unsuccesful- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate was not unsuccesful");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_destroy();
+	if (rc) {
+		IPA_UT_ERR("terminate failed - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("terminate_failed");
+	}
+
+	return 0;
+}
+
+/* test 1.1 */
+static int ipa_pm_ut_double_register_activate(void *priv)
+{
+	int rc = 0;
+	int hdl, hdl_test, vote;
+	struct callback_param user_data;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params register_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+	user_data.evt = IPA_PM_CB_EVENT_MAX;
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&register_params, &hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to register client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&register_params, &hdl_test);
+	if (rc != -EEXIST) {
+		IPA_UT_ERR("registered client with same name rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("did not to fail register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to do nothing - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("do nothing failed");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to do nothing on 2nd activate = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to not reactivate");
+		return -EFAULT;
+	}
+
+	msleep(200);
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deactivate_sync(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to deactivate client");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 0) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = clean_up(1, hdl);
+	return rc;
+}
+
+/* test 2 */
+static int ipa_pm_ut_deferred_deactivate(void *priv)
+{
+	int rc = 0;
+	int hdl, vote;
+	struct callback_param user_data;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params register_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+	user_data.evt = IPA_PM_CB_EVENT_MAX;
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&register_params, &hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to register client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client - rc = %d\n",
+		rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to reactivate client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("reactivate client failed");
+		return -EFAULT;
+	}
+
+	msleep(200);
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deactivate_sync(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate_sync client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deactivate sync failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = clean_up(1, hdl);
+	return rc;
+}
+
+
+/*test 3*/
+static int ipa_pm_ut_two_clients_activate(void *priv)
+{
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, vote;
+	u32 pipes;
+	struct callback_param user_data_USB;
+	struct callback_param user_data_WLAN;
+
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data_USB
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data_WLAN
+	};
+	user_data_USB.evt = IPA_PM_CB_EVENT_MAX;
+	user_data_WLAN.evt = IPA_PM_CB_EVENT_MAX;
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data_USB.complete);
+	init_completion(&user_data_WLAN.complete);
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_associate_ipa_cons_to_client(hdl_USB, IPA_CLIENT_USB_CONS);
+	if (rc) {
+		IPA_UT_ERR("fail to map client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to map client");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_associate_ipa_cons_to_client(hdl_WLAN,
+		IPA_CLIENT_WLAN1_CONS);
+	if (rc) {
+		IPA_UT_ERR("fail to map client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to map client");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_associate_ipa_cons_to_client(hdl_WLAN,
+		IPA_CLIENT_WLAN2_CONS);
+	if (rc) {
+		IPA_UT_ERR("fail to map client 2 to multiplt pipes rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to map client");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_USB);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work for client 1 - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work for client 2 - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data_USB.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback 1\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data_USB.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data_WLAN.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback 2\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data_WLAN.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data_WLAN.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	reinit_completion(&user_data_USB.complete);
+	reinit_completion(&user_data_WLAN.complete);
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client 1 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	msleep(200);
+
+	rc = ipa_pm_activate(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("no-block activate failed - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("no-block activate fail");
+		return -EFAULT;
+	}
+
+	pipes = 1 << ipa_get_ep_mapping(IPA_CLIENT_USB_CONS);
+	pipes |= 1 << ipa_get_ep_mapping(IPA_CLIENT_WLAN1_CONS);
+	pipes |= 1 << ipa_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
+
+	IPA_UT_DBG("pipes = %d\n", pipes);
+
+	rc = ipa_pm_handle_suspend(pipes);
+
+	if (!wait_for_completion_timeout(&user_data_USB.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for wakeup_callback 1\n");
+		IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
+		return -ETIME;
+	}
+
+	if (user_data_USB.evt != IPA_PM_REQUEST_WAKEUP) {
+		IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data_WLAN.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for wakeup_callback 2\n");
+		IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
+		return -ETIME;
+	}
+
+	if (user_data_WLAN.evt != IPA_PM_REQUEST_WAKEUP) {
+		IPA_UT_ERR("Callback = %d\n", user_data_WLAN.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	reinit_completion(&user_data_USB.complete);
+
+	rc = ipa_pm_deactivate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate_sync client 1 - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to deactivate_sync");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("no-block activate failed - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("no-block activate fail");
+		return -EFAULT;
+	}
+
+	pipes = 1 << ipa_get_ep_mapping(IPA_CLIENT_USB_CONS);
+
+	rc = ipa_pm_handle_suspend(pipes);
+
+	if (!wait_for_completion_timeout(&user_data_USB.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for wakeup_callback 1\n");
+		IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
+		return -ETIME;
+	}
+
+	if (user_data_USB.evt != IPA_PM_REQUEST_WAKEUP) {
+		IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	rc = clean_up(2, hdl_USB, hdl_WLAN);
+	return rc;
+}
+
+/* test 4 */
+static int ipa_pm_ut_deactivate_all_deferred(void *priv)
+{
+
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, hdl_MODEM, vote;
+	struct callback_param user_data;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params MODEM_params = {
+		.name = "MODEM",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+	user_data.evt = IPA_PM_CB_EVENT_MAX;
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rce %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_USB);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work for client 1 - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 2- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	if (!wait_for_completion_timeout(&user_data.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback 1\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to no-block activate - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("no-block-activate failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 3) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client 1 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_deactivate_all_deferred();
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("deactivate_all_deferred failed");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("clock vote went below 1");
+		return -EINVAL;
+	}
+
+	rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
+	return rc;
+}
+
+/* test 5 */
+static int ipa_pm_ut_deactivate_after_activate(void *priv)
+{
+
+	int rc = 0;
+	int hdl, vote;
+	struct callback_param user_data;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rce %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&USB_params, &hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work for client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client - rc = %d\n",
+		rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	msleep(200);
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work for client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_deactivate_sync(hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate sync client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deactivate sync fail");
+		return -EFAULT;
+	}
+
+	msleep(200);
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = clean_up(1, hdl);
+	return rc;
+}
+
+/* test 6 */
+static int ipa_pm_ut_atomic_activate(void *priv)
+{
+	int rc = 0;
+	int hdl, vote;
+	struct callback_param user_data;
+	spinlock_t lock;
+	unsigned long flags;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params register_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+		.user_data = &user_data
+	};
+	user_data.evt = IPA_PM_CB_EVENT_MAX;
+
+
+	spin_lock_init(&lock);
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	init_completion(&user_data.complete);
+
+	rc = ipa_pm_register(&register_params, &hdl);
+	if (rc) {
+		IPA_UT_ERR("fail to register client rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	spin_lock_irqsave(&lock, flags);
+	rc = ipa_pm_activate(hdl);
+	if (rc != -EINPROGRESS) {
+		IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
+		spin_unlock_irqrestore(&lock, flags);
+		return -EFAULT;
+	}
+	spin_unlock_irqrestore(&lock, flags);
+
+	if (!wait_for_completion_timeout(&user_data.complete, HZ)) {
+		IPA_UT_ERR("timeout waiting for activate_callback\n");
+		IPA_UT_TEST_FAIL_REPORT("activate callback not called");
+		return -ETIME;
+	}
+
+	if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
+		IPA_UT_ERR("Callback = %d\n", user_data.evt);
+		IPA_UT_TEST_FAIL_REPORT("wrong callback called");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = clean_up(1, hdl);
+	return rc;
+}
+
+/* test 7 */
+static int ipa_pm_ut_deactivate_loop(void *priv)
+{
+	int rc = 0;
+	int i, hdl_USB, hdl_WLAN, vote;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_USB, 1200);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 800);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	msleep(200);
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deferred_deactivate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to deffered deactivate client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+		return -EFAULT;
+	}
+
+	for (i = 0; i < 50; i++) {
+		IPA_UT_DBG("Loop iteration #%d\n", i);
+
+		vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+		if (vote != 2) {
+			IPA_UT_ERR("clock vote is at %d\n", vote);
+			IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+			return -EINVAL;
+		}
+
+		rc = ipa_pm_activate(hdl_WLAN);
+		if (rc) {
+			IPA_UT_ERR("fail to undo deactivate for client 2");
+			IPA_UT_ERR(" - rc = %d\n", rc);
+			IPA_UT_TEST_FAIL_REPORT("undo deactivate failed");
+			return -EFAULT;
+		}
+
+		rc = ipa_pm_deferred_deactivate(hdl_WLAN);
+		if (rc) {
+			IPA_UT_ERR("fail to deffered deactivate client");
+			IPA_UT_ERR(" - rc = %d\n", rc);
+			IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
+			return -EFAULT;
+		}
+	}
+
+	msleep(200);
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+	rc = clean_up(2, hdl_USB, hdl_WLAN);
+	return rc;
+
+}
+
+
+/*test 8*/
+static int ipa_pm_ut_set_perf_profile(void *priv)
+{
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, vote, idx;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_USB, 1200);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 800);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 1) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 1200);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 3) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = clean_up(2, hdl_USB, hdl_WLAN);
+	return rc;
+}
+
+/*test 9*/
+static int ipa_pm_ut_group_tput(void *priv)
+{
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_APPS,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_APPS,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params MODEM_params = {
+		.name = "MODEM",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_USB, 500);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 800);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 1) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 1) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_MODEM, 1000);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 3) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deactivate_sync(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deactivate failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
+	return rc;
+
+}
+
+/*test 10*/
+static int ipa_pm_ut_skip_clk_vote_tput(void *priv)
+{
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000}
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_MODEM,
+		.skip_clk_vote = 1,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params MODEM_params = {
+		.name = "MODEM",
+		.group = IPA_PM_GROUP_MODEM,
+		.skip_clk_vote = 1,
+		.callback = ipa_pm_call_back,
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_USB, 1200);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 800);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 1) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_MODEM, 2000);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 1) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 3) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+
+	rc = ipa_pm_deactivate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deactivate failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 0) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
+	return rc;
+}
+
+/* Test 11 */
+static int ipa_pm_ut_simple_exception(void *priv)
+{
+	int rc = 0;
+	int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
+
+	struct ipa_pm_exception exceptions = {
+		.usecase = "USB",
+		.threshold = {1000, 1800},
+	};
+
+	struct ipa_pm_init_params init_params = {
+		.threshold_size = IPA_PM_THRESHOLD_MAX,
+		.default_threshold = {600, 1000},
+		.exception_size = 1,
+		.exceptions[0] = exceptions,
+	};
+
+	struct ipa_pm_register_params USB_params = {
+		.name = "USB",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params WLAN_params = {
+		.name = "WLAN",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	struct ipa_pm_register_params MODEM_params = {
+		.name = "MODEM",
+		.group = IPA_PM_GROUP_DEFAULT,
+		.skip_clk_vote = 0,
+		.callback = ipa_pm_call_back,
+	};
+
+	rc = ipa_pm_init(&init_params);
+	if (rc) {
+		IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to init params");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&USB_params, &hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_USB, 1200);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_WLAN, 2000);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("activate sync failed");
+		return -EFAULT;
+	}
+
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 1) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_activate(hdl_WLAN);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to register");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_set_perf_profile(hdl_MODEM, 800);
+	if (rc) {
+		IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
+		return -EFAULT;
+	}
+
+	rc = ipa_pm_activate(hdl_MODEM);
+	if (rc) {
+		IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
+			rc);
+		IPA_UT_TEST_FAIL_REPORT("activate no block failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 3) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	msleep(200);
+	idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 3) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = ipa_pm_deactivate_sync(hdl_USB);
+	if (rc) {
+		IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
+		IPA_UT_TEST_FAIL_REPORT("deactivate failed");
+		return -EFAULT;
+	}
+
+	vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
+	if (vote != 2) {
+		IPA_UT_ERR("clock vote is at %d\n", vote);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
+		return -EINVAL;
+	}
+
+	 idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
+	if (idx != 2) {
+		IPA_UT_ERR("clock plan is at %d\n", idx);
+		IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
+		return -EINVAL;
+	}
+
+	rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
+	return rc;
+}
+
+/* Suite definition block */
+IPA_UT_DEFINE_SUITE_START(pm, "PM for IPA",
+	ipa_pm_ut_setup, ipa_pm_ut_teardown)
+{
+	IPA_UT_ADD_TEST(single_registration,
+		"Single Registration/Basic Functions",
+		ipa_pm_ut_single_registration,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(double_register_activate,
+		"double register/activate",
+		ipa_pm_ut_double_register_activate,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(deferred_deactivate,
+		"Deferred_deactivate",
+		ipa_pm_ut_deferred_deactivate,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(two_clients_activate,
+		"Activate two clients",
+		ipa_pm_ut_two_clients_activate,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(deactivate_all_deferred,
+		"Deactivate all deferred",
+		ipa_pm_ut_deactivate_all_deferred,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(deactivate_after_activate,
+		"Deactivate after activate",
+		ipa_pm_ut_deactivate_after_activate,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(atomic_activate,
+		"Atomic activate",
+		ipa_pm_ut_atomic_activate,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(deactivate_loop,
+		"Deactivate Loop",
+		ipa_pm_ut_deactivate_loop,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(set_perf_profile,
+		"Set perf profile",
+		ipa_pm_ut_set_perf_profile,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(group_tput,
+		"Group throughputs",
+		ipa_pm_ut_group_tput,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(skip_clk_vote_tput,
+		"Skip clock vote and tput",
+		ipa_pm_ut_skip_clk_vote_tput,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+	IPA_UT_ADD_TEST(simple_exception,
+		"throughput while passing simple exception",
+		ipa_pm_ut_simple_exception,
+		true, IPA_HW_v4_0, IPA_HW_MAX),
+} IPA_UT_DEFINE_SUITE_END(pm);
diff --git a/drivers/platform/msm/ipa/test/ipa_ut_suite_list.h b/drivers/platform/msm/ipa/test/ipa_ut_suite_list.h
index 823edcf..35f2878 100644
--- a/drivers/platform/msm/ipa/test/ipa_ut_suite_list.h
+++ b/drivers/platform/msm/ipa/test/ipa_ut_suite_list.h
@@ -22,6 +22,7 @@
  */
 IPA_UT_DECLARE_SUITE(mhi);
 IPA_UT_DECLARE_SUITE(dma);
+IPA_UT_DECLARE_SUITE(pm);
 IPA_UT_DECLARE_SUITE(example);
 IPA_UT_DECLARE_SUITE(hw_stats);
 
@@ -34,6 +35,7 @@
 {
 	IPA_UT_REGISTER_SUITE(mhi),
 	IPA_UT_REGISTER_SUITE(dma),
+	IPA_UT_REGISTER_SUITE(pm),
 	IPA_UT_REGISTER_SUITE(example),
 	IPA_UT_REGISTER_SUITE(hw_stats),
 } IPA_UT_DEFINE_ALL_SUITES_END;
diff --git a/drivers/platform/msm/qcom-geni-se.c b/drivers/platform/msm/qcom-geni-se.c
index aafb8fc..707c95e 100644
--- a/drivers/platform/msm/qcom-geni-se.c
+++ b/drivers/platform/msm/qcom-geni-se.c
@@ -1247,6 +1247,79 @@
 }
 EXPORT_SYMBOL(geni_se_iommu_free_buf);
 
+/**
+ * geni_se_dump_dbg_regs() - Print relevant registers that capture most
+ *			accurately the state of an SE.
+ * @_dev:		Pointer to the SE's device.
+ * @iomem:		Base address of the SE's register space.
+ * @ipc:		IPC log context handle.
+ *
+ * This function is used to print out all the registers that capture the state
+ * of an SE to help debug any errors.
+ *
+ * Return:	None
+ */
+void geni_se_dump_dbg_regs(struct se_geni_rsc *rsc, void __iomem *base,
+				void *ipc)
+{
+	u32 m_cmd0 = 0;
+	u32 m_irq_status = 0;
+	u32 geni_status = 0;
+	u32 geni_ios = 0;
+	u32 dma_rx_irq = 0;
+	u32 dma_tx_irq = 0;
+	u32 rx_fifo_status = 0;
+	u32 tx_fifo_status = 0;
+	u32 se_dma_dbg = 0;
+	u32 m_cmd_ctrl = 0;
+	u32 se_dma_rx_len = 0;
+	u32 se_dma_rx_len_in = 0;
+	u32 se_dma_tx_len = 0;
+	u32 se_dma_tx_len_in = 0;
+	struct geni_se_device *geni_se_dev;
+
+	if (!ipc)
+		return;
+
+	geni_se_dev = dev_get_drvdata(rsc->wrapper_dev);
+	if (unlikely(!geni_se_dev || !geni_se_dev->bus_bw))
+		return;
+	mutex_lock(&geni_se_dev->ab_ib_lock);
+	if (unlikely(list_empty(&rsc->ab_list) || list_empty(&rsc->ib_list))) {
+		GENI_SE_DBG(ipc, false, NULL, "%s: Clocks not on\n", __func__);
+		goto exit_geni_se_dump_dbg_regs;
+	}
+	m_cmd0 = geni_read_reg(base, SE_GENI_M_CMD0);
+	m_irq_status = geni_read_reg(base, SE_GENI_M_IRQ_STATUS);
+	geni_status = geni_read_reg(base, SE_GENI_STATUS);
+	geni_ios = geni_read_reg(base, SE_GENI_IOS);
+	dma_rx_irq = geni_read_reg(base, SE_DMA_TX_IRQ_STAT);
+	dma_tx_irq = geni_read_reg(base, SE_DMA_RX_IRQ_STAT);
+	rx_fifo_status = geni_read_reg(base, SE_GENI_RX_FIFO_STATUS);
+	tx_fifo_status = geni_read_reg(base, SE_GENI_TX_FIFO_STATUS);
+	se_dma_dbg = geni_read_reg(base, SE_DMA_DEBUG_REG0);
+	m_cmd_ctrl = geni_read_reg(base, SE_GENI_M_CMD_CTRL_REG);
+	se_dma_rx_len = geni_read_reg(base, SE_DMA_RX_LEN);
+	se_dma_rx_len_in = geni_read_reg(base, SE_DMA_RX_LEN_IN);
+	se_dma_tx_len = geni_read_reg(base, SE_DMA_TX_LEN);
+	se_dma_tx_len_in = geni_read_reg(base, SE_DMA_TX_LEN_IN);
+
+	GENI_SE_DBG(ipc, false, NULL,
+	"%s: m_cmd0:0x%x, m_irq_status:0x%x, geni_status:0x%x, geni_ios:0x%x\n",
+	__func__, m_cmd0, m_irq_status, geni_status, geni_ios);
+	GENI_SE_DBG(ipc, false, NULL,
+	"dma_rx_irq:0x%x, dma_tx_irq:0x%x, rx_fifo_sts:0x%x, tx_fifo_sts:0x%x\n"
+	, dma_rx_irq, dma_tx_irq, rx_fifo_status, tx_fifo_status);
+	GENI_SE_DBG(ipc, false, NULL,
+	"se_dma_dbg:0x%x, m_cmd_ctrl:0x%x, dma_rxlen:0x%x, dma_rxlen_in:0x%x\n",
+	se_dma_dbg, m_cmd_ctrl, se_dma_rx_len, se_dma_rx_len_in);
+	GENI_SE_DBG(ipc, false, NULL,
+	"dma_txlen:0x%x, dma_txlen_in:0x%x\n", se_dma_tx_len, se_dma_tx_len_in);
+exit_geni_se_dump_dbg_regs:
+	mutex_unlock(&geni_se_dev->ab_ib_lock);
+}
+EXPORT_SYMBOL(geni_se_dump_dbg_regs);
+
 static const struct of_device_id geni_se_dt_match[] = {
 	{ .compatible = "qcom,qupv3-geni-se", },
 	{ .compatible = "qcom,qupv3-geni-se-cb", },
diff --git a/drivers/platform/msm/qpnp-revid.c b/drivers/platform/msm/qpnp-revid.c
index 9ea0b40..0fec8ac 100644
--- a/drivers/platform/msm/qpnp-revid.c
+++ b/drivers/platform/msm/qpnp-revid.c
@@ -27,6 +27,7 @@
 #define REVID_SUBTYPE	0x5
 #define REVID_STATUS1	0x8
 #define REVID_SPARE_0	0x60
+#define REVID_TP_REV	0xf1
 #define REVID_FAB_ID	0xf2
 
 #define QPNP_REVID_DEV_NAME "qcom,qpnp-revid"
@@ -157,9 +158,9 @@
 static int qpnp_revid_probe(struct platform_device *pdev)
 {
 	u8 rev1, rev2, rev3, rev4, pmic_type, pmic_subtype, pmic_status;
-	u8 option1, option2, option3, option4, spare0, fab_id;
+	u8 option1, option2, option3, option4, spare0;
 	unsigned int base;
-	int rc;
+	int rc, fab_id, tp_rev;
 	char pmic_string[PMIC_STRING_MAXLENGTH] = {'\0'};
 	struct revid_chip *revid_chip;
 	struct regmap *regmap;
@@ -207,6 +208,11 @@
 	else
 		fab_id = -EINVAL;
 
+	if (of_property_read_bool(pdev->dev.of_node, "qcom,tp-rev-valid"))
+		tp_rev = qpnp_read_byte(regmap, base + REVID_TP_REV);
+	else
+		tp_rev = -EINVAL;
+
 	revid_chip = devm_kzalloc(&pdev->dev, sizeof(struct revid_chip),
 						GFP_KERNEL);
 	if (!revid_chip)
@@ -220,6 +226,7 @@
 	revid_chip->data.pmic_subtype = pmic_subtype;
 	revid_chip->data.pmic_type = pmic_type;
 	revid_chip->data.fab_id = fab_id;
+	revid_chip->data.tp_rev = tp_rev;
 
 	if (pmic_subtype < ARRAY_SIZE(pmic_names))
 		revid_chip->data.pmic_name = pmic_names[pmic_subtype];
diff --git a/drivers/platform/msm/seemp_core/seemp_logk.c b/drivers/platform/msm/seemp_core/seemp_logk.c
index 47208f7..4ffdbc9 100644
--- a/drivers/platform/msm/seemp_core/seemp_logk.c
+++ b/drivers/platform/msm/seemp_core/seemp_logk.c
@@ -346,9 +346,11 @@
 		return seemp_logk_set_mapping(arg);
 	} else if (cmd == SEEMP_CMD_CHECK_FILTER) {
 		return seemp_logk_check_filter(arg);
+	} else {
+		pr_err("Invalid Request %X\n", cmd);
+		return -ENOIOCTLCMD;
 	}
-	pr_err("Invalid Request %X\n", cmd);
-	return -ENOIOCTLCMD;
+	return 0;
 }
 
 static long seemp_logk_reserve_rdblks(
@@ -756,7 +758,7 @@
 		desc.args[1] = PAGE_SIZE;
 		ret = scm_call2(EL2_SCM_ID, &desc);
 		if (ret || desc.ret[0] || desc.ret[1]) {
-			pr_err("SCM call failed with ret val = %d %d %d",
+			pr_err("SCM call failed with ret val = %d %d %d\n",
 				ret, (int)desc.ret[0], (int)desc.ret[1]);
 			free_page((unsigned long) el2_shared_mem);
 			el2_shared_mem = NULL;
diff --git a/drivers/power/reset/msm-poweroff.c b/drivers/power/reset/msm-poweroff.c
index 9f04957..8d023a8 100644
--- a/drivers/power/reset/msm-poweroff.c
+++ b/drivers/power/reset/msm-poweroff.c
@@ -37,6 +37,7 @@
 #define EMERGENCY_DLOAD_MAGIC1    0x322A4F99
 #define EMERGENCY_DLOAD_MAGIC2    0xC67E4350
 #define EMERGENCY_DLOAD_MAGIC3    0x77777777
+#define EMMC_DLOAD_TYPE		0x2
 
 #define SCM_IO_DISABLE_PMIC_ARBITER	1
 #define SCM_IO_DEASSERT_PS_HOLD		2
@@ -47,13 +48,14 @@
 
 
 static int restart_mode;
-void *restart_reason;
+static void __iomem *restart_reason, *dload_type_addr;
 static bool scm_pmic_arbiter_disable_supported;
 static bool scm_deassert_ps_hold_supported;
 /* Download mode master kill-switch */
 static void __iomem *msm_ps_hold;
 static phys_addr_t tcsr_boot_misc_detect;
 static int download_mode = 1;
+static struct kobject dload_kobj;
 
 #ifdef CONFIG_QCOM_DLOAD_MODE
 #define EDL_MODE_PROP "qcom,msm-imem-emergency_download_mode"
@@ -72,8 +74,23 @@
 static bool scm_dload_supported;
 
 static int dload_set(const char *val, struct kernel_param *kp);
+/* interface for exporting attributes */
+struct reset_attribute {
+	struct attribute        attr;
+	ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+			char *buf);
+	size_t (*store)(struct kobject *kobj, struct attribute *attr,
+			const char *buf, size_t count);
+};
+#define to_reset_attr(_attr) \
+	container_of(_attr, struct reset_attribute, attr)
+#define RESET_ATTR(_name, _mode, _show, _store)	\
+	static struct reset_attribute reset_attr_##_name = \
+			__ATTR(_name, _mode, _show, _store)
+
 module_param_call(download_mode, dload_set, param_get_int,
 			&download_mode, 0644);
+
 static int panic_prep_restart(struct notifier_block *this,
 			      unsigned long event, void *ptr)
 {
@@ -85,7 +102,7 @@
 	.notifier_call	= panic_prep_restart,
 };
 
-int scm_set_dload_mode(int arg1, int arg2)
+static int scm_set_dload_mode(int arg1, int arg2)
 {
 	struct scm_desc desc = {
 		.args[0] = arg1,
@@ -397,6 +414,84 @@
 	pr_err("Powering off has failed\n");
 }
 
+static ssize_t attr_show(struct kobject *kobj, struct attribute *attr,
+				char *buf)
+{
+	struct reset_attribute *reset_attr = to_reset_attr(attr);
+	ssize_t ret = -EIO;
+
+	if (reset_attr->show)
+		ret = reset_attr->show(kobj, attr, buf);
+
+	return ret;
+}
+
+static ssize_t attr_store(struct kobject *kobj, struct attribute *attr,
+				const char *buf, size_t count)
+{
+	struct reset_attribute *reset_attr = to_reset_attr(attr);
+	ssize_t ret = -EIO;
+
+	if (reset_attr->store)
+		ret = reset_attr->store(kobj, attr, buf, count);
+
+	return ret;
+}
+
+static const struct sysfs_ops reset_sysfs_ops = {
+	.show	= attr_show,
+	.store	= attr_store,
+};
+
+static struct kobj_type reset_ktype = {
+	.sysfs_ops	= &reset_sysfs_ops,
+};
+
+static ssize_t show_emmc_dload(struct kobject *kobj, struct attribute *attr,
+				char *buf)
+{
+	uint32_t read_val, show_val;
+
+	read_val = __raw_readl(dload_type_addr);
+	if (read_val == EMMC_DLOAD_TYPE)
+		show_val = 1;
+	else
+		show_val = 0;
+
+	return snprintf(buf, sizeof(show_val), "%u\n", show_val);
+}
+
+static size_t store_emmc_dload(struct kobject *kobj, struct attribute *attr,
+				const char *buf, size_t count)
+{
+	uint32_t enabled;
+	int ret;
+
+	ret = kstrtouint(buf, 0, &enabled);
+	if (ret < 0)
+		return ret;
+
+	if (!((enabled == 0) || (enabled == 1)))
+		return -EINVAL;
+
+	if (enabled == 1)
+		__raw_writel(EMMC_DLOAD_TYPE, dload_type_addr);
+	else
+		__raw_writel(0, dload_type_addr);
+
+	return count;
+}
+RESET_ATTR(emmc_dload, 0644, show_emmc_dload, store_emmc_dload);
+
+static struct attribute *reset_attrs[] = {
+	&reset_attr_emmc_dload.attr,
+	NULL
+};
+
+static struct attribute_group reset_attr_group = {
+	.attrs = reset_attrs,
+};
+
 static int msm_restart_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -448,6 +543,33 @@
 		iounmap(kaslr_imem_addr);
 	}
 #endif
+	np = of_find_compatible_node(NULL, NULL,
+				"qcom,msm-imem-dload-type");
+	if (!np) {
+		pr_err("unable to find DT imem dload-type node\n");
+		goto skip_sysfs_create;
+	} else {
+		dload_type_addr = of_iomap(np, 0);
+		if (!dload_type_addr) {
+			pr_err("unable to map imem dload-type offset\n");
+			goto skip_sysfs_create;
+		}
+	}
+
+	ret = kobject_init_and_add(&dload_kobj, &reset_ktype,
+			kernel_kobj, "%s", "dload");
+	if (ret) {
+		pr_err("%s:Error in creation kobject_add\n", __func__);
+		kobject_put(&dload_kobj);
+		goto skip_sysfs_create;
+	}
+
+	ret = sysfs_create_group(&dload_kobj, &reset_attr_group);
+	if (ret) {
+		pr_err("%s:Error in creation sysfs_create_group\n", __func__);
+		kobject_del(&dload_kobj);
+	}
+skip_sysfs_create:
 #endif
 	np = of_find_compatible_node(NULL, NULL,
 				"qcom,msm-imem-restart_reason");
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 431cd24..b929d8b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -261,6 +261,8 @@
 	POWER_SUPPLY_ATTR(low_power),
 	POWER_SUPPLY_ATTR(temp_cool),
 	POWER_SUPPLY_ATTR(temp_warm),
+	POWER_SUPPLY_ATTR(temp_cold),
+	POWER_SUPPLY_ATTR(temp_hot),
 	POWER_SUPPLY_ATTR(system_temp_level),
 	POWER_SUPPLY_ATTR(resistance),
 	POWER_SUPPLY_ATTR(resistance_capacitive),
@@ -314,6 +316,9 @@
 	POWER_SUPPLY_ATTR(cc_step),
 	POWER_SUPPLY_ATTR(cc_step_sel),
 	POWER_SUPPLY_ATTR(sw_jeita_enabled),
+	POWER_SUPPLY_ATTR(pd_voltage_max),
+	POWER_SUPPLY_ATTR(pd_voltage_min),
+	POWER_SUPPLY_ATTR(sdp_current_max),
 	/* Local extensions of type int64_t */
 	POWER_SUPPLY_ATTR(charge_counter_ext),
 	/* Properties of type `const char *' */
diff --git a/drivers/power/supply/qcom/battery.c b/drivers/power/supply/qcom/battery.c
index 7f6d346..7f9a797 100644
--- a/drivers/power/supply/qcom/battery.c
+++ b/drivers/power/supply/qcom/battery.c
@@ -26,12 +26,14 @@
 #include <linux/pm_wakeup.h>
 #include <linux/slab.h>
 #include <linux/pmic-voter.h>
+#include <linux/workqueue.h>
 #include "battery.h"
 
 #define DRV_MAJOR_VERSION	1
 #define DRV_MINOR_VERSION	0
 
 #define CHG_STATE_VOTER			"CHG_STATE_VOTER"
+#define TAPER_STEPPER_VOTER		"TAPER_STEPPER_VOTER"
 #define TAPER_END_VOTER			"TAPER_END_VOTER"
 #define PL_TAPER_EARLY_BAD_VOTER	"PL_TAPER_EARLY_BAD_VOTER"
 #define PARALLEL_PSY_VOTER		"PARALLEL_PSY_VOTER"
@@ -41,12 +43,11 @@
 #define ICL_CHANGE_VOTER		"ICL_CHANGE_VOTER"
 #define PL_INDIRECT_VOTER		"PL_INDIRECT_VOTER"
 #define USBIN_I_VOTER			"USBIN_I_VOTER"
-#define FCC_CHANGE_VOTER		"FCC_CHANGE_VOTER"
+#define PL_FCC_LOW_VOTER		"PL_FCC_LOW_VOTER"
 
 struct pl_data {
 	int			pl_mode;
 	int			slave_pct;
-	int			taper_pct;
 	int			slave_fcc_ua;
 	int			restricted_current;
 	bool			restricted_charging_enabled;
@@ -59,7 +60,8 @@
 	struct votable		*pl_enable_votable_indirect;
 	struct delayed_work	status_change_work;
 	struct work_struct	pl_disable_forever_work;
-	struct delayed_work	pl_taper_work;
+	struct work_struct	pl_taper_work;
+	bool			taper_work_running;
 	struct power_supply	*main_psy;
 	struct power_supply	*pl_psy;
 	struct power_supply	*batt_psy;
@@ -342,67 +344,75 @@
 		*master_ua = max(0, total_ua);
 	else
 		*master_ua = max(0, total_ua - *slave_ua);
-
-	/* further reduce slave's share in accordance with taper reductions */
-	*slave_ua = (*slave_ua * chip->taper_pct) / 100;
 }
 
 #define MINIMUM_PARALLEL_FCC_UA		500000
-#define PL_TAPER_WORK_DELAY_MS		100
+#define PL_TAPER_WORK_DELAY_MS		500
 #define TAPER_RESIDUAL_PCT		90
+#define TAPER_REDUCTION_UA		200000
 static void pl_taper_work(struct work_struct *work)
 {
 	struct pl_data *chip = container_of(work, struct pl_data,
-						pl_taper_work.work);
+						pl_taper_work);
 	union power_supply_propval pval = {0, };
-	int total_fcc_ua, master_fcc_ua, slave_fcc_ua;
 	int rc;
+	int eff_fcc_ua;
+	int total_fcc_ua, master_fcc_ua, slave_fcc_ua = 0;
 
-	/* exit immediately if parallel is disabled */
-	if (get_effective_result(chip->pl_disable_votable)) {
-		pl_dbg(chip, PR_PARALLEL, "terminating parallel not in progress\n");
-		goto done;
+	chip->taper_work_running = true;
+	while (true) {
+		if (get_effective_result(chip->pl_disable_votable)) {
+			/*
+			 * if parallel's FCC share is low, simply disable
+			 * parallel with TAPER_END_VOTER
+			 */
+			total_fcc_ua = get_effective_result_locked(
+					chip->fcc_votable);
+			get_fcc_split(chip, total_fcc_ua, &master_fcc_ua,
+					&slave_fcc_ua);
+			if (slave_fcc_ua <= MINIMUM_PARALLEL_FCC_UA) {
+				pl_dbg(chip, PR_PARALLEL, "terminating: parallel's share is low\n");
+				vote(chip->pl_disable_votable, TAPER_END_VOTER,
+						true, 0);
+			} else {
+				pl_dbg(chip, PR_PARALLEL, "terminating: parallel disabled\n");
+			}
+			goto done;
+		}
+
+		rc = power_supply_get_property(chip->batt_psy,
+				       POWER_SUPPLY_PROP_CHARGE_TYPE, &pval);
+		if (rc < 0) {
+			pr_err("Couldn't get batt charge type rc=%d\n", rc);
+			goto done;
+		}
+
+		chip->charge_type = pval.intval;
+		if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) {
+			eff_fcc_ua = get_effective_result(chip->fcc_votable);
+			if (eff_fcc_ua < 0) {
+				pr_err("Couldn't get fcc, exiting taper work\n");
+				goto done;
+			}
+			eff_fcc_ua = eff_fcc_ua - TAPER_REDUCTION_UA;
+			if (eff_fcc_ua < 0) {
+				pr_err("Can't reduce FCC any more\n");
+				goto done;
+			}
+
+			pl_dbg(chip, PR_PARALLEL, "master is taper charging; reducing FCC to %dua\n",
+					eff_fcc_ua);
+			vote(chip->fcc_votable, TAPER_STEPPER_VOTER,
+					true, eff_fcc_ua);
+		} else {
+			pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n");
+		}
+		/* wait for the charger state to deglitch after FCC change */
+		msleep(PL_TAPER_WORK_DELAY_MS);
 	}
-
-	total_fcc_ua = get_effective_result_locked(chip->fcc_votable);
-	get_fcc_split(chip, total_fcc_ua, &master_fcc_ua, &slave_fcc_ua);
-	if (slave_fcc_ua < MINIMUM_PARALLEL_FCC_UA) {
-		pl_dbg(chip, PR_PARALLEL, "terminating parallel's share lower than 500mA\n");
-		vote(chip->pl_disable_votable, TAPER_END_VOTER, true, 0);
-		goto done;
-	}
-
-	pl_dbg(chip, PR_PARALLEL, "entering parallel taper work slave_fcc = %d\n",
-		slave_fcc_ua);
-
-	rc = power_supply_get_property(chip->batt_psy,
-			       POWER_SUPPLY_PROP_CHARGE_TYPE, &pval);
-	if (rc < 0) {
-		pr_err("Couldn't get batt charge type rc=%d\n", rc);
-		goto done;
-	}
-
-	chip->charge_type = pval.intval;
-	if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) {
-		pl_dbg(chip, PR_PARALLEL, "master is taper charging; reducing slave FCC\n");
-
-		vote(chip->pl_awake_votable, TAPER_END_VOTER, true, 0);
-		/* Reduce the taper percent by 10 percent */
-		chip->taper_pct = chip->taper_pct * TAPER_RESIDUAL_PCT / 100;
-		rerun_election(chip->fcc_votable);
-		pl_dbg(chip, PR_PARALLEL, "taper entry scheduling work after %d ms\n",
-				PL_TAPER_WORK_DELAY_MS);
-		schedule_delayed_work(&chip->pl_taper_work,
-				msecs_to_jiffies(PL_TAPER_WORK_DELAY_MS));
-		return;
-	}
-
-	/*
-	 * Master back to Fast Charge, get out of this round of taper reduction
-	 */
-	pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n");
-
 done:
+	chip->taper_work_running = false;
+	vote(chip->fcc_votable, TAPER_STEPPER_VOTER, false, 0);
 	vote(chip->pl_awake_votable, TAPER_END_VOTER, false, 0);
 }
 
@@ -422,24 +432,19 @@
 		get_fcc_split(chip, total_fcc_ua, &master_fcc_ua,
 				&slave_fcc_ua);
 
-		if (slave_fcc_ua > 500000) {
+		if (slave_fcc_ua > MINIMUM_PARALLEL_FCC_UA) {
 			chip->slave_fcc_ua = slave_fcc_ua;
-			vote(chip->pl_disable_votable, FCC_CHANGE_VOTER,
+			vote(chip->pl_disable_votable, PL_FCC_LOW_VOTER,
 							false, 0);
 		} else {
 			chip->slave_fcc_ua = 0;
-			vote(chip->pl_disable_votable, FCC_CHANGE_VOTER,
+			vote(chip->pl_disable_votable, PL_FCC_LOW_VOTER,
 							true, 0);
 		}
 	}
 
 	rerun_election(chip->pl_disable_votable);
 
-	pl_dbg(chip, PR_PARALLEL, "master_fcc=%d slave_fcc=%d distribution=(%d/%d)\n",
-		   master_fcc_ua, slave_fcc_ua,
-		   (master_fcc_ua * 100) / total_fcc_ua,
-		   (slave_fcc_ua * 100) / total_fcc_ua);
-
 	return 0;
 }
 
@@ -652,12 +657,21 @@
 		if (rc < 0) {
 			pr_err("Couldn't get batt charge type rc=%d\n", rc);
 		} else {
-			if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) {
+			if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER
+				&& !chip->taper_work_running) {
 				pl_dbg(chip, PR_PARALLEL,
 					"pl enabled in Taper scheduing work\n");
-				schedule_delayed_work(&chip->pl_taper_work, 0);
+				vote(chip->pl_awake_votable, TAPER_END_VOTER,
+						true, 0);
+				queue_work(system_long_wq,
+						&chip->pl_taper_work);
 			}
 		}
+
+		pl_dbg(chip, PR_PARALLEL, "master_fcc=%d slave_fcc=%d distribution=(%d/%d)\n",
+			master_fcc_ua, slave_fcc_ua,
+			(master_fcc_ua * 100) / total_fcc_ua,
+			(slave_fcc_ua * 100) / total_fcc_ua);
 	} else {
 		if ((chip->pl_mode == POWER_SUPPLY_PL_USBIN_USBIN)
 			|| (chip->pl_mode == POWER_SUPPLY_PL_USBIN_USBIN_EXT))
@@ -788,7 +802,6 @@
 	if ((pval.intval != POWER_SUPPLY_CHARGE_TYPE_FAST)
 		&& (pval.intval != POWER_SUPPLY_CHARGE_TYPE_TAPER)) {
 		vote(chip->pl_disable_votable, CHG_STATE_VOTER, true, 0);
-		chip->taper_pct = 100;
 		vote(chip->pl_disable_votable, TAPER_END_VOTER, false, 0);
 		vote(chip->pl_disable_votable, PL_TAPER_EARLY_BAD_VOTER,
 				false, 0);
@@ -800,8 +813,11 @@
 	if (chip->charge_type == POWER_SUPPLY_CHARGE_TYPE_FAST
 		&& (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER)) {
 		chip->charge_type = pval.intval;
-		pl_dbg(chip, PR_PARALLEL, "taper entry scheduling work\n");
-		schedule_delayed_work(&chip->pl_taper_work, 0);
+		if (!chip->taper_work_running) {
+			pl_dbg(chip, PR_PARALLEL, "taper entry scheduling work\n");
+			vote(chip->pl_awake_votable, TAPER_END_VOTER, true, 0);
+			queue_work(system_long_wq, &chip->pl_taper_work);
+		}
 		return;
 	}
 
@@ -1010,7 +1026,7 @@
 		goto release_wakeup_source;
 	}
 
-	chip->fv_votable = create_votable("FV", VOTE_MAX,
+	chip->fv_votable = create_votable("FV", VOTE_MIN,
 					pl_fv_vote_callback,
 					chip);
 	if (IS_ERR(chip->fv_votable)) {
@@ -1057,7 +1073,7 @@
 	vote(chip->pl_disable_votable, PL_INDIRECT_VOTER, true, 0);
 
 	INIT_DELAYED_WORK(&chip->status_change_work, status_change_work);
-	INIT_DELAYED_WORK(&chip->pl_taper_work, pl_taper_work);
+	INIT_WORK(&chip->pl_taper_work, pl_taper_work);
 	INIT_WORK(&chip->pl_disable_forever_work, pl_disable_forever_work);
 
 	rc = pl_register_notifier(chip);
@@ -1082,8 +1098,6 @@
 		goto unreg_notifier;
 	}
 
-	chip->taper_pct = 100;
-
 	the_chip = chip;
 
 	return 0;
@@ -1112,7 +1126,7 @@
 		return;
 
 	cancel_delayed_work_sync(&chip->status_change_work);
-	cancel_delayed_work_sync(&chip->pl_taper_work);
+	cancel_work_sync(&chip->pl_taper_work);
 	cancel_work_sync(&chip->pl_disable_forever_work);
 
 	power_supply_unreg_notifier(&chip->nb);
diff --git a/drivers/power/supply/qcom/fg-core.h b/drivers/power/supply/qcom/fg-core.h
index c793ee5..3ca5def 100644
--- a/drivers/power/supply/qcom/fg-core.h
+++ b/drivers/power/supply/qcom/fg-core.h
@@ -105,7 +105,7 @@
 };
 
 /* JEITA */
-enum {
+enum jeita_levels {
 	JEITA_COLD = 0,
 	JEITA_COOL,
 	JEITA_WARM,
@@ -252,6 +252,7 @@
 struct fg_dt_props {
 	bool	force_load_profile;
 	bool	hold_soc_while_full;
+	bool	linearize_soc;
 	bool	auto_recharge_soc;
 	int	cutoff_volt_mv;
 	int	empty_volt_mv;
@@ -286,6 +287,7 @@
 	int	esr_pulse_thresh_ma;
 	int	esr_meas_curr_ma;
 	int	bmd_en_delay_ms;
+	int	ki_coeff_full_soc_dischg;
 	int	jeita_thresholds[NUM_JEITA_LEVELS];
 	int	ki_coeff_soc[KI_COEFF_SOC_LEVELS];
 	int	ki_coeff_med_dischg[KI_COEFF_SOC_LEVELS];
@@ -415,6 +417,7 @@
 	struct mutex		bus_lock;
 	struct mutex		sram_rw_lock;
 	struct mutex		charge_full_lock;
+	struct mutex		qnovo_esr_ctrl_lock;
 	u32			batt_soc_base;
 	u32			batt_info_base;
 	u32			mem_if_base;
@@ -423,7 +426,6 @@
 	int			batt_id_ohms;
 	int			ki_coeff_full_soc;
 	int			charge_status;
-	int			prev_charge_status;
 	int			charge_done;
 	int			charge_type;
 	int			online_status;
@@ -449,6 +451,7 @@
 	bool			slope_limit_en;
 	bool			use_ima_single_mode;
 	bool			use_dma;
+	bool			qnovo_enable;
 	struct completion	soc_update;
 	struct completion	soc_ready;
 	struct completion	mem_grant;
@@ -504,6 +507,7 @@
 extern int fg_read(struct fg_chip *chip, int addr, u8 *val, int len);
 extern int fg_write(struct fg_chip *chip, int addr, u8 *val, int len);
 extern int fg_masked_write(struct fg_chip *chip, int addr, u8 mask, u8 val);
+extern int fg_dump_regs(struct fg_chip *chip);
 extern int fg_ima_init(struct fg_chip *chip);
 extern int fg_dma_init(struct fg_chip *chip);
 extern int fg_clear_ima_errors_if_any(struct fg_chip *chip, bool check_hw_sts);
diff --git a/drivers/power/supply/qcom/fg-memif.c b/drivers/power/supply/qcom/fg-memif.c
index 0abc9df..c1b5adc 100644
--- a/drivers/power/supply/qcom/fg-memif.c
+++ b/drivers/power/supply/qcom/fg-memif.c
@@ -792,6 +792,7 @@
 		} else {
 			pr_err("wait for mem_grant timed out ret=%d\n",
 				ret);
+			fg_dump_regs(chip);
 		}
 	}
 
diff --git a/drivers/power/supply/qcom/fg-util.c b/drivers/power/supply/qcom/fg-util.c
index aed2062..fc60b26 100644
--- a/drivers/power/supply/qcom/fg-util.c
+++ b/drivers/power/supply/qcom/fg-util.c
@@ -492,6 +492,33 @@
 	return rc;
 }
 
+int fg_dump_regs(struct fg_chip *chip)
+{
+	int i, rc;
+	u8 buf[256];
+
+	if (!chip)
+		return -EINVAL;
+
+	rc = fg_read(chip, chip->batt_soc_base, buf, sizeof(buf));
+	if (rc < 0)
+		return rc;
+
+	pr_info("batt_soc_base registers:\n");
+	for (i = 0; i < sizeof(buf); i++)
+		pr_info("%04x:%02x\n", chip->batt_soc_base + i, buf[i]);
+
+	rc = fg_read(chip, chip->mem_if_base, buf, sizeof(buf));
+	if (rc < 0)
+		return rc;
+
+	pr_info("mem_if_base registers:\n");
+	for (i = 0; i < sizeof(buf); i++)
+		pr_info("%04x:%02x\n", chip->mem_if_base + i, buf[i]);
+
+	return 0;
+}
+
 int64_t twos_compliment_extend(int64_t val, int sign_bit_pos)
 {
 	int i, nbytes = DIV_ROUND_UP(sign_bit_pos, 8);
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c
index 6f615e4..fc34a8c9 100644
--- a/drivers/power/supply/qcom/qpnp-fg-gen3.c
+++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c
@@ -576,6 +576,41 @@
 	return 0;
 }
 
+static int fg_get_jeita_threshold(struct fg_chip *chip,
+				enum jeita_levels level, int *temp_decidegC)
+{
+	int rc;
+	u8 val;
+	u16 reg;
+
+	switch (level) {
+	case JEITA_COLD:
+		reg = BATT_INFO_JEITA_TOO_COLD(chip);
+		break;
+	case JEITA_COOL:
+		reg = BATT_INFO_JEITA_COLD(chip);
+		break;
+	case JEITA_WARM:
+		reg = BATT_INFO_JEITA_HOT(chip);
+		break;
+	case JEITA_HOT:
+		reg = BATT_INFO_JEITA_TOO_HOT(chip);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	rc = fg_read(chip, reg, &val, 1);
+	if (rc < 0) {
+		pr_err("Error in reading jeita level %d, rc=%d\n", level, rc);
+		return rc;
+	}
+
+	/* Resolution is 0.5C. Base is -30C. */
+	*temp_decidegC = (((5 * val) / 10) - 30) * 10;
+	return 0;
+}
+
 #define BATT_TEMP_NUMR		1
 #define BATT_TEMP_DENR		1
 static int fg_get_battery_temp(struct fg_chip *chip, int *val)
@@ -838,7 +873,7 @@
 	if (rc < 0)
 		return rc;
 
-	if (chip->delta_soc > 0)
+	if (chip->dt.linearize_soc && chip->delta_soc > 0)
 		*val = chip->maint_soc;
 	else
 		*val = msoc;
@@ -978,12 +1013,6 @@
 	return 0;
 }
 
-static inline void get_temp_setpoint(int threshold, u8 *val)
-{
-	/* Resolution is 0.5C. Base is -30C. */
-	*val = DIV_ROUND_CLOSEST((threshold + 30) * 10, 5);
-}
-
 static inline void get_batt_temp_delta(int delta, u8 *val)
 {
 	switch (delta) {
@@ -1602,6 +1631,8 @@
 
 	if (batt_temp < 0)
 		ki_coeff_full_soc = 0;
+	else if (chip->charge_status == POWER_SUPPLY_STATUS_DISCHARGING)
+		ki_coeff_full_soc = chip->dt.ki_coeff_full_soc_dischg;
 	else
 		ki_coeff_full_soc = KI_COEFF_FULL_SOC_DEFAULT;
 
@@ -1658,12 +1689,38 @@
 	return 0;
 }
 
+static int fg_configure_full_soc(struct fg_chip *chip, int bsoc)
+{
+	int rc;
+	u8 full_soc[2] = {0xFF, 0xFF};
+
+	/*
+	 * Once SOC masking condition is cleared, FULL_SOC and MONOTONIC_SOC
+	 * needs to be updated to reflect the same. Write battery SOC to
+	 * FULL_SOC and write a full value to MONOTONIC_SOC.
+	 */
+	rc = fg_sram_write(chip, FULL_SOC_WORD, FULL_SOC_OFFSET,
+			(u8 *)&bsoc, 2, FG_IMA_ATOMIC);
+	if (rc < 0) {
+		pr_err("failed to write full_soc rc=%d\n", rc);
+		return rc;
+	}
+
+	rc = fg_sram_write(chip, MONOTONIC_SOC_WORD, MONOTONIC_SOC_OFFSET,
+			full_soc, 2, FG_IMA_ATOMIC);
+	if (rc < 0) {
+		pr_err("failed to write monotonic_soc rc=%d\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
 #define AUTO_RECHG_VOLT_LOW_LIMIT_MV	3700
 static int fg_charge_full_update(struct fg_chip *chip)
 {
 	union power_supply_propval prop = {0, };
 	int rc, msoc, bsoc, recharge_soc, msoc_raw;
-	u8 full_soc[2] = {0xFF, 0xFF};
 
 	if (!chip->dt.hold_soc_while_full)
 		return 0;
@@ -1693,12 +1750,12 @@
 
 	/* We need 2 most significant bytes here */
 	bsoc = (u32)bsoc >> 16;
-	rc = fg_get_msoc(chip, &msoc);
+	rc = fg_get_msoc_raw(chip, &msoc_raw);
 	if (rc < 0) {
-		pr_err("Error in getting msoc, rc=%d\n", rc);
+		pr_err("Error in getting msoc_raw, rc=%d\n", rc);
 		goto out;
 	}
-	msoc_raw = DIV_ROUND_CLOSEST(msoc * FULL_SOC_RAW, FULL_CAPACITY);
+	msoc = DIV_ROUND_CLOSEST(msoc_raw * FULL_CAPACITY, FULL_SOC_RAW);
 
 	fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
 		msoc, bsoc, chip->health, chip->charge_status,
@@ -1722,24 +1779,24 @@
 			fg_dbg(chip, FG_STATUS, "Terminated charging @ SOC%d\n",
 				msoc);
 		}
-	} else if (msoc_raw < recharge_soc && chip->charge_full) {
-		chip->delta_soc = FULL_CAPACITY - msoc;
+	} else if (msoc_raw <= recharge_soc && chip->charge_full) {
+		if (chip->dt.linearize_soc) {
+			chip->delta_soc = FULL_CAPACITY - msoc;
 
-		/*
-		 * We're spreading out the delta SOC over every 10% change
-		 * in monotonic SOC. We cannot spread more than 9% in the
-		 * range of 0-100 skipping the first 10%.
-		 */
-		if (chip->delta_soc > 9) {
-			chip->delta_soc = 0;
-			chip->maint_soc = 0;
-		} else {
-			chip->maint_soc = FULL_CAPACITY;
-			chip->last_msoc = msoc;
+			/*
+			 * We're spreading out the delta SOC over every 10%
+			 * change in monotonic SOC. We cannot spread more than
+			 * 9% in the range of 0-100 skipping the first 10%.
+			 */
+			if (chip->delta_soc > 9) {
+				chip->delta_soc = 0;
+				chip->maint_soc = 0;
+			} else {
+				chip->maint_soc = FULL_CAPACITY;
+				chip->last_msoc = msoc;
+			}
 		}
 
-		chip->charge_full = false;
-
 		/*
 		 * Raise the recharge voltage so that VBAT_LT_RECHG signal
 		 * will be asserted soon as battery SOC had dropped below
@@ -1752,35 +1809,23 @@
 				rc);
 			goto out;
 		}
+
+		/*
+		 * If charge_done is still set, wait for recharging or
+		 * discharging to happen.
+		 */
+		if (chip->charge_done)
+			goto out;
+
+		rc = fg_configure_full_soc(chip, bsoc);
+		if (rc < 0)
+			goto out;
+
+		chip->charge_full = false;
 		fg_dbg(chip, FG_STATUS, "msoc_raw = %d bsoc: %d recharge_soc: %d delta_soc: %d\n",
 			msoc_raw, bsoc >> 8, recharge_soc, chip->delta_soc);
-	} else {
-		goto out;
 	}
 
-	if (!chip->charge_full)
-		goto out;
-
-	/*
-	 * During JEITA conditions, charge_full can happen early. FULL_SOC
-	 * and MONOTONIC_SOC needs to be updated to reflect the same. Write
-	 * battery SOC to FULL_SOC and write a full value to MONOTONIC_SOC.
-	 */
-	rc = fg_sram_write(chip, FULL_SOC_WORD, FULL_SOC_OFFSET, (u8 *)&bsoc, 2,
-			FG_IMA_ATOMIC);
-	if (rc < 0) {
-		pr_err("failed to write full_soc rc=%d\n", rc);
-		goto out;
-	}
-
-	rc = fg_sram_write(chip, MONOTONIC_SOC_WORD, MONOTONIC_SOC_OFFSET,
-			full_soc, 2, FG_IMA_ATOMIC);
-	if (rc < 0) {
-		pr_err("failed to write monotonic_soc rc=%d\n", rc);
-		goto out;
-	}
-
-	fg_dbg(chip, FG_STATUS, "Set charge_full to true @ soc %d\n", msoc);
 out:
 	mutex_unlock(&chip->charge_full_lock);
 	return rc;
@@ -1863,6 +1908,44 @@
 	return 0;
 }
 
+static int fg_set_jeita_threshold(struct fg_chip *chip,
+				enum jeita_levels level, int temp_decidegC)
+{
+	int rc;
+	u8 val;
+	u16 reg;
+
+	if (temp_decidegC < -300 || temp_decidegC > 970)
+		return -EINVAL;
+
+	/* Resolution is 0.5C. Base is -30C. */
+	val = DIV_ROUND_CLOSEST(((temp_decidegC / 10) + 30) * 10, 5);
+	switch (level) {
+	case JEITA_COLD:
+		reg = BATT_INFO_JEITA_TOO_COLD(chip);
+		break;
+	case JEITA_COOL:
+		reg = BATT_INFO_JEITA_COLD(chip);
+		break;
+	case JEITA_WARM:
+		reg = BATT_INFO_JEITA_HOT(chip);
+		break;
+	case JEITA_HOT:
+		reg = BATT_INFO_JEITA_TOO_HOT(chip);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	rc = fg_write(chip, reg, &val, 1);
+	if (rc < 0) {
+		pr_err("Error in setting jeita level %d, rc=%d\n", level, rc);
+		return rc;
+	}
+
+	return 0;
+}
+
 static int fg_set_constant_chg_voltage(struct fg_chip *chip, int volt_uv)
 {
 	u8 buf[2];
@@ -2426,7 +2509,6 @@
 		goto out;
 	}
 
-	chip->prev_charge_status = chip->charge_status;
 	chip->charge_status = prop.intval;
 	rc = power_supply_get_property(chip->batt_psy,
 			POWER_SUPPLY_PROP_CHARGE_TYPE, &prop);
@@ -2862,6 +2944,9 @@
 		t_predicted_cv, t_predicted = 0;
 	s64 delta_ms;
 
+	if (!chip->soc_reporting_ready)
+		return -ENODATA;
+
 	if (chip->bp.float_volt_uv <= 0) {
 		pr_err("battery profile is not loaded\n");
 		return -ENODATA;
@@ -3137,6 +3222,9 @@
 {
 	int rc = 0, msoc;
 
+	if (!chip->dt.linearize_soc)
+		return 0;
+
 	mutex_lock(&chip->charge_full_lock);
 	if (chip->delta_soc <= 0)
 		goto out;
@@ -3213,20 +3301,21 @@
 	int rc;
 	int esr_uohms;
 
+	mutex_lock(&chip->qnovo_esr_ctrl_lock);
 	/* force esr extraction enable */
 	rc = fg_sram_masked_write(chip, ESR_EXTRACTION_ENABLE_WORD,
 			ESR_EXTRACTION_ENABLE_OFFSET, BIT(0), BIT(0),
 			FG_IMA_DEFAULT);
 	if (rc < 0) {
 		pr_err("failed to enable esr extn rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
 	rc = fg_masked_write(chip, BATT_INFO_QNOVO_CFG(chip),
 			LD_REG_CTRL_BIT, 0);
 	if (rc < 0) {
 		pr_err("Error in configuring qnovo_cfg rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
 	rc = fg_masked_write(chip, BATT_INFO_TM_MISC1(chip),
@@ -3234,24 +3323,36 @@
 			ESR_REQ_CTL_BIT | ESR_REQ_CTL_EN_BIT);
 	if (rc < 0) {
 		pr_err("Error in configuring force ESR rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
+	/*
+	 * Release and grab the lock again after 1.5 seconds so that prepare
+	 * callback can succeed if the request comes in between.
+	 */
+	mutex_unlock(&chip->qnovo_esr_ctrl_lock);
+
 	/* wait 1.5 seconds for hw to measure ESR */
 	msleep(1500);
+
+	mutex_lock(&chip->qnovo_esr_ctrl_lock);
 	rc = fg_masked_write(chip, BATT_INFO_TM_MISC1(chip),
 			ESR_REQ_CTL_BIT | ESR_REQ_CTL_EN_BIT,
 			0);
 	if (rc < 0) {
 		pr_err("Error in restoring force ESR rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
+	/* If qnovo is disabled, then leave ESR extraction enabled */
+	if (!chip->qnovo_enable)
+		goto done;
+
 	rc = fg_masked_write(chip, BATT_INFO_QNOVO_CFG(chip),
 			LD_REG_CTRL_BIT, LD_REG_CTRL_BIT);
 	if (rc < 0) {
 		pr_err("Error in restoring qnovo_cfg rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
 	/* force esr extraction disable */
@@ -3260,36 +3361,46 @@
 			FG_IMA_DEFAULT);
 	if (rc < 0) {
 		pr_err("failed to disable esr extn rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
 
+done:
 	fg_get_battery_resistance(chip, &esr_uohms);
 	fg_dbg(chip, FG_STATUS, "ESR uohms = %d\n", esr_uohms);
-
+out:
+	mutex_unlock(&chip->qnovo_esr_ctrl_lock);
 	return rc;
 }
 
 static int fg_prepare_for_qnovo(struct fg_chip *chip, int qnovo_enable)
 {
-	int rc;
+	int rc = 0;
 
+	mutex_lock(&chip->qnovo_esr_ctrl_lock);
 	/* force esr extraction disable when qnovo enables */
 	rc = fg_sram_masked_write(chip, ESR_EXTRACTION_ENABLE_WORD,
 			ESR_EXTRACTION_ENABLE_OFFSET,
 			BIT(0), qnovo_enable ? 0 : BIT(0),
 			FG_IMA_DEFAULT);
-	if (rc < 0)
+	if (rc < 0) {
 		pr_err("Error in configuring esr extraction rc=%d\n", rc);
+		goto out;
+	}
 
 	rc = fg_masked_write(chip, BATT_INFO_QNOVO_CFG(chip),
 			LD_REG_CTRL_BIT,
 			qnovo_enable ? LD_REG_CTRL_BIT : 0);
 	if (rc < 0) {
 		pr_err("Error in configuring qnovo_cfg rc=%d\n", rc);
-		return rc;
+		goto out;
 	}
-	fg_dbg(chip, FG_STATUS, "Prepared for Qnovo\n");
-	return 0;
+
+	fg_dbg(chip, FG_STATUS, "%s for Qnovo\n",
+		qnovo_enable ? "Prepared" : "Unprepared");
+	chip->qnovo_enable = qnovo_enable;
+out:
+	mutex_unlock(&chip->qnovo_esr_ctrl_lock);
+	return rc;
 }
 
 static void ttf_work(struct work_struct *work)
@@ -3365,6 +3476,9 @@
 	case POWER_SUPPLY_PROP_CAPACITY:
 		rc = fg_get_prop_capacity(chip, &pval->intval);
 		break;
+	case POWER_SUPPLY_PROP_CAPACITY_RAW:
+		rc = fg_get_msoc_raw(chip, &pval->intval);
+		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		if (chip->battery_missing)
 			pval->intval = 3700000;
@@ -3377,6 +3491,34 @@
 	case POWER_SUPPLY_PROP_TEMP:
 		rc = fg_get_battery_temp(chip, &pval->intval);
 		break;
+	case POWER_SUPPLY_PROP_COLD_TEMP:
+		rc = fg_get_jeita_threshold(chip, JEITA_COLD, &pval->intval);
+		if (rc < 0) {
+			pr_err("Error in reading jeita_cold, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_COOL_TEMP:
+		rc = fg_get_jeita_threshold(chip, JEITA_COOL, &pval->intval);
+		if (rc < 0) {
+			pr_err("Error in reading jeita_cool, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_WARM_TEMP:
+		rc = fg_get_jeita_threshold(chip, JEITA_WARM, &pval->intval);
+		if (rc < 0) {
+			pr_err("Error in reading jeita_warm, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_HOT_TEMP:
+		rc = fg_get_jeita_threshold(chip, JEITA_HOT, &pval->intval);
+		if (rc < 0) {
+			pr_err("Error in reading jeita_hot, rc=%d\n", rc);
+			return rc;
+		}
+		break;
 	case POWER_SUPPLY_PROP_RESISTANCE:
 		rc = fg_get_battery_resistance(chip, &pval->intval);
 		break;
@@ -3500,6 +3642,48 @@
 			return -EINVAL;
 		}
 		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL:
+		if (chip->cl.active) {
+			pr_warn("Capacity learning active!\n");
+			return 0;
+		}
+		if (pval->intval <= 0 || pval->intval > chip->cl.nom_cap_uah) {
+			pr_err("charge_full is out of bounds\n");
+			return -EINVAL;
+		}
+		chip->cl.learned_cc_uah = pval->intval;
+		rc = fg_save_learned_cap_to_sram(chip);
+		if (rc < 0)
+			pr_err("Error in saving learned_cc_uah, rc=%d\n", rc);
+		break;
+	case POWER_SUPPLY_PROP_COLD_TEMP:
+		rc = fg_set_jeita_threshold(chip, JEITA_COLD, pval->intval);
+		if (rc < 0) {
+			pr_err("Error in writing jeita_cold, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_COOL_TEMP:
+		rc = fg_set_jeita_threshold(chip, JEITA_COOL, pval->intval);
+		if (rc < 0) {
+			pr_err("Error in writing jeita_cool, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_WARM_TEMP:
+		rc = fg_set_jeita_threshold(chip, JEITA_WARM, pval->intval);
+		if (rc < 0) {
+			pr_err("Error in writing jeita_warm, rc=%d\n", rc);
+			return rc;
+		}
+		break;
+	case POWER_SUPPLY_PROP_HOT_TEMP:
+		rc = fg_set_jeita_threshold(chip, JEITA_HOT, pval->intval);
+		if (rc < 0) {
+			pr_err("Error in writing jeita_hot, rc=%d\n", rc);
+			return rc;
+		}
+		break;
 	default:
 		break;
 	}
@@ -3515,6 +3699,11 @@
 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
 	case POWER_SUPPLY_PROP_CC_STEP:
 	case POWER_SUPPLY_PROP_CC_STEP_SEL:
+	case POWER_SUPPLY_PROP_CHARGE_FULL:
+	case POWER_SUPPLY_PROP_COLD_TEMP:
+	case POWER_SUPPLY_PROP_COOL_TEMP:
+	case POWER_SUPPLY_PROP_WARM_TEMP:
+	case POWER_SUPPLY_PROP_HOT_TEMP:
 		return 1;
 	default:
 		break;
@@ -3541,6 +3730,7 @@
 		return NOTIFY_OK;
 
 	if ((strcmp(psy->desc->name, "battery") == 0)
+		|| (strcmp(psy->desc->name, "parallel") == 0)
 		|| (strcmp(psy->desc->name, "usb") == 0)) {
 		/*
 		 * We cannot vote for awake votable here as that takes
@@ -3555,7 +3745,12 @@
 
 static enum power_supply_property fg_psy_props[] = {
 	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_CAPACITY_RAW,
 	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_COLD_TEMP,
+	POWER_SUPPLY_PROP_COOL_TEMP,
+	POWER_SUPPLY_PROP_WARM_TEMP,
+	POWER_SUPPLY_PROP_HOT_TEMP,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_VOLTAGE_OCV,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
@@ -3734,29 +3929,29 @@
 		}
 	}
 
-	get_temp_setpoint(chip->dt.jeita_thresholds[JEITA_COLD], &val);
-	rc = fg_write(chip, BATT_INFO_JEITA_TOO_COLD(chip), &val, 1);
+	rc = fg_set_jeita_threshold(chip, JEITA_COLD,
+		chip->dt.jeita_thresholds[JEITA_COLD] * 10);
 	if (rc < 0) {
 		pr_err("Error in writing jeita_cold, rc=%d\n", rc);
 		return rc;
 	}
 
-	get_temp_setpoint(chip->dt.jeita_thresholds[JEITA_COOL], &val);
-	rc = fg_write(chip, BATT_INFO_JEITA_COLD(chip), &val, 1);
+	rc = fg_set_jeita_threshold(chip, JEITA_COOL,
+		chip->dt.jeita_thresholds[JEITA_COOL] * 10);
 	if (rc < 0) {
 		pr_err("Error in writing jeita_cool, rc=%d\n", rc);
 		return rc;
 	}
 
-	get_temp_setpoint(chip->dt.jeita_thresholds[JEITA_WARM], &val);
-	rc = fg_write(chip, BATT_INFO_JEITA_HOT(chip), &val, 1);
+	rc = fg_set_jeita_threshold(chip, JEITA_WARM,
+		chip->dt.jeita_thresholds[JEITA_WARM] * 10);
 	if (rc < 0) {
 		pr_err("Error in writing jeita_warm, rc=%d\n", rc);
 		return rc;
 	}
 
-	get_temp_setpoint(chip->dt.jeita_thresholds[JEITA_HOT], &val);
-	rc = fg_write(chip, BATT_INFO_JEITA_TOO_HOT(chip), &val, 1);
+	rc = fg_set_jeita_threshold(chip, JEITA_HOT,
+		chip->dt.jeita_thresholds[JEITA_HOT] * 10);
 	if (rc < 0) {
 		pr_err("Error in writing jeita_hot, rc=%d\n", rc);
 		return rc;
@@ -3922,8 +4117,7 @@
 	}
 
 	fg_dbg(chip, FG_IRQ, "irq %d triggered, status:%d\n", irq, status);
-	if (status & MEM_GNT_BIT)
-		complete_all(&chip->mem_grant);
+	complete_all(&chip->mem_grant);
 
 	return IRQ_HANDLED;
 }
@@ -4333,7 +4527,11 @@
 static int fg_parse_ki_coefficients(struct fg_chip *chip)
 {
 	struct device_node *node = chip->dev->of_node;
-	int rc, i;
+	int rc, i, temp;
+
+	rc = of_property_read_u32(node, "qcom,ki-coeff-full-dischg", &temp);
+	if (!rc)
+		chip->dt.ki_coeff_full_soc_dischg = temp;
 
 	rc = fg_parse_dt_property_u32_array(node, "qcom,ki-coeff-soc-dischg",
 		chip->dt.ki_coeff_soc, KI_COEFF_SOC_LEVELS);
@@ -4680,6 +4878,9 @@
 	chip->dt.hold_soc_while_full = of_property_read_bool(node,
 					"qcom,hold-soc-while-full");
 
+	chip->dt.linearize_soc = of_property_read_bool(node,
+					"qcom,linearize-soc");
+
 	rc = fg_parse_ki_coefficients(chip);
 	if (rc < 0)
 		pr_err("Error in parsing Ki coefficients, rc=%d\n", rc);
@@ -4761,6 +4962,13 @@
 
 static void fg_cleanup(struct fg_chip *chip)
 {
+	int i;
+
+	for (i = 0; i < FG_IRQ_MAX; i++) {
+		if (fg_irqs[i].irq)
+			devm_free_irq(chip->dev, fg_irqs[i].irq, chip);
+	}
+
 	power_supply_unreg_notifier(&chip->nb);
 	debugfs_remove_recursive(chip->dfs_root);
 	if (chip->awake_votable)
@@ -4792,7 +5000,6 @@
 	chip->debug_mask = &fg_gen3_debug_mask;
 	chip->irqs = fg_irqs;
 	chip->charge_status = -EINVAL;
-	chip->prev_charge_status = -EINVAL;
 	chip->ki_coeff_full_soc = -EINVAL;
 	chip->online_status = -EINVAL;
 	chip->regmap = dev_get_regmap(chip->dev->parent, NULL);
@@ -4865,6 +5072,7 @@
 	mutex_init(&chip->cl.lock);
 	mutex_init(&chip->ttf.lock);
 	mutex_init(&chip->charge_full_lock);
+	mutex_init(&chip->qnovo_esr_ctrl_lock);
 	init_completion(&chip->soc_update);
 	init_completion(&chip->soc_ready);
 	init_completion(&chip->mem_grant);
@@ -5002,6 +5210,29 @@
 	return 0;
 }
 
+static void fg_gen3_shutdown(struct platform_device *pdev)
+{
+	struct fg_chip *chip = dev_get_drvdata(&pdev->dev);
+	int rc, bsoc;
+
+	if (chip->charge_full) {
+		rc = fg_get_sram_prop(chip, FG_SRAM_BATT_SOC, &bsoc);
+		if (rc < 0) {
+			pr_err("Error in getting BATT_SOC, rc=%d\n", rc);
+			return;
+		}
+
+		/* We need 2 most significant bytes here */
+		bsoc = (u32)bsoc >> 16;
+
+		rc = fg_configure_full_soc(chip, bsoc);
+		if (rc < 0) {
+			pr_err("Error in configuring full_soc, rc=%d\n", rc);
+			return;
+		}
+	}
+}
+
 static const struct of_device_id fg_gen3_match_table[] = {
 	{.compatible = FG_GEN3_DEV_NAME},
 	{},
@@ -5016,6 +5247,7 @@
 	},
 	.probe		= fg_gen3_probe,
 	.remove		= fg_gen3_remove,
+	.shutdown	= fg_gen3_shutdown,
 };
 
 static int __init fg_gen3_init(void)
diff --git a/drivers/power/supply/qcom/qpnp-qnovo.c b/drivers/power/supply/qcom/qpnp-qnovo.c
index b208079..53af341 100644
--- a/drivers/power/supply/qcom/qpnp-qnovo.c
+++ b/drivers/power/supply/qcom/qpnp-qnovo.c
@@ -112,6 +112,7 @@
 #define GAIN_LSB_FACTOR	976560
 
 #define USER_VOTER		"user_voter"
+#define SHUTDOWN_VOTER		"user_voter"
 #define OK_TO_QNOVO_VOTER	"ok_to_qnovo_voter"
 
 #define QNOVO_VOTER		"qnovo_voter"
@@ -130,6 +131,7 @@
 struct qnovo_dt_props {
 	bool			external_rsense;
 	struct device_node	*revid_dev_node;
+	bool			enable_for_dc;
 };
 
 struct qnovo {
@@ -442,6 +444,8 @@
 		pr_err("Missing qcom,pmic-revid property - driver failed\n");
 		return -EINVAL;
 	}
+	chip->dt.enable_for_dc = of_property_read_bool(node,
+					"qcom,enable-for-dc");
 
 	return 0;
 }
@@ -1310,6 +1314,10 @@
 	if (usb_present)
 		dc_present = 0;
 
+	/* disable qnovo for dc path by forcing dc_present = 0 always */
+	if (!chip->dt.enable_for_dc)
+		dc_present = 0;
+
 	if (chip->dc_present && !dc_present) {
 		/* removal */
 		chip->dc_present = 0;
@@ -1333,6 +1341,26 @@
 				struct qnovo, ptrain_restart_work.work);
 	u8 pt_t1, pt_t2;
 	int rc;
+	u8 pt_en;
+
+	rc = qnovo_read(chip, QNOVO_PTRAIN_EN, &pt_en, 1);
+	if (rc < 0) {
+		dev_err(chip->dev, "Couldn't read QNOVO_PTRAIN_EN rc = %d\n",
+				rc);
+		goto clean_up;
+	}
+
+	if (!pt_en) {
+		rc = qnovo_masked_write(chip, QNOVO_PTRAIN_EN,
+				QNOVO_PTRAIN_EN_BIT, QNOVO_PTRAIN_EN_BIT);
+		if (rc < 0) {
+			dev_err(chip->dev, "Couldn't enable pulse train rc=%d\n",
+					rc);
+			goto clean_up;
+		}
+		/* sleep 20ms for the pulse trains to restart and settle */
+		msleep(20);
+	}
 
 	rc = qnovo_read(chip, QNOVO_PTTIME_STS, &pt_t1, 1);
 	if (rc < 0) {
@@ -1395,16 +1423,7 @@
 	struct qnovo *chip = data;
 	union power_supply_propval pval = {0};
 
-	/*
-	 * In some cases (esp shutting down) the userspace would  disable by
-	 * setting qnovo_enable=0. Also charger could be removed or there is
-	 * an error (i.e. its not okay to run qnovo)-
-	 * skip taking ESR measurement in such situations
-	 */
-
-	if (get_client_vote(chip->disable_votable, USER_VOTER)
-		|| get_effective_result(chip->not_ok_to_qnovo_votable) > 0)
-		return IRQ_HANDLED;
+	qnovo_update_status(chip);
 
 	/*
 	 * hw resets pt_en bit once ptrain_done triggers.
@@ -1415,13 +1434,14 @@
 	vote(chip->pt_dis_votable, QNI_PT_VOTER, true, 0);
 
 	vote(chip->pt_dis_votable, ESR_VOTER, true, 0);
-	if (is_fg_available(chip))
+	if (is_fg_available(chip)
+		&& !get_client_vote(chip->disable_votable, USER_VOTER)
+		&& !get_effective_result(chip->not_ok_to_qnovo_votable))
 		power_supply_set_property(chip->bms_psy,
 				POWER_SUPPLY_PROP_RESISTANCE,
 				&pval);
 
 	vote(chip->pt_dis_votable, ESR_VOTER, false, 0);
-	qnovo_update_status(chip);
 	kobject_uevent(&chip->dev->kobj, KOBJ_CHANGE);
 	return IRQ_HANDLED;
 }
@@ -1434,6 +1454,9 @@
 	u8 vadc_offset, vadc_gain;
 	u8 val;
 
+	vote(chip->chg_ready_votable, USB_READY_VOTER, false, 0);
+	vote(chip->chg_ready_votable, DC_READY_VOTER, false, 0);
+
 	vote(chip->disable_votable, USER_VOTER, true, 0);
 	vote(chip->disable_votable, FG_AVAILABLE_VOTER, true, 0);
 
@@ -1706,6 +1729,13 @@
 	return 0;
 }
 
+static void qnovo_shutdown(struct platform_device *pdev)
+{
+	struct qnovo *chip = platform_get_drvdata(pdev);
+
+	vote(chip->not_ok_to_qnovo_votable, SHUTDOWN_VOTER, true, 0);
+}
+
 static const struct of_device_id match_table[] = {
 	{ .compatible = "qcom,qpnp-qnovo", },
 	{ },
@@ -1719,6 +1749,7 @@
 	},
 	.probe		= qnovo_probe,
 	.remove		= qnovo_remove,
+	.shutdown	= qnovo_shutdown,
 };
 module_platform_driver(qnovo_driver);
 
diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c
index 60f5d23..34514c9 100644
--- a/drivers/power/supply/qcom/qpnp-smb2.c
+++ b/drivers/power/supply/qcom/qpnp-smb2.c
@@ -188,6 +188,11 @@
 module_param_named(
 	weak_chg_icl_ua, __weak_chg_icl_ua, int, 0600);
 
+static int __try_sink_enabled = 1;
+module_param_named(
+	try_sink_enabled, __try_sink_enabled, int, 0600
+);
+
 #define MICRO_1P5A		1500000
 #define MICRO_P1A		100000
 #define OTG_DEFAULT_DEGLITCH_TIME_MS	50
@@ -330,7 +335,6 @@
 static enum power_supply_property smb2_usb_props[] = {
 	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_ONLINE,
-	POWER_SUPPLY_PROP_VOLTAGE_MIN,
 	POWER_SUPPLY_PROP_VOLTAGE_MAX,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_PD_CURRENT_MAX,
@@ -349,6 +353,9 @@
 	POWER_SUPPLY_PROP_HW_CURRENT_MAX,
 	POWER_SUPPLY_PROP_REAL_TYPE,
 	POWER_SUPPLY_PROP_PR_SWAP,
+	POWER_SUPPLY_PROP_PD_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_PD_VOLTAGE_MIN,
+	POWER_SUPPLY_PROP_SDP_CURRENT_MAX,
 };
 
 static int smb2_usb_get_prop(struct power_supply *psy,
@@ -380,20 +387,17 @@
 		if (chg->real_charger_type == POWER_SUPPLY_TYPE_UNKNOWN)
 			val->intval = 0;
 		break;
-	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
-		val->intval = chg->voltage_min_uv;
-		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
-		val->intval = chg->voltage_max_uv;
+		rc = smblib_get_prop_usb_voltage_max(chg, val);
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		rc = smblib_get_prop_usb_voltage_now(chg, val);
 		break;
 	case POWER_SUPPLY_PROP_PD_CURRENT_MAX:
-		rc = smblib_get_prop_pd_current_max(chg, val);
+		val->intval = get_client_vote(chg->usb_icl_votable, PD_VOTER);
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_MAX:
-		rc = smblib_get_prop_usb_current_max(chg, val);
+		rc = smblib_get_prop_input_current_settled(chg, val);
 		break;
 	case POWER_SUPPLY_PROP_TYPE:
 		val->intval = POWER_SUPPLY_TYPE_USB_PD;
@@ -457,6 +461,16 @@
 	case POWER_SUPPLY_PROP_PR_SWAP:
 		rc = smblib_get_prop_pr_swap_in_progress(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_PD_VOLTAGE_MAX:
+		val->intval = chg->voltage_max_uv;
+		break;
+	case POWER_SUPPLY_PROP_PD_VOLTAGE_MIN:
+		val->intval = chg->voltage_min_uv;
+		break;
+	case POWER_SUPPLY_PROP_SDP_CURRENT_MAX:
+		val->intval = get_client_vote(chg->usb_icl_votable,
+					      USB_PSY_VOTER);
+		break;
 	default:
 		pr_err("get prop %d is not supported in usb\n", psp);
 		rc = -EINVAL;
@@ -484,18 +498,9 @@
 	}
 
 	switch (psp) {
-	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
-		rc = smblib_set_prop_usb_voltage_min(chg, val);
-		break;
-	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
-		rc = smblib_set_prop_usb_voltage_max(chg, val);
-		break;
 	case POWER_SUPPLY_PROP_PD_CURRENT_MAX:
 		rc = smblib_set_prop_pd_current_max(chg, val);
 		break;
-	case POWER_SUPPLY_PROP_CURRENT_MAX:
-		rc = smblib_set_prop_usb_current_max(chg, val);
-		break;
 	case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
 		rc = smblib_set_prop_typec_power_role(chg, val);
 		break;
@@ -518,6 +523,15 @@
 	case POWER_SUPPLY_PROP_PR_SWAP:
 		rc = smblib_set_prop_pr_swap_in_progress(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_PD_VOLTAGE_MAX:
+		rc = smblib_set_prop_pd_voltage_max(chg, val);
+		break;
+	case POWER_SUPPLY_PROP_PD_VOLTAGE_MIN:
+		rc = smblib_set_prop_pd_voltage_min(chg, val);
+		break;
+	case POWER_SUPPLY_PROP_SDP_CURRENT_MAX:
+		rc = smblib_set_prop_sdp_current_max(chg, val);
+		break;
 	default:
 		pr_err("set prop %d is not supported\n", psp);
 		rc = -EINVAL;
@@ -533,8 +547,6 @@
 		enum power_supply_property psp)
 {
 	switch (psp) {
-	case POWER_SUPPLY_PROP_CURRENT_MAX:
-	case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
 	case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
 		return 1;
 	default:
@@ -576,6 +588,8 @@
 static enum power_supply_property smb2_usb_port_props[] = {
 	POWER_SUPPLY_PROP_TYPE,
 	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_CURRENT_MAX,
 };
 
 static int smb2_usb_port_get_prop(struct power_supply *psy,
@@ -602,6 +616,12 @@
 		else
 			val->intval = 0;
 		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+		val->intval = 5000000;
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_MAX:
+		rc = smblib_get_prop_input_current_settled(chg, val);
+		break;
 	default:
 		pr_err_ratelimited("Get prop %d is not supported in pc_port\n",
 				psp);
@@ -780,9 +800,11 @@
  *************************/
 
 static enum power_supply_property smb2_dc_props[] = {
+	POWER_SUPPLY_PROP_INPUT_SUSPEND,
 	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_ONLINE,
 	POWER_SUPPLY_PROP_CURRENT_MAX,
+	POWER_SUPPLY_PROP_REAL_TYPE,
 };
 
 static int smb2_dc_get_prop(struct power_supply *psy,
@@ -794,6 +816,9 @@
 	int rc = 0;
 
 	switch (psp) {
+	case POWER_SUPPLY_PROP_INPUT_SUSPEND:
+		val->intval = get_effective_result(chg->dc_suspend_votable);
+		break;
 	case POWER_SUPPLY_PROP_PRESENT:
 		rc = smblib_get_prop_dc_present(chg, val);
 		break;
@@ -803,6 +828,9 @@
 	case POWER_SUPPLY_PROP_CURRENT_MAX:
 		rc = smblib_get_prop_dc_current_max(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_REAL_TYPE:
+		val->intval = POWER_SUPPLY_TYPE_WIPOWER;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -822,6 +850,10 @@
 	int rc = 0;
 
 	switch (psp) {
+	case POWER_SUPPLY_PROP_INPUT_SUSPEND:
+		rc = vote(chg->dc_suspend_votable, WBC_VOTER,
+				(bool)val->intval, 0);
+		break;
 	case POWER_SUPPLY_PROP_CURRENT_MAX:
 		rc = smblib_set_prop_dc_current_max(chg, val);
 		break;
@@ -851,7 +883,7 @@
 
 static const struct power_supply_desc dc_psy_desc = {
 	.name = "dc",
-	.type = POWER_SUPPLY_TYPE_WIPOWER,
+	.type = POWER_SUPPLY_TYPE_WIRELESS,
 	.properties = smb2_dc_props,
 	.num_properties = ARRAY_SIZE(smb2_dc_props),
 	.get_property = smb2_dc_get_prop,
@@ -909,6 +941,7 @@
 	POWER_SUPPLY_PROP_DP_DM,
 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
+	POWER_SUPPLY_PROP_CHARGE_COUNTER,
 };
 
 static int smb2_batt_get_prop(struct power_supply *psy,
@@ -1009,7 +1042,10 @@
 		val->intval = 0;
 		break;
 	case POWER_SUPPLY_PROP_DIE_HEALTH:
-		rc = smblib_get_prop_die_health(chg, val);
+		if (chg->die_health == -EINVAL)
+			rc = smblib_get_prop_die_health(chg, val);
+		else
+			val->intval = chg->die_health;
 		break;
 	case POWER_SUPPLY_PROP_DP_DM:
 		val->intval = chg->pulse_cnt;
@@ -1017,6 +1053,9 @@
 	case POWER_SUPPLY_PROP_RERUN_AICL:
 		val->intval = 0;
 		break;
+	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
+		rc = smblib_get_prop_batt_charge_counter(chg, val);
+		break;
 	default:
 		pr_err("batt power supply prop %d not supported\n", psp);
 		return -EINVAL;
@@ -1061,14 +1100,8 @@
 		rc = smblib_set_prop_charge_qnovo_enable(chg, val);
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_QNOVO:
-		if (val->intval == -EINVAL) {
-			vote(chg->fv_votable, BATT_PROFILE_VOTER,
-					true, chg->batt_profile_fv_uv);
-			vote(chg->fv_votable, QNOVO_VOTER, false, 0);
-		} else {
-			vote(chg->fv_votable, QNOVO_VOTER, true, val->intval);
-			vote(chg->fv_votable, BATT_PROFILE_VOTER, false, 0);
-		}
+		vote(chg->fv_votable, QNOVO_VOTER,
+			(val->intval >= 0), val->intval);
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
 		vote(chg->pl_disable_votable, PL_QNOVO_VOTER,
@@ -1114,6 +1147,10 @@
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
 		rc = smblib_set_prop_input_current_limited(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_DIE_HEALTH:
+		chg->die_health = val->intval;
+		power_supply_changed(chg->batt_psy);
+		break;
 	default:
 		rc = -EINVAL;
 	}
@@ -1135,6 +1172,7 @@
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
 	case POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED:
 	case POWER_SUPPLY_PROP_SW_JEITA_ENABLED:
+	case POWER_SUPPLY_PROP_DIE_HEALTH:
 		return 1;
 	default:
 		break;
@@ -1176,7 +1214,7 @@
  * VBUS REGULATOR REGISTRATION *
  ******************************/
 
-struct regulator_ops smb2_vbus_reg_ops = {
+static struct regulator_ops smb2_vbus_reg_ops = {
 	.enable = smblib_vbus_regulator_enable,
 	.disable = smblib_vbus_regulator_disable,
 	.is_enabled = smblib_vbus_regulator_is_enabled,
@@ -1218,7 +1256,7 @@
  * VCONN REGULATOR REGISTRATION *
  ******************************/
 
-struct regulator_ops smb2_vconn_reg_ops = {
+static struct regulator_ops smb2_vconn_reg_ops = {
 	.enable = smblib_vconn_regulator_enable,
 	.disable = smblib_vconn_regulator_disable,
 	.is_enabled = smblib_vconn_regulator_is_enabled,
@@ -1616,15 +1654,6 @@
 		return rc;
 	}
 
-	/* disable SW STAT override */
-	rc = smblib_masked_write(chg, STAT_CFG_REG,
-				 STAT_SW_OVERRIDE_CFG_BIT, 0);
-	if (rc < 0) {
-		dev_err(chg->dev, "Couldn't disable SW STAT override rc=%d\n",
-			rc);
-		return rc;
-	}
-
 	/* disable h/w autonomous parallel charging control */
 	rc = smblib_masked_write(chg, MISC_CFG_REG,
 				 STAT_PARALLEL_1400MA_EN_CFG_BIT, 0);
@@ -1807,8 +1836,8 @@
 		chip->chg.wa_flags |= BOOST_BACK_WA | OTG_WA;
 		chg->param.freq_buck = pm660_params.freq_buck;
 		chg->param.freq_boost = pm660_params.freq_boost;
-		chg->chg_freq.freq_5V		= 600;
-		chg->chg_freq.freq_6V_8V	= 800;
+		chg->chg_freq.freq_5V		= 650;
+		chg->chg_freq.freq_6V_8V	= 850;
 		chg->chg_freq.freq_9V		= 1050;
 		chg->chg_freq.freq_12V		= 1200;
 		chg->chg_freq.freq_removal	= 1050;
@@ -2213,9 +2242,11 @@
 	chg->dev = &pdev->dev;
 	chg->param = v1_params;
 	chg->debug_mask = &__debug_mask;
+	chg->try_sink_enabled = &__try_sink_enabled;
 	chg->weak_chg_icl_ua = &__weak_chg_icl_ua;
 	chg->mode = PARALLEL_MASTER;
 	chg->irq_info = smb2_irqs;
+	chg->die_health = -EINVAL;
 	chg->name = "PMI";
 
 	chg->regmap = dev_get_regmap(chg->dev->parent, NULL);
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index cc3bd93..52fcd7f 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -143,6 +143,23 @@
 	return rc;
 }
 
+int smblib_stat_sw_override_cfg(struct smb_charger *chg, bool override)
+{
+	int rc;
+
+	/* override  = 1, SW STAT override; override = 0, HW auto mode */
+	rc = smblib_masked_write(chg, STAT_CFG_REG,
+				STAT_SW_OVERRIDE_CFG_BIT,
+				override ? STAT_SW_OVERRIDE_CFG_BIT : 0);
+	if (rc < 0) {
+		dev_err(chg->dev, "Couldn't configure SW STAT override rc=%d\n",
+			rc);
+		return rc;
+	}
+
+	return rc;
+}
+
 /********************
  * REGISTER GETTERS *
  ********************/
@@ -419,19 +436,21 @@
 {
 	int rc = 0;
 
-	switch (allowed_voltage) {
-	case USBIN_ADAPTER_ALLOW_12V:
-	case USBIN_ADAPTER_ALLOW_5V_OR_12V:
-	case USBIN_ADAPTER_ALLOW_9V_TO_12V:
-	case USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V:
-	case USBIN_ADAPTER_ALLOW_5V_TO_12V:
-		/* PM660 only support max. 9V */
-		if (chg->smb_version == PM660_SUBTYPE) {
-			smblib_dbg(chg, PR_MISC, "voltage not supported=%d\n",
-					allowed_voltage);
+	/* PM660 only support max. 9V */
+	if (chg->smb_version == PM660_SUBTYPE) {
+		switch (allowed_voltage) {
+		case USBIN_ADAPTER_ALLOW_12V:
+		case USBIN_ADAPTER_ALLOW_9V_TO_12V:
+			allowed_voltage = USBIN_ADAPTER_ALLOW_9V;
+			break;
+		case USBIN_ADAPTER_ALLOW_5V_OR_12V:
+		case USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V:
+			allowed_voltage = USBIN_ADAPTER_ALLOW_5V_OR_9V;
+			break;
+		case USBIN_ADAPTER_ALLOW_5V_TO_12V:
 			allowed_voltage = USBIN_ADAPTER_ALLOW_5V_TO_9V;
+			break;
 		}
-		break;
 	}
 
 	rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage);
@@ -582,8 +601,10 @@
 			schedule_work(&chg->bms_update_work);
 	}
 
-	if (!chg->pl.psy && !strcmp(psy->desc->name, "parallel"))
+	if (!chg->pl.psy && !strcmp(psy->desc->name, "parallel")) {
 		chg->pl.psy = psy;
+		schedule_work(&chg->pl_update_work);
+	}
 
 	return NOTIFY_OK;
 }
@@ -889,7 +910,7 @@
 	bool override;
 
 	/* suspend and return if 25mA or less is requested */
-	if (icl_ua < USBIN_25MA)
+	if (icl_ua <= USBIN_25MA)
 		return smblib_set_usb_suspend(chg, true);
 
 	if (icl_ua == INT_MAX)
@@ -1015,7 +1036,7 @@
 		icl_ua = 0;
 	}
 
-	suspend = (icl_ua < USBIN_25MA);
+	suspend = (icl_ua <= USBIN_25MA);
 	if (suspend)
 		goto suspend;
 
@@ -1855,6 +1876,19 @@
 	return 0;
 }
 
+int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
+				     union power_supply_propval *val)
+{
+	int rc;
+
+	if (!chg->bms_psy)
+		return -EINVAL;
+
+	rc = power_supply_get_property(chg->bms_psy,
+				       POWER_SUPPLY_PROP_CHARGE_COUNTER, val);
+	return rc;
+}
+
 /***********************
  * BATTERY PSY SETTERS *
  ***********************/
@@ -2213,15 +2247,28 @@
 	return rc;
 }
 
+int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
+				    union power_supply_propval *val)
+{
+	switch (chg->real_charger_type) {
+	case POWER_SUPPLY_TYPE_USB_HVDCP:
+	case POWER_SUPPLY_TYPE_USB_PD:
+		if (chg->smb_version == PM660_SUBTYPE)
+			val->intval = MICRO_9V;
+		else
+			val->intval = MICRO_12V;
+		break;
+	default:
+		val->intval = MICRO_5V;
+		break;
+	}
+
+	return 0;
+}
+
 int smblib_get_prop_usb_voltage_now(struct smb_charger *chg,
 				    union power_supply_propval *val)
 {
-	int rc = 0;
-
-	rc = smblib_get_prop_usb_present(chg, val);
-	if (rc < 0 || !val->intval)
-		return rc;
-
 	if (!chg->iio.usbin_v_chan ||
 		PTR_ERR(chg->iio.usbin_v_chan) == -EPROBE_DEFER)
 		chg->iio.usbin_v_chan = iio_channel_get(chg->dev, "usbin_v");
@@ -2232,21 +2279,6 @@
 	return iio_read_channel_processed(chg->iio.usbin_v_chan, &val->intval);
 }
 
-int smblib_get_prop_pd_current_max(struct smb_charger *chg,
-				    union power_supply_propval *val)
-{
-	val->intval = get_client_vote_locked(chg->usb_icl_votable, PD_VOTER);
-	return 0;
-}
-
-int smblib_get_prop_usb_current_max(struct smb_charger *chg,
-				    union power_supply_propval *val)
-{
-	val->intval = get_client_vote_locked(chg->usb_icl_votable,
-			USB_PSY_VOTER);
-	return 0;
-}
-
 int smblib_get_prop_usb_current_now(struct smb_charger *chg,
 				    union power_supply_propval *val)
 {
@@ -2584,7 +2616,7 @@
 	return rc;
 }
 
-int smblib_set_prop_usb_current_max(struct smb_charger *chg,
+int smblib_set_prop_sdp_current_max(struct smb_charger *chg,
 				    const union power_supply_propval *val)
 {
 	int rc = 0;
@@ -2671,7 +2703,7 @@
 	return rc;
 }
 
-int smblib_set_prop_usb_voltage_min(struct smb_charger *chg,
+int smblib_set_prop_pd_voltage_min(struct smb_charger *chg,
 				    const union power_supply_propval *val)
 {
 	int rc, min_uv;
@@ -2690,7 +2722,7 @@
 	return rc;
 }
 
-int smblib_set_prop_usb_voltage_max(struct smb_charger *chg,
+int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
 				    const union power_supply_propval *val)
 {
 	int rc, max_uv;
@@ -2779,7 +2811,7 @@
 		hvdcp = stat & QC_CHARGER_BIT;
 		vote(chg->apsd_disable_votable, PD_VOTER, false, 0);
 		vote(chg->pd_allowed_votable, PD_VOTER, true, 0);
-		vote(chg->usb_irq_enable_votable, PD_VOTER, true, 0);
+		vote(chg->usb_irq_enable_votable, PD_VOTER, false, 0);
 		vote(chg->hvdcp_disable_votable_indirect, PD_INACTIVE_VOTER,
 								false, 0);
 
@@ -3339,6 +3371,10 @@
 		vote(chg->awake_votable, PL_DELAY_VOTER, true, 0);
 		schedule_delayed_work(&chg->pl_enable_work,
 					msecs_to_jiffies(PL_DELAY_MS));
+		/* vbus rising when APSD was disabled and PD_ACTIVE = 0 */
+		if (get_effective_result(chg->apsd_disable_votable) &&
+				!chg->pd_active)
+			pr_err("APSD disabled on vbus rising without PD\n");
 	} else {
 		if (chg->wa_flags & BOOST_BACK_WA) {
 			data = chg->irq_info[SWITCH_POWER_OK_IRQ].irq_data;
@@ -3623,6 +3659,37 @@
 	}
 }
 
+static void smblib_notify_extcon_props(struct smb_charger *chg, int id)
+{
+	union extcon_property_value val;
+	union power_supply_propval prop_val;
+
+	smblib_get_prop_typec_cc_orientation(chg, &prop_val);
+	val.intval = ((prop_val.intval == 2) ? 1 : 0);
+	extcon_set_property(chg->extcon, id,
+				EXTCON_PROP_USB_TYPEC_POLARITY, val);
+
+	val.intval = true;
+	extcon_set_property(chg->extcon, id,
+				EXTCON_PROP_USB_SS, val);
+}
+
+static void smblib_notify_device_mode(struct smb_charger *chg, bool enable)
+{
+	if (enable)
+		smblib_notify_extcon_props(chg, EXTCON_USB);
+
+	extcon_set_state_sync(chg->extcon, EXTCON_USB, enable);
+}
+
+static void smblib_notify_usb_host(struct smb_charger *chg, bool enable)
+{
+	if (enable)
+		smblib_notify_extcon_props(chg, EXTCON_USB_HOST);
+
+	extcon_set_state_sync(chg->extcon, EXTCON_USB_HOST, enable);
+}
+
 #define HVDCP_DET_MS 2500
 static void smblib_handle_apsd_done(struct smb_charger *chg, bool rising)
 {
@@ -3645,6 +3712,8 @@
 		/* if not DCP then no hvdcp timeout happens. Enable pd here */
 		vote(chg->pd_disallowed_votable_indirect, HVDCP_TIMEOUT_VOTER,
 				false, 0);
+		if (chg->use_extcon)
+			smblib_notify_device_mode(chg, true);
 		break;
 	case OCP_CHARGER_BIT:
 	case FLOAT_CHARGER_BIT:
@@ -3723,13 +3792,174 @@
 	return IRQ_HANDLED;
 }
 
+static int typec_try_sink(struct smb_charger *chg)
+{
+	union power_supply_propval val;
+	bool debounce_done, vbus_detected, sink;
+	u8 stat;
+	int exit_mode = ATTACHED_SRC, rc;
+
+	/* ignore typec interrupt while try.snk WIP */
+	chg->try_sink_active = true;
+
+	/* force SNK mode */
+	val.intval = POWER_SUPPLY_TYPEC_PR_SINK;
+	rc = smblib_set_prop_typec_power_role(chg, &val);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't set UFP mode rc=%d\n", rc);
+		goto try_sink_exit;
+	}
+
+	/* reduce Tccdebounce time to ~20ms */
+	rc = smblib_masked_write(chg, MISC_CFG_REG,
+			TCC_DEBOUNCE_20MS_BIT, TCC_DEBOUNCE_20MS_BIT);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't set MISC_CFG_REG rc=%d\n", rc);
+		goto try_sink_exit;
+	}
+
+	/*
+	 * give opportunity to the other side to be a SRC,
+	 * for tDRPTRY + Tccdebounce time
+	 */
+	msleep(100);
+
+	rc = smblib_read(chg, TYPE_C_STATUS_4_REG, &stat);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't read TYPE_C_STATUS_4 rc=%d\n",
+				rc);
+		goto try_sink_exit;
+	}
+
+	debounce_done = stat & TYPEC_DEBOUNCE_DONE_STATUS_BIT;
+
+	if (!debounce_done)
+		/*
+		 * The other side didn't switch to source, either it
+		 * is an adamant sink or is removed go back to showing Rp
+		 */
+		goto try_wait_src;
+
+	/*
+	 * We are in force sink mode and the other side has switched to
+	 * showing Rp. Config DRP in case the other side removes Rp so we
+	 * can quickly (20ms) switch to showing our Rp. Note that the spec
+	 * needs us to show Rp for 80mS while the drp DFP residency is just
+	 * 54mS. But 54mS is plenty time for us to react and force Rp for
+	 * the remaining 26mS.
+	 */
+	val.intval = POWER_SUPPLY_TYPEC_PR_DUAL;
+	rc = smblib_set_prop_typec_power_role(chg, &val);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't set DFP mode rc=%d\n",
+				rc);
+		goto try_sink_exit;
+	}
+
+	/*
+	 * while other side is Rp, wait for VBUS from it; exit if other side
+	 * removes Rp
+	 */
+	do {
+		rc = smblib_read(chg, TYPE_C_STATUS_4_REG, &stat);
+		if (rc < 0) {
+			smblib_err(chg, "Couldn't read TYPE_C_STATUS_4 rc=%d\n",
+					rc);
+			goto try_sink_exit;
+		}
+
+		debounce_done = stat & TYPEC_DEBOUNCE_DONE_STATUS_BIT;
+		vbus_detected = stat & TYPEC_VBUS_STATUS_BIT;
+
+		/* Successfully transitioned to ATTACHED.SNK */
+		if (vbus_detected && debounce_done) {
+			exit_mode = ATTACHED_SINK;
+			goto try_sink_exit;
+		}
+
+		/*
+		 * Ensure sink since drp may put us in source if other
+		 * side switches back to Rd
+		 */
+		sink = !(stat &  UFP_DFP_MODE_STATUS_BIT);
+
+		usleep_range(1000, 2000);
+	} while (debounce_done && sink);
+
+try_wait_src:
+	/*
+	 * Transition to trywait.SRC state. check if other side still wants
+	 * to be SNK or has been removed.
+	 */
+	val.intval = POWER_SUPPLY_TYPEC_PR_SOURCE;
+	rc = smblib_set_prop_typec_power_role(chg, &val);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't set UFP mode rc=%d\n", rc);
+		goto try_sink_exit;
+	}
+
+	/* Need to be in this state for tDRPTRY time, 75ms~150ms */
+	msleep(80);
+
+	rc = smblib_read(chg, TYPE_C_STATUS_4_REG, &stat);
+	if (rc < 0) {
+		smblib_err(chg, "Couldn't read TYPE_C_STATUS_4 rc=%d\n", rc);
+		goto try_sink_exit;
+	}
+
+	debounce_done = stat & TYPEC_DEBOUNCE_DONE_STATUS_BIT;
+
+	if (debounce_done)
+		/* the other side wants to be a sink */
+		exit_mode = ATTACHED_SRC;
+	else
+		/* the other side is detached */
+		exit_mode = UNATTACHED_SINK;
+
+try_sink_exit:
+	/* release forcing of SRC/SNK mode */
+	val.intval = POWER_SUPPLY_TYPEC_PR_DUAL;
+	rc = smblib_set_prop_typec_power_role(chg, &val);
+	if (rc < 0)
+		smblib_err(chg, "Couldn't set DFP mode rc=%d\n", rc);
+
+	/* revert Tccdebounce time back to ~120ms */
+	rc = smblib_masked_write(chg, MISC_CFG_REG, TCC_DEBOUNCE_20MS_BIT, 0);
+	if (rc < 0)
+		smblib_err(chg, "Couldn't set MISC_CFG_REG rc=%d\n", rc);
+
+	chg->try_sink_active = false;
+
+	return exit_mode;
+}
+
 static void typec_sink_insertion(struct smb_charger *chg)
 {
+	int exit_mode;
+
+	/*
+	 * Try.SNK entry status - ATTACHWAIT.SRC state and detected Rd-open
+	 * or RD-Ra for TccDebounce time.
+	 */
+
+	if (*chg->try_sink_enabled) {
+		exit_mode = typec_try_sink(chg);
+
+		if (exit_mode != ATTACHED_SRC) {
+			smblib_usb_typec_change(chg);
+			return;
+		}
+	}
+
 	/* when a sink is inserted we should not wait on hvdcp timeout to
 	 * enable pd
 	 */
 	vote(chg->pd_disallowed_votable_indirect, HVDCP_TIMEOUT_VOTER,
 			false, 0);
+	if (chg->use_extcon) {
+		smblib_notify_usb_host(chg, true);
+		chg->otg_present = true;
+	}
 }
 
 static void typec_sink_removal(struct smb_charger *chg)
@@ -3793,7 +4023,7 @@
 
 	/* reset parallel voters */
 	vote(chg->pl_disable_votable, PL_DELAY_VOTER, true, 0);
-	vote(chg->pl_disable_votable, FCC_CHANGE_VOTER, false, 0);
+	vote(chg->pl_disable_votable, PL_FCC_LOW_VOTER, false, 0);
 	vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0);
 	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
 	vote(chg->awake_votable, PL_DELAY_VOTER, false, 0);
@@ -3880,6 +4110,14 @@
 
 	typec_sink_removal(chg);
 	smblib_update_usb_type(chg);
+
+	if (chg->use_extcon) {
+		if (chg->otg_present)
+			smblib_notify_usb_host(chg, false);
+		else
+			smblib_notify_device_mode(chg, false);
+	}
+	chg->otg_present = false;
 }
 
 static void smblib_handle_typec_insertion(struct smb_charger *chg)
@@ -3979,7 +4217,7 @@
 				smblib_typec_mode_name[chg->typec_mode]);
 }
 
-static void smblib_usb_typec_change(struct smb_charger *chg)
+void smblib_usb_typec_change(struct smb_charger *chg)
 {
 	int rc;
 
@@ -4015,7 +4253,8 @@
 		return IRQ_HANDLED;
 	}
 
-	if (chg->cc2_detach_wa_active || chg->typec_en_dis_active) {
+	if (chg->cc2_detach_wa_active || chg->typec_en_dis_active ||
+					 chg->try_sink_active) {
 		smblib_dbg(chg, PR_INTERRUPT, "Ignoring since %s active\n",
 			chg->cc2_detach_wa_active ?
 			"cc2_detach_wa" : "typec_en_dis");
@@ -4049,6 +4288,14 @@
 	struct smb_charger *chg = irq_data->parent_data;
 
 	chg->is_hdc = true;
+	/*
+	 * Disable usb IRQs after the flag set and re-enable IRQs after
+	 * the flag cleared in the delayed work queue, to avoid any IRQ
+	 * storming during the delays
+	 */
+	if (chg->irq_info[HIGH_DUTY_CYCLE_IRQ].irq)
+		disable_irq_nosync(chg->irq_info[HIGH_DUTY_CYCLE_IRQ].irq);
+
 	schedule_delayed_work(&chg->clear_hdc_work, msecs_to_jiffies(60));
 
 	return IRQ_HANDLED;
@@ -4085,7 +4332,7 @@
 
 	/* skip suspending input if its already suspended by some other voter */
 	usb_icl = get_effective_result(chg->usb_icl_votable);
-	if ((stat & USE_USBIN_BIT) && usb_icl >= 0 && usb_icl < USBIN_25MA)
+	if ((stat & USE_USBIN_BIT) && usb_icl >= 0 && usb_icl <= USBIN_25MA)
 		return IRQ_HANDLED;
 
 	if (stat & USE_DCIN_BIT)
@@ -4220,12 +4467,22 @@
 		power_supply_changed(chg->batt_psy);
 }
 
+static void pl_update_work(struct work_struct *work)
+{
+	struct smb_charger *chg = container_of(work, struct smb_charger,
+						pl_update_work);
+
+	smblib_stat_sw_override_cfg(chg, false);
+}
+
 static void clear_hdc_work(struct work_struct *work)
 {
 	struct smb_charger *chg = container_of(work, struct smb_charger,
 						clear_hdc_work.work);
 
 	chg->is_hdc = 0;
+	if (chg->irq_info[HIGH_DUTY_CYCLE_IRQ].irq)
+		enable_irq(chg->irq_info[HIGH_DUTY_CYCLE_IRQ].irq);
 }
 
 static void rdstd_cc2_detach_work(struct work_struct *work)
@@ -4750,6 +5007,7 @@
 	mutex_init(&chg->otg_oc_lock);
 	mutex_init(&chg->vconn_oc_lock);
 	INIT_WORK(&chg->bms_update_work, bms_update_work);
+	INIT_WORK(&chg->pl_update_work, pl_update_work);
 	INIT_WORK(&chg->rdstd_cc2_detach_work, rdstd_cc2_detach_work);
 	INIT_DELAYED_WORK(&chg->hvdcp_detect_work, smblib_hvdcp_detect_work);
 	INIT_DELAYED_WORK(&chg->clear_hdc_work, clear_hdc_work);
@@ -4798,6 +5056,14 @@
 
 		chg->bms_psy = power_supply_get_by_name("bms");
 		chg->pl.psy = power_supply_get_by_name("parallel");
+		if (chg->pl.psy) {
+			rc = smblib_stat_sw_override_cfg(chg, false);
+			if (rc < 0) {
+				smblib_err(chg,
+					"Couldn't config stat sw rc=%d\n", rc);
+				return rc;
+			}
+		}
 		break;
 	case PARALLEL_SLAVE:
 		break;
@@ -4814,6 +5080,7 @@
 	switch (chg->mode) {
 	case PARALLEL_MASTER:
 		cancel_work_sync(&chg->bms_update_work);
+		cancel_work_sync(&chg->pl_update_work);
 		cancel_work_sync(&chg->rdstd_cc2_detach_work);
 		cancel_delayed_work_sync(&chg->hvdcp_detect_work);
 		cancel_delayed_work_sync(&chg->clear_hdc_work);
diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h
index bfc5cae..1046b27 100644
--- a/drivers/power/supply/qcom/smb-lib.h
+++ b/drivers/power/supply/qcom/smb-lib.h
@@ -66,7 +66,8 @@
 #define USBIN_I_VOTER			"USBIN_I_VOTER"
 #define WEAK_CHARGER_VOTER		"WEAK_CHARGER_VOTER"
 #define OTG_VOTER			"OTG_VOTER"
-#define FCC_CHANGE_VOTER		"FCC_CHANGE_VOTER"
+#define PL_FCC_LOW_VOTER		"PL_FCC_LOW_VOTER"
+#define WBC_VOTER			"WBC_VOTER"
 
 #define VCONN_MAX_ATTEMPTS	3
 #define OTG_MAX_ATTEMPTS	3
@@ -129,6 +130,12 @@
 	SMB_IRQ_MAX,
 };
 
+enum try_sink_exit_mode {
+	ATTACHED_SRC = 0,
+	ATTACHED_SINK,
+	UNATTACHED_SINK,
+};
+
 struct smb_irq_info {
 	const char			*name;
 	const irq_handler_t		handler;
@@ -144,6 +151,9 @@
 	EXTCON_NONE,
 };
 
+/* EXTCON_USB and EXTCON_USB_HOST are mutually exclusive */
+static const u32 smblib_extcon_exclusive[] = {0x3, 0};
+
 struct smb_regulator {
 	struct regulator_dev	*rdev;
 	struct regulator_desc	rdesc;
@@ -228,6 +238,7 @@
 	struct smb_params	param;
 	struct smb_iio		iio;
 	int			*debug_mask;
+	int			*try_sink_enabled;
 	enum smb_mode		mode;
 	struct smb_chg_freq	chg_freq;
 	int			smb_version;
@@ -283,6 +294,7 @@
 
 	/* work */
 	struct work_struct	bms_update_work;
+	struct work_struct	pl_update_work;
 	struct work_struct	rdstd_cc2_detach_work;
 	struct delayed_work	hvdcp_detect_work;
 	struct delayed_work	ps_change_timeout_work;
@@ -331,11 +343,14 @@
 	int			usb_icl_change_irq_enabled;
 	u32			jeita_status;
 	u8			float_cfg;
+	bool			use_extcon;
+	bool			otg_present;
 
 	/* workaround flag */
 	u32			wa_flags;
 	bool			cc2_detach_wa_active;
 	bool			typec_en_dis_active;
+	bool			try_sink_active;
 	int			boost_current_ua;
 	int			temp_speed_reading_count;
 
@@ -349,6 +364,8 @@
 	/* qnovo */
 	int			usb_icl_delta_ua;
 	int			pulse_cnt;
+
+	int			die_health;
 };
 
 int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
@@ -424,6 +441,8 @@
 				union power_supply_propval *val);
 int smblib_get_prop_batt_temp(struct smb_charger *chg,
 				union power_supply_propval *val);
+int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
+				union power_supply_propval *val);
 int smblib_set_prop_input_suspend(struct smb_charger *chg,
 				const union power_supply_propval *val);
 int smblib_set_prop_batt_capacity(struct smb_charger *chg,
@@ -450,12 +469,10 @@
 				union power_supply_propval *val);
 int smblib_get_prop_usb_suspend(struct smb_charger *chg,
 				union power_supply_propval *val);
+int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
+				union power_supply_propval *val);
 int smblib_get_prop_usb_voltage_now(struct smb_charger *chg,
 				union power_supply_propval *val);
-int smblib_get_prop_pd_current_max(struct smb_charger *chg,
-				union power_supply_propval *val);
-int smblib_get_prop_usb_current_max(struct smb_charger *chg,
-				union power_supply_propval *val);
 int smblib_get_prop_usb_current_now(struct smb_charger *chg,
 				union power_supply_propval *val);
 int smblib_get_prop_typec_cc_orientation(struct smb_charger *chg,
@@ -482,11 +499,11 @@
 			       union power_supply_propval *val);
 int smblib_set_prop_pd_current_max(struct smb_charger *chg,
 				const union power_supply_propval *val);
-int smblib_set_prop_usb_current_max(struct smb_charger *chg,
+int smblib_set_prop_sdp_current_max(struct smb_charger *chg,
 				const union power_supply_propval *val);
-int smblib_set_prop_usb_voltage_min(struct smb_charger *chg,
+int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
 				const union power_supply_propval *val);
-int smblib_set_prop_usb_voltage_max(struct smb_charger *chg,
+int smblib_set_prop_pd_voltage_min(struct smb_charger *chg,
 				const union power_supply_propval *val);
 int smblib_set_prop_boost_current(struct smb_charger *chg,
 				const union power_supply_propval *val);
@@ -517,6 +534,8 @@
 				union power_supply_propval *val);
 int smblib_set_prop_pr_swap_in_progress(struct smb_charger *chg,
 				const union power_supply_propval *val);
+int smblib_stat_sw_override_cfg(struct smb_charger *chg, bool override);
+void smblib_usb_typec_change(struct smb_charger *chg);
 
 int smblib_init(struct smb_charger *chg);
 int smblib_deinit(struct smb_charger *chg);
diff --git a/drivers/power/supply/qcom/smb1351-charger.c b/drivers/power/supply/qcom/smb1351-charger.c
index a464a81..4b2e9c8 100644
--- a/drivers/power/supply/qcom/smb1351-charger.c
+++ b/drivers/power/supply/qcom/smb1351-charger.c
@@ -861,7 +861,7 @@
 	return (reg & CMD_OTG_EN_BIT) ? 1 : 0;
 }
 
-struct regulator_ops smb1351_chg_otg_reg_ops = {
+static struct regulator_ops smb1351_chg_otg_reg_ops = {
 	.enable		= smb1351_chg_otg_regulator_enable,
 	.disable	= smb1351_chg_otg_regulator_disable,
 	.is_enabled	= smb1351_chg_otg_regulator_is_enable,
diff --git a/drivers/power/supply/qcom/smb1355-charger.c b/drivers/power/supply/qcom/smb1355-charger.c
index 4e1bb17..4b42420 100644
--- a/drivers/power/supply/qcom/smb1355-charger.c
+++ b/drivers/power/supply/qcom/smb1355-charger.c
@@ -146,6 +146,8 @@
 
 	struct power_supply	*parallel_psy;
 	struct pmic_revid_data	*pmic_rev_id;
+
+	int			c_health;
 };
 
 static bool is_secure(struct smb1355 *chip, int addr)
@@ -434,7 +436,10 @@
 		val->intval = POWER_SUPPLY_PL_USBMID_USBMID;
 		break;
 	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
-		val->intval = smb1355_get_prop_connector_health(chip);
+		if (chip->c_health == -EINVAL)
+			val->intval = smb1355_get_prop_connector_health(chip);
+		else
+			val->intval = chip->c_health;
 		break;
 	default:
 		pr_err_ratelimited("parallel psy get prop %d not supported\n",
@@ -497,6 +502,10 @@
 		rc = smb1355_set_charge_param(chip, &chip->param.fcc,
 						val->intval);
 		break;
+	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
+		chip->c_health = val->intval;
+		power_supply_changed(chip->parallel_psy);
+		break;
 	default:
 		pr_debug("parallel power supply set prop %d not supported\n",
 			prop);
@@ -509,6 +518,13 @@
 static int smb1355_parallel_prop_is_writeable(struct power_supply *psy,
 					      enum power_supply_property prop)
 {
+	switch (prop) {
+	case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
+		return 1;
+	default:
+		break;
+	}
+
 	return 0;
 }
 
@@ -613,6 +629,7 @@
 	[0] = {
 		.name		= "wdog-bark",
 		.handler	= smb1355_handle_wdog_bark,
+		.wake		= true,
 	},
 	[1] = {
 		.name		= "chg-state-change",
@@ -713,6 +730,7 @@
 
 	chip->dev = &pdev->dev;
 	chip->param = v1_params;
+	chip->c_health = -EINVAL;
 	chip->name = "smb1355";
 	mutex_init(&chip->write_lock);
 
@@ -762,14 +780,26 @@
 	return 0;
 }
 
+static void smb1355_shutdown(struct platform_device *pdev)
+{
+	struct smb1355 *chip = platform_get_drvdata(pdev);
+	int rc;
+
+	/* disable parallel charging path */
+	rc = smb1355_set_parallel_charging(chip, true);
+	if (rc < 0)
+		pr_err("Couldn't disable parallel path rc=%d\n", rc);
+}
+
 static struct platform_driver smb1355_driver = {
 	.driver	= {
 		.name		= "qcom,smb1355-charger",
 		.owner		= THIS_MODULE,
 		.of_match_table	= match_table,
 	},
-	.probe	= smb1355_probe,
-	.remove	= smb1355_remove,
+	.probe		= smb1355_probe,
+	.remove		= smb1355_remove,
+	.shutdown	= smb1355_shutdown,
 };
 module_platform_driver(smb1355_driver);
 
diff --git a/drivers/power/supply/qcom/smb135x-charger.c b/drivers/power/supply/qcom/smb135x-charger.c
index 803dd6e..edc0998 100644
--- a/drivers/power/supply/qcom/smb135x-charger.c
+++ b/drivers/power/supply/qcom/smb135x-charger.c
@@ -2218,7 +2218,7 @@
 	return  (reg & OTG_EN) ? 1 : 0;
 }
 
-struct regulator_ops smb135x_chg_otg_reg_ops = {
+static struct regulator_ops smb135x_chg_otg_reg_ops = {
 	.enable		= smb135x_chg_otg_regulator_enable,
 	.disable	= smb135x_chg_otg_regulator_disable,
 	.is_enabled	= smb135x_chg_otg_regulator_is_enable,
diff --git a/drivers/power/supply/qcom/smb138x-charger.c b/drivers/power/supply/qcom/smb138x-charger.c
index 20f1838..28c3512 100644
--- a/drivers/power/supply/qcom/smb138x-charger.c
+++ b/drivers/power/supply/qcom/smb138x-charger.c
@@ -111,7 +111,7 @@
 	debug_mask, __debug_mask, int, 0600
 );
 
-irqreturn_t smb138x_handle_slave_chg_state_change(int irq, void *data)
+static irqreturn_t smb138x_handle_slave_chg_state_change(int irq, void *data)
 {
 	struct smb_irq_data *irq_data = data;
 	struct smb138x *chip = irq_data->parent_data;
@@ -170,6 +170,9 @@
 	chip->dt.suspend_input = of_property_read_bool(node,
 				"qcom,suspend-input");
 
+	chg->use_extcon = of_property_read_bool(node,
+				"qcom,use-extcon");
+
 	rc = of_property_read_u32(node,
 				"qcom,fcc-max-ua", &chip->dt.fcc_ua);
 	if (rc < 0)
@@ -215,6 +218,7 @@
 	POWER_SUPPLY_PROP_TYPEC_MODE,
 	POWER_SUPPLY_PROP_TYPEC_POWER_ROLE,
 	POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION,
+	POWER_SUPPLY_PROP_SDP_CURRENT_MAX,
 };
 
 static int smb138x_usb_get_prop(struct power_supply *psy,
@@ -242,7 +246,7 @@
 		rc = smblib_get_prop_usb_voltage_now(chg, val);
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_MAX:
-		rc = smblib_get_prop_usb_current_max(chg, val);
+		val->intval = get_effective_result(chg->usb_icl_votable);
 		break;
 	case POWER_SUPPLY_PROP_TYPE:
 		val->intval = chg->usb_psy_desc.type;
@@ -256,6 +260,10 @@
 	case POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION:
 		rc = smblib_get_prop_typec_cc_orientation(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_SDP_CURRENT_MAX:
+		val->intval = get_client_vote(chg->usb_icl_votable,
+					      USB_PSY_VOTER);
+		break;
 	default:
 		pr_err("get prop %d is not supported\n", prop);
 		return -EINVAL;
@@ -278,18 +286,12 @@
 	int rc = 0;
 
 	switch (prop) {
-	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
-		rc = smblib_set_prop_usb_voltage_min(chg, val);
-		break;
-	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
-		rc = smblib_set_prop_usb_voltage_max(chg, val);
-		break;
-	case POWER_SUPPLY_PROP_CURRENT_MAX:
-		rc = smblib_set_prop_usb_current_max(chg, val);
-		break;
 	case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
 		rc = smblib_set_prop_typec_power_role(chg, val);
 		break;
+	case POWER_SUPPLY_PROP_SDP_CURRENT_MAX:
+		rc = smblib_set_prop_sdp_current_max(chg, val);
+		break;
 	default:
 		pr_err("set prop %d is not supported\n", prop);
 		return -EINVAL;
@@ -301,13 +303,6 @@
 static int smb138x_usb_prop_is_writeable(struct power_supply *psy,
 					 enum power_supply_property prop)
 {
-	switch (prop) {
-	case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
-		return 1;
-	default:
-		break;
-	}
-
 	return 0;
 }
 
@@ -735,7 +730,7 @@
  * VBUS REGULATOR REGISTRATION *
  ******************************/
 
-struct regulator_ops smb138x_vbus_reg_ops = {
+static struct regulator_ops smb138x_vbus_reg_ops = {
 	.enable		= smblib_vbus_regulator_enable,
 	.disable	= smblib_vbus_regulator_disable,
 	.is_enabled	= smblib_vbus_regulator_is_enabled,
@@ -777,7 +772,7 @@
  * VCONN REGULATOR REGISTRATION *
  ******************************/
 
-struct regulator_ops smb138x_vconn_reg_ops = {
+static struct regulator_ops smb138x_vconn_reg_ops = {
 	.enable		= smblib_vconn_regulator_enable,
 	.disable	= smblib_vconn_regulator_disable,
 	.is_enabled	= smblib_vconn_regulator_is_enabled,
@@ -871,6 +866,13 @@
 		return rc;
 	}
 
+	/* Disable OTG */
+	rc = smblib_masked_write(chg, CMD_OTG_REG, OTG_EN_BIT, 0);
+	if (rc < 0) {
+		pr_err("Couldn't disable OTG rc=%d\n", rc);
+		return rc;
+	}
+
 	/* suspend parallel charging */
 	rc = smb138x_set_parallel_suspend(chip, true);
 	if (rc < 0) {
@@ -976,6 +978,20 @@
 
 	chg->dcp_icl_ua = chip->dt.usb_icl_ua;
 
+	/* Disable OTG */
+	rc = smblib_masked_write(chg, CMD_OTG_REG, OTG_EN_BIT, 0);
+	if (rc < 0) {
+		pr_err("Couldn't disable OTG rc=%d\n", rc);
+		return rc;
+	}
+
+	/* Unsuspend USB input */
+	rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, 0);
+	if (rc < 0) {
+		pr_err("Couldn't unsuspend USB, rc=%d\n", rc);
+		return rc;
+	}
+
 	/* configure to a fixed 700khz freq to avoid tdie errors */
 	rc = smblib_set_charge_param(chg, &chg->param.freq_buck, 700);
 	if (rc < 0) {
@@ -1392,55 +1408,95 @@
 	rc = smb138x_parse_dt(chip);
 	if (rc < 0) {
 		pr_err("Couldn't parse device tree rc=%d\n", rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_init_vbus_regulator(chip);
 	if (rc < 0) {
 		pr_err("Couldn't initialize vbus regulator rc=%d\n",
 			rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_init_vconn_regulator(chip);
 	if (rc < 0) {
 		pr_err("Couldn't initialize vconn regulator rc=%d\n",
 			rc);
-		return rc;
+		goto cleanup;
+	}
+
+	if (chg->use_extcon) {
+		/* extcon registration */
+		chg->extcon = devm_extcon_dev_allocate(chg->dev,
+							smblib_extcon_cable);
+		if (IS_ERR(chg->extcon)) {
+			rc = PTR_ERR(chg->extcon);
+			dev_err(chg->dev, "failed to allocate extcon device rc=%d\n",
+					rc);
+			goto cleanup;
+		}
+
+		chg->extcon->mutually_exclusive = smblib_extcon_exclusive;
+		rc = devm_extcon_dev_register(chg->dev, chg->extcon);
+		if (rc < 0) {
+			dev_err(chg->dev, "failed to register extcon device rc=%d\n",
+						rc);
+			goto cleanup;
+		}
+
+		/* Support reporting polarity and speed via properties */
+		rc = extcon_set_property_capability(chg->extcon,
+				EXTCON_USB, EXTCON_PROP_USB_TYPEC_POLARITY);
+		rc |= extcon_set_property_capability(chg->extcon,
+				EXTCON_USB, EXTCON_PROP_USB_SS);
+		rc |= extcon_set_property_capability(chg->extcon,
+				EXTCON_USB_HOST,
+				EXTCON_PROP_USB_TYPEC_POLARITY);
+		rc |= extcon_set_property_capability(chg->extcon,
+				EXTCON_USB_HOST, EXTCON_PROP_USB_SS);
+		if (rc < 0) {
+			dev_err(chg->dev,
+				"failed to configure extcon capabilities\n");
+			goto cleanup;
+		}
 	}
 
 	rc = smb138x_init_usb_psy(chip);
 	if (rc < 0) {
 		pr_err("Couldn't initialize usb psy rc=%d\n", rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_init_batt_psy(chip);
 	if (rc < 0) {
 		pr_err("Couldn't initialize batt psy rc=%d\n", rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_init_hw(chip);
 	if (rc < 0) {
 		pr_err("Couldn't initialize hardware rc=%d\n", rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_determine_initial_status(chip);
 	if (rc < 0) {
 		pr_err("Couldn't determine initial status rc=%d\n",
 			rc);
-		return rc;
+		goto cleanup;
 	}
 
 	rc = smb138x_request_interrupts(chip);
 	if (rc < 0) {
 		pr_err("Couldn't request interrupts rc=%d\n", rc);
-		return rc;
+		goto cleanup;
 	}
 
 	return rc;
+
+cleanup:
+	smblib_deinit(chg);
+	return rc;
 }
 
 static int smb138x_slave_probe(struct smb138x *chip)
@@ -1616,14 +1672,33 @@
 	return 0;
 }
 
+static void smb138x_shutdown(struct platform_device *pdev)
+{
+	struct smb138x *chip = platform_get_drvdata(pdev);
+	struct smb_charger *chg = &chip->chg;
+	int rc;
+
+	/* Suspend charging */
+	rc = smb138x_set_parallel_suspend(chip, true);
+	if (rc < 0)
+		pr_err("Couldn't suspend charging rc=%d\n", rc);
+
+	/* Disable OTG */
+	rc = smblib_masked_write(chg, CMD_OTG_REG, OTG_EN_BIT, 0);
+	if (rc < 0)
+		pr_err("Couldn't disable OTG rc=%d\n", rc);
+
+}
+
 static struct platform_driver smb138x_driver = {
 	.driver	= {
 		.name		= "qcom,smb138x-charger",
 		.owner		= THIS_MODULE,
 		.of_match_table	= match_table,
 	},
-	.probe	= smb138x_probe,
-	.remove	= smb138x_remove,
+	.probe		= smb138x_probe,
+	.remove		= smb138x_remove,
+	.shutdown	= smb138x_shutdown,
 };
 module_platform_driver(smb138x_driver);
 
diff --git a/drivers/pwm/pwm-qpnp.c b/drivers/pwm/pwm-qpnp.c
index 86f08d2..e7267de 100644
--- a/drivers/pwm/pwm-qpnp.c
+++ b/drivers/pwm/pwm-qpnp.c
@@ -317,6 +317,7 @@
 	struct pwm_period_config	period;
 	int				supported_sizes;
 	int				force_pwm_size;
+	bool				update_period;
 };
 
 /* Public facing structure */
@@ -327,6 +328,7 @@
 	bool			enabled;
 	struct _qpnp_pwm_config	pwm_config;
 	struct	qpnp_lpg_config	lpg_config;
+	enum pm_pwm_mode	pwm_mode;
 	spinlock_t		lpg_lock;
 	enum qpnp_lpg_revision	revision;
 	u8			sub_type;
@@ -1211,28 +1213,32 @@
 	rc = qpnp_lpg_save_pwm_value(chip);
 	if (rc)
 		goto out;
-	rc = qpnp_lpg_configure_pwm(chip);
-	if (rc)
-		goto out;
-	rc = qpnp_configure_pwm_control(chip);
-	if (rc)
-		goto out;
 
-	if (!rc && chip->enabled) {
-		rc = qpnp_lpg_configure_pwm_state(chip, QPNP_PWM_ENABLE);
-		if (rc) {
-			pr_err("Error in configuring pwm state, rc=%d\n", rc);
-			return rc;
-		}
+	if (pwm_config->update_period) {
+		rc = qpnp_lpg_configure_pwm(chip);
+		if (rc)
+			goto out;
+		rc = qpnp_configure_pwm_control(chip);
+		if (rc)
+			goto out;
+		if (!rc && chip->enabled) {
+			rc = qpnp_lpg_configure_pwm_state(chip,
+					QPNP_PWM_ENABLE);
+			if (rc) {
+				pr_err("Error in configuring pwm state, rc=%d\n",
+						rc);
+				return rc;
+			}
 
-		/* Enable the glitch removal after PWM is enabled */
-		rc = qpnp_lpg_glitch_removal(chip, true);
-		if (rc) {
-			pr_err("Error in enabling glitch control, rc=%d\n", rc);
-			return rc;
+			/* Enable the glitch removal after PWM is enabled */
+			rc = qpnp_lpg_glitch_removal(chip, true);
+			if (rc) {
+				pr_err("Error in enabling glitch control, rc=%d\n",
+						rc);
+				return rc;
+			}
 		}
 	}
-
 	pr_debug("duty/period=%u/%u %s: pwm_value=%d (of %d)\n",
 		 (unsigned int)duty_value, (unsigned int)period_value,
 		 (tm_lvl == LVL_USEC) ? "usec" : "nsec",
@@ -1309,12 +1315,10 @@
 	return rc;
 }
 
+/* lpg_lock should be held while calling _pwm_enable() */
 static int _pwm_enable(struct qpnp_pwm_chip *chip)
 {
 	int rc = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(&chip->lpg_lock, flags);
 
 	if (QPNP_IS_PWM_CONFIG_SELECTED(
 		chip->qpnp_lpg_registers[QPNP_ENABLE_CONTROL]) ||
@@ -1327,8 +1331,21 @@
 	if (!rc)
 		chip->enabled = true;
 
-	spin_unlock_irqrestore(&chip->lpg_lock, flags);
+	return rc;
+}
 
+/* lpg_lock should be held while calling _pwm_change_mode() */
+static int _pwm_change_mode(struct qpnp_pwm_chip *chip, enum pm_pwm_mode mode)
+{
+	int rc;
+
+	if (mode == PM_PWM_MODE_LPG)
+		rc = qpnp_configure_lpg_control(chip);
+	else
+		rc = qpnp_configure_pwm_control(chip);
+
+	if (rc)
+		pr_err("Failed to change the mode\n");
 	return rc;
 }
 
@@ -1375,12 +1392,14 @@
 
 	spin_lock_irqsave(&chip->lpg_lock, flags);
 
+	chip->pwm_config.update_period = false;
 	if (prev_period_us > INT_MAX / NSEC_PER_USEC ||
 			prev_period_us * NSEC_PER_USEC != period_ns) {
 		qpnp_lpg_calc_period(LVL_NSEC, period_ns, chip);
 		qpnp_lpg_save_period(chip);
 		pwm->state.period = period_ns;
 		chip->pwm_config.pwm_period = period_ns / NSEC_PER_USEC;
+		chip->pwm_config.update_period = true;
 	}
 
 	rc = _pwm_config(chip, LVL_NSEC, duty_ns, period_ns);
@@ -1403,11 +1422,15 @@
 {
 	int rc;
 	struct qpnp_pwm_chip *chip = qpnp_pwm_from_pwm_chip(pwm_chip);
+	unsigned long flags;
 
+	spin_lock_irqsave(&chip->lpg_lock, flags);
 	rc = _pwm_enable(chip);
 	if (rc)
 		pr_err("Failed to enable PWM channel: %d\n", chip->channel_id);
 
+	spin_unlock_irqrestore(&chip->lpg_lock, flags);
+
 	return rc;
 }
 
@@ -1445,20 +1468,6 @@
 					chip->channel_id);
 }
 
-static int _pwm_change_mode(struct qpnp_pwm_chip *chip, enum pm_pwm_mode mode)
-{
-	int rc;
-
-	if (mode)
-		rc = qpnp_configure_lpg_control(chip);
-	else
-		rc = qpnp_configure_pwm_control(chip);
-
-	if (rc)
-		pr_err("Failed to change the mode\n");
-	return rc;
-}
-
 /**
  * pwm_change_mode - Change the PWM mode configuration
  * @pwm: the PWM device
@@ -1466,7 +1475,7 @@
  */
 int pwm_change_mode(struct pwm_device *pwm, enum pm_pwm_mode mode)
 {
-	int rc;
+	int rc = 0;
 	unsigned long flags;
 	struct qpnp_pwm_chip *chip;
 
@@ -1483,7 +1492,22 @@
 	chip = qpnp_pwm_from_pwm_dev(pwm);
 
 	spin_lock_irqsave(&chip->lpg_lock, flags);
-	rc = _pwm_change_mode(chip, mode);
+	if (chip->pwm_mode != mode) {
+		rc = _pwm_change_mode(chip, mode);
+		if (rc) {
+			pr_err("Failed to change mode: %d, rc=%d\n", mode, rc);
+			goto unlock;
+		}
+		chip->pwm_mode = mode;
+		if (chip->enabled) {
+			rc = _pwm_enable(chip);
+			if (rc) {
+				pr_err("Failed to enable PWM, rc=%d\n", rc);
+				goto unlock;
+			}
+		}
+	}
+unlock:
 	spin_unlock_irqrestore(&chip->lpg_lock, flags);
 
 	return rc;
@@ -1619,6 +1643,7 @@
 
 	spin_lock_irqsave(&chip->lpg_lock, flags);
 
+	chip->pwm_config.update_period = false;
 	if (chip->pwm_config.pwm_period != period_us) {
 		qpnp_lpg_calc_period(LVL_USEC, period_us, chip);
 		qpnp_lpg_save_period(chip);
@@ -1629,6 +1654,7 @@
 		else
 			pwm->state.period
 				= (unsigned int)period_us * NSEC_PER_USEC;
+		chip->pwm_config.update_period = true;
 	}
 
 	rc = _pwm_config(chip, LVL_USEC, duty_us, period_us);
@@ -1735,6 +1761,7 @@
 	qpnp_lpg_calc_period(LVL_USEC, period, chip);
 	qpnp_lpg_save_period(chip);
 	chip->pwm_config.pwm_period = period;
+	chip->pwm_config.update_period = true;
 
 	rc = _pwm_config(chip, LVL_USEC, chip->pwm_config.pwm_duty, period);
 
@@ -1885,7 +1912,7 @@
 static int qpnp_parse_dt_config(struct platform_device *pdev,
 					struct qpnp_pwm_chip *chip)
 {
-	int			rc, enable, lut_entry_size, list_size, i;
+	int			rc, mode, lut_entry_size, list_size, i;
 	const char		*label;
 	const __be32		*prop;
 	u32			size;
@@ -2069,18 +2096,20 @@
 		}
 	}
 
-	rc = of_property_read_u32(of_node, "qcom,mode-select", &enable);
+	rc = of_property_read_u32(of_node, "qcom,mode-select", &mode);
 	if (rc)
 		goto read_opt_props;
 
-	if ((enable == PM_PWM_MODE_PWM && found_pwm_subnode == 0) ||
-		(enable == PM_PWM_MODE_LPG && found_lpg_subnode == 0)) {
+	if (mode > PM_PWM_MODE_LPG ||
+		(mode == PM_PWM_MODE_PWM && found_pwm_subnode == 0) ||
+		(mode == PM_PWM_MODE_LPG && found_lpg_subnode == 0)) {
 		dev_err(&pdev->dev, "%s: Invalid mode select\n", __func__);
 		rc = -EINVAL;
 		goto out;
 	}
 
-	_pwm_change_mode(chip, enable);
+	chip->pwm_mode = mode;
+	_pwm_change_mode(chip, mode);
 	_pwm_enable(chip);
 
 read_opt_props:
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 9d253cb..e70410b 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -64,9 +64,9 @@
 u32	bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
 u32	*bfi_image_cb, *bfi_image_ct, *bfi_image_ct2;
 
-#define BFAD_FW_FILE_CB		"cbfw-3.2.3.0.bin"
-#define BFAD_FW_FILE_CT		"ctfw-3.2.3.0.bin"
-#define BFAD_FW_FILE_CT2	"ct2fw-3.2.3.0.bin"
+#define BFAD_FW_FILE_CB		"cbfw-3.2.5.1.bin"
+#define BFAD_FW_FILE_CT		"ctfw-3.2.5.1.bin"
+#define BFAD_FW_FILE_CT2	"ct2fw-3.2.5.1.bin"
 
 static u32 *bfad_load_fwimg(struct pci_dev *pdev);
 static void bfad_free_fwimg(void);
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index f9e8620..cfcfff4 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -58,7 +58,7 @@
 #ifdef BFA_DRIVER_VERSION
 #define BFAD_DRIVER_VERSION    BFA_DRIVER_VERSION
 #else
-#define BFAD_DRIVER_VERSION    "3.2.25.0"
+#define BFAD_DRIVER_VERSION    "3.2.25.1"
 #endif
 
 #define BFAD_PROTO_NAME FCPI_NAME
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 9ddc920..9e4b770 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -248,6 +248,7 @@
 	struct completion *remove_wait; /* device remove thread blocks */
 
 	atomic_t in_flight;		/* io counter */
+	bool internal_reset_inprogress;
 	u32 _reserved;			/* fill hole */
 	unsigned long state_flags;	/* protected by host lock */
 	enum fnic_state state;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d9fd2f8..44dd372 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2573,6 +2573,19 @@
 	unsigned long wait_host_tmo;
 	struct Scsi_Host *shost = sc->device->host;
 	struct fc_lport *lp = shost_priv(shost);
+	struct fnic *fnic = lport_priv(lp);
+	unsigned long flags;
+
+	spin_lock_irqsave(&fnic->fnic_lock, flags);
+	if (fnic->internal_reset_inprogress == 0) {
+		fnic->internal_reset_inprogress = 1;
+	} else {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+			"host reset in progress skipping another host reset\n");
+		return SUCCESS;
+	}
+	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 
 	/*
 	 * If fnic_reset is successful, wait for fabric login to complete
@@ -2593,6 +2606,9 @@
 		}
 	}
 
+	spin_lock_irqsave(&fnic->fnic_lock, flags);
+	fnic->internal_reset_inprogress = 0;
+	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 	return ret;
 }
 
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 1910100..00602ab 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -66,6 +66,9 @@
 {
 	static const char * const strings[] = RNC_STATES;
 
+	if (state >= ARRAY_SIZE(strings))
+		return "UNKNOWN";
+
 	return strings[state];
 }
 #undef C
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ad33238..8c4641b 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -243,12 +243,15 @@
 	struct qla_hw_data *ha = vha->hw;
 	ssize_t rval = 0;
 
-	if (ha->optrom_state != QLA_SREADING)
-		return 0;
-
 	mutex_lock(&ha->optrom_mutex);
+
+	if (ha->optrom_state != QLA_SREADING)
+		goto out;
+
 	rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
 	    ha->optrom_region_size);
+
+out:
 	mutex_unlock(&ha->optrom_mutex);
 
 	return rval;
@@ -263,14 +266,19 @@
 	    struct device, kobj)));
 	struct qla_hw_data *ha = vha->hw;
 
-	if (ha->optrom_state != QLA_SWRITING)
+	mutex_lock(&ha->optrom_mutex);
+
+	if (ha->optrom_state != QLA_SWRITING) {
+		mutex_unlock(&ha->optrom_mutex);
 		return -EINVAL;
-	if (off > ha->optrom_region_size)
+	}
+	if (off > ha->optrom_region_size) {
+		mutex_unlock(&ha->optrom_mutex);
 		return -ERANGE;
+	}
 	if (off + count > ha->optrom_region_size)
 		count = ha->optrom_region_size - off;
 
-	mutex_lock(&ha->optrom_mutex);
 	memcpy(&ha->optrom_buffer[off], buf, count);
 	mutex_unlock(&ha->optrom_mutex);
 
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 44c466b..4bd6fd4 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -142,6 +142,7 @@
 	struct sg_device *parentdp;	/* owning device */
 	wait_queue_head_t read_wait;	/* queue read until command done */
 	rwlock_t rq_list_lock;	/* protect access to list in req_arr */
+	struct mutex f_mutex;	/* protect against changes in this fd */
 	int timeout;		/* defaults to SG_DEFAULT_TIMEOUT      */
 	int timeout_user;	/* defaults to SG_DEFAULT_TIMEOUT_USER */
 	Sg_scatter_hold reserve;	/* buffer held for this file descriptor */
@@ -155,6 +156,7 @@
 	unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */
 	char keep_orphan;	/* 0 -> drop orphan (def), 1 -> keep for read() */
 	char mmap_called;	/* 0 -> mmap() never called on this fd */
+	char res_in_use;	/* 1 -> 'reserve' array in use */
 	struct kref f_ref;
 	struct execute_work ew;
 } Sg_fd;
@@ -198,7 +200,6 @@
 static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
 static Sg_request *sg_add_request(Sg_fd * sfp);
 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
-static int sg_res_in_use(Sg_fd * sfp);
 static Sg_device *sg_get_dev(int dev);
 static void sg_device_destroy(struct kref *kref);
 
@@ -499,7 +500,7 @@
 		old_hdr->result = EIO;
 		break;
 	case DID_ERROR:
-		old_hdr->result = (srp->sense_b[0] == 0 && 
+		old_hdr->result = (srp->sense_b[0] == 0 &&
 				  hp->masked_status == GOOD) ? 0 : EIO;
 		break;
 	default:
@@ -614,6 +615,7 @@
 	}
 	buf += SZ_SG_HEADER;
 	__get_user(opcode, buf);
+	mutex_lock(&sfp->f_mutex);
 	if (sfp->next_cmd_len > 0) {
 		cmd_size = sfp->next_cmd_len;
 		sfp->next_cmd_len = 0;	/* reset so only this write() effected */
@@ -622,6 +624,7 @@
 		if ((opcode >= 0xc0) && old_hdr.twelve_byte)
 			cmd_size = 12;
 	}
+	mutex_unlock(&sfp->f_mutex);
 	SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
 		"sg_write:   scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
 /* Determine buffer size.  */
@@ -721,7 +724,7 @@
 			sg_remove_request(sfp, srp);
 			return -EINVAL;	/* either MMAP_IO or DIRECT_IO (not both) */
 		}
-		if (sg_res_in_use(sfp)) {
+		if (sfp->res_in_use) {
 			sg_remove_request(sfp, srp);
 			return -EBUSY;	/* reserve buffer already being used */
 		}
@@ -856,8 +859,10 @@
 			return -ENXIO;
 		if (!access_ok(VERIFY_WRITE, p, SZ_SG_IO_HDR))
 			return -EFAULT;
+		mutex_lock(&sfp->parentdp->open_rel_lock);
 		result = sg_new_write(sfp, filp, p, SZ_SG_IO_HDR,
 				 1, read_only, 1, &srp);
+		mutex_unlock(&sfp->parentdp->open_rel_lock);
 		if (result < 0)
 			return result;
 		result = wait_event_interruptible(sfp->read_wait,
@@ -896,10 +901,12 @@
 			return result;
 		if (val) {
 			sfp->low_dma = 1;
-			if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
+			if ((0 == sfp->low_dma) && !sfp->res_in_use) {
 				val = (int) sfp->reserve.bufflen;
+				mutex_lock(&sfp->parentdp->open_rel_lock);
 				sg_remove_scat(sfp, &sfp->reserve);
 				sg_build_reserve(sfp, val);
+				mutex_unlock(&sfp->parentdp->open_rel_lock);
 			}
 		} else {
 			if (atomic_read(&sdp->detaching))
@@ -967,16 +974,23 @@
 		result = get_user(val, ip);
 		if (result)
 			return result;
-                if (val < 0)
-                        return -EINVAL;
+		if (val < 0)
+			return -EINVAL;
 		val = min_t(int, val,
 			    max_sectors_bytes(sdp->device->request_queue));
+		mutex_lock(&sfp->f_mutex);
 		if (val != sfp->reserve.bufflen) {
-			if (sg_res_in_use(sfp) || sfp->mmap_called)
+			if (sfp->mmap_called ||
+			    sfp->res_in_use) {
+				mutex_unlock(&sfp->f_mutex);
 				return -EBUSY;
+			}
+			mutex_lock(&sfp->parentdp->open_rel_lock);
 			sg_remove_scat(sfp, &sfp->reserve);
 			sg_build_reserve(sfp, val);
+			mutex_unlock(&sfp->parentdp->open_rel_lock);
 		}
+		mutex_unlock(&sfp->f_mutex);
 		return 0;
 	case SG_GET_RESERVED_SIZE:
 		val = min_t(int, sfp->reserve.bufflen,
@@ -1030,8 +1044,8 @@
 				if (srp) {
 					rinfo[val].req_state = srp->done + 1;
 					rinfo[val].problem =
-					    srp->header.masked_status & 
-					    srp->header.host_status & 
+					    srp->header.masked_status &
+					    srp->header.host_status &
 					    srp->header.driver_status;
 					if (srp->done)
 						rinfo[val].duration =
@@ -1052,7 +1066,7 @@
 				}
 			}
 			read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
-			result = __copy_to_user(p, rinfo, 
+			result = __copy_to_user(p, rinfo,
 						SZ_SG_REQ_INFO * SG_MAX_QUEUE);
 			result = result ? -EFAULT : 0;
 			kfree(rinfo);
@@ -1128,14 +1142,14 @@
 		return -ENXIO;
 
 	sdev = sdp->device;
-	if (sdev->host->hostt->compat_ioctl) { 
+	if (sdev->host->hostt->compat_ioctl) {
 		int ret;
 
 		ret = sdev->host->hostt->compat_ioctl(sdev, cmd_in, (void __user *)arg);
 
 		return ret;
 	}
-	
+
 	return -ENOIOCTLCMD;
 }
 #endif
@@ -1239,6 +1253,7 @@
 	unsigned long req_sz, len, sa;
 	Sg_scatter_hold *rsv_schp;
 	int k, length;
+	int ret = 0;
 
 	if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data)))
 		return -ENXIO;
@@ -1249,8 +1264,11 @@
 	if (vma->vm_pgoff)
 		return -EINVAL;	/* want no offset */
 	rsv_schp = &sfp->reserve;
-	if (req_sz > rsv_schp->bufflen)
-		return -ENOMEM;	/* cannot map more than reserved buffer */
+	mutex_lock(&sfp->f_mutex);
+	if (req_sz > rsv_schp->bufflen) {
+		ret = -ENOMEM;	/* cannot map more than reserved buffer */
+		goto out;
+	}
 
 	sa = vma->vm_start;
 	length = 1 << (PAGE_SHIFT + rsv_schp->page_order);
@@ -1264,7 +1282,9 @@
 	vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
 	vma->vm_private_data = sfp;
 	vma->vm_ops = &sg_mmap_vm_ops;
-	return 0;
+out:
+	mutex_unlock(&sfp->f_mutex);
+	return ret;
 }
 
 static void
@@ -1619,7 +1639,7 @@
 	else
 		def_reserved_size = sg_big_buff;
 
-	rc = register_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), 
+	rc = register_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
 				    SG_MAX_DEVS, "sg");
 	if (rc)
 		return rc;
@@ -1728,13 +1748,25 @@
 		md = &map_data;
 
 	if (md) {
-		if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
+		mutex_lock(&sfp->f_mutex);
+		if (dxfer_len <= rsv_schp->bufflen &&
+		    !sfp->res_in_use) {
+			sfp->res_in_use = 1;
 			sg_link_reserve(sfp, srp, dxfer_len);
-		else {
+		} else if (hp->flags & SG_FLAG_MMAP_IO) {
+			res = -EBUSY; /* sfp->res_in_use == 1 */
+			if (dxfer_len > rsv_schp->bufflen)
+				res = -ENOMEM;
+			mutex_unlock(&sfp->f_mutex);
+			return res;
+		} else {
 			res = sg_build_indirect(req_schp, sfp, dxfer_len);
-			if (res)
+			if (res) {
+				mutex_unlock(&sfp->f_mutex);
 				return res;
+			}
 		}
+		mutex_unlock(&sfp->f_mutex);
 
 		md->pages = req_schp->pages;
 		md->page_order = req_schp->page_order;
@@ -2025,6 +2057,8 @@
 	req_schp->sglist_len = 0;
 	sfp->save_scat_len = 0;
 	srp->res_used = 0;
+	/* Called without mutex lock to avoid deadlock */
+	sfp->res_in_use = 0;
 }
 
 static Sg_request *
@@ -2136,6 +2170,7 @@
 	rwlock_init(&sfp->rq_list_lock);
 
 	kref_init(&sfp->f_ref);
+	mutex_init(&sfp->f_mutex);
 	sfp->timeout = SG_DEFAULT_TIMEOUT;
 	sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
 	sfp->force_packid = SG_DEF_FORCE_PACK_ID;
@@ -2211,20 +2246,6 @@
 	schedule_work(&sfp->ew.work);
 }
 
-static int
-sg_res_in_use(Sg_fd * sfp)
-{
-	const Sg_request *srp;
-	unsigned long iflags;
-
-	read_lock_irqsave(&sfp->rq_list_lock, iflags);
-	for (srp = sfp->headrp; srp; srp = srp->nextrp)
-		if (srp->res_used)
-			break;
-	read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
-	return srp ? 1 : 0;
-}
-
 #ifdef CONFIG_SCSI_PROC_FS
 static int
 sg_idr_max_id(int id, void *p, void *data)
@@ -2299,7 +2320,7 @@
 };
 
 static int sg_proc_single_open_dressz(struct inode *inode, struct file *file);
-static ssize_t sg_proc_write_dressz(struct file *filp, 
+static ssize_t sg_proc_write_dressz(struct file *filp,
 		const char __user *buffer, size_t count, loff_t *off);
 static const struct file_operations dressz_fops = {
 	.owner = THIS_MODULE,
@@ -2439,7 +2460,7 @@
 	return single_open(file, sg_proc_seq_show_int, &sg_allow_dio);
 }
 
-static ssize_t 
+static ssize_t
 sg_proc_write_adio(struct file *filp, const char __user *buffer,
 		   size_t count, loff_t *off)
 {
@@ -2460,7 +2481,7 @@
 	return single_open(file, sg_proc_seq_show_int, &sg_big_buff);
 }
 
-static ssize_t 
+static ssize_t
 sg_proc_write_dressz(struct file *filp, const char __user *buffer,
 		     size_t count, loff_t *off)
 {
@@ -2620,7 +2641,7 @@
 			hp = &srp->header;
 			new_interface = (hp->interface_id == '\0') ? 0 : 1;
 			if (srp->res_used) {
-				if (new_interface && 
+				if (new_interface &&
 				    (SG_FLAG_MMAP_IO & hp->flags))
 					cp = "     mmap>> ";
 				else
diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
index 396b32d..7cf70aa 100644
--- a/drivers/scsi/snic/snic_main.c
+++ b/drivers/scsi/snic/snic_main.c
@@ -591,6 +591,7 @@
 	if (!pool) {
 		SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n");
 
+		ret = -ENOMEM;
 		goto err_free_res;
 	}
 
@@ -601,6 +602,7 @@
 	if (!pool) {
 		SNIC_HOST_ERR(shost, "max sgl pool creation failed\n");
 
+		ret = -ENOMEM;
 		goto err_free_dflt_sgl_pool;
 	}
 
@@ -611,6 +613,7 @@
 	if (!pool) {
 		SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n");
 
+		ret = -ENOMEM;
 		goto err_free_max_sgl_pool;
 	}
 
diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-debugfs.c
index 557ca19..11e11e4 100644
--- a/drivers/scsi/ufs/ufs-debugfs.c
+++ b/drivers/scsi/ufs/ufs-debugfs.c
@@ -950,6 +950,10 @@
 	seq_printf(file, "hba->saved_err = 0x%x\n", hba->saved_err);
 	seq_printf(file, "hba->saved_uic_err = 0x%x\n", hba->saved_uic_err);
 
+	seq_printf(file, "power_mode_change_cnt = %d\n",
+			hba->ufs_stats.power_mode_change_cnt);
+	seq_printf(file, "hibern8_exit_cnt = %d\n",
+			hba->ufs_stats.hibern8_exit_cnt);
 	return 0;
 }
 
diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h
index 792ae42..32edd76 100644
--- a/drivers/scsi/ufs/ufs-qcom.h
+++ b/drivers/scsi/ufs/ufs-qcom.h
@@ -21,6 +21,7 @@
 #define MAX_UFS_QCOM_HOSTS	2
 #define MAX_U32                 (~(u32)0)
 #define MPHY_TX_FSM_STATE       0x41
+#define MPHY_RX_FSM_STATE       0xC1
 #define TX_FSM_HIBERN8          0x1
 #define HBRN8_POLL_TOUT_MS      100
 #define DEFAULT_CLK_RATE_HZ     1000000
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 7c5a1bc..f5a6736 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -144,10 +144,11 @@
 static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		struct ufs_vreg **out_vreg)
 {
-	int ret = 0;
+	int len, ret = 0;
 	char prop_name[MAX_PROP_SIZE];
 	struct ufs_vreg *vreg = NULL;
 	struct device_node *np = dev->of_node;
+	const __be32 *prop;
 
 	if (!np) {
 		dev_err(dev, "%s: non DT initialization\n", __func__);
@@ -186,8 +187,16 @@
 			vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
 			vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
 		} else {
-			vreg->min_uV = UFS_VREG_VCC_MIN_UV;
-			vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			prop = of_get_property(np, "vcc-voltage-level", &len);
+			if (!prop || (len != (2 * sizeof(__be32)))) {
+				dev_warn(dev, "%s vcc-voltage-level property.\n",
+					prop ? "invalid format" : "no");
+				vreg->min_uV = UFS_VREG_VCC_MIN_UV;
+				vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			} else {
+				vreg->min_uV = be32_to_cpup(&prop[0]);
+				vreg->max_uV = be32_to_cpup(&prop[1]);
+			}
 		}
 	} else if (!strcmp(name, "vccq")) {
 		vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c132dbc..b6ba4c4 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -864,6 +864,24 @@
 	}
 }
 
+static void ufshcd_print_fsm_state(struct ufs_hba *hba)
+{
+	int err = 0, tx_fsm_val = 0, rx_fsm_val = 0;
+
+	err = ufshcd_dme_get(hba,
+			UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE,
+			UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)),
+			&tx_fsm_val);
+	dev_err(hba->dev, "%s: TX_FSM_STATE = %u, err = %d\n", __func__,
+			tx_fsm_val, err);
+	err = ufshcd_dme_get(hba,
+			UIC_ARG_MIB_SEL(MPHY_RX_FSM_STATE,
+			UIC_ARG_MPHY_RX_GEN_SEL_INDEX(0)),
+			&rx_fsm_val);
+	dev_err(hba->dev, "%s: RX_FSM_STATE = %u, err = %d\n", __func__,
+			rx_fsm_val, err);
+}
+
 static void ufshcd_print_host_state(struct ufs_hba *hba)
 {
 	if (!(hba->ufshcd_dbg_print & UFSHCD_DBG_PRINT_HOST_STATE_EN))
@@ -888,6 +906,7 @@
 		hba->capabilities, hba->caps);
 	dev_err(hba->dev, "quirks=0x%x, dev. quirks=0x%x\n", hba->quirks,
 		hba->dev_info.quirks);
+	ufshcd_print_fsm_state(hba);
 }
 
 /**
@@ -4856,6 +4875,7 @@
 
 		memcpy(&hba->pwr_info, pwr_mode,
 			sizeof(struct ufs_pa_layer_attr));
+		hba->ufs_stats.power_mode_change_cnt++;
 	}
 
 	return ret;
@@ -7151,6 +7171,12 @@
 	} while (err && --retries);
 
 	/*
+	 * There is no point proceeding even after failing
+	 * to recover after multiple retries.
+	 */
+	if (err && ufshcd_is_embedded_dev(hba))
+		BUG();
+	/*
 	 * After reset the door-bell might be cleared, complete
 	 * outstanding requests in s/w here.
 	 */
@@ -7615,9 +7641,6 @@
 {
 	int err_reg_hist_size = sizeof(struct ufs_uic_err_reg_hist);
 
-	hba->ufs_stats.hibern8_exit_cnt = 0;
-	hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
-
 	memset(&hba->ufs_stats.pa_err, 0, err_reg_hist_size);
 	memset(&hba->ufs_stats.dl_err, 0, err_reg_hist_size);
 	memset(&hba->ufs_stats.nl_err, 0, err_reg_hist_size);
@@ -9689,6 +9712,8 @@
 
 static void ufshcd_shutdown_clkscaling(struct ufs_hba *hba)
 {
+	if (!ufshcd_is_clkscaling_supported(hba))
+		return;
 	__ufshcd_shutdown_clkscaling(hba);
 	device_remove_file(hba->dev, &hba->clk_scaling.enable_attr);
 }
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index fc855db..1b21238 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -644,6 +644,7 @@
 	struct ufshcd_clk_ctx clk_rel;
 	u32 hibern8_exit_cnt;
 	ktime_t last_hibern8_exit_tstamp;
+	u32 power_mode_change_cnt;
 	struct ufs_uic_err_reg_hist pa_err;
 	struct ufs_uic_err_reg_hist dl_err;
 	struct ufs_uic_err_reg_hist nl_err;
@@ -1198,6 +1199,14 @@
 		pwr_info->pwr_tx == FASTAUTO_MODE);
 }
 
+static inline bool ufshcd_is_embedded_dev(struct ufs_hba *hba)
+{
+	if ((hba->dev_info.b_device_sub_class == UFS_DEV_EMBEDDED_BOOTABLE) ||
+	    (hba->dev_info.b_device_sub_class == UFS_DEV_EMBEDDED_NON_BOOTABLE))
+		return true;
+	return false;
+}
+
 #ifdef CONFIG_DEBUG_FS
 static inline void ufshcd_init_req_stats(struct ufs_hba *hba)
 {
diff --git a/drivers/slimbus/slimbus.c b/drivers/slimbus/slimbus.c
index 567f290..3ae9a10 100644
--- a/drivers/slimbus/slimbus.c
+++ b/drivers/slimbus/slimbus.c
@@ -2397,6 +2397,8 @@
 		bool opensl1valid = false;
 		int maxctrlw1, maxctrlw3, i;
 
+		/* intitalize array to zero */
+		memset(opensl1, 0x0, sizeof(opensl1));
 		finalexp = (ctrl->sched.chc3[last3])->rootexp;
 		if (last1 >= 0) {
 			slc1 = ctrl->sched.chc1[coeff1];
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 8b5a2fa..d845211 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -538,66 +538,6 @@
 	  Command DB queries shared memory by key string for shared system
 	  resources
 
-config MSM_QDSP6_APRV2_GLINK
-        bool "Audio QDSP6 APRv2 Over Glink support"
-	depends on MSM_GLINK
-        help
-          Enable APRv2 IPC protocol support between
-          application processor and QDSP6. APR is
-          used by audio driver to configure QDSP6's
-          ASM, ADM and AFE.
-
-config MSM_QDSP6_APRV3_GLINK
-	bool "Audio QDSP6 APRv3 Over Glink support"
-	depends on MSM_GLINK
-	help
-	  Enable APRv3 IPC protocol support between
-	  application processor and QDSP6. APR is
-	  used by audio driver to configure QDSP6v2's
-	  ASM, ADM and AFE.
-
-config MSM_QDSP6_SSR
-	bool "Audio QDSP6 SSR support"
-	depends on MSM_QDSP6_APRV2_GLINK || MSM_QDSP6_APRV3_GLINK
-	help
-	  Enable Subsystem Restart. Reset audio
-	  clients when the ADSP subsystem is
-	  restarted. Subsystem Restart for audio
-	  is only used for processes on the ADSP
-	  and signals audio drivers through APR.
-
-
-config MSM_QDSP6_PDR
-	bool "Audio QDSP6 PDR support"
-	depends on MSM_QDSP6_APRV2_GLINK || MSM_QDSP6_APRV3_GLINK
-	help
-	  Enable Protection Domain Restart. Reset
-          audio clients when a process on the ADSP
-          is restarted. PDR for audio is only used
-          for processes on the ADSP and signals
-          audio drivers through APR.
-
-config MSM_QDSP6_NOTIFIER
-	bool "Audio QDSP6 PDR support"
-	depends on MSM_QDSP6_SSR || MSM_QDSP6_PDR
-	help
-	  Enable notifier which decides whether
-	  to use SSR or PDR and notifies all
-	  audio clients of the event. Both SSR
-	  and PDR are recovery methods when
-	  there is a crash on ADSP. Audio drivers
-	  are contacted by ADSP through APR.
-
-config MSM_ADSP_LOADER
-	tristate "ADSP loader support"
-	select SND_SOC_MSM_APRV2_INTF
-	depends on MSM_QDSP6_APRV2_GLINK || MSM_QDSP6_APRV3_GLINK
-	help
-	  Enable ADSP image loader.
-	  The ADSP loader brings ADSP out of reset
-	  for the platforms that use APRv2.
-	  Say M if you want to enable this module.
-
 config MSM_PERFORMANCE
 	tristate "msm performacne driver to support userspace hotplug requests"
 	default n
@@ -607,16 +547,6 @@
 	  online at any given point in time. This module can also restrict
 	  max freq or min freq of cpu cluster
 
-config MSM_PERFORMANCE_HOTPLUG_ON
-	bool "Hotplug functionality through msm_performance turned on"
-	depends on MSM_PERFORMANCE
-	default y
-	help
-	  If some other core-control driver is present turn off the core-control
-	  capability of msm_performance driver. Setting this flag to false will
-	  compile out the nodes needed for core-control functionality through
-	  msm_performance.
-
 config MSM_CDSP_LOADER
 	tristate "CDSP loader support"
 	depends on MSM_GLINK
@@ -626,22 +556,6 @@
 	  for platforms that have compute DSP.
 	  Say M if you want to enable this module.
 
-config MSM_AVTIMER
-	tristate "Avtimer Driver"
-	depends on MSM_QDSP6_APRV2_GLINK || MSM_QDSP6_APRV3_GLINK
-	help
-		This driver gets the Q6 out of power collapsed state and
-		exposes ioctl control to read avtimer tick.
-
-config WCD_DSP_GLINK
-	tristate "WCD DSP GLINK Driver"
-	depends on MSM_GLINK
-	default y if SND_SOC_WCD934X=y
-	help
-	   This option enables driver which provides communication interface
-	   between MSM and WCD DSP over glink transport protocol. This driver
-	   provides read and write interface via char device.
-
 config QCOM_SMCINVOKE
 	bool "Secure QSEE Support"
 	help
@@ -778,3 +692,14 @@
 	  This module enables bridging an Inter-Processor Communication(IPC)
 	  interrupt from a remote subsystem directed towards Qualcomm
 	  Technologies, Inc. Secure Execution Environment(QSEE).
+
+config MSM_JTAGV8
+	bool "Debug and ETM trace support across power collapse for ARMv8"
+	default y if CORESIGHT_SOURCE_ETM4X
+	help
+	  Enables support for debugging (specifically breakpoints) and ETM
+	  processor tracing across power collapse both for JTag and OS hosted
+	  software running on ARMv8 target. Enabling this will ensure debug
+	  and ETM registers are saved and restored across power collapse.
+	  If unsure, say 'N' here to avoid potential power, performance and
+	  memory penalty.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 42a8ef5..b147c81 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -55,13 +55,12 @@
 obj-$(CONFIG_MSM_SYSTEM_HEALTH_MONITOR)	+=	system_health_monitor_v01.o
 obj-$(CONFIG_MSM_SYSTEM_HEALTH_MONITOR)	+=	system_health_monitor.o
 obj-$(CONFIG_MSM_SYSMON_GLINK_COMM) += sysmon-glink.o sysmon-qmi.o
-obj-$(CONFIG_ICNSS) += icnss.o wlan_firmware_service_v01.o icnss_utils.o
+obj-$(CONFIG_ICNSS) += icnss.o wlan_firmware_service_v01.o
 
 obj-$(CONFIG_MEM_SHARE_QMI_SERVICE)		+= memshare/
 obj-$(CONFIG_MSM_PIL_SSR_GENERIC) += subsys-pil-tz.o
 obj-$(CONFIG_MSM_PIL_MSS_QDSP6V5) += pil-q6v5.o pil-msa.o pil-q6v5-mss.o
 obj-$(CONFIG_MSM_PIL)   +=      peripheral-loader.o
-obj-$(CONFIG_MSM_AVTIMER) += avtimer.o
 
 obj-$(CONFIG_MSM_PERFORMANCE) += msm_performance.o
 
@@ -70,9 +69,9 @@
        obj-y += subsystem_restart.o
        obj-y += ramdump.o
 endif
+obj-$(CONFIG_MSM_JTAGV8) += jtagv8.o jtagv8-etm.o
 obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
 obj-$(CONFIG_MSM_QBT1000) += qbt1000.o
-obj-$(CONFIG_WCD_DSP_GLINK) += wcd-dsp-glink.o
 obj-$(CONFIG_MSM_EVENT_TIMER) += event_timer.o
 obj-$(CONFIG_MSM_IDLE_STATS)	+= lpm-stats.o
 obj-$(CONFIG_APSS_CORE_EA)	+= msm-core.o debug_core.o
diff --git a/drivers/soc/qcom/avtimer.c b/drivers/soc/qcom/avtimer.c
deleted file mode 100644
index 1819d46..0000000
--- a/drivers/soc/qcom/avtimer.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/cdev.h>
-#include <linux/uaccess.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-#include <linux/avtimer.h>
-#include <linux/slab.h>
-#include <linux/of.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/qdsp6v2/apr.h>
-#include <sound/q6core.h>
-
-#define DEVICE_NAME "avtimer"
-#define TIMEOUT_MS 1000
-#define CORE_CLIENT 1
-#define TEMP_PORT ((CORE_CLIENT << 8) | 0x0001)
-#define SSR_WAKETIME 1000
-#define Q6_READY_RETRY 250
-#define Q6_READY_MAX_RETRIES 40
-
-#define AVCS_CMD_REMOTE_AVTIMER_VOTE_REQUEST 0x00012914
-#define AVCS_CMD_RSP_REMOTE_AVTIMER_VOTE_REQUEST 0x00012915
-#define AVCS_CMD_REMOTE_AVTIMER_RELEASE_REQUEST 0x00012916
-#define AVTIMER_REG_CNT 2
-
-struct adsp_avt_timer {
-	struct apr_hdr hdr;
-	union {
-		char client_name[8];
-		u32 avtimer_handle;
-	};
-} __packed;
-
-static int major;
-
-struct avtimer_t {
-	struct apr_svc *core_handle_q;
-	struct cdev myc;
-	struct class *avtimer_class;
-	struct mutex avtimer_lock;
-	int avtimer_open_cnt;
-	struct delayed_work ssr_dwork;
-	wait_queue_head_t adsp_resp_wait;
-	int enable_timer_resp_received;
-	int timer_handle;
-	void __iomem *p_avtimer_msw;
-	void __iomem *p_avtimer_lsw;
-	uint32_t clk_div;
-	uint32_t clk_mult;
-	atomic_t adsp_ready;
-	int num_retries;
-};
-
-static struct avtimer_t avtimer;
-
-static int32_t aprv2_core_fn_q(struct apr_client_data *data, void *priv)
-{
-	uint32_t *payload1;
-
-	if (!data) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: core msg: payload len = %u, apr resp opcode = 0x%X\n",
-		__func__, data->payload_size, data->opcode);
-
-	switch (data->opcode) {
-
-	case APR_BASIC_RSP_RESULT:{
-
-		if (!data->payload_size) {
-			pr_err("%s: APR_BASIC_RSP_RESULT No Payload ",
-					__func__);
-			return 0;
-		}
-
-		payload1 = data->payload;
-		switch (payload1[0]) {
-		case AVCS_CMD_REMOTE_AVTIMER_RELEASE_REQUEST:
-			pr_debug("%s: Cmd = TIMER RELEASE status[0x%x]\n",
-			__func__, payload1[1]);
-			break;
-		default:
-			pr_err("Invalid cmd rsp[0x%x][0x%x]\n",
-					payload1[0], payload1[1]);
-			break;
-		}
-		break;
-	}
-
-	case RESET_EVENTS:{
-		pr_debug("%s: Reset event received in AV timer\n", __func__);
-		apr_reset(avtimer.core_handle_q);
-		avtimer.core_handle_q = NULL;
-		avtimer.avtimer_open_cnt = 0;
-		atomic_set(&avtimer.adsp_ready, 0);
-		schedule_delayed_work(&avtimer.ssr_dwork,
-				  msecs_to_jiffies(SSR_WAKETIME));
-		break;
-	}
-
-	case AVCS_CMD_RSP_REMOTE_AVTIMER_VOTE_REQUEST:
-		payload1 = data->payload;
-		pr_debug("%s: RSP_REMOTE_AVTIMER_VOTE_REQUEST handle %x\n",
-			__func__, payload1[0]);
-		avtimer.timer_handle = payload1[0];
-		avtimer.enable_timer_resp_received = 1;
-		wake_up(&avtimer.adsp_resp_wait);
-		break;
-	default:
-		pr_err("%s: Message adspcore svc: %d\n",
-				__func__, data->opcode);
-		break;
-	}
-
-	return 0;
-}
-
-int avcs_core_open(void)
-{
-	if (!avtimer.core_handle_q)
-		avtimer.core_handle_q = apr_register("ADSP", "CORE",
-					aprv2_core_fn_q, TEMP_PORT, NULL);
-	pr_debug("%s: Open_q %p\n", __func__, avtimer.core_handle_q);
-	if (!avtimer.core_handle_q) {
-		pr_err("%s: Unable to register CORE\n", __func__);
-		return -EINVAL;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(avcs_core_open);
-
-static int avcs_core_disable_avtimer(int timerhandle)
-{
-	int rc = -EINVAL;
-	struct adsp_avt_timer payload;
-
-	if (!timerhandle) {
-		pr_err("%s: Invalid timer handle\n", __func__);
-		return -EINVAL;
-	}
-	memset(&payload, 0, sizeof(payload));
-	rc = avcs_core_open();
-	if (!rc && avtimer.core_handle_q) {
-		payload.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		payload.hdr.pkt_size =
-			sizeof(struct adsp_avt_timer);
-		payload.hdr.src_svc = avtimer.core_handle_q->id;
-		payload.hdr.src_domain = APR_DOMAIN_APPS;
-		payload.hdr.dest_domain = APR_DOMAIN_ADSP;
-		payload.hdr.dest_svc = APR_SVC_ADSP_CORE;
-		payload.hdr.src_port = TEMP_PORT;
-		payload.hdr.dest_port = TEMP_PORT;
-		payload.hdr.token = CORE_CLIENT;
-		payload.hdr.opcode = AVCS_CMD_REMOTE_AVTIMER_RELEASE_REQUEST;
-		payload.avtimer_handle = timerhandle;
-		pr_debug("%s: disable avtimer opcode %x handle %x\n",
-			__func__, payload.hdr.opcode, payload.avtimer_handle);
-		rc = apr_send_pkt(avtimer.core_handle_q,
-						(uint32_t *)&payload);
-		if (rc < 0)
-			pr_err("%s: Enable AVtimer failed op[0x%x]rc[%d]\n",
-				__func__, payload.hdr.opcode, rc);
-		else
-			rc = 0;
-	}
-	return rc;
-}
-
-static int avcs_core_enable_avtimer(char *client_name)
-{
-	int rc = -EINVAL, ret = -EINVAL;
-	struct adsp_avt_timer payload;
-
-	if (!client_name) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	memset(&payload, 0, sizeof(payload));
-	rc = avcs_core_open();
-	if (!rc && avtimer.core_handle_q) {
-		avtimer.enable_timer_resp_received = 0;
-		payload.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_EVENT,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		payload.hdr.pkt_size =
-			sizeof(struct adsp_avt_timer);
-		payload.hdr.src_svc = avtimer.core_handle_q->id;
-		payload.hdr.src_domain = APR_DOMAIN_APPS;
-		payload.hdr.dest_domain = APR_DOMAIN_ADSP;
-		payload.hdr.dest_svc = APR_SVC_ADSP_CORE;
-		payload.hdr.src_port = TEMP_PORT;
-		payload.hdr.dest_port = TEMP_PORT;
-		payload.hdr.token = CORE_CLIENT;
-		payload.hdr.opcode = AVCS_CMD_REMOTE_AVTIMER_VOTE_REQUEST;
-		strlcpy(payload.client_name, client_name,
-			   sizeof(payload.client_name));
-		pr_debug("%s: enable avtimer opcode %x client name %s\n",
-			__func__, payload.hdr.opcode, payload.client_name);
-		rc = apr_send_pkt(avtimer.core_handle_q,
-						(uint32_t *)&payload);
-		if (rc < 0) {
-			pr_err("%s: Enable AVtimer failed op[0x%x]rc[%d]\n",
-				__func__, payload.hdr.opcode, rc);
-			goto bail;
-		} else
-			rc = 0;
-		ret = wait_event_timeout(avtimer.adsp_resp_wait,
-			(avtimer.enable_timer_resp_received == 1),
-			msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout for Enable timer\n",
-					__func__);
-			rc = -ETIMEDOUT;
-		}
-		if (rc)
-			avtimer.timer_handle = 0;
-	}
-bail:
-	return rc;
-}
-
-int avcs_core_disable_power_collapse(int enable)
-{
-	int rc = 0;
-
-	mutex_lock(&avtimer.avtimer_lock);
-	if (enable) {
-		if (avtimer.avtimer_open_cnt) {
-			avtimer.avtimer_open_cnt++;
-			pr_debug("%s: opened avtimer open count=%d\n",
-				__func__, avtimer.avtimer_open_cnt);
-			rc = 0;
-			goto done;
-		}
-		rc = avcs_core_enable_avtimer("timer");
-		if (!rc) {
-			avtimer.avtimer_open_cnt++;
-			atomic_set(&avtimer.adsp_ready, 1);
-		}
-	} else {
-		if (avtimer.avtimer_open_cnt > 0) {
-			avtimer.avtimer_open_cnt--;
-			if (!avtimer.avtimer_open_cnt) {
-				rc = avcs_core_disable_avtimer(
-				avtimer.timer_handle);
-				avtimer.timer_handle = 0;
-			}
-		}
-	}
-done:
-	mutex_unlock(&avtimer.avtimer_lock);
-	return rc;
-}
-EXPORT_SYMBOL(avcs_core_disable_power_collapse);
-
-static void reset_work(struct work_struct *work)
-{
-	if (q6core_is_adsp_ready()) {
-		avcs_core_disable_power_collapse(1);
-		avtimer.num_retries = Q6_READY_MAX_RETRIES;
-		return;
-	}
-	pr_debug("%s:Q6 not ready-retry after sometime\n", __func__);
-	if (--avtimer.num_retries > 0) {
-		schedule_delayed_work(&avtimer.ssr_dwork,
-			  msecs_to_jiffies(Q6_READY_RETRY));
-	} else {
-		pr_err("%s: Q6 failed responding after multiple retries\n",
-							__func__);
-		avtimer.num_retries = Q6_READY_MAX_RETRIES;
-	}
-}
-
-int avcs_core_query_timer(uint64_t *avtimer_tick)
-{
-	uint32_t avtimer_msw = 0, avtimer_lsw = 0;
-	uint64_t avtimer_tick_temp;
-
-	if (!atomic_read(&avtimer.adsp_ready)) {
-		pr_debug("%s:In SSR, return\n", __func__);
-		return -ENETRESET;
-	}
-	avtimer_lsw = ioread32(avtimer.p_avtimer_lsw);
-	avtimer_msw = ioread32(avtimer.p_avtimer_msw);
-
-	avtimer_tick_temp = (uint64_t)((uint64_t)avtimer_msw << 32)
-			    | avtimer_lsw;
-	*avtimer_tick = mul_u64_u32_div(avtimer_tick_temp, avtimer.clk_mult,
-					avtimer.clk_div);
-	pr_debug_ratelimited("%s:Avtimer: msw: %u, lsw: %u, tick: %llu\n",
-			__func__,
-			avtimer_msw, avtimer_lsw, *avtimer_tick);
-	return 0;
-}
-EXPORT_SYMBOL(avcs_core_query_timer);
-
-static int avtimer_open(struct inode *inode, struct file *file)
-{
-	return avcs_core_disable_power_collapse(1);
-}
-
-static int avtimer_release(struct inode *inode, struct file *file)
-{
-	return avcs_core_disable_power_collapse(0);
-}
-
-/*
- * ioctl call provides GET_AVTIMER
- */
-static long avtimer_ioctl(struct file *file, unsigned int ioctl_num,
-				unsigned long ioctl_param)
-{
-	switch (ioctl_num) {
-	case IOCTL_GET_AVTIMER_TICK:
-	{
-		uint64_t avtimer_tick = 0;
-		int rc;
-
-		rc = avcs_core_query_timer(&avtimer_tick);
-
-		if (rc) {
-			pr_err("%s: Error: Invalid AV Timer tick, rc = %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		pr_debug_ratelimited("%s: AV Timer tick: time %llx\n",
-		__func__, avtimer_tick);
-		if (copy_to_user((void *) ioctl_param, &avtimer_tick,
-		    sizeof(avtimer_tick))) {
-			pr_err("%s: copy_to_user failed\n", __func__);
-			return -EFAULT;
-		}
-	}
-		break;
-
-	default:
-		pr_err("%s: invalid cmd\n", __func__);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static const struct file_operations avtimer_fops = {
-	.unlocked_ioctl = avtimer_ioctl,
-	.compat_ioctl = avtimer_ioctl,
-	.open = avtimer_open,
-	.release = avtimer_release
-};
-
-static int dev_avtimer_probe(struct platform_device *pdev)
-{
-	int result = 0;
-	dev_t dev = MKDEV(major, 0);
-	struct device *device_handle;
-	struct resource *reg_lsb = NULL, *reg_msb = NULL;
-	uint32_t clk_div_val;
-	uint32_t clk_mult_val;
-
-	if (!pdev) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	reg_lsb = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "avtimer_lsb_addr");
-	if (!reg_lsb) {
-		dev_err(&pdev->dev, "%s: Looking up %s property",
-			"avtimer_lsb_addr", __func__);
-		return -EINVAL;
-	}
-	reg_msb = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "avtimer_msb_addr");
-	if (!reg_msb) {
-		dev_err(&pdev->dev, "%s: Looking up %s property",
-			"avtimer_msb_addr", __func__);
-		return -EINVAL;
-	}
-	INIT_DELAYED_WORK(&avtimer.ssr_dwork, reset_work);
-
-	avtimer.p_avtimer_lsw = devm_ioremap_nocache(&pdev->dev,
-				reg_lsb->start, resource_size(reg_lsb));
-	if (!avtimer.p_avtimer_lsw) {
-		dev_err(&pdev->dev, "%s: ioremap failed for lsb avtimer register",
-			__func__);
-		return -ENOMEM;
-	}
-
-	avtimer.p_avtimer_msw = devm_ioremap_nocache(&pdev->dev,
-				reg_msb->start, resource_size(reg_msb));
-	if (!avtimer.p_avtimer_msw) {
-		dev_err(&pdev->dev, "%s: ioremap failed for msb avtimer register",
-			__func__);
-		goto unmap;
-	}
-	avtimer.num_retries = Q6_READY_MAX_RETRIES;
-	/* get the device number */
-	if (major)
-		result = register_chrdev_region(dev, 1, DEVICE_NAME);
-	else {
-		result = alloc_chrdev_region(&dev, 0, 1, DEVICE_NAME);
-		major = MAJOR(dev);
-	}
-
-	if (result < 0) {
-		dev_err(&pdev->dev, "%s: Registering avtimer device failed\n",
-			__func__);
-		goto unmap;
-	}
-
-	avtimer.avtimer_class = class_create(THIS_MODULE, "avtimer");
-	if (IS_ERR(avtimer.avtimer_class)) {
-		result = PTR_ERR(avtimer.avtimer_class);
-		dev_err(&pdev->dev, "%s: Error creating avtimer class: %d\n",
-			__func__, result);
-		goto unregister_chrdev_region;
-	}
-
-	cdev_init(&avtimer.myc, &avtimer_fops);
-	result = cdev_add(&avtimer.myc, dev, 1);
-
-	if (result < 0) {
-		dev_err(&pdev->dev, "%s: Registering file operations failed\n",
-			__func__);
-		goto class_destroy;
-	}
-
-	device_handle = device_create(avtimer.avtimer_class,
-			NULL, avtimer.myc.dev, NULL, "avtimer");
-	if (IS_ERR(device_handle)) {
-		result = PTR_ERR(device_handle);
-		pr_err("%s: device_create failed: %d\n", __func__, result);
-		goto class_destroy;
-	}
-	init_waitqueue_head(&avtimer.adsp_resp_wait);
-	mutex_init(&avtimer.avtimer_lock);
-	avtimer.avtimer_open_cnt = 0;
-
-	pr_debug("%s: Device create done for avtimer major=%d\n",
-			__func__, major);
-
-	if (of_property_read_u32(pdev->dev.of_node,
-			"qcom,clk-div", &clk_div_val))
-		avtimer.clk_div = 1;
-	else
-		avtimer.clk_div = clk_div_val;
-
-	if (of_property_read_u32(pdev->dev.of_node,
-			"qcom,clk-mult", &clk_mult_val))
-		avtimer.clk_mult = 1;
-	else
-		avtimer.clk_mult = clk_mult_val;
-
-	pr_debug("%s: avtimer.clk_div = %d, avtimer.clk_mult = %d\n",
-		 __func__, avtimer.clk_div, avtimer.clk_mult);
-	return 0;
-
-class_destroy:
-	class_destroy(avtimer.avtimer_class);
-unregister_chrdev_region:
-	unregister_chrdev_region(MKDEV(major, 0), 1);
-unmap:
-	if (avtimer.p_avtimer_lsw)
-		devm_iounmap(&pdev->dev, avtimer.p_avtimer_lsw);
-	if (avtimer.p_avtimer_msw)
-		devm_iounmap(&pdev->dev, avtimer.p_avtimer_msw);
-	avtimer.p_avtimer_lsw = NULL;
-	avtimer.p_avtimer_msw = NULL;
-	return result;
-
-}
-
-static int dev_avtimer_remove(struct platform_device *pdev)
-{
-	pr_debug("%s: dev_avtimer_remove\n", __func__);
-
-	if (avtimer.p_avtimer_lsw)
-		devm_iounmap(&pdev->dev, avtimer.p_avtimer_lsw);
-	if (avtimer.p_avtimer_msw)
-		devm_iounmap(&pdev->dev, avtimer.p_avtimer_msw);
-	device_destroy(avtimer.avtimer_class, avtimer.myc.dev);
-	cdev_del(&avtimer.myc);
-	class_destroy(avtimer.avtimer_class);
-	unregister_chrdev_region(MKDEV(major, 0), 1);
-
-	return 0;
-}
-
-static const struct of_device_id avtimer_machine_of_match[]  = {
-	{ .compatible = "qcom,avtimer", },
-	{},
-};
-static struct platform_driver dev_avtimer_driver = {
-	.probe = dev_avtimer_probe,
-	.remove = dev_avtimer_remove,
-	.driver = {
-		.name = "dev_avtimer",
-		.of_match_table = avtimer_machine_of_match,
-	},
-};
-
-static int  __init avtimer_init(void)
-{
-	s32 rc;
-
-	rc = platform_driver_register(&dev_avtimer_driver);
-	if (rc < 0) {
-		pr_err("%s: platform_driver_register failed\n", __func__);
-		goto error_platform_driver;
-	}
-	pr_debug("%s: dev_avtimer_init : done\n", __func__);
-
-	return 0;
-error_platform_driver:
-
-	pr_err("%s: encounterd error\n", __func__);
-	return rc;
-}
-
-static void __exit avtimer_exit(void)
-{
-	pr_debug("%s: avtimer_exit\n", __func__);
-	platform_driver_unregister(&dev_avtimer_driver);
-}
-
-module_init(avtimer_init);
-module_exit(avtimer_exit);
-
-MODULE_DESCRIPTION("avtimer driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/soc/qcom/dcc_v2.c b/drivers/soc/qcom/dcc_v2.c
index 21b2034..e11efb0 100644
--- a/drivers/soc/qcom/dcc_v2.c
+++ b/drivers/soc/qcom/dcc_v2.c
@@ -148,11 +148,6 @@
 	struct class		*sram_class;
 	struct list_head	cfg_head[DCC_MAX_LINK_LIST];
 	uint32_t		nr_config[DCC_MAX_LINK_LIST];
-	void			*reg_buf;
-	struct msm_dump_data	reg_data;
-	bool			save_reg;
-	void			*sram_buf;
-	struct msm_dump_data	sram_data;
 	uint8_t			curr_list;
 	uint8_t			cti_trig;
 };
@@ -490,39 +485,6 @@
 	return ret;
 }
 
-static void __dcc_reg_dump(struct dcc_drvdata *drvdata)
-{
-	uint32_t *reg_buf;
-	uint8_t i = 0;
-	uint8_t j;
-
-	if (!drvdata->reg_buf)
-		return;
-
-	drvdata->reg_data.version = DCC_REG_DUMP_VER;
-
-	reg_buf = drvdata->reg_buf;
-
-	reg_buf[i++] = dcc_readl(drvdata, DCC_HW_VERSION);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_HW_INFO);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_EXEC_CTRL);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_STATUS);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_CFG);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_FDA_CURR);
-	reg_buf[i++] = dcc_readl(drvdata, DCC_LLA_CURR);
-
-	for (j = 0; j < DCC_MAX_LINK_LIST; j++)
-		reg_buf[i++] = dcc_readl(drvdata, DCC_LL_LOCK(j));
-	for (j = 0; j < DCC_MAX_LINK_LIST; j++)
-		reg_buf[i++] = dcc_readl(drvdata, DCC_LL_CFG(j));
-	for (j = 0; j < DCC_MAX_LINK_LIST; j++)
-		reg_buf[i++] = dcc_readl(drvdata, DCC_LL_BASE(j));
-	for (j = 0; j < DCC_MAX_LINK_LIST; j++)
-		reg_buf[i++] = dcc_readl(drvdata, DCC_FD_BASE(j));
-
-	drvdata->reg_data.magic = DCC_REG_DUMP_MAGIC_V2;
-}
-
 static void __dcc_first_crc(struct dcc_drvdata *drvdata)
 {
 	int i;
@@ -598,7 +560,7 @@
 				   drvdata->ram_offset/4, DCC_LL_BASE(list));
 			dcc_writel(drvdata, drvdata->ram_start +
 				   drvdata->ram_offset/4, DCC_FD_BASE(list));
-			dcc_writel(drvdata, 0, DCC_LL_TIMEOUT(list));
+			dcc_writel(drvdata, 0xFFF, DCC_LL_TIMEOUT(list));
 		}
 
 		/* 4. Configure trigger, data sink and function type */
@@ -626,9 +588,6 @@
 					   DCC_LL_INT_ENABLE(list));
 		}
 	}
-	/* Save DCC registers */
-	if (drvdata->save_reg)
-		__dcc_reg_dump(drvdata);
 
 err:
 	mutex_unlock(&drvdata->mutex);
@@ -653,9 +612,6 @@
 	}
 	drvdata->ram_cfg = 0;
 	drvdata->ram_start = 0;
-	/* Save DCC registers */
-	if (drvdata->save_reg)
-		__dcc_reg_dump(drvdata);
 
 	mutex_unlock(&drvdata->mutex);
 }
@@ -1462,47 +1418,6 @@
 	dcc_sram_dev_deregister(drvdata);
 }
 
-static void dcc_allocate_dump_mem(struct dcc_drvdata *drvdata)
-{
-	int ret;
-	struct device *dev = drvdata->dev;
-	struct msm_dump_entry reg_dump_entry, sram_dump_entry;
-
-	/* Allocate memory for dcc reg dump */
-	drvdata->reg_buf = devm_kzalloc(dev, drvdata->reg_size, GFP_KERNEL);
-	if (drvdata->reg_buf) {
-		drvdata->reg_data.addr = virt_to_phys(drvdata->reg_buf);
-		drvdata->reg_data.len = drvdata->reg_size;
-		reg_dump_entry.id = MSM_DUMP_DATA_DCC_REG;
-		reg_dump_entry.addr = virt_to_phys(&drvdata->reg_data);
-		ret = msm_dump_data_register(MSM_DUMP_TABLE_APPS,
-					     &reg_dump_entry);
-		if (ret) {
-			dev_err(dev, "DCC REG dump setup failed\n");
-			devm_kfree(dev, drvdata->reg_buf);
-		}
-	} else {
-		dev_err(dev, "DCC REG dump allocation failed\n");
-	}
-
-	/* Allocate memory for dcc sram dump */
-	drvdata->sram_buf = devm_kzalloc(dev, drvdata->ram_size, GFP_KERNEL);
-	if (drvdata->sram_buf) {
-		drvdata->sram_data.addr = virt_to_phys(drvdata->sram_buf);
-		drvdata->sram_data.len = drvdata->ram_size;
-		sram_dump_entry.id = MSM_DUMP_DATA_DCC_SRAM;
-		sram_dump_entry.addr = virt_to_phys(&drvdata->sram_data);
-		ret = msm_dump_data_register(MSM_DUMP_TABLE_APPS,
-					     &sram_dump_entry);
-		if (ret) {
-			dev_err(dev, "DCC SRAM dump setup failed\n");
-			devm_kfree(dev, drvdata->sram_buf);
-		}
-	} else {
-		dev_err(dev, "DCC SRAM dump allocation failed\n");
-	}
-}
-
 static int dcc_probe(struct platform_device *pdev)
 {
 	int ret, i;
@@ -1542,9 +1457,6 @@
 	if (ret)
 		return -EINVAL;
 
-	drvdata->save_reg = of_property_read_bool(pdev->dev.of_node,
-						  "qcom,save-reg");
-
 	mutex_init(&drvdata->mutex);
 
 	for (i = 0; i < DCC_MAX_LINK_LIST; i++) {
@@ -1580,7 +1492,6 @@
 	if (ret)
 		goto err;
 
-	dcc_allocate_dump_mem(drvdata);
 	return 0;
 err:
 	return ret;
diff --git a/drivers/soc/qcom/eud.c b/drivers/soc/qcom/eud.c
index 51c08c6..f7f3317 100644
--- a/drivers/soc/qcom/eud.c
+++ b/drivers/soc/qcom/eud.c
@@ -27,6 +27,8 @@
 #include <linux/serial.h>
 #include <linux/workqueue.h>
 #include <linux/power_supply.h>
+#include <linux/clk.h>
+#include <linux/of.h>
 
 #define EUD_ENABLE_CMD 1
 #define EUD_DISABLE_CMD 0
@@ -71,6 +73,7 @@
 	struct uart_port		port;
 	struct work_struct		eud_work;
 	struct power_supply		*batt_psy;
+	struct clk			*cfg_ahb_clk;
 };
 
 static const unsigned int eud_extcon_cable[] = {
@@ -119,7 +122,7 @@
 		/* write into CSR to enable EUD */
 		writel_relaxed(BIT(0), priv->eud_reg_base + EUD_REG_CSR_EUD_EN);
 		/* Enable vbus, chgr & safe mode warning interrupts */
-		writel_relaxed(EUD_INT_VBUS | EUD_INT_CHGR | EUD_INT_SAFE_MODE,
+		writel_relaxed(EUD_INT_VBUS | EUD_INT_CHGR,
 				priv->eud_reg_base + EUD_REG_INT1_EN_MASK);
 
 		/* Ensure Register Writes Complete */
@@ -448,7 +451,11 @@
 {
 	struct eud_chip *chip = data;
 	u32 reg;
-	u32 int_mask_en1 = readl_relaxed(chip->eud_reg_base +
+	u32 int_mask_en1;
+
+	clk_prepare_enable(chip->cfg_ahb_clk);
+
+	int_mask_en1 = readl_relaxed(chip->eud_reg_base +
 					EUD_REG_INT1_EN_MASK);
 
 	/* read status register and find out which interrupt triggered */
@@ -472,9 +479,11 @@
 		pet_eud(chip);
 	} else {
 		dev_dbg(chip->dev, "Unknown/spurious EUD Interrupt!\n");
+		clk_disable_unprepare(chip->cfg_ahb_clk);
 		return IRQ_NONE;
 	}
 
+	clk_disable_unprepare(chip->cfg_ahb_clk);
 	return IRQ_HANDLED;
 }
 
@@ -492,6 +501,7 @@
 	}
 
 	platform_set_drvdata(pdev, chip);
+	chip->dev = &pdev->dev;
 
 	chip->extcon = devm_extcon_dev_allocate(&pdev->dev, eud_extcon_cable);
 	if (IS_ERR(chip->extcon)) {
@@ -517,10 +527,25 @@
 	if (IS_ERR(chip->eud_reg_base))
 		return PTR_ERR(chip->eud_reg_base);
 
+	if (of_property_match_string(pdev->dev.of_node,
+				"clock-names", "cfg_ahb_clk") >= 0) {
+		chip->cfg_ahb_clk = devm_clk_get(&pdev->dev, "cfg_ahb_clk");
+		if (IS_ERR(chip->cfg_ahb_clk)) {
+			ret = PTR_ERR(chip->cfg_ahb_clk);
+			if (ret != -EPROBE_DEFER)
+				dev_err(chip->dev,
+				"clk get failed for cfg_ahb_clk ret %d\n",
+				ret);
+			return ret;
+		}
+	}
+
 	chip->eud_irq = platform_get_irq_byname(pdev, "eud_irq");
 
-	ret = devm_request_irq(&pdev->dev, chip->eud_irq, handle_eud_irq,
-				IRQF_TRIGGER_HIGH, "eud_irq", chip);
+	ret = devm_request_threaded_irq(&pdev->dev, chip->eud_irq,
+					NULL, handle_eud_irq,
+					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+					"eud_irq", chip);
 	if (ret) {
 		dev_err(chip->dev, "request failed for eud irq\n");
 		return ret;
diff --git a/drivers/soc/qcom/gladiator_erp.c b/drivers/soc/qcom/gladiator_erp.c
index 835d4b0..3b70ca4 100644
--- a/drivers/soc/qcom/gladiator_erp.c
+++ b/drivers/soc/qcom/gladiator_erp.c
@@ -163,6 +163,7 @@
 	DISCONNECT_ERROR,
 	DIRECTORY_ERROR,
 	PARITY_ERROR,
+	PHYSICAL_ADDRESS_ERROR,
 };
 
 static void clear_gladiator_error(void __iomem *gladiator_virt_base,
@@ -200,12 +201,14 @@
 
 static inline void print_gld_errtype(unsigned int errtype)
 {
+	char *errors = "Disconnect, Directory, Parity, Physical address";
+
 	if (errtype == 0)
 		pr_alert("Error type: Snoop data transfer\n");
 	else if (errtype == 1)
 		pr_alert("Error type: DVM error\n");
 	else if (errtype == 3)
-		pr_alert("Error type: Disconnect, directory, or parity error\n");
+		pr_alert("Error type: %s\n", errors);
 	else
 		pr_alert("Error type: Unknown; value:%u\n", errtype);
 }
@@ -288,7 +291,7 @@
 
 	log_err_type = (err_reg5 & mask_shifts->gld_errlog5_error_type_mask)
 		>> mask_shifts->gld_errlog5_error_type_shift;
-	for (i = 0 ; i <= 6 ; i++) {
+	for (i = 0 ; i <= 7 ; i++) {
 		value = log_err_type & 0x1;
 		switch (i) {
 		case DATA_TRANSFER_ERROR:
@@ -337,7 +340,14 @@
 					mask_shifts);
 			decode_index_parity(err_reg5, mask_shifts);
 			break;
+		case PHYSICAL_ADDRESS_ERROR:
+			if (value == 0)
+				continue;
+			pr_alert("Error type: Physical address error\n");
+			pr_alert("Address is greater than SoC address range\n");
+			break;
 		}
+
 		log_err_type = log_err_type >> 1;
 	}
 }
diff --git a/drivers/soc/qcom/glink.c b/drivers/soc/qcom/glink.c
index 1d605e3..6019e4b 100644
--- a/drivers/soc/qcom/glink.c
+++ b/drivers/soc/qcom/glink.c
@@ -604,10 +604,11 @@
 static unsigned long glink_qos_calc_rate_kBps(size_t pkt_size,
 				       unsigned long interval_us)
 {
-	unsigned long rate_kBps, rem;
+	unsigned long rem;
+	uint64_t rate_kBps;
 
 	rate_kBps = pkt_size * USEC_PER_SEC;
-	rem = do_div(rate_kBps, (interval_us * 1024));
+	rem = do_div(rate_kBps, interval_us * 1024);
 	return rate_kBps;
 }
 
@@ -2372,6 +2373,35 @@
 }
 
 /**
+ * dummy_tx_cmd_ch_open() - dummy channel open cmd sending function
+ * @if_ptr:	The transport to transmit on.
+ * @lcid:	The local channel id to encode.
+ * @name:	The channel name to encode.
+ * @req_xprt:	The transport the core would like to migrate this channel to.
+ *
+ * Return: 0 on success or standard Linux error code.
+ */
+static int dummy_tx_cmd_ch_open(struct glink_transport_if *if_ptr,
+			uint32_t lcid, const char *name,
+			uint16_t req_xprt)
+{
+	return -EOPNOTSUPP;
+}
+
+/**
+ * dummy_tx_cmd_ch_remote_open_ack() - convert a channel open ack cmd to wire
+ *				format and transmit
+ * @if_ptr:	The transport to transmit on.
+ * @rcid:	The remote channel id to encode.
+ * @xprt_resp:	The response to a transport migration request.
+ */
+static void dummy_tx_cmd_ch_remote_open_ack(struct glink_transport_if *if_ptr,
+					uint32_t rcid, uint16_t xprt_resp)
+{
+	/* intentionally left blank */
+}
+
+/**
  * dummy_get_power_vote_ramp_time() - Dummy Power vote ramp time
  * @if_ptr:	The transport to transmit on.
  * @state:	The power state being requested from the transport.
@@ -4184,8 +4214,14 @@
 	if_ptr->tx_cmd_remote_rx_intent_req_ack =
 				dummy_tx_cmd_remote_rx_intent_req_ack;
 	if_ptr->tx_cmd_set_sigs = dummy_tx_cmd_set_sigs;
+	if_ptr->tx_cmd_ch_open = dummy_tx_cmd_ch_open;
+	if_ptr->tx_cmd_ch_remote_open_ack = dummy_tx_cmd_ch_remote_open_ack;
 	if_ptr->tx_cmd_ch_close = dummy_tx_cmd_ch_close;
 	if_ptr->tx_cmd_ch_remote_close_ack = dummy_tx_cmd_ch_remote_close_ack;
+	if_ptr->tx_cmd_tracer_pkt = dummy_tx_cmd_tracer_pkt;
+	if_ptr->get_power_vote_ramp_time = dummy_get_power_vote_ramp_time;
+	if_ptr->power_vote = dummy_power_vote;
+	if_ptr->power_unvote = dummy_power_unvote;
 
 	xprt_ptr->ops = if_ptr;
 	xprt_ptr->log_ctx = log_ctx;
@@ -5419,8 +5455,8 @@
 static void glink_scheduler_eval_prio(struct channel_ctx *ctx,
 			struct glink_core_xprt_ctx *xprt_ctx)
 {
-	unsigned long token_end_time;
-	unsigned long token_consume_time, rem;
+	unsigned long token_end_time, rem;
+	uint64_t token_consume_time;
 	unsigned long obs_rate_kBps;
 
 	if (ctx->initial_priority == 0)
diff --git a/drivers/soc/qcom/glink_spi_xprt.c b/drivers/soc/qcom/glink_spi_xprt.c
index c44aa93..a08c4bf 100644
--- a/drivers/soc/qcom/glink_spi_xprt.c
+++ b/drivers/soc/qcom/glink_spi_xprt.c
@@ -121,6 +121,8 @@
  * @tx_fifo_write_reg_addr:	Address of the TX FIFO Write Index Register.
  * @rx_fifo_read_reg_addr:	Address of the RX FIFO Read Index Register.
  * @rx_fifo_write_reg_addr:	Address of the RX FIFO Write Index Register.
+ * @tx_fifo_write:		Internal write index for TX FIFO.
+ * @rx_fifo_read:		Internal read index for RX FIFO.
  * @kwork:			Work to be executed when receiving data.
  * @kworker:			Handle to the entity processing @kwork.
  * @task:			Handle to the task context that runs @kworker.
@@ -158,6 +160,8 @@
 	unsigned int tx_fifo_write_reg_addr;
 	unsigned int rx_fifo_read_reg_addr;
 	unsigned int rx_fifo_write_reg_addr;
+	uint32_t tx_fifo_write;
+	uint32_t rx_fifo_read;
 
 	struct kthread_work kwork;
 	struct kthread_worker kworker;
@@ -374,6 +378,19 @@
 	int write_avail;
 	int ret;
 
+	if (unlikely(!einfo->tx_fifo_start)) {
+		ret = glink_spi_xprt_reg_read(einfo,
+			einfo->tx_fifo_write_reg_addr, &einfo->tx_fifo_write);
+		if (ret < 0) {
+			pr_err("%s: Error %d reading %s tx_fifo_write_reg_addr %d\n",
+				__func__, ret, einfo->xprt_cfg.edge,
+				einfo->tx_fifo_write_reg_addr);
+			return 0;
+		}
+		einfo->tx_fifo_start = einfo->tx_fifo_write;
+	}
+	write_id = einfo->tx_fifo_write;
+
 	ret = glink_spi_xprt_reg_read(einfo, einfo->tx_fifo_read_reg_addr,
 				   &read_id);
 	if (ret < 0) {
@@ -383,21 +400,9 @@
 		return 0;
 	}
 
-	ret = glink_spi_xprt_reg_read(einfo, einfo->tx_fifo_write_reg_addr,
-				&write_id);
-	if (ret < 0) {
-		pr_err("%s: Error %d reading %s tx_fifo_write_reg_addr %d\n",
-			__func__, ret, einfo->xprt_cfg.edge,
-			einfo->tx_fifo_write_reg_addr);
-		return 0;
-	}
-
 	if (!read_id || !write_id)
 		return 0;
 
-	if (unlikely(!einfo->tx_fifo_start))
-		einfo->tx_fifo_start = write_id;
-
 	if (read_id > write_id)
 		write_avail = read_id - write_id;
 	else
@@ -427,14 +432,18 @@
 	int read_avail;
 	int ret;
 
-	ret = glink_spi_xprt_reg_read(einfo, einfo->rx_fifo_read_reg_addr,
-				   &read_id);
-	if (ret < 0) {
-		pr_err("%s: Error %d reading %s rx_fifo_read_reg_addr %d\n",
-			__func__, ret, einfo->xprt_cfg.edge,
-			einfo->rx_fifo_read_reg_addr);
-		return 0;
+	if (unlikely(!einfo->rx_fifo_start)) {
+		ret = glink_spi_xprt_reg_read(einfo,
+			einfo->rx_fifo_read_reg_addr, &einfo->rx_fifo_read);
+		if (ret < 0) {
+			pr_err("%s: Error %d reading %s rx_fifo_read_reg_addr %d\n",
+				__func__, ret, einfo->xprt_cfg.edge,
+				einfo->rx_fifo_read_reg_addr);
+			return 0;
+		}
+		einfo->rx_fifo_start = einfo->rx_fifo_read;
 	}
+	read_id = einfo->rx_fifo_read;
 
 	ret = glink_spi_xprt_reg_read(einfo, einfo->rx_fifo_write_reg_addr,
 				&write_id);
@@ -448,9 +457,6 @@
 	if (!read_id || !write_id)
 		return 0;
 
-	if (unlikely(!einfo->rx_fifo_start))
-		einfo->rx_fifo_start = read_id;
-
 	if (read_id <= write_id)
 		read_avail = write_id - read_id;
 	else
@@ -477,15 +483,7 @@
 	uint32_t offset = 0;
 	int ret;
 
-	ret = glink_spi_xprt_reg_read(einfo, einfo->rx_fifo_read_reg_addr,
-				   &read_id);
-	if (ret < 0) {
-		pr_err("%s: Error %d reading %s rx_fifo_read_reg_addr %d\n",
-			__func__, ret, einfo->xprt_cfg.edge,
-			einfo->rx_fifo_read_reg_addr);
-		return ret;
-	}
-
+	read_id = einfo->rx_fifo_read;
 	do {
 		if ((read_id + size_to_read) >=
 		    (einfo->rx_fifo_start + einfo->fifo_size))
@@ -510,6 +508,9 @@
 		pr_err("%s: Error %d writing %s rx_fifo_read_reg_addr %d\n",
 			__func__, ret, einfo->xprt_cfg.edge,
 			einfo->rx_fifo_read_reg_addr);
+	else
+		einfo->rx_fifo_read = read_id;
+
 	return ret;
 }
 
@@ -532,15 +533,7 @@
 	uint32_t offset = 0;
 	int ret;
 
-	ret = glink_spi_xprt_reg_read(einfo, einfo->tx_fifo_write_reg_addr,
-				&write_id);
-	if (ret < 0) {
-		pr_err("%s: Error %d reading %s tx_fifo_write_reg_addr %d\n",
-			__func__, ret, einfo->xprt_cfg.edge,
-			einfo->tx_fifo_write_reg_addr);
-		return ret;
-	}
-
+	write_id = einfo->tx_fifo_write;
 	do {
 		if ((write_id + size_to_write) >=
 		    (einfo->tx_fifo_start + einfo->fifo_size))
@@ -565,6 +558,9 @@
 		pr_err("%s: Error %d writing %s tx_fifo_write_reg_addr %d\n",
 			__func__, ret, einfo->xprt_cfg.edge,
 			einfo->tx_fifo_write_reg_addr);
+	else
+		einfo->tx_fifo_write = write_id;
+
 	return ret;
 }
 
@@ -1242,6 +1238,8 @@
 	einfo->tx_blocked_signal_sent = false;
 	einfo->tx_fifo_start = 0;
 	einfo->rx_fifo_start = 0;
+	einfo->tx_fifo_write = 0;
+	einfo->rx_fifo_read = 0;
 	einfo->fifo_size = DEFAULT_FIFO_SIZE;
 	einfo->xprt_if.glink_core_if_ptr->link_down(&einfo->xprt_if);
 
diff --git a/drivers/soc/qcom/icnss.c b/drivers/soc/qcom/icnss.c
index dc891eb..6ce481b 100644
--- a/drivers/soc/qcom/icnss.c
+++ b/drivers/soc/qcom/icnss.c
@@ -152,6 +152,8 @@
 #define ICNSS_QMI_ASSERT() do { } while (0)
 #endif
 
+#define QMI_ERR_PLAT_CCPM_CLK_INIT_FAILED 0x77
+
 enum icnss_debug_quirks {
 	HW_ALWAYS_ON,
 	HW_DEBUG_ENABLE,
@@ -395,12 +397,6 @@
 	uint32_t rejuvenate_ack_err;
 };
 
-#define MAX_NO_OF_MAC_ADDR 4
-struct icnss_wlan_mac_addr {
-	u8 mac_addr[MAX_NO_OF_MAC_ADDR][ETH_ALEN];
-	uint32_t no_of_mac_addr_set;
-};
-
 enum icnss_pdr_cause_index {
 	ICNSS_FW_CRASH,
 	ICNSS_ROOT_PD_CRASH,
@@ -477,8 +473,6 @@
 	uint64_t vph_pwr;
 	atomic_t pm_count;
 	struct ramdump_device *msa0_dump_dev;
-	bool is_wlan_mac_set;
-	struct icnss_wlan_mac_addr wlan_mac_addr;
 	bool bypass_s1_smmu;
 	u8 cause_for_rejuvenation;
 	u8 requesting_sub_system;
@@ -503,10 +497,10 @@
 	phys_addr_t addr;
 	u32 size;
 	u32 i = 0;
-	u32 source_vmids[ICNSS_MAX_VMIDS];
+	u32 source_vmids[ICNSS_MAX_VMIDS] = {0};
 	u32 source_nelems;
-	u32 dest_vmids[ICNSS_MAX_VMIDS];
-	u32 dest_perms[ICNSS_MAX_VMIDS];
+	u32 dest_vmids[ICNSS_MAX_VMIDS] = {0};
+	u32 dest_perms[ICNSS_MAX_VMIDS] = {0};
 	u32 dest_nelems;
 	enum icnss_msa_perm cur_perm = mem_region->perm;
 	struct icnss_msa_perm_list_t *new_perm_list, *old_perm_list;
@@ -558,6 +552,12 @@
 	int i;
 	enum icnss_msa_perm old_perm;
 
+	if (priv->nr_mem_region > QMI_WLFW_MAX_NUM_MEMORY_REGIONS_V01) {
+		icnss_pr_err("Invalid memory region len %d\n",
+			     priv->nr_mem_region);
+		return -EINVAL;
+	}
+
 	for (i = 0; i < priv->nr_mem_region; i++) {
 		old_perm = priv->mem_region[i].perm;
 		ret = icnss_assign_msa_perm(&priv->mem_region[i], new_perm);
@@ -734,7 +734,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI vbatt request rejected, result:%d error:%d\n",
 			resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	priv->stats.vbatt_resp++;
@@ -1218,7 +1218,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI MSA Mem info request rejected, result:%d error:%d\n",
 			resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 
@@ -1290,7 +1290,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI MSA ready request rejected: result:%d error:%d\n",
 			resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	penv->stats.msa_ready_resp++;
@@ -1353,7 +1353,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI indication register request rejected, resut:%d error:%d\n",
 		       resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	penv->stats.ind_register_resp++;
@@ -1400,7 +1400,9 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI capability request rejected, result:%d error:%d\n",
 		       resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
+		if (resp.resp.error == QMI_ERR_PLAT_CCPM_CLK_INIT_FAILED)
+			icnss_pr_err("RF card Not present");
 		goto out;
 	}
 
@@ -1483,7 +1485,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI mode request rejected, mode:%d result:%d error:%d\n",
 			     mode, resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	penv->stats.mode_resp++;
@@ -1533,7 +1535,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI config request rejected, result:%d error:%d\n",
 		       resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	penv->stats.cfg_resp++;
@@ -1586,7 +1588,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI INI request rejected, fw_log_mode:%d result:%d error:%d\n",
 			     fw_log_mode, resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	penv->stats.ini_resp++;
@@ -1646,7 +1648,7 @@
 	if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI athdiag read request rejected, result:%d error:%d\n",
 			     resp->resp.result, resp->resp.error);
-		ret = resp->resp.result;
+		ret = -resp->resp.result;
 		goto out;
 	}
 
@@ -1712,7 +1714,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI athdiag write request rejected, result:%d error:%d\n",
 			     resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 out:
@@ -1807,7 +1809,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI rejuvenate ack request rejected, result:%d error %d\n",
 			     resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 	priv->stats.rejuvenate_ack_resp++;
@@ -1868,7 +1870,7 @@
 	if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
 		icnss_pr_err("QMI dynamic feature mask request rejected, result:%d error %d\n",
 			     resp.resp.result, resp.resp.error);
-		ret = resp.resp.result;
+		ret = -resp.resp.result;
 		goto out;
 	}
 
@@ -3269,78 +3271,6 @@
 }
 EXPORT_SYMBOL(icnss_socinfo_get_serial_number);
 
-int icnss_set_wlan_mac_address(const u8 *in, const uint32_t len)
-{
-	struct icnss_priv *priv = penv;
-	uint32_t no_of_mac_addr;
-	struct icnss_wlan_mac_addr *addr = NULL;
-	int iter;
-	u8 *temp = NULL;
-
-	if (!priv) {
-		icnss_pr_err("Priv data is NULL\n");
-		return -EINVAL;
-	}
-
-	if (priv->is_wlan_mac_set) {
-		icnss_pr_dbg("WLAN MAC address is already set\n");
-		return 0;
-	}
-
-	if (len == 0 || (len % ETH_ALEN) != 0) {
-		icnss_pr_err("Invalid length %d\n", len);
-		return -EINVAL;
-	}
-
-	no_of_mac_addr = len / ETH_ALEN;
-	if (no_of_mac_addr > MAX_NO_OF_MAC_ADDR) {
-		icnss_pr_err("Exceed maxinum supported MAC address %u %u\n",
-			     MAX_NO_OF_MAC_ADDR, no_of_mac_addr);
-		return -EINVAL;
-	}
-
-	priv->is_wlan_mac_set = true;
-	addr = &priv->wlan_mac_addr;
-	addr->no_of_mac_addr_set = no_of_mac_addr;
-	temp = &addr->mac_addr[0][0];
-
-	for (iter = 0; iter < no_of_mac_addr;
-	     ++iter, temp += ETH_ALEN, in += ETH_ALEN) {
-		ether_addr_copy(temp, in);
-		icnss_pr_dbg("MAC_ADDR:%02x:%02x:%02x:%02x:%02x:%02x\n",
-			     temp[0], temp[1], temp[2],
-			     temp[3], temp[4], temp[5]);
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(icnss_set_wlan_mac_address);
-
-u8 *icnss_get_wlan_mac_address(struct device *dev, uint32_t *num)
-{
-	struct icnss_priv *priv = dev_get_drvdata(dev);
-	struct icnss_wlan_mac_addr *addr = NULL;
-
-	if (priv->magic != ICNSS_MAGIC) {
-		icnss_pr_err("Invalid drvdata: dev %p, data %p, magic 0x%x\n",
-			     dev, priv, priv->magic);
-		goto out;
-	}
-
-	if (!priv->is_wlan_mac_set) {
-		icnss_pr_dbg("WLAN MAC address is not set\n");
-		goto out;
-	}
-
-	addr = &priv->wlan_mac_addr;
-	*num = addr->no_of_mac_addr_set;
-	return &addr->mac_addr[0][0];
-out:
-	*num = 0;
-	return NULL;
-}
-EXPORT_SYMBOL(icnss_get_wlan_mac_address);
-
 int icnss_trigger_recovery(struct device *dev)
 {
 	int ret = 0;
diff --git a/drivers/soc/qcom/icnss_utils.c b/drivers/soc/qcom/icnss_utils.c
deleted file mode 100644
index 6974146..0000000
--- a/drivers/soc/qcom/icnss_utils.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <soc/qcom/icnss.h>
-
-#define ICNSS_MAX_CH_NUM 45
-
-static DEFINE_MUTEX(unsafe_channel_list_lock);
-static DEFINE_SPINLOCK(dfs_nol_info_lock);
-static int driver_load_cnt;
-
-static struct icnss_unsafe_channel_list {
-	u16 unsafe_ch_count;
-	u16 unsafe_ch_list[ICNSS_MAX_CH_NUM];
-} unsafe_channel_list;
-
-static struct icnss_dfs_nol_info {
-	void *dfs_nol_info;
-	u16 dfs_nol_info_len;
-} dfs_nol_info;
-
-int icnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count)
-{
-	mutex_lock(&unsafe_channel_list_lock);
-	if ((!unsafe_ch_list) || (ch_count > ICNSS_MAX_CH_NUM)) {
-		mutex_unlock(&unsafe_channel_list_lock);
-		return -EINVAL;
-	}
-
-	unsafe_channel_list.unsafe_ch_count = ch_count;
-
-	if (ch_count != 0) {
-		memcpy(
-		       (char *)unsafe_channel_list.unsafe_ch_list,
-		       (char *)unsafe_ch_list, ch_count * sizeof(u16));
-	}
-	mutex_unlock(&unsafe_channel_list_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(icnss_set_wlan_unsafe_channel);
-
-int icnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list,
-				  u16 *ch_count, u16 buf_len)
-{
-	mutex_lock(&unsafe_channel_list_lock);
-	if (!unsafe_ch_list || !ch_count) {
-		mutex_unlock(&unsafe_channel_list_lock);
-		return -EINVAL;
-	}
-
-	if (buf_len < (unsafe_channel_list.unsafe_ch_count * sizeof(u16))) {
-		mutex_unlock(&unsafe_channel_list_lock);
-		return -ENOMEM;
-	}
-
-	*ch_count = unsafe_channel_list.unsafe_ch_count;
-	memcpy(
-		(char *)unsafe_ch_list,
-		(char *)unsafe_channel_list.unsafe_ch_list,
-		unsafe_channel_list.unsafe_ch_count * sizeof(u16));
-	mutex_unlock(&unsafe_channel_list_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(icnss_get_wlan_unsafe_channel);
-
-int icnss_wlan_set_dfs_nol(const void *info, u16 info_len)
-{
-	void *temp;
-	void *old_nol_info;
-	struct icnss_dfs_nol_info *dfs_info;
-
-	if (!info || !info_len)
-		return -EINVAL;
-
-	temp = kmalloc(info_len, GFP_ATOMIC);
-	if (!temp)
-		return -ENOMEM;
-
-	memcpy(temp, info, info_len);
-	spin_lock_bh(&dfs_nol_info_lock);
-	dfs_info = &dfs_nol_info;
-	old_nol_info = dfs_info->dfs_nol_info;
-	dfs_info->dfs_nol_info = temp;
-	dfs_info->dfs_nol_info_len = info_len;
-	spin_unlock_bh(&dfs_nol_info_lock);
-	kfree(old_nol_info);
-
-	return 0;
-}
-EXPORT_SYMBOL(icnss_wlan_set_dfs_nol);
-
-int icnss_wlan_get_dfs_nol(void *info, u16 info_len)
-{
-	int len;
-	struct icnss_dfs_nol_info *dfs_info;
-
-	if (!info || !info_len)
-		return -EINVAL;
-
-	spin_lock_bh(&dfs_nol_info_lock);
-
-	dfs_info = &dfs_nol_info;
-	if (dfs_info->dfs_nol_info == NULL ||
-	    dfs_info->dfs_nol_info_len == 0) {
-		spin_unlock_bh(&dfs_nol_info_lock);
-		return -ENOENT;
-	}
-
-	len = min(info_len, dfs_info->dfs_nol_info_len);
-	memcpy(info, dfs_info->dfs_nol_info, len);
-	spin_unlock_bh(&dfs_nol_info_lock);
-
-	return len;
-}
-EXPORT_SYMBOL(icnss_wlan_get_dfs_nol);
-
-void icnss_increment_driver_load_cnt(void)
-{
-	++driver_load_cnt;
-}
-EXPORT_SYMBOL(icnss_increment_driver_load_cnt);
-
-int icnss_get_driver_load_cnt(void)
-{
-	return driver_load_cnt;
-}
-EXPORT_SYMBOL(icnss_get_driver_load_cnt);
diff --git a/drivers/soc/qcom/jtagv8-etm.c b/drivers/soc/qcom/jtagv8-etm.c
new file mode 100644
index 0000000..ff8cc99
--- /dev/null
+++ b/drivers/soc/qcom/jtagv8-etm.c
@@ -0,0 +1,1722 @@
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/smp.h>
+#include <linux/export.h>
+#include <linux/printk.h>
+#include <linux/ratelimit.h>
+#include <linux/coresight.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/bitops.h>
+#include <linux/of.h>
+#include <linux/notifier.h>
+#include <linux/cpu.h>
+#include <linux/spinlock.h>
+#include <linux/mutex.h>
+#include <soc/qcom/scm.h>
+#include <soc/qcom/jtag.h>
+#include <asm/smp_plat.h>
+#include <asm/etmv4x.h>
+#include <soc/qcom/socinfo.h>
+
+#define CORESIGHT_LAR		(0xFB0)
+
+#define TIMEOUT_US		(100)
+
+#define BM(lsb, msb)		((BIT(msb) - BIT(lsb)) + BIT(msb))
+#define BMVAL(val, lsb, msb)	((val & BM(lsb, msb)) >> lsb)
+#define BVAL(val, n)		((val & BIT(n)) >> n)
+
+/*
+ * ETMv4 registers:
+ * 0x000 - 0x2FC: Trace         registers
+ * 0x300 - 0x314: Management    registers
+ * 0x318 - 0xEFC: Trace         registers
+ * 0xF00: Management		registers
+ * 0xFA0 - 0xFA4: Trace		registers
+ * 0xFA8 - 0xFFC: Management	registers
+ */
+
+/* Trace registers (0x000-0x2FC) */
+/* Main control and configuration registers  */
+#define TRCPRGCTLR			(0x004)
+#define TRCPROCSELR			(0x008)
+#define TRCSTATR			(0x00C)
+#define TRCCONFIGR			(0x010)
+#define TRCAUXCTLR			(0x018)
+#define TRCEVENTCTL0R			(0x020)
+#define TRCEVENTCTL1R			(0x024)
+#define TRCSTALLCTLR			(0x02C)
+#define TRCTSCTLR			(0x030)
+#define TRCSYNCPR			(0x034)
+#define TRCCCCTLR			(0x038)
+#define TRCBBCTLR			(0x03C)
+#define TRCTRACEIDR			(0x040)
+#define TRCQCTLR			(0x044)
+/* Filtering control registers */
+#define TRCVICTLR			(0x080)
+#define TRCVIIECTLR			(0x084)
+#define TRCVISSCTLR			(0x088)
+#define TRCVIPCSSCTLR			(0x08C)
+#define TRCVDCTLR			(0x0A0)
+#define TRCVDSACCTLR			(0x0A4)
+#define TRCVDARCCTLR			(0x0A8)
+/* Derived resources registers */
+#define TRCSEQEVRn(n)			(0x100 + (n * 4))
+#define TRCSEQRSTEVR			(0x118)
+#define TRCSEQSTR			(0x11C)
+#define TRCEXTINSELR			(0x120)
+#define TRCCNTRLDVRn(n)			(0x140 + (n * 4))
+#define TRCCNTCTLRn(n)			(0x150 + (n * 4))
+#define TRCCNTVRn(n)			(0x160 + (n * 4))
+/* ID registers */
+#define TRCIDR8				(0x180)
+#define TRCIDR9				(0x184)
+#define TRCIDR10			(0x188)
+#define TRCIDR11			(0x18C)
+#define TRCIDR12			(0x190)
+#define TRCIDR13			(0x194)
+#define TRCIMSPEC0			(0x1C0)
+#define TRCIMSPECn(n)			(0x1C0 + (n * 4))
+#define TRCIDR0				(0x1E0)
+#define TRCIDR1				(0x1E4)
+#define TRCIDR2				(0x1E8)
+#define TRCIDR3				(0x1EC)
+#define TRCIDR4				(0x1F0)
+#define TRCIDR5				(0x1F4)
+#define TRCIDR6				(0x1F8)
+#define TRCIDR7				(0x1FC)
+/* Resource selection registers */
+#define TRCRSCTLRn(n)			(0x200 + (n * 4))
+/* Single-shot comparator registers */
+#define TRCSSCCRn(n)			(0x280 + (n * 4))
+#define TRCSSCSRn(n)			(0x2A0 + (n * 4))
+#define TRCSSPCICRn(n)			(0x2C0 + (n * 4))
+/* Management registers (0x300-0x314) */
+#define TRCOSLAR			(0x300)
+#define TRCOSLSR			(0x304)
+#define TRCPDCR				(0x310)
+#define TRCPDSR				(0x314)
+/* Trace registers (0x318-0xEFC) */
+/* Comparator registers */
+#define TRCACVRn(n)			(0x400 + (n * 8))
+#define TRCACATRn(n)			(0x480 + (n * 8))
+#define TRCDVCVRn(n)			(0x500 + (n * 16))
+#define TRCDVCMRn(n)			(0x580 + (n * 16))
+#define TRCCIDCVRn(n)			(0x600 + (n * 8))
+#define TRCVMIDCVRn(n)			(0x640 + (n * 8))
+#define TRCCIDCCTLR0			(0x680)
+#define TRCCIDCCTLR1			(0x684)
+#define TRCVMIDCCTLR0			(0x688)
+#define TRCVMIDCCTLR1			(0x68C)
+/* Management register (0xF00) */
+/* Integration control registers */
+#define TRCITCTRL			(0xF00)
+/* Trace registers (0xFA0-0xFA4) */
+/* Claim tag registers */
+#define TRCCLAIMSET			(0xFA0)
+#define TRCCLAIMCLR			(0xFA4)
+/* Management registers (0xFA8-0xFFC) */
+#define TRCDEVAFF0			(0xFA8)
+#define TRCDEVAFF1			(0xFAC)
+#define TRCLAR				(0xFB0)
+#define TRCLSR				(0xFB4)
+#define TRCAUTHSTATUS			(0xFB8)
+#define TRCDEVARCH			(0xFBC)
+#define TRCDEVID			(0xFC8)
+#define TRCDEVTYPE			(0xFCC)
+#define TRCPIDR4			(0xFD0)
+#define TRCPIDR5			(0xFD4)
+#define TRCPIDR6			(0xFD8)
+#define TRCPIDR7			(0xFDC)
+#define TRCPIDR0			(0xFE0)
+#define TRCPIDR1			(0xFE4)
+#define TRCPIDR2			(0xFE8)
+#define TRCPIDR3			(0xFEC)
+#define TRCCIDR0			(0xFF0)
+#define TRCCIDR1			(0xFF4)
+#define TRCCIDR2			(0xFF8)
+#define TRCCIDR3			(0xFFC)
+
+/* ETMv4 resources */
+#define ETM_MAX_NR_PE			(8)
+#define ETM_MAX_CNTR			(4)
+#define ETM_MAX_SEQ_STATES		(4)
+#define ETM_MAX_EXT_INP_SEL		(4)
+#define ETM_MAX_EXT_INP			(256)
+#define ETM_MAX_EXT_OUT			(4)
+#define ETM_MAX_SINGLE_ADDR_CMP		(16)
+#define ETM_MAX_ADDR_RANGE_CMP		(ETM_MAX_SINGLE_ADDR_CMP / 2)
+#define ETM_MAX_DATA_VAL_CMP		(8)
+#define ETM_MAX_CTXID_CMP		(8)
+#define ETM_MAX_VMID_CMP		(8)
+#define ETM_MAX_PE_CMP			(8)
+#define ETM_MAX_RES_SEL			(32)
+#define ETM_MAX_SS_CMP			(8)
+
+#define ETM_CPMR_CLKEN			(0x4)
+#define ETM_ARCH_V4			(0x40)
+#define ETM_ARCH_V4_2			(0x42)
+
+#define MAX_ETM_STATE_SIZE	(165)
+
+#define TZ_DBG_ETM_FEAT_ID	(0x8)
+#define TZ_DBG_ETM_VER		(0x400000)
+#define HW_SOC_ID_M8953		(293)
+
+#define etm_writel(etm, val, off)	\
+		   __raw_writel(val, etm->base + off)
+#define etm_readl(etm, off)		\
+		  __raw_readl(etm->base + off)
+
+#define etm_writeq(etm, val, off)	\
+		   __raw_writeq(val, etm->base + off)
+#define etm_readq(etm, off)		\
+		  __raw_readq(etm->base + off)
+
+#define ETM_LOCK(base)							\
+do {									\
+	mb(); /* ensure configuration take effect before we lock it */	\
+	etm_writel(base, 0x0, CORESIGHT_LAR);				\
+} while (0)
+
+#define ETM_UNLOCK(base)						\
+do {									\
+	etm_writel(base, CORESIGHT_UNLOCK, CORESIGHT_LAR);		\
+	mb(); /* ensure unlock take effect before we configure */	\
+} while (0)
+
+struct etm_ctx {
+	uint8_t			arch;
+	uint8_t			nr_pe;
+	uint8_t			nr_pe_cmp;
+	uint8_t			nr_addr_cmp;
+	uint8_t			nr_data_cmp;
+	uint8_t			nr_cntr;
+	uint8_t			nr_ext_inp;
+	uint8_t			nr_ext_inp_sel;
+	uint8_t			nr_ext_out;
+	uint8_t			nr_ctxid_cmp;
+	uint8_t			nr_vmid_cmp;
+	uint8_t			nr_seq_state;
+	uint8_t			nr_event;
+	uint8_t			nr_resource;
+	uint8_t			nr_ss_cmp;
+	bool			si_enable;
+	bool			save_restore_disabled;
+	bool			save_restore_enabled;
+	bool			os_lock_present;
+	bool			init;
+	bool			enable;
+	void __iomem		*base;
+	struct device		*dev;
+	uint64_t		*state;
+	spinlock_t		spinlock;
+	struct mutex		mutex;
+};
+
+static struct etm_ctx *etm[NR_CPUS];
+static int cnt;
+
+static struct clk *clock[NR_CPUS];
+
+static ATOMIC_NOTIFIER_HEAD(etm_save_notifier_list);
+static ATOMIC_NOTIFIER_HEAD(etm_restore_notifier_list);
+
+int msm_jtag_save_register(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_register(&etm_save_notifier_list, nb);
+}
+EXPORT_SYMBOL(msm_jtag_save_register);
+
+int msm_jtag_save_unregister(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_unregister(&etm_save_notifier_list, nb);
+}
+EXPORT_SYMBOL(msm_jtag_save_unregister);
+
+int msm_jtag_restore_register(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_register(&etm_restore_notifier_list, nb);
+}
+EXPORT_SYMBOL(msm_jtag_restore_register);
+
+int msm_jtag_restore_unregister(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_unregister(&etm_restore_notifier_list, nb);
+}
+EXPORT_SYMBOL(msm_jtag_restore_unregister);
+
+static void etm_os_lock(struct etm_ctx *etmdata)
+{
+	if (etmdata->os_lock_present) {
+		etm_writel(etmdata, 0x1, TRCOSLAR);
+		/* Ensure OS lock is set before proceeding */
+		mb();
+	}
+}
+
+static void etm_os_unlock(struct etm_ctx *etmdata)
+{
+	if (etmdata->os_lock_present) {
+		/* Ensure all writes are complete before clearing OS lock */
+		mb();
+		etm_writel(etmdata, 0x0, TRCOSLAR);
+	}
+}
+
+static inline void etm_mm_save_state(struct etm_ctx *etmdata)
+{
+	int i, j, count;
+
+	i = 0;
+	mb(); /* ensure all register writes complete before saving them */
+	isb();
+	ETM_UNLOCK(etmdata);
+
+	switch (etmdata->arch) {
+	case ETM_ARCH_V4_2:
+	case ETM_ARCH_V4:
+		etm_os_lock(etmdata);
+
+		/* poll until programmers' model becomes stable */
+		for (count = TIMEOUT_US; (BVAL(etm_readl(etmdata, TRCSTATR), 1)
+		     != 1) && count > 0; count--)
+			udelay(1);
+		if (count == 0)
+			pr_err_ratelimited("programmers model is not stable\n"
+					   );
+
+		/* main control and configuration registers */
+		etmdata->state[i++] = etm_readl(etmdata, TRCPROCSELR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCCONFIGR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCAUXCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCEVENTCTL0R);
+		etmdata->state[i++] = etm_readl(etmdata, TRCEVENTCTL1R);
+		etmdata->state[i++] = etm_readl(etmdata, TRCSTALLCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCTSCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCSYNCPR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCCCCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCBBCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCTRACEIDR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCQCTLR);
+		/* filtering control registers */
+		etmdata->state[i++] = etm_readl(etmdata, TRCVICTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVIIECTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVISSCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVIPCSSCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVDCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVDSACCTLR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVDARCCTLR);
+		/* derived resource registers */
+		for (j = 0; j < etmdata->nr_seq_state-1; j++)
+			etmdata->state[i++] = etm_readl(etmdata, TRCSEQEVRn(j));
+		etmdata->state[i++] = etm_readl(etmdata, TRCSEQRSTEVR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCSEQSTR);
+		etmdata->state[i++] = etm_readl(etmdata, TRCEXTINSELR);
+		for (j = 0; j < etmdata->nr_cntr; j++)  {
+			etmdata->state[i++] = etm_readl(etmdata,
+						       TRCCNTRLDVRn(j));
+			etmdata->state[i++] = etm_readl(etmdata,
+						       TRCCNTCTLRn(j));
+			etmdata->state[i++] = etm_readl(etmdata,
+						       TRCCNTVRn(j));
+		}
+		/* resource selection registers */
+		for (j = 0; j < etmdata->nr_resource; j++)
+			etmdata->state[i++] = etm_readl(etmdata, TRCRSCTLRn(j));
+		/* comparator registers */
+		for (j = 0; j < etmdata->nr_addr_cmp * 2; j++) {
+			etmdata->state[i++] = etm_readq(etmdata, TRCACVRn(j));
+			etmdata->state[i++] = etm_readq(etmdata, TRCACATRn(j));
+		}
+		for (j = 0; j < etmdata->nr_data_cmp; j++) {
+			etmdata->state[i++] = etm_readq(etmdata, TRCDVCVRn(j));
+			etmdata->state[i++] = etm_readq(etmdata, TRCDVCMRn(i));
+		}
+		for (j = 0; j < etmdata->nr_ctxid_cmp; j++)
+			etmdata->state[i++] = etm_readq(etmdata, TRCCIDCVRn(j));
+		etmdata->state[i++] = etm_readl(etmdata, TRCCIDCCTLR0);
+		etmdata->state[i++] = etm_readl(etmdata, TRCCIDCCTLR1);
+		for (j = 0; j < etmdata->nr_vmid_cmp; j++)
+			etmdata->state[i++] = etm_readq(etmdata,
+							TRCVMIDCVRn(j));
+		etmdata->state[i++] = etm_readl(etmdata, TRCVMIDCCTLR0);
+		etmdata->state[i++] = etm_readl(etmdata, TRCVMIDCCTLR1);
+		/* single-shot comparator registers */
+		for (j = 0; j < etmdata->nr_ss_cmp; j++) {
+			etmdata->state[i++] = etm_readl(etmdata, TRCSSCCRn(j));
+			etmdata->state[i++] = etm_readl(etmdata, TRCSSCSRn(j));
+			etmdata->state[i++] = etm_readl(etmdata,
+							TRCSSPCICRn(j));
+		}
+		/* claim tag registers */
+		etmdata->state[i++] = etm_readl(etmdata, TRCCLAIMCLR);
+		/* program ctrl register */
+		etmdata->state[i++] = etm_readl(etmdata, TRCPRGCTLR);
+
+		/* ensure trace unit is idle to be powered down */
+		for (count = TIMEOUT_US; (BVAL(etm_readl(etmdata, TRCSTATR), 0)
+		     != 1) && count > 0; count--)
+			udelay(1);
+		if (count == 0)
+			pr_err_ratelimited("timeout waiting for idle state\n");
+
+		atomic_notifier_call_chain(&etm_save_notifier_list, 0, NULL);
+
+		break;
+	default:
+		pr_err_ratelimited("unsupported etm arch %d in %s\n",
+				   etmdata->arch, __func__);
+	}
+
+	ETM_LOCK(etmdata);
+}
+
+static inline void etm_mm_restore_state(struct etm_ctx *etmdata)
+{
+	int i, j;
+
+	i = 0;
+	ETM_UNLOCK(etmdata);
+
+	switch (etmdata->arch) {
+	case ETM_ARCH_V4_2:
+	case ETM_ARCH_V4:
+		atomic_notifier_call_chain(&etm_restore_notifier_list, 0, NULL);
+
+		/* check OS lock is locked */
+		if (BVAL(etm_readl(etmdata, TRCOSLSR), 1) != 1) {
+			pr_err_ratelimited("OS lock is unlocked\n");
+			etm_os_lock(etmdata);
+		}
+
+		/* main control and configuration registers */
+		etm_writel(etmdata, etmdata->state[i++], TRCPROCSELR);
+		etm_writel(etmdata, etmdata->state[i++], TRCCONFIGR);
+		etm_writel(etmdata, etmdata->state[i++], TRCAUXCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCEVENTCTL0R);
+		etm_writel(etmdata, etmdata->state[i++], TRCEVENTCTL1R);
+		etm_writel(etmdata, etmdata->state[i++], TRCSTALLCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCTSCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCSYNCPR);
+		etm_writel(etmdata, etmdata->state[i++], TRCCCCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCBBCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCTRACEIDR);
+		etm_writel(etmdata, etmdata->state[i++], TRCQCTLR);
+		/* filtering control registers */
+		etm_writel(etmdata, etmdata->state[i++], TRCVICTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVIIECTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVISSCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVIPCSSCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVDCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVDSACCTLR);
+		etm_writel(etmdata, etmdata->state[i++], TRCVDARCCTLR);
+		/* derived resources registers */
+		for (j = 0; j < etmdata->nr_seq_state-1; j++)
+			etm_writel(etmdata, etmdata->state[i++], TRCSEQEVRn(j));
+		etm_writel(etmdata, etmdata->state[i++], TRCSEQRSTEVR);
+		etm_writel(etmdata, etmdata->state[i++], TRCSEQSTR);
+		etm_writel(etmdata, etmdata->state[i++], TRCEXTINSELR);
+		for (j = 0; j < etmdata->nr_cntr; j++)  {
+			etm_writel(etmdata, etmdata->state[i++],
+				  TRCCNTRLDVRn(j));
+			etm_writel(etmdata, etmdata->state[i++],
+				  TRCCNTCTLRn(j));
+			etm_writel(etmdata, etmdata->state[i++], TRCCNTVRn(j));
+		}
+		/* resource selection registers */
+		for (j = 0; j < etmdata->nr_resource; j++)
+			etm_writel(etmdata, etmdata->state[i++], TRCRSCTLRn(j));
+		/* comparator registers */
+		for (j = 0; j < etmdata->nr_addr_cmp * 2; j++) {
+			etm_writeq(etmdata, etmdata->state[i++], TRCACVRn(j));
+			etm_writeq(etmdata, etmdata->state[i++], TRCACATRn(j));
+		}
+		for (j = 0; j < etmdata->nr_data_cmp; j++) {
+			etm_writeq(etmdata, etmdata->state[i++], TRCDVCVRn(j));
+			etm_writeq(etmdata, etmdata->state[i++], TRCDVCMRn(j));
+		}
+		for (j = 0; j < etmdata->nr_ctxid_cmp; j++)
+			etm_writeq(etmdata, etmdata->state[i++], TRCCIDCVRn(j));
+		etm_writel(etmdata, etmdata->state[i++], TRCCIDCCTLR0);
+		etm_writel(etmdata, etmdata->state[i++], TRCCIDCCTLR1);
+		for (j = 0; j < etmdata->nr_vmid_cmp; j++)
+			etm_writeq(etmdata, etmdata->state[i++],
+				   TRCVMIDCVRn(j));
+		etm_writel(etmdata, etmdata->state[i++], TRCVMIDCCTLR0);
+		etm_writel(etmdata, etmdata->state[i++], TRCVMIDCCTLR1);
+		/* e-shot comparator registers */
+		for (j = 0; j < etmdata->nr_ss_cmp; j++) {
+			etm_writel(etmdata, etmdata->state[i++], TRCSSCCRn(j));
+			etm_writel(etmdata, etmdata->state[i++], TRCSSCSRn(j));
+			etm_writel(etmdata, etmdata->state[i++],
+				   TRCSSPCICRn(j));
+		}
+		/* claim tag registers */
+		etm_writel(etmdata, etmdata->state[i++], TRCCLAIMSET);
+		/* program ctrl register */
+		etm_writel(etmdata, etmdata->state[i++], TRCPRGCTLR);
+
+		etm_os_unlock(etmdata);
+		break;
+	default:
+		pr_err_ratelimited("unsupported etm arch %d in %s\n",
+				   etmdata->arch,  __func__);
+	}
+
+	ETM_LOCK(etmdata);
+}
+
+static inline void etm_clk_disable(void)
+{
+	uint32_t cpmr;
+
+	isb();
+	cpmr = trc_readl(CPMR_EL1);
+	cpmr  &= ~ETM_CPMR_CLKEN;
+	trc_write(cpmr, CPMR_EL1);
+}
+
+static inline void etm_clk_enable(void)
+{
+	uint32_t cpmr;
+
+	cpmr = trc_readl(CPMR_EL1);
+	cpmr  |= ETM_CPMR_CLKEN;
+	trc_write(cpmr, CPMR_EL1);
+	isb();
+}
+
+static int etm_read_ssxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readl(ETMSEQEVR0);
+		break;
+	case 1:
+		state[i++] = trc_readl(ETMSEQEVR1);
+		break;
+	case 2:
+		state[i++] = trc_readl(ETMSEQEVR2);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_crxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readl(ETMCNTRLDVR0);
+		state[i++] = trc_readl(ETMCNTCTLR0);
+		state[i++] = trc_readl(ETMCNTVR0);
+		break;
+	case 1:
+		state[i++] = trc_readl(ETMCNTRLDVR1);
+		state[i++] = trc_readl(ETMCNTCTLR1);
+		state[i++] = trc_readl(ETMCNTVR1);
+		break;
+	case 2:
+		state[i++] = trc_readl(ETMCNTRLDVR2);
+		state[i++] = trc_readl(ETMCNTCTLR2);
+		state[i++] = trc_readl(ETMCNTVR2);
+		break;
+	case 3:
+		state[i++] = trc_readl(ETMCNTRLDVR3);
+		state[i++] = trc_readl(ETMCNTCTLR3);
+		state[i++] = trc_readl(ETMCNTVR3);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_rsxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 2:
+		state[i++] = trc_readl(ETMRSCTLR2);
+		break;
+	case 3:
+		state[i++] = trc_readl(ETMRSCTLR3);
+		break;
+	case 4:
+		state[i++] = trc_readl(ETMRSCTLR4);
+		break;
+	case 5:
+		state[i++] = trc_readl(ETMRSCTLR5);
+		break;
+	case 6:
+		state[i++] = trc_readl(ETMRSCTLR6);
+		break;
+	case 7:
+		state[i++] = trc_readl(ETMRSCTLR7);
+		break;
+	case 8:
+		state[i++] = trc_readl(ETMRSCTLR8);
+		break;
+	case 9:
+		state[i++] = trc_readl(ETMRSCTLR9);
+		break;
+	case 10:
+		state[i++] = trc_readl(ETMRSCTLR10);
+		break;
+	case 11:
+		state[i++] = trc_readl(ETMRSCTLR11);
+		break;
+	case 12:
+		state[i++] = trc_readl(ETMRSCTLR12);
+		break;
+	case 13:
+		state[i++] = trc_readl(ETMRSCTLR13);
+		break;
+	case 14:
+		state[i++] = trc_readl(ETMRSCTLR14);
+		break;
+	case 15:
+		state[i++] = trc_readl(ETMRSCTLR15);
+		break;
+	case 16:
+		state[i++] = trc_readl(ETMRSCTLR16);
+		break;
+	case 17:
+		state[i++] = trc_readl(ETMRSCTLR17);
+		break;
+	case 18:
+		state[i++] = trc_readl(ETMRSCTLR18);
+		break;
+	case 19:
+		state[i++] = trc_readl(ETMRSCTLR19);
+		break;
+	case 20:
+		state[i++] = trc_readl(ETMRSCTLR20);
+		break;
+	case 21:
+		state[i++] = trc_readl(ETMRSCTLR21);
+		break;
+	case 22:
+		state[i++] = trc_readl(ETMRSCTLR22);
+		break;
+	case 23:
+		state[i++] = trc_readl(ETMRSCTLR23);
+		break;
+	case 24:
+		state[i++] = trc_readl(ETMRSCTLR24);
+		break;
+	case 25:
+		state[i++] = trc_readl(ETMRSCTLR25);
+		break;
+	case 26:
+		state[i++] = trc_readl(ETMRSCTLR26);
+		break;
+	case 27:
+		state[i++] = trc_readl(ETMRSCTLR27);
+		break;
+	case 28:
+		state[i++] = trc_readl(ETMRSCTLR28);
+		break;
+	case 29:
+		state[i++] = trc_readl(ETMRSCTLR29);
+		break;
+	case 30:
+		state[i++] = trc_readl(ETMRSCTLR30);
+		break;
+	case 31:
+		state[i++] = trc_readl(ETMRSCTLR31);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_acr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readq(ETMACVR0);
+		state[i++] = trc_readq(ETMACATR0);
+		break;
+	case 1:
+		state[i++] = trc_readq(ETMACVR1);
+		state[i++] = trc_readq(ETMACATR1);
+		break;
+	case 2:
+		state[i++] = trc_readq(ETMACVR2);
+		state[i++] = trc_readq(ETMACATR2);
+		break;
+	case 3:
+		state[i++] = trc_readq(ETMACVR3);
+		state[i++] = trc_readq(ETMACATR3);
+		break;
+	case 4:
+		state[i++] = trc_readq(ETMACVR4);
+		state[i++] = trc_readq(ETMACATR4);
+		break;
+	case 5:
+		state[i++] = trc_readq(ETMACVR5);
+		state[i++] = trc_readq(ETMACATR5);
+		break;
+	case 6:
+		state[i++] = trc_readq(ETMACVR6);
+		state[i++] = trc_readq(ETMACATR6);
+		break;
+	case 7:
+		state[i++] = trc_readq(ETMACVR7);
+		state[i++] = trc_readq(ETMACATR7);
+		break;
+	case 8:
+		state[i++] = trc_readq(ETMACVR8);
+		state[i++] = trc_readq(ETMACATR8);
+		break;
+	case 9:
+		state[i++] = trc_readq(ETMACVR9);
+		state[i++] = trc_readq(ETMACATR9);
+		break;
+	case 10:
+		state[i++] = trc_readq(ETMACVR10);
+		state[i++] = trc_readq(ETMACATR10);
+		break;
+	case 11:
+		state[i++] = trc_readq(ETMACVR11);
+		state[i++] = trc_readq(ETMACATR11);
+		break;
+	case 12:
+		state[i++] = trc_readq(ETMACVR12);
+		state[i++] = trc_readq(ETMACATR12);
+		break;
+	case 13:
+		state[i++] = trc_readq(ETMACVR13);
+		state[i++] = trc_readq(ETMACATR13);
+		break;
+	case 14:
+		state[i++] = trc_readq(ETMACVR14);
+		state[i++] = trc_readq(ETMACATR14);
+		break;
+	case 15:
+		state[i++] = trc_readq(ETMACVR15);
+		state[i++] = trc_readq(ETMACATR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_dvcr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readq(ETMDVCVR0);
+		state[i++] = trc_readq(ETMDVCMR0);
+		break;
+	case 1:
+		state[i++] = trc_readq(ETMDVCVR1);
+		state[i++] = trc_readq(ETMDVCMR1);
+		break;
+	case 2:
+		state[i++] = trc_readq(ETMDVCVR2);
+		state[i++] = trc_readq(ETMDVCMR2);
+		break;
+	case 3:
+		state[i++] = trc_readq(ETMDVCVR3);
+		state[i++] = trc_readq(ETMDVCMR3);
+		break;
+	case 4:
+		state[i++] = trc_readq(ETMDVCVR4);
+		state[i++] = trc_readq(ETMDVCMR4);
+		break;
+	case 5:
+		state[i++] = trc_readq(ETMDVCVR5);
+		state[i++] = trc_readq(ETMDVCMR5);
+		break;
+	case 6:
+		state[i++] = trc_readq(ETMDVCVR6);
+		state[i++] = trc_readq(ETMDVCMR6);
+		break;
+	case 7:
+		state[i++] = trc_readq(ETMDVCVR7);
+		state[i++] = trc_readq(ETMDVCMR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_ccvr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readq(ETMCIDCVR0);
+		break;
+	case 1:
+		state[i++] = trc_readq(ETMCIDCVR1);
+		break;
+	case 2:
+		state[i++] = trc_readq(ETMCIDCVR2);
+		break;
+	case 3:
+		state[i++] = trc_readq(ETMCIDCVR3);
+		break;
+	case 4:
+		state[i++] = trc_readq(ETMCIDCVR4);
+		break;
+	case 5:
+		state[i++] = trc_readq(ETMCIDCVR5);
+		break;
+	case 6:
+		state[i++] = trc_readq(ETMCIDCVR6);
+		break;
+	case 7:
+		state[i++] = trc_readq(ETMCIDCVR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_vcvr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readq(ETMVMIDCVR0);
+		break;
+	case 1:
+		state[i++] = trc_readq(ETMVMIDCVR1);
+		break;
+	case 2:
+		state[i++] = trc_readq(ETMVMIDCVR2);
+		break;
+	case 3:
+		state[i++] = trc_readq(ETMVMIDCVR3);
+		break;
+	case 4:
+		state[i++] = trc_readq(ETMVMIDCVR4);
+		break;
+	case 5:
+		state[i++] = trc_readq(ETMVMIDCVR5);
+		break;
+	case 6:
+		state[i++] = trc_readq(ETMVMIDCVR6);
+		break;
+	case 7:
+		state[i++] = trc_readq(ETMVMIDCVR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_read_sscr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = trc_readl(ETMSSCCR0);
+		state[i++] = trc_readl(ETMSSCSR0);
+		state[i++] = trc_readl(ETMSSPCICR0);
+		break;
+	case 1:
+		state[i++] = trc_readl(ETMSSCCR1);
+		state[i++] = trc_readl(ETMSSCSR1);
+		state[i++] = trc_readl(ETMSSPCICR1);
+		break;
+	case 2:
+		state[i++] = trc_readl(ETMSSCCR2);
+		state[i++] = trc_readl(ETMSSCSR2);
+		state[i++] = trc_readl(ETMSSPCICR2);
+		break;
+	case 3:
+		state[i++] = trc_readl(ETMSSCCR3);
+		state[i++] = trc_readl(ETMSSCSR3);
+		state[i++] = trc_readl(ETMSSPCICR3);
+		break;
+	case 4:
+		state[i++] = trc_readl(ETMSSCCR4);
+		state[i++] = trc_readl(ETMSSCSR4);
+		state[i++] = trc_readl(ETMSSPCICR4);
+		break;
+	case 5:
+		state[i++] = trc_readl(ETMSSCCR5);
+		state[i++] = trc_readl(ETMSSCSR5);
+		state[i++] = trc_readl(ETMSSPCICR5);
+		break;
+	case 6:
+		state[i++] = trc_readl(ETMSSCCR6);
+		state[i++] = trc_readl(ETMSSCSR6);
+		state[i++] = trc_readl(ETMSSPCICR6);
+		break;
+	case 7:
+		state[i++] = trc_readl(ETMSSCCR7);
+		state[i++] = trc_readl(ETMSSCSR7);
+		state[i++] = trc_readl(ETMSSPCICR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static inline void etm_si_save_state(struct etm_ctx *etmdata)
+{
+	int i, j, count;
+
+	i = 0;
+	/* Ensure all writes are complete before saving ETM registers */
+	mb();
+	isb();
+
+	/* Vote for ETM power/clock enable */
+	etm_clk_enable();
+
+	switch (etmdata->arch) {
+	case ETM_ARCH_V4_2:
+	case ETM_ARCH_V4:
+		trc_write(0x1, ETMOSLAR);
+		isb();
+
+		/* poll until programmers' model becomes stable */
+		for (count = TIMEOUT_US; (BVAL(trc_readl(ETMSTATR), 1)
+		     != 1) && count > 0; count--)
+			udelay(1);
+		if (count == 0)
+			pr_err_ratelimited("programmers model is not stable\n");
+
+		/* main control and configuration registers */
+		etmdata->state[i++] = trc_readl(ETMCONFIGR);
+		etmdata->state[i++] = trc_readl(ETMEVENTCTL0R);
+		etmdata->state[i++] = trc_readl(ETMEVENTCTL1R);
+		etmdata->state[i++] = trc_readl(ETMSTALLCTLR);
+		etmdata->state[i++] = trc_readl(ETMTSCTLR);
+		etmdata->state[i++] = trc_readl(ETMSYNCPR);
+		etmdata->state[i++] = trc_readl(ETMCCCTLR);
+		etmdata->state[i++] = trc_readl(ETMTRACEIDR);
+		/* filtering control registers */
+		etmdata->state[i++] = trc_readl(ETMVICTLR);
+		etmdata->state[i++] = trc_readl(ETMVIIECTLR);
+		etmdata->state[i++] = trc_readl(ETMVISSCTLR);
+		/* derived resource registers */
+		for (j = 0; j < etmdata->nr_seq_state-1; j++)
+			i = etm_read_ssxr(etmdata->state, i, j);
+		etmdata->state[i++] = trc_readl(ETMSEQRSTEVR);
+		etmdata->state[i++] = trc_readl(ETMSEQSTR);
+		etmdata->state[i++] = trc_readl(ETMEXTINSELR);
+		for (j = 0; j < etmdata->nr_cntr; j++)
+			i = etm_read_crxr(etmdata->state, i, j);
+		/* resource selection registers */
+		for (j = 0; j < etmdata->nr_resource; j++)
+			i = etm_read_rsxr(etmdata->state, i, j + 2);
+		/* comparator registers */
+		for (j = 0; j < etmdata->nr_addr_cmp * 2; j++)
+			i = etm_read_acr(etmdata->state, i, j);
+		for (j = 0; j < etmdata->nr_data_cmp; j++)
+			i = etm_read_dvcr(etmdata->state, i, j);
+		for (j = 0; j < etmdata->nr_ctxid_cmp; j++)
+			i = etm_read_ccvr(etmdata->state, i, j);
+		etmdata->state[i++] = trc_readl(ETMCIDCCTLR0);
+		for (j = 0; j < etmdata->nr_vmid_cmp; j++)
+			i = etm_read_vcvr(etmdata->state, i, j);
+		/* single-shot comparator registers */
+		for (j = 0; j < etmdata->nr_ss_cmp; j++)
+			i = etm_read_sscr(etmdata->state, i, j);
+		/* program ctrl register */
+		etmdata->state[i++] = trc_readl(ETMPRGCTLR);
+
+		/* ensure trace unit is idle to be powered down */
+		for (count = TIMEOUT_US; (BVAL(trc_readl(ETMSTATR), 0)
+		     != 1) && count > 0; count--)
+			udelay(1);
+		if (count == 0)
+			pr_err_ratelimited("timeout waiting for idle state\n");
+
+		atomic_notifier_call_chain(&etm_save_notifier_list, 0, NULL);
+
+		break;
+	default:
+		pr_err_ratelimited("unsupported etm arch %d in %s\n",
+				   etmdata->arch, __func__);
+	}
+
+	/* Vote for ETM power/clock disable */
+	etm_clk_disable();
+}
+
+static int etm_write_ssxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMSEQEVR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMSEQEVR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMSEQEVR2);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_crxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMCNTRLDVR0);
+		trc_write(state[i++], ETMCNTCTLR0);
+		trc_write(state[i++], ETMCNTVR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMCNTRLDVR1);
+		trc_write(state[i++], ETMCNTCTLR1);
+		trc_write(state[i++], ETMCNTVR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMCNTRLDVR2);
+		trc_write(state[i++], ETMCNTCTLR2);
+		trc_write(state[i++], ETMCNTVR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMCNTRLDVR3);
+		trc_write(state[i++], ETMCNTCTLR3);
+		trc_write(state[i++], ETMCNTVR3);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_rsxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 2:
+		trc_write(state[i++], ETMRSCTLR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMRSCTLR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMRSCTLR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMRSCTLR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMRSCTLR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMRSCTLR7);
+		break;
+	case 8:
+		trc_write(state[i++], ETMRSCTLR8);
+		break;
+	case 9:
+		trc_write(state[i++], ETMRSCTLR9);
+		break;
+	case 10:
+		trc_write(state[i++], ETMRSCTLR10);
+		break;
+	case 11:
+		trc_write(state[i++], ETMRSCTLR11);
+		break;
+	case 12:
+		trc_write(state[i++], ETMRSCTLR12);
+		break;
+	case 13:
+		trc_write(state[i++], ETMRSCTLR13);
+		break;
+	case 14:
+		trc_write(state[i++], ETMRSCTLR14);
+		break;
+	case 15:
+		trc_write(state[i++], ETMRSCTLR15);
+		break;
+	case 16:
+		trc_write(state[i++], ETMRSCTLR16);
+		break;
+	case 17:
+		trc_write(state[i++], ETMRSCTLR17);
+		break;
+	case 18:
+		trc_write(state[i++], ETMRSCTLR18);
+		break;
+	case 19:
+		trc_write(state[i++], ETMRSCTLR19);
+		break;
+	case 20:
+		trc_write(state[i++], ETMRSCTLR20);
+		break;
+	case 21:
+		trc_write(state[i++], ETMRSCTLR21);
+		break;
+	case 22:
+		trc_write(state[i++], ETMRSCTLR22);
+		break;
+	case 23:
+		trc_write(state[i++], ETMRSCTLR23);
+		break;
+	case 24:
+		trc_write(state[i++], ETMRSCTLR24);
+		break;
+	case 25:
+		trc_write(state[i++], ETMRSCTLR25);
+		break;
+	case 26:
+		trc_write(state[i++], ETMRSCTLR26);
+		break;
+	case 27:
+		trc_write(state[i++], ETMRSCTLR27);
+		break;
+	case 28:
+		trc_write(state[i++], ETMRSCTLR28);
+		break;
+	case 29:
+		trc_write(state[i++], ETMRSCTLR29);
+		break;
+	case 30:
+		trc_write(state[i++], ETMRSCTLR30);
+		break;
+	case 31:
+		trc_write(state[i++], ETMRSCTLR31);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_acr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMACVR0);
+		trc_write(state[i++], ETMACATR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMACVR1);
+		trc_write(state[i++], ETMACATR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMACVR2);
+		trc_write(state[i++], ETMACATR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMACVR3);
+		trc_write(state[i++], ETMACATR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMACVR4);
+		trc_write(state[i++], ETMACATR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMACVR5);
+		trc_write(state[i++], ETMACATR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMACVR6);
+		trc_write(state[i++], ETMACATR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMACVR7);
+		trc_write(state[i++], ETMACATR7);
+		break;
+	case 8:
+		trc_write(state[i++], ETMACVR8);
+		trc_write(state[i++], ETMACATR8);
+		break;
+	case 9:
+		trc_write(state[i++], ETMACVR9);
+		trc_write(state[i++], ETMACATR9);
+		break;
+	case 10:
+		trc_write(state[i++], ETMACVR10);
+		trc_write(state[i++], ETMACATR10);
+		break;
+	case 11:
+		trc_write(state[i++], ETMACVR11);
+		trc_write(state[i++], ETMACATR11);
+		break;
+	case 12:
+		trc_write(state[i++], ETMACVR12);
+		trc_write(state[i++], ETMACATR12);
+		break;
+	case 13:
+		trc_write(state[i++], ETMACVR13);
+		trc_write(state[i++], ETMACATR13);
+		break;
+	case 14:
+		trc_write(state[i++], ETMACVR14);
+		trc_write(state[i++], ETMACATR14);
+		break;
+	case 15:
+		trc_write(state[i++], ETMACVR15);
+		trc_write(state[i++], ETMACATR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_dvcr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMDVCVR0);
+		trc_write(state[i++], ETMDVCMR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMDVCVR1);
+		trc_write(state[i++], ETMDVCMR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMDVCVR2);
+		trc_write(state[i++], ETMDVCMR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMDVCVR3);
+		trc_write(state[i++], ETMDVCMR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMDVCVR4);
+		trc_write(state[i++], ETMDVCMR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMDVCVR5);
+		trc_write(state[i++], ETMDVCMR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMDVCVR6);
+		trc_write(state[i++], ETMDVCMR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMDVCVR7);
+		trc_write(state[i++], ETMDVCMR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_ccvr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMCIDCVR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMCIDCVR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMCIDCVR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMCIDCVR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMCIDCVR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMCIDCVR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMCIDCVR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMCIDCVR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_vcvr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMVMIDCVR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMVMIDCVR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMVMIDCVR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMVMIDCVR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMVMIDCVR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMVMIDCVR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMVMIDCVR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMVMIDCVR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int etm_write_sscr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		trc_write(state[i++], ETMSSCCR0);
+		trc_write(state[i++], ETMSSCSR0);
+		trc_write(state[i++], ETMSSPCICR0);
+		break;
+	case 1:
+		trc_write(state[i++], ETMSSCCR1);
+		trc_write(state[i++], ETMSSCSR1);
+		trc_write(state[i++], ETMSSPCICR1);
+		break;
+	case 2:
+		trc_write(state[i++], ETMSSCCR2);
+		trc_write(state[i++], ETMSSCSR2);
+		trc_write(state[i++], ETMSSPCICR2);
+		break;
+	case 3:
+		trc_write(state[i++], ETMSSCCR3);
+		trc_write(state[i++], ETMSSCSR3);
+		trc_write(state[i++], ETMSSPCICR3);
+		break;
+	case 4:
+		trc_write(state[i++], ETMSSCCR4);
+		trc_write(state[i++], ETMSSCSR4);
+		trc_write(state[i++], ETMSSPCICR4);
+		break;
+	case 5:
+		trc_write(state[i++], ETMSSCCR5);
+		trc_write(state[i++], ETMSSCSR5);
+		trc_write(state[i++], ETMSSPCICR5);
+		break;
+	case 6:
+		trc_write(state[i++], ETMSSCCR6);
+		trc_write(state[i++], ETMSSCSR6);
+		trc_write(state[i++], ETMSSPCICR6);
+		break;
+	case 7:
+		trc_write(state[i++], ETMSSCCR7);
+		trc_write(state[i++], ETMSSCSR7);
+		trc_write(state[i++], ETMSSPCICR7);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static inline void etm_si_restore_state(struct etm_ctx *etmdata)
+{
+	int i, j;
+
+	i = 0;
+
+	/* Vote for ETM power/clock enable */
+	etm_clk_enable();
+
+	switch (etmdata->arch) {
+	case ETM_ARCH_V4_2:
+	case ETM_ARCH_V4:
+		atomic_notifier_call_chain(&etm_restore_notifier_list, 0, NULL);
+
+		/* check OS lock is locked */
+		if (BVAL(trc_readl(ETMOSLSR), 1) != 1) {
+			pr_err_ratelimited("OS lock is unlocked\n");
+			trc_write(0x1, ETMOSLAR);
+			isb();
+		}
+
+		/* main control and configuration registers */
+		trc_write(etmdata->state[i++], ETMCONFIGR);
+		trc_write(etmdata->state[i++], ETMEVENTCTL0R);
+		trc_write(etmdata->state[i++], ETMEVENTCTL1R);
+		trc_write(etmdata->state[i++], ETMSTALLCTLR);
+		trc_write(etmdata->state[i++], ETMTSCTLR);
+		trc_write(etmdata->state[i++], ETMSYNCPR);
+		trc_write(etmdata->state[i++], ETMCCCTLR);
+		trc_write(etmdata->state[i++], ETMTRACEIDR);
+		/* filtering control registers */
+		trc_write(etmdata->state[i++], ETMVICTLR);
+		trc_write(etmdata->state[i++], ETMVIIECTLR);
+		trc_write(etmdata->state[i++], ETMVISSCTLR);
+		/* derived resources registers */
+		for (j = 0; j < etmdata->nr_seq_state-1; j++)
+			i = etm_write_ssxr(etmdata->state, i, j);
+		trc_write(etmdata->state[i++], ETMSEQRSTEVR);
+		trc_write(etmdata->state[i++], ETMSEQSTR);
+		trc_write(etmdata->state[i++], ETMEXTINSELR);
+		for (j = 0; j < etmdata->nr_cntr; j++)
+			i = etm_write_crxr(etmdata->state, i, j);
+		/* resource selection registers */
+		for (j = 0; j < etmdata->nr_resource; j++)
+			i = etm_write_rsxr(etmdata->state, i, j + 2);
+		/* comparator registers */
+		for (j = 0; j < etmdata->nr_addr_cmp * 2; j++)
+			i = etm_write_acr(etmdata->state, i, j);
+		for (j = 0; j < etmdata->nr_data_cmp; j++)
+			i = etm_write_dvcr(etmdata->state, i, j);
+		for (j = 0; j < etmdata->nr_ctxid_cmp; j++)
+			i = etm_write_ccvr(etmdata->state, i, j);
+		trc_write(etmdata->state[i++], ETMCIDCCTLR0);
+		for (j = 0; j < etmdata->nr_vmid_cmp; j++)
+			i = etm_write_vcvr(etmdata->state, i, j);
+		/* single-shot comparator registers */
+		for (j = 0; j < etmdata->nr_ss_cmp; j++)
+			i = etm_write_sscr(etmdata->state, i, j);
+		/* program ctrl register */
+		trc_write(etmdata->state[i++], ETMPRGCTLR);
+
+		isb();
+		trc_write(0x0, ETMOSLAR);
+		break;
+	default:
+		pr_err_ratelimited("unsupported etm arch %d in %s\n",
+				   etmdata->arch,  __func__);
+	}
+
+	/* Vote for ETM power/clock disable */
+	etm_clk_disable();
+}
+
+void msm_jtag_etm_save_state(void)
+{
+	int cpu;
+
+	cpu = raw_smp_processor_id();
+
+	if (!etm[cpu] || etm[cpu]->save_restore_disabled)
+		return;
+
+	if (etm[cpu]->save_restore_enabled) {
+		if (etm[cpu]->si_enable)
+			etm_si_save_state(etm[cpu]);
+		else
+			etm_mm_save_state(etm[cpu]);
+	}
+}
+EXPORT_SYMBOL(msm_jtag_etm_save_state);
+
+void msm_jtag_etm_restore_state(void)
+{
+	int cpu;
+
+	cpu = raw_smp_processor_id();
+
+	if (!etm[cpu] || etm[cpu]->save_restore_disabled)
+		return;
+
+	/*
+	 * Check to ensure we attempt to restore only when save
+	 * has been done is accomplished by callee function.
+	 */
+	if (etm[cpu]->save_restore_enabled) {
+		if (etm[cpu]->si_enable)
+			etm_si_restore_state(etm[cpu]);
+		else
+			etm_mm_restore_state(etm[cpu]);
+	}
+}
+EXPORT_SYMBOL(msm_jtag_etm_restore_state);
+
+static inline bool etm_arch_supported(uint8_t arch)
+{
+	switch (arch) {
+	case ETM_ARCH_V4_2:
+	case ETM_ARCH_V4:
+		break;
+	default:
+		return false;
+	}
+	return true;
+}
+
+static void etm_os_lock_init(struct etm_ctx *etmdata)
+{
+	uint32_t etmoslsr;
+
+	etmoslsr = etm_readl(etmdata, TRCOSLSR);
+	if ((BVAL(etmoslsr, 0) == 0)  && BVAL(etmoslsr, 3))
+		etmdata->os_lock_present = true;
+	else
+		etmdata->os_lock_present = false;
+}
+
+static void etm_init_arch_data(void *info)
+{
+	uint32_t val;
+	struct etm_ctx  *etmdata = info;
+
+	ETM_UNLOCK(etmdata);
+
+	etm_os_lock_init(etmdata);
+
+	val = etm_readl(etmdata, TRCIDR1);
+	etmdata->arch = BMVAL(val, 4, 11);
+
+	/* number of resources trace unit supports */
+	val = etm_readl(etmdata, TRCIDR4);
+	etmdata->nr_addr_cmp = BMVAL(val, 0, 3);
+	etmdata->nr_data_cmp = BMVAL(val, 4, 7);
+	etmdata->nr_resource = BMVAL(val, 16, 19);
+	etmdata->nr_ss_cmp = BMVAL(val, 20, 23);
+	etmdata->nr_ctxid_cmp = BMVAL(val, 24, 27);
+	etmdata->nr_vmid_cmp = BMVAL(val, 28, 31);
+
+	val = etm_readl(etmdata, TRCIDR5);
+	etmdata->nr_seq_state = BMVAL(val, 25, 27);
+	etmdata->nr_cntr = BMVAL(val, 28, 30);
+
+	ETM_LOCK(etmdata);
+}
+
+static int jtag_mm_etm_starting(unsigned int cpu)
+{
+	if (!etm[cpu])
+		return 0;
+
+	spin_lock(&etm[cpu]->spinlock);
+	if (!etm[cpu]->init) {
+		etm_init_arch_data(etm[cpu]);
+		etm[cpu]->init = true;
+	}
+	spin_unlock(&etm[cpu]->spinlock);
+
+	return 0;
+}
+
+static int jtag_mm_etm_online(unsigned int cpu)
+{
+	if (!etm[cpu])
+		return 0;
+
+	mutex_lock(&etm[cpu]->mutex);
+	if (etm[cpu]->enable) {
+		mutex_unlock(&etm[cpu]->mutex);
+		return 0;
+	}
+	if (etm_arch_supported(etm[cpu]->arch)) {
+		if (scm_get_feat_version(TZ_DBG_ETM_FEAT_ID) <
+		    TZ_DBG_ETM_VER)
+			etm[cpu]->save_restore_enabled = true;
+		else
+			pr_info("etm save-restore supported by TZ\n");
+	} else
+		pr_info("etm arch %u not supported\n", etm[cpu]->arch);
+	etm[cpu]->enable = true;
+	mutex_unlock(&etm[cpu]->mutex);
+
+	return 0;
+}
+
+static bool skip_etm_save_restore(void)
+{
+	uint32_t id;
+	uint32_t version;
+
+	id = socinfo_get_id();
+	version = socinfo_get_version();
+
+	if (id == HW_SOC_ID_M8953 && SOCINFO_VERSION_MAJOR(version) == 1 &&
+	    SOCINFO_VERSION_MINOR(version) == 0)
+		return true;
+
+	return false;
+}
+
+static int jtag_mm_etm_probe(struct platform_device *pdev, uint32_t cpu)
+{
+	struct etm_ctx *etmdata;
+	struct resource *res;
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	/* Allocate memory per cpu */
+	etmdata = devm_kzalloc(dev, sizeof(struct etm_ctx), GFP_KERNEL);
+	if (!etmdata)
+		return -ENOMEM;
+
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "etm-base");
+	if (!res)
+		return -ENODEV;
+
+	etmdata->base = devm_ioremap(dev, res->start, resource_size(res));
+	if (!etmdata->base)
+		return -EINVAL;
+
+	etmdata->si_enable = of_property_read_bool(pdev->dev.of_node,
+						   "qcom,si-enable");
+	etmdata->save_restore_disabled = of_property_read_bool(
+					 pdev->dev.of_node,
+					 "qcom,save-restore-disable");
+
+	if (skip_etm_save_restore())
+		etmdata->save_restore_disabled = 1;
+
+	/* Allocate etm state save space per core */
+	etmdata->state = devm_kzalloc(dev,
+				      MAX_ETM_STATE_SIZE * sizeof(uint64_t),
+				      GFP_KERNEL);
+	if (!etmdata->state)
+		return -ENOMEM;
+
+	spin_lock_init(&etmdata->spinlock);
+	mutex_init(&etmdata->mutex);
+
+	if (cnt++ == 0) {
+		cpuhp_setup_state_nocalls(CPUHP_AP_ARM_MM_CORESIGHT4_STARTING,
+					  "AP_ARM_CORESIGHT4_STARTING",
+					  jtag_mm_etm_starting, NULL);
+		ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+						"AP_ARM_CORESIGHT4_ONLINE",
+						jtag_mm_etm_online, NULL);
+	}
+
+	get_online_cpus();
+
+	if (!smp_call_function_single(cpu, etm_init_arch_data, etmdata,
+				      1))
+		etmdata->init = true;
+
+	etm[cpu] = etmdata;
+
+	put_online_cpus();
+
+	mutex_lock(&etmdata->mutex);
+	if (etmdata->init && !etmdata->enable) {
+		if (etm_arch_supported(etmdata->arch)) {
+			if (scm_get_feat_version(TZ_DBG_ETM_FEAT_ID) <
+			    TZ_DBG_ETM_VER)
+				etmdata->save_restore_enabled = true;
+			else
+				pr_info("etm save-restore supported by TZ\n");
+		} else
+			pr_info("etm arch %u not supported\n", etmdata->arch);
+		etmdata->enable = true;
+	}
+	mutex_unlock(&etmdata->mutex);
+	return 0;
+}
+
+static int jtag_mm_probe(struct platform_device *pdev)
+{
+	int ret, i, cpu = -1;
+	struct device *dev = &pdev->dev;
+	struct device_node *cpu_node;
+
+	cpu_node = of_parse_phandle(pdev->dev.of_node,
+				    "qcom,coresight-jtagmm-cpu", 0);
+	if (!cpu_node) {
+		dev_err(dev, "Jtag-mm cpu handle not specified\n");
+		return -ENODEV;
+	}
+	for_each_possible_cpu(i) {
+		if (cpu_node == of_get_cpu_node(i, NULL)) {
+			cpu = i;
+			break;
+		}
+	}
+
+	if (cpu == -1) {
+		dev_err(dev, "invalid Jtag-mm cpu handle\n");
+		return -EINVAL;
+	}
+
+	clock[cpu] = devm_clk_get(dev, "core_clk");
+	if (IS_ERR(clock[cpu])) {
+		ret = PTR_ERR(clock[cpu]);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clock[cpu]);
+	if (ret)
+		return ret;
+
+	platform_set_drvdata(pdev, clock[cpu]);
+
+	ret  = jtag_mm_etm_probe(pdev, cpu);
+	if (ret)
+		clk_disable_unprepare(clock[cpu]);
+
+	return ret;
+}
+
+static void jtag_mm_etm_remove(void)
+{
+	cpuhp_remove_state_nocalls(CPUHP_AP_ARM_MM_CORESIGHT4_STARTING);
+}
+
+static int jtag_mm_remove(struct platform_device *pdev)
+{
+	struct clk *clock = platform_get_drvdata(pdev);
+
+	if (--cnt == 0)
+		jtag_mm_etm_remove();
+	clk_disable_unprepare(clock);
+	return 0;
+}
+
+static const struct of_device_id msm_qdss_mm_match[] = {
+	{ .compatible = "qcom,jtagv8-mm"},
+	{}
+};
+
+static struct platform_driver jtag_mm_driver = {
+	.probe          = jtag_mm_probe,
+	.remove         = jtag_mm_remove,
+	.driver         = {
+		.name   = "msm-jtagv8-mm",
+		.owner	= THIS_MODULE,
+		.of_match_table	= msm_qdss_mm_match,
+		},
+};
+
+static int __init jtag_mm_init(void)
+{
+	return platform_driver_register(&jtag_mm_driver);
+}
+module_init(jtag_mm_init);
+
+static void __exit jtag_mm_exit(void)
+{
+	platform_driver_unregister(&jtag_mm_driver);
+}
+module_exit(jtag_mm_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("CoreSight DEBUGv8 and ETMv4 save-restore driver");
diff --git a/drivers/soc/qcom/jtagv8.c b/drivers/soc/qcom/jtagv8.c
new file mode 100644
index 0000000..94dffd1
--- /dev/null
+++ b/drivers/soc/qcom/jtagv8.c
@@ -0,0 +1,1000 @@
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/smp.h>
+#include <linux/cpu.h>
+#include <linux/cpu_pm.h>
+#include <linux/export.h>
+#include <linux/printk.h>
+#include <linux/ratelimit.h>
+#include <linux/coresight.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/bitops.h>
+#include <soc/qcom/scm.h>
+#include <soc/qcom/jtag.h>
+#ifdef CONFIG_ARM64
+#include <asm/debugv8.h>
+#else
+#include <asm/hardware/debugv8.h>
+#endif
+
+#define TIMEOUT_US		(100)
+
+#define BM(lsb, msb)		((BIT(msb) - BIT(lsb)) + BIT(msb))
+#define BMVAL(val, lsb, msb)	((val & BM(lsb, msb)) >> lsb)
+#define BVAL(val, n)		((val & BIT(n)) >> n)
+
+#ifdef CONFIG_ARM64
+#define ARM_DEBUG_ARCH_V8_8	(0x8)
+#define ARM_DEBUG_ARCH_V8	(0x6)
+#endif
+
+#define MAX_DBG_REGS		(66)
+#define MAX_DBG_STATE_SIZE	(MAX_DBG_REGS * num_possible_cpus())
+
+#define OSLOCK_MAGIC		(0xC5ACCE55)
+#define TZ_DBG_ETM_FEAT_ID	(0x8)
+#define TZ_DBG_ETM_VER		(0x400000)
+
+static uint32_t msm_jtag_save_cntr[NR_CPUS];
+static uint32_t msm_jtag_restore_cntr[NR_CPUS];
+
+/* access debug registers using system instructions */
+struct dbg_cpu_ctx {
+	uint32_t		*state;
+};
+
+struct dbg_ctx {
+	uint8_t			arch;
+	bool			save_restore_enabled;
+	uint8_t			nr_wp;
+	uint8_t			nr_bp;
+	uint8_t			nr_ctx_cmp;
+#ifdef CONFIG_ARM64
+	uint64_t		*state;
+#else
+	uint32_t		*state;
+#endif
+};
+
+static struct dbg_ctx dbg;
+static struct notifier_block jtag_cpu_pm_notifier;
+
+#ifdef CONFIG_ARM64
+static int dbg_read_arch64_bxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = dbg_readq(DBGBVR0_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR0_EL1);
+		break;
+	case 1:
+		state[i++] = dbg_readq(DBGBVR1_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR1_EL1);
+		break;
+	case 2:
+		state[i++] = dbg_readq(DBGBVR2_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR2_EL1);
+		break;
+	case 3:
+		state[i++] = dbg_readq(DBGBVR3_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR3_EL1);
+		break;
+	case 4:
+		state[i++] = dbg_readq(DBGBVR4_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR4_EL1);
+		break;
+	case 5:
+		state[i++] = dbg_readq(DBGBVR5_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR5_EL1);
+		break;
+	case 6:
+		state[i++] = dbg_readq(DBGBVR6_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR6_EL1);
+		break;
+	case 7:
+		state[i++] = dbg_readq(DBGBVR7_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR7_EL1);
+		break;
+	case 8:
+		state[i++] = dbg_readq(DBGBVR8_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR8_EL1);
+		break;
+	case 9:
+		state[i++] = dbg_readq(DBGBVR9_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR9_EL1);
+		break;
+	case 10:
+		state[i++] = dbg_readq(DBGBVR10_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR10_EL1);
+		break;
+	case 11:
+		state[i++] = dbg_readq(DBGBVR11_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR11_EL1);
+		break;
+	case 12:
+		state[i++] = dbg_readq(DBGBVR12_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR12_EL1);
+		break;
+	case 13:
+		state[i++] = dbg_readq(DBGBVR13_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR13_EL1);
+		break;
+	case 14:
+		state[i++] = dbg_readq(DBGBVR14_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR14_EL1);
+		break;
+	case 15:
+		state[i++] = dbg_readq(DBGBVR15_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGBCR15_EL1);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_write_arch64_bxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		dbg_write(state[i++], DBGBVR0_EL1);
+		dbg_write(state[i++], DBGBCR0_EL1);
+		break;
+	case 1:
+		dbg_write(state[i++], DBGBVR1_EL1);
+		dbg_write(state[i++], DBGBCR1_EL1);
+		break;
+	case 2:
+		dbg_write(state[i++], DBGBVR2_EL1);
+		dbg_write(state[i++], DBGBCR2_EL1);
+		break;
+	case 3:
+		dbg_write(state[i++], DBGBVR3_EL1);
+		dbg_write(state[i++], DBGBCR3_EL1);
+		break;
+	case 4:
+		dbg_write(state[i++], DBGBVR4_EL1);
+		dbg_write(state[i++], DBGBCR4_EL1);
+		break;
+	case 5:
+		dbg_write(state[i++], DBGBVR5_EL1);
+		dbg_write(state[i++], DBGBCR5_EL1);
+		break;
+	case 6:
+		dbg_write(state[i++], DBGBVR6_EL1);
+		dbg_write(state[i++], DBGBCR6_EL1);
+		break;
+	case 7:
+		dbg_write(state[i++], DBGBVR7_EL1);
+		dbg_write(state[i++], DBGBCR7_EL1);
+		break;
+	case 8:
+		dbg_write(state[i++], DBGBVR8_EL1);
+		dbg_write(state[i++], DBGBCR8_EL1);
+		break;
+	case 9:
+		dbg_write(state[i++], DBGBVR9_EL1);
+		dbg_write(state[i++], DBGBCR9_EL1);
+		break;
+	case 10:
+		dbg_write(state[i++], DBGBVR10_EL1);
+		dbg_write(state[i++], DBGBCR10_EL1);
+		break;
+	case 11:
+		dbg_write(state[i++], DBGBVR11_EL1);
+		dbg_write(state[i++], DBGBCR11_EL1);
+		break;
+	case 12:
+		dbg_write(state[i++], DBGBVR12_EL1);
+		dbg_write(state[i++], DBGBCR12_EL1);
+		break;
+	case 13:
+		dbg_write(state[i++], DBGBVR13_EL1);
+		dbg_write(state[i++], DBGBCR13_EL1);
+		break;
+	case 14:
+		dbg_write(state[i++], DBGBVR14_EL1);
+		dbg_write(state[i++], DBGBCR14_EL1);
+		break;
+	case 15:
+		dbg_write(state[i++], DBGBVR15_EL1);
+		dbg_write(state[i++], DBGBCR15_EL1);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_read_arch64_wxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = dbg_readq(DBGWVR0_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR0_EL1);
+		break;
+	case 1:
+		state[i++] = dbg_readq(DBGWVR1_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR1_EL1);
+		break;
+	case 2:
+		state[i++] = dbg_readq(DBGWVR2_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR2_EL1);
+		break;
+	case 3:
+		state[i++] = dbg_readq(DBGWVR3_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR3_EL1);
+		break;
+	case 4:
+		state[i++] = dbg_readq(DBGWVR4_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR4_EL1);
+		break;
+	case 5:
+		state[i++] = dbg_readq(DBGWVR5_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR5_EL1);
+		break;
+	case 6:
+		state[i++] = dbg_readq(DBGWVR6_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR6_EL1);
+		break;
+	case 7:
+		state[i++] = dbg_readq(DBGWVR7_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR7_EL1);
+		break;
+	case 8:
+		state[i++] = dbg_readq(DBGWVR8_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR8_EL1);
+		break;
+	case 9:
+		state[i++] = dbg_readq(DBGWVR9_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR9_EL1);
+		break;
+	case 10:
+		state[i++] = dbg_readq(DBGWVR10_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR10_EL1);
+		break;
+	case 11:
+		state[i++] = dbg_readq(DBGWVR11_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR11_EL1);
+		break;
+	case 12:
+		state[i++] = dbg_readq(DBGWVR12_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR12_EL1);
+		break;
+	case 13:
+		state[i++] = dbg_readq(DBGWVR13_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR13_EL1);
+		break;
+	case 14:
+		state[i++] = dbg_readq(DBGWVR14_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR14_EL1);
+		break;
+	case 15:
+		state[i++] = dbg_readq(DBGWVR15_EL1);
+		state[i++] = (uint64_t)dbg_readl(DBGWCR15_EL1);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_write_arch64_wxr(uint64_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		dbg_write(state[i++], DBGWVR0_EL1);
+		dbg_write(state[i++], DBGWCR0_EL1);
+		break;
+	case 1:
+		dbg_write(state[i++], DBGWVR1_EL1);
+		dbg_write(state[i++], DBGWCR1_EL1);
+		break;
+	case 2:
+		dbg_write(state[i++], DBGWVR2_EL1);
+		dbg_write(state[i++], DBGWCR2_EL1);
+		break;
+	case 3:
+		dbg_write(state[i++], DBGWVR3_EL1);
+		dbg_write(state[i++], DBGWCR3_EL1);
+		break;
+	case 4:
+		dbg_write(state[i++], DBGWVR4_EL1);
+		dbg_write(state[i++], DBGWCR4_EL1);
+		break;
+	case 5:
+		dbg_write(state[i++], DBGWVR5_EL1);
+		dbg_write(state[i++], DBGWCR5_EL1);
+		break;
+	case 6:
+		dbg_write(state[i++], DBGWVR0_EL1);
+		dbg_write(state[i++], DBGWCR6_EL1);
+		break;
+	case 7:
+		dbg_write(state[i++], DBGWVR7_EL1);
+		dbg_write(state[i++], DBGWCR7_EL1);
+		break;
+	case 8:
+		dbg_write(state[i++], DBGWVR8_EL1);
+		dbg_write(state[i++], DBGWCR8_EL1);
+		break;
+	case 9:
+		dbg_write(state[i++], DBGWVR9_EL1);
+		dbg_write(state[i++], DBGWCR9_EL1);
+		break;
+	case 10:
+		dbg_write(state[i++], DBGWVR10_EL1);
+		dbg_write(state[i++], DBGWCR10_EL1);
+		break;
+	case 11:
+		dbg_write(state[i++], DBGWVR11_EL1);
+		dbg_write(state[i++], DBGWCR11_EL1);
+		break;
+	case 12:
+		dbg_write(state[i++], DBGWVR12_EL1);
+		dbg_write(state[i++], DBGWCR12_EL1);
+		break;
+	case 13:
+		dbg_write(state[i++], DBGWVR13_EL1);
+		dbg_write(state[i++], DBGWCR13_EL1);
+		break;
+	case 14:
+		dbg_write(state[i++], DBGWVR14_EL1);
+		dbg_write(state[i++], DBGWCR14_EL1);
+		break;
+	case 15:
+		dbg_write(state[i++], DBGWVR15_EL1);
+		dbg_write(state[i++], DBGWCR15_EL1);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static inline void dbg_save_state(int cpu)
+{
+	int i, j;
+
+	i = cpu * MAX_DBG_REGS;
+
+	switch (dbg.arch) {
+	case ARM_DEBUG_ARCH_V8_8:
+	case ARM_DEBUG_ARCH_V8:
+		/* Set OS Lock to inform the debugger that the OS is in the
+		 * process of saving debug registers. It prevents accidental
+		 * modification of the debug regs by the external debugger.
+		 */
+		dbg_write(0x1, OSLAR_EL1);
+		/* Ensure OS lock is set before proceeding */
+		isb();
+
+		dbg.state[i++] =  (uint32_t)dbg_readl(MDSCR_EL1);
+		for (j = 0; j < dbg.nr_bp; j++)
+			i = dbg_read_arch64_bxr((uint64_t *)dbg.state, i, j);
+		for (j = 0; j < dbg.nr_wp; j++)
+			i = dbg_read_arch64_wxr((uint64_t *)dbg.state, i, j);
+		dbg.state[i++] =  (uint32_t)dbg_readl(MDCCINT_EL1);
+		dbg.state[i++] =  (uint32_t)dbg_readl(DBGCLAIMCLR_EL1);
+		dbg.state[i++] =  (uint32_t)dbg_readl(OSECCR_EL1);
+		dbg.state[i++] =  (uint32_t)dbg_readl(OSDTRRX_EL1);
+		dbg.state[i++] =  (uint32_t)dbg_readl(OSDTRTX_EL1);
+
+		/* Set the OS double lock */
+		isb();
+		dbg_write(0x1, OSDLR_EL1);
+		isb();
+		break;
+	default:
+		pr_err_ratelimited("unsupported dbg arch %d in %s\n", dbg.arch,
+				   __func__);
+	}
+}
+
+static inline void dbg_restore_state(int cpu)
+{
+	int i, j;
+
+	i = cpu * MAX_DBG_REGS;
+
+	switch (dbg.arch) {
+	case ARM_DEBUG_ARCH_V8_8:
+	case ARM_DEBUG_ARCH_V8:
+		/* Clear the OS double lock */
+		isb();
+		dbg_write(0x0, OSDLR_EL1);
+		isb();
+
+		/* Set OS lock. Lock will already be set after power collapse
+		 * but this write is included to ensure it is set.
+		 */
+		dbg_write(0x1, OSLAR_EL1);
+		isb();
+
+		dbg_write(dbg.state[i++], MDSCR_EL1);
+		for (j = 0; j < dbg.nr_bp; j++)
+			i = dbg_write_arch64_bxr((uint64_t *)dbg.state, i, j);
+		for (j = 0; j < dbg.nr_wp; j++)
+			i = dbg_write_arch64_wxr((uint64_t *)dbg.state, i, j);
+		dbg_write(dbg.state[i++], MDCCINT_EL1);
+		dbg_write(dbg.state[i++], DBGCLAIMSET_EL1);
+		dbg_write(dbg.state[i++], OSECCR_EL1);
+		dbg_write(dbg.state[i++], OSDTRRX_EL1);
+		dbg_write(dbg.state[i++], OSDTRTX_EL1);
+
+		isb();
+		dbg_write(0x0, OSLAR_EL1);
+		isb();
+		break;
+	default:
+		pr_err_ratelimited("unsupported dbg arch %d in %s\n", dbg.arch,
+				   __func__);
+	}
+}
+
+static void dbg_init_arch_data(void)
+{
+	uint64_t dbgfr;
+
+	/* This will run on core0 so use it to populate parameters */
+	dbgfr = dbg_readq(ID_AA64DFR0_EL1);
+	dbg.arch = BMVAL(dbgfr, 0, 3);
+	dbg.nr_bp = BMVAL(dbgfr, 12, 15) + 1;
+	dbg.nr_wp = BMVAL(dbgfr, 20, 23) + 1;
+	dbg.nr_ctx_cmp = BMVAL(dbgfr, 28, 31) + 1;
+}
+#else
+
+static int dbg_read_arch32_bxr(uint32_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = dbg_read(DBGBVR0);
+		state[i++] = dbg_read(DBGBCR0);
+		break;
+	case 1:
+		state[i++] = dbg_read(DBGBVR1);
+		state[i++] = dbg_read(DBGBCR1);
+		break;
+	case 2:
+		state[i++] = dbg_read(DBGBVR2);
+		state[i++] = dbg_read(DBGBCR2);
+		break;
+	case 3:
+		state[i++] = dbg_read(DBGBVR3);
+		state[i++] = dbg_read(DBGBCR3);
+		break;
+	case 4:
+		state[i++] = dbg_read(DBGBVR4);
+		state[i++] = dbg_read(DBGBCR4);
+		break;
+	case 5:
+		state[i++] = dbg_read(DBGBVR5);
+		state[i++] = dbg_read(DBGBCR5);
+		break;
+	case 6:
+		state[i++] = dbg_read(DBGBVR6);
+		state[i++] = dbg_read(DBGBCR6);
+		break;
+	case 7:
+		state[i++] = dbg_read(DBGBVR7);
+		state[i++] = dbg_read(DBGBCR7);
+		break;
+	case 8:
+		state[i++] = dbg_read(DBGBVR8);
+		state[i++] = dbg_read(DBGBCR8);
+		break;
+	case 9:
+		state[i++] = dbg_read(DBGBVR9);
+		state[i++] = dbg_read(DBGBCR9);
+		break;
+	case 10:
+		state[i++] = dbg_read(DBGBVR10);
+		state[i++] = dbg_read(DBGBCR10);
+		break;
+	case 11:
+		state[i++] = dbg_read(DBGBVR11);
+		state[i++] = dbg_read(DBGBCR11);
+		break;
+	case 12:
+		state[i++] = dbg_read(DBGBVR12);
+		state[i++] = dbg_read(DBGBCR12);
+		break;
+	case 13:
+		state[i++] = dbg_read(DBGBVR13);
+		state[i++] = dbg_read(DBGBCR13);
+		break;
+	case 14:
+		state[i++] = dbg_read(DBGBVR14);
+		state[i++] = dbg_read(DBGBCR14);
+		break;
+	case 15:
+		state[i++] = dbg_read(DBGBVR15);
+		state[i++] = dbg_read(DBGBCR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_write_arch32_bxr(uint32_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		dbg_write(state[i++], DBGBVR0);
+		dbg_write(state[i++], DBGBCR0);
+		break;
+	case 1:
+		dbg_write(state[i++], DBGBVR1);
+		dbg_write(state[i++], DBGBCR1);
+		break;
+	case 2:
+		dbg_write(state[i++], DBGBVR2);
+		dbg_write(state[i++], DBGBCR2);
+		break;
+	case 3:
+		dbg_write(state[i++], DBGBVR3);
+		dbg_write(state[i++], DBGBCR3);
+		break;
+	case 4:
+		dbg_write(state[i++], DBGBVR4);
+		dbg_write(state[i++], DBGBCR4);
+		break;
+	case 5:
+		dbg_write(state[i++], DBGBVR5);
+		dbg_write(state[i++], DBGBCR5);
+		break;
+	case 6:
+		dbg_write(state[i++], DBGBVR6);
+		dbg_write(state[i++], DBGBCR6);
+		break;
+	case 7:
+		dbg_write(state[i++], DBGBVR7);
+		dbg_write(state[i++], DBGBCR7);
+		break;
+	case 8:
+		dbg_write(state[i++], DBGBVR8);
+		dbg_write(state[i++], DBGBCR8);
+		break;
+	case 9:
+		dbg_write(state[i++], DBGBVR9);
+		dbg_write(state[i++], DBGBCR9);
+		break;
+	case 10:
+		dbg_write(state[i++], DBGBVR10);
+		dbg_write(state[i++], DBGBCR10);
+		break;
+	case 11:
+		dbg_write(state[i++], DBGBVR11);
+		dbg_write(state[i++], DBGBCR11);
+		break;
+	case 12:
+		dbg_write(state[i++], DBGBVR12);
+		dbg_write(state[i++], DBGBCR12);
+		break;
+	case 13:
+		dbg_write(state[i++], DBGBVR13);
+		dbg_write(state[i++], DBGBCR13);
+		break;
+	case 14:
+		dbg_write(state[i++], DBGBVR14);
+		dbg_write(state[i++], DBGBCR14);
+		break;
+	case 15:
+		dbg_write(state[i++], DBGBVR15);
+		dbg_write(state[i++], DBGBCR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_read_arch32_wxr(uint32_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		state[i++] = dbg_read(DBGWVR0);
+		state[i++] = dbg_read(DBGWCR0);
+		break;
+	case 1:
+		state[i++] = dbg_read(DBGWVR1);
+		state[i++] = dbg_read(DBGWCR1);
+		break;
+	case 2:
+		state[i++] = dbg_read(DBGWVR2);
+		state[i++] = dbg_read(DBGWCR2);
+		break;
+	case 3:
+		state[i++] = dbg_read(DBGWVR3);
+		state[i++] = dbg_read(DBGWCR3);
+		break;
+	case 4:
+		state[i++] = dbg_read(DBGWVR4);
+		state[i++] = dbg_read(DBGWCR4);
+		break;
+	case 5:
+		state[i++] = dbg_read(DBGWVR5);
+		state[i++] = dbg_read(DBGWCR5);
+		break;
+	case 6:
+		state[i++] = dbg_read(DBGWVR6);
+		state[i++] = dbg_read(DBGWCR6);
+		break;
+	case 7:
+		state[i++] = dbg_read(DBGWVR7);
+		state[i++] = dbg_read(DBGWCR7);
+		break;
+	case 8:
+		state[i++] = dbg_read(DBGWVR8);
+		state[i++] = dbg_read(DBGWCR8);
+		break;
+	case 9:
+		state[i++] = dbg_read(DBGWVR9);
+		state[i++] = dbg_read(DBGWCR9);
+		break;
+	case 10:
+		state[i++] = dbg_read(DBGWVR10);
+		state[i++] = dbg_read(DBGWCR10);
+		break;
+	case 11:
+		state[i++] = dbg_read(DBGWVR11);
+		state[i++] = dbg_read(DBGWCR11);
+		break;
+	case 12:
+		state[i++] = dbg_read(DBGWVR12);
+		state[i++] = dbg_read(DBGWCR12);
+		break;
+	case 13:
+		state[i++] = dbg_read(DBGWVR13);
+		state[i++] = dbg_read(DBGWCR13);
+		break;
+	case 14:
+		state[i++] = dbg_read(DBGWVR14);
+		state[i++] = dbg_read(DBGWCR14);
+		break;
+	case 15:
+		state[i++] = dbg_read(DBGWVR15);
+		state[i++] = dbg_read(DBGWCR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static int dbg_write_arch32_wxr(uint32_t *state, int i, int j)
+{
+	switch (j) {
+	case 0:
+		dbg_write(state[i++], DBGWVR0);
+		dbg_write(state[i++], DBGWCR0);
+		break;
+	case 1:
+		dbg_write(state[i++], DBGWVR1);
+		dbg_write(state[i++], DBGWCR1);
+		break;
+	case 2:
+		dbg_write(state[i++], DBGWVR2);
+		dbg_write(state[i++], DBGWCR2);
+		break;
+	case 3:
+		dbg_write(state[i++], DBGWVR3);
+		dbg_write(state[i++], DBGWCR3);
+		break;
+	case 4:
+		dbg_write(state[i++], DBGWVR4);
+		dbg_write(state[i++], DBGWCR4);
+		break;
+	case 5:
+		dbg_write(state[i++], DBGWVR5);
+		dbg_write(state[i++], DBGWCR5);
+		break;
+	case 6:
+		dbg_write(state[i++], DBGWVR6);
+		dbg_write(state[i++], DBGWCR6);
+		break;
+	case 7:
+		dbg_write(state[i++], DBGWVR7);
+		dbg_write(state[i++], DBGWCR7);
+		break;
+	case 8:
+		dbg_write(state[i++], DBGWVR8);
+		dbg_write(state[i++], DBGWCR8);
+		break;
+	case 9:
+		dbg_write(state[i++], DBGWVR9);
+		dbg_write(state[i++], DBGWCR9);
+		break;
+	case 10:
+		dbg_write(state[i++], DBGWVR10);
+		dbg_write(state[i++], DBGWCR10);
+		break;
+	case 11:
+		dbg_write(state[i++], DBGWVR11);
+		dbg_write(state[i++], DBGWCR11);
+		break;
+	case 12:
+		dbg_write(state[i++], DBGWVR12);
+		dbg_write(state[i++], DBGWCR12);
+		break;
+	case 13:
+		dbg_write(state[i++], DBGWVR13);
+		dbg_write(state[i++], DBGWCR13);
+		break;
+	case 14:
+		dbg_write(state[i++], DBGWVR14);
+		dbg_write(state[i++], DBGWCR14);
+		break;
+	case 15:
+		dbg_write(state[i++], DBGWVR15);
+		dbg_write(state[i++], DBGWCR15);
+		break;
+	default:
+		pr_err_ratelimited("idx %d out of bounds in %s\n", j, __func__);
+	}
+	return i;
+}
+
+static inline void dbg_save_state(int cpu)
+{
+	int i, j;
+
+	i = cpu * MAX_DBG_REGS;
+
+	switch (dbg.arch) {
+	case ARM_DEBUG_ARCH_V8_8:
+	case ARM_DEBUG_ARCH_V8:
+		/* Set OS Lock to inform the debugger that the OS is in the
+		 * process of saving debug registers. It prevents accidental
+		 * modification of the debug regs by the external debugger.
+		 */
+		dbg_write(OSLOCK_MAGIC, DBGOSLAR);
+		/* Ensure OS lock is set before proceeding */
+		isb();
+
+		dbg.state[i++] =  dbg_read(DBGDSCRext);
+		for (j = 0; j < dbg.nr_bp; j++)
+			i = dbg_read_arch32_bxr(dbg.state, i, j);
+		for (j = 0; j < dbg.nr_wp; j++)
+			i = dbg_read_arch32_wxr(dbg.state, i, j);
+		dbg.state[i++] =  dbg_read(DBGDCCINT);
+		dbg.state[i++] =  dbg_read(DBGCLAIMCLR);
+		dbg.state[i++] =  dbg_read(DBGOSECCR);
+		dbg.state[i++] =  dbg_read(DBGDTRRXext);
+		dbg.state[i++] =  dbg_read(DBGDTRTXext);
+
+		/* Set the OS double lock */
+		isb();
+		dbg_write(0x1, DBGOSDLR);
+		isb();
+		break;
+	default:
+		pr_err_ratelimited("unsupported dbg arch %d in %s\n", dbg.arch,
+				   __func__);
+	}
+}
+
+static inline void dbg_restore_state(int cpu)
+{
+	int i, j;
+
+	i = cpu * MAX_DBG_REGS;
+
+	switch (dbg.arch) {
+	case ARM_DEBUG_ARCH_V8_8:
+	case ARM_DEBUG_ARCH_V8:
+		/* Clear the OS double lock */
+		isb();
+		dbg_write(0x0, DBGOSDLR);
+		isb();
+
+		/* Set OS lock. Lock will already be set after power collapse
+		 * but this write is included to ensure it is set.
+		 */
+		dbg_write(OSLOCK_MAGIC, DBGOSLAR);
+		isb();
+
+		dbg_write(dbg.state[i++], DBGDSCRext);
+		for (j = 0; j < dbg.nr_bp; j++)
+			i = dbg_write_arch32_bxr((uint32_t *)dbg.state, i, j);
+		for (j = 0; j < dbg.nr_wp; j++)
+			i = dbg_write_arch32_wxr((uint32_t *)dbg.state, i, j);
+		dbg_write(dbg.state[i++], DBGDCCINT);
+		dbg_write(dbg.state[i++], DBGCLAIMSET);
+		dbg_write(dbg.state[i++], DBGOSECCR);
+		dbg_write(dbg.state[i++], DBGDTRRXext);
+		dbg_write(dbg.state[i++], DBGDTRTXext);
+
+		isb();
+		dbg_write(0x0, DBGOSLAR);
+		isb();
+		break;
+	default:
+		pr_err_ratelimited("unsupported dbg arch %d in %s\n", dbg.arch,
+				   __func__);
+	}
+}
+
+static void dbg_init_arch_data(void)
+{
+	uint32_t dbgdidr;
+
+	/* This will run on core0 so use it to populate parameters */
+	dbgdidr = dbg_read(DBGDIDR);
+	dbg.arch = BMVAL(dbgdidr, 16, 19);
+	dbg.nr_ctx_cmp = BMVAL(dbgdidr, 20, 23) + 1;
+	dbg.nr_bp = BMVAL(dbgdidr, 24, 27) + 1;
+	dbg.nr_wp = BMVAL(dbgdidr, 28, 31) + 1;
+}
+#endif
+
+/*
+ * msm_jtag_save_state - save debug registers
+ *
+ * Debug registers are saved before power collapse if debug
+ * architecture is supported respectively and TZ isn't supporting
+ * the save and restore of debug registers.
+ *
+ * CONTEXT:
+ * Called with preemption off and interrupts locked from:
+ * 1. per_cpu idle thread context for idle power collapses
+ * or
+ * 2. per_cpu idle thread context for hotplug/suspend power collapse
+ *    for nonboot cpus
+ * or
+ * 3. suspend thread context for suspend power collapse for core0
+ *
+ * In all cases we will run on the same cpu for the entire duration.
+ */
+void msm_jtag_save_state(void)
+{
+	int cpu;
+
+	cpu = raw_smp_processor_id();
+
+	msm_jtag_save_cntr[cpu]++;
+	/* ensure counter is updated before moving forward */
+	mb();
+
+	msm_jtag_etm_save_state();
+	if (dbg.save_restore_enabled)
+		dbg_save_state(cpu);
+}
+EXPORT_SYMBOL(msm_jtag_save_state);
+
+void msm_jtag_restore_state(void)
+{
+	int cpu;
+
+	cpu = raw_smp_processor_id();
+
+	/* Attempt restore only if save has been done. If power collapse
+	 * is disabled, hotplug off of non-boot core will result in WFI
+	 * and hence msm_jtag_save_state will not occur. Subsequently,
+	 * during hotplug on of non-boot core when msm_jtag_restore_state
+	 * is called via msm_platform_secondary_init, this check will help
+	 * bail us out without restoring.
+	 */
+	if (msm_jtag_save_cntr[cpu] == msm_jtag_restore_cntr[cpu])
+		return;
+	else if (msm_jtag_save_cntr[cpu] != msm_jtag_restore_cntr[cpu] + 1)
+		pr_err_ratelimited("jtag imbalance, save:%lu, restore:%lu\n",
+				   (unsigned long)msm_jtag_save_cntr[cpu],
+				   (unsigned long)msm_jtag_restore_cntr[cpu]);
+
+	msm_jtag_restore_cntr[cpu]++;
+	/* ensure counter is updated before moving forward */
+	mb();
+
+	if (dbg.save_restore_enabled)
+		dbg_restore_state(cpu);
+	msm_jtag_etm_restore_state();
+}
+EXPORT_SYMBOL(msm_jtag_restore_state);
+
+static inline bool dbg_arch_supported(uint8_t arch)
+{
+	switch (arch) {
+	case ARM_DEBUG_ARCH_V8_8:
+	case ARM_DEBUG_ARCH_V8:
+		break;
+	default:
+		return false;
+	}
+	return true;
+}
+
+static int jtag_hotcpu_save_callback(unsigned int cpu)
+{
+	msm_jtag_save_state();
+	return 0;
+}
+
+static int jtag_hotcpu_restore_callback(unsigned int cpu)
+{
+	msm_jtag_restore_state();
+	return 0;
+}
+
+static int jtag_cpu_pm_callback(struct notifier_block *nfb,
+				unsigned long action, void *hcpu)
+{
+	switch (action) {
+	case CPU_PM_ENTER:
+		msm_jtag_save_state();
+		break;
+	case CPU_PM_ENTER_FAILED:
+	case CPU_PM_EXIT:
+		msm_jtag_restore_state();
+		break;
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block jtag_cpu_pm_notifier = {
+	.notifier_call = jtag_cpu_pm_callback,
+};
+
+static int __init msm_jtag_dbg_init(void)
+{
+	int ret;
+
+	/* This will run on core0 so use it to populate parameters */
+	dbg_init_arch_data();
+
+	if (dbg_arch_supported(dbg.arch)) {
+		if (scm_get_feat_version(TZ_DBG_ETM_FEAT_ID) < TZ_DBG_ETM_VER) {
+			dbg.save_restore_enabled = true;
+		} else {
+			pr_info("dbg save-restore supported by TZ\n");
+			goto dbg_out;
+		}
+	} else {
+		pr_info("dbg arch %u not supported\n", dbg.arch);
+		goto dbg_out;
+	}
+
+	/* Allocate dbg state save space */
+#ifdef CONFIG_ARM64
+	dbg.state = kcalloc(MAX_DBG_STATE_SIZE, sizeof(uint64_t), GFP_KERNEL);
+#else
+	dbg.state = kcalloc(MAX_DBG_STATE_SIZE, sizeof(uint32_t), GFP_KERNEL);
+#endif
+	if (!dbg.state) {
+		ret = -ENOMEM;
+		goto dbg_err;
+	}
+
+	cpuhp_setup_state_nocalls(CPUHP_AP_ARM_SAVE_RESTORE_CORESIGHT4_STARTING,
+				  "AP_ARM_SAVE_RESTORE_CORESIGHT4_STARTING",
+				  jtag_hotcpu_restore_callback,
+				  jtag_hotcpu_save_callback);
+
+	cpu_pm_register_notifier(&jtag_cpu_pm_notifier);
+dbg_out:
+	return 0;
+dbg_err:
+	return ret;
+}
+arch_initcall(msm_jtag_dbg_init);
diff --git a/drivers/soc/qcom/llcc-core.c b/drivers/soc/qcom/llcc-core.c
index 3d6b002..a5e5b56 100644
--- a/drivers/soc/qcom/llcc-core.c
+++ b/drivers/soc/qcom/llcc-core.c
@@ -35,6 +35,15 @@
 #define DRP0_INTERRUPT_ENABLE	BIT(6)
 #define SB_DB_DRP_INTERRUPT_ENABLE	0x3
 
+#ifdef CONFIG_EDAC_QCOM_LLCC
+#define ENABLE_ECC_INTR 1
+#else
+#define ENABLE_ECC_INTR 0
+#endif
+
+static int enable_ecc_intr = ENABLE_ECC_INTR;
+module_param(enable_ecc_intr, int, 0444);
+
 static void qcom_llcc_core_setup(struct regmap *llcc_regmap, uint32_t b_off)
 {
 	u32 sb_err_threshold;
@@ -81,7 +90,8 @@
 		return -EINVAL;
 	}
 
-	qcom_llcc_core_setup(llcc_regmap, b_off);
+	if (enable_ecc_intr)
+		qcom_llcc_core_setup(llcc_regmap, b_off);
 
 	return 0;
 }
diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
index 739c053..5234580 100644
--- a/drivers/soc/qcom/llcc-sdm845.c
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -57,23 +57,24 @@
 	}
 
 static struct llcc_slice_config sdm845_data[] =  {
-	SCT_ENTRY("cpuss",       1, 1, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 1),
+	SCT_ENTRY("cpuss",       1, 1, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 1),
 	SCT_ENTRY("vidsc0",      2, 2, 512, 2, 1, 0x0,  0x0F0, 0, 0, 1, 1, 0),
 	SCT_ENTRY("vidsc1",      3, 3, 512, 2, 1, 0x0,  0x0F0, 0, 0, 1, 1, 0),
-	SCT_ENTRY("rotator",     4, 4, 563, 2, 1, 0x0,  0x00F, 2, 0, 1, 1, 0),
-	SCT_ENTRY("voice",       5, 5, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("audio",       6, 6, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("modemhp_grow", 7, 7, 1024, 2, 0, 0x0F0, 0xF0F, 0, 0, 1, 1, 0),
-	SCT_ENTRY("modem",       8, 8, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("compute",     10, 10, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("gpuhtw",      11, 11, 512, 1, 1, 0x0,  0xC, 0, 0, 1, 1, 0),
-	SCT_ENTRY("gpu",         12, 12, 2560, 1, 0, 0xFF0, 0x3, 0, 0, 1, 1, 0),
-	SCT_ENTRY("mmuhwt",      13, 13, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 0, 1),
-	SCT_ENTRY("compute_dma", 15, 15, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("display",     16, 16, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
+	SCT_ENTRY("rotator",     4, 4, 563, 2, 1, 0x0,  0x00e, 2, 0, 1, 1, 0),
+	SCT_ENTRY("voice",       5, 5, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("audio",       6, 6, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("modemhp_grow", 7, 7, 1024, 2, 0, 0x0FC, 0xF00, 0, 0, 1, 1, 0),
+	SCT_ENTRY("modem",       8, 8, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("compute",     10, 10, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("gpuhtw",      11, 11, 512, 1, 1, 0xC,  0x0, 0, 0, 1, 1, 0),
+	SCT_ENTRY("gpu",         12, 12, 2304, 1, 0, 0xFF0, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("mmuhwt",      13, 13, 256, 2, 0, 0x0,  0x1, 0, 0, 1, 0, 1),
+	SCT_ENTRY("compute_dma", 15, 15, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("display",     16, 16, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+	SCT_ENTRY("videofw",     17, 17, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
 	SCT_ENTRY("modemhp_fix", 20, 20, 1024, 2, 1, 0x0,  0xF00, 0, 0, 1, 1, 0),
-	SCT_ENTRY("modem_paging", 21, 21, 1024, 0, 1, 0x0,  0xF, 0, 0, 1, 1, 0),
-	SCT_ENTRY("audiohw",     22, 22, 1024, 1, 1, 0xFF0, 0xF, 0, 0, 1, 1, 0),
+	SCT_ENTRY("modem_paging", 21, 21, 1024, 0, 1, 0x1e, 0x0, 0, 0, 1, 1, 0),
+	SCT_ENTRY("audiohw",     22, 22, 1024, 1, 1, 0xFFC, 0x2, 0, 0, 1, 1, 0),
 };
 
 static int sdm845_qcom_llcc_probe(struct platform_device *pdev)
diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index 5ca0941..5dd49e8 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -43,7 +43,10 @@
 #define LLCC_STATUS_READ_DELAY 100
 
 #define CACHE_LINE_SIZE_SHIFT 6
-#define SIZE_PER_LLCC_SHIFT   2
+
+#define LLCC_COMMON_STATUS0		0x0003000C
+#define LLCC_LB_CNT_MASK		0xf0000000
+#define LLCC_LB_CNT_SHIFT		28
 
 #define MAX_CAP_TO_BYTES(n) (n * 1024)
 #define LLCC_TRP_ACT_CTRLn(n) (n * 0x1000)
@@ -65,6 +68,7 @@
 	u32 llcc_config_data_sz;
 	u32 max_slices;
 	u32 b_off;
+	u32 no_banks;
 	unsigned long *llcc_slice_map;
 };
 
@@ -342,13 +346,15 @@
 		attr1_val |= (llcc_table[i].priority << ATTR1_PRIORITY_SHIFT);
 
 		max_cap_cacheline = MAX_CAP_TO_BYTES(llcc_table[i].max_cap);
-		max_cap_cacheline >>= CACHE_LINE_SIZE_SHIFT;
-		/* There are four llcc instances llcc0..llcc3. The SW writes to
-		 * to broadcast register which gets propagated to each llcc.
+
+		/* LLCC instances can vary for each target.
+		 * The SW writes to broadcast register which gets propagated
+		 * to each llcc instace (llcc0,.. llccN).
 		 * Since the size of the memory is divided equally amongst the
-		 * four llcc, we need to divide the max cap by 4
+		 * llcc instances, we need to configure the max cap accordingly.
 		 */
-		max_cap_cacheline >>= SIZE_PER_LLCC_SHIFT;
+		max_cap_cacheline = (max_cap_cacheline / drv->no_banks);
+		max_cap_cacheline >>= CACHE_LINE_SIZE_SHIFT;
 		attr1_val |= (max_cap_cacheline << ATTR1_MAX_CAP_SHIFT);
 
 		attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
@@ -375,6 +381,7 @@
 		      const struct llcc_slice_config *llcc_cfg, u32 sz)
 {
 	int rc = 0;
+	u32 num_banks = 0;
 	struct device *dev = &pdev->dev;
 	static struct llcc_drv_data *drv_data;
 
@@ -386,6 +393,13 @@
 	if (!drv_data->llcc_map)
 		return PTR_ERR(drv_data->llcc_map);
 
+	regmap_read(drv_data->llcc_map, LLCC_COMMON_STATUS0,
+		    &num_banks);
+
+	num_banks &= LLCC_LB_CNT_MASK;
+	num_banks >>= LLCC_LB_CNT_SHIFT;
+	drv_data->no_banks = num_banks;
+
 	rc = of_property_read_u32(pdev->dev.of_node, "max-slices",
 				  &drv_data->max_slices);
 	if (rc) {
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_bimc_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_bimc_rpmh.c
index c1e8feb..dafae4c 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_bimc_rpmh.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_bimc_rpmh.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -242,7 +242,7 @@
 	(M_BKE_GC_GC_BMSK >> \
 	(M_BKE_GC_GC_SHFT + 1))
 
-static int bimc_div(int64_t *a, uint32_t b)
+static int bimc_div(uint64_t *a, uint32_t b)
 {
 	if ((*a > 0) && (*a < b)) {
 		*a = 0;
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c
index 0e5ead0..5a110bb 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c
@@ -563,12 +563,14 @@
 		return ret;
 
 	list_for_each_entry_safe(node, node_tmp, clist, link) {
-		if (unlikely(node->node_info->defer_qos))
-			msm_bus_dev_init_qos(&node->dev, NULL);
-
 		bcm_clist_add(node);
 	}
 
+	if (!cur_rsc) {
+		MSM_BUS_ERR("%s: Error for cur_rsc is NULL.\n", __func__);
+		return ret;
+	}
+
 	cur_mbox = cur_rsc->rscdev->mbox;
 	cur_bcm_clist = cur_rsc->rscdev->bcm_clist;
 
@@ -640,33 +642,39 @@
 			MSM_BUS_ERR("%s: error sending active/awake sets: %d\n",
 						__func__, ret);
 	} else {
-		ret = rpmh_write_passthru(cur_mbox, cur_rsc->rscdev->req_state,
+		ret = rpmh_write_batch(cur_mbox, cur_rsc->rscdev->req_state,
 						cmdlist_active, n_active);
 		if (ret)
 			MSM_BUS_ERR("%s: error sending active/awake sets: %d\n",
 						__func__, ret);
 	}
 	if (cnt_wake) {
-		ret = rpmh_write_passthru(cur_mbox, RPMH_WAKE_ONLY_STATE,
+		ret = rpmh_write_batch(cur_mbox, RPMH_WAKE_ONLY_STATE,
 							cmdlist_wake, n_wake);
 		if (ret)
 			MSM_BUS_ERR("%s: error sending wake sets: %d\n",
 							__func__, ret);
+		kfree(n_wake);
+		kfree(cmdlist_wake);
 	}
 	if (cnt_sleep) {
-		ret = rpmh_write_passthru(cur_mbox, RPMH_SLEEP_STATE,
+		ret = rpmh_write_batch(cur_mbox, RPMH_SLEEP_STATE,
 							cmdlist_sleep, n_sleep);
 		if (ret)
 			MSM_BUS_ERR("%s: error sending sleep sets: %d\n",
 							__func__, ret);
+		kfree(n_sleep);
+		kfree(cmdlist_sleep);
 	}
 
 	kfree(cmdlist_active);
-	kfree(cmdlist_wake);
-	kfree(cmdlist_sleep);
 	kfree(n_active);
-	kfree(n_wake);
-	kfree(n_sleep);
+
+
+	list_for_each_entry_safe(node, node_tmp, clist, link) {
+		if (unlikely(node->node_info->defer_qos))
+			msm_bus_dev_init_qos(&node->dev, NULL);
+	}
 
 exit_msm_bus_commit_data:
 	list_for_each_entry_safe(node, node_tmp, clist, link) {
@@ -962,6 +970,12 @@
 
 	MSM_BUS_DBG("Device = %d", node_dev->node_info->id);
 
+	if (node_dev->node_info->qos_params.defer_init_qos) {
+		node_dev->node_info->qos_params.defer_init_qos = false;
+		node_dev->node_info->defer_qos = true;
+		goto exit_init_qos;
+	}
+
 	if (node_dev->ap_owned) {
 		struct msm_bus_node_device_type *bus_node_info;
 
@@ -995,6 +1009,7 @@
 
 				bus_node_info->fabdev->noc_ops.qos_init(
 					node_dev,
+					bus_node_info,
 					bus_node_info->fabdev->qos_base,
 					bus_node_info->fabdev->base_offset,
 					bus_node_info->fabdev->qos_off,
@@ -1290,6 +1305,8 @@
 				pdata_node_info->qos_params.reg_mode.write;
 	node_info->qos_params.urg_fwd_en =
 				pdata_node_info->qos_params.urg_fwd_en;
+	node_info->qos_params.defer_init_qos =
+				pdata_node_info->qos_params.defer_init_qos;
 	node_info->agg_params.buswidth = pdata_node_info->agg_params.buswidth;
 	node_info->agg_params.agg_scheme =
 					pdata_node_info->agg_params.agg_scheme;
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_noc_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_noc_rpmh.c
index 996c719..bdcdf29 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_noc_rpmh.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_noc_rpmh.c
@@ -15,10 +15,14 @@
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/msm-bus-board.h>
+#include <linux/msm-bus.h>
+#include <linux/spinlock.h>
 #include "msm_bus_core.h"
 #include "msm_bus_noc.h"
 #include "msm_bus_rpmh.h"
 
+static DEFINE_SPINLOCK(noc_lock);
+
 /* NOC_QOS generic */
 #define __CLZ(x) ((8 * sizeof(uint32_t)) - 1 - __fls(x))
 #define SAT_SCALE 16	/* 16 bytes minimum for saturation */
@@ -29,6 +33,7 @@
 #define MAX_SAT_FIELD (NOC_QOS_SATn_SAT_BMSK >> NOC_QOS_SATn_SAT_SHFT)
 #define MIN_SAT_FIELD	1
 #define MIN_BW_FIELD	1
+#define MSM_BUS_FAB_MEM_NOC 6152
 
 #define NOC_QOS_REG_BASE(b, o)		((b) + (o))
 
@@ -102,6 +107,8 @@
 	NOC_QOS_SATn_SAT_SHFT		= 0x0,
 };
 
+static void __iomem *memnoc_qos_base;
+
 static int noc_div(uint64_t *a, uint32_t b)
 {
 	if ((*a > 0) && (*a < b)) {
@@ -169,38 +176,10 @@
 	wmb();
 }
 
-static void noc_set_qos_limiter(void __iomem *base, uint32_t qos_off,
-		uint32_t mport, uint32_t qos_delta,
-		struct msm_bus_noc_limiter *lim, uint32_t lim_en)
+static void noc_enable_qos_limiter(void __iomem *base, uint32_t qos_off,
+		uint32_t mport, uint32_t qos_delta, uint32_t lim_en)
 {
 	uint32_t reg_val, val;
-
-	reg_val = readl_relaxed(NOC_QOS_MAINCTL_LOWn_ADDR(base, qos_off, mport,
-		qos_delta));
-
-	writel_relaxed((reg_val & (~(NOC_QOS_MCTL_LIMIT_ENn_BMSK))),
-		NOC_QOS_MAINCTL_LOWn_ADDR(base, qos_off, mport, qos_delta));
-
-	/* Ensure we disable limiter before config*/
-	wmb();
-
-	reg_val = readl_relaxed(NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport,
-		qos_delta));
-	val = lim->bw << NOC_QOS_LIMITBW_BWn_SHFT;
-	writel_relaxed(((reg_val & (~(NOC_QOS_LIMITBW_BWn_BMSK))) |
-		(val & NOC_QOS_LIMITBW_BWn_BMSK)),
-		NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport, qos_delta));
-
-	reg_val = readl_relaxed(NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport,
-		qos_delta));
-	val = lim->sat << NOC_QOS_LIMITBW_SATn_SHFT;
-	writel_relaxed(((reg_val & (~(NOC_QOS_LIMITBW_SATn_BMSK))) |
-		(val & NOC_QOS_LIMITBW_SATn_BMSK)),
-		NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport, qos_delta));
-
-	/* Ensure qos limiter settings in place before possibly enabling */
-	wmb();
-
 	reg_val = readl_relaxed(NOC_QOS_MAINCTL_LOWn_ADDR(base, qos_off, mport,
 		qos_delta));
 	val = lim_en << NOC_QOS_MCTL_LIMIT_ENn_SHFT;
@@ -208,9 +187,50 @@
 		(val & NOC_QOS_MCTL_LIMIT_ENn_BMSK)),
 		NOC_QOS_MAINCTL_LOWn_ADDR(base, qos_off, mport, qos_delta));
 
+	/* Ensure we disable/enable limiter before exiting*/
 	wmb();
 }
 
+static void noc_set_qos_limit_bw(void __iomem *base, uint32_t qos_off,
+		uint32_t mport, uint32_t qos_delta, uint32_t bw)
+{
+	uint32_t reg_val, val;
+	reg_val = readl_relaxed(NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport,
+		qos_delta));
+	val = bw << NOC_QOS_LIMITBW_BWn_SHFT;
+	writel_relaxed(((reg_val & (~(NOC_QOS_LIMITBW_BWn_BMSK))) |
+		(val & NOC_QOS_LIMITBW_BWn_BMSK)),
+		NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport, qos_delta));
+
+	/* Ensure we set limiter bw before exiting*/
+	wmb();
+}
+
+static void noc_set_qos_limit_sat(void __iomem *base, uint32_t qos_off,
+		uint32_t mport, uint32_t qos_delta, uint32_t sat)
+{
+	uint32_t reg_val, val;
+	reg_val = readl_relaxed(NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport,
+		qos_delta));
+	val = sat << NOC_QOS_LIMITBW_SATn_SHFT;
+	writel_relaxed(((reg_val & (~(NOC_QOS_LIMITBW_SATn_BMSK))) |
+		(val & NOC_QOS_LIMITBW_SATn_BMSK)),
+		NOC_QOS_LIMITBWn_ADDR(base, qos_off, mport, qos_delta));
+
+	/* Ensure we set limiter sat before exiting*/
+	wmb();
+}
+
+static void noc_set_qos_limiter(void __iomem *base, uint32_t qos_off,
+		uint32_t mport, uint32_t qos_delta,
+		struct msm_bus_noc_limiter *lim, uint32_t lim_en)
+{
+	noc_enable_qos_limiter(base, qos_off, mport, qos_delta, 0);
+	noc_set_qos_limit_bw(base, qos_off, mport, qos_delta, lim->bw);
+	noc_set_qos_limit_sat(base, qos_off, mport, qos_delta, lim->sat);
+	noc_enable_qos_limiter(base, qos_off, mport, qos_delta, lim_en);
+}
+
 static void noc_set_qos_regulator(void __iomem *base, uint32_t qos_off,
 		uint32_t mport, uint32_t qos_delta,
 		struct msm_bus_noc_regulator *reg,
@@ -317,6 +337,7 @@
 }
 
 static int msm_bus_noc_qos_init(struct msm_bus_node_device_type *info,
+				struct msm_bus_node_device_type *fabdev,
 				void __iomem *qos_base,
 				uint32_t qos_off, uint32_t qos_delta,
 				uint32_t qos_freq)
@@ -324,6 +345,7 @@
 	struct msm_bus_noc_qos_params *qos_params;
 	int ret = 0;
 	int i;
+	unsigned long flags;
 
 	qos_params = &info->node_info->qos_params;
 
@@ -333,6 +355,11 @@
 		goto err_qos_init;
 	}
 
+	spin_lock_irqsave(&noc_lock, flags);
+
+	if (fabdev->node_info->id == MSM_BUS_FAB_MEM_NOC)
+		memnoc_qos_base = qos_base;
+
 	for (i = 0; i < info->node_info->num_qports; i++) {
 		noc_set_qos_dflt_prio(qos_base, qos_off,
 					info->node_info->qport[i],
@@ -356,10 +383,87 @@
 					qos_delta,
 					qos_params->urg_fwd_en);
 	}
+	spin_unlock_irqrestore(&noc_lock, flags);
+
 err_qos_init:
 	return ret;
 }
 
+int msm_bus_noc_throttle_wa(bool enable)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&noc_lock, flags);
+
+	if (!memnoc_qos_base) {
+		MSM_BUS_ERR("Memnoc QoS Base address not found!");
+		goto noc_throttle_exit;
+	}
+
+	if (enable) {
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 2,
+								0x1000, 0x1B);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 3,
+								0x1000, 0x1B);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 10,
+								0x1000, 0x30);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 11,
+								0x1000, 0x30);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 10,
+								0x1000, 1);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 11,
+								0x1000, 1);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 2,
+								0x1000, 1);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 3,
+								0x1000, 1);
+	} else {
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 2,
+								0x1000, 0);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 3,
+								0x1000, 0);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 10,
+								0x1000, 0);
+		noc_enable_qos_limiter(memnoc_qos_base, 0x10000, 11,
+								0x1000, 0);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 2,
+								0x1000, 0);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 3,
+								0x1000, 0);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 10,
+								0x1000, 0);
+		noc_set_qos_limit_bw(memnoc_qos_base, 0x10000, 11,
+								0x1000, 0);
+	}
+
+noc_throttle_exit:
+	spin_unlock_irqrestore(&noc_lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(msm_bus_noc_throttle_wa);
+
+int msm_bus_noc_priority_wa(bool enable)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&noc_lock, flags);
+	if (!memnoc_qos_base) {
+		MSM_BUS_ERR("Memnoc QoS Base address not found!");
+		goto noc_priority_exit;
+	}
+
+	if (enable)
+		noc_set_qos_dflt_prio(memnoc_qos_base, 0x10000, 0,
+								0x1000, 7);
+	else
+		noc_set_qos_dflt_prio(memnoc_qos_base, 0x10000, 0,
+								0x1000, 6);
+noc_priority_exit:
+	spin_unlock_irqrestore(&noc_lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(msm_bus_noc_priority_wa);
+
 int msm_bus_noc_set_ops(struct msm_bus_node_device_type *bus_dev)
 {
 	if (!bus_dev)
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c
index 77cbbf1..32b6adf 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c
@@ -241,6 +241,8 @@
 	node_info->qos_params.urg_fwd_en = of_property_read_bool(dev_node,
 						"qcom,forwarding");
 
+	node_info->qos_params.defer_init_qos = of_property_read_bool(dev_node,
+						"qcom,defer-init-qos");
 }
 
 static int msm_bus_of_parse_clk_array(struct device_node *dev_node,
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_rpmh.h b/drivers/soc/qcom/msm_bus/msm_bus_rpmh.h
index ad04fef..8929959 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_rpmh.h
+++ b/drivers/soc/qcom/msm_bus/msm_bus_rpmh.h
@@ -42,6 +42,7 @@
 /* New types introduced for adhoc topology */
 struct msm_bus_noc_ops {
 	int (*qos_init)(struct msm_bus_node_device_type *dev,
+			struct msm_bus_node_device_type *fabdev,
 			void __iomem *qos_base, uint32_t qos_off,
 			uint32_t qos_delta, uint32_t qos_freq);
 	int (*set_bw)(struct msm_bus_node_device_type *dev,
@@ -136,6 +137,7 @@
 	struct msm_bus_noc_regulator reg;
 	struct msm_bus_noc_regulator_mode reg_mode;
 	bool urg_fwd_en;
+	bool defer_init_qos;
 };
 
 struct node_util_levels_type {
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_rules.c b/drivers/soc/qcom/msm_bus/msm_bus_rules.c
index 03042fa..4cff9f2 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_rules.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_rules.c
@@ -410,8 +410,10 @@
 {
 	struct rule_node_info *node_it = NULL;
 
+	mutex_lock(&msm_bus_rules_lock);
 	list_for_each_entry(node_it, &node_list, link)
 		print_rules(node_it);
+	mutex_unlock(&msm_bus_rules_lock);
 }
 
 void print_rules_buf(char *buf, int max_buf)
@@ -421,6 +423,7 @@
 	int i;
 	int cnt = 0;
 
+	mutex_lock(&msm_bus_rules_lock);
 	list_for_each_entry(node_it, &node_list, link) {
 		cnt += scnprintf(buf + cnt, max_buf - cnt,
 			"\n Now printing rules for Node %d cur_rule %d\n",
@@ -452,6 +455,7 @@
 					node_rule->rule_ops.mode);
 		}
 	}
+	mutex_unlock(&msm_bus_rules_lock);
 }
 
 static int copy_rule(struct bus_rule_type *src, struct rules_def *node_rule,
@@ -716,11 +720,12 @@
 {
 	bool ret = false;
 
+	mutex_lock(&msm_bus_rules_lock);
 	if (list_empty(&node_list))
 		ret = false;
 	else
 		ret = true;
-
+	mutex_unlock(&msm_bus_rules_lock);
 	return ret;
 }
 
diff --git a/drivers/soc/qcom/msm_glink_pkt.c b/drivers/soc/qcom/msm_glink_pkt.c
index 519bb611..25099bb 100644
--- a/drivers/soc/qcom/msm_glink_pkt.c
+++ b/drivers/soc/qcom/msm_glink_pkt.c
@@ -33,7 +33,8 @@
 #include <linux/termios.h>
 
 #include <soc/qcom/glink.h>
-
+/* This Limit ensures that auto queue will not exhaust memory on remote side */
+#define MAX_PENDING_GLINK_PKT 5
 #define MODULE_NAME "msm_glinkpkt"
 #define DEVICE_NAME "glinkpkt"
 #define WAKEUPSOURCE_TIMEOUT (2000) /* two seconds */
@@ -136,6 +137,7 @@
 	struct glink_link_info link_info;
 	void *link_state_handle;
 	bool link_up;
+	bool auto_intent_enabled;
 };
 
 /**
@@ -445,9 +447,26 @@
 bool glink_pkt_rmt_rx_intent_req_cb(void *handle, const void *priv, size_t sz)
 {
 	struct queue_rx_intent_work *work_item;
+	int pending_pkt_count = 0;
+	struct glink_rx_pkt *pkt = NULL;
+	unsigned long flags;
+	struct glink_pkt_dev *devp = (struct glink_pkt_dev *)priv;
 
 	GLINK_PKT_INFO("%s(): QUEUE RX INTENT to receive size[%zu]\n",
 		   __func__, sz);
+	if (devp->auto_intent_enabled) {
+		spin_lock_irqsave(&devp->pkt_list_lock, flags);
+		list_for_each_entry(pkt, &devp->pkt_list, list)
+			pending_pkt_count++;
+		spin_unlock_irqrestore(&devp->pkt_list_lock, flags);
+		if (pending_pkt_count > MAX_PENDING_GLINK_PKT) {
+			GLINK_PKT_ERR("%s failed, max limit reached\n",
+					__func__);
+			return false;
+		}
+	} else {
+		return false;
+	}
 
 	work_item = kzalloc(sizeof(*work_item), GFP_ATOMIC);
 	if (!work_item) {
@@ -456,7 +475,7 @@
 	}
 
 	work_item->intent_size = sz;
-	work_item->devp = (struct glink_pkt_dev *)priv;
+	work_item->devp = devp;
 	INIT_WORK(&work_item->work, glink_pkt_queue_rx_intent_worker);
 	queue_work(glink_pkt_wq, &work_item->work);
 
@@ -626,10 +645,11 @@
 	}
 
 	mutex_lock(&devp->ch_lock);
-	if (!glink_rx_intent_exists(devp->handle, count)) {
+	if (!glink_pkt_read_avail(devp) &&
+				!glink_rx_intent_exists(devp->handle, count)) {
 		ret  = glink_queue_rx_intent(devp->handle, devp, count);
 		if (ret) {
-			GLINK_PKT_ERR("%s: failed to queue_rx_intent ret[%d]\n",
+			GLINK_PKT_ERR("%s: failed to queue intent ret[%d]\n",
 					__func__, ret);
 			mutex_unlock(&devp->ch_lock);
 			return ret;
@@ -914,6 +934,7 @@
 	case GLINK_PKT_IOCTL_QUEUE_RX_INTENT:
 		ret = get_user(size, (uint32_t *)arg);
 		GLINK_PKT_INFO("%s: intent size[%d]\n", __func__, size);
+		devp->auto_intent_enabled = false;
 		ret  = glink_queue_rx_intent(devp->handle, devp, size);
 		if (ret) {
 			GLINK_PKT_ERR("%s: failed to QUEUE_RX_INTENT ret[%d]\n",
@@ -1182,6 +1203,7 @@
 				glink_pkt_link_state_cb;
 	devp->i = i;
 	devp->poll_mode = 0;
+	devp->auto_intent_enabled = true;
 	devp->ws_locked = 0;
 	devp->ch_state = GLINK_LOCAL_DISCONNECTED;
 	/* Default timeout for open wait is 120sec */
diff --git a/drivers/soc/qcom/msm_performance.c b/drivers/soc/qcom/msm_performance.c
index 979c628..b5ce753 100644
--- a/drivers/soc/qcom/msm_performance.c
+++ b/drivers/soc/qcom/msm_performance.c
@@ -25,7 +25,6 @@
 #include <linux/module.h>
 #include <linux/input.h>
 #include <linux/kthread.h>
-#include <soc/qcom/msm-core.h>
 
 static struct mutex managed_cpus_lock;
 
@@ -33,10 +32,6 @@
 static unsigned int num_clusters;
 struct cluster {
 	cpumask_var_t cpus;
-	/* Number of CPUs to maintain online */
-	int max_cpu_request;
-	/* To track CPUs that the module decides to offline */
-	cpumask_var_t offlined_cpus;
 	/* stats for load detection */
 	/* IO */
 	u64 last_io_check_ts;
@@ -84,8 +79,6 @@
 static struct cluster **managed_clusters;
 static bool clusters_inited;
 
-/* Work to evaluate the onlining/offlining CPUs */
-static struct delayed_work evaluate_hotplug_work;
 
 /* To handle cpufreq min/max request */
 struct cpu_status {
@@ -94,11 +87,8 @@
 };
 static DEFINE_PER_CPU(struct cpu_status, cpu_stats);
 
-static unsigned int num_online_managed(struct cpumask *mask);
 static int init_cluster_control(void);
-static int rm_high_pwr_cost_cpus(struct cluster *cl);
 static int init_events_group(void);
-static DEFINE_PER_CPU(unsigned int, cpu_power_cost);
 struct events {
 	spinlock_t cpu_hotplug_lock;
 	bool cpu_hotplug;
@@ -214,65 +204,6 @@
 };
 device_param_cb(num_clusters, &param_ops_num_clusters, NULL, 0644);
 
-static int set_max_cpus(const char *buf, const struct kernel_param *kp)
-{
-	unsigned int i, ntokens = 0;
-	const char *cp = buf;
-	int val;
-
-	if (!clusters_inited)
-		return -EINVAL;
-
-	while ((cp = strpbrk(cp + 1, ":")))
-		ntokens++;
-
-	if (ntokens != (num_clusters - 1))
-		return -EINVAL;
-
-	cp = buf;
-	for (i = 0; i < num_clusters; i++) {
-
-		if (sscanf(cp, "%d\n", &val) != 1)
-			return -EINVAL;
-		if (val > (int)cpumask_weight(managed_clusters[i]->cpus))
-			return -EINVAL;
-
-		managed_clusters[i]->max_cpu_request = val;
-
-		cp = strnchr(cp, strlen(cp), ':');
-		cp++;
-		trace_set_max_cpus(cpumask_bits(managed_clusters[i]->cpus)[0],
-								val);
-	}
-
-	schedule_delayed_work(&evaluate_hotplug_work, 0);
-
-	return 0;
-}
-
-static int get_max_cpus(char *buf, const struct kernel_param *kp)
-{
-	int i, cnt = 0;
-
-	if (!clusters_inited)
-		return cnt;
-
-	for (i = 0; i < num_clusters; i++)
-		cnt += snprintf(buf + cnt, PAGE_SIZE - cnt,
-				"%d:", managed_clusters[i]->max_cpu_request);
-	cnt--;
-	cnt += snprintf(buf + cnt, PAGE_SIZE - cnt, " ");
-	return cnt;
-}
-
-static const struct kernel_param_ops param_ops_max_cpus = {
-	.set = set_max_cpus,
-	.get = get_max_cpus,
-};
-
-#ifdef CONFIG_MSM_PERFORMANCE_HOTPLUG_ON
-device_param_cb(max_cpus, &param_ops_max_cpus, NULL, 0644);
-#endif
 
 static int set_managed_cpus(const char *buf, const struct kernel_param *kp)
 {
@@ -291,7 +222,6 @@
 		if (cpumask_empty(managed_clusters[i]->cpus)) {
 			mutex_lock(&managed_cpus_lock);
 			cpumask_copy(managed_clusters[i]->cpus, &tmp_mask);
-			cpumask_clear(managed_clusters[i]->offlined_cpus);
 			mutex_unlock(&managed_cpus_lock);
 			break;
 		}
@@ -337,53 +267,6 @@
 };
 device_param_cb(managed_cpus, &param_ops_managed_cpus, NULL, 0644);
 
-/* Read-only node: To display all the online managed CPUs */
-static int get_managed_online_cpus(char *buf, const struct kernel_param *kp)
-{
-	int i, cnt = 0, total_cnt = 0;
-	char tmp[MAX_LENGTH_CPU_STRING] = "";
-	struct cpumask tmp_mask;
-	struct cluster *i_cl;
-
-	if (!clusters_inited)
-		return cnt;
-
-	for (i = 0; i < num_clusters; i++) {
-		i_cl = managed_clusters[i];
-
-		cpumask_clear(&tmp_mask);
-		cpumask_complement(&tmp_mask, i_cl->offlined_cpus);
-		cpumask_and(&tmp_mask, i_cl->cpus, &tmp_mask);
-
-		cnt = cpumap_print_to_pagebuf(true, buf, &tmp_mask);
-		if ((i + 1) < num_clusters &&
-		    (total_cnt + cnt + 1) <= MAX_LENGTH_CPU_STRING) {
-			snprintf(tmp + total_cnt, cnt, "%s", buf);
-			tmp[cnt-1] = ':';
-			tmp[cnt] = '\0';
-			total_cnt += cnt;
-		} else if ((i + 1) == num_clusters &&
-			   (total_cnt + cnt) <= MAX_LENGTH_CPU_STRING) {
-			snprintf(tmp + total_cnt, cnt, "%s", buf);
-			total_cnt += cnt;
-		} else {
-			pr_err("invalid string for managed_cpu:%s%s\n", tmp,
-				buf);
-			break;
-		}
-	}
-	snprintf(buf, PAGE_SIZE, "%s", tmp);
-	return total_cnt;
-}
-
-static const struct kernel_param_ops param_ops_managed_online_cpus = {
-	.get = get_managed_online_cpus,
-};
-
-#ifdef CONFIG_MSM_PERFORMANCE_HOTPLUG_ON
-device_param_cb(managed_online_cpus, &param_ops_managed_online_cpus,
-							NULL, 0444);
-#endif
 /*
  * Userspace sends cpu#:min_freq_value to vote for min_freq_value as the new
  * scaling_min. To withdraw its vote it needs to enter cpu#:0
@@ -2274,15 +2157,6 @@
 };
 /*******************************sysfs ends************************************/
 
-static unsigned int num_online_managed(struct cpumask *mask)
-{
-	struct cpumask tmp_mask;
-
-	cpumask_clear(&tmp_mask);
-	cpumask_and(&tmp_mask, mask, cpu_online_mask);
-
-	return cpumask_weight(&tmp_mask);
-}
 
 static int perf_adjust_notify(struct notifier_block *nb, unsigned long val,
 							void *data)
@@ -2359,185 +2233,6 @@
 
 	return 0;
 }
-
-/*
- * Attempt to offline CPUs based on their power cost.
- * CPUs with higher power costs are offlined first.
- */
-static int __ref rm_high_pwr_cost_cpus(struct cluster *cl)
-{
-	unsigned int cpu, i;
-	struct cpu_pwr_stats *per_cpu_info = get_cpu_pwr_stats();
-	struct cpu_pstate_pwr *costs;
-	unsigned int *pcpu_pwr;
-	unsigned int max_cost_cpu, max_cost;
-	int any_cpu = -1;
-
-	if (!per_cpu_info)
-		return -EAGAIN;
-
-	for_each_cpu(cpu, cl->cpus) {
-		costs = per_cpu_info[cpu].ptable;
-		if (!costs || !costs[0].freq)
-			continue;
-
-		i = 1;
-		while (costs[i].freq)
-			i++;
-
-		pcpu_pwr = &per_cpu(cpu_power_cost, cpu);
-		*pcpu_pwr = costs[i - 1].power;
-		any_cpu = (int)cpu;
-		pr_debug("msm_perf: CPU:%d Power:%u\n", cpu, *pcpu_pwr);
-	}
-
-	if (any_cpu < 0)
-		return -EAGAIN;
-
-	for (i = 0; i < cpumask_weight(cl->cpus); i++) {
-		max_cost = 0;
-		max_cost_cpu = cpumask_first(cl->cpus);
-
-		for_each_cpu(cpu, cl->cpus) {
-			pcpu_pwr = &per_cpu(cpu_power_cost, cpu);
-			if (max_cost < *pcpu_pwr) {
-				max_cost = *pcpu_pwr;
-				max_cost_cpu = cpu;
-			}
-		}
-
-		if (!cpu_online(max_cost_cpu))
-			goto end;
-
-		pr_debug("msm_perf: Offlining CPU%d Power:%d\n", max_cost_cpu,
-								max_cost);
-		cpumask_set_cpu(max_cost_cpu, cl->offlined_cpus);
-		lock_device_hotplug();
-		if (device_offline(get_cpu_device(max_cost_cpu))) {
-			cpumask_clear_cpu(max_cost_cpu, cl->offlined_cpus);
-			pr_debug("msm_perf: Offlining CPU%d failed\n",
-								max_cost_cpu);
-		}
-		unlock_device_hotplug();
-
-end:
-		pcpu_pwr = &per_cpu(cpu_power_cost, max_cost_cpu);
-		*pcpu_pwr = 0;
-		if (num_online_managed(cl->cpus) <= cl->max_cpu_request)
-			break;
-	}
-
-	if (num_online_managed(cl->cpus) > cl->max_cpu_request)
-		return -EAGAIN;
-	else
-		return 0;
-}
-
-/*
- * try_hotplug tries to online/offline cores based on the current requirement.
- * It loops through the currently managed CPUs and tries to online/offline
- * them until the max_cpu_request criteria is met.
- */
-static void __ref try_hotplug(struct cluster *data)
-{
-	unsigned int i;
-
-	if (!clusters_inited)
-		return;
-
-	pr_debug("msm_perf: Trying hotplug...%d:%d\n",
-			num_online_managed(data->cpus),	num_online_cpus());
-
-	mutex_lock(&managed_cpus_lock);
-	if (num_online_managed(data->cpus) > data->max_cpu_request) {
-		if (!rm_high_pwr_cost_cpus(data)) {
-			mutex_unlock(&managed_cpus_lock);
-			return;
-		}
-
-		/*
-		 * If power aware offlining fails due to power cost info
-		 * being unavaiable fall back to original implementation
-		 */
-		for (i = num_present_cpus() - 1; i >= 0 &&
-						i < num_present_cpus(); i--) {
-			if (!cpumask_test_cpu(i, data->cpus) ||	!cpu_online(i))
-				continue;
-
-			pr_debug("msm_perf: Offlining CPU%d\n", i);
-			cpumask_set_cpu(i, data->offlined_cpus);
-			lock_device_hotplug();
-			if (device_offline(get_cpu_device(i))) {
-				cpumask_clear_cpu(i, data->offlined_cpus);
-				pr_debug("msm_perf: Offlining CPU%d failed\n",
-									i);
-				unlock_device_hotplug();
-				continue;
-			}
-			unlock_device_hotplug();
-			if (num_online_managed(data->cpus) <=
-							data->max_cpu_request)
-				break;
-		}
-	} else {
-		for_each_cpu(i, data->cpus) {
-			if (cpu_online(i))
-				continue;
-			pr_debug("msm_perf: Onlining CPU%d\n", i);
-			lock_device_hotplug();
-			if (device_online(get_cpu_device(i))) {
-				pr_debug("msm_perf: Onlining CPU%d failed\n",
-									i);
-				unlock_device_hotplug();
-				continue;
-			}
-			unlock_device_hotplug();
-			cpumask_clear_cpu(i, data->offlined_cpus);
-			if (num_online_managed(data->cpus) >=
-							data->max_cpu_request)
-				break;
-		}
-	}
-	mutex_unlock(&managed_cpus_lock);
-}
-
-static void __ref release_cluster_control(struct cpumask *off_cpus)
-{
-	int cpu;
-
-	for_each_cpu(cpu, off_cpus) {
-		pr_debug("msm_perf: Release CPU %d\n", cpu);
-		lock_device_hotplug();
-		if (!device_online(get_cpu_device(cpu)))
-			cpumask_clear_cpu(cpu, off_cpus);
-		unlock_device_hotplug();
-	}
-}
-
-/* Work to evaluate current online CPU status and hotplug CPUs as per need */
-static void check_cluster_status(struct work_struct *work)
-{
-	int i;
-	struct cluster *i_cl;
-
-	for (i = 0; i < num_clusters; i++) {
-		i_cl = managed_clusters[i];
-
-		if (cpumask_empty(i_cl->cpus))
-			continue;
-
-		if (i_cl->max_cpu_request < 0) {
-			if (!cpumask_empty(i_cl->offlined_cpus))
-				release_cluster_control(i_cl->offlined_cpus);
-			continue;
-		}
-
-		if (num_online_managed(i_cl->cpus) !=
-					i_cl->max_cpu_request)
-			try_hotplug(i_cl);
-	}
-}
-
 static int __ref msm_performance_cpu_callback(struct notifier_block *nfb,
 		unsigned long action, void *hcpu)
 {
@@ -2559,43 +2254,6 @@
 		}
 	}
 
-	if (i_cl == NULL)
-		return NOTIFY_OK;
-
-	if (action == CPU_UP_PREPARE || action == CPU_UP_PREPARE_FROZEN) {
-		/*
-		 * Prevent onlining of a managed CPU if max_cpu criteria is
-		 * already satisfied
-		 */
-		if (i_cl->offlined_cpus == NULL)
-			return NOTIFY_OK;
-		if (i_cl->max_cpu_request <=
-					num_online_managed(i_cl->cpus)) {
-			pr_debug("msm_perf: Prevent CPU%d onlining\n", cpu);
-			cpumask_set_cpu(cpu, i_cl->offlined_cpus);
-			return NOTIFY_BAD;
-		}
-		cpumask_clear_cpu(cpu, i_cl->offlined_cpus);
-
-	} else if (action == CPU_DEAD) {
-		if (i_cl->offlined_cpus == NULL)
-			return NOTIFY_OK;
-		if (cpumask_test_cpu(cpu, i_cl->offlined_cpus))
-			return NOTIFY_OK;
-		/*
-		 * Schedule a re-evaluation to check if any more CPUs can be
-		 * brought online to meet the max_cpu_request requirement. This
-		 * work is delayed to account for CPU hotplug latencies
-		 */
-		if (schedule_delayed_work(&evaluate_hotplug_work, 0)) {
-			trace_reevaluate_hotplug(cpumask_bits(i_cl->cpus)[0],
-							i_cl->max_cpu_request);
-			pr_debug("msm_perf: Re-evaluation scheduled %d\n", cpu);
-		} else {
-			pr_debug("msm_perf: Work scheduling failed %d\n", cpu);
-		}
-	}
-
 	return NOTIFY_OK;
 }
 
@@ -2626,13 +2284,7 @@
 			ret = -ENOMEM;
 			goto error;
 		}
-		if (!alloc_cpumask_var(&managed_clusters[i]->offlined_cpus,
-		     GFP_KERNEL)) {
-			ret = -ENOMEM;
-			goto error;
-		}
 
-		managed_clusters[i]->max_cpu_request = -1;
 		managed_clusters[i]->single_enter_load = DEF_SINGLE_ENT;
 		managed_clusters[i]->single_exit_load = DEF_SINGLE_EX;
 		managed_clusters[i]->single_enter_cycles
@@ -2669,7 +2321,6 @@
 			perf_cl_peak_mod_exit_timer;
 	}
 
-	INIT_DELAYED_WORK(&evaluate_hotplug_work, check_cluster_status);
 	mutex_init(&managed_cpus_lock);
 
 	ip_evts = kcalloc(1, sizeof(struct input_events), GFP_KERNEL);
@@ -2707,8 +2358,6 @@
 	for (i = 0; i < num_clusters; i++) {
 		if (!managed_clusters[i])
 			break;
-		if (managed_clusters[i]->offlined_cpus)
-			free_cpumask_var(managed_clusters[i]->offlined_cpus);
 		if (managed_clusters[i]->cpus)
 			free_cpumask_var(managed_clusters[i]->cpus);
 		kfree(managed_clusters[i]);
diff --git a/drivers/soc/qcom/peripheral-loader.c b/drivers/soc/qcom/peripheral-loader.c
index 91c9441..9d22925 100644
--- a/drivers/soc/qcom/peripheral-loader.c
+++ b/drivers/soc/qcom/peripheral-loader.c
@@ -55,7 +55,10 @@
 #endif
 
 #define PIL_NUM_DESC		10
+#define NUM_OF_ENCRYPTED_KEY	3
+#define MAX_LEN 96
 static void __iomem *pil_info_base;
+static void __iomem *pil_minidump_base;
 
 /**
  * proxy_timeout - Override for proxy vote timeouts
@@ -78,6 +81,18 @@
 };
 
 /**
+ * struct boot_minidump_smem_region - Representation of SMEM TOC
+ * @region_name: Name of modem segment to be dumped
+ * @region_base_address: Where segment start from
+ * @region_size: Size of segment to be dumped
+ */
+struct boot_minidump_smem_region {
+	char region_name[16];
+	u64 region_base_address;
+	u64 region_size;
+};
+
+/**
  * struct pil_seg - memory map representing one segment
  * @next: points to next seg mentor NULL if last segment
  * @paddr: physical start address of segment
@@ -131,11 +146,67 @@
 	phys_addr_t region_end;
 	void *region;
 	struct pil_image_info __iomem *info;
+	struct md_ssr_ss_info __iomem *minidump;
+	int minidump_id;
 	int id;
 	int unvoted_flag;
 	size_t region_size;
 };
 
+static int pil_do_minidump(struct pil_desc *desc, void *ramdump_dev)
+{
+	struct boot_minidump_smem_region __iomem *region_info;
+	struct ramdump_segment *ramdump_segs, *s;
+	struct pil_priv *priv = desc->priv;
+	void __iomem *subsys_smem_base;
+	void __iomem *offset;
+	int ss_mdump_seg_cnt;
+	int ret, i;
+
+	memcpy(&offset, &priv->minidump, sizeof(priv->minidump));
+	offset = offset + sizeof(priv->minidump->md_ss_smem_regions_baseptr);
+	/* There are 3 encryption keys which also need to be dumped */
+	ss_mdump_seg_cnt = readb_relaxed(offset) +
+				NUM_OF_ENCRYPTED_KEY;
+
+	subsys_smem_base = ioremap(__raw_readl(priv->minidump),
+				   ss_mdump_seg_cnt * sizeof(*region_info));
+	region_info =
+		(struct boot_minidump_smem_region __iomem *)subsys_smem_base;
+	ramdump_segs = kcalloc(ss_mdump_seg_cnt,
+			       sizeof(*ramdump_segs), GFP_KERNEL);
+	if (!ramdump_segs)
+		return -ENOMEM;
+
+	if (desc->subsys_vmid > 0)
+		ret = pil_assign_mem_to_linux(desc, priv->region_start,
+			(priv->region_end - priv->region_start));
+
+	s = ramdump_segs;
+	for (i = 0; i < ss_mdump_seg_cnt; i++) {
+		memcpy(&offset, &region_info, sizeof(region_info));
+		memcpy(&s->name, &region_info, sizeof(region_info));
+		offset = offset + sizeof(region_info->region_name);
+		s->address = __raw_readl(offset);
+		offset = offset + sizeof(region_info->region_base_address);
+		s->size = __raw_readl(offset);
+		s++;
+		region_info++;
+	}
+	ret = do_minidump(ramdump_dev, ramdump_segs, ss_mdump_seg_cnt);
+	kfree(ramdump_segs);
+	if (ret)
+		pil_err(desc, "%s: Ramdump collection failed for subsys %s rc:%d\n",
+			__func__, desc->name, ret);
+	writel_relaxed(0, &priv->minidump->md_ss_smem_regions_baseptr);
+	writeb_relaxed(1, &priv->minidump->md_ss_ssr_cause);
+
+	if (desc->subsys_vmid > 0)
+		ret = pil_assign_mem_to_subsys(desc, priv->region_start,
+			(priv->region_end - priv->region_start));
+	return ret;
+}
+
 /**
  * pil_do_ramdump() - Ramdump an image
  * @desc: descriptor from pil_desc_init()
@@ -151,6 +222,9 @@
 	int count = 0, ret;
 	struct ramdump_segment *ramdump_segs, *s;
 
+	if (priv->minidump && (__raw_readl(priv->minidump) > 0))
+		return pil_do_minidump(desc, ramdump_dev);
+
 	list_for_each_entry(seg, &priv->segs, list)
 		count++;
 
@@ -763,6 +837,23 @@
 	return 0;
 }
 
+static int pil_notify_aop(struct pil_desc *desc, char *status)
+{
+	struct qmp_pkt pkt;
+	char mbox_msg[MAX_LEN];
+
+	if (!desc->signal_aop)
+		return 0;
+
+	snprintf(mbox_msg, MAX_LEN,
+		"{class: image, res: load_state, name: %s, val: %s}",
+		desc->name, status);
+	pkt.size = MAX_LEN;
+	pkt.data = mbox_msg;
+
+	return mbox_send_message(desc->mbox, &pkt);
+}
+
 /* Synchronize request_firmware() with suspend */
 static DECLARE_RWSEM(pil_pm_rwsem);
 
@@ -784,6 +875,12 @@
 	bool mem_protect = false;
 	bool hyp_assign = false;
 
+	ret = pil_notify_aop(desc, "on");
+	if (ret < 0) {
+		pil_err(desc, "Failed to send ON message to AOP rc:%d\n", ret);
+		return ret;
+	}
+
 	if (desc->shutdown_fail)
 		pil_err(desc, "Subsystem shutdown failed previously!\n");
 
@@ -942,6 +1039,7 @@
 			priv->region = NULL;
 		}
 		pil_release_mmap(desc);
+		pil_notify_aop(desc, "off");
 	}
 	return ret;
 }
@@ -953,6 +1051,7 @@
  */
 void pil_shutdown(struct pil_desc *desc)
 {
+	int ret;
 	struct pil_priv *priv = desc->priv;
 
 	if (desc->ops->shutdown) {
@@ -970,6 +1069,9 @@
 		pil_proxy_unvote(desc, 1);
 	else
 		flush_delayed_work(&priv->proxy);
+	ret = pil_notify_aop(desc, "off");
+	if (ret < 0)
+		pr_warn("pil: failed to send OFF message to AOP rc:%d\n", ret);
 	desc->modem_ssr = true;
 }
 EXPORT_SYMBOL(pil_shutdown);
@@ -1011,9 +1113,10 @@
 int pil_desc_init(struct pil_desc *desc)
 {
 	struct pil_priv *priv;
-	int ret;
 	void __iomem *addr;
+	int ret, ss_imem_offset_mdump;
 	char buf[sizeof(priv->info->name)];
+	struct device_node *ofnode = desc->dev->of_node;
 
 	if (WARN(desc->ops->proxy_unvote && !desc->ops->proxy_vote,
 				"Invalid proxy voting. Ignoring\n"))
@@ -1036,6 +1139,22 @@
 		strlcpy(buf, desc->name, sizeof(buf));
 		__iowrite32_copy(priv->info->name, buf, sizeof(buf) / 4);
 	}
+	if (of_property_read_u32(ofnode, "qcom,minidump-id",
+		&priv->minidump_id))
+		pr_debug("minidump-id not found for %s\n", desc->name);
+	else {
+		ss_imem_offset_mdump =
+			sizeof(struct md_ssr_ss_info) * priv->minidump_id;
+		if (pil_minidump_base) {
+			/* Add 0x4 to get start of struct md_ssr_ss_info base
+			 * from struct md_ssr_toc for any subsystem,
+			 * struct md_ssr_ss_info is actually the pointer
+			 * of ToC in smem for any subsystem.
+			 */
+			addr = pil_minidump_base + ss_imem_offset_mdump + 0x4;
+			priv->minidump = (struct md_ssr_ss_info __iomem *)addr;
+		}
+	}
 
 	ret = pil_parse_devicetree(desc);
 	if (ret)
@@ -1144,6 +1263,20 @@
 	for (i = 0; i < resource_size(&res)/sizeof(u32); i++)
 		writel_relaxed(0, pil_info_base + (i * sizeof(u32)));
 
+	np = of_find_compatible_node(NULL, NULL, "qcom,msm-imem-minidump");
+	if (!np) {
+		pr_warn("pil: failed to find qcom,msm-imem-minidump node\n");
+		goto out;
+	} else {
+		pil_minidump_base = of_iomap(np, 0);
+		if (!pil_minidump_base) {
+			pr_err("unable to map pil minidump imem offset\n");
+			goto out;
+		}
+	}
+	for (i = 0; i < sizeof(struct md_ssr_toc)/sizeof(u32); i++)
+		writel_relaxed(0, pil_minidump_base + (i * sizeof(u32)));
+	writel_relaxed(1, pil_minidump_base);
 out:
 	return register_pm_notifier(&pil_pm_notifier);
 }
@@ -1154,6 +1287,8 @@
 	unregister_pm_notifier(&pil_pm_notifier);
 	if (pil_info_base)
 		iounmap(pil_info_base);
+	if (pil_minidump_base)
+		iounmap(pil_minidump_base);
 }
 module_exit(msm_pil_exit);
 
diff --git a/drivers/soc/qcom/peripheral-loader.h b/drivers/soc/qcom/peripheral-loader.h
index af7249b..f09adf5 100644
--- a/drivers/soc/qcom/peripheral-loader.h
+++ b/drivers/soc/qcom/peripheral-loader.h
@@ -12,6 +12,9 @@
 #ifndef __MSM_PERIPHERAL_LOADER_H
 #define __MSM_PERIPHERAL_LOADER_H
 
+#include <linux/mailbox_client.h>
+#include <linux/mailbox/qmp.h>
+
 struct device;
 struct module;
 struct pil_priv;
@@ -57,6 +60,9 @@
 	bool modem_ssr;
 	bool clear_fw_region;
 	u32 subsys_vmid;
+	bool signal_aop;
+	struct mbox_client cl;
+	struct mbox_chan *mbox;
 };
 
 /**
@@ -71,6 +77,34 @@
 	__le32 size;
 } __attribute__((__packed__));
 
+#define MAX_NUM_OF_SS 3
+
+/**
+ * struct md_ssr_ss_info - Info in imem about smem ToC
+ * @md_ss_smem_regions_baseptr: Start physical address of SMEM TOC
+ * @md_ss_num_of_regions: number of segments that need to be dumped
+ * @md_ss_encryption_status: status of encryption of segments
+ * @md_ss_ssr_cause: ssr cause enum
+ */
+struct md_ssr_ss_info {
+	u32 md_ss_smem_regions_baseptr;
+	u8 md_ss_num_of_regions;
+	u8 md_ss_encryption_status;
+	u8 md_ss_ssr_cause;
+	u8 reserved;
+};
+
+/**
+ * struct md_ssr_toc - Wrapper of struct md_ssr_ss_info
+ * @md_ssr_toc_init: flag to indicate to MSS SW about imem init done
+ * @md_ssr_ss: Instance of struct md_ssr_ss_info for a subsystem
+ */
+struct md_ssr_toc /* Shared IMEM ToC struct */
+{
+	u32 md_ssr_toc_init;
+	struct md_ssr_ss_info	md_ssr_ss[MAX_NUM_OF_SS];
+};
+
 /**
  * struct pil_reset_ops - PIL operations
  * @init_image: prepare an image for authentication
diff --git a/drivers/soc/qcom/pil-msa.c b/drivers/soc/qcom/pil-msa.c
index 20b9769..ec3063e 100644
--- a/drivers/soc/qcom/pil-msa.c
+++ b/drivers/soc/qcom/pil-msa.c
@@ -77,9 +77,8 @@
 
 #define MSS_MAGIC			0XAABADEAD
 
-#define MSS_PDC_OFFSET			8
-#define MSS_PDC_MASK			BIT(MSS_PDC_OFFSET)
-
+/* Timeout value for MBA boot when minidump is enabled */
+#define MBA_ENCRYPTION_TIMEOUT	3000
 enum scm_cmd {
 	PAS_MEM_SETUP_CMD = 2,
 };
@@ -212,13 +211,14 @@
 static void pil_mss_pdc_sync(struct q6v5_data *drv, bool pdc_sync)
 {
 	u32 val = 0;
+	u32 mss_pdc_mask = BIT(drv->mss_pdc_offset);
 
 	if (drv->pdc_sync) {
 		val = readl_relaxed(drv->pdc_sync);
 		if (pdc_sync)
-			val |= MSS_PDC_MASK;
+			val |= mss_pdc_mask;
 		else
-			val &= ~MSS_PDC_MASK;
+			val &= ~mss_pdc_mask;
 		writel_relaxed(val, drv->pdc_sync);
 		/* Ensure PDC is written before next write */
 		wmb();
@@ -267,7 +267,7 @@
 	return ret;
 }
 
-static int pil_mss_assert_resets(struct q6v5_data *drv)
+int pil_mss_assert_resets(struct q6v5_data *drv)
 {
 	int ret = 0;
 
@@ -278,7 +278,7 @@
 	return ret;
 }
 
-static int pil_mss_deassert_resets(struct q6v5_data *drv)
+int pil_mss_deassert_resets(struct q6v5_data *drv)
 {
 	int ret = 0;
 
@@ -298,7 +298,12 @@
 	struct device *dev = drv->desc.dev;
 	int ret;
 	u32 status;
-	u64 val = is_timeout_disabled() ? 0 : pbl_mba_boot_timeout_ms * 1000;
+	u64 val;
+
+	if (of_property_read_bool(dev->of_node, "qcom,minidump-id"))
+		pbl_mba_boot_timeout_ms = MBA_ENCRYPTION_TIMEOUT;
+
+	val = is_timeout_disabled() ? 0 : pbl_mba_boot_timeout_ms * 1000;
 
 	/* Wait for PBL completion. */
 	ret = readl_poll_timeout(drv->rmb_base + RMB_PBL_STATUS, status,
@@ -610,7 +615,7 @@
 	char *fw_name_p;
 	void *mba_dp_virt;
 	dma_addr_t mba_dp_phys, mba_dp_phys_end;
-	int ret, count;
+	int ret;
 	const u8 *data;
 	struct device *dma_dev = md->mba_mem_dev_fixed ?: &md->mba_mem_dev;
 
@@ -676,10 +681,9 @@
 					&mba_dp_phys, &mba_dp_phys_end);
 
 	/* Load the MBA image into memory */
-	count = fw->size;
-	if (count <= SZ_1M) {
+	if (fw->size <= SZ_1M) {
 		/* Ensures memcpy is done for max 1MB fw size */
-		memcpy(mba_dp_virt, data, count);
+		memcpy(mba_dp_virt, data, fw->size);
 	} else {
 		dev_err(pil->dev, "%s fw image loading into memory is failed due to fw size overflow\n",
 			__func__);
diff --git a/drivers/soc/qcom/pil-msa.h b/drivers/soc/qcom/pil-msa.h
index 1789ba3..7a6a3cc 100644
--- a/drivers/soc/qcom/pil-msa.h
+++ b/drivers/soc/qcom/pil-msa.h
@@ -46,4 +46,6 @@
 int pil_mss_shutdown(struct pil_desc *pil);
 int pil_mss_deinit_image(struct pil_desc *pil);
 int __pil_mss_deinit_image(struct pil_desc *pil, bool err_path);
+int pil_mss_assert_resets(struct q6v5_data *drv);
+int pil_mss_deassert_resets(struct q6v5_data *drv);
 #endif
diff --git a/drivers/soc/qcom/pil-q6v5-mss.c b/drivers/soc/qcom/pil-q6v5-mss.c
index 7984dfe..cf5f7e4 100644
--- a/drivers/soc/qcom/pil-q6v5-mss.c
+++ b/drivers/soc/qcom/pil-q6v5-mss.c
@@ -217,6 +217,22 @@
 	drv->subsys_desc.wdog_bite_handler = modem_wdog_bite_intr_handler;
 
 	drv->q6->desc.modem_ssr = false;
+	drv->q6->desc.signal_aop = of_property_read_bool(pdev->dev.of_node,
+						"qcom,signal-aop");
+	if (drv->q6->desc.signal_aop) {
+		drv->q6->desc.cl.dev = &pdev->dev;
+		drv->q6->desc.cl.tx_block = true;
+		drv->q6->desc.cl.tx_tout = 1000;
+		drv->q6->desc.cl.knows_txdone = false;
+		drv->q6->desc.mbox = mbox_request_channel(&drv->q6->desc.cl, 0);
+		if (IS_ERR(drv->q6->desc.mbox)) {
+			ret = PTR_ERR(drv->q6->desc.mbox);
+			dev_err(&pdev->dev, "Failed to get mailbox channel %pK %d\n",
+				drv->q6->desc.mbox, ret);
+			goto err_subsys;
+		}
+	}
+
 	drv->subsys = subsys_register(&drv->subsys_desc);
 	if (IS_ERR(drv->subsys)) {
 		ret = PTR_ERR(drv->subsys);
@@ -293,6 +309,13 @@
 	if (res) {
 		q6->pdc_sync = devm_ioremap(&pdev->dev,
 						res->start, resource_size(res));
+		if (of_property_read_u32(pdev->dev.of_node,
+			"qcom,mss_pdc_offset", &q6->mss_pdc_offset)) {
+			dev_err(&pdev->dev,
+				"Offset for MSS PDC not specified\n");
+			return -EINVAL;
+		}
+
 	}
 
 	q6->alt_reset = NULL;
diff --git a/drivers/soc/qcom/pil-q6v5.c b/drivers/soc/qcom/pil-q6v5.c
index 49dd0be..6d6b9f7 100644
--- a/drivers/soc/qcom/pil-q6v5.c
+++ b/drivers/soc/qcom/pil-q6v5.c
@@ -23,6 +23,7 @@
 #include <trace/events/trace_msm_pil_event.h>
 
 #include "peripheral-loader.h"
+#include "pil-msa.h"
 #include "pil-q6v5.h"
 
 /* QDSP6SS Register Offsets */
@@ -83,10 +84,10 @@
 /* QDSP6v65 parameters */
 #define QDSP6SS_BOOT_CORE_START		(0x400)
 #define QDSP6SS_BOOT_CMD		(0x404)
-#define QDSP6SS_BOOT_STATUS		(0x408)
+#define MSS_STATUS			(0x40)
 #define QDSP6SS_SLEEP			(0x3C)
 #define SLEEP_CHECK_MAX_LOOPS		(200)
-#define BOOT_FSM_TIMEOUT		(10)
+#define BOOT_FSM_TIMEOUT		(100)
 
 #define QDSP6SS_ACC_OVERRIDE_VAL	0x20
 
@@ -384,7 +385,7 @@
 {
 	struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
 	u32 val, count;
-	unsigned long timeout;
+	int ret;
 
 	val = readl_relaxed(drv->reg_base + QDSP6SS_SLEEP);
 	val |= 0x1;
@@ -409,15 +410,19 @@
 	writel_relaxed(1, drv->reg_base + QDSP6SS_BOOT_CMD);
 
 	/* Wait for boot FSM to complete */
-	timeout = jiffies + usecs_to_jiffies(BOOT_FSM_TIMEOUT);
-	while (time_before(jiffies, timeout)) {
-		val = readl_relaxed(drv->reg_base + QDSP6SS_BOOT_STATUS);
-		if (val & BIT(0))
-			return 0;
+	ret = readl_poll_timeout(drv->rmb_base + MSS_STATUS, val,
+			(val & BIT(1)) != 0, 10, BOOT_FSM_TIMEOUT);
+
+	if (ret) {
+		dev_err(drv->desc.dev, "Boot FSM failed to complete.\n");
+		/* Reset the modem so that boot FSM is in reset state */
+		pil_mss_assert_resets(drv);
+		/* Wait 6 32kHz sleep cycles for reset */
+		udelay(200);
+		pil_mss_deassert_resets(drv);
 	}
 
-	dev_err(drv->desc.dev, "Boot FSM failed to complete.\n");
-	return -ETIMEDOUT;
+	return ret;
 }
 
 static int __pil_q6v55_reset(struct pil_desc *pil)
diff --git a/drivers/soc/qcom/pil-q6v5.h b/drivers/soc/qcom/pil-q6v5.h
index 9b4c811..4961b1f 100644
--- a/drivers/soc/qcom/pil-q6v5.h
+++ b/drivers/soc/qcom/pil-q6v5.h
@@ -74,6 +74,7 @@
 	bool restart_reg_sec;
 	bool override_acc;
 	int override_acc_1;
+	int mss_pdc_offset;
 	bool ahb_clk_vote;
 	bool mx_spike_wa;
 };
diff --git a/drivers/soc/qcom/qdsp6v2/Makefile b/drivers/soc/qcom/qdsp6v2/Makefile
index 9fdd63a..93bab3d 100644
--- a/drivers/soc/qcom/qdsp6v2/Makefile
+++ b/drivers/soc/qcom/qdsp6v2/Makefile
@@ -1,8 +1 @@
-obj-$(CONFIG_MSM_QDSP6_APRV2_GLINK) += apr.o apr_v2.o apr_tal_glink.o
-obj-$(CONFIG_MSM_QDSP6_APRV3_GLINK) += apr.o apr_v3.o apr_tal_glink.o
-obj-$(CONFIG_SND_SOC_MSM_QDSP6V2_INTF) += msm_audio_ion.o
-obj-$(CONFIG_MSM_ADSP_LOADER) += adsp-loader.o
-obj-$(CONFIG_MSM_QDSP6_SSR) += audio_ssr.o
-obj-$(CONFIG_MSM_QDSP6_PDR) += audio_pdr.o
-obj-$(CONFIG_MSM_QDSP6_NOTIFIER) += audio_notifier.o
 obj-$(CONFIG_MSM_CDSP_LOADER) += cdsp-loader.o
diff --git a/drivers/soc/qcom/qdsp6v2/adsp-loader.c b/drivers/soc/qcom/qdsp6v2/adsp-loader.c
deleted file mode 100644
index d90267e..0000000
--- a/drivers/soc/qcom/qdsp6v2/adsp-loader.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (c) 2012-2014, 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/delay.h>
-#include <linux/platform_device.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/of_device.h>
-#include <linux/sysfs.h>
-#include <linux/workqueue.h>
-
-#include <soc/qcom/subsystem_restart.h>
-
-#define Q6_PIL_GET_DELAY_MS 100
-#define BOOT_CMD 1
-#define IMAGE_UNLOAD_CMD 0
-
-static ssize_t adsp_boot_store(struct kobject *kobj,
-	struct kobj_attribute *attr,
-	const char *buf, size_t count);
-
-struct adsp_loader_private {
-	void *pil_h;
-	struct kobject *boot_adsp_obj;
-	struct attribute_group *attr_group;
-};
-
-static struct kobj_attribute adsp_boot_attribute =
-	__ATTR(boot, 0220, NULL, adsp_boot_store);
-
-static struct attribute *attrs[] = {
-	&adsp_boot_attribute.attr,
-	NULL,
-};
-
-static struct work_struct adsp_ldr_work;
-static struct platform_device *adsp_private;
-static void adsp_loader_unload(struct platform_device *pdev);
-
-static void adsp_load_fw(struct work_struct *adsp_ldr_work)
-{
-	struct platform_device *pdev = adsp_private;
-	struct adsp_loader_private *priv = NULL;
-
-	const char *adsp_dt = "qcom,adsp-state";
-	int rc = 0;
-	u32 adsp_state;
-	const char *img_name;
-
-	if (!pdev) {
-		dev_err(&pdev->dev, "%s: Platform device null\n", __func__);
-		goto fail;
-	}
-
-	if (!pdev->dev.of_node) {
-		dev_err(&pdev->dev,
-			"%s: Device tree information missing\n", __func__);
-		goto fail;
-	}
-
-	rc = of_property_read_u32(pdev->dev.of_node, adsp_dt, &adsp_state);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: ADSP state = %x\n", __func__, adsp_state);
-		goto fail;
-	}
-
-	rc = of_property_read_string(pdev->dev.of_node,
-					"qcom,proc-img-to-load",
-					&img_name);
-
-	if (rc) {
-		dev_dbg(&pdev->dev,
-			"%s: loading default image ADSP\n", __func__);
-		goto load_adsp;
-	}
-	if (!strcmp(img_name, "modem")) {
-		/* adsp_state always returns "0". So load modem image based on
-		 * apr_modem_state to prevent loading of image twice
-		 */
-		adsp_state = apr_get_modem_state();
-		if (adsp_state == APR_SUBSYS_DOWN) {
-			priv = platform_get_drvdata(pdev);
-			if (!priv) {
-				dev_err(&pdev->dev,
-				" %s: Private data get failed\n", __func__);
-				goto fail;
-			}
-
-			priv->pil_h = subsystem_get("modem");
-			if (IS_ERR(priv->pil_h)) {
-				dev_err(&pdev->dev, "%s: pil get failed,\n",
-					__func__);
-				goto fail;
-			}
-
-			/* Set the state of the ADSP in APR driver */
-			apr_set_modem_state(APR_SUBSYS_LOADED);
-		} else if (adsp_state == APR_SUBSYS_LOADED) {
-			dev_dbg(&pdev->dev,
-			"%s: MDSP state = %x\n", __func__, adsp_state);
-		}
-
-		dev_dbg(&pdev->dev, "%s: Q6/MDSP image is loaded\n", __func__);
-		return;
-	}
-load_adsp:
-	{
-		adsp_state = apr_get_q6_state();
-		if (adsp_state == APR_SUBSYS_DOWN) {
-			priv = platform_get_drvdata(pdev);
-			if (!priv) {
-				dev_err(&pdev->dev,
-				" %s: Private data get failed\n", __func__);
-				goto fail;
-			}
-
-			priv->pil_h = subsystem_get("adsp");
-			if (IS_ERR(priv->pil_h)) {
-				dev_err(&pdev->dev, "%s: pil get failed,\n",
-					__func__);
-				goto fail;
-			}
-
-			/* Set the state of the ADSP in APR driver */
-			apr_set_q6_state(APR_SUBSYS_LOADED);
-		} else if (adsp_state == APR_SUBSYS_LOADED) {
-			dev_dbg(&pdev->dev,
-			"%s: ADSP state = %x\n", __func__, adsp_state);
-		}
-
-		dev_dbg(&pdev->dev, "%s: Q6/ADSP image is loaded\n", __func__);
-		return;
-	}
-fail:
-	dev_err(&pdev->dev, "%s: Q6 image loading failed\n", __func__);
-}
-
-static void adsp_loader_do(struct platform_device *pdev)
-{
-	schedule_work(&adsp_ldr_work);
-}
-
-static ssize_t adsp_boot_store(struct kobject *kobj,
-	struct kobj_attribute *attr,
-	const char *buf,
-	size_t count)
-{
-	int boot = 0;
-
-	if (sscanf(buf, "%du", &boot) != 1) {
-		pr_err("%s: failed to read boot info from string\n", __func__);
-		return -EINVAL;
-	}
-
-	if (boot == BOOT_CMD) {
-		pr_debug("%s: going to call adsp_loader_do\n", __func__);
-		adsp_loader_do(adsp_private);
-	} else if (boot == IMAGE_UNLOAD_CMD) {
-		pr_debug("%s: going to call adsp_unloader\n", __func__);
-		adsp_loader_unload(adsp_private);
-	}
-	return count;
-}
-
-static void adsp_loader_unload(struct platform_device *pdev)
-{
-	struct adsp_loader_private *priv = NULL;
-
-	priv = platform_get_drvdata(pdev);
-
-	if (!priv)
-		return;
-
-	if (priv->pil_h) {
-		dev_dbg(&pdev->dev, "%s: calling subsystem put\n", __func__);
-		subsystem_put(priv->pil_h);
-		priv->pil_h = NULL;
-	}
-}
-
-static int adsp_loader_init_sysfs(struct platform_device *pdev)
-{
-	int ret = -EINVAL;
-	struct adsp_loader_private *priv = NULL;
-
-	adsp_private = NULL;
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		ret = -ENOMEM;
-		return ret;
-	}
-
-	platform_set_drvdata(pdev, priv);
-
-	priv->pil_h = NULL;
-	priv->boot_adsp_obj = NULL;
-	priv->attr_group = devm_kzalloc(&pdev->dev,
-				sizeof(*(priv->attr_group)),
-				GFP_KERNEL);
-	if (!priv->attr_group) {
-		ret = -ENOMEM;
-		goto error_return;
-	}
-
-	priv->attr_group->attrs = attrs;
-
-	priv->boot_adsp_obj = kobject_create_and_add("boot_adsp", kernel_kobj);
-	if (!priv->boot_adsp_obj) {
-		dev_err(&pdev->dev, "%s: sysfs create and add failed\n",
-						__func__);
-		ret = -ENOMEM;
-		goto error_return;
-	}
-
-	ret = sysfs_create_group(priv->boot_adsp_obj, priv->attr_group);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: sysfs create group failed %d\n",
-							__func__, ret);
-		goto error_return;
-	}
-
-	adsp_private = pdev;
-
-	return 0;
-
-error_return:
-
-	if (priv->boot_adsp_obj) {
-		kobject_del(priv->boot_adsp_obj);
-		priv->boot_adsp_obj = NULL;
-	}
-
-	return ret;
-}
-
-static int adsp_loader_remove(struct platform_device *pdev)
-{
-	struct adsp_loader_private *priv = NULL;
-
-	priv = platform_get_drvdata(pdev);
-
-	if (!priv)
-		return 0;
-
-	if (priv->pil_h) {
-		subsystem_put(priv->pil_h);
-		priv->pil_h = NULL;
-	}
-
-	if (priv->boot_adsp_obj) {
-		sysfs_remove_group(priv->boot_adsp_obj, priv->attr_group);
-		kobject_del(priv->boot_adsp_obj);
-		priv->boot_adsp_obj = NULL;
-	}
-
-	return 0;
-}
-
-static int adsp_loader_probe(struct platform_device *pdev)
-{
-	int ret = adsp_loader_init_sysfs(pdev);
-
-	if (ret != 0) {
-		dev_err(&pdev->dev, "%s: Error in initing sysfs\n", __func__);
-		return ret;
-	}
-
-	INIT_WORK(&adsp_ldr_work, adsp_load_fw);
-
-	return 0;
-}
-
-static const struct of_device_id adsp_loader_dt_match[] = {
-	{ .compatible = "qcom,adsp-loader" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, adsp_loader_dt_match);
-
-static struct platform_driver adsp_loader_driver = {
-	.driver = {
-		.name = "adsp-loader",
-		.owner = THIS_MODULE,
-		.of_match_table = adsp_loader_dt_match,
-	},
-	.probe = adsp_loader_probe,
-	.remove = adsp_loader_remove,
-};
-
-static int __init adsp_loader_init(void)
-{
-	return platform_driver_register(&adsp_loader_driver);
-}
-module_init(adsp_loader_init);
-
-static void __exit adsp_loader_exit(void)
-{
-	platform_driver_unregister(&adsp_loader_driver);
-}
-module_exit(adsp_loader_exit);
-
-MODULE_DESCRIPTION("ADSP Loader module");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/soc/qcom/qdsp6v2/apr.c b/drivers/soc/qcom/qdsp6v2/apr.c
deleted file mode 100644
index de89b8f..0000000
--- a/drivers/soc/qcom/qdsp6v2/apr.c
+++ /dev/null
@@ -1,977 +0,0 @@
-/* Copyright (c) 2010-2014, 2016-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/spinlock.h>
-#include <linux/list.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/delay.h>
-#include <linux/debugfs.h>
-#include <linux/platform_device.h>
-#include <linux/sysfs.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <soc/qcom/subsystem_restart.h>
-#include <soc/qcom/scm.h>
-#include <sound/apr_audio-v2.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/qdsp6v2/apr_tal.h>
-#include <linux/qdsp6v2/dsp_debug.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include <linux/ipc_logging.h>
-
-#define APR_PKT_IPC_LOG_PAGE_CNT 2
-
-static struct apr_q6 q6;
-static struct apr_client client[APR_DEST_MAX][APR_CLIENT_MAX];
-static void *apr_pkt_ctx;
-static wait_queue_head_t dsp_wait;
-static wait_queue_head_t modem_wait;
-static bool is_modem_up;
-static bool is_initial_boot;
-/* Subsystem restart: QDSP6 data, functions */
-static struct workqueue_struct *apr_reset_workqueue;
-static void apr_reset_deregister(struct work_struct *work);
-static void dispatch_event(unsigned long code, uint16_t proc);
-struct apr_reset_work {
-	void *handle;
-	struct work_struct work;
-};
-
-static bool apr_cf_debug;
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_apr_debug;
-static ssize_t apr_debug_write(struct file *filp, const char __user *ubuf,
-			       size_t cnt, loff_t *ppos)
-{
-	char cmd;
-
-	if (copy_from_user(&cmd, ubuf, 1))
-		return -EFAULT;
-
-	apr_cf_debug = (cmd == '1') ? true : false;
-
-	return cnt;
-}
-
-static const struct file_operations apr_debug_ops = {
-	.write = apr_debug_write,
-};
-#endif
-
-#define APR_PKT_INFO(x...) \
-do { \
-	if (apr_pkt_ctx) \
-		ipc_log_string(apr_pkt_ctx, "<APR>: "x); \
-} while (0)
-
-
-struct apr_svc_table {
-	char name[64];
-	int idx;
-	int id;
-	int client_id;
-};
-
-static const struct apr_svc_table svc_tbl_qdsp6[] = {
-	{
-		.name = "AFE",
-		.idx = 0,
-		.id = APR_SVC_AFE,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "ASM",
-		.idx = 1,
-		.id = APR_SVC_ASM,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "ADM",
-		.idx = 2,
-		.id = APR_SVC_ADM,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "CORE",
-		.idx = 3,
-		.id = APR_SVC_ADSP_CORE,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "TEST",
-		.idx = 4,
-		.id = APR_SVC_TEST_CLIENT,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "MVM",
-		.idx = 5,
-		.id = APR_SVC_ADSP_MVM,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "CVS",
-		.idx = 6,
-		.id = APR_SVC_ADSP_CVS,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "CVP",
-		.idx = 7,
-		.id = APR_SVC_ADSP_CVP,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "USM",
-		.idx = 8,
-		.id = APR_SVC_USM,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-	{
-		.name = "VIDC",
-		.idx = 9,
-		.id = APR_SVC_VIDC,
-	},
-	{
-		.name = "LSM",
-		.idx = 10,
-		.id = APR_SVC_LSM,
-		.client_id = APR_CLIENT_AUDIO,
-	},
-};
-
-static struct apr_svc_table svc_tbl_voice[] = {
-	{
-		.name = "VSM",
-		.idx = 0,
-		.id = APR_SVC_VSM,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "VPM",
-		.idx = 1,
-		.id = APR_SVC_VPM,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "MVS",
-		.idx = 2,
-		.id = APR_SVC_MVS,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "MVM",
-		.idx = 3,
-		.id = APR_SVC_MVM,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "CVS",
-		.idx = 4,
-		.id = APR_SVC_CVS,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "CVP",
-		.idx = 5,
-		.id = APR_SVC_CVP,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "SRD",
-		.idx = 6,
-		.id = APR_SVC_SRD,
-		.client_id = APR_CLIENT_VOICE,
-	},
-	{
-		.name = "TEST",
-		.idx = 7,
-		.id = APR_SVC_TEST_CLIENT,
-		.client_id = APR_CLIENT_VOICE,
-	},
-};
-
-enum apr_subsys_state apr_get_modem_state(void)
-{
-	return atomic_read(&q6.modem_state);
-}
-
-void apr_set_modem_state(enum apr_subsys_state state)
-{
-	atomic_set(&q6.modem_state, state);
-}
-
-enum apr_subsys_state apr_cmpxchg_modem_state(enum apr_subsys_state prev,
-					      enum apr_subsys_state new)
-{
-	return atomic_cmpxchg(&q6.modem_state, prev, new);
-}
-
-static void apr_modem_down(unsigned long opcode)
-{
-	apr_set_modem_state(APR_SUBSYS_DOWN);
-	dispatch_event(opcode, APR_DEST_MODEM);
-}
-
-static void apr_modem_up(void)
-{
-	if (apr_cmpxchg_modem_state(APR_SUBSYS_DOWN, APR_SUBSYS_UP) ==
-							APR_SUBSYS_DOWN)
-		wake_up(&modem_wait);
-	is_modem_up = 1;
-}
-
-enum apr_subsys_state apr_get_q6_state(void)
-{
-	return atomic_read(&q6.q6_state);
-}
-EXPORT_SYMBOL(apr_get_q6_state);
-
-int apr_set_q6_state(enum apr_subsys_state state)
-{
-	pr_debug("%s: setting adsp state %d\n", __func__, state);
-	if (state < APR_SUBSYS_DOWN || state > APR_SUBSYS_LOADED)
-		return -EINVAL;
-	atomic_set(&q6.q6_state, state);
-	return 0;
-}
-EXPORT_SYMBOL(apr_set_q6_state);
-
-enum apr_subsys_state apr_cmpxchg_q6_state(enum apr_subsys_state prev,
-					   enum apr_subsys_state new)
-{
-	return atomic_cmpxchg(&q6.q6_state, prev, new);
-}
-
-static void apr_adsp_down(unsigned long opcode)
-{
-	apr_set_q6_state(APR_SUBSYS_DOWN);
-	dispatch_event(opcode, APR_DEST_QDSP6);
-}
-
-static void apr_adsp_up(void)
-{
-	if (apr_cmpxchg_q6_state(APR_SUBSYS_DOWN, APR_SUBSYS_LOADED) ==
-							APR_SUBSYS_DOWN)
-		wake_up(&dsp_wait);
-}
-
-int apr_wait_for_device_up(int dest_id)
-{
-	int rc = -1;
-
-	if (dest_id == APR_DEST_MODEM)
-		rc = wait_event_interruptible_timeout(modem_wait,
-				    (apr_get_modem_state() == APR_SUBSYS_UP),
-				    (1 * HZ));
-	else if (dest_id == APR_DEST_QDSP6)
-		rc = wait_event_interruptible_timeout(dsp_wait,
-				    (apr_get_q6_state() == APR_SUBSYS_UP),
-				    (1 * HZ));
-	else
-		pr_err("%s: unknown dest_id %d\n", __func__, dest_id);
-	/* returns left time */
-	return rc;
-}
-
-int apr_load_adsp_image(void)
-{
-	int rc = 0;
-
-	mutex_lock(&q6.lock);
-	if (apr_get_q6_state() == APR_SUBSYS_UP) {
-		q6.pil = subsystem_get("adsp");
-		if (IS_ERR(q6.pil)) {
-			rc = PTR_ERR(q6.pil);
-			pr_err("APR: Unable to load q6 image, error:%d\n", rc);
-		} else {
-			apr_set_q6_state(APR_SUBSYS_LOADED);
-			pr_debug("APR: Image is loaded, stated\n");
-		}
-	} else if (apr_get_q6_state() == APR_SUBSYS_LOADED) {
-		pr_debug("APR: q6 image already loaded\n");
-	} else {
-		pr_debug("APR: cannot load state %d\n", apr_get_q6_state());
-	}
-	mutex_unlock(&q6.lock);
-	return rc;
-}
-
-struct apr_client *apr_get_client(int dest_id, int client_id)
-{
-	return &client[dest_id][client_id];
-}
-
-int apr_send_pkt(void *handle, uint32_t *buf)
-{
-	struct apr_svc *svc = handle;
-	struct apr_client *clnt;
-	struct apr_hdr *hdr;
-	uint16_t dest_id;
-	uint16_t client_id;
-	uint16_t w_len;
-	int rc;
-	unsigned long flags;
-
-	if (!handle || !buf) {
-		pr_err("APR: Wrong parameters\n");
-		return -EINVAL;
-	}
-	if (svc->need_reset) {
-		pr_err("apr: send_pkt service need reset\n");
-		return -ENETRESET;
-	}
-
-	if ((svc->dest_id == APR_DEST_QDSP6) &&
-	    (apr_get_q6_state() != APR_SUBSYS_LOADED)) {
-		pr_err("%s: Still dsp is not Up\n", __func__);
-		return -ENETRESET;
-	} else if ((svc->dest_id == APR_DEST_MODEM) &&
-		   (apr_get_modem_state() == APR_SUBSYS_DOWN)) {
-		pr_err("apr: Still Modem is not Up\n");
-		return -ENETRESET;
-	}
-
-	spin_lock_irqsave(&svc->w_lock, flags);
-	dest_id = svc->dest_id;
-	client_id = svc->client_id;
-	clnt = &client[dest_id][client_id];
-
-	if (!client[dest_id][client_id].handle) {
-		pr_err("APR: Still service is not yet opened\n");
-		spin_unlock_irqrestore(&svc->w_lock, flags);
-		return -EINVAL;
-	}
-	hdr = (struct apr_hdr *)buf;
-
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->src_svc = svc->id;
-	hdr->dest_domain = svc->dest_domain;
-	hdr->dest_svc = svc->id;
-
-	if (unlikely(apr_cf_debug)) {
-		APR_PKT_INFO(
-		"Tx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X]",
-		(hdr->src_domain << 8) | hdr->src_svc,
-		(hdr->dest_domain << 8) | hdr->dest_svc, hdr->opcode,
-		hdr->token);
-	}
-
-	rc = apr_tal_write(clnt->handle, buf,
-			(struct apr_pkt_priv *)&svc->pkt_owner,
-			hdr->pkt_size);
-	if (rc >= 0) {
-		w_len = rc;
-		if (w_len != hdr->pkt_size) {
-			pr_err("%s: Unable to write whole APR pkt successfully: %d\n",
-			       __func__, rc);
-			rc = -EINVAL;
-		}
-	} else {
-		pr_err("%s: Write APR pkt failed with error %d\n",
-			__func__, rc);
-	}
-	spin_unlock_irqrestore(&svc->w_lock, flags);
-
-	return rc;
-}
-
-int apr_pkt_config(void *handle, struct apr_pkt_cfg *cfg)
-{
-	struct apr_svc *svc = (struct apr_svc *)handle;
-	uint16_t dest_id;
-	uint16_t client_id;
-	struct apr_client *clnt;
-
-	if (!handle) {
-		pr_err("%s: Invalid handle\n", __func__);
-		return -EINVAL;
-	}
-
-	if (svc->need_reset) {
-		pr_err("%s: service need reset\n", __func__);
-		return -ENETRESET;
-	}
-
-	svc->pkt_owner = cfg->pkt_owner;
-	dest_id = svc->dest_id;
-	client_id = svc->client_id;
-	clnt = &client[dest_id][client_id];
-
-	return apr_tal_rx_intents_config(clnt->handle,
-		cfg->intents.num_of_intents, cfg->intents.size);
-}
-
-struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
-				uint32_t src_port, void *priv)
-{
-	struct apr_client *clnt;
-	int client_id = 0;
-	int svc_idx = 0;
-	int svc_id = 0;
-	int dest_id = 0;
-	int domain_id = 0;
-	int temp_port = 0;
-	struct apr_svc *svc = NULL;
-	int rc = 0;
-	bool can_open_channel = true;
-
-	if (!dest || !svc_name || !svc_fn)
-		return NULL;
-
-	if (!strcmp(dest, "ADSP"))
-		domain_id = APR_DOMAIN_ADSP;
-	else if (!strcmp(dest, "MODEM")) {
-		/* Don't request for SMD channels if destination is MODEM,
-		 * as these channels are no longer used and these clients
-		 * are to listen only for MODEM SSR events
-		 */
-		can_open_channel = false;
-		domain_id = APR_DOMAIN_MODEM;
-	} else {
-		pr_err("APR: wrong destination\n");
-		goto done;
-	}
-
-	dest_id = apr_get_dest_id(dest);
-
-	if (dest_id == APR_DEST_QDSP6) {
-		if (apr_get_q6_state() != APR_SUBSYS_LOADED) {
-			pr_err("%s: adsp not up\n", __func__);
-			return NULL;
-		}
-		pr_debug("%s: adsp Up\n", __func__);
-	} else if (dest_id == APR_DEST_MODEM) {
-		if (apr_get_modem_state() == APR_SUBSYS_DOWN) {
-			if (is_modem_up) {
-				pr_err("%s: modem shutdown due to SSR, ret",
-					__func__);
-				return NULL;
-			}
-			pr_debug("%s: Wait for modem to bootup\n", __func__);
-			rc = apr_wait_for_device_up(APR_DEST_MODEM);
-			if (rc == 0) {
-				pr_err("%s: Modem is not Up\n", __func__);
-				return NULL;
-			}
-		}
-		pr_debug("%s: modem Up\n", __func__);
-	}
-
-	if (apr_get_svc(svc_name, domain_id, &client_id, &svc_idx, &svc_id)) {
-		pr_err("%s: apr_get_svc failed\n", __func__);
-		goto done;
-	}
-
-	clnt = &client[dest_id][client_id];
-	mutex_lock(&clnt->m_lock);
-	if (!clnt->handle && can_open_channel) {
-		clnt->handle = apr_tal_open(client_id, dest_id,
-				APR_DL_SMD, apr_cb_func, NULL);
-		if (!clnt->handle) {
-			svc = NULL;
-			pr_err("APR: Unable to open handle\n");
-			mutex_unlock(&clnt->m_lock);
-			goto done;
-		}
-	}
-	mutex_unlock(&clnt->m_lock);
-	svc = &clnt->svc[svc_idx];
-	mutex_lock(&svc->m_lock);
-	clnt->id = client_id;
-	if (svc->need_reset) {
-		mutex_unlock(&svc->m_lock);
-		pr_err("APR: Service needs reset\n");
-		goto done;
-	}
-	svc->id = svc_id;
-	svc->dest_id = dest_id;
-	svc->client_id = client_id;
-	svc->dest_domain = domain_id;
-	svc->pkt_owner = APR_PKT_OWNER_DRIVER;
-
-	if (src_port != 0xFFFFFFFF) {
-		temp_port = ((src_port >> 8) * 8) + (src_port & 0xFF);
-		pr_debug("port = %d t_port = %d\n", src_port, temp_port);
-		if (temp_port >= APR_MAX_PORTS || temp_port < 0) {
-			pr_err("APR: temp_port out of bounds\n");
-			mutex_unlock(&svc->m_lock);
-			return NULL;
-		}
-		if (!svc->svc_cnt)
-			clnt->svc_cnt++;
-		svc->port_cnt++;
-		svc->port_fn[temp_port] = svc_fn;
-		svc->port_priv[temp_port] = priv;
-		svc->svc_cnt++;
-	} else {
-		if (!svc->fn) {
-			if (!svc->svc_cnt)
-				clnt->svc_cnt++;
-			svc->fn = svc_fn;
-			svc->priv = priv;
-			svc->svc_cnt++;
-		}
-	}
-
-	mutex_unlock(&svc->m_lock);
-done:
-	return svc;
-}
-
-
-void apr_cb_func(void *buf, int len, void *priv)
-{
-	struct apr_client_data data;
-	struct apr_client *apr_client;
-	struct apr_svc *c_svc;
-	struct apr_hdr *hdr;
-	uint16_t hdr_size;
-	uint16_t msg_type;
-	uint16_t ver;
-	uint16_t src;
-	uint16_t svc;
-	uint16_t clnt;
-	int i;
-	int temp_port = 0;
-	uint32_t *ptr;
-
-	pr_debug("APR2: len = %d\n", len);
-	ptr = buf;
-	pr_debug("\n*****************\n");
-	for (i = 0; i < len/4; i++)
-		pr_debug("%x  ", ptr[i]);
-	pr_debug("\n");
-	pr_debug("\n*****************\n");
-
-	if (!buf || len <= APR_HDR_SIZE) {
-		pr_err("APR: Improper apr pkt received:%pK %d\n", buf, len);
-		return;
-	}
-	hdr = buf;
-
-	ver = hdr->hdr_field;
-	ver = (ver & 0x000F);
-	if (ver > APR_PKT_VER + 1) {
-		pr_err("APR: Wrong version: %d\n", ver);
-		return;
-	}
-
-	hdr_size = hdr->hdr_field;
-	hdr_size = ((hdr_size & 0x00F0) >> 0x4) * 4;
-	if (hdr_size < APR_HDR_SIZE) {
-		pr_err("APR: Wrong hdr size:%d\n", hdr_size);
-		return;
-	}
-
-	if (hdr->pkt_size < APR_HDR_SIZE) {
-		pr_err("APR: Wrong paket size\n");
-		return;
-	}
-	msg_type = hdr->hdr_field;
-	msg_type = (msg_type >> 0x08) & 0x0003;
-	if (msg_type >= APR_MSG_TYPE_MAX && msg_type != APR_BASIC_RSP_RESULT) {
-		pr_err("APR: Wrong message type: %d\n", msg_type);
-		return;
-	}
-
-	if (hdr->src_domain >= APR_DOMAIN_MAX ||
-		hdr->dest_domain >= APR_DOMAIN_MAX ||
-		hdr->src_svc >= APR_SVC_MAX ||
-		hdr->dest_svc >= APR_SVC_MAX) {
-		pr_err("APR: Wrong APR header\n");
-		return;
-	}
-
-	svc = hdr->dest_svc;
-	if (hdr->src_domain == APR_DOMAIN_MODEM) {
-		if (svc == APR_SVC_MVS || svc == APR_SVC_MVM ||
-		    svc == APR_SVC_CVS || svc == APR_SVC_CVP ||
-		    svc == APR_SVC_TEST_CLIENT)
-			clnt = APR_CLIENT_VOICE;
-		else {
-			pr_err("APR: Wrong svc :%d\n", svc);
-			return;
-		}
-	} else if (hdr->src_domain == APR_DOMAIN_ADSP) {
-		if (svc == APR_SVC_AFE || svc == APR_SVC_ASM ||
-		    svc == APR_SVC_VSM || svc == APR_SVC_VPM ||
-		    svc == APR_SVC_ADM || svc == APR_SVC_ADSP_CORE ||
-		    svc == APR_SVC_USM ||
-		    svc == APR_SVC_TEST_CLIENT || svc == APR_SVC_ADSP_MVM ||
-		    svc == APR_SVC_ADSP_CVS || svc == APR_SVC_ADSP_CVP ||
-		    svc == APR_SVC_LSM)
-			clnt = APR_CLIENT_AUDIO;
-		else if (svc == APR_SVC_VIDC)
-			clnt = APR_CLIENT_AUDIO;
-		else {
-			pr_err("APR: Wrong svc :%d\n", svc);
-			return;
-		}
-	} else {
-		pr_err("APR: Pkt from wrong source: %d\n", hdr->src_domain);
-		return;
-	}
-
-	src = apr_get_data_src(hdr);
-	if (src == APR_DEST_MAX)
-		return;
-
-	pr_debug("src =%d clnt = %d\n", src, clnt);
-	apr_client = &client[src][clnt];
-	for (i = 0; i < APR_SVC_MAX; i++)
-		if (apr_client->svc[i].id == svc) {
-			pr_debug("%d\n", apr_client->svc[i].id);
-			c_svc = &apr_client->svc[i];
-			break;
-		}
-
-	if (i == APR_SVC_MAX) {
-		pr_err("APR: service is not registered\n");
-		return;
-	}
-	pr_debug("svc_idx = %d\n", i);
-	pr_debug("%x %x %x %pK %pK\n", c_svc->id, c_svc->dest_id,
-		 c_svc->client_id, c_svc->fn, c_svc->priv);
-	data.payload_size = hdr->pkt_size - hdr_size;
-	data.opcode = hdr->opcode;
-	data.src = src;
-	data.src_port = hdr->src_port;
-	data.dest_port = hdr->dest_port;
-	data.token = hdr->token;
-	data.msg_type = msg_type;
-	data.payload = NULL;
-	if (data.payload_size > 0)
-		data.payload = (char *)hdr + hdr_size;
-
-	if (unlikely(apr_cf_debug)) {
-		if (hdr->opcode == APR_BASIC_RSP_RESULT && data.payload) {
-			uint32_t *ptr = data.payload;
-
-			APR_PKT_INFO(
-			"Rx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X] rc[0x%X]",
-			(hdr->src_domain << 8) | hdr->src_svc,
-			(hdr->dest_domain << 8) | hdr->dest_svc,
-			hdr->opcode, hdr->token, ptr[1]);
-		} else {
-			APR_PKT_INFO(
-			"Rx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X]",
-			(hdr->src_domain << 8) | hdr->src_svc,
-			(hdr->dest_domain << 8) | hdr->dest_svc, hdr->opcode,
-			hdr->token);
-		}
-	}
-
-	temp_port = ((data.dest_port >> 8) * 8) + (data.dest_port & 0xFF);
-	pr_debug("port = %d t_port = %d\n", data.src_port, temp_port);
-	if (c_svc->port_cnt && c_svc->port_fn[temp_port])
-		c_svc->port_fn[temp_port](&data,  c_svc->port_priv[temp_port]);
-	else if (c_svc->fn)
-		c_svc->fn(&data, c_svc->priv);
-	else
-		pr_err("APR: Rxed a packet for NULL callback\n");
-}
-
-int apr_get_svc(const char *svc_name, int domain_id, int *client_id,
-		int *svc_idx, int *svc_id)
-{
-	int i;
-	int size;
-	struct apr_svc_table *tbl;
-	int ret = 0;
-
-	if (domain_id == APR_DOMAIN_ADSP) {
-		tbl = (struct apr_svc_table *)&svc_tbl_qdsp6;
-		size = ARRAY_SIZE(svc_tbl_qdsp6);
-	} else {
-		tbl = (struct apr_svc_table *)&svc_tbl_voice;
-		size = ARRAY_SIZE(svc_tbl_voice);
-	}
-
-	for (i = 0; i < size; i++) {
-		if (!strcmp(svc_name, tbl[i].name)) {
-			*client_id = tbl[i].client_id;
-			*svc_idx = tbl[i].idx;
-			*svc_id = tbl[i].id;
-			break;
-		}
-	}
-
-	pr_debug("%s: svc_name = %s c_id = %d domain_id = %d\n",
-		 __func__, svc_name, *client_id, domain_id);
-	if (i == size) {
-		pr_err("%s: APR: Wrong svc name %s\n", __func__, svc_name);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static void apr_reset_deregister(struct work_struct *work)
-{
-	struct apr_svc *handle = NULL;
-	struct apr_reset_work *apr_reset =
-			container_of(work, struct apr_reset_work, work);
-
-	handle = apr_reset->handle;
-	pr_debug("%s:handle[%pK]\n", __func__, handle);
-	apr_deregister(handle);
-	kfree(apr_reset);
-}
-
-int apr_deregister(void *handle)
-{
-	struct apr_svc *svc = handle;
-	struct apr_client *clnt;
-	uint16_t dest_id;
-	uint16_t client_id;
-
-	if (!handle)
-		return -EINVAL;
-
-	mutex_lock(&svc->m_lock);
-	if (!svc->svc_cnt) {
-		pr_err("%s: svc already deregistered. svc = %pK\n",
-			__func__, svc);
-		mutex_unlock(&svc->m_lock);
-		return -EINVAL;
-	}
-
-	dest_id = svc->dest_id;
-	client_id = svc->client_id;
-	clnt = &client[dest_id][client_id];
-
-	if (svc->svc_cnt > 0) {
-		if (svc->port_cnt)
-			svc->port_cnt--;
-		svc->svc_cnt--;
-		if (!svc->svc_cnt) {
-			client[dest_id][client_id].svc_cnt--;
-			pr_debug("%s: service is reset %pK\n", __func__, svc);
-		}
-	}
-
-	if (!svc->svc_cnt) {
-		svc->priv = NULL;
-		svc->id = 0;
-		svc->fn = NULL;
-		svc->dest_id = 0;
-		svc->client_id = 0;
-		svc->need_reset = 0x0;
-	}
-	if (client[dest_id][client_id].handle &&
-	    !client[dest_id][client_id].svc_cnt) {
-		apr_tal_close(client[dest_id][client_id].handle);
-		client[dest_id][client_id].handle = NULL;
-	}
-	mutex_unlock(&svc->m_lock);
-
-	return 0;
-}
-
-void apr_reset(void *handle)
-{
-	struct apr_reset_work *apr_reset_worker = NULL;
-
-	if (!handle)
-		return;
-	pr_debug("%s: handle[%pK]\n", __func__, handle);
-
-	if (apr_reset_workqueue == NULL) {
-		pr_err("%s: apr_reset_workqueue is NULL\n", __func__);
-		return;
-	}
-
-	apr_reset_worker = kzalloc(sizeof(struct apr_reset_work),
-							GFP_ATOMIC);
-
-	if (apr_reset_worker == NULL) {
-		pr_err("%s: mem failure\n", __func__);
-		return;
-	}
-
-	apr_reset_worker->handle = handle;
-	INIT_WORK(&apr_reset_worker->work, apr_reset_deregister);
-	queue_work(apr_reset_workqueue, &apr_reset_worker->work);
-}
-
-/* Dispatch the Reset events to Modem and audio clients */
-static void dispatch_event(unsigned long code, uint16_t proc)
-{
-	struct apr_client *apr_client;
-	struct apr_client_data data;
-	struct apr_svc *svc;
-	uint16_t clnt;
-	int i, j;
-
-	memset(&data, 0, sizeof(data));
-	data.opcode = RESET_EVENTS;
-	data.reset_event = code;
-
-	/* Service domain can be different from the processor */
-	data.reset_proc = apr_get_reset_domain(proc);
-
-	clnt = APR_CLIENT_AUDIO;
-	apr_client = &client[proc][clnt];
-	for (i = 0; i < APR_SVC_MAX; i++) {
-		mutex_lock(&apr_client->svc[i].m_lock);
-		if (apr_client->svc[i].fn) {
-			apr_client->svc[i].need_reset = 0x1;
-			apr_client->svc[i].fn(&data, apr_client->svc[i].priv);
-		}
-		if (apr_client->svc[i].port_cnt) {
-			svc = &(apr_client->svc[i]);
-			svc->need_reset = 0x1;
-			for (j = 0; j < APR_MAX_PORTS; j++)
-				if (svc->port_fn[j])
-					svc->port_fn[j](&data,
-						svc->port_priv[j]);
-		}
-		mutex_unlock(&apr_client->svc[i].m_lock);
-	}
-
-	clnt = APR_CLIENT_VOICE;
-	apr_client = &client[proc][clnt];
-	for (i = 0; i < APR_SVC_MAX; i++) {
-		mutex_lock(&apr_client->svc[i].m_lock);
-		if (apr_client->svc[i].fn) {
-			apr_client->svc[i].need_reset = 0x1;
-			apr_client->svc[i].fn(&data, apr_client->svc[i].priv);
-		}
-		if (apr_client->svc[i].port_cnt) {
-			svc = &(apr_client->svc[i]);
-			svc->need_reset = 0x1;
-			for (j = 0; j < APR_MAX_PORTS; j++)
-				if (svc->port_fn[j])
-					svc->port_fn[j](&data,
-						svc->port_priv[j]);
-		}
-		mutex_unlock(&apr_client->svc[i].m_lock);
-	}
-}
-
-static int apr_notifier_service_cb(struct notifier_block *this,
-				   unsigned long opcode, void *data)
-{
-	struct audio_notifier_cb_data *cb_data = data;
-
-	if (cb_data == NULL) {
-		pr_err("%s: Callback data is NULL!\n", __func__);
-		goto done;
-	}
-
-	pr_debug("%s: Service opcode 0x%lx, domain %d\n",
-		__func__, opcode, cb_data->domain);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		/*
-		 * Use flag to ignore down notifications during
-		 * initial boot. There is no benefit from error
-		 * recovery notifications during initial boot
-		 * up since everything is expected to be down.
-		 */
-		if (is_initial_boot) {
-			is_initial_boot = false;
-			break;
-		}
-		if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
-			apr_modem_down(opcode);
-		else
-			apr_adsp_down(opcode);
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		is_initial_boot = false;
-		if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
-			apr_modem_up();
-		else
-			apr_adsp_up();
-		break;
-	default:
-		break;
-	}
-done:
-	return NOTIFY_OK;
-}
-
-static struct notifier_block adsp_service_nb = {
-	.notifier_call  = apr_notifier_service_cb,
-	.priority = 0,
-};
-
-static struct notifier_block modem_service_nb = {
-	.notifier_call  = apr_notifier_service_cb,
-	.priority = 0,
-};
-
-static int __init apr_init(void)
-{
-	int i, j, k;
-
-	for (i = 0; i < APR_DEST_MAX; i++)
-		for (j = 0; j < APR_CLIENT_MAX; j++) {
-			mutex_init(&client[i][j].m_lock);
-			for (k = 0; k < APR_SVC_MAX; k++) {
-				mutex_init(&client[i][j].svc[k].m_lock);
-				spin_lock_init(&client[i][j].svc[k].w_lock);
-			}
-		}
-	apr_set_subsys_state();
-	mutex_init(&q6.lock);
-	apr_reset_workqueue = create_singlethread_workqueue("apr_driver");
-	if (!apr_reset_workqueue)
-		return -ENOMEM;
-
-	apr_pkt_ctx = ipc_log_context_create(APR_PKT_IPC_LOG_PAGE_CNT,
-						"apr", 0);
-	if (!apr_pkt_ctx)
-		pr_err("%s: Unable to create ipc log context\n", __func__);
-
-	is_initial_boot = true;
-	subsys_notif_register("apr_adsp", AUDIO_NOTIFIER_ADSP_DOMAIN,
-			      &adsp_service_nb);
-	subsys_notif_register("apr_modem", AUDIO_NOTIFIER_MODEM_DOMAIN,
-			      &modem_service_nb);
-
-	return 0;
-}
-device_initcall(apr_init);
-
-static int __init apr_late_init(void)
-{
-	int ret = 0;
-
-	init_waitqueue_head(&dsp_wait);
-	init_waitqueue_head(&modem_wait);
-
-	return ret;
-}
-late_initcall(apr_late_init);
-
-#ifdef CONFIG_DEBUG_FS
-static int __init apr_debug_init(void)
-{
-	debugfs_apr_debug = debugfs_create_file("msm_apr_debug",
-						 S_IFREG | 0444, NULL, NULL,
-						 &apr_debug_ops);
-	return 0;
-}
-device_initcall(apr_debug_init);
-#endif
diff --git a/drivers/soc/qcom/qdsp6v2/apr_tal_glink.c b/drivers/soc/qcom/qdsp6v2/apr_tal_glink.c
deleted file mode 100644
index 9f12564a..0000000
--- a/drivers/soc/qcom/qdsp6v2/apr_tal_glink.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/* Copyright (c) 2016-2017 The Linux Foundation.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <soc/qcom/glink.h>
-#include <linux/qdsp6v2/apr_tal.h>
-
-#define APR_MAXIMUM_NUM_OF_RETRIES 2
-
-struct apr_tx_buf {
-	struct apr_pkt_priv pkt_priv;
-	char buf[APR_MAX_BUF];
-};
-
-struct link_state {
-	uint32_t dest;
-	void *handle;
-	enum glink_link_state link_state;
-	wait_queue_head_t wait;
-};
-
-static struct link_state link_state[APR_DEST_MAX];
-
-static char *svc_names[APR_DEST_MAX][APR_CLIENT_MAX] = {
-	{
-		"apr_audio_svc",
-		"apr_voice_svc",
-	},
-	{
-		"apr_audio_svc",
-		"apr_voice_svc",
-	},
-};
-
-static struct apr_svc_ch_dev
-	apr_svc_ch[APR_DL_MAX][APR_DEST_MAX][APR_CLIENT_MAX];
-
-static struct apr_tx_buf *apr_alloc_buf(int len)
-{
-
-	if (len > APR_MAX_BUF) {
-		pr_err("%s: buf too large [%d]\n", __func__, len);
-		return ERR_PTR(-EINVAL);
-	}
-
-	return kzalloc(sizeof(struct apr_tx_buf), GFP_ATOMIC);
-}
-
-static void apr_free_buf(const void *ptr)
-{
-
-	struct apr_pkt_priv *apr_pkt_priv = (struct apr_pkt_priv *)ptr;
-	struct apr_tx_buf *tx_buf;
-
-	if (!apr_pkt_priv) {
-		pr_err("%s: Invalid apr_pkt_priv\n", __func__);
-		return;
-	}
-
-	if (apr_pkt_priv->pkt_owner == APR_PKT_OWNER_DRIVER) {
-		tx_buf = container_of((void *)apr_pkt_priv,
-				      struct apr_tx_buf, pkt_priv);
-		pr_debug("%s: Freeing buffer %pK", __func__, tx_buf);
-		kfree(tx_buf);
-	}
-}
-
-
-static int __apr_tal_write(struct apr_svc_ch_dev *apr_ch, void *data,
-			   struct apr_pkt_priv *pkt_priv, int len)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(&apr_ch->w_lock, flags);
-	rc = glink_tx(apr_ch->handle, pkt_priv, data, len, GLINK_TX_ATOMIC);
-	spin_unlock_irqrestore(&apr_ch->w_lock, flags);
-
-	if (rc)
-		pr_err("%s: glink_tx failed, rc[%d]\n", __func__, rc);
-	else
-		rc = len;
-
-	return rc;
-}
-
-int apr_tal_write(struct apr_svc_ch_dev *apr_ch, void *data,
-		  struct apr_pkt_priv *pkt_priv, int len)
-{
-	int rc = 0, retries = 0;
-	void *pkt_data = NULL;
-	struct apr_tx_buf *tx_buf = NULL;
-	struct apr_pkt_priv *pkt_priv_ptr = pkt_priv;
-
-	if (!apr_ch->handle || !pkt_priv)
-		return -EINVAL;
-
-	if (pkt_priv->pkt_owner == APR_PKT_OWNER_DRIVER) {
-		tx_buf = apr_alloc_buf(len);
-		if (IS_ERR_OR_NULL(tx_buf)) {
-			rc = -EINVAL;
-			goto exit;
-		}
-		memcpy(tx_buf->buf, data, len);
-		memcpy(&tx_buf->pkt_priv, pkt_priv, sizeof(tx_buf->pkt_priv));
-		pkt_priv_ptr = &tx_buf->pkt_priv;
-		pkt_data = tx_buf->buf;
-	} else {
-		pkt_data = data;
-	}
-
-	do {
-		if (rc == -EAGAIN)
-			udelay(50);
-
-		rc = __apr_tal_write(apr_ch, pkt_data, pkt_priv_ptr, len);
-	} while (rc == -EAGAIN && retries++ < APR_MAXIMUM_NUM_OF_RETRIES);
-
-	if (rc < 0) {
-		pr_err("%s: Unable to send the packet, rc:%d\n", __func__, rc);
-		if (pkt_priv->pkt_owner == APR_PKT_OWNER_DRIVER)
-			kfree(tx_buf);
-	}
-exit:
-	return rc;
-}
-
-void apr_tal_notify_rx(void *handle, const void *priv, const void *pkt_priv,
-		       const void *ptr, size_t size)
-{
-	struct apr_svc_ch_dev *apr_ch = (struct apr_svc_ch_dev *)priv;
-	unsigned long flags;
-
-	if (!apr_ch || !ptr) {
-		pr_err("%s: Invalid apr_ch or ptr\n", __func__);
-		return;
-	}
-
-	pr_debug("%s: Rx packet received\n", __func__);
-
-	spin_lock_irqsave(&apr_ch->r_lock, flags);
-	if (apr_ch->func)
-		apr_ch->func((void *)ptr, size, (void *)pkt_priv);
-	spin_unlock_irqrestore(&apr_ch->r_lock, flags);
-	glink_rx_done(apr_ch->handle, ptr, true);
-}
-
-static void apr_tal_notify_tx_abort(void *handle, const void *priv,
-				    const void *pkt_priv)
-{
-	pr_debug("%s: tx_abort received for pkt_priv:%pK\n",
-		 __func__, pkt_priv);
-	apr_free_buf(pkt_priv);
-}
-
-void apr_tal_notify_tx_done(void *handle, const void *priv,
-			    const void *pkt_priv, const void *ptr)
-{
-	pr_debug("%s: tx_done received for pkt_priv:%pK\n",
-		 __func__, pkt_priv);
-	apr_free_buf(pkt_priv);
-}
-
-bool apr_tal_notify_rx_intent_req(void *handle, const void *priv,
-				  size_t req_size)
-{
-	struct apr_svc_ch_dev *apr_ch = (struct apr_svc_ch_dev *)priv;
-
-	if (!apr_ch) {
-		pr_err("%s: Invalid apr_ch\n", __func__);
-		return false;
-	}
-
-	pr_err("%s: No rx intents queued, unable to receive\n", __func__);
-	return false;
-}
-
-static void apr_tal_notify_remote_rx_intent(void *handle, const void *priv,
-					    size_t size)
-{
-	struct apr_svc_ch_dev *apr_ch = (struct apr_svc_ch_dev *)priv;
-
-	if (!apr_ch) {
-		pr_err("%s: Invalid apr_ch\n", __func__);
-		return;
-	}
-	/*
-	 * This is to make sure that the far end has queued at least one intent
-	 * before we attmpt any IPC. A simple bool flag is used here instead of
-	 * a counter, as the far end is required to guarantee intent
-	 * availability for all use cases once the channel is fully opened.
-	 */
-	pr_debug("%s: remote queued an intent\n", __func__);
-	apr_ch->if_remote_intent_ready = true;
-	wake_up(&apr_ch->wait);
-}
-
-void apr_tal_notify_state(void *handle, const void *priv, unsigned int event)
-{
-	struct apr_svc_ch_dev *apr_ch = (struct apr_svc_ch_dev *)priv;
-
-	if (!apr_ch) {
-		pr_err("%s: Invalid apr_ch\n", __func__);
-		return;
-	}
-
-	apr_ch->channel_state = event;
-	pr_info("%s: Channel state[%d]\n", __func__, event);
-
-	if (event == GLINK_CONNECTED)
-		wake_up(&apr_ch->wait);
-}
-
-int apr_tal_rx_intents_config(struct apr_svc_ch_dev *apr_ch,
-			      int num_of_intents, uint32_t size)
-{
-	int i;
-	int rc = 0;
-
-	if (!apr_ch || !num_of_intents || !size) {
-		pr_err("%s: Invalid parameter\n", __func__);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < num_of_intents; i++) {
-		rc = glink_queue_rx_intent(apr_ch->handle, apr_ch, size);
-		if (rc) {
-			pr_err("%s: Failed to queue rx intent, iteration[%d]\n",
-			       __func__, i);
-			break;
-		}
-	}
-
-	return rc;
-}
-
-struct apr_svc_ch_dev *apr_tal_open(uint32_t clnt, uint32_t dest, uint32_t dl,
-				    apr_svc_cb_fn func, void *priv)
-{
-	int rc;
-	struct glink_open_config open_cfg;
-	struct apr_svc_ch_dev *apr_ch;
-
-	if ((clnt >= APR_CLIENT_MAX) || (dest >= APR_DEST_MAX) ||
-	    (dl >= APR_DL_MAX)) {
-		pr_err("%s: Invalid params, clnt:%d, dest:%d, dl:%d\n",
-		       __func__, clnt, dest, dl);
-		return NULL;
-	}
-
-	apr_ch = &apr_svc_ch[dl][dest][clnt];
-	mutex_lock(&apr_ch->m_lock);
-	if (apr_ch->handle) {
-		pr_err("%s: This channel is already opened\n", __func__);
-		rc = -EBUSY;
-		goto unlock;
-	}
-
-	if (link_state[dest].link_state != GLINK_LINK_STATE_UP) {
-		rc = wait_event_timeout(link_state[dest].wait,
-			link_state[dest].link_state == GLINK_LINK_STATE_UP,
-			msecs_to_jiffies(APR_OPEN_TIMEOUT_MS));
-		if (rc == 0) {
-			pr_err("%s: Open timeout, dest:%d\n", __func__, dest);
-			rc = -ETIMEDOUT;
-			goto unlock;
-		}
-		pr_debug("%s: Wakeup done, dest:%d\n", __func__, dest);
-	}
-
-	memset(&open_cfg, 0, sizeof(struct glink_open_config));
-	open_cfg.options = GLINK_OPT_INITIAL_XPORT;
-	if (dest == APR_DEST_MODEM)
-		open_cfg.edge = "mpss";
-	else
-		open_cfg.edge = "lpass";
-
-	open_cfg.name = svc_names[dest][clnt];
-	open_cfg.notify_rx = apr_tal_notify_rx;
-	open_cfg.notify_tx_done = apr_tal_notify_tx_done;
-	open_cfg.notify_state = apr_tal_notify_state;
-	open_cfg.notify_rx_intent_req = apr_tal_notify_rx_intent_req;
-	open_cfg.notify_remote_rx_intent = apr_tal_notify_remote_rx_intent;
-	open_cfg.notify_tx_abort = apr_tal_notify_tx_abort;
-	open_cfg.priv = apr_ch;
-	open_cfg.transport = "smem";
-
-	apr_ch->channel_state = GLINK_REMOTE_DISCONNECTED;
-	apr_ch->handle = glink_open(&open_cfg);
-	if (IS_ERR_OR_NULL(apr_ch->handle)) {
-		pr_err("%s: glink_open failed %s\n", __func__,
-		       svc_names[dest][clnt]);
-		apr_ch->handle = NULL;
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	rc = wait_event_timeout(apr_ch->wait,
-		(apr_ch->channel_state == GLINK_CONNECTED), 5 * HZ);
-	if (rc == 0) {
-		pr_err("%s: TIMEOUT for OPEN event\n", __func__);
-		rc = -ETIMEDOUT;
-		goto close_link;
-	}
-
-	/*
-	 * Remote intent is not required for GLINK <--> SMD IPC, so this is
-	 * designed not to fail the open call.
-	 */
-	rc = wait_event_timeout(apr_ch->wait,
-		apr_ch->if_remote_intent_ready, 5 * HZ);
-	if (rc == 0)
-		pr_err("%s: TIMEOUT for remote intent readiness\n", __func__);
-
-	rc = apr_tal_rx_intents_config(apr_ch, APR_DEFAULT_NUM_OF_INTENTS,
-				       APR_MAX_BUF);
-	if (rc) {
-		pr_err("%s: Unable to queue intents\n", __func__);
-		goto close_link;
-	}
-
-	apr_ch->func = func;
-	apr_ch->priv = priv;
-
-close_link:
-	if (rc) {
-		glink_close(apr_ch->handle);
-		apr_ch->handle = NULL;
-	}
-unlock:
-	mutex_unlock(&apr_ch->m_lock);
-
-	return rc ? NULL : apr_ch;
-}
-
-int apr_tal_close(struct apr_svc_ch_dev *apr_ch)
-{
-	int rc;
-
-	if (!apr_ch || !apr_ch->handle) {
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	mutex_lock(&apr_ch->m_lock);
-	rc = glink_close(apr_ch->handle);
-	apr_ch->handle = NULL;
-	apr_ch->func = NULL;
-	apr_ch->priv = NULL;
-	apr_ch->if_remote_intent_ready = false;
-	mutex_unlock(&apr_ch->m_lock);
-exit:
-	return rc;
-}
-
-static void apr_tal_link_state_cb(struct glink_link_state_cb_info *cb_info,
-				  void *priv)
-{
-	uint32_t dest;
-
-	if (!cb_info) {
-		pr_err("%s: Invalid cb_info\n", __func__);
-		return;
-	}
-
-	if (!strcmp(cb_info->edge, "mpss"))
-		dest = APR_DEST_MODEM;
-	else if (!strcmp(cb_info->edge, "lpass"))
-		dest = APR_DEST_QDSP6;
-	else {
-		pr_err("%s:Unknown edge[%s]\n", __func__, cb_info->edge);
-		return;
-	}
-
-	pr_info("%s: edge[%s] link state[%d]\n", __func__, cb_info->edge,
-		cb_info->link_state);
-
-	link_state[dest].link_state = cb_info->link_state;
-	if (link_state[dest].link_state == GLINK_LINK_STATE_UP)
-		wake_up(&link_state[dest].wait);
-}
-
-static struct glink_link_info mpss_link_info = {
-	.transport = "smem",
-	.edge = "mpss",
-	.glink_link_state_notif_cb = apr_tal_link_state_cb,
-};
-
-static struct glink_link_info lpass_link_info = {
-	.transport = "smem",
-	.edge = "lpass",
-	.glink_link_state_notif_cb = apr_tal_link_state_cb,
-};
-
-static int __init apr_tal_init(void)
-{
-	int i, j, k;
-
-	for (i = 0; i < APR_DL_MAX; i++) {
-		for (j = 0; j < APR_DEST_MAX; j++) {
-			for (k = 0; k < APR_CLIENT_MAX; k++) {
-				init_waitqueue_head(&apr_svc_ch[i][j][k].wait);
-				spin_lock_init(&apr_svc_ch[i][j][k].w_lock);
-				spin_lock_init(&apr_svc_ch[i][j][k].r_lock);
-				mutex_init(&apr_svc_ch[i][j][k].m_lock);
-			}
-		}
-	}
-
-	for (i = 0; i < APR_DEST_MAX; i++)
-		init_waitqueue_head(&link_state[i].wait);
-
-	link_state[APR_DEST_MODEM].link_state = GLINK_LINK_STATE_DOWN;
-	link_state[APR_DEST_MODEM].handle =
-		glink_register_link_state_cb(&mpss_link_info, NULL);
-	if (!link_state[APR_DEST_MODEM].handle)
-		pr_err("%s: Unable to register mpss link state\n", __func__);
-
-	link_state[APR_DEST_QDSP6].link_state = GLINK_LINK_STATE_DOWN;
-	link_state[APR_DEST_QDSP6].handle =
-		glink_register_link_state_cb(&lpass_link_info, NULL);
-	if (!link_state[APR_DEST_QDSP6].handle)
-		pr_err("%s: Unable to register lpass link state\n", __func__);
-
-	return 0;
-}
-device_initcall(apr_tal_init);
diff --git a/drivers/soc/qcom/qdsp6v2/apr_v2.c b/drivers/soc/qcom/qdsp6v2/apr_v2.c
deleted file mode 100644
index 4ddf39b..0000000
--- a/drivers/soc/qcom/qdsp6v2/apr_v2.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/qdsp6v2/apr_tal.h>
-#include <linux/qdsp6v2/dsp_debug.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-
-enum apr_subsys_state apr_get_subsys_state(void)
-{
-	return apr_get_q6_state();
-}
-
-void apr_set_subsys_state(void)
-{
-	apr_set_q6_state(APR_SUBSYS_DOWN);
-	apr_set_modem_state(APR_SUBSYS_UP);
-}
-
-uint16_t apr_get_data_src(struct apr_hdr *hdr)
-{
-	if (hdr->src_domain == APR_DOMAIN_MODEM)
-		return APR_DEST_MODEM;
-	else if (hdr->src_domain == APR_DOMAIN_ADSP)
-		return APR_DEST_QDSP6;
-
-	pr_err("APR: Pkt from wrong source: %d\n", hdr->src_domain);
-	return APR_DEST_MAX;		/*RETURN INVALID VALUE*/
-}
-
-int apr_get_dest_id(char *dest)
-{
-	if (!strcmp(dest, "ADSP"))
-		return APR_DEST_QDSP6;
-	else
-		return APR_DEST_MODEM;
-}
-
-void subsys_notif_register(char *client_name, int domain,
-			   struct notifier_block *nb)
-{
-	int ret;
-
-	ret = audio_notifier_register(client_name, domain, nb);
-	if (ret < 0)
-		pr_err("%s: Audio notifier register failed for domain %d ret = %d\n",
-			__func__, domain, ret);
-}
-
-uint16_t apr_get_reset_domain(uint16_t proc)
-{
-	return proc;
-}
diff --git a/drivers/soc/qcom/qdsp6v2/apr_v3.c b/drivers/soc/qcom/qdsp6v2/apr_v3.c
deleted file mode 100644
index 2bfc518..0000000
--- a/drivers/soc/qcom/qdsp6v2/apr_v3.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/qdsp6v2/apr_tal.h>
-#include <linux/qdsp6v2/dsp_debug.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-
-#define DEST_ID APR_DEST_MODEM
-
-enum apr_subsys_state apr_get_subsys_state(void)
-{
-	return apr_get_modem_state();
-}
-
-void apr_set_subsys_state(void)
-{
-	apr_set_modem_state(APR_SUBSYS_DOWN);
-}
-
-uint16_t apr_get_data_src(struct apr_hdr *hdr)
-{
-	return DEST_ID;
-}
-
-int apr_get_dest_id(char *dest)
-{
-	return DEST_ID;
-}
-
-void subsys_notif_register(char *client_name, int domain,
-			   struct notifier_block *nb)
-{
-	int ret;
-
-	if (domain != AUDIO_NOTIFIER_MODEM_DOMAIN) {
-		pr_debug("%s: Unused domain %d not registering with notifier\n",
-			 __func__, domain);
-		return;
-	}
-
-	ret = audio_notifier_register(client_name, domain, nb);
-	if (ret < 0)
-		pr_err("%s: Audio notifier register failed for domain %d ret = %d\n",
-			__func__, domain, ret);
-}
-
-uint16_t apr_get_reset_domain(uint16_t proc)
-{
-	return APR_DEST_QDSP6;
-}
diff --git a/drivers/soc/qcom/qdsp6v2/audio_notifier.c b/drivers/soc/qcom/qdsp6v2/audio_notifier.c
deleted file mode 100644
index 94533a7..0000000
--- a/drivers/soc/qcom/qdsp6v2/audio_notifier.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/qdsp6v2/audio_pdr.h>
-#include <linux/qdsp6v2/audio_ssr.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include <soc/qcom/scm.h>
-#include <soc/qcom/subsystem_notif.h>
-#include <soc/qcom/service-notifier.h>
-
-/* Audio states internal to notifier. Client */
-/* used states defined in audio_notifier.h */
-/* for AUDIO_NOTIFIER_SERVICE_DOWN & UP */
-#define NO_SERVICE -2
-#define UNINIT_SERVICE -1
-
-/*
- * Used for each client registered with audio notifier
- */
-struct client_data {
-	struct list_head        list;
-	/* Notifier block given by client */
-	struct notifier_block   *nb;
-	char                    client_name[20];
-	int                     service;
-	int                     domain;
-};
-
-/*
- * Used for each service and domain combination
- * Tracks information specific to the underlying
- * service.
- */
-struct service_info {
-	const char                      name[20];
-	int                             domain_id;
-	int                             state;
-	void                            *handle;
-	/* Notifier block registered to service */
-	struct notifier_block           *nb;
-	/* Used to determine when to register and deregister service */
-	int                             num_of_clients;
-	/* List of all clients registered to the service and domain */
-	struct srcu_notifier_head       client_nb_list;
-};
-
-static int audio_notifer_ssr_adsp_cb(struct notifier_block *this,
-				     unsigned long opcode, void *data);
-static int audio_notifer_ssr_modem_cb(struct notifier_block *this,
-				     unsigned long opcode, void *data);
-static int audio_notifer_pdr_adsp_cb(struct notifier_block *this,
-				     unsigned long opcode, void *data);
-
-static struct notifier_block notifier_ssr_adsp_nb = {
-	.notifier_call  = audio_notifer_ssr_adsp_cb,
-	.priority = 0,
-};
-
-static struct notifier_block notifier_ssr_modem_nb = {
-	.notifier_call  = audio_notifer_ssr_modem_cb,
-	.priority = 0,
-};
-
-static struct notifier_block notifier_pdr_adsp_nb = {
-	.notifier_call  = audio_notifer_pdr_adsp_cb,
-	.priority = 0,
-};
-
-static struct service_info service_data[AUDIO_NOTIFIER_MAX_SERVICES]
-				       [AUDIO_NOTIFIER_MAX_DOMAINS] = {
-
-	{{
-		.name = "SSR_ADSP",
-		.domain_id = AUDIO_SSR_DOMAIN_ADSP,
-		.state = AUDIO_NOTIFIER_SERVICE_DOWN,
-		.nb = &notifier_ssr_adsp_nb
-	},
-	{
-		.name = "SSR_MODEM",
-		.domain_id = AUDIO_SSR_DOMAIN_MODEM,
-		.state = AUDIO_NOTIFIER_SERVICE_DOWN,
-		.nb = &notifier_ssr_modem_nb
-	} },
-
-	{{
-		.name = "PDR_ADSP",
-		.domain_id = AUDIO_PDR_DOMAIN_ADSP,
-		.state = UNINIT_SERVICE,
-		.nb = &notifier_pdr_adsp_nb
-	},
-	{	/* PDR MODEM service not enabled */
-		.name = "INVALID",
-		.state = NO_SERVICE,
-		.nb = NULL
-	} }
-};
-
-/* Master list of all audio notifier clients */
-struct list_head   client_list;
-struct mutex       notifier_mutex;
-
-static int audio_notifer_get_default_service(int domain)
-{
-	int service = NO_SERVICE;
-
-	/* initial service to connect per domain */
-	switch (domain) {
-	case AUDIO_NOTIFIER_ADSP_DOMAIN:
-		service = AUDIO_NOTIFIER_PDR_SERVICE;
-		break;
-	case AUDIO_NOTIFIER_MODEM_DOMAIN:
-		service = AUDIO_NOTIFIER_SSR_SERVICE;
-		break;
-	}
-
-	return service;
-}
-
-static void audio_notifer_disable_service(int service)
-{
-	int i;
-
-	for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++)
-		service_data[service][i].state = NO_SERVICE;
-}
-
-static bool audio_notifer_is_service_enabled(int service)
-{
-	int i;
-
-	for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++)
-		if (service_data[service][i].state != NO_SERVICE)
-			return true;
-	return false;
-}
-
-static void audio_notifer_init_service(int service)
-{
-	int i;
-
-	for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++) {
-		if (service_data[service][i].state == UNINIT_SERVICE)
-			service_data[service][i].state =
-				AUDIO_NOTIFIER_SERVICE_DOWN;
-	}
-}
-
-static int audio_notifer_reg_service(int service, int domain)
-{
-	void *handle;
-	int ret = 0;
-	int curr_state = AUDIO_NOTIFIER_SERVICE_DOWN;
-
-	switch (service) {
-	case AUDIO_NOTIFIER_SSR_SERVICE:
-		handle = audio_ssr_register(
-			service_data[service][domain].domain_id,
-			service_data[service][domain].nb);
-		break;
-	case AUDIO_NOTIFIER_PDR_SERVICE:
-		handle = audio_pdr_service_register(
-			service_data[service][domain].domain_id,
-			service_data[service][domain].nb, &curr_state);
-
-		if (curr_state == SERVREG_NOTIF_SERVICE_STATE_UP_V01)
-			curr_state = AUDIO_NOTIFIER_SERVICE_UP;
-		else
-			curr_state = AUDIO_NOTIFIER_SERVICE_DOWN;
-		break;
-	default:
-		pr_err("%s: Invalid service %d\n",
-			__func__, service);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: handle is incorrect for service %s\n",
-			__func__, service_data[service][domain].name);
-		ret = -EINVAL;
-		goto done;
-	}
-	service_data[service][domain].state = curr_state;
-	service_data[service][domain].handle = handle;
-
-	pr_info("%s: service %s is in use\n",
-		__func__, service_data[service][domain].name);
-	pr_debug("%s: service %s has current state %d, handle 0x%pK\n",
-		__func__, service_data[service][domain].name,
-		service_data[service][domain].state,
-		service_data[service][domain].handle);
-done:
-	return ret;
-}
-
-static int audio_notifer_dereg_service(int service, int domain)
-{
-	int ret;
-
-	switch (service) {
-	case AUDIO_NOTIFIER_SSR_SERVICE:
-		ret = audio_ssr_deregister(
-			service_data[service][domain].handle,
-			service_data[service][domain].nb);
-		break;
-	case AUDIO_NOTIFIER_PDR_SERVICE:
-		ret = audio_pdr_service_deregister(
-			service_data[service][domain].handle,
-			service_data[service][domain].nb);
-		break;
-	default:
-		pr_err("%s: Invalid service %d\n",
-			__func__, service);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (ret < 0) {
-		pr_err("%s: deregister failed for service %s, ret %d\n",
-			__func__, service_data[service][domain].name, ret);
-		goto done;
-	}
-
-	pr_debug("%s: service %s with handle 0x%pK deregistered\n",
-		__func__, service_data[service][domain].name,
-		service_data[service][domain].handle);
-
-	service_data[service][domain].state = AUDIO_NOTIFIER_SERVICE_DOWN;
-	service_data[service][domain].handle = NULL;
-done:
-	return ret;
-}
-
-static int audio_notifer_reg_client_service(struct client_data *client_data,
-					    int service)
-{
-	int ret = 0;
-	int domain = client_data->domain;
-	struct audio_notifier_cb_data data;
-
-	switch (service) {
-	case AUDIO_NOTIFIER_SSR_SERVICE:
-	case AUDIO_NOTIFIER_PDR_SERVICE:
-		if (service_data[service][domain].num_of_clients == 0)
-			ret = audio_notifer_reg_service(service, domain);
-		break;
-	default:
-		pr_err("%s: Invalid service for client %s, service %d, domain %d\n",
-			__func__, client_data->client_name, service, domain);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (ret < 0) {
-		pr_err("%s: service registration failed on service %s for client %s\n",
-			__func__, service_data[service][domain].name,
-			client_data->client_name);
-		goto done;
-	}
-
-	client_data->service = service;
-	srcu_notifier_chain_register(
-		&service_data[service][domain].client_nb_list,
-		client_data->nb);
-	service_data[service][domain].num_of_clients++;
-
-	pr_debug("%s: registered client %s on service %s, current state 0x%x\n",
-		__func__, client_data->client_name,
-		service_data[service][domain].name,
-		service_data[service][domain].state);
-
-	/*
-	 * PDR registration returns current state
-	 * Force callback of client with current state for PDR
-	 */
-	if (client_data->service == AUDIO_NOTIFIER_PDR_SERVICE) {
-		data.service = service;
-		data.domain = domain;
-		(void)client_data->nb->notifier_call(client_data->nb,
-			service_data[service][domain].state, &data);
-	}
-done:
-	return ret;
-}
-
-static int audio_notifer_reg_client(struct client_data *client_data)
-{
-	int ret = 0;
-	int service;
-	int domain = client_data->domain;
-
-	service = audio_notifer_get_default_service(domain);
-	if (service < 0) {
-		pr_err("%s: service %d is incorrect\n", __func__, service);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/* Search through services to find a valid one to register client on. */
-	for (; service >= 0; service--) {
-		/* If a service is not initialized, wait for it to come up. */
-		if (service_data[service][domain].state == UNINIT_SERVICE)
-			goto done;
-		/* Skip unsupported service and domain combinations. */
-		if (service_data[service][domain].state < 0)
-			continue;
-		/* Only register clients who have not acquired a service. */
-		if (client_data->service != NO_SERVICE)
-			continue;
-
-		/*
-		 * Only register clients, who have not acquired a service, on
-		 * the best available service for their domain. Uninitialized
-		 * services will try to register all of their clients after
-		 * they initialize correctly or will disable their service and
-		 * register clients on the next best avaialable service.
-		 */
-		pr_debug("%s: register client %s on service %s",
-				__func__, client_data->client_name,
-				service_data[service][domain].name);
-
-		ret = audio_notifer_reg_client_service(client_data, service);
-		if (ret < 0)
-			pr_err("%s: client %s failed to register on service %s",
-				__func__, client_data->client_name,
-				service_data[service][domain].name);
-	}
-
-done:
-	return ret;
-}
-
-static int audio_notifer_dereg_client(struct client_data *client_data)
-{
-	int ret = 0;
-	int service = client_data->service;
-	int domain = client_data->domain;
-
-	switch (client_data->service) {
-	case AUDIO_NOTIFIER_SSR_SERVICE:
-	case AUDIO_NOTIFIER_PDR_SERVICE:
-		if (service_data[service][domain].num_of_clients == 1)
-			ret = audio_notifer_dereg_service(service, domain);
-		break;
-	case NO_SERVICE:
-		goto done;
-	default:
-		pr_err("%s: Invalid service for client %s, service %d\n",
-			__func__, client_data->client_name,
-			client_data->service);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (ret < 0) {
-		pr_err("%s: deregister failed for client %s on service %s, ret %d\n",
-			__func__, client_data->client_name,
-			service_data[service][domain].name, ret);
-		goto done;
-	}
-
-	ret = srcu_notifier_chain_unregister(&service_data[service][domain].
-					     client_nb_list, client_data->nb);
-	if (ret < 0) {
-		pr_err("%s: srcu_notifier_chain_unregister failed, ret %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	pr_debug("%s: deregistered client %s on service %s\n",
-		__func__, client_data->client_name,
-		service_data[service][domain].name);
-
-	client_data->service = NO_SERVICE;
-	if (service_data[service][domain].num_of_clients > 0)
-		service_data[service][domain].num_of_clients--;
-done:
-	return ret;
-}
-
-static void audio_notifer_reg_all_clients(void)
-{
-	struct list_head *ptr, *next;
-	struct client_data *client_data;
-	int ret;
-
-	list_for_each_safe(ptr, next, &client_list) {
-		client_data = list_entry(ptr, struct client_data, list);
-
-		ret = audio_notifer_reg_client(client_data);
-		if (ret < 0)
-			pr_err("%s: audio_notifer_reg_client failed for client %s, ret %d\n",
-				__func__, client_data->client_name,
-				ret);
-	}
-}
-
-static int audio_notifer_pdr_callback(struct notifier_block *this,
-				      unsigned long opcode, void *data)
-{
-	pr_debug("%s: Audio PDR framework state 0x%lx\n",
-		__func__, opcode);
-	mutex_lock(&notifier_mutex);
-	if (opcode == AUDIO_PDR_FRAMEWORK_DOWN)
-		audio_notifer_disable_service(AUDIO_NOTIFIER_PDR_SERVICE);
-	else
-		audio_notifer_init_service(AUDIO_NOTIFIER_PDR_SERVICE);
-
-	audio_notifer_reg_all_clients();
-	mutex_unlock(&notifier_mutex);
-	return 0;
-}
-
-static struct notifier_block pdr_nb = {
-	.notifier_call  = audio_notifer_pdr_callback,
-	.priority = 0,
-};
-
-static int audio_notifer_convert_opcode(unsigned long opcode,
-					unsigned long *notifier_opcode)
-{
-	int ret = 0;
-
-	switch (opcode) {
-	case SUBSYS_BEFORE_SHUTDOWN:
-	case SERVREG_NOTIF_SERVICE_STATE_DOWN_V01:
-		*notifier_opcode = AUDIO_NOTIFIER_SERVICE_DOWN;
-		break;
-	case SUBSYS_AFTER_POWERUP:
-	case SERVREG_NOTIF_SERVICE_STATE_UP_V01:
-		*notifier_opcode = AUDIO_NOTIFIER_SERVICE_UP;
-		break;
-	default:
-		pr_debug("%s: Unused opcode 0x%lx\n", __func__, opcode);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int audio_notifer_service_cb(unsigned long opcode,
-				    int service, int domain)
-{
-	int ret = 0;
-	unsigned long notifier_opcode;
-	struct audio_notifier_cb_data data;
-
-	if (audio_notifer_convert_opcode(opcode, &notifier_opcode) < 0)
-		goto done;
-
-	data.service = service;
-	data.domain = domain;
-
-	pr_debug("%s: service %s, opcode 0x%lx\n",
-		__func__, service_data[service][domain].name, notifier_opcode);
-
-	mutex_lock(&notifier_mutex);
-
-	service_data[service][domain].state = notifier_opcode;
-	ret = srcu_notifier_call_chain(&service_data[service][domain].
-		client_nb_list, notifier_opcode, &data);
-	if (ret < 0)
-		pr_err("%s: srcu_notifier_call_chain returned %d, service %s, opcode 0x%lx\n",
-			__func__, ret, service_data[service][domain].name,
-			notifier_opcode);
-
-	mutex_unlock(&notifier_mutex);
-done:
-	return NOTIFY_OK;
-}
-
-static int audio_notifer_pdr_adsp_cb(struct notifier_block *this,
-				     unsigned long opcode, void *data)
-{
-	return audio_notifer_service_cb(opcode,
-					AUDIO_NOTIFIER_PDR_SERVICE,
-					AUDIO_NOTIFIER_ADSP_DOMAIN);
-}
-
-static int audio_notifer_ssr_adsp_cb(struct notifier_block *this,
-				     unsigned long opcode, void *data)
-{
-	if (opcode == SUBSYS_BEFORE_SHUTDOWN)
-		audio_ssr_send_nmi(data);
-
-	return audio_notifer_service_cb(opcode,
-					AUDIO_NOTIFIER_SSR_SERVICE,
-					AUDIO_NOTIFIER_ADSP_DOMAIN);
-}
-
-static int audio_notifer_ssr_modem_cb(struct notifier_block *this,
-				      unsigned long opcode, void *data)
-{
-	return audio_notifer_service_cb(opcode,
-					AUDIO_NOTIFIER_SSR_SERVICE,
-					AUDIO_NOTIFIER_MODEM_DOMAIN);
-}
-
-int audio_notifier_deregister(char *client_name)
-{
-	int ret = 0;
-	int ret2;
-	struct list_head *ptr, *next;
-	struct client_data *client_data = NULL;
-
-	if (client_name == NULL) {
-		pr_err("%s: client_name is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	mutex_lock(&notifier_mutex);
-	list_for_each_safe(ptr, next, &client_list) {
-		client_data = list_entry(ptr, struct client_data, list);
-		if (!strcmp(client_name, client_data->client_name)) {
-			ret2 = audio_notifer_dereg_client(client_data);
-			if (ret2 < 0) {
-				pr_err("%s: audio_notifer_dereg_client failed, ret %d\n, service %d, domain %d",
-					__func__, ret2, client_data->service,
-					client_data->domain);
-				ret = ret2;
-				continue;
-			}
-			list_del(&client_data->list);
-			kfree(client_data);
-		}
-	}
-	mutex_unlock(&notifier_mutex);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(audio_notifier_deregister);
-
-int audio_notifier_register(char *client_name, int domain,
-			    struct notifier_block *nb)
-{
-	int ret;
-	struct client_data *client_data;
-
-	if (client_name == NULL) {
-		pr_err("%s: client_name is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if (nb == NULL) {
-		pr_err("%s: Notifier block is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	client_data = kmalloc(sizeof(*client_data), GFP_KERNEL);
-	if (client_data == NULL) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	INIT_LIST_HEAD(&client_data->list);
-	client_data->nb = nb;
-	strlcpy(client_data->client_name, client_name,
-		sizeof(client_data->client_name));
-	client_data->service = NO_SERVICE;
-	client_data->domain = domain;
-
-	mutex_lock(&notifier_mutex);
-	ret = audio_notifer_reg_client(client_data);
-	if (ret < 0) {
-		mutex_unlock(&notifier_mutex);
-		pr_err("%s: audio_notifer_reg_client for client %s failed ret = %d\n",
-			__func__, client_data->client_name,
-			ret);
-		kfree(client_data);
-		goto done;
-	}
-	list_add_tail(&client_data->list, &client_list);
-	mutex_unlock(&notifier_mutex);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(audio_notifier_register);
-
-static int __init audio_notifier_subsys_init(void)
-{
-	int i, j;
-
-	mutex_init(&notifier_mutex);
-	INIT_LIST_HEAD(&client_list);
-	for (i = 0; i < AUDIO_NOTIFIER_MAX_SERVICES; i++) {
-		for (j = 0; j < AUDIO_NOTIFIER_MAX_DOMAINS; j++) {
-			if (service_data[i][j].state <= NO_SERVICE)
-				continue;
-
-			srcu_init_notifier_head(
-				&service_data[i][j].client_nb_list);
-		}
-	}
-
-	return 0;
-}
-subsys_initcall(audio_notifier_subsys_init);
-
-static int __init audio_notifier_init(void)
-{
-	int ret;
-
-	ret = audio_pdr_register(&pdr_nb);
-	if (ret < 0) {
-		pr_debug("%s: PDR register failed, ret = %d, disable service\n",
-			__func__, ret);
-		audio_notifer_disable_service(AUDIO_NOTIFIER_PDR_SERVICE);
-	}
-
-	/* Do not return error since PDR enablement is not critical */
-	return 0;
-}
-module_init(audio_notifier_init);
-
-static int __init audio_notifier_late_init(void)
-{
-	/*
-	 * If pdr registration failed, register clients on next service
-	 * Do in late init to ensure that SSR subsystem is initialized
-	 */
-	mutex_lock(&notifier_mutex);
-	if (!audio_notifer_is_service_enabled(AUDIO_NOTIFIER_PDR_SERVICE))
-		audio_notifer_reg_all_clients();
-
-	mutex_unlock(&notifier_mutex);
-	return 0;
-}
-late_initcall(audio_notifier_late_init);
diff --git a/drivers/soc/qcom/qdsp6v2/audio_pdr.c b/drivers/soc/qcom/qdsp6v2/audio_pdr.c
deleted file mode 100644
index 449d19a..0000000
--- a/drivers/soc/qcom/qdsp6v2/audio_pdr.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/qdsp6v2/audio_pdr.h>
-#include <soc/qcom/service-locator.h>
-#include <soc/qcom/service-notifier.h>
-
-static struct pd_qmi_client_data audio_pdr_services[AUDIO_PDR_DOMAIN_MAX] = {
-	{	/* AUDIO_PDR_DOMAIN_ADSP */
-		.client_name = "audio_pdr_adsp",
-		.service_name = "avs/audio"
-	}
-};
-
-struct srcu_notifier_head audio_pdr_cb_list;
-
-static int audio_pdr_locator_callback(struct notifier_block *this,
-				      unsigned long opcode, void *data)
-{
-	unsigned long pdr_state = AUDIO_PDR_FRAMEWORK_DOWN;
-
-	if (opcode == LOCATOR_DOWN) {
-		pr_debug("%s: Service %s is down!", __func__,
-			audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].
-			service_name);
-		goto done;
-	}
-
-	memcpy(&audio_pdr_services, data,
-		sizeof(audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP]));
-	if (audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].total_domains == 1) {
-		pr_debug("%s: Service %s, returned total domains %d, ",
-			__func__,
-			audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].service_name,
-			audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].
-			total_domains);
-		pdr_state = AUDIO_PDR_FRAMEWORK_UP;
-		goto done;
-	} else
-		pr_err("%s: Service %s returned invalid total domains %d",
-			__func__,
-			audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].service_name,
-			audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].
-			total_domains);
-done:
-	srcu_notifier_call_chain(&audio_pdr_cb_list, pdr_state, NULL);
-	return NOTIFY_OK;
-}
-
-static struct notifier_block audio_pdr_locator_nb = {
-	.notifier_call = audio_pdr_locator_callback,
-	.priority = 0,
-};
-
-int audio_pdr_register(struct notifier_block *nb)
-{
-	if (nb == NULL) {
-		pr_err("%s: Notifier block is NULL\n", __func__);
-		return -EINVAL;
-	}
-	return srcu_notifier_chain_register(&audio_pdr_cb_list, nb);
-}
-EXPORT_SYMBOL(audio_pdr_register);
-
-void *audio_pdr_service_register(int domain_id,
-				 struct notifier_block *nb, int *curr_state)
-{
-	void *handle;
-
-	if ((domain_id < 0) ||
-	    (domain_id >= AUDIO_PDR_DOMAIN_MAX)) {
-		pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
-		return ERR_PTR(-EINVAL);
-	}
-
-	handle = service_notif_register_notifier(
-		audio_pdr_services[domain_id].domain_list[0].name,
-		audio_pdr_services[domain_id].domain_list[0].instance_id,
-		nb, curr_state);
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: Failed to register for service %s, instance %d\n",
-			__func__,
-			audio_pdr_services[domain_id].domain_list[0].name,
-			audio_pdr_services[domain_id].domain_list[0].
-			instance_id);
-	}
-	return handle;
-}
-EXPORT_SYMBOL(audio_pdr_service_register);
-
-int audio_pdr_service_deregister(void *service_handle,
-	struct notifier_block *nb)
-{
-	int ret;
-
-	if (service_handle == NULL) {
-		pr_err("%s: service handle is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = service_notif_unregister_notifier(
-		service_handle, nb);
-	if (ret < 0)
-		pr_err("%s: Failed to deregister service ret %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(audio_pdr_service_deregister);
-
-static int __init audio_pdr_subsys_init(void)
-{
-	srcu_init_notifier_head(&audio_pdr_cb_list);
-	return 0;
-}
-subsys_initcall(audio_pdr_subsys_init);
-
-static int __init audio_pdr_late_init(void)
-{
-	int ret;
-
-	ret = get_service_location(
-		audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].client_name,
-		audio_pdr_services[AUDIO_PDR_DOMAIN_ADSP].service_name,
-		&audio_pdr_locator_nb);
-	if (ret < 0) {
-		pr_err("%s get_service_location failed ret %d\n",
-			__func__, ret);
-		srcu_notifier_call_chain(&audio_pdr_cb_list,
-					 AUDIO_PDR_FRAMEWORK_DOWN, NULL);
-	}
-
-	return ret;
-}
-late_initcall(audio_pdr_late_init);
diff --git a/drivers/soc/qcom/qdsp6v2/audio_ssr.c b/drivers/soc/qcom/qdsp6v2/audio_ssr.c
deleted file mode 100644
index a66fb2a..0000000
--- a/drivers/soc/qcom/qdsp6v2/audio_ssr.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/qdsp6v2/audio_ssr.h>
-#include <soc/qcom/scm.h>
-#include <soc/qcom/subsystem_restart.h>
-#include <soc/qcom/subsystem_notif.h>
-
-#define SCM_Q6_NMI_CMD 0x1
-
-static char *audio_ssr_domains[] = {
-	"adsp",
-	"modem"
-};
-
-void *audio_ssr_register(int domain_id, struct notifier_block *nb)
-{
-	if ((domain_id < 0) ||
-	    (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
-		pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
-		return ERR_PTR(-EINVAL);
-	}
-
-	return subsys_notif_register_notifier(
-		audio_ssr_domains[domain_id], nb);
-}
-EXPORT_SYMBOL(audio_ssr_register);
-
-int audio_ssr_deregister(void *handle, struct notifier_block *nb)
-{
-	return subsys_notif_unregister_notifier(handle, nb);
-}
-EXPORT_SYMBOL(audio_ssr_deregister);
-
-void audio_ssr_send_nmi(void *ssr_cb_data)
-{
-	struct notif_data *data = (struct notif_data *)ssr_cb_data;
-	struct scm_desc desc;
-
-	if (data && data->crashed) {
-		/* Send NMI to QDSP6 via an SCM call. */
-		if (!is_scm_armv8()) {
-			scm_call_atomic1(SCM_SVC_UTIL,
-					 SCM_Q6_NMI_CMD, 0x1);
-		} else {
-			desc.args[0] = 0x1;
-			desc.arginfo = SCM_ARGS(1);
-			scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_UTIL,
-					 SCM_Q6_NMI_CMD), &desc);
-		}
-		/* The write should go through before q6 is shutdown */
-		mb();
-		pr_debug("%s: Q6 NMI was sent.\n", __func__);
-	}
-}
-EXPORT_SYMBOL(audio_ssr_send_nmi);
diff --git a/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c b/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c
deleted file mode 100644
index 2f14c74..0000000
--- a/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c
+++ /dev/null
@@ -1,853 +0,0 @@
-/*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-#include <linux/list.h>
-#include <linux/dma-mapping.h>
-#include <linux/dma-buf.h>
-#include <linux/iommu.h>
-#include <linux/platform_device.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/of_device.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/export.h>
-#include <asm/dma-iommu.h>
-
-#define MSM_AUDIO_ION_PROBED (1 << 0)
-
-#define MSM_AUDIO_ION_PHYS_ADDR(alloc_data) \
-	alloc_data->table->sgl->dma_address
-
-#define MSM_AUDIO_ION_VA_START 0x10000000
-#define MSM_AUDIO_ION_VA_LEN 0x0FFFFFFF
-
-#define MSM_AUDIO_SMMU_SID_OFFSET 32
-
-struct msm_audio_ion_private {
-	bool smmu_enabled;
-	bool audioheap_enabled;
-	struct device *cb_dev;
-	struct dma_iommu_mapping *mapping;
-	u8 device_status;
-	struct list_head alloc_list;
-	struct mutex list_mutex;
-	u64 smmu_sid_bits;
-	u32 smmu_version;
-};
-
-struct msm_audio_alloc_data {
-	struct ion_client *client;
-	struct ion_handle *handle;
-	size_t len;
-	struct dma_buf *dma_buf;
-	struct dma_buf_attachment *attach;
-	struct sg_table *table;
-	struct list_head list;
-};
-
-static struct msm_audio_ion_private msm_audio_ion_data = {0,};
-
-static int msm_audio_ion_get_phys(struct ion_client *client,
-				  struct ion_handle *handle,
-				  ion_phys_addr_t *addr, size_t *len);
-
-static int msm_audio_dma_buf_map(struct ion_client *client,
-				  struct ion_handle *handle,
-				  ion_phys_addr_t *addr, size_t *len);
-
-static int msm_audio_dma_buf_unmap(struct ion_client *client,
-				   struct ion_handle *handle);
-
-static void msm_audio_ion_add_allocation(
-	struct msm_audio_ion_private *msm_audio_ion_data,
-	struct msm_audio_alloc_data *alloc_data)
-{
-	/*
-	 * Since these APIs can be invoked by multiple
-	 * clients, there is need to make sure the list
-	 * of allocations is always protected
-	 */
-	mutex_lock(&(msm_audio_ion_data->list_mutex));
-	list_add_tail(&(alloc_data->list),
-		      &(msm_audio_ion_data->alloc_list));
-	mutex_unlock(&(msm_audio_ion_data->list_mutex));
-}
-
-int msm_audio_ion_alloc(const char *name, struct ion_client **client,
-			struct ion_handle **handle, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr)
-{
-	int rc = -EINVAL;
-	unsigned long err_ion_ptr = 0;
-
-	if ((msm_audio_ion_data.smmu_enabled == true) &&
-	    !(msm_audio_ion_data.device_status & MSM_AUDIO_ION_PROBED)) {
-		pr_debug("%s:probe is not done, deferred\n", __func__);
-		return -EPROBE_DEFER;
-	}
-	if (!name || !client || !handle || !paddr || !vaddr
-		|| !bufsz || !pa_len) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	*client = msm_audio_ion_client_create(name);
-	if (IS_ERR_OR_NULL((void *)(*client))) {
-		pr_err("%s: ION create client for AUDIO failed\n", __func__);
-		goto err;
-	}
-
-	*handle = ion_alloc(*client, bufsz, SZ_4K,
-			ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL((void *) (*handle))) {
-		if (msm_audio_ion_data.smmu_enabled == true) {
-			pr_debug("system heap is used");
-			msm_audio_ion_data.audioheap_enabled = 0;
-			*handle = ion_alloc(*client, bufsz, SZ_4K,
-					ION_HEAP(ION_SYSTEM_HEAP_ID), 0);
-		}
-		if (IS_ERR_OR_NULL((void *) (*handle))) {
-			if (IS_ERR((void *)(*handle)))
-				err_ion_ptr = PTR_ERR((int *)(*handle));
-			pr_err("%s:ION alloc fail err ptr=%ld, smmu_enabled=%d\n",
-			__func__, err_ion_ptr, msm_audio_ion_data.smmu_enabled);
-			rc = -ENOMEM;
-			goto err_ion_client;
-		}
-	} else {
-		pr_debug("audio heap is used");
-		msm_audio_ion_data.audioheap_enabled = 1;
-	}
-
-	rc = msm_audio_ion_get_phys(*client, *handle, paddr, pa_len);
-	if (rc) {
-		pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
-			__func__, rc);
-		goto err_ion_handle;
-	}
-
-	*vaddr = ion_map_kernel(*client, *handle);
-	if (IS_ERR_OR_NULL((void *)*vaddr)) {
-		pr_err("%s: ION memory mapping for AUDIO failed\n", __func__);
-		goto err_ion_handle;
-	}
-	pr_debug("%s: mapped address = %pK, size=%zd\n", __func__,
-		*vaddr, bufsz);
-
-	if (bufsz != 0) {
-		pr_debug("%s: memset to 0 %pK %zd\n", __func__, *vaddr, bufsz);
-		memset((void *)*vaddr, 0, bufsz);
-	}
-
-	return rc;
-
-err_ion_handle:
-	ion_free(*client, *handle);
-err_ion_client:
-	msm_audio_ion_client_destroy(*client);
-	*handle = NULL;
-	*client = NULL;
-err:
-	return rc;
-}
-EXPORT_SYMBOL(msm_audio_ion_alloc);
-
-int msm_audio_ion_import(const char *name, struct ion_client **client,
-			struct ion_handle **handle, int fd,
-			unsigned long *ionflag, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr)
-{
-	int rc = 0;
-
-	if ((msm_audio_ion_data.smmu_enabled == true) &&
-	    !(msm_audio_ion_data.device_status & MSM_AUDIO_ION_PROBED)) {
-		pr_debug("%s:probe is not done, deferred\n", __func__);
-		return -EPROBE_DEFER;
-	}
-
-	if (!name || !client || !handle || !paddr || !vaddr || !pa_len) {
-		pr_err("%s: Invalid params\n", __func__);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	*client = msm_audio_ion_client_create(name);
-	if (IS_ERR_OR_NULL((void *)(*client))) {
-		pr_err("%s: ION create client for AUDIO failed\n", __func__);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	/* name should be audio_acdb_client or Audio_Dec_Client,
-	 * bufsz should be 0 and fd shouldn't be 0 as of now
-	 */
-	*handle = ion_import_dma_buf_fd(*client, fd);
-	pr_debug("%s: DMA Buf name=%s, fd=%d handle=%pK\n", __func__,
-							name, fd, *handle);
-	if (IS_ERR_OR_NULL((void *) (*handle))) {
-		pr_err("%s: ion import dma buffer failed\n",
-				__func__);
-		rc = -EINVAL;
-		goto err_destroy_client;
-	}
-
-	if (ionflag != NULL) {
-		rc = ion_handle_get_flags(*client, *handle, ionflag);
-		if (rc) {
-			pr_err("%s: could not get flags for the handle\n",
-				__func__);
-			goto err_ion_handle;
-		}
-	}
-
-	rc = msm_audio_ion_get_phys(*client, *handle, paddr, pa_len);
-	if (rc) {
-		pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
-				__func__, rc);
-		goto err_ion_handle;
-	}
-
-	*vaddr = ion_map_kernel(*client, *handle);
-	if (IS_ERR_OR_NULL((void *)*vaddr)) {
-		pr_err("%s: ION memory mapping for AUDIO failed\n", __func__);
-		rc = -ENOMEM;
-		goto err_ion_handle;
-	}
-	pr_debug("%s: mapped address = %pK, size=%zd\n", __func__,
-		*vaddr, bufsz);
-
-	return 0;
-
-err_ion_handle:
-	ion_free(*client, *handle);
-err_destroy_client:
-	msm_audio_ion_client_destroy(*client);
-	*client = NULL;
-	*handle = NULL;
-err:
-	return rc;
-}
-
-int msm_audio_ion_free(struct ion_client *client, struct ion_handle *handle)
-{
-	if (!client || !handle) {
-		pr_err("%s Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	if (msm_audio_ion_data.smmu_enabled)
-		msm_audio_dma_buf_unmap(client, handle);
-
-	ion_unmap_kernel(client, handle);
-
-	ion_free(client, handle);
-	msm_audio_ion_client_destroy(client);
-	return 0;
-}
-EXPORT_SYMBOL(msm_audio_ion_free);
-
-int msm_audio_ion_mmap(struct audio_buffer *ab,
-		       struct vm_area_struct *vma)
-{
-	struct sg_table *table;
-	unsigned long addr = vma->vm_start;
-	unsigned long offset = vma->vm_pgoff * PAGE_SIZE;
-	struct scatterlist *sg;
-	unsigned int i;
-	struct page *page;
-	int ret;
-
-	pr_debug("%s\n", __func__);
-
-	table = ion_sg_table(ab->client, ab->handle);
-
-	if (IS_ERR(table)) {
-		pr_err("%s: Unable to get sg_table from ion: %ld\n",
-			__func__, PTR_ERR(table));
-		return PTR_ERR(table);
-	} else if (!table) {
-		pr_err("%s: sg_list is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	/* uncached */
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-
-	/* We need to check if a page is associated with this sg list because:
-	 * If the allocation came from a carveout we currently don't have
-	 * pages associated with carved out memory. This might change in the
-	 * future and we can remove this check and the else statement.
-	 */
-	page = sg_page(table->sgl);
-	if (page) {
-		pr_debug("%s: page is NOT null\n", __func__);
-		for_each_sg(table->sgl, sg, table->nents, i) {
-			unsigned long remainder = vma->vm_end - addr;
-			unsigned long len = sg->length;
-
-			page = sg_page(sg);
-
-			if (offset >= len) {
-				offset -= len;
-				continue;
-			} else if (offset) {
-				page += offset / PAGE_SIZE;
-				len -= offset;
-				offset = 0;
-			}
-			len = min(len, remainder);
-			pr_debug("vma=%pK, addr=%x len=%ld vm_start=%x vm_end=%x vm_page_prot=%lu\n",
-				vma, (unsigned int)addr, len,
-				(unsigned int)vma->vm_start,
-				(unsigned int)vma->vm_end,
-				(unsigned long)vma->vm_page_prot.pgprot);
-			remap_pfn_range(vma, addr, page_to_pfn(page), len,
-					vma->vm_page_prot);
-			addr += len;
-			if (addr >= vma->vm_end)
-				return 0;
-		}
-	} else {
-		ion_phys_addr_t phys_addr;
-		size_t phys_len;
-		size_t va_len = 0;
-
-		pr_debug("%s: page is NULL\n", __func__);
-		ret = ion_phys(ab->client, ab->handle, &phys_addr, &phys_len);
-		if (ret) {
-			pr_err("%s: Unable to get phys address from ION buffer: %d\n"
-				, __func__, ret);
-			return ret;
-		}
-		pr_debug("phys=%pKK len=%zd\n", &phys_addr, phys_len);
-		pr_debug("vma=%pK, vm_start=%x vm_end=%x vm_pgoff=%ld vm_page_prot=%lu\n",
-			vma, (unsigned int)vma->vm_start,
-			(unsigned int)vma->vm_end, vma->vm_pgoff,
-			(unsigned long)vma->vm_page_prot.pgprot);
-		va_len = vma->vm_end - vma->vm_start;
-		if ((offset > phys_len) || (va_len > phys_len-offset)) {
-			pr_err("wrong offset size %ld, lens= %zd, va_len=%zd\n",
-				offset, phys_len, va_len);
-			return -EINVAL;
-		}
-		ret =  remap_pfn_range(vma, vma->vm_start,
-				__phys_to_pfn(phys_addr) + vma->vm_pgoff,
-				vma->vm_end - vma->vm_start,
-				vma->vm_page_prot);
-	}
-	return 0;
-}
-
-
-bool msm_audio_ion_is_smmu_available(void)
-{
-	return msm_audio_ion_data.smmu_enabled;
-}
-
-/* move to static section again */
-struct ion_client *msm_audio_ion_client_create(const char *name)
-{
-	struct ion_client *pclient = NULL;
-
-	pclient = msm_ion_client_create(name);
-	return pclient;
-}
-
-
-void msm_audio_ion_client_destroy(struct ion_client *client)
-{
-	pr_debug("%s: client = %pK smmu_enabled = %d\n", __func__,
-		client, msm_audio_ion_data.smmu_enabled);
-
-	ion_client_destroy(client);
-}
-
-int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
-			struct ion_handle **handle, int fd,
-			unsigned long *ionflag, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr)
-{
-	int rc = 0;
-
-	if (!name || !client || !handle || !paddr || !vaddr || !pa_len) {
-		pr_err("%s: Invalid params\n", __func__);
-		rc = -EINVAL;
-		goto err;
-	}
-	/* client is already created for legacy and given
-	 * name should be audio_acdb_client or Audio_Dec_Client,
-	 * bufsz should be 0 and fd shouldn't be 0 as of now
-	 */
-	*handle = ion_import_dma_buf_fd(client, fd);
-	pr_debug("%s: DMA Buf name=%s, fd=%d handle=%pK\n", __func__,
-							name, fd, *handle);
-	if (IS_ERR_OR_NULL((void *)(*handle))) {
-		pr_err("%s: ion import dma buffer failed\n",
-			__func__);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	if (ionflag != NULL) {
-		rc = ion_handle_get_flags(client, *handle, ionflag);
-		if (rc) {
-			pr_err("%s: could not get flags for the handle\n",
-							__func__);
-			rc = -EINVAL;
-			goto err_ion_handle;
-		}
-	}
-
-	rc = msm_audio_ion_get_phys(client, *handle, paddr, pa_len);
-	if (rc) {
-		pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
-			__func__, rc);
-		rc = -EINVAL;
-		goto err_ion_handle;
-	}
-
-	/*Need to add condition SMMU enable or not */
-	*vaddr = ion_map_kernel(client, *handle);
-	if (IS_ERR_OR_NULL((void *)*vaddr)) {
-		pr_err("%s: ION memory mapping for AUDIO failed\n", __func__);
-		rc = -EINVAL;
-		goto err_ion_handle;
-	}
-
-	if (bufsz != 0)
-		memset((void *)*vaddr, 0, bufsz);
-
-	return 0;
-
-err_ion_handle:
-	ion_free(client, *handle);
-err:
-	return rc;
-}
-
-int msm_audio_ion_free_legacy(struct ion_client *client,
-			      struct ion_handle *handle)
-{
-	if (msm_audio_ion_data.smmu_enabled)
-		msm_audio_dma_buf_unmap(client, handle);
-
-	ion_unmap_kernel(client, handle);
-
-	ion_free(client, handle);
-	/* no client_destrody in legacy*/
-	return 0;
-}
-
-int msm_audio_ion_cache_operations(struct audio_buffer *abuff, int cache_op)
-{
-	unsigned long ionflag = 0;
-	int rc = 0;
-	int msm_cache_ops = 0;
-
-	if (!abuff) {
-		pr_err("%s: Invalid params: %pK\n", __func__, abuff);
-		return -EINVAL;
-	}
-	rc = ion_handle_get_flags(abuff->client, abuff->handle,
-		&ionflag);
-	if (rc) {
-		pr_err("ion_handle_get_flags failed: %d\n", rc);
-		goto cache_op_failed;
-	}
-
-	/* has to be CACHED */
-	if (ION_IS_CACHED(ionflag)) {
-		/* ION_IOC_INV_CACHES or ION_IOC_CLEAN_CACHES */
-		msm_cache_ops = cache_op;
-		rc = msm_ion_do_cache_op(abuff->client,
-				abuff->handle,
-				(unsigned long *) abuff->data,
-				(unsigned long)abuff->size,
-				msm_cache_ops);
-		if (rc) {
-			pr_err("cache operation failed %d\n", rc);
-			goto cache_op_failed;
-		}
-	}
-cache_op_failed:
-	return rc;
-}
-
-
-static int msm_audio_dma_buf_map(struct ion_client *client,
-		struct ion_handle *handle,
-		ion_phys_addr_t *addr, size_t *len)
-{
-
-	struct msm_audio_alloc_data *alloc_data;
-	struct device *cb_dev;
-	int rc = 0;
-
-	cb_dev = msm_audio_ion_data.cb_dev;
-
-	/* Data required per buffer mapping */
-	alloc_data = kzalloc(sizeof(*alloc_data), GFP_KERNEL);
-	if (!alloc_data)
-		return -ENOMEM;
-
-	/* Get the ION handle size */
-	ion_handle_get_size(client, handle, len);
-
-	alloc_data->client = client;
-	alloc_data->handle = handle;
-	alloc_data->len = *len;
-
-	/* Get the dma_buf handle from ion_handle */
-	alloc_data->dma_buf = ion_share_dma_buf(client, handle);
-	if (IS_ERR(alloc_data->dma_buf)) {
-		rc = PTR_ERR(alloc_data->dma_buf);
-		dev_err(cb_dev,
-			"%s: Fail to get dma_buf handle, rc = %d\n",
-			__func__, rc);
-		goto err_dma_buf;
-	}
-
-	/* Attach the dma_buf to context bank device */
-	alloc_data->attach = dma_buf_attach(alloc_data->dma_buf,
-					    cb_dev);
-	if (IS_ERR(alloc_data->attach)) {
-		rc = PTR_ERR(alloc_data->attach);
-		dev_err(cb_dev,
-			"%s: Fail to attach dma_buf to CB, rc = %d\n",
-			__func__, rc);
-		goto err_attach;
-	}
-
-	/*
-	 * Get the scatter-gather list.
-	 * There is no info as this is a write buffer or
-	 * read buffer, hence the request is bi-directional
-	 * to accommodate both read and write mappings.
-	 */
-	alloc_data->table = dma_buf_map_attachment(alloc_data->attach,
-				DMA_BIDIRECTIONAL);
-	if (IS_ERR(alloc_data->table)) {
-		rc = PTR_ERR(alloc_data->table);
-		dev_err(cb_dev,
-			"%s: Fail to map attachment, rc = %d\n",
-			__func__, rc);
-		goto err_map_attach;
-	}
-
-	rc = dma_map_sg(cb_dev, alloc_data->table->sgl,
-			alloc_data->table->nents,
-			DMA_BIDIRECTIONAL);
-	if (rc != alloc_data->table->nents) {
-		dev_err(cb_dev,
-			"%s: Fail to map SG, rc = %d, nents = %d\n",
-			__func__, rc, alloc_data->table->nents);
-		goto err_map_sg;
-	}
-	/* Make sure not to return rc from dma_map_sg, as it can be nonzero */
-	rc = 0;
-
-	/* physical address from mapping */
-	*addr = MSM_AUDIO_ION_PHYS_ADDR(alloc_data);
-
-	msm_audio_ion_add_allocation(&msm_audio_ion_data,
-				     alloc_data);
-	return rc;
-
-err_map_sg:
-	dma_buf_unmap_attachment(alloc_data->attach,
-				 alloc_data->table,
-				 DMA_BIDIRECTIONAL);
-err_map_attach:
-	dma_buf_detach(alloc_data->dma_buf,
-		       alloc_data->attach);
-err_attach:
-	dma_buf_put(alloc_data->dma_buf);
-
-err_dma_buf:
-	kfree(alloc_data);
-
-	return rc;
-}
-
-static int msm_audio_dma_buf_unmap(struct ion_client *client,
-				   struct ion_handle *handle)
-{
-	int rc = 0;
-	struct msm_audio_alloc_data *alloc_data = NULL;
-	struct list_head *ptr, *next;
-	struct device *cb_dev = msm_audio_ion_data.cb_dev;
-	bool found = false;
-
-	/*
-	 * Though list_for_each_safe is delete safe, lock
-	 * should be explicitly acquired to avoid race condition
-	 * on adding elements to the list.
-	 */
-	mutex_lock(&(msm_audio_ion_data.list_mutex));
-	list_for_each_safe(ptr, next,
-			    &(msm_audio_ion_data.alloc_list)) {
-
-		alloc_data = list_entry(ptr, struct msm_audio_alloc_data,
-					list);
-
-		if (alloc_data->handle == handle &&
-		    alloc_data->client == client) {
-			found = true;
-			dma_unmap_sg(cb_dev,
-				    alloc_data->table->sgl,
-				    alloc_data->table->nents,
-				    DMA_BIDIRECTIONAL);
-
-			dma_buf_unmap_attachment(alloc_data->attach,
-						 alloc_data->table,
-						 DMA_BIDIRECTIONAL);
-
-			dma_buf_detach(alloc_data->dma_buf,
-				       alloc_data->attach);
-
-			dma_buf_put(alloc_data->dma_buf);
-
-			list_del(&(alloc_data->list));
-			kfree(alloc_data);
-			break;
-		}
-	}
-	mutex_unlock(&(msm_audio_ion_data.list_mutex));
-
-	if (!found) {
-		dev_err(cb_dev,
-			"%s: cannot find allocation, ion_handle %pK, ion_client %pK",
-			__func__, handle, client);
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-
-static int msm_audio_ion_get_phys(struct ion_client *client,
-		struct ion_handle *handle,
-		ion_phys_addr_t *addr, size_t *len)
-{
-	int rc = 0;
-
-	pr_debug("%s: smmu_enabled = %d\n", __func__,
-		msm_audio_ion_data.smmu_enabled);
-
-	if (msm_audio_ion_data.smmu_enabled) {
-		rc = msm_audio_dma_buf_map(client, handle, addr, len);
-		if (rc) {
-			pr_err("%s: failed to map DMA buf, err = %d\n",
-				__func__, rc);
-			goto err;
-		}
-		/* Append the SMMU SID information to the IOVA address */
-		*addr |= msm_audio_ion_data.smmu_sid_bits;
-	} else {
-		rc = ion_phys(client, handle, addr, len);
-	}
-
-	pr_debug("phys=%pK, len=%zd, rc=%d\n", &(*addr), *len, rc);
-err:
-	return rc;
-}
-
-static int msm_audio_smmu_init(struct device *dev)
-{
-	struct dma_iommu_mapping *mapping;
-	int ret;
-
-	mapping = arm_iommu_create_mapping(&platform_bus_type,
-					   MSM_AUDIO_ION_VA_START,
-					   MSM_AUDIO_ION_VA_LEN);
-	if (IS_ERR(mapping))
-		return PTR_ERR(mapping);
-
-	ret = arm_iommu_attach_device(dev, mapping);
-	if (ret) {
-		dev_err(dev, "%s: Attach failed, err = %d\n",
-			__func__, ret);
-		goto fail_attach;
-	}
-
-	msm_audio_ion_data.cb_dev = dev;
-	msm_audio_ion_data.mapping = mapping;
-	INIT_LIST_HEAD(&msm_audio_ion_data.alloc_list);
-	mutex_init(&(msm_audio_ion_data.list_mutex));
-
-	return 0;
-
-fail_attach:
-	arm_iommu_release_mapping(mapping);
-	return ret;
-}
-
-static const struct of_device_id msm_audio_ion_dt_match[] = {
-	{ .compatible = "qcom,msm-audio-ion" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, msm_audio_ion_dt_match);
-
-
-u32 msm_audio_ion_get_smmu_sid_mode32(void)
-{
-	if (msm_audio_ion_data.smmu_enabled)
-		return upper_32_bits(msm_audio_ion_data.smmu_sid_bits);
-	else
-		return 0;
-}
-
-u32 msm_audio_populate_upper_32_bits(ion_phys_addr_t pa)
-{
-	if (sizeof(ion_phys_addr_t) == sizeof(u32))
-		return msm_audio_ion_get_smmu_sid_mode32();
-	else
-		return upper_32_bits(pa);
-}
-
-static int msm_audio_ion_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	const char *msm_audio_ion_dt = "qcom,smmu-enabled";
-	const char *msm_audio_ion_smmu = "qcom,smmu-version";
-	const char *msm_audio_ion_smmu_sid_mask = "qcom,smmu-sid-mask";
-	bool smmu_enabled;
-	enum apr_subsys_state q6_state;
-	struct device *dev = &pdev->dev;
-
-	if (dev->of_node == NULL) {
-		dev_err(dev,
-			"%s: device tree is not found\n",
-			__func__);
-		msm_audio_ion_data.smmu_enabled = 0;
-		return 0;
-	}
-
-	smmu_enabled = of_property_read_bool(dev->of_node,
-					     msm_audio_ion_dt);
-	msm_audio_ion_data.smmu_enabled = smmu_enabled;
-
-	if (smmu_enabled) {
-		rc = of_property_read_u32(dev->of_node,
-					msm_audio_ion_smmu,
-					&msm_audio_ion_data.smmu_version);
-		if (rc) {
-			dev_err(dev,
-				"%s: qcom,smmu_version missing in DT node\n",
-				__func__);
-			return rc;
-		}
-		dev_dbg(dev, "%s: SMMU version is (%d)", __func__,
-				msm_audio_ion_data.smmu_version);
-		q6_state = apr_get_q6_state();
-		if (q6_state == APR_SUBSYS_DOWN) {
-			dev_dbg(dev,
-				"defering %s, adsp_state %d\n",
-				__func__, q6_state);
-			return -EPROBE_DEFER;
-		}
-		dev_dbg(dev, "%s: adsp is ready\n", __func__);
-	}
-
-	dev_dbg(dev, "%s: SMMU is %s\n", __func__,
-		(smmu_enabled) ? "Enabled" : "Disabled");
-
-	if (smmu_enabled) {
-		u64 smmu_sid = 0;
-		u64 smmu_sid_mask = 0;
-		struct of_phandle_args iommuspec;
-
-		/* Get SMMU SID information from Devicetree */
-		rc = of_property_read_u64(dev->of_node,
-					  msm_audio_ion_smmu_sid_mask,
-					  &smmu_sid_mask);
-		if (rc) {
-			dev_err(dev,
-				"%s: qcom,smmu-sid-mask missing in DT node, using default\n",
-				__func__);
-			smmu_sid_mask = 0xFFFFFFFFFFFFFFFF;
-		}
-		rc = of_parse_phandle_with_args(dev->of_node, "iommus",
-						"#iommu-cells", 0, &iommuspec);
-		if (rc)
-			dev_err(dev, "%s: could not get smmu SID, ret = %d\n",
-				__func__, rc);
-		else
-			smmu_sid = (iommuspec.args[0] & smmu_sid_mask);
-
-		msm_audio_ion_data.smmu_sid_bits =
-			smmu_sid << MSM_AUDIO_SMMU_SID_OFFSET;
-
-		if (msm_audio_ion_data.smmu_version == 0x2) {
-			rc = msm_audio_smmu_init(dev);
-		} else {
-			dev_err(dev, "%s: smmu version invalid %d\n",
-				__func__, msm_audio_ion_data.smmu_version);
-			rc = -EINVAL;
-		}
-		if (rc)
-			dev_err(dev, "%s: smmu init failed, err = %d\n",
-				__func__, rc);
-	}
-
-	if (!rc)
-		msm_audio_ion_data.device_status |= MSM_AUDIO_ION_PROBED;
-
-	return rc;
-}
-
-static int msm_audio_ion_remove(struct platform_device *pdev)
-{
-	struct dma_iommu_mapping *mapping;
-	struct device *audio_cb_dev;
-
-	mapping = msm_audio_ion_data.mapping;
-	audio_cb_dev = msm_audio_ion_data.cb_dev;
-
-	if (audio_cb_dev && mapping) {
-		arm_iommu_detach_device(audio_cb_dev);
-		arm_iommu_release_mapping(mapping);
-	}
-
-	msm_audio_ion_data.smmu_enabled = 0;
-	msm_audio_ion_data.device_status = 0;
-	return 0;
-}
-
-static struct platform_driver msm_audio_ion_driver = {
-	.driver = {
-		.name = "msm-audio-ion",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_audio_ion_dt_match,
-	},
-	.probe = msm_audio_ion_probe,
-	.remove = msm_audio_ion_remove,
-};
-
-static int __init msm_audio_ion_init(void)
-{
-	return platform_driver_register(&msm_audio_ion_driver);
-}
-module_init(msm_audio_ion_init);
-
-static void __exit msm_audio_ion_exit(void)
-{
-	platform_driver_unregister(&msm_audio_ion_driver);
-}
-module_exit(msm_audio_ion_exit);
-
-MODULE_DESCRIPTION("MSM Audio ION module");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/soc/qcom/ramdump.c b/drivers/soc/qcom/ramdump.c
index dd77062..e4c1bb8 100644
--- a/drivers/soc/qcom/ramdump.c
+++ b/drivers/soc/qcom/ramdump.c
@@ -38,6 +38,8 @@
 static DEFINE_IDA(rd_minor_id);
 static bool ramdump_devnode_inited;
 #define RAMDUMP_WAIT_MSECS	120000
+#define MAX_STRTBL_SIZE 512
+#define MAX_NAME_LENGTH 16
 
 struct ramdump_device {
 	char name[256];
@@ -452,12 +454,143 @@
 
 }
 
+static inline struct elf_shdr *elf_sheader(struct elfhdr *hdr)
+{
+	return (struct elf_shdr *)((size_t)hdr + (size_t)hdr->e_shoff);
+}
+
+static inline struct elf_shdr *elf_section(struct elfhdr *hdr, int idx)
+{
+	return &elf_sheader(hdr)[idx];
+}
+
+static inline char *elf_str_table(struct elfhdr *hdr)
+{
+	if (hdr->e_shstrndx == SHN_UNDEF)
+		return NULL;
+	return (char *)hdr + elf_section(hdr, hdr->e_shstrndx)->sh_offset;
+}
+
+static inline unsigned int set_section_name(const char *name,
+					    struct elfhdr *ehdr)
+{
+	char *strtab = elf_str_table(ehdr);
+	static int strtable_idx = 1;
+	int idx, ret = 0;
+
+	idx = strtable_idx;
+	if ((strtab == NULL) || (name == NULL))
+		return 0;
+
+	ret = idx;
+	idx += strlcpy((strtab + idx), name, MAX_NAME_LENGTH);
+	strtable_idx = idx + 1;
+
+	return ret;
+}
+
+static int _do_minidump(void *handle, struct ramdump_segment *segments,
+		int nsegments)
+{
+	int ret, i;
+	struct ramdump_device *rd_dev = (struct ramdump_device *)handle;
+	struct elfhdr *ehdr;
+	struct elf_shdr *shdr;
+	unsigned long offset, strtbl_off;
+
+	if (!rd_dev->consumer_present) {
+		pr_err("Ramdump(%s): No consumers. Aborting..\n", rd_dev->name);
+		return -EPIPE;
+	}
+
+	rd_dev->segments = segments;
+	rd_dev->nsegments = nsegments;
+
+	rd_dev->elfcore_size = sizeof(*ehdr) +
+			(sizeof(*shdr) * (nsegments + 2)) + MAX_STRTBL_SIZE;
+	ehdr = kzalloc(rd_dev->elfcore_size, GFP_KERNEL);
+	rd_dev->elfcore_buf = (char *)ehdr;
+	if (!rd_dev->elfcore_buf)
+		return -ENOMEM;
+
+	memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
+	ehdr->e_ident[EI_CLASS] = ELF_CLASS;
+	ehdr->e_ident[EI_DATA] = ELF_DATA;
+	ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+	ehdr->e_ident[EI_OSABI] = ELF_OSABI;
+	ehdr->e_type = ET_CORE;
+	ehdr->e_machine  = ELF_ARCH;
+	ehdr->e_version = EV_CURRENT;
+	ehdr->e_ehsize = sizeof(*ehdr);
+	ehdr->e_shoff = sizeof(*ehdr);
+	ehdr->e_shentsize = sizeof(*shdr);
+	ehdr->e_shstrndx = 1;
+
+
+	offset = rd_dev->elfcore_size;
+	shdr = (struct elf_shdr *)(ehdr + 1);
+	strtbl_off = sizeof(*ehdr) + sizeof(*shdr) * (nsegments + 2);
+	shdr++;
+	shdr->sh_type = SHT_STRTAB;
+	shdr->sh_offset = (elf_addr_t)strtbl_off;
+	shdr->sh_size = MAX_STRTBL_SIZE;
+	shdr->sh_entsize = 0;
+	shdr->sh_flags = 0;
+	shdr->sh_name = set_section_name("STR_TBL", ehdr);
+	shdr++;
+
+	for (i = 0; i < nsegments; i++, shdr++) {
+		/* Update elf header */
+		shdr->sh_type = SHT_PROGBITS;
+		shdr->sh_name = set_section_name(segments[i].name, ehdr);
+		shdr->sh_addr = (elf_addr_t)segments[i].address;
+		shdr->sh_size = segments[i].size;
+		shdr->sh_flags = SHF_WRITE;
+		shdr->sh_offset = offset;
+		shdr->sh_entsize = 0;
+		offset += shdr->sh_size;
+	}
+	ehdr->e_shnum = nsegments + 2;
+
+	rd_dev->data_ready = 1;
+	rd_dev->ramdump_status = -1;
+
+	reinit_completion(&rd_dev->ramdump_complete);
+
+	/* Tell userspace that the data is ready */
+	wake_up(&rd_dev->dump_wait_q);
+
+	/* Wait (with a timeout) to let the ramdump complete */
+	ret = wait_for_completion_timeout(&rd_dev->ramdump_complete,
+			msecs_to_jiffies(RAMDUMP_WAIT_MSECS));
+
+	if (!ret) {
+		pr_err("Ramdump(%s): Timed out waiting for userspace.\n",
+		       rd_dev->name);
+		ret = -EPIPE;
+	} else {
+		ret = (rd_dev->ramdump_status == 0) ? 0 : -EPIPE;
+	}
+
+	rd_dev->data_ready = 0;
+	rd_dev->elfcore_size = 0;
+	kfree(rd_dev->elfcore_buf);
+	rd_dev->elfcore_buf = NULL;
+	return ret;
+}
+
 int do_ramdump(void *handle, struct ramdump_segment *segments, int nsegments)
 {
 	return _do_ramdump(handle, segments, nsegments, false);
 }
 EXPORT_SYMBOL(do_ramdump);
 
+int do_minidump(void *handle, struct ramdump_segment *segments, int nsegments)
+{
+	return _do_minidump(handle, segments, nsegments);
+}
+EXPORT_SYMBOL(do_minidump);
+
 int
 do_elf_ramdump(void *handle, struct ramdump_segment *segments, int nsegments)
 {
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 8a7043a6..f7902e1 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -563,7 +563,7 @@
 	spin_lock_irqsave(&rpm->lock, flags);
 	for (i = 0; rpm->passthru_cache[i]; i++) {
 		rpm_msg = rpm->passthru_cache[i];
-		ret = mbox_send_controller_data(rc->chan, &rpm_msg->msg);
+		ret = mbox_write_controller_data(rc->chan, &rpm_msg->msg);
 		if (ret)
 			goto fail;
 	}
@@ -591,7 +591,8 @@
 }
 
 /**
- * rpmh_write_passthru: Write multiple batches of RPMH commands without caching
+ * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the
+ * batch to finish.
  *
  * @rc: The RPMh handle got from rpmh_get_dev_channel
  * @state: Active/sleep set
@@ -606,7 +607,7 @@
  *
  * May sleep. Do not call from atomic contexts for ACTIVE_ONLY requests.
  */
-int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
+int rpmh_write_batch(struct rpmh_client *rc, enum rpmh_state state,
 			struct tcs_cmd *cmd, int *n)
 {
 	struct rpmh_msg *rpm_msg[RPMH_MAX_REQ_IN_BATCH] = { NULL };
@@ -695,7 +696,7 @@
 
 	return 0;
 }
-EXPORT_SYMBOL(rpmh_write_passthru);
+EXPORT_SYMBOL(rpmh_write_batch);
 
 /**
  * rpmh_mode_solver_set: Indicate that the RSC controller hardware has
@@ -761,7 +762,7 @@
 	rpm_msg.msg.is_control = true;
 	rpm_msg.msg.is_complete = false;
 
-	return mbox_send_controller_data(rc->chan, &rpm_msg.msg);
+	return mbox_write_controller_data(rc->chan, &rpm_msg.msg);
 }
 EXPORT_SYMBOL(rpmh_write_control);
 
@@ -796,7 +797,7 @@
 	rpm->dirty = true;
 	spin_unlock_irqrestore(&rpm->lock, flags);
 
-	return mbox_send_controller_data(rc->chan, &rpm_msg.msg);
+	return mbox_write_controller_data(rc->chan, &rpm_msg.msg);
 }
 EXPORT_SYMBOL(rpmh_invalidate);
 
@@ -885,7 +886,7 @@
 	rpm_msg.msg.num_payload = 1;
 	rpm_msg.msg.is_complete = false;
 
-	return mbox_send_controller_data(rc->chan, &rpm_msg.msg);
+	return mbox_write_controller_data(rc->chan, &rpm_msg.msg);
 }
 
 /**
diff --git a/drivers/soc/qcom/smp2p_spinlock_test.c b/drivers/soc/qcom/smp2p_spinlock_test.c
index 56a0af6..d1e5090 100644
--- a/drivers/soc/qcom/smp2p_spinlock_test.c
+++ b/drivers/soc/qcom/smp2p_spinlock_test.c
@@ -1,6 +1,6 @@
 /* drivers/soc/qcom/smp2p_spinlock_test.c
  *
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -523,7 +523,7 @@
 	int spinlock_owner = 0;
 
 	struct workqueue_struct *ws = NULL;
-	struct rmt_spinlock_work_item work_item;
+	struct rmt_spinlock_work_item work_item = { .has_locked = false };
 
 	seq_printf(s, " Running %s Test\n",
 		   __func__);
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index c69429c..c35119c 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -564,6 +564,7 @@
 
 	/* sdm845 ID */
 	[321] = {MSM_CPU_SDM845, "SDM845"},
+	[341] = {MSM_CPU_SDM845, "SDA845"},
 
 	/* sdxpoorwills ID */
 	[334] = {SDX_CPU_SDXPOORWILLS, "SDXPOORWILLS"},
@@ -571,6 +572,12 @@
 	/* SDM670 ID */
 	[336] = {MSM_CPU_SDM670, "SDM670"},
 
+	/* QCS605 ID */
+	[347] = {MSM_CPU_QCS605, "QCS605"},
+
+	/* SDA670 ID */
+	[337] = {MSM_CPU_SDA670, "SDA670"},
+
 	/* Uninitialized IDs are not known to run Linux.
 	 * MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
 	 * considered as unknown CPU.
@@ -1433,6 +1440,14 @@
 		dummy_socinfo.id = 336;
 		strlcpy(dummy_socinfo.build_id, "sdm670 - ",
 			sizeof(dummy_socinfo.build_id));
+	} else if (early_machine_is_sda670()) {
+		dummy_socinfo.id = 337;
+		strlcpy(dummy_socinfo.build_id, "sda670 - ",
+			sizeof(dummy_socinfo.build_id));
+	} else if (early_machine_is_qcs605()) {
+		dummy_socinfo.id = 347;
+		strlcpy(dummy_socinfo.build_id, "qcs605 - ",
+			sizeof(dummy_socinfo.build_id));
 	} else if (early_machine_is_sdxpoorwills()) {
 		dummy_socinfo.id = 334;
 		strlcpy(dummy_socinfo.build_id, "sdxpoorwills - ",
diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c
index 806b756..68681f9 100644
--- a/drivers/soc/qcom/spcom.c
+++ b/drivers/soc/qcom/spcom.c
@@ -206,10 +206,8 @@
 	 * Only one rx/tx transaction at a time (request + response).
 	 */
 	int ref_count;
-	u32 pid;
 
-	/* link UP/DOWN callback */
-	void (*notify_link_state_cb)(bool up);
+	u32 pid; /* debug only to find user space application */
 
 	/* abort flags */
 	bool rx_abort;
@@ -493,13 +491,10 @@
 
 		ch->glink_state = event;
 
-		/*
-		 * if spcom_notify_state() is called within glink_open()
-		 * then ch->glink_handle is not updated yet.
-		 */
-		if (!ch->glink_handle) {
-			pr_debug("update glink_handle, ch [%s].\n", ch->name);
-			ch->glink_handle = handle;
+		if (!handle) {
+			pr_err("inavlid glink_handle, ch [%s].\n", ch->name);
+			mutex_unlock(&ch->lock);
+			return;
 		}
 
 		/* signal before unlock mutex & before calling glink */
@@ -512,8 +507,7 @@
 		 */
 
 		pr_debug("call glink_queue_rx_intent() ch [%s].\n", ch->name);
-		ret = glink_queue_rx_intent(ch->glink_handle,
-					    ch, ch->rx_buf_size);
+		ret = glink_queue_rx_intent(handle, ch, ch->rx_buf_size);
 		if (ret) {
 			pr_err("glink_queue_rx_intent() err [%d]\n", ret);
 		} else {
@@ -736,6 +730,7 @@
 	long timeleft;
 	const char *name;
 	void *handle;
+	u32 pid = current_pid();
 
 	mutex_lock(&ch->lock);
 	name = ch->name;
@@ -749,7 +744,7 @@
 	}
 
 	pr_debug("ch [%s] opened by PID [%d], count [%d]\n",
-		 name, ch->pid, ch->ref_count);
+		 name, pid, ch->ref_count);
 
 	pr_debug("Open channel [%s] timeout_msec [%d].\n", name, timeout_msec);
 
@@ -777,7 +772,7 @@
 	/* init channel context after successful open */
 	ch->glink_handle = handle;
 	ch->ref_count++;
-	ch->pid = current_pid();
+	ch->pid = pid;
 	ch->txn_id = INITIAL_TXN_ID;
 
 	mutex_unlock(&ch->lock);
@@ -1026,10 +1021,12 @@
 			 ch->name, ch->actual_rx_size);
 		goto exit_ready;
 	}
+	mutex_unlock(&ch->lock); /* unlock while waiting */
 
 	pr_debug("Wait for Rx Done, ch [%s].\n", ch->name);
 	wait_for_completion(&ch->rx_done);
 
+	mutex_lock(&ch->lock); /* re-lock after waiting */
 	/* Check Rx Abort on SP reset */
 	if (ch->rx_abort) {
 		pr_err("rx aborted.\n");
@@ -1136,6 +1133,7 @@
 	ch = spcom_find_channel_by_name(name);
 	if (!ch) {
 		pr_err("channel %s doesn't exist, load App first.\n", name);
+		kfree(client);
 		return NULL;
 	}
 
@@ -1322,6 +1320,7 @@
 	ch = spcom_find_channel_by_name(name);
 	if (!ch) {
 		pr_err("channel %s doesn't exist, load App first.\n", name);
+		kfree(server);
 		return NULL;
 	}
 
@@ -2025,6 +2024,7 @@
 				      void *buf,
 				      uint32_t size)
 {
+	int ret = -1;
 	uint32_t next_req_size = 0;
 
 	if (size < sizeof(next_req_size)) {
@@ -2032,7 +2032,10 @@
 		return -EINVAL;
 	}
 
-	next_req_size = spcom_get_next_request_size(ch);
+	ret = spcom_get_next_request_size(ch);
+	if (ret < 0)
+		return ret;
+	next_req_size = (uint32_t) ret;
 
 	memcpy(buf, &next_req_size, sizeof(next_req_size));
 	pr_debug("next_req_size [%d].\n", next_req_size);
@@ -2137,18 +2140,20 @@
 			      void *buf,
 			      uint32_t size)
 {
+	int ret = -1;
+
 	if (size == SPCOM_GET_NEXT_REQUEST_SIZE) {
 		pr_debug("get next request size, ch [%s].\n", ch->name);
 		ch->is_server = true;
-		size = spcom_handle_get_req_size(ch, buf, size);
+		ret = spcom_handle_get_req_size(ch, buf, size);
 	} else {
 		pr_debug("get request/response, ch [%s].\n", ch->name);
-		size = spcom_handle_read_req_resp(ch, buf, size);
+		ret = spcom_handle_read_req_resp(ch, buf, size);
 	}
 
 	pr_debug("ch [%s] , size = %d.\n", ch->name, size);
 
-	return size;
+	return ret;
 }
 
 /*======================================================================*/
@@ -2300,6 +2305,7 @@
 	char *buf;
 	struct spcom_channel *ch;
 	const char *name = file_to_filename(filp);
+	int buf_size = 0;
 
 	pr_debug("Write file [%s] size [%d] pos [%d].\n",
 		 name, (int) size, (int) *f_pos);
@@ -2326,6 +2332,7 @@
 			   (int) size, (int) SPCOM_MAX_COMMAND_SIZE);
 		return -EINVAL;
 	}
+	buf_size = size; /* explicit casting size_t to int */
 
 	if (*f_pos != 0) {
 		pr_err("offset should be zero, no sparse buffer.\n");
@@ -2343,7 +2350,7 @@
 		return -EFAULT;
 	}
 
-	ret = spcom_handle_write(ch, buf, size);
+	ret = spcom_handle_write(ch, buf, buf_size);
 	if (ret) {
 		pr_err("handle command error [%d].\n", ret);
 		kfree(buf);
@@ -2371,6 +2378,7 @@
 	char *buf;
 	struct spcom_channel *ch;
 	const char *name = file_to_filename(filp);
+	uint32_t buf_size = 0;
 
 	pr_debug("Read file [%s], size = %d bytes.\n", name, (int) size);
 
@@ -2379,6 +2387,7 @@
 		pr_err("invalid parameters.\n");
 		return -EINVAL;
 	}
+	buf_size = size; /* explicit casting size_t to uint32_t */
 
 	ch = filp->private_data;
 
@@ -2396,7 +2405,7 @@
 	if (buf == NULL)
 		return -ENOMEM;
 
-	ret = spcom_handle_read(ch, buf, size);
+	ret = spcom_handle_read(ch, buf, buf_size);
 	if (ret < 0) {
 		pr_err("read error [%d].\n", ret);
 		kfree(buf);
@@ -2479,9 +2488,14 @@
 		done = (spcom_dev->link_state == GLINK_LINK_STATE_UP);
 		break;
 	case SPCOM_POLL_CH_CONNECT:
+		/*
+		 * ch is not expected to be NULL since user must call open()
+		 * to get FD before it can call poll().
+		 * open() will fail if no ch related to the char-device.
+		 */
 		if (ch == NULL) {
 			pr_err("invalid ch pointer, file [%s].\n", name);
-			return -EINVAL;
+			return POLLERR;
 		}
 		pr_debug("ch [%s] SPCOM_POLL_CH_CONNECT.\n", name);
 		if (wait) {
@@ -2782,7 +2796,7 @@
 {
 	int ret;
 
-	pr_info("spcom driver version 1.1 17-July-2017.\n");
+	pr_info("spcom driver version 1.2 23-Aug-2017.\n");
 
 	ret = platform_driver_register(&spcom_driver);
 	if (ret)
diff --git a/drivers/soc/qcom/subsys-pil-tz.c b/drivers/soc/qcom/subsys-pil-tz.c
index 01eb260..3ea4be6 100644
--- a/drivers/soc/qcom/subsys-pil-tz.c
+++ b/drivers/soc/qcom/subsys-pil-tz.c
@@ -1152,6 +1152,22 @@
 		d->subsys_desc.wdog_bite_handler = subsys_wdog_bite_irq_handler;
 		d->subsys_desc.stop_ack_handler = subsys_stop_ack_intr_handler;
 	}
+	d->desc.signal_aop = of_property_read_bool(pdev->dev.of_node,
+						"qcom,signal-aop");
+	if (d->desc.signal_aop) {
+		d->desc.cl.dev = &pdev->dev;
+		d->desc.cl.tx_block = true;
+		d->desc.cl.tx_tout = 1000;
+		d->desc.cl.knows_txdone = false;
+		d->desc.mbox = mbox_request_channel(&d->desc.cl, 0);
+		if (IS_ERR(d->desc.mbox)) {
+			rc = PTR_ERR(d->desc.mbox);
+			dev_err(&pdev->dev, "Failed to get mailbox channel %pK %d\n",
+				d->desc.mbox, rc);
+			goto err_ramdump;
+		}
+	}
+
 	d->ramdump_dev = create_ramdump_device(d->subsys_desc.name,
 								&pdev->dev);
 	if (!d->ramdump_dev) {
diff --git a/drivers/soc/qcom/wcd-dsp-glink.c b/drivers/soc/qcom/wcd-dsp-glink.c
deleted file mode 100644
index 870b9f7..0000000
--- a/drivers/soc/qcom/wcd-dsp-glink.c
+++ /dev/null
@@ -1,1201 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/cdev.h>
-#include <linux/platform_device.h>
-#include <linux/vmalloc.h>
-#include <soc/qcom/glink.h>
-#include "sound/wcd-dsp-glink.h"
-
-#define WDSP_GLINK_DRIVER_NAME "wcd-dsp-glink"
-#define WDSP_MAX_WRITE_SIZE (256 * 1024)
-#define WDSP_MAX_READ_SIZE (4 * 1024)
-#define WDSP_MAX_NO_OF_INTENTS (20)
-#define WDSP_MAX_NO_OF_CHANNELS (10)
-#define WDSP_WRITE_PKT_SIZE (sizeof(struct wdsp_write_pkt))
-#define WDSP_REG_PKT_SIZE (sizeof(struct wdsp_reg_pkt))
-#define WDSP_CMD_PKT_SIZE (sizeof(struct wdsp_cmd_pkt))
-#define WDSP_CH_CFG_SIZE (sizeof(struct wdsp_glink_ch_cfg))
-
-#define MINOR_NUMBER_COUNT 1
-#define WDSP_EDGE "wdsp"
-#define RESP_QUEUE_SIZE 3
-#define QOS_PKT_SIZE 1024
-#define TIMEOUT_MS 1000
-
-struct wdsp_glink_dev {
-	struct class *cls;
-	struct device *dev;
-	struct cdev cdev;
-	dev_t dev_num;
-};
-
-struct wdsp_glink_rsp_que {
-	/* Size of valid data in buffer */
-	u32 buf_size;
-
-	/* Response buffer */
-	u8 buf[WDSP_MAX_READ_SIZE];
-};
-
-struct wdsp_glink_tx_buf {
-	struct work_struct tx_work;
-	struct work_struct free_tx_work;
-
-	/* Glink channel information */
-	struct wdsp_glink_ch *ch;
-
-	/* Tx buffer to send to glink */
-	u8 buf[0];
-};
-
-struct wdsp_glink_ch {
-	struct wdsp_glink_priv *wpriv;
-
-	/* Glink channel handle */
-	void *handle;
-
-	/* Channel states like connect, disconnect */
-	int channel_state;
-	struct mutex mutex;
-
-	/* To free up the channel memory */
-	bool free_mem;
-
-	/* Glink local channel open work */
-	struct work_struct lcl_ch_open_wrk;
-
-	/* Glink local channel close work */
-	struct work_struct lcl_ch_cls_wrk;
-
-	/* Wait for ch connect state before sending any command */
-	wait_queue_head_t ch_connect_wait;
-
-	/*
-	 * Glink channel configuration. This has to be the last
-	 * member of the strucuture as it has variable size
-	 */
-	struct wdsp_glink_ch_cfg ch_cfg;
-};
-
-struct wdsp_glink_state {
-	/* Glink link state information */
-	enum glink_link_state link_state;
-	void *handle;
-};
-
-struct wdsp_glink_priv {
-	/* Respone buffer related */
-	u8 rsp_cnt;
-	struct wdsp_glink_rsp_que rsp[RESP_QUEUE_SIZE];
-	struct completion rsp_complete;
-	struct mutex rsp_mutex;
-
-	/* Glink channel related */
-	struct mutex glink_mutex;
-	struct wdsp_glink_state glink_state;
-	struct wdsp_glink_ch **ch;
-	u8 no_of_channels;
-	struct work_struct ch_open_cls_wrk;
-	struct workqueue_struct *work_queue;
-
-	wait_queue_head_t link_state_wait;
-
-	struct device *dev;
-};
-
-static int wdsp_glink_close_ch(struct wdsp_glink_ch *ch);
-static int wdsp_glink_open_ch(struct wdsp_glink_ch *ch);
-
-/*
- * wdsp_glink_free_tx_buf_work - Work function to free tx pkt
- * work:      Work structure
- */
-static void wdsp_glink_free_tx_buf_work(struct work_struct *work)
-{
-	struct wdsp_glink_tx_buf *tx_buf;
-
-	tx_buf = container_of(work, struct wdsp_glink_tx_buf,
-			      free_tx_work);
-	vfree(tx_buf);
-}
-
-/*
- * wdsp_glink_free_tx_buf - Function to free tx buffer
- * priv:        Pointer to the channel
- * pkt_priv:    Pointer to the tx buffer
- */
-static void wdsp_glink_free_tx_buf(const void *priv, const void *pkt_priv)
-{
-	struct wdsp_glink_tx_buf *tx_buf = (struct wdsp_glink_tx_buf *)pkt_priv;
-	struct wdsp_glink_priv *wpriv;
-	struct wdsp_glink_ch *ch;
-
-	if (!priv) {
-		pr_err("%s: Invalid priv\n", __func__);
-		return;
-	}
-	if (!tx_buf) {
-		pr_err("%s: Invalid tx_buf\n", __func__);
-		return;
-	}
-
-	ch = (struct wdsp_glink_ch *)priv;
-	wpriv = ch->wpriv;
-	/* Work queue to free tx pkt */
-	INIT_WORK(&tx_buf->free_tx_work, wdsp_glink_free_tx_buf_work);
-	queue_work(wpriv->work_queue, &tx_buf->free_tx_work);
-}
-
-/*
- * wdsp_glink_notify_rx - Glink notify rx callback for responses
- * handle:      Opaque Channel handle returned by GLink
- * priv:        Private pointer to the channel
- * pkt_priv:    Private pointer to the packet
- * ptr:         Pointer to the Rx data
- * size:        Size of the Rx data
- */
-static void wdsp_glink_notify_rx(void *handle, const void *priv,
-				 const void *pkt_priv, const void *ptr,
-				 size_t size)
-{
-	u8 *rx_buf;
-	u8 rsp_cnt;
-	struct wdsp_glink_ch *ch;
-	struct wdsp_glink_priv *wpriv;
-
-	if (!ptr || !priv) {
-		pr_err("%s: Invalid parameters\n", __func__);
-		return;
-	}
-
-	ch = (struct wdsp_glink_ch *)priv;
-	wpriv = ch->wpriv;
-	rx_buf = (u8 *)ptr;
-	if (size > WDSP_MAX_READ_SIZE) {
-		dev_err(wpriv->dev, "%s: Size %zd is greater than allowed %d\n",
-			__func__, size, WDSP_MAX_READ_SIZE);
-		size = WDSP_MAX_READ_SIZE;
-	}
-
-	mutex_lock(&wpriv->rsp_mutex);
-	rsp_cnt = wpriv->rsp_cnt;
-	if (rsp_cnt >= RESP_QUEUE_SIZE) {
-		dev_err(wpriv->dev, "%s: Resp Queue is Full\n", __func__);
-		rsp_cnt = 0;
-	}
-	dev_dbg(wpriv->dev, "%s: copy into buffer %d\n", __func__, rsp_cnt);
-
-	memcpy(wpriv->rsp[rsp_cnt].buf, rx_buf, size);
-	wpriv->rsp[rsp_cnt].buf_size = size;
-	wpriv->rsp_cnt = ++rsp_cnt;
-	mutex_unlock(&wpriv->rsp_mutex);
-
-	glink_rx_done(handle, ptr, true);
-	complete(&wpriv->rsp_complete);
-}
-
-/*
- * wdsp_glink_notify_tx_done - Glink notify tx done callback to
- * free tx buffer
- * handle:      Opaque Channel handle returned by GLink
- * priv:        Private pointer to the channel
- * pkt_priv:    Private pointer to the packet
- * ptr:         Pointer to the Tx data
- */
-static void wdsp_glink_notify_tx_done(void *handle, const void *priv,
-				      const void *pkt_priv, const void *ptr)
-{
-	wdsp_glink_free_tx_buf(priv, pkt_priv);
-}
-/*
- * wdsp_glink_notify_tx_abort - Glink notify tx abort callback to
- * free tx buffer
- * handle:      Opaque Channel handle returned by GLink
- * priv:        Private pointer to the channel
- * pkt_priv:    Private pointer to the packet
- */
-static void wdsp_glink_notify_tx_abort(void *handle, const void *priv,
-				       const void *pkt_priv)
-{
-	wdsp_glink_free_tx_buf(priv, pkt_priv);
-}
-
-/*
- * wdsp_glink_notify_rx_intent_req - Glink notify rx intent request callback
- * to queue buffer to receive from remote client
- * handle:      Opaque channel handle returned by GLink
- * priv:        Private pointer to the channel
- * req_size:    Size of intent to be queued
- */
-static bool wdsp_glink_notify_rx_intent_req(void *handle, const void *priv,
-					    size_t req_size)
-{
-	struct wdsp_glink_priv *wpriv;
-	struct wdsp_glink_ch *ch;
-	int rc = 0;
-	bool ret = false;
-
-	if (!priv) {
-		pr_err("%s: Invalid priv\n", __func__);
-		goto done;
-	}
-	if (req_size > WDSP_MAX_READ_SIZE) {
-		pr_err("%s: Invalid req_size %zd\n", __func__, req_size);
-		goto done;
-	}
-
-	ch = (struct wdsp_glink_ch *)priv;
-	wpriv = ch->wpriv;
-
-	dev_dbg(wpriv->dev, "%s: intent size %zd requested for ch name %s",
-		 __func__, req_size, ch->ch_cfg.name);
-
-	mutex_lock(&ch->mutex);
-	rc = glink_queue_rx_intent(ch->handle, ch, req_size);
-	if (rc < 0) {
-		dev_err(wpriv->dev, "%s: Failed to queue rx intent, rc = %d\n",
-			__func__, rc);
-		mutex_unlock(&ch->mutex);
-		goto done;
-	}
-	mutex_unlock(&ch->mutex);
-	ret = true;
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_lcl_ch_open_wrk - Work function to open channel again
- * when local disconnect event happens
- * work:      Work structure
- */
-static void wdsp_glink_lcl_ch_open_wrk(struct work_struct *work)
-{
-	struct wdsp_glink_ch *ch;
-
-	ch = container_of(work, struct wdsp_glink_ch,
-			  lcl_ch_open_wrk);
-
-	wdsp_glink_open_ch(ch);
-}
-
-/*
- * wdsp_glink_lcl_ch_cls_wrk - Work function to close channel locally
- * when remote disconnect event happens
- * work:      Work structure
- */
-static void wdsp_glink_lcl_ch_cls_wrk(struct work_struct *work)
-{
-	struct wdsp_glink_ch *ch;
-
-	ch = container_of(work, struct wdsp_glink_ch,
-			  lcl_ch_cls_wrk);
-
-	wdsp_glink_close_ch(ch);
-}
-
-/*
- * wdsp_glink_notify_state - Glink channel state information event callback
- * handle:      Opaque Channel handle returned by GLink
- * priv:        Private pointer to the channel
- * event:       channel state event
- */
-static void wdsp_glink_notify_state(void *handle, const void *priv,
-				    unsigned int event)
-{
-	struct wdsp_glink_priv *wpriv;
-	struct wdsp_glink_ch *ch;
-	int i, ret = 0;
-
-	if (!priv) {
-		pr_err("%s: Invalid priv\n", __func__);
-		return;
-	}
-
-	ch = (struct wdsp_glink_ch *)priv;
-	wpriv = ch->wpriv;
-
-	mutex_lock(&ch->mutex);
-	ch->channel_state = event;
-	if (event == GLINK_CONNECTED) {
-		dev_dbg(wpriv->dev, "%s: glink channel: %s connected\n",
-			__func__, ch->ch_cfg.name);
-
-		for (i = 0; i < ch->ch_cfg.no_of_intents; i++) {
-			dev_dbg(wpriv->dev, "%s: intent_size = %d\n", __func__,
-				ch->ch_cfg.intents_size[i]);
-			ret = glink_queue_rx_intent(ch->handle, ch,
-						    ch->ch_cfg.intents_size[i]);
-			if (ret < 0)
-				dev_warn(wpriv->dev, "%s: Failed to queue intent %d of size %d\n",
-					 __func__, i,
-					 ch->ch_cfg.intents_size[i]);
-		}
-
-		ret = glink_qos_latency(ch->handle, ch->ch_cfg.latency_in_us,
-					QOS_PKT_SIZE);
-		if (ret < 0)
-			dev_warn(wpriv->dev, "%s: Failed to request qos %d for ch %s\n",
-				__func__, ch->ch_cfg.latency_in_us,
-				ch->ch_cfg.name);
-
-		wake_up(&ch->ch_connect_wait);
-		mutex_unlock(&ch->mutex);
-	} else if (event == GLINK_LOCAL_DISCONNECTED) {
-		/*
-		 * Don't use dev_dbg here as dev may not be valid if channel
-		 * closed from driver close.
-		 */
-		pr_debug("%s: channel: %s disconnected locally\n",
-			 __func__, ch->ch_cfg.name);
-		mutex_unlock(&ch->mutex);
-
-		if (ch->free_mem) {
-			kfree(ch);
-			ch = NULL;
-		}
-	} else if (event == GLINK_REMOTE_DISCONNECTED) {
-		dev_dbg(wpriv->dev, "%s: remote channel: %s disconnected remotely\n",
-			 __func__, ch->ch_cfg.name);
-		mutex_unlock(&ch->mutex);
-		/*
-		 * If remote disconnect happens, local side also has
-		 * to close the channel as per glink design in a
-		 * separate work_queue.
-		 */
-		queue_work(wpriv->work_queue, &ch->lcl_ch_cls_wrk);
-	}
-}
-
-/*
- * wdsp_glink_close_ch - Internal function to close glink channel
- * ch:       Glink Channel structure.
- */
-static int wdsp_glink_close_ch(struct wdsp_glink_ch *ch)
-{
-	struct wdsp_glink_priv *wpriv = ch->wpriv;
-	int ret = 0;
-
-	mutex_lock(&wpriv->glink_mutex);
-	if (ch->handle) {
-		ret = glink_close(ch->handle);
-		if (ret < 0) {
-			dev_err(wpriv->dev, "%s: glink_close is failed, ret = %d\n",
-				 __func__, ret);
-		} else {
-			ch->handle = NULL;
-			dev_dbg(wpriv->dev, "%s: ch %s is closed\n", __func__,
-				ch->ch_cfg.name);
-		}
-	} else {
-		dev_dbg(wpriv->dev, "%s: ch %s is already closed\n", __func__,
-			ch->ch_cfg.name);
-	}
-	mutex_unlock(&wpriv->glink_mutex);
-
-
-	return ret;
-}
-
-/*
- * wdsp_glink_open_ch - Internal function to open glink channel
- * ch:       Glink Channel structure.
- */
-static int wdsp_glink_open_ch(struct wdsp_glink_ch *ch)
-{
-	struct wdsp_glink_priv *wpriv = ch->wpriv;
-	struct glink_open_config open_cfg;
-	int ret = 0;
-
-	mutex_lock(&wpriv->glink_mutex);
-	if (!ch->handle) {
-		memset(&open_cfg, 0, sizeof(open_cfg));
-		open_cfg.options = GLINK_OPT_INITIAL_XPORT;
-		open_cfg.edge = WDSP_EDGE;
-		open_cfg.notify_rx = wdsp_glink_notify_rx;
-		open_cfg.notify_tx_done = wdsp_glink_notify_tx_done;
-		open_cfg.notify_tx_abort = wdsp_glink_notify_tx_abort;
-		open_cfg.notify_state = wdsp_glink_notify_state;
-		open_cfg.notify_rx_intent_req = wdsp_glink_notify_rx_intent_req;
-		open_cfg.priv = ch;
-		open_cfg.name = ch->ch_cfg.name;
-
-		dev_dbg(wpriv->dev, "%s: ch->ch_cfg.name = %s, latency_in_us = %d, intents = %d\n",
-			__func__, ch->ch_cfg.name, ch->ch_cfg.latency_in_us,
-			ch->ch_cfg.no_of_intents);
-
-		ch->handle = glink_open(&open_cfg);
-		if (IS_ERR_OR_NULL(ch->handle)) {
-			dev_err(wpriv->dev, "%s: glink_open failed for ch %s\n",
-				__func__, ch->ch_cfg.name);
-			ch->handle = NULL;
-			ret = -EINVAL;
-		}
-	} else {
-		dev_err(wpriv->dev, "%s: ch %s is already opened\n", __func__,
-			ch->ch_cfg.name);
-	}
-	mutex_unlock(&wpriv->glink_mutex);
-
-	return ret;
-}
-
-/*
- * wdsp_glink_close_all_ch - Internal function to close all glink channels
- * wpriv:       Wdsp_glink private structure
- */
-static void wdsp_glink_close_all_ch(struct wdsp_glink_priv *wpriv)
-{
-	int i;
-
-	for (i = 0; i < wpriv->no_of_channels; i++)
-		if (wpriv->ch && wpriv->ch[i])
-			wdsp_glink_close_ch(wpriv->ch[i]);
-}
-
-/*
- * wdsp_glink_open_all_ch - Internal function to open all glink channels
- * wpriv:       Wdsp_glink private structure
- */
-static int wdsp_glink_open_all_ch(struct wdsp_glink_priv *wpriv)
-{
-	int ret = 0, i, j;
-
-	for (i = 0; i < wpriv->no_of_channels; i++) {
-		if (wpriv->ch && wpriv->ch[i]) {
-			ret = wdsp_glink_open_ch(wpriv->ch[i]);
-			if (ret < 0)
-				goto err_open;
-		}
-	}
-	goto done;
-
-err_open:
-	for (j = 0; j < i; j++)
-		if (wpriv->ch[i])
-			wdsp_glink_close_ch(wpriv->ch[j]);
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_ch_open_wq - Work function to open glink channels
- * work:      Work structure
- */
-static void wdsp_glink_ch_open_cls_wrk(struct work_struct *work)
-{
-	struct wdsp_glink_priv *wpriv;
-
-	wpriv = container_of(work, struct wdsp_glink_priv,
-			     ch_open_cls_wrk);
-
-	if (wpriv->glink_state.link_state == GLINK_LINK_STATE_DOWN) {
-		dev_info(wpriv->dev, "%s: GLINK_LINK_STATE_DOWN\n",
-			 __func__);
-
-		wdsp_glink_close_all_ch(wpriv);
-	} else if (wpriv->glink_state.link_state == GLINK_LINK_STATE_UP) {
-		dev_info(wpriv->dev, "%s: GLINK_LINK_STATE_UP\n",
-			 __func__);
-
-		wdsp_glink_open_all_ch(wpriv);
-	}
-}
-
-/*
- * wdsp_glink_link_state_cb - Glink link state callback to inform
- * about link states
- * cb_info:     Glink link state callback information structure
- * priv:        Private structure of link state passed while register
- */
-static void wdsp_glink_link_state_cb(struct glink_link_state_cb_info *cb_info,
-				     void *priv)
-{
-	struct wdsp_glink_priv *wpriv;
-
-	if (!cb_info || !priv) {
-		pr_err("%s: Invalid parameters\n", __func__);
-		return;
-	}
-
-	wpriv = (struct wdsp_glink_priv *)priv;
-
-	mutex_lock(&wpriv->glink_mutex);
-	wpriv->glink_state.link_state = cb_info->link_state;
-	wake_up(&wpriv->link_state_wait);
-	mutex_unlock(&wpriv->glink_mutex);
-
-	queue_work(wpriv->work_queue, &wpriv->ch_open_cls_wrk);
-}
-
-/*
- * wdsp_glink_ch_info_init- Internal function to allocate channel memory
- * and register with glink
- * wpriv:     Wdsp_glink private structure.
- * pkt:       Glink registration packet contains glink channel information.
- * pkt_size:  Size of the pkt.
- */
-static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
-				   struct wdsp_reg_pkt *pkt, size_t pkt_size)
-{
-	int ret = 0, i, j;
-	struct glink_link_info link_info;
-	struct wdsp_glink_ch_cfg *ch_cfg;
-	struct wdsp_glink_ch **ch;
-	u8 no_of_channels;
-	u8 *payload;
-	u32 ch_size, ch_cfg_size;
-	size_t size = WDSP_WRITE_PKT_SIZE + WDSP_REG_PKT_SIZE;
-
-	mutex_lock(&wpriv->glink_mutex);
-	if (wpriv->ch) {
-		dev_err(wpriv->dev, "%s: glink ch memory is already allocated\n",
-			 __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	payload = (u8 *)pkt->payload;
-	no_of_channels = pkt->no_of_channels;
-
-	if (no_of_channels > WDSP_MAX_NO_OF_CHANNELS) {
-		dev_err(wpriv->dev, "%s: no_of_channels: %d but max allowed are %d\n",
-			__func__, no_of_channels, WDSP_MAX_NO_OF_CHANNELS);
-		ret = -EINVAL;
-		goto done;
-	}
-	ch = kcalloc(no_of_channels, sizeof(struct wdsp_glink_ch *),
-		     GFP_ATOMIC);
-	if (!ch) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	wpriv->ch = ch;
-	wpriv->no_of_channels = no_of_channels;
-
-	for (i = 0; i < no_of_channels; i++) {
-		ch_cfg = (struct wdsp_glink_ch_cfg *)payload;
-
-		size += WDSP_CH_CFG_SIZE;
-		if (size > pkt_size) {
-			dev_err(wpriv->dev, "%s: Invalid size = %zd, pkt_size = %zd\n",
-				__func__, size, pkt_size);
-			ret = -EINVAL;
-			goto err_ch_mem;
-		}
-		if (ch_cfg->no_of_intents > WDSP_MAX_NO_OF_INTENTS) {
-			dev_err(wpriv->dev, "%s: Invalid no_of_intents = %d\n",
-				__func__, ch_cfg->no_of_intents);
-			ret = -EINVAL;
-			goto err_ch_mem;
-		}
-		size += (sizeof(u32) * ch_cfg->no_of_intents);
-		if (size > pkt_size) {
-			dev_err(wpriv->dev, "%s: Invalid size = %zd, pkt_size = %zd\n",
-				__func__, size, pkt_size);
-			ret = -EINVAL;
-			goto err_ch_mem;
-		}
-
-		ch_cfg_size = sizeof(struct wdsp_glink_ch_cfg) +
-					(sizeof(u32) * ch_cfg->no_of_intents);
-		ch_size = sizeof(struct wdsp_glink_ch) +
-					(sizeof(u32) * ch_cfg->no_of_intents);
-
-		dev_dbg(wpriv->dev, "%s: channels: %d ch_cfg_size: %d, size: %zd, pkt_size: %zd",
-			 __func__, no_of_channels, ch_cfg_size, size, pkt_size);
-
-		ch[i] = kzalloc(ch_size, GFP_KERNEL);
-		if (!ch[i]) {
-			ret = -ENOMEM;
-			goto err_ch_mem;
-		}
-		ch[i]->channel_state = GLINK_LOCAL_DISCONNECTED;
-		memcpy(&ch[i]->ch_cfg, payload, ch_cfg_size);
-		payload += ch_cfg_size;
-
-		mutex_init(&ch[i]->mutex);
-		ch[i]->wpriv = wpriv;
-		INIT_WORK(&ch[i]->lcl_ch_open_wrk, wdsp_glink_lcl_ch_open_wrk);
-		INIT_WORK(&ch[i]->lcl_ch_cls_wrk, wdsp_glink_lcl_ch_cls_wrk);
-		init_waitqueue_head(&ch[i]->ch_connect_wait);
-	}
-
-	INIT_WORK(&wpriv->ch_open_cls_wrk, wdsp_glink_ch_open_cls_wrk);
-
-	/* Register glink link_state notification */
-	link_info.glink_link_state_notif_cb = wdsp_glink_link_state_cb;
-	link_info.transport = NULL;
-	link_info.edge = WDSP_EDGE;
-
-	wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
-	wpriv->glink_state.handle = glink_register_link_state_cb(&link_info,
-								 wpriv);
-	if (!wpriv->glink_state.handle) {
-		dev_err(wpriv->dev, "%s: Unable to register wdsp link state\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_ch_mem;
-	}
-	goto done;
-
-err_ch_mem:
-	for (j = 0; j < i; j++) {
-		mutex_destroy(&ch[j]->mutex);
-		kfree(wpriv->ch[j]);
-		wpriv->ch[j] = NULL;
-	}
-	kfree(wpriv->ch);
-	wpriv->ch = NULL;
-	wpriv->no_of_channels = 0;
-
-done:
-	mutex_unlock(&wpriv->glink_mutex);
-	return ret;
-}
-
-/*
- * wdsp_glink_tx_buf_work - Work queue function to send tx buffer to glink
- * work:     Work structure
- */
-static void wdsp_glink_tx_buf_work(struct work_struct *work)
-{
-	struct wdsp_glink_priv *wpriv;
-	struct wdsp_glink_ch *ch;
-	struct wdsp_glink_tx_buf *tx_buf;
-	struct wdsp_write_pkt *wpkt;
-	struct wdsp_cmd_pkt *cpkt;
-	int ret = 0;
-
-	tx_buf = container_of(work, struct wdsp_glink_tx_buf,
-			      tx_work);
-	ch = tx_buf->ch;
-	wpriv = ch->wpriv;
-	wpkt = (struct wdsp_write_pkt *)tx_buf->buf;
-	cpkt = (struct wdsp_cmd_pkt *)wpkt->payload;
-	dev_dbg(wpriv->dev, "%s: ch name = %s, payload size = %d\n",
-		__func__, cpkt->ch_name, cpkt->payload_size);
-
-	mutex_lock(&tx_buf->ch->mutex);
-	if (ch->channel_state == GLINK_CONNECTED) {
-		mutex_unlock(&tx_buf->ch->mutex);
-		ret = glink_tx(ch->handle, tx_buf,
-			       cpkt->payload, cpkt->payload_size,
-			       GLINK_TX_REQ_INTENT);
-		if (ret < 0) {
-			dev_err(wpriv->dev, "%s: glink tx failed, ret = %d\n",
-				__func__, ret);
-			/*
-			 * If glink_tx() is failed then free tx_buf here as
-			 * there won't be any tx_done notification to
-			 * free the buffer.
-			 */
-			vfree(tx_buf);
-		}
-	} else {
-		mutex_unlock(&tx_buf->ch->mutex);
-		dev_err(wpriv->dev, "%s: channel %s is not in connected state\n",
-			__func__, ch->ch_cfg.name);
-		/*
-		 * Free tx_buf here as there won't be any tx_done
-		 * notification in this case also.
-		 */
-		vfree(tx_buf);
-	}
-}
-
-/*
- * wdsp_glink_read - Read API to send the data to userspace
- * file:    Pointer to the file structure
- * buf:     Pointer to the userspace buffer
- * count:   Number bytes to read from the file
- * ppos:    Pointer to the position into the file
- */
-static ssize_t wdsp_glink_read(struct file *file, char __user *buf,
-			       size_t count, loff_t *ppos)
-{
-	int ret = 0, ret1 = 0;
-	struct wdsp_glink_rsp_que *rsp;
-	struct wdsp_glink_priv *wpriv;
-
-	wpriv = (struct wdsp_glink_priv *)file->private_data;
-	if (!wpriv) {
-		pr_err("%s: Invalid private data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (count > WDSP_MAX_READ_SIZE) {
-		dev_info(wpriv->dev, "%s: count = %zd is more than WDSP_MAX_READ_SIZE\n",
-			__func__, count);
-		count = WDSP_MAX_READ_SIZE;
-	}
-	/*
-	 * Complete signal has given from glink rx notification callback
-	 * or from flush API. Also use interruptible wait_for_completion API
-	 * to allow the system to go in suspend.
-	 */
-	ret = wait_for_completion_interruptible(&wpriv->rsp_complete);
-	if (ret)
-		goto done;
-
-	mutex_lock(&wpriv->rsp_mutex);
-	if (wpriv->rsp_cnt) {
-		wpriv->rsp_cnt--;
-		dev_dbg(wpriv->dev, "%s: read from buffer %d\n",
-			__func__, wpriv->rsp_cnt);
-
-		rsp = &wpriv->rsp[wpriv->rsp_cnt];
-		if (count < rsp->buf_size) {
-			ret1 = copy_to_user(buf, &rsp->buf, count);
-			/* Return the number of bytes copied */
-			ret = count;
-		} else {
-			ret1 = copy_to_user(buf, &rsp->buf, rsp->buf_size);
-			/* Return the number of bytes copied */
-			ret = rsp->buf_size;
-		}
-
-		if (ret1) {
-			mutex_unlock(&wpriv->rsp_mutex);
-			dev_err(wpriv->dev, "%s: copy_to_user failed %d\n",
-				__func__, ret);
-			ret = -EFAULT;
-			goto done;
-		}
-	} else {
-		/*
-		 * This will execute only if flush API is called or
-		 * something wrong with ref_cnt
-		 */
-		dev_dbg(wpriv->dev, "%s: resp count = %d\n", __func__,
-			wpriv->rsp_cnt);
-		ret = -EINVAL;
-	}
-	mutex_unlock(&wpriv->rsp_mutex);
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_write - Write API to receive the data from userspace
- * file:    Pointer to the file structure
- * buf:     Pointer to the userspace buffer
- * count:   Number bytes to read from the file
- * ppos:    Pointer to the position into the file
- */
-static ssize_t wdsp_glink_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	int ret = 0, i, tx_buf_size;
-	struct wdsp_write_pkt *wpkt;
-	struct wdsp_cmd_pkt *cpkt;
-	struct wdsp_glink_tx_buf *tx_buf;
-	struct wdsp_glink_priv *wpriv;
-	size_t pkt_max_size;
-
-	wpriv = (struct wdsp_glink_priv *)file->private_data;
-	if (!wpriv) {
-		pr_err("%s: Invalid private data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((count < WDSP_WRITE_PKT_SIZE) ||
-	    (count > WDSP_MAX_WRITE_SIZE)) {
-		dev_err(wpriv->dev, "%s: Invalid count = %zd\n",
-			__func__, count);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	dev_dbg(wpriv->dev, "%s: count = %zd\n", __func__, count);
-
-	tx_buf_size = count + sizeof(struct wdsp_glink_tx_buf);
-	tx_buf = vzalloc(tx_buf_size);
-	if (!tx_buf) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	ret = copy_from_user(tx_buf->buf, buf, count);
-	if (ret) {
-		dev_err(wpriv->dev, "%s: copy_from_user failed %d\n",
-			__func__, ret);
-		ret = -EFAULT;
-		goto free_buf;
-	}
-
-	wpkt = (struct wdsp_write_pkt *)tx_buf->buf;
-	switch (wpkt->pkt_type) {
-	case WDSP_REG_PKT:
-		if (count < (WDSP_WRITE_PKT_SIZE + WDSP_REG_PKT_SIZE +
-			     WDSP_CH_CFG_SIZE)) {
-			dev_err(wpriv->dev, "%s: Invalid reg pkt size = %zd\n",
-				__func__, count);
-			ret = -EINVAL;
-			goto free_buf;
-		}
-		ret = wdsp_glink_ch_info_init(wpriv,
-					(struct wdsp_reg_pkt *)wpkt->payload,
-					count);
-		if (ret < 0)
-			dev_err(wpriv->dev, "%s: glink register failed, ret = %d\n",
-				__func__, ret);
-		vfree(tx_buf);
-		break;
-	case WDSP_READY_PKT:
-		ret = wait_event_timeout(wpriv->link_state_wait,
-					 (wpriv->glink_state.link_state ==
-							GLINK_LINK_STATE_UP),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			dev_err(wpriv->dev, "%s: Link state wait timeout\n",
-				__func__);
-			ret = -ETIMEDOUT;
-			goto free_buf;
-		}
-		ret = 0;
-		vfree(tx_buf);
-		break;
-	case WDSP_CMD_PKT:
-		if (count <= (WDSP_WRITE_PKT_SIZE + WDSP_CMD_PKT_SIZE)) {
-			dev_err(wpriv->dev, "%s: Invalid cmd pkt size = %zd\n",
-				__func__, count);
-			ret = -EINVAL;
-			goto free_buf;
-		}
-		mutex_lock(&wpriv->glink_mutex);
-		if (wpriv->glink_state.link_state == GLINK_LINK_STATE_DOWN) {
-			mutex_unlock(&wpriv->glink_mutex);
-			dev_err(wpriv->dev, "%s: Link state is Down\n",
-				__func__);
-
-			ret = -ENETRESET;
-			goto free_buf;
-		}
-		mutex_unlock(&wpriv->glink_mutex);
-		cpkt = (struct wdsp_cmd_pkt *)wpkt->payload;
-		pkt_max_size =  sizeof(struct wdsp_write_pkt) +
-					sizeof(struct wdsp_cmd_pkt) +
-					cpkt->payload_size;
-		if (count < pkt_max_size) {
-			dev_err(wpriv->dev, "%s: Invalid cmd pkt count = %zd, pkt_size = %zd\n",
-				__func__, count, pkt_max_size);
-			ret = -EINVAL;
-			goto free_buf;
-		}
-		dev_dbg(wpriv->dev, "%s: requested ch_name: %s, pkt_size: %zd\n",
-			__func__, cpkt->ch_name, pkt_max_size);
-		for (i = 0; i < wpriv->no_of_channels; i++) {
-			if (wpriv->ch && wpriv->ch[i] &&
-				(!strcmp(cpkt->ch_name,
-						wpriv->ch[i]->ch_cfg.name))) {
-				tx_buf->ch = wpriv->ch[i];
-				break;
-			}
-		}
-		if (!tx_buf->ch) {
-			dev_err(wpriv->dev, "%s: Failed to get glink channel\n",
-				__func__);
-			ret = -EINVAL;
-			goto free_buf;
-		}
-
-		ret = wait_event_timeout(tx_buf->ch->ch_connect_wait,
-					 (tx_buf->ch->channel_state ==
-							GLINK_CONNECTED),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			dev_err(wpriv->dev, "%s: glink channel %s is not in connected state %d\n",
-				__func__, tx_buf->ch->ch_cfg.name,
-				tx_buf->ch->channel_state);
-			ret = -ETIMEDOUT;
-			goto free_buf;
-		}
-		ret = 0;
-
-		INIT_WORK(&tx_buf->tx_work, wdsp_glink_tx_buf_work);
-		queue_work(wpriv->work_queue, &tx_buf->tx_work);
-		break;
-	default:
-		dev_err(wpriv->dev, "%s: Invalid packet type\n", __func__);
-		ret = -EINVAL;
-		vfree(tx_buf);
-		break;
-	}
-	goto done;
-
-free_buf:
-	vfree(tx_buf);
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_open - Open API to initialize private data
- * inode:   Pointer to the inode structure
- * file:    Pointer to the file structure
- */
-static int wdsp_glink_open(struct inode *inode, struct file *file)
-{
-	int ret = 0;
-	struct wdsp_glink_priv *wpriv;
-	struct wdsp_glink_dev *wdev;
-
-	if (!inode->i_cdev) {
-		pr_err("%s: cdev is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	wdev = container_of(inode->i_cdev, struct wdsp_glink_dev, cdev);
-
-	wpriv = kzalloc(sizeof(struct wdsp_glink_priv), GFP_KERNEL);
-	if (!wpriv) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	wpriv->dev = wdev->dev;
-	wpriv->work_queue = create_singlethread_workqueue("wdsp_glink_wq");
-	if (!wpriv->work_queue) {
-		dev_err(wpriv->dev, "%s: Error creating wdsp_glink_wq\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_wq;
-	}
-
-	init_completion(&wpriv->rsp_complete);
-	init_waitqueue_head(&wpriv->link_state_wait);
-	mutex_init(&wpriv->rsp_mutex);
-	mutex_init(&wpriv->glink_mutex);
-	file->private_data = wpriv;
-
-	goto done;
-
-err_wq:
-	kfree(wpriv);
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_flush - Flush API to unblock read.
- * file:    Pointer to the file structure
- * id:      Lock owner ID
- */
-static int wdsp_glink_flush(struct file *file, fl_owner_t id)
-{
-	struct wdsp_glink_priv *wpriv;
-
-	wpriv = (struct wdsp_glink_priv *)file->private_data;
-	if (!wpriv) {
-		pr_err("%s: Invalid private data\n", __func__);
-		return -EINVAL;
-	}
-
-	complete(&wpriv->rsp_complete);
-
-	return 0;
-}
-
-/*
- * wdsp_glink_release - Release API to clean up resources.
- * Whenever a file structure is shared across multiple threads,
- * release won't be invoked until all copies are closed
- * (file->f_count.counter should be 0). If we need to flush pending
- * data when any copy is closed, you should implement the flush method.
- *
- * inode:   Pointer to the inode structure
- * file:    Pointer to the file structure
- */
-static int wdsp_glink_release(struct inode *inode, struct file *file)
-{
-	int i, ret = 0;
-	struct wdsp_glink_priv *wpriv;
-
-	wpriv = (struct wdsp_glink_priv *)file->private_data;
-	if (!wpriv) {
-		pr_err("%s: Invalid private data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (wpriv->glink_state.handle)
-		glink_unregister_link_state_cb(wpriv->glink_state.handle);
-
-	flush_workqueue(wpriv->work_queue);
-	destroy_workqueue(wpriv->work_queue);
-
-	/*
-	 * Clean up glink channel memory in channel state
-	 * callback only if close channels are called from here.
-	 */
-	if (wpriv->ch) {
-		for (i = 0; i < wpriv->no_of_channels; i++) {
-			if (wpriv->ch[i]) {
-				wpriv->ch[i]->free_mem = true;
-				/*
-				 * Channel handle NULL means channel is already
-				 * closed. Free the channel memory here itself.
-				 */
-				if (!wpriv->ch[i]->handle) {
-					kfree(wpriv->ch[i]);
-					wpriv->ch[i] = NULL;
-				} else {
-					wdsp_glink_close_ch(wpriv->ch[i]);
-				}
-			}
-		}
-
-		kfree(wpriv->ch);
-		wpriv->ch = NULL;
-	}
-
-	mutex_destroy(&wpriv->glink_mutex);
-	mutex_destroy(&wpriv->rsp_mutex);
-	kfree(wpriv);
-	file->private_data = NULL;
-
-done:
-	return ret;
-}
-
-static const struct file_operations wdsp_glink_fops = {
-	.owner =                THIS_MODULE,
-	.open =                 wdsp_glink_open,
-	.read =                 wdsp_glink_read,
-	.write =                wdsp_glink_write,
-	.flush =                wdsp_glink_flush,
-	.release =              wdsp_glink_release,
-};
-
-/*
- * wdsp_glink_probe - Driver probe to expose char device
- * pdev:    Pointer to device tree data.
- */
-static int wdsp_glink_probe(struct platform_device *pdev)
-{
-	int ret;
-	struct wdsp_glink_dev *wdev;
-
-	wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
-	if (!wdev) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	ret = alloc_chrdev_region(&wdev->dev_num, 0, MINOR_NUMBER_COUNT,
-				  WDSP_GLINK_DRIVER_NAME);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "%s: Failed to alloc char dev, err = %d\n",
-			__func__, ret);
-		goto err_chrdev;
-	}
-
-	wdev->cls = class_create(THIS_MODULE, WDSP_GLINK_DRIVER_NAME);
-	if (IS_ERR(wdev->cls)) {
-		ret = PTR_ERR(wdev->cls);
-		dev_err(&pdev->dev, "%s: Failed to create class, err = %d\n",
-			__func__, ret);
-		goto err_class;
-	}
-
-	wdev->dev = device_create(wdev->cls, NULL, wdev->dev_num,
-				  NULL, WDSP_GLINK_DRIVER_NAME);
-	if (IS_ERR(wdev->dev)) {
-		ret = PTR_ERR(wdev->dev);
-		dev_err(&pdev->dev, "%s: Failed to create device, err = %d\n",
-			__func__, ret);
-		goto err_dev_create;
-	}
-
-	cdev_init(&wdev->cdev, &wdsp_glink_fops);
-	ret = cdev_add(&wdev->cdev, wdev->dev_num, MINOR_NUMBER_COUNT);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "%s: Failed to register char dev, err = %d\n",
-			__func__, ret);
-		goto err_cdev_add;
-	}
-	platform_set_drvdata(pdev, wdev);
-	goto done;
-
-err_cdev_add:
-	device_destroy(wdev->cls, wdev->dev_num);
-
-err_dev_create:
-	class_destroy(wdev->cls);
-
-err_class:
-	unregister_chrdev_region(0, MINOR_NUMBER_COUNT);
-
-err_chrdev:
-	devm_kfree(&pdev->dev, wdev);
-
-done:
-	return ret;
-}
-
-/*
- * wdsp_glink_remove - Driver remove to handle cleanup
- * pdev:     Pointer to device tree data.
- */
-static int wdsp_glink_remove(struct platform_device *pdev)
-{
-	struct wdsp_glink_dev *wdev = platform_get_drvdata(pdev);
-
-	if (wdev) {
-		cdev_del(&wdev->cdev);
-		device_destroy(wdev->cls, wdev->dev_num);
-		class_destroy(wdev->cls);
-		unregister_chrdev_region(0, MINOR_NUMBER_COUNT);
-		devm_kfree(&pdev->dev, wdev);
-	} else {
-		dev_err(&pdev->dev, "%s: Invalid device data\n", __func__);
-	}
-
-	return 0;
-}
-
-static const struct of_device_id wdsp_glink_of_match[] = {
-	{.compatible = "qcom,wcd-dsp-glink"},
-	{ }
-};
-MODULE_DEVICE_TABLE(of, wdsp_glink_of_match);
-
-static struct platform_driver wdsp_glink_driver = {
-	.probe          = wdsp_glink_probe,
-	.remove         = wdsp_glink_remove,
-	.driver         = {
-		.name   = WDSP_GLINK_DRIVER_NAME,
-		.owner  = THIS_MODULE,
-		.of_match_table = wdsp_glink_of_match,
-	},
-};
-
-module_platform_driver(wdsp_glink_driver);
-
-MODULE_DESCRIPTION("SoC WCD_DSP GLINK Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/soundwire/Kconfig b/drivers/soundwire/Kconfig
deleted file mode 100644
index e1ca532..0000000
--- a/drivers/soundwire/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# SOUNDWIRE driver configuration
-#
-menuconfig SOUNDWIRE
-	bool "Soundwire support"
-	help
-	  Soundwire is a two wire interface for audio to connect
-	  simple peripheral components in mobile devices.
-
-if SOUNDWIRE
-config SOUNDWIRE_WCD_CTRL
-	depends on WCD9XXX_CODEC_CORE
-	tristate "QTI WCD CODEC Soundwire controller"
-	default n
-	help
-	  Select driver for QTI's Soundwire Master Component.
-endif
diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
deleted file mode 100644
index 53acff1..0000000
--- a/drivers/soundwire/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for kernel soundwire framework.
-#
-obj-$(CONFIG_SOUNDWIRE)			+= soundwire.o
-obj-$(CONFIG_SOUNDWIRE_WCD_CTRL)	+= swr-wcd-ctrl.o
diff --git a/drivers/soundwire/soundwire.c b/drivers/soundwire/soundwire.c
deleted file mode 100644
index 16b16e5e..0000000
--- a/drivers/soundwire/soundwire.c
+++ /dev/null
@@ -1,1035 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/of_device.h>
-#include <linux/completion.h>
-#include <linux/idr.h>
-#include <linux/pm_runtime.h>
-#include <linux/soundwire/soundwire.h>
-
-struct boardinfo {
-	struct list_head	list;
-	struct swr_boardinfo	board_info;
-};
-
-static LIST_HEAD(board_list);
-static LIST_HEAD(swr_master_list);
-static DEFINE_MUTEX(board_lock);
-static DEFINE_IDR(master_idr);
-static DEFINE_MUTEX(swr_lock);
-
-static struct device_type swr_dev_type;
-
-#define SOUNDWIRE_NAME_SIZE	32
-
-static void swr_master_put(struct swr_master *master)
-{
-	if (master)
-		put_device(&master->dev);
-}
-
-static struct swr_master *swr_master_get(struct swr_master *master)
-{
-	if (!master || !get_device(&master->dev))
-		return NULL;
-	return master;
-}
-
-static void swr_dev_release(struct device *dev)
-{
-	struct swr_device *swr_dev = to_swr_device(dev);
-	struct swr_master *master;
-
-	if (!swr_dev)
-		return;
-	master = swr_dev->master;
-	if (!master)
-		return;
-	mutex_lock(&master->mlock);
-	list_del_init(&swr_dev->dev_list);
-	mutex_unlock(&master->mlock);
-	swr_master_put(swr_dev->master);
-	kfree(swr_dev);
-}
-
-/**
- * swr_remove_device - remove a soundwire device
- * @swr_dev: soundwire device to remove
- *
- * Remove a soundwire device. Go through the soundwire
- * device list that master has and remove swr_dev from
- * it.
- */
-void swr_remove_device(struct swr_device *swr_dev)
-{
-	struct swr_device *swr_dev_loop, *safe;
-
-	/*
-	 * master still has reference to all nodes and deletes
-	 * at platform_unregister, so need to init the deleted
-	 * entry
-	 */
-	list_for_each_entry_safe(swr_dev_loop, safe,
-				 &swr_dev->master->devices,
-				 dev_list) {
-		if (swr_dev == swr_dev_loop)
-			list_del_init(&swr_dev_loop->dev_list);
-	}
-}
-EXPORT_SYMBOL(swr_remove_device);
-
-/**
- * swr_new_device - instantiate a new soundwire device
- * @master: Controller to which device is connected
- * @info: Describes the soundwire device
- * Context: can sleep
- *
- * Create a soundwire device. Binding is handled through driver model
- * probe/remove methods. A driver may be bound to this device when
- * the function gets returned.
- *
- * Returns a soundwire new device or NULL
- */
-struct swr_device *swr_new_device(struct swr_master *master,
-				 struct swr_boardinfo const *info)
-{
-	int result;
-	struct swr_device *swr;
-
-	if (!master || !swr_master_get(master)) {
-		pr_err("%s: master is NULL\n", __func__);
-		return NULL;
-	}
-
-	swr = kzalloc(sizeof(*swr), GFP_KERNEL);
-	if (!swr) {
-		put_device(&master->dev);
-		return NULL;
-	}
-	swr->master = master;
-	swr->addr = info->addr;
-	strlcpy(swr->name, info->name, sizeof(swr->name));
-	swr->dev.type = &swr_dev_type;
-	swr->dev.parent = &master->dev;
-	swr->dev.bus = &soundwire_type;
-	swr->dev.release = swr_dev_release;
-	swr->dev.of_node = info->of_node;
-	mutex_lock(&master->mlock);
-	list_add_tail(&swr->dev_list, &master->devices);
-	mutex_unlock(&master->mlock);
-
-	dev_set_name(&swr->dev, "%s.%lx", swr->name, swr->addr);
-	result = device_register(&swr->dev);
-	if (result) {
-		dev_err(&master->dev, "device [%s] register failed err %d\n",
-			swr->name, result);
-		goto err_out;
-	}
-	dev_dbg(&master->dev, "Device [%s] registered with bus id %s\n",
-		swr->name, dev_name(&swr->dev));
-	return swr;
-
-err_out:
-	dev_dbg(&master->dev, "Failed to register swr device %s at 0x%lx %d\n",
-		swr->name, swr->addr, result);
-	swr_master_put(master);
-	kfree(swr);
-	return NULL;
-}
-EXPORT_SYMBOL(swr_new_device);
-
-/**
- * of_register_swr_devices - register child devices on to the soundwire bus
- * @master: pointer to soundwire master device
- *
- * Registers a soundwire device for each child node of master node which has
- * a "swr-devid" property
- *
- */
-int of_register_swr_devices(struct swr_master *master)
-{
-	struct swr_device *swr;
-	struct device_node *node;
-
-	if (!master->dev.of_node)
-		return -EINVAL;
-
-	for_each_available_child_of_node(master->dev.of_node, node) {
-		struct swr_boardinfo info = {};
-		u64 addr;
-
-		dev_dbg(&master->dev, "of_swr:register %s\n", node->full_name);
-
-		if (of_modalias_node(node, info.name, sizeof(info.name)) < 0) {
-			dev_err(&master->dev, "of_swr:modalias failure %s\n",
-				node->full_name);
-			continue;
-		}
-		if (of_property_read_u64(node, "reg", &addr)) {
-			dev_err(&master->dev, "of_swr:invalid reg %s\n",
-				node->full_name);
-			continue;
-		}
-		info.addr = addr;
-		info.of_node = of_node_get(node);
-		master->num_dev++;
-		swr = swr_new_device(master, &info);
-		if (!swr) {
-			dev_err(&master->dev, "of_swr: Register failed %s\n",
-				node->full_name);
-			of_node_put(node);
-			master->num_dev--;
-			continue;
-		}
-	}
-	return 0;
-}
-EXPORT_SYMBOL(of_register_swr_devices);
-
-/**
- * swr_port_response - response from master to free the completed transaction
- * @mstr: pointer to soundwire master device
- * @tid: transaction id that indicates transaction to be freed.
- *
- * Master calls this function to free the compeleted transaction memory
- */
-void swr_port_response(struct swr_master *mstr, u8 tid)
-{
-	struct swr_params *txn;
-
-	txn = mstr->port_txn[tid];
-
-	if (txn == NULL) {
-		dev_err(&mstr->dev, "%s: transaction is already NULL\n",
-			__func__);
-		return;
-	}
-	mstr->port_txn[tid] = NULL;
-	kfree(txn);
-}
-EXPORT_SYMBOL(swr_port_response);
-
-/**
- * swr_remove_from_group - remove soundwire slave devices from group
- * @dev: pointer to the soundwire slave device
- * dev_num: device number of the soundwire slave device
- *
- * Returns error code for failure and 0 for success
- */
-int swr_remove_from_group(struct swr_device *dev, u8 dev_num)
-{
-	struct swr_master *master;
-
-	if (!dev)
-		return -ENODEV;
-
-	master = dev->master;
-	if (!master)
-		return -EINVAL;
-
-	if (!dev->group_id)
-		return 0;
-
-	if (master->gr_sid == dev_num)
-		return 0;
-
-	if (master->remove_from_group && master->remove_from_group(master))
-		dev_dbg(&master->dev, "%s: falling back to GROUP_NONE\n",
-			__func__);
-
-	return 0;
-}
-EXPORT_SYMBOL(swr_remove_from_group);
-
-/**
- * swr_slvdev_datapath_control - Enables/Disables soundwire slave device
- *                               data path
- * @dev: pointer to soundwire slave device
- * @dev_num: device number of the soundwire slave device
- *
- * Returns error code for failure and 0 for success
- */
-int swr_slvdev_datapath_control(struct swr_device *dev, u8 dev_num,
-				bool enable)
-{
-	struct swr_master *master;
-
-	if (!dev)
-		return -ENODEV;
-
-	master = dev->master;
-	if (!master)
-		return -EINVAL;
-
-	if (dev->group_id) {
-		/* Broadcast */
-		if (master->gr_sid != dev_num) {
-			if (!master->gr_sid)
-				master->gr_sid = dev_num;
-			else
-				return 0;
-		}
-	}
-
-	if (master->slvdev_datapath_control)
-		master->slvdev_datapath_control(master, enable);
-
-	return 0;
-}
-EXPORT_SYMBOL(swr_slvdev_datapath_control);
-
-/**
- * swr_connect_port - enable soundwire slave port(s)
- * @dev: pointer to soundwire slave device
- * @port_id: logical port id(s) of soundwire slave device
- * @num_port: number of slave device ports need to be enabled
- * @ch_mask: channels for each port that needs to be enabled
- * @ch_rate: rate at which each port/channels operate
- * @num_ch: number of channels for each port
- *
- * soundwire slave device call swr_connect_port API to enable all/some of
- * its ports and corresponding channels and channel rate. This API will
- * call master connect_port callback function to calculate frame structure
- * and enable master and slave ports
- */
-int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
-			u8 *ch_mask, u32 *ch_rate, u8 *num_ch)
-{
-	u8 i = 0;
-	int ret = 0;
-	struct swr_params *txn = NULL;
-	struct swr_params **temp_txn = NULL;
-	struct swr_master *master = dev->master;
-
-	if (!master) {
-		pr_err("%s: Master is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (num_port > SWR_MAX_DEV_PORT_NUM) {
-		dev_err(&master->dev, "%s: num_port %d exceeds max port %d\n",
-			__func__, num_port, SWR_MAX_DEV_PORT_NUM);
-		return -EINVAL;
-	}
-
-	/*
-	 * create "txn" to accommodate ports enablement of
-	 * different slave devices calling swr_connect_port at the
-	 * same time. Once master process the txn data, it calls
-	 * swr_port_response() to free the transaction. Maximum
-	 * of 256 transactions can be allocated.
-	 */
-	txn = kzalloc(sizeof(struct swr_params), GFP_KERNEL);
-	if (!txn)
-		return -ENOMEM;
-
-	mutex_lock(&master->mlock);
-	for (i = 0; i < master->last_tid; i++) {
-		if (master->port_txn[i] == NULL)
-			break;
-	}
-	if (i >= master->last_tid) {
-		if (master->last_tid == 255) {
-			mutex_unlock(&master->mlock);
-			kfree(txn);
-			dev_err(&master->dev, "%s Max tid reached\n",
-				__func__);
-			return -ENOMEM;
-		}
-		temp_txn = krealloc(master->port_txn,
-				(i + 1) * sizeof(struct swr_params *),
-				GFP_KERNEL);
-		if (!temp_txn) {
-			mutex_unlock(&master->mlock);
-			kfree(txn);
-			dev_err(&master->dev, "%s Not able to allocate\n"
-				"master port transaction memory\n",
-				__func__);
-			return -ENOMEM;
-		}
-		master->port_txn = temp_txn;
-		master->last_tid++;
-	}
-	master->port_txn[i] = txn;
-	mutex_unlock(&master->mlock);
-	txn->tid = i;
-
-	txn->dev_id = dev->dev_num;
-	txn->num_port = num_port;
-	for (i = 0; i < num_port; i++) {
-		txn->port_id[i] = port_id[i];
-		txn->num_ch[i]  = num_ch[i];
-		txn->ch_rate[i] = ch_rate[i];
-		txn->ch_en[i]   = ch_mask[i];
-	}
-	ret = master->connect_port(master, txn);
-	return ret;
-}
-EXPORT_SYMBOL(swr_connect_port);
-
-/**
- * swr_disconnect_port - disable soundwire slave port(s)
- * @dev: pointer to soundwire slave device
- * @port_id: logical port id(s) of soundwire slave device
- * @num_port: number of slave device ports need to be disabled
- *
- * soundwire slave device call swr_disconnect_port API to disable all/some of
- * its ports. This API will call master disconnect_port callback function to
- * disable master and slave port and (re)configure frame structure
- */
-int swr_disconnect_port(struct swr_device *dev, u8 *port_id, u8 num_port)
-{
-	u8 i = 0;
-	int ret;
-	struct swr_params *txn = NULL;
-	struct swr_params **temp_txn = NULL;
-	struct swr_master *master = dev->master;
-
-	if (!master) {
-		pr_err("%s: Master is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (num_port > SWR_MAX_DEV_PORT_NUM) {
-		dev_err(&master->dev, "%s: num_port %d exceeds max port %d\n",
-			__func__, num_port, SWR_MAX_DEV_PORT_NUM);
-		return -EINVAL;
-	}
-
-	txn = kzalloc(sizeof(struct swr_params), GFP_KERNEL);
-	if (!txn)
-		return -ENOMEM;
-
-	mutex_lock(&master->mlock);
-	for (i = 0; i < master->last_tid; i++) {
-		if (master->port_txn[i] == NULL)
-			break;
-	}
-	if (i >= master->last_tid) {
-		if (master->last_tid == 255) {
-			mutex_unlock(&master->mlock);
-			kfree(txn);
-			dev_err(&master->dev, "%s Max tid reached\n",
-				__func__);
-			return -ENOMEM;
-		}
-		temp_txn = krealloc(master->port_txn,
-				(i + 1) * sizeof(struct swr_params *),
-				GFP_KERNEL);
-		if (!temp_txn) {
-			mutex_unlock(&master->mlock);
-			kfree(txn);
-			dev_err(&master->dev, "%s Not able to allocate\n"
-				"master port transaction memory\n",
-				__func__);
-			return -ENOMEM;
-		}
-		master->port_txn = temp_txn;
-		master->last_tid++;
-	}
-	master->port_txn[i] = txn;
-	mutex_unlock(&master->mlock);
-	txn->tid = i;
-
-	txn->dev_id = dev->dev_num;
-	txn->num_port = num_port;
-	for (i = 0; i < num_port; i++)
-		txn->port_id[i] = port_id[i];
-	ret = master->disconnect_port(master, txn);
-	return ret;
-}
-EXPORT_SYMBOL(swr_disconnect_port);
-
-/**
- * swr_get_logical_dev_num - Get soundwire slave logical device number
- * @dev: pointer to soundwire slave device
- * @dev_id: physical device id of soundwire slave device
- * @dev_num: pointer to logical device num of soundwire slave device
- *
- * This API will get the logical device number of soundwire slave device
- */
-int swr_get_logical_dev_num(struct swr_device *dev, u64 dev_id,
-			u8 *dev_num)
-{
-	int ret = 0;
-	struct swr_master *master = dev->master;
-
-	if (!master) {
-		pr_err("%s: Master is NULL\n", __func__);
-		return -EINVAL;
-	}
-	mutex_lock(&master->mlock);
-	ret = master->get_logical_dev_num(master, dev_id, dev_num);
-	if (ret) {
-		pr_err("%s: Error %d to get logical addr for device %llx\n",
-			__func__, ret, dev_id);
-	}
-	mutex_unlock(&master->mlock);
-	return ret;
-}
-EXPORT_SYMBOL(swr_get_logical_dev_num);
-
-/**
- * swr_read - read soundwire slave device registers
- * @dev: pointer to soundwire slave device
- * @dev_num: logical device num of soundwire slave device
- * @reg_addr: base register address that needs to be read
- * @buf: pointer to store the values of registers from base address
- * @len: length of the buffer
- *
- * This API will read the value of the register address from
- * soundwire slave device
- */
-int swr_read(struct swr_device *dev, u8 dev_num, u16 reg_addr,
-	     void *buf, u32 len)
-{
-	struct swr_master *master = dev->master;
-
-	if (!master)
-		return -EINVAL;
-	return master->read(master, dev_num, reg_addr, buf, len);
-}
-EXPORT_SYMBOL(swr_read);
-
-/**
- * swr_bulk_write - write soundwire slave device registers
- * @dev: pointer to soundwire slave device
- * @dev_num: logical device num of soundwire slave device
- * @reg_addr: register address of soundwire slave device
- * @buf: contains value of register address
- * @len: indicates number of registers
- *
- * This API will write the value of the register address to
- * soundwire slave device
- */
-int swr_bulk_write(struct swr_device *dev, u8 dev_num, void *reg,
-		   const void *buf, size_t len)
-{
-	struct swr_master *master;
-
-	if (!dev || !dev->master)
-		return -EINVAL;
-
-	master = dev->master;
-	if (dev->group_id) {
-		if (master->gr_sid != dev_num) {
-			if (!master->gr_sid)
-				master->gr_sid = dev_num;
-			else
-				return 0;
-		}
-		dev_num = dev->group_id;
-	}
-	if (master->bulk_write)
-		return master->bulk_write(master, dev_num, reg, buf, len);
-
-	return -EOPNOTSUPP;
-}
-EXPORT_SYMBOL(swr_bulk_write);
-
-/**
- * swr_write - write soundwire slave device registers
- * @dev: pointer to soundwire slave device
- * @dev_num: logical device num of soundwire slave device
- * @reg_addr: register address of soundwire slave device
- * @buf: contains value of register address
- *
- * This API will write the value of the register address to
- * soundwire slave device
- */
-int swr_write(struct swr_device *dev, u8 dev_num, u16 reg_addr,
-	      const void *buf)
-{
-	struct swr_master *master = dev->master;
-
-	if (!master)
-		return -EINVAL;
-
-	if (dev->group_id) {
-		if (master->gr_sid != dev_num) {
-			if (!master->gr_sid)
-				master->gr_sid = dev_num;
-			else
-				return 0;
-		}
-		dev_num = dev->group_id;
-	}
-	return master->write(master, dev_num, reg_addr, buf);
-}
-EXPORT_SYMBOL(swr_write);
-
-/**
- * swr_device_up - Function to bringup the soundwire slave device
- * @swr_dev: pointer to soundwire slave device
- * Context: can sleep
- *
- * This API will be called by soundwire master to bringup the slave
- * device.
- */
-int swr_device_up(struct swr_device *swr_dev)
-{
-	struct device *dev;
-	const struct swr_driver *sdrv;
-
-	if (!swr_dev)
-		return -EINVAL;
-
-	dev = &swr_dev->dev;
-	sdrv = to_swr_driver(dev->driver);
-	if (!sdrv)
-		return 0;
-
-	if (sdrv->device_up)
-		return sdrv->device_up(to_swr_device(dev));
-
-	return -ENODEV;
-}
-EXPORT_SYMBOL(swr_device_up);
-
-/**
- * swr_device_down - Function to call soundwire slave device down
- * @swr_dev: pointer to soundwire slave device
- * Context: can sleep
- *
- * This API will be called by soundwire master to put slave device in
- * shutdown state.
- */
-int swr_device_down(struct swr_device *swr_dev)
-{
-	struct device *dev;
-	const struct swr_driver *sdrv;
-
-	if (!swr_dev)
-		return -EINVAL;
-
-	dev = &swr_dev->dev;
-	sdrv = to_swr_driver(dev->driver);
-	if (!sdrv)
-		return 0;
-
-	if (sdrv->device_down)
-		return sdrv->device_down(to_swr_device(dev));
-
-	return -ENODEV;
-}
-EXPORT_SYMBOL(swr_device_down);
-
-/**
- * swr_reset_device - reset soundwire slave device
- * @swr_dev: pointer to soundwire slave device
- * Context: can sleep
- *
- * This API will be called by soundwire master to reset the slave
- * device when the slave device is not responding or in undefined
- * state
- */
-int swr_reset_device(struct swr_device *swr_dev)
-{
-	struct device *dev;
-	const struct swr_driver *sdrv;
-
-	if (!swr_dev)
-		return -EINVAL;
-
-	dev = &swr_dev->dev;
-	sdrv = to_swr_driver(dev->driver);
-	if (!sdrv)
-		return -EINVAL;
-
-	if (sdrv->reset_device)
-		return sdrv->reset_device(to_swr_device(dev));
-
-	return -ENODEV;
-}
-EXPORT_SYMBOL(swr_reset_device);
-
-/**
- * swr_set_device_group - Assign group id to the slave devices
- * @swr_dev: pointer to soundwire slave device
- * @id: group id to be assigned to slave device
- * Context: can sleep
- *
- * This API will be called either from soundwire master or slave
- * device to assign group id.
- */
-int swr_set_device_group(struct swr_device *swr_dev, u8 id)
-{
-	struct swr_master *master;
-
-	if (!swr_dev)
-		return -EINVAL;
-
-	swr_dev->group_id = id;
-	master = swr_dev->master;
-	if (!id && master)
-		master->gr_sid = 0;
-
-	return 0;
-}
-EXPORT_SYMBOL(swr_set_device_group);
-
-static int swr_drv_probe(struct device *dev)
-{
-	const struct swr_driver *sdrv = to_swr_driver(dev->driver);
-
-	if (!sdrv)
-		return -EINVAL;
-
-	if (sdrv->probe)
-		return sdrv->probe(to_swr_device(dev));
-	return -ENODEV;
-}
-
-static int swr_drv_remove(struct device *dev)
-{
-	const struct swr_driver *sdrv = to_swr_driver(dev->driver);
-
-	if (!sdrv)
-		return -EINVAL;
-
-	if (sdrv->remove)
-		return sdrv->remove(to_swr_device(dev));
-	return -ENODEV;
-}
-
-static void swr_drv_shutdown(struct device *dev)
-{
-	const struct swr_driver *sdrv = to_swr_driver(dev->driver);
-
-	if (!sdrv)
-		return;
-
-	if (sdrv->shutdown)
-		sdrv->shutdown(to_swr_device(dev));
-}
-
-/**
- * swr_driver_register - register a soundwire driver
- * @drv: the driver to register
- * Context: can sleep
- */
-int swr_driver_register(struct swr_driver *drv)
-{
-	drv->driver.bus = &soundwire_type;
-	if (drv->probe)
-		drv->driver.probe = swr_drv_probe;
-	if (drv->remove)
-		drv->driver.remove = swr_drv_remove;
-
-	if (drv->shutdown)
-		drv->driver.shutdown = swr_drv_shutdown;
-
-	return driver_register(&drv->driver);
-}
-EXPORT_SYMBOL(swr_driver_register);
-
-/**
- * swr_driver_unregister - unregister a soundwire driver
- * @drv: the driver to unregister
- */
-void swr_driver_unregister(struct swr_driver *drv)
-{
-	if (drv)
-		driver_unregister(&drv->driver);
-}
-EXPORT_SYMBOL(swr_driver_unregister);
-
-static void swr_match_ctrl_to_boardinfo(struct swr_master *master,
-				struct swr_boardinfo *bi)
-{
-	struct swr_device *swr;
-
-	if (master->bus_num != bi->bus_num) {
-		dev_dbg(&master->dev,
-			"%s: master# %d and bi# %d does not match\n",
-			__func__, master->bus_num, bi->bus_num);
-		return;
-	}
-
-	swr = swr_new_device(master, bi);
-	if (!swr)
-		dev_err(&master->dev, "can't create new device for %s\n",
-			bi->swr_slave->name);
-}
-
-/**
- * swr_master_add_boarddevices - Add devices registered by board info
- * @master: master to which these devices are to be added to.
- *
- * This API is called by master when it is up and running. If devices
- * on a master were registered before master, this will make sure that
- * they get probed when master is up.
- */
-void swr_master_add_boarddevices(struct swr_master *master)
-{
-	struct boardinfo *bi;
-
-	mutex_lock(&board_lock);
-	list_add_tail(&master->list, &swr_master_list);
-	list_for_each_entry(bi, &board_list, list)
-		swr_match_ctrl_to_boardinfo(master, &bi->board_info);
-	mutex_unlock(&board_lock);
-}
-EXPORT_SYMBOL(swr_master_add_boarddevices);
-
-static void swr_unregister_device(struct swr_device *swr)
-{
-	if (swr)
-		device_unregister(&swr->dev);
-}
-
-static void swr_master_release(struct device *dev)
-{
-	/* kfree of master done at swrm_remove of device */
-}
-
-#define swr_master_attr_gr NULL
-static struct device_type swr_master_type = {
-	.groups     = swr_master_attr_gr,
-	.release    = swr_master_release,
-};
-
-static int __unregister(struct device *dev, void *null)
-{
-	swr_unregister_device(to_swr_device(dev));
-	return 0;
-}
-
-/**
- * swr_unregister_master - unregister soundwire master controller
- * @master: the master being unregistered
- *
- * This API is called by master controller driver to unregister
- *  master controller that was registered by swr_register_master API.
- */
-void swr_unregister_master(struct swr_master *master)
-{
-	int dummy;
-	struct swr_master *m_ctrl;
-
-	mutex_lock(&swr_lock);
-	m_ctrl = idr_find(&master_idr, master->bus_num);
-	mutex_unlock(&swr_lock);
-	if (m_ctrl != master)
-		return;
-
-	mutex_lock(&board_lock);
-	list_del(&master->list);
-	mutex_unlock(&board_lock);
-
-	/* free bus id */
-	mutex_lock(&swr_lock);
-	idr_remove(&master_idr, master->bus_num);
-	mutex_unlock(&swr_lock);
-
-	dummy = device_for_each_child(&master->dev, NULL, __unregister);
-	device_unregister(&master->dev);
-}
-EXPORT_SYMBOL(swr_unregister_master);
-
-/**
- * swr_register_master - register soundwire master controller
- * @master: master to be registered
- *
- * This API will register master with the framework. master->bus_num
- * is the desired number with which soundwire framework registers the
- * master.
- */
-int swr_register_master(struct swr_master *master)
-{
-	int id;
-	int status = 0;
-
-	mutex_lock(&swr_lock);
-	id = idr_alloc(&master_idr, master, master->bus_num,
-			master->bus_num+1, GFP_KERNEL);
-	mutex_unlock(&swr_lock);
-	if (id < 0)
-		return id;
-	master->bus_num = id;
-
-	/* Can't register until driver model init */
-	if (WARN_ON(!soundwire_type.p)) {
-		status = -EAGAIN;
-		goto done;
-	}
-
-	dev_set_name(&master->dev, "swr%u", master->bus_num);
-	master->dev.bus = &soundwire_type;
-	master->dev.type = &swr_master_type;
-	mutex_init(&master->mlock);
-	status = device_register(&master->dev);
-	if (status < 0)
-		goto done;
-
-	INIT_LIST_HEAD(&master->devices);
-	pr_debug("%s: SWR master registered successfully %s\n",
-		__func__, dev_name(&master->dev));
-	return 0;
-
-done:
-	idr_remove(&master_idr, master->bus_num);
-	return status;
-}
-EXPORT_SYMBOL(swr_register_master);
-
-#define swr_device_attr_gr NULL
-#define swr_device_uevent NULL
-static struct device_type swr_dev_type = {
-	.groups    = swr_device_attr_gr,
-	.uevent    = swr_device_uevent,
-	.release   = swr_dev_release,
-};
-
-static const struct swr_device_id *swr_match(const struct swr_device_id *id,
-					     const struct swr_device *swr_dev)
-{
-	while (id->name[0]) {
-		if (strcmp(swr_dev->name, id->name) == 0)
-			return id;
-		id++;
-	}
-	return NULL;
-}
-
-static int swr_device_match(struct device *dev, struct device_driver *driver)
-{
-	struct swr_device *swr_dev;
-	struct swr_driver *drv = to_swr_driver(driver);
-
-	if (!drv)
-		return -EINVAL;
-
-	if (dev->type == &swr_dev_type)
-		swr_dev = to_swr_device(dev);
-	else
-		return 0;
-	if (drv->id_table)
-		return swr_match(drv->id_table, swr_dev) != NULL;
-
-	if (driver->name)
-		return strcmp(swr_dev->name, driver->name) == 0;
-	return 0;
-}
-#ifdef CONFIG_PM_SLEEP
-static int swr_legacy_suspend(struct device *dev, pm_message_t mesg)
-{
-	struct swr_device *swr_dev = NULL;
-	struct swr_driver *driver;
-
-	if (dev->type == &swr_dev_type)
-		swr_dev = to_swr_device(dev);
-
-	if (!swr_dev || !dev->driver)
-		return 0;
-
-	driver = to_swr_driver(dev->driver);
-	if (!driver->suspend)
-		return 0;
-
-	return driver->suspend(swr_dev, mesg);
-}
-
-static int swr_legacy_resume(struct device *dev)
-{
-	struct swr_device *swr_dev = NULL;
-	struct swr_driver *driver;
-
-	if (dev->type == &swr_dev_type)
-		swr_dev = to_swr_device(dev);
-
-	if (!swr_dev || !dev->driver)
-		return 0;
-
-	driver = to_swr_driver(dev->driver);
-	if (!driver->resume)
-		return 0;
-
-	return driver->resume(swr_dev);
-}
-
-static int swr_pm_suspend(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_suspend(dev);
-	else
-		return swr_legacy_suspend(dev, PMSG_SUSPEND);
-}
-
-static int swr_pm_resume(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_resume(dev);
-	else
-		return swr_legacy_resume(dev);
-}
-#else
-#define swr_pm_suspend	NULL
-#define swr_pm_resume	NULL
-#endif /*CONFIG_PM_SLEEP*/
-
-static const struct dev_pm_ops soundwire_pm = {
-	.suspend = swr_pm_suspend,
-	.resume = swr_pm_resume,
-	SET_RUNTIME_PM_OPS(
-		pm_generic_suspend,
-		pm_generic_resume,
-		NULL
-		)
-};
-
-struct device soundwire_dev = {
-	.init_name = "soundwire",
-};
-
-struct bus_type soundwire_type = {
-	.name		= "soundwire",
-	.match		= swr_device_match,
-	.pm		= &soundwire_pm,
-};
-EXPORT_SYMBOL(soundwire_type);
-
-static void __exit soundwire_exit(void)
-{
-	device_unregister(&soundwire_dev);
-	bus_unregister(&soundwire_type);
-}
-
-static int __init soundwire_init(void)
-{
-	int retval;
-
-	retval = bus_register(&soundwire_type);
-	if (!retval)
-		retval = device_register(&soundwire_dev);
-
-	if (retval)
-		bus_unregister(&soundwire_type);
-
-	return retval;
-}
-postcore_initcall(soundwire_init);
-module_exit(soundwire_exit);
-
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Soundwire module");
-MODULE_ALIAS("platform:soundwire");
diff --git a/drivers/soundwire/swr-wcd-ctrl.c b/drivers/soundwire/swr-wcd-ctrl.c
deleted file mode 100644
index be0b5ce..0000000
--- a/drivers/soundwire/swr-wcd-ctrl.c
+++ /dev/null
@@ -1,1892 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/soundwire/soundwire.h>
-#include <linux/soundwire/swr-wcd.h>
-#include <linux/delay.h>
-#include <linux/kthread.h>
-#include <linux/clk.h>
-#include <linux/pm_runtime.h>
-#include <linux/of.h>
-#include <linux/debugfs.h>
-#include <linux/uaccess.h>
-#include "swrm_registers.h"
-#include "swr-wcd-ctrl.h"
-
-#define SWR_BROADCAST_CMD_ID            0x0F
-#define SWR_AUTO_SUSPEND_DELAY          3 /* delay in sec */
-#define SWR_DEV_ID_MASK			0xFFFFFFFF
-#define SWR_REG_VAL_PACK(data, dev, id, reg)	\
-			((reg) | ((id) << 16) | ((dev) << 20) | ((data) << 24))
-
-/* pm runtime auto suspend timer in msecs */
-static int auto_suspend_timer = SWR_AUTO_SUSPEND_DELAY * 1000;
-module_param(auto_suspend_timer, int, 0664);
-MODULE_PARM_DESC(auto_suspend_timer, "timer for auto suspend");
-
-static u8 mstr_ports[] = {100, 101, 102, 103, 104, 105, 106, 107};
-static u8 mstr_port_type[] = {SWR_DAC_PORT, SWR_COMP_PORT, SWR_BOOST_PORT,
-			      SWR_DAC_PORT, SWR_COMP_PORT, SWR_BOOST_PORT,
-			      SWR_VISENSE_PORT, SWR_VISENSE_PORT};
-
-struct usecase uc[] = {
-	{0, 0, 0},		/* UC0: no ports */
-	{1, 1, 2400},		/* UC1: Spkr */
-	{1, 4, 600},		/* UC2: Compander */
-	{1, 2, 300},		/* UC3: Smart Boost */
-	{1, 2, 1200},		/* UC4: VI Sense */
-	{4, 9, 4500},		/* UC5: Spkr + Comp + SB + VI */
-	{8, 18, 9000},		/* UC6: 2*(Spkr + Comp + SB + VI) */
-	{2, 2, 4800},		/* UC7: 2*Spkr */
-	{2, 5, 3000},		/* UC8: Spkr + Comp */
-	{4, 10, 6000},		/* UC9: 2*(Spkr + Comp) */
-	{3, 7, 3300},		/* UC10: Spkr + Comp + SB */
-	{6, 14, 6600},		/* UC11: 2*(Spkr + Comp + SB) */
-	{2, 3, 2700},		/* UC12: Spkr + SB */
-	{4, 6, 5400},		/* UC13: 2*(Spkr + SB) */
-	{3, 5, 3900},		/* UC14: Spkr + SB + VI */
-	{6, 10, 7800},		/* UC15: 2*(Spkr + SB + VI) */
-	{2, 3, 3600},		/* UC16: Spkr + VI */
-	{4, 6, 7200},		/* UC17: 2*(Spkr + VI) */
-	{3, 7, 4200},		/* UC18: Spkr + Comp + VI */
-	{6, 14, 8400},		/* UC19: 2*(Spkr + Comp + VI) */
-};
-#define MAX_USECASE	ARRAY_SIZE(uc)
-
-struct port_params pp[MAX_USECASE][SWR_MSTR_PORT_LEN] = {
-	/* UC 0 */
-	{
-		{0, 0, 0},
-	},
-	/* UC 1 */
-	{
-		{7, 1, 0},
-	},
-	/* UC 2 */
-	{
-		{31, 2, 0},
-	},
-	/* UC 3 */
-	{
-		{63, 12, 31},
-	},
-	/* UC 4 */
-	{
-		{15, 7, 0},
-	},
-	/* UC 5 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{63, 12, 31},
-		{15, 7, 0},
-	},
-	/* UC 6 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{63, 12, 31},
-		{15, 7, 0},
-		{7, 6, 0},
-		{31, 18, 0},
-		{63, 13, 31},
-		{15, 10, 0},
-	},
-	/* UC 7 */
-	{
-		{7, 1, 0},
-		{7, 6, 0},
-
-	},
-	/* UC 8 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-	},
-	/* UC 9 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{7, 6, 0},
-		{31, 18, 0},
-	},
-	/* UC 10 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{63, 12, 31},
-	},
-	/* UC 11 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{63, 12, 31},
-		{7, 6, 0},
-		{31, 18, 0},
-		{63, 13, 31},
-	},
-	/* UC 12 */
-	{
-		{7, 1, 0},
-		{63, 12, 31},
-	},
-	/* UC 13 */
-	{
-		{7, 1, 0},
-		{63, 12, 31},
-		{7, 6, 0},
-		{63, 13, 31},
-	},
-	/* UC 14 */
-	{
-		{7, 1, 0},
-		{63, 12, 31},
-		{15, 7, 0},
-	},
-	/* UC 15 */
-	{
-		{7, 1, 0},
-		{63, 12, 31},
-		{15, 7, 0},
-		{7, 6, 0},
-		{63, 13, 31},
-		{15, 10, 0},
-	},
-	/* UC 16 */
-	{
-		{7, 1, 0},
-		{15, 7, 0},
-	},
-	/* UC 17 */
-	{
-		{7, 1, 0},
-		{15, 7, 0},
-		{7, 6, 0},
-		{15, 10, 0},
-	},
-	/* UC 18 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{15, 7, 0},
-	},
-	/* UC 19 */
-	{
-		{7, 1, 0},
-		{31, 2, 0},
-		{15, 7, 0},
-		{7, 6, 0},
-		{31, 18, 0},
-		{15, 10, 0},
-	},
-};
-
-enum {
-	SWR_NOT_PRESENT, /* Device is detached/not present on the bus */
-	SWR_ATTACHED_OK, /* Device is attached */
-	SWR_ALERT,       /* Device alters master for any interrupts */
-	SWR_RESERVED,    /* Reserved */
-};
-
-#define SWRM_MAX_PORT_REG    40
-#define SWRM_MAX_INIT_REG    8
-
-#define SWR_MSTR_MAX_REG_ADDR	0x1740
-#define SWR_MSTR_START_REG_ADDR	0x00
-#define SWR_MSTR_MAX_BUF_LEN     32
-#define BYTES_PER_LINE          12
-#define SWR_MSTR_RD_BUF_LEN      8
-#define SWR_MSTR_WR_BUF_LEN      32
-
-static void swrm_copy_data_port_config(struct swr_master *master,
-				       u8 inactive_bank);
-static struct swr_mstr_ctrl *dbgswrm;
-static struct dentry *debugfs_swrm_dent;
-static struct dentry *debugfs_peek;
-static struct dentry *debugfs_poke;
-static struct dentry *debugfs_reg_dump;
-static unsigned int read_data;
-
-
-static bool swrm_is_msm_variant(int val)
-{
-	return (val == SWRM_VERSION_1_3);
-}
-
-static int swrm_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static int get_parameters(char *buf, u32 *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (kstrtou32(token, base, &param1[cnt]) != 0)
-				return -EINVAL;
-
-			token = strsep(&buf, " ");
-		} else
-			return -EINVAL;
-	}
-	return 0;
-}
-
-static ssize_t swrm_reg_show(char __user *ubuf, size_t count,
-					  loff_t *ppos)
-{
-	int i, reg_val, len;
-	ssize_t total = 0;
-	char tmp_buf[SWR_MSTR_MAX_BUF_LEN];
-
-	if (!ubuf || !ppos)
-		return 0;
-
-	for (i = (((int) *ppos / BYTES_PER_LINE) + SWR_MSTR_START_REG_ADDR);
-		i <= SWR_MSTR_MAX_REG_ADDR; i += 4) {
-		reg_val = dbgswrm->read(dbgswrm->handle, i);
-		len = snprintf(tmp_buf, 25, "0x%.3x: 0x%.2x\n", i, reg_val);
-		if ((total + len) >= count - 1)
-			break;
-		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
-			total = -EFAULT;
-			goto copy_err;
-		}
-		*ppos += len;
-		total += len;
-	}
-
-copy_err:
-	return total;
-}
-
-static ssize_t swrm_debug_read(struct file *file, char __user *ubuf,
-				size_t count, loff_t *ppos)
-{
-	char lbuf[SWR_MSTR_RD_BUF_LEN];
-	char *access_str;
-	ssize_t ret_cnt;
-
-	if (!count || !file || !ppos || !ubuf)
-		return -EINVAL;
-
-	access_str = file->private_data;
-	if (*ppos < 0)
-		return -EINVAL;
-
-	if (!strcmp(access_str, "swrm_peek")) {
-		snprintf(lbuf, sizeof(lbuf), "0x%x\n", read_data);
-		ret_cnt = simple_read_from_buffer(ubuf, count, ppos, lbuf,
-					       strnlen(lbuf, 7));
-	} else if (!strcmp(access_str, "swrm_reg_dump")) {
-		ret_cnt = swrm_reg_show(ubuf, count, ppos);
-	} else {
-		pr_err("%s: %s not permitted to read\n", __func__, access_str);
-		ret_cnt = -EPERM;
-	}
-	return ret_cnt;
-}
-
-static ssize_t swrm_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char lbuf[SWR_MSTR_WR_BUF_LEN];
-	int rc;
-	u32 param[5];
-	char *access_str;
-
-	if (!filp || !ppos || !ubuf)
-		return -EINVAL;
-
-	access_str = filp->private_data;
-	if (cnt > sizeof(lbuf) - 1)
-		return -EINVAL;
-
-	rc = copy_from_user(lbuf, ubuf, cnt);
-	if (rc)
-		return -EFAULT;
-
-	lbuf[cnt] = '\0';
-	if (!strcmp(access_str, "swrm_poke")) {
-		/* write */
-		rc = get_parameters(lbuf, param, 2);
-		if ((param[0] <= SWR_MSTR_MAX_REG_ADDR) &&
-			(param[1] <= 0xFFFFFFFF) &&
-			(rc == 0))
-			rc = dbgswrm->write(dbgswrm->handle, param[0],
-					    param[1]);
-		else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "swrm_peek")) {
-		/* read */
-		rc = get_parameters(lbuf, param, 1);
-		if ((param[0] <= SWR_MSTR_MAX_REG_ADDR) && (rc == 0))
-			read_data = dbgswrm->read(dbgswrm->handle, param[0]);
-		else
-			rc = -EINVAL;
-	}
-	if (rc == 0)
-		rc = cnt;
-	else
-		pr_err("%s: rc = %d\n", __func__, rc);
-
-	return rc;
-}
-
-static const struct file_operations swrm_debug_ops = {
-	.open = swrm_debug_open,
-	.write = swrm_debug_write,
-	.read = swrm_debug_read,
-};
-
-static int swrm_set_ch_map(struct swr_mstr_ctrl *swrm, void *data)
-{
-	struct swr_mstr_port *pinfo = (struct swr_mstr_port *)data;
-
-	swrm->mstr_port = kzalloc(sizeof(struct swr_mstr_port), GFP_KERNEL);
-	if (swrm->mstr_port == NULL)
-		return -ENOMEM;
-	swrm->mstr_port->num_port = pinfo->num_port;
-	swrm->mstr_port->port = kzalloc((pinfo->num_port * sizeof(u8)),
-					GFP_KERNEL);
-	if (!swrm->mstr_port->port) {
-		kfree(swrm->mstr_port);
-		swrm->mstr_port = NULL;
-		return -ENOMEM;
-	}
-	memcpy(swrm->mstr_port->port, pinfo->port, pinfo->num_port);
-	return 0;
-}
-
-static bool swrm_is_port_en(struct swr_master *mstr)
-{
-	return !!(mstr->num_port);
-}
-
-static int swrm_clk_request(struct swr_mstr_ctrl *swrm, bool enable)
-{
-	if (!swrm->clk || !swrm->handle)
-		return -EINVAL;
-
-	if (enable) {
-		swrm->clk_ref_count++;
-		if (swrm->clk_ref_count == 1) {
-			swrm->clk(swrm->handle, true);
-			swrm->state = SWR_MSTR_UP;
-		}
-	} else if (--swrm->clk_ref_count == 0) {
-		swrm->clk(swrm->handle, false);
-		swrm->state = SWR_MSTR_DOWN;
-	} else if (swrm->clk_ref_count < 0) {
-		pr_err("%s: swrm clk count mismatch\n", __func__);
-		swrm->clk_ref_count = 0;
-	}
-	return 0;
-}
-
-static int swrm_get_port_config(struct swr_master *master)
-{
-	u32 ch_rate = 0;
-	u32 num_ch = 0;
-	int i, uc_idx;
-	u32 portcount = 0;
-
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		if (master->port[i].port_en) {
-			ch_rate += master->port[i].ch_rate;
-			num_ch += master->port[i].num_ch;
-			portcount++;
-		}
-	}
-	for (i = 0; i < ARRAY_SIZE(uc); i++) {
-		if ((uc[i].num_port == portcount) &&
-		    (uc[i].num_ch == num_ch) &&
-		    (uc[i].chrate == ch_rate)) {
-			uc_idx = i;
-			break;
-		}
-	}
-
-	if (i >= ARRAY_SIZE(uc)) {
-		dev_err(&master->dev,
-			"%s: usecase port:%d, num_ch:%d, chrate:%d not found\n",
-			__func__, master->num_port, num_ch, ch_rate);
-		return -EINVAL;
-	}
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		if (master->port[i].port_en) {
-			master->port[i].sinterval = pp[uc_idx][i].si;
-			master->port[i].offset1 = pp[uc_idx][i].off1;
-			master->port[i].offset2 = pp[uc_idx][i].off2;
-		}
-	}
-	return 0;
-}
-
-static int swrm_get_master_port(u8 *mstr_port_id, u8 slv_port_id)
-{
-	int i;
-
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		if (mstr_ports[i] == slv_port_id) {
-			*mstr_port_id = i;
-			return 0;
-		}
-	}
-	return -EINVAL;
-}
-
-static u32 swrm_get_packed_reg_val(u8 *cmd_id, u8 cmd_data,
-				 u8 dev_addr, u16 reg_addr)
-{
-	u32 val;
-	u8 id = *cmd_id;
-
-	if (id != SWR_BROADCAST_CMD_ID) {
-		if (id < 14)
-			id += 1;
-		else
-			id = 0;
-		*cmd_id = id;
-	}
-	val = SWR_REG_VAL_PACK(cmd_data, dev_addr, id, reg_addr);
-
-	return val;
-}
-
-static int swrm_cmd_fifo_rd_cmd(struct swr_mstr_ctrl *swrm, int *cmd_data,
-				 u8 dev_addr, u8 cmd_id, u16 reg_addr,
-				 u32 len)
-{
-	u32 val;
-	int ret = 0;
-
-	val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr);
-	ret = swrm->write(swrm->handle, SWRM_CMD_FIFO_RD_CMD, val);
-	if (ret < 0) {
-		dev_err(swrm->dev, "%s: reg 0x%x write failed, err:%d\n",
-			__func__, val, ret);
-		goto err;
-	}
-	*cmd_data = swrm->read(swrm->handle, SWRM_CMD_FIFO_RD_FIFO_ADDR);
-	dev_dbg(swrm->dev,
-		"%s: reg: 0x%x, cmd_id: 0x%x, dev_id: 0x%x, cmd_data: 0x%x\n",
-		__func__, reg_addr, cmd_id, dev_addr, *cmd_data);
-err:
-	return ret;
-}
-
-static int swrm_cmd_fifo_wr_cmd(struct swr_mstr_ctrl *swrm, u8 cmd_data,
-				 u8 dev_addr, u8 cmd_id, u16 reg_addr)
-{
-	u32 val;
-	int ret = 0;
-
-	if (!cmd_id)
-		val = swrm_get_packed_reg_val(&swrm->wcmd_id, cmd_data,
-					      dev_addr, reg_addr);
-	else
-		val = swrm_get_packed_reg_val(&cmd_id, cmd_data,
-					      dev_addr, reg_addr);
-
-	dev_dbg(swrm->dev,
-		"%s: reg: 0x%x, cmd_id: 0x%x, dev_id: 0x%x, cmd_data: 0x%x\n",
-		__func__, reg_addr, cmd_id, dev_addr, cmd_data);
-	ret = swrm->write(swrm->handle, SWRM_CMD_FIFO_WR_CMD, val);
-	if (ret < 0) {
-		dev_err(swrm->dev, "%s: reg 0x%x write failed, err:%d\n",
-			__func__, val, ret);
-		goto err;
-	}
-	if (cmd_id == 0xF) {
-		/*
-		 * sleep for 10ms for MSM soundwire variant to allow broadcast
-		 * command to complete.
-		 */
-		if (swrm_is_msm_variant(swrm->version))
-			usleep_range(10000, 10100);
-		else
-			wait_for_completion_timeout(&swrm->broadcast,
-						    (2 * HZ/10));
-	}
-err:
-	return ret;
-}
-
-static int swrm_read(struct swr_master *master, u8 dev_num, u16 reg_addr,
-		     void *buf, u32 len)
-{
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	int ret = 0;
-	int val;
-	u8 *reg_val = (u8 *)buf;
-
-	if (!swrm) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (dev_num)
-		ret = swrm_cmd_fifo_rd_cmd(swrm, &val, dev_num, 0, reg_addr,
-					   len);
-	else
-		val = swrm->read(swrm->handle, reg_addr);
-
-	if (!ret)
-		*reg_val = (u8)val;
-
-	pm_runtime_mark_last_busy(&swrm->pdev->dev);
-
-	return ret;
-}
-
-static int swrm_write(struct swr_master *master, u8 dev_num, u16 reg_addr,
-		      const void *buf)
-{
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	int ret = 0;
-	u8 reg_val = *(u8 *)buf;
-
-	if (!swrm) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (dev_num)
-		ret = swrm_cmd_fifo_wr_cmd(swrm, reg_val, dev_num, 0, reg_addr);
-	else
-		ret = swrm->write(swrm->handle, reg_addr, reg_val);
-
-	pm_runtime_mark_last_busy(&swrm->pdev->dev);
-
-	return ret;
-}
-
-static int swrm_bulk_write(struct swr_master *master, u8 dev_num, void *reg,
-			   const void *buf, size_t len)
-{
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	int ret = 0;
-	int i;
-	u32 *val;
-	u32 *swr_fifo_reg;
-
-	if (!swrm || !swrm->handle) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (len <= 0)
-		return -EINVAL;
-
-	if (dev_num) {
-		swr_fifo_reg = kcalloc(len, sizeof(u32), GFP_KERNEL);
-		if (!swr_fifo_reg) {
-			ret = -ENOMEM;
-			goto err;
-		}
-		val = kcalloc(len, sizeof(u32), GFP_KERNEL);
-		if (!val) {
-			ret = -ENOMEM;
-			goto mem_fail;
-		}
-
-		for (i = 0; i < len; i++) {
-			val[i] = swrm_get_packed_reg_val(&swrm->wcmd_id,
-							 ((u8 *)buf)[i],
-							 dev_num,
-							 ((u16 *)reg)[i]);
-			swr_fifo_reg[i] = SWRM_CMD_FIFO_WR_CMD;
-		}
-		ret = swrm->bulk_write(swrm->handle, swr_fifo_reg, val, len);
-		if (ret) {
-			dev_err(&master->dev, "%s: bulk write failed\n",
-				__func__);
-			ret = -EINVAL;
-		}
-	} else {
-		dev_err(&master->dev,
-			"%s: No support of Bulk write for master regs\n",
-			__func__);
-		ret = -EINVAL;
-		goto err;
-	}
-	kfree(val);
-mem_fail:
-	kfree(swr_fifo_reg);
-err:
-	pm_runtime_mark_last_busy(&swrm->pdev->dev);
-	return ret;
-}
-
-static u8 get_inactive_bank_num(struct swr_mstr_ctrl *swrm)
-{
-	return (swrm->read(swrm->handle, SWRM_MCP_STATUS) &
-		SWRM_MCP_STATUS_BANK_NUM_MASK) ? 0 : 1;
-}
-
-static void enable_bank_switch(struct swr_mstr_ctrl *swrm, u8 bank,
-				u8 row, u8 col)
-{
-	swrm_cmd_fifo_wr_cmd(swrm, ((row << 3) | col), 0xF, 0xF,
-			SWRS_SCP_FRAME_CTRL_BANK(bank));
-}
-
-static struct swr_port_info *swrm_get_port(struct swr_master *master,
-					   u8 port_id)
-{
-	int i;
-	struct swr_port_info *port = NULL;
-
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		port = &master->port[i];
-		if (port->port_id == port_id) {
-			dev_dbg(&master->dev, "%s: port_id: %d, index: %d\n",
-				__func__, port_id, i);
-			return port;
-		}
-	}
-
-	return NULL;
-}
-
-static struct swr_port_info *swrm_get_avail_port(struct swr_master *master)
-{
-	int i;
-	struct swr_port_info *port = NULL;
-
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		port = &master->port[i];
-		if (port->port_en)
-			continue;
-
-		dev_dbg(&master->dev, "%s: port_id: %d, index: %d\n",
-			__func__, port->port_id, i);
-		return port;
-	}
-
-	return NULL;
-}
-
-static struct swr_port_info *swrm_get_enabled_port(struct swr_master *master,
-						   u8 port_id)
-{
-	int i;
-	struct swr_port_info *port = NULL;
-
-	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
-		port = &master->port[i];
-		if ((port->port_id == port_id) && (port->port_en == true))
-			break;
-	}
-	if (i == SWR_MSTR_PORT_LEN)
-		port = NULL;
-	return port;
-}
-
-static bool swrm_remove_from_group(struct swr_master *master)
-{
-	struct swr_device *swr_dev;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	bool is_removed = false;
-
-	if (!swrm)
-		goto end;
-
-	mutex_lock(&swrm->mlock);
-	if ((swrm->num_rx_chs > 1) &&
-	    (swrm->num_rx_chs == swrm->num_cfg_devs)) {
-		list_for_each_entry(swr_dev, &master->devices,
-				dev_list) {
-			swr_dev->group_id = SWR_GROUP_NONE;
-			master->gr_sid = 0;
-		}
-		is_removed = true;
-	}
-	mutex_unlock(&swrm->mlock);
-
-end:
-	return is_removed;
-}
-
-static void swrm_cleanup_disabled_data_ports(struct swr_master *master,
-					     u8 bank)
-{
-	u32 value;
-	struct swr_port_info *port;
-	int i;
-	int port_type;
-	struct swrm_mports *mport, *mport_next = NULL;
-	int port_disable_cnt = 0;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-
-	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
-		return;
-	}
-
-	dev_dbg(swrm->dev, "%s: master num_port: %d\n", __func__,
-		master->num_port);
-
-	mport = list_first_entry_or_null(&swrm->mport_list,
-					struct swrm_mports,
-					list);
-	if (!mport) {
-		dev_err(swrm->dev, "%s: list is empty\n", __func__);
-		return;
-	}
-
-	for (i = 0; i < master->num_port; i++) {
-		port = swrm_get_port(master, mstr_ports[mport->id]);
-		if (!port || port->ch_en)
-			goto inc_loop;
-
-		port_disable_cnt++;
-		port_type = mstr_port_type[mport->id];
-		value = ((port->ch_en)
-				<< SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
-		value |= ((port->offset2)
-				<< SWRM_DP_PORT_CTRL_OFFSET2_SHFT);
-		value |= ((port->offset1)
-				<< SWRM_DP_PORT_CTRL_OFFSET1_SHFT);
-		value |= port->sinterval;
-
-		swrm->write(swrm->handle,
-			    SWRM_DP_PORT_CTRL_BANK((mport->id+1), bank),
-			    value);
-		swrm_cmd_fifo_wr_cmd(swrm, 0x00, port->dev_id, 0x00,
-				SWRS_DP_CHANNEL_ENABLE_BANK(port_type, bank));
-
-		dev_dbg(swrm->dev, "%s: mport :%d, reg: 0x%x, val: 0x%x\n",
-			__func__, mport->id,
-			(SWRM_DP_PORT_CTRL_BANK((mport->id+1), bank)), value);
-
-inc_loop:
-		mport_next = list_next_entry(mport, list);
-		if (port && !port->ch_en) {
-			list_del(&mport->list);
-			kfree(mport);
-		}
-		if (!mport_next) {
-			dev_err(swrm->dev, "%s: end of list\n", __func__);
-			break;
-		}
-		mport = mport_next;
-	}
-	master->num_port -= port_disable_cnt;
-
-	dev_dbg(swrm->dev, "%s:disable ports: %d, active ports (rem): %d\n",
-		__func__, port_disable_cnt,  master->num_port);
-}
-
-static void swrm_slvdev_datapath_control(struct swr_master *master,
-					 bool enable)
-{
-	u8 bank;
-	u32 value, n_col;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	int mask = (SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK |
-		    SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK |
-		    SWRM_MCP_FRAME_CTRL_BANK_SSP_PERIOD_BMSK);
-	u8 inactive_bank;
-
-	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
-		return;
-	}
-
-	bank = get_inactive_bank_num(swrm);
-
-	dev_dbg(swrm->dev, "%s: enable: %d, cfg_devs: %d\n",
-		__func__, enable, swrm->num_cfg_devs);
-
-	if (enable) {
-		/* set Row = 48 and col = 16 */
-		n_col = SWR_MAX_COL;
-	} else {
-		/*
-		 * Do not change to 48x2 if number of channels configured
-		 * as stereo and if disable datapath is called for the
-		 * first slave device
-		 */
-		if (swrm->num_cfg_devs > 0)
-			n_col = SWR_MAX_COL;
-		else
-			n_col = SWR_MIN_COL;
-
-		/*
-		 * All ports are already disabled, no need to perform
-		 * bank-switch and copy operation. This case can arise
-		 * when speaker channels are enabled in stereo mode with
-		 * BROADCAST and disabled in GROUP_NONE
-		 */
-		if (master->num_port == 0)
-			return;
-	}
-
-	value = swrm->read(swrm->handle, SWRM_MCP_FRAME_CTRL_BANK_ADDR(bank));
-	value &= (~mask);
-	value |= ((0 << SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_SHFT) |
-		  (n_col << SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_SHFT) |
-		  (0 << SWRM_MCP_FRAME_CTRL_BANK_SSP_PERIOD_SHFT));
-	swrm->write(swrm->handle, SWRM_MCP_FRAME_CTRL_BANK_ADDR(bank), value);
-
-	dev_dbg(swrm->dev, "%s: regaddr: 0x%x, value: 0x%x\n", __func__,
-		SWRM_MCP_FRAME_CTRL_BANK_ADDR(bank), value);
-
-	enable_bank_switch(swrm, bank, SWR_MAX_ROW, n_col);
-
-	inactive_bank = bank ? 0 : 1;
-	if (enable)
-		swrm_copy_data_port_config(master, inactive_bank);
-	else
-		swrm_cleanup_disabled_data_ports(master, inactive_bank);
-
-	if (!swrm_is_port_en(master)) {
-		dev_dbg(&master->dev, "%s: pm_runtime auto suspend triggered\n",
-			__func__);
-		pm_runtime_mark_last_busy(&swrm->pdev->dev);
-		pm_runtime_put_autosuspend(&swrm->pdev->dev);
-	}
-}
-
-static void swrm_apply_port_config(struct swr_master *master)
-{
-	u8 bank;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-
-	if (!swrm) {
-		pr_err("%s: Invalid handle to swr controller\n",
-			__func__);
-		return;
-	}
-
-	bank = get_inactive_bank_num(swrm);
-	dev_dbg(swrm->dev, "%s: enter bank: %d master_ports: %d\n",
-		__func__, bank, master->num_port);
-
-
-	swrm_cmd_fifo_wr_cmd(swrm, 0x01, 0xF, 0x00,
-			SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(bank));
-
-	swrm_copy_data_port_config(master, bank);
-}
-
-static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
-{
-	u32 value;
-	struct swr_port_info *port;
-	int i;
-	int port_type;
-	struct swrm_mports *mport;
-	u32 reg[SWRM_MAX_PORT_REG];
-	u32 val[SWRM_MAX_PORT_REG];
-	int len = 0;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-
-	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
-		return;
-	}
-
-	dev_dbg(swrm->dev, "%s: master num_port: %d\n", __func__,
-		master->num_port);
-
-	mport = list_first_entry_or_null(&swrm->mport_list,
-					struct swrm_mports,
-					list);
-	if (!mport) {
-		dev_err(swrm->dev, "%s: list is empty\n", __func__);
-		return;
-	}
-	for (i = 0; i < master->num_port; i++) {
-
-		port = swrm_get_enabled_port(master, mstr_ports[mport->id]);
-		if (!port)
-			continue;
-		port_type = mstr_port_type[mport->id];
-		if (!port->dev_id || (port->dev_id > master->num_dev)) {
-			dev_dbg(swrm->dev, "%s: invalid device id = %d\n",
-				__func__, port->dev_id);
-			continue;
-		}
-		value = ((port->ch_en)
-				<< SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
-		value |= ((port->offset2)
-				<< SWRM_DP_PORT_CTRL_OFFSET2_SHFT);
-		value |= ((port->offset1)
-				<< SWRM_DP_PORT_CTRL_OFFSET1_SHFT);
-		value |= port->sinterval;
-
-		reg[len] = SWRM_DP_PORT_CTRL_BANK((mport->id+1), bank);
-		val[len++] = value;
-
-		dev_dbg(swrm->dev, "%s: mport :%d, reg: 0x%x, val: 0x%x\n",
-			__func__, mport->id,
-			(SWRM_DP_PORT_CTRL_BANK((mport->id+1), bank)), value);
-
-		reg[len] = SWRM_CMD_FIFO_WR_CMD;
-		val[len++] = SWR_REG_VAL_PACK(port->ch_en, port->dev_id, 0x00,
-				SWRS_DP_CHANNEL_ENABLE_BANK(port_type, bank));
-
-		reg[len] = SWRM_CMD_FIFO_WR_CMD;
-		val[len++] = SWR_REG_VAL_PACK(port->sinterval,
-				port->dev_id, 0x00,
-				SWRS_DP_SAMPLE_CONTROL_1_BANK(port_type, bank));
-
-		reg[len] = SWRM_CMD_FIFO_WR_CMD;
-		val[len++] = SWR_REG_VAL_PACK(port->offset1,
-				port->dev_id, 0x00,
-				SWRS_DP_OFFSET_CONTROL_1_BANK(port_type, bank));
-
-		if (port_type != 0) {
-			reg[len] = SWRM_CMD_FIFO_WR_CMD;
-			val[len++] = SWR_REG_VAL_PACK(port->offset2,
-					port->dev_id, 0x00,
-					SWRS_DP_OFFSET_CONTROL_2_BANK(port_type,
-									bank));
-		}
-		mport = list_next_entry(mport, list);
-		if (!mport) {
-			dev_err(swrm->dev, "%s: end of list\n", __func__);
-			break;
-		}
-	}
-	swrm->bulk_write(swrm->handle, reg, val, len);
-}
-
-static int swrm_connect_port(struct swr_master *master,
-			struct swr_params *portinfo)
-{
-	int i;
-	struct swr_port_info *port;
-	int ret = 0;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-	struct swrm_mports *mport;
-	struct list_head *ptr, *next;
-
-	dev_dbg(&master->dev, "%s: enter\n", __func__);
-	if (!portinfo)
-		return -EINVAL;
-
-	if (!swrm) {
-		dev_err(&master->dev,
-			"%s: Invalid handle to swr controller\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&swrm->mlock);
-	if (!swrm_is_port_en(master))
-		pm_runtime_get_sync(&swrm->pdev->dev);
-
-	for (i = 0; i < portinfo->num_port; i++) {
-		mport = kzalloc(sizeof(struct swrm_mports), GFP_KERNEL);
-		if (!mport) {
-			ret = -ENOMEM;
-			goto mem_fail;
-		}
-		ret = swrm_get_master_port(&mport->id,
-						portinfo->port_id[i]);
-		if (ret < 0) {
-			dev_err(&master->dev,
-				"%s: mstr portid for slv port %d not found\n",
-				__func__, portinfo->port_id[i]);
-			goto port_fail;
-		}
-		port = swrm_get_avail_port(master);
-		if (!port) {
-			dev_err(&master->dev,
-				"%s: avail ports not found!\n", __func__);
-			goto port_fail;
-		}
-		list_add(&mport->list, &swrm->mport_list);
-		port->dev_id = portinfo->dev_id;
-		port->port_id = portinfo->port_id[i];
-		port->num_ch = portinfo->num_ch[i];
-		port->ch_rate = portinfo->ch_rate[i];
-		port->ch_en = portinfo->ch_en[i];
-		port->port_en = true;
-		dev_dbg(&master->dev,
-			"%s: mstr port %d, slv port %d ch_rate %d num_ch %d\n",
-			__func__, mport->id, port->port_id, port->ch_rate,
-			port->num_ch);
-	}
-	master->num_port += portinfo->num_port;
-	if (master->num_port >= SWR_MSTR_PORT_LEN)
-		master->num_port = SWR_MSTR_PORT_LEN;
-
-	swrm_get_port_config(master);
-	swr_port_response(master, portinfo->tid);
-	swrm->num_cfg_devs += 1;
-	dev_dbg(&master->dev, "%s: cfg_devs: %d, rx_chs: %d\n",
-		__func__, swrm->num_cfg_devs, swrm->num_rx_chs);
-	if (swrm->num_rx_chs > 1) {
-		if (swrm->num_rx_chs == swrm->num_cfg_devs)
-			swrm_apply_port_config(master);
-	} else {
-		swrm_apply_port_config(master);
-	}
-	mutex_unlock(&swrm->mlock);
-	return 0;
-
-port_fail:
-	kfree(mport);
-mem_fail:
-	list_for_each_safe(ptr, next, &swrm->mport_list) {
-		mport = list_entry(ptr, struct swrm_mports, list);
-		for (i = 0; i < portinfo->num_port; i++) {
-			if (portinfo->port_id[i] == mstr_ports[mport->id]) {
-				port = swrm_get_port(master,
-						portinfo->port_id[i]);
-				if (port)
-					port->ch_en = false;
-				list_del(&mport->list);
-				kfree(mport);
-				break;
-			}
-		}
-	}
-	mutex_unlock(&swrm->mlock);
-	return ret;
-}
-
-static int swrm_disconnect_port(struct swr_master *master,
-			struct swr_params *portinfo)
-{
-	int i;
-	struct swr_port_info *port;
-	u8 bank;
-	u32 value;
-	int ret = 0;
-	u8 mport_id = 0;
-	int port_type = 0;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
-
-	if (!swrm) {
-		dev_err(&master->dev,
-			"%s: Invalid handle to swr controller\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!portinfo) {
-		dev_err(&master->dev, "%s: portinfo is NULL\n", __func__);
-		return -EINVAL;
-	}
-	mutex_lock(&swrm->mlock);
-	bank = get_inactive_bank_num(swrm);
-	for (i = 0; i < portinfo->num_port; i++) {
-		ret = swrm_get_master_port(&mport_id,
-						portinfo->port_id[i]);
-		if (ret < 0) {
-			dev_err(&master->dev,
-				"%s: mstr portid for slv port %d not found\n",
-				__func__, portinfo->port_id[i]);
-			mutex_unlock(&swrm->mlock);
-			return -EINVAL;
-		}
-		port = swrm_get_enabled_port(master, portinfo->port_id[i]);
-		if (!port) {
-			dev_dbg(&master->dev, "%s: port %d already disabled\n",
-				__func__, portinfo->port_id[i]);
-			continue;
-		}
-		port_type = mstr_port_type[mport_id];
-		port->dev_id = portinfo->dev_id;
-		port->port_en = false;
-		port->ch_en = 0;
-		value = port->ch_en << SWRM_DP_PORT_CTRL_EN_CHAN_SHFT;
-		value |= (port->offset2 << SWRM_DP_PORT_CTRL_OFFSET2_SHFT);
-		value |= (port->offset1 << SWRM_DP_PORT_CTRL_OFFSET1_SHFT);
-		value |= port->sinterval;
-
-
-		swrm->write(swrm->handle,
-			    SWRM_DP_PORT_CTRL_BANK((mport_id+1), bank),
-			    value);
-		swrm_cmd_fifo_wr_cmd(swrm, 0x00, port->dev_id, 0x00,
-				SWRS_DP_CHANNEL_ENABLE_BANK(port_type, bank));
-	}
-
-	swr_port_response(master, portinfo->tid);
-	swrm->num_cfg_devs -= 1;
-	dev_dbg(&master->dev, "%s: cfg_devs: %d, rx_chs: %d, active ports: %d\n",
-		__func__, swrm->num_cfg_devs, swrm->num_rx_chs,
-		master->num_port);
-	mutex_unlock(&swrm->mlock);
-
-	return 0;
-}
-
-static int swrm_check_slave_change_status(struct swr_mstr_ctrl *swrm,
-					int status, u8 *devnum)
-{
-	int i;
-	int new_sts = status;
-	int ret = SWR_NOT_PRESENT;
-
-	if (status != swrm->slave_status) {
-		for (i = 0; i < (swrm->master.num_dev + 1); i++) {
-			if ((status & SWRM_MCP_SLV_STATUS_MASK) !=
-			    (swrm->slave_status & SWRM_MCP_SLV_STATUS_MASK)) {
-				ret = (status & SWRM_MCP_SLV_STATUS_MASK);
-				*devnum = i;
-				break;
-			}
-			status >>= 2;
-			swrm->slave_status >>= 2;
-		}
-		swrm->slave_status = new_sts;
-	}
-	return ret;
-}
-
-static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
-{
-	struct swr_mstr_ctrl *swrm = dev;
-	u32 value, intr_sts;
-	int status, chg_sts, i;
-	u8 devnum = 0;
-	int ret = IRQ_HANDLED;
-
-	mutex_lock(&swrm->reslock);
-	swrm_clk_request(swrm, true);
-	mutex_unlock(&swrm->reslock);
-
-	intr_sts = swrm->read(swrm->handle, SWRM_INTERRUPT_STATUS);
-	intr_sts &= SWRM_INTERRUPT_STATUS_RMSK;
-	for (i = 0; i < SWRM_INTERRUPT_MAX; i++) {
-		value = intr_sts & (1 << i);
-		if (!value)
-			continue;
-
-		swrm->write(swrm->handle, SWRM_INTERRUPT_CLEAR, value);
-		switch (value) {
-		case SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ:
-			dev_dbg(swrm->dev, "SWR slave pend irq\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED:
-			dev_dbg(swrm->dev, "SWR new slave attached\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS:
-			status = swrm->read(swrm->handle, SWRM_MCP_SLV_STATUS);
-			if (status == swrm->slave_status) {
-				dev_dbg(swrm->dev,
-					"%s: No change in slave status: %d\n",
-					__func__, status);
-				break;
-			}
-			chg_sts = swrm_check_slave_change_status(swrm, status,
-								&devnum);
-			switch (chg_sts) {
-			case SWR_NOT_PRESENT:
-				dev_dbg(swrm->dev, "device %d got detached\n",
-					devnum);
-				break;
-			case SWR_ATTACHED_OK:
-				dev_dbg(swrm->dev, "device %d got attached\n",
-					devnum);
-				break;
-			case SWR_ALERT:
-				dev_dbg(swrm->dev,
-					"device %d has pending interrupt\n",
-					devnum);
-				break;
-			}
-			break;
-		case SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET:
-			dev_err_ratelimited(swrm->dev, "SWR bus clash detected\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW:
-			dev_dbg(swrm->dev, "SWR read FIFO overflow\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW:
-			dev_dbg(swrm->dev, "SWR read FIFO underflow\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW:
-			dev_dbg(swrm->dev, "SWR write FIFO overflow\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_CMD_ERROR:
-			value = swrm->read(swrm->handle, SWRM_CMD_FIFO_STATUS);
-			dev_err_ratelimited(swrm->dev,
-			"SWR CMD error, fifo status 0x%x, flushing fifo\n",
-					    value);
-			swrm->write(swrm->handle, SWRM_CMD_FIFO_CMD, 0x1);
-			break;
-		case SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION:
-			dev_dbg(swrm->dev, "SWR Port collision detected\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH:
-			dev_dbg(swrm->dev, "SWR read enable valid mismatch\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED:
-			complete(&swrm->broadcast);
-			dev_dbg(swrm->dev, "SWR cmd id finished\n");
-			break;
-		case SWRM_INTERRUPT_STATUS_NEW_SLAVE_AUTO_ENUM_FINISHED:
-			break;
-		case SWRM_INTERRUPT_STATUS_AUTO_ENUM_FAILED:
-			break;
-		case SWRM_INTERRUPT_STATUS_AUTO_ENUM_TABLE_IS_FULL:
-			break;
-		case SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED:
-			complete(&swrm->reset);
-			break;
-		case SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED:
-			break;
-		default:
-			dev_err_ratelimited(swrm->dev, "SWR unknown interrupt\n");
-			ret = IRQ_NONE;
-			break;
-		}
-	}
-
-	mutex_lock(&swrm->reslock);
-	swrm_clk_request(swrm, false);
-	mutex_unlock(&swrm->reslock);
-	return ret;
-}
-
-static int swrm_get_device_status(struct swr_mstr_ctrl *swrm, u8 devnum)
-{
-	u32 val;
-
-	swrm->slave_status = swrm->read(swrm->handle, SWRM_MCP_SLV_STATUS);
-	val = (swrm->slave_status >> (devnum * 2));
-	val &= SWRM_MCP_SLV_STATUS_MASK;
-	return val;
-}
-
-static int swrm_get_logical_dev_num(struct swr_master *mstr, u64 dev_id,
-				u8 *dev_num)
-{
-	int i;
-	u64 id = 0;
-	int ret = -EINVAL;
-	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
-
-	if (!swrm) {
-		pr_err("%s: Invalid handle to swr controller\n",
-			__func__);
-		return ret;
-	}
-
-	pm_runtime_get_sync(&swrm->pdev->dev);
-	for (i = 1; i < (mstr->num_dev + 1); i++) {
-		id = ((u64)(swrm->read(swrm->handle,
-			    SWRM_ENUMERATOR_SLAVE_DEV_ID_2(i))) << 32);
-		id |= swrm->read(swrm->handle,
-			    SWRM_ENUMERATOR_SLAVE_DEV_ID_1(i));
-		if ((id & SWR_DEV_ID_MASK) == dev_id) {
-			if (swrm_get_device_status(swrm, i) == 0x01) {
-				*dev_num = i;
-				ret = 0;
-			} else {
-				dev_err(swrm->dev, "%s: device is not ready\n",
-					 __func__);
-			}
-			goto found;
-		}
-	}
-	dev_err(swrm->dev, "%s: device id 0x%llx does not match with 0x%llx\n",
-		__func__, id, dev_id);
-found:
-	pm_runtime_mark_last_busy(&swrm->pdev->dev);
-	pm_runtime_put_autosuspend(&swrm->pdev->dev);
-	return ret;
-}
-static int swrm_master_init(struct swr_mstr_ctrl *swrm)
-{
-	int ret = 0;
-	u32 val;
-	u8 row_ctrl = SWR_MAX_ROW;
-	u8 col_ctrl = SWR_MIN_COL;
-	u8 ssp_period = 1;
-	u8 retry_cmd_num = 3;
-	u32 reg[SWRM_MAX_INIT_REG];
-	u32 value[SWRM_MAX_INIT_REG];
-	int len = 0;
-
-	/* Clear Rows and Cols */
-	val = ((row_ctrl << SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_SHFT) |
-		(col_ctrl << SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_SHFT) |
-		(ssp_period << SWRM_MCP_FRAME_CTRL_BANK_SSP_PERIOD_SHFT));
-
-	reg[len] = SWRM_MCP_FRAME_CTRL_BANK_ADDR(0);
-	value[len++] = val;
-
-	/* Set Auto enumeration flag */
-	reg[len] = SWRM_ENUMERATOR_CFG_ADDR;
-	value[len++] = 1;
-
-	/* Mask soundwire interrupts */
-	reg[len] = SWRM_INTERRUPT_MASK_ADDR;
-	value[len++] = 0x1FFFD;
-
-	/* Configure No pings */
-	val = swrm->read(swrm->handle, SWRM_MCP_CFG_ADDR);
-	val &= ~SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK;
-	val |= (0x1f << SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_SHFT);
-	reg[len] = SWRM_MCP_CFG_ADDR;
-	value[len++] = val;
-
-	/* Configure number of retries of a read/write cmd */
-	val = (retry_cmd_num << SWRM_CMD_FIFO_CFG_NUM_OF_CMD_RETRY_SHFT);
-	reg[len] = SWRM_CMD_FIFO_CFG_ADDR;
-	value[len++] = val;
-
-	/* Set IRQ to PULSE */
-	reg[len] = SWRM_COMP_CFG_ADDR;
-	value[len++] = 0x02;
-
-	reg[len] = SWRM_COMP_CFG_ADDR;
-	value[len++] = 0x03;
-
-	reg[len] = SWRM_INTERRUPT_CLEAR;
-	value[len++] = 0x08;
-
-	swrm->bulk_write(swrm->handle, reg, value, len);
-
-	return ret;
-}
-
-static int swrm_probe(struct platform_device *pdev)
-{
-	struct swr_mstr_ctrl *swrm;
-	struct swr_ctrl_platform_data *pdata;
-	int ret;
-
-	/* Allocate soundwire master driver structure */
-	swrm = kzalloc(sizeof(struct swr_mstr_ctrl), GFP_KERNEL);
-	if (!swrm) {
-		ret = -ENOMEM;
-		goto err_memory_fail;
-	}
-	swrm->dev = &pdev->dev;
-	swrm->pdev = pdev;
-	platform_set_drvdata(pdev, swrm);
-	swr_set_ctrl_data(&swrm->master, swrm);
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "%s: pdata from parent is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->handle = (void *)pdata->handle;
-	if (!swrm->handle) {
-		dev_err(&pdev->dev, "%s: swrm->handle is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->read = pdata->read;
-	if (!swrm->read) {
-		dev_err(&pdev->dev, "%s: swrm->read is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->write = pdata->write;
-	if (!swrm->write) {
-		dev_err(&pdev->dev, "%s: swrm->write is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->bulk_write = pdata->bulk_write;
-	if (!swrm->bulk_write) {
-		dev_err(&pdev->dev, "%s: swrm->bulk_write is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->clk = pdata->clk;
-	if (!swrm->clk) {
-		dev_err(&pdev->dev, "%s: swrm->clk is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->reg_irq = pdata->reg_irq;
-	if (!swrm->reg_irq) {
-		dev_err(&pdev->dev, "%s: swrm->reg_irq is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto err_pdata_fail;
-	}
-	swrm->master.read = swrm_read;
-	swrm->master.write = swrm_write;
-	swrm->master.bulk_write = swrm_bulk_write;
-	swrm->master.get_logical_dev_num = swrm_get_logical_dev_num;
-	swrm->master.connect_port = swrm_connect_port;
-	swrm->master.disconnect_port = swrm_disconnect_port;
-	swrm->master.slvdev_datapath_control = swrm_slvdev_datapath_control;
-	swrm->master.remove_from_group = swrm_remove_from_group;
-	swrm->master.dev.parent = &pdev->dev;
-	swrm->master.dev.of_node = pdev->dev.of_node;
-	swrm->master.num_port = 0;
-	swrm->num_enum_slaves = 0;
-	swrm->rcmd_id = 0;
-	swrm->wcmd_id = 0;
-	swrm->slave_status = 0;
-	swrm->num_rx_chs = 0;
-	swrm->clk_ref_count = 0;
-	swrm->state = SWR_MSTR_RESUME;
-	init_completion(&swrm->reset);
-	init_completion(&swrm->broadcast);
-	mutex_init(&swrm->mlock);
-	INIT_LIST_HEAD(&swrm->mport_list);
-	mutex_init(&swrm->reslock);
-
-	ret = swrm->reg_irq(swrm->handle, swr_mstr_interrupt, swrm,
-			    SWR_IRQ_REGISTER);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: IRQ register failed ret %d\n",
-			__func__, ret);
-		goto err_irq_fail;
-	}
-
-	ret = swr_register_master(&swrm->master);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: error adding swr master\n", __func__);
-		goto err_mstr_fail;
-	}
-
-	/* Add devices registered with board-info as the
-	 * controller will be up now
-	 */
-	swr_master_add_boarddevices(&swrm->master);
-	mutex_lock(&swrm->mlock);
-	swrm_clk_request(swrm, true);
-	ret = swrm_master_init(swrm);
-	if (ret < 0) {
-		dev_err(&pdev->dev,
-			"%s: Error in master Initializaiton, err %d\n",
-			__func__, ret);
-		mutex_unlock(&swrm->mlock);
-		goto err_mstr_fail;
-	}
-	swrm->version = swrm->read(swrm->handle, SWRM_COMP_HW_VERSION);
-
-	mutex_unlock(&swrm->mlock);
-
-	if (pdev->dev.of_node)
-		of_register_swr_devices(&swrm->master);
-
-	dbgswrm = swrm;
-	debugfs_swrm_dent = debugfs_create_dir(dev_name(&pdev->dev), 0);
-	if (!IS_ERR(debugfs_swrm_dent)) {
-		debugfs_peek = debugfs_create_file("swrm_peek",
-				S_IFREG | 0444, debugfs_swrm_dent,
-				(void *) "swrm_peek", &swrm_debug_ops);
-
-		debugfs_poke = debugfs_create_file("swrm_poke",
-				S_IFREG | 0444, debugfs_swrm_dent,
-				(void *) "swrm_poke", &swrm_debug_ops);
-
-		debugfs_reg_dump = debugfs_create_file("swrm_reg_dump",
-				   S_IFREG | 0444, debugfs_swrm_dent,
-				   (void *) "swrm_reg_dump",
-				   &swrm_debug_ops);
-	}
-	pm_runtime_set_autosuspend_delay(&pdev->dev, auto_suspend_timer);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	pm_runtime_set_active(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
-	pm_runtime_mark_last_busy(&pdev->dev);
-
-	return 0;
-err_mstr_fail:
-	swrm->reg_irq(swrm->handle, swr_mstr_interrupt,
-			swrm, SWR_IRQ_FREE);
-err_irq_fail:
-err_pdata_fail:
-	kfree(swrm);
-err_memory_fail:
-	return ret;
-}
-
-static int swrm_remove(struct platform_device *pdev)
-{
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-
-	swrm->reg_irq(swrm->handle, swr_mstr_interrupt,
-			swrm, SWR_IRQ_FREE);
-	if (swrm->mstr_port) {
-		kfree(swrm->mstr_port->port);
-		swrm->mstr_port->port = NULL;
-		kfree(swrm->mstr_port);
-		swrm->mstr_port = NULL;
-	}
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
-	swr_unregister_master(&swrm->master);
-	mutex_destroy(&swrm->mlock);
-	mutex_destroy(&swrm->reslock);
-	kfree(swrm);
-	return 0;
-}
-
-static int swrm_clk_pause(struct swr_mstr_ctrl *swrm)
-{
-	u32 val;
-
-	dev_dbg(swrm->dev, "%s: state: %d\n", __func__, swrm->state);
-	swrm->write(swrm->handle, SWRM_INTERRUPT_MASK_ADDR, 0x1FDFD);
-	val = swrm->read(swrm->handle, SWRM_MCP_CFG_ADDR);
-	val |= SWRM_MCP_CFG_BUS_CLK_PAUSE_BMSK;
-	swrm->write(swrm->handle, SWRM_MCP_CFG_ADDR, val);
-	swrm->state = SWR_MSTR_PAUSE;
-
-	return 0;
-}
-
-#ifdef CONFIG_PM
-static int swrm_runtime_resume(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-	int ret = 0;
-	struct swr_master *mstr = &swrm->master;
-	struct swr_device *swr_dev;
-
-	dev_dbg(dev, "%s: pm_runtime: resume, state:%d\n",
-		__func__, swrm->state);
-	mutex_lock(&swrm->reslock);
-	if ((swrm->state == SWR_MSTR_PAUSE) ||
-	    (swrm->state == SWR_MSTR_DOWN)) {
-		if (swrm->state == SWR_MSTR_DOWN) {
-			if (swrm_clk_request(swrm, true))
-				goto exit;
-		}
-		list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
-			ret = swr_device_up(swr_dev);
-			if (ret) {
-				dev_err(dev,
-					"%s: failed to wakeup swr dev %d\n",
-					__func__, swr_dev->dev_num);
-				swrm_clk_request(swrm, false);
-				goto exit;
-			}
-		}
-		swrm->write(swrm->handle, SWRM_COMP_SW_RESET, 0x01);
-		swrm->write(swrm->handle, SWRM_COMP_SW_RESET, 0x01);
-		swrm_master_init(swrm);
-	}
-exit:
-	pm_runtime_set_autosuspend_delay(&pdev->dev, auto_suspend_timer);
-	mutex_unlock(&swrm->reslock);
-	return ret;
-}
-
-static int swrm_runtime_suspend(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-	int ret = 0;
-	struct swr_master *mstr = &swrm->master;
-	struct swr_device *swr_dev;
-
-	dev_dbg(dev, "%s: pm_runtime: suspend state: %d\n",
-		__func__, swrm->state);
-	mutex_lock(&swrm->reslock);
-	if ((swrm->state == SWR_MSTR_RESUME) ||
-	    (swrm->state == SWR_MSTR_UP)) {
-		if (swrm_is_port_en(&swrm->master)) {
-			dev_dbg(dev, "%s ports are enabled\n", __func__);
-			ret = -EBUSY;
-			goto exit;
-		}
-		swrm_clk_pause(swrm);
-		swrm->write(swrm->handle, SWRM_COMP_CFG_ADDR, 0x00);
-		list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
-			ret = swr_device_down(swr_dev);
-			if (ret) {
-				dev_err(dev,
-					"%s: failed to shutdown swr dev %d\n",
-					__func__, swr_dev->dev_num);
-				goto exit;
-			}
-		}
-		swrm_clk_request(swrm, false);
-	}
-exit:
-	mutex_unlock(&swrm->reslock);
-	return ret;
-}
-#endif /* CONFIG_PM */
-
-static int swrm_device_down(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-	int ret = 0;
-	struct swr_master *mstr = &swrm->master;
-	struct swr_device *swr_dev;
-
-	dev_dbg(dev, "%s: swrm state: %d\n", __func__, swrm->state);
-	mutex_lock(&swrm->reslock);
-	if ((swrm->state == SWR_MSTR_RESUME) ||
-	    (swrm->state == SWR_MSTR_UP)) {
-		list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
-			ret = swr_device_down(swr_dev);
-			if (ret)
-				dev_err(dev,
-					"%s: failed to shutdown swr dev %d\n",
-					__func__, swr_dev->dev_num);
-		}
-		dev_dbg(dev, "%s: Shutting down SWRM\n", __func__);
-		pm_runtime_disable(dev);
-		pm_runtime_set_suspended(dev);
-		pm_runtime_enable(dev);
-		swrm_clk_request(swrm, false);
-	}
-	mutex_unlock(&swrm->reslock);
-	return ret;
-}
-
-/**
- * swrm_wcd_notify - parent device can notify to soundwire master through
- * this function
- * @pdev: pointer to platform device structure
- * @id: command id from parent to the soundwire master
- * @data: data from parent device to soundwire master
- */
-int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
-{
-	struct swr_mstr_ctrl *swrm;
-	int ret = 0;
-	struct swr_master *mstr;
-	struct swr_device *swr_dev;
-
-	if (!pdev) {
-		pr_err("%s: pdev is NULL\n", __func__);
-		return -EINVAL;
-	}
-	swrm = platform_get_drvdata(pdev);
-	if (!swrm) {
-		dev_err(&pdev->dev, "%s: swrm is NULL\n", __func__);
-		return -EINVAL;
-	}
-	mstr = &swrm->master;
-
-	switch (id) {
-	case SWR_CH_MAP:
-		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL\n", __func__);
-			ret = -EINVAL;
-		} else {
-			ret = swrm_set_ch_map(swrm, data);
-		}
-		break;
-	case SWR_DEVICE_DOWN:
-		dev_dbg(swrm->dev, "%s: swr master down called\n", __func__);
-		mutex_lock(&swrm->mlock);
-		if ((swrm->state == SWR_MSTR_PAUSE) ||
-		    (swrm->state == SWR_MSTR_DOWN))
-			dev_dbg(swrm->dev, "%s: SWR master is already Down: %d\n",
-				__func__, swrm->state);
-		else
-			swrm_device_down(&pdev->dev);
-		mutex_unlock(&swrm->mlock);
-		break;
-	case SWR_DEVICE_UP:
-		dev_dbg(swrm->dev, "%s: swr master up called\n", __func__);
-		mutex_lock(&swrm->mlock);
-		mutex_lock(&swrm->reslock);
-		if ((swrm->state == SWR_MSTR_RESUME) ||
-		    (swrm->state == SWR_MSTR_UP)) {
-			dev_dbg(swrm->dev, "%s: SWR master is already UP: %d\n",
-				__func__, swrm->state);
-		} else {
-			pm_runtime_mark_last_busy(&pdev->dev);
-			mutex_unlock(&swrm->reslock);
-			pm_runtime_get_sync(&pdev->dev);
-			mutex_lock(&swrm->reslock);
-			list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
-				ret = swr_reset_device(swr_dev);
-				if (ret) {
-					dev_err(swrm->dev,
-						"%s: failed to reset swr device %d\n",
-						__func__, swr_dev->dev_num);
-					swrm_clk_request(swrm, false);
-				}
-			}
-			pm_runtime_mark_last_busy(&pdev->dev);
-			pm_runtime_put_autosuspend(&pdev->dev);
-		}
-		mutex_unlock(&swrm->reslock);
-		mutex_unlock(&swrm->mlock);
-		break;
-	case SWR_SET_NUM_RX_CH:
-		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL\n", __func__);
-			ret = -EINVAL;
-		} else {
-			mutex_lock(&swrm->mlock);
-			swrm->num_rx_chs = *(int *)data;
-			if ((swrm->num_rx_chs > 1) && !swrm->num_cfg_devs) {
-				list_for_each_entry(swr_dev, &mstr->devices,
-						    dev_list) {
-					ret = swr_set_device_group(swr_dev,
-								SWR_BROADCAST);
-					if (ret)
-						dev_err(swrm->dev,
-							"%s: set num ch failed\n",
-							__func__);
-				}
-			} else {
-				list_for_each_entry(swr_dev, &mstr->devices,
-						    dev_list) {
-					ret = swr_set_device_group(swr_dev,
-								SWR_GROUP_NONE);
-					if (ret)
-						dev_err(swrm->dev,
-							"%s: set num ch failed\n",
-							__func__);
-				}
-			}
-			mutex_unlock(&swrm->mlock);
-		}
-		break;
-	default:
-		dev_err(swrm->dev, "%s: swr master unknown id %d\n",
-			__func__, id);
-		break;
-	}
-	return ret;
-}
-EXPORT_SYMBOL(swrm_wcd_notify);
-
-#ifdef CONFIG_PM_SLEEP
-static int swrm_suspend(struct device *dev)
-{
-	int ret = -EBUSY;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-
-	dev_dbg(dev, "%s: system suspend, state: %d\n", __func__, swrm->state);
-	if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
-		ret = swrm_runtime_suspend(dev);
-		if (!ret) {
-			/*
-			 * Synchronize runtime-pm and system-pm states:
-			 * At this point, we are already suspended. If
-			 * runtime-pm still thinks its active, then
-			 * make sure its status is in sync with HW
-			 * status. The three below calls let the
-			 * runtime-pm know that we are suspended
-			 * already without re-invoking the suspend
-			 * callback
-			 */
-			pm_runtime_disable(dev);
-			pm_runtime_set_suspended(dev);
-			pm_runtime_enable(dev);
-		}
-	}
-	if (ret == -EBUSY) {
-		/*
-		 * There is a possibility that some audio stream is active
-		 * during suspend. We dont want to return suspend failure in
-		 * that case so that display and relevant components can still
-		 * go to suspend.
-		 * If there is some other error, then it should be passed-on
-		 * to system level suspend
-		 */
-		ret = 0;
-	}
-	return ret;
-}
-
-static int swrm_resume(struct device *dev)
-{
-	int ret = 0;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
-
-	dev_dbg(dev, "%s: system resume, state: %d\n", __func__, swrm->state);
-	if (!pm_runtime_enabled(dev) || !pm_runtime_suspend(dev)) {
-		ret = swrm_runtime_resume(dev);
-		if (!ret) {
-			pm_runtime_mark_last_busy(dev);
-			pm_request_autosuspend(dev);
-		}
-	}
-	return ret;
-}
-#endif /* CONFIG_PM_SLEEP */
-
-static const struct dev_pm_ops swrm_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(
-		swrm_suspend,
-		swrm_resume
-	)
-	SET_RUNTIME_PM_OPS(
-		swrm_runtime_suspend,
-		swrm_runtime_resume,
-		NULL
-	)
-};
-
-static const struct of_device_id swrm_dt_match[] = {
-	{
-		.compatible = "qcom,swr-wcd",
-	},
-	{}
-};
-
-static struct platform_driver swr_mstr_driver = {
-	.probe = swrm_probe,
-	.remove = swrm_remove,
-	.driver = {
-		.name = SWR_WCD_NAME,
-		.owner = THIS_MODULE,
-		.pm = &swrm_dev_pm_ops,
-		.of_match_table = swrm_dt_match,
-	},
-};
-
-static int __init swrm_init(void)
-{
-	return platform_driver_register(&swr_mstr_driver);
-}
-subsys_initcall(swrm_init);
-
-static void __exit swrm_exit(void)
-{
-	platform_driver_unregister(&swr_mstr_driver);
-}
-module_exit(swrm_exit);
-
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("WCD SoundWire Controller");
-MODULE_ALIAS("platform:swr-wcd");
diff --git a/drivers/soundwire/swr-wcd-ctrl.h b/drivers/soundwire/swr-wcd-ctrl.h
deleted file mode 100644
index 104ac8f..0000000
--- a/drivers/soundwire/swr-wcd-ctrl.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _SWR_WCD_CTRL_H
-#define _SWR_WCD_CTRL_H
-#include <linux/module.h>
-#include <linux/soundwire/swr-wcd.h>
-
-#define SWR_MAX_ROW		0 /* Rows = 48 */
-#define SWR_MAX_COL		7 /* Cols = 16 */
-#define SWR_MIN_COL		0 /* Cols = 2 */
-
-#define SWR_WCD_NAME	"swr-wcd"
-
-#define SWR_MSTR_PORT_LEN	8 /* Number of master ports */
-
-#define SWRM_VERSION_1_0 0x01010000
-#define SWRM_VERSION_1_2 0x01030000
-#define SWRM_VERSION_1_3 0x01040000
-
-enum {
-	SWR_MSTR_PAUSE,
-	SWR_MSTR_RESUME,
-	SWR_MSTR_UP,
-	SWR_MSTR_DOWN,
-};
-
-enum {
-	SWR_IRQ_FREE,
-	SWR_IRQ_REGISTER,
-};
-
-enum {
-	SWR_DAC_PORT,
-	SWR_COMP_PORT,
-	SWR_BOOST_PORT,
-	SWR_VISENSE_PORT,
-};
-
-struct usecase {
-	u8 num_port;
-	u8 num_ch;
-	u32 chrate;
-};
-
-struct port_params {
-	u8 si;
-	u8 off1;
-	u8 off2;
-};
-
-struct swrm_mports {
-	struct list_head list;
-	u8 id;
-};
-
-struct swr_ctrl_platform_data {
-	void *handle; /* holds priv data */
-	int (*read)(void *handle, int reg);
-	int (*write)(void *handle, int reg, int val);
-	int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
-	int (*clk)(void *handle, bool enable);
-	int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
-			void *data), void *swr_handle, int type);
-};
-
-struct swr_mstr_ctrl {
-	struct swr_master master;
-	struct device *dev;
-	struct resource *supplies;
-	struct clk *mclk;
-	int clk_ref_count;
-	struct completion reset;
-	struct completion broadcast;
-	struct mutex mlock;
-	struct mutex reslock;
-	u8 rcmd_id;
-	u8 wcmd_id;
-	void *handle; /* SWR Master handle from client for read and writes */
-	int (*read)(void *handle, int reg);
-	int (*write)(void *handle, int reg, int val);
-	int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
-	int (*clk)(void *handle, bool enable);
-	int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
-			void *data), void *swr_handle, int type);
-	int irq;
-	int version;
-	int num_enum_slaves;
-	int slave_status;
-	struct swr_mstr_port *mstr_port;
-	struct list_head mport_list;
-	int state;
-	struct platform_device *pdev;
-	int num_rx_chs;
-	u8 num_cfg_devs;
-};
-
-#endif /* _SWR_WCD_CTRL_H */
diff --git a/drivers/soundwire/swrm_registers.h b/drivers/soundwire/swrm_registers.h
deleted file mode 100644
index 50c3ecf..0000000
--- a/drivers/soundwire/swrm_registers.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _SWRM_REGISTERS_H
-#define _SWRM_REGISTERS_H
-
-#define SWRM_BASE_ADDRESS				0x00
-
-#define SWRM_COMP_HW_VERSION                     SWRM_BASE_ADDRESS
-#define SWRM_COMP_CFG_ADDR			(SWRM_BASE_ADDRESS+0x00000004)
-#define SWRM_COMP_CFG_RMSK				0x3
-#define SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_BMSK		0x2
-#define SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_SHFT		0x1
-#define SWRM_COMP_CFG_ENABLE_BMSK			0x1
-#define SWRM_COMP_CFG_ENABLE_SHFT			0x0
-
-#define SWRM_COMP_SW_RESET		(SWRM_BASE_ADDRESS+0x00000008)
-
-#define SWRM_COMP_PARAMS		(SWRM_BASE_ADDRESS+0x100)
-#define SWRM_COMP_PARAMS_DOUT_PORTS_MASK	0x0000001F
-#define SWRM_COMP_PARAMS_DIN_PORTS_MASK		0x000003E0
-#define SWRM_COMP_PARAMS_WR_FIFO_DEPTH		0x00007C00
-#define SWRM_COMP_PARAMS_RD_FIFO_DEPTH		0x000F8000
-#define SWRM_COMP_PARAMS_AUTO_ENUM_SLAVES	0x00F00000
-#define SWRM_COMP_PARAMS_DATA_LANES		0x07000000
-
-
-#define SWRM_INTERRUPT_STATUS		(SWRM_BASE_ADDRESS+0x00000200)
-#define SWRM_INTERRUPT_STATUS_RMSK		0x1FFFD
-
-#define SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ			0x1
-#define SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED		0x2
-#define SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS		0x4
-#define SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET			0x8
-#define SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW			0x10
-#define SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW			0x20
-#define SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW		0x40
-#define SWRM_INTERRUPT_STATUS_CMD_ERROR				0x80
-#define SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION		0x100
-#define SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH		0x200
-#define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED		0x400
-#define SWRM_INTERRUPT_STATUS_NEW_SLAVE_AUTO_ENUM_FINISHED	0x800
-#define SWRM_INTERRUPT_STATUS_AUTO_ENUM_FAILED			0x1000
-#define SWRM_INTERRUPT_STATUS_AUTO_ENUM_TABLE_IS_FULL		0x2000
-#define SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED		0x4000
-#define SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED			0x8000
-#define SWRM_INTERRUPT_STATUS_ERROR_PORT_TEST			0x10000
-
-#define SWRM_INTERRUPT_MASK_ADDR		(SWRM_BASE_ADDRESS+0x00000204)
-#define SWRM_INTERRUPT_MASK_RMSK		0x1FFFF
-
-#define SWRM_INTERRUPT_MASK_SLAVE_PEND_IRQ_BMSK			0x1
-#define SWRM_INTERRUPT_MASK_SLAVE_PEND_IRQ_SHFT			0x0
-
-#define SWRM_INTERRUPT_MASK_NEW_SLAVE_ATTACHED_BMSK		0x2
-#define SWRM_INTERRUPT_MASK_NEW_SLAVE_ATTACHED_SHFT		0x1
-
-#define SWRM_INTERRUPT_MASK_CHANGE_ENUM_SLAVE_STATUS_BMSK	0x4
-#define SWRM_INTERRUPT_MASK_CHANGE_ENUM_SLAVE_STATUS_SHFT	0x2
-
-#define SWRM_INTERRUPT_MASK_MASTER_CLASH_DET_BMSK		0x8
-#define SWRM_INTERRUPT_MASK_MASTER_CLASH_DET_SHFT		0x3
-
-#define SWRM_INTERRUPT_MASK_RD_FIFO_OVERFLOW_BMSK		0x10
-#define SWRM_INTERRUPT_MASK_RD_FIFO_OVERFLOW_SHFT		0x4
-
-#define SWRM_INTERRUPT_MASK_RD_FIFO_UNDERFLOW_BMSK		0x20
-#define SWRM_INTERRUPT_MASK_RD_FIFO_UNDERFLOW_SHFT		0x5
-
-#define SWRM_INTERRUPT_MASK_WR_CMD_FIFO_OVERFLOW_BMSK		0x40
-#define SWRM_INTERRUPT_MASK_WR_CMD_FIFO_OVERFLOW_SHFT		0x6
-
-#define SWRM_INTERRUPT_MASK_CMD_ERROR_BMSK			0x80
-#define SWRM_INTERRUPT_MASK_CMD_ERROR_SHFT			0x7
-
-#define SWRM_INTERRUPT_MASK_DOUT_PORT_COLLISION_BMSK		0x100
-#define SWRM_INTERRUPT_MASK_DOUT_PORT_COLLISION_SHFT		0x8
-
-#define SWRM_INTERRUPT_MASK_READ_EN_RD_VALID_MISMATCH_BMSK	0x200
-#define SWRM_INTERRUPT_MASK_READ_EN_RD_VALID_MISMATCH_SHFT	0x9
-
-#define SWRM_INTERRUPT_MASK_SPECIAL_CMD_ID_FINISHED_BMSK	0x400
-#define SWRM_INTERRUPT_MASK_SPECIAL_CMD_ID_FINISHED_SHFT	0xA
-
-#define SWRM_INTERRUPT_MASK_NEW_SLAVE_AUTO_ENUM_FINISHED_BMSK	0x800
-#define SWRM_INTERRUPT_MASK_NEW_SLAVE_AUTO_ENUM_FINISHED_SHFT	0xB
-
-#define SWRM_INTERRUPT_MASK_AUTO_ENUM_FAILED_BMSK		0x1000
-#define SWRM_INTERRUPT_MASK_AUTO_ENUM_FAILED_SHFT		0xC
-
-#define SWRM_INTERRUPT_MASK_AUTO_ENUM_TABLE_IS_FULL_BMSK	0x2000
-#define SWRM_INTERRUPT_MASK_AUTO_ENUM_TABLE_IS_FULL_SHFT	0xD
-
-#define SWRM_INTERRUPT_MASK_BUS_RESET_FINISHED_BMSK		0x4000
-#define SWRM_INTERRUPT_MASK_BUS_RESET_FINISHED_SHFT		0xE
-
-#define SWRM_INTERRUPT_MASK_CLK_STOP_FINISHED_BMSK		0x8000
-#define SWRM_INTERRUPT_MASK_CLK_STOP_FINISHED_SHFT		0xF
-
-#define SWRM_INTERRUPT_MASK_ERROR_PORT_TEST_BMSK		0x10000
-#define SWRM_INTERRUPT_MASK_ERROR_PORT_TEST_SHFT		0x10
-
-#define SWRM_INTERRUPT_MAX					0x11
-
-#define SWRM_INTERRUPT_CLEAR		(SWRM_BASE_ADDRESS+0x00000208)
-
-#define SWRM_CMD_FIFO_WR_CMD		(SWRM_BASE_ADDRESS + 0x00000300)
-#define SWRM_CMD_FIFO_WR_CMD_MASK	0xFFFFFFFF
-#define SWRM_CMD_FIFO_RD_CMD		(SWRM_BASE_ADDRESS + 0x00000304)
-#define SWRM_CMD_FIFO_RD_CMD_MASK	0xFFFFFFF
-#define SWRM_CMD_FIFO_CMD		(SWRM_BASE_ADDRESS + 0x00000308)
-#define SWRM_CMD_FIFO_STATUS		(SWRM_BASE_ADDRESS + 0x0000030C)
-
-#define SWRM_CMD_FIFO_STATUS_WR_CMD_FIFO_CNT_MASK	0x1F00
-#define SWRM_CMD_FIFO_STATUS_RD_CMD_FIFO_CNT_MASK	0x7C00000
-
-#define SWRM_CMD_FIFO_CFG_ADDR			(SWRM_BASE_ADDRESS+0x00000314)
-#define SWRM_CMD_FIFO_CFG_NUM_OF_CMD_RETRY_BMSK		0x7
-#define SWRM_CMD_FIFO_CFG_NUM_OF_CMD_RETRY_SHFT		0x0
-
-#define SWRM_CMD_FIFO_RD_FIFO_ADDR	(SWRM_BASE_ADDRESS + 0x00000318)
-
-#define SWRM_ENUMERATOR_CFG_ADDR		(SWRM_BASE_ADDRESS+0x00000500)
-#define SWRM_ENUMERATOR_CFG_AUTO_ENUM_EN_BMSK		0x1
-#define SWRM_ENUMERATOR_CFG_AUTO_ENUM_EN_SHFT		0x0
-
-#define SWRM_ENUMERATOR_SLAVE_DEV_ID_1(m)   (SWRM_BASE_ADDRESS+0x530+0x8*m)
-#define SWRM_ENUMERATOR_SLAVE_DEV_ID_2(m)   (SWRM_BASE_ADDRESS+0x534+0x8*m)
-
-#define SWRM_MCP_FRAME_CTRL_BANK_ADDR(m)    (SWRM_BASE_ADDRESS+0x101C+0x40*m)
-#define SWRM_MCP_FRAME_CTRL_BANK_RMSK			0x00ff07ff
-#define SWRM_MCP_FRAME_CTRL_BANK_SHFT			0
-#define SWRM_MCP_FRAME_CTRL_BANK_SSP_PERIOD_BMSK	0xff0000
-#define SWRM_MCP_FRAME_CTRL_BANK_SSP_PERIOD_SHFT	16
-#define SWRM_MCP_FRAME_CTRL_BANK_PHASE_BMSK		0xf800
-#define SWRM_MCP_FRAME_CTRL_BANK_PHASE_SHFT		11
-#define SWRM_MCP_FRAME_CTRL_BANK_CLK_DIV_VALUE_BMSK	0x700
-#define SWRM_MCP_FRAME_CTRL_BANK_CLK_DIV_VALUE_SHFT	8
-#define SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK		0xF8
-#define SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_SHFT		3
-#define SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK		0x7
-#define SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_SHFT		0
-
-#define SWRM_MCP_BUS_CTRL_ADDR			(SWRM_BASE_ADDRESS+0x00001044)
-#define SWRM_MCP_BUS_CTRL_BUS_RESET_BMSK		0x1
-#define SWRM_MCP_BUS_CTRL_BUS_RESET_SHFT		0x0
-#define SWRM_MCP_BUS_CTRL_CLK_START_BMSK		0x2
-#define SWRM_MCP_BUS_CTRL_CLK_START_SHFT		0x1
-
-#define SWRM_MCP_CFG_ADDR			(SWRM_BASE_ADDRESS+0x00001048)
-#define SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK	0x3E0000
-#define SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_SHFT	0x11
-#define SWRM_MCP_CFG_BUS_CLK_PAUSE_BMSK			0x02
-
-#define SWRM_MCP_STATUS			(SWRM_BASE_ADDRESS+0x104C)
-#define SWRM_MCP_STATUS_BANK_NUM_MASK	0x01
-
-#define SWRM_MCP_SLV_STATUS		(SWRM_BASE_ADDRESS+0x1090)
-#define SWRM_MCP_SLV_STATUS_MASK	0x03
-
-#define SWRM_DP_PORT_CTRL_BANK(n, m)		(SWRM_BASE_ADDRESS + \
-							0x00001124 + \
-							0x100*(n-1) + \
-							0x40*m)
-#define SWRM_DP_PORT_CTRL_BANK_MASK		0xFFFFFFFF
-#define SWRM_DP_PORT_CTRL_EN_CHAN_MASK		0xFF000000
-#define SWRM_DP_PORT_CTRL_EN_CHAN_SHFT		0x18
-#define SWRM_DP_PORT_CTRL_OFFSET2_SHFT		0x10
-#define SWRM_DP_PORT_CTRL_OFFSET1_SHFT		0x08
-#define SWRM_DP_PORT_CTRL_SAMPLE_INTERVAL	0x00
-
-/* Soundwire Slave Register definition */
-
-#define SWRS_BASE_ADDRESS			0x00
-
-#define SWRS_DP_REG_OFFSET(port, bank)		((0x100*port)+(0x10*bank))
-
-#define SWRS_DP_CHANNEL_ENABLE_BANK(n, m)	(SWRS_BASE_ADDRESS + 0x120 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_DP_SAMPLE_CONTROL_1_BANK(n, m)	(SWRS_BASE_ADDRESS + 0x122 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_DP_OFFSET_CONTROL_1_BANK(n, m)	(SWRS_BASE_ADDRESS + 0x124 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_DP_OFFSET_CONTROL_2_BANK(n, m)	(SWRS_BASE_ADDRESS + 0x125 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_DP_HCONTROL_BANK(n, m)		(SWRS_BASE_ADDRESS + 0x126 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_DP_BLOCK_CONTROL_3_BANK(n, m)	(SWRS_BASE_ADDRESS + 0x127 + \
-						 SWRS_DP_REG_OFFSET(n, m))
-#define SWRS_SCP_FRAME_CTRL_BANK(m)		(SWRS_BASE_ADDRESS + 0x60 + \
-						 0x10*m)
-#define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m)	(SWRS_BASE_ADDRESS + 0xE0 + \
-						0x10*m)
-
-#endif /* _SWRM_REGISTERS_H */
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 9d72f37..c30b115 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -103,3 +103,5 @@
 obj-$(CONFIG_SPI_XLP)			+= spi-xlp.o
 obj-$(CONFIG_SPI_XTENSA_XTFPGA)		+= spi-xtensa-xtfpga.o
 obj-$(CONFIG_SPI_ZYNQMP_GQSPI)		+= spi-zynqmp-gqspi.o
+obj-$(CONFIG_SPI_QSD)			+= spi_qsd.o
+obj-$(CONFIG_SPI_QUP)			+= spi_qsd.o
diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index 2b1456e..c1eafbd 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -494,7 +494,8 @@
 			SPI_ENGINE_VERSION_MAJOR(version),
 			SPI_ENGINE_VERSION_MINOR(version),
 			SPI_ENGINE_VERSION_PATCH(version));
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_put_master;
 	}
 
 	spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 27960e4..c4226c0 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -107,7 +107,10 @@
 
 static int dw_spi_debugfs_init(struct dw_spi *dws)
 {
-	dws->debugfs = debugfs_create_dir("dw_spi", NULL);
+	char name[128];
+
+	snprintf(name, 128, "dw_spi-%s", dev_name(&dws->master->dev));
+	dws->debugfs = debugfs_create_dir(name, NULL);
 	if (!dws->debugfs)
 		return -ENOMEM;
 
diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index 6acb731..8dc42ac 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -24,6 +24,7 @@
 #include <linux/qcom-geni-se.h>
 #include <linux/msm_gpi.h>
 #include <linux/spi/spi.h>
+#include <linux/spi/spi-geni-qcom.h>
 
 #define SPI_NUM_CHIPSELECT	(4)
 #define SPI_XFER_TIMEOUT_MS	(250)
@@ -67,6 +68,11 @@
 /* SPI_TX/SPI_RX_TRANS_LEN fields */
 #define TRANS_LEN_MSK		(GENMASK(23, 0))
 
+/* SE_SPI_DELAY_COUNTERS */
+#define SPI_INTER_WORDS_DELAY_MSK	(GENMASK(9, 0))
+#define SPI_CS_CLK_DELAY_MSK		(GENMASK(19, 10))
+#define SPI_CS_CLK_DELAY_SHFT		(10)
+
 /* M_CMD OP codes for SPI */
 #define SPI_TX_ONLY		(1)
 #define SPI_RX_ONLY		(2)
@@ -192,16 +198,26 @@
 static void spi_setup_word_len(struct spi_geni_master *mas, u32 mode,
 						int bits_per_word)
 {
-	int pack_words = 0;
+	int pack_words = 1;
 	bool msb_first = (mode & SPI_LSB_FIRST) ? false : true;
 	u32 word_len = geni_read_reg(mas->base, SE_SPI_WORD_LEN);
+	unsigned long cfg0, cfg1;
 
+	/*
+	 * If bits_per_word isn't a byte aligned value, set the packing to be
+	 * 1 SPI word per FIFO word.
+	 */
 	if (!(mas->tx_fifo_width % bits_per_word))
 		pack_words = mas->tx_fifo_width / bits_per_word;
 	word_len &= ~WORD_LEN_MSK;
 	word_len |= ((bits_per_word - MIN_WORD_LEN) & WORD_LEN_MSK);
 	se_config_packing(mas->base, bits_per_word, pack_words, msb_first);
 	geni_write_reg(word_len, mas->base, SE_SPI_WORD_LEN);
+	se_get_packing_config(bits_per_word, pack_words, msb_first,
+							&cfg0, &cfg1);
+	GENI_SE_DBG(mas->ipc, false, mas->dev,
+		"%s: cfg0 %lu cfg1 %lu bpw %d pack_words %d\n", __func__,
+		cfg0, cfg1, bits_per_word, pack_words);
 }
 
 static int setup_fifo_params(struct spi_device *spi_slv,
@@ -219,6 +235,8 @@
 	int ret = 0;
 	int idx;
 	int div;
+	struct spi_geni_qcom_ctrl_data *delay_params = NULL;
+	u32 spi_delay_params = 0;
 
 	loopback_cfg &= ~LOOPBACK_MSK;
 	cpol &= ~CPOL;
@@ -236,6 +254,22 @@
 	if (spi_slv->mode & SPI_CS_HIGH)
 		demux_output_inv |= BIT(spi_slv->chip_select);
 
+	if (spi_slv->controller_data) {
+		u32 cs_clk_delay = 0;
+		u32 inter_words_delay = 0;
+
+		delay_params =
+		(struct spi_geni_qcom_ctrl_data *) spi_slv->controller_data;
+		cs_clk_delay =
+		(delay_params->spi_cs_clk_delay << SPI_CS_CLK_DELAY_SHFT)
+							& SPI_CS_CLK_DELAY_MSK;
+		inter_words_delay =
+			delay_params->spi_inter_words_delay &
+						SPI_INTER_WORDS_DELAY_MSK;
+		spi_delay_params =
+		(inter_words_delay | cs_clk_delay);
+	}
+
 	demux_sel = spi_slv->chip_select;
 	mas->cur_speed_hz = spi_slv->max_speed_hz;
 	mas->cur_word_len = spi_slv->bits_per_word;
@@ -257,6 +291,13 @@
 	geni_write_reg(demux_output_inv, mas->base, SE_SPI_DEMUX_OUTPUT_INV);
 	geni_write_reg(clk_sel, mas->base, SE_GENI_CLK_SEL);
 	geni_write_reg(m_clk_cfg, mas->base, GENI_SER_M_CLK_CFG);
+	geni_write_reg(spi_delay_params, mas->base, SE_SPI_DELAY_COUNTERS);
+	GENI_SE_DBG(mas->ipc, false, mas->dev,
+		"%s:Loopback%d demux_sel0x%x demux_op_inv 0x%x clk_cfg 0x%x\n",
+		__func__, loopback_cfg, demux_sel, demux_output_inv, m_clk_cfg);
+	GENI_SE_DBG(mas->ipc, false, mas->dev,
+		"%s:clk_sel 0x%x cpol %d cpha %d delay 0x%x\n", __func__,
+					clk_sel, cpol, cpha, spi_delay_params);
 	/* Ensure message level attributes are written before returning */
 	mb();
 setup_fifo_params_exit:
@@ -282,7 +323,7 @@
 	 */
 	if (fifo_disable && !dma_chan_valid)
 		mode = -EINVAL;
-	else if (fifo_disable)
+	else if (dma_chan_valid)
 		mode = GSI_DMA;
 	else
 		mode = FIFO_MODE;
@@ -290,7 +331,8 @@
 }
 
 static struct msm_gpi_tre *setup_config0_tre(struct spi_transfer *xfer,
-				struct spi_geni_master *mas, u16 mode)
+				struct spi_geni_master *mas, u16 mode,
+				u32 cs_clk_delay, u32 inter_words_delay)
 {
 	struct msm_gpi_tre *c0_tre = &mas->gsi[mas->num_xfers].config0_tre;
 	u8 flags = 0;
@@ -316,10 +358,7 @@
 		flags |= GSI_CS_TOGGLE;
 
 	word_len = xfer->bits_per_word - MIN_WORD_LEN;
-	if (mas->tx_fifo_width % xfer->bits_per_word)
-		pack = 0;
-	else
-		pack |= (GSI_TX_PACK_EN | GSI_RX_PACK_EN);
+	pack |= (GSI_TX_PACK_EN | GSI_RX_PACK_EN);
 	ret = get_spi_clk_cfg(mas->cur_speed_hz, mas, &idx, &div);
 	if (ret) {
 		dev_err(mas->dev, "%s:Err setting clks:%d\n", __func__, ret);
@@ -327,12 +366,16 @@
 	}
 	c0_tre->dword[0] = MSM_GPI_SPI_CONFIG0_TRE_DWORD0(pack, flags,
 								word_len);
-	c0_tre->dword[1] = MSM_GPI_SPI_CONFIG0_TRE_DWORD1(0, 0, 0);
+	c0_tre->dword[1] = MSM_GPI_SPI_CONFIG0_TRE_DWORD1(0, cs_clk_delay,
+							inter_words_delay);
 	c0_tre->dword[2] = MSM_GPI_SPI_CONFIG0_TRE_DWORD2(idx, div);
 	c0_tre->dword[3] = MSM_GPI_SPI_CONFIG0_TRE_DWORD3(0, 0, 0, 1);
 	GENI_SE_DBG(mas->ipc, false, mas->dev,
 		"%s: flags 0x%x word %d pack %d idx %d div %d\n",
 		__func__, flags, word_len, pack, idx, div);
+	GENI_SE_DBG(mas->ipc, false, mas->dev,
+		"%s: cs_clk_delay %d inter_words_delay %d\n", __func__,
+				 cs_clk_delay, inter_words_delay);
 	return c0_tre;
 }
 
@@ -490,13 +533,27 @@
 	u32 rx_len = 0;
 	int go_flags = 0;
 	unsigned long flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
+	struct spi_geni_qcom_ctrl_data *delay_params = NULL;
+	u32 cs_clk_delay = 0;
+	u32 inter_words_delay = 0;
+
+	if (spi_slv->controller_data) {
+		delay_params =
+		(struct spi_geni_qcom_ctrl_data *) spi_slv->controller_data;
+
+		cs_clk_delay =
+			delay_params->spi_cs_clk_delay;
+		inter_words_delay =
+			delay_params->spi_inter_words_delay;
+	}
 
 	if ((xfer->bits_per_word != mas->cur_word_len) ||
 		(xfer->speed_hz != mas->cur_speed_hz)) {
 		mas->cur_word_len = xfer->bits_per_word;
 		mas->cur_speed_hz = xfer->speed_hz;
 		tx_nent++;
-		c0_tre = setup_config0_tre(xfer, mas, spi_slv->mode);
+		c0_tre = setup_config0_tre(xfer, mas, spi_slv->mode,
+					cs_clk_delay, inter_words_delay);
 		if (IS_ERR_OR_NULL(c0_tre)) {
 			dev_err(mas->dev, "%s:Err setting c0tre:%d\n",
 							__func__, ret);
@@ -504,19 +561,26 @@
 		}
 	}
 
+	if (!(mas->cur_word_len % MIN_WORD_LEN)) {
+		rx_len = ((xfer->len << 3) / mas->cur_word_len);
+	} else {
+		int bytes_per_word = (mas->cur_word_len / BITS_PER_BYTE) + 1;
+
+		rx_len = (xfer->len / bytes_per_word);
+	}
+
 	if (xfer->tx_buf && xfer->rx_buf) {
 		cmd = SPI_FULL_DUPLEX;
 		tx_nent += 2;
 		rx_nent++;
-		rx_len = ((xfer->len << 3) / mas->cur_word_len);
 	} else if (xfer->tx_buf) {
 		cmd = SPI_TX_ONLY;
 		tx_nent += 2;
+		rx_len = 0;
 	} else if (xfer->rx_buf) {
 		cmd = SPI_RX_ONLY;
 		tx_nent++;
 		rx_nent++;
-		rx_len = ((xfer->len << 3) / mas->cur_word_len);
 	}
 
 	cs |= spi_slv->chip_select;
@@ -597,30 +661,32 @@
 				struct spi_message *msg)
 {
 	struct spi_transfer *xfer;
-	struct device *gsi_dev = mas->dev;
+	int ret = 0;
 
 	list_for_each_entry(xfer, &msg->transfers, transfer_list) {
 		if (xfer->rx_buf) {
-			xfer->rx_dma = dma_map_single(gsi_dev, xfer->rx_buf,
+			ret = geni_se_iommu_map_buf(mas->wrapper_dev,
+						&xfer->rx_dma, xfer->rx_buf,
 						xfer->len, DMA_FROM_DEVICE);
-			if (dma_mapping_error(mas->dev, xfer->rx_dma)) {
-				dev_err(mas->dev, "Err mapping buf\n");
-				return -ENOMEM;
+			if (ret) {
+				GENI_SE_ERR(mas->ipc, true, mas->dev,
+				"%s: Mapping Rx buffer %d\n", __func__, ret);
+				return ret;
 			}
 		}
 
 		if (xfer->tx_buf) {
-			xfer->tx_dma = dma_map_single(gsi_dev,
-				(void *)xfer->tx_buf, xfer->len, DMA_TO_DEVICE);
-			if (dma_mapping_error(gsi_dev, xfer->tx_dma)) {
-				dev_err(mas->dev, "Err mapping buf\n");
-				dma_unmap_single(gsi_dev, xfer->rx_dma,
-						xfer->len, DMA_FROM_DEVICE);
-				return -ENOMEM;
+			ret = geni_se_iommu_map_buf(mas->wrapper_dev,
+						&xfer->tx_dma,
+						(void *)xfer->tx_buf,
+						xfer->len, DMA_TO_DEVICE);
+			if (ret) {
+				GENI_SE_ERR(mas->ipc, true, mas->dev,
+				"%s: Mapping Tx buffer %d\n", __func__, ret);
+				return ret;
 			}
 		}
 	};
-
 	return 0;
 }
 
@@ -628,14 +694,13 @@
 				struct spi_message *msg)
 {
 	struct spi_transfer *xfer;
-	struct device *gsi_dev = mas->dev;
 
 	list_for_each_entry(xfer, &msg->transfers, transfer_list) {
 		if (xfer->rx_buf)
-			dma_unmap_single(gsi_dev, xfer->rx_dma,
+			geni_se_iommu_unmap_buf(mas->wrapper_dev, &xfer->rx_dma,
 						xfer->len, DMA_FROM_DEVICE);
 		if (xfer->tx_buf)
-			dma_unmap_single(gsi_dev, xfer->tx_dma,
+			geni_se_iommu_unmap_buf(mas->wrapper_dev, &xfer->tx_dma,
 						xfer->len, DMA_TO_DEVICE);
 	};
 }
@@ -689,7 +754,12 @@
 {
 	struct spi_geni_master *mas = spi_master_get_devdata(spi);
 	int ret = 0;
+	u32 max_speed = spi->cur_msg->spi->max_speed_hz;
+	struct se_geni_rsc *rsc = &mas->spi_rsc;
 
+	/* Adjust the AB/IB based on the max speed of the slave.*/
+	rsc->ib = max_speed * DEFAULT_BUS_WIDTH;
+	rsc->ab = max_speed * DEFAULT_BUS_WIDTH;
 	ret = pm_runtime_get_sync(mas->dev);
 	if (ret < 0) {
 		dev_err(mas->dev, "Error enabling SE resources\n");
@@ -844,7 +914,14 @@
 	spi_tx_cfg &= ~CS_TOGGLE;
 	if (xfer->cs_change)
 		spi_tx_cfg |= CS_TOGGLE;
-	trans_len = ((xfer->len << 3) / mas->cur_word_len) & TRANS_LEN_MSK;
+	if (!(mas->cur_word_len % MIN_WORD_LEN)) {
+		trans_len =
+			((xfer->len << 3) / mas->cur_word_len) & TRANS_LEN_MSK;
+	} else {
+		int bytes_per_word = (mas->cur_word_len / BITS_PER_BYTE) + 1;
+
+		trans_len = (xfer->len / bytes_per_word) & TRANS_LEN_MSK;
+	}
 	if (!list_is_last(&xfer->transfer_list, &spi->cur_msg->transfers))
 		m_param |= FRAGMENTATION;
 
@@ -860,6 +937,9 @@
 	}
 	geni_write_reg(spi_tx_cfg, mas->base, SE_SPI_TRANS_CFG);
 	geni_setup_m_cmd(mas->base, m_cmd, m_param);
+	GENI_SE_DBG(mas->ipc, false, mas->dev,
+		"%s: trans_len %d xferlen%d tx_cfg 0x%x cmd 0x%x\n",
+		__func__, trans_len, xfer->len, spi_tx_cfg, m_cmd);
 	if (m_cmd & SPI_TX_ONLY)
 		geni_write_reg(mas->tx_wm, mas->base, SE_GENI_TX_WATERMARK_REG);
 	/* Ensure all writes are done before the WM interrupt */
@@ -870,8 +950,10 @@
 {
 	unsigned long timeout;
 
+	geni_se_dump_dbg_regs(&mas->spi_rsc, mas->base, mas->ipc);
 	reinit_completion(&mas->xfer_done);
 	geni_cancel_m_cmd(mas->base);
+	geni_write_reg(0, mas->base, SE_GENI_TX_WATERMARK_REG);
 	/* Ensure cmd cancel is written */
 	mb();
 	timeout = wait_for_completion_timeout(&mas->xfer_done, HZ);
@@ -955,6 +1037,7 @@
 	}
 	return ret;
 err_gsi_geni_transfer_one:
+	geni_se_dump_dbg_regs(&mas->spi_rsc, mas->base, mas->ipc);
 	dmaengine_terminate_all(mas->tx);
 	return ret;
 err_fifo_geni_transfer_one:
@@ -966,12 +1049,25 @@
 {
 	int i = 0;
 	int tx_fifo_width = (mas->tx_fifo_width >> 3);
-	int max_bytes = (mas->tx_fifo_depth - mas->tx_wm) * tx_fifo_width;
+	int max_bytes = 0;
 	const u8 *tx_buf = NULL;
 
 	if (!mas->cur_xfer)
 		return;
 
+	/*
+	 * For non-byte aligned bits-per-word values:
+	 * Assumption is that each SPI word will be accomodated in
+	 * ceil (bits_per_word / bits_per_byte)
+	 * and the next SPI word starts at the next byte.
+	 * In such cases, we can fit 1 SPI word per FIFO word so adjust the
+	 * max byte that can be sent per IRQ accordingly.
+	 */
+	if ((mas->tx_fifo_width % mas->cur_word_len))
+		max_bytes = (mas->tx_fifo_depth - mas->tx_wm) *
+				((mas->cur_word_len / BITS_PER_BYTE) + 1);
+	else
+		max_bytes = (mas->tx_fifo_depth - mas->tx_wm) * tx_fifo_width;
 	tx_buf = mas->cur_xfer->tx_buf;
 	tx_buf += (mas->cur_xfer->len - mas->tx_rem_bytes);
 	max_bytes = min_t(int, mas->tx_rem_bytes, max_bytes);
@@ -979,8 +1075,13 @@
 		int j;
 		u32 fifo_word = 0;
 		u8 *fifo_byte;
-		int bytes_to_write = min_t(int, (max_bytes - i), tx_fifo_width);
+		int bytes_per_fifo = tx_fifo_width;
+		int bytes_to_write = 0;
 
+		if ((mas->tx_fifo_width % mas->cur_word_len))
+			bytes_per_fifo =
+				(mas->cur_word_len / BITS_PER_BYTE) + 1;
+		bytes_to_write = min_t(int, (max_bytes - i), bytes_per_fifo);
 		fifo_byte = (u8 *)&fifo_word;
 		for (j = 0; j < bytes_to_write; j++)
 			fifo_byte[j] = tx_buf[i++];
@@ -1019,15 +1120,24 @@
 			rx_bytes += rx_last_byte_valid;
 		}
 	}
-	rx_bytes += rx_wc * fifo_width;
+	if (!(mas->tx_fifo_width % mas->cur_word_len))
+		rx_bytes += rx_wc * fifo_width;
+	else
+		rx_bytes += rx_wc *
+			((mas->cur_word_len / BITS_PER_BYTE) + 1);
 	rx_bytes = min_t(int, mas->rx_rem_bytes, rx_bytes);
 	rx_buf += (mas->cur_xfer->len - mas->rx_rem_bytes);
 	while (i < rx_bytes) {
 		u32 fifo_word = 0;
 		u8 *fifo_byte;
-		int read_bytes = min_t(int, (rx_bytes - i), fifo_width);
+		int bytes_per_fifo = fifo_width;
+		int read_bytes = 0;
 		int j;
 
+		if ((mas->tx_fifo_width % mas->cur_word_len))
+			bytes_per_fifo =
+				(mas->cur_word_len / BITS_PER_BYTE) + 1;
+		read_bytes = min_t(int, (rx_bytes - i), bytes_per_fifo);
 		fifo_word = geni_read_reg(mas->base, SE_GENI_RX_FIFOn);
 		fifo_byte = (u8 *)&fifo_word;
 		for (j = 0; j < read_bytes; j++)
@@ -1039,8 +1149,14 @@
 static irqreturn_t geni_spi_irq(int irq, void *dev)
 {
 	struct spi_geni_master *mas = dev;
-	u32 m_irq = geni_read_reg(mas->base, SE_GENI_M_IRQ_STATUS);
+	u32 m_irq = 0;
 
+	if (pm_runtime_status_suspended(dev)) {
+		GENI_SE_DBG(mas->ipc, false, mas->dev,
+				"%s: device is suspended\n", __func__);
+		goto exit_geni_spi_irq;
+	}
+	m_irq = geni_read_reg(mas->base, SE_GENI_M_IRQ_STATUS);
 	if ((m_irq & M_RX_FIFO_WATERMARK_EN) || (m_irq & M_RX_FIFO_LAST_EN))
 		geni_spi_handle_rx(mas);
 
@@ -1050,7 +1166,26 @@
 	if ((m_irq & M_CMD_DONE_EN) || (m_irq & M_CMD_CANCEL_EN) ||
 		(m_irq & M_CMD_ABORT_EN)) {
 		complete(&mas->xfer_done);
+		/*
+		 * If this happens, then a CMD_DONE came before all the buffer
+		 * bytes were sent out. This is unusual, log this condition and
+		 * disable the WM interrupt to prevent the system from stalling
+		 * due an interrupt storm.
+		 * If this happens when all Rx bytes haven't been received, log
+		 * the condition.
+		 */
+		if (mas->tx_rem_bytes) {
+			geni_write_reg(0, mas->base, SE_GENI_TX_WATERMARK_REG);
+			GENI_SE_DBG(mas->ipc, false, mas->dev,
+				"%s:Premature Done.tx_rem%d bpw%d\n",
+				__func__, mas->tx_rem_bytes, mas->cur_word_len);
+		}
+		if (mas->rx_rem_bytes)
+			GENI_SE_DBG(mas->ipc, false, mas->dev,
+				"%s:Premature Done.rx_rem%d bpw%d\n",
+				__func__, mas->rx_rem_bytes, mas->cur_word_len);
 	}
+exit_geni_spi_irq:
 	geni_write_reg(m_irq, mas->base, SE_GENI_M_IRQ_CLEAR);
 	return IRQ_HANDLED;
 }
diff --git a/drivers/spi/spi_qsd.c b/drivers/spi/spi_qsd.c
new file mode 100644
index 0000000..bada281
--- /dev/null
+++ b/drivers/spi/spi_qsd.c
@@ -0,0 +1,2786 @@
+/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ *
+ */
+/*
+ * SPI driver for Qualcomm MSM platforms
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <linux/irq.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/interrupt.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/io.h>
+#include <linux/debugfs.h>
+#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/dma-mapping.h>
+#include <linux/sched.h>
+#include <linux/mutex.h>
+#include <linux/atomic.h>
+#include <linux/pm_runtime.h>
+#include <linux/spi/qcom-spi.h>
+#include <linux/msm-sps.h>
+#include <linux/msm-bus.h>
+#include <linux/msm-bus-board.h>
+#include "spi_qsd.h"
+
+#define SPI_MAX_BYTES_PER_WORD			(4)
+
+static int msm_spi_pm_resume_runtime(struct device *device);
+static int msm_spi_pm_suspend_runtime(struct device *device);
+static inline void msm_spi_dma_unmap_buffers(struct msm_spi *dd);
+static int get_local_resources(struct msm_spi *dd);
+static void put_local_resources(struct msm_spi *dd);
+
+static inline int msm_spi_configure_gsbi(struct msm_spi *dd,
+					struct platform_device *pdev)
+{
+	struct resource *resource;
+	unsigned long   gsbi_mem_phys_addr;
+	size_t          gsbi_mem_size;
+	void __iomem    *gsbi_base;
+
+	resource  = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (!resource)
+		return 0;
+
+	gsbi_mem_phys_addr = resource->start;
+	gsbi_mem_size = resource_size(resource);
+	if (!devm_request_mem_region(&pdev->dev, gsbi_mem_phys_addr,
+					gsbi_mem_size, SPI_DRV_NAME))
+		return -ENXIO;
+
+	gsbi_base = devm_ioremap(&pdev->dev, gsbi_mem_phys_addr,
+					gsbi_mem_size);
+	if (!gsbi_base)
+		return -ENXIO;
+
+	/* Set GSBI to SPI mode */
+	writel_relaxed(GSBI_SPI_CONFIG, gsbi_base + GSBI_CTRL_REG);
+
+	return 0;
+}
+
+static inline void msm_spi_register_init(struct msm_spi *dd)
+{
+	writel_relaxed(0x00000001, dd->base + SPI_SW_RESET);
+	msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+	writel_relaxed(0x00000000, dd->base + SPI_OPERATIONAL);
+	writel_relaxed(0x00000000, dd->base + SPI_CONFIG);
+	writel_relaxed(0x00000000, dd->base + SPI_IO_MODES);
+	if (dd->qup_ver)
+		writel_relaxed(0x00000000, dd->base + QUP_OPERATIONAL_MASK);
+}
+
+static int msm_spi_pinctrl_init(struct msm_spi *dd)
+{
+	dd->pinctrl = devm_pinctrl_get(dd->dev);
+	if (IS_ERR_OR_NULL(dd->pinctrl)) {
+		dev_err(dd->dev, "Failed to get pin ctrl\n");
+		return PTR_ERR(dd->pinctrl);
+	}
+	dd->pins_active = pinctrl_lookup_state(dd->pinctrl,
+				SPI_PINCTRL_STATE_DEFAULT);
+	if (IS_ERR_OR_NULL(dd->pins_active)) {
+		dev_err(dd->dev, "Failed to lookup pinctrl default state\n");
+		return PTR_ERR(dd->pins_active);
+	}
+
+	dd->pins_sleep = pinctrl_lookup_state(dd->pinctrl,
+				SPI_PINCTRL_STATE_SLEEP);
+	if (IS_ERR_OR_NULL(dd->pins_sleep)) {
+		dev_err(dd->dev, "Failed to lookup pinctrl sleep state\n");
+		return PTR_ERR(dd->pins_sleep);
+	}
+
+	return 0;
+}
+
+static inline int msm_spi_request_gpios(struct msm_spi *dd)
+{
+	int i = 0;
+	int result = 0;
+
+	if (!dd->pdata->use_pinctrl) {
+		for (i = 0; i < ARRAY_SIZE(spi_rsrcs); ++i) {
+			if (dd->spi_gpios[i] >= 0) {
+				result = gpio_request(dd->spi_gpios[i],
+						spi_rsrcs[i]);
+				if (result) {
+					dev_err(dd->dev,
+					"error %d gpio_request for pin %d\n",
+					result, dd->spi_gpios[i]);
+					goto error;
+				}
+			}
+		}
+	} else {
+		result = pinctrl_select_state(dd->pinctrl, dd->pins_active);
+		if (result) {
+			dev_err(dd->dev, "%s: Can not set %s pins\n",
+			__func__, SPI_PINCTRL_STATE_DEFAULT);
+			goto error;
+		}
+	}
+	return 0;
+error:
+	if (!dd->pdata->use_pinctrl) {
+		for (; --i >= 0;) {
+			if (dd->spi_gpios[i] >= 0)
+				gpio_free(dd->spi_gpios[i]);
+		}
+	}
+	return result;
+}
+
+static inline void msm_spi_free_gpios(struct msm_spi *dd)
+{
+	int i;
+	int result = 0;
+
+	if (!dd->pdata->use_pinctrl) {
+		for (i = 0; i < ARRAY_SIZE(spi_rsrcs); ++i) {
+			if (dd->spi_gpios[i] >= 0)
+				gpio_free(dd->spi_gpios[i]);
+			}
+
+		for (i = 0; i < ARRAY_SIZE(spi_cs_rsrcs); ++i) {
+			if (dd->cs_gpios[i].valid) {
+				gpio_free(dd->cs_gpios[i].gpio_num);
+				dd->cs_gpios[i].valid = 0;
+			}
+		}
+	} else {
+		result = pinctrl_select_state(dd->pinctrl, dd->pins_sleep);
+		if (result)
+			dev_err(dd->dev, "%s: Can not set %s pins\n",
+			__func__, SPI_PINCTRL_STATE_SLEEP);
+	}
+}
+
+static inline int msm_spi_request_cs_gpio(struct msm_spi *dd)
+{
+	int cs_num;
+	int rc;
+
+	cs_num = dd->spi->chip_select;
+	if (!(dd->spi->mode & SPI_LOOP)) {
+		if (!dd->pdata->use_pinctrl) {
+			if ((!(dd->cs_gpios[cs_num].valid)) &&
+				(dd->cs_gpios[cs_num].gpio_num >= 0)) {
+				rc = gpio_request(dd->cs_gpios[cs_num].gpio_num,
+					spi_cs_rsrcs[cs_num]);
+
+				if (rc) {
+					dev_err(dd->dev,
+					"gpio_request for pin %d failed,error %d\n",
+					dd->cs_gpios[cs_num].gpio_num, rc);
+					return rc;
+				}
+				dd->cs_gpios[cs_num].valid = 1;
+			}
+		}
+	}
+	return 0;
+}
+
+static inline void msm_spi_free_cs_gpio(struct msm_spi *dd)
+{
+	int cs_num;
+
+	cs_num = dd->spi->chip_select;
+	if (!dd->pdata->use_pinctrl) {
+		if (dd->cs_gpios[cs_num].valid) {
+			gpio_free(dd->cs_gpios[cs_num].gpio_num);
+			dd->cs_gpios[cs_num].valid = 0;
+		}
+	}
+}
+
+
+/**
+ * msm_spi_clk_max_rate: finds the nearest lower rate for a clk
+ * @clk the clock for which to find nearest lower rate
+ * @rate clock frequency in Hz
+ * @return nearest lower rate or negative error value
+ *
+ * Public clock API extends clk_round_rate which is a ceiling function. This
+ * function is a floor function implemented as a binary search using the
+ * ceiling function.
+ */
+static long msm_spi_clk_max_rate(struct clk *clk, unsigned long rate)
+{
+	long lowest_available, nearest_low, step_size, cur;
+	long step_direction = -1;
+	long guess = rate;
+	int  max_steps = 10;
+
+	cur =  clk_round_rate(clk, rate);
+	if (cur == rate)
+		return rate;
+
+	/* if we got here then: cur > rate */
+	lowest_available =  clk_round_rate(clk, 0);
+	if (lowest_available > rate)
+		return -EINVAL;
+
+	step_size = (rate - lowest_available) >> 1;
+	nearest_low = lowest_available;
+
+	while (max_steps-- && step_size) {
+		guess += step_size * step_direction;
+
+		cur =  clk_round_rate(clk, guess);
+
+		if ((cur < rate) && (cur > nearest_low))
+			nearest_low = cur;
+
+		/*
+		 * if we stepped too far, then start stepping in the other
+		 * direction with half the step size
+		 */
+		if (((cur > rate) && (step_direction > 0))
+		 || ((cur < rate) && (step_direction < 0))) {
+			step_direction = -step_direction;
+			step_size >>= 1;
+		}
+	}
+	return nearest_low;
+}
+
+static void msm_spi_clock_set(struct msm_spi *dd, int speed)
+{
+	long rate;
+	int rc;
+
+	rate = msm_spi_clk_max_rate(dd->clk, speed);
+	if (rate < 0) {
+		dev_err(dd->dev,
+		"%s: no match found for requested clock frequency:%d",
+			__func__, speed);
+		return;
+	}
+
+	rc = clk_set_rate(dd->clk, rate);
+	if (!rc)
+		dd->clock_speed = rate;
+}
+
+static void msm_spi_clk_path_vote(struct msm_spi *dd, u32 rate)
+{
+	if (dd->bus_cl_hdl) {
+		u64 ib = rate * dd->pdata->bus_width;
+
+		msm_bus_scale_update_bw(dd->bus_cl_hdl, 0, ib);
+	}
+}
+
+static void msm_spi_clk_path_teardown(struct msm_spi *dd)
+{
+	msm_spi_clk_path_vote(dd, 0);
+
+	if (dd->bus_cl_hdl) {
+		msm_bus_scale_unregister(dd->bus_cl_hdl);
+		dd->bus_cl_hdl = NULL;
+	}
+}
+
+/**
+ * msm_spi_clk_path_postponed_register: reg with bus-scaling after it is probed
+ *
+ * @return zero on success
+ *
+ * Workaround: SPI driver may be probed before the bus scaling driver. Calling
+ * msm_bus_scale_register_client() will fail if the bus scaling driver is not
+ * ready yet. Thus, this function should be called not from probe but from a
+ * later context. Also, this function may be called more then once before
+ * register succeed. At this case only one error message will be logged. At boot
+ * time all clocks are on, so earlier SPI transactions should succeed.
+ */
+static int msm_spi_clk_path_postponed_register(struct msm_spi *dd)
+{
+	int ret = 0;
+
+	dd->bus_cl_hdl = msm_bus_scale_register(dd->pdata->master_id,
+						MSM_BUS_SLAVE_EBI_CH0,
+						(char *)dev_name(dd->dev),
+						false);
+
+	if (IS_ERR_OR_NULL(dd->bus_cl_hdl)) {
+		ret = (dd->bus_cl_hdl ? PTR_ERR(dd->bus_cl_hdl) : -EAGAIN);
+		dev_err(dd->dev, "Failed bus registration Err %d", ret);
+	}
+
+	return ret;
+}
+
+static void msm_spi_clk_path_init(struct msm_spi *dd)
+{
+	/*
+	 * bail out if path voting is diabled (master_id == 0) or if it is
+	 * already registered (client_hdl != 0)
+	 */
+	if (!dd->pdata->master_id || dd->bus_cl_hdl)
+		return;
+
+	/* on failure try again later */
+	if (msm_spi_clk_path_postponed_register(dd))
+		return;
+
+}
+
+static int msm_spi_calculate_size(int *fifo_size,
+				  int *block_size,
+				  int block,
+				  int mult)
+{
+	int words;
+
+	switch (block) {
+	case 0:
+		words = 1; /* 4 bytes */
+		break;
+	case 1:
+		words = 4; /* 16 bytes */
+		break;
+	case 2:
+		words = 8; /* 32 bytes */
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (mult) {
+	case 0:
+		*fifo_size = words * 2;
+		break;
+	case 1:
+		*fifo_size = words * 4;
+		break;
+	case 2:
+		*fifo_size = words * 8;
+		break;
+	case 3:
+		*fifo_size = words * 16;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	*block_size = words * sizeof(u32); /* in bytes */
+	return 0;
+}
+
+static void msm_spi_calculate_fifo_size(struct msm_spi *dd)
+{
+	u32 spi_iom;
+	int block;
+	int mult;
+
+	spi_iom = readl_relaxed(dd->base + SPI_IO_MODES);
+
+	block = (spi_iom & SPI_IO_M_INPUT_BLOCK_SIZE) >> INPUT_BLOCK_SZ_SHIFT;
+	mult = (spi_iom & SPI_IO_M_INPUT_FIFO_SIZE) >> INPUT_FIFO_SZ_SHIFT;
+	if (msm_spi_calculate_size(&dd->input_fifo_size, &dd->input_block_size,
+				   block, mult)) {
+		goto fifo_size_err;
+	}
+
+	block = (spi_iom & SPI_IO_M_OUTPUT_BLOCK_SIZE) >> OUTPUT_BLOCK_SZ_SHIFT;
+	mult = (spi_iom & SPI_IO_M_OUTPUT_FIFO_SIZE) >> OUTPUT_FIFO_SZ_SHIFT;
+	if (msm_spi_calculate_size(&dd->output_fifo_size,
+				   &dd->output_block_size, block, mult)) {
+		goto fifo_size_err;
+	}
+	if (dd->qup_ver == SPI_QUP_VERSION_NONE) {
+		/* DM mode is not available for this block size */
+		if (dd->input_block_size == 4 || dd->output_block_size == 4)
+			dd->use_dma = 0;
+
+		if (dd->use_dma) {
+			dd->input_burst_size = max(dd->input_block_size,
+						DM_BURST_SIZE);
+			dd->output_burst_size = max(dd->output_block_size,
+						DM_BURST_SIZE);
+		}
+	}
+
+	return;
+
+fifo_size_err:
+	dd->use_dma = 0;
+	pr_err("%s: invalid FIFO size, SPI_IO_MODES=0x%x\n", __func__, spi_iom);
+}
+
+static void msm_spi_read_word_from_fifo(struct msm_spi *dd)
+{
+	u32   data_in;
+	int   i;
+	int   shift;
+	int   read_bytes = (dd->pack_words ?
+				SPI_MAX_BYTES_PER_WORD : dd->bytes_per_word);
+
+	data_in = readl_relaxed(dd->base + SPI_INPUT_FIFO);
+	if (dd->read_buf) {
+		for (i = 0; (i < read_bytes) &&
+			     dd->rx_bytes_remaining; i++) {
+			/* The data format depends on bytes_per_word:
+			 * 4 bytes: 0x12345678
+			 * 3 bytes: 0x00123456
+			 * 2 bytes: 0x00001234
+			 * 1 byte : 0x00000012
+			 */
+			shift = BITS_PER_BYTE * i;
+			*dd->read_buf++ = (data_in & (0xFF << shift)) >> shift;
+			dd->rx_bytes_remaining--;
+		}
+	} else {
+		if (dd->rx_bytes_remaining >= read_bytes)
+			dd->rx_bytes_remaining -= read_bytes;
+		else
+			dd->rx_bytes_remaining = 0;
+	}
+
+	dd->read_xfr_cnt++;
+}
+
+static inline bool msm_spi_is_valid_state(struct msm_spi *dd)
+{
+	u32 spi_op = readl_relaxed(dd->base + SPI_STATE);
+
+	return spi_op & SPI_OP_STATE_VALID;
+}
+
+static inline void msm_spi_udelay(unsigned int delay_usecs)
+{
+	/*
+	 * For smaller values of delay, context switch time
+	 * would negate the usage of usleep
+	 */
+	if (delay_usecs > 20)
+		usleep_range(delay_usecs, delay_usecs + 1);
+	else if (delay_usecs)
+		udelay(delay_usecs);
+}
+
+static inline int msm_spi_wait_valid(struct msm_spi *dd)
+{
+	unsigned int delay = 0;
+	unsigned long timeout = 0;
+
+	if (dd->clock_speed == 0)
+		return -EINVAL;
+	/*
+	 * Based on the SPI clock speed, sufficient time
+	 * should be given for the SPI state transition
+	 * to occur
+	 */
+	delay = (10 * USEC_PER_SEC) / dd->clock_speed;
+	/*
+	 * For small delay values, the default timeout would
+	 * be one jiffy
+	 */
+	if (delay < SPI_DELAY_THRESHOLD)
+		delay = SPI_DELAY_THRESHOLD;
+
+	/* Adding one to round off to the nearest jiffy */
+	timeout = jiffies + msecs_to_jiffies(delay * SPI_DEFAULT_TIMEOUT) + 1;
+	while (!msm_spi_is_valid_state(dd)) {
+		if (time_after(jiffies, timeout)) {
+			if (!msm_spi_is_valid_state(dd)) {
+				dev_err(dd->dev, "Invalid SPI operational state\n");
+				return -ETIMEDOUT;
+			} else
+				return 0;
+		}
+		msm_spi_udelay(delay);
+	}
+	return 0;
+}
+
+static inline int msm_spi_set_state(struct msm_spi *dd,
+				    enum msm_spi_state state)
+{
+	enum msm_spi_state cur_state;
+
+	if (msm_spi_wait_valid(dd))
+		return -EIO;
+	cur_state = readl_relaxed(dd->base + SPI_STATE);
+	/* Per spec:
+	 * For PAUSE_STATE to RESET_STATE, two writes of (10) are required
+	 */
+	if (((cur_state & SPI_OP_STATE) == SPI_OP_STATE_PAUSE) &&
+			(state == SPI_OP_STATE_RESET)) {
+		writel_relaxed(SPI_OP_STATE_CLEAR_BITS, dd->base + SPI_STATE);
+		writel_relaxed(SPI_OP_STATE_CLEAR_BITS, dd->base + SPI_STATE);
+	} else {
+		writel_relaxed((cur_state & ~SPI_OP_STATE) | state,
+		       dd->base + SPI_STATE);
+	}
+	if (msm_spi_wait_valid(dd))
+		return -EIO;
+
+	return 0;
+}
+
+/**
+ * msm_spi_set_bpw_and_no_io_flags: configure N, and no-input/no-output flags
+ */
+static inline void
+msm_spi_set_bpw_and_no_io_flags(struct msm_spi *dd, u32 *config, int n)
+{
+	*config &= ~(SPI_NO_INPUT|SPI_NO_OUTPUT);
+
+	if (n != (*config & SPI_CFG_N))
+		*config = (*config & ~SPI_CFG_N) | n;
+
+	if (dd->tx_mode == SPI_BAM_MODE) {
+		if (dd->read_buf == NULL)
+			*config |= SPI_NO_INPUT;
+		if (dd->write_buf == NULL)
+			*config |= SPI_NO_OUTPUT;
+	}
+}
+
+/**
+ * msm_spi_calc_spi_config_loopback_and_input_first: Calculate the values that
+ * should be updated into SPI_CONFIG's LOOPBACK and INPUT_FIRST flags
+ * @return calculatd value for SPI_CONFIG
+ */
+static u32
+msm_spi_calc_spi_config_loopback_and_input_first(u32 spi_config, u8 mode)
+{
+	if (mode & SPI_LOOP)
+		spi_config |= SPI_CFG_LOOPBACK;
+	else
+		spi_config &= ~SPI_CFG_LOOPBACK;
+
+	if (mode & SPI_CPHA)
+		spi_config &= ~SPI_CFG_INPUT_FIRST;
+	else
+		spi_config |= SPI_CFG_INPUT_FIRST;
+
+	return spi_config;
+}
+
+/**
+ * msm_spi_set_spi_config: prepares register SPI_CONFIG to process the
+ * next transfer
+ */
+static void msm_spi_set_spi_config(struct msm_spi *dd, int bpw)
+{
+	u32 spi_config = readl_relaxed(dd->base + SPI_CONFIG);
+
+	spi_config = msm_spi_calc_spi_config_loopback_and_input_first(
+					spi_config, dd->spi->mode);
+
+	if (dd->qup_ver == SPI_QUP_VERSION_NONE)
+		/* flags removed from SPI_CONFIG in QUP version-2 */
+		msm_spi_set_bpw_and_no_io_flags(dd, &spi_config, bpw-1);
+
+	/*
+	 * HS_MODE improves signal stability for spi-clk high rates
+	 * but is invalid in LOOPBACK mode.
+	 */
+	if ((dd->clock_speed >= SPI_HS_MIN_RATE) &&
+	   !(dd->spi->mode & SPI_LOOP))
+		spi_config |= SPI_CFG_HS_MODE;
+	else
+		spi_config &= ~SPI_CFG_HS_MODE;
+
+	writel_relaxed(spi_config, dd->base + SPI_CONFIG);
+}
+
+/**
+ * msm_spi_set_mx_counts: set SPI_MX_INPUT_COUNT and SPI_MX_INPUT_COUNT
+ * for FIFO-mode. set SPI_MX_INPUT_COUNT and SPI_MX_OUTPUT_COUNT for
+ * BAM and DMOV modes.
+ * @n_words The number of reads/writes of size N.
+ */
+static void msm_spi_set_mx_counts(struct msm_spi *dd, u32 n_words)
+{
+	/*
+	 * For FIFO mode:
+	 *   - Set the MX_OUTPUT_COUNT/MX_INPUT_COUNT registers to 0
+	 *   - Set the READ/WRITE_COUNT registers to 0 (infinite mode)
+	 *     or num bytes (finite mode) if less than fifo worth of data.
+	 * For Block mode:
+	 *  - Set the MX_OUTPUT/MX_INPUT_COUNT registers to num xfer bytes.
+	 *  - Set the READ/WRITE_COUNT registers to 0.
+	 */
+	if (dd->tx_mode != SPI_BAM_MODE) {
+		if (dd->tx_mode == SPI_FIFO_MODE) {
+			if (n_words <= dd->input_fifo_size)
+				msm_spi_set_write_count(dd, n_words);
+			else
+				msm_spi_set_write_count(dd, 0);
+			writel_relaxed(0, dd->base + SPI_MX_OUTPUT_COUNT);
+		} else
+			writel_relaxed(n_words, dd->base + SPI_MX_OUTPUT_COUNT);
+
+		if (dd->rx_mode == SPI_FIFO_MODE) {
+			if (n_words <= dd->input_fifo_size)
+				writel_relaxed(n_words,
+						dd->base + SPI_MX_READ_COUNT);
+			else
+				writel_relaxed(0,
+						dd->base + SPI_MX_READ_COUNT);
+			writel_relaxed(0, dd->base + SPI_MX_INPUT_COUNT);
+		} else
+			writel_relaxed(n_words, dd->base + SPI_MX_INPUT_COUNT);
+	} else {
+		/* must be zero for BAM and DMOV */
+		writel_relaxed(0, dd->base + SPI_MX_READ_COUNT);
+		msm_spi_set_write_count(dd, 0);
+
+		/*
+		 * for DMA transfers, both QUP_MX_INPUT_COUNT and
+		 * QUP_MX_OUTPUT_COUNT must be zero to all cases but one.
+		 * That case is a non-balanced transfer when there is
+		 * only a read_buf.
+		 */
+		if (dd->qup_ver == SPI_QUP_VERSION_BFAM) {
+			if (dd->write_buf)
+				writel_relaxed(0,
+						dd->base + SPI_MX_INPUT_COUNT);
+			else
+				writel_relaxed(n_words,
+						dd->base + SPI_MX_INPUT_COUNT);
+
+			writel_relaxed(0, dd->base + SPI_MX_OUTPUT_COUNT);
+		}
+	}
+}
+
+static int msm_spi_bam_pipe_disconnect(struct msm_spi *dd,
+						struct msm_spi_bam_pipe  *pipe)
+{
+	int ret = sps_disconnect(pipe->handle);
+
+	if (ret) {
+		dev_dbg(dd->dev, "%s disconnect bam %s pipe failed\n",
+			__func__, pipe->name);
+		return ret;
+	}
+	return 0;
+}
+
+static int msm_spi_bam_pipe_connect(struct msm_spi *dd,
+		struct msm_spi_bam_pipe  *pipe, struct sps_connect *config)
+{
+	int ret;
+	struct sps_register_event event  = {
+		.mode      = SPS_TRIGGER_WAIT,
+		.options   = SPS_O_EOT,
+	};
+
+	if (pipe == &dd->bam.prod)
+		event.xfer_done = &dd->rx_transfer_complete;
+	else if (pipe == &dd->bam.cons)
+		event.xfer_done = &dd->tx_transfer_complete;
+
+	ret = sps_connect(pipe->handle, config);
+	if (ret) {
+		dev_err(dd->dev, "%s: sps_connect(%s:0x%pK):%d",
+				__func__, pipe->name, pipe->handle, ret);
+		return ret;
+	}
+
+	ret = sps_register_event(pipe->handle, &event);
+	if (ret) {
+		dev_err(dd->dev, "%s sps_register_event(hndl:0x%pK %s):%d",
+				__func__, pipe->handle, pipe->name, ret);
+		msm_spi_bam_pipe_disconnect(dd, pipe);
+		return ret;
+	}
+
+	pipe->teardown_required = true;
+	return 0;
+}
+
+
+static void msm_spi_bam_pipe_flush(struct msm_spi *dd,
+					enum msm_spi_pipe_direction pipe_dir)
+{
+	struct msm_spi_bam_pipe *pipe = (pipe_dir == SPI_BAM_CONSUMER_PIPE) ?
+					(&dd->bam.prod) : (&dd->bam.cons);
+	struct sps_connect           config  = pipe->config;
+	int    ret;
+
+	ret = msm_spi_bam_pipe_disconnect(dd, pipe);
+	if (ret)
+		return;
+
+	ret = msm_spi_bam_pipe_connect(dd, pipe, &config);
+	if (ret)
+		return;
+}
+
+static void msm_spi_bam_flush(struct msm_spi *dd)
+{
+	dev_dbg(dd->dev, "%s flushing bam for recovery\n", __func__);
+
+	msm_spi_bam_pipe_flush(dd, SPI_BAM_CONSUMER_PIPE);
+	msm_spi_bam_pipe_flush(dd, SPI_BAM_PRODUCER_PIPE);
+}
+
+static int
+msm_spi_bam_process_rx(struct msm_spi *dd, u32 *bytes_to_send, u32 desc_cnt)
+{
+	int ret = 0;
+	u32 data_xfr_size = 0, rem_bc = 0;
+	u32 prod_flags = 0;
+
+	rem_bc = dd->cur_rx_transfer->len - dd->bam.curr_rx_bytes_recvd;
+	data_xfr_size = (rem_bc < *bytes_to_send) ? rem_bc : *bytes_to_send;
+
+	/*
+	 * set flags for last descriptor only
+	 */
+	if ((desc_cnt == 1)
+		|| (*bytes_to_send == data_xfr_size))
+		prod_flags = (dd->write_buf)
+			? 0 : (SPS_IOVEC_FLAG_EOT | SPS_IOVEC_FLAG_NWD);
+
+	/*
+	 * enqueue read buffer in BAM
+	 */
+	ret = sps_transfer_one(dd->bam.prod.handle,
+			dd->cur_rx_transfer->rx_dma
+				+ dd->bam.curr_rx_bytes_recvd,
+			data_xfr_size, dd, prod_flags);
+	if (ret < 0) {
+		dev_err(dd->dev,
+		"%s: Failed to queue producer BAM transfer",
+		__func__);
+		return ret;
+	}
+
+	dd->bam.curr_rx_bytes_recvd += data_xfr_size;
+	*bytes_to_send -= data_xfr_size;
+	dd->bam.bam_rx_len -= data_xfr_size;
+	return data_xfr_size;
+}
+
+static int
+msm_spi_bam_process_tx(struct msm_spi *dd, u32 *bytes_to_send, u32 desc_cnt)
+{
+	int ret = 0;
+	u32 data_xfr_size = 0, rem_bc = 0;
+	u32 cons_flags = 0;
+
+	rem_bc = dd->cur_tx_transfer->len - dd->bam.curr_tx_bytes_sent;
+	data_xfr_size = (rem_bc < *bytes_to_send) ? rem_bc : *bytes_to_send;
+
+	/*
+	 * set flags for last descriptor only
+	 */
+	if ((desc_cnt == 1)
+		|| (*bytes_to_send == data_xfr_size))
+		cons_flags = SPS_IOVEC_FLAG_EOT | SPS_IOVEC_FLAG_NWD;
+
+	/*
+	 * enqueue write buffer in BAM
+	 */
+	ret = sps_transfer_one(dd->bam.cons.handle,
+			dd->cur_tx_transfer->tx_dma
+				+ dd->bam.curr_tx_bytes_sent,
+			data_xfr_size, dd, cons_flags);
+	if (ret < 0) {
+		dev_err(dd->dev,
+		"%s: Failed to queue consumer BAM transfer",
+		__func__);
+		return ret;
+	}
+
+	dd->bam.curr_tx_bytes_sent	+= data_xfr_size;
+	*bytes_to_send	-= data_xfr_size;
+	dd->bam.bam_tx_len -= data_xfr_size;
+	return data_xfr_size;
+}
+
+
+/**
+ * msm_spi_bam_begin_transfer: transfer dd->tx_bytes_remaining bytes
+ * using BAM.
+ * @brief BAM can transfer SPI_MAX_TRFR_BTWN_RESETS byte at a single
+ * transfer. Between transfer QUP must change to reset state. A loop is
+ * issuing a single BAM transfer at a time.
+ * @return zero on success
+ */
+static int
+msm_spi_bam_begin_transfer(struct msm_spi *dd)
+{
+	u32 tx_bytes_to_send = 0, rx_bytes_to_recv = 0;
+	u32 n_words_xfr;
+	s32 ret = 0;
+	u32 prod_desc_cnt = SPI_BAM_MAX_DESC_NUM - 1;
+	u32 cons_desc_cnt = SPI_BAM_MAX_DESC_NUM - 1;
+	u32 byte_count = 0;
+
+	rx_bytes_to_recv = min_t(u32, dd->bam.bam_rx_len,
+				SPI_MAX_TRFR_BTWN_RESETS);
+	tx_bytes_to_send = min_t(u32, dd->bam.bam_tx_len,
+				SPI_MAX_TRFR_BTWN_RESETS);
+	n_words_xfr = DIV_ROUND_UP(rx_bytes_to_recv,
+				dd->bytes_per_word);
+
+	msm_spi_set_mx_counts(dd, n_words_xfr);
+	ret = msm_spi_set_state(dd, SPI_OP_STATE_RUN);
+	if (ret < 0) {
+		dev_err(dd->dev,
+			"%s: Failed to set QUP state to run",
+			__func__);
+		goto xfr_err;
+	}
+
+	while ((rx_bytes_to_recv + tx_bytes_to_send) &&
+		((cons_desc_cnt + prod_desc_cnt) > 0)) {
+		struct spi_transfer *t = NULL;
+
+		if (dd->read_buf && (prod_desc_cnt > 0)) {
+			ret = msm_spi_bam_process_rx(dd, &rx_bytes_to_recv,
+							prod_desc_cnt);
+			if (ret < 0)
+				goto xfr_err;
+
+			if (!(dd->cur_rx_transfer->len
+				- dd->bam.curr_rx_bytes_recvd))
+				t = dd->cur_rx_transfer;
+			prod_desc_cnt--;
+		}
+
+		if (dd->write_buf && (cons_desc_cnt > 0)) {
+			ret = msm_spi_bam_process_tx(dd, &tx_bytes_to_send,
+							cons_desc_cnt);
+			if (ret < 0)
+				goto xfr_err;
+
+			if (!(dd->cur_tx_transfer->len
+				- dd->bam.curr_tx_bytes_sent))
+				t = dd->cur_tx_transfer;
+			cons_desc_cnt--;
+		}
+
+		byte_count += ret;
+	}
+
+	dd->tx_bytes_remaining -= min_t(u32, byte_count,
+						SPI_MAX_TRFR_BTWN_RESETS);
+	return 0;
+xfr_err:
+	return ret;
+}
+
+static int
+msm_spi_bam_next_transfer(struct msm_spi *dd)
+{
+	if (dd->tx_mode != SPI_BAM_MODE)
+		return 0;
+
+	if (dd->tx_bytes_remaining > 0) {
+		if (msm_spi_set_state(dd, SPI_OP_STATE_RESET))
+			return 0;
+		if ((msm_spi_bam_begin_transfer(dd)) < 0) {
+			dev_err(dd->dev, "%s: BAM transfer setup failed\n",
+				__func__);
+			return 0;
+		}
+		return 1;
+	}
+	return 0;
+}
+
+static int msm_spi_dma_send_next(struct msm_spi *dd)
+{
+	int ret = 0;
+
+	if (dd->tx_mode == SPI_BAM_MODE)
+		ret = msm_spi_bam_next_transfer(dd);
+	return ret;
+}
+
+static inline void msm_spi_ack_transfer(struct msm_spi *dd)
+{
+	writel_relaxed(SPI_OP_MAX_INPUT_DONE_FLAG |
+		       SPI_OP_MAX_OUTPUT_DONE_FLAG,
+		       dd->base + SPI_OPERATIONAL);
+	/* Ensure done flag was cleared before proceeding further */
+	mb();
+}
+
+/* Figure which irq occurred and call the relevant functions */
+static inline irqreturn_t msm_spi_qup_irq(int irq, void *dev_id)
+{
+	u32 op, ret = IRQ_NONE;
+	struct msm_spi *dd = dev_id;
+
+	if (pm_runtime_suspended(dd->dev)) {
+		dev_warn(dd->dev, "QUP: pm runtime suspend, irq:%d\n", irq);
+		return ret;
+	}
+	if (readl_relaxed(dd->base + SPI_ERROR_FLAGS) ||
+	    readl_relaxed(dd->base + QUP_ERROR_FLAGS)) {
+		struct spi_master *master = dev_get_drvdata(dd->dev);
+
+		ret |= msm_spi_error_irq(irq, master);
+	}
+
+	op = readl_relaxed(dd->base + SPI_OPERATIONAL);
+	writel_relaxed(op, dd->base + SPI_OPERATIONAL);
+	/*
+	 * Ensure service flag was cleared before further
+	 * processing of interrupt.
+	 */
+	mb();
+	if (op & SPI_OP_INPUT_SERVICE_FLAG)
+		ret |= msm_spi_input_irq(irq, dev_id);
+
+	if (op & SPI_OP_OUTPUT_SERVICE_FLAG)
+		ret |= msm_spi_output_irq(irq, dev_id);
+
+	if (dd->tx_mode != SPI_BAM_MODE) {
+		if (!dd->rx_done) {
+			if (dd->rx_bytes_remaining == 0)
+				dd->rx_done = true;
+		}
+		if (!dd->tx_done) {
+			if (!dd->tx_bytes_remaining &&
+					(op & SPI_OP_IP_FIFO_NOT_EMPTY)) {
+				dd->tx_done = true;
+			}
+		}
+	}
+	if (dd->tx_done && dd->rx_done) {
+		msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+		dd->tx_done = false;
+		dd->rx_done = false;
+		complete(&dd->rx_transfer_complete);
+		complete(&dd->tx_transfer_complete);
+	}
+	return ret;
+}
+
+static irqreturn_t msm_spi_input_irq(int irq, void *dev_id)
+{
+	struct msm_spi	       *dd = dev_id;
+
+	dd->stat_rx++;
+
+	if (dd->rx_mode == SPI_MODE_NONE)
+		return IRQ_HANDLED;
+
+	if (dd->rx_mode == SPI_FIFO_MODE) {
+		while ((readl_relaxed(dd->base + SPI_OPERATIONAL) &
+			SPI_OP_IP_FIFO_NOT_EMPTY) &&
+			(dd->rx_bytes_remaining > 0)) {
+			msm_spi_read_word_from_fifo(dd);
+		}
+	} else if (dd->rx_mode == SPI_BLOCK_MODE) {
+		int count = 0;
+
+		while (dd->rx_bytes_remaining &&
+				(count < dd->input_block_size)) {
+			msm_spi_read_word_from_fifo(dd);
+			count += SPI_MAX_BYTES_PER_WORD;
+		}
+	}
+
+	return IRQ_HANDLED;
+}
+
+static void msm_spi_write_word_to_fifo(struct msm_spi *dd)
+{
+	u32    word;
+	u8     byte;
+	int    i;
+	int   write_bytes =
+		(dd->pack_words ? SPI_MAX_BYTES_PER_WORD : dd->bytes_per_word);
+
+	word = 0;
+	if (dd->write_buf) {
+		for (i = 0; (i < write_bytes) &&
+			     dd->tx_bytes_remaining; i++) {
+			dd->tx_bytes_remaining--;
+			byte = *dd->write_buf++;
+			word |= (byte << (BITS_PER_BYTE * i));
+		}
+	} else
+		if (dd->tx_bytes_remaining > write_bytes)
+			dd->tx_bytes_remaining -= write_bytes;
+		else
+			dd->tx_bytes_remaining = 0;
+	dd->write_xfr_cnt++;
+
+	writel_relaxed(word, dd->base + SPI_OUTPUT_FIFO);
+}
+
+static inline void msm_spi_write_rmn_to_fifo(struct msm_spi *dd)
+{
+	int count = 0;
+
+	if (dd->tx_mode == SPI_FIFO_MODE) {
+		while ((dd->tx_bytes_remaining > 0) &&
+			(count < dd->input_fifo_size) &&
+		       !(readl_relaxed(dd->base + SPI_OPERATIONAL)
+						& SPI_OP_OUTPUT_FIFO_FULL)) {
+			msm_spi_write_word_to_fifo(dd);
+			count++;
+		}
+	}
+
+	if (dd->tx_mode == SPI_BLOCK_MODE) {
+		while (dd->tx_bytes_remaining &&
+				(count < dd->output_block_size)) {
+			msm_spi_write_word_to_fifo(dd);
+			count += SPI_MAX_BYTES_PER_WORD;
+		}
+	}
+}
+
+static irqreturn_t msm_spi_output_irq(int irq, void *dev_id)
+{
+	struct msm_spi	       *dd = dev_id;
+
+	dd->stat_tx++;
+
+	if (dd->tx_mode == SPI_MODE_NONE)
+		return IRQ_HANDLED;
+
+	/* Output FIFO is empty. Transmit any outstanding write data. */
+	if ((dd->tx_mode == SPI_FIFO_MODE) || (dd->tx_mode == SPI_BLOCK_MODE))
+		msm_spi_write_rmn_to_fifo(dd);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t msm_spi_error_irq(int irq, void *dev_id)
+{
+	struct spi_master	*master = dev_id;
+	struct msm_spi          *dd = spi_master_get_devdata(master);
+	u32                      spi_err;
+
+	spi_err = readl_relaxed(dd->base + SPI_ERROR_FLAGS);
+	if (spi_err & SPI_ERR_OUTPUT_OVER_RUN_ERR)
+		dev_warn(master->dev.parent, "SPI output overrun error\n");
+	if (spi_err & SPI_ERR_INPUT_UNDER_RUN_ERR)
+		dev_warn(master->dev.parent, "SPI input underrun error\n");
+	if (spi_err & SPI_ERR_OUTPUT_UNDER_RUN_ERR)
+		dev_warn(master->dev.parent, "SPI output underrun error\n");
+	msm_spi_get_clk_err(dd, &spi_err);
+	if (spi_err & SPI_ERR_CLK_OVER_RUN_ERR)
+		dev_warn(master->dev.parent, "SPI clock overrun error\n");
+	if (spi_err & SPI_ERR_CLK_UNDER_RUN_ERR)
+		dev_warn(master->dev.parent, "SPI clock underrun error\n");
+	msm_spi_clear_error_flags(dd);
+	msm_spi_ack_clk_err(dd);
+	/* Ensure clearing of QUP_ERROR_FLAGS was completed */
+	mb();
+	return IRQ_HANDLED;
+}
+
+static int msm_spi_bam_map_buffers(struct msm_spi *dd)
+{
+	int ret = -EINVAL;
+	struct device *dev;
+	struct spi_transfer *xfr;
+	void *tx_buf, *rx_buf;
+	u32 tx_len, rx_len;
+
+	dev = dd->dev;
+	xfr = dd->cur_transfer;
+
+	tx_buf = (void *)xfr->tx_buf;
+	rx_buf = xfr->rx_buf;
+	tx_len = rx_len = xfr->len;
+	if (tx_buf != NULL) {
+		xfr->tx_dma = dma_map_single(dev, tx_buf,
+						tx_len, DMA_TO_DEVICE);
+		if (dma_mapping_error(dev, xfr->tx_dma)) {
+			ret = -ENOMEM;
+			goto error;
+		}
+	}
+
+	if (rx_buf != NULL) {
+		xfr->rx_dma = dma_map_single(dev, rx_buf, rx_len,
+						DMA_FROM_DEVICE);
+		if (dma_mapping_error(dev, xfr->rx_dma)) {
+			if (tx_buf != NULL)
+				dma_unmap_single(dev,
+						xfr->tx_dma,
+						tx_len, DMA_TO_DEVICE);
+			ret = -ENOMEM;
+			goto error;
+		}
+	}
+
+	return 0;
+error:
+	msm_spi_dma_unmap_buffers(dd);
+	return ret;
+}
+
+static int msm_spi_dma_map_buffers(struct msm_spi *dd)
+{
+	int ret = 0;
+
+	if (dd->tx_mode == SPI_BAM_MODE)
+		ret = msm_spi_bam_map_buffers(dd);
+	return ret;
+}
+
+static void msm_spi_bam_unmap_buffers(struct msm_spi *dd)
+{
+	struct device *dev;
+	struct spi_transfer *xfr;
+	void *tx_buf, *rx_buf;
+	u32  tx_len, rx_len;
+
+	dev = dd->dev;
+	xfr = dd->cur_transfer;
+
+	tx_buf = (void *)xfr->tx_buf;
+	rx_buf = xfr->rx_buf;
+	tx_len = rx_len = xfr->len;
+	if (tx_buf != NULL)
+		dma_unmap_single(dev, xfr->tx_dma,
+				tx_len, DMA_TO_DEVICE);
+
+	if (rx_buf != NULL)
+		dma_unmap_single(dev, xfr->rx_dma,
+				rx_len, DMA_FROM_DEVICE);
+}
+
+static inline void msm_spi_dma_unmap_buffers(struct msm_spi *dd)
+{
+	if (dd->tx_mode == SPI_BAM_MODE)
+		msm_spi_bam_unmap_buffers(dd);
+}
+
+/**
+ * msm_spi_use_dma - decides whether to use Data-Mover or BAM for
+ * the given transfer
+ * @dd:       device
+ * @tr:       transfer
+ *
+ * Start using DMA if:
+ * 1. Is supported by HW
+ * 2. Is not diabled by platform data
+ * 3. Transfer size is greater than 3*block size.
+ * 4. Buffers are aligned to cache line.
+ * 5. Bytes-per-word is 8,16 or 32.
+ */
+static inline bool
+msm_spi_use_dma(struct msm_spi *dd, struct spi_transfer *tr, u8 bpw)
+{
+	if (!dd->use_dma)
+		return false;
+
+	/* check constraints from platform data */
+	if ((dd->qup_ver == SPI_QUP_VERSION_BFAM) && !dd->pdata->use_bam)
+		return false;
+
+	if (dd->cur_msg_len < 3*dd->input_block_size)
+		return false;
+
+	if ((dd->qup_ver != SPI_QUP_VERSION_BFAM) &&
+		 !dd->read_len && !dd->write_len)
+		return false;
+
+	if (dd->qup_ver == SPI_QUP_VERSION_NONE) {
+		u32 cache_line = dma_get_cache_alignment();
+
+		if (tr->tx_buf) {
+			if (!IS_ALIGNED((size_t)tr->tx_buf, cache_line))
+				return 0;
+		}
+		if (tr->rx_buf) {
+			if (!IS_ALIGNED((size_t)tr->rx_buf, cache_line))
+				return false;
+		}
+
+		if (tr->cs_change &&
+		   ((bpw != 8) && (bpw != 16) && (bpw != 32)))
+			return false;
+	}
+
+	return true;
+}
+
+/**
+ * msm_spi_set_transfer_mode: Chooses optimal transfer mode. Sets dd->mode and
+ * prepares to process a transfer.
+ */
+static void
+msm_spi_set_transfer_mode(struct msm_spi *dd, u8 bpw, u32 read_count)
+{
+	if (msm_spi_use_dma(dd, dd->cur_transfer, bpw)) {
+		dd->tx_mode = SPI_BAM_MODE;
+		dd->rx_mode = SPI_BAM_MODE;
+	} else {
+		dd->rx_mode = SPI_FIFO_MODE;
+		dd->tx_mode = SPI_FIFO_MODE;
+		dd->read_len = dd->cur_transfer->len;
+		dd->write_len = dd->cur_transfer->len;
+	}
+}
+
+/**
+ * msm_spi_set_qup_io_modes: prepares register QUP_IO_MODES to process a
+ * transfer
+ */
+static void msm_spi_set_qup_io_modes(struct msm_spi *dd)
+{
+	u32 spi_iom;
+
+	spi_iom = readl_relaxed(dd->base + SPI_IO_MODES);
+	/* Set input and output transfer mode: FIFO, DMOV, or BAM */
+	spi_iom &= ~(SPI_IO_M_INPUT_MODE | SPI_IO_M_OUTPUT_MODE);
+	spi_iom = (spi_iom | (dd->tx_mode << OUTPUT_MODE_SHIFT));
+	spi_iom = (spi_iom | (dd->rx_mode << INPUT_MODE_SHIFT));
+
+	/* Always enable packing for the BAM mode and for non BAM mode only
+	 * if bpw is % 8 and transfer length is % 4 Bytes.
+	 */
+	if (dd->tx_mode == SPI_BAM_MODE ||
+		((dd->cur_msg_len % SPI_MAX_BYTES_PER_WORD == 0) &&
+		(dd->cur_transfer->bits_per_word) &&
+		(dd->cur_transfer->bits_per_word <= 32) &&
+		(dd->cur_transfer->bits_per_word % 8 == 0))) {
+		spi_iom |= SPI_IO_M_PACK_EN | SPI_IO_M_UNPACK_EN;
+		dd->pack_words = true;
+	} else {
+		spi_iom &= ~(SPI_IO_M_PACK_EN | SPI_IO_M_UNPACK_EN);
+		spi_iom |= SPI_IO_M_OUTPUT_BIT_SHIFT_EN;
+		dd->pack_words = false;
+	}
+
+	writel_relaxed(spi_iom, dd->base + SPI_IO_MODES);
+}
+
+static u32 msm_spi_calc_spi_ioc_clk_polarity(u32 spi_ioc, u8 mode)
+{
+	if (mode & SPI_CPOL)
+		spi_ioc |= SPI_IO_C_CLK_IDLE_HIGH;
+	else
+		spi_ioc &= ~SPI_IO_C_CLK_IDLE_HIGH;
+	return spi_ioc;
+}
+
+/**
+ * msm_spi_set_spi_io_control: prepares register SPI_IO_CONTROL to process the
+ * next transfer
+ * @return the new set value of SPI_IO_CONTROL
+ */
+static u32 msm_spi_set_spi_io_control(struct msm_spi *dd)
+{
+	u32 spi_ioc, spi_ioc_orig, chip_select;
+
+	spi_ioc = readl_relaxed(dd->base + SPI_IO_CONTROL);
+	spi_ioc_orig = spi_ioc;
+	spi_ioc = msm_spi_calc_spi_ioc_clk_polarity(spi_ioc
+						, dd->spi->mode);
+	/* Set chip-select */
+	chip_select = dd->spi->chip_select << 2;
+	if ((spi_ioc & SPI_IO_C_CS_SELECT) != chip_select)
+		spi_ioc = (spi_ioc & ~SPI_IO_C_CS_SELECT) | chip_select;
+	if (!dd->cur_transfer->cs_change)
+		spi_ioc |= SPI_IO_C_MX_CS_MODE;
+
+	if (spi_ioc != spi_ioc_orig)
+		writel_relaxed(spi_ioc, dd->base + SPI_IO_CONTROL);
+
+	/*
+	 * Ensure that the IO control mode register gets written
+	 * before proceeding with the transfer.
+	 */
+	mb();
+	return spi_ioc;
+}
+
+/**
+ * msm_spi_set_qup_op_mask: prepares register QUP_OPERATIONAL_MASK to process
+ * the next transfer
+ */
+static void msm_spi_set_qup_op_mask(struct msm_spi *dd)
+{
+	/* mask INPUT and OUTPUT service flags in to prevent IRQs on FIFO status
+	 * change in BAM mode
+	 */
+	u32 mask = (dd->tx_mode == SPI_BAM_MODE) ?
+		QUP_OP_MASK_OUTPUT_SERVICE_FLAG | QUP_OP_MASK_INPUT_SERVICE_FLAG
+		: 0;
+	writel_relaxed(mask, dd->base + QUP_OPERATIONAL_MASK);
+}
+
+static void get_transfer_length(struct msm_spi *dd)
+{
+	struct spi_transfer *xfer = dd->cur_transfer;
+
+	dd->cur_msg_len = 0;
+	dd->read_len = dd->write_len = 0;
+	dd->bam.bam_tx_len = dd->bam.bam_rx_len = 0;
+
+	if (xfer->tx_buf)
+		dd->bam.bam_tx_len = dd->write_len = xfer->len;
+	if (xfer->rx_buf)
+		dd->bam.bam_rx_len = dd->read_len = xfer->len;
+	dd->cur_msg_len = xfer->len;
+}
+
+static int msm_spi_process_transfer(struct msm_spi *dd)
+{
+	u8  bpw;
+	u32 max_speed;
+	u32 read_count;
+	u32 timeout;
+	u32 spi_ioc;
+	u32 int_loopback = 0;
+	int ret;
+	int status = 0;
+
+	get_transfer_length(dd);
+	dd->cur_tx_transfer = dd->cur_transfer;
+	dd->cur_rx_transfer = dd->cur_transfer;
+	dd->bam.curr_rx_bytes_recvd = dd->bam.curr_tx_bytes_sent = 0;
+	dd->write_xfr_cnt = dd->read_xfr_cnt = 0;
+	dd->tx_bytes_remaining = dd->cur_msg_len;
+	dd->rx_bytes_remaining = dd->cur_msg_len;
+	dd->read_buf           = dd->cur_transfer->rx_buf;
+	dd->write_buf          = dd->cur_transfer->tx_buf;
+	dd->tx_done = false;
+	dd->rx_done = false;
+	init_completion(&dd->tx_transfer_complete);
+	init_completion(&dd->rx_transfer_complete);
+	if (dd->cur_transfer->bits_per_word)
+		bpw = dd->cur_transfer->bits_per_word;
+	else
+		bpw = 8;
+	dd->bytes_per_word = (bpw + 7) / 8;
+
+	if (dd->cur_transfer->speed_hz)
+		max_speed = dd->cur_transfer->speed_hz;
+	else
+		max_speed = dd->spi->max_speed_hz;
+	if (!dd->clock_speed || max_speed != dd->clock_speed)
+		msm_spi_clock_set(dd, max_speed);
+
+	timeout = 100 * msecs_to_jiffies(
+			DIV_ROUND_UP(dd->cur_msg_len * 8,
+			DIV_ROUND_UP(max_speed, MSEC_PER_SEC)));
+
+	read_count = DIV_ROUND_UP(dd->cur_msg_len, dd->bytes_per_word);
+	if (dd->spi->mode & SPI_LOOP)
+		int_loopback = 1;
+
+	ret = msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+	if (ret < 0) {
+		dev_err(dd->dev,
+			"%s: Error setting QUP to reset-state",
+			__func__);
+		return ret;
+	}
+
+	msm_spi_set_transfer_mode(dd, bpw, read_count);
+	msm_spi_set_mx_counts(dd, read_count);
+	if (dd->tx_mode == SPI_BAM_MODE) {
+		ret = msm_spi_dma_map_buffers(dd);
+		if (ret < 0) {
+			pr_err("Mapping DMA buffers\n");
+			dd->tx_mode = SPI_MODE_NONE;
+			dd->rx_mode = SPI_MODE_NONE;
+			return ret;
+		}
+	}
+	msm_spi_set_qup_io_modes(dd);
+	msm_spi_set_spi_config(dd, bpw);
+	msm_spi_set_qup_config(dd, bpw);
+	spi_ioc = msm_spi_set_spi_io_control(dd);
+	msm_spi_set_qup_op_mask(dd);
+
+	/* The output fifo interrupt handler will handle all writes after
+	 * the first. Restricting this to one write avoids contention
+	 * issues and race conditions between this thread and the int handler
+	 */
+	if (dd->tx_mode != SPI_BAM_MODE) {
+		if (msm_spi_prepare_for_write(dd))
+			goto transfer_end;
+		msm_spi_start_write(dd, read_count);
+	} else {
+		if ((msm_spi_bam_begin_transfer(dd)) < 0) {
+			dev_err(dd->dev, "%s: BAM transfer setup failed\n",
+				__func__);
+			status = -EIO;
+			goto transfer_end;
+		}
+	}
+
+	/*
+	 * On BAM mode, current state here is run.
+	 * Only enter the RUN state after the first word is written into
+	 * the output FIFO. Otherwise, the output FIFO EMPTY interrupt
+	 * might fire before the first word is written resulting in a
+	 * possible race condition.
+	 */
+	if (dd->tx_mode != SPI_BAM_MODE)
+		if (msm_spi_set_state(dd, SPI_OP_STATE_RUN)) {
+			dev_warn(dd->dev,
+				"%s: Failed to set QUP to run-state. Mode:%d",
+				__func__, dd->tx_mode);
+			goto transfer_end;
+		}
+
+	/* Assume success, this might change later upon transaction result */
+	do {
+		if (dd->write_buf &&
+		    !wait_for_completion_timeout(&dd->tx_transfer_complete,
+		    timeout)) {
+			dev_err(dd->dev, "%s: SPI Tx transaction timeout\n",
+				__func__);
+			status = -EIO;
+			break;
+		}
+
+		if (dd->read_buf &&
+		    !wait_for_completion_timeout(&dd->rx_transfer_complete,
+		    timeout)) {
+			dev_err(dd->dev, "%s: SPI Rx transaction timeout\n",
+				__func__);
+			status = -EIO;
+			break;
+		}
+	} while (msm_spi_dma_send_next(dd));
+
+	msm_spi_udelay(dd->xfrs_delay_usec);
+
+transfer_end:
+	if ((dd->tx_mode == SPI_BAM_MODE) && status)
+		msm_spi_bam_flush(dd);
+	msm_spi_dma_unmap_buffers(dd);
+	dd->tx_mode = SPI_MODE_NONE;
+	dd->rx_mode = SPI_MODE_NONE;
+
+	msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+	if (!dd->cur_transfer->cs_change)
+		writel_relaxed(spi_ioc & ~SPI_IO_C_MX_CS_MODE,
+		       dd->base + SPI_IO_CONTROL);
+	return status;
+}
+
+
+static inline void msm_spi_set_cs(struct spi_device *spi, bool set_flag)
+{
+	struct msm_spi *dd = spi_master_get_devdata(spi->master);
+	u32 spi_ioc;
+	u32 spi_ioc_orig;
+	int rc = 0;
+
+	rc = pm_runtime_get_sync(dd->dev);
+	if (rc < 0) {
+		dev_err(dd->dev, "Failure during runtime get,rc=%d", rc);
+		return;
+	}
+
+	if (dd->pdata->is_shared) {
+		rc = get_local_resources(dd);
+		if (rc)
+			return;
+	}
+
+	msm_spi_clk_path_vote(dd, spi->max_speed_hz);
+
+	if (!(spi->mode & SPI_CS_HIGH))
+		set_flag = !set_flag;
+
+	/* Serve only under mutex lock as RT suspend may cause a race */
+	mutex_lock(&dd->core_lock);
+	if (dd->suspended) {
+		dev_err(dd->dev, "%s: SPI operational state=%d Invalid\n",
+			__func__, dd->suspended);
+		mutex_unlock(&dd->core_lock);
+		return;
+	}
+
+	spi_ioc = readl_relaxed(dd->base + SPI_IO_CONTROL);
+	spi_ioc_orig = spi_ioc;
+	if (set_flag)
+		spi_ioc |= SPI_IO_C_FORCE_CS;
+	else
+		spi_ioc &= ~SPI_IO_C_FORCE_CS;
+
+	if (spi_ioc != spi_ioc_orig)
+		writel_relaxed(spi_ioc, dd->base + SPI_IO_CONTROL);
+	if (dd->pdata->is_shared)
+		put_local_resources(dd);
+	mutex_unlock(&dd->core_lock);
+
+	pm_runtime_mark_last_busy(dd->dev);
+	pm_runtime_put_autosuspend(dd->dev);
+}
+
+static void reset_core(struct msm_spi *dd)
+{
+	u32 spi_ioc;
+
+	msm_spi_register_init(dd);
+	/*
+	 * The SPI core generates a bogus input overrun error on some targets,
+	 * when a transition from run to reset state occurs and if the FIFO has
+	 * an odd number of entries. Hence we disable the INPUT_OVER_RUN_ERR_EN
+	 * bit.
+	 */
+	msm_spi_enable_error_flags(dd);
+
+	spi_ioc = readl_relaxed(dd->base + SPI_IO_CONTROL);
+	spi_ioc |= SPI_IO_C_NO_TRI_STATE;
+	writel_relaxed(spi_ioc, dd->base + SPI_IO_CONTROL);
+	/*
+	 * Ensure that the IO control is written to before returning.
+	 */
+	mb();
+	msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+}
+
+static void put_local_resources(struct msm_spi *dd)
+{
+
+	if (IS_ERR_OR_NULL(dd->clk) || IS_ERR_OR_NULL(dd->pclk)) {
+		dev_err(dd->dev,
+			"%s: error clk put\n",
+				__func__);
+		return;
+	}
+	msm_spi_disable_irqs(dd);
+	clk_disable_unprepare(dd->clk);
+	dd->clock_speed = 0;
+	clk_disable_unprepare(dd->pclk);
+
+	/* Free  the spi clk, miso, mosi, cs gpio */
+	if (dd->pdata && dd->pdata->gpio_release)
+		dd->pdata->gpio_release();
+
+	msm_spi_free_gpios(dd);
+}
+
+static int get_local_resources(struct msm_spi *dd)
+{
+	int ret = -EINVAL;
+
+	if (IS_ERR_OR_NULL(dd->clk) || IS_ERR_OR_NULL(dd->pclk)) {
+		dev_err(dd->dev,
+			"%s: error clk put\n",
+				__func__);
+		return ret;
+	}
+
+	/* Configure the spi clk, miso, mosi and cs gpio */
+	if (dd->pdata->gpio_config) {
+		ret = dd->pdata->gpio_config();
+		if (ret) {
+			dev_err(dd->dev,
+					"%s: error configuring GPIOs\n",
+					__func__);
+			return ret;
+		}
+	}
+
+	ret = msm_spi_request_gpios(dd);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(dd->clk);
+	if (ret)
+		goto clk0_err;
+	ret = clk_prepare_enable(dd->pclk);
+	if (ret)
+		goto clk1_err;
+	msm_spi_enable_irqs(dd);
+
+	return 0;
+
+clk1_err:
+	clk_disable_unprepare(dd->clk);
+clk0_err:
+	msm_spi_free_gpios(dd);
+	return ret;
+}
+
+/**
+ * msm_spi_transfer_one: To process one spi transfer at a time
+ * @master: spi master controller reference
+ * @msg: one multi-segment SPI transaction
+ * @return zero on success or negative error value
+ *
+ */
+static int msm_spi_transfer_one(struct spi_master *master,
+				struct spi_device *spi,
+				struct spi_transfer *xfer)
+{
+	struct msm_spi	*dd;
+	unsigned long        flags;
+	u32	status_error = 0;
+
+	dd = spi_master_get_devdata(master);
+
+	/* Check message parameters */
+	if (xfer->speed_hz > dd->pdata->max_clock_speed ||
+	    (xfer->bits_per_word &&
+	     (xfer->bits_per_word < 4 || xfer->bits_per_word > 32)) ||
+	    (xfer->tx_buf == NULL && xfer->rx_buf == NULL)) {
+		dev_err(dd->dev,
+			"Invalid transfer: %d Hz, %d bpw tx=%pK, rx=%pK\n",
+			xfer->speed_hz, xfer->bits_per_word,
+			xfer->tx_buf, xfer->rx_buf);
+		return -EINVAL;
+	}
+	dd->spi = spi;
+	dd->cur_transfer = xfer;
+
+	mutex_lock(&dd->core_lock);
+
+	spin_lock_irqsave(&dd->queue_lock, flags);
+	dd->transfer_pending = 1;
+	spin_unlock_irqrestore(&dd->queue_lock, flags);
+	/*
+	 * get local resources for each transfer to ensure we're in a good
+	 * state and not interfering with other EE's using this device
+	 */
+	if (dd->pdata->is_shared) {
+		if (get_local_resources(dd)) {
+			mutex_unlock(&dd->core_lock);
+			spi_finalize_current_message(master);
+			return -EINVAL;
+		}
+
+		reset_core(dd);
+		if (dd->use_dma) {
+			msm_spi_bam_pipe_connect(dd, &dd->bam.prod,
+					&dd->bam.prod.config);
+			msm_spi_bam_pipe_connect(dd, &dd->bam.cons,
+					&dd->bam.cons.config);
+		}
+	}
+
+	if (dd->suspended || !msm_spi_is_valid_state(dd)) {
+		dev_err(dd->dev, "%s: SPI operational state not valid\n",
+			__func__);
+		status_error = 1;
+	}
+
+
+	if (!status_error)
+		status_error =
+			msm_spi_process_transfer(dd);
+
+	spin_lock_irqsave(&dd->queue_lock, flags);
+	dd->transfer_pending = 0;
+	spin_unlock_irqrestore(&dd->queue_lock, flags);
+
+	/*
+	 * Put local resources prior to calling finalize to ensure the hw
+	 * is in a known state before notifying the calling thread (which is a
+	 * different context since we're running in the spi kthread here) to
+	 * prevent race conditions between us and any other EE's using this hw.
+	 */
+	if (dd->pdata->is_shared) {
+		if (dd->use_dma) {
+			msm_spi_bam_pipe_disconnect(dd, &dd->bam.prod);
+			msm_spi_bam_pipe_disconnect(dd, &dd->bam.cons);
+		}
+		put_local_resources(dd);
+	}
+	mutex_unlock(&dd->core_lock);
+	if (dd->suspended)
+		wake_up_interruptible(&dd->continue_suspend);
+	return status_error;
+}
+
+static int msm_spi_prepare_transfer_hardware(struct spi_master *master)
+{
+	struct msm_spi	*dd = spi_master_get_devdata(master);
+	int resume_state = 0;
+
+	resume_state = pm_runtime_get_sync(dd->dev);
+	if (resume_state < 0)
+		goto spi_finalize;
+
+	/*
+	 * Counter-part of system-suspend when runtime-pm is not enabled.
+	 * This way, resume can be left empty and device will be put in
+	 * active mode only if client requests anything on the bus
+	 */
+	if (!pm_runtime_enabled(dd->dev))
+		resume_state = msm_spi_pm_resume_runtime(dd->dev);
+	if (resume_state < 0)
+		goto spi_finalize;
+	if (dd->suspended) {
+		resume_state = -EBUSY;
+		goto spi_finalize;
+	}
+	return 0;
+
+spi_finalize:
+	spi_finalize_current_message(master);
+	return resume_state;
+}
+
+static int msm_spi_unprepare_transfer_hardware(struct spi_master *master)
+{
+	struct msm_spi	*dd = spi_master_get_devdata(master);
+
+	pm_runtime_mark_last_busy(dd->dev);
+	pm_runtime_put_autosuspend(dd->dev);
+	return 0;
+}
+
+static int msm_spi_setup(struct spi_device *spi)
+{
+	struct msm_spi	*dd;
+	int              rc = 0;
+	u32              spi_ioc;
+	u32              spi_config;
+	u32              mask;
+
+	if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
+		dev_err(&spi->dev, "%s: invalid bits_per_word %d\n",
+			__func__, spi->bits_per_word);
+		return -EINVAL;
+	}
+	if (spi->chip_select > SPI_NUM_CHIPSELECTS-1) {
+		dev_err(&spi->dev, "%s, chip select %d exceeds max value %d\n",
+			__func__, spi->chip_select, SPI_NUM_CHIPSELECTS - 1);
+		return -EINVAL;
+	}
+
+	dd = spi_master_get_devdata(spi->master);
+
+	rc = pm_runtime_get_sync(dd->dev);
+	if (rc < 0 && !dd->is_init_complete &&
+			pm_runtime_enabled(dd->dev)) {
+		pm_runtime_set_suspended(dd->dev);
+		pm_runtime_put_sync(dd->dev);
+		rc = 0;
+		goto err_setup_exit;
+	} else
+		rc = 0;
+
+	mutex_lock(&dd->core_lock);
+
+	/* Counter-part of system-suspend when runtime-pm is not enabled. */
+	if (!pm_runtime_enabled(dd->dev)) {
+		rc = msm_spi_pm_resume_runtime(dd->dev);
+		if (rc < 0 && !dd->is_init_complete) {
+			rc = 0;
+			mutex_unlock(&dd->core_lock);
+			goto err_setup_exit;
+		}
+	}
+
+	if (dd->suspended) {
+		rc = -EBUSY;
+		mutex_unlock(&dd->core_lock);
+		goto err_setup_exit;
+	}
+
+	if (dd->pdata->is_shared) {
+		rc = get_local_resources(dd);
+		if (rc)
+			goto no_resources;
+	}
+
+	spi_ioc = readl_relaxed(dd->base + SPI_IO_CONTROL);
+	mask = SPI_IO_C_CS_N_POLARITY_0 << spi->chip_select;
+	if (spi->mode & SPI_CS_HIGH)
+		spi_ioc |= mask;
+	else
+		spi_ioc &= ~mask;
+	spi_ioc = msm_spi_calc_spi_ioc_clk_polarity(spi_ioc, spi->mode);
+
+	writel_relaxed(spi_ioc, dd->base + SPI_IO_CONTROL);
+
+	spi_config = readl_relaxed(dd->base + SPI_CONFIG);
+	spi_config = msm_spi_calc_spi_config_loopback_and_input_first(
+							spi_config, spi->mode);
+	writel_relaxed(spi_config, dd->base + SPI_CONFIG);
+
+	/* Ensure previous write completed before disabling the clocks */
+	mb();
+	if (dd->pdata->is_shared)
+		put_local_resources(dd);
+	/* Counter-part of system-resume when runtime-pm is not enabled. */
+	if (!pm_runtime_enabled(dd->dev))
+		msm_spi_pm_suspend_runtime(dd->dev);
+
+no_resources:
+	mutex_unlock(&dd->core_lock);
+	pm_runtime_mark_last_busy(dd->dev);
+	pm_runtime_put_autosuspend(dd->dev);
+
+err_setup_exit:
+	return rc;
+}
+
+#ifdef CONFIG_DEBUG_FS
+
+
+static int debugfs_iomem_x32_set(void *data, u64 val)
+{
+	struct msm_spi_debugfs_data *reg = (struct msm_spi_debugfs_data *)data;
+	struct msm_spi *dd = reg->dd;
+	int ret;
+
+	ret = pm_runtime_get_sync(dd->dev);
+	if (ret < 0)
+		return ret;
+
+	writel_relaxed(val, (dd->base + reg->offset));
+	/* Ensure the previous write completed. */
+	mb();
+
+	pm_runtime_mark_last_busy(dd->dev);
+	pm_runtime_put_autosuspend(dd->dev);
+	return 0;
+}
+
+static int debugfs_iomem_x32_get(void *data, u64 *val)
+{
+	struct msm_spi_debugfs_data *reg = (struct msm_spi_debugfs_data *)data;
+	struct msm_spi *dd = reg->dd;
+	int ret;
+
+	ret = pm_runtime_get_sync(dd->dev);
+	if (ret < 0)
+		return ret;
+	*val = readl_relaxed(dd->base + reg->offset);
+	/* Ensure the previous read completed. */
+	mb();
+
+	pm_runtime_mark_last_busy(dd->dev);
+	pm_runtime_put_autosuspend(dd->dev);
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, debugfs_iomem_x32_get,
+			debugfs_iomem_x32_set, "0x%08llx\n");
+
+static void spi_debugfs_init(struct msm_spi *dd)
+{
+	char dir_name[20];
+
+	scnprintf(dir_name, sizeof(dir_name), "%s_dbg", dev_name(dd->dev));
+	dd->dent_spi = debugfs_create_dir(dir_name, NULL);
+	if (dd->dent_spi) {
+		int i;
+
+		for (i = 0; i < ARRAY_SIZE(debugfs_spi_regs); i++) {
+			dd->reg_data[i].offset = debugfs_spi_regs[i].offset;
+			dd->reg_data[i].dd = dd;
+			dd->debugfs_spi_regs[i] =
+			   debugfs_create_file(
+			       debugfs_spi_regs[i].name,
+			       debugfs_spi_regs[i].mode,
+			       dd->dent_spi, &dd->reg_data[i],
+			       &fops_iomem_x32);
+		}
+	}
+}
+
+static void spi_debugfs_exit(struct msm_spi *dd)
+{
+	if (dd->dent_spi) {
+		int i;
+
+		debugfs_remove_recursive(dd->dent_spi);
+		dd->dent_spi = NULL;
+		for (i = 0; i < ARRAY_SIZE(debugfs_spi_regs); i++)
+			dd->debugfs_spi_regs[i] = NULL;
+	}
+}
+#else
+static void spi_debugfs_init(struct msm_spi *dd) {}
+static void spi_debugfs_exit(struct msm_spi *dd) {}
+#endif
+
+/* ===Device attributes begin=== */
+static ssize_t show_stats(struct device *dev, struct device_attribute *attr,
+			  char *buf)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct msm_spi *dd =  spi_master_get_devdata(master);
+
+	return snprintf(buf, PAGE_SIZE,
+			"Device       %s\n"
+			"rx fifo_size = %d spi words\n"
+			"tx fifo_size = %d spi words\n"
+			"use_dma ?    %s\n"
+			"rx block size = %d bytes\n"
+			"tx block size = %d bytes\n"
+			"input burst size = %d bytes\n"
+			"output burst size = %d bytes\n"
+			"DMA configuration:\n"
+			"tx_ch=%d, rx_ch=%d, tx_crci= %d, rx_crci=%d\n"
+			"--statistics--\n"
+			"Rx isrs  = %d\n"
+			"Tx isrs  = %d\n"
+			"--debug--\n"
+			"NA yet\n",
+			dev_name(dev),
+			dd->input_fifo_size,
+			dd->output_fifo_size,
+			dd->use_dma ? "yes" : "no",
+			dd->input_block_size,
+			dd->output_block_size,
+			dd->input_burst_size,
+			dd->output_burst_size,
+			dd->tx_dma_chan,
+			dd->rx_dma_chan,
+			dd->tx_dma_crci,
+			dd->rx_dma_crci,
+			dd->stat_rx,
+			dd->stat_tx
+			);
+}
+
+/* Reset statistics on write */
+static ssize_t set_stats(struct device *dev, struct device_attribute *attr,
+			 const char *buf, size_t count)
+{
+	struct msm_spi *dd = dev_get_drvdata(dev);
+
+	dd->stat_rx = 0;
+	dd->stat_tx = 0;
+	return count;
+}
+
+static DEVICE_ATTR(stats, 0644, show_stats, set_stats);
+
+static struct attribute *dev_attrs[] = {
+	&dev_attr_stats.attr,
+	NULL,
+};
+
+static struct attribute_group dev_attr_grp = {
+	.attrs = dev_attrs,
+};
+/* ===Device attributes end=== */
+
+static void msm_spi_bam_pipe_teardown(struct msm_spi *dd,
+					enum msm_spi_pipe_direction pipe_dir)
+{
+	struct msm_spi_bam_pipe *pipe = (pipe_dir == SPI_BAM_CONSUMER_PIPE) ?
+					(&dd->bam.prod) : (&dd->bam.cons);
+	if (!pipe->teardown_required)
+		return;
+
+	msm_spi_bam_pipe_disconnect(dd, pipe);
+	dma_free_coherent(dd->dev, pipe->config.desc.size,
+		pipe->config.desc.base, pipe->config.desc.phys_base);
+	sps_free_endpoint(pipe->handle);
+	pipe->handle = NULL;
+	pipe->teardown_required = false;
+}
+
+static int msm_spi_bam_pipe_init(struct msm_spi *dd,
+					enum msm_spi_pipe_direction pipe_dir)
+{
+	int rc = 0;
+	struct sps_pipe *pipe_handle;
+	struct msm_spi_bam_pipe *pipe = (pipe_dir == SPI_BAM_CONSUMER_PIPE) ?
+					(&dd->bam.prod) : (&dd->bam.cons);
+	struct sps_connect *pipe_conf = &pipe->config;
+
+	pipe->name   = (pipe_dir == SPI_BAM_CONSUMER_PIPE) ? "cons" : "prod";
+	pipe->handle = NULL;
+	pipe_handle  = sps_alloc_endpoint();
+	if (!pipe_handle) {
+		dev_err(dd->dev, "%s: Failed to allocate BAM endpoint\n"
+								, __func__);
+		return -ENOMEM;
+	}
+
+	memset(pipe_conf, 0, sizeof(*pipe_conf));
+	rc = sps_get_config(pipe_handle, pipe_conf);
+	if (rc) {
+		dev_err(dd->dev, "%s: Failed to get BAM pipe config\n"
+			, __func__);
+		goto config_err;
+	}
+
+	if (pipe_dir == SPI_BAM_CONSUMER_PIPE) {
+		pipe_conf->source          = dd->bam.handle;
+		pipe_conf->destination     = SPS_DEV_HANDLE_MEM;
+		pipe_conf->mode            = SPS_MODE_SRC;
+		pipe_conf->src_pipe_index  =
+					dd->pdata->bam_producer_pipe_index;
+		pipe_conf->dest_pipe_index = 0;
+	} else {
+		pipe_conf->source          = SPS_DEV_HANDLE_MEM;
+		pipe_conf->destination     = dd->bam.handle;
+		pipe_conf->mode            = SPS_MODE_DEST;
+		pipe_conf->src_pipe_index  = 0;
+		pipe_conf->dest_pipe_index =
+					dd->pdata->bam_consumer_pipe_index;
+	}
+	pipe_conf->options = SPS_O_EOT | SPS_O_AUTO_ENABLE;
+	pipe_conf->desc.size = SPI_BAM_MAX_DESC_NUM * sizeof(struct sps_iovec);
+	pipe_conf->desc.base = dma_alloc_coherent(dd->dev,
+				pipe_conf->desc.size,
+				&pipe_conf->desc.phys_base,
+				GFP_KERNEL);
+	if (!pipe_conf->desc.base) {
+		dev_err(dd->dev, "%s: Failed allocate BAM pipe memory"
+			, __func__);
+		rc = -ENOMEM;
+		goto config_err;
+	}
+	/* zero descriptor FIFO for convenient debugging of first descs */
+	memset(pipe_conf->desc.base, 0x00, pipe_conf->desc.size);
+
+	pipe->handle = pipe_handle;
+
+	return 0;
+
+config_err:
+	sps_free_endpoint(pipe_handle);
+
+	return rc;
+}
+
+static void msm_spi_bam_teardown(struct msm_spi *dd)
+{
+	msm_spi_bam_pipe_teardown(dd, SPI_BAM_PRODUCER_PIPE);
+	msm_spi_bam_pipe_teardown(dd, SPI_BAM_CONSUMER_PIPE);
+
+	if (dd->bam.deregister_required) {
+		sps_deregister_bam_device(dd->bam.handle);
+		dd->bam.deregister_required = false;
+	}
+}
+
+static int msm_spi_bam_init(struct msm_spi *dd)
+{
+	struct sps_bam_props bam_props = {0};
+	uintptr_t bam_handle;
+	int rc = 0;
+
+	rc = sps_phy2h(dd->bam.phys_addr, &bam_handle);
+	if (rc || !bam_handle) {
+		bam_props.phys_addr = dd->bam.phys_addr;
+		bam_props.virt_addr = dd->bam.base;
+		bam_props.irq       = dd->bam.irq;
+		bam_props.manage    = SPS_BAM_MGR_DEVICE_REMOTE;
+		bam_props.summing_threshold = 0x10;
+
+		rc = sps_register_bam_device(&bam_props, &bam_handle);
+		if (rc) {
+			dev_err(dd->dev,
+				"%s: Failed to register BAM device",
+				__func__);
+			return rc;
+		}
+		dd->bam.deregister_required = true;
+	}
+
+	dd->bam.handle = bam_handle;
+
+	rc = msm_spi_bam_pipe_init(dd, SPI_BAM_PRODUCER_PIPE);
+	if (rc) {
+		dev_err(dd->dev,
+			"%s: Failed to init producer BAM-pipe",
+			__func__);
+		goto bam_init_error;
+	}
+
+	rc = msm_spi_bam_pipe_init(dd, SPI_BAM_CONSUMER_PIPE);
+	if (rc) {
+		dev_err(dd->dev,
+			"%s: Failed to init consumer BAM-pipe",
+			__func__);
+		goto bam_init_error;
+	}
+
+	return 0;
+
+bam_init_error:
+	msm_spi_bam_teardown(dd);
+	return rc;
+}
+
+enum msm_spi_dt_entry_status {
+	DT_REQ,  /* Required:  fail if missing */
+	DT_SGST, /* Suggested: warn if missing */
+	DT_OPT,  /* Optional:  don't warn if missing */
+};
+
+enum msm_spi_dt_entry_type {
+	DT_U32,
+	DT_GPIO,
+	DT_BOOL,
+};
+
+struct msm_spi_dt_to_pdata_map {
+	const char                  *dt_name;
+	void                        *ptr_data;
+	enum msm_spi_dt_entry_status status;
+	enum msm_spi_dt_entry_type   type;
+	int                          default_val;
+};
+
+static int msm_spi_dt_to_pdata_populate(struct platform_device *pdev,
+					struct msm_spi_platform_data *pdata,
+					struct msm_spi_dt_to_pdata_map  *itr)
+{
+	int  ret, err = 0;
+	struct device_node *node = pdev->dev.of_node;
+
+	for (; itr->dt_name; ++itr) {
+		switch (itr->type) {
+		case DT_GPIO:
+			ret = of_get_named_gpio(node, itr->dt_name, 0);
+			if (ret >= 0) {
+				*((int *) itr->ptr_data) = ret;
+				ret = 0;
+			}
+			break;
+		case DT_U32:
+			ret = of_property_read_u32(node, itr->dt_name,
+							 (u32 *) itr->ptr_data);
+			break;
+		case DT_BOOL:
+			*((bool *) itr->ptr_data) =
+				of_property_read_bool(node, itr->dt_name);
+			ret = 0;
+			break;
+		default:
+			dev_err(&pdev->dev, "%d is an unknown DT entry type\n",
+								itr->type);
+			ret = -EBADE;
+		}
+
+		dev_dbg(&pdev->dev, "DT entry ret:%d name:%s val:%d\n",
+				ret, itr->dt_name, *((int *)itr->ptr_data));
+
+		if (ret) {
+			*((int *)itr->ptr_data) = itr->default_val;
+
+			if (itr->status < DT_OPT) {
+				dev_err(&pdev->dev, "Missing '%s' DT entry\n",
+								itr->dt_name);
+
+				/* cont on err to dump all missing entries */
+				if (itr->status == DT_REQ && !err)
+					err = ret;
+			}
+		}
+	}
+
+	return err;
+}
+
+/**
+ * msm_spi_dt_to_pdata: create pdata and read gpio config from device tree
+ */
+static struct msm_spi_platform_data *msm_spi_dt_to_pdata(
+			struct platform_device *pdev, struct msm_spi *dd)
+{
+	struct msm_spi_platform_data *pdata;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return NULL;
+
+	if (pdata) {
+		struct msm_spi_dt_to_pdata_map map[] = {
+		{"spi-max-frequency",
+			&pdata->max_clock_speed,         DT_SGST, DT_U32,   0},
+		{"qcom,infinite-mode",
+			&pdata->infinite_mode,           DT_OPT,  DT_U32,   0},
+		{"qcom,master-id",
+			&pdata->master_id,               DT_SGST, DT_U32,   0},
+		{"qcom,bus-width",
+			&pdata->bus_width,               DT_OPT, DT_U32,   8},
+		{"qcom,ver-reg-exists",
+			&pdata->ver_reg_exists,          DT_OPT,  DT_BOOL,  0},
+		{"qcom,use-bam",
+			&pdata->use_bam,                 DT_OPT,  DT_BOOL,  0},
+		{"qcom,use-pinctrl",
+			&pdata->use_pinctrl,             DT_OPT,  DT_BOOL,  0},
+		{"qcom,bam-consumer-pipe-index",
+			&pdata->bam_consumer_pipe_index, DT_OPT,  DT_U32,   0},
+		{"qcom,bam-producer-pipe-index",
+			&pdata->bam_producer_pipe_index, DT_OPT,  DT_U32,   0},
+		{"qcom,gpio-clk",
+			&dd->spi_gpios[0],               DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-miso",
+			&dd->spi_gpios[1],               DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-mosi",
+			&dd->spi_gpios[2],               DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-cs0",
+			&dd->cs_gpios[0].gpio_num,       DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-cs1",
+			&dd->cs_gpios[1].gpio_num,       DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-cs2",
+			&dd->cs_gpios[2].gpio_num,       DT_OPT,  DT_GPIO, -1},
+		{"qcom,gpio-cs3",
+			&dd->cs_gpios[3].gpio_num,       DT_OPT,  DT_GPIO, -1},
+		{"qcom,rt-priority",
+			&pdata->rt_priority,		 DT_OPT,  DT_BOOL,  0},
+		{"qcom,shared",
+			&pdata->is_shared,		 DT_OPT,  DT_BOOL,  0},
+		{NULL,  NULL,                            0,       0,        0},
+		};
+
+		if (msm_spi_dt_to_pdata_populate(pdev, pdata, map)) {
+			devm_kfree(&pdev->dev, pdata);
+			return NULL;
+		}
+	}
+
+	if (pdata->use_bam) {
+		if (!pdata->bam_consumer_pipe_index) {
+			dev_warn(&pdev->dev,
+			"missing qcom,bam-consumer-pipe-index entry in device-tree\n");
+			pdata->use_bam = false;
+		}
+
+		if (!pdata->bam_producer_pipe_index) {
+			dev_warn(&pdev->dev,
+			"missing qcom,bam-producer-pipe-index entry in device-tree\n");
+			pdata->use_bam = false;
+		}
+	}
+	return pdata;
+}
+
+static int msm_spi_get_qup_hw_ver(struct device *dev, struct msm_spi *dd)
+{
+	u32 data = readl_relaxed(dd->base + QUP_HARDWARE_VER);
+
+	return (data >= QUP_HARDWARE_VER_2_1_1) ? SPI_QUP_VERSION_BFAM
+						: SPI_QUP_VERSION_NONE;
+}
+
+static int msm_spi_bam_get_resources(struct msm_spi *dd,
+	struct platform_device *pdev, struct spi_master *master)
+{
+	struct resource *resource;
+	size_t bam_mem_size;
+
+	resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						"spi_bam_physical");
+	if (!resource) {
+		dev_warn(&pdev->dev,
+			"%s: Missing spi_bam_physical entry in DT",
+			__func__);
+		return -ENXIO;
+	}
+
+	dd->bam.phys_addr = resource->start;
+	bam_mem_size = resource_size(resource);
+	dd->bam.base = devm_ioremap(&pdev->dev, dd->bam.phys_addr,
+					bam_mem_size);
+	if (!dd->bam.base) {
+		dev_warn(&pdev->dev,
+			"%s: Failed to ioremap(spi_bam_physical)",
+			__func__);
+		return -ENXIO;
+	}
+
+	dd->bam.irq = platform_get_irq_byname(pdev, "spi_bam_irq");
+	if (dd->bam.irq < 0) {
+		dev_warn(&pdev->dev, "%s: Missing spi_bam_irq entry in DT",
+			__func__);
+		return -EINVAL;
+	}
+
+	dd->dma_init = msm_spi_bam_init;
+	dd->dma_teardown = msm_spi_bam_teardown;
+	return 0;
+}
+
+static int init_resources(struct platform_device *pdev)
+{
+	struct spi_master *master = platform_get_drvdata(pdev);
+	struct msm_spi	  *dd;
+	int               rc = -ENXIO;
+	int               clk_enabled = 0;
+	int               pclk_enabled = 0;
+
+	dd = spi_master_get_devdata(master);
+
+	if (dd->pdata && dd->pdata->use_pinctrl) {
+		rc = msm_spi_pinctrl_init(dd);
+		if (rc) {
+			dev_err(&pdev->dev, "%s: pinctrl init failed\n",
+					 __func__);
+			return rc;
+		}
+	}
+
+	mutex_lock(&dd->core_lock);
+
+	dd->clk = clk_get(&pdev->dev, "core_clk");
+	if (IS_ERR(dd->clk)) {
+		dev_err(&pdev->dev, "%s: unable to get core_clk\n", __func__);
+		rc = PTR_ERR(dd->clk);
+		goto err_clk_get;
+	}
+
+	dd->pclk = clk_get(&pdev->dev, "iface_clk");
+	if (IS_ERR(dd->pclk)) {
+		dev_err(&pdev->dev, "%s: unable to get iface_clk\n", __func__);
+		rc = PTR_ERR(dd->pclk);
+		goto err_pclk_get;
+	}
+
+	if (dd->pdata && dd->pdata->max_clock_speed)
+		msm_spi_clock_set(dd, dd->pdata->max_clock_speed);
+
+	rc = clk_prepare_enable(dd->clk);
+	if (rc) {
+		dev_err(&pdev->dev, "%s: unable to enable core_clk\n",
+			__func__);
+		goto err_clk_enable;
+	}
+
+	clk_enabled = 1;
+	rc = clk_prepare_enable(dd->pclk);
+	if (rc) {
+		dev_err(&pdev->dev, "%s: unable to enable iface_clk\n",
+		__func__);
+		goto err_pclk_enable;
+	}
+
+	pclk_enabled = 1;
+
+	if (dd->pdata && dd->pdata->ver_reg_exists) {
+		enum msm_spi_qup_version ver =
+					msm_spi_get_qup_hw_ver(&pdev->dev, dd);
+		if (dd->qup_ver != ver)
+			dev_warn(&pdev->dev,
+			"%s: HW version different then initially assumed by probe",
+			__func__);
+	}
+
+	/* GSBI dose not exists on B-family MSM-chips */
+	if (dd->qup_ver != SPI_QUP_VERSION_BFAM) {
+		rc = msm_spi_configure_gsbi(dd, pdev);
+		if (rc)
+			goto err_config_gsbi;
+	}
+
+	msm_spi_calculate_fifo_size(dd);
+	if (dd->use_dma) {
+		rc = dd->dma_init(dd);
+		if (rc) {
+			dev_err(&pdev->dev,
+				"%s: failed to init DMA. Disabling DMA mode\n",
+				__func__);
+			dd->use_dma = 0;
+		}
+	}
+
+	msm_spi_register_init(dd);
+	/*
+	 * The SPI core generates a bogus input overrun error on some targets,
+	 * when a transition from run to reset state occurs and if the FIFO has
+	 * an odd number of entries. Hence we disable the INPUT_OVER_RUN_ERR_EN
+	 * bit.
+	 */
+	msm_spi_enable_error_flags(dd);
+
+	writel_relaxed(SPI_IO_C_NO_TRI_STATE, dd->base + SPI_IO_CONTROL);
+	rc = msm_spi_set_state(dd, SPI_OP_STATE_RESET);
+	if (rc)
+		goto err_spi_state;
+
+	clk_disable_unprepare(dd->clk);
+	clk_disable_unprepare(dd->pclk);
+	clk_enabled = 0;
+	pclk_enabled = 0;
+
+	dd->transfer_pending = 0;
+	dd->tx_mode = SPI_MODE_NONE;
+	dd->rx_mode = SPI_MODE_NONE;
+
+	rc = msm_spi_request_irq(dd, pdev, master);
+	if (rc)
+		goto err_irq;
+
+	msm_spi_disable_irqs(dd);
+
+	mutex_unlock(&dd->core_lock);
+	return 0;
+
+err_irq:
+err_spi_state:
+	if (dd->use_dma && dd->dma_teardown)
+		dd->dma_teardown(dd);
+err_config_gsbi:
+	if (pclk_enabled)
+		clk_disable_unprepare(dd->pclk);
+err_pclk_enable:
+	if (clk_enabled)
+		clk_disable_unprepare(dd->clk);
+err_clk_enable:
+	clk_put(dd->pclk);
+err_pclk_get:
+	clk_put(dd->clk);
+err_clk_get:
+	mutex_unlock(&dd->core_lock);
+	return rc;
+}
+
+static int msm_spi_probe(struct platform_device *pdev)
+{
+	struct spi_master      *master;
+	struct msm_spi	       *dd;
+	struct resource	       *resource;
+	int			i = 0;
+	int                     rc = -ENXIO;
+	struct msm_spi_platform_data *pdata;
+
+	master = spi_alloc_master(&pdev->dev, sizeof(struct msm_spi));
+	if (!master) {
+		rc = -ENOMEM;
+		dev_err(&pdev->dev, "master allocation failed\n");
+		goto err_probe_exit;
+	}
+
+	master->bus_num        = pdev->id;
+	master->mode_bits      = SPI_SUPPORTED_MODES;
+	master->num_chipselect = SPI_NUM_CHIPSELECTS;
+	master->set_cs	       = msm_spi_set_cs;
+	master->setup          = msm_spi_setup;
+	master->prepare_transfer_hardware = msm_spi_prepare_transfer_hardware;
+	master->transfer_one = msm_spi_transfer_one;
+	master->unprepare_transfer_hardware
+			= msm_spi_unprepare_transfer_hardware;
+
+	platform_set_drvdata(pdev, master);
+	dd = spi_master_get_devdata(master);
+
+	if (pdev->dev.of_node) {
+		dd->qup_ver = SPI_QUP_VERSION_BFAM;
+		master->dev.of_node = pdev->dev.of_node;
+		pdata = msm_spi_dt_to_pdata(pdev, dd);
+		if (!pdata) {
+			dev_err(&pdev->dev, "platform data allocation failed\n");
+			rc = -ENOMEM;
+			goto err_probe_exit;
+		}
+
+		rc = of_alias_get_id(pdev->dev.of_node, "spi");
+		if (rc < 0)
+			dev_warn(&pdev->dev,
+				"using default bus_num %d\n", pdev->id);
+		else
+			master->bus_num = pdev->id = rc;
+	} else {
+		pdata = pdev->dev.platform_data;
+		dd->qup_ver = SPI_QUP_VERSION_NONE;
+
+		for (i = 0; i < ARRAY_SIZE(spi_rsrcs); ++i) {
+			resource = platform_get_resource(pdev, IORESOURCE_IO,
+							i);
+			dd->spi_gpios[i] = resource ? resource->start : -1;
+		}
+
+		for (i = 0; i < ARRAY_SIZE(spi_cs_rsrcs); ++i) {
+			resource = platform_get_resource(pdev, IORESOURCE_IO,
+						i + ARRAY_SIZE(spi_rsrcs));
+			dd->cs_gpios[i].gpio_num = resource ?
+							resource->start : -1;
+		}
+	}
+
+	for (i = 0; i < ARRAY_SIZE(spi_cs_rsrcs); ++i)
+		dd->cs_gpios[i].valid = 0;
+
+	dd->pdata = pdata;
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!resource) {
+		rc = -ENXIO;
+		goto err_probe_res;
+	}
+
+	dd->mem_phys_addr = resource->start;
+	dd->mem_size = resource_size(resource);
+	dd->dev = &pdev->dev;
+
+	if (pdata) {
+		master->rt = pdata->rt_priority;
+		if (pdata->dma_config) {
+			rc = pdata->dma_config();
+			if (rc) {
+				dev_warn(&pdev->dev,
+					"%s: DM mode not supported\n",
+					__func__);
+				dd->use_dma = 0;
+				goto skip_dma_resources;
+			}
+		}
+		if (!dd->pdata->use_bam)
+			goto skip_dma_resources;
+
+		rc = msm_spi_bam_get_resources(dd, pdev, master);
+		if (rc) {
+			dev_warn(dd->dev,
+					"%s: Failed to get BAM resources",
+					__func__);
+			goto skip_dma_resources;
+		}
+		dd->use_dma = 1;
+	}
+
+	spi_dma_mask(&pdev->dev);
+skip_dma_resources:
+
+	spin_lock_init(&dd->queue_lock);
+	mutex_init(&dd->core_lock);
+	init_waitqueue_head(&dd->continue_suspend);
+
+	if (!devm_request_mem_region(&pdev->dev, dd->mem_phys_addr,
+					dd->mem_size, SPI_DRV_NAME)) {
+		rc = -ENXIO;
+		goto err_probe_reqmem;
+	}
+
+	dd->base = devm_ioremap(&pdev->dev, dd->mem_phys_addr, dd->mem_size);
+	if (!dd->base) {
+		rc = -ENOMEM;
+		goto err_probe_reqmem;
+	}
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev, MSEC_PER_SEC);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	dd->suspended = 1;
+	rc = spi_register_master(master);
+	if (rc)
+		goto err_probe_reg_master;
+
+	rc = sysfs_create_group(&(dd->dev->kobj), &dev_attr_grp);
+	if (rc) {
+		dev_err(&pdev->dev, "failed to create dev. attrs : %d\n", rc);
+		goto err_attrs;
+	}
+	spi_debugfs_init(dd);
+
+	return 0;
+
+err_attrs:
+	spi_unregister_master(master);
+err_probe_reg_master:
+	pm_runtime_disable(&pdev->dev);
+err_probe_reqmem:
+err_probe_res:
+	spi_master_put(master);
+err_probe_exit:
+	return rc;
+}
+
+static int msm_spi_pm_suspend_runtime(struct device *device)
+{
+	struct platform_device *pdev = to_platform_device(device);
+	struct spi_master *master = platform_get_drvdata(pdev);
+	struct msm_spi	  *dd;
+	unsigned long	   flags;
+
+	dev_dbg(device, "pm_runtime: suspending...\n");
+	if (!master)
+		goto suspend_exit;
+	dd = spi_master_get_devdata(master);
+	if (!dd)
+		goto suspend_exit;
+
+	if (dd->suspended)
+		return 0;
+
+	/*
+	 * Make sure nothing is added to the queue while we're
+	 * suspending
+	 */
+	spin_lock_irqsave(&dd->queue_lock, flags);
+	dd->suspended = 1;
+	spin_unlock_irqrestore(&dd->queue_lock, flags);
+
+	/* Wait for transactions to end, or time out */
+	wait_event_interruptible(dd->continue_suspend,
+		!dd->transfer_pending);
+
+	mutex_lock(&dd->core_lock);
+	if (dd->pdata && !dd->pdata->is_shared && dd->use_dma) {
+		msm_spi_bam_pipe_disconnect(dd, &dd->bam.prod);
+		msm_spi_bam_pipe_disconnect(dd, &dd->bam.cons);
+	}
+	if (dd->pdata && !dd->pdata->is_shared)
+		put_local_resources(dd);
+
+	if (dd->pdata)
+		msm_spi_clk_path_vote(dd, 0);
+	mutex_unlock(&dd->core_lock);
+
+suspend_exit:
+	return 0;
+}
+
+static int msm_spi_pm_resume_runtime(struct device *device)
+{
+	struct platform_device *pdev = to_platform_device(device);
+	struct spi_master *master = platform_get_drvdata(pdev);
+	struct msm_spi	  *dd;
+	int               ret = 0;
+
+	dev_dbg(device, "pm_runtime: resuming...\n");
+	if (!master)
+		goto resume_exit;
+	dd = spi_master_get_devdata(master);
+	if (!dd)
+		goto resume_exit;
+
+	if (!dd->suspended)
+		return 0;
+	if (!dd->is_init_complete) {
+		ret = init_resources(pdev);
+		if (ret != 0)
+			return ret;
+
+		dd->is_init_complete = true;
+	}
+	msm_spi_clk_path_init(dd);
+	msm_spi_clk_path_vote(dd, dd->pdata->max_clock_speed);
+
+	if (!dd->pdata->is_shared) {
+		ret = get_local_resources(dd);
+		if (ret)
+			return ret;
+	}
+	if (!dd->pdata->is_shared && dd->use_dma) {
+		msm_spi_bam_pipe_connect(dd, &dd->bam.prod,
+				&dd->bam.prod.config);
+		msm_spi_bam_pipe_connect(dd, &dd->bam.cons,
+				&dd->bam.cons.config);
+	}
+	dd->suspended = 0;
+
+resume_exit:
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int msm_spi_suspend(struct device *device)
+{
+	if (!pm_runtime_enabled(device) || !pm_runtime_suspended(device)) {
+		struct platform_device *pdev = to_platform_device(device);
+		struct spi_master *master = platform_get_drvdata(pdev);
+		struct msm_spi   *dd;
+
+		dev_dbg(device, "system suspend");
+		if (!master)
+			goto suspend_exit;
+		dd = spi_master_get_devdata(master);
+		if (!dd)
+			goto suspend_exit;
+		msm_spi_pm_suspend_runtime(device);
+
+		/*
+		 * set the device's runtime PM status to 'suspended'
+		 */
+		pm_runtime_disable(device);
+		pm_runtime_set_suspended(device);
+		pm_runtime_enable(device);
+	}
+suspend_exit:
+	return 0;
+}
+
+static int msm_spi_resume(struct device *device)
+{
+	/*
+	 * Rely on runtime-PM to call resume in case it is enabled
+	 * Even if it's not enabled, rely on 1st client transaction to do
+	 * clock ON and gpio configuration
+	 */
+	dev_dbg(device, "system resume");
+	return 0;
+}
+#else
+#define msm_spi_suspend NULL
+#define msm_spi_resume NULL
+#endif
+
+
+static int msm_spi_remove(struct platform_device *pdev)
+{
+	struct spi_master *master = platform_get_drvdata(pdev);
+	struct msm_spi    *dd = spi_master_get_devdata(master);
+
+	spi_debugfs_exit(dd);
+	sysfs_remove_group(&pdev->dev.kobj, &dev_attr_grp);
+
+	if (dd->dma_teardown)
+		dd->dma_teardown(dd);
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	clk_put(dd->clk);
+	clk_put(dd->pclk);
+	msm_spi_clk_path_teardown(dd);
+	platform_set_drvdata(pdev, NULL);
+	spi_unregister_master(master);
+	spi_master_put(master);
+
+	return 0;
+}
+
+static const struct of_device_id msm_spi_dt_match[] = {
+	{
+		.compatible = "qcom,spi-qup-v2",
+	},
+	{}
+};
+
+static const struct dev_pm_ops msm_spi_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(msm_spi_suspend, msm_spi_resume)
+	SET_RUNTIME_PM_OPS(msm_spi_pm_suspend_runtime,
+			msm_spi_pm_resume_runtime, NULL)
+};
+
+static struct platform_driver msm_spi_driver = {
+	.driver		= {
+		.name	= SPI_DRV_NAME,
+		.owner	= THIS_MODULE,
+		.pm		= &msm_spi_dev_pm_ops,
+		.of_match_table = msm_spi_dt_match,
+	},
+	.probe		= msm_spi_probe,
+	.remove		= msm_spi_remove,
+};
+
+module_platform_driver(msm_spi_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:"SPI_DRV_NAME);
diff --git a/drivers/spi/spi_qsd.h b/drivers/spi/spi_qsd.h
new file mode 100644
index 0000000..b18b55e
--- /dev/null
+++ b/drivers/spi/spi_qsd.h
@@ -0,0 +1,557 @@
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 _SPI_QSD_H
+#define _SPI_QSD_H
+
+#include <linux/pinctrl/consumer.h>
+#define SPI_DRV_NAME                  "spi_qsd"
+
+#if IS_ENABLED(CONFIG_SPI_QSD) || IS_ENABLED(CONFIG_SPI_QSD_MODULE)
+
+#define QSD_REG(x) (x)
+#define QUP_REG(x)
+
+#define SPI_FIFO_WORD_CNT             0x0048
+
+#else
+
+#define QSD_REG(x)
+#define QUP_REG(x) (x)
+
+#define QUP_CONFIG                    0x0000 /* N & NO_INPUT/NO_OUTPUT bits */
+#define QUP_ERROR_FLAGS_EN            0x030C
+#define QUP_ERR_MASK                  0x3
+#define SPI_OUTPUT_FIFO_WORD_CNT      0x010C
+#define SPI_INPUT_FIFO_WORD_CNT       0x0214
+#define QUP_MX_WRITE_COUNT            0x0150
+#define QUP_MX_WRITE_CNT_CURRENT      0x0154
+
+#define QUP_CONFIG_SPI_MODE           0x0100
+#endif
+
+#define GSBI_CTRL_REG                 0x0
+#define GSBI_SPI_CONFIG               0x30
+/* B-family only registers */
+#define QUP_HARDWARE_VER              0x0030
+#define QUP_HARDWARE_VER_2_1_1        0X20010001
+#define QUP_OPERATIONAL_MASK          0x0028
+#define QUP_OP_MASK_OUTPUT_SERVICE_FLAG 0x100
+#define QUP_OP_MASK_INPUT_SERVICE_FLAG  0x200
+
+#define QUP_ERROR_FLAGS               0x0308
+
+#define SPI_CONFIG                    (QSD_REG(0x0000) QUP_REG(0x0300))
+#define SPI_IO_CONTROL                (QSD_REG(0x0004) QUP_REG(0x0304))
+#define SPI_IO_MODES                  (QSD_REG(0x0008) QUP_REG(0x0008))
+#define SPI_SW_RESET                  (QSD_REG(0x000C) QUP_REG(0x000C))
+#define SPI_TIME_OUT_CURRENT          (QSD_REG(0x0014) QUP_REG(0x0014))
+#define SPI_MX_OUTPUT_COUNT           (QSD_REG(0x0018) QUP_REG(0x0100))
+#define SPI_MX_OUTPUT_CNT_CURRENT     (QSD_REG(0x001C) QUP_REG(0x0104))
+#define SPI_MX_INPUT_COUNT            (QSD_REG(0x0020) QUP_REG(0x0200))
+#define SPI_MX_INPUT_CNT_CURRENT      (QSD_REG(0x0024) QUP_REG(0x0204))
+#define SPI_MX_READ_COUNT             (QSD_REG(0x0028) QUP_REG(0x0208))
+#define SPI_MX_READ_CNT_CURRENT       (QSD_REG(0x002C) QUP_REG(0x020C))
+#define SPI_OPERATIONAL               (QSD_REG(0x0030) QUP_REG(0x0018))
+#define SPI_ERROR_FLAGS               (QSD_REG(0x0034) QUP_REG(0x001C))
+#define SPI_ERROR_FLAGS_EN            (QSD_REG(0x0038) QUP_REG(0x0020))
+#define SPI_DEASSERT_WAIT             (QSD_REG(0x003C) QUP_REG(0x0310))
+#define SPI_OUTPUT_DEBUG              (QSD_REG(0x0040) QUP_REG(0x0108))
+#define SPI_INPUT_DEBUG               (QSD_REG(0x0044) QUP_REG(0x0210))
+#define SPI_TEST_CTRL                 (QSD_REG(0x004C) QUP_REG(0x0024))
+#define SPI_OUTPUT_FIFO               (QSD_REG(0x0100) QUP_REG(0x0110))
+#define SPI_INPUT_FIFO                (QSD_REG(0x0200) QUP_REG(0x0218))
+#define SPI_STATE                     (QSD_REG(SPI_OPERATIONAL) QUP_REG(0x0004))
+
+/* QUP_CONFIG fields */
+#define SPI_CFG_N                     0x0000001F
+#define SPI_NO_INPUT                  0x00000080
+#define SPI_NO_OUTPUT                 0x00000040
+#define SPI_EN_EXT_OUT_FLAG           0x00010000
+
+/* SPI_CONFIG fields */
+#define SPI_CFG_LOOPBACK              0x00000100
+#define SPI_CFG_INPUT_FIRST           0x00000200
+#define SPI_CFG_HS_MODE               0x00000400
+
+/* SPI_IO_CONTROL fields */
+#define SPI_IO_C_FORCE_CS             0x00000800
+#define SPI_IO_C_CLK_IDLE_HIGH        0x00000400
+#define SPI_IO_C_MX_CS_MODE           0x00000100
+#define SPI_IO_C_CS_N_POLARITY        0x000000F0
+#define SPI_IO_C_CS_N_POLARITY_0      0x00000010
+#define SPI_IO_C_CS_SELECT            0x0000000C
+#define SPI_IO_C_TRISTATE_CS          0x00000002
+#define SPI_IO_C_NO_TRI_STATE         0x00000001
+
+/* SPI_IO_MODES fields */
+#define SPI_IO_M_OUTPUT_BIT_SHIFT_EN  (QSD_REG(0x00004000) QUP_REG(0x00010000))
+#define SPI_IO_M_PACK_EN              (QSD_REG(0x00002000) QUP_REG(0x00008000))
+#define SPI_IO_M_UNPACK_EN            (QSD_REG(0x00001000) QUP_REG(0x00004000))
+#define SPI_IO_M_INPUT_MODE           (QSD_REG(0x00000C00) QUP_REG(0x00003000))
+#define SPI_IO_M_OUTPUT_MODE          (QSD_REG(0x00000300) QUP_REG(0x00000C00))
+#define SPI_IO_M_INPUT_FIFO_SIZE      (QSD_REG(0x000000C0) QUP_REG(0x00000380))
+#define SPI_IO_M_INPUT_BLOCK_SIZE     (QSD_REG(0x00000030) QUP_REG(0x00000060))
+#define SPI_IO_M_OUTPUT_FIFO_SIZE     (QSD_REG(0x0000000C) QUP_REG(0x0000001C))
+#define SPI_IO_M_OUTPUT_BLOCK_SIZE    (QSD_REG(0x00000003) QUP_REG(0x00000003))
+
+#define INPUT_BLOCK_SZ_SHIFT          (QSD_REG(4)          QUP_REG(5))
+#define INPUT_FIFO_SZ_SHIFT           (QSD_REG(6)          QUP_REG(7))
+#define OUTPUT_BLOCK_SZ_SHIFT         (QSD_REG(0)          QUP_REG(0))
+#define OUTPUT_FIFO_SZ_SHIFT          (QSD_REG(2)          QUP_REG(2))
+#define OUTPUT_MODE_SHIFT             (QSD_REG(8)          QUP_REG(10))
+#define INPUT_MODE_SHIFT              (QSD_REG(10)         QUP_REG(12))
+
+/* SPI_OPERATIONAL fields */
+#define SPI_OP_IN_BLK_RD_REQ_FLAG     0x00002000
+#define SPI_OP_OUT_BLK_WR_REQ_FLAG    0x00001000
+#define SPI_OP_MAX_INPUT_DONE_FLAG    0x00000800
+#define SPI_OP_MAX_OUTPUT_DONE_FLAG   0x00000400
+#define SPI_OP_INPUT_SERVICE_FLAG     0x00000200
+#define SPI_OP_OUTPUT_SERVICE_FLAG    0x00000100
+#define SPI_OP_INPUT_FIFO_FULL        0x00000080
+#define SPI_OP_OUTPUT_FIFO_FULL       0x00000040
+#define SPI_OP_IP_FIFO_NOT_EMPTY      0x00000020
+#define SPI_OP_OP_FIFO_NOT_EMPTY      0x00000010
+#define SPI_OP_STATE_VALID            0x00000004
+#define SPI_OP_STATE                  0x00000003
+
+#define SPI_OP_STATE_CLEAR_BITS       0x2
+
+#define SPI_PINCTRL_STATE_DEFAULT "spi_default"
+#define SPI_PINCTRL_STATE_SLEEP "spi_sleep"
+
+enum msm_spi_state {
+	SPI_OP_STATE_RESET = 0x00000000,
+	SPI_OP_STATE_RUN   = 0x00000001,
+	SPI_OP_STATE_PAUSE = 0x00000003,
+};
+
+/* SPI_ERROR_FLAGS fields */
+#define SPI_ERR_OUTPUT_OVER_RUN_ERR   0x00000020
+#define SPI_ERR_INPUT_UNDER_RUN_ERR   0x00000010
+#define SPI_ERR_OUTPUT_UNDER_RUN_ERR  0x00000008
+#define SPI_ERR_INPUT_OVER_RUN_ERR    0x00000004
+#define SPI_ERR_CLK_OVER_RUN_ERR      0x00000002
+#define SPI_ERR_CLK_UNDER_RUN_ERR     0x00000001
+
+/* We don't allow transactions larger than 4K-64 or 64K-64 due to
+ * mx_input/output_cnt register size
+ */
+#define SPI_MAX_TRANSFERS             (QSD_REG(0xFC0) QUP_REG(0xFC0))
+#define SPI_MAX_LEN                   (SPI_MAX_TRANSFERS * dd->bytes_per_word)
+
+#define SPI_NUM_CHIPSELECTS           4
+#define SPI_SUPPORTED_MODES  (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP)
+
+/* high speed mode is when bus rate is greater then 26MHz */
+#define SPI_HS_MIN_RATE               (26000000)
+
+#define SPI_DELAY_THRESHOLD           1
+/* Default timeout is 10 milliseconds */
+#define SPI_DEFAULT_TIMEOUT           10
+/* 250 microseconds */
+#define SPI_TRYLOCK_DELAY             250
+
+/* Data Mover burst size */
+#define DM_BURST_SIZE                 16
+/* Data Mover commands should be aligned to 64 bit(8 bytes) */
+#define DM_BYTE_ALIGN                 8
+
+#if defined(CONFIG_ARM64) || defined(CONFIG_LPAE)
+#define spi_dma_mask(dev)   (dma_set_mask((dev), DMA_BIT_MASK(36)))
+#else
+#define spi_dma_mask(dev)   (dma_set_mask((dev), DMA_BIT_MASK(32)))
+#endif
+
+
+enum msm_spi_qup_version {
+	SPI_QUP_VERSION_NONE    = 0x0,
+	SPI_QUP_VERSION_BFAM    = 0x2,
+};
+
+enum msm_spi_pipe_direction {
+	SPI_BAM_CONSUMER_PIPE   = 0x0,
+	SPI_BAM_PRODUCER_PIPE   = 0x1,
+};
+
+#define SPI_BAM_MAX_DESC_NUM      32
+#define SPI_MAX_TRFR_BTWN_RESETS  ((64 * 1024) - 16)  /* 64KB - 16byte */
+
+enum msm_spi_clk_path_vec_idx {
+	MSM_SPI_CLK_PATH_SUSPEND_VEC = 0,
+	MSM_SPI_CLK_PATH_RESUME_VEC  = 1,
+};
+#define MSM_SPI_CLK_PATH_AVRG_BW(dd) (76800000)
+#define MSM_SPI_CLK_PATH_BRST_BW(dd) (76800000)
+
+static char const * const spi_rsrcs[] = {
+	"spi_clk",
+	"spi_miso",
+	"spi_mosi"
+};
+
+static char const * const spi_cs_rsrcs[] = {
+	"spi_cs",
+	"spi_cs1",
+	"spi_cs2",
+	"spi_cs3",
+};
+
+enum msm_spi_mode {
+	SPI_FIFO_MODE  = 0x0,  /* 00 */
+	SPI_BLOCK_MODE = 0x1,  /* 01 */
+	SPI_BAM_MODE   = 0x3,  /* 11 */
+	SPI_MODE_NONE  = 0xFF, /* invalid value */
+};
+
+/* Structure for SPI CS GPIOs */
+struct spi_cs_gpio {
+	int  gpio_num;
+	bool valid;
+};
+
+#ifdef CONFIG_DEBUG_FS
+struct msm_spi_debugfs_data {
+	int offset;
+	struct msm_spi *dd;
+};
+/* Used to create debugfs entries */
+static struct msm_spi_regs{
+	const char *name;
+	mode_t mode;
+	int offset;
+} debugfs_spi_regs[] = {
+	{"config",               0644,  SPI_CONFIG },
+	{"io_control",           0644,  SPI_IO_CONTROL },
+	{"io_modes",             0644,  SPI_IO_MODES },
+	{"sw_reset",             0200,  SPI_SW_RESET },
+	{"time_out_current",     0444,  SPI_TIME_OUT_CURRENT },
+	{"mx_output_count",      0644,  SPI_MX_OUTPUT_COUNT },
+	{"mx_output_cnt_current", 0444, SPI_MX_OUTPUT_CNT_CURRENT },
+	{"mx_input_count",       0644,  SPI_MX_INPUT_COUNT },
+	{"mx_input_cnt_current", 0444,  SPI_MX_INPUT_CNT_CURRENT },
+	{"mx_read_count",        0644,  SPI_MX_READ_COUNT },
+	{"mx_read_cnt_current",  0444,  SPI_MX_READ_CNT_CURRENT },
+	{"operational",          0644,  SPI_OPERATIONAL },
+	{"error_flags",          0644,  SPI_ERROR_FLAGS },
+	{"error_flags_en",       0644,  SPI_ERROR_FLAGS_EN },
+	{"deassert_wait",        0644,  SPI_DEASSERT_WAIT },
+	{"output_debug",         0444,  SPI_OUTPUT_DEBUG },
+	{"input_debug",          0444,  SPI_INPUT_DEBUG },
+	{"test_ctrl",            0644,  SPI_TEST_CTRL },
+	{"output_fifo",          0200,  SPI_OUTPUT_FIFO },
+	{"input_fifo",           0400,  SPI_INPUT_FIFO },
+	{"spi_state",            0644,  SPI_STATE },
+#if IS_ENABLED(CONFIG_SPI_QSD) || IS_ENABLED(CONFIG_SPI_QSD_MODULE)
+	{"fifo_word_cnt",        0444,  SPI_FIFO_WORD_CNT},
+#else
+	{"qup_config",           0644,  QUP_CONFIG},
+	{"qup_error_flags",      0644,  QUP_ERROR_FLAGS},
+	{"qup_error_flags_en",   0644,  QUP_ERROR_FLAGS_EN},
+	{"mx_write_cnt",         0644,  QUP_MX_WRITE_COUNT},
+	{"mx_write_cnt_current", 0444,  QUP_MX_WRITE_CNT_CURRENT},
+	{"output_fifo_word_cnt", 0444,  SPI_OUTPUT_FIFO_WORD_CNT},
+	{"input_fifo_word_cnt",  0444,  SPI_INPUT_FIFO_WORD_CNT},
+#endif
+};
+#endif
+
+struct msm_spi_bam_pipe {
+	const char              *name;
+	struct sps_pipe         *handle;
+	struct sps_connect       config;
+	bool                     teardown_required;
+};
+
+struct msm_spi_bam {
+	void __iomem            *base;
+	phys_addr_t              phys_addr;
+	uintptr_t                handle;
+	int                      irq;
+	struct msm_spi_bam_pipe  prod;
+	struct msm_spi_bam_pipe  cons;
+	bool                     deregister_required;
+	u32			 curr_rx_bytes_recvd;
+	u32			 curr_tx_bytes_sent;
+	u32			 bam_rx_len;
+	u32			 bam_tx_len;
+};
+
+struct msm_spi {
+	u8                      *read_buf;
+	const u8                *write_buf;
+	void __iomem            *base;
+	struct device           *dev;
+	spinlock_t               queue_lock;
+	struct mutex             core_lock;
+	struct spi_device       *spi;
+	struct spi_transfer     *cur_transfer;
+	struct completion        tx_transfer_complete;
+	struct completion        rx_transfer_complete;
+	struct clk              *clk;    /* core clock */
+	struct clk              *pclk;   /* interface clock */
+	struct msm_bus_client_handle *bus_cl_hdl;
+	unsigned long            mem_phys_addr;
+	size_t                   mem_size;
+	int                      input_fifo_size;
+	int                      output_fifo_size;
+	u32                      rx_bytes_remaining;
+	u32                      tx_bytes_remaining;
+	u32                      clock_speed;
+	int                      irq_in;
+	int                      read_xfr_cnt;
+	int                      write_xfr_cnt;
+	int                      write_len;
+	int                      read_len;
+#if IS_ENABLED(CONFIG_SPI_QSD) || IS_ENABLED(CONFIG_SPI_QSD_MODULE)
+	int                      irq_out;
+	int                      irq_err;
+#endif
+	int                      bytes_per_word;
+	bool                     suspended;
+	bool                     transfer_pending;
+	wait_queue_head_t        continue_suspend;
+	/* DMA data */
+	enum msm_spi_mode        tx_mode;
+	enum msm_spi_mode        rx_mode;
+	bool                     use_dma;
+	int                      tx_dma_chan;
+	int                      tx_dma_crci;
+	int                      rx_dma_chan;
+	int                      rx_dma_crci;
+	int                      (*dma_init)(struct msm_spi *dd);
+	void                     (*dma_teardown)(struct msm_spi *dd);
+	struct msm_spi_bam       bam;
+	int                      input_block_size;
+	int                      output_block_size;
+	int                      input_burst_size;
+	int                      output_burst_size;
+	atomic_t                 rx_irq_called;
+	atomic_t                 tx_irq_called;
+	/* Used to pad messages unaligned to block size */
+	u8                       *tx_padding;
+	dma_addr_t               tx_padding_dma;
+	u8                       *rx_padding;
+	dma_addr_t               rx_padding_dma;
+	u32                      tx_unaligned_len;
+	u32                      rx_unaligned_len;
+	/* DMA statistics */
+	int                      stat_rx;
+	int                      stat_tx;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *dent_spi;
+	struct dentry *debugfs_spi_regs[ARRAY_SIZE(debugfs_spi_regs)];
+	struct msm_spi_debugfs_data reg_data[ARRAY_SIZE(debugfs_spi_regs)];
+#endif
+	struct msm_spi_platform_data *pdata; /* Platform data */
+	/* When set indicates multiple transfers in a single message */
+	bool                     rx_done;
+	bool                     tx_done;
+	u32                      cur_msg_len;
+	/* Used in FIFO mode to keep track of the transfer being processed */
+	struct spi_transfer     *cur_tx_transfer;
+	struct spi_transfer     *cur_rx_transfer;
+	/* Temporary buffer used for WR-WR or WR-RD transfers */
+	u8                      *temp_buf;
+	/* GPIO pin numbers for SPI clk, miso and mosi */
+	int                      spi_gpios[ARRAY_SIZE(spi_rsrcs)];
+	/* SPI CS GPIOs for each slave */
+	struct spi_cs_gpio       cs_gpios[ARRAY_SIZE(spi_cs_rsrcs)];
+	enum msm_spi_qup_version qup_ver;
+	int			 max_trfr_len;
+	u16			 xfrs_delay_usec;
+	struct pinctrl		*pinctrl;
+	struct pinctrl_state	*pins_active;
+	struct pinctrl_state	*pins_sleep;
+	bool			is_init_complete;
+	bool			pack_words;
+};
+
+/* Forward declaration */
+static irqreturn_t msm_spi_input_irq(int irq, void *dev_id);
+static irqreturn_t msm_spi_output_irq(int irq, void *dev_id);
+static irqreturn_t msm_spi_error_irq(int irq, void *dev_id);
+static inline int msm_spi_set_state(struct msm_spi *dd,
+				    enum msm_spi_state state);
+static void msm_spi_write_word_to_fifo(struct msm_spi *dd);
+static inline void msm_spi_write_rmn_to_fifo(struct msm_spi *dd);
+static irqreturn_t msm_spi_qup_irq(int irq, void *dev_id);
+
+#if IS_ENABLED(CONFIG_SPI_QSD) || IS_ENABLED(CONFIG_SPI_QSD_MODULE)
+static inline void msm_spi_disable_irqs(struct msm_spi *dd)
+{
+	disable_irq(dd->irq_in);
+	disable_irq(dd->irq_out);
+	disable_irq(dd->irq_err);
+}
+
+static inline void msm_spi_enable_irqs(struct msm_spi *dd)
+{
+	enable_irq(dd->irq_in);
+	enable_irq(dd->irq_out);
+	enable_irq(dd->irq_err);
+}
+
+static inline int msm_spi_request_irq(struct msm_spi *dd,
+				struct platform_device *pdev,
+				struct spi_master *master)
+{
+	int rc;
+
+	dd->irq_in  = platform_get_irq(pdev, 0);
+	dd->irq_out = platform_get_irq(pdev, 1);
+	dd->irq_err = platform_get_irq(pdev, 2);
+	if ((dd->irq_in < 0) || (dd->irq_out < 0) || (dd->irq_err < 0))
+		return -EINVAL;
+
+	rc = devm_request_irq(dd->dev, dd->irq_in, msm_spi_input_irq,
+		IRQF_TRIGGER_RISING, pdev->name, dd);
+	if (rc)
+		goto error_irq;
+
+	rc = devm_request_irq(dd->dev, dd->irq_out, msm_spi_output_irq,
+		IRQF_TRIGGER_RISING, pdev->name, dd);
+	if (rc)
+		goto error_irq;
+
+	rc = devm_request_irq(dd->dev, dd->irq_err, msm_spi_error_irq,
+		IRQF_TRIGGER_RISING, pdev->name, master);
+	if (rc)
+		goto error_irq;
+
+error_irq:
+	return rc;
+}
+
+static inline void msm_spi_get_clk_err(struct msm_spi *dd, u32 *spi_err) {}
+static inline void msm_spi_ack_clk_err(struct msm_spi *dd) {}
+static inline void msm_spi_set_qup_config(struct msm_spi *dd, int bpw) {}
+
+static inline int  msm_spi_prepare_for_write(struct msm_spi *dd) { return 0; }
+static inline void msm_spi_start_write(struct msm_spi *dd, u32 read_count)
+{
+	msm_spi_write_word_to_fifo(dd);
+}
+static inline void msm_spi_set_write_count(struct msm_spi *dd, int val) {}
+
+static inline void msm_spi_complete(struct msm_spi *dd)
+{
+	complete(&dd->transfer_complete);
+}
+
+static inline void msm_spi_enable_error_flags(struct msm_spi *dd)
+{
+	writel_relaxed(0x0000007B, dd->base + SPI_ERROR_FLAGS_EN);
+}
+
+static inline void msm_spi_clear_error_flags(struct msm_spi *dd)
+{
+	writel_relaxed(0x0000007F, dd->base + SPI_ERROR_FLAGS);
+}
+
+#else
+/* In QUP the same interrupt line is used for input, output and error*/
+static inline int msm_spi_request_irq(struct msm_spi *dd,
+				struct platform_device *pdev,
+				struct spi_master *master)
+{
+	dd->irq_in  = platform_get_irq(pdev, 0);
+	if (dd->irq_in < 0)
+		return -EINVAL;
+
+	return devm_request_irq(dd->dev, dd->irq_in, msm_spi_qup_irq,
+		IRQF_TRIGGER_HIGH, pdev->name, dd);
+}
+
+static inline void msm_spi_disable_irqs(struct msm_spi *dd)
+{
+	disable_irq(dd->irq_in);
+}
+
+static inline void msm_spi_enable_irqs(struct msm_spi *dd)
+{
+	enable_irq(dd->irq_in);
+}
+
+static inline void msm_spi_get_clk_err(struct msm_spi *dd, u32 *spi_err)
+{
+	*spi_err = readl_relaxed(dd->base + QUP_ERROR_FLAGS);
+}
+
+static inline void msm_spi_ack_clk_err(struct msm_spi *dd)
+{
+	writel_relaxed(QUP_ERR_MASK, dd->base + QUP_ERROR_FLAGS);
+}
+
+static inline void
+msm_spi_set_bpw_and_no_io_flags(struct msm_spi *dd, u32 *config, int n);
+
+/**
+ * msm_spi_set_qup_config: set QUP_CONFIG to no_input, no_output, and N bits
+ */
+static inline void msm_spi_set_qup_config(struct msm_spi *dd, int bpw)
+{
+	u32 qup_config = readl_relaxed(dd->base + QUP_CONFIG);
+
+	msm_spi_set_bpw_and_no_io_flags(dd, &qup_config, bpw-1);
+	writel_relaxed(qup_config | QUP_CONFIG_SPI_MODE, dd->base + QUP_CONFIG);
+}
+
+static inline int msm_spi_prepare_for_write(struct msm_spi *dd)
+{
+	if (msm_spi_set_state(dd, SPI_OP_STATE_RUN))
+		return -EINVAL;
+	if (msm_spi_set_state(dd, SPI_OP_STATE_PAUSE))
+		return -EINVAL;
+	return 0;
+}
+
+static inline void msm_spi_start_write(struct msm_spi *dd, u32 read_count)
+{
+	msm_spi_write_rmn_to_fifo(dd);
+}
+
+static inline void msm_spi_set_write_count(struct msm_spi *dd, int val)
+{
+	writel_relaxed(val, dd->base + QUP_MX_WRITE_COUNT);
+}
+
+static inline void msm_spi_complete(struct msm_spi *dd)
+{
+	dd->tx_done = true;
+	dd->rx_done = true;
+}
+
+static inline void msm_spi_enable_error_flags(struct msm_spi *dd)
+{
+	if (dd->qup_ver == SPI_QUP_VERSION_BFAM)
+		writel_relaxed(
+			SPI_ERR_CLK_UNDER_RUN_ERR | SPI_ERR_CLK_OVER_RUN_ERR,
+			dd->base + SPI_ERROR_FLAGS_EN);
+	else
+		writel_relaxed(0x00000078, dd->base + SPI_ERROR_FLAGS_EN);
+}
+
+static inline void msm_spi_clear_error_flags(struct msm_spi *dd)
+{
+	if (dd->qup_ver == SPI_QUP_VERSION_BFAM)
+		writel_relaxed(
+			SPI_ERR_CLK_UNDER_RUN_ERR | SPI_ERR_CLK_OVER_RUN_ERR,
+			dd->base + SPI_ERROR_FLAGS);
+	else
+		writel_relaxed(0x0000007C, dd->base + SPI_ERROR_FLAGS);
+}
+
+#endif
+#endif
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 7d9a2e8..b29e60d 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -59,6 +59,8 @@
 #define SPMI_OWNERSHIP_TABLE_REG(N)	(0x0700 + (4 * (N)))
 #define SPMI_OWNERSHIP_PERIPH2OWNER(X)	((X) & 0x7)
 
+#define SPMI_PROTOCOL_IRQ_STATUS	0x6000
+
 /* Channel Status fields */
 enum pmic_arb_chnl_status {
 	PMIC_ARB_STATUS_DONE	= BIT(0),
@@ -148,6 +150,8 @@
  * @ver_ops:		version dependent operations.
  * @ppid_to_apid	in-memory copy of PPID -> channel (APID) mapping table.
  *			v2 only.
+ * @ahb_bus_wa:		Use AHB bus workaround to avoid write transaction
+ *			corruption on some PMIC arbiter v5 platforms.
  */
 struct spmi_pmic_arb {
 	void __iomem		*rd_base;
@@ -172,6 +176,7 @@
 	u16			*ppid_to_apid;
 	u16			last_apid;
 	struct apid_data	apid_data[PMIC_ARB_MAX_PERIPHS];
+	bool			ahb_bus_wa;
 };
 
 /**
@@ -217,6 +222,16 @@
 static inline void pmic_arb_base_write(struct spmi_pmic_arb *pa,
 				       u32 offset, u32 val)
 {
+	if (pa->ahb_bus_wa) {
+		/* AHB bus register dummy read for workaround. */
+		readl_relaxed(pa->cnfg + SPMI_PROTOCOL_IRQ_STATUS);
+		/*
+		 * Ensure that the read completes before initiating the
+		 * subsequent register write.
+		 */
+		mb();
+	}
+
 	writel_relaxed(val, pa->wr_base + offset);
 }
 
@@ -1343,6 +1358,9 @@
 
 	pa->ee = ee;
 
+	pa->ahb_bus_wa = of_property_read_bool(pdev->dev.of_node,
+					"qcom,enable-ahb-bus-workaround");
+
 	pa->mapping_table = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PERIPHS - 1,
 					sizeof(*pa->mapping_table), GFP_KERNEL);
 	if (!pa->mapping_table) {
diff --git a/drivers/staging/android/fiq_debugger/fiq_debugger.c b/drivers/staging/android/fiq_debugger/fiq_debugger.c
index ce9dc7e..192661b 100644
--- a/drivers/staging/android/fiq_debugger/fiq_debugger.c
+++ b/drivers/staging/android/fiq_debugger/fiq_debugger.c
@@ -401,7 +401,7 @@
 		cmd += 6;
 		while (*cmd == ' ')
 			cmd++;
-		if ((cmd != '\0') && sysrq_on())
+		if ((*cmd != '\0') && sysrq_on())
 			kernel_restart(cmd);
 		else
 			kernel_restart(NULL);
diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
deleted file mode 100644
index 7e7431d..0000000
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- *
- * Copyright (C) 2011 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/kernel.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-
-#include "ion.h"
-#include "ion_priv.h"
-#include "compat_ion.h"
-
-union ion_ioctl_arg {
-	struct ion_fd_data fd;
-	struct ion_allocation_data allocation;
-	struct ion_handle_data handle;
-	struct ion_custom_data custom;
-	struct ion_heap_query query;
-};
-
-static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
-{
-	int ret = 0;
-
-	switch (cmd) {
-	case ION_IOC_HEAP_QUERY:
-		ret = arg->query.reserved0 != 0;
-		ret |= arg->query.reserved1 != 0;
-		ret |= arg->query.reserved2 != 0;
-		break;
-	default:
-		break;
-	}
-
-	return ret ? -EINVAL : 0;
-}
-
-/* fix up the cases where the ioctl direction bits are incorrect */
-static unsigned int ion_ioctl_dir(unsigned int cmd)
-{
-	switch (cmd) {
-	case ION_IOC_SYNC:
-	case ION_IOC_FREE:
-	case ION_IOC_CUSTOM:
-		return _IOC_WRITE;
-	default:
-		return _IOC_DIR(cmd);
-	}
-}
-
-long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-	struct ion_client *client = filp->private_data;
-	struct ion_device *dev = client->dev;
-	struct ion_handle *cleanup_handle = NULL;
-	int ret = 0;
-	unsigned int dir;
-	union ion_ioctl_arg data;
-
-	dir = ion_ioctl_dir(cmd);
-
-	if (_IOC_SIZE(cmd) > sizeof(data))
-		return -EINVAL;
-
-	/*
-	 * The copy_from_user is unconditional here for both read and write
-	 * to do the validate. If there is no write for the ioctl, the
-	 * buffer is cleared
-	 */
-	if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
-		return -EFAULT;
-
-	ret = validate_ioctl_arg(cmd, &data);
-	if (WARN_ON_ONCE(ret))
-		return ret;
-
-	if (!(dir & _IOC_WRITE))
-		memset(&data, 0, sizeof(data));
-
-	switch (cmd) {
-	case ION_IOC_ALLOC:
-	{
-		struct ion_handle *handle;
-
-		handle = ion_alloc(client, data.allocation.len,
-						data.allocation.align,
-						data.allocation.heap_id_mask,
-						data.allocation.flags);
-		if (IS_ERR(handle))
-			return PTR_ERR(handle);
-
-		data.allocation.handle = handle->id;
-
-		cleanup_handle = handle;
-		break;
-	}
-	case ION_IOC_FREE:
-	{
-		struct ion_handle *handle;
-
-		mutex_lock(&client->lock);
-		handle = ion_handle_get_by_id_nolock(client, data.handle.handle);
-		if (IS_ERR(handle)) {
-			mutex_unlock(&client->lock);
-			return PTR_ERR(handle);
-		}
-		ion_free_nolock(client, handle);
-		ion_handle_put_nolock(handle);
-		mutex_unlock(&client->lock);
-		break;
-	}
-	case ION_IOC_SHARE:
-	case ION_IOC_MAP:
-	{
-		struct ion_handle *handle;
-
-		handle = ion_handle_get_by_id(client, data.handle.handle);
-		if (IS_ERR(handle))
-			return PTR_ERR(handle);
-		data.fd.fd = ion_share_dma_buf_fd(client, handle);
-		ion_handle_put(handle);
-		if (data.fd.fd < 0)
-			ret = data.fd.fd;
-		break;
-	}
-	case ION_IOC_IMPORT:
-	{
-		struct ion_handle *handle;
-
-		handle = ion_import_dma_buf_fd(client, data.fd.fd);
-		if (IS_ERR(handle))
-			ret = PTR_ERR(handle);
-		else
-			data.handle.handle = handle->id;
-		break;
-	}
-	case ION_IOC_SYNC:
-	{
-		ret = ion_sync_for_device(client, data.fd.fd);
-		break;
-	}
-	case ION_IOC_CUSTOM:
-	{
-		if (!dev->custom_ioctl)
-			return -ENOTTY;
-		ret = dev->custom_ioctl(client, data.custom.cmd,
-						data.custom.arg);
-		break;
-	}
-	case ION_IOC_HEAP_QUERY:
-		ret = ion_query_heaps(client, &data.query);
-		break;
-	default:
-		return -ENOTTY;
-	}
-
-	if (dir & _IOC_READ) {
-		if (copy_to_user((void __user *)arg, &data, _IOC_SIZE(cmd))) {
-			if (cleanup_handle)
-				ion_free(client, cleanup_handle);
-			return -EFAULT;
-		}
-	}
-	return ret;
-}
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 9f47fb3..0948c22 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -707,7 +707,7 @@
 		WARN(1, "%s: invalid handle passed to free.\n", __func__);
 		return;
 	}
-	if (!handle->user_ref_count > 0) {
+	if (handle->user_ref_count == 0) {
 		WARN(1, "%s: User does not have access!\n", __func__);
 		return;
 	}
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 616375a..8d67f76 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -48,6 +48,7 @@
 #include <linux/fs.h>
 #include <linux/cpuset.h>
 #include <linux/vmpressure.h>
+#include <linux/freezer.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/almk.h>
@@ -116,6 +117,10 @@
 static int vmpressure_file_min;
 module_param_named(vmpressure_file_min, vmpressure_file_min, int, 0644);
 
+/* User knob to enable/disable oom reaping feature */
+static int oom_reaper;
+module_param_named(oom_reaper, oom_reaper, int, 0644);
+
 enum {
 	VMPRESSURE_NO_ADJUST = 0,
 	VMPRESSURE_ADJUST_ENCROACH,
@@ -406,6 +411,14 @@
 	}
 }
 
+static void mark_lmk_victim(struct task_struct *tsk)
+{
+	struct mm_struct *mm = tsk->mm;
+
+	if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm))
+		atomic_inc(&tsk->signal->oom_mm->mm_count);
+}
+
 static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 {
 	struct task_struct *tsk;
@@ -524,7 +537,11 @@
 		send_sig(SIGKILL, selected, 0);
 		if (selected->mm)
 			task_set_lmk_waiting(selected);
+		if (oom_reaper)
+			mark_lmk_victim(selected);
 		task_unlock(selected);
+		if (oom_reaper)
+			wake_oom_reaper(selected);
 		trace_lowmemory_kill(selected, cache_size, cache_limit, free);
 		lowmem_print(1, "Killing '%s' (%d) (tgid %d), adj %hd,\n"
 			"to free %ldkB on behalf of '%s' (%d) because\n"
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index a34fd5a..7458df4 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2385,6 +2385,7 @@
 			continue;
 		}
 
+		set_current_state(TASK_RUNNING);
 		wp = async->buf_write_ptr;
 		n1 = min(n, async->prealloc_bufsz - wp);
 		n2 = n - n1;
@@ -2517,6 +2518,8 @@
 			}
 			continue;
 		}
+
+		set_current_state(TASK_RUNNING);
 		rp = async->buf_read_ptr;
 		n1 = min(n, async->prealloc_bufsz - rp);
 		n2 = n - n1;
@@ -2898,9 +2901,6 @@
 
 	comedi_class->dev_groups = comedi_dev_groups;
 
-	/* XXX requires /proc interface */
-	comedi_proc_init();
-
 	/* create devices files for legacy/manual use */
 	for (i = 0; i < comedi_num_legacy_minors; i++) {
 		struct comedi_device *dev;
@@ -2918,6 +2918,9 @@
 		mutex_unlock(&dev->mutex);
 	}
 
+	/* XXX requires /proc interface */
+	comedi_proc_init();
+
 	return 0;
 }
 module_init(comedi_init);
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 6b99263..598f0fa 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -472,7 +472,7 @@
 			     long m)
 {
 	struct ad2s1210_state *st = iio_priv(indio_dev);
-	bool negative;
+	u16 negative;
 	int ret = 0;
 	u16 pos;
 	s16 vel;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index b432153..0f63a36 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -45,6 +45,7 @@
 	{USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
 	{USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
 	{USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
+	{USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
 	{}	/* Terminating entry */
 };
 
diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c
index 01438fa..f50076d 100644
--- a/drivers/staging/rts5208/rtsx_scsi.c
+++ b/drivers/staging/rts5208/rtsx_scsi.c
@@ -414,7 +414,7 @@
 	sense->ascq = ascq;
 	if (sns_key_info0 != 0) {
 		sense->sns_key_info[0] = SKSV | sns_key_info0;
-		sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 8;
+		sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 4;
 		sense->sns_key_info[2] = sns_key_info1 & 0x0f;
 	}
 }
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 6370a5e..defffa7 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -269,23 +269,12 @@
 
 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
 {
-	int i = 0;
-	int ret = -1;
-	struct wilc_vif *vif;
-	struct wilc *wilc;
+	struct wilc_vif *vif = netdev_priv(wilc_netdev);
 
-	vif = netdev_priv(wilc_netdev);
-	wilc = vif->wilc;
+	memcpy(vif->bssid, bssid, 6);
+	vif->mode = mode;
 
-	for (i = 0; i < wilc->vif_num; i++)
-		if (wilc->vif[i]->ndev == wilc_netdev) {
-			memcpy(wilc->vif[i]->bssid, bssid, 6);
-			wilc->vif[i]->mode = mode;
-			ret = 0;
-			break;
-		}
-
-	return ret;
+	return 0;
 }
 
 int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
@@ -1212,16 +1201,11 @@
 
 void wilc_netdev_cleanup(struct wilc *wilc)
 {
-	int i = 0;
-	struct wilc_vif *vif[NUM_CONCURRENT_IFC];
+	int i;
 
-	if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
+	if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev))
 		unregister_inetaddr_notifier(&g_dev_notifier);
 
-		for (i = 0; i < NUM_CONCURRENT_IFC; i++)
-			vif[i] = netdev_priv(wilc->vif[i]->ndev);
-	}
-
 	if (wilc && wilc->firmware) {
 		release_firmware(wilc->firmware);
 		wilc->firmware = NULL;
@@ -1230,7 +1214,7 @@
 	if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
 		for (i = 0; i < NUM_CONCURRENT_IFC; i++)
 			if (wilc->vif[i]->ndev)
-				if (vif[i]->mac_opened)
+				if (wilc->vif[i]->mac_opened)
 					wilc_mac_close(wilc->vif[i]->ndev);
 
 		for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
@@ -1278,9 +1262,9 @@
 
 		vif->idx = wl->vif_num;
 		vif->wilc = *wilc;
+		vif->ndev = ndev;
 		wl->vif[i] = vif;
-		wl->vif[wl->vif_num]->ndev = ndev;
-		wl->vif_num++;
+		wl->vif_num = i;
 		ndev->netdev_ops = &wilc_netdev_ops;
 
 		{
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
index 182b2d5..165c46f 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -666,8 +666,11 @@
 
 void prism2_roamed(struct wlandevice *wlandev)
 {
-	cfg80211_roamed(wlandev->netdev, NULL, wlandev->bssid,
-		NULL, 0, NULL, 0, GFP_KERNEL);
+	struct cfg80211_roam_info roam_info = {
+		.bssid = wlandev->bssid,
+	};
+
+	cfg80211_roamed(wlandev->netdev, &roam_info, GFP_KERNEL);
 }
 
 /* Structures for declaring wiphy interface */
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 155fe0e..e49fcd5 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -418,6 +418,7 @@
 		return 0;
 	}
 	np->np_thread_state = ISCSI_NP_THREAD_RESET;
+	atomic_inc(&np->np_reset_count);
 
 	if (np->np_thread) {
 		spin_unlock_bh(&np->np_thread_lock);
@@ -2177,6 +2178,7 @@
 	cmd->cmd_sn		= be32_to_cpu(hdr->cmdsn);
 	cmd->exp_stat_sn	= be32_to_cpu(hdr->exp_statsn);
 	cmd->data_direction	= DMA_NONE;
+	kfree(cmd->text_in_ptr);
 	cmd->text_in_ptr	= NULL;
 
 	return 0;
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 6128e8e..9ccd5da 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -1233,9 +1233,11 @@
 	flush_signals(current);
 
 	spin_lock_bh(&np->np_thread_lock);
-	if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+	if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
 		np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
+		spin_unlock_bh(&np->np_thread_lock);
 		complete(&np->np_restart_comp);
+		return 1;
 	} else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) {
 		spin_unlock_bh(&np->np_thread_lock);
 		goto exit;
@@ -1268,7 +1270,8 @@
 		goto exit;
 	} else if (rc < 0) {
 		spin_lock_bh(&np->np_thread_lock);
-		if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+		if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
+			np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
 			spin_unlock_bh(&np->np_thread_lock);
 			complete(&np->np_restart_comp);
 			iscsit_put_transport(conn->conn_transport);
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
index 6693d7c..e8efb42 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -490,14 +490,60 @@
 
 static int iscsi_target_do_login(struct iscsi_conn *, struct iscsi_login *);
 
-static bool iscsi_target_sk_state_check(struct sock *sk)
+static bool __iscsi_target_sk_check_close(struct sock *sk)
 {
 	if (sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) {
-		pr_debug("iscsi_target_sk_state_check: TCP_CLOSE_WAIT|TCP_CLOSE,"
+		pr_debug("__iscsi_target_sk_check_close: TCP_CLOSE_WAIT|TCP_CLOSE,"
 			"returning FALSE\n");
-		return false;
+		return true;
 	}
-	return true;
+	return false;
+}
+
+static bool iscsi_target_sk_check_close(struct iscsi_conn *conn)
+{
+	bool state = false;
+
+	if (conn->sock) {
+		struct sock *sk = conn->sock->sk;
+
+		read_lock_bh(&sk->sk_callback_lock);
+		state = (__iscsi_target_sk_check_close(sk) ||
+			 test_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags));
+		read_unlock_bh(&sk->sk_callback_lock);
+	}
+	return state;
+}
+
+static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int flag)
+{
+	bool state = false;
+
+	if (conn->sock) {
+		struct sock *sk = conn->sock->sk;
+
+		read_lock_bh(&sk->sk_callback_lock);
+		state = test_bit(flag, &conn->login_flags);
+		read_unlock_bh(&sk->sk_callback_lock);
+	}
+	return state;
+}
+
+static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned int flag)
+{
+	bool state = false;
+
+	if (conn->sock) {
+		struct sock *sk = conn->sock->sk;
+
+		write_lock_bh(&sk->sk_callback_lock);
+		state = (__iscsi_target_sk_check_close(sk) ||
+			 test_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags));
+		if (!state)
+			clear_bit(flag, &conn->login_flags);
+		write_unlock_bh(&sk->sk_callback_lock);
+	}
+	return state;
 }
 
 static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login)
@@ -537,6 +583,20 @@
 
 	pr_debug("entering iscsi_target_do_login_rx, conn: %p, %s:%d\n",
 			conn, current->comm, current->pid);
+	/*
+	 * If iscsi_target_do_login_rx() has been invoked by ->sk_data_ready()
+	 * before initial PDU processing in iscsi_target_start_negotiation()
+	 * has completed, go ahead and retry until it's cleared.
+	 *
+	 * Otherwise if the TCP connection drops while this is occuring,
+	 * iscsi_target_start_negotiation() will detect the failure, call
+	 * cancel_delayed_work_sync(&conn->login_work), and cleanup the
+	 * remaining iscsi connection resources from iscsi_np process context.
+	 */
+	if (iscsi_target_sk_check_flag(conn, LOGIN_FLAGS_INITIAL_PDU)) {
+		schedule_delayed_work(&conn->login_work, msecs_to_jiffies(10));
+		return;
+	}
 
 	spin_lock(&tpg->tpg_state_lock);
 	state = (tpg->tpg_state == TPG_STATE_ACTIVE);
@@ -544,26 +604,12 @@
 
 	if (!state) {
 		pr_debug("iscsi_target_do_login_rx: tpg_state != TPG_STATE_ACTIVE\n");
-		iscsi_target_restore_sock_callbacks(conn);
-		iscsi_target_login_drop(conn, login);
-		iscsit_deaccess_np(np, tpg, tpg_np);
-		return;
+		goto err;
 	}
 
-	if (conn->sock) {
-		struct sock *sk = conn->sock->sk;
-
-		read_lock_bh(&sk->sk_callback_lock);
-		state = iscsi_target_sk_state_check(sk);
-		read_unlock_bh(&sk->sk_callback_lock);
-
-		if (!state) {
-			pr_debug("iscsi_target_do_login_rx, TCP state CLOSE\n");
-			iscsi_target_restore_sock_callbacks(conn);
-			iscsi_target_login_drop(conn, login);
-			iscsit_deaccess_np(np, tpg, tpg_np);
-			return;
-		}
+	if (iscsi_target_sk_check_close(conn)) {
+		pr_debug("iscsi_target_do_login_rx, TCP state CLOSE\n");
+		goto err;
 	}
 
 	conn->login_kworker = current;
@@ -581,34 +627,29 @@
 	flush_signals(current);
 	conn->login_kworker = NULL;
 
-	if (rc < 0) {
-		iscsi_target_restore_sock_callbacks(conn);
-		iscsi_target_login_drop(conn, login);
-		iscsit_deaccess_np(np, tpg, tpg_np);
-		return;
-	}
+	if (rc < 0)
+		goto err;
 
 	pr_debug("iscsi_target_do_login_rx after rx_login_io, %p, %s:%d\n",
 			conn, current->comm, current->pid);
 
 	rc = iscsi_target_do_login(conn, login);
 	if (rc < 0) {
-		iscsi_target_restore_sock_callbacks(conn);
-		iscsi_target_login_drop(conn, login);
-		iscsit_deaccess_np(np, tpg, tpg_np);
+		goto err;
 	} else if (!rc) {
-		if (conn->sock) {
-			struct sock *sk = conn->sock->sk;
-
-			write_lock_bh(&sk->sk_callback_lock);
-			clear_bit(LOGIN_FLAGS_READ_ACTIVE, &conn->login_flags);
-			write_unlock_bh(&sk->sk_callback_lock);
-		}
+		if (iscsi_target_sk_check_and_clear(conn, LOGIN_FLAGS_READ_ACTIVE))
+			goto err;
 	} else if (rc == 1) {
 		iscsi_target_nego_release(conn);
 		iscsi_post_login_handler(np, conn, zero_tsih);
 		iscsit_deaccess_np(np, tpg, tpg_np);
 	}
+	return;
+
+err:
+	iscsi_target_restore_sock_callbacks(conn);
+	iscsi_target_login_drop(conn, login);
+	iscsit_deaccess_np(np, tpg, tpg_np);
 }
 
 static void iscsi_target_do_cleanup(struct work_struct *work)
@@ -656,31 +697,54 @@
 		orig_state_change(sk);
 		return;
 	}
+	state = __iscsi_target_sk_check_close(sk);
+	pr_debug("__iscsi_target_sk_close_change: state: %d\n", state);
+
 	if (test_bit(LOGIN_FLAGS_READ_ACTIVE, &conn->login_flags)) {
 		pr_debug("Got LOGIN_FLAGS_READ_ACTIVE=1 sk_state_change"
 			 " conn: %p\n", conn);
+		if (state)
+			set_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags);
 		write_unlock_bh(&sk->sk_callback_lock);
 		orig_state_change(sk);
 		return;
 	}
-	if (test_and_set_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags)) {
+	if (test_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags)) {
 		pr_debug("Got LOGIN_FLAGS_CLOSED=1 sk_state_change conn: %p\n",
 			 conn);
 		write_unlock_bh(&sk->sk_callback_lock);
 		orig_state_change(sk);
 		return;
 	}
-
-	state = iscsi_target_sk_state_check(sk);
-	write_unlock_bh(&sk->sk_callback_lock);
-
-	pr_debug("iscsi_target_sk_state_change: state: %d\n", state);
-
-	if (!state) {
+	/*
+	 * If the TCP connection has dropped, go ahead and set LOGIN_FLAGS_CLOSED,
+	 * but only queue conn->login_work -> iscsi_target_do_login_rx()
+	 * processing if LOGIN_FLAGS_INITIAL_PDU has already been cleared.
+	 *
+	 * When iscsi_target_do_login_rx() runs, iscsi_target_sk_check_close()
+	 * will detect the dropped TCP connection from delayed workqueue context.
+	 *
+	 * If LOGIN_FLAGS_INITIAL_PDU is still set, which means the initial
+	 * iscsi_target_start_negotiation() is running, iscsi_target_do_login()
+	 * via iscsi_target_sk_check_close() or iscsi_target_start_negotiation()
+	 * via iscsi_target_sk_check_and_clear() is responsible for detecting the
+	 * dropped TCP connection in iscsi_np process context, and cleaning up
+	 * the remaining iscsi connection resources.
+	 */
+	if (state) {
 		pr_debug("iscsi_target_sk_state_change got failed state\n");
-		schedule_delayed_work(&conn->login_cleanup_work, 0);
+		set_bit(LOGIN_FLAGS_CLOSED, &conn->login_flags);
+		state = test_bit(LOGIN_FLAGS_INITIAL_PDU, &conn->login_flags);
+		write_unlock_bh(&sk->sk_callback_lock);
+
+		orig_state_change(sk);
+
+		if (!state)
+			schedule_delayed_work(&conn->login_work, 0);
 		return;
 	}
+	write_unlock_bh(&sk->sk_callback_lock);
+
 	orig_state_change(sk);
 }
 
@@ -945,6 +1009,15 @@
 			if (iscsi_target_handle_csg_one(conn, login) < 0)
 				return -1;
 			if (login_rsp->flags & ISCSI_FLAG_LOGIN_TRANSIT) {
+				/*
+				 * Check to make sure the TCP connection has not
+				 * dropped asynchronously while session reinstatement
+				 * was occuring in this kthread context, before
+				 * transitioning to full feature phase operation.
+				 */
+				if (iscsi_target_sk_check_close(conn))
+					return -1;
+
 				login->tsih = conn->sess->tsih;
 				login->login_complete = 1;
 				iscsi_target_restore_sock_callbacks(conn);
@@ -971,21 +1044,6 @@
 		break;
 	}
 
-	if (conn->sock) {
-		struct sock *sk = conn->sock->sk;
-		bool state;
-
-		read_lock_bh(&sk->sk_callback_lock);
-		state = iscsi_target_sk_state_check(sk);
-		read_unlock_bh(&sk->sk_callback_lock);
-
-		if (!state) {
-			pr_debug("iscsi_target_do_login() failed state for"
-				 " conn: %p\n", conn);
-			return -1;
-		}
-	}
-
 	return 0;
 }
 
@@ -1252,13 +1310,25 @@
        if (conn->sock) {
                struct sock *sk = conn->sock->sk;
 
-               write_lock_bh(&sk->sk_callback_lock);
-               set_bit(LOGIN_FLAGS_READY, &conn->login_flags);
-               write_unlock_bh(&sk->sk_callback_lock);
-       }
+		write_lock_bh(&sk->sk_callback_lock);
+		set_bit(LOGIN_FLAGS_READY, &conn->login_flags);
+		set_bit(LOGIN_FLAGS_INITIAL_PDU, &conn->login_flags);
+		write_unlock_bh(&sk->sk_callback_lock);
+	}
+	/*
+	 * If iscsi_target_do_login returns zero to signal more PDU
+	 * exchanges are required to complete the login, go ahead and
+	 * clear LOGIN_FLAGS_INITIAL_PDU but only if the TCP connection
+	 * is still active.
+	 *
+	 * Otherwise if TCP connection dropped asynchronously, go ahead
+	 * and perform connection cleanup now.
+	 */
+	ret = iscsi_target_do_login(conn, login);
+	if (!ret && iscsi_target_sk_check_and_clear(conn, LOGIN_FLAGS_INITIAL_PDU))
+		ret = -1;
 
-       ret = iscsi_target_do_login(conn, login);
-       if (ret < 0) {
+	if (ret < 0) {
 		cancel_delayed_work_sync(&conn->login_work);
 		cancel_delayed_work_sync(&conn->login_cleanup_work);
 		iscsi_target_restore_sock_callbacks(conn);
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 1949f50..0e2e71f 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -364,7 +364,7 @@
 	mutex_lock(&tpg->acl_node_mutex);
 	if (acl->dynamic_node_acl)
 		acl->dynamic_node_acl = 0;
-	list_del(&acl->acl_list);
+	list_del_init(&acl->acl_list);
 	mutex_unlock(&tpg->acl_node_mutex);
 
 	target_shutdown_sessions(acl);
@@ -540,7 +540,7 @@
 	 * in transport_deregister_session().
 	 */
 	list_for_each_entry_safe(nacl, nacl_tmp, &node_list, acl_list) {
-		list_del(&nacl->acl_list);
+		list_del_init(&nacl->acl_list);
 
 		core_tpg_wait_for_nacl_pr_ref(nacl);
 		core_free_device_list_for_node(nacl, se_tpg);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index e8a1f5c..bacfa8f 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -465,7 +465,7 @@
 	}
 
 	mutex_lock(&se_tpg->acl_node_mutex);
-	list_del(&nacl->acl_list);
+	list_del_init(&nacl->acl_list);
 	mutex_unlock(&se_tpg->acl_node_mutex);
 
 	core_tpg_wait_for_nacl_pr_ref(nacl);
@@ -537,7 +537,7 @@
 			spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags);
 
 			if (se_nacl->dynamic_stop)
-				list_del(&se_nacl->acl_list);
+				list_del_init(&se_nacl->acl_list);
 		}
 		mutex_unlock(&se_tpg->acl_node_mutex);
 
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 65d8fd7..bb5f706 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -80,6 +80,7 @@
  * @polling_delay: zone polling interval
  * @slope: slope of the temperature adjustment curve
  * @offset: offset of the temperature adjustment curve
+ * @default_disable: Keep the thermal zone disabled by default
  * @tzd: thermal zone device pointer for this sensor
  * @ntrips: number of trip points
  * @trips: an array of trip points (0..ntrips - 1)
@@ -96,6 +97,7 @@
 	int slope;
 	int offset;
 	struct thermal_zone_device *tzd;
+	bool default_disable;
 
 	/* trip data */
 	int ntrips;
@@ -193,6 +195,12 @@
 
 	if (!data->senps || !data->senps->ops->get_temp)
 		return -EINVAL;
+	if (data->mode == THERMAL_DEVICE_DISABLED) {
+		*temp = tz->tzp->tracks_low ?
+				THERMAL_TEMP_INVALID_LOW :
+				THERMAL_TEMP_INVALID;
+		return 0;
+	}
 
 	return data->senps->ops->get_temp(data->senps->sensor_data, temp);
 }
@@ -507,6 +515,8 @@
 	head = &data->senps->first_tz;
 	list_for_each_entry(data, head, list) {
 		zone = data->tzd;
+		if (data->mode == THERMAL_DEVICE_DISABLED)
+			continue;
 		for (trip = 0; trip < data->ntrips; trip++) {
 			of_thermal_get_trip_type(zone, trip, &type);
 			if (!(BIT(type) & trip_type_mask))
@@ -570,6 +580,8 @@
 	head = &data->senps->first_tz;
 	list_for_each_entry(data, head, list) {
 		zone = data->tzd;
+		if (data->mode == THERMAL_DEVICE_DISABLED)
+			continue;
 		thermal_zone_device_update(zone, THERMAL_EVENT_UNSPECIFIED);
 	}
 }
@@ -700,6 +712,7 @@
 	for_each_available_child_of_node(np, child) {
 		struct of_phandle_args sensor_specs;
 		int ret, id;
+		struct __thermal_zone *tz;
 
 		/* For now, thermal framework supports only 1 sensor per zone */
 		ret = of_parse_phandle_with_args(child, "thermal-sensors",
@@ -723,7 +736,10 @@
 			if (!IS_ERR(tzd)) {
 				if (!first_tzd)
 					first_tzd = tzd;
-				tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
+				tz = tzd->devdata;
+				if (!tz->default_disable)
+					tzd->ops->set_mode(tzd,
+						THERMAL_DEVICE_ENABLED);
 			}
 		}
 		of_node_put(sensor_specs.np);
@@ -847,7 +863,7 @@
 	tzd = thermal_zone_get_zone_by_name(
 				sensor_data->virt_zone_name);
 	if (IS_ERR(tzd)) {
-		dev_err(dev, "sens:%s not available err: %ld\n",
+		dev_dbg(dev, "sens:%s not available err: %ld\n",
 				sensor_data->virt_zone_name,
 				PTR_ERR(tzd));
 		return tzd;
@@ -927,7 +943,8 @@
 	*ptr = tzd;
 	devres_add(dev, ptr);
 
-	tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
+	if (!tz->default_disable)
+		tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
 
 	return tzd;
 }
@@ -1196,6 +1213,8 @@
 	}
 	tz->polling_delay = prop;
 
+	tz->default_disable = of_property_read_bool(np,
+					"disable-thermal-zone");
 	/*
 	 * REVIST: for now, the thermal framework supports only
 	 * one sensor per thermal zone. Thus, we are considering
diff --git a/drivers/thermal/qcom/msm_lmh_dcvs.c b/drivers/thermal/qcom/msm_lmh_dcvs.c
index d590d24..4e5546e 100644
--- a/drivers/thermal/qcom/msm_lmh_dcvs.c
+++ b/drivers/thermal/qcom/msm_lmh_dcvs.c
@@ -354,7 +354,13 @@
 	mutex_lock(&hw->access_lock);
 	for_each_cpu(cpu_idx, &hw->core_map) {
 		if (cpu_idx == cpu)
-			hw->cdev_data[idx].max_freq = freq;
+		/*
+		 * If there is no limits restriction for CPU scaling max
+		 * frequency, vote for a very high value. This will allow
+		 * the CPU to use the boost frequencies.
+		 */
+			hw->cdev_data[idx].max_freq =
+				(freq == hw->max_freq) ? U32_MAX : freq;
 		if (max_freq > hw->cdev_data[idx].max_freq)
 			max_freq = hw->cdev_data[idx].max_freq;
 		idx++;
diff --git a/drivers/thermal/qcom/qmi_cooling.c b/drivers/thermal/qcom/qmi_cooling.c
index af82030..e1a01d8 100644
--- a/drivers/thermal/qcom/qmi_cooling.c
+++ b/drivers/thermal/qcom/qmi_cooling.c
@@ -85,6 +85,10 @@
 		.type = QMI_CDEV_MAX_LIMIT_TYPE,
 	},
 	{
+		.dev_name = "modem_skin",
+		.type = QMI_CDEV_MAX_LIMIT_TYPE,
+	},
+	{
 		.dev_name = "modem_bw",
 		.type = QMI_CDEV_MAX_LIMIT_TYPE,
 	},
diff --git a/drivers/thermal/qcom/qti_virtual_sensor.c b/drivers/thermal/qcom/qti_virtual_sensor.c
index 923680a..8cb7dc3 100644
--- a/drivers/thermal/qcom/qti_virtual_sensor.c
+++ b/drivers/thermal/qcom/qti_virtual_sensor.c
@@ -46,6 +46,24 @@
 				"cpu3-gold-usr"},
 		.logic = VIRT_MAXIMUM,
 	},
+	{
+		.virt_zone_name = "hexa-silv-max-step",
+		.num_sensors = 6,
+		.sensor_names = {"cpu0-silver-usr",
+				"cpu1-silver-usr",
+				"cpu2-silver-usr",
+				"cpu3-silver-usr",
+				"cpu4-silver-usr",
+				"cpu5-silver-usr"},
+		.logic = VIRT_MAXIMUM,
+	},
+	{
+		.virt_zone_name = "dual-gold-max-step",
+		.num_sensors = 2,
+		.sensor_names = {"cpu0-gold-usr",
+				"cpu1-gold-usr"},
+		.logic = VIRT_MAXIMUM,
+	},
 };
 
 int qti_virtual_sensor_register(struct device *dev)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 2bfe1b5..7663e3c 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -522,6 +522,7 @@
 		if (!ret && *temp < crit_temp)
 			*temp = tz->emul_temperature;
 	}
+	trace_thermal_query_temp(tz, *temp);
 	mutex_unlock(&tz->lock);
 exit:
 	return ret;
@@ -594,7 +595,8 @@
 	mutex_unlock(&tz->lock);
 
 	trace_thermal_temperature(tz);
-	if (tz->last_temperature == THERMAL_TEMP_INVALID)
+	if (tz->last_temperature == THERMAL_TEMP_INVALID ||
+		tz->last_temperature == THERMAL_TEMP_INVALID_LOW)
 		dev_dbg(&tz->device, "last_temperature N/A, current_temperature=%d\n",
 			tz->temperature);
 	else
@@ -688,6 +690,26 @@
 		       : "disabled");
 }
 
+static int thermal_zone_device_clear(struct thermal_zone_device *tz)
+{
+	struct thermal_instance *pos;
+	int ret = 0;
+
+	ret = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
+	mutex_lock(&tz->lock);
+	thermal_zone_device_reset(tz);
+	list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+		pos->target = THERMAL_NO_TARGET;
+		mutex_lock(&pos->cdev->lock);
+		pos->cdev->updated = false; /* cdev needs update */
+		mutex_unlock(&pos->cdev->lock);
+		thermal_cdev_update(pos->cdev);
+	}
+	mutex_unlock(&tz->lock);
+
+	return ret;
+}
+
 static ssize_t
 mode_store(struct device *dev, struct device_attribute *attr,
 	   const char *buf, size_t count)
@@ -701,7 +723,7 @@
 	if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
 		result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED);
 	else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
-		result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
+		result = thermal_zone_device_clear(tz);
 	else
 		result = -EINVAL;
 
@@ -2565,9 +2587,11 @@
 	case PM_POST_SUSPEND:
 		atomic_set(&in_suspend, 0);
 		list_for_each_entry(tz, &thermal_tz_list, node) {
+			mutex_lock(&tz->lock);
 			thermal_zone_device_reset(tz);
-			thermal_zone_device_update(tz,
-						   THERMAL_EVENT_UNSPECIFIED);
+			mod_delayed_work(system_freezable_power_efficient_wq,
+						&tz->poll_queue, 0);
+			mutex_unlock(&tz->lock);
 		}
 		break;
 	default:
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index bac9975..626cfdc 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1091,6 +1091,18 @@
 	select SERIAL_CORE_CONSOLE
 	select SERIAL_EARLYCON
 
+config SERIAL_MSM_HS
+	tristate "MSM UART High Speed: Serial Driver"
+	depends on ARCH_QCOM
+	select SERIAL_CORE
+	help
+	  If you have a machine based on MSM family of SoCs, you
+	  can enable its onboard high speed serial port by enabling
+	  this option.
+
+	  Choose M here to compile it as a module. The module will be
+	  called msm_serial_hs.
+
 config SERIAL_VT8500
 	bool "VIA VT8500 on-chip serial port support"
 	depends on ARCH_VT8500
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index b39165b..1bdc7f8 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -62,6 +62,7 @@
 obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
 obj-$(CONFIG_SERIAL_MSM) += msm_serial.o
 obj-$(CONFIG_SERIAL_MSM_GENI) += msm_geni_serial.o
+obj-$(CONFIG_SERIAL_MSM_HS) += msm_serial_hs.o
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_KGDB_NMI) += kgdb_nmi.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
diff --git a/drivers/tty/serial/msm_geni_serial.c b/drivers/tty/serial/msm_geni_serial.c
index d7355f0..af119f4 100644
--- a/drivers/tty/serial/msm_geni_serial.c
+++ b/drivers/tty/serial/msm_geni_serial.c
@@ -98,7 +98,9 @@
 #define UART_PARAM		(0x1)
 
 /* UART DMA Rx GP_IRQ_BITS */
-#define UART_DMA_RX_ERRS	(GENMASK(5, 8))
+#define UART_DMA_RX_PARITY_ERR	BIT(5)
+#define UART_DMA_RX_ERRS	(GENMASK(5, 6))
+#define UART_DMA_RX_BREAK	(GENMASK(7, 8))
 
 #define UART_OVERSAMPLING	(32)
 #define STALE_TIMEOUT		(16)
@@ -125,6 +127,7 @@
 } while (0)
 
 #define DMA_RX_BUF_SIZE		(2048)
+#define CONSOLE_YIELD_LEN	(8 * 1024)
 struct msm_geni_serial_port {
 	struct uart_port uport;
 	char name[20];
@@ -141,7 +144,8 @@
 	int (*handle_rx)(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last);
+			unsigned int rx_last,
+			bool drop_rx);
 	struct device *wrapper_dev;
 	struct se_geni_rsc serial_rsc;
 	dma_addr_t tx_dma;
@@ -159,6 +163,7 @@
 	unsigned int cur_baud;
 	int ioctl_count;
 	int edge_count;
+	unsigned int tx_yield_count;
 };
 
 static const struct uart_ops msm_geni_serial_pops;
@@ -167,11 +172,13 @@
 static int handle_rx_console(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last);
+			unsigned int rx_last,
+			bool drop_rx);
 static int handle_rx_hs(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last);
+			unsigned int rx_last,
+			bool drop_rx);
 static unsigned int msm_geni_serial_tx_empty(struct uart_port *port);
 static int msm_geni_serial_power_on(struct uart_port *uport);
 static void msm_geni_serial_power_off(struct uart_port *uport);
@@ -511,9 +518,6 @@
 	int done = 0;
 	unsigned int irq_clear = M_CMD_DONE_EN;
 
-	if (!uart_console(uport))
-		return;
-
 	done = msm_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
 						M_CMD_DONE_EN, true);
 	if (!done) {
@@ -684,7 +688,8 @@
 static int handle_rx_console(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last)
+			unsigned int rx_last,
+			bool drop_rx)
 {
 	int i, c;
 	unsigned char *rx_char;
@@ -697,6 +702,8 @@
 
 		*(msm_port->rx_fifo) =
 			geni_read_reg_nolog(uport->membase, SE_GENI_RX_FIFOn);
+		if (drop_rx)
+			continue;
 		rx_char = (unsigned char *)msm_port->rx_fifo;
 
 		if (i == (rx_fifo_wc - 1)) {
@@ -713,14 +720,16 @@
 				tty_insert_flip_char(tport, rx_char[c], flag);
 		}
 	}
-	tty_flip_buffer_push(tport);
+	if (!drop_rx)
+		tty_flip_buffer_push(tport);
 	return 0;
 }
 #else
 static int handle_rx_console(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last)
+			unsigned int rx_last,
+			bool drop_rx)
 {
 	return -EPERM;
 }
@@ -1004,7 +1013,8 @@
 static int handle_rx_hs(struct uart_port *uport,
 			unsigned int rx_fifo_wc,
 			unsigned int rx_last_byte_valid,
-			unsigned int rx_last)
+			unsigned int rx_last,
+			bool drop_rx)
 {
 	unsigned char *rx_char;
 	struct tty_port *tport;
@@ -1019,6 +1029,8 @@
 	tport = &uport->state->port;
 	ioread32_rep((uport->membase + SE_GENI_RX_FIFOn), msm_port->rx_fifo,
 								rx_fifo_wc);
+	if (drop_rx)
+		return 0;
 
 	rx_char = (unsigned char *)msm_port->rx_fifo;
 	ret = tty_insert_flip_string(tport, rx_char, rx_bytes);
@@ -1034,7 +1046,7 @@
 	return ret;
 }
 
-static int msm_geni_serial_handle_rx(struct uart_port *uport)
+static int msm_geni_serial_handle_rx(struct uart_port *uport, bool drop_rx)
 {
 	int ret = 0;
 	unsigned int rx_fifo_status;
@@ -1053,7 +1065,7 @@
 	rx_last = rx_fifo_status & RX_LAST;
 	if (rx_fifo_wc)
 		port->handle_rx(uport, rx_fifo_wc, rx_last_byte_valid,
-								rx_last);
+							rx_last, drop_rx);
 	return ret;
 }
 
@@ -1073,6 +1085,14 @@
 
 	xmit->tail = (xmit->tail + msm_port->xmit_size) & (UART_XMIT_SIZE - 1);
 	msm_port->xmit_size = 0;
+	if (uart_console(uport) &&
+	    (uport->icount.tx - msm_port->tx_yield_count) > CONSOLE_YIELD_LEN) {
+		msm_port->tx_yield_count = uport->icount.tx;
+		msm_geni_serial_stop_tx(uport);
+		uart_write_wakeup(uport);
+		goto exit_handle_tx;
+	}
+
 	tx_fifo_status = geni_read_reg_nolog(uport->membase,
 					SE_GENI_TX_FIFO_STATUS);
 	if (uart_circ_empty(xmit) && !tx_fifo_status) {
@@ -1125,18 +1145,19 @@
 		/* Ensure FIFO write goes through */
 		wmb();
 	}
-	msm_geni_serial_poll_cancel_tx(uport);
-	if (uart_console(uport))
+	if (uart_console(uport)) {
+		msm_geni_serial_poll_cancel_tx(uport);
 		xmit->tail = (xmit->tail + xmit_size) & (UART_XMIT_SIZE - 1);
-	else
+	} else {
 		msm_port->xmit_size = xmit_size;
+	}
+exit_handle_tx:
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
 		uart_write_wakeup(uport);
-exit_handle_tx:
 	return ret;
 }
 
-static int msm_geni_serial_handle_dma_rx(struct uart_port *uport)
+static int msm_geni_serial_handle_dma_rx(struct uart_port *uport, bool drop_rx)
 {
 	struct msm_geni_serial_port *msm_port = GET_DEV_PORT(uport);
 	unsigned int rx_bytes = 0;
@@ -1162,6 +1183,8 @@
 					__func__, rx_bytes);
 		goto exit_handle_dma_rx;
 	}
+	if (drop_rx)
+		goto exit_handle_dma_rx;
 
 	tport = &uport->state->port;
 	ret = tty_insert_flip_string(tport, (unsigned char *)(msm_port->rx_buf),
@@ -1213,6 +1236,7 @@
 	unsigned long flags;
 	unsigned int m_irq_en;
 	struct msm_geni_serial_port *msm_port = GET_DEV_PORT(uport);
+	bool drop_rx = false;
 
 	spin_lock_irqsave(&uport->lock, flags);
 	if (uart_console(uport) && uport->suspended)
@@ -1240,22 +1264,37 @@
 		goto exit_geni_serial_isr;
 	}
 
-	if (!dma) {
-		if ((s_irq_status & S_GP_IRQ_0_EN) ||
-			(s_irq_status & S_GP_IRQ_1_EN) ||
-			(s_irq_status & S_GP_IRQ_2_EN) ||
-			(s_irq_status & S_GP_IRQ_3_EN)) {
-			IPC_LOG_MSG(msm_port->ipc_log_misc,
-				"%s.sirq 0x%x.\n", __func__, s_irq_status);
-			goto exit_geni_serial_isr;
-		}
-		if ((s_irq_status & S_RX_FIFO_WATERMARK_EN) ||
-			(s_irq_status & S_RX_FIFO_LAST_EN))
-			msm_geni_serial_handle_rx(uport);
+	if (s_irq_status & S_RX_FIFO_WR_ERR_EN) {
+		uport->icount.buf_overrun++;
+		IPC_LOG_MSG(msm_port->ipc_log_misc,
+			"%s.sirq 0x%x buf_overrun:%d\n",
+			__func__, s_irq_status, uport->icount.buf_overrun);
+	}
 
+	if (!dma) {
 		if ((m_irq_status & m_irq_en) &
 		    (M_TX_FIFO_WATERMARK_EN | M_CMD_DONE_EN))
 			msm_geni_serial_handle_tx(uport);
+
+		if ((s_irq_status & S_GP_IRQ_0_EN) ||
+			(s_irq_status & S_GP_IRQ_1_EN)) {
+			if (s_irq_status & S_GP_IRQ_0_EN)
+				uport->icount.parity++;
+			IPC_LOG_MSG(msm_port->ipc_log_misc,
+				"%s.sirq 0x%x parity:%d\n",
+				__func__, s_irq_status, uport->icount.parity);
+			drop_rx = true;
+		} else if ((s_irq_status & S_GP_IRQ_2_EN) ||
+			(s_irq_status & S_GP_IRQ_3_EN)) {
+			uport->icount.brk++;
+			IPC_LOG_MSG(msm_port->ipc_log_misc,
+				"%s.sirq 0x%x break:%d\n",
+				__func__, s_irq_status, uport->icount.brk);
+		}
+
+		if ((s_irq_status & S_RX_FIFO_WATERMARK_EN) ||
+			(s_irq_status & S_RX_FIFO_LAST_EN))
+			msm_geni_serial_handle_rx(uport, drop_rx);
 	} else {
 		if (dma_tx_status) {
 			geni_write_reg_nolog(dma_tx_status, uport->membase,
@@ -1274,13 +1313,22 @@
 				goto exit_geni_serial_isr;
 			}
 			if (dma_rx_status & UART_DMA_RX_ERRS) {
+				if (dma_rx_status & UART_DMA_RX_PARITY_ERR)
+					uport->icount.parity++;
 				IPC_LOG_MSG(msm_port->ipc_log_misc,
-					"%s.Rx Errors.  0x%x.\n",
-						__func__, dma_rx_status);
-				goto exit_geni_serial_isr;
+					"%s.Rx Errors.  0x%x parity:%d\n",
+					__func__, dma_rx_status,
+					uport->icount.parity);
+				drop_rx = true;
+			} else if (dma_rx_status & UART_DMA_RX_BREAK) {
+				uport->icount.brk++;
+				IPC_LOG_MSG(msm_port->ipc_log_misc,
+					"%s.Rx Errors.  0x%x break:%d\n",
+					__func__, dma_rx_status,
+					uport->icount.brk);
 			}
 			if (dma_rx_status & RX_DMA_DONE)
-				msm_geni_serial_handle_dma_rx(uport);
+				msm_geni_serial_handle_dma_rx(uport, drop_rx);
 		}
 	}
 
@@ -1380,9 +1428,7 @@
 	msm_geni_serial_stop_rx(uport);
 	spin_unlock_irqrestore(&uport->lock, flags);
 
-	if (uart_console(uport)) {
-		se_geni_resources_off(&msm_port->serial_rsc);
-	} else {
+	if (!uart_console(uport)) {
 		msm_geni_serial_power_off(uport);
 		if (msm_port->wakeup_irq > 0) {
 			irq_set_irq_wake(msm_port->wakeup_irq, 0);
@@ -2032,6 +2078,21 @@
 		dev_err(uport->dev, "Failed to create dbg dir\n");
 }
 
+static void msm_geni_serial_cons_pm(struct uart_port *uport,
+		unsigned int new_state, unsigned int old_state)
+{
+	struct msm_geni_serial_port *msm_port = GET_DEV_PORT(uport);
+
+	if (unlikely(!uart_console(uport)))
+		return;
+
+	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
+		se_geni_resources_on(&msm_port->serial_rsc);
+	else if (new_state == UART_PM_STATE_OFF &&
+			old_state == UART_PM_STATE_ON)
+		se_geni_resources_off(&msm_port->serial_rsc);
+}
+
 static const struct uart_ops msm_geni_console_pops = {
 	.tx_empty = msm_geni_serial_tx_empty,
 	.stop_tx = msm_geni_serial_stop_tx,
@@ -2048,6 +2109,7 @@
 	.poll_get_char	= msm_geni_serial_get_char,
 	.poll_put_char	= msm_geni_serial_poll_put_char,
 #endif
+	.pm = msm_geni_serial_cons_pm,
 };
 
 static const struct uart_ops msm_geni_serial_pops = {
@@ -2372,7 +2434,6 @@
 
 	if (uart_console(uport) &&
 	    console_suspend_enabled && uport->suspended) {
-		se_geni_resources_on(&port->serial_rsc);
 		uart_resume_port((struct uart_driver *)uport->private_data,
 									uport);
 		disable_irq(uport->irq);
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
new file mode 100644
index 0000000..6a05d5b
--- /dev/null
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -0,0 +1,3808 @@
+/* drivers/serial/msm_serial_hs.c
+ *
+ * MSM 7k High speed uart driver
+ *
+ * Copyright (c) 2008 Google Inc.
+ * Copyright (c) 2007-2017, The Linux Foundation. All rights reserved.
+ * Modified: Nick Pelly <npelly@google.com>
+ *
+ * All source code in this file is licensed under the following license
+ * except where indicated.
+ *
+ * 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.
+ *
+ * Has optional support for uart power management independent of linux
+ * suspend/resume:
+ *
+ * RX wakeup.
+ * UART wakeup can be triggered by RX activity (using a wakeup GPIO on the
+ * UART RX pin). This should only be used if there is not a wakeup
+ * GPIO on the UART CTS, and the first RX byte is known (for example, with the
+ * Bluetooth Texas Instruments HCILL protocol), since the first RX byte will
+ * always be lost. RTS will be asserted even while the UART is off in this mode
+ * of operation. See msm_serial_hs_platform_data.rx_wakeup_irq.
+ */
+
+#include <linux/module.h>
+
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/atomic.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/dma-mapping.h>
+#include <linux/tty_flip.h>
+#include <linux/wait.h>
+#include <linux/sysfs.h>
+#include <linux/stat.h>
+#include <linux/device.h>
+#include <linux/wakelock.h>
+#include <linux/debugfs.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio.h>
+#include <linux/ipc_logging.h>
+#include <asm/irq.h>
+#include <linux/kthread.h>
+
+#include <linux/msm-sps.h>
+#include <linux/platform_data/msm_serial_hs.h>
+#include <linux/msm-bus.h>
+
+#include "msm_serial_hs_hwreg.h"
+#define UART_SPS_CONS_PERIPHERAL 0
+#define UART_SPS_PROD_PERIPHERAL 1
+
+#define IPC_MSM_HS_LOG_STATE_PAGES 2
+#define IPC_MSM_HS_LOG_USER_PAGES 2
+#define IPC_MSM_HS_LOG_DATA_PAGES 3
+#define UART_DMA_DESC_NR 8
+#define BUF_DUMP_SIZE 32
+
+/* If the debug_mask gets set to FATAL_LEV,
+ * a fatal error has happened and further IPC logging
+ * is disabled so that this problem can be detected
+ */
+enum {
+	FATAL_LEV = 0U,
+	ERR_LEV = 1U,
+	WARN_LEV = 2U,
+	INFO_LEV = 3U,
+	DBG_LEV = 4U,
+};
+
+#define MSM_HS_DBG(x...) do { \
+	if (msm_uport->ipc_debug_mask >= DBG_LEV) { \
+		if (msm_uport->ipc_msm_hs_log_ctxt) \
+			ipc_log_string(msm_uport->ipc_msm_hs_log_ctxt, x); \
+	} \
+} while (0)
+
+#define MSM_HS_INFO(x...) do { \
+	if (msm_uport->ipc_debug_mask >= INFO_LEV) {\
+		if (msm_uport->ipc_msm_hs_log_ctxt) \
+			ipc_log_string(msm_uport->ipc_msm_hs_log_ctxt, x); \
+	} \
+} while (0)
+
+/* warnings and errors show up on console always */
+#define MSM_HS_WARN(x...) do { \
+	pr_warn(x); \
+	if (msm_uport->ipc_msm_hs_log_ctxt && \
+			msm_uport->ipc_debug_mask >= WARN_LEV) \
+		ipc_log_string(msm_uport->ipc_msm_hs_log_ctxt, x); \
+} while (0)
+
+/* ERROR condition in the driver sets the hs_serial_debug_mask
+ * to ERR_FATAL level, so that this message can be seen
+ * in IPC logging. Further errors continue to log on the console
+ */
+#define MSM_HS_ERR(x...) do { \
+	pr_err(x); \
+	if (msm_uport->ipc_msm_hs_log_ctxt && \
+			msm_uport->ipc_debug_mask >= ERR_LEV) { \
+		ipc_log_string(msm_uport->ipc_msm_hs_log_ctxt, x); \
+		msm_uport->ipc_debug_mask = FATAL_LEV; \
+	} \
+} while (0)
+
+#define LOG_USR_MSG(ctx, x...) do { \
+	if (ctx) \
+		ipc_log_string(ctx, x); \
+} while (0)
+
+/*
+ * There are 3 different kind of UART Core available on MSM.
+ * High Speed UART (i.e. Legacy HSUART), GSBI based HSUART
+ * and BSLP based HSUART.
+ */
+enum uart_core_type {
+	LEGACY_HSUART,
+	GSBI_HSUART,
+	BLSP_HSUART,
+};
+
+enum flush_reason {
+	FLUSH_NONE,
+	FLUSH_DATA_READY,
+	FLUSH_DATA_INVALID,  /* values after this indicate invalid data */
+	FLUSH_IGNORE,
+	FLUSH_STOP,
+	FLUSH_SHUTDOWN,
+};
+
+/*
+ * SPS data structures to support HSUART with BAM
+ * @sps_pipe - This struct defines BAM pipe descriptor
+ * @sps_connect - This struct defines a connection's end point
+ * @sps_register - This struct defines a event registration parameters
+ */
+struct msm_hs_sps_ep_conn_data {
+	struct sps_pipe *pipe_handle;
+	struct sps_connect config;
+	struct sps_register_event event;
+};
+
+struct msm_hs_tx {
+	bool dma_in_flight;    /* tx dma in progress */
+	enum flush_reason flush;
+	wait_queue_head_t wait;
+	int tx_count;
+	dma_addr_t dma_base;
+	struct kthread_work kwork;
+	struct kthread_worker kworker;
+	struct task_struct *task;
+	struct msm_hs_sps_ep_conn_data cons;
+	struct timer_list tx_timeout_timer;
+	void *ipc_tx_ctxt;
+};
+
+struct msm_hs_rx {
+	enum flush_reason flush;
+	wait_queue_head_t wait;
+	dma_addr_t rbuffer;
+	unsigned char *buffer;
+	unsigned int buffer_pending;
+	struct delayed_work flip_insert_work;
+	struct kthread_work kwork;
+	struct kthread_worker kworker;
+	struct task_struct *task;
+	struct msm_hs_sps_ep_conn_data prod;
+	unsigned long queued_flag;
+	unsigned long pending_flag;
+	int rx_inx;
+	struct sps_iovec iovec[UART_DMA_DESC_NR]; /* track descriptors */
+	void *ipc_rx_ctxt;
+};
+enum buffer_states {
+	NONE_PENDING = 0x0,
+	FIFO_OVERRUN = 0x1,
+	PARITY_ERROR = 0x2,
+	CHARS_NORMAL = 0x4,
+};
+
+enum msm_hs_pm_state {
+	MSM_HS_PM_ACTIVE,
+	MSM_HS_PM_SUSPENDED,
+	MSM_HS_PM_SYS_SUSPENDED,
+};
+
+/* optional low power wakeup, typically on a GPIO RX irq */
+struct msm_hs_wakeup {
+	int irq;  /* < 0 indicates low power wakeup disabled */
+	unsigned char ignore;  /* bool */
+
+	/* bool: inject char into rx tty on wakeup */
+	bool inject_rx;
+	unsigned char rx_to_inject;
+	bool enabled;
+	bool freed;
+};
+
+struct msm_hs_port {
+	struct uart_port uport;
+	unsigned long imr_reg;  /* shadow value of UARTDM_IMR */
+	struct clk *clk;
+	struct clk *pclk;
+	struct msm_hs_tx tx;
+	struct msm_hs_rx rx;
+	atomic_t resource_count;
+	struct msm_hs_wakeup wakeup;
+
+	struct dentry *loopback_dir;
+	struct work_struct clock_off_w; /* work for actual clock off */
+	struct workqueue_struct *hsuart_wq; /* hsuart workqueue */
+	struct mutex mtx; /* resource access mutex */
+	enum uart_core_type uart_type;
+	unsigned long bam_handle;
+	resource_size_t bam_mem;
+	int bam_irq;
+	unsigned char __iomem *bam_base;
+	unsigned int bam_tx_ep_pipe_index;
+	unsigned int bam_rx_ep_pipe_index;
+	/* struct sps_event_notify is an argument passed when triggering a
+	 * callback event object registered for an SPS connection end point.
+	 */
+	struct sps_event_notify notify;
+	/* bus client handler */
+	u32 bus_perf_client;
+	/* BLSP UART required BUS Scaling data */
+	struct msm_bus_scale_pdata *bus_scale_table;
+	bool rx_bam_inprogress;
+	wait_queue_head_t bam_disconnect_wait;
+	bool use_pinctrl;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *gpio_state_active;
+	struct pinctrl_state *gpio_state_suspend;
+	bool flow_control;
+	enum msm_hs_pm_state pm_state;
+	atomic_t client_count;
+	bool obs; /* out of band sleep flag */
+	atomic_t client_req_state;
+	void *ipc_msm_hs_log_ctxt;
+	void *ipc_msm_hs_pwr_ctxt;
+	int ipc_debug_mask;
+};
+
+static const struct of_device_id msm_hs_match_table[] = {
+	{ .compatible = "qcom,msm-hsuart-v14"},
+	{}
+};
+
+
+#define MSM_UARTDM_BURST_SIZE 16   /* DM burst size (in bytes) */
+#define UARTDM_TX_BUF_SIZE UART_XMIT_SIZE
+#define UARTDM_RX_BUF_SIZE 512
+#define RETRY_TIMEOUT 5
+#define UARTDM_NR 256
+#define BAM_PIPE_MIN 0
+#define BAM_PIPE_MAX 11
+#define BUS_SCALING 1
+#define BUS_RESET 0
+#define RX_FLUSH_COMPLETE_TIMEOUT 300 /* In jiffies */
+#define BLSP_UART_CLK_FMAX 63160000
+
+static struct dentry *debug_base;
+static struct platform_driver msm_serial_hs_platform_driver;
+static struct uart_driver msm_hs_driver;
+static const struct uart_ops msm_hs_ops;
+static void msm_hs_start_rx_locked(struct uart_port *uport);
+static void msm_serial_hs_rx_work(struct kthread_work *work);
+static void flip_insert_work(struct work_struct *work);
+static void msm_hs_bus_voting(struct msm_hs_port *msm_uport, unsigned int vote);
+static struct msm_hs_port *msm_hs_get_hs_port(int port_index);
+static void msm_hs_queue_rx_desc(struct msm_hs_port *msm_uport);
+static int disconnect_rx_endpoint(struct msm_hs_port *msm_uport);
+static int msm_hs_pm_resume(struct device *dev);
+
+#define UARTDM_TO_MSM(uart_port) \
+	container_of((uart_port), struct msm_hs_port, uport)
+
+static int msm_hs_ioctl(struct uart_port *uport, unsigned int cmd,
+						unsigned long arg)
+{
+	int ret = 0, state = 1;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	if (!msm_uport)
+		return -ENODEV;
+
+	switch (cmd) {
+	case MSM_ENABLE_UART_CLOCK: {
+		ret = msm_hs_request_clock_on(&msm_uport->uport);
+		break;
+	}
+	case MSM_DISABLE_UART_CLOCK: {
+		ret = msm_hs_request_clock_off(&msm_uport->uport);
+		break;
+	}
+	case MSM_GET_UART_CLOCK_STATUS: {
+		/* Return value 0 - UART CLOCK is OFF
+		 * Return value 1 - UART CLOCK is ON
+		 */
+
+		if (msm_uport->pm_state != MSM_HS_PM_ACTIVE)
+			state = 0;
+		ret = state;
+		MSM_HS_INFO("%s():GET UART CLOCK STATUS: cmd=%d state=%d\n",
+			__func__, cmd, state);
+		break;
+	}
+	default: {
+		MSM_HS_INFO("%s():Unknown cmd specified: cmd=%d\n", __func__,
+			   cmd);
+		ret = -ENOIOCTLCMD;
+		break;
+	}
+	}
+
+	return ret;
+}
+
+/*
+ * This function is called initially during probe and then
+ * through the runtime PM framework. The function directly calls
+ * resource APIs to enable them.
+ */
+
+static int msm_hs_clk_bus_vote(struct msm_hs_port *msm_uport)
+{
+	int rc = 0;
+
+	msm_hs_bus_voting(msm_uport, BUS_SCALING);
+	/* Turn on core clk and iface clk */
+	if (msm_uport->pclk) {
+		rc = clk_prepare_enable(msm_uport->pclk);
+		if (rc) {
+			dev_err(msm_uport->uport.dev,
+				"%s: Could not turn on pclk [%d]\n",
+				__func__, rc);
+			goto busreset;
+		}
+	}
+	rc = clk_prepare_enable(msm_uport->clk);
+	if (rc) {
+		dev_err(msm_uport->uport.dev,
+			"%s: Could not turn on core clk [%d]\n",
+			__func__, rc);
+		goto core_unprepare;
+	}
+	MSM_HS_DBG("%s: Clock ON successful\n", __func__);
+	return rc;
+core_unprepare:
+	clk_disable_unprepare(msm_uport->pclk);
+busreset:
+	msm_hs_bus_voting(msm_uport, BUS_RESET);
+	return rc;
+}
+
+/*
+ * This function is called initially during probe and then
+ * through the runtime PM framework. The function directly calls
+ * resource apis to disable them.
+ */
+static void msm_hs_clk_bus_unvote(struct msm_hs_port *msm_uport)
+{
+	clk_disable_unprepare(msm_uport->clk);
+	if (msm_uport->pclk)
+		clk_disable_unprepare(msm_uport->pclk);
+	msm_hs_bus_voting(msm_uport, BUS_RESET);
+	MSM_HS_DBG("%s: Clock OFF successful\n", __func__);
+}
+
+ /* Remove vote for resources when done */
+static void msm_hs_resource_unvote(struct msm_hs_port *msm_uport)
+{
+	struct uart_port *uport = &(msm_uport->uport);
+	int rc = atomic_read(&msm_uport->resource_count);
+
+	MSM_HS_DBG("%s(): power usage count %d", __func__, rc);
+	if (rc <= 0) {
+		MSM_HS_WARN("%s(): rc zero, bailing\n", __func__);
+		WARN_ON(1);
+		return;
+	}
+	atomic_dec(&msm_uport->resource_count);
+	pm_runtime_mark_last_busy(uport->dev);
+	pm_runtime_put_autosuspend(uport->dev);
+}
+
+ /* Vote for resources before accessing them */
+static void msm_hs_resource_vote(struct msm_hs_port *msm_uport)
+{
+	int ret;
+	struct uart_port *uport = &(msm_uport->uport);
+
+	ret = pm_runtime_get_sync(uport->dev);
+	if (ret < 0 || msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s:%s runtime callback not invoked ret:%d st:%d",
+			__func__, dev_name(uport->dev), ret,
+					msm_uport->pm_state);
+		msm_hs_pm_resume(uport->dev);
+	}
+	atomic_inc(&msm_uport->resource_count);
+}
+
+/* Check if the uport line number matches with user id stored in pdata.
+ * User id information is stored during initialization. This function
+ * ensues that the same device is selected
+ */
+
+static struct msm_hs_port *get_matching_hs_port(struct platform_device *pdev)
+{
+	struct msm_serial_hs_platform_data *pdata = pdev->dev.platform_data;
+	struct msm_hs_port *msm_uport = msm_hs_get_hs_port(pdev->id);
+
+	if ((!msm_uport) || (msm_uport->uport.line != pdev->id
+	   && msm_uport->uport.line != pdata->userid)) {
+		pr_err("uport line number mismatch!");
+		WARN_ON(1);
+		return NULL;
+	}
+
+	return msm_uport;
+}
+
+static ssize_t show_clock(struct device *dev, struct device_attribute *attr,
+			  char *buf)
+{
+	int state = 1;
+	ssize_t ret = 0;
+	struct platform_device *pdev = container_of(dev, struct
+						    platform_device, dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+
+	/* This check should not fail */
+	if (msm_uport) {
+		if (msm_uport->pm_state != MSM_HS_PM_ACTIVE)
+			state = 0;
+		ret = snprintf(buf, PAGE_SIZE, "%d\n", state);
+	}
+	return ret;
+}
+
+static ssize_t set_clock(struct device *dev, struct device_attribute *attr,
+			 const char *buf, size_t count)
+{
+	int state;
+	ssize_t ret = 0;
+	struct platform_device *pdev = container_of(dev, struct
+						    platform_device, dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+
+	/* This check should not fail */
+	if (msm_uport) {
+		state = buf[0] - '0';
+		switch (state) {
+		case 0:
+			MSM_HS_DBG("%s: Request clock OFF\n", __func__);
+			msm_hs_request_clock_off(&msm_uport->uport);
+			ret = count;
+			break;
+		case 1:
+			MSM_HS_DBG("%s: Request clock ON\n", __func__);
+			msm_hs_request_clock_on(&msm_uport->uport);
+			ret = count;
+			break;
+		default:
+			ret = -EINVAL;
+		}
+	}
+	return ret;
+}
+
+static DEVICE_ATTR(clock, 0644, show_clock, set_clock);
+
+static ssize_t show_debug_mask(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	ssize_t ret = 0;
+	struct platform_device *pdev = container_of(dev, struct
+						    platform_device, dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+
+	/* This check should not fail */
+	if (msm_uport)
+		ret = snprintf(buf, sizeof(int), "%u\n",
+					msm_uport->ipc_debug_mask);
+	return ret;
+}
+
+static ssize_t set_debug_mask(struct device *dev,
+			struct device_attribute *attr,
+			const char *buf, size_t count)
+{
+	struct platform_device *pdev = container_of(dev, struct
+						    platform_device, dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+
+	/* This check should not fail */
+	if (msm_uport) {
+		msm_uport->ipc_debug_mask = buf[0] - '0';
+		if (msm_uport->ipc_debug_mask < FATAL_LEV ||
+				msm_uport->ipc_debug_mask > DBG_LEV) {
+			/* set to default level */
+			msm_uport->ipc_debug_mask = INFO_LEV;
+			MSM_HS_ERR("Range is 0 to 4;Set to default level 3\n");
+			return -EINVAL;
+		}
+	}
+	return count;
+}
+
+static DEVICE_ATTR(debug_mask, 0644, show_debug_mask,
+							set_debug_mask);
+
+static inline bool is_use_low_power_wakeup(struct msm_hs_port *msm_uport)
+{
+	return msm_uport->wakeup.irq > 0;
+}
+
+static void msm_hs_bus_voting(struct msm_hs_port *msm_uport, unsigned int vote)
+{
+	int ret;
+
+	if (msm_uport->bus_perf_client) {
+		MSM_HS_DBG("Bus voting:%d\n", vote);
+		ret = msm_bus_scale_client_update_request(
+				msm_uport->bus_perf_client, vote);
+		if (ret)
+			MSM_HS_ERR("%s(): Failed for Bus voting: %d\n",
+							__func__, vote);
+	}
+}
+
+static inline unsigned int msm_hs_read(struct uart_port *uport,
+				       unsigned int index)
+{
+	return readl_relaxed(uport->membase + index);
+}
+
+static inline void msm_hs_write(struct uart_port *uport, unsigned int index,
+				 unsigned int value)
+{
+	writel_relaxed(value, uport->membase + index);
+}
+
+static int sps_rx_disconnect(struct sps_pipe *sps_pipe_handler)
+{
+	struct sps_connect config;
+	int ret;
+
+	ret = sps_get_config(sps_pipe_handler, &config);
+	if (ret) {
+		pr_err("%s: sps_get_config() failed ret %d\n", __func__, ret);
+		return ret;
+	}
+	config.options |= SPS_O_POLL;
+	ret = sps_set_config(sps_pipe_handler, &config);
+	if (ret) {
+		pr_err("%s: sps_set_config() failed ret %d\n", __func__, ret);
+		return ret;
+	}
+	return sps_disconnect(sps_pipe_handler);
+}
+
+static void hex_dump_ipc(struct msm_hs_port *msm_uport, void *ipc_ctx,
+			char *prefix, char *string, u64 addr, int size)
+
+{
+	char buf[(BUF_DUMP_SIZE * 3) + 2];
+	int len = 0;
+
+	len = min(size, BUF_DUMP_SIZE);
+	/*
+	 * Print upto 32 data bytes, 32 bytes per line, 1 byte at a time and
+	 * don't include the ASCII text at the end of the buffer.
+	 */
+	hex_dump_to_buffer(string, len, 32, 1, buf, sizeof(buf), false);
+	ipc_log_string(ipc_ctx, "%s[0x%.10x:%d] : %s", prefix,
+					(unsigned int)addr, size, buf);
+}
+
+/*
+ * This API read and provides UART Core registers information.
+ */
+static void dump_uart_hs_registers(struct msm_hs_port *msm_uport)
+{
+	struct uart_port *uport = &(msm_uport->uport);
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_INFO("%s:Failed clocks are off, resource_count %d",
+			__func__, atomic_read(&msm_uport->resource_count));
+		return;
+	}
+
+	MSM_HS_DBG(
+	"MR1:%x MR2:%x TFWR:%x RFWR:%x DMEN:%x IMR:%x MISR:%x NCF_TX:%x\n",
+	msm_hs_read(uport, UART_DM_MR1),
+	msm_hs_read(uport, UART_DM_MR2),
+	msm_hs_read(uport, UART_DM_TFWR),
+	msm_hs_read(uport, UART_DM_RFWR),
+	msm_hs_read(uport, UART_DM_DMEN),
+	msm_hs_read(uport, UART_DM_IMR),
+	msm_hs_read(uport, UART_DM_MISR),
+	msm_hs_read(uport, UART_DM_NCF_TX));
+	MSM_HS_INFO("SR:%x ISR:%x DMRX:%x RX_SNAP:%x TXFS:%x RXFS:%x\n",
+	msm_hs_read(uport, UART_DM_SR),
+	msm_hs_read(uport, UART_DM_ISR),
+	msm_hs_read(uport, UART_DM_DMRX),
+	msm_hs_read(uport, UART_DM_RX_TOTAL_SNAP),
+	msm_hs_read(uport, UART_DM_TXFS),
+	msm_hs_read(uport, UART_DM_RXFS));
+	MSM_HS_DBG("rx.flush:%u\n", msm_uport->rx.flush);
+}
+
+static int msm_serial_loopback_enable_set(void *data, u64 val)
+{
+	struct msm_hs_port *msm_uport = data;
+	struct uart_port *uport = &(msm_uport->uport);
+	unsigned long flags;
+	int ret = 0;
+
+	msm_hs_resource_vote(msm_uport);
+
+	if (val) {
+		spin_lock_irqsave(&uport->lock, flags);
+		ret = msm_hs_read(uport, UART_DM_MR2);
+		ret |= (UARTDM_MR2_LOOP_MODE_BMSK |
+			UARTDM_MR2_RFR_CTS_LOOP_MODE_BMSK);
+		msm_hs_write(uport, UART_DM_MR2, ret);
+		spin_unlock_irqrestore(&uport->lock, flags);
+	} else {
+		spin_lock_irqsave(&uport->lock, flags);
+		ret = msm_hs_read(uport, UART_DM_MR2);
+		ret &= ~(UARTDM_MR2_LOOP_MODE_BMSK |
+			UARTDM_MR2_RFR_CTS_LOOP_MODE_BMSK);
+		msm_hs_write(uport, UART_DM_MR2, ret);
+		spin_unlock_irqrestore(&uport->lock, flags);
+	}
+	/* Calling CLOCK API. Hence mb() requires here. */
+	mb();
+
+	msm_hs_resource_unvote(msm_uport);
+	return 0;
+}
+
+static int msm_serial_loopback_enable_get(void *data, u64 *val)
+{
+	struct msm_hs_port *msm_uport = data;
+	struct uart_port *uport = &(msm_uport->uport);
+	unsigned long flags;
+	int ret = 0;
+
+	msm_hs_resource_vote(msm_uport);
+
+	spin_lock_irqsave(&uport->lock, flags);
+	ret = msm_hs_read(&msm_uport->uport, UART_DM_MR2);
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	msm_hs_resource_unvote(msm_uport);
+
+	*val = (ret & UARTDM_MR2_LOOP_MODE_BMSK) ? 1 : 0;
+
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(loopback_enable_fops, msm_serial_loopback_enable_get,
+			msm_serial_loopback_enable_set, "%llu\n");
+
+/*
+ * msm_serial_hs debugfs node: <debugfs_root>/msm_serial_hs/loopback.<id>
+ * writing 1 turns on internal loopback mode in HW. Useful for automation
+ * test scripts.
+ * writing 0 disables the internal loopback mode. Default is disabled.
+ */
+static void msm_serial_debugfs_init(struct msm_hs_port *msm_uport,
+					   int id)
+{
+	char node_name[15];
+
+	snprintf(node_name, sizeof(node_name), "loopback.%d", id);
+	msm_uport->loopback_dir = debugfs_create_file(node_name,
+						0644,
+						debug_base,
+						msm_uport,
+						&loopback_enable_fops);
+
+	if (IS_ERR_OR_NULL(msm_uport->loopback_dir))
+		MSM_HS_ERR("%s(): Cannot create loopback.%d debug entry",
+							__func__, id);
+}
+
+static int msm_hs_remove(struct platform_device *pdev)
+{
+
+	struct msm_hs_port *msm_uport;
+	struct device *dev;
+
+	if (pdev->id < 0 || pdev->id >= UARTDM_NR) {
+		pr_err("Invalid plaform device ID = %d\n", pdev->id);
+		return -EINVAL;
+	}
+
+	msm_uport = get_matching_hs_port(pdev);
+	if (!msm_uport)
+		return -EINVAL;
+
+	dev = msm_uport->uport.dev;
+	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_clock.attr);
+	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_debug_mask.attr);
+	debugfs_remove(msm_uport->loopback_dir);
+
+	dma_free_coherent(msm_uport->uport.dev,
+			UART_DMA_DESC_NR * UARTDM_RX_BUF_SIZE,
+			msm_uport->rx.buffer, msm_uport->rx.rbuffer);
+
+	msm_uport->rx.buffer = NULL;
+	msm_uport->rx.rbuffer = 0;
+
+	destroy_workqueue(msm_uport->hsuart_wq);
+	mutex_destroy(&msm_uport->mtx);
+
+	uart_remove_one_port(&msm_hs_driver, &msm_uport->uport);
+	clk_put(msm_uport->clk);
+	if (msm_uport->pclk)
+		clk_put(msm_uport->pclk);
+
+	iounmap(msm_uport->uport.membase);
+
+	return 0;
+}
+
+
+/* Connect a UART peripheral's SPS endpoint(consumer endpoint)
+ *
+ * Also registers a SPS callback function for the consumer
+ * process with the SPS driver
+ *
+ * @uport - Pointer to uart uport structure
+ *
+ * @return - 0 if successful else negative value.
+ *
+ */
+
+static int msm_hs_spsconnect_tx(struct msm_hs_port *msm_uport)
+{
+	int ret;
+	struct uart_port *uport = &msm_uport->uport;
+	struct msm_hs_tx *tx = &msm_uport->tx;
+	struct sps_pipe *sps_pipe_handle = tx->cons.pipe_handle;
+	struct sps_connect *sps_config = &tx->cons.config;
+	struct sps_register_event *sps_event = &tx->cons.event;
+	unsigned long flags;
+	unsigned int data;
+
+	if (tx->flush != FLUSH_SHUTDOWN) {
+		MSM_HS_ERR("%s:Invalid flush state:%d\n", __func__, tx->flush);
+		return 0;
+	}
+
+	/* Establish connection between peripheral and memory endpoint */
+	ret = sps_connect(sps_pipe_handle, sps_config);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: sps_connect() failed for tx!!\n"
+		"pipe_handle=0x%p ret=%d", sps_pipe_handle, ret);
+		return ret;
+	}
+	/* Register callback event for EOT (End of transfer) event. */
+	ret = sps_register_event(sps_pipe_handle, sps_event);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: sps_connect() failed for tx!!\n"
+		"pipe_handle=0x%p ret=%d", sps_pipe_handle, ret);
+		goto reg_event_err;
+	}
+
+	spin_lock_irqsave(&(msm_uport->uport.lock), flags);
+	msm_uport->tx.flush = FLUSH_STOP;
+	spin_unlock_irqrestore(&(msm_uport->uport.lock), flags);
+
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	/* Enable UARTDM Tx BAM Interface */
+	data |= UARTDM_TX_BAM_ENABLE_BMSK;
+	msm_hs_write(uport, UART_DM_DMEN, data);
+
+	msm_hs_write(uport, UART_DM_CR, RESET_TX);
+	msm_hs_write(uport, UART_DM_CR, START_TX_BAM_IFC);
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_TX_EN_BMSK);
+
+	MSM_HS_DBG("%s(): TX Connect", __func__);
+	return 0;
+
+reg_event_err:
+	sps_disconnect(sps_pipe_handle);
+	return ret;
+}
+
+/* Connect a UART peripheral's SPS endpoint(producer endpoint)
+ *
+ * Also registers a SPS callback function for the producer
+ * process with the SPS driver
+ *
+ * @uport - Pointer to uart uport structure
+ *
+ * @return - 0 if successful else negative value.
+ *
+ */
+
+static int msm_hs_spsconnect_rx(struct uart_port *uport)
+{
+	int ret;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	struct sps_pipe *sps_pipe_handle = rx->prod.pipe_handle;
+	struct sps_connect *sps_config = &rx->prod.config;
+	struct sps_register_event *sps_event = &rx->prod.event;
+	unsigned long flags;
+
+	/* Establish connection between peripheral and memory endpoint */
+	ret = sps_connect(sps_pipe_handle, sps_config);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: sps_connect() failed for rx!!\n"
+		"pipe_handle=0x%p ret=%d", sps_pipe_handle, ret);
+		return ret;
+	}
+	/* Register callback event for DESC_DONE event. */
+	ret = sps_register_event(sps_pipe_handle, sps_event);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: sps_connect() failed for rx!!\n"
+		"pipe_handle=0x%p ret=%d", sps_pipe_handle, ret);
+		goto reg_event_err;
+	}
+	spin_lock_irqsave(&uport->lock, flags);
+	if (msm_uport->rx.pending_flag)
+		MSM_HS_WARN("%s(): Buffers may be pending 0x%lx",
+		__func__, msm_uport->rx.pending_flag);
+	msm_uport->rx.queued_flag = 0;
+	msm_uport->rx.pending_flag = 0;
+	msm_uport->rx.rx_inx = 0;
+	msm_uport->rx.flush = FLUSH_STOP;
+	spin_unlock_irqrestore(&uport->lock, flags);
+	MSM_HS_DBG("%s(): RX Connect\n", __func__);
+	return 0;
+
+reg_event_err:
+	sps_disconnect(sps_pipe_handle);
+	return ret;
+}
+
+/*
+ * programs the UARTDM_CSR register with correct bit rates
+ *
+ * Interrupts should be disabled before we are called, as
+ * we modify Set Baud rate
+ * Set receive stale interrupt level, dependent on Bit Rate
+ * Goal is to have around 8 ms before indicate stale.
+ * roundup (((Bit Rate * .008) / 10) + 1
+ */
+static void msm_hs_set_bps_locked(struct uart_port *uport,
+			       unsigned int bps)
+{
+	unsigned long rxstale;
+	unsigned long data;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	switch (bps) {
+	case 300:
+		msm_hs_write(uport, UART_DM_CSR, 0x00);
+		rxstale = 1;
+		break;
+	case 600:
+		msm_hs_write(uport, UART_DM_CSR, 0x11);
+		rxstale = 1;
+		break;
+	case 1200:
+		msm_hs_write(uport, UART_DM_CSR, 0x22);
+		rxstale = 1;
+		break;
+	case 2400:
+		msm_hs_write(uport, UART_DM_CSR, 0x33);
+		rxstale = 1;
+		break;
+	case 4800:
+		msm_hs_write(uport, UART_DM_CSR, 0x44);
+		rxstale = 1;
+		break;
+	case 9600:
+		msm_hs_write(uport, UART_DM_CSR, 0x55);
+		rxstale = 2;
+		break;
+	case 14400:
+		msm_hs_write(uport, UART_DM_CSR, 0x66);
+		rxstale = 3;
+		break;
+	case 19200:
+		msm_hs_write(uport, UART_DM_CSR, 0x77);
+		rxstale = 4;
+		break;
+	case 28800:
+		msm_hs_write(uport, UART_DM_CSR, 0x88);
+		rxstale = 6;
+		break;
+	case 38400:
+		msm_hs_write(uport, UART_DM_CSR, 0x99);
+		rxstale = 8;
+		break;
+	case 57600:
+		msm_hs_write(uport, UART_DM_CSR, 0xaa);
+		rxstale = 16;
+		break;
+	case 76800:
+		msm_hs_write(uport, UART_DM_CSR, 0xbb);
+		rxstale = 16;
+		break;
+	case 115200:
+		msm_hs_write(uport, UART_DM_CSR, 0xcc);
+		rxstale = 31;
+		break;
+	case 230400:
+		msm_hs_write(uport, UART_DM_CSR, 0xee);
+		rxstale = 31;
+		break;
+	case 460800:
+		msm_hs_write(uport, UART_DM_CSR, 0xff);
+		rxstale = 31;
+		break;
+	case 4000000:
+	case 3686400:
+	case 3200000:
+	case 3500000:
+	case 3000000:
+	case 2500000:
+	case 2000000:
+	case 1500000:
+	case 1152000:
+	case 1000000:
+	case 921600:
+		msm_hs_write(uport, UART_DM_CSR, 0xff);
+		rxstale = 31;
+		break;
+	default:
+		msm_hs_write(uport, UART_DM_CSR, 0xff);
+		/* default to 9600 */
+		bps = 9600;
+		rxstale = 2;
+		break;
+	}
+	/*
+	 * uart baud rate depends on CSR and MND Values
+	 * we are updating CSR before and then calling
+	 * clk_set_rate which updates MND Values. Hence
+	 * dsb requires here.
+	 */
+	mb();
+	if (bps > 460800) {
+		uport->uartclk = bps * 16;
+		/* BLSP based UART supports maximum clock frequency
+		 * of 63.16 Mhz. With this (63.16 Mhz) clock frequency
+		 * UART can support baud rate of 3.94 Mbps which is
+		 * equivalent to 4 Mbps.
+		 * UART hardware is robust enough to handle this
+		 * deviation to achieve baud rate ~4 Mbps.
+		 */
+		if (bps == 4000000)
+			uport->uartclk = BLSP_UART_CLK_FMAX;
+	} else {
+		uport->uartclk = 7372800;
+	}
+
+	if (clk_set_rate(msm_uport->clk, uport->uartclk)) {
+		MSM_HS_WARN("Error setting clock rate on UART\n");
+		WARN_ON(1);
+	}
+
+	data = rxstale & UARTDM_IPR_STALE_LSB_BMSK;
+	data |= UARTDM_IPR_STALE_TIMEOUT_MSB_BMSK & (rxstale << 2);
+
+	msm_hs_write(uport, UART_DM_IPR, data);
+	/*
+	 * It is suggested to do reset of transmitter and receiver after
+	 * changing any protocol configuration. Here Baud rate and stale
+	 * timeout are getting updated. Hence reset transmitter and receiver.
+	 */
+	msm_hs_write(uport, UART_DM_CR, RESET_TX);
+	msm_hs_write(uport, UART_DM_CR, RESET_RX);
+}
+
+
+static void msm_hs_set_std_bps_locked(struct uart_port *uport,
+			       unsigned int bps)
+{
+	unsigned long rxstale;
+	unsigned long data;
+
+	switch (bps) {
+	case 9600:
+		msm_hs_write(uport, UART_DM_CSR, 0x99);
+		rxstale = 2;
+		break;
+	case 14400:
+		msm_hs_write(uport, UART_DM_CSR, 0xaa);
+		rxstale = 3;
+		break;
+	case 19200:
+		msm_hs_write(uport, UART_DM_CSR, 0xbb);
+		rxstale = 4;
+		break;
+	case 28800:
+		msm_hs_write(uport, UART_DM_CSR, 0xcc);
+		rxstale = 6;
+		break;
+	case 38400:
+		msm_hs_write(uport, UART_DM_CSR, 0xdd);
+		rxstale = 8;
+		break;
+	case 57600:
+		msm_hs_write(uport, UART_DM_CSR, 0xee);
+		rxstale = 16;
+		break;
+	case 115200:
+		msm_hs_write(uport, UART_DM_CSR, 0xff);
+		rxstale = 31;
+		break;
+	default:
+		msm_hs_write(uport, UART_DM_CSR, 0x99);
+		/* default to 9600 */
+		bps = 9600;
+		rxstale = 2;
+		break;
+	}
+
+	data = rxstale & UARTDM_IPR_STALE_LSB_BMSK;
+	data |= UARTDM_IPR_STALE_TIMEOUT_MSB_BMSK & (rxstale << 2);
+
+	msm_hs_write(uport, UART_DM_IPR, data);
+}
+
+static void msm_hs_enable_flow_control(struct uart_port *uport, bool override)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	unsigned int data;
+
+	if (msm_uport->flow_control || override) {
+		/* Enable RFR line */
+		msm_hs_write(uport, UART_DM_CR, RFR_LOW);
+		/* Enable auto RFR */
+		data = msm_hs_read(uport, UART_DM_MR1);
+		data |= UARTDM_MR1_RX_RDY_CTL_BMSK;
+		msm_hs_write(uport, UART_DM_MR1, data);
+		/* Ensure register IO completion */
+		mb();
+	}
+}
+
+static void msm_hs_disable_flow_control(struct uart_port *uport, bool override)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	unsigned int data;
+
+	/*
+	 * Clear the Rx Ready Ctl bit - This ensures that
+	 * flow control lines stop the other side from sending
+	 * data while we change the parameters
+	 */
+
+	if (msm_uport->flow_control || override) {
+		data = msm_hs_read(uport, UART_DM_MR1);
+		/* disable auto ready-for-receiving */
+		data &= ~UARTDM_MR1_RX_RDY_CTL_BMSK;
+		msm_hs_write(uport, UART_DM_MR1, data);
+		/* Disable RFR line */
+		msm_hs_write(uport, UART_DM_CR, RFR_HIGH);
+		/* Ensure register IO completion */
+		mb();
+	}
+}
+
+/*
+ * termios :  new ktermios
+ * oldtermios:  old ktermios previous setting
+ *
+ * Configure the serial port
+ */
+static void msm_hs_set_termios(struct uart_port *uport,
+				   struct ktermios *termios,
+				   struct ktermios *oldtermios)
+{
+	unsigned int bps;
+	unsigned long data;
+	unsigned int c_cflag = termios->c_cflag;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	/**
+	 * set_termios can be invoked from the framework when
+	 * the clocks are off and the client has not had a chance
+	 * to turn them on. Make sure that they are on
+	 */
+	msm_hs_resource_vote(msm_uport);
+	mutex_lock(&msm_uport->mtx);
+	msm_hs_write(uport, UART_DM_IMR, 0);
+
+	msm_hs_disable_flow_control(uport, true);
+
+	/*
+	 * Disable Rx channel of UARTDM
+	 * DMA Rx Stall happens if enqueue and flush of Rx command happens
+	 * concurrently. Hence before changing the baud rate/protocol
+	 * configuration and sending flush command to ADM, disable the Rx
+	 * channel of UARTDM.
+	 * Note: should not reset the receiver here immediately as it is not
+	 * suggested to do disable/reset or reset/disable at the same time.
+	 */
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	/* Disable UARTDM RX BAM Interface */
+	data &= ~UARTDM_RX_BAM_ENABLE_BMSK;
+	msm_hs_write(uport, UART_DM_DMEN, data);
+
+	/*
+	 * Reset RX and TX.
+	 * Resetting the RX enables it, therefore we must reset and disable.
+	 */
+	msm_hs_write(uport, UART_DM_CR, RESET_RX);
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_RX_DISABLE_BMSK);
+	msm_hs_write(uport, UART_DM_CR, RESET_TX);
+
+	/* 300 is the minimum baud support by the driver  */
+	bps = uart_get_baud_rate(uport, termios, oldtermios, 200, 4000000);
+
+	/* Temporary remapping  200 BAUD to 3.2 mbps */
+	if (bps == 200)
+		bps = 3200000;
+
+	uport->uartclk = clk_get_rate(msm_uport->clk);
+	if (!uport->uartclk)
+		msm_hs_set_std_bps_locked(uport, bps);
+	else
+		msm_hs_set_bps_locked(uport, bps);
+
+	data = msm_hs_read(uport, UART_DM_MR2);
+	data &= ~UARTDM_MR2_PARITY_MODE_BMSK;
+	/* set parity */
+	if (c_cflag & PARENB) {
+		if (c_cflag & PARODD)
+			data |= ODD_PARITY;
+		else if (c_cflag & CMSPAR)
+			data |= SPACE_PARITY;
+		else
+			data |= EVEN_PARITY;
+	}
+
+	/* Set bits per char */
+	data &= ~UARTDM_MR2_BITS_PER_CHAR_BMSK;
+
+	switch (c_cflag & CSIZE) {
+	case CS5:
+		data |= FIVE_BPC;
+		break;
+	case CS6:
+		data |= SIX_BPC;
+		break;
+	case CS7:
+		data |= SEVEN_BPC;
+		break;
+	default:
+		data |= EIGHT_BPC;
+		break;
+	}
+	/* stop bits */
+	if (c_cflag & CSTOPB) {
+		data |= STOP_BIT_TWO;
+	} else {
+		/* otherwise 1 stop bit */
+		data |= STOP_BIT_ONE;
+	}
+	data |= UARTDM_MR2_ERROR_MODE_BMSK;
+	/* write parity/bits per char/stop bit configuration */
+	msm_hs_write(uport, UART_DM_MR2, data);
+
+	uport->ignore_status_mask = termios->c_iflag & INPCK;
+	uport->ignore_status_mask |= termios->c_iflag & IGNPAR;
+	uport->ignore_status_mask |= termios->c_iflag & IGNBRK;
+
+	uport->read_status_mask = (termios->c_cflag & CREAD);
+
+	/* Set Transmit software time out */
+	uart_update_timeout(uport, c_cflag, bps);
+
+	/* Enable UARTDM Rx BAM Interface */
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	data |= UARTDM_RX_BAM_ENABLE_BMSK;
+	msm_hs_write(uport, UART_DM_DMEN, data);
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_RX_EN_BMSK);
+	/* Issue TX,RX BAM Start IFC command */
+	msm_hs_write(uport, UART_DM_CR, START_TX_BAM_IFC);
+	msm_hs_write(uport, UART_DM_CR, START_RX_BAM_IFC);
+	/* Ensure Register Writes Complete */
+	mb();
+
+	/* Configure HW flow control
+	 * UART Core would see status of CTS line when it is sending data
+	 * to remote uart to confirm that it can receive or not.
+	 * UART Core would trigger RFR if it is not having any space with
+	 * RX FIFO.
+	 */
+	/* Pulling RFR line high */
+	msm_hs_write(uport, UART_DM_CR, RFR_LOW);
+	data = msm_hs_read(uport, UART_DM_MR1);
+	data &= ~(UARTDM_MR1_CTS_CTL_BMSK | UARTDM_MR1_RX_RDY_CTL_BMSK);
+	if (c_cflag & CRTSCTS) {
+		data |= UARTDM_MR1_CTS_CTL_BMSK;
+		data |= UARTDM_MR1_RX_RDY_CTL_BMSK;
+		msm_uport->flow_control = true;
+	}
+	msm_hs_write(uport, UART_DM_MR1, data);
+	MSM_HS_INFO("%s: Cflags 0x%x Baud %u\n", __func__, c_cflag, bps);
+
+	mutex_unlock(&msm_uport->mtx);
+
+	msm_hs_resource_unvote(msm_uport);
+}
+
+/*
+ *  Standard API, Transmitter
+ *  Any character in the transmit shift register is sent
+ */
+unsigned int msm_hs_tx_empty(struct uart_port *uport)
+{
+	unsigned int data;
+	unsigned int isr;
+	unsigned int ret = 0;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_hs_resource_vote(msm_uport);
+	data = msm_hs_read(uport, UART_DM_SR);
+	isr = msm_hs_read(uport, UART_DM_ISR);
+	msm_hs_resource_unvote(msm_uport);
+	MSM_HS_INFO("%s(): SR:0x%x ISR:0x%x ", __func__, data, isr);
+
+	if (data & UARTDM_SR_TXEMT_BMSK) {
+		ret = TIOCSER_TEMT;
+	} else
+		/*
+		 * Add an extra sleep here because sometimes the framework's
+		 * delay (based on baud rate) isn't good enough.
+		 * Note that this won't happen during every port close, only
+		 * on select occassions when the userspace does back to back
+		 * write() and close().
+		 */
+		usleep_range(5000, 7000);
+
+	return ret;
+}
+EXPORT_SYMBOL(msm_hs_tx_empty);
+
+/*
+ *  Standard API, Stop transmitter.
+ *  Any character in the transmit shift register is sent as
+ *  well as the current data mover transfer .
+ */
+static void msm_hs_stop_tx_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_tx *tx = &msm_uport->tx;
+
+	tx->flush = FLUSH_STOP;
+}
+
+static int disconnect_rx_endpoint(struct msm_hs_port *msm_uport)
+{
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	struct sps_pipe *sps_pipe_handle = rx->prod.pipe_handle;
+	int ret = 0;
+
+	ret = sps_rx_disconnect(sps_pipe_handle);
+
+	if (msm_uport->rx.pending_flag)
+		MSM_HS_WARN("%s(): Buffers may be pending 0x%lx",
+		__func__, msm_uport->rx.pending_flag);
+	MSM_HS_DBG("%s(): clearing desc usage flag", __func__);
+	msm_uport->rx.queued_flag = 0;
+	msm_uport->rx.pending_flag = 0;
+	msm_uport->rx.rx_inx = 0;
+
+	if (ret)
+		MSM_HS_ERR("%s(): sps_disconnect failed\n", __func__);
+	msm_uport->rx.flush = FLUSH_SHUTDOWN;
+	MSM_HS_DBG("%s: Calling Completion\n", __func__);
+	wake_up(&msm_uport->bam_disconnect_wait);
+	MSM_HS_DBG("%s: Done Completion\n", __func__);
+	wake_up(&msm_uport->rx.wait);
+	return ret;
+}
+
+static int sps_tx_disconnect(struct msm_hs_port *msm_uport)
+{
+	struct uart_port *uport = &msm_uport->uport;
+	struct msm_hs_tx *tx = &msm_uport->tx;
+	struct sps_pipe *tx_pipe = tx->cons.pipe_handle;
+	unsigned long flags;
+	int ret = 0;
+
+	if (msm_uport->tx.flush == FLUSH_SHUTDOWN) {
+		MSM_HS_DBG("%s(): pipe already disonnected", __func__);
+		return ret;
+	}
+
+	ret = sps_disconnect(tx_pipe);
+
+	if (ret) {
+		MSM_HS_ERR("%s(): sps_disconnect failed %d", __func__, ret);
+		return ret;
+	}
+
+	spin_lock_irqsave(&uport->lock, flags);
+	msm_uport->tx.flush = FLUSH_SHUTDOWN;
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	MSM_HS_DBG("%s(): TX Disconnect", __func__);
+	return ret;
+}
+
+static void msm_hs_disable_rx(struct uart_port *uport)
+{
+	unsigned int data;
+
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	data &= ~UARTDM_RX_BAM_ENABLE_BMSK;
+	msm_hs_write(uport, UART_DM_DMEN, data);
+}
+
+/*
+ *  Standard API, Stop receiver as soon as possible.
+ *
+ *  Function immediately terminates the operation of the
+ *  channel receiver and any incoming characters are lost. None
+ *  of the receiver status bits are affected by this command and
+ *  characters that are already in the receive FIFO there.
+ */
+static void msm_hs_stop_rx_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE)
+		MSM_HS_WARN("%s(): Clocks are off\n", __func__);
+	else
+		msm_hs_disable_rx(uport);
+
+	if (msm_uport->rx.flush == FLUSH_NONE)
+		msm_uport->rx.flush = FLUSH_STOP;
+}
+
+static void msm_hs_disconnect_rx(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_hs_disable_rx(uport);
+	/* Disconnect the BAM RX pipe */
+	if (msm_uport->rx.flush == FLUSH_NONE)
+		msm_uport->rx.flush = FLUSH_STOP;
+	disconnect_rx_endpoint(msm_uport);
+	MSM_HS_DBG("%s(): rx->flush %d", __func__, msm_uport->rx.flush);
+}
+
+/* Tx timeout callback function */
+void tx_timeout_handler(unsigned long arg)
+{
+	struct msm_hs_port *msm_uport = (struct msm_hs_port *) arg;
+	struct uart_port *uport = &msm_uport->uport;
+	int isr;
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s(): clocks are off", __func__);
+		return;
+	}
+
+	isr = msm_hs_read(uport, UART_DM_ISR);
+	if (UARTDM_ISR_CURRENT_CTS_BMSK & isr)
+		MSM_HS_WARN("%s(): CTS Disabled, ISR 0x%x", __func__, isr);
+	dump_uart_hs_registers(msm_uport);
+}
+
+/*  Transmit the next chunk of data */
+static void msm_hs_submit_tx_locked(struct uart_port *uport)
+{
+	int left;
+	int tx_count;
+	int aligned_tx_count;
+	dma_addr_t src_addr;
+	dma_addr_t aligned_src_addr;
+	u32 flags = SPS_IOVEC_FLAG_EOT | SPS_IOVEC_FLAG_INT;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_tx *tx = &msm_uport->tx;
+	struct circ_buf *tx_buf = &msm_uport->uport.state->xmit;
+	struct sps_pipe *sps_pipe_handle;
+	int ret;
+
+	if (uart_circ_empty(tx_buf) || uport->state->port.tty->stopped) {
+		tx->dma_in_flight = false;
+		msm_hs_stop_tx_locked(uport);
+		return;
+	}
+
+	tx_count = uart_circ_chars_pending(tx_buf);
+
+	if (tx_count > UARTDM_TX_BUF_SIZE)
+		tx_count = UARTDM_TX_BUF_SIZE;
+
+	left = UART_XMIT_SIZE - tx_buf->tail;
+
+	if (tx_count > left)
+		tx_count = left;
+
+	src_addr = tx->dma_base + tx_buf->tail;
+	/* Mask the src_addr to align on a cache
+	 * and add those bytes to tx_count
+	 */
+	aligned_src_addr = src_addr & ~(dma_get_cache_alignment() - 1);
+	aligned_tx_count = tx_count + src_addr - aligned_src_addr;
+
+	dma_sync_single_for_device(uport->dev, aligned_src_addr,
+			aligned_tx_count, DMA_TO_DEVICE);
+
+	tx->tx_count = tx_count;
+
+	hex_dump_ipc(msm_uport, tx->ipc_tx_ctxt, "Tx",
+			&tx_buf->buf[tx_buf->tail], (u64)src_addr, tx_count);
+	sps_pipe_handle = tx->cons.pipe_handle;
+
+	/* Set 1 second timeout */
+	mod_timer(&tx->tx_timeout_timer,
+		jiffies + msecs_to_jiffies(MSEC_PER_SEC));
+	/* Queue transfer request to SPS */
+	ret = sps_transfer_one(sps_pipe_handle, src_addr, tx_count,
+				msm_uport, flags);
+
+	MSM_HS_DBG("%s:Enqueue Tx Cmd, ret %d\n", __func__, ret);
+}
+
+/* This function queues the rx descriptor for BAM transfer */
+static void msm_hs_post_rx_desc(struct msm_hs_port *msm_uport, int inx)
+{
+	u32 flags = SPS_IOVEC_FLAG_INT;
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	int ret;
+
+	phys_addr_t rbuff_addr = rx->rbuffer + (UARTDM_RX_BUF_SIZE * inx);
+	u8 *virt_addr = rx->buffer + (UARTDM_RX_BUF_SIZE * inx);
+
+	MSM_HS_DBG("%s: %d:Queue desc %d, 0x%llx, base 0x%llx virtaddr %p",
+		__func__, msm_uport->uport.line, inx,
+		(u64)rbuff_addr, (u64)rx->rbuffer, virt_addr);
+
+	rx->iovec[inx].size = 0;
+	ret = sps_transfer_one(rx->prod.pipe_handle, rbuff_addr,
+		UARTDM_RX_BUF_SIZE, msm_uport, flags);
+
+	if (ret)
+		MSM_HS_ERR("Error processing descriptor %d", ret);
+}
+
+/* Update the rx descriptor index to specify the next one to be processed */
+static void msm_hs_mark_next(struct msm_hs_port *msm_uport, int inx)
+{
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	int prev;
+
+	inx %= UART_DMA_DESC_NR;
+	MSM_HS_DBG("%s(): inx %d, pending 0x%lx", __func__, inx,
+		rx->pending_flag);
+
+	if (!inx)
+		prev = UART_DMA_DESC_NR - 1;
+	else
+		prev = inx - 1;
+
+	if (!test_bit(prev, &rx->pending_flag))
+		msm_uport->rx.rx_inx = inx;
+	MSM_HS_DBG("%s(): prev %d pending flag 0x%lx, next %d", __func__,
+		prev, rx->pending_flag, msm_uport->rx.rx_inx);
+}
+
+/*
+ *	Queue the rx descriptor that has just been processed or
+ *	all of them if queueing for the first time
+ */
+static void msm_hs_queue_rx_desc(struct msm_hs_port *msm_uport)
+{
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	int i, flag = 0;
+
+	/* At first, queue all, if not, queue only one */
+	if (rx->queued_flag || rx->pending_flag) {
+		if (!test_bit(rx->rx_inx, &rx->queued_flag) &&
+		    !test_bit(rx->rx_inx, &rx->pending_flag)) {
+			msm_hs_post_rx_desc(msm_uport, rx->rx_inx);
+			set_bit(rx->rx_inx, &rx->queued_flag);
+			MSM_HS_DBG("%s(): Set Queued Bit %d",
+				__func__, rx->rx_inx);
+		} else
+			MSM_HS_ERR("%s(): rx_inx pending or queued", __func__);
+		return;
+	}
+
+	for (i = 0; i < UART_DMA_DESC_NR; i++) {
+		if (!test_bit(i, &rx->queued_flag) &&
+		!test_bit(i, &rx->pending_flag)) {
+			MSM_HS_DBG("%s(): Calling post rx %d", __func__, i);
+			msm_hs_post_rx_desc(msm_uport, i);
+			set_bit(i, &rx->queued_flag);
+			flag = 1;
+		}
+	}
+
+	if (!flag)
+		MSM_HS_ERR("%s(): error queueing descriptor", __func__);
+}
+
+/* Start to receive the next chunk of data */
+static void msm_hs_start_rx_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	unsigned int buffer_pending = msm_uport->rx.buffer_pending;
+	unsigned int data;
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s(): Clocks are off\n", __func__);
+		return;
+	}
+	if (rx->pending_flag) {
+		MSM_HS_INFO("%s: Rx Cmd got executed, wait for rx_tlet\n",
+								 __func__);
+		rx->flush = FLUSH_IGNORE;
+		return;
+	}
+	if (buffer_pending)
+		MSM_HS_ERR("Error: rx started in buffer state =%x",
+			buffer_pending);
+
+	msm_hs_write(uport, UART_DM_CR, RESET_STALE_INT);
+	msm_hs_write(uport, UART_DM_DMRX, UARTDM_RX_BUF_SIZE);
+	msm_hs_write(uport, UART_DM_CR, STALE_EVENT_ENABLE);
+	/*
+	 * Enable UARTDM Rx Interface as previously it has been
+	 * disable in set_termios before configuring baud rate.
+	 */
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	/* Enable UARTDM Rx BAM Interface */
+	data |= UARTDM_RX_BAM_ENABLE_BMSK;
+
+	msm_hs_write(uport, UART_DM_DMEN, data);
+	msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
+	/* Calling next DMOV API. Hence mb() here. */
+	mb();
+
+	/*
+	 * RX-transfer will be automatically re-activated
+	 * after last data of previous transfer was read.
+	 */
+	data = (RX_STALE_AUTO_RE_EN | RX_TRANS_AUTO_RE_ACTIVATE |
+				RX_DMRX_CYCLIC_EN);
+	msm_hs_write(uport, UART_DM_RX_TRANS_CTRL, data);
+	/* Issue RX BAM Start IFC command */
+	msm_hs_write(uport, UART_DM_CR, START_RX_BAM_IFC);
+	/* Ensure register IO completion */
+	mb();
+
+	msm_uport->rx.flush = FLUSH_NONE;
+	msm_uport->rx_bam_inprogress = true;
+	msm_hs_queue_rx_desc(msm_uport);
+	msm_uport->rx_bam_inprogress = false;
+	wake_up(&msm_uport->rx.wait);
+	MSM_HS_DBG("%s:Enqueue Rx Cmd\n", __func__);
+}
+
+static void flip_insert_work(struct work_struct *work)
+{
+	unsigned long flags;
+	int retval;
+	struct msm_hs_port *msm_uport =
+		container_of(work, struct msm_hs_port,
+			     rx.flip_insert_work.work);
+	struct tty_struct *tty = msm_uport->uport.state->port.tty;
+
+	spin_lock_irqsave(&msm_uport->uport.lock, flags);
+	if (!tty || msm_uport->rx.flush == FLUSH_SHUTDOWN) {
+		dev_err(msm_uport->uport.dev,
+			"%s:Invalid driver state flush %d\n",
+				__func__, msm_uport->rx.flush);
+		MSM_HS_ERR("%s:Invalid driver state flush %d\n",
+				__func__, msm_uport->rx.flush);
+		spin_unlock_irqrestore(&msm_uport->uport.lock, flags);
+		return;
+	}
+
+	if (msm_uport->rx.buffer_pending == NONE_PENDING) {
+		MSM_HS_ERR("Error: No buffer pending in %s", __func__);
+		spin_unlock_irqrestore(&msm_uport->uport.lock, flags);
+		return;
+	}
+	if (msm_uport->rx.buffer_pending & FIFO_OVERRUN) {
+		retval = tty_insert_flip_char(tty->port, 0, TTY_OVERRUN);
+		if (retval)
+			msm_uport->rx.buffer_pending &= ~FIFO_OVERRUN;
+	}
+	if (msm_uport->rx.buffer_pending & PARITY_ERROR) {
+		retval = tty_insert_flip_char(tty->port, 0, TTY_PARITY);
+		if (retval)
+			msm_uport->rx.buffer_pending &= ~PARITY_ERROR;
+	}
+	if (msm_uport->rx.buffer_pending & CHARS_NORMAL) {
+		int rx_count, rx_offset;
+
+		rx_count = (msm_uport->rx.buffer_pending & 0xFFFF0000) >> 16;
+		rx_offset = (msm_uport->rx.buffer_pending & 0xFFD0) >> 5;
+		retval = tty_insert_flip_string(tty->port,
+			msm_uport->rx.buffer +
+			(msm_uport->rx.rx_inx * UARTDM_RX_BUF_SIZE)
+			+ rx_offset, rx_count);
+		msm_uport->rx.buffer_pending &= (FIFO_OVERRUN |
+						 PARITY_ERROR);
+		if (retval != rx_count)
+			msm_uport->rx.buffer_pending |= CHARS_NORMAL |
+				retval << 8 | (rx_count - retval) << 16;
+	}
+	if (msm_uport->rx.buffer_pending) {
+		schedule_delayed_work(&msm_uport->rx.flip_insert_work,
+				      msecs_to_jiffies(RETRY_TIMEOUT));
+	} else if (msm_uport->rx.flush <= FLUSH_IGNORE) {
+		MSM_HS_WARN("Pending buffers cleared, restarting");
+		clear_bit(msm_uport->rx.rx_inx,
+			&msm_uport->rx.pending_flag);
+		msm_hs_start_rx_locked(&msm_uport->uport);
+		msm_hs_mark_next(msm_uport, msm_uport->rx.rx_inx+1);
+	}
+	spin_unlock_irqrestore(&msm_uport->uport.lock, flags);
+	tty_flip_buffer_push(tty->port);
+}
+
+static void msm_serial_hs_rx_work(struct kthread_work *work)
+{
+	int retval;
+	int rx_count = 0;
+	unsigned long status;
+	unsigned long flags;
+	unsigned int error_f = 0;
+	struct uart_port *uport;
+	struct msm_hs_port *msm_uport;
+	unsigned int flush = FLUSH_DATA_INVALID;
+	struct tty_struct *tty;
+	struct sps_event_notify *notify;
+	struct msm_hs_rx *rx;
+	struct sps_pipe *sps_pipe_handle;
+	struct platform_device *pdev;
+	const struct msm_serial_hs_platform_data *pdata;
+
+	msm_uport = container_of((struct kthread_work *) work,
+				 struct msm_hs_port, rx.kwork);
+	msm_hs_resource_vote(msm_uport);
+	uport = &msm_uport->uport;
+	tty = uport->state->port.tty;
+	notify = &msm_uport->notify;
+	rx = &msm_uport->rx;
+	pdev = to_platform_device(uport->dev);
+	pdata = pdev->dev.platform_data;
+
+	spin_lock_irqsave(&uport->lock, flags);
+
+	if (!tty || rx->flush == FLUSH_SHUTDOWN) {
+		dev_err(uport->dev, "%s:Invalid driver state flush %d\n",
+				__func__, rx->flush);
+		MSM_HS_ERR("%s:Invalid driver state flush %d\n",
+				__func__, rx->flush);
+		spin_unlock_irqrestore(&uport->lock, flags);
+		msm_hs_resource_unvote(msm_uport);
+		return;
+	}
+
+	/*
+	 * Process all pending descs or if nothing is
+	 * queued - called from termios
+	 */
+	while (!rx->buffer_pending &&
+		(rx->pending_flag || !rx->queued_flag)) {
+		MSM_HS_DBG("%s(): Loop P 0x%lx Q 0x%lx", __func__,
+			rx->pending_flag, rx->queued_flag);
+
+		status = msm_hs_read(uport, UART_DM_SR);
+
+		MSM_HS_DBG("In %s\n", __func__);
+
+		/* overflow is not connect to data in a FIFO */
+		if (unlikely((status & UARTDM_SR_OVERRUN_BMSK) &&
+			     (uport->read_status_mask & CREAD))) {
+			retval = tty_insert_flip_char(tty->port,
+							0, TTY_OVERRUN);
+			MSM_HS_WARN("%s(): RX Buffer Overrun Detected\n",
+				__func__);
+			if (!retval)
+				msm_uport->rx.buffer_pending |= TTY_OVERRUN;
+			uport->icount.buf_overrun++;
+			error_f = 1;
+		}
+
+		if (!(uport->ignore_status_mask & INPCK))
+			status = status & ~(UARTDM_SR_PAR_FRAME_BMSK);
+
+		if (unlikely(status & UARTDM_SR_PAR_FRAME_BMSK)) {
+			/* Can not tell diff between parity & frame error */
+			MSM_HS_WARN("msm_serial_hs: parity error\n");
+			uport->icount.parity++;
+			error_f = 1;
+			if (!(uport->ignore_status_mask & IGNPAR)) {
+				retval = tty_insert_flip_char(tty->port,
+							0, TTY_PARITY);
+				if (!retval)
+					msm_uport->rx.buffer_pending
+								|= TTY_PARITY;
+			}
+		}
+
+		if (unlikely(status & UARTDM_SR_RX_BREAK_BMSK)) {
+			MSM_HS_DBG("msm_serial_hs: Rx break\n");
+			uport->icount.brk++;
+			error_f = 1;
+			if (!(uport->ignore_status_mask & IGNBRK)) {
+				retval = tty_insert_flip_char(tty->port,
+								0, TTY_BREAK);
+				if (!retval)
+					msm_uport->rx.buffer_pending
+								|= TTY_BREAK;
+			}
+		}
+
+		if (error_f)
+			msm_hs_write(uport, UART_DM_CR,	RESET_ERROR_STATUS);
+		flush = msm_uport->rx.flush;
+		if (flush == FLUSH_IGNORE)
+			if (!msm_uport->rx.buffer_pending) {
+				MSM_HS_DBG("%s: calling start_rx_locked\n",
+					__func__);
+				msm_hs_start_rx_locked(uport);
+			}
+		if (flush >= FLUSH_DATA_INVALID)
+			goto out;
+
+		rx_count = msm_uport->rx.iovec[msm_uport->rx.rx_inx].size;
+		hex_dump_ipc(msm_uport, rx->ipc_rx_ctxt, "Rx",
+			(msm_uport->rx.buffer +
+			(msm_uport->rx.rx_inx * UARTDM_RX_BUF_SIZE)),
+			msm_uport->rx.iovec[msm_uport->rx.rx_inx].addr,
+			rx_count);
+
+		 /*
+		  * We are in a spin locked context, spin lock taken at
+		  * other places where these flags are updated
+		  */
+		if (0 != (uport->read_status_mask & CREAD)) {
+			if (!test_bit(msm_uport->rx.rx_inx,
+				&msm_uport->rx.pending_flag) &&
+			    !test_bit(msm_uport->rx.rx_inx,
+				&msm_uport->rx.queued_flag))
+				MSM_HS_ERR("%s: RX INX not set", __func__);
+			else if (test_bit(msm_uport->rx.rx_inx,
+					&msm_uport->rx.pending_flag) &&
+				!test_bit(msm_uport->rx.rx_inx,
+					&msm_uport->rx.queued_flag)) {
+				MSM_HS_DBG("%s(): Clear Pending Bit %d",
+					__func__, msm_uport->rx.rx_inx);
+
+				retval = tty_insert_flip_string(tty->port,
+					msm_uport->rx.buffer +
+					(msm_uport->rx.rx_inx *
+					UARTDM_RX_BUF_SIZE),
+					rx_count);
+
+				if (retval != rx_count) {
+					MSM_HS_INFO("%s(): ret %d rx_count %d",
+						__func__, retval, rx_count);
+					msm_uport->rx.buffer_pending |=
+					CHARS_NORMAL | retval << 5 |
+					(rx_count - retval) << 16;
+				}
+			} else
+				MSM_HS_ERR("%s: Error in inx %d", __func__,
+					msm_uport->rx.rx_inx);
+		}
+
+		if (!msm_uport->rx.buffer_pending) {
+			msm_uport->rx.flush = FLUSH_NONE;
+			msm_uport->rx_bam_inprogress = true;
+			sps_pipe_handle = rx->prod.pipe_handle;
+			MSM_HS_DBG("Queing bam descriptor\n");
+			/* Queue transfer request to SPS */
+			clear_bit(msm_uport->rx.rx_inx,
+				&msm_uport->rx.pending_flag);
+			msm_hs_queue_rx_desc(msm_uport);
+			msm_hs_mark_next(msm_uport, msm_uport->rx.rx_inx+1);
+			msm_hs_write(uport, UART_DM_CR, START_RX_BAM_IFC);
+			msm_uport->rx_bam_inprogress = false;
+			wake_up(&msm_uport->rx.wait);
+		} else
+			break;
+
+	}
+out:
+	if (msm_uport->rx.buffer_pending) {
+		MSM_HS_WARN("%s: tty buffer exhausted. Stalling\n", __func__);
+		schedule_delayed_work(&msm_uport->rx.flip_insert_work
+				      , msecs_to_jiffies(RETRY_TIMEOUT));
+	}
+	/* tty_flip_buffer_push() might call msm_hs_start(), so unlock */
+	spin_unlock_irqrestore(&uport->lock, flags);
+	if (flush < FLUSH_DATA_INVALID)
+		tty_flip_buffer_push(tty->port);
+	msm_hs_resource_unvote(msm_uport);
+}
+
+static void msm_hs_start_tx_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_tx *tx = &msm_uport->tx;
+
+	/* Bail if transfer in progress */
+	if (tx->flush < FLUSH_STOP || tx->dma_in_flight) {
+		MSM_HS_INFO("%s(): retry, flush %d, dma_in_flight %d\n",
+			__func__, tx->flush, tx->dma_in_flight);
+		return;
+	}
+
+	if (!tx->dma_in_flight) {
+		tx->dma_in_flight = true;
+		kthread_queue_work(&msm_uport->tx.kworker,
+			&msm_uport->tx.kwork);
+	}
+}
+
+/**
+ * Callback notification from SPS driver
+ *
+ * This callback function gets triggered called from
+ * SPS driver when requested SPS data transfer is
+ * completed.
+ *
+ */
+
+static void msm_hs_sps_tx_callback(struct sps_event_notify *notify)
+{
+	struct msm_hs_port *msm_uport =
+		(struct msm_hs_port *)
+		((struct sps_event_notify *)notify)->user;
+	phys_addr_t addr = DESC_FULL_ADDR(notify->data.transfer.iovec.flags,
+		notify->data.transfer.iovec.addr);
+
+	msm_uport->notify = *notify;
+	MSM_HS_INFO("tx_cb: addr=0x%pa, size=0x%x, flags=0x%x\n",
+		&addr, notify->data.transfer.iovec.size,
+		notify->data.transfer.iovec.flags);
+
+	del_timer(&msm_uport->tx.tx_timeout_timer);
+	MSM_HS_DBG("%s(): Queue kthread work", __func__);
+	kthread_queue_work(&msm_uport->tx.kworker, &msm_uport->tx.kwork);
+}
+
+static void msm_serial_hs_tx_work(struct kthread_work *work)
+{
+	unsigned long flags;
+	struct msm_hs_port *msm_uport =
+			container_of((struct kthread_work *)work,
+			struct msm_hs_port, tx.kwork);
+	struct uart_port *uport = &msm_uport->uport;
+	struct circ_buf *tx_buf = &uport->state->xmit;
+	struct msm_hs_tx *tx = &msm_uport->tx;
+
+	/*
+	 * Do the work buffer related work in BAM
+	 * mode that is equivalent to legacy mode
+	 */
+	msm_hs_resource_vote(msm_uport);
+	if (tx->flush >= FLUSH_STOP) {
+		spin_lock_irqsave(&(msm_uport->uport.lock), flags);
+		tx->flush = FLUSH_NONE;
+		MSM_HS_DBG("%s(): calling submit_tx", __func__);
+		msm_hs_submit_tx_locked(uport);
+		spin_unlock_irqrestore(&(msm_uport->uport.lock), flags);
+		msm_hs_resource_unvote(msm_uport);
+		return;
+	}
+
+	spin_lock_irqsave(&(msm_uport->uport.lock), flags);
+	if (!uart_circ_empty(tx_buf))
+		tx_buf->tail = (tx_buf->tail +
+		tx->tx_count) & ~UART_XMIT_SIZE;
+	else
+		MSM_HS_DBG("%s:circ buffer is empty\n", __func__);
+
+	wake_up(&msm_uport->tx.wait);
+
+	uport->icount.tx += tx->tx_count;
+
+	/*
+	 * Calling to send next chunk of data
+	 * If the circ buffer is empty, we stop
+	 * If the clock off was requested, the clock
+	 * off sequence is kicked off
+	 */
+	 MSM_HS_DBG("%s(): calling submit_tx", __func__);
+	 msm_hs_submit_tx_locked(uport);
+
+	if (uart_circ_chars_pending(tx_buf) < WAKEUP_CHARS)
+		uart_write_wakeup(uport);
+
+	spin_unlock_irqrestore(&(msm_uport->uport.lock), flags);
+	msm_hs_resource_unvote(msm_uport);
+}
+
+static void
+msm_hs_mark_proc_rx_desc(struct msm_hs_port *msm_uport,
+			struct sps_event_notify *notify)
+{
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	phys_addr_t addr = DESC_FULL_ADDR(notify->data.transfer.iovec.flags,
+		notify->data.transfer.iovec.addr);
+	/* divide by UARTDM_RX_BUF_SIZE */
+	int inx = (addr - rx->rbuffer) >> 9;
+
+	set_bit(inx, &rx->pending_flag);
+	clear_bit(inx, &rx->queued_flag);
+	rx->iovec[inx] = notify->data.transfer.iovec;
+	MSM_HS_DBG("Clear Q, Set P Bit %d, Q 0x%lx P 0x%lx",
+		inx, rx->queued_flag, rx->pending_flag);
+}
+
+/**
+ * Callback notification from SPS driver
+ *
+ * This callback function gets triggered called from
+ * SPS driver when requested SPS data transfer is
+ * completed.
+ *
+ */
+
+static void msm_hs_sps_rx_callback(struct sps_event_notify *notify)
+{
+
+	struct msm_hs_port *msm_uport =
+		(struct msm_hs_port *)
+		((struct sps_event_notify *)notify)->user;
+	struct uart_port *uport;
+	unsigned long flags;
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	phys_addr_t addr = DESC_FULL_ADDR(notify->data.transfer.iovec.flags,
+		notify->data.transfer.iovec.addr);
+	/* divide by UARTDM_RX_BUF_SIZE */
+	int inx = (addr - rx->rbuffer) >> 9;
+
+	uport = &(msm_uport->uport);
+	msm_uport->notify = *notify;
+	MSM_HS_INFO("rx_cb: addr=0x%pa, size=0x%x, flags=0x%x\n",
+		&addr, notify->data.transfer.iovec.size,
+		notify->data.transfer.iovec.flags);
+
+	spin_lock_irqsave(&uport->lock, flags);
+	msm_hs_mark_proc_rx_desc(msm_uport, notify);
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	if (msm_uport->rx.flush == FLUSH_NONE) {
+		/* Test if others are queued */
+		if (msm_uport->rx.pending_flag & ~(1 << inx)) {
+			MSM_HS_DBG("%s(): inx 0x%x, 0x%lx not processed",
+			__func__, inx,
+			msm_uport->rx.pending_flag & ~(1<<inx));
+		}
+		kthread_queue_work(&msm_uport->rx.kworker,
+				&msm_uport->rx.kwork);
+		MSM_HS_DBG("%s(): Scheduled rx_tlet", __func__);
+	}
+}
+
+/*
+ *  Standard API, Current states of modem control inputs
+ *
+ * Since CTS can be handled entirely by HARDWARE we always
+ * indicate clear to send and count on the TX FIFO to block when
+ * it fills up.
+ *
+ * - TIOCM_DCD
+ * - TIOCM_CTS
+ * - TIOCM_DSR
+ * - TIOCM_RI
+ *  (Unsupported) DCD and DSR will return them high. RI will return low.
+ */
+static unsigned int msm_hs_get_mctrl_locked(struct uart_port *uport)
+{
+	return TIOCM_DSR | TIOCM_CAR | TIOCM_CTS;
+}
+
+/*
+ *  Standard API, Set or clear RFR_signal
+ *
+ * Set RFR high, (Indicate we are not ready for data), we disable auto
+ * ready for receiving and then set RFR_N high. To set RFR to low we just turn
+ * back auto ready for receiving and it should lower RFR signal
+ * when hardware is ready
+ */
+void msm_hs_set_mctrl_locked(struct uart_port *uport,
+				    unsigned int mctrl)
+{
+	unsigned int set_rts;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s(): Clocks are off\n", __func__);
+		return;
+	}
+	/* RTS is active low */
+	set_rts = TIOCM_RTS & mctrl ? 0 : 1;
+	MSM_HS_INFO("%s: set_rts %d\n", __func__, set_rts);
+
+	if (set_rts)
+		msm_hs_disable_flow_control(uport, false);
+	else
+		msm_hs_enable_flow_control(uport, false);
+}
+
+void msm_hs_set_mctrl(struct uart_port *uport,
+				    unsigned int mctrl)
+{
+	unsigned long flags;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_hs_resource_vote(msm_uport);
+	spin_lock_irqsave(&uport->lock, flags);
+	msm_hs_set_mctrl_locked(uport, mctrl);
+	spin_unlock_irqrestore(&uport->lock, flags);
+	msm_hs_resource_unvote(msm_uport);
+}
+EXPORT_SYMBOL(msm_hs_set_mctrl);
+
+/* Standard API, Enable modem status (CTS) interrupt  */
+static void msm_hs_enable_ms_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	if (msm_uport->pm_state != MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s(): Clocks are off\n", __func__);
+		return;
+	}
+
+	/* Enable DELTA_CTS Interrupt */
+	msm_uport->imr_reg |= UARTDM_ISR_DELTA_CTS_BMSK;
+	msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
+	/* Ensure register IO completion */
+	mb();
+
+}
+
+/*
+ *  Standard API, Break Signal
+ *
+ * Control the transmission of a break signal. ctl eq 0 => break
+ * signal terminate ctl ne 0 => start break signal
+ */
+static void msm_hs_break_ctl(struct uart_port *uport, int ctl)
+{
+	unsigned long flags;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_hs_resource_vote(msm_uport);
+	spin_lock_irqsave(&uport->lock, flags);
+	msm_hs_write(uport, UART_DM_CR, ctl ? START_BREAK : STOP_BREAK);
+	/* Ensure register IO completion */
+	mb();
+	spin_unlock_irqrestore(&uport->lock, flags);
+	msm_hs_resource_unvote(msm_uport);
+}
+
+static void msm_hs_config_port(struct uart_port *uport, int cfg_flags)
+{
+	if (cfg_flags & UART_CONFIG_TYPE)
+		uport->type = PORT_MSM;
+
+}
+
+/*  Handle CTS changes (Called from interrupt handler) */
+static void msm_hs_handle_delta_cts_locked(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_hs_resource_vote(msm_uport);
+	/* clear interrupt */
+	msm_hs_write(uport, UART_DM_CR, RESET_CTS);
+	/* Calling CLOCK API. Hence mb() requires here. */
+	mb();
+	uport->icount.cts++;
+
+	/* clear the IOCTL TIOCMIWAIT if called */
+	wake_up_interruptible(&uport->state->port.delta_msr_wait);
+	msm_hs_resource_unvote(msm_uport);
+}
+
+static irqreturn_t msm_hs_isr(int irq, void *dev)
+{
+	unsigned long flags;
+	unsigned int isr_status;
+	struct msm_hs_port *msm_uport = (struct msm_hs_port *)dev;
+	struct uart_port *uport = &msm_uport->uport;
+	struct circ_buf *tx_buf = &uport->state->xmit;
+	struct msm_hs_tx *tx = &msm_uport->tx;
+
+	spin_lock_irqsave(&uport->lock, flags);
+
+	isr_status = msm_hs_read(uport, UART_DM_MISR);
+	MSM_HS_INFO("%s: DM_ISR: 0x%x\n", __func__, isr_status);
+	dump_uart_hs_registers(msm_uport);
+
+	/* Uart RX starting */
+	if (isr_status & UARTDM_ISR_RXLEV_BMSK) {
+		MSM_HS_DBG("%s:UARTDM_ISR_RXLEV_BMSK\n", __func__);
+		msm_uport->imr_reg &= ~UARTDM_ISR_RXLEV_BMSK;
+		msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
+		/* Complete device write for IMR. Hence mb() requires. */
+		mb();
+	}
+	/* Stale rx interrupt */
+	if (isr_status & UARTDM_ISR_RXSTALE_BMSK) {
+		msm_hs_write(uport, UART_DM_CR, STALE_EVENT_DISABLE);
+		msm_hs_write(uport, UART_DM_CR, RESET_STALE_INT);
+		/*
+		 * Complete device write before calling DMOV API. Hence
+		 * mb() requires here.
+		 */
+		mb();
+		MSM_HS_DBG("%s:Stal Interrupt\n", __func__);
+	}
+	/* tx ready interrupt */
+	if (isr_status & UARTDM_ISR_TX_READY_BMSK) {
+		MSM_HS_DBG("%s: ISR_TX_READY Interrupt\n", __func__);
+		/* Clear  TX Ready */
+		msm_hs_write(uport, UART_DM_CR, CLEAR_TX_READY);
+
+		/*
+		 * Complete both writes before starting new TX.
+		 * Hence mb() requires here.
+		 */
+		mb();
+		/* Complete DMA TX transactions and submit new transactions */
+
+		/* Do not update tx_buf.tail if uart_flush_buffer already
+		 * called in serial core
+		 */
+		if (!uart_circ_empty(tx_buf))
+			tx_buf->tail = (tx_buf->tail +
+					tx->tx_count) & ~UART_XMIT_SIZE;
+
+		tx->dma_in_flight = false;
+
+		uport->icount.tx += tx->tx_count;
+
+		if (uart_circ_chars_pending(tx_buf) < WAKEUP_CHARS)
+			uart_write_wakeup(uport);
+	}
+	if (isr_status & UARTDM_ISR_TXLEV_BMSK) {
+		/* TX FIFO is empty */
+		msm_uport->imr_reg &= ~UARTDM_ISR_TXLEV_BMSK;
+		msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
+		MSM_HS_DBG("%s: TXLEV Interrupt\n", __func__);
+		/*
+		 * Complete device write before starting clock_off request.
+		 * Hence mb() requires here.
+		 */
+		mb();
+		queue_work(msm_uport->hsuart_wq, &msm_uport->clock_off_w);
+	}
+
+	/* Change in CTS interrupt */
+	if (isr_status & UARTDM_ISR_DELTA_CTS_BMSK)
+		msm_hs_handle_delta_cts_locked(uport);
+
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	return IRQ_HANDLED;
+}
+
+/* The following two functions provide interfaces to get the underlying
+ * port structure (struct uart_port or struct msm_hs_port) given
+ * the port index. msm_hs_get_uart port is called by clients.
+ * The function msm_hs_get_hs_port is for internal use
+ */
+
+struct uart_port *msm_hs_get_uart_port(int port_index)
+{
+	struct uart_state *state = msm_hs_driver.state + port_index;
+
+	/* The uart_driver structure stores the states in an array.
+	 * Thus the corresponding offset from the drv->state returns
+	 * the state for the uart_port that is requested
+	 */
+	if (port_index == state->uart_port->line)
+		return state->uart_port;
+
+	return NULL;
+}
+EXPORT_SYMBOL(msm_hs_get_uart_port);
+
+static struct msm_hs_port *msm_hs_get_hs_port(int port_index)
+{
+	struct uart_port *uport = msm_hs_get_uart_port(port_index);
+
+	if (uport)
+		return UARTDM_TO_MSM(uport);
+	return NULL;
+}
+
+void enable_wakeup_interrupt(struct msm_hs_port *msm_uport)
+{
+	unsigned long flags;
+	struct uart_port *uport = &(msm_uport->uport);
+
+	if (!is_use_low_power_wakeup(msm_uport))
+		return;
+	if (msm_uport->wakeup.freed)
+		return;
+
+	if (!(msm_uport->wakeup.enabled)) {
+		spin_lock_irqsave(&uport->lock, flags);
+		msm_uport->wakeup.ignore = 1;
+		msm_uport->wakeup.enabled = true;
+		spin_unlock_irqrestore(&uport->lock, flags);
+		disable_irq(uport->irq);
+		enable_irq(msm_uport->wakeup.irq);
+	} else {
+		MSM_HS_WARN("%s:Wake up IRQ already enabled", __func__);
+	}
+}
+
+void disable_wakeup_interrupt(struct msm_hs_port *msm_uport)
+{
+	unsigned long flags;
+	struct uart_port *uport = &(msm_uport->uport);
+
+	if (!is_use_low_power_wakeup(msm_uport))
+		return;
+	if (msm_uport->wakeup.freed)
+		return;
+
+	if (msm_uport->wakeup.enabled) {
+		disable_irq_nosync(msm_uport->wakeup.irq);
+		enable_irq(uport->irq);
+		spin_lock_irqsave(&uport->lock, flags);
+		msm_uport->wakeup.enabled = false;
+		spin_unlock_irqrestore(&uport->lock, flags);
+	} else {
+		MSM_HS_WARN("%s:Wake up IRQ already disabled", __func__);
+	}
+}
+
+void msm_hs_resource_off(struct msm_hs_port *msm_uport)
+{
+	struct uart_port *uport = &(msm_uport->uport);
+	unsigned int data;
+
+	MSM_HS_DBG("%s(): begin", __func__);
+	msm_hs_disable_flow_control(uport, false);
+	if (msm_uport->rx.flush == FLUSH_NONE)
+		msm_hs_disconnect_rx(uport);
+
+	/* disable dlink */
+	if (msm_uport->tx.flush == FLUSH_NONE)
+		wait_event_timeout(msm_uport->tx.wait,
+			msm_uport->tx.flush == FLUSH_STOP, 500);
+
+	if (msm_uport->tx.flush != FLUSH_SHUTDOWN) {
+		data = msm_hs_read(uport, UART_DM_DMEN);
+		data &= ~UARTDM_TX_BAM_ENABLE_BMSK;
+		msm_hs_write(uport, UART_DM_DMEN, data);
+		sps_tx_disconnect(msm_uport);
+	}
+	if (!atomic_read(&msm_uport->client_req_state))
+		msm_hs_enable_flow_control(uport, false);
+}
+
+void msm_hs_resource_on(struct msm_hs_port *msm_uport)
+{
+	struct uart_port *uport = &(msm_uport->uport);
+	unsigned int data;
+	unsigned long flags;
+
+	if (msm_uport->rx.flush == FLUSH_SHUTDOWN ||
+	msm_uport->rx.flush == FLUSH_STOP) {
+		msm_hs_write(uport, UART_DM_CR, RESET_RX);
+		data = msm_hs_read(uport, UART_DM_DMEN);
+		data |= UARTDM_RX_BAM_ENABLE_BMSK;
+		msm_hs_write(uport, UART_DM_DMEN, data);
+	}
+
+	msm_hs_spsconnect_tx(msm_uport);
+	if (msm_uport->rx.flush == FLUSH_SHUTDOWN) {
+		msm_hs_spsconnect_rx(uport);
+		spin_lock_irqsave(&uport->lock, flags);
+		msm_hs_start_rx_locked(uport);
+		spin_unlock_irqrestore(&uport->lock, flags);
+	}
+}
+
+/* Request to turn off uart clock once pending TX is flushed */
+int msm_hs_request_clock_off(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	int ret = 0;
+	int client_count = 0;
+
+	mutex_lock(&msm_uport->mtx);
+	/*
+	 * If we're in the middle of a system suspend, don't process these
+	 * userspace/kernel API commands.
+	 */
+	if (msm_uport->pm_state == MSM_HS_PM_SYS_SUSPENDED) {
+		MSM_HS_WARN("%s:Can't process clk request during suspend",
+			__func__);
+		ret = -EIO;
+	}
+	mutex_unlock(&msm_uport->mtx);
+	if (ret)
+		goto exit_request_clock_off;
+
+	if (atomic_read(&msm_uport->client_count) <= 0) {
+		MSM_HS_WARN("%s(): ioctl count -ve, client check voting",
+			__func__);
+		ret = -EPERM;
+		goto exit_request_clock_off;
+	}
+	/* Set the flag to disable flow control and wakeup irq */
+	if (msm_uport->obs)
+		atomic_set(&msm_uport->client_req_state, 1);
+	msm_hs_resource_unvote(msm_uport);
+	atomic_dec(&msm_uport->client_count);
+	client_count = atomic_read(&msm_uport->client_count);
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+			"%s: Client_Count %d\n", __func__,
+			client_count);
+exit_request_clock_off:
+	return ret;
+}
+EXPORT_SYMBOL(msm_hs_request_clock_off);
+
+int msm_hs_request_clock_on(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	int client_count;
+	int ret = 0;
+
+	mutex_lock(&msm_uport->mtx);
+	/*
+	 * If we're in the middle of a system suspend, don't process these
+	 * userspace/kernel API commands.
+	 */
+	if (msm_uport->pm_state == MSM_HS_PM_SYS_SUSPENDED) {
+		MSM_HS_WARN("%s:Can't process clk request during suspend",
+			__func__);
+		ret = -EIO;
+	}
+	mutex_unlock(&msm_uport->mtx);
+	if (ret)
+		goto exit_request_clock_on;
+
+	msm_hs_resource_vote(UARTDM_TO_MSM(uport));
+	atomic_inc(&msm_uport->client_count);
+	client_count = atomic_read(&msm_uport->client_count);
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+			"%s: Client_Count %d\n", __func__,
+			client_count);
+
+	/* Clear the flag */
+	if (msm_uport->obs)
+		atomic_set(&msm_uport->client_req_state, 0);
+exit_request_clock_on:
+	return ret;
+}
+EXPORT_SYMBOL(msm_hs_request_clock_on);
+
+static irqreturn_t msm_hs_wakeup_isr(int irq, void *dev)
+{
+	unsigned int wakeup = 0;
+	unsigned long flags;
+	struct msm_hs_port *msm_uport = (struct msm_hs_port *)dev;
+	struct uart_port *uport = &msm_uport->uport;
+	struct tty_struct *tty = NULL;
+
+	spin_lock_irqsave(&uport->lock, flags);
+
+	if (msm_uport->wakeup.ignore)
+		msm_uport->wakeup.ignore = 0;
+	else
+		wakeup = 1;
+
+	if (wakeup) {
+		/*
+		 * Port was clocked off during rx, wake up and
+		 * optionally inject char into tty rx
+		 */
+		if (msm_uport->wakeup.inject_rx) {
+			tty = uport->state->port.tty;
+			tty_insert_flip_char(tty->port,
+					     msm_uport->wakeup.rx_to_inject,
+					     TTY_NORMAL);
+			hex_dump_ipc(msm_uport, msm_uport->rx.ipc_rx_ctxt,
+				"Rx Inject",
+				&msm_uport->wakeup.rx_to_inject, 0, 1);
+			MSM_HS_INFO("Wakeup ISR.Ignore%d\n",
+						msm_uport->wakeup.ignore);
+		}
+	}
+
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	if (wakeup && msm_uport->wakeup.inject_rx)
+		tty_flip_buffer_push(tty->port);
+	return IRQ_HANDLED;
+}
+
+static const char *msm_hs_type(struct uart_port *port)
+{
+	return "MSM HS UART";
+}
+
+/**
+ * msm_hs_unconfig_uart_gpios: Unconfigures UART GPIOs
+ * @uport: uart port
+ */
+static void msm_hs_unconfig_uart_gpios(struct uart_port *uport)
+{
+	struct platform_device *pdev = to_platform_device(uport->dev);
+	const struct msm_serial_hs_platform_data *pdata =
+					pdev->dev.platform_data;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	int ret;
+
+	if (msm_uport->use_pinctrl) {
+		ret = pinctrl_select_state(msm_uport->pinctrl,
+				msm_uport->gpio_state_suspend);
+		if (ret)
+			MSM_HS_ERR("%s():Failed to pinctrl set_state",
+				__func__);
+	} else if (pdata) {
+		if (gpio_is_valid(pdata->uart_tx_gpio))
+			gpio_free(pdata->uart_tx_gpio);
+		if (gpio_is_valid(pdata->uart_rx_gpio))
+			gpio_free(pdata->uart_rx_gpio);
+		if (gpio_is_valid(pdata->uart_cts_gpio))
+			gpio_free(pdata->uart_cts_gpio);
+		if (gpio_is_valid(pdata->uart_rfr_gpio))
+			gpio_free(pdata->uart_rfr_gpio);
+	} else
+		MSM_HS_ERR("Error:Pdata is NULL.\n");
+}
+
+/**
+ * msm_hs_config_uart_gpios - Configures UART GPIOs
+ * @uport: uart port
+ */
+static int msm_hs_config_uart_gpios(struct uart_port *uport)
+{
+	struct platform_device *pdev = to_platform_device(uport->dev);
+	const struct msm_serial_hs_platform_data *pdata =
+					pdev->dev.platform_data;
+	int ret = 0;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	if (!IS_ERR_OR_NULL(msm_uport->pinctrl)) {
+		MSM_HS_DBG("%s(): Using Pinctrl", __func__);
+		msm_uport->use_pinctrl = true;
+		ret = pinctrl_select_state(msm_uport->pinctrl,
+				msm_uport->gpio_state_active);
+		if (ret)
+			MSM_HS_ERR("%s(): Failed to pinctrl set_state",
+				__func__);
+		return ret;
+	} else if (pdata) {
+		/* Fall back to using gpio lib */
+		if (gpio_is_valid(pdata->uart_tx_gpio)) {
+			ret = gpio_request(pdata->uart_tx_gpio,
+							"UART_TX_GPIO");
+			if (unlikely(ret)) {
+				MSM_HS_ERR("gpio request failed for:%d\n",
+					pdata->uart_tx_gpio);
+				goto exit_uart_config;
+			}
+		}
+
+		if (gpio_is_valid(pdata->uart_rx_gpio)) {
+			ret = gpio_request(pdata->uart_rx_gpio,
+							"UART_RX_GPIO");
+			if (unlikely(ret)) {
+				MSM_HS_ERR("gpio request failed for:%d\n",
+					pdata->uart_rx_gpio);
+				goto uart_tx_unconfig;
+			}
+		}
+
+		if (gpio_is_valid(pdata->uart_cts_gpio)) {
+			ret = gpio_request(pdata->uart_cts_gpio,
+							"UART_CTS_GPIO");
+			if (unlikely(ret)) {
+				MSM_HS_ERR("gpio request failed for:%d\n",
+					pdata->uart_cts_gpio);
+				goto uart_rx_unconfig;
+			}
+		}
+
+		if (gpio_is_valid(pdata->uart_rfr_gpio)) {
+			ret = gpio_request(pdata->uart_rfr_gpio,
+							"UART_RFR_GPIO");
+			if (unlikely(ret)) {
+				MSM_HS_ERR("gpio request failed for:%d\n",
+					pdata->uart_rfr_gpio);
+				goto uart_cts_unconfig;
+			}
+		}
+	} else {
+		MSM_HS_ERR("Pdata is NULL.\n");
+		ret = -EINVAL;
+	}
+	return ret;
+
+uart_cts_unconfig:
+	if (gpio_is_valid(pdata->uart_cts_gpio))
+		gpio_free(pdata->uart_cts_gpio);
+uart_rx_unconfig:
+	if (gpio_is_valid(pdata->uart_rx_gpio))
+		gpio_free(pdata->uart_rx_gpio);
+uart_tx_unconfig:
+	if (gpio_is_valid(pdata->uart_tx_gpio))
+		gpio_free(pdata->uart_tx_gpio);
+exit_uart_config:
+	return ret;
+}
+
+
+static void msm_hs_get_pinctrl_configs(struct uart_port *uport)
+{
+	struct pinctrl_state *set_state;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	msm_uport->pinctrl = devm_pinctrl_get(uport->dev);
+	if (IS_ERR_OR_NULL(msm_uport->pinctrl)) {
+		MSM_HS_DBG("%s(): Pinctrl not defined", __func__);
+	} else {
+		MSM_HS_DBG("%s(): Using Pinctrl", __func__);
+		msm_uport->use_pinctrl = true;
+
+		set_state = pinctrl_lookup_state(msm_uport->pinctrl,
+						PINCTRL_STATE_DEFAULT);
+		if (IS_ERR_OR_NULL(set_state)) {
+			dev_err(uport->dev,
+				"pinctrl lookup failed for default state");
+			goto pinctrl_fail;
+		}
+
+		MSM_HS_DBG("%s(): Pinctrl state active %p\n", __func__,
+			set_state);
+		msm_uport->gpio_state_active = set_state;
+
+		set_state = pinctrl_lookup_state(msm_uport->pinctrl,
+						PINCTRL_STATE_SLEEP);
+		if (IS_ERR_OR_NULL(set_state)) {
+			dev_err(uport->dev,
+				"pinctrl lookup failed for sleep state");
+			goto pinctrl_fail;
+		}
+
+		MSM_HS_DBG("%s(): Pinctrl state sleep %p\n", __func__,
+			set_state);
+		msm_uport->gpio_state_suspend = set_state;
+		return;
+	}
+pinctrl_fail:
+	msm_uport->pinctrl = NULL;
+}
+
+/* Called when port is opened */
+static int msm_hs_startup(struct uart_port *uport)
+{
+	int ret;
+	int rfr_level;
+	unsigned long flags;
+	unsigned int data;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct circ_buf *tx_buf = &uport->state->xmit;
+	struct msm_hs_tx *tx = &msm_uport->tx;
+	struct msm_hs_rx *rx = &msm_uport->rx;
+	struct sps_pipe *sps_pipe_handle_tx = tx->cons.pipe_handle;
+	struct sps_pipe *sps_pipe_handle_rx = rx->prod.pipe_handle;
+
+	rfr_level = uport->fifosize;
+	if (rfr_level > 16)
+		rfr_level -= 16;
+
+	tx->dma_base = dma_map_single(uport->dev, tx_buf->buf, UART_XMIT_SIZE,
+				      DMA_TO_DEVICE);
+
+	/* turn on uart clk */
+	msm_hs_resource_vote(msm_uport);
+
+	if (is_use_low_power_wakeup(msm_uport)) {
+		ret = request_threaded_irq(msm_uport->wakeup.irq, NULL,
+					msm_hs_wakeup_isr,
+					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+					"msm_hs_wakeup", msm_uport);
+		if (unlikely(ret)) {
+			MSM_HS_ERR("%s():Err getting uart wakeup_irq %d\n",
+				  __func__, ret);
+			goto unvote_exit;
+		}
+
+		msm_uport->wakeup.freed = false;
+		disable_irq(msm_uport->wakeup.irq);
+		msm_uport->wakeup.enabled = false;
+
+		ret = irq_set_irq_wake(msm_uport->wakeup.irq, 1);
+		if (unlikely(ret)) {
+			MSM_HS_ERR("%s():Err setting wakeup irq\n", __func__);
+			goto free_uart_irq;
+		}
+	}
+
+	ret = msm_hs_config_uart_gpios(uport);
+	if (ret) {
+		MSM_HS_ERR("Uart GPIO request failed\n");
+		goto free_uart_irq;
+	}
+
+	msm_hs_write(uport, UART_DM_DMEN, 0);
+
+	/* Connect TX */
+	sps_tx_disconnect(msm_uport);
+	ret = msm_hs_spsconnect_tx(msm_uport);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: SPS connect failed for TX");
+		goto unconfig_uart_gpios;
+	}
+
+	/* Connect RX */
+	kthread_flush_worker(&msm_uport->rx.kworker);
+	if (rx->flush != FLUSH_SHUTDOWN)
+		disconnect_rx_endpoint(msm_uport);
+	ret = msm_hs_spsconnect_rx(uport);
+	if (ret) {
+		MSM_HS_ERR("msm_serial_hs: SPS connect failed for RX");
+		goto sps_disconnect_tx;
+	}
+
+	data = (UARTDM_BCR_TX_BREAK_DISABLE | UARTDM_BCR_STALE_IRQ_EMPTY |
+		UARTDM_BCR_RX_DMRX_LOW_EN | UARTDM_BCR_RX_STAL_IRQ_DMRX_EQL |
+		UARTDM_BCR_RX_DMRX_1BYTE_RES_EN);
+	msm_hs_write(uport, UART_DM_BCR, data);
+
+	/* Set auto RFR Level */
+	data = msm_hs_read(uport, UART_DM_MR1);
+	data &= ~UARTDM_MR1_AUTO_RFR_LEVEL1_BMSK;
+	data &= ~UARTDM_MR1_AUTO_RFR_LEVEL0_BMSK;
+	data |= (UARTDM_MR1_AUTO_RFR_LEVEL1_BMSK & (rfr_level << 2));
+	data |= (UARTDM_MR1_AUTO_RFR_LEVEL0_BMSK & rfr_level);
+	msm_hs_write(uport, UART_DM_MR1, data);
+
+	/* Make sure RXSTALE count is non-zero */
+	data = msm_hs_read(uport, UART_DM_IPR);
+	if (!data) {
+		data |= 0x1f & UARTDM_IPR_STALE_LSB_BMSK;
+		msm_hs_write(uport, UART_DM_IPR, data);
+	}
+
+	/* Assume no flow control, unless termios sets it */
+	msm_uport->flow_control = false;
+	msm_hs_disable_flow_control(uport, true);
+
+
+	/* Reset TX */
+	msm_hs_write(uport, UART_DM_CR, RESET_TX);
+	msm_hs_write(uport, UART_DM_CR, RESET_RX);
+	msm_hs_write(uport, UART_DM_CR, RESET_ERROR_STATUS);
+	msm_hs_write(uport, UART_DM_CR, RESET_BREAK_INT);
+	msm_hs_write(uport, UART_DM_CR, RESET_STALE_INT);
+	msm_hs_write(uport, UART_DM_CR, RESET_CTS);
+	msm_hs_write(uport, UART_DM_CR, RFR_LOW);
+	/* Turn on Uart Receiver */
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_RX_EN_BMSK);
+
+	/* Turn on Uart Transmitter */
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_TX_EN_BMSK);
+
+	tx->dma_in_flight = false;
+	MSM_HS_DBG("%s():desc usage flag 0x%lx", __func__, rx->queued_flag);
+	setup_timer(&(tx->tx_timeout_timer),
+			tx_timeout_handler,
+			(unsigned long) msm_uport);
+
+	/* Enable reading the current CTS, no harm even if CTS is ignored */
+	msm_uport->imr_reg |= UARTDM_ISR_CURRENT_CTS_BMSK;
+
+	/* TXLEV on empty TX fifo */
+	msm_hs_write(uport, UART_DM_TFWR, 4);
+	/*
+	 * Complete all device write related configuration before
+	 * queuing RX request. Hence mb() requires here.
+	 */
+	mb();
+
+	ret = request_irq(uport->irq, msm_hs_isr, IRQF_TRIGGER_HIGH,
+			  "msm_hs_uart", msm_uport);
+	if (unlikely(ret)) {
+		MSM_HS_ERR("%s():Error %d getting uart irq\n", __func__, ret);
+		goto sps_disconnect_rx;
+	}
+
+
+	spin_lock_irqsave(&uport->lock, flags);
+	atomic_set(&msm_uport->client_count, 0);
+	atomic_set(&msm_uport->client_req_state, 0);
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+			"%s: Client_Count 0\n", __func__);
+	msm_hs_start_rx_locked(uport);
+
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	msm_hs_resource_unvote(msm_uport);
+	return 0;
+
+sps_disconnect_rx:
+	sps_disconnect(sps_pipe_handle_rx);
+sps_disconnect_tx:
+	sps_disconnect(sps_pipe_handle_tx);
+unconfig_uart_gpios:
+	msm_hs_unconfig_uart_gpios(uport);
+free_uart_irq:
+	free_irq(uport->irq, msm_uport);
+unvote_exit:
+	msm_hs_resource_unvote(msm_uport);
+	MSM_HS_ERR("%s(): Error return\n", __func__);
+	return ret;
+}
+
+/* Initialize tx and rx data structures */
+static int uartdm_init_port(struct uart_port *uport)
+{
+	int ret = 0;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct msm_hs_tx *tx = &msm_uport->tx;
+	struct msm_hs_rx *rx = &msm_uport->rx;
+
+	init_waitqueue_head(&rx->wait);
+	init_waitqueue_head(&tx->wait);
+	init_waitqueue_head(&msm_uport->bam_disconnect_wait);
+
+	/* Init kernel threads for tx and rx */
+
+	kthread_init_worker(&rx->kworker);
+	rx->task = kthread_run(kthread_worker_fn,
+			&rx->kworker, "msm_serial_hs_%d_rx_work", uport->line);
+	if (IS_ERR(rx->task)) {
+		MSM_HS_ERR("%s(): error creating task", __func__);
+		goto exit_lh_init;
+	}
+	kthread_init_work(&rx->kwork, msm_serial_hs_rx_work);
+
+	kthread_init_worker(&tx->kworker);
+	tx->task = kthread_run(kthread_worker_fn,
+			&tx->kworker, "msm_serial_hs_%d_tx_work", uport->line);
+	if (IS_ERR(rx->task)) {
+		MSM_HS_ERR("%s(): error creating task", __func__);
+		goto exit_lh_init;
+	}
+
+	kthread_init_work(&tx->kwork, msm_serial_hs_tx_work);
+
+	rx->buffer = dma_alloc_coherent(uport->dev,
+				UART_DMA_DESC_NR * UARTDM_RX_BUF_SIZE,
+				 &rx->rbuffer, GFP_KERNEL);
+	if (!rx->buffer) {
+		MSM_HS_ERR("%s(): cannot allocate rx->buffer", __func__);
+		ret = -ENOMEM;
+		goto exit_lh_init;
+	}
+
+	/* Set up Uart Receive */
+	msm_hs_write(uport, UART_DM_RFWR, 32);
+	/* Write to BADR explicitly to set up FIFO sizes */
+	msm_hs_write(uport, UARTDM_BADR_ADDR, 64);
+
+	INIT_DELAYED_WORK(&rx->flip_insert_work, flip_insert_work);
+
+	return ret;
+exit_lh_init:
+	kthread_stop(rx->task);
+	rx->task = NULL;
+	kthread_stop(tx->task);
+	tx->task = NULL;
+	return ret;
+}
+
+struct msm_serial_hs_platform_data
+	*msm_hs_dt_to_pdata(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct msm_serial_hs_platform_data *pdata;
+	u32 rx_to_inject;
+	int ret;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	pdev->id = of_alias_get_id(pdev->dev.of_node, "uart");
+	/* UART TX GPIO */
+	pdata->uart_tx_gpio = of_get_named_gpio(node,
+					"qcom,tx-gpio", 0);
+	if (pdata->uart_tx_gpio < 0)
+		pr_err("uart_tx_gpio is not available\n");
+
+	/* UART RX GPIO */
+	pdata->uart_rx_gpio = of_get_named_gpio(node,
+					"qcom,rx-gpio", 0);
+	if (pdata->uart_rx_gpio < 0)
+		pr_err("uart_rx_gpio is not available\n");
+
+	/* UART CTS GPIO */
+	pdata->uart_cts_gpio = of_get_named_gpio(node,
+					"qcom,cts-gpio", 0);
+	if (pdata->uart_cts_gpio < 0)
+		pr_err("uart_cts_gpio is not available\n");
+
+	/* UART RFR GPIO */
+	pdata->uart_rfr_gpio = of_get_named_gpio(node,
+					"qcom,rfr-gpio", 0);
+	if (pdata->uart_rfr_gpio < 0)
+		pr_err("uart_rfr_gpio is not available\n");
+
+	pdata->no_suspend_delay = of_property_read_bool(node,
+				"qcom,no-suspend-delay");
+
+	pdata->obs = of_property_read_bool(node,
+				"qcom,msm-obs");
+	if (pdata->obs)
+		pr_err("%s:Out of Band sleep flag is set\n", __func__);
+
+	pdata->inject_rx_on_wakeup = of_property_read_bool(node,
+				"qcom,inject-rx-on-wakeup");
+
+	if (pdata->inject_rx_on_wakeup) {
+		ret = of_property_read_u32(node, "qcom,rx-char-to-inject",
+						&rx_to_inject);
+		if (ret < 0) {
+			pr_err("Error: Rx_char_to_inject not specified.\n");
+			return ERR_PTR(ret);
+		}
+		pdata->rx_to_inject = (u8)rx_to_inject;
+	}
+
+	ret = of_property_read_u32(node, "qcom,bam-tx-ep-pipe-index",
+				&pdata->bam_tx_ep_pipe_index);
+	if (ret < 0) {
+		pr_err("Error: Getting UART BAM TX EP Pipe Index.\n");
+		return ERR_PTR(ret);
+	}
+
+	if (!(pdata->bam_tx_ep_pipe_index >= BAM_PIPE_MIN &&
+		pdata->bam_tx_ep_pipe_index <= BAM_PIPE_MAX)) {
+		pr_err("Error: Invalid UART BAM TX EP Pipe Index.\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	ret = of_property_read_u32(node, "qcom,bam-rx-ep-pipe-index",
+					&pdata->bam_rx_ep_pipe_index);
+	if (ret < 0) {
+		pr_err("Error: Getting UART BAM RX EP Pipe Index.\n");
+		return ERR_PTR(ret);
+	}
+
+	if (!(pdata->bam_rx_ep_pipe_index >= BAM_PIPE_MIN &&
+		pdata->bam_rx_ep_pipe_index <= BAM_PIPE_MAX)) {
+		pr_err("Error: Invalid UART BAM RX EP Pipe Index.\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	pr_debug("tx_ep_pipe_index:%d rx_ep_pipe_index:%d\n"
+		"tx_gpio:%d rx_gpio:%d rfr_gpio:%d cts_gpio:%d",
+		pdata->bam_tx_ep_pipe_index, pdata->bam_rx_ep_pipe_index,
+		pdata->uart_tx_gpio, pdata->uart_rx_gpio, pdata->uart_cts_gpio,
+		pdata->uart_rfr_gpio);
+
+	return pdata;
+}
+
+
+/**
+ * Deallocate UART peripheral's SPS endpoint
+ * @msm_uport - Pointer to msm_hs_port structure
+ * @ep - Pointer to sps endpoint data structure
+ */
+
+static void msm_hs_exit_ep_conn(struct msm_hs_port *msm_uport,
+				struct msm_hs_sps_ep_conn_data *ep)
+{
+	struct sps_pipe *sps_pipe_handle = ep->pipe_handle;
+	struct sps_connect *sps_config = &ep->config;
+
+	dma_free_coherent(msm_uport->uport.dev,
+			sps_config->desc.size,
+			&sps_config->desc.phys_base,
+			GFP_KERNEL);
+	sps_free_endpoint(sps_pipe_handle);
+}
+
+
+/**
+ * Allocate UART peripheral's SPS endpoint
+ *
+ * This function allocates endpoint context
+ * by calling appropriate SPS driver APIs.
+ *
+ * @msm_uport - Pointer to msm_hs_port structure
+ * @ep - Pointer to sps endpoint data structure
+ * @is_produce - 1 means Producer endpoint
+ *             - 0 means Consumer endpoint
+ *
+ * @return - 0 if successful else negative value
+ */
+
+static int msm_hs_sps_init_ep_conn(struct msm_hs_port *msm_uport,
+				struct msm_hs_sps_ep_conn_data *ep,
+				bool is_producer)
+{
+	int rc = 0;
+	struct sps_pipe *sps_pipe_handle;
+	struct sps_connect *sps_config = &ep->config;
+	struct sps_register_event *sps_event = &ep->event;
+
+	/* Allocate endpoint context */
+	sps_pipe_handle = sps_alloc_endpoint();
+	if (!sps_pipe_handle) {
+		MSM_HS_ERR("%s(): sps_alloc_endpoint() failed!!\n"
+			"is_producer=%d", __func__, is_producer);
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	/* Get default connection configuration for an endpoint */
+	rc = sps_get_config(sps_pipe_handle, sps_config);
+	if (rc) {
+		MSM_HS_ERR("%s(): failed! pipe_handle=0x%p rc=%d",
+			__func__, sps_pipe_handle, rc);
+		goto get_config_err;
+	}
+
+	/* Modify the default connection configuration */
+	if (is_producer) {
+		/* For UART producer transfer, source is UART peripheral
+		 * where as destination is system memory
+		 */
+		sps_config->source = msm_uport->bam_handle;
+		sps_config->destination = SPS_DEV_HANDLE_MEM;
+		sps_config->mode = SPS_MODE_SRC;
+		sps_config->src_pipe_index = msm_uport->bam_rx_ep_pipe_index;
+		sps_config->dest_pipe_index = 0;
+		sps_event->callback = msm_hs_sps_rx_callback;
+	} else {
+		/* For UART consumer transfer, source is system memory
+		 * where as destination is UART peripheral
+		 */
+		sps_config->source = SPS_DEV_HANDLE_MEM;
+		sps_config->destination = msm_uport->bam_handle;
+		sps_config->mode = SPS_MODE_DEST;
+		sps_config->src_pipe_index = 0;
+		sps_config->dest_pipe_index = msm_uport->bam_tx_ep_pipe_index;
+		sps_event->callback = msm_hs_sps_tx_callback;
+	}
+
+	sps_config->options = SPS_O_EOT | SPS_O_DESC_DONE | SPS_O_AUTO_ENABLE;
+	sps_config->event_thresh = 0x10;
+
+	/* Allocate maximum descriptor fifo size */
+	sps_config->desc.size =
+		(1 + UART_DMA_DESC_NR) * sizeof(struct sps_iovec);
+	sps_config->desc.base = dma_alloc_coherent(msm_uport->uport.dev,
+						sps_config->desc.size,
+						&sps_config->desc.phys_base,
+						GFP_KERNEL);
+	if (!sps_config->desc.base) {
+		rc = -ENOMEM;
+		MSM_HS_ERR("msm_serial_hs: dma_alloc_coherent() failed!!\n");
+		goto get_config_err;
+	}
+	memset(sps_config->desc.base, 0x00, sps_config->desc.size);
+
+	sps_event->mode = SPS_TRIGGER_CALLBACK;
+
+	sps_event->options = SPS_O_DESC_DONE | SPS_O_EOT;
+	sps_event->user = (void *)msm_uport;
+
+	/* Now save the sps pipe handle */
+	ep->pipe_handle = sps_pipe_handle;
+	MSM_HS_DBG("msm_serial_hs: success !! %s: pipe_handle=0x%p\n"
+		"desc_fifo.phys_base=0x%pa\n",
+		is_producer ? "READ" : "WRITE",
+		sps_pipe_handle, &sps_config->desc.phys_base);
+	return 0;
+
+get_config_err:
+	sps_free_endpoint(sps_pipe_handle);
+out:
+	return rc;
+}
+
+/**
+ * Initialize SPS HW connected with UART core
+ *
+ * This function register BAM HW resources with
+ * SPS driver and then initialize 2 SPS endpoints
+ *
+ * msm_uport - Pointer to msm_hs_port structure
+ *
+ * @return - 0 if successful else negative value
+ */
+
+static int msm_hs_sps_init(struct msm_hs_port *msm_uport)
+{
+	int rc = 0;
+	struct sps_bam_props bam = {0};
+	unsigned long bam_handle;
+
+	rc = sps_phy2h(msm_uport->bam_mem, &bam_handle);
+	if (rc || !bam_handle) {
+		bam.phys_addr = msm_uport->bam_mem;
+		bam.virt_addr = msm_uport->bam_base;
+		/*
+		 * This event thresold value is only significant for BAM-to-BAM
+		 * transfer. It's ignored for BAM-to-System mode transfer.
+		 */
+		bam.event_threshold = 0x10;	/* Pipe event threshold */
+		bam.summing_threshold = 1;	/* BAM event threshold */
+
+		/* SPS driver wll handle the UART BAM IRQ */
+		bam.irq = (u32)msm_uport->bam_irq;
+		bam.manage = SPS_BAM_MGR_DEVICE_REMOTE;
+
+		MSM_HS_DBG("msm_serial_hs: bam physical base=0x%pa\n",
+							&bam.phys_addr);
+		MSM_HS_DBG("msm_serial_hs: bam virtual base=0x%p\n",
+							bam.virt_addr);
+
+		/* Register UART Peripheral BAM device to SPS driver */
+		rc = sps_register_bam_device(&bam, &bam_handle);
+		if (rc) {
+			MSM_HS_ERR("%s: BAM device register failed\n",
+				  __func__);
+			return rc;
+		}
+		MSM_HS_DBG("%s:BAM device registered. bam_handle=0x%lx",
+			   __func__, msm_uport->bam_handle);
+	}
+	msm_uport->bam_handle = bam_handle;
+
+	rc = msm_hs_sps_init_ep_conn(msm_uport, &msm_uport->rx.prod,
+				UART_SPS_PROD_PERIPHERAL);
+	if (rc) {
+		MSM_HS_ERR("%s: Failed to Init Producer BAM-pipe", __func__);
+		goto deregister_bam;
+	}
+
+	rc = msm_hs_sps_init_ep_conn(msm_uport, &msm_uport->tx.cons,
+				UART_SPS_CONS_PERIPHERAL);
+	if (rc) {
+		MSM_HS_ERR("%s: Failed to Init Consumer BAM-pipe", __func__);
+		goto deinit_ep_conn_prod;
+	}
+	return 0;
+
+deinit_ep_conn_prod:
+	msm_hs_exit_ep_conn(msm_uport, &msm_uport->rx.prod);
+deregister_bam:
+	sps_deregister_bam_device(msm_uport->bam_handle);
+	return rc;
+}
+
+
+static bool deviceid[UARTDM_NR] = {0};
+/*
+ * The mutex synchronizes grabbing next free device number
+ * both in case of an alias being used or not. When alias is
+ * used, the msm_hs_dt_to_pdata gets it and the boolean array
+ * is accordingly updated with device_id_set_used. If no alias
+ * is used, then device_id_grab_next_free sets that array.
+ */
+static DEFINE_MUTEX(mutex_next_device_id);
+
+static int device_id_grab_next_free(void)
+{
+	int i;
+	int ret = -ENODEV;
+
+	mutex_lock(&mutex_next_device_id);
+	for (i = 0; i < UARTDM_NR; i++)
+		if (!deviceid[i]) {
+			ret = i;
+			deviceid[i] = true;
+			break;
+		}
+	mutex_unlock(&mutex_next_device_id);
+	return ret;
+}
+
+static int device_id_set_used(int index)
+{
+	int ret = 0;
+
+	mutex_lock(&mutex_next_device_id);
+	if (deviceid[index])
+		ret = -ENODEV;
+	else
+		deviceid[index] = true;
+	mutex_unlock(&mutex_next_device_id);
+	return ret;
+}
+
+static void obs_manage_irq(struct msm_hs_port *msm_uport, bool en)
+{
+	struct uart_port *uport = &(msm_uport->uport);
+
+	if (msm_uport->obs) {
+		if (en)
+			enable_irq(uport->irq);
+		else
+			disable_irq(uport->irq);
+	}
+}
+
+static void msm_hs_pm_suspend(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+	int ret;
+	int client_count = 0;
+
+	if (!msm_uport)
+		goto err_suspend;
+	mutex_lock(&msm_uport->mtx);
+
+	client_count = atomic_read(&msm_uport->client_count);
+	msm_uport->pm_state = MSM_HS_PM_SUSPENDED;
+	msm_hs_resource_off(msm_uport);
+	obs_manage_irq(msm_uport, false);
+	msm_hs_clk_bus_unvote(msm_uport);
+
+	/* For OBS, don't use wakeup interrupt, set gpio to suspended state */
+	if (msm_uport->obs) {
+		ret = pinctrl_select_state(msm_uport->pinctrl,
+			msm_uport->gpio_state_suspend);
+		if (ret)
+			MSM_HS_ERR("%s():Error selecting pinctrl suspend state",
+				__func__);
+	}
+
+	if (!atomic_read(&msm_uport->client_req_state))
+		enable_wakeup_interrupt(msm_uport);
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+		"%s: PM State Suspended client_count %d\n", __func__,
+								client_count);
+	mutex_unlock(&msm_uport->mtx);
+	return;
+err_suspend:
+	pr_err("%s(): invalid uport", __func__);
+}
+
+static int msm_hs_pm_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+	int ret = 0;
+	int client_count = 0;
+
+	if (!msm_uport) {
+		dev_err(dev, "%s:Invalid uport\n", __func__);
+		return -ENODEV;
+	}
+
+	mutex_lock(&msm_uport->mtx);
+	client_count = atomic_read(&msm_uport->client_count);
+	if (msm_uport->pm_state == MSM_HS_PM_ACTIVE)
+		goto exit_pm_resume;
+	if (!atomic_read(&msm_uport->client_req_state))
+		disable_wakeup_interrupt(msm_uport);
+
+	/* For OBS, don't use wakeup interrupt, set gpio to active state */
+	if (msm_uport->obs) {
+		ret = pinctrl_select_state(msm_uport->pinctrl,
+				msm_uport->gpio_state_active);
+		if (ret)
+			MSM_HS_ERR("%s():Error selecting active state",
+				 __func__);
+	}
+
+	ret = msm_hs_clk_bus_vote(msm_uport);
+	if (ret) {
+		MSM_HS_ERR("%s:Failed clock vote %d\n", __func__, ret);
+		dev_err(dev, "%s:Failed clock vote %d\n", __func__, ret);
+		goto exit_pm_resume;
+	}
+	obs_manage_irq(msm_uport, true);
+	msm_uport->pm_state = MSM_HS_PM_ACTIVE;
+	msm_hs_resource_on(msm_uport);
+
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+		"%s:PM State:Active client_count %d\n", __func__, client_count);
+exit_pm_resume:
+	mutex_unlock(&msm_uport->mtx);
+	return ret;
+}
+
+#ifdef CONFIG_PM
+static int msm_hs_pm_sys_suspend_noirq(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+	enum msm_hs_pm_state prev_pwr_state;
+	int clk_cnt, client_count, ret = 0;
+
+	if (IS_ERR_OR_NULL(msm_uport))
+		return -ENODEV;
+
+	mutex_lock(&msm_uport->mtx);
+
+	/*
+	 * If there is an active clk request or an impending userspace request
+	 * fail the suspend callback.
+	 */
+	clk_cnt = atomic_read(&msm_uport->resource_count);
+	client_count = atomic_read(&msm_uport->client_count);
+	if (msm_uport->pm_state == MSM_HS_PM_ACTIVE) {
+		MSM_HS_WARN("%s:Fail Suspend.clk_cnt:%d,clnt_count:%d\n",
+				 __func__, clk_cnt, client_count);
+		ret = -EBUSY;
+		goto exit_suspend_noirq;
+	}
+
+	prev_pwr_state = msm_uport->pm_state;
+	msm_uport->pm_state = MSM_HS_PM_SYS_SUSPENDED;
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+		"%s:PM State:Sys-Suspended client_count %d\n", __func__,
+								client_count);
+exit_suspend_noirq:
+	mutex_unlock(&msm_uport->mtx);
+	return ret;
+};
+
+static int msm_hs_pm_sys_resume_noirq(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct msm_hs_port *msm_uport = get_matching_hs_port(pdev);
+
+	if (IS_ERR_OR_NULL(msm_uport))
+		return -ENODEV;
+	/*
+	 * Note system-pm resume and update the state
+	 * variable. Resource activation will be done
+	 * when transfer is requested.
+	 */
+
+	mutex_lock(&msm_uport->mtx);
+	if (msm_uport->pm_state == MSM_HS_PM_SYS_SUSPENDED)
+		msm_uport->pm_state = MSM_HS_PM_SUSPENDED;
+	LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+		"%s:PM State: Suspended\n", __func__);
+	mutex_unlock(&msm_uport->mtx);
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM
+static void  msm_serial_hs_rt_init(struct uart_port *uport)
+{
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+
+	MSM_HS_INFO("%s(): Enabling runtime pm", __func__);
+	pm_runtime_set_suspended(uport->dev);
+	pm_runtime_set_autosuspend_delay(uport->dev, 100);
+	pm_runtime_use_autosuspend(uport->dev);
+	mutex_lock(&msm_uport->mtx);
+	msm_uport->pm_state = MSM_HS_PM_SUSPENDED;
+	mutex_unlock(&msm_uport->mtx);
+	pm_runtime_enable(uport->dev);
+}
+
+static int msm_hs_runtime_suspend(struct device *dev)
+{
+	msm_hs_pm_suspend(dev);
+	return 0;
+}
+
+static int msm_hs_runtime_resume(struct device *dev)
+{
+	return msm_hs_pm_resume(dev);
+}
+#else
+static void  msm_serial_hs_rt_init(struct uart_port *uport) {}
+static int msm_hs_runtime_suspend(struct device *dev) {}
+static int msm_hs_runtime_resume(struct device *dev) {}
+#endif
+
+
+static int msm_hs_probe(struct platform_device *pdev)
+{
+	int ret = 0;
+	struct uart_port *uport;
+	struct msm_hs_port *msm_uport;
+	struct resource *core_resource;
+	struct resource *bam_resource;
+	int core_irqres, bam_irqres, wakeup_irqres;
+	struct msm_serial_hs_platform_data *pdata = pdev->dev.platform_data;
+	unsigned long data;
+	char name[30];
+
+	if (pdev->dev.of_node) {
+		dev_dbg(&pdev->dev, "device tree enabled\n");
+		pdata = msm_hs_dt_to_pdata(pdev);
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+
+		if (pdev->id < 0) {
+			pdev->id = device_id_grab_next_free();
+			if (pdev->id < 0) {
+				dev_err(&pdev->dev,
+					"Error grabbing next free device id");
+				return pdev->id;
+			}
+		} else {
+			ret = device_id_set_used(pdev->id);
+			if (ret < 0) {
+				dev_err(&pdev->dev, "%d alias taken",
+					pdev->id);
+				return ret;
+			}
+		}
+		pdev->dev.platform_data = pdata;
+	}
+
+	if (pdev->id < 0 || pdev->id >= UARTDM_NR) {
+		dev_err(&pdev->dev, "Invalid plaform device ID = %d\n",
+								pdev->id);
+		return -EINVAL;
+	}
+
+	msm_uport = devm_kzalloc(&pdev->dev, sizeof(struct msm_hs_port),
+			GFP_KERNEL);
+	if (!msm_uport)
+		return -ENOMEM;
+
+	msm_uport->uport.type = PORT_UNKNOWN;
+	uport = &msm_uport->uport;
+	uport->dev = &pdev->dev;
+
+	if (pdev->dev.of_node)
+		msm_uport->uart_type = BLSP_HSUART;
+
+	msm_hs_get_pinctrl_configs(uport);
+	/* Get required resources for BAM HSUART */
+	core_resource = platform_get_resource_byname(pdev,
+				IORESOURCE_MEM, "core_mem");
+	if (!core_resource) {
+		dev_err(&pdev->dev, "Invalid core HSUART Resources.\n");
+		return -ENXIO;
+	}
+	bam_resource = platform_get_resource_byname(pdev,
+				IORESOURCE_MEM, "bam_mem");
+	if (!bam_resource) {
+		dev_err(&pdev->dev, "Invalid BAM HSUART Resources.\n");
+		return -ENXIO;
+	}
+	core_irqres = platform_get_irq_byname(pdev, "core_irq");
+	if (core_irqres < 0) {
+		dev_err(&pdev->dev, "Error %d, invalid core irq resources.\n",
+			core_irqres);
+		return -ENXIO;
+	}
+	bam_irqres = platform_get_irq_byname(pdev, "bam_irq");
+	if (bam_irqres < 0) {
+		dev_err(&pdev->dev, "Error %d, invalid bam irq resources.\n",
+			bam_irqres);
+		return -ENXIO;
+	}
+	wakeup_irqres = platform_get_irq_byname(pdev, "wakeup_irq");
+	if (wakeup_irqres < 0) {
+		wakeup_irqres = -1;
+		pr_info("Wakeup irq not specified.\n");
+	}
+
+	uport->mapbase = core_resource->start;
+
+	uport->membase = ioremap(uport->mapbase,
+				resource_size(core_resource));
+	if (unlikely(!uport->membase)) {
+		dev_err(&pdev->dev, "UART Resource ioremap Failed.\n");
+		return -ENOMEM;
+	}
+	msm_uport->bam_mem = bam_resource->start;
+	msm_uport->bam_base = ioremap(msm_uport->bam_mem,
+				resource_size(bam_resource));
+	if (unlikely(!msm_uport->bam_base)) {
+		dev_err(&pdev->dev, "UART BAM Resource ioremap Failed.\n");
+		iounmap(uport->membase);
+		return -ENOMEM;
+	}
+
+	memset(name, 0, sizeof(name));
+	scnprintf(name, sizeof(name), "%s%s", dev_name(msm_uport->uport.dev),
+									"_state");
+	msm_uport->ipc_msm_hs_log_ctxt =
+			ipc_log_context_create(IPC_MSM_HS_LOG_STATE_PAGES,
+								name, 0);
+	if (!msm_uport->ipc_msm_hs_log_ctxt) {
+		dev_err(&pdev->dev, "%s: error creating logging context",
+								__func__);
+	} else {
+		msm_uport->ipc_debug_mask = INFO_LEV;
+		ret = sysfs_create_file(&pdev->dev.kobj,
+				&dev_attr_debug_mask.attr);
+		if (unlikely(ret))
+			MSM_HS_WARN("%s: Failed to create dev. attr", __func__);
+	}
+
+	uport->irq = core_irqres;
+	msm_uport->bam_irq = bam_irqres;
+	pdata->wakeup_irq = wakeup_irqres;
+
+	msm_uport->bus_scale_table = msm_bus_cl_get_pdata(pdev);
+	if (!msm_uport->bus_scale_table) {
+		MSM_HS_ERR("BLSP UART: Bus scaling is disabled.\n");
+	} else {
+		msm_uport->bus_perf_client =
+			msm_bus_scale_register_client
+				(msm_uport->bus_scale_table);
+		if (IS_ERR(&msm_uport->bus_perf_client)) {
+			MSM_HS_ERR("%s():Bus client register failed\n",
+				   __func__);
+			ret = -EINVAL;
+			goto unmap_memory;
+		}
+	}
+
+	msm_uport->wakeup.irq = pdata->wakeup_irq;
+	msm_uport->wakeup.ignore = 1;
+	msm_uport->wakeup.inject_rx = pdata->inject_rx_on_wakeup;
+	msm_uport->wakeup.rx_to_inject = pdata->rx_to_inject;
+	msm_uport->obs = pdata->obs;
+
+	msm_uport->bam_tx_ep_pipe_index =
+			pdata->bam_tx_ep_pipe_index;
+	msm_uport->bam_rx_ep_pipe_index =
+			pdata->bam_rx_ep_pipe_index;
+	msm_uport->wakeup.enabled = true;
+
+	uport->iotype = UPIO_MEM;
+	uport->fifosize = 64;
+	uport->ops = &msm_hs_ops;
+	uport->flags = UPF_BOOT_AUTOCONF;
+	uport->uartclk = 7372800;
+	msm_uport->imr_reg = 0x0;
+
+	msm_uport->clk = clk_get(&pdev->dev, "core_clk");
+	if (IS_ERR(msm_uport->clk)) {
+		ret = PTR_ERR(msm_uport->clk);
+		goto deregister_bus_client;
+	}
+
+	msm_uport->pclk = clk_get(&pdev->dev, "iface_clk");
+	/*
+	 * Some configurations do not require explicit pclk control so
+	 * do not flag error on pclk get failure.
+	 */
+	if (IS_ERR(msm_uport->pclk))
+		msm_uport->pclk = NULL;
+
+	msm_uport->hsuart_wq = alloc_workqueue("k_hsuart",
+					WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+	if (!msm_uport->hsuart_wq) {
+		MSM_HS_ERR("%s(): Unable to create workqueue hsuart_wq\n",
+								__func__);
+		ret =  -ENOMEM;
+		goto put_clk;
+	}
+
+	mutex_init(&msm_uport->mtx);
+
+	/* Initialize SPS HW connected with UART core */
+	ret = msm_hs_sps_init(msm_uport);
+	if (unlikely(ret)) {
+		MSM_HS_ERR("SPS Initialization failed ! err=%d", ret);
+		goto destroy_mutex;
+	}
+
+	msm_uport->tx.flush = FLUSH_SHUTDOWN;
+	msm_uport->rx.flush = FLUSH_SHUTDOWN;
+
+	memset(name, 0, sizeof(name));
+	scnprintf(name, sizeof(name), "%s%s", dev_name(msm_uport->uport.dev),
+									"_tx");
+	msm_uport->tx.ipc_tx_ctxt =
+		ipc_log_context_create(IPC_MSM_HS_LOG_DATA_PAGES, name, 0);
+	if (!msm_uport->tx.ipc_tx_ctxt)
+		dev_err(&pdev->dev, "%s: error creating tx logging context",
+								__func__);
+
+	memset(name, 0, sizeof(name));
+	scnprintf(name, sizeof(name), "%s%s", dev_name(msm_uport->uport.dev),
+									"_rx");
+	msm_uport->rx.ipc_rx_ctxt = ipc_log_context_create(
+					IPC_MSM_HS_LOG_DATA_PAGES, name, 0);
+	if (!msm_uport->rx.ipc_rx_ctxt)
+		dev_err(&pdev->dev, "%s: error creating rx logging context",
+								__func__);
+
+	memset(name, 0, sizeof(name));
+	scnprintf(name, sizeof(name), "%s%s", dev_name(msm_uport->uport.dev),
+									"_pwr");
+	msm_uport->ipc_msm_hs_pwr_ctxt = ipc_log_context_create(
+					IPC_MSM_HS_LOG_USER_PAGES, name, 0);
+	if (!msm_uport->ipc_msm_hs_pwr_ctxt)
+		dev_err(&pdev->dev, "%s: error creating usr logging context",
+								__func__);
+
+	uport->irq = core_irqres;
+	msm_uport->bam_irq = bam_irqres;
+
+	clk_set_rate(msm_uport->clk, msm_uport->uport.uartclk);
+	msm_hs_clk_bus_vote(msm_uport);
+	ret = uartdm_init_port(uport);
+	if (unlikely(ret))
+		goto err_clock;
+
+	/* configure the CR Protection to Enable */
+	msm_hs_write(uport, UART_DM_CR, CR_PROTECTION_EN);
+
+	/*
+	 * Enable Command register protection before going ahead as this hw
+	 * configuration makes sure that issued cmd to CR register gets complete
+	 * before next issued cmd start. Hence mb() requires here.
+	 */
+	mb();
+
+	/*
+	 * Set RX_BREAK_ZERO_CHAR_OFF and RX_ERROR_CHAR_OFF
+	 * so any rx_break and character having parity of framing
+	 * error don't enter inside UART RX FIFO.
+	 */
+	data = msm_hs_read(uport, UART_DM_MR2);
+	data |= (UARTDM_MR2_RX_BREAK_ZERO_CHAR_OFF |
+			UARTDM_MR2_RX_ERROR_CHAR_OFF);
+	msm_hs_write(uport, UART_DM_MR2, data);
+	/* Ensure register IO completion */
+	mb();
+
+	ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_clock.attr);
+	if (unlikely(ret)) {
+		MSM_HS_ERR("Probe Failed as sysfs failed\n");
+		goto err_clock;
+	}
+
+	msm_serial_debugfs_init(msm_uport, pdev->id);
+	msm_hs_unconfig_uart_gpios(uport);
+
+	uport->line = pdev->id;
+	if (pdata->userid && pdata->userid <= UARTDM_NR)
+		uport->line = pdata->userid;
+	ret = uart_add_one_port(&msm_hs_driver, uport);
+	if (!ret) {
+		msm_hs_clk_bus_unvote(msm_uport);
+		msm_serial_hs_rt_init(uport);
+		return ret;
+	}
+
+err_clock:
+	msm_hs_clk_bus_unvote(msm_uport);
+
+destroy_mutex:
+	mutex_destroy(&msm_uport->mtx);
+	destroy_workqueue(msm_uport->hsuart_wq);
+
+put_clk:
+	if (msm_uport->pclk)
+		clk_put(msm_uport->pclk);
+
+	if (msm_uport->clk)
+		clk_put(msm_uport->clk);
+
+deregister_bus_client:
+	msm_bus_scale_unregister_client(msm_uport->bus_perf_client);
+unmap_memory:
+	iounmap(uport->membase);
+	iounmap(msm_uport->bam_base);
+
+	return ret;
+}
+
+static int __init msm_serial_hs_init(void)
+{
+	int ret;
+
+	ret = uart_register_driver(&msm_hs_driver);
+	if (unlikely(ret)) {
+		pr_err("%s failed to load\n", __func__);
+		return ret;
+	}
+	debug_base = debugfs_create_dir("msm_serial_hs", NULL);
+	if (IS_ERR_OR_NULL(debug_base))
+		pr_err("msm_serial_hs: Cannot create debugfs dir\n");
+
+	ret = platform_driver_register(&msm_serial_hs_platform_driver);
+	if (ret) {
+		pr_err("%s failed to load\n", __func__);
+		debugfs_remove_recursive(debug_base);
+		uart_unregister_driver(&msm_hs_driver);
+		return ret;
+	}
+
+	pr_info("msm_serial_hs module loaded\n");
+	return ret;
+}
+
+/*
+ *  Called by the upper layer when port is closed.
+ *     - Disables the port
+ *     - Unhook the ISR
+ */
+static void msm_hs_shutdown(struct uart_port *uport)
+{
+	int ret, rc;
+	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
+	struct circ_buf *tx_buf = &uport->state->xmit;
+	int data;
+	unsigned long flags;
+
+	if (is_use_low_power_wakeup(msm_uport))
+		irq_set_irq_wake(msm_uport->wakeup.irq, 0);
+
+	if (msm_uport->wakeup.enabled)
+		disable_irq(msm_uport->wakeup.irq);
+	else
+		disable_irq(uport->irq);
+
+	spin_lock_irqsave(&uport->lock, flags);
+	msm_uport->wakeup.enabled = false;
+	msm_uport->wakeup.ignore = 1;
+	spin_unlock_irqrestore(&uport->lock, flags);
+
+	/* Free the interrupt */
+	free_irq(uport->irq, msm_uport);
+	if (is_use_low_power_wakeup(msm_uport)) {
+		free_irq(msm_uport->wakeup.irq, msm_uport);
+		MSM_HS_DBG("%s(): wakeup irq freed", __func__);
+	}
+	msm_uport->wakeup.freed = true;
+
+	/* make sure tx lh finishes */
+	kthread_flush_worker(&msm_uport->tx.kworker);
+	ret = wait_event_timeout(msm_uport->tx.wait,
+			uart_circ_empty(tx_buf), 500);
+	if (!ret)
+		MSM_HS_WARN("Shutdown called when tx buff not empty");
+
+	msm_hs_resource_vote(msm_uport);
+	/* Stop remote side from sending data */
+	msm_hs_disable_flow_control(uport, false);
+	/* make sure rx lh finishes */
+	kthread_flush_worker(&msm_uport->rx.kworker);
+
+	if (msm_uport->rx.flush != FLUSH_SHUTDOWN) {
+		/* disable and disconnect rx */
+		ret = wait_event_timeout(msm_uport->rx.wait,
+				!msm_uport->rx.pending_flag, 500);
+		if (!ret)
+			MSM_HS_WARN("%s(): rx disconnect not complete",
+				__func__);
+		msm_hs_disconnect_rx(uport);
+	}
+
+	cancel_delayed_work_sync(&msm_uport->rx.flip_insert_work);
+	flush_workqueue(msm_uport->hsuart_wq);
+
+	/* BAM Disconnect for TX */
+	data = msm_hs_read(uport, UART_DM_DMEN);
+	data &= ~UARTDM_TX_BAM_ENABLE_BMSK;
+	msm_hs_write(uport, UART_DM_DMEN, data);
+	ret = sps_tx_disconnect(msm_uport);
+	if (ret)
+		MSM_HS_ERR("%s(): sps_disconnect failed\n",
+					__func__);
+	msm_uport->tx.flush = FLUSH_SHUTDOWN;
+	/* Disable the transmitter */
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_TX_DISABLE_BMSK);
+	/* Disable the receiver */
+	msm_hs_write(uport, UART_DM_CR, UARTDM_CR_RX_DISABLE_BMSK);
+
+	msm_uport->imr_reg = 0;
+	msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
+	/*
+	 * Complete all device write before actually disabling uartclk.
+	 * Hence mb() requires here.
+	 */
+	mb();
+
+	msm_uport->rx.buffer_pending = NONE_PENDING;
+	MSM_HS_DBG("%s(): tx, rx events complete", __func__);
+
+	dma_unmap_single(uport->dev, msm_uport->tx.dma_base,
+			 UART_XMIT_SIZE, DMA_TO_DEVICE);
+
+	msm_hs_resource_unvote(msm_uport);
+	rc = atomic_read(&msm_uport->resource_count);
+	if (rc) {
+		atomic_set(&msm_uport->resource_count, 1);
+		MSM_HS_WARN("%s(): removing extra vote\n", __func__);
+		msm_hs_resource_unvote(msm_uport);
+	}
+	if (atomic_read(&msm_uport->client_req_state)) {
+		MSM_HS_WARN("%s: Client clock vote imbalance\n", __func__);
+		atomic_set(&msm_uport->client_req_state, 0);
+	}
+	if (atomic_read(&msm_uport->client_count)) {
+		MSM_HS_WARN("%s: Client vote on, forcing to 0\n", __func__);
+		atomic_set(&msm_uport->client_count, 0);
+		LOG_USR_MSG(msm_uport->ipc_msm_hs_pwr_ctxt,
+			"%s: Client_Count 0\n", __func__);
+	}
+	msm_hs_unconfig_uart_gpios(uport);
+	MSM_HS_INFO("%s:UART port closed successfully\n", __func__);
+}
+
+static void __exit msm_serial_hs_exit(void)
+{
+	pr_info("msm_serial_hs module removed\n");
+	debugfs_remove_recursive(debug_base);
+	platform_driver_unregister(&msm_serial_hs_platform_driver);
+	uart_unregister_driver(&msm_hs_driver);
+}
+
+static const struct dev_pm_ops msm_hs_dev_pm_ops = {
+	.runtime_suspend = msm_hs_runtime_suspend,
+	.runtime_resume = msm_hs_runtime_resume,
+	.runtime_idle = NULL,
+	.suspend_noirq = msm_hs_pm_sys_suspend_noirq,
+	.resume_noirq = msm_hs_pm_sys_resume_noirq,
+};
+
+static struct platform_driver msm_serial_hs_platform_driver = {
+	.probe	= msm_hs_probe,
+	.remove = msm_hs_remove,
+	.driver = {
+		.name = "msm_serial_hs",
+		.pm   = &msm_hs_dev_pm_ops,
+		.of_match_table = msm_hs_match_table,
+	},
+};
+
+static struct uart_driver msm_hs_driver = {
+	.owner = THIS_MODULE,
+	.driver_name = "msm_serial_hs",
+	.dev_name = "ttyHS",
+	.nr = UARTDM_NR,
+	.cons = 0,
+};
+
+static const struct uart_ops msm_hs_ops = {
+	.tx_empty = msm_hs_tx_empty,
+	.set_mctrl = msm_hs_set_mctrl_locked,
+	.get_mctrl = msm_hs_get_mctrl_locked,
+	.stop_tx = msm_hs_stop_tx_locked,
+	.start_tx = msm_hs_start_tx_locked,
+	.stop_rx = msm_hs_stop_rx_locked,
+	.enable_ms = msm_hs_enable_ms_locked,
+	.break_ctl = msm_hs_break_ctl,
+	.startup = msm_hs_startup,
+	.shutdown = msm_hs_shutdown,
+	.set_termios = msm_hs_set_termios,
+	.type = msm_hs_type,
+	.config_port = msm_hs_config_port,
+	.flush_buffer = NULL,
+	.ioctl = msm_hs_ioctl,
+};
+
+module_init(msm_serial_hs_init);
+module_exit(msm_serial_hs_exit);
+MODULE_DESCRIPTION("High Speed UART Driver for the MSM chipset");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/tty/serial/msm_serial_hs_hwreg.h b/drivers/tty/serial/msm_serial_hs_hwreg.h
new file mode 100644
index 0000000..d5ce41f
--- /dev/null
+++ b/drivers/tty/serial/msm_serial_hs_hwreg.h
@@ -0,0 +1,283 @@
+/* drivers/serial/msm_serial_hs_hwreg.h
+ *
+ * Copyright (c) 2007-2009, 2012-2014,The Linux Foundation. All rights reserved.
+ *
+ * All source code in this file is licensed under the following license
+ * except where indicated.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can find it at http://www.fsf.org
+ */
+
+#ifndef MSM_SERIAL_HS_HWREG_H
+#define MSM_SERIAL_HS_HWREG_H
+
+#define GSBI_CONTROL_ADDR              0x0
+#define GSBI_PROTOCOL_CODE_MASK        0x30
+#define GSBI_PROTOCOL_I2C_UART         0x60
+#define GSBI_PROTOCOL_UART             0x40
+#define GSBI_PROTOCOL_IDLE             0x0
+
+#define TCSR_ADM_1_A_CRCI_MUX_SEL      0x78
+#define TCSR_ADM_1_B_CRCI_MUX_SEL      0x7C
+#define ADM1_CRCI_GSBI6_RX_SEL         0x800
+#define ADM1_CRCI_GSBI6_TX_SEL         0x400
+
+#define MSM_ENABLE_UART_CLOCK TIOCPMGET
+#define MSM_DISABLE_UART_CLOCK TIOCPMPUT
+#define MSM_GET_UART_CLOCK_STATUS TIOCPMACT
+
+enum msm_hsl_regs {
+	UARTDM_MR1,
+	UARTDM_MR2,
+	UARTDM_IMR,
+	UARTDM_SR,
+	UARTDM_CR,
+	UARTDM_CSR,
+	UARTDM_IPR,
+	UARTDM_ISR,
+	UARTDM_RX_TOTAL_SNAP,
+	UARTDM_RFWR,
+	UARTDM_TFWR,
+	UARTDM_RF,
+	UARTDM_TF,
+	UARTDM_MISR,
+	UARTDM_DMRX,
+	UARTDM_NCF_TX,
+	UARTDM_DMEN,
+	UARTDM_BCR,
+	UARTDM_TXFS,
+	UARTDM_RXFS,
+	UARTDM_LAST,
+};
+
+enum msm_hs_regs {
+	UART_DM_MR1 = 0x0,
+	UART_DM_MR2 = 0x4,
+	UART_DM_IMR = 0xb0,
+	UART_DM_SR = 0xa4,
+	UART_DM_CR = 0xa8,
+	UART_DM_CSR = 0xa0,
+	UART_DM_IPR = 0x18,
+	UART_DM_ISR = 0xb4,
+	UART_DM_RX_TOTAL_SNAP = 0xbc,
+	UART_DM_TFWR = 0x1c,
+	UART_DM_RFWR = 0x20,
+	UART_DM_RF = 0x140,
+	UART_DM_TF = 0x100,
+	UART_DM_MISR = 0xac,
+	UART_DM_DMRX = 0x34,
+	UART_DM_NCF_TX = 0x40,
+	UART_DM_DMEN = 0x3c,
+	UART_DM_TXFS = 0x4c,
+	UART_DM_RXFS = 0x50,
+	UART_DM_RX_TRANS_CTRL = 0xcc,
+	UART_DM_BCR = 0xc8,
+};
+
+#define UARTDM_MR1_ADDR 0x0
+#define UARTDM_MR2_ADDR 0x4
+
+/* Backward Compatibility Register for UARTDM Core v1.4 */
+#define UARTDM_BCR_ADDR	0xc8
+
+/*
+ * UARTDM Core v1.4 STALE_IRQ_EMPTY bit defination
+ * Stale interrupt will fire if bit is set when RX-FIFO is empty
+ */
+#define UARTDM_BCR_TX_BREAK_DISABLE	0x1
+#define UARTDM_BCR_STALE_IRQ_EMPTY	0x2
+#define UARTDM_BCR_RX_DMRX_LOW_EN	0x4
+#define UARTDM_BCR_RX_STAL_IRQ_DMRX_EQL	0x10
+#define UARTDM_BCR_RX_DMRX_1BYTE_RES_EN	0x20
+
+/* TRANSFER_CONTROL Register for UARTDM Core v1.4 */
+#define UARTDM_RX_TRANS_CTRL_ADDR      0xcc
+
+/* TRANSFER_CONTROL Register bits */
+#define RX_STALE_AUTO_RE_EN		0x1
+#define RX_TRANS_AUTO_RE_ACTIVATE	0x2
+#define RX_DMRX_CYCLIC_EN		0x4
+
+/* write only register */
+#define UARTDM_CSR_115200 0xFF
+#define UARTDM_CSR_57600  0xEE
+#define UARTDM_CSR_38400  0xDD
+#define UARTDM_CSR_28800  0xCC
+#define UARTDM_CSR_19200  0xBB
+#define UARTDM_CSR_14400  0xAA
+#define UARTDM_CSR_9600   0x99
+#define UARTDM_CSR_7200   0x88
+#define UARTDM_CSR_4800   0x77
+#define UARTDM_CSR_3600   0x66
+#define UARTDM_CSR_2400   0x55
+#define UARTDM_CSR_1200   0x44
+#define UARTDM_CSR_600    0x33
+#define UARTDM_CSR_300    0x22
+#define UARTDM_CSR_150    0x11
+#define UARTDM_CSR_75     0x00
+
+/* write only register */
+#define UARTDM_IPR_ADDR 0x18
+#define UARTDM_TFWR_ADDR 0x1c
+#define UARTDM_RFWR_ADDR 0x20
+#define UARTDM_HCR_ADDR 0x24
+#define UARTDM_DMRX_ADDR 0x34
+#define UARTDM_DMEN_ADDR 0x3c
+
+/* UART_DM_NO_CHARS_FOR_TX */
+#define UARTDM_NCF_TX_ADDR 0x40
+
+#define UARTDM_BADR_ADDR 0x44
+
+#define UARTDM_SIM_CFG_ADDR 0x80
+
+/* Read Only register */
+#define UARTDM_TXFS_ADDR 0x4C
+#define UARTDM_RXFS_ADDR 0x50
+
+/* Register field Mask Mapping */
+#define UARTDM_SR_RX_BREAK_BMSK	        BIT(6)
+#define UARTDM_SR_PAR_FRAME_BMSK	BIT(5)
+#define UARTDM_SR_OVERRUN_BMSK		BIT(4)
+#define UARTDM_SR_TXEMT_BMSK		BIT(3)
+#define UARTDM_SR_TXRDY_BMSK		BIT(2)
+#define UARTDM_SR_RXRDY_BMSK		BIT(0)
+
+#define UARTDM_CR_TX_DISABLE_BMSK	BIT(3)
+#define UARTDM_CR_RX_DISABLE_BMSK	BIT(1)
+#define UARTDM_CR_TX_EN_BMSK		BIT(2)
+#define UARTDM_CR_RX_EN_BMSK		BIT(0)
+
+/* UARTDM_CR channel_comman bit value (register field is bits 8:4) */
+#define RESET_RX		0x10
+#define RESET_TX		0x20
+#define RESET_ERROR_STATUS	0x30
+#define RESET_BREAK_INT		0x40
+#define START_BREAK		0x50
+#define STOP_BREAK		0x60
+#define RESET_CTS		0x70
+#define RESET_STALE_INT		0x80
+#define RFR_LOW			0xD0
+#define RFR_HIGH		0xE0
+#define CR_PROTECTION_EN	0x100
+#define STALE_EVENT_ENABLE	0x500
+#define STALE_EVENT_DISABLE	0x600
+#define FORCE_STALE_EVENT	0x400
+#define CLEAR_TX_READY		0x300
+#define RESET_TX_ERROR		0x800
+#define RESET_TX_DONE		0x810
+
+/*
+ * UARTDM_CR BAM IFC comman bit value
+ * for UARTDM Core v1.4
+ */
+#define START_RX_BAM_IFC	0x850
+#define START_TX_BAM_IFC	0x860
+
+#define UARTDM_MR1_AUTO_RFR_LEVEL1_BMSK 0xffffff00
+#define UARTDM_MR1_AUTO_RFR_LEVEL0_BMSK 0x3f
+#define UARTDM_MR1_CTS_CTL_BMSK 0x40
+#define UARTDM_MR1_RX_RDY_CTL_BMSK 0x80
+
+/*
+ * UARTDM Core v1.4 MR2_RFR_CTS_LOOP bitmask
+ * Enables internal loopback between RFR_N of
+ * RX channel and CTS_N of TX channel.
+ */
+#define UARTDM_MR2_RFR_CTS_LOOP_MODE_BMSK	0x400
+
+#define UARTDM_MR2_LOOP_MODE_BMSK		0x80
+#define UARTDM_MR2_ERROR_MODE_BMSK		0x40
+#define UARTDM_MR2_BITS_PER_CHAR_BMSK		0x30
+#define UARTDM_MR2_RX_ZERO_CHAR_OFF		0x100
+#define UARTDM_MR2_RX_ERROR_CHAR_OFF		0x200
+#define UARTDM_MR2_RX_BREAK_ZERO_CHAR_OFF	0x100
+
+#define UARTDM_MR2_BITS_PER_CHAR_8	(0x3 << 4)
+
+/* bits per character configuration */
+#define FIVE_BPC  (0 << 4)
+#define SIX_BPC   (1 << 4)
+#define SEVEN_BPC (2 << 4)
+#define EIGHT_BPC (3 << 4)
+
+#define UARTDM_MR2_STOP_BIT_LEN_BMSK 0xc
+#define STOP_BIT_ONE (1 << 2)
+#define STOP_BIT_TWO (3 << 2)
+
+#define UARTDM_MR2_PARITY_MODE_BMSK 0x3
+
+/* Parity configuration */
+#define NO_PARITY 0x0
+#define EVEN_PARITY 0x2
+#define ODD_PARITY 0x1
+#define SPACE_PARITY 0x3
+
+#define UARTDM_IPR_STALE_TIMEOUT_MSB_BMSK 0xffffff80
+#define UARTDM_IPR_STALE_LSB_BMSK 0x1f
+
+/* These can be used for both ISR and IMR register */
+#define UARTDM_ISR_TX_READY_BMSK	BIT(7)
+#define UARTDM_ISR_CURRENT_CTS_BMSK	BIT(6)
+#define UARTDM_ISR_DELTA_CTS_BMSK	BIT(5)
+#define UARTDM_ISR_RXLEV_BMSK		BIT(4)
+#define UARTDM_ISR_RXSTALE_BMSK		BIT(3)
+#define UARTDM_ISR_RXBREAK_BMSK		BIT(2)
+#define UARTDM_ISR_RXHUNT_BMSK		BIT(1)
+#define UARTDM_ISR_TXLEV_BMSK		BIT(0)
+
+/* Field definitions for UART_DM_DMEN*/
+#define UARTDM_TX_DM_EN_BMSK 0x1
+#define UARTDM_RX_DM_EN_BMSK 0x2
+
+/*
+ * UARTDM Core v1.4 bitmask
+ * Bitmasks for enabling Rx and Tx BAM Interface
+ */
+#define UARTDM_TX_BAM_ENABLE_BMSK 0x4
+#define UARTDM_RX_BAM_ENABLE_BMSK 0x8
+
+/* Register offsets for UART Core v13 */
+
+/* write only register */
+#define UARTDM_CSR_ADDR    0x8
+
+/* write only register */
+#define UARTDM_TF_ADDR   0x70
+#define UARTDM_TF2_ADDR  0x74
+#define UARTDM_TF3_ADDR  0x78
+#define UARTDM_TF4_ADDR  0x7c
+
+/* write only register */
+#define UARTDM_CR_ADDR 0x10
+/* write only register */
+#define UARTDM_IMR_ADDR 0x14
+#define UARTDM_IRDA_ADDR 0x38
+
+/* Read Only register */
+#define UARTDM_SR_ADDR 0x8
+
+/* Read Only register */
+#define UARTDM_RF_ADDR   0x70
+#define UARTDM_RF2_ADDR  0x74
+#define UARTDM_RF3_ADDR  0x78
+#define UARTDM_RF4_ADDR  0x7c
+
+/* Read Only register */
+#define UARTDM_MISR_ADDR 0x10
+
+/* Read Only register */
+#define UARTDM_ISR_ADDR 0x14
+#define UARTDM_RX_TOTAL_SNAP_ADDR 0x38
+
+#endif /* MSM_SERIAL_HS_HWREG_H */
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 840930b0..c8075eb 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -629,6 +629,8 @@
 	if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET &&
 			as->status != -ENOENT)
 		cancel_bulk_urbs(ps, as->bulk_addr);
+
+	wake_up(&ps->wait);
 	spin_unlock(&ps->lock);
 
 	if (signr) {
@@ -636,8 +638,6 @@
 		put_pid(pid);
 		put_cred(cred);
 	}
-
-	wake_up(&ps->wait);
 }
 
 static void destroy_async(struct usb_dev_state *ps, struct list_head *list)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index e07fa76..7b8ca7d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1878,7 +1878,7 @@
 	/* No more submits can occur */
 	spin_lock_irq(&hcd_urb_list_lock);
 rescan:
-	list_for_each_entry (urb, &ep->urb_list, urb_list) {
+	list_for_each_entry_reverse(urb, &ep->urb_list, urb_list) {
 		int	is_in;
 
 		if (urb->unlinked)
@@ -2256,39 +2256,38 @@
 
 /*-------------------------------------------------------------------------*/
 
-dma_addr_t
-usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
-	unsigned int intr_num)
+phys_addr_t
+usb_hcd_get_sec_event_ring_phys_addr(struct usb_device *udev,
+	unsigned int intr_num, dma_addr_t *dma)
 {
 	struct usb_hcd	*hcd = bus_to_hcd(udev->bus);
 
 	if (!HCD_RH_RUNNING(hcd))
 		return 0;
 
-	return hcd->driver->get_sec_event_ring_dma_addr(hcd, intr_num);
+	return hcd->driver->get_sec_event_ring_phys_addr(hcd, intr_num, dma);
 }
 
-dma_addr_t
-usb_hcd_get_dcba_dma_addr(struct usb_device *udev)
+phys_addr_t
+usb_hcd_get_xfer_ring_phys_addr(struct usb_device *udev,
+		struct usb_host_endpoint *ep, dma_addr_t *dma)
 {
 	struct usb_hcd	*hcd = bus_to_hcd(udev->bus);
 
 	if (!HCD_RH_RUNNING(hcd))
 		return 0;
 
-	return hcd->driver->get_dcba_dma_addr(hcd, udev);
+	return hcd->driver->get_xfer_ring_phys_addr(hcd, udev, ep, dma);
 }
 
-dma_addr_t
-usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
-		struct usb_host_endpoint *ep)
+int usb_hcd_get_controller_id(struct usb_device *udev)
 {
 	struct usb_hcd	*hcd = bus_to_hcd(udev->bus);
 
 	if (!HCD_RH_RUNNING(hcd))
-		return 0;
+		return -EINVAL;
 
-	return hcd->driver->get_xfer_ring_dma_addr(hcd, udev, ep);
+	return hcd->driver->get_core_id(hcd);
 }
 
 #ifdef	CONFIG_PM
@@ -2532,6 +2531,8 @@
 	}
 	if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) {
 		hcd = hcd->shared_hcd;
+		clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
+		set_bit(HCD_FLAG_DEAD, &hcd->flags);
 		if (hcd->rh_registered) {
 			clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 50679bc..3b0cc03 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4741,7 +4741,8 @@
 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 		u16 portchange)
 {
-	int status, i;
+	int status = -ENODEV;
+	int i;
 	unsigned unit_load;
 	struct usb_device *hdev = hub->hdev;
 	struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
@@ -4945,9 +4946,10 @@
 
 done:
 	hub_port_disable(hub, port1, 1);
-	if (hcd->driver->relinquish_port && !hub->hdev->parent)
-		hcd->driver->relinquish_port(hcd, port1);
-
+	if (hcd->driver->relinquish_port && !hub->hdev->parent) {
+		if (status != -ENOTCONN && status != -ENODEV)
+			hcd->driver->relinquish_port(hcd, port1);
+	}
 }
 
 /* Handle physical or logical connection change events.
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3a47077..41a9845 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1416,6 +1416,175 @@
 EXPORT_SYMBOL_GPL(usb_set_interface);
 
 /**
+ * usb_set_interface_timeout - Makes a particular alternate setting be current
+ * and allows to set a timout value for this control transfer.
+ * @dev: the device whose interface is being updated
+ * @interface: the interface being updated
+ * @alternate: the setting being chosen.
+ * @timeout: timeout value in ms (non-zero), before which this transfer should
+ * complete.
+ * Context: !in_interrupt ()
+ *
+ * This is used to enable data transfers on interfaces that may not
+ * be enabled by default.  Not all devices support such configurability.
+ * Only the driver bound to an interface may change its setting.
+ *
+ * Within any given configuration, each interface may have several
+ * alternative settings.  These are often used to control levels of
+ * bandwidth consumption.  For example, the default setting for a high
+ * speed interrupt endpoint may not send more than 64 bytes per microframe,
+ * while interrupt transfers of up to 3KBytes per microframe are legal.
+ * Also, isochronous endpoints may never be part of an
+ * interface's default setting.  To access such bandwidth, alternate
+ * interface settings must be made current.
+ *
+ * Note that in the Linux USB subsystem, bandwidth associated with
+ * an endpoint in a given alternate setting is not reserved until an URB
+ * is submitted that needs that bandwidth.  Some other operating systems
+ * allocate bandwidth early, when a configuration is chosen.
+ *
+ * This call is synchronous, and may not be used in an interrupt context.
+ * Also, drivers must not change altsettings while urbs are scheduled for
+ * endpoints in that interface; all such urbs must first be completed
+ * (perhaps forced by unlinking).
+ *
+ * Return: Zero on success, or else the status code returned by the
+ * underlying usb_control_msg() call.
+ */
+int usb_set_interface_timeout(struct usb_device *dev, int interface,
+	int alternate, unsigned long timeout_ms)
+{
+	struct usb_interface *iface;
+	struct usb_host_interface *alt;
+	struct usb_hcd *hcd = bus_to_hcd(dev->bus);
+	int i, ret, manual = 0;
+	unsigned int epaddr;
+	unsigned int pipe;
+
+	if (dev->state == USB_STATE_SUSPENDED)
+		return -EHOSTUNREACH;
+
+	iface = usb_ifnum_to_if(dev, interface);
+	if (!iface) {
+		dev_dbg(&dev->dev, "selecting invalid interface %d\n",
+			interface);
+		return -EINVAL;
+	}
+	if (iface->unregistering)
+		return -ENODEV;
+
+	alt = usb_altnum_to_altsetting(iface, alternate);
+	if (!alt) {
+		dev_warn(&dev->dev, "selecting invalid altsetting %d\n",
+			 alternate);
+		return -EINVAL;
+	}
+
+	/* Make sure we have enough bandwidth for this alternate interface.
+	 * Remove the current alt setting and add the new alt setting.
+	 */
+	mutex_lock(hcd->bandwidth_mutex);
+	/* Disable LPM, and re-enable it once the new alt setting is installed,
+	 * so that the xHCI driver can recalculate the U1/U2 timeouts.
+	 */
+	if (usb_disable_lpm(dev)) {
+		dev_err(&iface->dev, "%s Failed to disable LPM\n.", __func__);
+		mutex_unlock(hcd->bandwidth_mutex);
+		return -ENOMEM;
+	}
+	/* Changing alt-setting also frees any allocated streams */
+	for (i = 0; i < iface->cur_altsetting->desc.bNumEndpoints; i++)
+		iface->cur_altsetting->endpoint[i].streams = 0;
+
+	ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt);
+	if (ret < 0) {
+		dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n",
+				alternate);
+		usb_enable_lpm(dev);
+		mutex_unlock(hcd->bandwidth_mutex);
+		return ret;
+	}
+
+	if (dev->quirks & USB_QUIRK_NO_SET_INTF)
+		ret = -EPIPE;
+	else
+		ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				   USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
+				   alternate, interface, NULL, 0, timeout_ms);
+
+	/* 9.4.10 says devices don't need this and are free to STALL the
+	 * request if the interface only has one alternate setting.
+	 */
+	if (ret == -EPIPE && iface->num_altsetting == 1) {
+		dev_dbg(&dev->dev,
+			"manual set_interface for iface %d, alt %d\n",
+			interface, alternate);
+		manual = 1;
+	} else if (ret < 0) {
+		/* Re-instate the old alt setting */
+		usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting);
+		usb_enable_lpm(dev);
+		mutex_unlock(hcd->bandwidth_mutex);
+		return ret;
+	}
+	mutex_unlock(hcd->bandwidth_mutex);
+
+	/* FIXME drivers shouldn't need to replicate/bugfix the logic here
+	 * when they implement async or easily-killable versions of this or
+	 * other "should-be-internal" functions (like clear_halt).
+	 * should hcd+usbcore postprocess control requests?
+	 */
+
+	/* prevent submissions using previous endpoint settings */
+	if (iface->cur_altsetting != alt) {
+		remove_intf_ep_devs(iface);
+		usb_remove_sysfs_intf_files(iface);
+	}
+	usb_disable_interface(dev, iface, true);
+
+	iface->cur_altsetting = alt;
+
+	/* Now that the interface is installed, re-enable LPM. */
+	usb_unlocked_enable_lpm(dev);
+
+	/* If the interface only has one altsetting and the device didn't
+	 * accept the request, we attempt to carry out the equivalent action
+	 * by manually clearing the HALT feature for each endpoint in the
+	 * new altsetting.
+	 */
+	if (manual) {
+		for (i = 0; i < alt->desc.bNumEndpoints; i++) {
+			epaddr = alt->endpoint[i].desc.bEndpointAddress;
+			pipe = __create_pipe(dev,
+					USB_ENDPOINT_NUMBER_MASK & epaddr) |
+					(usb_endpoint_out(epaddr) ?
+					USB_DIR_OUT : USB_DIR_IN);
+
+			usb_clear_halt(dev, pipe);
+		}
+	}
+
+	/* 9.1.1.5: reset toggles for all endpoints in the new altsetting
+	 *
+	 * Note:
+	 * Despite EP0 is always present in all interfaces/AS, the list of
+	 * endpoints from the descriptor does not contain EP0. Due to its
+	 * omnipresence one might expect EP0 being considered "affected" by
+	 * any SetInterface request and hence assume toggles need to be reset.
+	 * However, EP0 toggles are re-synced for every individual transfer
+	 * during the SETUP stage - hence EP0 toggles are "don't care" here.
+	 * (Likewise, EP0 never "halts" on well designed devices.)
+	 */
+	usb_enable_interface(dev, iface, true);
+	if (device_is_registered(&iface->dev)) {
+		usb_create_sysfs_intf_files(iface);
+		create_intf_ep_devs(iface);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(usb_set_interface_timeout);
+
+/**
  * usb_reset_configuration - lightweight device reset
  * @dev: the device whose configuration is being reset
  *
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 3116edf..82806e3 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -57,8 +57,9 @@
 	/* Microsoft LifeCam-VX700 v2.0 */
 	{ USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
 
-	/* Logitech HD Pro Webcams C920 and C930e */
+	/* Logitech HD Pro Webcams C920, C920-C and C930e */
 	{ USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
+	{ USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
 	{ USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
 
 	/* Logitech ConferenceCam CC3000e */
@@ -150,6 +151,9 @@
 	/* appletouch */
 	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
+	{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
+
 	/* Avision AV600U */
 	{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
 	  USB_QUIRK_STRING_FETCH_255 },
@@ -214,6 +218,9 @@
 	{ USB_DEVICE(0x1a0a, 0x0200), .driver_info =
 			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
 
+	/* Corsair Strafe RGB */
+	{ USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
+
 	/* Acer C120 LED Projector */
 	{ USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
 
@@ -249,6 +256,7 @@
 	{ USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
 	{ USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
 	{ USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
+	{ USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
 
 	/* Logitech Optical Mouse M90/M100 */
 	{ USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 2776cfe..ef9cf4a 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -127,6 +127,22 @@
  */
 #define USB_ACPI_LOCATION_VALID (1 << 31)
 
+static struct acpi_device *usb_acpi_find_port(struct acpi_device *parent,
+					      int raw)
+{
+	struct acpi_device *adev;
+
+	if (!parent)
+		return NULL;
+
+	list_for_each_entry(adev, &parent->children, node) {
+		if (acpi_device_adr(adev) == raw)
+			return adev;
+	}
+
+	return acpi_find_child_device(parent, raw, false);
+}
+
 static struct acpi_device *usb_acpi_find_companion(struct device *dev)
 {
 	struct usb_device *udev;
@@ -174,8 +190,10 @@
 			int raw;
 
 			raw = usb_hcd_find_raw_port_number(hcd, port1);
-			adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev),
-					raw, false);
+
+			adev = usb_acpi_find_port(ACPI_COMPANION(&udev->dev),
+						  raw);
+
 			if (!adev)
 				return NULL;
 		} else {
@@ -186,7 +204,9 @@
 				return NULL;
 
 			acpi_bus_get_device(parent_handle, &adev);
-			adev = acpi_find_child_device(adev, port1, false);
+
+			adev = usb_acpi_find_port(adev, port1);
+
 			if (!adev)
 				return NULL;
 		}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 92e5d13..d745733 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -704,36 +704,35 @@
 }
 EXPORT_SYMBOL(usb_sec_event_ring_cleanup);
 
-dma_addr_t
-usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
-	unsigned int intr_num)
+phys_addr_t
+usb_get_sec_event_ring_phys_addr(struct usb_device *dev,
+	unsigned int intr_num, dma_addr_t *dma)
 {
 	if (dev->state == USB_STATE_NOTATTACHED)
 		return 0;
 
-	return usb_hcd_get_sec_event_ring_dma_addr(dev, intr_num);
+	return usb_hcd_get_sec_event_ring_phys_addr(dev, intr_num, dma);
 }
-EXPORT_SYMBOL(usb_get_sec_event_ring_dma_addr);
+EXPORT_SYMBOL(usb_get_sec_event_ring_phys_addr);
 
-dma_addr_t
-usb_get_dcba_dma_addr(struct usb_device *dev)
+phys_addr_t usb_get_xfer_ring_phys_addr(struct usb_device *dev,
+	struct usb_host_endpoint *ep, dma_addr_t *dma)
 {
 	if (dev->state == USB_STATE_NOTATTACHED)
 		return 0;
 
-	return usb_hcd_get_dcba_dma_addr(dev);
+	return usb_hcd_get_xfer_ring_phys_addr(dev, ep, dma);
 }
-EXPORT_SYMBOL(usb_get_dcba_dma_addr);
+EXPORT_SYMBOL(usb_get_xfer_ring_phys_addr);
 
-dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
-	struct usb_host_endpoint *ep)
+int usb_get_controller_id(struct usb_device *dev)
 {
 	if (dev->state == USB_STATE_NOTATTACHED)
-		return 0;
+		return -EINVAL;
 
-	return usb_hcd_get_xfer_ring_dma_addr(dev, ep);
+	return usb_hcd_get_controller_id(dev);
 }
-EXPORT_SYMBOL(usb_get_xfer_ring_dma_addr);
+EXPORT_SYMBOL(usb_get_controller_id);
 
 /*-------------------------------------------------------------------*/
 /*
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index aca5d97..d316821 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2857,8 +2857,7 @@
 }
 
 /*
- * Handle EUD based soft detach/attach event, and force USB high speed mode
- * functionality on receiving soft attach event.
+ * Handle EUD based soft detach/attach event
  *
  * @nb - notifier handler
  * @event - event information i.e. soft detach/attach event
@@ -2877,9 +2876,6 @@
 	if (mdwc->vbus_active == event)
 		return NOTIFY_DONE;
 
-	/* Force USB High-Speed enumeration Only */
-	dwc->maximum_speed = USB_SPEED_HIGH;
-	dbg_event(0xFF, "Speed", dwc->maximum_speed);
 	mdwc->vbus_active = event;
 	if (dwc->is_drd && !mdwc->in_restart)
 		queue_work(mdwc->dwc3_wq, &mdwc->resume_work);
@@ -3971,7 +3967,7 @@
 	}
 
 	ret = power_supply_set_property(mdwc->usb_psy,
-				POWER_SUPPLY_PROP_CURRENT_MAX, &pval);
+				POWER_SUPPLY_PROP_SDP_CURRENT_MAX, &pval);
 	if (ret) {
 		dev_dbg(mdwc->dev, "power supply error when setting property\n");
 		return ret;
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 5dd1832..35b6351 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
@@ -511,7 +512,7 @@
 
 	/* check the DMA Status */
 	reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
-
+	irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
 	ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
 					dwc3_omap_interrupt_thread, IRQF_SHARED,
 					"dwc3-omap", omap);
@@ -532,7 +533,7 @@
 	}
 
 	dwc3_omap_enable_irqs(omap);
-
+	enable_irq(omap->irq);
 	return 0;
 
 err2:
@@ -553,6 +554,7 @@
 	extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb);
 	extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb);
 	dwc3_omap_disable_irqs(omap);
+	disable_irq(omap->irq);
 	of_platform_depopulate(omap->dev);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index edd000b..9d247b8 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -279,7 +279,7 @@
 		dwc->ep0_bounced = false;
 		unmap_after_complete = true;
 	} else {
-		usb_gadget_unmap_request(&dwc->gadget,
+		usb_gadget_unmap_request_by_dev(dwc->sysdev,
 				&req->request, req->direction);
 	}
 
@@ -290,7 +290,7 @@
 	spin_lock(&dwc->lock);
 
 	if (unmap_after_complete)
-		usb_gadget_unmap_request(&dwc->gadget,
+		usb_gadget_unmap_request_by_dev(dwc->sysdev,
 				&req->request, req->direction);
 }
 
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 8a6ae0b..02adc93 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2155,7 +2155,7 @@
 	struct usb_gadget *gadget = dev_to_usb_gadget(dev);
 	struct usb_composite_dev *cdev = get_gadget_data(gadget);
 
-	return sprintf(buf, "%d\n", cdev->suspended);
+	return snprintf(buf, PAGE_SIZE, "%d\n", cdev->suspended);
 }
 static DEVICE_ATTR_RO(suspended);
 
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index f910990..d6e77a5 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1533,6 +1533,18 @@
 
 	gi = container_of(cdev, struct gadget_info, cdev);
 
+	/* FIXME: There's a race between usb_gadget_udc_stop() which is likely
+	 * to set the gadget driver to NULL in the udc driver and this drivers
+	 * gadget disconnect fn which likely checks for the gadget driver to
+	 * be a null ptr. It happens that unbind (doing set_gadget_data(NULL))
+	 * is called before the gadget driver is set to NULL and the udc driver
+	 * calls disconnect fn which results in cdev being a null ptr.
+	 */
+	if (cdev == NULL) {
+		WARN(1, "%s: gadget driver already disconnected\n", __func__);
+		return;
+	}
+
 	/* accessory HID support can be active while the
 		accessory function is not actually enabled,
 		so we need to inform it when we are disconnected.
diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c
index a7cb586..9240956 100644
--- a/drivers/usb/gadget/function/f_accessory.c
+++ b/drivers/usb/gadget/function/f_accessory.c
@@ -864,6 +864,14 @@
 	.probe = acc_hid_probe,
 };
 
+static void acc_complete_setup_noop(struct usb_ep *ep, struct usb_request *req)
+{
+	/*
+	 * Default no-op function when nothing needs to be done for the
+	 * setup request
+	 */
+}
+
 int acc_ctrlrequest(struct usb_composite_dev *cdev,
 				const struct usb_ctrlrequest *ctrl)
 {
@@ -891,6 +899,7 @@
 			schedule_delayed_work(
 				&dev->start_work, msecs_to_jiffies(10));
 			value = 0;
+			cdev->req->complete = acc_complete_setup_noop;
 		} else if (b_request == ACCESSORY_SEND_STRING) {
 			dev->string_index = w_index;
 			cdev->gadget->ep0->driver_data = dev;
@@ -899,10 +908,13 @@
 		} else if (b_request == ACCESSORY_SET_AUDIO_MODE &&
 				w_index == 0 && w_length == 0) {
 			dev->audio_mode = w_value;
+			cdev->req->complete = acc_complete_setup_noop;
 			value = 0;
 		} else if (b_request == ACCESSORY_REGISTER_HID) {
+			cdev->req->complete = acc_complete_setup_noop;
 			value = acc_register_hid(dev, w_value, w_index);
 		} else if (b_request == ACCESSORY_UNREGISTER_HID) {
+			cdev->req->complete = acc_complete_setup_noop;
 			value = acc_unregister_hid(dev, w_value);
 		} else if (b_request == ACCESSORY_SET_HID_REPORT_DESC) {
 			spin_lock_irqsave(&dev->lock, flags);
@@ -937,7 +949,7 @@
 		if (b_request == ACCESSORY_GET_PROTOCOL) {
 			*((u16 *)cdev->req->buf) = PROTOCOL_VERSION;
 			value = sizeof(u16);
-
+			cdev->req->complete = acc_complete_setup_noop;
 			/* clear any string left over from a previous session */
 			memset(dev->manufacturer, 0, sizeof(dev->manufacturer));
 			memset(dev->model, 0, sizeof(dev->model));
diff --git a/drivers/usb/gadget/function/f_ccid.h b/drivers/usb/gadget/function/f_ccid.h
index 42a7ebb..935308c 100644
--- a/drivers/usb/gadget/function/f_ccid.h
+++ b/drivers/usb/gadget/function/f_ccid.h
@@ -55,29 +55,29 @@
 #define CCID_READ_DTR		_IOR('C', 3, int)
 
 struct usb_ccid_notification {
-	unsigned char buf[4];
+	__u8 buf[4];
 } __packed;
 
 struct ccid_bulk_in_header {
-	unsigned char bMessageType;
-	unsigned long wLength;
-	unsigned char bSlot;
-	unsigned char bSeq;
-	unsigned char bStatus;
-	unsigned char bError;
-	unsigned char bSpecific;
-	unsigned char abData[ABDATA_SIZE];
-	unsigned char bSizeToSend;
+	__u8 bMessageType;
+	__u32 wLength;
+	__u8 bSlot;
+	__u8 bSeq;
+	__u8 bStatus;
+	__u8 bError;
+	__u8 bSpecific;
+	__u8 abData[ABDATA_SIZE];
+	__u8 bSizeToSend;
 } __packed;
 
 struct ccid_bulk_out_header {
-	unsigned char bMessageType;
-	unsigned long wLength;
-	unsigned char bSlot;
-	unsigned char bSeq;
-	unsigned char bSpecific_0;
-	unsigned char bSpecific_1;
-	unsigned char bSpecific_2;
-	unsigned char APDU[ABDATA_SIZE];
+	__u8 bMessageType;
+	__u32 wLength;
+	__u8 bSlot;
+	__u8 bSeq;
+	__u8 bSpecific_0;
+	__u8 bSpecific_1;
+	__u8 bSpecific_2;
+	__u8 APDU[ABDATA_SIZE];
 } __packed;
 #endif
diff --git a/drivers/usb/gadget/function/f_diag.c b/drivers/usb/gadget/function/f_diag.c
index e908ecf..be22de048 100644
--- a/drivers/usb/gadget/function/f_diag.c
+++ b/drivers/usb/gadget/function/f_diag.c
@@ -386,9 +386,11 @@
 	ch->priv = priv;
 	ch->notify = notify;
 
-	spin_lock_irqsave(&ch_lock, flags);
-	list_add_tail(&ch->list, &usb_diag_ch_list);
-	spin_unlock_irqrestore(&ch_lock, flags);
+	if (!found) {
+		spin_lock_irqsave(&ch_lock, flags);
+		list_add_tail(&ch->list, &usb_diag_ch_list);
+		spin_unlock_irqrestore(&ch_lock, flags);
+	}
 
 	return ch;
 }
@@ -863,6 +865,7 @@
 	struct diag_context *dev;
 	struct usb_diag_ch *_ch;
 	int found = 0;
+	unsigned long flags;
 
 	pr_debug("%s\n", __func__);
 
@@ -872,9 +875,19 @@
 			break;
 		}
 	}
+
 	if (!found) {
-		pr_err("%s: unable to get diag usb channel\n", __func__);
-		return ERR_PTR(-ENODEV);
+		pr_warn("%s: unable to get diag usb channel\n", __func__);
+
+		_ch = kzalloc(sizeof(*_ch), GFP_KERNEL);
+		if (_ch == NULL)
+			return ERR_PTR(-ENOMEM);
+
+		_ch->name = name;
+
+		spin_lock_irqsave(&ch_lock, flags);
+		list_add_tail(&_ch->list, &usb_diag_ch_list);
+		spin_unlock_irqrestore(&ch_lock, flags);
 	}
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c
index 4df2dc6..c11629d 100644
--- a/drivers/usb/gadget/function/f_gsi.c
+++ b/drivers/usb/gadget/function/f_gsi.c
@@ -14,26 +14,6 @@
 #include "f_gsi.h"
 #include "rndis.h"
 
-static unsigned int gsi_in_aggr_size;
-module_param(gsi_in_aggr_size, uint, 0644);
-MODULE_PARM_DESC(gsi_in_aggr_size,
-		"Aggr size of bus transfer to host");
-
-static unsigned int gsi_out_aggr_size;
-module_param(gsi_out_aggr_size, uint, 0644);
-MODULE_PARM_DESC(gsi_out_aggr_size,
-		"Aggr size of bus transfer to device");
-
-static unsigned int num_in_bufs = GSI_NUM_IN_BUFFERS;
-module_param(num_in_bufs, uint, 0644);
-MODULE_PARM_DESC(num_in_bufs,
-		"Number of IN buffers");
-
-static unsigned int num_out_bufs = GSI_NUM_OUT_BUFFERS;
-module_param(num_out_bufs, uint, 0644);
-MODULE_PARM_DESC(num_out_bufs,
-		"Number of OUT buffers");
-
 static bool qti_packet_debug;
 module_param(qti_packet_debug, bool, 0644);
 MODULE_PARM_DESC(qti_packet_debug, "Print QTI Packet's Raw Data");
@@ -384,17 +364,9 @@
 	conn_params->ipa_to_usb_xferrscidx_valid = true;
 	conn_params->teth_prot = gsi->prot_id;
 	conn_params->teth_prot_params.max_xfer_size_bytes_to_dev = 23700;
-	if (gsi_out_aggr_size)
-		conn_params->teth_prot_params.max_xfer_size_bytes_to_dev
-				= gsi_out_aggr_size;
-	else
-		conn_params->teth_prot_params.max_xfer_size_bytes_to_dev
+	conn_params->teth_prot_params.max_xfer_size_bytes_to_dev
 				= d_port->out_aggr_size;
-	if (gsi_in_aggr_size)
-		conn_params->teth_prot_params.max_xfer_size_bytes_to_host
-					= gsi_in_aggr_size;
-	else
-		conn_params->teth_prot_params.max_xfer_size_bytes_to_host
+	conn_params->teth_prot_params.max_xfer_size_bytes_to_host
 					= d_port->in_aggr_size;
 	conn_params->teth_prot_params.max_packet_number_to_dev =
 		DEFAULT_MAX_PKT_PER_XFER;
@@ -1593,12 +1565,22 @@
 		struct usb_request *req)
 {
 	struct f_gsi *gsi = req->context;
+	rndis_init_msg_type *buf;
 	int status;
 
 	status = rndis_msg_parser(gsi->params, (u8 *) req->buf);
 	if (status < 0)
 		log_event_err("RNDIS command error %d, %d/%d",
 			status, req->actual, req->length);
+
+	buf = (rndis_init_msg_type *)req->buf;
+	if (buf->MessageType == RNDIS_MSG_INIT) {
+		gsi->d_port.in_aggr_size = min_t(u32, gsi->d_port.in_aggr_size,
+						gsi->params->dl_max_xfer_size);
+		log_event_dbg("RNDIS host dl_aggr_size:%d in_aggr_size:%d\n",
+				gsi->params->dl_max_xfer_size,
+				gsi->d_port.in_aggr_size);
+	}
 }
 
 static void
@@ -2478,10 +2460,10 @@
 		info.out_epname = "gsi-epout";
 		info.in_req_buf_len = GSI_IN_BUFF_SIZE;
 		gsi->d_port.in_aggr_size = GSI_IN_RNDIS_AGGR_SIZE;
-		info.in_req_num_buf = num_in_bufs;
+		info.in_req_num_buf = GSI_NUM_IN_BUFFERS;
 		gsi->d_port.out_aggr_size = GSI_OUT_AGGR_SIZE;
 		info.out_req_buf_len = GSI_OUT_AGGR_SIZE;
-		info.out_req_num_buf = num_out_bufs;
+		info.out_req_num_buf = GSI_NUM_OUT_BUFFERS;
 		info.notify_buf_len = sizeof(struct usb_cdc_notification);
 
 		params = rndis_register(gsi_rndis_response_available, gsi,
@@ -2546,10 +2528,10 @@
 		info.out_epname = "gsi-epout";
 		gsi->d_port.in_aggr_size = GSI_IN_MBIM_AGGR_SIZE;
 		info.in_req_buf_len = GSI_IN_MBIM_AGGR_SIZE;
-		info.in_req_num_buf = num_in_bufs;
+		info.in_req_num_buf = GSI_NUM_IN_BUFFERS;
 		gsi->d_port.out_aggr_size = GSI_OUT_AGGR_SIZE;
 		info.out_req_buf_len = GSI_OUT_MBIM_BUF_LEN;
-		info.out_req_num_buf = num_out_bufs;
+		info.out_req_num_buf = GSI_NUM_OUT_BUFFERS;
 		info.notify_buf_len = sizeof(struct usb_cdc_notification);
 		mbim_gsi_desc.wMaxSegmentSize = cpu_to_le16(0x800);
 
@@ -2587,10 +2569,10 @@
 		info.out_epname = "gsi-epout";
 		gsi->d_port.in_aggr_size = GSI_IN_RMNET_AGGR_SIZE;
 		info.in_req_buf_len = GSI_IN_BUFF_SIZE;
-		info.in_req_num_buf = num_in_bufs;
+		info.in_req_num_buf = GSI_NUM_IN_BUFFERS;
 		gsi->d_port.out_aggr_size = GSI_OUT_AGGR_SIZE;
 		info.out_req_buf_len = GSI_OUT_RMNET_BUF_LEN;
-		info.out_req_num_buf = num_out_bufs;
+		info.out_req_num_buf = GSI_NUM_OUT_BUFFERS;
 		info.notify_buf_len = sizeof(struct usb_cdc_notification);
 		break;
 	case IPA_USB_ECM:
@@ -2619,10 +2601,10 @@
 		info.out_epname = "gsi-epout";
 		gsi->d_port.in_aggr_size = GSI_ECM_AGGR_SIZE;
 		info.in_req_buf_len = GSI_IN_BUFF_SIZE;
-		info.in_req_num_buf = num_in_bufs;
+		info.in_req_num_buf = GSI_NUM_IN_BUFFERS;
 		gsi->d_port.out_aggr_size = GSI_ECM_AGGR_SIZE;
 		info.out_req_buf_len = GSI_OUT_ECM_BUF_LEN;
-		info.out_req_num_buf = num_out_bufs;
+		info.out_req_num_buf = GSI_NUM_OUT_BUFFERS;
 		info.notify_buf_len = GSI_CTRL_NOTIFY_BUFF_LEN;
 
 		/* export host's Ethernet address in CDC format */
@@ -2646,16 +2628,16 @@
 		info.string_defs = qdss_gsi_string_defs;
 		info.data_desc = &qdss_gsi_data_intf_desc;
 		info.data_str_idx = 0;
-		info.fs_in_desc = &qdss_gsi_hs_data_desc;
+		info.fs_in_desc = &qdss_gsi_fs_data_desc;
 		info.hs_in_desc = &qdss_gsi_hs_data_desc;
 		info.ss_in_desc = &qdss_gsi_ss_data_desc;
-		info.fs_desc_hdr = qdss_gsi_hs_data_only_desc;
+		info.fs_desc_hdr = qdss_gsi_fs_data_only_desc;
 		info.hs_desc_hdr = qdss_gsi_hs_data_only_desc;
 		info.ss_desc_hdr = qdss_gsi_ss_data_only_desc;
 		info.in_epname = "gsi-epin";
 		info.out_epname = "";
 		info.in_req_buf_len = 16384;
-		info.in_req_num_buf = num_in_bufs;
+		info.in_req_num_buf = GSI_NUM_IN_BUFFERS;
 		info.notify_buf_len = sizeof(struct usb_cdc_notification);
 		break;
 	default:
diff --git a/drivers/usb/gadget/function/f_gsi.h b/drivers/usb/gadget/function/f_gsi.h
index 0fe3665..d6bf0f4 100644
--- a/drivers/usb/gadget/function/f_gsi.h
+++ b/drivers/usb/gadget/function/f_gsi.h
@@ -1340,6 +1340,14 @@
 	.bInterfaceProtocol =	0xff,
 };
 
+static struct usb_endpoint_descriptor qdss_gsi_fs_data_desc = {
+	.bLength              =	 USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType      =	 USB_DT_ENDPOINT,
+	.bEndpointAddress     =	 USB_DIR_IN,
+	.bmAttributes         =	 USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize       =	 cpu_to_le16(64),
+};
+
 static struct usb_endpoint_descriptor qdss_gsi_hs_data_desc = {
 	.bLength              =	 USB_DT_ENDPOINT_SIZE,
 	.bDescriptorType      =	 USB_DT_ENDPOINT,
@@ -1364,6 +1372,12 @@
 	.wBytesPerInterval    =	 0,
 };
 
+static struct usb_descriptor_header *qdss_gsi_fs_data_only_desc[] = {
+	(struct usb_descriptor_header *) &qdss_gsi_data_intf_desc,
+	(struct usb_descriptor_header *) &qdss_gsi_fs_data_desc,
+	NULL,
+};
+
 static struct usb_descriptor_header *qdss_gsi_hs_data_only_desc[] = {
 	(struct usb_descriptor_header *) &qdss_gsi_data_intf_desc,
 	(struct usb_descriptor_header *) &qdss_gsi_hs_data_desc,
@@ -1379,7 +1393,7 @@
 
 /* string descriptors: */
 static struct usb_string qdss_gsi_string_defs[] = {
-	[0].s = "QDSS DATA",
+	[0].s = "DPL Data",
 	{}, /* end of list */
 };
 
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index b0f7195..b6d4b48 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -582,7 +582,7 @@
 		}
 		status = usb_ep_enable(hidg->out_ep);
 		if (status < 0) {
-			ERROR(cdev, "Enable IN endpoint FAILED!\n");
+			ERROR(cdev, "Enable OUT endpoint FAILED!\n");
 			goto fail;
 		}
 		hidg->out_ep->driver_data = hidg;
diff --git a/drivers/usb/gadget/function/f_qdss.c b/drivers/usb/gadget/function/f_qdss.c
index 40a7acf..a0fecb2 100644
--- a/drivers/usb/gadget/function/f_qdss.c
+++ b/drivers/usb/gadget/function/f_qdss.c
@@ -338,7 +338,7 @@
 	struct usb_gadget *gadget = c->cdev->gadget;
 	struct f_qdss *qdss = func_to_qdss(f);
 	struct usb_ep *ep;
-	int iface;
+	int iface, id;
 
 	pr_debug("qdss_bind\n");
 
@@ -356,6 +356,12 @@
 	qdss_data_intf_desc.bInterfaceNumber = iface;
 	qdss->data_iface_id = iface;
 
+	id = usb_string_id(c->cdev);
+	if (id < 0)
+		return id;
+	qdss_string_defs[QDSS_DATA_IDX].id = id;
+	qdss_data_intf_desc.iInterface = id;
+
 	if (qdss->debug_inface_enabled) {
 		/* Allocate ctrl I/F */
 		iface = usb_interface_id(c, f);
@@ -365,6 +371,11 @@
 		}
 		qdss_ctrl_intf_desc.bInterfaceNumber = iface;
 		qdss->ctrl_iface_id = iface;
+		id = usb_string_id(c->cdev);
+		if (id < 0)
+			return id;
+		qdss_string_defs[QDSS_CTRL_IDX].id = id;
+		qdss_ctrl_intf_desc.iInterface = id;
 	}
 
 	ep = usb_ep_autoconfig_ss(gadget, &qdss_ss_data_desc,
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 38d58f3..ac2231a 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -813,8 +813,17 @@
 	/* For USB: responses may take up to 10 seconds */
 	switch (MsgType) {
 	case RNDIS_MSG_INIT:
-		pr_debug("%s: RNDIS_MSG_INIT\n",
-			__func__);
+		pr_debug("%s: RNDIS_MSG_INIT\n", __func__);
+		tmp++; /* to get RequestID */
+		params->host_rndis_major_ver = get_unaligned_le32(tmp++);
+		params->host_rndis_minor_ver = get_unaligned_le32(tmp++);
+		params->dl_max_xfer_size = get_unaligned_le32(tmp++);
+
+		pr_debug("%s(): RNDIS Host Major:%d Minor:%d version\n",
+					__func__, params->host_rndis_major_ver,
+					params->host_rndis_minor_ver);
+		pr_debug("%s(): DL Max Transfer size:%x\n",
+				__func__, params->dl_max_xfer_size);
 		params->state = RNDIS_INITIALIZED;
 		return rndis_init_response(params, (rndis_init_msg_type *)buf);
 
diff --git a/drivers/usb/gadget/function/rndis.h b/drivers/usb/gadget/function/rndis.h
index 939c3be..4ffc282 100644
--- a/drivers/usb/gadget/function/rndis.h
+++ b/drivers/usb/gadget/function/rndis.h
@@ -191,6 +191,9 @@
 
 	u32			vendorID;
 	u8			max_pkt_per_xfer;
+	u32			host_rndis_major_ver;
+	u32			host_rndis_minor_ver;
+	u32			dl_max_xfer_size;
 	const char		*vendorDescr;
 	u8			pkt_alignment_factor;
 	void			(*resp_avail)(void *v);
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index ba78e3f..d2cfefa 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -685,21 +685,32 @@
 	return usb3_req;
 }
 
+static void __usb3_request_done(struct renesas_usb3_ep *usb3_ep,
+				struct renesas_usb3_request *usb3_req,
+				int status)
+{
+	struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep);
+
+	dev_dbg(usb3_to_dev(usb3), "giveback: ep%2d, %u, %u, %d\n",
+		usb3_ep->num, usb3_req->req.length, usb3_req->req.actual,
+		status);
+	usb3_req->req.status = status;
+	usb3_ep->started = false;
+	list_del_init(&usb3_req->queue);
+	spin_unlock(&usb3->lock);
+	usb_gadget_giveback_request(&usb3_ep->ep, &usb3_req->req);
+	spin_lock(&usb3->lock);
+}
+
 static void usb3_request_done(struct renesas_usb3_ep *usb3_ep,
 			      struct renesas_usb3_request *usb3_req, int status)
 {
 	struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep);
 	unsigned long flags;
 
-	dev_dbg(usb3_to_dev(usb3), "giveback: ep%2d, %u, %u, %d\n",
-		usb3_ep->num, usb3_req->req.length, usb3_req->req.actual,
-		status);
-	usb3_req->req.status = status;
 	spin_lock_irqsave(&usb3->lock, flags);
-	usb3_ep->started = false;
-	list_del_init(&usb3_req->queue);
+	__usb3_request_done(usb3_ep, usb3_req, status);
 	spin_unlock_irqrestore(&usb3->lock, flags);
-	usb_gadget_giveback_request(&usb3_ep->ep, &usb3_req->req);
 }
 
 static void usb3_irq_epc_pipe0_status_end(struct renesas_usb3 *usb3)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index c8989c6..58b9685 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -98,6 +98,7 @@
 	AMD_CHIPSET_HUDSON2,
 	AMD_CHIPSET_BOLTON,
 	AMD_CHIPSET_YANGTZE,
+	AMD_CHIPSET_TAISHAN,
 	AMD_CHIPSET_UNKNOWN,
 };
 
@@ -145,20 +146,26 @@
 		pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
 				PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL);
 
-		if (!pinfo->smbus_dev) {
-			pinfo->sb_type.gen = NOT_AMD_CHIPSET;
-			return 0;
+		if (pinfo->smbus_dev) {
+			rev = pinfo->smbus_dev->revision;
+			if (rev >= 0x11 && rev <= 0x14)
+				pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2;
+			else if (rev >= 0x15 && rev <= 0x18)
+				pinfo->sb_type.gen = AMD_CHIPSET_BOLTON;
+			else if (rev >= 0x39 && rev <= 0x3a)
+				pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE;
+		} else {
+			pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
+							  0x145c, NULL);
+			if (pinfo->smbus_dev) {
+				rev = pinfo->smbus_dev->revision;
+				pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN;
+			} else {
+				pinfo->sb_type.gen = NOT_AMD_CHIPSET;
+				return 0;
+			}
 		}
-
-		rev = pinfo->smbus_dev->revision;
-		if (rev >= 0x11 && rev <= 0x14)
-			pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2;
-		else if (rev >= 0x15 && rev <= 0x18)
-			pinfo->sb_type.gen = AMD_CHIPSET_BOLTON;
-		else if (rev >= 0x39 && rev <= 0x3a)
-			pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE;
 	}
-
 	pinfo->sb_type.rev = rev;
 	return 1;
 }
@@ -260,11 +267,12 @@
 {
 	/* Make sure amd chipset type has already been initialized */
 	usb_amd_find_chipset_info();
-	if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE)
-		return 0;
-
-	dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
-	return 1;
+	if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE ||
+	    amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) {
+		dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
+		return 1;
+	}
+	return 0;
 }
 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk);
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6cb5ab3..14c0203 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -307,7 +307,7 @@
 
 	hcd_to_bus(xhci->shared_hcd)->skip_resume = true;
 
-	if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
+	if (device_property_read_bool(&pdev->dev, "usb3-lpm-capable"))
 		xhci->quirks |= XHCI_LPM_SUPPORT;
 
 	if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
@@ -316,6 +316,9 @@
 	if (device_property_read_u32(sysdev, "snps,xhci-imod-value", &imod))
 		imod = 0;
 
+	if (device_property_read_u32(sysdev, "usb-core-id", &xhci->core_id))
+		xhci->core_id = -EINVAL;
+
 	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 15bf308..1660c7c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4964,10 +4964,13 @@
 }
 EXPORT_SYMBOL_GPL(xhci_gen_setup);
 
-dma_addr_t xhci_get_sec_event_ring_dma_addr(struct usb_hcd *hcd,
-	unsigned int intr_num)
+static phys_addr_t xhci_get_sec_event_ring_phys_addr(struct usb_hcd *hcd,
+	unsigned int intr_num, dma_addr_t *dma)
 {
 	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+	struct device *dev = hcd->self.sysdev;
+	struct sg_table sgt;
+	phys_addr_t pa;
 
 	if (intr_num >= xhci->max_interrupters) {
 		xhci_err(xhci, "intr num %d >= max intrs %d\n", intr_num,
@@ -4977,31 +4980,34 @@
 
 	if (!(xhci->xhc_state & XHCI_STATE_HALTED) &&
 		xhci->sec_event_ring && xhci->sec_event_ring[intr_num]
-		&& xhci->sec_event_ring[intr_num]->first_seg)
-		return xhci->sec_event_ring[intr_num]->first_seg->dma;
+		&& xhci->sec_event_ring[intr_num]->first_seg) {
+
+		dma_get_sgtable(dev, &sgt,
+			xhci->sec_event_ring[intr_num]->first_seg->trbs,
+			xhci->sec_event_ring[intr_num]->first_seg->dma,
+			TRB_SEGMENT_SIZE);
+
+		*dma = xhci->sec_event_ring[intr_num]->first_seg->dma;
+
+		pa = page_to_phys(sg_page(sgt.sgl));
+		sg_free_table(&sgt);
+
+		return pa;
+	}
 
 	return 0;
 }
 
-dma_addr_t xhci_get_dcba_dma_addr(struct usb_hcd *hcd,
-	struct usb_device *udev)
-{
-	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-
-	if (!(xhci->xhc_state & XHCI_STATE_HALTED) && xhci->dcbaa)
-		return xhci->dcbaa->dev_context_ptrs[udev->slot_id];
-
-	return 0;
-}
-
-dma_addr_t xhci_get_xfer_ring_dma_addr(struct usb_hcd *hcd,
-	struct usb_device *udev, struct usb_host_endpoint *ep)
+static phys_addr_t xhci_get_xfer_ring_phys_addr(struct usb_hcd *hcd,
+	struct usb_device *udev, struct usb_host_endpoint *ep, dma_addr_t *dma)
 {
 	int ret;
 	unsigned int ep_index;
 	struct xhci_virt_device *virt_dev;
-
+	struct device *dev = hcd->self.sysdev;
 	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+	struct sg_table sgt;
+	phys_addr_t pa;
 
 	ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
 	if (ret <= 0) {
@@ -5013,12 +5019,31 @@
 	ep_index = xhci_get_endpoint_index(&ep->desc);
 
 	if (virt_dev->eps[ep_index].ring &&
-		virt_dev->eps[ep_index].ring->first_seg)
-		return virt_dev->eps[ep_index].ring->first_seg->dma;
+		virt_dev->eps[ep_index].ring->first_seg) {
+
+		dma_get_sgtable(dev, &sgt,
+			virt_dev->eps[ep_index].ring->first_seg->trbs,
+			virt_dev->eps[ep_index].ring->first_seg->dma,
+			TRB_SEGMENT_SIZE);
+
+		*dma = virt_dev->eps[ep_index].ring->first_seg->dma;
+
+		pa = page_to_phys(sg_page(sgt.sgl));
+		sg_free_table(&sgt);
+
+		return pa;
+	}
 
 	return 0;
 }
 
+int xhci_get_core_id(struct usb_hcd *hcd)
+{
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	return xhci->core_id;
+}
+
 static const struct hc_driver xhci_hc_driver = {
 	.description =		"xhci-hcd",
 	.product_desc =		"xHCI Host Controller",
@@ -5080,9 +5105,9 @@
 	.find_raw_port_number =	xhci_find_raw_port_number,
 	.sec_event_ring_setup =		xhci_sec_event_ring_setup,
 	.sec_event_ring_cleanup =	xhci_sec_event_ring_cleanup,
-	.get_sec_event_ring_dma_addr =	xhci_get_sec_event_ring_dma_addr,
-	.get_xfer_ring_dma_addr =	xhci_get_xfer_ring_dma_addr,
-	.get_dcba_dma_addr =		xhci_get_dcba_dma_addr,
+	.get_sec_event_ring_phys_addr =	xhci_get_sec_event_ring_phys_addr,
+	.get_xfer_ring_phys_addr =	xhci_get_xfer_ring_phys_addr,
+	.get_core_id =			xhci_get_core_id,
 };
 
 void xhci_init_driver(struct hc_driver *drv,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 757d045..db46db4 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1538,6 +1538,8 @@
 	/* secondary interrupter */
 	struct	xhci_intr_reg __iomem **sec_ir_set;
 
+	int		core_id;
+
 	/* Cached register copies of read-only HC data */
 	__u32		hcs_params1;
 	__u32		hcs_params2;
@@ -1977,6 +1979,7 @@
 		char *buf, u16 wLength);
 int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
 int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1);
+int xhci_get_core_id(struct usb_hcd *hcd);
 
 #ifdef CONFIG_PM
 int xhci_bus_suspend(struct usb_hcd *hcd);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 261ed2c..a6b6b1c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2655,6 +2655,13 @@
 {
 	struct musb	*musb = dev_to_musb(dev);
 	unsigned long	flags;
+	int ret;
+
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		pm_runtime_put_noidle(dev);
+		return ret;
+	}
 
 	musb_platform_disable(musb);
 	musb_generic_disable(musb);
@@ -2703,14 +2710,6 @@
 	if ((devctl & mask) != (musb->context.devctl & mask))
 		musb->port1_status = 0;
 
-	/*
-	 * The USB HUB code expects the device to be in RPM_ACTIVE once it came
-	 * out of suspend
-	 */
-	pm_runtime_disable(dev);
-	pm_runtime_set_active(dev);
-	pm_runtime_enable(dev);
-
 	musb_start(musb);
 
 	spin_lock_irqsave(&musb->lock, flags);
@@ -2720,6 +2719,9 @@
 			error);
 	spin_unlock_irqrestore(&musb->lock, flags);
 
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
+
 	return 0;
 }
 
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 99beda9..55c624f 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -139,6 +139,7 @@
 				"Could not flush host TX%d fifo: csr: %04x\n",
 				ep->epnum, csr))
 			return;
+		mdelay(1);
 	}
 }
 
diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c
index 574ff79..e8961b5 100644
--- a/drivers/usb/pd/policy_engine.c
+++ b/drivers/usb/pd/policy_engine.c
@@ -129,6 +129,12 @@
 	MSG_VCONN_SWAP,
 	MSG_WAIT,
 	MSG_SOFT_RESET,
+	MSG_NOT_SUPPORTED = 0x10,
+	MSG_GET_SOURCE_CAP_EXTENDED,
+	MSG_GET_STATUS,
+	MSG_FR_SWAP,
+	MSG_GET_PPS_STATUS,
+	MSG_GET_COUNTRY_CODES,
 };
 
 enum usbpd_data_msg_type {
@@ -136,9 +142,29 @@
 	MSG_REQUEST,
 	MSG_BIST,
 	MSG_SINK_CAPABILITIES,
+	MSG_BATTERY_STATUS,
+	MSG_ALERT,
+	MSG_GET_COUNTRY_INFO,
 	MSG_VDM = 0xF,
 };
 
+enum usbpd_ext_msg_type {
+	MSG_SOURCE_CAPABILITIES_EXTENDED = 1,
+	MSG_STATUS,
+	MSG_GET_BATTERY_CAP,
+	MSG_GET_BATTERY_STATUS,
+	MSG_BATTERY_CAPABILITIES,
+	MSG_GET_MANUFACTURER_INFO,
+	MSG_MANUFACTURER_INFO,
+	MSG_SECURITY_REQUEST,
+	MSG_SECURITY_RESPONSE,
+	MSG_FIRMWARE_UPDATE_REQUEST,
+	MSG_FIRMWARE_UPDATE_RESPONSE,
+	MSG_PPS_STATUS,
+	MSG_COUNTRY_INFO,
+	MSG_COUNTRY_CODES,
+};
+
 enum vdm_state {
 	VDM_NONE,
 	DISCOVERED_ID,
@@ -202,13 +228,30 @@
 
 #define PD_MAX_DATA_OBJ		7
 
+#define PD_SRC_CAP_EXT_DB_LEN	24
+#define PD_STATUS_DB_LEN	5
+#define PD_BATTERY_CAP_DB_LEN	9
+
+#define PD_MAX_EXT_MSG_LEN		260
+#define PD_MAX_EXT_MSG_LEGACY_LEN	26
+
 #define PD_MSG_HDR(type, dr, pr, id, cnt, rev) \
-	(((type) & 0xF) | ((dr) << 5) | (rev << 6) | \
+	(((type) & 0x1F) | ((dr) << 5) | (rev << 6) | \
 	 ((pr) << 8) | ((id) << 9) | ((cnt) << 12))
-#define PD_MSG_HDR_COUNT(hdr) (((hdr) >> 12) & 7)
-#define PD_MSG_HDR_TYPE(hdr) ((hdr) & 0xF)
-#define PD_MSG_HDR_ID(hdr) (((hdr) >> 9) & 7)
-#define PD_MSG_HDR_REV(hdr) (((hdr) >> 6) & 3)
+#define PD_MSG_HDR_COUNT(hdr)		(((hdr) >> 12) & 7)
+#define PD_MSG_HDR_TYPE(hdr)		((hdr) & 0x1F)
+#define PD_MSG_HDR_ID(hdr)		(((hdr) >> 9) & 7)
+#define PD_MSG_HDR_REV(hdr)		(((hdr) >> 6) & 3)
+#define PD_MSG_HDR_EXTENDED		BIT(15)
+#define PD_MSG_HDR_IS_EXTENDED(hdr)	((hdr) & PD_MSG_HDR_EXTENDED)
+
+#define PD_MSG_EXT_HDR(chunked, num, req, size) \
+	(((chunked) << 15) | (((num) & 0xF) << 11) | \
+	 ((req) << 10) | ((size) & 0x1FF))
+#define PD_MSG_EXT_HDR_IS_CHUNKED(ehdr)	((ehdr) & 0x8000)
+#define PD_MSG_EXT_HDR_CHUNK_NUM(ehdr)	(((ehdr) >> 11) & 0xF)
+#define PD_MSG_EXT_HDR_REQ_CHUNK(ehdr)	((ehdr) & 0x400)
+#define PD_MSG_EXT_HDR_DATA_SIZE(ehdr)	((ehdr) & 0x1FF)
 
 #define PD_RDO_FIXED(obj, gb, mismatch, usb_comm, no_usb_susp, curr1, curr2) \
 		(((obj) << 28) | ((gb) << 27) | ((mismatch) << 26) | \
@@ -295,19 +338,24 @@
 static const u32 default_snk_caps[] = { 0x2601912C };	/* VSafe5V @ 3A */
 
 struct vdm_tx {
-	u32			data[7];
+	u32			data[PD_MAX_DATA_OBJ];
 	int			size;
 };
 
 struct rx_msg {
-	u8			type;
-	u8			len;
-	u32			payload[7];
+	u16			hdr;
+	u16			data_len;	/* size of payload in bytes */
 	struct list_head	entry;
+	u8			payload[];
 };
 
-#define IS_DATA(m, t) ((m) && ((m)->len) && ((m)->type == (t)))
-#define IS_CTRL(m, t) ((m) && !((m)->len) && ((m)->type == (t)))
+#define IS_DATA(m, t) ((m) && !PD_MSG_HDR_IS_EXTENDED((m)->hdr) && \
+		PD_MSG_HDR_COUNT((m)->hdr) && \
+		(PD_MSG_HDR_TYPE((m)->hdr) == (t)))
+#define IS_CTRL(m, t) ((m) && !PD_MSG_HDR_COUNT((m)->hdr) && \
+		(PD_MSG_HDR_TYPE((m)->hdr) == (t)))
+#define IS_EXT(m, t) ((m) && PD_MSG_HDR_IS_EXTENDED((m)->hdr) && \
+		(PD_MSG_HDR_TYPE((m)->hdr) == (t)))
 
 struct usbpd {
 	struct device		dev;
@@ -322,8 +370,10 @@
 	bool			hard_reset_recvd;
 	struct list_head	rx_q;
 	spinlock_t		rx_lock;
+	struct rx_msg		*rx_ext_msg;
 
 	u32			received_pdos[PD_MAX_DATA_OBJ];
+	u32			received_ado;
 	u16			src_cap_id;
 	u8			selected_pdo;
 	u8			requested_pdo;
@@ -355,6 +405,8 @@
 	bool			pd_phy_opened;
 	bool			send_request;
 	struct completion	is_ready;
+	struct completion	tx_chunk_request;
+	u8			next_tx_chunk;
 
 	struct mutex		swap_lock;
 	struct dual_role_phy_instance	*dual_role;
@@ -378,11 +430,25 @@
 	int			num_svids;
 	struct vdm_tx		*vdm_tx;
 	struct vdm_tx		*vdm_tx_retry;
+	struct mutex		svid_handler_lock;
 	struct list_head	svid_handlers;
 
 	struct list_head	instance;
 
 	u16			ss_lane_svid;
+
+	/* ext msg support */
+	bool			send_get_src_cap_ext;
+	u8			src_cap_ext_db[PD_SRC_CAP_EXT_DB_LEN];
+	bool			send_get_pps_status;
+	u32			pps_status_db;
+	u8			status_db[PD_STATUS_DB_LEN];
+	bool			send_get_battery_cap;
+	u8			get_battery_cap_db;
+	u8			battery_cap_db[PD_BATTERY_CAP_DB_LEN];
+	u8			get_battery_status_db;
+	bool			send_get_battery_status;
+	u32			battery_sts_dobj;
 };
 
 static LIST_HEAD(_usbpd);	/* useful for debugging */
@@ -516,10 +582,15 @@
 {
 	struct usbpd_svid_handler *handler;
 
-	list_for_each_entry(handler, &pd->svid_handlers, entry)
-		if (svid == handler->svid)
+	mutex_lock(&pd->svid_handler_lock);
+	list_for_each_entry(handler, &pd->svid_handlers, entry) {
+		if (svid == handler->svid) {
+			mutex_unlock(&pd->svid_handler_lock);
 			return handler;
+		}
+	}
 
+	mutex_unlock(&pd->svid_handler_lock);
 	return NULL;
 }
 
@@ -554,6 +625,57 @@
 	return 0;
 }
 
+static int pd_send_ext_msg(struct usbpd *pd, u8 msg_type,
+		const u8 *data, size_t data_len, enum pd_sop_type sop)
+{
+	int ret;
+	size_t len_remain, chunk_len;
+	u8 chunked_payload[PD_MAX_DATA_OBJ * sizeof(u32)] = {0};
+	u16 hdr;
+	u16 ext_hdr;
+	u8 num_objs;
+
+	if (data_len > PD_MAX_EXT_MSG_LEN) {
+		usbpd_warn(&pd->dev, "Extended message length exceeds max, truncating...\n");
+		data_len = PD_MAX_EXT_MSG_LEN;
+	}
+
+	pd->next_tx_chunk = 0;
+	len_remain = data_len;
+	do {
+		ext_hdr = PD_MSG_EXT_HDR(1, pd->next_tx_chunk++, 0, data_len);
+		memcpy(chunked_payload, &ext_hdr, sizeof(ext_hdr));
+
+		chunk_len = min_t(size_t, len_remain,
+				PD_MAX_EXT_MSG_LEGACY_LEN);
+		memcpy(chunked_payload + sizeof(ext_hdr), data, chunk_len);
+
+		num_objs = DIV_ROUND_UP(chunk_len + sizeof(u16), sizeof(u32));
+		len_remain -= chunk_len;
+
+		reinit_completion(&pd->tx_chunk_request);
+		hdr = PD_MSG_HDR(msg_type, pd->current_dr, pd->current_pr,
+				pd->tx_msgid, num_objs, pd->spec_rev) |
+			PD_MSG_HDR_EXTENDED;
+		ret = pd_phy_write(hdr, chunked_payload,
+				num_objs * sizeof(u32), sop);
+		if (ret)
+			return ret;
+
+		pd->tx_msgid = (pd->tx_msgid + 1) & PD_MAX_MSG_ID;
+
+		/* Wait for request chunk */
+		if (len_remain &&
+			!wait_for_completion_timeout(&pd->tx_chunk_request,
+				msecs_to_jiffies(SENDER_RESPONSE_TIME))) {
+			usbpd_err(&pd->dev, "Timed out waiting for chunk request\n");
+			return -EPROTO;
+		}
+	} while (len_remain);
+
+	return 0;
+}
+
 static int pd_select_pdo(struct usbpd *pd, int pdo_pos, int uv, int ua)
 {
 	int curr;
@@ -694,6 +816,150 @@
 	kick_sm(pd, 0);
 }
 
+struct pd_request_chunk {
+	struct work_struct	w;
+	struct usbpd		*pd;
+	u8			msg_type;
+	u8			chunk_num;
+	enum pd_sop_type	sop;
+};
+
+static void pd_request_chunk_work(struct work_struct *w)
+{
+	struct pd_request_chunk *req =
+		container_of(w, struct pd_request_chunk, w);
+	struct usbpd *pd = req->pd;
+	unsigned long flags;
+	int ret;
+	u8 payload[4] = {0}; /* ext_hdr + padding */
+	u16 hdr = PD_MSG_HDR(req->msg_type, pd->current_dr, pd->current_pr,
+			pd->tx_msgid, 1, pd->spec_rev) | PD_MSG_HDR_EXTENDED;
+
+	*(u16 *)payload = PD_MSG_EXT_HDR(1, req->chunk_num, 1, 0);
+
+	ret = pd_phy_write(hdr, payload, sizeof(payload), req->sop);
+	if (!ret) {
+		pd->tx_msgid = (pd->tx_msgid + 1) & PD_MAX_MSG_ID;
+	} else {
+		usbpd_err(&pd->dev, "could not send chunk request\n");
+
+		/* queue what we have anyway */
+		spin_lock_irqsave(&pd->rx_lock, flags);
+		list_add_tail(&pd->rx_ext_msg->entry, &pd->rx_q);
+		spin_unlock_irqrestore(&pd->rx_lock, flags);
+
+		pd->rx_ext_msg = NULL;
+	}
+
+	kfree(req);
+}
+
+static struct rx_msg *pd_ext_msg_received(struct usbpd *pd, u16 header, u8 *buf,
+		size_t len, enum pd_sop_type sop)
+{
+	struct rx_msg *rx_msg;
+	u16 bytes_to_copy;
+	u16 ext_hdr = *(u16 *)buf;
+	u8 chunk_num;
+
+	if (!PD_MSG_EXT_HDR_IS_CHUNKED(ext_hdr)) {
+		usbpd_err(&pd->dev, "unchunked extended messages unsupported\n");
+		return NULL;
+	}
+
+	/* request for next Tx chunk */
+	if (PD_MSG_EXT_HDR_REQ_CHUNK(ext_hdr)) {
+		if (PD_MSG_EXT_HDR_DATA_SIZE(ext_hdr) ||
+			PD_MSG_EXT_HDR_CHUNK_NUM(ext_hdr) !=
+				pd->next_tx_chunk) {
+			usbpd_err(&pd->dev, "invalid request chunk ext header 0x%02x\n",
+					ext_hdr);
+			return NULL;
+		}
+
+		if (!completion_done(&pd->tx_chunk_request))
+			complete(&pd->tx_chunk_request);
+
+		return NULL;
+	}
+
+	chunk_num = PD_MSG_EXT_HDR_CHUNK_NUM(ext_hdr);
+	if (!chunk_num) {
+		/* allocate new message if first chunk */
+		rx_msg = kzalloc(sizeof(*rx_msg) +
+				PD_MSG_EXT_HDR_DATA_SIZE(ext_hdr),
+				GFP_KERNEL);
+		if (!rx_msg)
+			return NULL;
+
+		rx_msg->hdr = header;
+		rx_msg->data_len = PD_MSG_EXT_HDR_DATA_SIZE(ext_hdr);
+
+		if (rx_msg->data_len > PD_MAX_EXT_MSG_LEN) {
+			usbpd_warn(&pd->dev, "Extended message length exceeds max, truncating...\n");
+			rx_msg->data_len = PD_MAX_EXT_MSG_LEN;
+		}
+	} else {
+		if (!pd->rx_ext_msg) {
+			usbpd_err(&pd->dev, "missing first rx_ext_msg chunk\n");
+			return NULL;
+		}
+
+		rx_msg = pd->rx_ext_msg;
+	}
+
+	/*
+	 * The amount to copy is derived as follows:
+	 *
+	 * - if extended data_len < 26, then copy data_len bytes
+	 * - for chunks 0..N-2, copy 26 bytes
+	 * - for the last chunk (N-1), copy the remainder
+	 */
+	bytes_to_copy =
+		min((rx_msg->data_len - chunk_num * PD_MAX_EXT_MSG_LEGACY_LEN),
+			PD_MAX_EXT_MSG_LEGACY_LEN);
+
+	/* check against received length to avoid overrun */
+	if (bytes_to_copy > len - sizeof(ext_hdr)) {
+		usbpd_warn(&pd->dev, "not enough bytes in chunk, expected:%u received:%lu\n",
+			bytes_to_copy, len - sizeof(ext_hdr));
+		bytes_to_copy = len - sizeof(ext_hdr);
+	}
+
+	memcpy(rx_msg->payload + chunk_num * PD_MAX_EXT_MSG_LEGACY_LEN, buf + 2,
+			bytes_to_copy);
+
+	/* request next chunk? */
+	if ((rx_msg->data_len - chunk_num * PD_MAX_EXT_MSG_LEGACY_LEN) >
+			PD_MAX_EXT_MSG_LEGACY_LEN) {
+		struct pd_request_chunk *req;
+
+		if (pd->rx_ext_msg && pd->rx_ext_msg != rx_msg) {
+			usbpd_dbg(&pd->dev, "stale previous rx_ext_msg?\n");
+			kfree(pd->rx_ext_msg);
+		}
+
+		pd->rx_ext_msg = rx_msg;
+
+		req = kzalloc(sizeof(*req), GFP_KERNEL);
+		if (!req)
+			goto queue_rx; /* return what we have anyway */
+
+		INIT_WORK(&req->w, pd_request_chunk_work);
+		req->pd = pd;
+		req->msg_type = PD_MSG_HDR_TYPE(header);
+		req->chunk_num = chunk_num + 1;
+		req->sop = sop;
+		queue_work(pd->wq, &req->w);
+
+		return NULL;
+	}
+
+queue_rx:
+	pd->rx_ext_msg = NULL;
+	return rx_msg;	/* queue it for usbpd_sm */
+}
+
 static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop,
 		u8 *buf, size_t len)
 {
@@ -745,21 +1011,27 @@
 	if (PD_MSG_HDR_REV(header) < pd->spec_rev)
 		pd->spec_rev = PD_MSG_HDR_REV(header);
 
-	rx_msg = kzalloc(sizeof(*rx_msg), GFP_KERNEL);
-	if (!rx_msg)
-		return;
+	usbpd_dbg(&pd->dev, "received message: type(%d) num_objs(%d)\n",
+			PD_MSG_HDR_TYPE(header), PD_MSG_HDR_COUNT(header));
 
-	rx_msg->type = PD_MSG_HDR_TYPE(header);
-	rx_msg->len = PD_MSG_HDR_COUNT(header);
-	memcpy(&rx_msg->payload, buf, min(len, sizeof(rx_msg->payload)));
+	if (!PD_MSG_HDR_IS_EXTENDED(header)) {
+		rx_msg = kzalloc(sizeof(*rx_msg) + len, GFP_KERNEL);
+		if (!rx_msg)
+			return;
+
+		rx_msg->hdr = header;
+		rx_msg->data_len = len;
+		memcpy(rx_msg->payload, buf, len);
+	} else {
+		rx_msg = pd_ext_msg_received(pd, header, buf, len, sop);
+		if (!rx_msg)
+			return;
+	}
 
 	spin_lock_irqsave(&pd->rx_lock, flags);
 	list_add_tail(&rx_msg->entry, &pd->rx_q);
 	spin_unlock_irqrestore(&pd->rx_lock, flags);
 
-	usbpd_dbg(&pd->dev, "received message: type(%d) len(%d)\n",
-			rx_msg->type, rx_msg->len);
-
 	kick_sm(pd, 0);
 }
 
@@ -1035,7 +1307,7 @@
 		pd->current_voltage = pd->requested_voltage = 5000000;
 		val.intval = pd->requested_voltage; /* set max range to 5V */
 		power_supply_set_property(pd->usb_psy,
-				POWER_SUPPLY_PROP_VOLTAGE_MAX, &val);
+				POWER_SUPPLY_PROP_PD_VOLTAGE_MAX, &val);
 
 		if (!pd->vbus_present) {
 			pd->current_state = PE_SNK_DISCOVERY;
@@ -1146,9 +1418,11 @@
 		return -EINVAL;
 	}
 
-	usbpd_dbg(&pd->dev, "registered handler for SVID 0x%04x\n", hdlr->svid);
-
+	usbpd_dbg(&pd->dev, "registered handler(%pK) for SVID 0x%04x\n",
+							hdlr, hdlr->svid);
+	mutex_lock(&pd->svid_handler_lock);
 	list_add_tail(&hdlr->entry, &pd->svid_handlers);
+	mutex_unlock(&pd->svid_handler_lock);
 	hdlr->request_usb_ss_lane = usbpd_release_ss_lane;
 
 	/* already connected with this SVID discovered? */
@@ -1170,7 +1444,12 @@
 
 void usbpd_unregister_svid(struct usbpd *pd, struct usbpd_svid_handler *hdlr)
 {
+
+	usbpd_dbg(&pd->dev, "unregistered handler(%pK) for SVID 0x%04x\n",
+							hdlr, hdlr->svid);
+	mutex_lock(&pd->svid_handler_lock);
 	list_del_init(&hdlr->entry);
+	mutex_unlock(&pd->svid_handler_lock);
 }
 EXPORT_SYMBOL(usbpd_unregister_svid);
 
@@ -1215,11 +1494,13 @@
 
 static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg)
 {
-	u32 vdm_hdr = rx_msg->payload[0];
-	u32 *vdos = &rx_msg->payload[1];
+	u32 vdm_hdr =
+	rx_msg->data_len >= sizeof(u32) ? ((u32 *)rx_msg->payload)[0] : 0;
+
+	u32 *vdos = (u32 *)&rx_msg->payload[sizeof(u32)];
 	u16 svid = VDM_HDR_SVID(vdm_hdr);
 	u16 *psvid;
-	u8 i, num_vdos = rx_msg->len - 1;	/* num objects minus header */
+	u8 i, num_vdos = PD_MSG_HDR_COUNT(rx_msg->hdr) - 1;
 	u8 cmd = SVDM_HDR_CMD(vdm_hdr);
 	u8 cmd_type = SVDM_HDR_CMD_TYPE(vdm_hdr);
 	bool has_dp = false;
@@ -1479,6 +1760,7 @@
 {
 	struct usbpd_svid_handler *handler;
 
+	mutex_lock(&pd->svid_handler_lock);
 	list_for_each_entry(handler, &pd->svid_handlers, entry) {
 		if (handler->discovered) {
 			handler->disconnect(handler);
@@ -1486,6 +1768,7 @@
 		}
 	}
 
+	mutex_unlock(&pd->svid_handler_lock);
 	pd->vdm_state = VDM_NONE;
 	kfree(pd->vdm_tx_retry);
 	pd->vdm_tx_retry = NULL;
@@ -1727,7 +2010,7 @@
 		pd->requested_voltage = 5000000;
 		val.intval = pd->requested_voltage;
 		power_supply_set_property(pd->usb_psy,
-				POWER_SUPPLY_PROP_VOLTAGE_MIN, &val);
+				POWER_SUPPLY_PROP_PD_VOLTAGE_MIN, &val);
 
 		pd->in_pr_swap = false;
 		val.intval = 0;
@@ -1821,7 +2104,7 @@
 
 	case PE_SRC_SEND_CAPABILITIES_WAIT:
 		if (IS_DATA(rx_msg, MSG_REQUEST)) {
-			pd->rdo = rx_msg->payload[0];
+			pd->rdo = *(u32 *)rx_msg->payload;
 			usbpd_set_state(pd, PE_SRC_NEGOTIATE_CAPABILITY);
 		} else if (rx_msg) {
 			usbpd_err(&pd->dev, "Unexpected message received\n");
@@ -1844,7 +2127,7 @@
 				usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET);
 			}
 		} else if (IS_DATA(rx_msg, MSG_REQUEST)) {
-			pd->rdo = rx_msg->payload[0];
+			pd->rdo = *(u32 *)rx_msg->payload;
 			usbpd_set_state(pd, PE_SRC_NEGOTIATE_CAPABILITY);
 		} else if (IS_CTRL(rx_msg, MSG_DR_SWAP)) {
 			if (pd->vdm_state == MODE_ENTERED) {
@@ -1886,6 +2169,15 @@
 			vconn_swap(pd);
 		} else if (IS_DATA(rx_msg, MSG_VDM)) {
 			handle_vdm_rx(pd, rx_msg);
+		} else if (rx_msg && pd->spec_rev == USBPD_REV_30) {
+			/* unhandled messages */
+			ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0,
+					SOP_MSG);
+			if (ret) {
+				usbpd_err(&pd->dev, "Error sending Not supported\n");
+				usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET);
+			}
+			break;
 		} else if (pd->send_pr_swap) {
 			pd->send_pr_swap = false;
 			ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG);
@@ -2039,8 +2331,8 @@
 			val.intval = pd->requested_voltage;
 			power_supply_set_property(pd->usb_psy,
 				pd->requested_voltage >= pd->current_voltage ?
-					POWER_SUPPLY_PROP_VOLTAGE_MAX :
-					POWER_SUPPLY_PROP_VOLTAGE_MIN,
+					POWER_SUPPLY_PROP_PD_VOLTAGE_MAX :
+					POWER_SUPPLY_PROP_PD_VOLTAGE_MIN,
 					&val);
 
 			/*
@@ -2091,8 +2383,8 @@
 			val.intval = pd->requested_voltage;
 			power_supply_set_property(pd->usb_psy,
 				pd->requested_voltage >= pd->current_voltage ?
-					POWER_SUPPLY_PROP_VOLTAGE_MIN :
-					POWER_SUPPLY_PROP_VOLTAGE_MAX, &val);
+					POWER_SUPPLY_PROP_PD_VOLTAGE_MIN :
+					POWER_SUPPLY_PROP_PD_VOLTAGE_MAX, &val);
 			pd->current_voltage = pd->requested_voltage;
 
 			/* resume charging */
@@ -2123,7 +2415,8 @@
 				usbpd_err(&pd->dev, "Error sending Sink Caps\n");
 				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
 			}
-		} else if (IS_CTRL(rx_msg, MSG_GET_SOURCE_CAP)) {
+		} else if (IS_CTRL(rx_msg, MSG_GET_SOURCE_CAP) &&
+				pd->spec_rev == USBPD_REV_20) {
 			ret = pd_send_msg(pd, MSG_SOURCE_CAPABILITIES,
 					default_src_caps,
 					ARRAY_SIZE(default_src_caps), SOP_MSG);
@@ -2146,7 +2439,8 @@
 			}
 
 			dr_swap(pd);
-		} else if (IS_CTRL(rx_msg, MSG_PR_SWAP)) {
+		} else if (IS_CTRL(rx_msg, MSG_PR_SWAP) &&
+				pd->spec_rev == USBPD_REV_20) {
 			/* lock in current mode */
 			set_power_role(pd, pd->current_pr);
 
@@ -2164,7 +2458,8 @@
 					POWER_SUPPLY_PROP_PR_SWAP, &val);
 			usbpd_set_state(pd, PE_PRS_SNK_SRC_TRANSITION_TO_OFF);
 			break;
-		} else if (IS_CTRL(rx_msg, MSG_VCONN_SWAP)) {
+		} else if (IS_CTRL(rx_msg, MSG_VCONN_SWAP) &&
+				pd->spec_rev == USBPD_REV_20) {
 			/*
 			 * if VCONN is connected to VBUS, make sure we are
 			 * not in high voltage contract, otherwise reject.
@@ -2192,6 +2487,120 @@
 			vconn_swap(pd);
 		} else if (IS_DATA(rx_msg, MSG_VDM)) {
 			handle_vdm_rx(pd, rx_msg);
+		} else if (pd->send_get_src_cap_ext && is_sink_tx_ok(pd)) {
+			pd->send_get_src_cap_ext = false;
+			ret = pd_send_msg(pd, MSG_GET_SOURCE_CAP_EXTENDED, NULL,
+				0, SOP_MSG);
+			if (ret) {
+				dev_err(&pd->dev,
+					"Error sending get_src_cap_ext\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+				break;
+			}
+			kick_sm(pd, SENDER_RESPONSE_TIME);
+		} else if (rx_msg &&
+			IS_EXT(rx_msg, MSG_SOURCE_CAPABILITIES_EXTENDED)) {
+			if (rx_msg->data_len != PD_SRC_CAP_EXT_DB_LEN) {
+				usbpd_err(&pd->dev, "Invalid src cap ext db\n");
+				break;
+			}
+			memcpy(&pd->src_cap_ext_db, rx_msg->payload,
+				sizeof(pd->src_cap_ext_db));
+			complete(&pd->is_ready);
+		} else if (pd->send_get_pps_status && is_sink_tx_ok(pd)) {
+			pd->send_get_pps_status = false;
+			ret = pd_send_msg(pd, MSG_GET_PPS_STATUS, NULL,
+				0, SOP_MSG);
+			if (ret) {
+				dev_err(&pd->dev,
+					"Error sending get_pps_status\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+				break;
+			}
+			kick_sm(pd, SENDER_RESPONSE_TIME);
+		} else if (rx_msg &&
+			IS_EXT(rx_msg, MSG_PPS_STATUS)) {
+			if (rx_msg->data_len != sizeof(pd->pps_status_db)) {
+				usbpd_err(&pd->dev, "Invalid pps status db\n");
+				break;
+			}
+			memcpy(&pd->pps_status_db, rx_msg->payload,
+				sizeof(pd->pps_status_db));
+			complete(&pd->is_ready);
+		} else if (IS_DATA(rx_msg, MSG_ALERT)) {
+			if (rx_msg->data_len != sizeof(pd->received_ado)) {
+				usbpd_err(&pd->dev, "Invalid ado\n");
+				break;
+			}
+			memcpy(&pd->received_ado, rx_msg->payload,
+				sizeof(pd->received_ado));
+			ret = pd_send_msg(pd, MSG_GET_STATUS, NULL,
+				0, SOP_MSG);
+			if (ret) {
+				dev_err(&pd->dev,
+					"Error sending get_status\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+				break;
+			}
+			kick_sm(pd, SENDER_RESPONSE_TIME);
+		} else if (rx_msg &&
+			IS_EXT(rx_msg, MSG_STATUS)) {
+			if (rx_msg->data_len != PD_STATUS_DB_LEN) {
+				usbpd_err(&pd->dev, "Invalid status db\n");
+				break;
+			}
+			memcpy(&pd->status_db, rx_msg->payload,
+				sizeof(pd->status_db));
+			kobject_uevent(&pd->dev.kobj, KOBJ_CHANGE);
+		} else if (pd->send_get_battery_cap && is_sink_tx_ok(pd)) {
+			pd->send_get_battery_cap = false;
+			ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_CAP,
+				&pd->get_battery_cap_db, 1, SOP_MSG);
+			if (ret) {
+				dev_err(&pd->dev,
+					"Error sending get_battery_cap\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+				break;
+			}
+			kick_sm(pd, SENDER_RESPONSE_TIME);
+		} else if (rx_msg &&
+			IS_EXT(rx_msg, MSG_BATTERY_CAPABILITIES)) {
+			if (rx_msg->data_len != PD_BATTERY_CAP_DB_LEN) {
+				usbpd_err(&pd->dev, "Invalid battery cap db\n");
+				break;
+			}
+			memcpy(&pd->battery_cap_db, rx_msg->payload,
+				sizeof(pd->battery_cap_db));
+			complete(&pd->is_ready);
+		} else if (pd->send_get_battery_status && is_sink_tx_ok(pd)) {
+			pd->send_get_battery_status = false;
+			ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_STATUS,
+				&pd->get_battery_status_db, 1, SOP_MSG);
+			if (ret) {
+				dev_err(&pd->dev,
+					"Error sending get_battery_status\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+				break;
+			}
+			kick_sm(pd, SENDER_RESPONSE_TIME);
+		} else if (rx_msg &&
+			IS_EXT(rx_msg, MSG_BATTERY_STATUS)) {
+			if (rx_msg->data_len != sizeof(pd->battery_sts_dobj)) {
+				usbpd_err(&pd->dev, "Invalid bat sts dobj\n");
+				break;
+			}
+			memcpy(&pd->battery_sts_dobj, rx_msg->payload,
+				sizeof(pd->battery_sts_dobj));
+			complete(&pd->is_ready);
+		} else if (rx_msg && pd->spec_rev == USBPD_REV_30) {
+			/* unhandled messages */
+			ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0,
+					SOP_MSG);
+			if (ret) {
+				usbpd_err(&pd->dev, "Error sending Not supported\n");
+				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
+			}
+			break;
 		} else if (pd->send_request) {
 			pd->send_request = false;
 			usbpd_set_state(pd, PE_SNK_SELECT_CAPABILITY);
@@ -2274,7 +2683,7 @@
 
 		val.intval = pd->requested_voltage;
 		power_supply_set_property(pd->usb_psy,
-				POWER_SUPPLY_PROP_VOLTAGE_MIN, &val);
+				POWER_SUPPLY_PROP_PD_VOLTAGE_MIN, &val);
 
 		pd_send_hard_reset(pd);
 		pd->in_explicit_contract = false;
@@ -2828,6 +3237,10 @@
 				"explicit" : "implicit");
 	add_uevent_var(env, "ALT_MODE=%d", pd->vdm_state == MODE_ENTERED);
 
+	add_uevent_var(env, "ADO=%08x", pd->received_ado);
+	for (i = 0; i < PD_STATUS_DB_LEN; i++)
+		add_uevent_var(env, "SDB%d=%08x", i, pd->status_db[i]);
+
 	return 0;
 }
 
@@ -3175,6 +3588,145 @@
 }
 static DEVICE_ATTR_WO(hard_reset);
 
+static int trigger_tx_msg(struct usbpd *pd, bool *msg_tx_flag)
+{
+	int ret = 0;
+
+	/* Only allowed if we are already in explicit sink contract */
+	if (pd->current_state != PE_SNK_READY || !is_sink_tx_ok(pd)) {
+		usbpd_err(&pd->dev, "%s: Cannot send msg\n", __func__);
+		ret = -EBUSY;
+		goto out;
+	}
+
+	reinit_completion(&pd->is_ready);
+	*msg_tx_flag = true;
+	kick_sm(pd, 0);
+
+	/* wait for operation to complete */
+	if (!wait_for_completion_timeout(&pd->is_ready,
+			msecs_to_jiffies(1000))) {
+		usbpd_err(&pd->dev, "%s: request timed out\n", __func__);
+		ret = -ETIMEDOUT;
+	}
+
+out:
+	*msg_tx_flag = false;
+	return ret;
+
+}
+
+static ssize_t get_src_cap_ext_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int i, ret, len = 0;
+	struct usbpd *pd = dev_get_drvdata(dev);
+
+	if (pd->spec_rev == USBPD_REV_20)
+		return -EINVAL;
+
+	ret = trigger_tx_msg(pd, &pd->send_get_src_cap_ext);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < PD_SRC_CAP_EXT_DB_LEN; i++)
+		len += snprintf(buf + len, PAGE_SIZE - len, "%d\n",
+			pd->src_cap_ext_db[i]);
+	return len;
+}
+static DEVICE_ATTR_RO(get_src_cap_ext);
+
+static ssize_t get_pps_status_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int ret;
+	struct usbpd *pd = dev_get_drvdata(dev);
+
+	if (pd->spec_rev == USBPD_REV_20)
+		return -EINVAL;
+
+	ret = trigger_tx_msg(pd, &pd->send_get_pps_status);
+	if (ret)
+		return ret;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", pd->pps_status_db);
+}
+static DEVICE_ATTR_RO(get_pps_status);
+
+static ssize_t rx_ado_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	struct usbpd *pd = dev_get_drvdata(dev);
+
+	/* dump the ADO as a hex string */
+	return snprintf(buf, PAGE_SIZE, "%08x\n", pd->received_ado);
+}
+static DEVICE_ATTR_RO(rx_ado);
+
+static ssize_t get_battery_cap_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct usbpd *pd = dev_get_drvdata(dev);
+	int val, ret;
+
+	if (pd->spec_rev == USBPD_REV_20 || sscanf(buf, "%d\n", &val) != 1) {
+		pd->get_battery_cap_db = -EINVAL;
+		return -EINVAL;
+	}
+
+	pd->get_battery_cap_db = val;
+
+	ret = trigger_tx_msg(pd, &pd->send_get_battery_cap);
+
+	return ret ? ret : size;
+}
+
+static ssize_t get_battery_cap_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int i, len = 0;
+	struct usbpd *pd = dev_get_drvdata(dev);
+
+	if (pd->get_battery_cap_db == -EINVAL)
+		return -EINVAL;
+
+	for (i = 0; i < PD_BATTERY_CAP_DB_LEN; i++)
+		len += snprintf(buf + len, PAGE_SIZE - len, "%d\n",
+			pd->battery_cap_db[i]);
+	return len;
+}
+static DEVICE_ATTR_RW(get_battery_cap);
+
+static ssize_t get_battery_status_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct usbpd *pd = dev_get_drvdata(dev);
+	int val, ret;
+
+	if (pd->spec_rev == USBPD_REV_20 || sscanf(buf, "%d\n", &val) != 1) {
+		pd->get_battery_status_db = -EINVAL;
+		return -EINVAL;
+	}
+
+	pd->get_battery_status_db = val;
+
+	ret = trigger_tx_msg(pd, &pd->send_get_battery_status);
+
+	return ret ? ret : size;
+}
+
+static ssize_t get_battery_status_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct usbpd *pd = dev_get_drvdata(dev);
+
+	if (pd->get_battery_status_db == -EINVAL)
+		return -EINVAL;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", pd->battery_sts_dobj);
+}
+static DEVICE_ATTR_RW(get_battery_status);
+
 static struct attribute *usbpd_attrs[] = {
 	&dev_attr_contract.attr,
 	&dev_attr_initial_pr.attr,
@@ -3194,6 +3746,11 @@
 	&dev_attr_rdo.attr,
 	&dev_attr_rdo_h.attr,
 	&dev_attr_hard_reset.attr,
+	&dev_attr_get_src_cap_ext.attr,
+	&dev_attr_get_pps_status.attr,
+	&dev_attr_rx_ado.attr,
+	&dev_attr_get_battery_cap.attr,
+	&dev_attr_get_battery_status.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(usbpd);
@@ -3311,6 +3868,7 @@
 	hrtimer_init(&pd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	pd->timer.function = pd_timeout;
 	mutex_init(&pd->swap_lock);
+	mutex_init(&pd->svid_handler_lock);
 
 	pd->usb_psy = power_supply_get_by_name("usb");
 	if (!pd->usb_psy) {
@@ -3432,6 +3990,7 @@
 	INIT_LIST_HEAD(&pd->rx_q);
 	INIT_LIST_HEAD(&pd->svid_handlers);
 	init_completion(&pd->is_ready);
+	init_completion(&pd->tx_chunk_request);
 
 	pd->psy_nb.notifier_call = psy_changed;
 	ret = power_supply_reg_notifier(&pd->psy_nb);
diff --git a/drivers/usb/phy/phy-msm-qusb-v2.c b/drivers/usb/phy/phy-msm-qusb-v2.c
index 37d904f..68bd576 100644
--- a/drivers/usb/phy/phy-msm-qusb-v2.c
+++ b/drivers/usb/phy/phy-msm-qusb-v2.c
@@ -63,6 +63,17 @@
 #define LINESTATE_DP			BIT(0)
 #define LINESTATE_DM			BIT(1)
 
+/* eud related registers */
+#define EUD_SW_ATTACH_DET	0x1018
+#define EUD_INT1_EN_MASK	0x0024
+
+/* EUD interrupt mask bits */
+#define EUD_INT_RX		BIT(0)
+#define EUD_INT_TX		BIT(1)
+#define EUD_INT_VBUS		BIT(2)
+#define EUD_INT_CHGR		BIT(3)
+#define EUD_INT_SAFE_MODE	BIT(4)
+
 unsigned int phy_tune1;
 module_param(phy_tune1, uint, 0644);
 MODULE_PARM_DESC(phy_tune1, "QUSB PHY v2 TUNE1");
@@ -81,6 +92,7 @@
 	struct usb_phy		phy;
 	struct mutex		lock;
 	void __iomem		*base;
+	void __iomem		*eud_base;
 	void __iomem		*efuse_reg;
 
 	struct clk		*ref_clk_src;
@@ -572,11 +584,15 @@
 				qphy->base +
 				qphy->phy_reg[PLL_CORE_INPUT_OVERRIDE]);
 
-			/* enable phy auto-resume */
-			writel_relaxed(0x91, qphy->base + qphy->phy_reg[TEST1]);
-			/* flush the previous write before next write */
-			wmb();
-			writel_relaxed(0x90, qphy->base + qphy->phy_reg[TEST1]);
+			if (linestate & (LINESTATE_DP | LINESTATE_DM)) {
+				/* enable phy auto-resume */
+				writel_relaxed(0x91,
+					qphy->base + qphy->phy_reg[TEST1]);
+				/* flush the previous write before next write */
+				wmb();
+				writel_relaxed(0x90,
+					qphy->base + qphy->phy_reg[TEST1]);
+			}
 
 			dev_dbg(phy->dev, "%s: intr_mask = %x\n",
 			__func__, intr_mask);
@@ -660,6 +676,22 @@
 			return ret;
 		}
 		qphy->dpdm_enable = true;
+
+		if (qphy->eud_base) {
+			if (qphy->cfg_ahb_clk)
+				clk_prepare_enable(qphy->cfg_ahb_clk);
+			writel_relaxed(BIT(0),
+					qphy->eud_base + EUD_SW_ATTACH_DET);
+			/* to flush above write before next write */
+			wmb();
+
+			writel_relaxed(EUD_INT_VBUS | EUD_INT_CHGR,
+					qphy->eud_base + EUD_INT1_EN_MASK);
+			/* to flush above write before turning off clk */
+			wmb();
+			if (qphy->cfg_ahb_clk)
+				clk_disable_unprepare(qphy->cfg_ahb_clk);
+		}
 	}
 
 	return ret;
@@ -674,6 +706,16 @@
 				__func__, qphy->dpdm_enable);
 
 	if (qphy->dpdm_enable) {
+		if (qphy->eud_base) {
+			if (qphy->cfg_ahb_clk)
+				clk_prepare_enable(qphy->cfg_ahb_clk);
+			writel_relaxed(0, qphy->eud_base + EUD_SW_ATTACH_DET);
+			/* to flush above write before turning off clk */
+			wmb();
+			if (qphy->cfg_ahb_clk)
+				clk_disable_unprepare(qphy->cfg_ahb_clk);
+		}
+
 		ret = qusb_phy_enable_power(qphy, false);
 		if (ret < 0) {
 			dev_dbg(qphy->phy.dev,
@@ -780,6 +822,17 @@
 		}
 	}
 
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+							"eud_base");
+	if (res) {
+		qphy->eud_base = devm_ioremap(dev, res->start,
+					resource_size(res));
+		if (IS_ERR(qphy->eud_base)) {
+			dev_dbg(dev, "couldn't ioremap eud_base\n");
+			qphy->eud_base = NULL;
+		}
+	}
+
 	/* ref_clk_src is needed irrespective of SE_CLK or DIFF_CLK usage */
 	qphy->ref_clk_src = devm_clk_get(dev, "ref_clk_src");
 	if (IS_ERR(qphy->ref_clk_src)) {
diff --git a/drivers/usb/phy/phy-msm-ssusb-qmp.c b/drivers/usb/phy/phy-msm-ssusb-qmp.c
index 59f5379..7e7c76c 100644
--- a/drivers/usb/phy/phy-msm-ssusb-qmp.c
+++ b/drivers/usb/phy/phy-msm-ssusb-qmp.c
@@ -623,10 +623,7 @@
 	}
 
 	if (suspend) {
-		if (!phy->cable_connected)
-			writel_relaxed(0x00,
-			phy->base + phy->phy_reg[USB3_PHY_POWER_DOWN_CONTROL]);
-		else
+		if (phy->cable_connected)
 			msm_ssusb_qmp_enable_autonomous(phy, 1);
 
 		/* Make sure above write completed with PHY */
@@ -674,6 +671,10 @@
 	struct msm_ssphy_qmp *phy = container_of(uphy, struct msm_ssphy_qmp,
 					phy);
 
+	writel_relaxed(0x00,
+		phy->base + phy->phy_reg[USB3_PHY_POWER_DOWN_CONTROL]);
+	readl_relaxed(phy->base + phy->phy_reg[USB3_PHY_POWER_DOWN_CONTROL]);
+
 	dev_dbg(uphy->dev, "QMP phy disconnect notification\n");
 	dev_dbg(uphy->dev, " cable_connected=%d\n", phy->cable_connected);
 	phy->cable_connected = false;
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
index d544b33..02b67ab 100644
--- a/drivers/usb/renesas_usbhs/rcar3.c
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -20,9 +20,13 @@
 /* Low Power Status register (LPSTS) */
 #define LPSTS_SUSPM	0x4000
 
-/* USB General control register 2 (UGCTRL2), bit[31:6] should be 0 */
+/*
+ * USB General control register 2 (UGCTRL2)
+ * Remarks: bit[31:11] and bit[9:6] should be 0
+ */
 #define UGCTRL2_RESERVED_3	0x00000001	/* bit[3:0] should be B'0001 */
 #define UGCTRL2_USB0SEL_OTG	0x00000030
+#define UGCTRL2_VBUSSEL		0x00000400
 
 static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data)
 {
@@ -34,7 +38,8 @@
 {
 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
 
-	usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG);
+	usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG |
+		      UGCTRL2_VBUSSEL);
 
 	if (enable) {
 		usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 84b444f..470b17b 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -136,6 +136,7 @@
 	{ USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
 	{ USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
 	{ USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
+	{ USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
 	{ USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index ebe51f11..2a99443 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -2023,8 +2023,11 @@
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) },			/* D-Link DWM-158 */
+	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d0e, 0xff) },			/* D-Link DWM-157 C1 */
 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff),			/* D-Link DWM-221 B1 */
 	  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
+	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff),			/* D-Link DWM-222 */
+	  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 1db4b61..a51b283 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -49,6 +49,7 @@
 	{ USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
 	{ USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
 	{ USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
+	{ USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_UC485) },
 	{ USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) },
 	{ USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) },
 	{ USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) },
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 09d9be8..3b5a15d 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -27,6 +27,7 @@
 #define ATEN_VENDOR_ID		0x0557
 #define ATEN_VENDOR_ID2		0x0547
 #define ATEN_PRODUCT_ID		0x2008
+#define ATEN_PRODUCT_UC485	0x2021
 #define ATEN_PRODUCT_ID2	0x2118
 
 #define IODATA_VENDOR_ID	0x04bb
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index cbea9f3..cde1153 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -124,9 +124,9 @@
 /* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */
 UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999,
 		"Initio Corporation",
-		"",
+		"INIC-3069",
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-		US_FL_NO_ATA_1X),
+		US_FL_NO_ATA_1X | US_FL_IGNORE_RESIDUE),
 
 /* Reported-by: Tom Arild Naess <tanaess@gmail.com> */
 UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999,
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 031bc08..43559be 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1173,6 +1173,10 @@
 			return ret;
 
 		vdev->barmap[index] = pci_iomap(pdev, index, 0);
+		if (!vdev->barmap[index]) {
+			pci_release_selected_regions(pdev, 1 << index);
+			return -ENOMEM;
+		}
 	}
 
 	vma->vm_private_data = vdev;
diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
index 5ffd1d9..357243d 100644
--- a/drivers/vfio/pci/vfio_pci_rdwr.c
+++ b/drivers/vfio/pci/vfio_pci_rdwr.c
@@ -193,7 +193,10 @@
 	if (!vdev->has_vga)
 		return -EINVAL;
 
-	switch (pos) {
+	if (pos > 0xbfffful)
+		return -EINVAL;
+
+	switch ((u32)pos) {
 	case 0xa0000 ... 0xbffff:
 		count = min(count, (size_t)(0xc0000 - pos));
 		iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 5dc128a..96a0661 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -537,8 +537,13 @@
 
 		preempt_enable();
 
-		if (vhost_enable_notify(&net->dev, vq))
+		if (!vhost_vq_avail_empty(&net->dev, vq))
 			vhost_poll_queue(&vq->poll);
+		else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
+			vhost_disable_notify(&net->dev, vq);
+			vhost_poll_queue(&vq->poll);
+		}
+
 		mutex_unlock(&vq->mutex);
 
 		len = peek_head_len(sk);
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 2d3b691..038ac69 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -308,6 +308,11 @@
 	info->screen_size = resource_size(res);
 	info->screen_base = devm_ioremap(&dev->dev, res->start,
 					 info->screen_size);
+	if (!info->screen_base) {
+		framebuffer_release(info);
+		return -ENOMEM;
+	}
+
 	info->fbops = &cobalt_lcd_fbops;
 	info->fix = cobalt_lcdfb_fix;
 	info->fix.smem_start = res->start;
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 76c1ad9..f8a3839 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1097,6 +1097,13 @@
 	void __user *argp = (void __user *)arg;
 	long ret = 0;
 
+	memset(&var, 0, sizeof(var));
+	memset(&fix, 0, sizeof(fix));
+	memset(&con2fb, 0, sizeof(con2fb));
+	memset(&cmap_from, 0, sizeof(cmap_from));
+	memset(&cmap, 0, sizeof(cmap));
+	memset(&event, 0, sizeof(event));
+
 	switch (cmd) {
 	case FBIOGET_VSCREENINFO:
 		if (!lock_fb_info(info))
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 778acf8..85dd20e 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -58,9 +58,13 @@
 	xen_pfn_t *gpfns;
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+
 		r = &resources[i];
 		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
 		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@
 			idxs[j] = XEN_PFN_DOWN(r->start) + j;
 		}
 
-		xatp.domid = DOMID_SELF;
 		xatp.size = nr;
-		xatp.space = XENMAPSPACE_dev_mmio;
 
 		set_xen_guest_handle(xatp.gpfns, gpfns);
 		set_xen_guest_handle(xatp.idxs, idxs);
diff --git a/drivers/xen/biomerge.c b/drivers/xen/biomerge.c
index 4da69db..1bdd02a 100644
--- a/drivers/xen/biomerge.c
+++ b/drivers/xen/biomerge.c
@@ -10,8 +10,7 @@
 	unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page));
 	unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page));
 
-	return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) &&
-		((bfn1 == bfn2) || ((bfn1+1) == bfn2));
+	return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2;
 #else
 	/*
 	 * XXX: Add support for merging bio_vec when using different page
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e46e7fb..705bb5f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4759,10 +4759,6 @@
 		else
 			flush = BTRFS_RESERVE_NO_FLUSH;
 		spin_lock(&space_info->lock);
-		if (can_overcommit(root, space_info, orig, flush)) {
-			spin_unlock(&space_info->lock);
-			break;
-		}
 		if (list_empty(&space_info->tickets) &&
 		    list_empty(&space_info->priority_tickets)) {
 			spin_unlock(&space_info->lock);
@@ -7401,7 +7397,8 @@
 
 		spin_unlock(&cluster->refill_lock);
 
-		down_read(&used_bg->data_rwsem);
+		/* We should only have one-level nested. */
+		down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
 
 		spin_lock(&cluster->refill_lock);
 		if (used_bg == cluster->block_group)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a2a014b..8a05fa7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7648,11 +7648,18 @@
 	 * within our reservation, otherwise we need to adjust our inode
 	 * counter appropriately.
 	 */
-	if (dio_data->outstanding_extents) {
+	if (dio_data->outstanding_extents >= num_extents) {
 		dio_data->outstanding_extents -= num_extents;
 	} else {
+		/*
+		 * If dio write length has been split due to no large enough
+		 * contiguous space, we need to compensate our inode counter
+		 * appropriately.
+		 */
+		u64 num_needed = num_extents - dio_data->outstanding_extents;
+
 		spin_lock(&BTRFS_I(inode)->lock);
-		BTRFS_I(inode)->outstanding_extents += num_extents;
+		BTRFS_I(inode)->outstanding_extents += num_needed;
 		spin_unlock(&BTRFS_I(inode)->lock);
 	}
 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 74ed5aa..f6e1119 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1834,6 +1834,8 @@
 			goto restore;
 		}
 
+		btrfs_qgroup_rescan_resume(fs_info);
+
 		if (!fs_info->uuid_root) {
 			btrfs_info(fs_info, "creating UUID tree");
 			ret = btrfs_create_uuid_tree(fs_info);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index b890045..309313b 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -37,6 +37,7 @@
  */
 #define LOG_INODE_ALL 0
 #define LOG_INODE_EXISTS 1
+#define LOG_OTHER_INODE 2
 
 /*
  * directory trouble cases
@@ -4623,7 +4624,7 @@
 	if (S_ISDIR(inode->i_mode) ||
 	    (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
 		       &BTRFS_I(inode)->runtime_flags) &&
-	     inode_only == LOG_INODE_EXISTS))
+	     inode_only >= LOG_INODE_EXISTS))
 		max_key.type = BTRFS_XATTR_ITEM_KEY;
 	else
 		max_key.type = (u8)-1;
@@ -4647,7 +4648,13 @@
 		return ret;
 	}
 
-	mutex_lock(&BTRFS_I(inode)->log_mutex);
+	if (inode_only == LOG_OTHER_INODE) {
+		inode_only = LOG_INODE_EXISTS;
+		mutex_lock_nested(&BTRFS_I(inode)->log_mutex,
+				  SINGLE_DEPTH_NESTING);
+	} else {
+		mutex_lock(&BTRFS_I(inode)->log_mutex);
+	}
 
 	/*
 	 * a brute force approach to making sure we get the most uptodate
@@ -4799,7 +4806,7 @@
 				 * unpin it.
 				 */
 				err = btrfs_log_inode(trans, root, other_inode,
-						      LOG_INODE_EXISTS,
+						      LOG_OTHER_INODE,
 						      0, LLONG_MAX, ctx);
 				iput(other_inode);
 				if (err)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 900ffaf..7b79a54 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -188,7 +188,7 @@
 /*
  * read a single page, without unlocking it.
  */
-static int readpage_nounlock(struct file *filp, struct page *page)
+static int ceph_do_readpage(struct file *filp, struct page *page)
 {
 	struct inode *inode = file_inode(filp);
 	struct ceph_inode_info *ci = ceph_inode(inode);
@@ -218,7 +218,7 @@
 
 	err = ceph_readpage_from_fscache(inode, page);
 	if (err == 0)
-		goto out;
+		return -EINPROGRESS;
 
 	dout("readpage inode %p file %p page %p index %lu\n",
 	     inode, filp, page, page->index);
@@ -248,8 +248,11 @@
 
 static int ceph_readpage(struct file *filp, struct page *page)
 {
-	int r = readpage_nounlock(filp, page);
-	unlock_page(page);
+	int r = ceph_do_readpage(filp, page);
+	if (r != -EINPROGRESS)
+		unlock_page(page);
+	else
+		r = 0;
 	return r;
 }
 
@@ -1235,7 +1238,7 @@
 			goto retry_locked;
 		r = writepage_nounlock(page, NULL);
 		if (r < 0)
-			goto fail_nosnap;
+			goto fail_unlock;
 		goto retry_locked;
 	}
 
@@ -1263,11 +1266,14 @@
 	}
 
 	/* we need to read it. */
-	r = readpage_nounlock(file, page);
-	if (r < 0)
-		goto fail_nosnap;
+	r = ceph_do_readpage(file, page);
+	if (r < 0) {
+		if (r == -EINPROGRESS)
+			return -EAGAIN;
+		goto fail_unlock;
+	}
 	goto retry_locked;
-fail_nosnap:
+fail_unlock:
 	unlock_page(page);
 	return r;
 }
diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c
index 5bc5d37..a2d7997 100644
--- a/fs/ceph/cache.c
+++ b/fs/ceph/cache.c
@@ -240,13 +240,7 @@
 	}
 }
 
-static void ceph_vfs_readpage_complete(struct page *page, void *data, int error)
-{
-	if (!error)
-		SetPageUptodate(page);
-}
-
-static void ceph_vfs_readpage_complete_unlock(struct page *page, void *data, int error)
+static void ceph_readpage_from_fscache_complete(struct page *page, void *data, int error)
 {
 	if (!error)
 		SetPageUptodate(page);
@@ -274,7 +268,7 @@
 		return -ENOBUFS;
 
 	ret = fscache_read_or_alloc_page(ci->fscache, page,
-					 ceph_vfs_readpage_complete, NULL,
+					 ceph_readpage_from_fscache_complete, NULL,
 					 GFP_KERNEL);
 
 	switch (ret) {
@@ -303,7 +297,7 @@
 		return -ENOBUFS;
 
 	ret = fscache_read_or_alloc_pages(ci->fscache, mapping, pages, nr_pages,
-					  ceph_vfs_readpage_complete_unlock,
+					  ceph_readpage_from_fscache_complete,
 					  NULL, mapping_gfp_mask(mapping));
 
 	switch (ret) {
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 789ff1d..dd3e236 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -183,15 +183,20 @@
 }
 
 /*
+ * Don't allow path components longer than the server max.
  * Don't allow the separator character in a path component.
  * The VFS will not allow "/", but "\" is allowed by posix.
  */
 static int
-check_name(struct dentry *direntry)
+check_name(struct dentry *direntry, struct cifs_tcon *tcon)
 {
 	struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
 	int i;
 
+	if (unlikely(direntry->d_name.len >
+		     le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
+		return -ENAMETOOLONG;
+
 	if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) {
 		for (i = 0; i < direntry->d_name.len; i++) {
 			if (direntry->d_name.name[i] == '\\') {
@@ -489,10 +494,6 @@
 		return finish_no_open(file, res);
 	}
 
-	rc = check_name(direntry);
-	if (rc)
-		return rc;
-
 	xid = get_xid();
 
 	cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
@@ -505,6 +506,11 @@
 	}
 
 	tcon = tlink_tcon(tlink);
+
+	rc = check_name(direntry, tcon);
+	if (rc)
+		goto out_free_xid;
+
 	server = tcon->ses->server;
 
 	if (server->ops->new_lease_key)
@@ -765,7 +771,7 @@
 	}
 	pTcon = tlink_tcon(tlink);
 
-	rc = check_name(direntry);
+	rc = check_name(direntry, pTcon);
 	if (rc)
 		goto lookup_out;
 
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 7c1c6c3..0437e5f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2930,8 +2930,8 @@
 	kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) *
 			  le32_to_cpu(pfs_inf->SectorsPerAllocationUnit);
 	kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits);
-	kst->f_bfree  = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits);
-	kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
+	kst->f_bfree  = kst->f_bavail =
+			le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
 	return;
 }
 
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index dc0d141..1e1449a 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -84,8 +84,8 @@
 
 #define NUMBER_OF_SMB2_COMMANDS	0x0013
 
-/* BB FIXME - analyze following length BB */
-#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
+/* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
+#define MAX_SMB2_HDR_SIZE 0x00b0
 
 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
diff --git a/fs/dcache.c b/fs/dcache.c
index 7171f0d..227a4f9 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -277,6 +277,33 @@
 	return dentry->d_name.name != dentry->d_iname;
 }
 
+void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry)
+{
+	spin_lock(&dentry->d_lock);
+	if (unlikely(dname_external(dentry))) {
+		struct external_name *p = external_name(dentry);
+		atomic_inc(&p->u.count);
+		spin_unlock(&dentry->d_lock);
+		name->name = p->name;
+	} else {
+		memcpy(name->inline_name, dentry->d_iname, DNAME_INLINE_LEN);
+		spin_unlock(&dentry->d_lock);
+		name->name = name->inline_name;
+	}
+}
+EXPORT_SYMBOL(take_dentry_name_snapshot);
+
+void release_dentry_name_snapshot(struct name_snapshot *name)
+{
+	if (unlikely(name->name != name->inline_name)) {
+		struct external_name *p;
+		p = container_of(name->name, struct external_name, name[0]);
+		if (unlikely(atomic_dec_and_test(&p->u.count)))
+			kfree_rcu(p, u.head);
+	}
+}
+EXPORT_SYMBOL(release_dentry_name_snapshot);
+
 static inline void __d_set_inode_and_type(struct dentry *dentry,
 					  struct inode *inode,
 					  unsigned type_flags)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 1e30f74..3d7de9f 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -730,7 +730,7 @@
 {
 	int error;
 	struct dentry *dentry = NULL, *trap;
-	const char *old_name;
+	struct name_snapshot old_name;
 
 	trap = lock_rename(new_dir, old_dir);
 	/* Source or destination directories don't exist? */
@@ -745,19 +745,19 @@
 	if (IS_ERR(dentry) || dentry == trap || d_really_is_positive(dentry))
 		goto exit;
 
-	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
+	take_dentry_name_snapshot(&old_name, old_dentry);
 
 	error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
 			      dentry, 0);
 	if (error) {
-		fsnotify_oldname_free(old_name);
+		release_dentry_name_snapshot(&old_name);
 		goto exit;
 	}
 	d_move(old_dentry, dentry);
-	fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name,
+	fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name,
 		d_is_dir(old_dentry),
 		NULL, old_dentry);
-	fsnotify_oldname_free(old_name);
+	release_dentry_name_snapshot(&old_name);
 	unlock_rename(new_dir, old_dir);
 	dput(dentry);
 	return old_dentry;
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 58c2f4a..9ac6591 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -355,6 +355,10 @@
 	error = misc_register(&ls->ls_device);
 	if (error) {
 		kfree(ls->ls_device.name);
+		/* this has to be set to NULL
+		 * to avoid a double-free in dlm_device_deregister
+		 */
+		ls->ls_device.name = NULL;
 	}
 fail:
 	return error;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index dc4a34f..5b96ba7 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -524,8 +524,13 @@
 	wait_queue_head_t *whead;
 
 	rcu_read_lock();
-	/* If it is cleared by POLLFREE, it should be rcu-safe */
-	whead = rcu_dereference(pwq->whead);
+	/*
+	 * If it is cleared by POLLFREE, it should be rcu-safe.
+	 * If we read NULL we need a barrier paired with
+	 * smp_store_release() in ep_poll_callback(), otherwise
+	 * we rely on whead->lock.
+	 */
+	whead = smp_load_acquire(&pwq->whead);
 	if (whead)
 		remove_wait_queue(whead, &pwq->wait);
 	rcu_read_unlock();
@@ -1010,17 +1015,6 @@
 	struct eventpoll *ep = epi->ep;
 	int ewake = 0;
 
-	if ((unsigned long)key & POLLFREE) {
-		ep_pwq_from_wait(wait)->whead = NULL;
-		/*
-		 * whead = NULL above can race with ep_remove_wait_queue()
-		 * which can do another remove_wait_queue() after us, so we
-		 * can't use __remove_wait_queue(). whead->lock is held by
-		 * the caller.
-		 */
-		list_del_init(&wait->task_list);
-	}
-
 	spin_lock_irqsave(&ep->lock, flags);
 
 	/*
@@ -1102,10 +1096,26 @@
 	if (pwake)
 		ep_poll_safewake(&ep->poll_wait);
 
-	if (epi->event.events & EPOLLEXCLUSIVE)
-		return ewake;
+	if (!(epi->event.events & EPOLLEXCLUSIVE))
+		ewake = 1;
 
-	return 1;
+	if ((unsigned long)key & POLLFREE) {
+		/*
+		 * If we race with ep_remove_wait_queue() it can miss
+		 * ->whead = NULL and do another remove_wait_queue() after
+		 * us, so we can't use __remove_wait_queue().
+		 */
+		list_del_init(&wait->task_list);
+		/*
+		 * ->whead != NULL protects us from the race with ep_free()
+		 * or ep_remove(), ep_remove_wait_queue() takes whead->lock
+		 * held by the caller. Once we nullify it, nothing protects
+		 * ep/epi or even wait.
+		 */
+		smp_store_release(&ep_pwq_from_wait(wait)->whead, NULL);
+	}
+
+	return ewake;
 }
 
 /*
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 9e77c08..d17d12e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -469,6 +469,8 @@
 				lastoff = page_offset(page);
 				bh = head = page_buffers(page);
 				do {
+					if (lastoff + bh->b_size <= startoff)
+						goto next;
 					if (buffer_uptodate(bh) ||
 					    buffer_unwritten(bh)) {
 						if (whence == SEEK_DATA)
@@ -483,6 +485,7 @@
 						unlock_page(page);
 						goto out;
 					}
+next:
 					lastoff += bh->b_size;
 					bh = bh->b_this_page;
 				} while (bh != head);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index cf68100..95bf466 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1926,7 +1926,8 @@
 			n_desc_blocks = o_desc_blocks +
 				le16_to_cpu(es->s_reserved_gdt_blocks);
 			n_group = n_desc_blocks * EXT4_DESC_PER_BLOCK(sb);
-			n_blocks_count = n_group * EXT4_BLOCKS_PER_GROUP(sb);
+			n_blocks_count = (ext4_fsblk_t)n_group *
+				EXT4_BLOCKS_PER_GROUP(sb);
 			n_group--; /* set to last group number */
 		}
 
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 2fc84a9..98c1a63 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -316,7 +316,7 @@
 		return 0;
 
 	/* Get the previous summary */
-	for (i = CURSEG_WARM_DATA; i <= CURSEG_COLD_DATA; i++) {
+	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
 		struct curseg_info *curseg = CURSEG_I(sbi, i);
 		if (curseg->segno == segno) {
 			sum = curseg->sum_blk->entries[blkoff];
@@ -626,8 +626,6 @@
 	}
 
 	clear_sbi_flag(sbi, SBI_POR_DOING);
-	if (err)
-		set_ckpt_flags(sbi, CP_ERROR_FLAG);
 	mutex_unlock(&sbi->cp_mutex);
 
 	/* let's drop all the directory inodes for clean checkpoint */
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 75c95659..21d829b 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -55,7 +55,7 @@
 {
 	struct fuse_file *ff;
 
-	ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
+	ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL);
 	if (unlikely(!ff))
 		return NULL;
 
diff --git a/fs/inode.c b/fs/inode.c
index 0aaebd1..3844c31 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -637,6 +637,7 @@
 
 	dispose_list(&dispose);
 }
+EXPORT_SYMBOL_GPL(evict_inodes);
 
 /**
  * invalidate_inodes	- attempt to free all inodes on a superblock
diff --git a/fs/internal.h b/fs/internal.h
index 15fe2aa..3e58863 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -138,7 +138,6 @@
 extern void inode_io_list_del(struct inode *inode);
 
 extern long get_nr_dirty_inodes(void);
-extern void evict_inodes(struct super_block *);
 extern int invalidate_inodes(struct super_block *, bool);
 
 /*
diff --git a/fs/iomap.c b/fs/iomap.c
index 798c291..a49db88 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -281,7 +281,7 @@
 		unsigned long bytes;	/* Bytes to write to page */
 
 		offset = (pos & (PAGE_SIZE - 1));
-		bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, length);
 
 		rpage = __iomap_read_page(inode, pos);
 		if (IS_ERR(rpage))
@@ -376,7 +376,7 @@
 		unsigned offset, bytes;
 
 		offset = pos & (PAGE_SIZE - 1); /* Within page */
-		bytes = min_t(unsigned, PAGE_SIZE - offset, count);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, count);
 
 		if (IS_DAX(inode))
 			status = iomap_dax_zero(pos, offset, bytes, iomap);
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 7bc186f..1be45c8 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -77,13 +77,6 @@
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		ea_name = XATTR_NAME_POSIX_ACL_ACCESS;
-		if (acl) {
-			rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
-			if (rc)
-				return rc;
-			inode->i_ctime = current_time(inode);
-			mark_inode_dirty(inode);
-		}
 		break;
 	case ACL_TYPE_DEFAULT:
 		ea_name = XATTR_NAME_POSIX_ACL_DEFAULT;
@@ -118,9 +111,17 @@
 
 	tid = txBegin(inode->i_sb, 0);
 	mutex_lock(&JFS_IP(inode)->commit_mutex);
+	if (type == ACL_TYPE_ACCESS && acl) {
+		rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+		if (rc)
+			goto end_tx;
+		inode->i_ctime = current_time(inode);
+		mark_inode_dirty(inode);
+	}
 	rc = __jfs_set_acl(tid, inode, type, acl);
 	if (!rc)
 		rc = txCommit(tid, 1, &inode, 0);
+end_tx:
 	txEnd(tid);
 	mutex_unlock(&JFS_IP(inode)->commit_mutex);
 	return rc;
diff --git a/fs/namei.c b/fs/namei.c
index 79177c9..e10895c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4404,11 +4404,11 @@
 {
 	int error;
 	bool is_dir = d_is_dir(old_dentry);
-	const unsigned char *old_name;
 	struct inode *source = old_dentry->d_inode;
 	struct inode *target = new_dentry->d_inode;
 	bool new_is_dir = false;
 	unsigned max_links = new_dir->i_sb->s_max_links;
+	struct name_snapshot old_name;
 
 	/*
 	 * Check source == target.
@@ -4459,7 +4459,7 @@
 	if (error)
 		return error;
 
-	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
+	take_dentry_name_snapshot(&old_name, old_dentry);
 	dget(new_dentry);
 	if (!is_dir || (flags & RENAME_EXCHANGE))
 		lock_two_nondirectories(source, target);
@@ -4514,14 +4514,14 @@
 		inode_unlock(target);
 	dput(new_dentry);
 	if (!error) {
-		fsnotify_move(old_dir, new_dir, old_name, is_dir,
+		fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
 			      !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
 		if (flags & RENAME_EXCHANGE) {
 			fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
 				      new_is_dir, NULL, new_dentry);
 		}
 	}
-	fsnotify_oldname_free(old_name);
+	release_dentry_name_snapshot(&old_name);
 
 	return error;
 }
diff --git a/fs/namespace.c b/fs/namespace.c
index 7731f77..2160bb9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -227,6 +227,7 @@
 		mnt->mnt_count = 1;
 		mnt->mnt_writers = 0;
 #endif
+		mnt->mnt.data = NULL;
 
 		INIT_HLIST_NODE(&mnt->mnt_hash);
 		INIT_LIST_HEAD(&mnt->mnt_child);
@@ -976,7 +977,6 @@
 	if (!mnt)
 		return ERR_PTR(-ENOMEM);
 
-	mnt->mnt.data = NULL;
 	if (type->alloc_mnt_data) {
 		mnt->mnt.data = type->alloc_mnt_data();
 		if (!mnt->mnt.data) {
@@ -990,7 +990,6 @@
 
 	root = mount_fs(type, flags, name, &mnt->mnt, data);
 	if (IS_ERR(root)) {
-		kfree(mnt->mnt.data);
 		mnt_free_id(mnt);
 		free_vfsmnt(mnt);
 		return ERR_CAST(root);
@@ -1109,7 +1108,6 @@
 	return mnt;
 
  out_free:
-	kfree(mnt->mnt.data);
 	mnt_free_id(mnt);
 	free_vfsmnt(mnt);
 	return ERR_PTR(err);
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index f31fd0d..b1daeaf 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -121,6 +121,7 @@
 config PNFS_BLOCK
 	tristate
 	depends on NFS_V4_1 && BLK_DEV_DM
+	depends on 64BIT || LBDAF
 	default NFS_V4
 
 config PNFS_OBJLAYOUT
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index a1de8ef..1eec947 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -636,11 +636,11 @@
 	if (result <= 0)
 		goto out;
 
-	result = generic_write_sync(iocb, result);
-	if (result < 0)
-		goto out;
 	written = result;
 	iocb->ki_pos += written;
+	result = generic_write_sync(iocb, written);
+	if (result < 0)
+		goto out;
 
 	/* Return error values */
 	if (nfs_need_check_write(file, inode)) {
@@ -757,7 +757,7 @@
 	 */
 	nfs_sync_mapping(filp->f_mapping);
 	if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
-		nfs_zap_mapping(inode, filp->f_mapping);
+		nfs_zap_caches(inode);
 out:
 	return status;
 }
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index f7a3f6b..9009989 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -30,6 +30,7 @@
 {
 	nfs4_print_deviceid(&mirror_ds->id_node.deviceid);
 	nfs4_pnfs_ds_put(mirror_ds->ds);
+	kfree(mirror_ds->ds_versions);
 	kfree_rcu(mirror_ds, id_node.rcu);
 }
 
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 80bcc0b..52ea41b 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -248,7 +248,6 @@
 extern const struct nfs_pageio_ops nfs_pgio_rw_ops;
 struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *);
 void nfs_pgio_header_free(struct nfs_pgio_header *);
-void nfs_pgio_data_destroy(struct nfs_pgio_header *);
 int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *);
 int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr,
 		      struct rpc_cred *cred, const struct nfs_rpc_ops *rpc_ops,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 401ea6e..a53b8e0 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6419,7 +6419,7 @@
 		set_current_state(TASK_INTERRUPTIBLE);
 		spin_unlock_irqrestore(&q->lock, flags);
 
-		freezable_schedule_timeout_interruptible(NFS4_LOCK_MAXTIMEOUT);
+		freezable_schedule_timeout(NFS4_LOCK_MAXTIMEOUT);
 	}
 
 	finish_wait(q, &wait);
@@ -7410,7 +7410,7 @@
 			cdata->res.server_scope = NULL;
 		}
 		/* Save the EXCHANGE_ID verifier session trunk tests */
-		memcpy(clp->cl_confirm.data, cdata->args.verifier->data,
+		memcpy(clp->cl_confirm.data, cdata->args.verifier.data,
 		       sizeof(clp->cl_confirm.data));
 	}
 out:
@@ -7447,7 +7447,6 @@
 static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
 			u32 sp4_how, struct rpc_xprt *xprt)
 {
-	nfs4_verifier verifier;
 	struct rpc_message msg = {
 		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_EXCHANGE_ID],
 		.rpc_cred = cred,
@@ -7470,8 +7469,7 @@
 	if (!calldata)
 		goto out;
 
-	if (!xprt)
-		nfs4_init_boot_verifier(clp, &verifier);
+	nfs4_init_boot_verifier(clp, &calldata->args.verifier);
 
 	status = nfs4_init_uniform_client_string(clp);
 	if (status)
@@ -7516,9 +7514,8 @@
 		task_setup_data.rpc_xprt = xprt;
 		task_setup_data.flags =
 				RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC;
-		calldata->args.verifier = &clp->cl_confirm;
-	} else {
-		calldata->args.verifier = &verifier;
+		memcpy(calldata->args.verifier.data, clp->cl_confirm.data,
+				sizeof(calldata->args.verifier.data));
 	}
 	calldata->args.client = clp;
 #ifdef CONFIG_NFS_V4_1_MIGRATION
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index c9c4d985..5e2724a 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1761,7 +1761,7 @@
 	int len = 0;
 
 	encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
-	encode_nfs4_verifier(xdr, args->verifier);
+	encode_nfs4_verifier(xdr, &args->verifier);
 
 	encode_string(xdr, strlen(args->client->cl_owner_id),
 			args->client->cl_owner_id);
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 142a74f..3d17fc8 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -497,16 +497,6 @@
 }
 EXPORT_SYMBOL_GPL(nfs_pgio_header_alloc);
 
-/*
- * nfs_pgio_header_free - Free a read or write header
- * @hdr: The header to free
- */
-void nfs_pgio_header_free(struct nfs_pgio_header *hdr)
-{
-	hdr->rw_ops->rw_free_header(hdr);
-}
-EXPORT_SYMBOL_GPL(nfs_pgio_header_free);
-
 /**
  * nfs_pgio_data_destroy - make @hdr suitable for reuse
  *
@@ -515,14 +505,24 @@
  *
  * @hdr: A header that has had nfs_generic_pgio called
  */
-void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr)
+static void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr)
 {
 	if (hdr->args.context)
 		put_nfs_open_context(hdr->args.context);
 	if (hdr->page_array.pagevec != hdr->page_array.page_array)
 		kfree(hdr->page_array.pagevec);
 }
-EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy);
+
+/*
+ * nfs_pgio_header_free - Free a read or write header
+ * @hdr: The header to free
+ */
+void nfs_pgio_header_free(struct nfs_pgio_header *hdr)
+{
+	nfs_pgio_data_destroy(hdr);
+	hdr->rw_ops->rw_free_header(hdr);
+}
+EXPORT_SYMBOL_GPL(nfs_pgio_header_free);
 
 /**
  * nfs_pgio_rpcsetup - Set up arguments for a pageio call
@@ -636,7 +636,6 @@
 static void nfs_pgio_error(struct nfs_pgio_header *hdr)
 {
 	set_bit(NFS_IOHDR_REDO, &hdr->flags);
-	nfs_pgio_data_destroy(hdr);
 	hdr->completion_ops->completion(hdr);
 }
 
@@ -647,7 +646,6 @@
 static void nfs_pgio_release(void *calldata)
 {
 	struct nfs_pgio_header *hdr = calldata;
-	nfs_pgio_data_destroy(hdr);
 	hdr->completion_ops->completion(hdr);
 }
 
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 415d7e6..b7a07ba 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2145,7 +2145,6 @@
 		nfs_pageio_reset_write_mds(desc);
 		mirror->pg_recoalesce = 1;
 	}
-	nfs_pgio_data_destroy(hdr);
 	hdr->release(hdr);
 }
 
@@ -2257,7 +2256,6 @@
 		nfs_pageio_reset_read_mds(desc);
 		mirror->pg_recoalesce = 1;
 	}
-	nfs_pgio_data_destroy(hdr);
 	hdr->release(hdr);
 }
 
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 4e7a56a..2c4f7a2 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -129,7 +129,7 @@
 	argp->p = page_address(argp->pagelist[0]);
 	argp->pagelist++;
 	if (argp->pagelen < PAGE_SIZE) {
-		argp->end = argp->p + (argp->pagelen>>2);
+		argp->end = argp->p + XDR_QUADLEN(argp->pagelen);
 		argp->pagelen = 0;
 	} else {
 		argp->end = argp->p + (PAGE_SIZE>>2);
@@ -1246,9 +1246,7 @@
 		argp->pagelen -= pages * PAGE_SIZE;
 		len -= pages * PAGE_SIZE;
 
-		argp->p = (__be32 *)page_address(argp->pagelist[0]);
-		argp->pagelist++;
-		argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
+		next_decode_page(argp);
 	}
 	argp->p += XDR_QUADLEN(len);
 
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index db39de2..a64adc2 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -104,16 +104,20 @@
 	if (unlikely(!fsnotify_inode_watches_children(p_inode)))
 		__fsnotify_update_child_dentry_flags(p_inode);
 	else if (p_inode->i_fsnotify_mask & mask) {
+		struct name_snapshot name;
+
 		/* we are notifying a parent so come up with the new mask which
 		 * specifies these are events which came from a child. */
 		mask |= FS_EVENT_ON_CHILD;
 
+		take_dentry_name_snapshot(&name, dentry);
 		if (path)
 			ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
-				       dentry->d_name.name, 0);
+				       name.name, 0);
 		else
 			ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
-				       dentry->d_name.name, 0);
+				       name.name, 0);
+		release_dentry_name_snapshot(&name);
 	}
 
 	dput(parent);
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index bd2dc34..8e151fb 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -434,7 +434,7 @@
 	for (i = 0; i < cxt->max_dump_cnt; i++) {
 		cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
 						  &cxt->ecc_info,
-						  cxt->memtype);
+						  cxt->memtype, 0);
 		if (IS_ERR(cxt->przs[i])) {
 			err = PTR_ERR(cxt->przs[i]);
 			dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
@@ -471,7 +471,8 @@
 		return -ENOMEM;
 	}
 
-	*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info, cxt->memtype);
+	*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
+				  cxt->memtype, 0);
 	if (IS_ERR(*prz)) {
 		int err = PTR_ERR(*prz);
 
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 3975dee..e11672a 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -48,16 +48,15 @@
 	return atomic_read(&prz->buffer->start);
 }
 
-static DEFINE_RAW_SPINLOCK(buffer_lock);
-
 /* increase and wrap the start pointer, returning the old value */
 static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
 {
 	int old;
 	int new;
-	unsigned long flags;
+	unsigned long flags = 0;
 
-	raw_spin_lock_irqsave(&buffer_lock, flags);
+	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
+		raw_spin_lock_irqsave(&prz->buffer_lock, flags);
 
 	old = atomic_read(&prz->buffer->start);
 	new = old + a;
@@ -65,7 +64,8 @@
 		new -= prz->buffer_size;
 	atomic_set(&prz->buffer->start, new);
 
-	raw_spin_unlock_irqrestore(&buffer_lock, flags);
+	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
+		raw_spin_unlock_irqrestore(&prz->buffer_lock, flags);
 
 	return old;
 }
@@ -75,9 +75,10 @@
 {
 	size_t old;
 	size_t new;
-	unsigned long flags;
+	unsigned long flags = 0;
 
-	raw_spin_lock_irqsave(&buffer_lock, flags);
+	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
+		raw_spin_lock_irqsave(&prz->buffer_lock, flags);
 
 	old = atomic_read(&prz->buffer->size);
 	if (old == prz->buffer_size)
@@ -89,7 +90,8 @@
 	atomic_set(&prz->buffer->size, new);
 
 exit:
-	raw_spin_unlock_irqrestore(&buffer_lock, flags);
+	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
+		raw_spin_unlock_irqrestore(&prz->buffer_lock, flags);
 }
 
 static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,
@@ -491,6 +493,7 @@
 			 prz->buffer->sig);
 	}
 
+	/* Rewind missing or invalid memory area. */
 	prz->buffer->sig = sig;
 	persistent_ram_zap(prz);
 
@@ -517,7 +520,7 @@
 
 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
 			u32 sig, struct persistent_ram_ecc_info *ecc_info,
-			unsigned int memtype)
+			unsigned int memtype, u32 flags)
 {
 	struct persistent_ram_zone *prz;
 	int ret = -ENOMEM;
@@ -528,6 +531,10 @@
 		goto err;
 	}
 
+	/* Initialize general buffer state. */
+	raw_spin_lock_init(&prz->buffer_lock);
+	prz->flags = flags;
+
 	ret = persistent_ram_buffer_map(start, size, prz, memtype);
 	if (ret)
 		goto err;
diff --git a/fs/sdcardfs/derived_perm.c b/fs/sdcardfs/derived_perm.c
index 1239d1c..fffaad4 100644
--- a/fs/sdcardfs/derived_perm.c
+++ b/fs/sdcardfs/derived_perm.c
@@ -176,6 +176,9 @@
 	gid_t gid = sbi->options.fs_low_gid;
 	struct iattr newattrs;
 
+	if (!sbi->options.gid_derivation)
+		return;
+
 	info = SDCARDFS_I(d_inode(dentry));
 	info_d = info->data;
 	perm = info_d->perm;
diff --git a/fs/sdcardfs/file.c b/fs/sdcardfs/file.c
index 6076c34..5ac0b0b 100644
--- a/fs/sdcardfs/file.c
+++ b/fs/sdcardfs/file.c
@@ -104,12 +104,19 @@
 {
 	long err = -ENOTTY;
 	struct file *lower_file;
+	const struct cred *saved_cred = NULL;
+	struct dentry *dentry = file->f_path.dentry;
+	struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
 
 	lower_file = sdcardfs_lower_file(file);
 
 	/* XXX: use vfs_ioctl if/when VFS exports it */
 	if (!lower_file || !lower_file->f_op)
 		goto out;
+
+	/* save current_cred and override it */
+	OVERRIDE_CRED(sbi, saved_cred, SDCARDFS_I(file_inode(file)));
+
 	if (lower_file->f_op->unlocked_ioctl)
 		err = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg);
 
@@ -117,6 +124,7 @@
 	if (!err)
 		sdcardfs_copy_and_fix_attrs(file_inode(file),
 				      file_inode(lower_file));
+	REVERT_CRED(saved_cred);
 out:
 	return err;
 }
@@ -127,15 +135,23 @@
 {
 	long err = -ENOTTY;
 	struct file *lower_file;
+	const struct cred *saved_cred = NULL;
+	struct dentry *dentry = file->f_path.dentry;
+	struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
 
 	lower_file = sdcardfs_lower_file(file);
 
 	/* XXX: use vfs_ioctl if/when VFS exports it */
 	if (!lower_file || !lower_file->f_op)
 		goto out;
+
+	/* save current_cred and override it */
+	OVERRIDE_CRED(sbi, saved_cred, SDCARDFS_I(file_inode(file)));
+
 	if (lower_file->f_op->compat_ioctl)
 		err = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);
 
+	REVERT_CRED(saved_cred);
 out:
 	return err;
 }
diff --git a/fs/sdcardfs/inode.c b/fs/sdcardfs/inode.c
index 683b492..4a971e2 100644
--- a/fs/sdcardfs/inode.c
+++ b/fs/sdcardfs/inode.c
@@ -34,10 +34,14 @@
 	if (!cred)
 		return NULL;
 
-	if (data->under_obb)
-		uid = AID_MEDIA_OBB;
-	else
-		uid = multiuser_get_uid(data->userid, sbi->options.fs_low_uid);
+	if (sbi->options.gid_derivation) {
+		if (data->under_obb)
+			uid = AID_MEDIA_OBB;
+		else
+			uid = multiuser_get_uid(data->userid, sbi->options.fs_low_uid);
+	} else {
+		uid = sbi->options.fs_low_uid;
+	}
 	cred->fsuid = make_kuid(&init_user_ns, uid);
 	cred->fsgid = make_kgid(&init_user_ns, sbi->options.fs_low_gid);
 
diff --git a/fs/sdcardfs/main.c b/fs/sdcardfs/main.c
index 80825b2..0a2b516 100644
--- a/fs/sdcardfs/main.c
+++ b/fs/sdcardfs/main.c
@@ -32,6 +32,7 @@
 	Opt_multiuser,
 	Opt_userid,
 	Opt_reserved_mb,
+	Opt_gid_derivation,
 	Opt_err,
 };
 
@@ -43,6 +44,7 @@
 	{Opt_mask, "mask=%u"},
 	{Opt_userid, "userid=%d"},
 	{Opt_multiuser, "multiuser"},
+	{Opt_gid_derivation, "derive_gid"},
 	{Opt_reserved_mb, "reserved_mb=%u"},
 	{Opt_err, NULL}
 };
@@ -64,6 +66,8 @@
 	vfsopts->gid = 0;
 	/* by default, 0MB is reserved */
 	opts->reserved_mb = 0;
+	/* by default, gid derivation is off */
+	opts->gid_derivation = false;
 
 	*debug = 0;
 
@@ -115,6 +119,9 @@
 				return 0;
 			opts->reserved_mb = option;
 			break;
+		case Opt_gid_derivation:
+			opts->gid_derivation = true;
+			break;
 		/* unknown option */
 		default:
 			if (!silent)
diff --git a/fs/sdcardfs/sdcardfs.h b/fs/sdcardfs/sdcardfs.h
index 4e0ce49..d1d8bab 100644
--- a/fs/sdcardfs/sdcardfs.h
+++ b/fs/sdcardfs/sdcardfs.h
@@ -219,6 +219,7 @@
 	gid_t fs_low_gid;
 	userid_t fs_user_id;
 	bool multiuser;
+	bool gid_derivation;
 	unsigned int reserved_mb;
 };
 
diff --git a/fs/sdcardfs/super.c b/fs/sdcardfs/super.c
index 7f4539b..b89947d 100644
--- a/fs/sdcardfs/super.c
+++ b/fs/sdcardfs/super.c
@@ -302,6 +302,8 @@
 		seq_printf(m, ",mask=%u", vfsopts->mask);
 	if (opts->fs_user_id)
 		seq_printf(m, ",userid=%u", opts->fs_user_id);
+	if (opts->gid_derivation)
+		seq_puts(m, ",derive_gid");
 	if (opts->reserved_mb != 0)
 		seq_printf(m, ",reserved=%uMB", opts->reserved_mb);
 
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 2852521..c6c15e5 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -351,7 +351,7 @@
 
 	err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
 				XFS_ATTR_FORK, &xfs_attr3_leaf_buf_ops);
-	if (!err && tp)
+	if (!err && tp && *bpp)
 		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF);
 	return err;
 }
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 2a8cbd1..d2f4ab1 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -579,7 +579,7 @@
 
 #else
 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork)		do { } while (0)
-#define	xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
+#define	xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)	do { } while (0)
 #endif /* DEBUG */
 
 /*
@@ -5555,6 +5555,8 @@
 	int			whichfork;	/* data or attribute fork */
 	xfs_fsblock_t		sum;
 	xfs_filblks_t		len = *rlen;	/* length to unmap in file */
+	xfs_fileoff_t		max_len;
+	xfs_agnumber_t		prev_agno = NULLAGNUMBER, agno;
 
 	trace_xfs_bunmap(ip, bno, len, flags, _RET_IP_);
 
@@ -5576,6 +5578,16 @@
 	ASSERT(len > 0);
 	ASSERT(nexts >= 0);
 
+	/*
+	 * Guesstimate how many blocks we can unmap without running the risk of
+	 * blowing out the transaction with a mix of EFIs and reflink
+	 * adjustments.
+	 */
+	if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK)
+		max_len = min(len, xfs_refcount_max_unmap(tp->t_log_res));
+	else
+		max_len = len;
+
 	if (!(ifp->if_flags & XFS_IFEXTENTS) &&
 	    (error = xfs_iread_extents(tp, ip, whichfork)))
 		return error;
@@ -5621,7 +5633,7 @@
 
 	extno = 0;
 	while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >= 0 &&
-	       (nexts == 0 || extno < nexts)) {
+	       (nexts == 0 || extno < nexts) && max_len > 0) {
 		/*
 		 * Is the found extent after a hole in which bno lives?
 		 * Just back up to the previous extent, if so.
@@ -5647,6 +5659,17 @@
 		ASSERT(ep != NULL);
 		del = got;
 		wasdel = isnullstartblock(del.br_startblock);
+
+		/*
+		 * Make sure we don't touch multiple AGF headers out of order
+		 * in a single transaction, as that could cause AB-BA deadlocks.
+		 */
+		if (!wasdel) {
+			agno = XFS_FSB_TO_AGNO(mp, del.br_startblock);
+			if (prev_agno != NULLAGNUMBER && prev_agno > agno)
+				break;
+			prev_agno = agno;
+		}
 		if (got.br_startoff < start) {
 			del.br_startoff = start;
 			del.br_blockcount -= start - got.br_startoff;
@@ -5655,6 +5678,15 @@
 		}
 		if (del.br_startoff + del.br_blockcount > bno + 1)
 			del.br_blockcount = bno + 1 - del.br_startoff;
+
+		/* How much can we safely unmap? */
+		if (max_len < del.br_blockcount) {
+			del.br_startoff += del.br_blockcount - max_len;
+			if (!wasdel)
+				del.br_startblock += del.br_blockcount - max_len;
+			del.br_blockcount = max_len;
+		}
+
 		sum = del.br_startblock + del.br_blockcount;
 		if (isrt &&
 		    (mod = do_mod(sum, mp->m_sb.sb_rextsize))) {
@@ -5835,6 +5867,7 @@
 		if (!isrt && wasdel)
 			xfs_mod_fdblocks(mp, (int64_t)del.br_blockcount, false);
 
+		max_len -= del.br_blockcount;
 		bno = del.br_startoff - 1;
 nodelete:
 		/*
@@ -6604,25 +6637,33 @@
 	int				whichfork,
 	xfs_fileoff_t			startoff,
 	xfs_fsblock_t			startblock,
-	xfs_filblks_t			blockcount,
+	xfs_filblks_t			*blockcount,
 	xfs_exntst_t			state)
 {
 	struct xfs_bmbt_irec		bmap;
 	int				nimaps = 1;
 	xfs_fsblock_t			firstfsb;
 	int				flags = XFS_BMAPI_REMAP;
-	int				done;
 	int				error = 0;
 
 	bmap.br_startblock = startblock;
 	bmap.br_startoff = startoff;
-	bmap.br_blockcount = blockcount;
+	bmap.br_blockcount = *blockcount;
 	bmap.br_state = state;
 
+	/*
+	 * firstfsb is tied to the transaction lifetime and is used to
+	 * ensure correct AG locking order and schedule work item
+	 * continuations.  XFS_BUI_MAX_FAST_EXTENTS (== 1) restricts us
+	 * to only making one bmap call per transaction, so it should
+	 * be safe to have it as a local variable here.
+	 */
+	firstfsb = NULLFSBLOCK;
+
 	trace_xfs_bmap_deferred(tp->t_mountp,
 			XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type,
 			XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
-			ip->i_ino, whichfork, startoff, blockcount, state);
+			ip->i_ino, whichfork, startoff, *blockcount, state);
 
 	if (whichfork != XFS_DATA_FORK && whichfork != XFS_ATTR_FORK)
 		return -EFSCORRUPTED;
@@ -6641,12 +6682,11 @@
 					bmap.br_blockcount, flags, &firstfsb,
 					bmap.br_blockcount, &bmap, &nimaps,
 					dfops);
+		*blockcount = 0;
 		break;
 	case XFS_BMAP_UNMAP:
-		error = xfs_bunmapi(tp, ip, bmap.br_startoff,
-				bmap.br_blockcount, flags, 1, &firstfsb,
-				dfops, &done);
-		ASSERT(done);
+		error = __xfs_bunmapi(tp, ip, startoff, blockcount,
+				XFS_BMAPI_REMAP, 1, &firstfsb, dfops);
 		break;
 	default:
 		ASSERT(0);
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index e7d40b3..db53ac7f 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -265,7 +265,7 @@
 int	xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_defer_ops *dfops,
 		struct xfs_inode *ip, enum xfs_bmap_intent_type type,
 		int whichfork, xfs_fileoff_t startoff, xfs_fsblock_t startblock,
-		xfs_filblks_t blockcount, xfs_exntst_t state);
+		xfs_filblks_t *blockcount, xfs_exntst_t state);
 int	xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
 		struct xfs_inode *ip, struct xfs_bmbt_irec *imap);
 int	xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 5c39186..9968a74 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -888,6 +888,7 @@
 	cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
 	if (!cur)
 		return -ENOMEM;
+	cur->bc_private.b.flags |= XFS_BTCUR_BPRV_INVALID_OWNER;
 
 	error = xfs_btree_change_owner(cur, new_owner, buffer_list);
 	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 91c6891..4ad1e21 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -714,7 +714,8 @@
 	 * Get the block pointer for this level.
 	 */
 	block = xfs_btree_get_block(cur, level, &bp);
-	xfs_btree_check_block(cur, block, level, bp);
+	if (xfs_btree_check_block(cur, block, level, bp))
+		return 0;
 	/*
 	 * It's empty, there is no such record.
 	 */
@@ -743,7 +744,8 @@
 	 * Get the block pointer for this level.
 	 */
 	block = xfs_btree_get_block(cur, level, &bp);
-	xfs_btree_check_block(cur, block, level, bp);
+	if (xfs_btree_check_block(cur, block, level, bp))
+		return 0;
 	/*
 	 * It's empty, there is no such record.
 	 */
@@ -1772,6 +1774,7 @@
 
 	/* Check the inode owner since the verifiers don't. */
 	if (xfs_sb_version_hascrc(&cur->bc_mp->m_sb) &&
+	    !(cur->bc_private.b.flags & XFS_BTCUR_BPRV_INVALID_OWNER) &&
 	    (cur->bc_flags & XFS_BTREE_LONG_PTRS) &&
 	    be64_to_cpu((*blkp)->bb_u.l.bb_owner) !=
 			cur->bc_private.b.ip->i_ino)
@@ -4432,10 +4435,15 @@
 
 	/* modify the owner */
 	block = xfs_btree_get_block(cur, level, &bp);
-	if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
+	if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
+		if (block->bb_u.l.bb_owner == cpu_to_be64(bbcoi->new_owner))
+			return 0;
 		block->bb_u.l.bb_owner = cpu_to_be64(bbcoi->new_owner);
-	else
+	} else {
+		if (block->bb_u.s.bb_owner == cpu_to_be32(bbcoi->new_owner))
+			return 0;
 		block->bb_u.s.bb_owner = cpu_to_be32(bbcoi->new_owner);
+	}
 
 	/*
 	 * If the block is a root block hosted in an inode, we might not have a
@@ -4444,16 +4452,19 @@
 	 * block is formatted into the on-disk inode fork. We still change it,
 	 * though, so everything is consistent in memory.
 	 */
-	if (bp) {
-		if (cur->bc_tp) {
-			xfs_trans_ordered_buf(cur->bc_tp, bp);
-			xfs_btree_log_block(cur, bp, XFS_BB_OWNER);
-		} else {
-			xfs_buf_delwri_queue(bp, bbcoi->buffer_list);
-		}
-	} else {
+	if (!bp) {
 		ASSERT(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE);
 		ASSERT(level == cur->bc_nlevels - 1);
+		return 0;
+	}
+
+	if (cur->bc_tp) {
+		if (!xfs_trans_ordered_buf(cur->bc_tp, bp)) {
+			xfs_btree_log_block(cur, bp, XFS_BB_OWNER);
+			return -EAGAIN;
+		}
+	} else {
+		xfs_buf_delwri_queue(bp, bbcoi->buffer_list);
 	}
 
 	return 0;
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index 3b0fc1a..33c7be2 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -268,7 +268,8 @@
 			short		forksize;	/* fork's inode space */
 			char		whichfork;	/* data or attr fork */
 			char		flags;		/* flags */
-#define	XFS_BTCUR_BPRV_WASDEL	1			/* was delayed */
+#define	XFS_BTCUR_BPRV_WASDEL		(1<<0)		/* was delayed */
+#define	XFS_BTCUR_BPRV_INVALID_OWNER	(1<<1)		/* for ext swap */
 		} b;
 	}		bc_private;	/* per-btree type data */
 } xfs_btree_cur_t;
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 1bdf288..b305dbf 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -263,7 +263,7 @@
 
 	err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
 					which_fork, &xfs_da3_node_buf_ops);
-	if (!err && tp) {
+	if (!err && tp && *bpp) {
 		struct xfs_da_blkinfo	*info = (*bpp)->b_addr;
 		int			type;
 
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index aa17cb7..43c902f 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -139,7 +139,7 @@
 
 	err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp,
 				XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
-	if (!err && tp)
+	if (!err && tp && *bpp)
 		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
 	return err;
 }
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index b887fb2..f2e342e 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -268,7 +268,7 @@
 
 	err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
 				XFS_DATA_FORK, &xfs_dir3_leaf1_buf_ops);
-	if (!err && tp)
+	if (!err && tp && *bpp)
 		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF);
 	return err;
 }
@@ -285,7 +285,7 @@
 
 	err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
 				XFS_DATA_FORK, &xfs_dir3_leafn_buf_ops);
-	if (!err && tp)
+	if (!err && tp && *bpp)
 		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF);
 	return err;
 }
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index a2818f6..42fef07 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -368,8 +368,6 @@
 				 * transaction and pin the log appropriately.
 				 */
 				xfs_trans_ordered_buf(tp, fbuf);
-				xfs_trans_log_buf(tp, fbuf, 0,
-						  BBTOB(fbuf->b_length) - 1);
 			}
 		} else {
 			fbuf->b_flags |= XBF_DONE;
@@ -1123,6 +1121,7 @@
 	int			error;
 	int			offset;
 	int			i, j;
+	int			searchdistance = 10;
 
 	pag = xfs_perag_get(mp, agno);
 
@@ -1149,7 +1148,6 @@
 	if (pagno == agno) {
 		int		doneleft;	/* done, to the left */
 		int		doneright;	/* done, to the right */
-		int		searchdistance = 10;
 
 		error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i);
 		if (error)
@@ -1210,21 +1208,9 @@
 		/*
 		 * Loop until we find an inode chunk with a free inode.
 		 */
-		while (!doneleft || !doneright) {
+		while (--searchdistance > 0 && (!doneleft || !doneright)) {
 			int	useleft;  /* using left inode chunk this time */
 
-			if (!--searchdistance) {
-				/*
-				 * Not in range - save last search
-				 * location and allocate a new inode
-				 */
-				xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
-				pag->pagl_leftrec = trec.ir_startino;
-				pag->pagl_rightrec = rec.ir_startino;
-				pag->pagl_pagino = pagino;
-				goto newino;
-			}
-
 			/* figure out the closer block if both are valid. */
 			if (!doneleft && !doneright) {
 				useleft = pagino -
@@ -1236,13 +1222,13 @@
 
 			/* free inodes to the left? */
 			if (useleft && trec.ir_freecount) {
-				rec = trec;
 				xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 				cur = tcur;
 
 				pag->pagl_leftrec = trec.ir_startino;
 				pag->pagl_rightrec = rec.ir_startino;
 				pag->pagl_pagino = pagino;
+				rec = trec;
 				goto alloc_inode;
 			}
 
@@ -1268,26 +1254,37 @@
 				goto error1;
 		}
 
-		/*
-		 * We've reached the end of the btree. because
-		 * we are only searching a small chunk of the
-		 * btree each search, there is obviously free
-		 * inodes closer to the parent inode than we
-		 * are now. restart the search again.
-		 */
-		pag->pagl_pagino = NULLAGINO;
-		pag->pagl_leftrec = NULLAGINO;
-		pag->pagl_rightrec = NULLAGINO;
-		xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
-		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
-		goto restart_pagno;
+		if (searchdistance <= 0) {
+			/*
+			 * Not in range - save last search
+			 * location and allocate a new inode
+			 */
+			xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
+			pag->pagl_leftrec = trec.ir_startino;
+			pag->pagl_rightrec = rec.ir_startino;
+			pag->pagl_pagino = pagino;
+
+		} else {
+			/*
+			 * We've reached the end of the btree. because
+			 * we are only searching a small chunk of the
+			 * btree each search, there is obviously free
+			 * inodes closer to the parent inode than we
+			 * are now. restart the search again.
+			 */
+			pag->pagl_pagino = NULLAGINO;
+			pag->pagl_leftrec = NULLAGINO;
+			pag->pagl_rightrec = NULLAGINO;
+			xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
+			xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
+			goto restart_pagno;
+		}
 	}
 
 	/*
 	 * In a different AG from the parent.
 	 * See if the most recently allocated block has any free.
 	 */
-newino:
 	if (agi->agi_newino != cpu_to_be32(NULLAGINO)) {
 		error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino),
 					 XFS_LOOKUP_EQ, &i);
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 8a37efe..4e30448 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -1539,14 +1539,11 @@
 	xfs_ifork_t	*ifp,		/* inode fork pointer */
 	int		new_size)	/* new indirection array size */
 {
-	int		nlists;		/* number of irec's (ex lists) */
-	int		size;		/* current indirection array size */
-
 	ASSERT(ifp->if_flags & XFS_IFEXTIREC);
-	nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
-	size = nlists * sizeof(xfs_ext_irec_t);
 	ASSERT(ifp->if_real_bytes);
-	ASSERT((new_size >= 0) && (new_size != size));
+	ASSERT((new_size >= 0) &&
+	       (new_size != ((ifp->if_real_bytes / XFS_IEXT_BUFSZ) *
+			     sizeof(xfs_ext_irec_t))));
 	if (new_size == 0) {
 		xfs_iext_destroy(ifp);
 	} else {
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 82a38d8..d71cb63 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -784,14 +784,6 @@
 }
 
 /*
- * While we're adjusting the refcounts records of an extent, we have
- * to keep an eye on the number of extents we're dirtying -- run too
- * many in a single transaction and we'll exceed the transaction's
- * reservation and crash the fs.  Each record adds 12 bytes to the
- * log (plus any key updates) so we'll conservatively assume 24 bytes
- * per record.  We must also leave space for btree splits on both ends
- * of the range and space for the CUD and a new CUI.
- *
  * XXX: This is a pretty hand-wavy estimate.  The penalty for guessing
  * true incorrectly is a shutdown FS; the penalty for guessing false
  * incorrectly is more transaction rolls than might be necessary.
@@ -822,7 +814,7 @@
 	else if (overhead > cur->bc_tp->t_log_res)
 		return false;
 	return  cur->bc_tp->t_log_res - overhead >
-		cur->bc_private.a.priv.refc.nr_ops * 32;
+		cur->bc_private.a.priv.refc.nr_ops * XFS_REFCOUNT_ITEM_OVERHEAD;
 }
 
 /*
@@ -1648,6 +1640,10 @@
 	error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
 	if (error)
 		goto out_trans;
+	if (!agbp) {
+		error = -ENOMEM;
+		goto out_trans;
+	}
 	cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
 
 	/* Find all the leftover CoW staging extents. */
diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h
index 098dc668..eafb9d1 100644
--- a/fs/xfs/libxfs/xfs_refcount.h
+++ b/fs/xfs/libxfs/xfs_refcount.h
@@ -67,4 +67,20 @@
 extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
 		xfs_agnumber_t agno);
 
+/*
+ * While we're adjusting the refcounts records of an extent, we have
+ * to keep an eye on the number of extents we're dirtying -- run too
+ * many in a single transaction and we'll exceed the transaction's
+ * reservation and crash the fs.  Each record adds 12 bytes to the
+ * log (plus any key updates) so we'll conservatively assume 32 bytes
+ * per record.  We must also leave space for btree splits on both ends
+ * of the range and space for the CUD and a new CUI.
+ */
+#define XFS_REFCOUNT_ITEM_OVERHEAD	32
+
+static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res)
+{
+	return (log_res * 3 / 4) / XFS_REFCOUNT_ITEM_OVERHEAD;
+}
+
 #endif	/* __XFS_REFCOUNT_H__ */
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 5789814..d23889e 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -90,11 +90,11 @@
  * associated buffer_heads, paying attention to the start and end offsets that
  * we need to process on the page.
  *
- * Landmine Warning: bh->b_end_io() will call end_page_writeback() on the last
- * buffer in the IO. Once it does this, it is unsafe to access the bufferhead or
- * the page at all, as we may be racing with memory reclaim and it can free both
- * the bufferhead chain and the page as it will see the page as clean and
- * unused.
+ * Note that we open code the action in end_buffer_async_write here so that we
+ * only have to iterate over the buffers attached to the page once.  This is not
+ * only more efficient, but also ensures that we only calls end_page_writeback
+ * at the end of the iteration, and thus avoids the pitfall of having the page
+ * and buffers potentially freed after every call to end_buffer_async_write.
  */
 static void
 xfs_finish_page_writeback(
@@ -102,29 +102,45 @@
 	struct bio_vec		*bvec,
 	int			error)
 {
-	unsigned int		end = bvec->bv_offset + bvec->bv_len - 1;
-	struct buffer_head	*head, *bh, *next;
+	struct buffer_head	*head = page_buffers(bvec->bv_page), *bh = head;
+	bool			busy = false;
 	unsigned int		off = 0;
-	unsigned int		bsize;
+	unsigned long		flags;
 
 	ASSERT(bvec->bv_offset < PAGE_SIZE);
 	ASSERT((bvec->bv_offset & (i_blocksize(inode) - 1)) == 0);
-	ASSERT(end < PAGE_SIZE);
+	ASSERT(bvec->bv_offset + bvec->bv_len <= PAGE_SIZE);
 	ASSERT((bvec->bv_len & (i_blocksize(inode) - 1)) == 0);
 
-	bh = head = page_buffers(bvec->bv_page);
-
-	bsize = bh->b_size;
+	local_irq_save(flags);
+	bit_spin_lock(BH_Uptodate_Lock, &head->b_state);
 	do {
-		if (off > end)
-			break;
-		next = bh->b_this_page;
-		if (off < bvec->bv_offset)
-			goto next_bh;
-		bh->b_end_io(bh, !error);
-next_bh:
-		off += bsize;
-	} while ((bh = next) != head);
+		if (off >= bvec->bv_offset &&
+		    off < bvec->bv_offset + bvec->bv_len) {
+			ASSERT(buffer_async_write(bh));
+			ASSERT(bh->b_end_io == NULL);
+
+			if (error) {
+				mapping_set_error(bvec->bv_page->mapping, -EIO);
+				set_buffer_write_io_error(bh);
+				clear_buffer_uptodate(bh);
+				SetPageError(bvec->bv_page);
+			} else {
+				set_buffer_uptodate(bh);
+			}
+			clear_buffer_async_write(bh);
+			unlock_buffer(bh);
+		} else if (buffer_async_write(bh)) {
+			ASSERT(buffer_locked(bh));
+			busy = true;
+		}
+		off += bh->b_size;
+	} while ((bh = bh->b_this_page) != head);
+	bit_spin_unlock(BH_Uptodate_Lock, &head->b_state);
+	local_irq_restore(flags);
+
+	if (!busy)
+		end_page_writeback(bvec->bv_page);
 }
 
 /*
@@ -138,8 +154,10 @@
 	int			error)
 {
 	struct inode		*inode = ioend->io_inode;
-	struct bio		*last = ioend->io_bio;
-	struct bio		*bio, *next;
+	struct bio		*bio = &ioend->io_inline_bio;
+	struct bio		*last = ioend->io_bio, *next;
+	u64			start = bio->bi_iter.bi_sector;
+	bool			quiet = bio_flagged(bio, BIO_QUIET);
 
 	for (bio = &ioend->io_inline_bio; bio; bio = next) {
 		struct bio_vec	*bvec;
@@ -160,6 +178,11 @@
 
 		bio_put(bio);
 	}
+
+	if (unlikely(error && !quiet)) {
+		xfs_err_ratelimited(XFS_I(inode)->i_mount,
+			"writeback error on sector %llu", start);
+	}
 }
 
 /*
@@ -427,7 +450,8 @@
 	ASSERT(!buffer_delay(bh));
 	ASSERT(!buffer_unwritten(bh));
 
-	mark_buffer_async_write(bh);
+	bh->b_end_io = NULL;
+	set_buffer_async_write(bh);
 	set_buffer_uptodate(bh);
 	clear_buffer_dirty(bh);
 }
@@ -1566,9 +1590,12 @@
 	 * The swap code (ab-)uses ->bmap to get a block mapping and then
 	 * bypasseѕ the file system for actual I/O.  We really can't allow
 	 * that on reflinks inodes, so we have to skip out here.  And yes,
-	 * 0 is the magic code for a bmap error..
+	 * 0 is the magic code for a bmap error.
+	 *
+	 * Since we don't pass back blockdev info, we can't return bmap
+	 * information for rt files either.
 	 */
-	if (xfs_is_reflink_inode(ip)) {
+	if (xfs_is_reflink_inode(ip) || XFS_IS_REALTIME_INODE(ip)) {
 		xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 		return 0;
 	}
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index c4b90e7..5a54dcd 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -395,6 +395,7 @@
 	struct xfs_map_extent		*bmap;
 	xfs_fsblock_t			startblock_fsb;
 	xfs_fsblock_t			inode_fsb;
+	xfs_filblks_t			count;
 	bool				op_ok;
 	struct xfs_bud_log_item		*budp;
 	enum xfs_bmap_intent_type	type;
@@ -403,6 +404,7 @@
 	struct xfs_trans		*tp;
 	struct xfs_inode		*ip = NULL;
 	struct xfs_defer_ops		dfops;
+	struct xfs_bmbt_irec		irec;
 	xfs_fsblock_t			firstfsb;
 
 	ASSERT(!test_bit(XFS_BUI_RECOVERED, &buip->bui_flags));
@@ -480,13 +482,24 @@
 	}
 	xfs_trans_ijoin(tp, ip, 0);
 
+	count = bmap->me_len;
 	error = xfs_trans_log_finish_bmap_update(tp, budp, &dfops, type,
 			ip, whichfork, bmap->me_startoff,
-			bmap->me_startblock, bmap->me_len,
-			state);
+			bmap->me_startblock, &count, state);
 	if (error)
 		goto err_dfops;
 
+	if (count > 0) {
+		ASSERT(type == XFS_BMAP_UNMAP);
+		irec.br_startblock = bmap->me_startblock;
+		irec.br_blockcount = count;
+		irec.br_startoff = bmap->me_startoff;
+		irec.br_state = state;
+		error = xfs_bmap_unmap_extent(tp->t_mountp, &dfops, ip, &irec);
+		if (error)
+			goto err_dfops;
+	}
+
 	/* Finish transaction, free inodes. */
 	error = xfs_defer_finish(&tp, &dfops, NULL);
 	if (error)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 87b495e..5ffefac 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1825,29 +1825,18 @@
 	}
 
 	/*
-	 * Before we've swapped the forks, lets set the owners of the forks
-	 * appropriately. We have to do this as we are demand paging the btree
-	 * buffers, and so the validation done on read will expect the owner
-	 * field to be correctly set. Once we change the owners, we can swap the
-	 * inode forks.
+	 * Btree format (v3) inodes have the inode number stamped in the bmbt
+	 * block headers. We can't start changing the bmbt blocks until the
+	 * inode owner change is logged so recovery does the right thing in the
+	 * event of a crash. Set the owner change log flags now and leave the
+	 * bmbt scan as the last step.
 	 */
 	if (ip->i_d.di_version == 3 &&
-	    ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
+	    ip->i_d.di_format == XFS_DINODE_FMT_BTREE)
 		(*target_log_flags) |= XFS_ILOG_DOWNER;
-		error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK,
-					      tip->i_ino, NULL);
-		if (error)
-			return error;
-	}
-
 	if (tip->i_d.di_version == 3 &&
-	    tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
+	    tip->i_d.di_format == XFS_DINODE_FMT_BTREE)
 		(*src_log_flags) |= XFS_ILOG_DOWNER;
-		error = xfs_bmbt_change_owner(tp, tip, XFS_DATA_FORK,
-					      ip->i_ino, NULL);
-		if (error)
-			return error;
-	}
 
 	/*
 	 * Swap the data forks of the inodes
@@ -1925,6 +1914,48 @@
 	return 0;
 }
 
+/*
+ * Fix up the owners of the bmbt blocks to refer to the current inode. The
+ * change owner scan attempts to order all modified buffers in the current
+ * transaction. In the event of ordered buffer failure, the offending buffer is
+ * physically logged as a fallback and the scan returns -EAGAIN. We must roll
+ * the transaction in this case to replenish the fallback log reservation and
+ * restart the scan. This process repeats until the scan completes.
+ */
+static int
+xfs_swap_change_owner(
+	struct xfs_trans	**tpp,
+	struct xfs_inode	*ip,
+	struct xfs_inode	*tmpip)
+{
+	int			error;
+	struct xfs_trans	*tp = *tpp;
+
+	do {
+		error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino,
+					      NULL);
+		/* success or fatal error */
+		if (error != -EAGAIN)
+			break;
+
+		error = xfs_trans_roll(tpp, NULL);
+		if (error)
+			break;
+		tp = *tpp;
+
+		/*
+		 * Redirty both inodes so they can relog and keep the log tail
+		 * moving forward.
+		 */
+		xfs_trans_ijoin(tp, ip, 0);
+		xfs_trans_ijoin(tp, tmpip, 0);
+		xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+		xfs_trans_log_inode(tp, tmpip, XFS_ILOG_CORE);
+	} while (true);
+
+	return error;
+}
+
 int
 xfs_swap_extents(
 	struct xfs_inode	*ip,	/* target inode */
@@ -1938,8 +1969,8 @@
 	int			error = 0;
 	int			lock_flags;
 	struct xfs_ifork	*cowfp;
-	__uint64_t		f;
-	int			resblks;
+	uint64_t		f;
+	int			resblks = 0;
 
 	/*
 	 * Lock the inodes against other IO, page faults and truncate to
@@ -1987,11 +2018,8 @@
 			  XFS_SWAP_RMAP_SPACE_RES(mp,
 				XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK),
 				XFS_DATA_FORK);
-		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks,
-				0, 0, &tp);
-	} else
-		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0,
-				0, 0, &tp);
+	}
+	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
 	if (error)
 		goto out_unlock;
 
@@ -2077,6 +2105,23 @@
 	xfs_trans_log_inode(tp, tip, target_log_flags);
 
 	/*
+	 * The extent forks have been swapped, but crc=1,rmapbt=0 filesystems
+	 * have inode number owner values in the bmbt blocks that still refer to
+	 * the old inode. Scan each bmbt to fix up the owner values with the
+	 * inode number of the current inode.
+	 */
+	if (src_log_flags & XFS_ILOG_DOWNER) {
+		error = xfs_swap_change_owner(&tp, ip, tip);
+		if (error)
+			goto out_trans_cancel;
+	}
+	if (target_log_flags & XFS_ILOG_DOWNER) {
+		error = xfs_swap_change_owner(&tp, tip, ip);
+		if (error)
+			goto out_trans_cancel;
+	}
+
+	/*
 	 * If this is a synchronous mount, make sure that the
 	 * transaction goes to disk before returning to the user.
 	 */
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 1626927..eca7bae 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -116,7 +116,7 @@
 __xfs_buf_ioacct_dec(
 	struct xfs_buf	*bp)
 {
-	ASSERT(spin_is_locked(&bp->b_lock));
+	lockdep_assert_held(&bp->b_lock);
 
 	if (bp->b_state & XFS_BSTATE_IN_FLIGHT) {
 		bp->b_state &= ~XFS_BSTATE_IN_FLIGHT;
@@ -2022,6 +2022,66 @@
 	return error;
 }
 
+/*
+ * Push a single buffer on a delwri queue.
+ *
+ * The purpose of this function is to submit a single buffer of a delwri queue
+ * and return with the buffer still on the original queue. The waiting delwri
+ * buffer submission infrastructure guarantees transfer of the delwri queue
+ * buffer reference to a temporary wait list. We reuse this infrastructure to
+ * transfer the buffer back to the original queue.
+ *
+ * Note the buffer transitions from the queued state, to the submitted and wait
+ * listed state and back to the queued state during this call. The buffer
+ * locking and queue management logic between _delwri_pushbuf() and
+ * _delwri_queue() guarantee that the buffer cannot be queued to another list
+ * before returning.
+ */
+int
+xfs_buf_delwri_pushbuf(
+	struct xfs_buf		*bp,
+	struct list_head	*buffer_list)
+{
+	LIST_HEAD		(submit_list);
+	int			error;
+
+	ASSERT(bp->b_flags & _XBF_DELWRI_Q);
+
+	trace_xfs_buf_delwri_pushbuf(bp, _RET_IP_);
+
+	/*
+	 * Isolate the buffer to a new local list so we can submit it for I/O
+	 * independently from the rest of the original list.
+	 */
+	xfs_buf_lock(bp);
+	list_move(&bp->b_list, &submit_list);
+	xfs_buf_unlock(bp);
+
+	/*
+	 * Delwri submission clears the DELWRI_Q buffer flag and returns with
+	 * the buffer on the wait list with an associated reference. Rather than
+	 * bounce the buffer from a local wait list back to the original list
+	 * after I/O completion, reuse the original list as the wait list.
+	 */
+	xfs_buf_delwri_submit_buffers(&submit_list, buffer_list);
+
+	/*
+	 * The buffer is now under I/O and wait listed as during typical delwri
+	 * submission. Lock the buffer to wait for I/O completion. Rather than
+	 * remove the buffer from the wait list and release the reference, we
+	 * want to return with the buffer queued to the original list. The
+	 * buffer already sits on the original list with a wait list reference,
+	 * however. If we let the queue inherit that wait list reference, all we
+	 * need to do is reset the DELWRI_Q flag.
+	 */
+	xfs_buf_lock(bp);
+	error = bp->b_error;
+	bp->b_flags |= _XBF_DELWRI_Q;
+	xfs_buf_unlock(bp);
+
+	return error;
+}
+
 int __init
 xfs_buf_init(void)
 {
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index ad514a8..f961b19 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -333,6 +333,7 @@
 extern bool xfs_buf_delwri_queue(struct xfs_buf *, struct list_head *);
 extern int xfs_buf_delwri_submit(struct list_head *);
 extern int xfs_buf_delwri_submit_nowait(struct list_head *);
+extern int xfs_buf_delwri_pushbuf(struct xfs_buf *, struct list_head *);
 
 /* Buffer Daemon Setup Routines */
 extern int xfs_buf_init(void);
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 0306168..e0a0af0 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -29,6 +29,7 @@
 #include "xfs_error.h"
 #include "xfs_trace.h"
 #include "xfs_log.h"
+#include "xfs_inode.h"
 
 
 kmem_zone_t	*xfs_buf_item_zone;
@@ -322,6 +323,8 @@
 	ASSERT((bip->bli_flags & XFS_BLI_STALE) ||
 	       (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF
 	        && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF));
+	ASSERT(!(bip->bli_flags & XFS_BLI_ORDERED) ||
+	       (bip->bli_flags & XFS_BLI_STALE));
 
 
 	/*
@@ -346,16 +349,6 @@
 		bip->bli_flags &= ~XFS_BLI_INODE_BUF;
 	}
 
-	if ((bip->bli_flags & (XFS_BLI_ORDERED|XFS_BLI_STALE)) ==
-							XFS_BLI_ORDERED) {
-		/*
-		 * The buffer has been logged just to order it.  It is not being
-		 * included in the transaction commit, so don't format it.
-		 */
-		trace_xfs_buf_item_format_ordered(bip);
-		return;
-	}
-
 	for (i = 0; i < bip->bli_format_count; i++) {
 		xfs_buf_item_format_segment(bip, lv, &vecp, offset,
 					    &bip->bli_formats[i]);
@@ -574,26 +567,20 @@
 {
 	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
 	struct xfs_buf		*bp = bip->bli_buf;
-	bool			clean;
-	bool			aborted;
-	int			flags;
+	bool			aborted = !!(lip->li_flags & XFS_LI_ABORTED);
+	bool			hold = !!(bip->bli_flags & XFS_BLI_HOLD);
+	bool			dirty = !!(bip->bli_flags & XFS_BLI_DIRTY);
+#if defined(DEBUG) || defined(XFS_WARN)
+	bool			ordered = !!(bip->bli_flags & XFS_BLI_ORDERED);
+#endif
 
 	/* Clear the buffer's association with this transaction. */
 	bp->b_transp = NULL;
 
 	/*
-	 * If this is a transaction abort, don't return early.  Instead, allow
-	 * the brelse to happen.  Normally it would be done for stale
-	 * (cancelled) buffers at unpin time, but we'll never go through the
-	 * pin/unpin cycle if we abort inside commit.
+	 * The per-transaction state has been copied above so clear it from the
+	 * bli.
 	 */
-	aborted = (lip->li_flags & XFS_LI_ABORTED) ? true : false;
-	/*
-	 * Before possibly freeing the buf item, copy the per-transaction state
-	 * so we can reference it safely later after clearing it from the
-	 * buffer log item.
-	 */
-	flags = bip->bli_flags;
 	bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD | XFS_BLI_ORDERED);
 
 	/*
@@ -601,7 +588,7 @@
 	 * unlock the buffer and free the buf item when the buffer is unpinned
 	 * for the last time.
 	 */
-	if (flags & XFS_BLI_STALE) {
+	if (bip->bli_flags & XFS_BLI_STALE) {
 		trace_xfs_buf_item_unlock_stale(bip);
 		ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
 		if (!aborted) {
@@ -619,40 +606,34 @@
 	 * regardless of whether it is dirty or not. A dirty abort implies a
 	 * shutdown, anyway.
 	 *
-	 * Ordered buffers are dirty but may have no recorded changes, so ensure
-	 * we only release clean items here.
+	 * The bli dirty state should match whether the blf has logged segments
+	 * except for ordered buffers, where only the bli should be dirty.
 	 */
-	clean = (flags & XFS_BLI_DIRTY) ? false : true;
-	if (clean) {
-		int i;
-		for (i = 0; i < bip->bli_format_count; i++) {
-			if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map,
-				     bip->bli_formats[i].blf_map_size)) {
-				clean = false;
-				break;
-			}
-		}
-	}
+	ASSERT((!ordered && dirty == xfs_buf_item_dirty_format(bip)) ||
+	       (ordered && dirty && !xfs_buf_item_dirty_format(bip)));
 
 	/*
 	 * Clean buffers, by definition, cannot be in the AIL. However, aborted
-	 * buffers may be dirty and hence in the AIL. Therefore if we are
-	 * aborting a buffer and we've just taken the last refernce away, we
-	 * have to check if it is in the AIL before freeing it. We need to free
-	 * it in this case, because an aborted transaction has already shut the
-	 * filesystem down and this is the last chance we will have to do so.
+	 * buffers may be in the AIL regardless of dirty state. An aborted
+	 * transaction that invalidates a buffer already in the AIL may have
+	 * marked it stale and cleared the dirty state, for example.
+	 *
+	 * Therefore if we are aborting a buffer and we've just taken the last
+	 * reference away, we have to check if it is in the AIL before freeing
+	 * it. We need to free it in this case, because an aborted transaction
+	 * has already shut the filesystem down and this is the last chance we
+	 * will have to do so.
 	 */
 	if (atomic_dec_and_test(&bip->bli_refcount)) {
-		if (clean)
-			xfs_buf_item_relse(bp);
-		else if (aborted) {
+		if (aborted) {
 			ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp));
 			xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR);
 			xfs_buf_item_relse(bp);
-		}
+		} else if (!dirty)
+			xfs_buf_item_relse(bp);
 	}
 
-	if (!(flags & XFS_BLI_HOLD))
+	if (!hold)
 		xfs_buf_relse(bp);
 }
 
@@ -942,14 +923,22 @@
 
 
 /*
- * Return 1 if the buffer has been logged or ordered in a transaction (at any
- * point, not just the current transaction) and 0 if not.
+ * Return true if the buffer has any ranges logged/dirtied by a transaction,
+ * false otherwise.
  */
-uint
-xfs_buf_item_dirty(
-	xfs_buf_log_item_t	*bip)
+bool
+xfs_buf_item_dirty_format(
+	struct xfs_buf_log_item	*bip)
 {
-	return (bip->bli_flags & XFS_BLI_DIRTY);
+	int			i;
+
+	for (i = 0; i < bip->bli_format_count; i++) {
+		if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map,
+			     bip->bli_formats[i].blf_map_size))
+			return true;
+	}
+
+	return false;
 }
 
 STATIC void
@@ -1051,6 +1040,31 @@
 	}
 }
 
+/*
+ * Invoke the error state callback for each log item affected by the failed I/O.
+ *
+ * If a metadata buffer write fails with a non-permanent error, the buffer is
+ * eventually resubmitted and so the completion callbacks are not run. The error
+ * state may need to be propagated to the log items attached to the buffer,
+ * however, so the next AIL push of the item knows hot to handle it correctly.
+ */
+STATIC void
+xfs_buf_do_callbacks_fail(
+	struct xfs_buf		*bp)
+{
+	struct xfs_log_item	*next;
+	struct xfs_log_item	*lip = bp->b_fspriv;
+	struct xfs_ail		*ailp = lip->li_ailp;
+
+	spin_lock(&ailp->xa_lock);
+	for (; lip; lip = next) {
+		next = lip->li_bio_list;
+		if (lip->li_ops->iop_error)
+			lip->li_ops->iop_error(lip, bp);
+	}
+	spin_unlock(&ailp->xa_lock);
+}
+
 static bool
 xfs_buf_iodone_callback_error(
 	struct xfs_buf		*bp)
@@ -1120,7 +1134,11 @@
 	if ((mp->m_flags & XFS_MOUNT_UNMOUNTING) && mp->m_fail_unmount)
 		goto permanent_error;
 
-	/* still a transient error, higher layers will retry */
+	/*
+	 * Still a transient error, run IO completion failure callbacks and let
+	 * the higher layers retry the buffer.
+	 */
+	xfs_buf_do_callbacks_fail(bp);
 	xfs_buf_ioerror(bp, 0);
 	xfs_buf_relse(bp);
 	return true;
@@ -1201,3 +1219,31 @@
 	xfs_trans_ail_delete(ailp, lip, SHUTDOWN_CORRUPT_INCORE);
 	xfs_buf_item_free(BUF_ITEM(lip));
 }
+
+/*
+ * Requeue a failed buffer for writeback
+ *
+ * Return true if the buffer has been re-queued properly, false otherwise
+ */
+bool
+xfs_buf_resubmit_failed_buffers(
+	struct xfs_buf		*bp,
+	struct xfs_log_item	*lip,
+	struct list_head	*buffer_list)
+{
+	struct xfs_log_item	*next;
+
+	/*
+	 * Clear XFS_LI_FAILED flag from all items before resubmit
+	 *
+	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
+	 * function already have it acquired
+	 */
+	for (; lip; lip = next) {
+		next = lip->li_bio_list;
+		xfs_clear_li_failed(lip);
+	}
+
+	/* Add this buffer back to the delayed write list */
+	return xfs_buf_delwri_queue(bp, buffer_list);
+}
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index f7eba99..9690ce6 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -64,12 +64,15 @@
 int	xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
 void	xfs_buf_item_relse(struct xfs_buf *);
 void	xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
-uint	xfs_buf_item_dirty(xfs_buf_log_item_t *);
+bool	xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
 void	xfs_buf_attach_iodone(struct xfs_buf *,
 			      void(*)(struct xfs_buf *, xfs_log_item_t *),
 			      xfs_log_item_t *);
 void	xfs_buf_iodone_callbacks(struct xfs_buf *);
 void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
+bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
+					struct xfs_log_item *,
+					struct list_head *);
 
 extern kmem_zone_t	*xfs_buf_item_zone;
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index df206cf..586b398 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -729,6 +729,7 @@
 		xfs_rw_iunlock(ip, iolock);
 		eofb.eof_flags = XFS_EOF_FLAGS_SYNC;
 		xfs_icache_free_eofblocks(ip->i_mount, &eofb);
+		xfs_icache_free_cowblocks(ip->i_mount, &eofb);
 		goto write_retry;
 	}
 
@@ -1139,29 +1140,8 @@
 		want = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1;
 		nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index,
 					  want);
-		/*
-		 * No page mapped into given range.  If we are searching holes
-		 * and if this is the first time we got into the loop, it means
-		 * that the given offset is landed in a hole, return it.
-		 *
-		 * If we have already stepped through some block buffers to find
-		 * holes but they all contains data.  In this case, the last
-		 * offset is already updated and pointed to the end of the last
-		 * mapped page, if it does not reach the endpoint to search,
-		 * that means there should be a hole between them.
-		 */
-		if (nr_pages == 0) {
-			/* Data search found nothing */
-			if (type == DATA_OFF)
-				break;
-
-			ASSERT(type == HOLE_OFF);
-			if (lastoff == startoff || lastoff < endoff) {
-				found = true;
-				*offset = lastoff;
-			}
+		if (nr_pages == 0)
 			break;
-		}
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page	*page = pvec.pages[i];
@@ -1227,21 +1207,20 @@
 
 		/*
 		 * The number of returned pages less than our desired, search
-		 * done.  In this case, nothing was found for searching data,
-		 * but we found a hole behind the last offset.
+		 * done.
 		 */
-		if (nr_pages < want) {
-			if (type == HOLE_OFF) {
-				*offset = lastoff;
-				found = true;
-			}
+		if (nr_pages < want)
 			break;
-		}
 
 		index = pvec.pages[i - 1]->index + 1;
 		pagevec_release(&pvec);
 	} while (index <= end);
 
+	/* No page at lastoff and we are not done - we found a hole. */
+	if (type == HOLE_OFF && lastoff < endoff) {
+		*offset = lastoff;
+		found = true;
+	}
 out:
 	pagevec_release(&pvec);
 	return found;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 74304b6..86a4911 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -66,7 +66,6 @@
 
 	XFS_STATS_INC(mp, vn_active);
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
-	ASSERT(!spin_is_locked(&ip->i_flags_lock));
 	ASSERT(!xfs_isiflocked(ip));
 	ASSERT(ip->i_ino == 0);
 
@@ -192,7 +191,7 @@
 {
 	struct xfs_mount	*mp = pag->pag_mount;
 
-	ASSERT(spin_is_locked(&pag->pag_ici_lock));
+	lockdep_assert_held(&pag->pag_ici_lock);
 	if (pag->pag_ici_reclaimable++)
 		return;
 
@@ -214,7 +213,7 @@
 {
 	struct xfs_mount	*mp = pag->pag_mount;
 
-	ASSERT(spin_is_locked(&pag->pag_ici_lock));
+	lockdep_assert_held(&pag->pag_ici_lock);
 	if (--pag->pag_ici_reclaimable)
 		return;
 
@@ -1079,11 +1078,11 @@
 	 * Because we use RCU freeing we need to ensure the inode always appears
 	 * to be reclaimed with an invalid inode number when in the free state.
 	 * We do this as early as possible under the ILOCK so that
-	 * xfs_iflush_cluster() can be guaranteed to detect races with us here.
-	 * By doing this, we guarantee that once xfs_iflush_cluster has locked
-	 * XFS_ILOCK that it will see either a valid, flushable inode that will
-	 * serialise correctly, or it will see a clean (and invalid) inode that
-	 * it can skip.
+	 * xfs_iflush_cluster() and xfs_ifree_cluster() can be guaranteed to
+	 * detect races with us here. By doing this, we guarantee that once
+	 * xfs_iflush_cluster() or xfs_ifree_cluster() has locked XFS_ILOCK that
+	 * it will see either a valid inode that will serialise correctly, or it
+	 * will see an invalid inode that it can skip.
 	 */
 	spin_lock(&ip->i_flags_lock);
 	ip->i_flags = XFS_IRECLAIM;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 7a0b4ee..9e795ab 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -881,7 +881,6 @@
 	case S_IFREG:
 	case S_IFDIR:
 		if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
-			uint64_t	di_flags2 = 0;
 			uint		di_flags = 0;
 
 			if (S_ISDIR(mode)) {
@@ -918,20 +917,23 @@
 				di_flags |= XFS_DIFLAG_NODEFRAG;
 			if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
 				di_flags |= XFS_DIFLAG_FILESTREAM;
-			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
-				di_flags2 |= XFS_DIFLAG2_DAX;
 
 			ip->i_d.di_flags |= di_flags;
-			ip->i_d.di_flags2 |= di_flags2;
 		}
 		if (pip &&
 		    (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY) &&
 		    pip->i_d.di_version == 3 &&
 		    ip->i_d.di_version == 3) {
+			uint64_t	di_flags2 = 0;
+
 			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
-				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
+				di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
 				ip->i_d.di_cowextsize = pip->i_d.di_cowextsize;
 			}
+			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
+				di_flags2 |= XFS_DIFLAG2_DAX;
+
+			ip->i_d.di_flags2 |= di_flags2;
 		}
 		/* FALLTHROUGH */
 	case S_IFLNK:
@@ -2366,11 +2368,24 @@
 			 * already marked stale. If we can't lock it, back off
 			 * and retry.
 			 */
-			if (ip != free_ip &&
-			    !xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
-				rcu_read_unlock();
-				delay(1);
-				goto retry;
+			if (ip != free_ip) {
+				if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
+					rcu_read_unlock();
+					delay(1);
+					goto retry;
+				}
+
+				/*
+				 * Check the inode number again in case we're
+				 * racing with freeing in xfs_reclaim_inode().
+				 * See the comments in that function for more
+				 * information as to why the initial check is
+				 * not sufficient.
+				 */
+				if (ip->i_ino != inum + i) {
+					xfs_iunlock(ip, XFS_ILOCK_EXCL);
+					continue;
+				}
 			}
 			rcu_read_unlock();
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index d90e781..9491574 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -27,6 +27,7 @@
 #include "xfs_error.h"
 #include "xfs_trace.h"
 #include "xfs_trans_priv.h"
+#include "xfs_buf_item.h"
 #include "xfs_log.h"
 
 
@@ -475,6 +476,23 @@
 		wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
 }
 
+/*
+ * Callback used to mark a buffer with XFS_LI_FAILED when items in the buffer
+ * have been failed during writeback
+ *
+ * This informs the AIL that the inode is already flush locked on the next push,
+ * and acquires a hold on the buffer to ensure that it isn't reclaimed before
+ * dirty data makes it to disk.
+ */
+STATIC void
+xfs_inode_item_error(
+	struct xfs_log_item	*lip,
+	struct xfs_buf		*bp)
+{
+	ASSERT(xfs_isiflocked(INODE_ITEM(lip)->ili_inode));
+	xfs_set_li_failed(lip, bp);
+}
+
 STATIC uint
 xfs_inode_item_push(
 	struct xfs_log_item	*lip,
@@ -484,13 +502,28 @@
 {
 	struct xfs_inode_log_item *iip = INODE_ITEM(lip);
 	struct xfs_inode	*ip = iip->ili_inode;
-	struct xfs_buf		*bp = NULL;
+	struct xfs_buf		*bp = lip->li_buf;
 	uint			rval = XFS_ITEM_SUCCESS;
 	int			error;
 
 	if (xfs_ipincount(ip) > 0)
 		return XFS_ITEM_PINNED;
 
+	/*
+	 * The buffer containing this item failed to be written back
+	 * previously. Resubmit the buffer for IO.
+	 */
+	if (lip->li_flags & XFS_LI_FAILED) {
+		if (!xfs_buf_trylock(bp))
+			return XFS_ITEM_LOCKED;
+
+		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
+			rval = XFS_ITEM_FLUSHING;
+
+		xfs_buf_unlock(bp);
+		return rval;
+	}
+
 	if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
 		return XFS_ITEM_LOCKED;
 
@@ -622,7 +655,8 @@
 	.iop_unlock	= xfs_inode_item_unlock,
 	.iop_committed	= xfs_inode_item_committed,
 	.iop_push	= xfs_inode_item_push,
-	.iop_committing = xfs_inode_item_committing
+	.iop_committing = xfs_inode_item_committing,
+	.iop_error	= xfs_inode_item_error
 };
 
 
@@ -710,7 +744,8 @@
 		 * the AIL lock.
 		 */
 		iip = INODE_ITEM(blip);
-		if (iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn)
+		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
+		    lip->li_flags & XFS_LI_FAILED)
 			need_ail++;
 
 		blip = next;
@@ -718,7 +753,8 @@
 
 	/* make sure we capture the state of the initial inode. */
 	iip = INODE_ITEM(lip);
-	if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn)
+	if ((iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn) ||
+	    lip->li_flags & XFS_LI_FAILED)
 		need_ail++;
 
 	/*
@@ -731,22 +767,30 @@
 	 * holding the lock before removing the inode from the AIL.
 	 */
 	if (need_ail) {
-		struct xfs_log_item *log_items[need_ail];
-		int i = 0;
+		bool			mlip_changed = false;
+
+		/* this is an opencoded batch version of xfs_trans_ail_delete */
 		spin_lock(&ailp->xa_lock);
 		for (blip = lip; blip; blip = blip->li_bio_list) {
-			iip = INODE_ITEM(blip);
-			if (iip->ili_logged &&
-			    blip->li_lsn == iip->ili_flush_lsn) {
-				log_items[i++] = blip;
+			if (INODE_ITEM(blip)->ili_logged &&
+			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
+				mlip_changed |= xfs_ail_delete_one(ailp, blip);
+			else {
+				xfs_clear_li_failed(blip);
 			}
-			ASSERT(i <= need_ail);
 		}
-		/* xfs_trans_ail_delete_bulk() drops the AIL lock. */
-		xfs_trans_ail_delete_bulk(ailp, log_items, i,
-					  SHUTDOWN_CORRUPT_INCORE);
-	}
 
+		if (mlip_changed) {
+			if (!XFS_FORCED_SHUTDOWN(ailp->xa_mount))
+				xlog_assign_tail_lsn_locked(ailp->xa_mount);
+			if (list_empty(&ailp->xa_ail))
+				wake_up_all(&ailp->xa_empty);
+		}
+		spin_unlock(&ailp->xa_lock);
+
+		if (mlip_changed)
+			xfs_log_space_wake(ailp->xa_mount);
+	}
 
 	/*
 	 * clean up and unlock the flush lock now we are done. We can clear the
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 73cfc71..bce2e26 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -928,16 +928,15 @@
 	return 0;
 }
 
-STATIC void
-xfs_set_diflags(
+STATIC uint16_t
+xfs_flags2diflags(
 	struct xfs_inode	*ip,
 	unsigned int		xflags)
 {
-	unsigned int		di_flags;
-	uint64_t		di_flags2;
-
 	/* can't set PREALLOC this way, just preserve it */
-	di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
+	uint16_t		di_flags =
+		(ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
+
 	if (xflags & FS_XFLAG_IMMUTABLE)
 		di_flags |= XFS_DIFLAG_IMMUTABLE;
 	if (xflags & FS_XFLAG_APPEND)
@@ -967,19 +966,24 @@
 		if (xflags & FS_XFLAG_EXTSIZE)
 			di_flags |= XFS_DIFLAG_EXTSIZE;
 	}
-	ip->i_d.di_flags = di_flags;
 
-	/* diflags2 only valid for v3 inodes. */
-	if (ip->i_d.di_version < 3)
-		return;
+	return di_flags;
+}
 
-	di_flags2 = (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
+STATIC uint64_t
+xfs_flags2diflags2(
+	struct xfs_inode	*ip,
+	unsigned int		xflags)
+{
+	uint64_t		di_flags2 =
+		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
+
 	if (xflags & FS_XFLAG_DAX)
 		di_flags2 |= XFS_DIFLAG2_DAX;
 	if (xflags & FS_XFLAG_COWEXTSIZE)
 		di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
 
-	ip->i_d.di_flags2 = di_flags2;
+	return di_flags2;
 }
 
 STATIC void
@@ -1005,11 +1009,12 @@
 		inode->i_flags |= S_NOATIME;
 	else
 		inode->i_flags &= ~S_NOATIME;
+#if 0	/* disabled until the flag switching races are sorted out */
 	if (xflags & FS_XFLAG_DAX)
 		inode->i_flags |= S_DAX;
 	else
 		inode->i_flags &= ~S_DAX;
-
+#endif
 }
 
 static int
@@ -1019,6 +1024,7 @@
 	struct fsxattr		*fa)
 {
 	struct xfs_mount	*mp = ip->i_mount;
+	uint64_t		di_flags2;
 
 	/* Can't change realtime flag if any extents are allocated. */
 	if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
@@ -1049,7 +1055,14 @@
 	    !capable(CAP_LINUX_IMMUTABLE))
 		return -EPERM;
 
-	xfs_set_diflags(ip, fa->fsx_xflags);
+	/* diflags2 only valid for v3 inodes. */
+	di_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
+	if (di_flags2 && ip->i_d.di_version < 3)
+		return -EINVAL;
+
+	ip->i_d.di_flags = xfs_flags2diflags(ip, fa->fsx_xflags);
+	ip->i_d.di_flags2 = di_flags2;
+
 	xfs_diflags_to_linux(ip);
 	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index a1247c3..5b81f7f 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -802,7 +802,7 @@
  * Caution: The caller of this function is responsible for calling
  * setattr_prepare() or otherwise verifying the change is fine.
  */
-int
+STATIC int
 xfs_setattr_size(
 	struct xfs_inode	*ip,
 	struct iattr		*iattr)
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 1455b2520..3ebed16 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -363,7 +363,14 @@
 #endif /* DEBUG */
 
 #ifdef CONFIG_XFS_RT
-#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
+
+/*
+ * make sure we ignore the inode flag if the filesystem doesn't have a
+ * configured realtime device.
+ */
+#define XFS_IS_REALTIME_INODE(ip)			\
+	(((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) &&	\
+	 (ip)->i_mount->m_rtdev_targp)
 #else
 #define XFS_IS_REALTIME_INODE(ip) (0)
 #endif
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index b57ab34..33c9a3a 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -743,15 +743,45 @@
 	struct xfs_mount	*mp)
 {
 	int	error = 0;
+	bool	readonly = (mp->m_flags & XFS_MOUNT_RDONLY);
 
 	if (mp->m_flags & XFS_MOUNT_NORECOVERY) {
 		ASSERT(mp->m_flags & XFS_MOUNT_RDONLY);
 		return 0;
+	} else if (readonly) {
+		/* Allow unlinked processing to proceed */
+		mp->m_flags &= ~XFS_MOUNT_RDONLY;
 	}
 
+	/*
+	 * During the second phase of log recovery, we need iget and
+	 * iput to behave like they do for an active filesystem.
+	 * xfs_fs_drop_inode needs to be able to prevent the deletion
+	 * of inodes before we're done replaying log items on those
+	 * inodes.  Turn it off immediately after recovery finishes
+	 * so that we don't leak the quota inodes if subsequent mount
+	 * activities fail.
+	 *
+	 * We let all inodes involved in redo item processing end up on
+	 * the LRU instead of being evicted immediately so that if we do
+	 * something to an unlinked inode, the irele won't cause
+	 * premature truncation and freeing of the inode, which results
+	 * in log recovery failure.  We have to evict the unreferenced
+	 * lru inodes after clearing MS_ACTIVE because we don't
+	 * otherwise clean up the lru if there's a subsequent failure in
+	 * xfs_mountfs, which leads to us leaking the inodes if nothing
+	 * else (e.g. quotacheck) references the inodes before the
+	 * mount failure occurs.
+	 */
+	mp->m_super->s_flags |= MS_ACTIVE;
 	error = xlog_recover_finish(mp->m_log);
 	if (!error)
 		xfs_log_work_queue(mp);
+	mp->m_super->s_flags &= ~MS_ACTIVE;
+	evict_inodes(mp->m_super);
+
+	if (readonly)
+		mp->m_flags |= XFS_MOUNT_RDONLY;
 
 	return error;
 }
@@ -801,11 +831,14 @@
 	int		 error;
 
 	/*
-	 * Don't write out unmount record on read-only mounts.
+	 * Don't write out unmount record on norecovery mounts or ro devices.
 	 * Or, if we are doing a forced umount (typically because of IO errors).
 	 */
-	if (mp->m_flags & XFS_MOUNT_RDONLY)
+	if (mp->m_flags & XFS_MOUNT_NORECOVERY ||
+	    xfs_readonly_buftarg(log->l_mp->m_logdev_targp)) {
+		ASSERT(mp->m_flags & XFS_MOUNT_RDONLY);
 		return 0;
+	}
 
 	error = _xfs_log_force(mp, XFS_LOG_SYNC, NULL);
 	ASSERT(error || !(XLOG_FORCED_SHUTDOWN(log)));
@@ -3304,8 +3337,6 @@
 		 */
 		if (iclog->ic_state & XLOG_STATE_IOERROR)
 			return -EIO;
-		if (log_flushed)
-			*log_flushed = 1;
 	} else {
 
 no_sleep:
@@ -3409,8 +3440,6 @@
 
 				xlog_wait(&iclog->ic_prev->ic_write_wait,
 							&log->l_icloglock);
-				if (log_flushed)
-					*log_flushed = 1;
 				already_slept = 1;
 				goto try_again;
 			}
@@ -3444,9 +3473,6 @@
 			 */
 			if (iclog->ic_state & XLOG_STATE_IOERROR)
 				return -EIO;
-
-			if (log_flushed)
-				*log_flushed = 1;
 		} else {		/* just return */
 			spin_unlock(&log->l_icloglock);
 		}
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9b3d7c7..0590926 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1029,61 +1029,106 @@
 }
 
 /*
- * Check the log tail for torn writes. This is required when torn writes are
- * detected at the head and the head had to be walked back to a previous record.
- * The tail of the previous record must now be verified to ensure the torn
- * writes didn't corrupt the previous tail.
+ * Calculate distance from head to tail (i.e., unused space in the log).
+ */
+static inline int
+xlog_tail_distance(
+	struct xlog	*log,
+	xfs_daddr_t	head_blk,
+	xfs_daddr_t	tail_blk)
+{
+	if (head_blk < tail_blk)
+		return tail_blk - head_blk;
+
+	return tail_blk + (log->l_logBBsize - head_blk);
+}
+
+/*
+ * Verify the log tail. This is particularly important when torn or incomplete
+ * writes have been detected near the front of the log and the head has been
+ * walked back accordingly.
  *
- * Return an error if CRC verification fails as recovery cannot proceed.
+ * We also have to handle the case where the tail was pinned and the head
+ * blocked behind the tail right before a crash. If the tail had been pushed
+ * immediately prior to the crash and the subsequent checkpoint was only
+ * partially written, it's possible it overwrote the last referenced tail in the
+ * log with garbage. This is not a coherency problem because the tail must have
+ * been pushed before it can be overwritten, but appears as log corruption to
+ * recovery because we have no way to know the tail was updated if the
+ * subsequent checkpoint didn't write successfully.
+ *
+ * Therefore, CRC check the log from tail to head. If a failure occurs and the
+ * offending record is within max iclog bufs from the head, walk the tail
+ * forward and retry until a valid tail is found or corruption is detected out
+ * of the range of a possible overwrite.
  */
 STATIC int
 xlog_verify_tail(
 	struct xlog		*log,
 	xfs_daddr_t		head_blk,
-	xfs_daddr_t		tail_blk)
+	xfs_daddr_t		*tail_blk,
+	int			hsize)
 {
 	struct xlog_rec_header	*thead;
 	struct xfs_buf		*bp;
 	xfs_daddr_t		first_bad;
-	int			count;
 	int			error = 0;
 	bool			wrapped;
-	xfs_daddr_t		tmp_head;
+	xfs_daddr_t		tmp_tail;
+	xfs_daddr_t		orig_tail = *tail_blk;
 
 	bp = xlog_get_bp(log, 1);
 	if (!bp)
 		return -ENOMEM;
 
 	/*
-	 * Seek XLOG_MAX_ICLOGS + 1 records past the current tail record to get
-	 * a temporary head block that points after the last possible
-	 * concurrently written record of the tail.
+	 * Make sure the tail points to a record (returns positive count on
+	 * success).
 	 */
-	count = xlog_seek_logrec_hdr(log, head_blk, tail_blk,
-				     XLOG_MAX_ICLOGS + 1, bp, &tmp_head, &thead,
-				     &wrapped);
-	if (count < 0) {
-		error = count;
+	error = xlog_seek_logrec_hdr(log, head_blk, *tail_blk, 1, bp,
+			&tmp_tail, &thead, &wrapped);
+	if (error < 0)
 		goto out;
+	if (*tail_blk != tmp_tail)
+		*tail_blk = tmp_tail;
+
+	/*
+	 * Run a CRC check from the tail to the head. We can't just check
+	 * MAX_ICLOGS records past the tail because the tail may point to stale
+	 * blocks cleared during the search for the head/tail. These blocks are
+	 * overwritten with zero-length records and thus record count is not a
+	 * reliable indicator of the iclog state before a crash.
+	 */
+	first_bad = 0;
+	error = xlog_do_recovery_pass(log, head_blk, *tail_blk,
+				      XLOG_RECOVER_CRCPASS, &first_bad);
+	while ((error == -EFSBADCRC || error == -EFSCORRUPTED) && first_bad) {
+		int	tail_distance;
+
+		/*
+		 * Is corruption within range of the head? If so, retry from
+		 * the next record. Otherwise return an error.
+		 */
+		tail_distance = xlog_tail_distance(log, head_blk, first_bad);
+		if (tail_distance > BTOBB(XLOG_MAX_ICLOGS * hsize))
+			break;
+
+		/* skip to the next record; returns positive count on success */
+		error = xlog_seek_logrec_hdr(log, head_blk, first_bad, 2, bp,
+				&tmp_tail, &thead, &wrapped);
+		if (error < 0)
+			goto out;
+
+		*tail_blk = tmp_tail;
+		first_bad = 0;
+		error = xlog_do_recovery_pass(log, head_blk, *tail_blk,
+					      XLOG_RECOVER_CRCPASS, &first_bad);
 	}
 
-	/*
-	 * If the call above didn't find XLOG_MAX_ICLOGS + 1 records, we ran
-	 * into the actual log head. tmp_head points to the start of the record
-	 * so update it to the actual head block.
-	 */
-	if (count < XLOG_MAX_ICLOGS + 1)
-		tmp_head = head_blk;
-
-	/*
-	 * We now have a tail and temporary head block that covers at least
-	 * XLOG_MAX_ICLOGS records from the tail. We need to verify that these
-	 * records were completely written. Run a CRC verification pass from
-	 * tail to head and return the result.
-	 */
-	error = xlog_do_recovery_pass(log, tmp_head, tail_blk,
-				      XLOG_RECOVER_CRCPASS, &first_bad);
-
+	if (!error && *tail_blk != orig_tail)
+		xfs_warn(log->l_mp,
+		"Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
+			 orig_tail, *tail_blk);
 out:
 	xlog_put_bp(bp);
 	return error;
@@ -1143,7 +1188,7 @@
 	 */
 	error = xlog_do_recovery_pass(log, *head_blk, tmp_rhead_blk,
 				      XLOG_RECOVER_CRCPASS, &first_bad);
-	if (error == -EFSBADCRC) {
+	if ((error == -EFSBADCRC || error == -EFSCORRUPTED) && first_bad) {
 		/*
 		 * We've hit a potential torn write. Reset the error and warn
 		 * about it.
@@ -1183,31 +1228,12 @@
 			ASSERT(0);
 			return 0;
 		}
-
-		/*
-		 * Now verify the tail based on the updated head. This is
-		 * required because the torn writes trimmed from the head could
-		 * have been written over the tail of a previous record. Return
-		 * any errors since recovery cannot proceed if the tail is
-		 * corrupt.
-		 *
-		 * XXX: This leaves a gap in truly robust protection from torn
-		 * writes in the log. If the head is behind the tail, the tail
-		 * pushes forward to create some space and then a crash occurs
-		 * causing the writes into the previous record's tail region to
-		 * tear, log recovery isn't able to recover.
-		 *
-		 * How likely is this to occur? If possible, can we do something
-		 * more intelligent here? Is it safe to push the tail forward if
-		 * we can determine that the tail is within the range of the
-		 * torn write (e.g., the kernel can only overwrite the tail if
-		 * it has actually been pushed forward)? Alternatively, could we
-		 * somehow prevent this condition at runtime?
-		 */
-		error = xlog_verify_tail(log, *head_blk, *tail_blk);
 	}
+	if (error)
+		return error;
 
-	return error;
+	return xlog_verify_tail(log, *head_blk, tail_blk,
+				be32_to_cpu((*rhead)->h_size));
 }
 
 /*
@@ -4152,7 +4178,7 @@
 
 	#define XLOG_RECOVER_COMMIT_QUEUE_MAX 100
 
-	hlist_del(&trans->r_list);
+	hlist_del_init(&trans->r_list);
 
 	error = xlog_recover_reorder_trans(log, trans, pass);
 	if (error)
@@ -4354,6 +4380,8 @@
 	xlog_recover_item_t	*item, *n;
 	int			i;
 
+	hlist_del_init(&trans->r_list);
+
 	list_for_each_entry_safe(item, n, &trans->r_itemq, ri_list) {
 		/* Free the regions in the item. */
 		list_del(&item->ri_list);
@@ -4799,12 +4827,16 @@
 	int			error = 0;
 	struct xfs_ail_cursor	cur;
 	struct xfs_ail		*ailp;
+#if defined(DEBUG) || defined(XFS_WARN)
 	xfs_lsn_t		last_lsn;
+#endif
 
 	ailp = log->l_ailp;
 	spin_lock(&ailp->xa_lock);
 	lip = xfs_trans_ail_cursor_first(ailp, &cur, 0);
+#if defined(DEBUG) || defined(XFS_WARN)
 	last_lsn = xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block);
+#endif
 	while (lip != NULL) {
 		/*
 		 * We're done when we see something other than an intent.
@@ -5214,7 +5246,7 @@
 	xfs_daddr_t		*first_bad)	/* out: first bad log rec */
 {
 	xlog_rec_header_t	*rhead;
-	xfs_daddr_t		blk_no;
+	xfs_daddr_t		blk_no, rblk_no;
 	xfs_daddr_t		rhead_blk;
 	char			*offset;
 	xfs_buf_t		*hbp, *dbp;
@@ -5222,11 +5254,15 @@
 	int			error2 = 0;
 	int			bblks, split_bblks;
 	int			hblks, split_hblks, wrapped_hblks;
+	int			i;
 	struct hlist_head	rhash[XLOG_RHASH_SIZE];
 	LIST_HEAD		(buffer_list);
 
 	ASSERT(head_blk != tail_blk);
-	rhead_blk = 0;
+	blk_no = rhead_blk = tail_blk;
+
+	for (i = 0; i < XLOG_RHASH_SIZE; i++)
+		INIT_HLIST_HEAD(&rhash[i]);
 
 	/*
 	 * Read the header of the tail block and get the iclog buffer size from
@@ -5301,7 +5337,6 @@
 	}
 
 	memset(rhash, 0, sizeof(rhash));
-	blk_no = rhead_blk = tail_blk;
 	if (tail_blk > head_blk) {
 		/*
 		 * Perform recovery around the end of the physical log.
@@ -5363,9 +5398,19 @@
 			bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
 			blk_no += hblks;
 
-			/* Read in data for log record */
-			if (blk_no + bblks <= log->l_logBBsize) {
-				error = xlog_bread(log, blk_no, bblks, dbp,
+			/*
+			 * Read the log record data in multiple reads if it
+			 * wraps around the end of the log. Note that if the
+			 * header already wrapped, blk_no could point past the
+			 * end of the log. The record data is contiguous in
+			 * that case.
+			 */
+			if (blk_no + bblks <= log->l_logBBsize ||
+			    blk_no >= log->l_logBBsize) {
+				/* mod blk_no in case the header wrapped and
+				 * pushed it beyond the end of the log */
+				rblk_no = do_mod(blk_no, log->l_logBBsize);
+				error = xlog_bread(log, rblk_no, bblks, dbp,
 						   &offset);
 				if (error)
 					goto bread_err2;
@@ -5464,6 +5509,19 @@
 	if (error && first_bad)
 		*first_bad = rhead_blk;
 
+	/*
+	 * Transactions are freed at commit time but transactions without commit
+	 * records on disk are never committed. Free any that may be left in the
+	 * hash table.
+	 */
+	for (i = 0; i < XLOG_RHASH_SIZE; i++) {
+		struct hlist_node	*tmp;
+		struct xlog_recover	*trans;
+
+		hlist_for_each_entry_safe(trans, tmp, &rhash[i], r_list)
+			xlog_recover_free_trans(trans);
+	}
+
 	return error ? error : error2;
 }
 
@@ -5542,6 +5600,8 @@
 	xfs_buf_t	*bp;
 	xfs_sb_t	*sbp;
 
+	trace_xfs_log_recover(log, head_blk, tail_blk);
+
 	/*
 	 * First replay the images in the log.
 	 */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 13796f2..d4ce8d2 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -925,15 +925,6 @@
 	}
 
 	/*
-	 * During the second phase of log recovery, we need iget and
-	 * iput to behave like they do for an active filesystem.
-	 * xfs_fs_drop_inode needs to be able to prevent the deletion
-	 * of inodes before we're done replaying log items on those
-	 * inodes.
-	 */
-	mp->m_super->s_flags |= MS_ACTIVE;
-
-	/*
 	 * Finish recovering the file system.  This part needed to be delayed
 	 * until after the root and real-time bitmap inodes were consistently
 	 * read in.
@@ -1008,12 +999,13 @@
  out_quota:
 	xfs_qm_unmount_quotas(mp);
  out_rtunmount:
-	mp->m_super->s_flags &= ~MS_ACTIVE;
 	xfs_rtunmount_inodes(mp);
  out_rele_rip:
 	IRELE(rip);
 	cancel_delayed_work_sync(&mp->m_reclaim_work);
 	xfs_reclaim_inodes(mp, SYNC_WAIT);
+	/* Clean out dquots that might be in memory after quotacheck. */
+	xfs_qm_unmount(mp);
  out_log_dealloc:
 	mp->m_flags |= XFS_MOUNT_UNMOUNTING;
 	xfs_log_mount_cancel(mp);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 8b9a9f1..1fdd3fa 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -111,6 +111,9 @@
 			skipped = 0;
 			break;
 		}
+		/* we're done if id overflows back to zero */
+		if (!next_index)
+			break;
 	}
 
 	if (skipped) {
@@ -1247,6 +1250,7 @@
 	struct xfs_dquot	*dqp,
 	void			*data)
 {
+	struct xfs_mount	*mp = dqp->q_mount;
 	struct list_head	*buffer_list = data;
 	struct xfs_buf		*bp = NULL;
 	int			error = 0;
@@ -1257,7 +1261,32 @@
 	if (!XFS_DQ_IS_DIRTY(dqp))
 		goto out_unlock;
 
-	xfs_dqflock(dqp);
+	/*
+	 * The only way the dquot is already flush locked by the time quotacheck
+	 * gets here is if reclaim flushed it before the dqadjust walk dirtied
+	 * it for the final time. Quotacheck collects all dquot bufs in the
+	 * local delwri queue before dquots are dirtied, so reclaim can't have
+	 * possibly queued it for I/O. The only way out is to push the buffer to
+	 * cycle the flush lock.
+	 */
+	if (!xfs_dqflock_nowait(dqp)) {
+		/* buf is pinned in-core by delwri list */
+		DEFINE_SINGLE_BUF_MAP(map, dqp->q_blkno,
+				      mp->m_quotainfo->qi_dqchunklen);
+		bp = _xfs_buf_find(mp->m_ddev_targp, &map, 1, 0, NULL);
+		if (!bp) {
+			error = -EINVAL;
+			goto out_unlock;
+		}
+		xfs_buf_unlock(bp);
+
+		xfs_buf_delwri_pushbuf(bp, buffer_list);
+		xfs_buf_rele(bp);
+
+		error = -EAGAIN;
+		goto out_unlock;
+	}
+
 	error = xfs_qm_dqflush(dqp, &bp);
 	if (error)
 		goto out_unlock;
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 29a75ec..0015c19 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -169,6 +169,8 @@
 	error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
 	if (error)
 		return error;
+	if (!agbp)
+		return -ENOMEM;
 
 	cur = xfs_refcountbt_init_cursor(mp, NULL, agbp, agno, NULL);
 
@@ -333,7 +335,7 @@
 	struct xfs_defer_ops		*dfops)
 {
 	struct xfs_bmbt_irec		irec = *imap;
-	xfs_fsblock_t			first_block;
+	xfs_fsblock_t			first_block = NULLFSBLOCK;
 	int				nimaps = 1;
 
 	if (imap->br_state == XFS_EXT_NORM)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 882fb85..67d589e 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1214,7 +1214,7 @@
 	tmp_mp->m_super = sb;
 	error = xfs_parseargs(tmp_mp, options);
 	xfs_free_fsname(tmp_mp);
-	kfree(tmp_mp);
+	kmem_free(tmp_mp);
 
 	return error;
 }
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 828f383..bdf69e1 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -366,6 +366,7 @@
 DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
 DEFINE_BUF_EVENT(xfs_buf_delwri_queued);
 DEFINE_BUF_EVENT(xfs_buf_delwri_split);
+DEFINE_BUF_EVENT(xfs_buf_delwri_pushbuf);
 DEFINE_BUF_EVENT(xfs_buf_get_uncached);
 DEFINE_BUF_EVENT(xfs_bdstrat_shut);
 DEFINE_BUF_EVENT(xfs_buf_item_relse);
@@ -519,7 +520,6 @@
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_ordered);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
-DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_ordered);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
@@ -1990,6 +1990,24 @@
 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_before);
 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_after);
 
+TRACE_EVENT(xfs_log_recover,
+	TP_PROTO(struct xlog *log, xfs_daddr_t headblk, xfs_daddr_t tailblk),
+	TP_ARGS(log, headblk, tailblk),
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(xfs_daddr_t, headblk)
+		__field(xfs_daddr_t, tailblk)
+	),
+	TP_fast_assign(
+		__entry->dev = log->l_mp->m_super->s_dev;
+		__entry->headblk = headblk;
+		__entry->tailblk = tailblk;
+	),
+	TP_printk("dev %d:%d headblk 0x%llx tailblk 0x%llx",
+		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->headblk,
+		  __entry->tailblk)
+)
+
 TRACE_EVENT(xfs_log_recover_record,
 	TP_PROTO(struct xlog *log, struct xlog_rec_header *rhead, int pass),
 	TP_ARGS(log, rhead, pass),
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 98024cb..5669cf0 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -50,6 +50,7 @@
 	struct xfs_ail			*li_ailp;	/* ptr to AIL */
 	uint				li_type;	/* item type */
 	uint				li_flags;	/* misc flags */
+	struct xfs_buf			*li_buf;	/* real buffer pointer */
 	struct xfs_log_item		*li_bio_list;	/* buffer item list */
 	void				(*li_cb)(struct xfs_buf *,
 						 struct xfs_log_item *);
@@ -65,11 +66,13 @@
 } xfs_log_item_t;
 
 #define	XFS_LI_IN_AIL	0x1
-#define XFS_LI_ABORTED	0x2
+#define	XFS_LI_ABORTED	0x2
+#define	XFS_LI_FAILED	0x4
 
 #define XFS_LI_FLAGS \
 	{ XFS_LI_IN_AIL,	"IN_AIL" }, \
-	{ XFS_LI_ABORTED,	"ABORTED" }
+	{ XFS_LI_ABORTED,	"ABORTED" }, \
+	{ XFS_LI_FAILED,	"FAILED" }
 
 struct xfs_item_ops {
 	void (*iop_size)(xfs_log_item_t *, int *, int *);
@@ -80,6 +83,7 @@
 	void (*iop_unlock)(xfs_log_item_t *);
 	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
 	void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
+	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
 };
 
 void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
@@ -213,12 +217,14 @@
 void		xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);
 void		xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);
 void		xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);
-void		xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
+bool		xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
 void		xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
 void		xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
 void		xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int);
 void		xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
-void		xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint);
+void		xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint,
+				  uint);
+void		xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
 void		xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
 
 void		xfs_extent_free_init_defer_op(void);
@@ -277,6 +283,6 @@
 		struct xfs_bud_log_item *rudp, struct xfs_defer_ops *dfops,
 		enum xfs_bmap_intent_type type, struct xfs_inode *ip,
 		int whichfork, xfs_fileoff_t startoff, xfs_fsblock_t startblock,
-		xfs_filblks_t blockcount, xfs_exntst_t state);
+		xfs_filblks_t *blockcount, xfs_exntst_t state);
 
 #endif	/* __XFS_TRANS_H__ */
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index d6c9c3e..70f5ab0 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -684,8 +684,24 @@
 	}
 }
 
-/*
- * xfs_trans_ail_delete_bulk - remove multiple log items from the AIL
+bool
+xfs_ail_delete_one(
+	struct xfs_ail		*ailp,
+	struct xfs_log_item	*lip)
+{
+	struct xfs_log_item	*mlip = xfs_ail_min(ailp);
+
+	trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn);
+	xfs_ail_delete(ailp, lip);
+	xfs_clear_li_failed(lip);
+	lip->li_flags &= ~XFS_LI_IN_AIL;
+	lip->li_lsn = 0;
+
+	return mlip == lip;
+}
+
+/**
+ * Remove a log items from the AIL
  *
  * @xfs_trans_ail_delete_bulk takes an array of log items that all need to
  * removed from the AIL. The caller is already holding the AIL lock, and done
@@ -706,52 +722,36 @@
  * before returning.
  */
 void
-xfs_trans_ail_delete_bulk(
+xfs_trans_ail_delete(
 	struct xfs_ail		*ailp,
-	struct xfs_log_item	**log_items,
-	int			nr_items,
+	struct xfs_log_item	*lip,
 	int			shutdown_type) __releases(ailp->xa_lock)
 {
-	xfs_log_item_t		*mlip;
-	int			mlip_changed = 0;
-	int			i;
+	struct xfs_mount	*mp = ailp->xa_mount;
+	bool			mlip_changed;
 
-	mlip = xfs_ail_min(ailp);
-
-	for (i = 0; i < nr_items; i++) {
-		struct xfs_log_item *lip = log_items[i];
-		if (!(lip->li_flags & XFS_LI_IN_AIL)) {
-			struct xfs_mount	*mp = ailp->xa_mount;
-
-			spin_unlock(&ailp->xa_lock);
-			if (!XFS_FORCED_SHUTDOWN(mp)) {
-				xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
-		"%s: attempting to delete a log item that is not in the AIL",
-						__func__);
-				xfs_force_shutdown(mp, shutdown_type);
-			}
-			return;
+	if (!(lip->li_flags & XFS_LI_IN_AIL)) {
+		spin_unlock(&ailp->xa_lock);
+		if (!XFS_FORCED_SHUTDOWN(mp)) {
+			xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
+	"%s: attempting to delete a log item that is not in the AIL",
+					__func__);
+			xfs_force_shutdown(mp, shutdown_type);
 		}
-
-		trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn);
-		xfs_ail_delete(ailp, lip);
-		lip->li_flags &= ~XFS_LI_IN_AIL;
-		lip->li_lsn = 0;
-		if (mlip == lip)
-			mlip_changed = 1;
+		return;
 	}
 
+	mlip_changed = xfs_ail_delete_one(ailp, lip);
 	if (mlip_changed) {
-		if (!XFS_FORCED_SHUTDOWN(ailp->xa_mount))
-			xlog_assign_tail_lsn_locked(ailp->xa_mount);
+		if (!XFS_FORCED_SHUTDOWN(mp))
+			xlog_assign_tail_lsn_locked(mp);
 		if (list_empty(&ailp->xa_ail))
 			wake_up_all(&ailp->xa_empty);
-		spin_unlock(&ailp->xa_lock);
-
-		xfs_log_space_wake(ailp->xa_mount);
-	} else {
-		spin_unlock(&ailp->xa_lock);
 	}
+
+	spin_unlock(&ailp->xa_lock);
+	if (mlip_changed)
+		xfs_log_space_wake(ailp->xa_mount);
 }
 
 int
diff --git a/fs/xfs/xfs_trans_bmap.c b/fs/xfs/xfs_trans_bmap.c
index 6408e7d..14543d9 100644
--- a/fs/xfs/xfs_trans_bmap.c
+++ b/fs/xfs/xfs_trans_bmap.c
@@ -63,7 +63,7 @@
 	int				whichfork,
 	xfs_fileoff_t			startoff,
 	xfs_fsblock_t			startblock,
-	xfs_filblks_t			blockcount,
+	xfs_filblks_t			*blockcount,
 	xfs_exntst_t			state)
 {
 	int				error;
@@ -196,16 +196,23 @@
 	void				**state)
 {
 	struct xfs_bmap_intent		*bmap;
+	xfs_filblks_t			count;
 	int				error;
 
 	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+	count = bmap->bi_bmap.br_blockcount;
 	error = xfs_trans_log_finish_bmap_update(tp, done_item, dop,
 			bmap->bi_type,
 			bmap->bi_owner, bmap->bi_whichfork,
 			bmap->bi_bmap.br_startoff,
 			bmap->bi_bmap.br_startblock,
-			bmap->bi_bmap.br_blockcount,
+			&count,
 			bmap->bi_bmap.br_state);
+	if (!error && count > 0) {
+		ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
+		bmap->bi_bmap.br_blockcount = count;
+		return -EAGAIN;
+	}
 	kmem_free(bmap);
 	return error;
 }
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 8ee29ca..3ba7a96 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -356,6 +356,7 @@
 		 xfs_buf_t	*bp)
 {
 	xfs_buf_log_item_t	*bip;
+	int			freed;
 
 	/*
 	 * Default to a normal brelse() call if the tp is NULL.
@@ -419,16 +420,22 @@
 	/*
 	 * Drop our reference to the buf log item.
 	 */
-	atomic_dec(&bip->bli_refcount);
+	freed = atomic_dec_and_test(&bip->bli_refcount);
 
 	/*
-	 * If the buf item is not tracking data in the log, then
-	 * we must free it before releasing the buffer back to the
-	 * free pool.  Before releasing the buffer to the free pool,
-	 * clear the transaction pointer in b_fsprivate2 to dissolve
-	 * its relation to this transaction.
+	 * If the buf item is not tracking data in the log, then we must free it
+	 * before releasing the buffer back to the free pool.
+	 *
+	 * If the fs has shutdown and we dropped the last reference, it may fall
+	 * on us to release a (possibly dirty) bli if it never made it to the
+	 * AIL (e.g., the aborted unpin already happened and didn't release it
+	 * due to our reference). Since we're already shutdown and need xa_lock,
+	 * just force remove from the AIL and release the bli here.
 	 */
-	if (!xfs_buf_item_dirty(bip)) {
+	if (XFS_FORCED_SHUTDOWN(tp->t_mountp) && freed) {
+		xfs_trans_ail_remove(&bip->bli_item, SHUTDOWN_LOG_IO_ERROR);
+		xfs_buf_item_relse(bp);
+	} else if (!(bip->bli_flags & XFS_BLI_DIRTY)) {
 /***
 		ASSERT(bp->b_pincount == 0);
 ***/
@@ -486,25 +493,17 @@
 }
 
 /*
- * This is called to mark bytes first through last inclusive of the given
- * buffer as needing to be logged when the transaction is committed.
- * The buffer must already be associated with the given transaction.
- *
- * First and last are numbers relative to the beginning of this buffer,
- * so the first byte in the buffer is numbered 0 regardless of the
- * value of b_blkno.
+ * Mark a buffer dirty in the transaction.
  */
 void
-xfs_trans_log_buf(xfs_trans_t	*tp,
-		  xfs_buf_t	*bp,
-		  uint		first,
-		  uint		last)
+xfs_trans_dirty_buf(
+	struct xfs_trans	*tp,
+	struct xfs_buf		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
-	ASSERT(first <= last && last < BBTOB(bp->b_length));
 	ASSERT(bp->b_iodone == NULL ||
 	       bp->b_iodone == xfs_buf_iodone_callbacks);
 
@@ -524,8 +523,6 @@
 	bp->b_iodone = xfs_buf_iodone_callbacks;
 	bip->bli_item.li_cb = xfs_buf_iodone;
 
-	trace_xfs_trans_log_buf(bip);
-
 	/*
 	 * If we invalidated the buffer within this transaction, then
 	 * cancel the invalidation now that we're dirtying the buffer
@@ -538,17 +535,37 @@
 		bp->b_flags &= ~XBF_STALE;
 		bip->__bli_format.blf_flags &= ~XFS_BLF_CANCEL;
 	}
+	bip->bli_flags |= XFS_BLI_DIRTY | XFS_BLI_LOGGED;
 
 	tp->t_flags |= XFS_TRANS_DIRTY;
 	bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY;
+}
 
-	/*
-	 * If we have an ordered buffer we are not logging any dirty range but
-	 * it still needs to be marked dirty and that it has been logged.
-	 */
-	bip->bli_flags |= XFS_BLI_DIRTY | XFS_BLI_LOGGED;
-	if (!(bip->bli_flags & XFS_BLI_ORDERED))
-		xfs_buf_item_log(bip, first, last);
+/*
+ * This is called to mark bytes first through last inclusive of the given
+ * buffer as needing to be logged when the transaction is committed.
+ * The buffer must already be associated with the given transaction.
+ *
+ * First and last are numbers relative to the beginning of this buffer,
+ * so the first byte in the buffer is numbered 0 regardless of the
+ * value of b_blkno.
+ */
+void
+xfs_trans_log_buf(
+	struct xfs_trans	*tp,
+	struct xfs_buf		*bp,
+	uint			first,
+	uint			last)
+{
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+
+	ASSERT(first <= last && last < BBTOB(bp->b_length));
+	ASSERT(!(bip->bli_flags & XFS_BLI_ORDERED));
+
+	xfs_trans_dirty_buf(tp, bp);
+
+	trace_xfs_trans_log_buf(bip);
+	xfs_buf_item_log(bip, first, last);
 }
 
 
@@ -701,14 +718,13 @@
 }
 
 /*
- * Mark the buffer as ordered for this transaction. This means
- * that the contents of the buffer are not recorded in the transaction
- * but it is tracked in the AIL as though it was. This allows us
- * to record logical changes in transactions rather than the physical
- * changes we make to the buffer without changing writeback ordering
- * constraints of metadata buffers.
+ * Mark the buffer as ordered for this transaction. This means that the contents
+ * of the buffer are not recorded in the transaction but it is tracked in the
+ * AIL as though it was. This allows us to record logical changes in
+ * transactions rather than the physical changes we make to the buffer without
+ * changing writeback ordering constraints of metadata buffers.
  */
-void
+bool
 xfs_trans_ordered_buf(
 	struct xfs_trans	*tp,
 	struct xfs_buf		*bp)
@@ -719,8 +735,18 @@
 	ASSERT(bip != NULL);
 	ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
+	if (xfs_buf_item_dirty_format(bip))
+		return false;
+
 	bip->bli_flags |= XFS_BLI_ORDERED;
 	trace_xfs_buf_item_ordered(bip);
+
+	/*
+	 * We don't log a dirty range of an ordered buffer but it still needs
+	 * to be marked dirty and that it has been logged.
+	 */
+	xfs_trans_dirty_buf(tp, bp);
+	return true;
 }
 
 /*
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index 49931b7..b317a36 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -106,18 +106,9 @@
 	xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn);
 }
 
-void	xfs_trans_ail_delete_bulk(struct xfs_ail *ailp,
-				struct xfs_log_item **log_items, int nr_items,
-				int shutdown_type)
-				__releases(ailp->xa_lock);
-static inline void
-xfs_trans_ail_delete(
-	struct xfs_ail	*ailp,
-	xfs_log_item_t	*lip,
-	int		shutdown_type) __releases(ailp->xa_lock)
-{
-	xfs_trans_ail_delete_bulk(ailp, &lip, 1, shutdown_type);
-}
+bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip);
+void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip,
+		int shutdown_type) __releases(ailp->xa_lock);
 
 static inline void
 xfs_trans_ail_remove(
@@ -173,4 +164,35 @@
 	*dst = *src;
 }
 #endif
+
+static inline void
+xfs_clear_li_failed(
+	struct xfs_log_item	*lip)
+{
+	struct xfs_buf	*bp = lip->li_buf;
+
+	ASSERT(lip->li_flags & XFS_LI_IN_AIL);
+	lockdep_assert_held(&lip->li_ailp->xa_lock);
+
+	if (lip->li_flags & XFS_LI_FAILED) {
+		lip->li_flags &= ~XFS_LI_FAILED;
+		lip->li_buf = NULL;
+		xfs_buf_rele(bp);
+	}
+}
+
+static inline void
+xfs_set_li_failed(
+	struct xfs_log_item	*lip,
+	struct xfs_buf		*bp)
+{
+	lockdep_assert_held(&lip->li_ailp->xa_lock);
+
+	if (!(lip->li_flags & XFS_LI_FAILED)) {
+		xfs_buf_hold(bp);
+		lip->li_flags |= XFS_LI_FAILED;
+		lip->li_buf = bp;
+	}
+}
+
 #endif	/* __XFS_TRANS_PRIV_H__ */
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index fc824e2..5d2add1 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -48,7 +48,11 @@
 #define parent_node(node)	((void)(node),0)
 #endif
 #ifndef cpumask_of_node
-#define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #ifdef CONFIG_NEED_MULTIPLE_NODES
+    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_none_mask)
+  #else
+    #define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #endif
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)	((void)(bus), -1)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 31e1d63..dc81e52 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -60,6 +60,22 @@
 #define ALIGN_FUNCTION()  . = ALIGN(8)
 
 /*
+ * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which
+ * generates .data.identifier sections, which need to be pulled in with
+ * .data. We don't want to pull in .data..other sections, which Linux
+ * has defined. Same for text and bss.
+ */
+#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
+#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#else
+#define TEXT_MAIN .text
+#define DATA_MAIN .data
+#define BSS_MAIN .bss
+#endif
+
+/*
  * Align to a 32 byte boundary equal to the
  * alignment gcc 4.5 uses for a struct
  */
@@ -198,12 +214,9 @@
 
 /*
  * .data section
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections generates
- * .data.identifier which needs to be pulled in with .data, but don't want to
- * pull in .data..stuff which has its own requirements. Same for bss.
  */
 #define DATA_DATA							\
-	*(.data .data.[0-9a-zA-Z_]*)					\
+	*(DATA_MAIN)							\
 	*(.ref.data)							\
 	*(.data..shared_aligned) /* percpu related */			\
 	MEM_KEEP(init.data)						\
@@ -436,16 +449,17 @@
 		VMLINUX_SYMBOL(__security_initcall_end) = .;		\
 	}
 
-/* .text section. Map to function alignment to avoid address changes
+/*
+ * .text section. Map to function alignment to avoid address changes
  * during second ld run in second ld pass when generating System.map
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -ffunction-sections generates
- * .text.identifier which needs to be pulled in with .text , but some
- * architectures define .text.foo which is not intended to be pulled in here.
- * Those enabling LD_DEAD_CODE_DATA_ELIMINATION must ensure they don't have
- * conflicting section names, and must pull in .text.[0-9a-zA-Z_]* */
+ *
+ * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
+ * code elimination is enabled, so these sections should be converted
+ * to use ".." first.
+ */
 #define TEXT_TEXT							\
 		ALIGN_FUNCTION();					\
-		*(.text.hot .text .text.fixup .text.unlikely)		\
+		*(.text.hot TEXT_MAIN .text.fixup .text.unlikely)	\
 		*(.ref.text)						\
 	MEM_KEEP(init.text)						\
 	MEM_KEEP(exit.text)						\
@@ -613,7 +627,7 @@
 		BSS_FIRST_SECTIONS					\
 		*(.bss..page_aligned)					\
 		*(.dynbss)						\
-		*(.bss .bss.[0-9a-zA-Z_]*)				\
+		*(BSS_MAIN)						\
 		*(COMMON)						\
 	}
 
diff --git a/include/dt-bindings/clock/qcom,gcc-sdm845.h b/include/dt-bindings/clock/qcom,gcc-sdm845.h
index 339d470..c8696df 100644
--- a/include/dt-bindings/clock/qcom,gcc-sdm845.h
+++ b/include/dt-bindings/clock/qcom,gcc-sdm845.h
@@ -212,6 +212,7 @@
 #define GCC_VS_CTRL_CLK_SRC					194
 #define GCC_VSENSOR_CLK_SRC					195
 #define GPLL4							196
+#define GPLL6							197
 
 /* GCC reset clocks */
 #define GCC_MMSS_BCR						0
diff --git a/include/dt-bindings/msm/msm-bus-ids.h b/include/dt-bindings/msm/msm-bus-ids.h
index bc87beb..e20175d 100644
--- a/include/dt-bindings/msm/msm-bus-ids.h
+++ b/include/dt-bindings/msm/msm-bus-ids.h
@@ -251,7 +251,8 @@
 #define	MSM_BUS_MASTER_CAMNOC_HF1_UNCOMP 147
 #define	MSM_BUS_MASTER_CAMNOC_SF_UNCOMP 148
 #define	MSM_BUS_MASTER_GIC 149
-#define	MSM_BUS_MASTER_MASTER_LAST 150
+#define	MSM_BUS_MASTER_EMMC 150
+#define	MSM_BUS_MASTER_MASTER_LAST 151
 
 #define MSM_BUS_MASTER_LLCC_DISPLAY 20000
 #define MSM_BUS_MASTER_MNOC_HF_MEM_NOC_DISPLAY 20001
@@ -767,6 +768,7 @@
 #define	ICBID_MASTER_CNOC_A2NOC 146
 #define	ICBID_MASTER_WLAN 147
 #define	ICBID_MASTER_MSS_CE 148
+#define	ICBID_MASTER_EMMC 149
 
 #define	ICBID_SLAVE_EBI1 0
 #define	ICBID_SLAVE_APPSS_L2 1
diff --git a/include/linux/avtimer_kernel.h b/include/linux/avtimer_kernel.h
deleted file mode 100644
index e5a1255..0000000
--- a/include/linux/avtimer_kernel.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _AVTIMER_H
-#define _AVTIMER_H
-
-#include <uapi/linux/avtimer.h>
-
-int avcs_core_open(void);
-int avcs_core_disable_power_collapse(int disable);/* true or flase */
-int avcs_core_query_timer(uint64_t *avtimer_tick);
-
-#endif
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index a13b031..3101141 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -40,6 +40,7 @@
 	 */
 	s64 min_value;
 	u64 max_value;
+	bool value_from_signed;
 };
 
 enum bpf_stack_slot_type {
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 10842bb..32c3d42 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -158,6 +158,7 @@
  * @activated:	'true' only if a _sink_ has been activated.  A sink can be
 		activated but not yet enabled.  Enabling for a _sink_
 		happens when a source has been selected for that it.
+ * @abort:     captures sink trace on abort.
  */
 struct coresight_device {
 	struct coresight_connection *conns;
@@ -206,6 +207,7 @@
 	void (*update_buffer)(struct coresight_device *csdev,
 			      struct perf_output_handle *handle,
 			      void *sink_config);
+	void (*abort)(struct coresight_device *csdev);
 };
 
 /**
@@ -252,6 +254,7 @@
 extern void coresight_disable(struct coresight_device *csdev);
 extern int coresight_timeout(void __iomem *addr, u32 offset,
 			     int position, int value);
+extern void coresight_abort(void);
 #else
 static inline struct coresight_device *
 coresight_register(struct coresight_desc *desc) { return NULL; }
@@ -261,9 +264,10 @@
 static inline void coresight_disable(struct coresight_device *csdev) {}
 static inline int coresight_timeout(void __iomem *addr, u32 offset,
 				     int position, int value) { return 1; }
+static inline void coresight_abort(void) {}
 #endif
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_CORESIGHT)
 extern struct coresight_platform_data *of_get_coresight_platform_data(
 				struct device *dev, struct device_node *node);
 extern struct coresight_cti_data *of_get_coresight_cti_data(
@@ -271,7 +275,7 @@
 #else
 static inline struct coresight_platform_data *of_get_coresight_platform_data(
 	struct device *dev, struct device_node *node) { return NULL; }
-static inlint struct coresight_cti_data *of_get_coresight_cti_data(
+static inline struct coresight_cti_data *of_get_coresight_cti_data(
 		struct device *dev, struct device_node *node) { return NULL; }
 #endif
 
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index edf88bd..6be0299 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -10,7 +10,6 @@
 	CPUHP_PERF_X86_PREPARE,
 	CPUHP_PERF_X86_UNCORE_PREP,
 	CPUHP_PERF_X86_AMD_UNCORE_PREP,
-	CPUHP_PERF_X86_RAPL_PREP,
 	CPUHP_PERF_BFIN,
 	CPUHP_PERF_POWER,
 	CPUHP_PERF_SUPERH,
@@ -102,6 +101,8 @@
 	CPUHP_AP_DUMMY_TIMER_STARTING,
 	CPUHP_AP_ARM_XEN_STARTING,
 	CPUHP_AP_ARM_CORESIGHT_STARTING,
+	CPUHP_AP_ARM_SAVE_RESTORE_CORESIGHT4_STARTING,
+	CPUHP_AP_ARM_MM_CORESIGHT4_STARTING,
 	CPUHP_AP_ARM_CORESIGHT4_STARTING,
 	CPUHP_AP_ARM64_ISNDEP_STARTING,
 	CPUHP_AP_SMPCFD_DYING,
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index bfc204e..cd32a49 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -16,6 +16,19 @@
 
 #ifdef CONFIG_CPUSETS
 
+/*
+ * Static branch rewrites can happen in an arbitrary order for a given
+ * key. In code paths where we need to loop with read_mems_allowed_begin() and
+ * read_mems_allowed_retry() to get a consistent view of mems_allowed, we need
+ * to ensure that begin() always gets rewritten before retry() in the
+ * disabled -> enabled transition. If not, then if local irqs are disabled
+ * around the loop, we can deadlock since retry() would always be
+ * comparing the latest value of the mems_allowed seqcount against 0 as
+ * begin() still would see cpusets_enabled() as false. The enabled -> disabled
+ * transition should happen in reverse order for the same reasons (want to stop
+ * looking at real value of mems_allowed.sequence in retry() first).
+ */
+extern struct static_key_false cpusets_pre_enable_key;
 extern struct static_key_false cpusets_enabled_key;
 static inline bool cpusets_enabled(void)
 {
@@ -30,12 +43,14 @@
 
 static inline void cpuset_inc(void)
 {
+	static_branch_inc(&cpusets_pre_enable_key);
 	static_branch_inc(&cpusets_enabled_key);
 }
 
 static inline void cpuset_dec(void)
 {
 	static_branch_dec(&cpusets_enabled_key);
+	static_branch_dec(&cpusets_pre_enable_key);
 }
 
 extern int cpuset_init(void);
@@ -113,7 +128,7 @@
  */
 static inline unsigned int read_mems_allowed_begin(void)
 {
-	if (!cpusets_enabled())
+	if (!static_branch_unlikely(&cpusets_pre_enable_key))
 		return 0;
 
 	return read_seqcount_begin(&current->mems_allowed_seq);
@@ -127,7 +142,7 @@
  */
 static inline bool read_mems_allowed_retry(unsigned int seq)
 {
-	if (!cpusets_enabled())
+	if (!static_branch_unlikely(&cpusets_enabled_key))
 		return false;
 
 	return read_seqcount_retry(&current->mems_allowed_seq, seq);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 9b0477e..3d4a198 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -591,5 +591,11 @@
 	return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0));
 }
 
+struct name_snapshot {
+	const char *name;
+	char inline_name[DNAME_INLINE_LEN];
+};
+void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
+void release_dentry_name_snapshot(struct name_snapshot *);
 
 #endif	/* __LINUX_DCACHE_H */
diff --git a/include/linux/dma-mapping-fast.h b/include/linux/dma-mapping-fast.h
index 560f047..64ae548 100644
--- a/include/linux/dma-mapping-fast.h
+++ b/include/linux/dma-mapping-fast.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -41,19 +41,17 @@
 };
 
 #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
-int fast_smmu_attach_device(struct device *dev,
+int fast_smmu_init_mapping(struct device *dev,
 			    struct dma_iommu_mapping *mapping);
-void fast_smmu_detach_device(struct device *dev,
-			     struct dma_iommu_mapping *mapping);
+void fast_smmu_release_mapping(struct kref *kref);
 #else
-static inline int fast_smmu_attach_device(struct device *dev,
+static inline int fast_smmu_init_mapping(struct device *dev,
 					  struct dma_iommu_mapping *mapping)
 {
 	return -ENODEV;
 }
 
-static inline void fast_smmu_detach_device(struct device *dev,
-					   struct dma_iommu_mapping *mapping)
+static inline void fast_smmu_release_mapping(struct kref *kref)
 {
 }
 #endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 026aa0a..18bd249 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -941,9 +941,9 @@
 /* Page cache limit. The filesystems should put that into their s_maxbytes 
    limits, otherwise bad things can happen in VM. */ 
 #if BITS_PER_LONG==32
-#define MAX_LFS_FILESIZE	(((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
+#define MAX_LFS_FILESIZE	((loff_t)ULONG_MAX << PAGE_SHIFT)
 #elif BITS_PER_LONG==64
-#define MAX_LFS_FILESIZE 	((loff_t)0x7fffffffffffffffLL)
+#define MAX_LFS_FILESIZE 	((loff_t)LLONG_MAX)
 #endif
 
 #define FL_POSIX	1
@@ -2782,6 +2782,7 @@
 #endif
 extern void unlock_new_inode(struct inode *);
 extern unsigned int get_next_ino(void);
+extern void evict_inodes(struct super_block *sb);
 
 extern void __iget(struct inode * inode);
 extern void iget_failed(struct inode *);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index b8bcc05..e5f03a4d 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -293,35 +293,4 @@
 	}
 }
 
-#if defined(CONFIG_FSNOTIFY)	/* notify helpers */
-
-/*
- * fsnotify_oldname_init - save off the old filename before we change it
- */
-static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
-{
-	return kstrdup(name, GFP_KERNEL);
-}
-
-/*
- * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init
- */
-static inline void fsnotify_oldname_free(const unsigned char *old_name)
-{
-	kfree(old_name);
-}
-
-#else	/* CONFIG_FSNOTIFY */
-
-static inline const char *fsnotify_oldname_init(const unsigned char *name)
-{
-	return NULL;
-}
-
-static inline void fsnotify_oldname_free(const unsigned char *old_name)
-{
-}
-
-#endif	/*  CONFIG_FSNOTIFY */
-
 #endif	/* _LINUX_FS_NOTIFY_H */
diff --git a/include/linux/i2c/i2c-msm-v2.h b/include/linux/i2c/i2c-msm-v2.h
new file mode 100644
index 0000000..f5d699f
--- /dev/null
+++ b/include/linux/i2c/i2c-msm-v2.h
@@ -0,0 +1,666 @@
+/* Copyright (c) 2014-2015,2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ *
+ */
+/*
+ * I2C controller driver for Qualcomm Technologies Inc platforms
+ */
+
+#ifndef _I2C_MSM_V2_H
+#define _I2C_MSM_V2_H
+
+#include <linux/bitops.h>
+#include <linux/dmaengine.h>
+
+enum msm_i2_debug_level {
+	MSM_ERR,	/* Error messages only. Always on */
+	MSM_PROF,	/* High level events. Use for profiling */
+	MSM_DBG,	/* Low level details. Use for debugging */
+};
+
+#define i2c_msm_dbg(ctrl, dbg_level, fmt, ...) do {\
+		if (ctrl->dbgfs.dbg_lvl >= dbg_level)\
+			dev_info(ctrl->dev, pr_fmt(fmt), ##__VA_ARGS__);\
+	} while (0)
+
+#define BIT_IS_SET(val, idx)        ((val >> idx) & 0x1)
+#define BITS_AT(val, idx, n_bits)(((val) & (((1 << n_bits) - 1) << idx)) >> idx)
+#define MASK_IS_SET(val, mask)      ((val & mask) == mask)
+#define MASK_IS_SET_BOOL(val, mask) (MASK_IS_SET(val, mask) ? 1 : 0)
+#define KHz(freq) (1000 * freq)
+#define I2C_MSM_CLK_FAST_PLUS_FREQ  (1000000)
+
+/* QUP Registers */
+enum {
+	QUP_CONFIG              = 0x0,
+	QUP_STATE               = 0x4,
+	QUP_IO_MODES            = 0x8,
+	QUP_SW_RESET            = 0xC,
+	QUP_OPERATIONAL         = 0x18,
+	QUP_ERROR_FLAGS         = 0x1C,
+	QUP_ERROR_FLAGS_EN      = 0x20,
+	QUP_TEST_CTRL           = 0x24,
+	QUP_OPERATIONAL_MASK    = 0x28,
+	QUP_HW_VERSION          = 0x30,
+	QUP_MX_READ_COUNT       = 0x208,
+	QUP_MX_WRITE_COUNT      = 0x150,
+	QUP_MX_OUTPUT_COUNT     = 0x100,
+	QUP_MX_INPUT_COUNT      = 0x200,
+	QUP_MX_WR_CNT           = 0x100,
+	QUP_OUT_DEBUG           = 0x108,
+	QUP_OUT_FIFO_CNT        = 0x10C,
+	QUP_OUT_FIFO_BASE       = 0x110,
+	QUP_IN_READ_CUR         = 0x20C,
+	QUP_IN_DEBUG            = 0x210,
+	QUP_IN_FIFO_CNT         = 0x214,
+	QUP_IN_FIFO_BASE        = 0x218,
+	QUP_I2C_MASTER_CLK_CTL  = 0x400,
+	QUP_I2C_STATUS          = 0x404,
+	QUP_I2C_MASTER_CONFIG   = 0x408,
+	QUP_I2C_MASTER_BUS_CLR  = 0x40C,
+};
+
+/* Register:QUP_STATE state field values */
+enum i2c_msm_qup_state {
+	QUP_STATE_RESET         = 0,
+	QUP_STATE_RUN           = 1U,
+	QUP_STATE_PAUSE         = 3U,
+};
+
+/* Register:QUP_STATE fields */
+enum {
+	QUP_STATE_MASK          = 3U,
+	QUP_STATE_VALID         = BIT(2),
+	QUP_I2C_MAST_GEN        = BIT(4),
+	QUP_I2C_FLUSH           = BIT(6),
+	QUP_I2C_STATUS_RESET    = 0x42,
+};
+
+
+/* Register:QUP_CONFIG fields */
+enum {
+	QUP_MINI_CORE_MASK      = 0xF00,
+	QUP_MINI_CORE_I2C_VAL   = 0x200,
+	QUP_N_MASK              = 0x1F,
+	QUP_N_VAL               = 0x7, /* 0xF for A family */
+	QUP_NO_OUTPUT           = BIT(6),
+	QUP_NO_INPUT            = BIT(7),
+	QUP_APP_CLK_ON_EN       = BIT(12),
+	QUP_CORE_CLK_ON_EN      = BIT(13),
+	QUP_FIFO_CLK_GATE_EN    = BIT(14),
+};
+
+/* Register:QUP_OPERATIONAL fields */
+enum {
+	QUP_INPUT_FIFO_NOT_EMPTY = BIT(5),
+	QUP_OUTPUT_SERVICE_FLAG  = BIT(8),
+	QUP_INPUT_SERVICE_FLAG   = BIT(9),
+	QUP_MAX_OUTPUT_DONE_FLAG = BIT(10),
+	QUP_MAX_INPUT_DONE_FLAG  = BIT(11),
+	QUP_OUT_BLOCK_WRITE_REQ  = BIT(12),
+	QUP_IN_BLOCK_READ_REQ    = BIT(13),
+};
+
+/* Register:QUP_OPERATIONAL_MASK fields */
+enum {
+	QUP_INPUT_SERVICE_MASK  = BIT(9),
+	QUP_OUTPUT_SERVICE_MASK = BIT(8),
+};
+
+/* Register:QUP_IO_MODES fields */
+enum {
+	QUP_OUTPUT_MODE         = BIT(10) | BIT(11),
+	QUP_INPUT_MODE          = BIT(12) | BIT(13),
+	QUP_UNPACK_EN           = BIT(14),
+	QUP_PACK_EN             = BIT(15),
+	QUP_OUTPUT_BIT_SHIFT_EN = BIT(16),
+};
+
+/* Register:QUP_I2C_STATUS (a.k.a I2C_MASTER_STATUS) fields */
+enum {
+	QUP_BUS_ERROR           = BIT(2),
+	QUP_PACKET_NACKED       = BIT(3),
+	QUP_ARB_LOST            = BIT(4),
+	QUP_INVALID_WRITE       = BIT(5),
+	QUP_FAILED              = BIT(6),
+	QUP_BUS_ACTIVE          = BIT(8),
+	QUP_BUS_MASTER          = BIT(9),
+	QUP_INVALID_TAG         = BIT(23),
+	QUP_INVALID_READ_ADDR   = BIT(24),
+	QUP_INVALID_READ_SEQ    = BIT(25),
+	QUP_I2C_SDA             = BIT(26),
+	QUP_I2C_SCL             = BIT(27),
+	QUP_MSTR_STTS_ERR_MASK  = 0x380003C,
+};
+
+/* Register:QUP_I2C_MASTER_CONFIG fields */
+enum {
+	QUP_EN_VERSION_TWO_TAG  = 1U,
+};
+
+/* Register:QUP_I2C_MASTER_CLK_CTL field setters */
+#define I2C_MSM_SCL_NOISE_REJECTION(reg_val, noise_rej_val) \
+		(((reg_val) & ~(0x3 << 24)) | (((noise_rej_val) & 0x3) << 24))
+#define I2C_MSM_SDA_NOISE_REJECTION(reg_val, noise_rej_val) \
+		(((reg_val) & ~(0x3 << 26)) | (((noise_rej_val) & 0x3) << 26))
+
+/* Register:QUP_ERROR_FLAGS_EN flags */
+enum {
+	QUP_OUTPUT_OVER_RUN_ERR_EN  = BIT(5),
+	QUP_INPUT_UNDER_RUN_ERR_EN  = BIT(4),
+	QUP_OUTPUT_UNDER_RUN_ERR_EN = BIT(3),
+	QUP_INPUT_OVER_RUN_ERR_EN   = BIT(2),
+};
+
+/* Status, Error flags */
+enum {
+	I2C_STATUS_WR_BUFFER_FULL  = BIT(0),
+	I2C_STATUS_BUS_ACTIVE      = BIT(8),
+	I2C_STATUS_BUS_MASTER      = BIT(9),
+	I2C_STATUS_ERROR_MASK      = 0x38000FC,
+	QUP_I2C_NACK_FLAG          = BIT(3),
+	QUP_IN_NOT_EMPTY           = BIT(5),
+	QUP_ERR_FLGS_MASK           = 0x3C,
+};
+
+/* Master status clock states */
+enum {
+	I2C_CLK_RESET_BUSIDLE_STATE = 0,
+	I2C_CLK_FORCED_LOW_STATE    = 5,
+};
+
+/* Controller's power state */
+enum i2c_msm_power_state {
+	I2C_MSM_PM_RT_ACTIVE,
+	I2C_MSM_PM_RT_SUSPENDED,
+	I2C_MSM_PM_SYS_SUSPENDED
+};
+
+/*
+ * The max buffer size required for tags is for holding the following sequence:
+ * [start] + [start | slv-addr] + [ rd/wr | len]
+ * which sum up to 6 bytes. However, we use u64 to hold the value, thus we say
+ * that max length is 8 bytes.
+ */
+#define I2C_MSM_TAG2_MAX_LEN            (4)
+#define I2C_MSM_DMA_TX_SZ             (64) /* tx chan n entries */
+#define I2C_MSM_DMA_RX_SZ             (32) /* rx chan n entries */
+#define I2C_MSM_DMA_DESC_ARR_SIZ  (I2C_MSM_DMA_TX_SZ + I2C_MSM_DMA_RX_SZ)
+#define I2C_MSM_REG_2_STR_BUF_SZ        (128)
+/* Optimal value to hold the error strings */
+#define I2C_MSM_MAX_ERR_BUF_SZ		(256)
+#define I2C_MSM_BUF_DUMP_MAX_BC         (20)
+#define I2C_MSM_MAX_POLL_MSEC           (100)
+#define I2C_MSM_TIMEOUT_SAFETY_COEF     (10)
+#define I2C_MSM_TIMEOUT_MIN_USEC        (500000)
+#define I2C_QUP_MAX_BUS_RECOVERY_RETRY  (10)
+
+/* QUP v2 tags */
+#define QUP_TAG2_DATA_WRITE        (0x82ULL)
+#define QUP_TAG2_DATA_WRITE_N_STOP (0x83ULL)
+#define QUP_TAG2_DATA_READ         (0x85ULL)
+#define QUP_TAG2_DATA_READ_N_STOP  (0x87ULL)
+#define QUP_TAG2_START             (0x81ULL)
+#define QUP_TAG2_DATA_READ_N_NACK  (0x86ULL)
+#define QUP_TAG2_START_STOP        (0x8AULL)
+#define QUP_TAG2_INPUT_EOT         (0x93ULL)
+#define QUP_TAG2_FLUSH_STOP        (0x96ULL)
+#define QUP_BUF_OVERHD_BC          (2)
+#define QUP_MAX_BUF_SZ             (256)
+
+enum i2c_msm_clk_path_vec_idx {
+	I2C_MSM_CLK_PATH_SUSPEND_VEC,
+	I2C_MSM_CLK_PATH_RESUME_VEC,
+};
+#define I2C_MSM_CLK_PATH_AVRG_BW(ctrl) (0)
+#define I2C_MSM_CLK_PATH_BRST_BW(ctrl) (ctrl->rsrcs.clk_freq_in * 8)
+
+enum i2c_msm_gpio_name_idx {
+	I2C_MSM_GPIO_SCL,
+	I2C_MSM_GPIO_SDA,
+};
+
+extern const char * const i2c_msm_mode_str_tbl[];
+
+struct i2c_msm_ctrl;
+
+/*
+ *  i2c_msm_dma_mem: utility struct which holds both physical and virtual addr
+ */
+struct i2c_msm_dma_mem {
+	dma_addr_t               phy_addr;
+	void                    *vrtl_addr;
+};
+
+/*
+ * i2c_msm_tag: tag's data and its length.
+ *
+ * @len tag len can be two, four or six bytes.
+ */
+struct i2c_msm_tag {
+	u64                    val;
+	int                    len;
+};
+
+/*
+ * i2c_msm_dma_tag: similar to struct i2c_msm_tag but holds physical address.
+ *
+ * @buf physical address of entry in the tag_arr of
+ *          struct i2c_msm_xfer_mode_dma
+ * @len tag len.
+ *
+ * Hold the information from i2c_msm_dma_xfer_prepare() which is used by
+ * i2c_msm_dma_xfer_process() and freed by i2c_msm_dma_xfer_unprepare()
+ */
+struct i2c_msm_dma_tag {
+	dma_addr_t             buf;
+	size_t                 len;
+};
+
+/*
+ * i2c_msm_dma_buf: dma mapped pointer to i2c_msg data buffer and related tag
+ * @vir_addr ptr to i2c_msg buf beginning or with offset (when buf len > 256)
+ */
+struct i2c_msm_dma_buf {
+	struct i2c_msm_dma_mem   ptr;
+	enum dma_data_direction  dma_dir;
+	size_t                   len;
+	bool                     is_rx;
+	bool                     is_last;
+	struct i2c_msm_dma_tag   tag;
+	/* DMA API */
+	struct scatterlist	sg_list[2];
+};
+
+/*
+ * i2c_msm_dma_chan: per channel info
+ *
+ * @is_init true when the channel is initialized and requires eventual teardown.
+ * @name channel name (tx/rx) for debugging.
+ * @desc_cnt_cur number of occupied descriptors
+ */
+struct i2c_msm_dma_chan {
+	bool                     is_init;
+	const char              *name;
+	size_t                   desc_cnt_cur;
+	struct dma_chan         *dma_chan;
+	enum dma_transfer_direction dir;
+};
+
+enum i2c_msm_dma_chan_dir {
+	I2C_MSM_DMA_TX,
+	I2C_MSM_DMA_RX,
+	I2C_MSM_DMA_CNT,
+};
+
+enum i2c_msm_dma_state {
+	I2C_MSM_DMA_INIT_NONE, /* Uninitialized  DMA */
+	I2C_MSM_DMA_INIT_CORE, /* Core init not channels, memory Allocated */
+	I2C_MSM_DMA_INIT_CHAN, /* Both Core and channels are init */
+};
+
+/*
+ * struct i2c_msm_xfer_mode_dma: DMA mode configuration and work space
+ *
+ * @state   specifies the DMA core and channel initialization states.
+ * @buf_arr_cnt current number of valid buffers in buf_arr. The valid buffers
+ *          are at index 0..buf_arr_cnt excluding buf_arr_cnt.
+ * @buf_arr array of descriptors which point to the user's buffer
+ *     virtual and physical address, and hold meta data about the buffer
+ *     and respective tag.
+ * @tag_arr array of tags in DMAable memory. Holds a tag per buffer of the same
+ *          index, that is tag_arr[i] is related to buf_arr[i]. Also, tag_arr[i]
+ *          is queued in the tx channel just before buf_arr[i] is queued in
+ *          the tx (output buf) or rx channel (input buffer).
+ * @eot_n_flush_stop_tags EOT and flush-stop tags to be queued to the tx
+ *          DMA channel after the last transfer when it is a read.
+ * @input_tag hw is placing input tags in the rx channel on read operations.
+ *          The value of these tags is "don't care" from DMA transfer
+ *          perspective. Thus, this single buffer is used for all the input
+ *          tags. The field is used as write only.
+ */
+struct i2c_msm_xfer_mode_dma {
+	enum i2c_msm_dma_state   state;
+	size_t                   buf_arr_cnt;
+	struct i2c_msm_dma_buf   buf_arr[I2C_MSM_DMA_DESC_ARR_SIZ];
+	struct i2c_msm_dma_mem   tag_arr;
+	struct i2c_msm_dma_mem   eot_n_flush_stop_tags;
+	struct i2c_msm_dma_mem   input_tag;
+	struct i2c_msm_dma_chan  chan[I2C_MSM_DMA_CNT];
+};
+
+/*
+ * I2C_MSM_DMA_TAG_MEM_SZ includes the following fields of
+ * struct i2c_msm_xfer_mode_dma (in order):
+ *
+ * Buffer of DMA memory:
+ * +-----------+---------+-----------+-----------+----+-----------+
+ * | input_tag | eot_... | tag_arr 0 | tag_arr 1 | .. | tag_arr n |
+ * +-----------+---------+-----------+-----------+----+-----------+
+ *
+ * Why +2?
+ * One tag buffer for the input tags. This is a write only buffer for DMA, it is
+ *    used to read the tags of the input fifo. We let them overwrite each other,
+ *    since it is a throw-away from the driver's perspective.
+ * Second tag buffer for the EOT and flush-stop tags. This is a read only
+ *    buffer (from DMA perspective). It is used to put EOT and flush-stop at the
+ *    end of every transaction.
+ */
+#define I2C_MSM_DMA_TAG_MEM_SZ  \
+	((I2C_MSM_DMA_DESC_ARR_SIZ + 2) * I2C_MSM_TAG2_MAX_LEN)
+
+/*
+ * i2c_msm_xfer_mode_fifo: operations and state of FIFO mode
+ *
+ * @ops     "base class" of i2c_msm_xfer_mode_dma. Contains the operations while
+ *          the rest of the fields contain the data.
+ * @input_fifo_sz input fifo size in bytes
+ * @output_fifo_sz output fifo size in bytes
+ * @in_rem  remaining u32 entries in input FIFO before empty
+ * @out_rem remaining u32 entries in output FIFO before full
+ * @out_buf buffer for collecting bytes to four bytes groups (u32) before
+ *          writing them to the output fifo.
+ * @out_buf_idx next free index in out_buf. 0..3
+ */
+struct i2c_msm_xfer_mode_fifo {
+	size_t                   input_fifo_sz;
+	size_t                   output_fifo_sz;
+	size_t                   in_rem;
+	size_t                   out_rem;
+	u8                       out_buf[4];
+	int                      out_buf_idx;
+};
+
+/* i2c_msm_xfer_mode_blk: operations and state of Block mode
+ *
+ * @is_init when true, struct is initialized and requires mem free on exit
+ * @in_blk_sz size of input/rx block
+ * @out_blk_sz size of output/tx block
+ * @tx_cache internal buffer to store tx data
+ * @rx_cache internal buffer to store rx data
+ * @rx_cache_idx points to the next unread index in rx cache
+ * @tx_cache_idx points to the next unwritten index in tx cache
+ * @wait_rx_blk completion object to wait on for end of blk rx transfer.
+ * @wait_tx_blk completion object to wait on for end of blk tx transfer.
+ * @complete_mask applied to QUP_OPERATIONAL to determine when blk
+ *  xfer is complete.
+ */
+struct i2c_msm_xfer_mode_blk {
+	bool                     is_init;
+	size_t                   in_blk_sz;
+	size_t                   out_blk_sz;
+	u8                       *tx_cache;
+	u8                       *rx_cache;
+	int                      rx_cache_idx;
+	int                      tx_cache_idx;
+	struct completion        wait_rx_blk;
+	struct completion        wait_tx_blk;
+	u32                      complete_mask;
+};
+
+/* INPUT_MODE and OUTPUT_MODE filds of QUP_IO_MODES register */
+enum i2c_msm_xfer_mode_id {
+	I2C_MSM_XFER_MODE_FIFO,
+	I2C_MSM_XFER_MODE_BLOCK,
+	I2C_MSM_XFER_MODE_DMA,
+	I2C_MSM_XFER_MODE_NONE, /* keep last as a counter */
+};
+
+
+struct i2c_msm_dbgfs {
+	struct dentry             *root;
+	enum msm_i2_debug_level    dbg_lvl;
+	enum i2c_msm_xfer_mode_id  force_xfer_mode;
+};
+
+/*
+ * qup_i2c_clk_path_vote: data to use bus scaling driver for clock path vote
+ *
+ * @mstr_id master id number of the i2c core or its wrapper (BLSP/GSBI).
+ *       When zero, clock path voting is disabled.
+ * @client_hdl when zero, client is not registered with the bus scaling driver,
+ *      and bus scaling functionality should not be used. When non zero, it
+ *      is a bus scaling client id and may be used to vote for clock path.
+ * @reg_err when true, registration error was detected and an error message was
+ *      logged. i2c will attempt to re-register but will log error only once.
+ *      once registration succeed, the flag is set to false.
+ * @actv_only when set, votes when system active and removes the vote when
+ *       system goes idle (optimises for performance). When unset, voting using
+ *       runtime pm (optimizes for power).
+ */
+struct qup_i2c_clk_path_vote {
+	u32                         mstr_id;
+	u32                         client_hdl;
+	struct msm_bus_scale_pdata *pdata;
+	bool                        reg_err;
+	bool                        actv_only;
+};
+
+/*
+ * i2c_msm_resources: OS resources
+ *
+ * @mem  I2C controller memory resource from platform data.
+ * @base I2C controller virtual base address
+ * @clk_freq_in core clock frequency in Hz
+ * @clk_freq_out bus clock frequency in Hz
+ */
+struct i2c_msm_resources {
+	struct resource             *mem;
+	void __iomem                *base; /* virtual */
+	struct clk                  *core_clk;
+	struct clk                  *iface_clk;
+	int                          clk_freq_in;
+	int                          clk_freq_out;
+	struct qup_i2c_clk_path_vote clk_path_vote;
+	int                          irq;
+	bool                         disable_dma;
+	struct pinctrl              *pinctrl;
+	struct pinctrl_state        *gpio_state_active;
+	struct pinctrl_state        *gpio_state_suspend;
+};
+
+#define I2C_MSM_PINCTRL_ACTIVE       "i2c_active"
+#define I2C_MSM_PINCTRL_SUSPEND      "i2c_sleep"
+
+/*
+ * i2c_msm_xfer_buf: current xfer position and preprocessed tags
+ *
+ * @is_init the buf is marked initialized by the first call to
+ *          i2c_msm_xfer_next_buf()
+ * @msg_idx   index of the message that the buffer is pointing to
+ * @byte_idx  index of first byte in the current buffer
+ * @end_idx   count of bytes processed from the current message. This value
+ *            is compared against len to find out if buffer is done processing.
+ * @len       number of bytes in current buffer.
+ * @is_rx when true, current buffer is pointing to a i2c read operation.
+ * @slv_addr 8 bit address. This is the i2c_msg->addr + rd/wr bit.
+ *
+ * Keep track of current position in the client's transfer request and
+ * pre-process a transfer's buffer and tags.
+ */
+struct i2c_msm_xfer_buf {
+	bool                       is_init;
+	int                        msg_idx;
+	int                        byte_idx;
+	int                        end_idx;
+	int                        len;
+	bool                       is_rx;
+	bool                       is_last;
+	u16                        slv_addr;
+	struct i2c_msm_tag         in_tag;
+	struct i2c_msm_tag         out_tag;
+};
+
+#ifdef DEBUG
+#define I2C_MSM_PROF_MAX_EVNTS   (64)
+#else
+#define I2C_MSM_PROF_MAX_EVNTS   (16)
+#endif
+
+/*
+ * i2c_msm_prof_event: profiling event
+ *
+ * @data Additional data about the event. The interpretation of the data is
+ *       dependent on the type field.
+ * @type event type (see enum i2c_msm_prof_event_type)
+ */
+struct i2c_msm_prof_event {
+	struct timespec time;
+	u64             data0;
+	u32             data1;
+	u32             data2;
+	u8              type;
+	u8              dump_func_id;
+};
+
+enum i2c_msm_err {
+	I2C_MSM_NO_ERR = 0,
+	I2C_MSM_ERR_NACK,
+	I2C_MSM_ERR_ARB_LOST,
+	I2C_MSM_ERR_BUS_ERR,
+	I2C_MSM_ERR_TIMEOUT,
+	I2C_MSM_ERR_CORE_CLK,
+	I2C_MSM_ERR_OVR_UNDR_RUN,
+};
+
+/*
+ * i2c_msm_xfer: A client transfer request. A list of one or more i2c messages
+ *
+ * @msgs         NULL when no active xfer. Points to array of i2c_msgs
+ *               given by the client.
+ * @msg_cnt      number of messages in msgs array.
+ * @complete     completion object to wait on for end of transfer.
+ * @rx_cnt       number of input  bytes in the client's request.
+ * @tx_cnt       number of output bytes in the client's request.
+ * @rx_ovrhd_cnt number of input  bytes due to tags.
+ * @tx_ovrhd_cnt number of output bytes due to tags.
+ * @event        profiling data. An array of timestamps of transfer events
+ * @event_cnt    number of items in event array.
+ * @is_active    true during xfer process and false after xfer end
+ * @mtx          mutex to solve multithreaded problem in xfer
+ */
+struct i2c_msm_xfer {
+	struct i2c_msg            *msgs;
+	int                        msg_cnt;
+	enum i2c_msm_xfer_mode_id  mode_id;
+	struct completion          complete;
+	struct completion          rx_complete;
+	size_t                     rx_cnt;
+	size_t                     tx_cnt;
+	size_t                     rx_ovrhd_cnt;
+	size_t                     tx_ovrhd_cnt;
+	struct i2c_msm_xfer_buf    cur_buf;
+	u32                        timeout;
+	bool                       last_is_rx;
+	enum i2c_msm_err           err;
+	struct i2c_msm_prof_event  event[I2C_MSM_PROF_MAX_EVNTS];
+	atomic_t                   event_cnt;
+	atomic_t                   is_active;
+	struct mutex               mtx;
+	struct i2c_msm_xfer_mode_fifo	fifo;
+	struct i2c_msm_xfer_mode_blk	blk;
+	struct i2c_msm_xfer_mode_dma	dma;
+};
+
+/*
+ * i2c_msm_ctrl: the driver's main struct
+ *
+ * @is_init true when
+ * @ver info that is different between i2c controller versions
+ * @ver_num  ha
+ * @xfer     state of the currently processed transfer.
+ * @dbgfs    debug-fs root and values that may be set via debug-fs.
+ * @rsrcs    resources from platform data including clocks, gpios, irqs, and
+ *           memory regions.
+ * @mstr_clk_ctl cached value for programming to mstr_clk_ctl register
+ * @i2c_sts_reg	 status of QUP_I2C_MASTER_STATUS register.
+ * @qup_op_reg	 status of QUP_OPERATIONAL register.
+ */
+struct i2c_msm_ctrl {
+	struct device             *dev;
+	struct i2c_adapter         adapter;
+	struct i2c_msm_xfer        xfer;
+	struct i2c_msm_dbgfs       dbgfs;
+	struct i2c_msm_resources   rsrcs;
+	u32                        mstr_clk_ctl;
+	u32			   i2c_sts_reg;
+	u32			   qup_op_reg;
+	enum i2c_msm_power_state   pwr_state;
+};
+
+/* Enum for the profiling event types */
+enum i2c_msm_prof_evnt_type {
+	I2C_MSM_VALID_END,
+	I2C_MSM_PIP_DSCN,
+	I2C_MSM_PIP_CNCT,
+	I2C_MSM_ACTV_END,
+	I2C_MSM_IRQ_BGN,
+	I2C_MSM_IRQ_END,
+	I2C_MSM_XFER_BEG,
+	I2C_MSM_XFER_END,
+	I2C_MSM_SCAN_SUM,
+	I2C_MSM_NEXT_BUF,
+	I2C_MSM_COMPLT_OK,
+	I2C_MSM_COMPLT_FL,
+	I2C_MSM_PROF_RESET,
+};
+
+#ifdef CONFIG_I2C_MSM_PROF_DBG
+void i2c_msm_dbgfs_init(struct i2c_msm_ctrl *ctrl);
+
+void i2c_msm_dbgfs_teardown(struct i2c_msm_ctrl *ctrl);
+
+/* diagonisis the i2c registers and dump the errors accordingly */
+const char *i2c_msm_dbg_tag_to_str(const struct i2c_msm_tag *tag,
+						char *buf, size_t buf_len);
+
+void i2c_msm_prof_evnt_dump(struct i2c_msm_ctrl *ctrl);
+
+/* function definitions to be used from the i2c-msm-v2-debug file */
+void i2c_msm_prof_evnt_add(struct i2c_msm_ctrl *ctrl,
+				enum msm_i2_debug_level dbg_level,
+				enum i2c_msm_prof_evnt_type event,
+				u64 data0, u32 data1, u32 data2);
+
+int i2c_msm_dbg_qup_reg_dump(struct i2c_msm_ctrl *ctrl);
+
+const char *
+i2c_msm_dbg_dma_tag_to_str(const struct i2c_msm_dma_tag *dma_tag, char *buf,
+								size_t buf_len);
+#else
+/* use dummy functions */
+static inline void i2c_msm_dbgfs_init(struct i2c_msm_ctrl *ctrl) {}
+static inline void i2c_msm_dbgfs_teardown(struct i2c_msm_ctrl *ctrl) {}
+
+static inline const char *i2c_msm_dbg_tag_to_str(const struct i2c_msm_tag *tag,
+						char *buf, size_t buf_len)
+{
+	return NULL;
+}
+static inline void i2c_msm_prof_evnt_dump(struct i2c_msm_ctrl *ctrl) {}
+
+/* function definitions to be used from the i2c-msm-v2-debug file */
+static inline void i2c_msm_prof_evnt_add(struct i2c_msm_ctrl *ctrl,
+				enum msm_i2_debug_level dbg_level,
+				enum i2c_msm_prof_evnt_type event,
+				u64 data0, u32 data1, u32 data2) {}
+
+static inline int i2c_msm_dbg_qup_reg_dump(struct i2c_msm_ctrl *ctrl)
+{
+	return true;
+}
+static inline const char *i2c_msm_dbg_dma_tag_to_str(const struct
+			i2c_msm_dma_tag * dma_tag, char *buf, size_t buf_len)
+{
+	return NULL;
+}
+#endif /* I2C_MSM_V2_PROF_DBG */
+#endif /* _I2C_MSM_V2_H */
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 0b8aedf..99eb77a 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -142,6 +142,7 @@
 	DOMAIN_ATTR_PAGE_TABLE_IS_COHERENT,
 	DOMAIN_ATTR_PAGE_TABLE_FORCE_COHERENT,
 	DOMAIN_ATTR_CB_STALL_DISABLE,
+	DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR,
 	DOMAIN_ATTR_MAX,
 };
 
diff --git a/include/linux/ipa.h b/include/linux/ipa.h
index 6e664f6..f8e7e8c 100644
--- a/include/linux/ipa.h
+++ b/include/linux/ipa.h
@@ -671,7 +671,8 @@
  */
 enum ipa_voltage_level {
 	IPA_VOLTAGE_UNSPECIFIED,
-	IPA_VOLTAGE_SVS = IPA_VOLTAGE_UNSPECIFIED,
+	IPA_VOLTAGE_SVS2 = IPA_VOLTAGE_UNSPECIFIED,
+	IPA_VOLTAGE_SVS,
 	IPA_VOLTAGE_NOMINAL,
 	IPA_VOLTAGE_TURBO,
 	IPA_VOLTAGE_MAX,
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index b7e3431..c122409 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -450,6 +450,8 @@
 	return !!(val & ICC_SRE_EL1_SRE);
 }
 
+void gic_show_pending_irqs(void);
+unsigned int get_gic_highpri_irq(void);
 #endif
 
 #endif
diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h
index 86a2dc6..073391b 100644
--- a/include/linux/mailbox_client.h
+++ b/include/linux/mailbox_client.h
@@ -44,7 +44,7 @@
 					      const char *name);
 struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index);
 int mbox_send_message(struct mbox_chan *chan, void *mssg);
-int mbox_send_controller_data(struct mbox_chan *chan, void *mssg);
+int mbox_write_controller_data(struct mbox_chan *chan, void *mssg);
 void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */
 bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */
 void mbox_free_channel(struct mbox_chan *chan); /* may sleep */
diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
index 7827c68..751b354 100644
--- a/include/linux/mailbox_controller.h
+++ b/include/linux/mailbox_controller.h
@@ -24,8 +24,8 @@
  *		transmission of data is reported by the controller via
  *		mbox_chan_txdone (if it has some TX ACK irq). It must not
  *		sleep.
- * @send_controller_data:
- *		Send data for the controller driver. This could be data to
+ * @write_controller_data:
+ *		Write data for the controller driver. This could be data to
  *		configure the controller or data that may be cached in the
  *		controller and not transmitted immediately. There is no ACK
  *		for this request and the request is not buffered in the
@@ -54,7 +54,7 @@
  */
 struct mbox_chan_ops {
 	int (*send_data)(struct mbox_chan *chan, void *data);
-	int (*send_controller_data)(struct mbox_chan *chan, void *data);
+	int (*write_controller_data)(struct mbox_chan *chan, void *data);
 	int (*startup)(struct mbox_chan *chan);
 	void (*shutdown)(struct mbox_chan *chan);
 	bool (*last_tx_done)(struct mbox_chan *chan);
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 37e5178..600c905 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -64,6 +64,7 @@
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __meminit
 #define __initdata_memblock __meminitdata
+void memblock_discard(void);
 #else
 #define __init_memblock
 #define __initdata_memblock
@@ -77,8 +78,6 @@
 					int nid, ulong flags);
 phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
 				   phys_addr_t size, phys_addr_t align);
-phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
-phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
 void memblock_allow_resize(void);
 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
 int memblock_add(phys_addr_t base, phys_addr_t size);
@@ -114,6 +113,9 @@
 void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start,
 				phys_addr_t *out_end);
 
+void __memblock_free_early(phys_addr_t base, phys_addr_t size);
+void __memblock_free_late(phys_addr_t base, phys_addr_t size);
+
 /**
  * for_each_mem_range - iterate through memblock areas from type_a and not
  * included in type_b. Or just type_a if type_b is NULL.
diff --git a/include/linux/mfd/msm-cdc-pinctrl.h b/include/linux/mfd/msm-cdc-pinctrl.h
deleted file mode 100644
index 7eabefb..0000000
--- a/include/linux/mfd/msm-cdc-pinctrl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __MFD_CDC_PINCTRL_H_
-#define __MFD_CDC_PINCTRL_H_
-
-#include <linux/types.h>
-#include <linux/of.h>
-
-#if IS_ENABLED(CONFIG_MSM_CDC_PINCTRL)
-extern int msm_cdc_pinctrl_select_sleep_state(struct device_node *np);
-extern int msm_cdc_pinctrl_select_active_state(struct device_node *np);
-extern bool msm_cdc_pinctrl_get_state(struct device_node *np);
-extern int msm_cdc_get_gpio_state(struct device_node *np);
-int msm_cdc_pinctrl_drv_init(void);
-void msm_cdc_pinctrl_drv_exit(void);
-
-#else
-int msm_cdc_pinctrl_select_sleep_state(struct device_node *np)
-{
-	return 0;
-}
-int msm_cdc_pinctrl_select_active_state(struct device_node *np)
-{
-	return 0;
-}
-int msm_cdc_get_gpio_state(struct device_node *np)
-{
-	return 0;
-}
-int msm_cdc_pinctrl_drv_init(void)
-{
-	return 0;
-}
-void msm_cdc_pinctrl_drv_exit(void)
-{
-}
-#endif
-
-#endif
diff --git a/include/linux/mfd/msm-cdc-supply.h b/include/linux/mfd/msm-cdc-supply.h
deleted file mode 100644
index b40f44b..0000000
--- a/include/linux/mfd/msm-cdc-supply.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CODEC_POWER_SUPPLY_H__
-#define __CODEC_POWER_SUPPLY_H__
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/regulator/consumer.h>
-
-struct cdc_regulator {
-	const char *name;
-	int min_uV;
-	int max_uV;
-	int optimum_uA;
-	bool ondemand;
-	struct regulator *regulator;
-};
-
-extern int msm_cdc_get_power_supplies(struct device *dev,
-				      struct cdc_regulator **cdc_vreg,
-				      int *total_num_supplies);
-extern int msm_cdc_disable_static_supplies(struct device *dev,
-					struct regulator_bulk_data *supplies,
-					struct cdc_regulator *cdc_vreg,
-					int num_supplies);
-extern int msm_cdc_release_supplies(struct device *dev,
-				    struct regulator_bulk_data *supplies,
-				    struct cdc_regulator *cdc_vreg,
-				    int num_supplies);
-extern int msm_cdc_enable_static_supplies(struct device *dev,
-					  struct regulator_bulk_data *supplies,
-					  struct cdc_regulator *cdc_vreg,
-					  int num_supplies);
-extern int msm_cdc_init_supplies(struct device *dev,
-				 struct regulator_bulk_data **supplies,
-				 struct cdc_regulator *cdc_vreg,
-				 int num_supplies);
-#endif
diff --git a/include/linux/mfd/wcd9335/irq.h b/include/linux/mfd/wcd9335/irq.h
deleted file mode 100644
index c666d31..0000000
--- a/include/linux/mfd/wcd9335/irq.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9335_IRQ_H_
-#define __WCD9335_IRQ_H_
-
-enum {
-	/* INTR_REG 0 */
-	WCD9335_IRQ_FLL_LOCK_LOSS = 1,
-	WCD9335_IRQ_HPH_PA_OCPL_FAULT,
-	WCD9335_IRQ_HPH_PA_OCPR_FAULT,
-	WCD9335_IRQ_EAR_PA_OCP_FAULT,
-	WCD9335_IRQ_HPH_PA_CNPL_COMPLETE,
-	WCD9335_IRQ_HPH_PA_CNPR_COMPLETE,
-	WCD9335_IRQ_EAR_PA_CNP_COMPLETE,
-	/* INTR_REG 1 */
-	WCD9335_IRQ_MBHC_SW_DET,
-	WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
-	WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
-	WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
-	WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
-	WCD9335_IRQ_RESERVED_0,
-	WCD9335_IRQ_RESERVED_1,
-	WCD9335_IRQ_RESERVED_2,
-	/* INTR_REG 2 */
-	WCD9335_IRQ_LINE_PA1_CNP_COMPLETE,
-	WCD9335_IRQ_LINE_PA2_CNP_COMPLETE,
-	WCD9335_IRQ_LINE_PA3_CNP_COMPLETE,
-	WCD9335_IRQ_LINE_PA4_CNP_COMPLETE,
-	WCD9335_IRQ_SOUNDWIRE,
-	WCD9335_IRQ_VDD_DIG_RAMP_COMPLETE,
-	WCD9335_IRQ_RCO_ERROR,
-	WCD9335_IRQ_SVA_ERROR,
-	/* INTR_REG 3 */
-	WCD9335_IRQ_MAD_AUDIO,
-	WCD9335_IRQ_MAD_BEACON,
-	WCD9335_IRQ_MAD_ULTRASOUND,
-	WCD9335_IRQ_VBAT_ATTACK,
-	WCD9335_IRQ_VBAT_RESTORE,
-	WCD9335_IRQ_SVA_OUTBOX1,
-	WCD9335_IRQ_SVA_OUTBOX2,
-	WCD9335_NUM_IRQS,
-};
-
-#endif
diff --git a/include/linux/mfd/wcd9335/registers.h b/include/linux/mfd/wcd9335/registers.h
deleted file mode 100644
index c50430d..0000000
--- a/include/linux/mfd/wcd9335/registers.h
+++ /dev/null
@@ -1,1348 +0,0 @@
-/*
- * Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _WCD9335_REGISTERS_H
-#define _WCD9335_REGISTERS_H
-
-#define WCD9335_PAGE_SIZE 256
-#define WCD9335_NUM_PAGES 256
-
-extern const u8 *wcd9335_reg[WCD9335_NUM_PAGES];
-
-enum {
-	PAGE_0 = 0,
-	PAGE_1,
-	PAGE_2,
-	PAGE_6 = 6,
-	PAGE_10 = 0xA,
-	PAGE_11,
-	PAGE_12,
-	PAGE_13,
-	PAGE_0X80,
-};
-
-/* Page-0 Registers */
-#define WCD9335_PAGE0_PAGE_REGISTER                      0x0000
-#define WCD9335_CODEC_RPM_CLK_BYPASS                     0x0001
-#define WCD9335_CODEC_RPM_CLK_GATE                       0x0002
-#define WCD9335_CODEC_RPM_CLK_MCLK_CFG                   0x0003
-#define WCD9335_CODEC_RPM_RST_CTL                        0x0009
-#define WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL             0x0011
-#define WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_1              0x0012
-#define WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_2              0x0013
-#define WCD9335_CODEC_RPM_PWR_CPE_DEEPSLP_3              0x0014
-#define WCD9335_CODEC_RPM_PWR_CPE_IRAM_SHUTDOWN          0x0015
-#define WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN         0x0016
-#define WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_1       0x0017
-#define WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_2       0x0018
-#define WCD9335_CODEC_RPM_INT_MASK                       0x001d
-#define WCD9335_CODEC_RPM_INT_STATUS                     0x001e
-#define WCD9335_CODEC_RPM_INT_CLEAR                      0x001f
-#define WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE0             0x0021
-#define WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE1             0x0022
-#define WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE2             0x0023
-#define WCD9335_CHIP_TIER_CTRL_CHIP_ID_BYTE3             0x0024
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_CTL                 0x0025
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_TEST0               0x0026
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_TEST1               0x0027
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0            0x0029
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1            0x002a
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2            0x002b
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT3            0x002c
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT4            0x002d
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT5            0x002e
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT6            0x002f
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT7            0x0030
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT8            0x0031
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT9            0x0032
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10           0x0033
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11           0x0034
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12           0x0035
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT13           0x0036
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT14           0x0037
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT15           0x0038
-#define WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS              0x0039
-#define WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO      0x003a
-#define WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_1            0x003b
-#define WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_2            0x003c
-#define WCD9335_CHIP_TIER_CTRL_I2C_SLAVE_ID_3            0x003d
-#define WCD9335_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL        0x003e
-#define WCD9335_CHIP_TIER_CTRL_I2C_ACTIVE                0x003f
-#define WCD9335_CHIP_TIER_CTRL_PROC1_MON_CTL             0x0041
-#define WCD9335_CHIP_TIER_CTRL_PROC1_MON_STATUS          0x0042
-#define WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_MSB         0x0043
-#define WCD9335_CHIP_TIER_CTRL_PROC1_MON_CNT_LSB         0x0044
-#define WCD9335_CHIP_TIER_CTRL_PROC2_MON_CTL             0x0045
-#define WCD9335_CHIP_TIER_CTRL_PROC2_MON_STATUS          0x0046
-#define WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_MSB         0x0047
-#define WCD9335_CHIP_TIER_CTRL_PROC2_MON_CNT_LSB         0x0048
-#define WCD9335_CHIP_TIER_CTRL_PROC3_MON_CTL             0x0049
-#define WCD9335_CHIP_TIER_CTRL_PROC3_MON_STATUS          0x004a
-#define WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_MSB         0x004b
-#define WCD9335_CHIP_TIER_CTRL_PROC3_MON_CNT_LSB         0x004c
-#define WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL             0x0051
-#define WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL             0x0052
-#define WCD9335_DATA_HUB_DATA_HUB_I2S_CLK                0x0053
-#define WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG            0x0054
-#define WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG            0x0055
-#define WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG            0x0056
-#define WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG            0x0057
-#define WCD9335_DATA_HUB_DATA_HUB_RX4_INP_CFG            0x0058
-#define WCD9335_DATA_HUB_DATA_HUB_RX5_INP_CFG            0x0059
-#define WCD9335_DATA_HUB_DATA_HUB_RX6_INP_CFG            0x005a
-#define WCD9335_DATA_HUB_DATA_HUB_RX7_INP_CFG            0x005b
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX0_INP_CFG         0x0061
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX1_INP_CFG         0x0062
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX2_INP_CFG         0x0063
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX3_INP_CFG         0x0064
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX4_INP_CFG         0x0065
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX5_INP_CFG         0x0066
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX6_INP_CFG         0x0067
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX7_INP_CFG         0x0068
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX8_INP_CFG         0x0069
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX9_INP_CFG         0x006a
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX10_INP_CFG        0x006b
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG        0x006c
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG        0x006e
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX14_INP_CFG        0x006f
-#define WCD9335_DATA_HUB_DATA_HUB_SB_TX15_INP_CFG        0x0070
-#define WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG       0x0071
-#define WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG       0x0072
-#define WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG       0x0073
-#define WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG       0x0074
-#define WCD9335_DATA_HUB_NATIVE_FIFO_SYNC                0x0075
-#define WCD9335_DATA_HUB_NATIVE_FIFO_STATUS              0x007D
-#define WCD9335_INTR_CFG                                 0x0081
-#define WCD9335_INTR_CLR_COMMIT                          0x0082
-#define WCD9335_INTR_PIN1_MASK0                          0x0089
-#define WCD9335_INTR_PIN1_MASK1                          0x008a
-#define WCD9335_INTR_PIN1_MASK2                          0x008b
-#define WCD9335_INTR_PIN1_MASK3                          0x008c
-#define WCD9335_INTR_PIN1_STATUS0                        0x0091
-#define WCD9335_INTR_PIN1_STATUS1                        0x0092
-#define WCD9335_INTR_PIN1_STATUS2                        0x0093
-#define WCD9335_INTR_PIN1_STATUS3                        0x0094
-#define WCD9335_INTR_PIN1_CLEAR0                         0x0099
-#define WCD9335_INTR_PIN1_CLEAR1                         0x009a
-#define WCD9335_INTR_PIN1_CLEAR2                         0x009b
-#define WCD9335_INTR_PIN1_CLEAR3                         0x009c
-#define WCD9335_INTR_PIN2_MASK0                          0x00a1
-#define WCD9335_INTR_PIN2_MASK1                          0x00a2
-#define WCD9335_INTR_PIN2_MASK2                          0x00a3
-#define WCD9335_INTR_PIN2_MASK3                          0x00a4
-#define WCD9335_INTR_PIN2_STATUS0                        0x00a9
-#define WCD9335_INTR_PIN2_STATUS1                        0x00aa
-#define WCD9335_INTR_PIN2_STATUS2                        0x00ab
-#define WCD9335_INTR_PIN2_STATUS3                        0x00ac
-#define WCD9335_INTR_PIN2_CLEAR0                         0x00b1
-#define WCD9335_INTR_PIN2_CLEAR1                         0x00b2
-#define WCD9335_INTR_PIN2_CLEAR2                         0x00b3
-#define WCD9335_INTR_PIN2_CLEAR3                         0x00b4
-#define WCD9335_INTR_LEVEL0                              0x00e1
-#define WCD9335_INTR_LEVEL1                              0x00e2
-#define WCD9335_INTR_LEVEL2                              0x00e3
-#define WCD9335_INTR_LEVEL3                              0x00e4
-#define WCD9335_INTR_BYPASS0                             0x00e9
-#define WCD9335_INTR_BYPASS1                             0x00ea
-#define WCD9335_INTR_BYPASS2                             0x00eb
-#define WCD9335_INTR_BYPASS3                             0x00ec
-#define WCD9335_INTR_SET0                                0x00f1
-#define WCD9335_INTR_SET1                                0x00f2
-#define WCD9335_INTR_SET2                                0x00f3
-#define WCD9335_INTR_SET3                                0x00f4
-
-/* Page-1 Registers */
-#define WCD9335_PAGE1_PAGE_REGISTER                      0x0100
-#define WCD9335_CPE_FLL_USER_CTL_0                       0x0101
-#define WCD9335_CPE_FLL_USER_CTL_1                       0x0102
-#define WCD9335_CPE_FLL_USER_CTL_2                       0x0103
-#define WCD9335_CPE_FLL_USER_CTL_3                       0x0104
-#define WCD9335_CPE_FLL_USER_CTL_4                       0x0105
-#define WCD9335_CPE_FLL_USER_CTL_5                       0x0106
-#define WCD9335_CPE_FLL_USER_CTL_6                       0x0107
-#define WCD9335_CPE_FLL_USER_CTL_7                       0x0108
-#define WCD9335_CPE_FLL_USER_CTL_8                       0x0109
-#define WCD9335_CPE_FLL_USER_CTL_9                       0x010a
-#define WCD9335_CPE_FLL_L_VAL_CTL_0                      0x010b
-#define WCD9335_CPE_FLL_L_VAL_CTL_1                      0x010c
-#define WCD9335_CPE_FLL_DSM_FRAC_CTL_0                   0x010d
-#define WCD9335_CPE_FLL_DSM_FRAC_CTL_1                   0x010e
-#define WCD9335_CPE_FLL_CONFIG_CTL_0                     0x010f
-#define WCD9335_CPE_FLL_CONFIG_CTL_1                     0x0110
-#define WCD9335_CPE_FLL_CONFIG_CTL_2                     0x0111
-#define WCD9335_CPE_FLL_CONFIG_CTL_3                     0x0112
-#define WCD9335_CPE_FLL_CONFIG_CTL_4                     0x0113
-#define WCD9335_CPE_FLL_TEST_CTL_0                       0x0114
-#define WCD9335_CPE_FLL_TEST_CTL_1                       0x0115
-#define WCD9335_CPE_FLL_TEST_CTL_2                       0x0116
-#define WCD9335_CPE_FLL_TEST_CTL_3                       0x0117
-#define WCD9335_CPE_FLL_TEST_CTL_4                       0x0118
-#define WCD9335_CPE_FLL_TEST_CTL_5                       0x0119
-#define WCD9335_CPE_FLL_TEST_CTL_6                       0x011a
-#define WCD9335_CPE_FLL_TEST_CTL_7                       0x011b
-#define WCD9335_CPE_FLL_FREQ_CTL_0                       0x011c
-#define WCD9335_CPE_FLL_FREQ_CTL_1                       0x011d
-#define WCD9335_CPE_FLL_FREQ_CTL_2                       0x011e
-#define WCD9335_CPE_FLL_FREQ_CTL_3                       0x011f
-#define WCD9335_CPE_FLL_SSC_CTL_0                        0x0120
-#define WCD9335_CPE_FLL_SSC_CTL_1                        0x0121
-#define WCD9335_CPE_FLL_SSC_CTL_2                        0x0122
-#define WCD9335_CPE_FLL_SSC_CTL_3                        0x0123
-#define WCD9335_CPE_FLL_FLL_MODE                         0x0124
-#define WCD9335_CPE_FLL_STATUS_0                         0x0125
-#define WCD9335_CPE_FLL_STATUS_1                         0x0126
-#define WCD9335_CPE_FLL_STATUS_2                         0x0127
-#define WCD9335_CPE_FLL_STATUS_3                         0x0128
-#define WCD9335_I2S_FLL_USER_CTL_0                       0x0141
-#define WCD9335_I2S_FLL_USER_CTL_1                       0x0142
-#define WCD9335_I2S_FLL_USER_CTL_2                       0x0143
-#define WCD9335_I2S_FLL_USER_CTL_3                       0x0144
-#define WCD9335_I2S_FLL_USER_CTL_4                       0x0145
-#define WCD9335_I2S_FLL_USER_CTL_5                       0x0146
-#define WCD9335_I2S_FLL_USER_CTL_6                       0x0147
-#define WCD9335_I2S_FLL_USER_CTL_7                       0x0148
-#define WCD9335_I2S_FLL_USER_CTL_8                       0x0149
-#define WCD9335_I2S_FLL_USER_CTL_9                       0x014a
-#define WCD9335_I2S_FLL_L_VAL_CTL_0                      0x014b
-#define WCD9335_I2S_FLL_L_VAL_CTL_1                      0x014c
-#define WCD9335_I2S_FLL_DSM_FRAC_CTL_0                   0x014d
-#define WCD9335_I2S_FLL_DSM_FRAC_CTL_1                   0x014e
-#define WCD9335_I2S_FLL_CONFIG_CTL_0                     0x014f
-#define WCD9335_I2S_FLL_CONFIG_CTL_1                     0x0150
-#define WCD9335_I2S_FLL_CONFIG_CTL_2                     0x0151
-#define WCD9335_I2S_FLL_CONFIG_CTL_3                     0x0152
-#define WCD9335_I2S_FLL_CONFIG_CTL_4                     0x0153
-#define WCD9335_I2S_FLL_TEST_CTL_0                       0x0154
-#define WCD9335_I2S_FLL_TEST_CTL_1                       0x0155
-#define WCD9335_I2S_FLL_TEST_CTL_2                       0x0156
-#define WCD9335_I2S_FLL_TEST_CTL_3                       0x0157
-#define WCD9335_I2S_FLL_TEST_CTL_4                       0x0158
-#define WCD9335_I2S_FLL_TEST_CTL_5                       0x0159
-#define WCD9335_I2S_FLL_TEST_CTL_6                       0x015a
-#define WCD9335_I2S_FLL_TEST_CTL_7                       0x015b
-#define WCD9335_I2S_FLL_FREQ_CTL_0                       0x015c
-#define WCD9335_I2S_FLL_FREQ_CTL_1                       0x015d
-#define WCD9335_I2S_FLL_FREQ_CTL_2                       0x015e
-#define WCD9335_I2S_FLL_FREQ_CTL_3                       0x015f
-#define WCD9335_I2S_FLL_SSC_CTL_0                        0x0160
-#define WCD9335_I2S_FLL_SSC_CTL_1                        0x0161
-#define WCD9335_I2S_FLL_SSC_CTL_2                        0x0162
-#define WCD9335_I2S_FLL_SSC_CTL_3                        0x0163
-#define WCD9335_I2S_FLL_FLL_MODE                         0x0164
-#define WCD9335_I2S_FLL_STATUS_0                         0x0165
-#define WCD9335_I2S_FLL_STATUS_1                         0x0166
-#define WCD9335_I2S_FLL_STATUS_2                         0x0167
-#define WCD9335_I2S_FLL_STATUS_3                         0x0168
-#define WCD9335_SB_FLL_USER_CTL_0                        0x0181
-#define WCD9335_SB_FLL_USER_CTL_1                        0x0182
-#define WCD9335_SB_FLL_USER_CTL_2                        0x0183
-#define WCD9335_SB_FLL_USER_CTL_3                        0x0184
-#define WCD9335_SB_FLL_USER_CTL_4                        0x0185
-#define WCD9335_SB_FLL_USER_CTL_5                        0x0186
-#define WCD9335_SB_FLL_USER_CTL_6                        0x0187
-#define WCD9335_SB_FLL_USER_CTL_7                        0x0188
-#define WCD9335_SB_FLL_USER_CTL_8                        0x0189
-#define WCD9335_SB_FLL_USER_CTL_9                        0x018a
-#define WCD9335_SB_FLL_L_VAL_CTL_0                       0x018b
-#define WCD9335_SB_FLL_L_VAL_CTL_1                       0x018c
-#define WCD9335_SB_FLL_DSM_FRAC_CTL_0                    0x018d
-#define WCD9335_SB_FLL_DSM_FRAC_CTL_1                    0x018e
-#define WCD9335_SB_FLL_CONFIG_CTL_0                      0x018f
-#define WCD9335_SB_FLL_CONFIG_CTL_1                      0x0190
-#define WCD9335_SB_FLL_CONFIG_CTL_2                      0x0191
-#define WCD9335_SB_FLL_CONFIG_CTL_3                      0x0192
-#define WCD9335_SB_FLL_CONFIG_CTL_4                      0x0193
-#define WCD9335_SB_FLL_TEST_CTL_0                        0x0194
-#define WCD9335_SB_FLL_TEST_CTL_1                        0x0195
-#define WCD9335_SB_FLL_TEST_CTL_2                        0x0196
-#define WCD9335_SB_FLL_TEST_CTL_3                        0x0197
-#define WCD9335_SB_FLL_TEST_CTL_4                        0x0198
-#define WCD9335_SB_FLL_TEST_CTL_5                        0x0199
-#define WCD9335_SB_FLL_TEST_CTL_6                        0x019a
-#define WCD9335_SB_FLL_TEST_CTL_7                        0x019b
-#define WCD9335_SB_FLL_FREQ_CTL_0                        0x019c
-#define WCD9335_SB_FLL_FREQ_CTL_1                        0x019d
-#define WCD9335_SB_FLL_FREQ_CTL_2                        0x019e
-#define WCD9335_SB_FLL_FREQ_CTL_3                        0x019f
-#define WCD9335_SB_FLL_SSC_CTL_0                         0x01a0
-#define WCD9335_SB_FLL_SSC_CTL_1                         0x01a1
-#define WCD9335_SB_FLL_SSC_CTL_2                         0x01a2
-#define WCD9335_SB_FLL_SSC_CTL_3                         0x01a3
-#define WCD9335_SB_FLL_FLL_MODE                          0x01a4
-#define WCD9335_SB_FLL_STATUS_0                          0x01a5
-#define WCD9335_SB_FLL_STATUS_1                          0x01a6
-#define WCD9335_SB_FLL_STATUS_2                          0x01a7
-#define WCD9335_SB_FLL_STATUS_3                          0x01a8
-
-/* Page-2 Registers */
-#define WCD9335_PAGE2_PAGE_REGISTER                      0x0200
-#define WCD9335_CPE_SS_MEM_PTR_0                         0x0201
-#define WCD9335_CPE_SS_MEM_PTR_1                         0x0202
-#define WCD9335_CPE_SS_MEM_PTR_2                         0x0203
-#define WCD9335_CPE_SS_MEM_CTRL                          0x0205
-#define WCD9335_CPE_SS_MEM_BANK_0                        0x0206
-#define WCD9335_CPE_SS_MEM_BANK_1                        0x0207
-#define WCD9335_CPE_SS_MEM_BANK_2                        0x0208
-#define WCD9335_CPE_SS_MEM_BANK_3                        0x0209
-#define WCD9335_CPE_SS_MEM_BANK_4                        0x020a
-#define WCD9335_CPE_SS_MEM_BANK_5                        0x020b
-#define WCD9335_CPE_SS_MEM_BANK_6                        0x020c
-#define WCD9335_CPE_SS_MEM_BANK_7                        0x020d
-#define WCD9335_CPE_SS_MEM_BANK_8                        0x020e
-#define WCD9335_CPE_SS_MEM_BANK_9                        0x020f
-#define WCD9335_CPE_SS_MEM_BANK_10                       0x0210
-#define WCD9335_CPE_SS_MEM_BANK_11                       0x0211
-#define WCD9335_CPE_SS_MEM_BANK_12                       0x0212
-#define WCD9335_CPE_SS_MEM_BANK_13                       0x0213
-#define WCD9335_CPE_SS_MEM_BANK_14                       0x0214
-#define WCD9335_CPE_SS_MEM_BANK_15                       0x0215
-#define WCD9335_CPE_SS_INBOX1_TRG                        0x0216
-#define WCD9335_CPE_SS_INBOX2_TRG                        0x0217
-#define WCD9335_CPE_SS_INBOX1_0                          0x0218
-#define WCD9335_CPE_SS_INBOX1_1                          0x0219
-#define WCD9335_CPE_SS_INBOX1_2                          0x021a
-#define WCD9335_CPE_SS_INBOX1_3                          0x021b
-#define WCD9335_CPE_SS_INBOX1_4                          0x021c
-#define WCD9335_CPE_SS_INBOX1_5                          0x021d
-#define WCD9335_CPE_SS_INBOX1_6                          0x021e
-#define WCD9335_CPE_SS_INBOX1_7                          0x021f
-#define WCD9335_CPE_SS_INBOX1_8                          0x0220
-#define WCD9335_CPE_SS_INBOX1_9                          0x0221
-#define WCD9335_CPE_SS_INBOX1_10                         0x0222
-#define WCD9335_CPE_SS_INBOX1_11                         0x0223
-#define WCD9335_CPE_SS_INBOX1_12                         0x0224
-#define WCD9335_CPE_SS_INBOX1_13                         0x0225
-#define WCD9335_CPE_SS_INBOX1_14                         0x0226
-#define WCD9335_CPE_SS_INBOX1_15                         0x0227
-#define WCD9335_CPE_SS_OUTBOX1_0                         0x0228
-#define WCD9335_CPE_SS_OUTBOX1_1                         0x0229
-#define WCD9335_CPE_SS_OUTBOX1_2                         0x022a
-#define WCD9335_CPE_SS_OUTBOX1_3                         0x022b
-#define WCD9335_CPE_SS_OUTBOX1_4                         0x022c
-#define WCD9335_CPE_SS_OUTBOX1_5                         0x022d
-#define WCD9335_CPE_SS_OUTBOX1_6                         0x022e
-#define WCD9335_CPE_SS_OUTBOX1_7                         0x022f
-#define WCD9335_CPE_SS_OUTBOX1_8                         0x0230
-#define WCD9335_CPE_SS_OUTBOX1_9                         0x0231
-#define WCD9335_CPE_SS_OUTBOX1_10                        0x0232
-#define WCD9335_CPE_SS_OUTBOX1_11                        0x0233
-#define WCD9335_CPE_SS_OUTBOX1_12                        0x0234
-#define WCD9335_CPE_SS_OUTBOX1_13                        0x0235
-#define WCD9335_CPE_SS_OUTBOX1_14                        0x0236
-#define WCD9335_CPE_SS_OUTBOX1_15                        0x0237
-#define WCD9335_CPE_SS_INBOX2_0                          0x0238
-#define WCD9335_CPE_SS_INBOX2_1                          0x0239
-#define WCD9335_CPE_SS_INBOX2_2                          0x023a
-#define WCD9335_CPE_SS_INBOX2_3                          0x023b
-#define WCD9335_CPE_SS_INBOX2_4                          0x023c
-#define WCD9335_CPE_SS_INBOX2_5                          0x023d
-#define WCD9335_CPE_SS_INBOX2_6                          0x023e
-#define WCD9335_CPE_SS_INBOX2_7                          0x023f
-#define WCD9335_CPE_SS_INBOX2_8                          0x0240
-#define WCD9335_CPE_SS_INBOX2_9                          0x0241
-#define WCD9335_CPE_SS_INBOX2_10                         0x0242
-#define WCD9335_CPE_SS_INBOX2_11                         0x0243
-#define WCD9335_CPE_SS_INBOX2_12                         0x0244
-#define WCD9335_CPE_SS_INBOX2_13                         0x0245
-#define WCD9335_CPE_SS_INBOX2_14                         0x0246
-#define WCD9335_CPE_SS_INBOX2_15                         0x0247
-#define WCD9335_CPE_SS_OUTBOX2_0                         0x0248
-#define WCD9335_CPE_SS_OUTBOX2_1                         0x0249
-#define WCD9335_CPE_SS_OUTBOX2_2                         0x024a
-#define WCD9335_CPE_SS_OUTBOX2_3                         0x024b
-#define WCD9335_CPE_SS_OUTBOX2_4                         0x024c
-#define WCD9335_CPE_SS_OUTBOX2_5                         0x024d
-#define WCD9335_CPE_SS_OUTBOX2_6                         0x024e
-#define WCD9335_CPE_SS_OUTBOX2_7                         0x024f
-#define WCD9335_CPE_SS_OUTBOX2_8                         0x0250
-#define WCD9335_CPE_SS_OUTBOX2_9                         0x0251
-#define WCD9335_CPE_SS_OUTBOX2_10                        0x0252
-#define WCD9335_CPE_SS_OUTBOX2_11                        0x0253
-#define WCD9335_CPE_SS_OUTBOX2_12                        0x0254
-#define WCD9335_CPE_SS_OUTBOX2_13                        0x0255
-#define WCD9335_CPE_SS_OUTBOX2_14                        0x0256
-#define WCD9335_CPE_SS_OUTBOX2_15                        0x0257
-#define WCD9335_CPE_SS_OUTBOX1_ACK                       0x0258
-#define WCD9335_CPE_SS_OUTBOX2_ACK                       0x0259
-#define WCD9335_CPE_SS_EC_BUF_INT_PERIOD                 0x025a
-#define WCD9335_CPE_SS_US_BUF_INT_PERIOD                 0x025b
-#define WCD9335_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD         0x025c
-#define WCD9335_CPE_SS_CFG                               0x025d
-#define WCD9335_CPE_SS_US_EC_MUX_CFG                     0x025e
-#define WCD9335_CPE_SS_MAD_CTL                           0x025f
-#define WCD9335_CPE_SS_CPAR_CTL                          0x0260
-#define WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD              0x0261
-#define WCD9335_CPE_SS_TX_PP_CFG                         0x0262
-#define WCD9335_CPE_SS_DMIC0_CTL                         0x0263
-#define WCD9335_CPE_SS_DMIC1_CTL                         0x0264
-#define WCD9335_CPE_SS_DMIC2_CTL                         0x0265
-#define WCD9335_CPE_SS_DMIC_CFG                          0x0266
-#define WCD9335_CPE_SS_SVA_CFG                           0x0267
-#define WCD9335_CPE_SS_CPAR_CFG                          0x0271
-#define WCD9335_CPE_SS_WDOG_CFG                          0x0272
-#define WCD9335_CPE_SS_BACKUP_INT                        0x0273
-#define WCD9335_CPE_SS_STATUS                            0x0274
-#define WCD9335_CPE_SS_CPE_OCD_CFG                       0x0275
-#define WCD9335_CPE_SS_SS_ERROR_INT_MASK                 0x0276
-#define WCD9335_CPE_SS_SS_ERROR_INT_STATUS               0x0277
-#define WCD9335_CPE_SS_SS_ERROR_INT_CLEAR                0x0278
-#define WCD9335_SOC_MAD_MAIN_CTL_1                       0x0281
-#define WCD9335_SOC_MAD_MAIN_CTL_2                       0x0282
-#define WCD9335_SOC_MAD_AUDIO_CTL_1                      0x0283
-#define WCD9335_SOC_MAD_AUDIO_CTL_2                      0x0284
-#define WCD9335_SOC_MAD_AUDIO_CTL_3                      0x0285
-#define WCD9335_SOC_MAD_AUDIO_CTL_4                      0x0286
-#define WCD9335_SOC_MAD_AUDIO_CTL_5                      0x0287
-#define WCD9335_SOC_MAD_AUDIO_CTL_6                      0x0288
-#define WCD9335_SOC_MAD_AUDIO_CTL_7                      0x0289
-#define WCD9335_SOC_MAD_AUDIO_CTL_8                      0x028a
-#define WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR                0x028b
-#define WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL                0x028c
-#define WCD9335_SOC_MAD_ULTR_CTL_1                       0x028d
-#define WCD9335_SOC_MAD_ULTR_CTL_2                       0x028e
-#define WCD9335_SOC_MAD_ULTR_CTL_3                       0x028f
-#define WCD9335_SOC_MAD_ULTR_CTL_4                       0x0290
-#define WCD9335_SOC_MAD_ULTR_CTL_5                       0x0291
-#define WCD9335_SOC_MAD_ULTR_CTL_6                       0x0292
-#define WCD9335_SOC_MAD_ULTR_CTL_7                       0x0293
-#define WCD9335_SOC_MAD_BEACON_CTL_1                     0x0294
-#define WCD9335_SOC_MAD_BEACON_CTL_2                     0x0295
-#define WCD9335_SOC_MAD_BEACON_CTL_3                     0x0296
-#define WCD9335_SOC_MAD_BEACON_CTL_4                     0x0297
-#define WCD9335_SOC_MAD_BEACON_CTL_5                     0x0298
-#define WCD9335_SOC_MAD_BEACON_CTL_6                     0x0299
-#define WCD9335_SOC_MAD_BEACON_CTL_7                     0x029a
-#define WCD9335_SOC_MAD_BEACON_CTL_8                     0x029b
-#define WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR               0x029c
-#define WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL               0x029d
-#define WCD9335_SOC_MAD_INP_SEL                          0x029e
-
-/* Page-6 Registers */
-#define WCD9335_PAGE6_PAGE_REGISTER                      0x0600
-#define WCD9335_ANA_BIAS                                 0x0601
-#define WCD9335_ANA_CLK_TOP                              0x0602
-#define WCD9335_ANA_RCO                                  0x0603
-#define WCD9335_ANA_BUCK_VOUT_A                          0x0604
-#define WCD9335_ANA_BUCK_VOUT_D                          0x0605
-#define WCD9335_ANA_BUCK_CTL                             0x0606
-#define WCD9335_ANA_BUCK_STATUS                          0x0607
-#define WCD9335_ANA_RX_SUPPLIES                          0x0608
-#define WCD9335_ANA_HPH                                  0x0609
-#define WCD9335_ANA_EAR                                  0x060a
-#define WCD9335_ANA_LO_1_2                               0x060b
-#define WCD9335_ANA_LO_3_4                               0x060c
-#define WCD9335_ANA_MAD_SETUP                            0x060d
-#define WCD9335_ANA_AMIC1                                0x060e
-#define WCD9335_ANA_AMIC2                                0x060f
-#define WCD9335_ANA_AMIC3                                0x0610
-#define WCD9335_ANA_AMIC4                                0x0611
-#define WCD9335_ANA_AMIC5                                0x0612
-#define WCD9335_ANA_AMIC6                                0x0613
-#define WCD9335_ANA_MBHC_MECH                            0x0614
-#define WCD9335_ANA_MBHC_ELECT                           0x0615
-#define WCD9335_ANA_MBHC_ZDET                            0x0616
-#define WCD9335_ANA_MBHC_RESULT_1                        0x0617
-#define WCD9335_ANA_MBHC_RESULT_2                        0x0618
-#define WCD9335_ANA_MBHC_RESULT_3                        0x0619
-#define WCD9335_ANA_MBHC_BTN0                            0x061a
-#define WCD9335_ANA_MBHC_BTN1                            0x061b
-#define WCD9335_ANA_MBHC_BTN2                            0x061c
-#define WCD9335_ANA_MBHC_BTN3                            0x061d
-#define WCD9335_ANA_MBHC_BTN4                            0x061e
-#define WCD9335_ANA_MBHC_BTN5                            0x061f
-#define WCD9335_ANA_MBHC_BTN6                            0x0620
-#define WCD9335_ANA_MBHC_BTN7                            0x0621
-#define WCD9335_ANA_MICB1                                0x0622
-#define WCD9335_ANA_MICB2                                0x0623
-#define WCD9335_ANA_MICB2_RAMP                           0x0624
-#define WCD9335_ANA_MICB3                                0x0625
-#define WCD9335_ANA_MICB4                                0x0626
-#define WCD9335_ANA_VBADC                                0x0627
-#define WCD9335_BIAS_CTL                                 0x0628
-#define WCD9335_BIAS_VBG_FINE_ADJ                        0x0629
-#define WCD9335_CLOCK_TEST_CTL                           0x062d
-#define WCD9335_RCO_CTRL_1                               0x062e
-#define WCD9335_RCO_CTRL_2                               0x062f
-#define WCD9335_RCO_CAL                                  0x0630
-#define WCD9335_RCO_CAL_1                                0x0631
-#define WCD9335_RCO_CAL_2                                0x0632
-#define WCD9335_RCO_TEST_CTRL                            0x0633
-#define WCD9335_RCO_CAL_OUT_1                            0x0634
-#define WCD9335_RCO_CAL_OUT_2                            0x0635
-#define WCD9335_RCO_CAL_OUT_3                            0x0636
-#define WCD9335_RCO_CAL_OUT_4                            0x0637
-#define WCD9335_RCO_CAL_OUT_5                            0x0638
-#define WCD9335_SIDO_SIDO_MODE_1                         0x063a
-#define WCD9335_SIDO_SIDO_MODE_2                         0x063b
-#define WCD9335_SIDO_SIDO_MODE_3                         0x063c
-#define WCD9335_SIDO_SIDO_MODE_4                         0x063d
-#define WCD9335_SIDO_SIDO_VCL_1                          0x063e
-#define WCD9335_SIDO_SIDO_VCL_2                          0x063f
-#define WCD9335_SIDO_SIDO_VCL_3                          0x0640
-#define WCD9335_SIDO_SIDO_CCL_1                          0x0641
-#define WCD9335_SIDO_SIDO_CCL_2                          0x0642
-#define WCD9335_SIDO_SIDO_CCL_3                          0x0643
-#define WCD9335_SIDO_SIDO_CCL_4                          0x0644
-#define WCD9335_SIDO_SIDO_CCL_5                          0x0645
-#define WCD9335_SIDO_SIDO_CCL_6                          0x0646
-#define WCD9335_SIDO_SIDO_CCL_7                          0x0647
-#define WCD9335_SIDO_SIDO_CCL_8                          0x0648
-#define WCD9335_SIDO_SIDO_CCL_9                          0x0649
-#define WCD9335_SIDO_SIDO_CCL_10                         0x064a
-#define WCD9335_SIDO_SIDO_FILTER_1                       0x064b
-#define WCD9335_SIDO_SIDO_FILTER_2                       0x064c
-#define WCD9335_SIDO_SIDO_DRIVER_1                       0x064d
-#define WCD9335_SIDO_SIDO_DRIVER_2                       0x064e
-#define WCD9335_SIDO_SIDO_DRIVER_3                       0x064f
-#define WCD9335_SIDO_SIDO_CAL_CODE_EXT_1                 0x0650
-#define WCD9335_SIDO_SIDO_CAL_CODE_EXT_2                 0x0651
-#define WCD9335_SIDO_SIDO_CAL_CODE_OUT_1                 0x0652
-#define WCD9335_SIDO_SIDO_CAL_CODE_OUT_2                 0x0653
-#define WCD9335_SIDO_SIDO_TEST_1                         0x0654
-#define WCD9335_SIDO_SIDO_TEST_2                         0x0655
-#define WCD9335_MBHC_CTL_1                               0x0656
-#define WCD9335_MBHC_CTL_2                               0x0657
-#define WCD9335_MBHC_PLUG_DETECT_CTL                     0x0658
-#define WCD9335_MBHC_ZDET_ANA_CTL                        0x0659
-#define WCD9335_MBHC_ZDET_RAMP_CTL                       0x065a
-#define WCD9335_MBHC_FSM_DEBUG                           0x065b /* v1.x */
-#define WCD9335_MBHC_FSM_STATUS                          0x065b /* v2.0 */
-#define WCD9335_MBHC_TEST_CTL                            0x065c
-#define WCD9335_VBADC_SUBBLOCK_EN                        0x065d
-#define WCD9335_VBADC_IBIAS_FE                           0x065e
-#define WCD9335_VBADC_BIAS_ADC                           0x065f
-#define WCD9335_VBADC_FE_CTRL                            0x0660
-#define WCD9335_VBADC_ADC_REF                            0x0661
-#define WCD9335_VBADC_ADC_IO                             0x0662
-#define WCD9335_VBADC_ADC_SAR                            0x0663
-#define WCD9335_VBADC_DEBUG                              0x0664
-#define WCD9335_VBADC_ADC_DOUTMSB                        0x0665
-#define WCD9335_VBADC_ADC_DOUTLSB                        0x0666
-#define WCD9335_LDOH_MODE                                0x0667
-#define WCD9335_LDOH_BIAS                                0x0668
-#define WCD9335_LDOH_STB_LOADS                           0x0669
-#define WCD9335_LDOH_SLOWRAMP                            0x066a
-#define WCD9335_MICB1_TEST_CTL_1                         0x066b
-#define WCD9335_MICB1_TEST_CTL_2                         0x066c
-#define WCD9335_MICB1_TEST_CTL_3                         0x066d
-#define WCD9335_MICB2_TEST_CTL_1                         0x066e
-#define WCD9335_MICB2_TEST_CTL_2                         0x066f
-#define WCD9335_MICB2_TEST_CTL_3                         0x0670
-#define WCD9335_MICB3_TEST_CTL_1                         0x0671
-#define WCD9335_MICB3_TEST_CTL_2                         0x0672
-#define WCD9335_MICB3_TEST_CTL_3                         0x0673
-#define WCD9335_MICB4_TEST_CTL_1                         0x0674
-#define WCD9335_MICB4_TEST_CTL_2                         0x0675
-#define WCD9335_MICB4_TEST_CTL_3                         0x0676
-#define WCD9335_TX_COM_ADC_VCM                           0x0677
-#define WCD9335_TX_COM_BIAS_ATEST                        0x0678
-#define WCD9335_TX_COM_ADC_INT1_IB                       0x0679
-#define WCD9335_TX_COM_ADC_INT2_IB                       0x067a
-#define WCD9335_TX_COM_TXFE_DIV_CTL                      0x067b
-#define WCD9335_TX_COM_TXFE_DIV_START                    0x067c
-#define WCD9335_TX_COM_TXFE_DIV_STOP_9P6M                0x067d
-#define WCD9335_TX_COM_TXFE_DIV_STOP_12P288M             0x067e
-#define WCD9335_TX_1_2_TEST_EN                           0x067f
-#define WCD9335_TX_1_2_ADC_IB                            0x0680
-#define WCD9335_TX_1_2_ATEST_REFCTL                      0x0681
-#define WCD9335_TX_1_2_TEST_CTL                          0x0682
-#define WCD9335_TX_1_2_TEST_BLK_EN                       0x0683
-#define WCD9335_TX_1_2_TXFE_CLKDIV                       0x0684
-#define WCD9335_TX_1_2_SAR1_ERR                          0x0685
-#define WCD9335_TX_1_2_SAR2_ERR                          0x0686
-#define WCD9335_TX_3_4_TEST_EN                           0x0687
-#define WCD9335_TX_3_4_ADC_IB                            0x0688
-#define WCD9335_TX_3_4_ATEST_REFCTL                      0x0689
-#define WCD9335_TX_3_4_TEST_CTL                          0x068a
-#define WCD9335_TX_3_4_TEST_BLK_EN                       0x068b
-#define WCD9335_TX_3_4_TXFE_CLKDIV                       0x068c
-#define WCD9335_TX_3_4_SAR1_ERR                          0x068d
-#define WCD9335_TX_3_4_SAR2_ERR                          0x068e
-#define WCD9335_TX_5_6_TEST_EN                           0x068f
-#define WCD9335_TX_5_6_ADC_IB                            0x0690
-#define WCD9335_TX_5_6_ATEST_REFCTL                      0x0691
-#define WCD9335_TX_5_6_TEST_CTL                          0x0692
-#define WCD9335_TX_5_6_TEST_BLK_EN                       0x0693
-#define WCD9335_TX_5_6_TXFE_CLKDIV                       0x0694
-#define WCD9335_TX_5_6_SAR1_ERR                          0x0695
-#define WCD9335_TX_5_6_SAR2_ERR                          0x0696
-#define WCD9335_CLASSH_MODE_1                            0x0697
-#define WCD9335_CLASSH_MODE_2                            0x0698
-#define WCD9335_CLASSH_MODE_3                            0x0699
-#define WCD9335_CLASSH_CTRL_VCL_1                        0x069a
-#define WCD9335_CLASSH_CTRL_VCL_2                        0x069b
-#define WCD9335_CLASSH_CTRL_CCL_1                        0x069c
-#define WCD9335_CLASSH_CTRL_CCL_2                        0x069d
-#define WCD9335_CLASSH_CTRL_CCL_3                        0x069e
-#define WCD9335_CLASSH_CTRL_CCL_4                        0x069f
-#define WCD9335_CLASSH_CTRL_CCL_5                        0x06a0
-#define WCD9335_CLASSH_BUCK_TMUX_A_D                     0x06a1
-#define WCD9335_CLASSH_BUCK_SW_DRV_CNTL                  0x06a2
-#define WCD9335_CLASSH_SPARE                             0x06a3
-#define WCD9335_FLYBACK_EN                               0x06a4
-#define WCD9335_FLYBACK_VNEG_CTRL_1                      0x06a5
-#define WCD9335_FLYBACK_VNEG_CTRL_2                      0x06a6
-#define WCD9335_FLYBACK_VNEG_CTRL_3                      0x06a7
-#define WCD9335_FLYBACK_VNEG_CTRL_4                      0x06a8
-#define WCD9335_FLYBACK_VNEG_CTRL_5                      0x06a9
-#define WCD9335_FLYBACK_VNEG_CTRL_6                      0x06aa
-#define WCD9335_FLYBACK_VNEG_CTRL_7                      0x06ab
-#define WCD9335_FLYBACK_VNEG_CTRL_8                      0x06ac
-#define WCD9335_FLYBACK_VNEG_CTRL_9                      0x06ad
-#define WCD9335_FLYBACK_VNEG_DAC_CTRL_1                  0x06ae
-#define WCD9335_FLYBACK_VNEG_DAC_CTRL_2                  0x06af
-#define WCD9335_FLYBACK_VNEG_DAC_CTRL_3                  0x06b0
-#define WCD9335_FLYBACK_VNEG_DAC_CTRL_4                  0x06b1 /* v1.x */
-#define WCD9335_FLYBACK_CTRL_1                           0x06b1 /* v2.0 */
-#define WCD9335_FLYBACK_TEST_CTL                         0x06b2
-#define WCD9335_RX_AUX_SW_CTL                            0x06b3
-#define WCD9335_RX_PA_AUX_IN_CONN                        0x06b4
-#define WCD9335_RX_TIMER_DIV                             0x06b5
-#define WCD9335_RX_OCP_CTL                               0x06b6
-#define WCD9335_RX_OCP_COUNT                             0x06b7
-#define WCD9335_RX_BIAS_EAR_DAC                          0x06b8
-#define WCD9335_RX_BIAS_EAR_AMP                          0x06b9
-#define WCD9335_RX_BIAS_HPH_LDO                          0x06ba
-#define WCD9335_RX_BIAS_HPH_PA                           0x06bb
-#define WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2                0x06bc
-#define WCD9335_RX_BIAS_HPH_RDAC_LDO                     0x06bd
-#define WCD9335_RX_BIAS_HPH_CNP1                         0x06be
-#define WCD9335_RX_BIAS_HPH_LOWPOWER                     0x06bf
-#define WCD9335_RX_BIAS_DIFFLO_PA                        0x06c0
-#define WCD9335_RX_BIAS_DIFFLO_REF                       0x06c1
-#define WCD9335_RX_BIAS_DIFFLO_LDO                       0x06c2
-#define WCD9335_RX_BIAS_SELO_DAC_PA                      0x06c3
-#define WCD9335_RX_BIAS_BUCK_RST                         0x06c4
-#define WCD9335_RX_BIAS_BUCK_VREF_ERRAMP                 0x06c5
-#define WCD9335_RX_BIAS_FLYB_ERRAMP                      0x06c6
-#define WCD9335_RX_BIAS_FLYB_BUFF                        0x06c7
-#define WCD9335_RX_BIAS_FLYB_MID_RST                     0x06c8
-#define WCD9335_HPH_L_STATUS                             0x06c9
-#define WCD9335_HPH_R_STATUS                             0x06ca
-#define WCD9335_HPH_CNP_EN                               0x06cb
-#define WCD9335_HPH_CNP_WG_CTL                           0x06cc
-#define WCD9335_HPH_CNP_WG_TIME                          0x06cd
-#define WCD9335_HPH_OCP_CTL                              0x06ce
-#define WCD9335_HPH_AUTO_CHOP                            0x06cf
-#define WCD9335_HPH_CHOP_CTL                             0x06d0
-#define WCD9335_HPH_PA_CTL1                              0x06d1
-#define WCD9335_HPH_PA_CTL2                              0x06d2
-#define WCD9335_HPH_L_EN                                 0x06d3
-#define WCD9335_HPH_L_TEST                               0x06d4
-#define WCD9335_HPH_L_ATEST                              0x06d5
-#define WCD9335_HPH_R_EN                                 0x06d6
-#define WCD9335_HPH_R_TEST                               0x06d7
-#define WCD9335_HPH_R_ATEST                              0x06d8
-#define WCD9335_HPH_RDAC_CLK_CTL1                        0x06d9
-#define WCD9335_HPH_RDAC_CLK_CTL2                        0x06da
-#define WCD9335_HPH_RDAC_LDO_CTL                         0x06db
-#define WCD9335_HPH_RDAC_CHOP_CLK_LP_CTL                 0x06dc
-#define WCD9335_HPH_REFBUFF_UHQA_CTL                     0x06dd
-#define WCD9335_HPH_REFBUFF_LP_CTL                       0x06de
-#define WCD9335_HPH_L_DAC_CTL                            0x06df
-#define WCD9335_HPH_R_DAC_CTL                            0x06e0
-#define WCD9335_EAR_EN_REG                               0x06e1
-#define WCD9335_EAR_CMBUFF                               0x06e2
-#define WCD9335_EAR_ICTL                                 0x06e3
-#define WCD9335_EAR_EN_DBG_CTL                           0x06e4
-#define WCD9335_EAR_CNP                                  0x06e5
-#define WCD9335_EAR_DAC_CTL_ATEST                        0x06e6
-#define WCD9335_EAR_STATUS_REG                           0x06e7
-#define WCD9335_EAR_OUT_SHORT                            0x06e8
-#define WCD9335_DIFF_LO_MISC                             0x06e9
-#define WCD9335_DIFF_LO_LO2_COMPANDER                    0x06ea
-#define WCD9335_DIFF_LO_LO1_COMPANDER                    0x06eb
-#define WCD9335_DIFF_LO_COMMON                           0x06ec
-#define WCD9335_DIFF_LO_BYPASS_EN                        0x06ed
-#define WCD9335_DIFF_LO_CNP                              0x06ee
-#define WCD9335_DIFF_LO_CORE_OUT_PROG                    0x06ef
-#define WCD9335_DIFF_LO_LDO_OUT_PROG                     0x06f0
-#define WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ            0x06f1
-#define WCD9335_DIFF_LO_COM_PA_FREQ                      0x06f2
-#define WCD9335_DIFF_LO_RESERVED_REG                     0x06f3
-#define WCD9335_DIFF_LO_LO1_STATUS_1                     0x06f4
-#define WCD9335_DIFF_LO_LO1_STATUS_2                     0x06f5
-#define WCD9335_SE_LO_COM1                               0x06f6
-#define WCD9335_SE_LO_COM2                               0x06f7
-#define WCD9335_SE_LO_LO3_GAIN                           0x06f8
-#define WCD9335_SE_LO_LO3_CTRL                           0x06f9
-#define WCD9335_SE_LO_LO4_GAIN                           0x06fa
-#define WCD9335_SE_LO_LO4_CTRL                           0x06fb
-#define WCD9335_SE_LO_LO3_STATUS                         0x06fe
-#define WCD9335_SE_LO_LO4_STATUS                         0x06ff
-
-/* Page-10 Registers */
-#define WCD9335_PAGE10_PAGE_REGISTER                     0x0a00
-#define WCD9335_CDC_ANC0_CLK_RESET_CTL                   0x0a01
-#define WCD9335_CDC_ANC0_MODE_1_CTL                      0x0a02
-#define WCD9335_CDC_ANC0_MODE_2_CTL                      0x0a03
-#define WCD9335_CDC_ANC0_FF_SHIFT                        0x0a04
-#define WCD9335_CDC_ANC0_FB_SHIFT                        0x0a05
-#define WCD9335_CDC_ANC0_LPF_FF_A_CTL                    0x0a06
-#define WCD9335_CDC_ANC0_LPF_FF_B_CTL                    0x0a07
-#define WCD9335_CDC_ANC0_LPF_FB_CTL                      0x0a08
-#define WCD9335_CDC_ANC0_SMLPF_CTL                       0x0a09
-#define WCD9335_CDC_ANC0_DCFLT_SHIFT_CTL                 0x0a0a
-#define WCD9335_CDC_ANC0_IIR_ADAPT_CTL                   0x0a0b
-#define WCD9335_CDC_ANC0_IIR_COEFF_1_CTL                 0x0a0c
-#define WCD9335_CDC_ANC0_IIR_COEFF_2_CTL                 0x0a0d
-#define WCD9335_CDC_ANC0_FF_A_GAIN_CTL                   0x0a0e
-#define WCD9335_CDC_ANC0_FF_B_GAIN_CTL                   0x0a0f
-#define WCD9335_CDC_ANC0_FB_GAIN_CTL                     0x0a10
-#define WCD9335_CDC_ANC1_CLK_RESET_CTL                   0x0a19
-#define WCD9335_CDC_ANC1_MODE_1_CTL                      0x0a1a
-#define WCD9335_CDC_ANC1_MODE_2_CTL                      0x0a1b
-#define WCD9335_CDC_ANC1_FF_SHIFT                        0x0a1c
-#define WCD9335_CDC_ANC1_FB_SHIFT                        0x0a1d
-#define WCD9335_CDC_ANC1_LPF_FF_A_CTL                    0x0a1e
-#define WCD9335_CDC_ANC1_LPF_FF_B_CTL                    0x0a1f
-#define WCD9335_CDC_ANC1_LPF_FB_CTL                      0x0a20
-#define WCD9335_CDC_ANC1_SMLPF_CTL                       0x0a21
-#define WCD9335_CDC_ANC1_DCFLT_SHIFT_CTL                 0x0a22
-#define WCD9335_CDC_ANC1_IIR_ADAPT_CTL                   0x0a23
-#define WCD9335_CDC_ANC1_IIR_COEFF_1_CTL                 0x0a24
-#define WCD9335_CDC_ANC1_IIR_COEFF_2_CTL                 0x0a25
-#define WCD9335_CDC_ANC1_FF_A_GAIN_CTL                   0x0a26
-#define WCD9335_CDC_ANC1_FF_B_GAIN_CTL                   0x0a27
-#define WCD9335_CDC_ANC1_FB_GAIN_CTL                     0x0a28
-#define WCD9335_CDC_TX0_TX_PATH_CTL                      0x0a31
-#define WCD9335_CDC_TX0_TX_PATH_CFG0                     0x0a32
-#define WCD9335_CDC_TX0_TX_PATH_CFG1                     0x0a33
-#define WCD9335_CDC_TX0_TX_VOL_CTL                       0x0a34
-#define WCD9335_CDC_TX0_TX_PATH_192_CTL                  0x0a35
-#define WCD9335_CDC_TX0_TX_PATH_192_CFG                  0x0a36
-#define WCD9335_CDC_TX0_TX_PATH_SEC0                     0x0a37
-#define WCD9335_CDC_TX0_TX_PATH_SEC1                     0x0a38
-#define WCD9335_CDC_TX0_TX_PATH_SEC2                     0x0a39
-#define WCD9335_CDC_TX0_TX_PATH_SEC3                     0x0a3a
-#define WCD9335_CDC_TX0_TX_PATH_SEC4                     0x0a3b
-#define WCD9335_CDC_TX0_TX_PATH_SEC5                     0x0a3c
-#define WCD9335_CDC_TX0_TX_PATH_SEC6                     0x0a3d
-#define WCD9335_CDC_TX0_TX_PATH_SEC7                     0x0a3e
-#define WCD9335_CDC_TX1_TX_PATH_CTL                      0x0a41
-#define WCD9335_CDC_TX1_TX_PATH_CFG0                     0x0a42
-#define WCD9335_CDC_TX1_TX_PATH_CFG1                     0x0a43
-#define WCD9335_CDC_TX1_TX_VOL_CTL                       0x0a44
-#define WCD9335_CDC_TX1_TX_PATH_192_CTL                  0x0a45
-#define WCD9335_CDC_TX1_TX_PATH_192_CFG                  0x0a46
-#define WCD9335_CDC_TX1_TX_PATH_SEC0                     0x0a47
-#define WCD9335_CDC_TX1_TX_PATH_SEC1                     0x0a48
-#define WCD9335_CDC_TX1_TX_PATH_SEC2                     0x0a49
-#define WCD9335_CDC_TX1_TX_PATH_SEC3                     0x0a4a
-#define WCD9335_CDC_TX1_TX_PATH_SEC4                     0x0a4b
-#define WCD9335_CDC_TX1_TX_PATH_SEC5                     0x0a4c
-#define WCD9335_CDC_TX1_TX_PATH_SEC6                     0x0a4d
-#define WCD9335_CDC_TX2_TX_PATH_CTL                      0x0a51
-#define WCD9335_CDC_TX2_TX_PATH_CFG0                     0x0a52
-#define WCD9335_CDC_TX2_TX_PATH_CFG1                     0x0a53
-#define WCD9335_CDC_TX2_TX_VOL_CTL                       0x0a54
-#define WCD9335_CDC_TX2_TX_PATH_192_CTL                  0x0a55
-#define WCD9335_CDC_TX2_TX_PATH_192_CFG                  0x0a56
-#define WCD9335_CDC_TX2_TX_PATH_SEC0                     0x0a57
-#define WCD9335_CDC_TX2_TX_PATH_SEC1                     0x0a58
-#define WCD9335_CDC_TX2_TX_PATH_SEC2                     0x0a59
-#define WCD9335_CDC_TX2_TX_PATH_SEC3                     0x0a5a
-#define WCD9335_CDC_TX2_TX_PATH_SEC4                     0x0a5b
-#define WCD9335_CDC_TX2_TX_PATH_SEC5                     0x0a5c
-#define WCD9335_CDC_TX2_TX_PATH_SEC6                     0x0a5d
-#define WCD9335_CDC_TX3_TX_PATH_CTL                      0x0a61
-#define WCD9335_CDC_TX3_TX_PATH_CFG0                     0x0a62
-#define WCD9335_CDC_TX3_TX_PATH_CFG1                     0x0a63
-#define WCD9335_CDC_TX3_TX_VOL_CTL                       0x0a64
-#define WCD9335_CDC_TX3_TX_PATH_192_CTL                  0x0a65
-#define WCD9335_CDC_TX3_TX_PATH_192_CFG                  0x0a66
-#define WCD9335_CDC_TX3_TX_PATH_SEC0                     0x0a67
-#define WCD9335_CDC_TX3_TX_PATH_SEC1                     0x0a68
-#define WCD9335_CDC_TX3_TX_PATH_SEC2                     0x0a69
-#define WCD9335_CDC_TX3_TX_PATH_SEC3                     0x0a6a
-#define WCD9335_CDC_TX3_TX_PATH_SEC4                     0x0a6b
-#define WCD9335_CDC_TX3_TX_PATH_SEC5                     0x0a6c
-#define WCD9335_CDC_TX3_TX_PATH_SEC6                     0x0a6d
-#define WCD9335_CDC_TX4_TX_PATH_CTL                      0x0a71
-#define WCD9335_CDC_TX4_TX_PATH_CFG0                     0x0a72
-#define WCD9335_CDC_TX4_TX_PATH_CFG1                     0x0a73
-#define WCD9335_CDC_TX4_TX_VOL_CTL                       0x0a74
-#define WCD9335_CDC_TX4_TX_PATH_192_CTL                  0x0a75
-#define WCD9335_CDC_TX4_TX_PATH_192_CFG                  0x0a76
-#define WCD9335_CDC_TX4_TX_PATH_SEC0                     0x0a77
-#define WCD9335_CDC_TX4_TX_PATH_SEC1                     0x0a78
-#define WCD9335_CDC_TX4_TX_PATH_SEC2                     0x0a79
-#define WCD9335_CDC_TX4_TX_PATH_SEC3                     0x0a7a
-#define WCD9335_CDC_TX4_TX_PATH_SEC4                     0x0a7b
-#define WCD9335_CDC_TX4_TX_PATH_SEC5                     0x0a7c
-#define WCD9335_CDC_TX4_TX_PATH_SEC6                     0x0a7d
-#define WCD9335_CDC_TX5_TX_PATH_CTL                      0x0a81
-#define WCD9335_CDC_TX5_TX_PATH_CFG0                     0x0a82
-#define WCD9335_CDC_TX5_TX_PATH_CFG1                     0x0a83
-#define WCD9335_CDC_TX5_TX_VOL_CTL                       0x0a84
-#define WCD9335_CDC_TX5_TX_PATH_192_CTL                  0x0a85
-#define WCD9335_CDC_TX5_TX_PATH_192_CFG                  0x0a86
-#define WCD9335_CDC_TX5_TX_PATH_SEC0                     0x0a87
-#define WCD9335_CDC_TX5_TX_PATH_SEC1                     0x0a88
-#define WCD9335_CDC_TX5_TX_PATH_SEC2                     0x0a89
-#define WCD9335_CDC_TX5_TX_PATH_SEC3                     0x0a8a
-#define WCD9335_CDC_TX5_TX_PATH_SEC4                     0x0a8b
-#define WCD9335_CDC_TX5_TX_PATH_SEC5                     0x0a8c
-#define WCD9335_CDC_TX5_TX_PATH_SEC6                     0x0a8d
-#define WCD9335_CDC_TX6_TX_PATH_CTL                      0x0a91
-#define WCD9335_CDC_TX6_TX_PATH_CFG0                     0x0a92
-#define WCD9335_CDC_TX6_TX_PATH_CFG1                     0x0a93
-#define WCD9335_CDC_TX6_TX_VOL_CTL                       0x0a94
-#define WCD9335_CDC_TX6_TX_PATH_192_CTL                  0x0a95
-#define WCD9335_CDC_TX6_TX_PATH_192_CFG                  0x0a96
-#define WCD9335_CDC_TX6_TX_PATH_SEC0                     0x0a97
-#define WCD9335_CDC_TX6_TX_PATH_SEC1                     0x0a98
-#define WCD9335_CDC_TX6_TX_PATH_SEC2                     0x0a99
-#define WCD9335_CDC_TX6_TX_PATH_SEC3                     0x0a9a
-#define WCD9335_CDC_TX6_TX_PATH_SEC4                     0x0a9b
-#define WCD9335_CDC_TX6_TX_PATH_SEC5                     0x0a9c
-#define WCD9335_CDC_TX6_TX_PATH_SEC6                     0x0a9d
-#define WCD9335_CDC_TX7_TX_PATH_CTL                      0x0aa1
-#define WCD9335_CDC_TX7_TX_PATH_CFG0                     0x0aa2
-#define WCD9335_CDC_TX7_TX_PATH_CFG1                     0x0aa3
-#define WCD9335_CDC_TX7_TX_VOL_CTL                       0x0aa4
-#define WCD9335_CDC_TX7_TX_PATH_192_CTL                  0x0aa5
-#define WCD9335_CDC_TX7_TX_PATH_192_CFG                  0x0aa6
-#define WCD9335_CDC_TX7_TX_PATH_SEC0                     0x0aa7
-#define WCD9335_CDC_TX7_TX_PATH_SEC1                     0x0aa8
-#define WCD9335_CDC_TX7_TX_PATH_SEC2                     0x0aa9
-#define WCD9335_CDC_TX7_TX_PATH_SEC3                     0x0aaa
-#define WCD9335_CDC_TX7_TX_PATH_SEC4                     0x0aab
-#define WCD9335_CDC_TX7_TX_PATH_SEC5                     0x0aac
-#define WCD9335_CDC_TX7_TX_PATH_SEC6                     0x0aad
-#define WCD9335_CDC_TX8_TX_PATH_CTL                      0x0ab1
-#define WCD9335_CDC_TX8_TX_PATH_CFG0                     0x0ab2
-#define WCD9335_CDC_TX8_TX_PATH_CFG1                     0x0ab3
-#define WCD9335_CDC_TX8_TX_VOL_CTL                       0x0ab4
-#define WCD9335_CDC_TX8_TX_PATH_192_CTL                  0x0ab5
-#define WCD9335_CDC_TX8_TX_PATH_192_CFG                  0x0ab6
-#define WCD9335_CDC_TX8_TX_PATH_SEC0                     0x0ab7
-#define WCD9335_CDC_TX8_TX_PATH_SEC1                     0x0ab8
-#define WCD9335_CDC_TX8_TX_PATH_SEC2                     0x0ab9
-#define WCD9335_CDC_TX8_TX_PATH_SEC3                     0x0aba
-#define WCD9335_CDC_TX8_TX_PATH_SEC4                     0x0abb
-#define WCD9335_CDC_TX8_TX_PATH_SEC5                     0x0abc
-#define WCD9335_CDC_TX8_TX_PATH_SEC6                     0x0abd
-#define WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL               0x0ac2
-#define WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0              0x0ac3
-#define WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL              0x0ac6
-#define WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0             0x0ac7
-#define WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL              0x0aca
-#define WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0             0x0acb
-#define WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL              0x0ace
-#define WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0             0x0acf
-
-/* Page-11 Registers */
-#define WCD9335_PAGE11_PAGE_REGISTER                     0x0b00
-#define WCD9335_CDC_COMPANDER1_CTL0                      0x0b01
-#define WCD9335_CDC_COMPANDER1_CTL1                      0x0b02
-#define WCD9335_CDC_COMPANDER1_CTL2                      0x0b03
-#define WCD9335_CDC_COMPANDER1_CTL3                      0x0b04
-#define WCD9335_CDC_COMPANDER1_CTL4                      0x0b05
-#define WCD9335_CDC_COMPANDER1_CTL5                      0x0b06
-#define WCD9335_CDC_COMPANDER1_CTL6                      0x0b07
-#define WCD9335_CDC_COMPANDER1_CTL7                      0x0b08
-#define WCD9335_CDC_COMPANDER2_CTL0                      0x0b09
-#define WCD9335_CDC_COMPANDER2_CTL1                      0x0b0a
-#define WCD9335_CDC_COMPANDER2_CTL2                      0x0b0b
-#define WCD9335_CDC_COMPANDER2_CTL3                      0x0b0c
-#define WCD9335_CDC_COMPANDER2_CTL4                      0x0b0d
-#define WCD9335_CDC_COMPANDER2_CTL5                      0x0b0e
-#define WCD9335_CDC_COMPANDER2_CTL6                      0x0b0f
-#define WCD9335_CDC_COMPANDER2_CTL7                      0x0b10
-#define WCD9335_CDC_COMPANDER3_CTL0                      0x0b11
-#define WCD9335_CDC_COMPANDER3_CTL1                      0x0b12
-#define WCD9335_CDC_COMPANDER3_CTL2                      0x0b13
-#define WCD9335_CDC_COMPANDER3_CTL3                      0x0b14
-#define WCD9335_CDC_COMPANDER3_CTL4                      0x0b15
-#define WCD9335_CDC_COMPANDER3_CTL5                      0x0b16
-#define WCD9335_CDC_COMPANDER3_CTL6                      0x0b17
-#define WCD9335_CDC_COMPANDER3_CTL7                      0x0b18
-#define WCD9335_CDC_COMPANDER4_CTL0                      0x0b19
-#define WCD9335_CDC_COMPANDER4_CTL1                      0x0b1a
-#define WCD9335_CDC_COMPANDER4_CTL2                      0x0b1b
-#define WCD9335_CDC_COMPANDER4_CTL3                      0x0b1c
-#define WCD9335_CDC_COMPANDER4_CTL4                      0x0b1d
-#define WCD9335_CDC_COMPANDER4_CTL5                      0x0b1e
-#define WCD9335_CDC_COMPANDER4_CTL6                      0x0b1f
-#define WCD9335_CDC_COMPANDER4_CTL7                      0x0b20
-#define WCD9335_CDC_COMPANDER5_CTL0                      0x0b21
-#define WCD9335_CDC_COMPANDER5_CTL1                      0x0b22
-#define WCD9335_CDC_COMPANDER5_CTL2                      0x0b23
-#define WCD9335_CDC_COMPANDER5_CTL3                      0x0b24
-#define WCD9335_CDC_COMPANDER5_CTL4                      0x0b25
-#define WCD9335_CDC_COMPANDER5_CTL5                      0x0b26
-#define WCD9335_CDC_COMPANDER5_CTL6                      0x0b27
-#define WCD9335_CDC_COMPANDER5_CTL7                      0x0b28
-#define WCD9335_CDC_COMPANDER6_CTL0                      0x0b29
-#define WCD9335_CDC_COMPANDER6_CTL1                      0x0b2a
-#define WCD9335_CDC_COMPANDER6_CTL2                      0x0b2b
-#define WCD9335_CDC_COMPANDER6_CTL3                      0x0b2c
-#define WCD9335_CDC_COMPANDER6_CTL4                      0x0b2d
-#define WCD9335_CDC_COMPANDER6_CTL5                      0x0b2e
-#define WCD9335_CDC_COMPANDER6_CTL6                      0x0b2f
-#define WCD9335_CDC_COMPANDER6_CTL7                      0x0b30
-#define WCD9335_CDC_COMPANDER7_CTL0                      0x0b31
-#define WCD9335_CDC_COMPANDER7_CTL1                      0x0b32
-#define WCD9335_CDC_COMPANDER7_CTL2                      0x0b33
-#define WCD9335_CDC_COMPANDER7_CTL3                      0x0b34
-#define WCD9335_CDC_COMPANDER7_CTL4                      0x0b35
-#define WCD9335_CDC_COMPANDER7_CTL5                      0x0b36
-#define WCD9335_CDC_COMPANDER7_CTL6                      0x0b37
-#define WCD9335_CDC_COMPANDER7_CTL7                      0x0b38
-#define WCD9335_CDC_COMPANDER8_CTL0                      0x0b39
-#define WCD9335_CDC_COMPANDER8_CTL1                      0x0b3a
-#define WCD9335_CDC_COMPANDER8_CTL2                      0x0b3b
-#define WCD9335_CDC_COMPANDER8_CTL3                      0x0b3c
-#define WCD9335_CDC_COMPANDER8_CTL4                      0x0b3d
-#define WCD9335_CDC_COMPANDER8_CTL5                      0x0b3e
-#define WCD9335_CDC_COMPANDER8_CTL6                      0x0b3f
-#define WCD9335_CDC_COMPANDER8_CTL7                      0x0b40
-#define WCD9335_CDC_RX0_RX_PATH_CTL                      0x0b41
-#define WCD9335_CDC_RX0_RX_PATH_CFG0                     0x0b42
-#define WCD9335_CDC_RX0_RX_PATH_CFG1                     0x0b43
-#define WCD9335_CDC_RX0_RX_PATH_CFG2                     0x0b44
-#define WCD9335_CDC_RX0_RX_VOL_CTL                       0x0b45
-#define WCD9335_CDC_RX0_RX_PATH_MIX_CTL                  0x0b46
-#define WCD9335_CDC_RX0_RX_PATH_MIX_CFG                  0x0b47
-#define WCD9335_CDC_RX0_RX_VOL_MIX_CTL                   0x0b48
-#define WCD9335_CDC_RX0_RX_PATH_SEC0                     0x0b49
-#define WCD9335_CDC_RX0_RX_PATH_SEC1                     0x0b4a
-#define WCD9335_CDC_RX0_RX_PATH_SEC2                     0x0b4b
-#define WCD9335_CDC_RX0_RX_PATH_SEC3                     0x0b4c
-#define WCD9335_CDC_RX0_RX_PATH_SEC5                     0x0b4e
-#define WCD9335_CDC_RX0_RX_PATH_SEC6                     0x0b4f
-#define WCD9335_CDC_RX0_RX_PATH_SEC7                     0x0b50
-#define WCD9335_CDC_RX0_RX_PATH_MIX_SEC0                 0x0b51
-#define WCD9335_CDC_RX0_RX_PATH_MIX_SEC1                 0x0b52
-#define WCD9335_CDC_RX1_RX_PATH_CTL                      0x0b55
-#define WCD9335_CDC_RX1_RX_PATH_CFG0                     0x0b56
-#define WCD9335_CDC_RX1_RX_PATH_CFG1                     0x0b57
-#define WCD9335_CDC_RX1_RX_PATH_CFG2                     0x0b58
-#define WCD9335_CDC_RX1_RX_VOL_CTL                       0x0b59
-#define WCD9335_CDC_RX1_RX_PATH_MIX_CTL                  0x0b5a
-#define WCD9335_CDC_RX1_RX_PATH_MIX_CFG                  0x0b5b
-#define WCD9335_CDC_RX1_RX_VOL_MIX_CTL                   0x0b5c
-#define WCD9335_CDC_RX1_RX_PATH_SEC0                     0x0b5d
-#define WCD9335_CDC_RX1_RX_PATH_SEC1                     0x0b5e
-#define WCD9335_CDC_RX1_RX_PATH_SEC2                     0x0b5f
-#define WCD9335_CDC_RX1_RX_PATH_SEC3                     0x0b60
-#define WCD9335_CDC_RX1_RX_PATH_SEC4                     0x0b61
-#define WCD9335_CDC_RX1_RX_PATH_SEC5                     0x0b62
-#define WCD9335_CDC_RX1_RX_PATH_SEC6                     0x0b63
-#define WCD9335_CDC_RX1_RX_PATH_SEC7                     0x0b64
-#define WCD9335_CDC_RX1_RX_PATH_MIX_SEC0                 0x0b65
-#define WCD9335_CDC_RX1_RX_PATH_MIX_SEC1                 0x0b66
-#define WCD9335_CDC_RX2_RX_PATH_CTL                      0x0b69
-#define WCD9335_CDC_RX2_RX_PATH_CFG0                     0x0b6a
-#define WCD9335_CDC_RX2_RX_PATH_CFG1                     0x0b6b
-#define WCD9335_CDC_RX2_RX_PATH_CFG2                     0x0b6c
-#define WCD9335_CDC_RX2_RX_VOL_CTL                       0x0b6d
-#define WCD9335_CDC_RX2_RX_PATH_MIX_CTL                  0x0b6e
-#define WCD9335_CDC_RX2_RX_PATH_MIX_CFG                  0x0b6f
-#define WCD9335_CDC_RX2_RX_VOL_MIX_CTL                   0x0b70
-#define WCD9335_CDC_RX2_RX_PATH_SEC0                     0x0b71
-#define WCD9335_CDC_RX2_RX_PATH_SEC1                     0x0b72
-#define WCD9335_CDC_RX2_RX_PATH_SEC2                     0x0b73
-#define WCD9335_CDC_RX2_RX_PATH_SEC3                     0x0b74
-#define WCD9335_CDC_RX2_RX_PATH_SEC4                     0x0b75
-#define WCD9335_CDC_RX2_RX_PATH_SEC5                     0x0b76
-#define WCD9335_CDC_RX2_RX_PATH_SEC6                     0x0b77
-#define WCD9335_CDC_RX2_RX_PATH_SEC7                     0x0b78
-#define WCD9335_CDC_RX2_RX_PATH_MIX_SEC0                 0x0b79
-#define WCD9335_CDC_RX2_RX_PATH_MIX_SEC1                 0x0b7a
-#define WCD9335_CDC_RX3_RX_PATH_CTL                      0x0b7d
-#define WCD9335_CDC_RX3_RX_PATH_CFG0                     0x0b7e
-#define WCD9335_CDC_RX3_RX_PATH_CFG1                     0x0b7f
-#define WCD9335_CDC_RX3_RX_PATH_CFG2                     0x0b80
-#define WCD9335_CDC_RX3_RX_VOL_CTL                       0x0b81
-#define WCD9335_CDC_RX3_RX_PATH_MIX_CTL                  0x0b82
-#define WCD9335_CDC_RX3_RX_PATH_MIX_CFG                  0x0b83
-#define WCD9335_CDC_RX3_RX_VOL_MIX_CTL                   0x0b84
-#define WCD9335_CDC_RX3_RX_PATH_SEC0                     0x0b85
-#define WCD9335_CDC_RX3_RX_PATH_SEC1                     0x0b86
-#define WCD9335_CDC_RX3_RX_PATH_SEC2                     0x0b87
-#define WCD9335_CDC_RX3_RX_PATH_SEC3                     0x0b88
-#define WCD9335_CDC_RX3_RX_PATH_SEC5                     0x0b8a
-#define WCD9335_CDC_RX3_RX_PATH_SEC6                     0x0b8b
-#define WCD9335_CDC_RX3_RX_PATH_SEC7                     0x0b8c
-#define WCD9335_CDC_RX3_RX_PATH_MIX_SEC0                 0x0b8d
-#define WCD9335_CDC_RX3_RX_PATH_MIX_SEC1                 0x0b8e
-#define WCD9335_CDC_RX4_RX_PATH_CTL                      0x0b91
-#define WCD9335_CDC_RX4_RX_PATH_CFG0                     0x0b92
-#define WCD9335_CDC_RX4_RX_PATH_CFG1                     0x0b93
-#define WCD9335_CDC_RX4_RX_PATH_CFG2                     0x0b94
-#define WCD9335_CDC_RX4_RX_VOL_CTL                       0x0b95
-#define WCD9335_CDC_RX4_RX_PATH_MIX_CTL                  0x0b96
-#define WCD9335_CDC_RX4_RX_PATH_MIX_CFG                  0x0b97
-#define WCD9335_CDC_RX4_RX_VOL_MIX_CTL                   0x0b98
-#define WCD9335_CDC_RX4_RX_PATH_SEC0                     0x0b99
-#define WCD9335_CDC_RX4_RX_PATH_SEC1                     0x0b9a
-#define WCD9335_CDC_RX4_RX_PATH_SEC2                     0x0b9b
-#define WCD9335_CDC_RX4_RX_PATH_SEC3                     0x0b9c
-#define WCD9335_CDC_RX4_RX_PATH_SEC5                     0x0b9e
-#define WCD9335_CDC_RX4_RX_PATH_SEC6                     0x0b9f
-#define WCD9335_CDC_RX4_RX_PATH_SEC7                     0x0ba0
-#define WCD9335_CDC_RX4_RX_PATH_MIX_SEC0                 0x0ba1
-#define WCD9335_CDC_RX4_RX_PATH_MIX_SEC1                 0x0ba2
-#define WCD9335_CDC_RX5_RX_PATH_CTL                      0x0ba5
-#define WCD9335_CDC_RX5_RX_PATH_CFG0                     0x0ba6
-#define WCD9335_CDC_RX5_RX_PATH_CFG1                     0x0ba7
-#define WCD9335_CDC_RX5_RX_PATH_CFG2                     0x0ba8
-#define WCD9335_CDC_RX5_RX_VOL_CTL                       0x0ba9
-#define WCD9335_CDC_RX5_RX_PATH_MIX_CTL                  0x0baa
-#define WCD9335_CDC_RX5_RX_PATH_MIX_CFG                  0x0bab
-#define WCD9335_CDC_RX5_RX_VOL_MIX_CTL                   0x0bac
-#define WCD9335_CDC_RX5_RX_PATH_SEC0                     0x0bad
-#define WCD9335_CDC_RX5_RX_PATH_SEC1                     0x0bae
-#define WCD9335_CDC_RX5_RX_PATH_SEC2                     0x0baf
-#define WCD9335_CDC_RX5_RX_PATH_SEC3                     0x0bb0
-#define WCD9335_CDC_RX5_RX_PATH_SEC5                     0x0bb2
-#define WCD9335_CDC_RX5_RX_PATH_SEC6                     0x0bb3
-#define WCD9335_CDC_RX5_RX_PATH_SEC7                     0x0bb4
-#define WCD9335_CDC_RX5_RX_PATH_MIX_SEC0                 0x0bb5
-#define WCD9335_CDC_RX5_RX_PATH_MIX_SEC1                 0x0bb6
-#define WCD9335_CDC_RX6_RX_PATH_CTL                      0x0bb9
-#define WCD9335_CDC_RX6_RX_PATH_CFG0                     0x0bba
-#define WCD9335_CDC_RX6_RX_PATH_CFG1                     0x0bbb
-#define WCD9335_CDC_RX6_RX_PATH_CFG2                     0x0bbc
-#define WCD9335_CDC_RX6_RX_VOL_CTL                       0x0bbd
-#define WCD9335_CDC_RX6_RX_PATH_MIX_CTL                  0x0bbe
-#define WCD9335_CDC_RX6_RX_PATH_MIX_CFG                  0x0bbf
-#define WCD9335_CDC_RX6_RX_VOL_MIX_CTL                   0x0bc0
-#define WCD9335_CDC_RX6_RX_PATH_SEC0                     0x0bc1
-#define WCD9335_CDC_RX6_RX_PATH_SEC1                     0x0bc2
-#define WCD9335_CDC_RX6_RX_PATH_SEC2                     0x0bc3
-#define WCD9335_CDC_RX6_RX_PATH_SEC3                     0x0bc4
-#define WCD9335_CDC_RX6_RX_PATH_SEC5                     0x0bc6
-#define WCD9335_CDC_RX6_RX_PATH_SEC6                     0x0bc7
-#define WCD9335_CDC_RX6_RX_PATH_SEC7                     0x0bc8
-#define WCD9335_CDC_RX6_RX_PATH_MIX_SEC0                 0x0bc9
-#define WCD9335_CDC_RX6_RX_PATH_MIX_SEC1                 0x0bca
-#define WCD9335_CDC_RX7_RX_PATH_CTL                      0x0bcd
-#define WCD9335_CDC_RX7_RX_PATH_CFG0                     0x0bce
-#define WCD9335_CDC_RX7_RX_PATH_CFG1                     0x0bcf
-#define WCD9335_CDC_RX7_RX_PATH_CFG2                     0x0bd0
-#define WCD9335_CDC_RX7_RX_VOL_CTL                       0x0bd1
-#define WCD9335_CDC_RX7_RX_PATH_MIX_CTL                  0x0bd2
-#define WCD9335_CDC_RX7_RX_PATH_MIX_CFG                  0x0bd3
-#define WCD9335_CDC_RX7_RX_VOL_MIX_CTL                   0x0bd4
-#define WCD9335_CDC_RX7_RX_PATH_SEC0                     0x0bd5
-#define WCD9335_CDC_RX7_RX_PATH_SEC1                     0x0bd6
-#define WCD9335_CDC_RX7_RX_PATH_SEC2                     0x0bd7
-#define WCD9335_CDC_RX7_RX_PATH_SEC3                     0x0bd8
-#define WCD9335_CDC_RX7_RX_PATH_SEC5                     0x0bda
-#define WCD9335_CDC_RX7_RX_PATH_SEC6                     0x0bdb
-#define WCD9335_CDC_RX7_RX_PATH_SEC7                     0x0bdc
-#define WCD9335_CDC_RX7_RX_PATH_MIX_SEC0                 0x0bdd
-#define WCD9335_CDC_RX7_RX_PATH_MIX_SEC1                 0x0bde
-#define WCD9335_CDC_RX8_RX_PATH_CTL                      0x0be1
-#define WCD9335_CDC_RX8_RX_PATH_CFG0                     0x0be2
-#define WCD9335_CDC_RX8_RX_PATH_CFG1                     0x0be3
-#define WCD9335_CDC_RX8_RX_PATH_CFG2                     0x0be4
-#define WCD9335_CDC_RX8_RX_VOL_CTL                       0x0be5
-#define WCD9335_CDC_RX8_RX_PATH_MIX_CTL                  0x0be6
-#define WCD9335_CDC_RX8_RX_PATH_MIX_CFG                  0x0be7
-#define WCD9335_CDC_RX8_RX_VOL_MIX_CTL                   0x0be8
-#define WCD9335_CDC_RX8_RX_PATH_SEC0                     0x0be9
-#define WCD9335_CDC_RX8_RX_PATH_SEC1                     0x0bea
-#define WCD9335_CDC_RX8_RX_PATH_SEC2                     0x0beb
-#define WCD9335_CDC_RX8_RX_PATH_SEC3                     0x0bec
-#define WCD9335_CDC_RX8_RX_PATH_SEC5                     0x0bee
-#define WCD9335_CDC_RX8_RX_PATH_SEC6                     0x0bef
-#define WCD9335_CDC_RX8_RX_PATH_SEC7                     0x0bf0
-#define WCD9335_CDC_RX8_RX_PATH_MIX_SEC0                 0x0bf1
-#define WCD9335_CDC_RX8_RX_PATH_MIX_SEC1                 0x0bf2
-
-/* Page-12 Registers */
-#define WCD9335_PAGE12_PAGE_REGISTER                     0x0c00
-#define WCD9335_CDC_CLSH_CRC                             0x0c01
-#define WCD9335_CDC_CLSH_DLY_CTRL                        0x0c02
-#define WCD9335_CDC_CLSH_DECAY_CTRL                      0x0c03
-#define WCD9335_CDC_CLSH_HPH_V_PA                        0x0c04
-#define WCD9335_CDC_CLSH_EAR_V_PA                        0x0c05
-#define WCD9335_CDC_CLSH_HPH_V_HD                        0x0c06
-#define WCD9335_CDC_CLSH_EAR_V_HD                        0x0c07
-#define WCD9335_CDC_CLSH_K1_MSB                          0x0c08
-#define WCD9335_CDC_CLSH_K1_LSB                          0x0c09
-#define WCD9335_CDC_CLSH_K2_MSB                          0x0c0a
-#define WCD9335_CDC_CLSH_K2_LSB                          0x0c0b
-#define WCD9335_CDC_CLSH_IDLE_CTRL                       0x0c0c
-#define WCD9335_CDC_CLSH_IDLE_HPH                        0x0c0d
-#define WCD9335_CDC_CLSH_IDLE_EAR                        0x0c0e
-#define WCD9335_CDC_CLSH_TEST0                           0x0c0f
-#define WCD9335_CDC_CLSH_TEST1                           0x0c10
-#define WCD9335_CDC_CLSH_OVR_VREF                        0x0c11
-#define WCD9335_CDC_BOOST0_BOOST_PATH_CTL                0x0c19
-#define WCD9335_CDC_BOOST0_BOOST_CTL                     0x0c1a
-#define WCD9335_CDC_BOOST0_BOOST_CFG1                    0x0c1b
-#define WCD9335_CDC_BOOST0_BOOST_CFG2                    0x0c1c
-#define WCD9335_CDC_BOOST1_BOOST_PATH_CTL                0x0c21
-#define WCD9335_CDC_BOOST1_BOOST_CTL                     0x0c22
-#define WCD9335_CDC_BOOST1_BOOST_CFG1                    0x0c23
-#define WCD9335_CDC_BOOST1_BOOST_CFG2                    0x0c24
-#define WCD9335_SWR_AHB_BRIDGE_WR_DATA_0                 0x0c29
-#define WCD9335_SWR_AHB_BRIDGE_WR_DATA_1                 0x0c2a
-#define WCD9335_SWR_AHB_BRIDGE_WR_DATA_2                 0x0c2b
-#define WCD9335_SWR_AHB_BRIDGE_WR_DATA_3                 0x0c2c
-#define WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0                 0x0c2d
-#define WCD9335_SWR_AHB_BRIDGE_WR_ADDR_1                 0x0c2e
-#define WCD9335_SWR_AHB_BRIDGE_WR_ADDR_2                 0x0c2f
-#define WCD9335_SWR_AHB_BRIDGE_WR_ADDR_3                 0x0c30
-#define WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0                 0x0c31
-#define WCD9335_SWR_AHB_BRIDGE_RD_ADDR_1                 0x0c32
-#define WCD9335_SWR_AHB_BRIDGE_RD_ADDR_2                 0x0c33
-#define WCD9335_SWR_AHB_BRIDGE_RD_ADDR_3                 0x0c34
-#define WCD9335_SWR_AHB_BRIDGE_RD_DATA_0                 0x0c35
-#define WCD9335_SWR_AHB_BRIDGE_RD_DATA_1                 0x0c36
-#define WCD9335_SWR_AHB_BRIDGE_RD_DATA_2                 0x0c37
-#define WCD9335_SWR_AHB_BRIDGE_RD_DATA_3                 0x0c38
-#define WCD9335_SWR_AHB_BRIDGE_ACCESS_CFG                0x0c39
-#define WCD9335_SWR_AHB_BRIDGE_ACCESS_STATUS             0x0c3a
-#define WCD9335_CDC_VBAT_VBAT_PATH_CTL                   0x0c3d
-#define WCD9335_CDC_VBAT_VBAT_CFG                        0x0c3e
-#define WCD9335_CDC_VBAT_VBAT_ADC_CAL1                   0x0c3f
-#define WCD9335_CDC_VBAT_VBAT_ADC_CAL2                   0x0c40
-#define WCD9335_CDC_VBAT_VBAT_ADC_CAL3                   0x0c41
-#define WCD9335_CDC_VBAT_VBAT_PK_EST1                    0x0c42
-#define WCD9335_CDC_VBAT_VBAT_PK_EST2                    0x0c43
-#define WCD9335_CDC_VBAT_VBAT_PK_EST3                    0x0c44
-#define WCD9335_CDC_VBAT_VBAT_RF_PROC1                   0x0c45
-#define WCD9335_CDC_VBAT_VBAT_RF_PROC2                   0x0c46
-#define WCD9335_CDC_VBAT_VBAT_TAC1                       0x0c47
-#define WCD9335_CDC_VBAT_VBAT_TAC2                       0x0c48
-#define WCD9335_CDC_VBAT_VBAT_TAC3                       0x0c49
-#define WCD9335_CDC_VBAT_VBAT_TAC4                       0x0c4a
-#define WCD9335_CDC_VBAT_VBAT_GAIN_UPD1                  0x0c4b
-#define WCD9335_CDC_VBAT_VBAT_GAIN_UPD2                  0x0c4c
-#define WCD9335_CDC_VBAT_VBAT_GAIN_UPD3                  0x0c4d
-#define WCD9335_CDC_VBAT_VBAT_GAIN_UPD4                  0x0c4e
-#define WCD9335_CDC_VBAT_VBAT_DEBUG1                     0x0c4f
-#define WCD9335_CDC_VBAT_VBAT_GAIN_UPD_MON               0x0c50
-#define WCD9335_CDC_VBAT_VBAT_GAIN_MON_VAL               0x0c51
-#define WCD9335_SPLINE_SRC0_CLK_RST_CTL_0                0x0c55
-#define WCD9335_SPLINE_SRC0_STATUS                       0x0c56
-#define WCD9335_SPLINE_SRC1_CLK_RST_CTL_0                0x0c6d
-#define WCD9335_SPLINE_SRC1_STATUS                       0x0c6e
-#define WCD9335_SPLINE_SRC2_CLK_RST_CTL_0                0x0c85
-#define WCD9335_SPLINE_SRC2_STATUS                       0x0c86
-#define WCD9335_SPLINE_SRC3_CLK_RST_CTL_0                0x0c9d
-#define WCD9335_SPLINE_SRC3_STATUS                       0x0c9e
-#define WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL        0x0cb5
-#define WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1       0x0cb6
-#define WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL        0x0cb9
-#define WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1       0x0cba
-
-/* Page-13 Registers */
-#define WCD9335_PAGE13_PAGE_REGISTER                     0x0d00
-#define WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0              0x0d01
-#define WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1              0x0d02
-#define WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0              0x0d03
-#define WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1              0x0d04
-#define WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0              0x0d05
-#define WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1              0x0d06
-#define WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0              0x0d07
-#define WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1              0x0d08
-#define WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0              0x0d09
-#define WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1              0x0d0a
-#define WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0              0x0d0b
-#define WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1              0x0d0c
-#define WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0              0x0d0d
-#define WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1              0x0d0e
-#define WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0              0x0d0f
-#define WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1              0x0d10
-#define WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0              0x0d11
-#define WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1              0x0d12
-#define WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0               0x0d13
-#define WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1               0x0d14
-#define WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2               0x0d15
-#define WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3               0x0d16
-#define WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4               0x0d17
-#define WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0         0x0d18
-#define WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1         0x0d19
-#define WCD9335_CDC_RX_INP_MUX_ANC_CFG0                  0x0d1a
-#define WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0           0x0d1b
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0             0x0d1d
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1             0x0d1e
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0             0x0d1f
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1             0x0d20
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0             0x0d21
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1             0x0d22
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0             0x0d23
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1             0x0d24
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0             0x0d25
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0             0x0d26
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0             0x0d27
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0             0x0d28
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0             0x0d29
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0            0x0d2b
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0            0x0d2c
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0            0x0d2d
-#define WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0            0x0d2e
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0   0x0d31
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1   0x0d32
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2   0x0d33
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3   0x0d34
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0   0x0d35
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1   0x0d36
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2   0x0d37
-#define WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3   0x0d38
-#define WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0                0x0d3a
-#define WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1                0x0d3b
-#define WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2                0x0d3c
-#define WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3                0x0d3d
-#define WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL            0x0d41
-#define WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL          0x0d42
-#define WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL             0x0d43
-#define WCD9335_CDC_PROX_DETECT_PROX_CTL                 0x0d49
-#define WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD0        0x0d4a
-#define WCD9335_CDC_PROX_DETECT_PROX_POLL_PERIOD1        0x0d4b
-#define WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB     0x0d4c
-#define WCD9335_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB     0x0d4d
-#define WCD9335_CDC_PROX_DETECT_PROX_STATUS              0x0d4e
-#define WCD9335_CDC_PROX_DETECT_PROX_TEST_CTRL           0x0d4f
-#define WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB       0x0d50
-#define WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB       0x0d51
-#define WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD    0x0d52
-#define WCD9335_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD    0x0d53
-#define WCD9335_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT      0x0d54
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL           0x0d55
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL        0x0d56
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL        0x0d57
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL        0x0d58
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL        0x0d59
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL        0x0d5a
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL        0x0d5b
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL        0x0d5c
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL        0x0d5d
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_CTL                0x0d5e
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL     0x0d5f
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL        0x0d60
-#define WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL        0x0d61
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL           0x0d65
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL        0x0d66
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL        0x0d67
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL        0x0d68
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL        0x0d69
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL        0x0d6a
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL        0x0d6b
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL        0x0d6c
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL        0x0d6d
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_CTL                0x0d6e
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL     0x0d6f
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL        0x0d70
-#define WCD9335_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL        0x0d71
-#define WCD9335_CDC_TOP_TOP_CFG0                         0x0d81
-#define WCD9335_CDC_TOP_TOP_CFG1                         0x0d82
-#define WCD9335_CDC_TOP_TOP_CFG2                         0x0d83
-#define WCD9335_CDC_TOP_TOP_CFG3                         0x0d84
-#define WCD9335_CDC_TOP_TOP_CFG4                         0x0d85
-#define WCD9335_CDC_TOP_TOP_CFG5                         0x0d86
-#define WCD9335_CDC_TOP_TOP_CFG6                         0x0d87
-#define WCD9335_CDC_TOP_TOP_CFG7                         0x0d88
-#define WCD9335_CDC_TOP_HPHL_COMP_WR_LSB                 0x0d89
-#define WCD9335_CDC_TOP_HPHL_COMP_WR_MSB                 0x0d8a
-#define WCD9335_CDC_TOP_HPHL_COMP_LUT                    0x0d8b
-#define WCD9335_CDC_TOP_HPHL_COMP_RD_LSB                 0x0d8c
-#define WCD9335_CDC_TOP_HPHL_COMP_RD_MSB                 0x0d8d
-#define WCD9335_CDC_TOP_HPHR_COMP_WR_LSB                 0x0d8e
-#define WCD9335_CDC_TOP_HPHR_COMP_WR_MSB                 0x0d8f
-#define WCD9335_CDC_TOP_HPHR_COMP_LUT                    0x0d90
-#define WCD9335_CDC_TOP_HPHR_COMP_RD_LSB                 0x0d91
-#define WCD9335_CDC_TOP_HPHR_COMP_RD_MSB                 0x0d92
-#define WCD9335_CDC_TOP_DIFFL_COMP_WR_LSB                0x0d93
-#define WCD9335_CDC_TOP_DIFFL_COMP_WR_MSB                0x0d94
-#define WCD9335_CDC_TOP_DIFFL_COMP_LUT                   0x0d95
-#define WCD9335_CDC_TOP_DIFFL_COMP_RD_LSB                0x0d96
-#define WCD9335_CDC_TOP_DIFFL_COMP_RD_MSB                0x0d97
-#define WCD9335_CDC_TOP_DIFFR_COMP_WR_LSB                0x0d98
-#define WCD9335_CDC_TOP_DIFFR_COMP_WR_MSB                0x0d99
-#define WCD9335_CDC_TOP_DIFFR_COMP_LUT                   0x0d9a
-#define WCD9335_CDC_TOP_DIFFR_COMP_RD_LSB                0x0d9b
-#define WCD9335_CDC_TOP_DIFFR_COMP_RD_MSB                0x0d9c
-
-/* Page-0x80 Registers */
-#define WCD9335_PAGE80_PAGE_REGISTER                     0x8000
-#define WCD9335_TLMM_BIST_MODE_PINCFG                    0x8001
-#define WCD9335_TLMM_RF_PA_ON_PINCFG                     0x8002
-#define WCD9335_TLMM_INTR1_PINCFG                        0x8003
-#define WCD9335_TLMM_INTR2_PINCFG                        0x8004
-#define WCD9335_TLMM_SWR_DATA_PINCFG                     0x8005
-#define WCD9335_TLMM_SWR_CLK_PINCFG                      0x8006
-#define WCD9335_TLMM_SLIMBUS_DATA2_PINCFG                0x8007
-#define WCD9335_TLMM_I2C_CLK_PINCFG                      0x8008
-#define WCD9335_TLMM_I2C_DATA_PINCFG                     0x8009
-#define WCD9335_TLMM_I2S_RX_SD0_PINCFG                   0x800a
-#define WCD9335_TLMM_I2S_RX_SD1_PINCFG                   0x800b
-#define WCD9335_TLMM_I2S_RX_SCK_PINCFG                   0x800c
-#define WCD9335_TLMM_I2S_RX_WS_PINCFG                    0x800d
-#define WCD9335_TLMM_I2S_TX_SD0_PINCFG                   0x800e
-#define WCD9335_TLMM_I2S_TX_SD1_PINCFG                   0x800f
-#define WCD9335_TLMM_I2S_TX_SCK_PINCFG                   0x8010
-#define WCD9335_TLMM_I2S_TX_WS_PINCFG                    0x8011
-#define WCD9335_TLMM_DMIC1_CLK_PINCFG                    0x8012
-#define WCD9335_TLMM_DMIC1_DATA_PINCFG                   0x8013
-#define WCD9335_TLMM_DMIC2_CLK_PINCFG                    0x8014
-#define WCD9335_TLMM_DMIC2_DATA_PINCFG                   0x8015
-#define WCD9335_TLMM_DMIC3_CLK_PINCFG                    0x8016
-#define WCD9335_TLMM_DMIC3_DATA_PINCFG                   0x8017
-#define WCD9335_TLMM_JTDI_PINCFG                         0x8018
-#define WCD9335_TLMM_JTDO_PINCFG                         0x8019
-#define WCD9335_TLMM_JTMS_PINCFG                         0x801a
-#define WCD9335_TLMM_JTCK_PINCFG                         0x801b
-#define WCD9335_TLMM_JTRST_PINCFG                        0x801c
-#define WCD9335_TEST_DEBUG_PIN_CTL_OE_0                  0x8031
-#define WCD9335_TEST_DEBUG_PIN_CTL_OE_1                  0x8032
-#define WCD9335_TEST_DEBUG_PIN_CTL_OE_2                  0x8033
-#define WCD9335_TEST_DEBUG_PIN_CTL_OE_3                  0x8034
-#define WCD9335_TEST_DEBUG_PIN_CTL_DATA_0                0x8035
-#define WCD9335_TEST_DEBUG_PIN_CTL_DATA_1                0x8036
-#define WCD9335_TEST_DEBUG_PIN_CTL_DATA_2                0x8037
-#define WCD9335_TEST_DEBUG_PIN_CTL_DATA_3                0x8038
-#define WCD9335_TEST_DEBUG_PAD_DRVCTL                    0x8039
-#define WCD9335_TEST_DEBUG_PIN_STATUS                    0x803a
-#define WCD9335_TEST_DEBUG_NPL_DLY_TEST_1                0x803b
-#define WCD9335_TEST_DEBUG_NPL_DLY_TEST_2                0x803c
-#define WCD9335_TEST_DEBUG_MEM_CTRL                      0x803d
-#define WCD9335_TEST_DEBUG_DEBUG_BUS_SEL                 0x8041
-#define WCD9335_TEST_DEBUG_DEBUG_JTAG                    0x8042
-#define WCD9335_TEST_DEBUG_DEBUG_EN_1                    0x8043
-#define WCD9335_TEST_DEBUG_DEBUG_EN_2                    0x8044
-#define WCD9335_TEST_DEBUG_DEBUG_EN_3                    0x8045
-#define WCD9335_MAX_REGISTER                             0x80FF
-
-/* SLIMBUS Slave Registers */
-#define TASHA_SLIM_PGD_PORT_INT_EN0                     (0x30)
-#define TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0             (0x34)
-#define TASHA_SLIM_PGD_PORT_INT_STATUS_RX_1             (0x35)
-#define TASHA_SLIM_PGD_PORT_INT_STATUS_TX_0             (0x36)
-#define TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1             (0x37)
-#define TASHA_SLIM_PGD_PORT_INT_CLR_RX_0                (0x38)
-#define TASHA_SLIM_PGD_PORT_INT_CLR_RX_1                (0x39)
-#define TASHA_SLIM_PGD_PORT_INT_CLR_TX_0                (0x3A)
-#define TASHA_SLIM_PGD_PORT_INT_CLR_TX_1                (0x3B)
-#define TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0		(0x60)
-#define TASHA_SLIM_PGD_PORT_INT_TX_SOURCE0		(0x70)
-
-/* Macros for Packing Register Writes into a U32 */
-#define TASHA_PACKED_REG_SIZE sizeof(u32)
-
-#define TASHA_CODEC_PACK_ENTRY(reg, mask, val) ((val & 0xff)|\
-	((mask & 0xff) << 8)|((reg & 0xffff) << 16))
-#define TASHA_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
-	do { \
-		((reg) = ((packed >> 16) & (0xffff))); \
-		((mask) = ((packed >> 8) & (0xff))); \
-		((val) = ((packed) & (0xff))); \
-	} while (0)
-#endif
diff --git a/include/linux/mfd/wcd934x/irq.h b/include/linux/mfd/wcd934x/irq.h
deleted file mode 100644
index 1a18be3..0000000
--- a/include/linux/mfd/wcd934x/irq.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD934X_IRQ_H_
-#define __WCD934X_IRQ_H_
-
-enum {
-	/* INTR_REG 0 */
-	WCD934X_IRQ_MISC = 1,
-	WCD934X_IRQ_HPH_PA_OCPL_FAULT,
-	WCD934X_IRQ_HPH_PA_OCPR_FAULT,
-	WCD934X_IRQ_EAR_PA_OCP_FAULT,
-	WCD934X_IRQ_HPH_PA_CNPL_COMPLETE,
-	WCD934X_IRQ_HPH_PA_CNPR_COMPLETE,
-	WCD934X_IRQ_EAR_PA_CNP_COMPLETE,
-	/* INTR_REG 1 */
-	WCD934X_IRQ_MBHC_SW_DET,
-	WCD934X_IRQ_MBHC_ELECT_INS_REM_DET,
-	WCD934X_IRQ_MBHC_BUTTON_PRESS_DET,
-	WCD934X_IRQ_MBHC_BUTTON_RELEASE_DET,
-	WCD934X_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
-	WCD934X_IRQ_RESERVED_0,
-	WCD934X_IRQ_RESERVED_1,
-	WCD934X_IRQ_RESERVED_2,
-	/* INTR_REG 2 */
-	WCD934X_IRQ_LINE_PA1_CNP_COMPLETE,
-	WCD934X_IRQ_LINE_PA2_CNP_COMPLETE,
-	WCD934X_IRQ_SLNQ_ANALOG_ERROR,
-	WCD934X_IRQ_RESERVED_3,
-	WCD934X_IRQ_SOUNDWIRE,
-	WCD934X_IRQ_VDD_DIG_RAMP_COMPLETE,
-	WCD934X_IRQ_RCO_ERROR,
-	WCD934X_IRQ_CPE_ERROR,
-	/* INTR_REG 3 */
-	WCD934X_IRQ_MAD_AUDIO,
-	WCD934X_IRQ_MAD_BEACON,
-	WCD934X_IRQ_MAD_ULTRASOUND,
-	WCD934X_IRQ_VBAT_ATTACK,
-	WCD934X_IRQ_VBAT_RESTORE,
-	WCD934X_IRQ_CPE1_INTR,
-	WCD934X_IRQ_RESERVED_4,
-	WCD934X_IRQ_SLNQ_DIGITAL,
-	WCD934X_NUM_IRQS,
-};
-
-#endif
diff --git a/include/linux/mfd/wcd934x/registers.h b/include/linux/mfd/wcd934x/registers.h
deleted file mode 100644
index a824875..0000000
--- a/include/linux/mfd/wcd934x/registers.h
+++ /dev/null
@@ -1,1848 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _WCD934X_REGISTERS_H
-#define _WCD934X_REGISTERS_H
-
-#define WCD934X_PAGE_SIZE 256
-#define WCD934X_NUM_PAGES 256
-
-extern const u8 * const wcd934x_reg[WCD934X_NUM_PAGES];
-
-enum {
-	WCD934X_PAGE_0 = 0,
-	WCD934X_PAGE_1,
-	WCD934X_PAGE_2,
-	WCD934X_PAGE_4 = 4,
-	WCD934X_PAGE_5,
-	WCD934X_PAGE_6,
-	WCD934X_PAGE_7,
-	WCD934X_PAGE_10 = 0xA,
-	WCD934X_PAGE_11,
-	WCD934X_PAGE_12,
-	WCD934X_PAGE_13,
-	WCD934X_PAGE_14,
-	WCD934X_PAGE_15,
-	WCD934X_PAGE_0x50,
-	WCD934X_PAGE_0X80,
-};
-
-enum {
-	WCD934X_WRITE = 0,
-	WCD934X_READ,
-	WCD934X_READ_WRITE,
-};
-
-/* Page-0 Registers */
-#define WCD934X_PAGE0_PAGE_REGISTER                        0x0000
-#define WCD934X_CODEC_RPM_CLK_BYPASS                       0x0001
-#define WCD934X_CODEC_RPM_CLK_GATE                         0x0002
-#define WCD934X_CODEC_RPM_CLK_MCLK_CFG                     0x0003
-#define WCD934X_CODEC_RPM_CLK_MCLK2_CFG                    0x0004
-#define WCD934X_CODEC_RPM_I2S_DSD_CLK_SEL                  0x0005
-#define WCD934X_CODEC_RPM_RST_CTL                          0x0009
-#define WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL               0x0011
-#define WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0               0x0021
-#define WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE1               0x0022
-#define WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE2               0x0023
-#define WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE3               0x0024
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_CTL                   0x0025
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_TEST0                 0x0026
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_TEST1                 0x0027
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT0              0x0029
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1              0x002a
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2              0x002b
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT3              0x002c
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT4              0x002d
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT5              0x002e
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT6              0x002f
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT7              0x0030
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT8              0x0031
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT9              0x0032
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT10             0x0033
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT11             0x0034
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT12             0x0035
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT13             0x0036
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14             0x0037
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15             0x0038
-#define WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS                0x0039
-#define WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_NONNEGO        0x003a
-#define WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_1              0x003b
-#define WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_2              0x003c
-#define WCD934X_CHIP_TIER_CTRL_I2C_SLAVE_ID_3              0x003d
-#define WCD934X_CHIP_TIER_CTRL_ANA_WAIT_STATE_CTL          0x003e
-#define WCD934X_CHIP_TIER_CTRL_SLNQ_WAIT_STATE_CTL         0x003f
-#define WCD934X_CHIP_TIER_CTRL_I2C_ACTIVE                  0x0040
-#define WCD934X_CHIP_TIER_CTRL_ALT_FUNC_EN                 0x0041
-#define WCD934X_CHIP_TIER_CTRL_GPIO_CTL_OE                 0x0042
-#define WCD934X_CHIP_TIER_CTRL_GPIO_CTL_DATA               0x0043
-#define WCD934X_DATA_HUB_RX0_CFG                           0x0051
-#define WCD934X_DATA_HUB_RX1_CFG                           0x0052
-#define WCD934X_DATA_HUB_RX2_CFG                           0x0053
-#define WCD934X_DATA_HUB_RX3_CFG                           0x0054
-#define WCD934X_DATA_HUB_RX4_CFG                           0x0055
-#define WCD934X_DATA_HUB_RX5_CFG                           0x0056
-#define WCD934X_DATA_HUB_RX6_CFG                           0x0057
-#define WCD934X_DATA_HUB_RX7_CFG                           0x0058
-#define WCD934X_DATA_HUB_SB_TX0_INP_CFG                    0x0061
-#define WCD934X_DATA_HUB_SB_TX1_INP_CFG                    0x0062
-#define WCD934X_DATA_HUB_SB_TX2_INP_CFG                    0x0063
-#define WCD934X_DATA_HUB_SB_TX3_INP_CFG                    0x0064
-#define WCD934X_DATA_HUB_SB_TX4_INP_CFG                    0x0065
-#define WCD934X_DATA_HUB_SB_TX5_INP_CFG                    0x0066
-#define WCD934X_DATA_HUB_SB_TX6_INP_CFG                    0x0067
-#define WCD934X_DATA_HUB_SB_TX7_INP_CFG                    0x0068
-#define WCD934X_DATA_HUB_SB_TX8_INP_CFG                    0x0069
-#define WCD934X_DATA_HUB_SB_TX9_INP_CFG                    0x006a
-#define WCD934X_DATA_HUB_SB_TX10_INP_CFG                   0x006b
-#define WCD934X_DATA_HUB_SB_TX11_INP_CFG                   0x006c
-#define WCD934X_DATA_HUB_SB_TX13_INP_CFG                   0x006e
-#define WCD934X_DATA_HUB_SB_TX14_INP_CFG                   0x006f
-#define WCD934X_DATA_HUB_SB_TX15_INP_CFG                   0x0070
-#define WCD934X_DATA_HUB_I2S_TX0_CFG                       0x0071
-#define WCD934X_DATA_HUB_I2S_TX1_0_CFG                     0x0073
-#define WCD934X_DATA_HUB_I2S_TX1_1_CFG                     0x0074
-#define WCD934X_DATA_HUB_I2S_0_CTL                         0x0081
-#define WCD934X_DATA_HUB_I2S_1_CTL                         0x0082
-#define WCD934X_DATA_HUB_I2S_2_CTL                         0x0083
-#define WCD934X_DATA_HUB_I2S_3_CTL                         0x0084
-#define WCD934X_DATA_HUB_I2S_CLKSRC_CTL                    0x0085
-#define WCD934X_DATA_HUB_I2S_COMMON_CTL                    0x0086
-#define WCD934X_DATA_HUB_I2S_0_TDM_CTL                     0x0087
-#define WCD934X_DATA_HUB_I2S_STATUS                        0x0088
-#define WCD934X_DMA_RDMA_CTL_0                             0x0091
-#define WCD934X_DMA_CH_2_3_CFG_RDMA_0                      0x0092
-#define WCD934X_DMA_CH_0_1_CFG_RDMA_0                      0x0093
-#define WCD934X_DMA_RDMA_CTL_1                             0x0094
-#define WCD934X_DMA_CH_2_3_CFG_RDMA_1                      0x0095
-#define WCD934X_DMA_CH_0_1_CFG_RDMA_1                      0x0096
-#define WCD934X_DMA_RDMA_CTL_2                             0x0097
-#define WCD934X_DMA_CH_2_3_CFG_RDMA_2                      0x0098
-#define WCD934X_DMA_CH_0_1_CFG_RDMA_2                      0x0099
-#define WCD934X_DMA_RDMA_CTL_3                             0x009A
-#define WCD934X_DMA_CH_2_3_CFG_RDMA_3                      0x009B
-#define WCD934X_DMA_CH_0_1_CFG_RDMA_3                      0x009C
-#define WCD934X_DMA_RDMA_CTL_4                             0x009D
-#define WCD934X_DMA_CH_2_3_CFG_RDMA_4                      0x009E
-#define WCD934X_DMA_CH_0_1_CFG_RDMA_4                      0x009F
-#define WCD934X_DMA_RDMA4_PRT_CFG                          0x00b1
-#define WCD934X_DMA_RDMA_SBTX0_7_CFG                       0x00b9
-#define WCD934X_DMA_RDMA_SBTX8_11_CFG                      0x00ba
-#define WCD934X_DMA_WDMA_CTL_0                             0x00c1
-#define WCD934X_DMA_CH_4_5_CFG_WDMA_0                      0x00c2
-#define WCD934X_DMA_CH_2_3_CFG_WDMA_0                      0x00c3
-#define WCD934X_DMA_CH_0_1_CFG_WDMA_0                      0x00c4
-#define WCD934X_DMA_WDMA_CTL_1                             0x00C6
-#define WCD934X_DMA_CH_4_5_CFG_WDMA_1                      0x00C7
-#define WCD934X_DMA_CH_2_3_CFG_WDMA_1                      0x00C8
-#define WCD934X_DMA_CH_0_1_CFG_WDMA_1                      0x00C9
-#define WCD934X_DMA_WDMA_CTL_2                             0x00CB
-#define WCD934X_DMA_CH_4_5_CFG_WDMA_2                      0x00CC
-#define WCD934X_DMA_CH_2_3_CFG_WDMA_2                      0x00CD
-#define WCD934X_DMA_CH_0_1_CFG_WDMA_2                      0x00CE
-#define WCD934X_DMA_WDMA_CTL_3                             0x00D0
-#define WCD934X_DMA_CH_4_5_CFG_WDMA_3                      0x00D1
-#define WCD934X_DMA_CH_2_3_CFG_WDMA_3                      0x00D2
-#define WCD934X_DMA_CH_0_1_CFG_WDMA_3                      0x00D3
-#define WCD934X_DMA_WDMA_CTL_4                             0x00D5
-#define WCD934X_DMA_CH_4_5_CFG_WDMA_4                      0x00D6
-#define WCD934X_DMA_CH_2_3_CFG_WDMA_4                      0x00D7
-#define WCD934X_DMA_CH_0_1_CFG_WDMA_4                      0x00D8
-#define WCD934X_DMA_WDMA0_PRT_CFG                          0x00E1
-#define WCD934X_DMA_WDMA3_PRT_CFG                          0x00E2
-#define WCD934X_DMA_WDMA4_PRT0_3_CFG                       0x00E3
-#define WCD934X_DMA_WDMA4_PRT4_7_CFG                       0x00E4
-#define WCD934X_PAGE1_PAGE_REGISTER                        0x0100
-#define WCD934X_CPE_FLL_USER_CTL_0                         0x0101
-#define WCD934X_CPE_FLL_USER_CTL_1                         0x0102
-#define WCD934X_CPE_FLL_USER_CTL_2                         0x0103
-#define WCD934X_CPE_FLL_USER_CTL_3                         0x0104
-#define WCD934X_CPE_FLL_USER_CTL_4                         0x0105
-#define WCD934X_CPE_FLL_USER_CTL_5                         0x0106
-#define WCD934X_CPE_FLL_USER_CTL_6                         0x0107
-#define WCD934X_CPE_FLL_USER_CTL_7                         0x0108
-#define WCD934X_CPE_FLL_USER_CTL_8                         0x0109
-#define WCD934X_CPE_FLL_USER_CTL_9                         0x010a
-#define WCD934X_CPE_FLL_L_VAL_CTL_0                        0x010b
-#define WCD934X_CPE_FLL_L_VAL_CTL_1                        0x010c
-#define WCD934X_CPE_FLL_DSM_FRAC_CTL_0                     0x010d
-#define WCD934X_CPE_FLL_DSM_FRAC_CTL_1                     0x010e
-#define WCD934X_CPE_FLL_CONFIG_CTL_0                       0x010f
-#define WCD934X_CPE_FLL_CONFIG_CTL_1                       0x0110
-#define WCD934X_CPE_FLL_CONFIG_CTL_2                       0x0111
-#define WCD934X_CPE_FLL_CONFIG_CTL_3                       0x0112
-#define WCD934X_CPE_FLL_CONFIG_CTL_4                       0x0113
-#define WCD934X_CPE_FLL_TEST_CTL_0                         0x0114
-#define WCD934X_CPE_FLL_TEST_CTL_1                         0x0115
-#define WCD934X_CPE_FLL_TEST_CTL_2                         0x0116
-#define WCD934X_CPE_FLL_TEST_CTL_3                         0x0117
-#define WCD934X_CPE_FLL_TEST_CTL_4                         0x0118
-#define WCD934X_CPE_FLL_TEST_CTL_5                         0x0119
-#define WCD934X_CPE_FLL_TEST_CTL_6                         0x011a
-#define WCD934X_CPE_FLL_TEST_CTL_7                         0x011b
-#define WCD934X_CPE_FLL_FREQ_CTL_0                         0x011c
-#define WCD934X_CPE_FLL_FREQ_CTL_1                         0x011d
-#define WCD934X_CPE_FLL_FREQ_CTL_2                         0x011e
-#define WCD934X_CPE_FLL_FREQ_CTL_3                         0x011f
-#define WCD934X_CPE_FLL_SSC_CTL_0                          0x0120
-#define WCD934X_CPE_FLL_SSC_CTL_1                          0x0121
-#define WCD934X_CPE_FLL_SSC_CTL_2                          0x0122
-#define WCD934X_CPE_FLL_SSC_CTL_3                          0x0123
-#define WCD934X_CPE_FLL_FLL_MODE                           0x0124
-#define WCD934X_CPE_FLL_STATUS_0                           0x0125
-#define WCD934X_CPE_FLL_STATUS_1                           0x0126
-#define WCD934X_CPE_FLL_STATUS_2                           0x0127
-#define WCD934X_CPE_FLL_STATUS_3                           0x0128
-#define WCD934X_I2S_FLL_USER_CTL_0                         0x0141
-#define WCD934X_I2S_FLL_USER_CTL_1                         0x0142
-#define WCD934X_I2S_FLL_USER_CTL_2                         0x0143
-#define WCD934X_I2S_FLL_USER_CTL_3                         0x0144
-#define WCD934X_I2S_FLL_USER_CTL_4                         0x0145
-#define WCD934X_I2S_FLL_USER_CTL_5                         0x0146
-#define WCD934X_I2S_FLL_USER_CTL_6                         0x0147
-#define WCD934X_I2S_FLL_USER_CTL_7                         0x0148
-#define WCD934X_I2S_FLL_USER_CTL_8                         0x0149
-#define WCD934X_I2S_FLL_USER_CTL_9                         0x014a
-#define WCD934X_I2S_FLL_L_VAL_CTL_0                        0x014b
-#define WCD934X_I2S_FLL_L_VAL_CTL_1                        0x014c
-#define WCD934X_I2S_FLL_DSM_FRAC_CTL_0                     0x014d
-#define WCD934X_I2S_FLL_DSM_FRAC_CTL_1                     0x014e
-#define WCD934X_I2S_FLL_CONFIG_CTL_0                       0x014f
-#define WCD934X_I2S_FLL_CONFIG_CTL_1                       0x0150
-#define WCD934X_I2S_FLL_CONFIG_CTL_2                       0x0151
-#define WCD934X_I2S_FLL_CONFIG_CTL_3                       0x0152
-#define WCD934X_I2S_FLL_CONFIG_CTL_4                       0x0153
-#define WCD934X_I2S_FLL_TEST_CTL_0                         0x0154
-#define WCD934X_I2S_FLL_TEST_CTL_1                         0x0155
-#define WCD934X_I2S_FLL_TEST_CTL_2                         0x0156
-#define WCD934X_I2S_FLL_TEST_CTL_3                         0x0157
-#define WCD934X_I2S_FLL_TEST_CTL_4                         0x0158
-#define WCD934X_I2S_FLL_TEST_CTL_5                         0x0159
-#define WCD934X_I2S_FLL_TEST_CTL_6                         0x015a
-#define WCD934X_I2S_FLL_TEST_CTL_7                         0x015b
-#define WCD934X_I2S_FLL_FREQ_CTL_0                         0x015c
-#define WCD934X_I2S_FLL_FREQ_CTL_1                         0x015d
-#define WCD934X_I2S_FLL_FREQ_CTL_2                         0x015e
-#define WCD934X_I2S_FLL_FREQ_CTL_3                         0x015f
-#define WCD934X_I2S_FLL_SSC_CTL_0                          0x0160
-#define WCD934X_I2S_FLL_SSC_CTL_1                          0x0161
-#define WCD934X_I2S_FLL_SSC_CTL_2                          0x0162
-#define WCD934X_I2S_FLL_SSC_CTL_3                          0x0163
-#define WCD934X_I2S_FLL_FLL_MODE                           0x0164
-#define WCD934X_I2S_FLL_STATUS_0                           0x0165
-#define WCD934X_I2S_FLL_STATUS_1                           0x0166
-#define WCD934X_I2S_FLL_STATUS_2                           0x0167
-#define WCD934X_I2S_FLL_STATUS_3                           0x0168
-#define WCD934X_SB_FLL_USER_CTL_0                          0x0181
-#define WCD934X_SB_FLL_USER_CTL_1                          0x0182
-#define WCD934X_SB_FLL_USER_CTL_2                          0x0183
-#define WCD934X_SB_FLL_USER_CTL_3                          0x0184
-#define WCD934X_SB_FLL_USER_CTL_4                          0x0185
-#define WCD934X_SB_FLL_USER_CTL_5                          0x0186
-#define WCD934X_SB_FLL_USER_CTL_6                          0x0187
-#define WCD934X_SB_FLL_USER_CTL_7                          0x0188
-#define WCD934X_SB_FLL_USER_CTL_8                          0x0189
-#define WCD934X_SB_FLL_USER_CTL_9                          0x018a
-#define WCD934X_SB_FLL_L_VAL_CTL_0                         0x018b
-#define WCD934X_SB_FLL_L_VAL_CTL_1                         0x018c
-#define WCD934X_SB_FLL_DSM_FRAC_CTL_0                      0x018d
-#define WCD934X_SB_FLL_DSM_FRAC_CTL_1                      0x018e
-#define WCD934X_SB_FLL_CONFIG_CTL_0                        0x018f
-#define WCD934X_SB_FLL_CONFIG_CTL_1                        0x0190
-#define WCD934X_SB_FLL_CONFIG_CTL_2                        0x0191
-#define WCD934X_SB_FLL_CONFIG_CTL_3                        0x0192
-#define WCD934X_SB_FLL_CONFIG_CTL_4                        0x0193
-#define WCD934X_SB_FLL_TEST_CTL_0                          0x0194
-#define WCD934X_SB_FLL_TEST_CTL_1                          0x0195
-#define WCD934X_SB_FLL_TEST_CTL_2                          0x0196
-#define WCD934X_SB_FLL_TEST_CTL_3                          0x0197
-#define WCD934X_SB_FLL_TEST_CTL_4                          0x0198
-#define WCD934X_SB_FLL_TEST_CTL_5                          0x0199
-#define WCD934X_SB_FLL_TEST_CTL_6                          0x019a
-#define WCD934X_SB_FLL_TEST_CTL_7                          0x019b
-#define WCD934X_SB_FLL_FREQ_CTL_0                          0x019c
-#define WCD934X_SB_FLL_FREQ_CTL_1                          0x019d
-#define WCD934X_SB_FLL_FREQ_CTL_2                          0x019e
-#define WCD934X_SB_FLL_FREQ_CTL_3                          0x019f
-#define WCD934X_SB_FLL_SSC_CTL_0                           0x01a0
-#define WCD934X_SB_FLL_SSC_CTL_1                           0x01a1
-#define WCD934X_SB_FLL_SSC_CTL_2                           0x01a2
-#define WCD934X_SB_FLL_SSC_CTL_3                           0x01a3
-#define WCD934X_SB_FLL_FLL_MODE                            0x01a4
-#define WCD934X_SB_FLL_STATUS_0                            0x01a5
-#define WCD934X_SB_FLL_STATUS_1                            0x01a6
-#define WCD934X_SB_FLL_STATUS_2                            0x01a7
-#define WCD934X_SB_FLL_STATUS_3                            0x01a8
-#define WCD934X_PAGE2_PAGE_REGISTER                        0x0200
-#define WCD934X_CPE_SS_CPE_CTL                             0x0201
-#define WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0                0x0202
-#define WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_1                0x0203
-#define WCD934X_CPE_SS_PWR_CPEFLL_CTL                      0x0204
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0            0x0205
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1            0x0206
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_OVERRIDE     0x0207
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0           0x0208
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1           0x0209
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2           0x020a
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3           0x020b
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_4           0x020c
-#define WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_5           0x020d
-#define WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN              0x020e
-#define WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL                 0x020f
-#define WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL        0x0210
-#define WCD934X_CPE_SS_SOC_SW_COLLAPSE_OVERRIDE_CTL1       0x0211
-#define WCD934X_CPE_SS_US_BUF_INT_PERIOD                   0x0212
-#define WCD934X_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD           0x0213
-#define WCD934X_CPE_SS_SVA_CFG                             0x0214
-#define WCD934X_CPE_SS_US_CFG                              0x0215
-#define WCD934X_CPE_SS_MAD_CTL                             0x0216
-#define WCD934X_CPE_SS_CPAR_CTL                            0x0217
-#define WCD934X_CPE_SS_DMIC0_CTL                           0x0218
-#define WCD934X_CPE_SS_DMIC1_CTL                           0x0219
-#define WCD934X_CPE_SS_DMIC2_CTL                           0x021a
-#define WCD934X_CPE_SS_DMIC_CFG                            0x021b
-#define WCD934X_CPE_SS_CPAR_CFG                            0x021c
-#define WCD934X_CPE_SS_WDOG_CFG                            0x021d
-#define WCD934X_CPE_SS_BACKUP_INT                          0x021e
-#define WCD934X_CPE_SS_STATUS                              0x021f
-#define WCD934X_CPE_SS_CPE_OCD_CFG                         0x0220
-#define WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A                0x0221
-#define WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B                0x0222
-#define WCD934X_CPE_SS_SS_ERROR_INT_MASK_1A                0x0223
-#define WCD934X_CPE_SS_SS_ERROR_INT_MASK_1B                0x0224
-#define WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A              0x0225
-#define WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B              0x0226
-#define WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1A              0x0227
-#define WCD934X_CPE_SS_SS_ERROR_INT_STATUS_1B              0x0228
-#define WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A               0x0229
-#define WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B               0x022a
-#define WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1A               0x022b
-#define WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_1B               0x022c
-#define WCD934X_SOC_MAD_MAIN_CTL_1                         0x0281
-#define WCD934X_SOC_MAD_MAIN_CTL_2                         0x0282
-#define WCD934X_SOC_MAD_AUDIO_CTL_1                        0x0283
-#define WCD934X_SOC_MAD_AUDIO_CTL_2                        0x0284
-#define WCD934X_SOC_MAD_AUDIO_CTL_3                        0x0285
-#define WCD934X_SOC_MAD_AUDIO_CTL_4                        0x0286
-#define WCD934X_SOC_MAD_AUDIO_CTL_5                        0x0287
-#define WCD934X_SOC_MAD_AUDIO_CTL_6                        0x0288
-#define WCD934X_SOC_MAD_AUDIO_CTL_7                        0x0289
-#define WCD934X_SOC_MAD_AUDIO_CTL_8                        0x028a
-#define WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR                  0x028b
-#define WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL                  0x028c
-#define WCD934X_SOC_MAD_ULTR_CTL_1                         0x028d
-#define WCD934X_SOC_MAD_ULTR_CTL_2                         0x028e
-#define WCD934X_SOC_MAD_ULTR_CTL_3                         0x028f
-#define WCD934X_SOC_MAD_ULTR_CTL_4                         0x0290
-#define WCD934X_SOC_MAD_ULTR_CTL_5                         0x0291
-#define WCD934X_SOC_MAD_ULTR_CTL_6                         0x0292
-#define WCD934X_SOC_MAD_ULTR_CTL_7                         0x0293
-#define WCD934X_SOC_MAD_BEACON_CTL_1                       0x0294
-#define WCD934X_SOC_MAD_BEACON_CTL_2                       0x0295
-#define WCD934X_SOC_MAD_BEACON_CTL_3                       0x0296
-#define WCD934X_SOC_MAD_BEACON_CTL_4                       0x0297
-#define WCD934X_SOC_MAD_BEACON_CTL_5                       0x0298
-#define WCD934X_SOC_MAD_BEACON_CTL_6                       0x0299
-#define WCD934X_SOC_MAD_BEACON_CTL_7                       0x029a
-#define WCD934X_SOC_MAD_BEACON_CTL_8                       0x029b
-#define WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR                 0x029c
-#define WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL                 0x029d
-#define WCD934X_SOC_MAD_INP_SEL                            0x029e
-#define WCD934X_PAGE4_PAGE_REGISTER                        0x0400
-#define WCD934X_INTR_CFG                                   0x0401
-#define WCD934X_INTR_CLR_COMMIT                            0x0402
-#define WCD934X_INTR_PIN1_MASK0                            0x0409
-#define WCD934X_INTR_PIN1_MASK1                            0x040a
-#define WCD934X_INTR_PIN1_MASK2                            0x040b
-#define WCD934X_INTR_PIN1_MASK3                            0x040c
-#define WCD934X_INTR_PIN1_STATUS0                          0x0411
-#define WCD934X_INTR_PIN1_STATUS1                          0x0412
-#define WCD934X_INTR_PIN1_STATUS2                          0x0413
-#define WCD934X_INTR_PIN1_STATUS3                          0x0414
-#define WCD934X_INTR_PIN1_CLEAR0                           0x0419
-#define WCD934X_INTR_PIN1_CLEAR1                           0x041a
-#define WCD934X_INTR_PIN1_CLEAR2                           0x041b
-#define WCD934X_INTR_PIN1_CLEAR3                           0x041c
-#define WCD934X_INTR_PIN2_MASK3                            0x0424
-#define WCD934X_INTR_PIN2_STATUS3                          0x042c
-#define WCD934X_INTR_PIN2_CLEAR3                           0x0434
-#define WCD934X_INTR_CPESS_SUMRY_MASK2                     0x043b
-#define WCD934X_INTR_CPESS_SUMRY_MASK3                     0x043c
-#define WCD934X_INTR_CPESS_SUMRY_STATUS2                   0x0443
-#define WCD934X_INTR_CPESS_SUMRY_STATUS3                   0x0444
-#define WCD934X_INTR_CPESS_SUMRY_CLEAR2                    0x044b
-#define WCD934X_INTR_CPESS_SUMRY_CLEAR3                    0x044c
-#define WCD934X_INTR_LEVEL0                                0x0461
-#define WCD934X_INTR_LEVEL1                                0x0462
-#define WCD934X_INTR_LEVEL2                                0x0463
-#define WCD934X_INTR_LEVEL3                                0x0464
-#define WCD934X_INTR_BYPASS0                               0x0469
-#define WCD934X_INTR_BYPASS1                               0x046a
-#define WCD934X_INTR_BYPASS2                               0x046b
-#define WCD934X_INTR_BYPASS3                               0x046c
-#define WCD934X_INTR_SET0                                  0x0471
-#define WCD934X_INTR_SET1                                  0x0472
-#define WCD934X_INTR_SET2                                  0x0473
-#define WCD934X_INTR_SET3                                  0x0474
-#define WCD934X_INTR_CODEC_MISC_MASK                       0x04b1
-#define WCD934X_INTR_CODEC_MISC_STATUS                     0x04b2
-#define WCD934X_INTR_CODEC_MISC_CLEAR                      0x04b3
-#define WCD934X_PAGE5_PAGE_REGISTER                        0x0500
-#define WCD934X_SLNQ_DIG_DEVICE                            0x0501
-#define WCD934X_SLNQ_DIG_REVISION                          0x0502
-#define WCD934X_SLNQ_DIG_H_COMMAND                         0x0511
-#define WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_MSB                0x0512
-#define WCD934X_SLNQ_DIG_NUMBER_OF_BYTE_LSB                0x0513
-#define WCD934X_SLNQ_DIG_MASTER_ADDRESS_MSB                0x0514
-#define WCD934X_SLNQ_DIG_MASTER_ADDRESS_LSB                0x0515
-#define WCD934X_SLNQ_DIG_SLAVE_ADDRESS_MSB                 0x0516
-#define WCD934X_SLNQ_DIG_SLAVE_ADDRESS_LSB                 0x0517
-#define WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_MSB              0x0518
-#define WCD934X_SLNQ_DIG_TIMER0_INTERRUPT_LSB              0x0519
-#define WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_MSB              0x051a
-#define WCD934X_SLNQ_DIG_TIMER1_INTERRUPT_LSB              0x051b
-#define WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_MSB              0x051c
-#define WCD934X_SLNQ_DIG_TIMER2_INTERRUPT_LSB              0x051d
-#define WCD934X_SLNQ_DIG_COMM_CTL                          0x0520
-#define WCD934X_SLNQ_DIG_FRAME_CTRL                        0x0542
-#define WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH1_2                0x055c
-#define WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH3_4                0x055d
-#define WCD934X_SLNQ_DIG_PDM_2ND_DATA_CH5                  0x055e
-#define WCD934X_SLNQ_DIG_SW_EVENT_RD                       0x0561
-#define WCD934X_SLNQ_DIG_SW_EVENT_CTRL                     0x0562
-#define WCD934X_SLNQ_DIG_PDM_SELECT_1                      0x0563
-#define WCD934X_SLNQ_DIG_PDM_SELECT_2                      0x0564
-#define WCD934X_SLNQ_DIG_PDM_SELECT_3                      0x0565
-#define WCD934X_SLNQ_DIG_PDM_SAMPLING_FREQ                 0x0566
-#define WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_CTL             0x0569
-#define WCD934X_SLNQ_DIG_PDM_DC_CONVERSION_SEL             0x056a
-#define WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_MSB               0x056b
-#define WCD934X_SLNQ_DIG_PDM_DC_CONV_CHA_LSB               0x056c
-#define WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_MSB               0x056d
-#define WCD934X_SLNQ_DIG_PDM_DC_CONV_CHB_LSB               0x056e
-#define WCD934X_SLNQ_DIG_RAM_CNTRL                         0x0571
-#define WCD934X_SLNQ_DIG_SRAM_BANK                         0x0572
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_0                       0x0573
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1                       0x0574
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2                       0x0575
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3                       0x0576
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_4                       0x0577
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_5                       0x0578
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_6                       0x0579
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_7                       0x057a
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_8                       0x057b
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_9                       0x057c
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_A                       0x057d
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_B                       0x057e
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_C                       0x057f
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_D                       0x0580
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_E                       0x0581
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_F                       0x0582
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_10                      0x0583
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_11                      0x0584
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_12                      0x0585
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_13                      0x0586
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_14                      0x0587
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_15                      0x0588
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_16                      0x0589
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_17                      0x058a
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_18                      0x058b
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_19                      0x058c
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1A                      0x058d
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1B                      0x058e
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1C                      0x058f
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1D                      0x0590
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1E                      0x0591
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_1F                      0x0592
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_20                      0x0593
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_21                      0x0594
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_22                      0x0595
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_23                      0x0596
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_24                      0x0597
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_25                      0x0598
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_26                      0x0599
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_27                      0x059a
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_28                      0x059b
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_29                      0x059c
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2A                      0x059d
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2B                      0x059e
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2C                      0x059f
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2D                      0x05a0
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2E                      0x05a1
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_2F                      0x05a2
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_30                      0x05a3
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_31                      0x05a4
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_32                      0x05a5
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_33                      0x05a6
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_34                      0x05a7
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_35                      0x05a8
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_36                      0x05a9
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_37                      0x05aa
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_38                      0x05ab
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_39                      0x05ac
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3A                      0x05ad
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3B                      0x05ae
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3C                      0x05af
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3D                      0x05b0
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3E                      0x05b1
-#define WCD934X_SLNQ_DIG_SRAM_BYTE_3F                      0x05b2
-#define WCD934X_SLNQ_DIG_TOP_CTRL1                         0x05b3
-#define WCD934X_SLNQ_DIG_TOP_CTRL2                         0x05b4
-#define WCD934X_SLNQ_DIG_PDM_CTRL                          0x05b5
-#define WCD934X_SLNQ_DIG_PDM_MUTE_CTRL                     0x05b6
-#define WCD934X_SLNQ_DIG_DEC_BYPASS_CTRL                   0x05b7
-#define WCD934X_SLNQ_DIG_DEC_BYPASS_STATUS                 0x05b8
-#define WCD934X_SLNQ_DIG_DEC_BYPASS_FS                     0x05b9
-#define WCD934X_SLNQ_DIG_DEC_BYPASS_IN_SEL                 0x05ba
-#define WCD934X_SLNQ_DIG_GPOUT_ENABLE                      0x05bb
-#define WCD934X_SLNQ_DIG_GPOUT_VAL                         0x05bc
-#define WCD934X_SLNQ_DIG_ANA_INTERRUPT_MASK                0x05be
-#define WCD934X_SLNQ_DIG_ANA_INTERRUPT_STATUS              0x05bf
-#define WCD934X_SLNQ_DIG_ANA_INTERRUPT_CLR                 0x05c0
-#define WCD934X_SLNQ_DIG_IP_TESTING                        0x05c1
-#define WCD934X_SLNQ_DIG_INTERRUPT_CNTRL                   0x05e3
-#define WCD934X_SLNQ_DIG_INTERRUPT_CNT                     0x05e9
-#define WCD934X_SLNQ_DIG_INTERRUPT_CNT_MSB                 0x05eb
-#define WCD934X_SLNQ_DIG_INTERRUPT_CNT_LSB                 0x05ec
-#define WCD934X_SLNQ_DIG_INTERRUPT_MASK0                   0x05f1
-#define WCD934X_SLNQ_DIG_INTERRUPT_MASK1                   0x05f2
-#define WCD934X_SLNQ_DIG_INTERRUPT_MASK2                   0x05f3
-#define WCD934X_SLNQ_DIG_INTERRUPT_MASK3                   0x05f4
-#define WCD934X_SLNQ_DIG_INTERRUPT_MASK4                   0x05f5
-#define WCD934X_SLNQ_DIG_INTERRUPT_STATUS0                 0x05f6
-#define WCD934X_SLNQ_DIG_INTERRUPT_STATUS1                 0x05f7
-#define WCD934X_SLNQ_DIG_INTERRUPT_STATUS2                 0x05f8
-#define WCD934X_SLNQ_DIG_INTERRUPT_STATUS3                 0x05f9
-#define WCD934X_SLNQ_DIG_INTERRUPT_STATUS4                 0x05fa
-#define WCD934X_SLNQ_DIG_INTERRUPT_CLR0                    0x05fb
-#define WCD934X_SLNQ_DIG_INTERRUPT_CLR1                    0x05fc
-#define WCD934X_SLNQ_DIG_INTERRUPT_CLR2                    0x05fd
-#define WCD934X_SLNQ_DIG_INTERRUPT_CLR3                    0x05fe
-#define WCD934X_SLNQ_DIG_INTERRUPT_CLR4                    0x05ff
-#define WCD934X_ANA_PAGE_REGISTER                          0x0600
-#define WCD934X_ANA_BIAS                                   0x0601
-#define WCD934X_ANA_RCO                                    0x0603
-#define WCD934X_ANA_PAGE6_SPARE2                           0x0604
-#define WCD934X_ANA_PAGE6_SPARE3                           0x0605
-#define WCD934X_ANA_BUCK_CTL                               0x0606
-#define WCD934X_ANA_BUCK_STATUS                            0x0607
-#define WCD934X_ANA_RX_SUPPLIES                            0x0608
-#define WCD934X_ANA_HPH                                    0x0609
-#define WCD934X_ANA_EAR                                    0x060a
-#define WCD934X_ANA_LO_1_2                                 0x060b
-#define WCD934X_ANA_MAD_SETUP                              0x060d
-#define WCD934X_ANA_AMIC1                                  0x060e
-#define WCD934X_ANA_AMIC2                                  0x060f
-#define WCD934X_ANA_AMIC3                                  0x0610
-#define WCD934X_ANA_AMIC4                                  0x0611
-#define WCD934X_ANA_MBHC_MECH                              0x0614
-#define WCD934X_ANA_MBHC_ELECT                             0x0615
-#define WCD934X_ANA_MBHC_ZDET                              0x0616
-#define WCD934X_ANA_MBHC_RESULT_1                          0x0617
-#define WCD934X_ANA_MBHC_RESULT_2                          0x0618
-#define WCD934X_ANA_MBHC_RESULT_3                          0x0619
-#define WCD934X_ANA_MBHC_BTN0                              0x061a
-#define WCD934X_ANA_MBHC_BTN1                              0x061b
-#define WCD934X_ANA_MBHC_BTN2                              0x061c
-#define WCD934X_ANA_MBHC_BTN3                              0x061d
-#define WCD934X_ANA_MBHC_BTN4                              0x061e
-#define WCD934X_ANA_MBHC_BTN5                              0x061f
-#define WCD934X_ANA_MBHC_BTN6                              0x0620
-#define WCD934X_ANA_MBHC_BTN7                              0x0621
-#define WCD934X_ANA_MICB1                                  0x0622
-#define WCD934X_ANA_MICB2                                  0x0623
-#define WCD934X_ANA_MICB2_RAMP                             0x0624
-#define WCD934X_ANA_MICB3                                  0x0625
-#define WCD934X_ANA_MICB4                                  0x0626
-#define WCD934X_ANA_VBADC                                  0x0627
-#define WCD934X_BIAS_CTL                                   0x0628
-#define WCD934X_BIAS_VBG_FINE_ADJ                          0x0629
-#define WCD934X_RCO_CTRL_1                                 0x062e
-#define WCD934X_RCO_CTRL_2                                 0x062f
-#define WCD934X_RCO_CAL                                    0x0630
-#define WCD934X_RCO_CAL_1                                  0x0631
-#define WCD934X_RCO_CAL_2                                  0x0632
-#define WCD934X_RCO_TEST_CTRL                              0x0633
-#define WCD934X_RCO_CAL_OUT_1                              0x0634
-#define WCD934X_RCO_CAL_OUT_2                              0x0635
-#define WCD934X_RCO_CAL_OUT_3                              0x0636
-#define WCD934X_RCO_CAL_OUT_4                              0x0637
-#define WCD934X_RCO_CAL_OUT_5                              0x0638
-#define WCD934X_SIDO_MODE_1                                0x063a
-#define WCD934X_SIDO_MODE_2                                0x063b
-#define WCD934X_SIDO_MODE_3                                0x063c
-#define WCD934X_SIDO_MODE_4                                0x063d
-#define WCD934X_SIDO_VCL_1                                 0x063e
-#define WCD934X_SIDO_VCL_2                                 0x063f
-#define WCD934X_SIDO_VCL_3                                 0x0640
-#define WCD934X_SIDO_CCL_1                                 0x0641
-#define WCD934X_SIDO_CCL_2                                 0x0642
-#define WCD934X_SIDO_CCL_3                                 0x0643
-#define WCD934X_SIDO_CCL_4                                 0x0644
-#define WCD934X_SIDO_CCL_5                                 0x0645
-#define WCD934X_SIDO_CCL_6                                 0x0646
-#define WCD934X_SIDO_CCL_7                                 0x0647
-#define WCD934X_SIDO_CCL_8                                 0x0648
-#define WCD934X_SIDO_CCL_9                                 0x0649
-#define WCD934X_SIDO_CCL_10                                0x064a
-#define WCD934X_SIDO_FILTER_1                              0x064b
-#define WCD934X_SIDO_FILTER_2                              0x064c
-#define WCD934X_SIDO_DRIVER_1                              0x064d
-#define WCD934X_SIDO_DRIVER_2                              0x064e
-#define WCD934X_SIDO_DRIVER_3                              0x064f
-#define WCD934X_SIDO_CAL_CODE_EXT_1                        0x0650
-#define WCD934X_SIDO_CAL_CODE_EXT_2                        0x0651
-#define WCD934X_SIDO_CAL_CODE_OUT_1                        0x0652
-#define WCD934X_SIDO_CAL_CODE_OUT_2                        0x0653
-#define WCD934X_SIDO_TEST_1                                0x0654
-#define WCD934X_SIDO_TEST_2                                0x0655
-#define WCD934X_MBHC_CTL_CLK                               0x0656
-#define WCD934X_MBHC_CTL_ANA                               0x0657
-#define WCD934X_MBHC_CTL_SPARE_1                           0x0658
-#define WCD934X_MBHC_CTL_SPARE_2                           0x0659
-#define WCD934X_MBHC_CTL_BCS                               0x065a
-#define WCD934X_MBHC_STATUS_SPARE_1                        0x065b
-#define WCD934X_MBHC_TEST_CTL                              0x065c
-#define WCD934X_VBADC_SUBBLOCK_EN                          0x065d
-#define WCD934X_VBADC_IBIAS_FE                             0x065e
-#define WCD934X_VBADC_BIAS_ADC                             0x065f
-#define WCD934X_VBADC_FE_CTRL                              0x0660
-#define WCD934X_VBADC_ADC_REF                              0x0661
-#define WCD934X_VBADC_ADC_IO                               0x0662
-#define WCD934X_VBADC_ADC_SAR                              0x0663
-#define WCD934X_VBADC_DEBUG                                0x0664
-#define WCD934X_LDOH_MODE                                  0x0667
-#define WCD934X_LDOH_BIAS                                  0x0668
-#define WCD934X_LDOH_STB_LOADS                             0x0669
-#define WCD934X_LDOH_SLOWRAMP                              0x066a
-#define WCD934X_MICB1_TEST_CTL_1                           0x066b
-#define WCD934X_MICB1_TEST_CTL_2                           0x066c
-#define WCD934X_MICB1_TEST_CTL_3                           0x066d
-#define WCD934X_MICB2_TEST_CTL_1                           0x066e
-#define WCD934X_MICB2_TEST_CTL_2                           0x066f
-#define WCD934X_MICB2_TEST_CTL_3                           0x0670
-#define WCD934X_MICB3_TEST_CTL_1                           0x0671
-#define WCD934X_MICB3_TEST_CTL_2                           0x0672
-#define WCD934X_MICB3_TEST_CTL_3                           0x0673
-#define WCD934X_MICB4_TEST_CTL_1                           0x0674
-#define WCD934X_MICB4_TEST_CTL_2                           0x0675
-#define WCD934X_MICB4_TEST_CTL_3                           0x0676
-#define WCD934X_TX_COM_ADC_VCM                             0x0677
-#define WCD934X_TX_COM_BIAS_ATEST                          0x0678
-#define WCD934X_TX_COM_ADC_INT1_IB                         0x0679
-#define WCD934X_TX_COM_ADC_INT2_IB                         0x067a
-#define WCD934X_TX_COM_TXFE_DIV_CTL                        0x067b
-#define WCD934X_TX_COM_TXFE_DIV_START                      0x067c
-#define WCD934X_TX_COM_TXFE_DIV_STOP_9P6M                  0x067d
-#define WCD934X_TX_COM_TXFE_DIV_STOP_12P288M               0x067e
-#define WCD934X_TX_1_2_TEST_EN                             0x067f
-#define WCD934X_TX_1_2_ADC_IB                              0x0680
-#define WCD934X_TX_1_2_ATEST_REFCTL                        0x0681
-#define WCD934X_TX_1_2_TEST_CTL                            0x0682
-#define WCD934X_TX_1_2_TEST_BLK_EN                         0x0683
-#define WCD934X_TX_1_2_TXFE_CLKDIV                         0x0684
-#define WCD934X_TX_1_2_SAR1_ERR                            0x0685
-#define WCD934X_TX_1_2_SAR2_ERR                            0x0686
-#define WCD934X_TX_3_4_TEST_EN                             0x0687
-#define WCD934X_TX_3_4_ADC_IB                              0x0688
-#define WCD934X_TX_3_4_ATEST_REFCTL                        0x0689
-#define WCD934X_TX_3_4_TEST_CTL                            0x068a
-#define WCD934X_TX_3_4_TEST_BLK_EN                         0x068b
-#define WCD934X_TX_3_4_TXFE_CLKDIV                         0x068c
-#define WCD934X_TX_3_4_SAR1_ERR                            0x068d
-#define WCD934X_TX_3_4_SAR2_ERR                            0x068e
-#define WCD934X_CLASSH_MODE_1                              0x0697
-#define WCD934X_CLASSH_MODE_2                              0x0698
-#define WCD934X_CLASSH_MODE_3                              0x0699
-#define WCD934X_CLASSH_CTRL_VCL_1                          0x069a
-#define WCD934X_CLASSH_CTRL_VCL_2                          0x069b
-#define WCD934X_CLASSH_CTRL_CCL_1                          0x069c
-#define WCD934X_CLASSH_CTRL_CCL_2                          0x069d
-#define WCD934X_CLASSH_CTRL_CCL_3                          0x069e
-#define WCD934X_CLASSH_CTRL_CCL_4                          0x069f
-#define WCD934X_CLASSH_CTRL_CCL_5                          0x06a0
-#define WCD934X_CLASSH_BUCK_TMUX_A_D                       0x06a1
-#define WCD934X_CLASSH_BUCK_SW_DRV_CNTL                    0x06a2
-#define WCD934X_CLASSH_SPARE                               0x06a3
-#define WCD934X_FLYBACK_EN                                 0x06a4
-#define WCD934X_FLYBACK_VNEG_CTRL_1                        0x06a5
-#define WCD934X_FLYBACK_VNEG_CTRL_2                        0x06a6
-#define WCD934X_FLYBACK_VNEG_CTRL_3                        0x06a7
-#define WCD934X_FLYBACK_VNEG_CTRL_4                        0x06a8
-#define WCD934X_FLYBACK_VNEG_CTRL_5                        0x06a9
-#define WCD934X_FLYBACK_VNEG_CTRL_6                        0x06aa
-#define WCD934X_FLYBACK_VNEG_CTRL_7                        0x06ab
-#define WCD934X_FLYBACK_VNEG_CTRL_8                        0x06ac
-#define WCD934X_FLYBACK_VNEG_CTRL_9                        0x06ad
-#define WCD934X_FLYBACK_VNEGDAC_CTRL_1                     0x06ae
-#define WCD934X_FLYBACK_VNEGDAC_CTRL_2                     0x06af
-#define WCD934X_FLYBACK_VNEGDAC_CTRL_3                     0x06b0
-#define WCD934X_FLYBACK_CTRL_1                             0x06b1
-#define WCD934X_FLYBACK_TEST_CTL                           0x06b2
-#define WCD934X_RX_AUX_SW_CTL                              0x06b3
-#define WCD934X_RX_PA_AUX_IN_CONN                          0x06b4
-#define WCD934X_RX_TIMER_DIV                               0x06b5
-#define WCD934X_RX_OCP_CTL                                 0x06b6
-#define WCD934X_RX_OCP_COUNT                               0x06b7
-#define WCD934X_RX_BIAS_EAR_DAC                            0x06b8
-#define WCD934X_RX_BIAS_EAR_AMP                            0x06b9
-#define WCD934X_RX_BIAS_HPH_LDO                            0x06ba
-#define WCD934X_RX_BIAS_HPH_PA                             0x06bb
-#define WCD934X_RX_BIAS_HPH_RDACBUFF_CNP2                  0x06bc
-#define WCD934X_RX_BIAS_HPH_RDAC_LDO                       0x06bd
-#define WCD934X_RX_BIAS_HPH_CNP1                           0x06be
-#define WCD934X_RX_BIAS_HPH_LOWPOWER                       0x06bf
-#define WCD934X_RX_BIAS_DIFFLO_PA                          0x06c0
-#define WCD934X_RX_BIAS_DIFFLO_REF                         0x06c1
-#define WCD934X_RX_BIAS_DIFFLO_LDO                         0x06c2
-#define WCD934X_RX_BIAS_SELO_DAC_PA                        0x06c3
-#define WCD934X_RX_BIAS_BUCK_RST                           0x06c4
-#define WCD934X_RX_BIAS_BUCK_VREF_ERRAMP                   0x06c5
-#define WCD934X_RX_BIAS_FLYB_ERRAMP                        0x06c6
-#define WCD934X_RX_BIAS_FLYB_BUFF                          0x06c7
-#define WCD934X_RX_BIAS_FLYB_MID_RST                       0x06c8
-#define WCD934X_HPH_L_STATUS                               0x06c9
-#define WCD934X_HPH_R_STATUS                               0x06ca
-#define WCD934X_HPH_CNP_EN                                 0x06cb
-#define WCD934X_HPH_CNP_WG_CTL                             0x06cc
-#define WCD934X_HPH_CNP_WG_TIME                            0x06cd
-#define WCD934X_HPH_OCP_CTL                                0x06ce
-#define WCD934X_HPH_AUTO_CHOP                              0x06cf
-#define WCD934X_HPH_CHOP_CTL                               0x06d0
-#define WCD934X_HPH_PA_CTL1                                0x06d1
-#define WCD934X_HPH_PA_CTL2                                0x06d2
-#define WCD934X_HPH_L_EN                                   0x06d3
-#define WCD934X_HPH_L_TEST                                 0x06d4
-#define WCD934X_HPH_L_ATEST                                0x06d5
-#define WCD934X_HPH_R_EN                                   0x06d6
-#define WCD934X_HPH_R_TEST                                 0x06d7
-#define WCD934X_HPH_R_ATEST                                0x06d8
-#define WCD934X_HPH_RDAC_CLK_CTL1                          0x06d9
-#define WCD934X_HPH_RDAC_CLK_CTL2                          0x06da
-#define WCD934X_HPH_RDAC_LDO_CTL                           0x06db
-#define WCD934X_HPH_RDAC_CHOP_CLK_LP_CTL                   0x06dc
-#define WCD934X_HPH_REFBUFF_UHQA_CTL                       0x06dd
-#define WCD934X_HPH_REFBUFF_LP_CTL                         0x06de
-#define WCD934X_HPH_L_DAC_CTL                              0x06df
-#define WCD934X_HPH_R_DAC_CTL                              0x06e0
-#define WCD934X_EAR_EN_REG                                 0x06e1
-#define WCD934X_EAR_CMBUFF                                 0x06e2
-#define WCD934X_EAR_ICTL                                   0x06e3
-#define WCD934X_EAR_EN_DBG_CTL                             0x06e4
-#define WCD934X_EAR_CNP                                    0x06e5
-#define WCD934X_EAR_DAC_CTL_ATEST                          0x06e6
-#define WCD934X_EAR_STATUS_REG                             0x06e7
-#define WCD934X_EAR_EAR_MISC                               0x06e8
-#define WCD934X_DIFF_LO_MISC                               0x06e9
-#define WCD934X_DIFF_LO_LO2_COMPANDER                      0x06ea
-#define WCD934X_DIFF_LO_LO1_COMPANDER                      0x06eb
-#define WCD934X_DIFF_LO_COMMON                             0x06ec
-#define WCD934X_DIFF_LO_BYPASS_EN                          0x06ed
-#define WCD934X_DIFF_LO_CNP                                0x06ee
-#define WCD934X_DIFF_LO_CORE_OUT_PROG                      0x06ef
-#define WCD934X_DIFF_LO_LDO_OUT_PROG                       0x06f0
-#define WCD934X_DIFF_LO_COM_SWCAP_REFBUF_FREQ              0x06f1
-#define WCD934X_DIFF_LO_COM_PA_FREQ                        0x06f2
-#define WCD934X_DIFF_LO_RESERVED_REG                       0x06f3
-#define WCD934X_DIFF_LO_LO1_STATUS_1                       0x06f4
-#define WCD934X_DIFF_LO_LO1_STATUS_2                       0x06f5
-#define WCD934X_ANA_NEW_PAGE_REGISTER                      0x0700
-#define WCD934X_HPH_NEW_ANA_HPH2                           0x0701
-#define WCD934X_HPH_NEW_ANA_HPH3                           0x0702
-#define WCD934X_SLNQ_ANA_EN                                0x0703
-#define WCD934X_SLNQ_ANA_STATUS                            0x0704
-#define WCD934X_SLNQ_ANA_LDO_CONFIG                        0x0705
-#define WCD934X_SLNQ_ANA_LDO_OCP_CONFIG                    0x0706
-#define WCD934X_SLNQ_ANA_TX_LDO_CONFIG                     0x0707
-#define WCD934X_SLNQ_ANA_TX_DRV_CONFIG                     0x0708
-#define WCD934X_SLNQ_ANA_RX_CONFIG_1                       0x0709
-#define WCD934X_SLNQ_ANA_RX_CONFIG_2                       0x070a
-#define WCD934X_SLNQ_ANA_PLL_ENABLES                       0x070b
-#define WCD934X_SLNQ_ANA_PLL_PRESET                        0x070c
-#define WCD934X_SLNQ_ANA_PLL_STATUS                        0x070d
-#define WCD934X_CLK_SYS_PLL_ENABLES                        0x070e
-#define WCD934X_CLK_SYS_PLL_PRESET                         0x070f
-#define WCD934X_CLK_SYS_PLL_STATUS                         0x0710
-#define WCD934X_CLK_SYS_MCLK_PRG                           0x0711
-#define WCD934X_CLK_SYS_MCLK2_PRG1                         0x0712
-#define WCD934X_CLK_SYS_MCLK2_PRG2                         0x0713
-#define WCD934X_CLK_SYS_XO_PRG                             0x0714
-#define WCD934X_CLK_SYS_XO_CAP_XTP                         0x0715
-#define WCD934X_CLK_SYS_XO_CAP_XTM                         0x0716
-#define WCD934X_BOOST_BST_EN_DLY                           0x0718
-#define WCD934X_BOOST_CTRL_ILIM                            0x0719
-#define WCD934X_BOOST_VOUT_SETTING                         0x071a
-#define WCD934X_SIDO_NEW_VOUT_A_STARTUP                    0x071b
-#define WCD934X_SIDO_NEW_VOUT_D_STARTUP                    0x071c
-#define WCD934X_SIDO_NEW_VOUT_D_FREQ1                      0x071d
-#define WCD934X_SIDO_NEW_VOUT_D_FREQ2                      0x071e
-#define WCD934X_MBHC_NEW_ELECT_REM_CLAMP_CTL               0x071f
-#define WCD934X_MBHC_NEW_CTL_1                             0x0720
-#define WCD934X_MBHC_NEW_CTL_2                             0x0721
-#define WCD934X_MBHC_NEW_PLUG_DETECT_CTL                   0x0722
-#define WCD934X_MBHC_NEW_ZDET_ANA_CTL                      0x0723
-#define WCD934X_MBHC_NEW_ZDET_RAMP_CTL                     0x0724
-#define WCD934X_MBHC_NEW_FSM_STATUS                        0x0725
-#define WCD934X_MBHC_NEW_ADC_RESULT                        0x0726
-#define WCD934X_TX_NEW_AMIC_4_5_SEL                        0x0727
-#define WCD934X_VBADC_NEW_ADC_MODE                         0x072f
-#define WCD934X_VBADC_NEW_ADC_DOUTMSB                      0x0730
-#define WCD934X_VBADC_NEW_ADC_DOUTLSB                      0x0731
-#define WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL                  0x0732
-#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL                   0x0733
-#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L                 0x0733
-#define WCD934X_HPH_NEW_INT_RDAC_VREF_CTL                  0x0734
-#define WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL              0x0735
-#define WCD934X_HPH_NEW_INT_RDAC_MISC1                     0x0736
-#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R                 0x0736
-#define WCD934X_HPH_NEW_INT_PA_MISC1                       0x0737
-#define WCD934X_HPH_NEW_INT_PA_MISC2                       0x0738
-#define WCD934X_HPH_NEW_INT_PA_RDAC_MISC                   0x0739
-#define WCD934X_HPH_NEW_INT_HPH_TIMER1                     0x073a
-#define WCD934X_HPH_NEW_INT_HPH_TIMER2                     0x073b
-#define WCD934X_HPH_NEW_INT_HPH_TIMER3                     0x073c
-#define WCD934X_HPH_NEW_INT_HPH_TIMER4                     0x073d
-#define WCD934X_HPH_NEW_INT_PA_RDAC_MISC2                  0x073e
-#define WCD934X_HPH_NEW_INT_PA_RDAC_MISC3                  0x073f
-#define WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI            0x0745
-#define WCD934X_RX_NEW_INT_HPH_RDAC_BIAS_ULP               0x0746
-#define WCD934X_RX_NEW_INT_HPH_RDAC_LDO_LP                 0x0747
-#define WCD934X_SLNQ_INT_ANA_INT_LDO_TEST                  0x074b
-#define WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_1               0x074c
-#define WCD934X_SLNQ_INT_ANA_INT_LDO_DEBUG_2               0x074d
-#define WCD934X_SLNQ_INT_ANA_INT_TX_LDO_TEST               0x074e
-#define WCD934X_SLNQ_INT_ANA_INT_TX_DRV_TEST               0x074f
-#define WCD934X_SLNQ_INT_ANA_INT_RX_TEST                   0x0750
-#define WCD934X_SLNQ_INT_ANA_INT_RX_TEST_STATUS            0x0751
-#define WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_1                0x0752
-#define WCD934X_SLNQ_INT_ANA_INT_RX_DEBUG_2                0x0753
-#define WCD934X_SLNQ_INT_ANA_INT_CLK_CTRL                  0x0754
-#define WCD934X_SLNQ_INT_ANA_INT_RESERVED_1                0x0755
-#define WCD934X_SLNQ_INT_ANA_INT_RESERVED_2                0x0756
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG0         0x0757
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_POST_DIV_REG1         0x0758
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG0          0x0759
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_REF_DIV_REG1          0x075a
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG0           0x075b
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_FILTER_REG1           0x075c
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_L_VAL                 0x075d
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_M_VAL                 0x075e
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_N_VAL                 0x075f
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG0             0x0760
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_PFD_CP_DSM_PROG       0x0761
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_VCO_PROG              0x0762
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_TEST_REG1             0x0763
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_LDO_LOCK_CFG          0x0764
-#define WCD934X_SLNQ_INT_ANA_INT_PLL_DIG_LOCK_DET_CFG      0x0765
-#define WCD934X_CLK_SYS_INT_POST_DIV_REG0                  0x076c
-#define WCD934X_CLK_SYS_INT_POST_DIV_REG1                  0x076d
-#define WCD934X_CLK_SYS_INT_REF_DIV_REG0                   0x076e
-#define WCD934X_CLK_SYS_INT_REF_DIV_REG1                   0x076f
-#define WCD934X_CLK_SYS_INT_FILTER_REG0                    0x0770
-#define WCD934X_CLK_SYS_INT_FILTER_REG1                    0x0771
-#define WCD934X_CLK_SYS_INT_PLL_L_VAL                      0x0772
-#define WCD934X_CLK_SYS_INT_PLL_M_VAL                      0x0773
-#define WCD934X_CLK_SYS_INT_PLL_N_VAL                      0x0774
-#define WCD934X_CLK_SYS_INT_TEST_REG0                      0x0775
-#define WCD934X_CLK_SYS_INT_PFD_CP_DSM_PROG                0x0776
-#define WCD934X_CLK_SYS_INT_VCO_PROG                       0x0777
-#define WCD934X_CLK_SYS_INT_TEST_REG1                      0x0778
-#define WCD934X_CLK_SYS_INT_LDO_LOCK_CFG                   0x0779
-#define WCD934X_CLK_SYS_INT_DIG_LOCK_DET_CFG               0x077a
-#define WCD934X_CLK_SYS_INT_CLK_TEST1                      0x077b
-#define WCD934X_CLK_SYS_INT_CLK_TEST2                      0x077c
-#define WCD934X_CLK_SYS_INT_CLK_TEST3                      0x077d
-#define WCD934X_CLK_SYS_INT_XO_TEST1                       0x077e
-#define WCD934X_CLK_SYS_INT_XO_TEST2                       0x077f
-#define WCD934X_BOOST_INT_VCOMP_HYST                       0x0787
-#define WCD934X_BOOST_INT_VLOOP_FILTER                     0x0788
-#define WCD934X_BOOST_INT_CTRL_IDELTA                      0x0789
-#define WCD934X_BOOST_INT_CTRL_ILIM_STARTUP                0x078a
-#define WCD934X_BOOST_INT_CTRL_MIN_ONTIME                  0x078b
-#define WCD934X_BOOST_INT_CTRL_MAX_ONTIME                  0x078c
-#define WCD934X_BOOST_INT_CTRL_TIMING                      0x078d
-#define WCD934X_BOOST_INT_TMUX_A_D                         0x078e
-#define WCD934X_BOOST_INT_SW_DRV_CNTL                      0x078f
-#define WCD934X_BOOST_INT_SPARE1                           0x0790
-#define WCD934X_BOOST_INT_SPARE2                           0x0791
-#define WCD934X_SIDO_NEW_INT_RAMP_STATUS                   0x0796
-#define WCD934X_SIDO_NEW_INT_SPARE_1                       0x0797
-#define WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_A          0x0798
-#define WCD934X_SIDO_NEW_INT_DEBUG_VOUT_SETTING_D          0x0799
-#define WCD934X_SIDO_NEW_INT_RAMP_INC_WAIT                 0x079a
-#define WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_CTL             0x079b
-#define WCD934X_SIDO_NEW_INT_RAMP_IBLEED_CTL               0x079c
-#define WCD934X_SIDO_NEW_INT_DEBUG_CPROVR_TEST             0x079d
-#define WCD934X_SIDO_NEW_INT_RAMP_CTL_A                    0x079e
-#define WCD934X_SIDO_NEW_INT_RAMP_CTL_D                    0x079f
-#define WCD934X_SIDO_NEW_INT_RAMP_TIMEOUT_PERIOD           0x07a0
-#define WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING1        0x07a1
-#define WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING2        0x07a2
-#define WCD934X_SIDO_NEW_INT_DYNAMIC_IPEAK_SETTING3        0x07a3
-#define WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL1           0x07a4
-#define WCD934X_SIDO_NEW_INT_HIGH_ACCU_MODE_SEL2           0x07a5
-#define WCD934X_MBHC_NEW_INT_SLNQ_HPF                      0x07af
-#define WCD934X_MBHC_NEW_INT_SLNQ_REF                      0x07b0
-#define WCD934X_MBHC_NEW_INT_SLNQ_COMP                     0x07b1
-#define WCD934X_MBHC_NEW_INT_SPARE_2                       0x07b2
-#define WCD934X_PAGE10_PAGE_REGISTER                       0x0a00
-#define WCD934X_CDC_ANC0_CLK_RESET_CTL                     0x0a01
-#define WCD934X_CDC_ANC0_MODE_1_CTL                        0x0a02
-#define WCD934X_CDC_ANC0_MODE_2_CTL                        0x0a03
-#define WCD934X_CDC_ANC0_FF_SHIFT                          0x0a04
-#define WCD934X_CDC_ANC0_FB_SHIFT                          0x0a05
-#define WCD934X_CDC_ANC0_LPF_FF_A_CTL                      0x0a06
-#define WCD934X_CDC_ANC0_LPF_FF_B_CTL                      0x0a07
-#define WCD934X_CDC_ANC0_LPF_FB_CTL                        0x0a08
-#define WCD934X_CDC_ANC0_SMLPF_CTL                         0x0a09
-#define WCD934X_CDC_ANC0_DCFLT_SHIFT_CTL                   0x0a0a
-#define WCD934X_CDC_ANC0_IIR_ADAPT_CTL                     0x0a0b
-#define WCD934X_CDC_ANC0_IIR_COEFF_1_CTL                   0x0a0c
-#define WCD934X_CDC_ANC0_IIR_COEFF_2_CTL                   0x0a0d
-#define WCD934X_CDC_ANC0_FF_A_GAIN_CTL                     0x0a0e
-#define WCD934X_CDC_ANC0_FF_B_GAIN_CTL                     0x0a0f
-#define WCD934X_CDC_ANC0_FB_GAIN_CTL                       0x0a10
-#define WCD934X_CDC_ANC0_RC_COMMON_CTL                     0x0a11
-#define WCD934X_CDC_ANC0_FIFO_COMMON_CTL                   0x0a13
-#define WCD934X_CDC_ANC0_RC0_STATUS_FMIN_CNTR              0x0a14
-#define WCD934X_CDC_ANC0_RC1_STATUS_FMIN_CNTR              0x0a15
-#define WCD934X_CDC_ANC0_RC0_STATUS_FMAX_CNTR              0x0a16
-#define WCD934X_CDC_ANC0_RC1_STATUS_FMAX_CNTR              0x0a17
-#define WCD934X_CDC_ANC0_STATUS_FIFO                       0x0a18
-#define WCD934X_CDC_ANC1_CLK_RESET_CTL                     0x0a19
-#define WCD934X_CDC_ANC1_MODE_1_CTL                        0x0a1a
-#define WCD934X_CDC_ANC1_MODE_2_CTL                        0x0a1b
-#define WCD934X_CDC_ANC1_FF_SHIFT                          0x0a1c
-#define WCD934X_CDC_ANC1_FB_SHIFT                          0x0a1d
-#define WCD934X_CDC_ANC1_LPF_FF_A_CTL                      0x0a1e
-#define WCD934X_CDC_ANC1_LPF_FF_B_CTL                      0x0a1f
-#define WCD934X_CDC_ANC1_LPF_FB_CTL                        0x0a20
-#define WCD934X_CDC_ANC1_SMLPF_CTL                         0x0a21
-#define WCD934X_CDC_ANC1_DCFLT_SHIFT_CTL                   0x0a22
-#define WCD934X_CDC_ANC1_IIR_ADAPT_CTL                     0x0a23
-#define WCD934X_CDC_ANC1_IIR_COEFF_1_CTL                   0x0a24
-#define WCD934X_CDC_ANC1_IIR_COEFF_2_CTL                   0x0a25
-#define WCD934X_CDC_ANC1_FF_A_GAIN_CTL                     0x0a26
-#define WCD934X_CDC_ANC1_FF_B_GAIN_CTL                     0x0a27
-#define WCD934X_CDC_ANC1_FB_GAIN_CTL                       0x0a28
-#define WCD934X_CDC_ANC1_RC_COMMON_CTL                     0x0a29
-#define WCD934X_CDC_ANC1_FIFO_COMMON_CTL                   0x0a2b
-#define WCD934X_CDC_ANC1_RC0_STATUS_FMIN_CNTR              0x0a2c
-#define WCD934X_CDC_ANC1_RC1_STATUS_FMIN_CNTR              0x0a2d
-#define WCD934X_CDC_ANC1_RC0_STATUS_FMAX_CNTR              0x0a2e
-#define WCD934X_CDC_ANC1_RC1_STATUS_FMAX_CNTR              0x0a2f
-#define WCD934X_CDC_ANC1_STATUS_FIFO                       0x0a30
-#define WCD934X_CDC_TX0_TX_PATH_CTL                        0x0a31
-#define WCD934X_CDC_TX0_TX_PATH_CFG0                       0x0a32
-#define WCD934X_CDC_TX0_TX_PATH_CFG1                       0x0a33
-#define WCD934X_CDC_TX0_TX_VOL_CTL                         0x0a34
-#define WCD934X_CDC_TX0_TX_PATH_192_CTL                    0x0a35
-#define WCD934X_CDC_TX0_TX_PATH_192_CFG                    0x0a36
-#define WCD934X_CDC_TX0_TX_PATH_SEC0                       0x0a37
-#define WCD934X_CDC_TX0_TX_PATH_SEC1                       0x0a38
-#define WCD934X_CDC_TX0_TX_PATH_SEC2                       0x0a39
-#define WCD934X_CDC_TX0_TX_PATH_SEC3                       0x0a3a
-#define WCD934X_CDC_TX0_TX_PATH_SEC4                       0x0a3b
-#define WCD934X_CDC_TX0_TX_PATH_SEC5                       0x0a3c
-#define WCD934X_CDC_TX0_TX_PATH_SEC6                       0x0a3d
-#define WCD934X_CDC_TX0_TX_PATH_SEC7                       0x0a3e
-#define WCD934X_CDC_TX1_TX_PATH_CTL                        0x0a41
-#define WCD934X_CDC_TX1_TX_PATH_CFG0                       0x0a42
-#define WCD934X_CDC_TX1_TX_PATH_CFG1                       0x0a43
-#define WCD934X_CDC_TX1_TX_VOL_CTL                         0x0a44
-#define WCD934X_CDC_TX1_TX_PATH_192_CTL                    0x0a45
-#define WCD934X_CDC_TX1_TX_PATH_192_CFG                    0x0a46
-#define WCD934X_CDC_TX1_TX_PATH_SEC0                       0x0a47
-#define WCD934X_CDC_TX1_TX_PATH_SEC1                       0x0a48
-#define WCD934X_CDC_TX1_TX_PATH_SEC2                       0x0a49
-#define WCD934X_CDC_TX1_TX_PATH_SEC3                       0x0a4a
-#define WCD934X_CDC_TX1_TX_PATH_SEC4                       0x0a4b
-#define WCD934X_CDC_TX1_TX_PATH_SEC5                       0x0a4c
-#define WCD934X_CDC_TX1_TX_PATH_SEC6                       0x0a4d
-#define WCD934X_CDC_TX2_TX_PATH_CTL                        0x0a51
-#define WCD934X_CDC_TX2_TX_PATH_CFG0                       0x0a52
-#define WCD934X_CDC_TX2_TX_PATH_CFG1                       0x0a53
-#define WCD934X_CDC_TX2_TX_VOL_CTL                         0x0a54
-#define WCD934X_CDC_TX2_TX_PATH_192_CTL                    0x0a55
-#define WCD934X_CDC_TX2_TX_PATH_192_CFG                    0x0a56
-#define WCD934X_CDC_TX2_TX_PATH_SEC0                       0x0a57
-#define WCD934X_CDC_TX2_TX_PATH_SEC1                       0x0a58
-#define WCD934X_CDC_TX2_TX_PATH_SEC2                       0x0a59
-#define WCD934X_CDC_TX2_TX_PATH_SEC3                       0x0a5a
-#define WCD934X_CDC_TX2_TX_PATH_SEC4                       0x0a5b
-#define WCD934X_CDC_TX2_TX_PATH_SEC5                       0x0a5c
-#define WCD934X_CDC_TX2_TX_PATH_SEC6                       0x0a5d
-#define WCD934X_CDC_TX3_TX_PATH_CTL                        0x0a61
-#define WCD934X_CDC_TX3_TX_PATH_CFG0                       0x0a62
-#define WCD934X_CDC_TX3_TX_PATH_CFG1                       0x0a63
-#define WCD934X_CDC_TX3_TX_VOL_CTL                         0x0a64
-#define WCD934X_CDC_TX3_TX_PATH_192_CTL                    0x0a65
-#define WCD934X_CDC_TX3_TX_PATH_192_CFG                    0x0a66
-#define WCD934X_CDC_TX3_TX_PATH_SEC0                       0x0a67
-#define WCD934X_CDC_TX3_TX_PATH_SEC1                       0x0a68
-#define WCD934X_CDC_TX3_TX_PATH_SEC2                       0x0a69
-#define WCD934X_CDC_TX3_TX_PATH_SEC3                       0x0a6a
-#define WCD934X_CDC_TX3_TX_PATH_SEC4                       0x0a6b
-#define WCD934X_CDC_TX3_TX_PATH_SEC5                       0x0a6c
-#define WCD934X_CDC_TX3_TX_PATH_SEC6                       0x0a6d
-#define WCD934X_CDC_TX4_TX_PATH_CTL                        0x0a71
-#define WCD934X_CDC_TX4_TX_PATH_CFG0                       0x0a72
-#define WCD934X_CDC_TX4_TX_PATH_CFG1                       0x0a73
-#define WCD934X_CDC_TX4_TX_VOL_CTL                         0x0a74
-#define WCD934X_CDC_TX4_TX_PATH_192_CTL                    0x0a75
-#define WCD934X_CDC_TX4_TX_PATH_192_CFG                    0x0a76
-#define WCD934X_CDC_TX4_TX_PATH_SEC0                       0x0a77
-#define WCD934X_CDC_TX4_TX_PATH_SEC1                       0x0a78
-#define WCD934X_CDC_TX4_TX_PATH_SEC2                       0x0a79
-#define WCD934X_CDC_TX4_TX_PATH_SEC3                       0x0a7a
-#define WCD934X_CDC_TX4_TX_PATH_SEC4                       0x0a7b
-#define WCD934X_CDC_TX4_TX_PATH_SEC5                       0x0a7c
-#define WCD934X_CDC_TX4_TX_PATH_SEC6                       0x0a7d
-#define WCD934X_CDC_TX5_TX_PATH_CTL                        0x0a81
-#define WCD934X_CDC_TX5_TX_PATH_CFG0                       0x0a82
-#define WCD934X_CDC_TX5_TX_PATH_CFG1                       0x0a83
-#define WCD934X_CDC_TX5_TX_VOL_CTL                         0x0a84
-#define WCD934X_CDC_TX5_TX_PATH_192_CTL                    0x0a85
-#define WCD934X_CDC_TX5_TX_PATH_192_CFG                    0x0a86
-#define WCD934X_CDC_TX5_TX_PATH_SEC0                       0x0a87
-#define WCD934X_CDC_TX5_TX_PATH_SEC1                       0x0a88
-#define WCD934X_CDC_TX5_TX_PATH_SEC2                       0x0a89
-#define WCD934X_CDC_TX5_TX_PATH_SEC3                       0x0a8a
-#define WCD934X_CDC_TX5_TX_PATH_SEC4                       0x0a8b
-#define WCD934X_CDC_TX5_TX_PATH_SEC5                       0x0a8c
-#define WCD934X_CDC_TX5_TX_PATH_SEC6                       0x0a8d
-#define WCD934X_CDC_TX6_TX_PATH_CTL                        0x0a91
-#define WCD934X_CDC_TX6_TX_PATH_CFG0                       0x0a92
-#define WCD934X_CDC_TX6_TX_PATH_CFG1                       0x0a93
-#define WCD934X_CDC_TX6_TX_VOL_CTL                         0x0a94
-#define WCD934X_CDC_TX6_TX_PATH_192_CTL                    0x0a95
-#define WCD934X_CDC_TX6_TX_PATH_192_CFG                    0x0a96
-#define WCD934X_CDC_TX6_TX_PATH_SEC0                       0x0a97
-#define WCD934X_CDC_TX6_TX_PATH_SEC1                       0x0a98
-#define WCD934X_CDC_TX6_TX_PATH_SEC2                       0x0a99
-#define WCD934X_CDC_TX6_TX_PATH_SEC3                       0x0a9a
-#define WCD934X_CDC_TX6_TX_PATH_SEC4                       0x0a9b
-#define WCD934X_CDC_TX6_TX_PATH_SEC5                       0x0a9c
-#define WCD934X_CDC_TX6_TX_PATH_SEC6                       0x0a9d
-#define WCD934X_CDC_TX7_TX_PATH_CTL                        0x0aa1
-#define WCD934X_CDC_TX7_TX_PATH_CFG0                       0x0aa2
-#define WCD934X_CDC_TX7_TX_PATH_CFG1                       0x0aa3
-#define WCD934X_CDC_TX7_TX_VOL_CTL                         0x0aa4
-#define WCD934X_CDC_TX7_TX_PATH_192_CTL                    0x0aa5
-#define WCD934X_CDC_TX7_TX_PATH_192_CFG                    0x0aa6
-#define WCD934X_CDC_TX7_TX_PATH_SEC0                       0x0aa7
-#define WCD934X_CDC_TX7_TX_PATH_SEC1                       0x0aa8
-#define WCD934X_CDC_TX7_TX_PATH_SEC2                       0x0aa9
-#define WCD934X_CDC_TX7_TX_PATH_SEC3                       0x0aaa
-#define WCD934X_CDC_TX7_TX_PATH_SEC4                       0x0aab
-#define WCD934X_CDC_TX7_TX_PATH_SEC5                       0x0aac
-#define WCD934X_CDC_TX7_TX_PATH_SEC6                       0x0aad
-#define WCD934X_CDC_TX8_TX_PATH_CTL                        0x0ab1
-#define WCD934X_CDC_TX8_TX_PATH_CFG0                       0x0ab2
-#define WCD934X_CDC_TX8_TX_PATH_CFG1                       0x0ab3
-#define WCD934X_CDC_TX8_TX_VOL_CTL                         0x0ab4
-#define WCD934X_CDC_TX8_TX_PATH_192_CTL                    0x0ab5
-#define WCD934X_CDC_TX8_TX_PATH_192_CFG                    0x0ab6
-#define WCD934X_CDC_TX8_TX_PATH_SEC0                       0x0ab7
-#define WCD934X_CDC_TX8_TX_PATH_SEC1                       0x0ab8
-#define WCD934X_CDC_TX8_TX_PATH_SEC2                       0x0ab9
-#define WCD934X_CDC_TX8_TX_PATH_SEC3                       0x0aba
-#define WCD934X_CDC_TX8_TX_PATH_SEC4                       0x0abb
-#define WCD934X_CDC_TX8_TX_PATH_SEC5                       0x0abc
-#define WCD934X_CDC_TX8_TX_PATH_SEC6                       0x0abd
-#define WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL                 0x0ac2
-#define WCD934X_CDC_TX9_SPKR_PROT_PATH_CFG0                0x0ac3
-#define WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL                0x0ac6
-#define WCD934X_CDC_TX10_SPKR_PROT_PATH_CFG0               0x0ac7
-#define WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL                0x0aca
-#define WCD934X_CDC_TX11_SPKR_PROT_PATH_CFG0               0x0acb
-#define WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL                0x0ace
-#define WCD934X_CDC_TX12_SPKR_PROT_PATH_CFG0               0x0acf
-#define WCD934X_PAGE11_PAGE_REGISTER                       0x0b00
-#define WCD934X_CDC_COMPANDER1_CTL0                        0x0b01
-#define WCD934X_CDC_COMPANDER1_CTL1                        0x0b02
-#define WCD934X_CDC_COMPANDER1_CTL2                        0x0b03
-#define WCD934X_CDC_COMPANDER1_CTL3                        0x0b04
-#define WCD934X_CDC_COMPANDER1_CTL4                        0x0b05
-#define WCD934X_CDC_COMPANDER1_CTL5                        0x0b06
-#define WCD934X_CDC_COMPANDER1_CTL6                        0x0b07
-#define WCD934X_CDC_COMPANDER1_CTL7                        0x0b08
-#define WCD934X_CDC_COMPANDER2_CTL0                        0x0b09
-#define WCD934X_CDC_COMPANDER2_CTL1                        0x0b0a
-#define WCD934X_CDC_COMPANDER2_CTL2                        0x0b0b
-#define WCD934X_CDC_COMPANDER2_CTL3                        0x0b0c
-#define WCD934X_CDC_COMPANDER2_CTL4                        0x0b0d
-#define WCD934X_CDC_COMPANDER2_CTL5                        0x0b0e
-#define WCD934X_CDC_COMPANDER2_CTL6                        0x0b0f
-#define WCD934X_CDC_COMPANDER2_CTL7                        0x0b10
-#define WCD934X_CDC_COMPANDER3_CTL0                        0x0b11
-#define WCD934X_CDC_COMPANDER3_CTL1                        0x0b12
-#define WCD934X_CDC_COMPANDER3_CTL2                        0x0b13
-#define WCD934X_CDC_COMPANDER3_CTL3                        0x0b14
-#define WCD934X_CDC_COMPANDER3_CTL4                        0x0b15
-#define WCD934X_CDC_COMPANDER3_CTL5                        0x0b16
-#define WCD934X_CDC_COMPANDER3_CTL6                        0x0b17
-#define WCD934X_CDC_COMPANDER3_CTL7                        0x0b18
-#define WCD934X_CDC_COMPANDER4_CTL0                        0x0b19
-#define WCD934X_CDC_COMPANDER4_CTL1                        0x0b1a
-#define WCD934X_CDC_COMPANDER4_CTL2                        0x0b1b
-#define WCD934X_CDC_COMPANDER4_CTL3                        0x0b1c
-#define WCD934X_CDC_COMPANDER4_CTL4                        0x0b1d
-#define WCD934X_CDC_COMPANDER4_CTL5                        0x0b1e
-#define WCD934X_CDC_COMPANDER4_CTL6                        0x0b1f
-#define WCD934X_CDC_COMPANDER4_CTL7                        0x0b20
-#define WCD934X_CDC_COMPANDER7_CTL0                        0x0b31
-#define WCD934X_CDC_COMPANDER7_CTL1                        0x0b32
-#define WCD934X_CDC_COMPANDER7_CTL2                        0x0b33
-#define WCD934X_CDC_COMPANDER7_CTL3                        0x0b34
-#define WCD934X_CDC_COMPANDER7_CTL4                        0x0b35
-#define WCD934X_CDC_COMPANDER7_CTL5                        0x0b36
-#define WCD934X_CDC_COMPANDER7_CTL6                        0x0b37
-#define WCD934X_CDC_COMPANDER7_CTL7                        0x0b38
-#define WCD934X_CDC_COMPANDER8_CTL0                        0x0b39
-#define WCD934X_CDC_COMPANDER8_CTL1                        0x0b3a
-#define WCD934X_CDC_COMPANDER8_CTL2                        0x0b3b
-#define WCD934X_CDC_COMPANDER8_CTL3                        0x0b3c
-#define WCD934X_CDC_COMPANDER8_CTL4                        0x0b3d
-#define WCD934X_CDC_COMPANDER8_CTL5                        0x0b3e
-#define WCD934X_CDC_COMPANDER8_CTL6                        0x0b3f
-#define WCD934X_CDC_COMPANDER8_CTL7                        0x0b40
-#define WCD934X_CDC_RX0_RX_PATH_CTL                        0x0b41
-#define WCD934X_CDC_RX0_RX_PATH_CFG0                       0x0b42
-#define WCD934X_CDC_RX0_RX_PATH_CFG1                       0x0b43
-#define WCD934X_CDC_RX0_RX_PATH_CFG2                       0x0b44
-#define WCD934X_CDC_RX0_RX_VOL_CTL                         0x0b45
-#define WCD934X_CDC_RX0_RX_PATH_MIX_CTL                    0x0b46
-#define WCD934X_CDC_RX0_RX_PATH_MIX_CFG                    0x0b47
-#define WCD934X_CDC_RX0_RX_VOL_MIX_CTL                     0x0b48
-#define WCD934X_CDC_RX0_RX_PATH_SEC0                       0x0b49
-#define WCD934X_CDC_RX0_RX_PATH_SEC1                       0x0b4a
-#define WCD934X_CDC_RX0_RX_PATH_SEC2                       0x0b4b
-#define WCD934X_CDC_RX0_RX_PATH_SEC3                       0x0b4c
-#define WCD934X_CDC_RX0_RX_PATH_SEC5                       0x0b4e
-#define WCD934X_CDC_RX0_RX_PATH_SEC6                       0x0b4f
-#define WCD934X_CDC_RX0_RX_PATH_SEC7                       0x0b50
-#define WCD934X_CDC_RX0_RX_PATH_MIX_SEC0                   0x0b51
-#define WCD934X_CDC_RX0_RX_PATH_MIX_SEC1                   0x0b52
-#define WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL                 0x0b53
-#define WCD934X_CDC_RX1_RX_PATH_CTL                        0x0b55
-#define WCD934X_CDC_RX1_RX_PATH_CFG0                       0x0b56
-#define WCD934X_CDC_RX1_RX_PATH_CFG1                       0x0b57
-#define WCD934X_CDC_RX1_RX_PATH_CFG2                       0x0b58
-#define WCD934X_CDC_RX1_RX_VOL_CTL                         0x0b59
-#define WCD934X_CDC_RX1_RX_PATH_MIX_CTL                    0x0b5a
-#define WCD934X_CDC_RX1_RX_PATH_MIX_CFG                    0x0b5b
-#define WCD934X_CDC_RX1_RX_VOL_MIX_CTL                     0x0b5c
-#define WCD934X_CDC_RX1_RX_PATH_SEC0                       0x0b5d
-#define WCD934X_CDC_RX1_RX_PATH_SEC1                       0x0b5e
-#define WCD934X_CDC_RX1_RX_PATH_SEC2                       0x0b5f
-#define WCD934X_CDC_RX1_RX_PATH_SEC3                       0x0b60
-#define WCD934X_CDC_RX1_RX_PATH_SEC4                       0x0b61
-#define WCD934X_CDC_RX1_RX_PATH_SEC5                       0x0b62
-#define WCD934X_CDC_RX1_RX_PATH_SEC6                       0x0b63
-#define WCD934X_CDC_RX1_RX_PATH_SEC7                       0x0b64
-#define WCD934X_CDC_RX1_RX_PATH_MIX_SEC0                   0x0b65
-#define WCD934X_CDC_RX1_RX_PATH_MIX_SEC1                   0x0b66
-#define WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL                 0x0b67
-#define WCD934X_CDC_RX2_RX_PATH_CTL                        0x0b69
-#define WCD934X_CDC_RX2_RX_PATH_CFG0                       0x0b6a
-#define WCD934X_CDC_RX2_RX_PATH_CFG1                       0x0b6b
-#define WCD934X_CDC_RX2_RX_PATH_CFG2                       0x0b6c
-#define WCD934X_CDC_RX2_RX_VOL_CTL                         0x0b6d
-#define WCD934X_CDC_RX2_RX_PATH_MIX_CTL                    0x0b6e
-#define WCD934X_CDC_RX2_RX_PATH_MIX_CFG                    0x0b6f
-#define WCD934X_CDC_RX2_RX_VOL_MIX_CTL                     0x0b70
-#define WCD934X_CDC_RX2_RX_PATH_SEC0                       0x0b71
-#define WCD934X_CDC_RX2_RX_PATH_SEC1                       0x0b72
-#define WCD934X_CDC_RX2_RX_PATH_SEC2                       0x0b73
-#define WCD934X_CDC_RX2_RX_PATH_SEC3                       0x0b74
-#define WCD934X_CDC_RX2_RX_PATH_SEC4                       0x0b75
-#define WCD934X_CDC_RX2_RX_PATH_SEC5                       0x0b76
-#define WCD934X_CDC_RX2_RX_PATH_SEC6                       0x0b77
-#define WCD934X_CDC_RX2_RX_PATH_SEC7                       0x0b78
-#define WCD934X_CDC_RX2_RX_PATH_MIX_SEC0                   0x0b79
-#define WCD934X_CDC_RX2_RX_PATH_MIX_SEC1                   0x0b7a
-#define WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL                 0x0b7b
-#define WCD934X_CDC_RX3_RX_PATH_CTL                        0x0b7d
-#define WCD934X_CDC_RX3_RX_PATH_CFG0                       0x0b7e
-#define WCD934X_CDC_RX3_RX_PATH_CFG1                       0x0b7f
-#define WCD934X_CDC_RX3_RX_PATH_CFG2                       0x0b80
-#define WCD934X_CDC_RX3_RX_VOL_CTL                         0x0b81
-#define WCD934X_CDC_RX3_RX_PATH_MIX_CTL                    0x0b82
-#define WCD934X_CDC_RX3_RX_PATH_MIX_CFG                    0x0b83
-#define WCD934X_CDC_RX3_RX_VOL_MIX_CTL                     0x0b84
-#define WCD934X_CDC_RX3_RX_PATH_SEC0                       0x0b85
-#define WCD934X_CDC_RX3_RX_PATH_SEC1                       0x0b86
-#define WCD934X_CDC_RX3_RX_PATH_SEC2                       0x0b87
-#define WCD934X_CDC_RX3_RX_PATH_SEC3                       0x0b88
-#define WCD934X_CDC_RX3_RX_PATH_SEC5                       0x0b8a
-#define WCD934X_CDC_RX3_RX_PATH_SEC6                       0x0b8b
-#define WCD934X_CDC_RX3_RX_PATH_SEC7                       0x0b8c
-#define WCD934X_CDC_RX3_RX_PATH_MIX_SEC0                   0x0b8d
-#define WCD934X_CDC_RX3_RX_PATH_MIX_SEC1                   0x0b8e
-#define WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL                 0x0b8f
-#define WCD934X_CDC_RX4_RX_PATH_CTL                        0x0b91
-#define WCD934X_CDC_RX4_RX_PATH_CFG0                       0x0b92
-#define WCD934X_CDC_RX4_RX_PATH_CFG1                       0x0b93
-#define WCD934X_CDC_RX4_RX_PATH_CFG2                       0x0b94
-#define WCD934X_CDC_RX4_RX_VOL_CTL                         0x0b95
-#define WCD934X_CDC_RX4_RX_PATH_MIX_CTL                    0x0b96
-#define WCD934X_CDC_RX4_RX_PATH_MIX_CFG                    0x0b97
-#define WCD934X_CDC_RX4_RX_VOL_MIX_CTL                     0x0b98
-#define WCD934X_CDC_RX4_RX_PATH_SEC0                       0x0b99
-#define WCD934X_CDC_RX4_RX_PATH_SEC1                       0x0b9a
-#define WCD934X_CDC_RX4_RX_PATH_SEC2                       0x0b9b
-#define WCD934X_CDC_RX4_RX_PATH_SEC3                       0x0b9c
-#define WCD934X_CDC_RX4_RX_PATH_SEC5                       0x0b9e
-#define WCD934X_CDC_RX4_RX_PATH_SEC6                       0x0b9f
-#define WCD934X_CDC_RX4_RX_PATH_SEC7                       0x0ba0
-#define WCD934X_CDC_RX4_RX_PATH_MIX_SEC0                   0x0ba1
-#define WCD934X_CDC_RX4_RX_PATH_MIX_SEC1                   0x0ba2
-#define WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL                 0x0ba3
-#define WCD934X_CDC_RX7_RX_PATH_CTL                        0x0bcd
-#define WCD934X_CDC_RX7_RX_PATH_CFG0                       0x0bce
-#define WCD934X_CDC_RX7_RX_PATH_CFG1                       0x0bcf
-#define WCD934X_CDC_RX7_RX_PATH_CFG2                       0x0bd0
-#define WCD934X_CDC_RX7_RX_VOL_CTL                         0x0bd1
-#define WCD934X_CDC_RX7_RX_PATH_MIX_CTL                    0x0bd2
-#define WCD934X_CDC_RX7_RX_PATH_MIX_CFG                    0x0bd3
-#define WCD934X_CDC_RX7_RX_VOL_MIX_CTL                     0x0bd4
-#define WCD934X_CDC_RX7_RX_PATH_SEC0                       0x0bd5
-#define WCD934X_CDC_RX7_RX_PATH_SEC1                       0x0bd6
-#define WCD934X_CDC_RX7_RX_PATH_SEC2                       0x0bd7
-#define WCD934X_CDC_RX7_RX_PATH_SEC3                       0x0bd8
-#define WCD934X_CDC_RX7_RX_PATH_SEC5                       0x0bda
-#define WCD934X_CDC_RX7_RX_PATH_SEC6                       0x0bdb
-#define WCD934X_CDC_RX7_RX_PATH_SEC7                       0x0bdc
-#define WCD934X_CDC_RX7_RX_PATH_MIX_SEC0                   0x0bdd
-#define WCD934X_CDC_RX7_RX_PATH_MIX_SEC1                   0x0bde
-#define WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL                 0x0bdf
-#define WCD934X_CDC_RX8_RX_PATH_CTL                        0x0be1
-#define WCD934X_CDC_RX8_RX_PATH_CFG0                       0x0be2
-#define WCD934X_CDC_RX8_RX_PATH_CFG1                       0x0be3
-#define WCD934X_CDC_RX8_RX_PATH_CFG2                       0x0be4
-#define WCD934X_CDC_RX8_RX_VOL_CTL                         0x0be5
-#define WCD934X_CDC_RX8_RX_PATH_MIX_CTL                    0x0be6
-#define WCD934X_CDC_RX8_RX_PATH_MIX_CFG                    0x0be7
-#define WCD934X_CDC_RX8_RX_VOL_MIX_CTL                     0x0be8
-#define WCD934X_CDC_RX8_RX_PATH_SEC0                       0x0be9
-#define WCD934X_CDC_RX8_RX_PATH_SEC1                       0x0bea
-#define WCD934X_CDC_RX8_RX_PATH_SEC2                       0x0beb
-#define WCD934X_CDC_RX8_RX_PATH_SEC3                       0x0bec
-#define WCD934X_CDC_RX8_RX_PATH_SEC5                       0x0bee
-#define WCD934X_CDC_RX8_RX_PATH_SEC6                       0x0bef
-#define WCD934X_CDC_RX8_RX_PATH_SEC7                       0x0bf0
-#define WCD934X_CDC_RX8_RX_PATH_MIX_SEC0                   0x0bf1
-#define WCD934X_CDC_RX8_RX_PATH_MIX_SEC1                   0x0bf2
-#define WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL                 0x0bf3
-#define WCD934X_PAGE12_PAGE_REGISTER                       0x0c00
-#define WCD934X_CDC_CLSH_CRC                               0x0c01
-#define WCD934X_CDC_CLSH_DLY_CTRL                          0x0c02
-#define WCD934X_CDC_CLSH_DECAY_CTRL                        0x0c03
-#define WCD934X_CDC_CLSH_HPH_V_PA                          0x0c04
-#define WCD934X_CDC_CLSH_EAR_V_PA                          0x0c05
-#define WCD934X_CDC_CLSH_HPH_V_HD                          0x0c06
-#define WCD934X_CDC_CLSH_EAR_V_HD                          0x0c07
-#define WCD934X_CDC_CLSH_K1_MSB                            0x0c08
-#define WCD934X_CDC_CLSH_K1_LSB                            0x0c09
-#define WCD934X_CDC_CLSH_K2_MSB                            0x0c0a
-#define WCD934X_CDC_CLSH_K2_LSB                            0x0c0b
-#define WCD934X_CDC_CLSH_IDLE_CTRL                         0x0c0c
-#define WCD934X_CDC_CLSH_IDLE_HPH                          0x0c0d
-#define WCD934X_CDC_CLSH_IDLE_EAR                          0x0c0e
-#define WCD934X_CDC_CLSH_TEST0                             0x0c0f
-#define WCD934X_CDC_CLSH_TEST1                             0x0c10
-#define WCD934X_CDC_CLSH_OVR_VREF                          0x0c11
-#define WCD934X_CDC_BOOST0_BOOST_PATH_CTL                  0x0c19
-#define WCD934X_CDC_BOOST0_BOOST_CTL                       0x0c1a
-#define WCD934X_CDC_BOOST0_BOOST_CFG1                      0x0c1b
-#define WCD934X_CDC_BOOST0_BOOST_CFG2                      0x0c1c
-#define WCD934X_CDC_BOOST1_BOOST_PATH_CTL                  0x0c21
-#define WCD934X_CDC_BOOST1_BOOST_CTL                       0x0c22
-#define WCD934X_CDC_BOOST1_BOOST_CFG1                      0x0c23
-#define WCD934X_CDC_BOOST1_BOOST_CFG2                      0x0c24
-#define WCD934X_CDC_VBAT_VBAT_PATH_CTL                     0x0c3d
-#define WCD934X_CDC_VBAT_VBAT_CFG                          0x0c3e
-#define WCD934X_CDC_VBAT_VBAT_ADC_CAL1                     0x0c3f
-#define WCD934X_CDC_VBAT_VBAT_ADC_CAL2                     0x0c40
-#define WCD934X_CDC_VBAT_VBAT_ADC_CAL3                     0x0c41
-#define WCD934X_CDC_VBAT_VBAT_PK_EST1                      0x0c42
-#define WCD934X_CDC_VBAT_VBAT_PK_EST2                      0x0c43
-#define WCD934X_CDC_VBAT_VBAT_PK_EST3                      0x0c44
-#define WCD934X_CDC_VBAT_VBAT_RF_PROC1                     0x0c45
-#define WCD934X_CDC_VBAT_VBAT_RF_PROC2                     0x0c46
-#define WCD934X_CDC_VBAT_VBAT_TAC1                         0x0c47
-#define WCD934X_CDC_VBAT_VBAT_TAC2                         0x0c48
-#define WCD934X_CDC_VBAT_VBAT_TAC3                         0x0c49
-#define WCD934X_CDC_VBAT_VBAT_TAC4                         0x0c4a
-#define WCD934X_CDC_VBAT_VBAT_GAIN_UPD1                    0x0c4b
-#define WCD934X_CDC_VBAT_VBAT_GAIN_UPD2                    0x0c4c
-#define WCD934X_CDC_VBAT_VBAT_GAIN_UPD3                    0x0c4d
-#define WCD934X_CDC_VBAT_VBAT_GAIN_UPD4                    0x0c4e
-#define WCD934X_CDC_VBAT_VBAT_DEBUG1                       0x0c4f
-#define WCD934X_CDC_VBAT_VBAT_GAIN_UPD_MON                 0x0c50
-#define WCD934X_CDC_VBAT_VBAT_GAIN_MON_VAL                 0x0c51
-#define WCD934X_CDC_VBAT_VBAT_BAN                          0x0c52
-#define WCD934X_MIXING_ASRC0_CLK_RST_CTL                   0x0c55
-#define WCD934X_MIXING_ASRC0_CTL0                          0x0c56
-#define WCD934X_MIXING_ASRC0_CTL1                          0x0c57
-#define WCD934X_MIXING_ASRC0_FIFO_CTL                      0x0c58
-#define WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_LSB          0x0c59
-#define WCD934X_MIXING_ASRC0_STATUS_FMIN_CNTR_MSB          0x0c5a
-#define WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_LSB          0x0c5b
-#define WCD934X_MIXING_ASRC0_STATUS_FMAX_CNTR_MSB          0x0c5c
-#define WCD934X_MIXING_ASRC0_STATUS_FIFO                   0x0c5d
-#define WCD934X_MIXING_ASRC1_CLK_RST_CTL                   0x0c61
-#define WCD934X_MIXING_ASRC1_CTL0                          0x0c62
-#define WCD934X_MIXING_ASRC1_CTL1                          0x0c63
-#define WCD934X_MIXING_ASRC1_FIFO_CTL                      0x0c64
-#define WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_LSB          0x0c65
-#define WCD934X_MIXING_ASRC1_STATUS_FMIN_CNTR_MSB          0x0c66
-#define WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_LSB          0x0c67
-#define WCD934X_MIXING_ASRC1_STATUS_FMAX_CNTR_MSB          0x0c68
-#define WCD934X_MIXING_ASRC1_STATUS_FIFO                   0x0c69
-#define WCD934X_MIXING_ASRC2_CLK_RST_CTL                   0x0c6d
-#define WCD934X_MIXING_ASRC2_CTL0                          0x0c6e
-#define WCD934X_MIXING_ASRC2_CTL1                          0x0c6f
-#define WCD934X_MIXING_ASRC2_FIFO_CTL                      0x0c70
-#define WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_LSB          0x0c71
-#define WCD934X_MIXING_ASRC2_STATUS_FMIN_CNTR_MSB          0x0c72
-#define WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_LSB          0x0c73
-#define WCD934X_MIXING_ASRC2_STATUS_FMAX_CNTR_MSB          0x0c74
-#define WCD934X_MIXING_ASRC2_STATUS_FIFO                   0x0c75
-#define WCD934X_MIXING_ASRC3_CLK_RST_CTL                   0x0c79
-#define WCD934X_MIXING_ASRC3_CTL0                          0x0c7a
-#define WCD934X_MIXING_ASRC3_CTL1                          0x0c7b
-#define WCD934X_MIXING_ASRC3_FIFO_CTL                      0x0c7c
-#define WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_LSB          0x0c7d
-#define WCD934X_MIXING_ASRC3_STATUS_FMIN_CNTR_MSB          0x0c7e
-#define WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_LSB          0x0c7f
-#define WCD934X_MIXING_ASRC3_STATUS_FMAX_CNTR_MSB          0x0c80
-#define WCD934X_MIXING_ASRC3_STATUS_FIFO                   0x0c81
-#define WCD934X_SWR_AHB_BRIDGE_WR_DATA_0                   0x0c85
-#define WCD934X_SWR_AHB_BRIDGE_WR_DATA_1                   0x0c86
-#define WCD934X_SWR_AHB_BRIDGE_WR_DATA_2                   0x0c87
-#define WCD934X_SWR_AHB_BRIDGE_WR_DATA_3                   0x0c88
-#define WCD934X_SWR_AHB_BRIDGE_WR_ADDR_0                   0x0c89
-#define WCD934X_SWR_AHB_BRIDGE_WR_ADDR_1                   0x0c8a
-#define WCD934X_SWR_AHB_BRIDGE_WR_ADDR_2                   0x0c8b
-#define WCD934X_SWR_AHB_BRIDGE_WR_ADDR_3                   0x0c8c
-#define WCD934X_SWR_AHB_BRIDGE_RD_ADDR_0                   0x0c8d
-#define WCD934X_SWR_AHB_BRIDGE_RD_ADDR_1                   0x0c8e
-#define WCD934X_SWR_AHB_BRIDGE_RD_ADDR_2                   0x0c8f
-#define WCD934X_SWR_AHB_BRIDGE_RD_ADDR_3                   0x0c90
-#define WCD934X_SWR_AHB_BRIDGE_RD_DATA_0                   0x0c91
-#define WCD934X_SWR_AHB_BRIDGE_RD_DATA_1                   0x0c92
-#define WCD934X_SWR_AHB_BRIDGE_RD_DATA_2                   0x0c93
-#define WCD934X_SWR_AHB_BRIDGE_RD_DATA_3                   0x0c94
-#define WCD934X_SWR_AHB_BRIDGE_ACCESS_CFG                  0x0c95
-#define WCD934X_SWR_AHB_BRIDGE_ACCESS_STATUS               0x0c96
-#define WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL          0x0cb5
-#define WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CFG1         0x0cb6
-#define WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL          0x0cb9
-#define WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CFG1         0x0cba
-#define WCD934X_SIDETONE_ASRC0_CLK_RST_CTL                 0x0cbd
-#define WCD934X_SIDETONE_ASRC0_CTL0                        0x0cbe
-#define WCD934X_SIDETONE_ASRC0_CTL1                        0x0cbf
-#define WCD934X_SIDETONE_ASRC0_FIFO_CTL                    0x0cc0
-#define WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_LSB        0x0cc1
-#define WCD934X_SIDETONE_ASRC0_STATUS_FMIN_CNTR_MSB        0x0cc2
-#define WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_LSB        0x0cc3
-#define WCD934X_SIDETONE_ASRC0_STATUS_FMAX_CNTR_MSB        0x0cc4
-#define WCD934X_SIDETONE_ASRC0_STATUS_FIFO                 0x0cc5
-#define WCD934X_SIDETONE_ASRC1_CLK_RST_CTL                 0x0cc9
-#define WCD934X_SIDETONE_ASRC1_CTL0                        0x0cca
-#define WCD934X_SIDETONE_ASRC1_CTL1                        0x0ccb
-#define WCD934X_SIDETONE_ASRC1_FIFO_CTL                    0x0ccc
-#define WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_LSB        0x0ccd
-#define WCD934X_SIDETONE_ASRC1_STATUS_FMIN_CNTR_MSB        0x0cce
-#define WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_LSB        0x0ccf
-#define WCD934X_SIDETONE_ASRC1_STATUS_FMAX_CNTR_MSB        0x0cd0
-#define WCD934X_SIDETONE_ASRC1_STATUS_FIFO                 0x0cd1
-#define WCD934X_EC_REF_HQ0_EC_REF_HQ_PATH_CTL              0x0cd5
-#define WCD934X_EC_REF_HQ0_EC_REF_HQ_CFG0                  0x0cd6
-#define WCD934X_EC_REF_HQ1_EC_REF_HQ_PATH_CTL              0x0cdd
-#define WCD934X_EC_REF_HQ1_EC_REF_HQ_CFG0                  0x0cde
-#define WCD934X_EC_ASRC0_CLK_RST_CTL                       0x0ce5
-#define WCD934X_EC_ASRC0_CTL0                              0x0ce6
-#define WCD934X_EC_ASRC0_CTL1                              0x0ce7
-#define WCD934X_EC_ASRC0_FIFO_CTL                          0x0ce8
-#define WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_LSB              0x0ce9
-#define WCD934X_EC_ASRC0_STATUS_FMIN_CNTR_MSB              0x0cea
-#define WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_LSB              0x0ceb
-#define WCD934X_EC_ASRC0_STATUS_FMAX_CNTR_MSB              0x0cec
-#define WCD934X_EC_ASRC0_STATUS_FIFO                       0x0ced
-#define WCD934X_EC_ASRC1_CLK_RST_CTL                       0x0cf1
-#define WCD934X_EC_ASRC1_CTL0                              0x0cf2
-#define WCD934X_EC_ASRC1_CTL1                              0x0cf3
-#define WCD934X_EC_ASRC1_FIFO_CTL                          0x0cf4
-#define WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_LSB              0x0cf5
-#define WCD934X_EC_ASRC1_STATUS_FMIN_CNTR_MSB              0x0cf6
-#define WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_LSB              0x0cf7
-#define WCD934X_EC_ASRC1_STATUS_FMAX_CNTR_MSB              0x0cf8
-#define WCD934X_EC_ASRC1_STATUS_FIFO                       0x0cf9
-#define WCD934X_PAGE13_PAGE_REGISTER                       0x0d00
-#define WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0                0x0d01
-#define WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1                0x0d02
-#define WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0                0x0d03
-#define WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1                0x0d04
-#define WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0                0x0d05
-#define WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1                0x0d06
-#define WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0                0x0d07
-#define WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1                0x0d08
-#define WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0                0x0d09
-#define WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1                0x0d0a
-#define WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0                0x0d0f
-#define WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1                0x0d10
-#define WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0                0x0d11
-#define WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1                0x0d12
-#define WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG0                 0x0d13
-#define WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG1                 0x0d14
-#define WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG2                 0x0d15
-#define WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG3                 0x0d16
-#define WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG4                 0x0d17
-#define WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0           0x0d18
-#define WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1           0x0d19
-#define WCD934X_CDC_RX_INP_MUX_ANC_CFG0                    0x0d1a
-#define WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0            0x0d1b
-#define WCD934X_CDC_RX_INP_MUX_EC_REF_HQ_CFG0              0x0d1c
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0               0x0d1d
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1               0x0d1e
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0               0x0d1f
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1               0x0d20
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0               0x0d21
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1               0x0d22
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0               0x0d23
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1               0x0d25
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0               0x0d26
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0               0x0d27
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0               0x0d28
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0               0x0d29
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0               0x0d2a
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX10_CFG0              0x0d2b
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX11_CFG0              0x0d2c
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX12_CFG0              0x0d2d
-#define WCD934X_CDC_TX_INP_MUX_ADC_MUX13_CFG0              0x0d2e
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0     0x0d31
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1     0x0d32
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2     0x0d33
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3     0x0d34
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0     0x0d35
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1     0x0d36
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2     0x0d37
-#define WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3     0x0d38
-#define WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0                  0x0d3a
-#define WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1                  0x0d3b
-#define WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2                  0x0d3c
-#define WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3                  0x0d3d
-#define WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL              0x0d41
-#define WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL            0x0d42
-#define WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL               0x0d43
-#define WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL               0x0d44
-#define WCD934X_CDC_CLK_RST_CTRL_ASRC_SHARE_CONTROL        0x0d45
-#define WCD934X_CDC_CLK_RST_CTRL_GFM_CONTROL               0x0d46
-#define WCD934X_CDC_PROX_DETECT_PROX_CTL                   0x0d49
-#define WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD0          0x0d4a
-#define WCD934X_CDC_PROX_DETECT_PROX_POLL_PERIOD1          0x0d4b
-#define WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_LSB       0x0d4c
-#define WCD934X_CDC_PROX_DETECT_PROX_SIG_PATTERN_MSB       0x0d4d
-#define WCD934X_CDC_PROX_DETECT_PROX_STATUS                0x0d4e
-#define WCD934X_CDC_PROX_DETECT_PROX_TEST_CTRL             0x0d4f
-#define WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB         0x0d50
-#define WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB         0x0d51
-#define WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_LSB_RD      0x0d52
-#define WCD934X_CDC_PROX_DETECT_PROX_TEST_BUFF_MSB_RD      0x0d53
-#define WCD934X_CDC_PROX_DETECT_PROX_CTL_REPEAT_PAT        0x0d54
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_PATH_CTL             0x0d55
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL          0x0d56
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL          0x0d57
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL          0x0d58
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL          0x0d59
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B5_CTL          0x0d5a
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B6_CTL          0x0d5b
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B7_CTL          0x0d5c
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B8_CTL          0x0d5d
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_CTL                  0x0d5e
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL       0x0d5f
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL          0x0d60
-#define WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL          0x0d61
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_PATH_CTL             0x0d65
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL          0x0d66
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL          0x0d67
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL          0x0d68
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL          0x0d69
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B5_CTL          0x0d6a
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B6_CTL          0x0d6b
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B7_CTL          0x0d6c
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B8_CTL          0x0d6d
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_CTL                  0x0d6e
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL       0x0d6f
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B1_CTL          0x0d70
-#define WCD934X_CDC_SIDETONE_IIR1_IIR_COEF_B2_CTL          0x0d71
-#define WCD934X_CDC_TOP_TOP_CFG0                           0x0d81
-#define WCD934X_CDC_TOP_TOP_CFG1                           0x0d82
-#define WCD934X_CDC_TOP_TOP_CFG7                           0x0d88
-#define WCD934X_CDC_TOP_HPHL_COMP_WR_LSB                   0x0d89
-#define WCD934X_CDC_TOP_HPHL_COMP_WR_MSB                   0x0d8a
-#define WCD934X_CDC_TOP_HPHL_COMP_LUT                      0x0d8b
-#define WCD934X_CDC_TOP_HPHL_COMP_RD_LSB                   0x0d8c
-#define WCD934X_CDC_TOP_HPHL_COMP_RD_MSB                   0x0d8d
-#define WCD934X_CDC_TOP_HPHR_COMP_WR_LSB                   0x0d8e
-#define WCD934X_CDC_TOP_HPHR_COMP_WR_MSB                   0x0d8f
-#define WCD934X_CDC_TOP_HPHR_COMP_LUT                      0x0d90
-#define WCD934X_CDC_TOP_HPHR_COMP_RD_LSB                   0x0d91
-#define WCD934X_CDC_TOP_HPHR_COMP_RD_MSB                   0x0d92
-#define WCD934X_CDC_TOP_DIFFL_COMP_WR_LSB                  0x0d93
-#define WCD934X_CDC_TOP_DIFFL_COMP_WR_MSB                  0x0d94
-#define WCD934X_CDC_TOP_DIFFL_COMP_LUT                     0x0d95
-#define WCD934X_CDC_TOP_DIFFL_COMP_RD_LSB                  0x0d96
-#define WCD934X_CDC_TOP_DIFFL_COMP_RD_MSB                  0x0d97
-#define WCD934X_CDC_TOP_DIFFR_COMP_WR_LSB                  0x0d98
-#define WCD934X_CDC_TOP_DIFFR_COMP_WR_MSB                  0x0d99
-#define WCD934X_CDC_TOP_DIFFR_COMP_LUT                     0x0d9a
-#define WCD934X_CDC_TOP_DIFFR_COMP_RD_LSB                  0x0d9b
-#define WCD934X_CDC_TOP_DIFFR_COMP_RD_MSB                  0x0d9c
-#define WCD934X_CDC_DSD0_PATH_CTL                          0x0db1
-#define WCD934X_CDC_DSD0_CFG0                              0x0db2
-#define WCD934X_CDC_DSD0_CFG1                              0x0db3
-#define WCD934X_CDC_DSD0_CFG2                              0x0db4
-#define WCD934X_CDC_DSD0_CFG3                              0x0db5
-#define WCD934X_CDC_DSD0_CFG4                              0x0db6
-#define WCD934X_CDC_DSD0_CFG5                              0x0db7
-#define WCD934X_CDC_DSD1_PATH_CTL                          0x0dc1
-#define WCD934X_CDC_DSD1_CFG0                              0x0dc2
-#define WCD934X_CDC_DSD1_CFG1                              0x0dc3
-#define WCD934X_CDC_DSD1_CFG2                              0x0dc4
-#define WCD934X_CDC_DSD1_CFG3                              0x0dc5
-#define WCD934X_CDC_DSD1_CFG4                              0x0dc6
-#define WCD934X_CDC_DSD1_CFG5                              0x0dc7
-#define WCD934X_CDC_RX_IDLE_DET_PATH_CTL                   0x0dd1
-#define WCD934X_CDC_RX_IDLE_DET_CFG0                       0x0dd2
-#define WCD934X_CDC_RX_IDLE_DET_CFG1                       0x0dd3
-#define WCD934X_CDC_RX_IDLE_DET_CFG2                       0x0dd4
-#define WCD934X_CDC_RX_IDLE_DET_CFG3                       0x0dd5
-#define WCD934X_PAGE14_PAGE_REGISTER                       0x0e00
-#define WCD934X_CDC_RATE_EST0_RE_CLK_RST_CTL               0x0e01
-#define WCD934X_CDC_RATE_EST0_RE_CTL                       0x0e02
-#define WCD934X_CDC_RATE_EST0_RE_PULSE_SUPR_CTL            0x0e03
-#define WCD934X_CDC_RATE_EST0_RE_TIMER                     0x0e04
-#define WCD934X_CDC_RATE_EST0_RE_BW_SW                     0x0e05
-#define WCD934X_CDC_RATE_EST0_RE_THRESH                    0x0e06
-#define WCD934X_CDC_RATE_EST0_RE_STATUS                    0x0e07
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_CTRL                 0x0e09
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_TIMER2               0x0e0c
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW1           0x0e0d
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW2           0x0e0e
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW3           0x0e0f
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW4           0x0e10
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_OFFSET_BW5           0x0e11
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW1            0x0e12
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW2            0x0e13
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW3            0x0e14
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW4            0x0e15
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMIT_BW5            0x0e16
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW1          0x0e17
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW2          0x0e18
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW3          0x0e19
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW4          0x0e1a
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_LIMITD1_BW5          0x0e1b
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW1             0x0e1c
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW2             0x0e1d
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW3             0x0e1e
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW4             0x0e1f
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_HYST_BW5             0x0e20
-#define WCD934X_CDC_RATE_EST0_RE_RMAX_DIAG                 0x0e21
-#define WCD934X_CDC_RATE_EST0_RE_RMIN_DIAG                 0x0e22
-#define WCD934X_CDC_RATE_EST0_RE_PH_DET                    0x0e23
-#define WCD934X_CDC_RATE_EST0_RE_DIAG_CLR                  0x0e24
-#define WCD934X_CDC_RATE_EST0_RE_MB_SW_STATE               0x0e25
-#define WCD934X_CDC_RATE_EST0_RE_MAST_DIAG_STATE           0x0e26
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_7_0              0x0e27
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_15_8             0x0e28
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_23_16            0x0e29
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_31_24            0x0e2a
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_39_32            0x0e2b
-#define WCD934X_CDC_RATE_EST0_RE_RATE_OUT_40_43            0x0e2c
-#define WCD934X_CDC_RATE_EST1_RE_CLK_RST_CTL               0x0e31
-#define WCD934X_CDC_RATE_EST1_RE_CTL                       0x0e32
-#define WCD934X_CDC_RATE_EST1_RE_PULSE_SUPR_CTL            0x0e33
-#define WCD934X_CDC_RATE_EST1_RE_TIMER                     0x0e34
-#define WCD934X_CDC_RATE_EST1_RE_BW_SW                     0x0e35
-#define WCD934X_CDC_RATE_EST1_RE_THRESH                    0x0e36
-#define WCD934X_CDC_RATE_EST1_RE_STATUS                    0x0e37
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_CTRL                 0x0e39
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_TIMER2               0x0e3c
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW1           0x0e3d
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW2           0x0e3e
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW3           0x0e3f
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW4           0x0e40
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_OFFSET_BW5           0x0e41
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW1            0x0e42
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW2            0x0e43
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW3            0x0e44
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW4            0x0e45
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMIT_BW5            0x0e46
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW1          0x0e47
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW2          0x0e48
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW3          0x0e49
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW4          0x0e4a
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_LIMITD1_BW5          0x0e4b
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW1             0x0e4c
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW2             0x0e4d
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW3             0x0e4e
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW4             0x0e4f
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_HYST_BW5             0x0e50
-#define WCD934X_CDC_RATE_EST1_RE_RMAX_DIAG                 0x0e51
-#define WCD934X_CDC_RATE_EST1_RE_RMIN_DIAG                 0x0e52
-#define WCD934X_CDC_RATE_EST1_RE_PH_DET                    0x0e53
-#define WCD934X_CDC_RATE_EST1_RE_DIAG_CLR                  0x0e54
-#define WCD934X_CDC_RATE_EST1_RE_MB_SW_STATE               0x0e55
-#define WCD934X_CDC_RATE_EST1_RE_MAST_DIAG_STATE           0x0e56
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_7_0              0x0e57
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_15_8             0x0e58
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_23_16            0x0e59
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_31_24            0x0e5a
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_39_32            0x0e5b
-#define WCD934X_CDC_RATE_EST1_RE_RATE_OUT_40_43            0x0e5c
-#define WCD934X_CDC_RATE_EST2_RE_CLK_RST_CTL               0x0e61
-#define WCD934X_CDC_RATE_EST2_RE_CTL                       0x0e62
-#define WCD934X_CDC_RATE_EST2_RE_PULSE_SUPR_CTL            0x0e63
-#define WCD934X_CDC_RATE_EST2_RE_TIMER                     0x0e64
-#define WCD934X_CDC_RATE_EST2_RE_BW_SW                     0x0e65
-#define WCD934X_CDC_RATE_EST2_RE_THRESH                    0x0e66
-#define WCD934X_CDC_RATE_EST2_RE_STATUS                    0x0e67
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_CTRL                 0x0e69
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_TIMER2               0x0e6c
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW1           0x0e6d
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW2           0x0e6e
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW3           0x0e6f
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW4           0x0e70
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_OFFSET_BW5           0x0e71
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW1            0x0e72
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW2            0x0e73
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW3            0x0e74
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW4            0x0e75
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMIT_BW5            0x0e76
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW1          0x0e77
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW2          0x0e78
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW3          0x0e79
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW4          0x0e7a
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_LIMITD1_BW5          0x0e7b
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW1             0x0e7c
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW2             0x0e7d
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW3             0x0e7e
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW4             0x0e7f
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_HYST_BW5             0x0e80
-#define WCD934X_CDC_RATE_EST2_RE_RMAX_DIAG                 0x0e81
-#define WCD934X_CDC_RATE_EST2_RE_RMIN_DIAG                 0x0e82
-#define WCD934X_CDC_RATE_EST2_RE_PH_DET                    0x0e83
-#define WCD934X_CDC_RATE_EST2_RE_DIAG_CLR                  0x0e84
-#define WCD934X_CDC_RATE_EST2_RE_MB_SW_STATE               0x0e85
-#define WCD934X_CDC_RATE_EST2_RE_MAST_DIAG_STATE           0x0e86
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_7_0              0x0e87
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_15_8             0x0e88
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_23_16            0x0e89
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_31_24            0x0e8a
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_39_32            0x0e8b
-#define WCD934X_CDC_RATE_EST2_RE_RATE_OUT_40_43            0x0e8c
-#define WCD934X_CDC_RATE_EST3_RE_CLK_RST_CTL               0x0e91
-#define WCD934X_CDC_RATE_EST3_RE_CTL                       0x0e92
-#define WCD934X_CDC_RATE_EST3_RE_PULSE_SUPR_CTL            0x0e93
-#define WCD934X_CDC_RATE_EST3_RE_TIMER                     0x0e94
-#define WCD934X_CDC_RATE_EST3_RE_BW_SW                     0x0e95
-#define WCD934X_CDC_RATE_EST3_RE_THRESH                    0x0e96
-#define WCD934X_CDC_RATE_EST3_RE_STATUS                    0x0e97
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_CTRL                 0x0e99
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_TIMER2               0x0e9c
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW1           0x0e9d
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW2           0x0e9e
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW3           0x0e9f
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW4           0x0ea0
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_OFFSET_BW5           0x0ea1
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW1            0x0ea2
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW2            0x0ea3
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW3            0x0ea4
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW4            0x0ea5
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMIT_BW5            0x0ea6
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW1          0x0ea7
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW2          0x0ea8
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW3          0x0ea9
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW4          0x0eaa
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_LIMITD1_BW5          0x0eab
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW1             0x0eac
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW2             0x0ead
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW3             0x0eae
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW4             0x0eaf
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_HYST_BW5             0x0eb0
-#define WCD934X_CDC_RATE_EST3_RE_RMAX_DIAG                 0x0eb1
-#define WCD934X_CDC_RATE_EST3_RE_RMIN_DIAG                 0x0eb2
-#define WCD934X_CDC_RATE_EST3_RE_PH_DET                    0x0eb3
-#define WCD934X_CDC_RATE_EST3_RE_DIAG_CLR                  0x0eb4
-#define WCD934X_CDC_RATE_EST3_RE_MB_SW_STATE               0x0eb5
-#define WCD934X_CDC_RATE_EST3_RE_MAST_DIAG_STATE           0x0eb6
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_7_0              0x0eb7
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_15_8             0x0eb8
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_23_16            0x0eb9
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_31_24            0x0eba
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_39_32            0x0ebb
-#define WCD934X_CDC_RATE_EST3_RE_RATE_OUT_40_43            0x0ebc
-#define WCD934X_PAGE15_PAGE_REGISTER                       0x0f00
-#define WCD934X_SPLINE_SRC0_CLK_RST_CTL_0                  0x0f01
-#define WCD934X_SPLINE_SRC0_STATUS                         0x0f02
-#define WCD934X_SPLINE_SRC1_CLK_RST_CTL_0                  0x0f19
-#define WCD934X_SPLINE_SRC1_STATUS                         0x0f1a
-#define WCD934X_SPLINE_SRC2_CLK_RST_CTL_0                  0x0f31
-#define WCD934X_SPLINE_SRC2_STATUS                         0x0f32
-#define WCD934X_SPLINE_SRC3_CLK_RST_CTL_0                  0x0f49
-#define WCD934X_SPLINE_SRC3_STATUS                         0x0f4a
-#define WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0                  0x0fa1
-#define WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1                  0x0fa2
-#define WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG2                  0x0fa3
-#define WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3                  0x0fa4
-#define WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0                  0x0fa5
-#define WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1                  0x0fa6
-#define WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG2                  0x0fa7
-#define WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3                  0x0fa8
-#define WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG0            0x0fa9
-#define WCD934X_CDC_DEBUG_SPLINE_SRC_DEBUG_CFG1            0x0faa
-#define WCD934X_CDC_DEBUG_RC_RE_ASRC_DEBUG_CFG0            0x0fab
-#define WCD934X_CDC_DEBUG_ANC0_RC0_FIFO_CTL                0x0fac
-#define WCD934X_CDC_DEBUG_ANC0_RC1_FIFO_CTL                0x0fad
-#define WCD934X_CDC_DEBUG_ANC1_RC0_FIFO_CTL                0x0fae
-#define WCD934X_CDC_DEBUG_ANC1_RC1_FIFO_CTL                0x0faf
-#define WCD934X_CDC_DEBUG_ANC_RC_RST_DBG_CNTR              0x0fb0
-#define WCD934X_PAGE80_PAGE_REGISTER                       0x5000
-#define WCD934X_CODEC_CPR_WR_DATA_0                        0x5001
-#define WCD934X_CODEC_CPR_WR_DATA_1                        0x5002
-#define WCD934X_CODEC_CPR_WR_DATA_2                        0x5003
-#define WCD934X_CODEC_CPR_WR_DATA_3                        0x5004
-#define WCD934X_CODEC_CPR_WR_ADDR_0                        0x5005
-#define WCD934X_CODEC_CPR_WR_ADDR_1                        0x5006
-#define WCD934X_CODEC_CPR_WR_ADDR_2                        0x5007
-#define WCD934X_CODEC_CPR_WR_ADDR_3                        0x5008
-#define WCD934X_CODEC_CPR_RD_ADDR_0                        0x5009
-#define WCD934X_CODEC_CPR_RD_ADDR_1                        0x500a
-#define WCD934X_CODEC_CPR_RD_ADDR_2                        0x500b
-#define WCD934X_CODEC_CPR_RD_ADDR_3                        0x500c
-#define WCD934X_CODEC_CPR_RD_DATA_0                        0x500d
-#define WCD934X_CODEC_CPR_RD_DATA_1                        0x500e
-#define WCD934X_CODEC_CPR_RD_DATA_2                        0x500f
-#define WCD934X_CODEC_CPR_RD_DATA_3                        0x5010
-#define WCD934X_CODEC_CPR_ACCESS_CFG                       0x5011
-#define WCD934X_CODEC_CPR_ACCESS_STATUS                    0x5012
-#define WCD934X_CODEC_CPR_NOM_CX_VDD                       0x5021
-#define WCD934X_CODEC_CPR_SVS_CX_VDD                       0x5022
-#define WCD934X_CODEC_CPR_SVS2_CX_VDD                      0x5023
-#define WCD934X_CODEC_CPR_NOM_MX_VDD                       0x5024
-#define WCD934X_CODEC_CPR_SVS_MX_VDD                       0x5025
-#define WCD934X_CODEC_CPR_SVS2_MX_VDD                      0x5026
-#define WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD                  0x5027
-#define WCD934X_CODEC_CPR_MAX_SVS2_STEP                    0x5028
-#define WCD934X_CODEC_CPR_CTL                              0x5029
-#define WCD934X_CODEC_CPR_SW_MODECHNG_STATUS               0x502a
-#define WCD934X_CODEC_CPR_SW_MODECHNG_START                0x502b
-#define WCD934X_CODEC_CPR_CPR_STATUS                       0x502c
-#define WCD934X_PAGE128_PAGE_REGISTER                      0x8000
-#define WCD934X_TLMM_BIST_MODE_PINCFG                      0x8001
-#define WCD934X_TLMM_RF_PA_ON_PINCFG                       0x8002
-#define WCD934X_TLMM_INTR1_PINCFG                          0x8003
-#define WCD934X_TLMM_INTR2_PINCFG                          0x8004
-#define WCD934X_TLMM_SWR_DATA_PINCFG                       0x8005
-#define WCD934X_TLMM_SWR_CLK_PINCFG                        0x8006
-#define WCD934X_TLMM_I2S_2_SCK_PINCFG                      0x8007
-#define WCD934X_TLMM_SLIMBUS_DATA1_PINCFG                  0x8008
-#define WCD934X_TLMM_SLIMBUS_DATA2_PINCFG                  0x8009
-#define WCD934X_TLMM_SLIMBUS_CLK_PINCFG                    0x800a
-#define WCD934X_TLMM_I2C_CLK_PINCFG                        0x800b
-#define WCD934X_TLMM_I2C_DATA_PINCFG                       0x800c
-#define WCD934X_TLMM_I2S_0_RX_PINCFG                       0x800d
-#define WCD934X_TLMM_I2S_0_TX_PINCFG                       0x800e
-#define WCD934X_TLMM_I2S_0_SCK_PINCFG                      0x800f
-#define WCD934X_TLMM_I2S_0_WS_PINCFG                       0x8010
-#define WCD934X_TLMM_I2S_1_RX_PINCFG                       0x8011
-#define WCD934X_TLMM_I2S_1_TX_PINCFG                       0x8012
-#define WCD934X_TLMM_I2S_1_SCK_PINCFG                      0x8013
-#define WCD934X_TLMM_I2S_1_WS_PINCFG                       0x8014
-#define WCD934X_TLMM_DMIC1_CLK_PINCFG                      0x8015
-#define WCD934X_TLMM_DMIC1_DATA_PINCFG                     0x8016
-#define WCD934X_TLMM_DMIC2_CLK_PINCFG                      0x8017
-#define WCD934X_TLMM_DMIC2_DATA_PINCFG                     0x8018
-#define WCD934X_TLMM_DMIC3_CLK_PINCFG                      0x8019
-#define WCD934X_TLMM_DMIC3_DATA_PINCFG                     0x801a
-#define WCD934X_TLMM_JTCK_PINCFG                           0x801b
-#define WCD934X_TLMM_GPIO1_PINCFG                          0x801c
-#define WCD934X_TLMM_GPIO2_PINCFG                          0x801d
-#define WCD934X_TLMM_GPIO3_PINCFG                          0x801e
-#define WCD934X_TLMM_GPIO4_PINCFG                          0x801f
-#define WCD934X_TLMM_SPI_S_CSN_PINCFG                      0x8020
-#define WCD934X_TLMM_SPI_S_CLK_PINCFG                      0x8021
-#define WCD934X_TLMM_SPI_S_DOUT_PINCFG                     0x8022
-#define WCD934X_TLMM_SPI_S_DIN_PINCFG                      0x8023
-#define WCD934X_TLMM_BA_N_PINCFG                           0x8024
-#define WCD934X_TLMM_GPIO0_PINCFG                          0x8025
-#define WCD934X_TLMM_I2S_2_RX_PINCFG                       0x8026
-#define WCD934X_TLMM_I2S_2_WS_PINCFG                       0x8027
-#define WCD934X_TEST_DEBUG_PIN_CTL_OE_0                    0x8031
-#define WCD934X_TEST_DEBUG_PIN_CTL_OE_1                    0x8032
-#define WCD934X_TEST_DEBUG_PIN_CTL_OE_2                    0x8033
-#define WCD934X_TEST_DEBUG_PIN_CTL_OE_3                    0x8034
-#define WCD934X_TEST_DEBUG_PIN_CTL_OE_4                    0x8035
-#define WCD934X_TEST_DEBUG_PIN_CTL_DATA_0                  0x8036
-#define WCD934X_TEST_DEBUG_PIN_CTL_DATA_1                  0x8037
-#define WCD934X_TEST_DEBUG_PIN_CTL_DATA_2                  0x8038
-#define WCD934X_TEST_DEBUG_PIN_CTL_DATA_3                  0x8039
-#define WCD934X_TEST_DEBUG_PIN_CTL_DATA_4                  0x803a
-#define WCD934X_TEST_DEBUG_PAD_DRVCTL_0                    0x803b
-#define WCD934X_TEST_DEBUG_PAD_DRVCTL_1                    0x803c
-#define WCD934X_TEST_DEBUG_PIN_STATUS                      0x803d
-#define WCD934X_TEST_DEBUG_NPL_DLY_TEST_1                  0x803e
-#define WCD934X_TEST_DEBUG_NPL_DLY_TEST_2                  0x803f
-#define WCD934X_TEST_DEBUG_MEM_CTRL                        0x8040
-#define WCD934X_TEST_DEBUG_DEBUG_BUS_SEL                   0x8041
-#define WCD934X_TEST_DEBUG_DEBUG_JTAG                      0x8042
-#define WCD934X_TEST_DEBUG_DEBUG_EN_1                      0x8043
-#define WCD934X_TEST_DEBUG_DEBUG_EN_2                      0x8044
-#define WCD934X_TEST_DEBUG_DEBUG_EN_3                      0x8045
-#define WCD934X_TEST_DEBUG_DEBUG_EN_4                      0x8046
-#define WCD934X_TEST_DEBUG_DEBUG_EN_5                      0x8047
-#define WCD934X_TEST_DEBUG_ANA_DTEST_DIR                   0x804a
-#define WCD934X_TEST_DEBUG_PAD_INP_DISABLE_0               0x804b
-#define WCD934X_TEST_DEBUG_PAD_INP_DISABLE_1               0x804c
-#define WCD934X_TEST_DEBUG_PAD_INP_DISABLE_2               0x804d
-#define WCD934X_TEST_DEBUG_PAD_INP_DISABLE_3               0x804e
-#define WCD934X_TEST_DEBUG_PAD_INP_DISABLE_4               0x804f
-#define WCD934X_TEST_DEBUG_SYSMEM_CTRL                     0x8050
-#define WCD934X_TEST_DEBUG_SOC_SW_PWR_SEQ_DELAY            0x8051
-#define WCD934X_TEST_DEBUG_LVAL_NOM_LOW                    0x8052
-#define WCD934X_TEST_DEBUG_LVAL_NOM_HIGH                   0x8053
-#define WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW               0x8054
-#define WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH              0x8055
-#define WCD934X_TEST_DEBUG_SPI_SLAVE_CHAR                  0x8056
-#define WCD934X_TEST_DEBUG_CODEC_DIAGS                     0x8057
-#define WCD934X_MAX_REGISTER                               0x80FF
-
-/* SLIMBUS Slave Registers */
-#define WCD934X_SLIM_PGD_PORT_INT_RX_EN0                     (0x30)
-#define WCD934X_SLIM_PGD_PORT_INT_TX_EN0                     (0x32)
-#define WCD934X_SLIM_PGD_PORT_INT_STATUS_RX_0                (0x34)
-#define WCD934X_SLIM_PGD_PORT_INT_STATUS_RX_1                (0x35)
-#define WCD934X_SLIM_PGD_PORT_INT_STATUS_TX_0                (0x36)
-#define WCD934X_SLIM_PGD_PORT_INT_STATUS_TX_1                (0x37)
-#define WCD934X_SLIM_PGD_PORT_INT_CLR_RX_0                   (0x38)
-#define WCD934X_SLIM_PGD_PORT_INT_CLR_RX_1                   (0x39)
-#define WCD934X_SLIM_PGD_PORT_INT_CLR_TX_0                   (0x3A)
-#define WCD934X_SLIM_PGD_PORT_INT_CLR_TX_1                   (0x3B)
-#define WCD934X_SLIM_PGD_PORT_INT_RX_SOURCE0                 (0x60)
-#define WCD934X_SLIM_PGD_PORT_INT_TX_SOURCE0                 (0x70)
-
-#endif
diff --git a/include/linux/mfd/wcd9xxx/Kbuild b/include/linux/mfd/wcd9xxx/Kbuild
deleted file mode 100644
index 8e55965..0000000
--- a/include/linux/mfd/wcd9xxx/Kbuild
+++ /dev/null
@@ -1,2 +0,0 @@
-header-y += wcd9xxx_registers.h
-header-y += wcd9320_registers.h
diff --git a/include/linux/mfd/wcd9xxx/core.h b/include/linux/mfd/wcd9xxx/core.h
deleted file mode 100644
index b994010..0000000
--- a/include/linux/mfd/wcd9xxx/core.h
+++ /dev/null
@@ -1,440 +0,0 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __MFD_TABLA_CORE_H__
-#define __MFD_TABLA_CORE_H__
-
-#include <linux/types.h>
-#include <linux/platform_device.h>
-#include <linux/of_irq.h>
-#include <linux/interrupt.h>
-#include <linux/pm_qos.h>
-
-#define WCD9XXX_MAX_IRQ_REGS 4
-#define WCD9XXX_MAX_NUM_IRQS (WCD9XXX_MAX_IRQ_REGS * 8)
-#define WCD9XXX_SLIM_NUM_PORT_REG 3
-#define TABLA_VERSION_1_0	0
-#define TABLA_VERSION_1_1	1
-#define TABLA_VERSION_2_0	2
-#define TABLA_IS_1_X(ver) \
-	(((ver == TABLA_VERSION_1_0) || (ver == TABLA_VERSION_1_1)) ? 1 : 0)
-#define TABLA_IS_2_0(ver) ((ver == TABLA_VERSION_2_0) ? 1 : 0)
-
-#define WCD9XXX_SUPPLY_BUCK_NAME "cdc-vdd-buck"
-
-#define SITAR_VERSION_1P0 0
-#define SITAR_VERSION_1P1 1
-#define SITAR_IS_1P0(ver) \
-	((ver == SITAR_VERSION_1P0) ? 1 : 0)
-#define SITAR_IS_1P1(ver) \
-	((ver == SITAR_VERSION_1P1) ? 1 : 0)
-
-#define TAIKO_VERSION_1_0	1
-#define TAIKO_IS_1_0(ver) \
-	((ver == TAIKO_VERSION_1_0) ? 1 : 0)
-
-#define TAPAN_VERSION_1_0	0
-#define TAPAN_IS_1_0(ver) \
-	((ver == TAPAN_VERSION_1_0) ? 1 : 0)
-
-#define TOMTOM_VERSION_1_0	1
-#define TOMTOM_IS_1_0(ver) \
-	((ver == TOMTOM_VERSION_1_0) ? 1 : 0)
-
-#define TASHA_VERSION_1_0     0
-#define TASHA_VERSION_1_1     1
-#define TASHA_VERSION_2_0     2
-
-#define TASHA_IS_1_0(wcd) \
-	((wcd->type == WCD9335 || wcd->type == WCD9326) ? \
-	((wcd->version == TASHA_VERSION_1_0) ? 1 : 0) : 0)
-
-#define TASHA_IS_1_1(wcd) \
-	((wcd->type == WCD9335 || wcd->type == WCD9326) ? \
-	((wcd->version == TASHA_VERSION_1_1) ? 1 : 0) : 0)
-
-#define TASHA_IS_2_0(wcd) \
-	((wcd->type == WCD9335 || wcd->type == WCD9326) ? \
-	((wcd->version == TASHA_VERSION_2_0) ? 1 : 0) : 0)
-
-/*
- * As fine version info cannot be retrieved before tavil probe.
- * Define three coarse versions for possible future use before tavil probe.
- */
-#define TAVIL_VERSION_1_0             0
-#define TAVIL_VERSION_1_1             1
-#define TAVIL_VERSION_WCD9340_1_0     2
-#define TAVIL_VERSION_WCD9341_1_0     3
-#define TAVIL_VERSION_WCD9340_1_1     4
-#define TAVIL_VERSION_WCD9341_1_1     5
-
-#define TAVIL_IS_1_0(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_1_0 || \
-	   wcd->version == TAVIL_VERSION_WCD9340_1_0 || \
-	   wcd->version == TAVIL_VERSION_WCD9341_1_0) ? 1 : 0) : 0)
-#define TAVIL_IS_1_1(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_1_1 || \
-	   wcd->version == TAVIL_VERSION_WCD9340_1_1 || \
-	   wcd->version == TAVIL_VERSION_WCD9341_1_1) ? 1 : 0) : 0)
-#define TAVIL_IS_WCD9340_1_0(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_WCD9340_1_0) ? 1 : 0) : 0)
-#define TAVIL_IS_WCD9341_1_0(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_WCD9341_1_0) ? 1 : 0) : 0)
-#define TAVIL_IS_WCD9340_1_1(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_WCD9340_1_1) ? 1 : 0) : 0)
-#define TAVIL_IS_WCD9341_1_1(wcd) \
-	((wcd->type == WCD934X) ? \
-	 ((wcd->version == TAVIL_VERSION_WCD9341_1_1) ? 1 : 0) : 0)
-
-#define IS_CODEC_TYPE(wcd, wcdtype) \
-	((wcd->type == wcdtype) ? true : false)
-#define IS_CODEC_VERSION(wcd, wcdversion) \
-	((wcd->version == wcdversion) ? true : false)
-
-enum {
-	CDC_V_1_0,
-	CDC_V_1_1,
-	CDC_V_2_0,
-};
-
-enum codec_variant {
-	WCD9XXX,
-	WCD9330,
-	WCD9335,
-	WCD9326,
-	WCD934X,
-};
-
-enum wcd9xxx_slim_slave_addr_type {
-	WCD9XXX_SLIM_SLAVE_ADDR_TYPE_0,
-	WCD9XXX_SLIM_SLAVE_ADDR_TYPE_1,
-};
-
-enum wcd9xxx_pm_state {
-	WCD9XXX_PM_SLEEPABLE,
-	WCD9XXX_PM_AWAKE,
-	WCD9XXX_PM_ASLEEP,
-};
-
-enum {
-	WCD9XXX_INTR_STATUS_BASE = 0,
-	WCD9XXX_INTR_CLEAR_BASE,
-	WCD9XXX_INTR_MASK_BASE,
-	WCD9XXX_INTR_LEVEL_BASE,
-	WCD9XXX_INTR_CLR_COMMIT,
-	WCD9XXX_INTR_REG_MAX,
-};
-
-enum wcd9xxx_intf_status {
-	WCD9XXX_INTERFACE_TYPE_PROBING,
-	WCD9XXX_INTERFACE_TYPE_SLIMBUS,
-	WCD9XXX_INTERFACE_TYPE_I2C,
-};
-
-enum {
-	/* INTR_REG 0 */
-	WCD9XXX_IRQ_SLIMBUS = 0,
-	WCD9XXX_IRQ_MBHC_REMOVAL,
-	WCD9XXX_IRQ_MBHC_SHORT_TERM,
-	WCD9XXX_IRQ_MBHC_PRESS,
-	WCD9XXX_IRQ_MBHC_RELEASE,
-	WCD9XXX_IRQ_MBHC_POTENTIAL,
-	WCD9XXX_IRQ_MBHC_INSERTION,
-	WCD9XXX_IRQ_BG_PRECHARGE,
-	/* INTR_REG 1 */
-	WCD9XXX_IRQ_PA1_STARTUP,
-	WCD9XXX_IRQ_PA2_STARTUP,
-	WCD9XXX_IRQ_PA3_STARTUP,
-	WCD9XXX_IRQ_PA4_STARTUP,
-	WCD9306_IRQ_HPH_PA_OCPR_FAULT = WCD9XXX_IRQ_PA4_STARTUP,
-	WCD9XXX_IRQ_PA5_STARTUP,
-	WCD9XXX_IRQ_MICBIAS1_PRECHARGE,
-	WCD9306_IRQ_HPH_PA_OCPL_FAULT = WCD9XXX_IRQ_MICBIAS1_PRECHARGE,
-	WCD9XXX_IRQ_MICBIAS2_PRECHARGE,
-	WCD9XXX_IRQ_MICBIAS3_PRECHARGE,
-	/* INTR_REG 2 */
-	WCD9XXX_IRQ_HPH_PA_OCPL_FAULT,
-	WCD9XXX_IRQ_HPH_PA_OCPR_FAULT,
-	WCD9XXX_IRQ_EAR_PA_OCPL_FAULT,
-	WCD9XXX_IRQ_HPH_L_PA_STARTUP,
-	WCD9XXX_IRQ_HPH_R_PA_STARTUP,
-	WCD9320_IRQ_EAR_PA_STARTUP,
-	WCD9306_IRQ_MBHC_JACK_SWITCH = WCD9320_IRQ_EAR_PA_STARTUP,
-	WCD9310_NUM_IRQS,
-	WCD9XXX_IRQ_RESERVED_0 = WCD9310_NUM_IRQS,
-	WCD9XXX_IRQ_RESERVED_1,
-	WCD9330_IRQ_SVASS_ERR_EXCEPTION = WCD9310_NUM_IRQS,
-	WCD9330_IRQ_MBHC_JACK_SWITCH,
-	/* INTR_REG 3 */
-	WCD9XXX_IRQ_MAD_AUDIO,
-	WCD9XXX_IRQ_MAD_ULTRASOUND,
-	WCD9XXX_IRQ_MAD_BEACON,
-	WCD9XXX_IRQ_SPEAKER_CLIPPING,
-	WCD9320_IRQ_MBHC_JACK_SWITCH,
-	WCD9306_NUM_IRQS,
-	WCD9XXX_IRQ_VBAT_MONITOR_ATTACK = WCD9306_NUM_IRQS,
-	WCD9XXX_IRQ_VBAT_MONITOR_RELEASE,
-	WCD9XXX_NUM_IRQS,
-	/* WCD9330 INTR1_REG 3*/
-	WCD9330_IRQ_SVASS_ENGINE = WCD9XXX_IRQ_MAD_AUDIO,
-	WCD9330_IRQ_MAD_AUDIO,
-	WCD9330_IRQ_MAD_ULTRASOUND,
-	WCD9330_IRQ_MAD_BEACON,
-	WCD9330_IRQ_SPEAKER1_CLIPPING,
-	WCD9330_IRQ_SPEAKER2_CLIPPING,
-	WCD9330_IRQ_VBAT_MONITOR_ATTACK,
-	WCD9330_IRQ_VBAT_MONITOR_RELEASE,
-	WCD9330_NUM_IRQS,
-	WCD9XXX_IRQ_RESERVED_2 = WCD9330_NUM_IRQS,
-};
-
-enum {
-	TABLA_NUM_IRQS = WCD9310_NUM_IRQS,
-	SITAR_NUM_IRQS = WCD9310_NUM_IRQS,
-	TAIKO_NUM_IRQS = WCD9XXX_NUM_IRQS,
-	TAPAN_NUM_IRQS = WCD9306_NUM_IRQS,
-	TOMTOM_NUM_IRQS = WCD9330_NUM_IRQS,
-};
-
-struct intr_data {
-	int intr_num;
-	bool clear_first;
-};
-
-struct wcd9xxx_core_resource {
-	struct mutex irq_lock;
-	struct mutex nested_irq_lock;
-
-	enum wcd9xxx_pm_state pm_state;
-	struct mutex pm_lock;
-	/* pm_wq notifies change of pm_state */
-	wait_queue_head_t pm_wq;
-	struct pm_qos_request pm_qos_req;
-	int wlock_holders;
-
-
-	/* holds the table of interrupts per codec */
-	const struct intr_data *intr_table;
-	int intr_table_size;
-	unsigned int irq_base;
-	unsigned int irq;
-	u8 irq_masks_cur[WCD9XXX_MAX_IRQ_REGS];
-	u8 irq_masks_cache[WCD9XXX_MAX_IRQ_REGS];
-	bool irq_level_high[WCD9XXX_MAX_NUM_IRQS];
-	int num_irqs;
-	int num_irq_regs;
-	u16 intr_reg[WCD9XXX_INTR_REG_MAX];
-	struct regmap *wcd_core_regmap;
-
-	/* Pointer to parent container data structure */
-	void *parent;
-
-	struct device *dev;
-	struct irq_domain *domain;
-};
-
-/*
- * data structure for Slimbus and I2S channel.
- * Some of fields are only used in smilbus mode
- */
-struct wcd9xxx_ch {
-	u32 sph;		/* share channel handle - slimbus only	*/
-	u32 ch_num;		/*
-				 * vitrual channel number, such as 128 -144.
-				 * apply for slimbus only
-				 */
-	u16 ch_h;		/* chanel handle - slimbus only */
-	u16 port;		/*
-				 * tabla port for RX and TX
-				 * such as 0-9 for TX and 10 -16 for RX
-				 * apply for both i2s and slimbus
-				 */
-	u16 shift;		/*
-				 * shift bit for RX and TX
-				 * apply for both i2s and slimbus
-				 */
-	struct list_head list;	/*
-				 * channel link list
-				 * apply for both i2s and slimbus
-				 */
-};
-
-struct wcd9xxx_codec_dai_data {
-	u32 rate;				/* sample rate          */
-	u32 bit_width;				/* sit width 16,24,32   */
-	struct list_head wcd9xxx_ch_list;	/* channel list         */
-	u16 grph;				/* slimbus group handle */
-	unsigned long ch_mask;
-	wait_queue_head_t dai_wait;
-	bool bus_down_in_recovery;
-};
-
-#define WCD9XXX_CH(xport, xshift) \
-	{.port = xport, .shift = xshift}
-
-enum wcd9xxx_chipid_major {
-	TABLA_MAJOR = cpu_to_le16(0x100),
-	SITAR_MAJOR = cpu_to_le16(0x101),
-	TAIKO_MAJOR = cpu_to_le16(0x102),
-	TAPAN_MAJOR = cpu_to_le16(0x103),
-	TOMTOM_MAJOR = cpu_to_le16(0x105),
-	TASHA_MAJOR = cpu_to_le16(0x0),
-	TASHA2P0_MAJOR = cpu_to_le16(0x107),
-	TAVIL_MAJOR = cpu_to_le16(0x108),
-};
-
-enum codec_power_states {
-	WCD_REGION_POWER_COLLAPSE_REMOVE,
-	WCD_REGION_POWER_COLLAPSE_BEGIN,
-	WCD_REGION_POWER_DOWN,
-};
-
-enum wcd_power_regions {
-	WCD9XXX_DIG_CORE_REGION_1,
-	WCD9XXX_MAX_PWR_REGIONS,
-};
-
-struct wcd9xxx_codec_type {
-	u16 id_major;
-	u16 id_minor;
-	struct mfd_cell *dev;
-	int size;
-	int num_irqs;
-	int version; /* -1 to retrieve version from chip version register */
-	enum wcd9xxx_slim_slave_addr_type slim_slave_type;
-	u16 i2c_chip_status;
-	const struct intr_data *intr_tbl;
-	int intr_tbl_size;
-	u16 intr_reg[WCD9XXX_INTR_REG_MAX];
-};
-
-struct wcd9xxx_power_region {
-	enum codec_power_states power_state;
-	u16 pwr_collapse_reg_min;
-	u16 pwr_collapse_reg_max;
-};
-
-struct wcd9xxx {
-	struct device *dev;
-	struct slim_device *slim;
-	struct slim_device *slim_slave;
-	struct mutex io_lock;
-	struct mutex xfer_lock;
-	struct mutex reset_lock;
-	u8 version;
-
-	int reset_gpio;
-	struct device_node *wcd_rst_np;
-
-	int (*read_dev)(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			int bytes, void *dest, bool interface_reg);
-	int (*write_dev)(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			int bytes, void *src, bool interface_reg);
-	int (*multi_reg_write)(struct wcd9xxx *wcd9xxx, const void *data,
-			       size_t count);
-	int (*dev_down)(struct wcd9xxx *wcd9xxx);
-	int (*post_reset)(struct wcd9xxx *wcd9xxx);
-
-	void *ssr_priv;
-	unsigned long dev_up;
-
-	u32 num_of_supplies;
-	struct regulator_bulk_data *supplies;
-
-	struct wcd9xxx_core_resource core_res;
-
-	u16 id_minor;
-	u16 id_major;
-
-	/* Slimbus or I2S port */
-	u32 num_rx_port;
-	u32 num_tx_port;
-	struct wcd9xxx_ch *rx_chs;
-	struct wcd9xxx_ch *tx_chs;
-	u32 mclk_rate;
-	enum codec_variant type;
-	struct regmap *regmap;
-
-	struct wcd9xxx_codec_type *codec_type;
-	bool prev_pg_valid;
-	u8 prev_pg;
-	u8 avoid_cdc_rstlow;
-	struct wcd9xxx_power_region *wcd9xxx_pwr[WCD9XXX_MAX_PWR_REGIONS];
-};
-
-struct wcd9xxx_reg_val {
-	unsigned short reg; /* register address */
-	u8 *buf;            /* buffer to be written to reg. addr */
-	int bytes;          /* number of bytes to be written */
-};
-
-int wcd9xxx_interface_reg_read(struct wcd9xxx *wcd9xxx, unsigned short reg);
-int wcd9xxx_interface_reg_write(struct wcd9xxx *wcd9xxx, unsigned short reg,
-		u8 val);
-int wcd9xxx_get_logical_addresses(u8 *pgd_la, u8 *inf_la);
-int wcd9xxx_slim_write_repeat(struct wcd9xxx *wcd9xxx, unsigned short reg,
-			     int bytes, void *src);
-int wcd9xxx_slim_reserve_bw(struct wcd9xxx *wcd9xxx,
-			    u32 bw_ops, bool commit);
-int wcd9xxx_set_power_state(struct wcd9xxx *wcd9xxx, enum codec_power_states,
-			    enum wcd_power_regions);
-int wcd9xxx_get_current_power_state(struct wcd9xxx *wcd9xxx,
-				    enum wcd_power_regions);
-
-int wcd9xxx_page_write(struct wcd9xxx *wcd9xxx, unsigned short *reg);
-
-int wcd9xxx_slim_bulk_write(struct wcd9xxx *wcd9xxx,
-			    struct wcd9xxx_reg_val *bulk_reg,
-			    unsigned int size, bool interface);
-
-extern int wcd9xxx_core_res_init(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res,
-	int num_irqs, int num_irq_regs, struct regmap *wcd_regmap);
-
-extern void wcd9xxx_core_res_deinit(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res);
-
-extern int wcd9xxx_core_res_suspend(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res,
-	pm_message_t pmesg);
-
-extern int wcd9xxx_core_res_resume(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res);
-
-extern int wcd9xxx_core_irq_init(
-	struct wcd9xxx_core_resource *wcd9xxx_core_res);
-
-extern int wcd9xxx_assign_irq(struct wcd9xxx_core_resource *wcd9xxx_core_res,
-			      unsigned int irq,
-			      unsigned int irq_base);
-
-extern enum wcd9xxx_intf_status wcd9xxx_get_intf_type(void);
-extern void wcd9xxx_set_intf_type(enum wcd9xxx_intf_status);
-
-extern enum wcd9xxx_pm_state wcd9xxx_pm_cmpxchg(
-			struct wcd9xxx_core_resource *wcd9xxx_core_res,
-			enum wcd9xxx_pm_state o,
-			enum wcd9xxx_pm_state n);
-static inline int __init wcd9xxx_irq_of_init(struct device_node *node,
-			       struct device_node *parent)
-{
-	return 0;
-}
-
-int wcd9xxx_init(void);
-void wcd9xxx_exit(void);
-#endif
diff --git a/include/linux/mfd/wcd9xxx/pdata.h b/include/linux/mfd/wcd9xxx/pdata.h
deleted file mode 100644
index cfe4724..0000000
--- a/include/linux/mfd/wcd9xxx/pdata.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __MFD_WCD9XXX_PDATA_H__
-
-#define __MFD_WCD9XXX_PDATA_H__
-
-#include <linux/slimbus/slimbus.h>
-#include <linux/mfd/msm-cdc-supply.h>
-
-#define MICBIAS_EXT_BYP_CAP 0x00
-#define MICBIAS_NO_EXT_BYP_CAP 0x01
-
-#define SITAR_LDOH_1P95_V 0x0
-#define SITAR_LDOH_2P35_V 0x1
-#define SITAR_LDOH_2P75_V 0x2
-#define SITAR_LDOH_2P85_V 0x3
-
-#define SITAR_CFILT1_SEL 0x0
-#define SITAR_CFILT2_SEL 0x1
-#define SITAR_CFILT3_SEL 0x2
-
-#define WCD9XXX_LDOH_1P95_V 0x0
-#define WCD9XXX_LDOH_2P35_V 0x1
-#define WCD9XXX_LDOH_2P75_V 0x2
-#define WCD9XXX_LDOH_2P85_V 0x3
-#define WCD9XXX_LDOH_3P0_V 0x3
-
-#define TABLA_LDOH_1P95_V 0x0
-#define TABLA_LDOH_2P35_V 0x1
-#define TABLA_LDOH_2P75_V 0x2
-#define TABLA_LDOH_2P85_V 0x3
-
-#define TABLA_CFILT1_SEL 0x0
-#define TABLA_CFILT2_SEL 0x1
-#define TABLA_CFILT3_SEL 0x2
-
-#define MAX_AMIC_CHANNEL 7
-
-#define TABLA_OCP_300_MA 0x0
-#define TABLA_OCP_350_MA 0x2
-#define TABLA_OCP_365_MA 0x3
-#define TABLA_OCP_150_MA 0x4
-#define TABLA_OCP_190_MA 0x6
-#define TABLA_OCP_220_MA 0x7
-
-#define TABLA_DCYCLE_255  0x0
-#define TABLA_DCYCLE_511  0x1
-#define TABLA_DCYCLE_767  0x2
-#define TABLA_DCYCLE_1023 0x3
-#define TABLA_DCYCLE_1279 0x4
-#define TABLA_DCYCLE_1535 0x5
-#define TABLA_DCYCLE_1791 0x6
-#define TABLA_DCYCLE_2047 0x7
-#define TABLA_DCYCLE_2303 0x8
-#define TABLA_DCYCLE_2559 0x9
-#define TABLA_DCYCLE_2815 0xA
-#define TABLA_DCYCLE_3071 0xB
-#define TABLA_DCYCLE_3327 0xC
-#define TABLA_DCYCLE_3583 0xD
-#define TABLA_DCYCLE_3839 0xE
-#define TABLA_DCYCLE_4095 0xF
-
-#define WCD9XXX_MCLK_CLK_12P288MHZ 12288000
-#define WCD9XXX_MCLK_CLK_9P6HZ 9600000
-
-/* Only valid for 9.6 MHz mclk */
-#define WCD9XXX_DMIC_SAMPLE_RATE_600KHZ 600000
-#define WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ 2400000
-#define WCD9XXX_DMIC_SAMPLE_RATE_3P2MHZ 3200000
-#define WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ 4800000
-
-/* Only valid for 12.288 MHz mclk */
-#define WCD9XXX_DMIC_SAMPLE_RATE_768KHZ 768000
-#define WCD9XXX_DMIC_SAMPLE_RATE_2P048MHZ 2048000
-#define WCD9XXX_DMIC_SAMPLE_RATE_3P072MHZ 3072000
-#define WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ 4096000
-#define WCD9XXX_DMIC_SAMPLE_RATE_6P144MHZ 6144000
-
-#define WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED 0
-
-#define WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED 0
-
-struct wcd9xxx_amic {
-	/*legacy mode, txfe_enable and txfe_buff take 7 input
-	 * each bit represent the channel / TXFE number
-	 * and numbered as below
-	 * bit 0 = channel 1 / TXFE1_ENABLE / TXFE1_BUFF
-	 * bit 1 = channel 2 / TXFE2_ENABLE / TXFE2_BUFF
-	 * ...
-	 * bit 7 = channel 7 / TXFE7_ENABLE / TXFE7_BUFF
-	 */
-	u8 legacy_mode:MAX_AMIC_CHANNEL;
-	u8 txfe_enable:MAX_AMIC_CHANNEL;
-	u8 txfe_buff:MAX_AMIC_CHANNEL;
-	u8 use_pdata:MAX_AMIC_CHANNEL;
-};
-
-/* Each micbias can be assigned to one of three cfilters
- * Vbatt_min >= .15V + ldoh_v
- * ldoh_v >= .15v + cfiltx_mv
- * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
- * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
- * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
- * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
- */
-
-struct wcd9xxx_micbias_setting {
-	u8 ldoh_v;
-	u32 cfilt1_mv; /* in mv */
-	u32 cfilt2_mv; /* in mv */
-	u32 cfilt3_mv; /* in mv */
-	u32 micb1_mv;
-	u32 micb2_mv;
-	u32 micb3_mv;
-	u32 micb4_mv;
-	/* Different WCD9xxx series codecs may not
-	 * have 4 mic biases. If a codec has fewer
-	 * mic biases, some of these properties will
-	 * not be used.
-	 */
-	u8 bias1_cfilt_sel;
-	u8 bias2_cfilt_sel;
-	u8 bias3_cfilt_sel;
-	u8 bias4_cfilt_sel;
-	u8 bias1_cap_mode;
-	u8 bias2_cap_mode;
-	u8 bias3_cap_mode;
-	u8 bias4_cap_mode;
-	bool bias2_is_headset_only;
-};
-
-struct wcd9xxx_ocp_setting {
-	unsigned int	use_pdata:1; /* 0 - use sys default as recommended */
-	unsigned int	num_attempts:4; /* up to 15 attempts */
-	unsigned int	run_time:4; /* in duty cycle */
-	unsigned int	wait_time:4; /* in duty cycle */
-	unsigned int	hph_ocp_limit:3; /* Headphone OCP current limit */
-};
-
-#define WCD9XXX_MAX_REGULATOR	9
-/*
- *      format : TABLA_<POWER_SUPPLY_PIN_NAME>_CUR_MAX
- *
- *      <POWER_SUPPLY_PIN_NAME> from Tabla objective spec
- */
-
-#define  WCD9XXX_CDC_VDDA_CP_CUR_MAX      500000
-#define  WCD9XXX_CDC_VDDA_RX_CUR_MAX      20000
-#define  WCD9XXX_CDC_VDDA_TX_CUR_MAX      20000
-#define  WCD9XXX_VDDIO_CDC_CUR_MAX        5000
-
-#define  WCD9XXX_VDDD_CDC_D_CUR_MAX       5000
-#define  WCD9XXX_VDDD_CDC_A_CUR_MAX       5000
-
-#define WCD9XXX_VDD_SPKDRV_NAME "cdc-vdd-spkdrv"
-#define WCD9XXX_VDD_SPKDRV2_NAME "cdc-vdd-spkdrv-2"
-
-struct wcd9xxx_regulator {
-	const char *name;
-	int min_uV;
-	int max_uV;
-	int optimum_uA;
-	bool ondemand;
-	struct regulator *regulator;
-};
-
-struct wcd9xxx_pdata {
-	int irq;
-	int irq_base;
-	int num_irqs;
-	int reset_gpio;
-	bool has_buck_vsel_gpio;
-	struct device_node *buck_vsel_ctl_np;
-	struct device_node *wcd_rst_np;
-	struct wcd9xxx_amic amic_settings;
-	struct slim_device slimbus_slave_device;
-	struct wcd9xxx_micbias_setting micbias;
-	struct wcd9xxx_ocp_setting ocp;
-	struct cdc_regulator *regulator;
-	int num_supplies;
-	u32 mclk_rate;
-	u32 dmic_sample_rate;
-	u32 mad_dmic_sample_rate;
-	u32 ecpp_dmic_sample_rate;
-	u32 dmic_clk_drv;
-	u16 use_pinctrl;
-};
-
-#endif
diff --git a/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h b/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h
deleted file mode 100644
index 99ce603..0000000
--- a/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include <linux/mfd/wcd9xxx/core.h>
-
-#ifndef __MFD_WCD9XXX_IRQ_H
-#define __MFD_WCD9XXX_IRQ_H
-bool wcd9xxx_lock_sleep(struct wcd9xxx_core_resource *wcd9xxx_res);
-void wcd9xxx_unlock_sleep(struct wcd9xxx_core_resource *wcd9xxx_res);
-void wcd9xxx_nested_irq_lock(struct wcd9xxx_core_resource *wcd9xxx_res);
-void wcd9xxx_nested_irq_unlock(struct wcd9xxx_core_resource *wcd9xxx_res);
-int wcd9xxx_request_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq,
-			irq_handler_t handler, const char *name, void *data);
-
-void wcd9xxx_free_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
-			int irq, void *data);
-void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
-void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
-			int irq);
-void wcd9xxx_disable_irq_sync(struct wcd9xxx_core_resource *wcd9xxx_res,
-			int irq);
-
-int wcd9xxx_irq_init(struct wcd9xxx_core_resource *wcd9xxx_res);
-void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *wcd9xxx_res);
-int wcd9xxx_irq_drv_init(void);
-void wcd9xxx_irq_drv_exit(void);
-#endif
diff --git a/include/linux/mfd/wcd9xxx/wcd9xxx-slimslave.h b/include/linux/mfd/wcd9xxx/wcd9xxx-slimslave.h
deleted file mode 100644
index 96fdb00..0000000
--- a/include/linux/mfd/wcd9xxx/wcd9xxx-slimslave.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9310_SLIMSLAVE_H_
-#define __WCD9310_SLIMSLAVE_H_
-
-#include <linux/slimbus/slimbus.h>
-#include <linux/mfd/wcd9xxx/core.h>
-
-
-/*
- *  client is expected to give port ids in the range of
- *  1-10 for pre Taiko Tx ports and 1-16 for Taiko
- *  1-7 for pre Taiko Rx ports and 1-16 for Tako,
- *  we need to add offset for getting the absolute slave
- *  port id before configuring the HW
- */
-#define TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 10
-#define TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 16
-
-#define SLIM_MAX_TX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
-
-#define TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
-	TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
-#define TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
-	TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
-
-#define TABLA_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 7
-#define TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 13
-
-#define SLIM_MAX_RX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS
-
-#define SLIM_MAX_REG_ADDR (0x180 + 4 * (SLIM_MAX_RX_PORTS))
-
-#define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
-	TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
-#define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
-	TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
-
-#define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16
-#define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31
-
-#define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9
-#define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15
-
-/* below details are taken from SLIMBUS slave SWI */
-#define SB_PGD_PORT_BASE 0x000
-
-#define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \
-		(SB_PGD_PORT_BASE + offset + (1 * port_num))
-
-#define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \
-		(SB_PGD_PORT_BASE + 0x100 + 4*port_num)
-#define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID   0
-#define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID     7
-
-#define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \
-		(SB_PGD_PORT_BASE + 0x101 + 4*port_num)
-#define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID   8
-
-#define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \
-		(SB_PGD_PORT_BASE + offset + (4 * port_num))
-
-/* slave port water mark level
- *   (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
- */
-#define SLAVE_PORT_WATER_MARK_6BYTES  0
-#define SLAVE_PORT_WATER_MARK_9BYTES  1
-#define SLAVE_PORT_WATER_MARK_12BYTES 2
-#define SLAVE_PORT_WATER_MARK_15BYTES 3
-#define SLAVE_PORT_WATER_MARK_SHIFT 1
-#define SLAVE_PORT_ENABLE           1
-#define SLAVE_PORT_DISABLE          0
-#define WATER_MARK_VAL \
-	((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
-	 (SLAVE_PORT_ENABLE))
-#define BASE_CH_NUM 128
-
-
-int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx,
-			   u8 wcd9xxx_pgd_la,
-			   unsigned int tx_num, unsigned int *tx_slot,
-			   unsigned int rx_num, unsigned int *rx_slot);
-
-int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx);
-
-int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list,
-			    unsigned int rate, unsigned int bit_width,
-			    u16 *grph);
-int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list,
-			    unsigned int rate, unsigned int bit_width,
-				u16 *grph);
-int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
-			      struct list_head *wcd9xxx_ch_list, u16 grph);
-int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
-			      struct list_head *wcd9xxx_ch_list, u16 grph);
-int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx,
-			unsigned int *rx_ch,
-			unsigned int *tx_ch);
-int wcd9xxx_get_slave_port(unsigned int ch_num);
-int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
-			    struct list_head *wcd9xxx_ch_list, u16 grph);
-int wcd9xxx_rx_vport_validation(u32 port_id,
-				struct list_head *codec_dai_list);
-int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
-				struct wcd9xxx_codec_dai_data *codec_dai,
-				u32 num_codec_dais);
-#endif /* __WCD9310_SLIMSLAVE_H_ */
diff --git a/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h b/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h
deleted file mode 100644
index 7a13dd1..0000000
--- a/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9XXX_UTILS_H__
-#define __WCD9XXX_UTILS_H__
-
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/regmap.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/mfd/wcd9xxx/core.h>
-
-struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev);
-int wcd9xxx_bringup(struct device *dev);
-int wcd9xxx_bringdown(struct device *dev);
-struct regmap *wcd9xxx_regmap_init(struct device *dev,
-				   const struct regmap_config *config);
-int wcd9xxx_reset(struct device *dev);
-int wcd9xxx_reset_low(struct device *dev);
-int wcd9xxx_get_codec_info(struct device *dev);
-
-typedef int (*codec_bringup_fn)(struct wcd9xxx *);
-typedef int (*codec_bringdown_fn)(struct wcd9xxx *);
-typedef int (*codec_type_fn)(struct wcd9xxx *,
-			     struct wcd9xxx_codec_type *);
-
-codec_bringdown_fn wcd9xxx_bringdown_fn(int type);
-codec_bringup_fn wcd9xxx_bringup_fn(int type);
-codec_type_fn wcd9xxx_get_codec_info_fn(int type);
-
-#endif
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index c9f3796..80faf44 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -1384,6 +1384,8 @@
 int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
 int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
 				      bool *vlan_offload_disabled);
+void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
+				       struct _rule_hw *eth_header);
 int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
 int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
 int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 3139ea4..5942478 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -515,6 +515,10 @@
 	 */
 	bool tlb_flush_pending;
 #endif
+#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
+	/* See flush_tlb_batched_pending() */
+	bool tlb_flush_batched;
+#endif
 	struct uprobes_state uprobes_state;
 #ifdef CONFIG_X86_INTEL_MPX
 	/* address of the bounds directory */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index f214b0c..1e07ed2 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -226,6 +226,7 @@
 	unsigned int		resp_arg;
 	unsigned int		dev_pend_tasks;
 	bool			resp_err;
+	bool			skip_err_handling;
 	int			tag; /* used for command queuing */
 	u8			ctx_id;
 };
@@ -543,6 +544,7 @@
 	unsigned int		bus_resume_flags;
 #define MMC_BUSRESUME_MANUAL_RESUME	(1 << 0)
 #define MMC_BUSRESUME_NEEDS_RESUME	(1 << 1)
+	bool ignore_bus_resume_flags;
 
 	unsigned int		sdio_irqs;
 	struct task_struct	*sdio_irq_thread;
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index ed0099c9..07e1acb 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -158,7 +158,6 @@
 	NR_UNEVICTABLE,		/*  "     "     "   "       "         */
 	NR_ISOLATED_ANON,	/* Temporary isolated pages from anon lru */
 	NR_ISOLATED_FILE,	/* Temporary isolated pages from file lru */
-	NR_PAGES_SCANNED,	/* pages scanned since last reclaim */
 	WORKINGSET_REFAULT,
 	WORKINGSET_ACTIVATE,
 	WORKINGSET_NODERECLAIM,
@@ -645,6 +644,8 @@
 	int kswapd_order;
 	enum zone_type kswapd_classzone_idx;
 
+	int kswapd_failures;		/* Number of 'reclaimed == 0' runs */
+
 #ifdef CONFIG_COMPACTION
 	int kcompactd_max_order;
 	enum zone_type kcompactd_classzone_idx;
diff --git a/include/linux/msm-bus.h b/include/linux/msm-bus.h
index c298666..a584e0a 100644
--- a/include/linux/msm-bus.h
+++ b/include/linux/msm-bus.h
@@ -130,6 +130,8 @@
 					uint32_t cl, unsigned int index);
 int msm_bus_scale_query_tcs_cmd_all(struct msm_bus_tcs_handle *tcs_handle,
 					uint32_t cl);
+int msm_bus_noc_throttle_wa(bool enable);
+int msm_bus_noc_priority_wa(bool enable);
 
 /* AXI Port configuration APIs */
 int msm_bus_axi_porthalt(int master_port);
@@ -211,6 +213,16 @@
 	return 0;
 }
 
+static inline int msm_bus_noc_throttle_wa(bool enable)
+{
+	return 0;
+}
+
+static inline int msm_bus_noc_priority_wa(bool enable)
+{
+	return 0;
+}
+
 #endif
 
 #if defined(CONFIG_OF) && defined(CONFIG_QCOM_BUS_SCALING)
diff --git a/include/linux/msm_audio_ion.h b/include/linux/msm_audio_ion.h
deleted file mode 100644
index 0761b88..0000000
--- a/include/linux/msm_audio_ion.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _LINUX_MSM_AUDIO_ION_H
-#define _LINUX_MSM_AUDIO_ION_H
-#include <sound/q6asm-v2.h>
-#include <sound/pcm.h>
-#include <linux/msm_ion.h>
-
-
-int msm_audio_ion_alloc(const char *name, struct ion_client **client,
-			struct ion_handle **handle, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr);
-
-int msm_audio_ion_import(const char *name, struct ion_client **client,
-			struct ion_handle **handle, int fd,
-			unsigned long *ionflag, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr);
-int msm_audio_ion_free(struct ion_client *client, struct ion_handle *handle);
-int msm_audio_ion_mmap(struct audio_buffer *substream,
-		       struct vm_area_struct *vma);
-
-bool msm_audio_ion_is_smmu_available(void);
-int msm_audio_ion_cache_operations(struct audio_buffer *abuff, int cache_op);
-
-struct ion_client *msm_audio_ion_client_create(const char *name);
-void msm_audio_ion_client_destroy(struct ion_client *client);
-int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
-			struct ion_handle **handle, int fd,
-			unsigned long *ionflag, size_t bufsz,
-			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr);
-int msm_audio_ion_free_legacy(struct ion_client *client,
-			struct ion_handle *handle);
-u32 msm_audio_populate_upper_32_bits(ion_phys_addr_t pa);
-#endif /* _LINUX_MSM_AUDIO_ION_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d92d9a6..266471e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3905,6 +3905,8 @@
 	     updev; \
 	     updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)))
 
+bool netdev_has_any_upper_dev(struct net_device *dev);
+
 void *netdev_lower_get_next_private(struct net_device *dev,
 				    struct list_head **iter);
 void *netdev_lower_get_next_private_rcu(struct net_device *dev,
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index beb1e10..3bf867a 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1199,7 +1199,7 @@
 
 struct nfs41_exchange_id_args {
 	struct nfs_client		*client;
-	nfs4_verifier			*verifier;
+	nfs4_verifier			verifier;
 	u32				flags;
 	struct nfs41_state_protection	state_protect;
 };
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 3ca2526..4443a29 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -24,6 +24,9 @@
 #define NMI_WATCHDOG_ENABLED      (1 << NMI_WATCHDOG_ENABLED_BIT)
 #define SOFT_WATCHDOG_ENABLED     (1 << SOFT_WATCHDOG_ENABLED_BIT)
 
+DECLARE_PER_CPU(unsigned long, hrtimer_interrupts);
+DECLARE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
+
 /**
  * touch_nmi_watchdog - restart NMI watchdog timeout.
  *
@@ -31,8 +34,11 @@
  * may be used to reset the timeout - for code which intentionally
  * disables interrupts for a long time. This call is stateless.
  */
-#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
+#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR_NMI)
 #include <asm/nmi.h>
+#endif
+
+#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
 extern void touch_nmi_watchdog(void);
 #else
 static inline void touch_nmi_watchdog(void)
@@ -130,6 +136,7 @@
 #define sysctl_softlockup_all_cpu_backtrace 0
 #define sysctl_hardlockup_all_cpu_backtrace 0
 #endif
+
 extern bool is_hardlockup(void);
 struct ctl_table;
 extern int proc_watchdog(struct ctl_table *, int ,
diff --git a/include/linux/oom.h b/include/linux/oom.h
index b986840..5b5d4c7 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -82,6 +82,8 @@
 extern void dump_tasks(struct mem_cgroup *memcg,
 		const nodemask_t *nodemask);
 
+extern void wake_oom_reaper(struct task_struct *tsk);
+
 /* sysctls */
 extern int sysctl_oom_dump_tasks;
 extern int sysctl_oom_kill_allocating_task;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 3e5dbbe..4308204 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -574,6 +574,7 @@
 #define PCI_DEVICE_ID_AMD_CS5536_EHC    0x2095
 #define PCI_DEVICE_ID_AMD_CS5536_UDC    0x2096
 #define PCI_DEVICE_ID_AMD_CS5536_UOC    0x2097
+#define PCI_DEVICE_ID_AMD_CS5536_DEV_IDE    0x2092
 #define PCI_DEVICE_ID_AMD_CS5536_IDE    0x209A
 #define PCI_DEVICE_ID_AMD_LX_VIDEO  0x2081
 #define PCI_DEVICE_ID_AMD_LX_AES    0x2082
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 3c80583..6e38683 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -583,6 +583,12 @@
 	int				group_caps;
 
 	struct perf_event		*group_leader;
+
+	/*
+	 * Protect the pmu, attributes and context of a group leader.
+	 * Note: does not protect the pointer to the group_leader.
+	 */
+	struct mutex			group_leader_mutex;
 	struct pmu			*pmu;
 	void				*pmu_private;
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6c9b1e0..8431c8c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -799,6 +799,10 @@
 int genphy_suspend(struct phy_device *phydev);
 int genphy_resume(struct phy_device *phydev);
 int genphy_soft_reset(struct phy_device *phydev);
+static inline int genphy_no_soft_reset(struct phy_device *phydev)
+{
+	return 0;
+}
 void phy_driver_unregister(struct phy_driver *drv);
 void phy_drivers_unregister(struct phy_driver *drv, int n);
 int phy_driver_register(struct phy_driver *new_driver, struct module *owner);
diff --git a/include/linux/platform_data/msm_serial_hs.h b/include/linux/platform_data/msm_serial_hs.h
new file mode 100644
index 0000000..72c76e5
--- /dev/null
+++ b/include/linux/platform_data/msm_serial_hs.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 Google, Inc.
+ * Copyright (C) 2010-2014, The Linux Foundation. All rights reserved.
+ * Author: Nick Pelly <npelly@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 __ASM_ARCH_MSM_SERIAL_HS_H
+#define __ASM_ARCH_MSM_SERIAL_HS_H
+
+#include <linux/serial_core.h>
+
+/**
+ * struct msm_serial_hs_platform_data - platform device data
+ *					for msm hsuart device
+ * @wakeup_irq : IRQ line to be configured as Wakeup source.
+ * @inject_rx_on_wakeup : Set 1 if specific character to be inserted on wakeup
+ * @rx_to_inject : Character to be inserted on wakeup
+ * @gpio_config : Configure gpios that are used for uart communication
+ * @userid : User-defined number to be used to enumerate device as tty<userid>
+ * @uart_tx_gpio: GPIO number for UART Tx Line.
+ * @uart_rx_gpio: GPIO number for UART Rx Line.
+ * @uart_cts_gpio: GPIO number for UART CTS Line.
+ * @uart_rfr_gpio: GPIO number for UART RFR Line.
+ * @bam_tx_ep_pipe_index : BAM TX Endpoint Pipe Index for HSUART
+ * @bam_tx_ep_pipe_index : BAM RX Endpoint Pipe Index for HSUART
+ * @no_suspend_delay : Flag used to make system go to suspend
+ * immediately or not
+ * @obs: Flag to enable out of band sleep feature support
+ */
+struct msm_serial_hs_platform_data {
+	int wakeup_irq;  /* wakeup irq */
+	bool inject_rx_on_wakeup;
+	u8 rx_to_inject;
+	int (*gpio_config)(int);
+	int userid;
+
+	int uart_tx_gpio;
+	int uart_rx_gpio;
+	int uart_cts_gpio;
+	int uart_rfr_gpio;
+	unsigned int bam_tx_ep_pipe_index;
+	unsigned int bam_rx_ep_pipe_index;
+	bool no_suspend_delay;
+	bool obs;
+};
+
+/* return true when tx is empty */
+unsigned int msm_hs_tx_empty(struct uart_port *uport);
+int msm_hs_request_clock_off(struct uart_port *uport);
+int msm_hs_request_clock_on(struct uart_port *uport);
+struct uart_port *msm_hs_get_uart_port(int port_index);
+void msm_hs_set_mctrl(struct uart_port *uport,
+				    unsigned int mctrl);
+#endif
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index ec3be7b..b6c8c92 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -199,6 +199,8 @@
 	POWER_SUPPLY_PROP_LOW_POWER,
 	POWER_SUPPLY_PROP_COOL_TEMP,
 	POWER_SUPPLY_PROP_WARM_TEMP,
+	POWER_SUPPLY_PROP_COLD_TEMP,
+	POWER_SUPPLY_PROP_HOT_TEMP,
 	POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL,
 	POWER_SUPPLY_PROP_RESISTANCE,
 	POWER_SUPPLY_PROP_RESISTANCE_CAPACITIVE,
@@ -252,6 +254,9 @@
 	POWER_SUPPLY_PROP_CC_STEP,
 	POWER_SUPPLY_PROP_CC_STEP_SEL,
 	POWER_SUPPLY_PROP_SW_JEITA_ENABLED,
+	POWER_SUPPLY_PROP_PD_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_PD_VOLTAGE_MIN,
+	POWER_SUPPLY_PROP_SDP_CURRENT_MAX,
 	/* Local extensions of type int64_t */
 	POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
 	/* Properties of type `const char *' */
diff --git a/include/linux/property.h b/include/linux/property.h
index 856e50b..338f9b7 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -33,6 +33,8 @@
 	DEV_DMA_COHERENT,
 };
 
+struct fwnode_handle *dev_fwnode(struct device *dev);
+
 bool device_property_present(struct device *dev, const char *propname);
 int device_property_read_u8_array(struct device *dev, const char *propname,
 				  u8 *val, size_t nval);
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 485cc8e..cb5edd6 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -24,6 +24,13 @@
 #include <linux/list.h>
 #include <linux/types.h>
 
+/*
+ * Choose whether access to the RAM zone requires locking or not.  If a zone
+ * can be written to from different CPUs like with ftrace for example, then
+ * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
+ */
+#define PRZ_FLAG_NO_LOCK	BIT(0)
+
 struct persistent_ram_buffer;
 struct rs_control;
 
@@ -40,6 +47,8 @@
 	void *vaddr;
 	struct persistent_ram_buffer *buffer;
 	size_t buffer_size;
+	u32 flags;
+	raw_spinlock_t buffer_lock;
 
 	/* ECC correction */
 	char *par_buffer;
@@ -55,7 +64,7 @@
 
 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
 			u32 sig, struct persistent_ram_ecc_info *ecc_info,
-			unsigned int memtype);
+			unsigned int memtype, u32 flags);
 void persistent_ram_free(struct persistent_ram_zone *prz);
 void persistent_ram_zap(struct persistent_ram_zone *prz);
 
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 6c70444..b83507c 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -340,9 +340,9 @@
 	__PTR_RING_PEEK_CALL_v; \
 })
 
-static inline void **__ptr_ring_init_queue_alloc(int size, gfp_t gfp)
+static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp)
 {
-	return kzalloc(ALIGN(size * sizeof(void *), SMP_CACHE_BYTES), gfp);
+	return kcalloc(size, sizeof(void *), gfp);
 }
 
 static inline int ptr_ring_init(struct ptr_ring *r, int size, gfp_t gfp)
@@ -417,7 +417,8 @@
  * In particular if you consume ring in interrupt or BH context, you must
  * disable interrupts/BH when doing so.
  */
-static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings,
+static inline int ptr_ring_resize_multiple(struct ptr_ring **rings,
+					   unsigned int nrings,
 					   int size,
 					   gfp_t gfp, void (*destroy)(void *))
 {
@@ -425,7 +426,7 @@
 	void ***queues;
 	int i;
 
-	queues = kmalloc(nrings * sizeof *queues, gfp);
+	queues = kmalloc_array(nrings, sizeof(*queues), gfp);
 	if (!queues)
 		goto noqueues;
 
diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
index aa4c1ed..77a46bd 100644
--- a/include/linux/qcom-geni-se.h
+++ b/include/linux/qcom-geni-se.h
@@ -117,6 +117,7 @@
 #define SE_HW_PARAM_0			(0xE24)
 #define SE_HW_PARAM_1			(0xE28)
 #define SE_DMA_GENERAL_CFG		(0xE30)
+#define SE_DMA_DEBUG_REG0		(0xE40)
 
 /* GENI_OUTPUT_CTRL fields */
 #define DEFAULT_IO_OUTPUT_CTRL_MSK	(GENMASK(6, 0))
@@ -736,6 +737,22 @@
 int geni_se_iommu_free_buf(struct device *wrapper_dev, dma_addr_t *iova,
 			   void *buf, size_t size);
 
+
+/**
+ * geni_se_dump_dbg_regs() - Print relevant registers that capture most
+ *			accurately the state of an SE; meant to be called
+ *			in case of errors to help debug.
+ * @_dev:		Pointer to the SE's device.
+ * @iomem:		Base address of the SE's register space.
+ * @ipc:		IPC log context handle.
+ *
+ * This function is used to print out all the registers that capture the state
+ * of an SE to help debug any errors.
+ *
+ * Return:	None
+ */
+void geni_se_dump_dbg_regs(struct se_geni_rsc *rsc, void __iomem *base,
+				void *ipc);
 #else
 static inline unsigned int geni_read_reg_nolog(void __iomem *base, int offset)
 {
@@ -907,5 +924,10 @@
 	return -ENXIO;
 }
 
+static void geni_se_dump_dbg_regs(struct se_geni_rsc *rsc, void __iomem *base,
+				void *ipc)
+{
+}
+
 #endif
 #endif
diff --git a/include/linux/qdsp6v2/apr.h b/include/linux/qdsp6v2/apr.h
deleted file mode 100644
index 29deb3c..0000000
--- a/include/linux/qdsp6v2/apr.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __APR_H_
-#define __APR_H_
-
-#include <linux/mutex.h>
-#include <soc/qcom/subsystem_notif.h>
-
-enum apr_subsys_state {
-	APR_SUBSYS_DOWN,
-	APR_SUBSYS_UP,
-	APR_SUBSYS_LOADED,
-};
-
-struct apr_q6 {
-	void *pil;
-	atomic_t q6_state;
-	atomic_t modem_state;
-	struct mutex lock;
-};
-
-struct apr_hdr {
-	uint16_t hdr_field;
-	uint16_t pkt_size;
-	uint8_t src_svc;
-	uint8_t src_domain;
-	uint16_t src_port;
-	uint8_t dest_svc;
-	uint8_t dest_domain;
-	uint16_t dest_port;
-	uint32_t token;
-	uint32_t opcode;
-};
-
-#define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
-#define APR_PKT_SIZE(hdr_len, payload_len) ((hdr_len) + (payload_len))
-#define APR_HDR_FIELD(msg_type, hdr_len, ver)\
-	(((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
-
-#define APR_HDR_SIZE sizeof(struct apr_hdr)
-
-/* Version */
-#define APR_PKT_VER		0x0
-
-/* Command and Response Types */
-#define APR_MSG_TYPE_EVENT	0x0
-#define APR_MSG_TYPE_CMD_RSP	0x1
-#define APR_MSG_TYPE_SEQ_CMD	0x2
-#define APR_MSG_TYPE_NSEQ_CMD	0x3
-#define APR_MSG_TYPE_MAX	0x04
-
-/* APR Basic Response Message */
-#define APR_BASIC_RSP_RESULT 0x000110E8
-#define APR_RSP_ACCEPTED     0x000100BE
-
-/* Domain IDs */
-#define APR_DOMAIN_SIM	0x1
-#define APR_DOMAIN_PC		0x2
-#define APR_DOMAIN_MODEM	0x3
-#define APR_DOMAIN_ADSP	0x4
-#define APR_DOMAIN_APPS	0x5
-#define APR_DOMAIN_MAX	0x6
-
-/* ADSP service IDs */
-#define APR_SVC_TEST_CLIENT     0x2
-#define APR_SVC_ADSP_CORE	0x3
-#define APR_SVC_AFE		0x4
-#define APR_SVC_VSM		0x5
-#define APR_SVC_VPM		0x6
-#define APR_SVC_ASM		0x7
-#define APR_SVC_ADM		0x8
-#define APR_SVC_ADSP_MVM	0x09
-#define APR_SVC_ADSP_CVS	0x0A
-#define APR_SVC_ADSP_CVP	0x0B
-#define APR_SVC_USM		0x0C
-#define APR_SVC_LSM		0x0D
-#define APR_SVC_VIDC		0x16
-#define APR_SVC_MAX		0x17
-
-/* Modem Service IDs */
-#define APR_SVC_MVS		0x3
-#define APR_SVC_MVM		0x4
-#define APR_SVC_CVS		0x5
-#define APR_SVC_CVP		0x6
-#define APR_SVC_SRD		0x7
-
-/* APR Port IDs */
-#define APR_MAX_PORTS		0x80
-
-#define APR_NAME_MAX		0x40
-
-#define RESET_EVENTS		0x000130D7
-
-#define LPASS_RESTART_EVENT	0x1000
-#define LPASS_RESTART_READY	0x1001
-
-struct apr_client_data {
-	uint16_t reset_event;
-	uint16_t reset_proc;
-	uint16_t payload_size;
-	uint16_t hdr_len;
-	uint16_t msg_type;
-	uint16_t src;
-	uint16_t dest_svc;
-	uint16_t src_port;
-	uint16_t dest_port;
-	uint32_t token;
-	uint32_t opcode;
-	void *payload;
-};
-
-typedef int32_t (*apr_fn)(struct apr_client_data *data, void *priv);
-
-struct apr_svc {
-	uint16_t id;
-	uint16_t dest_id;
-	uint16_t client_id;
-	uint16_t dest_domain;
-	uint8_t rvd;
-	uint8_t port_cnt;
-	uint8_t svc_cnt;
-	uint8_t need_reset;
-	apr_fn port_fn[APR_MAX_PORTS];
-	void *port_priv[APR_MAX_PORTS];
-	apr_fn fn;
-	void *priv;
-	struct mutex m_lock;
-	spinlock_t w_lock;
-	uint8_t pkt_owner;
-};
-
-struct apr_client {
-	uint8_t id;
-	uint8_t svc_cnt;
-	uint8_t rvd;
-	struct mutex m_lock;
-	struct apr_svc_ch_dev *handle;
-	struct apr_svc svc[APR_SVC_MAX];
-};
-
-struct apr_rx_intents {
-	int num_of_intents;
-	uint32_t size;
-};
-
-struct apr_pkt_cfg {
-	uint8_t pkt_owner;
-	struct apr_rx_intents intents;
-};
-
-int apr_load_adsp_image(void);
-struct apr_client *apr_get_client(int dest_id, int client_id);
-int apr_wait_for_device_up(int dest_id);
-int apr_get_svc(const char *svc_name, int dest_id, int *client_id,
-		int *svc_idx, int *svc_id);
-void apr_cb_func(void *buf, int len, void *priv);
-struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
-					uint32_t src_port, void *priv);
-inline int apr_fill_hdr(void *handle, uint32_t *buf, uint16_t src_port,
-			uint16_t msg_type, uint16_t dest_port,
-			uint32_t token, uint32_t opcode, uint16_t len);
-
-int apr_send_pkt(void *handle, uint32_t *buf);
-int apr_deregister(void *handle);
-void subsys_notif_register(char *client_name, int domain,
-			   struct notifier_block *nb);
-int apr_get_dest_id(char *dest);
-uint16_t apr_get_data_src(struct apr_hdr *hdr);
-void change_q6_state(int state);
-void q6audio_dsp_not_responding(void);
-void apr_reset(void *handle);
-enum apr_subsys_state apr_get_subsys_state(void);
-enum apr_subsys_state apr_get_modem_state(void);
-void apr_set_modem_state(enum apr_subsys_state state);
-enum apr_subsys_state apr_get_q6_state(void);
-int apr_set_q6_state(enum apr_subsys_state state);
-void apr_set_subsys_state(void);
-const char *apr_get_lpass_subsys_name(void);
-uint16_t apr_get_reset_domain(uint16_t proc);
-#endif
diff --git a/include/linux/qdsp6v2/apr_tal.h b/include/linux/qdsp6v2/apr_tal.h
deleted file mode 100644
index 26d1a4c..0000000
--- a/include/linux/qdsp6v2/apr_tal.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (c) 2010-2011, 2016-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __APR_TAL_H_
-#define __APR_TAL_H_
-
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-#include <linux/uaccess.h>
-
-/* APR Client IDs */
-#define APR_CLIENT_AUDIO	0x0
-#define APR_CLIENT_VOICE	0x1
-#define APR_CLIENT_MAX		0x2
-
-#define APR_DL_SMD    0
-#define APR_DL_MAX    1
-
-#define APR_DEST_MODEM 0
-#define APR_DEST_QDSP6 1
-#define APR_DEST_MAX   2
-
-#if defined(CONFIG_MSM_QDSP6_APRV2_GLINK) || \
-	defined(CONFIG_MSM_QDSP6_APRV3_GLINK)
-#define APR_MAX_BUF			512
-#else
-#define APR_MAX_BUF			8092
-#endif
-
-#define APR_DEFAULT_NUM_OF_INTENTS 20
-
-#define APR_OPEN_TIMEOUT_MS 5000
-
-enum {
-	/* If client sets the pkt_owner to APR_PKT_OWNER_DRIVER, APR
-	 * driver will allocate a buffer, where the user packet is
-	 * copied into, for each and every single Tx transmission.
-	 * The buffer is thereafter passed to underlying link layer
-	 * and freed upon the notification received from the link layer
-	 * that the packet has been consumed.
-	 */
-	APR_PKT_OWNER_DRIVER,
-	/* If client sets the pkt_owner to APR_PKT_OWNER_CLIENT, APR
-	 * will pass the user packet memory address directly to underlying
-	 * link layer. In this case it is the client's responsibility to
-	 * make sure the packet is intact until being notified that the
-	 * packet has been consumed.
-	 */
-	APR_PKT_OWNER_CLIENT,
-};
-
-struct apr_pkt_priv {
-	/* This property is only applicable for APR over Glink.
-	 * It is ignored in APR over SMD cases.
-	 */
-	uint8_t pkt_owner;
-};
-
-typedef void (*apr_svc_cb_fn)(void *buf, int len, void *priv);
-struct apr_svc_ch_dev *apr_tal_open(uint32_t svc, uint32_t dest,
-			uint32_t dl, apr_svc_cb_fn func, void *priv);
-int apr_tal_write(struct apr_svc_ch_dev *apr_ch, void *data,
-		struct apr_pkt_priv *pkt_priv, int len);
-int apr_tal_close(struct apr_svc_ch_dev *apr_ch);
-int apr_tal_rx_intents_config(struct apr_svc_ch_dev *apr_ch,
-		int num_of_intents, uint32_t size);
-
-
-struct apr_svc_ch_dev {
-	void               *handle;
-	spinlock_t         w_lock;
-	spinlock_t         r_lock;
-	struct mutex       m_lock;
-	apr_svc_cb_fn      func;
-	wait_queue_head_t  wait;
-	void               *priv;
-	unsigned int       channel_state;
-	bool               if_remote_intent_ready;
-};
-
-#endif
diff --git a/include/linux/qdsp6v2/apr_us.h b/include/linux/qdsp6v2/apr_us.h
deleted file mode 100644
index 9a6804a..0000000
--- a/include/linux/qdsp6v2/apr_us.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __APR_US_H__
-#define __APR_US_H__
-
-#include <linux/qdsp6v2/apr.h>
-
-/* ======================================================================= */
-/*  Session Level commands */
-
-#define USM_SESSION_CMD_RUN				0x00012306
-struct usm_stream_cmd_run {
-	struct apr_hdr hdr;
-	u32            flags;
-	u32            msw_ts;
-	u32            lsw_ts;
-} __packed;
-
-/* Stream level commands */
-#define USM_STREAM_CMD_OPEN_READ			0x00012309
-struct usm_stream_cmd_open_read {
-	struct apr_hdr hdr;
-	u32            uMode;
-	u32            src_endpoint;
-	u32            pre_proc_top;
-	u32            format;
-} __packed;
-
-#define USM_STREAM_CMD_OPEN_WRITE			0x00011271
-struct usm_stream_cmd_open_write {
-	struct apr_hdr hdr;
-	u32            format;
-} __packed;
-
-
-#define USM_STREAM_CMD_CLOSE				0x0001230A
-
-#define USM_STREAM_CMD_SET_PARAM			0x00012731
-struct usm_stream_cmd_set_param {
-	struct apr_hdr hdr;
-	u32            buf_addr_lsw;
-	u32            buf_addr_msw;
-	u32            mem_map_handle;
-	u32            buf_size;
-	u32            module_id;
-	u32            param_id;
-} __packed;
-
-#define USM_STREAM_CMD_GET_PARAM			0x00012732
-struct usm_stream_cmd_get_param {
-	struct apr_hdr hdr;
-	u32            buf_addr_lsw;
-	u32            buf_addr_msw;
-	u32            mem_map_handle;
-	u32            buf_size;
-	u32            module_id;
-	u32            param_id;
-} __packed;
-
-/* Encoder configuration definitions */
-#define USM_STREAM_CMD_SET_ENC_PARAM			0x0001230B
-/* Decoder configuration definitions */
-#define USM_DATA_CMD_MEDIA_FORMAT_UPDATE		0x00011272
-
-/* Encoder/decoder configuration block */
-#define USM_PARAM_ID_ENCDEC_ENC_CFG_BLK			0x0001230D
-
-/* Max number of static located ports (bytes) */
-#define USM_MAX_PORT_NUMBER 8
-
-/* Max number of static located transparent data (bytes) */
-#define USM_MAX_CFG_DATA_SIZE 100
-
-/* Parameter structures used in  USM_STREAM_CMD_SET_ENCDEC_PARAM command */
-/* common declarations */
-struct usm_cfg_common {
-	u16 ch_cfg;
-	u16 bits_per_sample;
-	u32 sample_rate;
-	u32 dev_id;
-	u8 data_map[USM_MAX_PORT_NUMBER];
-} __packed;
-
-struct us_encdec_cfg {
-	u32 format_id;
-	struct usm_cfg_common cfg_common;
-	u16 params_size;
-	u8 *params;
-} __packed;
-
-/* Start/stop US signal detection */
-#define USM_SESSION_CMD_SIGNAL_DETECT_MODE		0x00012719
-
-struct usm_session_cmd_detect_info {
-	struct apr_hdr hdr;
-	u32 detect_mode;
-	u32 skip_interval;
-	u32 algorithm_cfg_size;
-} __packed;
-
-/* US signal detection result */
-#define USM_SESSION_EVENT_SIGNAL_DETECT_RESULT		0x00012720
-
-/* ======================================================================= */
-/*  Session Level commands */
-#define USM_CMD_SHARED_MEM_MAP_REGION		0x00012728
-struct usm_cmd_memory_map_region {
-	struct apr_hdr hdr;
-	u16            mempool_id;
-	u16            num_regions;
-	u32            flags;
-	u32            shm_addr_lsw;
-	u32            shm_addr_msw;
-	u32            mem_size_bytes;
-} __packed;
-
-#define USM_CMDRSP_SHARED_MEM_MAP_REGION	0x00012729
-struct usm_cmdrsp_memory_map_region {
-	u32            mem_map_handle;
-} __packed;
-
-#define USM_CMD_SHARED_MEM_UNMAP_REGION         0x0001272A
-struct usm_cmd_memory_unmap_region {
-	struct apr_hdr hdr;
-	u32            mem_map_handle;
-} __packed;
-
-#define USM_DATA_CMD_READ			0x00012724
-struct usm_stream_cmd_read {
-	struct apr_hdr hdr;
-	u32            buf_addr_lsw;
-	u32            buf_addr_msw;
-	u32            mem_map_handle;
-	u32            buf_size;
-	u32            seq_id;
-	u32            counter;
-} __packed;
-
-#define USM_DATA_EVENT_READ_DONE		0x00012725
-
-#define USM_DATA_CMD_WRITE			0x00012726
-struct usm_stream_cmd_write {
-	struct apr_hdr hdr;
-	u32            buf_addr_lsw;
-	u32            buf_addr_msw;
-	u32            mem_map_handle;
-	u32            buf_size;
-	u32            seq_id;
-	u32            res0;
-	u32            res1;
-	u32            res2;
-} __packed;
-
-#define USM_DATA_EVENT_WRITE_DONE		0x00012727
-
-struct usm_stream_media_format_update {
-	struct apr_hdr hdr;
-	u32 format_id;
-	/* <cfg_size> = sizeof(usm_cfg_common)+|transp_data| */
-	u32 cfg_size;
-	struct usm_cfg_common cfg_common;
-	/* Transparent configuration data for specific encoder */
-	u8  transp_data[USM_MAX_CFG_DATA_SIZE];
-} __packed;
-
-struct usm_encode_cfg_blk {
-	u32 frames_per_buf;
-	u32 format_id;
-	/* <cfg_size> = sizeof(usm_cfg_common)+|transp_data| */
-	u32 cfg_size;
-	struct usm_cfg_common cfg_common;
-	/* Transparent configuration data for specific encoder */
-	u8  transp_data[USM_MAX_CFG_DATA_SIZE];
-} __packed;
-
-struct usm_stream_cmd_encdec_cfg_blk {
-	struct apr_hdr hdr;
-	u32 param_id;
-	u32 param_size;
-	struct usm_encode_cfg_blk enc_blk;
-} __packed;
-
-#endif /* __APR_US_H__ */
diff --git a/include/linux/qdsp6v2/audio_notifier.h b/include/linux/qdsp6v2/audio_notifier.h
deleted file mode 100644
index 3587b49..0000000
--- a/include/linux/qdsp6v2/audio_notifier.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __AUDIO_NOTIFIER_H_
-#define __AUDIO_NOTIFIER_H_
-
-/* State of the notifier domain */
-enum {
-	AUDIO_NOTIFIER_SERVICE_DOWN,
-	AUDIO_NOTIFIER_SERVICE_UP
-};
-
-/* Service order determines connection priority
- * Highest number connected first
- */
-enum {
-	AUDIO_NOTIFIER_SSR_SERVICE,
-	AUDIO_NOTIFIER_PDR_SERVICE,
-	AUDIO_NOTIFIER_MAX_SERVICES
-};
-
-enum {
-	AUDIO_NOTIFIER_ADSP_DOMAIN,
-	AUDIO_NOTIFIER_MODEM_DOMAIN,
-	AUDIO_NOTIFIER_MAX_DOMAINS
-};
-
-/* Structure populated in void *data of nb function
- * callback used for audio_notifier_register
- */
-struct audio_notifier_cb_data {
-	int service;
-	int domain;
-};
-
-#ifdef CONFIG_MSM_QDSP6_NOTIFIER
-
-/*
- * Use audio_notifier_register to register any audio
- * clients who need to be notified of a remote process.
- * This API will determine and register the client with
- * the best available subsystem (SSR or PDR) for that
- * domain (Adsp or Modem). When an event is sent from that
- * domain the notifier block callback function will be called.
- *
- * client_name - A unique user name defined by the client.
- *	If the same name is used for multiple calls each will
- *	be tracked & called back separately and a single call
- *	to deregister will delete them all.
- * domain - Domain the client wants to get events from.
- *	AUDIO_NOTIFIER_ADSP_DOMAIN
- *	AUDIO_NOTIFIER_MODEM_DOMAIN
- * *nb - Pointer to a notifier block. Provide a callback function
- *	to be notified of an even on that domain.
- *
- *      nb_func(struct notifier_block *this, unsigned long opcode, void *data)
- *		this - pointer to own nb
- *		opcode - event from registered domain
- *			AUDIO_NOTIFIER_SERVICE_DOWN
- *			AUDIO_NOTIFIER_SERVICE_UP
- *		*data - pointer to struct audio_notifier_cb_data
- *
- * Returns:	Success: 0
- *		Error: -#
- */
-int audio_notifier_register(char *client_name, int domain,
-			    struct notifier_block *nb);
-
-/*
- * Use audio_notifier_deregister to deregister the clients from
- * all domains registered using audio_notifier_register that
- * match the client name.
- *
- * client_name - Unique user name used in audio_notifier_register.
- * Returns:	Success: 0
- *		Error: -#
- */
-int audio_notifier_deregister(char *client_name);
-
-#else
-
-static inline int audio_notifier_register(char *client_name, int domain,
-					  struct notifier_block *nb)
-{
-	return -ENODEV;
-}
-
-static inline int audio_notifier_deregister(char *client_name)
-{
-	return 0;
-}
-
-#endif /* CONFIG_MSM_QDSP6_PDR */
-
-#endif
diff --git a/include/linux/qdsp6v2/audio_pdr.h b/include/linux/qdsp6v2/audio_pdr.h
deleted file mode 100644
index ebfd366..0000000
--- a/include/linux/qdsp6v2/audio_pdr.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __AUDIO_PDR_H_
-#define __AUDIO_PDR_H_
-
-enum {
-	AUDIO_PDR_DOMAIN_ADSP,
-	AUDIO_PDR_DOMAIN_MAX
-};
-
-enum {
-	AUDIO_PDR_FRAMEWORK_DOWN,
-	AUDIO_PDR_FRAMEWORK_UP
-};
-
-#ifdef CONFIG_MSM_QDSP6_PDR
-
-/*
- * Use audio_pdr_register to register with the PDR subsystem this
- * should be done before module late init otherwise notification
- * of the AUDIO_PDR_FRAMEWORK_UP cannot be guaranteed.
- *
- * *nb - Pointer to a notifier block. Provide a callback function
- *       to be notified once the PDR framework has been initialized.
- *       Callback will receive either the AUDIO_PDR_FRAMEWORK_DOWN
- *       or AUDIO_PDR_FRAMEWORK_UP ioctl depending on the state of
- *       the PDR framework.
- *
- * Returns: Success: 0
- *          Failure: Error code
- */
-int audio_pdr_register(struct notifier_block *nb);
-
-/*
- * Use audio_pdr_service_register to register with a PDR service
- * Function should be called after nb callback registered with
- * audio_pdr_register has been called back with the
- * AUDIO_PDR_FRAMEWORK_UP ioctl.
- *
- * domain_id - Domain to use, example: AUDIO_PDR_ADSP
- * *nb - Pointer to a notifier block. Provide a callback function
- *       that will be notified of the state of the domain
- *       requested. The ioctls received by the callback are
- *       defined in service-notifier.h.
- *
- * Returns: Success: Client handle
- *          Failure: Pointer error code
- */
-void *audio_pdr_service_register(int domain_id,
-				 struct notifier_block *nb, int *curr_state);
-
-/*
- * Use audio_pdr_service_deregister to deregister with a PDR
- * service that was registered using the audio_pdr_service_register
- * API.
- *
- * *service_handle - Service handle returned by audio_pdr_service_register
- * *nb - Pointer to the notifier block. Used in the call to
- *       audio_pdr_service_register.
- *
- * Returns: Success: Client handle
- *          Failure: Error code
- */
-int audio_pdr_service_deregister(void *service_handle,
-				 struct notifier_block *nb);
-
-#else
-
-static inline int audio_pdr_register(struct notifier_block *nb)
-{
-	return -ENODEV;
-}
-
-
-static inline void *audio_pdr_service_register(int domain_id,
-					       struct notifier_block *nb,
-					       int *curr_state)
-{
-	return NULL;
-}
-
-static inline int audio_pdr_service_deregister(void *service_handle,
-					       struct notifier_block *nb)
-{
-	return 0;
-}
-
-#endif /* CONFIG_MSM_QDSP6_PDR */
-
-#endif
diff --git a/include/linux/qdsp6v2/audio_ssr.h b/include/linux/qdsp6v2/audio_ssr.h
deleted file mode 100644
index a807021..0000000
--- a/include/linux/qdsp6v2/audio_ssr.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __AUDIO_SSR_H_
-#define __AUDIO_SSR_H_
-
-enum {
-	AUDIO_SSR_DOMAIN_ADSP,
-	AUDIO_SSR_DOMAIN_MODEM,
-	AUDIO_SSR_DOMAIN_MAX
-};
-
-#ifdef CONFIG_MSM_QDSP6_SSR
-
-/*
- * Use audio_ssr_register to register with the SSR subsystem
- *
- * domain_id - Service to use, example: AUDIO_SSR_DOMAIN_ADSP
- * *nb - Pointer to a notifier block. Provide a callback function
- *       to be notified of an event for that service. The ioctls
- *       used by the callback are defined in subsystem_notif.h.
- *
- * Returns: Success: Client handle
- *          Failure: Pointer error code
- */
-void *audio_ssr_register(int domain_id, struct notifier_block *nb);
-
-/*
- * Use audio_ssr_deregister to register with the SSR subsystem
- *
- * handle - Handle received from audio_ssr_register
- * *nb - Pointer to a notifier block. Callback function
- *       Used from audio_ssr_register.
- *
- * Returns: Success: 0
- *          Failure: Error code
- */
-int audio_ssr_deregister(void *handle, struct notifier_block *nb);
-
-
-/*
- * Use audio_ssr_send_nmi to force a RAM dump on ADSP
- * down event.
- *
- * *ssr_cb_data - *data received from notifier callback
- */
-void audio_ssr_send_nmi(void *ssr_cb_data);
-
-#else
-
-static inline void *audio_ssr_register(int domain_id,
-				       struct notifier_block *nb)
-{
-	return NULL;
-}
-
-static inline int audio_ssr_deregister(void *handle, struct notifier_block *nb)
-{
-	return 0;
-}
-
-static inline void audio_ssr_send_nmi(void *ssr_cb_data)
-{
-}
-
-#endif /* CONFIG_MSM_QDSP6_SSR */
-
-#endif
diff --git a/include/linux/qdsp6v2/rtac.h b/include/linux/qdsp6v2/rtac.h
deleted file mode 100644
index eeea0eb..0000000
--- a/include/linux/qdsp6v2/rtac.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Copyright (c) 2011, 2013-2015, 2017, The Linux Foundation. All rights
- * reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __RTAC_H__
-#define __RTAC_H__
-
-#include <sound/apr_audio-v2.h>
-
-/* Voice Modes */
-#define RTAC_CVP		0
-#define RTAC_CVS		1
-#define RTAC_VOICE_MODES	2
-
-#define RTAC_MAX_ACTIVE_DEVICES		4
-#define RTAC_MAX_ACTIVE_POPP		8
-
-#define DEFAULT_APP_TYPE	0x00011130
-
-enum {
-	ADM_RTAC_CAL,
-	ASM_RTAC_CAL,
-	VOICE_RTAC_CAL,
-	AFE_RTAC_CAL,
-	MAX_RTAC_BLOCKS
-};
-
-struct rtac_cal_mem_map_data {
-	uint32_t		map_size;
-	uint32_t		map_handle;
-	struct ion_client	*ion_client;
-	struct ion_handle	*ion_handle;
-};
-
-struct rtac_cal_data {
-	size_t			size;
-	void			*kvaddr;
-	phys_addr_t		paddr;
-};
-
-struct rtac_cal_block_data {
-	struct rtac_cal_mem_map_data	map_data;
-	struct rtac_cal_data		cal_data;
-};
-
-struct rtac_popp_data {
-	uint32_t	popp;
-	uint32_t	popp_topology;
-	uint32_t	app_type;
-};
-
-struct rtac_adm_data {
-	uint32_t		topology_id;
-	uint32_t		afe_topology;
-	uint32_t		afe_port;
-	uint32_t		copp;
-	uint32_t		num_of_popp;
-	uint32_t		app_type;
-	uint32_t		acdb_dev_id;
-	struct rtac_popp_data	popp[RTAC_MAX_ACTIVE_POPP];
-};
-
-struct rtac_adm {
-	uint32_t			num_of_dev;
-	struct rtac_adm_data		device[RTAC_MAX_ACTIVE_DEVICES];
-};
-
-void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id,
-			u32 app_type, u32 acdb_dev_id);
-void rtac_remove_adm_device(u32 port_id, u32 copp_id);
-void rtac_remove_popp_from_adm_devices(u32 popp_id);
-void rtac_add_voice(u32 cvs_handle, u32 cvp_handle, u32 rx_afe_port,
-	u32 tx_afe_port, u32 rx_acdb_id, u32 tx_acdb_id, u32 session_id);
-void rtac_remove_voice(u32 cvs_handle);
-void rtac_set_adm_handle(void *handle);
-bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size);
-void rtac_copy_adm_payload_to_user(void *payload, u32 payload_size);
-void rtac_set_asm_handle(u32 session_id, void *handle);
-bool rtac_make_asm_callback(u32 session_id, uint32_t *payload,
-	u32 payload_size);
-void rtac_copy_asm_payload_to_user(void *payload, u32 payload_size);
-void rtac_set_voice_handle(u32 mode, void *handle);
-bool rtac_make_voice_callback(u32 mode, uint32_t *payload, u32 payload_size);
-void rtac_copy_voice_payload_to_user(void *payload, u32 payload_size);
-int rtac_clear_mapping(uint32_t cal_type);
-bool rtac_make_afe_callback(uint32_t *payload, u32 payload_size);
-void rtac_set_afe_handle(void *handle);
-void get_rtac_adm_data(struct rtac_adm *adm_data);
-void rtac_update_afe_topology(u32 port_id);
-#endif
diff --git a/include/linux/qdsp6v2/usf.h b/include/linux/qdsp6v2/usf.h
deleted file mode 100644
index 544b624..0000000
--- a/include/linux/qdsp6v2/usf.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __USF_H__
-#define __USF_H__
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-
-#define USF_IOCTL_MAGIC 'U'
-
-#define US_SET_TX_INFO   _IOW(USF_IOCTL_MAGIC, 0, \
-				struct us_tx_info_type)
-#define US_START_TX      _IO(USF_IOCTL_MAGIC, 1)
-#define US_GET_TX_UPDATE _IOWR(USF_IOCTL_MAGIC, 2, \
-				struct us_tx_update_info_type)
-#define US_SET_RX_INFO   _IOW(USF_IOCTL_MAGIC, 3, \
-				struct us_rx_info_type)
-#define US_SET_RX_UPDATE _IOWR(USF_IOCTL_MAGIC, 4, \
-				struct us_rx_update_info_type)
-#define US_START_RX      _IO(USF_IOCTL_MAGIC, 5)
-
-#define US_STOP_TX      _IO(USF_IOCTL_MAGIC, 6)
-#define US_STOP_RX      _IO(USF_IOCTL_MAGIC, 7)
-
-#define US_SET_DETECTION _IOWR(USF_IOCTL_MAGIC, 8, \
-				struct us_detect_info_type)
-
-#define US_GET_VERSION  _IOWR(USF_IOCTL_MAGIC, 9, \
-				struct us_version_info_type)
-
-#define US_SET_TX_STREAM_PARAM   _IOW(USF_IOCTL_MAGIC, 10, \
-				struct us_stream_param_type)
-#define US_GET_TX_STREAM_PARAM  _IOWR(USF_IOCTL_MAGIC, 11, \
-				struct us_stream_param_type)
-#define US_SET_RX_STREAM_PARAM   _IOW(USF_IOCTL_MAGIC, 12, \
-				struct us_stream_param_type)
-#define US_GET_RX_STREAM_PARAM  _IOWR(USF_IOCTL_MAGIC, 13, \
-				struct us_stream_param_type)
-
-/* Special timeout values */
-#define USF_NO_WAIT_TIMEOUT	0x00000000
-/* Infinitive */
-#define USF_INFINITIVE_TIMEOUT	0xffffffff
-/* Default value, used by the driver */
-#define USF_DEFAULT_TIMEOUT	0xfffffffe
-
-/* US detection place (HW|FW) */
-enum us_detect_place_enum {
-/* US is detected in HW */
-	US_DETECT_HW,
-/* US is detected in FW */
-	US_DETECT_FW
-};
-
-/* US detection mode */
-enum us_detect_mode_enum {
-/* US detection is disabled */
-	US_DETECT_DISABLED_MODE,
-/* US detection is enabled in continue mode */
-	US_DETECT_CONTINUE_MODE,
-/* US detection is enabled in one shot mode */
-	US_DETECT_SHOT_MODE
-};
-
-/* Encoder (TX), decoder (RX) supported US data formats */
-#define USF_POINT_EPOS_FORMAT	0
-#define USF_RAW_FORMAT		1
-
-/* Indexes of event types, produced by the calculators */
-#define USF_TSC_EVENT_IND      0
-#define USF_TSC_PTR_EVENT_IND  1
-#define USF_MOUSE_EVENT_IND    2
-#define USF_KEYBOARD_EVENT_IND 3
-#define USF_TSC_EXT_EVENT_IND  4
-#define USF_MAX_EVENT_IND      5
-
-/* Types of events, produced by the calculators */
-#define USF_NO_EVENT 0
-#define USF_TSC_EVENT      (1 << USF_TSC_EVENT_IND)
-#define USF_TSC_PTR_EVENT  (1 << USF_TSC_PTR_EVENT_IND)
-#define USF_MOUSE_EVENT    (1 << USF_MOUSE_EVENT_IND)
-#define USF_KEYBOARD_EVENT (1 << USF_KEYBOARD_EVENT_IND)
-#define USF_TSC_EXT_EVENT  (1 << USF_TSC_EXT_EVENT_IND)
-#define USF_ALL_EVENTS         (USF_TSC_EVENT |\
-				USF_TSC_PTR_EVENT |\
-				USF_MOUSE_EVENT |\
-				USF_KEYBOARD_EVENT |\
-				USF_TSC_EXT_EVENT)
-
-/* min, max array dimension */
-#define MIN_MAX_DIM 2
-
-/* coordinates (x,y,z) array dimension */
-#define COORDINATES_DIM 3
-
-/* tilts (x,y) array dimension */
-#define TILTS_DIM 2
-
-/* Max size of the client name */
-#define USF_MAX_CLIENT_NAME_SIZE	20
-
-/* Max number of the ports (mics/speakers) */
-#define USF_MAX_PORT_NUM                8
-
-/* Info structure common for TX and RX */
-struct us_xx_info_type {
-/* Input:  general info */
-/* Name of the client - event calculator */
-	const char __user *client_name;
-/* Selected device identification, accepted in the kernel's CAD */
-	uint32_t dev_id;
-/* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
-	uint32_t stream_format;
-/* Required sample rate in Hz */
-	uint32_t sample_rate;
-/* Size of a buffer (bytes) for US data transfer between the module and USF */
-	uint32_t buf_size;
-/* Number of the buffers for the US data transfer */
-	uint16_t buf_num;
-/* Number of the microphones (TX) or speakers(RX) */
-	uint16_t port_cnt;
-/* Microphones(TX) or speakers(RX) indexes in their enumeration */
-	uint8_t  port_id[USF_MAX_PORT_NUM];
-/* Bits per sample 16 or 32 */
-	uint16_t bits_per_sample;
-/* Input:  Transparent info for encoder in the LPASS */
-/* Parameters data size in bytes */
-	uint16_t params_data_size;
-/* Pointer to the parameters */
-	uint8_t __user *params_data;
-/* Max size of buffer for get and set parameter */
-	uint32_t max_get_set_param_buf_size;
-};
-
-struct us_input_info_type {
-	/* Touch screen dimensions: min & max;for input module */
-	int tsc_x_dim[MIN_MAX_DIM];
-	int tsc_y_dim[MIN_MAX_DIM];
-	int tsc_z_dim[MIN_MAX_DIM];
-	/* Touch screen tilt dimensions: min & max;for input module */
-	int tsc_x_tilt[MIN_MAX_DIM];
-	int tsc_y_tilt[MIN_MAX_DIM];
-	/* Touch screen pressure limits: min & max; for input module */
-	int tsc_pressure[MIN_MAX_DIM];
-	/* The requested buttons bitmap */
-	uint16_t req_buttons_bitmap;
-	/* Bitmap of types of events (USF_X_EVENT), produced by calculator */
-	uint16_t event_types;
-	/* Bitmap of types of events from devs, conflicting with USF */
-	uint16_t conflicting_event_types;
-};
-
-struct us_tx_info_type {
-	/* Common info */
-	struct us_xx_info_type us_xx_info;
-	/* Info specific for TX*/
-	struct us_input_info_type input_info;
-};
-
-struct us_rx_info_type {
-	/* Common info */
-	struct us_xx_info_type us_xx_info;
-	/* Info specific for RX*/
-};
-
-struct point_event_type {
-/* Pen coordinates (x, y, z) in units, defined by <coordinates_type>  */
-	int coordinates[COORDINATES_DIM];
-	/* {x;y}  in transparent units */
-	int inclinations[TILTS_DIM];
-/* [0-1023] (10bits); 0 - pen up */
-	uint32_t pressure;
-/* Bitmap for button state. 1 - down, 0 - up */
-	uint16_t buttons_state_bitmap;
-};
-
-/* Mouse buttons, supported by USF */
-#define USF_BUTTON_LEFT_MASK   1
-#define USF_BUTTON_MIDDLE_MASK 2
-#define USF_BUTTON_RIGHT_MASK  4
-struct mouse_event_type {
-/* The mouse relative movement (dX, dY, dZ) */
-	int rels[COORDINATES_DIM];
-/* Bitmap of mouse buttons states: 1 - down, 0 - up; */
-	uint16_t buttons_states;
-};
-
-struct key_event_type {
-/*  Calculated MS key- see input.h. */
-	uint32_t key;
-/* Keyboard's key state: 1 - down, 0 - up; */
-	uint8_t key_state;
-};
-
-struct usf_event_type {
-/* Event sequence number */
-	uint32_t seq_num;
-/* Event generation system time */
-	uint32_t timestamp;
-/* Destination input event type index (e.g. touch screen, mouse, key) */
-	uint16_t event_type_ind;
-	union {
-		struct point_event_type point_event;
-		struct mouse_event_type mouse_event;
-		struct key_event_type   key_event;
-	} event_data;
-};
-
-struct us_tx_update_info_type {
-/* Input  general: */
-/* Number of calculated events */
-	uint16_t event_counter;
-/* Calculated events or NULL */
-	struct usf_event_type __user *event;
-/* Pointer (read index) to the end of available region */
-/* in the shared US data memory */
-	uint32_t free_region;
-/* Time (sec) to wait for data or special values: */
-/* USF_NO_WAIT_TIMEOUT, USF_INFINITIVE_TIMEOUT, USF_DEFAULT_TIMEOUT */
-	uint32_t timeout;
-/* Events (from conflicting devs) to be disabled/enabled */
-	uint16_t event_filters;
-
-/* Input  transparent data: */
-/* Parameters size */
-	uint16_t params_data_size;
-/* Pointer to the parameters */
-	uint8_t __user *params_data;
-/* Output parameters: */
-/* Pointer (write index) to the end of ready US data region */
-/* in the shared memory */
-	uint32_t ready_region;
-};
-
-struct us_rx_update_info_type {
-/* Input  general: */
-/* Pointer (write index) to the end of ready US data region */
-/* in the shared memory */
-	uint32_t ready_region;
-/* Input  transparent data: */
-/* Parameters size */
-	uint16_t params_data_size;
-/* pPointer to the parameters */
-	uint8_t __user *params_data;
-/* Output parameters: */
-/* Pointer (read index) to the end of available region */
-/* in the shared US data memory */
-	uint32_t free_region;
-};
-
-struct us_detect_info_type {
-/* US detection place (HW|FW) */
-/* NA in the Active and OFF states */
-	enum us_detect_place_enum us_detector;
-/* US detection mode */
-	enum us_detect_mode_enum  us_detect_mode;
-/* US data dropped during this time (msec) */
-	uint32_t skip_time;
-/* Transparent data size */
-	uint16_t params_data_size;
-/* Pointer to the transparent data */
-	uint8_t __user *params_data;
-/* Time (sec) to wait for US presence event */
-	uint32_t detect_timeout;
-/* Out parameter: US presence */
-	bool is_us;
-};
-
-struct us_version_info_type {
-/* Size of memory for the version string */
-	uint16_t buf_size;
-/* Pointer to the memory for the version string */
-	char __user *pbuf;
-};
-
-struct us_stream_param_type {
-/* Id of module */
-	uint32_t module_id;
-/* Id of parameter */
-	uint32_t param_id;
-/* Size of memory of the parameter buffer */
-	uint32_t buf_size;
-/* Pointer to the memory of the parameter buffer */
-	uint8_t __user *pbuf;
-};
-
-#endif /* __USF_H__ */
diff --git a/include/linux/qpnp/qpnp-revid.h b/include/linux/qpnp/qpnp-revid.h
index 7fca674..42fd34c 100644
--- a/include/linux/qpnp/qpnp-revid.h
+++ b/include/linux/qpnp/qpnp-revid.h
@@ -247,6 +247,7 @@
 	u8		pmic_subtype;
 	const char	*pmic_name;
 	int		fab_id;
+	int		tp_rev;
 };
 
 #ifdef CONFIG_QPNP_REVID
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0737cb6..67860f3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -928,6 +928,16 @@
 
 #define SIGNAL_UNKILLABLE	0x00000040 /* for init: ignore fatal signals */
 
+#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
+			  SIGNAL_STOP_CONTINUED)
+
+static inline void signal_set_stop_flags(struct signal_struct *sig,
+					 unsigned int flags)
+{
+	WARN_ON(sig->flags & (SIGNAL_GROUP_EXIT|SIGNAL_GROUP_COREDUMP));
+	sig->flags = (sig->flags & ~SIGNAL_STOP_MASK) | flags;
+}
+
 /* If true, all threads except ->group_exit_task have pending SIGKILL */
 static inline int signal_group_exit(const struct signal_struct *sig)
 {
@@ -1197,6 +1207,37 @@
 
 struct sched_group;
 
+struct eas_stats {
+	/* select_idle_sibling() stats */
+	u64 sis_attempts;
+	u64 sis_idle;
+	u64 sis_cache_affine;
+	u64 sis_suff_cap;
+	u64 sis_idle_cpu;
+	u64 sis_count;
+
+	/* select_energy_cpu_brute() stats */
+	u64 secb_attempts;
+	u64 secb_sync;
+	u64 secb_idle_bt;
+	u64 secb_insuff_cap;
+	u64 secb_no_nrg_sav;
+	u64 secb_nrg_sav;
+	u64 secb_count;
+
+	/* find_best_target() stats */
+	u64 fbt_attempts;
+	u64 fbt_no_cpu;
+	u64 fbt_no_sd;
+	u64 fbt_pref_idle;
+	u64 fbt_count;
+
+	/* cas */
+	/* select_task_rq_fair() stats */
+	u64 cas_attempts;
+	u64 cas_count;
+};
+
 struct sched_domain_shared {
 	atomic_t	ref;
 	atomic_t	nr_busy_cpus;
@@ -1265,6 +1306,8 @@
 	unsigned int ttwu_wake_remote;
 	unsigned int ttwu_move_affine;
 	unsigned int ttwu_move_balance;
+
+	struct eas_stats eas_stats;
 #endif
 #ifdef CONFIG_SCHED_DEBUG
 	char *name;
@@ -1463,6 +1506,35 @@
 	u64			nr_wakeups_affine_attempts;
 	u64			nr_wakeups_passive;
 	u64			nr_wakeups_idle;
+
+	/* select_idle_sibling() */
+	u64			nr_wakeups_sis_attempts;
+	u64			nr_wakeups_sis_idle;
+	u64			nr_wakeups_sis_cache_affine;
+	u64			nr_wakeups_sis_suff_cap;
+	u64			nr_wakeups_sis_idle_cpu;
+	u64			nr_wakeups_sis_count;
+
+	/* energy_aware_wake_cpu() */
+	u64			nr_wakeups_secb_attempts;
+	u64			nr_wakeups_secb_sync;
+	u64			nr_wakeups_secb_idle_bt;
+	u64			nr_wakeups_secb_insuff_cap;
+	u64			nr_wakeups_secb_no_nrg_sav;
+	u64			nr_wakeups_secb_nrg_sav;
+	u64			nr_wakeups_secb_count;
+
+	/* find_best_target() */
+	u64			nr_wakeups_fbt_attempts;
+	u64			nr_wakeups_fbt_no_cpu;
+	u64			nr_wakeups_fbt_no_sd;
+	u64			nr_wakeups_fbt_pref_idle;
+	u64			nr_wakeups_fbt_count;
+
+	/* cas */
+	/* select_task_rq_fair() */
+	u64			nr_wakeups_cas_attempts;
+	u64			nr_wakeups_cas_count;
 };
 #endif
 
@@ -2318,23 +2390,6 @@
 }
 
 static inline int pid_alive(const struct task_struct *p);
-static inline pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
-static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
-{
-	pid_t pid = 0;
-
-	rcu_read_lock();
-	if (pid_alive(tsk))
-		pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
-	rcu_read_unlock();
-
-	return pid;
-}
-
-static inline pid_t task_ppid_nr(const struct task_struct *tsk)
-{
-	return task_ppid_nr_ns(tsk, &init_pid_ns);
-}
 
 static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
 					struct pid_namespace *ns)
@@ -2369,6 +2424,23 @@
 	return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, NULL);
 }
 
+static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
+{
+	pid_t pid = 0;
+
+	rcu_read_lock();
+	if (pid_alive(tsk))
+		pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
+	rcu_read_unlock();
+
+	return pid;
+}
+
+static inline pid_t task_ppid_nr(const struct task_struct *tsk)
+{
+	return task_ppid_nr_ns(tsk, &init_pid_ns);
+}
+
 /* obsolete, do not use */
 static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 {
@@ -3888,6 +3960,7 @@
 #define SCHED_CPUFREQ_INTERCLUSTER_MIG (1U << 3)
 #define SCHED_CPUFREQ_WALT (1U << 4)
 #define SCHED_CPUFREQ_PL	(1U << 5)
+#define SCHED_CPUFREQ_EARLY_DET	(1U << 6)
 
 #define SCHED_CPUFREQ_RT_DL	(SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL)
 
@@ -3902,4 +3975,6 @@
 void cpufreq_remove_update_util_hook(int cpu);
 #endif /* CONFIG_CPU_FREQ */
 
+extern DEFINE_PER_CPU_READ_MOSTLY(int, sched_load_boost);
+
 #endif
diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h
index f4dfade..be8b902 100644
--- a/include/linux/skb_array.h
+++ b/include/linux/skb_array.h
@@ -162,7 +162,8 @@
 }
 
 static inline int skb_array_resize_multiple(struct skb_array **rings,
-					    int nrings, int size, gfp_t gfp)
+					    int nrings, unsigned int size,
+					    gfp_t gfp)
 {
 	BUILD_BUG_ON(offsetof(struct skb_array, ring));
 	return ptr_ring_resize_multiple((struct ptr_ring **)rings,
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 084b12b..4c53635 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -226,7 +226,7 @@
  * (PAGE_SIZE*2).  Larger requests are passed to the page allocator.
  */
 #define KMALLOC_SHIFT_HIGH	(PAGE_SHIFT + 1)
-#define KMALLOC_SHIFT_MAX	(MAX_ORDER + PAGE_SHIFT)
+#define KMALLOC_SHIFT_MAX	(MAX_ORDER + PAGE_SHIFT - 1)
 #ifndef KMALLOC_SHIFT_LOW
 #define KMALLOC_SHIFT_LOW	3
 #endif
@@ -239,7 +239,7 @@
  * be allocated from the same page.
  */
 #define KMALLOC_SHIFT_HIGH	PAGE_SHIFT
-#define KMALLOC_SHIFT_MAX	30
+#define KMALLOC_SHIFT_MAX	(MAX_ORDER + PAGE_SHIFT - 1)
 #ifndef KMALLOC_SHIFT_LOW
 #define KMALLOC_SHIFT_LOW	3
 #endif
diff --git a/include/linux/soundwire/soundwire.h b/include/linux/soundwire/soundwire.h
deleted file mode 100644
index a60d78c..0000000
--- a/include/linux/soundwire/soundwire.h
+++ /dev/null
@@ -1,312 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _LINUX_SOUNDWIRE_H
-#define _LINUX_SOUNDWIRE_H
-#include <linux/device.h>
-#include <linux/mutex.h>
-#include <linux/mod_devicetable.h>
-
-extern struct bus_type soundwire_type;
-
-/* Soundwire supports max. of 8 channels per port */
-#define SWR_MAX_CHANNEL_NUM	8
-/* Soundwire supports max. of 14 ports on each device */
-#define SWR_MAX_DEV_PORT_NUM	14
-/* Maximum number of slave devices that a master can control */
-#define SWR_MAX_DEV_NUM		11
-/* Maximum number of ports on master so that it can accommodate all the port
- * configurations of all devices
- */
-#define SWR_MAX_MSTR_PORT_NUM	(SWR_MAX_DEV_NUM * SWR_MAX_DEV_PORT_NUM)
-
-/* Indicates soundwire devices group information */
-enum {
-	SWR_GROUP_NONE = 0,
-	SWR_GROUP_12 = 12,
-	SWR_GROUP_13 = 13,
-	SWR_BROADCAST = 15,
-};
-
-/*
- * struct swr_port_info - represent soundwire frame shape
- * @dev_id: logical device number of the soundwire slave device
- * @port_en: flag indicates whether the port is enabled
- * @port_id: logical port number of the soundwire slave device
- * @offset1: sample offset indicating the offset of the channel
- * from the start of the frame
- * @offset2: channel offset indicating offset between to channels
- * @sinterval: sample interval indicates spacing from one sample
- * event to the next
- * @ch_en: channels in a port that need to be enabled
- * @num_ch: number of channels enabled in a port
- * @ch_rate: sampling rate of the channel with which data will be
- * transferred
- *
- * Soundwire frame shape is created based on swr_port_info struct
- * parameters.
- */
-struct swr_port_info {
-	u8 dev_id;
-	u8 port_en;
-	u8 port_id;
-	u8 offset1;
-	u8 offset2;
-	u8 sinterval;
-	u8 ch_en;
-	u8 num_ch;
-	u32 ch_rate;
-};
-
-/*
- * struct swr_params - represent transfer of data from soundwire slave
- * to soundwire master
- * @tid: transaction ID to track each transaction
- * @dev_id: logical device number of the soundwire slave device
- * @num_port: number of ports that needs to be configured
- * @port_id: array of logical port numbers of the soundwire slave device
- * @num_ch: array of number of channels enabled
- * @ch_rate: array of sampling rate of different channels that need to
- * be configured
- * @ch_en: array of channels mask for all the ports
- */
-struct swr_params {
-	u8 tid;
-	u8 dev_id;
-	u8 num_port;
-	u8 port_id[SWR_MAX_DEV_PORT_NUM];
-	u8 num_ch[SWR_MAX_DEV_PORT_NUM];
-	u32 ch_rate[SWR_MAX_DEV_PORT_NUM];
-	u8 ch_en[SWR_MAX_DEV_PORT_NUM];
-};
-
-/*
- * struct swr_reg - struct to handle soundwire slave register read/writes
- * @tid: transaction id for reg read/writes
- * @dev_id: logical device number of the soundwire slave device
- * @regaddr: 16 bit regaddr of soundwire slave
- * @buf: value to be written/read to/from regaddr
- * @len: length of the buffer buf
- */
-struct swr_reg {
-	u8  tid;
-	u8  dev_id;
-	u32 regaddr;
-	u32 *buf;
-	u32 len;
-};
-
-/*
- * struct swr_master - Interface to the soundwire master controller
- * @dev: device interface to this driver
- * @list: link with other soundwire master controllers
- * @bus_num: board/SoC specific identifier for a soundwire master
- * @mlock: mutex protecting master data structures
- * @devices: list of devices on this master
- * @port: logical port numbers of the soundwire master. This array
- * can hold maximum master ports which is equal to number of slave
- * devices multiplied by number of ports in each slave device
- * @port_txn: table of port config transactions with transaction id
- * @reg_txn: table of register transactions with transaction id
- * @last_tid: size of table port_txn (can't grow beyond 256 since
- * tid is 8 bits)
- * @num_port: number of active ports on soundwire master
- * @gr_sid: slave id used by the group for write operations
- * @connect_port: callback for configuration of soundwire port(s)
- * @disconnect_port: callback for disable of soundwire port(s)
- * @read: callback for soundwire slave register read
- * @write: callback for soundwire slave register write
- * @get_logical_dev_num: callback to get soundwire slave logical
- * device number
- */
-struct swr_master {
-	struct device dev;
-	struct list_head list;
-	unsigned int bus_num;
-	struct mutex mlock;
-	struct list_head devices;
-	struct swr_port_info port[SWR_MAX_MSTR_PORT_NUM];
-	struct swr_params **port_txn;
-	struct swr_reg **reg_txn;
-	u8 last_tid;
-	u8 num_port;
-	u8 num_dev;
-	u8 gr_sid;
-	int (*connect_port)(struct swr_master *mstr, struct swr_params *txn);
-	int (*disconnect_port)(struct swr_master *mstr, struct swr_params *txn);
-	int (*read)(struct swr_master *mstr, u8 dev_num, u16 reg_addr,
-			void *buf, u32 len);
-	int (*write)(struct swr_master *mstr, u8 dev_num, u16 reg_addr,
-			const void *buf);
-	int (*bulk_write)(struct swr_master *master, u8 dev_num, void *reg,
-			  const void *buf, size_t len);
-	int (*get_logical_dev_num)(struct swr_master *mstr, u64 dev_id,
-				u8 *dev_num);
-	void (*slvdev_datapath_control)(struct swr_master *mstr, bool enable);
-	bool (*remove_from_group)(struct swr_master *mstr);
-};
-
-static inline struct swr_master *to_swr_master(struct device *dev)
-{
-	return dev ? container_of(dev, struct swr_master, dev) : NULL;
-}
-
-/*
- * struct swr_device - represent a soundwire slave device
- * @name: indicates the name of the device, defined in devicetree
- * binding under soundwire slave device node as a compatible field.
- * @master: soundwire master managing the bus hosting this device
- * @driver: Device's driver. Pointer to access routines
- * @dev_list: list of devices on a controller
- * @dev_num: logical device number of the soundwire slave device
- * @dev: driver model representation of the device
- * @addr: represents "ea-addr" which is unique-id of soundwire slave
- * device
- * @group_id: group id supported by the slave device
- */
-struct swr_device {
-	char name[SOUNDWIRE_NAME_SIZE];
-	struct swr_master *master;
-	struct swr_driver *driver;
-	struct list_head dev_list;
-	u8               dev_num;
-	struct device    dev;
-	unsigned long    addr;
-	u8 group_id;
-};
-
-static inline struct swr_device *to_swr_device(struct device *dev)
-{
-	return dev ? container_of(dev, struct swr_device, dev) : NULL;
-}
-
-/*
- * struct swr_driver - Manage soundwire slave device driver
- * @probe: binds this driver to soundwire device
- * @remove: unbinds this driver from soundwire device
- * @shutdown: standard shutdown callback used during power down/halt
- * @suspend: standard suspend callback used during system suspend
- * @resume: standard resume callback used during system resume
- * @driver: soundwire device drivers should initialize name and
- * owner field of this structure
- * @id_table: list of soundwire devices supported by this driver
- */
-struct swr_driver {
-	int	(*probe)(struct swr_device *swr);
-	int	(*remove)(struct swr_device *swr);
-	void	(*shutdown)(struct swr_device *swr);
-	int	(*suspend)(struct swr_device *swr, pm_message_t pmesg);
-	int	(*resume)(struct swr_device *swr);
-	int	(*device_up)(struct swr_device *swr);
-	int	(*device_down)(struct swr_device *swr);
-	int	(*reset_device)(struct swr_device *swr);
-	struct device_driver		driver;
-	const struct swr_device_id	*id_table;
-};
-
-static inline struct swr_driver *to_swr_driver(struct device_driver *drv)
-{
-	return drv ? container_of(drv, struct swr_driver, driver) : NULL;
-}
-
-/*
- * struct swr_boardinfo - Declare board info for soundwire device bringup
- * @name: name to initialize swr_device.name
- * @bus_num: identifies which soundwire master parents the soundwire
- * slave_device
- * @addr: represents "ea-addr" of soundwire slave device
- * @of_node: pointer to OpenFirmware device node
- * @swr_slave: device to be registered with soundwire
- */
-struct swr_boardinfo {
-	char               name[SOUNDWIRE_NAME_SIZE];
-	int                bus_num;
-	u64		   addr;
-	struct device_node *of_node;
-	struct swr_device  *swr_slave;
-};
-
-static inline void *swr_get_ctrl_data(const struct swr_master *master)
-{
-	return master ? dev_get_drvdata(&master->dev) : NULL;
-}
-
-static inline void swr_set_ctrl_data(struct swr_master *master, void *data)
-{
-	dev_set_drvdata(&master->dev, data);
-}
-
-static inline void *swr_get_dev_data(const struct swr_device *dev)
-{
-	return dev ? dev_get_drvdata(&dev->dev) : NULL;
-}
-
-static inline void swr_set_dev_data(struct swr_device *dev, void *data)
-{
-	dev_set_drvdata(&dev->dev, data);
-}
-
-extern int swr_startup_devices(struct swr_device *swr_dev);
-
-extern struct swr_device *swr_new_device(struct swr_master *master,
-				struct swr_boardinfo const *info);
-
-extern int of_register_swr_devices(struct swr_master *master);
-
-extern void swr_port_response(struct swr_master *mstr, u8 tid);
-
-extern int swr_get_logical_dev_num(struct swr_device *dev, u64 dev_id,
-			u8 *dev_num);
-
-extern int swr_read(struct swr_device *dev, u8 dev_num, u16 reg_addr,
-			void *buf, u32 len);
-
-extern int swr_write(struct swr_device *dev, u8 dev_num, u16 reg_addr,
-			const void *buf);
-
-extern int swr_bulk_write(struct swr_device *dev, u8 dev_num, void *reg_addr,
-			  const void *buf, size_t len);
-
-extern int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
-				u8 *ch_mask, u32 *ch_rate, u8 *num_ch);
-
-extern int swr_disconnect_port(struct swr_device *dev,
-				u8 *port_id, u8 num_port);
-
-extern int swr_set_device_group(struct swr_device *swr_dev, u8 id);
-
-extern int swr_driver_register(struct swr_driver *drv);
-
-extern void swr_driver_unregister(struct swr_driver *drv);
-
-extern int swr_add_device(struct swr_master *master,
-				struct swr_device *swrdev);
-extern void swr_remove_device(struct swr_device *swr);
-
-extern void swr_master_add_boarddevices(struct swr_master *master);
-
-extern void swr_unregister_master(struct swr_master *master);
-
-extern int swr_register_master(struct swr_master *master);
-
-extern int swr_device_up(struct swr_device *swr_dev);
-
-extern int swr_device_down(struct swr_device *swr_dev);
-
-extern int swr_reset_device(struct swr_device *swr_dev);
-
-extern int swr_slvdev_datapath_control(struct swr_device *swr_dev, u8 dev_num,
-				       bool enable);
-extern int swr_remove_from_group(struct swr_device *dev, u8 dev_num);
-
-extern void swr_remove_device(struct swr_device *swr_dev);
-#endif /* _LINUX_SOUNDWIRE_H */
diff --git a/include/linux/soundwire/swr-wcd.h b/include/linux/soundwire/swr-wcd.h
deleted file mode 100644
index 041b901..0000000
--- a/include/linux/soundwire/swr-wcd.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _LINUX_SWR_WCD_H
-#define _LINUX_SWR_WCD_H
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/bitops.h>
-
-enum {
-	SWR_CH_MAP,
-	SWR_DEVICE_DOWN,
-	SWR_DEVICE_UP,
-	SWR_SUBSYS_RESTART,
-	SWR_SET_NUM_RX_CH,
-};
-
-struct swr_mstr_port {
-	int num_port;
-	u8 *port;
-};
-
-extern int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data);
-
-#endif /* _LINUX_SWR_WCD_H */
diff --git a/include/linux/spi/qcom-spi.h b/include/linux/spi/qcom-spi.h
new file mode 100644
index 0000000..5984810
--- /dev/null
+++ b/include/linux/spi/qcom-spi.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ *
+ */
+/*
+ * SPI driver for Qualcomm MSM platforms.
+ */
+
+/**
+ * msm_spi_platform_data: msm spi-controller's configuration data
+ *
+ * @max_clock_speed max spi clock speed
+ * @active_only when set, votes when system active and removes the vote when
+ *       system goes idle (optimises for performance). When unset, voting using
+ *       runtime pm (optimizes for power).
+ * @master_id master id number of the controller's wrapper (BLSP or GSBI).
+ *       When zero, clock path voting is disabled.
+ * @gpio_config pointer to function for configuring gpio
+ * @gpio_release pointer to function for releasing gpio pins
+ * @dma_config function poniter for configuring dma engine
+ * @pm_lat power management latency
+ * @infinite_mode use FIFO mode in infinite mode
+ * @ver_reg_exists if the version register exists
+ * @use_beam true if BAM is available
+ * @bam_consumer_pipe_index BAM conusmer pipe
+ * @bam_producer_pipe_index BAM producer pipe
+ * @rt_priority true if RT thread
+ * @use_pinctrl true if pinctrl library is used
+ * @is_shared true when qup is shared between ee's
+ */
+struct msm_spi_platform_data {
+	u32 max_clock_speed;
+	u32  master_id;
+	u32 bus_width;
+	int (*gpio_config)(void);
+	void (*gpio_release)(void);
+	int (*dma_config)(void);
+	const char *rsl_id;
+	u32  pm_lat;
+	u32  infinite_mode;
+	bool ver_reg_exists;
+	bool use_bam;
+	u32  bam_consumer_pipe_index;
+	u32  bam_producer_pipe_index;
+	bool rt_priority;
+	bool use_pinctrl;
+	bool is_shared;
+};
diff --git a/sound/soc/codecs/audio-ext-clk-up.h b/include/linux/spi/spi-geni-qcom.h
similarity index 63%
copy from sound/soc/codecs/audio-ext-clk-up.h
copy to include/linux/spi/spi-geni-qcom.h
index 8a0232e..8aee88a 100644
--- a/sound/soc/codecs/audio-ext-clk-up.h
+++ b/include/linux/spi/spi-geni-qcom.h
@@ -7,14 +7,17 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
+ *
  */
 
-#ifndef __AUDIO_EXT_CLK_UP_H_
-#define __AUDIO_EXT_CLK_UP_H_
+#ifndef __SPI_GENI_QCOM_HEADER___
+#define __SPI_GENI_QCOM_HEADER___
 
-int audio_ref_clk_platform_init(void);
-void audio_ref_clk_platform_exit(void);
+struct spi_geni_qcom_ctrl_data {
+	u32 spi_cs_clk_delay;
+	u32 spi_inter_words_delay;
+};
 
-#endif
+#endif /*__SPI_GENI_QCOM_HEADER___*/
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 0a34489..17a33f3 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -23,6 +23,8 @@
 extern int snprint_stack_trace(char *buf, size_t size,
 			struct stack_trace *trace, int spaces);
 
+#define BACKPORTED_EXPORT_SAVE_STACK_TRACE_TSK_ARM
+
 #ifdef CONFIG_USER_STACKTRACE_SUPPORT
 extern void save_stack_trace_user(struct stack_trace *trace);
 #else
diff --git a/include/linux/string.h b/include/linux/string.h
index 4e510df..0463dfb 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -178,17 +178,6 @@
 void __write_overflow(void) __compiletime_error("detected write beyond size of object passed as 1st parameter");
 
 #if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
-__FORTIFY_INLINE char *strcpy(char *p, const char *q)
-{
-	size_t p_size = __builtin_object_size(p, 0);
-	size_t q_size = __builtin_object_size(q, 0);
-	if (p_size == (size_t)-1 && q_size == (size_t)-1)
-		return __builtin_strcpy(p, q);
-	if (strscpy(p, q, p_size < q_size ? p_size : q_size) < 0)
-		fortify_panic(__func__);
-	return p;
-}
-
 __FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size)
 {
 	size_t p_size = __builtin_object_size(p, 0);
@@ -367,6 +356,18 @@
 		fortify_panic(__func__);
 	return __real_kmemdup(p, size, gfp);
 }
+
+/* defined after fortified strlen and memcpy to reuse them */
+__FORTIFY_INLINE char *strcpy(char *p, const char *q)
+{
+	size_t p_size = __builtin_object_size(p, 0);
+	size_t q_size = __builtin_object_size(q, 0);
+	if (p_size == (size_t)-1 && q_size == (size_t)-1)
+		return __builtin_strcpy(p, q);
+	memcpy(p, q, strlen(q) + 1);
+	return p;
+}
+
 #endif
 
 #endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index aa17ccf..c97fac8 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -43,9 +43,10 @@
 
 	struct fence		*fence;
 	struct fence_cb cb;
+	unsigned long flags;
 };
 
-#define POLL_ENABLED FENCE_FLAG_USER_BITS
+#define POLL_ENABLED 0
 
 struct sync_file *sync_file_create(struct fence *fence);
 struct fence *sync_file_get_fence(int fd);
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 6e49b86..a700e5f 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -47,11 +47,17 @@
 #define THERMAL_WEIGHT_DEFAULT 0
 
 /* Max sensors that can be used for a single virtual thermalzone */
-#define THERMAL_MAX_VIRT_SENSORS 5
+#define THERMAL_MAX_VIRT_SENSORS 8
 
 /* use value, which < 0K, to indicate an invalid/uninitialized temperature */
 #define THERMAL_TEMP_INVALID	-274000
 
+/*
+ * use a high value for low temp tracking zone,
+ * to indicate an invalid/uninitialized temperature
+ */
+#define THERMAL_TEMP_INVALID_LOW 274000
+
 /* Unit conversion macros */
 #define DECI_KELVIN_TO_CELSIUS(t)	({			\
 	long _t = (t);						\
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 513cd4fd..fc72465 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -119,6 +119,7 @@
 extern void tick_nohz_idle_exit(void);
 extern void tick_nohz_irq_exit(void);
 extern ktime_t tick_nohz_get_sleep_length(void);
+extern unsigned long tick_nohz_get_idle_calls(void);
 extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
 extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time);
 #else /* !CONFIG_NO_HZ_COMMON */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 0f9fff3..232c3e0 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -751,11 +751,11 @@
 extern int usb_sec_event_ring_cleanup(struct usb_device *dev,
 	unsigned int intr_num);
 
-extern dma_addr_t usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
-	unsigned int intr_num);
-extern dma_addr_t usb_get_dcba_dma_addr(struct usb_device *dev);
-extern dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
-	struct usb_host_endpoint *ep);
+extern phys_addr_t usb_get_sec_event_ring_phys_addr(
+	struct usb_device *dev, unsigned int intr_num, dma_addr_t *dma);
+extern phys_addr_t usb_get_xfer_ring_phys_addr(struct usb_device *dev,
+	struct usb_host_endpoint *ep, dma_addr_t *dma);
+extern int usb_get_controller_id(struct usb_device *dev);
 
 /* Sets up a group of bulk endpoints to support multiple stream IDs. */
 extern int usb_alloc_streams(struct usb_interface *interface,
@@ -1725,6 +1725,8 @@
 extern int usb_clear_halt(struct usb_device *dev, int pipe);
 extern int usb_reset_configuration(struct usb_device *dev);
 extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
+extern int usb_set_interface_timeout(struct usb_device *dev, int ifnum,
+		int alternate, unsigned long timeout);
 extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
 
 /* this request isn't really synchronous, but it belongs with the others */
diff --git a/include/linux/usb/ccid_desc.h b/include/linux/usb/ccid_desc.h
index 9a0c726..2e6dbb5 100644
--- a/include/linux/usb/ccid_desc.h
+++ b/include/linux/usb/ccid_desc.h
@@ -86,27 +86,27 @@
  * Table 5.1-1 Smart Card Device Class descriptors
  */
 struct usb_ccid_class_descriptor {
-	unsigned char  bLength;
-	unsigned char  bDescriptorType;
-	unsigned short bcdCCID;
-	unsigned char  bMaxSlotIndex;
-	unsigned char  bVoltageSupport;
-	unsigned long  dwProtocols;
-	unsigned long  dwDefaultClock;
-	unsigned long  dwMaximumClock;
-	unsigned char  bNumClockSupported;
-	unsigned long  dwDataRate;
-	unsigned long  dwMaxDataRate;
-	unsigned char  bNumDataRatesSupported;
-	unsigned long  dwMaxIFSD;
-	unsigned long  dwSynchProtocols;
-	unsigned long  dwMechanical;
-	unsigned long  dwFeatures;
-	unsigned long  dwMaxCCIDMessageLength;
-	unsigned char  bClassGetResponse;
-	unsigned char  bClassEnvelope;
-	unsigned short wLcdLayout;
-	unsigned char  bPINSupport;
-	unsigned char  bMaxCCIDBusySlots;
+	__u8  bLength;
+	__u8  bDescriptorType;
+	__u16 bcdCCID;
+	__u8  bMaxSlotIndex;
+	__u8  bVoltageSupport;
+	__u32  dwProtocols;
+	__u32  dwDefaultClock;
+	__u32  dwMaximumClock;
+	__u8  bNumClockSupported;
+	__u32  dwDataRate;
+	__u32  dwMaxDataRate;
+	__u8  bNumDataRatesSupported;
+	__u32  dwMaxIFSD;
+	__u32  dwSynchProtocols;
+	__u32  dwMechanical;
+	__u32  dwFeatures;
+	__u32  dwMaxCCIDMessageLength;
+	__u8  bClassGetResponse;
+	__u8  bClassEnvelope;
+	__u16 wLcdLayout;
+	__u8  bPINSupport;
+	__u8  bMaxCCIDBusySlots;
 } __packed;
 #endif
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index b305b0e..1699d2b 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -401,12 +401,12 @@
 	int (*sec_event_ring_setup)(struct usb_hcd *hcd, unsigned int intr_num);
 	int (*sec_event_ring_cleanup)(struct usb_hcd *hcd,
 			unsigned int intr_num);
-	dma_addr_t (*get_sec_event_ring_dma_addr)(struct usb_hcd *hcd,
-			unsigned int intr_num);
-	dma_addr_t (*get_xfer_ring_dma_addr)(struct usb_hcd *hcd,
-			struct usb_device *udev, struct usb_host_endpoint *ep);
-	dma_addr_t (*get_dcba_dma_addr)(struct usb_hcd *hcd,
-			struct usb_device *udev);
+	phys_addr_t (*get_sec_event_ring_phys_addr)(struct usb_hcd *hcd,
+			unsigned int intr_num, dma_addr_t *dma);
+	phys_addr_t (*get_xfer_ring_phys_addr)(struct usb_hcd *hcd,
+			struct usb_device *udev, struct usb_host_endpoint *ep,
+			dma_addr_t *dma);
+	int (*get_core_id)(struct usb_hcd *hcd);
 };
 
 static inline int hcd_giveback_urb_in_bh(struct usb_hcd *hcd)
@@ -449,11 +449,11 @@
 	unsigned int intr_num);
 extern int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev,
 	unsigned int intr_num);
-extern dma_addr_t usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
-		unsigned int intr_num);
-extern dma_addr_t usb_hcd_get_dcba_dma_addr(struct usb_device *udev);
-extern dma_addr_t usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
-	struct usb_host_endpoint *ep);
+extern phys_addr_t usb_hcd_get_sec_event_ring_phys_addr(
+	struct usb_device *udev, unsigned int intr_num, dma_addr_t *dma);
+extern phys_addr_t usb_hcd_get_xfer_ring_phys_addr(
+	struct usb_device *udev, struct usb_host_endpoint *ep, dma_addr_t *dma);
+extern int usb_hcd_get_controller_id(struct usb_device *udev);
 
 struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
 		struct device *sysdev, struct device *dev, const char *bus_name,
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index fc6e221..1061add 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -312,6 +312,7 @@
 	__WQ_DRAINING		= 1 << 16, /* internal: workqueue is draining */
 	__WQ_ORDERED		= 1 << 17, /* internal: workqueue is ordered */
 	__WQ_LEGACY		= 1 << 18, /* internal: create*_workqueue() */
+	__WQ_ORDERED_EXPLICIT	= 1 << 19, /* internal: alloc_ordered_workqueue() */
 
 	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
 	WQ_MAX_UNBOUND_PER_CPU	= 4,	  /* 4 * #cpus for unbound wq */
@@ -409,7 +410,8 @@
  * Pointer to the allocated workqueue on success, %NULL on failure.
  */
 #define alloc_ordered_workqueue(fmt, flags, args...)			\
-	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
+	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED |		\
+			__WQ_ORDERED_EXPLICIT | (flags), 1, ##args)
 
 #define create_workqueue(name)						\
 	alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 82b4b53..73da337 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -49,6 +49,13 @@
 #define CFG80211_REKEY_DATA_KEK_LEN 1
 
 /**
+ * Indicate backport support for the new cfg80211_roamed event which unifies the
+ * old APIs cfg80211_roamed and cfg80211_roamed_bss and takes a structure to
+ * update roam information to the kernel.
+ */
+#define CFG80211_ROAMED_API_UNIFIED 1
+
+/**
  * DOC: Introduction
  *
  * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
@@ -2661,8 +2668,7 @@
  *	indication of requesting reassociation.
  *	In both the driver-initiated and new connect() call initiated roaming
  *	cases, the result of roaming is indicated with a call to
- *	cfg80211_roamed() or cfg80211_roamed_bss().
- *	(invoked with the wireless_dev mutex held)
+ *	cfg80211_roamed(). (invoked with the wireless_dev mutex held)
  * @update_connect_params: Update the connect parameters while connected to a
  *	BSS. The updated parameters can be used by driver/firmware for
  *	subsequent BSS selection (roaming) decisions and to form the
@@ -5301,51 +5307,50 @@
 }
 
 /**
+ * struct cfg80211_roam_info - driver initiated roaming information
+ *
+ * @channel: the channel of the new AP
+ * @bss: entry of bss to which STA got roamed (may be %NULL if %bssid is set)
+ * @bssid: the BSSID of the new AP (may be %NULL if %bss is set)
+ * @req_ie: association request IEs (maybe be %NULL)
+ * @req_ie_len: association request IEs length
+ * @resp_ie: association response IEs (may be %NULL)
+ * @resp_ie_len: assoc response IEs length
+ * @authorized: true if the 802.1X authentication was done by the driver or is
+ *	not needed (e.g., when Fast Transition protocol was used), false
+ *	otherwise. Ignored for networks that don't use 802.1X authentication.
+ */
+struct cfg80211_roam_info {
+	struct ieee80211_channel *channel;
+	struct cfg80211_bss *bss;
+	const u8 *bssid;
+	const u8 *req_ie;
+	size_t req_ie_len;
+	const u8 *resp_ie;
+	size_t resp_ie_len;
+	bool authorized;
+};
+
+/**
  * cfg80211_roamed - notify cfg80211 of roaming
  *
  * @dev: network device
- * @channel: the channel of the new AP
- * @bssid: the BSSID of the new AP
- * @req_ie: association request IEs (maybe be %NULL)
- * @req_ie_len: association request IEs length
- * @resp_ie: association response IEs (may be %NULL)
- * @resp_ie_len: assoc response IEs length
+ * @info: information about the new BSS. struct &cfg80211_roam_info.
  * @gfp: allocation flags
  *
- * It should be called by the underlying driver whenever it roamed
- * from one AP to another while connected.
- */
-void cfg80211_roamed(struct net_device *dev,
-		     struct ieee80211_channel *channel,
-		     const u8 *bssid,
-		     const u8 *req_ie, size_t req_ie_len,
-		     const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);
-
-/**
- * cfg80211_roamed_bss - notify cfg80211 of roaming
- *
- * @dev: network device
- * @bss: entry of bss to which STA got roamed
- * @req_ie: association request IEs (maybe be %NULL)
- * @req_ie_len: association request IEs length
- * @resp_ie: association response IEs (may be %NULL)
- * @resp_ie_len: assoc response IEs length
- * @gfp: allocation flags
- *
- * This is just a wrapper to notify cfg80211 of roaming event with driver
- * passing bss to avoid a race in timeout of the bss entry. It should be
- * called by the underlying driver whenever it roamed from one AP to another
- * while connected. Drivers which have roaming implemented in firmware
- * may use this function to avoid a race in bss entry timeout where the bss
- * entry of the new AP is seen in the driver, but gets timed out by the time
- * it is accessed in __cfg80211_roamed() due to delay in scheduling
+ * This function may be called with the driver passing either the BSSID of the
+ * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
+ * It should be called by the underlying driver whenever it roamed from one AP
+ * to another while connected. Drivers which have roaming implemented in
+ * firmware should pass the bss entry to avoid a race in bss entry timeout where
+ * the bss entry of the new AP is seen in the driver, but gets timed out by the
+ * time it is accessed in __cfg80211_roamed() due to delay in scheduling
  * rdev->event_work. In case of any failures, the reference is released
- * either in cfg80211_roamed_bss() or in __cfg80211_romed(), Otherwise,
- * it will be released while diconneting from the current bss.
+ * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
+ * released while diconneting from the current bss.
  */
-void cfg80211_roamed_bss(struct net_device *dev, struct cfg80211_bss *bss,
-			 const u8 *req_ie, size_t req_ie_len,
-			 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);
+void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
+		     gfp_t gfp);
 
 /**
  * cfg80211_disconnected - notify cfg80211 that connection was dropped
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 261202f..8dbfdf7 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -95,8 +95,6 @@
 	[FRA_FWMARK]	= { .type = NLA_U32 }, \
 	[FRA_FWMASK]	= { .type = NLA_U32 }, \
 	[FRA_TABLE]     = { .type = NLA_U32 }, \
-	[FRA_UID_START]	= { .type = NLA_U32 }, \
-	[FRA_UID_END]	= { .type = NLA_U32 }, \
 	[FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
 	[FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
 	[FRA_GOTO]	= { .type = NLA_U32 }, \
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 909972a..634d192 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -1,14 +1,9 @@
 #ifndef __NET_FRAG_H__
 #define __NET_FRAG_H__
 
-#include <linux/percpu_counter.h>
-
 struct netns_frags {
-	/* The percpu_counter "mem" need to be cacheline aligned.
-	 *  mem.count must not share cacheline with other writers
-	 */
-	struct percpu_counter   mem ____cacheline_aligned_in_smp;
-
+	/* Keep atomic mem on separate cachelines in structs that include it */
+	atomic_t		mem ____cacheline_aligned_in_smp;
 	/* sysctls */
 	int			timeout;
 	int			high_thresh;
@@ -108,15 +103,10 @@
 int inet_frags_init(struct inet_frags *);
 void inet_frags_fini(struct inet_frags *);
 
-static inline int inet_frags_init_net(struct netns_frags *nf)
+static inline void inet_frags_init_net(struct netns_frags *nf)
 {
-	return percpu_counter_init(&nf->mem, 0, GFP_KERNEL);
+	atomic_set(&nf->mem, 0);
 }
-static inline void inet_frags_uninit_net(struct netns_frags *nf)
-{
-	percpu_counter_destroy(&nf->mem);
-}
-
 void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
 
 void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
@@ -140,37 +130,24 @@
 
 /* Memory Tracking Functions. */
 
-/* The default percpu_counter batch size is not big enough to scale to
- * fragmentation mem acct sizes.
- * The mem size of a 64K fragment is approx:
- *  (44 fragments * 2944 truesize) + frag_queue struct(200) = 129736 bytes
- */
-static unsigned int frag_percpu_counter_batch = 130000;
-
 static inline int frag_mem_limit(struct netns_frags *nf)
 {
-	return percpu_counter_read(&nf->mem);
+	return atomic_read(&nf->mem);
 }
 
 static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
 {
-	__percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
+	atomic_sub(i, &nf->mem);
 }
 
 static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
 {
-	__percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
+	atomic_add(i, &nf->mem);
 }
 
-static inline unsigned int sum_frag_mem_limit(struct netns_frags *nf)
+static inline int sum_frag_mem_limit(struct netns_frags *nf)
 {
-	unsigned int res;
-
-	local_bh_disable();
-	res = percpu_counter_sum_positive(&nf->mem);
-	local_bh_enable();
-
-	return res;
+	return atomic_read(&nf->mem);
 }
 
 /* RFC 3168 support :
diff --git a/include/net/ip.h b/include/net/ip.h
index 9816365..4ef6792 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -342,7 +342,7 @@
 	    !forwarding)
 		return dst_mtu(dst);
 
-	return min(dst->dev->mtu, IP_MAX_MTU);
+	return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
 }
 
 static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
@@ -354,7 +354,7 @@
 		return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding);
 	}
 
-	return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU);
+	return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU);
 }
 
 u32 ip_idents_reserve(u32 hash, int segs);
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index a74e2aa..a6bcb18 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -68,6 +68,7 @@
 	__u16			fn_flags;
 	int			fn_sernum;
 	struct rt6_info		*rr_ptr;
+	struct rcu_head		rcu;
 };
 
 #ifndef CONFIG_IPV6_SUBTREES
@@ -102,7 +103,7 @@
 	 * the same cache line.
 	 */
 	struct fib6_table		*rt6i_table;
-	struct fib6_node		*rt6i_node;
+	struct fib6_node __rcu		*rt6i_node;
 
 	struct in6_addr			rt6i_gateway;
 
@@ -165,13 +166,40 @@
 	rt0->rt6i_flags |= RTF_EXPIRES;
 }
 
+/* Function to safely get fn->sernum for passed in rt
+ * and store result in passed in cookie.
+ * Return true if we can get cookie safely
+ * Return false if not
+ */
+static inline bool rt6_get_cookie_safe(const struct rt6_info *rt,
+				       u32 *cookie)
+{
+	struct fib6_node *fn;
+	bool status = false;
+
+	rcu_read_lock();
+	fn = rcu_dereference(rt->rt6i_node);
+
+	if (fn) {
+		*cookie = fn->fn_sernum;
+		status = true;
+	}
+
+	rcu_read_unlock();
+	return status;
+}
+
 static inline u32 rt6_get_cookie(const struct rt6_info *rt)
 {
+	u32 cookie = 0;
+
 	if (rt->rt6i_flags & RTF_PCPU ||
 	    (unlikely(rt->dst.flags & DST_NOCACHE) && rt->dst.from))
 		rt = (struct rt6_info *)(rt->dst.from);
 
-	return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+	rt6_get_cookie_safe(rt, &cookie);
+
+	return cookie;
 }
 
 static inline void ip6_rt_put(struct rt6_info *rt)
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index e0f4109..c2aa73e 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -556,7 +556,8 @@
 		memcpy(stream + lcp_len,
 		       ((char *) &iwe->u) + IW_EV_POINT_OFF,
 		       IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
-		memcpy(stream + point_len, extra, iwe->u.data.length);
+		if (iwe->u.data.length && extra)
+			memcpy(stream + point_len, extra, iwe->u.data.length);
 		stream += event_len;
 	}
 	return stream;
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index e6aa0a2..f18fc1a 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -768,8 +768,11 @@
 	old = *pold;
 	*pold = new;
 	if (old != NULL) {
-		qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
+		unsigned int qlen = old->q.qlen;
+		unsigned int backlog = old->qstats.backlog;
+
 		qdisc_reset(old);
+		qdisc_tree_reduce_backlog(old, qlen, backlog);
 	}
 	sch_tree_unlock(sch);
 
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 31acc3f..61d9ce8 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -460,6 +460,8 @@
 
 #define _sctp_walk_params(pos, chunk, end, member)\
 for (pos.v = chunk->member;\
+     (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\
+      (void *)chunk + end) &&\
      pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
      ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\
      pos.v += SCTP_PAD4(ntohs(pos.p->length)))
@@ -470,6 +472,8 @@
 #define _sctp_walk_errors(err, chunk_hdr, end)\
 for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
 	    sizeof(sctp_chunkhdr_t));\
+     ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <=\
+      (void *)chunk_hdr + end) &&\
      (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
      ntohs(err->length) >= sizeof(sctp_errhdr_t); \
      err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length))))
diff --git a/include/soc/qcom/icnss.h b/include/soc/qcom/icnss.h
index 3527c35..e58a522 100644
--- a/include/soc/qcom/icnss.h
+++ b/include/soc/qcom/icnss.h
@@ -127,16 +127,7 @@
 extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr,
 			  uint32_t *iova_addr, size_t size);
 extern unsigned int icnss_socinfo_get_serial_number(struct device *dev);
-extern int icnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count);
-extern int icnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 *ch_count,
-					 u16 buf_len);
-extern int icnss_wlan_set_dfs_nol(const void *info, u16 info_len);
-extern int icnss_wlan_get_dfs_nol(void *info, u16 info_len);
 extern bool icnss_is_qmi_disable(void);
 extern bool icnss_is_fw_ready(void);
-extern int icnss_set_wlan_mac_address(const u8 *in, const uint32_t len);
-extern u8 *icnss_get_wlan_mac_address(struct device *dev, uint32_t *num);
 extern int icnss_trigger_recovery(struct device *dev);
-extern int icnss_get_driver_load_cnt(void);
-extern void icnss_increment_driver_load_cnt(void);
 #endif /* _ICNSS_WLAN_H_ */
diff --git a/include/soc/qcom/jtag.h b/include/soc/qcom/jtag.h
index 5719e05..dff601d 100644
--- a/include/soc/qcom/jtag.h
+++ b/include/soc/qcom/jtag.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015, 2017. The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
diff --git a/include/soc/qcom/memory_dump.h b/include/soc/qcom/memory_dump.h
index 50e4b8c..e67ee0e 100644
--- a/include/soc/qcom/memory_dump.h
+++ b/include/soc/qcom/memory_dump.h
@@ -83,6 +83,7 @@
 	MSM_DUMP_DATA_RPM = 0xEA,
 	MSM_DUMP_DATA_SCANDUMP = 0xEB,
 	MSM_DUMP_DATA_RPMH = 0xEC,
+	MSM_DUMP_DATA_POWER_REGS = 0xED,
 	MSM_DUMP_DATA_TMC_ETF = 0xF0,
 	MSM_DUMP_DATA_TMC_REG = 0x100,
 	MSM_DUMP_DATA_LOG_BUF = 0x110,
diff --git a/include/soc/qcom/ramdump.h b/include/soc/qcom/ramdump.h
index 50a17c8..4e23ccf 100644
--- a/include/soc/qcom/ramdump.h
+++ b/include/soc/qcom/ramdump.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -16,6 +16,7 @@
 struct device;
 
 struct ramdump_segment {
+	char *name;
 	unsigned long address;
 	void *v_address;
 	unsigned long size;
@@ -28,6 +29,8 @@
 		int nsegments);
 extern int do_elf_ramdump(void *handle, struct ramdump_segment *segments,
 		int nsegments);
+extern int do_minidump(void *handle, struct ramdump_segment *segments,
+		       int nsegments);
 
 #else
 static inline void *create_ramdump_device(const char *dev_name,
diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h
index f0b3d02..1982bfb 100644
--- a/include/soc/qcom/rpmh.h
+++ b/include/soc/qcom/rpmh.h
@@ -31,7 +31,7 @@
 int rpmh_write_async(struct rpmh_client *rc, enum rpmh_state state,
 			struct tcs_cmd *cmd, int n);
 
-int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
+int rpmh_write_batch(struct rpmh_client *rc, enum rpmh_state state,
 			struct tcs_cmd *cmd, int *n);
 
 int rpmh_mode_solver_set(struct rpmh_client *rc, bool enable);
@@ -70,7 +70,7 @@
 			enum rpmh_state state, struct tcs_cmd *cmd, int n)
 { return -ENODEV; }
 
-static inline int rpmh_write_passthru(struct rpmh_client *rc,
+static inline int rpmh_write_batch(struct rpmh_client *rc,
 			enum rpmh_state state, struct tcs_cmd *cmd, int *n)
 { return -ENODEV; }
 
diff --git a/include/soc/qcom/socinfo.h b/include/soc/qcom/socinfo.h
index f196d40..71bd075 100644
--- a/include/soc/qcom/socinfo.h
+++ b/include/soc/qcom/socinfo.h
@@ -102,6 +102,10 @@
 	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm845")
 #define early_machine_is_sdm670()	\
 	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm670")
+#define early_machine_is_qcs605()	\
+	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,qcs605")
+#define early_machine_is_sda670()	\
+	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sda670")
 #else
 #define of_board_is_sim()		0
 #define of_board_is_rumi()		0
@@ -142,6 +146,8 @@
 #define early_machine_is_sdxpoorwills()	0
 #define early_machine_is_sdm845()	0
 #define early_machine_is_sdm670()	0
+#define early_machine_is_qcs605()	0
+#define early_machine_is_sda670()	0
 #endif
 
 #define PLATFORM_SUBTYPE_MDM	1
@@ -204,6 +210,8 @@
 	SDX_CPU_SDXPOORWILLS,
 	MSM_CPU_SDM845,
 	MSM_CPU_SDM670,
+	MSM_CPU_QCS605,
+	MSM_CPU_SDA670,
 };
 
 struct msm_soc_info {
diff --git a/include/sound/adsp_err.h b/include/sound/adsp_err.h
deleted file mode 100644
index 43be91d..0000000
--- a/include/sound/adsp_err.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __ADSP_ERR__
-#define __ADSP_ERR__
-
-int adsp_err_get_lnx_err_code(u32 adsp_error);
-
-char *adsp_err_get_err_str(u32 adsp_error);
-
-#endif
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h
deleted file mode 100644
index bdab0b8..0000000
--- a/include/sound/apr_audio-v2.h
+++ /dev/null
@@ -1,10753 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _APR_AUDIO_V2_H_
-#define _APR_AUDIO_V2_H_
-
-#include <linux/qdsp6v2/apr.h>
-#include <linux/msm_audio.h>
-
-/* size of header needed for passing data out of band */
-#define APR_CMD_OB_HDR_SZ  12
-
-/* size of header needed for getting data */
-#define APR_CMD_GET_HDR_SZ 16
-
-struct param_outband {
-	size_t       size;
-	void        *kvaddr;
-	phys_addr_t  paddr;
-};
-
-#define ADSP_ADM_VERSION    0x00070000
-
-#define ADM_CMD_SHARED_MEM_MAP_REGIONS    0x00010322
-#define ADM_CMDRSP_SHARED_MEM_MAP_REGIONS 0x00010323
-#define ADM_CMD_SHARED_MEM_UNMAP_REGIONS 0x00010324
-
-#define ADM_CMD_MATRIX_MAP_ROUTINGS_V5 0x00010325
-#define ADM_CMD_STREAM_DEVICE_MAP_ROUTINGS_V5 0x0001033D
-/* Enumeration for an audio Rx matrix ID.*/
-#define ADM_MATRIX_ID_AUDIO_RX              0
-
-#define ADM_MATRIX_ID_AUDIO_TX              1
-
-#define ADM_MATRIX_ID_COMPRESSED_AUDIO_RX   2
-
-#define ADM_MATRIX_ID_COMPRESSED_AUDIO_TX   3
-
-#define ADM_MATRIX_ID_LISTEN_TX             4
-/* Enumeration for an audio Tx matrix ID.*/
-#define ADM_MATRIX_ID_AUDIOX              1
-
-#define ADM_MAX_COPPS 5
-
-/* make sure this matches with msm_audio_calibration */
-#define SP_V2_NUM_MAX_SPKR 2
-
-/* Session map node structure.
- * Immediately following this structure are num_copps
- * entries of COPP IDs. The COPP IDs are 16 bits, so
- * there might be a padding 16-bit field if num_copps
- * is odd.
- */
-struct adm_session_map_node_v5 {
-	u16                  session_id;
-	/* Handle of the ASM session to be routed. Supported values: 1
-	 * to 8.
-	 */
-
-
-	u16                  num_copps;
-	/* Number of COPPs to which this session is to be routed.
-	 * Supported values: 0 < num_copps <= ADM_MAX_COPPS.
-	 */
-} __packed;
-
-/*  Payload of the #ADM_CMD_MATRIX_MAP_ROUTINGS_V5 command.
- *	Immediately following this structure are num_sessions of the session map
- *	node payload (adm_session_map_node_v5).
- */
-
-struct adm_cmd_matrix_map_routings_v5 {
-	struct apr_hdr	hdr;
-
-	u32                  matrix_id;
-	/* Specifies whether the matrix ID is Audio Rx (0) or Audio Tx
-	 * (1). Use the ADM_MATRIX_ID_AUDIO_RX or ADM_MATRIX_ID_AUDIOX
-	 * macros to set this field.
-	 */
-	u32                  num_sessions;
-	/* Number of sessions being updated by this command (optional). */
-} __packed;
-
-/* This command allows a client to open a COPP/Voice Proc. TX module
- * and sets up the device session: Matrix -> COPP -> AFE on the RX
- * and AFE -> COPP -> Matrix on the TX. This enables PCM data to
- * be transferred to/from the endpoint (AFEPortID).
- *
- * @return
- * #ADM_CMDRSP_DEVICE_OPEN_V5 with the resulting status and COPP ID.
- */
-#define ADM_CMD_DEVICE_OPEN_V5                          0x00010326
-
-/* This command allows a client to open a COPP/Voice Proc the
- *	way as ADM_CMD_DEVICE_OPEN_V5 but supports multiple endpoint2
- *	channels.
- *
- *	@return
- *	#ADM_CMDRSP_DEVICE_OPEN_V6 with the resulting status and
- *	COPP ID.
- */
-#define ADM_CMD_DEVICE_OPEN_V6                      0x00010356
-
-/* Definition for a low latency stream session. */
-#define ADM_LOW_LATENCY_DEVICE_SESSION			0x2000
-
-/* Definition for a ultra low latency stream session. */
-#define ADM_ULTRA_LOW_LATENCY_DEVICE_SESSION		0x4000
-
-/* Definition for a ultra low latency with Post Processing stream session. */
-#define ADM_ULL_POST_PROCESSING_DEVICE_SESSION		0x8000
-
-/* Definition for a legacy device session. */
-#define ADM_LEGACY_DEVICE_SESSION                                      0
-
-/* Indicates that endpoint_id_2 is to be ignored.*/
-#define ADM_CMD_COPP_OPEN_END_POINT_ID_2_IGNORE				0xFFFF
-
-#define ADM_CMD_COPP_OPEN_MODE_OF_OPERATION_RX_PATH_COPP		 1
-
-#define ADM_CMD_COPP_OPEN_MODE_OF_OPERATIONX_PATH_LIVE_COPP		 2
-
-#define ADM_CMD_COPP_OPEN_MODE_OF_OPERATIONX_PATH_NON_LIVE_COPP	 3
-
-/* Indicates that an audio COPP is to send/receive a mono PCM
- * stream to/from
- *	END_POINT_ID_1.
- */
-#define ADM_CMD_COPP_OPEN_CHANNEL_CONFIG_MONO		1
-
-/* Indicates that an audio COPP is to send/receive a
- *	stereo PCM stream to/from END_POINT_ID_1.
- */
-#define ADM_CMD_COPP_OPEN_CHANNEL_CONFIG_STEREO		2
-
-/* Sample rate is 8000 Hz.*/
-#define ADM_CMD_COPP_OPEN_SAMPLE_RATE_8K 8000
-
-/* Sample rate is 16000 Hz.*/
-#define ADM_CMD_COPP_OPEN_SAMPLE_RATE_16K 16000
-
-/* Sample rate is 48000 Hz.*/
-#define ADM_CMD_COPP_OPEN_SAMPLE_RATE_48K 48000
-
-/* Definition for a COPP live input flag bitmask.*/
-#define ADM_BIT_MASK_COPP_LIVE_INPUT_FLAG (0x0001U)
-
-/* Definition for a COPP live shift value bitmask.*/
-#define ADM_SHIFT_COPP_LIVE_INPUT_FLAG	 0
-
-/* Definition for the COPP ID bitmask.*/
-#define ADM_BIT_MASK_COPP_ID  (0x0000FFFFUL)
-
-/* Definition for the COPP ID shift value.*/
-#define ADM_SHIFT_COPP_ID	0
-
-/* Definition for the service ID bitmask.*/
-#define ADM_BIT_MASK_SERVICE_ID  (0x00FF0000UL)
-
-/* Definition for the service ID shift value.*/
-#define ADM_SHIFT_SERVICE_ID	16
-
-/* Definition for the domain ID bitmask.*/
-#define ADM_BIT_MASK_DOMAIN_ID    (0xFF000000UL)
-
-/* Definition for the domain ID shift value.*/
-#define ADM_SHIFT_DOMAIN_ID	24
-
-/* ADM device open command payload of the
- * #ADM_CMD_DEVICE_OPEN_V5 command.
- */
-struct adm_cmd_device_open_v5 {
-	struct apr_hdr		hdr;
-	u16                  flags;
-/* Reserved for future use. Clients must set this field
- * to zero.
- */
-
-	u16                  mode_of_operation;
-/* Specifies whether the COPP must be opened on the Tx or Rx
- * path. Use the ADM_CMD_COPP_OPEN_MODE_OF_OPERATION_* macros for
- * supported values and interpretation.
- * Supported values:
- * - 0x1 -- Rx path COPP
- * - 0x2 -- Tx path live COPP
- * - 0x3 -- Tx path nonlive COPP
- * Live connections cause sample discarding in the Tx device
- * matrix if the destination output ports do not pull them
- * fast enough. Nonlive connections queue the samples
- * indefinitely.
- */
-
-	u16                  endpoint_id_1;
-/* Logical and physical endpoint ID of the audio path.
- * If the ID is a voice processor Tx block, it receives near
- * samples.	Supported values: Any pseudoport, AFE Rx port,
- * or AFE Tx port For a list of valid IDs, refer to
- * @xhyperref{Q4,[Q4]}.
- * Q4 = Hexagon Multimedia: AFE Interface Specification
- */
-
-	u16                  endpoint_id_2;
-/* Logical and physical endpoint ID 2 for a voice processor
- * Tx block.
- * This is not applicable to audio COPP.
- * Supported values:
- * - AFE Rx port
- * - 0xFFFF -- Endpoint 2 is unavailable and the voice
- * processor Tx
- * block ignores this endpoint
- * When the voice processor Tx block is created on the audio
- * record path,
- * it can receive far-end samples from an AFE Rx port if the
- * voice call
- * is active. The ID of the AFE port is provided in this
- * field.
- * For a list of valid IDs, refer @xhyperref{Q4,[Q4]}.
- */
-
-	u32                  topology_id;
-/* Audio COPP topology ID; 32-bit GUID. */
-
-	u16                  dev_num_channel;
-/* Number of channels the audio COPP sends to/receives from
- * the endpoint.
- * Supported values: 1 to 8.
- * The value is ignored for the voice processor Tx block,
- * where channel
- * configuration is derived from the topology ID.
- */
-
-	u16                  bit_width;
-/* Bit width (in bits) that the audio COPP sends to/receives
- * from the
- * endpoint. The value is ignored for the voice processing
- * Tx block,
- * where the PCM width is 16 bits.
- */
-
-	u32                  sample_rate;
-/* Sampling rate at which the audio COPP/voice processor
- * Tx block
- * interfaces with the endpoint.
- * Supported values for voice processor Tx: 8000, 16000,
- * 48000 Hz
- * Supported values for audio COPP: >0 and <=192 kHz
- */
-
-	u8                   dev_channel_mapping[8];
-/* Array of channel mapping of buffers that the audio COPP
- * sends to the endpoint. Channel[i] mapping describes channel
- * I inside the buffer, where 0 < i < dev_num_channel.
- * This value is relevant only for an audio Rx COPP.
- * For the voice processor block and Tx audio block, this field
- * is set to zero and is ignored.
- */
-} __packed;
-
-/*  ADM device open command payload of the
- *  #ADM_CMD_DEVICE_OPEN_V6 command.
- */
-struct adm_cmd_device_open_v6 {
-	struct apr_hdr		hdr;
-	u16                  flags;
-/* Reserved for future use. Clients must set this field
- * to zero.
- */
-
-	u16                  mode_of_operation;
-/* Specifies whether the COPP must be opened on the Tx or Rx
- * path. Use the ADM_CMD_COPP_OPEN_MODE_OF_OPERATION_* macros for
- * supported values and interpretation.
- * Supported values:
- * - 0x1 -- Rx path COPP
- * - 0x2 -- Tx path live COPP
- * - 0x3 -- Tx path nonlive COPP
- * Live connections cause sample discarding in the Tx device
- * matrix if the destination output ports do not pull them
- * fast enough. Nonlive connections queue the samples
- * indefinitely.
- */
-
-	u16                  endpoint_id_1;
-/* Logical and physical endpoint ID of the audio path.
- * If the ID is a voice processor Tx block, it receives near
- * samples.	Supported values: Any pseudoport, AFE Rx port,
- * or AFE Tx port For a list of valid IDs, refer to
- * @xhyperref{Q4,[Q4]}.
- * Q4 = Hexagon Multimedia: AFE Interface Specification
- */
-
-	u16                  endpoint_id_2;
-/* Logical and physical endpoint ID 2 for a voice processor
- * Tx block.
- * This is not applicable to audio COPP.
- * Supported values:
- * - AFE Rx port
- * - 0xFFFF -- Endpoint 2 is unavailable and the voice
- * processor Tx
- * block ignores this endpoint
- * When the voice processor Tx block is created on the audio
- * record path,
- * it can receive far-end samples from an AFE Rx port if the
- * voice call
- * is active. The ID of the AFE port is provided in this
- * field.
- * For a list of valid IDs, refer @xhyperref{Q4,[Q4]}.
- */
-
-	u32                  topology_id;
-/* Audio COPP topology ID; 32-bit GUID. */
-
-	u16                  dev_num_channel;
-/* Number of channels the audio COPP sends to/receives from
- * the endpoint.
- * Supported values: 1 to 8.
- * The value is ignored for the voice processor Tx block,
- * where channel
- * configuration is derived from the topology ID.
- */
-
-	u16                  bit_width;
-/* Bit width (in bits) that the audio COPP sends to/receives
- * from the
- * endpoint. The value is ignored for the voice processing
- * Tx block,
- * where the PCM width is 16 bits.
- */
-
-	u32                  sample_rate;
-/* Sampling rate at which the audio COPP/voice processor
- * Tx block
- * interfaces with the endpoint.
- * Supported values for voice processor Tx: 8000, 16000,
- * 48000 Hz
- * Supported values for audio COPP: >0 and <=192 kHz
- */
-
-	u8                   dev_channel_mapping[8];
-/* Array of channel mapping of buffers that the audio COPP
- * sends to the endpoint. Channel[i] mapping describes channel
- * I inside the buffer, where 0 < i < dev_num_channel.
- * This value is relevant only for an audio Rx COPP.
- * For the voice processor block and Tx audio block, this field
- * is set to zero and is ignored.
- */
-
-	u16                  dev_num_channel_eid2;
-/* Number of channels the voice processor block sends
- * to/receives from the endpoint2.
- * Supported values: 1 to 8.
- * The value is ignored for audio COPP or if endpoint_id_2 is
- * set to 0xFFFF.
- */
-
-	u16                  bit_width_eid2;
-/* Bit width (in bits) that the voice processor sends
- * to/receives from the endpoint2.
- * Supported values: 16 and 24.
- * The value is ignored for audio COPP or if endpoint_id_2 is
- * set to 0xFFFF.
- */
-
-	u32                  sample_rate_eid2;
-/* Sampling rate at which the voice processor Tx block
- * interfaces with the endpoint2.
- * Supported values for Tx voice processor: >0 and <=384 kHz
- * The value is ignored for audio COPP or if endpoint_id_2 is
- * set to 0xFFFF.
- */
-
-	u8                   dev_channel_mapping_eid2[8];
-/* Array of channel mapping of buffers that the voice processor
- * sends to the endpoint. Channel[i] mapping describes channel
- * I inside the buffer, where 0 < i < dev_num_channel.
- * This value is relevant only for the Tx voice processor.
- * The values are ignored for audio COPP or if endpoint_id_2 is
- * set to 0xFFFF.
- */
-} __packed;
-
-/*
- *	This command allows the client to close a COPP and disconnect
- *	the device session.
- */
-#define ADM_CMD_DEVICE_CLOSE_V5                         0x00010327
-
-/* Sets one or more parameters to a COPP. */
-#define ADM_CMD_SET_PP_PARAMS_V5                        0x00010328
-
-/*  Payload of the #ADM_CMD_SET_PP_PARAMS_V5 command.
- *	If the data_payload_addr_lsw and data_payload_addr_msw element
- *	are NULL, a series of adm_param_datastructures immediately
- *	follows, whose total size is data_payload_size bytes.
- */
-struct adm_cmd_set_pp_params_v5 {
-	struct apr_hdr hdr;
-	u32		payload_addr_lsw;
-/* LSW of parameter data payload address. */
-	u32		payload_addr_msw;
-/* MSW of parameter data payload address. */
-
-	u32		mem_map_handle;
-/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS
- * command
- *
- * If mem_map_handle is zero implies the message is in
- * the payload
- */
-
-	u32		payload_size;
-/* Size in bytes of the variable payload accompanying this
- * message or
- * in shared memory. This is used for parsing the parameter
- * payload.
- */
-} __packed;
-
-/*  Payload format for COPP parameter data.
- * Immediately following this structure are param_size bytes
- * of parameter
- * data.
- */
-struct adm_param_data_v5 {
-	u32                  module_id;
-	/* Unique ID of the module. */
-	u32                  param_id;
-	/* Unique ID of the parameter. */
-	u16                  param_size;
-	/* Data size of the param_id/module_id combination.
-	 * This value is a
-	 * multiple of 4 bytes.
-	 */
-	u16                  reserved;
-	/* Reserved for future enhancements.
-	 * This field must be set to zero.
-	 */
-} __packed;
-
-#define ASM_STREAM_CMD_REGISTER_PP_EVENTS 0x00013213
-#define ASM_STREAM_PP_EVENT 0x00013214
-#define ASM_STREAM_CMD_REGISTER_IEC_61937_FMT_UPDATE 0x13333
-#define ASM_IEC_61937_MEDIA_FMT_EVENT 0x13334
-
-#define DSP_STREAM_CMD "ADSP Stream Cmd"
-#define DSP_STREAM_CALLBACK "ADSP Stream Callback Event"
-#define DSP_STREAM_CALLBACK_QUEUE_SIZE 1024
-
-struct dsp_stream_callback_list {
-	struct list_head list;
-	struct msm_adsp_event_data event;
-};
-
-struct dsp_stream_callback_prtd {
-	uint16_t event_count;
-	struct list_head event_queue;
-	spinlock_t prtd_spin_lock;
-};
-
-/* set customized mixing on matrix mixer */
-#define ADM_CMD_SET_PSPD_MTMX_STRTR_PARAMS_V5                        0x00010344
-struct adm_cmd_set_pspd_mtmx_strtr_params_v5 {
-	struct apr_hdr hdr;
-	/* LSW of parameter data payload address.*/
-	u32		payload_addr_lsw;
-	/* MSW of parameter data payload address.*/
-	u32		payload_addr_msw;
-	/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS */
-	/* command. If mem_map_handle is zero implies the message is in */
-	/* the payload */
-	u32		mem_map_handle;
-	/* Size in bytes of the variable payload accompanying this */
-	/* message or in shared memory. This is used for parsing the */
-	/* parameter payload. */
-	u32		payload_size;
-	u16		direction;
-	u16		sessionid;
-	u16		deviceid;
-	u16		reserved;
-} __packed;
-
-/* Defined specifically for in-band use, includes params */
-struct adm_cmd_set_pp_params_inband_v5 {
-	struct apr_hdr hdr;
-	/* LSW of parameter data payload address.*/
-	u32             payload_addr_lsw;
-	/* MSW of parameter data payload address.*/
-	u32             payload_addr_msw;
-	/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS */
-	/* command. If mem_map_handle is zero implies the message is in */
-	/* the payload */
-	u32             mem_map_handle;
-	/* Size in bytes of the variable payload accompanying this */
-	/* message or in shared memory. This is used for parsing the */
-	/* parameter payload. */
-	u32             payload_size;
-	/* Parameters passed for in band payload */
-	struct adm_param_data_v5        params;
-} __packed;
-
-/* Returns the status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V5 command.
- */
-#define ADM_CMDRSP_DEVICE_OPEN_V5                      0x00010329
-
-/*  Payload of the #ADM_CMDRSP_DEVICE_OPEN_V5 message,
- *	which returns the
- *	status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V5 command.
- */
-struct adm_cmd_rsp_device_open_v5 {
-	u32                  status;
-	/* Status message (error code).*/
-
-	u16                  copp_id;
-	/* COPP ID:  Supported values: 0 <= copp_id < ADM_MAX_COPPS*/
-
-	u16                  reserved;
-	/* Reserved. This field must be set to zero.*/
-} __packed;
-
-/* Returns the status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V6 command. */
-#define ADM_CMDRSP_DEVICE_OPEN_V6                      0x00010357
-
-/*  Payload of the #ADM_CMDRSP_DEVICE_OPEN_V6 message,
- *	which returns the
- *	status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V6 command
- *	is the exact same as ADM_CMDRSP_DEVICE_OPEN_V5.
- */
-
-/* This command allows a query of one COPP parameter. */
-#define ADM_CMD_GET_PP_PARAMS_V5                                0x0001032A
-
-/*  Payload an #ADM_CMD_GET_PP_PARAMS_V5 command. */
-struct adm_cmd_get_pp_params_v5 {
-	struct apr_hdr hdr;
-	u32                  data_payload_addr_lsw;
-	/* LSW of parameter data payload address.*/
-
-	u32                  data_payload_addr_msw;
-	/* MSW of parameter data payload address.*/
-
-	/* If the mem_map_handle is non zero,
-	 * on ACK, the ParamData payloads begin at
-	 * the address specified (out-of-band).
-	 */
-
-	u32                  mem_map_handle;
-	/* Memory map handle returned
-	 * by ADM_CMD_SHARED_MEM_MAP_REGIONS command.
-	 * If the mem_map_handle is 0, it implies that
-	 * the ACK's payload will contain the ParamData (in-band).
-	 */
-
-	u32                  module_id;
-	/* Unique ID of the module. */
-
-	u32                  param_id;
-	/* Unique ID of the parameter. */
-
-	u16                  param_max_size;
-	/* Maximum data size of the parameter
-	 *ID/module ID combination. This
-	 * field is a multiple of 4 bytes.
-	 */
-	u16                  reserved;
-	/* Reserved for future enhancements.
-	 * This field must be set to zero.
-	 */
-} __packed;
-
-/* Returns parameter values
- *	in response to an #ADM_CMD_GET_PP_PARAMS_V5 command.
- */
-#define ADM_CMDRSP_GET_PP_PARAMS_V5		0x0001032B
-
-/* Payload of the #ADM_CMDRSP_GET_PP_PARAMS_V5 message,
- * which returns parameter values in response
- * to an #ADM_CMD_GET_PP_PARAMS_V5 command.
- * Immediately following this
- * structure is the adm_param_data_v5
- * structure containing the pre/postprocessing
- * parameter data. For an in-band
- * scenario, the variable payload depends
- * on the size of the parameter.
- */
-struct adm_cmd_rsp_get_pp_params_v5 {
-	u32                  status;
-	/* Status message (error code).*/
-} __packed;
-
-/* Structure for holding soft stepping volume parameters. */
-
-/*
- * Payload of the #ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS
- * parameters used by the Volume Control module.
- */
-
-struct audproc_softvolume_params {
-	u32 period;
-	u32 step;
-	u32 rampingcurve;
-} __packed;
-
-/*
- * ID of the Media Format Converter (MFC) module.
- * This module supports the following parameter IDs:
- * #AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT
- * #AUDPROC_CHMIXER_PARAM_ID_COEFF
- */
-#define AUDPROC_MODULE_ID_MFC                               0x00010912
-
-/* ID of the Output Media Format parameters used by AUDPROC_MODULE_ID_MFC.
- *
- */
-#define AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT            0x00010913
-
-
-struct audproc_mfc_output_media_fmt {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-	uint32_t sampling_rate;
-	uint16_t bits_per_sample;
-	uint16_t num_channels;
-	uint16_t channel_type[8];
-} __packed;
-
-struct audproc_volume_ctrl_master_gain {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-	/* Linear gain in Q13 format. */
-	uint16_t                  master_gain;
-	/* Clients must set this field to zero. */
-	uint16_t                  reserved;
-} __packed;
-
-struct audproc_soft_step_volume_params {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-/*
- * Period in milliseconds.
- * Supported values: 0 to 15000
- */
-	uint32_t                  period;
-/*
- * Step in microseconds.
- * Supported values: 0 to 15000000
- */
-	uint32_t                  step;
-/*
- * Ramping curve type.
- * Supported values:
- * - #AUDPROC_PARAM_SVC_RAMPINGCURVE_LINEAR
- * - #AUDPROC_PARAM_SVC_RAMPINGCURVE_EXP
- * - #AUDPROC_PARAM_SVC_RAMPINGCURVE_LOG
- */
-	uint32_t                  ramping_curve;
-} __packed;
-
-struct audproc_enable_param_t {
-	struct adm_cmd_set_pp_params_inband_v5 pp_params;
-	/*
-	 * Specifies whether the Audio processing module is enabled.
-	 * This parameter is generic/common parameter to configure or
-	 * determine the state of any audio processing module.
-
-	 * @values 0 : Disable 1: Enable
-	 */
-	uint32_t                  enable;
-};
-
-/*
- * Allows a client to control the gains on various session-to-COPP paths.
- */
-#define ADM_CMD_MATRIX_RAMP_GAINS_V5                                 0x0001032C
-
-/* Indicates that the target gain in the
- *	current adm_session_copp_gain_v5
- *	structure is to be applied to all
- *	the session-to-COPP paths that exist for
- *	the specified session.
- */
-#define ADM_CMD_MATRIX_RAMP_GAINS_COPP_ID_ALL_CONNECTED_COPPS     0xFFFF
-
-/* Indicates that the target gain is
- * to be immediately applied to the
- * specified session-to-COPP path,
- * without a ramping fashion.
- */
-#define ADM_CMD_MATRIX_RAMP_GAINS_RAMP_DURATION_IMMEDIATE         0x0000
-
-/* Enumeration for a linear ramping curve.*/
-#define ADM_CMD_MATRIX_RAMP_GAINS_RAMP_CURVE_LINEAR               0x0000
-
-/*  Payload of the #ADM_CMD_MATRIX_RAMP_GAINS_V5 command.
- * Immediately following this structure are num_gains of the
- * adm_session_copp_gain_v5structure.
- */
-struct adm_cmd_matrix_ramp_gains_v5 {
-	u32                  matrix_id;
-/* Specifies whether the matrix ID is Audio Rx (0) or Audio Tx (1).
- * Use the ADM_MATRIX_ID_AUDIO_RX or  ADM_MATRIX_ID_AUDIOX
- * macros to set this field.
- */
-
-	u16                  num_gains;
-	/* Number of gains being applied. */
-
-	u16                  reserved_for_align;
-	/* Reserved. This field must be set to zero.*/
-} __packed;
-
-/*  Session-to-COPP path gain structure, used by the
- *	#ADM_CMD_MATRIX_RAMP_GAINS_V5 command.
- *	This structure specifies the target
- *	gain (per channel) that must be applied
- *	to a particular session-to-COPP path in
- *	the audio matrix. The structure can
- *	also be used to apply the gain globally
- *	to all session-to-COPP paths that
- *	exist for the given session.
- *	The aDSP uses device channel mapping to
- *	determine which channel gains to
- *	use from this command. For example,
- *	if the device is configured as stereo,
- *	the aDSP uses only target_gain_ch_1 and
- *	target_gain_ch_2, and it ignores
- *	the others.
- */
-struct adm_session_copp_gain_v5 {
-	u16                  session_id;
-/* Handle of the ASM session.
- *	Supported values: 1 to 8.
- */
-
-	u16                  copp_id;
-/* Handle of the COPP. Gain will be applied on the Session ID
- * COPP ID path.
- */
-
-	u16                  ramp_duration;
-/* Duration (in milliseconds) of the ramp over
- * which target gains are
- * to be applied. Use
- * #ADM_CMD_MATRIX_RAMP_GAINS_RAMP_DURATION_IMMEDIATE
- * to indicate that gain must be applied immediately.
- */
-
-	u16                  step_duration;
-/* Duration (in milliseconds) of each step in the ramp.
- * This parameter is ignored if ramp_duration is equal to
- * #ADM_CMD_MATRIX_RAMP_GAINS_RAMP_DURATION_IMMEDIATE.
- * Supported value: 1
- */
-
-	u16                  ramp_curve;
-/* Type of ramping curve.
- * Supported value: #ADM_CMD_MATRIX_RAMP_GAINS_RAMP_CURVE_LINEAR
- */
-
-	u16                  reserved_for_align;
-	/* Reserved. This field must be set to zero. */
-
-	u16                  target_gain_ch_1;
-	/* Target linear gain for channel 1 in Q13 format; */
-
-	u16                  target_gain_ch_2;
-	/* Target linear gain for channel 2 in Q13 format; */
-
-	u16                  target_gain_ch_3;
-	/* Target linear gain for channel 3 in Q13 format; */
-
-	u16                  target_gain_ch_4;
-	/* Target linear gain for channel 4 in Q13 format; */
-
-	u16                  target_gain_ch_5;
-	/* Target linear gain for channel 5 in Q13 format; */
-
-	u16                  target_gain_ch_6;
-	/* Target linear gain for channel 6 in Q13 format; */
-
-	u16                  target_gain_ch_7;
-	/* Target linear gain for channel 7 in Q13 format; */
-
-	u16                  target_gain_ch_8;
-	/* Target linear gain for channel 8 in Q13 format; */
-} __packed;
-
-/* Allows to set mute/unmute on various session-to-COPP paths.
- *	For every session-to-COPP path (stream-device interconnection),
- *	mute/unmute can be set individually on the output channels.
- */
-#define ADM_CMD_MATRIX_MUTE_V5                                0x0001032D
-
-/* Indicates that mute/unmute in the
- *	current adm_session_copp_mute_v5structure
- *	is to be applied to all the session-to-COPP
- *	paths that exist for the specified session.
- */
-#define ADM_CMD_MATRIX_MUTE_COPP_ID_ALL_CONNECTED_COPPS     0xFFFF
-
-/*  Payload of the #ADM_CMD_MATRIX_MUTE_V5 command*/
-struct adm_cmd_matrix_mute_v5 {
-	u32                  matrix_id;
-/* Specifies whether the matrix ID is Audio Rx (0) or Audio Tx (1).
- * Use the ADM_MATRIX_ID_AUDIO_RX or  ADM_MATRIX_ID_AUDIOX
- * macros to set this field.
- */
-
-	u16                  session_id;
-/* Handle of the ASM session.
- * Supported values: 1 to 8.
- */
-
-	u16                  copp_id;
-/* Handle of the COPP.
- * Use ADM_CMD_MATRIX_MUTE_COPP_ID_ALL_CONNECTED_COPPS
- * to indicate that mute/unmute must be applied to
- * all the COPPs connected to session_id.
- * Supported values:
- * - 0xFFFF -- Apply mute/unmute to all connected COPPs
- * - Other values -- Valid COPP ID
- */
-
-	u8                  mute_flag_ch_1;
-	/* Mute flag for channel 1 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_2;
-	/* Mute flag for channel 2 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_3;
-	/* Mute flag for channel 3 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_4;
-	/* Mute flag for channel 4 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_5;
-	/* Mute flag for channel 5 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_6;
-	/* Mute flag for channel 6 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_7;
-	/* Mute flag for channel 7 is set to unmute (0) or mute (1). */
-
-	u8                  mute_flag_ch_8;
-	/* Mute flag for channel 8 is set to unmute (0) or mute (1). */
-
-	u16                 ramp_duration;
-/* Period (in milliseconds) over which the soft mute/unmute will be
- * applied.
- * Supported values: 0 (Default) to 0xFFFF
- * The default of 0 means mute/unmute will be applied immediately.
- */
-
-	u16                 reserved_for_align;
-	/* Clients must set this field to zero.*/
-} __packed;
-
-#define ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG_V2 (0x00010DD8)
-
-struct asm_aac_stereo_mix_coeff_selection_param_v2 {
-	struct apr_hdr          hdr;
-	u32                     param_id;
-	u32                     param_size;
-	u32                     aac_stereo_mix_coeff_flag;
-} __packed;
-
-/* Allows a client to connect the desired stream to
- * the desired AFE port through the stream router
- *
- * This command allows the client to connect specified session to
- * specified AFE port. This is used for compressed streams only
- * opened using the #ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED or
- * #ASM_STREAM_CMD_OPEN_READ_COMPRESSED command.
- *
- * @prerequisites
- * Session ID and AFE Port ID must be valid.
- * #ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED or
- * #ASM_STREAM_CMD_OPEN_READ_COMPRESSED
- * must have been called on this session.
- */
-
-#define ADM_CMD_CONNECT_AFE_PORT_V5	0x0001032E
-#define ADM_CMD_DISCONNECT_AFE_PORT_V5	0x0001032F
-/* Enumeration for the Rx stream router ID.*/
-#define ADM_STRTR_ID_RX                    0
-/* Enumeration for the Tx stream router ID.*/
-#define ADM_STRTR_IDX                    1
-
-/*  Payload of the #ADM_CMD_CONNECT_AFE_PORT_V5 command.*/
-struct adm_cmd_connect_afe_port_v5 {
-	struct apr_hdr     hdr;
-	u8                  mode;
-/* ID of the stream router (RX/TX). Use the
- * ADM_STRTR_ID_RX or ADM_STRTR_IDX macros
- * to set this field.
- */
-
-	u8                  session_id;
-	/* Session ID of the stream to connect */
-
-	u16                 afe_port_id;
-	/* Port ID of the AFE port to connect to.*/
-	u32                 num_channels;
-/* Number of device channels
- * Supported values: 2(Audio Sample Packet),
- * 8 (HBR Audio Stream Sample Packet)
- */
-
-	u32                 sampling_rate;
-/* Device sampling rate
- * Supported values: Any
- */
-} __packed;
-
-
-/* adsp_adm_api.h */
-
-
-/* Port ID. Update afe_get_port_index
- * when a new port is added here.
- */
-#define PRIMARY_I2S_RX 0
-#define PRIMARY_I2S_TX 1
-#define SECONDARY_I2S_RX 4
-#define SECONDARY_I2S_TX 5
-#define MI2S_RX 6
-#define MI2S_TX 7
-#define HDMI_RX 8
-#define RSVD_2 9
-#define RSVD_3 10
-#define DIGI_MIC_TX 11
-#define VOICE2_PLAYBACK_TX 0x8002
-#define VOICE_RECORD_RX 0x8003
-#define VOICE_RECORD_TX 0x8004
-#define VOICE_PLAYBACK_TX 0x8005
-
-/* Slimbus Multi channel port id pool  */
-#define SLIMBUS_0_RX		0x4000
-#define SLIMBUS_0_TX		0x4001
-#define SLIMBUS_1_RX		0x4002
-#define SLIMBUS_1_TX		0x4003
-#define SLIMBUS_2_RX		0x4004
-#define SLIMBUS_2_TX		0x4005
-#define SLIMBUS_3_RX		0x4006
-#define SLIMBUS_3_TX		0x4007
-#define SLIMBUS_4_RX		0x4008
-#define SLIMBUS_4_TX		0x4009
-#define SLIMBUS_5_RX		0x400a
-#define SLIMBUS_5_TX		0x400b
-#define SLIMBUS_6_RX		0x400c
-#define SLIMBUS_6_TX		0x400d
-#define SLIMBUS_7_RX		0x400e
-#define SLIMBUS_7_TX		0x400f
-#define SLIMBUS_8_RX		0x4010
-#define SLIMBUS_8_TX		0x4011
-#define SLIMBUS_PORT_LAST	SLIMBUS_8_TX
-#define INT_BT_SCO_RX 0x3000
-#define INT_BT_SCO_TX 0x3001
-#define INT_BT_A2DP_RX 0x3002
-#define INT_FM_RX 0x3004
-#define INT_FM_TX 0x3005
-#define RT_PROXY_PORT_001_RX	0x2000
-#define RT_PROXY_PORT_001_TX	0x2001
-#define DISPLAY_PORT_RX	0x6020
-
-#define AFE_PORT_INVALID 0xFFFF
-#define SLIMBUS_INVALID AFE_PORT_INVALID
-
-#define AFE_PORT_CMD_START 0x000100ca
-
-#define AFE_EVENT_RTPORT_START 0
-#define AFE_EVENT_RTPORT_STOP 1
-#define AFE_EVENT_RTPORT_LOW_WM 2
-#define AFE_EVENT_RTPORT_HI_WM 3
-
-#define ADSP_AFE_VERSION    0x00200000
-
-/* Size of the range of port IDs for the audio interface. */
-#define  AFE_PORT_ID_AUDIO_IF_PORT_RANGE_SIZE	0xF
-
-/* Size of the range of port IDs for internal BT-FM ports. */
-#define AFE_PORT_ID_INTERNAL_BT_FM_RANGE_SIZE	0x6
-
-/* Size of the range of port IDs for SLIMbus<sup>&reg;
- * </sup> multichannel
- * ports.
- */
-#define AFE_PORT_ID_SLIMBUS_RANGE_SIZE	0xA
-
-/* Size of the range of port IDs for real-time proxy ports. */
-#define  AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE	0x2
-
-/* Size of the range of port IDs for pseudoports. */
-#define AFE_PORT_ID_PSEUDOPORT_RANGE_SIZE	0x5
-
-/* Start of the range of port IDs for the audio interface. */
-#define  AFE_PORT_ID_AUDIO_IF_PORT_RANGE_START	0x1000
-
-/* End of the range of port IDs for the audio interface. */
-#define  AFE_PORT_ID_AUDIO_IF_PORT_RANGE_END \
-	(AFE_PORT_ID_AUDIO_IF_PORT_RANGE_START +\
-	AFE_PORT_ID_AUDIO_IF_PORT_RANGE_SIZE - 1)
-
-/* Start of the range of port IDs for real-time proxy ports. */
-#define  AFE_PORT_ID_RT_PROXY_PORT_RANGE_START	0x2000
-
-/* End of the range of port IDs for real-time proxy ports. */
-#define  AFE_PORT_ID_RT_PROXY_PORT_RANGE_END \
-	(AFE_PORT_ID_RT_PROXY_PORT_RANGE_START +\
-	AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE-1)
-
-/* Start of the range of port IDs for internal BT-FM devices. */
-#define AFE_PORT_ID_INTERNAL_BT_FM_RANGE_START	0x3000
-
-/* End of the range of port IDs for internal BT-FM devices. */
-#define AFE_PORT_ID_INTERNAL_BT_FM_RANGE_END \
-	(AFE_PORT_ID_INTERNAL_BT_FM_RANGE_START +\
-	AFE_PORT_ID_INTERNAL_BT_FM_RANGE_SIZE-1)
-
-/*	Start of the range of port IDs for SLIMbus devices. */
-#define AFE_PORT_ID_SLIMBUS_RANGE_START	0x4000
-
-/*	End of the range of port IDs for SLIMbus devices. */
-#define AFE_PORT_ID_SLIMBUS_RANGE_END \
-	(AFE_PORT_ID_SLIMBUS_RANGE_START +\
-	AFE_PORT_ID_SLIMBUS_RANGE_SIZE-1)
-
-/* Start of the range of port IDs for pseudoports. */
-#define AFE_PORT_ID_PSEUDOPORT_RANGE_START	0x8001
-
-/* End of the range of port IDs for pseudoports.  */
-#define AFE_PORT_ID_PSEUDOPORT_RANGE_END \
-	(AFE_PORT_ID_PSEUDOPORT_RANGE_START +\
-	AFE_PORT_ID_PSEUDOPORT_RANGE_SIZE-1)
-
-/* Start of the range of port IDs for TDM devices. */
-#define AFE_PORT_ID_TDM_PORT_RANGE_START	0x9000
-
-/* End of the range of port IDs for TDM devices. */
-#define AFE_PORT_ID_TDM_PORT_RANGE_END \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START+0x40-1)
-
-/* Size of the range of port IDs for TDM ports. */
-#define AFE_PORT_ID_TDM_PORT_RANGE_SIZE \
-	(AFE_PORT_ID_TDM_PORT_RANGE_END - \
-	AFE_PORT_ID_TDM_PORT_RANGE_START+1)
-
-#define AFE_PORT_ID_PRIMARY_MI2S_RX         0x1000
-#define AFE_PORT_ID_PRIMARY_MI2S_TX         0x1001
-#define AFE_PORT_ID_SECONDARY_MI2S_RX       0x1002
-#define AFE_PORT_ID_SECONDARY_MI2S_TX       0x1003
-#define AFE_PORT_ID_TERTIARY_MI2S_RX        0x1004
-#define AFE_PORT_ID_TERTIARY_MI2S_TX        0x1005
-#define AFE_PORT_ID_QUATERNARY_MI2S_RX      0x1006
-#define AFE_PORT_ID_QUATERNARY_MI2S_TX      0x1007
-#define AUDIO_PORT_ID_I2S_RX                0x1008
-#define AFE_PORT_ID_DIGITAL_MIC_TX          0x1009
-#define AFE_PORT_ID_PRIMARY_PCM_RX          0x100A
-#define AFE_PORT_ID_PRIMARY_PCM_TX          0x100B
-#define AFE_PORT_ID_SECONDARY_PCM_RX        0x100C
-#define AFE_PORT_ID_SECONDARY_PCM_TX        0x100D
-#define AFE_PORT_ID_MULTICHAN_HDMI_RX       0x100E
-#define AFE_PORT_ID_SECONDARY_MI2S_RX_SD1   0x1010
-#define AFE_PORT_ID_TERTIARY_PCM_RX         0x1012
-#define AFE_PORT_ID_TERTIARY_PCM_TX         0x1013
-#define AFE_PORT_ID_QUATERNARY_PCM_RX       0x1014
-#define AFE_PORT_ID_QUATERNARY_PCM_TX       0x1015
-#define AFE_PORT_ID_QUINARY_MI2S_RX         0x1016
-#define AFE_PORT_ID_QUINARY_MI2S_TX         0x1017
-/* ID of the senary MI2S Rx port. */
-#define AFE_PORT_ID_SENARY_MI2S_RX          0x1018
-/* ID of the senary MI2S Tx port. */
-#define AFE_PORT_ID_SENARY_MI2S_TX          0x1019
-/* ID of the Internal 0 MI2S Rx port */
-#define AFE_PORT_ID_INT0_MI2S_RX                 0x102E
-/* ID of the Internal 0 MI2S Tx port */
-#define AFE_PORT_ID_INT0_MI2S_TX                 0x102F
-/* ID of the Internal 1 MI2S Rx port */
-#define AFE_PORT_ID_INT1_MI2S_RX                 0x1030
-/* ID of the Internal 1 MI2S Tx port */
-#define AFE_PORT_ID_INT1_MI2S_TX                 0x1031
-/* ID of the Internal 2 MI2S Rx port */
-#define AFE_PORT_ID_INT2_MI2S_RX                 0x1032
-/* ID of the Internal 2 MI2S Tx port */
-#define AFE_PORT_ID_INT2_MI2S_TX                 0x1033
-/* ID of the Internal 3 MI2S Rx port */
-#define AFE_PORT_ID_INT3_MI2S_RX                 0x1034
-/* ID of the Internal 3 MI2S Tx port */
-#define AFE_PORT_ID_INT3_MI2S_TX                 0x1035
-/* ID of the Internal 4 MI2S Rx port */
-#define AFE_PORT_ID_INT4_MI2S_RX                 0x1036
-/* ID of the Internal 4 MI2S Tx port */
-#define AFE_PORT_ID_INT4_MI2S_TX                 0x1037
-/* ID of the Internal 5 MI2S Rx port */
-#define AFE_PORT_ID_INT5_MI2S_RX                 0x1038
-/* ID of the Internal 5 MI2S Tx port */
-#define AFE_PORT_ID_INT5_MI2S_TX                 0x1039
-/* ID of the Internal 6 MI2S Rx port */
-#define AFE_PORT_ID_INT6_MI2S_RX                 0x103A
-/* ID of the Internal 6 MI2S Tx port */
-#define AFE_PORT_ID_INT6_MI2S_TX                 0x103B
-#define AFE_PORT_ID_SPDIF_RX                0x5000
-#define  AFE_PORT_ID_RT_PROXY_PORT_001_RX   0x2000
-#define  AFE_PORT_ID_RT_PROXY_PORT_001_TX   0x2001
-#define AFE_PORT_ID_INTERNAL_BT_SCO_RX      0x3000
-#define AFE_PORT_ID_INTERNAL_BT_SCO_TX      0x3001
-#define AFE_PORT_ID_INTERNAL_BT_A2DP_RX     0x3002
-#define AFE_PORT_ID_INTERNAL_FM_RX          0x3004
-#define AFE_PORT_ID_INTERNAL_FM_TX          0x3005
-/* SLIMbus Rx port on channel 0. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX      0x4000
-/* SLIMbus Tx port on channel 0. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX      0x4001
-/* SLIMbus Rx port on channel 1. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX      0x4002
-/* SLIMbus Tx port on channel 1. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX      0x4003
-/* SLIMbus Rx port on channel 2. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX      0x4004
-/* SLIMbus Tx port on channel 2. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX      0x4005
-/* SLIMbus Rx port on channel 3. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX      0x4006
-/* SLIMbus Tx port on channel 3. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX      0x4007
-/* SLIMbus Rx port on channel 4. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX      0x4008
-/* SLIMbus Tx port on channel 4. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX      0x4009
-/* SLIMbus Rx port on channel 5. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX      0x400a
-/* SLIMbus Tx port on channel 5. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX      0x400b
-/* SLIMbus Rx port on channel 6. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX      0x400c
-/* SLIMbus Tx port on channel 6. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX      0x400d
-/* SLIMbus Rx port on channel 7. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_RX      0x400e
-/* SLIMbus Tx port on channel 7. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_TX      0x400f
-/* SLIMbus Rx port on channel 8. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_RX      0x4010
-/* SLIMbus Tx port on channel 8. */
-#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_TX      0x4011
-/* AFE Rx port for audio over Display port */
-#define AFE_PORT_ID_HDMI_OVER_DP_RX              0x6020
-/*USB AFE port */
-#define AFE_PORT_ID_USB_RX                       0x7000
-#define AFE_PORT_ID_USB_TX                       0x7001
-
-/* Generic pseudoport 1. */
-#define AFE_PORT_ID_PSEUDOPORT_01      0x8001
-/* Generic pseudoport 2. */
-#define AFE_PORT_ID_PSEUDOPORT_02      0x8002
-
-/* @xreflabel{hdr:AfePortIdPrimaryAuxPcmTx}
- * Primary Aux PCM Tx port ID.
- */
-#define AFE_PORT_ID_PRIMARY_PCM_TX      0x100B
-/* Pseudoport that corresponds to the voice Rx path.
- * For recording, the voice Rx path samples are written to this
- * port and consumed by the audio path.
- */
-
-#define AFE_PORT_ID_VOICE_RECORD_RX	0x8003
-
-/* Pseudoport that corresponds to the voice Tx path.
- * For recording, the voice Tx path samples are written to this
- * port and consumed by the audio path.
- */
-
-#define AFE_PORT_ID_VOICE_RECORD_TX	0x8004
-/* Pseudoport that corresponds to in-call voice delivery samples.
- * During in-call audio delivery, the audio path delivers samples
- * to this port from where the voice path delivers them on the
- * Rx path.
- */
-#define AFE_PORT_ID_VOICE2_PLAYBACK_TX  0x8002
-#define AFE_PORT_ID_VOICE_PLAYBACK_TX   0x8005
-
-#define AFE_PORT_ID_PRIMARY_TDM_RX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x00)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_1 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x02)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_2 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x04)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_3 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x06)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_4 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x08)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_5 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x0A)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_6 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x0C)
-#define AFE_PORT_ID_PRIMARY_TDM_RX_7 \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x0E)
-
-#define AFE_PORT_ID_PRIMARY_TDM_TX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x01)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_1 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x02)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_2 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x04)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_3 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x06)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_4 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x08)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_5 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x0A)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_6 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x0C)
-#define AFE_PORT_ID_PRIMARY_TDM_TX_7 \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x0E)
-
-#define AFE_PORT_ID_SECONDARY_TDM_RX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x10)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_1 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x02)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_2 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x04)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_3 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x06)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_4 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x08)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_5 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x0A)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_6 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x0C)
-#define AFE_PORT_ID_SECONDARY_TDM_RX_7 \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x0E)
-
-#define AFE_PORT_ID_SECONDARY_TDM_TX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x11)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_1 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x02)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_2 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x04)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_3 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x06)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_4 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x08)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_5 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x0A)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_6 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x0C)
-#define AFE_PORT_ID_SECONDARY_TDM_TX_7 \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x0E)
-
-#define AFE_PORT_ID_TERTIARY_TDM_RX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x20)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_1 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x02)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_2 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x04)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_3 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x06)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_4 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x08)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_5 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x0A)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_6 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x0C)
-#define AFE_PORT_ID_TERTIARY_TDM_RX_7 \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x0E)
-
-#define AFE_PORT_ID_TERTIARY_TDM_TX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x21)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_1 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x02)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_2 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x04)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_3 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x06)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_4 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x08)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_5 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x0A)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_6 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x0C)
-#define AFE_PORT_ID_TERTIARY_TDM_TX_7 \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x0E)
-
-#define AFE_PORT_ID_QUATERNARY_TDM_RX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x30)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_1 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x02)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_2 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x04)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_3 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x06)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_4 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x08)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_5 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x0A)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_6 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x0C)
-#define AFE_PORT_ID_QUATERNARY_TDM_RX_7 \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x0E)
-
-#define AFE_PORT_ID_QUATERNARY_TDM_TX \
-	(AFE_PORT_ID_TDM_PORT_RANGE_START + 0x31)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_1 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x02)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_2 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x04)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_3 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x06)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_4 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x08)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_5 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x0A)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_6 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x0C)
-#define AFE_PORT_ID_QUATERNARY_TDM_TX_7 \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x0E)
-
-#define AFE_PORT_ID_INVALID             0xFFFF
-
-#define AAC_ENC_MODE_AAC_LC 0x02
-#define AAC_ENC_MODE_AAC_P 0x05
-#define AAC_ENC_MODE_EAAC_P 0x1D
-
-#define AFE_PSEUDOPORT_CMD_START 0x000100cf
-struct afe_pseudoport_start_command {
-	struct apr_hdr hdr;
-	u16 port_id;		/* Pseudo Port 1 = 0x8000 */
-				/* Pseudo Port 2 = 0x8001 */
-				/* Pseudo Port 3 = 0x8002 */
-	u16 timing;		/* FTRT = 0 , AVTimer = 1, */
-} __packed;
-
-#define AFE_PSEUDOPORT_CMD_STOP 0x000100d0
-struct afe_pseudoport_stop_command {
-	struct apr_hdr hdr;
-	u16 port_id;		/* Pseudo Port 1 = 0x8000 */
-				/* Pseudo Port 2 = 0x8001 */
-				/* Pseudo Port 3 = 0x8002 */
-	u16 reserved;
-} __packed;
-
-
-#define AFE_MODULE_SIDETONE_IIR_FILTER	0x00010202
-#define AFE_PARAM_ID_ENABLE	0x00010203
-
-/*  Payload of the #AFE_PARAM_ID_ENABLE
- * parameter, which enables or
- * disables any module.
- * The fixed size of this structure is four bytes.
- */
-
-struct afe_mod_enable_param {
-	u16                  enable;
-	/* Enables (1) or disables (0) the module. */
-
-	u16                  reserved;
-	/* This field must be set to zero. */
-} __packed;
-
-/* ID of the configuration parameter used by the
- * #AFE_MODULE_SIDETONE_IIR_FILTER module.
- */
-#define AFE_PARAM_ID_SIDETONE_IIR_FILTER_CONFIG	0x00010204
-#define MAX_SIDETONE_IIR_DATA_SIZE 224
-#define MAX_NO_IIR_FILTER_STAGE    10
-
-struct afe_sidetone_iir_filter_config_params {
-	u16                  num_biquad_stages;
-/* Number of stages.
- * Supported values: Minimum of 5 and maximum of 10
- */
-
-	u16                  pregain;
-/* Pregain for the compensating filter response.
- * Supported values: Any number in Q13 format
- */
-	uint8_t   iir_config[MAX_SIDETONE_IIR_DATA_SIZE];
-} __packed;
-
-#define AFE_MODULE_LOOPBACK	0x00010205
-#define AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH	0x00010206
-
-/* Payload of the #AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH parameter,
- * which gets/sets loopback gain of a port to an Rx port.
- * The Tx port ID of the loopback is part of the set_param command.
- */
-
-/*  Payload of the #AFE_PORT_CMD_SET_PARAM_V2 command's
- * configuration/calibration settings for the AFE port.
- */
-struct afe_port_cmd_set_param_v2 {
-	u16 port_id;
-/* Port interface and direction (Rx or Tx) to start. */
-
-	u16 payload_size;
-/* Actual size of the payload in bytes.
- * This is used for parsing the parameter payload.
- * Supported values: > 0
- */
-
-u32 payload_address_lsw;
-/* LSW of 64 bit Payload address.
- * Address should be 32-byte,
- * 4kbyte aligned and must be contiguous memory.
- */
-
-u32 payload_address_msw;
-/* MSW of 64 bit Payload address.
- * In case of 32-bit shared memory address,
- * this field must be set to zero.
- * In case of 36-bit shared memory address,
- * bit-4 to bit-31 must be set to zero.
- * Address should be 32-byte, 4kbyte aligned
- * and must be contiguous memory.
- */
-
-u32 mem_map_handle;
-/* Memory map handle returned by
- * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
- * Supported Values:
- * - NULL -- Message. The parameter data is in-band.
- * - Non-NULL -- The parameter data is Out-band.Pointer to
- * the physical address
- * in shared memory of the payload data.
- * An optional field is available if parameter
- * data is in-band:
- * afe_param_data_v2 param_data[...].
- * For detailed payload content, see the
- * afe_port_param_data_v2 structure.
- */
-} __packed;
-
-#define AFE_PORT_CMD_SET_PARAM_V2	0x000100EF
-
-struct afe_port_param_data_v2 {
-	u32 module_id;
-/* ID of the module to be configured.
- * Supported values: Valid module ID
- */
-
-u32 param_id;
-/* ID of the parameter corresponding to the supported parameters
- * for the module ID.
- * Supported values: Valid parameter ID
- */
-
-u16 param_size;
-/* Actual size of the data for the
- * module_id/param_id pair. The size is a
- * multiple of four bytes.
- * Supported values: > 0
- */
-
-u16 reserved;
-/* This field must be set to zero.
- */
-} __packed;
-
-struct afe_loopback_gain_per_path_param {
-	struct apr_hdr	hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	u16                  rx_port_id;
-/* Rx port of the loopback. */
-
-u16                  gain;
-/* Loopback gain per path of the port.
- * Supported values: Any number in Q13 format
- */
-} __packed;
-
-/* Parameter ID used to configure and enable/disable the
- * loopback path. The difference with respect to the existing
- * API, AFE_PORT_CMD_LOOPBACK, is that it allows Rx port to be
- * configured as source port in loopback path. Port-id in
- * AFE_PORT_CMD_SET_PARAM cmd is the source port which can be
- * Tx or Rx port. In addition, we can configure the type of
- * routing mode to handle different use cases.
- */
-#define AFE_PARAM_ID_LOOPBACK_CONFIG	0x0001020B
-#define AFE_API_VERSION_LOOPBACK_CONFIG	0x1
-
-enum afe_loopback_routing_mode {
-	LB_MODE_DEFAULT = 1,
-	/* Regular loopback from source to destination port */
-	LB_MODE_SIDETONE,
-	/* Sidetone feed from Tx source to Rx destination port */
-	LB_MODE_EC_REF_VOICE_AUDIO,
-	/* Echo canceller reference, voice + audio + DTMF */
-	LB_MODE_EC_REF_VOICE
-	/* Echo canceller reference, voice alone */
-} __packed;
-
-/*  Payload of the #AFE_PARAM_ID_LOOPBACK_CONFIG ,
- * which enables/disables one AFE loopback.
- */
-struct afe_loopback_cfg_v1 {
-	struct apr_hdr	hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	u32		loopback_cfg_minor_version;
-/* Minor version used for tracking the version of the RMC module
- * configuration interface.
- * Supported values: #AFE_API_VERSION_LOOPBACK_CONFIG
- */
-	u16                  dst_port_id;
-	/* Destination Port Id. */
-	u16                  routing_mode;
-/* Specifies data path type from src to dest port.
- * Supported values:
- * #LB_MODE_DEFAULT
- * #LB_MODE_SIDETONE
- * #LB_MODE_EC_REF_VOICE_AUDIO
- * #LB_MODE_EC_REF_VOICE_A
- * #LB_MODE_EC_REF_VOICE
- */
-
-	u16                  enable;
-/* Specifies whether to enable (1) or
- * disable (0) an AFE loopback.
- */
-	u16                  reserved;
-/* Reserved for 32-bit alignment. This field must be set to 0.
- */
-
-} __packed;
-
-struct afe_loopback_sidetone_gain {
-	u16                  rx_port_id;
-	u16                  gain;
-} __packed;
-
-struct loopback_cfg_data {
-	u32                  loopback_cfg_minor_version;
-/* Minor version used for tracking the version of the RMC module
- * configuration interface.
- * Supported values: #AFE_API_VERSION_LOOPBACK_CONFIG
- */
-	u16                  dst_port_id;
-	/* Destination Port Id. */
-	u16                  routing_mode;
-/* Specifies data path type from src to dest port.
- * Supported values:
- * #LB_MODE_DEFAULT
- * #LB_MODE_SIDETONE
- * #LB_MODE_EC_REF_VOICE_AUDIO
- * #LB_MODE_EC_REF_VOICE_A
- * #LB_MODE_EC_REF_VOICE
- */
-
-	u16                  enable;
-/* Specifies whether to enable (1) or
- * disable (0) an AFE loopback.
- */
-	u16                  reserved;
-/* Reserved for 32-bit alignment. This field must be set to 0.
- */
-} __packed;
-
-struct afe_st_loopback_cfg_v1 {
-	struct apr_hdr                    hdr;
-	struct afe_port_cmd_set_param_v2  param;
-	struct afe_port_param_data_v2     gain_pdata;
-	struct afe_loopback_sidetone_gain gain_data;
-	struct afe_port_param_data_v2     cfg_pdata;
-	struct loopback_cfg_data          cfg_data;
-} __packed;
-
-struct afe_loopback_iir_cfg_v2 {
-	struct apr_hdr                          hdr;
-	struct afe_port_cmd_set_param_v2        param;
-	struct afe_port_param_data_v2           st_iir_enable_pdata;
-	struct afe_mod_enable_param             st_iir_mode_enable_data;
-	struct afe_port_param_data_v2           st_iir_filter_config_pdata;
-	struct afe_sidetone_iir_filter_config_params st_iir_filter_config_data;
-} __packed;
-#define AFE_MODULE_SPEAKER_PROTECTION	0x00010209
-#define AFE_PARAM_ID_SPKR_PROT_CONFIG	0x0001020a
-#define AFE_API_VERSION_SPKR_PROT_CONFIG	0x1
-#define AFE_SPKR_PROT_EXCURSIONF_LEN	512
-struct afe_spkr_prot_cfg_param_v1 {
-	u32       spkr_prot_minor_version;
-/*
- * Minor version used for tracking the version of the
- * speaker protection module configuration interface.
- * Supported values: #AFE_API_VERSION_SPKR_PROT_CONFIG
- */
-
-int16_t        win_size;
-/* Analysis and synthesis window size (nWinSize).
- * Supported values: 1024, 512, 256 samples
- */
-
-int16_t        margin;
-/* Allowable margin for excursion prediction,
- * in L16Q15 format. This is a
- * control parameter to allow
- * for overestimation of peak excursion.
- */
-
-int16_t        spkr_exc_limit;
-/* Speaker excursion limit, in L16Q15 format.*/
-
-int16_t        spkr_resonance_freq;
-/* Resonance frequency of the speaker; used
- * to define a frequency range
- * for signal modification.
- *
- * Supported values: 0 to 2000 Hz
- */
-
-int16_t        limhresh;
-/* Threshold of the hard limiter; used to
- * prevent overshooting beyond a
- * signal level that was set by the limiter
- * prior to speaker protection.
- * Supported values: 0 to 32767
- */
-
-int16_t        hpf_cut_off_freq;
-/* High pass filter cutoff frequency.
- * Supported values: 100, 200, 300 Hz
- */
-
-int16_t        hpf_enable;
-/* Specifies whether the high pass filter
- * is enabled (0) or disabled (1).
- */
-
-int16_t        reserved;
-/* This field must be set to zero. */
-
-int32_t        amp_gain;
-/* Amplifier gain in L32Q15 format.
- * This is the RMS voltage at the
- * loudspeaker when a 0dBFS tone
- * is played in the digital domain.
- */
-
-int16_t        excursionf[AFE_SPKR_PROT_EXCURSIONF_LEN];
-/* Array of the excursion transfer function.
- * The peak excursion of the
- * loudspeaker diaphragm is
- * measured in millimeters for 1 Vrms Sine
- * tone at all FFT bin frequencies.
- * Supported values: Q15 format
- */
-} __packed;
-
-
-#define AFE_SERVICE_CMD_REGISTER_RT_PORT_DRIVER	0x000100E0
-
-/*  Payload of the #AFE_SERVICE_CMD_REGISTER_RT_PORT_DRIVER
- * command, which registers a real-time port driver
- * with the AFE service.
- */
-struct afe_service_cmd_register_rt_port_driver {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Port ID with which the real-time driver exchanges data
- * (registers for events).
- * Supported values: #AFE_PORT_ID_RT_PROXY_PORT_RANGE_START to
- * #AFE_PORT_ID_RT_PROXY_PORT_RANGE_END
- */
-
-	u16                  reserved;
-	/* This field must be set to zero. */
-} __packed;
-
-#define AFE_SERVICE_CMD_UNREGISTER_RT_PORT_DRIVER	0x000100E1
-
-/*  Payload of the #AFE_SERVICE_CMD_UNREGISTER_RT_PORT_DRIVER
- * command, which unregisters a real-time port driver from
- * the AFE service.
- */
-struct afe_service_cmd_unregister_rt_port_driver {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Port ID from which the real-time
- * driver unregisters for events.
- * Supported values: #AFE_PORT_ID_RT_PROXY_PORT_RANGE_START to
- * #AFE_PORT_ID_RT_PROXY_PORT_RANGE_END
- */
-
-	u16                  reserved;
-	/* This field must be set to zero.	*/
-} __packed;
-
-#define AFE_EVENT_RT_PROXY_PORT_STATUS	0x00010105
-#define AFE_EVENTYPE_RT_PROXY_PORT_START	0
-#define AFE_EVENTYPE_RT_PROXY_PORT_STOP	1
-#define AFE_EVENTYPE_RT_PROXY_PORT_LOW_WATER_MARK	2
-#define AFE_EVENTYPE_RT_PROXY_PORT_HIGH_WATER_MARK	3
-#define AFE_EVENTYPE_RT_PROXY_PORT_INVALID	0xFFFF
-
-/*  Payload of the #AFE_EVENT_RT_PROXY_PORT_STATUS
- * message, which sends an event from the AFE service
- * to a registered client.
- */
-struct afe_event_rt_proxy_port_status {
-	u16                  port_id;
-/* Port ID to which the event is sent.
- * Supported values: #AFE_PORT_ID_RT_PROXY_PORT_RANGE_START to
- * #AFE_PORT_ID_RT_PROXY_PORT_RANGE_END
- */
-
-	u16                  eventype;
-/* Type of event.
- * Supported values:
- * - #AFE_EVENTYPE_RT_PROXY_PORT_START
- * - #AFE_EVENTYPE_RT_PROXY_PORT_STOP
- * - #AFE_EVENTYPE_RT_PROXY_PORT_LOW_WATER_MARK
- * - #AFE_EVENTYPE_RT_PROXY_PORT_HIGH_WATER_MARK
- */
-} __packed;
-
-#define AFE_PORT_DATA_CMD_RT_PROXY_PORT_WRITE_V2 0x000100ED
-
-struct afe_port_data_cmd_rt_proxy_port_write_v2 {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Tx (mic) proxy port ID with which the real-time
- * driver exchanges data.
- * Supported values: #AFE_PORT_ID_RT_PROXY_PORT_RANGE_START to
- * #AFE_PORT_ID_RT_PROXY_PORT_RANGE_END
- */
-
-	u16                  reserved;
-	/* This field must be set to zero. */
-
-	u32                  buffer_address_lsw;
-/* LSW Address of the buffer containing the
- * data from the real-time source
- * device on a client.
- */
-
-	u32                  buffer_address_msw;
-/* MSW Address of the buffer containing the
- * data from the real-time source
- * device on a client.
- */
-
-	u32					mem_map_handle;
-/* A memory map handle encapsulating shared memory
- * attributes is returned if
- * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS
- * command is successful.
- * Supported Values:
- * - Any 32 bit value
- */
-
-	u32                  available_bytes;
-/* Number of valid bytes available
- * in the buffer (including all
- * channels: number of bytes per
- * channel = availableBytesumChannels).
- * Supported values: > 0
- *
- * This field must be equal to the frame
- * size specified in the #AFE_PORT_AUDIO_IF_CONFIG
- * command that was sent to configure this
- * port.
- */
-} __packed;
-
-#define AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2	0x000100EE
-
-/*  Payload of the
- * #AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2 command, which
- * delivers an empty buffer to the AFE service. On
- * acknowledgment, data is filled in the buffer.
- */
-struct afe_port_data_cmd_rt_proxy_port_read_v2 {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Rx proxy port ID with which the real-time
- * driver exchanges data.
- * Supported values: #AFE_PORT_ID_RT_PROXY_PORT_RANGE_START to
- * #AFE_PORT_ID_RT_PROXY_PORT_RANGE_END
- * (This must be an Rx (speaker) port.)
- */
-
-	u16                  reserved;
-	/* This field must be set to zero. */
-
-	u32                  buffer_address_lsw;
-/* LSW Address of the buffer containing the data sent from the AFE
- * service to a real-time sink device on the client.
- */
-
-
-	u32                  buffer_address_msw;
-/* MSW Address of the buffer containing the data sent from the AFE
- * service to a real-time sink device on the client.
- */
-
-		u32				mem_map_handle;
-/* A memory map handle encapsulating shared memory attributes is
- * returned if AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS command is
- * successful.
- * Supported Values:
- * - Any 32 bit value
- */
-
-	u32                  available_bytes;
-/* Number of valid bytes available in the buffer (including all
- * channels).
- * Supported values: > 0
- * This field must be equal to the frame size specified in the
- * #AFE_PORT_AUDIO_IF_CONFIG command that was sent to configure
- * this port.
- */
-} __packed;
-
-/* This module ID is related to device configuring like I2S,PCM,
- * HDMI, SLIMBus etc. This module supports following parameter ids.
- * - #AFE_PARAM_ID_I2S_CONFIG
- * - #AFE_PARAM_ID_PCM_CONFIG
- * - #AFE_PARAM_ID_DIGI_MIC_CONFIG
- * - #AFE_PARAM_ID_HDMI_CONFIG
- * - #AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG
- * - #AFE_PARAM_ID_SLIMBUS_CONFIG
- * - #AFE_PARAM_ID_RT_PROXY_CONFIG
- */
-
-#define AFE_MODULE_AUDIO_DEV_INTERFACE    0x0001020C
-#define AFE_PORT_SAMPLE_RATE_8K           8000
-#define AFE_PORT_SAMPLE_RATE_16K          16000
-#define AFE_PORT_SAMPLE_RATE_48K          48000
-#define AFE_PORT_SAMPLE_RATE_96K          96000
-#define AFE_PORT_SAMPLE_RATE_176P4K       176400
-#define AFE_PORT_SAMPLE_RATE_192K         192000
-#define AFE_PORT_SAMPLE_RATE_352P8K       352800
-#define AFE_LINEAR_PCM_DATA				0x0
-#define AFE_NON_LINEAR_DATA				0x1
-#define AFE_LINEAR_PCM_DATA_PACKED_60958 0x2
-#define AFE_NON_LINEAR_DATA_PACKED_60958 0x3
-#define AFE_GENERIC_COMPRESSED           0x8
-
-/* This param id is used to configure I2S interface */
-#define AFE_PARAM_ID_I2S_CONFIG	0x0001020D
-#define AFE_API_VERSION_I2S_CONFIG	0x1
-/*	Enumeration for setting the I2S configuration
- * channel_mode parameter to
- * serial data wire number 1-3 (SD3).
- */
-#define AFE_PORT_I2S_SD0                     0x1
-#define AFE_PORT_I2S_SD1                     0x2
-#define AFE_PORT_I2S_SD2                     0x3
-#define AFE_PORT_I2S_SD3                     0x4
-#define AFE_PORT_I2S_QUAD01                  0x5
-#define AFE_PORT_I2S_QUAD23                  0x6
-#define AFE_PORT_I2S_6CHS                    0x7
-#define AFE_PORT_I2S_8CHS                    0x8
-#define AFE_PORT_I2S_MONO                    0x0
-#define AFE_PORT_I2S_STEREO                  0x1
-#define AFE_PORT_CONFIG_I2S_WS_SRC_EXTERNAL  0x0
-#define AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL  0x1
-
-/*  Payload of the #AFE_PARAM_ID_I2S_CONFIG
- * command's (I2S configuration
- * parameter).
- */
-struct afe_param_id_i2s_cfg {
-	u32                  i2s_cfg_minor_version;
-/* Minor version used for tracking the version of the I2S
- * configuration interface.
- * Supported values: #AFE_API_VERSION_I2S_CONFIG
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16, 24
- */
-
-	u16                  channel_mode;
-/* I2S lines and multichannel operation.
- * Supported values:
- * - #AFE_PORT_I2S_SD0
- * - #AFE_PORT_I2S_SD1
- * - #AFE_PORT_I2S_SD2
- * - #AFE_PORT_I2S_SD3
- * - #AFE_PORT_I2S_QUAD01
- * - #AFE_PORT_I2S_QUAD23
- * - #AFE_PORT_I2S_6CHS
- * - #AFE_PORT_I2S_8CHS
- */
-
-	u16                  mono_stereo;
-/* Specifies mono or stereo. This applies only when
- * a single I2S line is used.
- * Supported values:
- * - #AFE_PORT_I2S_MONO
- * - #AFE_PORT_I2S_STEREO
- */
-
-	u16                  ws_src;
-/* Word select source: internal or external.
- * Supported values:
- * - #AFE_PORT_CONFIG_I2S_WS_SRC_EXTERNAL
- * - #AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL
- */
-
-	u32                  sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- * - #AFE_PORT_SAMPLE_RATE_48K
- * - #AFE_PORT_SAMPLE_RATE_96K
- * - #AFE_PORT_SAMPLE_RATE_192K
- */
-
-	u16					data_format;
-/* data format
- * Supported values:
- * - #LINEAR_PCM_DATA
- * - #NON_LINEAR_DATA
- * - #LINEAR_PCM_DATA_PACKED_IN_60958
- * - #NON_LINEAR_DATA_PACKED_IN_60958
- */
-		u16                  reserved;
-	/* This field must be set to zero. */
-} __packed;
-
-/*
- * This param id is used to configure PCM interface
- */
-
-#define AFE_API_VERSION_SPDIF_CONFIG 0x1
-#define AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG 0x1
-#define AFE_API_VERSION_SPDIF_CLK_CONFIG 0x1
-#define AFE_CH_STATUS_A 1
-#define AFE_CH_STATUS_B 2
-
-#define AFE_PARAM_ID_SPDIF_CONFIG 0x00010244
-#define AFE_PARAM_ID_CH_STATUS_CONFIG 0x00010245
-#define AFE_PARAM_ID_SPDIF_CLK_CONFIG 0x00010246
-
-#define AFE_PORT_CLK_ROOT_LPAPLL 0x3
-#define AFE_PORT_CLK_ROOT_LPAQ6PLL   0x4
-
-struct afe_param_id_spdif_cfg {
-/* Minor version used for tracking the version of the SPDIF
- * configuration interface.
- * Supported values: #AFE_API_VERSION_SPDIF_CONFIG
- */
-	u32	spdif_cfg_minor_version;
-
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_22_05K
- * - #AFE_PORT_SAMPLE_RATE_32K
- * - #AFE_PORT_SAMPLE_RATE_44_1K
- * - #AFE_PORT_SAMPLE_RATE_48K
- * - #AFE_PORT_SAMPLE_RATE_96K
- * - #AFE_PORT_SAMPLE_RATE_176_4K
- * - #AFE_PORT_SAMPLE_RATE_192K
- */
-	u32	sample_rate;
-
-/* data format
- * Supported values:
- * - #AFE_LINEAR_PCM_DATA
- * - #AFE_NON_LINEAR_DATA
- */
-	u16	data_format;
-/* Number of channels supported by the port
- * - PCM - 1, Compressed Case - 2
- */
-	u16	num_channels;
-/* Bit width of the sample.
- * Supported values: 16, 24
- */
-	u16	bit_width;
-/* This field must be set to zero. */
-	u16	reserved;
-} __packed;
-
-struct afe_param_id_spdif_ch_status_cfg {
-	u32 ch_status_cfg_minor_version;
-/* Minor version used for tracking the version of channel
- * status configuration. Current supported version is 1
- */
-
-	u32 status_type;
-/* Indicate if the channel status is for channel A or B
- * Supported values:
- * - #AFE_CH_STATUS_A
- * - #AFE_CH_STATUS_B
- */
-
-	u8 status_bits[24];
-/* Channel status - 192 bits for channel
- * Byte ordering as defined by IEC60958-3
- */
-
-	u8 status_mask[24];
-/* Channel status with mask bits 1 will be applied.
- * Byte ordering as defined by IEC60958-3
- */
-} __packed;
-
-struct afe_param_id_spdif_clk_cfg {
-	u32 clk_cfg_minor_version;
-/* Minor version used for tracking the version of SPDIF
- * interface clock configuration. Current supported version
- * is 1
- */
-
-	u32 clk_value;
-/* Specifies the clock frequency in Hz to set
- * Supported values:
- * 0 - Disable the clock
- * 2 (byphase) * 32 (60958 subframe size) * sampling rate * 2
- * (channels A and B)
- */
-
-	u32 clk_root;
-/* Specifies SPDIF root clk source
- * Supported Values:
- * - #AFE_PORT_CLK_ROOT_LPAPLL
- * - #AFE_PORT_CLK_ROOT_LPAQ6PLL
- */
-} __packed;
-
-struct afe_spdif_clk_config_command {
-	struct apr_hdr                    hdr;
-	struct afe_port_cmd_set_param_v2  param;
-	struct afe_port_param_data_v2     pdata;
-	struct afe_param_id_spdif_clk_cfg clk_cfg;
-} __packed;
-
-struct afe_spdif_chstatus_config_command {
-	struct apr_hdr                    hdr;
-	struct afe_port_cmd_set_param_v2  param;
-	struct afe_port_param_data_v2     pdata;
-	struct afe_param_id_spdif_ch_status_cfg ch_status;
-} __packed;
-
-struct afe_spdif_port_config {
-	struct afe_param_id_spdif_cfg            cfg;
-	struct afe_param_id_spdif_ch_status_cfg  ch_status;
-} __packed;
-
-#define AFE_PARAM_ID_PCM_CONFIG        0x0001020E
-#define AFE_API_VERSION_PCM_CONFIG	0x1
-/* Enumeration for the auxiliary PCM synchronization signal
- * provided by an external source.
- */
-
-#define AFE_PORT_PCM_SYNC_SRC_EXTERNAL 0x0
-/*	Enumeration for the auxiliary PCM synchronization signal
- * provided by an internal source.
- */
-#define AFE_PORT_PCM_SYNC_SRC_INTERNAL  0x1
-/*	Enumeration for the PCM configuration aux_mode parameter,
- * which configures the auxiliary PCM interface to use
- * short synchronization.
- */
-#define AFE_PORT_PCM_AUX_MODE_PCM  0x0
-/*
- * Enumeration for the PCM configuration aux_mode parameter,
- * which configures the auxiliary PCM interface to use long
- * synchronization.
- */
-#define AFE_PORT_PCM_AUX_MODE_AUX    0x1
-/*
- * Enumeration for setting the PCM configuration frame to 8.
- */
-#define AFE_PORT_PCM_BITS_PER_FRAME_8  0x0
-/*
- * Enumeration for setting the PCM configuration frame to 16.
- */
-#define AFE_PORT_PCM_BITS_PER_FRAME_16   0x1
-
-/*	Enumeration for setting the PCM configuration frame to 32.*/
-#define AFE_PORT_PCM_BITS_PER_FRAME_32 0x2
-
-/*	Enumeration for setting the PCM configuration frame to 64.*/
-#define AFE_PORT_PCM_BITS_PER_FRAME_64   0x3
-
-/*	Enumeration for setting the PCM configuration frame to 128.*/
-#define AFE_PORT_PCM_BITS_PER_FRAME_128 0x4
-
-/*	Enumeration for setting the PCM configuration frame to 256.*/
-#define AFE_PORT_PCM_BITS_PER_FRAME_256 0x5
-
-/*	Enumeration for setting the PCM configuration
- * quantype parameter to A-law with no padding.
- */
-#define AFE_PORT_PCM_ALAW_NOPADDING 0x0
-
-/* Enumeration for setting the PCM configuration quantype
- * parameter to mu-law with no padding.
- */
-#define AFE_PORT_PCM_MULAW_NOPADDING 0x1
-/*	Enumeration for setting the PCM configuration quantype
- * parameter to linear with no padding.
- */
-#define AFE_PORT_PCM_LINEAR_NOPADDING 0x2
-/*	Enumeration for setting the PCM configuration quantype
- * parameter to A-law with padding.
- */
-#define AFE_PORT_PCM_ALAW_PADDING  0x3
-/*	Enumeration for setting the PCM configuration quantype
- * parameter to mu-law with padding.
- */
-#define AFE_PORT_PCM_MULAW_PADDING 0x4
-/*	Enumeration for setting the PCM configuration quantype
- * parameter to linear with padding.
- */
-#define AFE_PORT_PCM_LINEAR_PADDING 0x5
-/*	Enumeration for disabling the PCM configuration
- * ctrl_data_out_enable parameter.
- * The PCM block is the only master.
- */
-#define AFE_PORT_PCM_CTRL_DATA_OE_DISABLE 0x0
-/*
- * Enumeration for enabling the PCM configuration
- * ctrl_data_out_enable parameter. The PCM block shares
- * the signal with other masters.
- */
-#define AFE_PORT_PCM_CTRL_DATA_OE_ENABLE  0x1
-
-/*  Payload of the #AFE_PARAM_ID_PCM_CONFIG command's
- * (PCM configuration parameter).
- */
-
-struct afe_param_id_pcm_cfg {
-	u32                  pcm_cfg_minor_version;
-/* Minor version used for tracking the version of the AUX PCM
- * configuration interface.
- * Supported values: #AFE_API_VERSION_PCM_CONFIG
- */
-
-	u16                  aux_mode;
-/* PCM synchronization setting.
- * Supported values:
- * - #AFE_PORT_PCM_AUX_MODE_PCM
- * - #AFE_PORT_PCM_AUX_MODE_AUX
- */
-
-	u16                  sync_src;
-/* Synchronization source.
- * Supported values:
- * - #AFE_PORT_PCM_SYNC_SRC_EXTERNAL
- * - #AFE_PORT_PCM_SYNC_SRC_INTERNAL
- */
-
-	u16                  frame_setting;
-/* Number of bits per frame.
- * Supported values:
- * - #AFE_PORT_PCM_BITS_PER_FRAME_8
- * - #AFE_PORT_PCM_BITS_PER_FRAME_16
- * - #AFE_PORT_PCM_BITS_PER_FRAME_32
- * - #AFE_PORT_PCM_BITS_PER_FRAME_64
- * - #AFE_PORT_PCM_BITS_PER_FRAME_128
- * - #AFE_PORT_PCM_BITS_PER_FRAME_256
- */
-
-	u16                  quantype;
-/* PCM quantization type.
- * Supported values:
- * - #AFE_PORT_PCM_ALAW_NOPADDING
- * - #AFE_PORT_PCM_MULAW_NOPADDING
- * - #AFE_PORT_PCM_LINEAR_NOPADDING
- * - #AFE_PORT_PCM_ALAW_PADDING
- * - #AFE_PORT_PCM_MULAW_PADDING
- * - #AFE_PORT_PCM_LINEAR_PADDING
- */
-
-	u16                  ctrl_data_out_enable;
-/* Specifies whether the PCM block shares the data-out
- * signal to the drive with other masters.
- * Supported values:
- * - #AFE_PORT_PCM_CTRL_DATA_OE_DISABLE
- * - #AFE_PORT_PCM_CTRL_DATA_OE_ENABLE
- */
-		u16                  reserved;
-	/* This field must be set to zero. */
-
-	u32                  sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16
- */
-
-	u16                  num_channels;
-/* Number of channels.
- * Supported values: 1 to 4
- */
-
-	u16                  slot_number_mapping[4];
-/* Specifies the slot number for the each channel in
- * multi channel scenario.
- * Supported values: 1 to 32
- */
-} __packed;
-
-/*
- * This param id is used to configure DIGI MIC interface
- */
-#define AFE_PARAM_ID_DIGI_MIC_CONFIG	0x0001020F
-/*  This version information is used to handle the new
- *   additions to the config interface in future in backward
- *   compatible manner.
- */
-#define AFE_API_VERSION_DIGI_MIC_CONFIG 0x1
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to left 0.
- */
-
-#define AFE_PORT_DIGI_MIC_MODE_LEFT0  0x1
-
-/*Enumeration for setting the digital mic configuration
- * channel_mode parameter to right 0.
- */
-
-
-#define AFE_PORT_DIGI_MIC_MODE_RIGHT0  0x2
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to left 1.
- */
-
-#define AFE_PORT_DIGI_MIC_MODE_LEFT1  0x3
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to right 1.
- */
-
-#define AFE_PORT_DIGI_MIC_MODE_RIGHT1 0x4
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to stereo 0.
- */
-#define AFE_PORT_DIGI_MIC_MODE_STEREO0  0x5
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to stereo 1.
- */
-
-
-#define AFE_PORT_DIGI_MIC_MODE_STEREO1    0x6
-
-/* Enumeration for setting the digital mic configuration
- * channel_mode parameter to quad.
- */
-
-#define AFE_PORT_DIGI_MIC_MODE_QUAD     0x7
-
-/*  Payload of the #AFE_PARAM_ID_DIGI_MIC_CONFIG command's
- * (DIGI MIC configuration
- * parameter).
- */
-struct afe_param_id_digi_mic_cfg {
-	u32                  digi_mic_cfg_minor_version;
-/* Minor version used for tracking the version of the DIGI Mic
- * configuration interface.
- * Supported values: #AFE_API_VERSION_DIGI_MIC_CONFIG
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16
- */
-
-	u16                  channel_mode;
-/* Digital mic and multichannel operation.
- * Supported values:
- * - #AFE_PORT_DIGI_MIC_MODE_LEFT0
- * - #AFE_PORT_DIGI_MIC_MODE_RIGHT0
- * - #AFE_PORT_DIGI_MIC_MODE_LEFT1
- * - #AFE_PORT_DIGI_MIC_MODE_RIGHT1
- * - #AFE_PORT_DIGI_MIC_MODE_STEREO0
- * - #AFE_PORT_DIGI_MIC_MODE_STEREO1
- * - #AFE_PORT_DIGI_MIC_MODE_QUAD
- */
-
-	u32                  sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- * - #AFE_PORT_SAMPLE_RATE_48K
- */
-} __packed;
-
-/* This param id is used to configure HDMI interface */
-#define AFE_PARAM_ID_HDMI_CONFIG     0x00010210
-
-/* This version information is used to handle the new
- * additions to the config interface in future in backward
- * compatible manner.
- */
-#define AFE_API_VERSION_HDMI_CONFIG 0x1
-
-/* Payload of the #AFE_PARAM_ID_HDMI_CONFIG command,
- * which configures a multichannel HDMI audio interface.
- */
-struct afe_param_id_hdmi_multi_chan_audio_cfg {
-	u32                  hdmi_cfg_minor_version;
-/* Minor version used for tracking the version of the HDMI
- * configuration interface.
- * Supported values: #AFE_API_VERSION_HDMI_CONFIG
- */
-
-u16                  datatype;
-/* data type
- * Supported values:
- * - #LINEAR_PCM_DATA
- * - #NON_LINEAR_DATA
- * - #LINEAR_PCM_DATA_PACKED_IN_60958
- * - #NON_LINEAR_DATA_PACKED_IN_60958
- */
-
-u16                  channel_allocation;
-/* HDMI channel allocation information for programming an HDMI
- * frame. The default is 0 (Stereo).
- *
- * This information is defined in the HDMI standard, CEA 861-D
- * (refer to @xhyperref{S1,[S1]}). The number of channels is also
- * inferred from this parameter.
- */
-
-
-u32                  sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- * - #AFE_PORT_SAMPLE_RATE_48K
- * - #AFE_PORT_SAMPLE_RATE_96K
- * - 22050, 44100, 176400 for compressed streams
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16, 24
- */
-		u16                  reserved;
-	/* This field must be set to zero. */
-} __packed;
-
-/* This param id is used to configure BT or FM(RIVA) interface */
-#define AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG  0x00010211
-
-/* This version information is used to handle the new
- * additions to the config interface in future in backward
- * compatible manner.
- */
-#define AFE_API_VERSION_INTERNAL_BT_FM_CONFIG	0x1
-
-/* Payload of the #AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG
- * command's BT voice/BT audio/FM configuration parameter.
- */
-struct afe_param_id_internal_bt_fm_cfg {
-	u32                  bt_fm_cfg_minor_version;
-/* Minor version used for tracking the version of the BT and FM
- * configuration interface.
- * Supported values: #AFE_API_VERSION_INTERNAL_BT_FM_CONFIG
- */
-
-	u16                  num_channels;
-/* Number of channels.
- * Supported values: 1 to 2
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16
- */
-
-	u32                  sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K (only for BTSCO)
- * - #AFE_PORT_SAMPLE_RATE_16K (only for BTSCO)
- * - #AFE_PORT_SAMPLE_RATE_48K (FM and A2DP)
- */
-} __packed;
-
-/* This param id is used to configure SLIMBUS interface using
- * shared channel approach.
- */
-
-
-#define AFE_PARAM_ID_SLIMBUS_CONFIG    0x00010212
-
-/* This version information is used to handle the new
- * additions to the config interface in future in backward
- * compatible manner.
- */
-#define AFE_API_VERSION_SLIMBUS_CONFIG 0x1
-
-/* Enumeration for setting SLIMbus device ID 1. */
-#define AFE_SLIMBUS_DEVICE_1           0x0
-
-/* Enumeration for setting SLIMbus device ID 2. */
-#define AFE_SLIMBUS_DEVICE_2          0x1
-
-/* Enumeration for setting the SLIMbus data formats. */
-#define AFE_SB_DATA_FORMAT_NOT_INDICATED 0x0
-
-/* Enumeration for setting the maximum number of streams per
- * device.
- */
-
-#define AFE_PORT_MAX_AUDIO_CHAN_CNT	0x8
-
-/* Payload of the #AFE_PORT_CMD_SLIMBUS_CONFIG command's SLIMbus
- * port configuration parameter.
- */
-
-struct afe_param_id_slimbus_cfg {
-	u32                  sb_cfg_minor_version;
-/* Minor version used for tracking the version of the SLIMBUS
- * configuration interface.
- * Supported values: #AFE_API_VERSION_SLIMBUS_CONFIG
- */
-
-	u16                  slimbus_dev_id;
-/* SLIMbus hardware device ID, which is required to handle
- * multiple SLIMbus hardware blocks.
- * Supported values: - #AFE_SLIMBUS_DEVICE_1 - #AFE_SLIMBUS_DEVICE_2
- */
-
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16, 24
- */
-
-	u16                  data_format;
-/* Data format supported by the SLIMbus hardware. The default is
- * 0 (#AFE_SB_DATA_FORMAT_NOT_INDICATED), which indicates the
- * hardware does not perform any format conversions before the data
- * transfer.
- */
-
-
-	u16                  num_channels;
-/* Number of channels.
- * Supported values: 1 to #AFE_PORT_MAX_AUDIO_CHAN_CNT
- */
-
-	u8  shared_ch_mapping[AFE_PORT_MAX_AUDIO_CHAN_CNT];
-/* Mapping of shared channel IDs (128 to 255) to which the
- * master port is to be connected.
- * Shared_channel_mapping[i] represents the shared channel assigned
- * for audio channel i in multichannel audio data.
- */
-
-	u32              sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- * - #AFE_PORT_SAMPLE_RATE_48K
- * - #AFE_PORT_SAMPLE_RATE_96K
- * - #AFE_PORT_SAMPLE_RATE_192K
- */
-} __packed;
-
-
-/* ID of the parameter used by AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS to configure
- * USB audio device parameter. It should be used with
- * AFE_MODULE_AUDIO_DEV_INTERFACE
- */
-#define AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS    0x000102A5
-
-
-/* ID of the parameter used to set the endianness value for the
- * USB audio device. It should be used with
- * AFE_MODULE_AUDIO_DEV_INTERFACE
- */
-#define AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT 0x000102AA
-
-/* Minor version used for tracking USB audio  configuration */
-#define AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG 0x1
-
-/* Payload of the AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS parameter used by
- * AFE_MODULE_AUDIO_DEV_INTERFACE.
- */
-struct afe_param_id_usb_audio_dev_params {
-/* Minor version used for tracking USB audio device parameter.
- * Supported values: AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG
- */
-	u32                  cfg_minor_version;
-/* Token of actual end USB aduio device */
-	u32                  dev_token;
-} __packed;
-
-struct afe_param_id_usb_audio_dev_lpcm_fmt {
-/* Minor version used for tracking USB audio device parameter.
- * Supported values: AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG
- */
-	u32                  cfg_minor_version;
-/* Endianness of actual end USB audio device */
-	u32                  endian;
-} __packed;
-
-/* ID of the parameter used by AFE_PARAM_ID_USB_AUDIO_CONFIG to configure
- * USB audio interface. It should be used with AFE_MODULE_AUDIO_DEV_INTERFACE
- */
-#define AFE_PARAM_ID_USB_AUDIO_CONFIG    0x000102A4
-
-/* Payload of the AFE_PARAM_ID_USB_AUDIO_CONFIG parameter used by
- * AFE_MODULE_AUDIO_DEV_INTERFACE.
- */
-struct afe_param_id_usb_audio_cfg {
-/* Minor version used for tracking USB audio device configuration.
- * Supported values: AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG
- */
-	u32                  cfg_minor_version;
-/* Sampling rate of the port.
- * Supported values:
- * - AFE_PORT_SAMPLE_RATE_8K
- * - AFE_PORT_SAMPLE_RATE_11025
- * - AFE_PORT_SAMPLE_RATE_12K
- * - AFE_PORT_SAMPLE_RATE_16K
- * - AFE_PORT_SAMPLE_RATE_22050
- * - AFE_PORT_SAMPLE_RATE_24K
- * - AFE_PORT_SAMPLE_RATE_32K
- * - AFE_PORT_SAMPLE_RATE_44P1K
- * - AFE_PORT_SAMPLE_RATE_48K
- * - AFE_PORT_SAMPLE_RATE_96K
- * - AFE_PORT_SAMPLE_RATE_192K
- */
-	u32                  sample_rate;
-/* Bit width of the sample.
- * Supported values: 16, 24
- */
-	u16                  bit_width;
-/* Number of channels.
- * Supported values: 1 and 2
- */
-	u16                  num_channels;
-/* Data format supported by the USB. The supported value is
- * 0 (#AFE_USB_AUDIO_DATA_FORMAT_LINEAR_PCM).
- */
-	u16                  data_format;
-/* this field must be 0 */
-	u16                  reserved;
-/* device token of actual end USB aduio device */
-	u32                  dev_token;
-/* endianness of this interface */
-	u32                   endian;
-} __packed;
-
-struct afe_usb_audio_dev_param_command {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	union {
-		struct afe_param_id_usb_audio_dev_params usb_dev;
-		struct afe_param_id_usb_audio_dev_lpcm_fmt lpcm_fmt;
-	};
-} __packed;
-
-/* This param id is used to configure Real Time Proxy interface. */
-#define AFE_PARAM_ID_RT_PROXY_CONFIG 0x00010213
-
-/* This version information is used to handle the new
- * additions to the config interface in future in backward
- * compatible manner.
- */
-#define AFE_API_VERSION_RT_PROXY_CONFIG 0x1
-
-/*  Payload of the #AFE_PARAM_ID_RT_PROXY_CONFIG
- * command (real-time proxy port configuration parameter).
- */
-struct afe_param_id_rt_proxy_port_cfg {
-	u32                  rt_proxy_cfg_minor_version;
-/* Minor version used for tracking the version of rt-proxy
- * config interface.
- */
-
-	u16                  bit_width;
-/* Bit width of the sample.
- * Supported values: 16
- */
-
-	u16                  interleaved;
-/* Specifies whether the data exchanged between the AFE
- * interface and real-time port is interleaved.
- * Supported values: - 0 -- Non-interleaved (samples from each
- * channel are contiguous in the buffer) - 1 -- Interleaved
- * (corresponding samples from each input channel are interleaved
- * within the buffer)
- */
-
-
-	u16                  frame_size;
-/* Size of the frames that are used for PCM exchanges with this
- * port.
- * Supported values: > 0, in bytes
- * For example, 5 ms buffers of 16 bits and 16 kHz stereo samples
- * is 5 ms * 16 samples/ms * 2 bytes/sample * 2 channels = 320
- * bytes.
- */
-	u16                  jitter_allowance;
-/* Configures the amount of jitter that the port will allow.
- * Supported values: > 0
- * For example, if +/-10 ms of jitter is anticipated in the timing
- * of sending frames to the port, and the configuration is 16 kHz
- * mono with 16-bit samples, this field is 10 ms * 16 samples/ms * 2
- * bytes/sample = 320.
- */
-
-	u16                  low_water_mark;
-/* Low watermark in bytes (including all channels).
- * Supported values:
- * - 0 -- Do not send any low watermark events
- * - > 0 -- Low watermark for triggering an event
- * If the number of bytes in an internal circular buffer is lower
- * than this low_water_mark parameter, a LOW_WATER_MARK event is
- * sent to applications (via the #AFE_EVENT_RT_PROXY_PORT_STATUS
- * event).
- * Use of watermark events is optional for debugging purposes.
- */
-
-	u16                  high_water_mark;
-/* High watermark in bytes (including all channels).
- * Supported values:
- * - 0 -- Do not send any high watermark events
- * - > 0 -- High watermark for triggering an event
- * If the number of bytes in an internal circular buffer exceeds
- * TOTAL_CIRC_BUF_SIZE minus high_water_mark, a high watermark event
- * is sent to applications (via the #AFE_EVENT_RT_PROXY_PORT_STATUS
- * event).
- * The use of watermark events is optional and for debugging
- * purposes.
- */
-
-
-	u32					sample_rate;
-/* Sampling rate of the port.
- * Supported values:
- * - #AFE_PORT_SAMPLE_RATE_8K
- * - #AFE_PORT_SAMPLE_RATE_16K
- * - #AFE_PORT_SAMPLE_RATE_48K
- */
-
-	u16                  num_channels;
-/* Number of channels.
- * Supported values: 1 to #AFE_PORT_MAX_AUDIO_CHAN_CNT
- */
-
-	u16                  reserved;
-	/* For 32 bit alignment. */
-} __packed;
-
-
-/* This param id is used to configure the Pseudoport interface */
-
-#define AFE_PARAM_ID_PSEUDO_PORT_CONFIG	0x00010219
-
-/* Version information used to handle future additions to the configuration
- * interface (for backward compatibility).
- */
-#define AFE_API_VERSION_PSEUDO_PORT_CONFIG                          0x1
-
-/* Enumeration for setting the timing_mode parameter to faster than real
- * time.
- */
-#define AFE_PSEUDOPORT_TIMING_MODE_FTRT                             0x0
-
-/* Enumeration for setting the timing_mode parameter to real time using
- * timers.
- */
-#define AFE_PSEUDOPORT_TIMING_MODE_TIMER                            0x1
-
-/* Payload of the AFE_PARAM_ID_PSEUDO_PORT_CONFIG parameter used by
- * AFE_MODULE_AUDIO_DEV_INTERFACE.
- */
-struct afe_param_id_pseudo_port_cfg {
-	u32                  pseud_port_cfg_minor_version;
-	/*
-	 * Minor version used for tracking the version of the pseudoport
-	 * configuration interface.
-	 */
-
-	u16                  bit_width;
-	/* Bit width of the sample at values 16, 24 */
-
-	u16                  num_channels;
-	/* Number of channels at values  1 to 8 */
-
-	u16                  data_format;
-	/* Non-linear data format supported by the pseudoport (for future use).
-	 * At values #AFE_LINEAR_PCM_DATA
-	 */
-
-	u16                  timing_mode;
-	/* Indicates whether the pseudoport synchronizes to the clock or
-	 * operates faster than real time.
-	 * at values
-	 * - #AFE_PSEUDOPORT_TIMING_MODE_FTRT
-	 * - #AFE_PSEUDOPORT_TIMING_MODE_TIMER @tablebulletend
-	 */
-
-	u32                  sample_rate;
-	/* Sample rate at which the pseudoport will run.
-	 * at values
-	 * - #AFE_PORT_SAMPLE_RATE_8K
-	 * - #AFE_PORT_SAMPLE_RATE_32K
-	 * - #AFE_PORT_SAMPLE_RATE_48K
-	 * - #AFE_PORT_SAMPLE_RATE_96K
-	 * - #AFE_PORT_SAMPLE_RATE_192K @tablebulletend
-	 */
-} __packed;
-
-#define AFE_PARAM_ID_TDM_CONFIG		0x0001029D
-
-#define AFE_API_VERSION_TDM_CONFIG              1
-
-#define AFE_PORT_TDM_SHORT_SYNC_BIT_MODE        0
-#define AFE_PORT_TDM_LONG_SYNC_MODE             1
-#define AFE_PORT_TDM_SHORT_SYNC_SLOT_MODE       2
-
-#define AFE_PORT_TDM_SYNC_SRC_EXTERNAL          0
-#define AFE_PORT_TDM_SYNC_SRC_INTERNAL          1
-
-#define AFE_PORT_TDM_CTRL_DATA_OE_DISABLE       0
-#define AFE_PORT_TDM_CTRL_DATA_OE_ENABLE        1
-
-#define AFE_PORT_TDM_SYNC_NORMAL                0
-#define AFE_PORT_TDM_SYNC_INVERT                1
-
-#define AFE_PORT_TDM_DATA_DELAY_0_BCLK_CYCLE    0
-#define AFE_PORT_TDM_DATA_DELAY_1_BCLK_CYCLE    1
-#define AFE_PORT_TDM_DATA_DELAY_2_BCLK_CYCLE    2
-
-/* Payload of the AFE_PARAM_ID_TDM_CONFIG parameter used by
- * AFE_MODULE_AUDIO_DEV_INTERFACE.
- */
-struct afe_param_id_tdm_cfg {
-	u32	tdm_cfg_minor_version;
-	/* < Minor version used to track TDM configuration.
-	 * @values #AFE_API_VERSION_TDM_CONFIG
-	 */
-
-	u32	num_channels;
-	/* < Number of enabled slots for TDM frame.
-	 * @values 1 to 8
-	 */
-
-	u32	sample_rate;
-	/* < Sampling rate of the port.
-	 * @values
-	 * - #AFE_PORT_SAMPLE_RATE_8K
-	 * - #AFE_PORT_SAMPLE_RATE_16K
-	 * - #AFE_PORT_SAMPLE_RATE_24K
-	 * - #AFE_PORT_SAMPLE_RATE_32K
-	 * - #AFE_PORT_SAMPLE_RATE_48K
-	 * - #AFE_PORT_SAMPLE_RATE_176P4K
-	 * - #AFE_PORT_SAMPLE_RATE_352P8K @tablebulletend
-	 */
-
-	u32	bit_width;
-	/* < Bit width of the sample.
-	 * @values 16, 24
-	 */
-
-	u16	data_format;
-	/* < Data format: linear ,compressed, generic compresssed
-	 * @values
-	 * - #AFE_LINEAR_PCM_DATA
-	 * - #AFE_NON_LINEAR_DATA
-	 * - #AFE_GENERIC_COMPRESSED
-	 */
-
-	u16	sync_mode;
-	/* < TDM synchronization setting.
-	 * @values (short, long, slot) sync mode
-	 * - #AFE_PORT_TDM_SHORT_SYNC_BIT_MODE
-	 * - #AFE_PORT_TDM_LONG_SYNC_MODE
-	 * - #AFE_PORT_TDM_SHORT_SYNC_SLOT_MODE @tablebulletend
-	 */
-
-	u16	sync_src;
-	/* < Synchronization source.
-	 * @values
-	 * - #AFE_PORT_TDM_SYNC_SRC_EXTERNAL
-	 * - #AFE_PORT_TDM_SYNC_SRC_INTERNAL @tablebulletend
-	 */
-
-	u16	nslots_per_frame;
-	/* < Number of slots per frame. Typical : 1, 2, 4, 8, 16, 32.
-	 * @values 1 - 32
-	 */
-
-	u16	ctrl_data_out_enable;
-	/* < Specifies whether the TDM block shares the data-out signal to the
-	 * drive with other masters.
-	 * @values
-	 * - #AFE_PORT_TDM_CTRL_DATA_OE_DISABLE
-	 * - #AFE_PORT_TDM_CTRL_DATA_OE_ENABLE @tablebulletend
-	 */
-
-	u16	ctrl_invert_sync_pulse;
-	/* < Specifies whether to invert the sync or not.
-	 * @values
-	 * - #AFE_PORT_TDM_SYNC_NORMAL
-	 * - #AFE_PORT_TDM_SYNC_INVERT @tablebulletend
-	 */
-
-	u16	ctrl_sync_data_delay;
-	/* < Specifies the number of bit clock to delay data with respect to
-	 * sync edge.
-	 * @values
-	 * - #AFE_PORT_TDM_DATA_DELAY_0_BCLK_CYCLE
-	 * - #AFE_PORT_TDM_DATA_DELAY_1_BCLK_CYCLE
-	 * - #AFE_PORT_TDM_DATA_DELAY_2_BCLK_CYCLE @tablebulletend
-	 */
-
-	u16	slot_width;
-	/* < Slot width of the slot in a TDM frame.  (slot_width >= bit_width)
-	 * have to be satisfied.
-	 * @values 16, 24, 32
-	 */
-
-	u32	slot_mask;
-	/* < Position of active slots.  When that bit is set,
-	 * that paricular slot is active.
-	 * Number of active slots can be inferred by number of
-	 * bits set in the mask.  Only 8 individual bits can be enabled.
-	 * Bits 0..31 corresponding to slot 0..31
-	 * @values 1 to 2^32 - 1
-	 */
-} __packed;
-
-/* ID of Time Divsion Multiplexing (TDM) module,
- * which is used for configuring the AFE TDM.
- *
- * This module supports following parameter IDs:
- * - #AFE_PORT_TDM_SLOT_CONFIG
- *
- * To configure the TDM interface, the client must use the
- * #AFE_PORT_CMD_SET_PARAM command, and fill the module ID with the
- * respective parameter IDs as listed above.
- */
-
-#define AFE_MODULE_TDM		0x0001028A
-
-/* ID of the parameter used by #AFE_MODULE_TDM to configure
- * the TDM slot mapping. #AFE_PORT_CMD_SET_PARAM can use this parameter ID.
- */
-#define AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG	0x00010297
-
-/* Version information used to handle future additions to slot mapping
- * configuration (for backward compatibility).
- */
-#define AFE_API_VERSION_SLOT_MAPPING_CONFIG	0x1
-
-/* Data align type  */
-#define AFE_SLOT_MAPPING_DATA_ALIGN_MSB		0
-#define AFE_SLOT_MAPPING_DATA_ALIGN_LSB		1
-
-#define AFE_SLOT_MAPPING_OFFSET_INVALID		0xFFFF
-
-/* Payload of the AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG
- * command's TDM configuration parameter.
- */
-struct afe_param_id_slot_mapping_cfg {
-	u32	minor_version;
-	/* < Minor version used for tracking TDM slot configuration.
-	 * @values #AFE_API_VERSION_TDM_SLOT_CONFIG
-	 */
-
-	u16	num_channel;
-	/* < number of channel of the audio sample.
-	 * @values 1, 2, 4, 6, 8 @tablebulletend
-	 */
-
-	u16	bitwidth;
-	/* < Slot bit width for each channel
-	 * @values 16, 24, 32
-	 */
-
-	u32	data_align_type;
-	/* < indicate how data packed from slot_offset for 32 slot bit width
-	 * in case of sample bit width is 24.
-	 * @values
-	 * #AFE_SLOT_MAPPING_DATA_ALIGN_MSB
-	 * #AFE_SLOT_MAPPING_DATA_ALIGN_LSB
-	 */
-
-	u16	offset[AFE_PORT_MAX_AUDIO_CHAN_CNT];
-	/* < Array of the slot mapping start offset in bytes for this frame.
-	 * The bytes is counted from 0. The 0 is mapped to the 1st byte
-	 * in or out of the digital serial data line this sub-frame belong to.
-	 * slot_offset[] setting is per-channel based.
-	 * The max num of channel supported is 8.
-	 * The valid offset value must always be continuly placed in from
-	 * index 0.
-	 * Set offset as AFE_SLOT_MAPPING_OFFSET_INVALID for not used arrays.
-	 * If "slot_bitwidth_per_channel" is 32 and "sample_bitwidth" is 24,
-	 * "data_align_type" is used to indicate how 24 bit sample data in
-	 * aligning with 32 bit slot width per-channel.
-	 * @values, in byte
-	 */
-} __packed;
-
-/* ID of the parameter used by #AFE_MODULE_TDM to configure
- * the customer TDM header. #AFE_PORT_CMD_SET_PARAM can use this parameter ID.
- */
-#define AFE_PARAM_ID_CUSTOM_TDM_HEADER_CONFIG		0x00010298
-
-/* Version information used to handle future additions to custom TDM header
- * configuration (for backward compatibility).
- */
-#define AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG	0x1
-
-#define AFE_CUSTOM_TDM_HEADER_TYPE_INVALID		0x0
-#define AFE_CUSTOM_TDM_HEADER_TYPE_DEFAULT		0x1
-#define AFE_CUSTOM_TDM_HEADER_TYPE_ENTERTAINMENT_MOST	0x2
-
-#define AFE_CUSTOM_TDM_HEADER_MAX_CNT	0x8
-
-/* Payload of the AFE_PARAM_ID_CUSTOM_TDM_HEADER_CONFIG parameter ID */
-struct afe_param_id_custom_tdm_header_cfg {
-	u32	minor_version;
-	/* < Minor version used for tracking custom TDM header configuration.
-	 * @values #AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG
-	 */
-
-	u16	start_offset;
-	/* < the slot mapping start offset in bytes from this sub-frame
-	 * The bytes is counted from 0. The 0 is mapped to the 1st byte in or
-	 * out of the digital serial data line this sub-frame belong to.
-	 * @values, in byte,
-	 * supported values are 0, 4, 8
-	 */
-
-	u16	header_width;
-	/* < the header width per-frame followed.
-	 * 2 bytes for MOST/TDM case
-	 * @values, in byte
-	 * supported value is 2
-	 */
-
-	u16	header_type;
-	/* < Indicate what kind of custom TDM header it is.
-	 * @values #AFE_CUSTOM_TDM_HEADER_TYPE_INVALID = 0
-	 * #AFE_CUSTOM_TDM_HEADER_TYPE_DEFAULT = 1  (for AAN channel per MOST)
-	 * #AFE_CUSTOM_TDM_HEADER_TYPE_ENTERTAINMENT_MOST = 2
-	 * (for entertainment channel, which will overwrite
-	 * AFE_API_VERSION_TDM_SAD_HEADER_TYPE_DEFAULT per MOST)
-	 */
-
-	u16	num_frame_repeat;
-	/* < num of header followed.
-	 * @values, supported value is 8
-	 */
-	u16	header[AFE_CUSTOM_TDM_HEADER_MAX_CNT];
-	/* < SAD header for MOST/TDM case is followed as payload as below.
-	 * The size of followed SAD header in bytes is num_of_frame_repeat *
-	 * header_width_per_frame, which is 2 * 8 = 16 bytes here.
-	 * the supported payload format is in uint16_t as below
-	 * uint16_t header0; SyncHi 0x3C Info[4] - CodecType -> 0x3C00
-	 * uint16_t header1; SyncLo 0xB2 Info[5] - SampleWidth -> 0xB218
-	 * uint16_t header2; DTCP Info     Info[6] - unused -> 0x0
-	 * uint16_t header3; Extension Info[7] - ASAD-Value -> 0xC0
-	 * uint16_t header4; Reserved Info[0] - Num of bytes following  -> 0x7
-	 * uint16_t header5; Reserved Info[1] - Media Type -> 0x0
-	 * uint16_t header6; Reserved Info[2] - Bitrate[kbps] - High Byte -> 0x0
-	 * uint16_t header7; Reserved Info[3] - Bitrate[kbps] - Low  Byte -> 0x0
-	 */
-} __packed;
-
-struct afe_slot_mapping_config_command {
-	struct apr_hdr	hdr;
-	struct afe_port_cmd_set_param_v2	param;
-	struct afe_port_param_data_v2	pdata;
-	struct afe_param_id_slot_mapping_cfg	slot_mapping;
-} __packed;
-
-struct afe_custom_tdm_header_config_command {
-	struct apr_hdr	hdr;
-	struct afe_port_cmd_set_param_v2	param;
-	struct afe_port_param_data_v2	pdata;
-	struct afe_param_id_custom_tdm_header_cfg	custom_tdm_header;
-} __packed;
-
-struct afe_tdm_port_config {
-	struct afe_param_id_tdm_cfg				tdm;
-	struct afe_param_id_slot_mapping_cfg		slot_mapping;
-	struct afe_param_id_custom_tdm_header_cfg	custom_tdm_header;
-} __packed;
-
-#define AFE_PARAM_ID_DEVICE_HW_DELAY     0x00010243
-#define AFE_API_VERSION_DEVICE_HW_DELAY  0x1
-
-struct afe_param_id_device_hw_delay_cfg {
-	uint32_t    device_hw_delay_minor_version;
-	uint32_t    delay_in_us;
-} __packed;
-
-#define AFE_PARAM_ID_SET_TOPOLOGY    0x0001025A
-#define AFE_API_VERSION_TOPOLOGY_V1 0x1
-
-struct afe_param_id_set_topology_cfg {
-	/*
-	 * Minor version used for tracking afe topology id configuration.
-	 * @values #AFE_API_VERSION_TOPOLOGY_V1
-	 */
-	u32		minor_version;
-	/*
-	 * Id of the topology for the afe session.
-	 * @values Any valid AFE topology ID
-	 */
-	u32		topology_id;
-} __packed;
-
-
-/*
- * Generic encoder module ID.
- * This module supports the following parameter IDs:
- * #AVS_ENCODER_PARAM_ID_ENC_FMT_ID (cannot be set run time)
- * #AVS_ENCODER_PARAM_ID_ENC_CFG_BLK (may be set run time)
- * #AVS_ENCODER_PARAM_ID_ENC_BITRATE (may be set run time)
- * #AVS_ENCODER_PARAM_ID_PACKETIZER_ID (cannot be set run time)
- * Opcode - AVS_MODULE_ID_ENCODER
- * AFE Command AFE_PORT_CMD_SET_PARAM_V2 supports this module ID.
- */
-#define AFE_MODULE_ID_ENCODER        0x00013229
-
-/* Macro for defining the packetizer ID: COP. */
-#define AFE_MODULE_ID_PACKETIZER_COP 0x0001322A
-
-/*
- * Packetizer type parameter for the #AVS_MODULE_ID_ENCODER module.
- * This parameter cannot be set runtime.
- */
-#define AFE_ENCODER_PARAM_ID_PACKETIZER_ID 0x0001322E
-
-/*
- * Encoder config block  parameter for the #AVS_MODULE_ID_ENCODER module.
- * This parameter may be set runtime.
- */
-#define AFE_ENCODER_PARAM_ID_ENC_CFG_BLK 0x0001322C
-
-/*
- * Encoder format ID parameter for the #AVS_MODULE_ID_ENCODER module.
- * This parameter cannot be set runtime.
- */
-#define AFE_ENCODER_PARAM_ID_ENC_FMT_ID         0x0001322B
-
-/*
- * Data format to send compressed data
- * is transmitted/received over Slimbus lines.
- */
-#define AFE_SB_DATA_FORMAT_GENERIC_COMPRESSED    0x3
-
-/*
- * ID for AFE port module. This will be used to define port properties.
- * This module supports following parameter IDs:
- * #AFE_PARAM_ID_PORT_MEDIA_TYPE
- * To configure the port property, the client must use the
- * #AFE_PORT_CMD_SET_PARAM_V2 command,
- * and fill the module ID with the respective parameter IDs as listed above.
- * @apr_hdr_fields
- * Opcode -- AFE_MODULE_PORT
- */
-#define AFE_MODULE_PORT                          0x000102a6
-
-/*
- * ID of the parameter used by #AFE_MODULE_PORT to set the port media type.
- * parameter ID is currently supported using#AFE_PORT_CMD_SET_PARAM_V2 command.
- */
-#define AFE_PARAM_ID_PORT_MEDIA_TYPE              0x000102a7
-
-/*
- * Macros for defining the "data_format" field in the
- * #AFE_PARAM_ID_PORT_MEDIA_TYPE
- */
-#define AFE_PORT_DATA_FORMAT_PCM                  0x0
-#define AFE_PORT_DATA_FORMAT_GENERIC_COMPRESSED   0x1
-
-/*
- * Macro for defining the "minor_version" field in the
- * #AFE_PARAM_ID_PORT_MEDIA_TYPE
- */
-#define AFE_API_VERSION_PORT_MEDIA_TYPE           0x1
-
-#define ASM_MEDIA_FMT_NONE                        0x0
-
-/*
- * Media format ID for SBC encode configuration.
- * @par SBC encode configuration (asm_sbc_enc_cfg_t)
- * @table{weak__asm__sbc__enc__cfg__t}
- */
-#define ASM_MEDIA_FMT_SBC                         0x00010BF2
-
-/* SBC channel Mono mode.*/
-#define ASM_MEDIA_FMT_SBC_CHANNEL_MODE_MONO                     1
-
-/* SBC channel Stereo mode. */
-#define ASM_MEDIA_FMT_SBC_CHANNEL_MODE_STEREO                   2
-
-/* SBC channel Dual Mono mode. */
-#define ASM_MEDIA_FMT_SBC_CHANNEL_MODE_DUAL_MONO                8
-
-/* SBC channel Joint Stereo mode. */
-#define ASM_MEDIA_FMT_SBC_CHANNEL_MODE_JOINT_STEREO             9
-
-/* SBC bit allocation method = loudness. */
-#define ASM_MEDIA_FMT_SBC_ALLOCATION_METHOD_LOUDNESS            0
-
-/* SBC bit allocation method = SNR. */
-#define ASM_MEDIA_FMT_SBC_ALLOCATION_METHOD_SNR                 1
-
-
-/*
- * Payload of the SBC encoder configuration parameters in the
- * #ASM_MEDIA_FMT_SBC media format.
- */
-struct asm_sbc_enc_cfg_t {
-	/*
-	 * Number of subbands.
-	 * @values 4, 8
-	 */
-	uint32_t    num_subbands;
-
-	/*
-	 * Size of the encoded block in samples.
-	 * @values 4, 8, 12, 16
-	 */
-	uint32_t    blk_len;
-
-	/*
-	 * Mode used to allocate bits between channels.
-	 * @values
-	 * 0 (Native mode)
-	 * #ASM_MEDIA_FMT_SBC_CHANNEL_MODE_MONO
-	 * #ASM_MEDIA_FMT_SBC_CHANNEL_MODE_STEREO
-	 * #ASM_MEDIA_FMT_SBC_CHANNEL_MODE_DUAL_MONO
-	 * #ASM_MEDIA_FMT_SBC_CHANNEL_MODE_JOINT_STEREO
-	 * Native mode indicates that encoding must be performed with the number
-	 * of channels at the input.
-	 * If postprocessing outputs one-channel data, Mono mode is used. If
-	 * postprocessing outputs two-channel data, Stereo mode is used.
-	 * The number of channels must not change during encoding.
-	 */
-	uint32_t    channel_mode;
-
-	/*
-	 * Encoder bit allocation method.
-	 * @values
-	 * #ASM_MEDIA_FMT_SBC_ALLOCATION_METHOD_LOUDNESS
-	 * #ASM_MEDIA_FMT_SBC_ALLOCATION_METHOD_SNR @tablebulletend
-	 */
-	uint32_t    alloc_method;
-
-	/*
-	 * Number of encoded bits per second.
-	 * @values
-	 * Mono channel -- Maximum of 320 kbps
-	 * Stereo channel -- Maximum of 512 kbps @tablebulletend
-	 */
-	uint32_t    bit_rate;
-
-	/*
-	 * Number of samples per second.
-	 * @values 0 (Native mode), 16000, 32000, 44100, 48000&nbsp;Hz
-	 * Native mode indicates that encoding must be performed with the
-	 * sampling rate at the input.
-	 * The sampling rate must not change during encoding.
-	 */
-	uint32_t    sample_rate;
-};
-
-#define ASM_MEDIA_FMT_AAC_AOT_LC            2
-#define ASM_MEDIA_FMT_AAC_AOT_SBR           5
-#define ASM_MEDIA_FMT_AAC_AOT_PS            29
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADTS  0
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_RAW   3
-
-struct asm_aac_enc_cfg_v2_t {
-
-	/* Encoding rate in bits per second.*/
-	uint32_t     bit_rate;
-
-	/*
-	 * Encoding mode.
-	 * Supported values:
-	 * #ASM_MEDIA_FMT_AAC_AOT_LC
-	 * #ASM_MEDIA_FMT_AAC_AOT_SBR
-	 * #ASM_MEDIA_FMT_AAC_AOT_PS
-	 */
-	uint32_t     enc_mode;
-
-	/*
-	 * AAC format flag.
-	 * Supported values:
-	 * #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADTS
-	 * #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_RAW
-	 */
-	uint16_t     aac_fmt_flag;
-
-	/*
-	 * Number of channels to encode.
-	 * Supported values:
-	 * 0 - Native mode
-	 * 1 - Mono
-	 * 2 - Stereo
-	 * Other values are not supported.
-	 * @note1hang The eAAC+ encoder mode supports only stereo.
-	 * Native mode indicates that encoding must be performed with the
-	 * number of channels at the input.
-	 * The number of channels must not change during encoding.
-	 */
-	uint16_t     channel_cfg;
-
-	/*
-	 * Number of samples per second.
-	 * Supported values: - 0 -- Native mode - For other values,
-	 * Native mode indicates that encoding must be performed with the
-	 * sampling rate at the input.
-	 * The sampling rate must not change during encoding.
-	 */
-	uint32_t     sample_rate;
-} __packed;
-
-/* FMT ID for apt-X Classic */
-#define ASM_MEDIA_FMT_APTX 0x000131ff
-
-/* FMT ID for apt-X HD */
-#define ASM_MEDIA_FMT_APTX_HD 0x00013200
-
-#define PCM_CHANNEL_L         1
-#define PCM_CHANNEL_R         2
-#define PCM_CHANNEL_C         3
-
-struct asm_custom_enc_cfg_aptx_t {
-	uint32_t    sample_rate;
-	/* Mono or stereo */
-	uint16_t    num_channels;
-	uint16_t    reserved;
-	/* num_ch == 1, then PCM_CHANNEL_C,
-	 * num_ch == 2, then {PCM_CHANNEL_L, PCM_CHANNEL_R}
-	 */
-	uint8_t     channel_mapping[8];
-	uint32_t    custom_size;
-} __packed;
-
-struct afe_enc_fmt_id_param_t {
-	/*
-	 * Supported values:
-	 *  #ASM_MEDIA_FMT_SBC
-	 *  #ASM_MEDIA_FMT_AAC_V2
-	 * Any OpenDSP supported values
-	 */
-	uint32_t    fmt_id;
-} __packed;
-
-struct afe_port_media_type_t {
-	/*
-	 * Minor version
-	 * @values #AFE_API_VERSION_PORT_MEDIA_TYPE.
-	 */
-	uint32_t    minor_version;
-
-	/*
-	 * Sampling rate of the port.
-	 * @values
-	 * #AFE_PORT_SAMPLE_RATE_8K
-	 * #AFE_PORT_SAMPLE_RATE_11_025K
-	 * #AFE_PORT_SAMPLE_RATE_12K
-	 * #AFE_PORT_SAMPLE_RATE_16K
-	 * #AFE_PORT_SAMPLE_RATE_22_05K
-	 * #AFE_PORT_SAMPLE_RATE_24K
-	 * #AFE_PORT_SAMPLE_RATE_32K
-	 * #AFE_PORT_SAMPLE_RATE_44_1K
-	 * #AFE_PORT_SAMPLE_RATE_48K
-	 * #AFE_PORT_SAMPLE_RATE_88_2K
-	 * #AFE_PORT_SAMPLE_RATE_96K
-	 * #AFE_PORT_SAMPLE_RATE_176_4K
-	 * #AFE_PORT_SAMPLE_RATE_192K
-	 * #AFE_PORT_SAMPLE_RATE_352_8K
-	 * #AFE_PORT_SAMPLE_RATE_384K
-	 */
-	uint32_t    sample_rate;
-
-	/*
-	 * Bit width of the sample.
-	 * @values 16, 24
-	 */
-	uint16_t    bit_width;
-
-	/*
-	 * Number of channels.
-	 * @values 1 to #AFE_PORT_MAX_AUDIO_CHAN_CNT
-	 */
-	uint16_t    num_channels;
-
-	/*
-	 * Data format supported by this port.
-	 * If the port media type and device media type are different,
-	 * it signifies a encoding/decoding use case
-	 * @values
-	 * #AFE_PORT_DATA_FORMAT_PCM
-	 * #AFE_PORT_DATA_FORMAT_GENERIC_COMPRESSED
-	 */
-	uint16_t   data_format;
-
-	/*This field must be set to zero.*/
-	uint16_t   reserved;
-} __packed;
-
-union afe_enc_config_data {
-	struct asm_sbc_enc_cfg_t sbc_config;
-	struct asm_aac_enc_cfg_v2_t aac_config;
-	struct asm_custom_enc_cfg_aptx_t  aptx_config;
-};
-
-struct afe_enc_config {
-	u32 format;
-	union afe_enc_config_data data;
-};
-
-struct afe_enc_cfg_blk_param_t {
-	uint32_t enc_cfg_blk_size;
-	/*
-	 *Size of the encoder configuration block that follows this member
-	 */
-	union afe_enc_config_data enc_blk_config;
-};
-
-/*
- * Payload of the AVS_ENCODER_PARAM_ID_PACKETIZER_ID parameter.
- */
-struct avs_enc_packetizer_id_param_t {
-	/*
-	 * Supported values:
-	 * #AVS_MODULE_ID_PACKETIZER_COP
-	 * Any OpenDSP supported values
-	 */
-	uint32_t enc_packetizer_id;
-};
-
-union afe_port_config {
-	struct afe_param_id_pcm_cfg               pcm;
-	struct afe_param_id_i2s_cfg               i2s;
-	struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
-	struct afe_param_id_slimbus_cfg           slim_sch;
-	struct afe_param_id_rt_proxy_port_cfg     rtproxy;
-	struct afe_param_id_internal_bt_fm_cfg    int_bt_fm;
-	struct afe_param_id_pseudo_port_cfg       pseudo_port;
-	struct afe_param_id_device_hw_delay_cfg   hw_delay;
-	struct afe_param_id_spdif_cfg             spdif;
-	struct afe_param_id_set_topology_cfg      topology;
-	struct afe_param_id_tdm_cfg               tdm;
-	struct afe_param_id_usb_audio_cfg         usb_audio;
-	struct afe_enc_fmt_id_param_t             enc_fmt;
-	struct afe_port_media_type_t              media_type;
-	struct afe_enc_cfg_blk_param_t            enc_blk_param;
-	struct avs_enc_packetizer_id_param_t      enc_pkt_id_param;
-} __packed;
-
-struct afe_audioif_config_command_no_payload {
-	struct apr_hdr			hdr;
-	struct afe_port_cmd_set_param_v2 param;
-} __packed;
-
-struct afe_audioif_config_command {
-	struct apr_hdr			hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	union afe_port_config            port;
-} __packed;
-
-#define AFE_PORT_CMD_DEVICE_START 0x000100E5
-
-/*  Payload of the #AFE_PORT_CMD_DEVICE_START.*/
-struct afe_port_cmd_device_start {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Port interface and direction (Rx or Tx) to start. An even
- * number represents the Rx direction, and an odd number represents
- * the Tx direction.
- */
-
-
-	u16                  reserved;
-/* Reserved for 32-bit alignment. This field must be set to 0.*/
-
-} __packed;
-
-#define AFE_PORT_CMD_DEVICE_STOP  0x000100E6
-
-/* Payload of the #AFE_PORT_CMD_DEVICE_STOP. */
-struct afe_port_cmd_device_stop {
-	struct apr_hdr hdr;
-	u16                  port_id;
-/* Port interface and direction (Rx or Tx) to start. An even
- * number represents the Rx direction, and an odd number represents
- * the Tx direction.
- */
-
-	u16                  reserved;
-/* Reserved for 32-bit alignment. This field must be set to 0.*/
-} __packed;
-
-#define AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS 0x000100EA
-
-/*  Memory map regions command payload used by the
- * #AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS .
- * This structure allows clients to map multiple shared memory
- * regions in a single command. Following this structure are
- * num_regions of afe_service_shared_map_region_payload.
- */
-struct afe_service_cmd_shared_mem_map_regions {
-	struct apr_hdr hdr;
-u16                  mem_pool_id;
-/* Type of memory on which this memory region is mapped.
- * Supported values:
- * - #ADSP_MEMORY_MAP_EBI_POOL
- * - #ADSP_MEMORY_MAP_SMI_POOL
- * - #ADSP_MEMORY_MAP_SHMEM8_4K_POOL
- * - Other values are reserved
- *
- * The memory pool ID implicitly defines the characteristics of the
- * memory. Characteristics may include alignment type, permissions,
- * etc.
- *
- * ADSP_MEMORY_MAP_EBI_POOL is External Buffer Interface type memory
- * ADSP_MEMORY_MAP_SMI_POOL is Shared Memory Interface type memory
- * ADSP_MEMORY_MAP_SHMEM8_4K_POOL is shared memory, byte
- * addressable, and 4 KB aligned.
- */
-
-
-	u16                  num_regions;
-/* Number of regions to map.
- * Supported values:
- * - Any value greater than zero
- */
-
-	u32                  property_flag;
-/* Configures one common property for all the regions in the
- * payload.
- *
- * Supported values: - 0x00000000 to 0x00000001
- *
- * b0 - bit 0 indicates physical or virtual mapping 0 Shared memory
- * address provided in afe_service_shared_map_region_payloadis a
- * physical address. The shared memory needs to be mapped( hardware
- * TLB entry) and a software entry needs to be added for internal
- * book keeping.
- *
- * 1 Shared memory address provided in
- * afe_service_shared_map_region_payloadis a virtual address. The
- * shared memory must not be mapped (since hardware TLB entry is
- * already available) but a software entry needs to be added for
- * internal book keeping. This can be useful if two services with in
- * ADSP is communicating via APR. They can now directly communicate
- * via the Virtual address instead of Physical address. The virtual
- * regions must be contiguous. num_regions must be 1 in this case.
- *
- * b31-b1 - reserved bits. must be set to zero
- */
-
-
-} __packed;
-/*  Map region payload used by the
- * afe_service_shared_map_region_payloadstructure.
- */
-struct afe_service_shared_map_region_payload {
-	u32                  shm_addr_lsw;
-/* least significant word of starting address in the memory
- * region to map. It must be contiguous memory, and it must be 4 KB
- * aligned.
- * Supported values: - Any 32 bit value
- */
-
-
-	u32                  shm_addr_msw;
-/* most significant word of startng address in the memory region
- * to map. For 32 bit shared memory address, this field must be set
- * to zero. For 36 bit shared memory address, bit31 to bit 4 must be
- * set to zero
- *
- * Supported values: - For 32 bit shared memory address, this field
- * must be set to zero. - For 36 bit shared memory address, bit31 to
- * bit 4 must be set to zero - For 64 bit shared memory address, any
- * 32 bit value
- */
-
-
-	u32                  mem_size_bytes;
-/* Number of bytes in the region. The aDSP will always map the
- * regions as virtual contiguous memory, but the memory size must be
- * in multiples of 4 KB to avoid gaps in the virtually contiguous
- * mapped memory.
- *
- * Supported values: - multiples of 4KB
- */
-
-} __packed;
-
-#define AFE_SERVICE_CMDRSP_SHARED_MEM_MAP_REGIONS 0x000100EB
-struct afe_service_cmdrsp_shared_mem_map_regions {
-	u32                  mem_map_handle;
-/* A memory map handle encapsulating shared memory attributes is
- * returned iff AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS command is
- * successful. In the case of failure , a generic APR error response
- * is returned to the client.
- *
- * Supported Values: - Any 32 bit value
- */
-
-} __packed;
-#define AFE_SERVICE_CMD_SHARED_MEM_UNMAP_REGIONS 0x000100EC
-/* Memory unmap regions command payload used by the
- * #AFE_SERVICE_CMD_SHARED_MEM_UNMAP_REGIONS
- *
- * This structure allows clients to unmap multiple shared memory
- * regions in a single command.
- */
-
-
-struct afe_service_cmd_shared_mem_unmap_regions {
-	struct apr_hdr hdr;
-u32                  mem_map_handle;
-/* memory map handle returned by
- * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands
- *
- * Supported Values:
- * - Any 32 bit value
- */
-} __packed;
-
-#define  AFE_PORT_CMD_GET_PARAM_V2 0x000100F0
-
-/*  Payload of the #AFE_PORT_CMD_GET_PARAM_V2 command,
- * which queries for one post/preprocessing parameter of a
- * stream.
- */
-struct afe_port_cmd_get_param_v2 {
-	u16 port_id;
-/* Port interface and direction (Rx or Tx) to start. */
-
-	u16 payload_size;
-/* Maximum data size of the parameter ID/module ID combination.
- * This is a multiple of four bytes
- * Supported values: > 0
- */
-
-	u32 payload_address_lsw;
-/* LSW of 64 bit Payload address. Address should be 32-byte,
- * 4kbyte aligned and must be contig memory.
- */
-
-
-	u32 payload_address_msw;
-/* MSW of 64 bit Payload address. In case of 32-bit shared
- * memory address, this field must be set to zero. In case of 36-bit
- * shared memory address, bit-4 to bit-31 must be set to zero.
- * Address should be 32-byte, 4kbyte aligned and must be contiguous
- * memory.
- */
-
-	u32 mem_map_handle;
-/* Memory map handle returned by
- * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
- * Supported Values: - NULL -- Message. The parameter data is
- * in-band. - Non-NULL -- The parameter data is Out-band.Pointer to
- * - the physical address in shared memory of the payload data.
- * For detailed payload content, see the afe_port_param_data_v2
- * structure
- */
-
-
-	u32 module_id;
-/* ID of the module to be queried.
- * Supported values: Valid module ID
- */
-
-	u32 param_id;
-/* ID of the parameter to be queried.
- * Supported values: Valid parameter ID
- */
-} __packed;
-
-#define AFE_PORT_CMDRSP_GET_PARAM_V2 0x00010106
-
-/* Payload of the #AFE_PORT_CMDRSP_GET_PARAM_V2 message, which
- * responds to an #AFE_PORT_CMD_GET_PARAM_V2 command.
- *
- * Immediately following this structure is the parameters structure
- * (afe_port_param_data) containing the response(acknowledgment)
- * parameter payload. This payload is included for an in-band
- * scenario. For an address/shared memory-based set parameter, this
- * payload is not needed.
- */
-
-
-struct afe_port_cmdrsp_get_param_v2 {
-	u32                  status;
-} __packed;
-
-#define AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG	0x0001028C
-#define AFE_API_VERSION_LPASS_CORE_SHARED_CLK_CONFIG	0x1
-
-/* Payload of the AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG parameter used by
- * AFE_MODULE_AUDIO_DEV_INTERFACE.
- */
-struct afe_param_id_lpass_core_shared_clk_cfg {
-	u32	lpass_core_shared_clk_cfg_minor_version;
-/*
- * Minor version used for lpass core shared clock configuration
- * Supported value: AFE_API_VERSION_LPASS_CORE_SHARED_CLK_CONFIG
- */
-	u32	enable;
-/*
- * Specifies whether the lpass core shared clock is
- * enabled (1) or disabled (0).
- */
-} __packed;
-
-struct afe_lpass_core_shared_clk_config_command {
-	struct apr_hdr		   hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	struct afe_param_id_lpass_core_shared_clk_cfg clk_cfg;
-} __packed;
-
-/* adsp_afe_service_commands.h */
-
-#define ADSP_MEMORY_MAP_EBI_POOL      0
-
-#define ADSP_MEMORY_MAP_SMI_POOL      1
-#define ADSP_MEMORY_MAP_IMEM_POOL      2
-#define ADSP_MEMORY_MAP_SHMEM8_4K_POOL      3
-
-/* Definition of virtual memory flag */
-#define ADSP_MEMORY_MAP_VIRTUAL_MEMORY 1
-
-/* Definition of physical memory flag */
-#define ADSP_MEMORY_MAP_PHYSICAL_MEMORY 0
-
-#define NULL_POPP_TOPOLOGY				0x00010C68
-#define NULL_COPP_TOPOLOGY				0x00010312
-#define DEFAULT_COPP_TOPOLOGY				0x00010314
-#define DEFAULT_POPP_TOPOLOGY				0x00010BE4
-#define COMPRESSED_PASSTHROUGH_DEFAULT_TOPOLOGY         0x0001076B
-#define COMPRESSED_PASSTHROUGH_NONE_TOPOLOGY            0x00010774
-#define VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY			0x00010F89
-#define VPM_TX_DM_FLUENCE_COPP_TOPOLOGY			0x00010F72
-#define VPM_TX_QMIC_FLUENCE_COPP_TOPOLOGY		0x00010F75
-#define VPM_TX_DM_RFECNS_COPP_TOPOLOGY			0x00010F86
-#define ADM_CMD_COPP_OPEN_TOPOLOGY_ID_DTS_HPX		0x10015002
-#define ADM_CMD_COPP_OPEN_TOPOLOGY_ID_AUDIOSPHERE	0x10028000
-
-/* Memory map regions command payload used by the
- * #ASM_CMD_SHARED_MEM_MAP_REGIONS ,#ADM_CMD_SHARED_MEM_MAP_REGIONS
- * commands.
- *
- * This structure allows clients to map multiple shared memory
- * regions in a single command. Following this structure are
- * num_regions of avs_shared_map_region_payload.
- */
-
-
-struct avs_cmd_shared_mem_map_regions {
-	struct apr_hdr hdr;
-	u16                  mem_pool_id;
-/* Type of memory on which this memory region is mapped.
- *
- * Supported values: - #ADSP_MEMORY_MAP_EBI_POOL -
- * #ADSP_MEMORY_MAP_SMI_POOL - #ADSP_MEMORY_MAP_IMEM_POOL
- * (unsupported) - #ADSP_MEMORY_MAP_SHMEM8_4K_POOL - Other values
- * are reserved
- *
- * The memory ID implicitly defines the characteristics of the
- * memory. Characteristics may include alignment type, permissions,
- * etc.
- *
- * SHMEM8_4K is shared memory, byte addressable, and 4 KB aligned.
- */
-
-
-	u16                  num_regions;
-	/* Number of regions to map.*/
-
-	u32                  property_flag;
-/* Configures one common property for all the regions in the
- * payload. No two regions in the same memory map regions cmd can
- * have differnt property. Supported values: - 0x00000000 to
- * 0x00000001
- *
- * b0 - bit 0 indicates physical or virtual mapping 0 shared memory
- * address provided in avs_shared_map_regions_payload is physical
- * address. The shared memory needs to be mapped( hardware TLB
- * entry)
- *
- * and a software entry needs to be added for internal book keeping.
- *
- * 1 Shared memory address provided in MayPayload[usRegions] is
- * virtual address. The shared memory must not be mapped (since
- * hardware TLB entry is already available) but a software entry
- * needs to be added for internal book keeping. This can be useful
- * if two services with in ADSP is communicating via APR. They can
- * now directly communicate via the Virtual address instead of
- * Physical address. The virtual regions must be contiguous.
- *
- * b31-b1 - reserved bits. must be set to zero
- */
-
-} __packed;
-
-struct avs_shared_map_region_payload {
-	u32                  shm_addr_lsw;
-/* least significant word of shared memory address of the memory
- * region to map. It must be contiguous memory, and it must be 4 KB
- * aligned.
- */
-
-	u32                  shm_addr_msw;
-/* most significant word of shared memory address of the memory
- * region to map. For 32 bit shared memory address, this field must
- * tbe set to zero. For 36 bit shared memory address, bit31 to bit 4
- * must be set to zero
- */
-
-	u32                  mem_size_bytes;
-/* Number of bytes in the region.
- *
- * The aDSP will always map the regions as virtual contiguous
- * memory, but the memory size must be in multiples of 4 KB to avoid
- * gaps in the virtually contiguous mapped memory.
- */
-
-} __packed;
-
-struct avs_cmd_shared_mem_unmap_regions {
-	struct apr_hdr       hdr;
-	u32                  mem_map_handle;
-/* memory map handle returned by ASM_CMD_SHARED_MEM_MAP_REGIONS
- * , ADM_CMD_SHARED_MEM_MAP_REGIONS, commands
- */
-
-} __packed;
-
-/* Memory map command response payload used by the
- * #ASM_CMDRSP_SHARED_MEM_MAP_REGIONS
- * ,#ADM_CMDRSP_SHARED_MEM_MAP_REGIONS
- */
-
-
-struct avs_cmdrsp_shared_mem_map_regions {
-	u32                  mem_map_handle;
-/* A memory map handle encapsulating shared memory attributes is
- * returned
- */
-
-} __packed;
-
-/*adsp_audio_memmap_api.h*/
-
-/* ASM related data structures */
-struct asm_wma_cfg {
-	u16 format_tag;
-	u16 ch_cfg;
-	u32 sample_rate;
-	u32 avg_bytes_per_sec;
-	u16 block_align;
-	u16 valid_bits_per_sample;
-	u32 ch_mask;
-	u16 encode_opt;
-	u16 adv_encode_opt;
-	u32 adv_encode_opt2;
-	u32 drc_peak_ref;
-	u32 drc_peak_target;
-	u32 drc_ave_ref;
-	u32 drc_ave_target;
-} __packed;
-
-struct asm_wmapro_cfg {
-	u16 format_tag;
-	u16 ch_cfg;
-	u32 sample_rate;
-	u32 avg_bytes_per_sec;
-	u16 block_align;
-	u16 valid_bits_per_sample;
-	u32 ch_mask;
-	u16 encode_opt;
-	u16 adv_encode_opt;
-	u32 adv_encode_opt2;
-	u32 drc_peak_ref;
-	u32 drc_peak_target;
-	u32 drc_ave_ref;
-	u32 drc_ave_target;
-} __packed;
-
-struct asm_aac_cfg {
-	u16 format;
-	u16 aot;
-	u16 ep_config;
-	u16 section_data_resilience;
-	u16 scalefactor_data_resilience;
-	u16 spectral_data_resilience;
-	u16 ch_cfg;
-	u16 reserved;
-	u32 sample_rate;
-} __packed;
-
-struct asm_amrwbplus_cfg {
-	u32  size_bytes;
-	u32  version;
-	u32  num_channels;
-	u32  amr_band_mode;
-	u32  amr_dtx_mode;
-	u32  amr_frame_fmt;
-	u32  amr_lsf_idx;
-} __packed;
-
-struct asm_flac_cfg {
-	u32 sample_rate;
-	u32 ext_sample_rate;
-	u32 min_frame_size;
-	u32 max_frame_size;
-	u16 stream_info_present;
-	u16 min_blk_size;
-	u16 max_blk_size;
-	u16 ch_cfg;
-	u16 sample_size;
-	u16 md5_sum;
-};
-
-struct asm_alac_cfg {
-	u32 frame_length;
-	u8 compatible_version;
-	u8 bit_depth;
-	u8 pb;
-	u8 mb;
-	u8 kb;
-	u8 num_channels;
-	u16 max_run;
-	u32 max_frame_bytes;
-	u32 avg_bit_rate;
-	u32 sample_rate;
-	u32 channel_layout_tag;
-};
-
-struct asm_g711_dec_cfg {
-	u32 sample_rate;
-};
-
-struct asm_vorbis_cfg {
-	u32 bit_stream_fmt;
-};
-
-struct asm_ape_cfg {
-	u16 compatible_version;
-	u16 compression_level;
-	u32 format_flags;
-	u32 blocks_per_frame;
-	u32 final_frame_blocks;
-	u32 total_frames;
-	u16 bits_per_sample;
-	u16 num_channels;
-	u32 sample_rate;
-	u32 seek_table_present;
-};
-
-struct asm_dsd_cfg {
-	u16 num_version;
-	u16 is_bitwise_big_endian;
-	u16 dsd_channel_block_size;
-	u16 num_channels;
-	u8  channel_mapping[8];
-	u32 dsd_data_rate;
-};
-
-struct asm_softpause_params {
-	u32 enable;
-	u32 period;
-	u32 step;
-	u32 rampingcurve;
-} __packed;
-
-struct asm_softvolume_params {
-	u32 period;
-	u32 step;
-	u32 rampingcurve;
-} __packed;
-
-#define ASM_END_POINT_DEVICE_MATRIX     0
-
-#define PCM_CHANNEL_NULL 0
-
-/* Front left channel. */
-#define PCM_CHANNEL_FL    1
-
-/* Front right channel. */
-#define PCM_CHANNEL_FR    2
-
-/* Front center channel. */
-#define PCM_CHANNEL_FC    3
-
-/* Left surround channel.*/
-#define PCM_CHANNEL_LS   4
-
-/* Right surround channel.*/
-#define PCM_CHANNEL_RS   5
-
-/* Low frequency effect channel. */
-#define PCM_CHANNEL_LFE  6
-
-/* Center surround channel; Rear center channel. */
-#define PCM_CHANNEL_CS   7
-
-/* Left back channel; Rear left channel. */
-#define PCM_CHANNEL_LB   8
-
-/* Right back channel; Rear right channel. */
-#define PCM_CHANNEL_RB   9
-
-/* Top surround channel. */
-#define PCM_CHANNELS   10
-
-/* Center vertical height channel.*/
-#define PCM_CHANNEL_CVH  11
-
-/* Mono surround channel.*/
-#define PCM_CHANNEL_MS   12
-
-/* Front left of center. */
-#define PCM_CHANNEL_FLC  13
-
-/* Front right of center. */
-#define PCM_CHANNEL_FRC  14
-
-/* Rear left of center. */
-#define PCM_CHANNEL_RLC  15
-
-/* Rear right of center. */
-#define PCM_CHANNEL_RRC  16
-
-#define PCM_FORMAT_MAX_NUM_CHANNEL  8
-
-#define ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2 0x00010DA5
-
-#define ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3 0x00010DDC
-
-#define ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V4 0x0001320C
-
-#define ASM_MEDIA_FMT_EVRCB_FS 0x00010BEF
-
-#define ASM_MEDIA_FMT_EVRCWB_FS 0x00010BF0
-
-#define ASM_MEDIA_FMT_GENERIC_COMPRESSED  0x00013212
-
-#define ASM_MAX_EQ_BANDS 12
-
-#define ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2 0x00010D98
-
-struct asm_data_cmd_media_fmt_update_v2 {
-u32                    fmt_blk_size;
-	/* Media format block size in bytes.*/
-}  __packed;
-
-struct asm_generic_compressed_fmt_blk_t {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
-
-	/*
-	 * Channel mapping array of bitstream output.
-	 * Channel[i] mapping describes channel i inside the buffer, where
-	 * i < num_channels. All valid used channels must be
-	 * present at the beginning of the array.
-	 */
-	uint8_t channel_mapping[8];
-
-	/*
-	 * Number of channels of the incoming bitstream.
-	 * Supported values: 1,2,3,4,5,6,7,8
-	 */
-	uint16_t num_channels;
-
-	/*
-	 * Nominal bits per sample value of the incoming bitstream.
-	 * Supported values: 16, 32
-	 */
-	uint16_t bits_per_sample;
-
-	/*
-	 * Nominal sampling rate of the incoming bitstream.
-	 * Supported values: 8000, 11025, 16000, 22050, 24000, 32000,
-	 *                   44100, 48000, 88200, 96000, 176400, 192000,
-	 *                   352800, 384000
-	 */
-	uint32_t sampling_rate;
-
-} __packed;
-
-
-/* Command to send sample rate & channels for IEC61937 (compressed) or IEC60958
- * (pcm) streams. Both audio standards use the same format and are used for
- * HDMI or SPDIF.
- */
-#define ASM_DATA_CMD_IEC_60958_MEDIA_FMT        0x0001321E
-
-struct asm_iec_compressed_fmt_blk_t {
-	struct apr_hdr hdr;
-
-	/*
-	 * Nominal sampling rate of the incoming bitstream.
-	 * Supported values: 8000, 11025, 16000, 22050, 24000, 32000,
-	 *                   44100, 48000, 88200, 96000, 176400, 192000,
-	 *                   352800, 384000
-	 */
-	uint32_t sampling_rate;
-
-	/*
-	 * Number of channels of the incoming bitstream.
-	 * Supported values: 1,2,3,4,5,6,7,8
-	 */
-	uint32_t num_channels;
-
-} __packed;
-
-struct asm_multi_channel_pcm_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
-
-	u16  num_channels;
-	/* Number of channels. Supported values: 1 to 8 */
-	u16  bits_per_sample;
-/* Number of bits per sample per channel. * Supported values:
- * 16, 24 * When used for playback, the client must send 24-bit
- * samples packed in 32-bit words. The 24-bit samples must be placed
- * in the most significant 24 bits of the 32-bit word. When used for
- * recording, the aDSP sends 24-bit samples packed in 32-bit words.
- * The 24-bit samples are placed in the most significant 24 bits of
- * the 32-bit word.
- */
-
-
-	u32  sample_rate;
-/* Number of samples per second (in Hertz).
- * Supported values: 2000 to 48000
- */
-
-	u16  is_signed;
-	/* Flag that indicates the samples are signed (1). */
-
-	u16  reserved;
-	/* reserved field for 32 bit alignment. must be set to zero. */
-
-	u8   channel_mapping[8];
-/* Channel array of size 8.
- * Supported values:
- * - #PCM_CHANNEL_L
- * - #PCM_CHANNEL_R
- * - #PCM_CHANNEL_C
- * - #PCM_CHANNEL_LS
- * - #PCM_CHANNEL_RS
- * - #PCM_CHANNEL_LFE
- * - #PCM_CHANNEL_CS
- * - #PCM_CHANNEL_LB
- * - #PCM_CHANNEL_RB
- * - #PCM_CHANNELS
- * - #PCM_CHANNEL_CVH
- * - #PCM_CHANNEL_MS
- * - #PCM_CHANNEL_FLC
- * - #PCM_CHANNEL_FRC
- * - #PCM_CHANNEL_RLC
- * - #PCM_CHANNEL_RRC
- *
- * Channel[i] mapping describes channel I. Each element i of the
- * array describes channel I inside the buffer where 0 @le I <
- * num_channels. An unused channel is set to zero.
- */
-} __packed;
-
-struct asm_multi_channel_pcm_fmt_blk_v3 {
-	uint16_t                num_channels;
-/*
- * Number of channels
- * Supported values: 1 to 8
- */
-
-	uint16_t                bits_per_sample;
-/*
- * Number of bits per sample per channel
- * Supported values: 16, 24
- */
-
-	uint32_t                sample_rate;
-/*
- * Number of samples per second
- * Supported values: 2000 to 48000, 96000,192000 Hz
- */
-
-	uint16_t                is_signed;
-/* Flag that indicates that PCM samples are signed (1) */
-
-	uint16_t                sample_word_size;
-/*
- * Size in bits of the word that holds a sample of a channel.
- * Supported values: 12,24,32
- */
-
-	uint8_t                 channel_mapping[8];
-/*
- * Each element, i, in the array describes channel i inside the buffer where
- * 0 <= i < num_channels. Unused channels are set to 0.
- */
-} __packed;
-
-struct asm_multi_channel_pcm_fmt_blk_v4 {
-	uint16_t                num_channels;
-/*
- * Number of channels
- * Supported values: 1 to 8
- */
-
-	uint16_t                bits_per_sample;
-/*
- * Number of bits per sample per channel
- * Supported values: 16, 24, 32
- */
-
-	uint32_t                sample_rate;
-/*
- * Number of samples per second
- * Supported values: 2000 to 48000, 96000,192000 Hz
- */
-
-	uint16_t                is_signed;
-/* Flag that indicates that PCM samples are signed (1) */
-
-	uint16_t                sample_word_size;
-/*
- * Size in bits of the word that holds a sample of a channel.
- * Supported values: 12,24,32
- */
-
-	uint8_t                 channel_mapping[8];
-/*
- * Each element, i, in the array describes channel i inside the buffer where
- * 0 <= i < num_channels. Unused channels are set to 0.
- */
-	uint16_t                endianness;
-/*
- * Flag to indicate the endianness of the pcm sample
- * Supported values: 0 - Little endian (all other formats)
- *                   1 - Big endian (AIFF)
- */
-	uint16_t                mode;
-/*
- * Mode to provide additional info about the pcm input data.
- * Supported values: 0 - Default QFs (Q15 for 16b, Q23 for packed 24b,
- *                       Q31 for unpacked 24b or 32b)
- *                  15 - for 16 bit
- *                  23 - for 24b packed or 8.24 format
- *                  31 - for 24b unpacked or 32bit
- */
-} __packed;
-
-/*
- * Payload of the multichannel PCM configuration parameters in
- * the ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3 media format.
- */
-struct asm_multi_channel_pcm_fmt_blk_param_v3 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
-	struct asm_multi_channel_pcm_fmt_blk_v3 param;
-} __packed;
-
-/*
- * Payload of the multichannel PCM configuration parameters in
- * the ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V4 media format.
- */
-struct asm_multi_channel_pcm_fmt_blk_param_v4 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
-	struct asm_multi_channel_pcm_fmt_blk_v4 param;
-} __packed;
-
-struct asm_stream_cmd_set_encdec_param {
-	u32                  param_id;
-	/* ID of the parameter. */
-
-	u32                  param_size;
-/* Data size of this parameter, in bytes. The size is a multiple
- * of 4 bytes.
- */
-
-} __packed;
-
-struct asm_enc_cfg_blk_param_v2 {
-	u32                  frames_per_buf;
-/* Number of encoded frames to pack into each buffer.
- *
- * @note1hang This is only guidance information for the aDSP. The
- * number of encoded frames put into each buffer (specified by the
- * client) is less than or equal to this number.
- */
-
-	u32                  enc_cfg_blk_size;
-/* Size in bytes of the encoder configuration block that follows
- * this member.
- */
-
-} __packed;
-
-/* @brief Dolby Digital Plus end point configuration structure
- */
-struct asm_dec_ddp_endp_param_v2 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	int endp_param_value;
-} __packed;
-
-/*
- * Payload of the multichannel PCM encoder configuration parameters in
- * the ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V4 media format.
- */
-
-struct asm_multi_channel_pcm_enc_cfg_v4 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param encdec;
-	struct asm_enc_cfg_blk_param_v2 encblk;
-	uint16_t num_channels;
-	/*
-	 * Number of PCM channels.
-	 * @values
-	 * - 0 -- Native mode
-	 * - 1 -- 8 channels
-	 * Native mode indicates that encoding must be performed with the number
-	 * of channels at the input.
-	 */
-	uint16_t  bits_per_sample;
-	/*
-	 * Number of bits per sample per channel.
-	 * @values 16, 24
-	 */
-	uint32_t  sample_rate;
-	/*
-	 * Number of samples per second.
-	 * @values 0, 8000 to 48000 Hz
-	 * A value of 0 indicates the native sampling rate. Encoding is
-	 * performed at the input sampling rate.
-	 */
-	uint16_t  is_signed;
-	/*
-	 * Flag that indicates the PCM samples are signed (1). Currently, only
-	 * signed PCM samples are supported.
-	 */
-	uint16_t    sample_word_size;
-	/*
-	 * The size in bits of the word that holds a sample of a channel.
-	 * @values 16, 24, 32
-	 * 16-bit samples are always placed in 16-bit words:
-	 * sample_word_size = 1.
-	 * 24-bit samples can be placed in 32-bit words or in consecutive
-	 * 24-bit words.
-	 * - If sample_word_size = 32, 24-bit samples are placed in the
-	 * most significant 24 bits of a 32-bit word.
-	 * - If sample_word_size = 24, 24-bit samples are placed in
-	 * 24-bit words. @tablebulletend
-	 */
-	uint8_t   channel_mapping[8];
-	/*
-	 * Channel mapping array expected at the encoder output.
-	 *  Channel[i] mapping describes channel i inside the buffer, where
-	 *  0 @le i < num_channels. All valid used channels must be present at
-	 *  the beginning of the array.
-	 * If Native mode is set for the channels, this field is ignored.
-	 * @values See Section @xref{dox:PcmChannelDefs}
-	 */
-	uint16_t                endianness;
-	/*
-	 * Flag to indicate the endianness of the pcm sample
-	 * Supported values: 0 - Little endian (all other formats)
-	 *                   1 - Big endian (AIFF)
-	 */
-	uint16_t                mode;
-	/*
-	 * Mode to provide additional info about the pcm input data.
-	 * Supported values: 0 - Default QFs (Q15 for 16b, Q23 for packed 24b,
-	 *                       Q31 for unpacked 24b or 32b)
-	 *                  15 - for 16 bit
-	 *                  23 - for 24b packed or 8.24 format
-	 *                  31 - for 24b unpacked or 32bit
-	 */
-} __packed;
-
-/*
- * Payload of the multichannel PCM encoder configuration parameters in
- * the ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3 media format.
- */
-
-struct asm_multi_channel_pcm_enc_cfg_v3 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param encdec;
-	struct asm_enc_cfg_blk_param_v2 encblk;
-	uint16_t num_channels;
-	/*
-	 * Number of PCM channels.
-	 * @values
-	 * - 0 -- Native mode
-	 * - 1 -- 8 channels
-	 * Native mode indicates that encoding must be performed with the number
-	 * of channels at the input.
-	 */
-	uint16_t  bits_per_sample;
-	/*
-	 * Number of bits per sample per channel.
-	 * @values 16, 24
-	 */
-	uint32_t  sample_rate;
-	/*
-	 * Number of samples per second.
-	 * @values 0, 8000 to 48000 Hz
-	 * A value of 0 indicates the native sampling rate. Encoding is
-	 * performed at the input sampling rate.
-	 */
-	uint16_t  is_signed;
-	/*
-	 * Flag that indicates the PCM samples are signed (1). Currently, only
-	 * signed PCM samples are supported.
-	 */
-	uint16_t    sample_word_size;
-	/*
-	 * The size in bits of the word that holds a sample of a channel.
-	 * @values 16, 24, 32
-	 * 16-bit samples are always placed in 16-bit words:
-	 * sample_word_size = 1.
-	 * 24-bit samples can be placed in 32-bit words or in consecutive
-	 * 24-bit words.
-	 * - If sample_word_size = 32, 24-bit samples are placed in the
-	 * most significant 24 bits of a 32-bit word.
-	 * - If sample_word_size = 24, 24-bit samples are placed in
-	 * 24-bit words. @tablebulletend
-	 */
-	uint8_t   channel_mapping[8];
-	/*
-	 * Channel mapping array expected at the encoder output.
-	 *  Channel[i] mapping describes channel i inside the buffer, where
-	 *  0 @le i < num_channels. All valid used channels must be present at
-	 *  the beginning of the array.
-	 * If Native mode is set for the channels, this field is ignored.
-	 * @values See Section @xref{dox:PcmChannelDefs}
-	 */
-};
-
-/* @brief Multichannel PCM encoder configuration structure used
- * in the #ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2 command.
- */
-
-struct asm_multi_channel_pcm_enc_cfg_v2 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-	uint16_t  num_channels;
-/*< Number of PCM channels.
- *
- * Supported values: - 0 -- Native mode - 1 -- 8 Native mode
- * indicates that encoding must be performed with the number of
- * channels at the input.
- */
-
-	uint16_t  bits_per_sample;
-/*< Number of bits per sample per channel.
- * Supported values: 16, 24
- */
-
-	uint32_t  sample_rate;
-/*< Number of samples per second (in Hertz).
- *
- * Supported values: 0, 8000 to 48000 A value of 0 indicates the
- * native sampling rate. Encoding is performed at the input sampling
- * rate.
- */
-
-	uint16_t  is_signed;
-/*< Specifies whether the samples are signed (1). Currently,
- * only signed samples are supported.
- */
-
-	uint16_t  reserved;
-/*< reserved field for 32 bit alignment. must be set to zero.*/
-
-
-	uint8_t   channel_mapping[8];
-} __packed;
-
-#define ASM_MEDIA_FMT_MP3 0x00010BE9
-#define ASM_MEDIA_FMT_AAC_V2 0x00010DA6
-
-/* @xreflabel
- * {hdr:AsmMediaFmtDolbyAac} Media format ID for the
- * Dolby AAC decoder. This format ID is be used if the client wants
- * to use the Dolby AAC decoder to decode MPEG2 and MPEG4 AAC
- * contents.
- */
-
-#define ASM_MEDIA_FMT_DOLBY_AAC 0x00010D86
-
-/* Enumeration for the audio data transport stream AAC format. */
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADTS 0
-
-/* Enumeration for low overhead audio stream AAC format. */
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_LOAS                      1
-
-/* Enumeration for the audio data interchange format
- * AAC format.
- */
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADIF   2
-
-/* Enumeration for the raw AAC format. */
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_RAW    3
-
-/* Enumeration for the AAC LATM format. */
-#define ASM_MEDIA_FMT_AAC_FORMAT_FLAG_LATM   4
-
-#define ASM_MEDIA_FMT_AAC_AOT_LC             2
-#define ASM_MEDIA_FMT_AAC_AOT_SBR            5
-#define ASM_MEDIA_FMT_AAC_AOT_PS             29
-#define ASM_MEDIA_FMT_AAC_AOT_BSAC           22
-
-struct asm_aac_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
-
-		u16          aac_fmt_flag;
-/* Bitstream format option.
- * Supported values:
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADTS
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_LOAS
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADIF
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_RAW
- */
-
-	u16          audio_objype;
-/* Audio Object Type (AOT) present in the AAC stream.
- * Supported values:
- * - #ASM_MEDIA_FMT_AAC_AOT_LC
- * - #ASM_MEDIA_FMT_AAC_AOT_SBR
- * - #ASM_MEDIA_FMT_AAC_AOT_BSAC
- * - #ASM_MEDIA_FMT_AAC_AOT_PS
- * - Otherwise -- Not supported
- */
-
-	u16          channel_config;
-/* Number of channels present in the AAC stream.
- * Supported values:
- * - 1 -- Mono
- * - 2 -- Stereo
- * - 6 -- 5.1 content
- */
-
-	u16          total_size_of_PCE_bits;
-/* greater or equal to zero. * -In case of RAW formats and
- * channel config = 0 (PCE), client can send * the bit stream
- * containing PCE immediately following this structure * (in-band).
- * -This number does not include bits included for 32 bit alignment.
- * -If zero, then the PCE info is assumed to be available in the
- * audio -bit stream & not in-band.
- */
-
-	u32          sample_rate;
-/* Number of samples per second (in Hertz).
- *
- * Supported values: 8000, 11025, 12000, 16000, 22050, 24000, 32000,
- * 44100, 48000
- *
- * This field must be equal to the sample rate of the AAC-LC
- * decoder's output. - For MP4 or 3GP containers, this is indicated
- * by the samplingFrequencyIndex field in the AudioSpecificConfig
- * element. - For ADTS format, this is indicated by the
- * samplingFrequencyIndex in the ADTS fixed header. - For ADIF
- * format, this is indicated by the samplingFrequencyIndex in the
- * program_config_element present in the ADIF header.
- */
-
-} __packed;
-
-struct asm_aac_enc_cfg_v2 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-
-	u32          bit_rate;
-	/* Encoding rate in bits per second. */
-	u32          enc_mode;
-/* Encoding mode.
- * Supported values:
- * - #ASM_MEDIA_FMT_AAC_AOT_LC
- * - #ASM_MEDIA_FMT_AAC_AOT_SBR
- * - #ASM_MEDIA_FMT_AAC_AOT_PS
- */
-	u16          aac_fmt_flag;
-/* AAC format flag.
- * Supported values:
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_ADTS
- * - #ASM_MEDIA_FMT_AAC_FORMAT_FLAG_RAW
- */
-	u16          channel_cfg;
-/* Number of channels to encode.
- * Supported values:
- * - 0 -- Native mode
- * - 1 -- Mono
- * - 2 -- Stereo
- * - Other values are not supported.
- * @note1hang The eAAC+ encoder mode supports only stereo.
- * Native mode indicates that encoding must be performed with the
- * number of channels at the input.
- * The number of channels must not change during encoding.
- */
-
-	u32          sample_rate;
-/* Number of samples per second.
- * Supported values: - 0 -- Native mode - For other values,
- * Native mode indicates that encoding must be performed with the
- * sampling rate at the input.
- * The sampling rate must not change during encoding.
- */
-
-} __packed;
-
-#define ASM_MEDIA_FMT_G711_ALAW_FS 0x00010BF7
-#define ASM_MEDIA_FMT_G711_MLAW_FS 0x00010C2E
-
-struct asm_g711_enc_cfg_v2 {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param encdec;
-	struct asm_enc_cfg_blk_param_v2 encblk;
-
-	u32          sample_rate;
-/*
- * Number of samples per second.
- * Supported values: 8000, 16000 Hz
- */
-
-} __packed;
-
-struct asm_vorbis_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-	u32          bit_stream_fmt;
-/* Bit stream format.
- * Supported values:
- * - 0 -- Raw bitstream
- * - 1 -- Transcoded bitstream
- *
- * Transcoded bitstream containing the size of the frame as the first
- * word in each frame.
- */
-
-} __packed;
-
-struct asm_flac_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-
-	u16 is_stream_info_present;
-/* Specifies whether stream information is present in the FLAC format
- * block.
- *
- * Supported values:
- * - 0 -- Stream information is not present in this message
- * - 1 -- Stream information is present in this message
- *
- * When set to 1, the FLAC bitstream was successfully parsed by the
- * client, and other fields in the FLAC format block can be read by the
- * decoder to get metadata stream information.
- */
-
-	u16 num_channels;
-/* Number of channels for decoding.
- * Supported values: 1 to 2
- */
-
-	u16 min_blk_size;
-/* Minimum block size (in samples) used in the stream. It must be less
- * than or equal to max_blk_size.
- */
-
-	u16 max_blk_size;
-/* Maximum block size (in samples) used in the stream. If the
- * minimum block size equals the maximum block size, a fixed block
- * size stream is implied.
- */
-
-	u16 md5_sum[8];
-/* MD5 signature array of the unencoded audio data. This allows the
- * decoder to determine if an error exists in the audio data, even when
- * the error does not result in an invalid bitstream.
- */
-
-	u32 sample_rate;
-/* Number of samples per second.
- * Supported values: 8000 to 48000 Hz
- */
-
-	u32 min_frame_size;
-/* Minimum frame size used in the stream.
- * Supported values:
- * - > 0 bytes
- * - 0 -- The value is unknown
- */
-
-	u32 max_frame_size;
-/* Maximum frame size used in the stream.
- * Supported values:
- * -- > 0 bytes
- * -- 0 . The value is unknown
- */
-
-	u16 sample_size;
-/* Bits per sample.Supported values: 8, 16 */
-
-	u16 reserved;
-/* Clients must set this field to zero
- */
-
-} __packed;
-
-struct asm_alac_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-
-	u32 frame_length;
-	u8 compatible_version;
-	u8 bit_depth;
-	u8 pb;
-	u8 mb;
-	u8 kb;
-	u8 num_channels;
-	u16 max_run;
-	u32 max_frame_bytes;
-	u32 avg_bit_rate;
-	u32 sample_rate;
-	u32 channel_layout_tag;
-
-} __packed;
-
-struct asm_g711_dec_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-	u32 sample_rate;
-} __packed;
-
-struct asm_ape_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-
-	u16 compatible_version;
-	u16 compression_level;
-	u32 format_flags;
-	u32 blocks_per_frame;
-	u32 final_frame_blocks;
-	u32 total_frames;
-	u16 bits_per_sample;
-	u16 num_channels;
-	u32 sample_rate;
-	u32 seek_table_present;
-
-} __packed;
-
-struct asm_dsd_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-
-	u16 num_version;
-	u16 is_bitwise_big_endian;
-	u16 dsd_channel_block_size;
-	u16 num_channels;
-	u8  channel_mapping[8];
-	u32 dsd_data_rate;
-
-} __packed;
-
-#define ASM_MEDIA_FMT_AMRNB_FS                  0x00010BEB
-
-/* Enumeration for 4.75 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MR475                0
-
-/* Enumeration for 5.15 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MR515                1
-
-/* Enumeration for 5.90 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR59                2
-
-/* Enumeration for 6.70 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR67                3
-
-/* Enumeration for 7.40 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR74                4
-
-/* Enumeration for 7.95 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR795               5
-
-/* Enumeration for 10.20 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR102               6
-
-/* Enumeration for 12.20 kbps AMR-NB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_MMR122               7
-
-/* Enumeration for AMR-NB Discontinuous Transmission mode off. */
-#define ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_OFF                     0
-
-/* Enumeration for AMR-NB DTX mode VAD1. */
-#define ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_VAD1                    1
-
-/* Enumeration for AMR-NB DTX mode VAD2. */
-#define ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_VAD2                    2
-
-/* Enumeration for AMR-NB DTX mode auto. */
-#define ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_AUTO                    3
-
-struct asm_amrnb_enc_cfg {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-
-	u16          enc_mode;
-/* AMR-NB encoding rate.
- * Supported values:
- * Use the ASM_MEDIA_FMT_AMRNB_FS_ENCODE_MODE_*
- * macros
- */
-
-	u16          dtx_mode;
-/* Specifies whether DTX mode is disabled or enabled.
- * Supported values:
- * - #ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_OFF
- * - #ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_VAD1
- */
-} __packed;
-
-#define ASM_MEDIA_FMT_AMRWB_FS                  0x00010BEC
-
-/* Enumeration for 6.6 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR66                 0
-
-/* Enumeration for 8.85 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR885                1
-
-/* Enumeration for 12.65 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR1265               2
-
-/* Enumeration for 14.25 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR1425               3
-
-/* Enumeration for 15.85 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR1585               4
-
-/* Enumeration for 18.25 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR1825               5
-
-/* Enumeration for 19.85 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR1985               6
-
-/* Enumeration for 23.05 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR2305               7
-
-/* Enumeration for 23.85 kbps AMR-WB Encoding mode. */
-#define ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_MR2385               8
-
-struct asm_amrwb_enc_cfg {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-
-	u16          enc_mode;
-/* AMR-WB encoding rate.
- * Suupported values:
- * Use the ASM_MEDIA_FMT_AMRWB_FS_ENCODE_MODE_*
- * macros
- */
-
-	u16          dtx_mode;
-/* Specifies whether DTX mode is disabled or enabled.
- * Supported values:
- * - #ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_OFF
- * - #ASM_MEDIA_FMT_AMRNB_FS_DTX_MODE_VAD1
- */
-} __packed;
-
-#define ASM_MEDIA_FMT_V13K_FS                      0x00010BED
-
-/* Enumeration for 14.4 kbps V13K Encoding mode. */
-#define ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1440                0
-
-/* Enumeration for 12.2 kbps V13K Encoding mode. */
-#define ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1220                1
-
-/* Enumeration for 11.2 kbps V13K Encoding mode. */
-#define ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1120                2
-
-/* Enumeration for 9.0 kbps V13K Encoding mode. */
-#define ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR90                  3
-
-/* Enumeration for 7.2 kbps V13K eEncoding mode. */
-#define ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR720                 4
-
-/* Enumeration for 1/8 vocoder rate.*/
-#define ASM_MEDIA_FMT_VOC_ONE_EIGHTH_RATE          1
-
-/* Enumeration for 1/4 vocoder rate. */
-#define ASM_MEDIA_FMT_VOC_ONE_FOURTH_RATE       2
-
-/* Enumeration for 1/2 vocoder rate. */
-#define ASM_MEDIA_FMT_VOC_HALF_RATE             3
-
-/* Enumeration for full vocoder rate. */
-#define ASM_MEDIA_FMT_VOC_FULL_RATE             4
-
-struct asm_v13k_enc_cfg {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-		u16          max_rate;
-/* Maximum allowed encoder frame rate.
- * Supported values:
- * - #ASM_MEDIA_FMT_VOC_ONE_EIGHTH_RATE
- * - #ASM_MEDIA_FMT_VOC_ONE_FOURTH_RATE
- * - #ASM_MEDIA_FMT_VOC_HALF_RATE
- * - #ASM_MEDIA_FMT_VOC_FULL_RATE
- */
-
-	u16          min_rate;
-/* Minimum allowed encoder frame rate.
- * Supported values:
- * - #ASM_MEDIA_FMT_VOC_ONE_EIGHTH_RATE
- * - #ASM_MEDIA_FMT_VOC_ONE_FOURTH_RATE
- * - #ASM_MEDIA_FMT_VOC_HALF_RATE
- * - #ASM_MEDIA_FMT_VOC_FULL_RATE
- */
-
-	u16          reduced_rate_cmd;
-/* Reduced rate command, used to change
- * the average bitrate of the V13K
- * vocoder.
- * Supported values:
- * - #ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1440 (Default)
- * - #ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1220
- * - #ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR1120
- * - #ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR90
- * - #ASM_MEDIA_FMT_V13K_FS_ENCODE_MODE_MR720
- */
-
-	u16          rate_mod_cmd;
-/* Rate modulation command. Default = 0.
- *- If bit 0=1, rate control is enabled.
- *- If bit 1=1, the maximum number of consecutive full rate
- *			frames is limited with numbers supplied in
- *			bits 2 to 10.
- *- If bit 1=0, the minimum number of non-full rate frames
- *			in between two full rate frames is forced to
- * the number supplied in bits 2 to 10. In both cases, if necessary,
- * half rate is used to substitute full rate. - Bits 15 to 10 are
- * reserved and must all be set to zero.
- */
-
-} __packed;
-
-#define ASM_MEDIA_FMT_EVRC_FS                   0x00010BEE
-
-/*  EVRC encoder configuration structure used in the
- * #ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2 command.
- */
-struct asm_evrc_enc_cfg {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-	u16          max_rate;
-/* Maximum allowed encoder frame rate.
- * Supported values:
- * - #ASM_MEDIA_FMT_VOC_ONE_EIGHTH_RATE
- * - #ASM_MEDIA_FMT_VOC_ONE_FOURTH_RATE
- * - #ASM_MEDIA_FMT_VOC_HALF_RATE
- * - #ASM_MEDIA_FMT_VOC_FULL_RATE
- */
-
-	u16          min_rate;
-/* Minimum allowed encoder frame rate.
- * Supported values:
- * - #ASM_MEDIA_FMT_VOC_ONE_EIGHTH_RATE
- * - #ASM_MEDIA_FMT_VOC_ONE_FOURTH_RATE
- * - #ASM_MEDIA_FMT_VOC_HALF_RATE
- * - #ASM_MEDIA_FMT_VOC_FULL_RATE
- */
-
-	u16          rate_mod_cmd;
-/* Rate modulation command. Default: 0.
- * - If bit 0=1, rate control is enabled.
- * - If bit 1=1, the maximum number of consecutive full rate frames
- * is limited with numbers supplied in bits 2 to 10.
- *
- * - If bit 1=0, the minimum number of non-full rate frames in
- * between two full rate frames is forced to the number supplied in
- * bits 2 to 10. In both cases, if necessary, half rate is used to
- * substitute full rate.
- *
- * - Bits 15 to 10 are reserved and must all be set to zero.
- */
-
-	u16          reserved;
-	/* Reserved. Clients must set this field to zero. */
-} __packed;
-
-#define ASM_MEDIA_FMT_WMA_V10PRO_V2                0x00010DA7
-
-struct asm_wmaprov10_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-
-	u16          fmtag;
-/* WMA format type.
- * Supported values:
- * - 0x162 -- WMA 9 Pro
- * - 0x163 -- WMA 9 Pro Lossless
- * - 0x166 -- WMA 10 Pro
- * - 0x167 -- WMA 10 Pro Lossless
- */
-
-	u16          num_channels;
-/* Number of channels encoded in the input stream.
- * Supported values: 1 to 8
- */
-
-	u32          sample_rate;
-/* Number of samples per second (in Hertz).
- * Supported values: 11025, 16000, 22050, 32000, 44100, 48000,
- * 88200, 96000
- */
-
-	u32          avg_bytes_per_sec;
-/* Bitrate expressed as the average bytes per second.
- * Supported values: 2000 to 96000
- */
-
-	u16          blk_align;
-/* Size of the bitstream packet size in bytes. WMA Pro files
- * have a payload of one block per bitstream packet.
- * Supported values: @le 13376
- */
-
-	u16          bits_per_sample;
-/* Number of bits per sample in the encoded WMA stream.
- * Supported values: 16, 24
- */
-
-	u32          channel_mask;
-/* Bit-packed double word (32-bits) that indicates the
- * recommended speaker positions for each source channel.
- */
-
-	u16          enc_options;
-/* Bit-packed word with values that indicate whether certain
- * features of the bitstream are used.
- * Supported values: - 0x0001 -- ENCOPT3_PURE_LOSSLESS - 0x0006 --
- * ENCOPT3_FRM_SIZE_MOD - 0x0038 -- ENCOPT3_SUBFRM_DIV - 0x0040 --
- * ENCOPT3_WRITE_FRAMESIZE_IN_HDR - 0x0080 --
- * ENCOPT3_GENERATE_DRC_PARAMS - 0x0100 -- ENCOPT3_RTMBITS
- */
-
-
-	u16          usAdvancedEncodeOpt;
-	/* Advanced encoding option.  */
-
-	u32          advanced_enc_options2;
-	/* Advanced encoding option 2. */
-
-} __packed;
-
-#define ASM_MEDIA_FMT_WMA_V9_V2                    0x00010DA8
-struct asm_wmastdv9_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-	u16          fmtag;
-/* WMA format tag.
- * Supported values: 0x161 (WMA 9 standard)
- */
-
-	u16          num_channels;
-/* Number of channels in the stream.
- * Supported values: 1, 2
- */
-
-	u32          sample_rate;
-/* Number of samples per second (in Hertz).
- * Supported values: 48000
- */
-
-	u32          avg_bytes_per_sec;
-	/* Bitrate expressed as the average bytes per second. */
-
-	u16          blk_align;
-/* Block align. All WMA files with a maximum packet size of
- * 13376 are supported.
- */
-
-
-	u16          bits_per_sample;
-/* Number of bits per sample in the output.
- * Supported values: 16
- */
-
-	u32          channel_mask;
-/* Channel mask.
- * Supported values:
- * - 3 -- Stereo (front left/front right)
- * - 4 -- Mono (center)
- */
-
-	u16          enc_options;
-	/* Options used during encoding. */
-
-	u16          reserved;
-
-} __packed;
-
-#define ASM_MEDIA_FMT_WMA_V8                    0x00010D91
-
-struct asm_wmastdv8_enc_cfg {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-	u32          bit_rate;
-	/* Encoding rate in bits per second. */
-
-	u32          sample_rate;
-/* Number of samples per second.
- *
- * Supported values:
- * - 0 -- Native mode
- * - Other Supported values are 22050, 32000, 44100, and 48000.
- *
- * Native mode indicates that encoding must be performed with the
- * sampling rate at the input.
- * The sampling rate must not change during encoding.
- */
-
-	u16          channel_cfg;
-/* Number of channels to encode.
- * Supported values:
- * - 0 -- Native mode
- * - 1 -- Mono
- * - 2 -- Stereo
- * - Other values are not supported.
- *
- * Native mode indicates that encoding must be performed with the
- * number of channels at the input.
- * The number of channels must not change during encoding.
- */
-
-	u16          reserved;
-	/* Reserved. Clients must set this field to zero.*/
-	} __packed;
-
-#define ASM_MEDIA_FMT_AMR_WB_PLUS_V2               0x00010DA9
-
-struct asm_amrwbplus_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-	u32          amr_frame_fmt;
-/* AMR frame format.
- * Supported values:
- * - 6 -- Transport Interface Format (TIF)
- * - Any other value -- File storage format (FSF)
- *
- * TIF stream contains 2-byte header for each frame within the
- * superframe. FSF stream contains one 2-byte header per superframe.
- */
-
-} __packed;
-
-#define ASM_MEDIA_FMT_AC3                    0x00010DEE
-#define ASM_MEDIA_FMT_EAC3                   0x00010DEF
-#define ASM_MEDIA_FMT_DTS                    0x00010D88
-#define ASM_MEDIA_FMT_MP2                    0x00010DE9
-#define ASM_MEDIA_FMT_FLAC                   0x00010C16
-#define ASM_MEDIA_FMT_ALAC                   0x00012F31
-#define ASM_MEDIA_FMT_VORBIS                 0x00010C15
-#define ASM_MEDIA_FMT_APE                    0x00012F32
-#define ASM_MEDIA_FMT_DSD                    0x00012F3E
-#define ASM_MEDIA_FMT_TRUEHD                 0x00013215
-/* 0x0 is used for fomat ID since ADSP dynamically determines the
- * format encapsulated in the IEC61937 (compressed) or IEC60958
- * (pcm) packets.
- */
-#define ASM_MEDIA_FMT_IEC                    0x00000000
-
-/* Media format ID for adaptive transform acoustic coding. This
- * ID is used by the #ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED command
- * only.
- */
-
-#define ASM_MEDIA_FMT_ATRAC                  0x00010D89
-
-/* Media format ID for metadata-enhanced audio transmission.
- * This ID is used by the #ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED
- * command only.
- */
-
-#define ASM_MEDIA_FMT_MAT                    0x00010D8A
-
-/*  adsp_media_fmt.h */
-
-#define ASM_DATA_CMD_WRITE_V2 0x00010DAB
-
-struct asm_data_cmd_write_v2 {
-	struct apr_hdr hdr;
-	u32                  buf_addr_lsw;
-/* The 64 bit address msw-lsw should be a valid, mapped address.
- * 64 bit address should be a multiple of 32 bytes
- */
-
-	u32                  buf_addr_msw;
-/* The 64 bit address msw-lsw should be a valid, mapped address.
- * 64 bit address should be a multiple of 32 bytes.
- * -Address of the buffer containing the data to be decoded.
- * The buffer should be aligned to a 32 byte boundary.
- * -In the case of 32 bit Shared memory address, msw field must
- * -be set to zero.
- * -In the case of 36 bit shared memory address, bit 31 to bit 4
- * -of msw must be set to zero.
- */
-	u32                  mem_map_handle;
-/* memory map handle returned by DSP through
- * ASM_CMD_SHARED_MEM_MAP_REGIONS command
- */
-	u32                  buf_size;
-/* Number of valid bytes available in the buffer for decoding. The
- * first byte starts at buf_addr.
- */
-
-	u32                  seq_id;
-	/* Optional buffer sequence ID. */
-
-	u32                  timestamp_lsw;
-/* Lower 32 bits of the 64-bit session time in microseconds of the
- * first buffer sample.
- */
-
-	u32                  timestamp_msw;
-/* Upper 32 bits of the 64-bit session time in microseconds of the
- * first buffer sample.
- */
-
-	u32                  flags;
-/* Bitfield of flags.
- * Supported values for bit 31:
- * - 1 -- Valid timestamp.
- * - 0 -- Invalid timestamp.
- * - Use #ASM_BIT_MASKIMESTAMP_VALID_FLAG as the bitmask and
- * #ASM_SHIFTIMESTAMP_VALID_FLAG as the shift value to set this bit.
- * Supported values for bit 30:
- * - 1 -- Last buffer.
- * - 0 -- Not the last buffer.
- *
- * Supported values for bit 29:
- * - 1 -- Continue the timestamp from the previous buffer.
- * - 0 -- Timestamp of the current buffer is not related
- * to the timestamp of the previous buffer.
- * - Use #ASM_BIT_MASKS_CONTINUE_FLAG and #ASM_SHIFTS_CONTINUE_FLAG
- * to set this bit.
- *
- * Supported values for bit 4:
- * - 1 -- End of the frame.
- * - 0 -- Not the end of frame, or this information is not known.
- * - Use #ASM_BIT_MASK_EOF_FLAG as the bitmask and #ASM_SHIFT_EOF_FLAG
- * as the shift value to set this bit.
- *
- * All other bits are reserved and must be set to 0.
- *
- * If bit 31=0 and bit 29=1: The timestamp of the first sample in
- * this buffer continues from the timestamp of the last sample in
- * the previous buffer. If there is no previous buffer (i.e., this
- * is the first buffer sent after opening the stream or after a
- * flush operation), or if the previous buffer does not have a valid
- * timestamp, the samples in the current buffer also do not have a
- * valid timestamp. They are played out as soon as possible.
- *
- *
- * If bit 31=0 and bit 29=0: No timestamp is associated with the
- * first sample in this buffer. The samples are played out as soon
- * as possible.
- *
- *
- * If bit 31=1 and bit 29 is ignored: The timestamp specified in
- * this payload is honored.
- *
- *
- * If bit 30=0: Not the last buffer in the stream. This is useful
- * in removing trailing samples.
- *
- *
- * For bit 4: The client can set this flag for every buffer sent in
- * which the last byte is the end of a frame. If this flag is set,
- * the buffer can contain data from multiple frames, but it should
- * always end at a frame boundary. Restrictions allow the aDSP to
- * detect an end of frame without requiring additional processing.
- */
-
-} __packed;
-
-#define ASM_DATA_CMD_READ_V2 0x00010DAC
-
-struct asm_data_cmd_read_v2 {
-	struct apr_hdr       hdr;
-	u32                  buf_addr_lsw;
-/* the 64 bit address msw-lsw should be a valid mapped address
- * and should be a multiple of 32 bytes
- */
-
-
-	u32                  buf_addr_msw;
-/* the 64 bit address msw-lsw should be a valid mapped address
- * and should be a multiple of 32 bytes.
- * - Address of the buffer where the DSP puts the encoded data,
- * potentially, at an offset specified by the uOffset field in
- * ASM_DATA_EVENT_READ_DONE structure. The buffer should be aligned
- * to a 32 byte boundary.
- * - In the case of 32 bit Shared memory address, msw field must
- * - be set to zero.
- * - In the case of 36 bit shared memory address, bit 31 to bit
- * - 4 of msw must be set to zero.
- */
-	u32                  mem_map_handle;
-/* memory map handle returned by DSP through
- * ASM_CMD_SHARED_MEM_MAP_REGIONS command.
- */
-
-	u32                  buf_size;
-/* Number of bytes available for the aDSP to write. The aDSP
- * starts writing from buf_addr.
- */
-
-	u32                  seq_id;
-	/* Optional buffer sequence ID. */
-} __packed;
-
-#define ASM_DATA_CMD_EOS               0x00010BDB
-#define ASM_DATA_EVENT_RENDERED_EOS    0x00010C1C
-#define ASM_DATA_EVENT_EOS             0x00010BDD
-
-#define ASM_DATA_EVENT_WRITE_DONE_V2 0x00010D99
-struct asm_data_event_write_done_v2 {
-	u32                  buf_addr_lsw;
-	/* lsw of the 64 bit address */
-	u32                  buf_addr_msw;
-	/* msw of the 64 bit address. address given by the client in
-	 * ASM_DATA_CMD_WRITE_V2 command.
-	 */
-	u32                  mem_map_handle;
-	/* memory map handle in the ASM_DATA_CMD_WRITE_V2 */
-
-	u32                  status;
-/* Status message (error code) that indicates whether the
- * referenced buffer has been successfully consumed.
- * Supported values: Refer to @xhyperref{Q3,[Q3]}
- */
-} __packed;
-
-#define ASM_DATA_EVENT_READ_DONE_V2 0x00010D9A
-
-/* Definition of the frame metadata flag bitmask.*/
-#define ASM_BIT_MASK_FRAME_METADATA_FLAG (0x40000000UL)
-
-/* Definition of the frame metadata flag shift value. */
-#define ASM_SHIFT_FRAME_METADATA_FLAG 30
-
-struct asm_data_event_read_done_v2 {
-	u32                  status;
-/* Status message (error code).
- * Supported values: Refer to @xhyperref{Q3,[Q3]}
- */
-
-u32                  buf_addr_lsw;
-/* 64 bit address msw-lsw is a valid, mapped address. 64 bit
- * address is a multiple of 32 bytes.
- */
-
-u32                  buf_addr_msw;
-/* 64 bit address msw-lsw is a valid, mapped address. 64 bit
- * address is a multiple of 32 bytes.
- *
- * -Same address provided by the client in ASM_DATA_CMD_READ_V2
- * -In the case of 32 bit Shared memory address, msw field is set to
- * zero.
- * -In the case of 36 bit shared memory address, bit 31 to bit 4
- * -of msw is set to zero.
- */
-
-u32                  mem_map_handle;
-/* memory map handle in the ASM_DATA_CMD_READ_V2  */
-
-u32                  enc_framesotal_size;
-/* Total size of the encoded frames in bytes.
- * Supported values: >0
- */
-
-u32                  offset;
-/* Offset (from buf_addr) to the first byte of the first encoded
- * frame. All encoded frames are consecutive, starting from this
- * offset.
- * Supported values: > 0
- */
-
-u32                  timestamp_lsw;
-/* Lower 32 bits of the 64-bit session time in microseconds of
- * the first sample in the buffer. If Bit 5 of mode_flags flag of
- * ASM_STREAM_CMD_OPEN_READ_V2 is 1 then the 64 bit timestamp is
- * absolute capture time otherwise it is relative session time. The
- * absolute timestamp doesn't reset unless the system is reset.
- */
-
-
-u32                  timestamp_msw;
-/* Upper 32 bits of the 64-bit session time in microseconds of
- * the first sample in the buffer.
- */
-
-
-u32                  flags;
-/* Bitfield of flags. Bit 30 indicates whether frame metadata is
- * present. If frame metadata is present, num_frames consecutive
- * instances of @xhyperref{hdr:FrameMetaData,Frame metadata} start
- * at the buffer address.
- * Supported values for bit 31:
- * - 1 -- Timestamp is valid.
- * - 0 -- Timestamp is invalid.
- * - Use #ASM_BIT_MASKIMESTAMP_VALID_FLAG and
- * #ASM_SHIFTIMESTAMP_VALID_FLAG to set this bit.
- *
- * Supported values for bit 30:
- * - 1 -- Frame metadata is present.
- * - 0 -- Frame metadata is absent.
- * - Use #ASM_BIT_MASK_FRAME_METADATA_FLAG and
- * #ASM_SHIFT_FRAME_METADATA_FLAG to set this bit.
- *
- * All other bits are reserved; the aDSP sets them to 0.
- */
-
-u32                  num_frames;
-/* Number of encoded frames in the buffer. */
-
-u32                  seq_id;
-/* Optional buffer sequence ID.	*/
-} __packed;
-
-struct asm_data_read_buf_metadata_v2 {
-	u32          offset;
-/* Offset from buf_addr in #ASM_DATA_EVENT_READ_DONE_PAYLOAD to
- * the frame associated with this metadata.
- * Supported values: > 0
- */
-
-u32          frm_size;
-/* Size of the encoded frame in bytes.
- * Supported values: > 0
- */
-
-u32          num_encoded_pcm_samples;
-/* Number of encoded PCM samples (per channel) in the frame
- * associated with this metadata.
- * Supported values: > 0
- */
-
-u32          timestamp_lsw;
-/* Lower 32 bits of the 64-bit session time in microseconds of the
- * first sample for this frame.
- * If Bit 5 of mode_flags flag of ASM_STREAM_CMD_OPEN_READ_V2 is 1
- * then the 64 bit timestamp is absolute capture time otherwise it
- * is relative session time. The absolute timestamp doesn't reset
- * unless the system is reset.
- */
-
-
-u32          timestamp_msw;
-/* Lower 32 bits of the 64-bit session time in microseconds of the
- * first sample for this frame.
- */
-
-u32          flags;
-/* Frame flags.
- * Supported values for bit 31:
- * - 1 -- Time stamp is valid
- * - 0 -- Time stamp is not valid
- * - All other bits are reserved; the aDSP sets them to 0.
- */
-} __packed;
-
-/* Notifies the client of a change in the data sampling rate or
- * Channel mode. This event is raised by the decoder service. The
- * event is enabled through the mode flags of
- * #ASM_STREAM_CMD_OPEN_WRITE_V2 or
- * #ASM_STREAM_CMD_OPEN_READWRITE_V2. - The decoder detects a change
- * in the output sampling frequency or the number/positioning of
- * output channels, or if it is the first frame decoded.The new
- * sampling frequency or the new channel configuration is
- * communicated back to the client asynchronously.
- */
-
-#define ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY 0x00010C65
-
-/*  Payload of the #ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY event.
- * This event is raised when the following conditions are both true:
- * - The event is enabled through the mode_flags of
- * #ASM_STREAM_CMD_OPEN_WRITE_V2 or
- * #ASM_STREAM_CMD_OPEN_READWRITE_V2. - The decoder detects a change
- * in either the output sampling frequency or the number/positioning
- * of output channels, or if it is the first frame decoded.
- * This event is not raised (even if enabled) if the decoder is
- * MIDI, because
- */
-
-
-struct asm_data_event_sr_cm_change_notify {
-	u32                  sample_rate;
-/* New sampling rate (in Hertz) after detecting a change in the
- * bitstream.
- * Supported values: 2000 to 48000
- */
-
-	u16                  num_channels;
-/* New number of channels after detecting a change in the
- * bitstream.
- * Supported values: 1 to 8
- */
-
-
-	u16                  reserved;
-	/* Reserved for future use. This field must be set to 0.*/
-
-	u8                   channel_mapping[8];
-
-} __packed;
-
-/* Notifies the client of a data sampling rate or channel mode
- * change. This event is raised by the encoder service.
- * This event is raised when :
- * - Native mode encoding was requested in the encoder
- * configuration (i.e., the channel number was 0), the sample rate
- * was 0, or both were 0.
- *
- * - The input data frame at the encoder is the first one, or the
- * sampling rate/channel mode is different from the previous input
- * data frame.
- *
- */
-#define ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY 0x00010BDE
-
-struct asm_data_event_enc_sr_cm_change_notify {
-	u32                  sample_rate;
-/* New sampling rate (in Hertz) after detecting a change in the
- * input data.
- * Supported values: 2000 to 48000
- */
-
-
-	u16                  num_channels;
-/* New number of channels after detecting a change in the input
- * data. Supported values: 1 to 8
- */
-
-
-	u16                  bits_per_sample;
-/* New bits per sample after detecting a change in the input
- * data.
- * Supported values: 16, 24
- */
-
-
-	u8                   channel_mapping[8];
-
-} __packed;
-#define ASM_DATA_CMD_IEC_60958_FRAME_RATE 0x00010D87
-
-
-/* Payload of the #ASM_DATA_CMD_IEC_60958_FRAME_RATE command,
- * which is used to indicate the IEC 60958 frame rate of a given
- * packetized audio stream.
- */
-
-struct asm_data_cmd_iec_60958_frame_rate {
-	u32                  frame_rate;
-/* IEC 60958 frame rate of the incoming IEC 61937 packetized stream.
- * Supported values: Any valid frame rate
- */
-} __packed;
-
-/* adsp_asm_data_commands.h*/
-/* Definition of the stream ID bitmask.*/
-#define ASM_BIT_MASK_STREAM_ID                 (0x000000FFUL)
-
-/* Definition of the stream ID shift value.*/
-#define ASM_SHIFT_STREAM_ID                    0
-
-/* Definition of the session ID bitmask.*/
-#define ASM_BIT_MASK_SESSION_ID                (0x0000FF00UL)
-
-/* Definition of the session ID shift value.*/
-#define ASM_SHIFT_SESSION_ID                   8
-
-/* Definition of the service ID bitmask.*/
-#define ASM_BIT_MASK_SERVICE_ID                (0x00FF0000UL)
-
-/* Definition of the service ID shift value.*/
-#define ASM_SHIFT_SERVICE_ID                   16
-
-/* Definition of the domain ID bitmask.*/
-#define ASM_BIT_MASK_DOMAIN_ID                (0xFF000000UL)
-
-/* Definition of the domain ID shift value.*/
-#define ASM_SHIFT_DOMAIN_ID                    24
-
-#define ASM_CMD_SHARED_MEM_MAP_REGIONS               0x00010D92
-#define ASM_CMDRSP_SHARED_MEM_MAP_REGIONS     0x00010D93
-#define ASM_CMD_SHARED_MEM_UNMAP_REGIONS              0x00010D94
-
-/* adsp_asm_service_commands.h */
-
-#define ASM_MAX_SESSION_ID  (15)
-
-/* Maximum number of sessions.*/
-#define ASM_MAX_NUM_SESSIONS                ASM_MAX_SESSION_ID
-
-/* Maximum number of streams per session.*/
-#define ASM_MAX_STREAMS_PER_SESSION (8)
-#define ASM_SESSION_CMD_RUN_V2                   0x00010DAA
-#define ASM_SESSION_CMD_RUN_STARTIME_RUN_IMMEDIATE  0
-#define ASM_SESSION_CMD_RUN_STARTIME_RUN_AT_ABSOLUTEIME 1
-#define ASM_SESSION_CMD_RUN_STARTIME_RUN_AT_RELATIVEIME 2
-#define ASM_SESSION_CMD_RUN_STARTIME_RUN_WITH_DELAY     3
-
-#define ASM_BIT_MASK_RUN_STARTIME                 (0x00000003UL)
-
-/* Bit shift value used to specify the start time for the
- * ASM_SESSION_CMD_RUN_V2 command.
- */
-#define ASM_SHIFT_RUN_STARTIME 0
-struct asm_session_cmd_run_v2 {
-	struct apr_hdr hdr;
-	u32                  flags;
-/* Specifies whether to run immediately or at a specific
- * rendering time or with a specified delay. Run with delay is
- * useful for delaying in case of ASM loopback opened through
- * ASM_STREAM_CMD_OPEN_LOOPBACK_V2. Use #ASM_BIT_MASK_RUN_STARTIME
- * and #ASM_SHIFT_RUN_STARTIME to set this 2-bit flag.
- *
- *
- *Bits 0 and 1 can take one of four possible values:
- *
- *- #ASM_SESSION_CMD_RUN_STARTIME_RUN_IMMEDIATE
- *- #ASM_SESSION_CMD_RUN_STARTIME_RUN_AT_ABSOLUTEIME
- *- #ASM_SESSION_CMD_RUN_STARTIME_RUN_AT_RELATIVEIME
- *- #ASM_SESSION_CMD_RUN_STARTIME_RUN_WITH_DELAY
- *
- *All other bits are reserved; clients must set them to zero.
- */
-
-	u32                  time_lsw;
-/* Lower 32 bits of the time in microseconds used to align the
- * session origin time. When bits 0-1 of flags is
- * ASM_SESSION_CMD_RUN_START_RUN_WITH_DELAY, time lsw is the lsw of
- * the delay in us. For ASM_SESSION_CMD_RUN_START_RUN_WITH_DELAY,
- * maximum value of the 64 bit delay is 150 ms.
- */
-
-	u32                  time_msw;
-/* Upper 32 bits of the time in microseconds used to align the
- * session origin time. When bits 0-1 of flags is
- * ASM_SESSION_CMD_RUN_START_RUN_WITH_DELAY, time msw is the msw of
- * the delay in us. For ASM_SESSION_CMD_RUN_START_RUN_WITH_DELAY,
- * maximum value of the 64 bit delay is 150 ms.
- */
-
-} __packed;
-
-#define ASM_SESSION_CMD_PAUSE 0x00010BD3
-#define ASM_SESSION_CMD_SUSPEND 0x00010DEC
-#define ASM_SESSION_CMD_GET_SESSIONTIME_V3 0x00010D9D
-#define ASM_SESSION_CMD_REGISTER_FOR_RX_UNDERFLOW_EVENTS 0x00010BD5
-
-struct asm_session_cmd_rgstr_rx_underflow {
-	struct apr_hdr hdr;
-	u16                  enable_flag;
-/* Specifies whether a client is to receive events when an Rx
- * session underflows.
- * Supported values:
- * - 0 -- Do not send underflow events
- * - 1 -- Send underflow events
- */
-	u16                  reserved;
-	/* Reserved. This field must be set to zero.*/
-} __packed;
-
-#define ASM_SESSION_CMD_REGISTER_FORX_OVERFLOW_EVENTS 0x00010BD6
-
-struct asm_session_cmd_regx_overflow {
-	struct apr_hdr hdr;
-	u16                  enable_flag;
-/* Specifies whether a client is to receive events when a Tx
- * session overflows.
- * Supported values:
- * - 0 -- Do not send overflow events
- * - 1 -- Send overflow events
- */
-
-	u16                  reserved;
-	/* Reserved. This field must be set to zero.*/
-} __packed;
-
-#define ASM_SESSION_EVENT_RX_UNDERFLOW        0x00010C17
-#define ASM_SESSION_EVENTX_OVERFLOW           0x00010C18
-#define ASM_SESSION_CMDRSP_GET_SESSIONTIME_V3 0x00010D9E
-
-struct asm_session_cmdrsp_get_sessiontime_v3 {
-	u32                  status;
-	/* Status message (error code).
-	 * Supported values: Refer to @xhyperref{Q3,[Q3]}
-	 */
-
-	u32                  sessiontime_lsw;
-	/* Lower 32 bits of the current session time in microseconds.*/
-
-	u32                  sessiontime_msw;
-	/* Upper 32 bits of the current session time in microseconds.*/
-
-	u32                  absolutetime_lsw;
-/* Lower 32 bits in micro seconds of the absolute time at which
- * the * sample corresponding to the above session time gets
- * rendered * to hardware. This absolute time may be slightly in the
- * future or past.
- */
-
-
-	u32                  absolutetime_msw;
-/* Upper 32 bits in micro seconds of the absolute time at which
- * the * sample corresponding to the above session time gets
- * rendered to * hardware. This absolute time may be slightly in the
- * future or past.
- */
-
-} __packed;
-
-#define ASM_SESSION_CMD_ADJUST_SESSION_CLOCK_V2     0x00010D9F
-
-struct asm_session_cmd_adjust_session_clock_v2 {
-	struct apr_hdr hdr;
-u32                  adjustime_lsw;
-/* Lower 32 bits of the signed 64-bit quantity that specifies the
- * adjustment time in microseconds to the session clock.
- *
- * Positive values indicate advancement of the session clock.
- * Negative values indicate delay of the session clock.
- */
-
-
-	u32                  adjustime_msw;
-/* Upper 32 bits of the signed 64-bit quantity that specifies
- * the adjustment time in microseconds to the session clock.
- * Positive values indicate advancement of the session clock.
- * Negative values indicate delay of the session clock.
- */
-
-} __packed;
-
-#define ASM_SESSION_CMDRSP_ADJUST_SESSION_CLOCK_V2    0x00010DA0
-
-struct asm_session_cmdrsp_adjust_session_clock_v2 {
-	u32                  status;
-/* Status message (error code).
- * Supported values: Refer to @xhyperref{Q3,[Q3]}
- * An error means the session clock is not adjusted. In this case,
- * the next two fields are irrelevant.
- */
-
-
-	u32                  actual_adjustime_lsw;
-/* Lower 32 bits of the signed 64-bit quantity that specifies
- * the actual adjustment in microseconds performed by the aDSP.
- * A positive value indicates advancement of the session clock. A
- * negative value indicates delay of the session clock.
- */
-
-
-	u32                  actual_adjustime_msw;
-/* Upper 32 bits of the signed 64-bit quantity that specifies
- * the actual adjustment in microseconds performed by the aDSP.
- * A positive value indicates advancement of the session clock. A
- * negative value indicates delay of the session clock.
- */
-
-
-	u32                  cmd_latency_lsw;
-/* Lower 32 bits of the unsigned 64-bit quantity that specifies
- * the amount of time in microseconds taken to perform the session
- * clock adjustment.
- */
-
-
-	u32                  cmd_latency_msw;
-/* Upper 32 bits of the unsigned 64-bit quantity that specifies
- * the amount of time in microseconds taken to perform the session
- * clock adjustment.
- */
-
-} __packed;
-
-#define ASM_SESSION_CMD_GET_PATH_DELAY_V2	 0x00010DAF
-#define ASM_SESSION_CMDRSP_GET_PATH_DELAY_V2 0x00010DB0
-
-struct asm_session_cmdrsp_get_path_delay_v2 {
-	u32                  status;
-/* Status message (error code). Whether this get delay operation
- * is successful or not. Delay value is valid only if status is
- * success.
- * Supported values: Refer to @xhyperref{Q5,[Q5]}
- */
-
-	u32                  audio_delay_lsw;
-	/* Upper 32 bits of the aDSP delay in microseconds. */
-
-	u32                  audio_delay_msw;
-	/* Lower 32 bits of the aDSP delay  in microseconds. */
-
-} __packed;
-
-/* adsp_asm_session_command.h*/
-#define ASM_STREAM_CMD_OPEN_WRITE_V3       0x00010DB3
-
-#define ASM_LOW_LATENCY_STREAM_SESSION				0x10000000
-
-#define ASM_ULTRA_LOW_LATENCY_STREAM_SESSION			0x20000000
-
-#define ASM_ULL_POST_PROCESSING_STREAM_SESSION			0x40000000
-
-#define ASM_LEGACY_STREAM_SESSION                                      0
-
-
-struct asm_stream_cmd_open_write_v3 {
-	struct apr_hdr			hdr;
-	uint32_t                    mode_flags;
-/* Mode flags that configure the stream to notify the client
- * whenever it detects an SR/CM change at the input to its POPP.
- * Supported values for bits 0 to 1:
- * - Reserved; clients must set them to zero.
- * Supported values for bit 2:
- * - 0 -- SR/CM change notification event is disabled.
- * - 1 -- SR/CM change notification event is enabled.
- * - Use #ASM_BIT_MASK_SR_CM_CHANGE_NOTIFY_FLAG and
- * #ASM_SHIFT_SR_CM_CHANGE_NOTIFY_FLAG to set or get this bit.
- *
- * Supported values for bit 31:
- * - 0 -- Stream to be opened in on-Gapless mode.
- * - 1 -- Stream to be opened in Gapless mode. In Gapless mode,
- * successive streams must be opened with same session ID but
- * different stream IDs.
- *
- * - Use #ASM_BIT_MASK_GAPLESS_MODE_FLAG and
- * #ASM_SHIFT_GAPLESS_MODE_FLAG to set or get this bit.
- *
- *
- * @note1hang MIDI and DTMF streams cannot be opened in Gapless mode.
- */
-
-	uint16_t                    sink_endpointype;
-/*< Sink point type.
- * Supported values:
- * - 0 -- Device matrix
- * - Other values are reserved.
- *
- * The device matrix is the gateway to the hardware ports.
- */
-
-	uint16_t                    bits_per_sample;
-/*< Number of bits per sample processed by ASM modules.
- * Supported values: 16 and 24 bits per sample
- */
-
-	uint32_t                    postprocopo_id;
-/*< Specifies the topology (order of processing) of
- * postprocessing algorithms. <i>None</i> means no postprocessing.
- * Supported values:
- * - #ASM_STREAM_POSTPROCOPO_ID_DEFAULT
- * - #ASM_STREAM_POSTPROCOPO_ID_MCH_PEAK_VOL
- * - #ASM_STREAM_POSTPROCOPO_ID_NONE
- *
- * This field can also be enabled through SetParams flags.
- */
-
-	uint32_t                    dec_fmt_id;
-/*< Configuration ID of the decoder media format.
- *
- * Supported values:
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_ADPCM
- * - #ASM_MEDIA_FMT_MP3
- * - #ASM_MEDIA_FMT_AAC_V2
- * - #ASM_MEDIA_FMT_DOLBY_AAC
- * - #ASM_MEDIA_FMT_AMRNB_FS
- * - #ASM_MEDIA_FMT_AMRWB_FS
- * - #ASM_MEDIA_FMT_AMR_WB_PLUS_V2
- * - #ASM_MEDIA_FMT_V13K_FS
- * - #ASM_MEDIA_FMT_EVRC_FS
- * - #ASM_MEDIA_FMT_EVRCB_FS
- * - #ASM_MEDIA_FMT_EVRCWB_FS
- * - #ASM_MEDIA_FMT_SBC
- * - #ASM_MEDIA_FMT_WMA_V10PRO_V2
- * - #ASM_MEDIA_FMT_WMA_V9_V2
- * - #ASM_MEDIA_FMT_AC3
- * - #ASM_MEDIA_FMT_EAC3
- * - #ASM_MEDIA_FMT_G711_ALAW_FS
- * - #ASM_MEDIA_FMT_G711_MLAW_FS
- * - #ASM_MEDIA_FMT_G729A_FS
- * - #ASM_MEDIA_FMT_FR_FS
- * - #ASM_MEDIA_FMT_VORBIS
- * - #ASM_MEDIA_FMT_FLAC
- * - #ASM_MEDIA_FMT_ALAC
- * - #ASM_MEDIA_FMT_APE
- * - #ASM_MEDIA_FMT_EXAMPLE
- */
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_PULL_MODE_WRITE    0x00010DD9
-
-/* Bitmask for the stream_perf_mode subfield. */
-#define ASM_BIT_MASK_STREAM_PERF_FLAG_PULL_MODE_WRITE 0xE0000000UL
-
-/* Bitmask for the stream_perf_mode subfield. */
-#define ASM_SHIFT_STREAM_PERF_FLAG_PULL_MODE_WRITE 29
-
-#define ASM_STREAM_CMD_OPEN_PUSH_MODE_READ  0x00010DDA
-
-#define ASM_BIT_MASK_STREAM_PERF_FLAG_PUSH_MODE_READ 0xE0000000UL
-
-#define ASM_SHIFT_STREAM_PERF_FLAG_PUSH_MODE_READ 29
-
-#define ASM_DATA_EVENT_WATERMARK 0x00010DDB
-
-struct asm_shared_position_buffer {
-	volatile uint32_t               frame_counter;
-/* Counter used to handle interprocessor synchronization issues.
- * When frame_counter is 0: read_index, wall_clock_us_lsw, and
- * wall_clock_us_msw are invalid.
- * Supported values: >= 0.
- */
-
-	volatile uint32_t               index;
-/* Index in bytes from where the aDSP is reading/writing.
- * Supported values: 0 to circular buffer size - 1
- */
-
-	volatile uint32_t               wall_clock_us_lsw;
-/* Lower 32 bits of the 64-bit wall clock time in microseconds when the
- * read index was updated.
- * Supported values: >= 0
- */
-
-	volatile uint32_t               wall_clock_us_msw;
-/* Upper 32 bits of the 64 bit wall clock time in microseconds when the
- * read index was updated
- * Supported values: >= 0
- */
-} __packed;
-
-struct asm_shared_watermark_level {
-	uint32_t                watermark_level_bytes;
-} __packed;
-
-struct asm_stream_cmd_open_shared_io {
-	struct apr_hdr          hdr;
-	uint32_t                mode_flags;
-	uint16_t                endpoint_type;
-	uint16_t                topo_bits_per_sample;
-	uint32_t                topo_id;
-	uint32_t                fmt_id;
-	uint32_t                shared_pos_buf_phy_addr_lsw;
-	uint32_t                shared_pos_buf_phy_addr_msw;
-	uint16_t                shared_pos_buf_mem_pool_id;
-	uint16_t                shared_pos_buf_num_regions;
-	uint32_t                shared_pos_buf_property_flag;
-	uint32_t                shared_circ_buf_start_phy_addr_lsw;
-	uint32_t                shared_circ_buf_start_phy_addr_msw;
-	uint32_t                shared_circ_buf_size;
-	uint16_t                shared_circ_buf_mem_pool_id;
-	uint16_t                shared_circ_buf_num_regions;
-	uint32_t                shared_circ_buf_property_flag;
-	uint32_t                num_watermark_levels;
-	struct asm_multi_channel_pcm_fmt_blk_v3         fmt;
-	struct avs_shared_map_region_payload            map_region_pos_buf;
-	struct avs_shared_map_region_payload            map_region_circ_buf;
-	struct asm_shared_watermark_level watermark[0];
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_READ_V3                 0x00010DB4
-
-/* Definition of the timestamp type flag bitmask */
-#define ASM_BIT_MASKIMESTAMPYPE_FLAG        (0x00000020UL)
-
-/* Definition of the timestamp type flag shift value. */
-#define ASM_SHIFTIMESTAMPYPE_FLAG 5
-
-/* Relative timestamp is identified by this value.*/
-#define ASM_RELATIVEIMESTAMP      0
-
-/* Absolute timestamp is identified by this value.*/
-#define ASM_ABSOLUTEIMESTAMP      1
-
-/* Bit value for Low Latency Tx stream subfield */
-#define ASM_LOW_LATENCY_TX_STREAM_SESSION			1
-
-/* Bit shift for the stream_perf_mode subfield. */
-#define ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ              29
-
-struct asm_stream_cmd_open_read_v3 {
-	struct apr_hdr hdr;
-	u32                    mode_flags;
-/* Mode flags that indicate whether meta information per encoded
- * frame is to be provided.
- * Supported values for bit 4:
- *
- * - 0 -- Return data buffer contains all encoded frames only; it
- * does not contain frame metadata.
- *
- * - 1 -- Return data buffer contains an array of metadata and
- * encoded frames.
- *
- * - Use #ASM_BIT_MASK_META_INFO_FLAG as the bitmask and
- * #ASM_SHIFT_META_INFO_FLAG as the shift value for this bit.
- *
- *
- * Supported values for bit 5:
- *
- * - ASM_RELATIVEIMESTAMP -- ASM_DATA_EVENT_READ_DONE_V2 will have
- * - relative time-stamp.
- * - ASM_ABSOLUTEIMESTAMP -- ASM_DATA_EVENT_READ_DONE_V2 will
- * - have absolute time-stamp.
- *
- * - Use #ASM_BIT_MASKIMESTAMPYPE_FLAG as the bitmask and
- * #ASM_SHIFTIMESTAMPYPE_FLAG as the shift value for this bit.
- *
- * All other bits are reserved; clients must set them to zero.
- */
-
-	u32                    src_endpointype;
-/* Specifies the endpoint providing the input samples.
- * Supported values:
- * - 0 -- Device matrix
- * - All other values are reserved; clients must set them to zero.
- * Otherwise, an error is returned.
- * The device matrix is the gateway from the tunneled Tx ports.
- */
-
-	u32                    preprocopo_id;
-/* Specifies the topology (order of processing) of preprocessing
- * algorithms. <i>None</i> means no preprocessing.
- * Supported values:
- * - #ASM_STREAM_PREPROCOPO_ID_DEFAULT
- * - #ASM_STREAM_PREPROCOPO_ID_NONE
- *
- * This field can also be enabled through SetParams flags.
- */
-
-	u32                    enc_cfg_id;
-/* Media configuration ID for encoded output.
- * Supported values:
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_AAC_V2
- * - #ASM_MEDIA_FMT_AMRNB_FS
- * - #ASM_MEDIA_FMT_AMRWB_FS
- * - #ASM_MEDIA_FMT_V13K_FS
- * - #ASM_MEDIA_FMT_EVRC_FS
- * - #ASM_MEDIA_FMT_EVRCB_FS
- * - #ASM_MEDIA_FMT_EVRCWB_FS
- * - #ASM_MEDIA_FMT_SBC
- * - #ASM_MEDIA_FMT_G711_ALAW_FS
- * - #ASM_MEDIA_FMT_G711_MLAW_FS
- * - #ASM_MEDIA_FMT_G729A_FS
- * - #ASM_MEDIA_FMT_EXAMPLE
- * - #ASM_MEDIA_FMT_WMA_V8
- */
-
-	u16                    bits_per_sample;
-/* Number of bits per sample processed by ASM modules.
- * Supported values: 16 and 24 bits per sample
- */
-
-	u16                    reserved;
-/* Reserved for future use. This field must be set to zero.*/
-} __packed;
-
-#define ASM_POPP_OUTPUT_SR_NATIVE_RATE                                  0
-
-/* Enumeration for the maximum sampling rate at the POPP output.*/
-#define ASM_POPP_OUTPUT_SR_MAX_RATE             48000
-
-#define ASM_STREAM_CMD_OPEN_READWRITE_V2        0x00010D8D
-#define ASM_STREAM_CMD_OPEN_READWRITE_V2        0x00010D8D
-
-struct asm_stream_cmd_open_readwrite_v2 {
-	struct apr_hdr         hdr;
-	u32                    mode_flags;
-/* Mode flags.
- * Supported values for bit 2:
- * - 0 -- SR/CM change notification event is disabled.
- * - 1 -- SR/CM change notification event is enabled. Use
- * #ASM_BIT_MASK_SR_CM_CHANGE_NOTIFY_FLAG and
- * #ASM_SHIFT_SR_CM_CHANGE_NOTIFY_FLAG to set or
- * getting this flag.
- *
- * Supported values for bit 4:
- * - 0 -- Return read data buffer contains all encoded frames only; it
- * does not contain frame metadata.
- * - 1 -- Return read data buffer contains an array of metadata and
- * encoded frames.
- *
- * All other bits are reserved; clients must set them to zero.
- */
-
-	u32                    postprocopo_id;
-/* Specifies the topology (order of processing) of postprocessing
- * algorithms. <i>None</i> means no postprocessing.
- *
- * Supported values:
- * - #ASM_STREAM_POSTPROCOPO_ID_DEFAULT
- * - #ASM_STREAM_POSTPROCOPO_ID_MCH_PEAK_VOL
- * - #ASM_STREAM_POSTPROCOPO_ID_NONE
- */
-
-	u32                    dec_fmt_id;
-/* Specifies the media type of the input data. PCM indicates that
- * no decoding must be performed, e.g., this is an NT encoder
- * session.
- * Supported values:
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_ADPCM
- * - #ASM_MEDIA_FMT_MP3
- * - #ASM_MEDIA_FMT_AAC_V2
- * - #ASM_MEDIA_FMT_DOLBY_AAC
- * - #ASM_MEDIA_FMT_AMRNB_FS
- * - #ASM_MEDIA_FMT_AMRWB_FS
- * - #ASM_MEDIA_FMT_V13K_FS
- * - #ASM_MEDIA_FMT_EVRC_FS
- * - #ASM_MEDIA_FMT_EVRCB_FS
- * - #ASM_MEDIA_FMT_EVRCWB_FS
- * - #ASM_MEDIA_FMT_SBC
- * - #ASM_MEDIA_FMT_WMA_V10PRO_V2
- * - #ASM_MEDIA_FMT_WMA_V9_V2
- * - #ASM_MEDIA_FMT_AMR_WB_PLUS_V2
- * - #ASM_MEDIA_FMT_AC3
- * - #ASM_MEDIA_FMT_G711_ALAW_FS
- * - #ASM_MEDIA_FMT_G711_MLAW_FS
- * - #ASM_MEDIA_FMT_G729A_FS
- * - #ASM_MEDIA_FMT_EXAMPLE
- */
-
-	u32                    enc_cfg_id;
-/* Specifies the media type for the output of the stream. PCM
- * indicates that no encoding must be performed, e.g., this is an NT
- * decoder session.
- * Supported values:
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_AAC_V2
- * - #ASM_MEDIA_FMT_AMRNB_FS
- * - #ASM_MEDIA_FMT_AMRWB_FS
- * - #ASM_MEDIA_FMT_V13K_FS
- * - #ASM_MEDIA_FMT_EVRC_FS
- * - #ASM_MEDIA_FMT_EVRCB_FS
- * - #ASM_MEDIA_FMT_EVRCWB_FS
- * - #ASM_MEDIA_FMT_SBC
- * - #ASM_MEDIA_FMT_G711_ALAW_FS
- * - #ASM_MEDIA_FMT_G711_MLAW_FS
- * - #ASM_MEDIA_FMT_G729A_FS
- * - #ASM_MEDIA_FMT_EXAMPLE
- * - #ASM_MEDIA_FMT_WMA_V8
- */
-
-	u16                    bits_per_sample;
-/* Number of bits per sample processed by ASM modules.
- * Supported values: 16 and 24 bits per sample
- */
-
-	u16                    reserved;
-/* Reserved for future use. This field must be set to zero.*/
-
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_LOOPBACK_V2 0x00010D8E
-struct asm_stream_cmd_open_loopback_v2 {
-	struct apr_hdr         hdr;
-	u32                    mode_flags;
-/* Mode flags.
- * Bit 0-31: reserved; client should set these bits to 0
- */
-	u16                    src_endpointype;
-	/* Endpoint type. 0 = Tx Matrix */
-	u16                    sink_endpointype;
-	/* Endpoint type. 0 = Rx Matrix */
-	u32                    postprocopo_id;
-/* Postprocessor topology ID. Specifies the topology of
- * postprocessing algorithms.
- */
-
-	u16                    bits_per_sample;
-/* The number of bits per sample processed by ASM modules
- * Supported values: 16 and 24 bits per sample
- */
-	u16                    reserved;
-/* Reserved for future use. This field must be set to zero. */
-} __packed;
-
-
-#define ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK    0x00010DBA
-
-/* Bitmask for the stream's Performance mode. */
-#define ASM_BIT_MASK_STREAM_PERF_MODE_FLAG_IN_OPEN_TRANSCODE_LOOPBACK \
-	(0x70000000UL)
-
-/* Bit shift for the stream's Performance mode. */
-#define ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_TRANSCODE_LOOPBACK    28
-
-/* Bitmask for the decoder converter enable flag. */
-#define ASM_BIT_MASK_DECODER_CONVERTER_FLAG    (0x00000078UL)
-
-/* Shift value for the decoder converter enable flag. */
-#define ASM_SHIFT_DECODER_CONVERTER_FLAG                              3
-
-/* Converter mode is None (Default). */
-#define ASM_CONVERTER_MODE_NONE                                       0
-
-/* Converter mode is DDP-to-DD. */
-#define ASM_DDP_DD_CONVERTER_MODE                                     1
-
-/*  Identifies a special converter mode where source and sink formats
- *  are the same but postprocessing must applied. Therefore, Decode
- *  @rarrow Re-encode is necessary.
- */
-#define ASM_POST_PROCESS_CONVERTER_MODE                               2
-
-
-struct asm_stream_cmd_open_transcode_loopback_t {
-	struct apr_hdr         hdr;
-	u32                    mode_flags;
-/* Mode Flags specifies the performance mode in which this stream
- * is to be opened.
- * Supported values{for bits 30 to 28}(stream_perf_mode flag)
- *
- * #ASM_LEGACY_STREAM_SESSION -- This mode ensures backward
- *       compatibility to the original behavior
- *       of ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK
- *
- * #ASM_LOW_LATENCY_STREAM_SESSION -- Opens a loopback session by using
- *  shortened buffers in low latency POPP
- *  - Recommendation: Do not enable high latency algorithms. They might
- *    negate the benefits of opening a low latency stream, and they
- *    might also suffer quality degradation from unexpected jitter.
- *  - This Low Latency mode is supported only for PCM In and PCM Out
- *    loopbacks. An error is returned if Low Latency mode is opened for
- *    other transcode loopback modes.
- *  - To configure this subfield, use
- *     ASM_BIT_MASK_STREAM_PERF_MODE_FLAG_IN_OPEN_TRANSCODE_LOOPBACK and
- *     ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_TRANSCODE_LOOPBACK.
- *
- * Supported values{for bits 6 to 3} (decoder-converter compatibility)
- * #ASM_CONVERTER_MODE_NONE (0x0) -- Default
- * #ASM_DDP_DD_CONVERTER_MODE (0x1)
- * #ASM_POST_PROCESS_CONVERTER_MODE (0x2)
- * 0x3-0xF -- Reserved for future use
- * - Use #ASM_BIT_MASK_DECODER_CONVERTER_FLAG and
- *        ASM_SHIFT_DECODER_CONVERTER_FLAG to set this bit
- * All other bits are reserved; clients must set them to 0.
- */
-
-	u32                    src_format_id;
-/* Specifies the media format of the input audio stream.
- *
- * Supported values
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3
- * - #ASM_MEDIA_FMT_DTS
- * - #ASM_MEDIA_FMT_EAC3_DEC
- * - #ASM_MEDIA_FMT_EAC3
- * - #ASM_MEDIA_FMT_AC3_DEC
- * - #ASM_MEDIA_FMT_AC3
- */
-	u32                    sink_format_id;
-/* Specifies the media format of the output stream.
- *
- * Supported values
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2
- * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3
- * - #ASM_MEDIA_FMT_DTS (not supported in Low Latency mode)
- * - #ASM_MEDIA_FMT_EAC3_DEC (not supported in Low Latency mode)
- * - #ASM_MEDIA_FMT_EAC3 (not supported in Low Latency mode)
- * - #ASM_MEDIA_FMT_AC3_DEC (not supported in Low Latency mode)
- * - #ASM_MEDIA_FMT_AC3 (not supported in Low Latency mode)
- */
-
-	u32                    audproc_topo_id;
-/* Postprocessing topology ID, which specifies the topology (order of
- *        processing) of postprocessing algorithms.
- *
- * Supported values
- *    - #ASM_STREAM_POSTPROC_TOPO_ID_DEFAULT
- *    - #ASM_STREAM_POSTPROC_TOPO_ID_PEAKMETER
- *    - #ASM_STREAM_POSTPROC_TOPO_ID_MCH_PEAK_VOL
- *    - #ASM_STREAM_POSTPROC_TOPO_ID_NONE
- *  Topologies can be added through #ASM_CMD_ADD_TOPOLOGIES.
- *  This field is ignored for the Converter mode, in which no
- *  postprocessing is performed.
- */
-
-	u16                    src_endpoint_type;
-/* Specifies the source endpoint that provides the input samples.
- *
- * Supported values
- *  - 0 -- Tx device matrix or stream router (gateway to the hardware
- *    ports)
- *  - All other values are reserved
- *  Clients must set this field to 0. Otherwise, an error is returned.
- */
-
-	u16                    sink_endpoint_type;
-/*  Specifies the sink endpoint type.
- *
- *  Supported values
- *  - 0 -- Rx device matrix or stream router (gateway to the hardware
- *    ports)
- *  - All other values are reserved
- *   Clients must set this field to 0. Otherwise, an error is returned.
- */
-
-	u16                    bits_per_sample;
-/*   Number of bits per sample processed by the ASM modules.
- *   Supported values 16, 24
- */
-
-	u16                    reserved;
-/*   This field must be set to 0.
- */
-} __packed;
-
-
-#define ASM_STREAM_CMD_CLOSE             0x00010BCD
-#define ASM_STREAM_CMD_FLUSH             0x00010BCE
-
-
-#define ASM_STREAM_CMD_FLUSH_READBUFS   0x00010C09
-#define ASM_STREAM_CMD_SET_PP_PARAMS_V2 0x00010DA1
-
-struct asm_stream_cmd_set_pp_params_v2 {
-	u32                  data_payload_addr_lsw;
-/* LSW of parameter data payload address. Supported values: any. */
-	u32                  data_payload_addr_msw;
-/* MSW of Parameter data payload address. Supported values: any.
- * - Must be set to zero for in-band data.
- * - In the case of 32 bit Shared memory address, msw  field must be
- * - set to zero.
- * - In the case of 36 bit shared memory address, bit 31 to bit 4 of
- * msw
- *
- * - must be set to zero.
- */
-	u32                  mem_map_handle;
-/* Supported Values: Any.
- * memory map handle returned by DSP through
- * ASM_CMD_SHARED_MEM_MAP_REGIONS
- * command.
- * if mmhandle is NULL, the ParamData payloads are within the
- * message payload (in-band).
- * If mmhandle is non-NULL, the ParamData payloads begin at the
- * address specified in the address msw and lsw (out-of-band).
- */
-
-	u32                  data_payload_size;
-/* Size in bytes of the variable payload accompanying the
- * message, or in shared memory. This field is used for parsing the
- * parameter payload.
- */
-} __packed;
-
-
-struct asm_stream_param_data_v2 {
-	u32                  module_id;
-	/* Unique module ID. */
-
-	u32                  param_id;
-	/* Unique parameter ID. */
-
-	u16                  param_size;
-/* Data size of the param_id/module_id combination. This is
- * a multiple of 4 bytes.
- */
-
-	u16                  reserved;
-/* Reserved for future enhancements. This field must be set to
- * zero.
- */
-
-} __packed;
-
-#define ASM_STREAM_CMD_GET_PP_PARAMS_V2		0x00010DA2
-
-struct asm_stream_cmd_get_pp_params_v2 {
-	u32                  data_payload_addr_lsw;
-	/* LSW of the parameter data payload address. */
-	u32                  data_payload_addr_msw;
-/* MSW of the parameter data payload address.
- * - Size of the shared memory, if specified, shall be large enough
- * to contain the whole ParamData payload, including Module ID,
- * Param ID, Param Size, and Param Values
- * - Must be set to zero for in-band data
- * - In the case of 32 bit Shared memory address, msw field must be
- * set to zero.
- * - In the case of 36 bit shared memory address, bit 31 to bit 4 of
- * msw must be set to zero.
- */
-
-	u32                  mem_map_handle;
-/* Supported Values: Any.
- * memory map handle returned by DSP through ASM_CMD_SHARED_MEM_MAP_REGIONS
- * command.
- * if mmhandle is NULL, the ParamData payloads in the ACK are within the
- * message payload (in-band).
- * If mmhandle is non-NULL, the ParamData payloads in the ACK begin at the
- * address specified in the address msw and lsw.
- * (out-of-band).
- */
-
-	u32                  module_id;
-/* Unique module ID. */
-
-	u32                  param_id;
-/* Unique parameter ID. */
-
-	u16                  param_max_size;
-/* Maximum data size of the module_id/param_id combination. This
- * is a multiple of 4 bytes.
- */
-
-
-	u16                  reserved;
-/* Reserved for backward compatibility. Clients must set this
- * field to zero.
- */
-} __packed;
-
-#define ASM_STREAM_CMD_SET_ENCDEC_PARAM 0x00010C10
-
-#define ASM_STREAM_CMD_SET_ENCDEC_PARAM_V2     0x00013218
-
-struct asm_stream_cmd_set_encdec_param_v2 {
-	u16                  service_id;
-	/* 0 - ASM_ENCODER_SVC; 1 - ASM_DECODER_SVC */
-
-	u16                  reserved;
-
-	u32                  param_id;
-	/* ID of the parameter. */
-
-	u32                  param_size;
-	/*
-	 * Data size of this parameter, in bytes. The size is a multiple
-	 * of 4 bytes.
-	 */
-} __packed;
-
-#define ASM_STREAM_CMD_REGISTER_ENCDEC_EVENTS  0x00013219
-
-#define ASM_STREAM_CMD_ENCDEC_EVENTS           0x0001321A
-
-#define AVS_PARAM_ID_RTIC_SHARED_MEMORY_ADDR   0x00013237
-
-struct avs_rtic_shared_mem_addr {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param_v2  encdec;
-	u32                 shm_buf_addr_lsw;
-	/* Lower 32 bit of the RTIC shared memory */
-
-	u32                 shm_buf_addr_msw;
-	/* Upper 32 bit of the RTIC shared memory */
-
-	u32                 buf_size;
-	/* Size of buffer */
-
-	u16                 shm_buf_mem_pool_id;
-	/* ADSP_MEMORY_MAP_SHMEM8_4K_POOL */
-
-	u16                 shm_buf_num_regions;
-	/* number of regions to map */
-
-	u32                 shm_buf_flag;
-	/* buffer property flag */
-
-	struct avs_shared_map_region_payload map_region;
-	/* memory map region*/
-} __packed;
-
-#define AVS_PARAM_ID_RTIC_EVENT_ACK           0x00013238
-
-struct avs_param_rtic_event_ack {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param_v2  encdec;
-} __packed;
-
-#define ASM_PARAM_ID_ENCDEC_BITRATE     0x00010C13
-
-struct asm_bitrate_param {
-	u32                  bitrate;
-/* Maximum supported bitrate. Only the AAC encoder is supported.*/
-
-} __packed;
-
-#define ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2 0x00010DA3
-#define ASM_PARAM_ID_AAC_SBR_PS_FLAG		 0x00010C63
-
-/* Flag to turn off both SBR and PS processing, if they are
- * present in the bitstream.
- */
-
-#define ASM_AAC_SBR_OFF_PS_OFF (2)
-
-/* Flag to turn on SBR but turn off PS processing,if they are
- * present in the bitstream.
- */
-
-#define ASM_AAC_SBR_ON_PS_OFF  (1)
-
-/* Flag to turn on both SBR and PS processing, if they are
- * present in the bitstream (default behavior).
- */
-
-
-#define ASM_AAC_SBR_ON_PS_ON   (0)
-
-/* Structure for an AAC SBR PS processing flag. */
-
-/*  Payload of the #ASM_PARAM_ID_AAC_SBR_PS_FLAG parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-struct asm_aac_sbr_ps_flag_param {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-
-	u32                  sbr_ps_flag;
-/* Control parameter to enable or disable SBR/PS processing in
- * the AAC bitstream. Use the following macros to set this field:
- * - #ASM_AAC_SBR_OFF_PS_OFF -- Turn off both SBR and PS
- * processing, if they are present in the bitstream.
- * - #ASM_AAC_SBR_ON_PS_OFF -- Turn on SBR processing, but not PS
- * processing, if they are present in the bitstream.
- * - #ASM_AAC_SBR_ON_PS_ON -- Turn on both SBR and PS processing,
- * if they are present in the bitstream (default behavior).
- * - All other values are invalid.
- * Changes are applied to the next decoded frame.
- */
-} __packed;
-
-#define ASM_PARAM_ID_AAC_DUAL_MONO_MAPPING                      0x00010C64
-
-/*	First single channel element in a dual mono bitstream.*/
-#define ASM_AAC_DUAL_MONO_MAP_SCE_1                                 (1)
-
-/*	Second single channel element in a dual mono bitstream.*/
-#define ASM_AAC_DUAL_MONO_MAP_SCE_2                                 (2)
-
-/* Structure for AAC decoder dual mono channel mapping. */
-
-
-struct asm_aac_dual_mono_mapping_param {
-	struct apr_hdr							hdr;
-	struct asm_stream_cmd_set_encdec_param	encdec;
-	u16    left_channel_sce;
-	u16    right_channel_sce;
-
-} __packed;
-
-#define ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 0x00010DA4
-
-struct asm_stream_cmdrsp_get_pp_params_v2 {
-	u32                  status;
-} __packed;
-
-#define ASM_PARAM_ID_AC3_KARAOKE_MODE 0x00010D73
-
-/* Enumeration for both vocals in a karaoke stream.*/
-#define AC3_KARAOKE_MODE_NO_VOCAL     (0)
-
-/* Enumeration for only the left vocal in a karaoke stream.*/
-#define AC3_KARAOKE_MODE_LEFT_VOCAL   (1)
-
-/* Enumeration for only the right vocal in a karaoke stream.*/
-#define AC3_KARAOKE_MODE_RIGHT_VOCAL (2)
-
-/* Enumeration for both vocal channels in a karaoke stream.*/
-#define AC3_KARAOKE_MODE_BOTH_VOCAL             (3)
-#define ASM_PARAM_ID_AC3_DRC_MODE               0x00010D74
-/* Enumeration for the Custom Analog mode.*/
-#define AC3_DRC_MODE_CUSTOM_ANALOG              (0)
-
-/* Enumeration for the Custom Digital mode.*/
-#define AC3_DRC_MODE_CUSTOM_DIGITAL             (1)
-/* Enumeration for the Line Out mode (light compression).*/
-#define AC3_DRC_MODE_LINE_OUT  (2)
-
-/* Enumeration for the RF remodulation mode (heavy compression).*/
-#define AC3_DRC_MODE_RF_REMOD                         (3)
-#define ASM_PARAM_ID_AC3_DUAL_MONO_MODE               0x00010D75
-
-/* Enumeration for playing dual mono in stereo mode.*/
-#define AC3_DUAL_MONO_MODE_STEREO                     (0)
-
-/* Enumeration for playing left mono.*/
-#define AC3_DUAL_MONO_MODE_LEFT_MONO                  (1)
-
-/* Enumeration for playing right mono.*/
-#define AC3_DUAL_MONO_MODE_RIGHT_MONO                 (2)
-
-/* Enumeration for mixing both dual mono channels and playing them.*/
-#define AC3_DUAL_MONO_MODE_MIXED_MONO        (3)
-#define ASM_PARAM_ID_AC3_STEREO_DOWNMIX_MODE 0x00010D76
-
-/* Enumeration for using the Downmix mode indicated in the bitstream. */
-
-#define AC3_STEREO_DOWNMIX_MODE_AUTO_DETECT  (0)
-
-/* Enumeration for Surround Compatible mode (preserves the
- * surround information).
- */
-
-#define AC3_STEREO_DOWNMIX_MODE_LT_RT        (1)
-/* Enumeration for Mono Compatible mode (if the output is to be
- * further downmixed to mono).
- */
-
-#define AC3_STEREO_DOWNMIX_MODE_LO_RO (2)
-
-/* ID of the AC3 PCM scale factor parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-#define ASM_PARAM_ID_AC3_PCM_SCALEFACTOR 0x00010D78
-
-/* ID of the AC3 DRC boost scale factor parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-#define ASM_PARAM_ID_AC3_DRC_BOOST_SCALEFACTOR 0x00010D79
-
-/* ID of the AC3 DRC cut scale factor parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-#define ASM_PARAM_ID_AC3_DRC_CUT_SCALEFACTOR 0x00010D7A
-
-/* Structure for AC3 Generic Parameter. */
-
-/*  Payload of the AC3 parameters in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-struct asm_ac3_generic_param {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	struct asm_enc_cfg_blk_param_v2	encblk;
-	u32                  generic_parameter;
-/* AC3 generic parameter. Select from one of the following
- * possible values.
- *
- * For #ASM_PARAM_ID_AC3_KARAOKE_MODE, supported values are:
- * - AC3_KARAOKE_MODE_NO_VOCAL
- * - AC3_KARAOKE_MODE_LEFT_VOCAL
- * - AC3_KARAOKE_MODE_RIGHT_VOCAL
- * - AC3_KARAOKE_MODE_BOTH_VOCAL
- *
- * For #ASM_PARAM_ID_AC3_DRC_MODE, supported values are:
- * - AC3_DRC_MODE_CUSTOM_ANALOG
- * - AC3_DRC_MODE_CUSTOM_DIGITAL
- * - AC3_DRC_MODE_LINE_OUT
- * - AC3_DRC_MODE_RF_REMOD
- *
- * For #ASM_PARAM_ID_AC3_DUAL_MONO_MODE, supported values are:
- * - AC3_DUAL_MONO_MODE_STEREO
- * - AC3_DUAL_MONO_MODE_LEFT_MONO
- * - AC3_DUAL_MONO_MODE_RIGHT_MONO
- * - AC3_DUAL_MONO_MODE_MIXED_MONO
- *
- * For #ASM_PARAM_ID_AC3_STEREO_DOWNMIX_MODE, supported values are:
- * - AC3_STEREO_DOWNMIX_MODE_AUTO_DETECT
- * - AC3_STEREO_DOWNMIX_MODE_LT_RT
- * - AC3_STEREO_DOWNMIX_MODE_LO_RO
- *
- * For #ASM_PARAM_ID_AC3_PCM_SCALEFACTOR, supported values are
- * 0 to 1 in Q31 format.
- *
- * For #ASM_PARAM_ID_AC3_DRC_BOOST_SCALEFACTOR, supported values are
- * 0 to 1 in Q31 format.
- *
- * For #ASM_PARAM_ID_AC3_DRC_CUT_SCALEFACTOR, supported values are
- * 0 to 1 in Q31 format.
- */
-} __packed;
-
-/* Enumeration for Raw mode (no downmixing), which specifies
- * that all channels in the bitstream are to be played out as is
- * without any downmixing. (Default)
- */
-
-#define WMAPRO_CHANNEL_MASK_RAW (-1)
-
-/* Enumeration for setting the channel mask to 0. The 7.1 mode
- * (Home Theater) is assigned.
- */
-
-
-#define WMAPRO_CHANNEL_MASK_ZERO 0x0000
-
-/* Speaker layout mask for one channel (Home Theater, mono).
- * - Speaker front center
- */
-#define WMAPRO_CHANNEL_MASK_1_C 0x0004
-
-/* Speaker layout mask for two channels (Home Theater, stereo).
- * - Speaker front left
- * - Speaker front right
- */
-#define WMAPRO_CHANNEL_MASK_2_L_R 0x0003
-
-/* Speaker layout mask for three channels (Home Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- */
-#define WMAPRO_CHANNEL_MASK_3_L_C_R 0x0007
-
-/* Speaker layout mask for two channels (stereo).
- * - Speaker back left
- * - Speaker back right
- */
-#define WMAPRO_CHANNEL_MASK_2_Bl_Br  0x0030
-
-/* Speaker layout mask for four channels.
- * - Speaker front left
- * - Speaker front right
- * - Speaker back left
- * - Speaker back right
- */
-#define WMAPRO_CHANNEL_MASK_4_L_R_Bl_Br 0x0033
-
-/* Speaker layout mask for four channels (Home Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back center
- */
-#define WMAPRO_CHANNEL_MASK_4_L_R_C_Bc_HT 0x0107
-/* Speaker layout mask for five channels.
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back left
- * - Speaker back right
- */
-#define WMAPRO_CHANNEL_MASK_5_L_C_R_Bl_Br  0x0037
-
-/* Speaker layout mask for five channels (5 mode, Home Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker side left
- * - Speaker side right
- */
-#define WMAPRO_CHANNEL_MASK_5_L_C_R_Sl_Sr_HT   0x0607
-/* Speaker layout mask for six channels (5.1 mode).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker low frequency
- * - Speaker back left
- * - Speaker back right
- */
-#define WMAPRO_CHANNEL_MASK_5DOT1_L_C_R_Bl_Br_SLF  0x003F
-/* Speaker layout mask for six channels (5.1 mode, Home Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker low frequency
- * - Speaker side left
- * - Speaker side right
- */
-#define WMAPRO_CHANNEL_MASK_5DOT1_L_C_R_Sl_Sr_SLF_HT  0x060F
-/* Speaker layout mask for six channels (5.1 mode, no LFE).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back left
- * - Speaker back right
- * - Speaker back center
- */
-#define WMAPRO_CHANNEL_MASK_5DOT1_L_C_R_Bl_Br_Bc  0x0137
-/* Speaker layout mask for six channels (5.1 mode, Home Theater,
- * no LFE).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back center
- * - Speaker side left
- * - Speaker side right
- */
-#define WMAPRO_CHANNEL_MASK_5DOT1_L_C_R_Sl_Sr_Bc_HT   0x0707
-
-/* Speaker layout mask for seven channels (6.1 mode).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker low frequency
- * - Speaker back left
- * - Speaker back right
- * - Speaker back center
- */
-#define WMAPRO_CHANNEL_MASK_6DOT1_L_C_R_Bl_Br_Bc_SLF   0x013F
-
-/* Speaker layout mask for seven channels (6.1 mode, Home
- * Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker low frequency
- * - Speaker back center
- * - Speaker side left
- * - Speaker side right
- */
-#define WMAPRO_CHANNEL_MASK_6DOT1_L_C_R_Sl_Sr_Bc_SLF_HT 0x070F
-
-/* Speaker layout mask for seven channels (6.1 mode, no LFE).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back left
- * - Speaker back right
- * - Speaker front left of center
- * - Speaker front right of center
- */
-#define WMAPRO_CHANNEL_MASK_6DOT1_L_C_R_Bl_Br_SFLOC_SFROC   0x00F7
-
-/* Speaker layout mask for seven channels (6.1 mode, Home
- * Theater, no LFE).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker side left
- * - Speaker side right
- * - Speaker front left of center
- * - Speaker front right of center
- */
-#define WMAPRO_CHANNEL_MASK_6DOT1_L_C_R_Sl_Sr_SFLOC_SFROC_HT 0x0637
-
-/* Speaker layout mask for eight channels (7.1 mode).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker back left
- * - Speaker back right
- * - Speaker low frequency
- * - Speaker front left of center
- * - Speaker front right of center
- */
-#define WMAPRO_CHANNEL_MASK_7DOT1_L_C_R_Bl_Br_SLF_SFLOC_SFROC \
-					0x00FF
-
-/* Speaker layout mask for eight channels (7.1 mode, Home Theater).
- * - Speaker front left
- * - Speaker front right
- * - Speaker front center
- * - Speaker side left
- * - Speaker side right
- * - Speaker low frequency
- * - Speaker front left of center
- * - Speaker front right of center
- *
- */
-#define WMAPRO_CHANNEL_MASK_7DOT1_L_C_R_Sl_Sr_SLF_SFLOC_SFROC_HT \
-					0x063F
-
-#define ASM_PARAM_ID_DEC_OUTPUT_CHAN_MAP  0x00010D82
-
-/* Maximum number of decoder output channels. */
-#define MAX_CHAN_MAP_CHANNELS  16
-
-/* Structure for decoder output channel mapping. */
-
-/* Payload of the #ASM_PARAM_ID_DEC_OUTPUT_CHAN_MAP parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- */
-struct asm_dec_out_chan_map_param {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param  encdec;
-	u32                 num_channels;
-/* Number of decoder output channels.
- * Supported values: 0 to #MAX_CHAN_MAP_CHANNELS
- *
- * A value of 0 indicates native channel mapping, which is valid
- * only for NT mode. This means the output of the decoder is to be
- * preserved as is.
- */
-	u8                  channel_mapping[MAX_CHAN_MAP_CHANNELS];
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED  0x00010D84
-
-/* Bitmask for the IEC 61937 enable flag.*/
-#define ASM_BIT_MASK_IEC_61937_STREAM_FLAG   (0x00000001UL)
-
-/* Shift value for the IEC 61937 enable flag.*/
-#define ASM_SHIFT_IEC_61937_STREAM_FLAG  0
-
-/* Bitmask for the IEC 60958 enable flag.*/
-#define ASM_BIT_MASK_IEC_60958_STREAM_FLAG   (0x00000002UL)
-
-/* Shift value for the IEC 60958 enable flag.*/
-#define ASM_SHIFT_IEC_60958_STREAM_FLAG   1
-
-/* Payload format for open write compressed command */
-
-/* Payload format for the #ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED
- * command, which opens a stream for a given session ID and stream ID
- * to be rendered in the compressed format.
- */
-
-struct asm_stream_cmd_open_write_compressed {
-	struct apr_hdr hdr;
-	u32                    flags;
-/* Mode flags that configure the stream for a specific format.
- * Supported values:
- * - Bit 0 -- IEC 61937 compatibility
- *   - 0 -- Stream is not in IEC 61937 format
- *   - 1 -- Stream is in IEC 61937 format
- * - Bit 1 -- IEC 60958 compatibility
- *   - 0 -- Stream is not in IEC 60958 format
- *   - 1 -- Stream is in IEC 60958 format
- * - Bits 2 to 31 -- 0 (Reserved)
- *
- * For the same stream, bit 0 cannot be set to 0 and bit 1 cannot
- * be set to 1. A compressed stream connot have IEC 60958
- * packetization applied without IEC 61937 packetization.
- * @note1hang Currently, IEC 60958 packetized input streams are not
- * supported.
- */
-
-
-	u32                    fmt_id;
-/* Specifies the media type of the HDMI stream to be opened.
- * Supported values:
- * - #ASM_MEDIA_FMT_AC3
- * - #ASM_MEDIA_FMT_EAC3
- * - #ASM_MEDIA_FMT_DTS
- * - #ASM_MEDIA_FMT_ATRAC
- * - #ASM_MEDIA_FMT_MAT
- *
- * @note1hang This field must be set to a valid media type even if
- * IEC 61937 packetization is not performed by the aDSP.
- */
-
-} __packed;
-
-
-/* Indicates the number of samples per channel to be removed from the
- * beginning of the stream.
- */
-#define ASM_DATA_CMD_REMOVE_INITIAL_SILENCE 0x00010D67
-
-/* Indicates the number of samples per channel to be removed from
- * the end of the stream.
- */
-#define ASM_DATA_CMD_REMOVE_TRAILING_SILENCE 0x00010D68
-
-struct asm_data_cmd_remove_silence {
-	struct apr_hdr hdr;
-	u32	num_samples_to_remove;
-	/* < Number of samples per channel to be removed.
-	 * @values 0 to (2@sscr{32}-1)
-	 */
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_READ_COMPRESSED                        0x00010D95
-
-struct asm_stream_cmd_open_read_compressed {
-	struct apr_hdr hdr;
-	u32                    mode_flags;
-/* Mode flags that indicate whether meta information per encoded
- * frame is to be provided.
- * Supported values for bit 4:
- * - 0 -- Return data buffer contains all encoded frames only; it does
- *      not contain frame metadata.
- * - 1 -- Return data buffer contains an array of metadata and encoded
- *      frames.
- * - Use #ASM_BIT_MASK_META_INFO_FLAG to set the bitmask and
- * #ASM_SHIFT_META_INFO_FLAG to set the shift value for this bit.
- * All other bits are reserved; clients must set them to zero.
- */
-
-	u32                    frames_per_buf;
-/* Indicates the number of frames that need to be returned per
- * read buffer
- * Supported values: should be greater than 0
- */
-
-} __packed;
-
-/* adsp_asm_stream_commands.h*/
-
-
-/* adsp_asm_api.h (no changes)*/
-#define ASM_STREAM_POSTPROCOPO_ID_DEFAULT \
-								0x00010BE4
-#define ASM_STREAM_POSTPROCOPO_ID_PEAKMETER \
-								0x00010D83
-#define ASM_STREAM_POSTPROCOPO_ID_NONE \
-								0x00010C68
-#define ASM_STREAM_POSTPROCOPO_ID_MCH_PEAK_VOL \
-								0x00010D8B
-#define ASM_STREAM_PREPROCOPO_ID_DEFAULT \
-			ASM_STREAM_POSTPROCOPO_ID_DEFAULT
-#define ASM_STREAM_PREPROCOPO_ID_NONE \
-			ASM_STREAM_POSTPROCOPO_ID_NONE
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_NONE_AUDIO_COPP \
-			0x00010312
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_MONO_AUDIO_COPP \
-								0x00010313
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_STEREO_AUDIO_COPP \
-								0x00010314
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_STEREO_IIR_AUDIO_COPP\
-								0x00010704
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_MONO_AUDIO_COPP_MBDRCV2\
-								0x0001070D
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_STEREO_AUDIO_COPP_MBDRCV2\
-								0x0001070E
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_STEREO_IIR_AUDIO_COPP_MBDRCV2\
-								0x0001070F
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_STEREO_AUDIO_COPP_MBDRC_V3 \
-								0x11000000
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_SPEAKER_MCH_PEAK_VOL \
-								0x0001031B
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_MIC_MONO_AUDIO_COPP  0x00010315
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_MIC_STEREO_AUDIO_COPP 0x00010316
-#define AUDPROC_COPPOPOLOGY_ID_MCHAN_IIR_AUDIO           0x00010715
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_DEFAULT_AUDIO_COPP   0x00010BE3
-#define ADM_CMD_COPP_OPENOPOLOGY_ID_PEAKMETER_AUDIO_COPP 0x00010317
-#define AUDPROC_MODULE_ID_AIG   0x00010716
-#define AUDPROC_PARAM_ID_AIG_ENABLE		0x00010717
-#define AUDPROC_PARAM_ID_AIG_CONFIG		0x00010718
-
-struct Audio_AigParam {
-	uint16_t	mode;
-/*< Mode word for enabling AIG/SIG mode .
- * Byte offset: 0
- */
-	int16_t		staticGainL16Q12;
-/*< Static input gain when aigMode is set to 1.
- * Byte offset: 2
- */
-	int16_t		initialGainDBL16Q7;
-/*<Initial value that the adaptive gain update starts from dB
- * Q7 Byte offset: 4
- */
-	int16_t		idealRMSDBL16Q7;
-/*<Average RMS level that AIG attempts to achieve Q8.7
- * Byte offset: 6
- */
-	int32_t		noiseGateL32;
-/*Threshold below which signal is considered as noise and AIG
- * Byte offset: 8
- */
-	int32_t		minGainL32Q15;
-/*Minimum gain that can be provided by AIG Q16.15
- * Byte offset: 12
- */
-	int32_t		maxGainL32Q15;
-/*Maximum gain that can be provided by AIG Q16.15
- * Byte offset: 16
- */
-	uint32_t		gainAtRtUL32Q31;
-/*Attack/release time for AIG update Q1.31
- * Byte offset: 20
- */
-	uint32_t		longGainAtRtUL32Q31;
-/*Long attack/release time while updating gain for
- * noise/silence Q1.31 Byte offset: 24
- */
-
-	uint32_t		rmsTavUL32Q32;
-/* RMS smoothing time constant used for long-term RMS estimate
- * Q0.32 Byte offset: 28
- */
-
-	uint32_t		gainUpdateStartTimMsUL32Q0;
-/* The waiting time before which AIG starts to apply adaptive
- * gain update Q32.0 Byte offset: 32
- */
-
-} __packed;
-
-
-#define ADM_MODULE_ID_EANS                            0x00010C4A
-#define ADM_PARAM_ID_EANS_ENABLE                      0x00010C4B
-#define ADM_PARAM_ID_EANS_PARAMS                      0x00010C4C
-
-struct adm_eans_enable {
-
-	uint32_t                  enable_flag;
-/*< Specifies whether EANS is disabled (0) or enabled
- * (nonzero).
- * This is supported only for sampling rates of 8, 12, 16, 24, 32,
- * and 48 kHz. It is not supported for sampling rates of 11.025,
- * 22.05, or 44.1 kHz.
- */
-
-} __packed;
-
-
-struct adm_eans_params {
-	int16_t                         eans_mode;
-/*< Mode word for enabling/disabling submodules.
- * Byte offset: 0
- */
-
-	int16_t                         eans_input_gain;
-/*< Q2.13 input gain to the EANS module.
- * Byte offset: 2
- */
-
-	int16_t                         eans_output_gain;
-/*< Q2.13 output gain to the EANS module.
- * Byte offset: 4
- */
-
-	int16_t                         eansarget_ns;
-/*< Target noise suppression level in dB.
- * Byte offset: 6
- */
-
-	int16_t                         eans_s_alpha;
-/*< Q3.12 over-subtraction factor for stationary noise
- * suppression.
- * Byte offset: 8
- */
-
-	int16_t                         eans_n_alpha;
-/* < Q3.12 over-subtraction factor for nonstationary noise
- * suppression.
- * Byte offset: 10
- */
-
-	int16_t                         eans_n_alphamax;
-/*< Q3.12 maximum over-subtraction factor for nonstationary
- * noise suppression.
- * Byte offset: 12
- */
-	int16_t                         eans_e_alpha;
-/*< Q15 scaling factor for excess noise suppression.
- * Byte offset: 14
- */
-
-	int16_t                         eans_ns_snrmax;
-/*< Upper boundary in dB for SNR estimation.
- * Byte offset: 16
- */
-
-	int16_t                         eans_sns_block;
-/*< Quarter block size for stationary noise suppression.
- * Byte offset: 18
- */
-
-	int16_t                         eans_ns_i;
-/*< Initialization block size for noise suppression.
- * Byte offset: 20
- */
-	int16_t                         eans_np_scale;
-/*< Power scale factor for nonstationary noise update.
- * Byte offset: 22
- */
-
-	int16_t                         eans_n_lambda;
-/*< Smoothing factor for higher level nonstationary noise
- * update.
- * Byte offset: 24
- */
-
-	int16_t                         eans_n_lambdaf;
-/*< Medium averaging factor for noise update.
- * Byte offset: 26
- */
-
-	int16_t                         eans_gs_bias;
-/*< Bias factor in dB for gain calculation.
- * Byte offset: 28
- */
-
-	int16_t                         eans_gs_max;
-/*< SNR lower boundary in dB for aggressive gain calculation.
- * Byte offset: 30
- */
-
-	int16_t                         eans_s_alpha_hb;
-/*< Q3.12 over-subtraction factor for high-band stationary
- * noise suppression.
- * Byte offset: 32
- */
-
-	int16_t                         eans_n_alphamax_hb;
-/*< Q3.12 maximum over-subtraction factor for high-band
- * nonstationary noise suppression.
- * Byte offset: 34
- */
-
-	int16_t                         eans_e_alpha_hb;
-/*< Q15 scaling factor for high-band excess noise suppression.
- * Byte offset: 36
- */
-
-	int16_t                         eans_n_lambda0;
-/*< Smoothing factor for nonstationary noise update during
- * speech activity.
- * Byte offset: 38
- */
-
-	int16_t                         thresh;
-/*< Threshold for generating a binary VAD decision.
- * Byte offset: 40
- */
-
-	int16_t                         pwr_scale;
-/*< Indirect lower boundary of the noise level estimate.
- * Byte offset: 42
- */
-
-	int16_t                         hangover_max;
-/*< Avoids mid-speech clipping and reliably detects weak speech
- * bursts at the end of speech activity.
- * Byte offset: 44
- */
-
-	int16_t                         alpha_snr;
-/*< Controls responsiveness of the VAD.
- * Byte offset: 46
- */
-
-	int16_t                         snr_diff_max;
-/*< Maximum SNR difference. Decreasing this parameter value may
- * help in making correct decisions during abrupt changes; however,
- * decreasing too much may increase false alarms during long
- * pauses/silences.
- * Byte offset: 48
- */
-
-	int16_t                         snr_diff_min;
-/*< Minimum SNR difference. Decreasing this parameter value may
- * help in making correct decisions during abrupt changes; however,
- * decreasing too much may increase false alarms during long
- * pauses/silences.
- * Byte offset: 50
- */
-
-	int16_t                         init_length;
-/*< Defines the number of frames for which a noise level
- * estimate is set to a fixed value.
- * Byte offset: 52
- */
-
-	int16_t                         max_val;
-/*< Defines the upper limit of the noise level.
- * Byte offset: 54
- */
-
-	int16_t                         init_bound;
-/*< Defines the initial bounding value for the noise level
- * estimate. This is used during the initial segment defined by the
- * init_length parameter.
- * Byte offset: 56
- */
-
-	int16_t                         reset_bound;
-/*< Reset boundary for noise tracking.
- * Byte offset: 58
- */
-
-	int16_t                         avar_scale;
-/*< Defines the bias factor in noise estimation.
- * Byte offset: 60
- */
-
-	int16_t                         sub_nc;
-/*< Defines the window length for noise estimation.
- * Byte offset: 62
- */
-
-	int16_t                         spow_min;
-/*< Defines the minimum signal power required to update the
- * boundaries for the noise floor estimate.
- * Byte offset: 64
- */
-
-	int16_t                         eans_gs_fast;
-/*< Fast smoothing factor for postprocessor gain.
- * Byte offset: 66
- */
-
-	int16_t                         eans_gs_med;
-/*< Medium smoothing factor for postprocessor gain.
- * Byte offset: 68
- */
-
-	int16_t                         eans_gs_slow;
-/*< Slow smoothing factor for postprocessor gain.
- * Byte offset: 70
- */
-
-	int16_t                         eans_swb_salpha;
-/*< Q3.12 super wideband aggressiveness factor for stationary
- * noise suppression.
- * Byte offset: 72
- */
-
-	int16_t                         eans_swb_nalpha;
-/*< Q3.12 super wideband aggressiveness factor for
- * nonstationary noise suppression.
- * Byte offset: 74
- */
-} __packed;
-#define ADM_MODULE_IDX_MIC_GAIN_CTRL   0x00010C35
-
-/* @addtogroup audio_pp_param_ids
- * ID of the Tx mic gain control parameter used by the
- * #ADM_MODULE_IDX_MIC_GAIN_CTRL module.
- * @messagepayload
- * @structure{admx_mic_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_IDX_MIC_GAIN.tex}
- */
-#define ADM_PARAM_IDX_MIC_GAIN       0x00010C36
-
-/* Structure for a Tx mic gain parameter for the mic gain
- * control module.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_IDX_MIC_GAIN parameter in the
- * Tx Mic Gain Control module.
- */
-struct admx_mic_gain {
-	uint16_t                  tx_mic_gain;
-	/*< Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero. */
-} __packed;
-
-struct adm_set_mic_gain_params {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-	struct admx_mic_gain mic_gain_data;
-} __packed;
-
-/* end_addtogroup audio_pp_param_ids */
-
-/* @ingroup audio_pp_module_ids
- * ID of the Rx Codec Gain Control module.
- *
- * This module supports the following parameter ID:
- * - #ADM_PARAM_ID_RX_CODEC_GAIN
- */
-#define ADM_MODULE_ID_RX_CODEC_GAIN_CTRL       0x00010C37
-
-/* @addtogroup audio_pp_param_ids
- * ID of the Rx codec gain control parameter used by the
- * #ADM_MODULE_ID_RX_CODEC_GAIN_CTRL module.
- *
- * @messagepayload
- * @structure{adm_rx_codec_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_RX_CODEC_GAIN.tex}
- */
-#define ADM_PARAM_ID_RX_CODEC_GAIN   0x00010C38
-
-/* Structure for the Rx common codec gain control module. */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_RX_CODEC_GAIN parameter
- * in the Rx Codec Gain Control module.
- */
-
-
-struct adm_rx_codec_gain {
-	uint16_t                  rx_codec_gain;
-	/* Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/* Clients must set this field to zero.*/
-} __packed;
-
-/* end_addtogroup audio_pp_param_ids */
-
-/* @ingroup audio_pp_module_ids
- * ID of the HPF Tuning Filter module on the Tx path.
- * This module supports the following parameter IDs:
- * - #ADM_PARAM_ID_HPF_IIRX_FILTER_ENABLE_CONFIG
- * - #ADM_PARAM_ID_HPF_IIRX_FILTER_PRE_GAIN
- * - #ADM_PARAM_ID_HPF_IIRX_FILTER_CONFIG_PARAMS
- */
-#define ADM_MODULE_ID_HPF_IIRX_FILTER    0x00010C3D
-
-/* @addtogroup audio_pp_param_ids */
-/* ID of the Tx HPF IIR filter enable parameter used by the
- * #ADM_MODULE_ID_HPF_IIRX_FILTER module.
- * @parspace Message payload
- * @structure{adm_hpfx_iir_filter_enable_cfg}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_HPF_IIRX_FILTER_ENABLE_CONFIG.tex}
- */
-#define ADM_PARAM_ID_HPF_IIRX_FILTER_ENABLE_CONFIG   0x00010C3E
-
-/* ID of the Tx HPF IIR filter pregain parameter used by the
- * #ADM_MODULE_ID_HPF_IIRX_FILTER module.
- * @parspace Message payload
- * @structure{adm_hpfx_iir_filter_pre_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_HPF_IIRX_FILTER_PRE_GAIN.tex}
- */
-#define ADM_PARAM_ID_HPF_IIRX_FILTER_PRE_GAIN   0x00010C3F
-
-/* ID of the Tx HPF IIR filter configuration parameters used by the
- * #ADM_MODULE_ID_HPF_IIRX_FILTER module.
- * @parspace Message payload
- * @structure{adm_hpfx_iir_filter_cfg_params}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_HPF_IIRX_FILTER_CONFIG_PA
- * RAMS.tex}
- */
-#define ADM_PARAM_ID_HPF_IIRX_FILTER_CONFIG_PARAMS  0x00010C40
-
-/* Structure for enabling a configuration parameter for
- * the HPF IIR tuning filter module on the Tx path.
- */
-
-/* @brief Payload of the #ADM_PARAM_ID_HPF_IIRX_FILTER_ENABLE_CONFIG
- * parameter in the Tx path HPF Tuning Filter module.
- */
-struct adm_hpfx_iir_filter_enable_cfg {
-	uint32_t                  enable_flag;
-/* Specifies whether the HPF tuning filter is disabled (0) or
- * enabled (nonzero).
- */
-} __packed;
-
-
-/* Structure for the pregain parameter for the HPF
- * IIR tuning filter module on the Tx path.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_HPF_IIRX_FILTER_PRE_GAIN parameter
- * in the Tx path HPF Tuning Filter module.
- */
-struct adm_hpfx_iir_filter_pre_gain {
-	uint16_t                  pre_gain;
-	/* Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/* Clients must set this field to zero.*/
-} __packed;
-
-
-/* Structure for the configuration parameter for the
- * HPF IIR tuning filter module on the Tx path.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_HPF_IIRX_FILTER_CONFIG_PARAMS
- * parameters in the Tx path HPF Tuning Filter module. \n
- * \n
- * This structure is followed by tuning filter coefficients as follows: \n
- * - Sequence of int32_t FilterCoeffs.
- * Each band has five coefficients, each in int32_t format in the order of
- * b0, b1, b2, a1, a2.
- * - Sequence of int16_t NumShiftFactor.
- * One int16_t per band. The numerator shift factor is related to the Q
- * factor of the filter coefficients.
- * - Sequence of uint16_t PanSetting.
- * One uint16_t for each band to indicate application of the filter to
- * left (0), right (1), or both (2) channels.
- */
-struct adm_hpfx_iir_filter_cfg_params {
-	uint16_t                  num_biquad_stages;
-/*< Number of bands.
- * Supported values: 0 to 20
- */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-
-/* end_addtogroup audio_pp_module_ids */
-
-/* @addtogroup audio_pp_module_ids */
-/* ID of the Tx path IIR Tuning Filter module.
- *	This module supports the following parameter IDs:
- *	- #ADM_PARAM_IDX_IIR_FILTER_ENABLE_CONFIG
- */
-#define ADM_MODULE_IDX_IIR_FILTER 0x00010C41
-
-/* ID of the Rx path IIR Tuning Filter module for the left channel.
- *	The parameter IDs of the IIR tuning filter module
- *	(#ASM_MODULE_ID_IIRUNING_FILTER) are used for the left IIR Rx tuning
- *	filter.
- *
- * Pan parameters are not required for this per-channel IIR filter; the pan
- * parameters are ignored by this module.
- */
-#define ADM_MODULE_ID_LEFT_IIRUNING_FILTER      0x00010705
-
-/* ID of the the Rx path IIR Tuning Filter module for the right
- * channel.
- * The parameter IDs of the IIR tuning filter module
- * (#ASM_MODULE_ID_IIRUNING_FILTER) are used for the right IIR Rx
- * tuning filter.
- *
- * Pan parameters are not required for this per-channel IIR filter;
- * the pan parameters are ignored by this module.
- */
-#define ADM_MODULE_ID_RIGHT_IIRUNING_FILTER    0x00010706
-
-/* end_addtogroup audio_pp_module_ids */
-
-/* @addtogroup audio_pp_param_ids */
-
-/* ID of the Tx IIR filter enable parameter used by the
- * #ADM_MODULE_IDX_IIR_FILTER module.
- * @parspace Message payload
- * @structure{admx_iir_filter_enable_cfg}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_IDX_IIR_FILTER_ENABLE_CONFIG.tex}
- */
-#define ADM_PARAM_IDX_IIR_FILTER_ENABLE_CONFIG   0x00010C42
-
-/* ID of the Tx IIR filter pregain parameter used by the
- * #ADM_MODULE_IDX_IIR_FILTER module.
- * @parspace Message payload
- * @structure{admx_iir_filter_pre_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_IDX_IIR_FILTER_PRE_GAIN.tex}
- */
-#define ADM_PARAM_IDX_IIR_FILTER_PRE_GAIN    0x00010C43
-
-/* ID of the Tx IIR filter configuration parameters used by the
- * #ADM_MODULE_IDX_IIR_FILTER module.
- * @parspace Message payload
- * @structure{admx_iir_filter_cfg_params}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_IDX_IIR_FILTER_CONFIG_PARAMS.tex}
- */
-#define ADM_PARAM_IDX_IIR_FILTER_CONFIG_PARAMS     0x00010C44
-
-/* Structure for enabling the configuration parameter for the
- * IIR filter module on the Tx path.
- */
-
-/* @brief Payload of the #ADM_PARAM_IDX_IIR_FILTER_ENABLE_CONFIG
- * parameter in the Tx Path IIR Tuning Filter module.
- */
-
-struct admx_iir_filter_enable_cfg {
-	uint32_t                  enable_flag;
-/*< Specifies whether the IIR tuning filter is disabled (0) or
- * enabled (nonzero).
- */
-
-} __packed;
-
-
-/* Structure for the pregain parameter for the
- * IIR filter module on the Tx path.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_IDX_IIR_FILTER_PRE_GAIN
- * parameter in the Tx Path IIR Tuning Filter module.
- */
-
-struct admx_iir_filter_pre_gain {
-	uint16_t                  pre_gain;
-	/*< Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-
-
-/* Structure for the configuration parameter for the
- * IIR filter module on the Tx path.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_IDX_IIR_FILTER_CONFIG_PARAMS
- * parameter in the Tx Path IIR Tuning Filter module. \n
- *	\n
- * This structure is followed by the HPF IIR filter coefficients on
- * the Tx path as follows: \n
- * - Sequence of int32_t ulFilterCoeffs. Each band has five
- * coefficients, each in int32_t format in the order of b0, b1, b2,
- * a1, a2.
- * - Sequence of int16_t sNumShiftFactor. One int16_t per band. The
- * numerator shift factor is related to the Q factor of the filter
- * coefficients.
- * - Sequence of uint16_t usPanSetting. One uint16_t for each band
- * to indicate if the filter is applied to left (0), right (1), or
- * both (2) channels.
- */
-struct admx_iir_filter_cfg_params {
-	uint16_t                  num_biquad_stages;
-/*< Number of bands.
- * Supported values: 0 to 20
- */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-
-/* end_addtogroup audio_pp_module_ids */
-
-/* @ingroup audio_pp_module_ids
- *	ID of the QEnsemble module.
- *	This module supports the following parameter IDs:
- *	- #ADM_PARAM_ID_QENSEMBLE_ENABLE
- *	- #ADM_PARAM_ID_QENSEMBLE_BACKGAIN
- *	- #ADM_PARAM_ID_QENSEMBLE_SET_NEW_ANGLE
- */
-#define ADM_MODULE_ID_QENSEMBLE    0x00010C59
-
-/* @addtogroup audio_pp_param_ids */
-/* ID of the QEnsemble enable parameter used by the
- * #ADM_MODULE_ID_QENSEMBLE module.
- * @messagepayload
- * @structure{adm_qensemble_enable}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_QENSEMBLE_ENABLE.tex}
- */
-#define ADM_PARAM_ID_QENSEMBLE_ENABLE   0x00010C60
-
-/* ID of the QEnsemble back gain parameter used by the
- * #ADM_MODULE_ID_QENSEMBLE module.
- * @messagepayload
- * @structure{adm_qensemble_param_backgain}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_QENSEMBLE_BACKGAIN.tex}
- */
-#define ADM_PARAM_ID_QENSEMBLE_BACKGAIN   0x00010C61
-
-/* ID of the QEnsemble new angle parameter used by the
- * #ADM_MODULE_ID_QENSEMBLE module.
- * @messagepayload
- * @structure{adm_qensemble_param_set_new_angle}
- * @tablespace
- * @inputtable{Audio_Postproc_ADM_PARAM_ID_QENSEMBLE_SET_NEW_ANGLE.tex}
- */
-#define ADM_PARAM_ID_QENSEMBLE_SET_NEW_ANGLE    0x00010C62
-
-/* Structure for enabling the configuration parameter for the
- * QEnsemble module.
- */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_QENSEMBLE_ENABLE
- * parameter used by the QEnsemble module.
- */
-struct adm_qensemble_enable {
-	uint32_t                  enable_flag;
-/*< Specifies whether the QEnsemble module is disabled (0) or enabled
- * (nonzero).
- */
-} __packed;
-
-
-/* Structure for the background gain for the QEnsemble module. */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_QENSEMBLE_BACKGAIN
- * parameter used by
- * the QEnsemble module.
- */
-struct adm_qensemble_param_backgain {
-	int16_t                  back_gain;
-/*< Linear gain in Q15 format.
- * Supported values: 0 to 32767
- */
-
-	uint16_t                 reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-/* Structure for setting a new angle for the QEnsemble module. */
-
-
-/* @brief Payload of the #ADM_PARAM_ID_QENSEMBLE_SET_NEW_ANGLE
- * parameter used
- * by the QEnsemble module.
- */
-struct adm_qensemble_param_set_new_angle {
-	int16_t                    new_angle;
-/*< New angle in degrees.
- * Supported values: 0 to 359
- */
-
-	int16_t                    time_ms;
-/*< Transition time in milliseconds to set the new angle.
- * Supported values: 0 to 32767
- */
-} __packed;
-
-
-#define ADM_CMD_GET_PP_TOPO_MODULE_LIST				0x00010349
-#define ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST			0x00010350
-#define AUDPROC_PARAM_ID_ENABLE					0x00010904
- /*
-  * Payload of the ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
-  */
-struct adm_cmd_get_pp_topo_module_list_t {
-	struct apr_hdr hdr;
-	/* Lower 32 bits of the 64-bit parameter data payload address. */
-	uint32_t                  data_payload_addr_lsw;
-	/*
-	 * Upper 32 bits of the 64-bit parameter data payload address.
-	 *
-	 *
-	 * The size of the shared memory, if specified, must be large enough to
-	 * contain the entire parameter data payload, including the module ID,
-	 * parameter ID, parameter size, and parameter values.
-	 */
-	uint32_t                  data_payload_addr_msw;
-	/*
-	 *  Unique identifier for an address.
-	 *
-	 * This memory map handle is returned by the aDSP through the
-	 * #ADM_CMD_SHARED_MEM_MAP_REGIONS command.
-	 *
-	 * @values
-	 * - Non-NULL -- On acknowledgment, the parameter data payloads begin at
-	 * the address specified (out-of-band)
-	 * - NULL -- The acknowledgment's payload contains the parameter data
-	 * (in-band) @tablebulletend
-	 */
-	uint32_t                  mem_map_handle;
-	/*
-	 * Maximum data size of the list of modules. This
-	 * field is a multiple of 4 bytes.
-	 */
-	uint16_t                  param_max_size;
-	/* This field must be set to zero. */
-	uint16_t                  reserved;
-} __packed;
-
-/*
- * Payload of the ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST message, which returns
- * module ids in response to an ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
- * Immediately following this structure is the acknowledgment <b>module id
- * data variable payload</b> containing the pre/postprocessing module id
- * values. For an in-band scenario, the variable payload depends on the size
- * of the parameter.
- */
-struct adm_cmd_rsp_get_pp_topo_module_list_t {
-	/* Status message (error code). */
-	uint32_t                  status;
-} __packed;
-
-struct audproc_topology_module_id_info_t {
-	uint32_t	num_modules;
-} __packed;
-
-/* end_addtogroup audio_pp_module_ids */
-
-/* @ingroup audio_pp_module_ids
- * ID of the Volume Control module pre/postprocessing block.
- * This module supports the following parameter IDs:
- * - #ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN
- * - #ASM_PARAM_ID_MULTICHANNEL_GAIN
- * - #ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG
- * - #ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS
- * - #ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS
- * - #ASM_PARAM_ID_MULTICHANNEL_GAIN
- * - #ASM_PARAM_ID_MULTICHANNEL_MUTE
- */
-#define ASM_MODULE_ID_VOL_CTRL   0x00010BFE
-#define ASM_MODULE_ID_VOL_CTRL2  0x00010910
-#define AUDPROC_MODULE_ID_VOL_CTRL ASM_MODULE_ID_VOL_CTRL
-
-/* @addtogroup audio_pp_param_ids */
-/* ID of the master gain parameter used by the #ASM_MODULE_ID_VOL_CTRL
- * module.
- * @messagepayload
- * @structure{asm_volume_ctrl_master_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN.tex}
- */
-#define ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN    0x00010BFF
-#define AUDPROC_PARAM_ID_VOL_CTRL_MASTER_GAIN ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN
-
-/* ID of the left/right channel gain parameter used by the
- * #ASM_MODULE_ID_VOL_CTRL module.
- * @messagepayload
- * @structure{asm_volume_ctrl_lr_chan_gain}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_MULTICHANNEL_GAIN.tex}
- */
-#define ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN     0x00010C00
-
-/* ID of the mute configuration parameter used by the
- * #ASM_MODULE_ID_VOL_CTRL module.
- * @messagepayload
- * @structure{asm_volume_ctrl_mute_config}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG.tex}
- */
-#define ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG   0x00010C01
-
-/* ID of the soft stepping volume parameters used by the
- * #ASM_MODULE_ID_VOL_CTRL module.
- * @messagepayload
- * @structure{asm_soft_step_volume_params}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMET
- * ERS.tex}
- */
-#define ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS  0x00010C29
-#define AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS\
-			ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS
-
-/* ID of the soft pause parameters used by the #ASM_MODULE_ID_VOL_CTRL
- * module.
- */
-#define ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS   0x00010D6A
-
-/* ID of the multiple-channel volume control parameters used by the
- * #ASM_MODULE_ID_VOL_CTRL module.
- */
-#define ASM_PARAM_ID_MULTICHANNEL_GAIN  0x00010713
-
-/* ID of the multiple-channel mute configuration parameters used by the
- * #ASM_MODULE_ID_VOL_CTRL module.
- */
-
-#define ASM_PARAM_ID_MULTICHANNEL_MUTE  0x00010714
-
-/* Structure for the master gain parameter for a volume control
- * module.
- */
-
-
-/* @brief Payload of the #ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN
- * parameter used by the Volume Control module.
- */
-
-
-
-struct asm_volume_ctrl_master_gain {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint16_t                  master_gain;
-	/* Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/* Clients must set this field to zero. */
-} __packed;
-
-
-struct asm_volume_ctrl_lr_chan_gain {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-
-	uint16_t                  l_chan_gain;
-	/*< Linear gain in Q13 format for the left channel. */
-
-	uint16_t                  r_chan_gain;
-	/*< Linear gain in Q13 format for the right channel.*/
-} __packed;
-
-
-/* Structure for the mute configuration parameter for a
- * volume control module.
- */
-
-
-/* @brief Payload of the #ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG
- * parameter used by the Volume Control module.
- */
-
-
-struct asm_volume_ctrl_mute_config {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint32_t                  mute_flag;
-/*< Specifies whether mute is disabled (0) or enabled (nonzero).*/
-
-} __packed;
-
-/*
- * Supported parameters for a soft stepping linear ramping curve.
- */
-#define ASM_PARAM_SVC_RAMPINGCURVE_LINEAR  0
-
-/*
- * Exponential ramping curve.
- */
-#define ASM_PARAM_SVC_RAMPINGCURVE_EXP    1
-
-/*
- * Logarithmic ramping curve.
- */
-#define ASM_PARAM_SVC_RAMPINGCURVE_LOG    2
-
-/* Structure for holding soft stepping volume parameters. */
-
-
-/*  Payload of the #ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS
- * parameters used by the Volume Control module.
- */
-struct asm_soft_step_volume_params {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint32_t                  period;
-/*< Period in milliseconds.
- * Supported values: 0 to 15000
- */
-
-	uint32_t                  step;
-/*< Step in microseconds.
- * Supported values: 0 to 15000000
- */
-
-	uint32_t                  ramping_curve;
-/*< Ramping curve type.
- * Supported values:
- * - #ASM_PARAM_SVC_RAMPINGCURVE_LINEAR
- * - #ASM_PARAM_SVC_RAMPINGCURVE_EXP
- * - #ASM_PARAM_SVC_RAMPINGCURVE_LOG
- */
-} __packed;
-
-
-/* Structure for holding soft pause parameters. */
-
-
-/* Payload of the #ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS
- * parameters used by the Volume Control module.
- */
-
-
-struct asm_soft_pause_params {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint32_t                  enable_flag;
-/*< Specifies whether soft pause is disabled (0) or enabled
- * (nonzero).
- */
-
-
-
-	uint32_t                  period;
-/*< Period in milliseconds.
- * Supported values: 0 to 15000
- */
-
-	uint32_t                  step;
-/*< Step in microseconds.
- * Supported values: 0 to 15000000
- */
-
-	uint32_t                  ramping_curve;
-/*< Ramping curve.
- * Supported values:
- * - #ASM_PARAM_SVC_RAMPINGCURVE_LINEAR
- * - #ASM_PARAM_SVC_RAMPINGCURVE_EXP
- * - #ASM_PARAM_SVC_RAMPINGCURVE_LOG
- */
-} __packed;
-
-
-/* Maximum number of channels.*/
-#define VOLUME_CONTROL_MAX_CHANNELS                       8
-
-/* Structure for holding one channel type - gain pair. */
-
-
-/* Payload of the #ASM_PARAM_ID_MULTICHANNEL_GAIN channel
- * type/gain pairs used by the Volume Control module. \n \n This
- * structure immediately follows the
- * asm_volume_ctrl_multichannel_gain structure.
- */
-
-
-struct asm_volume_ctrl_channeltype_gain_pair {
-	uint8_t                   channeltype;
-	/*
-	 * Channel type for which the gain setting is to be applied.
-	 * Supported values:
-	 * - #PCM_CHANNEL_L
-	 * - #PCM_CHANNEL_R
-	 * - #PCM_CHANNEL_C
-	 * - #PCM_CHANNEL_LS
-	 * - #PCM_CHANNEL_RS
-	 * - #PCM_CHANNEL_LFE
-	 * - #PCM_CHANNEL_CS
-	 * - #PCM_CHANNEL_LB
-	 * - #PCM_CHANNEL_RB
-	 * - #PCM_CHANNELS
-	 * - #PCM_CHANNEL_CVH
-	 * - #PCM_CHANNEL_MS
-	 * - #PCM_CHANNEL_FLC
-	 * - #PCM_CHANNEL_FRC
-	 * - #PCM_CHANNEL_RLC
-	 * - #PCM_CHANNEL_RRC
-	 */
-
-	uint8_t                   reserved1;
-	/* Clients must set this field to zero. */
-
-	uint8_t                   reserved2;
-	/* Clients must set this field to zero. */
-
-	uint8_t                   reserved3;
-	/* Clients must set this field to zero. */
-
-	uint32_t                  gain;
-	/*
-	 * Gain value for this channel in Q28 format.
-	 * Supported values: Any
-	 */
-} __packed;
-
-
-/* Structure for the multichannel gain command */
-
-
-/* Payload of the #ASM_PARAM_ID_MULTICHANNEL_GAIN
- * parameters used by the Volume Control module.
- */
-
-
-struct asm_volume_ctrl_multichannel_gain {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint32_t                  num_channels;
-	/*
-	 * Number of channels for which gain values are provided. Any
-	 * channels present in the data for which gain is not provided are
-	 * set to unity gain.
-	 * Supported values: 1 to 8
-	 */
-
-	struct asm_volume_ctrl_channeltype_gain_pair
-		gain_data[VOLUME_CONTROL_MAX_CHANNELS];
-	/* Array of channel type/gain pairs.*/
-} __packed;
-
-
-/* Structure for holding one channel type - mute pair. */
-
-
-/* Payload of the #ASM_PARAM_ID_MULTICHANNEL_MUTE channel
- * type/mute setting pairs used by the Volume Control module. \n \n
- * This structure immediately follows the
- * asm_volume_ctrl_multichannel_mute structure.
- */
-
-
-struct asm_volume_ctrl_channelype_mute_pair {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint8_t                   channelype;
-/*< Channel type for which the mute setting is to be applied.
- * Supported values:
- * - #PCM_CHANNEL_L
- * - #PCM_CHANNEL_R
- * - #PCM_CHANNEL_C
- * - #PCM_CHANNEL_LS
- * - #PCM_CHANNEL_RS
- * - #PCM_CHANNEL_LFE
- * - #PCM_CHANNEL_CS
- * - #PCM_CHANNEL_LB
- * - #PCM_CHANNEL_RB
- * - #PCM_CHANNELS
- * - #PCM_CHANNEL_CVH
- * - #PCM_CHANNEL_MS
- * - #PCM_CHANNEL_FLC
- * - #PCM_CHANNEL_FRC
- * - #PCM_CHANNEL_RLC
- * - #PCM_CHANNEL_RRC
- */
-
-	uint8_t                   reserved1;
-	/*< Clients must set this field to zero. */
-
-	uint8_t                   reserved2;
-	/*< Clients must set this field to zero. */
-
-	uint8_t                   reserved3;
-	/*< Clients must set this field to zero. */
-
-	uint32_t                  mute;
-/*< Mute setting for this channel.
- * Supported values:
- * - 0 = Unmute
- * - Nonzero = Mute
- */
-} __packed;
-
-
-/* Structure for the multichannel mute command */
-
-
-/* @brief Payload of the #ASM_PARAM_ID_MULTICHANNEL_MUTE
- * parameters used by the Volume Control module.
- */
-
-
-struct asm_volume_ctrl_multichannel_mute {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	uint32_t                  num_channels;
-/*< Number of channels for which mute configuration is
- * provided. Any channels present in the data for which mute
- * configuration is not provided are set to unmute.
- * Supported values: 1 to 8
- */
-
-struct asm_volume_ctrl_channelype_mute_pair
-				mute_data[VOLUME_CONTROL_MAX_CHANNELS];
-	/*< Array of channel type/mute setting pairs.*/
-} __packed;
-/* end_addtogroup audio_pp_param_ids */
-
-/* audio_pp_module_ids
- * ID of the IIR Tuning Filter module.
- * This module supports the following parameter IDs:
- * - #ASM_PARAM_ID_IIRUNING_FILTER_ENABLE_CONFIG
- * - #ASM_PARAM_ID_IIRUNING_FILTER_PRE_GAIN
- * - #ASM_PARAM_ID_IIRUNING_FILTER_CONFIG_PARAMS
- */
-#define ASM_MODULE_ID_IIRUNING_FILTER   0x00010C02
-
-/* @addtogroup audio_pp_param_ids */
-/* ID of the IIR tuning filter enable parameter used by the
- * #ASM_MODULE_ID_IIRUNING_FILTER module.
- * @messagepayload
- * @structure{asm_iiruning_filter_enable}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_IIRUNING_FILTER_ENABLE_CO
- * NFIG.tex}
- */
-#define ASM_PARAM_ID_IIRUNING_FILTER_ENABLE_CONFIG   0x00010C03
-
-/* ID of the IIR tuning filter pregain parameter used by the
- * #ASM_MODULE_ID_IIRUNING_FILTER module.
- */
-#define ASM_PARAM_ID_IIRUNING_FILTER_PRE_GAIN  0x00010C04
-
-/* ID of the IIR tuning filter configuration parameters used by the
- * #ASM_MODULE_ID_IIRUNING_FILTER module.
- */
-#define ASM_PARAM_ID_IIRUNING_FILTER_CONFIG_PARAMS  0x00010C05
-
-/* Structure for an enable configuration parameter for an
- * IIR tuning filter module.
- */
-
-
-/* @brief Payload of the #ASM_PARAM_ID_IIRUNING_FILTER_ENABLE_CONFIG
- * parameter used by the IIR Tuning Filter module.
- */
-struct asm_iiruning_filter_enable {
-	uint32_t                  enable_flag;
-/*< Specifies whether the IIR tuning filter is disabled (0) or
- * enabled (1).
- */
-} __packed;
-
-/* Structure for the pregain parameter for an IIR tuning filter module. */
-
-
-/* Payload of the #ASM_PARAM_ID_IIRUNING_FILTER_PRE_GAIN
- * parameters used by the IIR Tuning Filter module.
- */
-struct asm_iiruning_filter_pregain {
-	uint16_t                  pregain;
-	/*< Linear gain in Q13 format. */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-
-/* Structure for the configuration parameter for an IIR tuning filter
- * module.
- */
-
-
-/* @brief Payload of the #ASM_PARAM_ID_IIRUNING_FILTER_CONFIG_PARAMS
- * parameters used by the IIR Tuning Filter module. \n
- * \n
- * This structure is followed by the IIR filter coefficients: \n
- * - Sequence of int32_t FilterCoeffs \n
- * Five coefficients for each band. Each coefficient is in int32_t format, in
- * the order of b0, b1, b2, a1, a2.
- * - Sequence of int16_t NumShiftFactor \n
- * One int16_t per band. The numerator shift factor is related to the Q
- * factor of the filter coefficients.
- * - Sequence of uint16_t PanSetting \n
- * One uint16_t per band, indicating if the filter is applied to left (0),
- * right (1), or both (2) channels.
- */
-struct asm_iir_filter_config_params {
-	uint16_t                  num_biquad_stages;
-/*< Number of bands.
- * Supported values: 0 to 20
- */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero.*/
-} __packed;
-
-/* audio_pp_module_ids
- * ID of the Multiband Dynamic Range Control (MBDRC) module on the Tx/Rx
- * paths.
- * This module supports the following parameter IDs:
- * - #ASM_PARAM_ID_MBDRC_ENABLE
- * - #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS
- */
-#define ASM_MODULE_ID_MBDRC   0x00010C06
-
-/* audio_pp_param_ids */
-/* ID of the MBDRC enable parameter used by the #ASM_MODULE_ID_MBDRC module.
- * @messagepayload
- * @structure{asm_mbdrc_enable}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_MBDRC_ENABLE.tex}
- */
-#define ASM_PARAM_ID_MBDRC_ENABLE   0x00010C07
-
-/* ID of the MBDRC configuration parameters used by the
- * #ASM_MODULE_ID_MBDRC module.
- * @messagepayload
- * @structure{asm_mbdrc_config_params}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_MBDRC_CONFIG_PARAMS.tex}
- *
- * @parspace Sub-band DRC configuration parameters
- * @structure{asm_subband_drc_config_params}
- * @tablespace
- * @inputtable{Audio_Postproc_ASM_PARAM_ID_MBDRC_CONFIG_PARAMS_subband_DRC.tex}
- *
- * @keep{6}
- * To obtain legacy ADRC from MBDRC, use the calibration tool to:
- *
- * - Enable MBDRC (EnableFlag = TRUE)
- * - Set number of bands to 1 (uiNumBands = 1)
- * - Enable the first MBDRC band (DrcMode[0] = DRC_ENABLED = 1)
- * - Clear the first band mute flag (MuteFlag[0] = 0)
- * - Set the first band makeup gain to unity (compMakeUpGain[0] = 0x2000)
- * - Use the legacy ADRC parameters to calibrate the rest of the MBDRC
- * parameters.
- */
-#define ASM_PARAM_ID_MBDRC_CONFIG_PARAMS  0x00010C08
-
-/* end_addtogroup audio_pp_param_ids */
-
-/* audio_pp_module_ids
- * ID of the MMBDRC module version 2 pre/postprocessing block.
- * This module differs from the original MBDRC (#ASM_MODULE_ID_MBDRC) in
- * the length of the filters used in each sub-band.
- * This module supports the following parameter ID:
- * - #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS_IMPROVED_FILTBANK_V2
- */
-#define ASM_MODULE_ID_MBDRCV2                                0x0001070B
-
-/* @addtogroup audio_pp_param_ids */
-/* ID of the configuration parameters used by the
- * #ASM_MODULE_ID_MBDRCV2 module for the improved filter structure
- * of the MBDRC v2 pre/postprocessing block.
- * The update to this configuration structure from the original
- * MBDRC is the number of filter coefficients in the filter
- * structure. The sequence for is as follows:
- * - 1 band = 0 FIR coefficient + 1 mute flag + uint16_t padding
- * - 2 bands = 141 FIR coefficients + 2 mute flags + uint16_t padding
- * - 3 bands = 141+81 FIR coefficients + 3 mute flags + uint16_t padding
- * - 4 bands = 141+81+61 FIR coefficients + 4 mute flags + uint16_t
- * padding
- * - 5 bands = 141+81+61+61 FIR coefficients + 5 mute flags +
- * uint16_t padding
- *	This block uses the same parameter structure as
- *	#ASM_PARAM_ID_MBDRC_CONFIG_PARAMS.
- */
-#define ASM_PARAM_ID_MBDRC_CONFIG_PARAMS_IMPROVED_FILTBANK_V2 \
-								0x0001070C
-
-#define ASM_MODULE_ID_MBDRCV3					0x0001090B
-/*
- * ID of the MMBDRC module version 3 pre/postprocessing block.
- * This module differs from MBDRCv2 (#ASM_MODULE_ID_MBDRCV2) in
- * that it supports both 16- and 24-bit data.
- * This module supports the following parameter ID:
- * - #ASM_PARAM_ID_MBDRC_ENABLE
- * - #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS
- * - #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS_V3
- * - #ASM_PARAM_ID_MBDRC_FILTER_XOVER_FREQS
- */
-
-/* Structure for the enable parameter for an MBDRC module. */
-
-
-/* Payload of the #ASM_PARAM_ID_MBDRC_ENABLE parameter used by the
- * MBDRC module.
- */
-struct asm_mbdrc_enable {
-	uint32_t                  enable_flag;
-/*< Specifies whether MBDRC is disabled (0) or enabled (nonzero).*/
-} __packed;
-
-/* Structure for the configuration parameters for an MBDRC module. */
-
-
-/* Payload of the #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS
- * parameters used by the MBDRC module. \n \n Following this
- * structure is the payload for sub-band DRC configuration
- * parameters (asm_subband_drc_config_params). This sub-band
- * structure must be repeated for each band.
- */
-
-
-struct asm_mbdrc_config_params {
-	uint16_t                  num_bands;
-/*< Number of bands.
- * Supported values: 1 to 5
- */
-
-	int16_t                   limiterhreshold;
-/*< Threshold in decibels for the limiter output.
- * Supported values: -72 to 18 \n
- * Recommended value: 3994 (-0.22 db in Q3.12 format)
- */
-
-	int16_t                   limiter_makeup_gain;
-/*< Makeup gain in decibels for the limiter output.
- * Supported values: -42 to 42 \n
- * Recommended value: 256 (0 dB in Q7.8 format)
- */
-
-	int16_t                   limiter_gc;
-/*< Limiter gain recovery coefficient.
- * Supported values: 0.5 to 0.99 \n
- * Recommended value: 32440 (0.99 in Q15 format)
- */
-
-	int16_t                   limiter_delay;
-/*< Limiter delay in samples.
- * Supported values: 0 to 10 \n
- * Recommended value: 262 (0.008 samples in Q15 format)
- */
-
-	int16_t                   limiter_max_wait;
-/*< Maximum limiter waiting time in samples.
- * Supported values: 0 to 10 \n
- * Recommended value: 262 (0.008 samples in Q15 format)
- */
-} __packed;
-
-/* DRC configuration structure for each sub-band of an MBDRC module. */
-
-
-/* Payload of the #ASM_PARAM_ID_MBDRC_CONFIG_PARAMS DRC
- * configuration parameters for each sub-band in the MBDRC module.
- * After this DRC structure is configured for valid bands, the next
- * MBDRC setparams expects the sequence of sub-band MBDRC filter
- * coefficients (the length depends on the number of bands) plus the
- * mute flag for that band plus uint16_t padding.
- *
- * @keep{10}
- * The filter coefficient and mute flag are of type int16_t:
- * - FIR coefficient = int16_t firFilter
- * - Mute flag = int16_t fMuteFlag
- *
- * The sequence is as follows:
- * - 1 band = 0 FIR coefficient + 1 mute flag + uint16_t padding
- * - 2 bands = 97 FIR coefficients + 2 mute flags + uint16_t padding
- * - 3 bands = 97+33 FIR coefficients + 3 mute flags + uint16_t padding
- * - 4 bands = 97+33+33 FIR coefficients + 4 mute flags + uint16_t padding
- * - 5 bands = 97+33+33+33 FIR coefficients + 5 mute flags + uint16_t padding
- *
- * For improved filterbank, the sequence is as follows:
- * - 1 band = 0 FIR coefficient + 1 mute flag + uint16_t padding
- * - 2 bands = 141 FIR coefficients + 2 mute flags + uint16_t padding
- * - 3 bands = 141+81 FIR coefficients + 3 mute flags + uint16_t padding
- * - 4 bands = 141+81+61 FIR coefficients + 4 mute flags + uint16_t padding
- * - 5 bands = 141+81+61+61 FIR coefficients + 5 mute flags + uint16_t padding
- */
-struct asm_subband_drc_config_params {
-	int16_t                   drc_stereo_linked_flag;
-/*< Specifies whether all stereo channels have the same applied
- * dynamics (1) or if they process their dynamics independently (0).
- * Supported values:
- * - 0 -- Not linked
- * - 1 -- Linked
- */
-
-	int16_t                   drc_mode;
-/*< Specifies whether DRC mode is bypassed for sub-bands.
- * Supported values:
- * - 0 -- Disabled
- * - 1 -- Enabled
- */
-
-	int16_t                   drc_down_sample_level;
-/*< DRC down sample level.
- * Supported values: @ge 1
- */
-
-	int16_t                   drc_delay;
-/*< DRC delay in samples.
- * Supported values: 0 to 1200
- */
-
-	uint16_t                  drc_rmsime_avg_const;
-/*< RMS signal energy time-averaging constant.
- * Supported values: 0 to 2^16-1
- */
-
-	uint16_t                  drc_makeup_gain;
-/*< DRC makeup gain in decibels.
- * Supported values: 258 to 64917
- */
-	/* Down expander settings */
-	int16_t                   down_expdrhreshold;
-/*< Down expander threshold.
- * Supported Q7 format values: 1320 to up_cmpsrhreshold
- */
-
-	int16_t                   down_expdr_slope;
-/*< Down expander slope.
- * Supported Q8 format values: -32768 to 0.
- */
-
-	uint32_t                  down_expdr_attack;
-/*< Down expander attack constant.
- * Supported Q31 format values: 196844 to 2^31.
- */
-
-	uint32_t                  down_expdr_release;
-/*< Down expander release constant.
- * Supported Q31 format values: 19685 to 2^31
- */
-
-	uint16_t                  down_expdr_hysteresis;
-/*< Down expander hysteresis constant.
- * Supported Q14 format values: 1 to 32690
- */
-
-	uint16_t                  reserved;
-	/*< Clients must set this field to zero. */
-
-	int32_t                   down_expdr_min_gain_db;
-/*< Down expander minimum gain.
- * Supported Q23 format values: -805306368 to 0.
- */
-
-	/* Up compressor settings */
-
-	int16_t                   up_cmpsrhreshold;
-/*< Up compressor threshold.
- * Supported Q7 format values: down_expdrhreshold to
- * down_cmpsrhreshold.
- */
-
-	uint16_t                  up_cmpsr_slope;
-/*< Up compressor slope.
- * Supported Q16 format values: 0 to 64881.
- */
-
-	uint32_t                  up_cmpsr_attack;
-/*< Up compressor attack constant.
- * Supported Q31 format values: 196844 to 2^31.
- */
-
-	uint32_t                  up_cmpsr_release;
-/*< Up compressor release constant.
- * Supported Q31 format values: 19685 to 2^31.
- */
-
-	uint16_t                  up_cmpsr_hysteresis;
-/*< Up compressor hysteresis constant.
- * Supported Q14 format values: 1 to 32690.
- */
-
-	/* Down compressor settings */
-
-	int16_t                   down_cmpsrhreshold;
-/*< Down compressor threshold.
- * Supported Q7 format values: up_cmpsrhreshold to 11560.
- */
-
-	uint16_t                  down_cmpsr_slope;
-/*< Down compressor slope.
- * Supported Q16 format values: 0 to 64881.
- */
-
-	uint16_t                  reserved1;
-/*< Clients must set this field to zero. */
-
-	uint32_t                  down_cmpsr_attack;
-/*< Down compressor attack constant.
- * Supported Q31 format values: 196844 to 2^31.
- */
-
-	uint32_t                  down_cmpsr_release;
-/*< Down compressor release constant.
- * Supported Q31 format values: 19685 to 2^31.
- */
-
-	uint16_t                  down_cmpsr_hysteresis;
-/*< Down compressor hysteresis constant.
- * Supported Q14 values: 1 to 32690.
- */
-
-	uint16_t                  reserved2;
-/*< Clients must set this field to zero.*/
-} __packed;
-
-#define ASM_MODULE_ID_EQUALIZER            0x00010C27
-#define ASM_PARAM_ID_EQUALIZER_PARAMETERS  0x00010C28
-
-#define ASM_MAX_EQ_BANDS 12
-
-struct asm_eq_per_band_params {
-	uint32_t                  band_idx;
-/*< Band index.
- * Supported values: 0 to 11
- */
-
-	uint32_t                  filterype;
-/*< Type of filter.
- * Supported values:
- * - #ASM_PARAM_EQYPE_NONE
- * - #ASM_PARAM_EQ_BASS_BOOST
- * - #ASM_PARAM_EQ_BASS_CUT
- * - #ASM_PARAM_EQREBLE_BOOST
- * - #ASM_PARAM_EQREBLE_CUT
- * - #ASM_PARAM_EQ_BAND_BOOST
- * - #ASM_PARAM_EQ_BAND_CUT
- */
-
-	uint32_t                  center_freq_hz;
-	/*< Filter band center frequency in Hertz. */
-
-	int32_t                   filter_gain;
-/*< Filter band initial gain.
- * Supported values: +12 to -12 dB in 1 dB increments
- */
-
-	int32_t                   q_factor;
-/*< Filter band quality factor expressed as a Q8 number, i.e., a
- * fixed-point number with q factor of 8. For example, 3000/(2^8).
- */
-} __packed;
-
-struct asm_eq_params {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-		uint32_t                  enable_flag;
-/*< Specifies whether the equalizer module is disabled (0) or enabled
- * (nonzero).
- */
-
-		uint32_t                  num_bands;
-/*< Number of bands.
- * Supported values: 1 to 12
- */
-	struct asm_eq_per_band_params eq_bands[ASM_MAX_EQ_BANDS];
-
-} __packed;
-
-/*	No equalizer effect.*/
-#define ASM_PARAM_EQYPE_NONE      0
-
-/*	Bass boost equalizer effect.*/
-#define ASM_PARAM_EQ_BASS_BOOST     1
-
-/*Bass cut equalizer effect.*/
-#define ASM_PARAM_EQ_BASS_CUT       2
-
-/*	Treble boost equalizer effect */
-#define ASM_PARAM_EQREBLE_BOOST   3
-
-/*	Treble cut equalizer effect.*/
-#define ASM_PARAM_EQREBLE_CUT     4
-
-/*	Band boost equalizer effect.*/
-#define ASM_PARAM_EQ_BAND_BOOST     5
-
-/*	Band cut equalizer effect.*/
-#define ASM_PARAM_EQ_BAND_CUT       6
-
-/* Get & set params */
-#define VSS_ICOMMON_CMD_SET_PARAM_V2	0x0001133D
-#define VSS_ICOMMON_CMD_GET_PARAM_V2	0x0001133E
-#define VSS_ICOMMON_RSP_GET_PARAM	0x00011008
-
-#define VSS_MAX_AVCS_NUM_SERVICES	25
-
-/* ID of the Bass Boost module.
- * This module supports the following parameter IDs:
- *  - #AUDPROC_PARAM_ID_BASS_BOOST_ENABLE
- *  - #AUDPROC_PARAM_ID_BASS_BOOST_MODE
- *  - #AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH
- */
-#define AUDPROC_MODULE_ID_BASS_BOOST                             0x000108A1
-/* ID of the Bass Boost enable parameter used by
- * AUDPROC_MODULE_ID_BASS_BOOST.
- */
-#define AUDPROC_PARAM_ID_BASS_BOOST_ENABLE                       0x000108A2
-/* ID of the Bass Boost mode parameter used by
- * AUDPROC_MODULE_ID_BASS_BOOST.
- */
-#define AUDPROC_PARAM_ID_BASS_BOOST_MODE                         0x000108A3
-/* ID of the Bass Boost strength parameter used by
- * AUDPROC_MODULE_ID_BASS_BOOST.
- */
-#define AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH                     0x000108A4
-
-/* ID of the PBE module.
- * This module supports the following parameter IDs:
- * - #AUDPROC_PARAM_ID_PBE_ENABLE
- * - #AUDPROC_PARAM_ID_PBE_PARAM_CONFIG
- */
-#define AUDPROC_MODULE_ID_PBE                                    0x00010C2A
-/* ID of the Bass Boost enable parameter used by
- * AUDPROC_MODULE_ID_BASS_BOOST.
- */
-#define AUDPROC_PARAM_ID_PBE_ENABLE                              0x00010C2B
-/* ID of the Bass Boost mode parameter used by
- * AUDPROC_MODULE_ID_BASS_BOOST.
- */
-#define AUDPROC_PARAM_ID_PBE_PARAM_CONFIG                        0x00010C49
-
-/* ID of the Virtualizer module. This module supports the
- * following parameter IDs:
- * - #AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE
- * - #AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH
- * - #AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE
- * - #AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST
- */
-#define AUDPROC_MODULE_ID_VIRTUALIZER                            0x000108A5
-/* ID of the Virtualizer enable parameter used by
- * AUDPROC_MODULE_ID_VIRTUALIZER.
- */
-#define AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE                      0x000108A6
-/* ID of the Virtualizer strength parameter used by
- * AUDPROC_MODULE_ID_VIRTUALIZER.
- */
-#define AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH                    0x000108A7
-/* ID of the Virtualizer out type parameter used by
- * AUDPROC_MODULE_ID_VIRTUALIZER.
- */
-#define AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE                    0x000108A8
-/* ID of the Virtualizer out type parameter used by
- * AUDPROC_MODULE_ID_VIRTUALIZER.
- */
-#define AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST                 0x000108A9
-
-/* ID of the Reverb module. This module supports the following
- * parameter IDs:
- * - #AUDPROC_PARAM_ID_REVERB_ENABLE
- * - #AUDPROC_PARAM_ID_REVERB_MODE
- * - #AUDPROC_PARAM_ID_REVERB_PRESET
- * - #AUDPROC_PARAM_ID_REVERB_WET_MIX
- * - #AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST
- * - #AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL
- * - #AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL
- * - #AUDPROC_PARAM_ID_REVERB_DECAY_TIME
- * - #AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO
- * - #AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL
- * - #AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY
- * - #AUDPROC_PARAM_ID_REVERB_LEVEL
- * - #AUDPROC_PARAM_ID_REVERB_DELAY
- * - #AUDPROC_PARAM_ID_REVERB_DIFFUSION
- * - #AUDPROC_PARAM_ID_REVERB_DENSITY
- */
-#define AUDPROC_MODULE_ID_REVERB                          0x000108AA
-/* ID of the Reverb enable parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_ENABLE                    0x000108AB
-/* ID of the Reverb mode parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_MODE                      0x000108AC
-/* ID of the Reverb preset parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_PRESET                    0x000108AD
-/* ID of the Reverb wet mix parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_WET_MIX                   0x000108AE
-/* ID of the Reverb gain adjust parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST               0x000108AF
-/* ID of the Reverb room level parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL                0x000108B0
-/* ID of the Reverb room hf level parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL             0x000108B1
-/* ID of the Reverb decay time parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_DECAY_TIME                0x000108B2
-/* ID of the Reverb decay hf ratio parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO            0x000108B3
-/* ID of the Reverb reflections level parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL         0x000108B4
-/* ID of the Reverb reflections delay parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY         0x000108B5
-/* ID of the Reverb level parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_LEVEL                      0x000108B6
-/* ID of the Reverb delay parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_DELAY                      0x000108B7
-/* ID of the Reverb diffusion parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_DIFFUSION                  0x000108B8
-/* ID of the Reverb density parameter used by
- * AUDPROC_MODULE_ID_REVERB.
- */
-#define AUDPROC_PARAM_ID_REVERB_DENSITY                    0x000108B9
-
-/* ID of the Popless Equalizer module. This module supports the
- * following parameter IDs:
- * - #AUDPROC_PARAM_ID_EQ_ENABLE
- * - #AUDPROC_PARAM_ID_EQ_CONFIG
- * - #AUDPROC_PARAM_ID_EQ_NUM_BANDS
- * - #AUDPROC_PARAM_ID_EQ_BAND_LEVELS
- * - #AUDPROC_PARAM_ID_EQ_BAND_LEVEL_RANGE
- * - #AUDPROC_PARAM_ID_EQ_BAND_FREQS
- * - #AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ_RANGE
- * - #AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ
- * - #AUDPROC_PARAM_ID_EQ_BAND_INDEX
- * - #AUDPROC_PARAM_ID_EQ_PRESET_ID
- * - #AUDPROC_PARAM_ID_EQ_NUM_PRESETS
- * - #AUDPROC_PARAM_ID_EQ_GET_PRESET_NAME
- */
-#define AUDPROC_MODULE_ID_POPLESS_EQUALIZER                    0x000108BA
-/* ID of the Popless Equalizer enable parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
- */
-#define AUDPROC_PARAM_ID_EQ_ENABLE                             0x000108BB
-/* ID of the Popless Equalizer config parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
- */
-#define AUDPROC_PARAM_ID_EQ_CONFIG                             0x000108BC
-/* ID of the Popless Equalizer number of bands parameter used
- * by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
- * used for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_NUM_BANDS                          0x000108BD
-/* ID of the Popless Equalizer band levels parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
- * used for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_BAND_LEVELS                        0x000108BE
-/* ID of the Popless Equalizer band level range parameter used
- * by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
- * used for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_BAND_LEVEL_RANGE                   0x000108BF
-/* ID of the Popless Equalizer band frequencies parameter used
- * by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
- * used for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_BAND_FREQS                         0x000108C0
-/* ID of the Popless Equalizer single band frequency range
- * parameter used by AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
- *  This param ID is used for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ_RANGE             0x000108C1
-/* ID of the Popless Equalizer single band frequency parameter
- * used by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID
- * is used for set param only.
- */
-#define AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ                   0x000108C2
-/* ID of the Popless Equalizer band index parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
- */
-#define AUDPROC_PARAM_ID_EQ_BAND_INDEX                         0x000108C3
-/* ID of the Popless Equalizer preset id parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
- * for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_PRESET_ID                          0x000108C4
-/* ID of the Popless Equalizer number of presets parameter used
- * by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
- * for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_NUM_PRESETS                        0x000108C5
-/* ID of the Popless Equalizer preset name parameter used by
- * AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
- * for get param only.
- */
-#define AUDPROC_PARAM_ID_EQ_PRESET_NAME                        0x000108C6
-
-/* Set Q6 topologies */
-#define ASM_CMD_ADD_TOPOLOGIES				0x00010DBE
-#define ADM_CMD_ADD_TOPOLOGIES				0x00010335
-#define AFE_CMD_ADD_TOPOLOGIES				0x000100f8
-/* structure used for both ioctls */
-struct cmd_set_topologies {
-	struct apr_hdr hdr;
-	u32		payload_addr_lsw;
-	/* LSW of parameter data payload address.*/
-	u32		payload_addr_msw;
-	/* MSW of parameter data payload address.*/
-	u32		mem_map_handle;
-	/* Memory map handle returned by mem map command */
-	u32		payload_size;
-	/* Size in bytes of the variable payload in shared memory */
-} __packed;
-
-/* This module represents the Rx processing of Feedback speaker protection.
- * It contains the excursion control, thermal protection,
- * analog clip manager features in it.
- * This module id will support following param ids.
- * - AFE_PARAM_ID_FBSP_MODE_RX_CFG
- */
-
-#define AFE_MODULE_FB_SPKR_PROT_RX 0x0001021C
-#define AFE_MODULE_FB_SPKR_PROT_V2_RX 0x0001025F
-
-#define AFE_PARAM_ID_FBSP_MODE_RX_CFG 0x0001021D
-#define AFE_PARAM_ID_FBSP_PTONE_RAMP_CFG 0x00010260
-
-struct asm_fbsp_mode_rx_cfg {
-	uint32_t minor_version;
-	uint32_t mode;
-} __packed;
-
-/* This module represents the VI processing of feedback speaker protection.
- * It will receive Vsens and Isens from codec and generates necessary
- * parameters needed by Rx processing.
- * This module id will support following param ids.
- * - AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG
- * - AFE_PARAM_ID_CALIB_RES_CFG
- * - AFE_PARAM_ID_FEEDBACK_PATH_CFG
- */
-
-#define AFE_MODULE_FB_SPKR_PROT_VI_PROC 0x00010226
-#define AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2 0x0001026A
-
-#define AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG 0x0001022A
-#define AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2  0x0001026B
-
-struct asm_spkr_calib_vi_proc_cfg {
-	uint32_t minor_version;
-	uint32_t operation_mode;
-	uint32_t r0_t0_selection_flag[SP_V2_NUM_MAX_SPKR];
-	int32_t r0_cali_q24[SP_V2_NUM_MAX_SPKR];
-	int16_t	t0_cali_q6[SP_V2_NUM_MAX_SPKR];
-	uint32_t quick_calib_flag;
-} __packed;
-
-#define AFE_PARAM_ID_CALIB_RES_CFG 0x0001022B
-#define AFE_PARAM_ID_CALIB_RES_CFG_V2 0x0001026E
-
-struct asm_calib_res_cfg {
-	uint32_t minor_version;
-	int32_t	r0_cali_q24[SP_V2_NUM_MAX_SPKR];
-	uint32_t th_vi_ca_state;
-} __packed;
-
-#define AFE_PARAM_ID_FEEDBACK_PATH_CFG 0x0001022C
-#define AFE_MODULE_FEEDBACK 0x00010257
-
-struct asm_feedback_path_cfg {
-	uint32_t minor_version;
-	int32_t	dst_portid;
-	int32_t	num_channels;
-	int32_t	chan_info[4];
-} __packed;
-
-#define AFE_PARAM_ID_MODE_VI_PROC_CFG 0x00010227
-
-struct asm_mode_vi_proc_cfg {
-	uint32_t minor_version;
-	uint32_t cal_mode;
-} __packed;
-
-#define AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI	0x0001026A
-#define AFE_PARAM_ID_SP_V2_TH_VI_MODE_CFG	0x0001026B
-#define AFE_PARAM_ID_SP_V2_TH_VI_FTM_CFG	0x0001029F
-#define AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS	0x000102A0
-
-struct afe_sp_th_vi_mode_cfg {
-	uint32_t minor_version;
-	uint32_t operation_mode;
-	/*
-	 * Operation mode of thermal VI module.
-	 *   0 -- Normal Running mode
-	 *   1 -- Calibration mode
-	 *   2 -- FTM mode
-	 */
-	uint32_t r0t0_selection_flag[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Specifies which set of R0, T0 values the algorithm will use.
-	 * This field is valid only in Normal mode (operation_mode = 0).
-	 * 0 -- Use calibrated R0, T0 value
-	 * 1 -- Use safe R0, T0 value
-	 */
-	int32_t r0_cali_q24[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Calibration point resistance per device. This field is valid
-	 * only in Normal mode (operation_mode = 0).
-	 * values 33554432 to 1073741824 Ohms (in Q24 format)
-	 */
-	int16_t t0_cali_q6[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Calibration point temperature per device. This field is valid
-	 * in both Normal mode and Calibration mode.
-	 * values -1920 to 5120 degrees C (in Q6 format)
-	 */
-	uint32_t quick_calib_flag;
-	/*
-	 * Indicates whether calibration is to be done in quick mode or not.
-	 * This field is valid only in Calibration mode (operation_mode = 1).
-	 * 0 -- Disabled
-	 * 1 -- Enabled
-	 */
-} __packed;
-
-struct afe_sp_th_vi_ftm_cfg {
-	uint32_t minor_version;
-	uint32_t wait_time_ms[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Wait time to heat up speaker before collecting statistics
-	 * for ftm mode in ms.
-	 * values 0 to 4294967295 ms
-	 */
-	uint32_t ftm_time_ms[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * duration for which FTM statistics are collected in ms.
-	 * values 0 to 2000 ms
-	 */
-} __packed;
-
-struct afe_sp_th_vi_ftm_params {
-	uint32_t minor_version;
-	int32_t dc_res_q24[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * DC resistance value in q24 format
-	 * values 0 to 2147483647 Ohms (in Q24 format)
-	 */
-	int32_t temp_q22[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * temperature value in q22 format
-	 * values -125829120 to 2147483647 degC (in Q22 format)
-	 */
-	uint32_t status[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * FTM packet status
-	 * 0 - Incorrect operation mode.This status is returned
-	 *     when GET_PARAM is called in non FTM Mode
-	 * 1 - Inactive mode -- Port is not yet started.
-	 * 2 - Wait state. wait_time_ms has not yet elapsed
-	 * 3 - In progress state. ftm_time_ms has not yet elapsed.
-	 * 4 - Success.
-	 * 5 - Failed.
-	 */
-} __packed;
-
-struct afe_sp_th_vi_get_param {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_get_param_v2 get_param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_sp_th_vi_ftm_params param;
-} __packed;
-
-struct afe_sp_th_vi_get_param_resp {
-	uint32_t status;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_sp_th_vi_ftm_params param;
-} __packed;
-
-
-#define AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI	0x0001026F
-#define AFE_PARAM_ID_SP_V2_EX_VI_MODE_CFG	0x000102A1
-#define AFE_PARAM_ID_SP_V2_EX_VI_FTM_CFG	0x000102A2
-#define AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS	0x000102A3
-
-struct afe_sp_ex_vi_mode_cfg {
-	uint32_t minor_version;
-	uint32_t operation_mode;
-	/*
-	 * Operation mode of Excursion VI module.
-	 * 0 - Normal Running mode
-	 * 2 - FTM mode
-	 */
-} __packed;
-
-struct afe_sp_ex_vi_ftm_cfg {
-	uint32_t minor_version;
-	uint32_t wait_time_ms[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Wait time to heat up speaker before collecting statistics
-	 * for ftm mode in ms.
-	 * values 0 to 4294967295 ms
-	 */
-	uint32_t ftm_time_ms[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * duration for which FTM statistics are collected in ms.
-	 * values 0 to 2000 ms
-	 */
-} __packed;
-
-struct afe_sp_ex_vi_ftm_params {
-	uint32_t minor_version;
-	int32_t freq_q20[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Resonance frequency in q20 format
-	 * values 0 to 2147483647 Hz (in Q20 format)
-	 */
-	int32_t resis_q24[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Mechanical resistance in q24 format
-	 * values 0 to 2147483647 Ohms (in Q24 format)
-	 */
-	int32_t qmct_q24[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * Mechanical Qfactor in q24 format
-	 * values 0 to 2147483647 (in Q24 format)
-	 */
-	uint32_t status[SP_V2_NUM_MAX_SPKR];
-	/*
-	 * FTM packet status
-	 * 0 - Incorrect operation mode.This status is returned
-	 *      when GET_PARAM is called in non FTM Mode.
-	 * 1 - Inactive mode -- Port is not yet started.
-	 * 2 - Wait state. wait_time_ms has not yet elapsed
-	 * 3 - In progress state. ftm_time_ms has not yet elapsed.
-	 * 4 - Success.
-	 * 5 - Failed.
-	 */
-} __packed;
-
-struct afe_sp_ex_vi_get_param {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_get_param_v2 get_param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_sp_ex_vi_ftm_params param;
-} __packed;
-
-struct afe_sp_ex_vi_get_param_resp {
-	uint32_t status;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_sp_ex_vi_ftm_params param;
-} __packed;
-
-union afe_spkr_prot_config {
-	struct asm_fbsp_mode_rx_cfg mode_rx_cfg;
-	struct asm_spkr_calib_vi_proc_cfg vi_proc_cfg;
-	struct asm_feedback_path_cfg feedback_path_cfg;
-	struct asm_mode_vi_proc_cfg mode_vi_proc_cfg;
-	struct afe_sp_th_vi_mode_cfg th_vi_mode_cfg;
-	struct afe_sp_th_vi_ftm_cfg th_vi_ftm_cfg;
-	struct afe_sp_ex_vi_mode_cfg ex_vi_mode_cfg;
-	struct afe_sp_ex_vi_ftm_cfg ex_vi_ftm_cfg;
-} __packed;
-
-struct afe_spkr_prot_config_command {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2 pdata;
-	union afe_spkr_prot_config prot_config;
-} __packed;
-
-struct afe_spkr_prot_get_vi_calib {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_get_param_v2 get_param;
-	struct afe_port_param_data_v2 pdata;
-	struct asm_calib_res_cfg res_cfg;
-} __packed;
-
-struct afe_spkr_prot_calib_get_resp {
-	uint32_t status;
-	struct afe_port_param_data_v2 pdata;
-	struct asm_calib_res_cfg res_cfg;
-} __packed;
-
-
-/* SRS TRUMEDIA start */
-/* topology */
-#define SRS_TRUMEDIA_TOPOLOGY_ID			0x00010D90
-/* module */
-#define SRS_TRUMEDIA_MODULE_ID				0x10005010
-/* parameters */
-#define SRS_TRUMEDIA_PARAMS				0x10005011
-#define SRS_TRUMEDIA_PARAMS_WOWHD			0x10005012
-#define SRS_TRUMEDIA_PARAMS_CSHP			0x10005013
-#define SRS_TRUMEDIA_PARAMS_HPF				0x10005014
-#define SRS_TRUMEDIA_PARAMS_AEQ				0x10005015
-#define SRS_TRUMEDIA_PARAMS_HL				0x10005016
-#define SRS_TRUMEDIA_PARAMS_GEQ				0x10005017
-
-#define SRS_ID_GLOBAL	0x00000001
-#define SRS_ID_WOWHD	0x00000002
-#define SRS_ID_CSHP	0x00000003
-#define SRS_ID_HPF	0x00000004
-#define SRS_ID_AEQ	0x00000005
-#define SRS_ID_HL		0x00000006
-#define SRS_ID_GEQ	0x00000007
-
-#define SRS_CMD_UPLOAD		0x7FFF0000
-#define SRS_PARAM_OFFSET_MASK	0x3FFF0000
-#define SRS_PARAM_VALUE_MASK	0x0000FFFF
-
-struct srs_trumedia_params_GLOBAL {
-	uint8_t                  v1;
-	uint8_t                  v2;
-	uint8_t                  v3;
-	uint8_t                  v4;
-	uint8_t                  v5;
-	uint8_t                  v6;
-	uint8_t                  v7;
-	uint8_t                  v8;
-	uint16_t                 v9;
-} __packed;
-
-struct srs_trumedia_params_WOWHD {
-	uint32_t				v1;
-	uint16_t				v2;
-	uint16_t				v3;
-	uint16_t				v4;
-	uint16_t				v5;
-	uint16_t				v6;
-	uint16_t				v7;
-	uint16_t				v8;
-	uint16_t				v____A1;
-	uint32_t				v9;
-	uint16_t				v10;
-	uint16_t				v11;
-	uint32_t				v12[16];
-	uint32_t	v13[16];
-	uint32_t	v14[16];
-	uint32_t	v15[16];
-	uint32_t	v16;
-	uint16_t	v17;
-	uint16_t	v18;
-} __packed;
-
-struct srs_trumedia_params_CSHP {
-	uint32_t		v1;
-	uint16_t		v2;
-	uint16_t		v3;
-	uint16_t		v4;
-	uint16_t		v5;
-	uint16_t		v6;
-	uint16_t		v____A1;
-	uint32_t		v7;
-	uint16_t		v8;
-	uint16_t		v9;
-	uint32_t		v10[16];
-} __packed;
-
-struct srs_trumedia_params_HPF {
-	uint32_t		v1;
-	uint32_t		v2[26];
-} __packed;
-
-struct srs_trumedia_params_AEQ {
-	uint32_t		v1;
-	uint16_t		v2;
-	uint16_t		v3;
-	uint16_t		v4;
-	uint16_t		v____A1;
-	uint32_t	v5[74];
-	uint32_t	v6[74];
-	uint16_t	v7[2048];
-} __packed;
-
-struct srs_trumedia_params_HL {
-	uint16_t		v1;
-	uint16_t		v2;
-	uint16_t		v3;
-	uint16_t		v____A1;
-	int32_t			v4;
-	uint32_t		v5;
-	uint16_t		v6;
-	uint16_t		v____A2;
-	uint32_t		v7;
-} __packed;
-
-struct srs_trumedia_params_GEQ {
-	int16_t		v1[10];
-} __packed;
-struct srs_trumedia_params {
-	struct srs_trumedia_params_GLOBAL	global;
-	struct srs_trumedia_params_WOWHD	wowhd;
-	struct srs_trumedia_params_CSHP		cshp;
-	struct srs_trumedia_params_HPF		hpf;
-	struct srs_trumedia_params_AEQ		aeq;
-	struct srs_trumedia_params_HL		hl;
-	struct srs_trumedia_params_GEQ		geq;
-} __packed;
-/* SRS TruMedia end */
-
-#define AUDPROC_PARAM_ID_ENABLE		0x00010904
-#define ASM_STREAM_POSTPROC_TOPO_ID_SA_PLUS 0x1000FFFF
-/* DTS Eagle */
-#define AUDPROC_MODULE_ID_DTS_HPX_PREMIX 0x0001077C
-#define AUDPROC_MODULE_ID_DTS_HPX_POSTMIX 0x0001077B
-#define ASM_STREAM_POSTPROC_TOPO_ID_DTS_HPX 0x00010DED
-#define ASM_STREAM_POSTPROC_TOPO_ID_HPX_PLUS  0x10015000
-#define ASM_STREAM_POSTPROC_TOPO_ID_HPX_MASTER  0x10015001
-struct asm_dts_eagle_param {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_set_pp_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-} __packed;
-
-struct asm_dts_eagle_param_get {
-	struct apr_hdr	hdr;
-	struct asm_stream_cmd_get_pp_params_v2 param;
-} __packed;
-
-/* Opcode to set BT address and license for aptx decoder */
-#define APTX_DECODER_BT_ADDRESS 0x00013201
-#define APTX_CLASSIC_DEC_LICENSE_ID 0x00013202
-
-struct aptx_dec_bt_addr_cfg {
-	uint32_t lap;
-	uint32_t uap;
-	uint32_t nap;
-} __packed;
-
-struct aptx_dec_bt_dev_addr {
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_encdec_param encdec;
-	struct aptx_dec_bt_addr_cfg bt_addr_cfg;
-} __packed;
-
-struct asm_aptx_dec_fmt_blk_v2 {
-	struct apr_hdr hdr;
-	struct asm_data_cmd_media_fmt_update_v2 fmtblk;
-	u32     sample_rate;
-/* Number of samples per second.
- * Supported values: 44100 and 48000 Hz
- */
-} __packed;
-
-/* Q6Core Specific */
-#define AVCS_CMD_GET_FWK_VERSION (0x0001292C)
-#define AVCS_CMDRSP_GET_FWK_VERSION (0x0001292D)
-
-#define AVCS_SERVICE_ID_ALL (0xFFFFFFFF)
-#define APRV2_IDS_SERVICE_ID_ADSP_CVP_V	(0xB)
-
-struct avcs_get_fwk_version {
-	/*
-	 * Indicates the major version of the AVS build.
-	 * This value is incremented on chipset family boundaries.
-	 */
-	uint32_t build_major_version;
-
-	/*
-	 * Minor version of the AVS build.
-	 * This value represents the mainline to which the AVS build belongs.
-	 */
-	uint32_t build_minor_version;
-
-	/* Indicates the AVS branch version to which the image belongs. */
-	uint32_t build_branch_version;
-
-	/* Indicates the AVS sub-branch or customer product line information. */
-	uint32_t build_subbranch_version;
-
-	/* Number of supported AVS services in the current build. */
-	uint32_t num_services;
-};
-
-struct avs_svc_api_info {
-	/*
-	 * APRV2 service IDs for the individual static services.
-	 *
-	 *	 @values
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_CORE_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_AFE_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_ASM_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_ADM_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_MVM_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_CVS_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_CVP_V
-	 *	 - APRV2_IDS_SERVICE_ID_ADSP_LSM_V
-	 */
-	uint32_t service_id;
-
-	/*
-	 * Indicates the API version of the service.
-	 *
-	 * Each new API update that warrants a change on the HLOS side triggers
-	 * an increment in the version.
-	 */
-	uint32_t api_version;
-
-	/*
-	 * Indicates the API increments on a sub-branch (not on the mainline).
-	 *
-	 * API branch version numbers can increment independently on different
-	 * sub-branches.
-	 */
-	uint32_t api_branch_version;
-};
-
-struct avcs_fwk_ver_info {
-	struct avcs_get_fwk_version avcs_fwk_version;
-	struct avs_svc_api_info *services;
-} __packed;
-
-/* LSM Specific */
-#define VW_FEAT_DIM					(39)
-
-#define APRV2_IDS_SERVICE_ID_ADSP_LSM_V			(0xD)
-#define APRV2_IDS_DOMAIN_ID_ADSP_V			(0x4)
-#define APRV2_IDS_DOMAIN_ID_APPS_V			(0x5)
-
-#define LSM_SESSION_CMD_SHARED_MEM_MAP_REGIONS		(0x00012A7F)
-#define LSM_SESSION_CMDRSP_SHARED_MEM_MAP_REGIONS	(0x00012A80)
-#define LSM_SESSION_CMD_SHARED_MEM_UNMAP_REGIONS	(0x00012A81)
-#define LSM_SESSION_CMD_OPEN_TX				(0x00012A82)
-#define LSM_SESSION_CMD_CLOSE_TX			(0x00012A88)
-#define LSM_SESSION_CMD_SET_PARAMS			(0x00012A83)
-#define LSM_SESSION_CMD_SET_PARAMS_V2			(0x00012A8F)
-#define LSM_SESSION_CMD_REGISTER_SOUND_MODEL		(0x00012A84)
-#define LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL		(0x00012A85)
-#define LSM_SESSION_CMD_START				(0x00012A86)
-#define LSM_SESSION_CMD_STOP				(0x00012A87)
-#define LSM_SESSION_CMD_EOB				(0x00012A89)
-#define LSM_SESSION_CMD_READ				(0x00012A8A)
-#define LSM_SESSION_CMD_OPEN_TX_V2			(0x00012A8B)
-#define LSM_CMD_ADD_TOPOLOGIES				(0x00012A8C)
-
-#define LSM_SESSION_EVENT_DETECTION_STATUS		(0x00012B00)
-#define LSM_SESSION_EVENT_DETECTION_STATUS_V2		(0x00012B01)
-#define LSM_DATA_EVENT_READ_DONE			(0x00012B02)
-#define LSM_DATA_EVENT_STATUS				(0x00012B03)
-#define LSM_SESSION_EVENT_DETECTION_STATUS_V3		(0x00012B04)
-
-#define LSM_MODULE_ID_VOICE_WAKEUP			(0x00012C00)
-#define LSM_PARAM_ID_ENDPOINT_DETECT_THRESHOLD		(0x00012C01)
-#define LSM_PARAM_ID_OPERATION_MODE			(0x00012C02)
-#define LSM_PARAM_ID_GAIN				(0x00012C03)
-#define LSM_PARAM_ID_CONNECT_TO_PORT			(0x00012C04)
-#define LSM_PARAM_ID_FEATURE_COMPENSATION_DATA		(0x00012C07)
-#define LSM_PARAM_ID_MIN_CONFIDENCE_LEVELS		(0x00012C07)
-#define LSM_MODULE_ID_LAB				(0x00012C08)
-#define LSM_PARAM_ID_LAB_ENABLE				(0x00012C09)
-#define LSM_PARAM_ID_LAB_CONFIG				(0x00012C0A)
-#define LSM_MODULE_ID_FRAMEWORK				(0x00012C0E)
-#define LSM_PARAM_ID_SWMAD_CFG				(0x00012C18)
-#define LSM_PARAM_ID_SWMAD_MODEL			(0x00012C19)
-#define LSM_PARAM_ID_SWMAD_ENABLE			(0x00012C1A)
-#define LSM_PARAM_ID_POLLING_ENABLE			(0x00012C1B)
-#define LSM_PARAM_ID_MEDIA_FMT				(0x00012C1E)
-#define LSM_PARAM_ID_FWK_MODE_CONFIG			(0x00012C27)
-
-/* HW MAD specific */
-#define AFE_MODULE_HW_MAD				(0x00010230)
-#define AFE_PARAM_ID_HW_MAD_CFG				(0x00010231)
-#define AFE_PARAM_ID_HW_MAD_CTRL			(0x00010232)
-#define AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG		(0x00010233)
-
-/* SW MAD specific */
-#define AFE_MODULE_SW_MAD				(0x0001022D)
-#define AFE_PARAM_ID_SW_MAD_CFG				(0x0001022E)
-#define AFE_PARAM_ID_SVM_MODEL				(0x0001022F)
-
-/* Commands/Params to pass the codec/slimbus data to DSP */
-#define AFE_SVC_CMD_SET_PARAM				(0x000100f3)
-#define AFE_MODULE_CDC_DEV_CFG				(0x00010234)
-#define AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG		(0x00010235)
-#define AFE_PARAM_ID_CDC_REG_CFG			(0x00010236)
-#define AFE_PARAM_ID_CDC_REG_CFG_INIT			(0x00010237)
-#define AFE_PARAM_ID_CDC_REG_PAGE_CFG                   (0x00010296)
-
-#define AFE_MAX_CDC_REGISTERS_TO_CONFIG			(20)
-
-/* AANC Port Config Specific */
-#define AFE_PARAM_ID_AANC_PORT_CONFIG			(0x00010215)
-#define AFE_API_VERSION_AANC_PORT_CONFIG		(0x1)
-#define AANC_TX_MIC_UNUSED				(0)
-#define AANC_TX_VOICE_MIC				(1)
-#define AANC_TX_ERROR_MIC				(2)
-#define AANC_TX_NOISE_MIC				(3)
-#define AFE_PORT_MAX_CHANNEL_CNT			(8)
-#define AFE_MODULE_AANC					(0x00010214)
-#define AFE_PARAM_ID_CDC_AANC_VERSION			(0x0001023A)
-#define AFE_API_VERSION_CDC_AANC_VERSION		(0x1)
-#define AANC_HW_BLOCK_VERSION_1				(1)
-#define AANC_HW_BLOCK_VERSION_2				(2)
-
-/*Clip bank selection*/
-#define AFE_API_VERSION_CLIP_BANK_SEL_CFG 0x1
-#define AFE_CLIP_MAX_BANKS		4
-#define AFE_PARAM_ID_CLIP_BANK_SEL_CFG 0x00010242
-
-struct afe_param_aanc_port_cfg {
-	/* Minor version used for tracking the version of the module's
-	 * source port configuration.
-	 */
-	uint32_t aanc_port_cfg_minor_version;
-
-	/* Sampling rate of the source Tx port. 8k - 192k*/
-	uint32_t tx_port_sample_rate;
-
-	/* Channel mapping for the Tx port signal carrying Noise (X),
-	 * Error (E), and Voice (V) signals.
-	 */
-	uint8_t tx_port_channel_map[AFE_PORT_MAX_CHANNEL_CNT];
-
-	/* Number of channels on the source Tx port. */
-	uint16_t tx_port_num_channels;
-
-	/* Port ID of the Rx path reference signal. */
-	uint16_t rx_path_ref_port_id;
-
-	/* Sampling rate of the reference port. 8k - 192k*/
-	uint32_t ref_port_sample_rate;
-} __packed;
-
-struct afe_param_id_cdc_aanc_version {
-	/* Minor version used for tracking the version of the module's
-	 * hw version
-	 */
-	uint32_t cdc_aanc_minor_version;
-
-	/* HW version. */
-	uint32_t aanc_hw_version;
-} __packed;
-
-struct afe_param_id_clip_bank_sel {
-	/* Minor version used for tracking the version of the module's
-	 * hw version
-	 */
-	uint32_t minor_version;
-
-	/* Number of banks to be read */
-	uint32_t num_banks;
-
-	uint32_t bank_map[AFE_CLIP_MAX_BANKS];
-} __packed;
-
-/* ERROR CODES */
-/* Success. The operation completed with no errors. */
-#define ADSP_EOK          0x00000000
-/* General failure. */
-#define ADSP_EFAILED      0x00000001
-/* Bad operation parameter. */
-#define ADSP_EBADPARAM    0x00000002
-/* Unsupported routine or operation. */
-#define ADSP_EUNSUPPORTED 0x00000003
-/* Unsupported version. */
-#define ADSP_EVERSION     0x00000004
-/* Unexpected problem encountered. */
-#define ADSP_EUNEXPECTED  0x00000005
-/* Unhandled problem occurred. */
-#define ADSP_EPANIC       0x00000006
-/* Unable to allocate resource. */
-#define ADSP_ENORESOURCE  0x00000007
-/* Invalid handle. */
-#define ADSP_EHANDLE      0x00000008
-/* Operation is already processed. */
-#define ADSP_EALREADY     0x00000009
-/* Operation is not ready to be processed. */
-#define ADSP_ENOTREADY    0x0000000A
-/* Operation is pending completion. */
-#define ADSP_EPENDING     0x0000000B
-/* Operation could not be accepted or processed. */
-#define ADSP_EBUSY        0x0000000C
-/* Operation aborted due to an error. */
-#define ADSP_EABORTED     0x0000000D
-/* Operation preempted by a higher priority. */
-#define ADSP_EPREEMPTED   0x0000000E
-/* Operation requests intervention to complete. */
-#define ADSP_ECONTINUE    0x0000000F
-/* Operation requests immediate intervention to complete. */
-#define ADSP_EIMMEDIATE   0x00000010
-/* Operation is not implemented. */
-#define ADSP_ENOTIMPL     0x00000011
-/* Operation needs more data or resources. */
-#define ADSP_ENEEDMORE    0x00000012
-/* Operation does not have memory. */
-#define ADSP_ENOMEMORY    0x00000014
-/* Item does not exist. */
-#define ADSP_ENOTEXIST    0x00000015
-/* Max count for adsp error code sent to HLOS*/
-#define ADSP_ERR_MAX      (ADSP_ENOTEXIST + 1)
-/* Operation is finished. */
-#define ADSP_ETERMINATED    0x00011174
-
-/*bharath, adsp_error_codes.h */
-
-/* LPASS clock for I2S Interface */
-
-/* Supported OSR clock values */
-#define Q6AFE_LPASS_OSR_CLK_12_P288_MHZ		0xBB8000
-#define Q6AFE_LPASS_OSR_CLK_11_P2896_MHZ		0xAC4400
-#define Q6AFE_LPASS_OSR_CLK_9_P600_MHZ		0x927C00
-#define Q6AFE_LPASS_OSR_CLK_8_P192_MHZ		0x7D0000
-#define Q6AFE_LPASS_OSR_CLK_6_P144_MHZ		0x5DC000
-#define Q6AFE_LPASS_OSR_CLK_4_P096_MHZ		0x3E8000
-#define Q6AFE_LPASS_OSR_CLK_3_P072_MHZ		0x2EE000
-#define Q6AFE_LPASS_OSR_CLK_2_P048_MHZ		0x1F4000
-#define Q6AFE_LPASS_OSR_CLK_1_P536_MHZ		0x177000
-#define Q6AFE_LPASS_OSR_CLK_1_P024_MHZ		 0xFA000
-#define Q6AFE_LPASS_OSR_CLK_768_kHZ		 0xBB800
-#define Q6AFE_LPASS_OSR_CLK_512_kHZ		 0x7D000
-#define Q6AFE_LPASS_OSR_CLK_DISABLE		     0x0
-
-/* Supported Bit clock values */
-#define Q6AFE_LPASS_IBIT_CLK_12_P288_MHZ	0xBB8000
-#define Q6AFE_LPASS_IBIT_CLK_11_P2896_MHZ	0xAC4400
-#define Q6AFE_LPASS_IBIT_CLK_8_P192_MHZ		0x7D0000
-#define Q6AFE_LPASS_IBIT_CLK_6_P144_MHZ		0x5DC000
-#define Q6AFE_LPASS_IBIT_CLK_4_P096_MHZ		0x3E8000
-#define Q6AFE_LPASS_IBIT_CLK_3_P072_MHZ		0x2EE000
-#define Q6AFE_LPASS_IBIT_CLK_2_P8224_MHZ		0x2b1100
-#define Q6AFE_LPASS_IBIT_CLK_2_P048_MHZ		0x1F4000
-#define Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ		0x177000
-#define Q6AFE_LPASS_IBIT_CLK_1_P4112_MHZ		0x158880
-#define Q6AFE_LPASS_IBIT_CLK_1_P024_MHZ		 0xFA000
-#define Q6AFE_LPASS_IBIT_CLK_768_KHZ		 0xBB800
-#define Q6AFE_LPASS_IBIT_CLK_512_KHZ		 0x7D000
-#define Q6AFE_LPASS_IBIT_CLK_256_KHZ		 0x3E800
-#define Q6AFE_LPASS_IBIT_CLK_DISABLE		     0x0
-
-/* Supported LPASS CLK sources */
-#define Q6AFE_LPASS_CLK_SRC_EXTERNAL 0
-#define Q6AFE_LPASS_CLK_SRC_INTERNAL 1
-
-/* Supported LPASS CLK root*/
-#define Q6AFE_LPASS_CLK_ROOT_DEFAULT 0
-
-enum afe_lpass_clk_mode {
-	Q6AFE_LPASS_MODE_BOTH_INVALID,
-	Q6AFE_LPASS_MODE_CLK1_VALID,
-	Q6AFE_LPASS_MODE_CLK2_VALID,
-	Q6AFE_LPASS_MODE_BOTH_VALID,
-} __packed;
-
-/* Clock ID Enumeration Define. */
-/* Clock ID for Primary I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT                          0x100
-/* Clock ID for Primary I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT                          0x101
-/* Clock ID for Secondary I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT                          0x102
-/* Clock ID for Secondary I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT                          0x103
-/* Clock ID for Tertiary I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT                          0x104
-/* Clock ID for Tertiary I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT                          0x105
-/* Clock ID for Quartnery I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT                         0x106
-/* Clock ID for Quartnery I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT                         0x107
-/* Clock ID for Speaker I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_IBIT                       0x108
-/* Clock ID for Speaker I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_EBIT                       0x109
-/* Clock ID for Speaker I2S OSR */
-#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_OSR                        0x10A
-
-/* Clock ID for QUINARY  I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT			0x10B
-/* Clock ID for QUINARY  I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT			0x10C
-/* Clock ID for SENARY  I2S IBIT */
-#define Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT			0x10D
-/* Clock ID for SENARY  I2S EBIT */
-#define Q6AFE_LPASS_CLK_ID_SEN_MI2S_EBIT			0x10E
-/* Clock ID for INT0 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT                       0x10F
-/* Clock ID for INT1 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT1_MI2S_IBIT                       0x110
-/* Clock ID for INT2 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT2_MI2S_IBIT                       0x111
-/* Clock ID for INT3 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT                       0x112
-/* Clock ID for INT4 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT4_MI2S_IBIT                       0x113
-/* Clock ID for INT5 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT5_MI2S_IBIT                       0x114
-/* Clock ID for INT6 I2S IBIT  */
-#define Q6AFE_LPASS_CLK_ID_INT6_MI2S_IBIT                       0x115
-
-/* Clock ID for Primary PCM IBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT                           0x200
-/* Clock ID for Primary PCM EBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT                           0x201
-/* Clock ID for Secondary PCM IBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT                           0x202
-/* Clock ID for Secondary PCM EBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT                           0x203
-/* Clock ID for Tertiary PCM IBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT                           0x204
-/* Clock ID for Tertiary PCM EBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT                           0x205
-/* Clock ID for Quartery PCM IBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT                          0x206
-/* Clock ID for Quartery PCM EBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT                          0x207
-
-/** Clock ID for Primary TDM IBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT                           0x200
-/** Clock ID for Primary TDM EBIT */
-#define Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT                           0x201
-/** Clock ID for Secondary TDM IBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT                           0x202
-/** Clock ID for Secondary TDM EBIT */
-#define Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT                           0x203
-/** Clock ID for Tertiary TDM IBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT                           0x204
-/** Clock ID for Tertiary TDM EBIT */
-#define Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT                           0x205
-/** Clock ID for Quartery TDM IBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT                          0x206
-/** Clock ID for Quartery TDM EBIT */
-#define Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT                          0x207
-
-/* Clock ID for MCLK1 */
-#define Q6AFE_LPASS_CLK_ID_MCLK_1                                 0x300
-/* Clock ID for MCLK2 */
-#define Q6AFE_LPASS_CLK_ID_MCLK_2                                 0x301
-/* Clock ID for MCLK3 */
-#define Q6AFE_LPASS_CLK_ID_MCLK_3                                 0x302
-/* Clock ID for MCLK4 */
-#define Q6AFE_LPASS_CLK_ID_MCLK_4                                 0x304
-/* Clock ID for Internal Digital Codec Core */
-#define Q6AFE_LPASS_CLK_ID_INTERNAL_DIGITAL_CODEC_CORE            0x303
-/* Clock ID for INT MCLK0 */
-#define Q6AFE_LPASS_CLK_ID_INT_MCLK_0                             0x305
-/* Clock ID for INT MCLK1 */
-#define Q6AFE_LPASS_CLK_ID_INT_MCLK_1                             0x306
-/*
- * Clock ID for soundwire NPL.
- * This is the clock to be used to enable NPL clock for  internal Soundwire.
- */
-#define AFE_CLOCK_SET_CLOCK_ID_SWR_NPL_CLK                         0x307
-
-/* Clock ID for AHB HDMI input */
-#define Q6AFE_LPASS_CLK_ID_AHB_HDMI_INPUT                         0x400
-
-/* Clock ID for SPDIF core */
-#define Q6AFE_LPASS_CLK_ID_SPDIF_CORE                             0x500
-
-
-/* Clock attribute for invalid use (reserved for internal usage) */
-#define Q6AFE_LPASS_CLK_ATTRIBUTE_INVALID		0x0
-/* Clock attribute for no couple case */
-#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO		0x1
-/* Clock attribute for dividend couple case */
-#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVIDEND	0x2
-/* Clock attribute for divisor couple case */
-#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVISOR	0x3
-/* Clock attribute for invert and no couple case */
-#define Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO	0x4
-/* Clock set API version */
-#define Q6AFE_LPASS_CLK_CONFIG_API_VERSION		0x1
-
-struct afe_clk_set {
-	/*
-	 * Minor version used for tracking clock set.
-	 *	@values #AFE_API_VERSION_CLOCK_SET
-	 */
-	uint32_t clk_set_minor_version;
-
-	/*
-	 * Clock ID
-	 *	@values
-	 *	- 0x100 to 0x10A - MSM8996
-	 *	- 0x200 to 0x207 - MSM8996
-	 *	- 0x300 to 0x302 - MSM8996 @tablebulletend
-	 */
-	uint32_t clk_id;
-
-	/*
-	 * Clock frequency  (in Hertz) to be set.
-	 *	@values
-	 *	- >= 0 for clock frequency to set @tablebulletend
-	 */
-	uint32_t clk_freq_in_hz;
-
-	/* Use to specific divider for two clocks if needed.
-	 *	Set to Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO for no divider
-	 *	relation clocks
-	 *	@values
-	 *	- #Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO
-	 *	- #Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVIDEND
-	 *	- #Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVISOR @tablebulletend
-	 */
-	uint16_t clk_attri;
-
-	/*
-	 * Specifies the root clock source.
-	 *	Currently, only Q6AFE_LPASS_CLK_ROOT_DEFAULT is valid
-	 *	@values
-	 *	- 0 @tablebulletend
-	 */
-	uint16_t clk_root;
-
-	/*
-	 * for enable and disable clock.
-	 *	"clk_freq_in_hz", "clk_attri", and "clk_root"
-	 *	are ignored in disable clock case.
-	 *	@values 
-	 *	- 0 -- Disabled
-	 *	- 1 -- Enabled  @tablebulletend
-	 */
-	uint32_t enable;
-};
-
-struct afe_clk_cfg {
-/* Minor version used for tracking the version of the I2S
- * configuration interface.
- * Supported values: #AFE_API_VERSION_I2S_CONFIG
- */
-	u32                  i2s_cfg_minor_version;
-
-/* clk value 1 in MHz. */
-	u32                  clk_val1;
-
-/* clk value 2 in MHz. */
-	u32                  clk_val2;
-
-/* clk_src
- * #Q6AFE_LPASS_CLK_SRC_EXTERNAL
- * #Q6AFE_LPASS_CLK_SRC_INTERNAL
- */
-
-	u16                  clk_src;
-
-/* clk_root -0 for default */
-	u16                  clk_root;
-
-/* clk_set_mode
- * #Q6AFE_LPASS_MODE_BOTH_INVALID
- * #Q6AFE_LPASS_MODE_CLK1_VALID
- * #Q6AFE_LPASS_MODE_CLK2_VALID
- * #Q6AFE_LPASS_MODE_BOTH_VALID
- */
-	u16                  clk_set_mode;
-
-/* This param id is used to configure I2S clk */
-	u16                  reserved;
-} __packed;
-
-/* This param id is used to configure I2S clk */
-#define AFE_PARAM_ID_LPAIF_CLK_CONFIG	0x00010238
-#define AFE_MODULE_CLOCK_SET		0x0001028F
-#define AFE_PARAM_ID_CLOCK_SET		0x00010290
-
-struct afe_lpass_clk_config_command {
-	struct apr_hdr			 hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	struct afe_clk_cfg clk_cfg;
-} __packed;
-
-enum afe_lpass_digital_clk_src {
-	Q6AFE_LPASS_DIGITAL_ROOT_INVALID,
-	Q6AFE_LPASS_DIGITAL_ROOT_PRI_MI2S_OSR,
-	Q6AFE_LPASS_DIGITAL_ROOT_SEC_MI2S_OSR,
-	Q6AFE_LPASS_DIGITAL_ROOT_TER_MI2S_OSR,
-	Q6AFE_LPASS_DIGITAL_ROOT_QUAD_MI2S_OSR,
-	Q6AFE_LPASS_DIGITAL_ROOT_CDC_ROOT_CLK,
-} __packed;
-
-/* This param id is used to configure internal clk */
-#define AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG	0x00010239
-
-struct afe_digital_clk_cfg {
-/* Minor version used for tracking the version of the I2S
- * configuration interface.
- * Supported values: #AFE_API_VERSION_I2S_CONFIG
- */
-	u32                  i2s_cfg_minor_version;
-
-/* clk value in MHz. */
-	u32                  clk_val;
-
-/*	INVALID
- *	PRI_MI2S_OSR
- *	SEC_MI2S_OSR
- *	TER_MI2S_OSR
- *	QUAD_MI2S_OSR
- *	DIGT_CDC_ROOT
- */
-	u16                  clk_root;
-
-/* This field must be set to zero. */
-	u16                  reserved;
-} __packed;
-
-
-struct afe_lpass_digital_clk_config_command {
-	struct apr_hdr			 hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2    pdata;
-	struct afe_digital_clk_cfg clk_cfg;
-} __packed;
-
-/*
- * Opcode for AFE to start DTMF.
- */
-#define AFE_PORTS_CMD_DTMF_CTL	0x00010102
-
-/** DTMF payload.*/
-struct afe_dtmf_generation_command {
-	struct apr_hdr hdr;
-
-	/*
-	 * Duration of the DTMF tone in ms.
-	 * -1      -> continuous,
-	 *  0      -> disable
-	 */
-	int64_t                   duration_in_ms;
-
-	/*
-	 * The DTMF high tone frequency.
-	 */
-	uint16_t                  high_freq;
-
-	/*
-	 * The DTMF low tone frequency.
-	 */
-	uint16_t                  low_freq;
-
-	/*
-	 * The DTMF volume setting
-	 */
-	uint16_t                  gain;
-
-	/*
-	 * The number of ports to enable/disable on.
-	 */
-	uint16_t                  num_ports;
-
-	/*
-	 * The Destination ports - array  .
-	 * For DTMF on multiple ports, portIds needs to
-	 * be populated numPorts times.
-	 */
-	uint16_t                  port_ids;
-
-	/*
-	 * variable for 32 bit alignment of APR packet.
-	 */
-	uint16_t                  reserved;
-} __packed;
-
-enum afe_config_type {
-	AFE_SLIMBUS_SLAVE_PORT_CONFIG,
-	AFE_SLIMBUS_SLAVE_CONFIG,
-	AFE_CDC_REGISTERS_CONFIG,
-	AFE_AANC_VERSION,
-	AFE_CDC_CLIP_REGISTERS_CONFIG,
-	AFE_CLIP_BANK_SEL,
-	AFE_CDC_REGISTER_PAGE_CONFIG,
-	AFE_MAX_CONFIG_TYPES,
-};
-
-struct afe_param_slimbus_slave_port_cfg {
-	uint32_t minor_version;
-	uint16_t slimbus_dev_id;
-	uint16_t slave_dev_pgd_la;
-	uint16_t slave_dev_intfdev_la;
-	uint16_t bit_width;
-	uint16_t data_format;
-	uint16_t num_channels;
-	uint16_t slave_port_mapping[AFE_PORT_MAX_AUDIO_CHAN_CNT];
-} __packed;
-
-struct afe_param_cdc_slimbus_slave_cfg {
-	uint32_t minor_version;
-	uint32_t device_enum_addr_lsw;
-	uint32_t device_enum_addr_msw;
-	uint16_t tx_slave_port_offset;
-	uint16_t rx_slave_port_offset;
-} __packed;
-
-struct afe_param_cdc_reg_cfg {
-	uint32_t minor_version;
-	uint32_t reg_logical_addr;
-	uint32_t reg_field_type;
-	uint32_t reg_field_bit_mask;
-	uint16_t reg_bit_width;
-	uint16_t reg_offset_scale;
-} __packed;
-
-#define AFE_API_VERSION_CDC_REG_PAGE_CFG   1
-
-enum {
-	AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_0 = 0,
-	AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
-	AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_2,
-	AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_3,
-};
-
-struct afe_param_cdc_reg_page_cfg {
-	uint32_t minor_version;
-	uint32_t enable;
-	uint32_t proc_id;
-} __packed;
-
-struct afe_param_cdc_reg_cfg_data {
-	uint32_t num_registers;
-	struct afe_param_cdc_reg_cfg *reg_data;
-} __packed;
-
-struct afe_svc_cmd_set_param {
-	uint32_t payload_size;
-	uint32_t payload_address_lsw;
-	uint32_t payload_address_msw;
-	uint32_t mem_map_handle;
-} __packed;
-
-struct afe_svc_param_data {
-	uint32_t module_id;
-	uint32_t param_id;
-	uint16_t param_size;
-	uint16_t reserved;
-} __packed;
-
-struct afe_param_hw_mad_ctrl {
-	uint32_t minor_version;
-	uint16_t mad_type;
-	uint16_t mad_enable;
-} __packed;
-
-struct afe_cmd_hw_mad_ctrl {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_hw_mad_ctrl payload;
-} __packed;
-
-struct afe_cmd_hw_mad_slimbus_slave_port_cfg {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_slimbus_slave_port_cfg sb_port_cfg;
-} __packed;
-
-struct afe_cmd_sw_mad_enable {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2 pdata;
-} __packed;
-
-struct afe_param_cdc_reg_cfg_payload {
-	struct afe_svc_param_data     common;
-	struct afe_param_cdc_reg_cfg  reg_cfg;
-} __packed;
-
-struct afe_lpass_clk_config_command_v2 {
-	struct apr_hdr			hdr;
-	struct afe_svc_cmd_set_param	param;
-	struct afe_svc_param_data	pdata;
-	struct afe_clk_set		clk_cfg;
-} __packed;
-
-/*
- * reg_data's size can be up to AFE_MAX_CDC_REGISTERS_TO_CONFIG
- */
-struct afe_svc_cmd_cdc_reg_cfg {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_param_cdc_reg_cfg_payload reg_data[0];
-} __packed;
-
-struct afe_svc_cmd_init_cdc_reg_cfg {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 init;
-} __packed;
-
-struct afe_svc_cmd_sb_slave_cfg {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_cdc_slimbus_slave_cfg sb_slave_cfg;
-} __packed;
-
-struct afe_svc_cmd_cdc_reg_page_cfg {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_cdc_reg_page_cfg cdc_reg_page_cfg;
-} __packed;
-
-struct afe_svc_cmd_cdc_aanc_version {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_id_cdc_aanc_version version;
-} __packed;
-
-struct afe_port_cmd_set_aanc_param {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-	struct afe_port_param_data_v2 pdata;
-	union {
-		struct afe_param_aanc_port_cfg aanc_port_cfg;
-		struct afe_mod_enable_param    mod_enable;
-	} __packed data;
-} __packed;
-
-struct afe_port_cmd_set_aanc_acdb_table {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_set_param_v2 param;
-} __packed;
-
-/* Dolby DAP topology */
-#define DOLBY_ADM_COPP_TOPOLOGY_ID	0x0001033B
-#define DS2_ADM_COPP_TOPOLOGY_ID	0x1301033B
-
-/* RMS value from DSP */
-#define RMS_MODULEID_APPI_PASSTHRU  0x10009011
-#define RMS_PARAM_FIRST_SAMPLE 0x10009012
-#define RMS_PAYLOAD_LEN 4
-
-/* Customized mixing in matix mixer */
-#define MTMX_MODULE_ID_DEFAULT_CHMIXER  0x00010341
-#define DEFAULT_CHMIXER_PARAM_ID_COEFF  0x00010342
-#define CUSTOM_STEREO_PAYLOAD_SIZE	9
-#define CUSTOM_STEREO_CMD_PARAM_SIZE	24
-#define CUSTOM_STEREO_NUM_OUT_CH	0x0002
-#define CUSTOM_STEREO_NUM_IN_CH		0x0002
-#define CUSTOM_STEREO_INDEX_PARAM	0x0002
-#define Q14_GAIN_ZERO_POINT_FIVE	0x2000
-#define Q14_GAIN_UNITY			0x4000
-
-struct afe_svc_cmd_set_clip_bank_selection {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_id_clip_bank_sel bank_sel;
-} __packed;
-
-/* Ultrasound supported formats */
-#define US_POINT_EPOS_FORMAT_V2 0x0001272D
-#define US_RAW_FORMAT_V2        0x0001272C
-#define US_PROX_FORMAT_V4       0x0001273B
-#define US_RAW_SYNC_FORMAT      0x0001272F
-#define US_GES_SYNC_FORMAT      0x00012730
-
-#define AFE_MODULE_GROUP_DEVICE	0x00010254
-#define AFE_PARAM_ID_GROUP_DEVICE_CFG	0x00010255
-#define AFE_PARAM_ID_GROUP_DEVICE_ENABLE 0x00010256
-#define AFE_GROUP_DEVICE_ID_SECONDARY_MI2S_RX	0x1102
-
-/*  Payload of the #AFE_PARAM_ID_GROUP_DEVICE_CFG
- * parameter, which configures max of 8 AFE ports
- * into a group.
- * The fixed size of this structure is sixteen bytes.
- */
-struct afe_group_device_group_cfg {
-	u32 minor_version;
-	u16 group_id;
-	u16 num_channels;
-	u16 port_id[8];
-} __packed;
-
-#define AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX \
-	(AFE_PORT_ID_PRIMARY_TDM_RX + 0x100)
-#define AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX \
-	(AFE_PORT_ID_PRIMARY_TDM_TX + 0x100)
-#define AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX \
-	(AFE_PORT_ID_SECONDARY_TDM_RX + 0x100)
-#define AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX \
-	(AFE_PORT_ID_SECONDARY_TDM_TX + 0x100)
-#define AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX \
-	(AFE_PORT_ID_TERTIARY_TDM_RX + 0x100)
-#define AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX \
-	(AFE_PORT_ID_TERTIARY_TDM_TX + 0x100)
-#define AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX \
-	(AFE_PORT_ID_QUATERNARY_TDM_RX + 0x100)
-#define AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX \
-	(AFE_PORT_ID_QUATERNARY_TDM_TX + 0x100)
-
-/* ID of the parameter used by #AFE_MODULE_GROUP_DEVICE to configure the
- * group device. #AFE_SVC_CMD_SET_PARAM can use this parameter ID.
- *
- * Requirements:
- * - Configure the group before the member ports in the group are
- * configured and started.
- * - Enable the group only after it is configured.
- * - Stop all member ports in the group before disabling the group.
- */
-#define AFE_PARAM_ID_GROUP_DEVICE_TDM_CONFIG	0x0001029E
-
-/* Version information used to handle future additions to
- * AFE_PARAM_ID_GROUP_DEVICE_TDM_CONFIG processing (for backward compatibility).
- */
-#define AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG	0x1
-
-/* Number of AFE ports in group device  */
-#define AFE_GROUP_DEVICE_NUM_PORTS					8
-
-/* Payload of the AFE_PARAM_ID_GROUP_DEVICE_TDM_CONFIG parameter ID
- * used by AFE_MODULE_GROUP_DEVICE.
- */
-struct afe_param_id_group_device_tdm_cfg {
-	u32	group_device_cfg_minor_version;
-	/* Minor version used to track group device configuration.
-	 * @values #AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG
-	 */
-
-	u16	group_id;
-	/* ID for the group device.
-	 * @values
-	 * - #AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX
-	 * - #AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX
-	 * - #AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX
-	 * - #AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX
-	 * - #AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX
-	 * - #AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX
-	 * - #AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX
-	 * - #AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX
-	 */
-
-	u16	reserved;
-	/* 0 */
-
-	u16	port_id[AFE_GROUP_DEVICE_NUM_PORTS];
-	/* Array of member port IDs of this group.
-	 * @values
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_1
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_2
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_3
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_4
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_5
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_6
-	 * - #AFE_PORT_ID_PRIMARY_TDM_RX_7
-
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_1
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_2
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_3
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_4
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_5
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_6
-	 * - #AFE_PORT_ID_PRIMARY_TDM_TX_7
-
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_1
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_2
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_3
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_4
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_5
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_6
-	 * - #AFE_PORT_ID_SECONDARY_TDM_RX_7
-
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_1
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_2
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_3
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_4
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_5
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_6
-	 * - #AFE_PORT_ID_SECONDARY_TDM_TX_7
-
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_1
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_2
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_3
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_4
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_5
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_6
-	 * - #AFE_PORT_ID_TERTIARY_TDM_RX_7
-
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_1
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_2
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_3
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_4
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_5
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_6
-	 * - #AFE_PORT_ID_TERTIARY_TDM_TX_7
-
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_1
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_2
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_3
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_4
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_5
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_6
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_RX_7
-
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_1
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_2
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_3
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_4
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_5
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_6
-	 * - #AFE_PORT_ID_QUATERNARY_TDM_TX_7
-	 * @tablebulletend
-	 */
-
-	u32	num_channels;
-	/* Number of enabled slots for TDM frame.
-	 * @values 1 to 8
-	 */
-
-	u32	sample_rate;
-	/* Sampling rate of the port.
-	 * @values
-	 * - #AFE_PORT_SAMPLE_RATE_8K
-	 * - #AFE_PORT_SAMPLE_RATE_16K
-	 * - #AFE_PORT_SAMPLE_RATE_24K
-	 * - #AFE_PORT_SAMPLE_RATE_32K
-	 * - #AFE_PORT_SAMPLE_RATE_48K @tablebulletend
-	 */
-
-	u32	bit_width;
-	/* Bit width of the sample.
-	 * @values 16, 24, (32)
-	 */
-
-	u16	nslots_per_frame;
-	/* Number of slots per frame. Typical : 1, 2, 4, 8, 16, 32.
-	 * @values 1 - 32
-	 */
-
-	u16	slot_width;
-	/* Slot width of the slot in a TDM frame.  (slot_width >= bit_width)
-	 * have to be satisfied.
-	 * @values 16, 24, 32
-	 */
-
-	u32	slot_mask;
-	/* Position of active slots.  When that bit is set, that paricular
-	 * slot is active.
-	 * Number of active slots can be inferred by number of bits set in
-	 * the mask.  Only 8 individual bits can be enabled.
-	 * Bits 0..31 corresponding to slot 0..31
-	 * @values 1 to 2^32 -1
-	 */
-} __packed;
-
-/*  Payload of the #AFE_PARAM_ID_GROUP_DEVICE_ENABLE
- * parameter, which enables or
- * disables any module.
- * The fixed size of this structure is four bytes.
- */
-
-struct afe_group_device_enable {
-	u16 group_id;
-	/* valid value is AFE_GROUP_DEVICE_ID_SECONDARY_MI2S_RX */
-	u16 enable;
-	/* Enables (1) or disables (0) the module. */
-} __packed;
-
-union afe_port_group_config {
-	struct afe_group_device_group_cfg group_cfg;
-	struct afe_group_device_enable group_enable;
-	struct afe_param_id_group_device_tdm_cfg tdm_cfg;
-} __packed;
-
-struct afe_port_group_create {
-	struct apr_hdr hdr;
-	struct afe_svc_cmd_set_param param;
-	struct afe_port_param_data_v2 pdata;
-	union afe_port_group_config data;
-} __packed;
-
-/* ID of the parameter used by #AFE_MODULE_AUDIO_DEV_INTERFACE to specify
- * the timing statistics of the corresponding device interface.
- * Client can periodically query for the device time statistics to help adjust
- * the PLL based on the drift value. The get param command must be sent to
- * AFE port ID corresponding to device interface
-
- * This parameter ID supports following get param commands:
- * #AFE_PORT_CMD_GET_PARAM_V2 and
- * #AFE_PORT_CMD_GET_PARAM_V3.
- */
-#define AFE_PARAM_ID_DEV_TIMING_STATS           0x000102AD
-
-/* Version information used to handle future additions to AFE device
- * interface timing statistics (for backward compatibility).
- */
-#define AFE_API_VERSION_DEV_TIMING_STATS        0x1
-
-/* Enumeration for specifying a sink(Rx) device */
-#define AFE_SINK_DEVICE                         0x0
-
-/* Enumeration for specifying a source(Tx) device */
-#define AFE_SOURCE_DEVICE                       0x1
-
-/* Enumeration for specifying the drift reference is of type AV Timer */
-#define AFE_REF_TIMER_TYPE_AVTIMER              0x0
-
-/* Message payload structure for the
- * AFE_PARAM_ID_DEV_TIMING_STATS parameter.
- */
-struct afe_param_id_dev_timing_stats {
-	/* Minor version used to track the version of device interface timing
-	 * statistics. Currently, the supported version is 1.
-	 * @values #AFE_API_VERSION_DEV_TIMING_STATS
-	 */
-	u32       minor_version;
-
-	/* Indicates the device interface direction as either
-	 * source (Tx) or sink (Rx).
-	 * @values
-	 * #AFE_SINK_DEVICE
-	 * #AFE_SOURCE_DEVICE
-	 */
-	u16        device_direction;
-
-	/* Reference timer for drift accumulation and time stamp information.
-	 * @values
-	 * #AFE_REF_TIMER_TYPE_AVTIMER @tablebulletend
-	 */
-	u16        reference_timer;
-
-	/*
-	 * Flag to indicate if resync is required on the client side for
-	 * drift correction. Flag is set to TRUE for the first get_param
-	 * response after device interface starts. This flag value can be
-	 * used by client to identify if device interface restart has
-	 * happened and if any re-sync is required at their end for drift
-	 * correction.
-	 * @values
-	 * 0: FALSE (Resync not required)
-	 * 1: TRUE (Resync required) @tablebulletend
-	 */
-	u32        resync_flag;
-
-	/* Accumulated drift value in microseconds. This value is updated
-	 * every 100th ms.
-	 * Positive drift value indicates AV timer is running faster than device
-	 * Negative drift value indicates AV timer is running slower than device
-	 * @values Any valid int32 number
-	 */
-	s32         acc_drift_value;
-
-	/* Lower 32 bits of the 64-bit absolute timestamp of reference
-	 * timer in microseconds.
-
-	 * This timestamp corresponds to the time when the drift values
-	 * are accumlated for every 100th ms.
-	 * @values Any valid uint32 number
-	 */
-	u32        ref_timer_abs_ts_lsw;
-
-	/* Upper 32 bits of the 64-bit absolute timestamp of reference
-	 * timer in microseconds.
-	 * This timestamp corresponds to the time when the drift values
-	 * are accumlated for every 100th ms.
-	 * @values Any valid uint32 number
-	 */
-	u32        ref_timer_abs_ts_msw;
-} __packed;
-
-struct afe_av_dev_drift_get_param {
-	struct apr_hdr hdr;
-	struct afe_port_cmd_get_param_v2 get_param;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_id_dev_timing_stats timing_stats;
-} __packed;
-
-struct afe_av_dev_drift_get_param_resp {
-	uint32_t status;
-	struct afe_port_param_data_v2 pdata;
-	struct afe_param_id_dev_timing_stats timing_stats;
-} __packed;
-
-/* Command for Matrix or Stream Router */
-#define ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2    0x00010DCE
-/* Module for AVSYNC */
-#define ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC    0x00010DC6
-
-/* Parameter used by #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC to specify the
- * render window start value. This parameter is supported only for a Set
- * command (not a Get command) in the Rx direction
- * (#ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2).
- * Render window start is a value (session time minus timestamp, or ST-TS)
- * below which frames are held, and after which frames are immediately
- * rendered.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2 0x00010DD1
-
-/* Parameter used by #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC to specify the
- * render window end value. This parameter is supported only for a Set
- * command (not a Get command) in the Rx direction
- * (#ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2). Render window end is a value
- * (session time minus timestamp) above which frames are dropped, and below
- * which frames are immediately rendered.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2   0x00010DD2
-
-/* Generic payload of the window parameters in the
- * #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC module.
- * This payload is supported only for a Set command
- * (not a Get command) on the Rx path.
- */
-struct asm_session_mtmx_strtr_param_window_v2_t {
-	u32    window_lsw;
-	/* Lower 32 bits of the render window start value. */
-
-	u32    window_msw;
-	/* Upper 32 bits of the render window start value.
-	 *
-	 * The 64-bit number formed by window_lsw and window_msw specifies a
-	 * signed 64-bit window value in microseconds. The sign extension is
-	 * necessary. This value is used by the following parameter IDs:
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_STAT_WINDOW_START_V2
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_STAT_WINDOW_END_V2
-	 * The value depends on which parameter ID is used.
-	 * The aDSP honors the windows at a granularity of 1 ms.
-	 */
-};
-
-struct asm_session_cmd_set_mtmx_strstr_params_v2 {
-	uint32_t                  data_payload_addr_lsw;
-	/* Lower 32 bits of the 64-bit data payload address. */
-
-	uint32_t                  data_payload_addr_msw;
-	/* Upper 32 bits of the 64-bit data payload address.
-	 * If the address is not sent (NULL), the message is in the payload.
-	 * If the address is sent (non-NULL), the parameter data payloads
-	 * begin at the specified address.
-	 */
-
-	uint32_t                  mem_map_handle;
-	/* Unique identifier for an address. This memory map handle is returned
-	 * by the aDSP through the #ASM_CMD_SHARED_MEM_MAP_REGIONS command.
-	 * values
-	 * - NULL -- Parameter data payloads are within the message payload
-	 * (in-band).
-	 * - Non-NULL -- Parameter data payloads begin at the address specified
-	 * in the data_payload_addr_lsw and data_payload_addr_msw fields
-	 * (out-of-band).
-	 */
-
-	uint32_t                  data_payload_size;
-	/* Actual size of the variable payload accompanying the message, or in
-	 * shared memory. This field is used for parsing the parameter payload.
-	 * values > 0 bytes
-	 */
-
-	uint32_t                  direction;
-	/* Direction of the entity (matrix mixer or stream router) on which
-	 * the parameter is to be set.
-	 * values
-	 * - 0 -- Rx (for Rx stream router or Rx matrix mixer)
-	 * - 1 -- Tx (for Tx stream router or Tx matrix mixer)
-	 */
-};
-
-/* Parameter used by #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC which allows the
- * audio client choose the rendering decision that the audio DSP should use.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_RENDER_MODE_CMD  0x00012F0D
-
-/* Indicates that rendering decision will be based on default rate
- * (session clock based rendering, device driven).
- * 1. The default session clock based rendering is inherently driven
- *    by the timing of the device.
- * 2. After the initial decision is made (first buffer after a run
- *    command), subsequent data rendering decisions are made with
- *    respect to the rate at which the device is rendering, thus deriving
- *    its timing from the device.
- * 3. While this decision making is simple, it has some inherent limitations
- *    (mentioned in the next section).
- * 4. If this API is not set, the session clock based rendering will be assumed
- *    and this will ensure that the DSP is backward compatible.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_RENDER_DEFAULT 0
-
-/* Indicates that rendering decision will be based on local clock rate.
- * 1. In the DSP loopback/client loopback use cases (frame based
- *    inputs), the incoming data into audio DSP is time-stamped at the
- *    local clock rate (STC).
- * 2. This TS rate may match the incoming data rate or maybe different
- *    from the incoming data rate.
- * 3. Regardless, the data will be time-stamped with local STC and
- *    therefore, the client is recommended to set this mode for these
- *    use cases. This method is inherently more robust to sequencing
- *    (AFE Start/Stop) and device switches, among other benefits.
- * 4. This API will inform the DSP to compare every incoming buffer TS
- *    against local STC.
- * 5. DSP will continue to honor render windows APIs, as before.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_RENDER_LOCAL_STC 1
-
-/* Structure for rendering decision parameter */
-struct asm_session_mtmx_strtr_param_render_mode_t {
-	/* Specifies the type of rendering decision the audio DSP should use.
-	 *
-	 * @values
-	 * - #ASM_SESSION_MTMX_STRTR_PARAM_RENDER_DEFAULT
-	 * - #ASM_SESSION_MTMX_STRTR_PARAM_RENDER_LOCAL_STC
-	 */
-	u32                  flags;
-} __packed;
-
-/* Parameter used by #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC which allows the
- * audio client to specify the clock recovery mechanism that the audio DSP
- * should use.
- */
-
-#define ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_CMD 0x00012F0E
-
-/* Indicates that default clock recovery will be used (no clock recovery).
- * If the client wishes that no clock recovery be done, the client can
- * choose this. This means that no attempt will made by the DSP to try and
- * match the rates of the input and output audio.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_NONE 0
-
-/* Indicates that independent clock recovery needs to be used.
- * 1. In the DSP loopback/client loopback use cases (frame based inputs),
- *    the client should choose the independent clock recovery option.
- * 2. This basically de-couples the audio and video from knowing each others
- *    clock sources and lets the audio DSP independently rate match the input
- *    and output rates.
- * 3. After drift detection, the drift correction is achieved by either pulling
- *    the PLLs (if applicable) or by stream to device rate matching
- *    (for PCM use cases) by comparing drift with respect to STC.
- * 4. For passthrough use cases, since the PLL pulling is the only option,
- *    a best effort will be made.
- *    If PLL pulling is not possible / available, the rendering will be
- *    done without rate matching.
- */
-#define ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_AUTO 1
-
-/* Payload of the #ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC parameter.
- */
-struct asm_session_mtmx_strtr_param_clk_rec_t {
-	/* Specifies the type of clock recovery that the audio DSP should
-	 * use for rate matching.
-	 */
-
-	/* @values
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_DEFAULT
-	 * #ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_INDEPENDENT
-	 */
-	u32                  flags;
-} __packed;
-
-
-/* Parameter used by #ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC to
- * realize smoother adjustment of audio session clock for a specified session.
- * The desired audio session clock adjustment(in micro seconds) is specified
- * using the command #ASM_SESSION_CMD_ADJUST_SESSION_CLOCK_V2.
- * Delaying/Advancing the session clock would be implemented by inserting
- * interpolated/dropping audio samples in the playback path respectively.
- * Also, this parameter has to be configured before the Audio Session is put
- * to RUN state to avoid cold start latency/glitches in the playback.
- */
-
-#define ASM_SESSION_MTMX_PARAM_ADJUST_SESSION_TIME_CTL         0x00013217
-
-struct asm_session_mtmx_param_adjust_session_time_ctl_t {
-	/* Specifies whether the module is enabled or not
-	 * @values
-	 * 0 -- disabled
-	 * 1 -- enabled
-	 */
-	u32                 enable;
-};
-
-union asm_session_mtmx_strtr_param_config {
-	struct asm_session_mtmx_strtr_param_window_v2_t window_param;
-	struct asm_session_mtmx_strtr_param_render_mode_t render_param;
-	struct asm_session_mtmx_strtr_param_clk_rec_t clk_rec_param;
-	struct asm_session_mtmx_param_adjust_session_time_ctl_t adj_time_param;
-} __packed;
-
-struct asm_mtmx_strtr_params {
-	struct apr_hdr  hdr;
-	struct asm_session_cmd_set_mtmx_strstr_params_v2 param;
-	struct asm_stream_param_data_v2 data;
-	union asm_session_mtmx_strtr_param_config config;
-} __packed;
-
-#define ASM_SESSION_CMD_GET_MTMX_STRTR_PARAMS_V2 0x00010DCF
-#define ASM_SESSION_CMDRSP_GET_MTMX_STRTR_PARAMS_V2 0x00010DD0
-
-#define ASM_SESSION_MTMX_STRTR_PARAM_SESSION_TIME_V3 0x00012F0B
-#define ASM_SESSION_MTMX_STRTR_PARAM_STIME_TSTMP_FLG_BMASK (0x80000000UL)
-
-struct asm_session_cmd_get_mtmx_strstr_params_v2 {
-	uint32_t                  data_payload_addr_lsw;
-	/* Lower 32 bits of the 64-bit data payload address. */
-
-	uint32_t                  data_payload_addr_msw;
-	/*
-	 * Upper 32 bits of the 64-bit data payload address.
-	 * If the address is not sent (NULL), the message is in the payload.
-	 * If the address is sent (non-NULL), the parameter data payloads
-	 * begin at the specified address.
-	 */
-
-	uint32_t                  mem_map_handle;
-	/*
-	 * Unique identifier for an address. This memory map handle is returned
-	 * by the aDSP through the #ASM_CMD_SHARED_MEM_MAP_REGIONS command.
-	 * values
-	 * - NULL -- Parameter data payloads are within the message payload
-	 * (in-band).
-	 * - Non-NULL -- Parameter data payloads begin at the address specified
-	 * in the data_payload_addr_lsw and data_payload_addr_msw fields
-	 * (out-of-band).
-	 */
-	uint32_t                  direction;
-	/*
-	 * Direction of the entity (matrix mixer or stream router) on which
-	 * the parameter is to be set.
-	 * values
-	 * - 0 -- Rx (for Rx stream router or Rx matrix mixer)
-	 * - 1 -- Tx (for Tx stream router or Tx matrix mixer)
-	 */
-	uint32_t                  module_id;
-	/* Unique module ID. */
-
-	uint32_t                  param_id;
-	/* Unique parameter ID. */
-
-	uint32_t                  param_max_size;
-};
-
-struct asm_session_mtmx_strtr_param_session_time_v3_t {
-	uint32_t                  session_time_lsw;
-	/* Lower 32 bits of the current session time in microseconds */
-
-	uint32_t                  session_time_msw;
-	/*
-	 * Upper 32 bits of the current session time in microseconds.
-	 * The 64-bit number formed by session_time_lsw and session_time_msw
-	 * is treated as signed.
-	 */
-
-	uint32_t                  absolute_time_lsw;
-	/*
-	 * Lower 32 bits of the 64-bit absolute time in microseconds.
-	 * This is the time when the sample corresponding to the
-	 * session_time_lsw is rendered to the hardware. This absolute
-	 * time can be slightly in the future or past.
-	 */
-
-	uint32_t                  absolute_time_msw;
-	/*
-	 * Upper 32 bits of the 64-bit absolute time in microseconds.
-	 * This is the time when the sample corresponding to the
-	 * session_time_msw is rendered to hardware. This absolute
-	 * time can be slightly in the future or past. The 64-bit number
-	 * formed by absolute_time_lsw and absolute_time_msw is treated as
-	 * unsigned.
-	 */
-
-	uint32_t                  time_stamp_lsw;
-	/* Lower 32 bits of the last processed timestamp in microseconds */
-
-	uint32_t                  time_stamp_msw;
-	/*
-	 * Upper 32 bits of the last processed timestamp in microseconds.
-	 * The 64-bit number formed by time_stamp_lsw and time_stamp_lsw
-	 * is treated as unsigned.
-	 */
-
-	uint32_t                  flags;
-	/*
-	 * Keeps track of any additional flags needed.
-	 * @values{for bit 31}
-	 * - 0 -- Uninitialized/invalid
-	 * - 1 -- Valid
-	 * All other bits are reserved; clients must set them to zero.
-	 */
-};
-
-union asm_session_mtmx_strtr_data_type {
-	struct asm_session_mtmx_strtr_param_session_time_v3_t session_time;
-};
-
-struct asm_mtmx_strtr_get_params {
-	struct apr_hdr hdr;
-	struct asm_session_cmd_get_mtmx_strstr_params_v2 param_info;
-} __packed;
-
-struct asm_mtmx_strtr_get_params_cmdrsp {
-	uint32_t err_code;
-	struct asm_stream_param_data_v2 param_info;
-	union asm_session_mtmx_strtr_data_type param_data;
-} __packed;
-
-#define AUDPROC_MODULE_ID_RESAMPLER 0x00010719
-
-enum {
-	LEGACY_PCM = 0,
-	COMPRESSED_PASSTHROUGH,
-	COMPRESSED_PASSTHROUGH_CONVERT,
-	COMPRESSED_PASSTHROUGH_DSD,
-	LISTEN,
-	COMPRESSED_PASSTHROUGH_GEN,
-	COMPRESSED_PASSTHROUGH_IEC61937
-};
-
-#define AUDPROC_MODULE_ID_COMPRESSED_MUTE                0x00010770
-#define AUDPROC_PARAM_ID_COMPRESSED_MUTE                 0x00010771
-
-struct adm_set_compressed_device_mute {
-	struct adm_cmd_set_pp_params_v5 command;
-	struct adm_param_data_v5 params;
-	u32    mute_on;
-} __packed;
-
-#define AUDPROC_MODULE_ID_COMPRESSED_LATENCY             0x0001076E
-#define AUDPROC_PARAM_ID_COMPRESSED_LATENCY              0x0001076F
-
-struct adm_set_compressed_device_latency {
-	struct adm_cmd_set_pp_params_v5 command;
-	struct adm_param_data_v5 params;
-	u32    latency;
-} __packed;
-
-#define VOICEPROC_MODULE_ID_GENERIC_TX                      0x00010EF6
-#define VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS               0x00010E37
-#define VOICEPROC_PARAM_ID_FLUENCE_SOURCETRACKING           0x00010E38
-#define MAX_SECTORS                                         8
-#define MAX_NOISE_SOURCE_INDICATORS                         3
-#define MAX_POLAR_ACTIVITY_INDICATORS                       360
-
-struct sound_focus_param {
-	uint16_t start_angle[MAX_SECTORS];
-	uint8_t enable[MAX_SECTORS];
-	uint16_t gain_step;
-} __packed;
-
-struct source_tracking_param {
-	uint8_t vad[MAX_SECTORS];
-	uint16_t doa_speech;
-	uint16_t doa_noise[MAX_NOISE_SOURCE_INDICATORS];
-	uint8_t polar_activity[MAX_POLAR_ACTIVITY_INDICATORS];
-} __packed;
-
-struct adm_param_fluence_soundfocus_t {
-	uint16_t start_angles[MAX_SECTORS];
-	uint8_t enables[MAX_SECTORS];
-	uint16_t gain_step;
-	uint16_t reserved;
-} __packed;
-
-struct adm_set_fluence_soundfocus_param {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-	struct adm_param_fluence_soundfocus_t soundfocus_data;
-} __packed;
-
-struct adm_param_fluence_sourcetracking_t {
-	uint8_t vad[MAX_SECTORS];
-	uint16_t doa_speech;
-	uint16_t doa_noise[MAX_NOISE_SOURCE_INDICATORS];
-	uint8_t polar_activity[MAX_POLAR_ACTIVITY_INDICATORS];
-} __packed;
-
-#define AUDPROC_MODULE_ID_AUDIOSPHERE               0x00010916
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE         0x00010917
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH       0x00010918
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_CONFIG_MODE    0x00010919
-
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_COEFFS_STEREO_INPUT         0x0001091A
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_COEFFS_MULTICHANNEL_INPUT   0x0001091B
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_DESIGN_STEREO_INPUT         0x0001091C
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_DESIGN_MULTICHANNEL_INPUT   0x0001091D
-
-#define AUDPROC_PARAM_ID_AUDIOSPHERE_OPERATING_INPUT_MEDIA_INFO  0x0001091E
-
-#define AUDPROC_MODULE_ID_VOICE_TX_SECNS   0x10027059
-#define AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH 0x10014444
-
-struct admx_sec_primary_mic_ch {
-	uint16_t version;
-	uint16_t reserved;
-	uint16_t sec_primary_mic_ch;
-	uint16_t reserved1;
-} __packed;
-
-
-struct adm_set_sec_primary_ch_params {
-	struct adm_cmd_set_pp_params_v5 params;
-	struct adm_param_data_v5 data;
-	struct admx_sec_primary_mic_ch sec_primary_mic_ch_data;
-} __packed;
-#endif /*_APR_AUDIO_V2_H_ */
diff --git a/include/sound/apr_audio.h b/include/sound/apr_audio.h
deleted file mode 100644
index 795ff56..0000000
--- a/include/sound/apr_audio.h
+++ /dev/null
@@ -1,1931 +0,0 @@
-/*
- *
- * Copyright (c) 2010-2013, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _APR_AUDIO_H_
-#define _APR_AUDIO_H_
-
-/* ASM opcodes without APR payloads*/
-#include <linux/qdsp6v2/apr.h>
-
-/*
- * Audio Front End (AFE)
- */
-
-/* Port ID. Update afe_get_port_index when a new port is added here. */
-#define PRIMARY_I2S_RX 0		/* index = 0 */
-#define PRIMARY_I2S_TX 1		/* index = 1 */
-#define PCM_RX 2			/* index = 2 */
-#define PCM_TX 3			/* index = 3 */
-#define SECONDARY_I2S_RX 4		/* index = 4 */
-#define SECONDARY_I2S_TX 5		/* index = 5 */
-#define MI2S_RX 6			/* index = 6 */
-#define MI2S_TX 7			/* index = 7 */
-#define HDMI_RX 8			/* index = 8 */
-#define RSVD_2 9			/* index = 9 */
-#define RSVD_3 10			/* index = 10 */
-#define DIGI_MIC_TX 11			/* index = 11 */
-#define VOICE_RECORD_RX 0x8003		/* index = 12 */
-#define VOICE_RECORD_TX 0x8004		/* index = 13 */
-#define VOICE_PLAYBACK_TX 0x8005	/* index = 14 */
-
-/* Slimbus Multi channel port id pool  */
-#define SLIMBUS_0_RX		0x4000		/* index = 15 */
-#define SLIMBUS_0_TX		0x4001		/* index = 16 */
-#define SLIMBUS_1_RX		0x4002		/* index = 17 */
-#define SLIMBUS_1_TX		0x4003		/* index = 18 */
-#define SLIMBUS_2_RX		0x4004
-#define SLIMBUS_2_TX		0x4005
-#define SLIMBUS_3_RX		0x4006
-#define SLIMBUS_3_TX		0x4007
-#define SLIMBUS_4_RX		0x4008
-#define SLIMBUS_4_TX		0x4009		/* index = 24 */
-
-#define INT_BT_SCO_RX 0x3000		/* index = 25 */
-#define INT_BT_SCO_TX 0x3001		/* index = 26 */
-#define INT_BT_A2DP_RX 0x3002		/* index = 27 */
-#define INT_FM_RX 0x3004		/* index = 28 */
-#define INT_FM_TX 0x3005		/* index = 29 */
-#define RT_PROXY_PORT_001_RX	0x2000    /* index = 30 */
-#define RT_PROXY_PORT_001_TX	0x2001    /* index = 31 */
-#define SECONDARY_PCM_RX 12			/* index = 32 */
-#define SECONDARY_PCM_TX 13			/* index = 33 */
-#define PSEUDOPORT_01           0x8001    /* index =34 */
-
-#define AFE_PORT_INVALID 0xFFFF
-#define SLIMBUS_EXTPROC_RX AFE_PORT_INVALID
-
-#define AFE_PORT_CMD_START 0x000100ca
-
-#define AFE_EVENT_RTPORT_START 0
-#define AFE_EVENT_RTPORT_STOP 1
-#define AFE_EVENT_RTPORT_LOW_WM 2
-#define AFE_EVENT_RTPORT_HI_WM 3
-
-struct afe_port_start_command {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 gain;		/* Q13 */
-	u32 sample_rate;	/* 8 , 16, 48khz */
-} __packed;
-
-#define AFE_PORT_CMD_STOP 0x000100cb
-struct afe_port_stop_command {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 reserved;
-} __packed;
-
-#define AFE_PORT_CMD_APPLY_GAIN 0x000100cc
-struct afe_port_gain_command {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16	gain;/* Q13 */
-} __packed;
-
-#define AFE_PORT_CMD_SIDETONE_CTL 0x000100cd
-struct afe_port_sidetone_command {
-	struct apr_hdr hdr;
-	u16 rx_port_id;		/* Primary i2s tx = 1 */
-				/* PCM tx = 3 */
-				/* Secondary i2s tx = 5 */
-				/* Mi2s tx = 7 */
-				/* Digital mic tx = 11 */
-	u16 tx_port_id;		/* Primary i2s rx = 0 */
-				/* PCM rx = 2 */
-				/* Secondary i2s rx = 4 */
-				/* Mi2S rx = 6 */
-				/* HDMI rx = 8 */
-	u16 gain;		/* Q13 */
-	u16 enable;		/* 1 = enable, 0 = disable */
-} __packed;
-
-#define AFE_PORT_CMD_LOOPBACK 0x000100ce
-struct afe_loopback_command {
-	struct apr_hdr hdr;
-	u16 tx_port_id;		/* Primary i2s rx = 0 */
-				/* PCM rx = 2 */
-				/* Secondary i2s rx = 4 */
-				/* Mi2S rx = 6 */
-				/* HDMI rx = 8 */
-	u16 rx_port_id;		/* Primary i2s tx = 1 */
-				/* PCM tx = 3 */
-				/* Secondary i2s tx = 5 */
-				/* Mi2s tx = 7 */
-				/* Digital mic tx = 11 */
-	u16 mode;		/* Default -1, DSP will conver
-				 * the tx to rx format
-				 */
-	u16 enable;		/* 1 = enable, 0 = disable */
-} __packed;
-
-#define AFE_PSEUDOPORT_CMD_START 0x000100cf
-struct afe_pseudoport_start_command {
-	struct apr_hdr hdr;
-	u16 port_id;		/* Pseudo Port 1 = 0x8000 */
-				/* Pseudo Port 2 = 0x8001 */
-				/* Pseudo Port 3 = 0x8002 */
-	u16 timing;		/* FTRT = 0 , AVTimer = 1, */
-} __packed;
-
-#define AFE_PSEUDOPORT_CMD_STOP 0x000100d0
-struct afe_pseudoport_stop_command {
-	struct apr_hdr hdr;
-	u16 port_id;		/* Pseudo Port 1 = 0x8000 */
-				/* Pseudo Port 2 = 0x8001 */
-				/* Pseudo Port 3 = 0x8002 */
-	u16 reserved;
-} __packed;
-
-#define AFE_CMD_GET_ACTIVE_PORTS 0x000100d1
-
-
-#define AFE_CMD_GET_ACTIVE_HANDLES_FOR_PORT 0x000100d2
-struct afe_get_active_handles_command {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 reserved;
-} __packed;
-
-/*
- * Opcode for AFE to start DTMF.
- */
-#define AFE_PORTS_CMD_DTMF_CTL	0x00010102
-
-/** DTMF payload.*/
-struct afe_dtmf_generation_command {
-	struct apr_hdr hdr;
-
-	/*
-	 * Duration of the DTMF tone in ms.
-	 * -1      -> continuous,
-	 *  0      -> disable
-	 */
-	int64_t                   duration_in_ms;
-
-	/*
-	 * The DTMF high tone frequency.
-	 */
-	uint16_t                  high_freq;
-
-	/*
-	 * The DTMF low tone frequency.
-	 */
-	uint16_t                  low_freq;
-
-	/*
-	 * The DTMF volume setting
-	 */
-	uint16_t                  gain;
-
-	/*
-	 * The number of ports to enable/disable on.
-	 */
-	uint16_t                  num_ports;
-
-	/*
-	 * The Destination ports - array  .
-	 * For DTMF on multiple ports, portIds needs to
-	 * be populated numPorts times.
-	 */
-	uint16_t                  port_ids;
-
-	/*
-	 * variable for 32 bit alignment of APR packet.
-	 */
-	uint16_t                  reserved;
-} __packed;
-
-#define AFE_PCM_CFG_MODE_PCM			0x0
-#define AFE_PCM_CFG_MODE_AUX			0x1
-#define AFE_PCM_CFG_SYNC_EXT			0x0
-#define AFE_PCM_CFG_SYNC_INT			0x1
-#define AFE_PCM_CFG_FRM_8BPF			0x0
-#define AFE_PCM_CFG_FRM_16BPF			0x1
-#define AFE_PCM_CFG_FRM_32BPF			0x2
-#define AFE_PCM_CFG_FRM_64BPF			0x3
-#define AFE_PCM_CFG_FRM_128BPF			0x4
-#define AFE_PCM_CFG_FRM_256BPF			0x5
-#define AFE_PCM_CFG_QUANT_ALAW_NOPAD		0x0
-#define AFE_PCM_CFG_QUANT_MULAW_NOPAD		0x1
-#define AFE_PCM_CFG_QUANT_LINEAR_NOPAD		0x2
-#define AFE_PCM_CFG_QUANT_ALAW_PAD		0x3
-#define AFE_PCM_CFG_QUANT_MULAW_PAD		0x4
-#define AFE_PCM_CFG_QUANT_LINEAR_PAD		0x5
-#define AFE_PCM_CFG_CDATAOE_MASTER		0x0
-#define AFE_PCM_CFG_CDATAOE_SHARE		0x1
-
-struct afe_port_pcm_cfg {
-	u16	mode;	/* PCM (short sync) = 0, AUXPCM (long sync) = 1 */
-	u16	sync;	/* external = 0 , internal = 1 */
-	u16	frame;	/* 8 bpf = 0 */
-			/* 16 bpf = 1 */
-			/* 32 bpf = 2 */
-			/* 64 bpf = 3 */
-			/* 128 bpf = 4 */
-			/* 256 bpf = 5 */
-	u16     quant;
-	u16	slot;	/* Slot for PCM stream , 0 - 31 */
-	u16	data;	/* 0, PCM block is the only master */
-			/* 1, PCM block is shares to driver data out signal */
-			/*    other master                                  */
-	u16	reserved;
-} __packed;
-
-enum {
-	AFE_I2S_SD0 = 1,
-	AFE_I2S_SD1,
-	AFE_I2S_SD2,
-	AFE_I2S_SD3,
-	AFE_I2S_QUAD01,
-	AFE_I2S_QUAD23,
-	AFE_I2S_6CHS,
-	AFE_I2S_8CHS,
-};
-
-#define AFE_MI2S_MONO 0
-#define AFE_MI2S_STEREO 3
-#define AFE_MI2S_4CHANNELS 4
-#define AFE_MI2S_6CHANNELS 6
-#define AFE_MI2S_8CHANNELS 8
-
-struct afe_port_mi2s_cfg {
-	u16	bitwidth;	/* 16,24,32 */
-	u16	line;		/* Called ChannelMode in documentation */
-				/* i2s_sd0 = 1 */
-				/* i2s_sd1 = 2 */
-				/* i2s_sd2 = 3 */
-				/* i2s_sd3 = 4 */
-				/* i2s_quad01 = 5 */
-				/* i2s_quad23 = 6 */
-				/* i2s_6chs = 7 */
-				/* i2s_8chs = 8 */
-	u16	channel;	/* Called MonoStereo in documentation */
-				/* i2s mono = 0 */
-				/* i2s mono right = 1 */
-				/* i2s mono left = 2 */
-				/* i2s stereo = 3 */
-	u16	ws;		/* 0, word select signal from external source */
-				/* 1, word select signal from internal source */
-	u16	format;	/* don't touch this field if it is not for */
-				/* AFE_PORT_CMD_I2S_CONFIG opcode */
-} __packed;
-
-struct afe_port_hdmi_cfg {
-	u16	bitwidth;	/* 16,24,32 */
-	u16	channel_mode;	/* HDMI Stereo = 0 */
-				/* HDMI_3Point1 (4-ch) = 1 */
-				/* HDMI_5Point1 (6-ch) = 2 */
-				/* HDMI_6Point1 (8-ch) = 3 */
-	u16	data_type;	/* HDMI_Linear = 0 */
-				/* HDMI_non_Linear = 1 */
-} __packed;
-
-
-struct afe_port_hdmi_multi_ch_cfg {
-	u16	data_type;		/* HDMI_Linear = 0 */
-					/* HDMI_non_Linear = 1 */
-	u16	channel_allocation;	/* The default is 0 (Stereo) */
-	u16	reserved;		/* must be set to 0 */
-} __packed;
-
-
-/* Slimbus Device Ids */
-#define AFE_SLIMBUS_DEVICE_1		0x0
-#define AFE_SLIMBUS_DEVICE_2		0x1
-#define AFE_PORT_MAX_AUDIO_CHAN_CNT	16
-
-struct afe_port_slimbus_cfg {
-	u16	slimbus_dev_id;		/* SLIMBUS Device id.*/
-
-	u16	slave_dev_pgd_la;	/* Slave ported generic device
-					 * logical address.
-					 */
-	u16	slave_dev_intfdev_la;	/* Slave interface device logical
-					 * address.
-					 */
-	u16	bit_width;		/* bit width of the samples, 16, 24.*/
-
-	u16	data_format;		/* data format.*/
-
-	u16	num_channels;		/* Number of channels.*/
-
-	/* Slave port mapping for respective channels.*/
-	u16	slave_port_mapping[AFE_PORT_MAX_AUDIO_CHAN_CNT];
-
-	u16	reserved;
-} __packed;
-
-struct afe_port_slimbus_sch_cfg {
-	u16	slimbus_dev_id;		/* SLIMBUS Device id.*/
-	u16	bit_width;		/* bit width of the samples, 16, 24.*/
-	u16	data_format;		/* data format.*/
-	u16	num_channels;		/* Number of channels.*/
-	u16	reserved;
-	/* Slave channel  mapping for respective channels.*/
-	u8	slave_ch_mapping[8];
-} __packed;
-
-struct afe_port_rtproxy_cfg {
-	u16	bitwidth;	/* 16,24,32 */
-	u16	interleaved;    /* interleaved = 1 */
-				/* Noninterleaved = 0 */
-	u16	frame_sz;	/* 5ms buffers = 160bytes */
-	u16	jitter;		/* 10ms of jitter = 320 */
-	u16	lw_mark;	/* Low watermark in bytes for triggering event*/
-	u16	hw_mark;	/* High watermark bytes for triggering event*/
-	u16	rsvd;
-	int	num_ch;		/* 1 to 8 */
-} __packed;
-
-struct afe_port_pseudo_cfg {
-	u16 bit_width;
-	u16 num_channels;
-	u16 data_format;
-	u16 timing_mode;
-	u16 reserved;
-} __packed;
-
-#define AFE_PORT_AUDIO_IF_CONFIG 0x000100d3
-#define AFE_PORT_AUDIO_SLIM_SCH_CONFIG 0x000100e4
-#define AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG	0x000100D9
-#define AFE_PORT_CMD_I2S_CONFIG	0x000100E7
-
-union afe_port_config {
-	struct afe_port_pcm_cfg           pcm;
-	struct afe_port_mi2s_cfg          mi2s;
-	struct afe_port_hdmi_cfg          hdmi;
-	struct afe_port_hdmi_multi_ch_cfg hdmi_multi_ch;
-	struct afe_port_slimbus_cfg	  slimbus;
-	struct afe_port_slimbus_sch_cfg	  slim_sch;
-	struct afe_port_rtproxy_cfg       rtproxy;
-	struct afe_port_pseudo_cfg        pseudo;
-} __packed;
-
-struct afe_audioif_config_command {
-	struct apr_hdr hdr;
-	u16 port_id;
-	union afe_port_config port;
-} __packed;
-
-#define AFE_TEST_CODEC_LOOPBACK_CTL 0x000100d5
-struct afe_codec_loopback_command {
-	u16	port_inf;	/* Primary i2s = 0 */
-				/* PCM = 2 */
-				/* Secondary i2s = 4 */
-				/* Mi2s = 6 */
-	u16	enable;		/* 0, disable. 1, enable */
-} __packed;
-
-
-#define AFE_PARAM_ID_SIDETONE_GAIN	0x00010300
-struct afe_param_sidetone_gain {
-	u16 gain;
-	u16 reserved;
-} __packed;
-
-#define AFE_PARAM_ID_SAMPLING_RATE	0x00010301
-struct afe_param_sampling_rate {
-	u32 sampling_rate;
-} __packed;
-
-
-#define AFE_PARAM_ID_CHANNELS		0x00010302
-struct afe_param_channels {
-	u16 channels;
-	u16 reserved;
-} __packed;
-
-
-#define AFE_PARAM_ID_LOOPBACK_GAIN	0x00010303
-struct afe_param_loopback_gain {
-	u16 gain;
-	u16 reserved;
-} __packed;
-
-/* Parameter ID used to configure and enable/disable the loopback path. The
- * difference with respect to the existing API, AFE_PORT_CMD_LOOPBACK, is that
- * it allows Rx port to be configured as source port in loopback path. Port-id
- * in AFE_PORT_CMD_SET_PARAM cmd is the source port which can be Tx or Rx port.
- * In addition, we can configure the type of routing mode to handle different
- * use cases.
- */
-enum {
-	/* Regular loopback from source to destination port */
-	LB_MODE_DEFAULT = 1,
-	/* Sidetone feed from Tx source to Rx destination port */
-	LB_MODE_SIDETONE,
-	/* Echo canceller reference, voice + audio + DTMF */
-	LB_MODE_EC_REF_VOICE_AUDIO,
-	/* Echo canceller reference, voice alone */
-	LB_MODE_EC_REF_VOICE
-};
-
-#define AFE_PARAM_ID_LOOPBACK_CONFIG 0x0001020B
-#define AFE_API_VERSION_LOOPBACK_CONFIG 0x1
-struct afe_param_loopback_cfg {
-	/* Minor version used for tracking the version of the configuration
-	 * interface.
-	 */
-	uint32_t loopback_cfg_minor_version;
-
-	/* Destination Port Id. */
-	uint16_t dst_port_id;
-
-	/* Specifies data path type from src to dest port. Supported values:
-	 * LB_MODE_DEFAULT
-	 * LB_MODE_SIDETONE
-	 * LB_MODE_EC_REF_VOICE_AUDIO
-	 * LB_MODE_EC_REF_VOICE
-	 */
-	uint16_t routing_mode;
-
-	/* Specifies whether to enable (1) or disable (0) an AFE loopback. */
-	uint16_t enable;
-
-	/* Reserved for 32-bit alignment. This field must be set to 0. */
-	uint16_t reserved;
-} __packed;
-
-#define AFE_MODULE_ID_PORT_INFO		0x00010200
-/* Module ID for the loopback-related parameters. */
-#define AFE_MODULE_LOOPBACK           0x00010205
-struct afe_param_payload_base {
-	u32 module_id;
-	u32 param_id;
-	u16 param_size;
-	u16 reserved;
-} __packed;
-
-struct afe_param_payload {
-	struct afe_param_payload_base base;
-	union {
-		struct afe_param_sidetone_gain sidetone_gain;
-		struct afe_param_sampling_rate sampling_rate;
-		struct afe_param_channels      channels;
-		struct afe_param_loopback_gain loopback_gain;
-		struct afe_param_loopback_cfg loopback_cfg;
-	} __packed param;
-} __packed;
-
-#define AFE_PORT_CMD_SET_PARAM		0x000100dc
-
-struct afe_port_cmd_set_param {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 payload_size;
-	u32 payload_address;
-	struct afe_param_payload payload;
-} __packed;
-
-struct afe_port_cmd_set_param_no_payload {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 payload_size;
-	u32 payload_address;
-} __packed;
-
-#define AFE_EVENT_GET_ACTIVE_PORTS 0x00010100
-struct afe_get_active_ports_rsp {
-	u16	num_ports;
-	u16	port_id;
-} __packed;
-
-
-#define AFE_EVENT_GET_ACTIVE_HANDLES 0x00010102
-struct afe_get_active_handles_rsp {
-	u16	port_id;
-	u16	num_handles;
-	u16	mode;		/* 0, voice rx */
-				/* 1, voice tx */
-				/* 2, audio rx */
-				/* 3, audio tx */
-	u16	handle;
-} __packed;
-
-#define AFE_SERVICE_CMD_MEMORY_MAP 0x000100DE
-struct afe_cmd_memory_map {
-	struct apr_hdr hdr;
-	u32 phy_addr;
-	u32 mem_sz;
-	u16 mem_id;
-	u16 rsvd;
-} __packed;
-
-#define AFE_SERVICE_CMD_MEMORY_UNMAP 0x000100DF
-struct afe_cmd_memory_unmap {
-	struct apr_hdr hdr;
-	u32 phy_addr;
-} __packed;
-
-#define AFE_SERVICE_CMD_REG_RTPORT 0x000100E0
-struct afe_cmd_reg_rtport {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 rsvd;
-} __packed;
-
-#define AFE_SERVICE_CMD_UNREG_RTPORT 0x000100E1
-struct afe_cmd_unreg_rtport {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 rsvd;
-} __packed;
-
-#define AFE_SERVICE_CMD_RTPORT_WR 0x000100E2
-struct afe_cmd_rtport_wr {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 rsvd;
-	u32 buf_addr;
-	u32 bytes_avail;
-} __packed;
-
-#define AFE_SERVICE_CMD_RTPORT_RD 0x000100E3
-struct afe_cmd_rtport_rd {
-	struct apr_hdr hdr;
-	u16 port_id;
-	u16 rsvd;
-	u32 buf_addr;
-	u32 bytes_avail;
-} __packed;
-
-#define AFE_EVENT_RT_PROXY_PORT_STATUS 0x00010105
-
-#define ADM_MAX_COPPS 5
-
-#define ADM_SERVICE_CMD_GET_COPP_HANDLES                 0x00010300
-struct adm_get_copp_handles_command {
-	struct apr_hdr hdr;
-} __packed;
-
-#define ADM_CMD_MATRIX_MAP_ROUTINGS                      0x00010301
-struct adm_routings_session {
-	u16 id;
-	u16 num_copps;
-	u16 copp_id[ADM_MAX_COPPS+1]; /*Padding if numCopps is odd */
-} __packed;
-
-struct adm_routings_command {
-	struct apr_hdr hdr;
-	u32 path; /* 0 = Rx, 1 Tx */
-	u32 num_sessions;
-	struct adm_routings_session session[8];
-} __packed;
-
-
-#define ADM_CMD_MATRIX_RAMP_GAINS                        0x00010302
-struct adm_ramp_gain {
-	struct apr_hdr hdr;
-	u16 session_id;
-	u16 copp_id;
-	u16 initial_gain;
-	u16 gain_increment;
-	u16 ramp_duration;
-	u16 reserved;
-} __packed;
-
-struct adm_ramp_gains_command {
-	struct apr_hdr hdr;
-	u32 id;
-	u32 num_gains;
-	struct adm_ramp_gain gains[ADM_MAX_COPPS];
-} __packed;
-
-
-#define ADM_CMD_COPP_OPEN                                0x00010304
-struct adm_copp_open_command {
-	struct apr_hdr hdr;
-	u16 flags;
-	u16 mode; /* 1-RX, 2-Live TX, 3-Non Live TX */
-	u16 endpoint_id1;
-	u16 endpoint_id2;
-	u32 topology_id;
-	u16 channel_config;
-	u16 reserved;
-	u32 rate;
-} __packed;
-
-#define ADM_CMD_COPP_CLOSE                               0x00010305
-
-#define ADM_CMD_MULTI_CHANNEL_COPP_OPEN                  0x00010310
-#define ADM_CMD_MULTI_CHANNEL_COPP_OPEN_V3               0x00010333
-struct adm_multi_ch_copp_open_command {
-	struct apr_hdr hdr;
-	u16 flags;
-	u16 mode; /* 1-RX, 2-Live TX, 3-Non Live TX */
-	u16 endpoint_id1;
-	u16 endpoint_id2;
-	u32 topology_id;
-	u16 channel_config;
-	u16 reserved;
-	u32 rate;
-	u8 dev_channel_mapping[8];
-} __packed;
-
-struct adm_multi_channel_copp_open_v3 {
-	struct apr_hdr hdr;
-	u16 flags;
-	u16 mode;
-	u16 endpoint_id1;
-	u16 endpoint_id2;
-	u32 topology_id;
-	u16 channel_config;
-	u16 bit_width;
-	u32 rate;
-	u8  dev_channel_mapping[8];
-};
-
-#define ADM_CMD_MEMORY_MAP				0x00010C30
-struct adm_cmd_memory_map {
-	struct apr_hdr	hdr;
-	u32		buf_add;
-	u32		buf_size;
-	u16		mempool_id;
-	u16		reserved;
-} __packed;
-
-#define ADM_CMD_MEMORY_UNMAP				0x00010C31
-struct adm_cmd_memory_unmap {
-	struct apr_hdr	hdr;
-	u32		buf_add;
-} __packed;
-
-#define ADM_CMD_MEMORY_MAP_REGIONS			0x00010C47
-struct adm_memory_map_regions {
-	u32		phys;
-	u32		buf_size;
-} __packed;
-
-struct adm_cmd_memory_map_regions {
-	struct apr_hdr	hdr;
-	u16		mempool_id;
-	u16		nregions;
-} __packed;
-
-#define ADM_CMD_MEMORY_UNMAP_REGIONS			0x00010C48
-struct adm_memory_unmap_regions {
-	u32		phys;
-} __packed;
-
-struct adm_cmd_memory_unmap_regions {
-	struct apr_hdr	hdr;
-	u16		nregions;
-	u16		reserved;
-} __packed;
-
-#define DEFAULT_COPP_TOPOLOGY				0x00010be3
-#define DEFAULT_POPP_TOPOLOGY				0x00010be4
-#define VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY			0x00010F89
-#define VPM_TX_DM_FLUENCE_COPP_TOPOLOGY			0x00010F72
-#define VPM_TX_QMIC_FLUENCE_COPP_TOPOLOGY		0x00010F75
-
-#define LOWLATENCY_POPP_TOPOLOGY			0x00010C68
-#define LOWLATENCY_COPP_TOPOLOGY			0x00010312
-#define PCM_BITS_PER_SAMPLE				16
-
-#define ASM_OPEN_WRITE_PERF_MODE_BIT			(1<<28)
-#define ASM_OPEN_READ_PERF_MODE_BIT			(1<<29)
-#define ADM_MULTI_CH_COPP_OPEN_PERF_MODE_BIT		(1<<13)
-
-
-#define ASM_MAX_EQ_BANDS 12
-
-struct asm_eq_band {
-	u32 band_idx; /* The band index, 0 .. 11 */
-	u32 filter_type; /* Filter band type */
-	u32 center_freq_hz; /* Filter band center frequency */
-	u32 filter_gain; /* Filter band initial gain (dB) */
-			/* Range is +12 dB to -12 dB with 1dB increments. */
-	u32 q_factor;
-} __packed;
-
-struct asm_equalizer_params {
-	u32 enable;
-	u32 num_bands;
-	struct asm_eq_band eq_bands[ASM_MAX_EQ_BANDS];
-} __packed;
-
-struct asm_master_gain_params {
-	u16 master_gain;
-	u16 padding;
-} __packed;
-
-struct asm_lrchannel_gain_params {
-	u16 left_gain;
-	u16 right_gain;
-} __packed;
-
-struct asm_mute_params {
-	u32 muteflag;
-} __packed;
-
-struct asm_softvolume_params {
-	u32 period;
-	u32 step;
-	u32 rampingcurve;
-} __packed;
-
-struct asm_softpause_params {
-	u32 enable;
-	u32 period;
-	u32 step;
-	u32 rampingcurve;
-} __packed;
-
-struct asm_pp_param_data_hdr {
-	u32 module_id;
-	u32 param_id;
-	u16 param_size;
-	u16 reserved;
-} __packed;
-
-struct asm_pp_params_command {
-	struct apr_hdr	hdr;
-	u32    *payload;
-	u32	payload_size;
-	struct  asm_pp_param_data_hdr params;
-} __packed;
-
-#define EQUALIZER_MODULE_ID		0x00010c27
-#define EQUALIZER_PARAM_ID		0x00010c28
-
-#define VOLUME_CONTROL_MODULE_ID	0x00010bfe
-#define MASTER_GAIN_PARAM_ID		0x00010bff
-#define L_R_CHANNEL_GAIN_PARAM_ID	0x00010c00
-#define MUTE_CONFIG_PARAM_ID 0x00010c01
-#define SOFT_PAUSE_PARAM_ID 0x00010D6A
-#define SOFT_VOLUME_PARAM_ID 0x00010C29
-
-#define IIR_FILTER_ENABLE_PARAM_ID 0x00010c03
-#define IIR_FILTER_PREGAIN_PARAM_ID 0x00010c04
-#define IIR_FILTER_CONFIG_PARAM_ID 0x00010c05
-
-#define MBADRC_MODULE_ID 0x00010c06
-#define MBADRC_ENABLE_PARAM_ID 0x00010c07
-#define MBADRC_CONFIG_PARAM_ID 0x00010c08
-
-
-#define ADM_CMD_SET_PARAMS                               0x00010306
-#define ADM_CMD_GET_PARAMS                               0x0001030B
-#define ADM_CMDRSP_GET_PARAMS                            0x0001030C
-struct adm_set_params_command {
-	struct apr_hdr		hdr;
-	u32			payload;
-	u32			payload_size;
-} __packed;
-
-
-#define ADM_CMD_TAP_COPP_PCM                             0x00010307
-struct adm_tap_copp_pcm_command {
-	struct apr_hdr hdr;
-} __packed;
-
-
-/* QDSP6 to Client messages */
-#define ADM_SERVICE_CMDRSP_GET_COPP_HANDLES              0x00010308
-struct adm_get_copp_handles_respond {
-	struct apr_hdr hdr;
-	u32 handles;
-	u32 copp_id;
-} __packed;
-
-#define ADM_CMDRSP_COPP_OPEN                             0x0001030A
-struct adm_copp_open_respond {
-	u32 status;
-	u16 copp_id;
-	u16 reserved;
-} __packed;
-
-#define ADM_CMDRSP_MULTI_CHANNEL_COPP_OPEN               0x00010311
-#define ADM_CMDRSP_MULTI_CHANNEL_COPP_OPEN_V3            0x00010334
-
-
-#define ASM_STREAM_PRIORITY_NORMAL	0
-#define ASM_STREAM_PRIORITY_LOW		1
-#define ASM_STREAM_PRIORITY_HIGH	2
-#define ASM_STREAM_PRIORITY_RESERVED	3
-
-#define ASM_END_POINT_DEVICE_MATRIX	0
-#define ASM_END_POINT_STREAM		1
-
-#define AAC_ENC_MODE_AAC_LC            0x02
-#define AAC_ENC_MODE_AAC_P             0x05
-#define AAC_ENC_MODE_EAAC_P            0x1D
-
-#define ASM_STREAM_CMD_CLOSE                             0x00010BCD
-#define ASM_STREAM_CMD_FLUSH                             0x00010BCE
-#define ASM_STREAM_CMD_SET_PP_PARAMS                     0x00010BCF
-#define ASM_STREAM_CMD_GET_PP_PARAMS                     0x00010BD0
-#define ASM_STREAM_CMDRSP_GET_PP_PARAMS                  0x00010BD1
-#define ASM_SESSION_CMD_PAUSE                            0x00010BD3
-#define ASM_SESSION_CMD_GET_SESSION_TIME                 0x00010BD4
-#define ASM_DATA_CMD_EOS                                 0x00010BDB
-#define ASM_DATA_EVENT_EOS                               0x00010BDD
-
-#define ASM_SERVICE_CMD_GET_STREAM_HANDLES               0x00010C0B
-#define ASM_STREAM_CMD_FLUSH_READBUFS                    0x00010C09
-
-#define ASM_SESSION_EVENT_RX_UNDERFLOW			 0x00010C17
-#define ASM_SESSION_EVENT_TX_OVERFLOW			 0x00010C18
-#define ASM_SERVICE_CMD_GET_WALLCLOCK_TIME               0x00010C19
-#define ASM_DATA_CMDRSP_EOS                              0x00010C1C
-
-/* ASM Data structures */
-
-/* common declarations */
-struct asm_pcm_cfg {
-	u16 ch_cfg;
-	u16 bits_per_sample;
-	u32 sample_rate;
-	u16 is_signed;
-	u16 interleaved;
-};
-
-#define PCM_CHANNEL_NULL 0
-
-/* Front left channel. */
-#define PCM_CHANNEL_FL    1
-
-/* Front right channel. */
-#define PCM_CHANNEL_FR    2
-
-/* Front center channel. */
-#define PCM_CHANNEL_FC    3
-
-/* Left surround channel.*/
-#define PCM_CHANNEL_LS   4
-
-/* Right surround channel.*/
-#define PCM_CHANNEL_RS   5
-
-/* Low frequency effect channel. */
-#define PCM_CHANNEL_LFE  6
-
-/* Center surround channel; Rear center channel. */
-#define PCM_CHANNEL_CS   7
-
-/* Left back channel; Rear left channel. */
-#define PCM_CHANNEL_LB   8
-
-/* Right back channel; Rear right channel. */
-#define PCM_CHANNEL_RB   9
-
-/* Top surround channel. */
-#define PCM_CHANNEL_TS   10
-
-/* Center vertical height channel.*/
-#define PCM_CHANNEL_CVH  11
-
-/* Mono surround channel.*/
-#define PCM_CHANNEL_MS   12
-
-/* Front left of center. */
-#define PCM_CHANNEL_FLC  13
-
-/* Front right of center. */
-#define PCM_CHANNEL_FRC  14
-
-/* Rear left of center. */
-#define PCM_CHANNEL_RLC  15
-
-/* Rear right of center. */
-#define PCM_CHANNEL_RRC  16
-
-#define PCM_FORMAT_MAX_NUM_CHANNEL  8
-
-/* Maximum number of channels supported
- * in ASM_ENCDEC_DEC_CHAN_MAP command
- */
-#define MAX_CHAN_MAP_CHANNELS 16
-/*
- *  Multiple-channel PCM decoder format block structure used in the
- *  #ASM_STREAM_CMD_OPEN_WRITE command.
- *  The data must be in little-endian format.
- */
-struct asm_multi_channel_pcm_fmt_blk {
-
-	u16 num_channels;	/*
-				 * Number of channels.
-				 * Supported values:1 to 8
-				 */
-
-	u16 bits_per_sample;	/*
-				 * Number of bits per sample per channel.
-				 * Supported values: 16, 24 When used for
-				 * playback, the client must send 24-bit
-				 * samples packed in 32-bit words. The
-				 * 24-bit samples must be placed in the most
-				 * significant 24 bits of the 32-bit word. When
-				 * used for recording, the aDSP sends 24-bit
-				 * samples packed in 32-bit words. The 24-bit
-				 * samples are placed in the most significant
-				 * 24 bits of the 32-bit word.
-				 */
-
-	u32 sample_rate;	/*
-				 * Number of samples per second
-				 * (in Hertz). Supported values:
-				 * 2000 to 48000
-				 */
-
-	u16 is_signed;		/*
-				 * Flag that indicates the samples
-				 * are signed (1).
-				 */
-
-	u16 is_interleaved;	/*
-				 * Flag that indicates whether the channels are
-				 * de-interleaved (0) or interleaved (1).
-				 * Interleaved format means corresponding
-				 * samples from the left and right channels are
-				 * interleaved within the buffer.
-				 * De-interleaved format means samples from
-				 * each channel are contiguous in the buffer.
-				 * The samples from one channel immediately
-				 * follow those of the previous channel.
-				 */
-
-	u8 channel_mapping[8];	/*
-				 * Supported values:
-				 * PCM_CHANNEL_NULL, PCM_CHANNEL_FL,
-				 * PCM_CHANNEL_FR, PCM_CHANNEL_FC,
-				 * PCM_CHANNEL_LS, PCM_CHANNEL_RS,
-				 * PCM_CHANNEL_LFE, PCM_CHANNEL_CS,
-				 * PCM_CHANNEL_LB, PCM_CHANNEL_RB,
-				 * PCM_CHANNEL_TS, PCM_CHANNEL_CVH,
-				 * PCM_CHANNEL_MS, PCM_CHANNEL_FLC,
-				 * PCM_CHANNEL_FRC, PCM_CHANNEL_RLC,
-				 * PCM_CHANNEL_RRC.
-				 * Channel[i] mapping describes channel I. Each
-				 * element i of the array describes channel I
-				 * inside the buffer where  I < num_channels.
-				 * An unused channel is set to zero.
-				 */
-};
-struct asm_dts_enc_cfg {
-	uint32_t	sample_rate;
-	/*
-	 * Samples at which input is to be encoded.
-	 * Supported values:
-	 * 44100 -- encode at 44.1 Khz
-	 * 48000 -- encode at 48 Khz
-	 */
-
-	uint32_t	num_channels;
-	/*
-	 * Number of channels for multi-channel encoding.
-	 * Supported values: 1 to 6
-	 */
-
-	uint8_t		channel_mapping[6];
-	/*
-	 * Channel array of size 16. Channel[i] mapping describes channel I.
-	 * Each element i of the array describes channel I inside the buffer
-	 * where num_channels. An unused channel is set to zero. Only first
-	 * num_channels elements are valid
-	 *
-	 * Supported values:
-	 * - # PCM_CHANNEL_L
-	 * - # PCM_CHANNEL_R
-	 * - # PCM_CHANNEL_C
-	 * - # PCM_CHANNEL_LS
-	 * - # PCM_CHANNEL_RS
-	 * - # PCM_CHANNEL_LFE
-	 */
-
-};
-struct asm_adpcm_cfg {
-	u16 ch_cfg;
-	u16 bits_per_sample;
-	u32 sample_rate;
-	u32 block_size;
-};
-
-struct asm_yadpcm_cfg {
-	u16 ch_cfg;
-	u16 bits_per_sample;
-	u32 sample_rate;
-};
-
-struct asm_midi_cfg {
-	u32 nMode;
-};
-
-struct asm_wma_cfg {
-	u16 format_tag;
-	u16 ch_cfg;
-	u32 sample_rate;
-	u32 avg_bytes_per_sec;
-	u16 block_align;
-	u16 valid_bits_per_sample;
-	u32 ch_mask;
-	u16 encode_opt;
-	u16 adv_encode_opt;
-	u32 adv_encode_opt2;
-	u32 drc_peak_ref;
-	u32 drc_peak_target;
-	u32 drc_ave_ref;
-	u32 drc_ave_target;
-};
-
-struct asm_wmapro_cfg {
-	u16 format_tag;
-	u16 ch_cfg;
-	u32 sample_rate;
-	u32 avg_bytes_per_sec;
-	u16 block_align;
-	u16 valid_bits_per_sample;
-	u32 ch_mask;
-	u16 encode_opt;
-	u16 adv_encode_opt;
-	u32 adv_encode_opt2;
-	u32 drc_peak_ref;
-	u32 drc_peak_target;
-	u32 drc_ave_ref;
-	u32 drc_ave_target;
-};
-
-struct asm_aac_cfg {
-	u16 format;
-	u16 aot;
-	u16 ep_config;
-	u16 section_data_resilience;
-	u16 scalefactor_data_resilience;
-	u16 spectral_data_resilience;
-	u16 ch_cfg;
-	u16 reserved;
-	u32 sample_rate;
-};
-
-struct asm_amrwbplus_cfg {
-	u32  size_bytes;
-	u32  version;
-	u32  num_channels;
-	u32  amr_band_mode;
-	u32  amr_dtx_mode;
-	u32  amr_frame_fmt;
-	u32  amr_lsf_idx;
-};
-
-struct asm_flac_cfg {
-	u16 stream_info_present;
-	u16 min_blk_size;
-	u16 max_blk_size;
-	u16 ch_cfg;
-	u16 sample_size;
-	u16 sample_rate;
-	u16 md5_sum;
-	u32 ext_sample_rate;
-	u32 min_frame_size;
-	u32 max_frame_size;
-};
-
-struct asm_vorbis_cfg {
-	u32 ch_cfg;
-	u32 bit_rate;
-	u32 min_bit_rate;
-	u32 max_bit_rate;
-	u16 bit_depth_pcm_sample;
-	u16 bit_stream_format;
-};
-
-struct asm_aac_read_cfg {
-	u32 bitrate;
-	u32 enc_mode;
-	u16 format;
-	u16 ch_cfg;
-	u32 sample_rate;
-};
-
-struct asm_amrnb_read_cfg {
-	u16 mode;
-	u16 dtx_mode;
-};
-
-struct asm_amrwb_read_cfg {
-	u16 mode;
-	u16 dtx_mode;
-};
-
-struct asm_evrc_read_cfg {
-	u16 max_rate;
-	u16 min_rate;
-	u16 rate_modulation_cmd;
-	u16 reserved;
-};
-
-struct asm_qcelp13_read_cfg {
-	u16 max_rate;
-	u16 min_rate;
-	u16 reduced_rate_level;
-	u16 rate_modulation_cmd;
-};
-
-struct asm_sbc_read_cfg {
-	u32 subband;
-	u32 block_len;
-	u32 ch_mode;
-	u32 alloc_method;
-	u32 bit_rate;
-	u32 sample_rate;
-};
-
-struct asm_sbc_bitrate {
-	u32 bitrate;
-};
-
-struct asm_immed_decode {
-	u32 mode;
-};
-
-struct asm_sbr_ps {
-	u32 enable;
-};
-
-struct asm_dual_mono {
-	u16 sce_left;
-	u16 sce_right;
-};
-
-struct asm_dec_chan_map {
-	u32 num_channels;			  /* Number of decoder output
-						   * channels. A value of 0
-						   * indicates native channel
-						   * mapping, which is valid
-						   * only for NT mode. This
-						   * means the output of the
-						   * decoder is to be preserved
-						   * as is.
-						   */
-
-	u8 channel_mapping[MAX_CHAN_MAP_CHANNELS];/* Channel array of size
-						   * num_channels. It can grow
-						   * till MAX_CHAN_MAP_CHANNELS.
-						   * Channel[i] mapping
-						   * describes channel I inside
-						   * the decoder output buffer.
-						   * Valid channel mapping
-						   * values are to be present at
-						   * the beginning of the array.
-						   * All remaining elements of
-						   * the array are to be filled
-						   * with PCM_CHANNEL_NULL.
-						   */
-};
-
-struct asm_encode_cfg_blk {
-	u32 frames_per_buf;
-	u32 format_id;
-	u32 cfg_size;
-	union {
-		struct asm_pcm_cfg          pcm;
-		struct asm_aac_read_cfg     aac;
-		struct asm_amrnb_read_cfg   amrnb;
-		struct asm_evrc_read_cfg    evrc;
-		struct asm_qcelp13_read_cfg qcelp13;
-		struct asm_sbc_read_cfg     sbc;
-		struct asm_amrwb_read_cfg   amrwb;
-		struct asm_multi_channel_pcm_fmt_blk      mpcm;
-		struct asm_dts_enc_cfg      dts;
-	} __packed cfg;
-};
-
-struct asm_frame_meta_info {
-	u32 offset_to_frame;
-	u32 frame_size;
-	u32 encoded_pcm_samples;
-	u32 msw_ts;
-	u32 lsw_ts;
-	u32 nflags;
-};
-
-/* Stream level commands */
-#define ASM_STREAM_CMD_OPEN_READ                         0x00010BCB
-#define ASM_STREAM_CMD_OPEN_READ_V2_1                    0x00010DB2
-struct asm_stream_cmd_open_read {
-	struct apr_hdr hdr;
-	u32            uMode;
-	u32            src_endpoint;
-	u32            pre_proc_top;
-	u32            format;
-} __packed;
-
-struct asm_stream_cmd_open_read_v2_1 {
-	struct apr_hdr hdr;
-	u32            uMode;
-	u32            src_endpoint;
-	u32            pre_proc_top;
-	u32            format;
-	u16            bits_per_sample;
-	u16            reserved;
-} __packed;
-
-/* Supported formats */
-#define LINEAR_PCM   0x00010BE5
-#define DTMF         0x00010BE6
-#define ADPCM        0x00010BE7
-#define YADPCM       0x00010BE8
-#define MP3          0x00010BE9
-#define MPEG4_AAC    0x00010BEA
-#define AMRNB_FS     0x00010BEB
-#define AMRWB_FS     0x00010BEC
-#define V13K_FS      0x00010BED
-#define EVRC_FS      0x00010BEE
-#define EVRCB_FS     0x00010BEF
-#define EVRCWB_FS    0x00010BF0
-#define MIDI         0x00010BF1
-#define SBC          0x00010BF2
-#define WMA_V10PRO   0x00010BF3
-#define WMA_V9       0x00010BF4
-#define AMR_WB_PLUS  0x00010BF5
-#define AC3_DECODER  0x00010BF6
-#define EAC3_DECODER 0x00010C3C
-#define DTS	0x00010D88
-#define DTS_LBR	0x00010DBB
-#define MP2          0x00010DBE
-#define ATRAC	0x00010D89
-#define MAT	0x00010D8A
-#define G711_ALAW_FS 0x00010BF7
-#define G711_MLAW_FS 0x00010BF8
-#define G711_PCM_FS  0x00010BF9
-#define MPEG4_MULTI_AAC 0x00010D86
-#define US_POINT_EPOS_FORMAT 0x00012310
-#define US_RAW_FORMAT        0x0001127C
-#define US_PROX_FORMAT       0x0001272B
-#define MULTI_CHANNEL_PCM    0x00010C66
-
-#define ASM_ENCDEC_SBCRATE         0x00010C13
-#define ASM_ENCDEC_IMMDIATE_DECODE 0x00010C14
-#define ASM_ENCDEC_CFG_BLK         0x00010C2C
-
-#define ASM_ENCDEC_SBCRATE         0x00010C13
-#define ASM_ENCDEC_IMMDIATE_DECODE 0x00010C14
-#define ASM_ENCDEC_CFG_BLK         0x00010C2C
-
-#define ASM_STREAM_CMD_OPEN_READ_COMPRESSED               0x00010D95
-struct asm_stream_cmd_open_read_compressed {
-	struct apr_hdr hdr;
-	u32            uMode;
-	u32            frame_per_buf;
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_WRITE                        0x00010BCA
-#define ASM_STREAM_CMD_OPEN_WRITE_V2_1                   0x00010DB1
-struct asm_stream_cmd_open_write {
-	struct apr_hdr hdr;
-	u32            uMode;
-	u16            sink_endpoint;
-	u16            stream_handle;
-	u32            post_proc_top;
-	u32            format;
-} __packed;
-
-#define IEC_61937_MASK	0x00000001
-#define IEC_60958_MASK	0x00000002
-
-#define ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED	0x00010D84
-struct asm_stream_cmd_open_write_compressed {
-	struct apr_hdr hdr;
-	u32	flags;
-	u32	format;
-} __packed;
-#define ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK     0x00010DBA
-struct asm_stream_cmd_open_transcode_loopback {
-	struct apr_hdr hdr;
-	uint32_t	mode_flags;
-	/*
-	 * All bits are reserved. Clients must set them to zero.
-	 */
-
-	uint32_t	src_format_id;
-	/*
-	 * Specifies the media format of the input audio stream.
-	 *
-	 * Supported values:
-	 * - #ASM_MEDIA_FMT_LINEAR_PCM
-	 * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM
-	 */
-
-	uint32_t	sink_format_id;
-	/*
-	 * Specifies the media format of the output stream.
-	 *
-	 * Supported values:
-	 * - #ASM_MEDIA_FMT_LINEAR_PCM
-	 * - #ASM_MEDIA_FMT_MULTI_CHANNEL_PCM
-	 * - #ASM_MEDIA_FMT_DTS
-	 */
-
-	uint32_t	audproc_topo_id;
-	/*
-	 * Postprocessing topology ID, which specifies the topology (order of
-	 * processing) of postprocessing algorithms.
-	 *
-	 * Supported values:
-	 * - #ASM_STREAM_POSTPROC_TOPO_ID_DEFAULT
-	 * - #ASM_STREAM_POSTPROC_TOPO_ID_PEAKMETER
-	 * - #ASM_STREAM_POSTPROC_TOPO_ID_NONE
-	 * - #ASM_STREAM_POSTPROC_TOPO_ID_MCH_PEAK_VOL
-	 */
-
-	uint16_t	src_endpoint_type;
-	/*
-	 * Specifies the source endpoint that provides the input samples.
-	 *
-	 * Supported values:
-	 * - 0 -- Tx device matrix or stream router
-	 * (gateway to the hardware ports)
-	 * - All other values are reserved
-	 *
-	 * Clients must set this field to zero. Otherwise, an error is returned.
-	 */
-
-	uint16_t	sink_endpoint_type;
-	/*
-	 * Specifies the sink endpoint type.
-	 *
-	 * Supported values:
-	 * - 0 -- Rx device matrix or stream router
-	 * (gateway to the hardware ports)
-	 * - All other values are reserved
-	 *
-	 * Clients must set this field to zero. Otherwise, an error is returned.
-	 */
-
-	uint16_t	bits_per_sample;
-	/*
-	 * Number of bits per sample processed by the ASM modules.
-	 * Supported values: 16, 24
-	 */
-
-	uint16_t	reserved;
-	/*
-	 * This field must be set to zero.
-	 */
-} __packed;
-
-/*
- * ID of the DTS mix LFE channel to front channels parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- * asm_dts_generic_param_t
- * ASM_PARAM_ID_DTS_MIX_LFE_TO_FRONT
- */
-#define ASM_PARAM_ID_DTS_MIX_LFE_TO_FRONT                          0x00010DB6
-
-/*
- * ID of the DTS DRC ratio parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- * asm_dts_generic_param_t
- * ASM_PARAM_ID_DTS_DRC_RATIO
- */
-#define ASM_PARAM_ID_DTS_DRC_RATIO                                   0x00010DB7
-
-/*
- * ID of the DTS enable dialog normalization parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- *
- * asm_dts_generic_param_t
- * ASM_PARAM_ID_DTS_ENABLE_DIALNORM
- */
-#define ASM_PARAM_ID_DTS_ENABLE_DIALNORM                             0x00010DB8
-
-/*
- * ID of the DTS enable parse REV2AUX parameter in the
- * #ASM_STREAM_CMD_SET_ENCDEC_PARAM command.
- * asm_dts_generic_param_t
- * ASM_PARAM_ID_DTS_ENABLE_PARSE_REV2AUX
- */
-#define ASM_PARAM_ID_DTS_ENABLE_PARSE_REV2AUX                         0x00010DB9
-
-struct asm_dts_generic_param {
-	int32_t		generic_parameter;
-	/*
-	 * #ASM_PARAM_ID_DTS_MIX_LFE_TO_FRONT:
-	 * - if enabled, mixes LFE channel to front
-	 * while downmixing (if necessary)
-	 * - Supported values: 1-> enable, 0-> disable
-	 * - Default: disabled
-	 *
-	 * #ASM_PARAM_ID_DTS_DRC_RATIO:
-	 * - percentage of DRC ratio.
-	 * - Supported values: 0-100
-	 * - Default: 0, DRC is disabled.
-	 *
-	 * #ASM_PARAM_ID_DTS_ENABLE_DIALNORM:
-	 * - flag to enable dialog normalization post processing.
-	 * - Supported values: 1-> enable, 0-> disable.
-	 * - Default: enabled.
-	 *
-	 * #ASM_PARAM_ID_DTS_ENABLE_PARSE_REV2AUX:
-	 * - flag to enable parsing of rev2aux chunk in the bitstream.
-	 * This chunk contains broadcast metadata.
-	 * - Supported values: 1-> enable, 0-> disable.
-	 * - Default: disabled.
-	 */
-};
-
-struct asm_stream_cmd_dts_dec_param {
-	struct apr_hdr hdr;
-	u32            param_id;
-	u32            param_size;
-	struct asm_dts_generic_param generic_param;
-} __packed;
-
-
-#define ASM_STREAM_CMD_OPEN_READWRITE                    0x00010BCC
-
-struct asm_stream_cmd_open_read_write {
-	struct apr_hdr     hdr;
-	u32                uMode;
-	u32                post_proc_top;
-	u32                write_format;
-	u32                read_format;
-} __packed;
-
-#define ASM_STREAM_CMD_OPEN_LOOPBACK	0x00010D6E
-struct asm_stream_cmd_open_loopback {
-	struct apr_hdr         hdr;
-	u32                    mode_flags;
-/* Mode flags.
- * Bit 0-31: reserved; client should set these bits to 0
- */
-	u16                    src_endpointype;
-	/* Endpoint type. 0 = Tx Matrix */
-	u16                    sink_endpointype;
-	/* Endpoint type. 0 = Rx Matrix */
-	u32                    postprocopo_id;
-/* Postprocessor topology ID. Specifies the topology of
- * postprocessing algorithms.
- */
-} __packed;
-
-#define ADM_CMD_CONNECT_AFE_PORT 0x00010320
-#define ADM_CMD_DISCONNECT_AFE_PORT 0x00010321
-
-struct adm_cmd_connect_afe_port {
-	struct apr_hdr     hdr;
-	u8	mode; /*mode represent the interface is for RX or TX*/
-	u8	session_id; /*ASM session ID*/
-	u16	afe_port_id;
-} __packed;
-
-#define ADM_CMD_CONNECT_AFE_PORT_V2 0x00010332
-
-struct adm_cmd_connect_afe_port_v2 {
-	struct apr_hdr     hdr;
-	u8	mode; /*mode represent the interface is for RX or TX*/
-	u8	session_id; /*ASM session ID*/
-	u16	afe_port_id;
-	u32	num_channels;
-	u32	sampling_rate;
-} __packed;
-
-#define ASM_STREAM_CMD_SET_ENCDEC_PARAM                  0x00010C10
-#define ASM_STREAM_CMD_GET_ENCDEC_PARAM                  0x00010C11
-#define ASM_ENCDEC_CFG_BLK_ID				 0x00010C2C
-#define ASM_ENABLE_SBR_PS				 0x00010C63
-#define ASM_CONFIGURE_DUAL_MONO			 0x00010C64
-struct asm_stream_cmd_encdec_cfg_blk {
-	struct apr_hdr              hdr;
-	u32                         param_id;
-	u32                         param_size;
-	struct asm_encode_cfg_blk   enc_blk;
-} __packed;
-
-struct asm_stream_cmd_encdec_sbc_bitrate {
-	struct apr_hdr hdr;
-	u32            param_id;
-		struct asm_sbc_bitrate      sbc_bitrate;
-} __packed;
-
-struct asm_stream_cmd_encdec_immed_decode {
-	struct apr_hdr hdr;
-	u32            param_id;
-	u32            param_size;
-	struct asm_immed_decode dec;
-} __packed;
-
-struct asm_stream_cmd_encdec_sbr {
-	struct apr_hdr hdr;
-	u32            param_id;
-	u32            param_size;
-	struct asm_sbr_ps sbr_ps;
-} __packed;
-
-struct asm_stream_cmd_encdec_dualmono {
-	struct apr_hdr hdr;
-	u32            param_id;
-	u32            param_size;
-	struct asm_dual_mono channel_map;
-} __packed;
-
-#define ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG        0x00010DD8
-
-/* Structure for AAC decoder stereo coefficient setting. */
-
-struct asm_aac_stereo_mix_coeff_selection_param {
-	struct apr_hdr				hdr;
-	u32					param_id;
-	u32					param_size;
-	u32					aac_stereo_mix_coeff_flag;
-} __packed;
-
-#define ASM_ENCDEC_DEC_CHAN_MAP				 0x00010D82
-struct asm_stream_cmd_encdec_channelmap {
-	struct apr_hdr hdr;
-	u32            param_id;
-	u32            param_size;
-	struct asm_dec_chan_map chan_map;
-} __packed;
-
-#define ASM_STREAM_CMD_ADJUST_SAMPLES                   0x00010C0A
-struct asm_stream_cmd_adjust_samples {
-	struct apr_hdr hdr;
-	u16            nsamples;
-	u16            reserved;
-} __packed;
-
-#define ASM_STREAM_CMD_TAP_POPP_PCM                      0x00010BF9
-struct asm_stream_cmd_tap_popp_pcm {
-	struct apr_hdr hdr;
-	u16            enable;
-	u16            reserved;
-	u32            module_id;
-} __packed;
-
-/*  Session Level commands */
-#define ASM_SESSION_CMD_MEMORY_MAP			0x00010C32
-struct asm_stream_cmd_memory_map {
-	struct apr_hdr	hdr;
-	u32		buf_add;
-	u32		buf_size;
-	u16		mempool_id;
-	u16		reserved;
-} __packed;
-
-#define ASM_SESSION_CMD_MEMORY_UNMAP			0x00010C33
-struct asm_stream_cmd_memory_unmap {
-	struct apr_hdr	hdr;
-	u32		buf_add;
-} __packed;
-
-#define ASM_SESSION_CMD_MEMORY_MAP_REGIONS		0x00010C45
-struct asm_memory_map_regions {
-	u32		phys;
-	u32		buf_size;
-} __packed;
-
-struct asm_stream_cmd_memory_map_regions {
-	struct apr_hdr	hdr;
-	u16		mempool_id;
-	u16		nregions;
-} __packed;
-
-#define ASM_SESSION_CMD_MEMORY_UNMAP_REGIONS		0x00010C46
-struct asm_memory_unmap_regions {
-	u32		phys;
-} __packed;
-
-struct asm_stream_cmd_memory_unmap_regions {
-	struct apr_hdr	hdr;
-	u16		nregions;
-	u16		reserved;
-} __packed;
-
-#define ASM_SESSION_CMD_RUN                              0x00010BD2
-struct asm_stream_cmd_run {
-	struct apr_hdr hdr;
-	u32            flags;
-	u32            msw_ts;
-	u32            lsw_ts;
-} __packed;
-
-/* Session level events */
-#define ASM_SESSION_CMD_REGISTER_FOR_RX_UNDERFLOW_EVENTS 0x00010BD5
-struct asm_stream_cmd_reg_rx_underflow_event {
-	struct apr_hdr hdr;
-	u16            enable;
-	u16            reserved;
-} __packed;
-
-#define ASM_SESSION_CMD_REGISTER_FOR_TX_OVERFLOW_EVENTS  0x00010BD6
-struct asm_stream_cmd_reg_tx_overflow_event {
-	struct apr_hdr hdr;
-	u16            enable;
-	u16            reserved;
-} __packed;
-
-/* Data Path commands */
-#define ASM_DATA_CMD_WRITE                               0x00010BD9
-struct asm_stream_cmd_write {
-	struct apr_hdr     hdr;
-	u32	buf_add;
-	u32	avail_bytes;
-	u32	uid;
-	u32	msw_ts;
-	u32	lsw_ts;
-	u32	uflags;
-} __packed;
-
-#define ASM_DATA_CMD_READ                                0x00010BDA
-struct asm_stream_cmd_read {
-	struct apr_hdr     hdr;
-	u32	buf_add;
-	u32	buf_size;
-	u32	uid;
-} __packed;
-
-#define ASM_DATA_CMD_READ_COMPRESSED                     0x00010DBF
-struct asm_stream_cmd_read_compressed {
-	struct apr_hdr     hdr;
-	u32	buf_add;
-	u32	buf_size;
-	u32	uid;
-} __packed;
-
-#define ASM_DATA_CMD_MEDIA_FORMAT_UPDATE                 0x00010BDC
-#define ASM_DATA_EVENT_ENC_SR_CM_NOTIFY                  0x00010BDE
-struct asm_stream_media_format_update {
-	struct apr_hdr hdr;
-	u32            format;
-	u32            cfg_size;
-	union {
-		struct asm_pcm_cfg         pcm_cfg;
-		struct asm_adpcm_cfg       adpcm_cfg;
-		struct asm_yadpcm_cfg      yadpcm_cfg;
-		struct asm_midi_cfg        midi_cfg;
-		struct asm_wma_cfg         wma_cfg;
-		struct asm_wmapro_cfg      wmapro_cfg;
-		struct asm_aac_cfg         aac_cfg;
-		struct asm_flac_cfg        flac_cfg;
-		struct asm_vorbis_cfg      vorbis_cfg;
-		struct asm_multi_channel_pcm_fmt_blk multi_ch_pcm_cfg;
-		struct asm_amrwbplus_cfg   amrwbplus_cfg;
-	} __packed write_cfg;
-} __packed;
-
-
-/* Command Responses */
-#define ASM_STREAM_CMDRSP_GET_ENCDEC_PARAM               0x00010C12
-struct asm_stream_cmdrsp_get_readwrite_param {
-	struct apr_hdr hdr;
-	u32            status;
-	u32            param_id;
-	u16            param_size;
-	u16            padding;
-	union {
-		struct asm_sbc_bitrate      sbc_bitrate;
-		struct asm_immed_decode aac_dec;
-	} __packed read_write_cfg;
-} __packed;
-
-
-#define ASM_SESSION_CMDRSP_GET_SESSION_TIME              0x00010BD8
-struct asm_stream_cmdrsp_get_session_time {
-	struct apr_hdr hdr;
-	u32            status;
-	u32            msw_ts;
-	u32            lsw_ts;
-} __packed;
-
-#define ASM_DATA_EVENT_WRITE_DONE                        0x00010BDF
-struct asm_data_event_write_done {
-	u32	buf_add;
-	u32            status;
-} __packed;
-
-#define ASM_DATA_EVENT_READ_DONE                         0x00010BE0
-struct asm_data_event_read_done {
-	u32            status;
-	u32            buffer_add;
-	u32            enc_frame_size;
-	u32            offset;
-	u32            msw_ts;
-	u32            lsw_ts;
-	u32            flags;
-	u32            num_frames;
-	u32            id;
-} __packed;
-
-#define ASM_DATA_EVENT_READ_COMPRESSED_DONE              0x00010DC0
-struct asm_data_event_read_compressed_done {
-	u32            status;
-	u32            buffer_add;
-	u32            enc_frame_size;
-	u32            offset;
-	u32            msw_ts;
-	u32            lsw_ts;
-	u32            flags;
-	u32            num_frames;
-	u32            id;
-} __packed;
-
-#define ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY               0x00010C65
-struct asm_data_event_sr_cm_change_notify {
-	u32            sample_rate;
-	u16	           no_of_channels;
-	u16            reserved;
-	u8             channel_map[8];
-} __packed;
-
-/* service level events */
-
-#define ASM_SERVICE_CMDRSP_GET_STREAM_HANDLES            0x00010C1B
-struct asm_svc_cmdrsp_get_strm_handles {
-	struct apr_hdr hdr;
-	u32            num_handles;
-	u32            stream_handles;
-} __packed;
-
-
-#define ASM_SERVICE_CMDRSP_GET_WALLCLOCK_TIME            0x00010C1A
-struct asm_svc_cmdrsp_get_wallclock_time {
-	struct apr_hdr hdr;
-	u32            status;
-	u32            msw_ts;
-	u32            lsw_ts;
-} __packed;
-
-/* Error code */
-#define ADSP_EOK          0x00000000 /* Success / completed / no errors. */
-#define ADSP_EFAILED      0x00000001 /* General failure. */
-#define ADSP_EBADPARAM    0x00000002 /* Bad operation parameter(s). */
-#define ADSP_EUNSUPPORTED 0x00000003 /* Unsupported routine/operation. */
-#define ADSP_EVERSION     0x00000004 /* Unsupported version. */
-#define ADSP_EUNEXPECTED  0x00000005 /* Unexpected problem encountered. */
-#define ADSP_EPANIC       0x00000006 /* Unhandled problem occurred. */
-#define ADSP_ENORESOURCE  0x00000007 /* Unable to allocate resource(s). */
-#define ADSP_EHANDLE      0x00000008 /* Invalid handle. */
-#define ADSP_EALREADY     0x00000009 /* Operation is already processed. */
-#define ADSP_ENOTREADY    0x0000000A /* Operation not ready to be processed*/
-#define ADSP_EPENDING     0x0000000B /* Operation is pending completion*/
-#define ADSP_EBUSY        0x0000000C /* Operation could not be accepted or
-				      * processed.
-				      */
-#define ADSP_EABORTED     0x0000000D /* Operation aborted due to an error. */
-#define ADSP_EPREEMPTED   0x0000000E /* Operation preempted by higher priority*/
-#define ADSP_ECONTINUE    0x0000000F /* Operation requests intervention
-				      * to complete.
-				      */
-#define ADSP_EIMMEDIATE   0x00000010 /* Operation requests immediate
-				      * intervention to complete.
-				      */
-#define ADSP_ENOTIMPL     0x00000011 /* Operation is not implemented. */
-#define ADSP_ENEEDMORE    0x00000012 /* Operation needs more data or resources*/
-
-/* SRS TRUMEDIA GUIDS */
-#define SRS_TRUMEDIA_TOPOLOGY_ID    0x00010D90
-#define SRS_TRUMEDIA_MODULE_ID      0x10005010
-#define SRS_TRUMEDIA_PARAMS         0x10005011
-#define SRS_TRUMEDIA_PARAMS_WOWHD   0x10005012
-#define SRS_TRUMEDIA_PARAMS_CSHP    0x10005013
-#define SRS_TRUMEDIA_PARAMS_HPF     0x10005014
-#define SRS_TRUMEDIA_PARAMS_PEQ     0x10005015
-#define SRS_TRUMEDIA_PARAMS_HL      0x10005016
-
-/* SRS STUDIO SOUND 3D GUIDS */
-#define SRS_SS3D_TOPOLOGY_ID        0x00010720
-#define SRS_SS3D_MODULE_ID          0x10005020
-#define SRS_SS3D_PARAMS             0x10005021
-#define SRS_SS3D_PARAMS_CTRL        0x10005022
-#define SRS_SS3D_PARAMS_FILTER      0x10005023
-
-/* SRS ALSA CMD MASKS */
-#define SRS_CMD_UPLOAD              0x7FFF0000
-#define SRS_PARAM_INDEX_MASK        0x80000000
-#define SRS_PARAM_OFFSET_MASK       0x3FFF0000
-#define SRS_PARAM_VALUE_MASK        0x0000FFFF
-
-/* SRS TRUMEDIA start */
-#define SRS_ID_GLOBAL               0x00000001
-#define SRS_ID_WOWHD                0x00000002
-#define SRS_ID_CSHP                 0x00000003
-#define SRS_ID_HPF                  0x00000004
-#define SRS_ID_PEQ                  0x00000005
-#define SRS_ID_HL                   0x00000006
-
-struct srs_trumedia_params_GLOBAL {
-	uint8_t                  v1;
-	uint8_t                  v2;
-	uint8_t                  v3;
-	uint8_t                  v4;
-	uint8_t                  v5;
-	uint8_t                  v6;
-	uint8_t                  v7;
-	uint8_t                  v8;
-} __packed;
-
-struct srs_trumedia_params_WOWHD {
-	uint32_t				v1;
-	uint16_t				v2;
-	uint16_t				v3;
-	uint16_t				v4;
-	uint16_t				v5;
-	uint16_t				v6;
-	uint16_t				v7;
-	uint16_t				v8;
-	uint16_t				v____A1;
-	uint32_t				v9;
-	uint16_t				v10;
-	uint16_t				v11;
-	uint32_t				v12[16];
-} __packed;
-
-struct srs_trumedia_params_CSHP {
-	uint32_t				v1;
-	uint16_t				v2;
-	uint16_t				v3;
-	uint16_t				v4;
-	uint16_t				v5;
-	uint16_t				v6;
-	uint16_t				v____A1;
-	uint32_t				v7;
-	uint16_t				v8;
-	uint16_t				v9;
-	uint32_t				v10[16];
-} __packed;
-
-struct srs_trumedia_params_HPF {
-	uint32_t				v1;
-	uint32_t				v2[26];
-} __packed;
-
-struct srs_trumedia_params_PEQ {
-	uint32_t				v1;
-	uint16_t				v2;
-	uint16_t				v3;
-	uint16_t				v4;
-	uint16_t				v____A1;
-	uint32_t				v5[26];
-	uint32_t				v6[26];
-} __packed;
-
-struct srs_trumedia_params_HL {
-	uint16_t				v1;
-	uint16_t				v2;
-	uint16_t				v3;
-	uint16_t				v____A1;
-	int32_t					v4;
-	uint32_t				v5;
-	uint16_t				v6;
-	uint16_t				v____A2;
-	uint32_t				v7;
-} __packed;
-
-struct srs_trumedia_params {
-	struct srs_trumedia_params_GLOBAL	global;
-	struct srs_trumedia_params_WOWHD	wowhd;
-	struct srs_trumedia_params_CSHP		cshp;
-	struct srs_trumedia_params_HPF		hpf;
-	struct srs_trumedia_params_PEQ		peq;
-	struct srs_trumedia_params_HL		hl;
-} __packed;
-
-int srs_trumedia_open(int port_id, int srs_tech_id, void *srs_params);
-/* SRS TruMedia end */
-
-/* SRS Studio Sound 3D start */
-#define SRS_ID_SS3D_GLOBAL	0x00000001
-#define SRS_ID_SS3D_CTRL	0x00000002
-#define SRS_ID_SS3D_FILTER	0x00000003
-
-struct srs_SS3D_params_GLOBAL {
-	uint8_t                  v1;
-	uint8_t                  v2;
-	uint8_t                  v3;
-	uint8_t                  v4;
-	uint8_t                  v5;
-	uint8_t                  v6;
-	uint8_t                  v7;
-	uint8_t                  v8;
-} __packed;
-
-struct srs_SS3D_ctrl_params {
-	uint8_t				v[236];
-} __packed;
-
-struct srs_SS3D_filter_params {
-	uint8_t				v[28 + 2752];
-} __packed;
-
-struct srs_SS3D_params {
-	struct srs_SS3D_params_GLOBAL   global;
-	struct srs_SS3D_ctrl_params     ss3d;
-	struct srs_SS3D_filter_params   ss3d_f;
-} __packed;
-
-int srs_ss3d_open(int port_id, int srs_tech_id, void *srs_params);
-/* SRS Studio Sound 3D end */
-#endif /*_APR_AUDIO_H_*/
diff --git a/include/sound/audio_cal_utils.h b/include/sound/audio_cal_utils.h
deleted file mode 100644
index b28b3bd..0000000
--- a/include/sound/audio_cal_utils.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _AUDIO_CAL_UTILS_H
-#define _AUDIO_CAL_UTILS_H
-
-#include <linux/msm_ion.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/msm_audio_calibration.h>
-#include "audio_calibration.h"
-
-struct cal_data {
-	size_t		size;
-	void		*kvaddr;
-	phys_addr_t	paddr;
-};
-
-struct mem_map_data {
-	size_t			map_size;
-	int32_t			q6map_handle;
-	int32_t			ion_map_handle;
-	struct ion_client	*ion_client;
-	struct ion_handle	*ion_handle;
-};
-
-struct cal_block_data {
-	size_t			client_info_size;
-	void			*client_info;
-	void			*cal_info;
-	struct list_head	list;
-	struct cal_data		cal_data;
-	struct mem_map_data	map_data;
-	int32_t			buffer_number;
-};
-
-struct cal_util_callbacks {
-	int (*map_cal)
-		(int32_t cal_type, struct cal_block_data *cal_block);
-	int (*unmap_cal)
-		(int32_t cal_type, struct cal_block_data *cal_block);
-	bool (*match_block)
-		(struct cal_block_data *cal_block, void *user_data);
-};
-
-struct cal_type_info {
-	struct audio_cal_reg		reg;
-	struct cal_util_callbacks	cal_util_callbacks;
-};
-
-struct cal_type_data {
-	struct cal_type_info		info;
-	struct mutex			lock;
-	struct list_head		cal_blocks;
-};
-
-
-/* to register & degregister with cal util driver */
-int cal_utils_create_cal_types(int num_cal_types,
-			struct cal_type_data **cal_type,
-			struct cal_type_info *info);
-void cal_utils_destroy_cal_types(int num_cal_types,
-			struct cal_type_data **cal_type);
-
-/* common functions for callbacks */
-int cal_utils_alloc_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type,
-			size_t client_info_size, void *client_info);
-int cal_utils_dealloc_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type);
-int cal_utils_set_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type,
-			size_t client_info_size, void *client_info);
-
-/* use for SSR */
-void cal_utils_clear_cal_block_q6maps(int num_cal_types,
-					struct cal_type_data **cal_type);
-
-
-/* common matching functions used to add blocks */
-bool cal_utils_match_buf_num(struct cal_block_data *cal_block,
-					void *user_data);
-
-/* common matching functions to find cal blocks */
-struct cal_block_data *cal_utils_get_only_cal_block(
-			struct cal_type_data *cal_type);
-
-/* Size of calibration specific data */
-size_t get_cal_info_size(int32_t cal_type);
-size_t get_user_cal_type_size(int32_t cal_type);
-
-/* Version of the cal type*/
-int32_t cal_utils_get_cal_type_version(void *cal_type_data);
-#endif
diff --git a/include/sound/audio_calibration.h b/include/sound/audio_calibration.h
deleted file mode 100644
index 5decff9..0000000
--- a/include/sound/audio_calibration.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (c) 2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _AUDIO_CALIBRATION_H
-#define _AUDIO_CALIBRATION_H
-
-#include <linux/msm_audio_calibration.h>
-
-/* Used by driver in buffer_number field to notify client
- * To update all blocks, for example: freeing all memory
- */
-#define ALL_CAL_BLOCKS		-1
-
-
-struct audio_cal_callbacks {
-	int (*alloc)(int32_t cal_type, size_t data_size, void *data);
-	int (*dealloc)(int32_t cal_type, size_t data_size, void *data);
-	int (*pre_cal)(int32_t cal_type, size_t data_size, void *data);
-	int (*set_cal)(int32_t cal_type, size_t data_size, void *data);
-	int (*get_cal)(int32_t cal_type, size_t data_size, void *data);
-	int (*post_cal)(int32_t cal_type, size_t data_size, void *data);
-};
-
-struct audio_cal_reg {
-	int32_t				cal_type;
-	struct audio_cal_callbacks	callbacks;
-};
-
-int audio_cal_register(int num_cal_types, struct audio_cal_reg *reg_data);
-int audio_cal_deregister(int num_cal_types, struct audio_cal_reg *reg_data);
-
-#endif
diff --git a/include/sound/audio_slimslave.h b/include/sound/audio_slimslave.h
deleted file mode 100644
index 316a557..0000000
--- a/include/sound/audio_slimslave.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __AUDIO_SLIMSLAVE_H__
-#define __AUDIO_SLIMSLAVE_H__
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-
-#define AUDIO_SLIMSLAVE_IOCTL_NAME "audio_slimslave"
-#define AUDIO_SLIMSLAVE_MAGIC 'S'
-
-#define AUDIO_SLIMSLAVE_IOCTL_UNVOTE	_IO(AUDIO_SLIMSLAVE_MAGIC, 0x00)
-#define AUDIO_SLIMSLAVE_IOCTL_VOTE	_IO(AUDIO_SLIMSLAVE_MAGIC, 0x01)
-
-enum {
-	AUDIO_SLIMSLAVE_UNVOTE,
-	AUDIO_SLIMSLAVE_VOTE
-};
-
-#endif
diff --git a/include/sound/cpe_cmi.h b/include/sound/cpe_cmi.h
deleted file mode 100644
index cbf83e7..0000000
--- a/include/sound/cpe_cmi.h
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright (c) 2014-2016, Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CPE_CMI_H__
-#define __CPE_CMI_H__
-
-#include <linux/types.h>
-
-#define CPE_AFE_PORT_1_TX 1
-#define CPE_AFE_PORT_3_TX 3
-#define CPE_AFE_PORT_ID_2_OUT 0x02
-#define CMI_INBAND_MESSAGE_SIZE 127
-
-/*
- * Multiple mad types can be supported at once.
- * these values can be OR'ed to form the set of
- * supported mad types
- */
-#define MAD_TYPE_AUDIO (1 << 0)
-#define MAD_TYPE_BEACON (1 << 1)
-#define MAD_TYPE_ULTRASND (1 << 2)
-
-/* Core service command opcodes */
-#define CPE_CORE_SVC_CMD_SHARED_MEM_ALLOC	(0x3001)
-#define CPE_CORE_SVC_CMDRSP_SHARED_MEM_ALLOC	(0x3002)
-#define CPE_CORE_SVC_CMD_SHARED_MEM_DEALLOC	(0x3003)
-#define CPE_CORE_SVC_CMD_DRAM_ACCESS_REQ	(0x3004)
-#define CPE_CORE_SVC_EVENT_SYSTEM_BOOT		(0x3005)
-/* core service command opcodes for WCD9335 */
-#define CPE_CORE_SVC_CMD_CFG_CLK_PLAN		(0x3006)
-#define CPE_CORE_SVC_CMD_CLK_FREQ_REQUEST	(0x3007)
-
-#define CPE_BOOT_SUCCESS 0x00
-#define CPE_BOOT_FAILED 0x01
-
-#define CPE_CORE_VERSION_SYSTEM_BOOT_EVENT 0x01
-
-/* LSM Service command opcodes */
-#define CPE_LSM_SESSION_CMD_OPEN_TX		(0x2000)
-#define CPE_LSM_SESSION_CMD_SET_PARAMS		(0x2001)
-#define CPE_LSM_SESSION_CMD_REGISTER_SOUND_MODEL (0x2002)
-#define CPE_LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL (0x2003)
-#define CPE_LSM_SESSION_CMD_START		(0x2004)
-#define CPE_LSM_SESSION_CMD_STOP		(0x2005)
-#define CPE_LSM_SESSION_EVENT_DETECTION_STATUS_V2 (0x2006)
-#define CPE_LSM_SESSION_CMD_CLOSE_TX		(0x2007)
-#define CPE_LSM_SESSION_CMD_SHARED_MEM_ALLOC	(0x2008)
-#define CPE_LSM_SESSION_CMDRSP_SHARED_MEM_ALLOC (0x2009)
-#define CPE_LSM_SESSION_CMD_SHARED_MEM_DEALLOC	(0x200A)
-#define CPE_LSM_SESSION_CMD_TX_BUFF_OUTPUT_CONFIG (0x200f)
-#define CPE_LSM_SESSION_CMD_OPEN_TX_V2		(0x200D)
-#define CPE_LSM_SESSION_CMD_SET_PARAMS_V2	(0x200E)
-
-/* LSM Service module and param IDs */
-#define CPE_LSM_MODULE_ID_VOICE_WAKEUP		(0x00012C00)
-#define CPE_LSM_MODULE_ID_VOICE_WAKEUP_V2	(0x00012C0D)
-#define CPE_LSM_MODULE_FRAMEWORK		(0x00012C0E)
-
-#define CPE_LSM_PARAM_ID_ENDPOINT_DETECT_THRESHOLD (0x00012C01)
-#define CPE_LSM_PARAM_ID_OPERATION_MODE		(0x00012C02)
-#define CPE_LSM_PARAM_ID_GAIN			(0x00012C03)
-#define CPE_LSM_PARAM_ID_CONNECT_TO_PORT	(0x00012C04)
-#define CPE_LSM_PARAM_ID_MIN_CONFIDENCE_LEVELS	(0x00012C07)
-
-/* LSM LAB command opcodes */
-#define CPE_LSM_SESSION_CMD_EOB		0x0000200B
-#define CPE_LSM_MODULE_ID_LAB		0x00012C08
-/* used for enable/disable lab*/
-#define CPE_LSM_PARAM_ID_LAB_ENABLE	0x00012C09
-/* used for T in LAB config DSP internal buffer*/
-#define CPE_LSM_PARAM_ID_LAB_CONFIG	0x00012C0A
-#define CPE_LSM_PARAM_ID_REGISTER_SOUND_MODEL	(0x00012C14)
-#define CPE_LSM_PARAM_ID_DEREGISTER_SOUND_MODEL	(0x00012C15)
-#define CPE_LSM_PARAM_ID_MEDIA_FMT		(0x00012C1E)
-
-/* AFE Service command opcodes */
-#define CPE_AFE_PORT_CMD_START			(0x1001)
-#define CPE_AFE_PORT_CMD_STOP			(0x1002)
-#define CPE_AFE_PORT_CMD_SUSPEND		(0x1003)
-#define CPE_AFE_PORT_CMD_RESUME			(0x1004)
-#define CPE_AFE_PORT_CMD_SHARED_MEM_ALLOC	(0x1005)
-#define CPE_AFE_PORT_CMDRSP_SHARED_MEM_ALLOC	(0x1006)
-#define CPE_AFE_PORT_CMD_SHARED_MEM_DEALLOC	(0x1007)
-#define CPE_AFE_PORT_CMD_GENERIC_CONFIG		(0x1008)
-#define CPE_AFE_SVC_CMD_LAB_MODE		(0x1009)
-
-/* AFE Service module and param IDs */
-#define CPE_AFE_CMD_SET_PARAM			(0x1000)
-#define CPE_AFE_MODULE_ID_SW_MAD		(0x0001022D)
-#define CPE_AFE_PARAM_ID_SW_MAD_CFG		(0x0001022E)
-#define CPE_AFE_PARAM_ID_SVM_MODEL		(0x0001022F)
-
-#define CPE_AFE_MODULE_HW_MAD			(0x00010230)
-#define CPE_AFE_PARAM_ID_HW_MAD_CTL		(0x00010232)
-#define CPE_AFE_PARAM_ID_HW_MAD_CFG		(0x00010231)
-
-#define CPE_AFE_MODULE_AUDIO_DEV_INTERFACE	(0x0001020C)
-#define CPE_AFE_PARAM_ID_GENERIC_PORT_CONFIG	(0x00010253)
-
-#define CPE_CMI_BASIC_RSP_OPCODE	(0x0001)
-#define CPE_HDR_MAX_PLD_SIZE	(0x7F)
-
-#define CMI_OBM_FLAG_IN_BAND	0
-#define CMI_OBM_FLAG_OUT_BAND	1
-
-#define CMI_SHMEM_ALLOC_FAILED 0xff
-
-/*
- * Future Service ID's can be added one line
- * before the CMI_CPE_SERVICE_ID_MAX
- */
-enum {
-	CMI_CPE_SERVICE_ID_MIN = 0,
-	CMI_CPE_CORE_SERVICE_ID,
-	CMI_CPE_AFE_SERVICE_ID,
-	CMI_CPE_LSM_SERVICE_ID,
-	CMI_CPE_SERVICE_ID_MAX,
-};
-
-#define CPE_LSM_SESSION_ID_MAX 2
-
-#define IS_VALID_SESSION_ID(s_id) \
-	(s_id <= CPE_LSM_SESSION_ID_MAX)
-
-#define IS_VALID_SERVICE_ID(s_id) \
-	(s_id > CMI_CPE_SERVICE_ID_MIN && \
-	 s_id < CMI_CPE_SERVICE_ID_MAX)
-
-#define IS_VALID_PLD_SIZE(p_size) \
-	(p_size <= CPE_HDR_MAX_PLD_SIZE)
-
-#define CMI_HDR_SET_OPCODE(hdr, cmd) (hdr->opcode = cmd)
-
-
-#define CMI_HDR_SET(hdr_info, mask, shift, value) \
-		(hdr_info = (((hdr_info) & ~(mask)) | \
-			((value << shift) & mask)))
-
-#define SVC_ID_SHIFT 4
-#define SVC_ID_MASK (0x07 << SVC_ID_SHIFT)
-
-#define SESSION_ID_SHIFT 0
-#define SESSION_ID_MASK (0x0F << SESSION_ID_SHIFT)
-
-#define PAYLD_SIZE_SHIFT 0
-#define PAYLD_SIZE_MASK (0x7F << PAYLD_SIZE_SHIFT)
-
-#define OBM_FLAG_SHIFT 7
-#define OBM_FLAG_MASK (1 << OBM_FLAG_SHIFT)
-
-#define VERSION_SHIFT 7
-#define VERSION_MASK (1 << VERSION_SHIFT)
-
-#define CMI_HDR_SET_SERVICE(hdr, s_id) \
-		CMI_HDR_SET(hdr->hdr_info, SVC_ID_MASK,\
-			    SVC_ID_SHIFT, s_id)
-#define CMI_HDR_GET_SERVICE(hdr) \
-		((hdr->hdr_info >> SVC_ID_SHIFT) & \
-			(SVC_ID_MASK >> SVC_ID_SHIFT))
-
-
-#define CMI_HDR_SET_SESSION(hdr, s_id) \
-		CMI_HDR_SET(hdr->hdr_info, SESSION_ID_MASK,\
-			    SESSION_ID_SHIFT, s_id)
-
-#define CMI_HDR_GET_SESSION_ID(hdr) \
-		((hdr->hdr_info >> SESSION_ID_SHIFT) & \
-			 (SESSION_ID_MASK >> SESSION_ID_SHIFT))
-
-#define CMI_GET_HEADER(msg)	((struct cmi_hdr *)(msg))
-#define CMI_GET_PAYLOAD(msg)	((void *)(CMI_GET_HEADER(msg) + 1))
-#define CMI_GET_OPCODE(msg)	(CMI_GET_HEADER(msg)->opcode)
-
-#define CMI_HDR_SET_VERSION(hdr, ver) \
-		CMI_HDR_SET(hdr->hdr_info, VERSION_MASK, \
-				VERSION_SHIFT, ver)
-
-#define CMI_HDR_SET_PAYLOAD_SIZE(hdr, p_size) \
-		CMI_HDR_SET(hdr->pld_info, PAYLD_SIZE_MASK, \
-			    PAYLD_SIZE_SHIFT, p_size)
-
-#define CMI_HDR_GET_PAYLOAD_SIZE(hdr) \
-		((hdr->pld_info >> PAYLD_SIZE_SHIFT) & \
-			(PAYLD_SIZE_MASK >> PAYLD_SIZE_SHIFT))
-
-#define CMI_HDR_SET_OBM(hdr, obm_flag) \
-		CMI_HDR_SET(hdr->pld_info, OBM_FLAG_MASK, \
-			    OBM_FLAG_SHIFT, obm_flag)
-
-#define CMI_HDR_GET_OBM_FLAG(hdr) \
-	((hdr->pld_info >> OBM_FLAG_SHIFT) & \
-		(OBM_FLAG_MASK >> OBM_FLAG_SHIFT))
-
-struct cmi_hdr {
-	/*
-	 * bits 0:3 is session id
-	 * bits 4:6 is service id
-	 * bit 7 is the version flag
-	 */
-	u8 hdr_info;
-
-	/*
-	 * bits 0:6 is payload size in case of in-band message
-	 * bits 0:6 is size (OBM message size)
-	 * bit 7 is the OBM flag
-	 */
-	u8 pld_info;
-
-	/* 16 bit command opcode */
-	u16 opcode;
-} __packed;
-
-union cpe_addr {
-	u64 msw_lsw;
-	void *kvaddr;
-} __packed;
-
-struct cmi_obm {
-	u32 version;
-	u32 size;
-	union cpe_addr data_ptr;
-	u32 mem_handle;
-} __packed;
-
-struct cmi_obm_msg {
-	struct cmi_hdr hdr;
-	struct cmi_obm pld;
-} __packed;
-
-struct cmi_core_svc_event_system_boot {
-	u8 status;
-	u8 version;
-	u16 sfr_buff_size;
-	u32 sfr_buff_address;
-} __packed;
-
-struct cmi_core_svc_cmd_shared_mem_alloc {
-	u32 size;
-} __packed;
-
-struct cmi_core_svc_cmdrsp_shared_mem_alloc {
-	u32 addr;
-} __packed;
-
-struct cmi_core_svc_cmd_clk_freq_request {
-	u32 clk_freq;
-} __packed;
-
-struct cmi_msg_transport {
-	u32 size;
-	u32 addr;
-} __packed;
-
-struct cmi_basic_rsp_result {
-	u8 status;
-} __packed;
-
-struct cpe_lsm_cmd_open_tx {
-	struct cmi_hdr	hdr;
-	u16 app_id;
-	u16 reserved;
-	u32 sampling_rate;
-} __packed;
-
-struct cpe_lsm_cmd_open_tx_v2 {
-	struct cmi_hdr hdr;
-	u32 topology_id;
-} __packed;
-
-struct cpe_cmd_shmem_alloc {
-	struct cmi_hdr hdr;
-	u32 size;
-} __packed;
-
-struct cpe_cmdrsp_shmem_alloc {
-	struct cmi_hdr hdr;
-	u32 addr;
-} __packed;
-
-struct cpe_cmd_shmem_dealloc {
-	struct cmi_hdr	hdr;
-	u32 addr;
-} __packed;
-
-struct cpe_lsm_event_detect_v2 {
-	struct cmi_hdr	hdr;
-	u8 detection_status;
-	u8 size;
-	u8 payload[0];
-} __packed;
-
-struct cpe_lsm_psize_res {
-	u16 param_size;
-	u16 reserved;
-} __packed;
-
-union cpe_lsm_param_size {
-	u32 param_size;
-	struct cpe_lsm_psize_res sr;
-} __packed;
-
-struct cpe_param_data {
-	u32 module_id;
-	u32 param_id;
-	union cpe_lsm_param_size p_size;
-} __packed;
-
-struct cpe_lsm_param_epd_thres {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u32 minor_version;
-	u32 epd_begin;
-	u32 epd_end;
-} __packed;
-
-struct cpe_lsm_param_gain {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u32 minor_version;
-	u16 gain;
-	u16 reserved;
-} __packed;
-
-struct cpe_afe_hw_mad_ctrl {
-	struct cpe_param_data param;
-	u32 minor_version;
-	u16 mad_type;
-	u16 mad_enable;
-} __packed;
-
-struct cpe_afe_port_cfg {
-	struct cpe_param_data param;
-	u32 minor_version;
-	u16 bit_width;
-	u16 num_channels;
-	u32 sample_rate;
-} __packed;
-
-struct cpe_afe_cmd_port_cfg {
-	struct cmi_hdr hdr;
-	u8 bit_width;
-	u8 num_channels;
-	u16 buffer_size;
-	u32 sample_rate;
-} __packed;
-
-struct cpe_afe_params {
-	struct cmi_hdr hdr;
-	struct cpe_afe_hw_mad_ctrl hw_mad_ctrl;
-	struct cpe_afe_port_cfg port_cfg;
-} __packed;
-
-struct cpe_afe_svc_cmd_mode {
-	struct cmi_hdr hdr;
-	u8 mode;
-} __packed;
-
-struct cpe_lsm_param_opmode {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u32 minor_version;
-	u16 mode;
-	u16 reserved;
-} __packed;
-
-struct cpe_lsm_param_connectport {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u32 minor_version;
-	u16 afe_port_id;
-	u16 reserved;
-} __packed;
-
-/*
- * This cannot be sent to CPE as is,
- * need to append the conf_levels dynamically
- */
-struct cpe_lsm_conf_level {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u8 num_active_models;
-} __packed;
-
-struct cpe_lsm_output_format_cfg {
-	struct cmi_hdr hdr;
-	u8 format;
-	u8 packing;
-	u8 data_path_events;
-} __packed;
-
-struct cpe_lsm_lab_enable {
-	struct cpe_param_data param;
-	u16 enable;
-	u16 reserved;
-} __packed;
-
-struct cpe_lsm_control_lab {
-	struct cmi_hdr hdr;
-	struct cpe_lsm_lab_enable lab_enable;
-} __packed;
-
-struct cpe_lsm_lab_config {
-	struct cpe_param_data param;
-	u32 minor_ver;
-	u32 latency;
-} __packed;
-
-struct cpe_lsm_lab_latency_config {
-	struct cmi_hdr hdr;
-	struct cpe_lsm_lab_config latency_cfg;
-} __packed;
-
-struct cpe_lsm_media_fmt_param {
-	struct cmi_hdr hdr;
-	struct cpe_param_data param;
-	u32 minor_version;
-	u32 sample_rate;
-	u16 num_channels;
-	u16 bit_width;
-} __packed;
-
-
-#define CPE_PARAM_LSM_LAB_LATENCY_SIZE (\
-				sizeof(struct cpe_lsm_lab_latency_config) - \
-				sizeof(struct cmi_hdr))
-#define PARAM_SIZE_LSM_LATENCY_SIZE (\
-					sizeof(struct cpe_lsm_lab_config) - \
-					sizeof(struct cpe_param_data))
-#define CPE_PARAM_SIZE_LSM_LAB_CONTROL (\
-				sizeof(struct cpe_lsm_control_lab) - \
-				sizeof(struct cmi_hdr))
-#define PARAM_SIZE_LSM_CONTROL_SIZE (sizeof(struct cpe_lsm_lab_enable) - \
-					sizeof(struct cpe_param_data))
-#define PARAM_SIZE_AFE_HW_MAD_CTRL (sizeof(struct cpe_afe_hw_mad_ctrl) - \
-				sizeof(struct cpe_param_data))
-#define PARAM_SIZE_AFE_PORT_CFG (sizeof(struct cpe_afe_port_cfg) - \
-				 sizeof(struct cpe_param_data))
-#define CPE_AFE_PARAM_PAYLOAD_SIZE (sizeof(struct cpe_afe_params) - \
-				sizeof(struct cmi_hdr))
-
-#define OPEN_CMD_PAYLOAD_SIZE (sizeof(struct cpe_lsm_cmd_open_tx) - \
-			       sizeof(struct cmi_hdr))
-#define OPEN_V2_CMD_PAYLOAD_SIZE (sizeof(struct cpe_lsm_cmd_open_tx_v2) - \
-			       sizeof(struct cmi_hdr))
-#define SHMEM_ALLOC_CMD_PLD_SIZE (sizeof(struct cpe_cmd_shmem_alloc) - \
-				      sizeof(struct cmi_hdr))
-
-#define SHMEM_DEALLOC_CMD_PLD_SIZE (sizeof(struct cpe_cmd_shmem_dealloc) - \
-				      sizeof(struct cmi_hdr))
-#define OUT_FMT_CFG_CMD_PAYLOAD_SIZE ( \
-		sizeof(struct cpe_lsm_output_format_cfg) - \
-		sizeof(struct cmi_hdr))
-
-#define CPE_AFE_CMD_PORT_CFG_PAYLOAD_SIZE \
-		(sizeof(struct cpe_afe_cmd_port_cfg) - \
-		 sizeof(struct cmi_hdr))
-
-#define CPE_AFE_CMD_MODE_PAYLOAD_SIZE \
-		(sizeof(struct cpe_afe_svc_cmd_mode) - \
-		 sizeof(struct cmi_hdr))
-#define CPE_CMD_EPD_THRES_PLD_SIZE (sizeof(struct cpe_lsm_param_epd_thres) - \
-				    sizeof(struct cmi_hdr))
-#define CPE_EPD_THRES_PARAM_SIZE ((CPE_CMD_EPD_THRES_PLD_SIZE) - \
-				  sizeof(struct cpe_param_data))
-#define CPE_CMD_OPMODE_PLD_SIZE (sizeof(struct cpe_lsm_param_opmode) - \
-				 sizeof(struct cmi_hdr))
-#define CPE_OPMODE_PARAM_SIZE ((CPE_CMD_OPMODE_PLD_SIZE) -\
-			       sizeof(struct cpe_param_data))
-#define CPE_CMD_CONNECTPORT_PLD_SIZE \
-	(sizeof(struct cpe_lsm_param_connectport) - \
-	 sizeof(struct cmi_hdr))
-#define CPE_CONNECTPORT_PARAM_SIZE ((CPE_CMD_CONNECTPORT_PLD_SIZE) - \
-				    sizeof(struct cpe_param_data))
-#define CPE_CMD_GAIN_PLD_SIZE (sizeof(struct cpe_lsm_param_gain) - \
-			       sizeof(struct cmi_hdr))
-#define CPE_GAIN_PARAM_SIZE ((CPE_CMD_GAIN_PLD_SIZE) - \
-			     sizeof(struct cpe_param_data))
-#define CPE_MEDIA_FMT_PLD_SIZE (sizeof(struct cpe_lsm_media_fmt_param) - \
-				sizeof(struct cmi_hdr))
-#define CPE_MEDIA_FMT_PARAM_SIZE ((CPE_MEDIA_FMT_PLD_SIZE) - \
-				  sizeof(struct cpe_param_data))
-#endif /* __CPE_CMI_H__ */
diff --git a/include/sound/cpe_core.h b/include/sound/cpe_core.h
deleted file mode 100644
index 411c2ff..0000000
--- a/include/sound/cpe_core.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2013-2017, Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CPE_CORE_H__
-#define __CPE_CORE_H__
-
-#include <linux/types.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <sound/lsm_params.h>
-
-enum {
-	CMD_INIT_STATE = 0,
-	CMD_SENT,
-	CMD_RESP_RCVD,
-};
-
-enum wcd_cpe_event {
-	WCD_CPE_PRE_ENABLE = 1,
-	WCD_CPE_POST_ENABLE,
-	WCD_CPE_PRE_DISABLE,
-	WCD_CPE_POST_DISABLE,
-};
-
-struct wcd_cpe_afe_port_cfg {
-	u8 port_id;
-	u16 bit_width;
-	u16 num_channels;
-	u32 sample_rate;
-};
-
-struct lsm_out_fmt_cfg {
-	u8 format;
-	u8 pack_mode;
-	u8 data_path_events;
-	u8 transfer_mode;
-};
-
-struct lsm_hw_params {
-	u32 sample_rate;
-	u16 num_chs;
-	u16 bit_width;
-};
-
-struct cpe_lsm_session {
-	/* sound model related */
-	void *snd_model_data;
-	u8 *conf_levels;
-	void *cmi_reg_handle;
-
-	/* Clients private data */
-	void *priv_d;
-
-	void (*event_cb)(void *priv_data,
-			  u8 detect_status,
-			  u8 size, u8 *payload);
-
-	struct completion cmd_comp;
-	struct wcd_cpe_afe_port_cfg afe_port_cfg;
-	struct wcd_cpe_afe_port_cfg afe_out_port_cfg;
-	struct mutex lsm_lock;
-
-	u32 snd_model_size;
-	u32 lsm_mem_handle;
-	u16 cmd_err_code;
-	u8 id;
-	u8 num_confidence_levels;
-	u16 afe_out_port_id;
-	struct task_struct *lsm_lab_thread;
-	bool started;
-
-	u32 lab_enable;
-	struct lsm_out_fmt_cfg out_fmt_cfg;
-
-	bool is_topology_used;
-};
-
-struct wcd_cpe_afe_ops {
-	int (*afe_set_params)(void *core_handle,
-			       struct wcd_cpe_afe_port_cfg *cfg,
-			       bool afe_mad_ctl);
-
-	int (*afe_port_start)(void *core_handle,
-			       struct wcd_cpe_afe_port_cfg *cfg);
-
-	int (*afe_port_stop)(void *core_handle,
-			       struct wcd_cpe_afe_port_cfg *cfg);
-
-	int (*afe_port_suspend)(void *core_handle,
-			       struct wcd_cpe_afe_port_cfg *cfg);
-
-	int (*afe_port_resume)(void *core_handle,
-			       struct wcd_cpe_afe_port_cfg *cfg);
-
-	int (*afe_port_cmd_cfg)(void *core_handle,
-				struct wcd_cpe_afe_port_cfg *cfg);
-};
-
-struct wcd_cpe_lsm_ops {
-
-	struct cpe_lsm_session *(*lsm_alloc_session)
-			(void *core_handle, void *lsm_priv_d,
-			 void (*event_cb)(void *priv_data,
-					   u8 detect_status,
-					   u8 size, u8 *payload));
-
-	int (*lsm_dealloc_session)
-		(void *core_handle, struct cpe_lsm_session *);
-
-	int (*lsm_open_tx)(void *core_handle,
-			    struct cpe_lsm_session *, u16, u16);
-
-	int (*lsm_close_tx)(void *core_handle,
-			     struct cpe_lsm_session *);
-
-	int (*lsm_shmem_alloc)(void *core_handle,
-				struct cpe_lsm_session *, u32 size);
-
-	int (*lsm_shmem_dealloc)(void *core_handle,
-				  struct cpe_lsm_session *);
-
-	int (*lsm_register_snd_model)(void *core_handle,
-				       struct cpe_lsm_session *,
-				       enum lsm_detection_mode, bool);
-
-	int (*lsm_deregister_snd_model)(void *core_handle,
-					 struct cpe_lsm_session *);
-
-	int (*lsm_get_afe_out_port_id)(void *core_handle,
-			       struct cpe_lsm_session *session);
-
-	int (*lsm_start)(void *core_handle,
-			  struct cpe_lsm_session *);
-
-	int (*lsm_stop)(void *core_handle,
-			 struct cpe_lsm_session *);
-
-	int (*lsm_lab_control)(void *core_handle,
-			       struct cpe_lsm_session *session,
-			       bool enable);
-
-	int (*lab_ch_setup)(void *core_handle,
-				   struct cpe_lsm_session *session,
-				   enum wcd_cpe_event event);
-
-	int (*lsm_set_data)(void *core_handle,
-			struct cpe_lsm_session *session,
-			enum lsm_detection_mode detect_mode,
-			bool detect_failure);
-	int (*lsm_set_fmt_cfg)(void *core_handle,
-			struct cpe_lsm_session *session);
-	int (*lsm_set_one_param)(void *core_handle,
-			struct cpe_lsm_session *session,
-			struct lsm_params_info *p_info,
-			void *data, uint32_t param_type);
-	void (*lsm_get_snd_model_offset)
-		(void *core_handle, struct cpe_lsm_session *,
-		 size_t *offset);
-	int (*lsm_set_media_fmt_params)(void *core_handle,
-				       struct cpe_lsm_session *session,
-				       struct lsm_hw_params *param);
-	int (*lsm_set_port)(void *core_handle,
-			    struct cpe_lsm_session *session, void *data);
-};
-
-int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops);
-int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops);
-void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec);
-#endif
diff --git a/include/sound/cpe_err.h b/include/sound/cpe_err.h
deleted file mode 100644
index d355803..0000000
--- a/include/sound/cpe_err.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CPE_ERR__
-#define __CPE_ERR__
-
-#include <linux/errno.h>
-
-/* ERROR CODES */
-/* Success. The operation completed with no errors. */
-#define CPE_EOK          0x00000000
-/* General failure. */
-#define CPE_EFAILED      0x00000001
-/* Bad operation parameter. */
-#define CPE_EBADPARAM    0x00000002
-/* Unsupported routine or operation. */
-#define CPE_EUNSUPPORTED 0x00000003
-/* Unsupported version. */
-#define CPE_EVERSION     0x00000004
-/* Unexpected problem encountered. */
-#define CPE_EUNEXPECTED  0x00000005
-/* Unhandled problem occurred. */
-#define CPE_EPANIC       0x00000006
-/* Unable to allocate resource. */
-#define CPE_ENORESOURCE  0x00000007
-/* Invalid handle. */
-#define CPE_EHANDLE      0x00000008
-/* Operation is already processed. */
-#define CPE_EALREADY     0x00000009
-/* Operation is not ready to be processed. */
-#define CPE_ENOTREADY    0x0000000A
-/* Operation is pending completion. */
-#define CPE_EPENDING     0x0000000B
-/* Operation could not be accepted or processed. */
-#define CPE_EBUSY        0x0000000C
-/* Operation aborted due to an error. */
-#define CPE_EABORTED     0x0000000D
-/* Operation preempted by a higher priority. */
-#define CPE_EPREEMPTED   0x0000000E
-/* Operation requests intervention to complete. */
-#define CPE_ECONTINUE    0x0000000F
-/* Operation requests immediate intervention to complete. */
-#define CPE_EIMMEDIATE   0x00000010
-/* Operation is not implemented. */
-#define CPE_ENOTIMPL     0x00000011
-/* Operation needs more data or resources. */
-#define CPE_ENEEDMORE    0x00000012
-/* Operation does not have memory. */
-#define CPE_ENOMEMORY    0x00000014
-/* Item does not exist. */
-#define CPE_ENOTEXIST    0x00000015
-/* Operation is finished. */
-#define CPE_ETERMINATED  0x00000016
-/* Max count for adsp error code sent to HLOS*/
-#define CPE_ERR_MAX      (CPE_ETERMINATED + 1)
-
-
-/* ERROR STRING */
-/* Success. The operation completed with no errors. */
-#define CPE_EOK_STR          "CPE_EOK"
-/* General failure. */
-#define CPE_EFAILED_STR      "CPE_EFAILED"
-/* Bad operation parameter. */
-#define CPE_EBADPARAM_STR    "CPE_EBADPARAM"
-/* Unsupported routine or operation. */
-#define CPE_EUNSUPPORTED_STR "CPE_EUNSUPPORTED"
-/* Unsupported version. */
-#define CPE_EVERSION_STR     "CPE_EVERSION"
-/* Unexpected problem encountered. */
-#define CPE_EUNEXPECTED_STR  "CPE_EUNEXPECTED"
-/* Unhandled problem occurred. */
-#define CPE_EPANIC_STR       "CPE_EPANIC"
-/* Unable to allocate resource. */
-#define CPE_ENORESOURCE_STR  "CPE_ENORESOURCE"
-/* Invalid handle. */
-#define CPE_EHANDLE_STR      "CPE_EHANDLE"
-/* Operation is already processed. */
-#define CPE_EALREADY_STR     "CPE_EALREADY"
-/* Operation is not ready to be processed. */
-#define CPE_ENOTREADY_STR    "CPE_ENOTREADY"
-/* Operation is pending completion. */
-#define CPE_EPENDING_STR     "CPE_EPENDING"
-/* Operation could not be accepted or processed. */
-#define CPE_EBUSY_STR        "CPE_EBUSY"
-/* Operation aborted due to an error. */
-#define CPE_EABORTED_STR     "CPE_EABORTED"
-/* Operation preempted by a higher priority. */
-#define CPE_EPREEMPTED_STR   "CPE_EPREEMPTED"
-/* Operation requests intervention to complete. */
-#define CPE_ECONTINUE_STR    "CPE_ECONTINUE"
-/* Operation requests immediate intervention to complete. */
-#define CPE_EIMMEDIATE_STR   "CPE_EIMMEDIATE"
-/* Operation is not implemented. */
-#define CPE_ENOTIMPL_STR     "CPE_ENOTIMPL"
-/* Operation needs more data or resources. */
-#define CPE_ENEEDMORE_STR    "CPE_ENEEDMORE"
-/* Operation does not have memory. */
-#define CPE_ENOMEMORY_STR    "CPE_ENOMEMORY"
-/* Item does not exist. */
-#define CPE_ENOTEXIST_STR    "CPE_ENOTEXIST"
-/* Operation is finished. */
-#define CPE_ETERMINATED_STR  "CPE_ETERMINATED"
-/* Unexpected error code. */
-#define CPE_ERR_MAX_STR      "CPE_ERR_MAX"
-
-
-struct cpe_err_code {
-	int     lnx_err_code;
-	char    *cpe_err_str;
-};
-
-
-static struct cpe_err_code cpe_err_code_info[CPE_ERR_MAX+1] = {
-	{ 0, CPE_EOK_STR},
-	{ -ENOTRECOVERABLE, CPE_EFAILED_STR},
-	{ -EINVAL, CPE_EBADPARAM_STR},
-	{ -EOPNOTSUPP, CPE_EUNSUPPORTED_STR},
-	{ -ENOPROTOOPT, CPE_EVERSION_STR},
-	{ -ENOTRECOVERABLE, CPE_EUNEXPECTED_STR},
-	{ -ENOTRECOVERABLE, CPE_EPANIC_STR},
-	{ -ENOSPC, CPE_ENORESOURCE_STR},
-	{ -EBADR, CPE_EHANDLE_STR},
-	{ -EALREADY, CPE_EALREADY_STR},
-	{ -EPERM, CPE_ENOTREADY_STR},
-	{ -EINPROGRESS, CPE_EPENDING_STR},
-	{ -EBUSY, CPE_EBUSY_STR},
-	{ -ECANCELED, CPE_EABORTED_STR},
-	{ -EAGAIN, CPE_EPREEMPTED_STR},
-	{ -EAGAIN, CPE_ECONTINUE_STR},
-	{ -EAGAIN, CPE_EIMMEDIATE_STR},
-	{ -EAGAIN, CPE_ENOTIMPL_STR},
-	{ -ENODATA, CPE_ENEEDMORE_STR},
-	{ -EADV, CPE_ERR_MAX_STR},
-	{ -ENOMEM, CPE_ENOMEMORY_STR},
-	{ -ENODEV, CPE_ENOTEXIST_STR},
-	{ -EADV, CPE_ETERMINATED_STR},
-	{ -EADV, CPE_ERR_MAX_STR},
-};
-
-static inline int cpe_err_get_lnx_err_code(u32 cpe_error)
-{
-	if (cpe_error > CPE_ERR_MAX)
-		return cpe_err_code_info[CPE_ERR_MAX].lnx_err_code;
-	else
-		return cpe_err_code_info[cpe_error].lnx_err_code;
-}
-
-static inline char *cpe_err_get_err_str(u32 cpe_error)
-{
-	if (cpe_error > CPE_ERR_MAX)
-		return cpe_err_code_info[CPE_ERR_MAX].cpe_err_str;
-	else
-		return cpe_err_code_info[cpe_error].cpe_err_str;
-}
-
-#endif
diff --git a/include/sound/msm-audio-effects-q6-v2.h b/include/sound/msm-audio-effects-q6-v2.h
deleted file mode 100644
index 6bc2338..0000000
--- a/include/sound/msm-audio-effects-q6-v2.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_AUDIO_EFFECTS_H
-#define _MSM_AUDIO_EFFECTS_H
-
-#include <sound/audio_effects.h>
-
-#define MAX_PP_PARAMS_SZ   128
-
-bool msm_audio_effects_is_effmodule_supp_in_top(int effect_module,
-						int topology);
-
-int msm_audio_effects_enable_extn(struct audio_client *ac,
-			     struct msm_nt_eff_all_config *effects,
-			     bool flag);
-
-int msm_audio_effects_reverb_handler(struct audio_client *ac,
-				     struct reverb_params *reverb,
-				     long *values);
-
-int msm_audio_effects_bass_boost_handler(struct audio_client *ac,
-					struct bass_boost_params *bass_boost,
-					long *values);
-
-int msm_audio_effects_pbe_handler(struct audio_client *ac,
-					struct pbe_params *pbe,
-					long *values);
-
-int msm_audio_effects_virtualizer_handler(struct audio_client *ac,
-				struct virtualizer_params *virtualizer,
-				long *values);
-
-int msm_audio_effects_popless_eq_handler(struct audio_client *ac,
-					 struct eq_params *eq,
-					 long *values);
-
-int msm_audio_effects_volume_handler(struct audio_client *ac,
-				     struct soft_volume_params *vol,
-				     long *values);
-
-int msm_audio_effects_volume_handler_v2(struct audio_client *ac,
-					struct soft_volume_params *vol,
-					long *values, int instance);
-#endif /*_MSM_AUDIO_EFFECTS_H*/
diff --git a/include/sound/msm-dai-q6-v2.h b/include/sound/msm-dai-q6-v2.h
deleted file mode 100644
index b1d76bf..0000000
--- a/include/sound/msm-dai-q6-v2.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __MSM_DAI_Q6_PDATA_H__
-
-#define __MSM_DAI_Q6_PDATA_H__
-
-#define MSM_MI2S_SD0 (1 << 0)
-#define MSM_MI2S_SD1 (1 << 1)
-#define MSM_MI2S_SD2 (1 << 2)
-#define MSM_MI2S_SD3 (1 << 3)
-#define MSM_MI2S_CAP_RX 0
-#define MSM_MI2S_CAP_TX 1
-
-#define MSM_PRIM_MI2S 0
-#define MSM_SEC_MI2S  1
-#define MSM_TERT_MI2S 2
-#define MSM_QUAT_MI2S  3
-#define MSM_SEC_MI2S_SD1  4
-#define MSM_QUIN_MI2S  5
-#define MSM_SENARY_MI2S  6
-#define MSM_INT0_MI2S  7
-#define MSM_INT1_MI2S  8
-#define MSM_INT2_MI2S  9
-#define MSM_INT3_MI2S  10
-#define MSM_INT4_MI2S  11
-#define MSM_INT5_MI2S  12
-#define MSM_INT6_MI2S  13
-#define MSM_MI2S_MIN MSM_PRIM_MI2S
-#define MSM_MI2S_MAX MSM_INT6_MI2S
-
-struct msm_dai_auxpcm_config {
-	u16 mode;
-	u16 sync;
-	u16 frame;
-	u16 quant;
-	u16 num_slots;
-	u16 *slot_mapping;
-	u16 data;
-	u32 pcm_clk_rate;
-};
-
-struct msm_dai_auxpcm_pdata {
-	struct msm_dai_auxpcm_config mode_8k;
-	struct msm_dai_auxpcm_config mode_16k;
-};
-
-struct msm_mi2s_pdata {
-	u16 rx_sd_lines;
-	u16 tx_sd_lines;
-	u16 intf_id;
-};
-
-struct msm_i2s_data {
-	u32 capability; /* RX or TX */
-	u16 sd_lines;
-};
-
-struct msm_dai_tdm_group_config {
-	u16 group_id;
-	u16 num_ports;
-	u16 *port_id;
-	u32 clk_rate;
-};
-
-struct msm_dai_tdm_config {
-	u16 sync_mode;
-	u16 sync_src;
-	u16 data_out;
-	u16 invert_sync;
-	u16 data_delay;
-	u32 data_align;
-	u16 header_start_offset;
-	u16 header_width;
-	u16 header_num_frame_repeat;
-};
-
-struct msm_dai_tdm_pdata {
-	struct msm_dai_tdm_group_config group_config;
-	struct msm_dai_tdm_config config;
-};
-
-#endif
diff --git a/include/sound/msm-slim-dma.h b/include/sound/msm-slim-dma.h
deleted file mode 100644
index daf394b..0000000
--- a/include/sound/msm-slim-dma.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_SLIMBUS_DMA_H
-#define _MSM_SLIMBUS_DMA_H
-
-#include <linux/slimbus/slimbus.h>
-
-/*
- * struct msm_slim_dma_data - DMA data for slimbus data transfer
- *
- * @sdev: Handle to the slim_device instance associated with the
- *	  data transfer.
- * @ph:	Port handle for the slimbus ports.
- * @dai_channel_ctl: callback function into the CPU dai driver
- *		     to setup the data path.
- *
- * This structure is used to share the slimbus port handles and
- * other data path setup related handles with other drivers.
- */
-struct msm_slim_dma_data {
-
-	/* Handle to slimbus device */
-	struct slim_device *sdev;
-
-	/* Port Handle */
-	u32 ph;
-
-	/* Callback for data channel control */
-	int (*dai_channel_ctl)(struct msm_slim_dma_data *dma_data,
-				struct snd_soc_dai *dai, bool enable);
-};
-
-#endif
diff --git a/include/sound/q6adm-v2.h b/include/sound/q6adm-v2.h
deleted file mode 100644
index e689e93..0000000
--- a/include/sound/q6adm-v2.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6_ADM_V2_H__
-#define __Q6_ADM_V2_H__
-
-
-#define ADM_PATH_PLAYBACK 0x1
-#define ADM_PATH_LIVE_REC 0x2
-#define ADM_PATH_NONLIVE_REC 0x3
-#define ADM_PATH_COMPRESSED_RX 0x5
-#define ADM_PATH_COMPRESSED_TX 0x6
-#include <linux/qdsp6v2/rtac.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6audio-v2.h>
-
-#define MAX_MODULES_IN_TOPO 16
-#define ADM_GET_TOPO_MODULE_LIST_LENGTH\
-		((MAX_MODULES_IN_TOPO + 1) * sizeof(uint32_t))
-#define AUD_PROC_BLOCK_SIZE	4096
-#define AUD_VOL_BLOCK_SIZE	4096
-#define AUDIO_RX_CALIBRATION_SIZE	(AUD_PROC_BLOCK_SIZE + \
-						AUD_VOL_BLOCK_SIZE)
-enum {
-	ADM_CUSTOM_TOP_CAL = 0,
-	ADM_AUDPROC_CAL,
-	ADM_AUDVOL_CAL,
-	ADM_RTAC_INFO_CAL,
-	ADM_RTAC_APR_CAL,
-	ADM_SRS_TRUMEDIA,
-	ADM_RTAC_AUDVOL_CAL,
-	ADM_MAX_CAL_TYPES
-};
-
-enum {
-	ADM_MEM_MAP_INDEX_SOURCE_TRACKING = ADM_MAX_CAL_TYPES,
-	ADM_MEM_MAP_INDEX_MAX
-};
-
-enum {
-	ADM_CLIENT_ID_DEFAULT = 0,
-	ADM_CLIENT_ID_SOURCE_TRACKING,
-	ADM_CLIENT_ID_MAX,
-};
-
-#define MAX_COPPS_PER_PORT 0x8
-#define ADM_MAX_CHANNELS 8
-
-/* multiple copp per stream. */
-struct route_payload {
-	unsigned int copp_idx[MAX_COPPS_PER_PORT];
-	unsigned int port_id[MAX_COPPS_PER_PORT];
-	int app_type[MAX_COPPS_PER_PORT];
-	int acdb_dev_id[MAX_COPPS_PER_PORT];
-	int sample_rate[MAX_COPPS_PER_PORT];
-	unsigned short num_copps;
-	unsigned int session_id;
-};
-
-struct default_chmixer_param_id_coeff {
-	uint32_t index;
-	uint16_t num_output_channels;
-	uint16_t num_input_channels;
-};
-
-struct msm_pcm_channel_mixer {
-	int output_channel;
-	int input_channels[ADM_MAX_CHANNELS];
-	bool enable;
-	int rule;
-	int channel_weight[ADM_MAX_CHANNELS][ADM_MAX_CHANNELS];
-};
-
-int srs_trumedia_open(int port_id, int copp_idx, __s32 srs_tech_id,
-		      void *srs_params);
-
-int adm_dts_eagle_set(int port_id, int copp_idx, int param_id,
-		      void *data, uint32_t size);
-
-int adm_dts_eagle_get(int port_id, int copp_idx, int param_id,
-		      void *data, uint32_t size);
-
-void adm_copp_mfc_cfg(int port_id, int copp_idx, int dst_sample_rate);
-
-int adm_get_params(int port_id, int copp_idx, uint32_t module_id,
-		   uint32_t param_id, uint32_t params_length, char *params);
-
-int adm_send_params_v5(int port_id, int copp_idx, char *params,
-			      uint32_t params_length);
-
-int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,
-			      uint32_t params_length);
-
-int adm_open(int port, int path, int rate, int mode, int topology,
-			   int perf_mode, uint16_t bits_per_sample,
-			   int app_type, int acdbdev_id);
-
-int adm_map_rtac_block(struct rtac_cal_block_data *cal_block);
-
-int adm_unmap_rtac_block(uint32_t *mem_map_handle);
-
-int adm_close(int port, int topology, int perf_mode);
-
-int adm_matrix_map(int path, struct route_payload payload_map,
-		   int perf_mode, uint32_t passthr_mode);
-
-int adm_connect_afe_port(int mode, int session_id, int port_id);
-
-void adm_ec_ref_rx_id(int  port_id);
-
-void adm_num_ec_ref_rx_chans(int num_chans);
-
-void adm_ec_ref_rx_bit_width(int bit_width);
-
-void adm_ec_ref_rx_sampling_rate(int sampling_rate);
-
-int adm_get_lowlatency_copp_id(int port_id);
-
-int adm_set_multi_ch_map(char *channel_map, int path);
-
-int adm_get_multi_ch_map(char *channel_map, int path);
-
-int adm_validate_and_get_port_index(int port_id);
-
-int adm_get_default_copp_idx(int port_id);
-
-int adm_get_topology_for_port_from_copp_id(int port_id, int copp_id);
-
-int adm_get_topology_for_port_copp_idx(int port_id, int copp_idx);
-
-int adm_get_indexes_from_copp_id(int copp_id, int *port_idx, int *copp_idx);
-
-int adm_set_stereo_to_custom_stereo(int port_id, int copp_idx,
-				    unsigned int session_id,
-				    char *params, uint32_t params_length);
-
-int adm_get_pp_topo_module_list(int port_id, int copp_idx, int32_t param_length,
-				char *params);
-
-int adm_set_volume(int port_id, int copp_idx, int volume);
-
-int adm_set_softvolume(int port_id, int copp_idx,
-		       struct audproc_softvolume_params *softvol_param);
-
-int adm_set_mic_gain(int port_id, int copp_idx, int volume);
-
-int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx,
-				int primary_mic_ch);
-
-int adm_param_enable(int port_id, int copp_idx, int module_id,  int enable);
-
-int adm_send_calibration(int port_id, int copp_idx, int path, int perf_mode,
-			 int cal_type, char *params, int size);
-
-int adm_set_wait_parameters(int port_id, int copp_idx);
-
-int adm_reset_wait_parameters(int port_id, int copp_idx);
-
-int adm_wait_timeout(int port_id, int copp_idx, int wait_time);
-
-int adm_store_cal_data(int port_id, int copp_idx, int path, int perf_mode,
-		       int cal_type, char *params, int *size);
-
-int adm_send_compressed_device_mute(int port_id, int copp_idx, bool mute_on);
-
-int adm_send_compressed_device_latency(int port_id, int copp_idx, int latency);
-int adm_set_sound_focus(int port_id, int copp_idx,
-			struct sound_focus_param soundFocusData);
-int adm_get_sound_focus(int port_id, int copp_idx,
-			struct sound_focus_param *soundFocusData);
-int adm_get_source_tracking(int port_id, int copp_idx,
-			    struct source_tracking_param *sourceTrackingData);
-int adm_swap_speaker_channels(int port_id, int copp_idx, int sample_rate,
-				bool spk_swap);
-int adm_programable_channel_mixer(int port_id, int copp_idx, int session_id,
-			int session_type,
-			struct msm_pcm_channel_mixer *ch_mixer,
-			int channel_index);
-#endif /* __Q6_ADM_V2_H__ */
diff --git a/include/sound/q6afe-v2.h b/include/sound/q6afe-v2.h
deleted file mode 100644
index 8361175..0000000
--- a/include/sound/q6afe-v2.h
+++ /dev/null
@@ -1,371 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6AFE_V2_H__
-#define __Q6AFE_V2_H__
-#include <sound/apr_audio-v2.h>
-#include <linux/qdsp6v2/rtac.h>
-
-#define IN			0x000
-#define OUT			0x001
-#define MSM_AFE_MONO        0
-#define MSM_AFE_CH_STEREO   1
-#define MSM_AFE_MONO_RIGHT  1
-#define MSM_AFE_MONO_LEFT   2
-#define MSM_AFE_STEREO      3
-#define MSM_AFE_4CHANNELS   4
-#define MSM_AFE_6CHANNELS   6
-#define MSM_AFE_8CHANNELS   8
-
-#define MSM_AFE_I2S_FORMAT_LPCM		0
-#define MSM_AFE_I2S_FORMAT_COMPR		1
-#define MSM_AFE_I2S_FORMAT_IEC60958_LPCM	2
-#define MSM_AFE_I2S_FORMAT_IEC60958_COMPR	3
-
-#define MSM_AFE_PORT_TYPE_RX 0
-#define MSM_AFE_PORT_TYPE_TX 1
-
-#define RT_PROXY_DAI_001_RX	0xE0
-#define RT_PROXY_DAI_001_TX	0xF0
-#define RT_PROXY_DAI_002_RX	0xF1
-#define RT_PROXY_DAI_002_TX	0xE1
-#define VIRTUAL_ID_TO_PORTID(val) ((val & 0xF) | 0x2000)
-
-#define AFE_CLK_VERSION_V1    1
-#define AFE_CLK_VERSION_V2    2
-
-typedef int (*routing_cb)(int port);
-
-enum {
-	/* IDX 0->4 */
-	IDX_PRIMARY_I2S_RX,
-	IDX_PRIMARY_I2S_TX,
-	IDX_AFE_PORT_ID_PRIMARY_PCM_RX,
-	IDX_AFE_PORT_ID_PRIMARY_PCM_TX,
-	IDX_SECONDARY_I2S_RX,
-	/* IDX 5->9 */
-	IDX_SECONDARY_I2S_TX,
-	IDX_MI2S_RX,
-	IDX_MI2S_TX,
-	IDX_HDMI_RX,
-	IDX_RSVD_2,
-	/* IDX 10->14 */
-	IDX_RSVD_3,
-	IDX_DIGI_MIC_TX,
-	IDX_VOICE_RECORD_RX,
-	IDX_VOICE_RECORD_TX,
-	IDX_VOICE_PLAYBACK_TX,
-	/* IDX 15->19 */
-	IDX_SLIMBUS_0_RX,
-	IDX_SLIMBUS_0_TX,
-	IDX_SLIMBUS_1_RX,
-	IDX_SLIMBUS_1_TX,
-	IDX_SLIMBUS_2_RX,
-	/* IDX 20->24 */
-	IDX_SLIMBUS_2_TX,
-	IDX_SLIMBUS_3_RX,
-	IDX_SLIMBUS_3_TX,
-	IDX_SLIMBUS_4_RX,
-	IDX_SLIMBUS_4_TX,
-	/* IDX 25->29 */
-	IDX_SLIMBUS_5_RX,
-	IDX_SLIMBUS_5_TX,
-	IDX_INT_BT_SCO_RX,
-	IDX_INT_BT_SCO_TX,
-	IDX_INT_BT_A2DP_RX,
-	/* IDX 30->34 */
-	IDX_INT_FM_RX,
-	IDX_INT_FM_TX,
-	IDX_RT_PROXY_PORT_001_RX,
-	IDX_RT_PROXY_PORT_001_TX,
-	IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX,
-	/* IDX 35->39 */
-	IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX,
-	IDX_AFE_PORT_ID_SECONDARY_MI2S_RX,
-	IDX_AFE_PORT_ID_SECONDARY_MI2S_TX,
-	IDX_AFE_PORT_ID_TERTIARY_MI2S_RX,
-	IDX_AFE_PORT_ID_TERTIARY_MI2S_TX,
-	/* IDX 40->44 */
-	IDX_AFE_PORT_ID_PRIMARY_MI2S_RX,
-	IDX_AFE_PORT_ID_PRIMARY_MI2S_TX,
-	IDX_AFE_PORT_ID_SECONDARY_PCM_RX,
-	IDX_AFE_PORT_ID_SECONDARY_PCM_TX,
-	IDX_VOICE2_PLAYBACK_TX,
-	/* IDX 45->49 */
-	IDX_SLIMBUS_6_RX,
-	IDX_SLIMBUS_6_TX,
-	IDX_SPDIF_RX,
-	IDX_GLOBAL_CFG,
-	IDX_AUDIO_PORT_ID_I2S_RX,
-	/* IDX 50->53 */
-	IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1,
-	IDX_AFE_PORT_ID_QUINARY_MI2S_RX,
-	IDX_AFE_PORT_ID_QUINARY_MI2S_TX,
-	IDX_AFE_PORT_ID_SENARY_MI2S_TX,
-	/* IDX 54->117 */
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7,
-	IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7,
-	IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7,
-	IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7,
-	IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7,
-	/* IDX 118->121 */
-	IDX_SLIMBUS_7_RX,
-	IDX_SLIMBUS_7_TX,
-	IDX_SLIMBUS_8_RX,
-	IDX_SLIMBUS_8_TX,
-	/* IDX 122-> 123 */
-	IDX_AFE_PORT_ID_USB_RX,
-	IDX_AFE_PORT_ID_USB_TX,
-	/* IDX 124 */
-	IDX_DISPLAY_PORT_RX,
-	/* IDX 125-> 128 */
-	IDX_AFE_PORT_ID_TERTIARY_PCM_RX,
-	IDX_AFE_PORT_ID_TERTIARY_PCM_TX,
-	IDX_AFE_PORT_ID_QUATERNARY_PCM_RX,
-	IDX_AFE_PORT_ID_QUATERNARY_PCM_TX,
-	/* IDX 129-> 142 */
-	IDX_AFE_PORT_ID_INT0_MI2S_RX,
-	IDX_AFE_PORT_ID_INT0_MI2S_TX,
-	IDX_AFE_PORT_ID_INT1_MI2S_RX,
-	IDX_AFE_PORT_ID_INT1_MI2S_TX,
-	IDX_AFE_PORT_ID_INT2_MI2S_RX,
-	IDX_AFE_PORT_ID_INT2_MI2S_TX,
-	IDX_AFE_PORT_ID_INT3_MI2S_RX,
-	IDX_AFE_PORT_ID_INT3_MI2S_TX,
-	IDX_AFE_PORT_ID_INT4_MI2S_RX,
-	IDX_AFE_PORT_ID_INT4_MI2S_TX,
-	IDX_AFE_PORT_ID_INT5_MI2S_RX,
-	IDX_AFE_PORT_ID_INT5_MI2S_TX,
-	IDX_AFE_PORT_ID_INT6_MI2S_RX,
-	IDX_AFE_PORT_ID_INT6_MI2S_TX,
-	AFE_MAX_PORTS
-};
-
-enum afe_mad_type {
-	MAD_HW_NONE = 0x00,
-	MAD_HW_AUDIO = 0x01,
-	MAD_HW_BEACON = 0x02,
-	MAD_HW_ULTRASOUND = 0x04,
-	MAD_SW_AUDIO = 0x05,
-};
-
-enum afe_cal_mode {
-	AFE_CAL_MODE_DEFAULT = 0x00,
-	AFE_CAL_MODE_NONE,
-};
-
-struct afe_audio_buffer {
-	dma_addr_t phys;
-	void       *data;
-	uint32_t   used;
-	uint32_t   size;/* size of buffer */
-	uint32_t   actual_size; /* actual number of bytes read by DSP */
-	struct      ion_handle *handle;
-	struct      ion_client *client;
-};
-
-struct afe_audio_port_data {
-	struct afe_audio_buffer *buf;
-	uint32_t	    max_buf_cnt;
-	uint32_t	    dsp_buf;
-	uint32_t	    cpu_buf;
-	struct list_head    mem_map_handle;
-	uint32_t	    tmp_hdl;
-	/* read or write locks */
-	struct mutex	    lock;
-	spinlock_t	    dsp_lock;
-};
-
-struct afe_audio_client {
-	atomic_t	       cmd_state;
-	/* Relative or absolute TS */
-	uint32_t	       time_flag;
-	void		       *priv;
-	uint64_t	       time_stamp;
-	struct mutex	       cmd_lock;
-	/* idx:1 out port, 0: in port*/
-	struct afe_audio_port_data port[2];
-	wait_queue_head_t      cmd_wait;
-	uint32_t               mem_map_handle;
-};
-
-struct aanc_data {
-	bool aanc_active;
-	uint16_t aanc_rx_port;
-	uint16_t aanc_tx_port;
-	uint32_t aanc_rx_port_sample_rate;
-	uint32_t aanc_tx_port_sample_rate;
-};
-
-int afe_open(u16 port_id, union afe_port_config *afe_config, int rate);
-int afe_close(int port_id);
-int afe_loopback(u16 enable, u16 rx_port, u16 tx_port);
-int afe_sidetone_enable(u16 tx_port_id, u16 rx_port_id, bool enable);
-int afe_loopback_gain(u16 port_id, u16 volume);
-int afe_validate_port(u16 port_id);
-int afe_get_port_index(u16 port_id);
-int afe_get_topology(int port_id);
-int afe_start_pseudo_port(u16 port_id);
-int afe_stop_pseudo_port(u16 port_id);
-uint32_t afe_req_mmap_handle(struct afe_audio_client *ac);
-int afe_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz,
-		struct afe_audio_client *ac);
-int afe_cmd_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz);
-int afe_cmd_memory_map_nowait(int port_id, phys_addr_t dma_addr_p,
-			u32 dma_buf_sz);
-int afe_cmd_memory_unmap(u32 dma_addr_p);
-int afe_cmd_memory_unmap_nowait(u32 dma_addr_p);
-void afe_set_dtmf_gen_rx_portid(u16 rx_port_id, int set);
-int afe_dtmf_generate_rx(int64_t duration_in_ms,
-			 uint16_t high_freq,
-			 uint16_t low_freq, uint16_t gain);
-int afe_register_get_events(u16 port_id,
-		void (*cb)(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv),
-		void *private_data);
-int afe_unregister_get_events(u16 port_id);
-int afe_rt_proxy_port_write(phys_addr_t buf_addr_p,
-			u32 mem_map_handle, int bytes);
-int afe_rt_proxy_port_read(phys_addr_t buf_addr_p,
-			u32 mem_map_handle, int bytes);
-void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode);
-int afe_port_start(u16 port_id, union afe_port_config *afe_config,
-	u32 rate);
-int afe_port_start_v2(u16 port_id, union afe_port_config *afe_config,
-		      u32 rate, u16 afe_in_channels, u16 afe_in_bit_width,
-		      struct afe_enc_config *enc_config);
-int afe_spk_prot_feed_back_cfg(int src_port, int dst_port,
-	int l_ch, int r_ch, u32 enable);
-int afe_spk_prot_get_calib_data(struct afe_spkr_prot_get_vi_calib *calib);
-int afe_port_stop_nowait(int port_id);
-int afe_apply_gain(u16 port_id, u16 gain);
-int afe_q6_interface_prepare(void);
-int afe_get_port_type(u16 port_id);
-int q6afe_audio_client_buf_alloc_contiguous(unsigned int dir,
-			struct afe_audio_client *ac,
-			unsigned int bufsz,
-			unsigned int bufcnt);
-struct afe_audio_client *q6afe_audio_client_alloc(void *priv);
-int q6afe_audio_client_buf_free_contiguous(unsigned int dir,
-			struct afe_audio_client *ac);
-void q6afe_audio_client_free(struct afe_audio_client *ac);
-/* if port_id is virtual, convert to physical..
- * if port_id is already physical, return physical
- */
-int afe_convert_virtual_to_portid(u16 port_id);
-
-int afe_pseudo_port_start_nowait(u16 port_id);
-int afe_pseudo_port_stop_nowait(u16 port_id);
-int afe_set_lpass_clock(u16 port_id, struct afe_clk_cfg *cfg);
-int afe_set_lpass_clock_v2(u16 port_id, struct afe_clk_set *cfg);
-int afe_set_lpass_clk_cfg(int index, struct afe_clk_set *cfg);
-int afe_set_digital_codec_core_clock(u16 port_id,
-			struct afe_digital_clk_cfg *cfg);
-int afe_set_lpass_internal_digital_codec_clock(u16 port_id,
-				struct afe_digital_clk_cfg *cfg);
-int afe_enable_lpass_core_shared_clock(u16 port_id, u32 enable);
-
-int q6afe_check_osr_clk_freq(u32 freq);
-
-int afe_send_spdif_clk_cfg(struct afe_param_id_spdif_clk_cfg *cfg,
-		u16 port_id);
-int afe_send_spdif_ch_status_cfg(struct afe_param_id_spdif_ch_status_cfg
-		*ch_status_cfg,	u16 port_id);
-
-int afe_spdif_port_start(u16 port_id, struct afe_spdif_port_config *spdif_port,
-		u32 rate);
-
-int afe_turn_onoff_hw_mad(u16 mad_type, u16 mad_enable);
-int afe_port_set_mad_type(u16 port_id, enum afe_mad_type mad_type);
-enum afe_mad_type afe_port_get_mad_type(u16 port_id);
-int afe_set_config(enum afe_config_type config_type, void *config_data,
-		   int arg);
-void afe_clear_config(enum afe_config_type config);
-bool afe_has_config(enum afe_config_type config);
-
-void afe_set_aanc_info(struct aanc_data *aanc_info);
-int afe_port_group_set_param(u16 group_id,
-	union afe_port_group_config *afe_group_config);
-int afe_port_group_enable(u16 group_id,
-	union afe_port_group_config *afe_group_config, u16 enable);
-int afe_unmap_rtac_block(uint32_t *mem_map_handle);
-int afe_map_rtac_block(struct rtac_cal_block_data *cal_block);
-int afe_send_slot_mapping_cfg(
-	struct afe_param_id_slot_mapping_cfg *slot_mapping_cfg,
-	u16 port_id);
-int afe_send_custom_tdm_header_cfg(
-	struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header_cfg,
-	u16 port_id);
-int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port,
-		       u32 rate, u16 num_groups);
-void afe_set_routing_callback(routing_cb cb);
-int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
-		u16 port);
-#endif /* __Q6AFE_V2_H__ */
diff --git a/include/sound/q6asm-v2.h b/include/sound/q6asm-v2.h
deleted file mode 100644
index 00b46a5..0000000
--- a/include/sound/q6asm-v2.h
+++ /dev/null
@@ -1,686 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6_ASM_V2_H__
-#define __Q6_ASM_V2_H__
-
-#include <linux/qdsp6v2/apr.h>
-#include <linux/qdsp6v2/rtac.h>
-#include <sound/apr_audio-v2.h>
-#include <linux/list.h>
-#include <linux/msm_ion.h>
-
-#define IN                      0x000
-#define OUT                     0x001
-#define CH_MODE_MONO            0x001
-#define CH_MODE_STEREO          0x002
-
-#define FORMAT_LINEAR_PCM   0x0000
-#define FORMAT_DTMF         0x0001
-#define FORMAT_ADPCM	    0x0002
-#define FORMAT_YADPCM       0x0003
-#define FORMAT_MP3          0x0004
-#define FORMAT_MPEG4_AAC    0x0005
-#define FORMAT_AMRNB	    0x0006
-#define FORMAT_AMRWB	    0x0007
-#define FORMAT_V13K	    0x0008
-#define FORMAT_EVRC	    0x0009
-#define FORMAT_EVRCB	    0x000a
-#define FORMAT_EVRCWB	    0x000b
-#define FORMAT_MIDI	    0x000c
-#define FORMAT_SBC	    0x000d
-#define FORMAT_WMA_V10PRO   0x000e
-#define FORMAT_WMA_V9	    0x000f
-#define FORMAT_AMR_WB_PLUS  0x0010
-#define FORMAT_MPEG4_MULTI_AAC 0x0011
-#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012
-#define FORMAT_AC3          0x0013
-#define FORMAT_EAC3         0x0014
-#define FORMAT_MP2          0x0015
-#define FORMAT_FLAC         0x0016
-#define FORMAT_ALAC         0x0017
-#define FORMAT_VORBIS       0x0018
-#define FORMAT_APE          0x0019
-#define FORMAT_G711_ALAW_FS 0x001a
-#define FORMAT_G711_MLAW_FS 0x001b
-#define FORMAT_DTS          0x001c
-#define FORMAT_DSD          0x001d
-#define FORMAT_APTX         0x001e
-#define FORMAT_GEN_COMPR    0x001f
-#define FORMAT_TRUEHD       0x0020
-#define FORMAT_IEC61937     0x0021
-
-#define ENCDEC_SBCBITRATE   0x0001
-#define ENCDEC_IMMEDIATE_DECODE 0x0002
-#define ENCDEC_CFG_BLK          0x0003
-
-#define CMD_PAUSE          0x0001
-#define CMD_FLUSH          0x0002
-#define CMD_EOS            0x0003
-#define CMD_CLOSE          0x0004
-#define CMD_OUT_FLUSH      0x0005
-#define CMD_SUSPEND        0x0006
-
-/* bit 0:1 represents priority of stream */
-#define STREAM_PRIORITY_NORMAL	0x0000
-#define STREAM_PRIORITY_LOW	0x0001
-#define STREAM_PRIORITY_HIGH	0x0002
-
-/* bit 4 represents META enable of encoded data buffer */
-#define BUFFER_META_ENABLE	0x0010
-
-/* bit 5 represents timestamp */
-/* bit 5 - 0 -- ASM_DATA_EVENT_READ_DONE will have relative time-stamp*/
-/* bit 5 - 1 -- ASM_DATA_EVENT_READ_DONE will have absolute time-stamp*/
-#define ABSOLUTE_TIMESTAMP_ENABLE  0x0020
-
-/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
-#define SR_CM_NOTIFY_ENABLE	0x0004
-
-#define TUN_WRITE_IO_MODE 0x0008 /* tunnel read write mode */
-#define TUN_READ_IO_MODE  0x0004 /* tunnel read write mode */
-#define SYNC_IO_MODE	0x0001
-#define ASYNC_IO_MODE	0x0002
-#define COMPRESSED_IO	0x0040
-#define COMPRESSED_STREAM_IO	0x0080
-#define NT_MODE        0x0400
-
-#define NO_TIMESTAMP    0xFF00
-#define SET_TIMESTAMP   0x0000
-
-#define SOFT_PAUSE_ENABLE	1
-#define SOFT_PAUSE_DISABLE	0
-
-#define ASM_ACTIVE_STREAMS_ALLOWED	0x8
-/* Control session is used for mapping calibration memory */
-#define ASM_CONTROL_SESSION	(ASM_ACTIVE_STREAMS_ALLOWED + 1)
-
-#define ASM_SHIFT_GAPLESS_MODE_FLAG	31
-#define ASM_SHIFT_LAST_BUFFER_FLAG	30
-
-#define ASM_LITTLE_ENDIAN 0
-#define ASM_BIG_ENDIAN 1
-
-/* PCM_MEDIA_FORMAT_Version */
-enum {
-	PCM_MEDIA_FORMAT_V2 = 0,
-	PCM_MEDIA_FORMAT_V3,
-	PCM_MEDIA_FORMAT_V4,
-};
-
-/* PCM format modes in DSP */
-enum {
-	DEFAULT_QF = 0,
-	Q15 = 15,
-	Q23 = 23,
-	Q31 = 31,
-};
-
-/* payload structure bytes */
-#define READDONE_IDX_STATUS 0
-#define READDONE_IDX_BUFADD_LSW 1
-#define READDONE_IDX_BUFADD_MSW 2
-#define READDONE_IDX_MEMMAP_HDL 3
-#define READDONE_IDX_SIZE 4
-#define READDONE_IDX_OFFSET 5
-#define READDONE_IDX_LSW_TS 6
-#define READDONE_IDX_MSW_TS 7
-#define READDONE_IDX_FLAGS 8
-#define READDONE_IDX_NUMFRAMES 9
-#define READDONE_IDX_SEQ_ID 10
-
-#define SOFT_PAUSE_PERIOD       30   /* ramp up/down for 30ms    */
-#define SOFT_PAUSE_STEP         0 /* Step value 0ms or 0us */
-enum {
-	SOFT_PAUSE_CURVE_LINEAR = 0,
-	SOFT_PAUSE_CURVE_EXP,
-	SOFT_PAUSE_CURVE_LOG,
-};
-
-#define SOFT_VOLUME_PERIOD       30   /* ramp up/down for 30ms    */
-#define SOFT_VOLUME_STEP         0 /* Step value 0ms or 0us */
-enum {
-	SOFT_VOLUME_CURVE_LINEAR = 0,
-	SOFT_VOLUME_CURVE_EXP,
-	SOFT_VOLUME_CURVE_LOG,
-};
-
-#define SOFT_VOLUME_INSTANCE_1	1
-#define SOFT_VOLUME_INSTANCE_2	2
-
-typedef void (*app_cb)(uint32_t opcode, uint32_t token,
-			uint32_t *payload, void *priv);
-
-struct audio_buffer {
-	dma_addr_t phys;
-	void       *data;
-	uint32_t   used;
-	uint32_t   size;/* size of buffer */
-	uint32_t   actual_size; /* actual number of bytes read by DSP */
-	struct      ion_handle *handle;
-	struct      ion_client *client;
-};
-
-struct audio_aio_write_param {
-	phys_addr_t   paddr;
-	uint32_t      len;
-	uint32_t      uid;
-	uint32_t      lsw_ts;
-	uint32_t      msw_ts;
-	uint32_t      flags;
-	uint32_t      metadata_len;
-	uint32_t      last_buffer;
-};
-
-struct audio_aio_read_param {
-	phys_addr_t   paddr;
-	uint32_t      len;
-	uint32_t      uid;
-	uint32_t      flags;/*meta data flags*/
-};
-
-struct audio_port_data {
-	struct audio_buffer *buf;
-	uint32_t	    max_buf_cnt;
-	uint32_t	    dsp_buf;
-	uint32_t	    cpu_buf;
-	struct list_head    mem_map_handle;
-	uint32_t	    tmp_hdl;
-	/* read or write locks */
-	struct mutex	    lock;
-	spinlock_t	    dsp_lock;
-};
-
-struct shared_io_config {
-	uint32_t format;
-	uint16_t bits_per_sample;
-	uint32_t rate;
-	uint32_t channels;
-	uint16_t sample_word_size;
-	uint32_t bufsz;
-	uint32_t bufcnt;
-};
-
-struct audio_client {
-	int                    session;
-	app_cb		       cb;
-	atomic_t	       cmd_state;
-	atomic_t	       cmd_state_pp;
-	/* Relative or absolute TS */
-	atomic_t	       time_flag;
-	atomic_t	       nowait_cmd_cnt;
-	atomic_t               mem_state;
-	void		       *priv;
-	uint32_t               io_mode;
-	uint64_t	       time_stamp;
-	struct apr_svc         *apr;
-	struct apr_svc         *mmap_apr;
-	struct apr_svc         *apr2;
-	struct mutex	       cmd_lock;
-	/* idx:1 out port, 0: in port*/
-	struct audio_port_data port[2];
-	wait_queue_head_t      cmd_wait;
-	wait_queue_head_t      time_wait;
-	wait_queue_head_t      mem_wait;
-	int                    perf_mode;
-	int					   stream_id;
-	struct device *dev;
-	int		       topology;
-	int		       app_type;
-	/* audio cache operations fptr*/
-	int (*fptr_cache_ops)(struct audio_buffer *abuff, int cache_op);
-	atomic_t               unmap_cb_success;
-	atomic_t               reset;
-	/* holds latest DSP pipeline delay */
-	uint32_t               path_delay;
-	/* shared io */
-	struct audio_buffer shared_pos_buf;
-	struct shared_io_config config;
-};
-
-void q6asm_audio_client_free(struct audio_client *ac);
-
-struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
-
-struct audio_client *q6asm_get_audio_client(int session_id);
-
-int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
-				struct audio_client *ac,
-				unsigned int bufsz,
-				uint32_t bufcnt);
-int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
-				/* 1:Out,0:In */,
-				struct audio_client *ac,
-				unsigned int bufsz,
-				unsigned int bufcnt);
-
-int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
-			struct audio_client *ac);
-
-int q6asm_open_read(struct audio_client *ac, uint32_t format
-		/*, uint16_t bits_per_sample*/);
-
-int q6asm_open_read_v2(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample);
-
-int q6asm_open_read_v3(struct audio_client *ac, uint32_t format,
-		       uint16_t bits_per_sample);
-
-int q6asm_open_read_v4(struct audio_client *ac, uint32_t format,
-		       uint16_t bits_per_sample, bool ts_mode);
-
-int q6asm_open_write(struct audio_client *ac, uint32_t format
-		/*, uint16_t bits_per_sample*/);
-
-int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample);
-
-int q6asm_open_shared_io(struct audio_client *ac,
-			 struct shared_io_config *c, int dir);
-
-int q6asm_open_write_v3(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample);
-
-int q6asm_open_write_v4(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample);
-
-int q6asm_stream_open_write_v2(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode);
-
-int q6asm_stream_open_write_v3(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode);
-
-int q6asm_stream_open_write_v4(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode);
-
-int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format,
-				uint32_t passthrough_flag);
-
-int q6asm_open_read_write(struct audio_client *ac,
-			uint32_t rd_format,
-			uint32_t wr_format);
-
-int q6asm_open_read_write_v2(struct audio_client *ac, uint32_t rd_format,
-			     uint32_t wr_format, bool is_meta_data_mode,
-			     uint32_t bits_per_sample, bool overwrite_topology,
-			     int topology);
-
-int q6asm_open_loopback_v2(struct audio_client *ac,
-			   uint16_t bits_per_sample);
-
-int q6asm_open_transcode_loopback(struct audio_client *ac,
-			   uint16_t bits_per_sample, uint32_t source_format,
-			   uint32_t sink_format);
-
-int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
-				uint32_t lsw_ts, uint32_t flags);
-int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
-				uint32_t lsw_ts, uint32_t flags);
-
-int q6asm_async_write(struct audio_client *ac,
-					  struct audio_aio_write_param *param);
-
-int q6asm_async_read(struct audio_client *ac,
-					  struct audio_aio_read_param *param);
-
-int q6asm_read(struct audio_client *ac);
-int q6asm_read_v2(struct audio_client *ac, uint32_t len);
-int q6asm_read_nolock(struct audio_client *ac);
-
-int q6asm_memory_map(struct audio_client *ac, phys_addr_t buf_add,
-			int dir, uint32_t bufsz, uint32_t bufcnt);
-
-int q6asm_memory_unmap(struct audio_client *ac, phys_addr_t buf_add,
-							int dir);
-
-struct audio_buffer *q6asm_shared_io_buf(struct audio_client *ac, int dir);
-
-int q6asm_shared_io_free(struct audio_client *ac, int dir);
-
-int q6asm_get_shared_pos(struct audio_client *ac, uint32_t *si, uint32_t *msw,
-			 uint32_t *lsw);
-
-int q6asm_map_rtac_block(struct rtac_cal_block_data *cal_block);
-
-int q6asm_unmap_rtac_block(uint32_t *mem_map_handle);
-
-int q6asm_send_cal(struct audio_client *ac);
-
-int q6asm_run(struct audio_client *ac, uint32_t flags,
-		uint32_t msw_ts, uint32_t lsw_ts);
-
-int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
-		uint32_t msw_ts, uint32_t lsw_ts);
-
-int q6asm_stream_run_nowait(struct audio_client *ac, uint32_t flags,
-		uint32_t msw_ts, uint32_t lsw_ts, uint32_t stream_id);
-
-int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
-
-int q6asm_reg_rx_underflow(struct audio_client *ac, uint16_t enable);
-
-int q6asm_cmd(struct audio_client *ac, int cmd);
-
-int q6asm_stream_cmd(struct audio_client *ac, int cmd, uint32_t stream_id);
-
-int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
-
-int q6asm_stream_cmd_nowait(struct audio_client *ac, int cmd,
-			    uint32_t stream_id);
-
-void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
-				uint32_t *size, uint32_t *idx);
-
-int q6asm_cpu_buf_release(int dir, struct audio_client *ac);
-
-void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
-					uint32_t *size, uint32_t *idx);
-
-int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
-
-/* File format specific configurations to be added below */
-
-int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
-			 uint32_t frames_per_buf,
-			uint32_t sample_rate, uint32_t channels,
-			 uint32_t bit_rate,
-			 uint32_t mode, uint32_t format);
-
-int q6asm_enc_cfg_blk_g711(struct audio_client *ac,
-			 uint32_t frames_per_buf,
-			uint32_t sample_rate);
-
-int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
-			uint32_t rate, uint32_t channels);
-
-int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			uint16_t bits_per_sample,
-			bool use_default_chmap, bool use_back_flavor,
-			u8 *channel_map);
-
-int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
-			     uint32_t rate, uint32_t channels,
-			     uint16_t bits_per_sample, bool use_default_chmap,
-			     bool use_back_flavor, u8 *channel_map,
-			     uint16_t sample_word_size);
-
-int q6asm_enc_cfg_blk_pcm_v4(struct audio_client *ac,
-			     uint32_t rate, uint32_t channels,
-			     uint16_t bits_per_sample, bool use_default_chmap,
-			     bool use_back_flavor, u8 *channel_map,
-			     uint16_t sample_word_size, uint16_t endianness,
-			     uint16_t mode);
-
-int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			uint16_t bits_per_sample);
-
-int q6asm_enc_cfg_blk_pcm_format_support_v3(struct audio_client *ac,
-					    uint32_t rate, uint32_t channels,
-					    uint16_t bits_per_sample,
-					    uint16_t sample_word_size);
-
-int q6asm_enc_cfg_blk_pcm_format_support_v4(struct audio_client *ac,
-					    uint32_t rate, uint32_t channels,
-					    uint16_t bits_per_sample,
-					    uint16_t sample_word_size,
-					    uint16_t endianness,
-					    uint16_t mode);
-
-int q6asm_set_encdec_chan_map(struct audio_client *ac,
-		uint32_t num_channels);
-
-int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
-			uint32_t rate, uint32_t channels);
-
-int q6asm_enable_sbrps(struct audio_client *ac,
-			uint32_t sbr_ps);
-
-int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
-			uint16_t sce_left, uint16_t sce_right);
-
-int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
-
-int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t min_rate, uint16_t max_rate,
-		uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
-
-int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t min_rate, uint16_t max_rate,
-		uint16_t rate_modulation_cmd);
-
-int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t band_mode, uint16_t dtx_enable);
-
-int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t band_mode, uint16_t dtx_enable);
-
-int q6asm_media_format_block_pcm(struct audio_client *ac,
-			uint32_t rate, uint32_t channels);
-
-int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			uint16_t bits_per_sample);
-
-int q6asm_media_format_block_pcm_format_support_v2(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				uint16_t bits_per_sample, int stream_id,
-				bool use_default_chmap, char *channel_map);
-
-int q6asm_media_format_block_pcm_format_support_v3(struct audio_client *ac,
-						   uint32_t rate,
-						   uint32_t channels,
-						   uint16_t bits_per_sample,
-						   int stream_id,
-						   bool use_default_chmap,
-						   char *channel_map,
-						   uint16_t sample_word_size);
-
-int q6asm_media_format_block_pcm_format_support_v4(struct audio_client *ac,
-						   uint32_t rate,
-						   uint32_t channels,
-						   uint16_t bits_per_sample,
-						   int stream_id,
-						   bool use_default_chmap,
-						   char *channel_map,
-						   uint16_t sample_word_size,
-						   uint16_t endianness,
-						   uint16_t mode);
-
-int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			bool use_default_chmap, char *channel_map);
-
-int q6asm_media_format_block_multi_ch_pcm_v2(
-			struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			bool use_default_chmap, char *channel_map,
-			uint16_t bits_per_sample);
-int q6asm_media_format_block_gen_compr(
-			struct audio_client *ac,
-			uint32_t rate, uint32_t channels,
-			bool use_default_chmap, char *channel_map,
-			uint16_t bits_per_sample);
-
-int q6asm_media_format_block_iec(
-			struct audio_client *ac,
-			uint32_t rate, uint32_t channels);
-
-int q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t bits_per_sample,
-					     uint16_t sample_word_size);
-
-int q6asm_media_format_block_multi_ch_pcm_v4(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t bits_per_sample,
-					     uint16_t sample_word_size,
-					     uint16_t endianness,
-					     uint16_t mode);
-
-int q6asm_media_format_block_aac(struct audio_client *ac,
-			struct asm_aac_cfg *cfg);
-
-int q6asm_stream_media_format_block_aac(struct audio_client *ac,
-			struct asm_aac_cfg *cfg, int stream_id);
-
-int q6asm_media_format_block_multi_aac(struct audio_client *ac,
-			struct asm_aac_cfg *cfg);
-
-int q6asm_media_format_block_wma(struct audio_client *ac,
-			void *cfg, int stream_id);
-
-int q6asm_media_format_block_wmapro(struct audio_client *ac,
-			void *cfg, int stream_id);
-
-int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
-			struct asm_amrwbplus_cfg *cfg);
-
-int q6asm_stream_media_format_block_flac(struct audio_client *ac,
-			struct asm_flac_cfg *cfg, int stream_id);
-
-int q6asm_media_format_block_alac(struct audio_client *ac,
-			struct asm_alac_cfg *cfg, int stream_id);
-
-int q6asm_media_format_block_g711(struct audio_client *ac,
-			struct asm_g711_dec_cfg *cfg, int stream_id);
-
-int q6asm_stream_media_format_block_vorbis(struct audio_client *ac,
-			struct asm_vorbis_cfg *cfg, int stream_id);
-
-int q6asm_media_format_block_ape(struct audio_client *ac,
-			struct asm_ape_cfg *cfg, int stream_id);
-
-int q6asm_media_format_block_dsd(struct audio_client *ac,
-			struct asm_dsd_cfg *cfg, int stream_id);
-
-int q6asm_stream_media_format_block_aptx_dec(struct audio_client *ac,
-						uint32_t sr, int stream_id);
-
-int q6asm_ds1_set_endp_params(struct audio_client *ac,
-				int param_id, int param_value);
-
-/* Send stream based end params */
-int q6asm_ds1_set_stream_endp_params(struct audio_client *ac, int param_id,
-				     int param_value, int stream_id);
-
-/* PP specific */
-int q6asm_equalizer(struct audio_client *ac, void *eq);
-
-/* Send Volume Command */
-int q6asm_set_volume(struct audio_client *ac, int volume);
-
-/* Send Volume Command */
-int q6asm_set_volume_v2(struct audio_client *ac, int volume, int instance);
-
-/* DTS Eagle Params */
-int q6asm_dts_eagle_set(struct audio_client *ac, int param_id, uint32_t size,
-			void *data, struct param_outband *po, int m_id);
-int q6asm_dts_eagle_get(struct audio_client *ac, int param_id, uint32_t size,
-			void *data, struct param_outband *po, int m_id);
-
-/* Send aptx decoder BT address */
-int q6asm_set_aptx_dec_bt_addr(struct audio_client *ac,
-				struct aptx_dec_bt_addr_cfg *cfg);
-
-/* Set SoftPause Params */
-int q6asm_set_softpause(struct audio_client *ac,
-			struct asm_softpause_params *param);
-
-/* Set Softvolume Params */
-int q6asm_set_softvolume(struct audio_client *ac,
-			struct asm_softvolume_params *param);
-
-/* Set Softvolume Params */
-int q6asm_set_softvolume_v2(struct audio_client *ac,
-			    struct asm_softvolume_params *param, int instance);
-
-/* Send left-right channel gain */
-int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
-
-/* Send multi channel gain */
-int q6asm_set_multich_gain(struct audio_client *ac, uint32_t channels,
-			   uint32_t *gains, uint8_t *ch_map, bool use_default);
-
-/* Enable Mute/unmute flag */
-int q6asm_set_mute(struct audio_client *ac, int muteflag);
-
-int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
-
-int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp);
-
-int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
-				    uint32_t params_length);
-
-int q6asm_send_stream_cmd(struct audio_client *ac,
-			  struct msm_adsp_event_data *data);
-
-int q6asm_send_ion_fd(struct audio_client *ac, int fd);
-
-int q6asm_send_rtic_event_ack(struct audio_client *ac,
-			      void *param, uint32_t params_length);
-
-/* Client can set the IO mode to either AIO/SIO mode */
-int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
-
-/* Get Service ID for APR communication */
-int q6asm_get_apr_service_id(int session_id);
-
-/* Common format block without any payload */
-int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
-
-/* Send the meta data to remove initial and trailing silence */
-int q6asm_send_meta_data(struct audio_client *ac, uint32_t initial_samples,
-		uint32_t trailing_samples);
-
-/* Send the stream meta data to remove initial and trailing silence */
-int q6asm_stream_send_meta_data(struct audio_client *ac, uint32_t stream_id,
-		uint32_t initial_samples, uint32_t trailing_samples);
-
-int q6asm_get_asm_topology(int session_id);
-int q6asm_get_asm_app_type(int session_id);
-
-int q6asm_send_mtmx_strtr_window(struct audio_client *ac,
-		struct asm_session_mtmx_strtr_param_window_v2_t *window_param,
-		uint32_t param_id);
-
-/* Configure DSP render mode */
-int q6asm_send_mtmx_strtr_render_mode(struct audio_client *ac,
-		uint32_t render_mode);
-
-/* Configure DSP clock recovery mode */
-int q6asm_send_mtmx_strtr_clk_rec_mode(struct audio_client *ac,
-		uint32_t clk_rec_mode);
-
-/* Enable adjust session clock in DSP */
-int q6asm_send_mtmx_strtr_enable_adjust_session_clock(struct audio_client *ac,
-		bool enable);
-
-/* Retrieve the current DSP path delay */
-int q6asm_get_path_delay(struct audio_client *ac);
-
-/* Helper functions to retrieve data from token */
-uint8_t q6asm_get_buf_index_from_token(uint32_t token);
-uint8_t q6asm_get_stream_id_from_token(uint32_t token);
-
-/* Adjust session clock in DSP */
-int q6asm_adjust_session_clock(struct audio_client *ac,
-		uint32_t adjust_time_lsw,
-		uint32_t adjust_time_msw);
-#endif /* __Q6_ASM_H__ */
diff --git a/include/sound/q6audio-v2.h b/include/sound/q6audio-v2.h
deleted file mode 100644
index fd14f33..0000000
--- a/include/sound/q6audio-v2.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (c) 2012-2013, 2015 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _Q6_AUDIO_H_
-#define _Q6_AUDIO_H_
-
-#include <linux/qdsp6v2/apr.h>
-
-enum {
-	LEGACY_PCM_MODE = 0,
-	LOW_LATENCY_PCM_MODE,
-	ULTRA_LOW_LATENCY_PCM_MODE,
-	ULL_POST_PROCESSING_PCM_MODE,
-};
-
-
-int q6audio_get_port_index(u16 port_id);
-
-int q6audio_convert_virtual_to_portid(u16 port_id);
-
-int q6audio_validate_port(u16 port_id);
-
-int q6audio_is_digital_pcm_interface(u16 port_id);
-
-int q6audio_get_port_id(u16 port_id);
-
-#endif
diff --git a/include/sound/q6core.h b/include/sound/q6core.h
deleted file mode 100644
index 111af67..0000000
--- a/include/sound/q6core.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6CORE_H__
-#define __Q6CORE_H__
-#include <linux/qdsp6v2/apr.h>
-#include <sound/apr_audio-v2.h>
-
-
-
-#define AVCS_CMD_ADSP_EVENT_GET_STATE		0x0001290C
-#define AVCS_CMDRSP_ADSP_EVENT_GET_STATE	0x0001290D
-
-bool q6core_is_adsp_ready(void);
-
-int q6core_get_service_version(uint32_t service_id,
-			       struct avcs_fwk_ver_info *ver_info,
-			       size_t size);
-size_t q6core_get_avcs_service_size(uint32_t service_id);
-
-#define ADSP_CMD_SET_DTS_EAGLE_DATA_ID 0x00012919
-#define DTS_EAGLE_LICENSE_ID           0x00028346
-struct adsp_dts_eagle {
-	struct apr_hdr hdr;
-	uint32_t id;
-	uint32_t overwrite;
-	uint32_t size;
-	char data[];
-};
-int core_dts_eagle_set(int size, char *data);
-int core_dts_eagle_get(int id, int size, char *data);
-
-#define ADSP_CMD_SET_DOLBY_MANUFACTURER_ID 0x00012918
-
-struct adsp_dolby_manufacturer_id {
-	struct apr_hdr hdr;
-	int manufacturer_id;
-};
-
-uint32_t core_set_dolby_manufacturer_id(int manufacturer_id);
-
-/* Dolby Surround1 Module License ID. This ID is used as an identifier
- * for DS1 license via ADSP generic license mechanism.
- * Please refer AVCS_CMD_SET_LICENSE for more details.
- */
-#define DOLBY_DS1_LICENSE_ID	0x00000001
-
-#define AVCS_CMD_SET_LICENSE	0x00012919
-struct avcs_cmd_set_license {
-	struct apr_hdr hdr;
-	uint32_t id; /**< A unique ID used to refer to this license */
-	uint32_t overwrite;
-	/* 0 = do not overwrite an existing license with this id.
-	 * 1 = overwrite an existing license with this id.
-	 */
-	uint32_t size;
-	/**< Size in bytes of the license data following this header. */
-	/* uint8_t* data ,  data and padding follows this structure
-	 * total packet size needs to be multiple of 4 Bytes
-	 */
-
-};
-
-#define AVCS_CMD_GET_LICENSE_VALIDATION_RESULT        0x0001291A
-struct avcs_cmd_get_license_validation_result {
-	struct apr_hdr hdr;
-	uint32_t id; /**< A unique ID used to refer to this license */
-};
-
-#define AVCS_CMDRSP_GET_LICENSE_VALIDATION_RESULT        0x0001291B
-struct avcs_cmdrsp_get_license_validation_result {
-	uint32_t result;
-	/* ADSP_EOK if the license validation result was successfully retrieved.
-	 * ADSP_ENOTEXIST if there is no license with the given id.
-	 * ADSP_ENOTIMPL if there is no validation function for a license
-	 * with this id.
-	 */
-	uint32_t size;
-	/* Length in bytes of the result that follows this structure*/
-};
-
-/* Set Q6 topologies */
-/*
- *	Registers custom topologies in the aDSP for
- *	use in audio, voice, AFE and LSM.
- */
-
-
-#define AVCS_CMD_SHARED_MEM_MAP_REGIONS                             0x00012924
-#define AVCS_CMDRSP_SHARED_MEM_MAP_REGIONS                          0x00012925
-#define AVCS_CMD_SHARED_MEM_UNMAP_REGIONS                           0x00012926
-
-
-#define AVCS_CMD_REGISTER_TOPOLOGIES                                0x00012923
-
-/* The payload for the AVCS_CMD_REGISTER_TOPOLOGIES command */
-struct avcs_cmd_register_topologies {
-	struct apr_hdr hdr;
-	uint32_t                  payload_addr_lsw;
-	/* Lower 32 bits of the topology buffer address. */
-
-	uint32_t                  payload_addr_msw;
-	/* Upper 32 bits of the topology buffer address. */
-
-	uint32_t                  mem_map_handle;
-	/* Unique identifier for an address.
-	 * -This memory map handle is returned by the aDSP through the
-	 * memory map command.
-	 * -NULL mem_map_handle is interpreted as in-band parameter
-	 * passing.
-	 * -Client has the flexibility to choose in-band or out-of-band.
-	 * -Out-of-band is recommended in this case.
-	 */
-
-	uint32_t                  payload_size;
-	/* Size in bytes of the valid data in the topology buffer. */
-} __packed;
-
-
-#define AVCS_CMD_DEREGISTER_TOPOLOGIES                                0x0001292a
-
-/* The payload for the AVCS_CMD_DEREGISTER_TOPOLOGIES command */
-struct avcs_cmd_deregister_topologies {
-	struct apr_hdr hdr;
-	uint32_t                  payload_addr_lsw;
-	/* Lower 32 bits of the topology buffer address. */
-
-	uint32_t                  payload_addr_msw;
-	/* Upper 32 bits of the topology buffer address. */
-
-	uint32_t                  mem_map_handle;
-	/* Unique identifier for an address.
-	 * -This memory map handle is returned by the aDSP through the
-	 * memory map command.
-	 * -NULL mem_map_handle is interpreted as in-band parameter
-	 * passing.
-	 * -Client has the flexibility to choose in-band or out-of-band.
-	 * -Out-of-band is recommended in this case.
-	 */
-
-	uint32_t                  payload_size;
-	/* Size in bytes of the valid data in the topology buffer. */
-
-	uint32_t                  mode;
-	/* 1: Deregister selected topologies
-	 * 2: Deregister all topologies
-	 */
-} __packed;
-
-#define AVCS_MODE_DEREGISTER_ALL_CUSTOM_TOPOLOGIES	2
-
-
-int32_t core_set_license(uint32_t key, uint32_t module_id);
-int32_t core_get_license_status(uint32_t module_id);
-
-#endif /* __Q6CORE_H__ */
diff --git a/include/sound/q6lsm.h b/include/sound/q6lsm.h
deleted file mode 100644
index 26106a8..0000000
--- a/include/sound/q6lsm.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __Q6LSM_H__
-#define __Q6LSM_H__
-
-#include <linux/list.h>
-#include <linux/msm_ion.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/lsm_params.h>
-#include <linux/qdsp6v2/apr.h>
-
-#define MAX_NUM_CONFIDENCE 20
-
-#define ADM_LSM_PORT_ID 0xADCB
-
-#define LSM_MAX_NUM_CHANNELS 8
-
-typedef void (*lsm_app_cb)(uint32_t opcode, uint32_t token,
-		       uint32_t *payload, void *priv);
-
-struct lsm_sound_model {
-	dma_addr_t      phys;
-	void		*data;
-	size_t		size; /* size of buffer */
-	uint32_t	actual_size; /* actual number of bytes read by DSP */
-	struct ion_handle *handle;
-	struct ion_client *client;
-	uint32_t	mem_map_handle;
-};
-
-struct snd_lsm_event_status_v2 {
-	uint16_t status;
-	uint16_t payload_size;
-	uint8_t  confidence_value[0];
-};
-
-struct lsm_lab_buffer {
-	dma_addr_t phys;
-	void *data;
-	size_t size;
-	struct ion_handle *handle;
-	struct ion_client *client;
-	uint32_t mem_map_handle;
-};
-
-struct lsm_hw_params {
-	u16 sample_rate;
-	u16 sample_size;
-	u32 buf_sz;
-	u32 period_count;
-	u16 num_chs;
-};
-
-struct lsm_client {
-	int		session;
-	lsm_app_cb	cb;
-	atomic_t	cmd_state;
-	void		*priv;
-	struct apr_svc  *apr;
-	struct apr_svc  *mmap_apr;
-	struct mutex    cmd_lock;
-	struct lsm_sound_model sound_model;
-	wait_queue_head_t cmd_wait;
-	uint32_t	cmd_err_code;
-	uint16_t	mode;
-	uint16_t	connect_to_port;
-	uint8_t		num_confidence_levels;
-	uint8_t		*confidence_levels;
-	bool		opened;
-	bool		started;
-	dma_addr_t	lsm_cal_phy_addr;
-	uint32_t	lsm_cal_size;
-	uint32_t	app_id;
-	bool		lab_enable;
-	bool		lab_started;
-	struct lsm_lab_buffer *lab_buffer;
-	struct lsm_hw_params hw_params;
-	bool		use_topology;
-	int		session_state;
-	bool		poll_enable;
-	int		perf_mode;
-	uint32_t	event_mode;
-};
-
-struct lsm_stream_cmd_open_tx {
-	struct apr_hdr  hdr;
-	uint16_t	app_id;
-	uint16_t	reserved;
-	uint32_t	sampling_rate;
-} __packed;
-
-struct lsm_stream_cmd_open_tx_v2 {
-	struct apr_hdr hdr;
-	uint32_t	topology_id;
-} __packed;
-
-struct lsm_custom_topologies {
-	struct apr_hdr hdr;
-	uint32_t data_payload_addr_lsw;
-	uint32_t data_payload_addr_msw;
-	uint32_t mem_map_handle;
-	uint32_t buffer_size;
-} __packed;
-
-struct lsm_param_size_reserved {
-	uint16_t param_size;
-	uint16_t reserved;
-} __packed;
-
-union lsm_param_size {
-	uint32_t param_size;
-	struct lsm_param_size_reserved sr;
-} __packed;
-
-struct lsm_param_payload_common {
-	uint32_t	module_id;
-	uint32_t	param_id;
-	union lsm_param_size p_size;
-} __packed;
-
-struct lsm_param_op_mode {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	uint16_t	mode;
-	uint16_t	reserved;
-} __packed;
-
-struct lsm_param_connect_to_port {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	/* AFE port id that receives voice wake up data */
-	uint16_t	port_id;
-	uint16_t	reserved;
-} __packed;
-
-struct lsm_param_poll_enable {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	/* indicates to voice wakeup that HW MAD/SW polling is enabled or not */
-	uint32_t	polling_enable;
-} __packed;
-
-struct lsm_param_fwk_mode_cfg {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	uint32_t	mode;
-} __packed;
-
-struct lsm_param_media_fmt {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	uint32_t	sample_rate;
-	uint16_t	num_channels;
-	uint16_t	bit_width;
-	uint8_t		channel_mapping[LSM_MAX_NUM_CHANNELS];
-} __packed;
-
-/*
- * This param cannot be sent in this format.
- * The actual number of confidence level values
- * need to appended to this param payload.
- */
-struct lsm_param_min_confidence_levels {
-	struct lsm_param_payload_common common;
-	uint8_t		num_confidence_levels;
-} __packed;
-
-struct lsm_set_params_hdr {
-	uint32_t	data_payload_size;
-	uint32_t	data_payload_addr_lsw;
-	uint32_t	data_payload_addr_msw;
-	uint32_t	mem_map_handle;
-} __packed;
-
-struct lsm_cmd_set_params {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr param_hdr;
-} __packed;
-
-struct lsm_cmd_set_params_conf {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_min_confidence_levels	conf_payload;
-} __packed;
-
-struct lsm_cmd_set_params_opmode {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_op_mode op_mode;
-} __packed;
-
-struct lsm_cmd_set_connectport {
-	struct apr_hdr msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_connect_to_port connect_to_port;
-} __packed;
-
-struct lsm_cmd_poll_enable {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_poll_enable poll_enable;
-} __packed;
-
-struct lsm_param_epd_thres {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	uint32_t	epd_begin;
-	uint32_t	epd_end;
-} __packed;
-
-struct lsm_cmd_set_epd_threshold {
-	struct apr_hdr msg_hdr;
-	struct lsm_set_params_hdr param_hdr;
-	struct lsm_param_epd_thres epd_thres;
-} __packed;
-
-struct lsm_param_gain {
-	struct lsm_param_payload_common common;
-	uint32_t	minor_version;
-	uint16_t	gain;
-	uint16_t	reserved;
-} __packed;
-
-struct lsm_cmd_set_gain {
-	struct apr_hdr msg_hdr;
-	struct lsm_set_params_hdr param_hdr;
-	struct lsm_param_gain lsm_gain;
-} __packed;
-
-struct lsm_cmd_reg_snd_model {
-	struct apr_hdr	hdr;
-	uint32_t	model_size;
-	uint32_t	model_addr_lsw;
-	uint32_t	model_addr_msw;
-	uint32_t	mem_map_handle;
-} __packed;
-
-struct lsm_lab_enable {
-	struct lsm_param_payload_common common;
-	uint16_t enable;
-	uint16_t reserved;
-} __packed;
-
-struct lsm_params_lab_enable {
-	struct apr_hdr msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_lab_enable lab_enable;
-} __packed;
-
-struct lsm_lab_config {
-	struct lsm_param_payload_common common;
-	uint32_t minor_version;
-	uint32_t wake_up_latency_ms;
-} __packed;
-
-
-struct lsm_params_lab_config {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_lab_config lab_config;
-} __packed;
-
-struct lsm_cmd_read {
-	struct apr_hdr hdr;
-	uint32_t buf_addr_lsw;
-	uint32_t buf_addr_msw;
-	uint32_t mem_map_handle;
-	uint32_t buf_size;
-} __packed;
-
-struct lsm_cmd_read_done {
-	struct apr_hdr hdr;
-	uint32_t status;
-	uint32_t buf_addr_lsw;
-	uint32_t buf_addr_msw;
-	uint32_t mem_map_handle;
-	uint32_t total_size;
-	uint32_t offset;
-	uint32_t timestamp_lsw;
-	uint32_t timestamp_msw;
-	uint32_t flags;
-} __packed;
-
-struct lsm_cmd_set_fwk_mode_cfg {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_fwk_mode_cfg fwk_mode_cfg;
-} __packed;
-
-struct lsm_cmd_set_media_fmt {
-	struct apr_hdr  msg_hdr;
-	struct lsm_set_params_hdr params_hdr;
-	struct lsm_param_media_fmt media_fmt;
-} __packed;
-
-
-struct lsm_client *q6lsm_client_alloc(lsm_app_cb cb, void *priv);
-void q6lsm_client_free(struct lsm_client *client);
-int q6lsm_open(struct lsm_client *client, uint16_t app_id);
-int q6lsm_start(struct lsm_client *client, bool wait);
-int q6lsm_stop(struct lsm_client *client, bool wait);
-int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len,
-			      bool allocate_module_data);
-int q6lsm_snd_model_buf_free(struct lsm_client *client);
-int q6lsm_close(struct lsm_client *client);
-int q6lsm_register_sound_model(struct lsm_client *client,
-			       enum lsm_detection_mode mode,
-			       bool detectfailure);
-int q6lsm_set_data(struct lsm_client *client,
-		   enum lsm_detection_mode mode,
-		   bool detectfailure);
-int q6lsm_deregister_sound_model(struct lsm_client *client);
-void set_lsm_port(int lsm_port);
-int get_lsm_port(void);
-int q6lsm_lab_control(struct lsm_client *client, u32 enable);
-int q6lsm_stop_lab(struct lsm_client *client);
-int q6lsm_read(struct lsm_client *client, struct lsm_cmd_read *read);
-int q6lsm_lab_buffer_alloc(struct lsm_client *client, bool alloc);
-int q6lsm_set_one_param(struct lsm_client *client,
-			struct lsm_params_info *p_info, void *data,
-			uint32_t param_type);
-void q6lsm_sm_set_param_data(struct lsm_client *client,
-		struct lsm_params_info *p_info,
-		size_t *offset);
-int q6lsm_set_port_connected(struct lsm_client *client);
-int q6lsm_set_fwk_mode_cfg(struct lsm_client *client, uint32_t event_mode);
-int q6lsm_set_media_fmt_params(struct lsm_client *client);
-#endif /* __Q6LSM_H__ */
diff --git a/include/sound/voice_params.h b/include/sound/voice_params.h
deleted file mode 100644
index 43e3b9d..0000000
--- a/include/sound/voice_params.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __VOICE_PARAMS_H__
-#define __VOICE_PARAMS_H__
-
-#include <linux/types.h>
-#include <sound/asound.h>
-
-enum voice_lch_mode {
-	VOICE_LCH_START = 1,
-	VOICE_LCH_STOP
-};
-
-#define SNDRV_VOICE_IOCTL_LCH _IOW('U', 0x00, enum voice_lch_mode)
-
-#endif
diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h
index 33b2e75..6021c3a 100644
--- a/include/target/iscsi/iscsi_target_core.h
+++ b/include/target/iscsi/iscsi_target_core.h
@@ -563,6 +563,7 @@
 #define LOGIN_FLAGS_READ_ACTIVE		1
 #define LOGIN_FLAGS_CLOSED		2
 #define LOGIN_FLAGS_READY		4
+#define LOGIN_FLAGS_INITIAL_PDU		8
 	unsigned long		login_flags;
 	struct delayed_work	login_work;
 	struct delayed_work	login_cleanup_work;
@@ -784,6 +785,7 @@
 	int			np_sock_type;
 	enum np_thread_state_table np_thread_state;
 	bool                    enabled;
+	atomic_t		np_reset_count;
 	enum iscsi_timer_flags_table np_login_timer_flags;
 	u32			np_exports;
 	enum np_flags_table	np_flags;
diff --git a/include/trace/events/exception.h b/include/trace/events/exception.h
new file mode 100644
index 0000000..2e8ddc1
--- /dev/null
+++ b/include/trace/events/exception.h
@@ -0,0 +1,124 @@
+/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM exception
+
+#if !defined(_TRACE_EXCEPTION_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EXCEPTION_H
+
+#include <linux/tracepoint.h>
+
+struct task_struct;
+
+TRACE_EVENT(user_fault,
+
+	TP_PROTO(struct task_struct *tsk, unsigned long addr, unsigned int fsr),
+
+	TP_ARGS(tsk, addr, fsr),
+
+	TP_STRUCT__entry(
+		__string(task_name, tsk->comm)
+		__field(unsigned long, addr)
+		__field(unsigned int, fsr)
+	),
+
+	TP_fast_assign(
+	__assign_str(task_name, tsk->comm)
+		__entry->addr	= addr;
+		__entry->fsr	= fsr;
+	),
+
+	TP_printk("task_name:%s addr:%lu, fsr:%u", __get_str(task_name),
+		__entry->addr, __entry->fsr)
+);
+
+
+struct pt_regs;
+
+TRACE_EVENT(undef_instr,
+
+	TP_PROTO(struct pt_regs *regs, void __user *prog_cnt),
+
+	TP_ARGS(regs, prog_cnt),
+
+	TP_STRUCT__entry(
+		__field(void __user *, prog_cnt)
+		__field(struct pt_regs *, regs)
+	),
+
+	TP_fast_assign(
+		__entry->regs		= regs;
+		__entry->prog_cnt	= prog_cnt;
+	),
+
+	TP_printk("pc:%p", __entry->prog_cnt)
+);
+
+TRACE_EVENT(unhandled_abort,
+
+	TP_PROTO(struct pt_regs *regs, unsigned long addr, unsigned int fsr),
+
+	TP_ARGS(regs, addr, fsr),
+
+	TP_STRUCT__entry(
+		__field(struct pt_regs *, regs)
+		__field(unsigned long, addr)
+		__field(unsigned int, fsr)
+	),
+
+	TP_fast_assign(
+		__entry->regs	= regs;
+		__entry->addr	= addr;
+		__entry->fsr	= fsr;
+	),
+
+	TP_printk("addr:%lu, fsr:%u", __entry->addr, __entry->fsr)
+);
+
+TRACE_EVENT(kernel_panic,
+
+	TP_PROTO(long dummy),
+
+	TP_ARGS(dummy),
+
+	TP_STRUCT__entry(
+		__field(long, dummy)
+	),
+
+	TP_fast_assign(
+		__entry->dummy	= dummy;
+	),
+
+	TP_printk("dummy:%ld", __entry->dummy)
+);
+
+TRACE_EVENT(kernel_panic_late,
+
+	TP_PROTO(long dummy),
+
+	TP_ARGS(dummy),
+
+	TP_STRUCT__entry(
+		__field(long, dummy)
+	),
+
+	TP_fast_assign(
+		__entry->dummy	= dummy;
+	),
+
+	TP_printk("dummy:%ld", __entry->dummy)
+);
+
+#endif
+
+#include <trace/define_trace.h>
diff --git a/include/trace/events/iommu.h b/include/trace/events/iommu.h
index 2c7befb..9652037 100644
--- a/include/trace/events/iommu.h
+++ b/include/trace/events/iommu.h
@@ -161,6 +161,62 @@
 
 	TP_ARGS(dev, iova, flags)
 );
+
+DECLARE_EVENT_CLASS(iommu_errata_tlbi,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time),
+
+	TP_STRUCT__entry(
+		__string(device, dev_name(dev))
+		__field(u64, time)
+	),
+
+	TP_fast_assign(
+		__assign_str(device, dev_name(dev));
+		__entry->time = time;
+	),
+
+	TP_printk("IOMMU:%s %lld us",
+			__get_str(device), __entry->time
+	)
+);
+
+DEFINE_EVENT(iommu_errata_tlbi, errata_tlbi_start,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time)
+);
+
+DEFINE_EVENT(iommu_errata_tlbi, errata_tlbi_end,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time)
+);
+
+DEFINE_EVENT(iommu_errata_tlbi, errata_throttle_start,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time)
+);
+
+DEFINE_EVENT(iommu_errata_tlbi, errata_throttle_end,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time)
+);
+
+DEFINE_EVENT(iommu_errata_tlbi, errata_failed,
+
+	TP_PROTO(struct device *dev, u64 time),
+
+	TP_ARGS(dev, time)
+);
 #endif /* _TRACE_IOMMU_H */
 
 /* This part must be outside protection */
diff --git a/include/trace/events/thermal.h b/include/trace/events/thermal.h
index c0475a2..94ee287 100644
--- a/include/trace/events/thermal.h
+++ b/include/trace/events/thermal.h
@@ -20,6 +20,29 @@
 			 { THERMAL_TRIP_PASSIVE,  "PASSIVE"},	\
 			 { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
 
+TRACE_EVENT(thermal_query_temp,
+
+	TP_PROTO(struct thermal_zone_device *tz, int temp),
+
+	TP_ARGS(tz, temp),
+
+	TP_STRUCT__entry(
+		__string(thermal_zone, tz->type)
+		__field(int, id)
+		__field(int, temp)
+	),
+
+	TP_fast_assign(
+		__assign_str(thermal_zone, tz->type);
+		__entry->id = tz->id;
+		__entry->temp = temp;
+	),
+
+	TP_printk("thermal_zone=%s id=%d temp=%d",
+		__get_str(thermal_zone), __entry->id,
+		__entry->temp)
+);
+
 TRACE_EVENT(thermal_temperature,
 
 	TP_PROTO(struct thermal_zone_device *tz),
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index c88fd09..2f8536b 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -269,23 +269,24 @@
 		__entry->retval)
 );
 
-DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
-
+TRACE_EVENT(mm_vmscan_lru_isolate,
 	TP_PROTO(int classzone_idx,
 		int order,
 		unsigned long nr_requested,
 		unsigned long nr_scanned,
+		unsigned long nr_skipped,
 		unsigned long nr_taken,
 		isolate_mode_t isolate_mode,
 		int file),
 
-	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file),
+	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, file),
 
 	TP_STRUCT__entry(
 		__field(int, classzone_idx)
 		__field(int, order)
 		__field(unsigned long, nr_requested)
 		__field(unsigned long, nr_scanned)
+		__field(unsigned long, nr_skipped)
 		__field(unsigned long, nr_taken)
 		__field(isolate_mode_t, isolate_mode)
 		__field(int, file)
@@ -296,49 +297,23 @@
 		__entry->order = order;
 		__entry->nr_requested = nr_requested;
 		__entry->nr_scanned = nr_scanned;
+		__entry->nr_skipped = nr_skipped;
 		__entry->nr_taken = nr_taken;
 		__entry->isolate_mode = isolate_mode;
 		__entry->file = file;
 	),
 
-	TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
+	TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu file=%d",
 		__entry->isolate_mode,
 		__entry->classzone_idx,
 		__entry->order,
 		__entry->nr_requested,
 		__entry->nr_scanned,
+		__entry->nr_skipped,
 		__entry->nr_taken,
 		__entry->file)
 );
 
-DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
-
-	TP_PROTO(int classzone_idx,
-		int order,
-		unsigned long nr_requested,
-		unsigned long nr_scanned,
-		unsigned long nr_taken,
-		isolate_mode_t isolate_mode,
-		int file),
-
-	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
-
-);
-
-DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
-
-	TP_PROTO(int classzone_idx,
-		int order,
-		unsigned long nr_requested,
-		unsigned long nr_scanned,
-		unsigned long nr_taken,
-		isolate_mode_t isolate_mode,
-		int file),
-
-	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
-
-);
-
 TRACE_EVENT(mm_vmscan_writepage,
 
 	TP_PROTO(struct page *page),
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index 6ff08de..d5438d3 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -324,6 +324,7 @@
 #define DRM_EVENT_SYS_BACKLIGHT 0x80000003
 #define DRM_EVENT_SDE_POWER 0x80000004
 #define DRM_EVENT_IDLE_NOTIFY 0x80000005
+#define DRM_EVENT_PANEL_DEAD 0x80000006 /* ESD event */
 
 #define DRM_IOCTL_MSM_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
 #define DRM_IOCTL_MSM_GEM_NEW          DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
diff --git a/include/uapi/drm/msm_drm_pp.h b/include/uapi/drm/msm_drm_pp.h
index 5f70a57..0765527 100644
--- a/include/uapi/drm/msm_drm_pp.h
+++ b/include/uapi/drm/msm_drm_pp.h
@@ -174,6 +174,17 @@
 	__u32 strength;
 };
 
+#define HIST_V_SIZE 256
+/**
+ * struct drm_msm_hist - histogram feature structure
+ * @flags: for customizing operations
+ * @data: histogram data
+ */
+struct drm_msm_hist {
+	__u64 flags;
+	__u32 data[HIST_V_SIZE];
+};
+
 #define AD4_LUT_GRP0_SIZE 33
 #define AD4_LUT_GRP1_SIZE 32
 /*
diff --git a/include/uapi/drm/sde_drm.h b/include/uapi/drm/sde_drm.h
index 285508a..1a43659 100644
--- a/include/uapi/drm/sde_drm.h
+++ b/include/uapi/drm/sde_drm.h
@@ -295,6 +295,44 @@
 	struct sde_drm_de_v1 de;
 };
 
+/* Number of dest scalers supported */
+#define SDE_MAX_DS_COUNT 2
+
+/*
+ * Destination scaler flag config
+ */
+#define SDE_DRM_DESTSCALER_ENABLE           0x1
+#define SDE_DRM_DESTSCALER_SCALE_UPDATE     0x2
+#define SDE_DRM_DESTSCALER_ENHANCER_UPDATE  0x4
+#define SDE_DRM_DESTSCALER_PU_ENABLE        0x8
+
+/**
+ * struct sde_drm_dest_scaler_cfg - destination scaler config structure
+ * @flags:      Flag to switch between mode for destination scaler
+ *              refer to destination scaler flag config
+ * @index:      Destination scaler selection index
+ * @lm_width:   Layer mixer width configuration
+ * @lm_height:  Layer mixer height configuration
+ * @scaler_cfg: The scaling parameters for all the mode except disable
+ *              Userspace pointer to struct sde_drm_scaler_v2
+ */
+struct sde_drm_dest_scaler_cfg {
+	uint32_t flags;
+	uint32_t index;
+	uint32_t lm_width;
+	uint32_t lm_height;
+	uint64_t scaler_cfg;
+};
+
+/**
+ * struct sde_drm_dest_scaler_data - destination scaler data struct
+ * @num_dest_scaler: Number of dest scalers to be configured
+ * @ds_cfg:          Destination scaler block configuration
+ */
+struct sde_drm_dest_scaler_data {
+	uint32_t num_dest_scaler;
+	struct sde_drm_dest_scaler_cfg ds_cfg[SDE_MAX_DS_COUNT];
+};
 
 /*
  * Define constants for struct sde_drm_csc
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index cd758c2..ea727f2 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -63,7 +63,6 @@
 header-y += auto_fs4.h
 header-y += auto_fs.h
 header-y += auxvec.h
-header-y += avtimer.h
 header-y += ax25.h
 header-y += b1lli.h
 header-y += baycom.h
@@ -287,23 +286,6 @@
 header-y += mroute.h
 header-y += msdos_fs.h
 header-y += msg.h
-header-y += msm_audio.h
-header-y += msm_audio_aac.h
-header-y += msm_audio_ac3.h
-header-y += msm_audio_amrnb.h
-header-y += msm_audio_amrwb.h
-header-y += msm_audio_amrwbplus.h
-header-y += msm_audio_calibration.h
-header-y += msm_audio_mvs.h
-header-y += msm_audio_qcp.h
-header-y += msm_audio_sbc.h
-header-y += msm_audio_voicememo.h
-header-y += msm_audio_wma.h
-header-y += msm_audio_wmapro.h
-header-y += msm_audio_alac.h
-header-y += msm_audio_ape.h
-header-y += msm_audio_g711.h
-header-y += msm_audio_g711_dec.h
 header-y += msm_ion.h
 header-y += msm_ipc.h
 header-y += msm_kgsl.h
diff --git a/include/uapi/linux/avtimer.h b/include/uapi/linux/avtimer.h
deleted file mode 100644
index 96b5483..0000000
--- a/include/uapi/linux/avtimer.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _UAPI_AVTIMER_H
-#define _UAPI_AVTIMER_H
-
-#include <linux/ioctl.h>
-
-#define MAJOR_NUM 100
-
-#define IOCTL_GET_AVTIMER_TICK _IOR(MAJOR_NUM, 0, uint64_t)
-
-#endif
diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h
index a66c4ba..bbf02a6 100644
--- a/include/uapi/linux/fib_rules.h
+++ b/include/uapi/linux/fib_rules.h
@@ -54,8 +54,6 @@
 	FRA_TABLE,	/* Extended table id */
 	FRA_FWMASK,	/* mask for netfilter mark */
 	FRA_OIFNAME,
-	FRA_UID_START,	/* UID range */
-	FRA_UID_END,
 	FRA_PAD,
 	FRA_L3MDEV,	/* iif or oif is l3mdev goto its table */
 	FRA_UID_RANGE,	/* UID range */
diff --git a/include/uapi/linux/msm_audio.h b/include/uapi/linux/msm_audio.h
deleted file mode 100644
index 3213d00..0000000
--- a/include/uapi/linux/msm_audio.h
+++ /dev/null
@@ -1,475 +0,0 @@
-/* include/linux/msm_audio.h
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2012, 2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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 _UAPI_LINUX_MSM_AUDIO_H
-#define _UAPI_LINUX_MSM_AUDIO_H
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-
-/* PCM Audio */
-
-#define AUDIO_IOCTL_MAGIC 'a'
-
-#define AUDIO_START        _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned int)
-#define AUDIO_STOP         _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned int)
-#define AUDIO_FLUSH        _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned int)
-#define AUDIO_GET_CONFIG   _IOR(AUDIO_IOCTL_MAGIC, 3, \
-		struct msm_audio_config)
-#define AUDIO_SET_CONFIG   _IOW(AUDIO_IOCTL_MAGIC, 4, \
-		struct msm_audio_config)
-#define AUDIO_GET_STATS    _IOR(AUDIO_IOCTL_MAGIC, 5, \
-		struct msm_audio_stats)
-#define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned int)
-#define AUDIO_SET_ADRC     _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned int)
-#define AUDIO_SET_EQ       _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned int)
-#define AUDIO_SET_RX_IIR   _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned int)
-#define AUDIO_SET_VOLUME   _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned int)
-#define AUDIO_PAUSE        _IOW(AUDIO_IOCTL_MAGIC, 11, unsigned int)
-#define AUDIO_PLAY_DTMF    _IOW(AUDIO_IOCTL_MAGIC, 12, unsigned int)
-#define AUDIO_GET_EVENT    _IOR(AUDIO_IOCTL_MAGIC, 13, \
-		struct msm_audio_event)
-#define AUDIO_ABORT_GET_EVENT _IOW(AUDIO_IOCTL_MAGIC, 14, unsigned int)
-#define AUDIO_REGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 15, unsigned int)
-#define AUDIO_DEREGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 16, unsigned int)
-#define AUDIO_ASYNC_WRITE _IOW(AUDIO_IOCTL_MAGIC, 17, \
-		struct msm_audio_aio_buf)
-#define AUDIO_ASYNC_READ _IOW(AUDIO_IOCTL_MAGIC, 18, \
-		struct msm_audio_aio_buf)
-#define AUDIO_SET_INCALL _IOW(AUDIO_IOCTL_MAGIC, 19, struct msm_voicerec_mode)
-#define AUDIO_GET_NUM_SND_DEVICE _IOR(AUDIO_IOCTL_MAGIC, 20, unsigned int)
-#define AUDIO_GET_SND_DEVICES _IOWR(AUDIO_IOCTL_MAGIC, 21, \
-				struct msm_snd_device_list)
-#define AUDIO_ENABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 22, unsigned int)
-#define AUDIO_DISABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 23, unsigned int)
-#define AUDIO_ROUTE_STREAM _IOW(AUDIO_IOCTL_MAGIC, 24, \
-				struct msm_audio_route_config)
-#define AUDIO_GET_PCM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 30, unsigned int)
-#define AUDIO_SET_PCM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 31, unsigned int)
-#define AUDIO_SWITCH_DEVICE  _IOW(AUDIO_IOCTL_MAGIC, 32, unsigned int)
-#define AUDIO_SET_MUTE       _IOW(AUDIO_IOCTL_MAGIC, 33, unsigned int)
-#define AUDIO_UPDATE_ACDB    _IOW(AUDIO_IOCTL_MAGIC, 34, unsigned int)
-#define AUDIO_START_VOICE    _IOW(AUDIO_IOCTL_MAGIC, 35, unsigned int)
-#define AUDIO_STOP_VOICE     _IOW(AUDIO_IOCTL_MAGIC, 36, unsigned int)
-#define AUDIO_REINIT_ACDB    _IOW(AUDIO_IOCTL_MAGIC, 39, unsigned int)
-#define AUDIO_OUTPORT_FLUSH  _IOW(AUDIO_IOCTL_MAGIC, 40, unsigned short)
-#define AUDIO_SET_ERR_THRESHOLD_VALUE _IOW(AUDIO_IOCTL_MAGIC, 41, \
-					unsigned short)
-#define AUDIO_GET_BITSTREAM_ERROR_INFO _IOR(AUDIO_IOCTL_MAGIC, 42, \
-			       struct msm_audio_bitstream_error_info)
-
-#define AUDIO_SET_SRS_TRUMEDIA_PARAM _IOW(AUDIO_IOCTL_MAGIC, 43, unsigned int)
-
-/* Qualcomm technologies inc extensions */
-#define AUDIO_SET_STREAM_CONFIG   _IOW(AUDIO_IOCTL_MAGIC, 80, \
-				struct msm_audio_stream_config)
-#define AUDIO_GET_STREAM_CONFIG   _IOR(AUDIO_IOCTL_MAGIC, 81, \
-				struct msm_audio_stream_config)
-#define AUDIO_GET_SESSION_ID _IOR(AUDIO_IOCTL_MAGIC, 82, unsigned short)
-#define AUDIO_GET_STREAM_INFO   _IOR(AUDIO_IOCTL_MAGIC, 83, \
-			       struct msm_audio_bitstream_info)
-#define AUDIO_SET_PAN       _IOW(AUDIO_IOCTL_MAGIC, 84, unsigned int)
-#define AUDIO_SET_QCONCERT_PLUS       _IOW(AUDIO_IOCTL_MAGIC, 85, unsigned int)
-#define AUDIO_SET_MBADRC       _IOW(AUDIO_IOCTL_MAGIC, 86, unsigned int)
-#define AUDIO_SET_VOLUME_PATH   _IOW(AUDIO_IOCTL_MAGIC, 87, \
-				     struct msm_vol_info)
-#define AUDIO_SET_MAX_VOL_ALL _IOW(AUDIO_IOCTL_MAGIC, 88, unsigned int)
-#define AUDIO_ENABLE_AUDPRE  _IOW(AUDIO_IOCTL_MAGIC, 89, unsigned int)
-#define AUDIO_SET_AGC        _IOW(AUDIO_IOCTL_MAGIC, 90, unsigned int)
-#define AUDIO_SET_NS         _IOW(AUDIO_IOCTL_MAGIC, 91, unsigned int)
-#define AUDIO_SET_TX_IIR     _IOW(AUDIO_IOCTL_MAGIC, 92, unsigned int)
-#define AUDIO_GET_BUF_CFG    _IOW(AUDIO_IOCTL_MAGIC, 93, \
-					struct msm_audio_buf_cfg)
-#define AUDIO_SET_BUF_CFG    _IOW(AUDIO_IOCTL_MAGIC, 94, \
-					struct msm_audio_buf_cfg)
-#define AUDIO_SET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 95,  \
-					struct msm_acdb_cmd_device)
-#define AUDIO_GET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 96,  \
-					struct msm_acdb_cmd_device)
-
-#define AUDIO_REGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 97, \
-		struct msm_audio_ion_info)
-#define AUDIO_DEREGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 98, \
-		struct msm_audio_ion_info)
-#define AUDIO_SET_EFFECTS_CONFIG   _IOW(AUDIO_IOCTL_MAGIC, 99, \
-				struct msm_hwacc_effects_config)
-#define AUDIO_EFFECTS_SET_BUF_LEN _IOW(AUDIO_IOCTL_MAGIC, 100, \
-				struct msm_hwacc_buf_cfg)
-#define AUDIO_EFFECTS_GET_BUF_AVAIL _IOW(AUDIO_IOCTL_MAGIC, 101, \
-				struct msm_hwacc_buf_avail)
-#define AUDIO_EFFECTS_WRITE _IOW(AUDIO_IOCTL_MAGIC, 102, void *)
-#define AUDIO_EFFECTS_READ _IOWR(AUDIO_IOCTL_MAGIC, 103, void *)
-#define AUDIO_EFFECTS_SET_PP_PARAMS _IOW(AUDIO_IOCTL_MAGIC, 104, void *)
-
-#define AUDIO_PM_AWAKE      _IOW(AUDIO_IOCTL_MAGIC, 105, unsigned int)
-#define AUDIO_PM_RELAX      _IOW(AUDIO_IOCTL_MAGIC, 106, unsigned int)
-
-#define	AUDIO_MAX_COMMON_IOCTL_NUM	107
-
-
-#define HANDSET_MIC			0x01
-#define HANDSET_SPKR			0x02
-#define HEADSET_MIC			0x03
-#define HEADSET_SPKR_MONO		0x04
-#define HEADSET_SPKR_STEREO		0x05
-#define SPKR_PHONE_MIC			0x06
-#define SPKR_PHONE_MONO			0x07
-#define SPKR_PHONE_STEREO		0x08
-#define BT_SCO_MIC			0x09
-#define BT_SCO_SPKR			0x0A
-#define BT_A2DP_SPKR			0x0B
-#define TTY_HEADSET_MIC			0x0C
-#define TTY_HEADSET_SPKR		0x0D
-
-/* Default devices are not supported in a */
-/* device switching context. Only supported */
-/* for stream devices. */
-/* DO NOT USE */
-#define DEFAULT_TX			0x0E
-#define DEFAULT_RX			0x0F
-
-#define BT_A2DP_TX			0x10
-
-#define HEADSET_MONO_PLUS_SPKR_MONO_RX         0x11
-#define HEADSET_MONO_PLUS_SPKR_STEREO_RX       0x12
-#define HEADSET_STEREO_PLUS_SPKR_MONO_RX       0x13
-#define HEADSET_STEREO_PLUS_SPKR_STEREO_RX     0x14
-
-#define I2S_RX				0x20
-#define I2S_TX				0x21
-
-#define ADRC_ENABLE		0x0001
-#define EQUALIZER_ENABLE	0x0002
-#define IIR_ENABLE		0x0004
-#define QCONCERT_PLUS_ENABLE	0x0008
-#define MBADRC_ENABLE		0x0010
-#define SRS_ENABLE		0x0020
-#define SRS_DISABLE	0x0040
-
-#define AGC_ENABLE		0x0001
-#define NS_ENABLE		0x0002
-#define TX_IIR_ENABLE		0x0004
-#define FLUENCE_ENABLE		0x0008
-
-#define VOC_REC_UPLINK		0x00
-#define VOC_REC_DOWNLINK	0x01
-#define VOC_REC_BOTH		0x02
-
-struct msm_audio_config {
-	uint32_t buffer_size;
-	uint32_t buffer_count;
-	uint32_t channel_count;
-	uint32_t sample_rate;
-	uint32_t type;
-	uint32_t meta_field;
-	uint32_t bits;
-	uint32_t unused[3];
-};
-
-struct msm_audio_stream_config {
-	uint32_t buffer_size;
-	uint32_t buffer_count;
-};
-
-struct msm_audio_buf_cfg {
-	uint32_t meta_info_enable;
-	uint32_t frames_per_buf;
-};
-
-struct msm_audio_stats {
-	uint32_t byte_count;
-	uint32_t sample_count;
-	uint32_t unused[2];
-};
-
-struct msm_audio_ion_info {
-	int fd;
-	void *vaddr;
-};
-
-struct msm_audio_pmem_info {
-	int fd;
-	void *vaddr;
-};
-
-struct msm_audio_aio_buf {
-	void *buf_addr;
-	uint32_t buf_len;
-	uint32_t data_len;
-	void *private_data;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-/* Audio routing */
-
-#define SND_IOCTL_MAGIC 's'
-
-#define SND_MUTE_UNMUTED 0
-#define SND_MUTE_MUTED   1
-
-struct msm_mute_info {
-	uint32_t mute;
-	uint32_t path;
-};
-
-struct msm_vol_info {
-	uint32_t vol;
-	uint32_t path;
-};
-
-struct msm_voicerec_mode {
-	uint32_t rec_mode;
-};
-
-struct msm_snd_device_config {
-	uint32_t device;
-	uint32_t ear_mute;
-	uint32_t mic_mute;
-};
-
-#define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *)
-
-enum cad_device_path_type {
-	CAD_DEVICE_PATH_RX,	/*For Decoding session*/
-	CAD_DEVICE_PATH_TX,	/* For Encoding session*/
-	CAD_DEVICE_PATH_RX_TX, /* For Voice call */
-	CAD_DEVICE_PATH_LB,	/* For loopback (FM Analog)*/
-	CAD_DEVICE_PATH_MAX
-};
-
-struct cad_devices_type {
-	uint32_t rx_device;
-	uint32_t tx_device;
-	enum cad_device_path_type pathtype;
-};
-
-struct msm_cad_device_config {
-	struct cad_devices_type device;
-	uint32_t ear_mute;
-	uint32_t mic_mute;
-};
-
-#define CAD_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_cad_device_config *)
-
-#define SND_METHOD_VOICE 0
-#define SND_METHOD_MIDI 4
-
-struct msm_snd_volume_config {
-	uint32_t device;
-	uint32_t method;
-	uint32_t volume;
-};
-
-#define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *)
-
-struct msm_cad_volume_config {
-	struct cad_devices_type device;
-	uint32_t method;
-	uint32_t volume;
-};
-
-#define CAD_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_cad_volume_config *)
-
-/* Returns the number of SND endpoints supported. */
-
-#define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned int *)
-
-struct msm_snd_endpoint {
-	int id; /* input and output */
-	char name[64]; /* output only */
-};
-
-/* Takes an index between 0 and one less than the number returned by
- * SND_GET_NUM_ENDPOINTS, and returns the SND index and name of a
- * SND endpoint.  On input, the .id field contains the number of the
- * endpoint, and on exit it contains the SND index, while .name contains
- * the description of the endpoint.
- */
-
-#define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *)
-
-
-#define SND_AVC_CTL _IOW(SND_IOCTL_MAGIC, 6, unsigned int *)
-#define SND_AGC_CTL _IOW(SND_IOCTL_MAGIC, 7, unsigned int *)
-
-/*return the number of CAD endpoints supported. */
-
-#define CAD_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned int *)
-
-struct msm_cad_endpoint {
-	int id; /* input and output */
-	char name[64]; /* output only */
-};
-
-/* Takes an index between 0 and one less than the number returned by
- * SND_GET_NUM_ENDPOINTS, and returns the CAD index and name of a
- * CAD endpoint.  On input, the .id field contains the number of the
- * endpoint, and on exit it contains the SND index, while .name contains
- * the description of the endpoint.
- */
-
-#define CAD_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_cad_endpoint *)
-
-struct msm_audio_pcm_config {
-	uint32_t pcm_feedback;	/* 0 - disable > 0 - enable */
-	uint32_t buffer_count;	/* Number of buffers to allocate */
-	uint32_t buffer_size;	/* Size of buffer for capturing of
-				 * PCM samples
-				 */
-};
-
-#define AUDIO_EVENT_SUSPEND 0
-#define AUDIO_EVENT_RESUME 1
-#define AUDIO_EVENT_WRITE_DONE 2
-#define AUDIO_EVENT_READ_DONE   3
-#define AUDIO_EVENT_STREAM_INFO 4
-#define AUDIO_EVENT_BITSTREAM_ERROR_INFO 5
-
-#define AUDIO_CODEC_TYPE_MP3 0
-#define AUDIO_CODEC_TYPE_AAC 1
-
-struct msm_audio_bitstream_info {
-	uint32_t codec_type;
-	uint32_t chan_info;
-	uint32_t sample_rate;
-	uint32_t bit_stream_info;
-	uint32_t bit_rate;
-	uint32_t unused[3];
-};
-
-struct msm_audio_bitstream_error_info {
-	uint32_t dec_id;
-	uint32_t err_msg_indicator;
-	uint32_t err_type;
-};
-
-union msm_audio_event_payload {
-	struct msm_audio_aio_buf aio_buf;
-	struct msm_audio_bitstream_info stream_info;
-	struct msm_audio_bitstream_error_info error_info;
-	int reserved;
-};
-
-struct msm_audio_event {
-	int event_type;
-	int timeout_ms;
-	union msm_audio_event_payload event_payload;
-};
-
-#define MSM_SNDDEV_CAP_RX 0x1
-#define MSM_SNDDEV_CAP_TX 0x2
-#define MSM_SNDDEV_CAP_VOICE 0x4
-
-struct msm_snd_device_info {
-	uint32_t dev_id;
-	uint32_t dev_cap; /* bitmask describe capability of device */
-	char dev_name[64];
-};
-
-struct msm_snd_device_list {
-	uint32_t  num_dev; /* Indicate number of device info to be retrieved */
-	struct msm_snd_device_info *list;
-};
-
-struct msm_dtmf_config {
-	uint16_t path;
-	uint16_t dtmf_hi;
-	uint16_t dtmf_low;
-	uint16_t duration;
-	uint16_t tx_gain;
-	uint16_t rx_gain;
-	uint16_t mixing;
-};
-
-#define AUDIO_ROUTE_STREAM_VOICE_RX 0
-#define AUDIO_ROUTE_STREAM_VOICE_TX 1
-#define AUDIO_ROUTE_STREAM_PLAYBACK 2
-#define AUDIO_ROUTE_STREAM_REC      3
-
-struct msm_audio_route_config {
-	uint32_t stream_type;
-	uint32_t stream_id;
-	uint32_t dev_id;
-};
-
-#define AUDIO_MAX_EQ_BANDS 12
-
-struct msm_audio_eq_band {
-	uint16_t     band_idx; /* The band index, 0 .. 11 */
-	uint32_t     filter_type; /* Filter band type */
-	uint32_t     center_freq_hz; /* Filter band center frequency */
-	uint32_t     filter_gain; /* Filter band initial gain (dB) */
-			/* Range is +12 dB to -12 dB with 1dB increments. */
-	uint32_t     q_factor;
-} __attribute__ ((packed));
-
-struct msm_audio_eq_stream_config {
-	uint32_t	enable; /* Number of consequtive bands specified */
-	uint32_t	num_bands;
-	struct msm_audio_eq_band	eq_bands[AUDIO_MAX_EQ_BANDS];
-} __attribute__ ((packed));
-
-struct msm_acdb_cmd_device {
-	uint32_t     command_id;
-	uint32_t     device_id;
-	uint32_t     network_id;
-	uint32_t     sample_rate_id;      /* Actual sample rate value */
-	uint32_t     interface_id;        /* See interface id's above */
-	uint32_t     algorithm_block_id;  /* See enumerations above */
-	uint32_t     total_bytes;         /* Length in bytes used by buffer */
-	uint32_t     *phys_buf;           /* Physical Address of data */
-};
-
-struct msm_hwacc_data_config {
-	__u32 buf_size;
-	__u32 num_buf;
-	__u32 num_channels;
-	__u8 channel_map[8];
-	__u32 sample_rate;
-	__u32 bits_per_sample;
-};
-
-struct msm_hwacc_buf_cfg {
-	__u32 input_len;
-	__u32 output_len;
-};
-
-struct msm_hwacc_buf_avail {
-	__u32 input_num_avail;
-	__u32 output_num_avail;
-};
-
-struct msm_hwacc_effects_config {
-	struct msm_hwacc_data_config input;
-	struct msm_hwacc_data_config output;
-	struct msm_hwacc_buf_cfg buf_cfg;
-	__u32 meta_mode_enabled;
-	__u32 overwrite_topology;
-	__s32 topology;
-};
-
-#define ADSP_STREAM_PP_EVENT				0
-#define ADSP_STREAM_ENCDEC_EVENT			1
-#define ADSP_STREAM_IEC_61937_FMT_UPDATE_EVENT		2
-#define ADSP_STREAM_EVENT_MAX				3
-
-struct msm_adsp_event_data {
-	__u32 event_type;
-	__u32 payload_len;
-	__u8 payload[0];
-};
-
-#endif
diff --git a/include/uapi/linux/msm_audio_aac.h b/include/uapi/linux/msm_audio_aac.h
deleted file mode 100644
index 7e1e1b7..0000000
--- a/include/uapi/linux/msm_audio_aac.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_AAC_H
-#define _UAPI_MSM_AUDIO_AAC_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_SET_AAC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_aac_config)
-#define AUDIO_GET_AAC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_aac_config)
-
-#define AUDIO_SET_AAC_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+3), struct msm_audio_aac_enc_config)
-
-#define AUDIO_GET_AAC_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+4), struct msm_audio_aac_enc_config)
-
-#define AUDIO_SET_AAC_MIX_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+5), uint32_t)
-
-#define AUDIO_AAC_FORMAT_ADTS		-1
-#define	AUDIO_AAC_FORMAT_RAW		0x0000
-#define	AUDIO_AAC_FORMAT_PSUEDO_RAW	0x0001
-#define AUDIO_AAC_FORMAT_LOAS		0x0002
-#define AUDIO_AAC_FORMAT_ADIF		0x0003
-
-#define AUDIO_AAC_OBJECT_LC		0x0002
-#define AUDIO_AAC_OBJECT_LTP		0x0004
-#define AUDIO_AAC_OBJECT_ERLC		0x0011
-#define AUDIO_AAC_OBJECT_BSAC		0x0016
-
-#define AUDIO_AAC_SEC_DATA_RES_ON       0x0001
-#define AUDIO_AAC_SEC_DATA_RES_OFF      0x0000
-
-#define AUDIO_AAC_SCA_DATA_RES_ON       0x0001
-#define AUDIO_AAC_SCA_DATA_RES_OFF      0x0000
-
-#define AUDIO_AAC_SPEC_DATA_RES_ON      0x0001
-#define AUDIO_AAC_SPEC_DATA_RES_OFF     0x0000
-
-#define AUDIO_AAC_SBR_ON_FLAG_ON	0x0001
-#define AUDIO_AAC_SBR_ON_FLAG_OFF	0x0000
-
-#define AUDIO_AAC_SBR_PS_ON_FLAG_ON	0x0001
-#define AUDIO_AAC_SBR_PS_ON_FLAG_OFF	0x0000
-
-/* Primary channel on both left and right channels */
-#define AUDIO_AAC_DUAL_MONO_PL_PR  0
-/* Secondary channel on both left and right channels */
-#define AUDIO_AAC_DUAL_MONO_SL_SR  1
-/* Primary channel on right channel and 2nd on left channel */
-#define AUDIO_AAC_DUAL_MONO_SL_PR  2
-/* 2nd channel on right channel and primary on left channel */
-#define AUDIO_AAC_DUAL_MONO_PL_SR  3
-
-struct msm_audio_aac_config {
-	signed short format;
-	unsigned short audio_object;
-	unsigned short ep_config;	/* 0 ~ 3 useful only obj = ERLC */
-	unsigned short aac_section_data_resilience_flag;
-	unsigned short aac_scalefactor_data_resilience_flag;
-	unsigned short aac_spectral_data_resilience_flag;
-	unsigned short sbr_on_flag;
-	unsigned short sbr_ps_on_flag;
-	unsigned short dual_mono_mode;
-	unsigned short channel_configuration;
-	unsigned short sample_rate;
-};
-
-struct msm_audio_aac_enc_config {
-	uint32_t channels;
-	uint32_t sample_rate;
-	uint32_t bit_rate;
-	uint32_t stream_format;
-};
-
-#endif /* _UAPI_MSM_AUDIO_AAC_H */
diff --git a/include/uapi/linux/msm_audio_ac3.h b/include/uapi/linux/msm_audio_ac3.h
deleted file mode 100644
index 1df6e69..0000000
--- a/include/uapi/linux/msm_audio_ac3.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_AC3_H
-#define _UAPI_MSM_AUDIO_AC3_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_SET_AC3_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), unsigned int)
-#define AUDIO_GET_AC3_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), unsigned int)
-
-#define AUDAC3_DEF_WORDSIZE 0
-#define AUDAC3_DEF_USER_DOWNMIX_FLAG 0x0
-#define AUDAC3_DEF_USER_KARAOKE_FLAG 0x0
-#define AUDAC3_DEF_ERROR_CONCEALMENT 0
-#define AUDAC3_DEF_MAX_REPEAT_COUNT  0
-
-struct msm_audio_ac3_config {
-	unsigned short		numChans;
-	unsigned short		wordSize;
-	unsigned short		kCapableMode;
-	unsigned short		compMode;
-	unsigned short		outLfeOn;
-	unsigned short		outputMode;
-	unsigned short		stereoMode;
-	unsigned short		dualMonoMode;
-	unsigned short		fsCod;
-	unsigned short		pcmScaleFac;
-	unsigned short		dynRngScaleHi;
-	unsigned short		dynRngScaleLow;
-	unsigned short		user_downmix_flag;
-	unsigned short		user_karaoke_flag;
-	unsigned short		dm_address_high;
-	unsigned short		dm_address_low;
-	unsigned short		ko_address_high;
-	unsigned short		ko_address_low;
-	unsigned short		error_concealment;
-	unsigned short		max_rep_count;
-	unsigned short		channel_routing_mode[6];
-};
-
-#endif /* _UAPI_MSM_AUDIO_AC3_H */
diff --git a/include/uapi/linux/msm_audio_alac.h b/include/uapi/linux/msm_audio_alac.h
deleted file mode 100644
index 5476e96..0000000
--- a/include/uapi/linux/msm_audio_alac.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_ALAC_H
-#define _UAPI_MSM_AUDIO_ALAC_H
-
-#define AUDIO_GET_ALAC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_alac_config)
-#define AUDIO_SET_ALAC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_alac_config)
-
-struct msm_audio_alac_config {
-	uint32_t frameLength;
-	uint8_t compatVersion;
-	uint8_t bitDepth;
-	uint8_t pb; /* currently unused */
-	uint8_t mb; /* currently unused */
-	uint8_t kb; /* currently unused */
-	uint8_t channelCount;
-	uint16_t maxRun; /* currently unused */
-	uint32_t maxSize;
-	uint32_t averageBitRate;
-	uint32_t sampleRate;
-	uint32_t channelLayout;
-};
-
-#endif /* _UAPI_MSM_AUDIO_ALAC_H */
diff --git a/include/uapi/linux/msm_audio_amrnb.h b/include/uapi/linux/msm_audio_amrnb.h
deleted file mode 100644
index 619f928..0000000
--- a/include/uapi/linux/msm_audio_amrnb.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_AMRNB_H
-#define _UAPI_MSM_AUDIO_AMRNB_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_GET_AMRNB_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), unsigned int)
-#define AUDIO_SET_AMRNB_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), unsigned int)
-#define AUDIO_GET_AMRNB_ENC_CONFIG_V2  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+2), \
-	struct msm_audio_amrnb_enc_config_v2)
-#define AUDIO_SET_AMRNB_ENC_CONFIG_V2  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+3), \
-	struct msm_audio_amrnb_enc_config_v2)
-
-struct msm_audio_amrnb_enc_config {
-	unsigned short voicememoencweight1;
-	unsigned short voicememoencweight2;
-	unsigned short voicememoencweight3;
-	unsigned short voicememoencweight4;
-	unsigned short dtx_mode_enable; /* 0xFFFF - enable, 0- disable */
-	unsigned short test_mode_enable; /* 0xFFFF - enable, 0- disable */
-	unsigned short enc_mode; /* 0-MR475,1-MR515,2-MR59,3-MR67,4-MR74
-				  * 5-MR795, 6- MR102, 7- MR122(default)
-				  */
-};
-
-struct msm_audio_amrnb_enc_config_v2 {
-	uint32_t band_mode;
-	uint32_t dtx_enable;
-	uint32_t frame_format;
-};
-#endif /* _UAPI_MSM_AUDIO_AMRNB_H */
diff --git a/include/uapi/linux/msm_audio_amrwb.h b/include/uapi/linux/msm_audio_amrwb.h
deleted file mode 100644
index 5124038..0000000
--- a/include/uapi/linux/msm_audio_amrwb.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_AMRWB_H
-#define _UAPI_MSM_AUDIO_AMRWB_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_GET_AMRWB_ENC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), \
-	struct msm_audio_amrwb_enc_config)
-#define AUDIO_SET_AMRWB_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), \
-	struct msm_audio_amrwb_enc_config)
-
-struct msm_audio_amrwb_enc_config {
-	uint32_t band_mode;
-	uint32_t dtx_enable;
-	uint32_t frame_format;
-};
-#endif /* _UAPI_MSM_AUDIO_AMRWB_H */
diff --git a/include/uapi/linux/msm_audio_amrwbplus.h b/include/uapi/linux/msm_audio_amrwbplus.h
deleted file mode 100644
index ba2d06e..0000000
--- a/include/uapi/linux/msm_audio_amrwbplus.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_AMR_WB_PLUS_H
-#define _UAPI_MSM_AUDIO_AMR_WB_PLUS_H
-
-#define AUDIO_GET_AMRWBPLUS_CONFIG_V2  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+2), struct msm_audio_amrwbplus_config_v2)
-#define AUDIO_SET_AMRWBPLUS_CONFIG_V2  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+3), struct msm_audio_amrwbplus_config_v2)
-
-struct msm_audio_amrwbplus_config_v2 {
-	unsigned int size_bytes;
-	unsigned int version;
-	unsigned int num_channels;
-	unsigned int amr_band_mode;
-	unsigned int amr_dtx_mode;
-	unsigned int amr_frame_fmt;
-	unsigned int amr_lsf_idx;
-};
-#endif /* _UAPI_MSM_AUDIO_AMR_WB_PLUS_H */
diff --git a/include/uapi/linux/msm_audio_ape.h b/include/uapi/linux/msm_audio_ape.h
deleted file mode 100644
index 587d3bc..0000000
--- a/include/uapi/linux/msm_audio_ape.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* The following structure has been taken
- * from Monkey's Audio SDK with permission
- */
-
-#ifndef _UAPI_MSM_AUDIO_APE_H
-#define _UAPI_MSM_AUDIO_APE_H
-
-#define AUDIO_GET_APE_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_ape_config)
-#define AUDIO_SET_APE_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_ape_config)
-
-struct msm_audio_ape_config {
-	uint16_t compatibleVersion;
-	uint16_t compressionLevel;
-	uint32_t formatFlags;
-	uint32_t blocksPerFrame;
-	uint32_t finalFrameBlocks;
-	uint32_t totalFrames;
-	uint16_t bitsPerSample;
-	uint16_t numChannels;
-	uint32_t sampleRate;
-	uint32_t seekTablePresent;
-};
-
-#endif /* _UAPI_MSM_AUDIO_APE_H */
diff --git a/include/uapi/linux/msm_audio_calibration.h b/include/uapi/linux/msm_audio_calibration.h
deleted file mode 100644
index 5a0b860..0000000
--- a/include/uapi/linux/msm_audio_calibration.h
+++ /dev/null
@@ -1,719 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_CALIBRATION_H
-#define _UAPI_MSM_AUDIO_CALIBRATION_H
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-
-#define CAL_IOCTL_MAGIC 'a'
-
-#define AUDIO_ALLOCATE_CALIBRATION	_IOWR(CAL_IOCTL_MAGIC, \
-							200, void *)
-#define AUDIO_DEALLOCATE_CALIBRATION	_IOWR(CAL_IOCTL_MAGIC, \
-							201, void *)
-#define AUDIO_PREPARE_CALIBRATION	_IOWR(CAL_IOCTL_MAGIC, \
-							202, void *)
-#define AUDIO_SET_CALIBRATION		_IOWR(CAL_IOCTL_MAGIC, \
-							203, void *)
-#define AUDIO_GET_CALIBRATION		_IOWR(CAL_IOCTL_MAGIC, \
-							204, void *)
-#define AUDIO_POST_CALIBRATION		_IOWR(CAL_IOCTL_MAGIC, \
-							205, void *)
-
-/* For Real-Time Audio Calibration */
-#define AUDIO_GET_RTAC_ADM_INFO		_IOR(CAL_IOCTL_MAGIC, \
-							207, void *)
-#define AUDIO_GET_RTAC_VOICE_INFO	_IOR(CAL_IOCTL_MAGIC, \
-							208, void *)
-#define AUDIO_GET_RTAC_ADM_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							209, void *)
-#define AUDIO_SET_RTAC_ADM_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							210, void *)
-#define AUDIO_GET_RTAC_ASM_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							211, void *)
-#define AUDIO_SET_RTAC_ASM_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							212, void *)
-#define AUDIO_GET_RTAC_CVS_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							213, void *)
-#define AUDIO_SET_RTAC_CVS_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							214, void *)
-#define AUDIO_GET_RTAC_CVP_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							215, void *)
-#define AUDIO_SET_RTAC_CVP_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							216, void *)
-#define AUDIO_GET_RTAC_AFE_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							217, void *)
-#define AUDIO_SET_RTAC_AFE_CAL		_IOWR(CAL_IOCTL_MAGIC, \
-							218, void *)
-enum {
-	CVP_VOC_RX_TOPOLOGY_CAL_TYPE = 0,
-	CVP_VOC_TX_TOPOLOGY_CAL_TYPE,
-	CVP_VOCPROC_STATIC_CAL_TYPE,
-	CVP_VOCPROC_DYNAMIC_CAL_TYPE,
-	CVS_VOCSTRM_STATIC_CAL_TYPE,
-	CVP_VOCDEV_CFG_CAL_TYPE,
-	CVP_VOCPROC_STATIC_COL_CAL_TYPE,
-	CVP_VOCPROC_DYNAMIC_COL_CAL_TYPE,
-	CVS_VOCSTRM_STATIC_COL_CAL_TYPE,
-
-	ADM_TOPOLOGY_CAL_TYPE,
-	ADM_CUST_TOPOLOGY_CAL_TYPE,
-	ADM_AUDPROC_CAL_TYPE,
-	ADM_AUDVOL_CAL_TYPE,
-
-	ASM_TOPOLOGY_CAL_TYPE,
-	ASM_CUST_TOPOLOGY_CAL_TYPE,
-	ASM_AUDSTRM_CAL_TYPE,
-
-	AFE_COMMON_RX_CAL_TYPE,
-	AFE_COMMON_TX_CAL_TYPE,
-	AFE_ANC_CAL_TYPE,
-	AFE_AANC_CAL_TYPE,
-	AFE_FB_SPKR_PROT_CAL_TYPE,
-	AFE_HW_DELAY_CAL_TYPE,
-	AFE_SIDETONE_CAL_TYPE,
-	AFE_TOPOLOGY_CAL_TYPE,
-	AFE_CUST_TOPOLOGY_CAL_TYPE,
-
-	LSM_CUST_TOPOLOGY_CAL_TYPE,
-	LSM_TOPOLOGY_CAL_TYPE,
-	LSM_CAL_TYPE,
-
-	ADM_RTAC_INFO_CAL_TYPE,
-	VOICE_RTAC_INFO_CAL_TYPE,
-	ADM_RTAC_APR_CAL_TYPE,
-	ASM_RTAC_APR_CAL_TYPE,
-	VOICE_RTAC_APR_CAL_TYPE,
-
-	MAD_CAL_TYPE,
-	ULP_AFE_CAL_TYPE,
-	ULP_LSM_CAL_TYPE,
-
-	DTS_EAGLE_CAL_TYPE,
-	AUDIO_CORE_METAINFO_CAL_TYPE,
-	SRS_TRUMEDIA_CAL_TYPE,
-
-	CORE_CUSTOM_TOPOLOGIES_CAL_TYPE,
-	ADM_RTAC_AUDVOL_CAL_TYPE,
-
-	ULP_LSM_TOPOLOGY_ID_CAL_TYPE,
-	AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE,
-	AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE,
-	AFE_SIDETONE_IIR_CAL_TYPE,
-	MAX_CAL_TYPES,
-};
-
-#define AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE
-#define AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE
-
-#define AFE_SIDETONE_IIR_CAL_TYPE AFE_SIDETONE_IIR_CAL_TYPE
-
-enum {
-	VERSION_0_0,
-};
-
-enum {
-	PER_VOCODER_CAL_BIT_MASK = 0x10000,
-};
-
-#define MAX_IOCTL_CMD_SIZE	512
-
-/* common structures */
-
-struct audio_cal_header {
-	int32_t		data_size;
-	int32_t		version;
-	int32_t		cal_type;
-	int32_t		cal_type_size;
-};
-
-struct audio_cal_type_header {
-	int32_t		version;
-	int32_t		buffer_number;
-};
-
-struct audio_cal_data {
-	/* Size of cal data at mem_handle allocation or at vaddr */
-	int32_t		cal_size;
-	/* If mem_handle if shared memory is used*/
-	int32_t		mem_handle;
-	/* size of virtual memory if shared memory not used */
-};
-
-
-/* AUDIO_ALLOCATE_CALIBRATION */
-struct audio_cal_type_alloc {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-};
-
-struct audio_cal_alloc {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_alloc	cal_type;
-};
-
-
-/* AUDIO_DEALLOCATE_CALIBRATION */
-struct audio_cal_type_dealloc {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-};
-
-struct audio_cal_dealloc {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_dealloc	cal_type;
-};
-
-
-/* AUDIO_PREPARE_CALIBRATION */
-struct audio_cal_type_prepare {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-};
-
-struct audio_cal_prepare {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_prepare	cal_type;
-};
-
-
-/* AUDIO_POST_CALIBRATION */
-struct audio_cal_type_post {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-};
-
-struct audio_cal_post {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_post	cal_type;
-};
-
-/*AUDIO_CORE_META_INFO */
-
-struct audio_cal_info_metainfo {
-	uint32_t nKey;
-};
-
-/* Cal info types */
-enum {
-	RX_DEVICE,
-	TX_DEVICE,
-	MAX_PATH_TYPE
-};
-
-struct audio_cal_info_adm_top {
-	int32_t		topology;
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		app_type;
-	int32_t		sample_rate;
-};
-
-struct audio_cal_info_audproc {
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		app_type;
-	int32_t		sample_rate;
-};
-
-struct audio_cal_info_audvol {
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		app_type;
-	int32_t		vol_index;
-};
-
-struct audio_cal_info_afe {
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		sample_rate;
-};
-
-struct audio_cal_info_afe_top {
-	int32_t		topology;
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		sample_rate;
-};
-
-struct audio_cal_info_asm_top {
-	int32_t		topology;
-	int32_t		app_type;
-};
-
-struct audio_cal_info_audstrm {
-	int32_t		app_type;
-};
-
-struct audio_cal_info_aanc {
-	int32_t		acdb_id;
-};
-
-#define MAX_HW_DELAY_ENTRIES	25
-
-struct audio_cal_hw_delay_entry {
-	uint32_t sample_rate;
-	uint32_t delay_usec;
-};
-
-struct audio_cal_hw_delay_data {
-	uint32_t				num_entries;
-	struct audio_cal_hw_delay_entry		entry[MAX_HW_DELAY_ENTRIES];
-};
-
-struct audio_cal_info_hw_delay {
-	int32_t					acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t					path;
-	int32_t					property_type;
-	struct audio_cal_hw_delay_data		data;
-};
-
-enum msm_spkr_prot_states {
-	MSM_SPKR_PROT_CALIBRATED,
-	MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS,
-	MSM_SPKR_PROT_DISABLED,
-	MSM_SPKR_PROT_NOT_CALIBRATED,
-	MSM_SPKR_PROT_PRE_CALIBRATED,
-	MSM_SPKR_PROT_IN_FTM_MODE
-};
-#define MSM_SPKR_PROT_IN_FTM_MODE MSM_SPKR_PROT_IN_FTM_MODE
-
-enum msm_spkr_count {
-	SP_V2_SPKR_1,
-	SP_V2_SPKR_2,
-	SP_V2_NUM_MAX_SPKRS
-};
-
-struct audio_cal_info_spk_prot_cfg {
-	int32_t		r0[SP_V2_NUM_MAX_SPKRS];
-	int32_t		t0[SP_V2_NUM_MAX_SPKRS];
-	uint32_t	quick_calib_flag;
-	uint32_t	mode;
-	/*
-	 * 0 - Start spk prot
-	 * 1 - Start calib
-	 * 2 - Disable spk prot
-	 */
-};
-
-struct audio_cal_info_sp_th_vi_ftm_cfg {
-	uint32_t	wait_time[SP_V2_NUM_MAX_SPKRS];
-	uint32_t	ftm_time[SP_V2_NUM_MAX_SPKRS];
-	uint32_t	mode;
-	/*
-	 * 0 - normal running mode
-	 * 1 - Calibration
-	 * 2 - FTM mode
-	 */
-};
-
-struct audio_cal_info_sp_ex_vi_ftm_cfg {
-	uint32_t	wait_time[SP_V2_NUM_MAX_SPKRS];
-	uint32_t	ftm_time[SP_V2_NUM_MAX_SPKRS];
-	uint32_t	mode;
-	/*
-	 * 0 - normal running mode
-	 * 2 - FTM mode
-	 */
-};
-
-struct audio_cal_info_sp_ex_vi_param {
-	int32_t		freq_q20[SP_V2_NUM_MAX_SPKRS];
-	int32_t		resis_q24[SP_V2_NUM_MAX_SPKRS];
-	int32_t		qmct_q24[SP_V2_NUM_MAX_SPKRS];
-	int32_t		status[SP_V2_NUM_MAX_SPKRS];
-};
-
-struct audio_cal_info_sp_th_vi_param {
-	int32_t		r_dc_q24[SP_V2_NUM_MAX_SPKRS];
-	int32_t		temp_q22[SP_V2_NUM_MAX_SPKRS];
-	int32_t		status[SP_V2_NUM_MAX_SPKRS];
-};
-
-struct audio_cal_info_msm_spk_prot_status {
-	int32_t		r0[SP_V2_NUM_MAX_SPKRS];
-	int32_t		status;
-};
-
-struct audio_cal_info_sidetone {
-	uint16_t	enable;
-	uint16_t	gain;
-	int32_t		tx_acdb_id;
-	int32_t		rx_acdb_id;
-	int32_t		mid;
-	int32_t		pid;
-};
-
-#define MAX_SIDETONE_IIR_DATA_SIZE   224
-#define MAX_NO_IIR_FILTER_STAGE      10
-
-struct audio_cal_info_sidetone_iir {
-	uint16_t	iir_enable;
-	uint16_t	num_biquad_stages;
-	uint16_t	pregain;
-	int32_t	        tx_acdb_id;
-	int32_t	        rx_acdb_id;
-	int32_t	        mid;
-	int32_t	        pid;
-	uint8_t	        iir_config[MAX_SIDETONE_IIR_DATA_SIZE];
-};
-struct audio_cal_info_lsm_top {
-	int32_t		topology;
-	int32_t		acdb_id;
-	int32_t		app_type;
-};
-
-
-struct audio_cal_info_lsm {
-	int32_t		acdb_id;
-	/* RX_DEVICE or TX_DEVICE */
-	int32_t		path;
-	int32_t		app_type;
-};
-
-struct audio_cal_info_voc_top {
-	int32_t		topology;
-	int32_t		acdb_id;
-};
-
-struct audio_cal_info_vocproc {
-	int32_t		tx_acdb_id;
-	int32_t		rx_acdb_id;
-	int32_t		tx_sample_rate;
-	int32_t		rx_sample_rate;
-};
-
-enum {
-	DEFAULT_FEATURE_SET,
-	VOL_BOOST_FEATURE_SET,
-};
-
-struct audio_cal_info_vocvol {
-	int32_t		tx_acdb_id;
-	int32_t		rx_acdb_id;
-	/* DEFAULT_ or VOL_BOOST_FEATURE_SET */
-	int32_t		feature_set;
-};
-
-struct audio_cal_info_vocdev_cfg {
-	int32_t		tx_acdb_id;
-	int32_t		rx_acdb_id;
-};
-
-#define MAX_VOICE_COLUMNS	20
-
-union audio_cal_col_na {
-	uint8_t		val8;
-	uint16_t	val16;
-	uint32_t	val32;
-	uint64_t	val64;
-} __packed;
-
-struct audio_cal_col {
-	uint32_t		id;
-	uint32_t		type;
-	union audio_cal_col_na	na_value;
-} __packed;
-
-struct audio_cal_col_data {
-	uint32_t		num_columns;
-	struct audio_cal_col	column[MAX_VOICE_COLUMNS];
-} __packed;
-
-struct audio_cal_info_voc_col {
-	int32_t				table_id;
-	int32_t				tx_acdb_id;
-	int32_t				rx_acdb_id;
-	struct audio_cal_col_data	data;
-};
-
-/* AUDIO_SET_CALIBRATION & */
-struct audio_cal_type_basic {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-};
-
-struct audio_cal_basic {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_basic	cal_type;
-};
-
-struct audio_cal_type_adm_top {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_adm_top	cal_info;
-};
-
-struct audio_cal_adm_top {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_adm_top	cal_type;
-};
-
-struct audio_cal_type_metainfo {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_metainfo	cal_info;
-};
-
-struct audio_core_metainfo {
-	struct audio_cal_header	  hdr;
-	struct audio_cal_type_metainfo cal_type;
-};
-
-struct audio_cal_type_audproc {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_audproc	cal_info;
-};
-
-struct audio_cal_audproc {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_audproc	cal_type;
-};
-
-struct audio_cal_type_audvol {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_audvol	cal_info;
-};
-
-struct audio_cal_audvol {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_audvol	cal_type;
-};
-
-struct audio_cal_type_asm_top {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_asm_top	cal_info;
-};
-
-struct audio_cal_asm_top {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_asm_top	cal_type;
-};
-
-struct audio_cal_type_audstrm {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_audstrm	cal_info;
-};
-
-struct audio_cal_audstrm {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_audstrm	cal_type;
-};
-
-struct audio_cal_type_afe {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_afe	cal_info;
-};
-
-struct audio_cal_afe {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_afe	cal_type;
-};
-
-struct audio_cal_type_afe_top {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_afe_top	cal_info;
-};
-
-struct audio_cal_afe_top {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_afe_top	cal_type;
-};
-
-struct audio_cal_type_aanc {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_aanc	cal_info;
-};
-
-struct audio_cal_aanc {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_aanc	cal_type;
-};
-
-struct audio_cal_type_fb_spk_prot_cfg {
-	struct audio_cal_type_header		cal_hdr;
-	struct audio_cal_data			cal_data;
-	struct audio_cal_info_spk_prot_cfg	cal_info;
-};
-
-struct audio_cal_fb_spk_prot_cfg {
-	struct audio_cal_header			hdr;
-	struct audio_cal_type_fb_spk_prot_cfg	cal_type;
-};
-
-struct audio_cal_type_sp_th_vi_ftm_cfg {
-	struct audio_cal_type_header		cal_hdr;
-	struct audio_cal_data			cal_data;
-	struct audio_cal_info_sp_th_vi_ftm_cfg	cal_info;
-};
-
-struct audio_cal_sp_th_vi_ftm_cfg {
-	struct audio_cal_header			hdr;
-	struct audio_cal_type_sp_th_vi_ftm_cfg	cal_type;
-};
-
-struct audio_cal_type_sp_ex_vi_ftm_cfg {
-	struct audio_cal_type_header		cal_hdr;
-	struct audio_cal_data			cal_data;
-	struct audio_cal_info_sp_ex_vi_ftm_cfg	cal_info;
-};
-
-struct audio_cal_sp_ex_vi_ftm_cfg {
-	struct audio_cal_header			hdr;
-	struct audio_cal_type_sp_ex_vi_ftm_cfg	cal_type;
-};
-struct audio_cal_type_hw_delay {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_hw_delay	cal_info;
-};
-
-struct audio_cal_hw_delay {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_hw_delay	cal_type;
-};
-
-struct audio_cal_type_sidetone {
-	struct audio_cal_type_header		cal_hdr;
-	struct audio_cal_data			cal_data;
-	struct audio_cal_info_sidetone		cal_info;
-};
-
-struct audio_cal_sidetone {
-	struct audio_cal_header			hdr;
-	struct audio_cal_type_sidetone		cal_type;
-};
-
-struct audio_cal_type_sidetone_iir {
-	struct audio_cal_type_header	   cal_hdr;
-	struct audio_cal_data		   cal_data;
-	struct audio_cal_info_sidetone_iir cal_info;
-};
-
-struct audio_cal_sidetone_iir {
-	struct audio_cal_header		   hdr;
-	struct audio_cal_type_sidetone_iir cal_type;
-};
-
-struct audio_cal_type_lsm_top {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_lsm_top	cal_info;
-};
-
-struct audio_cal_lsm_top {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_lsm_top	cal_type;
-};
-
-struct audio_cal_type_lsm {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_lsm	cal_info;
-};
-
-struct audio_cal_lsm {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_lsm	cal_type;
-};
-
-struct audio_cal_type_voc_top {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_voc_top	cal_info;
-};
-
-struct audio_cal_voc_top {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_voc_top	cal_type;
-};
-
-struct audio_cal_type_vocproc {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_vocproc	cal_info;
-};
-
-struct audio_cal_vocproc {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_vocproc	cal_type;
-};
-
-struct audio_cal_type_vocvol {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_vocvol	cal_info;
-};
-
-struct audio_cal_vocvol {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_vocvol	cal_type;
-};
-
-struct audio_cal_type_vocdev_cfg {
-	struct audio_cal_type_header		cal_hdr;
-	struct audio_cal_data			cal_data;
-	struct audio_cal_info_vocdev_cfg	cal_info;
-};
-
-struct audio_cal_vocdev_cfg {
-	struct audio_cal_header			hdr;
-	struct audio_cal_type_vocdev_cfg	cal_type;
-};
-
-struct audio_cal_type_voc_col {
-	struct audio_cal_type_header	cal_hdr;
-	struct audio_cal_data		cal_data;
-	struct audio_cal_info_voc_col	cal_info;
-};
-
-struct audio_cal_voc_col {
-	struct audio_cal_header		hdr;
-	struct audio_cal_type_voc_col	cal_type;
-};
-
-/* AUDIO_GET_CALIBRATION */
-struct audio_cal_type_fb_spk_prot_status {
-	struct audio_cal_type_header			cal_hdr;
-	struct audio_cal_data				cal_data;
-	struct audio_cal_info_msm_spk_prot_status	cal_info;
-};
-
-struct audio_cal_fb_spk_prot_status {
-	struct audio_cal_header				hdr;
-	struct audio_cal_type_fb_spk_prot_status	cal_type;
-};
-
-struct audio_cal_type_sp_th_vi_param {
-	struct audio_cal_type_header			cal_hdr;
-	struct audio_cal_data				cal_data;
-	struct audio_cal_info_sp_th_vi_param		cal_info;
-};
-
-struct audio_cal_sp_th_vi_param {
-	struct audio_cal_header				hdr;
-	struct audio_cal_type_sp_th_vi_param		cal_type;
-};
-struct audio_cal_type_sp_ex_vi_param {
-	struct audio_cal_type_header			cal_hdr;
-	struct audio_cal_data				cal_data;
-	struct audio_cal_info_sp_ex_vi_param		cal_info;
-};
-
-struct audio_cal_sp_ex_vi_param {
-	struct audio_cal_header				hdr;
-	struct audio_cal_type_sp_ex_vi_param		cal_type;
-};
-#endif /* _UAPI_MSM_AUDIO_CALIBRATION_H */
diff --git a/include/uapi/linux/msm_audio_g711.h b/include/uapi/linux/msm_audio_g711.h
deleted file mode 100644
index 48ebd6a..0000000
--- a/include/uapi/linux/msm_audio_g711.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_G711_H
-#define _UAPI_MSM_AUDIO_G711_H
-
-#include <linux/msm_audio.h>
-
-struct msm_audio_g711_enc_config {
-	uint32_t sample_rate;
-};
-
-#define AUDIO_SET_G711_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_enc_config)
-
-#define AUDIO_GET_G711_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_enc_config)
-
-
-#endif /* _UAPI_MSM_AUDIO_G711_H */
diff --git a/include/uapi/linux/msm_audio_g711_dec.h b/include/uapi/linux/msm_audio_g711_dec.h
deleted file mode 100644
index ff7e4ce..0000000
--- a/include/uapi/linux/msm_audio_g711_dec.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_G711_H
-#define _UAPI_MSM_AUDIO_G711_H
-
-#include <linux/msm_audio.h>
-
-struct msm_audio_g711_dec_config {
-	uint32_t sample_rate;
-};
-
-#define AUDIO_SET_G711_DEC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_g711_dec_config)
-
-#define AUDIO_GET_G711_DEC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_g711_dec_config)
-
-#endif /* _UAPI_MSM_AUDIO_G711_H */
diff --git a/include/uapi/linux/msm_audio_mvs.h b/include/uapi/linux/msm_audio_mvs.h
deleted file mode 100644
index 5b76bf9..0000000
--- a/include/uapi/linux/msm_audio_mvs.h
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_MVS_H
-#define _UAPI_MSM_AUDIO_MVS_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_GET_MVS_CONFIG _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM + 0), unsigned int)
-#define AUDIO_SET_MVS_CONFIG _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM + 1), unsigned int)
-
-/* MVS modes */
-#define MVS_MODE_IS733 0x1 /*QCELP 13K*/
-#define MVS_MODE_IS127 0x2 /*EVRC-8k*/
-#define MVS_MODE_4GV_NB 0x3 /*EVRC-B*/
-#define MVS_MODE_4GV_WB 0x4 /*EVRC-WB*/
-#define MVS_MODE_AMR 0x5
-#define MVS_MODE_EFR 0x6
-#define MVS_MODE_FR 0x7
-#define MVS_MODE_HR 0x8
-#define MVS_MODE_LINEAR_PCM 0x9
-#define MVS_MODE_G711 0xA
-#define MVS_MODE_PCM 0xC
-#define MVS_MODE_AMR_WB 0xD
-#define MVS_MODE_G729A 0xE
-#define MVS_MODE_G711A 0xF
-#define MVS_MODE_G722 0x10
-#define MVS_MODE_PCM_WB 0x12
-
-enum msm_audio_amr_mode {
-	MVS_AMR_MODE_0475, /* AMR 4.75 kbps */
-	MVS_AMR_MODE_0515, /* AMR 5.15 kbps */
-	MVS_AMR_MODE_0590, /* AMR 5.90 kbps */
-	MVS_AMR_MODE_0670, /* AMR 6.70 kbps */
-	MVS_AMR_MODE_0740, /* AMR 7.40 kbps */
-	MVS_AMR_MODE_0795, /* AMR 7.95 kbps */
-	MVS_AMR_MODE_1020, /* AMR 10.20 kbps */
-	MVS_AMR_MODE_1220, /* AMR 12.20 kbps */
-	MVS_AMR_MODE_0660, /* AMR-WB 6.60 kbps */
-	MVS_AMR_MODE_0885, /* AMR-WB 8.85 kbps */
-	MVS_AMR_MODE_1265, /* AMR-WB 12.65 kbps */
-	MVS_AMR_MODE_1425, /* AMR-WB 14.25 kbps */
-	MVS_AMR_MODE_1585, /* AMR-WB 15.85 kbps */
-	MVS_AMR_MODE_1825, /* AMR-WB 18.25 kbps */
-	MVS_AMR_MODE_1985, /* AMR-WB 19.85 kbps */
-	MVS_AMR_MODE_2305, /* AMR-WB 23.05 kbps */
-	MVS_AMR_MODE_2385, /* AMR-WB 23.85 kbps */
-	MVS_AMR_MODE_UNDEF
-};
-
-/* The MVS VOC rate type is used to identify the rate of QCELP 13K(IS733),
- * EVRC(IS127), 4GV, or 4GV-WB frame.
- */
-enum msm_audio_voc_rate {
-		MVS_VOC_0_RATE, /* Blank frame */
-		MVS_VOC_8_RATE, /* 1/8 rate    */
-		MVS_VOC_4_RATE, /* 1/4 rate    */
-		MVS_VOC_2_RATE, /* 1/2 rate    */
-		MVS_VOC_1_RATE, /* Full rate   */
-		MVS_VOC_ERASURE, /* erasure frame */
-		MVS_VOC_RATE_MAX,
-		MVS_VOC_RATE_UNDEF = MVS_VOC_RATE_MAX
-};
-
-enum msm_audio_amr_frame_type {
-	MVS_AMR_SPEECH_GOOD,	      /* Good speech frame              */
-	MVS_AMR_SPEECH_DEGRADED,      /* Speech degraded                */
-	MVS_AMR_ONSET,		      /* Onset                          */
-	MVS_AMR_SPEECH_BAD,	      /* Corrupt speech frame (bad CRC) */
-	MVS_AMR_SID_FIRST,	      /* First silence descriptor       */
-	MVS_AMR_SID_UPDATE,	      /* Comfort noise frame            */
-	MVS_AMR_SID_BAD,	      /* Corrupt SID frame (bad CRC)    */
-	MVS_AMR_NO_DATA,	      /* Nothing to transmit            */
-	MVS_AMR_SPEECH_LOST	      /* Downlink speech lost           */
-};
-
-enum msm_audio_g711a_mode {
-	MVS_G711A_MODE_MULAW,
-	MVS_G711A_MODE_ALAW
-};
-
-enum msm_audio_g711_mode {
-	MVS_G711_MODE_MULAW,
-	MVS_G711_MODE_ALAW
-};
-
-enum mvs_g722_mode_type {
-	MVS_G722_MODE_01,
-	MVS_G722_MODE_02,
-	MVS_G722_MODE_03,
-	MVS_G722_MODE_MAX,
-	MVS_G722_MODE_UNDEF
-};
-
-enum msm_audio_g711a_frame_type {
-	MVS_G711A_SPEECH_GOOD,
-	MVS_G711A_SID,
-	MVS_G711A_NO_DATA,
-	MVS_G711A_ERASURE
-};
-
-enum msm_audio_g729a_frame_type {
-	MVS_G729A_NO_DATA,
-	MVS_G729A_SPEECH_GOOD,
-	MVS_G729A_SID,
-	MVS_G729A_ERASURE
-};
-
-struct min_max_rate {
-	uint32_t min_rate;
-	uint32_t max_rate;
-};
-
-struct msm_audio_mvs_config {
-	uint32_t mvs_mode;
-	uint32_t rate_type;
-	struct min_max_rate min_max_rate;
-	uint32_t dtx_mode;
-};
-
-#define MVS_MAX_VOC_PKT_SIZE 640
-
-struct gsm_header {
-	uint8_t bfi;
-	uint8_t sid;
-	uint8_t taf;
-	uint8_t ufi;
-};
-
-struct q6_msm_audio_mvs_frame {
-	union {
-	uint32_t frame_type;
-	uint32_t packet_rate;
-	struct gsm_header gsm_frame_type;
-	} header;
-	uint32_t len;
-	uint8_t voc_pkt[MVS_MAX_VOC_PKT_SIZE];
-
-};
-
-struct msm_audio_mvs_frame {
-	uint32_t frame_type;
-	uint32_t len;
-	uint8_t voc_pkt[MVS_MAX_VOC_PKT_SIZE];
-
-};
-
-#define Q5V2_MVS_MAX_VOC_PKT_SIZE 320
-
-struct q5v2_msm_audio_mvs_frame {
-	uint32_t frame_type;
-	uint32_t len;
-	uint8_t voc_pkt[Q5V2_MVS_MAX_VOC_PKT_SIZE];
-
-};
-#endif /* _UAPI_MSM_AUDIO_MVS_H */
diff --git a/include/uapi/linux/msm_audio_qcp.h b/include/uapi/linux/msm_audio_qcp.h
deleted file mode 100644
index fdb234e..0000000
--- a/include/uapi/linux/msm_audio_qcp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_QCP_H
-#define _UAPI_MSM_AUDIO_QCP_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_SET_QCELP_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	0, struct msm_audio_qcelp_enc_config)
-
-#define AUDIO_GET_QCELP_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	1, struct msm_audio_qcelp_enc_config)
-
-#define AUDIO_SET_EVRC_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	2, struct msm_audio_evrc_enc_config)
-
-#define AUDIO_GET_EVRC_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	3, struct msm_audio_evrc_enc_config)
-
-#define CDMA_RATE_BLANK		0x00
-#define CDMA_RATE_EIGHTH	0x01
-#define CDMA_RATE_QUARTER	0x02
-#define CDMA_RATE_HALF		0x03
-#define CDMA_RATE_FULL		0x04
-#define CDMA_RATE_ERASURE	0x05
-
-struct msm_audio_qcelp_enc_config {
-	uint32_t cdma_rate;
-	uint32_t min_bit_rate;
-	uint32_t max_bit_rate;
-};
-
-struct msm_audio_evrc_enc_config {
-	uint32_t cdma_rate;
-	uint32_t min_bit_rate;
-	uint32_t max_bit_rate;
-};
-
-#endif /* _UAPI_MSM_AUDIO_QCP_H */
diff --git a/include/uapi/linux/msm_audio_sbc.h b/include/uapi/linux/msm_audio_sbc.h
deleted file mode 100644
index 1c7c63d..0000000
--- a/include/uapi/linux/msm_audio_sbc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_SBC_H
-#define _UAPI_MSM_AUDIO_SBC_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_SET_SBC_ENC_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_sbc_enc_config)
-
-#define AUDIO_GET_SBC_ENC_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_sbc_enc_config)
-
-#define AUDIO_SBC_BA_LOUDNESS		0x0
-#define AUDIO_SBC_BA_SNR		0x1
-
-#define AUDIO_SBC_MODE_MONO		0x0
-#define AUDIO_SBC_MODE_DUAL		0x1
-#define AUDIO_SBC_MODE_STEREO		0x2
-#define AUDIO_SBC_MODE_JSTEREO		0x3
-
-#define AUDIO_SBC_BANDS_8		0x1
-
-#define AUDIO_SBC_BLOCKS_4		0x0
-#define AUDIO_SBC_BLOCKS_8		0x1
-#define AUDIO_SBC_BLOCKS_12		0x2
-#define AUDIO_SBC_BLOCKS_16		0x3
-
-struct msm_audio_sbc_enc_config {
-	uint32_t channels;
-	uint32_t sample_rate;
-	uint32_t bit_allocation;
-	uint32_t number_of_subbands;
-	uint32_t number_of_blocks;
-	uint32_t bit_rate;
-	uint32_t mode;
-};
-#endif /* _UAPI_MSM_AUDIO_SBC_H */
diff --git a/include/uapi/linux/msm_audio_voicememo.h b/include/uapi/linux/msm_audio_voicememo.h
deleted file mode 100644
index a7a7a4d..0000000
--- a/include/uapi/linux/msm_audio_voicememo.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_VOICEMEMO_H
-#define _UAPI_MSM_AUDIO_VOICEMEMO_H
-
-#include <linux/msm_audio.h>
-
-#define AUDIO_GET_VOICEMEMO_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+0), unsigned int)
-#define AUDIO_SET_VOICEMEMO_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	(AUDIO_MAX_COMMON_IOCTL_NUM+1), unsigned int)
-
-/* rec_type */
-enum rpc_voc_rec_dir_type {
-	RPC_VOC_REC_NONE,
-	RPC_VOC_REC_FORWARD,
-	RPC_VOC_REC_REVERSE,
-	RPC_VOC_REC_BOTH,
-	RPC_VOC_MAX_REC_TYPE
-};
-
-/* capability */
-enum rpc_voc_capability_type {
-	RPC_VOC_CAP_IS733 = 4,
-	RPC_VOC_CAP_IS127 = 8,
-	RPC_VOC_CAP_AMR = 64,
-	RPC_VOC_CAP_32BIT_DUMMY = 2147483647
-};
-
-/* Rate */
-enum rpc_voc_rate_type {
-	RPC_VOC_0_RATE = 0,
-	RPC_VOC_8_RATE,
-	RPC_VOC_4_RATE,
-	RPC_VOC_2_RATE,
-	RPC_VOC_1_RATE,
-	RPC_VOC_ERASURE,
-	RPC_VOC_ERR_RATE,
-	RPC_VOC_AMR_RATE_475 = 0,
-	RPC_VOC_AMR_RATE_515 = 1,
-	RPC_VOC_AMR_RATE_590 = 2,
-	RPC_VOC_AMR_RATE_670 = 3,
-	RPC_VOC_AMR_RATE_740 = 4,
-	RPC_VOC_AMR_RATE_795 = 5,
-	RPC_VOC_AMR_RATE_1020 = 6,
-	RPC_VOC_AMR_RATE_1220 = 7,
-};
-
-/* frame_format */
-enum rpc_voc_pb_len_rate_var_type {
-	RPC_VOC_PB_NATIVE_QCP = 3,
-	RPC_VOC_PB_AMR,
-	RPC_VOC_PB_EVB
-};
-
-struct msm_audio_voicememo_config {
-	uint32_t rec_type;
-	uint32_t rec_interval_ms;
-	uint32_t auto_stop_ms;
-	uint32_t capability;
-	uint32_t max_rate;
-	uint32_t min_rate;
-	uint32_t frame_format;
-	uint32_t dtx_enable;
-	uint32_t data_req_ms;
-};
-
-#endif /* _UAPI_MSM_AUDIO_VOICEMEMO_H */
diff --git a/include/uapi/linux/msm_audio_wma.h b/include/uapi/linux/msm_audio_wma.h
deleted file mode 100644
index 523fade..0000000
--- a/include/uapi/linux/msm_audio_wma.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_WMA_H
-#define _UAPI_MSM_AUDIO_WMA_H
-
-#define AUDIO_GET_WMA_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), unsigned int)
-#define AUDIO_SET_WMA_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), unsigned int)
-
-#define AUDIO_GET_WMA_CONFIG_V2  _IOR(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+2), struct msm_audio_wma_config_v2)
-#define AUDIO_SET_WMA_CONFIG_V2  _IOW(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+3), struct msm_audio_wma_config_v2)
-
-struct msm_audio_wma_config {
-	unsigned short	armdatareqthr;
-	unsigned short	channelsdecoded;
-	unsigned short	wmabytespersec;
-	unsigned short	wmasamplingfreq;
-	unsigned short	wmaencoderopts;
-};
-
-struct msm_audio_wma_config_v2 {
-	unsigned short	format_tag;
-	unsigned short	numchannels;
-	uint32_t	samplingrate;
-	uint32_t	avgbytespersecond;
-	unsigned short	block_align;
-	unsigned short  validbitspersample;
-	uint32_t	channelmask;
-	unsigned short	encodeopt;
-};
-
-#endif /* _UAPI_MSM_AUDIO_WMA_H */
diff --git a/include/uapi/linux/msm_audio_wmapro.h b/include/uapi/linux/msm_audio_wmapro.h
deleted file mode 100644
index 64cbf9e..0000000
--- a/include/uapi/linux/msm_audio_wmapro.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _UAPI_MSM_AUDIO_WMAPRO_H
-#define _UAPI_MSM_AUDIO_WMAPRO_H
-
-#define AUDIO_GET_WMAPRO_CONFIG  _IOR(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+0), struct msm_audio_wmapro_config)
-#define AUDIO_SET_WMAPRO_CONFIG  _IOW(AUDIO_IOCTL_MAGIC, \
-	  (AUDIO_MAX_COMMON_IOCTL_NUM+1), struct msm_audio_wmapro_config)
-
-struct msm_audio_wmapro_config {
-	unsigned short  armdatareqthr;
-	uint8_t         validbitspersample;
-	uint8_t         numchannels;
-	unsigned short  formattag;
-	uint32_t        samplingrate;
-	uint32_t        avgbytespersecond;
-	unsigned short  asfpacketlength;
-	uint32_t        channelmask;
-	unsigned short  encodeopt;
-	unsigned short  advancedencodeopt;
-	uint32_t        advancedencodeopt2;
-};
-#endif /* _UAPI_MSM_AUDIO_WMAPRO_H */
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 8c0fc7b..9fbdc11 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -546,6 +546,12 @@
  *	well to remain backwards compatible.
  * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
  *	sent as an event when the card/driver roamed by itself.
+ *	When used as an event, and the driver roamed in a network that requires
+ *	802.1X authentication, %NL80211_ATTR_PORT_AUTHORIZED should be set
+ *	if the 802.1X authentication was done by the driver or if roaming was
+ *	done using Fast Transition protocol (in which case 802.1X authentication
+ *	is not needed). If %NL80211_ATTR_PORT_AUTHORIZED is not set, user space
+ *	is responsible for the 802.1X authentication.
  * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
  *	userspace that a connection was dropped by the AP or due to other
  *	reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
@@ -2066,6 +2072,10 @@
  *
  * @NL80211_ATTR_PMK: PMK for the PMKSA identified by %NL80211_ATTR_PMKID.
  *	This is used with @NL80211_CMD_SET_PMKSA.
+ * @NL80211_ATTR_PORT_AUTHORIZED: flag attribute used in %NL80211_CMD_ROAMED
+ *	notification indicating that that 802.1X authentication was done by
+ *	the driver or is not needed (because roaming used the Fast Transition
+ *	protocol).
  *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -2486,6 +2496,13 @@
 
 	NL80211_ATTR_PMK,
 
+	NL80211_ATTR_SCHED_SCAN_MULTI,
+	NL80211_ATTR_SCHED_SCAN_MAX_REQS,
+
+	NL80211_ATTR_WANT_1X_4WAY_HS,
+	NL80211_ATTR_PMKR0_NAME,
+	NL80211_ATTR_PORT_AUTHORIZED,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/include/uapi/linux/rmnet_ipa_fd_ioctl.h b/include/uapi/linux/rmnet_ipa_fd_ioctl.h
index f04ac49..04aaaad 100644
--- a/include/uapi/linux/rmnet_ipa_fd_ioctl.h
+++ b/include/uapi/linux/rmnet_ipa_fd_ioctl.h
@@ -33,6 +33,7 @@
 #define WAN_IOCTL_QUERY_DL_FILTER_STATS  8
 #define WAN_IOCTL_ADD_FLT_RULE_EX        9
 #define WAN_IOCTL_QUERY_TETHER_STATS_ALL  10
+#define WAN_IOCTL_NOTIFY_WAN_STATE  11
 
 /* User space may not have this defined. */
 #ifndef IFNAMSIZ
@@ -126,6 +127,10 @@
 	uint32_t index;
 };
 
+struct wan_ioctl_notify_wan_state {
+	uint8_t up;
+};
+
 #define WAN_IOC_ADD_FLT_RULE _IOWR(WAN_IOC_MAGIC, \
 		WAN_IOCTL_ADD_FLT_RULE, \
 		struct ipa_install_fltr_rule_req_msg_v01 *)
@@ -170,4 +175,8 @@
 		WAN_IOCTL_QUERY_TETHER_STATS_ALL, \
 		struct wan_ioctl_query_tether_stats_all *)
 
+#define WAN_IOC_NOTIFY_WAN_STATE _IOWR(WAN_IOC_MAGIC, \
+		WAN_IOCTL_NOTIFY_WAN_STATE, \
+		struct wan_ioctl_notify_wan_state *)
+
 #endif /* _RMNET_IPA_FD_IOCTL_H */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 26506d5..d750568 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1126,6 +1126,14 @@
 #define V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_CUSTOM_MATRIX \
 		(V4L2_CID_MPEG_MSM_VIDC_BASE + 114)
 
+#define V4L2_CID_MPEG_VIDC_VIDEO_FLIP (V4L2_CID_MPEG_MSM_VIDC_BASE + 115)
+enum v4l2_mpeg_vidc_video_flip {
+	V4L2_CID_MPEG_VIDC_VIDEO_FLIP_NONE = 0,
+	V4L2_CID_MPEG_VIDC_VIDEO_FLIP_HORI = 1,
+	V4L2_CID_MPEG_VIDC_VIDEO_FLIP_VERT = 2,
+	V4L2_CID_MPEG_VIDC_VIDEO_FLIP_BOTH = 3,
+};
+
 /*  Camera class control IDs */
 
 #define V4L2_CID_CAMERA_CLASS_BASE 	(V4L2_CTRL_CLASS_CAMERA | 0x900)
diff --git a/include/uapi/media/Kbuild b/include/uapi/media/Kbuild
index 4ded0a4..e72a1f0 100644
--- a/include/uapi/media/Kbuild
+++ b/include/uapi/media/Kbuild
@@ -1,5 +1,6 @@
 header-y += cam_cpas.h
 header-y += cam_defs.h
+header-y += cam_fd.h
 header-y += cam_icp.h
 header-y += cam_isp.h
 header-y += cam_isp_vfe.h
diff --git a/include/uapi/media/cam_defs.h b/include/uapi/media/cam_defs.h
index 5f0f070..9a767dd 100644
--- a/include/uapi/media/cam_defs.h
+++ b/include/uapi/media/cam_defs.h
@@ -21,6 +21,24 @@
 #define CAM_HANDLE_USER_POINTER                 1
 #define CAM_HANDLE_MEM_HANDLE                   2
 
+/* Generic Blob CmdBuffer header properties */
+#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK    0xFFFFFF00
+#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT   8
+#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK    0xFF
+#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT   0
+
+/* Command Buffer Types */
+#define CAM_CMD_BUF_DMI                     0x1
+#define CAM_CMD_BUF_DMI16                   0x2
+#define CAM_CMD_BUF_DMI32                   0x3
+#define CAM_CMD_BUF_DMI64                   0x4
+#define CAM_CMD_BUF_DIRECT                  0x5
+#define CAM_CMD_BUF_INDIRECT                0x6
+#define CAM_CMD_BUF_I2C                     0x7
+#define CAM_CMD_BUF_FW                      0x8
+#define CAM_CMD_BUF_GENERIC                 0x9
+#define CAM_CMD_BUF_LEGACY                  0xA
+
 /**
  * struct cam_control - Structure used by ioctl control for camera
  *
diff --git a/include/uapi/media/cam_fd.h b/include/uapi/media/cam_fd.h
new file mode 100644
index 0000000..8feb6e4
--- /dev/null
+++ b/include/uapi/media/cam_fd.h
@@ -0,0 +1,127 @@
+#ifndef __UAPI_CAM_FD_H__
+#define __UAPI_CAM_FD_H__
+
+#include "cam_defs.h"
+
+#define CAM_FD_MAX_FACES                       35
+#define CAM_FD_RAW_RESULT_ENTRIES              512
+
+/* FD Op Codes */
+#define CAM_PACKET_OPCODES_FD_FRAME_UPDATE     0x0
+
+/* FD Command Buffer identifiers */
+#define CAM_FD_CMD_BUFFER_ID_GENERIC           0x0
+#define CAM_FD_CMD_BUFFER_ID_CDM               0x1
+#define CAM_FD_CMD_BUFFER_ID_MAX               0x2
+
+/* FD Blob types */
+#define CAM_FD_BLOB_TYPE_SOC_CLOCK_BW_REQUEST  0x0
+#define CAM_FD_BLOB_TYPE_RAW_RESULTS_REQUIRED  0x1
+
+/* FD Resource IDs */
+#define CAM_FD_INPUT_PORT_ID_IMAGE             0x0
+#define CAM_FD_INPUT_PORT_ID_MAX               0x1
+
+#define CAM_FD_OUTPUT_PORT_ID_RESULTS          0x0
+#define CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS      0x1
+#define CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER      0x2
+#define CAM_FD_OUTPUT_PORT_ID_MAX              0x3
+
+/**
+ * struct cam_fd_soc_clock_bw_request - SOC clock, bandwidth request info
+ *
+ * @clock_rate : Clock rate required while processing frame
+ * @bandwidth  : Bandwidth required while processing frame
+ * @reserved   : Reserved for future use
+ */
+struct cam_fd_soc_clock_bw_request {
+	uint64_t    clock_rate;
+	uint64_t    bandwidth;
+	uint64_t    reserved[4];
+};
+
+/**
+ * struct cam_fd_face - Face properties
+ *
+ * @prop1 : Property 1 of face
+ * @prop2 : Property 2 of face
+ * @prop3 : Property 3 of face
+ * @prop4 : Property 4 of face
+ *
+ * Do not change this layout, this is inline with how HW writes
+ * these values directly when the buffer is programmed to HW
+ */
+struct cam_fd_face {
+	uint32_t    prop1;
+	uint32_t    prop2;
+	uint32_t    prop3;
+	uint32_t    prop4;
+};
+
+/**
+ * struct cam_fd_results - FD results layout
+ *
+ * @faces      : Array of faces with face properties
+ * @face_count : Number of faces detected
+ * @reserved   : Reserved for alignment
+ *
+ * Do not change this layout, this is inline with how HW writes
+ * these values directly when the buffer is programmed to HW
+ */
+struct cam_fd_results {
+	struct cam_fd_face    faces[CAM_FD_MAX_FACES];
+	uint32_t              face_count;
+	uint32_t              reserved[3];
+};
+
+/**
+ * struct cam_fd_hw_caps - Face properties
+ *
+ * @core_version          : FD core version
+ * @wrapper_version       : FD wrapper version
+ * @raw_results_available : Whether raw results are available on this HW
+ * @supported_modes       : Modes supported by this HW.
+ * @reserved              : Reserved for future use
+ */
+struct cam_fd_hw_caps {
+	struct cam_hw_version    core_version;
+	struct cam_hw_version    wrapper_version;
+	uint32_t                 raw_results_available;
+	uint32_t                 supported_modes;
+	uint64_t                 reserved;
+};
+
+/**
+ * struct cam_fd_query_cap_cmd - FD Query capabilities information
+ *
+ * @device_iommu : FD IOMMU handles
+ * @cdm_iommu    : CDM iommu handles
+ * @hw_caps      : FD HW capabilities
+ * @reserved     : Reserved for alignment
+ */
+struct cam_fd_query_cap_cmd {
+	struct cam_iommu_handle    device_iommu;
+	struct cam_iommu_handle    cdm_iommu;
+	struct cam_fd_hw_caps      hw_caps;
+	uint64_t                   reserved;
+};
+
+/**
+ * struct cam_fd_acquire_dev_info - FD acquire device information
+ *
+ * @clk_bw_request  : SOC clock, bandwidth request
+ * @priority        : Priority for this acquire
+ * @mode            : Mode in which to run FD HW.
+ * @get_raw_results : Whether this acquire needs face raw results
+ *                    while frame processing
+ * @reserved        : Reserved field for 64 bit alignment
+ */
+struct cam_fd_acquire_dev_info {
+	struct cam_fd_soc_clock_bw_request clk_bw_request;
+	uint32_t                           priority;
+	uint32_t                           mode;
+	uint32_t                           get_raw_results;
+	uint32_t                           reserved[13];
+};
+
+#endif /* __UAPI_CAM_FD_H__ */
diff --git a/include/uapi/media/cam_icp.h b/include/uapi/media/cam_icp.h
index 9351d2d..cd2d2d2 100644
--- a/include/uapi/media/cam_icp.h
+++ b/include/uapi/media/cam_icp.h
@@ -56,6 +56,29 @@
 
 #define CAM_ICP_BPS_IO_IMAGES_MAX               0x9
 
+/* Command meta types */
+#define CAM_ICP_CMD_META_GENERIC_BLOB           0x1
+
+/* Generic blon types */
+#define CAM_ICP_CMD_GENERIC_BLOB_CLK            0x1
+
+/**
+ * struct cam_icp_clk_bw_request
+ *
+ * @budget_ns: Time required to process frame
+ * @frame_cycles: Frame cycles needed to process the frame
+ * @rt_flag: Flag to indicate real time stream
+ * @uncompressed_bw: Bandwidth required to process frame
+ * @compressed_bw: Compressed bandwidth to process frame
+ */
+struct cam_icp_clk_bw_request {
+	uint64_t budget_ns;
+	uint32_t frame_cycles;
+	uint32_t rt_flag;
+	uint64_t uncompressed_bw;
+	uint64_t compressed_bw;
+};
+
 /**
  * struct cam_icp_dev_ver - Device information for particular hw type
  *
diff --git a/include/uapi/media/cam_isp.h b/include/uapi/media/cam_isp.h
index 2a57130..05c9283 100644
--- a/include/uapi/media/cam_isp.h
+++ b/include/uapi/media/cam_isp.h
@@ -73,13 +73,17 @@
 #define CAM_ISP_PACKET_META_DMI_COMMON          6
 #define CAM_ISP_PACKET_META_CLOCK               7
 #define CAM_ISP_PACKET_META_CSID                8
-#define CAM_ISP_PACKET_META_MAX                 9
+#define CAM_ISP_PACKET_META_DUAL_CONFIG         9
+#define CAM_ISP_PACKET_META_GENERIC_BLOB        10
+#define CAM_ISP_PACKET_META_MAX                 11
 
 /* DSP mode */
 #define CAM_ISP_DSP_MODE_NONE                   0
 #define CAM_ISP_DSP_MODE_ONE_WAY                1
 #define CAM_ISP_DSP_MODE_ROUND                  2
 
+/* ISP Generic Cmd Buffer Blob types */
+#define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG    0
 
 /* Query devices */
 /**
@@ -222,4 +226,96 @@
 	uint64_t                       res_hdl;
 };
 
+/**
+ * struct cam_isp_port_hfr_config - HFR configuration for this port
+ *
+ * @resource_type:              Resource type
+ * @subsample_pattern:          Subsample pattern. Used in HFR mode. It
+ *                              should be consistent with batchSize and
+ *                              CAMIF programming.
+ * @subsample_period:           Subsample period. Used in HFR mode. It
+ *                              should be consistent with batchSize and
+ *                              CAMIF programming.
+ * @framedrop_pattern:          Framedrop pattern
+ * @framedrop_period:           Framedrop period
+ * @reserved:                   Reserved for alignment
+ */
+struct cam_isp_port_hfr_config {
+	uint32_t                       resource_type;
+	uint32_t                       subsample_pattern;
+	uint32_t                       subsample_period;
+	uint32_t                       framedrop_pattern;
+	uint32_t                       framedrop_period;
+	uint32_t                       reserved;
+};
+
+/**
+ * struct cam_isp_resource_hfr_config - Resource HFR configuration
+ *
+ * @num_io_configs:             Number of ports
+ * @reserved:                   Reserved for alignment
+ * @io_hfr_config:              HFR configuration for each IO port
+ */
+struct cam_isp_resource_hfr_config {
+	uint32_t                       num_io_configs;
+	uint32_t                       reserved;
+	struct cam_isp_port_hfr_config io_hfr_config[1];
+};
+
+/**
+ * struct cam_isp_dual_split_params - dual isp spilt parameters
+ *
+ * @split_point:                Split point information x, where (0 < x < width)
+ *                              left ISP's input ends at x + righ padding and
+ *                              Right ISP's input starts at x - left padding
+ * @right_padding:              Padding added past the split point for left
+ *                              ISP's input
+ * @left_padding:               Padding added before split point for right
+ *                              ISP's input
+ * @reserved:                   Reserved filed for alignment
+ *
+ */
+struct cam_isp_dual_split_params {
+	uint32_t                       split_point;
+	uint32_t                       right_padding;
+	uint32_t                       left_padding;
+	uint32_t                       reserved;
+};
+
+/**
+ * struct cam_isp_dual_stripe_config - stripe config per bus client
+ *
+ * @offset:                     Start horizontal offset relative to
+ *                              output buffer
+ *                              In UBWC mode, this value indicates the H_INIT
+ *                              value in pixel
+ * @width:                      Width of the stripe in bytes
+ * @tileconfig                  Ubwc meta tile config. Contain the partial
+ *                              tile info
+ * @port_id:                    port id of ISP output
+ *
+ */
+struct cam_isp_dual_stripe_config {
+	uint32_t                       offset;
+	uint32_t                       width;
+	uint32_t                       tileconfig;
+	uint32_t                       port_id;
+};
+
+/**
+ * struct cam_isp_dual_config - dual isp configuration
+ *
+ * @num_ports                   Number of isp output ports
+ * @reserved                    Reserved field for alignment
+ * @split_params:               Inpput split parameters
+ * @stripes:                    Stripe information
+ *
+ */
+struct cam_isp_dual_config {
+	uint32_t                           num_ports;
+	uint32_t                           reserved;
+	struct cam_isp_dual_split_params   split_params;
+	struct cam_isp_dual_stripe_config  stripes[1];
+};
+
 #endif /* __UAPI_CAM_ISP_H__ */
diff --git a/include/uapi/media/cam_req_mgr.h b/include/uapi/media/cam_req_mgr.h
index 23a8ccf..9b7d055 100644
--- a/include/uapi/media/cam_req_mgr.h
+++ b/include/uapi/media/cam_req_mgr.h
@@ -23,6 +23,7 @@
 #define CAM_CCI_DEVICE_TYPE       (CAM_DEVICE_TYPE_BASE + 10)
 #define CAM_FLASH_DEVICE_TYPE     (CAM_DEVICE_TYPE_BASE + 11)
 #define CAM_EEPROM_DEVICE_TYPE    (CAM_DEVICE_TYPE_BASE + 12)
+#define CAM_OIS_DEVICE_TYPE       (CAM_DEVICE_TYPE_BASE + 13)
 
 /* cam_req_mgr hdl info */
 #define CAM_REQ_MGR_HDL_IDX_POS           8
@@ -215,7 +216,8 @@
 /* Maximum allowed buffers in existence */
 #define CAM_MEM_BUFQ_MAX                        1024
 
-#define CAM_MEM_MGR_HDL_IDX_SIZE                16
+#define CAM_MEM_MGR_SECURE_BIT_POS              15
+#define CAM_MEM_MGR_HDL_IDX_SIZE                15
 #define CAM_MEM_MGR_HDL_FD_SIZE                 16
 #define CAM_MEM_MGR_HDL_IDX_END_POS             16
 #define CAM_MEM_MGR_HDL_FD_END_POS              32
@@ -223,11 +225,19 @@
 #define CAM_MEM_MGR_HDL_IDX_MASK      ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
 
 #define GET_MEM_HANDLE(idx, fd) \
-	((idx << (CAM_MEM_MGR_HDL_IDX_END_POS - CAM_MEM_MGR_HDL_IDX_SIZE)) | \
+	((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \
 	(fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
 
 #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
 
+#define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \
+	((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \
+	((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS)))
+
+#define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \
+	(((hdl) & \
+	(1<<CAM_MEM_MGR_SECURE_BIT_POS)) >> CAM_MEM_MGR_SECURE_BIT_POS)
+
 /**
  * memory allocation type
  */
diff --git a/include/uapi/media/cam_sensor.h b/include/uapi/media/cam_sensor.h
index ac370ba..87f25b0 100644
--- a/include/uapi/media/cam_sensor.h
+++ b/include/uapi/media/cam_sensor.h
@@ -7,6 +7,8 @@
 
 #define CAM_SENSOR_PROBE_CMD   (CAM_COMMON_OPCODE_MAX + 1)
 #define CAM_FLASH_MAX_LED_TRIGGERS 3
+#define MAX_OIS_NAME_SIZE 32
+#define CAM_CSIPHY_SECURE_MODE_ENABLED 1
 /**
  * struct cam_sensor_query_cap - capabilities info for sensor
  *
@@ -75,6 +77,16 @@
 } __attribute__((packed));
 
 /**
+ * struct cam_ois_query_cap_t - capabilities info for ois
+ *
+ * @slot_info                  :  Indicates about the slotId or cell Index
+ */
+struct cam_ois_query_cap_t {
+	uint32_t            slot_info;
+	uint16_t            reserved;
+} __attribute__((packed));
+
+/**
  * struct cam_cmd_i2c_info - Contains slave I2C related info
  *
  * @slave_addr      :    Slave address
@@ -88,6 +100,42 @@
 } __attribute__((packed));
 
 /**
+ * struct cam_ois_opcode - Contains OIS opcode
+ *
+ * @prog            :    OIS FW prog register address
+ * @coeff           :    OIS FW coeff register address
+ * @pheripheral     :    OIS pheripheral
+ * @memory          :    OIS memory
+ */
+struct cam_ois_opcode {
+	uint32_t prog;
+	uint32_t coeff;
+	uint32_t pheripheral;
+	uint32_t memory;
+} __attribute__((packed));
+
+/**
+ * struct cam_cmd_ois_info - Contains OIS slave info
+ *
+ * @slave_addr            :    OIS i2c slave address
+ * @i2c_freq_mode         :    i2c frequency mode
+ * @ois_fw_flag           :    indicates if fw is present or not
+ * @is_ois_calib          :    indicates the calibration data is available
+ * @ois_name              :    OIS name
+ * @opcode                :    opcode
+ * @cmd_type              :    Explains type of command
+ */
+struct cam_cmd_ois_info {
+	uint16_t              slave_addr;
+	uint8_t               i2c_freq_mode;
+	uint8_t               ois_fw_flag;
+	uint8_t               is_ois_calib;
+	char                  ois_name[MAX_OIS_NAME_SIZE];
+	struct cam_ois_opcode opcode;
+	uint8_t               cmd_type;
+} __attribute__((packed));
+
+/**
  * struct cam_cmd_probe - Contains sensor slave info
  *
  * @data_type       :   Slave register data type
@@ -269,15 +317,15 @@
 
 /**
  * cam_csiphy_info: Provides cmdbuffer structre
- * @lane_mask     :  Lane mask details
- * @lane_assign   :  Lane sensor will be using
- * @csiphy_3phase :  Total number of lanes
- * @combo_mode    :  Info regarding combo_mode is enable / disable
- * @lane_cnt      :  Total number of lanes
- * @reserved
- * @3phase        :  Details whether 3Phase / 2Phase operation
- * @settle_time   :  Settling time in ms
- * @data_rate     :  Data rate
+ * @lane_mask     : Lane mask details
+ * @lane_assign   : Lane sensor will be using
+ * @csiphy_3phase : Total number of lanes
+ * @combo_mode    : Info regarding combo_mode is enable / disable
+ * @lane_cnt      : Total number of lanes
+ * @secure_mode   : Secure mode flag to enable / disable
+ * @3phase        : Details whether 3Phase / 2Phase operation
+ * @settle_time   : Settling time in ms
+ * @data_rate     : Data rate
  *
  */
 struct cam_csiphy_info {
@@ -286,7 +334,7 @@
 	uint8_t     csiphy_3phase;
 	uint8_t     combo_mode;
 	uint8_t     lane_cnt;
-	uint8_t     reserved;
+	uint8_t     secure_mode;
 	uint64_t    settle_time;
 	uint64_t    data_rate;
 } __attribute__((packed));
diff --git a/include/uapi/sound/Kbuild b/include/uapi/sound/Kbuild
index 27e9ef8..9578d8b 100644
--- a/include/uapi/sound/Kbuild
+++ b/include/uapi/sound/Kbuild
@@ -14,10 +14,3 @@
 header-y += tlv.h
 header-y += usb_stream.h
 header-y += snd_sst_tokens.h
-header-y += lsm_params.h
-header-y += audio_slimslave.h
-header-y += voice_params.h
-header-y += audio_effects.h
-header-y += devdep_params.h
-header-y += msmcal-hwdep.h
-header-y += wcd-dsp-glink.h
diff --git a/include/uapi/sound/audio_effects.h b/include/uapi/sound/audio_effects.h
deleted file mode 100644
index 063b5c1..0000000
--- a/include/uapi/sound/audio_effects.h
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (c) 2013-2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _AUDIO_EFFECTS_H
-#define _AUDIO_EFFECTS_H
-
-/** AUDIO EFFECTS **/
-
-
-/* CONFIG GET/SET */
-#define CONFIG_CACHE			0
-#define CONFIG_SET			1
-#define CONFIG_GET			2
-
-/* CONFIG HEADER */
-/*
- * MODULE_ID,
- * DEVICE,
- * NUM_COMMANDS,
- * COMMAND_ID_1,
- * CONFIG_CACHE/SET/GET,
- * OFFSET_1,
- * LENGTH_1,
- * VALUES_1,
- * ...,
- * ...,
- * COMMAND_ID_2,
- * CONFIG_CACHE/SET/GET,
- * OFFSET_2,
- * LENGTH_2,
- * VALUES_2,
- * ...,
- * ...,
- * COMMAND_ID_3,
- * ...
- */
-
-
-/* CONFIG PARAM IDs */
-#define VIRTUALIZER_MODULE		0x00001000
-#define VIRTUALIZER_ENABLE		0x00001001
-#define VIRTUALIZER_STRENGTH		0x00001002
-#define VIRTUALIZER_OUT_TYPE		0x00001003
-#define VIRTUALIZER_GAIN_ADJUST		0x00001004
-#define VIRTUALIZER_ENABLE_PARAM_LEN		1
-#define VIRTUALIZER_STRENGTH_PARAM_LEN		1
-#define VIRTUALIZER_OUT_TYPE_PARAM_LEN		1
-#define VIRTUALIZER_GAIN_ADJUST_PARAM_LEN	1
-
-#define REVERB_MODULE			0x00002000
-#define REVERB_ENABLE			0x00002001
-#define REVERB_MODE			0x00002002
-#define REVERB_PRESET			0x00002003
-#define REVERB_WET_MIX			0x00002004
-#define REVERB_GAIN_ADJUST		0x00002005
-#define REVERB_ROOM_LEVEL		0x00002006
-#define REVERB_ROOM_HF_LEVEL		0x00002007
-#define REVERB_DECAY_TIME		0x00002008
-#define REVERB_DECAY_HF_RATIO		0x00002009
-#define REVERB_REFLECTIONS_LEVEL	0x0000200a
-#define REVERB_REFLECTIONS_DELAY	0x0000200b
-#define REVERB_LEVEL			0x0000200c
-#define REVERB_DELAY			0x0000200d
-#define REVERB_DIFFUSION		0x0000200e
-#define REVERB_DENSITY			0x0000200f
-#define REVERB_ENABLE_PARAM_LEN			1
-#define REVERB_MODE_PARAM_LEN			1
-#define REVERB_PRESET_PARAM_LEN			1
-#define REVERB_WET_MIX_PARAM_LEN		1
-#define REVERB_GAIN_ADJUST_PARAM_LEN		1
-#define REVERB_ROOM_LEVEL_PARAM_LEN		1
-#define REVERB_ROOM_HF_LEVEL_PARAM_LEN		1
-#define REVERB_DECAY_TIME_PARAM_LEN		1
-#define REVERB_DECAY_HF_RATIO_PARAM_LEN		1
-#define REVERB_REFLECTIONS_LEVEL_PARAM_LEN	1
-#define REVERB_REFLECTIONS_DELAY_PARAM_LEN	1
-#define REVERB_LEVEL_PARAM_LEN			1
-#define REVERB_DELAY_PARAM_LEN			1
-#define REVERB_DIFFUSION_PARAM_LEN		1
-#define REVERB_DENSITY_PARAM_LEN		1
-
-#define BASS_BOOST_MODULE		0x00003000
-#define BASS_BOOST_ENABLE		0x00003001
-#define BASS_BOOST_MODE			0x00003002
-#define BASS_BOOST_STRENGTH		0x00003003
-#define BASS_BOOST_ENABLE_PARAM_LEN		1
-#define BASS_BOOST_MODE_PARAM_LEN		1
-#define BASS_BOOST_STRENGTH_PARAM_LEN		1
-
-#define EQ_MODULE			0x00004000
-#define EQ_ENABLE			0x00004001
-#define EQ_CONFIG			0x00004002
-#define EQ_NUM_BANDS			0x00004003
-#define EQ_BAND_LEVELS			0x00004004
-#define EQ_BAND_LEVEL_RANGE		0x00004005
-#define EQ_BAND_FREQS			0x00004006
-#define EQ_SINGLE_BAND_FREQ_RANGE	0x00004007
-#define EQ_SINGLE_BAND_FREQ		0x00004008
-#define EQ_BAND_INDEX			0x00004009
-#define EQ_PRESET_ID			0x0000400a
-#define EQ_NUM_PRESETS			0x0000400b
-#define EQ_PRESET_NAME			0x0000400c
-#define EQ_ENABLE_PARAM_LEN			1
-#define EQ_CONFIG_PARAM_LEN			3
-#define EQ_CONFIG_PER_BAND_PARAM_LEN		5
-#define EQ_NUM_BANDS_PARAM_LEN			1
-#define EQ_BAND_LEVELS_PARAM_LEN		13
-#define EQ_BAND_LEVEL_RANGE_PARAM_LEN		2
-#define EQ_BAND_FREQS_PARAM_LEN			13
-#define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN	2
-#define EQ_SINGLE_BAND_FREQ_PARAM_LEN		1
-#define EQ_BAND_INDEX_PARAM_LEN			1
-#define EQ_PRESET_ID_PARAM_LEN			1
-#define EQ_NUM_PRESETS_PARAM_LEN		1
-#define EQ_PRESET_NAME_PARAM_LEN		32
-
-#define EQ_TYPE_NONE	0
-#define EQ_BASS_BOOST	1
-#define EQ_BASS_CUT	2
-#define EQ_TREBLE_BOOST	3
-#define EQ_TREBLE_CUT	4
-#define EQ_BAND_BOOST	5
-#define EQ_BAND_CUT	6
-
-#define SOFT_VOLUME_MODULE		0x00006000
-#define SOFT_VOLUME_ENABLE		0x00006001
-#define SOFT_VOLUME_GAIN_2CH		0x00006002
-#define SOFT_VOLUME_GAIN_MASTER		0x00006003
-#define SOFT_VOLUME_ENABLE_PARAM_LEN		1
-#define SOFT_VOLUME_GAIN_2CH_PARAM_LEN		2
-#define SOFT_VOLUME_GAIN_MASTER_PARAM_LEN	1
-
-#define SOFT_VOLUME2_MODULE		0x00007000
-#define SOFT_VOLUME2_ENABLE		0x00007001
-#define SOFT_VOLUME2_GAIN_2CH		0x00007002
-#define SOFT_VOLUME2_GAIN_MASTER	0x00007003
-#define SOFT_VOLUME2_ENABLE_PARAM_LEN		SOFT_VOLUME_ENABLE_PARAM_LEN
-#define SOFT_VOLUME2_GAIN_2CH_PARAM_LEN		SOFT_VOLUME_GAIN_2CH_PARAM_LEN
-#define SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN	\
-					SOFT_VOLUME_GAIN_MASTER_PARAM_LEN
-
-#define PBE_CONF_MODULE_ID	0x00010C2A
-#define PBE_CONF_PARAM_ID	0x00010C49
-
-#define PBE_MODULE		0x00008000
-#define PBE_ENABLE		0x00008001
-#define PBE_CONFIG		0x00008002
-#define PBE_ENABLE_PARAM_LEN		1
-#define PBE_CONFIG_PARAM_LEN		28
-
-#define COMMAND_PAYLOAD_LEN	3
-#define COMMAND_PAYLOAD_SZ	(COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
-#define MAX_INBAND_PARAM_SZ	4096
-#define Q27_UNITY		(1 << 27)
-#define Q8_UNITY		(1 << 8)
-#define CUSTOM_OPENSL_PRESET	18
-
-#define VIRTUALIZER_ENABLE_PARAM_SZ	\
-			(VIRTUALIZER_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define VIRTUALIZER_STRENGTH_PARAM_SZ	\
-			(VIRTUALIZER_STRENGTH_PARAM_LEN*sizeof(uint32_t))
-#define VIRTUALIZER_OUT_TYPE_PARAM_SZ	\
-			(VIRTUALIZER_OUT_TYPE_PARAM_LEN*sizeof(uint32_t))
-#define VIRTUALIZER_GAIN_ADJUST_PARAM_SZ	\
-			(VIRTUALIZER_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
-struct virtualizer_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	uint32_t strength;
-	uint32_t out_type;
-	int32_t gain_adjust;
-};
-
-#define NUM_OSL_REVERB_PRESETS_SUPPORTED	6
-#define REVERB_ENABLE_PARAM_SZ		\
-			(REVERB_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_MODE_PARAM_SZ		\
-			(REVERB_MODE_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_PRESET_PARAM_SZ		\
-			(REVERB_PRESET_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_WET_MIX_PARAM_SZ		\
-			(REVERB_WET_MIX_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_GAIN_ADJUST_PARAM_SZ	\
-			(REVERB_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_ROOM_LEVEL_PARAM_SZ	\
-			(REVERB_ROOM_LEVEL_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_ROOM_HF_LEVEL_PARAM_SZ	\
-			(REVERB_ROOM_HF_LEVEL_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_DECAY_TIME_PARAM_SZ	\
-			(REVERB_DECAY_TIME_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_DECAY_HF_RATIO_PARAM_SZ	\
-			(REVERB_DECAY_HF_RATIO_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_REFLECTIONS_LEVEL_PARAM_SZ	\
-			(REVERB_REFLECTIONS_LEVEL_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_REFLECTIONS_DELAY_PARAM_SZ	\
-			(REVERB_REFLECTIONS_DELAY_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_LEVEL_PARAM_SZ		\
-			(REVERB_LEVEL_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_DELAY_PARAM_SZ		\
-			(REVERB_DELAY_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_DIFFUSION_PARAM_SZ	\
-			(REVERB_DIFFUSION_PARAM_LEN*sizeof(uint32_t))
-#define REVERB_DENSITY_PARAM_SZ		\
-			(REVERB_DENSITY_PARAM_LEN*sizeof(uint32_t))
-struct reverb_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	uint32_t mode;
-	uint32_t preset;
-	uint32_t wet_mix;
-	int32_t  gain_adjust;
-	int32_t  room_level;
-	int32_t  room_hf_level;
-	uint32_t decay_time;
-	uint32_t decay_hf_ratio;
-	int32_t  reflections_level;
-	uint32_t reflections_delay;
-	int32_t  level;
-	uint32_t delay;
-	uint32_t diffusion;
-	uint32_t density;
-};
-
-#define BASS_BOOST_ENABLE_PARAM_SZ	\
-			(BASS_BOOST_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define BASS_BOOST_MODE_PARAM_SZ	\
-			(BASS_BOOST_MODE_PARAM_LEN*sizeof(uint32_t))
-#define BASS_BOOST_STRENGTH_PARAM_SZ	\
-			(BASS_BOOST_STRENGTH_PARAM_LEN*sizeof(uint32_t))
-struct bass_boost_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	uint32_t mode;
-	uint32_t strength;
-};
-
-
-#define MAX_EQ_BANDS 12
-#define MAX_OSL_EQ_BANDS 5
-#define EQ_ENABLE_PARAM_SZ			\
-			(EQ_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define EQ_CONFIG_PARAM_SZ			\
-			(EQ_CONFIG_PARAM_LEN*sizeof(uint32_t))
-#define EQ_CONFIG_PER_BAND_PARAM_SZ		\
-			(EQ_CONFIG_PER_BAND_PARAM_LEN*sizeof(uint32_t))
-#define EQ_CONFIG_PARAM_MAX_LEN			(EQ_CONFIG_PARAM_LEN+\
-			MAX_EQ_BANDS*EQ_CONFIG_PER_BAND_PARAM_LEN)
-#define EQ_CONFIG_PARAM_MAX_SZ			\
-			(EQ_CONFIG_PARAM_MAX_LEN*sizeof(uint32_t))
-#define EQ_NUM_BANDS_PARAM_SZ			\
-			(EQ_NUM_BANDS_PARAM_LEN*sizeof(uint32_t))
-#define EQ_BAND_LEVELS_PARAM_SZ			\
-			(EQ_BAND_LEVELS_PARAM_LEN*sizeof(uint32_t))
-#define EQ_BAND_LEVEL_RANGE_PARAM_SZ		\
-			(EQ_BAND_LEVEL_RANGE_PARAM_LEN*sizeof(uint32_t))
-#define EQ_BAND_FREQS_PARAM_SZ			\
-			(EQ_BAND_FREQS_PARAM_LEN*sizeof(uint32_t))
-#define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_SZ	\
-			(EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN*sizeof(uint32_t))
-#define EQ_SINGLE_BAND_FREQ_PARAM_SZ		\
-			(EQ_SINGLE_BAND_FREQ_PARAM_LEN*sizeof(uint32_t))
-#define EQ_BAND_INDEX_PARAM_SZ			\
-			(EQ_BAND_INDEX_PARAM_LEN*sizeof(uint32_t))
-#define EQ_PRESET_ID_PARAM_SZ			\
-			(EQ_PRESET_ID_PARAM_LEN*sizeof(uint32_t))
-#define EQ_NUM_PRESETS_PARAM_SZ			\
-			(EQ_NUM_PRESETS_PARAM_LEN*sizeof(uint8_t))
-struct eq_config_t {
-	int32_t eq_pregain;
-	int32_t preset_id;
-	uint32_t num_bands;
-};
-struct eq_per_band_config_t {
-	int32_t band_idx;
-	uint32_t filter_type;
-	uint32_t freq_millihertz;
-	int32_t  gain_millibels;
-	uint32_t quality_factor;
-};
-struct eq_per_band_freq_range_t {
-	uint32_t band_index;
-	uint32_t min_freq_millihertz;
-	uint32_t max_freq_millihertz;
-};
-
-struct eq_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	struct eq_config_t config;
-	struct eq_per_band_config_t per_band_cfg[MAX_EQ_BANDS];
-	struct eq_per_band_freq_range_t per_band_freq_range[MAX_EQ_BANDS];
-	uint32_t band_index;
-	uint32_t freq_millihertz;
-};
-
-#define PBE_ENABLE_PARAM_SZ	\
-			(PBE_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define PBE_CONFIG_PARAM_SZ	\
-			(PBE_CONFIG_PARAM_LEN*sizeof(uint16_t))
-struct pbe_config_t {
-	int16_t  real_bass_mix;
-	int16_t  bass_color_control;
-	uint16_t main_chain_delay;
-	uint16_t xover_filter_order;
-	uint16_t bandpass_filter_order;
-	int16_t  drc_delay;
-	uint16_t rms_tav;
-	int16_t exp_threshold;
-	uint16_t exp_slope;
-	int16_t comp_threshold;
-	uint16_t comp_slope;
-	uint16_t makeup_gain;
-	uint32_t comp_attack;
-	uint32_t comp_release;
-	uint32_t exp_attack;
-	uint32_t exp_release;
-	int16_t limiter_bass_threshold;
-	int16_t limiter_high_threshold;
-	int16_t limiter_bass_makeup_gain;
-	int16_t limiter_high_makeup_gain;
-	int16_t limiter_bass_gc;
-	int16_t limiter_high_gc;
-	int16_t  limiter_delay;
-	uint16_t reserved;
-	/* place holder for filter coeffs to be followed */
-	int32_t p1LowPassCoeffs[5*2];
-	int32_t p1HighPassCoeffs[5*2];
-	int32_t p1BandPassCoeffs[5*3];
-	int32_t p1BassShelfCoeffs[5];
-	int32_t p1TrebleShelfCoeffs[5];
-} __packed;
-
-struct pbe_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	uint32_t cfg_len;
-	struct pbe_config_t config;
-};
-
-#define SOFT_VOLUME_ENABLE_PARAM_SZ		\
-			(SOFT_VOLUME_ENABLE_PARAM_LEN*sizeof(uint32_t))
-#define SOFT_VOLUME_GAIN_MASTER_PARAM_SZ	\
-			(SOFT_VOLUME_GAIN_MASTER_PARAM_LEN*sizeof(uint32_t))
-#define SOFT_VOLUME_GAIN_2CH_PARAM_SZ		\
-			(SOFT_VOLUME_GAIN_2CH_PARAM_LEN*sizeof(uint16_t))
-struct soft_volume_params {
-	uint32_t device;
-	uint32_t enable_flag;
-	uint32_t master_gain;
-	uint32_t left_gain;
-	uint32_t right_gain;
-};
-
-struct msm_nt_eff_all_config {
-	struct bass_boost_params bass_boost;
-	struct pbe_params pbe;
-	struct virtualizer_params virtualizer;
-	struct reverb_params reverb;
-	struct eq_params equalizer;
-	struct soft_volume_params saplus_vol;
-	struct soft_volume_params topo_switch_vol;
-};
-
-#endif /*_MSM_AUDIO_EFFECTS_H*/
diff --git a/include/uapi/sound/devdep_params.h b/include/uapi/sound/devdep_params.h
deleted file mode 100644
index 9e3133b..0000000
--- a/include/uapi/sound/devdep_params.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2013-2015,2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _DEV_DEP_H
-#define _DEV_DEP_H
-
-struct dolby_param_data {
-	int32_t version;
-	int32_t device_id;
-	int32_t be_id;
-	int32_t param_id;
-	int32_t length;
-	int32_t __user *data;
-};
-
-struct dolby_param_license {
-	int32_t dmid;
-	int32_t license_key;
-};
-
-#define SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM\
-		_IOWR('U', 0x10, struct dolby_param_data)
-#define SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM\
-		_IOR('U', 0x11, struct dolby_param_data)
-#define SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND\
-		_IOWR('U', 0x13, struct dolby_param_data)
-#define SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE\
-		_IOWR('U', 0x14, struct dolby_param_license)
-#define SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER\
-		_IOR('U', 0x15, struct dolby_param_data)
-
-#define DTS_EAGLE_MODULE			0x00005000
-#define DTS_EAGLE_MODULE_ENABLE			0x00005001
-#define EAGLE_DRIVER_ID				0xF2
-#define DTS_EAGLE_IOCTL_GET_CACHE_SIZE		_IOR(EAGLE_DRIVER_ID, 0, int)
-#define DTS_EAGLE_IOCTL_SET_CACHE_SIZE		_IOW(EAGLE_DRIVER_ID, 1, int)
-#define DTS_EAGLE_IOCTL_GET_PARAM		_IOR(EAGLE_DRIVER_ID, 2, void*)
-#define DTS_EAGLE_IOCTL_SET_PARAM		_IOW(EAGLE_DRIVER_ID, 3, void*)
-#define DTS_EAGLE_IOCTL_SET_CACHE_BLOCK		_IOW(EAGLE_DRIVER_ID, 4, void*)
-#define DTS_EAGLE_IOCTL_SET_ACTIVE_DEVICE	_IOW(EAGLE_DRIVER_ID, 5, void*)
-#define DTS_EAGLE_IOCTL_GET_LICENSE		_IOR(EAGLE_DRIVER_ID, 6, void*)
-#define DTS_EAGLE_IOCTL_SET_LICENSE		_IOW(EAGLE_DRIVER_ID, 7, void*)
-#define DTS_EAGLE_IOCTL_SEND_LICENSE		_IOW(EAGLE_DRIVER_ID, 8, int)
-#define DTS_EAGLE_IOCTL_SET_VOLUME_COMMANDS	_IOW(EAGLE_DRIVER_ID, 9, void*)
-#define DTS_EAGLE_FLAG_IOCTL_PRE		(1<<30)
-#define DTS_EAGLE_FLAG_IOCTL_JUSTSETCACHE	(1<<31)
-#define DTS_EAGLE_FLAG_IOCTL_GETFROMCORE       DTS_EAGLE_FLAG_IOCTL_JUSTSETCACHE
-#define DTS_EAGLE_FLAG_IOCTL_MASK		(~(DTS_EAGLE_FLAG_IOCTL_PRE | \
-					     DTS_EAGLE_FLAG_IOCTL_JUSTSETCACHE))
-#define DTS_EAGLE_FLAG_ALSA_GET			(1<<31)
-
-struct dts_eagle_param_desc {
-	uint32_t id;
-	uint32_t size;
-	int32_t offset;
-	uint32_t device;
-} __packed;
-
-#define HWDEP_FE_BASE                   3000 /*unique base for FE hw dep nodes*/
-struct snd_pcm_mmap_fd {
-	int32_t dir;
-	int32_t fd;
-	int32_t size;
-	int32_t actual_size;
-};
-
-#define SNDRV_PCM_IOCTL_MMAP_DATA_FD    _IOWR('U', 0xd2, struct snd_pcm_mmap_fd)
-
-#endif
diff --git a/include/uapi/sound/lsm_params.h b/include/uapi/sound/lsm_params.h
deleted file mode 100644
index 9ca5930..0000000
--- a/include/uapi/sound/lsm_params.h
+++ /dev/null
@@ -1,200 +0,0 @@
-#ifndef _UAPI_LSM_PARAMS_H__
-#define _UAPI_LSM_PARAMS_H__
-
-#define LSM_POLLING_ENABLE_SUPPORT
-#define LSM_EVENT_TIMESTAMP_MODE_SUPPORT
-
-#include <linux/types.h>
-#include <sound/asound.h>
-
-#define SNDRV_LSM_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 0)
-
-#define LSM_OUT_FORMAT_PCM (0)
-#define LSM_OUT_FORMAT_ADPCM (1 << 0)
-
-#define LSM_OUT_DATA_RAW (0)
-#define LSM_OUT_DATA_PACKED (1)
-
-#define LSM_OUT_DATA_EVENTS_DISABLED (0)
-#define LSM_OUT_DATA_EVENTS_ENABLED (1)
-
-#define LSM_OUT_TRANSFER_MODE_RT (0)
-#define LSM_OUT_TRANSFER_MODE_FTRT (1)
-
-#define LSM_ENDPOINT_DETECT_THRESHOLD (0)
-#define LSM_OPERATION_MODE (1)
-#define LSM_GAIN (2)
-#define LSM_MIN_CONFIDENCE_LEVELS (3)
-#define LSM_REG_SND_MODEL (4)
-#define LSM_DEREG_SND_MODEL (5)
-#define LSM_CUSTOM_PARAMS (6)
-#define LSM_POLLING_ENABLE (7)
-#define LSM_PARAMS_MAX (LSM_POLLING_ENABLE + 1)
-
-#define LSM_EVENT_NON_TIME_STAMP_MODE (0)
-#define LSM_EVENT_TIME_STAMP_MODE (1)
-
-enum lsm_app_id {
-	LSM_VOICE_WAKEUP_APP_ID = 1,
-	LSM_VOICE_WAKEUP_APP_ID_V2 = 2,
-};
-
-enum lsm_detection_mode {
-	LSM_MODE_KEYWORD_ONLY_DETECTION = 1,
-	LSM_MODE_USER_KEYWORD_DETECTION
-};
-
-enum lsm_vw_status {
-	LSM_VOICE_WAKEUP_STATUS_RUNNING = 1,
-	LSM_VOICE_WAKEUP_STATUS_DETECTED,
-	LSM_VOICE_WAKEUP_STATUS_END_SPEECH,
-	LSM_VOICE_WAKEUP_STATUS_REJECTED
-};
-
-/*
- * Data for LSM_ENDPOINT_DETECT_THRESHOLD param_type
- * @epd_begin: Begin threshold
- * @epd_end: End threshold
- */
-struct snd_lsm_ep_det_thres {
-	__u32 epd_begin;
-	__u32 epd_end;
-};
-
-/*
- * Data for LSM_OPERATION_MODE param_type
- * @mode: The detection mode to be used
- * @detect_failure: Setting to enable failure detections.
- */
-struct snd_lsm_detect_mode {
-	enum lsm_detection_mode mode;
-	bool detect_failure;
-};
-
-/*
- * Data for LSM_GAIN param_type
- * @gain: The gain to be applied on LSM
- */
-struct snd_lsm_gain {
-	__u16 gain;
-};
-
-/*
- * Data for LSM_POLLING_ENABLE param_type
- * @poll_en: Polling enable or disable
- */
-struct snd_lsm_poll_enable {
-	bool poll_en;
-};
-
-
-struct snd_lsm_sound_model_v2 {
-	__u8 __user *data;
-	__u8 *confidence_level;
-	__u32 data_size;
-	enum lsm_detection_mode detection_mode;
-	__u8 num_confidence_levels;
-	bool detect_failure;
-};
-
-struct snd_lsm_session_data {
-	enum lsm_app_id app_id;
-};
-
-struct snd_lsm_event_status {
-	__u16 status;
-	__u16 payload_size;
-	__u8 payload[0];
-};
-
-struct snd_lsm_event_status_v3 {
-	__u32 timestamp_lsw;
-	__u32 timestamp_msw;
-	__u16 status;
-	__u16 payload_size;
-	__u8 payload[0];
-};
-
-struct snd_lsm_detection_params {
-	__u8 *conf_level;
-	enum lsm_detection_mode detect_mode;
-	__u8 num_confidence_levels;
-	bool detect_failure;
-	bool poll_enable;
-};
-
-/*
- * Param info for each parameter type
- * @module_id: Module to which parameter is to be set
- * @param_id: Parameter that is to be set
- * @param_size: size (in number of bytes) for the data
- *		in param_data.
- *		For confidence levels, this is num_conf_levels
- *		For REG_SND_MODEL, this is size of sound model
- *		For CUSTOM_PARAMS, this is size of the entire blob of data
- * @param_data: Data for the parameter.
- *		For some param_types this is a structure defined, ex: LSM_GAIN
- *		For CONFIDENCE_LEVELS, this is array of confidence levels
- *		For REG_SND_MODEL, this is the sound model data
- *		For CUSTOM_PARAMS, this is the blob of custom data.
- */
-struct lsm_params_info {
-	__u32 module_id;
-	__u32 param_id;
-	__u32 param_size;
-	__u8 __user *param_data;
-	uint32_t param_type;
-};
-
-/*
- * Data passed to the SET_PARAM_V2 IOCTL
- * @num_params: Number of params that are to be set
- *		should not be greater than LSM_PARAMS_MAX
- * @params: Points to an array of lsm_params_info
- *	    Each entry points to one parameter to set
- * @data_size: size (in bytes) for params
- *	       should be equal to
- *	       num_params * sizeof(struct lsm_parms_info)
- */
-struct snd_lsm_module_params {
-	__u8 __user *params;
-	__u32 num_params;
-	__u32 data_size;
-};
-
-/*
- * Data passed to LSM_OUT_FORMAT_CFG IOCTL
- * @format: The media format enum
- * @packing: indicates the packing method used for data path
- * @events: indicates whether data path events need to be enabled
- * @transfer_mode: indicates whether FTRT mode or RT mode.
- */
-struct snd_lsm_output_format_cfg {
-	__u8 format;
-	__u8 packing;
-	__u8 events;
-	__u8 mode;
-};
-
-#define SNDRV_LSM_DEREG_SND_MODEL _IOW('U', 0x01, int)
-#define SNDRV_LSM_EVENT_STATUS	_IOW('U', 0x02, struct snd_lsm_event_status)
-#define SNDRV_LSM_ABORT_EVENT	_IOW('U', 0x03, int)
-#define SNDRV_LSM_START		_IOW('U', 0x04, int)
-#define SNDRV_LSM_STOP		_IOW('U', 0x05, int)
-#define SNDRV_LSM_SET_SESSION_DATA _IOW('U', 0x06, struct snd_lsm_session_data)
-#define SNDRV_LSM_REG_SND_MODEL_V2 _IOW('U', 0x07,\
-					struct snd_lsm_sound_model_v2)
-#define SNDRV_LSM_LAB_CONTROL	_IOW('U', 0x08, uint32_t)
-#define SNDRV_LSM_STOP_LAB	_IO('U', 0x09)
-#define SNDRV_LSM_SET_PARAMS	_IOW('U', 0x0A, \
-					struct snd_lsm_detection_params)
-#define SNDRV_LSM_SET_MODULE_PARAMS	_IOW('U', 0x0B, \
-					struct snd_lsm_module_params)
-#define SNDRV_LSM_OUT_FORMAT_CFG _IOW('U', 0x0C, \
-				      struct snd_lsm_output_format_cfg)
-#define SNDRV_LSM_SET_PORT	_IO('U', 0x0D)
-#define SNDRV_LSM_SET_FWK_MODE_CONFIG	_IOW('U', 0x0E, uint32_t)
-#define SNDRV_LSM_EVENT_STATUS_V3	_IOW('U', 0x0F, \
-					struct snd_lsm_event_status_v3)
-
-#endif
diff --git a/include/uapi/sound/msmcal-hwdep.h b/include/uapi/sound/msmcal-hwdep.h
deleted file mode 100644
index 2a29482..0000000
--- a/include/uapi/sound/msmcal-hwdep.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _CALIB_HWDEP_H
-#define _CALIB_HWDEP_H
-
-#define WCD9XXX_CODEC_HWDEP_NODE    1000
-enum wcd_cal_type {
-	WCD9XXX_MIN_CAL,
-	WCD9XXX_ANC_CAL = WCD9XXX_MIN_CAL,
-	WCD9XXX_MAD_CAL,
-	WCD9XXX_MBHC_CAL,
-	WCD9XXX_VBAT_CAL,
-	WCD9XXX_MAX_CAL,
-};
-
-struct wcdcal_ioctl_buffer {
-	__u32 size;
-	__u8 __user *buffer;
-	enum wcd_cal_type cal_type;
-};
-
-#define SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE \
-	_IOW('U', 0x1, struct wcdcal_ioctl_buffer)
-
-#endif /*_CALIB_HWDEP_H*/
diff --git a/include/uapi/sound/wcd-dsp-glink.h b/include/uapi/sound/wcd-dsp-glink.h
deleted file mode 100644
index 39d128d..0000000
--- a/include/uapi/sound/wcd-dsp-glink.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef _WCD_DSP_GLINK_H
-#define _WCD_DSP_GLINK_H
-
-#include <linux/types.h>
-
-#define WDSP_CH_NAME_MAX_LEN 50
-
-enum {
-	WDSP_REG_PKT = 1,
-	WDSP_CMD_PKT,
-	WDSP_READY_PKT,
-};
-#define WDSP_READY_PKT WDSP_READY_PKT
-
-/*
- * struct wdsp_reg_pkt -  Glink channel information structure format
- * @no_of_channels:   Number of glink channels to open
- * @payload[0]:       Dynamic array contains all the glink channels information
- */
-struct wdsp_reg_pkt {
-	__u8 no_of_channels;
-	__u8 payload[0];
-};
-
-/*
- * struct wdsp_cmd_pkt - WDSP command packet format
- * @ch_name:         Name of the glink channel
- * @payload_size:    Size of the payload
- * @payload[0]:      Actual data payload
- */
-struct wdsp_cmd_pkt {
-	char ch_name[WDSP_CH_NAME_MAX_LEN];
-	__u32 payload_size;
-	__u8 payload[0];
-};
-
-/*
- * struct wdsp_write_pkt - Format that userspace send the data to driver.
- * @pkt_type:      Type of the packet(REG or CMD PKT)
- * @payload[0]:    Payload is either cmd or reg pkt structure based on pkt type
- */
-struct wdsp_write_pkt {
-	__u8 pkt_type;
-	__u8 payload[0];
-};
-
-/*
- * struct wdsp_glink_ch_cfg - Defines the glink channel configuration.
- * @ch_name:           Name of the glink channel
- * @latency_in_us:     Latency specified in micro seconds for QOS
- * @no_of_intents:     Number of intents prequeued
- * @intents_size[0]:   Dynamic array to specify size of each intent
- */
-struct wdsp_glink_ch_cfg {
-	char name[WDSP_CH_NAME_MAX_LEN];
-	__u32 latency_in_us;
-	__u32 no_of_intents;
-	__u32 intents_size[0];
-};
-#endif /* _WCD_DSP_GLINK_H */
diff --git a/init/Kconfig b/init/Kconfig
index af000c7..9782dfc 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1293,6 +1293,16 @@
 
 	  If unsure, say N here.
 
+config SCHED_CORE_ROTATE
+	bool "Scheduler core rotation"
+	depends on SMP
+	help
+	  This options enables the core rotation functionality in
+	  the scheduler. Scheduler with core rotation aims to utilize
+	  CPUs evenly.
+
+	  If unsure, say N here.
+
 config CHECKPOINT_RESTORE
 	bool "Checkpoint/restore support" if EXPERT
 	select PROC_CHILDREN
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 0d302a8..690e1e3 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -457,13 +457,15 @@
 	list_del(&krule->rlist);
 
 	if (list_empty(&watch->rules)) {
+		/*
+		 * audit_remove_watch() drops our reference to 'parent' which
+		 * can get freed. Grab our own reference to be safe.
+		 */
+		audit_get_parent(parent);
 		audit_remove_watch(watch);
-
-		if (list_empty(&parent->watches)) {
-			audit_get_parent(parent);
+		if (list_empty(&parent->watches))
 			fsnotify_destroy_mark(&parent->mark, audit_watch_group);
-			audit_put_parent(parent);
-		}
+		audit_put_parent(parent);
 	}
 }
 
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 8ce679d..779c871 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -139,7 +139,7 @@
 	struct bpf_verifier_stack_elem *next;
 };
 
-#define BPF_COMPLEXITY_LIMIT_INSNS	65536
+#define BPF_COMPLEXITY_LIMIT_INSNS	98304
 #define BPF_COMPLEXITY_LIMIT_STACK	1024
 
 struct bpf_call_arg_meta {
@@ -682,12 +682,13 @@
 	return -EACCES;
 }
 
-static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
+static bool __is_pointer_value(bool allow_ptr_leaks,
+			       const struct bpf_reg_state *reg)
 {
-	if (env->allow_ptr_leaks)
+	if (allow_ptr_leaks)
 		return false;
 
-	switch (env->cur_state.regs[regno].type) {
+	switch (reg->type) {
 	case UNKNOWN_VALUE:
 	case CONST_IMM:
 		return false;
@@ -696,6 +697,11 @@
 	}
 }
 
+static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
+{
+	return __is_pointer_value(env->allow_ptr_leaks, &env->cur_state.regs[regno]);
+}
+
 static int check_ptr_alignment(struct bpf_verifier_env *env,
 			       struct bpf_reg_state *reg, int off, int size)
 {
@@ -1467,6 +1473,65 @@
 	return 0;
 }
 
+static int evaluate_reg_imm_alu_unknown(struct bpf_verifier_env *env,
+					struct bpf_insn *insn)
+{
+	struct bpf_reg_state *regs = env->cur_state.regs;
+	struct bpf_reg_state *dst_reg = &regs[insn->dst_reg];
+	struct bpf_reg_state *src_reg = &regs[insn->src_reg];
+	u8 opcode = BPF_OP(insn->code);
+	s64 imm_log2 = __ilog2_u64((long long)dst_reg->imm);
+
+	/* BPF_X code with src_reg->type UNKNOWN_VALUE here. */
+	if (src_reg->imm > 0 && dst_reg->imm) {
+		switch (opcode) {
+		case BPF_ADD:
+			/* dreg += sreg
+			 * where both have zero upper bits. Adding them
+			 * can only result making one more bit non-zero
+			 * in the larger value.
+			 * Ex. 0xffff (imm=48) + 1 (imm=63) = 0x10000 (imm=47)
+			 *     0xffff (imm=48) + 0xffff = 0x1fffe (imm=47)
+			 */
+			dst_reg->imm = min(src_reg->imm, 63 - imm_log2);
+			dst_reg->imm--;
+			break;
+		case BPF_AND:
+			/* dreg &= sreg
+			 * AND can not extend zero bits only shrink
+			 * Ex.  0x00..00ffffff
+			 *    & 0x0f..ffffffff
+			 *     ----------------
+			 *      0x00..00ffffff
+			 */
+			dst_reg->imm = max(src_reg->imm, 63 - imm_log2);
+			break;
+		case BPF_OR:
+			/* dreg |= sreg
+			 * OR can only extend zero bits
+			 * Ex.  0x00..00ffffff
+			 *    | 0x0f..ffffffff
+			 *     ----------------
+			 *      0x0f..00ffffff
+			 */
+			dst_reg->imm = min(src_reg->imm, 63 - imm_log2);
+			break;
+		case BPF_SUB:
+		case BPF_MUL:
+		case BPF_RSH:
+		case BPF_LSH:
+			/* These may be flushed out later */
+		default:
+			mark_reg_unknown_value(regs, insn->dst_reg);
+		}
+	} else {
+		mark_reg_unknown_value(regs, insn->dst_reg);
+	}
+
+	dst_reg->type = UNKNOWN_VALUE;
+	return 0;
+}
+
 static int evaluate_reg_imm_alu(struct bpf_verifier_env *env,
 				struct bpf_insn *insn)
 {
@@ -1475,6 +1540,9 @@
 	struct bpf_reg_state *src_reg = &regs[insn->src_reg];
 	u8 opcode = BPF_OP(insn->code);
 
+	if (BPF_SRC(insn->code) == BPF_X && src_reg->type == UNKNOWN_VALUE)
+		return evaluate_reg_imm_alu_unknown(env, insn);
+
 	/* dst_reg->type == CONST_IMM here, simulate execution of 'add' insn.
 	 * Don't care about overflow or negative values, just add them
 	 */
@@ -1530,10 +1598,24 @@
 	}
 
 	/* We don't know anything about what was done to this register, mark it
-	 * as unknown.
+	 * as unknown. Also, if both derived bounds came from signed/unsigned
+	 * mixed compares and one side is unbounded, we cannot really do anything
+	 * with them as boundaries cannot be trusted. Thus, arithmetic of two
+	 * regs of such kind will get invalidated bounds on the dst side.
 	 */
-	if (min_val == BPF_REGISTER_MIN_RANGE &&
-	    max_val == BPF_REGISTER_MAX_RANGE) {
+	if ((min_val == BPF_REGISTER_MIN_RANGE &&
+	     max_val == BPF_REGISTER_MAX_RANGE) ||
+	    (BPF_SRC(insn->code) == BPF_X &&
+	     ((min_val != BPF_REGISTER_MIN_RANGE &&
+	       max_val == BPF_REGISTER_MAX_RANGE) ||
+	      (min_val == BPF_REGISTER_MIN_RANGE &&
+	       max_val != BPF_REGISTER_MAX_RANGE) ||
+	      (dst_reg->min_value != BPF_REGISTER_MIN_RANGE &&
+	       dst_reg->max_value == BPF_REGISTER_MAX_RANGE) ||
+	      (dst_reg->min_value == BPF_REGISTER_MIN_RANGE &&
+	       dst_reg->max_value != BPF_REGISTER_MAX_RANGE)) &&
+	     regs[insn->dst_reg].value_from_signed !=
+	     regs[insn->src_reg].value_from_signed)) {
 		reset_reg_range_values(regs, insn->dst_reg);
 		return;
 	}
@@ -1542,10 +1624,12 @@
 	 * do our normal operations to the register, we need to set the values
 	 * to the min/max since they are undefined.
 	 */
-	if (min_val == BPF_REGISTER_MIN_RANGE)
-		dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
-	if (max_val == BPF_REGISTER_MAX_RANGE)
-		dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
+	if (opcode != BPF_SUB) {
+		if (min_val == BPF_REGISTER_MIN_RANGE)
+			dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
+		if (max_val == BPF_REGISTER_MAX_RANGE)
+			dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
+	}
 
 	switch (opcode) {
 	case BPF_ADD:
@@ -1555,10 +1639,17 @@
 			dst_reg->max_value += max_val;
 		break;
 	case BPF_SUB:
+		/* If one of our values was at the end of our ranges, then the
+		 * _opposite_ value in the dst_reg goes to the end of our range.
+		 */
+		if (min_val == BPF_REGISTER_MIN_RANGE)
+			dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
+		if (max_val == BPF_REGISTER_MAX_RANGE)
+			dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
 		if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
-			dst_reg->min_value -= min_val;
+			dst_reg->min_value -= max_val;
 		if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
-			dst_reg->max_value -= max_val;
+			dst_reg->max_value -= min_val;
 		break;
 	case BPF_MUL:
 		if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
@@ -1808,6 +1899,7 @@
 		 * register as unknown.
 		 */
 		if (env->allow_ptr_leaks &&
+		    BPF_CLASS(insn->code) == BPF_ALU64 && opcode == BPF_ADD &&
 		    (dst_reg->type == PTR_TO_MAP_VALUE ||
 		     dst_reg->type == PTR_TO_MAP_VALUE_ADJ))
 			dst_reg->type = PTR_TO_MAP_VALUE_ADJ;
@@ -1876,38 +1968,63 @@
 			    struct bpf_reg_state *false_reg, u64 val,
 			    u8 opcode)
 {
+	bool value_from_signed = true;
+	bool is_range = true;
+
 	switch (opcode) {
 	case BPF_JEQ:
 		/* If this is false then we know nothing Jon Snow, but if it is
 		 * true then we know for sure.
 		 */
 		true_reg->max_value = true_reg->min_value = val;
+		is_range = false;
 		break;
 	case BPF_JNE:
 		/* If this is true we know nothing Jon Snow, but if it is false
 		 * we know the value for sure;
 		 */
 		false_reg->max_value = false_reg->min_value = val;
+		is_range = false;
 		break;
 	case BPF_JGT:
-		/* Unsigned comparison, the minimum value is 0. */
-		false_reg->min_value = 0;
+		value_from_signed = false;
+		/* fallthrough */
 	case BPF_JSGT:
+		if (true_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(true_reg, 0);
+		if (false_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(false_reg, 0);
+		if (opcode == BPF_JGT) {
+			/* Unsigned comparison, the minimum value is 0. */
+			false_reg->min_value = 0;
+		}
 		/* If this is false then we know the maximum val is val,
 		 * otherwise we know the min val is val+1.
 		 */
 		false_reg->max_value = val;
+		false_reg->value_from_signed = value_from_signed;
 		true_reg->min_value = val + 1;
+		true_reg->value_from_signed = value_from_signed;
 		break;
 	case BPF_JGE:
-		/* Unsigned comparison, the minimum value is 0. */
-		false_reg->min_value = 0;
+		value_from_signed = false;
+		/* fallthrough */
 	case BPF_JSGE:
+		if (true_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(true_reg, 0);
+		if (false_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(false_reg, 0);
+		if (opcode == BPF_JGE) {
+			/* Unsigned comparison, the minimum value is 0. */
+			false_reg->min_value = 0;
+		}
 		/* If this is false then we know the maximum value is val - 1,
 		 * otherwise we know the mimimum value is val.
 		 */
 		false_reg->max_value = val - 1;
+		false_reg->value_from_signed = value_from_signed;
 		true_reg->min_value = val;
+		true_reg->value_from_signed = value_from_signed;
 		break;
 	default:
 		break;
@@ -1915,6 +2032,12 @@
 
 	check_reg_overflow(false_reg);
 	check_reg_overflow(true_reg);
+	if (is_range) {
+		if (__is_pointer_value(false, false_reg))
+			reset_reg_range_values(false_reg, 0);
+		if (__is_pointer_value(false, true_reg))
+			reset_reg_range_values(true_reg, 0);
+	}
 }
 
 /* Same as above, but for the case that dst_reg is a CONST_IMM reg and src_reg
@@ -1924,39 +2047,64 @@
 				struct bpf_reg_state *false_reg, u64 val,
 				u8 opcode)
 {
+	bool value_from_signed = true;
+	bool is_range = true;
+
 	switch (opcode) {
 	case BPF_JEQ:
 		/* If this is false then we know nothing Jon Snow, but if it is
 		 * true then we know for sure.
 		 */
 		true_reg->max_value = true_reg->min_value = val;
+		is_range = false;
 		break;
 	case BPF_JNE:
 		/* If this is true we know nothing Jon Snow, but if it is false
 		 * we know the value for sure;
 		 */
 		false_reg->max_value = false_reg->min_value = val;
+		is_range = false;
 		break;
 	case BPF_JGT:
-		/* Unsigned comparison, the minimum value is 0. */
-		true_reg->min_value = 0;
+		value_from_signed = false;
+		/* fallthrough */
 	case BPF_JSGT:
+		if (true_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(true_reg, 0);
+		if (false_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(false_reg, 0);
+		if (opcode == BPF_JGT) {
+			/* Unsigned comparison, the minimum value is 0. */
+			true_reg->min_value = 0;
+		}
 		/*
 		 * If this is false, then the val is <= the register, if it is
 		 * true the register <= to the val.
 		 */
 		false_reg->min_value = val;
+		false_reg->value_from_signed = value_from_signed;
 		true_reg->max_value = val - 1;
+		true_reg->value_from_signed = value_from_signed;
 		break;
 	case BPF_JGE:
-		/* Unsigned comparison, the minimum value is 0. */
-		true_reg->min_value = 0;
+		value_from_signed = false;
+		/* fallthrough */
 	case BPF_JSGE:
+		if (true_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(true_reg, 0);
+		if (false_reg->value_from_signed != value_from_signed)
+			reset_reg_range_values(false_reg, 0);
+		if (opcode == BPF_JGE) {
+			/* Unsigned comparison, the minimum value is 0. */
+			true_reg->min_value = 0;
+		}
 		/* If this is false then constant < register, if it is true then
 		 * the register < constant.
 		 */
 		false_reg->min_value = val + 1;
+		false_reg->value_from_signed = value_from_signed;
 		true_reg->max_value = val;
+		true_reg->value_from_signed = value_from_signed;
 		break;
 	default:
 		break;
@@ -1964,6 +2112,12 @@
 
 	check_reg_overflow(false_reg);
 	check_reg_overflow(true_reg);
+	if (is_range) {
+		if (__is_pointer_value(false, false_reg))
+			reset_reg_range_values(false_reg, 0);
+		if (__is_pointer_value(false, true_reg))
+			reset_reg_range_values(true_reg, 0);
+	}
 }
 
 static void mark_map_reg(struct bpf_reg_state *regs, u32 regno, u32 id,
@@ -2390,6 +2544,7 @@
 				env->explored_states[t + 1] = STATE_LIST_MARK;
 		} else {
 			/* conditional jump with two edges */
+			env->explored_states[t] = STATE_LIST_MARK;
 			ret = push_insn(t, t + 1, FALLTHROUGH, env);
 			if (ret == 1)
 				goto peek_stack;
@@ -2548,6 +2703,12 @@
 		     rcur->type != NOT_INIT))
 			continue;
 
+		/* Don't care about the reg->id in this case. */
+		if (rold->type == PTR_TO_MAP_VALUE_OR_NULL &&
+		    rcur->type == PTR_TO_MAP_VALUE_OR_NULL &&
+		    rold->map_ptr == rcur->map_ptr)
+			continue;
+
 		if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET &&
 		    compare_ptrs_to_packet(rold, rcur))
 			continue;
@@ -2682,6 +2843,9 @@
 			goto process_bpf_exit;
 		}
 
+		if (need_resched())
+			cond_resched();
+
 		if (log_level && do_print_state) {
 			verbose("\nfrom %d to %d:", prev_insn_idx, insn_idx);
 			print_verifier_state(&env->cur_state);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7bb21fd..26c624e 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3508,11 +3508,11 @@
 	cgrp->subtree_control &= ~disable;
 
 	ret = cgroup_apply_control(cgrp);
-
 	cgroup_finalize_control(cgrp, ret);
+	if (ret)
+		goto out_unlock;
 
 	kernfs_activate(cgrp->kn);
-	ret = 0;
 out_unlock:
 	cgroup_kn_unlock(of->kn);
 	return ret ?: nbytes;
@@ -5744,6 +5744,10 @@
 
 		if (ss->bind)
 			ss->bind(init_css_set.subsys[ssid]);
+
+		mutex_lock(&cgroup_mutex);
+		css_populate_dir(init_css_set.subsys[ssid]);
+		mutex_unlock(&cgroup_mutex);
 	}
 
 	/* init_css_set.subsys[] has been updated, re-hash */
diff --git a/kernel/configs/README.android b/kernel/configs/README.android
deleted file mode 100644
index 2e2d7c0..0000000
--- a/kernel/configs/README.android
+++ /dev/null
@@ -1,15 +0,0 @@
-The android-*.config files in this directory are meant to be used as a base
-for an Android kernel config. All devices should have the options in
-android-base.config enabled. While not mandatory, the options in
-android-recommended.config enable advanced Android features.
-
-Assuming you already have a minimalist defconfig for your device, a possible
-way to enable these options would be:
-
-     ARCH=<arch> scripts/kconfig/merge_config.sh <path_to>/<device>_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config
-
-This will generate a .config that can then be used to save a new defconfig or
-compile a new kernel with Android features enabled.
-
-Because there is no tool to consistently generate these config fragments,
-lets keep them alphabetically sorted instead of random.
diff --git a/kernel/configs/android-base-arm64.cfg b/kernel/configs/android-base-arm64.cfg
deleted file mode 100644
index 43f23d6..0000000
--- a/kernel/configs/android-base-arm64.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-#  KEEP ALPHABETICALLY SORTED
-CONFIG_ARMV8_DEPRECATED=y
-CONFIG_CP15_BARRIER_EMULATION=y
-CONFIG_SETEND_EMULATION=y
-CONFIG_SWP_EMULATION=y
diff --git a/kernel/configs/android-base.config b/kernel/configs/android-base.config
deleted file mode 100644
index 80df048..0000000
--- a/kernel/configs/android-base.config
+++ /dev/null
@@ -1,170 +0,0 @@
-#  KEEP ALPHABETICALLY SORTED
-# CONFIG_DEVKMEM is not set
-# CONFIG_DEVMEM is not set
-# CONFIG_FHANDLE is not set
-# CONFIG_INET_LRO is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFS_FS is not set
-# CONFIG_OABI_COMPAT is not set
-# CONFIG_SYSVIPC is not set
-# CONFIG_USELIB is not set
-CONFIG_ANDROID=y
-CONFIG_ANDROID_BINDER_DEVICES=binder,hwbinder,vndbinder
-CONFIG_ANDROID_BINDER_IPC=y
-CONFIG_ANDROID_LOW_MEMORY_KILLER=y
-CONFIG_ASHMEM=y
-CONFIG_AUDIT=y
-CONFIG_BLK_DEV_INITRD=y
-CONFIG_CGROUPS=y
-CONFIG_CGROUP_CPUACCT=y
-CONFIG_CGROUP_FREEZER=y
-CONFIG_CGROUP_SCHED=y
-CONFIG_CGROUP_BPF=y
-CONFIG_DEFAULT_SECURITY_SELINUX=y
-CONFIG_EMBEDDED=y
-CONFIG_FB=y
-CONFIG_HARDENED_USERCOPY=y
-CONFIG_HIGH_RES_TIMERS=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_INET6_AH=y
-CONFIG_INET6_ESP=y
-CONFIG_INET6_IPCOMP=y
-CONFIG_INET=y
-CONFIG_INET_DIAG_DESTROY=y
-CONFIG_INET_ESP=y
-CONFIG_INET_XFRM_MODE_TUNNEL=y
-CONFIG_IP6_NF_FILTER=y
-CONFIG_IP6_NF_IPTABLES=y
-CONFIG_IP6_NF_MANGLE=y
-CONFIG_IP6_NF_RAW=y
-CONFIG_IP6_NF_TARGET_REJECT=y
-CONFIG_IPV6=y
-CONFIG_IPV6_MIP6=y
-CONFIG_IPV6_MULTIPLE_TABLES=y
-CONFIG_IPV6_OPTIMISTIC_DAD=y
-CONFIG_IPV6_ROUTER_PREF=y
-CONFIG_IPV6_ROUTE_INFO=y
-CONFIG_IP_ADVANCED_ROUTER=y
-CONFIG_IP_MULTICAST=y
-CONFIG_IP_MULTIPLE_TABLES=y
-CONFIG_IP_NF_ARPFILTER=y
-CONFIG_IP_NF_ARPTABLES=y
-CONFIG_IP_NF_ARP_MANGLE=y
-CONFIG_IP_NF_FILTER=y
-CONFIG_IP_NF_IPTABLES=y
-CONFIG_IP_NF_MANGLE=y
-CONFIG_IP_NF_MATCH_AH=y
-CONFIG_IP_NF_MATCH_ECN=y
-CONFIG_IP_NF_MATCH_TTL=y
-CONFIG_IP_NF_NAT=y
-CONFIG_IP_NF_RAW=y
-CONFIG_IP_NF_SECURITY=y
-CONFIG_IP_NF_TARGET_MASQUERADE=y
-CONFIG_IP_NF_TARGET_NETMAP=y
-CONFIG_IP_NF_TARGET_REDIRECT=y
-CONFIG_IP_NF_TARGET_REJECT=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_MODVERSIONS=y
-CONFIG_NET=y
-CONFIG_NETDEVICES=y
-CONFIG_NETFILTER=y
-CONFIG_NETFILTER_XT_MATCH_COMMENT=y
-CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
-CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
-CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
-CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
-CONFIG_NETFILTER_XT_MATCH_HELPER=y
-CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
-CONFIG_NETFILTER_XT_MATCH_LENGTH=y
-CONFIG_NETFILTER_XT_MATCH_LIMIT=y
-CONFIG_NETFILTER_XT_MATCH_MAC=y
-CONFIG_NETFILTER_XT_MATCH_MARK=y
-CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
-CONFIG_NETFILTER_XT_MATCH_POLICY=y
-CONFIG_NETFILTER_XT_MATCH_QTAGUID=y
-CONFIG_NETFILTER_XT_MATCH_QUOTA2=y
-CONFIG_NETFILTER_XT_MATCH_QUOTA=y
-CONFIG_NETFILTER_XT_MATCH_SOCKET=y
-CONFIG_NETFILTER_XT_MATCH_STATE=y
-CONFIG_NETFILTER_XT_MATCH_STATISTIC=y
-CONFIG_NETFILTER_XT_MATCH_STRING=y
-CONFIG_NETFILTER_XT_MATCH_TIME=y
-CONFIG_NETFILTER_XT_MATCH_U32=y
-CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
-CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
-CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
-CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
-CONFIG_NETFILTER_XT_TARGET_MARK=y
-CONFIG_NETFILTER_XT_TARGET_NFLOG=y
-CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
-CONFIG_NETFILTER_XT_TARGET_SECMARK=y
-CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
-CONFIG_NETFILTER_XT_TARGET_TPROXY=y
-CONFIG_NETFILTER_XT_TARGET_TRACE=y
-CONFIG_NET_CLS_ACT=y
-CONFIG_NET_CLS_U32=y
-CONFIG_NET_EMATCH=y
-CONFIG_NET_EMATCH_U32=y
-CONFIG_NET_KEY=y
-CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_HTB=y
-CONFIG_NF_CONNTRACK=y
-CONFIG_NF_CONNTRACK_AMANDA=y
-CONFIG_NF_CONNTRACK_EVENTS=y
-CONFIG_NF_CONNTRACK_FTP=y
-CONFIG_NF_CONNTRACK_H323=y
-CONFIG_NF_CONNTRACK_IPV4=y
-CONFIG_NF_CONNTRACK_IPV6=y
-CONFIG_NF_CONNTRACK_IRC=y
-CONFIG_NF_CONNTRACK_NETBIOS_NS=y
-CONFIG_NF_CONNTRACK_PPTP=y
-CONFIG_NF_CONNTRACK_SANE=y
-CONFIG_NF_CONNTRACK_SECMARK=y
-CONFIG_NF_CONNTRACK_TFTP=y
-CONFIG_NF_CT_NETLINK=y
-CONFIG_NF_CT_PROTO_DCCP=y
-CONFIG_NF_CT_PROTO_SCTP=y
-CONFIG_NF_CT_PROTO_UDPLITE=y
-CONFIG_NF_NAT=y
-CONFIG_NO_HZ=y
-CONFIG_PACKET=y
-CONFIG_PM_AUTOSLEEP=y
-CONFIG_PM_WAKELOCKS=y
-CONFIG_PPP=y
-CONFIG_PPPOLAC=y
-CONFIG_PPPOPNS=y
-CONFIG_PPP_BSDCOMP=y
-CONFIG_PPP_DEFLATE=y
-CONFIG_PPP_MPPE=y
-CONFIG_PREEMPT=y
-CONFIG_PROFILING=y
-CONFIG_QFMT_V2=y
-CONFIG_QUOTA=y
-CONFIG_QUOTACTL=y
-CONFIG_QUOTA_NETLINK_INTERFACE=y
-CONFIG_QUOTA_TREE=y
-CONFIG_RANDOMIZE_BASE=y
-CONFIG_RTC_CLASS=y
-CONFIG_RT_GROUP_SCHED=y
-CONFIG_SECCOMP=y
-CONFIG_SECURITY=y
-CONFIG_SECURITY_NETWORK=y
-CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
-CONFIG_SECURITY_SELINUX=y
-CONFIG_STAGING=y
-CONFIG_SYNC=y
-CONFIG_TUN=y
-CONFIG_UID_SYS_STATS=y
-CONFIG_UNIX=y
-CONFIG_USB_CONFIGFS=y
-CONFIG_USB_CONFIGFS_F_ACC=y
-CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y
-CONFIG_USB_CONFIGFS_F_FS=y
-CONFIG_USB_CONFIGFS_F_MIDI=y
-CONFIG_USB_CONFIGFS_F_MTP=y
-CONFIG_USB_CONFIGFS_F_PTP=y
-CONFIG_USB_CONFIGFS_UEVENT=y
-CONFIG_USB_GADGET=y
-CONFIG_XFRM_USER=y
diff --git a/kernel/configs/android-recommended.config b/kernel/configs/android-recommended.config
deleted file mode 100644
index 36ec6c1..0000000
--- a/kernel/configs/android-recommended.config
+++ /dev/null
@@ -1,133 +0,0 @@
-#  KEEP ALPHABETICALLY SORTED
-# CONFIG_AIO is not set
-# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_LEGACY_PTYS is not set
-# CONFIG_NF_CONNTRACK_SIP is not set
-# CONFIG_PM_WAKELOCKS_GC is not set
-# CONFIG_VT is not set
-CONFIG_ARM64_SW_TTBR0_PAN=y
-CONFIG_BACKLIGHT_LCD_SUPPORT=y
-CONFIG_BLK_DEV_DM=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_CC_STACKPROTECTOR_STRONG=y
-CONFIG_COMPACTION=y
-CONFIG_CPU_SW_DOMAIN_PAN=y
-CONFIG_DEBUG_RODATA=y
-CONFIG_DM_CRYPT=y
-CONFIG_DM_UEVENT=y
-CONFIG_DM_VERITY=y
-CONFIG_DM_VERITY_FEC=y
-CONFIG_DRAGONRISE_FF=y
-CONFIG_ENABLE_DEFAULT_TRACERS=y
-CONFIG_EXT4_FS=y
-CONFIG_EXT4_FS_SECURITY=y
-CONFIG_FUSE_FS=y
-CONFIG_GREENASIA_FF=y
-CONFIG_HIDRAW=y
-CONFIG_HID_A4TECH=y
-CONFIG_HID_ACRUX=y
-CONFIG_HID_ACRUX_FF=y
-CONFIG_HID_APPLE=y
-CONFIG_HID_BELKIN=y
-CONFIG_HID_CHERRY=y
-CONFIG_HID_CHICONY=y
-CONFIG_HID_CYPRESS=y
-CONFIG_HID_DRAGONRISE=y
-CONFIG_HID_ELECOM=y
-CONFIG_HID_EMS_FF=y
-CONFIG_HID_EZKEY=y
-CONFIG_HID_GREENASIA=y
-CONFIG_HID_GYRATION=y
-CONFIG_HID_HOLTEK=y
-CONFIG_HID_KENSINGTON=y
-CONFIG_HID_KEYTOUCH=y
-CONFIG_HID_KYE=y
-CONFIG_HID_LCPOWER=y
-CONFIG_HID_LOGITECH=y
-CONFIG_HID_LOGITECH_DJ=y
-CONFIG_HID_MAGICMOUSE=y
-CONFIG_HID_MICROSOFT=y
-CONFIG_HID_MONTEREY=y
-CONFIG_HID_MULTITOUCH=y
-CONFIG_HID_NTRIG=y
-CONFIG_HID_ORTEK=y
-CONFIG_HID_PANTHERLORD=y
-CONFIG_HID_PETALYNX=y
-CONFIG_HID_PICOLCD=y
-CONFIG_HID_PRIMAX=y
-CONFIG_HID_PRODIKEYS=y
-CONFIG_HID_ROCCAT=y
-CONFIG_HID_SAITEK=y
-CONFIG_HID_SAMSUNG=y
-CONFIG_HID_SMARTJOYPLUS=y
-CONFIG_HID_SONY=y
-CONFIG_HID_SPEEDLINK=y
-CONFIG_HID_SUNPLUS=y
-CONFIG_HID_THRUSTMASTER=y
-CONFIG_HID_TIVO=y
-CONFIG_HID_TOPSEED=y
-CONFIG_HID_TWINHAN=y
-CONFIG_HID_UCLOGIC=y
-CONFIG_HID_WACOM=y
-CONFIG_HID_WALTOP=y
-CONFIG_HID_WIIMOTE=y
-CONFIG_HID_ZEROPLUS=y
-CONFIG_HID_ZYDACRON=y
-CONFIG_INPUT_EVDEV=y
-CONFIG_INPUT_GPIO=y
-CONFIG_INPUT_JOYSTICK=y
-CONFIG_INPUT_KEYCHORD=y
-CONFIG_INPUT_KEYRESET=y
-CONFIG_INPUT_MISC=y
-CONFIG_INPUT_TABLET=y
-CONFIG_INPUT_UINPUT=y
-CONFIG_ION=y
-CONFIG_JOYSTICK_XPAD=y
-CONFIG_JOYSTICK_XPAD_FF=y
-CONFIG_JOYSTICK_XPAD_LEDS=y
-CONFIG_KALLSYMS_ALL=y
-CONFIG_KSM=y
-CONFIG_LOGIG940_FF=y
-CONFIG_LOGIRUMBLEPAD2_FF=y
-CONFIG_LOGITECH_FF=y
-CONFIG_MD=y
-CONFIG_MEDIA_SUPPORT=y
-CONFIG_MEMORY_STATE_TIME=y
-CONFIG_MSDOS_FS=y
-CONFIG_PANIC_TIMEOUT=5
-CONFIG_PANTHERLORD_FF=y
-CONFIG_PERF_EVENTS=y
-CONFIG_PM_DEBUG=y
-CONFIG_PM_RUNTIME=y
-CONFIG_PM_WAKELOCKS_LIMIT=0
-CONFIG_POWER_SUPPLY=y
-CONFIG_PSTORE=y
-CONFIG_PSTORE_CONSOLE=y
-CONFIG_PSTORE_RAM=y
-CONFIG_SCHEDSTATS=y
-CONFIG_SMARTJOYPLUS_FF=y
-CONFIG_SND=y
-CONFIG_SOUND=y
-CONFIG_SUSPEND_TIME=y
-CONFIG_TABLET_USB_ACECAD=y
-CONFIG_TABLET_USB_AIPTEK=y
-CONFIG_TABLET_USB_GTCO=y
-CONFIG_TABLET_USB_HANWANG=y
-CONFIG_TABLET_USB_KBTAB=y
-CONFIG_TASKSTATS=y
-CONFIG_TASK_DELAY_ACCT=y
-CONFIG_TASK_IO_ACCOUNTING=y
-CONFIG_TASK_XACCT=y
-CONFIG_TIMER_STATS=y
-CONFIG_TMPFS=y
-CONFIG_TMPFS_POSIX_ACL=y
-CONFIG_UHID=y
-CONFIG_MEMORY_STATE_TIME=y
-CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_HIDDEV=y
-CONFIG_USB_USBNET=y
-CONFIG_VFAT_FS=y
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 7e3dfa6..69dc428 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -411,13 +411,16 @@
 }
 static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st);
 
+static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st);
+
 static int bringup_wait_for_ap(unsigned int cpu)
 {
 	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 
 	/* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */
 	wait_for_completion(&st->done);
-	BUG_ON(!cpu_online(cpu));
+	if (WARN_ON_ONCE((!cpu_online(cpu))))
+		return -ECANCELED;
 
 	/* Unpark the stopper thread and the hotplug thread of the target cpu */
 	stop_machine_unpark(cpu);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index a99cd8d..d3a7411 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -61,6 +61,7 @@
 #include <linux/cgroup.h>
 #include <linux/wait.h>
 
+DEFINE_STATIC_KEY_FALSE(cpusets_pre_enable_key);
 DEFINE_STATIC_KEY_FALSE(cpusets_enabled_key);
 
 /* See "Frequency meter" comments, below. */
@@ -1907,6 +1908,7 @@
 	{
 		.name = "memory_pressure",
 		.read_u64 = cpuset_read_u64,
+		.private = FILE_MEMORY_PRESSURE,
 	},
 
 	{
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d1bed63..f6e81b5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1757,10 +1757,17 @@
 	 * If this was a group event with sibling events then
 	 * upgrade the siblings to singleton events by adding them
 	 * to whatever list we are on.
+	 * If this isn't on a list, make sure we still remove the sibling's
+	 * group_entry from this sibling_list; otherwise, when that sibling
+	 * is later deallocated, it will try to remove itself from this
+	 * sibling_list, which may well have been deallocated already,
+	 * resulting in a use-after-free.
 	 */
 	list_for_each_entry_safe(sibling, tmp, &event->sibling_list, group_entry) {
 		if (list)
 			list_move_tail(&sibling->group_entry, list);
+		else
+			list_del_init(&sibling->group_entry);
 		sibling->group_leader = sibling;
 
 		/* Inherit group flags from the previous leader */
@@ -9242,6 +9249,7 @@
 	if (!group_leader)
 		group_leader = event;
 
+	mutex_init(&event->group_leader_mutex);
 	mutex_init(&event->child_mutex);
 	INIT_LIST_HEAD(&event->child_list);
 
@@ -9755,6 +9763,16 @@
 			group_leader = NULL;
 	}
 
+	/*
+	 * Take the group_leader's group_leader_mutex before observing
+	 * anything in the group leader that leads to changes in ctx,
+	 * many of which may be changing on another thread.
+	 * In particular, we want to take this lock before deciding
+	 * whether we need to move_group.
+	 */
+	if (group_leader)
+		mutex_lock(&group_leader->group_leader_mutex);
+
 	if (pid != -1 && !(flags & PERF_FLAG_PID_CGROUP)) {
 		task = find_lively_task_by_vpid(pid);
 		if (IS_ERR(task)) {
@@ -9876,28 +9894,27 @@
 			goto err_context;
 
 		/*
-		 * Do not allow to attach to a group in a different
-		 * task or CPU context:
+		 * Make sure we're both events for the same CPU;
+		 * grouping events for different CPUs is broken; since
+		 * you can never concurrently schedule them anyhow.
 		 */
-		if (move_group) {
-			/*
-			 * Make sure we're both on the same task, or both
-			 * per-cpu events.
-			 */
-			if (group_leader->ctx->task != ctx->task)
-				goto err_context;
+		if (group_leader->cpu != event->cpu)
+			goto err_context;
 
-			/*
-			 * Make sure we're both events for the same CPU;
-			 * grouping events for different CPUs is broken; since
-			 * you can never concurrently schedule them anyhow.
-			 */
-			if (group_leader->cpu != event->cpu)
-				goto err_context;
-		} else {
-			if (group_leader->ctx != ctx)
-				goto err_context;
-		}
+		/*
+		 * Make sure we're both on the same task, or both
+		 * per-CPU events.
+		 */
+		if (group_leader->ctx->task != ctx->task)
+			goto err_context;
+
+		/*
+		 * Do not allow to attach to a group in a different task
+		 * or CPU context. If we're moving SW events, we'll fix
+		 * this up later, so allow that.
+		 */
+		if (!move_group && group_leader->ctx != ctx)
+			goto err_context;
 
 		/*
 		 * Only a group leader can be exclusive or pinned
@@ -10049,6 +10066,8 @@
 	if (move_group)
 		perf_event_ctx_unlock(group_leader, gctx);
 	mutex_unlock(&ctx->mutex);
+	if (group_leader)
+		mutex_unlock(&group_leader->group_leader_mutex);
 
 	if (task) {
 		mutex_unlock(&task->signal->cred_guard_mutex);
@@ -10096,6 +10115,8 @@
 	if (task)
 		put_task_struct(task);
 err_group_fd:
+	if (group_leader)
+		mutex_unlock(&group_leader->group_leader_mutex);
 	fdput(group);
 err_fd:
 	put_unused_fd(event_fd);
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index f9ec9ad..a1de021 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1254,8 +1254,6 @@
 
 void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm)
 {
-	newmm->uprobes_state.xol_area = NULL;
-
 	if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) {
 		set_bit(MMF_HAS_UPROBES, &newmm->flags);
 		/* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */
diff --git a/kernel/fork.c b/kernel/fork.c
index 39c0709..610aded 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -745,6 +745,13 @@
 #endif
 }
 
+static void mm_init_uprobes_state(struct mm_struct *mm)
+{
+#ifdef CONFIG_UPROBES
+	mm->uprobes_state.xol_area = NULL;
+#endif
+}
+
 static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
 	struct user_namespace *user_ns)
 {
@@ -766,11 +773,13 @@
 	mm_init_cpumask(mm);
 	mm_init_aio(mm);
 	mm_init_owner(mm, p);
+	RCU_INIT_POINTER(mm->exe_file, NULL);
 	mmu_notifier_mm_init(mm);
 	clear_tlb_flush_pending(mm);
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
 	mm->pmd_huge_pte = NULL;
 #endif
+	mm_init_uprobes_state(mm);
 
 	if (current->mm) {
 		mm->flags = current->mm->flags & MMF_INIT_MASK;
diff --git a/kernel/futex.c b/kernel/futex.c
index 4c6b6e6..88bad86 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -668,13 +668,14 @@
 		 * this reference was taken by ihold under the page lock
 		 * pinning the inode in place so i_lock was unnecessary. The
 		 * only way for this check to fail is if the inode was
-		 * truncated in parallel so warn for now if this happens.
+		 * truncated in parallel which is almost certainly an
+		 * application bug. In such a case, just retry.
 		 *
 		 * We are not calling into get_futex_key_refs() in file-backed
 		 * cases, therefore a successful atomic_inc return below will
 		 * guarantee that get_futex_key() will still imply smp_mb(); (B).
 		 */
-		if (WARN_ON_ONCE(!atomic_inc_not_zero(&inode->i_count))) {
+		if (!atomic_inc_not_zero(&inode->i_count)) {
 			rcu_read_unlock();
 			put_page(page);
 
diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
index 2f9df37..c51a49c 100644
--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -98,6 +98,12 @@
 }
 EXPORT_SYMBOL(__gcov_merge_icall_topn);
 
+void __gcov_exit(void)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_exit);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 6a5c239..46a18e7 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ >= 7)
+#define GCOV_COUNTERS			9
+#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS			10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 077c87f..f30110e 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -895,13 +895,15 @@
 
 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 {
-	unsigned long flags;
+	unsigned long flags, trigger, tmp;
 	struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
 
 	if (!desc)
 		return;
 	irq_settings_clr_and_set(desc, clr, set);
 
+	trigger = irqd_get_trigger_type(&desc->irq_data);
+
 	irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
 		   IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
 	if (irq_settings_has_no_balance_set(desc))
@@ -913,7 +915,11 @@
 	if (irq_settings_is_level(desc))
 		irqd_set(&desc->irq_data, IRQD_LEVEL);
 
-	irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
+	tmp = irq_settings_get_trigger_mask(desc);
+	if (tmp != IRQ_TYPE_NONE)
+		trigger = tmp;
+
+	irqd_set(&desc->irq_data, trigger);
 
 	irq_put_desc_unlock(desc, flags);
 }
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c
index 1a9abc1..259a22a 100644
--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -165,7 +165,7 @@
 	struct irq_data *data = irq_get_irq_data(irq);
 	struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
 
-	if (!data || !ipimask || cpu > nr_cpu_ids)
+	if (!data || !ipimask || cpu >= nr_cpu_ids)
 		return INVALID_HWIRQ;
 
 	if (!cpumask_test_cpu(cpu, ipimask))
@@ -195,7 +195,7 @@
 	if (!chip->ipi_send_single && !chip->ipi_send_mask)
 		return -EINVAL;
 
-	if (cpu > nr_cpu_ids)
+	if (cpu >= nr_cpu_ids)
 		return -EINVAL;
 
 	if (dest) {
diff --git a/kernel/kcov.c b/kernel/kcov.c
index 3cbb0c8..f8f3f4c 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -14,6 +14,7 @@
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/kcov.h>
+#include <asm/setup.h>
 
 /*
  * kcov descriptor (one per opened debugfs file).
@@ -68,6 +69,11 @@
 	if (mode == KCOV_MODE_TRACE) {
 		unsigned long *area;
 		unsigned long pos;
+		unsigned long ip = _RET_IP_;
+
+#ifdef CONFIG_RANDOMIZE_BASE
+		ip -= kaslr_offset();
+#endif
 
 		/*
 		 * There is some code that runs in interrupts but for which
@@ -81,7 +87,7 @@
 		/* The first word is number of subsequent PCs. */
 		pos = READ_ONCE(area[0]) + 1;
 		if (likely(pos < t->kcov_size)) {
-			area[pos] = _RET_IP_;
+			area[pos] = ip;
 			WRITE_ONCE(area[0], pos);
 		}
 	}
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index f8c5af5..d3de04b 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -780,6 +780,10 @@
 	else
 		lock_torture_print_module_parms(cxt.cur_ops,
 						"End of test: SUCCESS");
+
+	kfree(cxt.lwsa);
+	kfree(cxt.lrsa);
+
 end:
 	torture_cleanup_end();
 }
@@ -924,6 +928,8 @@
 				       GFP_KERNEL);
 		if (reader_tasks == NULL) {
 			VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory");
+			kfree(writer_tasks);
+			writer_tasks = NULL;
 			firsterr = -ENOMEM;
 			goto unwind;
 		}
diff --git a/kernel/panic.c b/kernel/panic.c
index dbec387..fcc8786 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -25,6 +25,8 @@
 #include <linux/nmi.h>
 #include <linux/console.h>
 #include <linux/bug.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/exception.h>
 
 #define PANIC_TIMER_STEP 100
 #define PANIC_BLINK_SPD 18
@@ -136,6 +138,8 @@
 	int old_cpu, this_cpu;
 	bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
 
+	trace_kernel_panic(0);
+
 	/*
 	 * Disable local interrupts. This will prevent panic_smp_self_stop
 	 * from deadlocking the first cpu that invokes the panic, since
@@ -260,6 +264,9 @@
 			mdelay(PANIC_TIMER_STEP);
 		}
 	}
+
+	trace_kernel_panic_late(0);
+
 	if (panic_timeout != 0) {
 		/*
 		 * This will not be a clean reboot, with everything
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a836ad6..d43ad69 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3232,20 +3232,21 @@
 
 static inline
 unsigned long sum_capacity_reqs(unsigned long cfs_cap,
-				struct sched_capacity_reqs *scr)
+				struct sched_capacity_reqs *scr, int cpu)
 {
-	unsigned long total = add_capacity_margin(cfs_cap + scr->rt);
+	unsigned long total = add_capacity_margin(cfs_cap + scr->rt, cpu);
 	return total += scr->dl;
 }
 
+unsigned long boosted_cpu_util(int cpu);
 static void sched_freq_tick_pelt(int cpu)
 {
-	unsigned long cpu_utilization = capacity_max;
+	unsigned long cpu_utilization = boosted_cpu_util(cpu);
 	unsigned long capacity_curr = capacity_curr_of(cpu);
 	struct sched_capacity_reqs *scr;
 
 	scr = &per_cpu(cpu_sched_capacity_reqs, cpu);
-	if (sum_capacity_reqs(cpu_utilization, scr) < capacity_curr)
+	if (sum_capacity_reqs(cpu_utilization, scr, cpu) < capacity_curr)
 		return;
 
 	/*
@@ -3304,6 +3305,7 @@
 	bool early_notif;
 	u32 old_load;
 	struct related_thread_group *grp;
+	unsigned int flag = 0;
 
 	sched_clock_tick();
 
@@ -3320,10 +3322,12 @@
 	cpu_load_update_active(rq);
 	calc_global_load_tick(rq);
 	sched_freq_tick(cpu);
-	cpufreq_update_util(rq, 0);
 
 	early_notif = early_detection_notify(rq, wallclock);
+	if (early_notif)
+		flag = SCHED_CPUFREQ_WALT | SCHED_CPUFREQ_EARLY_DET;
 
+	cpufreq_update_util(rq, flag);
 	raw_spin_unlock(&rq->lock);
 
 	if (early_notif)
@@ -6222,9 +6226,6 @@
 
 	if (!(sd->flags & SD_LOAD_BALANCE)) {
 		printk("does not load-balance\n");
-		if (sd->parent)
-			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
-					" has parent");
 		return -1;
 	}
 
@@ -6319,8 +6320,12 @@
 
 static int sd_degenerate(struct sched_domain *sd)
 {
-	if (cpumask_weight(sched_domain_span(sd)) == 1)
-		return 1;
+	if (cpumask_weight(sched_domain_span(sd)) == 1) {
+		if (sd->groups->sge)
+			sd->flags &= ~SD_LOAD_BALANCE;
+		else
+			return 1;
+	}
 
 	/* Following flags need at least 2 groups */
 	if (sd->flags & (SD_LOAD_BALANCE |
@@ -6366,6 +6371,10 @@
 				SD_PREFER_SIBLING |
 				SD_SHARE_POWERDOMAIN |
 				SD_SHARE_CAP_STATES);
+		if (parent->groups->sge) {
+			parent->flags &= ~SD_LOAD_BALANCE;
+			return 0;
+		}
 		if (nr_node_ids == 1)
 			pflags &= ~SD_SERIALIZE;
 	}
@@ -6446,6 +6455,9 @@
 		goto free_rto_mask;
 
 	init_max_cpu_capacity(&rd->max_cpu_capacity);
+
+	rd->max_cap_orig_cpu = rd->min_cap_orig_cpu = -1;
+
 	return 0;
 
 free_rto_mask:
@@ -6790,6 +6802,7 @@
 		 */
 		sg->sgc->capacity = SCHED_CAPACITY_SCALE * cpumask_weight(sg_span);
 		sg->sgc->max_capacity = SCHED_CAPACITY_SCALE;
+		sg->sgc->min_capacity = SCHED_CAPACITY_SCALE;
 
 		/*
 		 * Make sure the first group of this domain contains the
@@ -7668,7 +7681,6 @@
 	enum s_alloc alloc_state;
 	struct sched_domain *sd;
 	struct s_data d;
-	struct rq *rq = NULL;
 	int i, ret = -ENOMEM;
 
 	alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
@@ -7686,8 +7698,6 @@
 				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
 				sd->flags |= SD_OVERLAP;
-			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
-				break;
 		}
 	}
 
@@ -7722,8 +7732,19 @@
 	/* Attach the domains */
 	rcu_read_lock();
 	for_each_cpu(i, cpu_map) {
-		rq = cpu_rq(i);
+		int max_cpu = READ_ONCE(d.rd->max_cap_orig_cpu);
+		int min_cpu = READ_ONCE(d.rd->min_cap_orig_cpu);
+
+		if ((max_cpu < 0) || (cpu_rq(i)->cpu_capacity_orig >
+		    cpu_rq(max_cpu)->cpu_capacity_orig))
+			WRITE_ONCE(d.rd->max_cap_orig_cpu, i);
+
+		if ((min_cpu < 0) || (cpu_rq(i)->cpu_capacity_orig <
+		    cpu_rq(min_cpu)->cpu_capacity_orig))
+			WRITE_ONCE(d.rd->min_cap_orig_cpu, i);
+
 		sd = *per_cpu_ptr(d.sd, i);
+
 		cpu_attach_domain(sd, d.rd, i);
 	}
 	rcu_read_unlock();
@@ -8260,6 +8281,7 @@
 #ifdef CONFIG_FAIR_GROUP_SCHED
 		root_task_group.shares = ROOT_TASK_GROUP_LOAD;
 		INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
+		rq->tmp_alone_branch = &rq->leaf_cfs_rq_list;
 		/*
 		 * How much cpu bandwidth does root_task_group get?
 		 *
@@ -9081,11 +9103,20 @@
 	if (IS_ERR(tg))
 		return ERR_PTR(-ENOMEM);
 
-	sched_online_group(tg, parent);
-
 	return &tg->css;
 }
 
+/* Expose task group only after completing cgroup initialization */
+static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
+{
+	struct task_group *tg = css_tg(css);
+	struct task_group *parent = css_tg(css->parent);
+
+	if (parent)
+		sched_online_group(tg, parent);
+	return 0;
+}
+
 static void cpu_cgroup_css_released(struct cgroup_subsys_state *css)
 {
 	struct task_group *tg = css_tg(css);
@@ -9488,6 +9519,7 @@
 
 struct cgroup_subsys cpu_cgrp_subsys = {
 	.css_alloc	= cpu_cgroup_css_alloc,
+	.css_online	= cpu_cgroup_css_online,
 	.css_released	= cpu_cgroup_css_released,
 	.css_free	= cpu_cgroup_css_free,
 	.fork		= cpu_cgroup_fork,
@@ -9591,4 +9623,51 @@
 }
 #endif /* CONFIG_SCHED_WALT */
 
-__read_mostly bool sched_predl;
+__read_mostly bool sched_predl = 1;
+
+#ifdef CONFIG_SCHED_CORE_ROTATE
+int
+find_first_cpu_bit(struct task_struct *p, const cpumask_t *search_cpus,
+		   struct sched_group *sg_target, bool *avoid_prev_cpu,
+		   bool *do_rotate, struct find_first_cpu_bit_env *env)
+{
+	int i = -1;
+	unsigned long mcc;
+	int cpu = smp_processor_id();
+
+	mcc = cpu_rq(cpu)->rd->max_cpu_capacity.val;
+
+	/* do rotation only for big CPUs. */
+	*do_rotate = (cpumask_first(search_cpus) < nr_cpu_ids &&
+		     capacity_orig_of(cpumask_first(search_cpus)) == mcc);
+
+	if (*do_rotate) {
+		if (time_before_eq(jiffies, *env->avoid_prev_cpu_last +
+				   env->interval))
+			return *env->rotate_cpu_start;
+
+		spin_lock(env->rotate_lock);
+		if (time_after(jiffies, *env->avoid_prev_cpu_last +
+					env->interval)) {
+			cpumask_t tmpmask;
+
+			*env->avoid_prev_cpu_last = jiffies;
+			*avoid_prev_cpu = true;
+
+			cpumask_copy(&tmpmask, sched_group_cpus(sg_target));
+			cpumask_andnot(&tmpmask, &tmpmask, cpu_isolated_mask);
+
+			i = cpumask_next(*env->rotate_cpu_start, &tmpmask);
+			if (i >= nr_cpu_ids)
+				i = cpumask_first(&tmpmask) - 1;
+			/* Change start CPU every interval. */
+			*env->rotate_cpu_start = i;
+		} else {
+			i = *env->rotate_cpu_start;
+		}
+		spin_unlock(env->rotate_lock);
+	}
+
+	return i;
+}
+#endif
diff --git a/kernel/sched/core_ctl.c b/kernel/sched/core_ctl.c
index e56af41..772d97b 100644
--- a/kernel/sched/core_ctl.c
+++ b/kernel/sched/core_ctl.c
@@ -19,6 +19,7 @@
 #include <linux/kthread.h>
 #include <linux/sched.h>
 #include <linux/sched/rt.h>
+#include <linux/syscore_ops.h>
 
 #include <trace/events/sched.h>
 
@@ -35,6 +36,10 @@
 	unsigned int active_cpus;
 	unsigned int num_cpus;
 	unsigned int nr_isolated_cpus;
+#ifdef CONFIG_SCHED_CORE_ROTATE
+	unsigned long set_max;
+	unsigned long set_cur;
+#endif
 	cpumask_t cpu_mask;
 	unsigned int need_cpus;
 	unsigned int task_thres;
@@ -76,6 +81,7 @@
 static bool initialized;
 
 static unsigned int get_active_cpu_count(const struct cluster_data *cluster);
+static void cpuset_next(struct cluster_data *cluster);
 
 /* ========================= sysfs interface =========================== */
 
@@ -88,6 +94,7 @@
 		return -EINVAL;
 
 	state->min_cpus = min(val, state->max_cpus);
+	cpuset_next(state);
 	wake_up_core_ctl_thread(state);
 
 	return count;
@@ -109,6 +116,7 @@
 	val = min(val, state->num_cpus);
 	state->max_cpus = val;
 	state->min_cpus = min(state->min_cpus, state->max_cpus);
+	cpuset_next(state);
 	wake_up_core_ctl_thread(state);
 
 	return count;
@@ -702,6 +710,67 @@
 	spin_unlock_irqrestore(&state_lock, flags);
 }
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+static void cpuset_next(struct cluster_data *cluster)
+{
+	int cpus_needed = cluster->num_cpus - cluster->min_cpus;
+
+	cluster->set_cur++;
+	cluster->set_cur = min(cluster->set_cur, cluster->set_max);
+
+	/*
+	 * This loop generates bit sets from 0 to pow(num_cpus, 2) - 1.
+	 * We start loop from set_cur to set_cur - 1 and break when weight of
+	 * set_cur equals to cpus_needed.
+	 */
+
+	while (1) {
+		if (bitmap_weight(&cluster->set_cur, BITS_PER_LONG) ==
+		    cpus_needed) {
+			break;
+		}
+		cluster->set_cur++;
+		cluster->set_cur = min(cluster->set_cur, cluster->set_max);
+		if (cluster->set_cur == cluster->set_max)
+			/* roll over */
+			cluster->set_cur = 0;
+	};
+
+	pr_debug("first_cpu=%d cpus_needed=%d set_cur=0x%lx\n",
+		 cluster->first_cpu, cpus_needed, cluster->set_cur);
+}
+
+static bool should_we_isolate(int cpu, struct cluster_data *cluster)
+{
+	/* cpu should be part of cluster */
+	return !!(cluster->set_cur & (1 << (cpu - cluster->first_cpu)));
+}
+
+static void core_ctl_resume(void)
+{
+	unsigned int i = 0;
+	struct cluster_data *cluster;
+
+	/* move to next isolation cpu set */
+	for_each_cluster(cluster, i)
+		cpuset_next(cluster);
+}
+
+static struct syscore_ops core_ctl_syscore_ops = {
+	.resume	= core_ctl_resume,
+};
+
+#else
+
+static void cpuset_next(struct cluster_data *cluster) { }
+
+static bool should_we_isolate(int cpu, struct cluster_data *cluster)
+{
+	return true;
+}
+
+#endif
+
 static void try_to_isolate(struct cluster_data *cluster, unsigned int need)
 {
 	struct cpu_data *c, *tmp;
@@ -726,6 +795,9 @@
 		if (c->is_busy)
 			continue;
 
+		if (!should_we_isolate(c->cpu, cluster))
+			continue;
+
 		spin_unlock_irqrestore(&state_lock, flags);
 
 		pr_debug("Trying to isolate CPU%u\n", c->cpu);
@@ -1029,6 +1101,11 @@
 	cluster->offline_delay_ms = 100;
 	cluster->task_thres = UINT_MAX;
 	cluster->nrrun = cluster->num_cpus;
+#ifdef CONFIG_SCHED_CORE_ROTATE
+	cluster->set_max = cluster->num_cpus * cluster->num_cpus;
+	/* by default mark all cpus as eligible */
+	cluster->set_cur = cluster->set_max - 1;
+#endif
 	cluster->enable = true;
 	INIT_LIST_HEAD(&cluster->lru);
 	spin_lock_init(&cluster->pending_lock);
@@ -1065,6 +1142,10 @@
 	if (should_skip(cpu_possible_mask))
 		return 0;
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+	register_syscore_ops(&core_ctl_syscore_ops);
+#endif
+
 	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
 			"core_ctl/isolation:online",
 			core_ctl_isolation_online_cpu, NULL);
diff --git a/kernel/sched/cpufreq_sched.c b/kernel/sched/cpufreq_sched.c
index 11b75e3..843eaa7 100644
--- a/kernel/sched/cpufreq_sched.c
+++ b/kernel/sched/cpufreq_sched.c
@@ -32,6 +32,12 @@
 static DEFINE_PER_CPU(unsigned long, enabled);
 DEFINE_PER_CPU(struct sched_capacity_reqs, cpu_sched_capacity_reqs);
 
+struct gov_tunables {
+	struct gov_attr_set attr_set;
+	unsigned int up_throttle_nsec;
+	unsigned int down_throttle_nsec;
+};
+
 /**
  * gov_data - per-policy data internal to the governor
  * @up_throttle: next throttling period expiry if increasing OPP
@@ -53,8 +59,8 @@
 struct gov_data {
 	ktime_t up_throttle;
 	ktime_t down_throttle;
-	unsigned int up_throttle_nsec;
-	unsigned int down_throttle_nsec;
+	struct gov_tunables *tunables;
+	struct list_head tunables_hook;
 	struct task_struct *task;
 	struct irq_work irq_work;
 	unsigned int requested_freq;
@@ -71,8 +77,10 @@
 
 	__cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
 
-	gd->up_throttle = ktime_add_ns(ktime_get(), gd->up_throttle_nsec);
-	gd->down_throttle = ktime_add_ns(ktime_get(), gd->down_throttle_nsec);
+	gd->up_throttle = ktime_add_ns(ktime_get(),
+				       gd->tunables->up_throttle_nsec);
+	gd->down_throttle = ktime_add_ns(ktime_get(),
+					 gd->tunables->down_throttle_nsec);
 	up_write(&policy->rwsem);
 }
 
@@ -263,12 +271,70 @@
 	static_key_slow_dec(&__sched_freq);
 }
 
-static struct attribute_group sched_attr_group_gov_pol;
-static struct attribute_group *get_sysfs_attr(void)
+/* Tunables */
+static struct gov_tunables *global_tunables;
+
+static inline struct gov_tunables *to_tunables(struct gov_attr_set *attr_set)
 {
-	return &sched_attr_group_gov_pol;
+	return container_of(attr_set, struct gov_tunables, attr_set);
 }
 
+static ssize_t up_throttle_nsec_show(struct gov_attr_set *attr_set, char *buf)
+{
+	struct gov_tunables *tunables = to_tunables(attr_set);
+
+	return sprintf(buf, "%u\n", tunables->up_throttle_nsec);
+}
+
+static ssize_t up_throttle_nsec_store(struct gov_attr_set *attr_set,
+				      const char *buf, size_t count)
+{
+	struct gov_tunables *tunables = to_tunables(attr_set);
+	int ret;
+	long unsigned int val;
+
+	ret = kstrtoul(buf, 0, &val);
+	if (ret < 0)
+		return ret;
+	tunables->up_throttle_nsec = val;
+	return count;
+}
+
+static ssize_t down_throttle_nsec_show(struct gov_attr_set *attr_set, char *buf)
+{
+	struct gov_tunables *tunables = to_tunables(attr_set);
+
+	return sprintf(buf, "%u\n", tunables->down_throttle_nsec);
+}
+
+static ssize_t down_throttle_nsec_store(struct gov_attr_set *attr_set,
+					const char *buf, size_t count)
+{
+	struct gov_tunables *tunables = to_tunables(attr_set);
+	int ret;
+	long unsigned int val;
+
+	ret = kstrtoul(buf, 0, &val);
+	if (ret < 0)
+		return ret;
+	tunables->down_throttle_nsec = val;
+	return count;
+}
+
+static struct governor_attr up_throttle_nsec = __ATTR_RW(up_throttle_nsec);
+static struct governor_attr down_throttle_nsec = __ATTR_RW(down_throttle_nsec);
+
+static struct attribute *schedfreq_attributes[] = {
+	&up_throttle_nsec.attr,
+	&down_throttle_nsec.attr,
+	NULL
+};
+
+static struct kobj_type tunables_ktype = {
+	.default_attrs = schedfreq_attributes,
+	.sysfs_ops = &governor_sysfs_ops,
+};
+
 static int cpufreq_sched_policy_init(struct cpufreq_policy *policy)
 {
 	struct gov_data *gd;
@@ -283,17 +349,39 @@
 	if (!gd)
 		return -ENOMEM;
 
-	gd->up_throttle_nsec = policy->cpuinfo.transition_latency ?
-			    policy->cpuinfo.transition_latency :
-			    THROTTLE_UP_NSEC;
-	gd->down_throttle_nsec = THROTTLE_DOWN_NSEC;
-	pr_debug("%s: throttle threshold = %u [ns]\n",
-		  __func__, gd->up_throttle_nsec);
+	policy->governor_data = gd;
 
-	rc = sysfs_create_group(&policy->kobj, get_sysfs_attr());
-	if (rc) {
-		pr_err("%s: couldn't create sysfs attributes: %d\n", __func__, rc);
-		goto err;
+	if (!global_tunables) {
+		gd->tunables = kzalloc(sizeof(*gd->tunables), GFP_KERNEL);
+		if (!gd->tunables)
+			goto free_gd;
+
+		gd->tunables->up_throttle_nsec =
+			policy->cpuinfo.transition_latency ?
+			policy->cpuinfo.transition_latency :
+			THROTTLE_UP_NSEC;
+		gd->tunables->down_throttle_nsec =
+			THROTTLE_DOWN_NSEC;
+
+		rc = kobject_init_and_add(&gd->tunables->attr_set.kobj,
+					  &tunables_ktype,
+					  get_governor_parent_kobj(policy),
+					  "%s", cpufreq_gov_sched.name);
+		if (rc)
+			goto free_tunables;
+
+		gov_attr_set_init(&gd->tunables->attr_set,
+				  &gd->tunables_hook);
+
+		pr_debug("%s: throttle_threshold = %u [ns]\n",
+			 __func__, gd->tunables->up_throttle_nsec);
+
+		if (!have_governor_per_policy())
+			global_tunables = gd->tunables;
+	} else {
+		gd->tunables = global_tunables;
+		gov_attr_set_get(&global_tunables->attr_set,
+				 &gd->tunables_hook);
 	}
 
 	policy->governor_data = gd;
@@ -305,7 +393,7 @@
 		if (IS_ERR_OR_NULL(gd->task)) {
 			pr_err("%s: failed to create kschedfreq thread\n",
 			       __func__);
-			goto err;
+			goto free_tunables;
 		}
 		get_task_struct(gd->task);
 		kthread_bind_mask(gd->task, policy->related_cpus);
@@ -317,7 +405,9 @@
 
 	return 0;
 
-err:
+free_tunables:
+	kfree(gd->tunables);
+free_gd:
 	policy->governor_data = NULL;
 	kfree(gd);
 	return -ENOMEM;
@@ -325,6 +415,7 @@
 
 static void cpufreq_sched_policy_exit(struct cpufreq_policy *policy)
 {
+	unsigned int count;
 	struct gov_data *gd = policy->governor_data;
 
 	clear_sched_freq();
@@ -333,7 +424,12 @@
 		put_task_struct(gd->task);
 	}
 
-	sysfs_remove_group(&policy->kobj, get_sysfs_attr());
+	count = gov_attr_set_put(&gd->tunables->attr_set, &gd->tunables_hook);
+	if (!count) {
+		if (!have_governor_per_policy())
+			global_tunables = NULL;
+		kfree(gd->tunables);
+	}
 
 	policy->governor_data = NULL;
 
@@ -373,88 +469,6 @@
 		per_cpu(enabled, cpu) = 0;
 }
 
-/* Tunables */
-static ssize_t show_up_throttle_nsec(struct gov_data *gd, char *buf)
-{
-	return sprintf(buf, "%u\n", gd->up_throttle_nsec);
-}
-
-static ssize_t store_up_throttle_nsec(struct gov_data *gd,
-		const char *buf, size_t count)
-{
-	int ret;
-	long unsigned int val;
-
-	ret = kstrtoul(buf, 0, &val);
-	if (ret < 0)
-		return ret;
-	gd->up_throttle_nsec = val;
-	return count;
-}
-
-static ssize_t show_down_throttle_nsec(struct gov_data *gd, char *buf)
-{
-	return sprintf(buf, "%u\n", gd->down_throttle_nsec);
-}
-
-static ssize_t store_down_throttle_nsec(struct gov_data *gd,
-		const char *buf, size_t count)
-{
-	int ret;
-	long unsigned int val;
-
-	ret = kstrtoul(buf, 0, &val);
-	if (ret < 0)
-		return ret;
-	gd->down_throttle_nsec = val;
-	return count;
-}
-
-/*
- * Create show/store routines
- * - sys: One governor instance for complete SYSTEM
- * - pol: One governor instance per struct cpufreq_policy
- */
-#define show_gov_pol_sys(file_name)					\
-static ssize_t show_##file_name##_gov_pol				\
-(struct cpufreq_policy *policy, char *buf)				\
-{									\
-	return show_##file_name(policy->governor_data, buf);		\
-}
-
-#define store_gov_pol_sys(file_name)					\
-static ssize_t store_##file_name##_gov_pol				\
-(struct cpufreq_policy *policy, const char *buf, size_t count)		\
-{									\
-	return store_##file_name(policy->governor_data, buf, count);	\
-}
-
-#define gov_pol_attr_rw(_name)						\
-	static struct freq_attr _name##_gov_pol =				\
-	__ATTR(_name, 0644, show_##_name##_gov_pol, store_##_name##_gov_pol)
-
-#define show_store_gov_pol_sys(file_name)				\
-	show_gov_pol_sys(file_name);						\
-	store_gov_pol_sys(file_name)
-#define tunable_handlers(file_name) \
-	show_gov_pol_sys(file_name); \
-	store_gov_pol_sys(file_name); \
-	gov_pol_attr_rw(file_name)
-
-tunable_handlers(down_throttle_nsec);
-tunable_handlers(up_throttle_nsec);
-
-/* Per policy governor instance */
-static struct attribute *sched_attributes_gov_pol[] = {
-	&up_throttle_nsec_gov_pol.attr,
-	&down_throttle_nsec_gov_pol.attr,
-	NULL,
-};
-
-static struct attribute_group sched_attr_group_gov_pol = {
-	.attrs = sched_attributes_gov_pol,
-	.name = "sched",
-};
 
 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_SCHED
 static
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 8d327c3..2eb966c 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -17,12 +17,18 @@
 #include <trace/events/power.h>
 #include <linux/sched/sysctl.h>
 #include "sched.h"
+#include "tune.h"
+
+#ifdef CONFIG_SCHED_WALT
+unsigned long boosted_cpu_util(int cpu);
+#endif
 
 #define SUGOV_KTHREAD_PRIORITY	50
 
 struct sugov_tunables {
 	struct gov_attr_set attr_set;
 	unsigned int rate_limit_us;
+	unsigned int hispeed_load;
 	unsigned int hispeed_freq;
 	bool pl;
 };
@@ -71,9 +77,15 @@
 	unsigned long max;
 	unsigned int flags;
 	unsigned int cpu;
+
+	/* The field below is for single-CPU policies only. */
+#ifdef CONFIG_NO_HZ_COMMON
+	unsigned long saved_idle_calls;
+#endif
 };
 
 static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu);
+static unsigned int stale_ns;
 
 /************************ Governor internals ***********************/
 
@@ -100,22 +112,20 @@
 {
 	struct cpufreq_policy *policy = sg_policy->policy;
 
+	if (sg_policy->next_freq == next_freq)
+		return;
+
+	sg_policy->next_freq = next_freq;
 	sg_policy->last_freq_update_time = time;
 
 	if (policy->fast_switch_enabled) {
-		if (sg_policy->next_freq == next_freq) {
-			trace_cpu_frequency(policy->cur, smp_processor_id());
-			return;
-		}
-		sg_policy->next_freq = next_freq;
 		next_freq = cpufreq_driver_fast_switch(policy, next_freq);
 		if (next_freq == CPUFREQ_ENTRY_INVALID)
 			return;
 
 		policy->cur = next_freq;
 		trace_cpu_frequency(next_freq, smp_processor_id());
-	} else if (sg_policy->next_freq != next_freq) {
-		sg_policy->next_freq = next_freq;
+	} else {
 		sg_policy->work_in_progress = true;
 		irq_work_queue(&sg_policy->irq_work);
 	}
@@ -171,6 +181,7 @@
 	*max = cfs_max;
 
 	*util = cpu_util_freq(cpu, &loadcpu->walt_load);
+	*util = boosted_cpu_util(cpu);
 }
 
 static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
@@ -256,7 +267,7 @@
 }
 
 #define NL_RATIO 75
-#define HISPEED_LOAD 90
+#define DEFAULT_HISPEED_LOAD 90
 static void sugov_walt_adjust(struct sugov_cpu *sg_cpu, unsigned long *util,
 			      unsigned long *max)
 {
@@ -270,7 +281,7 @@
 		return;
 
 	is_hiload = (cpu_util >= mult_frac(sg_policy->avg_cap,
-					   HISPEED_LOAD,
+					   sg_policy->tunables->hispeed_load,
 					   100));
 
 	if (is_hiload && !is_migration)
@@ -283,6 +294,19 @@
 		*util = max(*util, sg_cpu->walt_load.pl);
 }
 
+#ifdef CONFIG_NO_HZ_COMMON
+static bool sugov_cpu_is_busy(struct sugov_cpu *sg_cpu)
+{
+	unsigned long idle_calls = tick_nohz_get_idle_calls();
+	bool ret = idle_calls == sg_cpu->saved_idle_calls;
+
+	sg_cpu->saved_idle_calls = idle_calls;
+	return ret;
+}
+#else
+static inline bool sugov_cpu_is_busy(struct sugov_cpu *sg_cpu) { return false; }
+#endif /* CONFIG_NO_HZ_COMMON */
+
 static void sugov_update_single(struct update_util_data *hook, u64 time,
 				unsigned int flags)
 {
@@ -291,6 +315,7 @@
 	struct cpufreq_policy *policy = sg_policy->policy;
 	unsigned long util, max;
 	unsigned int next_f;
+	bool busy;
 
 	sugov_set_iowait_boost(sg_cpu, time, flags);
 	sg_cpu->last_update = time;
@@ -298,6 +323,7 @@
 	if (!sugov_should_update_freq(sg_policy, time))
 		return;
 
+	busy = sugov_cpu_is_busy(sg_cpu);
 	flags &= ~SCHED_CPUFREQ_RT_DL;
 
 	if (flags & SCHED_CPUFREQ_RT_DL) {
@@ -309,35 +335,29 @@
 				   sg_policy->policy->cur);
 		sugov_walt_adjust(sg_cpu, &util, &max);
 		next_f = get_next_freq(sg_policy, util, max);
+		/*
+		 * Do not reduce the frequency if the CPU has not been idle
+		 * recently, as the reduction is likely to be premature then.
+		 */
+		if (busy && next_f < sg_policy->next_freq)
+			next_f = sg_policy->next_freq;
 	}
 	sugov_update_commit(sg_policy, time, next_f);
 }
 
-static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu,
-					   unsigned long util, unsigned long max,
-					   unsigned int flags)
+static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu)
 {
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
 	struct cpufreq_policy *policy = sg_policy->policy;
-	unsigned int max_f = policy->cpuinfo.max_freq;
 	u64 last_freq_update_time = sg_policy->last_freq_update_time;
+	unsigned long util = 0, max = 1;
 	unsigned int j;
 
-	if (flags & SCHED_CPUFREQ_RT_DL)
-		return max_f;
-
-	sugov_iowait_boost(sg_cpu, &util, &max);
-	sugov_walt_adjust(sg_cpu, &util, &max);
-
 	for_each_cpu(j, policy->cpus) {
-		struct sugov_cpu *j_sg_cpu;
+		struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
 		unsigned long j_util, j_max;
 		s64 delta_ns;
 
-		if (j == sg_cpu->cpu)
-			continue;
-
-		j_sg_cpu = &per_cpu(sugov_cpu, j);
 		/*
 		 * If the CPU utilization was last updated before the previous
 		 * frequency update and the time elapsed between the last update
@@ -346,12 +366,12 @@
 		 * idle now (and clear iowait_boost for it).
 		 */
 		delta_ns = last_freq_update_time - j_sg_cpu->last_update;
-		if (delta_ns > sched_ravg_window) {
+		if (delta_ns > stale_ns) {
 			j_sg_cpu->iowait_boost = 0;
 			continue;
 		}
 		if (j_sg_cpu->flags & SCHED_CPUFREQ_RT_DL)
-			return max_f;
+			return policy->cpuinfo.max_freq;
 
 		j_util = j_sg_cpu->util;
 		j_max = j_sg_cpu->max;
@@ -404,7 +424,11 @@
 				sg_cpu->walt_load.pl, flags);
 
 	if (sugov_should_update_freq(sg_policy, time)) {
-		next_f = sugov_next_freq_shared(sg_cpu, util, max, flags);
+		if (flags & SCHED_CPUFREQ_RT_DL)
+			next_f = sg_policy->policy->cpuinfo.max_freq;
+		else
+			next_f = sugov_next_freq_shared(sg_cpu);
+
 		sugov_update_commit(sg_policy, time, next_f);
 	}
 
@@ -485,6 +509,26 @@
 	return count;
 }
 
+static ssize_t hispeed_load_show(struct gov_attr_set *attr_set, char *buf)
+{
+	struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
+
+	return sprintf(buf, "%u\n", tunables->hispeed_load);
+}
+
+static ssize_t hispeed_load_store(struct gov_attr_set *attr_set,
+				  const char *buf, size_t count)
+{
+	struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
+
+	if (kstrtouint(buf, 10, &tunables->hispeed_load))
+		return -EINVAL;
+
+	tunables->hispeed_load = min(100U, tunables->hispeed_load);
+
+	return count;
+}
+
 static ssize_t hispeed_freq_show(struct gov_attr_set *attr_set, char *buf)
 {
 	struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
@@ -536,11 +580,13 @@
 }
 
 static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us);
+static struct governor_attr hispeed_load = __ATTR_RW(hispeed_load);
 static struct governor_attr hispeed_freq = __ATTR_RW(hispeed_freq);
 static struct governor_attr pl = __ATTR_RW(pl);
 
 static struct attribute *sugov_attributes[] = {
 	&rate_limit_us.attr,
+	&hispeed_load.attr,
 	&hispeed_freq.attr,
 	&pl.attr,
 	NULL
@@ -687,6 +733,7 @@
 	}
 
 	tunables->rate_limit_us = LATENCY_MULTIPLIER;
+	tunables->hispeed_load = DEFAULT_HISPEED_LOAD;
 	tunables->hispeed_freq = 0;
 	lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
 	if (lat)
@@ -694,6 +741,7 @@
 
 	policy->governor_data = sg_policy;
 	sg_policy->tunables = tunables;
+	stale_ns = sched_ravg_window + (sched_ravg_window >> 3);
 
 	ret = kobject_init_and_add(&tunables->attr_set.kobj, &sugov_tunables_ktype,
 				   get_governor_parent_kobj(policy), "%s",
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 0f8c0b2..c091ca4 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -1008,6 +1008,33 @@
 		P_SCHEDSTAT(se.statistics.nr_wakeups_affine_attempts);
 		P_SCHEDSTAT(se.statistics.nr_wakeups_passive);
 		P_SCHEDSTAT(se.statistics.nr_wakeups_idle);
+		/* eas */
+		/* select_idle_sibling() */
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_attempts);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_idle);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_cache_affine);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_suff_cap);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_idle_cpu);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_sis_count);
+		/* select_energy_cpu_brute() */
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_attempts);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_sync);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_idle_bt);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_insuff_cap);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_no_nrg_sav);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_nrg_sav);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_secb_count);
+		/* find_best_target() */
+		P_SCHEDSTAT(se.statistics.nr_wakeups_fbt_attempts);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_fbt_no_cpu);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_fbt_no_sd);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_fbt_pref_idle);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_fbt_count);
+		/* cas */
+		/* select_task_rq_fair() */
+		P_SCHEDSTAT(se.statistics.nr_wakeups_cas_attempts);
+		P_SCHEDSTAT(se.statistics.nr_wakeups_cas_count);
+ 
 #ifdef CONFIG_SCHED_WALT
 		P(ravg.demand);
 #endif
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 62a29ed..7b459ca 100755
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -89,6 +89,7 @@
 unsigned int sysctl_sched_sync_hint_enable = 1;
 unsigned int sysctl_sched_initial_task_util = 0;
 unsigned int sysctl_sched_cstate_aware = 1;
+DEFINE_PER_CPU_READ_MOSTLY(int, sched_load_boost);
 
 #ifdef CONFIG_SCHED_WALT
 unsigned int sysctl_sched_use_walt_cpu_util = 1;
@@ -160,7 +161,7 @@
 
 /*
  * The margin used when comparing utilization with CPU capacity:
- * util * 1024 < capacity * margin
+ * util * margin < capacity * 1024
  */
 unsigned int sysctl_sched_capacity_margin = 1078; /* ~5% margin */
 unsigned int sysctl_sched_capacity_margin_down = 1205; /* ~15% margin */
@@ -338,19 +339,59 @@
 static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
 {
 	if (!cfs_rq->on_list) {
+		struct rq *rq = rq_of(cfs_rq);
+		int cpu = cpu_of(rq);
 		/*
 		 * Ensure we either appear before our parent (if already
 		 * enqueued) or force our parent to appear after us when it is
-		 * enqueued.  The fact that we always enqueue bottom-up
-		 * reduces this to two cases.
+		 * enqueued. The fact that we always enqueue bottom-up
+		 * reduces this to two cases and a special case for the root
+		 * cfs_rq. Furthermore, it also means that we will always reset
+		 * tmp_alone_branch either when the branch is connected
+		 * to a tree or when we reach the beg of the tree
 		 */
 		if (cfs_rq->tg->parent &&
-		    cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]->on_list) {
-			list_add_rcu(&cfs_rq->leaf_cfs_rq_list,
-				&rq_of(cfs_rq)->leaf_cfs_rq_list);
-		} else {
+		    cfs_rq->tg->parent->cfs_rq[cpu]->on_list) {
+			/*
+			 * If parent is already on the list, we add the child
+			 * just before. Thanks to circular linked property of
+			 * the list, this means to put the child at the tail
+			 * of the list that starts by parent.
+			 */
 			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
-				&rq_of(cfs_rq)->leaf_cfs_rq_list);
+				&(cfs_rq->tg->parent->cfs_rq[cpu]->leaf_cfs_rq_list));
+			/*
+			 * The branch is now connected to its tree so we can
+			 * reset tmp_alone_branch to the beginning of the
+			 * list.
+			 */
+			rq->tmp_alone_branch = &rq->leaf_cfs_rq_list;
+		} else if (!cfs_rq->tg->parent) {
+			/*
+			 * cfs rq without parent should be put
+			 * at the tail of the list.
+			 */
+			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
+				&rq->leaf_cfs_rq_list);
+			/*
+			 * We have reach the beg of a tree so we can reset
+			 * tmp_alone_branch to the beginning of the list.
+			 */
+			rq->tmp_alone_branch = &rq->leaf_cfs_rq_list;
+		} else {
+			/*
+			 * The parent has not already been added so we want to
+			 * make sure that it will be put after us.
+			 * tmp_alone_branch points to the beg of the branch
+			 * where we will add parent.
+			 */
+			list_add_rcu(&cfs_rq->leaf_cfs_rq_list,
+				rq->tmp_alone_branch);
+			/*
+			 * update tmp_alone_branch to points to the new beg
+			 * of the branch
+			 */
+			rq->tmp_alone_branch = &cfs_rq->leaf_cfs_rq_list;
 		}
 
 		cfs_rq->on_list = 1;
@@ -759,9 +800,7 @@
 }
 
 static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq);
-static int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, bool update_freq);
-static void update_tg_load_avg(struct cfs_rq *cfs_rq, int force);
-static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se);
+static void attach_entity_cfs_rq(struct sched_entity *se);
 
 /*
  * With new tasks being created, their initial util_avgs are extrapolated
@@ -793,7 +832,6 @@
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
 	struct sched_avg *sa = &se->avg;
 	long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2;
-	u64 now = cfs_rq_clock_task(cfs_rq);
 
 	if (cap > 0) {
 		if (cfs_rq->avg.util_avg != 0) {
@@ -821,14 +859,12 @@
 			 * such that the next switched_to_fair() has the
 			 * expected state.
 			 */
-			se->avg.last_update_time = now;
+			se->avg.last_update_time = cfs_rq_clock_task(cfs_rq);
 			return;
 		}
 	}
 
-	update_cfs_rq_load_avg(now, cfs_rq, false);
-	attach_entity_load_avg(cfs_rq, se);
-	update_tg_load_avg(cfs_rq, false);
+	attach_entity_cfs_rq(se);
 }
 
 #else /* !CONFIG_SMP */
@@ -2697,16 +2733,20 @@
 
 static inline int throttled_hierarchy(struct cfs_rq *cfs_rq);
 
-static void update_cfs_shares(struct cfs_rq *cfs_rq)
+static void update_cfs_shares(struct sched_entity *se)
 {
+	struct cfs_rq *cfs_rq = group_cfs_rq(se);
 	struct task_group *tg;
-	struct sched_entity *se;
 	long shares;
 
-	tg = cfs_rq->tg;
-	se = tg->se[cpu_of(rq_of(cfs_rq))];
-	if (!se || throttled_hierarchy(cfs_rq))
+	if (!cfs_rq)
 		return;
+
+	if (throttled_hierarchy(cfs_rq))
+		return;
+
+	tg = cfs_rq->tg;
+
 #ifndef CONFIG_SMP
 	if (likely(se->load.weight == tg->shares))
 		return;
@@ -2715,8 +2755,9 @@
 
 	reweight_entity(cfs_rq_of(se), se, shares);
 }
+
 #else /* CONFIG_FAIR_GROUP_SCHED */
-static inline void update_cfs_shares(struct cfs_rq *cfs_rq)
+static inline void update_cfs_shares(struct sched_entity *se)
 {
 }
 #endif /* CONFIG_FAIR_GROUP_SCHED */
@@ -2962,6 +3003,26 @@
 	return decayed;
 }
 
+/*
+ * Signed add and clamp on underflow.
+ *
+ * Explicitly do a load-store to ensure the intermediate value never hits
+ * memory. This allows lockless observations without ever seeing the negative
+ * values.
+ */
+#define add_positive(_ptr, _val) do {                           \
+	typeof(_ptr) ptr = (_ptr);                              \
+	typeof(_val) val = (_val);                              \
+	typeof(*ptr) res, var = READ_ONCE(*ptr);                \
+								\
+	res = var + val;                                        \
+								\
+	if (val < 0 && res > var)                               \
+		res = 0;                                        \
+								\
+	WRITE_ONCE(*ptr, res);                                  \
+} while (0)
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
 /**
  * update_tg_load_avg - update the tg's load avg
@@ -3041,8 +3102,138 @@
 		se->avg.last_update_time = n_last_update_time;
 	}
 }
+
+/* Take into account change of utilization of a child task group */
+static inline void
+update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se)
+{
+	struct cfs_rq *gcfs_rq = group_cfs_rq(se);
+	long delta = gcfs_rq->avg.util_avg - se->avg.util_avg;
+
+	/* Nothing to update */
+	if (!delta)
+		return;
+
+	/* Set new sched_entity's utilization */
+	se->avg.util_avg = gcfs_rq->avg.util_avg;
+	se->avg.util_sum = se->avg.util_avg * LOAD_AVG_MAX;
+
+	/* Update parent cfs_rq utilization */
+	add_positive(&cfs_rq->avg.util_avg, delta);
+	cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * LOAD_AVG_MAX;
+}
+
+/* Take into account change of load of a child task group */
+static inline void
+update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se)
+{
+	struct cfs_rq *gcfs_rq = group_cfs_rq(se);
+	long delta, load = gcfs_rq->avg.load_avg;
+
+	/*
+	 * If the load of group cfs_rq is null, the load of the
+	 * sched_entity will also be null so we can skip the formula
+	 */
+	if (load) {
+		long tg_load;
+
+		/* Get tg's load and ensure tg_load > 0 */
+		tg_load = atomic_long_read(&gcfs_rq->tg->load_avg) + 1;
+
+		/* Ensure tg_load >= load and updated with current load*/
+		tg_load -= gcfs_rq->tg_load_avg_contrib;
+		tg_load += load;
+
+		/*
+		 * We need to compute a correction term in the case that the
+		 * task group is consuming more CPU than a task of equal
+		 * weight. A task with a weight equals to tg->shares will have
+		 * a load less or equal to scale_load_down(tg->shares).
+		 * Similarly, the sched_entities that represent the task group
+		 * at parent level, can't have a load higher than
+		 * scale_load_down(tg->shares). And the Sum of sched_entities'
+		 * load must be <= scale_load_down(tg->shares).
+		 */
+		if (tg_load > scale_load_down(gcfs_rq->tg->shares)) {
+			/* scale gcfs_rq's load into tg's shares*/
+			load *= scale_load_down(gcfs_rq->tg->shares);
+			load /= tg_load;
+		}
+	}
+
+	delta = load - se->avg.load_avg;
+
+	/* Nothing to update */
+	if (!delta)
+		return;
+
+	/* Set new sched_entity's load */
+	se->avg.load_avg = load;
+	se->avg.load_sum = se->avg.load_avg * LOAD_AVG_MAX;
+
+	/* Update parent cfs_rq load */
+	add_positive(&cfs_rq->avg.load_avg, delta);
+	cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * LOAD_AVG_MAX;
+
+	/*
+	 * If the sched_entity is already enqueued, we also have to update the
+	 * runnable load avg.
+	 */
+	if (se->on_rq) {
+		/* Update parent cfs_rq runnable_load_avg */
+		add_positive(&cfs_rq->runnable_load_avg, delta);
+		cfs_rq->runnable_load_sum = cfs_rq->runnable_load_avg * LOAD_AVG_MAX;
+	}
+}
+
+static inline void set_tg_cfs_propagate(struct cfs_rq *cfs_rq)
+{
+	cfs_rq->propagate_avg = 1;
+}
+
+static inline int test_and_clear_tg_cfs_propagate(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq = group_cfs_rq(se);
+
+	if (!cfs_rq->propagate_avg)
+		return 0;
+
+	cfs_rq->propagate_avg = 0;
+	return 1;
+}
+
+/* Update task and its cfs_rq load average */
+static inline int propagate_entity_load_avg(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq;
+
+	if (entity_is_task(se))
+		return 0;
+
+	if (!test_and_clear_tg_cfs_propagate(se))
+		return 0;
+
+	cfs_rq = cfs_rq_of(se);
+
+	set_tg_cfs_propagate(cfs_rq);
+
+	update_tg_cfs_util(cfs_rq, se);
+	update_tg_cfs_load(cfs_rq, se);
+
+	return 1;
+}
+
 #else /* CONFIG_FAIR_GROUP_SCHED */
+
 static inline void update_tg_load_avg(struct cfs_rq *cfs_rq, int force) {}
+
+static inline int propagate_entity_load_avg(struct sched_entity *se)
+{
+	return 0;
+}
+
+static inline void set_tg_cfs_propagate(struct cfs_rq *cfs_rq) {}
+
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
 static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
@@ -3113,6 +3304,7 @@
 		sub_positive(&sa->load_avg, r);
 		sub_positive(&sa->load_sum, r * LOAD_AVG_MAX);
 		removed_load = 1;
+		set_tg_cfs_propagate(cfs_rq);
 	}
 
 	if (atomic_long_read(&cfs_rq->removed_util_avg)) {
@@ -3120,6 +3312,7 @@
 		sub_positive(&sa->util_avg, r);
 		sub_positive(&sa->util_sum, r * LOAD_AVG_MAX);
 		removed_util = 1;
+		set_tg_cfs_propagate(cfs_rq);
 	}
 
 	decayed = __update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa,
@@ -3133,31 +3326,46 @@
 	if (update_freq && (decayed || removed_util))
 		cfs_rq_util_change(cfs_rq);
 
+	/* Trace CPU load, unless cfs_rq belongs to a non-root task_group */
+	if (cfs_rq == &rq_of(cfs_rq)->cfs)
+		trace_sched_load_avg_cpu(cpu_of(rq_of(cfs_rq)), cfs_rq);
+
 	return decayed || removed_load;
 }
 
+/*
+ * Optional action to be done while updating the load average
+ */
+#define UPDATE_TG	0x1
+#define SKIP_AGE_LOAD	0x2
+
 /* Update task and its cfs_rq load average */
-static inline void update_load_avg(struct sched_entity *se, int update_tg)
+static inline void update_load_avg(struct sched_entity *se, int flags)
 {
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
 	u64 now = cfs_rq_clock_task(cfs_rq);
 	struct rq *rq = rq_of(cfs_rq);
 	int cpu = cpu_of(rq);
+	int decayed;
 
 	/*
 	 * Track task load average for carrying it to new CPU after migrated, and
 	 * track group sched_entity load average for task_h_load calc in migration
 	 */
-	__update_load_avg(now, cpu, &se->avg,
+	if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) {
+		__update_load_avg(now, cpu, &se->avg,
 			  se->on_rq * scale_load_down(se->load.weight),
 			  cfs_rq->curr == se, NULL);
+	}
 
-	if (update_cfs_rq_load_avg(now, cfs_rq, true) && update_tg)
+	decayed  = update_cfs_rq_load_avg(now, cfs_rq, true);
+	decayed |= propagate_entity_load_avg(se);
+
+	if (decayed && (flags & UPDATE_TG))
 		update_tg_load_avg(cfs_rq, 0);
 
 	if (entity_is_task(se))
 		trace_sched_load_avg_task(task_of(se), &se->avg);
-	trace_sched_load_avg_cpu(cpu, cfs_rq);
 }
 
 /**
@@ -3170,31 +3378,12 @@
  */
 static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	if (!sched_feat(ATTACH_AGE_LOAD))
-		goto skip_aging;
-
-	/*
-	 * If we got migrated (either between CPUs or between cgroups) we'll
-	 * have aged the average right before clearing @last_update_time.
-	 *
-	 * Or we're fresh through post_init_entity_util_avg().
-	 */
-	if (se->avg.last_update_time) {
-		__update_load_avg(cfs_rq->avg.last_update_time, cpu_of(rq_of(cfs_rq)),
-				  &se->avg, 0, 0, NULL);
-
-		/*
-		 * XXX: we could have just aged the entire load away if we've been
-		 * absent from the fair class for too long.
-		 */
-	}
-
-skip_aging:
 	se->avg.last_update_time = cfs_rq->avg.last_update_time;
 	cfs_rq->avg.load_avg += se->avg.load_avg;
 	cfs_rq->avg.load_sum += se->avg.load_sum;
 	cfs_rq->avg.util_avg += se->avg.util_avg;
 	cfs_rq->avg.util_sum += se->avg.util_sum;
+	set_tg_cfs_propagate(cfs_rq);
 
 	cfs_rq_util_change(cfs_rq);
 }
@@ -3209,14 +3398,12 @@
  */
 static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	__update_load_avg(cfs_rq->avg.last_update_time, cpu_of(rq_of(cfs_rq)),
-			  &se->avg, se->on_rq * scale_load_down(se->load.weight),
-			  cfs_rq->curr == se, NULL);
 
 	sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg);
 	sub_positive(&cfs_rq->avg.load_sum, se->avg.load_sum);
 	sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg);
 	sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum);
+	set_tg_cfs_propagate(cfs_rq);
 
 	cfs_rq_util_change(cfs_rq);
 }
@@ -3226,34 +3413,20 @@
 enqueue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
 	struct sched_avg *sa = &se->avg;
-	u64 now = cfs_rq_clock_task(cfs_rq);
-	int migrated, decayed;
-
-	migrated = !sa->last_update_time;
-	if (!migrated) {
-		__update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa,
-			se->on_rq * scale_load_down(se->load.weight),
-			cfs_rq->curr == se, NULL);
-	}
-
-	decayed = update_cfs_rq_load_avg(now, cfs_rq, !migrated);
 
 	cfs_rq->runnable_load_avg += sa->load_avg;
 	cfs_rq->runnable_load_sum += sa->load_sum;
 
-	if (migrated)
+	if (!sa->last_update_time) {
 		attach_entity_load_avg(cfs_rq, se);
-
-	if (decayed || migrated)
 		update_tg_load_avg(cfs_rq, 0);
+	}
 }
 
 /* Remove the runnable load generated by se from cfs_rq's runnable load average */
 static inline void
 dequeue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	update_load_avg(se, 1);
-
 	cfs_rq->runnable_load_avg =
 		max_t(long, cfs_rq->runnable_load_avg - se->avg.load_avg, 0);
 	cfs_rq->runnable_load_sum =
@@ -3282,13 +3455,25 @@
 #endif
 
 /*
+ * Synchronize entity load avg of dequeued entity without locking
+ * the previous rq.
+ */
+void sync_entity_load_avg(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq = cfs_rq_of(se);
+	u64 last_update_time;
+
+	last_update_time = cfs_rq_last_update_time(cfs_rq);
+	__update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL);
+}
+
+/*
  * Task first catches up with cfs_rq, and then subtract
  * itself from the cfs_rq (task must be off the queue now).
  */
 void remove_entity_load_avg(struct sched_entity *se)
 {
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
-	u64 last_update_time;
 
 	/*
 	 * tasks cannot exit without having gone through wake_up_new_task() ->
@@ -3300,9 +3485,7 @@
 	 * calls this.
 	 */
 
-	last_update_time = cfs_rq_last_update_time(cfs_rq);
-
-	__update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL);
+	sync_entity_load_avg(se);
 	atomic_long_add(se->avg.load_avg, &cfs_rq->removed_load_avg);
 	atomic_long_add(se->avg.util_avg, &cfs_rq->removed_util_avg);
 }
@@ -3327,7 +3510,10 @@
 	return 0;
 }
 
-static inline void update_load_avg(struct sched_entity *se, int not_used)
+#define UPDATE_TG	0x0
+#define SKIP_AGE_LOAD	0x0
+
+static inline void update_load_avg(struct sched_entity *se, int not_used1)
 {
 	cpufreq_update_util(rq_of(cfs_rq_of(se)), 0);
 }
@@ -3472,9 +3658,18 @@
 	if (renorm && !curr)
 		se->vruntime += cfs_rq->min_vruntime;
 
+	/*
+	 * When enqueuing a sched_entity, we must:
+	 *   - Update loads to have both entity and cfs_rq synced with now.
+	 *   - Add its load to cfs_rq->runnable_avg
+	 *   - For group_entity, update its weight to reflect the new share of
+	 *     its group cfs_rq
+	 *   - Add its new weight to cfs_rq->load.weight
+	 */
+	update_load_avg(se, UPDATE_TG);
 	enqueue_entity_load_avg(cfs_rq, se);
+	update_cfs_shares(se);
 	account_entity_enqueue(cfs_rq, se);
-	update_cfs_shares(cfs_rq);
 
 	if (flags & ENQUEUE_WAKEUP)
 		place_entity(cfs_rq, se, 0);
@@ -3546,6 +3741,16 @@
 	 * Update run-time statistics of the 'current'.
 	 */
 	update_curr(cfs_rq);
+
+	/*
+	 * When dequeuing a sched_entity, we must:
+	 *   - Update loads to have both entity and cfs_rq synced with now.
+	 *   - Substract its load from the cfs_rq->runnable_avg.
+	 *   - Substract its previous weight from cfs_rq->load.weight.
+	 *   - For group entity, update its weight to reflect the new share
+	 *     of its group cfs_rq.
+	 */
+	update_load_avg(se, UPDATE_TG);
 	dequeue_entity_load_avg(cfs_rq, se);
 
 	update_stats_dequeue(cfs_rq, se, flags);
@@ -3569,7 +3774,7 @@
 	/* return excess runtime on last dequeue */
 	return_cfs_rq_runtime(cfs_rq);
 
-	update_cfs_shares(cfs_rq);
+	update_cfs_shares(se);
 
 	/*
 	 * Now advance min_vruntime if @se was the entity holding it back,
@@ -3633,7 +3838,7 @@
 		 */
 		update_stats_wait_end(cfs_rq, se);
 		__dequeue_entity(cfs_rq, se);
-		update_load_avg(se, 1);
+		update_load_avg(se, UPDATE_TG);
 	}
 
 	update_stats_curr_start(cfs_rq, se);
@@ -3751,8 +3956,8 @@
 	/*
 	 * Ensure that runnable average is periodically updated.
 	 */
-	update_load_avg(curr, 1);
-	update_cfs_shares(cfs_rq);
+	update_load_avg(curr, UPDATE_TG);
+	update_cfs_shares(curr);
 
 #ifdef CONFIG_SCHED_HRTICK
 	/*
@@ -4614,9 +4819,9 @@
 #ifdef CONFIG_SMP
 static unsigned long capacity_orig_of(int cpu);
 static unsigned long cpu_util(int cpu);
-static inline unsigned long boosted_cpu_util(int cpu);
+unsigned long boosted_cpu_util(int cpu);
 #else
-#define boosted_cpu_util(cpu) cpu_util(cpu)
+#define boosted_cpu_util(cpu) cpu_util_freq(cpu)
 #endif
 
 #ifdef CONFIG_SMP
@@ -4688,8 +4893,8 @@
 		if (cfs_rq_throttled(cfs_rq))
 			break;
 
-		update_load_avg(se, 1);
-		update_cfs_shares(cfs_rq);
+		update_load_avg(se, UPDATE_TG);
+		update_cfs_shares(se);
 	}
 
 	if (!se) {
@@ -4699,6 +4904,25 @@
 
 #ifdef CONFIG_SMP
 
+	/*
+	 * Update SchedTune accounting.
+	 *
+	 * We do it before updating the CPU capacity to ensure the
+	 * boost value of the current task is accounted for in the
+	 * selection of the OPP.
+	 *
+	 * We do it also in the case where we enqueue a throttled task;
+	 * we could argue that a throttled task should not boost a CPU,
+	 * however:
+	 * a) properly implementing CPU boosting considering throttled
+	 *    tasks will increase a lot the complexity of the solution
+	 * b) it's not easy to quantify the benefits introduced by
+	 *    such a more complex solution.
+	 * Thus, for the time being we go for the simple solution and boost
+	 * also for throttled RQs.
+	 */
+	schedtune_enqueue_task(p, cpu_of(rq));
+
 	if (!se) {
 		if (!task_new && !rq->rd->overutilized &&
 		    cpu_overutilized(rq->cpu)) {
@@ -4717,9 +4941,6 @@
 			update_capacity_of(cpu_of(rq));
 	}
 
-	/* Update SchedTune accouting */
-	schedtune_enqueue_task(p, cpu_of(rq));
-
 #endif /* CONFIG_SMP */
 	hrtick_update(rq);
 }
@@ -4775,8 +4996,8 @@
 		if (cfs_rq_throttled(cfs_rq))
 			break;
 
-		update_load_avg(se, 1);
-		update_cfs_shares(cfs_rq);
+		update_load_avg(se, UPDATE_TG);
+		update_cfs_shares(se);
 	}
 
 	if (!se) {
@@ -4786,6 +5007,15 @@
 
 #ifdef CONFIG_SMP
 
+	/*
+	 * Update SchedTune accounting
+	 *
+	 * We do it before updating the CPU capacity to ensure the
+	 * boost value of the current task is accounted for in the
+	 * selection of the OPP.
+	 */
+	schedtune_dequeue_task(p, cpu_of(rq));
+
 	if (!se) {
 		if (rq->cfs.nr_running)
 			update_capacity_of(cpu_of(rq));
@@ -4793,9 +5023,6 @@
 			set_cfs_cpu_capacity(cpu_of(rq), false, 0);
 	}
 
-	/* Update SchedTune accouting */
-	schedtune_dequeue_task(p, cpu_of(rq));
-
 #endif /* CONFIG_SMP */
 
 	hrtick_update(rq);
@@ -4807,6 +5034,19 @@
 DEFINE_PER_CPU(cpumask_var_t, load_balance_mask);
 DEFINE_PER_CPU(cpumask_var_t, select_idle_mask);
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+static int rotate_cpu_start;
+static DEFINE_SPINLOCK(rotate_lock);
+static unsigned long avoid_prev_cpu_last;
+
+static struct find_first_cpu_bit_env first_cpu_bit_env = {
+	.avoid_prev_cpu_last = &avoid_prev_cpu_last,
+	.rotate_cpu_start = &rotate_cpu_start,
+	.interval = HZ,
+	.rotate_lock = &rotate_lock,
+};
+#endif
+
 #ifdef CONFIG_NO_HZ_COMMON
 /*
  * per rq 'load' arrray crap; XXX kill this.
@@ -5431,10 +5671,10 @@
 
 	for (idx = 0; idx < sge->nr_cap_states; idx++) {
 		if (sge->cap_states[idx].cap >= util)
-			break;
+			return idx;
 	}
 
-	return idx;
+	return (sge->nr_cap_states - 1);
 }
 
 static int find_new_capacity(struct energy_env *eenv,
@@ -5449,9 +5689,11 @@
 	return idx;
 }
 
-static int group_idle_state(struct sched_group *sg)
+static int group_idle_state(struct energy_env *eenv, struct sched_group *sg)
 {
 	int i, state = INT_MAX;
+	int src_in_grp, dst_in_grp;
+	long grp_util = 0;
 
 	/* Find the shallowest idle state in the sched group. */
 	for_each_cpu(i, sched_group_cpus(sg))
@@ -5463,6 +5705,54 @@
 	/* Take non-cpuidle idling into account (active idle/arch_cpu_idle()) */
 	state++;
 
+	/*
+	 * Try to estimate if a deeper idle state is
+	 * achievable when we move the task.
+	 */
+	for_each_cpu(i, sched_group_cpus(sg))
+		grp_util += cpu_util(i);
+
+	src_in_grp = cpumask_test_cpu(eenv->src_cpu, sched_group_cpus(sg));
+	dst_in_grp = cpumask_test_cpu(eenv->dst_cpu, sched_group_cpus(sg));
+	if (src_in_grp == dst_in_grp) {
+		/* both CPUs under consideration are in the same group or not in
+		 * either group, migration should leave idle state the same.
+		 */
+		goto end;
+	}
+	/* add or remove util as appropriate to indicate what group util
+	 * will be (worst case - no concurrent execution) after moving the task
+	 */
+	grp_util += src_in_grp ? -eenv->util_delta : eenv->util_delta;
+
+	if (grp_util <=
+		((long)sg->sgc->max_capacity * (int)sg->group_weight)) {
+		/* after moving, this group is at most partly
+		 * occupied, so it should have some idle time.
+		 */
+		int max_idle_state_idx = sg->sge->nr_idle_states - 2;
+		int new_state = grp_util * max_idle_state_idx;
+		if (grp_util <= 0)
+			/* group will have no util, use lowest state */
+			new_state = max_idle_state_idx + 1;
+		else {
+			/* for partially idle, linearly map util to idle
+			 * states, excluding the lowest one. This does not
+			 * correspond to the state we expect to enter in
+			 * reality, but an indication of what might happen.
+			 */
+			new_state = min(max_idle_state_idx, (int)
+					(new_state / sg->sgc->max_capacity));
+			new_state = max_idle_state_idx - new_state;
+		}
+		state = new_state;
+	} else {
+		/* After moving, the group will be fully occupied
+		 * so assume it will not be idle at all.
+		 */
+		state = 0;
+	}
+end:
 	return state;
 }
 
@@ -5499,15 +5789,7 @@
 		 */
 		sd = rcu_dereference(per_cpu(sd_scs, cpu));
 
-		if (!sd)
-			/*
-			 * We most probably raced with hotplug; returning a
-			 * wrong energy estimation is better than entering an
-			 * infinite loop.
-			 */
-			return -EINVAL;
-
-		if (sd->parent)
+		if (sd && sd->parent)
 			sg_shared_cap = sd->parent->groups;
 
 		for_each_domain(cpu, sd) {
@@ -5544,7 +5826,7 @@
 					}
 				}
 
-				idle_idx = group_idle_state(sg);
+				idle_idx = group_idle_state(eenv, sg);
 				if (unlikely(idle_idx < 0))
 					return idle_idx;
 
@@ -5577,6 +5859,14 @@
 
 			} while (sg = sg->next, sg != sd->groups);
 		}
+
+		/*
+		 * If we raced with hotplug and got an sd NULL-pointer;
+		 * returning a wrong energy estimation is better than
+		 * entering an infinite loop.
+		 */
+		if (cpumask_test_cpu(cpu, &visit_cpus))
+			return -EINVAL;
 next_cpu:
 		cpumask_clear_cpu(cpu, &visit_cpus);
 		continue;
@@ -5603,6 +5893,7 @@
 	struct sched_domain *sd;
 	struct sched_group *sg;
 	int sd_cpu = -1, energy_before = 0, energy_after = 0;
+	int diff, margin;
 
 	struct energy_env eenv_before = {
 		.util_delta	= 0,
@@ -5647,12 +5938,22 @@
 	eenv->nrg.after = energy_after;
 	eenv->nrg.diff = eenv->nrg.after - eenv->nrg.before;
 	eenv->payoff = 0;
-
+#ifndef CONFIG_SCHED_TUNE
 	trace_sched_energy_diff(eenv->task,
 			eenv->src_cpu, eenv->dst_cpu, eenv->util_delta,
 			eenv->nrg.before, eenv->nrg.after, eenv->nrg.diff,
 			eenv->cap.before, eenv->cap.after, eenv->cap.delta,
 			eenv->nrg.delta, eenv->payoff);
+#endif
+	/*
+	 * Dead-zone margin preventing too many migrations.
+	 */
+
+	margin = eenv->nrg.before >> 6; /* ~1.56% */
+
+	diff = eenv->nrg.after - eenv->nrg.before;
+
+	eenv->nrg.diff = (abs(diff) < margin) ? 0 : eenv->nrg.diff;
 
 	return eenv->nrg.diff;
 }
@@ -5660,23 +5961,30 @@
 #ifdef CONFIG_SCHED_TUNE
 
 struct target_nrg schedtune_target_nrg;
-
+extern bool schedtune_initialized;
 /*
  * System energy normalization
- * Returns the normalized value, in the range [0..SCHED_LOAD_SCALE],
+ * Returns the normalized value, in the range [0..SCHED_CAPACITY_SCALE],
  * corresponding to the specified energy variation.
  */
 static inline int
 normalize_energy(int energy_diff)
 {
 	u32 normalized_nrg;
+
+	/* during early setup, we don't know the extents */
+	if (unlikely(!schedtune_initialized))
+		return energy_diff < 0 ? -1 : 1 ;
+
 #ifdef CONFIG_SCHED_DEBUG
+	{
 	int max_delta;
 
 	/* Check for boundaries */
 	max_delta  = schedtune_target_nrg.max_power;
 	max_delta -= schedtune_target_nrg.min_power;
 	WARN_ON(abs(energy_diff) >= max_delta);
+	}
 #endif
 
 	/* Do scaling using positive numbers to increase the range */
@@ -5695,18 +6003,13 @@
 static inline int
 energy_diff(struct energy_env *eenv)
 {
-	unsigned int boost;
+	int boost = schedtune_task_boost(eenv->task);
 	int nrg_delta;
 
 	/* Conpute "absolute" energy diff */
 	__energy_diff(eenv);
 
 	/* Return energy diff when boost margin is 0 */
-#ifdef CONFIG_CGROUP_SCHEDTUNE
-	boost = schedtune_task_boost(eenv->task);
-#else
-	boost = get_sysctl_sched_cfs_boost();
-#endif
 	if (boost == 0)
 		return eenv->nrg.diff;
 
@@ -5719,6 +6022,12 @@
 			eenv->cap.delta,
 			eenv->task);
 
+	trace_sched_energy_diff(eenv->task,
+			eenv->src_cpu, eenv->dst_cpu, eenv->util_delta,
+			eenv->nrg.before, eenv->nrg.after, eenv->nrg.diff,
+			eenv->cap.before, eenv->cap.after, eenv->cap.delta,
+			eenv->nrg.delta, eenv->payoff);
+
 	/*
 	 * When SchedTune is enabled, the energy_diff() function will return
 	 * the computed energy payoff value. Since the energy_diff() return
@@ -5865,19 +6174,21 @@
 	return __task_fits(p, cpu, cpu_util(cpu));
 }
 
-static bool __cpu_overutilized(int cpu, int delta)
+bool __cpu_overutilized(int cpu, unsigned long util)
 {
-	return (capacity_orig_of(cpu) * 1024) <
-	       ((cpu_util(cpu) + delta) * sysctl_sched_capacity_margin);
+	return (capacity_orig_of(cpu) * 1024 <
+		util * sysctl_sched_capacity_margin);
 }
 
 bool cpu_overutilized(int cpu)
 {
-	return __cpu_overutilized(cpu, 0);
+	return __cpu_overutilized(cpu, cpu_util(cpu));
 }
 
 #ifdef CONFIG_SCHED_TUNE
 
+struct reciprocal_value schedtune_spc_rdiv;
+
 static long
 schedtune_margin(unsigned long signal, long boost)
 {
@@ -5888,30 +6199,16 @@
 	 *
 	 * The Boost (B) value is used to compute a Margin (M) which is
 	 * proportional to the complement of the original Signal (S):
-	 *   M = B * (SCHED_LOAD_SCALE - S), if B is positive
-	 *   M = B * S, if B is negative
+	 *   M = B * (SCHED_CAPACITY_SCALE - S)
 	 * The obtained M could be used by the caller to "boost" S.
 	 */
-
 	if (boost >= 0) {
 		margin  = SCHED_CAPACITY_SCALE - signal;
 		margin *= boost;
 	} else
 		margin = -signal * boost;
-	/*
-	 * Fast integer division by constant:
-	 *  Constant   :                 (C) = 100
-	 *  Precision  : 0.1%            (P) = 0.1
-	 *  Reference  : C * 100 / P     (R) = 100000
-	 *
-	 * Thus:
-	 *  Shift bits : ceil(log(R,2))  (S) = 17
-	 *  Mult const : round(2^S/C)    (M) = 1311
-	 *
-	 *
-	 */
-	margin  *= 1311;
-	margin >>= 17;
+
+	margin  = reciprocal_divide(margin, schedtune_spc_rdiv);
 
 	if (boost < 0)
 		margin *= -1;
@@ -5921,13 +6218,8 @@
 static inline int
 schedtune_cpu_margin(unsigned long util, int cpu)
 {
-	int boost;
+	int boost = schedtune_cpu_boost(cpu);
 
-#ifdef CONFIG_CGROUP_SCHEDTUNE
-	boost = schedtune_cpu_boost(cpu);
-#else
-	boost = get_sysctl_sched_cfs_boost();
-#endif
 	if (boost == 0)
 		return 0;
 
@@ -5937,15 +6229,10 @@
 static inline long
 schedtune_task_margin(struct task_struct *task)
 {
-	int boost;
+	int boost = schedtune_task_boost(task);
 	unsigned long util;
 	long margin;
 
-#ifdef CONFIG_CGROUP_SCHEDTUNE
-	boost = schedtune_task_boost(task);
-#else
-	boost = get_sysctl_sched_cfs_boost();
-#endif
 	if (boost == 0)
 		return 0;
 
@@ -5971,7 +6258,7 @@
 
 #endif /* CONFIG_SCHED_TUNE */
 
-static inline unsigned long
+unsigned long
 boosted_cpu_util(int cpu)
 {
 	unsigned long util = cpu_util_freq(cpu, NULL);
@@ -6317,20 +6604,29 @@
 	struct sched_domain *sd;
 	struct sched_group *sg;
 	int i = task_cpu(p);
-	int best_idle = -1;
-	int best_idle_cstate = -1;
-	int best_idle_capacity = INT_MAX;
+	int best_idle_cpu = -1;
+	int best_idle_cstate = INT_MAX;
+	unsigned long best_idle_capacity = ULONG_MAX;
+
+	schedstat_inc(p->se.statistics.nr_wakeups_sis_attempts);
+	schedstat_inc(this_rq()->eas_stats.sis_attempts);
 
 	if (!sysctl_sched_cstate_aware) {
-		if (idle_cpu(target) && !cpu_isolated(target))
+		if (idle_cpu(target) && !cpu_isolated(target)) {
+			schedstat_inc(p->se.statistics.nr_wakeups_sis_idle);
+			schedstat_inc(this_rq()->eas_stats.sis_idle);
 			return target;
+		}
 
 		/*
 		 * If the prevous cpu is cache affine and idle, don't be stupid.
 		 */
 		if (i != target && cpus_share_cache(i, target) &&
-				idle_cpu(i) && !cpu_isolated(i))
+				idle_cpu(i) && !cpu_isolated(i)) {
+			schedstat_inc(p->se.statistics.nr_wakeups_sis_cache_affine);
+			schedstat_inc(this_rq()->eas_stats.sis_cache_affine);
 			return i;
+		}
 
 		sd = rcu_dereference(per_cpu(sd_llc, target));
 		if (!sd)
@@ -6363,8 +6659,7 @@
 
 			if (sysctl_sched_cstate_aware) {
 				for_each_cpu_and(i, tsk_cpus_allowed(p), sched_group_cpus(sg)) {
-					struct rq *rq = cpu_rq(i);
-					int idle_idx = idle_get_state_idx(rq);
+					int idle_idx = idle_get_state_idx(cpu_rq(i));
 					unsigned long new_usage = boosted_task_util(p);
 					unsigned long capacity_orig = capacity_orig_of(i);
 
@@ -6374,11 +6669,16 @@
 					if (new_usage > capacity_orig || !idle_cpu(i))
 						goto next;
 
-					if (i == target && new_usage <= capacity_curr_of(target))
+					if (i == target && new_usage <= capacity_curr_of(target)) {
+						schedstat_inc(p->se.statistics.nr_wakeups_sis_suff_cap);
+						schedstat_inc(this_rq()->eas_stats.sis_suff_cap);
+						schedstat_inc(sd->eas_stats.sis_suff_cap);
 						return target;
+					}
 
-					if (best_idle < 0 || (idle_idx < best_idle_cstate && capacity_orig <= best_idle_capacity)) {
-						best_idle = i;
+					if (idle_idx < best_idle_cstate &&
+					    capacity_orig <= best_idle_capacity) {
+						best_idle_cpu = i;
 						best_idle_cstate = idle_idx;
 						best_idle_capacity = capacity_orig;
 					}
@@ -6394,19 +6694,26 @@
 
 				target = cpumask_first_and(sched_group_cpus(sg),
 					tsk_cpus_allowed(p));
+				schedstat_inc(p->se.statistics.nr_wakeups_sis_idle_cpu);
+				schedstat_inc(this_rq()->eas_stats.sis_idle_cpu);
+				schedstat_inc(sd->eas_stats.sis_idle_cpu);
 				goto done;
 			}
 next:
 			sg = sg->next;
 		} while (sg != sd->groups);
 	}
-	if (best_idle > 0)
-		target = best_idle;
+
+	if (best_idle_cpu >= 0)
+		target = best_idle_cpu;
 
 done:
+	schedstat_inc(p->se.statistics.nr_wakeups_sis_count);
+	schedstat_inc(this_rq()->eas_stats.sis_count);
+
 	return target;
 }
-
+ 
 static inline int find_best_target(struct task_struct *p, bool boosted, bool prefer_idle)
 {
 	int iter_cpu;
@@ -6589,7 +6896,7 @@
 	int target_cpu, targeted_cpus = 0;
 	unsigned long task_util_boosted = 0, curr_util = 0;
 	long new_util, new_util_cum;
-	int i;
+	int i = -1;
 	int ediff = -1;
 	int cpu = smp_processor_id();
 	int min_util_cpu = -1;
@@ -6608,8 +6915,17 @@
 	enum sched_boost_policy placement_boost = task_sched_boost(p) ?
 				sched_boost_policy() : SCHED_BOOST_NONE;
 	struct related_thread_group *grp;
+	cpumask_t search_cpus;
+	int prev_cpu = task_cpu(p);
+#ifdef CONFIG_SCHED_CORE_ROTATE
+	bool do_rotate = false;
+	bool avoid_prev_cpu = false;
+#else
+#define do_rotate false
+#define avoid_prev_cpu false
+#endif
 
-	sd = rcu_dereference(per_cpu(sd_ea, task_cpu(p)));
+	sd = rcu_dereference(per_cpu(sd_ea, prev_cpu));
 
 	if (!sd)
 		return target;
@@ -6628,7 +6944,7 @@
 		rtg_target = &grp->preferred_cluster->cpus;
 
 	if (sync && bias_to_waker_cpu(p, cpu, rtg_target)) {
-		trace_sched_task_util_bias_to_waker(p, task_cpu(p),
+		trace_sched_task_util_bias_to_waker(p, prev_cpu,
 					task_util(p), cpu, cpu, 0, need_idle);
 		return cpu;
 	}
@@ -6691,18 +7007,34 @@
 
 		target_cpu = -1;
 
+		cpumask_copy(&search_cpus, tsk_cpus_allowed(p));
+		cpumask_and(&search_cpus, &search_cpus,
+			    sched_group_cpus(sg_target));
+
+#ifdef CONFIG_SCHED_CORE_ROTATE
+		i = find_first_cpu_bit(p, &search_cpus, sg_target,
+				       &avoid_prev_cpu, &do_rotate,
+				       &first_cpu_bit_env);
+
+retry:
+#endif
 		/* Find cpu with sufficient capacity */
-		for_each_cpu_and(i, tsk_cpus_allowed(p), sched_group_cpus(sg_target)) {
+		while ((i = cpumask_next(i, &search_cpus)) < nr_cpu_ids) {
+			cpumask_clear_cpu(i, &search_cpus);
+
 			if (cpu_isolated(i))
 				continue;
 
 			if (isolated_candidate == -1)
 				isolated_candidate = i;
 
+			if (avoid_prev_cpu && i == prev_cpu)
+				continue;
+
 			if (is_reserved(i))
 				continue;
 
-			if (sched_cpu_high_irqload(cpu))
+			if (sched_cpu_high_irqload(i))
 				continue;
 
 			/*
@@ -6750,7 +7082,7 @@
 			cpu_idle_idx = idle_get_state_idx(cpu_rq(i));
 
 			if (!need_idle &&
-			    add_capacity_margin(new_util_cum) <
+			    add_capacity_margin(new_util_cum, i) <
 			    capacity_curr_of(i)) {
 				if (sysctl_sched_cstate_aware) {
 					if (cpu_idle_idx < min_idle_idx) {
@@ -6767,9 +7099,9 @@
 						    new_util ||
 						    (target_cpu_util ==
 						     new_util &&
-						     (i == task_cpu(p) ||
+						     (i == prev_cpu ||
 						      (target_cpu !=
-						       task_cpu(p) &&
+						       prev_cpu &&
 						       target_cpu_new_util_cum >
 						       new_util_cum))))) {
 						min_idle_idx_cpu = i;
@@ -6781,6 +7113,9 @@
 					}
 				} else if (cpu_rq(i)->nr_running) {
 					target_cpu = i;
+#ifdef CONFIG_SCHED_CORE_ROTATE
+					do_rotate = false;
+#endif
 					break;
 				}
 			} else if (!need_idle) {
@@ -6820,6 +7155,19 @@
 			}
 		}
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+		if (do_rotate) {
+			/*
+			 * We started iteration somewhere in the middle of
+			 * cpumask.  Iterate once again from bit 0 to the
+			 * previous starting point bit.
+			 */
+			do_rotate = false;
+			i = -1;
+			goto retry;
+		}
+#endif
+
 		if (target_cpu == -1 ||
 		    (target_cpu != min_util_cpu && !safe_to_pack &&
 		     !is_packing_eligible(p, task_util_boosted, sg_target,
@@ -6854,7 +7202,8 @@
 		}
 	}
 
-	if (target_cpu != task_cpu(p) && !cpu_isolated(task_cpu(p))) {
+	if (target_cpu != task_cpu(p) && !avoid_prev_cpu &&
+	    !cpu_isolated(task_cpu(p))) {
 		struct energy_env eenv = {
 			.util_delta	= task_util(p),
 			.src_cpu	= task_cpu(p),
@@ -6894,7 +7243,9 @@
 		task_util_boosted = 0;
 #endif
 		/* Not enough spare capacity on previous cpu */
-		if (__cpu_overutilized(task_cpu(p), task_util_boosted)) {
+		if (__cpu_overutilized(task_cpu(p),
+				       cpu_util(task_cpu(p)) +
+						task_util_boosted)) {
 			trace_sched_task_util_overutilzed(p, task_cpu(p),
 						task_util(p), target_cpu,
 						target_cpu, 0, need_idle);
@@ -8046,6 +8397,10 @@
 
 		if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true))
 			update_tg_load_avg(cfs_rq, 0);
+
+		/* Propagate pending load changes to the parent */
+		if (cfs_rq->tg->se[cpu])
+			update_load_avg(cfs_rq->tg->se[cpu], 0);
 	}
 	raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
@@ -8270,7 +8625,6 @@
 	raw_spin_unlock_irqrestore(&mcc->lock, flags);
 
 skip_unlock: __attribute__ ((unused));
-	sdg->sgc->max_capacity = capacity;
 
 	capacity *= scale_rt_capacity(cpu);
 	capacity >>= SCHED_CAPACITY_SHIFT;
@@ -8280,13 +8634,15 @@
 
 	cpu_rq(cpu)->cpu_capacity = capacity;
 	sdg->sgc->capacity = capacity;
+	sdg->sgc->max_capacity = capacity;
+	sdg->sgc->min_capacity = capacity;
 }
 
 void update_group_capacity(struct sched_domain *sd, int cpu)
 {
 	struct sched_domain *child = sd->child;
 	struct sched_group *group, *sdg = sd->groups;
-	unsigned long capacity, max_capacity;
+	unsigned long capacity, max_capacity, min_capacity;
 	unsigned long interval;
 
 	interval = msecs_to_jiffies(sd->balance_interval);
@@ -8300,6 +8656,7 @@
 
 	capacity = 0;
 	max_capacity = 0;
+	min_capacity = ULONG_MAX;
 
 	if (child->flags & SD_OVERLAP) {
 		/*
@@ -8332,6 +8689,7 @@
 			}
 
 			max_capacity = max(capacity, max_capacity);
+			min_capacity = min(capacity, min_capacity);
 		}
 	} else  {
 		/*
@@ -8348,6 +8706,7 @@
 			if (!cpu_isolated(cpumask_first(cpus))) {
 				capacity += sgc->capacity;
 				max_capacity = max(sgc->max_capacity, max_capacity);
+				min_capacity = min(sgc->min_capacity, min_capacity);
 			}
 			group = group->next;
 		} while (group != child->groups);
@@ -8355,6 +8714,7 @@
 
 	sdg->sgc->capacity = capacity;
 	sdg->sgc->max_capacity = max_capacity;
+	sdg->sgc->min_capacity = min_capacity;
 }
 
 /*
@@ -8598,6 +8958,16 @@
 	if (sgs->avg_load <= busiest->avg_load)
 		return false;
 
+	if (!(env->sd->flags & SD_ASYM_CPUCAPACITY))
+		goto asym_packing;
+
+	/*
+	 * Candidate sg has no more than one task per CPU and
+	 * has higher per-CPU capacity. Migrating tasks to less
+	 * capable CPUs may harm throughput. Maximize throughput,
+	 * power/energy consequences are not considered.
+	 */
+
 	/*
 	 * Candiate sg has no more than one task per cpu and has higher
 	 * per-cpu capacity. No reason to pull tasks to less capable cpus.
@@ -8606,6 +8976,7 @@
 	    group_smaller_cpu_capacity(sds->local, sg))
 		return false;
 
+asym_packing:
 	/* This is the busiest node in its class. */
 	if (!(env->sd->flags & SD_ASYM_PACKING))
 		return true;
@@ -8660,6 +9031,9 @@
 }
 #endif /* CONFIG_NUMA_BALANCING */
 
+#define lb_sd_parent(sd) \
+	(sd->parent && sd->parent->groups != sd->parent->groups->next)
+
 /**
  * update_sd_lb_stats - Update sched_domain's statistics for load balancing.
  * @env: The load balancing environment.
@@ -8744,7 +9118,7 @@
 
 	env->src_grp_nr_running = sds->busiest_stat.sum_nr_running;
 
-	if (!env->sd->parent) {
+	if (!lb_sd_parent(env->sd)) {
 		/* update overload indicator if we are at root domain */
 		if (env->dst_rq->rd->overload != overload)
 			env->dst_rq->rd->overload = overload;
@@ -10246,8 +10620,13 @@
 	if (time_before(now, nohz.next_balance))
 		return false;
 
+	if (rq->nr_running >= 2 &&
+	    (!energy_aware() || cpu_overutilized(cpu)))
+		return true;
+
+	/* Do idle load balance if there have misfit task */
 	if (energy_aware())
-		return rq->nr_running >= 2 && cpu_overutilized(cpu);
+		return rq->misfit_task;
 
 	rcu_read_lock();
 	sds = rcu_dereference(per_cpu(sd_llc_shared, cpu));
@@ -10475,11 +10854,65 @@
 	return false;
 }
 
+#ifdef CONFIG_FAIR_GROUP_SCHED
+/*
+ * Propagate the changes of the sched_entity across the tg tree to make it
+ * visible to the root
+ */
+static void propagate_entity_cfs_rq(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq;
+
+	/* Start to propagate at parent */
+	se = se->parent;
+
+	for_each_sched_entity(se) {
+		cfs_rq = cfs_rq_of(se);
+
+		if (cfs_rq_throttled(cfs_rq))
+			break;
+
+		update_load_avg(se, UPDATE_TG);
+	}
+}
+#else
+static void propagate_entity_cfs_rq(struct sched_entity *se) { }
+#endif
+
+static void detach_entity_cfs_rq(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq = cfs_rq_of(se);
+
+	/* Catch up with the cfs_rq and remove our load when we leave */
+	update_load_avg(se, 0);
+	detach_entity_load_avg(cfs_rq, se);
+	update_tg_load_avg(cfs_rq, false);
+	propagate_entity_cfs_rq(se);
+}
+
+static void attach_entity_cfs_rq(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq = cfs_rq_of(se);
+
+#ifdef CONFIG_FAIR_GROUP_SCHED
+	/*
+	 * Since the real-depth could have been changed (only FAIR
+	 * class maintain depth value), reset depth properly.
+	 */
+	se->depth = se->parent ? se->parent->depth + 1 : 0;
+#endif
+
+	/* Synchronize entity with its cfs_rq */
+	update_load_avg(se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD);
+	attach_entity_load_avg(cfs_rq, se);
+	update_tg_load_avg(cfs_rq, false);
+	propagate_entity_cfs_rq(se);
+}
+
 static void detach_task_cfs_rq(struct task_struct *p)
 {
 	struct sched_entity *se = &p->se;
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
-	u64 now = cfs_rq_clock_task(cfs_rq);
 
 	if (!vruntime_normalized(p)) {
 		/*
@@ -10490,30 +10923,15 @@
 		se->vruntime -= cfs_rq->min_vruntime;
 	}
 
-	/* Catch up with the cfs_rq and remove our load when we leave */
-	update_cfs_rq_load_avg(now, cfs_rq, false);
-	detach_entity_load_avg(cfs_rq, se);
-	update_tg_load_avg(cfs_rq, false);
+	detach_entity_cfs_rq(se);
 }
 
 static void attach_task_cfs_rq(struct task_struct *p)
 {
 	struct sched_entity *se = &p->se;
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
-	u64 now = cfs_rq_clock_task(cfs_rq);
 
-#ifdef CONFIG_FAIR_GROUP_SCHED
-	/*
-	 * Since the real-depth could have been changed (only FAIR
-	 * class maintain depth value), reset depth properly.
-	 */
-	se->depth = se->parent ? se->parent->depth + 1 : 0;
-#endif
-
-	/* Synchronize task with its cfs_rq */
-	update_cfs_rq_load_avg(now, cfs_rq, false);
-	attach_entity_load_avg(cfs_rq, se);
-	update_tg_load_avg(cfs_rq, false);
+	attach_entity_cfs_rq(se);
 
 	if (!vruntime_normalized(p))
 		se->vruntime += cfs_rq->min_vruntime;
@@ -10567,6 +10985,9 @@
 	cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
 #endif
 #ifdef CONFIG_SMP
+#ifdef CONFIG_FAIR_GROUP_SCHED
+	cfs_rq->propagate_avg = 0;
+#endif
 	atomic_long_set(&cfs_rq->removed_load_avg, 0);
 	atomic_long_set(&cfs_rq->removed_util_avg, 0);
 #endif
@@ -10767,8 +11188,10 @@
 
 		/* Possible calls to update_curr() need rq clock */
 		update_rq_clock(rq);
-		for_each_sched_entity(se)
-			update_cfs_shares(group_cfs_rq(se));
+		for_each_sched_entity(se) {
+			update_load_avg(se, UPDATE_TG);
+			update_cfs_shares(se);
+		}
 		raw_spin_unlock_irqrestore(&rq->lock, flags);
 	}
 
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 6b935e7..7feba85 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1711,6 +1711,19 @@
 	return NULL;
 }
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+static int rotate_cpu_start;
+static DEFINE_SPINLOCK(rotate_lock);
+static unsigned long avoid_prev_cpu_last;
+
+static struct find_first_cpu_bit_env first_cpu_bit_env = {
+	.avoid_prev_cpu_last = &avoid_prev_cpu_last,
+	.rotate_cpu_start = &rotate_cpu_start,
+	.interval = HZ,
+	.rotate_lock = &rotate_lock,
+};
+#endif
+
 static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask);
 
 static int find_lowest_rq(struct task_struct *task)
@@ -1719,17 +1732,24 @@
 	struct sched_group *sg, *sg_target;
 	struct cpumask *lowest_mask = this_cpu_cpumask_var_ptr(local_cpu_mask);
 	int this_cpu = smp_processor_id();
-	int cpu, best_cpu;
+	int cpu = -1, best_cpu;
 	struct cpumask search_cpu, backup_search_cpu;
 	unsigned long cpu_capacity;
 	unsigned long best_capacity;
 	unsigned long util, best_cpu_util = ULONG_MAX;
+	unsigned long best_cpu_util_cum = ULONG_MAX;
+	unsigned long util_cum;
+	unsigned long tutil = task_util(task);
 	int best_cpu_idle_idx = INT_MAX;
 	int cpu_idle_idx = -1;
-	long new_util_cum;
-	int max_spare_cap_cpu = -1;
-	long max_spare_cap = -LONG_MAX;
 	bool placement_boost;
+#ifdef CONFIG_SCHED_CORE_ROTATE
+	bool do_rotate = false;
+	bool avoid_prev_cpu = false;
+#else
+#define do_rotate false
+#define avoid_prev_cpu false
+#endif
 
 	/* Make sure the mask is initialized first */
 	if (unlikely(!lowest_mask))
@@ -1761,6 +1781,10 @@
 
 		sg = sd->groups;
 		do {
+			if (!cpumask_intersects(lowest_mask,
+						sched_group_cpus(sg)))
+				continue;
+
 			cpu = group_first_cpu(sg);
 			cpu_capacity = capacity_orig_of(cpu);
 
@@ -1778,68 +1802,98 @@
 		} while (sg = sg->next, sg != sd->groups);
 		rcu_read_unlock();
 
-		cpumask_and(&search_cpu, lowest_mask,
-			    sched_group_cpus(sg_target));
-		cpumask_copy(&backup_search_cpu, lowest_mask);
-		cpumask_andnot(&backup_search_cpu, &backup_search_cpu,
-			       &search_cpu);
+		if (sg_target) {
+			cpumask_and(&search_cpu, lowest_mask,
+				    sched_group_cpus(sg_target));
+			cpumask_copy(&backup_search_cpu, lowest_mask);
+			cpumask_andnot(&backup_search_cpu, &backup_search_cpu,
+				       &search_cpu);
+
+#ifdef CONFIG_SCHED_CORE_ROTATE
+			cpu = find_first_cpu_bit(task, &search_cpu, sg_target,
+						 &avoid_prev_cpu, &do_rotate,
+						 &first_cpu_bit_env);
+#endif
+		} else {
+			cpumask_copy(&search_cpu, lowest_mask);
+			cpumask_clear(&backup_search_cpu);
+			cpu = -1;
+		}
 
 retry:
-		for_each_cpu(cpu, &search_cpu) {
+		while ((cpu = cpumask_next(cpu, &search_cpu)) < nr_cpu_ids) {
+			cpumask_clear_cpu(cpu, &search_cpu);
+
 			/*
 			 * Don't use capcity_curr_of() since it will
 			 * double count rt task load.
 			 */
 			util = cpu_util(cpu);
-			if (!cpu_overutilized(cpu)) {
-				if (cpu_isolated(cpu))
+
+			if (avoid_prev_cpu && cpu == task_cpu(task))
+				continue;
+
+			if (__cpu_overutilized(cpu, util + tutil))
+				continue;
+
+			if (cpu_isolated(cpu))
+				continue;
+
+			if (sched_cpu_high_irqload(cpu))
+				continue;
+
+			/* Find the least loaded CPU */
+			if (util > best_cpu_util)
+				continue;
+
+			/*
+			 * If the previous CPU has same load, keep it as
+			 * best_cpu.
+			 */
+			if (best_cpu_util == util && best_cpu == task_cpu(task))
+				continue;
+
+			/*
+			 * If candidate CPU is the previous CPU, select it.
+			 * Otherwise, if its load is same with best_cpu and in
+			 * a shallower C-state, select it.  If all above
+			 * conditions are same, select the least cumulative
+			 * window demand CPU.
+			 */
+			if (sysctl_sched_cstate_aware)
+				cpu_idle_idx = idle_get_state_idx(cpu_rq(cpu));
+
+			util_cum = cpu_util_cum(cpu, 0);
+			if (cpu != task_cpu(task) && best_cpu_util == util) {
+				if (best_cpu_idle_idx < cpu_idle_idx)
 					continue;
 
-				if (sched_cpu_high_irqload(cpu))
+				if (best_cpu_idle_idx == cpu_idle_idx &&
+				    best_cpu_util_cum < util_cum)
 					continue;
-
-				new_util_cum = cpu_util_cum(cpu, 0);
-
-				if (!task_in_cum_window_demand(cpu_rq(cpu),
-							       task))
-					new_util_cum += task_util(task);
-
-				trace_sched_cpu_util(task, cpu, task_util(task),
-						     0, new_util_cum, 0);
-
-				if (sysctl_sched_cstate_aware)
-					cpu_idle_idx =
-					     idle_get_state_idx(cpu_rq(cpu));
-
-				if (add_capacity_margin(new_util_cum) <
-				    capacity_curr_of(cpu)) {
-					if (cpu_idle_idx < best_cpu_idle_idx ||
-					    (best_cpu != task_cpu(task) &&
-					     (best_cpu_idle_idx ==
-					      cpu_idle_idx &&
-					      best_cpu_util > util))) {
-						best_cpu_util = util;
-						best_cpu = cpu;
-						best_cpu_idle_idx =
-						    cpu_idle_idx;
-					}
-				} else {
-					long spare_cap = capacity_of(cpu) -
-							 util;
-
-					if (spare_cap > 0 &&
-					    max_spare_cap < spare_cap) {
-						max_spare_cap_cpu = cpu;
-						max_spare_cap = spare_cap;
-					}
-				}
 			}
+
+			best_cpu_idle_idx = cpu_idle_idx;
+			best_cpu_util_cum = util_cum;
+			best_cpu_util = util;
+			best_cpu = cpu;
 		}
 
+#ifdef CONFIG_SCHED_CORE_ROTATE
+		if (do_rotate) {
+			/*
+			 * We started iteration somewhere in the middle of
+			 * cpumask.  Iterate once again from bit 0 to the
+			 * previous starting point bit.
+			 */
+			do_rotate = false;
+			cpu = -1;
+			goto retry;
+		}
+#endif
+
 		if (best_cpu != -1) {
 			return best_cpu;
-		} else if (max_spare_cap_cpu != -1) {
-			return max_spare_cap_cpu;
 		} else if (!cpumask_empty(&backup_search_cpu)) {
 			cpumask_copy(&search_cpu, &backup_search_cpu);
 			cpumask_clear(&backup_search_cpu);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 3df55ac..7ac731d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -29,6 +29,7 @@
 
 #ifdef CONFIG_SCHED_WALT
 extern unsigned int sched_ravg_window;
+extern unsigned int walt_cpu_util_freq_divisor;
 
 struct walt_sched_stats {
 	int nr_big_tasks;
@@ -477,6 +478,7 @@
 	unsigned long runnable_load_avg;
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	unsigned long tg_load_avg_contrib;
+	unsigned long propagate_avg;
 #endif
 	atomic_long_t removed_load_avg, removed_util_avg;
 #ifndef CONFIG_64BIT
@@ -662,6 +664,9 @@
 
 	/* Maximum cpu capacity in the system. */
 	struct max_cpu_capacity max_cpu_capacity;
+
+	/* First cpu with maximum and minimum original capacity */
+	int max_cap_orig_cpu, min_cap_orig_cpu;
 };
 
 extern struct root_domain def_root_domain;
@@ -720,6 +725,7 @@
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	/* list of leaf cfs_rq on this cpu: */
 	struct list_head leaf_cfs_rq_list;
+	struct list_head *tmp_alone_branch;
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
 	/*
@@ -842,6 +848,9 @@
 	/* try_to_wake_up() stats */
 	unsigned int ttwu_count;
 	unsigned int ttwu_local;
+#ifdef CONFIG_SMP
+	struct eas_stats eas_stats;
+#endif
 #endif
 
 #ifdef CONFIG_SMP
@@ -1012,6 +1021,7 @@
 	 */
 	unsigned long capacity;
 	unsigned long max_capacity; /* Max per-cpu capacity in group */
+	unsigned long min_capacity; /* Min per-CPU capacity in group */
 	unsigned long next_update;
 	int imbalance; /* XXX unrelated to capacity but shared group state */
 
@@ -1447,6 +1457,7 @@
 
 extern void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask);
 
+bool __cpu_overutilized(int cpu, unsigned long util);
 bool cpu_overutilized(int cpu);
 
 #endif
@@ -1796,47 +1807,87 @@
 #endif
 
 static inline unsigned long
-cpu_util_freq(int cpu, struct sched_walt_cpu_load *walt_load)
+cpu_util_freq_pelt(int cpu)
 {
 	struct rq *rq = cpu_rq(cpu);
-	u64 util = rq->cfs.avg.util_avg;
+	unsigned long util = rq->cfs.avg.util_avg;
 	unsigned long capacity = capacity_orig_of(cpu);
 
-#ifdef CONFIG_SCHED_WALT
-	if (!walt_disabled && sysctl_sched_use_walt_cpu_util) {
+	util *= (100 + per_cpu(sched_load_boost, cpu));
+	do_div(util, 100);
 
-		util = freq_policy_load(rq);
-		util = div64_u64(util,
-				 sched_ravg_window >> SCHED_CAPACITY_SHIFT);
-
-		if (walt_load) {
-			u64 nl = cpu_rq(cpu)->nt_prev_runnable_sum +
-				rq->grp_time.nt_prev_runnable_sum;
-			u64 pl = rq->walt_stats.pred_demands_sum;
-
-			nl = div64_u64(nl, sched_ravg_window >>
-						SCHED_CAPACITY_SHIFT);
-			pl = div64_u64(pl, sched_ravg_window >>
-						SCHED_CAPACITY_SHIFT);
-
-			walt_load->prev_window_util = util;
-			walt_load->nl = nl;
-			walt_load->pl = pl;
-			rq->old_busy_time = util;
-			rq->old_estimated_time = pl;
-			walt_load->ws = rq->window_start;
-		}
-	}
-#endif
 	return (util >= capacity) ? capacity : util;
 }
+
+#ifdef CONFIG_SCHED_WALT
+static inline unsigned long
+cpu_util_freq_walt(int cpu, struct sched_walt_cpu_load *walt_load)
+{
+	u64 util, util_unboosted;
+	struct rq *rq = cpu_rq(cpu);
+	unsigned long capacity = capacity_orig_of(cpu);
+	int boost;
+
+	if (walt_disabled || !sysctl_sched_use_walt_cpu_util)
+		return cpu_util_freq_pelt(cpu);
+
+	boost = per_cpu(sched_load_boost, cpu);
+	util_unboosted = util = freq_policy_load(rq);
+	util = div64_u64(util * (100 + boost),
+			 walt_cpu_util_freq_divisor);
+
+	if (walt_load) {
+		u64 nl = cpu_rq(cpu)->nt_prev_runnable_sum +
+			rq->grp_time.nt_prev_runnable_sum;
+		u64 pl = rq->walt_stats.pred_demands_sum;
+
+		/* do_pl_notif() needs unboosted signals */
+		rq->old_busy_time = div64_u64(util_unboosted,
+					      sched_ravg_window >>
+					      SCHED_CAPACITY_SHIFT);
+		rq->old_estimated_time = div64_u64(pl, sched_ravg_window >>
+						       SCHED_CAPACITY_SHIFT);
+
+		nl = div64_u64(nl * (100 + boost),
+			       walt_cpu_util_freq_divisor);
+		pl = div64_u64(pl * (100 + boost),
+			       walt_cpu_util_freq_divisor);
+
+		walt_load->prev_window_util = util;
+		walt_load->nl = nl;
+		walt_load->pl = pl;
+		walt_load->ws = rq->window_start;
+	}
+
+	return (util >= capacity) ? capacity : util;
+}
+
+static inline unsigned long
+cpu_util_freq(int cpu, struct sched_walt_cpu_load *walt_load)
+{
+	return cpu_util_freq_walt(cpu, walt_load);
+}
+
+#else
+
+static inline unsigned long
+cpu_util_freq(int cpu, struct sched_walt_cpu_load *walt_load)
+{
+	return cpu_util_freq_pelt(cpu);
+}
+
+#endif /* CONFIG_SCHED_WALT */
+
 #endif
 
 extern unsigned int capacity_margin_freq;
 
-static inline unsigned long add_capacity_margin(unsigned long cpu_capacity)
+static inline unsigned long
+add_capacity_margin(unsigned long cpu_capacity, int cpu)
 {
-	cpu_capacity  = cpu_capacity * capacity_margin_freq;
+	cpu_capacity  = cpu_capacity * capacity_margin_freq *
+			(100 + per_cpu(sched_load_boost, cpu));
+	cpu_capacity /= 100;
 	cpu_capacity /= SCHED_CAPACITY_SCALE;
 	return cpu_capacity;
 }
@@ -2241,7 +2292,7 @@
 
 #ifdef CONFIG_SCHED_WALT
 	unsigned int exception_flags = SCHED_CPUFREQ_INTERCLUSTER_MIG |
-						SCHED_CPUFREQ_PL;
+				SCHED_CPUFREQ_PL | SCHED_CPUFREQ_EARLY_DET;
 
 	/*
 	 * Skip if we've already reported, but not if this is an inter-cluster
@@ -2790,3 +2841,17 @@
 {
 	return sched_feat(ENERGY_AWARE);
 }
+
+#ifdef CONFIG_SCHED_CORE_ROTATE
+struct find_first_cpu_bit_env {
+	unsigned long *avoid_prev_cpu_last;
+	int *rotate_cpu_start;
+	int interval;
+	spinlock_t *rotate_lock;
+};
+
+int
+find_first_cpu_bit(struct task_struct *p, const cpumask_t *search_cpus,
+		   struct sched_group *sg_target, bool *avoid_prev_cpu,
+		   bool *do_rotate, struct find_first_cpu_bit_env *env);
+#endif
diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c
index 87e2c9f..6d74a7c 100644
--- a/kernel/sched/stats.c
+++ b/kernel/sched/stats.c
@@ -12,6 +12,28 @@
  */
 #define SCHEDSTAT_VERSION 15
 
+#ifdef CONFIG_SMP
+static inline void show_easstat(struct seq_file *seq, struct eas_stats *stats)
+{
+	/* eas-specific runqueue stats */
+	seq_printf(seq, "eas %llu %llu %llu %llu %llu %llu ",
+	    stats->sis_attempts, stats->sis_idle, stats->sis_cache_affine,
+	    stats->sis_suff_cap, stats->sis_idle_cpu, stats->sis_count);
+
+	seq_printf(seq, "%llu %llu %llu %llu %llu %llu %llu ",
+	    stats->secb_attempts, stats->secb_sync, stats->secb_idle_bt,
+	    stats->secb_insuff_cap, stats->secb_no_nrg_sav,
+	    stats->secb_nrg_sav, stats->secb_count);
+
+	seq_printf(seq, "%llu %llu %llu %llu %llu ",
+	    stats->fbt_attempts, stats->fbt_no_cpu, stats->fbt_no_sd,
+	    stats->fbt_pref_idle, stats->fbt_count);
+
+	seq_printf(seq, "%llu %llu\n",
+	    stats->cas_attempts, stats->cas_count);
+}
+#endif
+
 static int show_schedstat(struct seq_file *seq, void *v)
 {
 	int cpu;
@@ -40,6 +62,8 @@
 		seq_printf(seq, "\n");
 
 #ifdef CONFIG_SMP
+		show_easstat(seq, &rq->eas_stats);
+
 		/* domain-specific stats */
 		rcu_read_lock();
 		for_each_domain(cpu, sd) {
@@ -66,6 +90,8 @@
 			    sd->sbf_count, sd->sbf_balanced, sd->sbf_pushed,
 			    sd->ttwu_wake_remote, sd->ttwu_move_affine,
 			    sd->ttwu_move_balance);
+
+			show_easstat(seq, &sd->eas_stats);
 		}
 		rcu_read_unlock();
 #endif
diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c
index 86a167b..93643ba 100644
--- a/kernel/sched/tune.c
+++ b/kernel/sched/tune.c
@@ -14,11 +14,12 @@
 unsigned int sysctl_sched_cfs_boost __read_mostly;
 
 #ifdef CONFIG_CGROUP_SCHEDTUNE
-static bool schedtune_initialized = false;
-#endif /* CONFIG_CGROUP_SCHEDTUNE */
+bool schedtune_initialized = false;
+#endif
 
 unsigned int sysctl_sched_cfs_boost __read_mostly;
 
+extern struct reciprocal_value schedtune_spc_rdiv;
 extern struct target_nrg schedtune_target_nrg;
 
 /* Performance Boost region (B) threshold params */
@@ -680,6 +681,9 @@
 	struct schedtune *st;
 	int task_boost;
 
+	if (!unlikely(schedtune_initialized))
+		return 0;
+
 	/* Get task boost value */
 	rcu_read_lock();
 	st = task_schedtune(p);
@@ -694,6 +698,9 @@
 	struct schedtune *st;
 	int prefer_idle;
 
+	if (!unlikely(schedtune_initialized))
+		return 0;
+
 	/* Get prefer_idle value */
 	rcu_read_lock();
 	st = task_schedtune(p);
@@ -1126,9 +1133,12 @@
 	pr_info("schedtune: configured to support global boosting only\n");
 #endif /* CONFIG_CGROUP_SCHEDTUNE */
 
+	schedtune_spc_rdiv = reciprocal_value(100);
+
 	return 0;
 
 nodata:
+	pr_warning("schedtune: disabled!\n");
 	rcu_read_unlock();
 	return -EINVAL;
 }
diff --git a/kernel/sched/walt.c b/kernel/sched/walt.c
index cbc75c0..316c276 100644
--- a/kernel/sched/walt.c
+++ b/kernel/sched/walt.c
@@ -69,6 +69,20 @@
 	local_irq_restore(*flags);
 }
 
+#ifdef CONFIG_HZ_300
+/*
+ * Tick interval becomes to 3333333 due to
+ * rounding error when HZ=300.
+ */
+#define MIN_SCHED_RAVG_WINDOW (3333333 * 6)
+#else
+/* Min window size (in ns) = 20ms */
+#define MIN_SCHED_RAVG_WINDOW 20000000
+#endif
+
+/* Max window size (in ns) = 1s */
+#define MAX_SCHED_RAVG_WINDOW 1000000000
+
 /* 1 -> use PELT based load stats, 0 -> use window-based load stats */
 unsigned int __read_mostly walt_disabled = 0;
 
@@ -95,6 +109,12 @@
 /* Window size (in ns) */
 __read_mostly unsigned int sched_ravg_window = MIN_SCHED_RAVG_WINDOW;
 
+/*
+ * A after-boot constant divisor for cpu_util_freq_walt() to apply the load
+ * boost.
+ */
+__read_mostly unsigned int walt_cpu_util_freq_divisor;
+
 /* Initial task load. Newly created tasks are assigned this load. */
 unsigned int __read_mostly sched_init_task_load_windows;
 unsigned int __read_mostly sysctl_sched_init_task_load_pct = 15;
@@ -132,7 +152,6 @@
  */
 __read_mostly unsigned int sched_load_granule =
 			MIN_SCHED_RAVG_WINDOW / NUM_LOAD_INDICES;
-
 /* Size of bitmaps maintained to track top tasks */
 static const unsigned int top_tasks_bitmap_size =
 		BITS_TO_LONGS(NUM_LOAD_INDICES + 1) * sizeof(unsigned long);
@@ -3094,4 +3113,7 @@
 		clear_top_tasks_bitmap(rq->top_tasks_bitmap[j]);
 	}
 	rq->cum_window_demand = 0;
+
+	walt_cpu_util_freq_divisor =
+	    (sched_ravg_window >> SCHED_CAPACITY_SHIFT) * 100;
 }
diff --git a/kernel/sched/walt.h b/kernel/sched/walt.h
index 535f14b..86d5bfd 100644
--- a/kernel/sched/walt.h
+++ b/kernel/sched/walt.h
@@ -24,12 +24,6 @@
 #define WINDOW_STATS_AVG		3
 #define WINDOW_STATS_INVALID_POLICY	4
 
-/* Min window size (in ns) = 20ms */
-#define MIN_SCHED_RAVG_WINDOW 20000000
-
-/* Max window size (in ns) = 1s */
-#define MAX_SCHED_RAVG_WINDOW 1000000000
-
 #define EXITING_TASK_MARKER	0xdeaddead
 
 #define FREQ_REPORT_MAX_CPU_LOAD_TOP_TASK	0
diff --git a/kernel/signal.c b/kernel/signal.c
index deb04d5..e48668c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -346,7 +346,7 @@
 	 * fresh group stop.  Read comment in do_signal_stop() for details.
 	 */
 	if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) {
-		sig->flags = SIGNAL_STOP_STOPPED;
+		signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED);
 		return true;
 	}
 	return false;
@@ -845,7 +845,7 @@
 			 * will take ->siglock, notice SIGNAL_CLD_MASK, and
 			 * notify its parent. See get_signal_to_deliver().
 			 */
-			signal->flags = why | SIGNAL_STOP_CONTINUED;
+			signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED);
 			signal->group_stop_count = 0;
 			signal->group_exit_code = 0;
 		}
diff --git a/kernel/smp.c b/kernel/smp.c
index ee80cc8..313d9a8 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -15,6 +15,7 @@
 #include <linux/cpu.h>
 #include <linux/sched.h>
 #include <linux/hypervisor.h>
+#include <linux/suspend.h>
 
 #include "smpboot.h"
 
@@ -751,7 +752,8 @@
 	for_each_online_cpu(cpu) {
 		if (cpu == smp_processor_id())
 			continue;
-		if (!cpu_isolated(cpu))
+		if (suspend_freeze_state == FREEZE_STATE_ENTER ||
+		    !cpu_isolated(cpu))
 			wake_up_if_idle(cpu);
 	}
 	preempt_enable();
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 1d894fc..2c4cd17 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -335,8 +335,8 @@
 		.extra2		= &max_sched_granularity_ns,
 	},
 	{
-		.procname	= "sched_is_big_little",
-		.data		= &sysctl_sched_is_big_little,
+		.procname	= "sched_sync_hint_enable",
+		.data		= &sysctl_sched_sync_hint_enable,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
@@ -367,13 +367,6 @@
 	},
 #endif
 	{
-		.procname	= "sched_sync_hint_enable",
-		.data		= &sysctl_sched_sync_hint_enable,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
 		.procname	= "sched_initial_task_util",
 		.data		= &sysctl_sched_initial_task_util,
 		.maxlen		= sizeof(unsigned int),
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 44cc350..df3191e 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1020,6 +1020,18 @@
 	return ts->sleep_length;
 }
 
+/**
+ * tick_nohz_get_idle_calls - return the current idle calls counter value
+ *
+ * Called from the schedutil frequency scaling governor in scheduler context.
+ */
+unsigned long tick_nohz_get_idle_calls(void)
+{
+	struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
+
+	return ts->idle_calls;
+}
+
 static void tick_nohz_account_idle_ticks(struct tick_sched *ts)
 {
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 3a2dd86..80aa30d 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -201,6 +201,7 @@
 	bool			migration_enabled;
 	bool			nohz_active;
 	bool			is_idle;
+	bool			must_forward_clk;
 	DECLARE_BITMAP(pending_map, WHEEL_SIZE);
 	struct hlist_head	vectors[WHEEL_SIZE];
 } ____cacheline_aligned;
@@ -472,17 +473,26 @@
  */
 static inline unsigned calc_index(unsigned expires, unsigned lvl)
 {
-	expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
+	if (expires & ~(UINT_MAX << LVL_SHIFT(lvl)))
+		expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
+	else
+		expires = expires >> LVL_SHIFT(lvl);
+
 	return LVL_OFFS(lvl) + (expires & LVL_MASK);
 }
 
+static inline unsigned int calc_index_min_granularity(unsigned int  expires)
+{
+	return LVL_OFFS(0) + ((expires >> LVL_SHIFT(0)) & LVL_MASK);
+}
+
 static int calc_wheel_index(unsigned long expires, unsigned long clk)
 {
 	unsigned long delta = expires - clk;
 	unsigned int idx;
 
 	if (delta < LVL_START(1)) {
-		idx = calc_index(expires, 0);
+		idx = calc_index_min_granularity(expires);
 	} else if (delta < LVL_START(2)) {
 		idx = calc_index(expires, 1);
 	} else if (delta < LVL_START(3)) {
@@ -865,13 +875,19 @@
 
 static inline void forward_timer_base(struct timer_base *base)
 {
-	unsigned long jnow = READ_ONCE(jiffies);
+	unsigned long jnow;
 
 	/*
-	 * We only forward the base when it's idle and we have a delta between
-	 * base clock and jiffies.
+	 * We only forward the base when we are idle or have just come out of
+	 * idle (must_forward_clk logic), and have a delta between base clock
+	 * and jiffies. In the common case, run_timers will take care of it.
 	 */
-	if (!base->is_idle || (long) (jnow - base->clk) < 2)
+	if (likely(!base->must_forward_clk))
+		return;
+
+	jnow = READ_ONCE(jiffies);
+	base->must_forward_clk = base->is_idle;
+	if ((long)(jnow - base->clk) < 2)
 		return;
 
 	/*
@@ -947,6 +963,11 @@
 	 * same array bucket then just return:
 	 */
 	if (timer_pending(timer)) {
+		/*
+		 * The downside of this optimization is that it can result in
+		 * larger granularity than you would get from adding a new
+		 * timer with this expiry.
+		 */
 		if (timer->expires == expires)
 			return 1;
 
@@ -957,6 +978,7 @@
 		 * dequeue/enqueue dance.
 		 */
 		base = lock_timer_base(timer, &flags);
+		forward_timer_base(base);
 
 		clk = base->clk;
 		idx = calc_wheel_index(expires, clk);
@@ -973,6 +995,7 @@
 		}
 	} else {
 		base = lock_timer_base(timer, &flags);
+		forward_timer_base(base);
 	}
 
 	ret = detach_if_pending(timer, base, false);
@@ -1000,12 +1023,10 @@
 			spin_lock(&base->lock);
 			WRITE_ONCE(timer->flags,
 				   (timer->flags & ~TIMER_BASEMASK) | base->cpu);
+			forward_timer_base(base);
 		}
 	}
 
-	/* Try to forward a stale timer base clock */
-	forward_timer_base(base);
-
 	timer->expires = expires;
 	/*
 	 * If 'idx' was calculated above and the base time did not advance
@@ -1121,6 +1142,7 @@
 		WRITE_ONCE(timer->flags,
 			   (timer->flags & ~TIMER_BASEMASK) | cpu);
 	}
+	forward_timer_base(base);
 
 	debug_activate(timer, timer->expires);
 	internal_add_timer(base, timer);
@@ -1351,17 +1373,22 @@
  * (@offset) up to @offset + clk.
  */
 static int next_pending_bucket(struct timer_base *base, unsigned offset,
-			       unsigned clk)
+			       unsigned int clk, int lvl)
 {
-	unsigned pos, start = offset + clk;
+	unsigned int pos_up = -1, pos_down, start = offset + clk;
 	unsigned end = offset + LVL_SIZE;
+	unsigned int pos;
 
 	pos = find_next_bit(base->pending_map, end, start);
 	if (pos < end)
-		return pos - start;
+		pos_up = pos - start;
 
 	pos = find_next_bit(base->pending_map, start, offset);
-	return pos < start ? pos + LVL_SIZE - start : -1;
+	pos_down = pos < start ? pos + LVL_SIZE - start : -1;
+	if (((pos_up + base->clk) << LVL_SHIFT(lvl)) >
+		((pos_down + base->clk) << LVL_SHIFT(lvl)))
+		return pos_down;
+	return pos_up;
 }
 
 /*
@@ -1376,7 +1403,8 @@
 	next = base->clk + NEXT_TIMER_MAX_DELTA;
 	clk = base->clk;
 	for (lvl = 0; lvl < LVL_DEPTH; lvl++, offset += LVL_SIZE) {
-		int pos = next_pending_bucket(base, offset, clk & LVL_MASK);
+		int pos = next_pending_bucket(base, offset, clk & LVL_MASK,
+			  lvl);
 
 		if (pos >= 0) {
 			unsigned long tmp = clk + (unsigned long) pos;
@@ -1529,12 +1557,18 @@
 		base->is_idle = false;
 	} else {
 		if (!is_max_delta)
-			expires = basem + (nextevt - basej) * TICK_NSEC;
+			expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
 		/*
-		 * If we expect to sleep more than a tick, mark the base idle:
+		 * If we expect to sleep more than a tick, mark the base idle.
+		 * Also the tick is stopped so any added timer must forward
+		 * the base clk itself to keep granularity small. This idle
+		 * logic is only maintained for the BASE_STD base, deferrable
+		 * timers may still see large granularity skew (by design).
 		 */
-		if ((expires - basem) > TICK_NSEC)
+		if ((expires - basem) > TICK_NSEC) {
+			base->must_forward_clk = true;
 			base->is_idle = true;
+		}
 	}
 	spin_unlock(&base->lock);
 
@@ -1644,6 +1678,19 @@
 {
 	struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
 
+	/*
+	 * must_forward_clk must be cleared before running timers so that any
+	 * timer functions that call mod_timer will not try to forward the
+	 * base. idle trcking / clock forwarding logic is only used with
+	 * BASE_STD timers.
+	 *
+	 * The deferrable base does not do idle tracking at all, so we do
+	 * not forward it. This can result in very large variations in
+	 * granularity for deferrable timers, but they can be deferred for
+	 * long periods due to idle.
+	 */
+	base->must_forward_clk = false;
+
 	__run_timers(base);
 	if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && base->nohz_active)
 		__run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 5dcb992..41805fb 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -203,10 +203,36 @@
 		fmt_cnt++;
 	}
 
-	return __trace_printk(1/* fake ip will not be printed */, fmt,
-			      mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1,
-			      mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2,
-			      mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3);
+/* Horrid workaround for getting va_list handling working with different
+ * argument type combinations generically for 32 and 64 bit archs.
+ */
+#define __BPF_TP_EMIT()	__BPF_ARG3_TP()
+#define __BPF_TP(...)							\
+	__trace_printk(1 /* Fake ip will not be printed. */,		\
+		       fmt, ##__VA_ARGS__)
+
+#define __BPF_ARG1_TP(...)						\
+	((mod[0] == 2 || (mod[0] == 1 && __BITS_PER_LONG == 64))	\
+	  ? __BPF_TP(arg1, ##__VA_ARGS__)				\
+	  : ((mod[0] == 1 || (mod[0] == 0 && __BITS_PER_LONG == 32))	\
+	      ? __BPF_TP((long)arg1, ##__VA_ARGS__)			\
+	      : __BPF_TP((u32)arg1, ##__VA_ARGS__)))
+
+#define __BPF_ARG2_TP(...)						\
+	((mod[1] == 2 || (mod[1] == 1 && __BITS_PER_LONG == 64))	\
+	  ? __BPF_ARG1_TP(arg2, ##__VA_ARGS__)				\
+	  : ((mod[1] == 1 || (mod[1] == 0 && __BITS_PER_LONG == 32))	\
+	      ? __BPF_ARG1_TP((long)arg2, ##__VA_ARGS__)		\
+	      : __BPF_ARG1_TP((u32)arg2, ##__VA_ARGS__)))
+
+#define __BPF_ARG3_TP(...)						\
+	((mod[2] == 2 || (mod[2] == 1 && __BITS_PER_LONG == 64))	\
+	  ? __BPF_ARG2_TP(arg3, ##__VA_ARGS__)				\
+	  : ((mod[2] == 1 || (mod[2] == 0 && __BITS_PER_LONG == 32))	\
+	      ? __BPF_ARG2_TP((long)arg3, ##__VA_ARGS__)		\
+	      : __BPF_ARG2_TP((u32)arg3, ##__VA_ARGS__)))
+
+	return __BPF_TP_EMIT();
 }
 
 static const struct bpf_func_proto bpf_trace_printk_proto = {
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4f7ea84..6e432ed 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -876,6 +876,10 @@
 
 	function_profile_call(trace->func, 0, NULL, NULL);
 
+	/* If function graph is shutting down, ret_stack can be NULL */
+	if (!current->ret_stack)
+		return 0;
+
 	if (index >= 0 && index < FTRACE_RETFUNC_DEPTH)
 		current->ret_stack[index].subtime = 0;
 
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4a848f7..cddedb5 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1599,11 +1599,11 @@
 
 #define SAVED_CMDLINES_DEFAULT 128
 #define NO_CMDLINE_MAP UINT_MAX
-static unsigned saved_tgids[SAVED_CMDLINES_DEFAULT];
 static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 struct saved_cmdlines_buffer {
 	unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1];
 	unsigned *map_cmdline_to_pid;
+	unsigned *map_cmdline_to_tgid;
 	unsigned cmdline_num;
 	int cmdline_idx;
 	char *saved_cmdlines;
@@ -1637,12 +1637,23 @@
 		return -ENOMEM;
 	}
 
+	s->map_cmdline_to_tgid = kmalloc_array(val,
+					       sizeof(*s->map_cmdline_to_tgid),
+					       GFP_KERNEL);
+	if (!s->map_cmdline_to_tgid) {
+		kfree(s->map_cmdline_to_pid);
+		kfree(s->saved_cmdlines);
+		return -ENOMEM;
+	}
+
 	s->cmdline_idx = 0;
 	s->cmdline_num = val;
 	memset(&s->map_pid_to_cmdline, NO_CMDLINE_MAP,
 	       sizeof(s->map_pid_to_cmdline));
 	memset(s->map_cmdline_to_pid, NO_CMDLINE_MAP,
 	       val * sizeof(*s->map_cmdline_to_pid));
+	memset(s->map_cmdline_to_tgid, NO_CMDLINE_MAP,
+	       val * sizeof(*s->map_cmdline_to_tgid));
 
 	return 0;
 }
@@ -1808,14 +1819,17 @@
 	if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
 		return 0;
 
+	preempt_disable();
 	/*
 	 * It's not the end of the world if we don't get
 	 * the lock, but we also don't want to spin
 	 * nor do we want to disable interrupts,
 	 * so if we miss here, then better luck next time.
 	 */
-	if (!arch_spin_trylock(&trace_cmdline_lock))
+	if (!arch_spin_trylock(&trace_cmdline_lock)) {
+		preempt_enable();
 		return 0;
+	}
 
 	idx = savedcmd->map_pid_to_cmdline[tsk->pid];
 	if (idx == NO_CMDLINE_MAP) {
@@ -1838,8 +1852,9 @@
 	}
 
 	set_cmdline(idx, tsk->comm);
-	saved_tgids[idx] = tsk->tgid;
+	savedcmd->map_cmdline_to_tgid[idx] = tsk->tgid;
 	arch_spin_unlock(&trace_cmdline_lock);
+	preempt_enable();
 
 	return 1;
 }
@@ -1881,19 +1896,29 @@
 	preempt_enable();
 }
 
-int trace_find_tgid(int pid)
+static int __find_tgid_locked(int pid)
 {
 	unsigned map;
 	int tgid;
 
-	preempt_disable();
-	arch_spin_lock(&trace_cmdline_lock);
 	map = savedcmd->map_pid_to_cmdline[pid];
 	if (map != NO_CMDLINE_MAP)
-		tgid = saved_tgids[map];
+		tgid = savedcmd->map_cmdline_to_tgid[map];
 	else
 		tgid = -1;
 
+	return tgid;
+}
+
+int trace_find_tgid(int pid)
+{
+	int tgid;
+
+	preempt_disable();
+	arch_spin_lock(&trace_cmdline_lock);
+
+	tgid = __find_tgid_locked(pid);
+
 	arch_spin_unlock(&trace_cmdline_lock);
 	preempt_enable();
 
@@ -4386,10 +4411,15 @@
 {
 	char buf[64];
 	int r;
+	unsigned int n;
 
+	preempt_disable();
 	arch_spin_lock(&trace_cmdline_lock);
-	r = scnprintf(buf, sizeof(buf), "%u\n", savedcmd->cmdline_num);
+	n = savedcmd->cmdline_num;
 	arch_spin_unlock(&trace_cmdline_lock);
+	preempt_enable();
+
+	r = scnprintf(buf, sizeof(buf), "%u\n", n);
 
 	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
 }
@@ -4398,6 +4428,7 @@
 {
 	kfree(s->saved_cmdlines);
 	kfree(s->map_cmdline_to_pid);
+	kfree(s->map_cmdline_to_tgid);
 	kfree(s);
 }
 
@@ -4414,10 +4445,12 @@
 		return -ENOMEM;
 	}
 
+	preempt_disable();
 	arch_spin_lock(&trace_cmdline_lock);
 	savedcmd_temp = savedcmd;
 	savedcmd = s;
 	arch_spin_unlock(&trace_cmdline_lock);
+	preempt_enable();
 	free_saved_cmdlines_buffer(savedcmd_temp);
 
 	return 0;
@@ -4636,33 +4669,61 @@
 	char *file_buf;
 	char *buf;
 	int len = 0;
-	int pid;
 	int i;
+	int *pids;
+	int n = 0;
 
-	file_buf = kmalloc(SAVED_CMDLINES_DEFAULT*(16+1+16), GFP_KERNEL);
-	if (!file_buf)
+	preempt_disable();
+	arch_spin_lock(&trace_cmdline_lock);
+
+	pids = kmalloc_array(savedcmd->cmdline_num, 2*sizeof(int), GFP_KERNEL);
+	if (!pids) {
+		arch_spin_unlock(&trace_cmdline_lock);
+		preempt_enable();
 		return -ENOMEM;
+	}
 
-	buf = file_buf;
-
-	for (i = 0; i < SAVED_CMDLINES_DEFAULT; i++) {
-		int tgid;
-		int r;
+	for (i = 0; i < savedcmd->cmdline_num; i++) {
+		int pid;
 
 		pid = savedcmd->map_cmdline_to_pid[i];
 		if (pid == -1 || pid == NO_CMDLINE_MAP)
 			continue;
 
-		tgid = trace_find_tgid(pid);
-		r = sprintf(buf, "%d %d\n", pid, tgid);
+		pids[n] = pid;
+		pids[n+1] = __find_tgid_locked(pid);
+		n += 2;
+	}
+	arch_spin_unlock(&trace_cmdline_lock);
+	preempt_enable();
+
+	if (n == 0) {
+		kfree(pids);
+		return 0;
+	}
+
+	/* enough to hold max pair of pids + space, lr and nul */
+	len = n * 12;
+	file_buf = kmalloc(len, GFP_KERNEL);
+	if (!file_buf) {
+		kfree(pids);
+		return -ENOMEM;
+	}
+
+	buf = file_buf;
+	for (i = 0; i < n && len > 0; i += 2) {
+		int r;
+
+		r = snprintf(buf, len, "%d %d\n", pids[i], pids[i+1]);
 		buf += r;
-		len += r;
+		len -= r;
 	}
 
 	len = simple_read_from_buffer(ubuf, cnt, ppos,
-				      file_buf, len);
+				      file_buf, buf - file_buf);
 
 	kfree(file_buf);
+	kfree(pids);
 
 	return len;
 }
@@ -7865,4 +7926,4 @@
 }
 
 fs_initcall(tracer_init_tracefs);
-late_initcall(clear_boot_tracer);
+late_initcall_sync(clear_boot_tracer);
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 9daa9b3..0193f58 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1926,6 +1926,10 @@
 		if (err && set_str)
 			append_filter_err(ps, filter);
 	}
+	if (err && !set_str) {
+		free_event_filter(filter);
+		filter = NULL;
+	}
 	create_filter_finish(ps);
 
 	*filterp = filter;
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
index 0a689bb..305039b 100644
--- a/kernel/trace/tracing_map.c
+++ b/kernel/trace/tracing_map.c
@@ -221,16 +221,19 @@
 	if (!a)
 		return;
 
-	if (!a->pages) {
-		kfree(a);
-		return;
-	}
+	if (!a->pages)
+		goto free;
 
 	for (i = 0; i < a->n_pages; i++) {
 		if (!a->pages[i])
 			break;
 		free_page((unsigned long)a->pages[i]);
 	}
+
+	kfree(a->pages);
+
+ free:
+	kfree(a);
 }
 
 struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts,
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index cffb5f2..cfbf027 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -81,10 +81,10 @@
 static DEFINE_PER_CPU(unsigned int, watchdog_en);
 static DEFINE_PER_CPU(bool, softlockup_touch_sync);
 static DEFINE_PER_CPU(bool, soft_watchdog_warn);
-static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
 static DEFINE_PER_CPU(unsigned long, soft_lockup_hrtimer_cnt);
 static DEFINE_PER_CPU(struct task_struct *, softlockup_task_ptr_saved);
-static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
+DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
+DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
 static unsigned long soft_lockup_nmi_warn;
 
 unsigned int __read_mostly softlockup_panic =
@@ -254,6 +254,10 @@
 {
 }
 
+void __weak watchdog_check_hardlockup_other_cpu(void)
+{
+}
+
 static int watchdog_enable_all_cpus(void);
 static void watchdog_disable_all_cpus(void);
 
@@ -271,6 +275,9 @@
 	/* kick the hardlockup detector */
 	watchdog_interrupt_count();
 
+	/* test for hardlockups on the next cpu */
+	watchdog_check_hardlockup_other_cpu();
+
 	/* kick the softlockup detector */
 	wake_up_process(__this_cpu_read(softlockup_watchdog));
 
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 12b8dd6..5b2c127 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -18,7 +18,11 @@
 
 static DEFINE_PER_CPU(bool, hard_watchdog_warn);
 static DEFINE_PER_CPU(bool, watchdog_nmi_touch);
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU
+static cpumask_t __read_mostly watchdog_cpus;
+#else
 static DEFINE_PER_CPU(struct perf_event *, watchdog_ev);
+#endif
 
 /* boot commands */
 /*
@@ -26,7 +30,10 @@
  */
 unsigned int __read_mostly hardlockup_panic =
 			CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
+
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_NMI
 static unsigned long hardlockup_allcpu_dumped;
+#endif
 /*
  * We may not want to enable hard lockup detection by default in all cases,
  * for example when running the kernel as a guest on a hypervisor. In these
@@ -68,6 +75,108 @@
 }
 EXPORT_SYMBOL(touch_nmi_watchdog);
 
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU
+static unsigned int watchdog_next_cpu(unsigned int cpu)
+{
+	cpumask_t cpus = watchdog_cpus;
+	unsigned int next_cpu;
+
+	next_cpu = cpumask_next(cpu, &cpus);
+	if (next_cpu >= nr_cpu_ids)
+		next_cpu = cpumask_first(&cpus);
+
+	if (next_cpu == cpu)
+		return nr_cpu_ids;
+
+	return next_cpu;
+}
+
+static int is_hardlockup_other_cpu(unsigned int cpu)
+{
+	unsigned long hrint = per_cpu(hrtimer_interrupts, cpu);
+
+	if (per_cpu(hrtimer_interrupts_saved, cpu) == hrint)
+		return 1;
+
+	per_cpu(hrtimer_interrupts_saved, cpu) = hrint;
+	return 0;
+}
+
+void watchdog_check_hardlockup_other_cpu(void)
+{
+	unsigned int next_cpu;
+
+	/*
+	 * Test for hardlockups every 3 samples.  The sample period is
+	 *  watchdog_thresh * 2 / 5, so 3 samples gets us back to slightly over
+	 *  watchdog_thresh (over by 20%).
+	 */
+	if (__this_cpu_read(hrtimer_interrupts) % 3 != 0)
+		return;
+
+	/* check for a hardlockup on the next cpu */
+	next_cpu = watchdog_next_cpu(smp_processor_id());
+	if (next_cpu >= nr_cpu_ids)
+		return;
+
+	smp_rmb();
+
+	if (per_cpu(watchdog_nmi_touch, next_cpu) == true) {
+		per_cpu(watchdog_nmi_touch, next_cpu) = false;
+		return;
+	}
+
+	if (is_hardlockup_other_cpu(next_cpu)) {
+		/* only warn once */
+		if (per_cpu(hard_watchdog_warn, next_cpu) == true)
+			return;
+
+		if (hardlockup_panic)
+			panic("Watchdog detected hard LOCKUP on cpu %u",
+				next_cpu);
+		else
+			WARN(1, "Watchdog detected hard LOCKUP on cpu %u",
+				next_cpu);
+
+		per_cpu(hard_watchdog_warn, next_cpu) = true;
+	} else {
+		per_cpu(hard_watchdog_warn, next_cpu) = false;
+	}
+}
+
+int watchdog_nmi_enable(unsigned int cpu)
+{
+	/*
+	 * The new cpu will be marked online before the first hrtimer interrupt
+	 * runs on it.  If another cpu tests for a hardlockup on the new cpu
+	 * before it has run its first hrtimer, it will get a false positive.
+	 * Touch the watchdog on the new cpu to delay the first check for at
+	 * least 3 sampling periods to guarantee one hrtimer has run on the new
+	 * cpu.
+	 */
+	per_cpu(watchdog_nmi_touch, cpu) = true;
+	smp_wmb();
+	cpumask_set_cpu(cpu, &watchdog_cpus);
+	return 0;
+}
+
+void watchdog_nmi_disable(unsigned int cpu)
+{
+	unsigned int next_cpu = watchdog_next_cpu(cpu);
+
+	/*
+	 * Offlining this cpu will cause the cpu before this one to start
+	 * checking the one after this one.  If this cpu just finished checking
+	 * the next cpu and updating hrtimer_interrupts_saved, and then the
+	 * previous cpu checks it within one sample period, it will trigger a
+	 * false positive.  Touch the watchdog on the next cpu to prevent it.
+	 */
+	if (next_cpu < nr_cpu_ids)
+		per_cpu(watchdog_nmi_touch, next_cpu) = true;
+	smp_wmb();
+	cpumask_clear_cpu(cpu, &watchdog_cpus);
+}
+#else
 static struct perf_event_attr wd_hw_attr = {
 	.type		= PERF_TYPE_HARDWARE,
 	.config		= PERF_COUNT_HW_CPU_CYCLES,
@@ -228,3 +337,4 @@
 		cpu0_err = 0;
 	}
 }
+#endif
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 812b8f8..0e5e54f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3737,8 +3737,12 @@
 		return -EINVAL;
 
 	/* creating multiple pwqs breaks ordering guarantee */
-	if (WARN_ON((wq->flags & __WQ_ORDERED) && !list_empty(&wq->pwqs)))
-		return -EINVAL;
+	if (!list_empty(&wq->pwqs)) {
+		if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
+			return -EINVAL;
+
+		wq->flags &= ~__WQ_ORDERED;
+	}
 
 	ctx = apply_wqattrs_prepare(wq, attrs);
 	if (!ctx)
@@ -3922,6 +3926,16 @@
 	struct workqueue_struct *wq;
 	struct pool_workqueue *pwq;
 
+	/*
+	 * Unbound && max_active == 1 used to imply ordered, which is no
+	 * longer the case on NUMA machines due to per-node pools.  While
+	 * alloc_ordered_workqueue() is the right way to create an ordered
+	 * workqueue, keep the previous behavior to avoid subtle breakages
+	 * on NUMA.
+	 */
+	if ((flags & WQ_UNBOUND) && max_active == 1)
+		flags |= __WQ_ORDERED;
+
 	/* see the comment above the definition of WQ_POWER_EFFICIENT */
 	if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
 		flags |= WQ_UNBOUND;
@@ -4110,13 +4124,14 @@
 	struct pool_workqueue *pwq;
 
 	/* disallow meddling with max_active for ordered workqueues */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return;
 
 	max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
 
 	mutex_lock(&wq->mutex);
 
+	wq->flags &= ~__WQ_ORDERED;
 	wq->saved_max_active = max_active;
 
 	for_each_pwq(pwq, wq)
@@ -5221,7 +5236,7 @@
 	 * attributes breaks ordering guarantee.  Disallow exposing ordered
 	 * workqueues.
 	 */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return -EINVAL;
 
 	wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2f9f7aa..2812580 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -145,7 +145,7 @@
 
 config DEBUG_INFO_SPLIT
 	bool "Produce split debuginfo in .dwo files"
-	depends on DEBUG_INFO
+	depends on DEBUG_INFO && !FRV
 	help
 	  Generate debug info into separate .dwo files. This significantly
 	  reduces the build directory size for builds with DEBUG_INFO,
@@ -779,11 +779,20 @@
 	  The frequency of hrtimer and NMI events and the soft and hard lockup
 	  thresholds can be controlled through the sysctl watchdog_thresh.
 
-config HARDLOCKUP_DETECTOR
+config HARDLOCKUP_DETECTOR_NMI
 	def_bool y
 	depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG
 	depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI
 
+config HARDLOCKUP_DETECTOR_OTHER_CPU
+       def_bool y
+       depends on LOCKUP_DETECTOR && SMP
+       depends on !HARDLOCKUP_DETECTOR_NMI && !HAVE_NMI_WATCHDOG
+
+config HARDLOCKUP_DETECTOR
+       def_bool y
+       depends on HARDLOCKUP_DETECTOR_NMI || HARDLOCKUP_DETECTOR_OTHER_CPU
+
 config BOOTPARAM_HARDLOCKUP_PANIC
 	bool "Panic (Reboot) On Hard Lockups"
 	depends on HARDLOCKUP_DETECTOR
diff --git a/lib/lz4/lz4hc_compress.c b/lib/lz4/lz4hc_compress.c
index f344f76..6b2e046 100644
--- a/lib/lz4/lz4hc_compress.c
+++ b/lib/lz4/lz4hc_compress.c
@@ -131,7 +131,7 @@
 #endif
 	int nbattempts = MAX_NB_ATTEMPTS;
 	size_t repl = 0, ml = 0;
-	u16 delta;
+	u16 delta = 0;
 
 	/* HC4 match finder */
 	lz4hc_insert(hc4, ip);
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index 5a0f75a..eead4b3 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -364,11 +364,11 @@
 	}
 
 	miter.consumed = lzeros;
-	sg_miter_stop(&miter);
 
 	nbytes -= lzeros;
 	nbits = nbytes * 8;
 	if (nbits > MAX_EXTERN_MPI_BITS) {
+		sg_miter_stop(&miter);
 		pr_info("MPI: mpi too large (%u bits)\n", nbits);
 		return NULL;
 	}
@@ -376,6 +376,8 @@
 	if (nbytes > 0)
 		nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8);
 
+	sg_miter_stop(&miter);
+
 	nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB);
 	val = mpi_alloc(nlimbs);
 	if (!val)
diff --git a/mm/internal.h b/mm/internal.h
index 537ac99..0ee4f54 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -74,11 +74,16 @@
 extern unsigned long highest_memmap_pfn;
 
 /*
+ * Maximum number of reclaim retries without progress before the OOM
+ * killer is consider the only way forward.
+ */
+#define MAX_RECLAIM_RETRIES 16
+
+/*
  * in mm/vmscan.c:
  */
 extern int isolate_lru_page(struct page *page);
 extern void putback_lru_page(struct page *page);
-extern bool pgdat_reclaimable(struct pglist_data *pgdat);
 
 /*
  * in mm/rmap.c:
@@ -472,6 +477,7 @@
 #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
 void try_to_unmap_flush(void);
 void try_to_unmap_flush_dirty(void);
+void flush_tlb_batched_pending(struct mm_struct *mm);
 #else
 static inline void try_to_unmap_flush(void)
 {
@@ -479,7 +485,9 @@
 static inline void try_to_unmap_flush_dirty(void)
 {
 }
-
+static inline void flush_tlb_batched_pending(struct mm_struct *mm)
+{
+}
 #endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
 
 extern const struct trace_print_flags pageflag_names[];
diff --git a/mm/madvise.c b/mm/madvise.c
index 279627a..088a5b22 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -21,6 +21,7 @@
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/mmu_notifier.h>
+#include "internal.h"
 
 #include <asm/tlb.h>
 
@@ -282,6 +283,7 @@
 		return 0;
 
 	orig_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
+	flush_tlb_batched_pending(mm);
 	arch_enter_lazy_mmu_mode();
 	for (; addr != end; pte++, addr += PAGE_SIZE) {
 		ptent = *pte;
@@ -329,8 +331,8 @@
 				pte_offset_map_lock(mm, pmd, addr, &ptl);
 				goto out;
 			}
-			put_page(page);
 			unlock_page(page);
+			put_page(page);
 			pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
 			pte--;
 			addr -= PAGE_SIZE;
@@ -531,6 +533,8 @@
 static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
 {
 	struct page *p;
+	struct zone *zone;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 	for (; start < end; start += PAGE_SIZE <<
@@ -559,6 +563,11 @@
 		if (ret)
 			return ret;
 	}
+
+	/* Ensure that all poisoned pages are removed from per-cpu lists */
+	for_each_populated_zone(zone)
+		drain_all_pages(zone);
+
 	return 0;
 }
 #endif
diff --git a/mm/memblock.c b/mm/memblock.c
index f1eabcc..3b7d23c 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -301,31 +301,27 @@
 }
 
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-
-phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
-					phys_addr_t *addr)
+/**
+ * Discard memory and reserved arrays if they were allocated
+ */
+void __init memblock_discard(void)
 {
-	if (memblock.reserved.regions == memblock_reserved_init_regions)
-		return 0;
+	phys_addr_t addr, size;
 
-	*addr = __pa(memblock.reserved.regions);
+	if (memblock.reserved.regions != memblock_reserved_init_regions) {
+		addr = __pa(memblock.reserved.regions);
+		size = PAGE_ALIGN(sizeof(struct memblock_region) *
+				  memblock.reserved.max);
+		__memblock_free_late(addr, size);
+	}
 
-	return PAGE_ALIGN(sizeof(struct memblock_region) *
-			  memblock.reserved.max);
+	if (memblock.memory.regions != memblock_memory_init_regions) {
+		addr = __pa(memblock.memory.regions);
+		size = PAGE_ALIGN(sizeof(struct memblock_region) *
+				  memblock.memory.max);
+		__memblock_free_late(addr, size);
+	}
 }
-
-phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
-					phys_addr_t *addr)
-{
-	if (memblock.memory.regions == memblock_memory_init_regions)
-		return 0;
-
-	*addr = __pa(memblock.memory.regions);
-
-	return PAGE_ALIGN(sizeof(struct memblock_region) *
-			  memblock.memory.max);
-}
-
 #endif
 
 /**
diff --git a/mm/memory.c b/mm/memory.c
index 49d9b42..378ebc0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1124,6 +1124,7 @@
 	init_rss_vec(rss);
 	start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
 	pte = start_pte;
+	flush_tlb_batched_pending(mm);
 	arch_enter_lazy_mmu_mode();
 	do {
 		pte_t ptent = *pte;
@@ -3595,6 +3596,11 @@
 	/* do counter updates before entering really critical section. */
 	check_sync_rss_stat(current);
 
+	if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
+					    flags & FAULT_FLAG_INSTRUCTION,
+					    flags & FAULT_FLAG_REMOTE))
+		return VM_FAULT_SIGSEGV;
+
 	/*
 	 * Enable the memcg OOM handling for faults triggered in user
 	 * space.  Kernel faults are handled more gracefully.
@@ -3602,11 +3608,6 @@
 	if (flags & FAULT_FLAG_USER)
 		mem_cgroup_oom_enable();
 
-	if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
-					    flags & FAULT_FLAG_INSTRUCTION,
-					    flags & FAULT_FLAG_REMOTE))
-		return VM_FAULT_SIGSEGV;
-
 	if (unlikely(is_vm_hugetlb_page(vma)))
 		ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
 	else
@@ -3634,8 +3635,18 @@
 	 * further.
 	 */
 	if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR)
-				&& test_bit(MMF_UNSTABLE, &vma->vm_mm->flags)))
+				&& test_bit(MMF_UNSTABLE, &vma->vm_mm->flags))) {
+
+		/*
+		 * We are going to enforce SIGBUS but the PF path might have
+		 * dropped the mmap_sem already so take it again so that
+		 * we do not break expectations of all arch specific PF paths
+		 * and g-u-p
+		 */
+		if (ret & VM_FAULT_RETRY)
+			down_read(&vma->vm_mm->mmap_sem);
 		ret = VM_FAULT_SIGBUS;
+	}
 
 	return ret;
 }
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index ede13734..6eb61a4 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1201,7 +1201,11 @@
 
 		arch_refresh_nodedata(nid, pgdat);
 	} else {
-		/* Reset the nr_zones, order and classzone_idx before reuse */
+		/*
+		 * Reset the nr_zones, order and classzone_idx before reuse.
+		 * Note that kswapd will init kswapd_classzone_idx properly
+		 * when it starts in the near future.
+		 */
 		pgdat->nr_zones = 0;
 		pgdat->kswapd_order = 0;
 		pgdat->kswapd_classzone_idx = 0;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9ff5657..9547583 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -927,11 +927,6 @@
 		*policy |= (pol->flags & MPOL_MODE_FLAGS);
 	}
 
-	if (vma) {
-		up_read(&current->mm->mmap_sem);
-		vma = NULL;
-	}
-
 	err = 0;
 	if (nmask) {
 		if (mpol_store_user_nodemask(pol)) {
diff --git a/mm/migrate.c b/mm/migrate.c
index f0b786d..eb1f043 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -40,6 +40,7 @@
 #include <linux/mmu_notifier.h>
 #include <linux/page_idle.h>
 #include <linux/page_owner.h>
+#include <linux/ptrace.h>
 
 #include <asm/tlbflush.h>
 
@@ -1665,7 +1666,6 @@
 		const int __user *, nodes,
 		int __user *, status, int, flags)
 {
-	const struct cred *cred = current_cred(), *tcred;
 	struct task_struct *task;
 	struct mm_struct *mm;
 	int err;
@@ -1689,14 +1689,9 @@
 
 	/*
 	 * Check if this process has the right to modify the specified
-	 * process. The right exists if the process has administrative
-	 * capabilities, superuser privileges or the same
-	 * userid as the target process.
+	 * process. Use the regular "ptrace_may_access()" checks.
 	 */
-	tcred = __task_cred(task);
-	if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
-	    !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
-	    !capable(CAP_SYS_NICE)) {
+	if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
 		rcu_read_unlock();
 		err = -EPERM;
 		goto out;
@@ -1738,9 +1733,6 @@
 {
 	int z;
 
-	if (!pgdat_reclaimable(pgdat))
-		return false;
-
 	for (z = pgdat->nr_zones - 1; z >= 0; z--) {
 		struct zone *zone = pgdat->node_zones + z;
 
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 2c40836..1f2c969 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -74,6 +74,7 @@
 	if (!pte)
 		return 0;
 
+	flush_tlb_batched_pending(vma->vm_mm);
 	arch_enter_lazy_mmu_mode();
 	do {
 		oldpte = *pte;
diff --git a/mm/mremap.c b/mm/mremap.c
index 30d7d24..1597671 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -142,6 +142,7 @@
 	new_ptl = pte_lockptr(mm, new_pmd);
 	if (new_ptl != old_ptl)
 		spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
+	flush_tlb_batched_pending(vma->vm_mm);
 	arch_enter_lazy_mmu_mode();
 
 	for (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index e1e8c63..aa59572 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -146,22 +146,6 @@
 				NULL)
 		count += __free_memory_core(start, end);
 
-#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-	{
-		phys_addr_t size;
-
-		/* Free memblock.reserved array if it was allocated */
-		size = get_allocated_memblock_reserved_regions_info(&start);
-		if (size)
-			count += __free_memory_core(start, start + size);
-
-		/* Free memblock.memory array if it was allocated */
-		size = get_allocated_memblock_memory_regions_info(&start);
-		if (size)
-			count += __free_memory_core(start, start + size);
-	}
-#endif
-
 	return count;
 }
 
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 3a22b14..af783a6 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -608,18 +608,23 @@
 	return 0;
 }
 
-static void wake_oom_reaper(struct task_struct *tsk)
+void wake_oom_reaper(struct task_struct *tsk)
 {
 	if (!oom_reaper_th)
 		return;
 
+	/* move the lock here to avoid scenario of queuing
+	 * the same task by both OOM killer and LMK.
+	 */
+	spin_lock(&oom_reaper_lock);
 	/* tsk is already queued? */
-	if (tsk == oom_reaper_list || tsk->oom_reaper_list)
+	if (tsk == oom_reaper_list || tsk->oom_reaper_list) {
+		spin_unlock(&oom_reaper_lock);
 		return;
+	}
 
 	get_task_struct(tsk);
 
-	spin_lock(&oom_reaper_lock);
 	tsk->oom_reaper_list = oom_reaper_list;
 	oom_reaper_list = tsk;
 	spin_unlock(&oom_reaper_lock);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 44085b2..acf411c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1099,14 +1099,10 @@
 {
 	int migratetype = 0;
 	int batch_free = 0;
-	unsigned long nr_scanned;
 	bool isolated_pageblocks;
 
 	spin_lock(&zone->lock);
 	isolated_pageblocks = has_isolate_pageblock(zone);
-	nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED);
-	if (nr_scanned)
-		__mod_node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED, -nr_scanned);
 
 	while (count) {
 		struct page *page;
@@ -1159,12 +1155,7 @@
 				unsigned int order,
 				int migratetype)
 {
-	unsigned long nr_scanned;
 	spin_lock(&zone->lock);
-	nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED);
-	if (nr_scanned)
-		__mod_node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED, -nr_scanned);
-
 	if (unlikely(has_isolate_pageblock(zone) ||
 		is_migrate_isolate(migratetype))) {
 		migratetype = get_pfnblock_migratetype(page, pfn);
@@ -1588,6 +1579,10 @@
 	/* Reinit limits that are based on free pages after the kernel is up */
 	files_maxfiles_init();
 #endif
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+	/* Discard memblock private memory */
+	memblock_discard();
+#endif
 
 	for_each_populated_zone(zone)
 		set_zone_contiguous(zone);
@@ -1874,14 +1869,14 @@
 #endif
 
 	for (page = start_page; page <= end_page;) {
-		/* Make sure we are not inadvertently changing nodes */
-		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
-
 		if (!pfn_valid_within(page_to_pfn(page))) {
 			page++;
 			continue;
 		}
 
+		/* Make sure we are not inadvertently changing nodes */
+		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
+
 		if (!PageBuddy(page)) {
 			page++;
 			continue;
@@ -3501,19 +3496,12 @@
 }
 
 /*
- * Maximum number of reclaim retries without any progress before OOM killer
- * is consider as the only way to move forward.
- */
-#define MAX_RECLAIM_RETRIES 16
-
-/*
  * Checks whether it makes sense to retry the reclaim to make a forward progress
  * for the given allocation request.
- * The reclaim feedback represented by did_some_progress (any progress during
- * the last reclaim round) and no_progress_loops (number of reclaim rounds without
- * any progress in a row) is considered as well as the reclaimable pages on the
- * applicable zone list (with a backoff mechanism which is a function of
- * no_progress_loops).
+ *
+ * We give up when we either have tried MAX_RECLAIM_RETRIES in a row
+ * without success, or when we couldn't even meet the watermark if we
+ * reclaimed all remaining pages on the LRU lists.
  *
  * Returns true if a retry is viable or false to enter the oom path.
  */
@@ -3556,13 +3544,11 @@
 		unsigned long reclaimable;
 
 		available = reclaimable = zone_reclaimable_pages(zone);
-		available -= DIV_ROUND_UP((*no_progress_loops) * available,
-					  MAX_RECLAIM_RETRIES);
 		available += zone_page_state_snapshot(zone, NR_FREE_PAGES);
 
 		/*
-		 * Would the allocation succeed if we reclaimed the whole
-		 * available?
+		 * Would the allocation succeed if we reclaimed all
+		 * reclaimable pages?
 		 */
 		if (__zone_watermark_ok(zone, order, min_wmark_pages(zone),
 				ac_classzone_idx(ac), alloc_flags, available)) {
@@ -4442,7 +4428,6 @@
 #endif
 			" writeback_tmp:%lukB"
 			" unstable:%lukB"
-			" pages_scanned:%lu"
 			" all_unreclaimable? %s"
 			"\n",
 			pgdat->node_id,
@@ -4465,8 +4450,8 @@
 #endif
 			K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
 			K(node_page_state(pgdat, NR_UNSTABLE_NFS)),
-			node_page_state(pgdat, NR_PAGES_SCANNED),
-			!pgdat_reclaimable(pgdat) ? "yes" : "no");
+			pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES ?
+				"yes" : "no");
 	}
 
 	for_each_populated_zone(zone) {
@@ -6544,8 +6529,8 @@
 	}
 
 	if (pages && s)
-		pr_info("Freeing %s memory: %ldK (%p - %p)\n",
-			s, pages << (PAGE_SHIFT - 10), start, end);
+		pr_info("Freeing %s memory: %ldK\n",
+			s, pages << (PAGE_SHIFT - 10));
 
 	return pages;
 }
@@ -7435,7 +7420,7 @@
 
 	/* Make sure the range is really isolated. */
 	if (test_pages_isolated(outer_start, end, false)) {
-		pr_info("%s: [%lx, %lx) PFNs busy\n",
+		pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n",
 			__func__, outer_start, end);
 		ret = -EBUSY;
 		goto done;
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 65e24fb..fe850b9 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -143,7 +143,7 @@
 		.nr_entries = 0,
 		.entries = entries,
 		.max_entries = PAGE_OWNER_STACK_DEPTH,
-		.skip = 0
+		.skip = 2
 	};
 	depot_stack_handle_t handle;
 
diff --git a/mm/rmap.c b/mm/rmap.c
index dfb19f0..4d19dd1 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -617,6 +617,13 @@
 	tlb_ubc->flush_required = true;
 
 	/*
+	 * Ensure compiler does not re-order the setting of tlb_flush_batched
+	 * before the PTE is cleared.
+	 */
+	barrier();
+	mm->tlb_flush_batched = true;
+
+	/*
 	 * If the PTE was dirty then it's best to assume it's writable. The
 	 * caller must use try_to_unmap_flush_dirty() or try_to_unmap_flush()
 	 * before the page is queued for IO.
@@ -643,6 +650,35 @@
 
 	return should_defer;
 }
+
+/*
+ * Reclaim unmaps pages under the PTL but do not flush the TLB prior to
+ * releasing the PTL if TLB flushes are batched. It's possible for a parallel
+ * operation such as mprotect or munmap to race between reclaim unmapping
+ * the page and flushing the page. If this race occurs, it potentially allows
+ * access to data via a stale TLB entry. Tracking all mm's that have TLB
+ * batching in flight would be expensive during reclaim so instead track
+ * whether TLB batching occurred in the past and if so then do a flush here
+ * if required. This will cost one additional flush per reclaim cycle paid
+ * by the first operation at risk such as mprotect and mumap.
+ *
+ * This must be called under the PTL so that an access to tlb_flush_batched
+ * that is potentially a "reclaim vs mprotect/munmap/etc" race will synchronise
+ * via the PTL.
+ */
+void flush_tlb_batched_pending(struct mm_struct *mm)
+{
+	if (mm->tlb_flush_batched) {
+		flush_tlb_mm(mm);
+
+		/*
+		 * Do not allow the compiler to re-order the clearing of
+		 * tlb_flush_batched before the tlb is flushed.
+		 */
+		barrier();
+		mm->tlb_flush_batched = false;
+	}
+}
 #else
 static void set_tlb_ubc_flush_pending(struct mm_struct *mm,
 		struct page *page, bool writable)
diff --git a/mm/shmem.c b/mm/shmem.c
index 142887f..7a74b6d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1007,7 +1007,11 @@
 			 */
 			if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
 				spin_lock(&sbinfo->shrinklist_lock);
-				if (list_empty(&info->shrinklist)) {
+				/*
+				 * _careful to defend against unlocked access to
+				 * ->shrink_list in shmem_unused_huge_shrink()
+				 */
+				if (list_empty_careful(&info->shrinklist)) {
 					list_add_tail(&info->shrinklist,
 							&sbinfo->shrinklist);
 					sbinfo->shrinklist_len++;
@@ -1774,7 +1778,11 @@
 			 * to shrink under memory pressure.
 			 */
 			spin_lock(&sbinfo->shrinklist_lock);
-			if (list_empty(&info->shrinklist)) {
+			/*
+			 * _careful to defend against unlocked access to
+			 * ->shrink_list in shmem_unused_huge_shrink()
+			 */
+			if (list_empty_careful(&info->shrinklist)) {
 				list_add_tail(&info->shrinklist,
 						&sbinfo->shrinklist);
 				sbinfo->shrinklist_len++;
@@ -3802,7 +3810,7 @@
 	}
 
 #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
-	if (has_transparent_hugepage() && shmem_huge < SHMEM_HUGE_DENY)
+	if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY)
 		SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
 	else
 		shmem_huge = 0; /* just in case it was patched */
@@ -3863,7 +3871,7 @@
 		return -EINVAL;
 
 	shmem_huge = huge;
-	if (shmem_huge < SHMEM_HUGE_DENY)
+	if (shmem_huge > SHMEM_HUGE_DENY)
 		SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
 	return count;
 }
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7b5848cf..bb18b47 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -235,12 +235,6 @@
 	return nr;
 }
 
-bool pgdat_reclaimable(struct pglist_data *pgdat)
-{
-	return node_page_state_snapshot(pgdat, NR_PAGES_SCANNED) <
-		pgdat_reclaimable_pages(pgdat) * 6;
-}
-
 /**
  * lruvec_lru_size -  Returns the number of pages on the given LRU list.
  * @lruvec: lru vector
@@ -1495,7 +1489,7 @@
  *
  * Appropriate locks must be held before calling this function.
  *
- * @nr_to_scan:	The number of pages to look through on the list.
+ * @nr_to_scan:	The number of eligible pages to look through on the list.
  * @lruvec:	The LRU vector to pull pages from.
  * @dst:	The temp list to put pages on to.
  * @nr_scanned:	The number of pages that were scanned.
@@ -1514,11 +1508,14 @@
 	unsigned long nr_taken = 0;
 	unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 };
 	unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
-	unsigned long scan, nr_pages;
+	unsigned long skipped = 0;
+	unsigned long scan, total_scan, nr_pages;
 	LIST_HEAD(pages_skipped);
 
-	for (scan = 0; scan < nr_to_scan && nr_taken < nr_to_scan &&
-					!list_empty(src);) {
+	scan = 0;
+	for (total_scan = 0;
+	     scan < nr_to_scan && nr_taken < nr_to_scan && !list_empty(src);
+	     total_scan++) {
 		struct page *page;
 
 		page = lru_to_page(src);
@@ -1533,11 +1530,12 @@
 		}
 
 		/*
-		 * Account for scanned and skipped separetly to avoid the pgdat
-		 * being prematurely marked unreclaimable by pgdat_reclaimable.
+		 * Do not count skipped pages because that makes the function
+		 * return with no isolated pages if the LRU mostly contains
+		 * ineligible pages.  This causes the VM to not reclaim any
+		 * pages, triggering a premature OOM.
 		 */
 		scan++;
-
 		switch (__isolate_lru_page(page, mode)) {
 		case 0:
 			nr_pages = hpage_nr_pages(page);
@@ -1565,28 +1563,20 @@
 	 */
 	if (!list_empty(&pages_skipped)) {
 		int zid;
-		unsigned long total_skipped = 0;
 
+		list_splice(&pages_skipped, src);
 		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
 			if (!nr_skipped[zid])
 				continue;
 
 			__count_zid_vm_events(PGSCAN_SKIP, zid, nr_skipped[zid]);
-			total_skipped += nr_skipped[zid];
+			skipped += nr_skipped[zid];
 		}
-
-		/*
-		 * Account skipped pages as a partial scan as the pgdat may be
-		 * close to unreclaimable. If the LRU list is empty, account
-		 * skipped pages as a full scan.
-		 */
-		scan += list_empty(src) ? total_skipped : total_skipped >> 2;
-
-		list_splice(&pages_skipped, src);
 	}
-	*nr_scanned = scan;
-	trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan, scan,
-				    nr_taken, mode, is_file_lru(lru));
+	*nr_scanned = total_scan;
+	trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan,
+					total_scan, skipped, nr_taken, mode,
+					is_file_lru(lru));
 	update_lru_sizes(lruvec, lru, nr_zone_taken);
 	return nr_taken;
 }
@@ -1849,7 +1839,6 @@
 	reclaim_stat->recent_scanned[file] += nr_taken;
 
 	if (global_reclaim(sc)) {
-		__mod_node_page_state(pgdat, NR_PAGES_SCANNED, nr_scanned);
 		if (current_is_kswapd())
 			__count_vm_events(PGSCAN_KSWAPD, nr_scanned);
 		else
@@ -2038,8 +2027,6 @@
 	__mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken);
 	reclaim_stat->recent_scanned[file] += nr_taken;
 
-	if (global_reclaim(sc))
-		__mod_node_page_state(pgdat, NR_PAGES_SCANNED, nr_scanned);
 	__count_vm_events(PGREFILL, nr_scanned);
 
 	spin_unlock_irq(&pgdat->lru_lock);
@@ -2199,30 +2186,8 @@
 	unsigned long anon_prio, file_prio;
 	enum scan_balance scan_balance;
 	unsigned long anon, file;
-	bool force_scan = false;
 	unsigned long ap, fp;
 	enum lru_list lru;
-	bool some_scanned;
-	int pass;
-
-	/*
-	 * If the zone or memcg is small, nr[l] can be 0.  This
-	 * results in no scanning on this priority and a potential
-	 * priority drop.  Global direct reclaim can go to the next
-	 * zone and tends to have no problems. Global kswapd is for
-	 * zone balancing and it needs to scan a minimum amount. When
-	 * reclaiming for a memcg, a priority drop can cause high
-	 * latencies, so it's better to scan a minimum amount there as
-	 * well.
-	 */
-	if (current_is_kswapd()) {
-		if (!pgdat_reclaimable(pgdat))
-			force_scan = true;
-		if (!mem_cgroup_online(memcg))
-			force_scan = true;
-	}
-	if (!global_reclaim(sc))
-		force_scan = true;
 
 	/* If we have no swap space, do not bother scanning anon pages. */
 	if (!sc->may_swap || mem_cgroup_get_nr_swap_pages(memcg) <= 0) {
@@ -2354,55 +2319,48 @@
 	fraction[1] = fp;
 	denominator = ap + fp + 1;
 out:
-	some_scanned = false;
-	/* Only use force_scan on second pass. */
-	for (pass = 0; !some_scanned && pass < 2; pass++) {
-		*lru_pages = 0;
-		for_each_evictable_lru(lru) {
-			int file = is_file_lru(lru);
-			unsigned long size;
-			unsigned long scan;
+	*lru_pages = 0;
+	for_each_evictable_lru(lru) {
+		int file = is_file_lru(lru);
+		unsigned long size;
+		unsigned long scan;
 
-			size = lruvec_lru_size(lruvec, lru, sc->reclaim_idx);
-			scan = size >> sc->priority;
+		size = lruvec_lru_size(lruvec, lru, sc->reclaim_idx);
+		scan = size >> sc->priority;
+		/*
+		 * If the cgroup's already been deleted, make sure to
+		 * scrape out the remaining cache.
+		 */
+		if (!scan && !mem_cgroup_online(memcg))
+			scan = min(size, SWAP_CLUSTER_MAX);
 
-			if (!scan && pass && force_scan)
-				scan = min(size, SWAP_CLUSTER_MAX);
-
-			switch (scan_balance) {
-			case SCAN_EQUAL:
-				/* Scan lists relative to size */
-				break;
-			case SCAN_FRACT:
-				/*
-				 * Scan types proportional to swappiness and
-				 * their relative recent reclaim efficiency.
-				 */
-				scan = div64_u64(scan * fraction[file],
-							denominator);
-				break;
-			case SCAN_FILE:
-			case SCAN_ANON:
-				/* Scan one type exclusively */
-				if ((scan_balance == SCAN_FILE) != file) {
-					size = 0;
-					scan = 0;
-				}
-				break;
-			default:
-				/* Look ma, no brain */
-				BUG();
-			}
-
-			*lru_pages += size;
-			nr[lru] = scan;
-
+		switch (scan_balance) {
+		case SCAN_EQUAL:
+			/* Scan lists relative to size */
+			break;
+		case SCAN_FRACT:
 			/*
-			 * Skip the second pass and don't force_scan,
-			 * if we found something to scan.
+			 * Scan types proportional to swappiness and
+			 * their relative recent reclaim efficiency.
 			 */
-			some_scanned |= !!scan;
+			scan = div64_u64(scan * fraction[file],
+					 denominator);
+			break;
+		case SCAN_FILE:
+		case SCAN_ANON:
+			/* Scan one type exclusively */
+			if ((scan_balance == SCAN_FILE) != file) {
+				size = 0;
+				scan = 0;
+			}
+			break;
+		default:
+			/* Look ma, no brain */
+			BUG();
 		}
+
+		*lru_pages += size;
+		nr[lru] = scan;
 	}
 }
 
@@ -2704,6 +2662,15 @@
 	} while (should_continue_reclaim(pgdat, sc->nr_reclaimed - nr_reclaimed,
 					 sc->nr_scanned - nr_scanned, sc));
 
+	/*
+	 * Kswapd gives up on balancing particular nodes after too
+	 * many failures to reclaim anything from them and goes to
+	 * sleep. On reclaim progress, reset the failure counter. A
+	 * successful direct reclaim run will revive a dormant kswapd.
+	 */
+	if (reclaimable)
+		pgdat->kswapd_failures = 0;
+
 	return reclaimable;
 }
 
@@ -2778,10 +2745,6 @@
 						 GFP_KERNEL | __GFP_HARDWALL))
 				continue;
 
-			if (sc->priority != DEF_PRIORITY &&
-			    !pgdat_reclaimable(zone->zone_pgdat))
-				continue;	/* Let kswapd poll it */
-
 			/*
 			 * If we already have plenty of memory free for
 			 * compaction in this zone, don't free any more.
@@ -2918,7 +2881,7 @@
 	return 0;
 }
 
-static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
+static bool allow_direct_reclaim(pg_data_t *pgdat)
 {
 	struct zone *zone;
 	unsigned long pfmemalloc_reserve = 0;
@@ -2926,10 +2889,15 @@
 	int i;
 	bool wmark_ok;
 
+	if (pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)
+		return true;
+
 	for (i = 0; i <= ZONE_NORMAL; i++) {
 		zone = &pgdat->node_zones[i];
-		if (!managed_zone(zone) ||
-		    pgdat_reclaimable_pages(pgdat) == 0)
+		if (!managed_zone(zone))
+			continue;
+
+		if (!zone_reclaimable_pages(zone))
 			continue;
 
 		pfmemalloc_reserve += min_wmark_pages(zone);
@@ -3006,7 +2974,7 @@
 
 		/* Throttle based on the first usable node */
 		pgdat = zone->zone_pgdat;
-		if (pfmemalloc_watermark_ok(pgdat))
+		if (allow_direct_reclaim(pgdat))
 			goto out;
 		break;
 	}
@@ -3028,14 +2996,14 @@
 	 */
 	if (!(gfp_mask & __GFP_FS)) {
 		wait_event_interruptible_timeout(pgdat->pfmemalloc_wait,
-			pfmemalloc_watermark_ok(pgdat), HZ);
+			allow_direct_reclaim(pgdat), HZ);
 
 		goto check_pending;
 	}
 
 	/* Throttle until kswapd wakes the process */
 	wait_event_killable(zone->zone_pgdat->pfmemalloc_wait,
-		pfmemalloc_watermark_ok(pgdat));
+		allow_direct_reclaim(pgdat));
 
 check_pending:
 	if (fatal_signal_pending(current))
@@ -3185,21 +3153,44 @@
 	} while (memcg);
 }
 
-static bool zone_balanced(struct zone *zone, int order, int classzone_idx)
+/*
+ * Returns true if there is an eligible zone balanced for the request order
+ * and classzone_idx
+ */
+static bool pgdat_balanced(pg_data_t *pgdat, int order, int classzone_idx)
 {
-	unsigned long mark = high_wmark_pages(zone);
+	int i;
+	unsigned long mark = -1;
+	struct zone *zone;
 
-	if (!zone_watermark_ok_safe(zone, order, mark, classzone_idx))
-		return false;
+	for (i = 0; i <= classzone_idx; i++) {
+		zone = pgdat->node_zones + i;
+
+		if (!managed_zone(zone))
+			continue;
+
+		mark = high_wmark_pages(zone);
+		if (zone_watermark_ok_safe(zone, order, mark, classzone_idx))
+			return true;
+	}
 
 	/*
-	 * If any eligible zone is balanced then the node is not considered
-	 * to be congested or dirty
+	 * If a node has no populated zone within classzone_idx, it does not
+	 * need balancing by definition. This can happen if a zone-restricted
+	 * allocation tries to wake a remote kswapd.
 	 */
-	clear_bit(PGDAT_CONGESTED, &zone->zone_pgdat->flags);
-	clear_bit(PGDAT_DIRTY, &zone->zone_pgdat->flags);
+	if (mark == -1)
+		return true;
 
-	return true;
+	return false;
+}
+
+/* Clear pgdat state for congested, dirty or under writeback. */
+static void clear_pgdat_congested(pg_data_t *pgdat)
+{
+	clear_bit(PGDAT_CONGESTED, &pgdat->flags);
+	clear_bit(PGDAT_DIRTY, &pgdat->flags);
+	clear_bit(PGDAT_WRITEBACK, &pgdat->flags);
 }
 
 /*
@@ -3210,11 +3201,9 @@
  */
 static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)
 {
-	int i;
-
 	/*
 	 * The throttled processes are normally woken up in balance_pgdat() as
-	 * soon as pfmemalloc_watermark_ok() is true. But there is a potential
+	 * soon as allow_direct_reclaim() is true. But there is a potential
 	 * race between when kswapd checks the watermarks and a process gets
 	 * throttled. There is also a potential race if processes get
 	 * throttled, kswapd wakes, a large process exits thereby balancing the
@@ -3228,17 +3217,16 @@
 	if (waitqueue_active(&pgdat->pfmemalloc_wait))
 		wake_up_all(&pgdat->pfmemalloc_wait);
 
-	for (i = 0; i <= classzone_idx; i++) {
-		struct zone *zone = pgdat->node_zones + i;
+	/* Hopeless node, leave it to direct reclaim */
+	if (pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)
+		return true;
 
-		if (!managed_zone(zone))
-			continue;
-
-		if (!zone_balanced(zone, order, classzone_idx))
-			return false;
+	if (pgdat_balanced(pgdat, order, classzone_idx)) {
+		clear_pgdat_congested(pgdat);
+		return true;
 	}
 
-	return true;
+	return false;
 }
 
 /*
@@ -3314,9 +3302,9 @@
 	count_vm_event(PAGEOUTRUN);
 
 	do {
+		unsigned long nr_reclaimed = sc.nr_reclaimed;
 		bool raise_priority = true;
 
-		sc.nr_reclaimed = 0;
 		sc.reclaim_idx = classzone_idx;
 
 		/*
@@ -3341,23 +3329,12 @@
 		}
 
 		/*
-		 * Only reclaim if there are no eligible zones. Check from
-		 * high to low zone as allocations prefer higher zones.
-		 * Scanning from low to high zone would allow congestion to be
-		 * cleared during a very small window when a small low
-		 * zone was balanced even under extreme pressure when the
-		 * overall node may be congested. Note that sc.reclaim_idx
-		 * is not used as buffer_heads_over_limit may have adjusted
-		 * it.
+		 * Only reclaim if there are no eligible zones. Note that
+		 * sc.reclaim_idx is not used as buffer_heads_over_limit may
+		 * have adjusted it.
 		 */
-		for (i = classzone_idx; i >= 0; i--) {
-			zone = pgdat->node_zones + i;
-			if (!managed_zone(zone))
-				continue;
-
-			if (zone_balanced(zone, sc.order, classzone_idx))
-				goto out;
-		}
+		if (pgdat_balanced(pgdat, sc.order, classzone_idx))
+			goto out;
 
 		/*
 		 * Do some background aging of the anon list, to give
@@ -3371,7 +3348,7 @@
 		 * If we're getting trouble reclaiming, start doing writepage
 		 * even in laptop mode.
 		 */
-		if (sc.priority < DEF_PRIORITY - 2 || !pgdat_reclaimable(pgdat))
+		if (sc.priority < DEF_PRIORITY - 2)
 			sc.may_writepage = 1;
 
 		/* Call soft limit reclaim before calling shrink_node. */
@@ -3395,7 +3372,7 @@
 		 * able to safely make forward progress. Wake them
 		 */
 		if (waitqueue_active(&pgdat->pfmemalloc_wait) &&
-				pfmemalloc_watermark_ok(pgdat))
+				allow_direct_reclaim(pgdat))
 			wake_up_all(&pgdat->pfmemalloc_wait);
 
 		/* Check if kswapd should be suspending */
@@ -3406,10 +3383,14 @@
 		 * Raise priority if scanning rate is too low or there was no
 		 * progress in reclaiming pages
 		 */
-		if (raise_priority || !sc.nr_reclaimed)
+		nr_reclaimed = sc.nr_reclaimed - nr_reclaimed;
+		if (raise_priority || !nr_reclaimed)
 			sc.priority--;
 	} while (sc.priority >= 1);
 
+	if (!sc.nr_reclaimed)
+		pgdat->kswapd_failures++;
+
 out:
 	/*
 	 * Return the order kswapd stopped reclaiming at as
@@ -3420,6 +3401,22 @@
 	return sc.order;
 }
 
+/*
+ * pgdat->kswapd_classzone_idx is the highest zone index that a recent
+ * allocation request woke kswapd for. When kswapd has not woken recently,
+ * the value is MAX_NR_ZONES which is not a valid index. This compares a
+ * given classzone and returns it or the highest classzone index kswapd
+ * was recently woke for.
+ */
+static enum zone_type kswapd_classzone_idx(pg_data_t *pgdat,
+					   enum zone_type classzone_idx)
+{
+	if (pgdat->kswapd_classzone_idx == MAX_NR_ZONES)
+		return classzone_idx;
+
+	return max(pgdat->kswapd_classzone_idx, classzone_idx);
+}
+
 static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
 				unsigned int classzone_idx)
 {
@@ -3431,7 +3428,13 @@
 
 	prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
 
-	/* Try to sleep for a short interval */
+	/*
+	 * Try to sleep for a short interval. Note that kcompactd will only be
+	 * woken if it is possible to sleep for a short interval. This is
+	 * deliberate on the assumption that if reclaim cannot keep an
+	 * eligible zone balanced that it's also unlikely that compaction will
+	 * succeed.
+	 */
 	if (prepare_kswapd_sleep(pgdat, reclaim_order, classzone_idx)) {
 		/*
 		 * Compaction records what page blocks it recently failed to
@@ -3455,7 +3458,7 @@
 		 * the previous request that slept prematurely.
 		 */
 		if (remaining) {
-			pgdat->kswapd_classzone_idx = max(pgdat->kswapd_classzone_idx, classzone_idx);
+			pgdat->kswapd_classzone_idx = kswapd_classzone_idx(pgdat, classzone_idx);
 			pgdat->kswapd_order = max(pgdat->kswapd_order, reclaim_order);
 		}
 
@@ -3509,7 +3512,8 @@
  */
 static int kswapd(void *p)
 {
-	unsigned int alloc_order, reclaim_order, classzone_idx;
+	unsigned int alloc_order, reclaim_order;
+	unsigned int classzone_idx = MAX_NR_ZONES - 1;
 	pg_data_t *pgdat = (pg_data_t*)p;
 	struct task_struct *tsk = current;
 
@@ -3539,20 +3543,23 @@
 	tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
 	set_freezable();
 
-	pgdat->kswapd_order = alloc_order = reclaim_order = 0;
-	pgdat->kswapd_classzone_idx = classzone_idx = 0;
+	pgdat->kswapd_order = 0;
+	pgdat->kswapd_classzone_idx = MAX_NR_ZONES;
 	for ( ; ; ) {
 		bool ret;
 
+		alloc_order = reclaim_order = pgdat->kswapd_order;
+		classzone_idx = kswapd_classzone_idx(pgdat, classzone_idx);
+
 kswapd_try_sleep:
 		kswapd_try_to_sleep(pgdat, alloc_order, reclaim_order,
 					classzone_idx);
 
 		/* Read the new order and classzone_idx */
 		alloc_order = reclaim_order = pgdat->kswapd_order;
-		classzone_idx = pgdat->kswapd_classzone_idx;
+		classzone_idx = kswapd_classzone_idx(pgdat, 0);
 		pgdat->kswapd_order = 0;
-		pgdat->kswapd_classzone_idx = 0;
+		pgdat->kswapd_classzone_idx = MAX_NR_ZONES;
 
 		ret = try_to_freeze();
 		if (kthread_should_stop())
@@ -3578,9 +3585,6 @@
 		reclaim_order = balance_pgdat(pgdat, alloc_order, classzone_idx);
 		if (reclaim_order < alloc_order)
 			goto kswapd_try_sleep;
-
-		alloc_order = reclaim_order = pgdat->kswapd_order;
-		classzone_idx = pgdat->kswapd_classzone_idx;
 	}
 
 	tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD);
@@ -3596,7 +3600,6 @@
 void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx)
 {
 	pg_data_t *pgdat;
-	int z;
 
 	if (!managed_zone(zone))
 		return;
@@ -3604,22 +3607,20 @@
 	if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL))
 		return;
 	pgdat = zone->zone_pgdat;
-	pgdat->kswapd_classzone_idx = max(pgdat->kswapd_classzone_idx, classzone_idx);
+	pgdat->kswapd_classzone_idx = kswapd_classzone_idx(pgdat,
+							   classzone_idx);
 	pgdat->kswapd_order = max(pgdat->kswapd_order, order);
 	if (!waitqueue_active(&pgdat->kswapd_wait))
 		return;
 
-	/* Only wake kswapd if all zones are unbalanced */
-	for (z = 0; z <= classzone_idx; z++) {
-		zone = pgdat->node_zones + z;
-		if (!managed_zone(zone))
-			continue;
+	/* Hopeless node, leave it to direct reclaim */
+	if (pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)
+		return;
 
-		if (zone_balanced(zone, order, classzone_idx))
-			return;
-	}
+	if (pgdat_balanced(pgdat, order, classzone_idx))
+		return;
 
-	trace_mm_vmscan_wakeup_kswapd(pgdat->node_id, zone_idx(zone), order);
+	trace_mm_vmscan_wakeup_kswapd(pgdat->node_id, classzone_idx, order);
 	wake_up_interruptible(&pgdat->kswapd_wait);
 }
 
@@ -3879,9 +3880,6 @@
 	    sum_zone_node_page_state(pgdat->node_id, NR_SLAB_RECLAIMABLE) <= pgdat->min_slab_pages)
 		return NODE_RECLAIM_FULL;
 
-	if (!pgdat_reclaimable(pgdat))
-		return NODE_RECLAIM_FULL;
-
 	/*
 	 * Do not scan if the allocation should not be delayed.
 	 */
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 513c37a..2ab7973 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -954,7 +954,6 @@
 	"nr_unevictable",
 	"nr_isolated_anon",
 	"nr_isolated_file",
-	"nr_pages_scanned",
 	"workingset_refault",
 	"workingset_activate",
 	"workingset_nodereclaim",
@@ -1379,7 +1378,6 @@
 		   "\n        min      %lu"
 		   "\n        low      %lu"
 		   "\n        high     %lu"
-		   "\n   node_scanned  %lu"
 		   "\n        spanned  %lu"
 		   "\n        present  %lu"
 		   "\n        managed  %lu",
@@ -1387,7 +1385,6 @@
 		   min_wmark_pages(zone),
 		   low_wmark_pages(zone),
 		   high_wmark_pages(zone),
-		   node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED),
 		   zone->spanned_pages,
 		   zone->present_pages,
 		   zone->managed_pages);
@@ -1426,7 +1423,7 @@
 		   "\n  node_unreclaimable:  %u"
 		   "\n  start_pfn:           %lu"
 		   "\n  node_inactive_ratio: %u",
-		   !pgdat_reclaimable(zone->zone_pgdat),
+		   pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES,
 		   zone->zone_start_pfn,
 		   zone->zone_pgdat->inactive_ratio);
 	seq_putc(m, '\n');
@@ -1588,22 +1585,9 @@
 	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) {
 		val = atomic_long_read(&vm_zone_stat[i]);
 		if (val < 0) {
-			switch (i) {
-			case NR_PAGES_SCANNED:
-				/*
-				 * This is often seen to go negative in
-				 * recent kernels, but not to go permanently
-				 * negative.  Whilst it would be nicer not to
-				 * have exceptions, rooting them out would be
-				 * another task, of rather low priority.
-				 */
-				break;
-			default:
-				pr_warn("%s: %s %ld\n",
-					__func__, vmstat_text[i], val);
-				err = -EINVAL;
-				break;
-			}
+			pr_warn("%s: %s %ld\n",
+				__func__, vmstat_text[i], val);
+			err = -EINVAL;
 		}
 	}
 	if (err)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index fbf251f..4d6b94d 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -484,16 +484,16 @@
 	struct net_device *dev = s->dev;
 	struct sock *sk = s->sock->sk;
 	struct sk_buff *skb;
-	wait_queue_t wait;
+	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 
 	BT_DBG("");
 
 	set_user_nice(current, -15);
 
-	init_waitqueue_entry(&wait, current);
 	add_wait_queue(sk_sleep(sk), &wait);
 	while (1) {
-		set_current_state(TASK_INTERRUPTIBLE);
+		/* Ensure session->terminate is updated */
+		smp_mb__before_atomic();
 
 		if (atomic_read(&s->terminate))
 			break;
@@ -515,9 +515,8 @@
 				break;
 		netif_wake_queue(dev);
 
-		schedule();
+		wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
 	}
-	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(sk_sleep(sk), &wait);
 
 	/* Cleanup session */
@@ -666,7 +665,7 @@
 	s = __bnep_get_session(req->dst);
 	if (s) {
 		atomic_inc(&s->terminate);
-		wake_up_process(s->task);
+		wake_up_interruptible(sk_sleep(s->sock->sk));
 	} else
 		err = -ENOENT;
 
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 9e59b66..1152ce3 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -280,16 +280,16 @@
 	struct cmtp_session *session = arg;
 	struct sock *sk = session->sock->sk;
 	struct sk_buff *skb;
-	wait_queue_t wait;
+	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 
 	BT_DBG("session %p", session);
 
 	set_user_nice(current, -15);
 
-	init_waitqueue_entry(&wait, current);
 	add_wait_queue(sk_sleep(sk), &wait);
 	while (1) {
-		set_current_state(TASK_INTERRUPTIBLE);
+		/* Ensure session->terminate is updated */
+		smp_mb__before_atomic();
 
 		if (atomic_read(&session->terminate))
 			break;
@@ -306,9 +306,8 @@
 
 		cmtp_process_transmit(session);
 
-		schedule();
+		wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
 	}
-	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(sk_sleep(sk), &wait);
 
 	down_write(&cmtp_session_sem);
@@ -393,7 +392,7 @@
 		err = cmtp_attach_device(session);
 		if (err < 0) {
 			atomic_inc(&session->terminate);
-			wake_up_process(session->task);
+			wake_up_interruptible(sk_sleep(session->sock->sk));
 			up_write(&cmtp_session_sem);
 			return err;
 		}
@@ -431,7 +430,11 @@
 
 		/* Stop session thread */
 		atomic_inc(&session->terminate);
-		wake_up_process(session->task);
+
+		/* Ensure session->terminate is updated */
+		smp_mb__after_atomic();
+
+		wake_up_interruptible(sk_sleep(session->sock->sk));
 	} else
 		err = -ENOENT;
 
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 0bec458..1fc0764 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -36,6 +36,7 @@
 #define VERSION "1.2"
 
 static DECLARE_RWSEM(hidp_session_sem);
+static DECLARE_WAIT_QUEUE_HEAD(hidp_session_wq);
 static LIST_HEAD(hidp_session_list);
 
 static unsigned char hidp_keycode[256] = {
@@ -1068,12 +1069,12 @@
  * Wake up session thread and notify it to stop. This is asynchronous and
  * returns immediately. Call this whenever a runtime error occurs and you want
  * the session to stop.
- * Note: wake_up_process() performs any necessary memory-barriers for us.
+ * Note: wake_up_interruptible() performs any necessary memory-barriers for us.
  */
 static void hidp_session_terminate(struct hidp_session *session)
 {
 	atomic_inc(&session->terminate);
-	wake_up_process(session->task);
+	wake_up_interruptible(&hidp_session_wq);
 }
 
 /*
@@ -1180,7 +1181,9 @@
 	struct sock *ctrl_sk = session->ctrl_sock->sk;
 	struct sock *intr_sk = session->intr_sock->sk;
 	struct sk_buff *skb;
+	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 
+	add_wait_queue(&hidp_session_wq, &wait);
 	for (;;) {
 		/*
 		 * This thread can be woken up two ways:
@@ -1188,12 +1191,10 @@
 		 *    session->terminate flag and wakes this thread up.
 		 *  - Via modifying the socket state of ctrl/intr_sock. This
 		 *    thread is woken up by ->sk_state_changed().
-		 *
-		 * Note: set_current_state() performs any necessary
-		 * memory-barriers for us.
 		 */
-		set_current_state(TASK_INTERRUPTIBLE);
 
+		/* Ensure session->terminate is updated */
+		smp_mb__before_atomic();
 		if (atomic_read(&session->terminate))
 			break;
 
@@ -1227,11 +1228,22 @@
 		hidp_process_transmit(session, &session->ctrl_transmit,
 				      session->ctrl_sock);
 
-		schedule();
+		wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
 	}
+	remove_wait_queue(&hidp_session_wq, &wait);
 
 	atomic_inc(&session->terminate);
-	set_current_state(TASK_RUNNING);
+
+	/* Ensure session->terminate is updated */
+	smp_mb__after_atomic();
+}
+
+static int hidp_session_wake_function(wait_queue_t *wait,
+				      unsigned int mode,
+				      int sync, void *key)
+{
+	wake_up_interruptible(&hidp_session_wq);
+	return false;
 }
 
 /*
@@ -1244,7 +1256,8 @@
 static int hidp_session_thread(void *arg)
 {
 	struct hidp_session *session = arg;
-	wait_queue_t ctrl_wait, intr_wait;
+	DEFINE_WAIT_FUNC(ctrl_wait, hidp_session_wake_function);
+	DEFINE_WAIT_FUNC(intr_wait, hidp_session_wake_function);
 
 	BT_DBG("session %p", session);
 
@@ -1254,8 +1267,6 @@
 	set_user_nice(current, -15);
 	hidp_set_timer(session);
 
-	init_waitqueue_entry(&ctrl_wait, current);
-	init_waitqueue_entry(&intr_wait, current);
 	add_wait_queue(sk_sleep(session->ctrl_sock->sk), &ctrl_wait);
 	add_wait_queue(sk_sleep(session->intr_sock->sk), &intr_wait);
 	/* This memory barrier is paired with wq_has_sleeper(). See
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 577f1c0..ffd09c1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -58,7 +58,7 @@
 				       u8 code, u8 ident, u16 dlen, void *data);
 static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
 			   void *data);
-static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data);
+static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data_size);
 static void l2cap_send_disconn_req(struct l2cap_chan *chan, int err);
 
 static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
@@ -1473,7 +1473,7 @@
 
 			set_bit(CONF_REQ_SENT, &chan->conf_state);
 			l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-				       l2cap_build_conf_req(chan, buf), buf);
+				       l2cap_build_conf_req(chan, buf, sizeof(buf)), buf);
 			chan->num_conf_req++;
 		}
 
@@ -2977,12 +2977,15 @@
 	return len;
 }
 
-static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val)
+static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val, size_t size)
 {
 	struct l2cap_conf_opt *opt = *ptr;
 
 	BT_DBG("type 0x%2.2x len %u val 0x%lx", type, len, val);
 
+	if (size < L2CAP_CONF_OPT_SIZE + len)
+		return;
+
 	opt->type = type;
 	opt->len  = len;
 
@@ -3007,7 +3010,7 @@
 	*ptr += L2CAP_CONF_OPT_SIZE + len;
 }
 
-static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
+static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan, size_t size)
 {
 	struct l2cap_conf_efs efs;
 
@@ -3035,7 +3038,7 @@
 	}
 
 	l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs),
-			   (unsigned long) &efs);
+			   (unsigned long) &efs, size);
 }
 
 static void l2cap_ack_timeout(struct work_struct *work)
@@ -3181,11 +3184,12 @@
 	chan->ack_win = chan->tx_win;
 }
 
-static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
+static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data_size)
 {
 	struct l2cap_conf_req *req = data;
 	struct l2cap_conf_rfc rfc = { .mode = chan->mode };
 	void *ptr = req->data;
+	void *endptr = data + data_size;
 	u16 size;
 
 	BT_DBG("chan %p", chan);
@@ -3210,7 +3214,7 @@
 
 done:
 	if (chan->imtu != L2CAP_DEFAULT_MTU)
-		l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu);
+		l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu, endptr - ptr);
 
 	switch (chan->mode) {
 	case L2CAP_MODE_BASIC:
@@ -3229,7 +3233,7 @@
 		rfc.max_pdu_size    = 0;
 
 		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
-				   (unsigned long) &rfc);
+				   (unsigned long) &rfc, endptr - ptr);
 		break;
 
 	case L2CAP_MODE_ERTM:
@@ -3249,21 +3253,21 @@
 				       L2CAP_DEFAULT_TX_WINDOW);
 
 		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
-				   (unsigned long) &rfc);
+				   (unsigned long) &rfc, endptr - ptr);
 
 		if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
-			l2cap_add_opt_efs(&ptr, chan);
+			l2cap_add_opt_efs(&ptr, chan, endptr - ptr);
 
 		if (test_bit(FLAG_EXT_CTRL, &chan->flags))
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2,
-					   chan->tx_win);
+					   chan->tx_win, endptr - ptr);
 
 		if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
 			if (chan->fcs == L2CAP_FCS_NONE ||
 			    test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) {
 				chan->fcs = L2CAP_FCS_NONE;
 				l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
-						   chan->fcs);
+						   chan->fcs, endptr - ptr);
 			}
 		break;
 
@@ -3281,17 +3285,17 @@
 		rfc.max_pdu_size = cpu_to_le16(size);
 
 		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
-				   (unsigned long) &rfc);
+				   (unsigned long) &rfc, endptr - ptr);
 
 		if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
-			l2cap_add_opt_efs(&ptr, chan);
+			l2cap_add_opt_efs(&ptr, chan, endptr - ptr);
 
 		if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
 			if (chan->fcs == L2CAP_FCS_NONE ||
 			    test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) {
 				chan->fcs = L2CAP_FCS_NONE;
 				l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
-						   chan->fcs);
+						   chan->fcs, endptr - ptr);
 			}
 		break;
 	}
@@ -3302,10 +3306,11 @@
 	return ptr - data;
 }
 
-static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
+static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data_size)
 {
 	struct l2cap_conf_rsp *rsp = data;
 	void *ptr = rsp->data;
+	void *endptr = data + data_size;
 	void *req = chan->conf_req;
 	int len = chan->conf_len;
 	int type, hint, olen;
@@ -3407,7 +3412,7 @@
 			return -ECONNREFUSED;
 
 		l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
-				   (unsigned long) &rfc);
+				   (unsigned long) &rfc, endptr - ptr);
 	}
 
 	if (result == L2CAP_CONF_SUCCESS) {
@@ -3420,7 +3425,7 @@
 			chan->omtu = mtu;
 			set_bit(CONF_MTU_DONE, &chan->conf_state);
 		}
-		l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu);
+		l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu, endptr - ptr);
 
 		if (remote_efs) {
 			if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
@@ -3434,7 +3439,7 @@
 
 				l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
 						   sizeof(efs),
-						   (unsigned long) &efs);
+						   (unsigned long) &efs, endptr - ptr);
 			} else {
 				/* Send PENDING Conf Rsp */
 				result = L2CAP_CONF_PENDING;
@@ -3467,7 +3472,7 @@
 			set_bit(CONF_MODE_DONE, &chan->conf_state);
 
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
-					   sizeof(rfc), (unsigned long) &rfc);
+					   sizeof(rfc), (unsigned long) &rfc, endptr - ptr);
 
 			if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
 				chan->remote_id = efs.id;
@@ -3481,7 +3486,7 @@
 					le32_to_cpu(efs.sdu_itime);
 				l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
 						   sizeof(efs),
-						   (unsigned long) &efs);
+						   (unsigned long) &efs, endptr - ptr);
 			}
 			break;
 
@@ -3495,7 +3500,7 @@
 			set_bit(CONF_MODE_DONE, &chan->conf_state);
 
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
-					   (unsigned long) &rfc);
+					   (unsigned long) &rfc, endptr - ptr);
 
 			break;
 
@@ -3517,10 +3522,11 @@
 }
 
 static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
-				void *data, u16 *result)
+				void *data, size_t size, u16 *result)
 {
 	struct l2cap_conf_req *req = data;
 	void *ptr = req->data;
+	void *endptr = data + size;
 	int type, olen;
 	unsigned long val;
 	struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
@@ -3538,13 +3544,13 @@
 				chan->imtu = L2CAP_DEFAULT_MIN_MTU;
 			} else
 				chan->imtu = val;
-			l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu);
+			l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu, endptr - ptr);
 			break;
 
 		case L2CAP_CONF_FLUSH_TO:
 			chan->flush_to = val;
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO,
-					   2, chan->flush_to);
+					   2, chan->flush_to, endptr - ptr);
 			break;
 
 		case L2CAP_CONF_RFC:
@@ -3558,13 +3564,13 @@
 			chan->fcs = 0;
 
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
-					   sizeof(rfc), (unsigned long) &rfc);
+					   sizeof(rfc), (unsigned long) &rfc, endptr - ptr);
 			break;
 
 		case L2CAP_CONF_EWS:
 			chan->ack_win = min_t(u16, val, chan->ack_win);
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2,
-					   chan->tx_win);
+					   chan->tx_win, endptr - ptr);
 			break;
 
 		case L2CAP_CONF_EFS:
@@ -3577,7 +3583,7 @@
 				return -ECONNREFUSED;
 
 			l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
-					   (unsigned long) &efs);
+					   (unsigned long) &efs, endptr - ptr);
 			break;
 
 		case L2CAP_CONF_FCS:
@@ -3682,7 +3688,7 @@
 		return;
 
 	l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-		       l2cap_build_conf_req(chan, buf), buf);
+		       l2cap_build_conf_req(chan, buf, sizeof(buf)), buf);
 	chan->num_conf_req++;
 }
 
@@ -3890,7 +3896,7 @@
 		u8 buf[128];
 		set_bit(CONF_REQ_SENT, &chan->conf_state);
 		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-			       l2cap_build_conf_req(chan, buf), buf);
+			       l2cap_build_conf_req(chan, buf, sizeof(buf)), buf);
 		chan->num_conf_req++;
 	}
 
@@ -3968,7 +3974,7 @@
 			break;
 
 		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-			       l2cap_build_conf_req(chan, req), req);
+			       l2cap_build_conf_req(chan, req, sizeof(req)), req);
 		chan->num_conf_req++;
 		break;
 
@@ -4080,7 +4086,7 @@
 	}
 
 	/* Complete config. */
-	len = l2cap_parse_conf_req(chan, rsp);
+	len = l2cap_parse_conf_req(chan, rsp, sizeof(rsp));
 	if (len < 0) {
 		l2cap_send_disconn_req(chan, ECONNRESET);
 		goto unlock;
@@ -4114,7 +4120,7 @@
 	if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) {
 		u8 buf[64];
 		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-			       l2cap_build_conf_req(chan, buf), buf);
+			       l2cap_build_conf_req(chan, buf, sizeof(buf)), buf);
 		chan->num_conf_req++;
 	}
 
@@ -4174,7 +4180,7 @@
 			char buf[64];
 
 			len = l2cap_parse_conf_rsp(chan, rsp->data, len,
-						   buf, &result);
+						   buf, sizeof(buf), &result);
 			if (len < 0) {
 				l2cap_send_disconn_req(chan, ECONNRESET);
 				goto done;
@@ -4204,7 +4210,7 @@
 			/* throw out any old stored conf requests */
 			result = L2CAP_CONF_SUCCESS;
 			len = l2cap_parse_conf_rsp(chan, rsp->data, len,
-						   req, &result);
+						   req, sizeof(req), &result);
 			if (len < 0) {
 				l2cap_send_disconn_req(chan, ECONNRESET);
 				goto done;
@@ -4781,7 +4787,7 @@
 			set_bit(CONF_REQ_SENT, &chan->conf_state);
 			l2cap_send_cmd(chan->conn, l2cap_get_ident(chan->conn),
 				       L2CAP_CONF_REQ,
-				       l2cap_build_conf_req(chan, buf), buf);
+				       l2cap_build_conf_req(chan, buf, sizeof(buf)), buf);
 			chan->num_conf_req++;
 		}
 	}
@@ -7457,7 +7463,7 @@
 				set_bit(CONF_REQ_SENT, &chan->conf_state);
 				l2cap_send_cmd(conn, l2cap_get_ident(conn),
 					       L2CAP_CONF_REQ,
-					       l2cap_build_conf_req(chan, buf),
+					       l2cap_build_conf_req(chan, buf, sizeof(buf)),
 					       buf);
 				chan->num_conf_req++;
 			}
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index fcaa484..04eea2f 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -48,6 +48,9 @@
 		return NETDEV_TX_OK;
 	}
 
+#ifdef CONFIG_NET_SWITCHDEV
+	skb->offload_fwd_mark = 0;
+#endif
 	BR_INPUT_SKB_CB(skb)->brdev = dev;
 
 	skb_reset_mac_header(skb);
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 58dfa23..4fa4011 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -351,7 +351,7 @@
 	if (flags & MSG_PEEK) {
 		err = -ENOENT;
 		spin_lock_bh(&sk->sk_receive_queue.lock);
-		if (skb == skb_peek(&sk->sk_receive_queue)) {
+		if (skb->next) {
 			__skb_unlink(skb, &sk->sk_receive_queue);
 			atomic_dec(&skb->users);
 			err = 0;
diff --git a/net/core/dev.c b/net/core/dev.c
index 7e168d0..bc129b0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2704,9 +2704,10 @@
 static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
 {
 	if (tx_path)
-		return skb->ip_summed != CHECKSUM_PARTIAL;
-	else
-		return skb->ip_summed == CHECKSUM_NONE;
+		return skb->ip_summed != CHECKSUM_PARTIAL &&
+		       skb->ip_summed != CHECKSUM_UNNECESSARY;
+
+	return skb->ip_summed == CHECKSUM_NONE;
 }
 
 /**
@@ -2725,11 +2726,12 @@
 struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
 				  netdev_features_t features, bool tx_path)
 {
+	struct sk_buff *segs;
+
 	if (unlikely(skb_needs_check(skb, tx_path))) {
 		int err;
 
-		skb_warn_bad_offload(skb);
-
+		/* We're going to init ->check field in TCP or UDP header */
 		err = skb_cow_head(skb, 0);
 		if (err < 0)
 			return ERR_PTR(err);
@@ -2757,7 +2759,12 @@
 	skb_reset_mac_header(skb);
 	skb_reset_mac_len(skb);
 
-	return skb_mac_gso_segment(skb, features);
+	segs = skb_mac_gso_segment(skb, features);
+
+	if (unlikely(skb_needs_check(skb, tx_path)))
+		skb_warn_bad_offload(skb);
+
+	return segs;
 }
 EXPORT_SYMBOL(__skb_gso_segment);
 
@@ -5360,12 +5367,13 @@
  * Find out if a device is linked to an upper device and return true in case
  * it is. The caller must hold the RTNL lock.
  */
-static bool netdev_has_any_upper_dev(struct net_device *dev)
+bool netdev_has_any_upper_dev(struct net_device *dev)
 {
 	ASSERT_RTNL();
 
 	return !list_empty(&dev->all_adj_list.upper);
 }
+EXPORT_SYMBOL(netdev_has_any_upper_dev);
 
 /**
  * netdev_master_upper_dev_get - Get master upper device
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index b94b1d2..151e047 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -28,6 +28,7 @@
 
 	if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
 		return -EFAULT;
+	ifr.ifr_name[IFNAMSIZ-1] = 0;
 
 	error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex);
 	if (error)
diff --git a/net/core/dst.c b/net/core/dst.c
index 39cc119..b5de366 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -349,8 +349,15 @@
 
 	new = ((unsigned long) &dst_default_metrics) | DST_METRICS_READ_ONLY;
 	prev = cmpxchg(&dst->_metrics, old, new);
-	if (prev == old)
-		kfree(__DST_METRICS_PTR(old));
+	if (prev == old) {
+		struct dst_metrics *old_p = (struct dst_metrics *)
+					    __DST_METRICS_PTR(old);
+
+		if (prev & DST_METRICS_REFCOUNTED) {
+			if (atomic_dec_and_test(&old_p->refcnt))
+				kfree(old_p);
+		}
+	}
 }
 EXPORT_SYMBOL(__dst_destroy_metrics_generic);
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 9c6fd7f..4d26297 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1965,7 +1965,8 @@
 		struct sockaddr *sa;
 		int len;
 
-		len = sizeof(sa_family_t) + dev->addr_len;
+		len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len,
+						  sizeof(*sa));
 		sa = kmalloc(len, GFP_KERNEL);
 		if (!sa) {
 			err = -ENOMEM;
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 1704948..f227f00 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -1471,9 +1471,12 @@
 	 * singleton values (which always leads to failure).
 	 * These settings can still (later) be overridden via sockopts.
 	 */
-	if (ccid_get_builtin_ccids(&tx.val, &tx.len) ||
-	    ccid_get_builtin_ccids(&rx.val, &rx.len))
+	if (ccid_get_builtin_ccids(&tx.val, &tx.len))
 		return -ENOBUFS;
+	if (ccid_get_builtin_ccids(&rx.val, &rx.len)) {
+		kfree(tx.val);
+		return -ENOBUFS;
+	}
 
 	if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) ||
 	    !dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len))
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 86b0933..8fc1600 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -637,6 +637,7 @@
 		goto drop_and_free;
 
 	inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
+	reqsk_put(req);
 	return 0;
 
 drop_and_free:
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 2ac9d2a..28e8252 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -380,6 +380,7 @@
 		goto drop_and_free;
 
 	inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
+	reqsk_put(req);
 	return 0;
 
 drop_and_free:
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 9fe25bf..b68168f 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -24,6 +24,7 @@
 #include <net/checksum.h>
 
 #include <net/inet_sock.h>
+#include <net/inet_common.h>
 #include <net/sock.h>
 #include <net/xfrm.h>
 
@@ -170,6 +171,15 @@
 
 EXPORT_SYMBOL_GPL(dccp_packet_name);
 
+static void dccp_sk_destruct(struct sock *sk)
+{
+	struct dccp_sock *dp = dccp_sk(sk);
+
+	ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
+	dp->dccps_hc_tx_ccid = NULL;
+	inet_sock_destruct(sk);
+}
+
 int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
@@ -179,6 +189,7 @@
 	icsk->icsk_syn_retries	= sysctl_dccp_request_retries;
 	sk->sk_state		= DCCP_CLOSED;
 	sk->sk_write_space	= dccp_write_space;
+	sk->sk_destruct		= dccp_sk_destruct;
 	icsk->icsk_sync_mss	= dccp_sync_mss;
 	dp->dccps_mss_cache	= 536;
 	dp->dccps_rate_last	= jiffies;
@@ -201,10 +212,7 @@
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 
-	/*
-	 * DCCP doesn't use sk_write_queue, just sk_send_head
-	 * for retransmissions
-	 */
+	__skb_queue_purge(&sk->sk_write_queue);
 	if (sk->sk_send_head != NULL) {
 		kfree_skb(sk->sk_send_head);
 		sk->sk_send_head = NULL;
@@ -222,8 +230,7 @@
 		dp->dccps_hc_rx_ackvec = NULL;
 	}
 	ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
-	ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
-	dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
+	dp->dccps_hc_rx_ccid = NULL;
 
 	/* clean up feature negotiation state */
 	dccp_feat_list_purge(&dp->dccps_featneg);
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index 30d875d..f85b08b 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -580,19 +580,14 @@
 {
 	struct netns_ieee802154_lowpan *ieee802154_lowpan =
 		net_ieee802154_lowpan(net);
-	int res;
 
 	ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
 	ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH;
 	ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT;
 
-	res = inet_frags_init_net(&ieee802154_lowpan->frags);
-	if (res)
-		return res;
-	res = lowpan_frags_ns_sysctl_register(net);
-	if (res)
-		inet_frags_uninit_net(&ieee802154_lowpan->frags);
-	return res;
+	inet_frags_init_net(&ieee802154_lowpan->frags);
+
+	return lowpan_frags_ns_sysctl_register(net);
 }
 
 static void __net_exit lowpan_frags_exit_net(struct net *net)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ceddf42..2b887c5 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1714,6 +1714,13 @@
 	net->ipv4.sysctl_ip_dynaddr = 0;
 	net->ipv4.sysctl_ip_early_demux = 1;
 
+	/* Some igmp sysctl, whose values are always used */
+	net->ipv4.sysctl_igmp_max_memberships = 20;
+	net->ipv4.sysctl_igmp_max_msf = 10;
+	/* IGMP reports for link-local multicast groups are enabled by default */
+	net->ipv4.sysctl_igmp_llm_reports = 1;
+	net->ipv4.sysctl_igmp_qrv = 2;
+
 	return 0;
 }
 
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 37f4578..c8409ca0 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1320,13 +1320,14 @@
 
 void __init ip_fib_init(void)
 {
-	rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
-	rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
-	rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
+	fib_trie_init();
 
 	register_pernet_subsys(&fib_net_ops);
+
 	register_netdevice_notifier(&fib_netdev_notifier);
 	register_inetaddr_notifier(&fib_inetaddr_notifier);
 
-	fib_trie_init();
+	rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
+	rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
+	rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
 }
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 7563831..38c1c97 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1044,15 +1044,17 @@
 	fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
 	if (!fi)
 		goto failure;
-	fib_info_cnt++;
 	if (cfg->fc_mx) {
 		fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL);
-		if (!fi->fib_metrics)
-			goto failure;
+		if (unlikely(!fi->fib_metrics)) {
+			kfree(fi);
+			return ERR_PTR(err);
+		}
 		atomic_set(&fi->fib_metrics->refcnt, 1);
-	} else
+	} else {
 		fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
-
+	}
+	fib_info_cnt++;
 	fi->fib_net = net;
 	fi->fib_protocol = cfg->fc_protocol;
 	fi->fib_scope = cfg->fc_scope;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 19930da..08575e3 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2974,12 +2974,6 @@
 		goto out_sock;
 	}
 
-	/* Sysctl initialization */
-	net->ipv4.sysctl_igmp_max_memberships = 20;
-	net->ipv4.sysctl_igmp_max_msf = 10;
-	/* IGMP reports for link-local multicast groups are enabled by default */
-	net->ipv4.sysctl_igmp_llm_reports = 1;
-	net->ipv4.sysctl_igmp_qrv = 2;
 	return 0;
 
 out_sock:
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index b5e9317..631c0d0 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -234,10 +234,8 @@
 	cond_resched();
 
 	if (read_seqretry(&f->rnd_seqlock, seq) ||
-	    percpu_counter_sum(&nf->mem))
+	    sum_frag_mem_limit(nf))
 		goto evict_again;
-
-	percpu_counter_destroy(&nf->mem);
 }
 EXPORT_SYMBOL(inet_frags_exit_net);
 
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index bbe7f72..453db95 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -835,8 +835,6 @@
 
 static int __net_init ipv4_frags_init_net(struct net *net)
 {
-	int res;
-
 	/* Fragment cache limits.
 	 *
 	 * The fragment memory accounting code, (tries to) account for
@@ -862,13 +860,9 @@
 
 	net->ipv4.frags.max_dist = 64;
 
-	res = inet_frags_init_net(&net->ipv4.frags);
-	if (res)
-		return res;
-	res = ip4_frags_ns_ctl_register(net);
-	if (res)
-		inet_frags_uninit_net(&net->ipv4.frags);
-	return res;
+	inet_frags_init_net(&net->ipv4.frags);
+
+	return ip4_frags_ns_ctl_register(net);
 }
 
 static void __net_exit ipv4_frags_exit_net(struct net *net)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 2c18bcf..e60f9fa 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -958,10 +958,12 @@
 		csummode = CHECKSUM_PARTIAL;
 
 	cork->length += length;
-	if (((length > mtu) || (skb && skb_is_gso(skb))) &&
+	if ((skb && skb_is_gso(skb)) ||
+	    ((length > mtu) &&
+	    (skb_queue_len(queue) <= 1) &&
 	    (sk->sk_protocol == IPPROTO_UDP) &&
 	    (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&
-	    (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) {
+	    (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx)) {
 		err = ip_ufo_append_data(sk, queue, getfrag, from, length,
 					 hh_len, fragheaderlen, transhdrlen,
 					 maxfraglen, flags);
@@ -1277,6 +1279,7 @@
 		return -EINVAL;
 
 	if ((size + skb->len > mtu) &&
+	    (skb_queue_len(&sk->sk_write_queue) == 1) &&
 	    (sk->sk_protocol == IPPROTO_UDP) &&
 	    (rt->dst.dev->features & NETIF_F_UFO)) {
 		if (skb->ip_summed != CHECKSUM_PARTIAL)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 5719d6b..bd7f183 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -609,8 +609,8 @@
 		ip_rt_put(rt);
 		goto tx_dropped;
 	}
-	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, key->tos,
-		      key->ttl, df, !net_eq(tunnel->net, dev_net(dev)));
+	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, tos, ttl,
+		      df, !net_eq(tunnel->net, dev_net(dev)));
 	return;
 tx_error:
 	dev->stats.tx_errors++;
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index fd82202..146d861 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -126,6 +126,8 @@
 	/* ip_route_me_harder expects skb->dst to be set */
 	skb_dst_set_noref(nskb, skb_dst(oldskb));
 
+	nskb->mark = IP4_REPLY_MARK(net, oldskb->mark);
+
 	skb_reserve(nskb, LL_MAX_HEADER);
 	niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
 				   ip4_dst_hoplimit(skb_dst(nskb)));
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 18c6e79..a4faf30 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1253,7 +1253,7 @@
 	if (mtu)
 		return mtu;
 
-	mtu = dst->dev->mtu;
+	mtu = READ_ONCE(dst->dev->mtu);
 
 	if (unlikely(dst_metric_locked(dst, RTAX_MTU))) {
 		if (rt->rt_uses_gateway && mtu > 576)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 0dc6286..f56a668 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -334,6 +334,7 @@
 	treq = tcp_rsk(req);
 	treq->rcv_isn		= ntohl(th->seq) - 1;
 	treq->snt_isn		= cookie;
+	treq->txhash		= net_tx_rndhash();
 	req->mss		= mss;
 	ireq->ir_num		= ntohs(th->dest);
 	ireq->ir_rmt_port	= th->source;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 51ac77e..ccc484a 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -1010,7 +1010,7 @@
 		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
+		.proc_handler	= proc_douintvec,
 	},
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	{
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 7c90130..4946e8f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2306,6 +2306,10 @@
 	tcp_set_ca_state(sk, TCP_CA_Open);
 	tcp_clear_retrans(tp);
 	inet_csk_delack_init(sk);
+	/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
+	 * issue in __tcp_select_window()
+	 */
+	icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
 	tcp_init_send_head(sk);
 	memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
 	__sk_dst_reset(sk);
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index 0ea66c2..cb8db34 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -83,7 +83,8 @@
 		cwnd_gain:10,	/* current gain for setting cwnd */
 		full_bw_cnt:3,	/* number of rounds without large bw gains */
 		cycle_idx:3,	/* current index in pacing_gain cycle array */
-		unused_b:6;
+		has_seen_rtt:1, /* have we seen an RTT sample yet? */
+		unused_b:5;
 	u32	prior_cwnd;	/* prior cwnd upon entering loss recovery */
 	u32	full_bw;	/* recent bw, to estimate if pipe is full */
 };
@@ -182,6 +183,35 @@
 	return rate >> BW_SCALE;
 }
 
+/* Convert a BBR bw and gain factor to a pacing rate in bytes per second. */
+static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain)
+{
+	u64 rate = bw;
+
+	rate = bbr_rate_bytes_per_sec(sk, rate, gain);
+	rate = min_t(u64, rate, sk->sk_max_pacing_rate);
+	return rate;
+}
+
+/* Initialize pacing rate to: high_gain * init_cwnd / RTT. */
+static void bbr_init_pacing_rate_from_rtt(struct sock *sk)
+{
+	struct tcp_sock *tp = tcp_sk(sk);
+	struct bbr *bbr = inet_csk_ca(sk);
+	u64 bw;
+	u32 rtt_us;
+
+	if (tp->srtt_us) {		/* any RTT sample yet? */
+		rtt_us = max(tp->srtt_us >> 3, 1U);
+		bbr->has_seen_rtt = 1;
+	} else {			 /* no RTT sample yet */
+		rtt_us = USEC_PER_MSEC;	 /* use nominal default RTT */
+	}
+	bw = (u64)tp->snd_cwnd * BW_UNIT;
+	do_div(bw, rtt_us);
+	sk->sk_pacing_rate = bbr_bw_to_pacing_rate(sk, bw, bbr_high_gain);
+}
+
 /* Pace using current bw estimate and a gain factor. In order to help drive the
  * network toward lower queues while maintaining high utilization and low
  * latency, the average pacing rate aims to be slightly (~1%) lower than the
@@ -191,12 +221,13 @@
  */
 static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain)
 {
+	struct tcp_sock *tp = tcp_sk(sk);
 	struct bbr *bbr = inet_csk_ca(sk);
-	u64 rate = bw;
+	u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain);
 
-	rate = bbr_rate_bytes_per_sec(sk, rate, gain);
-	rate = min_t(u64, rate, sk->sk_max_pacing_rate);
-	if (bbr->mode != BBR_STARTUP || rate > sk->sk_pacing_rate)
+	if (unlikely(!bbr->has_seen_rtt && tp->srtt_us))
+		bbr_init_pacing_rate_from_rtt(sk);
+	if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate)
 		sk->sk_pacing_rate = rate;
 }
 
@@ -769,7 +800,6 @@
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct bbr *bbr = inet_csk_ca(sk);
-	u64 bw;
 
 	bbr->prior_cwnd = 0;
 	bbr->tso_segs_goal = 0;	 /* default segs per skb until first ACK */
@@ -785,11 +815,8 @@
 
 	minmax_reset(&bbr->bw, bbr->rtt_cnt, 0);  /* init max bw to 0 */
 
-	/* Initialize pacing rate to: high_gain * init_cwnd / RTT. */
-	bw = (u64)tp->snd_cwnd * BW_UNIT;
-	do_div(bw, (tp->srtt_us >> 3) ? : USEC_PER_MSEC);
-	sk->sk_pacing_rate = 0;		/* force an update of sk_pacing_rate */
-	bbr_set_pacing_rate(sk, bw, bbr_high_gain);
+	bbr->has_seen_rtt = 0;
+	bbr_init_pacing_rate_from_rtt(sk);
 
 	bbr->restore_cwnd = 0;
 	bbr->round_start = 0;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3d980d6..491b03a 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2561,8 +2561,8 @@
 		return;
 
 	/* Reset cwnd to ssthresh in CWR or Recovery (unless it's undone) */
-	if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR ||
-	    (tp->undo_marker && tp->snd_ssthresh < TCP_INFINITE_SSTHRESH)) {
+	if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH &&
+	    (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR || tp->undo_marker)) {
 		tp->snd_cwnd = tp->snd_ssthresh;
 		tp->snd_cwnd_stamp = tcp_time_stamp;
 	}
@@ -3037,8 +3037,7 @@
 			/* delta may not be positive if the socket is locked
 			 * when the retrans timer fires and is rescheduled.
 			 */
-			if (delta > 0)
-				rto = delta;
+			rto = max(delta, 1);
 		}
 		inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto,
 					  TCP_RTO_MAX);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e6bf011..a835716 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3344,6 +3344,9 @@
 	struct sk_buff *buff;
 	int err;
 
+	if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk))
+		return -EHOSTUNREACH; /* Routing failure or similar. */
+
 	tcp_connect_init(sk);
 
 	if (unlikely(tp->repair)) {
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 732060d..d3d3ef6 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -686,7 +686,8 @@
 		goto death;
 	}
 
-	if (!sock_flag(sk, SOCK_KEEPOPEN) || sk->sk_state == TCP_CLOSE)
+	if (!sock_flag(sk, SOCK_KEEPOPEN) ||
+	    ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)))
 		goto out;
 
 	elapsed = keepalive_time_when(tp);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index fe24424..7c1f5f6 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -818,7 +818,7 @@
 	if (is_udplite)  				 /*     UDP-Lite      */
 		csum = udplite_csum(skb);
 
-	else if (sk->sk_no_check_tx) {   /* UDP csum disabled */
+	else if (sk->sk_no_check_tx && !skb_is_gso(skb)) {   /* UDP csum off */
 
 		skb->ip_summed = CHECKSUM_NONE;
 		goto send;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index b2be1d9..6de016f 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -232,7 +232,7 @@
 	if (uh->check == 0)
 		uh->check = CSUM_MANGLED_0;
 
-	skb->ip_summed = CHECKSUM_NONE;
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 	/* If there is no outer header we can fake a checksum offload
 	 * due to the fact that we have already done the checksum in
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index fe5305a..371312b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5485,7 +5485,7 @@
 		 * our DAD process, so we don't need
 		 * to do it again
 		 */
-		if (!(ifp->rt->rt6i_node))
+		if (!rcu_access_pointer(ifp->rt->rt6i_node))
 			ip6_ins_rt(ifp->rt);
 		if (ifp->idev->cnf.forwarding)
 			addrconf_join_anycast(ifp);
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 4345ee3..5da8649 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -148,11 +148,23 @@
 	return fn;
 }
 
-static void node_free(struct fib6_node *fn)
+static void node_free_immediate(struct fib6_node *fn)
 {
 	kmem_cache_free(fib6_node_kmem, fn);
 }
 
+static void node_free_rcu(struct rcu_head *head)
+{
+	struct fib6_node *fn = container_of(head, struct fib6_node, rcu);
+
+	kmem_cache_free(fib6_node_kmem, fn);
+}
+
+static void node_free(struct fib6_node *fn)
+{
+	call_rcu(&fn->rcu, node_free_rcu);
+}
+
 static void rt6_rcu_free(struct rt6_info *rt)
 {
 	call_rcu(&rt->dst.rcu_head, dst_rcu_free);
@@ -189,6 +201,12 @@
 	}
 }
 
+static void fib6_free_table(struct fib6_table *table)
+{
+	inetpeer_invalidate_tree(&table->tb6_peers);
+	kfree(table);
+}
+
 static void fib6_link_table(struct net *net, struct fib6_table *tb)
 {
 	unsigned int h;
@@ -589,9 +607,9 @@
 
 		if (!in || !ln) {
 			if (in)
-				node_free(in);
+				node_free_immediate(in);
 			if (ln)
-				node_free(ln);
+				node_free_immediate(ln);
 			return ERR_PTR(-ENOMEM);
 		}
 
@@ -862,7 +880,7 @@
 
 		rt->dst.rt6_next = iter;
 		*ins = rt;
-		rt->rt6i_node = fn;
+		rcu_assign_pointer(rt->rt6i_node, fn);
 		atomic_inc(&rt->rt6i_ref);
 		inet6_rt_notify(RTM_NEWROUTE, rt, info, nlflags);
 		info->nl_net->ipv6.rt6_stats->fib_rt_entries++;
@@ -887,7 +905,7 @@
 			return err;
 
 		*ins = rt;
-		rt->rt6i_node = fn;
+		rcu_assign_pointer(rt->rt6i_node, fn);
 		rt->dst.rt6_next = iter->dst.rt6_next;
 		atomic_inc(&rt->rt6i_ref);
 		inet6_rt_notify(RTM_NEWROUTE, rt, info, NLM_F_REPLACE);
@@ -897,6 +915,8 @@
 		}
 		nsiblings = iter->rt6i_nsiblings;
 		fib6_purge_rt(iter, fn, info->nl_net);
+		if (fn->rr_ptr == iter)
+			fn->rr_ptr = NULL;
 		rt6_release(iter);
 
 		if (nsiblings) {
@@ -909,6 +929,8 @@
 				if (rt6_qualify_for_ecmp(iter)) {
 					*ins = iter->dst.rt6_next;
 					fib6_purge_rt(iter, fn, info->nl_net);
+					if (fn->rr_ptr == iter)
+						fn->rr_ptr = NULL;
 					rt6_release(iter);
 					nsiblings--;
 				} else {
@@ -997,7 +1019,7 @@
 			/* Create subtree root node */
 			sfn = node_alloc();
 			if (!sfn)
-				goto st_failure;
+				goto failure;
 
 			sfn->leaf = info->nl_net->ipv6.ip6_null_entry;
 			atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref);
@@ -1013,12 +1035,12 @@
 
 			if (IS_ERR(sn)) {
 				/* If it is failed, discard just allocated
-				   root, and then (in st_failure) stale node
+				   root, and then (in failure) stale node
 				   in main tree.
 				 */
-				node_free(sfn);
+				node_free_immediate(sfn);
 				err = PTR_ERR(sn);
-				goto st_failure;
+				goto failure;
 			}
 
 			/* Now link new subtree to main tree */
@@ -1032,7 +1054,7 @@
 
 			if (IS_ERR(sn)) {
 				err = PTR_ERR(sn);
-				goto st_failure;
+				goto failure;
 			}
 		}
 
@@ -1074,22 +1096,22 @@
 			atomic_inc(&pn->leaf->rt6i_ref);
 		}
 #endif
-		if (!(rt->dst.flags & DST_NOCACHE))
-			dst_free(&rt->dst);
+		goto failure;
 	}
 	return err;
 
-#ifdef CONFIG_IPV6_SUBTREES
-	/* Subtree creation failed, probably main tree node
-	   is orphan. If it is, shoot it.
+failure:
+	/* fn->leaf could be NULL if fn is an intermediate node and we
+	 * failed to add the new route to it in both subtree creation
+	 * failure and fib6_add_rt2node() failure case.
+	 * In both cases, fib6_repair_tree() should be called to fix
+	 * fn->leaf.
 	 */
-st_failure:
 	if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)))
 		fib6_repair_tree(info->nl_net, fn);
 	if (!(rt->dst.flags & DST_NOCACHE))
 		dst_free(&rt->dst);
 	return err;
-#endif
 }
 
 /*
@@ -1443,8 +1465,9 @@
 
 int fib6_del(struct rt6_info *rt, struct nl_info *info)
 {
+	struct fib6_node *fn = rcu_dereference_protected(rt->rt6i_node,
+				    lockdep_is_held(&rt->rt6i_table->tb6_lock));
 	struct net *net = info->nl_net;
-	struct fib6_node *fn = rt->rt6i_node;
 	struct rt6_info **rtp;
 
 #if RT6_DEBUG >= 2
@@ -1633,7 +1656,9 @@
 			if (res) {
 #if RT6_DEBUG >= 2
 				pr_debug("%s: del failed: rt=%p@%p err=%d\n",
-					 __func__, rt, rt->rt6i_node, res);
+					 __func__, rt,
+					 rcu_access_pointer(rt->rt6i_node),
+					 res);
 #endif
 				continue;
 			}
@@ -1874,15 +1899,22 @@
 
 static void fib6_net_exit(struct net *net)
 {
+	unsigned int i;
+
 	rt6_ifdown(net, NULL);
 	del_timer_sync(&net->ipv6.ip6_fib_timer);
 
-#ifdef CONFIG_IPV6_MULTIPLE_TABLES
-	inetpeer_invalidate_tree(&net->ipv6.fib6_local_tbl->tb6_peers);
-	kfree(net->ipv6.fib6_local_tbl);
-#endif
-	inetpeer_invalidate_tree(&net->ipv6.fib6_main_tbl->tb6_peers);
-	kfree(net->ipv6.fib6_main_tbl);
+	for (i = 0; i < FIB6_TABLE_HASHSZ; i++) {
+		struct hlist_head *head = &net->ipv6.fib_table_hash[i];
+		struct hlist_node *tmp;
+		struct fib6_table *tb;
+
+		hlist_for_each_entry_safe(tb, tmp, head, tb6_hlist) {
+			hlist_del(&tb->tb6_hlist);
+			fib6_free_table(tb);
+		}
+	}
+
 	kfree(net->ipv6.fib_table_hash);
 	kfree(net->ipv6.rt6_stats);
 }
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c329a15..ae87b9a 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -432,7 +432,9 @@
 		}
 		break;
 	case ICMPV6_PKT_TOOBIG:
-		mtu = be32_to_cpu(info) - offset;
+		mtu = be32_to_cpu(info) - offset - t->tun_hlen;
+		if (t->dev->type == ARPHRD_ETHER)
+			mtu -= ETH_HLEN;
 		if (mtu < IPV6_MIN_MTU)
 			mtu = IPV6_MIN_MTU;
 		t->dev->mtu = mtu;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 3e42221..821aa0b 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -671,8 +671,6 @@
 		*prevhdr = NEXTHDR_FRAGMENT;
 		tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC);
 		if (!tmp_hdr) {
-			IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
-				      IPSTATS_MIB_FRAGFAILS);
 			err = -ENOMEM;
 			goto fail;
 		}
@@ -791,8 +789,6 @@
 		frag = alloc_skb(len + hlen + sizeof(struct frag_hdr) +
 				 hroom + troom, GFP_ATOMIC);
 		if (!frag) {
-			IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
-				      IPSTATS_MIB_FRAGFAILS);
 			err = -ENOMEM;
 			goto fail;
 		}
@@ -1384,11 +1380,12 @@
 	 */
 
 	cork->length += length;
-	if (((length > mtu) ||
-	     (skb && skb_is_gso(skb))) &&
+	if ((skb && skb_is_gso(skb)) ||
+	    (((length + fragheaderlen) > mtu) &&
+	    (skb_queue_len(queue) <= 1) &&
 	    (sk->sk_protocol == IPPROTO_UDP) &&
 	    (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&
-	    (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
+	    (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk))) {
 		err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
 					  hh_len, fragheaderlen, exthdrlen,
 					  transhdrlen, mtu, flags, fl6);
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 986d4ca..b263bf3 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -622,18 +622,12 @@
 
 static int nf_ct_net_init(struct net *net)
 {
-	int res;
-
 	net->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
 	net->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
 	net->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT;
-	res = inet_frags_init_net(&net->nf_frag.frags);
-	if (res)
-		return res;
-	res = nf_ct_frag6_sysctl_register(net);
-	if (res)
-		inet_frags_uninit_net(&net->nf_frag.frags);
-	return res;
+	inet_frags_init_net(&net->nf_frag.frags);
+
+	return nf_ct_frag6_sysctl_register(net);
 }
 
 static void nf_ct_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 1009040..eedee5d 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -157,6 +157,7 @@
 	fl6.fl6_sport = otcph->dest;
 	fl6.fl6_dport = otcph->source;
 	fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev);
+	fl6.flowi6_mark = IP6_REPLY_MARK(net, oldskb->mark);
 	security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
 	dst = ip6_route_output(net, NULL, &fl6);
 	if (dst->error) {
@@ -180,6 +181,8 @@
 
 	skb_dst_set(nskb, dst);
 
+	nskb->mark = fl6.flowi6_mark;
+
 	skb_reserve(nskb, hh_len + dst->header_len);
 	ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
 				    ip6_dst_hoplimit(dst));
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index e9065b8..a338bbc 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -78,7 +78,7 @@
 
 int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 {
-	u16 offset = sizeof(struct ipv6hdr);
+	unsigned int offset = sizeof(struct ipv6hdr);
 	unsigned int packet_len = skb_tail_pointer(skb) -
 		skb_network_header(skb);
 	int found_rhdr = 0;
@@ -112,6 +112,8 @@
 		exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
 						 offset);
 		offset += ipv6_optlen(exthdr);
+		if (offset > IPV6_MAXPLEN)
+			return -EINVAL;
 		*nexthdr = &exthdr->nexthdr;
 	}
 
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 3815e85..e585c0a 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -709,19 +709,13 @@
 
 static int __net_init ipv6_frags_init_net(struct net *net)
 {
-	int res;
-
 	net->ipv6.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
 	net->ipv6.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
 	net->ipv6.frags.timeout = IPV6_FRAG_TIMEOUT;
 
-	res = inet_frags_init_net(&net->ipv6.frags);
-	if (res)
-		return res;
-	res = ip6_frags_ns_sysctl_register(net);
-	if (res)
-		inet_frags_uninit_net(&net->ipv6.frags);
-	return res;
+	inet_frags_init_net(&net->ipv6.frags);
+
+	return ip6_frags_ns_sysctl_register(net);
 }
 
 static void __net_exit ipv6_frags_exit_net(struct net *net)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d8123f6..5acd855 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1261,7 +1261,9 @@
 
 static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
 {
-	if (!rt->rt6i_node || (rt->rt6i_node->fn_sernum != cookie))
+	u32 rt_cookie = 0;
+
+	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
 		return NULL;
 
 	if (rt6_check_expired(rt))
@@ -1329,8 +1331,14 @@
 		if (rt->rt6i_flags & RTF_CACHE) {
 			dst_hold(&rt->dst);
 			ip6_del_rt(rt);
-		} else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) {
-			rt->rt6i_node->fn_sernum = -1;
+		} else {
+			struct fib6_node *fn;
+
+			rcu_read_lock();
+			fn = rcu_dereference(rt->rt6i_node);
+			if (fn && (rt->rt6i_flags & RTF_DEFAULT))
+				fn->fn_sernum = -1;
+			rcu_read_unlock();
 		}
 	}
 }
@@ -1347,7 +1355,8 @@
 static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
 {
 	return !(rt->rt6i_flags & RTF_CACHE) &&
-		(rt->rt6i_flags & RTF_PCPU || rt->rt6i_node);
+		(rt->rt6i_flags & RTF_PCPU ||
+		 rcu_access_pointer(rt->rt6i_node));
 }
 
 static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 97830a6..a67174e 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -209,6 +209,7 @@
 	treq->snt_synack.v64	= 0;
 	treq->rcv_isn = ntohl(th->seq) - 1;
 	treq->snt_isn = cookie;
+	treq->txhash = net_tx_rndhash();
 
 	/*
 	 * We need to lookup the dst_entry to get the correct window size.
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index c925fd9..c43ef0c 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -915,6 +915,7 @@
 		 */
 		offset = skb_transport_offset(skb);
 		skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);
+		csum = skb->csum;
 
 		skb->ip_summed = CHECKSUM_NONE;
 
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index a2267f8..e7d378c 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -72,7 +72,7 @@
 		if (uh->check == 0)
 			uh->check = CSUM_MANGLED_0;
 
-		skb->ip_summed = CHECKSUM_NONE;
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* If there is no outer header we can fake a checksum offload
 		 * due to the fact that we have already done the checksum in
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 391c3cb..101ed6c 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -2223,7 +2223,7 @@
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self = irda_sk(sk);
-	struct irda_device_list list;
+	struct irda_device_list list = { 0 };
 	struct irda_device_info *discoveries;
 	struct irda_ias_set *	ias_opt;	/* IAS get/query params */
 	struct ias_object *	ias_obj;	/* Object in IAS */
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index fecad10..7eb0e8f 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1381,6 +1381,10 @@
 	if (!csk)
 		return -EINVAL;
 
+	/* We must prevent loops or risk deadlock ! */
+	if (csk->sk_family == PF_KCM)
+		return -EOPNOTSUPP;
+
 	psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL);
 	if (!psock)
 		return -ENOMEM;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index d8d95b6..94bf810 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -63,6 +63,7 @@
 		} u;
 		struct sk_buff	*skb;
 	} dump;
+	struct mutex dump_lock;
 };
 
 static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len,
@@ -143,6 +144,7 @@
 {
 	struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
 	struct sock *sk;
+	struct pfkey_sock *pfk;
 	int err;
 
 	if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
@@ -157,6 +159,9 @@
 	if (sk == NULL)
 		goto out;
 
+	pfk = pfkey_sk(sk);
+	mutex_init(&pfk->dump_lock);
+
 	sock->ops = &pfkey_ops;
 	sock_init_data(sock, sk);
 
@@ -223,7 +228,7 @@
 #define BROADCAST_ONE		1
 #define BROADCAST_REGISTERED	2
 #define BROADCAST_PROMISC_ONLY	4
-static int pfkey_broadcast(struct sk_buff *skb,
+static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
 			   int broadcast_flags, struct sock *one_sk,
 			   struct net *net)
 {
@@ -273,7 +278,7 @@
 	rcu_read_unlock();
 
 	if (one_sk != NULL)
-		err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk);
+		err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
 
 	kfree_skb(skb2);
 	kfree_skb(skb);
@@ -285,23 +290,36 @@
 	struct sadb_msg *hdr;
 	int rc;
 
+	mutex_lock(&pfk->dump_lock);
+	if (!pfk->dump.dump) {
+		rc = 0;
+		goto out;
+	}
+
 	rc = pfk->dump.dump(pfk);
-	if (rc == -ENOBUFS)
-		return 0;
+	if (rc == -ENOBUFS) {
+		rc = 0;
+		goto out;
+	}
 
 	if (pfk->dump.skb) {
-		if (!pfkey_can_dump(&pfk->sk))
-			return 0;
+		if (!pfkey_can_dump(&pfk->sk)) {
+			rc = 0;
+			goto out;
+		}
 
 		hdr = (struct sadb_msg *) pfk->dump.skb->data;
 		hdr->sadb_msg_seq = 0;
 		hdr->sadb_msg_errno = rc;
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 		pfk->dump.skb = NULL;
 	}
 
 	pfkey_terminate_dump(pfk);
+
+out:
+	mutex_unlock(&pfk->dump_lock);
 	return rc;
 }
 
@@ -337,7 +355,7 @@
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
 			     sizeof(uint64_t));
 
-	pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+	pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk));
 
 	return 0;
 }
@@ -1378,7 +1396,7 @@
 
 	xfrm_state_put(x);
 
-	pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net);
+	pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net);
 
 	return 0;
 }
@@ -1465,7 +1483,7 @@
 	hdr->sadb_msg_seq = c->seq;
 	hdr->sadb_msg_pid = c->portid;
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x));
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
 
 	return 0;
 }
@@ -1578,7 +1596,7 @@
 	out_hdr->sadb_msg_reserved = 0;
 	out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
 	out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-	pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk));
 
 	return 0;
 }
@@ -1683,8 +1701,8 @@
 		return -ENOBUFS;
 	}
 
-	pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk));
-
+	pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,
+			sock_net(sk));
 	return 0;
 }
 
@@ -1702,7 +1720,8 @@
 	hdr->sadb_msg_errno = (uint8_t) 0;
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 
-	return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk,
+			       sock_net(sk));
 }
 
 static int key_notify_sa_flush(const struct km_event *c)
@@ -1723,7 +1742,7 @@
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 	hdr->sadb_msg_reserved = 0;
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net);
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 
 	return 0;
 }
@@ -1780,7 +1799,7 @@
 	out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
 	if (pfk->dump.skb)
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 	pfk->dump.skb = out_skb;
 
@@ -1806,19 +1825,26 @@
 	struct xfrm_address_filter *filter = NULL;
 	struct pfkey_sock *pfk = pfkey_sk(sk);
 
-	if (pfk->dump.dump != NULL)
+	mutex_lock(&pfk->dump_lock);
+	if (pfk->dump.dump != NULL) {
+		mutex_unlock(&pfk->dump_lock);
 		return -EBUSY;
+	}
 
 	proto = pfkey_satype2proto(hdr->sadb_msg_satype);
-	if (proto == 0)
+	if (proto == 0) {
+		mutex_unlock(&pfk->dump_lock);
 		return -EINVAL;
+	}
 
 	if (ext_hdrs[SADB_X_EXT_FILTER - 1]) {
 		struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1];
 
 		filter = kmalloc(sizeof(*filter), GFP_KERNEL);
-		if (filter == NULL)
+		if (filter == NULL) {
+			mutex_unlock(&pfk->dump_lock);
 			return -ENOMEM;
+		}
 
 		memcpy(&filter->saddr, &xfilter->sadb_x_filter_saddr,
 		       sizeof(xfrm_address_t));
@@ -1834,6 +1860,7 @@
 	pfk->dump.dump = pfkey_dump_sa;
 	pfk->dump.done = pfkey_dump_sa_done;
 	xfrm_state_walk_init(&pfk->dump.u.state, proto, filter);
+	mutex_unlock(&pfk->dump_lock);
 
 	return pfkey_do_dump(pfk);
 }
@@ -1860,7 +1887,7 @@
 		new_hdr->sadb_msg_errno = 0;
 	}
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk));
+	pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk));
 	return 0;
 }
 
@@ -2193,7 +2220,7 @@
 	out_hdr->sadb_msg_errno = 0;
 	out_hdr->sadb_msg_seq = c->seq;
 	out_hdr->sadb_msg_pid = c->portid;
-	pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
 	return 0;
 
 }
@@ -2413,7 +2440,7 @@
 	out_hdr->sadb_msg_errno = 0;
 	out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
 	out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-	pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp));
 	err = 0;
 
 out:
@@ -2669,7 +2696,7 @@
 	out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
 	if (pfk->dump.skb)
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 	pfk->dump.skb = out_skb;
 
@@ -2693,14 +2720,18 @@
 {
 	struct pfkey_sock *pfk = pfkey_sk(sk);
 
-	if (pfk->dump.dump != NULL)
+	mutex_lock(&pfk->dump_lock);
+	if (pfk->dump.dump != NULL) {
+		mutex_unlock(&pfk->dump_lock);
 		return -EBUSY;
+	}
 
 	pfk->dump.msg_version = hdr->sadb_msg_version;
 	pfk->dump.msg_portid = hdr->sadb_msg_pid;
 	pfk->dump.dump = pfkey_dump_sp;
 	pfk->dump.done = pfkey_dump_sp_done;
 	xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN);
+	mutex_unlock(&pfk->dump_lock);
 
 	return pfkey_do_dump(pfk);
 }
@@ -2722,7 +2753,7 @@
 	hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 	hdr->sadb_msg_reserved = 0;
-	pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net);
+	pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 	return 0;
 
 }
@@ -2784,7 +2815,7 @@
 	void *ext_hdrs[SADB_EXT_MAX];
 	int err;
 
-	pfkey_broadcast(skb_clone(skb, GFP_KERNEL),
+	pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
 			BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
 
 	memset(ext_hdrs, 0, sizeof(ext_hdrs));
@@ -3006,7 +3037,8 @@
 	out_hdr->sadb_msg_seq = 0;
 	out_hdr->sadb_msg_pid = 0;
 
-	pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			xs_net(x));
 	return 0;
 }
 
@@ -3196,7 +3228,8 @@
 		       xfrm_ctx->ctx_len);
 	}
 
-	return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			       xs_net(x));
 }
 
 static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
@@ -3394,7 +3427,8 @@
 	n_port->sadb_x_nat_t_port_port = sport;
 	n_port->sadb_x_nat_t_port_reserved = 0;
 
-	return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			       xs_net(x));
 }
 
 #ifdef CONFIG_NET_KEY_MIGRATE
@@ -3586,7 +3620,7 @@
 	}
 
 	/* broadcast migrate message to sockets */
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net);
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);
 
 	return 0;
 
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 74d0d33..96efe47 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -64,7 +64,7 @@
 	struct sock *sk;
 
 	sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
-		const struct in6_addr *addr = inet6_rcv_saddr(sk);
+		const struct in6_addr *sk_laddr = inet6_rcv_saddr(sk);
 		struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);
 
 		if (l2tp == NULL)
@@ -72,7 +72,7 @@
 
 		if ((l2tp->conn_id == tunnel_id) &&
 		    net_eq(sock_net(sk), net) &&
-		    (!addr || ipv6_addr_equal(addr, laddr)) &&
+		    (!sk_laddr || ipv6_addr_any(sk_laddr) || ipv6_addr_equal(sk_laddr, laddr)) &&
 		    (!sk->sk_bound_dev_if || !dif ||
 		     sk->sk_bound_dev_if == dif))
 			goto found;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 19b89b1..ff2d32e 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -298,7 +298,7 @@
 static void
 clean_from_lists(struct nf_conn *ct)
 {
-	pr_debug("clean_from_lists(%p)\n", ct);
+	pr_debug("clean_from_lists(%pK)\n", ct);
 	hlist_nulls_del_rcu(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
 	hlist_nulls_del_rcu(&ct->tuplehash[IP_CT_DIR_REPLY].hnnode);
 
@@ -384,7 +384,7 @@
 	struct nf_conn *ct = (struct nf_conn *)nfct;
 	struct nf_conntrack_l4proto *l4proto;
 
-	pr_debug("destroy_conntrack(%p)\n", ct);
+	pr_debug("destroy_conntrack(%pK)\n", ct);
 	NF_CT_ASSERT(atomic_read(&nfct->use) == 0);
 
 	if (unlikely(nf_ct_is_template(ct))) {
@@ -413,7 +413,7 @@
 	if (ct->master)
 		nf_ct_put(ct->master);
 
-	pr_debug("destroy_conntrack: returning ct=%p to slab\n", ct);
+	pr_debug("destroy_conntrack: returning ct=%pK to slab\n", ct);
 	nf_conntrack_free(ct);
 }
 
@@ -747,7 +747,7 @@
 	 * confirmed us.
 	 */
 	NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
-	pr_debug("Confirming conntrack %p\n", ct);
+	pr_debug("Confirming conntrack %pK\n", ct);
 	/* We have to check the DYING flag after unlink to prevent
 	 * a race against nf_ct_get_next_corpse() possibly called from
 	 * user context, else we insert an already 'dead' hash, blocking
@@ -1177,7 +1177,7 @@
 		spin_lock(&nf_conntrack_expect_lock);
 		exp = nf_ct_find_expectation(net, zone, tuple);
 		if (exp) {
-			pr_debug("expectation arrives ct=%p exp=%p\n",
+			pr_debug("expectation arrives ct=%pK exp=%pK\n",
 				 ct, exp);
 			/* Welcome, Mr. Bond.  We've been expecting you... */
 			__set_bit(IPS_EXPECTED_BIT, &ct->status);
@@ -1266,13 +1266,13 @@
 	} else {
 		/* Once we've had two way comms, always ESTABLISHED. */
 		if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
-			pr_debug("normal packet for %p\n", ct);
+			pr_debug("normal packet for %pK\n", ct);
 			*ctinfo = IP_CT_ESTABLISHED;
 		} else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
-			pr_debug("related packet for %p\n", ct);
+			pr_debug("related packet for %pK\n", ct);
 			*ctinfo = IP_CT_RELATED;
 		} else {
-			pr_debug("new packet for %p\n", ct);
+			pr_debug("new packet for %pK\n", ct);
 			*ctinfo = IP_CT_NEW;
 		}
 		*set_reply = 0;
@@ -1414,7 +1414,7 @@
 	/* Should be unconfirmed, so not in hash table yet */
 	NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
 
-	pr_debug("Altering reply tuple of %p to ", ct);
+	pr_debug("Altering reply tuple of %pK to ", ct);
 	nf_ct_dump_tuple(newreply);
 
 	ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index 02bcf00..008299b 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -53,7 +53,11 @@
 
 	rcu_read_lock();
 	t = rcu_dereference(nf_ct_ext_types[id]);
-	BUG_ON(t == NULL);
+	if (!t) {
+		rcu_read_unlock();
+		return NULL;
+	}
+
 	off = ALIGN(sizeof(struct nf_ct_ext), t->align);
 	len = off + t->len + var_alloc_len;
 	alloc_size = t->alloc_size + var_alloc_len;
@@ -88,7 +92,10 @@
 
 	rcu_read_lock();
 	t = rcu_dereference(nf_ct_ext_types[id]);
-	BUG_ON(t == NULL);
+	if (!t) {
+		rcu_read_unlock();
+		return NULL;
+	}
 
 	newoff = ALIGN(old->len, t->align);
 	newlen = newoff + t->len + var_alloc_len;
@@ -175,6 +182,6 @@
 	RCU_INIT_POINTER(nf_ct_ext_types[type->id], NULL);
 	update_alloc_size(type);
 	mutex_unlock(&nf_ct_ext_type_mutex);
-	rcu_barrier(); /* Wait for completion of call_rcu()'s */
+	synchronize_rcu();
 }
 EXPORT_SYMBOL_GPL(nf_ct_extend_unregister);
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 5b9c884..dde64c4 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -225,20 +225,21 @@
 		.tuple = tuple,
 		.zone = zone
 	};
-	struct rhlist_head *hl;
+	struct rhlist_head *hl, *h;
 
 	hl = rhltable_lookup(&nf_nat_bysource_table, &key,
 			     nf_nat_bysource_params);
-	if (!hl)
-		return 0;
 
-	ct = container_of(hl, typeof(*ct), nat_bysource);
+	rhl_for_each_entry_rcu(ct, h, hl, nat_bysource) {
+		nf_ct_invert_tuplepr(result,
+				     &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+		result->dst = tuple->dst;
 
-	nf_ct_invert_tuplepr(result,
-			     &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
-	result->dst = tuple->dst;
+		if (in_range(l3proto, l4proto, result, range))
+			return 1;
+	}
 
-	return in_range(l3proto, l4proto, result, range);
+	return 0;
 }
 
 /* For [FUTURE] fragmentation handling, we want the least-used
diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c
index 1fbe4b6..1cf2874 100644
--- a/net/netfilter/xt_qtaguid.c
+++ b/net/netfilter/xt_qtaguid.c
@@ -1597,14 +1597,6 @@
 	if (sk) {
 		MT_DEBUG("qtaguid: %p->sk_proto=%u "
 			 "->sk_state=%d\n", sk, sk->sk_protocol, sk->sk_state);
-		/*
-		 * When in TCP_TIME_WAIT the sk is not a "struct sock" but
-		 * "struct inet_timewait_sock" which is missing fields.
-		 */
-		if (!sk_fullsock(sk) || sk->sk_state  == TCP_TIME_WAIT) {
-			sock_gen_put(sk);
-			sk = NULL;
-		}
 	}
 	return sk;
 }
@@ -1697,10 +1689,25 @@
 		 */
 		sk = qtaguid_find_sk(skb, par);
 		/*
-		 * If we got the socket from the find_sk(), we will need to put
-		 * it back, as nf_tproxy_get_sock_v4() got it.
+		 * TCP_NEW_SYN_RECV are not "struct sock" but "struct request_sock"
+		 * where we can get a pointer to a full socket to retrieve uid/gid.
+		 * When in TCP_TIME_WAIT, sk is a struct inet_timewait_sock
+		 * which is missing fields and does not contain any reference
+		 * to a full socket, so just ignore the socket.
 		 */
-		got_sock = sk;
+		if (sk && sk->sk_state == TCP_NEW_SYN_RECV) {
+			sock_gen_put(sk);
+			sk = sk_to_full_sk(sk);
+		} else if (sk && (!sk_fullsock(sk) || sk->sk_state == TCP_TIME_WAIT)) {
+			sock_gen_put(sk);
+			sk = NULL;
+		} else {
+			/*
+			 * If we got the socket from the find_sk(), we will need to put
+			 * it back, as nf_tproxy_get_sock_v4() got it.
+			 */
+			got_sock = sk;
+		}
 		if (sk)
 			atomic64_inc(&qtu_events.match_found_sk_in_ct);
 		else
@@ -1710,18 +1717,9 @@
 	}
 	MT_DEBUG("qtaguid[%d]: sk=%p got_sock=%d fam=%d proto=%d\n",
 		 par->hooknum, sk, got_sock, par->family, ipx_proto(skb, par));
-	if (sk != NULL) {
-		set_sk_callback_lock = true;
-		read_lock_bh(&sk->sk_callback_lock);
-		MT_DEBUG("qtaguid[%d]: sk=%p->sk_socket=%p->file=%p\n",
-			par->hooknum, sk, sk->sk_socket,
-			sk->sk_socket ? sk->sk_socket->file : (void *)-1LL);
-		filp = sk->sk_socket ? sk->sk_socket->file : NULL;
-		MT_DEBUG("qtaguid[%d]: filp...uid=%u\n",
-			par->hooknum, filp ? from_kuid(&init_user_ns, filp->f_cred->fsuid) : -1);
-	}
 
-	if (sk == NULL || sk->sk_socket == NULL) {
+
+	if (sk == NULL) {
 		/*
 		 * Here, the qtaguid_find_sk() using connection tracking
 		 * couldn't find the owner, so for now we just count them
@@ -1734,9 +1732,7 @@
 		 */
 		if (!(info->match & XT_QTAGUID_UID))
 			account_for_uid(skb, sk, 0, par);
-		MT_DEBUG("qtaguid[%d]: leaving (sk?sk->sk_socket)=%p\n",
-			par->hooknum,
-			sk ? sk->sk_socket : NULL);
+		MT_DEBUG("qtaguid[%d]: leaving (sk=NULL)\n", par->hooknum);
 		res = (info->match ^ info->invert) == 0;
 		atomic64_inc(&qtu_events.match_no_sk);
 		goto put_sock_ret_res;
@@ -1744,16 +1740,7 @@
 		res = false;
 		goto put_sock_ret_res;
 	}
-	filp = sk->sk_socket->file;
-	if (filp == NULL) {
-		MT_DEBUG("qtaguid[%d]: leaving filp=NULL\n", par->hooknum);
-		account_for_uid(skb, sk, 0, par);
-		res = ((info->match ^ info->invert) &
-			(XT_QTAGUID_UID | XT_QTAGUID_GID)) == 0;
-		atomic64_inc(&qtu_events.match_no_sk_file);
-		goto put_sock_ret_res;
-	}
-	sock_uid = filp->f_cred->fsuid;
+	sock_uid = sk->sk_uid;
 	/*
 	 * TODO: unhack how to force just accounting.
 	 * For now we only do iface stats when the uid-owner is not requested
@@ -1771,8 +1758,8 @@
 		kuid_t uid_min = make_kuid(&init_user_ns, info->uid_min);
 		kuid_t uid_max = make_kuid(&init_user_ns, info->uid_max);
 
-		if ((uid_gte(filp->f_cred->fsuid, uid_min) &&
-		     uid_lte(filp->f_cred->fsuid, uid_max)) ^
+		if ((uid_gte(sk->sk_uid, uid_min) &&
+		     uid_lte(sk->sk_uid, uid_max)) ^
 		    !(info->invert & XT_QTAGUID_UID)) {
 			MT_DEBUG("qtaguid[%d]: leaving uid not matching\n",
 				 par->hooknum);
@@ -1783,7 +1770,19 @@
 	if (info->match & XT_QTAGUID_GID) {
 		kgid_t gid_min = make_kgid(&init_user_ns, info->gid_min);
 		kgid_t gid_max = make_kgid(&init_user_ns, info->gid_max);
-
+		set_sk_callback_lock = true;
+		read_lock_bh(&sk->sk_callback_lock);
+		MT_DEBUG("qtaguid[%d]: sk=%pK->sk_socket=%pK->file=%pK\n",
+			par->hooknum, sk, sk->sk_socket,
+			sk->sk_socket ? sk->sk_socket->file : (void *)-1LL);
+		filp = sk->sk_socket ? sk->sk_socket->file : NULL;
+		if (!filp) {
+			res = ((info->match ^ info->invert) & XT_QTAGUID_GID) == 0;
+			atomic64_inc(&qtu_events.match_no_sk_gid);
+			goto put_sock_ret_res;
+		}
+		MT_DEBUG("qtaguid[%d]: filp...uid=%u\n",
+			par->hooknum, filp ? from_kuid(&init_user_ns, filp->f_cred->fsuid) : -1);
 		if ((gid_gte(filp->f_cred->fsgid, gid_min) &&
 				gid_lte(filp->f_cred->fsgid, gid_max)) ^
 			!(info->invert & XT_QTAGUID_GID)) {
@@ -1955,7 +1954,7 @@
 			   "match_found_sk_in_ct=%llu "
 			   "match_found_no_sk_in_ct=%llu "
 			   "match_no_sk=%llu "
-			   "match_no_sk_file=%llu\n",
+			   "match_no_sk_gid=%llu\n",
 			   (u64)atomic64_read(&qtu_events.sockets_tagged),
 			   (u64)atomic64_read(&qtu_events.sockets_untagged),
 			   (u64)atomic64_read(&qtu_events.counter_set_changes),
@@ -1967,7 +1966,7 @@
 			   (u64)atomic64_read(&qtu_events.match_found_sk_in_ct),
 			   (u64)atomic64_read(&qtu_events.match_found_no_sk_in_ct),
 			   (u64)atomic64_read(&qtu_events.match_no_sk),
-			   (u64)atomic64_read(&qtu_events.match_no_sk_file));
+			   (u64)atomic64_read(&qtu_events.match_no_sk_gid));
 
 		/* Count the following as part of the last item_index. No need
 		 * to lock the sock_tag_list here since it is already locked when
diff --git a/net/netfilter/xt_qtaguid_internal.h b/net/netfilter/xt_qtaguid_internal.h
index 8178fbd..c705270 100644
--- a/net/netfilter/xt_qtaguid_internal.h
+++ b/net/netfilter/xt_qtaguid_internal.h
@@ -289,10 +289,10 @@
 	 */
 	atomic64_t match_no_sk;
 	/*
-	 * The file ptr in the sk_socket wasn't there.
+	 * The file ptr in the sk_socket wasn't there and we couldn't get GID.
 	 * This might happen for traffic while the socket is being closed.
 	 */
-	atomic64_t match_no_sk_file;
+	atomic64_t match_no_sk_gid;
 };
 
 /* Track the set active_set for the given tag. */
diff --git a/net/netfilter/xt_socket.c b/net/netfilter/xt_socket.c
index a52fbaf..ec87467 100644
--- a/net/netfilter/xt_socket.c
+++ b/net/netfilter/xt_socket.c
@@ -244,7 +244,7 @@
 			transparent = xt_socket_sk_is_transparent(sk);
 
 		if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
-		    transparent)
+		    transparent && sk_fullsock(sk))
 			pskb->mark = sk->sk_mark;
 
 		sock_gen_put(sk);
@@ -433,7 +433,7 @@
 			transparent = xt_socket_sk_is_transparent(sk);
 
 		if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
-		    transparent)
+		    transparent && sk_fullsock(sk))
 			pskb->mark = sk->sk_mark;
 
 		if (sk != skb->sk)
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 2b0f0ac..5a58f9f 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -209,6 +209,11 @@
 		}
 		create_info = (struct hci_create_pipe_resp *)skb->data;
 
+		if (create_info->pipe >= NFC_HCI_MAX_PIPES) {
+			status = NFC_HCI_ANY_E_NOK;
+			goto exit;
+		}
+
 		/* Save the new created pipe and bind with local gate,
 		 * the description for skb->data[3] is destination gate id
 		 * but since we received this cmd from host controller, we
@@ -232,6 +237,11 @@
 		}
 		delete_info = (struct hci_delete_pipe_noti *)skb->data;
 
+		if (delete_info->pipe >= NFC_HCI_MAX_PIPES) {
+			status = NFC_HCI_ANY_E_NOK;
+			goto exit;
+		}
+
 		hdev->pipes[delete_info->pipe].gate = NFC_HCI_INVALID_GATE;
 		hdev->pipes[delete_info->pipe].dest_host = NFC_HCI_INVALID_HOST;
 		break;
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 4e03f64..05d9f42 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -1240,6 +1240,7 @@
 		goto out;
 	}
 
+	OVS_CB(skb)->acts_origlen = acts->orig_len;
 	err = do_execute_actions(dp, skb, key,
 				 acts->actions, acts->actions_len);
 
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 48386bf..b28e45b 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1088,8 +1088,8 @@
 
 	nla_for_each_nested(a, attr, rem) {
 		int type = nla_type(a);
-		int maxlen = ovs_ct_attr_lens[type].maxlen;
-		int minlen = ovs_ct_attr_lens[type].minlen;
+		int maxlen;
+		int minlen;
 
 		if (type > OVS_CT_ATTR_MAX) {
 			OVS_NLERR(log,
@@ -1097,6 +1097,9 @@
 				  type, OVS_CT_ATTR_MAX);
 			return -EINVAL;
 		}
+
+		maxlen = ovs_ct_attr_lens[type].maxlen;
+		minlen = ovs_ct_attr_lens[type].minlen;
 		if (nla_len(a) < minlen || nla_len(a) > maxlen) {
 			OVS_NLERR(log,
 				  "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d67ea8..453f806 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -383,7 +383,7 @@
 }
 
 static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
-			      unsigned int hdrlen)
+			      unsigned int hdrlen, int actions_attrlen)
 {
 	size_t size = NLMSG_ALIGN(sizeof(struct ovs_header))
 		+ nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */
@@ -400,7 +400,7 @@
 
 	/* OVS_PACKET_ATTR_ACTIONS */
 	if (upcall_info->actions_len)
-		size += nla_total_size(upcall_info->actions_len);
+		size += nla_total_size(actions_attrlen);
 
 	/* OVS_PACKET_ATTR_MRU */
 	if (upcall_info->mru)
@@ -467,7 +467,8 @@
 	else
 		hlen = skb->len;
 
-	len = upcall_msg_size(upcall_info, hlen - cutlen);
+	len = upcall_msg_size(upcall_info, hlen - cutlen,
+			      OVS_CB(skb)->acts_origlen);
 	user_skb = genlmsg_new(len, GFP_ATOMIC);
 	if (!user_skb) {
 		err = -ENOMEM;
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index ab85c1c..e19ace4 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -100,12 +100,14 @@
  * @input_vport: The original vport packet came in on. This value is cached
  * when a packet is received by OVS.
  * @mru: The maximum received fragement size; 0 if the packet is not
+ * @acts_origlen: The netlink size of the flow actions applied to this skb.
  * @cutlen: The number of bytes from the packet end to be removed.
  * fragmented.
  */
 struct ovs_skb_cb {
 	struct vport		*input_vport;
 	u16			mru;
+	u16			acts_origlen;
 	u32			cutlen;
 };
 #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 6a563e6..35ba4b6 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2151,6 +2151,7 @@
 	struct timespec ts;
 	__u32 ts_status;
 	bool is_drop_n_account = false;
+	bool do_vnet = false;
 
 	/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
 	 * We may add members to them until current aligned size without forcing
@@ -2201,8 +2202,10 @@
 		netoff = TPACKET_ALIGN(po->tp_hdrlen +
 				       (maclen < 16 ? 16 : maclen)) +
 				       po->tp_reserve;
-		if (po->has_vnet_hdr)
+		if (po->has_vnet_hdr) {
 			netoff += sizeof(struct virtio_net_hdr);
+			do_vnet = true;
+		}
 		macoff = netoff - maclen;
 	}
 	if (po->tp_version <= TPACKET_V2) {
@@ -2219,8 +2222,10 @@
 					skb_set_owner_r(copy_skb, sk);
 			}
 			snaplen = po->rx_ring.frame_size - macoff;
-			if ((int)snaplen < 0)
+			if ((int)snaplen < 0) {
 				snaplen = 0;
+				do_vnet = false;
+			}
 		}
 	} else if (unlikely(macoff + snaplen >
 			    GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) {
@@ -2233,6 +2238,7 @@
 		if (unlikely((int)snaplen < 0)) {
 			snaplen = 0;
 			macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len;
+			do_vnet = false;
 		}
 	}
 	spin_lock(&sk->sk_receive_queue.lock);
@@ -2258,7 +2264,7 @@
 	}
 	spin_unlock(&sk->sk_receive_queue.lock);
 
-	if (po->has_vnet_hdr) {
+	if (do_vnet) {
 		if (__packet_rcv_vnet(skb, h.raw + macoff -
 					   sizeof(struct virtio_net_hdr))) {
 			spin_lock(&sk->sk_receive_queue.lock);
@@ -3698,14 +3704,19 @@
 
 		if (optlen != sizeof(val))
 			return -EINVAL;
-		if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
-			return -EBUSY;
 		if (copy_from_user(&val, optval, sizeof(val)))
 			return -EFAULT;
 		if (val > INT_MAX)
 			return -EINVAL;
-		po->tp_reserve = val;
-		return 0;
+		lock_sock(sk);
+		if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
+			ret = -EBUSY;
+		} else {
+			po->tp_reserve = val;
+			ret = 0;
+		}
+		release_sock(sk);
+		return ret;
 	}
 	case PACKET_LOSS:
 	{
@@ -4322,7 +4333,7 @@
 		register_prot_hook(sk);
 	}
 	spin_unlock(&po->bind_lock);
-	if (closing && (po->tp_version > TPACKET_V2)) {
+	if (pg_vec && (po->tp_version > TPACKET_V2)) {
 		/* Because we don't support block-based V3 on tx-ring */
 		if (!tx_ring)
 			prb_shutdown_retire_blk_timer(po, rb_queue);
diff --git a/net/rmnet_data/rmnet_data_handlers.c b/net/rmnet_data/rmnet_data_handlers.c
index 35be79e..57646ef 100644
--- a/net/rmnet_data/rmnet_data_handlers.c
+++ b/net/rmnet_data/rmnet_data_handlers.c
@@ -537,6 +537,7 @@
 {
 	int required_headroom, additional_header_length, ckresult;
 	struct rmnet_map_header_s *map_header;
+	int non_linear_skb;
 
 	additional_header_length = 0;
 
@@ -565,9 +566,11 @@
 		rmnet_stats_ul_checksum(ckresult);
 	}
 
+	non_linear_skb = (orig_dev->features & NETIF_F_GSO) &&
+			 skb_is_nonlinear(skb);
+
 	if ((!(config->egress_data_format &
-	    RMNET_EGRESS_FORMAT_AGGREGATION)) ||
-	    ((orig_dev->features & NETIF_F_GSO) && skb_is_nonlinear(skb)))
+	    RMNET_EGRESS_FORMAT_AGGREGATION)) || non_linear_skb)
 		map_header = rmnet_map_add_map_header
 		(skb, additional_header_length, RMNET_MAP_NO_PAD_BYTES);
 	else
@@ -589,7 +592,8 @@
 
 	skb->protocol = htons(ETH_P_MAP);
 
-	if (config->egress_data_format & RMNET_EGRESS_FORMAT_AGGREGATION) {
+	if ((config->egress_data_format & RMNET_EGRESS_FORMAT_AGGREGATION) &&
+	    !non_linear_skb) {
 		rmnet_map_aggregate(skb, config);
 		return RMNET_MAP_CONSUMED;
 	}
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 378c1c9..5003051 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -41,6 +41,7 @@
 {
 	struct xt_tgchk_param par;
 	struct xt_target *target;
+	struct ipt_entry e = {};
 	int ret = 0;
 
 	target = xt_request_find_target(AF_INET, t->u.user.name,
@@ -49,8 +50,9 @@
 		return PTR_ERR(target);
 
 	t->u.kernel.target = target;
+	memset(&par, 0, sizeof(par));
 	par.table     = table;
-	par.entryinfo = NULL;
+	par.entryinfo = &e;
 	par.target    = target;
 	par.targinfo  = t->data;
 	par.hook_mask = hook;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index daf6624..a74d32e 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -277,9 +277,6 @@
 void qdisc_hash_add(struct Qdisc *q)
 {
 	if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) {
-		struct Qdisc *root = qdisc_dev(q)->qdisc;
-
-		WARN_ON_ONCE(root == &noop_qdisc);
 		ASSERT_RTNL();
 		hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle);
 	}
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index bc5e995..ea8a56f 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -434,6 +434,7 @@
 		qdisc_drop(head, sch, to_free);
 
 		slot_queue_add(slot, skb);
+		qdisc_tree_reduce_backlog(sch, 0, delta);
 		return NET_XMIT_CN;
 	}
 
@@ -465,8 +466,10 @@
 	/* Return Congestion Notification only if we dropped a packet
 	 * from this flow.
 	 */
-	if (qlen != slot->qlen)
+	if (qlen != slot->qlen) {
+		qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
 		return NET_XMIT_CN;
+	}
 
 	/* As we dropped a packet, better let upper stack know this */
 	qdisc_tree_reduce_backlog(sch, 1, dropped);
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 0c09060..ca4a63e 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -512,7 +512,9 @@
 {
 	addr->sa.sa_family = AF_INET6;
 	addr->v6.sin6_port = port;
+	addr->v6.sin6_flowinfo = 0;
 	addr->v6.sin6_addr = *saddr;
+	addr->v6.sin6_scope_id = 0;
 }
 
 /* Compare addresses exactly.
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index 048954e..e8f56b7 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -70,7 +70,8 @@
 
 	info = nla_data(attr);
 	list_for_each_entry_rcu(laddr, address_list, list) {
-		memcpy(info, &laddr->a, addrlen);
+		memcpy(info, &laddr->a, sizeof(laddr->a));
+		memset(info + sizeof(laddr->a), 0, addrlen - sizeof(laddr->a));
 		info += addrlen;
 	}
 
@@ -93,7 +94,9 @@
 	info = nla_data(attr);
 	list_for_each_entry(from, &asoc->peer.transport_addr_list,
 			    transports) {
-		memcpy(info, &from->ipaddr, addrlen);
+		memcpy(info, &from->ipaddr, sizeof(from->ipaddr));
+		memset(info + sizeof(from->ipaddr), 0,
+		       addrlen - sizeof(from->ipaddr));
 		info += addrlen;
 	}
 
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9647e31..3ef7252 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4373,8 +4373,7 @@
 	info->sctpi_ictrlchunks = asoc->stats.ictrlchunks;
 
 	prim = asoc->peer.primary_path;
-	memcpy(&info->sctpi_p_address, &prim->ipaddr,
-	       sizeof(struct sockaddr_storage));
+	memcpy(&info->sctpi_p_address, &prim->ipaddr, sizeof(prim->ipaddr));
 	info->sctpi_p_state = prim->state;
 	info->sctpi_p_cwnd = prim->cwnd;
 	info->sctpi_p_srtt = prim->srtt;
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 84d0fda..d3cfbf2 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -265,7 +265,8 @@
 		sctp_ulpq_clear_pd(ulpq);
 
 	if (queue == &sk->sk_receive_queue && !sp->data_ready_signalled) {
-		sp->data_ready_signalled = 1;
+		if (!sock_owned_by_user(sk))
+			sp->data_ready_signalled = 1;
 		sk->sk_data_ready(sk);
 	}
 	return 1;
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index a4bc982..266a30c 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -408,6 +408,9 @@
 		dprintk("svc: socket %p(inet %p), busy=%d\n",
 			svsk, sk,
 			test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+		/* Refer to svc_setup_socket() for details. */
+		rmb();
 		svsk->sk_odata(sk);
 		if (!test_and_set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags))
 			svc_xprt_enqueue(&svsk->sk_xprt);
@@ -424,6 +427,9 @@
 	if (svsk) {
 		dprintk("svc: socket %p(inet %p), write_space busy=%d\n",
 			svsk, sk, test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+		/* Refer to svc_setup_socket() for details. */
+		rmb();
 		svsk->sk_owspace(sk);
 		svc_xprt_enqueue(&svsk->sk_xprt);
 	}
@@ -748,8 +754,12 @@
 	dprintk("svc: socket %p TCP (listen) state change %d\n",
 		sk, sk->sk_state);
 
-	if (svsk)
+	if (svsk) {
+		/* Refer to svc_setup_socket() for details. */
+		rmb();
 		svsk->sk_odata(sk);
+	}
+
 	/*
 	 * This callback may called twice when a new connection
 	 * is established as a child socket inherits everything
@@ -782,6 +792,8 @@
 	if (!svsk)
 		printk("svc: socket %p: no user data\n", sk);
 	else {
+		/* Refer to svc_setup_socket() for details. */
+		rmb();
 		svsk->sk_ostate(sk);
 		if (sk->sk_state != TCP_ESTABLISHED) {
 			set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
@@ -1368,12 +1380,18 @@
 		return ERR_PTR(err);
 	}
 
-	inet->sk_user_data = svsk;
 	svsk->sk_sock = sock;
 	svsk->sk_sk = inet;
 	svsk->sk_ostate = inet->sk_state_change;
 	svsk->sk_odata = inet->sk_data_ready;
 	svsk->sk_owspace = inet->sk_write_space;
+	/*
+	 * This barrier is necessary in order to prevent race condition
+	 * with svc_data_ready(), svc_listen_data_ready() and others
+	 * when calling callbacks above.
+	 */
+	wmb();
+	inet->sk_user_data = svsk;
 
 	/* Initialize the socket */
 	if (sock->type == SOCK_DGRAM)
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 1fd4647..aedc476 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -258,13 +258,15 @@
 	arg = nlmsg_new(0, GFP_KERNEL);
 	if (!arg) {
 		kfree_skb(msg->rep);
+		msg->rep = NULL;
 		return -ENOMEM;
 	}
 
 	err = __tipc_nl_compat_dumpit(cmd, msg, arg);
-	if (err)
+	if (err) {
 		kfree_skb(msg->rep);
-
+		msg->rep = NULL;
+	}
 	kfree_skb(arg);
 
 	return err;
diff --git a/net/wireless/core.h b/net/wireless/core.h
index cf7063a..c40f3de 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -221,13 +221,7 @@
 
 	union {
 		struct cfg80211_connect_resp_params cr;
-		struct {
-			const u8 *req_ie;
-			const u8 *resp_ie;
-			size_t req_ie_len;
-			size_t resp_ie_len;
-			struct cfg80211_bss *bss;
-		} rm;
+		struct cfg80211_roam_info rm;
 		struct {
 			const u8 *ie;
 			size_t ie_len;
@@ -385,9 +379,7 @@
 			struct net_device *dev, u16 reason,
 			bool wextev);
 void __cfg80211_roamed(struct wireless_dev *wdev,
-		       struct cfg80211_bss *bss,
-		       const u8 *req_ie, size_t req_ie_len,
-		       const u8 *resp_ie, size_t resp_ie_len);
+		       struct cfg80211_roam_info *info);
 int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
 			      struct wireless_dev *wdev);
 
diff --git a/net/wireless/db.txt b/net/wireless/db.txt
index 413deff..cad82a4 100644
--- a/net/wireless/db.txt
+++ b/net/wireless/db.txt
@@ -223,17 +223,16 @@
 	(5490 - 5710 @ 160), (30), DFS
 
 country BZ:
-	(2402 - 2482 @ 40), (36)
-	(5170 - 5330 @ 160), (27)
-	(5490 - 5730 @ 160), (36)
-	(5735 - 5835 @ 80), (36)
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5330 @ 160), (23)
+	(5490 - 5730 @ 160), (30)
+	(5735 - 5835 @ 80), (30)
 
 country CA: DFS-FCC
 	(2402 - 2472 @ 40), (30)
 	(5170 - 5250 @ 80), (24), AUTO-BW
 	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
-	(5490 - 5590 @ 80), (24), DFS
-	(5650 - 5730 @ 80), (24), DFS
+	(5490 - 5730 @ 160), (24), DFS
 	(5735 - 5835 @ 80), (30)
 	# 60 gHz band channels 1-3
 	(57240 - 63720 @ 2160), (40)
@@ -682,7 +681,13 @@
 country IN:
 	(2402 - 2482 @ 40), (20)
 	(5170 - 5330 @ 160), (23)
-	(5735 - 5835 @ 80), (30)
+	(5735 - 5835 @ 80), (33)
+
+country IQ: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (23), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (30), DFS
 
 country IS: DFS-ETSI
 	(2402 - 2482 @ 40), (20)
@@ -736,7 +741,6 @@
 
 country JP: DFS-JP
 	(2402 - 2482 @ 40), (20)
-	(2474 - 2494 @ 20), (20), NO-OFDM
 	(5170 - 5250 @ 80), (20), AUTO-BW, NO-OUTDOOR
 	(5250 - 5330 @ 80), (20), DFS, AUTO-BW, NO-OUTDOOR
 	(5490 - 5710 @ 160), (20), DFS
@@ -758,7 +762,7 @@
 country KN: DFS-FCC
 	(2402 - 2482 @ 40), (20)
 	(5170 - 5250 @ 80), (23), AUTO-BW
-	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5250 - 5330 @ 80), (30), DFS, AUTO-BW
 	(5490 - 5710 @ 160), (30), DFS
 	(5735 - 5815 @ 80), (30)
 
@@ -1009,7 +1013,7 @@
 	(5170 - 5250 @ 80), (24), AUTO-BW
 	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
 	(5490 - 5650 @ 160), (24), DFS
-	(5735 - 5815 @ 80), (24)
+	(5735 - 5835 @ 80), (24)
 	# 60 gHz band channels 1-3
 	(57240 - 63720 @ 2160), (40)
 
@@ -1089,7 +1093,7 @@
 	(5490 - 5710 @ 160), (30), DFS
 
 country PA:
-	(2402 - 2472 @ 40), (30)
+	(2402 - 2472 @ 40), (36)
 	(5170 - 5250 @ 80), (23), AUT0-BW
 	(5250 - 5330 @ 80), (30), AUTO-BW
 	(5735 - 5835 @ 80), (36)
@@ -1374,9 +1378,9 @@
 
 country TT:
 	(2402 - 2482 @ 40), (20)
-	(5170 - 5330 @ 160), (27)
-	(5490 - 5730 @ 160), (36)
-	(5735 - 5835 @ 80), (36)
+	(5170 - 5330 @ 160), (24)
+	(5490 - 5730 @ 160), (24)
+	(5735 - 5835 @ 80), (30)
 	# 60 gHz band channels 1-3, FCC
 	(57240 - 63720 @ 2160), (40)
 
@@ -1450,7 +1454,7 @@
 country UZ: DFS-ETSI
 	(2402 - 2482 @ 40), (20)
 	(5170 - 5250 @ 80), (23), AUTO-BW
-	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
 
 country VC: DFS-ETSI
 	(2402 - 2482 @ 40), (20)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ebd9a4b..adf7d03 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -13415,14 +13415,14 @@
 }
 
 void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
-			 struct net_device *netdev, const u8 *bssid,
-			 const u8 *req_ie, size_t req_ie_len,
-			 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp)
+			 struct net_device *netdev,
+			 struct cfg80211_roam_info *info, gfp_t gfp)
 {
 	struct sk_buff *msg;
 	void *hdr;
+	const u8 *bssid = info->bss ? info->bss->bssid : info->bssid;
 
-	msg = nlmsg_new(100 + req_ie_len + resp_ie_len, gfp);
+	msg = nlmsg_new(100 + info->req_ie_len + info->resp_ie_len, gfp);
 	if (!msg)
 		return;
 
@@ -13435,10 +13435,14 @@
 	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
 	    nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
 	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid) ||
-	    (req_ie &&
-	     nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) ||
-	    (resp_ie &&
-	     nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie)))
+	    (info->req_ie &&
+	     nla_put(msg, NL80211_ATTR_REQ_IE, info->req_ie_len,
+		     info->req_ie)) ||
+	    (info->resp_ie &&
+	     nla_put(msg, NL80211_ATTR_RESP_IE, info->resp_ie_len,
+		     info->resp_ie)) ||
+	    (info->authorized &&
+	     nla_put_flag(msg, NL80211_ATTR_PORT_AUTHORIZED)))
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 2a84d18..c9d4805 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -59,9 +59,8 @@
 				 struct cfg80211_connect_resp_params *params,
 				 gfp_t gfp);
 void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
-			 struct net_device *netdev, const u8 *bssid,
-			 const u8 *req_ie, size_t req_ie_len,
-			 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);
+			 struct net_device *netdev,
+			 struct cfg80211_roam_info *info, gfp_t gfp);
 void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
 			       struct net_device *netdev, u16 reason,
 			       const u8 *ie, size_t ie_len, bool from_ap);
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index d7e6abc..bb7f5be 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -5,6 +5,7 @@
  *
  * Copyright 2009	Johannes Berg <johannes@sipsolutions.net>
  * Copyright (C) 2009   Intel Corporation. All rights reserved.
+ * Copyright 2017	Intel Deutschland GmbH
  */
 
 #include <linux/etherdevice.h>
@@ -893,9 +894,7 @@
 
 /* Consumes bss object one way or another */
 void __cfg80211_roamed(struct wireless_dev *wdev,
-		       struct cfg80211_bss *bss,
-		       const u8 *req_ie, size_t req_ie_len,
-		       const u8 *resp_ie, size_t resp_ie_len)
+		       struct cfg80211_roam_info *info)
 {
 #ifdef CONFIG_CFG80211_WEXT
 	union iwreq_data wrqu;
@@ -913,97 +912,85 @@
 	cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
 	wdev->current_bss = NULL;
 
-	cfg80211_hold_bss(bss_from_pub(bss));
-	wdev->current_bss = bss_from_pub(bss);
+	if (WARN_ON(!info->bss))
+		return;
+
+	cfg80211_hold_bss(bss_from_pub(info->bss));
+	wdev->current_bss = bss_from_pub(info->bss);
 
 	nl80211_send_roamed(wiphy_to_rdev(wdev->wiphy),
-			    wdev->netdev, bss->bssid,
-			    req_ie, req_ie_len, resp_ie, resp_ie_len,
-			    GFP_KERNEL);
+			    wdev->netdev, info, GFP_KERNEL);
 
 #ifdef CONFIG_CFG80211_WEXT
-	if (req_ie) {
+	if (info->req_ie) {
 		memset(&wrqu, 0, sizeof(wrqu));
-		wrqu.data.length = req_ie_len;
+		wrqu.data.length = info->req_ie_len;
 		wireless_send_event(wdev->netdev, IWEVASSOCREQIE,
-				    &wrqu, req_ie);
+				    &wrqu, info->req_ie);
 	}
 
-	if (resp_ie) {
+	if (info->resp_ie) {
 		memset(&wrqu, 0, sizeof(wrqu));
-		wrqu.data.length = resp_ie_len;
+		wrqu.data.length = info->resp_ie_len;
 		wireless_send_event(wdev->netdev, IWEVASSOCRESPIE,
-				    &wrqu, resp_ie);
+				    &wrqu, info->resp_ie);
 	}
 
 	memset(&wrqu, 0, sizeof(wrqu));
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	memcpy(wrqu.ap_addr.sa_data, bss->bssid, ETH_ALEN);
-	memcpy(wdev->wext.prev_bssid, bss->bssid, ETH_ALEN);
+	memcpy(wrqu.ap_addr.sa_data, info->bss->bssid, ETH_ALEN);
+	memcpy(wdev->wext.prev_bssid, info->bss->bssid, ETH_ALEN);
 	wdev->wext.prev_bssid_valid = true;
 	wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL);
 #endif
 
 	return;
 out:
-	cfg80211_put_bss(wdev->wiphy, bss);
+	cfg80211_put_bss(wdev->wiphy, info->bss);
 }
 
-void cfg80211_roamed(struct net_device *dev,
-		     struct ieee80211_channel *channel,
-		     const u8 *bssid,
-		     const u8 *req_ie, size_t req_ie_len,
-		     const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp)
-{
-	struct wireless_dev *wdev = dev->ieee80211_ptr;
-	struct cfg80211_bss *bss;
-
-	bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, wdev->ssid,
-			       wdev->ssid_len,
-			       wdev->conn_bss_type, IEEE80211_PRIVACY_ANY);
-	if (WARN_ON(!bss))
-		return;
-
-	cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie,
-			    resp_ie_len, gfp);
-}
-EXPORT_SYMBOL(cfg80211_roamed);
-
-/* Consumes bss object one way or another */
-void cfg80211_roamed_bss(struct net_device *dev,
-			 struct cfg80211_bss *bss, const u8 *req_ie,
-			 size_t req_ie_len, const u8 *resp_ie,
-			 size_t resp_ie_len, gfp_t gfp)
+/* Consumes info->bss object one way or another */
+void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
+		     gfp_t gfp)
 {
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
 	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
 	struct cfg80211_event *ev;
 	unsigned long flags;
 
-	if (WARN_ON(!bss))
+	if (!info->bss) {
+		info->bss = cfg80211_get_bss(wdev->wiphy, info->channel,
+					     info->bssid, wdev->ssid,
+					     wdev->ssid_len,
+					     wdev->conn_bss_type,
+					     IEEE80211_PRIVACY_ANY);
+	}
+
+	if (WARN_ON(!info->bss))
 		return;
 
-	ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp);
+	ev = kzalloc(sizeof(*ev) + info->req_ie_len + info->resp_ie_len, gfp);
 	if (!ev) {
-		cfg80211_put_bss(wdev->wiphy, bss);
+		cfg80211_put_bss(wdev->wiphy, info->bss);
 		return;
 	}
 
 	ev->type = EVENT_ROAMED;
 	ev->rm.req_ie = ((u8 *)ev) + sizeof(*ev);
-	ev->rm.req_ie_len = req_ie_len;
-	memcpy((void *)ev->rm.req_ie, req_ie, req_ie_len);
-	ev->rm.resp_ie = ((u8 *)ev) + sizeof(*ev) + req_ie_len;
-	ev->rm.resp_ie_len = resp_ie_len;
-	memcpy((void *)ev->rm.resp_ie, resp_ie, resp_ie_len);
-	ev->rm.bss = bss;
+	ev->rm.req_ie_len = info->req_ie_len;
+	memcpy((void *)ev->rm.req_ie, info->req_ie, info->req_ie_len);
+	ev->rm.resp_ie = ((u8 *)ev) + sizeof(*ev) + info->req_ie_len;
+	ev->rm.resp_ie_len = info->resp_ie_len;
+	memcpy((void *)ev->rm.resp_ie, info->resp_ie, info->resp_ie_len);
+	ev->rm.bss = info->bss;
+	ev->rm.authorized = info->authorized;
 
 	spin_lock_irqsave(&wdev->event_lock, flags);
 	list_add_tail(&ev->list, &wdev->event_list);
 	spin_unlock_irqrestore(&wdev->event_lock, flags);
 	queue_work(cfg80211_wq, &rdev->event_work);
 }
-EXPORT_SYMBOL(cfg80211_roamed_bss);
+EXPORT_SYMBOL(cfg80211_roamed);
 
 void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
 			     size_t ie_len, u16 reason, bool from_ap)
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 8ac413f..a4ab20a 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -953,9 +953,7 @@
 				ev->cr.status == WLAN_STATUS_SUCCESS);
 			break;
 		case EVENT_ROAMED:
-			__cfg80211_roamed(wdev, ev->rm.bss, ev->rm.req_ie,
-					  ev->rm.req_ie_len, ev->rm.resp_ie,
-					  ev->rm.resp_ie_len);
+			__cfg80211_roamed(wdev, &ev->rm);
 			break;
 		case EVENT_DISCONNECTED:
 			__cfg80211_disconnected(wdev->netdev,
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 8da67f7..8ce5711 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1248,7 +1248,7 @@
 }
 
 static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
-						 const struct flowi *fl)
+						 const struct flowi *fl, u16 family)
 {
 	struct xfrm_policy *pol;
 
@@ -1256,8 +1256,7 @@
  again:
 	pol = rcu_dereference(sk->sk_policy[dir]);
 	if (pol != NULL) {
-		bool match = xfrm_selector_match(&pol->selector, fl,
-						 sk->sk_family);
+		bool match = xfrm_selector_match(&pol->selector, fl, family);
 		int err = 0;
 
 		if (match) {
@@ -2206,7 +2205,7 @@
 	sk = sk_const_to_full_sk(sk);
 	if (sk && sk->sk_policy[XFRM_POLICY_OUT]) {
 		num_pols = 1;
-		pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
+		pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl, family);
 		err = xfrm_expand_policies(fl, family, pols,
 					   &num_pols, &num_xfrms);
 		if (err < 0)
@@ -2485,7 +2484,7 @@
 	pol = NULL;
 	sk = sk_to_full_sk(sk);
 	if (sk && sk->sk_policy[dir]) {
-		pol = xfrm_sk_policy_lookup(sk, dir, &fl);
+		pol = xfrm_sk_policy_lookup(sk, dir, &fl, family);
 		if (IS_ERR(pol)) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR);
 			return 0;
@@ -3309,9 +3308,15 @@
 	struct xfrm_state *x_new[XFRM_MAX_DEPTH];
 	struct xfrm_migrate *mp;
 
+	/* Stage 0 - sanity checks */
 	if ((err = xfrm_migrate_check(m, num_migrate)) < 0)
 		goto out;
 
+	if (dir >= XFRM_POLICY_MAX) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	/* Stage 1 - find policy */
 	if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) {
 		err = -ENOENT;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index a7e27e1..b2bba35 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1695,6 +1695,10 @@
 	struct sk_buff *skb;
 	int err;
 
+	err = verify_policy_dir(dir);
+	if (err)
+		return ERR_PTR(err);
+
 	skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!skb)
 		return ERR_PTR(-ENOMEM);
@@ -2216,6 +2220,10 @@
 	int n = 0;
 	struct net *net = sock_net(skb->sk);
 
+	err = verify_policy_dir(pi->dir);
+	if (err)
+		return err;
+
 	if (attrs[XFRMA_MIGRATE] == NULL)
 		return -EINVAL;
 
@@ -2331,6 +2339,11 @@
 {
 	struct net *net = &init_net;
 	struct sk_buff *skb;
+	int err;
+
+	err = verify_policy_dir(dir);
+	if (err)
+		return err;
 
 	skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k), GFP_ATOMIC);
 	if (skb == NULL)
@@ -2985,6 +2998,11 @@
 
 static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c)
 {
+	int err;
+
+	err = verify_policy_dir(dir);
+	if (err)
+		return err;
 
 	switch (c->event) {
 	case XFRM_MSG_NEWPOLICY:
diff --git a/scripts/Makefile.dtbo b/scripts/Makefile.dtbo
index db4a0f4..b298f4a 100644
--- a/scripts/Makefile.dtbo
+++ b/scripts/Makefile.dtbo
@@ -10,7 +10,7 @@
 ifneq ($(DTC_OVERLAY_TEST_EXT),)
 DTC_OVERLAY_TEST = $(DTC_OVERLAY_TEST_EXT)
 quiet_cmd_dtbo_verify	= VERIFY  $@
-cmd_dtbo_verify = $(DTC_OVERLAY_TEST) $(addprefix $(obj)/,$($(@F)-base)) $@ $(dot-target).dtb
+cmd_dtbo_verify = $(DTC_OVERLAY_TEST) $(addprefix $(obj)/,$($(@F)-base)) $@ $(dot-target).tmp
 else
 cmd_dtbo_verify = true
 endif
diff --git a/security/commoncap.c b/security/commoncap.c
index 3e44d01..b5aca42 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -58,7 +58,7 @@
 }
 
 /**
- * cap_capable - Determine whether a task has a particular effective capability
+ * __cap_capable - Determine whether a task has a particular effective capability
  * @cred: The credentials to use
  * @ns:  The user namespace in which we need the capability
  * @cap: The capability to check for
@@ -72,18 +72,11 @@
  * cap_has_capability() returns 0 when a task has a capability, but the
  * kernel's capable() and has_capability() returns 1 for this case.
  */
-int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
+int __cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
 		int cap, int audit)
 {
 	struct user_namespace *ns = targ_ns;
 
-#ifdef CONFIG_ANDROID_PARANOID_NETWORK
-	if (cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW))
-		return 0;
-	if (cap == CAP_NET_ADMIN && in_egroup_p(AID_NET_ADMIN))
-		return 0;
-#endif
-
 	/* See if cred has the capability in the target user namespace
 	 * by examining the target user namespace and all of the target
 	 * user namespace's parents.
@@ -114,6 +107,27 @@
 	/* We never get here */
 }
 
+int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
+		int cap, int audit)
+{
+	int ret = __cap_capable(cred, targ_ns, cap, audit);
+
+#ifdef CONFIG_ANDROID_PARANOID_NETWORK
+	if (ret != 0 && cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW)) {
+		printk("Process %s granted CAP_NET_RAW from Android group net_raw.\n", current->comm);
+		printk("  Please update the .rc file to explictly set 'capabilities NET_RAW'\n");
+		printk("  Implicit grants are deprecated and will be removed in the future.\n");
+		return 0;
+	}
+	if (ret != 0 && cap == CAP_NET_ADMIN && in_egroup_p(AID_NET_ADMIN)) {
+		printk("Process %s granted CAP_NET_ADMIN from Android group net_admin.\n", current->comm);
+		printk("  Please update the .rc file to explictly set 'capabilities NET_ADMIN'\n");
+		printk("  Implicit grants are deprecated and will be removed in the future.\n");
+		return 0;
+	}
+#endif
+	return ret;
+}
 /**
  * cap_settime - Determine whether the current process may set the system clock
  * @ts: The time to set
diff --git a/sound/core/control.c b/sound/core/control.c
index fb096cb..995cde4 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1156,7 +1156,7 @@
 		mutex_lock(&ue->card->user_ctl_lock);
 		change = ue->tlv_data_size != size;
 		if (!change)
-			change = memcmp(ue->tlv_data, new_data, size);
+			change = memcmp(ue->tlv_data, new_data, size) != 0;
 		kfree(ue->tlv_data);
 		ue->tlv_data = new_data;
 		ue->tlv_data_size = size;
diff --git a/sound/core/info.c b/sound/core/info.c
index 2ffa3fa..08558ae 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -735,8 +735,11 @@
 	INIT_LIST_HEAD(&entry->children);
 	INIT_LIST_HEAD(&entry->list);
 	entry->parent = parent;
-	if (parent)
+	if (parent) {
+		mutex_lock(&parent->access);
 		list_add_tail(&entry->list, &parent->children);
+		mutex_unlock(&parent->access);
+	}
 	return entry;
 }
 
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index f3b1d7f..67c4c68 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1502,16 +1502,11 @@
 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
 {
 	struct snd_seq_queue_info *info = arg;
-	int result;
 	struct snd_seq_queue *q;
 
-	result = snd_seq_queue_alloc(client->number, info->locked, info->flags);
-	if (result < 0)
-		return result;
-
-	q = queueptr(result);
-	if (q == NULL)
-		return -EINVAL;
+	q = snd_seq_queue_alloc(client->number, info->locked, info->flags);
+	if (IS_ERR(q))
+		return PTR_ERR(q);
 
 	info->queue = q->queue;
 	info->locked = q->locked;
@@ -1521,7 +1516,7 @@
 	if (!info->name[0])
 		snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue);
 	strlcpy(q->name, info->name, sizeof(q->name));
-	queuefree(q);
+	snd_use_lock_free(&q->use_lock);
 
 	return 0;
 }
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 450c518..79e0c56 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -184,22 +184,26 @@
 static void queue_use(struct snd_seq_queue *queue, int client, int use);
 
 /* allocate a new queue -
- * return queue index value or negative value for error
+ * return pointer to new queue or ERR_PTR(-errno) for error
+ * The new queue's use_lock is set to 1. It is the caller's responsibility to
+ * call snd_use_lock_free(&q->use_lock).
  */
-int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
 {
 	struct snd_seq_queue *q;
 
 	q = queue_new(client, locked);
 	if (q == NULL)
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 	q->info_flags = info_flags;
 	queue_use(q, client, 1);
+	snd_use_lock_use(&q->use_lock);
 	if (queue_list_add(q) < 0) {
+		snd_use_lock_free(&q->use_lock);
 		queue_delete(q);
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 	}
-	return q->queue;
+	return q;
 }
 
 /* delete a queue - queue must be owned by the client */
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h
index 30c8111..7190934 100644
--- a/sound/core/seq/seq_queue.h
+++ b/sound/core/seq/seq_queue.h
@@ -71,7 +71,7 @@
 
 
 /* create new queue (constructor) */
-int snd_seq_queue_alloc(int client, int locked, unsigned int flags);
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
 
 /* delete queue (destructor) */
 int snd_seq_queue_delete(int client, int queueid);
diff --git a/sound/firewire/iso-resources.c b/sound/firewire/iso-resources.c
index f0e4d50..066b5df 100644
--- a/sound/firewire/iso-resources.c
+++ b/sound/firewire/iso-resources.c
@@ -210,9 +210,14 @@
  */
 void fw_iso_resources_free(struct fw_iso_resources *r)
 {
-	struct fw_card *card = fw_parent_device(r->unit)->card;
+	struct fw_card *card;
 	int bandwidth, channel;
 
+	/* Not initialized. */
+	if (r->unit == NULL)
+		return;
+	card = fw_parent_device(r->unit)->card;
+
 	mutex_lock(&r->mutex);
 
 	if (r->allocated) {
diff --git a/sound/isa/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c
index ffc67fd..58e59cd 100644
--- a/sound/isa/msnd/msnd_midi.c
+++ b/sound/isa/msnd/msnd_midi.c
@@ -120,24 +120,24 @@
 	unsigned long flags;
 	struct snd_msndmidi *mpu = mpuv;
 	void *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF;
+	u16 head, tail, size;
 
 	spin_lock_irqsave(&mpu->input_lock, flags);
-	while (readw(mpu->dev->MIDQ + JQS_wTail) !=
-	       readw(mpu->dev->MIDQ + JQS_wHead)) {
-		u16 wTmp, val;
-		val = readw(pwMIDQData + 2 * readw(mpu->dev->MIDQ + JQS_wHead));
+	head = readw(mpu->dev->MIDQ + JQS_wHead);
+	tail = readw(mpu->dev->MIDQ + JQS_wTail);
+	size = readw(mpu->dev->MIDQ + JQS_wSize);
+	if (head > size || tail > size)
+		goto out;
+	while (head != tail) {
+		unsigned char val = readw(pwMIDQData + 2 * head);
 
-			if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER,
-				     &mpu->mode))
-				snd_rawmidi_receive(mpu->substream_input,
-						    (unsigned char *)&val, 1);
-
-		wTmp = readw(mpu->dev->MIDQ + JQS_wHead) + 1;
-		if (wTmp > readw(mpu->dev->MIDQ + JQS_wSize))
-			writew(0,  mpu->dev->MIDQ + JQS_wHead);
-		else
-			writew(wTmp,  mpu->dev->MIDQ + JQS_wHead);
+		if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode))
+			snd_rawmidi_receive(mpu->substream_input, &val, 1);
+		if (++head > size)
+			head = 0;
+		writew(head, mpu->dev->MIDQ + JQS_wHead);
 	}
+ out:
 	spin_unlock_irqrestore(&mpu->input_lock, flags);
 }
 EXPORT_SYMBOL(snd_msndmidi_input_read);
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
index 4c07266..a31ea6c 100644
--- a/sound/isa/msnd/msnd_pinnacle.c
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -170,23 +170,24 @@
 {
 	struct snd_msnd *chip = dev_id;
 	void *pwDSPQData = chip->mappedbase + DSPQ_DATA_BUFF;
+	u16 head, tail, size;
 
 	/* Send ack to DSP */
 	/* inb(chip->io + HP_RXL); */
 
 	/* Evaluate queued DSP messages */
-	while (readw(chip->DSPQ + JQS_wTail) != readw(chip->DSPQ + JQS_wHead)) {
-		u16 wTmp;
-
-		snd_msnd_eval_dsp_msg(chip,
-			readw(pwDSPQData + 2 * readw(chip->DSPQ + JQS_wHead)));
-
-		wTmp = readw(chip->DSPQ + JQS_wHead) + 1;
-		if (wTmp > readw(chip->DSPQ + JQS_wSize))
-			writew(0, chip->DSPQ + JQS_wHead);
-		else
-			writew(wTmp, chip->DSPQ + JQS_wHead);
+	head = readw(chip->DSPQ + JQS_wHead);
+	tail = readw(chip->DSPQ + JQS_wTail);
+	size = readw(chip->DSPQ + JQS_wSize);
+	if (head > size || tail > size)
+		goto out;
+	while (head != tail) {
+		snd_msnd_eval_dsp_msg(chip, readw(pwDSPQData + 2 * head));
+		if (++head > size)
+			head = 0;
+		writew(head, chip->DSPQ + JQS_wHead);
 	}
+ out:
 	/* Send ack to DSP */
 	inb(chip->io + HP_RXL);
 	return IRQ_HANDLED;
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index c47287d..a178e0d 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1235,8 +1235,6 @@
 		}
 	}
 
-	snd_fm801_chip_init(chip);
-
 	if ((chip->tea575x_tuner & TUNER_ONLY) == 0) {
 		if (devm_request_irq(&pci->dev, pci->irq, snd_fm801_interrupt,
 				IRQF_SHARED, KBUILD_MODNAME, chip)) {
@@ -1248,6 +1246,8 @@
 		pci_set_master(pci);
 	}
 
+	snd_fm801_chip_init(chip);
+
 	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
 		snd_fm801_free(chip);
 		return err;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index c15c51b..f2e4e99 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -854,6 +854,7 @@
 	SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
+	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
 	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 4bf4833..775c678 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3600,11 +3600,15 @@
 HDA_CODEC_ENTRY(0x10951390, "SiI1390 HDMI",	patch_generic_hdmi),
 HDA_CODEC_ENTRY(0x10951392, "SiI1392 HDMI",	patch_generic_hdmi),
 HDA_CODEC_ENTRY(0x17e80047, "Chrontel HDMI",	patch_generic_hdmi),
+HDA_CODEC_ENTRY(0x10de0001, "MCP73 HDMI",	patch_nvhdmi_2ch),
 HDA_CODEC_ENTRY(0x10de0002, "MCP77/78 HDMI",	patch_nvhdmi_8ch_7x),
 HDA_CODEC_ENTRY(0x10de0003, "MCP77/78 HDMI",	patch_nvhdmi_8ch_7x),
+HDA_CODEC_ENTRY(0x10de0004, "GPU 04 HDMI",	patch_nvhdmi_8ch_7x),
 HDA_CODEC_ENTRY(0x10de0005, "MCP77/78 HDMI",	patch_nvhdmi_8ch_7x),
 HDA_CODEC_ENTRY(0x10de0006, "MCP77/78 HDMI",	patch_nvhdmi_8ch_7x),
 HDA_CODEC_ENTRY(0x10de0007, "MCP79/7A HDMI",	patch_nvhdmi_8ch_7x),
+HDA_CODEC_ENTRY(0x10de0008, "GPU 08 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0009, "GPU 09 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de000a, "GPU 0a HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de000b, "GPU 0b HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de000c, "MCP89 HDMI",	patch_nvhdmi),
@@ -3631,17 +3635,40 @@
 HDA_CODEC_ENTRY(0x10de0042, "GPU 42 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0043, "GPU 43 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0044, "GPU 44 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0045, "GPU 45 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0050, "GPU 50 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0051, "GPU 51 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0052, "GPU 52 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0060, "GPU 60 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0061, "GPU 61 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0062, "GPU 62 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0067, "MCP67 HDMI",	patch_nvhdmi_2ch),
 HDA_CODEC_ENTRY(0x10de0070, "GPU 70 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0073, "GPU 73 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0074, "GPU 74 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0076, "GPU 76 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de007b, "GPU 7b HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de007c, "GPU 7c HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de007e, "GPU 7e HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0080, "GPU 80 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0081, "GPU 81 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0082, "GPU 82 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de0083, "GPU 83 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0084, "GPU 84 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0090, "GPU 90 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0091, "GPU 91 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0092, "GPU 92 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0093, "GPU 93 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0094, "GPU 94 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0095, "GPU 95 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0097, "GPU 97 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0098, "GPU 98 HDMI/DP",	patch_nvhdmi),
+HDA_CODEC_ENTRY(0x10de0099, "GPU 99 HDMI/DP",	patch_nvhdmi),
 HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI",	patch_nvhdmi_2ch),
+HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI",	patch_nvhdmi_2ch),
 HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP",	patch_via_hdmi),
 HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP",	patch_via_hdmi),
 HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP",	patch_generic_hdmi),
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index bb1aad3..6f337f0 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2233,6 +2233,7 @@
 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
+	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
 
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 22b3073..182d92e 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -54,7 +54,6 @@
 source "sound/soc/img/Kconfig"
 source "sound/soc/intel/Kconfig"
 source "sound/soc/mediatek/Kconfig"
-source "sound/soc/msm/Kconfig"
 source "sound/soc/mxs/Kconfig"
 source "sound/soc/pxa/Kconfig"
 source "sound/soc/qcom/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 1466075..9a30f21 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -31,7 +31,6 @@
 obj-$(CONFIG_SND_SOC)	+= img/
 obj-$(CONFIG_SND_SOC)	+= intel/
 obj-$(CONFIG_SND_SOC)	+= mediatek/
-obj-$(CONFIG_SND_SOC)	+= msm/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
 obj-$(CONFIG_SND_SOC)	+= omap/
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 27f5d34..c67667b 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -875,71 +875,6 @@
 config SND_SOC_UDA1380
         tristate
 
-config SND_SOC_WCD934X_DSD
-        tristate
-
-config SND_SOC_WCD9335
-        tristate
-	depends on WCD9XXX_CODEC_CORE
-	select SND_SOC_WCD9XXX
-	select SND_SOC_WCD_MBHC_LEGACY
-	select SND_SOC_WCD_CPE
-
-config SND_SOC_WCD934X
-        tristate
-	depends on WCD9XXX_CODEC_CORE
-	select SND_SOC_WCD9XXX
-	select AUDIO_EXT_CLK
-	select SND_SOC_WCD_DSP_MGR
-	select SND_SOC_WCD_SPI
-	select SND_SOC_WCD934X_MBHC
-        select SND_SOC_WCD934X_DSD
-	select WCD_DSP_GLINK
-
-config SND_SOC_WCD934X_MBHC
-        tristate
-	depends on SND_SOC_WCD934X
-	select SND_SOC_WCD_MBHC_ADC
-
-config REGMAP_SWR
-	tristate
-	default y
-
-config SND_SOC_WSA881X
-        tristate
-	depends on REGMAP_SWR
-	select MSM_CDC_PINCTRL
-
-config SND_SOC_WCD9XXX
-	tristate
-	default y if SND_SOC_WCD9335=y || SND_SOC_WCD934X=y
-
-config SND_SOC_WCD_CPE
-	tristate
-	default y if SND_SOC_WCD9335=y
-
-config AUDIO_EXT_CLK
-	tristate
-	default y if SND_SOC_WCD9335=y || SND_SOC_SDM660_CDC=y
-
-config SND_SOC_WCD_MBHC
-	tristate
-
-config SND_SOC_WCD_MBHC_LEGACY
-	tristate
-	select SND_SOC_WCD_MBHC
-
-config SND_SOC_WCD_MBHC_ADC
-	tristate
-	select SND_SOC_WCD_MBHC
-
-config SND_SOC_WCD_DSP_MGR
-	tristate
-
-config SND_SOC_WCD_SPI
-	depends on SPI
-	tristate
-
 config SND_SOC_WL1273
 	tristate
 
@@ -1154,17 +1089,4 @@
 	tristate "Texas Instruments TPA6130A2 headphone amplifier"
 	depends on I2C
 
-config SND_SOC_MSM_STUB
-	tristate
-
-config SND_SOC_MSM_HDMI_CODEC_RX
-	bool "HDMI Audio Playback"
-	depends on DRM_MSM && (SND_SOC_MSM8998 || SND_SOC_660 || SND_SOC_SDM845)
-	help
-	HDMI audio drivers should be built only if the platform
-	supports hdmi panel.
-
-source "sound/soc/codecs/sdm660_cdc/Kconfig"
-source "sound/soc/codecs/msm_sdw/Kconfig"
-
 endmenu
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index daf05d8..958cd49 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -158,21 +158,6 @@
 snd-soc-twl6040-objs := twl6040.o
 snd-soc-uda134x-objs := uda134x.o
 snd-soc-uda1380-objs := uda1380.o
-snd-soc-wcd9335-objs := wcd9335.o
-snd-soc-wcd934x-objs := wcd934x.o
-snd-soc-wcd9xxx-objs := wcd9xxx-common-v2.o wcd9xxx-resmgr-v2.o \
-			wcdcal-hwdep.o wcd-dsp-mgr.o wcd-dsp-utils.o \
-			wcd9xxx-soc-init.o audio-ext-clk-up.o
-snd-soc-wcd-cpe-objs := wcd_cpe_services.o wcd_cpe_core.o
-snd-soc-wsa881x-objs := wsa881x.o wsa881x-tables.o wsa881x-regmap.o wsa881x-temp-sensor.o
-snd-soc-wcd-mbhc-objs := wcd-mbhc-v2.o
-ifneq (,$(filter $(CONFIG_SND_SOC_WCD_MBHC_LEGACY),y m))
-	snd-soc-wcd-mbhc-objs += wcd-mbhc-legacy.o
-endif
-ifneq (,$(filter $(CONFIG_SND_SOC_WCD_MBHC_ADC),y m))
-	snd-soc-wcd-mbhc-objs += wcd-mbhc-adc.o
-endif
-snd-soc-wcd-spi-objs := wcd-spi.o
 snd-soc-wl1273-objs := wl1273.o
 snd-soc-wm-adsp-objs := wm_adsp.o
 snd-soc-wm0010-objs := wm0010.o
@@ -229,8 +214,6 @@
 snd-soc-wm9712-objs := wm9712.o
 snd-soc-wm9713-objs := wm9713.o
 snd-soc-wm-hubs-objs := wm_hubs.o
-snd-soc-msm-stub-objs := msm_stub.o
-obj-$(CONFIG_SND_SOC_MSM_HDMI_CODEC_RX) := msm_hdmi_codec_rx.o
 
 # Amp
 snd-soc-max9877-objs := max9877.o
@@ -396,15 +379,7 @@
 obj-$(CONFIG_SND_SOC_TWL6040)	+= snd-soc-twl6040.o
 obj-$(CONFIG_SND_SOC_UDA134X)	+= snd-soc-uda134x.o
 obj-$(CONFIG_SND_SOC_UDA1380)	+= snd-soc-uda1380.o
-obj-$(CONFIG_SND_SOC_WCD9320)	+= snd-soc-wcd9320.o
-obj-$(CONFIG_SND_SOC_WCD9335)	+= snd-soc-wcd9335.o
-obj-$(CONFIG_SND_SOC_WCD934X)	+= wcd934x/
-obj-$(CONFIG_SND_SOC_WCD9XXX) += snd-soc-wcd9xxx.o
-obj-$(CONFIG_SND_SOC_WCD_CPE)   += snd-soc-wcd-cpe.o
-obj-$(CONFIG_SND_SOC_WCD_MBHC)  += snd-soc-wcd-mbhc.o
-obj-$(CONFIG_SND_SOC_WSA881X)	+= snd-soc-wsa881x.o
 obj-$(CONFIG_SND_SOC_WL1273)	+= snd-soc-wl1273.o
-obj-$(CONFIG_SND_SOC_WCD_SPI)  += snd-soc-wcd-spi.o
 obj-$(CONFIG_SND_SOC_WM0010)	+= snd-soc-wm0010.o
 obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o
 obj-$(CONFIG_SND_SOC_WM2000)	+= snd-soc-wm2000.o
@@ -460,11 +435,8 @@
 obj-$(CONFIG_SND_SOC_WM9713)	+= snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_WM_ADSP)	+= snd-soc-wm-adsp.o
 obj-$(CONFIG_SND_SOC_WM_HUBS)	+= snd-soc-wm-hubs.o
-obj-$(CONFIG_SND_SOC_MSM_STUB)  += snd-soc-msm-stub.o
 
 # Amp
 obj-$(CONFIG_SND_SOC_MAX9877)	+= snd-soc-max9877.o
 obj-$(CONFIG_SND_SOC_MAX98504)	+= snd-soc-max98504.o
 obj-$(CONFIG_SND_SOC_TPA6130A2)	+= snd-soc-tpa6130a2.o
-obj-y += sdm660_cdc/
-obj-y += msm_sdw/
diff --git a/sound/soc/codecs/audio-ext-clk-up.c b/sound/soc/codecs/audio-ext-clk-up.c
deleted file mode 100644
index 31c063d..0000000
--- a/sound/soc/codecs/audio-ext-clk-up.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/clk.h>
-#include <linux/clk-provider.h>
-#include "../../../drivers/clk/qcom/common.h"
-#include <linux/platform_device.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <dt-bindings/clock/qcom,audio-ext-clk.h>
-#include <sound/q6afe-v2.h>
-#include "audio-ext-clk-up.h"
-
-enum audio_clk_mux {
-	AP_CLK2,
-	LPASS_MCLK,
-	LPASS_MCLK2,
-};
-
-struct pinctrl_info {
-	struct pinctrl *pinctrl;
-	struct pinctrl_state *sleep;
-	struct pinctrl_state *active;
-	char __iomem *base;
-};
-
-struct audio_ext_ap_clk {
-	bool enabled;
-	int gpio;
-	struct clk_fixed_factor fact;
-};
-
-struct audio_ext_pmi_clk {
-	int gpio;
-	struct clk_fixed_factor fact;
-};
-
-struct audio_ext_ap_clk2 {
-	bool enabled;
-	struct pinctrl_info pnctrl_info;
-	struct clk_fixed_factor fact;
-};
-
-struct audio_ext_lpass_mclk {
-	struct pinctrl_info pnctrl_info;
-	struct clk_fixed_factor fact;
-};
-
-static struct afe_clk_set clk2_config = {
-	Q6AFE_LPASS_CLK_CONFIG_API_VERSION,
-	Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_OSR,
-	Q6AFE_LPASS_IBIT_CLK_11_P2896_MHZ,
-	Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	0,
-};
-
-static struct afe_clk_set lpass_default = {
-	Q6AFE_LPASS_CLK_CONFIG_API_VERSION,
-	Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_OSR,
-	Q6AFE_LPASS_IBIT_CLK_11_P2896_MHZ,
-	Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	0,
-};
-
-static struct afe_clk_set lpass_mclk = {
-	Q6AFE_LPASS_CLK_CONFIG_API_VERSION,
-	Q6AFE_LPASS_CLK_ID_MCLK_1,
-	Q6AFE_LPASS_OSR_CLK_11_P2896_MHZ,
-	Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	0,
-};
-
-static inline struct audio_ext_ap_clk *to_audio_ap_clk(struct clk_hw *hw)
-{
-	return container_of(hw, struct audio_ext_ap_clk, fact.hw);
-}
-
-static int audio_ext_clk_prepare(struct clk_hw *hw)
-{
-	struct audio_ext_ap_clk *audio_clk = to_audio_ap_clk(hw);
-
-	pr_debug("%s: gpio: %d\n", __func__, audio_clk->gpio);
-	if (gpio_is_valid(audio_clk->gpio))
-		return gpio_direction_output(audio_clk->gpio, 1);
-	return 0;
-}
-
-static void audio_ext_clk_unprepare(struct clk_hw *hw)
-{
-	struct audio_ext_ap_clk *audio_clk = to_audio_ap_clk(hw);
-
-	pr_debug("%s: gpio: %d\n", __func__, audio_clk->gpio);
-	if (gpio_is_valid(audio_clk->gpio))
-		gpio_direction_output(audio_clk->gpio, 0);
-}
-
-static inline struct audio_ext_ap_clk2 *to_audio_ap_clk2(struct clk_hw *hw)
-{
-	return container_of(hw, struct audio_ext_ap_clk2, fact.hw);
-}
-
-static int audio_ext_clk2_prepare(struct clk_hw *hw)
-{
-	struct audio_ext_ap_clk2 *audio_clk2 = to_audio_ap_clk2(hw);
-	struct pinctrl_info *pnctrl_info = &audio_clk2->pnctrl_info;
-	int ret;
-
-
-	if (!pnctrl_info->pinctrl || !pnctrl_info->active)
-		return 0;
-
-	ret = pinctrl_select_state(pnctrl_info->pinctrl,
-				   pnctrl_info->active);
-	if (ret) {
-		pr_err("%s: active state select failed with %d\n",
-			__func__, ret);
-		return -EIO;
-	}
-
-	clk2_config.enable = 1;
-	ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &clk2_config);
-	if (ret < 0) {
-		pr_err("%s: failed to set clock, ret = %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static void audio_ext_clk2_unprepare(struct clk_hw *hw)
-{
-	struct audio_ext_ap_clk2 *audio_clk2 = to_audio_ap_clk2(hw);
-	struct pinctrl_info *pnctrl_info = &audio_clk2->pnctrl_info;
-	int ret;
-
-	if (!pnctrl_info->pinctrl || !pnctrl_info->sleep)
-		return;
-
-	ret = pinctrl_select_state(pnctrl_info->pinctrl,
-				   pnctrl_info->sleep);
-	if (ret)
-		pr_err("%s: sleep state select failed with %d\n",
-			__func__, ret);
-
-	clk2_config.enable = 0;
-	ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &clk2_config);
-	if (ret < 0)
-		pr_err("%s: failed to reset clock, ret = %d\n", __func__, ret);
-}
-
-static inline struct audio_ext_lpass_mclk *to_audio_lpass_mclk(
-						struct clk_hw *hw)
-{
-	return container_of(hw, struct audio_ext_lpass_mclk, fact.hw);
-}
-
-static int audio_ext_lpass_mclk_prepare(struct clk_hw *hw)
-{
-	struct audio_ext_lpass_mclk *audio_lpass_mclk = to_audio_lpass_mclk(hw);
-	struct pinctrl_info *pnctrl_info = &audio_lpass_mclk->pnctrl_info;
-	int ret;
-
-	lpass_mclk.enable = 1;
-	ret = afe_set_lpass_clock_v2(AFE_PORT_ID_PRIMARY_MI2S_RX,
-				&lpass_mclk);
-	if (ret < 0) {
-		pr_err("%s afe_set_digital_codec_core_clock failed\n",
-			__func__);
-		return ret;
-	}
-
-	if (pnctrl_info->pinctrl) {
-		ret = pinctrl_select_state(pnctrl_info->pinctrl,
-				pnctrl_info->active);
-		if (ret) {
-			pr_err("%s: active state select failed with %d\n",
-				__func__, ret);
-			return -EIO;
-		}
-	}
-
-	if (pnctrl_info->base)
-		iowrite32(1, pnctrl_info->base);
-	return 0;
-}
-
-static void audio_ext_lpass_mclk_unprepare(struct clk_hw *hw)
-{
-	struct audio_ext_lpass_mclk *audio_lpass_mclk = to_audio_lpass_mclk(hw);
-	struct pinctrl_info *pnctrl_info = &audio_lpass_mclk->pnctrl_info;
-	int ret;
-
-	if (pnctrl_info->pinctrl) {
-		ret = pinctrl_select_state(pnctrl_info->pinctrl,
-					   pnctrl_info->sleep);
-		if (ret) {
-			pr_err("%s: active state select failed with %d\n",
-				__func__, ret);
-			return;
-		}
-	}
-
-	lpass_mclk.enable = 0;
-	ret = afe_set_lpass_clock_v2(AFE_PORT_ID_PRIMARY_MI2S_RX,
-			&lpass_mclk);
-	if (ret < 0)
-		pr_err("%s: afe_set_digital_codec_core_clock failed, ret = %d\n",
-			__func__, ret);
-	if (pnctrl_info->base)
-		iowrite32(0, pnctrl_info->base);
-}
-
-static int audio_ext_lpass_mclk2_prepare(struct clk_hw *hw)
-{
-	struct audio_ext_lpass_mclk *audio_lpass_mclk2 =
-					to_audio_lpass_mclk(hw);
-	struct pinctrl_info *pnctrl_info = &audio_lpass_mclk2->pnctrl_info;
-	int ret;
-
-	if (pnctrl_info->pinctrl) {
-		ret = pinctrl_select_state(pnctrl_info->pinctrl,
-					   pnctrl_info->active);
-		if (ret) {
-			pr_err("%s: active state select failed with %d\n",
-				__func__, ret);
-			return -EIO;
-		}
-	}
-
-	lpass_default.enable = 1;
-	ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &lpass_default);
-	if (ret < 0) {
-		pr_err("%s: failed to set clock, ret = %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static void audio_ext_lpass_mclk2_unprepare(struct clk_hw *hw)
-{
-	struct audio_ext_lpass_mclk *audio_lpass_mclk2 =
-					to_audio_lpass_mclk(hw);
-	struct pinctrl_info *pnctrl_info = &audio_lpass_mclk2->pnctrl_info;
-	int ret;
-
-	if (pnctrl_info->pinctrl) {
-		ret = pinctrl_select_state(pnctrl_info->pinctrl,
-					   pnctrl_info->sleep);
-		if (ret)
-			pr_err("%s: sleep state select failed with %d\n",
-				__func__, ret);
-	}
-
-	lpass_default.enable = 0;
-	ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &lpass_default);
-	if (ret < 0)
-		pr_err("%s: failed to reset clock, ret = %d\n", __func__, ret);
-}
-
-static const struct clk_ops audio_ext_ap_clk_ops = {
-	.prepare = audio_ext_clk_prepare,
-	.unprepare = audio_ext_clk_unprepare,
-};
-
-static const struct clk_ops audio_ext_ap_clk2_ops = {
-	.prepare = audio_ext_clk2_prepare,
-	.unprepare = audio_ext_clk2_unprepare,
-};
-
-static const struct clk_ops audio_ext_lpass_mclk_ops = {
-	.prepare = audio_ext_lpass_mclk_prepare,
-	.unprepare = audio_ext_lpass_mclk_unprepare,
-};
-
-static const struct clk_ops audio_ext_lpass_mclk2_ops = {
-	.prepare = audio_ext_lpass_mclk2_prepare,
-	.unprepare = audio_ext_lpass_mclk2_unprepare,
-};
-
-static struct audio_ext_pmi_clk audio_pmi_clk = {
-	.gpio = -EINVAL,
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_ext_pmi_clk",
-			.parent_names = (const char *[]){ "div_clk1" },
-			.num_parents = 1,
-			.ops = &clk_dummy_ops,
-		},
-	},
-};
-
-static struct audio_ext_pmi_clk audio_pmi_lnbb_clk = {
-	.gpio = -EINVAL,
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_ext_pmi_lnbb_clk",
-			.parent_names = (const char *[]){ "ln_bb_clk2" },
-			.num_parents = 1,
-			.ops = &clk_dummy_ops,
-		},
-	},
-};
-
-static struct audio_ext_ap_clk audio_ap_clk = {
-	.gpio = -EINVAL,
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_ap_clk",
-			.ops = &audio_ext_ap_clk_ops,
-		},
-	},
-};
-
-static struct audio_ext_ap_clk2 audio_ap_clk2 = {
-	.enabled = false,
-	.pnctrl_info = {NULL},
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_ap_clk2",
-			.ops = &audio_ext_ap_clk2_ops,
-		},
-	},
-};
-
-static struct audio_ext_lpass_mclk audio_lpass_mclk = {
-	.pnctrl_info = {NULL},
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_lpass_mclk",
-			.ops = &audio_ext_lpass_mclk_ops,
-		},
-	},
-};
-
-static struct audio_ext_lpass_mclk audio_lpass_mclk2 = {
-	.pnctrl_info = {NULL},
-	.fact = {
-		.mult = 1,
-		.div = 1,
-		.hw.init = &(struct clk_init_data){
-			.name = "audio_lpass_mclk2",
-			.ops = &audio_ext_lpass_mclk2_ops,
-		},
-	},
-};
-
-static struct clk_hw *audio_msm_hws[] = {
-	&audio_pmi_clk.fact.hw,
-	&audio_ap_clk.fact.hw,
-	&audio_ap_clk2.fact.hw,
-	&audio_lpass_mclk.fact.hw,
-	&audio_lpass_mclk2.fact.hw,
-};
-
-static struct clk_hw *audio_msm_hws1[] = {
-	&audio_pmi_lnbb_clk.fact.hw,
-};
-
-static int audio_get_pinctrl(struct platform_device *pdev,
-			     enum audio_clk_mux mux)
-{
-	struct device *dev =  &pdev->dev;
-	struct pinctrl_info *pnctrl_info;
-	struct pinctrl *pinctrl;
-	int ret;
-	u32 reg;
-
-	switch (mux) {
-	case AP_CLK2:
-		pnctrl_info = &audio_ap_clk2.pnctrl_info;
-		break;
-	case LPASS_MCLK:
-		pnctrl_info = &audio_lpass_mclk.pnctrl_info;
-		break;
-	case LPASS_MCLK2:
-		pnctrl_info = &audio_lpass_mclk2.pnctrl_info;
-		break;
-	default:
-		dev_err(dev, "%s Not a valid MUX ID: %d\n",
-			__func__, mux);
-		return -EINVAL;
-	}
-
-	if (pnctrl_info->pinctrl) {
-		dev_dbg(dev, "%s: already requested before\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	pinctrl = devm_pinctrl_get(dev);
-	if (IS_ERR_OR_NULL(pinctrl)) {
-		dev_dbg(dev, "%s: Unable to get pinctrl handle\n",
-			__func__);
-		return -EINVAL;
-	}
-	pnctrl_info->pinctrl = pinctrl;
-	/* get all state handles from Device Tree */
-	pnctrl_info->sleep = pinctrl_lookup_state(pinctrl, "sleep");
-	if (IS_ERR(pnctrl_info->sleep)) {
-		dev_err(dev, "%s: could not get sleep pinstate\n",
-			__func__);
-		goto err;
-	}
-	pnctrl_info->active = pinctrl_lookup_state(pinctrl, "active");
-	if (IS_ERR(pnctrl_info->active)) {
-		dev_err(dev, "%s: could not get active pinstate\n",
-			__func__);
-		goto err;
-	}
-	/* Reset the TLMM pins to a default state */
-	ret = pinctrl_select_state(pnctrl_info->pinctrl,
-				   pnctrl_info->sleep);
-	if (ret) {
-		dev_err(dev, "%s: Disable TLMM pins failed with %d\n",
-			__func__, ret);
-		goto err;
-	}
-
-	ret = of_property_read_u32(dev->of_node, "qcom,mclk-clk-reg", &reg);
-	if (ret < 0) {
-		dev_dbg(dev, "%s: miss mclk reg\n", __func__);
-	} else {
-		pnctrl_info->base = ioremap(reg, sizeof(u32));
-		if (pnctrl_info->base ==  NULL) {
-			dev_err(dev, "%s ioremap failed\n", __func__);
-			goto err;
-		}
-	}
-
-	return 0;
-
-err:
-	devm_pinctrl_put(pnctrl_info->pinctrl);
-	return -EINVAL;
-}
-
-static int audio_ref_clk_probe(struct platform_device *pdev)
-{
-	int clk_gpio;
-	int ret;
-	u32 mclk_freq;
-	struct clk *audio_clk;
-	struct device *dev = &pdev->dev;
-	int i;
-	struct clk_onecell_data *clk_data;
-
-	ret = of_property_read_u32(pdev->dev.of_node,
-			"qcom,codec-mclk-clk-freq",
-			&mclk_freq);
-	if (!ret) {
-		lpass_mclk.clk_freq_in_hz = mclk_freq;
-
-		ret = audio_get_pinctrl(pdev, LPASS_MCLK);
-		if (ret)
-			dev_err(&pdev->dev, "%s: Parsing pinctrl %s failed\n",
-				__func__, "LPASS_MCLK");
-		ret = audio_get_pinctrl(pdev, LPASS_MCLK2);
-		if (ret)
-			dev_dbg(&pdev->dev, "%s: Parsing pinctrl %s failed\n",
-				__func__, "LPASS_MCLK2");
-	}
-
-	clk_gpio = of_get_named_gpio(pdev->dev.of_node,
-				     "qcom,audio-ref-clk-gpio", 0);
-	if (clk_gpio > 0) {
-		ret = gpio_request(clk_gpio, "EXT_CLK");
-		if (ret) {
-			dev_err(&pdev->dev,
-				"Request ext clk gpio failed %d, err:%d\n",
-				clk_gpio, ret);
-			goto err;
-		}
-		if (of_property_read_bool(pdev->dev.of_node,
-					"qcom,node_has_rpm_clock")) {
-			audio_pmi_clk.gpio = clk_gpio;
-		} else
-			audio_ap_clk.gpio = clk_gpio;
-
-	}
-
-	ret = audio_get_pinctrl(pdev, AP_CLK2);
-	if (ret)
-		dev_dbg(&pdev->dev, "%s: Parsing pinctrl failed\n",
-			__func__);
-
-	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
-	if (!clk_data)
-		goto err_gpio;
-
-
-	clk_gpio = of_get_named_gpio(pdev->dev.of_node,
-				     "qcom,audio-ref-clk-gpio", 0);
-	if (clk_gpio > 0) {
-		clk_data->clk_num = ARRAY_SIZE(audio_msm_hws);
-		clk_data->clks = devm_kzalloc(&pdev->dev,
-					clk_data->clk_num *
-					sizeof(struct clk *),
-					GFP_KERNEL);
-		if (!clk_data->clks)
-			goto err_clk;
-
-		for (i = 0; i < ARRAY_SIZE(audio_msm_hws); i++) {
-			audio_clk = devm_clk_register(dev, audio_msm_hws[i]);
-			if (IS_ERR(audio_clk)) {
-				dev_err(&pdev->dev,
-					"%s: ref clock: %d register failed\n",
-					__func__, i);
-				return PTR_ERR(audio_clk);
-			}
-			clk_data->clks[i] = audio_clk;
-		}
-	} else {
-		clk_data->clk_num = ARRAY_SIZE(audio_msm_hws1);
-		clk_data->clks = devm_kzalloc(&pdev->dev,
-					clk_data->clk_num *
-					sizeof(struct clk *),
-					GFP_KERNEL);
-		if (!clk_data->clks)
-			goto err_clk;
-
-		for (i = 0; i < ARRAY_SIZE(audio_msm_hws1); i++) {
-			audio_clk = devm_clk_register(dev, audio_msm_hws1[i]);
-			if (IS_ERR(audio_clk)) {
-				dev_err(&pdev->dev,
-					"%s: ref clock: %d register failed\n",
-					__func__, i);
-				return PTR_ERR(audio_clk);
-			}
-			clk_data->clks[i] = audio_clk;
-		}
-	}
-
-	ret = of_clk_add_provider(pdev->dev.of_node,
-				of_clk_src_onecell_get, clk_data);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: audio ref clock register failed\n",
-			__func__);
-		goto err_gpio;
-	}
-
-	return 0;
-
-err_clk:
-	if (clk_data)
-		devm_kfree(&pdev->dev, clk_data->clks);
-	devm_kfree(&pdev->dev, clk_data);
-err_gpio:
-	gpio_free(clk_gpio);
-
-err:
-	return ret;
-}
-
-static int audio_ref_clk_remove(struct platform_device *pdev)
-{
-	struct pinctrl_info *pnctrl_info = &audio_ap_clk2.pnctrl_info;
-
-	if (audio_pmi_clk.gpio > 0)
-		gpio_free(audio_pmi_clk.gpio);
-	else if (audio_ap_clk.gpio > 0)
-		gpio_free(audio_ap_clk.gpio);
-
-	if (pnctrl_info->pinctrl) {
-		devm_pinctrl_put(pnctrl_info->pinctrl);
-		pnctrl_info->pinctrl = NULL;
-	}
-
-	return 0;
-}
-
-static const struct of_device_id audio_ref_clk_match[] = {
-	{.compatible = "qcom,audio-ref-clk"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, audio_ref_clk_match);
-
-static struct platform_driver audio_ref_clk_driver = {
-	.driver = {
-		.name = "audio-ref-clk",
-		.owner = THIS_MODULE,
-		.of_match_table = audio_ref_clk_match,
-	},
-	.probe = audio_ref_clk_probe,
-	.remove = audio_ref_clk_remove,
-};
-
-int audio_ref_clk_platform_init(void)
-{
-	return platform_driver_register(&audio_ref_clk_driver);
-}
-
-void audio_ref_clk_platform_exit(void)
-{
-	platform_driver_unregister(&audio_ref_clk_driver);
-}
-
-MODULE_DESCRIPTION("Audio Ref Up Clock module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/msm_hdmi_codec_rx.c b/sound/soc/codecs/msm_hdmi_codec_rx.c
deleted file mode 100644
index 46cfe7d..0000000
--- a/sound/soc/codecs/msm_hdmi_codec_rx.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/of_device.h>
-#include <linux/err.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <linux/msm_ext_display.h>
-
-#define MSM_EXT_DISP_PCM_RATES	SNDRV_PCM_RATE_48000
-#define AUD_EXT_DISP_ACK_DISCONNECT (AUDIO_ACK_CONNECT ^ AUDIO_ACK_CONNECT)
-#define AUD_EXT_DISP_ACK_CONNECT    (AUDIO_ACK_CONNECT)
-#define AUD_EXT_DISP_ACK_ENABLE     (AUDIO_ACK_SET_ENABLE | AUDIO_ACK_ENABLE)
-
-static const char *const ext_disp_audio_type_text[] = {"None", "HDMI", "DP"};
-static const char *const ext_disp_audio_ack_text[] = {"Disconnect",  "Connect",
-						      "Ack_Enable"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_audio_type, ext_disp_audio_type_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_audio_ack_state,
-				ext_disp_audio_ack_text);
-
-struct msm_ext_disp_audio_codec_rx_data {
-	struct platform_device *ext_disp_core_pdev;
-	struct msm_ext_disp_audio_codec_ops ext_disp_ops;
-	int cable_status;
-};
-
-static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_info *uinfo)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-	struct msm_ext_disp_audio_edid_blk edid_blk;
-	int rc;
-
-	codec_data = snd_soc_codec_get_drvdata(codec);
-
-	if (!codec_data) {
-		dev_err(codec->dev, "%s: codec_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!codec_data->ext_disp_ops.get_audio_edid_blk) {
-		dev_dbg(codec->dev, "%s: get_audio_edid_blk() is NULL\n",
-			__func__);
-		uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-		uinfo->count = 0;
-		return 0;
-	}
-
-	rc = codec_data->ext_disp_ops.get_audio_edid_blk(
-				codec_data->ext_disp_core_pdev, &edid_blk);
-	if (rc >= 0) {
-		uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-		uinfo->count = edid_blk.audio_data_blk_size +
-			edid_blk.spk_alloc_data_blk_size;
-	}
-
-	dev_dbg(codec->dev, "%s: count: %d\n", __func__, uinfo->count);
-
-	return rc;
-}
-
-static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol) {
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-	struct msm_ext_disp_audio_edid_blk edid_blk;
-	int rc;
-
-	codec_data = snd_soc_codec_get_drvdata(codec);
-	if (!codec_data || !codec_data->ext_disp_ops.get_audio_edid_blk) {
-		dev_err(codec->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	rc = codec_data->ext_disp_ops.get_audio_edid_blk(
-			codec_data->ext_disp_core_pdev, &edid_blk);
-	if (rc >= 0) {
-		if (sizeof(ucontrol->value.bytes.data) <
-			  (edid_blk.audio_data_blk_size +
-			   edid_blk.spk_alloc_data_blk_size)) {
-			dev_err(codec->dev,
-				"%s: Not enough memory to copy EDID data\n",
-				__func__);
-			return -ENOMEM;
-		}
-
-		memcpy(ucontrol->value.bytes.data,
-		       edid_blk.audio_data_blk,
-		       edid_blk.audio_data_blk_size);
-		memcpy((ucontrol->value.bytes.data +
-		       edid_blk.audio_data_blk_size),
-		       edid_blk.spk_alloc_data_blk,
-		       edid_blk.spk_alloc_data_blk_size);
-
-		dev_dbg(codec->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n",
-			__func__, edid_blk.audio_data_blk_size,
-			edid_blk.spk_alloc_data_blk_size);
-	}
-
-	return rc;
-}
-
-static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-	enum msm_ext_disp_cable_state cable_state;
-	enum msm_ext_disp_type disp_type;
-	int rc;
-
-	codec_data = snd_soc_codec_get_drvdata(codec);
-	if (!codec_data ||
-	    !codec_data->ext_disp_ops.get_audio_edid_blk ||
-	    !codec_data->ext_disp_ops.get_intf_id) {
-		dev_err(codec->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	cable_state = codec_data->ext_disp_ops.cable_status(
-				   codec_data->ext_disp_core_pdev, 1);
-	if (cable_state < 0) {
-		dev_err(codec->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
-			__func__, cable_state);
-		rc = cable_state;
-		goto done;
-	}
-
-	codec_data->cable_status = cable_state;
-	if (cable_state == EXT_DISPLAY_CABLE_DISCONNECT) {
-		dev_err(codec->dev, "%s: Display cable disconnected\n",
-			__func__);
-		ucontrol->value.integer.value[0] = 0;
-		rc = 0;
-		goto done;
-	}
-
-	disp_type = codec_data->ext_disp_ops.get_intf_id(
-						codec_data->ext_disp_core_pdev);
-	if (disp_type >= 0) {
-		switch (disp_type) {
-		case EXT_DISPLAY_TYPE_DP:
-			ucontrol->value.integer.value[0] = 2;
-			rc = 0;
-			break;
-		case EXT_DISPLAY_TYPE_HDMI:
-			ucontrol->value.integer.value[0] = 1;
-			rc = 0;
-			break;
-		default:
-			rc = -EINVAL;
-			dev_err(codec->dev, "%s: Invalid disp_type:%d\n",
-			       __func__, disp_type);
-			goto done;
-		}
-		dev_dbg(codec->dev, "%s: Display type: %d\n",
-			__func__, disp_type);
-	} else {
-		dev_err(codec->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
-			__func__, disp_type);
-		rc = disp_type;
-	}
-
-done:
-	return rc;
-}
-
-static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-	u32 ack_state = 0;
-	int rc;
-
-	codec_data = snd_soc_codec_get_drvdata(codec);
-	if (!codec_data ||
-	    !codec_data->ext_disp_ops.acknowledge) {
-		dev_err(codec->dev,
-			"%s: codec_data or ops acknowledge() is NULL\n",
-			__func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	switch (ucontrol->value.enumerated.item[0]) {
-	case 0:
-		ack_state = AUD_EXT_DISP_ACK_DISCONNECT;
-		break;
-	case 1:
-		ack_state = AUD_EXT_DISP_ACK_CONNECT;
-		break;
-	case 2:
-		ack_state = AUD_EXT_DISP_ACK_ENABLE;
-		break;
-	default:
-		rc = -EINVAL;
-		dev_err(codec->dev,
-			"%s: invalid value %d for mixer ctl\n",
-			__func__, ucontrol->value.enumerated.item[0]);
-		goto done;
-	}
-	dev_dbg(codec->dev, "%s: control %d, ack set value 0x%x\n",
-		__func__, ucontrol->value.enumerated.item[0], ack_state);
-
-	rc = codec_data->ext_disp_ops.acknowledge(
-			 codec_data->ext_disp_core_pdev, ack_state);
-	if (rc < 0) {
-		dev_err(codec->dev, "%s: error from acknowledge(), err:%d\n",
-			__func__, rc);
-	}
-
-done:
-	return rc;
-}
-
-static const struct snd_kcontrol_new msm_ext_disp_codec_rx_controls[] = {
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ |
-			  SNDRV_CTL_ELEM_ACCESS_VOLATILE,
-		.iface  = SNDRV_CTL_ELEM_IFACE_PCM,
-		.name   = "HDMI EDID",
-		.info   = msm_ext_disp_edid_ctl_info,
-		.get    = msm_ext_disp_edid_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ |
-			  SNDRV_CTL_ELEM_ACCESS_VOLATILE,
-		.iface  = SNDRV_CTL_ELEM_IFACE_PCM,
-		.name   = "Display Port EDID",
-		.info   = msm_ext_disp_edid_ctl_info,
-		.get    = msm_ext_disp_edid_get,
-	},
-	SOC_ENUM_EXT("External Display Type", ext_disp_audio_type,
-		     msm_ext_disp_audio_type_get, NULL),
-	SOC_ENUM_EXT("External Display Audio Ack", ext_disp_audio_ack_state,
-		     NULL, msm_ext_disp_audio_ack_set),
-};
-
-static int msm_ext_disp_audio_codec_rx_dai_startup(
-		struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	int ret = 0;
-	struct msm_ext_disp_audio_codec_rx_data *codec_data =
-			dev_get_drvdata(dai->codec->dev);
-
-	if (!codec_data || !codec_data->ext_disp_ops.cable_status) {
-		dev_err(dai->dev, "%s() codec_data or cable_status is null\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	codec_data->cable_status =
-		codec_data->ext_disp_ops.cable_status(
-		codec_data->ext_disp_core_pdev, 1);
-	if (codec_data->cable_status < 0) {
-		dev_err(dai->dev,
-			"%s() ext disp core is not ready (ret val = %d)\n",
-			__func__, codec_data->cable_status);
-		ret = codec_data->cable_status;
-	} else if (!codec_data->cable_status) {
-		dev_err(dai->dev,
-			"%s() ext disp cable is not connected (ret val = %d)\n",
-			__func__, codec_data->cable_status);
-		ret = -ENODEV;
-	}
-
-	return ret;
-}
-
-static int msm_ext_disp_audio_codec_rx_dai_hw_params(
-		struct snd_pcm_substream *substream,
-		struct snd_pcm_hw_params *params,
-		struct snd_soc_dai *dai)
-{
-	u32 channel_allocation = 0;
-	u32 level_shift  = 0; /* 0dB */
-	bool down_mix = 0;
-	u32 num_channels = params_channels(params);
-	int rc = 0;
-	struct msm_ext_disp_audio_setup_params audio_setup_params = {0};
-
-	struct msm_ext_disp_audio_codec_rx_data *codec_data =
-			dev_get_drvdata(dai->codec->dev);
-
-	if (!codec_data || !codec_data->ext_disp_ops.audio_info_setup) {
-		dev_err(dai->dev, "%s: codec_data or audio_info_setup is null\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (codec_data->cable_status < 0) {
-		dev_err_ratelimited(dai->dev,
-			"%s() ext disp core is not ready (ret val = %d)\n",
-			__func__, codec_data->cable_status);
-		return codec_data->cable_status;
-	} else if (!codec_data->cable_status) {
-		dev_err_ratelimited(dai->dev,
-			"%s() ext disp cable is not connected (ret val = %d)\n",
-			__func__, codec_data->cable_status);
-		return -ENODEV;
-	}
-
-	/*refer to HDMI spec CEA-861-E: Table 28 Audio InfoFrame Data Byte 4*/
-	switch (num_channels) {
-	case 2:
-		channel_allocation  = 0;
-		break;
-	case 3:
-		channel_allocation  = 0x02;/*default to FL/FR/FC*/
-		audio_setup_params.sample_present = 0x3;
-		break;
-	case 4:
-		channel_allocation  = 0x06;/*default to FL/FR/FC/RC*/
-		audio_setup_params.sample_present = 0x7;
-		break;
-	case 5:
-		channel_allocation  = 0x0A;/*default to FL/FR/FC/RR/RL*/
-		audio_setup_params.sample_present = 0x7;
-		break;
-	case 6:
-		channel_allocation  = 0x0B;
-		audio_setup_params.sample_present = 0x7;
-		break;
-	case 7:
-		channel_allocation  = 0x12;/*default to FL/FR/FC/RL/RR/RRC/RLC*/
-		audio_setup_params.sample_present = 0xf;
-		break;
-	case 8:
-		channel_allocation  = 0x13;
-		audio_setup_params.sample_present = 0xf;
-		break;
-	default:
-		dev_err(dai->dev, "invalid Channels = %u\n", num_channels);
-		return -EINVAL;
-	}
-
-	dev_dbg(dai->dev,
-		"%s() num_ch %u  samplerate %u channel_allocation = %u\n",
-		__func__, num_channels, params_rate(params),
-		channel_allocation);
-
-	audio_setup_params.sample_rate_hz = params_rate(params);
-	audio_setup_params.num_of_channels = num_channels;
-	audio_setup_params.channel_allocation = channel_allocation;
-	audio_setup_params.level_shift = level_shift;
-	audio_setup_params.down_mix = down_mix;
-
-	rc = codec_data->ext_disp_ops.audio_info_setup(
-			codec_data->ext_disp_core_pdev, &audio_setup_params);
-	if (rc < 0) {
-		dev_err_ratelimited(dai->dev,
-			"%s() ext disp core is not ready, rc: %d\n",
-			__func__, rc);
-	}
-
-	return rc;
-}
-
-static void msm_ext_disp_audio_codec_rx_dai_shutdown(
-		struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	int rc;
-
-	struct msm_ext_disp_audio_codec_rx_data *codec_data =
-			dev_get_drvdata(dai->codec->dev);
-
-	if (!codec_data || !codec_data->ext_disp_ops.teardown_done ||
-	    !codec_data->ext_disp_ops.cable_status) {
-		dev_err(dai->dev, "%s: codec data or teardown_done or cable_status is null\n",
-			__func__);
-		return;
-	}
-
-	rc = codec_data->ext_disp_ops.cable_status(
-			codec_data->ext_disp_core_pdev, 0);
-	if (rc < 0) {
-		dev_err(dai->dev,
-			"%s: ext disp core had problems releasing audio flag\n",
-			__func__);
-	}
-
-	codec_data->ext_disp_ops.teardown_done(
-		codec_data->ext_disp_core_pdev);
-}
-
-static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
-{
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-	struct device_node *of_node_parent = NULL;
-
-	codec_data = kzalloc(sizeof(struct msm_ext_disp_audio_codec_rx_data),
-		GFP_KERNEL);
-
-	if (!codec_data) {
-		dev_err(codec->dev, "%s(): fail to allocate dai data\n",
-				__func__);
-		return -ENOMEM;
-	}
-
-	of_node_parent = of_get_parent(codec->dev->of_node);
-	if (!of_node_parent) {
-		dev_err(codec->dev, "%s(): Parent device tree node not found\n",
-				__func__);
-		kfree(codec_data);
-		return -ENODEV;
-	}
-
-	codec_data->ext_disp_core_pdev = of_find_device_by_node(of_node_parent);
-	if (!codec_data->ext_disp_core_pdev) {
-		dev_err(codec->dev, "%s(): can't get parent pdev\n", __func__);
-		kfree(codec_data);
-		return -ENODEV;
-	}
-
-	if (msm_ext_disp_register_audio_codec(codec_data->ext_disp_core_pdev,
-				&codec_data->ext_disp_ops)) {
-		dev_err(codec->dev, "%s(): can't register with ext disp core",
-				__func__);
-		kfree(codec_data);
-		return -ENODEV;
-	}
-
-	dev_set_drvdata(codec->dev, codec_data);
-
-	dev_dbg(codec->dev, "%s(): registered %s with ext disp core\n",
-		__func__, codec->component.name);
-
-	return 0;
-}
-
-static int msm_ext_disp_audio_codec_rx_remove(struct snd_soc_codec *codec)
-{
-	struct msm_ext_disp_audio_codec_rx_data *codec_data;
-
-	codec_data = dev_get_drvdata(codec->dev);
-	kfree(codec_data);
-
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_ext_disp_audio_codec_rx_dai_ops = {
-	.startup   = msm_ext_disp_audio_codec_rx_dai_startup,
-	.hw_params = msm_ext_disp_audio_codec_rx_dai_hw_params,
-	.shutdown  = msm_ext_disp_audio_codec_rx_dai_shutdown
-};
-
-static struct snd_soc_dai_driver msm_ext_disp_audio_codec_rx_dais[] = {
-	{
-		.name = "msm_hdmi_audio_codec_rx_dai",
-		.playback = {
-			.stream_name = "HDMI Playback",
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 48000,
-			.rate_max = 48000,
-			.rates = MSM_EXT_DISP_PCM_RATES,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		},
-		.ops = &msm_ext_disp_audio_codec_rx_dai_ops,
-	},
-	{
-		.name = "msm_dp_audio_codec_rx_dai",
-		.playback = {
-			.stream_name = "Display Port Playback",
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 48000,
-			.rate_max = 192000,
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-		},
-		.ops = &msm_ext_disp_audio_codec_rx_dai_ops,
-	},
-};
-
-static struct snd_soc_codec_driver msm_ext_disp_audio_codec_rx_soc_driver = {
-	.probe = msm_ext_disp_audio_codec_rx_probe,
-	.remove =  msm_ext_disp_audio_codec_rx_remove,
-	.component_driver = {
-		.controls = msm_ext_disp_codec_rx_controls,
-		.num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls),
-	},
-};
-
-static int msm_ext_disp_audio_codec_rx_plat_probe(
-		struct platform_device *pdev)
-{
-	dev_dbg(&pdev->dev, "%s(): dev name %s\n", __func__,
-		dev_name(&pdev->dev));
-
-	return snd_soc_register_codec(&pdev->dev,
-		&msm_ext_disp_audio_codec_rx_soc_driver,
-		msm_ext_disp_audio_codec_rx_dais,
-		ARRAY_SIZE(msm_ext_disp_audio_codec_rx_dais));
-}
-
-static int msm_ext_disp_audio_codec_rx_plat_remove(
-		struct platform_device *pdev)
-{
-	snd_soc_unregister_codec(&pdev->dev);
-	return 0;
-}
-static const struct of_device_id msm_ext_disp_audio_codec_rx_dt_match[] = {
-	{ .compatible = "qcom,msm-ext-disp-audio-codec-rx", },
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_ext_disp_audio_codec_rx_dt_match);
-
-static struct platform_driver msm_ext_disp_audio_codec_rx_driver = {
-	.driver = {
-		.name = "msm-ext-disp-audio-codec-rx",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_ext_disp_audio_codec_rx_dt_match,
-	},
-	.probe = msm_ext_disp_audio_codec_rx_plat_probe,
-	.remove = msm_ext_disp_audio_codec_rx_plat_remove,
-};
-
-static int __init msm_ext_disp_audio_codec_rx_init(void)
-{
-	int rc;
-
-	rc = platform_driver_register(&msm_ext_disp_audio_codec_rx_driver);
-	if (rc) {
-		pr_err("%s: failed to register ext disp codec driver err:%d\n",
-		       __func__, rc);
-	}
-
-	return rc;
-}
-module_init(msm_ext_disp_audio_codec_rx_init);
-
-static void __exit msm_ext_disp_audio_codec_rx_exit(void)
-{
-	platform_driver_unregister(&msm_ext_disp_audio_codec_rx_driver);
-}
-module_exit(msm_ext_disp_audio_codec_rx_exit);
-
-MODULE_DESCRIPTION("MSM External Display Audio CODEC Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/msm_sdw/Kconfig b/sound/soc/codecs/msm_sdw/Kconfig
deleted file mode 100644
index abd7c8c..0000000
--- a/sound/soc/codecs/msm_sdw/Kconfig
+++ /dev/null
@@ -1,6 +0,0 @@
-config SND_SOC_MSM_SDW
-	tristate "MSM Internal soundwire codec"
-	 help
-	 MSM-based soundwire codec core driver
-	 supported along with internal digital
-	 codec core.
diff --git a/sound/soc/codecs/msm_sdw/Makefile b/sound/soc/codecs/msm_sdw/Makefile
deleted file mode 100644
index 64e932b..0000000
--- a/sound/soc/codecs/msm_sdw/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-snd-soc-msm-sdw-objs := msm_sdw_cdc.o msm_sdw_regmap.o msm-sdw-tables.o msm_sdw_cdc_utils.o
-obj-$(CONFIG_SND_SOC_MSM_SDW)	+= snd-soc-msm-sdw.o
-ccflags-y += -I$(srctree)/sound/soc/msm
diff --git a/sound/soc/codecs/msm_sdw/msm-sdw-tables.c b/sound/soc/codecs/msm_sdw/msm-sdw-tables.c
deleted file mode 100644
index 1b51805..0000000
--- a/sound/soc/codecs/msm_sdw/msm-sdw-tables.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/types.h>
-#include "msm_sdw.h"
-
-const u8 msm_sdw_page_map[MSM_SDW_MAX_REGISTER] = {
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CTL] = 0xa,
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CFG0] = 0xa,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CTL] = 0xa,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CFG0] = 0xa,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CTL] = 0xa,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CFG0] = 0xa,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CTL] = 0xa,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CFG0] = 0xa,
-	[MSM_SDW_COMPANDER7_CTL0] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL1] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL2] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL3] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL4] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL5] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL6] = 0xb,
-	[MSM_SDW_COMPANDER7_CTL7] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL0] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL1] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL2] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL3] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL4] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL5] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL6] = 0xb,
-	[MSM_SDW_COMPANDER8_CTL7] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_CTL] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_CFG0] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_CFG1] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_CFG2] = 0xb,
-	[MSM_SDW_RX7_RX_VOL_CTL] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_MIX_CTL] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_MIX_CFG] = 0xb,
-	[MSM_SDW_RX7_RX_VOL_MIX_CTL] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC0] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC1] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC2] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC3] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC5] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC6] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_SEC7] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC0] = 0xb,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC1] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_CTL] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_CFG0] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_CFG1] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_CFG2] = 0xb,
-	[MSM_SDW_RX8_RX_VOL_CTL] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_MIX_CTL] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_MIX_CFG] = 0xb,
-	[MSM_SDW_RX8_RX_VOL_MIX_CTL] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC0] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC1] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC2] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC3] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC5] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC6] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_SEC7] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC0] = 0xb,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC1] = 0xb,
-	[MSM_SDW_BOOST0_BOOST_PATH_CTL] = 0xc,
-	[MSM_SDW_BOOST0_BOOST_CTL] = 0xc,
-	[MSM_SDW_BOOST0_BOOST_CFG1] = 0xc,
-	[MSM_SDW_BOOST0_BOOST_CFG2] = 0xc,
-	[MSM_SDW_BOOST1_BOOST_PATH_CTL] = 0xc,
-	[MSM_SDW_BOOST1_BOOST_CTL] = 0xc,
-	[MSM_SDW_BOOST1_BOOST_CFG1] = 0xc,
-	[MSM_SDW_BOOST1_BOOST_CFG2] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_0] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_1] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_2] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_3] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_0] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_1] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_2] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_3] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_0] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_1] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_2] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_3] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_0] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_1] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_2] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_3] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_ACCESS_CFG] = 0xc,
-	[MSM_SDW_AHB_BRIDGE_ACCESS_STATUS] = 0xc,
-	[MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL] = 0xd,
-	[MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL] = 0xd,
-	[MSM_SDW_CLK_RST_CTRL_SWR_CONTROL] = 0xd,
-	[MSM_SDW_TOP_TOP_CFG0] = 0xd,
-	[MSM_SDW_TOP_TOP_CFG1] = 0xd,
-	[MSM_SDW_TOP_RX_I2S_CTL] = 0xd,
-	[MSM_SDW_TOP_TX_I2S_CTL] = 0xd,
-	[MSM_SDW_TOP_I2S_CLK] = 0xd,
-	[MSM_SDW_TOP_RX7_PATH_INPUT0_MUX] = 0xd,
-	[MSM_SDW_TOP_RX7_PATH_INPUT1_MUX] = 0xd,
-	[MSM_SDW_TOP_RX8_PATH_INPUT0_MUX] = 0xd,
-	[MSM_SDW_TOP_RX8_PATH_INPUT1_MUX] = 0xd,
-	[MSM_SDW_TOP_FREQ_MCLK] = 0xd,
-	[MSM_SDW_TOP_DEBUG_BUS_SEL] = 0xd,
-	[MSM_SDW_TOP_DEBUG_EN] = 0xd,
-	[MSM_SDW_TOP_I2S_RESET] = 0xd,
-	[MSM_SDW_TOP_BLOCKS_RESET] = 0xd,
-};
-
-const u8 msm_sdw_reg_readable[MSM_SDW_MAX_REGISTER] = {
-	[MSM_SDW_PAGE_REGISTER] = 1,
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_COMPANDER7_CTL0] = 1,
-	[MSM_SDW_COMPANDER7_CTL1] = 1,
-	[MSM_SDW_COMPANDER7_CTL2] = 1,
-	[MSM_SDW_COMPANDER7_CTL3] = 1,
-	[MSM_SDW_COMPANDER7_CTL4] = 1,
-	[MSM_SDW_COMPANDER7_CTL5] = 1,
-	[MSM_SDW_COMPANDER7_CTL6] = 1,
-	[MSM_SDW_COMPANDER7_CTL7] = 1,
-	[MSM_SDW_COMPANDER8_CTL0] = 1,
-	[MSM_SDW_COMPANDER8_CTL1] = 1,
-	[MSM_SDW_COMPANDER8_CTL2] = 1,
-	[MSM_SDW_COMPANDER8_CTL3] = 1,
-	[MSM_SDW_COMPANDER8_CTL4] = 1,
-	[MSM_SDW_COMPANDER8_CTL5] = 1,
-	[MSM_SDW_COMPANDER8_CTL6] = 1,
-	[MSM_SDW_COMPANDER8_CTL7] = 1,
-	[MSM_SDW_RX7_RX_PATH_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG0] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG1] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG2] = 1,
-	[MSM_SDW_RX7_RX_VOL_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_CFG] = 1,
-	[MSM_SDW_RX7_RX_VOL_MIX_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC0] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC1] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC2] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC3] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC5] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC6] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC7] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC0] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC1] = 1,
-	[MSM_SDW_RX8_RX_PATH_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG0] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG1] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG2] = 1,
-	[MSM_SDW_RX8_RX_VOL_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_CFG] = 1,
-	[MSM_SDW_RX8_RX_VOL_MIX_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC0] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC1] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC2] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC3] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC5] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC6] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC7] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC0] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC1] = 1,
-	[MSM_SDW_BOOST0_BOOST_PATH_CTL] = 1,
-	[MSM_SDW_BOOST0_BOOST_CTL] = 1,
-	[MSM_SDW_BOOST0_BOOST_CFG1] = 1,
-	[MSM_SDW_BOOST0_BOOST_CFG2] = 1,
-	[MSM_SDW_BOOST1_BOOST_PATH_CTL] = 1,
-	[MSM_SDW_BOOST1_BOOST_CTL] = 1,
-	[MSM_SDW_BOOST1_BOOST_CFG1] = 1,
-	[MSM_SDW_BOOST1_BOOST_CFG2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_DATA_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_ACCESS_CFG] = 1,
-	[MSM_SDW_AHB_BRIDGE_ACCESS_STATUS] = 1,
-	[MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL] = 1,
-	[MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL] = 1,
-	[MSM_SDW_CLK_RST_CTRL_SWR_CONTROL] = 1,
-	[MSM_SDW_TOP_TOP_CFG0] = 1,
-	[MSM_SDW_TOP_TOP_CFG1] = 1,
-	[MSM_SDW_TOP_RX_I2S_CTL] = 1,
-	[MSM_SDW_TOP_TX_I2S_CTL] = 1,
-	[MSM_SDW_TOP_RX7_PATH_INPUT0_MUX] = 1,
-	[MSM_SDW_TOP_RX7_PATH_INPUT1_MUX] = 1,
-	[MSM_SDW_TOP_RX8_PATH_INPUT0_MUX] = 1,
-	[MSM_SDW_TOP_RX8_PATH_INPUT1_MUX] = 1,
-	[MSM_SDW_TOP_FREQ_MCLK] = 1,
-	[MSM_SDW_TOP_DEBUG_BUS_SEL] = 1,
-	[MSM_SDW_TOP_DEBUG_EN] = 1,
-	[MSM_SDW_TOP_I2S_RESET] = 1,
-	[MSM_SDW_TOP_BLOCKS_RESET] = 1,
-};
-
-const u8 msm_sdw_reg_writeable[MSM_SDW_MAX_REGISTER] = {
-	[MSM_SDW_PAGE_REGISTER] = 1,
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX9_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX10_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX11_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CTL] = 1,
-	[MSM_SDW_TX12_SPKR_PROT_PATH_CFG0] = 1,
-	[MSM_SDW_COMPANDER7_CTL0] = 1,
-	[MSM_SDW_COMPANDER7_CTL1] = 1,
-	[MSM_SDW_COMPANDER7_CTL2] = 1,
-	[MSM_SDW_COMPANDER7_CTL3] = 1,
-	[MSM_SDW_COMPANDER7_CTL4] = 1,
-	[MSM_SDW_COMPANDER7_CTL5] = 1,
-	[MSM_SDW_COMPANDER7_CTL7] = 1,
-	[MSM_SDW_COMPANDER8_CTL0] = 1,
-	[MSM_SDW_COMPANDER8_CTL1] = 1,
-	[MSM_SDW_COMPANDER8_CTL2] = 1,
-	[MSM_SDW_COMPANDER8_CTL3] = 1,
-	[MSM_SDW_COMPANDER8_CTL4] = 1,
-	[MSM_SDW_COMPANDER8_CTL5] = 1,
-	[MSM_SDW_COMPANDER8_CTL7] = 1,
-	[MSM_SDW_RX7_RX_PATH_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG0] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG1] = 1,
-	[MSM_SDW_RX7_RX_PATH_CFG2] = 1,
-	[MSM_SDW_RX7_RX_VOL_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_CFG] = 1,
-	[MSM_SDW_RX7_RX_VOL_MIX_CTL] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC0] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC1] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC2] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC3] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC5] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC6] = 1,
-	[MSM_SDW_RX7_RX_PATH_SEC7] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC0] = 1,
-	[MSM_SDW_RX7_RX_PATH_MIX_SEC1] = 1,
-	[MSM_SDW_RX8_RX_PATH_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG0] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG1] = 1,
-	[MSM_SDW_RX8_RX_PATH_CFG2] = 1,
-	[MSM_SDW_RX8_RX_VOL_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_CFG] = 1,
-	[MSM_SDW_RX8_RX_VOL_MIX_CTL] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC0] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC1] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC2] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC3] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC5] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC6] = 1,
-	[MSM_SDW_RX8_RX_PATH_SEC7] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC0] = 1,
-	[MSM_SDW_RX8_RX_PATH_MIX_SEC1] = 1,
-	[MSM_SDW_BOOST0_BOOST_PATH_CTL] = 1,
-	[MSM_SDW_BOOST0_BOOST_CTL] = 1,
-	[MSM_SDW_BOOST0_BOOST_CFG1] = 1,
-	[MSM_SDW_BOOST0_BOOST_CFG2] = 1,
-	[MSM_SDW_BOOST1_BOOST_PATH_CTL] = 1,
-	[MSM_SDW_BOOST1_BOOST_CTL] = 1,
-	[MSM_SDW_BOOST1_BOOST_CFG1] = 1,
-	[MSM_SDW_BOOST1_BOOST_CFG2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_DATA_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_WR_ADDR_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_0] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_1] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_2] = 1,
-	[MSM_SDW_AHB_BRIDGE_RD_ADDR_3] = 1,
-	[MSM_SDW_AHB_BRIDGE_ACCESS_CFG] = 1,
-	[MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL] = 1,
-	[MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL] = 1,
-	[MSM_SDW_CLK_RST_CTRL_SWR_CONTROL] = 1,
-	[MSM_SDW_TOP_TOP_CFG0] = 1,
-	[MSM_SDW_TOP_TOP_CFG1] = 1,
-	[MSM_SDW_TOP_RX_I2S_CTL] = 1,
-	[MSM_SDW_TOP_TX_I2S_CTL] = 1,
-	[MSM_SDW_TOP_RX7_PATH_INPUT0_MUX] = 1,
-	[MSM_SDW_TOP_RX7_PATH_INPUT1_MUX] = 1,
-	[MSM_SDW_TOP_RX8_PATH_INPUT0_MUX] = 1,
-	[MSM_SDW_TOP_RX8_PATH_INPUT1_MUX] = 1,
-	[MSM_SDW_TOP_FREQ_MCLK] = 1,
-	[MSM_SDW_TOP_DEBUG_BUS_SEL] = 1,
-	[MSM_SDW_TOP_DEBUG_EN] = 1,
-	[MSM_SDW_TOP_I2S_RESET] = 1,
-	[MSM_SDW_TOP_BLOCKS_RESET] = 1,
-};
diff --git a/sound/soc/codecs/msm_sdw/msm_sdw.h b/sound/soc/codecs/msm_sdw/msm_sdw.h
deleted file mode 100644
index 376ebc6..0000000
--- a/sound/soc/codecs/msm_sdw/msm_sdw.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 MSM_SDW_H
-#define MSM_SDW_H
-
-#include <sound/soc.h>
-#include <sound/q6afe-v2.h>
-#include "msm_sdw_registers.h"
-
-#define MSM_SDW_MAX_REGISTER 0x400
-
-extern const struct regmap_config msm_sdw_regmap_config;
-extern const u8 msm_sdw_page_map[MSM_SDW_MAX_REGISTER];
-extern const u8 msm_sdw_reg_readable[MSM_SDW_MAX_REGISTER];
-extern const u8 msm_sdw_reg_writeable[MSM_SDW_MAX_REGISTER];
-
-enum {
-	MSM_SDW_RX4 = 0,
-	MSM_SDW_RX5,
-	MSM_SDW_RX_MAX,
-};
-
-enum {
-	MSM_SDW_TX0 = 0,
-	MSM_SDW_TX1,
-	MSM_SDW_TX_MAX,
-};
-
-enum {
-	COMP1, /* SPK_L */
-	COMP2, /* SPK_R */
-	COMP_MAX
-};
-
-/*
- * Structure used to update codec
- * register defaults after reset
- */
-struct msm_sdw_reg_mask_val {
-	u16 reg;
-	u8 mask;
-	u8 val;
-};
-
-/*
- * Selects compander and smart boost settings
- * for a given speaker mode
- */
-enum {
-	SPKR_MODE_DEFAULT,
-	SPKR_MODE_1,          /* COMP Gain = 12dB, Smartboost Max = 5.5V */
-};
-
-/* Rx path gain offsets */
-enum {
-	RX_GAIN_OFFSET_M1P5_DB,
-	RX_GAIN_OFFSET_0_DB,
-};
-
-struct msm_sdw_reg_val {
-	unsigned short reg; /* register address */
-	u8 *buf;            /* buffer to be written to reg. addr */
-	int bytes;          /* number of bytes to be written */
-};
-
-/* Hold instance to soundwire platform device */
-struct msm_sdw_ctrl_data {
-	struct platform_device *sdw_pdev;
-};
-
-struct wcd_sdw_ctrl_platform_data {
-	void *handle; /* holds codec private data */
-	int (*read)(void *handle, int reg);
-	int (*write)(void *handle, int reg, int val);
-	int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
-	int (*clk)(void *handle, bool enable);
-	int (*handle_irq)(void *handle,
-			  irqreturn_t (*swrm_irq_handler)(int irq,
-							  void *data),
-			  void *swrm_handle,
-			  int action);
-};
-
-struct msm_sdw_priv {
-	struct device *dev;
-	struct mutex io_lock;
-
-	int (*read_dev)(struct msm_sdw_priv *msm_sdw, unsigned short reg,
-			int bytes, void *dest);
-	int (*write_dev)(struct msm_sdw_priv *msm_sdw, unsigned short reg,
-			 int bytes, void *src);
-	int (*multi_reg_write)(struct msm_sdw_priv *msm_sdw, const void *data,
-			       size_t count);
-	struct snd_soc_codec *codec;
-	struct device_node *sdw_gpio_p; /* used by pinctrl API */
-	/* SoundWire data structure */
-	struct msm_sdw_ctrl_data *sdw_ctrl_data;
-	int nr;
-
-	/* compander */
-	int comp_enabled[COMP_MAX];
-	int ear_spkr_gain;
-
-	/* to track the status */
-	unsigned long status_mask;
-
-	struct work_struct msm_sdw_add_child_devices_work;
-	struct wcd_sdw_ctrl_platform_data sdw_plat_data;
-
-	unsigned int vi_feed_value;
-
-	struct mutex sdw_read_lock;
-	struct mutex sdw_write_lock;
-	struct mutex sdw_clk_lock;
-	int sdw_clk_users;
-	int sdw_mclk_users;
-
-	int sdw_irq;
-	int int_mclk1_rsc_ref;
-	bool int_mclk1_enabled;
-	bool sdw_npl_clk_enabled;
-	struct mutex cdc_int_mclk1_mutex;
-	struct mutex sdw_npl_clk_mutex;
-	struct delayed_work disable_int_mclk1_work;
-	struct afe_clk_set sdw_cdc_core_clk;
-	struct afe_clk_set sdw_npl_clk;
-	struct notifier_block service_nb;
-	int (*sdw_cdc_gpio_fn)(bool enable, struct snd_soc_codec *codec);
-	bool dev_up;
-
-	int spkr_gain_offset;
-	int spkr_mode;
-	struct mutex codec_mutex;
-	int rx_4_count;
-	int rx_5_count;
-	u32 mclk_rate;
-	struct regmap *regmap;
-
-	bool prev_pg_valid;
-	u8 prev_pg;
-	u32 sdw_base_addr;
-	char __iomem *sdw_base;
-	u32 version;
-
-	/* Entry for version info */
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-};
-
-extern int msm_sdw_set_spkr_mode(struct snd_soc_codec *codec, int mode);
-extern int msm_sdw_set_spkr_gain_offset(struct snd_soc_codec *codec,
-					int offset);
-extern void msm_sdw_gpio_cb(
-	int (*sdw_cdc_gpio_fn)(bool enable, struct snd_soc_codec *codec),
-	struct snd_soc_codec *codec);
-extern struct regmap *msm_sdw_regmap_init(struct device *dev,
-					  const struct regmap_config *config);
-extern int msm_sdw_codec_info_create_codec_entry(
-	struct snd_info_entry *codec_root,
-	struct snd_soc_codec *codec);
-#endif
diff --git a/sound/soc/codecs/msm_sdw/msm_sdw_cdc.c b/sound/soc/codecs/msm_sdw/msm_sdw_cdc.c
deleted file mode 100644
index a253aea..0000000
--- a/sound/soc/codecs/msm_sdw/msm_sdw_cdc.c
+++ /dev/null
@@ -1,2009 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/io.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <linux/printk.h>
-#include <linux/debugfs.h>
-#include <linux/bitops.h>
-#include <linux/regmap.h>
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/soundwire/swr-wcd.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/q6core.h>
-#include <sound/tlv.h>
-#include "msm_sdw.h"
-#include "msm_sdw_registers.h"
-
-#define MSM_SDW_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000)
-#define MSM_SDW_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
-		SNDRV_PCM_FMTBIT_S24_LE |\
-		SNDRV_PCM_FMTBIT_S24_3LE)
-
-#define MSM_SDW_STRING_LEN 80
-
-#define INT_MCLK1_FREQ 9600000
-#define SDW_NPL_FREQ 153600000
-
-#define MSM_SDW_VERSION_1_0 0x0001
-#define MSM_SDW_VERSION_ENTRY_SIZE 32
-
-/*
- * 200 Milliseconds sufficient for DSP bring up in the modem
- * after Sub System Restart
- */
-#define ADSP_STATE_READY_TIMEOUT_MS 200
-
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
-static struct snd_soc_dai_driver msm_sdw_dai[];
-static bool skip_irq = true;
-
-static int msm_sdw_config_ear_spkr_gain(struct snd_soc_codec *codec,
-					int event, int gain_reg);
-static int msm_sdw_config_compander(struct snd_soc_codec *, int, int);
-static int msm_sdw_mclk_enable(struct msm_sdw_priv *msm_sdw,
-			       int mclk_enable, bool dapm);
-static int msm_int_enable_sdw_cdc_clk(struct msm_sdw_priv *msm_sdw,
-				      int enable, bool dapm);
-
-enum {
-	VI_SENSE_1,
-	VI_SENSE_2,
-};
-
-enum {
-	AIF1_SDW_PB = 0,
-	AIF1_SDW_VIFEED,
-	NUM_CODEC_DAIS,
-};
-
-static const struct msm_sdw_reg_mask_val msm_sdw_spkr_default[] = {
-	{MSM_SDW_COMPANDER7_CTL3, 0x80, 0x80},
-	{MSM_SDW_COMPANDER8_CTL3, 0x80, 0x80},
-	{MSM_SDW_COMPANDER7_CTL7, 0x01, 0x01},
-	{MSM_SDW_COMPANDER8_CTL7, 0x01, 0x01},
-	{MSM_SDW_BOOST0_BOOST_CTL, 0x7C, 0x50},
-	{MSM_SDW_BOOST1_BOOST_CTL, 0x7C, 0x50},
-};
-
-static const struct msm_sdw_reg_mask_val msm_sdw_spkr_mode1[] = {
-	{MSM_SDW_COMPANDER7_CTL3, 0x80, 0x00},
-	{MSM_SDW_COMPANDER8_CTL3, 0x80, 0x00},
-	{MSM_SDW_COMPANDER7_CTL7, 0x01, 0x00},
-	{MSM_SDW_COMPANDER8_CTL7, 0x01, 0x00},
-	{MSM_SDW_BOOST0_BOOST_CTL, 0x7C, 0x44},
-	{MSM_SDW_BOOST1_BOOST_CTL, 0x7C, 0x44},
-};
-
-/**
- * msm_sdw_set_spkr_gain_offset - offset the speaker path
- * gain with the given offset value.
- *
- * @codec: codec instance
- * @offset: Indicates speaker path gain offset value.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int msm_sdw_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
-{
-	struct msm_sdw_priv *priv;
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer!\n", __func__);
-		return -EINVAL;
-	}
-
-	priv = snd_soc_codec_get_drvdata(codec);
-	if (!priv)
-		return -EINVAL;
-
-	priv->spkr_gain_offset = offset;
-	return 0;
-}
-EXPORT_SYMBOL(msm_sdw_set_spkr_gain_offset);
-
-/**
- * msm_sdw_set_spkr_mode - Configures speaker compander and smartboost
- * settings based on speaker mode.
- *
- * @codec: codec instance
- * @mode: Indicates speaker configuration mode.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int msm_sdw_set_spkr_mode(struct snd_soc_codec *codec, int mode)
-{
-	struct msm_sdw_priv *priv;
-	int i;
-	const struct msm_sdw_reg_mask_val *regs;
-	int size;
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer!\n", __func__);
-		return -EINVAL;
-	}
-
-	priv = snd_soc_codec_get_drvdata(codec);
-	if (!priv)
-		return -EINVAL;
-
-	switch (mode) {
-	case SPKR_MODE_1:
-		regs = msm_sdw_spkr_mode1;
-		size = ARRAY_SIZE(msm_sdw_spkr_mode1);
-		break;
-	default:
-		regs = msm_sdw_spkr_default;
-		size = ARRAY_SIZE(msm_sdw_spkr_default);
-		break;
-	}
-
-	priv->spkr_mode = mode;
-	for (i = 0; i < size; i++)
-		snd_soc_update_bits(codec, regs[i].reg,
-				    regs[i].mask, regs[i].val);
-	return 0;
-}
-EXPORT_SYMBOL(msm_sdw_set_spkr_mode);
-
-static int msm_enable_sdw_npl_clk(struct msm_sdw_priv *msm_sdw, int enable)
-{
-	int ret = 0;
-
-	dev_dbg(msm_sdw->dev, "%s: enable %d\n", __func__, enable);
-
-	mutex_lock(&msm_sdw->sdw_npl_clk_mutex);
-	if (enable) {
-		if (msm_sdw->sdw_npl_clk_enabled == false) {
-			msm_sdw->sdw_npl_clk.enable = 1;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT4_MI2S_RX,
-				&msm_sdw->sdw_npl_clk);
-			if (ret < 0) {
-				dev_err(msm_sdw->dev,
-					"%s: failed to enable SDW NPL CLK\n",
-					__func__);
-				mutex_unlock(&msm_sdw->sdw_npl_clk_mutex);
-				return ret;
-			}
-			dev_dbg(msm_sdw->dev, "enabled sdw npl clk\n");
-			msm_sdw->sdw_npl_clk_enabled = true;
-		}
-	} else {
-		if (msm_sdw->sdw_npl_clk_enabled == true) {
-			msm_sdw->sdw_npl_clk.enable = 0;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT4_MI2S_RX,
-				&msm_sdw->sdw_npl_clk);
-			if (ret < 0)
-				dev_err(msm_sdw->dev,
-					"%s: failed to disable SDW NPL CLK\n",
-					__func__);
-			msm_sdw->sdw_npl_clk_enabled = false;
-		}
-	}
-	mutex_unlock(&msm_sdw->sdw_npl_clk_mutex);
-	return ret;
-}
-
-static int msm_int_enable_sdw_cdc_clk(struct msm_sdw_priv *msm_sdw,
-				      int enable, bool dapm)
-{
-	int ret = 0;
-
-	mutex_lock(&msm_sdw->cdc_int_mclk1_mutex);
-	dev_dbg(msm_sdw->dev, "%s: enable %d mclk1 ref counter %d\n",
-		__func__, enable, msm_sdw->int_mclk1_rsc_ref);
-	if (enable) {
-		if (msm_sdw->int_mclk1_rsc_ref == 0) {
-			cancel_delayed_work_sync(
-					&msm_sdw->disable_int_mclk1_work);
-			if (msm_sdw->int_mclk1_enabled == false) {
-				msm_sdw->sdw_cdc_core_clk.enable = 1;
-				ret = afe_set_lpass_clock_v2(
-					AFE_PORT_ID_INT4_MI2S_RX,
-					&msm_sdw->sdw_cdc_core_clk);
-				if (ret < 0) {
-					dev_err(msm_sdw->dev,
-						"%s: failed to enable SDW MCLK\n",
-						__func__);
-					goto rtn;
-				}
-				dev_dbg(msm_sdw->dev,
-					"enabled sdw codec core mclk\n");
-				msm_sdw->int_mclk1_enabled = true;
-			}
-		}
-		msm_sdw->int_mclk1_rsc_ref++;
-	} else {
-		cancel_delayed_work_sync(&msm_sdw->disable_int_mclk1_work);
-		if (msm_sdw->int_mclk1_rsc_ref > 0) {
-			msm_sdw->int_mclk1_rsc_ref--;
-			dev_dbg(msm_sdw->dev,
-				"%s: decrementing mclk_res_ref %d\n",
-				 __func__, msm_sdw->int_mclk1_rsc_ref);
-		}
-		if (msm_sdw->int_mclk1_enabled == true &&
-			msm_sdw->int_mclk1_rsc_ref == 0) {
-			msm_sdw->sdw_cdc_core_clk.enable = 0;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT4_MI2S_RX,
-				&msm_sdw->sdw_cdc_core_clk);
-			if (ret < 0)
-				dev_err(msm_sdw->dev,
-					"%s: failed to disable SDW MCLK\n",
-					__func__);
-			msm_sdw->int_mclk1_enabled = false;
-		}
-	}
-	mutex_unlock(&msm_sdw->cdc_int_mclk1_mutex);
-rtn:
-	return ret;
-}
-EXPORT_SYMBOL(msm_int_enable_sdw_cdc_clk);
-
-static void msm_disable_int_mclk1(struct work_struct *work)
-{
-	struct msm_sdw_priv *msm_sdw = NULL;
-	struct delayed_work *dwork;
-	int ret = 0;
-
-	dwork = to_delayed_work(work);
-	msm_sdw = container_of(dwork, struct msm_sdw_priv,
-			disable_int_mclk1_work);
-	mutex_lock(&msm_sdw->cdc_int_mclk1_mutex);
-	dev_dbg(msm_sdw->dev, "%s: mclk1_enabled %d mclk1_rsc_ref %d\n",
-		__func__, msm_sdw->int_mclk1_enabled,
-		msm_sdw->int_mclk1_rsc_ref);
-	if (msm_sdw->int_mclk1_enabled == true
-			&& msm_sdw->int_mclk1_rsc_ref == 0) {
-		dev_dbg(msm_sdw->dev, "Disable the mclk1\n");
-		msm_sdw->sdw_cdc_core_clk.enable = 0;
-		ret = afe_set_lpass_clock_v2(
-			AFE_PORT_ID_INT4_MI2S_RX,
-			&msm_sdw->sdw_cdc_core_clk);
-		if (ret < 0)
-			dev_err(msm_sdw->dev,
-				"%s failed to disable the MCLK1\n",
-				__func__);
-		msm_sdw->int_mclk1_enabled = false;
-	}
-	mutex_unlock(&msm_sdw->cdc_int_mclk1_mutex);
-}
-
-static int msm_int_mclk1_event(struct snd_soc_dapm_widget *w,
-			       struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	dev_dbg(msm_sdw->dev, "%s: event = %d\n", __func__, event);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* enable the codec mclk config */
-		msm_int_enable_sdw_cdc_clk(msm_sdw, 1, true);
-		msm_sdw_mclk_enable(msm_sdw, 1, true);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* disable the codec mclk config */
-		msm_sdw_mclk_enable(msm_sdw, 0, true);
-		msm_int_enable_sdw_cdc_clk(msm_sdw, 0, true);
-		break;
-	default:
-		dev_err(msm_sdw->dev,
-			"%s: invalid DAPM event %d\n", __func__, event);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int msm_sdw_ahb_write_device(struct msm_sdw_priv *msm_sdw,
-					u16 reg, u8 *value)
-{
-	u32 temp = (u32)(*value) & 0x000000FF;
-
-	if (!msm_sdw->dev_up) {
-		dev_err_ratelimited(msm_sdw->dev, "%s: q6 not ready\n",
-				    __func__);
-		return 0;
-	}
-
-	iowrite32(temp, msm_sdw->sdw_base + reg);
-	return 0;
-}
-
-static int msm_sdw_ahb_read_device(struct msm_sdw_priv *msm_sdw,
-					u16 reg, u8 *value)
-{
-	u32 temp;
-
-	if (!msm_sdw->dev_up) {
-		dev_err_ratelimited(msm_sdw->dev, "%s: q6 not ready\n",
-				    __func__);
-		return 0;
-	}
-
-	temp = ioread32(msm_sdw->sdw_base + reg);
-	*value = (u8)temp;
-	return 0;
-}
-
-static int __msm_sdw_reg_read(struct msm_sdw_priv *msm_sdw, unsigned short reg,
-			int bytes, void *dest)
-{
-	int ret = -EINVAL, i;
-	u8 temp = 0;
-
-	dev_dbg(msm_sdw->dev, "%s reg = %x\n", __func__, reg);
-	mutex_lock(&msm_sdw->cdc_int_mclk1_mutex);
-	if (msm_sdw->int_mclk1_enabled == false) {
-		msm_sdw->sdw_cdc_core_clk.enable = 1;
-		ret = afe_set_lpass_clock_v2(
-					AFE_PORT_ID_INT4_MI2S_RX,
-					&msm_sdw->sdw_cdc_core_clk);
-		if (ret < 0) {
-			dev_err(msm_sdw->dev,
-				"%s:failed to enable the INT_MCLK1\n",
-				__func__);
-			goto unlock_exit;
-		}
-		dev_dbg(msm_sdw->dev, "%s:enabled sdw codec core clk\n",
-			__func__);
-		for (i = 0; i < bytes; i++)  {
-			ret = msm_sdw_ahb_read_device(
-				msm_sdw, reg + (4 * i), &temp);
-			((u8 *)dest)[i] = temp;
-		}
-		msm_sdw->int_mclk1_enabled = true;
-		schedule_delayed_work(&msm_sdw->disable_int_mclk1_work, 50);
-		goto unlock_exit;
-	}
-	for (i = 0; i < bytes; i++)  {
-		ret = msm_sdw_ahb_read_device(
-			msm_sdw, reg + (4 * i), &temp);
-		((u8 *)dest)[i] = temp;
-	}
-unlock_exit:
-	mutex_unlock(&msm_sdw->cdc_int_mclk1_mutex);
-	if (ret < 0) {
-		dev_err_ratelimited(msm_sdw->dev,
-				    "%s: codec read failed for reg 0x%x\n",
-				    __func__, reg);
-		return ret;
-	}
-	dev_dbg(msm_sdw->dev, "Read 0x%02x from 0x%x\n", temp, reg);
-
-	return 0;
-}
-
-static int __msm_sdw_reg_write(struct msm_sdw_priv *msm_sdw, unsigned short reg,
-			       int bytes, void *src)
-{
-	int ret = -EINVAL, i;
-
-	mutex_lock(&msm_sdw->cdc_int_mclk1_mutex);
-	if (msm_sdw->int_mclk1_enabled == false) {
-		msm_sdw->sdw_cdc_core_clk.enable = 1;
-		ret = afe_set_lpass_clock_v2(AFE_PORT_ID_INT4_MI2S_RX,
-					     &msm_sdw->sdw_cdc_core_clk);
-		if (ret < 0) {
-			dev_err(msm_sdw->dev,
-				"%s: failed to enable the INT_MCLK1\n",
-				__func__);
-			ret = 0;
-			goto unlock_exit;
-		}
-		dev_dbg(msm_sdw->dev, "%s: enabled INT_MCLK1\n", __func__);
-		for (i = 0; i < bytes; i++)
-			ret = msm_sdw_ahb_write_device(msm_sdw, reg + (4 * i),
-						       &((u8 *)src)[i]);
-		msm_sdw->int_mclk1_enabled = true;
-		schedule_delayed_work(&msm_sdw->disable_int_mclk1_work, 50);
-		goto unlock_exit;
-	}
-	for (i = 0; i < bytes; i++)
-		ret = msm_sdw_ahb_write_device(msm_sdw, reg + (4 * i),
-					       &((u8 *)src)[i]);
-unlock_exit:
-	mutex_unlock(&msm_sdw->cdc_int_mclk1_mutex);
-	dev_dbg(msm_sdw->dev, "Write 0x%x val 0x%02x\n",
-				reg, (u32)(*(u32 *)src));
-
-	return ret;
-}
-
-static int msm_sdw_codec_enable_vi_feedback(struct snd_soc_dapm_widget *w,
-					    struct snd_kcontrol *kcontrol,
-					    int event)
-{
-	struct snd_soc_codec *codec = NULL;
-	struct msm_sdw_priv *msm_sdw_p = NULL;
-	int ret = 0;
-
-	if (!w) {
-		pr_err("%s invalid params\n", __func__);
-		return -EINVAL;
-	}
-	codec = snd_soc_dapm_to_codec(w->dapm);
-	msm_sdw_p = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
-		__func__, codec->component.num_dai, w->sname);
-
-	dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
-		__func__, w->name, event, w->shift);
-	if (w->shift != AIF1_SDW_VIFEED) {
-		dev_err(codec->dev,
-			"%s:Error in enabling the vi feedback path\n",
-			__func__);
-		ret = -EINVAL;
-		goto out_vi;
-	}
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		if (test_bit(VI_SENSE_1, &msm_sdw_p->status_mask)) {
-			dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x04);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x0F, 0x04);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &msm_sdw_p->status_mask)) {
-			dev_dbg(codec->dev, "%s: spkr2 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x0F,
-				0x04);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x0F,
-				0x04);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (test_bit(VI_SENSE_1, &msm_sdw_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &msm_sdw_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-			snd_soc_update_bits(codec,
-				MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		break;
-	}
-out_vi:
-	return ret;
-}
-
-static int msm_sdwm_handle_irq(void *handle,
-			       irqreturn_t (*swrm_irq_handler)(int irq,
-							       void *data),
-			       void *swrm_handle,
-			       int action)
-{
-	struct msm_sdw_priv *msm_sdw;
-	int ret = 0;
-
-	if (!handle) {
-		pr_err("%s: null handle received\n", __func__);
-		return -EINVAL;
-	}
-	msm_sdw = (struct msm_sdw_priv *) handle;
-
-	if (skip_irq)
-		return ret;
-
-	if (action) {
-		ret = request_threaded_irq(msm_sdw->sdw_irq, NULL,
-					   swrm_irq_handler,
-					   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-					   "swr_master_irq", swrm_handle);
-		if (ret)
-			dev_err(msm_sdw->dev, "%s: Failed to request irq %d\n",
-				__func__, ret);
-	} else
-		free_irq(msm_sdw->sdw_irq, swrm_handle);
-
-	return ret;
-}
-
-static void msm_sdw_codec_hd2_control(struct snd_soc_codec *codec,
-				      u16 reg, int event)
-{
-	u16 hd2_scale_reg;
-	u16 hd2_enable_reg = 0;
-
-	if (reg == MSM_SDW_RX7_RX_PATH_CTL) {
-		hd2_scale_reg = MSM_SDW_RX7_RX_PATH_SEC3;
-		hd2_enable_reg = MSM_SDW_RX7_RX_PATH_CFG0;
-	}
-	if (reg == MSM_SDW_RX8_RX_PATH_CTL) {
-		hd2_scale_reg = MSM_SDW_RX8_RX_PATH_SEC3;
-		hd2_enable_reg = MSM_SDW_RX8_RX_PATH_CFG0;
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
-	}
-}
-
-static int msm_sdw_enable_swr(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_sdw_priv *msm_sdw;
-	int i, ch_cnt;
-
-	msm_sdw = snd_soc_codec_get_drvdata(codec);
-
-	if (!msm_sdw->nr)
-		return 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (!(strnstr(w->name, "RX4", sizeof("RX4 MIX"))) &&
-		    !msm_sdw->rx_4_count)
-			msm_sdw->rx_4_count++;
-		if (!(strnstr(w->name, "RX5", sizeof("RX5 MIX"))) &&
-		    !msm_sdw->rx_5_count)
-			msm_sdw->rx_5_count++;
-		ch_cnt = msm_sdw->rx_4_count + msm_sdw->rx_5_count;
-
-		for (i = 0; i < msm_sdw->nr; i++) {
-			swrm_wcd_notify(msm_sdw->sdw_ctrl_data[i].sdw_pdev,
-					SWR_DEVICE_UP, NULL);
-			swrm_wcd_notify(msm_sdw->sdw_ctrl_data[i].sdw_pdev,
-					SWR_SET_NUM_RX_CH, &ch_cnt);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (!(strnstr(w->name, "RX4", sizeof("RX4 MIX"))) &&
-		    msm_sdw->rx_4_count)
-			msm_sdw->rx_4_count--;
-		if (!(strnstr(w->name, "RX5", sizeof("RX5 MIX"))) &&
-		    msm_sdw->rx_5_count)
-			msm_sdw->rx_5_count--;
-		ch_cnt = msm_sdw->rx_4_count + msm_sdw->rx_5_count;
-
-		for (i = 0; i < msm_sdw->nr; i++)
-			swrm_wcd_notify(msm_sdw->sdw_ctrl_data[i].sdw_pdev,
-					SWR_SET_NUM_RX_CH, &ch_cnt);
-		break;
-	}
-	dev_dbg(msm_sdw->dev, "%s: current swr ch cnt: %d\n",
-		__func__, msm_sdw->rx_4_count + msm_sdw->rx_5_count);
-
-	return 0;
-}
-
-static int msm_sdw_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
-					     struct snd_kcontrol *kcontrol,
-					     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-	u16 gain_reg;
-	u16 reg;
-	int val;
-	int offset_val = 0;
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-
-	if (!(strcmp(w->name, "RX INT4 INTERP"))) {
-		reg = MSM_SDW_RX7_RX_PATH_CTL;
-		gain_reg = MSM_SDW_RX7_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
-		reg = MSM_SDW_RX8_RX_PATH_CTL;
-		gain_reg = MSM_SDW_RX8_RX_VOL_CTL;
-	} else {
-		dev_err(codec->dev, "%s: Interpolator reg not found\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, reg, 0x10, 0x10);
-		msm_sdw_codec_hd2_control(codec, reg, event);
-		snd_soc_update_bits(codec, reg, 1 << 0x5, 1 << 0x5);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		msm_sdw_config_compander(codec, w->shift, event);
-		/* apply gain after int clk is enabled */
-		if ((msm_sdw->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (msm_sdw->comp_enabled[COMP1] ||
-		     msm_sdw->comp_enabled[COMP2]) &&
-		    (gain_reg == MSM_SDW_RX7_RX_VOL_CTL ||
-		     gain_reg == MSM_SDW_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, MSM_SDW_RX7_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    MSM_SDW_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, MSM_SDW_RX8_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    MSM_SDW_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			offset_val = -2;
-		}
-		val = snd_soc_read(codec, gain_reg);
-		val += offset_val;
-		snd_soc_write(codec, gain_reg, val);
-		msm_sdw_config_ear_spkr_gain(codec, event, gain_reg);
-		snd_soc_update_bits(codec, reg, 0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, reg, 1 << 0x5, 0 << 0x5);
-		snd_soc_update_bits(codec, reg,	0x40, 0x40);
-		snd_soc_update_bits(codec, reg,	0x40, 0x00);
-		msm_sdw_codec_hd2_control(codec, reg, event);
-		msm_sdw_config_compander(codec, w->shift, event);
-		if ((msm_sdw->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (msm_sdw->comp_enabled[COMP1] ||
-		     msm_sdw->comp_enabled[COMP2]) &&
-		    (gain_reg == MSM_SDW_RX7_RX_VOL_CTL ||
-		     gain_reg == MSM_SDW_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, MSM_SDW_RX7_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    MSM_SDW_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, MSM_SDW_RX8_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    MSM_SDW_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			offset_val = 2;
-			val = snd_soc_read(codec, gain_reg);
-			val += offset_val;
-			snd_soc_write(codec, gain_reg, val);
-		}
-		msm_sdw_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	};
-
-	return 0;
-}
-
-static int msm_sdw_config_ear_spkr_gain(struct snd_soc_codec *codec,
-					int event, int gain_reg)
-{
-	int comp_gain_offset, val;
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-
-	switch (msm_sdw->spkr_mode) {
-	/* Compander gain in SPKR_MODE1 case is 12 dB */
-	case SPKR_MODE_1:
-		comp_gain_offset = -12;
-		break;
-	/* Default case compander gain is 15 dB */
-	default:
-		comp_gain_offset = -15;
-		break;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/* Apply ear spkr gain only if compander is enabled */
-		if (msm_sdw->comp_enabled[COMP1] &&
-		    (gain_reg == MSM_SDW_RX7_RX_VOL_CTL) &&
-		    (msm_sdw->ear_spkr_gain != 0)) {
-			/* For example, val is -8(-12+5-1) for 4dB of gain */
-			val = comp_gain_offset + msm_sdw->ear_spkr_gain - 1;
-			snd_soc_write(codec, gain_reg, val);
-
-			dev_dbg(codec->dev, "%s: RX4 Volume %d dB\n",
-				__func__, val);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * Reset RX4 volume to 0 dB if compander is enabled and
-		 * ear_spkr_gain is non-zero.
-		 */
-		if (msm_sdw->comp_enabled[COMP1] &&
-		    (gain_reg == MSM_SDW_RX7_RX_VOL_CTL) &&
-		    (msm_sdw->ear_spkr_gain != 0)) {
-			snd_soc_write(codec, gain_reg, 0x0);
-
-			dev_dbg(codec->dev, "%s: Reset RX4 Volume to 0 dB\n",
-				__func__);
-		}
-		break;
-	}
-
-	return 0;
-}
-
-static int msm_sdw_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 boost_path_ctl, boost_path_cfg1;
-	u16 reg;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	if (!strcmp(w->name, "RX INT4 CHAIN")) {
-		boost_path_ctl = MSM_SDW_BOOST0_BOOST_PATH_CTL;
-		boost_path_cfg1 = MSM_SDW_RX7_RX_PATH_CFG1;
-		reg = MSM_SDW_RX7_RX_PATH_CTL;
-	} else if (!strcmp(w->name, "RX INT5 CHAIN")) {
-		boost_path_ctl = MSM_SDW_BOOST1_BOOST_PATH_CTL;
-		boost_path_cfg1 = MSM_SDW_RX8_RX_PATH_CFG1;
-		reg = MSM_SDW_RX8_RX_PATH_CTL;
-	} else {
-		dev_err(codec->dev, "%s: boost reg not found\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
-		snd_soc_update_bits(codec, reg, 0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
-		break;
-	};
-
-	return 0;
-}
-
-static int msm_sdw_config_compander(struct snd_soc_codec *codec, int comp,
-				    int event)
-{
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-	u16 comp_ctl0_reg, rx_path_cfg0_reg;
-
-	if (comp < COMP1 || comp >= COMP_MAX)
-		return 0;
-
-	dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
-		__func__, event, comp + 1, msm_sdw->comp_enabled[comp]);
-
-	if (!msm_sdw->comp_enabled[comp])
-		return 0;
-
-	comp_ctl0_reg = MSM_SDW_COMPANDER7_CTL0 + (comp * 0x20);
-	rx_path_cfg0_reg = MSM_SDW_RX7_RX_PATH_CFG0 + (comp * 0x1E0);
-
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		/* Enable Compander Clock */
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
-	}
-
-	return 0;
-}
-
-static int msm_sdw_get_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = msm_sdw->comp_enabled[comp];
-	return 0;
-}
-
-static int msm_sdw_set_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n",
-		__func__, comp + 1, msm_sdw->comp_enabled[comp], value);
-	msm_sdw->comp_enabled[comp] = value;
-
-	return 0;
-}
-
-static int msm_sdw_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = msm_sdw->ear_spkr_gain;
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_sdw_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_sdw_priv *msm_sdw = snd_soc_codec_get_drvdata(codec);
-
-	msm_sdw->ear_spkr_gain =  ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: gain = %d\n", __func__,
-		msm_sdw->ear_spkr_gain);
-
-	return 0;
-}
-
-static int msm_sdw_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct msm_sdw_priv *msm_sdw_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = msm_sdw_p->vi_feed_value;
-
-	return 0;
-}
-
-static int msm_sdw_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct msm_sdw_priv *msm_sdw_p = snd_soc_codec_get_drvdata(codec);
-	struct soc_multi_mixer_control *mixer =
-		((struct soc_multi_mixer_control *)kcontrol->private_value);
-	u32 dai_id = widget->shift;
-	u32 port_id = mixer->shift;
-	u32 enable = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
-		__func__, enable, port_id, dai_id);
-
-	msm_sdw_p->vi_feed_value = ucontrol->value.integer.value[0];
-
-	mutex_lock(&msm_sdw_p->codec_mutex);
-	if (enable) {
-		if (port_id == MSM_SDW_TX0 && !test_bit(VI_SENSE_1,
-						&msm_sdw_p->status_mask))
-			set_bit(VI_SENSE_1, &msm_sdw_p->status_mask);
-		if (port_id == MSM_SDW_TX1 && !test_bit(VI_SENSE_2,
-						&msm_sdw_p->status_mask))
-			set_bit(VI_SENSE_2, &msm_sdw_p->status_mask);
-	} else {
-		if (port_id == MSM_SDW_TX0 && test_bit(VI_SENSE_1,
-					&msm_sdw_p->status_mask))
-			clear_bit(VI_SENSE_1, &msm_sdw_p->status_mask);
-		if (port_id == MSM_SDW_TX1 && test_bit(VI_SENSE_2,
-					&msm_sdw_p->status_mask))
-			clear_bit(VI_SENSE_2, &msm_sdw_p->status_mask);
-	}
-	mutex_unlock(&msm_sdw_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
-
-	return 0;
-}
-
-static int msm_sdw_mclk_enable(struct msm_sdw_priv *msm_sdw,
-			       int mclk_enable, bool dapm)
-{
-	dev_dbg(msm_sdw->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
-		__func__, mclk_enable, dapm, msm_sdw->sdw_mclk_users);
-	if (mclk_enable) {
-		msm_sdw->sdw_mclk_users++;
-		if (msm_sdw->sdw_mclk_users == 1) {
-			regmap_update_bits(msm_sdw->regmap,
-					MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x01, 0x01);
-			regmap_update_bits(msm_sdw->regmap,
-				MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL,
-				0x01, 0x01);
-			/* 9.6MHz MCLK, set value 0x00 if other frequency */
-			regmap_update_bits(msm_sdw->regmap,
-				MSM_SDW_TOP_FREQ_MCLK, 0x01, 0x01);
-		}
-	} else {
-		msm_sdw->sdw_mclk_users--;
-		if (msm_sdw->sdw_mclk_users == 0) {
-			regmap_update_bits(msm_sdw->regmap,
-					MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x01, 0x00);
-			regmap_update_bits(msm_sdw->regmap,
-					MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL,
-					0x01, 0x00);
-		}
-	}
-	return 0;
-}
-EXPORT_SYMBOL(msm_sdw_mclk_enable);
-
-static int msm_sdw_swrm_read(void *handle, int reg)
-{
-	struct msm_sdw_priv *msm_sdw;
-	unsigned short sdw_rd_addr_base;
-	unsigned short sdw_rd_data_base;
-	int val, ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	msm_sdw = (struct msm_sdw_priv *)handle;
-
-	dev_dbg(msm_sdw->dev, "%s: Reading soundwire register, 0x%x\n",
-		__func__, reg);
-	sdw_rd_addr_base = MSM_SDW_AHB_BRIDGE_RD_ADDR_0;
-	sdw_rd_data_base = MSM_SDW_AHB_BRIDGE_RD_DATA_0;
-	/*
-	 * Add sleep as SWR slave access read takes time.
-	 * Allow for RD_DONE to complete for previous register if any.
-	 */
-	usleep_range(100, 105);
-
-	/* read_lock */
-	mutex_lock(&msm_sdw->sdw_read_lock);
-	ret = regmap_bulk_write(msm_sdw->regmap, sdw_rd_addr_base,
-				(u8 *)&reg, 4);
-	if (ret < 0) {
-		dev_err(msm_sdw->dev, "%s: RD Addr Failure\n", __func__);
-		goto err;
-	}
-	/* Add sleep for SWR register read value to get updated. */
-	usleep_range(100, 105);
-	/* Check for RD value */
-	ret = regmap_bulk_read(msm_sdw->regmap, sdw_rd_data_base,
-			       (u8 *)&val, 4);
-	if (ret < 0) {
-		dev_err(msm_sdw->dev, "%s: RD Data Failure\n", __func__);
-		goto err;
-	}
-	ret = val;
-err:
-	/* read_unlock */
-	mutex_unlock(&msm_sdw->sdw_read_lock);
-	return ret;
-}
-
-static int msm_sdw_bulk_write(struct msm_sdw_priv *msm_sdw,
-				struct msm_sdw_reg_val *bulk_reg,
-				size_t len)
-{
-	int i, ret = 0;
-	unsigned short sdw_wr_addr_base;
-	unsigned short sdw_wr_data_base;
-
-	sdw_wr_addr_base = MSM_SDW_AHB_BRIDGE_WR_ADDR_0;
-	sdw_wr_data_base = MSM_SDW_AHB_BRIDGE_WR_DATA_0;
-
-	for (i = 0; i < len; i += 2) {
-		/*
-		 * Add sleep as SWR slave write takes time.
-		 * Allow for any previous pending write to complete.
-		 */
-		usleep_range(100, 105);
-		/* First Write the Data to register */
-		ret = regmap_bulk_write(msm_sdw->regmap,
-			sdw_wr_data_base, bulk_reg[i].buf, 4);
-		if (ret < 0) {
-			dev_err(msm_sdw->dev, "%s: WR Data Failure\n",
-				__func__);
-			break;
-		}
-		/* Next Write Address */
-		ret = regmap_bulk_write(msm_sdw->regmap,
-			sdw_wr_addr_base, bulk_reg[i+1].buf, 4);
-		if (ret < 0) {
-			dev_err(msm_sdw->dev,
-				"%s: WR Addr Failure: 0x%x\n",
-				__func__, (u32)(bulk_reg[i+1].buf[0]));
-			break;
-		}
-	}
-	return ret;
-}
-
-static int msm_sdw_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
-{
-	struct msm_sdw_priv *msm_sdw;
-	struct msm_sdw_reg_val *bulk_reg;
-	unsigned short sdw_wr_addr_base;
-	unsigned short sdw_wr_data_base;
-	int i, j, ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-
-	msm_sdw = (struct msm_sdw_priv *)handle;
-	if (len <= 0) {
-		dev_err(msm_sdw->dev,
-			"%s: Invalid size: %zu\n", __func__, len);
-		return -EINVAL;
-	}
-
-	sdw_wr_addr_base = MSM_SDW_AHB_BRIDGE_WR_ADDR_0;
-	sdw_wr_data_base = MSM_SDW_AHB_BRIDGE_WR_DATA_0;
-
-	bulk_reg = kzalloc((2 * len * sizeof(struct msm_sdw_reg_val)),
-			   GFP_KERNEL);
-	if (!bulk_reg)
-		return -ENOMEM;
-
-	for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
-		bulk_reg[i].reg = sdw_wr_data_base;
-		bulk_reg[i].buf = (u8 *)(&val[j]);
-		bulk_reg[i].bytes = 4;
-		bulk_reg[i+1].reg = sdw_wr_addr_base;
-		bulk_reg[i+1].buf = (u8 *)(&reg[j]);
-		bulk_reg[i+1].bytes = 4;
-	}
-	mutex_lock(&msm_sdw->sdw_write_lock);
-
-	ret = msm_sdw_bulk_write(msm_sdw, bulk_reg, (len * 2));
-	if (ret)
-		dev_err(msm_sdw->dev, "%s: swrm bulk write failed, ret: %d\n",
-			__func__, ret);
-
-	mutex_unlock(&msm_sdw->sdw_write_lock);
-	kfree(bulk_reg);
-
-	return ret;
-}
-
-static int msm_sdw_swrm_write(void *handle, int reg, int val)
-{
-	struct msm_sdw_priv *msm_sdw;
-	unsigned short sdw_wr_addr_base;
-	unsigned short sdw_wr_data_base;
-	struct msm_sdw_reg_val bulk_reg[2];
-	int ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	msm_sdw = (struct msm_sdw_priv *)handle;
-
-	sdw_wr_addr_base = MSM_SDW_AHB_BRIDGE_WR_ADDR_0;
-	sdw_wr_data_base = MSM_SDW_AHB_BRIDGE_WR_DATA_0;
-
-	/* First Write the Data to register */
-	bulk_reg[0].reg = sdw_wr_data_base;
-	bulk_reg[0].buf = (u8 *)(&val);
-	bulk_reg[0].bytes = 4;
-	bulk_reg[1].reg = sdw_wr_addr_base;
-	bulk_reg[1].buf = (u8 *)(&reg);
-	bulk_reg[1].bytes = 4;
-
-	mutex_lock(&msm_sdw->sdw_write_lock);
-
-	ret = msm_sdw_bulk_write(msm_sdw, bulk_reg, 2);
-	if (ret < 0)
-		dev_err(msm_sdw->dev, "%s: WR Data Failure\n", __func__);
-
-	mutex_unlock(&msm_sdw->sdw_write_lock);
-	return ret;
-}
-
-static int msm_sdw_swrm_clock(void *handle, bool enable)
-{
-	struct msm_sdw_priv *msm_sdw = (struct msm_sdw_priv *) handle;
-
-	mutex_lock(&msm_sdw->sdw_clk_lock);
-
-	dev_dbg(msm_sdw->dev, "%s: swrm clock %s\n",
-		__func__, (enable ? "enable" : "disable"));
-	if (enable) {
-		msm_sdw->sdw_clk_users++;
-		if (msm_sdw->sdw_clk_users == 1) {
-			msm_int_enable_sdw_cdc_clk(msm_sdw, 1, true);
-			msm_sdw_mclk_enable(msm_sdw, 1, true);
-			regmap_update_bits(msm_sdw->regmap,
-				MSM_SDW_CLK_RST_CTRL_SWR_CONTROL, 0x01, 0x01);
-			msm_enable_sdw_npl_clk(msm_sdw, true);
-			msm_cdc_pinctrl_select_active_state(
-							msm_sdw->sdw_gpio_p);
-		}
-	} else {
-		msm_sdw->sdw_clk_users--;
-		if (msm_sdw->sdw_clk_users == 0) {
-			regmap_update_bits(msm_sdw->regmap,
-				MSM_SDW_CLK_RST_CTRL_SWR_CONTROL,
-				0x01, 0x00);
-			msm_sdw_mclk_enable(msm_sdw, 0, true);
-			msm_int_enable_sdw_cdc_clk(msm_sdw, 0, true);
-			msm_enable_sdw_npl_clk(msm_sdw, false);
-			msm_cdc_pinctrl_select_sleep_state(msm_sdw->sdw_gpio_p);
-		}
-	}
-	dev_dbg(msm_sdw->dev, "%s: swrm clock users %d\n",
-		__func__, msm_sdw->sdw_clk_users);
-	mutex_unlock(&msm_sdw->sdw_clk_lock);
-	return 0;
-}
-
-static int msm_sdw_startup(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	dev_dbg(dai->codec->dev, "%s(): substream = %s  stream = %d\n",
-		__func__,
-		substream->name, substream->stream);
-	return 0;
-}
-
-static int msm_sdw_hw_params(struct snd_pcm_substream *substream,
-			    struct snd_pcm_hw_params *params,
-			    struct snd_soc_dai *dai)
-{
-	u8 clk_fs_rate, fs_rate;
-
-	dev_dbg(dai->codec->dev,
-		"%s: dai_name = %s DAI-ID %x rate %d num_ch %d format %d\n",
-		__func__, dai->name, dai->id, params_rate(params),
-		params_channels(params), params_format(params));
-
-	switch (params_rate(params)) {
-	case 8000:
-		clk_fs_rate = 0x00;
-		fs_rate = 0x00;
-		break;
-	case 16000:
-		clk_fs_rate = 0x01;
-		fs_rate = 0x01;
-		break;
-	case 32000:
-		clk_fs_rate = 0x02;
-		fs_rate = 0x03;
-		break;
-	case 48000:
-		clk_fs_rate = 0x03;
-		fs_rate = 0x04;
-		break;
-	case 96000:
-		clk_fs_rate = 0x04;
-		fs_rate = 0x05;
-		break;
-	case 192000:
-		clk_fs_rate = 0x05;
-		fs_rate = 0x06;
-		break;
-	default:
-		dev_err(dai->codec->dev,
-			"%s: Invalid sampling rate %d\n", __func__,
-			params_rate(params));
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		snd_soc_update_bits(dai->codec,
-				MSM_SDW_TOP_TX_I2S_CTL, 0x1C,
-				(clk_fs_rate << 2));
-	} else {
-		snd_soc_update_bits(dai->codec,
-				MSM_SDW_TOP_RX_I2S_CTL, 0x1C,
-				(clk_fs_rate << 2));
-		snd_soc_update_bits(dai->codec,
-				MSM_SDW_RX7_RX_PATH_CTL, 0x0F,
-				fs_rate);
-		snd_soc_update_bits(dai->codec,
-				MSM_SDW_RX8_RX_PATH_CTL, 0x0F,
-				fs_rate);
-	}
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			snd_soc_update_bits(dai->codec,
-					MSM_SDW_TOP_TX_I2S_CTL, 0x20, 0x20);
-		else
-			snd_soc_update_bits(dai->codec,
-					MSM_SDW_TOP_RX_I2S_CTL, 0x20, 0x20);
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			snd_soc_update_bits(dai->codec,
-					MSM_SDW_TOP_TX_I2S_CTL, 0x20, 0x00);
-		else
-			snd_soc_update_bits(dai->codec,
-					MSM_SDW_TOP_RX_I2S_CTL, 0x20, 0x00);
-		break;
-	default:
-		dev_err(dai->codec->dev, "%s: wrong format selected\n",
-				__func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static void msm_sdw_shutdown(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	dev_dbg(dai->codec->dev,
-		"%s(): substream = %s  stream = %d\n", __func__,
-		substream->name, substream->stream);
-}
-
-static ssize_t msm_sdw_codec_version_read(struct snd_info_entry *entry,
-					  void *file_private_data,
-					  struct file *file,
-					  char __user *buf, size_t count,
-					  loff_t pos)
-{
-	struct msm_sdw_priv *msm_sdw;
-	char buffer[MSM_SDW_VERSION_ENTRY_SIZE];
-	int len = 0;
-
-	msm_sdw = (struct msm_sdw_priv *) entry->private_data;
-	if (!msm_sdw) {
-		pr_err("%s: msm_sdw priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (msm_sdw->version) {
-	case MSM_SDW_VERSION_1_0:
-		len = snprintf(buffer, sizeof(buffer), "SDW-CDC_1_0\n");
-		break;
-	default:
-		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-	}
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops msm_sdw_codec_info_ops = {
-	.read = msm_sdw_codec_version_read,
-};
-
-/*
- * msm_sdw_codec_info_create_codec_entry - creates msm_sdw module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates msm_sdw module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int msm_sdw_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					  struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct msm_sdw_priv *msm_sdw;
-	struct snd_soc_card *card;
-	char name[80];
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	msm_sdw = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-
-	snprintf(name, sizeof(name), "%x.%s", (u32)msm_sdw->sdw_base_addr,
-			"msm-sdw-codec");
-	msm_sdw->entry = snd_info_create_subdir(codec_root->module,
-						(const char *)name,
-						codec_root);
-	if (!msm_sdw->entry) {
-		dev_err(codec->dev, "%s: failed to create msm_sdw entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   msm_sdw->entry);
-	if (!version_entry) {
-		dev_err(codec->dev, "%s: failed to create msm_sdw version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = msm_sdw;
-	version_entry->size = MSM_SDW_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &msm_sdw_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	msm_sdw->version_entry = version_entry;
-
-	return 0;
-}
-EXPORT_SYMBOL(msm_sdw_codec_info_create_codec_entry);
-
-static struct snd_soc_dai_ops msm_sdw_dai_ops = {
-	.startup = msm_sdw_startup,
-	.shutdown = msm_sdw_shutdown,
-	.hw_params = msm_sdw_hw_params,
-};
-
-static struct snd_soc_dai_driver msm_sdw_dai[] = {
-	{
-		.name = "msm_sdw_i2s_rx1",
-		.id = AIF1_SDW_PB,
-		.playback = {
-			.stream_name = "AIF1_SDW Playback",
-			.rates = MSM_SDW_RATES,
-			.formats = MSM_SDW_FORMATS,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &msm_sdw_dai_ops,
-	},
-	{
-		.name = "msm_sdw_vifeedback",
-		.id = AIF1_SDW_VIFEED,
-		.capture = {
-			.stream_name = "VIfeed_SDW",
-			.rates = MSM_SDW_RATES,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_max = 48000,
-			.rate_min = 8000,
-			.channels_min = 2,
-			.channels_max = 4,
-		},
-		.ops = &msm_sdw_dai_ops,
-	},
-};
-
-static const char * const rx_mix1_text[] = {
-	"ZERO", "RX4", "RX5"
-};
-
-static const char * const msm_sdw_ear_spkr_pa_gain_text[] = {
-	"G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB",
-	"G_4_DB", "G_5_DB", "G_6_DB"
-};
-
-static SOC_ENUM_SINGLE_EXT_DECL(msm_sdw_ear_spkr_pa_gain_enum,
-				msm_sdw_ear_spkr_pa_gain_text);
-/* RX4 MIX1 */
-static const struct soc_enum rx4_mix1_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM_SDW_TOP_RX7_PATH_INPUT0_MUX,
-		0, 3, rx_mix1_text);
-
-static const struct soc_enum rx4_mix1_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM_SDW_TOP_RX7_PATH_INPUT1_MUX,
-		0, 3, rx_mix1_text);
-
-/* RX5 MIX1 */
-static const struct soc_enum rx5_mix1_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM_SDW_TOP_RX8_PATH_INPUT0_MUX,
-		0, 3, rx_mix1_text);
-
-static const struct soc_enum rx5_mix1_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM_SDW_TOP_RX8_PATH_INPUT1_MUX,
-		0, 3, rx_mix1_text);
-
-static const struct snd_kcontrol_new rx4_mix1_inp1_mux =
-	SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", rx4_mix1_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx4_mix1_inp2_mux =
-	SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx5_mix1_inp1_mux =
-	SOC_DAPM_ENUM("RX5 MIX1 INP1 Mux", rx5_mix1_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx5_mix1_inp2_mux =
-	SOC_DAPM_ENUM("RX5 MIX1 INP2 Mux", rx5_mix1_inp2_chain_enum);
-
-static const struct snd_kcontrol_new aif1_vi_mixer[] = {
-	SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, MSM_SDW_TX0, 1, 0,
-			msm_sdw_vi_feed_mixer_get, msm_sdw_vi_feed_mixer_put),
-	SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, MSM_SDW_TX1, 1, 0,
-			msm_sdw_vi_feed_mixer_get, msm_sdw_vi_feed_mixer_put),
-};
-
-static const struct snd_soc_dapm_widget msm_sdw_dapm_widgets[] = {
-	SND_SOC_DAPM_AIF_IN("I2S RX4", "AIF1_SDW Playback", 0,
-		SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_AIF_IN("I2S RX5", "AIF1_SDW Playback", 0,
-		SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF1_SDW VI", "VIfeed_SDW", 0, SND_SOC_NOPM,
-		AIF1_SDW_VIFEED, 0, msm_sdw_codec_enable_vi_feedback,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER("AIF1_VI_SDW Mixer", SND_SOC_NOPM, AIF1_SDW_VIFEED,
-		0, aif1_vi_mixer, ARRAY_SIZE(aif1_vi_mixer)),
-
-	SND_SOC_DAPM_MUX_E("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx4_mix1_inp1_mux, msm_sdw_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx4_mix1_inp2_mux, msm_sdw_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX5 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx5_mix1_inp1_mux, msm_sdw_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX5 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx5_mix1_inp2_mux, msm_sdw_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER("RX4 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX5 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MIXER_E("RX INT4 INTERP", SND_SOC_NOPM,
-		COMP1, 0, NULL, 0, msm_sdw_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT5 INTERP", SND_SOC_NOPM,
-		COMP2, 0, NULL, 0, msm_sdw_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MIXER_E("RX INT4 CHAIN", SND_SOC_NOPM, 0, 0,
-		NULL, 0, msm_sdw_codec_spk_boost_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT5 CHAIN", SND_SOC_NOPM, 0, 0,
-		NULL, 0, msm_sdw_codec_spk_boost_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_INPUT("VIINPUT_SDW"),
-
-	SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
-	SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
-
-	SND_SOC_DAPM_SUPPLY_S("SDW_CONN", -1, MSM_SDW_TOP_I2S_CLK,
-		0, 0, NULL, 0),
-
-	SND_SOC_DAPM_SUPPLY_S("INT_MCLK1", -2, SND_SOC_NOPM, 0, 0,
-	msm_int_mclk1_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("SDW_RX_I2S_CLK",
-		MSM_SDW_TOP_RX_I2S_CTL, 0, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("SDW_TX_I2S_CLK",
-		MSM_SDW_TOP_TX_I2S_CTL, 0, 0, NULL, 0),
-};
-
-static const struct snd_kcontrol_new msm_sdw_snd_controls[] = {
-	SOC_ENUM_EXT("EAR SPKR PA Gain", msm_sdw_ear_spkr_pa_gain_enum,
-		     msm_sdw_ear_spkr_pa_gain_get,
-		     msm_sdw_ear_spkr_pa_gain_put),
-	SOC_SINGLE_SX_TLV("RX4 Digital Volume", MSM_SDW_RX7_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX5 Digital Volume", MSM_SDW_RX8_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMP1, 1, 0,
-		msm_sdw_get_compander, msm_sdw_set_compander),
-	SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMP2, 1, 0,
-		msm_sdw_get_compander, msm_sdw_set_compander),
-};
-
-static const struct snd_soc_dapm_route audio_map[] = {
-
-	{"AIF1_SDW VI", NULL, "SDW_TX_I2S_CLK"},
-	{"SDW_TX_I2S_CLK", NULL, "INT_MCLK1"},
-	{"SDW_TX_I2S_CLK", NULL, "SDW_CONN"},
-
-	/* VI Feedback */
-	{"AIF1_VI_SDW Mixer", "SPKR_VI_1", "VIINPUT_SDW"},
-	{"AIF1_VI_SDW Mixer", "SPKR_VI_2", "VIINPUT_SDW"},
-	{"AIF1_SDW VI", NULL, "AIF1_VI_SDW Mixer"},
-
-	{"SDW_RX_I2S_CLK", NULL, "INT_MCLK1"},
-	{"SDW_RX_I2S_CLK", NULL, "SDW_CONN"},
-	{"I2S RX4", NULL, "SDW_RX_I2S_CLK"},
-	{"I2S RX5", NULL, "SDW_RX_I2S_CLK"},
-
-	{"RX4 MIX1 INP1", "RX4", "I2S RX4"},
-	{"RX4 MIX1 INP1", "RX5", "I2S RX5"},
-	{"RX4 MIX1 INP2", "RX4", "I2S RX4"},
-	{"RX4 MIX1 INP2", "RX5", "I2S RX5"},
-	{"RX5 MIX1 INP1", "RX4", "I2S RX4"},
-	{"RX5 MIX1 INP1", "RX5", "I2S RX5"},
-	{"RX5 MIX1 INP2", "RX4", "I2S RX4"},
-	{"RX5 MIX1 INP2", "RX5", "I2S RX5"},
-
-	{"RX4 MIX1", NULL, "RX4 MIX1 INP1"},
-	{"RX4 MIX1", NULL, "RX4 MIX1 INP2"},
-	{"RX5 MIX1", NULL, "RX5 MIX1 INP1"},
-	{"RX5 MIX1", NULL, "RX5 MIX1 INP2"},
-
-	{"RX INT4 INTERP", NULL, "RX4 MIX1"},
-	{"RX INT4 CHAIN", NULL, "RX INT4 INTERP"},
-	{"SPK1 OUT", NULL, "RX INT4 CHAIN"},
-
-	{"RX INT5 INTERP", NULL, "RX5 MIX1"},
-	{"RX INT5 CHAIN", NULL, "RX INT5 INTERP"},
-	{"SPK2 OUT", NULL, "RX INT5 CHAIN"},
-};
-
-static const struct msm_sdw_reg_mask_val msm_sdw_reg_init[] = {
-	{MSM_SDW_BOOST0_BOOST_CFG1, 0x3F, 0x12},
-	{MSM_SDW_BOOST0_BOOST_CFG2, 0x1C, 0x08},
-	{MSM_SDW_COMPANDER7_CTL7, 0x1E, 0x18},
-	{MSM_SDW_BOOST1_BOOST_CFG1, 0x3F, 0x12},
-	{MSM_SDW_BOOST1_BOOST_CFG2, 0x1C, 0x08},
-	{MSM_SDW_COMPANDER8_CTL7, 0x1E, 0x18},
-	{MSM_SDW_BOOST0_BOOST_CTL, 0x70, 0x50},
-	{MSM_SDW_BOOST1_BOOST_CTL, 0x70, 0x50},
-	{MSM_SDW_RX7_RX_PATH_CFG1, 0x08, 0x08},
-	{MSM_SDW_RX8_RX_PATH_CFG1, 0x08, 0x08},
-	{MSM_SDW_TOP_TOP_CFG1, 0x02, 0x02},
-	{MSM_SDW_TOP_TOP_CFG1, 0x01, 0x01},
-	{MSM_SDW_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_COMPANDER7_CTL3, 0x80, 0x80},
-	{MSM_SDW_COMPANDER8_CTL3, 0x80, 0x80},
-	{MSM_SDW_COMPANDER7_CTL7, 0x01, 0x01},
-	{MSM_SDW_COMPANDER8_CTL7, 0x01, 0x01},
-	{MSM_SDW_RX7_RX_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_RX8_RX_PATH_CFG0, 0x01, 0x01},
-	{MSM_SDW_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{MSM_SDW_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
-};
-
-static void msm_sdw_init_reg(struct snd_soc_codec *codec)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(msm_sdw_reg_init); i++)
-		snd_soc_update_bits(codec,
-				msm_sdw_reg_init[i].reg,
-				msm_sdw_reg_init[i].mask,
-				msm_sdw_reg_init[i].val);
-}
-
-static int msm_sdw_notifier_service_cb(struct notifier_block *nb,
-				       unsigned long opcode, void *ptr)
-{
-	int i;
-	struct msm_sdw_priv *msm_sdw = container_of(nb,
-						    struct msm_sdw_priv,
-						    service_nb);
-	bool adsp_ready = false;
-	unsigned long timeout;
-	static bool initial_boot = true;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	mutex_lock(&msm_sdw->codec_mutex);
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		if (initial_boot) {
-			initial_boot = false;
-			break;
-		}
-		msm_sdw->int_mclk1_enabled = false;
-		msm_sdw->dev_up = false;
-		for (i = 0; i < msm_sdw->nr; i++)
-			swrm_wcd_notify(msm_sdw->sdw_ctrl_data[i].sdw_pdev,
-					SWR_DEVICE_DOWN, NULL);
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (initial_boot)
-			initial_boot = false;
-		if (!q6core_is_adsp_ready()) {
-			dev_dbg(msm_sdw->dev, "ADSP isn't ready\n");
-			timeout = jiffies +
-				  msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
-			while (!time_after(jiffies, timeout)) {
-				if (!q6core_is_adsp_ready()) {
-					dev_dbg(msm_sdw->dev,
-						"ADSP isn't ready\n");
-				} else {
-					dev_dbg(msm_sdw->dev,
-						"ADSP is ready\n");
-					adsp_ready = true;
-					goto powerup;
-				}
-			}
-		} else {
-			adsp_ready = true;
-			dev_dbg(msm_sdw->dev, "%s: DSP is ready\n", __func__);
-		}
-powerup:
-		if (adsp_ready) {
-			msm_sdw->dev_up = true;
-			msm_sdw_init_reg(msm_sdw->codec);
-			regcache_mark_dirty(msm_sdw->regmap);
-			regcache_sync(msm_sdw->regmap);
-			msm_sdw_set_spkr_mode(msm_sdw->codec,
-					      msm_sdw->spkr_mode);
-		}
-		break;
-	default:
-		break;
-	}
-	mutex_unlock(&msm_sdw->codec_mutex);
-	return NOTIFY_OK;
-}
-
-static int msm_sdw_codec_probe(struct snd_soc_codec *codec)
-{
-	struct msm_sdw_priv *msm_sdw;
-	int i, ret;
-
-	msm_sdw = snd_soc_codec_get_drvdata(codec);
-	if (!msm_sdw) {
-		pr_err("%s:SDW priv data null\n", __func__);
-		return -EINVAL;
-	}
-	msm_sdw->codec = codec;
-	for (i = 0; i < COMP_MAX; i++)
-		msm_sdw->comp_enabled[i] = 0;
-
-	msm_sdw->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
-	msm_sdw_init_reg(codec);
-	msm_sdw->version = MSM_SDW_VERSION_1_0;
-
-	msm_sdw->service_nb.notifier_call = msm_sdw_notifier_service_cb;
-	ret = audio_notifier_register("msm_sdw",
-				AUDIO_NOTIFIER_ADSP_DOMAIN,
-				&msm_sdw->service_nb);
-	if (ret < 0)
-		dev_err(msm_sdw->dev,
-			"%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-	return 0;
-}
-
-static int msm_sdw_codec_remove(struct snd_soc_codec *codec)
-{
-	return 0;
-}
-
-static struct regmap *msm_sdw_get_regmap(struct device *dev)
-{
-	struct msm_sdw_priv *msm_sdw = dev_get_drvdata(dev);
-
-	return msm_sdw->regmap;
-}
-
-static struct snd_soc_codec_driver soc_codec_dev_msm_sdw = {
-	.probe = msm_sdw_codec_probe,
-	.remove = msm_sdw_codec_remove,
-	.get_regmap = msm_sdw_get_regmap,
-	.component_driver = {
-		.controls = msm_sdw_snd_controls,
-		.num_controls = ARRAY_SIZE(msm_sdw_snd_controls),
-		.dapm_widgets = msm_sdw_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(msm_sdw_dapm_widgets),
-		.dapm_routes = audio_map,
-		.num_dapm_routes = ARRAY_SIZE(audio_map),
-	},
-};
-
-static void msm_sdw_add_child_devices(struct work_struct *work)
-{
-	struct msm_sdw_priv *msm_sdw;
-	struct platform_device *pdev;
-	struct device_node *node;
-	struct msm_sdw_ctrl_data *sdw_ctrl_data = NULL, *temp;
-	int ret, ctrl_num = 0;
-	struct wcd_sdw_ctrl_platform_data *platdata;
-	char plat_dev_name[MSM_SDW_STRING_LEN];
-
-	msm_sdw = container_of(work, struct msm_sdw_priv,
-			     msm_sdw_add_child_devices_work);
-	if (!msm_sdw) {
-		pr_err("%s: Memory for msm_sdw does not exist\n",
-			__func__);
-		return;
-	}
-	if (!msm_sdw->dev->of_node) {
-		dev_err(msm_sdw->dev,
-			"%s: DT node for msm_sdw does not exist\n", __func__);
-		return;
-	}
-
-	platdata = &msm_sdw->sdw_plat_data;
-
-	for_each_available_child_of_node(msm_sdw->dev->of_node, node) {
-		if (!strcmp(node->name, "swr_master"))
-			strlcpy(plat_dev_name, "msm_sdw_swr_ctrl",
-				(MSM_SDW_STRING_LEN - 1));
-		else if (strnstr(node->name, "msm_cdc_pinctrl",
-				 strlen("msm_cdc_pinctrl")) != NULL)
-			strlcpy(plat_dev_name, node->name,
-				(MSM_SDW_STRING_LEN - 1));
-		else
-			continue;
-
-		pdev = platform_device_alloc(plat_dev_name, -1);
-		if (!pdev) {
-			dev_err(msm_sdw->dev, "%s: pdev memory alloc failed\n",
-				__func__);
-			ret = -ENOMEM;
-			goto err;
-		}
-		pdev->dev.parent = msm_sdw->dev;
-		pdev->dev.of_node = node;
-
-		if (!strcmp(node->name, "swr_master")) {
-			ret = platform_device_add_data(pdev, platdata,
-						       sizeof(*platdata));
-			if (ret) {
-				dev_err(&pdev->dev,
-					"%s: cannot add plat data ctrl:%d\n",
-					__func__, ctrl_num);
-				goto fail_pdev_add;
-			}
-		}
-
-		ret = platform_device_add(pdev);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: Cannot add platform device\n",
-				__func__);
-			goto fail_pdev_add;
-		}
-
-		if (!strcmp(node->name, "swr_master")) {
-			temp = krealloc(sdw_ctrl_data,
-					(ctrl_num + 1) * sizeof(
-					struct msm_sdw_ctrl_data),
-					GFP_KERNEL);
-			if (!temp) {
-				dev_err(&pdev->dev, "out of memory\n");
-				ret = -ENOMEM;
-				goto err;
-			}
-			sdw_ctrl_data = temp;
-			sdw_ctrl_data[ctrl_num].sdw_pdev = pdev;
-			ctrl_num++;
-			dev_dbg(&pdev->dev,
-				"%s: Added soundwire ctrl device(s)\n",
-				__func__);
-			msm_sdw->nr = ctrl_num;
-			msm_sdw->sdw_ctrl_data = sdw_ctrl_data;
-		}
-	}
-
-	return;
-fail_pdev_add:
-	platform_device_put(pdev);
-err:
-	return;
-}
-
-static int msm_sdw_probe(struct platform_device *pdev)
-{
-	int ret = 0;
-	struct msm_sdw_priv *msm_sdw;
-	int adsp_state;
-
-	adsp_state = apr_get_subsys_state();
-	if (adsp_state != APR_SUBSYS_LOADED) {
-		dev_err(&pdev->dev, "Adsp is not loaded yet %d\n",
-				adsp_state);
-		return -EPROBE_DEFER;
-	}
-
-	msm_sdw = devm_kzalloc(&pdev->dev, sizeof(struct msm_sdw_priv),
-			    GFP_KERNEL);
-	if (!msm_sdw)
-		return -ENOMEM;
-	dev_set_drvdata(&pdev->dev, msm_sdw);
-	msm_sdw->dev_up = true;
-
-	msm_sdw->dev = &pdev->dev;
-	INIT_WORK(&msm_sdw->msm_sdw_add_child_devices_work,
-		  msm_sdw_add_child_devices);
-	msm_sdw->sdw_plat_data.handle = (void *) msm_sdw;
-	msm_sdw->sdw_plat_data.read = msm_sdw_swrm_read;
-	msm_sdw->sdw_plat_data.write = msm_sdw_swrm_write;
-	msm_sdw->sdw_plat_data.bulk_write = msm_sdw_swrm_bulk_write;
-	msm_sdw->sdw_plat_data.clk = msm_sdw_swrm_clock;
-	msm_sdw->sdw_plat_data.handle_irq = msm_sdwm_handle_irq;
-	ret = of_property_read_u32(pdev->dev.of_node, "reg",
-				   &msm_sdw->sdw_base_addr);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
-			__func__, "reg");
-		goto err_sdw_cdc;
-	}
-
-	msm_sdw->sdw_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,cdc-sdw-gpios", 0);
-	msm_sdw->sdw_base = ioremap(msm_sdw->sdw_base_addr,
-				    MSM_SDW_MAX_REGISTER);
-	msm_sdw->read_dev = __msm_sdw_reg_read;
-	msm_sdw->write_dev = __msm_sdw_reg_write;
-
-	msm_sdw->regmap = msm_sdw_regmap_init(msm_sdw->dev,
-					      &msm_sdw_regmap_config);
-	msm_sdw->sdw_irq = platform_get_irq_byname(pdev, "swr_master_irq");
-	if (msm_sdw->sdw_irq < 0) {
-		dev_err(msm_sdw->dev, "%s() error getting irq handle: %d\n",
-				__func__, msm_sdw->sdw_irq);
-		ret = -ENODEV;
-		goto err_sdw_cdc;
-	}
-	ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm_sdw,
-				     msm_sdw_dai, ARRAY_SIZE(msm_sdw_dai));
-	if (ret) {
-		dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
-			__func__, ret);
-		goto err_sdw_cdc;
-	}
-	/* initialize the int_mclk1 */
-	msm_sdw->sdw_cdc_core_clk.clk_set_minor_version =
-			AFE_API_VERSION_I2S_CONFIG;
-	msm_sdw->sdw_cdc_core_clk.clk_id =
-			Q6AFE_LPASS_CLK_ID_INT_MCLK_1;
-	msm_sdw->sdw_cdc_core_clk.clk_freq_in_hz =
-			INT_MCLK1_FREQ;
-	msm_sdw->sdw_cdc_core_clk.clk_attri =
-			Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
-	msm_sdw->sdw_cdc_core_clk.clk_root =
-			Q6AFE_LPASS_CLK_ROOT_DEFAULT;
-	msm_sdw->sdw_cdc_core_clk.enable = 0;
-
-	/* initialize the sdw_npl_clk */
-	msm_sdw->sdw_npl_clk.clk_set_minor_version =
-			AFE_API_VERSION_I2S_CONFIG;
-	msm_sdw->sdw_npl_clk.clk_id =
-			AFE_CLOCK_SET_CLOCK_ID_SWR_NPL_CLK;
-	msm_sdw->sdw_npl_clk.clk_freq_in_hz = SDW_NPL_FREQ;
-	msm_sdw->sdw_npl_clk.clk_attri =
-			Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
-	msm_sdw->sdw_npl_clk.clk_root =
-			Q6AFE_LPASS_CLK_ROOT_DEFAULT;
-	msm_sdw->sdw_npl_clk.enable = 0;
-
-	INIT_DELAYED_WORK(&msm_sdw->disable_int_mclk1_work,
-			  msm_disable_int_mclk1);
-	mutex_init(&msm_sdw->cdc_int_mclk1_mutex);
-	mutex_init(&msm_sdw->sdw_npl_clk_mutex);
-	mutex_init(&msm_sdw->io_lock);
-	mutex_init(&msm_sdw->sdw_read_lock);
-	mutex_init(&msm_sdw->sdw_write_lock);
-	mutex_init(&msm_sdw->sdw_clk_lock);
-	mutex_init(&msm_sdw->codec_mutex);
-	schedule_work(&msm_sdw->msm_sdw_add_child_devices_work);
-
-	dev_dbg(&pdev->dev, "%s: msm_sdw driver probe done\n", __func__);
-	return ret;
-
-err_sdw_cdc:
-	devm_kfree(&pdev->dev, msm_sdw);
-	return ret;
-}
-
-static int msm_sdw_remove(struct platform_device *pdev)
-{
-	struct msm_sdw_priv *msm_sdw;
-
-	msm_sdw = dev_get_drvdata(&pdev->dev);
-
-	mutex_destroy(&msm_sdw->io_lock);
-	mutex_destroy(&msm_sdw->sdw_read_lock);
-	mutex_destroy(&msm_sdw->sdw_write_lock);
-	mutex_destroy(&msm_sdw->sdw_clk_lock);
-	mutex_destroy(&msm_sdw->codec_mutex);
-	mutex_destroy(&msm_sdw->cdc_int_mclk1_mutex);
-	devm_kfree(&pdev->dev, msm_sdw);
-	snd_soc_unregister_codec(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_sdw_codec_dt_match[] = {
-	{ .compatible = "qcom,msm-sdw-codec", },
-	{}
-};
-
-static struct platform_driver msm_sdw_codec_driver = {
-	.probe = msm_sdw_probe,
-	.remove = msm_sdw_remove,
-	.driver = {
-		.name = "msm_sdw_codec",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_sdw_codec_dt_match,
-	},
-};
-module_platform_driver(msm_sdw_codec_driver);
-
-MODULE_DESCRIPTION("MSM Soundwire Codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/msm_sdw/msm_sdw_cdc_utils.c b/sound/soc/codecs/msm_sdw/msm_sdw_cdc_utils.c
deleted file mode 100644
index 9a5c85b..0000000
--- a/sound/soc/codecs/msm_sdw/msm_sdw_cdc_utils.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/regmap.h>
-#include "msm_sdw.h"
-
-#define REG_BYTES 2
-#define VAL_BYTES 1
-/*
- * Page Register Address that APP Proc uses to
- * access WCD9335 Codec registers is identified
- * as 0x00
- */
-#define PAGE_REG_ADDR 0x00
-
-/*
- * msm_sdw_page_write:
- * Retrieve page number from register and
- * write that page number to the page address.
- * Called under io_lock acquisition.
- *
- * @msm_sdw: pointer to msm_sdw
- * @reg: Register address from which page number is retrieved
- *
- * Returns 0 for success and negative error code for failure.
- */
-int msm_sdw_page_write(struct msm_sdw_priv *msm_sdw, unsigned short reg)
-{
-	int ret = 0;
-	u8 pg_num, prev_pg_num;
-
-	pg_num = msm_sdw_page_map[reg];
-	if (msm_sdw->prev_pg_valid) {
-		prev_pg_num = msm_sdw->prev_pg;
-		if (prev_pg_num != pg_num) {
-			ret = msm_sdw->write_dev(msm_sdw, PAGE_REG_ADDR, 1,
-						 (void *) &pg_num);
-			if (ret < 0) {
-				dev_err(msm_sdw->dev,
-					"page write error, pg_num: 0x%x\n",
-					pg_num);
-			} else {
-				msm_sdw->prev_pg = pg_num;
-				dev_dbg(msm_sdw->dev,
-					"%s: Page 0x%x Write to 0x00\n",
-					__func__, pg_num);
-			}
-		}
-	} else {
-		ret = msm_sdw->write_dev(msm_sdw, PAGE_REG_ADDR, 1,
-					 (void *) &pg_num);
-		if (ret < 0) {
-			dev_err(msm_sdw->dev,
-				"page write error, pg_num: 0x%x\n", pg_num);
-		} else {
-			msm_sdw->prev_pg = pg_num;
-			msm_sdw->prev_pg_valid = true;
-			dev_dbg(msm_sdw->dev, "%s: Page 0x%x Write to 0x00\n",
-				__func__, pg_num);
-		}
-	}
-	return ret;
-}
-EXPORT_SYMBOL(msm_sdw_page_write);
-
-static int regmap_bus_read(void *context, const void *reg, size_t reg_size,
-			   void *val, size_t val_size)
-{
-	struct device *dev = context;
-	struct msm_sdw_priv *msm_sdw = dev_get_drvdata(dev);
-	unsigned short c_reg;
-	int ret, i;
-
-	if (!msm_sdw) {
-		dev_err(dev, "%s: msm_sdw is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-	if (!msm_sdw->dev_up) {
-		dev_dbg_ratelimited(dev, "%s: No read allowed. dev_up = %d\n",
-				    __func__, msm_sdw->dev_up);
-		return 0;
-	}
-
-	mutex_lock(&msm_sdw->io_lock);
-	c_reg = *(u16 *)reg;
-	ret = msm_sdw_page_write(msm_sdw, c_reg);
-	if (ret)
-		goto err;
-	ret = msm_sdw->read_dev(msm_sdw, c_reg, val_size, val);
-	if (ret < 0)
-		dev_err(dev, "%s: Codec read failed (%d), reg: 0x%x, size:%zd\n",
-			__func__, ret, c_reg, val_size);
-	else {
-		for (i = 0; i < val_size; i++)
-			dev_dbg(dev, "%s: Read 0x%02x from 0x%x\n",
-				__func__, ((u8 *)val)[i], c_reg + i);
-	}
-err:
-	mutex_unlock(&msm_sdw->io_lock);
-
-	return ret;
-}
-
-static int regmap_bus_gather_write(void *context,
-				   const void *reg, size_t reg_size,
-				   const void *val, size_t val_size)
-{
-	struct device *dev = context;
-	struct msm_sdw_priv *msm_sdw = dev_get_drvdata(dev);
-	unsigned short c_reg;
-	int ret, i;
-
-	if (!msm_sdw) {
-		dev_err(dev, "%s: msm_sdw is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
-			__func__, reg_size);
-		return -EINVAL;
-	}
-	if (!msm_sdw->dev_up) {
-		dev_dbg_ratelimited(dev, "%s: No write allowed. dev_up = %d\n",
-				    __func__, msm_sdw->dev_up);
-		return 0;
-	}
-
-	mutex_lock(&msm_sdw->io_lock);
-	c_reg = *(u16 *)reg;
-	ret = msm_sdw_page_write(msm_sdw, c_reg);
-	if (ret)
-		goto err;
-
-	for (i = 0; i < val_size; i++)
-		dev_dbg(dev, "Write %02x to 0x%x\n", ((u8 *)val)[i],
-			c_reg + i*4);
-
-	ret = msm_sdw->write_dev(msm_sdw, c_reg, val_size, (void *) val);
-	if (ret < 0)
-		dev_err(dev,
-			"%s: Codec write failed (%d), reg:0x%x, size:%zd\n",
-			__func__, ret, c_reg, val_size);
-
-err:
-	mutex_unlock(&msm_sdw->io_lock);
-	return ret;
-}
-
-static int regmap_bus_write(void *context, const void *data, size_t count)
-{
-	struct device *dev = context;
-	struct msm_sdw_priv *msm_sdw = dev_get_drvdata(dev);
-
-	if (!msm_sdw)
-		return -EINVAL;
-
-	WARN_ON(count < REG_BYTES);
-
-	return regmap_bus_gather_write(context, data, REG_BYTES,
-				       data + REG_BYTES,
-				       count - REG_BYTES);
-
-}
-
-static struct regmap_bus regmap_bus_config = {
-	.write = regmap_bus_write,
-	.gather_write = regmap_bus_gather_write,
-	.read = regmap_bus_read,
-	.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
-};
-
-/*
- * msm_sdw_regmap_init:
- * Initialize msm_sdw register map
- *
- * @dev: pointer to wcd device
- * @config: pointer to register map config
- *
- * Returns pointer to regmap structure for success
- * or NULL in case of failure.
- */
-struct regmap *msm_sdw_regmap_init(struct device *dev,
-				   const struct regmap_config *config)
-{
-	return devm_regmap_init(dev, &regmap_bus_config, dev, config);
-}
-EXPORT_SYMBOL(msm_sdw_regmap_init);
diff --git a/sound/soc/codecs/msm_sdw/msm_sdw_registers.h b/sound/soc/codecs/msm_sdw/msm_sdw_registers.h
deleted file mode 100644
index 1b7b0b0..0000000
--- a/sound/soc/codecs/msm_sdw/msm_sdw_registers.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 MSM_SDW_REGISTERS_H
-#define MSM_SDW_REGISTERS_H
-
-#define MSM_SDW_PAGE_REGISTER                     0x0000
-
-/* Page-A Registers */
-#define MSM_SDW_TX9_SPKR_PROT_PATH_CTL               0x0308
-#define MSM_SDW_TX9_SPKR_PROT_PATH_CFG0              0x030c
-#define MSM_SDW_TX10_SPKR_PROT_PATH_CTL              0x0318
-#define MSM_SDW_TX10_SPKR_PROT_PATH_CFG0             0x031c
-#define MSM_SDW_TX11_SPKR_PROT_PATH_CTL              0x0328
-#define MSM_SDW_TX11_SPKR_PROT_PATH_CFG0             0x032c
-#define MSM_SDW_TX12_SPKR_PROT_PATH_CTL              0x0338
-#define MSM_SDW_TX12_SPKR_PROT_PATH_CFG0             0x033c
-
-/* Page-B Registers */
-#define MSM_SDW_COMPANDER7_CTL0                      0x0024
-#define MSM_SDW_COMPANDER7_CTL1                      0x0028
-#define MSM_SDW_COMPANDER7_CTL2                      0x002c
-#define MSM_SDW_COMPANDER7_CTL3                      0x0030
-#define MSM_SDW_COMPANDER7_CTL4                      0x0034
-#define MSM_SDW_COMPANDER7_CTL5                      0x0038
-#define MSM_SDW_COMPANDER7_CTL6                      0x003c
-#define MSM_SDW_COMPANDER7_CTL7                      0x0040
-#define MSM_SDW_COMPANDER8_CTL0                      0x0044
-#define MSM_SDW_COMPANDER8_CTL1                      0x0048
-#define MSM_SDW_COMPANDER8_CTL2                      0x004c
-#define MSM_SDW_COMPANDER8_CTL3                      0x0050
-#define MSM_SDW_COMPANDER8_CTL4                      0x0054
-#define MSM_SDW_COMPANDER8_CTL5                      0x0058
-#define MSM_SDW_COMPANDER8_CTL6                      0x005c
-#define MSM_SDW_COMPANDER8_CTL7                      0x0060
-#define MSM_SDW_RX7_RX_PATH_CTL                      0x01a4
-#define MSM_SDW_RX7_RX_PATH_CFG0                     0x01a8
-#define MSM_SDW_RX7_RX_PATH_CFG1                     0x01ac
-#define MSM_SDW_RX7_RX_PATH_CFG2                     0x01b0
-#define MSM_SDW_RX7_RX_VOL_CTL                       0x01b4
-#define MSM_SDW_RX7_RX_PATH_MIX_CTL                  0x01b8
-#define MSM_SDW_RX7_RX_PATH_MIX_CFG                  0x01bc
-#define MSM_SDW_RX7_RX_VOL_MIX_CTL                   0x01c0
-#define MSM_SDW_RX7_RX_PATH_SEC0                     0x01c4
-#define MSM_SDW_RX7_RX_PATH_SEC1                     0x01c8
-#define MSM_SDW_RX7_RX_PATH_SEC2                     0x01cc
-#define MSM_SDW_RX7_RX_PATH_SEC3                     0x01d0
-#define MSM_SDW_RX7_RX_PATH_SEC5                     0x01d8
-#define MSM_SDW_RX7_RX_PATH_SEC6                     0x01dc
-#define MSM_SDW_RX7_RX_PATH_SEC7                     0x01e0
-#define MSM_SDW_RX7_RX_PATH_MIX_SEC0                 0x01e4
-#define MSM_SDW_RX7_RX_PATH_MIX_SEC1                 0x01e8
-#define MSM_SDW_RX8_RX_PATH_CTL                      0x0384
-#define MSM_SDW_RX8_RX_PATH_CFG0                     0x0388
-#define MSM_SDW_RX8_RX_PATH_CFG1                     0x038c
-#define MSM_SDW_RX8_RX_PATH_CFG2                     0x0390
-#define MSM_SDW_RX8_RX_VOL_CTL                       0x0394
-#define MSM_SDW_RX8_RX_PATH_MIX_CTL                  0x0398
-#define MSM_SDW_RX8_RX_PATH_MIX_CFG                  0x039c
-#define MSM_SDW_RX8_RX_VOL_MIX_CTL                   0x03a0
-#define MSM_SDW_RX8_RX_PATH_SEC0                     0x03a4
-#define MSM_SDW_RX8_RX_PATH_SEC1                     0x03a8
-#define MSM_SDW_RX8_RX_PATH_SEC2                     0x03ac
-#define MSM_SDW_RX8_RX_PATH_SEC3                     0x03b0
-#define MSM_SDW_RX8_RX_PATH_SEC5                     0x03b8
-#define MSM_SDW_RX8_RX_PATH_SEC6                     0x03bc
-#define MSM_SDW_RX8_RX_PATH_SEC7                     0x03c0
-#define MSM_SDW_RX8_RX_PATH_MIX_SEC0                 0x03c4
-#define MSM_SDW_RX8_RX_PATH_MIX_SEC1                 0x03c8
-
-/* Page-C Registers */
-#define MSM_SDW_BOOST0_BOOST_PATH_CTL                0x0064
-#define MSM_SDW_BOOST0_BOOST_CTL                     0x0068
-#define MSM_SDW_BOOST0_BOOST_CFG1                    0x006c
-#define MSM_SDW_BOOST0_BOOST_CFG2                    0x0070
-#define MSM_SDW_BOOST1_BOOST_PATH_CTL                0x0084
-#define MSM_SDW_BOOST1_BOOST_CTL                     0x0088
-#define MSM_SDW_BOOST1_BOOST_CFG1                    0x008c
-#define MSM_SDW_BOOST1_BOOST_CFG2                    0x0090
-#define MSM_SDW_AHB_BRIDGE_WR_DATA_0                 0x00a4
-#define MSM_SDW_AHB_BRIDGE_WR_DATA_1                 0x00a8
-#define MSM_SDW_AHB_BRIDGE_WR_DATA_2                 0x00ac
-#define MSM_SDW_AHB_BRIDGE_WR_DATA_3                 0x00b0
-#define MSM_SDW_AHB_BRIDGE_WR_ADDR_0                 0x00b4
-#define MSM_SDW_AHB_BRIDGE_WR_ADDR_1                 0x00b8
-#define MSM_SDW_AHB_BRIDGE_WR_ADDR_2                 0x00bc
-#define MSM_SDW_AHB_BRIDGE_WR_ADDR_3                 0x00c0
-#define MSM_SDW_AHB_BRIDGE_RD_ADDR_0                 0x00c4
-#define MSM_SDW_AHB_BRIDGE_RD_ADDR_1                 0x00c8
-#define MSM_SDW_AHB_BRIDGE_RD_ADDR_2                 0x00cc
-#define MSM_SDW_AHB_BRIDGE_RD_ADDR_3                 0x00d0
-#define MSM_SDW_AHB_BRIDGE_RD_DATA_0                 0x00d4
-#define MSM_SDW_AHB_BRIDGE_RD_DATA_1                 0x00d8
-#define MSM_SDW_AHB_BRIDGE_RD_DATA_2                 0x00dc
-#define MSM_SDW_AHB_BRIDGE_RD_DATA_3                 0x00e0
-#define MSM_SDW_AHB_BRIDGE_ACCESS_CFG                0x00e4
-#define MSM_SDW_AHB_BRIDGE_ACCESS_STATUS             0x00e8
-
-/* Page-D Registers */
-#define MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL            0x0104
-#define MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL          0x0108
-#define MSM_SDW_CLK_RST_CTRL_SWR_CONTROL             0x010c
-#define MSM_SDW_TOP_TOP_CFG0                         0x0204
-#define MSM_SDW_TOP_TOP_CFG1                         0x0208
-#define MSM_SDW_TOP_RX_I2S_CTL                       0x020c
-#define MSM_SDW_TOP_TX_I2S_CTL                       0x0210
-#define MSM_SDW_TOP_I2S_CLK                          0x0214
-#define MSM_SDW_TOP_RX7_PATH_INPUT0_MUX              0x0218
-#define MSM_SDW_TOP_RX7_PATH_INPUT1_MUX              0x021c
-#define MSM_SDW_TOP_RX8_PATH_INPUT0_MUX              0x0220
-#define MSM_SDW_TOP_RX8_PATH_INPUT1_MUX              0x0224
-#define MSM_SDW_TOP_FREQ_MCLK                        0x0228
-#define MSM_SDW_TOP_DEBUG_BUS_SEL                    0x022c
-#define MSM_SDW_TOP_DEBUG_EN                         0x0230
-#define MSM_SDW_TOP_I2S_RESET                        0x0234
-#define MSM_SDW_TOP_BLOCKS_RESET                     0x0238
-
-#endif
diff --git a/sound/soc/codecs/msm_sdw/msm_sdw_regmap.c b/sound/soc/codecs/msm_sdw/msm_sdw_regmap.c
deleted file mode 100644
index 2266338..0000000
--- a/sound/soc/codecs/msm_sdw/msm_sdw_regmap.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/regmap.h>
-#include "msm_sdw.h"
-
-static const struct reg_default msm_sdw_defaults[] = {
-	/* Page #10 registers */
-	{ MSM_SDW_PAGE_REGISTER, 0x00 },
-	{ MSM_SDW_TX9_SPKR_PROT_PATH_CTL, 0x02 },
-	{ MSM_SDW_TX9_SPKR_PROT_PATH_CFG0, 0x00 },
-	{ MSM_SDW_TX10_SPKR_PROT_PATH_CTL, 0x02 },
-	{ MSM_SDW_TX10_SPKR_PROT_PATH_CFG0, 0x00 },
-	{ MSM_SDW_TX11_SPKR_PROT_PATH_CTL, 0x02 },
-	{ MSM_SDW_TX11_SPKR_PROT_PATH_CFG0, 0x00 },
-	{ MSM_SDW_TX12_SPKR_PROT_PATH_CTL, 0x02 },
-	{ MSM_SDW_TX12_SPKR_PROT_PATH_CFG0, 0x00 },
-	/* Page #11 registers */
-	{ MSM_SDW_COMPANDER7_CTL0, 0x60 },
-	{ MSM_SDW_COMPANDER7_CTL1, 0xdb },
-	{ MSM_SDW_COMPANDER7_CTL2, 0xff },
-	{ MSM_SDW_COMPANDER7_CTL3, 0x35 },
-	{ MSM_SDW_COMPANDER7_CTL4, 0xff },
-	{ MSM_SDW_COMPANDER7_CTL5, 0x00 },
-	{ MSM_SDW_COMPANDER7_CTL6, 0x01 },
-	{ MSM_SDW_COMPANDER8_CTL0, 0x60 },
-	{ MSM_SDW_COMPANDER8_CTL1, 0xdb },
-	{ MSM_SDW_COMPANDER8_CTL2, 0xff },
-	{ MSM_SDW_COMPANDER8_CTL3, 0x35 },
-	{ MSM_SDW_COMPANDER8_CTL4, 0xff },
-	{ MSM_SDW_COMPANDER8_CTL5, 0x00 },
-	{ MSM_SDW_COMPANDER8_CTL6, 0x01 },
-	{ MSM_SDW_RX7_RX_PATH_CTL, 0x04 },
-	{ MSM_SDW_RX7_RX_PATH_CFG0, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_CFG2, 0x8f },
-	{ MSM_SDW_RX7_RX_VOL_CTL, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_MIX_CTL, 0x04 },
-	{ MSM_SDW_RX7_RX_VOL_MIX_CTL, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_SEC2, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_SEC3, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_SEC5, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_SEC6, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_SEC7, 0x00 },
-	{ MSM_SDW_RX7_RX_PATH_MIX_SEC1, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_CTL, 0x04 },
-	{ MSM_SDW_RX8_RX_PATH_CFG0, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_CFG2, 0x8f },
-	{ MSM_SDW_RX8_RX_VOL_CTL, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_MIX_CTL, 0x04 },
-	{ MSM_SDW_RX8_RX_VOL_MIX_CTL, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_SEC2, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_SEC3, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_SEC5, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_SEC6, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_SEC7, 0x00 },
-	{ MSM_SDW_RX8_RX_PATH_MIX_SEC1, 0x00 },
-	/* Page #12 registers */
-	{ MSM_SDW_BOOST0_BOOST_PATH_CTL, 0x00 },
-	{ MSM_SDW_BOOST0_BOOST_CTL, 0xb2 },
-	{ MSM_SDW_BOOST0_BOOST_CFG1, 0x00 },
-	{ MSM_SDW_BOOST0_BOOST_CFG2, 0x00 },
-	{ MSM_SDW_BOOST1_BOOST_PATH_CTL, 0x00 },
-	{ MSM_SDW_BOOST1_BOOST_CTL, 0xb2 },
-	{ MSM_SDW_BOOST1_BOOST_CFG1, 0x00 },
-	{ MSM_SDW_BOOST1_BOOST_CFG2, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_DATA_0, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_DATA_1, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_DATA_2, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_DATA_3, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_ADDR_0, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_ADDR_1, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_ADDR_2, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_WR_ADDR_3, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_ADDR_0, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_ADDR_1, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_ADDR_2, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_ADDR_3, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_DATA_0, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_DATA_1, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_DATA_2, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_RD_DATA_3, 0x00 },
-	{ MSM_SDW_AHB_BRIDGE_ACCESS_CFG, 0x0f },
-	{ MSM_SDW_AHB_BRIDGE_ACCESS_STATUS, 0x03 },
-	/* Page #13 registers */
-	{ MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL, 0x00 },
-	{ MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL, 0x00 },
-	{ MSM_SDW_CLK_RST_CTRL_SWR_CONTROL, 0x00 },
-	{ MSM_SDW_TOP_TOP_CFG0, 0x00 },
-	{ MSM_SDW_TOP_TOP_CFG1, 0x00 },
-	{ MSM_SDW_TOP_RX_I2S_CTL, 0x0C },
-	{ MSM_SDW_TOP_TX_I2S_CTL, 0x00 },
-	{ MSM_SDW_TOP_I2S_CLK, 0x00 },
-	{ MSM_SDW_TOP_RX7_PATH_INPUT0_MUX, 0x00 },
-	{ MSM_SDW_TOP_RX7_PATH_INPUT1_MUX, 0x00 },
-	{ MSM_SDW_TOP_RX8_PATH_INPUT0_MUX, 0x00 },
-	{ MSM_SDW_TOP_RX8_PATH_INPUT1_MUX, 0x00 },
-	{ MSM_SDW_TOP_FREQ_MCLK, 0x00 },
-	{ MSM_SDW_TOP_DEBUG_BUS_SEL, 0x00 },
-	{ MSM_SDW_TOP_DEBUG_EN, 0x00 },
-	{ MSM_SDW_TOP_I2S_RESET, 0x00 },
-	{ MSM_SDW_TOP_BLOCKS_RESET, 0x00 },
-};
-
-static bool msm_sdw_is_readable_register(struct device *dev, unsigned int reg)
-{
-	return msm_sdw_reg_readable[reg];
-}
-
-static bool msm_sdw_is_writeable_register(struct device *dev, unsigned int reg)
-{
-	return msm_sdw_reg_writeable[reg];
-}
-
-static bool msm_sdw_is_volatile_register(struct device *dev, unsigned int reg)
-{
-	switch (reg) {
-	case MSM_SDW_AHB_BRIDGE_WR_DATA_0:
-	case MSM_SDW_AHB_BRIDGE_WR_DATA_1:
-	case MSM_SDW_AHB_BRIDGE_WR_DATA_2:
-	case MSM_SDW_AHB_BRIDGE_WR_DATA_3:
-	case MSM_SDW_AHB_BRIDGE_WR_ADDR_0:
-	case MSM_SDW_AHB_BRIDGE_WR_ADDR_1:
-	case MSM_SDW_AHB_BRIDGE_WR_ADDR_2:
-	case MSM_SDW_AHB_BRIDGE_WR_ADDR_3:
-	case MSM_SDW_AHB_BRIDGE_RD_DATA_0:
-	case MSM_SDW_AHB_BRIDGE_RD_DATA_1:
-	case MSM_SDW_AHB_BRIDGE_RD_DATA_2:
-	case MSM_SDW_AHB_BRIDGE_RD_DATA_3:
-	case MSM_SDW_AHB_BRIDGE_RD_ADDR_0:
-	case MSM_SDW_AHB_BRIDGE_RD_ADDR_1:
-	case MSM_SDW_AHB_BRIDGE_RD_ADDR_2:
-	case MSM_SDW_AHB_BRIDGE_RD_ADDR_3:
-	case MSM_SDW_CLK_RST_CTRL_MCLK_CONTROL:
-	case MSM_SDW_CLK_RST_CTRL_FS_CNT_CONTROL:
-		return true;
-	default:
-		return false;
-	}
-}
-
-const struct regmap_config msm_sdw_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.reg_stride = 4,
-	.cache_type = REGCACHE_RBTREE,
-	.reg_defaults = msm_sdw_defaults,
-	.num_reg_defaults = ARRAY_SIZE(msm_sdw_defaults),
-	.max_register = MSM_SDW_MAX_REGISTER,
-	.writeable_reg = msm_sdw_is_writeable_register,
-	.volatile_reg = msm_sdw_is_volatile_register,
-	.readable_reg = msm_sdw_is_readable_register,
-};
diff --git a/sound/soc/codecs/msm_stub.c b/sound/soc/codecs/msm_stub.c
deleted file mode 100644
index 68e55ae..0000000
--- a/sound/soc/codecs/msm_stub.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-
-/* A dummy driver useful only to advertise hardware parameters */
-static struct snd_soc_dai_driver msm_stub_dais[] = {
-	{
-		.name = "msm-stub-rx",
-		.playback = { /* Support maximum range */
-			.stream_name = "Playback",
-			.channels_min = 1,
-			.channels_max = 8,
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		},
-	},
-	{
-		.name = "msm-stub-tx",
-		.capture = { /* Support maximum range */
-			.stream_name = "Record",
-			.channels_min = 1,
-			.channels_max = 8,
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-		},
-	},
-};
-
-static struct snd_soc_codec_driver soc_msm_stub = {};
-
-static int msm_stub_dev_probe(struct platform_device *pdev)
-{
-	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
-
-	return snd_soc_register_codec(&pdev->dev,
-	&soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais));
-}
-
-static int msm_stub_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_codec(&pdev->dev);
-	return 0;
-}
-static const struct of_device_id msm_stub_codec_dt_match[] = {
-	{ .compatible = "qcom,msm-stub-codec", },
-	{}
-};
-
-static struct platform_driver msm_stub_driver = {
-	.driver = {
-		.name = "msm-stub-codec",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_stub_codec_dt_match,
-	},
-	.probe = msm_stub_dev_probe,
-	.remove = msm_stub_dev_remove,
-};
-
-static int __init msm_stub_init(void)
-{
-	return platform_driver_register(&msm_stub_driver);
-}
-module_init(msm_stub_init);
-
-static void __exit msm_stub_exit(void)
-{
-	platform_driver_unregister(&msm_stub_driver);
-}
-module_exit(msm_stub_exit);
-
-MODULE_DESCRIPTION("Generic MSM CODEC driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index e643be9..f9f2737 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1928,7 +1928,8 @@
 			NAU8825_FLL_INTEGER_MASK, fll_param->fll_int);
 	/* FLL pre-scaler */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4,
-			NAU8825_FLL_REF_DIV_MASK, fll_param->clk_ref_div);
+			NAU8825_FLL_REF_DIV_MASK,
+			fll_param->clk_ref_div << NAU8825_FLL_REF_DIV_SFT);
 	/* select divided VCO input */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,
 		NAU8825_FLL_CLK_SW_MASK, NAU8825_FLL_CLK_SW_REF);
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 1c63e2a..574d6f9 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -129,7 +129,8 @@
 #define NAU8825_FLL_CLK_SRC_FS			(0x3 << NAU8825_FLL_CLK_SRC_SFT)
 
 /* FLL4 (0x07) */
-#define NAU8825_FLL_REF_DIV_MASK		(0x3 << 10)
+#define NAU8825_FLL_REF_DIV_SFT	10
+#define NAU8825_FLL_REF_DIV_MASK	(0x3 << NAU8825_FLL_REF_DIV_SFT)
 
 /* FLL5 (0x08) */
 #define NAU8825_FLL_PDB_DAC_EN		(0x1 << 15)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 10c2a564..1ac96ef 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3833,6 +3833,9 @@
 		}
 	}
 
+	regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
+		RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
+
 	if (rt5645->pdata.jd_invert) {
 		regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
 			RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
diff --git a/sound/soc/codecs/sdm660_cdc/Kconfig b/sound/soc/codecs/sdm660_cdc/Kconfig
deleted file mode 100644
index e618258..0000000
--- a/sound/soc/codecs/sdm660_cdc/Kconfig
+++ /dev/null
@@ -1,4 +0,0 @@
-
-config SND_SOC_SDM660_CDC
-	tristate "MSM Internal PMIC based codec"
-	select SND_SOC_WCD_MBHC_LEGACY
diff --git a/sound/soc/codecs/sdm660_cdc/Makefile b/sound/soc/codecs/sdm660_cdc/Makefile
deleted file mode 100644
index d846fae..0000000
--- a/sound/soc/codecs/sdm660_cdc/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-snd-soc-sdm660-cdc-objs := msm-analog-cdc.o msm-digital-cdc.o sdm660-regmap.o
-obj-$(CONFIG_SND_SOC_SDM660_CDC) += snd-soc-sdm660-cdc.o sdm660-cdc-irq.o
diff --git a/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.c b/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.c
deleted file mode 100644
index f126d35..0000000
--- a/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.c
+++ /dev/null
@@ -1,4691 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/printk.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/regulator/consumer.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/workqueue.h>
-#include <linux/regmap.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include <sound/q6afe-v2.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include <sound/q6core.h>
-#include "msm-analog-cdc.h"
-#include "sdm660-cdc-irq.h"
-#include "sdm660-cdc-registers.h"
-#include "msm-cdc-common.h"
-#include "../../msm/sdm660-common.h"
-#include "../wcd-mbhc-v2-api.h"
-
-#define DRV_NAME "pmic_analog_codec"
-#define SDM660_CDC_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
-			SNDRV_PCM_RATE_192000)
-#define SDM660_CDC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
-		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE)
-#define MSM_DIG_CDC_STRING_LEN 80
-#define MSM_ANLG_CDC_VERSION_ENTRY_SIZE 32
-
-#define CODEC_DT_MAX_PROP_SIZE			40
-#define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH	64
-#define BUS_DOWN 1
-
-/*
- * 50 Milliseconds sufficient for DSP bring up in the lpass
- * after Sub System Restart
- */
-#define ADSP_STATE_READY_TIMEOUT_MS 50
-
-#define EAR_PMD 0
-#define EAR_PMU 1
-#define SPK_PMD 2
-#define SPK_PMU 3
-
-#define MICBIAS_DEFAULT_VAL 1800000
-#define MICBIAS_MIN_VAL 1600000
-#define MICBIAS_STEP_SIZE 50000
-
-#define DEFAULT_BOOST_VOLTAGE 5000
-#define MIN_BOOST_VOLTAGE 4000
-#define MAX_BOOST_VOLTAGE 5550
-#define BOOST_VOLTAGE_STEP 50
-
-#define SDM660_CDC_MBHC_BTN_COARSE_ADJ  100 /* in mV */
-#define SDM660_CDC_MBHC_BTN_FINE_ADJ 12 /* in mV */
-
-#define VOLTAGE_CONVERTER(value, min_value, step_size)\
-	((value - min_value)/step_size)
-
-enum {
-	BOOST_SWITCH = 0,
-	BOOST_ALWAYS,
-	BYPASS_ALWAYS,
-	BOOST_ON_FOREVER,
-};
-
-static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
-static struct snd_soc_dai_driver msm_anlg_cdc_i2s_dai[];
-/* By default enable the internal speaker boost */
-static bool spkr_boost_en = true;
-
-static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
-	"cdc-vdd-mic-bias",
-};
-
-static struct wcd_mbhc_register
-	wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
-	WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1, 0x18, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
-			  MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x06, 1, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
-			  MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
-			  MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER, 0xF0, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
-			  MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER, 0x0C, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
-			  MSM89XX_PMIC_ANALOG_MBHC_BTN3_CTL, 0x03, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0x01,
-			  0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0x02,
-			  1, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0x08,
-			  3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0x04,
-			  2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
-			  MSM89XX_PMIC_ANALOG_RX_COM_OCP_CTL, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT, 0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
-			  MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL, 0x70, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0xFF,
-			  0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
-			  MSM89XX_PMIC_ANALOG_MICB_2_EN, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
-			  MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME, 0xFC, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
-			  MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
-			  MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
-			  MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN, 0x30, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
-			  MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT,
-			  0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
-			  MSM89XX_PMIC_ANALOG_MICB_2_EN, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN", 0, 0, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS", 0, 0, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL", 0, 0, 0, 0),
-};
-
-/* Multiply gain_adj and offset by 1000 and 100 to avoid float arithmetic */
-static const struct wcd_imped_i_ref imped_i_ref[] = {
-	{I_h4_UA, 8, 800, 9000, 10000},
-	{I_pt5_UA, 10, 100, 990, 4600},
-	{I_14_UA, 17, 14, 1050, 700},
-	{I_l4_UA, 10, 4, 1165, 110},
-	{I_1_UA, 0, 1, 1200, 65},
-};
-
-static const struct wcd_mbhc_intr intr_ids = {
-	.mbhc_sw_intr =  MSM89XX_IRQ_MBHC_HS_DET,
-	.mbhc_btn_press_intr = MSM89XX_IRQ_MBHC_PRESS,
-	.mbhc_btn_release_intr = MSM89XX_IRQ_MBHC_RELEASE,
-	.mbhc_hs_ins_intr = MSM89XX_IRQ_MBHC_INSREM_DET1,
-	.mbhc_hs_rem_intr = MSM89XX_IRQ_MBHC_INSREM_DET,
-	.hph_left_ocp = MSM89XX_IRQ_HPHL_OCP,
-	.hph_right_ocp = MSM89XX_IRQ_HPHR_OCP,
-};
-
-static int msm_anlg_cdc_dt_parse_vreg_info(struct device *dev,
-					   struct sdm660_cdc_regulator *vreg,
-					   const char *vreg_name,
-					   bool ondemand);
-static struct sdm660_cdc_pdata *msm_anlg_cdc_populate_dt_pdata(
-						struct device *dev);
-static int msm_anlg_cdc_enable_ext_mb_source(struct wcd_mbhc *wcd_mbhc,
-					     bool turn_on);
-static void msm_anlg_cdc_trim_btn_reg(struct snd_soc_codec *codec);
-static void msm_anlg_cdc_set_micb_v(struct snd_soc_codec *codec);
-static void msm_anlg_cdc_set_boost_v(struct snd_soc_codec *codec);
-static void msm_anlg_cdc_set_auto_zeroing(struct snd_soc_codec *codec,
-					  bool enable);
-static void msm_anlg_cdc_configure_cap(struct snd_soc_codec *codec,
-				       bool micbias1, bool micbias2);
-static bool msm_anlg_cdc_use_mb(struct snd_soc_codec *codec);
-
-static int get_codec_version(struct sdm660_cdc_priv *sdm660_cdc)
-{
-	if (sdm660_cdc->codec_version == DRAX_CDC)
-		return DRAX_CDC;
-	else if (sdm660_cdc->codec_version == DIANGU)
-		return DIANGU;
-	else if (sdm660_cdc->codec_version == CAJON_2_0)
-		return CAJON_2_0;
-	else if (sdm660_cdc->codec_version == CAJON)
-		return CAJON;
-	else if (sdm660_cdc->codec_version == CONGA)
-		return CONGA;
-	else if (sdm660_cdc->pmic_rev == TOMBAK_2_0)
-		return TOMBAK_2_0;
-	else if (sdm660_cdc->pmic_rev == TOMBAK_1_0)
-		return TOMBAK_1_0;
-
-	pr_err("%s: unsupported codec version\n", __func__);
-	return UNSUPPORTED;
-}
-
-static void wcd_mbhc_meas_imped(struct snd_soc_codec *codec,
-				s16 *impedance_l, s16 *impedance_r)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if ((sdm660_cdc->imped_det_pin == WCD_MBHC_DET_BOTH) ||
-	    (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHL)) {
-		/* Enable ZDET_L_MEAS_EN */
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-				0x08, 0x08);
-		/* Wait for 2ms for measurement to complete */
-		usleep_range(2000, 2100);
-		/* Read Left impedance value from Result1 */
-		*impedance_l = snd_soc_read(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT);
-		/* Enable ZDET_R_MEAS_EN */
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-				0x08, 0x00);
-	}
-	if ((sdm660_cdc->imped_det_pin == WCD_MBHC_DET_BOTH) ||
-	    (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHR)) {
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-				0x04, 0x04);
-		/* Wait for 2ms for measurement to complete */
-		usleep_range(2000, 2100);
-		/* Read Right impedance value from Result1 */
-		*impedance_r = snd_soc_read(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT);
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-				0x04, 0x00);
-	}
-}
-
-static void msm_anlg_cdc_set_ref_current(struct snd_soc_codec *codec,
-					 enum wcd_curr_ref curr_ref)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: curr_ref: %d\n", __func__, curr_ref);
-
-	if (get_codec_version(sdm660_cdc) < CAJON)
-		dev_dbg(codec->dev, "%s: Setting ref current not required\n",
-			__func__);
-
-	sdm660_cdc->imped_i_ref = imped_i_ref[curr_ref];
-
-	switch (curr_ref) {
-	case I_h4_UA:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0x07, 0x01);
-		break;
-	case I_pt5_UA:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0x07, 0x04);
-		break;
-	case I_14_UA:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0x07, 0x03);
-		break;
-	case I_l4_UA:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0x07, 0x01);
-		break;
-	case I_1_UA:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0x07, 0x00);
-		break;
-	default:
-		pr_debug("%s: No ref current set\n", __func__);
-		break;
-	}
-}
-
-static bool msm_anlg_cdc_adj_ref_current(struct snd_soc_codec *codec,
-					 s16 *impedance_l, s16 *impedance_r)
-{
-	int i = 2;
-	s16 compare_imp = 0;
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHR)
-		compare_imp = *impedance_r;
-	else
-		compare_imp = *impedance_l;
-
-	if (get_codec_version(sdm660_cdc) < CAJON) {
-		dev_dbg(codec->dev,
-			"%s: Reference current adjustment not required\n",
-			 __func__);
-		return false;
-	}
-
-	while (compare_imp < imped_i_ref[i].min_val) {
-		msm_anlg_cdc_set_ref_current(codec, imped_i_ref[++i].curr_ref);
-		wcd_mbhc_meas_imped(codec, impedance_l, impedance_r);
-		compare_imp = (sdm660_cdc->imped_det_pin ==
-			       WCD_MBHC_DET_HPHR) ? *impedance_r : *impedance_l;
-		if (i >= I_1_UA)
-			break;
-	}
-	return true;
-}
-
-void msm_anlg_cdc_spk_ext_pa_cb(
-		int (*codec_spk_ext_pa)(struct snd_soc_codec *codec,
-			int enable), struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc;
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer!\n", __func__);
-		return;
-	}
-
-	sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: Enter\n", __func__);
-	sdm660_cdc->codec_spk_ext_pa_cb = codec_spk_ext_pa;
-}
-
-static void msm_anlg_cdc_compute_impedance(struct snd_soc_codec *codec, s16 l,
-					   s16 r, uint32_t *zl, uint32_t *zr,
-					   bool high)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	uint32_t rl = 0, rr = 0;
-	struct wcd_imped_i_ref R = sdm660_cdc->imped_i_ref;
-	int codec_ver = get_codec_version(sdm660_cdc);
-
-	switch (codec_ver) {
-	case TOMBAK_1_0:
-	case TOMBAK_2_0:
-	case CONGA:
-		if (high) {
-			dev_dbg(codec->dev,
-				"%s: This plug has high range impedance\n",
-				 __func__);
-			rl = (uint32_t)(((100 * (l * 400 - 200))/96) - 230);
-			rr = (uint32_t)(((100 * (r * 400 - 200))/96) - 230);
-		} else {
-			dev_dbg(codec->dev,
-				"%s: This plug has low range impedance\n",
-				 __func__);
-			rl = (uint32_t)(((1000 * (l * 2 - 1))/1165) - (13/10));
-			rr = (uint32_t)(((1000 * (r * 2 - 1))/1165) - (13/10));
-		}
-		break;
-	case CAJON:
-	case CAJON_2_0:
-	case DIANGU:
-	case DRAX_CDC:
-		if (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHL) {
-			rr = (uint32_t)(((DEFAULT_MULTIPLIER * (10 * r - 5)) -
-			   (DEFAULT_OFFSET * DEFAULT_GAIN))/DEFAULT_GAIN);
-			rl = (uint32_t)(((10000 * (R.multiplier * (10 * l - 5)))
-			      - R.offset * R.gain_adj)/(R.gain_adj * 100));
-		} else if (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHR) {
-			rr = (uint32_t)(((10000 * (R.multiplier * (10 * r - 5)))
-			      - R.offset * R.gain_adj)/(R.gain_adj * 100));
-			rl = (uint32_t)(((DEFAULT_MULTIPLIER * (10 * l - 5))-
-			   (DEFAULT_OFFSET * DEFAULT_GAIN))/DEFAULT_GAIN);
-		} else if (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_NONE) {
-			rr = (uint32_t)(((DEFAULT_MULTIPLIER * (10 * r - 5)) -
-			   (DEFAULT_OFFSET * DEFAULT_GAIN))/DEFAULT_GAIN);
-			rl = (uint32_t)(((DEFAULT_MULTIPLIER * (10 * l - 5))-
-			   (DEFAULT_OFFSET * DEFAULT_GAIN))/DEFAULT_GAIN);
-		} else {
-			rr = (uint32_t)(((10000 * (R.multiplier * (10 * r - 5)))
-			      - R.offset * R.gain_adj)/(R.gain_adj * 100));
-			rl = (uint32_t)(((10000 * (R.multiplier * (10 * l - 5)))
-			      - R.offset * R.gain_adj)/(R.gain_adj * 100));
-		}
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: No codec mentioned\n", __func__);
-		break;
-	}
-	*zl = rl;
-	*zr = rr;
-}
-
-static struct firmware_cal *msm_anlg_cdc_get_hwdep_fw_cal(
-		struct wcd_mbhc *wcd_mbhc,
-		enum wcd_cal_type type)
-{
-	struct sdm660_cdc_priv *sdm660_cdc;
-	struct firmware_cal *hwdep_cal;
-	struct snd_soc_codec *codec = wcd_mbhc->codec;
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer\n", __func__);
-		return NULL;
-	}
-	sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-	hwdep_cal = wcdcal_get_fw_cal(sdm660_cdc->fw_data, type);
-	if (!hwdep_cal) {
-		dev_err(codec->dev, "%s: cal not sent by %d\n",
-				__func__, type);
-		return NULL;
-	}
-	return hwdep_cal;
-}
-
-static void wcd9xxx_spmi_irq_control(struct snd_soc_codec *codec,
-				     int irq, bool enable)
-{
-	if (enable)
-		wcd9xxx_spmi_enable_irq(irq);
-	else
-		wcd9xxx_spmi_disable_irq(irq);
-}
-
-static void msm_anlg_cdc_mbhc_clk_setup(struct snd_soc_codec *codec,
-					bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				0x08, 0x08);
-	else
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				0x08, 0x00);
-}
-
-static int msm_anlg_cdc_mbhc_map_btn_code_to_num(struct snd_soc_codec *codec)
-{
-	int btn_code;
-	int btn;
-
-	btn_code = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT);
-
-	switch (btn_code) {
-	case 0:
-		btn = 0;
-		break;
-	case 1:
-		btn = 1;
-		break;
-	case 3:
-		btn = 2;
-		break;
-	case 7:
-		btn = 3;
-		break;
-	case 15:
-		btn = 4;
-		break;
-	default:
-		btn = -EINVAL;
-		break;
-	};
-
-	return btn;
-}
-
-static bool msm_anlg_cdc_spmi_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
-{
-	if (lock)
-		return wcd9xxx_spmi_lock_sleep();
-	wcd9xxx_spmi_unlock_sleep();
-	return 0;
-}
-
-static bool msm_anlg_cdc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
-{
-	if (micb_num == MIC_BIAS_1)
-		return (snd_soc_read(mbhc->codec,
-				     MSM89XX_PMIC_ANALOG_MICB_1_EN) &
-			0x80);
-	if (micb_num == MIC_BIAS_2)
-		return (snd_soc_read(mbhc->codec,
-				     MSM89XX_PMIC_ANALOG_MICB_2_EN) &
-			0x80);
-	return false;
-}
-
-static void msm_anlg_cdc_enable_master_bias(struct snd_soc_codec *codec,
-					    bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL,
-				    0x30, 0x30);
-	else
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL,
-				    0x30, 0x00);
-}
-
-static void msm_anlg_cdc_mbhc_common_micb_ctrl(struct snd_soc_codec *codec,
-					       int event, bool enable)
-{
-	u16 reg;
-	u8 mask;
-	u8 val;
-
-	switch (event) {
-	case MBHC_COMMON_MICB_PRECHARGE:
-		reg = MSM89XX_PMIC_ANALOG_MICB_1_CTL;
-		mask = 0x60;
-		val = (enable ? 0x60 : 0x00);
-		break;
-	case MBHC_COMMON_MICB_SET_VAL:
-		reg = MSM89XX_PMIC_ANALOG_MICB_1_VAL;
-		mask = 0xFF;
-		val = (enable ? 0xC0 : 0x00);
-		break;
-	case MBHC_COMMON_MICB_TAIL_CURR:
-		reg = MSM89XX_PMIC_ANALOG_MICB_1_EN;
-		mask = 0x04;
-		val = (enable ? 0x04 : 0x00);
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: Invalid event received\n", __func__);
-		return;
-	};
-	snd_soc_update_bits(codec, reg, mask, val);
-}
-
-static void msm_anlg_cdc_mbhc_internal_micbias_ctrl(struct snd_soc_codec *codec,
-						    int micbias_num,
-						    bool enable)
-{
-	if (micbias_num == 1) {
-		if (enable)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS,
-				0x10, 0x10);
-		else
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS,
-				0x10, 0x00);
-	}
-}
-
-static bool msm_anlg_cdc_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
-{
-	return (snd_soc_read(codec, MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN) &
-		0x30) ? true : false;
-}
-
-static void msm_anlg_cdc_mbhc_program_btn_thr(struct snd_soc_codec *codec,
-					      s16 *btn_low, s16 *btn_high,
-					      int num_btn, bool is_micbias)
-{
-	int i;
-	u32 course, fine, reg_val;
-	u16 reg_addr = MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL;
-	s16 *btn_voltage;
-
-	btn_voltage = ((is_micbias) ? btn_high : btn_low);
-
-	for (i = 0; i <  num_btn; i++) {
-		course = (btn_voltage[i] / SDM660_CDC_MBHC_BTN_COARSE_ADJ);
-		fine = ((btn_voltage[i] % SDM660_CDC_MBHC_BTN_COARSE_ADJ) /
-				SDM660_CDC_MBHC_BTN_FINE_ADJ);
-
-		reg_val = (course << 5) | (fine << 2);
-		snd_soc_update_bits(codec, reg_addr, 0xFC, reg_val);
-		dev_dbg(codec->dev,
-			"%s: course: %d fine: %d reg_addr: %x reg_val: %x\n",
-			  __func__, course, fine, reg_addr, reg_val);
-		reg_addr++;
-	}
-}
-
-static void msm_anlg_cdc_mbhc_calc_impedance(struct wcd_mbhc *mbhc,
-					     uint32_t *zl, uint32_t *zr)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	s16 impedance_l, impedance_r;
-	s16 impedance_l_fixed;
-	s16 reg0, reg1, reg2, reg3, reg4;
-	bool high = false;
-	bool min_range_used =  false;
-
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-	reg0 = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER);
-	reg1 = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL);
-	reg2 = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2);
-	reg3 = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MICB_2_EN);
-	reg4 = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL);
-
-	sdm660_cdc->imped_det_pin = WCD_MBHC_DET_BOTH;
-	mbhc->hph_type = WCD_MBHC_HPH_NONE;
-
-	/* disable FSM and micbias and enable pullup*/
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x80, 0x00);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_2_EN,
-			0xA5, 0x25);
-	/*
-	 * Enable legacy electrical detection current sources
-	 * and disable fast ramp and enable manual switching
-	 * of extra capacitance
-	 */
-	dev_dbg(codec->dev, "%s: Setup for impedance det\n", __func__);
-
-	msm_anlg_cdc_set_ref_current(codec, I_h4_UA);
-
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2,
-			0x06, 0x02);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER,
-			0x02, 0x02);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL,
-			0x02, 0x00);
-
-	dev_dbg(codec->dev, "%s: Start performing impedance detection\n",
-		 __func__);
-
-	wcd_mbhc_meas_imped(codec, &impedance_l, &impedance_r);
-
-	if (impedance_l > 2 || impedance_r > 2) {
-		high = true;
-		if (!mbhc->mbhc_cfg->mono_stero_detection) {
-			/* Set ZDET_CHG to 0  to discharge ramp */
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-					0x02, 0x00);
-			/* wait 40ms for the discharge ramp to complete */
-			usleep_range(40000, 40100);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-				0x03, 0x00);
-			sdm660_cdc->imped_det_pin = (impedance_l > 2 &&
-						      impedance_r > 2) ?
-						      WCD_MBHC_DET_NONE :
-						      ((impedance_l > 2) ?
-						      WCD_MBHC_DET_HPHR :
-						      WCD_MBHC_DET_HPHL);
-			if (sdm660_cdc->imped_det_pin == WCD_MBHC_DET_NONE)
-				goto exit;
-		} else {
-			if (get_codec_version(sdm660_cdc) >= CAJON) {
-				if (impedance_l == 63 && impedance_r == 63) {
-					dev_dbg(codec->dev,
-						"%s: HPHL and HPHR are floating\n",
-						 __func__);
-					sdm660_cdc->imped_det_pin =
-							WCD_MBHC_DET_NONE;
-					mbhc->hph_type = WCD_MBHC_HPH_NONE;
-				} else if (impedance_l == 63
-					   && impedance_r < 63) {
-					dev_dbg(codec->dev,
-						"%s: Mono HS with HPHL floating\n",
-						 __func__);
-					sdm660_cdc->imped_det_pin =
-							WCD_MBHC_DET_HPHR;
-					mbhc->hph_type = WCD_MBHC_HPH_MONO;
-				} else if (impedance_r == 63 &&
-					   impedance_l < 63) {
-					dev_dbg(codec->dev,
-						"%s: Mono HS with HPHR floating\n",
-						 __func__);
-					sdm660_cdc->imped_det_pin =
-							WCD_MBHC_DET_HPHL;
-					mbhc->hph_type = WCD_MBHC_HPH_MONO;
-				} else if (impedance_l > 3 && impedance_r > 3 &&
-					(impedance_l == impedance_r)) {
-					snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2,
-					0x06, 0x06);
-					wcd_mbhc_meas_imped(codec, &impedance_l,
-							    &impedance_r);
-					if (impedance_r == impedance_l)
-						dev_dbg(codec->dev,
-							"%s: Mono Headset\n",
-							__func__);
-						sdm660_cdc->imped_det_pin =
-							WCD_MBHC_DET_NONE;
-						mbhc->hph_type =
-							WCD_MBHC_HPH_MONO;
-				} else {
-					dev_dbg(codec->dev,
-						"%s: STEREO headset is found\n",
-						 __func__);
-					sdm660_cdc->imped_det_pin =
-							WCD_MBHC_DET_BOTH;
-					mbhc->hph_type = WCD_MBHC_HPH_STEREO;
-				}
-			}
-		}
-	}
-
-	msm_anlg_cdc_set_ref_current(codec, I_pt5_UA);
-	msm_anlg_cdc_set_ref_current(codec, I_14_UA);
-
-	/* Enable RAMP_L , RAMP_R & ZDET_CHG*/
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-			0x03, 0x03);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x02, 0x02);
-	/* wait for 50msec for the HW to apply ramp on HPHL and HPHR */
-	usleep_range(50000, 50100);
-	/* Enable ZDET_DISCHG_CAP_CTL  to add extra capacitance */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x01, 0x01);
-	/* wait for 5msec for the voltage to get stable */
-	usleep_range(5000, 5100);
-
-	wcd_mbhc_meas_imped(codec, &impedance_l, &impedance_r);
-
-	min_range_used = msm_anlg_cdc_adj_ref_current(codec,
-						&impedance_l, &impedance_r);
-	if (!mbhc->mbhc_cfg->mono_stero_detection) {
-		/* Set ZDET_CHG to 0  to discharge ramp */
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-				0x02, 0x00);
-		/* wait for 40msec for the capacitor to discharge */
-		usleep_range(40000, 40100);
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-				0x03, 0x00);
-		goto exit;
-	}
-
-	/* we are setting ref current to the minimun range or the measured
-	 * value larger than the minimum value, so min_range_used is true.
-	 * If the headset is mono headset with either HPHL or HPHR floating
-	 * then we have already done the mono stereo detection and do not
-	 * need to continue further.
-	 */
-
-	if (!min_range_used ||
-	    sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHL ||
-	    sdm660_cdc->imped_det_pin == WCD_MBHC_DET_HPHR)
-		goto exit;
-
-
-	/* Disable Set ZDET_CONN_RAMP_L and enable ZDET_CONN_FIXED_L */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-			0x02, 0x00);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN1_ZDETM_CTL,
-			0x02, 0x02);
-	/* Set ZDET_CHG to 0  */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x02, 0x00);
-	/* wait for 40msec for the capacitor to discharge */
-	usleep_range(40000, 40100);
-
-	/* Set ZDET_CONN_RAMP_R to 0  */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-			0x01, 0x00);
-	/* Enable ZDET_L_MEAS_EN */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x08, 0x08);
-	/* wait for 2msec for the HW to compute left inpedance value */
-	usleep_range(2000, 2100);
-	/* Read Left impedance value from Result1 */
-	impedance_l_fixed = snd_soc_read(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT);
-	/* Disable ZDET_L_MEAS_EN */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x08, 0x00);
-	/*
-	 * Assume impedance_l is L1, impedance_l_fixed is L2.
-	 * If the following condition is met, we can take this
-	 * headset as mono one with impedance of L2.
-	 * Otherwise, take it as stereo with impedance of L1.
-	 * Condition:
-	 * abs[(L2-0.5L1)/(L2+0.5L1)] < abs [(L2-L1)/(L2+L1)]
-	 */
-	if ((abs(impedance_l_fixed - impedance_l/2) *
-		(impedance_l_fixed + impedance_l)) >=
-		(abs(impedance_l_fixed - impedance_l) *
-		(impedance_l_fixed + impedance_l/2))) {
-		dev_dbg(codec->dev,
-			"%s: STEREO plug type detected\n",
-			 __func__);
-		mbhc->hph_type = WCD_MBHC_HPH_STEREO;
-	} else {
-		dev_dbg(codec->dev,
-			"%s: MONO plug type detected\n",
-			__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_MONO;
-		impedance_l = impedance_l_fixed;
-	}
-	/* Enable ZDET_CHG  */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x02, 0x02);
-	/* wait for 10msec for the capacitor to charge */
-	usleep_range(10000, 10100);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-			0x02, 0x02);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN1_ZDETM_CTL,
-			0x02, 0x00);
-	/* Set ZDET_CHG to 0  to discharge HPHL */
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL,
-			0x02, 0x00);
-	/* wait for 40msec for the capacitor to discharge */
-	usleep_range(40000, 40100);
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL,
-			0x02, 0x00);
-
-exit:
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL, reg4);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MICB_2_EN, reg3);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL, reg1);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER, reg0);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, reg2);
-	msm_anlg_cdc_compute_impedance(codec, impedance_l, impedance_r,
-				      zl, zr, high);
-
-	dev_dbg(codec->dev, "%s: RL %d ohm, RR %d ohm\n", __func__, *zl, *zr);
-	dev_dbg(codec->dev, "%s: Impedance detection completed\n", __func__);
-}
-
-static int msm_anlg_cdc_dig_register_notifier(void *handle,
-					      struct notifier_block *nblock,
-					      bool enable)
-{
-	struct sdm660_cdc_priv *handle_cdc = handle;
-
-	if (enable)
-		return blocking_notifier_chain_register(&handle_cdc->notifier,
-							nblock);
-
-	return blocking_notifier_chain_unregister(&handle_cdc->notifier,
-						  nblock);
-}
-
-static int msm_anlg_cdc_mbhc_register_notifier(struct wcd_mbhc *wcd_mbhc,
-					       struct notifier_block *nblock,
-					       bool enable)
-{
-	struct snd_soc_codec *codec = wcd_mbhc->codec;
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (enable)
-		return blocking_notifier_chain_register(
-						&sdm660_cdc->notifier_mbhc,
-						nblock);
-
-	return blocking_notifier_chain_unregister(&sdm660_cdc->notifier_mbhc,
-						  nblock);
-}
-
-static int msm_anlg_cdc_request_irq(struct snd_soc_codec *codec,
-				    int irq, irq_handler_t handler,
-				    const char *name, void *data)
-{
-	return wcd9xxx_spmi_request_irq(irq, handler, name, data);
-}
-
-static int msm_anlg_cdc_free_irq(struct snd_soc_codec *codec,
-				 int irq, void *data)
-{
-	return wcd9xxx_spmi_free_irq(irq, data);
-}
-
-static const struct wcd_mbhc_cb mbhc_cb = {
-	.enable_mb_source = msm_anlg_cdc_enable_ext_mb_source,
-	.trim_btn_reg = msm_anlg_cdc_trim_btn_reg,
-	.compute_impedance = msm_anlg_cdc_mbhc_calc_impedance,
-	.set_micbias_value = msm_anlg_cdc_set_micb_v,
-	.set_auto_zeroing = msm_anlg_cdc_set_auto_zeroing,
-	.get_hwdep_fw_cal = msm_anlg_cdc_get_hwdep_fw_cal,
-	.set_cap_mode = msm_anlg_cdc_configure_cap,
-	.register_notifier = msm_anlg_cdc_mbhc_register_notifier,
-	.request_irq = msm_anlg_cdc_request_irq,
-	.irq_control = wcd9xxx_spmi_irq_control,
-	.free_irq = msm_anlg_cdc_free_irq,
-	.clk_setup = msm_anlg_cdc_mbhc_clk_setup,
-	.map_btn_code_to_num = msm_anlg_cdc_mbhc_map_btn_code_to_num,
-	.lock_sleep = msm_anlg_cdc_spmi_lock_sleep,
-	.micbias_enable_status = msm_anlg_cdc_micb_en_status,
-	.mbhc_bias = msm_anlg_cdc_enable_master_bias,
-	.mbhc_common_micb_ctrl = msm_anlg_cdc_mbhc_common_micb_ctrl,
-	.micb_internal = msm_anlg_cdc_mbhc_internal_micbias_ctrl,
-	.hph_pa_on_status = msm_anlg_cdc_mbhc_hph_pa_on_status,
-	.set_btn_thr = msm_anlg_cdc_mbhc_program_btn_thr,
-	.extn_use_mb = msm_anlg_cdc_use_mb,
-};
-
-static const uint32_t wcd_imped_val[] = {4, 8, 12, 13, 16,
-					20, 24, 28, 32,
-					36, 40, 44, 48};
-
-static void msm_anlg_cdc_dig_notifier_call(struct snd_soc_codec *codec,
-					const enum dig_cdc_notify_event event)
-{
-	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-
-	pr_debug("%s: notifier call event %d\n", __func__, event);
-	blocking_notifier_call_chain(&sdm660_cdc->notifier,
-				     event, NULL);
-}
-
-static void msm_anlg_cdc_notifier_call(struct snd_soc_codec *codec,
-				       const enum wcd_notify_event event)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: notifier call event %d\n", __func__, event);
-	blocking_notifier_call_chain(&sdm660_cdc->notifier_mbhc, event,
-				     &sdm660_cdc->mbhc);
-}
-
-static void msm_anlg_cdc_boost_on(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x0F, 0x0F);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0xA5);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x0F);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL, 0x30);
-	if (get_codec_version(sdm660_cdc) < CAJON_2_0)
-		snd_soc_write(codec, MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0x82);
-	else
-		snd_soc_write(codec, MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0xA2);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-			    0x69, 0x69);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG,
-			    0x01, 0x01);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SLOPE_COMP_IP_ZERO,
-			    0x88, 0x88);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL,
-			    0x03, 0x03);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL,
-			    0xE1, 0xE1);
-	if (get_codec_version(sdm660_cdc) < CAJON_2_0) {
-		snd_soc_update_bits(codec, MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				    0x20, 0x20);
-		/* Wait for 1ms after clock ctl enable */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-				    0xDF, 0xDF);
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-	} else {
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-				    0x40, 0x00);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				    0x20, 0x20);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-				    0x80, 0x80);
-		/* Wait for 500us after BOOST_EN to happen */
-		usleep_range(500, 510);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-				    0x40, 0x40);
-		/* Wait for 500us after BOOST pulse_skip */
-		usleep_range(500, 510);
-	}
-}
-
-static void msm_anlg_cdc_boost_off(struct snd_soc_codec *codec)
-{
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-			    0xDF, 0x5F);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			    0x20, 0x00);
-}
-
-static void msm_anlg_cdc_bypass_on(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) < CAJON_2_0) {
-		snd_soc_write(codec,
-			MSM89XX_PMIC_ANALOG_SEC_ACCESS,
-			0xA5);
-		snd_soc_write(codec,
-			MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3,
-			0x07);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x02, 0x02);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x01, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x40, 0x40);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x80, 0x80);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-			0xDF, 0xDF);
-	} else {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			0x20, 0x20);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x20, 0x20);
-	}
-}
-
-static void msm_anlg_cdc_bypass_off(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) < CAJON_2_0) {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BOOST_EN_CTL,
-			0x80, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x80, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x02, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x40, 0x00);
-	} else {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_BYPASS_MODE,
-			0x20, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			0x20, 0x00);
-	}
-}
-
-static void msm_anlg_cdc_boost_mode_sequence(struct snd_soc_codec *codec,
-					     int flag)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (flag == EAR_PMU) {
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->ear_pa_boost_set) {
-				msm_anlg_cdc_boost_off(codec);
-				msm_anlg_cdc_bypass_on(codec);
-			}
-			break;
-		case BOOST_ALWAYS:
-			msm_anlg_cdc_boost_on(codec);
-			break;
-		case BYPASS_ALWAYS:
-			msm_anlg_cdc_bypass_on(codec);
-			break;
-		case BOOST_ON_FOREVER:
-			msm_anlg_cdc_boost_on(codec);
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-	} else if (flag == EAR_PMD) {
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->ear_pa_boost_set)
-				msm_anlg_cdc_bypass_off(codec);
-			break;
-		case BOOST_ALWAYS:
-			msm_anlg_cdc_boost_off(codec);
-			/* 80ms for EAR boost to settle down */
-			msleep(80);
-			break;
-		case BYPASS_ALWAYS:
-			/* nothing to do as bypass on always */
-			break;
-		case BOOST_ON_FOREVER:
-			/* nothing to do as boost on forever */
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-	} else if (flag == SPK_PMU) {
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->spk_boost_set) {
-				msm_anlg_cdc_bypass_off(codec);
-				msm_anlg_cdc_boost_on(codec);
-			}
-			break;
-		case BOOST_ALWAYS:
-			msm_anlg_cdc_boost_on(codec);
-			break;
-		case BYPASS_ALWAYS:
-			msm_anlg_cdc_bypass_on(codec);
-			break;
-		case BOOST_ON_FOREVER:
-			msm_anlg_cdc_boost_on(codec);
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-	} else if (flag == SPK_PMD) {
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->spk_boost_set) {
-				msm_anlg_cdc_boost_off(codec);
-				/*
-				 * Add 40 ms sleep for the spk
-				 * boost to settle down
-				 */
-				msleep(40);
-			}
-			break;
-		case BOOST_ALWAYS:
-			msm_anlg_cdc_boost_off(codec);
-			/*
-			 * Add 40 ms sleep for the spk
-			 * boost to settle down
-			 */
-			msleep(40);
-			break;
-		case BYPASS_ALWAYS:
-			/* nothing to do as bypass on always */
-			break;
-		case BOOST_ON_FOREVER:
-			/* nothing to do as boost on forever */
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-	}
-}
-
-static int msm_anlg_cdc_dt_parse_vreg_info(struct device *dev,
-	struct sdm660_cdc_regulator *vreg, const char *vreg_name,
-	bool ondemand)
-{
-	int len, ret = 0;
-	const __be32 *prop;
-	char prop_name[CODEC_DT_MAX_PROP_SIZE];
-	struct device_node *regnode = NULL;
-	u32 prop_val;
-
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE, "%s-supply",
-		vreg_name);
-	regnode = of_parse_phandle(dev->of_node, prop_name, 0);
-
-	if (!regnode) {
-		dev_err(dev, "Looking up %s property in node %s failed\n",
-			prop_name, dev->of_node->full_name);
-		return -ENODEV;
-	}
-
-	dev_dbg(dev, "Looking up %s property in node %s\n",
-		prop_name, dev->of_node->full_name);
-
-	vreg->name = vreg_name;
-	vreg->ondemand = ondemand;
-
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE,
-		"qcom,%s-voltage", vreg_name);
-	prop = of_get_property(dev->of_node, prop_name, &len);
-
-	if (!prop || (len != (2 * sizeof(__be32)))) {
-		dev_err(dev, "%s %s property\n",
-			prop ? "invalid format" : "no", prop_name);
-		return -EINVAL;
-	}
-	vreg->min_uv = be32_to_cpup(&prop[0]);
-	vreg->max_uv = be32_to_cpup(&prop[1]);
-
-	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE,
-		"qcom,%s-current", vreg_name);
-
-	ret = of_property_read_u32(dev->of_node, prop_name, &prop_val);
-	if (ret) {
-		dev_err(dev, "Looking up %s property in node %s failed",
-			prop_name, dev->of_node->full_name);
-		return -EFAULT;
-	}
-	vreg->optimum_ua = prop_val;
-
-	dev_dbg(dev, "%s: vol=[%d %d]uV, curr=[%d]uA, ond %d\n\n", vreg->name,
-		 vreg->min_uv, vreg->max_uv, vreg->optimum_ua, vreg->ondemand);
-	return 0;
-}
-
-static void msm_anlg_cdc_dt_parse_boost_info(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-		snd_soc_codec_get_drvdata(codec);
-	const char *prop_name = "qcom,cdc-boost-voltage";
-	int boost_voltage, ret;
-
-	ret = of_property_read_u32(codec->dev->of_node, prop_name,
-			&boost_voltage);
-	if (ret) {
-		dev_dbg(codec->dev, "Looking up %s property in node %s failed\n",
-			prop_name, codec->dev->of_node->full_name);
-		boost_voltage = DEFAULT_BOOST_VOLTAGE;
-	}
-	if (boost_voltage < MIN_BOOST_VOLTAGE ||
-			boost_voltage > MAX_BOOST_VOLTAGE) {
-		dev_err(codec->dev,
-				"Incorrect boost voltage. Reverting to default\n");
-		boost_voltage = DEFAULT_BOOST_VOLTAGE;
-	}
-
-	sdm660_cdc_priv->boost_voltage =
-		VOLTAGE_CONVERTER(boost_voltage, MIN_BOOST_VOLTAGE,
-				BOOST_VOLTAGE_STEP);
-	dev_dbg(codec->dev, "Boost voltage value is: %d\n",
-			boost_voltage);
-}
-
-static void msm_anlg_cdc_dt_parse_micbias_info(struct device *dev,
-				struct wcd_micbias_setting *micbias)
-{
-	const char *prop_name = "qcom,cdc-micbias-cfilt-mv";
-	int ret;
-
-	ret = of_property_read_u32(dev->of_node, prop_name,
-			&micbias->cfilt1_mv);
-	if (ret) {
-		dev_dbg(dev, "Looking up %s property in node %s failed",
-			prop_name, dev->of_node->full_name);
-		micbias->cfilt1_mv = MICBIAS_DEFAULT_VAL;
-	}
-}
-
-static struct sdm660_cdc_pdata *msm_anlg_cdc_populate_dt_pdata(
-						struct device *dev)
-{
-	struct sdm660_cdc_pdata *pdata;
-	int ret, static_cnt, ond_cnt, idx, i;
-	const char *name = NULL;
-	const char *static_prop_name = "qcom,cdc-static-supplies";
-	const char *ond_prop_name = "qcom,cdc-on-demand-supplies";
-
-	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return NULL;
-
-	static_cnt = of_property_count_strings(dev->of_node, static_prop_name);
-	if (static_cnt < 0) {
-		dev_err(dev, "%s: Failed to get static supplies %d\n", __func__,
-			static_cnt);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	/* On-demand supply list is an optional property */
-	ond_cnt = of_property_count_strings(dev->of_node, ond_prop_name);
-	if (ond_cnt < 0)
-		ond_cnt = 0;
-
-	WARN_ON(static_cnt <= 0 || ond_cnt < 0);
-	if ((static_cnt + ond_cnt) > ARRAY_SIZE(pdata->regulator)) {
-		dev_err(dev, "%s: Num of supplies %u > max supported %zd\n",
-				__func__, (static_cnt + ond_cnt),
-					ARRAY_SIZE(pdata->regulator));
-		ret = -EINVAL;
-		goto err;
-	}
-
-	for (idx = 0; idx < static_cnt; idx++) {
-		ret = of_property_read_string_index(dev->of_node,
-						    static_prop_name, idx,
-						    &name);
-		if (ret) {
-			dev_err(dev, "%s: of read string %s idx %d error %d\n",
-				__func__, static_prop_name, idx, ret);
-			goto err;
-		}
-
-		dev_dbg(dev, "%s: Found static cdc supply %s\n", __func__,
-			name);
-		ret = msm_anlg_cdc_dt_parse_vreg_info(dev,
-						&pdata->regulator[idx],
-						name, false);
-		if (ret) {
-			dev_err(dev, "%s:err parsing vreg for %s idx %d\n",
-				__func__, name, idx);
-			goto err;
-		}
-	}
-
-	for (i = 0; i < ond_cnt; i++, idx++) {
-		ret = of_property_read_string_index(dev->of_node, ond_prop_name,
-						    i, &name);
-		if (ret) {
-			dev_err(dev, "%s: err parsing on_demand for %s idx %d\n",
-				__func__, ond_prop_name, i);
-			goto err;
-		}
-
-		dev_dbg(dev, "%s: Found on-demand cdc supply %s\n", __func__,
-			name);
-		ret = msm_anlg_cdc_dt_parse_vreg_info(dev,
-						&pdata->regulator[idx],
-						name, true);
-		if (ret) {
-			dev_err(dev, "%s: err parsing vreg on_demand for %s idx %d\n",
-				__func__, name, idx);
-			goto err;
-		}
-	}
-	msm_anlg_cdc_dt_parse_micbias_info(dev, &pdata->micbias);
-
-	return pdata;
-err:
-	devm_kfree(dev, pdata);
-	dev_err(dev, "%s: Failed to populate DT data ret = %d\n",
-		__func__, ret);
-	return NULL;
-}
-
-static int msm_anlg_cdc_codec_enable_on_demand_supply(
-		struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	struct on_demand_supply *supply;
-
-	if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
-		dev_err(codec->dev, "%s: error index > MAX Demand supplies",
-			__func__);
-		ret = -EINVAL;
-		goto out;
-	}
-	dev_dbg(codec->dev, "%s: supply: %s event: %d ref: %d\n",
-		__func__, on_demand_supply_name[w->shift], event,
-		atomic_read(&sdm660_cdc->on_demand_list[w->shift].ref));
-
-	supply = &sdm660_cdc->on_demand_list[w->shift];
-	WARN_ONCE(!supply->supply, "%s isn't defined\n",
-		  on_demand_supply_name[w->shift]);
-	if (!supply->supply) {
-		dev_err(codec->dev, "%s: err supply not present ond for %d",
-			__func__, w->shift);
-		goto out;
-	}
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (atomic_inc_return(&supply->ref) == 1) {
-			ret = regulator_set_voltage(supply->supply,
-						    supply->min_uv,
-						    supply->max_uv);
-			if (ret) {
-				dev_err(codec->dev,
-					"Setting regulator voltage(en) for micbias with err = %d\n",
-					ret);
-				goto out;
-			}
-			ret = regulator_set_load(supply->supply,
-						 supply->optimum_ua);
-			if (ret < 0) {
-				dev_err(codec->dev,
-					"Setting regulator optimum mode(en) failed for micbias with err = %d\n",
-					ret);
-				goto out;
-			}
-			ret = regulator_enable(supply->supply);
-		}
-		if (ret)
-			dev_err(codec->dev, "%s: Failed to enable %s\n",
-				__func__,
-				on_demand_supply_name[w->shift]);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (atomic_read(&supply->ref) == 0) {
-			dev_dbg(codec->dev, "%s: %s supply has been disabled.\n",
-				 __func__, on_demand_supply_name[w->shift]);
-			goto out;
-		}
-		if (atomic_dec_return(&supply->ref) == 0) {
-			ret = regulator_disable(supply->supply);
-			if (ret)
-				dev_err(codec->dev, "%s: Failed to disable %s\n",
-					__func__,
-					on_demand_supply_name[w->shift]);
-			ret = regulator_set_voltage(supply->supply,
-						    0,
-						    supply->max_uv);
-			if (ret) {
-				dev_err(codec->dev,
-					"Setting regulator voltage(dis) failed for micbias with err = %d\n",
-					ret);
-				goto out;
-			}
-			ret = regulator_set_load(supply->supply, 0);
-			if (ret < 0)
-				dev_err(codec->dev,
-					"Setting regulator optimum mode(dis) failed for micbias with err = %d\n",
-					ret);
-		}
-		break;
-	default:
-		break;
-	}
-out:
-	return ret;
-}
-
-static int msm_anlg_cdc_codec_enable_clock_block(struct snd_soc_codec *codec,
-						 int enable)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	if (enable) {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL, 0x30, 0x30);
-		msm_anlg_cdc_dig_notifier_call(codec, DIG_CDC_EVENT_CLK_ON);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80, 0x80);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL, 0x0C, 0x0C);
-	} else {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL, 0x0C, 0x00);
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_codec_enable_charge_pump(struct snd_soc_dapm_widget *w,
-						 struct snd_kcontrol *kcontrol,
-						 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		msm_anlg_cdc_codec_enable_clock_block(codec, 1);
-		if (!(strcmp(w->name, "EAR CP"))) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x80, 0x80);
-			msm_anlg_cdc_boost_mode_sequence(codec, EAR_PMU);
-		} else if (get_codec_version(sdm660_cdc) >= DIANGU) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x80, 0x80);
-		} else {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0xC0, 0xC0);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* Wait for 1ms post powerup of chargepump */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* Wait for 1ms post powerdown of chargepump */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		if (!(strcmp(w->name, "EAR CP"))) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x80, 0x00);
-			if (sdm660_cdc->boost_option != BOOST_ALWAYS) {
-				dev_dbg(codec->dev,
-					"%s: boost_option:%d, tear down ear\n",
-					__func__, sdm660_cdc->boost_option);
-				msm_anlg_cdc_boost_mode_sequence(codec,
-								 EAR_PMD);
-			}
-			/*
-			 * Reset pa select bit from ear to hph after ear pa
-			 * is disabled and HPH DAC disable to reduce ear
-			 * turn off pop and avoid HPH pop in concurrency
-			 */
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_EAR_CTL, 0x80, 0x00);
-		} else {
-			if (get_codec_version(sdm660_cdc) < DIANGU)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x40, 0x00);
-			if (sdm660_cdc->rx_bias_count == 0)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x80, 0x00);
-			dev_dbg(codec->dev, "%s: rx_bias_count = %d\n",
-					__func__, sdm660_cdc->rx_bias_count);
-		}
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_ear_pa_boost_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] =
-		(sdm660_cdc->ear_pa_boost_set ? 1 : 0);
-	dev_dbg(codec->dev, "%s: sdm660_cdc->ear_pa_boost_set = %d\n",
-			__func__, sdm660_cdc->ear_pa_boost_set);
-	return 0;
-}
-
-static int msm_anlg_cdc_ear_pa_boost_set(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-	sdm660_cdc->ear_pa_boost_set =
-		(ucontrol->value.integer.value[0] ? true : false);
-	return 0;
-}
-
-static int msm_anlg_cdc_loopback_mode_get(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	return pdata->lb_mode;
-}
-
-static int msm_anlg_cdc_loopback_mode_put(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		pdata->lb_mode = false;
-		break;
-	case 1:
-		pdata->lb_mode = true;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_anlg_cdc_pa_gain_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) >= DIANGU) {
-		ear_pa_gain = snd_soc_read(codec,
-					MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC);
-		ear_pa_gain = (ear_pa_gain >> 1) & 0x3;
-
-		if (ear_pa_gain == 0x00) {
-			ucontrol->value.integer.value[0] = 3;
-		} else if (ear_pa_gain == 0x01) {
-			ucontrol->value.integer.value[1] = 2;
-		} else if (ear_pa_gain == 0x02) {
-			ucontrol->value.integer.value[2] = 1;
-		} else if (ear_pa_gain == 0x03) {
-			ucontrol->value.integer.value[3] = 0;
-		} else {
-			dev_err(codec->dev,
-				"%s: ERROR: Unsupported Ear Gain = 0x%x\n",
-				__func__, ear_pa_gain);
-			return -EINVAL;
-		}
-	} else {
-		ear_pa_gain = snd_soc_read(codec,
-					   MSM89XX_PMIC_ANALOG_RX_EAR_CTL);
-		ear_pa_gain = (ear_pa_gain >> 5) & 0x1;
-		if (ear_pa_gain == 0x00) {
-			ucontrol->value.integer.value[0] = 0;
-		} else if (ear_pa_gain == 0x01) {
-			ucontrol->value.integer.value[0] = 3;
-		} else  {
-			dev_err(codec->dev,
-				"%s: ERROR: Unsupported Ear Gain = 0x%x\n",
-				__func__, ear_pa_gain);
-			return -EINVAL;
-		}
-	}
-	ucontrol->value.integer.value[0] = ear_pa_gain;
-	dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain);
-	return 0;
-}
-
-static int msm_anlg_cdc_pa_gain_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	if (get_codec_version(sdm660_cdc) >= DIANGU) {
-		switch (ucontrol->value.integer.value[0]) {
-		case 0:
-			ear_pa_gain = 0x06;
-			break;
-		case 1:
-			ear_pa_gain = 0x04;
-			break;
-		case 2:
-			ear_pa_gain = 0x02;
-			break;
-		case 3:
-			ear_pa_gain = 0x00;
-			break;
-		default:
-			return -EINVAL;
-		}
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-			    0x06, ear_pa_gain);
-	} else {
-		switch (ucontrol->value.integer.value[0]) {
-		case 0:
-			ear_pa_gain = 0x00;
-			break;
-		case 3:
-			ear_pa_gain = 0x20;
-			break;
-		case 1:
-		case 2:
-		default:
-			return -EINVAL;
-		}
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-			    0x20, ear_pa_gain);
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_hph_mode_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (sdm660_cdc->hph_mode == NORMAL_MODE) {
-		ucontrol->value.integer.value[0] = 0;
-	} else if (sdm660_cdc->hph_mode == HD2_MODE) {
-		ucontrol->value.integer.value[0] = 1;
-	} else  {
-		dev_err(codec->dev, "%s: ERROR: Default HPH Mode= %d\n",
-			__func__, sdm660_cdc->hph_mode);
-	}
-
-	dev_dbg(codec->dev, "%s: sdm660_cdc->hph_mode = %d\n", __func__,
-			sdm660_cdc->hph_mode);
-	return 0;
-}
-
-static int msm_anlg_cdc_hph_mode_set(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		sdm660_cdc->hph_mode = NORMAL_MODE;
-		break;
-	case 1:
-		if (get_codec_version(sdm660_cdc) >= DIANGU)
-			sdm660_cdc->hph_mode = HD2_MODE;
-		break;
-	default:
-		sdm660_cdc->hph_mode = NORMAL_MODE;
-		break;
-	}
-	dev_dbg(codec->dev, "%s: sdm660_cdc->hph_mode_set = %d\n",
-		__func__, sdm660_cdc->hph_mode);
-	return 0;
-}
-
-static int msm_anlg_cdc_boost_option_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (sdm660_cdc->boost_option == BOOST_SWITCH) {
-		ucontrol->value.integer.value[0] = 0;
-	} else if (sdm660_cdc->boost_option == BOOST_ALWAYS) {
-		ucontrol->value.integer.value[0] = 1;
-	} else if (sdm660_cdc->boost_option == BYPASS_ALWAYS) {
-		ucontrol->value.integer.value[0] = 2;
-	} else if (sdm660_cdc->boost_option == BOOST_ON_FOREVER) {
-		ucontrol->value.integer.value[0] = 3;
-	} else  {
-		dev_err(codec->dev, "%s: ERROR: Unsupported Boost option= %d\n",
-			__func__, sdm660_cdc->boost_option);
-		return -EINVAL;
-	}
-
-	dev_dbg(codec->dev, "%s: sdm660_cdc->boost_option = %d\n", __func__,
-			sdm660_cdc->boost_option);
-	return 0;
-}
-
-static int msm_anlg_cdc_boost_option_set(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		sdm660_cdc->boost_option = BOOST_SWITCH;
-		break;
-	case 1:
-		sdm660_cdc->boost_option = BOOST_ALWAYS;
-		break;
-	case 2:
-		sdm660_cdc->boost_option = BYPASS_ALWAYS;
-		msm_anlg_cdc_bypass_on(codec);
-		break;
-	case 3:
-		sdm660_cdc->boost_option = BOOST_ON_FOREVER;
-		msm_anlg_cdc_boost_on(codec);
-		break;
-	default:
-		pr_err("%s: invalid boost option: %d\n", __func__,
-					sdm660_cdc->boost_option);
-		return -EINVAL;
-	}
-	dev_dbg(codec->dev, "%s: sdm660_cdc->boost_option_set = %d\n",
-		__func__, sdm660_cdc->boost_option);
-	return 0;
-}
-
-static int msm_anlg_cdc_spk_boost_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (sdm660_cdc->spk_boost_set == false) {
-		ucontrol->value.integer.value[0] = 0;
-	} else if (sdm660_cdc->spk_boost_set == true) {
-		ucontrol->value.integer.value[0] = 1;
-	} else  {
-		dev_err(codec->dev, "%s: ERROR: Unsupported Speaker Boost = %d\n",
-				__func__, sdm660_cdc->spk_boost_set);
-		return -EINVAL;
-	}
-
-	dev_dbg(codec->dev, "%s: sdm660_cdc->spk_boost_set = %d\n", __func__,
-			sdm660_cdc->spk_boost_set);
-	return 0;
-}
-
-static int msm_anlg_cdc_spk_boost_set(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-			__func__, ucontrol->value.integer.value[0]);
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		sdm660_cdc->spk_boost_set = false;
-		break;
-	case 1:
-		sdm660_cdc->spk_boost_set = true;
-		break;
-	default:
-		return -EINVAL;
-	}
-	dev_dbg(codec->dev, "%s: sdm660_cdc->spk_boost_set = %d\n",
-		__func__, sdm660_cdc->spk_boost_set);
-	return 0;
-}
-
-static int msm_anlg_cdc_ext_spk_boost_get(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (sdm660_cdc->ext_spk_boost_set == false)
-		ucontrol->value.integer.value[0] = 0;
-	else
-		ucontrol->value.integer.value[0] = 1;
-
-	dev_dbg(codec->dev, "%s: sdm660_cdc->ext_spk_boost_set = %d\n",
-				__func__, sdm660_cdc->ext_spk_boost_set);
-	return 0;
-}
-
-static int msm_anlg_cdc_ext_spk_boost_set(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		sdm660_cdc->ext_spk_boost_set = false;
-		break;
-	case 1:
-		sdm660_cdc->ext_spk_boost_set = true;
-		break;
-	default:
-		return -EINVAL;
-	}
-	dev_dbg(codec->dev, "%s: sdm660_cdc->spk_boost_set = %d\n",
-		__func__, sdm660_cdc->spk_boost_set);
-	return 0;
-}
-
-
-static const char * const msm_anlg_cdc_loopback_mode_ctrl_text[] = {
-		"DISABLE", "ENABLE"};
-static const struct soc_enum msm_anlg_cdc_loopback_mode_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(2, msm_anlg_cdc_loopback_mode_ctrl_text),
-};
-
-static const char * const msm_anlg_cdc_ear_pa_boost_ctrl_text[] = {
-		"DISABLE", "ENABLE"};
-static const struct soc_enum msm_anlg_cdc_ear_pa_boost_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(2, msm_anlg_cdc_ear_pa_boost_ctrl_text),
-};
-
-static const char * const msm_anlg_cdc_ear_pa_gain_text[] = {
-		"POS_1P5_DB", "POS_3_DB", "POS_4P5_DB", "POS_6_DB"};
-static const struct soc_enum msm_anlg_cdc_ear_pa_gain_enum[] = {
-		SOC_ENUM_SINGLE_EXT(4, msm_anlg_cdc_ear_pa_gain_text),
-};
-
-static const char * const msm_anlg_cdc_boost_option_ctrl_text[] = {
-		"BOOST_SWITCH", "BOOST_ALWAYS", "BYPASS_ALWAYS",
-		"BOOST_ON_FOREVER"};
-static const struct soc_enum msm_anlg_cdc_boost_option_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(4, msm_anlg_cdc_boost_option_ctrl_text),
-};
-static const char * const msm_anlg_cdc_spk_boost_ctrl_text[] = {
-		"DISABLE", "ENABLE"};
-static const struct soc_enum msm_anlg_cdc_spk_boost_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(2, msm_anlg_cdc_spk_boost_ctrl_text),
-};
-
-static const char * const msm_anlg_cdc_ext_spk_boost_ctrl_text[] = {
-		"DISABLE", "ENABLE"};
-static const struct soc_enum msm_anlg_cdc_ext_spk_boost_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(2, msm_anlg_cdc_ext_spk_boost_ctrl_text),
-};
-
-static const char * const msm_anlg_cdc_hph_mode_ctrl_text[] = {
-		"NORMAL", "HD2"};
-static const struct soc_enum msm_anlg_cdc_hph_mode_ctl_enum[] = {
-		SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(msm_anlg_cdc_hph_mode_ctrl_text),
-			msm_anlg_cdc_hph_mode_ctrl_text),
-};
-
-/*cut of frequency for high pass filter*/
-static const char * const cf_text[] = {
-	"MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz"
-};
-
-
-static const struct snd_kcontrol_new msm_anlg_cdc_snd_controls[] = {
-
-	SOC_ENUM_EXT("RX HPH Mode", msm_anlg_cdc_hph_mode_ctl_enum[0],
-		msm_anlg_cdc_hph_mode_get, msm_anlg_cdc_hph_mode_set),
-
-	SOC_ENUM_EXT("Boost Option", msm_anlg_cdc_boost_option_ctl_enum[0],
-		msm_anlg_cdc_boost_option_get, msm_anlg_cdc_boost_option_set),
-
-	SOC_ENUM_EXT("EAR PA Boost", msm_anlg_cdc_ear_pa_boost_ctl_enum[0],
-		msm_anlg_cdc_ear_pa_boost_get, msm_anlg_cdc_ear_pa_boost_set),
-
-	SOC_ENUM_EXT("EAR PA Gain", msm_anlg_cdc_ear_pa_gain_enum[0],
-		msm_anlg_cdc_pa_gain_get, msm_anlg_cdc_pa_gain_put),
-
-	SOC_ENUM_EXT("Speaker Boost", msm_anlg_cdc_spk_boost_ctl_enum[0],
-		msm_anlg_cdc_spk_boost_get, msm_anlg_cdc_spk_boost_set),
-
-	SOC_ENUM_EXT("Ext Spk Boost", msm_anlg_cdc_ext_spk_boost_ctl_enum[0],
-		msm_anlg_cdc_ext_spk_boost_get, msm_anlg_cdc_ext_spk_boost_set),
-
-	SOC_ENUM_EXT("LOOPBACK Mode", msm_anlg_cdc_loopback_mode_ctl_enum[0],
-		msm_anlg_cdc_loopback_mode_get, msm_anlg_cdc_loopback_mode_put),
-	SOC_SINGLE_TLV("ADC1 Volume", MSM89XX_PMIC_ANALOG_TX_1_EN, 3,
-					8, 0, analog_gain),
-	SOC_SINGLE_TLV("ADC2 Volume", MSM89XX_PMIC_ANALOG_TX_2_EN, 3,
-					8, 0, analog_gain),
-	SOC_SINGLE_TLV("ADC3 Volume", MSM89XX_PMIC_ANALOG_TX_3_EN, 3,
-					8, 0, analog_gain),
-
-
-};
-
-static int tombak_hph_impedance_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	int ret;
-	uint32_t zl, zr;
-	bool hphr;
-	struct soc_multi_mixer_control *mc;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
-
-	hphr = mc->shift;
-	ret = wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
-	if (ret)
-		dev_dbg(codec->dev, "%s: Failed to get mbhc imped", __func__);
-	dev_dbg(codec->dev, "%s: zl %u, zr %u\n", __func__, zl, zr);
-	ucontrol->value.integer.value[0] = hphr ? zr : zl;
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
-			tombak_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
-			tombak_hph_impedance_get, NULL),
-};
-
-static int tombak_get_hph_type(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct sdm660_cdc_priv *priv = snd_soc_codec_get_drvdata(codec);
-	struct wcd_mbhc *mbhc;
-
-	if (!priv) {
-		dev_err(codec->dev,
-			"%s: sdm660_cdc-wcd private data is NULL\n",
-			 __func__);
-		return -EINVAL;
-	}
-
-	mbhc = &priv->mbhc;
-	if (!mbhc) {
-		dev_err(codec->dev, "%s: mbhc not initialized\n", __func__);
-		return -EINVAL;
-	}
-
-	ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
-	dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
-	tombak_get_hph_type, NULL),
-};
-
-static const char * const rdac2_mux_text[] = {
-	"ZERO", "RX2", "RX1"
-};
-
-static const struct snd_kcontrol_new adc1_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct soc_enum rdac2_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_PMIC_DIGITAL_CDC_CONN_HPHR_DAC_CTL,
-		0, 3, rdac2_mux_text);
-
-static const char * const adc2_mux_text[] = {
-	"ZERO", "INP2", "INP3"
-};
-
-static const char * const ext_spk_text[] = {
-	"Off", "On"
-};
-
-static const char * const wsa_spk_text[] = {
-	"ZERO", "WSA"
-};
-
-static const struct soc_enum adc2_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0,
-		ARRAY_SIZE(adc2_mux_text), adc2_mux_text);
-
-static const struct soc_enum ext_spk_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0,
-		ARRAY_SIZE(ext_spk_text), ext_spk_text);
-
-static const struct soc_enum wsa_spk_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0,
-		ARRAY_SIZE(wsa_spk_text), wsa_spk_text);
-
-
-
-static const struct snd_kcontrol_new ext_spk_mux =
-	SOC_DAPM_ENUM("Ext Spk Switch Mux", ext_spk_enum);
-
-
-
-static const struct snd_kcontrol_new tx_adc2_mux =
-	SOC_DAPM_ENUM("ADC2 MUX Mux", adc2_enum);
-
-
-static const struct snd_kcontrol_new rdac2_mux =
-	SOC_DAPM_ENUM("RDAC2 MUX Mux", rdac2_mux_enum);
-
-static const char * const ear_text[] = {
-	"ZERO", "Switch",
-};
-
-static const struct soc_enum ear_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(ear_text), ear_text);
-
-static const struct snd_kcontrol_new ear_pa_mux[] = {
-	SOC_DAPM_ENUM("EAR_S", ear_enum)
-};
-
-static const struct snd_kcontrol_new wsa_spk_mux[] = {
-	SOC_DAPM_ENUM("WSA Spk Switch", wsa_spk_enum)
-};
-
-
-
-static const char * const hph_text[] = {
-	"ZERO", "Switch",
-};
-
-static const struct soc_enum hph_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(hph_text), hph_text);
-
-static const struct snd_kcontrol_new hphl_mux[] = {
-	SOC_DAPM_ENUM("HPHL", hph_enum)
-};
-
-static const struct snd_kcontrol_new hphr_mux[] = {
-	SOC_DAPM_ENUM("HPHR", hph_enum)
-};
-
-static const struct snd_kcontrol_new spkr_mux[] = {
-	SOC_DAPM_ENUM("SPK", hph_enum)
-};
-
-static const char * const lo_text[] = {
-	"ZERO", "Switch",
-};
-
-static const struct soc_enum lo_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(hph_text), hph_text);
-
-static const struct snd_kcontrol_new lo_mux[] = {
-	SOC_DAPM_ENUM("LINE_OUT", lo_enum)
-};
-
-static void msm_anlg_cdc_codec_enable_adc_block(struct snd_soc_codec *codec,
-					 int enable)
-{
-	struct sdm660_cdc_priv *wcd8x16 = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, enable);
-
-	if (enable) {
-		wcd8x16->adc_count++;
-		snd_soc_update_bits(codec,
-				    MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL,
-				    0x20, 0x20);
-		snd_soc_update_bits(codec,
-				    MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				    0x10, 0x10);
-	} else {
-		wcd8x16->adc_count--;
-		if (!wcd8x16->adc_count) {
-			snd_soc_update_bits(codec,
-				    MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				    0x10, 0x00);
-			snd_soc_update_bits(codec,
-				    MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL,
-					    0x20, 0x0);
-		}
-	}
-}
-
-static int msm_anlg_cdc_codec_enable_adc(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 adc_reg;
-	u8 init_bit_shift;
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-
-	adc_reg = MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_2;
-
-	if (w->reg == MSM89XX_PMIC_ANALOG_TX_1_EN)
-		init_bit_shift = 5;
-	else if ((w->reg == MSM89XX_PMIC_ANALOG_TX_2_EN) ||
-		 (w->reg == MSM89XX_PMIC_ANALOG_TX_3_EN))
-		init_bit_shift = 4;
-	else {
-		dev_err(codec->dev, "%s: Error, invalid adc register\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		msm_anlg_cdc_codec_enable_adc_block(codec, 1);
-		if (w->reg == MSM89XX_PMIC_ANALOG_TX_2_EN)
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_1_CTL, 0x02, 0x02);
-		/*
-		 * Add delay of 10 ms to give sufficient time for the voltage
-		 * to shoot up and settle so that the txfe init does not
-		 * happen when the input voltage is changing too much.
-		 */
-		usleep_range(10000, 10010);
-		snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift,
-				1 << init_bit_shift);
-		if (w->reg == MSM89XX_PMIC_ANALOG_TX_1_EN)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_CONN_TX1_CTL,
-				0x03, 0x00);
-		else if ((w->reg == MSM89XX_PMIC_ANALOG_TX_2_EN) ||
-			(w->reg == MSM89XX_PMIC_ANALOG_TX_3_EN))
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_CONN_TX2_CTL,
-				0x03, 0x00);
-		/* Wait for 1ms to allow txfe settling time */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/*
-		 * Add delay of 12 ms before deasserting the init
-		 * to reduce the tx pop
-		 */
-		usleep_range(12000, 12010);
-		snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00);
-		/* Wait for 1ms to allow txfe settling time post powerup */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		msm_anlg_cdc_codec_enable_adc_block(codec, 0);
-		if (w->reg == MSM89XX_PMIC_ANALOG_TX_2_EN)
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_MICB_1_CTL, 0x02, 0x00);
-		if (w->reg == MSM89XX_PMIC_ANALOG_TX_1_EN)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_CONN_TX1_CTL,
-				0x03, 0x02);
-		else if ((w->reg == MSM89XX_PMIC_ANALOG_TX_2_EN) ||
-			(w->reg == MSM89XX_PMIC_ANALOG_TX_3_EN))
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_CONN_TX2_CTL,
-				0x03, 0x02);
-
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_codec_enable_spk_pa(struct snd_soc_dapm_widget *w,
-					    struct snd_kcontrol *kcontrol,
-					    int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL, 0x01, 0x01);
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (!sdm660_cdc->spk_boost_set)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL,
-					0x10, 0x10);
-			break;
-		case BOOST_ALWAYS:
-		case BOOST_ON_FOREVER:
-			break;
-		case BYPASS_ALWAYS:
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL,
-				0x10, 0x10);
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-		/* Wait for 1ms after SPK_DAC CTL setting */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL, 0xE0, 0xE0);
-		if (get_codec_version(sdm660_cdc) != TOMBAK_1_0)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_EAR_CTL, 0x01, 0x01);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* Wait for 1ms after SPK_VBAT_LDO Enable */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->spk_boost_set)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-					0xEF, 0xEF);
-			else
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL,
-					0x10, 0x00);
-			break;
-		case BOOST_ALWAYS:
-		case BOOST_ON_FOREVER:
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-				0xEF, 0xEF);
-			break;
-		case BYPASS_ALWAYS:
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x10, 0x00);
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-		msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX3_MUTE_OFF);
-		snd_soc_update_bits(codec, w->reg, 0x80, 0x80);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX3_MUTE_ON);
-		/*
-		 * Add 1 ms sleep for the mute to take effect
-		 */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x10, 0x10);
-		if (get_codec_version(sdm660_cdc) < CAJON_2_0)
-			msm_anlg_cdc_boost_mode_sequence(codec, SPK_PMD);
-		snd_soc_update_bits(codec, w->reg, 0x80, 0x00);
-		switch (sdm660_cdc->boost_option) {
-		case BOOST_SWITCH:
-			if (sdm660_cdc->spk_boost_set)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-					0xEF, 0x69);
-			break;
-		case BOOST_ALWAYS:
-		case BOOST_ON_FOREVER:
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-				0xEF, 0x69);
-			break;
-		case BYPASS_ALWAYS:
-			break;
-		default:
-			dev_err(codec->dev,
-				"%s: invalid boost option: %d\n", __func__,
-				sdm660_cdc->boost_option);
-			break;
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL, 0xE0, 0x00);
-		/* Wait for 1ms to allow setting time for spkr path disable */
-		usleep_range(CODEC_DELAY_1_MS, CODEC_DELAY_1_1_MS);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL, 0x01, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x10, 0x00);
-		if (get_codec_version(sdm660_cdc) != TOMBAK_1_0)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_EAR_CTL, 0x01, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x00);
-		if (get_codec_version(sdm660_cdc) >= CAJON_2_0)
-			msm_anlg_cdc_boost_mode_sequence(codec, SPK_PMD);
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_codec_enable_dig_clk(struct snd_soc_dapm_widget *w,
-					     struct snd_kcontrol *kcontrol,
-					     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-
-	dev_dbg(codec->dev, "%s event %d w->name %s\n", __func__,
-			event, w->name);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		msm_anlg_cdc_codec_enable_clock_block(codec, 1);
-		snd_soc_update_bits(codec, w->reg, 0x80, 0x80);
-		msm_anlg_cdc_boost_mode_sequence(codec, SPK_PMU);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (sdm660_cdc->rx_bias_count == 0)
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-					0x80, 0x00);
-	}
-	return 0;
-}
-
-
-
-static bool msm_anlg_cdc_use_mb(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) < CAJON)
-		return true;
-	else
-		return false;
-}
-
-static void msm_anlg_cdc_set_auto_zeroing(struct snd_soc_codec *codec,
-					  bool enable)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) < CONGA) {
-		if (enable)
-			/*
-			 * Set autozeroing for special headset detection and
-			 * buttons to work.
-			 */
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_2_EN,
-				0x18, 0x10);
-		else
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_2_EN,
-				0x18, 0x00);
-
-	} else {
-		dev_dbg(codec->dev,
-			"%s: Auto Zeroing is not required from CONGA\n",
-			__func__);
-	}
-}
-
-static void msm_anlg_cdc_trim_btn_reg(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	if (get_codec_version(sdm660_cdc) == TOMBAK_1_0) {
-		pr_debug("%s: This device needs to be trimmed\n", __func__);
-		/*
-		 * Calculate the trim value for each device used
-		 * till is comes in production by hardware team
-		 */
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SEC_ACCESS,
-				0xA5, 0xA5);
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_TRIM_CTRL2,
-				0xFF, 0x30);
-	} else {
-		dev_dbg(codec->dev, "%s: This device is trimmed at ATE\n",
-			__func__);
-	}
-}
-
-static int msm_anlg_cdc_enable_ext_mb_source(struct wcd_mbhc *wcd_mbhc,
-					     bool turn_on)
-{
-	int ret = 0;
-	static int count;
-	struct snd_soc_codec *codec = wcd_mbhc->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
-	dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
-			count);
-	if (turn_on) {
-		if (!count) {
-			ret = snd_soc_dapm_force_enable_pin(dapm,
-				"MICBIAS_REGULATOR");
-			snd_soc_dapm_sync(dapm);
-		}
-		count++;
-	} else {
-		if (count > 0)
-			count--;
-		if (!count) {
-			ret = snd_soc_dapm_disable_pin(dapm,
-				"MICBIAS_REGULATOR");
-			snd_soc_dapm_sync(dapm);
-		}
-	}
-
-	if (ret)
-		dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
-			__func__, turn_on ? "enable" : "disabled");
-	else
-		dev_dbg(codec->dev, "%s: %s external micbias source\n",
-			 __func__, turn_on ? "Enabled" : "Disabled");
-
-	return ret;
-}
-
-static int msm_anlg_cdc_codec_enable_micbias(struct snd_soc_dapm_widget *w,
-					     struct snd_kcontrol *kcontrol,
-					     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-				snd_soc_codec_get_drvdata(codec);
-	u16 micb_int_reg;
-	char *internal1_text = "Internal1";
-	char *internal2_text = "Internal2";
-	char *internal3_text = "Internal3";
-	char *external2_text = "External2";
-	char *external_text = "External";
-	bool micbias2;
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-	switch (w->reg) {
-	case MSM89XX_PMIC_ANALOG_MICB_1_EN:
-	case MSM89XX_PMIC_ANALOG_MICB_2_EN:
-		micb_int_reg = MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS;
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: Error, invalid micbias register 0x%x\n",
-			__func__, w->reg);
-		return -EINVAL;
-	}
-
-	micbias2 = (snd_soc_read(codec, MSM89XX_PMIC_ANALOG_MICB_2_EN) & 0x80);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (strnstr(w->name, internal1_text, strlen(w->name))) {
-			if (get_codec_version(sdm660_cdc) >= CAJON)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2,
-					0x02, 0x02);
-			snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x80);
-		} else if (strnstr(w->name, internal2_text, strlen(w->name))) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x10);
-			snd_soc_update_bits(codec, w->reg, 0x60, 0x00);
-		} else if (strnstr(w->name, internal3_text, strlen(w->name))) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x2);
-		/*
-		 * update MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2
-		 * for external bias only, not for external2.
-		*/
-		} else if (!strnstr(w->name, external2_text, strlen(w->name)) &&
-					strnstr(w->name, external_text,
-						strlen(w->name))) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2,
-					0x02, 0x02);
-		}
-		if (!strnstr(w->name, external_text, strlen(w->name)))
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_1_EN, 0x05, 0x04);
-		if (w->reg == MSM89XX_PMIC_ANALOG_MICB_1_EN)
-			msm_anlg_cdc_configure_cap(codec, true, micbias2);
-
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if (get_codec_version(sdm660_cdc) <= TOMBAK_2_0)
-			/*
-			 * Wait for 20ms post micbias enable
-			 * for version < tombak 2.0.
-			 */
-			usleep_range(20000, 20100);
-		if (strnstr(w->name, internal1_text, strlen(w->name))) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x40, 0x40);
-		} else if (strnstr(w->name, internal2_text,  strlen(w->name))) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x08, 0x08);
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_MICBIAS_2_ON);
-		} else if (strnstr(w->name, internal3_text, 30)) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x01, 0x01);
-		} else if (strnstr(w->name, external2_text, strlen(w->name))) {
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_MICBIAS_2_ON);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (strnstr(w->name, internal1_text, strlen(w->name))) {
-			snd_soc_update_bits(codec, micb_int_reg, 0xC0, 0x40);
-		} else if (strnstr(w->name, internal2_text, strlen(w->name))) {
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_MICBIAS_2_OFF);
-		} else if (strnstr(w->name, internal3_text, 30)) {
-			snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0);
-		} else if (strnstr(w->name, external2_text, strlen(w->name))) {
-			/*
-			 * send micbias turn off event to mbhc driver and then
-			 * break, as no need to set MICB_1_EN register.
-			 */
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_MICBIAS_2_OFF);
-			break;
-		}
-		if (w->reg == MSM89XX_PMIC_ANALOG_MICB_1_EN)
-			msm_anlg_cdc_configure_cap(codec, false, micbias2);
-		break;
-	}
-	return 0;
-}
-
-static void update_clkdiv(void *handle, int val)
-{
-	struct sdm660_cdc_priv *handle_cdc = handle;
-	struct snd_soc_codec *codec = handle_cdc->codec;
-
-	snd_soc_update_bits(codec,
-			    MSM89XX_PMIC_ANALOG_TX_1_2_TXFE_CLKDIV,
-			    0xFF, val);
-}
-
-static int get_cdc_version(void *handle)
-{
-	struct sdm660_cdc_priv *sdm660_cdc = handle;
-
-	return get_codec_version(sdm660_cdc);
-}
-
-static int sdm660_wcd_codec_enable_vdd_spkr(struct snd_soc_dapm_widget *w,
-					       struct snd_kcontrol *kcontrol,
-					       int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	if (!sdm660_cdc->ext_spk_boost_set) {
-		dev_dbg(codec->dev, "%s: ext_boost not supported/disabled\n",
-								__func__);
-		return 0;
-	}
-	dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (sdm660_cdc->spkdrv_reg) {
-			ret = regulator_enable(sdm660_cdc->spkdrv_reg);
-			if (ret)
-				dev_err(codec->dev,
-					"%s Failed to enable spkdrv reg %s\n",
-					__func__, MSM89XX_VDD_SPKDRV_NAME);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (sdm660_cdc->spkdrv_reg) {
-			ret = regulator_disable(sdm660_cdc->spkdrv_reg);
-			if (ret)
-				dev_err(codec->dev,
-					"%s: Failed to disable spkdrv_reg %s\n",
-					__func__, MSM89XX_VDD_SPKDRV_NAME);
-		}
-		break;
-	}
-	return 0;
-}
-
-
-/* The register address is the same as other codec so it can use resmgr */
-static int msm_anlg_cdc_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
-					     struct snd_kcontrol *kcontrol,
-					     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		sdm660_cdc->rx_bias_count++;
-		if (sdm660_cdc->rx_bias_count == 1) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-					0x80, 0x80);
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-					0x01, 0x01);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		sdm660_cdc->rx_bias_count--;
-		if (sdm660_cdc->rx_bias_count == 0) {
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-					0x01, 0x00);
-			snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-					0x80, 0x00);
-		}
-		break;
-	}
-	dev_dbg(codec->dev, "%s rx_bias_count = %d\n",
-			__func__, sdm660_cdc->rx_bias_count);
-	return 0;
-}
-
-static uint32_t wcd_get_impedance_value(uint32_t imped)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(wcd_imped_val) - 1; i++) {
-		if (imped >= wcd_imped_val[i] &&
-			imped < wcd_imped_val[i + 1])
-			break;
-	}
-
-	pr_debug("%s: selected impedance value = %d\n",
-		 __func__, wcd_imped_val[i]);
-	return wcd_imped_val[i];
-}
-
-static void wcd_imped_config(struct snd_soc_codec *codec,
-			     uint32_t imped, bool set_gain)
-{
-	uint32_t value;
-	int codec_version;
-	struct sdm660_cdc_priv *sdm660_cdc =
-				snd_soc_codec_get_drvdata(codec);
-
-	value = wcd_get_impedance_value(imped);
-
-	if (value < wcd_imped_val[0]) {
-		dev_dbg(codec->dev,
-			"%s, detected impedance is less than 4 Ohm\n",
-			 __func__);
-		return;
-	}
-
-	codec_version = get_codec_version(sdm660_cdc);
-
-	if (set_gain) {
-		switch (codec_version) {
-		case TOMBAK_1_0:
-		case TOMBAK_2_0:
-		case CONGA:
-			/*
-			 * For 32Ohm load and higher loads, Set 0x19E
-			 * bit 5 to 1 (POS_0_DB_DI). For loads lower
-			 * than 32Ohm (such as 16Ohm load), Set 0x19E
-			 * bit 5 to 0 (POS_M4P5_DB_DI)
-			 */
-			if (value >= 32)
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-					0x20, 0x20);
-			else
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-					0x20, 0x00);
-			break;
-		case CAJON:
-		case CAJON_2_0:
-		case DIANGU:
-		case DRAX_CDC:
-			if (value >= 13) {
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-					0x20, 0x20);
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_NCP_VCTRL,
-					0x07, 0x07);
-			} else {
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-					0x20, 0x00);
-				snd_soc_update_bits(codec,
-					MSM89XX_PMIC_ANALOG_NCP_VCTRL,
-					0x07, 0x04);
-			}
-			break;
-		}
-	} else {
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-			0x20, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_NCP_VCTRL,
-			0x07, 0x04);
-	}
-
-	dev_dbg(codec->dev, "%s: Exit\n", __func__);
-}
-
-static int msm_anlg_cdc_hphl_dac_event(struct snd_soc_dapm_widget *w,
-				       struct snd_kcontrol *kcontrol,
-				       int event)
-{
-	uint32_t impedl, impedr;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-	int ret;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-	ret = wcd_mbhc_get_impedance(&sdm660_cdc->mbhc,
-			&impedl, &impedr);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (get_codec_version(sdm660_cdc) > CAJON)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN,
-				0x08, 0x08);
-		if (get_codec_version(sdm660_cdc) == CAJON ||
-			get_codec_version(sdm660_cdc) == CAJON_2_0) {
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST,
-				0x80, 0x80);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST,
-				0x80, 0x80);
-		}
-		if (get_codec_version(sdm660_cdc) > CAJON)
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN,
-				0x08, 0x00);
-		if (sdm660_cdc->hph_mode == HD2_MODE)
-			msm_anlg_cdc_dig_notifier_call(codec,
-					DIG_CDC_EVENT_PRE_RX1_INT_ON);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL, 0x02, 0x02);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL, 0x01, 0x01);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x02, 0x02);
-		if (!ret)
-			wcd_imped_config(codec, impedl, true);
-		else
-			dev_dbg(codec->dev, "Failed to get mbhc impedance %d\n",
-				ret);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL, 0x02, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		wcd_imped_config(codec, impedl, false);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x02, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL, 0x01, 0x00);
-		if (sdm660_cdc->hph_mode == HD2_MODE)
-			msm_anlg_cdc_dig_notifier_call(codec,
-					DIG_CDC_EVENT_POST_RX1_INT_OFF);
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_lo_dac_event(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x20, 0x20);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x80, 0x80);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x08, 0x08);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x40, 0x40);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x80, 0x80);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x08, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x40, 0x40);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* Wait for 20ms before powerdown of lineout_dac */
-		usleep_range(20000, 20100);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x80, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x40, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x08, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x80, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x40, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x20, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x00);
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_hphr_dac_event(struct snd_soc_dapm_widget *w,
-				       struct snd_kcontrol *kcontrol,
-				       int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (sdm660_cdc->hph_mode == HD2_MODE)
-			msm_anlg_cdc_dig_notifier_call(codec,
-					DIG_CDC_EVENT_PRE_RX2_INT_ON);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL, 0x02, 0x02);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL, 0x02, 0x02);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x01, 0x01);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL, 0x02, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x01, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL, 0x02, 0x00);
-		if (sdm660_cdc->hph_mode == HD2_MODE)
-			msm_anlg_cdc_dig_notifier_call(codec,
-					DIG_CDC_EVENT_POST_RX2_INT_OFF);
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_hph_pa_event(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: %s event = %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (w->shift == 5)
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_PRE_HPHL_PA_ON);
-		else if (w->shift == 4)
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_PRE_HPHR_PA_ON);
-		snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0x20, 0x20);
-		break;
-
-	case SND_SOC_DAPM_POST_PMU:
-		/* Wait for 7ms to allow setting time for HPH_PA Enable */
-		usleep_range(7000, 7100);
-		if (w->shift == 5) {
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST, 0x04, 0x04);
-			msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX1_MUTE_OFF);
-		} else if (w->shift == 4) {
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST, 0x04, 0x04);
-			msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX2_MUTE_OFF);
-		}
-		break;
-
-	case SND_SOC_DAPM_PRE_PMD:
-		if (w->shift == 5) {
-			msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX1_MUTE_ON);
-			/* Wait for 20ms after HPHL RX digital mute */
-			msleep(20);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST, 0x04, 0x00);
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_PRE_HPHL_PA_OFF);
-		} else if (w->shift == 4) {
-			msm_anlg_cdc_dig_notifier_call(codec,
-					       DIG_CDC_EVENT_RX2_MUTE_ON);
-			/* Wait for 20ms after HPHR RX digital mute */
-			msleep(20);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST, 0x04, 0x00);
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_PRE_HPHR_PA_OFF);
-		}
-		if (get_codec_version(sdm660_cdc) >= CAJON) {
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_CNP,
-				0xF0, 0x30);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (w->shift == 5) {
-			clear_bit(WCD_MBHC_HPHL_PA_OFF_ACK,
-				&sdm660_cdc->mbhc.hph_pa_dac_state);
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_HPHL_PA_OFF);
-		} else if (w->shift == 4) {
-			clear_bit(WCD_MBHC_HPHR_PA_OFF_ACK,
-				&sdm660_cdc->mbhc.hph_pa_dac_state);
-			msm_anlg_cdc_notifier_call(codec,
-					WCD_EVENT_POST_HPHR_PA_OFF);
-		}
-		/* Wait for 15ms after HPH RX teardown */
-		usleep_range(15000, 15100);
-		break;
-	}
-	return 0;
-}
-
-static const struct snd_soc_dapm_route audio_map[] = {
-	/* RDAC Connections */
-	{"HPHR DAC", NULL, "RDAC2 MUX"},
-	{"RDAC2 MUX", "RX1", "PDM_IN_RX1"},
-	{"RDAC2 MUX", "RX2", "PDM_IN_RX2"},
-
-	/* WSA */
-	{"WSA_SPK OUT", NULL, "WSA Spk Switch"},
-	{"WSA Spk Switch", "WSA", "EAR PA"},
-
-	/* Earpiece (RX MIX1) */
-	{"EAR", NULL, "EAR_S"},
-	{"EAR_S", "Switch", "EAR PA"},
-	{"EAR PA", NULL, "RX_BIAS"},
-	{"EAR PA", NULL, "HPHL DAC"},
-	{"EAR PA", NULL, "HPHR DAC"},
-	{"EAR PA", NULL, "EAR CP"},
-
-	/* Headset (RX MIX1 and RX MIX2) */
-	{"HEADPHONE", NULL, "HPHL PA"},
-	{"HEADPHONE", NULL, "HPHR PA"},
-
-	{"Ext Spk", NULL, "Ext Spk Switch"},
-	{"Ext Spk Switch", "On", "HPHL PA"},
-	{"Ext Spk Switch", "On", "HPHR PA"},
-
-	{"HPHL PA", NULL, "HPHL"},
-	{"HPHR PA", NULL, "HPHR"},
-	{"HPHL", "Switch", "HPHL DAC"},
-	{"HPHR", "Switch", "HPHR DAC"},
-	{"HPHL PA", NULL, "CP"},
-	{"HPHL PA", NULL, "RX_BIAS"},
-	{"HPHR PA", NULL, "CP"},
-	{"HPHR PA", NULL, "RX_BIAS"},
-	{"HPHL DAC", NULL, "PDM_IN_RX1"},
-
-	{"SPK_OUT", NULL, "SPK PA"},
-	{"SPK PA", NULL, "SPK_RX_BIAS"},
-	{"SPK PA", NULL, "SPK"},
-	{"SPK", "Switch", "SPK DAC"},
-	{"SPK DAC", NULL, "PDM_IN_RX3"},
-	{"SPK DAC", NULL, "VDD_SPKDRV"},
-
-	/* lineout */
-	{"LINEOUT", NULL, "LINEOUT PA"},
-	{"LINEOUT PA", NULL, "SPK_RX_BIAS"},
-	{"LINEOUT PA", NULL, "LINE_OUT"},
-	{"LINE_OUT", "Switch", "LINEOUT DAC"},
-	{"LINEOUT DAC", NULL, "PDM_IN_RX3"},
-
-	/* lineout to WSA */
-	{"WSA_SPK OUT", NULL, "LINEOUT PA"},
-
-	{"PDM_IN_RX1", NULL, "RX1 CLK"},
-	{"PDM_IN_RX2", NULL, "RX2 CLK"},
-	{"PDM_IN_RX3", NULL, "RX3 CLK"},
-
-	{"ADC1_OUT", NULL, "ADC1"},
-	{"ADC2_OUT", NULL, "ADC2"},
-	{"ADC3_OUT", NULL, "ADC3"},
-
-	/* ADC Connections */
-	{"ADC2", NULL, "ADC2 MUX"},
-	{"ADC3", NULL, "ADC2 MUX"},
-	{"ADC2 MUX", "INP2", "ADC2_INP2"},
-	{"ADC2 MUX", "INP3", "ADC2_INP3"},
-
-	{"ADC1", NULL, "ADC1_INP1"},
-	{"ADC1_INP1", "Switch", "AMIC1"},
-	{"ADC2_INP2", NULL, "AMIC2"},
-	{"ADC2_INP3", NULL, "AMIC3"},
-
-	{"MIC BIAS Internal1", NULL, "INT_LDO_H"},
-	{"MIC BIAS Internal2", NULL, "INT_LDO_H"},
-	{"MIC BIAS External", NULL, "INT_LDO_H"},
-	{"MIC BIAS External2", NULL, "INT_LDO_H"},
-	{"MIC BIAS Internal1", NULL, "MICBIAS_REGULATOR"},
-	{"MIC BIAS Internal2", NULL, "MICBIAS_REGULATOR"},
-	{"MIC BIAS External", NULL, "MICBIAS_REGULATOR"},
-	{"MIC BIAS External2", NULL, "MICBIAS_REGULATOR"},
-};
-
-static int msm_anlg_cdc_startup(struct snd_pcm_substream *substream,
-				struct snd_soc_dai *dai)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-		snd_soc_codec_get_drvdata(dai->codec);
-
-	dev_dbg(dai->codec->dev, "%s(): substream = %s  stream = %d\n",
-		__func__,
-		substream->name, substream->stream);
-	/*
-	 * If status_mask is BUS_DOWN it means SSR is not complete.
-	 * So return error.
-	 */
-	if (test_bit(BUS_DOWN, &sdm660_cdc->status_mask)) {
-		dev_err(dai->codec->dev, "Error, Device is not up post SSR\n");
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static void msm_anlg_cdc_shutdown(struct snd_pcm_substream *substream,
-				  struct snd_soc_dai *dai)
-{
-	dev_dbg(dai->codec->dev,
-		"%s(): substream = %s  stream = %d\n", __func__,
-		substream->name, substream->stream);
-}
-
-int msm_anlg_cdc_mclk_enable(struct snd_soc_codec *codec,
-			     int mclk_enable, bool dapm)
-{
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: mclk_enable = %u, dapm = %d\n",
-		__func__, mclk_enable, dapm);
-	if (mclk_enable) {
-		sdm660_cdc->int_mclk0_enabled = true;
-		msm_anlg_cdc_codec_enable_clock_block(codec, 1);
-	} else {
-		if (!sdm660_cdc->int_mclk0_enabled) {
-			dev_err(codec->dev, "Error, MCLK already diabled\n");
-			return -EINVAL;
-		}
-		sdm660_cdc->int_mclk0_enabled = false;
-		msm_anlg_cdc_codec_enable_clock_block(codec, 0);
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_set_dai_sysclk(struct snd_soc_dai *dai,
-		int clk_id, unsigned int freq, int dir)
-{
-	dev_dbg(dai->codec->dev, "%s\n", __func__);
-	return 0;
-}
-
-static int msm_anlg_cdc_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
-	dev_dbg(dai->codec->dev, "%s\n", __func__);
-	return 0;
-}
-
-static int msm_anlg_cdc_set_channel_map(struct snd_soc_dai *dai,
-				unsigned int tx_num, unsigned int *tx_slot,
-				unsigned int rx_num, unsigned int *rx_slot)
-
-{
-	dev_dbg(dai->codec->dev, "%s\n", __func__);
-	return 0;
-}
-
-static int msm_anlg_cdc_get_channel_map(struct snd_soc_dai *dai,
-				 unsigned int *tx_num, unsigned int *tx_slot,
-				 unsigned int *rx_num, unsigned int *rx_slot)
-
-{
-	dev_dbg(dai->codec->dev, "%s\n", __func__);
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_anlg_cdc_dai_ops = {
-	.startup = msm_anlg_cdc_startup,
-	.shutdown = msm_anlg_cdc_shutdown,
-	.set_sysclk = msm_anlg_cdc_set_dai_sysclk,
-	.set_fmt = msm_anlg_cdc_set_dai_fmt,
-	.set_channel_map = msm_anlg_cdc_set_channel_map,
-	.get_channel_map = msm_anlg_cdc_get_channel_map,
-};
-
-static struct snd_soc_dai_driver msm_anlg_cdc_i2s_dai[] = {
-	{
-		.name = "msm_anlg_cdc_i2s_rx1",
-		.id = AIF1_PB,
-		.playback = {
-			.stream_name = "PDM Playback",
-			.rates = SDM660_CDC_RATES,
-			.formats = SDM660_CDC_FORMATS,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 3,
-		},
-		.ops = &msm_anlg_cdc_dai_ops,
-	},
-	{
-		.name = "msm_anlg_cdc_i2s_tx1",
-		.id = AIF1_CAP,
-		.capture = {
-			.stream_name = "PDM Capture",
-			.rates = SDM660_CDC_RATES,
-			.formats = SDM660_CDC_FORMATS,
-			.rate_max = 48000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &msm_anlg_cdc_dai_ops,
-	},
-	{
-		.name = "msm_anlg_cdc_i2s_tx2",
-		.id = AIF3_SVA,
-		.capture = {
-			.stream_name = "RecordSVA",
-			.rates = SDM660_CDC_RATES,
-			.formats = SDM660_CDC_FORMATS,
-			.rate_max = 48000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &msm_anlg_cdc_dai_ops,
-	},
-	{
-		.name = "msm_anlg_vifeedback",
-		.id = AIF2_VIFEED,
-		.capture = {
-			.stream_name = "VIfeed",
-			.rates = SDM660_CDC_RATES,
-			.formats = SDM660_CDC_FORMATS,
-			.rate_max = 48000,
-			.rate_min = 48000,
-			.channels_min = 2,
-			.channels_max = 2,
-		},
-		.ops = &msm_anlg_cdc_dai_ops,
-	},
-};
-
-
-static int msm_anlg_cdc_codec_enable_lo_pa(struct snd_soc_dapm_widget *w,
-					   struct snd_kcontrol *kcontrol,
-					   int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: %d %s\n", __func__, event, w->name);
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		msm_anlg_cdc_dig_notifier_call(codec,
-				       DIG_CDC_EVENT_RX3_MUTE_OFF);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		msm_anlg_cdc_dig_notifier_call(codec,
-				       DIG_CDC_EVENT_RX3_MUTE_ON);
-		break;
-	}
-
-	return 0;
-}
-
-static int msm_anlg_cdc_codec_enable_spk_ext_pa(struct snd_soc_dapm_widget *w,
-						struct snd_kcontrol *kcontrol,
-						int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: %s event = %d\n", __func__, w->name, event);
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		dev_dbg(codec->dev,
-			"%s: enable external speaker PA\n", __func__);
-		if (sdm660_cdc->codec_spk_ext_pa_cb)
-			sdm660_cdc->codec_spk_ext_pa_cb(codec, 1);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		dev_dbg(codec->dev,
-			"%s: enable external speaker PA\n", __func__);
-		if (sdm660_cdc->codec_spk_ext_pa_cb)
-			sdm660_cdc->codec_spk_ext_pa_cb(codec, 0);
-		break;
-	}
-	return 0;
-}
-
-static int msm_anlg_cdc_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
-					    struct snd_kcontrol *kcontrol,
-					    int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		dev_dbg(codec->dev,
-			"%s: Sleeping 20ms after select EAR PA\n",
-			__func__);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-			    0x80, 0x80);
-		if (get_codec_version(sdm660_cdc) < CONGA)
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME, 0xFF, 0x2A);
-		if (get_codec_version(sdm660_cdc) >= DIANGU) {
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC, 0x08, 0x00);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST, 0x04, 0x04);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST, 0x04, 0x04);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		dev_dbg(codec->dev,
-			"%s: Sleeping 20ms after enabling EAR PA\n",
-			__func__);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-			    0x40, 0x40);
-		/* Wait for 7ms after EAR PA enable */
-		usleep_range(7000, 7100);
-		msm_anlg_cdc_dig_notifier_call(codec,
-				       DIG_CDC_EVENT_RX1_MUTE_OFF);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		msm_anlg_cdc_dig_notifier_call(codec,
-				       DIG_CDC_EVENT_RX1_MUTE_ON);
-		/* Wait for 20ms for RX digital mute to take effect */
-		msleep(20);
-		if (sdm660_cdc->boost_option == BOOST_ALWAYS) {
-			dev_dbg(codec->dev,
-				"%s: boost_option:%d, tear down ear\n",
-				__func__, sdm660_cdc->boost_option);
-			msm_anlg_cdc_boost_mode_sequence(codec, EAR_PMD);
-		}
-		if (get_codec_version(sdm660_cdc) >= DIANGU) {
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST, 0x04, 0x0);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST, 0x04, 0x0);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		dev_dbg(codec->dev,
-			"%s: Sleeping 7ms after disabling EAR PA\n",
-			__func__);
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-			    0x40, 0x00);
-		/* Wait for 7ms after EAR PA teardown */
-		usleep_range(7000, 7100);
-		if (get_codec_version(sdm660_cdc) < CONGA)
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME, 0xFF, 0x16);
-		if (get_codec_version(sdm660_cdc) >= DIANGU)
-			snd_soc_update_bits(codec,
-			MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC, 0x08, 0x08);
-		break;
-	}
-	return 0;
-}
-
-static const struct snd_soc_dapm_widget msm_anlg_cdc_dapm_widgets[] = {
-	SND_SOC_DAPM_PGA_E("EAR PA", SND_SOC_NOPM,
-			0, 0, NULL, 0, msm_anlg_cdc_codec_enable_ear_pa,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHL PA", MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN,
-		5, 0, NULL, 0,
-		msm_anlg_cdc_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHR PA", MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN,
-		4, 0, NULL, 0,
-		msm_anlg_cdc_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM,
-			0, 0, NULL, 0, msm_anlg_cdc_codec_enable_spk_pa,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT PA", MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL,
-			5, 0, NULL, 0, msm_anlg_cdc_codec_enable_lo_pa,
-			SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("EAR_S", SND_SOC_NOPM, 0, 0, ear_pa_mux),
-	SND_SOC_DAPM_MUX("SPK", SND_SOC_NOPM, 0, 0, spkr_mux),
-	SND_SOC_DAPM_MUX("HPHL", SND_SOC_NOPM, 0, 0, hphl_mux),
-	SND_SOC_DAPM_MUX("HPHR", SND_SOC_NOPM, 0, 0, hphr_mux),
-	SND_SOC_DAPM_MUX("RDAC2 MUX", SND_SOC_NOPM, 0, 0, &rdac2_mux),
-	SND_SOC_DAPM_MUX("WSA Spk Switch", SND_SOC_NOPM, 0, 0, wsa_spk_mux),
-	SND_SOC_DAPM_MUX("Ext Spk Switch", SND_SOC_NOPM, 0, 0, &ext_spk_mux),
-	SND_SOC_DAPM_MUX("LINE_OUT", SND_SOC_NOPM, 0, 0, lo_mux),
-	SND_SOC_DAPM_MUX("ADC2 MUX", SND_SOC_NOPM, 0, 0, &tx_adc2_mux),
-
-	SND_SOC_DAPM_MIXER_E("HPHL DAC",
-		MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL, 3, 0, NULL,
-		0, msm_anlg_cdc_hphl_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("HPHR DAC",
-		MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL, 3, 0, NULL,
-		0, msm_anlg_cdc_hphr_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER("ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_DAC("SPK DAC", NULL, MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL,
-			 7, 0),
-	SND_SOC_DAPM_DAC_E("LINEOUT DAC", NULL,
-		SND_SOC_NOPM, 0, 0, msm_anlg_cdc_lo_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SPK("Ext Spk", msm_anlg_cdc_codec_enable_spk_ext_pa),
-
-	SND_SOC_DAPM_SWITCH("ADC1_INP1", SND_SOC_NOPM, 0, 0,
-			    &adc1_switch),
-	SND_SOC_DAPM_SUPPLY("RX1 CLK", MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			    0, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("RX2 CLK", MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			    1, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("RX3 CLK", MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-			    2, 0, msm_anlg_cdc_codec_enable_dig_clk,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("CP", MSM89XX_PMIC_ANALOG_NCP_EN, 0, 0,
-			    msm_anlg_cdc_codec_enable_charge_pump,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			    SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("EAR CP", MSM89XX_PMIC_ANALOG_NCP_EN, 4, 0,
-			    msm_anlg_cdc_codec_enable_charge_pump,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			    SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY_S("RX_BIAS", 1, SND_SOC_NOPM,
-		0, 0, msm_anlg_cdc_codec_enable_rx_bias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY_S("SPK_RX_BIAS", 1, SND_SOC_NOPM, 0, 0,
-		msm_anlg_cdc_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0,
-			    sdm660_wcd_codec_enable_vdd_spkr,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("INT_LDO_H", SND_SOC_NOPM, 1, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
-		ON_DEMAND_MICBIAS, 0,
-		msm_anlg_cdc_codec_enable_on_demand_supply,
-		SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS Internal1",
-		MSM89XX_PMIC_ANALOG_MICB_1_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS Internal2",
-		MSM89XX_PMIC_ANALOG_MICB_2_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS Internal3",
-		MSM89XX_PMIC_ANALOG_MICB_1_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("ADC1", NULL, MSM89XX_PMIC_ANALOG_TX_1_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("ADC2_INP2",
-		NULL, MSM89XX_PMIC_ANALOG_TX_2_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("ADC2_INP3",
-		NULL, MSM89XX_PMIC_ANALOG_TX_3_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS External",
-		MSM89XX_PMIC_ANALOG_MICB_1_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS External2",
-		MSM89XX_PMIC_ANALOG_MICB_2_EN, 7, 0,
-		msm_anlg_cdc_codec_enable_micbias, SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_INPUT("AMIC1"),
-	SND_SOC_DAPM_INPUT("AMIC2"),
-	SND_SOC_DAPM_INPUT("AMIC3"),
-	SND_SOC_DAPM_AIF_IN("PDM_IN_RX1", "PDM Playback",
-		0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PDM_IN_RX2", "PDM Playback",
-		0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PDM_IN_RX3", "PDM Playback",
-		0, SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_OUTPUT("EAR"),
-	SND_SOC_DAPM_OUTPUT("WSA_SPK OUT"),
-	SND_SOC_DAPM_OUTPUT("HEADPHONE"),
-	SND_SOC_DAPM_OUTPUT("SPK_OUT"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT"),
-	SND_SOC_DAPM_AIF_OUT("ADC1_OUT", "PDM Capture",
-		0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("ADC2_OUT", "PDM Capture",
-		0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("ADC3_OUT", "PDM Capture",
-		0, SND_SOC_NOPM, 0, 0),
-};
-
-static const struct sdm660_cdc_reg_mask_val msm_anlg_cdc_reg_defaults[] = {
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x03),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0x82),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1),
-};
-
-static const struct sdm660_cdc_reg_mask_val
-					msm_anlg_cdc_reg_defaults_2_0[] = {
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS, 0x4F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0x28),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL, 0x69),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG, 0x01),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_BOOST_EN_CTL, 0x5F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SLOPE_COMP_IP_ZERO, 0x88),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0x82),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x03),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80),
-};
-
-static const struct sdm660_cdc_reg_mask_val conga_wcd_reg_defaults[] = {
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS, 0x4C),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0x28),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL, 0x69),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG, 0x01),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_PERPH_SUBTYPE, 0x0A),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x03),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80),
-};
-
-static const struct sdm660_cdc_reg_mask_val cajon_wcd_reg_defaults[] = {
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS, 0x4C),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0x82),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0xA8),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_VCTRL, 0xA4),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_ANA_BIAS_SET, 0x41),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL, 0x69),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG, 0x01),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x03),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_PA, 0xFA),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80),
-};
-
-static const struct sdm660_cdc_reg_mask_val cajon2p0_wcd_reg_defaults[] = {
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0xA5),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x0F),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS, 0x4C),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0xA2),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0xA8),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_NCP_VCTRL, 0xA4),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_ANA_BIAS_SET, 0x41),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL, 0x69),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG, 0x01),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x03),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_RX_EAR_STATUS, 0x10),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_BYPASS_MODE, 0x18),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_PA, 0xFA),
-	MSM89XX_REG_VAL(MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80),
-};
-
-static void msm_anlg_cdc_update_reg_defaults(struct snd_soc_codec *codec)
-{
-	u32 i, version;
-	struct sdm660_cdc_priv *sdm660_cdc =
-					snd_soc_codec_get_drvdata(codec);
-
-	version = get_codec_version(sdm660_cdc);
-	if (version == TOMBAK_1_0) {
-		for (i = 0; i < ARRAY_SIZE(msm_anlg_cdc_reg_defaults); i++)
-			snd_soc_write(codec, msm_anlg_cdc_reg_defaults[i].reg,
-					msm_anlg_cdc_reg_defaults[i].val);
-	} else if (version == TOMBAK_2_0) {
-		for (i = 0; i < ARRAY_SIZE(msm_anlg_cdc_reg_defaults_2_0); i++)
-			snd_soc_write(codec,
-				msm_anlg_cdc_reg_defaults_2_0[i].reg,
-				msm_anlg_cdc_reg_defaults_2_0[i].val);
-	} else if (version == CONGA) {
-		for (i = 0; i < ARRAY_SIZE(conga_wcd_reg_defaults); i++)
-			snd_soc_write(codec,
-				conga_wcd_reg_defaults[i].reg,
-				conga_wcd_reg_defaults[i].val);
-	} else if (version == CAJON) {
-		for (i = 0; i < ARRAY_SIZE(cajon_wcd_reg_defaults); i++)
-			snd_soc_write(codec,
-				cajon_wcd_reg_defaults[i].reg,
-				cajon_wcd_reg_defaults[i].val);
-	} else if (version == CAJON_2_0 || version == DIANGU
-				|| version == DRAX_CDC) {
-		for (i = 0; i < ARRAY_SIZE(cajon2p0_wcd_reg_defaults); i++)
-			snd_soc_write(codec,
-				cajon2p0_wcd_reg_defaults[i].reg,
-				cajon2p0_wcd_reg_defaults[i].val);
-	}
-}
-
-static const struct sdm660_cdc_reg_mask_val
-	msm_anlg_cdc_codec_reg_init_val[] = {
-
-	/* Initialize current threshold to 350MA
-	 * number of wait and run cycles to 4096
-	 */
-	{MSM89XX_PMIC_ANALOG_RX_COM_OCP_CTL, 0xFF, 0x12},
-	{MSM89XX_PMIC_ANALOG_RX_COM_OCP_COUNT, 0xFF, 0xFF},
-};
-
-static void msm_anlg_cdc_codec_init_cache(struct snd_soc_codec *codec)
-{
-	u32 i;
-
-	regcache_cache_only(codec->component.regmap, true);
-	/* update cache with POR values */
-	for (i = 0; i < ARRAY_SIZE(msm89xx_pmic_cdc_defaults); i++)
-		snd_soc_write(codec, msm89xx_pmic_cdc_defaults[i].reg,
-			      msm89xx_pmic_cdc_defaults[i].def);
-	regcache_cache_only(codec->component.regmap, false);
-}
-
-static void msm_anlg_cdc_codec_init_reg(struct snd_soc_codec *codec)
-{
-	u32 i;
-
-	for (i = 0; i < ARRAY_SIZE(msm_anlg_cdc_codec_reg_init_val); i++)
-		snd_soc_update_bits(codec,
-				    msm_anlg_cdc_codec_reg_init_val[i].reg,
-				    msm_anlg_cdc_codec_reg_init_val[i].mask,
-				    msm_anlg_cdc_codec_reg_init_val[i].val);
-}
-
-static int msm_anlg_cdc_bringup(struct snd_soc_codec *codec)
-{
-	snd_soc_write(codec,
-		MSM89XX_PMIC_DIGITAL_SEC_ACCESS,
-		0xA5);
-	snd_soc_write(codec, MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL4, 0x01);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_SEC_ACCESS,
-		0xA5);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL4, 0x01);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_DIGITAL_SEC_ACCESS,
-		0xA5);
-	snd_soc_write(codec, MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL4, 0x00);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_SEC_ACCESS,
-		0xA5);
-	snd_soc_write(codec, MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL4, 0x00);
-
-	return 0;
-}
-
-static struct regulator *msm_anlg_cdc_find_regulator(
-				const struct sdm660_cdc_priv *sdm660_cdc,
-				const char *name)
-{
-	int i;
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (sdm660_cdc->supplies[i].supply &&
-		    !strcmp(sdm660_cdc->supplies[i].supply, name))
-			return sdm660_cdc->supplies[i].consumer;
-	}
-
-	dev_err(sdm660_cdc->dev, "Error: regulator not found:%s\n"
-				, name);
-	return NULL;
-}
-
-static void msm_anlg_cdc_update_micbias_regulator(
-				const struct sdm660_cdc_priv *sdm660_cdc,
-				const char *name,
-				struct on_demand_supply *micbias_supply)
-{
-	int i;
-	struct sdm660_cdc_pdata *pdata = sdm660_cdc->dev->platform_data;
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (sdm660_cdc->supplies[i].supply &&
-		    !strcmp(sdm660_cdc->supplies[i].supply, name)) {
-			micbias_supply->supply =
-				sdm660_cdc->supplies[i].consumer;
-			micbias_supply->min_uv = pdata->regulator[i].min_uv;
-			micbias_supply->max_uv = pdata->regulator[i].max_uv;
-			micbias_supply->optimum_ua =
-					pdata->regulator[i].optimum_ua;
-			return;
-		}
-	}
-
-	dev_err(sdm660_cdc->dev, "Error: regulator not found:%s\n", name);
-}
-
-static int msm_anlg_cdc_device_down(struct snd_soc_codec *codec)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-		snd_soc_codec_get_drvdata(codec);
-	unsigned int tx_1_en;
-	unsigned int tx_2_en;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	dev_dbg(codec->dev, "%s: device down!\n", __func__);
-
-	tx_1_en = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_TX_1_EN);
-	tx_2_en = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_TX_2_EN);
-	tx_1_en = tx_1_en & 0x7f;
-	tx_2_en = tx_2_en & 0x7f;
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_TX_1_EN, tx_1_en);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_TX_2_EN, tx_2_en);
-	if (sdm660_cdc_priv->boost_option == BOOST_ON_FOREVER) {
-		if ((snd_soc_read(codec, MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL)
-			& 0x80) == 0) {
-			msm_anlg_cdc_dig_notifier_call(codec,
-						       DIG_CDC_EVENT_CLK_ON);
-			snd_soc_write(codec,
-				MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL, 0x30);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x80, 0x80);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL,
-				0x0C, 0x0C);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL,
-				0x84, 0x84);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL,
-				0x10, 0x10);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL,
-				0x1F, 0x1F);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC,
-				0x90, 0x90);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_RX_EAR_CTL,
-				0xFF, 0xFF);
-			/* Wait for 20us for boost settings to take effect */
-			usleep_range(20, 21);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL,
-				0xFF, 0xFF);
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-				0xE9, 0xE9);
-		}
-	}
-	msm_anlg_cdc_boost_off(codec);
-	sdm660_cdc_priv->hph_mode = NORMAL_MODE;
-
-	/* 40ms to allow boost to discharge */
-	msleep(40);
-	/* Disable PA to avoid pop during codec bring up */
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN,
-			0x30, 0x00);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL,
-			0x80, 0x00);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL, 0x20);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL, 0x20);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_RX_EAR_CTL, 0x12);
-	snd_soc_write(codec,
-		MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x93);
-
-	msm_anlg_cdc_dig_notifier_call(codec, DIG_CDC_EVENT_SSR_DOWN);
-	atomic_set(&pdata->int_mclk0_enabled, false);
-	set_bit(BUS_DOWN, &sdm660_cdc_priv->status_mask);
-	snd_soc_card_change_online_state(codec->component.card, 0);
-
-	return 0;
-}
-
-static int msm_anlg_cdc_device_up(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-		snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: device up!\n", __func__);
-
-	msm_anlg_cdc_dig_notifier_call(codec, DIG_CDC_EVENT_SSR_UP);
-	clear_bit(BUS_DOWN, &sdm660_cdc_priv->status_mask);
-	snd_soc_card_change_online_state(codec->component.card, 1);
-	/* delay is required to make sure sound card state updated */
-	usleep_range(5000, 5100);
-
-	snd_soc_write(codec, MSM89XX_PMIC_DIGITAL_INT_EN_SET,
-				MSM89XX_PMIC_DIGITAL_INT_EN_SET__POR);
-	snd_soc_write(codec, MSM89XX_PMIC_DIGITAL_INT_EN_CLR,
-				MSM89XX_PMIC_DIGITAL_INT_EN_CLR__POR);
-
-	msm_anlg_cdc_set_boost_v(codec);
-	msm_anlg_cdc_set_micb_v(codec);
-	if (sdm660_cdc_priv->boost_option == BOOST_ON_FOREVER)
-		msm_anlg_cdc_boost_on(codec);
-	else if (sdm660_cdc_priv->boost_option == BYPASS_ALWAYS)
-		msm_anlg_cdc_bypass_on(codec);
-
-	return 0;
-}
-
-static int sdm660_cdc_notifier_service_cb(struct notifier_block *nb,
-					     unsigned long opcode, void *ptr)
-{
-	struct snd_soc_codec *codec;
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-				container_of(nb, struct sdm660_cdc_priv,
-					     audio_ssr_nb);
-	bool adsp_ready = false;
-	bool timedout;
-	unsigned long timeout;
-	static bool initial_boot = true;
-
-	codec = sdm660_cdc_priv->codec;
-	dev_dbg(codec->dev, "%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		if (initial_boot) {
-			initial_boot = false;
-			break;
-		}
-		dev_dbg(codec->dev,
-			"ADSP is about to power down. teardown/reset codec\n");
-		msm_anlg_cdc_device_down(codec);
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (initial_boot)
-			initial_boot = false;
-		dev_dbg(codec->dev,
-			"ADSP is about to power up. bring up codec\n");
-
-		if (!q6core_is_adsp_ready()) {
-			dev_dbg(codec->dev,
-				"ADSP isn't ready\n");
-			timeout = jiffies +
-				  msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
-			while (!(timedout = time_after(jiffies, timeout))) {
-				if (!q6core_is_adsp_ready()) {
-					dev_dbg(codec->dev,
-						"ADSP isn't ready\n");
-				} else {
-					dev_dbg(codec->dev,
-						"ADSP is ready\n");
-					adsp_ready = true;
-					goto powerup;
-				}
-			}
-		} else {
-			adsp_ready = true;
-			dev_dbg(codec->dev, "%s: DSP is ready\n", __func__);
-		}
-powerup:
-		if (adsp_ready)
-			msm_anlg_cdc_device_up(codec);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-int msm_anlg_cdc_hs_detect(struct snd_soc_codec *codec,
-			   struct wcd_mbhc_config *mbhc_cfg)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-		snd_soc_codec_get_drvdata(codec);
-
-	return wcd_mbhc_start(&sdm660_cdc_priv->mbhc, mbhc_cfg);
-}
-EXPORT_SYMBOL(msm_anlg_cdc_hs_detect);
-
-void msm_anlg_cdc_hs_detect_exit(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-		snd_soc_codec_get_drvdata(codec);
-
-	wcd_mbhc_stop(&sdm660_cdc_priv->mbhc);
-}
-EXPORT_SYMBOL(msm_anlg_cdc_hs_detect_exit);
-
-void msm_anlg_cdc_update_int_spk_boost(bool enable)
-{
-	pr_debug("%s: enable = %d\n", __func__, enable);
-	spkr_boost_en = enable;
-}
-EXPORT_SYMBOL(msm_anlg_cdc_update_int_spk_boost);
-
-static void msm_anlg_cdc_set_micb_v(struct snd_soc_codec *codec)
-{
-
-	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-	struct sdm660_cdc_pdata *pdata = sdm660_cdc->dev->platform_data;
-	u8 reg_val;
-
-	reg_val = VOLTAGE_CONVERTER(pdata->micbias.cfilt1_mv, MICBIAS_MIN_VAL,
-			MICBIAS_STEP_SIZE);
-	dev_dbg(codec->dev, "cfilt1_mv %d reg_val %x\n",
-			(u32)pdata->micbias.cfilt1_mv, reg_val);
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_VAL,
-			0xF8, (reg_val << 3));
-}
-
-static void msm_anlg_cdc_set_boost_v(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-				snd_soc_codec_get_drvdata(codec);
-
-	snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_OUTPUT_VOLTAGE,
-			0x1F, sdm660_cdc_priv->boost_voltage);
-}
-
-static void msm_anlg_cdc_configure_cap(struct snd_soc_codec *codec,
-				       bool micbias1, bool micbias2)
-{
-
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-
-	pr_debug("\n %s: micbias1 %x micbias2 = %d\n", __func__, micbias1,
-			micbias2);
-	if (micbias1 && micbias2) {
-		if ((pdata->micbias1_cap_mode
-		     == MICBIAS_EXT_BYP_CAP) ||
-		    (pdata->micbias2_cap_mode
-		     == MICBIAS_EXT_BYP_CAP))
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_1_EN,
-				0x40, (MICBIAS_EXT_BYP_CAP << 6));
-		else
-			snd_soc_update_bits(codec,
-				MSM89XX_PMIC_ANALOG_MICB_1_EN,
-				0x40, (MICBIAS_NO_EXT_BYP_CAP << 6));
-	} else if (micbias2) {
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
-				0x40, (pdata->micbias2_cap_mode << 6));
-	} else if (micbias1) {
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
-				0x40, (pdata->micbias1_cap_mode << 6));
-	} else {
-		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
-				0x40, 0x00);
-	}
-}
-
-static ssize_t msm_anlg_codec_version_read(struct snd_info_entry *entry,
-					   void *file_private_data,
-					   struct file *file,
-					   char __user *buf, size_t count,
-					   loff_t pos)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv;
-	char buffer[MSM_ANLG_CDC_VERSION_ENTRY_SIZE];
-	int len = 0;
-
-	sdm660_cdc_priv = (struct sdm660_cdc_priv *) entry->private_data;
-	if (!sdm660_cdc_priv) {
-		pr_err("%s: sdm660_cdc_priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (get_codec_version(sdm660_cdc_priv)) {
-	case DRAX_CDC:
-		len = snprintf(buffer, sizeof(buffer), "DRAX-CDC_1_0\n");
-		break;
-	default:
-		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-	}
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops msm_anlg_codec_info_ops = {
-	.read = msm_anlg_codec_version_read,
-};
-
-/*
- * msm_anlg_codec_info_create_codec_entry - creates pmic_analog module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates pmic_analog module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int msm_anlg_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					   struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct sdm660_cdc_priv *sdm660_cdc_priv;
-	struct snd_soc_card *card;
-	int ret;
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	sdm660_cdc_priv = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-	sdm660_cdc_priv->entry = snd_info_create_subdir(codec_root->module,
-							     "spmi0-03",
-							     codec_root);
-	if (!sdm660_cdc_priv->entry) {
-		dev_dbg(codec->dev, "%s: failed to create pmic_analog entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   sdm660_cdc_priv->entry);
-	if (!version_entry) {
-		dev_dbg(codec->dev, "%s: failed to create pmic_analog version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = sdm660_cdc_priv;
-	version_entry->size = MSM_ANLG_CDC_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &msm_anlg_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	sdm660_cdc_priv->version_entry = version_entry;
-
-	sdm660_cdc_priv->audio_ssr_nb.notifier_call =
-				sdm660_cdc_notifier_service_cb;
-	ret = audio_notifier_register("pmic_analog_cdc",
-				      AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &sdm660_cdc_priv->audio_ssr_nb);
-	if (ret < 0) {
-		pr_err("%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-		return ret;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(msm_anlg_codec_info_create_codec_entry);
-
-static int msm_anlg_cdc_soc_probe(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	int ret;
-
-	sdm660_cdc = dev_get_drvdata(codec->dev);
-	sdm660_cdc->codec = codec;
-
-	/* codec resmgr module init */
-	sdm660_cdc->spkdrv_reg =
-				msm_anlg_cdc_find_regulator(sdm660_cdc,
-						MSM89XX_VDD_SPKDRV_NAME);
-	sdm660_cdc->pmic_rev =
-				snd_soc_read(codec,
-					     MSM89XX_PMIC_DIGITAL_REVISION1);
-	sdm660_cdc->codec_version =
-				snd_soc_read(codec,
-					MSM89XX_PMIC_DIGITAL_PERPH_SUBTYPE);
-	sdm660_cdc->analog_major_rev =
-				snd_soc_read(codec,
-					     MSM89XX_PMIC_ANALOG_REVISION4);
-
-	if (sdm660_cdc->codec_version == CONGA) {
-		dev_dbg(codec->dev, "%s :Conga REV: %d\n", __func__,
-					sdm660_cdc->codec_version);
-		sdm660_cdc->ext_spk_boost_set = true;
-	} else {
-		dev_dbg(codec->dev, "%s :PMIC REV: %d\n", __func__,
-					sdm660_cdc->pmic_rev);
-		if (sdm660_cdc->pmic_rev == TOMBAK_1_0 &&
-			sdm660_cdc->codec_version == CAJON_2_0) {
-			if (sdm660_cdc->analog_major_rev == 0x02) {
-				sdm660_cdc->codec_version = DRAX_CDC;
-				dev_dbg(codec->dev,
-					"%s : Drax codec detected\n", __func__);
-			} else {
-				sdm660_cdc->codec_version = DIANGU;
-				dev_dbg(codec->dev, "%s : Diangu detected\n",
-					__func__);
-			}
-		} else if (sdm660_cdc->pmic_rev == TOMBAK_1_0 &&
-			(snd_soc_read(codec, MSM89XX_PMIC_ANALOG_NCP_FBCTRL)
-			 & 0x80)) {
-			sdm660_cdc->codec_version = CAJON;
-			dev_dbg(codec->dev, "%s : Cajon detected\n", __func__);
-		} else if (sdm660_cdc->pmic_rev == TOMBAK_2_0 &&
-			(snd_soc_read(codec, MSM89XX_PMIC_ANALOG_NCP_FBCTRL)
-			 & 0x80)) {
-			sdm660_cdc->codec_version = CAJON_2_0;
-			dev_dbg(codec->dev, "%s : Cajon 2.0 detected\n",
-						__func__);
-		}
-	}
-	/*
-	 * set to default boost option BOOST_SWITCH, user mixer path can change
-	 * it to BOOST_ALWAYS or BOOST_BYPASS based on solution chosen.
-	 */
-	sdm660_cdc->boost_option = BOOST_SWITCH;
-	sdm660_cdc->hph_mode = NORMAL_MODE;
-
-	msm_anlg_cdc_dt_parse_boost_info(codec);
-	msm_anlg_cdc_set_boost_v(codec);
-
-	snd_soc_add_codec_controls(codec, impedance_detect_controls,
-				   ARRAY_SIZE(impedance_detect_controls));
-	snd_soc_add_codec_controls(codec, hph_type_detect_controls,
-				  ARRAY_SIZE(hph_type_detect_controls));
-
-	msm_anlg_cdc_bringup(codec);
-	msm_anlg_cdc_codec_init_cache(codec);
-	msm_anlg_cdc_codec_init_reg(codec);
-	msm_anlg_cdc_update_reg_defaults(codec);
-
-	wcd9xxx_spmi_set_codec(codec);
-
-	msm_anlg_cdc_update_micbias_regulator(
-				sdm660_cdc,
-				on_demand_supply_name[ON_DEMAND_MICBIAS],
-				&sdm660_cdc->on_demand_list[ON_DEMAND_MICBIAS]);
-	atomic_set(&sdm660_cdc->on_demand_list[ON_DEMAND_MICBIAS].ref,
-		   0);
-
-	sdm660_cdc->fw_data = devm_kzalloc(codec->dev,
-					sizeof(*(sdm660_cdc->fw_data)),
-					GFP_KERNEL);
-	if (!sdm660_cdc->fw_data)
-		return -ENOMEM;
-
-	set_bit(WCD9XXX_MBHC_CAL, sdm660_cdc->fw_data->cal_bit);
-	ret = wcd_cal_create_hwdep(sdm660_cdc->fw_data,
-			WCD9XXX_CODEC_HWDEP_NODE, codec);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	wcd_mbhc_init(&sdm660_cdc->mbhc, codec, &mbhc_cb, &intr_ids,
-		      wcd_mbhc_registers, true);
-
-	sdm660_cdc->int_mclk0_enabled = false;
-	/*Update speaker boost configuration*/
-	sdm660_cdc->spk_boost_set = spkr_boost_en;
-	pr_debug("%s: speaker boost configured = %d\n",
-			__func__, sdm660_cdc->spk_boost_set);
-
-	/* Set initial MICBIAS voltage level */
-	msm_anlg_cdc_set_micb_v(codec);
-
-	/* Set initial cap mode */
-	msm_anlg_cdc_configure_cap(codec, false, false);
-
-	snd_soc_dapm_ignore_suspend(dapm, "PDM Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "PDM Capture");
-
-	snd_soc_dapm_sync(dapm);
-
-	return 0;
-}
-
-static int msm_anlg_cdc_soc_remove(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc_priv =
-					dev_get_drvdata(codec->dev);
-
-	sdm660_cdc_priv->spkdrv_reg = NULL;
-	sdm660_cdc_priv->on_demand_list[ON_DEMAND_MICBIAS].supply = NULL;
-	atomic_set(&sdm660_cdc_priv->on_demand_list[ON_DEMAND_MICBIAS].ref,
-		   0);
-	wcd_mbhc_deinit(&sdm660_cdc_priv->mbhc);
-
-	return 0;
-}
-
-static int msm_anlg_cdc_enable_static_supplies_to_optimum(
-				struct sdm660_cdc_priv *sdm660_cdc,
-				struct sdm660_cdc_pdata *pdata)
-{
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (pdata->regulator[i].ondemand)
-			continue;
-		if (regulator_count_voltages(
-				sdm660_cdc->supplies[i].consumer) <= 0)
-			continue;
-
-		ret = regulator_set_voltage(
-				sdm660_cdc->supplies[i].consumer,
-				pdata->regulator[i].min_uv,
-				pdata->regulator[i].max_uv);
-		if (ret) {
-			dev_err(sdm660_cdc->dev,
-				"Setting volt failed for regulator %s err %d\n",
-				sdm660_cdc->supplies[i].supply, ret);
-		}
-
-		ret = regulator_set_load(sdm660_cdc->supplies[i].consumer,
-			pdata->regulator[i].optimum_ua);
-		dev_dbg(sdm660_cdc->dev, "Regulator %s set optimum mode\n",
-			 sdm660_cdc->supplies[i].supply);
-	}
-
-	return ret;
-}
-
-static int msm_anlg_cdc_disable_static_supplies_to_optimum(
-			struct sdm660_cdc_priv *sdm660_cdc,
-			struct sdm660_cdc_pdata *pdata)
-{
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (pdata->regulator[i].ondemand)
-			continue;
-		if (regulator_count_voltages(
-				sdm660_cdc->supplies[i].consumer) <= 0)
-			continue;
-		regulator_set_voltage(sdm660_cdc->supplies[i].consumer, 0,
-				pdata->regulator[i].max_uv);
-		regulator_set_load(sdm660_cdc->supplies[i].consumer, 0);
-		dev_dbg(sdm660_cdc->dev, "Regulator %s set optimum mode\n",
-				 sdm660_cdc->supplies[i].supply);
-	}
-
-	return ret;
-}
-
-static int msm_anlg_cdc_suspend(struct snd_soc_codec *codec)
-{
-	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-	struct sdm660_cdc_pdata *sdm660_cdc_pdata =
-					sdm660_cdc->dev->platform_data;
-
-	msm_anlg_cdc_disable_static_supplies_to_optimum(sdm660_cdc,
-							sdm660_cdc_pdata);
-	return 0;
-}
-
-static int msm_anlg_cdc_resume(struct snd_soc_codec *codec)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
-	struct sdm660_cdc_pdata *sdm660_cdc_pdata =
-					sdm660_cdc->dev->platform_data;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	msm_anlg_cdc_enable_static_supplies_to_optimum(sdm660_cdc,
-						       sdm660_cdc_pdata);
-	return 0;
-}
-
-static struct regmap *msm_anlg_get_regmap(struct device *dev)
-{
-	return dev_get_regmap(dev->parent, NULL);
-}
-
-static struct snd_soc_codec_driver soc_codec_dev_sdm660_cdc = {
-	.probe	= msm_anlg_cdc_soc_probe,
-	.remove	= msm_anlg_cdc_soc_remove,
-	.suspend = msm_anlg_cdc_suspend,
-	.resume = msm_anlg_cdc_resume,
-	.reg_word_size = 1,
-	.get_regmap = msm_anlg_get_regmap,
-	.component_driver = {
-		.controls = msm_anlg_cdc_snd_controls,
-		.num_controls = ARRAY_SIZE(msm_anlg_cdc_snd_controls),
-		.dapm_widgets = msm_anlg_cdc_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(msm_anlg_cdc_dapm_widgets),
-		.dapm_routes = audio_map,
-		.num_dapm_routes = ARRAY_SIZE(audio_map),
-	},
-};
-
-static int msm_anlg_cdc_init_supplies(struct sdm660_cdc_priv *sdm660_cdc,
-				struct sdm660_cdc_pdata *pdata)
-{
-	int ret;
-	int i;
-
-	sdm660_cdc->supplies = devm_kzalloc(sdm660_cdc->dev,
-					sizeof(struct regulator_bulk_data) *
-					ARRAY_SIZE(pdata->regulator),
-					GFP_KERNEL);
-	if (!sdm660_cdc->supplies) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	sdm660_cdc->num_of_supplies = 0;
-	if (ARRAY_SIZE(pdata->regulator) > MAX_REGULATOR) {
-		dev_err(sdm660_cdc->dev, "%s: Array Size out of bound\n",
-			__func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) {
-		if (pdata->regulator[i].name) {
-			sdm660_cdc->supplies[i].supply =
-						pdata->regulator[i].name;
-			sdm660_cdc->num_of_supplies++;
-		}
-	}
-
-	ret = devm_regulator_bulk_get(sdm660_cdc->dev,
-				      sdm660_cdc->num_of_supplies,
-				      sdm660_cdc->supplies);
-	if (ret != 0) {
-		dev_err(sdm660_cdc->dev,
-			"Failed to get supplies: err = %d\n",
-			ret);
-		goto err_supplies;
-	}
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (regulator_count_voltages(
-			sdm660_cdc->supplies[i].consumer) <= 0)
-			continue;
-		if (pdata->regulator[i].ondemand) {
-			ret = regulator_set_voltage(
-					sdm660_cdc->supplies[i].consumer,
-					0, pdata->regulator[i].max_uv);
-			if (ret) {
-				dev_err(sdm660_cdc->dev,
-					"Setting regulator voltage failed for regulator %s err = %d\n",
-					sdm660_cdc->supplies[i].supply, ret);
-				goto err_supplies;
-			}
-			ret = regulator_set_load(
-				sdm660_cdc->supplies[i].consumer, 0);
-			if (ret < 0) {
-				dev_err(sdm660_cdc->dev,
-					"Setting regulator optimum mode failed for regulator %s err = %d\n",
-					sdm660_cdc->supplies[i].supply, ret);
-				goto err_supplies;
-			} else {
-				ret = 0;
-				continue;
-			}
-		}
-		ret = regulator_set_voltage(sdm660_cdc->supplies[i].consumer,
-					    pdata->regulator[i].min_uv,
-					    pdata->regulator[i].max_uv);
-		if (ret) {
-			dev_err(sdm660_cdc->dev,
-				"Setting regulator voltage failed for regulator %s err = %d\n",
-				sdm660_cdc->supplies[i].supply, ret);
-			goto err_supplies;
-		}
-		ret = regulator_set_load(sdm660_cdc->supplies[i].consumer,
-					 pdata->regulator[i].optimum_ua);
-		if (ret < 0) {
-			dev_err(sdm660_cdc->dev,
-				"Setting regulator optimum mode failed for regulator %s err = %d\n",
-				sdm660_cdc->supplies[i].supply, ret);
-			goto err_supplies;
-		} else {
-			ret = 0;
-		}
-	}
-
-	return ret;
-
-err_supplies:
-	kfree(sdm660_cdc->supplies);
-err:
-	return ret;
-}
-
-static int msm_anlg_cdc_enable_static_supplies(
-					struct sdm660_cdc_priv *sdm660_cdc,
-					struct sdm660_cdc_pdata *pdata)
-{
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (pdata->regulator[i].ondemand)
-			continue;
-		ret = regulator_enable(sdm660_cdc->supplies[i].consumer);
-		if (ret) {
-			dev_err(sdm660_cdc->dev, "Failed to enable %s\n",
-			       sdm660_cdc->supplies[i].supply);
-			break;
-		}
-		dev_dbg(sdm660_cdc->dev, "Enabled regulator %s\n",
-				 sdm660_cdc->supplies[i].supply);
-	}
-
-	while (ret && --i)
-		if (!pdata->regulator[i].ondemand)
-			regulator_disable(sdm660_cdc->supplies[i].consumer);
-	return ret;
-}
-
-static void msm_anlg_cdc_disable_supplies(struct sdm660_cdc_priv *sdm660_cdc,
-				     struct sdm660_cdc_pdata *pdata)
-{
-	int i;
-
-	regulator_bulk_disable(sdm660_cdc->num_of_supplies,
-			       sdm660_cdc->supplies);
-	for (i = 0; i < sdm660_cdc->num_of_supplies; i++) {
-		if (regulator_count_voltages(
-				sdm660_cdc->supplies[i].consumer) <= 0)
-			continue;
-		regulator_set_voltage(sdm660_cdc->supplies[i].consumer, 0,
-				pdata->regulator[i].max_uv);
-		regulator_set_load(sdm660_cdc->supplies[i].consumer, 0);
-	}
-	regulator_bulk_free(sdm660_cdc->num_of_supplies,
-			    sdm660_cdc->supplies);
-	kfree(sdm660_cdc->supplies);
-}
-
-static const struct of_device_id sdm660_codec_of_match[] = {
-	{ .compatible = "qcom,pmic-analog-codec", },
-	{},
-};
-
-static void msm_anlg_add_child_devices(struct work_struct *work)
-{
-	struct sdm660_cdc_priv *pdata;
-	struct platform_device *pdev;
-	struct device_node *node;
-	struct msm_dig_ctrl_data *dig_ctrl_data = NULL, *temp;
-	int ret, ctrl_num = 0;
-	struct msm_dig_ctrl_platform_data *platdata;
-	char plat_dev_name[MSM_DIG_CDC_STRING_LEN];
-
-	pdata = container_of(work, struct sdm660_cdc_priv,
-			     msm_anlg_add_child_devices_work);
-	if (!pdata) {
-		pr_err("%s: Memory for pdata does not exist\n",
-			__func__);
-		return;
-	}
-	if (!pdata->dev->of_node) {
-		dev_err(pdata->dev,
-			"%s: DT node for pdata does not exist\n", __func__);
-		return;
-	}
-
-	platdata = &pdata->dig_plat_data;
-
-	for_each_child_of_node(pdata->dev->of_node, node) {
-		if (!strcmp(node->name, "msm-dig-codec"))
-			strlcpy(plat_dev_name, "msm_digital_codec",
-				(MSM_DIG_CDC_STRING_LEN - 1));
-		else
-			continue;
-
-		pdev = platform_device_alloc(plat_dev_name, -1);
-		if (!pdev) {
-			dev_err(pdata->dev, "%s: pdev memory alloc failed\n",
-				__func__);
-			ret = -ENOMEM;
-			goto err;
-		}
-		pdev->dev.parent = pdata->dev;
-		pdev->dev.of_node = node;
-
-		if (!strcmp(node->name, "msm-dig-codec")) {
-			ret = platform_device_add_data(pdev, platdata,
-						       sizeof(*platdata));
-			if (ret) {
-				dev_err(&pdev->dev,
-					"%s: cannot add plat data ctrl:%d\n",
-					__func__, ctrl_num);
-				goto fail_pdev_add;
-			}
-		}
-
-		ret = platform_device_add(pdev);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: Cannot add platform device\n",
-				__func__);
-			goto fail_pdev_add;
-		}
-
-		if (!strcmp(node->name, "msm-dig-codec")) {
-			temp = krealloc(dig_ctrl_data,
-					(ctrl_num + 1) * sizeof(
-					struct msm_dig_ctrl_data),
-					GFP_KERNEL);
-			if (!temp) {
-				dev_err(&pdev->dev, "out of memory\n");
-				ret = -ENOMEM;
-				goto err;
-			}
-			dig_ctrl_data = temp;
-			dig_ctrl_data[ctrl_num].dig_pdev = pdev;
-			ctrl_num++;
-			dev_dbg(&pdev->dev,
-				"%s: Added digital codec device(s)\n",
-				__func__);
-			pdata->dig_ctrl_data = dig_ctrl_data;
-		}
-	}
-
-	return;
-fail_pdev_add:
-	platform_device_put(pdev);
-err:
-	return;
-}
-
-static int msm_anlg_cdc_probe(struct platform_device *pdev)
-{
-	int ret = 0;
-	struct sdm660_cdc_priv *sdm660_cdc = NULL;
-	struct sdm660_cdc_pdata *pdata;
-	int adsp_state;
-
-	adsp_state = apr_get_subsys_state();
-	if (adsp_state != APR_SUBSYS_LOADED) {
-		dev_err(&pdev->dev, "Adsp is not loaded yet %d\n",
-			adsp_state);
-		return -EPROBE_DEFER;
-	}
-	device_init_wakeup(&pdev->dev, true);
-
-	if (pdev->dev.of_node) {
-		dev_dbg(&pdev->dev, "%s:Platform data from device tree\n",
-			__func__);
-		pdata = msm_anlg_cdc_populate_dt_pdata(&pdev->dev);
-		pdev->dev.platform_data = pdata;
-	} else {
-		dev_dbg(&pdev->dev, "%s:Platform data from board file\n",
-			__func__);
-		pdata = pdev->dev.platform_data;
-	}
-	if (pdata == NULL) {
-		dev_err(&pdev->dev, "%s:Platform data failed to populate\n",
-			__func__);
-		goto rtn;
-	}
-	sdm660_cdc = devm_kzalloc(&pdev->dev, sizeof(struct sdm660_cdc_priv),
-				     GFP_KERNEL);
-	if (sdm660_cdc == NULL) {
-		ret = -ENOMEM;
-		goto rtn;
-	}
-
-	sdm660_cdc->dev = &pdev->dev;
-	ret = msm_anlg_cdc_init_supplies(sdm660_cdc, pdata);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: Fail to enable Codec supplies\n",
-			__func__);
-		goto rtn;
-	}
-	ret = msm_anlg_cdc_enable_static_supplies(sdm660_cdc, pdata);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"%s: Fail to enable Codec pre-reset supplies\n",
-			__func__);
-		goto rtn;
-	}
-	/* Allow supplies to be ready */
-	usleep_range(5, 6);
-
-	wcd9xxx_spmi_set_dev(pdev, 0);
-	wcd9xxx_spmi_set_dev(pdev, 1);
-	if (wcd9xxx_spmi_irq_init()) {
-		dev_err(&pdev->dev,
-			"%s: irq initialization failed\n", __func__);
-	} else {
-		dev_dbg(&pdev->dev,
-			"%s: irq initialization passed\n", __func__);
-	}
-	dev_set_drvdata(&pdev->dev, sdm660_cdc);
-
-	ret = snd_soc_register_codec(&pdev->dev,
-				     &soc_codec_dev_sdm660_cdc,
-				     msm_anlg_cdc_i2s_dai,
-				     ARRAY_SIZE(msm_anlg_cdc_i2s_dai));
-	if (ret) {
-		dev_err(&pdev->dev,
-			"%s:snd_soc_register_codec failed with error %d\n",
-			__func__, ret);
-		goto err_supplies;
-	}
-	BLOCKING_INIT_NOTIFIER_HEAD(&sdm660_cdc->notifier);
-	BLOCKING_INIT_NOTIFIER_HEAD(&sdm660_cdc->notifier_mbhc);
-
-	sdm660_cdc->dig_plat_data.handle = (void *) sdm660_cdc;
-	sdm660_cdc->dig_plat_data.update_clkdiv = update_clkdiv;
-	sdm660_cdc->dig_plat_data.get_cdc_version = get_cdc_version;
-	sdm660_cdc->dig_plat_data.register_notifier =
-					msm_anlg_cdc_dig_register_notifier;
-	INIT_WORK(&sdm660_cdc->msm_anlg_add_child_devices_work,
-		  msm_anlg_add_child_devices);
-	schedule_work(&sdm660_cdc->msm_anlg_add_child_devices_work);
-
-	return ret;
-err_supplies:
-	msm_anlg_cdc_disable_supplies(sdm660_cdc, pdata);
-rtn:
-	return ret;
-}
-
-static int msm_anlg_cdc_remove(struct platform_device *pdev)
-{
-	struct sdm660_cdc_priv *sdm660_cdc = dev_get_drvdata(&pdev->dev);
-	struct sdm660_cdc_pdata *pdata = sdm660_cdc->dev->platform_data;
-
-	snd_soc_unregister_codec(&pdev->dev);
-	msm_anlg_cdc_disable_supplies(sdm660_cdc, pdata);
-	return 0;
-}
-
-static struct platform_driver msm_anlg_codec_driver = {
-	.driver		= {
-		.owner          = THIS_MODULE,
-		.name           = DRV_NAME,
-		.of_match_table = of_match_ptr(sdm660_codec_of_match)
-	},
-	.probe          = msm_anlg_cdc_probe,
-	.remove         = msm_anlg_cdc_remove,
-};
-module_platform_driver(msm_anlg_codec_driver);
-
-MODULE_DESCRIPTION("MSM Audio Analog codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.h b/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.h
deleted file mode 100644
index 9563565..0000000
--- a/sound/soc/codecs/sdm660_cdc/msm-analog-cdc.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 MSM_ANALOG_CDC_H
-#define MSM_ANALOG_CDC_H
-
-#include <sound/soc.h>
-#include <sound/jack.h>
-#include <sound/q6afe-v2.h>
-#include "../wcd-mbhc-v2.h"
-#include "../wcdcal-hwdep.h"
-#include "sdm660-cdc-registers.h"
-
-#define MICBIAS_EXT_BYP_CAP 0x00
-#define MICBIAS_NO_EXT_BYP_CAP 0x01
-
-#define MSM89XX_NUM_IRQ_REGS	2
-#define MAX_REGULATOR		7
-#define MSM89XX_REG_VAL(reg, val)	{reg, 0, val}
-
-#define MSM89XX_VDD_SPKDRV_NAME "cdc-vdd-spkdrv"
-
-#define DEFAULT_MULTIPLIER 800
-#define DEFAULT_GAIN 9
-#define DEFAULT_OFFSET 100
-
-extern const u8 msm89xx_pmic_cdc_reg_readable[MSM89XX_PMIC_CDC_CACHE_SIZE];
-extern const u8 msm89xx_cdc_core_reg_readable[MSM89XX_CDC_CORE_CACHE_SIZE];
-extern struct regmap_config msm89xx_cdc_core_regmap_config;
-extern struct regmap_config msm89xx_pmic_cdc_regmap_config;
-
-enum wcd_curr_ref {
-	I_h4_UA = 0,
-	I_pt5_UA,
-	I_14_UA,
-	I_l4_UA,
-	I_1_UA,
-};
-
-enum wcd_mbhc_imp_det_pin {
-	WCD_MBHC_DET_NONE = 0,
-	WCD_MBHC_DET_HPHL,
-	WCD_MBHC_DET_HPHR,
-	WCD_MBHC_DET_BOTH,
-};
-
-
-/* Each micbias can be assigned to one of three cfilters
- * Vbatt_min >= .15V + ldoh_v
- * ldoh_v >= .15v + cfiltx_mv
- * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
- * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
- * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
- * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
- */
-
-struct wcd_micbias_setting {
-	u8 ldoh_v;
-	u32 cfilt1_mv; /* in mv */
-	u32 cfilt2_mv; /* in mv */
-	u32 cfilt3_mv; /* in mv */
-	/* Different WCD9xxx series codecs may not
-	 * have 4 mic biases. If a codec has fewer
-	 * mic biases, some of these properties will
-	 * not be used.
-	 */
-	u8 bias1_cfilt_sel;
-	u8 bias2_cfilt_sel;
-	u8 bias3_cfilt_sel;
-	u8 bias4_cfilt_sel;
-	u8 bias1_cap_mode;
-	u8 bias2_cap_mode;
-	u8 bias3_cap_mode;
-	u8 bias4_cap_mode;
-	bool bias2_is_headset_only;
-};
-
-enum sdm660_cdc_pid_current {
-	MSM89XX_PID_MIC_2P5_UA,
-	MSM89XX_PID_MIC_5_UA,
-	MSM89XX_PID_MIC_10_UA,
-	MSM89XX_PID_MIC_20_UA,
-};
-
-struct sdm660_cdc_reg_mask_val {
-	u16	reg;
-	u8	mask;
-	u8	val;
-};
-
-enum {
-	/* INTR_REG 0 - Digital Periph */
-	MSM89XX_IRQ_SPKR_CNP = 0,
-	MSM89XX_IRQ_SPKR_CLIP,
-	MSM89XX_IRQ_SPKR_OCP,
-	MSM89XX_IRQ_MBHC_INSREM_DET1,
-	MSM89XX_IRQ_MBHC_RELEASE,
-	MSM89XX_IRQ_MBHC_PRESS,
-	MSM89XX_IRQ_MBHC_INSREM_DET,
-	MSM89XX_IRQ_MBHC_HS_DET,
-	/* INTR_REG 1 - Analog Periph */
-	MSM89XX_IRQ_EAR_OCP,
-	MSM89XX_IRQ_HPHR_OCP,
-	MSM89XX_IRQ_HPHL_OCP,
-	MSM89XX_IRQ_EAR_CNP,
-	MSM89XX_IRQ_HPHR_CNP,
-	MSM89XX_IRQ_HPHL_CNP,
-	MSM89XX_NUM_IRQS,
-};
-
-enum {
-	ON_DEMAND_MICBIAS = 0,
-	ON_DEMAND_SPKDRV,
-	ON_DEMAND_SUPPLIES_MAX,
-};
-
-/*
- * The delay list is per codec HW specification.
- * Please add delay in the list in the future instead
- * of magic number
- */
-enum {
-	CODEC_DELAY_1_MS = 1000,
-	CODEC_DELAY_1_1_MS  = 1100,
-};
-
-struct sdm660_cdc_regulator {
-	const char *name;
-	int min_uv;
-	int max_uv;
-	int optimum_ua;
-	bool ondemand;
-	struct regulator *regulator;
-};
-
-struct on_demand_supply {
-	struct regulator *supply;
-	atomic_t ref;
-	int min_uv;
-	int max_uv;
-	int optimum_ua;
-};
-
-struct wcd_imped_i_ref {
-	enum wcd_curr_ref curr_ref;
-	int min_val;
-	int multiplier;
-	int gain_adj;
-	int offset;
-};
-
-enum sdm660_cdc_micbias_num {
-	MSM89XX_MICBIAS1 = 0,
-};
-
-/* Hold instance to digital codec platform device */
-struct msm_dig_ctrl_data {
-	struct platform_device *dig_pdev;
-};
-
-struct msm_dig_ctrl_platform_data {
-	void *handle;
-	void (*update_clkdiv)(void *handle, int val);
-	int (*get_cdc_version)(void *handle);
-	int (*register_notifier)(void *handle,
-				 struct notifier_block *nblock,
-				 bool enable);
-};
-
-struct sdm660_cdc_priv {
-	struct device *dev;
-	u32 num_of_supplies;
-	struct regulator_bulk_data *supplies;
-	struct snd_soc_codec *codec;
-	struct work_struct msm_anlg_add_child_devices_work;
-	struct msm_dig_ctrl_platform_data dig_plat_data;
-	/* digital codec data structure */
-	struct msm_dig_ctrl_data *dig_ctrl_data;
-	struct blocking_notifier_head notifier;
-	u16 pmic_rev;
-	u16 codec_version;
-	u16 analog_major_rev;
-	u32 boost_voltage;
-	u32 adc_count;
-	u32 rx_bias_count;
-	bool int_mclk0_enabled;
-	u16 boost_option;
-	/* mode to select hd2 */
-	u32 hph_mode;
-	/* compander used for each rx chain */
-	bool spk_boost_set;
-	bool ear_pa_boost_set;
-	bool ext_spk_boost_set;
-	struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
-	struct regulator *spkdrv_reg;
-	struct blocking_notifier_head notifier_mbhc;
-	/* mbhc module */
-	struct wcd_mbhc mbhc;
-	/* cal info for codec */
-	struct fw_info *fw_data;
-	struct notifier_block audio_ssr_nb;
-	int (*codec_spk_ext_pa_cb)(struct snd_soc_codec *codec, int enable);
-	unsigned long status_mask;
-	struct wcd_imped_i_ref imped_i_ref;
-	enum wcd_mbhc_imp_det_pin imped_det_pin;
-	/* Entry for version info */
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-};
-
-struct sdm660_cdc_pdata {
-	struct wcd_micbias_setting micbias;
-	struct sdm660_cdc_regulator regulator[MAX_REGULATOR];
-};
-
-
-extern int msm_anlg_cdc_mclk_enable(struct snd_soc_codec *codec,
-				    int mclk_enable, bool dapm);
-
-extern int msm_anlg_cdc_hs_detect(struct snd_soc_codec *codec,
-		    struct wcd_mbhc_config *mbhc_cfg);
-
-extern void msm_anlg_cdc_hs_detect_exit(struct snd_soc_codec *codec);
-
-extern void sdm660_cdc_update_int_spk_boost(bool enable);
-
-extern void msm_anlg_cdc_spk_ext_pa_cb(
-		int (*codec_spk_ext_pa)(struct snd_soc_codec *codec,
-		int enable), struct snd_soc_codec *codec);
-int msm_anlg_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					   struct snd_soc_codec *codec);
-#endif
diff --git a/sound/soc/codecs/sdm660_cdc/msm-cdc-common.h b/sound/soc/codecs/sdm660_cdc/msm-cdc-common.h
deleted file mode 100644
index 1a490a4..0000000
--- a/sound/soc/codecs/sdm660_cdc/msm-cdc-common.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/regmap.h>
-#include "sdm660-cdc-registers.h"
-
-extern struct reg_default
-		msm89xx_cdc_core_defaults[MSM89XX_CDC_CORE_CACHE_SIZE];
-extern struct reg_default
-		msm89xx_pmic_cdc_defaults[MSM89XX_PMIC_CDC_CACHE_SIZE];
-
-bool msm89xx_cdc_core_readable_reg(struct device *dev, unsigned int reg);
-bool msm89xx_cdc_core_writeable_reg(struct device *dev, unsigned int reg);
-bool msm89xx_cdc_core_volatile_reg(struct device *dev, unsigned int reg);
-
-enum {
-	AIF1_PB = 0,
-	AIF1_CAP,
-	AIF2_VIFEED,
-	AIF3_SVA,
-	NUM_CODEC_DAIS,
-};
-
-enum codec_versions {
-	TOMBAK_1_0,
-	TOMBAK_2_0,
-	CONGA,
-	CAJON,
-	CAJON_2_0,
-	DIANGU,
-	DRAX_CDC,
-	UNSUPPORTED,
-};
-
-/* Support different hph modes */
-enum {
-	NORMAL_MODE = 0,
-	HD2_MODE,
-};
-
-enum dig_cdc_notify_event {
-	DIG_CDC_EVENT_INVALID,
-	DIG_CDC_EVENT_CLK_ON,
-	DIG_CDC_EVENT_CLK_OFF,
-	DIG_CDC_EVENT_RX1_MUTE_ON,
-	DIG_CDC_EVENT_RX1_MUTE_OFF,
-	DIG_CDC_EVENT_RX2_MUTE_ON,
-	DIG_CDC_EVENT_RX2_MUTE_OFF,
-	DIG_CDC_EVENT_RX3_MUTE_ON,
-	DIG_CDC_EVENT_RX3_MUTE_OFF,
-	DIG_CDC_EVENT_PRE_RX1_INT_ON,
-	DIG_CDC_EVENT_PRE_RX2_INT_ON,
-	DIG_CDC_EVENT_POST_RX1_INT_OFF,
-	DIG_CDC_EVENT_POST_RX2_INT_OFF,
-	DIG_CDC_EVENT_SSR_DOWN,
-	DIG_CDC_EVENT_SSR_UP,
-	DIG_CDC_EVENT_LAST,
-};
diff --git a/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.c b/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.c
deleted file mode 100644
index 5e0a104..0000000
--- a/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.c
+++ /dev/null
@@ -1,2189 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-#include <linux/printk.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/qdsp6v2/apr.h>
-#include <linux/workqueue.h>
-#include <linux/regmap.h>
-#include <sound/q6afe-v2.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include "sdm660-cdc-registers.h"
-#include "msm-digital-cdc.h"
-#include "msm-cdc-common.h"
-#include "../../msm/sdm660-common.h"
-#include "../../../../drivers/base/regmap/internal.h"
-
-#define DRV_NAME "msm_digital_codec"
-#define MCLK_RATE_9P6MHZ        9600000
-#define MCLK_RATE_12P288MHZ     12288000
-#define TX_MUX_CTL_CUT_OFF_FREQ_MASK	0x30
-#define CF_MIN_3DB_4HZ			0x0
-#define CF_MIN_3DB_75HZ			0x1
-#define CF_MIN_3DB_150HZ		0x2
-
-#define MSM_DIG_CDC_VERSION_ENTRY_SIZE 32
-
-static unsigned long rx_digital_gain_reg[] = {
-	MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL,
-	MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL,
-	MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL,
-};
-
-static unsigned long tx_digital_gain_reg[] = {
-	MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN,
-	MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN,
-	MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN,
-	MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN,
-	MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN,
-};
-
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
-
-struct snd_soc_codec *registered_digcodec;
-struct hpf_work tx_hpf_work[NUM_DECIMATORS];
-
-/* Codec supports 2 IIR filters */
-enum {
-	IIR1 = 0,
-	IIR2,
-	IIR_MAX,
-};
-
-static int msm_digcdc_clock_control(bool flag)
-{
-	int ret = -EINVAL;
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct msm_dig_priv *msm_dig_cdc =
-				snd_soc_codec_get_drvdata(registered_digcodec);
-
-	pdata = snd_soc_card_get_drvdata(registered_digcodec->component.card);
-
-	if (flag) {
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		if (atomic_read(&pdata->int_mclk0_enabled) == false) {
-			pdata->digital_cdc_core_clk.enable = 1;
-			ret = afe_set_lpass_clock_v2(
-						AFE_PORT_ID_INT0_MI2S_RX,
-						&pdata->digital_cdc_core_clk);
-			if (ret < 0) {
-				pr_err("%s:failed to enable the MCLK\n",
-				       __func__);
-				/*
-				 * Avoid access to lpass register
-				 * as clock enable failed during SSR.
-				 */
-				if (ret == -ENODEV)
-					msm_dig_cdc->regmap->cache_only = true;
-				return ret;
-			}
-			pr_debug("enabled digital codec core clk\n");
-			atomic_set(&pdata->int_mclk0_enabled, true);
-			schedule_delayed_work(&pdata->disable_int_mclk0_work,
-					      50);
-		}
-	} else {
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		dev_dbg(registered_digcodec->dev,
-			"disable MCLK, workq to disable set already\n");
-	}
-	return 0;
-}
-
-static void enable_digital_callback(void *flag)
-{
-	msm_digcdc_clock_control(true);
-}
-
-static void disable_digital_callback(void *flag)
-{
-	msm_digcdc_clock_control(false);
-	pr_debug("disable mclk happens in workq\n");
-}
-
-static int msm_dig_cdc_put_dec_enum(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int dec_mux, decimator;
-	char *dec_name = NULL;
-	char *widget_name = NULL;
-	char *temp;
-	u16 tx_mux_ctl_reg;
-	u8 adc_dmic_sel = 0x0;
-	int ret = 0;
-	char *dec_num;
-
-	if (ucontrol->value.enumerated.item[0] > e->items) {
-		dev_err(codec->dev, "%s: Invalid enum value: %d\n",
-			__func__, ucontrol->value.enumerated.item[0]);
-		return -EINVAL;
-	}
-	dec_mux = ucontrol->value.enumerated.item[0];
-
-	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
-	if (!widget_name) {
-		dev_err(codec->dev, "%s: failed to copy string\n",
-			__func__);
-		return -ENOMEM;
-	}
-	temp = widget_name;
-
-	dec_name = strsep(&widget_name, " ");
-	widget_name = temp;
-	if (!dec_name) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, w->name);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	dec_num = strpbrk(dec_name, "12345");
-	if (dec_num == NULL) {
-		dev_err(codec->dev, "%s: Invalid DEC selected\n", __func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	ret = kstrtouint(dec_num, 10, &decimator);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, dec_name);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	dev_dbg(w->dapm->dev, "%s(): widget = %s decimator = %u dec_mux = %u\n"
-		, __func__, w->name, decimator, dec_mux);
-
-	switch (decimator) {
-	case 1:
-	case 2:
-	case 3:
-	case 4:
-	case 5:
-		if ((dec_mux == 4) || (dec_mux == 5) ||
-		    (dec_mux == 6) || (dec_mux == 7))
-			adc_dmic_sel = 0x1;
-		else
-			adc_dmic_sel = 0x0;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid Decimator = %u\n",
-			__func__, decimator);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	tx_mux_ctl_reg =
-		MSM89XX_CDC_CORE_TX1_MUX_CTL + 32 * (decimator - 1);
-
-	snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel);
-
-	ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
-
-out:
-	kfree(widget_name);
-	return ret;
-}
-
-
-static int msm_dig_cdc_codec_config_compander(struct snd_soc_codec *codec,
-					      int interp_n, int event)
-{
-	struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: event %d shift %d, enabled %d\n",
-		__func__, event, interp_n,
-		dig_cdc->comp_enabled[interp_n]);
-
-	/* compander is not enabled */
-	if (!dig_cdc->comp_enabled[interp_n])
-		return 0;
-
-	switch (dig_cdc->comp_enabled[interp_n]) {
-	case COMPANDER_1:
-		if (SND_SOC_DAPM_EVENT_ON(event)) {
-			/* Enable Compander Clock */
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B2_CTL, 0x0F, 0x09);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_CLK_RX_B2_CTL, 0x01, 0x01);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B1_CTL,
-				1 << interp_n, 1 << interp_n);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B3_CTL, 0xFF, 0x01);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B2_CTL, 0xF0, 0x50);
-			/* add sleep for compander to settle */
-			usleep_range(1000, 1100);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B3_CTL, 0xFF, 0x28);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B2_CTL, 0xF0, 0xB0);
-
-			/* Enable Compander GPIO */
-			if (dig_cdc->codec_hph_comp_gpio)
-				dig_cdc->codec_hph_comp_gpio(1, codec);
-		} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
-			/* Disable Compander GPIO */
-			if (dig_cdc->codec_hph_comp_gpio)
-				dig_cdc->codec_hph_comp_gpio(0, codec);
-
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B2_CTL, 0x0F, 0x05);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_COMP0_B1_CTL,
-				1 << interp_n, 0);
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_CLK_RX_B2_CTL, 0x01, 0x00);
-		}
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: Invalid compander %d\n", __func__,
-				dig_cdc->comp_enabled[interp_n]);
-		break;
-	};
-
-	return 0;
-}
-
-/**
- * msm_dig_cdc_hph_comp_cb - registers callback to codec by machine driver.
- *
- * @codec_hph_comp_gpio: function pointer to set comp gpio at machine driver
- * @codec: codec pointer
- *
- */
-void msm_dig_cdc_hph_comp_cb(
-	int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec),
-	struct snd_soc_codec *codec)
-{
-	struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
-
-	pr_debug("%s: Enter\n", __func__);
-	dig_cdc->codec_hph_comp_gpio = codec_hph_comp_gpio;
-}
-EXPORT_SYMBOL(msm_dig_cdc_hph_comp_cb);
-
-static int msm_dig_cdc_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
-						 struct snd_kcontrol *kcontrol,
-						 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_dig_priv *msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-
-	if (w->shift >= MSM89XX_RX_MAX || w->shift < 0) {
-		dev_err(codec->dev, "%s: wrong RX index: %d\n",
-			__func__, w->shift);
-		return -EINVAL;
-	}
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		msm_dig_cdc_codec_config_compander(codec, w->shift, event);
-		/* apply the digital gain after the interpolator is enabled*/
-		if ((w->shift) < ARRAY_SIZE(rx_digital_gain_reg))
-			snd_soc_write(codec,
-				  rx_digital_gain_reg[w->shift],
-				  snd_soc_read(codec,
-				  rx_digital_gain_reg[w->shift])
-				  );
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		msm_dig_cdc_codec_config_compander(codec, w->shift, event);
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_CLK_RX_RESET_CTL,
-			1 << w->shift, 1 << w->shift);
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_CLK_RX_RESET_CTL,
-			1 << w->shift, 0x0);
-		/*
-		 * disable the mute enabled during the PMD of this device
-		 */
-		if ((w->shift == 0) &&
-			(msm_dig_cdc->mute_mask & HPHL_PA_DISABLE)) {
-			pr_debug("disabling HPHL mute\n");
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B6_CTL, 0x01, 0x00);
-			msm_dig_cdc->mute_mask &= ~(HPHL_PA_DISABLE);
-		} else if ((w->shift == 1) &&
-				(msm_dig_cdc->mute_mask & HPHR_PA_DISABLE)) {
-			pr_debug("disabling HPHR mute\n");
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B6_CTL, 0x01, 0x00);
-			msm_dig_cdc->mute_mask &= ~(HPHR_PA_DISABLE);
-		} else if ((w->shift == 2) &&
-				(msm_dig_cdc->mute_mask & SPKR_PA_DISABLE)) {
-			pr_debug("disabling SPKR mute\n");
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX3_B6_CTL, 0x01, 0x00);
-			msm_dig_cdc->mute_mask &= ~(SPKR_PA_DISABLE);
-		}
-	}
-	return 0;
-}
-
-static int msm_dig_cdc_get_iir_enable_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	ucontrol->value.integer.value[0] =
-		(snd_soc_read(codec,
-			    (MSM89XX_CDC_CORE_IIR1_CTL + 64 * iir_idx)) &
-		(1 << band_idx)) != 0;
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
-		iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_dig_cdc_put_iir_enable_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	int value = ucontrol->value.integer.value[0];
-
-	/* Mask first 5 bits, 6-8 are reserved */
-	snd_soc_update_bits(codec,
-		(MSM89XX_CDC_CORE_IIR1_CTL + 64 * iir_idx),
-			    (1 << band_idx), (value << band_idx));
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
-	  iir_idx, band_idx,
-		((snd_soc_read(codec,
-		(MSM89XX_CDC_CORE_IIR1_CTL + 64 * iir_idx)) &
-	  (1 << band_idx)) != 0));
-
-	return 0;
-}
-
-static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
-				   int iir_idx, int band_idx,
-				   int coeff_idx)
-{
-	uint32_t value = 0;
-
-	/* Address does not automatically update if reading */
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL + 64 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t)) & 0x7F);
-
-	value |= snd_soc_read(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx));
-
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL + 64 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 1) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx)) << 8);
-
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL + 64 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 2) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx)) << 16);
-
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL + 64 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 3) & 0x7F);
-
-	/* Mask bits top 2 bits since they are reserved */
-	value |= ((snd_soc_read(codec, (MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL
-		+ 64 * iir_idx)) & 0x3f) << 24);
-
-	return value;
-
-}
-
-static void set_iir_band_coeff(struct snd_soc_codec *codec,
-			       int iir_idx, int band_idx,
-			       uint32_t value)
-{
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx),
-		(value & 0xFF));
-
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx),
-		(value >> 8) & 0xFF);
-
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx),
-		(value >> 16) & 0xFF);
-
-	/* Mask top 2 bits, 7-8 are reserved */
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL + 64 * iir_idx),
-		(value >> 24) & 0x3F);
-
-}
-
-static int msm_dig_cdc_get_iir_band_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	ucontrol->value.integer.value[0] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0);
-	ucontrol->value.integer.value[1] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1);
-	ucontrol->value.integer.value[2] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2);
-	ucontrol->value.integer.value[3] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3);
-	ucontrol->value.integer.value[4] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4);
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[1],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[2],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[3],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[4]);
-	return 0;
-}
-
-static int msm_dig_cdc_put_iir_band_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	/* Mask top bit it is reserved */
-	/* Updates addr automatically for each B2 write */
-	snd_soc_write(codec,
-		(MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL + 64 * iir_idx),
-		(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
-
-
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-			   ucontrol->value.integer.value[0]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-			   ucontrol->value.integer.value[1]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-			   ucontrol->value.integer.value[2]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-			   ucontrol->value.integer.value[3]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-			   ucontrol->value.integer.value[4]);
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4));
-	return 0;
-}
-
-static void tx_hpf_corner_freq_callback(struct work_struct *work)
-{
-	struct delayed_work *hpf_delayed_work;
-	struct hpf_work *hpf_work;
-	struct snd_soc_codec *codec;
-	struct msm_dig_priv *msm_dig_cdc;
-	u16 tx_mux_ctl_reg;
-	u8 hpf_cut_of_freq;
-
-	hpf_delayed_work = to_delayed_work(work);
-	hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
-	codec = hpf_work->dig_cdc->codec;
-	msm_dig_cdc = hpf_work->dig_cdc;
-	hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq;
-
-	tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX1_MUX_CTL +
-			(hpf_work->decimator - 1) * 32;
-
-	dev_dbg(codec->dev, "%s(): decimator %u hpf_cut_of_freq 0x%x\n",
-		 __func__, hpf_work->decimator, (unsigned int)hpf_cut_of_freq);
-	msm_dig_cdc->update_clkdiv(msm_dig_cdc->handle, 0x51);
-
-	snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4);
-}
-
-static int msm_dig_cdc_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int value = 0, reg;
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		if (w->shift == 0)
-			reg = MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL;
-		else if (w->shift == 1)
-			reg = MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL;
-		else
-			goto ret;
-		value = snd_soc_read(codec, reg);
-		snd_soc_write(codec, reg, value);
-		break;
-	default:
-		pr_err("%s: event = %d not expected\n", __func__, event);
-	}
-ret:
-	return 0;
-}
-
-static int msm_dig_cdc_compander_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
-	int comp_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int rx_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	dev_dbg(codec->dev, "%s: msm_dig_cdc->comp[%d]_enabled[%d] = %d\n",
-			__func__, comp_idx, rx_idx,
-			dig_cdc->comp_enabled[rx_idx]);
-
-	ucontrol->value.integer.value[0] = dig_cdc->comp_enabled[rx_idx];
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_dig_cdc_compander_set(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
-	int comp_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int rx_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	if (dig_cdc->version >= DIANGU) {
-		if (!value)
-			dig_cdc->comp_enabled[rx_idx] = 0;
-		else
-			dig_cdc->comp_enabled[rx_idx] = comp_idx;
-	}
-
-	dev_dbg(codec->dev, "%s: msm_dig_cdc->comp[%d]_enabled[%d] = %d\n",
-		__func__, comp_idx, rx_idx,
-		dig_cdc->comp_enabled[rx_idx]);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new compander_kcontrols[] = {
-	SOC_SINGLE_EXT("COMP0 RX1", COMPANDER_1, MSM89XX_RX1, 1, 0,
-	msm_dig_cdc_compander_get, msm_dig_cdc_compander_set),
-
-	SOC_SINGLE_EXT("COMP0 RX2", COMPANDER_1, MSM89XX_RX2, 1, 0,
-	msm_dig_cdc_compander_get, msm_dig_cdc_compander_set),
-
-};
-
-static int msm_dig_cdc_set_interpolator_rate(struct snd_soc_dai *dai,
-					     u8 rx_fs_rate_reg_val,
-					     u32 sample_rate)
-{
-	snd_soc_update_bits(dai->codec,
-			MSM89XX_CDC_CORE_RX1_B5_CTL, 0xF0, rx_fs_rate_reg_val);
-	snd_soc_update_bits(dai->codec,
-			MSM89XX_CDC_CORE_RX2_B5_CTL, 0xF0, rx_fs_rate_reg_val);
-	return 0;
-}
-
-static int msm_dig_cdc_hw_params(struct snd_pcm_substream *substream,
-				 struct snd_pcm_hw_params *params,
-				 struct snd_soc_dai *dai)
-{
-	u8 tx_fs_rate, rx_fs_rate, rx_clk_fs_rate;
-	int ret;
-
-	dev_dbg(dai->codec->dev,
-		"%s: dai_name = %s DAI-ID %x rate %d num_ch %d format %d\n",
-		__func__, dai->name, dai->id, params_rate(params),
-		params_channels(params), params_format(params));
-
-	switch (params_rate(params)) {
-	case 8000:
-		tx_fs_rate = 0x00;
-		rx_fs_rate = 0x00;
-		rx_clk_fs_rate = 0x00;
-		break;
-	case 16000:
-		tx_fs_rate = 0x20;
-		rx_fs_rate = 0x20;
-		rx_clk_fs_rate = 0x01;
-		break;
-	case 32000:
-		tx_fs_rate = 0x40;
-		rx_fs_rate = 0x40;
-		rx_clk_fs_rate = 0x02;
-		break;
-	case 44100:
-	case 48000:
-		tx_fs_rate = 0x60;
-		rx_fs_rate = 0x60;
-		rx_clk_fs_rate = 0x03;
-		break;
-	case 96000:
-		tx_fs_rate = 0x80;
-		rx_fs_rate = 0x80;
-		rx_clk_fs_rate = 0x04;
-		break;
-	case 192000:
-		tx_fs_rate = 0xA0;
-		rx_fs_rate = 0xA0;
-		rx_clk_fs_rate = 0x05;
-		break;
-	default:
-		dev_err(dai->codec->dev,
-			"%s: Invalid sampling rate %d\n", __func__,
-			params_rate(params));
-		return -EINVAL;
-	}
-
-	snd_soc_update_bits(dai->codec,
-			MSM89XX_CDC_CORE_CLK_RX_I2S_CTL, 0x0F, rx_clk_fs_rate);
-
-	switch (substream->stream) {
-	case SNDRV_PCM_STREAM_CAPTURE:
-		break;
-	case SNDRV_PCM_STREAM_PLAYBACK:
-		ret = msm_dig_cdc_set_interpolator_rate(dai, rx_fs_rate,
-						  params_rate(params));
-		if (ret < 0) {
-			dev_err(dai->codec->dev,
-				"%s: set decimator rate failed %d\n", __func__,
-				ret);
-			return ret;
-		}
-		break;
-	default:
-		dev_err(dai->codec->dev,
-			"%s: Invalid stream type %d\n", __func__,
-			substream->stream);
-		return -EINVAL;
-	}
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		snd_soc_update_bits(dai->codec,
-				MSM89XX_CDC_CORE_CLK_RX_I2S_CTL, 0x20, 0x20);
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		snd_soc_update_bits(dai->codec,
-				MSM89XX_CDC_CORE_CLK_RX_I2S_CTL, 0x20, 0x00);
-		break;
-	default:
-		dev_err(dai->codec->dev, "%s: wrong format selected\n",
-				__func__);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int msm_dig_cdc_codec_enable_dmic(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
-	u8  dmic_clk_en;
-	u16 dmic_clk_reg;
-	s32 *dmic_clk_cnt;
-	unsigned int dmic;
-	int ret;
-	char *dmic_num = strpbrk(w->name, "1234");
-
-	if (dmic_num == NULL) {
-		dev_err(codec->dev, "%s: Invalid DMIC\n", __func__);
-		return -EINVAL;
-	}
-
-	ret = kstrtouint(dmic_num, 10, &dmic);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Invalid DMIC line on the codec\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (dmic) {
-	case 1:
-	case 2:
-		dmic_clk_en = 0x01;
-		dmic_clk_cnt = &(dig_cdc->dmic_1_2_clk_cnt);
-		dmic_clk_reg = MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL;
-		dev_dbg(codec->dev,
-			"%s() event %d DMIC%d dmic_1_2_clk_cnt %d\n",
-			__func__, event,  dmic, *dmic_clk_cnt);
-		break;
-	case 3:
-	case 4:
-		dmic_clk_en = 0x01;
-		dmic_clk_cnt = &(dig_cdc->dmic_3_4_clk_cnt);
-		dmic_clk_reg = MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL;
-		dev_dbg(codec->dev,
-			"%s() event %d DMIC%d dmic_3_4_clk_cnt %d\n",
-			__func__, event,  dmic, *dmic_clk_cnt);
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid DMIC Selection\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		(*dmic_clk_cnt)++;
-		if (*dmic_clk_cnt == 1) {
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					0x0E, 0x04);
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					dmic_clk_en, dmic_clk_en);
-		}
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_TX1_DMIC_CTL + (dmic - 1) * 0x20,
-			0x07, 0x02);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		(*dmic_clk_cnt)--;
-		if (*dmic_clk_cnt  == 0)
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					dmic_clk_en, 0);
-		break;
-	}
-	return 0;
-}
-
-static int msm_dig_cdc_codec_enable_dec(struct snd_soc_dapm_widget *w,
-					struct snd_kcontrol *kcontrol,
-					int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct msm_asoc_mach_data *pdata = NULL;
-	unsigned int decimator;
-	struct msm_dig_priv *msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
-	char *dec_name = NULL;
-	char *widget_name = NULL;
-	char *temp;
-	int ret = 0, i;
-	u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg;
-	u8 dec_hpf_cut_of_freq;
-	int offset;
-	char *dec_num;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-
-	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
-	if (!widget_name)
-		return -ENOMEM;
-	temp = widget_name;
-
-	dec_name = strsep(&widget_name, " ");
-	widget_name = temp;
-	if (!dec_name) {
-		dev_err(codec->dev,
-			"%s: Invalid decimator = %s\n", __func__, w->name);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	dec_num = strpbrk(dec_name, "12345");
-	if (dec_num == NULL) {
-		dev_err(codec->dev, "%s: Invalid Decimator\n", __func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	ret = kstrtouint(dec_num, 10, &decimator);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Invalid decimator = %s\n", __func__, dec_name);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	dev_dbg(codec->dev,
-		"%s(): widget = %s dec_name = %s decimator = %u\n", __func__,
-		w->name, dec_name, decimator);
-
-	if (w->reg == MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL) {
-		dec_reset_reg = MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL;
-		offset = 0;
-	} else {
-		dev_err(codec->dev, "%s: Error, incorrect dec\n", __func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	tx_vol_ctl_reg = MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG +
-			 32 * (decimator - 1);
-	tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX1_MUX_CTL +
-			  32 * (decimator - 1);
-	if (decimator == 5) {
-		tx_vol_ctl_reg = MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG;
-		tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX5_MUX_CTL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* Enableable TX digital mute */
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);
-		for (i = 0; i < NUM_DECIMATORS; i++) {
-			if (decimator == i + 1)
-				msm_dig_cdc->dec_active[i] = true;
-		}
-
-		dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg);
-
-		dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & 0x30) >> 4;
-
-		tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq =
-			dec_hpf_cut_of_freq;
-
-		if (dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ) {
-
-			/* set cut of freq to CF_MIN_3DB_150HZ (0x1); */
-			snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30,
-					    CF_MIN_3DB_150HZ << 4);
-		}
-		msm_dig_cdc->update_clkdiv(msm_dig_cdc->handle, 0x42);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* enable HPF */
-		snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x00);
-
-		if (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq !=
-				CF_MIN_3DB_150HZ) {
-
-			schedule_delayed_work(&tx_hpf_work[decimator - 1].dwork,
-					msecs_to_jiffies(300));
-		}
-		/* apply the digital gain after the decimator is enabled*/
-		if ((w->shift) < ARRAY_SIZE(tx_digital_gain_reg))
-			snd_soc_write(codec,
-				  tx_digital_gain_reg[w->shift + offset],
-				  snd_soc_read(codec,
-				  tx_digital_gain_reg[w->shift + offset])
-				  );
-		if (pdata->lb_mode) {
-			pr_debug("%s: loopback mode unmute the DEC\n",
-							__func__);
-			snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00);
-		}
-				snd_soc_update_bits(codec, tx_vol_ctl_reg,
-						0x01, 0x00);
-
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);
-		msleep(20);
-		snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08);
-		cancel_delayed_work_sync(&tx_hpf_work[decimator - 1].dwork);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift,
-			1 << w->shift);
-		snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0);
-		snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08);
-		snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30,
-			(tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4);
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00);
-		for (i = 0; i < NUM_DECIMATORS; i++) {
-			if (decimator == i + 1)
-				msm_dig_cdc->dec_active[i] = false;
-		}
-		break;
-	}
-out:
-	kfree(widget_name);
-	return ret;
-}
-
-static int msm_dig_cdc_event_notify(struct notifier_block *block,
-				    unsigned long val,
-				    void *data)
-{
-	enum dig_cdc_notify_event event = (enum dig_cdc_notify_event)val;
-	struct snd_soc_codec *codec = registered_digcodec;
-	struct msm_dig_priv *msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
-	struct msm_asoc_mach_data *pdata = NULL;
-	int ret = -EINVAL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-
-	switch (event) {
-	case DIG_CDC_EVENT_CLK_ON:
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_CLK_PDM_CTL, 0x03, 0x03);
-		if (pdata->mclk_freq == MCLK_RATE_12P288MHZ ||
-		    pdata->native_clk_set)
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_TOP_CTL, 0x01, 0x00);
-		else if (pdata->mclk_freq == MCLK_RATE_9P6MHZ)
-			snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_TOP_CTL, 0x01, 0x01);
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_CLK_MCLK_CTL, 0x01, 0x01);
-		break;
-	case DIG_CDC_EVENT_CLK_OFF:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_CLK_PDM_CTL, 0x03, 0x00);
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_CLK_MCLK_CTL, 0x01, 0x00);
-		break;
-	case DIG_CDC_EVENT_RX1_MUTE_ON:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX1_B6_CTL, 0x01, 0x01);
-		msm_dig_cdc->mute_mask |= HPHL_PA_DISABLE;
-		break;
-	case DIG_CDC_EVENT_RX1_MUTE_OFF:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX1_B6_CTL, 0x01, 0x00);
-		msm_dig_cdc->mute_mask &= (~HPHL_PA_DISABLE);
-		break;
-	case DIG_CDC_EVENT_RX2_MUTE_ON:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX2_B6_CTL, 0x01, 0x01);
-		msm_dig_cdc->mute_mask |= HPHR_PA_DISABLE;
-		break;
-	case DIG_CDC_EVENT_RX2_MUTE_OFF:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX2_B6_CTL, 0x01, 0x00);
-		msm_dig_cdc->mute_mask &= (~HPHR_PA_DISABLE);
-		break;
-	case DIG_CDC_EVENT_RX3_MUTE_ON:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX3_B6_CTL, 0x01, 0x01);
-		msm_dig_cdc->mute_mask |= SPKR_PA_DISABLE;
-		break;
-	case DIG_CDC_EVENT_RX3_MUTE_OFF:
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_RX3_B6_CTL, 0x01, 0x00);
-		msm_dig_cdc->mute_mask &= (~SPKR_PA_DISABLE);
-		break;
-	case DIG_CDC_EVENT_PRE_RX1_INT_ON:
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B3_CTL, 0x3C, 0x28);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B4_CTL, 0x18, 0x10);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B3_CTL, 0x80, 0x80);
-		break;
-	case DIG_CDC_EVENT_PRE_RX2_INT_ON:
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B3_CTL, 0x3C, 0x28);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B4_CTL, 0x18, 0x10);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B3_CTL, 0x80, 0x80);
-		break;
-	case DIG_CDC_EVENT_POST_RX1_INT_OFF:
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B3_CTL, 0x3C, 0x00);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B4_CTL, 0x18, 0xFF);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX1_B3_CTL, 0x80, 0x00);
-		break;
-	case DIG_CDC_EVENT_POST_RX2_INT_OFF:
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B3_CTL, 0x3C, 0x00);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B4_CTL, 0x18, 0xFF);
-		snd_soc_update_bits(codec,
-				MSM89XX_CDC_CORE_RX2_B3_CTL, 0x80, 0x00);
-		break;
-	case DIG_CDC_EVENT_SSR_DOWN:
-		regcache_cache_only(msm_dig_cdc->regmap, true);
-		break;
-	case DIG_CDC_EVENT_SSR_UP:
-		regcache_cache_only(msm_dig_cdc->regmap, false);
-		regcache_mark_dirty(msm_dig_cdc->regmap);
-
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		pdata->digital_cdc_core_clk.enable = 1;
-		ret = afe_set_lpass_clock_v2(
-					AFE_PORT_ID_INT0_MI2S_RX,
-					&pdata->digital_cdc_core_clk);
-		if (ret < 0) {
-			pr_err("%s:failed to enable the MCLK\n",
-			       __func__);
-			mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-			break;
-		}
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-
-		regcache_sync(msm_dig_cdc->regmap);
-
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		pdata->digital_cdc_core_clk.enable = 0;
-		afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT0_MI2S_RX,
-				&pdata->digital_cdc_core_clk);
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		break;
-	case DIG_CDC_EVENT_INVALID:
-	default:
-		break;
-	}
-	return 0;
-}
-
-static ssize_t msm_dig_codec_version_read(struct snd_info_entry *entry,
-					  void *file_private_data,
-					  struct file *file,
-					  char __user *buf, size_t count,
-					  loff_t pos)
-{
-	struct msm_dig_priv *msm_dig;
-	char buffer[MSM_DIG_CDC_VERSION_ENTRY_SIZE];
-	int len = 0;
-
-	msm_dig = (struct msm_dig_priv *) entry->private_data;
-	if (!msm_dig) {
-		pr_err("%s: msm_dig priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (msm_dig->version) {
-	case DRAX_CDC:
-		len = snprintf(buffer, sizeof(buffer), "SDM660-CDC_1_0\n");
-		break;
-	default:
-		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-	}
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops msm_dig_codec_info_ops = {
-	.read = msm_dig_codec_version_read,
-};
-
-/*
- * msm_dig_codec_info_create_codec_entry - creates msm_dig module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates msm_dig module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					  struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct msm_dig_priv *msm_dig;
-	struct snd_soc_card *card;
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	msm_dig = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-	msm_dig->entry = snd_info_create_subdir(codec_root->module,
-						  "msm_digital_codec",
-						  codec_root);
-	if (!msm_dig->entry) {
-		dev_dbg(codec->dev, "%s: failed to create msm_digital entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   msm_dig->entry);
-	if (!version_entry) {
-		dev_dbg(codec->dev, "%s: failed to create msm_digital version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = msm_dig;
-	version_entry->size = MSM_DIG_CDC_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &msm_dig_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	msm_dig->version_entry = version_entry;
-	if (msm_dig->get_cdc_version)
-		msm_dig->version = msm_dig->get_cdc_version(msm_dig->handle);
-	else
-		msm_dig->version = DRAX_CDC;
-
-	return 0;
-}
-EXPORT_SYMBOL(msm_dig_codec_info_create_codec_entry);
-
-static int msm_dig_cdc_soc_probe(struct snd_soc_codec *codec)
-{
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(codec->dev);
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	int i, ret;
-
-	msm_dig_cdc->codec = codec;
-
-	snd_soc_add_codec_controls(codec, compander_kcontrols,
-			ARRAY_SIZE(compander_kcontrols));
-
-	for (i = 0; i < NUM_DECIMATORS; i++) {
-		tx_hpf_work[i].dig_cdc = msm_dig_cdc;
-		tx_hpf_work[i].decimator = i + 1;
-		INIT_DELAYED_WORK(&tx_hpf_work[i].dwork,
-			tx_hpf_corner_freq_callback);
-	}
-
-	for (i = 0; i < MSM89XX_RX_MAX; i++)
-		msm_dig_cdc->comp_enabled[i] = COMPANDER_NONE;
-
-	/* Register event notifier */
-	msm_dig_cdc->nblock.notifier_call = msm_dig_cdc_event_notify;
-	if (msm_dig_cdc->register_notifier) {
-		ret = msm_dig_cdc->register_notifier(msm_dig_cdc->handle,
-						     &msm_dig_cdc->nblock,
-						     true);
-		if (ret) {
-			pr_err("%s: Failed to register notifier %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-	registered_digcodec = codec;
-
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC1_IN");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC2_IN");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC3_IN");
-	snd_soc_dapm_ignore_suspend(dapm, "PDM_OUT_RX1");
-	snd_soc_dapm_ignore_suspend(dapm, "PDM_OUT_RX2");
-	snd_soc_dapm_ignore_suspend(dapm, "PDM_OUT_RX3");
-
-	snd_soc_dapm_sync(dapm);
-
-	return 0;
-}
-
-static int msm_dig_cdc_soc_remove(struct snd_soc_codec *codec)
-{
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(codec->dev);
-
-	if (msm_dig_cdc->register_notifier)
-		msm_dig_cdc->register_notifier(msm_dig_cdc->handle,
-					       &msm_dig_cdc->nblock,
-					       false);
-	iounmap(msm_dig_cdc->dig_base);
-	return 0;
-}
-
-static const struct snd_soc_dapm_route audio_dig_map[] = {
-	{"RX_I2S_CLK", NULL, "CDC_CONN"},
-	{"I2S RX1", NULL, "RX_I2S_CLK"},
-	{"I2S RX2", NULL, "RX_I2S_CLK"},
-	{"I2S RX3", NULL, "RX_I2S_CLK"},
-
-	{"I2S TX1", NULL, "TX_I2S_CLK"},
-	{"I2S TX2", NULL, "TX_I2S_CLK"},
-	{"I2S TX3", NULL, "TX_I2S_CLK"},
-	{"I2S TX4", NULL, "TX_I2S_CLK"},
-	{"I2S TX5", NULL, "TX_I2S_CLK"},
-	{"I2S TX6", NULL, "TX_I2S_CLK"},
-
-	{"I2S TX1", NULL, "DEC1 MUX"},
-	{"I2S TX2", NULL, "DEC2 MUX"},
-	{"I2S TX3", NULL, "I2S TX2 INP1"},
-	{"I2S TX4", NULL, "I2S TX2 INP2"},
-	{"I2S TX5", NULL, "DEC3 MUX"},
-	{"I2S TX6", NULL, "I2S TX3 INP2"},
-
-	{"I2S TX2 INP1", "RX_MIX1", "RX1 MIX2"},
-	{"I2S TX2 INP1", "DEC3", "DEC3 MUX"},
-	{"I2S TX2 INP2", "RX_MIX2", "RX2 MIX2"},
-	{"I2S TX2 INP2", "RX_MIX3", "RX3 MIX1"},
-	{"I2S TX2 INP2", "DEC4", "DEC4 MUX"},
-	{"I2S TX3 INP2", "DEC4", "DEC4 MUX"},
-	{"I2S TX3 INP2", "DEC5", "DEC5 MUX"},
-
-	{"PDM_OUT_RX1", NULL, "RX1 CHAIN"},
-	{"PDM_OUT_RX2", NULL, "RX2 CHAIN"},
-	{"PDM_OUT_RX3", NULL, "RX3 CHAIN"},
-
-	{"RX1 CHAIN", NULL, "RX1 MIX2"},
-	{"RX2 CHAIN", NULL, "RX2 MIX2"},
-	{"RX3 CHAIN", NULL, "RX3 MIX1"},
-
-	{"RX1 MIX1", NULL, "RX1 MIX1 INP1"},
-	{"RX1 MIX1", NULL, "RX1 MIX1 INP2"},
-	{"RX1 MIX1", NULL, "RX1 MIX1 INP3"},
-	{"RX2 MIX1", NULL, "RX2 MIX1 INP1"},
-	{"RX2 MIX1", NULL, "RX2 MIX1 INP2"},
-	{"RX3 MIX1", NULL, "RX3 MIX1 INP1"},
-	{"RX3 MIX1", NULL, "RX3 MIX1 INP2"},
-	{"RX1 MIX2", NULL, "RX1 MIX1"},
-	{"RX1 MIX2", NULL, "RX1 MIX2 INP1"},
-	{"RX2 MIX2", NULL, "RX2 MIX1"},
-	{"RX2 MIX2", NULL, "RX2 MIX2 INP1"},
-
-	{"RX1 MIX1 INP1", "RX1", "I2S RX1"},
-	{"RX1 MIX1 INP1", "RX2", "I2S RX2"},
-	{"RX1 MIX1 INP1", "RX3", "I2S RX3"},
-	{"RX1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX1 MIX1 INP1", "IIR2", "IIR2"},
-	{"RX1 MIX1 INP2", "RX1", "I2S RX1"},
-	{"RX1 MIX1 INP2", "RX2", "I2S RX2"},
-	{"RX1 MIX1 INP2", "RX3", "I2S RX3"},
-	{"RX1 MIX1 INP2", "IIR1", "IIR1"},
-	{"RX1 MIX1 INP2", "IIR2", "IIR2"},
-	{"RX1 MIX1 INP3", "RX1", "I2S RX1"},
-	{"RX1 MIX1 INP3", "RX2", "I2S RX2"},
-	{"RX1 MIX1 INP3", "RX3", "I2S RX3"},
-
-	{"RX2 MIX1 INP1", "RX1", "I2S RX1"},
-	{"RX2 MIX1 INP1", "RX2", "I2S RX2"},
-	{"RX2 MIX1 INP1", "RX3", "I2S RX3"},
-	{"RX2 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX2 MIX1 INP1", "IIR2", "IIR2"},
-	{"RX2 MIX1 INP2", "RX1", "I2S RX1"},
-	{"RX2 MIX1 INP2", "RX2", "I2S RX2"},
-	{"RX2 MIX1 INP2", "RX3", "I2S RX3"},
-	{"RX2 MIX1 INP2", "IIR1", "IIR1"},
-	{"RX2 MIX1 INP2", "IIR2", "IIR2"},
-
-	{"RX3 MIX1 INP1", "RX1", "I2S RX1"},
-	{"RX3 MIX1 INP1", "RX2", "I2S RX2"},
-	{"RX3 MIX1 INP1", "RX3", "I2S RX3"},
-	{"RX3 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX3 MIX1 INP1", "IIR2", "IIR2"},
-	{"RX3 MIX1 INP2", "RX1", "I2S RX1"},
-	{"RX3 MIX1 INP2", "RX2", "I2S RX2"},
-	{"RX3 MIX1 INP2", "RX3", "I2S RX3"},
-	{"RX3 MIX1 INP2", "IIR1", "IIR1"},
-	{"RX3 MIX1 INP2", "IIR2", "IIR2"},
-
-	{"RX1 MIX2 INP1", "IIR1", "IIR1"},
-	{"RX2 MIX2 INP1", "IIR1", "IIR1"},
-	{"RX1 MIX2 INP1", "IIR2", "IIR2"},
-	{"RX2 MIX2 INP1", "IIR2", "IIR2"},
-
-		/* Decimator Inputs */
-	{"DEC1 MUX", "DMIC1", "DMIC1"},
-	{"DEC1 MUX", "DMIC2", "DMIC2"},
-	{"DEC1 MUX", "DMIC3", "DMIC3"},
-	{"DEC1 MUX", "DMIC4", "DMIC4"},
-	{"DEC1 MUX", "ADC1", "ADC1_IN"},
-	{"DEC1 MUX", "ADC2", "ADC2_IN"},
-	{"DEC1 MUX", "ADC3", "ADC3_IN"},
-	{"DEC1 MUX", NULL, "CDC_CONN"},
-
-	{"DEC2 MUX", "DMIC1", "DMIC1"},
-	{"DEC2 MUX", "DMIC2", "DMIC2"},
-	{"DEC2 MUX", "DMIC3", "DMIC3"},
-	{"DEC2 MUX", "DMIC4", "DMIC4"},
-	{"DEC2 MUX", "ADC1", "ADC1_IN"},
-	{"DEC2 MUX", "ADC2", "ADC2_IN"},
-	{"DEC2 MUX", "ADC3", "ADC3_IN"},
-	{"DEC2 MUX", NULL, "CDC_CONN"},
-
-	{"DEC3 MUX", "DMIC1", "DMIC1"},
-	{"DEC3 MUX", "DMIC2", "DMIC2"},
-	{"DEC3 MUX", "DMIC3", "DMIC3"},
-	{"DEC3 MUX", "DMIC4", "DMIC4"},
-	{"DEC3 MUX", "ADC1", "ADC1_IN"},
-	{"DEC3 MUX", "ADC2", "ADC2_IN"},
-	{"DEC3 MUX", "ADC3", "ADC3_IN"},
-	{"DEC3 MUX", NULL, "CDC_CONN"},
-
-	{"DEC4 MUX", "DMIC1", "DMIC1"},
-	{"DEC4 MUX", "DMIC2", "DMIC2"},
-	{"DEC4 MUX", "DMIC3", "DMIC3"},
-	{"DEC4 MUX", "DMIC4", "DMIC4"},
-	{"DEC4 MUX", "ADC1", "ADC1_IN"},
-	{"DEC4 MUX", "ADC2", "ADC2_IN"},
-	{"DEC4 MUX", "ADC3", "ADC3_IN"},
-	{"DEC4 MUX", NULL, "CDC_CONN"},
-
-	{"DEC5 MUX", "DMIC1", "DMIC1"},
-	{"DEC5 MUX", "DMIC2", "DMIC2"},
-	{"DEC5 MUX", "DMIC3", "DMIC3"},
-	{"DEC5 MUX", "DMIC4", "DMIC4"},
-	{"DEC5 MUX", "ADC1", "ADC1_IN"},
-	{"DEC5 MUX", "ADC2", "ADC2_IN"},
-	{"DEC5 MUX", "ADC3", "ADC3_IN"},
-	{"DEC5 MUX", NULL, "CDC_CONN"},
-
-	{"IIR1", NULL, "IIR1 INP1 MUX"},
-	{"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"},
-	{"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"},
-	{"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"},
-	{"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"},
-	{"IIR2", NULL, "IIR2 INP1 MUX"},
-	{"IIR2 INP1 MUX", "DEC1", "DEC1 MUX"},
-	{"IIR2 INP1 MUX", "DEC2", "DEC2 MUX"},
-	{"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"},
-	{"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"},
-};
-
-
-static const char * const i2s_tx2_inp1_text[] = {
-	"ZERO", "RX_MIX1", "DEC3"
-};
-
-static const char * const i2s_tx2_inp2_text[] = {
-	"ZERO", "RX_MIX2", "RX_MIX3", "DEC4"
-};
-
-static const char * const i2s_tx3_inp2_text[] = {
-	"DEC4", "DEC5"
-};
-
-static const char * const rx_mix1_text[] = {
-	"ZERO", "IIR1", "IIR2", "RX1", "RX2", "RX3"
-};
-
-static const char * const rx_mix2_text[] = {
-	"ZERO", "IIR1", "IIR2"
-};
-
-static const char * const dec_mux_text[] = {
-	"ZERO", "ADC1", "ADC2", "ADC3", "DMIC1", "DMIC2", "DMIC3", "DMIC4"
-};
-
-static const char * const iir_inp1_text[] = {
-	"ZERO", "DEC1", "DEC2", "RX1", "RX2", "RX3", "DEC3", "DEC4"
-};
-
-/* I2S TX MUXes */
-static const struct soc_enum i2s_tx2_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL,
-		2, 3, i2s_tx2_inp1_text);
-
-static const struct soc_enum i2s_tx2_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL,
-		0, 4, i2s_tx2_inp2_text);
-
-static const struct soc_enum i2s_tx3_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL,
-		4, 2, i2s_tx3_inp2_text);
-
-/* RX1 MIX1 */
-static const struct soc_enum rx_mix1_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX1_B1_CTL,
-		0, 6, rx_mix1_text);
-
-static const struct soc_enum rx_mix1_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX1_B1_CTL,
-		3, 6, rx_mix1_text);
-
-static const struct soc_enum rx_mix1_inp3_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX1_B2_CTL,
-		0, 6, rx_mix1_text);
-
-/* RX1 MIX2 */
-static const struct soc_enum rx_mix2_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX1_B3_CTL,
-		0, 3, rx_mix2_text);
-
-/* RX2 MIX1 */
-static const struct soc_enum rx2_mix1_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX2_B1_CTL,
-		0, 6, rx_mix1_text);
-
-static const struct soc_enum rx2_mix1_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX2_B1_CTL,
-		3, 6, rx_mix1_text);
-
-static const struct soc_enum rx2_mix1_inp3_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX2_B1_CTL,
-		0, 6, rx_mix1_text);
-
-/* RX2 MIX2 */
-static const struct soc_enum rx2_mix2_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX2_B3_CTL,
-		0, 3, rx_mix2_text);
-
-/* RX3 MIX1 */
-static const struct soc_enum rx3_mix1_inp1_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX3_B1_CTL,
-		0, 6, rx_mix1_text);
-
-static const struct soc_enum rx3_mix1_inp2_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX3_B1_CTL,
-		3, 6, rx_mix1_text);
-
-static const struct soc_enum rx3_mix1_inp3_chain_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_RX3_B1_CTL,
-		0, 6, rx_mix1_text);
-
-/* DEC */
-static const struct soc_enum dec1_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_B1_CTL,
-		0, 8, dec_mux_text);
-
-static const struct soc_enum dec2_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_B1_CTL,
-		3, 8, dec_mux_text);
-
-static const struct soc_enum dec3_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_B2_CTL,
-		0, 8, dec_mux_text);
-
-static const struct soc_enum dec4_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_B2_CTL,
-		3, 8, dec_mux_text);
-
-static const struct soc_enum decsva_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_TX_B3_CTL,
-		0, 8, dec_mux_text);
-
-static const struct soc_enum iir1_inp1_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL,
-		0, 8, iir_inp1_text);
-
-static const struct soc_enum iir2_inp1_mux_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL,
-		0, 8, iir_inp1_text);
-
-/*cut of frequency for high pass filter*/
-static const char * const cf_text[] = {
-	"MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz"
-};
-
-static const struct soc_enum cf_rxmix1_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_RX1_B4_CTL, 0, 3, cf_text);
-
-static const struct soc_enum cf_rxmix2_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_RX2_B4_CTL, 0, 3, cf_text);
-
-static const struct soc_enum cf_rxmix3_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_RX3_B4_CTL, 0, 3, cf_text);
-
-static const struct snd_kcontrol_new rx3_mix1_inp1_mux =
-	SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum);
-
-#define MSM89XX_DEC_ENUM(xname, xenum) \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
-	.info = snd_soc_info_enum_double, \
-	.get = snd_soc_dapm_get_enum_double, \
-	.put = msm_dig_cdc_put_dec_enum, \
-	.private_value = (unsigned long)&xenum }
-
-static const struct snd_kcontrol_new dec1_mux =
-	MSM89XX_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum);
-
-static const struct snd_kcontrol_new dec2_mux =
-	MSM89XX_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum);
-
-static const struct snd_kcontrol_new dec3_mux =
-	MSM89XX_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum);
-
-static const struct snd_kcontrol_new dec4_mux =
-	MSM89XX_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum);
-
-static const struct snd_kcontrol_new decsva_mux =
-	MSM89XX_DEC_ENUM("DEC5 MUX Mux", decsva_mux_enum);
-
-static const struct snd_kcontrol_new i2s_tx2_inp1_mux =
-	SOC_DAPM_ENUM("I2S TX2 INP1 Mux", i2s_tx2_inp1_chain_enum);
-
-static const struct snd_kcontrol_new i2s_tx2_inp2_mux =
-	SOC_DAPM_ENUM("I2S TX2 INP2 Mux", i2s_tx2_inp2_chain_enum);
-
-static const struct snd_kcontrol_new i2s_tx3_inp2_mux =
-	SOC_DAPM_ENUM("I2S TX3 INP2 Mux", i2s_tx3_inp2_chain_enum);
-
-static const struct snd_kcontrol_new iir1_inp1_mux =
-	SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
-
-static const struct snd_kcontrol_new iir2_inp1_mux =
-	SOC_DAPM_ENUM("IIR2 INP1 Mux", iir2_inp1_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix1_inp1_mux =
-	SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_mix1_inp2_mux =
-	SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_mix1_inp3_mux =
-	SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", rx_mix1_inp3_chain_enum);
-
-static const struct snd_kcontrol_new rx2_mix1_inp1_mux =
-	SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx2_mix1_inp2_mux =
-	SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx2_mix1_inp3_mux =
-	SOC_DAPM_ENUM("RX2 MIX1 INP3 Mux", rx2_mix1_inp3_chain_enum);
-
-static const struct snd_kcontrol_new rx3_mix1_inp2_mux =
-	SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx3_mix1_inp3_mux =
-	SOC_DAPM_ENUM("RX3 MIX1 INP3 Mux", rx3_mix1_inp3_chain_enum);
-
-static const struct snd_kcontrol_new rx1_mix2_inp1_mux =
-	SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", rx_mix2_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx2_mix2_inp1_mux =
-	SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", rx2_mix2_inp1_chain_enum);
-
-static const struct snd_soc_dapm_widget msm_dig_dapm_widgets[] = {
-	SND_SOC_DAPM_AIF_IN("I2S RX1", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_IN("I2S RX2", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_IN("I2S RX3", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_AIF_OUT("I2S TX1", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("I2S TX2", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("I2S TX3", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("I2S TX4", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("I2S TX5", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("I2S TX6", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_MIXER_E("RX1 MIX2", MSM89XX_CDC_CORE_CLK_RX_B1_CTL,
-			     MSM89XX_RX1, 0, NULL, 0,
-			     msm_dig_cdc_codec_enable_interpolator,
-			     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX2 MIX2", MSM89XX_CDC_CORE_CLK_RX_B1_CTL,
-			     MSM89XX_RX2, 0, NULL, 0,
-			     msm_dig_cdc_codec_enable_interpolator,
-			     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX3 MIX1", MSM89XX_CDC_CORE_CLK_RX_B1_CTL,
-			     MSM89XX_RX3, 0, NULL, 0,
-			     msm_dig_cdc_codec_enable_interpolator,
-			     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MIXER("RX1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX2 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MIXER("RX1 CHAIN", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX2 CHAIN", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX3 CHAIN", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_mix1_inp1_mux),
-	SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_mix1_inp2_mux),
-	SND_SOC_DAPM_MUX("RX1 MIX1 INP3", SND_SOC_NOPM, 0, 0,
-		&rx_mix1_inp3_mux),
-
-	SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx2_mix1_inp1_mux),
-	SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx2_mix1_inp2_mux),
-	SND_SOC_DAPM_MUX("RX2 MIX1 INP3", SND_SOC_NOPM, 0, 0,
-		&rx2_mix1_inp3_mux),
-
-	SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx3_mix1_inp1_mux),
-	SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx3_mix1_inp2_mux),
-	SND_SOC_DAPM_MUX("RX3 MIX1 INP3", SND_SOC_NOPM, 0, 0,
-		&rx3_mix1_inp3_mux),
-
-	SND_SOC_DAPM_MUX("RX1 MIX2 INP1", SND_SOC_NOPM, 0, 0,
-		&rx1_mix2_inp1_mux),
-	SND_SOC_DAPM_MUX("RX2 MIX2 INP1", SND_SOC_NOPM, 0, 0,
-		&rx2_mix2_inp1_mux),
-
-	SND_SOC_DAPM_SUPPLY_S("CDC_CONN", -2, MSM89XX_CDC_CORE_CLK_OTHR_CTL,
-		2, 0, NULL, 0),
-
-	SND_SOC_DAPM_MUX_E("DEC1 MUX",
-		MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 0, 0,
-		&dec1_mux, msm_dig_cdc_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("DEC2 MUX",
-		MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 1, 0,
-		&dec2_mux, msm_dig_cdc_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("DEC3 MUX",
-		MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 2, 0,
-		&dec3_mux, msm_dig_cdc_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("DEC4 MUX",
-		MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 3, 0,
-		&dec4_mux, msm_dig_cdc_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("DEC5 MUX",
-		MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 4, 0,
-		&decsva_mux, msm_dig_cdc_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	/* Sidetone */
-	SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
-	SND_SOC_DAPM_PGA_E("IIR1", MSM89XX_CDC_CORE_CLK_SD_CTL, 0, 0, NULL, 0,
-		msm_dig_cdc_codec_set_iir_gain, SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX("IIR2 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp1_mux),
-	SND_SOC_DAPM_PGA_E("IIR2", MSM89XX_CDC_CORE_CLK_SD_CTL, 1, 0, NULL, 0,
-		msm_dig_cdc_codec_set_iir_gain, SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_SUPPLY("RX_I2S_CLK",
-		MSM89XX_CDC_CORE_CLK_RX_I2S_CTL, 4, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("TX_I2S_CLK",
-		MSM89XX_CDC_CORE_CLK_TX_I2S_CTL, 4, 0, NULL, 0),
-
-
-	SND_SOC_DAPM_MUX("I2S TX2 INP1", SND_SOC_NOPM, 0, 0,
-			&i2s_tx2_inp1_mux),
-	SND_SOC_DAPM_MUX("I2S TX2 INP2", SND_SOC_NOPM, 0, 0,
-			&i2s_tx2_inp2_mux),
-	SND_SOC_DAPM_MUX("I2S TX3 INP2", SND_SOC_NOPM, 0, 0,
-			&i2s_tx3_inp2_mux),
-
-	/* Digital Mic Inputs */
-	SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
-		msm_dig_cdc_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
-		msm_dig_cdc_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
-		msm_dig_cdc_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
-		msm_dig_cdc_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_INPUT("ADC1_IN"),
-	SND_SOC_DAPM_INPUT("ADC2_IN"),
-	SND_SOC_DAPM_INPUT("ADC3_IN"),
-	SND_SOC_DAPM_OUTPUT("PDM_OUT_RX1"),
-	SND_SOC_DAPM_OUTPUT("PDM_OUT_RX2"),
-	SND_SOC_DAPM_OUTPUT("PDM_OUT_RX3"),
-};
-
-static const struct soc_enum cf_dec1_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_TX1_MUX_CTL, 4, 3, cf_text);
-
-static const struct soc_enum cf_dec2_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_TX2_MUX_CTL, 4, 3, cf_text);
-
-static const struct soc_enum cf_dec3_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_TX3_MUX_CTL, 4, 3, cf_text);
-
-static const struct soc_enum cf_dec4_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_TX4_MUX_CTL, 4, 3, cf_text);
-
-static const struct soc_enum cf_decsva_enum =
-	SOC_ENUM_SINGLE(MSM89XX_CDC_CORE_TX5_MUX_CTL, 4, 3, cf_text);
-
-static const struct snd_kcontrol_new msm_dig_snd_controls[] = {
-	SOC_SINGLE_SX_TLV("DEC1 Volume",
-		MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC2 Volume",
-		  MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC3 Volume",
-		  MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC4 Volume",
-		  MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC5 Volume",
-		  MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN,
-		0, -84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
-			  MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
-			  MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL,
-			0,  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
-			  MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL,
-			0,  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP4 Volume",
-			  MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL,
-			0,  -84,	40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR2 INP1 Volume",
-			  MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("RX1 Digital Volume",
-		MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX2 Digital Volume",
-		MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX3 Digital Volume",
-		MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL,
-		0, -84, 40, digital_gain),
-
-	SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-
-	SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0,
-		msm_dig_cdc_get_iir_enable_audio_mixer,
-		msm_dig_cdc_put_iir_enable_audio_mixer),
-
-	SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-
-	SOC_SINGLE_MULTI_EXT("IIR2 Band1", IIR2, BAND1, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR2 Band2", IIR2, BAND2, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR2 Band3", IIR2, BAND3, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR2 Band4", IIR2, BAND4, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR2 Band5", IIR2, BAND5, 255, 0, 5,
-		msm_dig_cdc_get_iir_band_audio_mixer,
-		msm_dig_cdc_put_iir_band_audio_mixer),
-
-	SOC_SINGLE("RX1 HPF Switch",
-		MSM89XX_CDC_CORE_RX1_B5_CTL, 2, 1, 0),
-	SOC_SINGLE("RX2 HPF Switch",
-		MSM89XX_CDC_CORE_RX2_B5_CTL, 2, 1, 0),
-	SOC_SINGLE("RX3 HPF Switch",
-		MSM89XX_CDC_CORE_RX3_B5_CTL, 2, 1, 0),
-
-	SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum),
-	SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum),
-	SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum),
-
-	SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
-	SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
-	SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
-	SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
-	SOC_ENUM("TX5 HPF cut off", cf_decsva_enum),
-	SOC_SINGLE("TX1 HPF Switch",
-		MSM89XX_CDC_CORE_TX1_MUX_CTL, 3, 1, 0),
-	SOC_SINGLE("TX2 HPF Switch",
-		MSM89XX_CDC_CORE_TX2_MUX_CTL, 3, 1, 0),
-	SOC_SINGLE("TX3 HPF Switch",
-		MSM89XX_CDC_CORE_TX3_MUX_CTL, 3, 1, 0),
-	SOC_SINGLE("TX4 HPF Switch",
-		MSM89XX_CDC_CORE_TX4_MUX_CTL, 3, 1, 0),
-	SOC_SINGLE("TX5 HPF Switch",
-		MSM89XX_CDC_CORE_TX5_MUX_CTL, 3, 1, 0),
-};
-
-static int msm_dig_cdc_digital_mute(struct snd_soc_dai *dai, int mute)
-{
-	struct snd_soc_codec *codec = NULL;
-	u16 tx_vol_ctl_reg = 0;
-	u8 decimator = 0, i;
-	struct msm_dig_priv *dig_cdc;
-
-	pr_debug("%s: Digital Mute val = %d\n", __func__, mute);
-
-	if (!dai || !dai->codec) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	codec = dai->codec;
-	dig_cdc = snd_soc_codec_get_drvdata(codec);
-
-	if (dai->id == AIF1_PB) {
-		dev_dbg(codec->dev, "%s: Not capture use case skip\n",
-			__func__);
-		return 0;
-	}
-
-	mute = (mute) ? 1 : 0;
-	if (!mute) {
-		/*
-		 * 15 ms is an emperical value for the mute time
-		 * that was arrived by checking the pop level
-		 * to be inaudible
-		 */
-		usleep_range(15000, 15010);
-	}
-
-	if (dai->id == AIF3_SVA) {
-		snd_soc_update_bits(codec,
-			MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG, 0x01, mute);
-		goto ret;
-	}
-	for (i = 0; i < (NUM_DECIMATORS - 1); i++) {
-		if (dig_cdc->dec_active[i])
-			decimator = i + 1;
-		if (decimator && decimator < NUM_DECIMATORS) {
-			/* mute/unmute decimators corresponding to Tx DAI's */
-			tx_vol_ctl_reg =
-			MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG +
-					32 * (decimator - 1);
-			snd_soc_update_bits(codec, tx_vol_ctl_reg,
-					    0x01, mute);
-		}
-		decimator = 0;
-	}
-ret:
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_dig_dai_ops = {
-	.hw_params = msm_dig_cdc_hw_params,
-	.digital_mute = msm_dig_cdc_digital_mute,
-};
-
-
-static struct snd_soc_dai_driver msm_codec_dais[] = {
-	{
-		.name = "msm_dig_cdc_dai_rx1",
-		.id = AIF1_PB,
-		.playback = { /* Support maximum range */
-			.stream_name = "AIF1 Playback",
-			.channels_min = 1,
-			.channels_max = 2,
-			.rates = SNDRV_PCM_RATE_8000_192000,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-		},
-		 .ops = &msm_dig_dai_ops,
-	},
-	{
-		.name = "msm_dig_cdc_dai_tx1",
-		.id = AIF1_CAP,
-		.capture = { /* Support maximum range */
-			.stream_name = "AIF1 Capture",
-			.channels_min = 1,
-			.channels_max = 4,
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		},
-		 .ops = &msm_dig_dai_ops,
-	},
-	{
-		.name = "msm_dig_cdc_dai_tx2",
-		.id = AIF3_SVA,
-		.capture = { /* Support maximum range */
-			.stream_name = "AIF2 Capture",
-			.channels_min = 1,
-			.channels_max = 2,
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		},
-		 .ops = &msm_dig_dai_ops,
-	},
-	{
-		.name = "msm_dig_cdc_dai_vifeed",
-		.id = AIF2_VIFEED,
-		.capture = { /* Support maximum range */
-			.stream_name = "AIF2 Capture",
-			.channels_min = 1,
-			.channels_max = 2,
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		},
-		 .ops = &msm_dig_dai_ops,
-	},
-};
-
-static struct regmap *msm_digital_get_regmap(struct device *dev)
-{
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(dev);
-
-	return msm_dig_cdc->regmap;
-}
-
-static int msm_dig_cdc_suspend(struct snd_soc_codec *codec)
-{
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(codec->dev);
-
-	msm_dig_cdc->dapm_bias_off = 1;
-	return 0;
-}
-
-static int msm_dig_cdc_resume(struct snd_soc_codec *codec)
-{
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(codec->dev);
-
-	msm_dig_cdc->dapm_bias_off = 0;
-	return 0;
-}
-
-static struct snd_soc_codec_driver soc_msm_dig_codec = {
-	.probe  = msm_dig_cdc_soc_probe,
-	.remove = msm_dig_cdc_soc_remove,
-	.suspend = msm_dig_cdc_suspend,
-	.resume = msm_dig_cdc_resume,
-	.get_regmap = msm_digital_get_regmap,
-	.component_driver = {
-		.controls = msm_dig_snd_controls,
-		.num_controls = ARRAY_SIZE(msm_dig_snd_controls),
-		.dapm_widgets = msm_dig_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(msm_dig_dapm_widgets),
-		.dapm_routes = audio_dig_map,
-		.num_dapm_routes = ARRAY_SIZE(audio_dig_map),
-	},
-};
-
-const struct regmap_config msm_digital_regmap_config = {
-	.reg_bits = 32,
-	.reg_stride = 4,
-	.val_bits = 8,
-	.lock = enable_digital_callback,
-	.unlock = disable_digital_callback,
-	.cache_type = REGCACHE_FLAT,
-	.reg_defaults = msm89xx_cdc_core_defaults,
-	.num_reg_defaults = MSM89XX_CDC_CORE_MAX_REGISTER,
-	.writeable_reg = msm89xx_cdc_core_writeable_reg,
-	.readable_reg = msm89xx_cdc_core_readable_reg,
-	.volatile_reg = msm89xx_cdc_core_volatile_reg,
-	.reg_format_endian = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian = REGMAP_ENDIAN_NATIVE,
-	.max_register = MSM89XX_CDC_CORE_MAX_REGISTER,
-};
-
-static int msm_dig_cdc_probe(struct platform_device *pdev)
-{
-	int ret;
-	u32 dig_cdc_addr;
-	struct msm_dig_priv *msm_dig_cdc;
-	struct dig_ctrl_platform_data *pdata;
-
-	msm_dig_cdc = devm_kzalloc(&pdev->dev, sizeof(struct msm_dig_priv),
-			      GFP_KERNEL);
-	if (!msm_dig_cdc)
-		return -ENOMEM;
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "%s: pdata from parent is NULL\n",
-			__func__);
-		ret = -EINVAL;
-		goto rtn;
-	}
-
-	ret = of_property_read_u32(pdev->dev.of_node, "reg",
-					&dig_cdc_addr);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
-			__func__, "reg");
-		return ret;
-	}
-
-	msm_dig_cdc->dig_base = ioremap(dig_cdc_addr,
-					MSM89XX_CDC_CORE_MAX_REGISTER);
-	if (msm_dig_cdc->dig_base == NULL) {
-		dev_err(&pdev->dev, "%s ioremap failed\n", __func__);
-		return -ENOMEM;
-	}
-	msm_dig_cdc->regmap =
-		devm_regmap_init_mmio_clk(&pdev->dev, NULL,
-			msm_dig_cdc->dig_base, &msm_digital_regmap_config);
-
-	msm_dig_cdc->update_clkdiv = pdata->update_clkdiv;
-	msm_dig_cdc->get_cdc_version = pdata->get_cdc_version;
-	msm_dig_cdc->handle = pdata->handle;
-	msm_dig_cdc->register_notifier = pdata->register_notifier;
-
-	dev_set_drvdata(&pdev->dev, msm_dig_cdc);
-	snd_soc_register_codec(&pdev->dev, &soc_msm_dig_codec,
-				msm_codec_dais, ARRAY_SIZE(msm_codec_dais));
-	dev_dbg(&pdev->dev, "%s: registered DIG CODEC 0x%x\n",
-			__func__, dig_cdc_addr);
-rtn:
-	return ret;
-}
-
-static int msm_dig_cdc_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_codec(&pdev->dev);
-	return 0;
-}
-
-#ifdef CONFIG_PM
-static int msm_dig_suspend(struct device *dev)
-{
-	struct msm_asoc_mach_data *pdata;
-	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(dev);
-
-	if (!registered_digcodec || !msm_dig_cdc) {
-		pr_debug("%s:digcodec not initialized, return\n", __func__);
-		return 0;
-	}
-	pdata = snd_soc_card_get_drvdata(registered_digcodec->component.card);
-	if (!pdata) {
-		pr_debug("%s:card not initialized, return\n", __func__);
-		return 0;
-	}
-	if (msm_dig_cdc->dapm_bias_off) {
-		pr_debug("%s: mclk cnt = %d, mclk_enabled = %d\n",
-			__func__, atomic_read(&pdata->int_mclk0_rsc_ref),
-			atomic_read(&pdata->int_mclk0_enabled));
-
-		if (atomic_read(&pdata->int_mclk0_enabled) == true) {
-			cancel_delayed_work_sync(
-				&pdata->disable_int_mclk0_work);
-			mutex_lock(&pdata->cdc_int_mclk0_mutex);
-			pdata->digital_cdc_core_clk.enable = 0;
-			afe_set_lpass_clock_v2(AFE_PORT_ID_INT0_MI2S_RX,
-						&pdata->digital_cdc_core_clk);
-			atomic_set(&pdata->int_mclk0_enabled, false);
-			mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		}
-	}
-
-	return 0;
-}
-
-static int msm_dig_resume(struct device *dev)
-{
-	return 0;
-}
-
-static const struct dev_pm_ops msm_dig_pm_ops = {
-	.suspend_late = msm_dig_suspend,
-	.resume_early = msm_dig_resume,
-};
-#endif
-
-static const struct of_device_id msm_dig_cdc_of_match[] = {
-	{.compatible = "qcom,msm-digital-codec"},
-	{},
-};
-
-static struct platform_driver msm_digcodec_driver = {
-	.driver                 = {
-		.owner          = THIS_MODULE,
-		.name           = DRV_NAME,
-		.of_match_table = msm_dig_cdc_of_match,
-#ifdef CONFIG_PM
-	.pm = &msm_dig_pm_ops,
-#endif
-	},
-	.probe                  = msm_dig_cdc_probe,
-	.remove                 = msm_dig_cdc_remove,
-};
-module_platform_driver(msm_digcodec_driver);
-
-MODULE_DESCRIPTION("MSM Audio Digital codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.h b/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.h
deleted file mode 100644
index f0e7a9c..0000000
--- a/sound/soc/codecs/sdm660_cdc/msm-digital-cdc.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 MSM_DIGITAL_CDC_H
-#define MSM_DIGITAL_CDC_H
-
-#define HPHL_PA_DISABLE (0x01 << 1)
-#define HPHR_PA_DISABLE (0x01 << 2)
-#define SPKR_PA_DISABLE (0x01 << 3)
-
-#define NUM_DECIMATORS	5
-/* Codec supports 1 compander */
-enum {
-	COMPANDER_NONE = 0,
-	COMPANDER_1, /* HPHL/R */
-	COMPANDER_MAX,
-};
-
-/* Number of output I2S port */
-enum {
-	MSM89XX_RX1 = 0,
-	MSM89XX_RX2,
-	MSM89XX_RX3,
-	MSM89XX_RX_MAX,
-};
-
-struct msm_dig_priv {
-	struct snd_soc_codec *codec;
-	u32 comp_enabled[MSM89XX_RX_MAX];
-	int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec);
-	s32 dmic_1_2_clk_cnt;
-	s32 dmic_3_4_clk_cnt;
-	bool dec_active[NUM_DECIMATORS];
-	int version;
-	/* Entry for version info */
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-	char __iomem *dig_base;
-	struct regmap *regmap;
-	struct notifier_block nblock;
-	u32 mute_mask;
-	int dapm_bias_off;
-	void *handle;
-	void (*update_clkdiv)(void *handle, int val);
-	int (*get_cdc_version)(void *handle);
-	int (*register_notifier)(void *handle,
-				 struct notifier_block *nblock,
-				 bool enable);
-};
-
-struct dig_ctrl_platform_data {
-	void *handle;
-	void (*update_clkdiv)(void *handle, int val);
-	int (*get_cdc_version)(void *handle);
-	int (*register_notifier)(void *handle,
-				 struct notifier_block *nblock,
-				 bool enable);
-};
-
-struct hpf_work {
-	struct msm_dig_priv *dig_cdc;
-	u32 decimator;
-	u8 tx_hpf_cut_of_freq;
-	struct delayed_work dwork;
-};
-
-/* Codec supports 5 bands */
-enum {
-	BAND1 = 0,
-	BAND2,
-	BAND3,
-	BAND4,
-	BAND5,
-	BAND_MAX,
-};
-
-extern void msm_dig_cdc_hph_comp_cb(
-		int (*codec_hph_comp_gpio)(
-			bool enable, struct snd_soc_codec *codec),
-		struct snd_soc_codec *codec);
-int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					  struct snd_soc_codec *codec);
-#endif
diff --git a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.c b/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.c
deleted file mode 100644
index ee4ec34..0000000
--- a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/bitops.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/of_irq.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/spmi.h>
-#include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
-#include <linux/interrupt.h>
-#include <linux/pm_qos.h>
-#include <soc/qcom/pm.h>
-#include <sound/soc.h>
-#include "msm-analog-cdc.h"
-#include "sdm660-cdc-irq.h"
-#include "sdm660-cdc-registers.h"
-
-#define MAX_NUM_IRQS 14
-#define NUM_IRQ_REGS 2
-#define WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS 700
-
-#define BYTE_BIT_MASK(nr) (1UL << ((nr) % BITS_PER_BYTE))
-#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
-
-static irqreturn_t wcd9xxx_spmi_irq_handler(int linux_irq, void *data);
-
-char *irq_names[MAX_NUM_IRQS] = {
-	"spk_cnp_int",
-	"spk_clip_int",
-	"spk_ocp_int",
-	"ins_rem_det1",
-	"but_rel_det",
-	"but_press_det",
-	"ins_rem_det",
-	"mbhc_int",
-	"ear_ocp_int",
-	"hphr_ocp_int",
-	"hphl_ocp_det",
-	"ear_cnp_int",
-	"hphr_cnp_int",
-	"hphl_cnp_int"
-};
-
-int order[MAX_NUM_IRQS] = {
-	MSM89XX_IRQ_SPKR_CNP,
-	MSM89XX_IRQ_SPKR_CLIP,
-	MSM89XX_IRQ_SPKR_OCP,
-	MSM89XX_IRQ_MBHC_INSREM_DET1,
-	MSM89XX_IRQ_MBHC_RELEASE,
-	MSM89XX_IRQ_MBHC_PRESS,
-	MSM89XX_IRQ_MBHC_INSREM_DET,
-	MSM89XX_IRQ_MBHC_HS_DET,
-	MSM89XX_IRQ_EAR_OCP,
-	MSM89XX_IRQ_HPHR_OCP,
-	MSM89XX_IRQ_HPHL_OCP,
-	MSM89XX_IRQ_EAR_CNP,
-	MSM89XX_IRQ_HPHR_CNP,
-	MSM89XX_IRQ_HPHL_CNP,
-};
-
-enum wcd9xxx_spmi_pm_state {
-	WCD9XXX_PM_SLEEPABLE,
-	WCD9XXX_PM_AWAKE,
-	WCD9XXX_PM_ASLEEP,
-};
-
-struct wcd9xxx_spmi_map {
-	uint8_t handled[NUM_IRQ_REGS];
-	uint8_t mask[NUM_IRQ_REGS];
-	int linuxirq[MAX_NUM_IRQS];
-	irq_handler_t handler[MAX_NUM_IRQS];
-	struct platform_device *spmi[NUM_IRQ_REGS];
-	struct snd_soc_codec *codec;
-
-	enum wcd9xxx_spmi_pm_state pm_state;
-	struct mutex pm_lock;
-	/* pm_wq notifies change of pm_state */
-	wait_queue_head_t pm_wq;
-	struct pm_qos_request pm_qos_req;
-	int wlock_holders;
-};
-
-struct wcd9xxx_spmi_map map;
-
-void wcd9xxx_spmi_enable_irq(int irq)
-{
-	pr_debug("%s: irqno =%d\n", __func__, irq);
-
-	if (!(map.mask[BIT_BYTE(irq)] & (BYTE_BIT_MASK(irq))))
-		return;
-
-	map.mask[BIT_BYTE(irq)] &=
-		~(BYTE_BIT_MASK(irq));
-
-	enable_irq(map.linuxirq[irq]);
-}
-
-void wcd9xxx_spmi_disable_irq(int irq)
-{
-	pr_debug("%s: irqno =%d\n", __func__, irq);
-
-	if (map.mask[BIT_BYTE(irq)] & (BYTE_BIT_MASK(irq)))
-		return;
-
-	map.mask[BIT_BYTE(irq)] |=
-		(BYTE_BIT_MASK(irq));
-
-	disable_irq_nosync(map.linuxirq[irq]);
-}
-
-int wcd9xxx_spmi_request_irq(int irq, irq_handler_t handler,
-			const char *name, void *priv)
-{
-	int rc;
-	unsigned long irq_flags;
-
-	map.linuxirq[irq] =
-		platform_get_irq_byname(map.spmi[BIT_BYTE(irq)],
-					irq_names[irq]);
-
-	if (strcmp(name, "mbhc sw intr"))
-		irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
-			IRQF_ONESHOT;
-	else
-		irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
-			IRQF_ONESHOT | IRQF_NO_SUSPEND;
-	pr_debug("%s: name:%s irq_flags = %lx\n", __func__, name, irq_flags);
-
-	rc = devm_request_threaded_irq(&map.spmi[BIT_BYTE(irq)]->dev,
-				map.linuxirq[irq], NULL,
-				wcd9xxx_spmi_irq_handler,
-				irq_flags,
-				name, priv);
-		if (rc < 0) {
-			dev_err(&map.spmi[BIT_BYTE(irq)]->dev,
-				"Can't request %d IRQ\n", irq);
-			return rc;
-		}
-
-	dev_dbg(&map.spmi[BIT_BYTE(irq)]->dev,
-			"irq %d linuxIRQ: %d\n", irq, map.linuxirq[irq]);
-	map.mask[BIT_BYTE(irq)] &= ~BYTE_BIT_MASK(irq);
-	map.handler[irq] = handler;
-	enable_irq_wake(map.linuxirq[irq]);
-	return 0;
-}
-
-int wcd9xxx_spmi_free_irq(int irq, void *priv)
-{
-	devm_free_irq(&map.spmi[BIT_BYTE(irq)]->dev, map.linuxirq[irq],
-						priv);
-	map.mask[BIT_BYTE(irq)] |= BYTE_BIT_MASK(irq);
-	return 0;
-}
-
-static int get_irq_bit(int linux_irq)
-{
-	int i = 0;
-
-	for (; i < MAX_NUM_IRQS; i++)
-		if (map.linuxirq[i] == linux_irq)
-			return i;
-
-	return i;
-}
-
-static int get_order_irq(int  i)
-{
-	return order[i];
-}
-
-static irqreturn_t wcd9xxx_spmi_irq_handler(int linux_irq, void *data)
-{
-	int irq, i, j;
-	unsigned long status[NUM_IRQ_REGS] = {0};
-
-	if (unlikely(wcd9xxx_spmi_lock_sleep() == false)) {
-		pr_err("Failed to hold suspend\n");
-		return IRQ_NONE;
-	}
-
-	irq = get_irq_bit(linux_irq);
-	if (irq == MAX_NUM_IRQS)
-		return IRQ_HANDLED;
-
-	status[BIT_BYTE(irq)] |= BYTE_BIT_MASK(irq);
-	for (i = 0; i < NUM_IRQ_REGS; i++) {
-		status[i] |= snd_soc_read(map.codec,
-				BIT_BYTE(irq) * 0x100 +
-			MSM89XX_PMIC_DIGITAL_INT_LATCHED_STS);
-		status[i] &= ~map.mask[i];
-	}
-	for (i = 0; i < MAX_NUM_IRQS; i++) {
-		j = get_order_irq(i);
-		if ((status[BIT_BYTE(j)] & BYTE_BIT_MASK(j)) &&
-			((map.handled[BIT_BYTE(j)] &
-			BYTE_BIT_MASK(j)) == 0)) {
-			map.handler[j](irq, data);
-			map.handled[BIT_BYTE(j)] |=
-					BYTE_BIT_MASK(j);
-		}
-	}
-	map.handled[BIT_BYTE(irq)] &= ~BYTE_BIT_MASK(irq);
-	wcd9xxx_spmi_unlock_sleep();
-
-	return IRQ_HANDLED;
-}
-
-enum wcd9xxx_spmi_pm_state wcd9xxx_spmi_pm_cmpxchg(
-		enum wcd9xxx_spmi_pm_state o,
-		enum wcd9xxx_spmi_pm_state n)
-{
-	enum wcd9xxx_spmi_pm_state old;
-
-	mutex_lock(&map.pm_lock);
-	old = map.pm_state;
-	if (old == o)
-		map.pm_state = n;
-	pr_debug("%s: map.pm_state = %d\n", __func__, map.pm_state);
-	mutex_unlock(&map.pm_lock);
-	return old;
-}
-EXPORT_SYMBOL(wcd9xxx_spmi_pm_cmpxchg);
-
-int wcd9xxx_spmi_suspend(pm_message_t pmesg)
-{
-	int ret = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	/*
-	 * pm_qos_update_request() can be called after this suspend chain call
-	 * started. thus suspend can be called while lock is being held
-	 */
-	mutex_lock(&map.pm_lock);
-	if (map.pm_state == WCD9XXX_PM_SLEEPABLE) {
-		pr_debug("%s: suspending system, state %d, wlock %d\n",
-			 __func__, map.pm_state,
-			 map.wlock_holders);
-		map.pm_state = WCD9XXX_PM_ASLEEP;
-	} else if (map.pm_state == WCD9XXX_PM_AWAKE) {
-		/*
-		 * unlock to wait for pm_state == WCD9XXX_PM_SLEEPABLE
-		 * then set to WCD9XXX_PM_ASLEEP
-		 */
-		pr_debug("%s: waiting to suspend system, state %d, wlock %d\n",
-			 __func__, map.pm_state,
-			 map.wlock_holders);
-		mutex_unlock(&map.pm_lock);
-		if (!(wait_event_timeout(map.pm_wq,
-					 wcd9xxx_spmi_pm_cmpxchg(
-							WCD9XXX_PM_SLEEPABLE,
-							WCD9XXX_PM_ASLEEP) ==
-							WCD9XXX_PM_SLEEPABLE,
-							HZ))) {
-			pr_debug("%s: suspend failed state %d, wlock %d\n",
-				 __func__, map.pm_state,
-				 map.wlock_holders);
-			ret = -EBUSY;
-		} else {
-			pr_debug("%s: done, state %d, wlock %d\n", __func__,
-				 map.pm_state,
-				 map.wlock_holders);
-		}
-		mutex_lock(&map.pm_lock);
-	} else if (map.pm_state == WCD9XXX_PM_ASLEEP) {
-		pr_warn("%s: system is already suspended, state %d, wlock %dn",
-			__func__, map.pm_state,
-			map.wlock_holders);
-	}
-	mutex_unlock(&map.pm_lock);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_spmi_suspend);
-
-int wcd9xxx_spmi_resume(void)
-{
-	int ret = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	mutex_lock(&map.pm_lock);
-	if (map.pm_state == WCD9XXX_PM_ASLEEP) {
-		pr_debug("%s: resuming system, state %d, wlock %d\n", __func__,
-				map.pm_state,
-				map.wlock_holders);
-		map.pm_state = WCD9XXX_PM_SLEEPABLE;
-	} else {
-		pr_warn("%s: system is already awake, state %d wlock %d\n",
-				__func__, map.pm_state,
-				map.wlock_holders);
-	}
-	mutex_unlock(&map.pm_lock);
-	wake_up_all(&map.pm_wq);
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd9xxx_spmi_resume);
-
-bool wcd9xxx_spmi_lock_sleep(void)
-{
-	/*
-	 * wcd9xxx_spmi_{lock/unlock}_sleep will be called by
-	 * wcd9xxx_spmi_irq_thread
-	 * and its subroutines only motly.
-	 * but btn0_lpress_fn is not wcd9xxx_spmi_irq_thread's subroutine and
-	 * It can race with wcd9xxx_spmi_irq_thread.
-	 * So need to embrace wlock_holders with mutex.
-	 */
-	mutex_lock(&map.pm_lock);
-	if (map.wlock_holders++ == 0) {
-		pr_debug("%s: holding wake lock\n", __func__);
-		pm_qos_update_request(&map.pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-		pm_stay_awake(&map.spmi[0]->dev);
-	}
-	mutex_unlock(&map.pm_lock);
-	pr_debug("%s: wake lock counter %d\n", __func__,
-			map.wlock_holders);
-	pr_debug("%s: map.pm_state = %d\n", __func__, map.pm_state);
-
-	if (!wait_event_timeout(map.pm_wq,
-				((wcd9xxx_spmi_pm_cmpxchg(
-					WCD9XXX_PM_SLEEPABLE,
-					WCD9XXX_PM_AWAKE)) ==
-					WCD9XXX_PM_SLEEPABLE ||
-					(wcd9xxx_spmi_pm_cmpxchg(
-						 WCD9XXX_PM_SLEEPABLE,
-						 WCD9XXX_PM_AWAKE) ==
-						 WCD9XXX_PM_AWAKE)),
-					msecs_to_jiffies(
-					WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) {
-		pr_warn("%s: system didn't resume within %dms, s %d, w %d\n",
-			__func__,
-			WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS, map.pm_state,
-			map.wlock_holders);
-		wcd9xxx_spmi_unlock_sleep();
-		return false;
-	}
-	wake_up_all(&map.pm_wq);
-	pr_debug("%s: leaving pm_state = %d\n", __func__, map.pm_state);
-	return true;
-}
-EXPORT_SYMBOL(wcd9xxx_spmi_lock_sleep);
-
-void wcd9xxx_spmi_unlock_sleep(void)
-{
-	mutex_lock(&map.pm_lock);
-	if (--map.wlock_holders == 0) {
-		pr_debug("%s: releasing wake lock pm_state %d -> %d\n",
-			 __func__, map.pm_state, WCD9XXX_PM_SLEEPABLE);
-		/*
-		 * if wcd9xxx_spmi_lock_sleep failed, pm_state would be still
-		 * WCD9XXX_PM_ASLEEP, don't overwrite
-		 */
-		if (likely(map.pm_state == WCD9XXX_PM_AWAKE))
-			map.pm_state = WCD9XXX_PM_SLEEPABLE;
-		pm_qos_update_request(&map.pm_qos_req,
-				PM_QOS_DEFAULT_VALUE);
-		pm_relax(&map.spmi[0]->dev);
-	}
-	mutex_unlock(&map.pm_lock);
-	pr_debug("%s: wake lock counter %d\n", __func__,
-			map.wlock_holders);
-	pr_debug("%s: map.pm_state = %d\n", __func__, map.pm_state);
-	wake_up_all(&map.pm_wq);
-}
-EXPORT_SYMBOL(wcd9xxx_spmi_unlock_sleep);
-
-void wcd9xxx_spmi_set_codec(struct snd_soc_codec *codec)
-{
-	map.codec = codec;
-}
-
-void wcd9xxx_spmi_set_dev(struct platform_device *spmi, int i)
-{
-	if (i < NUM_IRQ_REGS)
-		map.spmi[i] = spmi;
-}
-
-int wcd9xxx_spmi_irq_init(void)
-{
-	int i = 0;
-
-	for (; i < MAX_NUM_IRQS; i++)
-		map.mask[BIT_BYTE(i)] |= BYTE_BIT_MASK(i);
-	mutex_init(&map.pm_lock);
-	map.wlock_holders = 0;
-	map.pm_state = WCD9XXX_PM_SLEEPABLE;
-	init_waitqueue_head(&map.pm_wq);
-	pm_qos_add_request(&map.pm_qos_req,
-				PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-
-	return 0;
-}
-
-MODULE_DESCRIPTION("MSM8x16 SPMI IRQ driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.h b/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.h
deleted file mode 100644
index d0f48d0..0000000
--- a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-irq.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9XXX_SPMI_IRQ_H__
-#define __WCD9XXX_SPMI_IRQ_H__
-
-#include <sound/soc.h>
-#include <linux/spmi.h>
-#include <linux/platform_device.h>
-#include <linux/irq.h>
-#include <linux/pm_qos.h>
-
-extern void wcd9xxx_spmi_enable_irq(int irq);
-extern void wcd9xxx_spmi_disable_irq(int irq);
-extern int wcd9xxx_spmi_request_irq(int irq, irq_handler_t handler,
-				const char *name, void *priv);
-extern int wcd9xxx_spmi_free_irq(int irq, void *priv);
-extern void wcd9xxx_spmi_set_codec(struct snd_soc_codec *codec);
-extern void wcd9xxx_spmi_set_dev(struct platform_device *spmi, int i);
-extern int wcd9xxx_spmi_irq_init(void);
-extern int wcd9xxx_spmi_suspend(pm_message_t pmesg);
-extern int wcd9xxx_spmi_resume(void);
-bool wcd9xxx_spmi_lock_sleep(void);
-void wcd9xxx_spmi_unlock_sleep(void);
-
-#endif
diff --git a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-registers.h b/sound/soc/codecs/sdm660_cdc/sdm660-cdc-registers.h
deleted file mode 100644
index 1317ce1..0000000
--- a/sound/soc/codecs/sdm660_cdc/sdm660-cdc-registers.h
+++ /dev/null
@@ -1,603 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 SDM660_WCD_REGISTERS_H
-#define SDM660_WCD_REGISTERS_H
-
-#define CDC_DIG_BASE		0xF000
-#define CDC_ANA_BASE		0xF100
-
-#define MSM89XX_PMIC_DIGITAL_REVISION1		(CDC_DIG_BASE+0x000)
-#define MSM89XX_PMIC_DIGITAL_REVISION1__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_REVISION2		(CDC_DIG_BASE+0x001)
-#define MSM89XX_PMIC_DIGITAL_REVISION2__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_PERPH_TYPE		(CDC_DIG_BASE+0x004)
-#define MSM89XX_PMIC_DIGITAL_PERPH_TYPE__POR		(0x23)
-#define MSM89XX_PMIC_DIGITAL_PERPH_SUBTYPE		(CDC_DIG_BASE+0x005)
-#define MSM89XX_PMIC_DIGITAL_PERPH_SUBTYPE__POR		(0x01)
-#define MSM89XX_PMIC_DIGITAL_INT_RT_STS		(CDC_DIG_BASE+0x010)
-#define MSM89XX_PMIC_DIGITAL_INT_RT_STS__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_SET_TYPE		(CDC_DIG_BASE+0x011)
-#define MSM89XX_PMIC_DIGITAL_INT_SET_TYPE__POR		(0xFF)
-#define MSM89XX_PMIC_DIGITAL_INT_POLARITY_HIGH		(CDC_DIG_BASE+0x012)
-#define MSM89XX_PMIC_DIGITAL_INT_POLARITY_HIGH__POR		(0xFF)
-#define MSM89XX_PMIC_DIGITAL_INT_POLARITY_LOW		(CDC_DIG_BASE+0x013)
-#define MSM89XX_PMIC_DIGITAL_INT_POLARITY_LOW__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_LATCHED_CLR		(CDC_DIG_BASE+0x014)
-#define MSM89XX_PMIC_DIGITAL_INT_LATCHED_CLR__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_EN_SET		(CDC_DIG_BASE+0x015)
-#define MSM89XX_PMIC_DIGITAL_INT_EN_SET__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_EN_CLR		(CDC_DIG_BASE+0x016)
-#define MSM89XX_PMIC_DIGITAL_INT_EN_CLR__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_LATCHED_STS		(CDC_DIG_BASE+0x018)
-#define MSM89XX_PMIC_DIGITAL_INT_LATCHED_STS__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_PENDING_STS		(CDC_DIG_BASE+0x019)
-#define MSM89XX_PMIC_DIGITAL_INT_PENDING_STS__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_MID_SEL		(CDC_DIG_BASE+0x01A)
-#define MSM89XX_PMIC_DIGITAL_INT_MID_SEL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_PRIORITY		(CDC_DIG_BASE+0x01B)
-#define MSM89XX_PMIC_DIGITAL_INT_PRIORITY__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_GPIO_MODE		(CDC_DIG_BASE+0x040)
-#define MSM89XX_PMIC_DIGITAL_GPIO_MODE__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_PIN_CTL_OE		(CDC_DIG_BASE+0x041)
-#define MSM89XX_PMIC_DIGITAL_PIN_CTL_OE__POR		(0x01)
-#define MSM89XX_PMIC_DIGITAL_PIN_CTL_DATA		(CDC_DIG_BASE+0x042)
-#define MSM89XX_PMIC_DIGITAL_PIN_CTL_DATA__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_PIN_STATUS		(CDC_DIG_BASE+0x043)
-#define MSM89XX_PMIC_DIGITAL_PIN_STATUS__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_HDRIVE_CTL		(CDC_DIG_BASE+0x044)
-#define MSM89XX_PMIC_DIGITAL_HDRIVE_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_RST_CTL		(CDC_DIG_BASE+0x046)
-#define MSM89XX_PMIC_DIGITAL_CDC_RST_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL		(CDC_DIG_BASE+0x048)
-#define MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL		(CDC_DIG_BASE+0x049)
-#define MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL		(CDC_DIG_BASE+0x04A)
-#define MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_TX1_CTL		(CDC_DIG_BASE+0x050)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_TX1_CTL__POR		(0x02)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_TX2_CTL		(CDC_DIG_BASE+0x051)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_TX2_CTL__POR		(0x02)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_HPHR_DAC_CTL	(CDC_DIG_BASE+0x052)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_HPHR_DAC_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX1_CTL		(CDC_DIG_BASE+0x053)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX1_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX2_CTL		(CDC_DIG_BASE+0x054)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX2_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX3_CTL		(CDC_DIG_BASE+0x055)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX3_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX_LB_CTL	(CDC_DIG_BASE+0x056)
-#define MSM89XX_PMIC_DIGITAL_CDC_CONN_RX_LB_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL1		(CDC_DIG_BASE+0x058)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL1__POR		(0x7C)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL2		(CDC_DIG_BASE+0x059)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL2__POR		(0x7C)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL3		(CDC_DIG_BASE+0x05A)
-#define MSM89XX_PMIC_DIGITAL_CDC_RX_CTL3__POR		(0x7C)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA0		(CDC_DIG_BASE+0x05B)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA0__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA1		(CDC_DIG_BASE+0x05C)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA1__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA2		(CDC_DIG_BASE+0x05D)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA2__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA3		(CDC_DIG_BASE+0x05E)
-#define MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA3__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_DIG_DEBUG_CTL		(CDC_DIG_BASE+0x068)
-#define MSM89XX_PMIC_DIGITAL_DIG_DEBUG_CTL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_DIG_DEBUG_EN		(CDC_DIG_BASE+0x069)
-#define MSM89XX_PMIC_DIGITAL_DIG_DEBUG_EN__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_SPARE_0		(CDC_DIG_BASE+0x070)
-#define MSM89XX_PMIC_DIGITAL_SPARE_0__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_SPARE_1		(CDC_DIG_BASE+0x071)
-#define MSM89XX_PMIC_DIGITAL_SPARE_1__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_SPARE_2		(CDC_DIG_BASE+0x072)
-#define MSM89XX_PMIC_DIGITAL_SPARE_2__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_SEC_ACCESS		(CDC_DIG_BASE+0x0D0)
-#define MSM89XX_PMIC_DIGITAL_SEC_ACCESS__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL1		(CDC_DIG_BASE+0x0D8)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL1__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL2		(CDC_DIG_BASE+0x0D9)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL2__POR		(0x01)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3		(CDC_DIG_BASE+0x0DA)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3__POR		(0x05)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL4		(CDC_DIG_BASE+0x0DB)
-#define MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL4__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_TEST1		(CDC_DIG_BASE+0x0E0)
-#define MSM89XX_PMIC_DIGITAL_INT_TEST1__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_INT_TEST_VAL		(CDC_DIG_BASE+0x0E1)
-#define MSM89XX_PMIC_DIGITAL_INT_TEST_VAL__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_TRIM_NUM		(CDC_DIG_BASE+0x0F0)
-#define MSM89XX_PMIC_DIGITAL_TRIM_NUM__POR		(0x00)
-#define MSM89XX_PMIC_DIGITAL_TRIM_CTRL		(CDC_DIG_BASE+0x0F1)
-#define MSM89XX_PMIC_DIGITAL_TRIM_CTRL__POR		(0x00)
-
-#define MSM89XX_PMIC_ANALOG_REVISION1		(CDC_ANA_BASE+0x00)
-#define MSM89XX_PMIC_ANALOG_REVISION1__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_REVISION2		(CDC_ANA_BASE+0x01)
-#define MSM89XX_PMIC_ANALOG_REVISION2__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_REVISION3		(CDC_ANA_BASE+0x02)
-#define MSM89XX_PMIC_ANALOG_REVISION3__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_REVISION4		(CDC_ANA_BASE+0x03)
-#define MSM89XX_PMIC_ANALOG_REVISION4__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_PERPH_TYPE		(CDC_ANA_BASE+0x04)
-#define MSM89XX_PMIC_ANALOG_PERPH_TYPE__POR		(0x23)
-#define MSM89XX_PMIC_ANALOG_PERPH_SUBTYPE		(CDC_ANA_BASE+0x05)
-#define MSM89XX_PMIC_ANALOG_PERPH_SUBTYPE__POR		(0x09)
-#define MSM89XX_PMIC_ANALOG_INT_RT_STS		(CDC_ANA_BASE+0x10)
-#define MSM89XX_PMIC_ANALOG_INT_RT_STS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_SET_TYPE		(CDC_ANA_BASE+0x11)
-#define MSM89XX_PMIC_ANALOG_INT_SET_TYPE__POR		(0x3F)
-#define MSM89XX_PMIC_ANALOG_INT_POLARITY_HIGH		(CDC_ANA_BASE+0x12)
-#define MSM89XX_PMIC_ANALOG_INT_POLARITY_HIGH__POR		(0x3F)
-#define MSM89XX_PMIC_ANALOG_INT_POLARITY_LOW		(CDC_ANA_BASE+0x13)
-#define MSM89XX_PMIC_ANALOG_INT_POLARITY_LOW__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_LATCHED_CLR		(CDC_ANA_BASE+0x14)
-#define MSM89XX_PMIC_ANALOG_INT_LATCHED_CLR__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_EN_SET		(CDC_ANA_BASE+0x15)
-#define MSM89XX_PMIC_ANALOG_INT_EN_SET__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_EN_CLR		(CDC_ANA_BASE+0x16)
-#define MSM89XX_PMIC_ANALOG_INT_EN_CLR__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_LATCHED_STS		(CDC_ANA_BASE+0x18)
-#define MSM89XX_PMIC_ANALOG_INT_LATCHED_STS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_PENDING_STS		(CDC_ANA_BASE+0x19)
-#define MSM89XX_PMIC_ANALOG_INT_PENDING_STS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_MID_SEL		(CDC_ANA_BASE+0x1A)
-#define MSM89XX_PMIC_ANALOG_INT_MID_SEL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_PRIORITY		(CDC_ANA_BASE+0x1B)
-#define MSM89XX_PMIC_ANALOG_INT_PRIORITY__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MICB_1_EN		(CDC_ANA_BASE+0x40)
-#define MSM89XX_PMIC_ANALOG_MICB_1_EN__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MICB_1_VAL		(CDC_ANA_BASE+0x41)
-#define MSM89XX_PMIC_ANALOG_MICB_1_VAL__POR		(0x20)
-#define MSM89XX_PMIC_ANALOG_MICB_1_CTL		(CDC_ANA_BASE+0x42)
-#define MSM89XX_PMIC_ANALOG_MICB_1_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS		(CDC_ANA_BASE+0x43)
-#define MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS__POR		(0x49)
-#define MSM89XX_PMIC_ANALOG_MICB_2_EN		(CDC_ANA_BASE+0x44)
-#define MSM89XX_PMIC_ANALOG_MICB_2_EN__POR		(0x20)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2		(CDC_ANA_BASE+0x45)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL		(CDC_ANA_BASE+0x46)
-#define MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1		(CDC_ANA_BASE+0x47)
-#define MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1__POR		(0x35)
-#define MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2		(CDC_ANA_BASE+0x50)
-#define MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2__POR		(0x08)
-#define MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL		(CDC_ANA_BASE+0x51)
-#define MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER		(CDC_ANA_BASE+0x52)
-#define MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER__POR		(0x98)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL	(CDC_ANA_BASE+0x53)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN1_ZDETM_CTL	(CDC_ANA_BASE+0x54)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN1_ZDETM_CTL__POR		(0x20)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL	(CDC_ANA_BASE+0x55)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL__POR		(0x40)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN3_CTL		(CDC_ANA_BASE+0x56)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN3_CTL__POR		(0x61)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN4_CTL		(CDC_ANA_BASE+0x57)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN4_CTL__POR		(0x80)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT		(CDC_ANA_BASE+0x58)
-#define MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT	(CDC_ANA_BASE+0x59)
-#define MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT__POR	(0x00)
-#define MSM89XX_PMIC_ANALOG_TX_1_EN		(CDC_ANA_BASE+0x60)
-#define MSM89XX_PMIC_ANALOG_TX_1_EN__POR		(0x03)
-#define MSM89XX_PMIC_ANALOG_TX_2_EN		(CDC_ANA_BASE+0x61)
-#define MSM89XX_PMIC_ANALOG_TX_2_EN__POR		(0x03)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_1		(CDC_ANA_BASE+0x62)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_1__POR		(0xBF)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_2		(CDC_ANA_BASE+0x63)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_2__POR		(0x8C)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL		(CDC_ANA_BASE+0x64)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS		(CDC_ANA_BASE+0x65)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS__POR		(0x6B)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TXFE_CLKDIV		(CDC_ANA_BASE+0x66)
-#define MSM89XX_PMIC_ANALOG_TX_1_2_TXFE_CLKDIV__POR		(0x51)
-#define MSM89XX_PMIC_ANALOG_TX_3_EN		(CDC_ANA_BASE+0x67)
-#define MSM89XX_PMIC_ANALOG_TX_3_EN__POR		(0x02)
-#define MSM89XX_PMIC_ANALOG_NCP_EN		(CDC_ANA_BASE+0x80)
-#define MSM89XX_PMIC_ANALOG_NCP_EN__POR		(0x26)
-#define MSM89XX_PMIC_ANALOG_NCP_CLK		(CDC_ANA_BASE+0x81)
-#define MSM89XX_PMIC_ANALOG_NCP_CLK__POR		(0x23)
-#define MSM89XX_PMIC_ANALOG_NCP_DEGLITCH		(CDC_ANA_BASE+0x82)
-#define MSM89XX_PMIC_ANALOG_NCP_DEGLITCH__POR		(0x5B)
-#define MSM89XX_PMIC_ANALOG_NCP_FBCTRL		(CDC_ANA_BASE+0x83)
-#define MSM89XX_PMIC_ANALOG_NCP_FBCTRL__POR		(0x08)
-#define MSM89XX_PMIC_ANALOG_NCP_BIAS		(CDC_ANA_BASE+0x84)
-#define MSM89XX_PMIC_ANALOG_NCP_BIAS__POR		(0x29)
-#define MSM89XX_PMIC_ANALOG_NCP_VCTRL		(CDC_ANA_BASE+0x85)
-#define MSM89XX_PMIC_ANALOG_NCP_VCTRL__POR		(0x24)
-#define MSM89XX_PMIC_ANALOG_NCP_TEST		(CDC_ANA_BASE+0x86)
-#define MSM89XX_PMIC_ANALOG_NCP_TEST__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_NCP_CLIM_ADDR		(CDC_ANA_BASE+0x87)
-#define MSM89XX_PMIC_ANALOG_NCP_CLIM_ADDR__POR		(0xD5)
-#define MSM89XX_PMIC_ANALOG_RX_CLOCK_DIVIDER		(CDC_ANA_BASE+0x90)
-#define MSM89XX_PMIC_ANALOG_RX_CLOCK_DIVIDER__POR		(0xE8)
-#define MSM89XX_PMIC_ANALOG_RX_COM_OCP_CTL		(CDC_ANA_BASE+0x91)
-#define MSM89XX_PMIC_ANALOG_RX_COM_OCP_CTL__POR		(0xCF)
-#define MSM89XX_PMIC_ANALOG_RX_COM_OCP_COUNT		(CDC_ANA_BASE+0x92)
-#define MSM89XX_PMIC_ANALOG_RX_COM_OCP_COUNT__POR		(0x6E)
-#define MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC		(CDC_ANA_BASE+0x93)
-#define MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC__POR		(0x18)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_PA		(CDC_ANA_BASE+0x94)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_PA__POR		(0x5A)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_LDO_OCP	(CDC_ANA_BASE+0x95)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_LDO_OCP__POR		(0x69)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_CNP		(CDC_ANA_BASE+0x96)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_CNP__POR		(0x29)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN		(CDC_ANA_BASE+0x97)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN__POR		(0x80)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_CTL		(CDC_ANA_BASE+0x98)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_CTL__POR		(0xDA)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME		(CDC_ANA_BASE+0x99)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME__POR		(0x16)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST		(CDC_ANA_BASE+0x9A)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL	(CDC_ANA_BASE+0x9B)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL__POR		(0x20)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST		(CDC_ANA_BASE+0x9C)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL	(CDC_ANA_BASE+0x9D)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL__POR		(0x20)
-#define MSM89XX_PMIC_ANALOG_RX_EAR_CTL		(CDC_ANA_BASE+0x9E)
-#define MSM89XX_PMIC_ANALOG_RX_EAR_CTL___POR		(0x12)
-#define MSM89XX_PMIC_ANALOG_RX_ATEST		(CDC_ANA_BASE+0x9F)
-#define MSM89XX_PMIC_ANALOG_RX_ATEST__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_STATUS		(CDC_ANA_BASE+0xA0)
-#define MSM89XX_PMIC_ANALOG_RX_HPH_STATUS__POR		(0x0C)
-#define MSM89XX_PMIC_ANALOG_RX_EAR_STATUS		(CDC_ANA_BASE+0xA1)
-#define MSM89XX_PMIC_ANALOG_RX_EAR_STATUS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL		(CDC_ANA_BASE+0xAC)
-#define MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL		(CDC_ANA_BASE+0xAD)
-#define MSM89XX_PMIC_ANALOG_RX_RX_LO_EN_CTL__POR	(0x00)
-#define MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL		(CDC_ANA_BASE+0xB0)
-#define MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL__POR		(0x83)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_CLIP_DET		(CDC_ANA_BASE+0xB1)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_CLIP_DET__POR		(0x91)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL		(CDC_ANA_BASE+0xB2)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL__POR		(0x29)
-#define MSM89XX_PMIC_ANALOG_SPKR_ANA_BIAS_SET		(CDC_ANA_BASE+0xB3)
-#define MSM89XX_PMIC_ANALOG_SPKR_ANA_BIAS_SET__POR		(0x4D)
-#define MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL		(CDC_ANA_BASE+0xB4)
-#define MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL__POR		(0xE1)
-#define MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL		(CDC_ANA_BASE+0xB5)
-#define MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL__POR		(0x1E)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_MISC		(CDC_ANA_BASE+0xB6)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_MISC__POR		(0xCB)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG		(CDC_ANA_BASE+0xB7)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_CURRENT_LIMIT		(CDC_ANA_BASE+0xC0)
-#define MSM89XX_PMIC_ANALOG_CURRENT_LIMIT__POR		(0x02)
-#define MSM89XX_PMIC_ANALOG_OUTPUT_VOLTAGE		(CDC_ANA_BASE+0xC1)
-#define MSM89XX_PMIC_ANALOG_OUTPUT_VOLTAGE__POR		(0x14)
-#define MSM89XX_PMIC_ANALOG_BYPASS_MODE		(CDC_ANA_BASE+0xC2)
-#define MSM89XX_PMIC_ANALOG_BYPASS_MODE__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_BOOST_EN_CTL		(CDC_ANA_BASE+0xC3)
-#define MSM89XX_PMIC_ANALOG_BOOST_EN_CTL__POR		(0x1F)
-#define MSM89XX_PMIC_ANALOG_SLOPE_COMP_IP_ZERO		(CDC_ANA_BASE+0xC4)
-#define MSM89XX_PMIC_ANALOG_SLOPE_COMP_IP_ZERO__POR		(0x8C)
-#define MSM89XX_PMIC_ANALOG_RDSON_MAX_DUTY_CYCLE	(CDC_ANA_BASE+0xC5)
-#define MSM89XX_PMIC_ANALOG_RDSON_MAX_DUTY_CYCLE__POR		(0xC0)
-#define MSM89XX_PMIC_ANALOG_BOOST_TEST1_1		(CDC_ANA_BASE+0xC6)
-#define MSM89XX_PMIC_ANALOG_BOOST_TEST1_1__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_BOOST_TEST_2		(CDC_ANA_BASE+0xC7)
-#define MSM89XX_PMIC_ANALOG_BOOST_TEST_2__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_SPKR_SAR_STATUS		(CDC_ANA_BASE+0xC8)
-#define MSM89XX_PMIC_ANALOG_SPKR_SAR_STATUS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_STATUS		(CDC_ANA_BASE+0xC9)
-#define MSM89XX_PMIC_ANALOG_SPKR_DRV_STATUS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_PBUS_ADD_CSR		(CDC_ANA_BASE+0xCE)
-#define MSM89XX_PMIC_ANALOG_PBUS_ADD_CSR__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_PBUS_ADD_SEL		(CDC_ANA_BASE+0xCF)
-#define MSM89XX_PMIC_ANALOG_PBUS_ADD_SEL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_SEC_ACCESS		(CDC_ANA_BASE+0xD0)
-#define MSM89XX_PMIC_ANALOG_SEC_ACCESS__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL1		(CDC_ANA_BASE+0xD8)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL1__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL2		(CDC_ANA_BASE+0xD9)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL2__POR		(0x01)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3		(CDC_ANA_BASE+0xDA)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3__POR		(0x05)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL4		(CDC_ANA_BASE+0xDB)
-#define MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL4__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_TEST1		(CDC_ANA_BASE+0xE0)
-#define MSM89XX_PMIC_ANALOG_INT_TEST1__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_INT_TEST_VAL		(CDC_ANA_BASE+0xE1)
-#define MSM89XX_PMIC_ANALOG_INT_TEST_VAL__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_TRIM_NUM		(CDC_ANA_BASE+0xF0)
-#define MSM89XX_PMIC_ANALOG_TRIM_NUM__POR		(0x04)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL1		(CDC_ANA_BASE+0xF1)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL1__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL2		(CDC_ANA_BASE+0xF2)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL2__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL3		(CDC_ANA_BASE+0xF3)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL3__POR		(0x00)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL4		(CDC_ANA_BASE+0xF4)
-#define MSM89XX_PMIC_ANALOG_TRIM_CTRL4__POR		(0x00)
-
-#define MSM89XX_PMIC_CDC_NUM_REGISTERS \
-		(MSM89XX_PMIC_ANALOG_TRIM_CTRL4+1)
-#define MSM89XX_PMIC_CDC_MAX_REGISTER \
-		(MSM89XX_PMIC_CDC_NUM_REGISTERS-1)
-#define MSM89XX_PMIC_CDC_CACHE_SIZE \
-		MSM89XX_PMIC_CDC_NUM_REGISTERS
-
-
-#define MSM89XX_CDC_CORE_CLK_RX_RESET_CTL	(0x00)
-#define MSM89XX_CDC_CORE_CLK_RX_RESET_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL	(0x04)
-#define MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL	(0x08)
-#define MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_RX_I2S_CTL		(0x0C)
-#define MSM89XX_CDC_CORE_CLK_RX_I2S_CTL__POR		(0x13)
-#define MSM89XX_CDC_CORE_CLK_TX_I2S_CTL		(0x10)
-#define MSM89XX_CDC_CORE_CLK_TX_I2S_CTL__POR		(0x13)
-#define MSM89XX_CDC_CORE_CLK_OTHR_RESET_B1_CTL	(0x14)
-#define MSM89XX_CDC_CORE_CLK_OTHR_RESET_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL	(0x18)
-#define MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_CLK_OTHR_CTL		(0x1C)
-#define MSM89XX_CDC_CORE_CLK_OTHR_CTL__POR		(0x04)
-#define MSM89XX_CDC_CORE_CLK_RX_B1_CTL		(0x20)
-#define MSM89XX_CDC_CORE_CLK_RX_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_MCLK_CTL		(0x24)
-#define MSM89XX_CDC_CORE_CLK_MCLK_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_PDM_CTL		(0x28)
-#define MSM89XX_CDC_CORE_CLK_PDM_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_SD_CTL		(0x2C)
-#define MSM89XX_CDC_CORE_CLK_SD_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL	(0x30)
-#define MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_RX_B2_CTL		(0x34)
-#define MSM89XX_CDC_CORE_CLK_RX_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CLK_TX2_I2S_CTL	(0x38)
-#define MSM89XX_CDC_CORE_CLK_TX2_I2S_CTL__POR		(0x13)
-#define MSM89XX_CDC_CORE_RX1_B1_CTL		(0x40)
-#define MSM89XX_CDC_CORE_RX1_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX2_B1_CTL		(0x60)
-#define MSM89XX_CDC_CORE_RX2_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX3_B1_CTL		(0x80)
-#define MSM89XX_CDC_CORE_RX3_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX1_B2_CTL		(0x44)
-#define MSM89XX_CDC_CORE_RX1_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX2_B2_CTL		(0x64)
-#define MSM89XX_CDC_CORE_RX2_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX3_B2_CTL		(0x84)
-#define MSM89XX_CDC_CORE_RX3_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX1_B3_CTL		(0x48)
-#define MSM89XX_CDC_CORE_RX1_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX2_B3_CTL		(0x68)
-#define MSM89XX_CDC_CORE_RX2_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX3_B3_CTL		(0x88)
-#define MSM89XX_CDC_CORE_RX3_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX1_B4_CTL		(0x4C)
-#define MSM89XX_CDC_CORE_RX1_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX2_B4_CTL		(0x6C)
-#define MSM89XX_CDC_CORE_RX2_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX3_B4_CTL		(0x8C)
-#define MSM89XX_CDC_CORE_RX3_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX1_B5_CTL		(0x50)
-#define MSM89XX_CDC_CORE_RX1_B5_CTL__POR		(0x68)
-#define MSM89XX_CDC_CORE_RX2_B5_CTL		(0x70)
-#define MSM89XX_CDC_CORE_RX2_B5_CTL__POR		(0x68)
-#define MSM89XX_CDC_CORE_RX3_B5_CTL		(0x90)
-#define MSM89XX_CDC_CORE_RX3_B5_CTL__POR		(0x68)
-#define MSM89XX_CDC_CORE_RX1_B6_CTL		(0x54)
-#define MSM89XX_CDC_CORE_RX1_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX2_B6_CTL		(0x74)
-#define MSM89XX_CDC_CORE_RX2_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX3_B6_CTL		(0x94)
-#define MSM89XX_CDC_CORE_RX3_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_RX1_VOL_CTL_B1_CTL	(0x58)
-#define MSM89XX_CDC_CORE_RX1_VOL_CTL_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_RX2_VOL_CTL_B1_CTL	(0x78)
-#define MSM89XX_CDC_CORE_RX2_VOL_CTL_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_RX3_VOL_CTL_B1_CTL	(0x98)
-#define MSM89XX_CDC_CORE_RX3_VOL_CTL_B1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL	(0x5C)
-#define MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL	(0x7C)
-#define MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL	(0x9C)
-#define MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_TOP_GAIN_UPDATE	(0xA0)
-#define MSM89XX_CDC_CORE_TOP_GAIN_UPDATE__POR		(0x00)
-#define MSM89XX_CDC_CORE_TOP_CTL		(0xA4)
-#define MSM89XX_CDC_CORE_TOP_CTL__POR			(0x01)
-#define MSM89XX_CDC_CORE_COMP0_B1_CTL		(0xB0)
-#define MSM89XX_CDC_CORE_COMP0_B1_CTL__POR		(0x30)
-#define MSM89XX_CDC_CORE_COMP0_B2_CTL		(0xB4)
-#define MSM89XX_CDC_CORE_COMP0_B2_CTL__POR		(0xB5)
-#define MSM89XX_CDC_CORE_COMP0_B3_CTL		(0xB8)
-#define MSM89XX_CDC_CORE_COMP0_B3_CTL__POR		(0x28)
-#define MSM89XX_CDC_CORE_COMP0_B4_CTL		(0xBC)
-#define MSM89XX_CDC_CORE_COMP0_B4_CTL__POR		(0x37)
-#define MSM89XX_CDC_CORE_COMP0_B5_CTL		(0xC0)
-#define MSM89XX_CDC_CORE_COMP0_B5_CTL__POR		(0x7F)
-#define MSM89XX_CDC_CORE_COMP0_B6_CTL		(0xC4)
-#define MSM89XX_CDC_CORE_COMP0_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_COMP0_SHUT_DOWN_STATUS	(0xC8)
-#define MSM89XX_CDC_CORE_COMP0_SHUT_DOWN_STATUS__POR	(0x03)
-#define MSM89XX_CDC_CORE_COMP0_FS_CFG		(0xCC)
-#define MSM89XX_CDC_CORE_COMP0_FS_CFG__POR		(0x03)
-#define MSM89XX_CDC_CORE_COMP0_DELAY_BUF_CTL	(0xD0)
-#define MSM89XX_CDC_CORE_COMP0_DELAY_BUF_CTL__POR	(0x02)
-#define MSM89XX_CDC_CORE_DEBUG_DESER1_CTL	(0xE0)
-#define MSM89XX_CDC_CORE_DEBUG_DESER1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_DEBUG_DESER2_CTL	(0xE4)
-#define MSM89XX_CDC_CORE_DEBUG_DESER2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_DEBUG_B1_CTL_CFG	(0xE8)
-#define MSM89XX_CDC_CORE_DEBUG_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_DEBUG_B2_CTL_CFG	(0xEC)
-#define MSM89XX_CDC_CORE_DEBUG_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_DEBUG_B3_CTL_CFG	(0xF0)
-#define MSM89XX_CDC_CORE_DEBUG_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL	(0x100)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL	(0x140)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL	(0x104)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B2_CTL	(0x144)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL	(0x108)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B3_CTL	(0x148)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL	(0x10C)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B4_CTL	(0x14C)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B5_CTL	(0x110)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B5_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B5_CTL	(0x150)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B5_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B6_CTL	(0x114)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B6_CTL	(0x154)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B6_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B7_CTL	(0x118)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B7_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B7_CTL	(0x158)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B7_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B8_CTL	(0x11C)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_B8_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B8_CTL	(0x15C)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_B8_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_CTL		(0x120)
-#define MSM89XX_CDC_CORE_IIR1_CTL__POR			(0x40)
-#define MSM89XX_CDC_CORE_IIR2_CTL		(0x160)
-#define MSM89XX_CDC_CORE_IIR2_CTL__POR			(0x40)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_TIMER_CTL	(0x124)
-#define MSM89XX_CDC_CORE_IIR1_GAIN_TIMER_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_TIMER_CTL	(0x164)
-#define MSM89XX_CDC_CORE_IIR2_GAIN_TIMER_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL	(0x128)
-#define MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL	(0x168)
-#define MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL	(0x12C)
-#define MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_IIR2_COEF_B2_CTL	(0x16C)
-#define MSM89XX_CDC_CORE_IIR2_COEF_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX1_B1_CTL	(0x180)
-#define MSM89XX_CDC_CORE_CONN_RX1_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX1_B2_CTL	(0x184)
-#define MSM89XX_CDC_CORE_CONN_RX1_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX1_B3_CTL	(0x188)
-#define MSM89XX_CDC_CORE_CONN_RX1_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX2_B1_CTL	(0x18C)
-#define MSM89XX_CDC_CORE_CONN_RX2_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX2_B2_CTL	(0x190)
-#define MSM89XX_CDC_CORE_CONN_RX2_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX2_B3_CTL	(0x194)
-#define MSM89XX_CDC_CORE_CONN_RX2_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX3_B1_CTL	(0x198)
-#define MSM89XX_CDC_CORE_CONN_RX3_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_RX3_B2_CTL	(0x19C)
-#define MSM89XX_CDC_CORE_CONN_RX3_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_TX_B1_CTL		(0x1A0)
-#define MSM89XX_CDC_CORE_CONN_TX_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_TX_B2_CTL		(0x1A4)
-#define MSM89XX_CDC_CORE_CONN_TX_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL	(0x1A8)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B2_CTL	(0x1AC)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B3_CTL	(0x1B0)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B4_CTL	(0x1B4)
-#define MSM89XX_CDC_CORE_CONN_EQ1_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL	(0x1B8)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B2_CTL	(0x1BC)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B2_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B3_CTL	(0x1C0)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B4_CTL	(0x1C4)
-#define MSM89XX_CDC_CORE_CONN_EQ2_B4_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL	(0x1C8)
-#define MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL__POR	(0x00)
-#define MSM89XX_CDC_CORE_CONN_TX_B3_CTL		(0x1CC)
-#define MSM89XX_CDC_CORE_CONN_TX_B3_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_TIMER	(0x1E0)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_TIMER__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN	(0x1E4)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG	(0x1E8)
-#define MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX5_MUX_CTL		(0x1EC)
-#define MSM89XX_CDC_CORE_TX5_MUX_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX5_CLK_FS_CTL		(0x1F0)
-#define MSM89XX_CDC_CORE_TX5_CLK_FS_CTL__POR		(0x03)
-#define MSM89XX_CDC_CORE_TX5_DMIC_CTL		(0x1F4)
-#define MSM89XX_CDC_CORE_TX5_DMIC_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_TIMER	(0x280)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_TIMER__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_TIMER	(0x2A0)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_TIMER__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_TIMER	(0x2C0)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_TIMER__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_TIMER	(0x2E0)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_TIMER__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN	(0x284)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN	(0x2A4)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN	(0x2C4)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN	(0x2E4)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG	(0x288)
-#define MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG	(0x2A8)
-#define MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG	(0x2C8)
-#define MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG	(0x2E8)
-#define MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX1_MUX_CTL		(0x28C)
-#define MSM89XX_CDC_CORE_TX1_MUX_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX2_MUX_CTL		(0x2AC)
-#define MSM89XX_CDC_CORE_TX2_MUX_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX3_MUX_CTL		(0x2CC)
-#define MSM89XX_CDC_CORE_TX3_MUX_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX4_MUX_CTL		(0x2EC)
-#define MSM89XX_CDC_CORE_TX4_MUX_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX1_CLK_FS_CTL		(0x290)
-#define MSM89XX_CDC_CORE_TX1_CLK_FS_CTL__POR		(0x03)
-#define MSM89XX_CDC_CORE_TX2_CLK_FS_CTL		(0x2B0)
-#define MSM89XX_CDC_CORE_TX2_CLK_FS_CTL__POR		(0x03)
-#define MSM89XX_CDC_CORE_TX3_CLK_FS_CTL		(0x2D0)
-#define MSM89XX_CDC_CORE_TX3_CLK_FS_CTL__POR		(0x03)
-#define MSM89XX_CDC_CORE_TX4_CLK_FS_CTL		(0x2F0)
-#define MSM89XX_CDC_CORE_TX4_CLK_FS_CTL__POR		(0x03)
-#define MSM89XX_CDC_CORE_TX1_DMIC_CTL		(0x294)
-#define MSM89XX_CDC_CORE_TX1_DMIC_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX2_DMIC_CTL		(0x2B4)
-#define MSM89XX_CDC_CORE_TX2_DMIC_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX3_DMIC_CTL		(0x2D4)
-#define MSM89XX_CDC_CORE_TX3_DMIC_CTL__POR		(0x00)
-#define MSM89XX_CDC_CORE_TX4_DMIC_CTL		(0x2F4)
-#define MSM89XX_CDC_CORE_TX4_DMIC_CTL__POR		(0x00)
-
-#define MSM89XX_CDC_CORE_NUM_REGISTERS \
-		(MSM89XX_CDC_CORE_TX4_DMIC_CTL+1)
-#define MSM89XX_CDC_CORE_MAX_REGISTER \
-		(MSM89XX_CDC_CORE_NUM_REGISTERS-1)
-#define MSM89XX_CDC_CORE_CACHE_SIZE \
-		MSM89XX_CDC_CORE_NUM_REGISTERS
-#endif
diff --git a/sound/soc/codecs/sdm660_cdc/sdm660-regmap.c b/sound/soc/codecs/sdm660_cdc/sdm660-regmap.c
deleted file mode 100644
index 7d8ac6d..0000000
--- a/sound/soc/codecs/sdm660_cdc/sdm660-regmap.c
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/regmap.h>
-#include "msm-cdc-common.h"
-#include "sdm660-cdc-registers.h"
-
-/*
- * Default register reset values that are common across different versions
- * are defined here. If a register reset value is changed based on version
- * then remove it from this structure and add it in version specific
- * structures.
- */
-struct reg_default
-	msm89xx_cdc_core_defaults[MSM89XX_CDC_CORE_CACHE_SIZE] = {
-	{MSM89XX_CDC_CORE_CLK_RX_RESET_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_RX_I2S_CTL, 0x13},
-	{MSM89XX_CDC_CORE_CLK_TX_I2S_CTL, 0x13},
-	{MSM89XX_CDC_CORE_CLK_OTHR_RESET_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_OTHR_CTL, 0x04},
-	{MSM89XX_CDC_CORE_CLK_RX_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_MCLK_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_PDM_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_SD_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_RX_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CLK_TX2_I2S_CTL, 0x13},
-	{MSM89XX_CDC_CORE_RX1_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_B5_CTL, 0x68},
-	{MSM89XX_CDC_CORE_RX2_B5_CTL, 0x68},
-	{MSM89XX_CDC_CORE_RX3_B5_CTL, 0x68},
-	{MSM89XX_CDC_CORE_RX1_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_VOL_CTL_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_VOL_CTL_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_VOL_CTL_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TOP_GAIN_UPDATE, 0x00},
-	{MSM89XX_CDC_CORE_TOP_CTL, 0x01},
-	{MSM89XX_CDC_CORE_COMP0_B1_CTL, 0x30},
-	{MSM89XX_CDC_CORE_COMP0_B2_CTL, 0xB5},
-	{MSM89XX_CDC_CORE_COMP0_B3_CTL, 0x28},
-	{MSM89XX_CDC_CORE_COMP0_B4_CTL, 0x37},
-	{MSM89XX_CDC_CORE_COMP0_B5_CTL, 0x7F},
-	{MSM89XX_CDC_CORE_COMP0_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_COMP0_SHUT_DOWN_STATUS, 0x03},
-	{MSM89XX_CDC_CORE_COMP0_FS_CFG, 0x03},
-	{MSM89XX_CDC_CORE_COMP0_DELAY_BUF_CTL, 0x02},
-	{MSM89XX_CDC_CORE_DEBUG_DESER1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_DEBUG_DESER2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_DEBUG_B1_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_DEBUG_B2_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_DEBUG_B3_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B5_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B5_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B6_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B7_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B7_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_B8_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_B8_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_CTL, 0x40},
-	{MSM89XX_CDC_CORE_IIR2_CTL, 0x40},
-	{MSM89XX_CDC_CORE_IIR1_GAIN_TIMER_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_GAIN_TIMER_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_IIR2_COEF_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX1_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX1_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX1_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX2_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX2_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX2_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX3_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_RX3_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_TX_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_TX_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ1_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ1_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ1_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ2_B2_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ2_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_EQ2_B4_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL, 0x00},
-	{MSM89XX_CDC_CORE_CONN_TX_B3_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX5_VOL_CTL_TIMER, 0x00},
-	{MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN, 0x00},
-	{MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_TX5_MUX_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX5_CLK_FS_CTL, 0x03},
-	{MSM89XX_CDC_CORE_TX5_DMIC_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX1_VOL_CTL_TIMER, 0x00},
-	{MSM89XX_CDC_CORE_TX2_VOL_CTL_TIMER, 0x00},
-	{MSM89XX_CDC_CORE_TX3_VOL_CTL_TIMER, 0x00},
-	{MSM89XX_CDC_CORE_TX4_VOL_CTL_TIMER, 0x00},
-	{MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN, 0x00},
-	{MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN, 0x00},
-	{MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN, 0x00},
-	{MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN, 0x00},
-	{MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG, 0x00},
-	{MSM89XX_CDC_CORE_TX1_MUX_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX2_MUX_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX3_MUX_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX4_MUX_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX1_CLK_FS_CTL, 0x03},
-	{MSM89XX_CDC_CORE_TX2_CLK_FS_CTL, 0x03},
-	{MSM89XX_CDC_CORE_TX3_CLK_FS_CTL, 0x03},
-	{MSM89XX_CDC_CORE_TX4_CLK_FS_CTL, 0x03},
-	{MSM89XX_CDC_CORE_TX1_DMIC_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX2_DMIC_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX3_DMIC_CTL, 0x00},
-	{MSM89XX_CDC_CORE_TX4_DMIC_CTL, 0x00},
-};
-
-struct reg_default
-	msm89xx_pmic_cdc_defaults[MSM89XX_PMIC_CDC_CACHE_SIZE] = {
-	{MSM89XX_PMIC_DIGITAL_REVISION1, 0x00},
-	{MSM89XX_PMIC_DIGITAL_REVISION2, 0x00},
-	{MSM89XX_PMIC_DIGITAL_PERPH_TYPE, 0x23},
-	{MSM89XX_PMIC_DIGITAL_PERPH_SUBTYPE, 0x01},
-	{MSM89XX_PMIC_DIGITAL_INT_RT_STS, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_SET_TYPE, 0xFF},
-	{MSM89XX_PMIC_DIGITAL_INT_POLARITY_HIGH, 0xFF},
-	{MSM89XX_PMIC_DIGITAL_INT_POLARITY_LOW, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_LATCHED_CLR, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_EN_SET, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_EN_CLR, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_LATCHED_STS, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_PENDING_STS, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_MID_SEL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_PRIORITY, 0x00},
-	{MSM89XX_PMIC_DIGITAL_GPIO_MODE, 0x00},
-	{MSM89XX_PMIC_DIGITAL_PIN_CTL_OE, 0x01},
-	{MSM89XX_PMIC_DIGITAL_PIN_CTL_DATA, 0x00},
-	{MSM89XX_PMIC_DIGITAL_PIN_STATUS, 0x00},
-	{MSM89XX_PMIC_DIGITAL_HDRIVE_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_RST_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_TOP_CLK_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_ANA_CLK_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_DIG_CLK_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_TX1_CTL, 0x02},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_TX2_CTL, 0x02},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_HPHR_DAC_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_RX1_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_RX2_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_RX3_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_CONN_RX_LB_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_CDC_RX_CTL1, 0x7C},
-	{MSM89XX_PMIC_DIGITAL_CDC_RX_CTL2, 0x7C},
-	{MSM89XX_PMIC_DIGITAL_CDC_RX_CTL3, 0x7C},
-	{MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA0, 0x00},
-	{MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA1, 0x00},
-	{MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA2, 0x00},
-	{MSM89XX_PMIC_DIGITAL_DEM_BYPASS_DATA3, 0x00},
-	{MSM89XX_PMIC_DIGITAL_DIG_DEBUG_CTL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_DIG_DEBUG_EN, 0x00},
-	{MSM89XX_PMIC_DIGITAL_SPARE_0, 0x00},
-	{MSM89XX_PMIC_DIGITAL_SPARE_1, 0x00},
-	{MSM89XX_PMIC_DIGITAL_SPARE_2, 0x00},
-	{MSM89XX_PMIC_DIGITAL_SEC_ACCESS, 0x00},
-	{MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL1, 0x00},
-	{MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL2, 0x02},
-	{MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL3, 0x05},
-	{MSM89XX_PMIC_DIGITAL_PERPH_RESET_CTL4, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_TEST1, 0x00},
-	{MSM89XX_PMIC_DIGITAL_INT_TEST_VAL, 0x00},
-	{MSM89XX_PMIC_DIGITAL_TRIM_NUM, 0x00},
-	{MSM89XX_PMIC_DIGITAL_TRIM_CTRL, 0x00},
-	{MSM89XX_PMIC_ANALOG_REVISION1, 0x00},
-	{MSM89XX_PMIC_ANALOG_REVISION2, 0x00},
-	{MSM89XX_PMIC_ANALOG_REVISION3, 0x00},
-	{MSM89XX_PMIC_ANALOG_REVISION4, 0x00},
-	{MSM89XX_PMIC_ANALOG_PERPH_TYPE, 0x23},
-	{MSM89XX_PMIC_ANALOG_PERPH_SUBTYPE, 0x09},
-	{MSM89XX_PMIC_ANALOG_INT_RT_STS, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_SET_TYPE, 0x3F},
-	{MSM89XX_PMIC_ANALOG_INT_POLARITY_HIGH, 0x3F},
-	{MSM89XX_PMIC_ANALOG_INT_POLARITY_LOW, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_LATCHED_CLR, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_EN_SET, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_EN_CLR, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_LATCHED_STS, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_PENDING_STS, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_MID_SEL, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_PRIORITY, 0x00},
-	{MSM89XX_PMIC_ANALOG_MICB_1_EN, 0x00},
-	{MSM89XX_PMIC_ANALOG_MICB_1_VAL, 0x20},
-	{MSM89XX_PMIC_ANALOG_MICB_1_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_MICB_1_INT_RBIAS, 0x49},
-	{MSM89XX_PMIC_ANALOG_MICB_2_EN, 0x20},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL_2, 0x00},
-	{MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_1, 0x35},
-	{MSM89XX_PMIC_ANALOG_MBHC_DET_CTL_2, 0x08},
-	{MSM89XX_PMIC_ANALOG_MBHC_FSM_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_MBHC_DBNC_TIMER, 0x98},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN0_ZDETL_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN1_ZDETM_CTL, 0x20},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN2_ZDETH_CTL, 0x40},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN3_CTL, 0x61},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN4_CTL, 0x80},
-	{MSM89XX_PMIC_ANALOG_MBHC_BTN_RESULT, 0x00},
-	{MSM89XX_PMIC_ANALOG_MBHC_ZDET_ELECT_RESULT, 0x00},
-	{MSM89XX_PMIC_ANALOG_TX_1_EN, 0x03},
-	{MSM89XX_PMIC_ANALOG_TX_2_EN, 0x03},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_1, 0xBF},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_TEST_CTL_2, 0x8C},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_ATEST_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_OPAMP_BIAS, 0x6B},
-	{MSM89XX_PMIC_ANALOG_TX_1_2_TXFE_CLKDIV, 0x51},
-	{MSM89XX_PMIC_ANALOG_TX_3_EN, 0x02},
-	{MSM89XX_PMIC_ANALOG_NCP_EN, 0x26},
-	{MSM89XX_PMIC_ANALOG_NCP_CLK, 0x23},
-	{MSM89XX_PMIC_ANALOG_NCP_DEGLITCH, 0x5B},
-	{MSM89XX_PMIC_ANALOG_NCP_FBCTRL, 0x08},
-	{MSM89XX_PMIC_ANALOG_NCP_BIAS, 0x29},
-	{MSM89XX_PMIC_ANALOG_NCP_VCTRL, 0x24},
-	{MSM89XX_PMIC_ANALOG_NCP_TEST, 0x00},
-	{MSM89XX_PMIC_ANALOG_NCP_CLIM_ADDR, 0xD5},
-	{MSM89XX_PMIC_ANALOG_RX_CLOCK_DIVIDER, 0xE8},
-	{MSM89XX_PMIC_ANALOG_RX_COM_OCP_CTL, 0xCF},
-	{MSM89XX_PMIC_ANALOG_RX_COM_OCP_COUNT, 0x6E},
-	{MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC, 0x18},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_PA, 0x5A},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_LDO_OCP, 0x69},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_BIAS_CNP, 0x29},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_CNP_EN, 0x80},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_CTL, 0xDA},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_CNP_WG_TIME, 0x16},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_L_TEST, 0x00},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_L_PA_DAC_CTL, 0x20},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_R_TEST, 0x00},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_R_PA_DAC_CTL, 0x20},
-	{MSM89XX_PMIC_ANALOG_RX_EAR_CTL, 0x12},
-	{MSM89XX_PMIC_ANALOG_RX_ATEST, 0x00},
-	{MSM89XX_PMIC_ANALOG_RX_HPH_STATUS, 0x0C},
-	{MSM89XX_PMIC_ANALOG_RX_EAR_STATUS, 0x00},
-	{MSM89XX_PMIC_ANALOG_RX_LO_DAC_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_RX_LO_EN_CTL, 0x00},
-	{MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x83},
-	{MSM89XX_PMIC_ANALOG_SPKR_DRV_CLIP_DET, 0x91},
-	{MSM89XX_PMIC_ANALOG_SPKR_DRV_CTL, 0x29},
-	{MSM89XX_PMIC_ANALOG_SPKR_ANA_BIAS_SET, 0x4D},
-	{MSM89XX_PMIC_ANALOG_SPKR_OCP_CTL, 0xE1},
-	{MSM89XX_PMIC_ANALOG_SPKR_PWRSTG_CTL, 0x1E},
-	{MSM89XX_PMIC_ANALOG_SPKR_DRV_MISC, 0xCB},
-	{MSM89XX_PMIC_ANALOG_SPKR_DRV_DBG, 0x00},
-	{MSM89XX_PMIC_ANALOG_CURRENT_LIMIT, 0x02},
-	{MSM89XX_PMIC_ANALOG_OUTPUT_VOLTAGE, 0x14},
-	{MSM89XX_PMIC_ANALOG_BYPASS_MODE, 0x00},
-	{MSM89XX_PMIC_ANALOG_BOOST_EN_CTL, 0x1F},
-	{MSM89XX_PMIC_ANALOG_SLOPE_COMP_IP_ZERO, 0x8C},
-	{MSM89XX_PMIC_ANALOG_RDSON_MAX_DUTY_CYCLE, 0xC0},
-	{MSM89XX_PMIC_ANALOG_BOOST_TEST1_1, 0x00},
-	{MSM89XX_PMIC_ANALOG_BOOST_TEST_2, 0x00},
-	{MSM89XX_PMIC_ANALOG_SPKR_SAR_STATUS, 0x00},
-	{MSM89XX_PMIC_ANALOG_SPKR_DRV_STATUS, 0x00},
-	{MSM89XX_PMIC_ANALOG_PBUS_ADD_CSR, 0x00},
-	{MSM89XX_PMIC_ANALOG_PBUS_ADD_SEL, 0x00},
-	{MSM89XX_PMIC_ANALOG_SEC_ACCESS, 0x00},
-	{MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL1, 0x00},
-	{MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL2, 0x01},
-	{MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL3, 0x05},
-	{MSM89XX_PMIC_ANALOG_PERPH_RESET_CTL4, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_TEST1, 0x00},
-	{MSM89XX_PMIC_ANALOG_INT_TEST_VAL, 0x00},
-	{MSM89XX_PMIC_ANALOG_TRIM_NUM, 0x04},
-	{MSM89XX_PMIC_ANALOG_TRIM_CTRL1, 0x00},
-	{MSM89XX_PMIC_ANALOG_TRIM_CTRL2, 0x00},
-	{MSM89XX_PMIC_ANALOG_TRIM_CTRL3, 0x00},
-	{MSM89XX_PMIC_ANALOG_TRIM_CTRL4, 0x00},
-};
-
-static const u8 msm89xx_cdc_core_reg_readable[MSM89XX_CDC_CORE_CACHE_SIZE] = {
-		[MSM89XX_CDC_CORE_CLK_RX_RESET_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_OTHR_RESET_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_OTHR_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_MCLK_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_PDM_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_SD_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX2_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_TOP_GAIN_UPDATE] = 1,
-		[MSM89XX_CDC_CORE_TOP_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_SHUT_DOWN_STATUS] = 1,
-		[MSM89XX_CDC_CORE_COMP0_FS_CFG] = 1,
-		[MSM89XX_CDC_CORE_COMP0_DELAY_BUF_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_DESER1_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_DESER2_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B1_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B2_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B3_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B7_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B7_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B8_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B8_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_TIMER_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_TIMER_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_COEF_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX3_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX3_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX1_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX5_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_DMIC_CTL] = 1,
-};
-
-static const u8 msm89xx_cdc_core_reg_writeable[MSM89XX_CDC_CORE_CACHE_SIZE] = {
-		[MSM89XX_CDC_CORE_CLK_RX_RESET_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_RESET_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_DMIC_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_OTHR_RESET_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX_CLK_EN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_OTHR_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_MCLK_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_PDM_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_SD_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_DMIC_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_RX_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CLK_TX2_I2S_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_VOL_CTL_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_RX3_VOL_CTL_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_TOP_GAIN_UPDATE] = 1,
-		[MSM89XX_CDC_CORE_TOP_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_COMP0_FS_CFG] = 1,
-		[MSM89XX_CDC_CORE_COMP0_DELAY_BUF_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_DESER1_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_DESER2_CTL] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B1_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B2_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_DEBUG_B3_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B5_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B6_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B7_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B7_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_B8_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_B8_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_GAIN_TIMER_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_GAIN_TIMER_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR1_COEF_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_IIR2_COEF_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX3_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_RX3_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ1_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B2_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_EQ2_B4_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_I2S_SD1_CTL] = 1,
-		[MSM89XX_CDC_CORE_CONN_TX_B3_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX1_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_TIMER] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_GAIN] = 1,
-		[MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG] = 1,
-		[MSM89XX_CDC_CORE_TX5_MUX_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_CLK_FS_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX5_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX1_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX2_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX3_DMIC_CTL] = 1,
-		[MSM89XX_CDC_CORE_TX4_DMIC_CTL] = 1,
-};
-
-bool msm89xx_cdc_core_readable_reg(struct device *dev, unsigned int reg)
-{
-	return msm89xx_cdc_core_reg_readable[reg];
-}
-
-bool msm89xx_cdc_core_writeable_reg(struct device *dev, unsigned int reg)
-{
-	return msm89xx_cdc_core_reg_writeable[reg];
-}
-
-bool msm89xx_cdc_core_volatile_reg(struct device *dev, unsigned int reg)
-{
-	switch (reg) {
-	case MSM89XX_CDC_CORE_RX1_B1_CTL:
-	case MSM89XX_CDC_CORE_RX2_B1_CTL:
-	case MSM89XX_CDC_CORE_RX3_B1_CTL:
-	case MSM89XX_CDC_CORE_RX1_B6_CTL:
-	case MSM89XX_CDC_CORE_RX2_B6_CTL:
-	case MSM89XX_CDC_CORE_RX3_B6_CTL:
-	case MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG:
-	case MSM89XX_CDC_CORE_TX2_VOL_CTL_CFG:
-	case MSM89XX_CDC_CORE_TX3_VOL_CTL_CFG:
-	case MSM89XX_CDC_CORE_TX4_VOL_CTL_CFG:
-	case MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG:
-	case MSM89XX_CDC_CORE_IIR1_COEF_B1_CTL:
-	case MSM89XX_CDC_CORE_IIR2_COEF_B1_CTL:
-	case MSM89XX_CDC_CORE_CLK_MCLK_CTL:
-	case MSM89XX_CDC_CORE_CLK_PDM_CTL:
-		return true;
-	default:
-		return false;
-	}
-}
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 5a8d96e..fe45a16 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -126,6 +126,16 @@
 	{ 108, 0x00 }, { 109, 0x00 },
 };
 
+static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case AIC3X_RESET:
+		return true;
+	default:
+		return false;
+	}
+}
+
 static const struct regmap_config aic3x_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -133,6 +143,9 @@
 	.max_register = DAC_ICC_ADJ,
 	.reg_defaults = aic3x_reg,
 	.num_reg_defaults = ARRAY_SIZE(aic3x_reg),
+
+	.volatile_reg = aic3x_volatile_reg,
+
 	.cache_type = REGCACHE_RBTREE,
 };
 
diff --git a/sound/soc/codecs/wcd-dsp-mgr.c b/sound/soc/codecs/wcd-dsp-mgr.c
deleted file mode 100644
index 6cc9f8c..0000000
--- a/sound/soc/codecs/wcd-dsp-mgr.c
+++ /dev/null
@@ -1,1260 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/stringify.h>
-#include <linux/of.h>
-#include <linux/debugfs.h>
-#include <linux/component.h>
-#include <linux/dma-mapping.h>
-#include <soc/qcom/ramdump.h>
-#include <sound/wcd-dsp-mgr.h>
-#include "wcd-dsp-utils.h"
-
-/* Forward declarations */
-static char *wdsp_get_cmpnt_type_string(enum wdsp_cmpnt_type);
-
-/* Component related macros */
-#define WDSP_GET_COMPONENT(wdsp, x) ((x >= WDSP_CMPNT_TYPE_MAX || x < 0) ? \
-					NULL : (&(wdsp->cmpnts[x])))
-#define WDSP_GET_CMPNT_TYPE_STR(x) wdsp_get_cmpnt_type_string(x)
-
-/*
- * These #defines indicate the bit number in status field
- * for each of the status. If bit is set, it indicates
- * the status as done, else if bit is not set, it indicates
- * the status is either failed or not done.
- */
-#define WDSP_STATUS_INITIALIZED   BIT(0)
-#define WDSP_STATUS_CODE_DLOADED  BIT(1)
-#define WDSP_STATUS_DATA_DLOADED  BIT(2)
-#define WDSP_STATUS_BOOTED        BIT(3)
-
-/* Helper macros for printing wdsp messages */
-#define WDSP_ERR(wdsp, fmt, ...)		\
-	dev_err(wdsp->mdev, "%s: " fmt "\n", __func__, ##__VA_ARGS__)
-#define WDSP_DBG(wdsp, fmt, ...)	\
-	dev_dbg(wdsp->mdev, "%s: " fmt "\n", __func__, ##__VA_ARGS__)
-
-/* Helper macros for locking */
-#define WDSP_MGR_MUTEX_LOCK(wdsp, lock)         \
-{                                               \
-	WDSP_DBG(wdsp, "mutex_lock(%s)",        \
-		 __stringify_1(lock));          \
-	mutex_lock(&lock);                      \
-}
-
-#define WDSP_MGR_MUTEX_UNLOCK(wdsp, lock)       \
-{                                               \
-	WDSP_DBG(wdsp, "mutex_unlock(%s)",      \
-		 __stringify_1(lock));          \
-	mutex_unlock(&lock);                    \
-}
-
-/* Helper macros for using status mask */
-#define WDSP_SET_STATUS(wdsp, state)                  \
-{                                                     \
-	wdsp->status |= state;                        \
-	WDSP_DBG(wdsp, "set 0x%lx, new_state = 0x%x", \
-		 state, wdsp->status);                \
-}
-
-#define WDSP_CLEAR_STATUS(wdsp, state)                  \
-{                                                       \
-	wdsp->status &= (~state);                       \
-	WDSP_DBG(wdsp, "clear 0x%lx, new_state = 0x%x", \
-		 state, wdsp->status);                  \
-}
-
-#define WDSP_STATUS_IS_SET(wdsp, state) (wdsp->status & state)
-
-/* SSR relate status macros */
-#define WDSP_SSR_STATUS_WDSP_READY    BIT(0)
-#define WDSP_SSR_STATUS_CDC_READY     BIT(1)
-#define WDSP_SSR_STATUS_READY         \
-	(WDSP_SSR_STATUS_WDSP_READY | WDSP_SSR_STATUS_CDC_READY)
-#define WDSP_SSR_READY_WAIT_TIMEOUT   (10 * HZ)
-
-enum wdsp_ssr_type {
-
-	/* Init value, indicates there is no SSR in progress */
-	WDSP_SSR_TYPE_NO_SSR = 0,
-
-	/*
-	 * Indicates WDSP crashed. The manager driver internally
-	 * decides when to perform WDSP restart based on the
-	 * users of wdsp. Hence there is no explicit WDSP_UP.
-	 */
-	WDSP_SSR_TYPE_WDSP_DOWN,
-
-	/* Indicates codec hardware is down */
-	WDSP_SSR_TYPE_CDC_DOWN,
-
-	/* Indicates codec hardware is up, trigger to restart WDSP */
-	WDSP_SSR_TYPE_CDC_UP,
-};
-
-struct wdsp_cmpnt {
-
-	/* OF node of the phandle */
-	struct device_node *np;
-
-	/*
-	 * Child component's dev_name, should be set in DT for the child's
-	 * phandle if child's dev->of_node does not match the phandle->of_node
-	 */
-	const char *cdev_name;
-
-	/* Child component's device node */
-	struct device *cdev;
-
-	/* Private data that component may want back on callbacks */
-	void *priv_data;
-
-	/* Child ops */
-	struct wdsp_cmpnt_ops *ops;
-};
-
-struct wdsp_ramdump_data {
-
-	/* Ramdump device */
-	void *rd_dev;
-
-	/* DMA address of the dump */
-	dma_addr_t rd_addr;
-
-	/* Virtual address of the dump */
-	void *rd_v_addr;
-
-	/* Data provided through error interrupt */
-	struct wdsp_err_signal_arg err_data;
-};
-
-struct wdsp_mgr_priv {
-
-	/* Manager driver's struct device pointer */
-	struct device *mdev;
-
-	/* Match struct for component framework */
-	struct component_match *match;
-
-	/* Manager's ops/function callbacks */
-	struct wdsp_mgr_ops *ops;
-
-	/* Array to store information for all expected components */
-	struct wdsp_cmpnt cmpnts[WDSP_CMPNT_TYPE_MAX];
-
-	/* The filename of image to be downloaded */
-	const char *img_fname;
-
-	/* Keeps track of current state of manager driver */
-	u32 status;
-
-	/* Work to load the firmware image after component binding */
-	struct work_struct load_fw_work;
-
-	/* List of segments in image to be downloaded */
-	struct list_head *seg_list;
-
-	/* Base address of the image in memory */
-	u32 base_addr;
-
-	/* Instances using dsp */
-	int dsp_users;
-
-	/* Lock for serializing ops called by components */
-	struct mutex api_mutex;
-
-	struct wdsp_ramdump_data dump_data;
-
-	/* SSR related */
-	enum wdsp_ssr_type ssr_type;
-	struct mutex ssr_mutex;
-	struct work_struct ssr_work;
-	u16 ready_status;
-	struct completion ready_compl;
-
-	/* Debugfs related */
-	struct dentry *entry;
-	bool panic_on_error;
-};
-
-static char *wdsp_get_ssr_type_string(enum wdsp_ssr_type type)
-{
-	switch (type) {
-	case WDSP_SSR_TYPE_NO_SSR:
-		return "NO_SSR";
-	case WDSP_SSR_TYPE_WDSP_DOWN:
-		return "WDSP_DOWN";
-	case WDSP_SSR_TYPE_CDC_DOWN:
-		return "CDC_DOWN";
-	case WDSP_SSR_TYPE_CDC_UP:
-		return "CDC_UP";
-	default:
-		pr_err("%s: Invalid ssr_type %d\n",
-			__func__, type);
-		return "Invalid";
-	}
-}
-
-static char *wdsp_get_cmpnt_type_string(enum wdsp_cmpnt_type type)
-{
-	switch (type) {
-	case WDSP_CMPNT_CONTROL:
-		return "control";
-	case WDSP_CMPNT_IPC:
-		return "ipc";
-	case WDSP_CMPNT_TRANSPORT:
-		return "transport";
-	default:
-		pr_err("%s: Invalid component type %d\n",
-			__func__, type);
-		return "Invalid";
-	}
-}
-
-static void __wdsp_clr_ready_locked(struct wdsp_mgr_priv *wdsp,
-				    u16 value)
-{
-	wdsp->ready_status &= ~(value);
-	WDSP_DBG(wdsp, "ready_status = 0x%x", wdsp->ready_status);
-}
-
-static void __wdsp_set_ready_locked(struct wdsp_mgr_priv *wdsp,
-				    u16 value, bool mark_complete)
-{
-	wdsp->ready_status |= value;
-	WDSP_DBG(wdsp, "ready_status = 0x%x", wdsp->ready_status);
-
-	if (mark_complete &&
-	    wdsp->ready_status == WDSP_SSR_STATUS_READY) {
-		WDSP_DBG(wdsp, "marking ready completion");
-		complete(&wdsp->ready_compl);
-	}
-}
-
-static void wdsp_broadcast_event_upseq(struct wdsp_mgr_priv *wdsp,
-				       enum wdsp_event_type event,
-				       void *data)
-{
-	struct wdsp_cmpnt *cmpnt;
-	int i;
-
-	for (i = 0; i < WDSP_CMPNT_TYPE_MAX; i++) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-		if (cmpnt && cmpnt->ops && cmpnt->ops->event_handler)
-			cmpnt->ops->event_handler(cmpnt->cdev, cmpnt->priv_data,
-						  event, data);
-	}
-}
-
-static void wdsp_broadcast_event_downseq(struct wdsp_mgr_priv *wdsp,
-					 enum wdsp_event_type event,
-					 void *data)
-{
-	struct wdsp_cmpnt *cmpnt;
-	int i;
-
-	for (i = WDSP_CMPNT_TYPE_MAX - 1; i >= 0; i--) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-		if (cmpnt && cmpnt->ops && cmpnt->ops->event_handler)
-			cmpnt->ops->event_handler(cmpnt->cdev, cmpnt->priv_data,
-						  event, data);
-	}
-}
-
-static int wdsp_unicast_event(struct wdsp_mgr_priv *wdsp,
-			      enum wdsp_cmpnt_type type,
-			      enum wdsp_event_type event,
-			      void *data)
-{
-	struct wdsp_cmpnt *cmpnt;
-	int ret;
-
-	cmpnt = WDSP_GET_COMPONENT(wdsp, type);
-	if (cmpnt && cmpnt->ops && cmpnt->ops->event_handler) {
-		ret = cmpnt->ops->event_handler(cmpnt->cdev, cmpnt->priv_data,
-						event, data);
-	} else {
-		WDSP_ERR(wdsp, "not valid event_handler for %s",
-			 WDSP_GET_CMPNT_TYPE_STR(type));
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static void wdsp_deinit_components(struct wdsp_mgr_priv *wdsp)
-{
-	struct wdsp_cmpnt *cmpnt;
-	int i;
-
-	for (i = WDSP_CMPNT_TYPE_MAX - 1; i >= 0; i--) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-		if (cmpnt && cmpnt->ops && cmpnt->ops->deinit)
-			cmpnt->ops->deinit(cmpnt->cdev, cmpnt->priv_data);
-	}
-}
-
-static int wdsp_init_components(struct wdsp_mgr_priv *wdsp)
-{
-	struct wdsp_cmpnt *cmpnt;
-	int fail_idx = WDSP_CMPNT_TYPE_MAX;
-	int i, ret = 0;
-
-	for (i = 0; i < WDSP_CMPNT_TYPE_MAX; i++) {
-
-		cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-
-		/* Init is allowed to be NULL */
-		if (!cmpnt->ops || !cmpnt->ops->init)
-			continue;
-		ret = cmpnt->ops->init(cmpnt->cdev, cmpnt->priv_data);
-		if (ret) {
-			WDSP_ERR(wdsp, "Init failed (%d) for component %s",
-				 ret, WDSP_GET_CMPNT_TYPE_STR(i));
-				fail_idx = i;
-				break;
-		}
-	}
-
-	if (fail_idx < WDSP_CMPNT_TYPE_MAX) {
-		/* Undo init for already initialized components */
-		for (i = fail_idx - 1; i >= 0; i--) {
-			struct wdsp_cmpnt *cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-
-			if (cmpnt->ops && cmpnt->ops->deinit)
-				cmpnt->ops->deinit(cmpnt->cdev,
-						   cmpnt->priv_data);
-		}
-	} else {
-		wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_POST_INIT, NULL);
-	}
-
-	return ret;
-}
-
-static int wdsp_load_each_segment(struct wdsp_mgr_priv *wdsp,
-				  struct wdsp_img_segment *seg)
-{
-	struct wdsp_img_section img_section;
-	int ret;
-
-	WDSP_DBG(wdsp,
-		 "base_addr 0x%x, split_fname %s, load_addr 0x%x, size 0x%zx",
-		 wdsp->base_addr, seg->split_fname, seg->load_addr, seg->size);
-
-	if (seg->load_addr < wdsp->base_addr) {
-		WDSP_ERR(wdsp, "Invalid addr 0x%x, base_addr = 0x%x",
-			 seg->load_addr, wdsp->base_addr);
-		return -EINVAL;
-	}
-
-	img_section.addr = seg->load_addr - wdsp->base_addr;
-	img_section.size = seg->size;
-	img_section.data = seg->data;
-
-	ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_TRANSPORT,
-				 WDSP_EVENT_DLOAD_SECTION,
-				 &img_section);
-	if (ret < 0)
-		WDSP_ERR(wdsp,
-			 "Failed, err = %d for base_addr = 0x%x split_fname = %s, load_addr = 0x%x, size = 0x%zx",
-			 ret, wdsp->base_addr, seg->split_fname,
-			 seg->load_addr, seg->size);
-	return ret;
-}
-
-static int wdsp_download_segments(struct wdsp_mgr_priv *wdsp,
-				  unsigned int type)
-{
-	struct wdsp_cmpnt *ctl;
-	struct wdsp_img_segment *seg = NULL;
-	enum wdsp_event_type pre, post;
-	long status;
-	int ret;
-
-	ctl = WDSP_GET_COMPONENT(wdsp, WDSP_CMPNT_CONTROL);
-
-	if (type == WDSP_ELF_FLAG_RE) {
-		pre = WDSP_EVENT_PRE_DLOAD_CODE;
-		post = WDSP_EVENT_POST_DLOAD_CODE;
-		status = WDSP_STATUS_CODE_DLOADED;
-	} else if (type == WDSP_ELF_FLAG_WRITE) {
-		pre = WDSP_EVENT_PRE_DLOAD_DATA;
-		post = WDSP_EVENT_POST_DLOAD_DATA;
-		status = WDSP_STATUS_DATA_DLOADED;
-	} else {
-		WDSP_ERR(wdsp, "Invalid type %u", type);
-		return -EINVAL;
-	}
-
-	ret = wdsp_get_segment_list(ctl->cdev, wdsp->img_fname,
-				    type, wdsp->seg_list, &wdsp->base_addr);
-	if (ret < 0 ||
-	    list_empty(wdsp->seg_list)) {
-		WDSP_ERR(wdsp, "Error %d to get image segments for type %d",
-			 ret, type);
-		wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_DLOAD_FAILED,
-					     NULL);
-		goto done;
-	}
-
-	/* Notify all components that image is about to be downloaded */
-	wdsp_broadcast_event_upseq(wdsp, pre, NULL);
-
-	/* Go through the list of segments and download one by one */
-	list_for_each_entry(seg, wdsp->seg_list, list) {
-		ret = wdsp_load_each_segment(wdsp, seg);
-		if (ret)
-			goto dload_error;
-	}
-
-	/* Flush the list before setting status and notifying components */
-	wdsp_flush_segment_list(wdsp->seg_list);
-
-	WDSP_SET_STATUS(wdsp, status);
-
-	/* Notify all components that image is downloaded */
-	wdsp_broadcast_event_downseq(wdsp, post, NULL);
-done:
-	return ret;
-
-dload_error:
-	wdsp_flush_segment_list(wdsp->seg_list);
-	wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_DLOAD_FAILED, NULL);
-	return ret;
-}
-
-static int wdsp_init_and_dload_code_sections(struct wdsp_mgr_priv *wdsp)
-{
-	int ret;
-	bool is_initialized;
-
-	is_initialized = WDSP_STATUS_IS_SET(wdsp, WDSP_STATUS_INITIALIZED);
-
-	if (!is_initialized) {
-		/* Components are not initialized yet, initialize them */
-		ret = wdsp_init_components(wdsp);
-		if (ret < 0) {
-			WDSP_ERR(wdsp, "INIT failed, err = %d", ret);
-			goto done;
-		}
-		WDSP_SET_STATUS(wdsp, WDSP_STATUS_INITIALIZED);
-	}
-
-	/* Download the read-execute sections of image */
-	ret = wdsp_download_segments(wdsp, WDSP_ELF_FLAG_RE);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Error %d to download code sections", ret);
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static void wdsp_load_fw_image(struct work_struct *work)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int ret;
-
-	wdsp = container_of(work, struct wdsp_mgr_priv, load_fw_work);
-	if (!wdsp) {
-		pr_err("%s: Invalid private_data\n", __func__);
-		return;
-	}
-
-	ret = wdsp_init_and_dload_code_sections(wdsp);
-	if (ret < 0)
-		WDSP_ERR(wdsp, "dload code sections failed, err = %d", ret);
-}
-
-static int wdsp_enable_dsp(struct wdsp_mgr_priv *wdsp)
-{
-	int ret;
-
-	/* Make sure wdsp is in good state */
-	if (!WDSP_STATUS_IS_SET(wdsp, WDSP_STATUS_CODE_DLOADED)) {
-		WDSP_ERR(wdsp, "WDSP in invalid state 0x%x", wdsp->status);
-		return -EINVAL;
-	}
-
-	/*
-	 * Acquire SSR mutex lock to make sure enablement of DSP
-	 * does not race with SSR handling.
-	 */
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->ssr_mutex);
-	/* Download the read-write sections of image */
-	ret = wdsp_download_segments(wdsp, WDSP_ELF_FLAG_WRITE);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Data section download failed, err = %d", ret);
-		goto done;
-	}
-
-	wdsp_broadcast_event_upseq(wdsp, WDSP_EVENT_PRE_BOOTUP, NULL);
-
-	ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_CONTROL,
-				 WDSP_EVENT_DO_BOOT, NULL);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Failed to boot dsp, err = %d", ret);
-		WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_DATA_DLOADED);
-		goto done;
-	}
-
-	wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_POST_BOOTUP, NULL);
-	WDSP_SET_STATUS(wdsp, WDSP_STATUS_BOOTED);
-done:
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-	return ret;
-}
-
-static int wdsp_disable_dsp(struct wdsp_mgr_priv *wdsp)
-{
-	int ret;
-
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->ssr_mutex);
-
-	/*
-	 * If Disable happened while SSR is in progress, then set the SSR
-	 * ready status indicating WDSP is now ready. Ignore the disable
-	 * event here and let the SSR handler go through shutdown.
-	 */
-	if (wdsp->ssr_type != WDSP_SSR_TYPE_NO_SSR) {
-		__wdsp_set_ready_locked(wdsp, WDSP_SSR_STATUS_WDSP_READY, true);
-		WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-		return 0;
-	}
-
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-
-	/* Make sure wdsp is in good state */
-	if (!WDSP_STATUS_IS_SET(wdsp, WDSP_STATUS_BOOTED)) {
-		WDSP_ERR(wdsp, "wdsp in invalid state 0x%x", wdsp->status);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_PRE_SHUTDOWN, NULL);
-	ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_CONTROL,
-				 WDSP_EVENT_DO_SHUTDOWN, NULL);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Failed to shutdown dsp, err = %d", ret);
-		goto done;
-	}
-
-	wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_POST_SHUTDOWN, NULL);
-	WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_BOOTED);
-
-	/* Data sections are to be downloaded per boot */
-	WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_DATA_DLOADED);
-done:
-	return ret;
-}
-
-static int wdsp_register_cmpnt_ops(struct device *wdsp_dev,
-				   struct device *cdev,
-				   void *priv_data,
-				   struct wdsp_cmpnt_ops *ops)
-{
-	struct wdsp_mgr_priv *wdsp;
-	struct wdsp_cmpnt *cmpnt;
-	int i, ret;
-
-	if (!wdsp_dev || !cdev || !ops)
-		return -EINVAL;
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->api_mutex);
-
-	for (i = 0; i < WDSP_CMPNT_TYPE_MAX; i++) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, i);
-		if ((cdev->of_node && cdev->of_node == cmpnt->np) ||
-		    (cmpnt->cdev_name &&
-		     !strcmp(dev_name(cdev), cmpnt->cdev_name))) {
-			break;
-		}
-	}
-
-	if (i == WDSP_CMPNT_TYPE_MAX) {
-		WDSP_ERR(wdsp, "Failed to register component dev %s",
-			 dev_name(cdev));
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cmpnt->cdev = cdev;
-	cmpnt->ops = ops;
-	cmpnt->priv_data = priv_data;
-done:
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->api_mutex);
-	return 0;
-}
-
-static struct device *wdsp_get_dev_for_cmpnt(struct device *wdsp_dev,
-					     enum wdsp_cmpnt_type type)
-{
-	struct wdsp_mgr_priv *wdsp;
-	struct wdsp_cmpnt *cmpnt;
-
-	if (!wdsp_dev || type >= WDSP_CMPNT_TYPE_MAX)
-		return NULL;
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-	cmpnt = WDSP_GET_COMPONENT(wdsp, type);
-
-	return cmpnt->cdev;
-}
-
-static int wdsp_get_devops_for_cmpnt(struct device *wdsp_dev,
-				     enum wdsp_cmpnt_type type,
-				     void *data)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int ret = 0;
-
-	if (!wdsp_dev || type >= WDSP_CMPNT_TYPE_MAX)
-		return -EINVAL;
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-	ret = wdsp_unicast_event(wdsp, type,
-				 WDSP_EVENT_GET_DEVOPS, data);
-	if (ret)
-		WDSP_ERR(wdsp, "get_dev_ops failed for cmpnt type %d",
-			 type);
-	return ret;
-}
-
-static void wdsp_collect_ramdumps(struct wdsp_mgr_priv *wdsp)
-{
-	struct wdsp_img_section img_section;
-	struct wdsp_err_signal_arg *data = &wdsp->dump_data.err_data;
-	struct ramdump_segment rd_seg;
-	int ret = 0;
-
-	if (wdsp->ssr_type != WDSP_SSR_TYPE_WDSP_DOWN ||
-	    !data->mem_dumps_enabled) {
-		WDSP_DBG(wdsp, "cannot dump memory, ssr_type %s, dumps %s",
-			 wdsp_get_ssr_type_string(wdsp->ssr_type),
-			 !(data->mem_dumps_enabled) ? "disabled" : "enabled");
-		goto done;
-	}
-
-	if (data->dump_size == 0 ||
-	    data->remote_start_addr < wdsp->base_addr) {
-		WDSP_ERR(wdsp, "Invalid start addr 0x%x or dump_size 0x%zx",
-			 data->remote_start_addr, data->dump_size);
-		goto done;
-	}
-
-	if (!wdsp->dump_data.rd_dev) {
-		WDSP_ERR(wdsp, "Ramdump device is not setup");
-		goto done;
-	}
-
-	WDSP_DBG(wdsp, "base_addr 0x%x, dump_start_addr 0x%x, dump_size 0x%zx",
-		 wdsp->base_addr, data->remote_start_addr, data->dump_size);
-
-	/* Allocate memory for dumps */
-	wdsp->dump_data.rd_v_addr = dma_alloc_coherent(wdsp->mdev,
-						       data->dump_size,
-						       &wdsp->dump_data.rd_addr,
-						       GFP_KERNEL);
-	if (!wdsp->dump_data.rd_v_addr)
-		goto done;
-
-	img_section.addr = data->remote_start_addr - wdsp->base_addr;
-	img_section.size = data->dump_size;
-	img_section.data = wdsp->dump_data.rd_v_addr;
-
-	ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_TRANSPORT,
-				 WDSP_EVENT_READ_SECTION,
-				 &img_section);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Failed to read dumps, size 0x%zx at addr 0x%x",
-			 img_section.size, img_section.addr);
-		goto err_read_dumps;
-	}
-
-	/*
-	 * If panic_on_error flag is explicitly set through the debugfs,
-	 * then cause a BUG here to aid debugging.
-	 */
-	BUG_ON(wdsp->panic_on_error);
-
-	rd_seg.address = (unsigned long) wdsp->dump_data.rd_v_addr;
-	rd_seg.size = img_section.size;
-	rd_seg.v_address = wdsp->dump_data.rd_v_addr;
-
-	ret = do_ramdump(wdsp->dump_data.rd_dev, &rd_seg, 1);
-	if (ret < 0)
-		WDSP_ERR(wdsp, "do_ramdump failed with error %d", ret);
-
-err_read_dumps:
-	dma_free_coherent(wdsp->mdev, data->dump_size,
-			  wdsp->dump_data.rd_v_addr, wdsp->dump_data.rd_addr);
-done:
-	return;
-}
-
-static void wdsp_ssr_work_fn(struct work_struct *work)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int ret;
-
-	wdsp = container_of(work, struct wdsp_mgr_priv, ssr_work);
-	if (!wdsp) {
-		pr_err("%s: Invalid private_data\n", __func__);
-		return;
-	}
-
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->ssr_mutex);
-
-	/* Issue ramdumps and shutdown only if DSP is currently booted */
-	if (WDSP_STATUS_IS_SET(wdsp, WDSP_STATUS_BOOTED)) {
-		wdsp_collect_ramdumps(wdsp);
-		ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_CONTROL,
-					 WDSP_EVENT_DO_SHUTDOWN, NULL);
-		if (ret < 0)
-			WDSP_ERR(wdsp, "Failed WDSP shutdown, err = %d", ret);
-
-		wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_POST_SHUTDOWN,
-					     NULL);
-		WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_BOOTED);
-	}
-
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-	ret = wait_for_completion_timeout(&wdsp->ready_compl,
-					  WDSP_SSR_READY_WAIT_TIMEOUT);
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->ssr_mutex);
-	if (ret == 0) {
-		WDSP_ERR(wdsp, "wait_for_ready timed out, status = 0x%x",
-			 wdsp->ready_status);
-		goto done;
-	}
-
-	/* Data sections are to downloaded per WDSP boot */
-	WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_DATA_DLOADED);
-
-	/*
-	 * Even though code section could possible be retained on DSP
-	 * crash, go ahead and still re-download just to avoid any
-	 * memory corruption from previous crash.
-	 */
-	WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_CODE_DLOADED);
-
-	/* If codec restarted, then all components must be re-initialized */
-	if (wdsp->ssr_type == WDSP_SSR_TYPE_CDC_UP) {
-		wdsp_deinit_components(wdsp);
-		WDSP_CLEAR_STATUS(wdsp, WDSP_STATUS_INITIALIZED);
-	}
-
-	ret = wdsp_init_and_dload_code_sections(wdsp);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Failed to dload code sections err = %d",
-			 ret);
-		goto done;
-	}
-
-	/* SSR handling is finished, mark SSR type as NO_SSR */
-	wdsp->ssr_type = WDSP_SSR_TYPE_NO_SSR;
-done:
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-}
-
-static int wdsp_ssr_handler(struct wdsp_mgr_priv *wdsp, void *arg,
-			    enum wdsp_ssr_type ssr_type)
-{
-	enum wdsp_ssr_type current_ssr_type;
-	struct wdsp_err_signal_arg *err_data;
-
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->ssr_mutex);
-
-	current_ssr_type = wdsp->ssr_type;
-	WDSP_DBG(wdsp, "Current ssr_type %s, handling ssr_type %s",
-		 wdsp_get_ssr_type_string(current_ssr_type),
-		 wdsp_get_ssr_type_string(ssr_type));
-	wdsp->ssr_type = ssr_type;
-
-	if (arg) {
-		err_data = (struct wdsp_err_signal_arg *) arg;
-		memcpy(&wdsp->dump_data.err_data, err_data,
-		       sizeof(*err_data));
-	} else {
-		memset(&wdsp->dump_data.err_data, 0,
-		       sizeof(wdsp->dump_data.err_data));
-	}
-
-	switch (ssr_type) {
-
-	case WDSP_SSR_TYPE_WDSP_DOWN:
-		__wdsp_clr_ready_locked(wdsp, WDSP_SSR_STATUS_WDSP_READY);
-		wdsp_broadcast_event_downseq(wdsp, WDSP_EVENT_PRE_SHUTDOWN,
-					     NULL);
-		schedule_work(&wdsp->ssr_work);
-		break;
-
-	case WDSP_SSR_TYPE_CDC_DOWN:
-		__wdsp_clr_ready_locked(wdsp, WDSP_SSR_STATUS_CDC_READY);
-		/*
-		 * If DSP is booted when CDC_DOWN is received, it needs
-		 * to be shutdown.
-		 */
-		if (WDSP_STATUS_IS_SET(wdsp, WDSP_STATUS_BOOTED)) {
-			__wdsp_clr_ready_locked(wdsp,
-						WDSP_SSR_STATUS_WDSP_READY);
-			wdsp_broadcast_event_downseq(wdsp,
-						     WDSP_EVENT_PRE_SHUTDOWN,
-						     NULL);
-		}
-
-		schedule_work(&wdsp->ssr_work);
-		break;
-
-	case WDSP_SSR_TYPE_CDC_UP:
-		__wdsp_set_ready_locked(wdsp, WDSP_SSR_STATUS_CDC_READY, true);
-		break;
-
-	default:
-		WDSP_ERR(wdsp, "undefined ssr_type %d\n", ssr_type);
-		/* Revert back the ssr_type for undefined events */
-		wdsp->ssr_type = current_ssr_type;
-		break;
-	}
-
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->ssr_mutex);
-
-	return 0;
-}
-
-static int wdsp_signal_handler(struct device *wdsp_dev,
-			       enum wdsp_signal signal, void *arg)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int ret;
-
-	if (!wdsp_dev)
-		return -EINVAL;
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->api_mutex);
-
-	WDSP_DBG(wdsp, "Raised signal %d", signal);
-
-	switch (signal) {
-	case WDSP_IPC1_INTR:
-		ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_IPC,
-					 WDSP_EVENT_IPC1_INTR, NULL);
-		break;
-	case WDSP_ERR_INTR:
-		ret = wdsp_ssr_handler(wdsp, arg, WDSP_SSR_TYPE_WDSP_DOWN);
-		break;
-	case WDSP_CDC_DOWN_SIGNAL:
-		ret = wdsp_ssr_handler(wdsp, arg, WDSP_SSR_TYPE_CDC_DOWN);
-		break;
-	case WDSP_CDC_UP_SIGNAL:
-		ret = wdsp_ssr_handler(wdsp, arg, WDSP_SSR_TYPE_CDC_UP);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	if (ret < 0)
-		WDSP_ERR(wdsp, "handling signal %d failed with error %d",
-			 signal, ret);
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->api_mutex);
-
-	return ret;
-}
-
-static int wdsp_vote_for_dsp(struct device *wdsp_dev,
-			     bool vote)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int ret = 0;
-
-	if (!wdsp_dev)
-		return -EINVAL;
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-
-	WDSP_MGR_MUTEX_LOCK(wdsp, wdsp->api_mutex);
-	WDSP_DBG(wdsp, "request %s, current users = %d",
-		 vote ? "enable" : "disable", wdsp->dsp_users);
-
-	if (vote) {
-		wdsp->dsp_users++;
-		if (wdsp->dsp_users == 1)
-			ret = wdsp_enable_dsp(wdsp);
-	} else {
-		if (wdsp->dsp_users == 0)
-			goto done;
-
-		wdsp->dsp_users--;
-		if (wdsp->dsp_users == 0)
-			ret = wdsp_disable_dsp(wdsp);
-	}
-
-	if (ret < 0)
-		WDSP_DBG(wdsp, "wdsp %s failed, err = %d",
-			 vote ? "enable" : "disable", ret);
-
-done:
-	WDSP_MGR_MUTEX_UNLOCK(wdsp, wdsp->api_mutex);
-	return ret;
-}
-
-static int wdsp_suspend(struct device *wdsp_dev)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int rc = 0, i;
-
-	if (!wdsp_dev) {
-		pr_err("%s: Invalid handle to device\n", __func__);
-		return -EINVAL;
-	}
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-
-	for (i =  WDSP_CMPNT_TYPE_MAX - 1; i >= 0; i--) {
-		rc = wdsp_unicast_event(wdsp, i, WDSP_EVENT_SUSPEND, NULL);
-		if (rc < 0) {
-			WDSP_ERR(wdsp, "component %s failed to suspend\n",
-				WDSP_GET_CMPNT_TYPE_STR(i));
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int wdsp_resume(struct device *wdsp_dev)
-{
-	struct wdsp_mgr_priv *wdsp;
-	int rc = 0, i;
-
-	if (!wdsp_dev) {
-		pr_err("%s: Invalid handle to device\n", __func__);
-		return -EINVAL;
-	}
-
-	wdsp = dev_get_drvdata(wdsp_dev);
-
-	for (i =  0; i < WDSP_CMPNT_TYPE_MAX; i++) {
-		rc = wdsp_unicast_event(wdsp, i, WDSP_EVENT_RESUME, NULL);
-		if (rc < 0) {
-			WDSP_ERR(wdsp, "component %s failed to resume\n",
-				WDSP_GET_CMPNT_TYPE_STR(i));
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static struct wdsp_mgr_ops wdsp_ops = {
-	.register_cmpnt_ops = wdsp_register_cmpnt_ops,
-	.get_dev_for_cmpnt = wdsp_get_dev_for_cmpnt,
-	.get_devops_for_cmpnt = wdsp_get_devops_for_cmpnt,
-	.signal_handler = wdsp_signal_handler,
-	.vote_for_dsp = wdsp_vote_for_dsp,
-	.suspend = wdsp_suspend,
-	.resume = wdsp_resume,
-};
-
-static int wdsp_mgr_compare_of(struct device *dev, void *data)
-{
-	struct wdsp_cmpnt *cmpnt = data;
-
-	/*
-	 * First try to match based on of_node, if of_node is not
-	 * present, try to match on the dev_name
-	 */
-	return ((dev->of_node && dev->of_node == cmpnt->np) ||
-		(cmpnt->cdev_name &&
-		 !strcmp(dev_name(dev), cmpnt->cdev_name)));
-}
-
-static void wdsp_mgr_debugfs_init(struct wdsp_mgr_priv *wdsp)
-{
-	wdsp->entry = debugfs_create_dir("wdsp_mgr", NULL);
-	if (IS_ERR_OR_NULL(wdsp->entry))
-		return;
-
-	debugfs_create_bool("panic_on_error", 0644,
-			    wdsp->entry, &wdsp->panic_on_error);
-}
-
-static void wdsp_mgr_debugfs_remove(struct wdsp_mgr_priv *wdsp)
-{
-	debugfs_remove_recursive(wdsp->entry);
-	wdsp->entry = NULL;
-}
-
-static int wdsp_mgr_bind(struct device *dev)
-{
-	struct wdsp_mgr_priv *wdsp = dev_get_drvdata(dev);
-	struct wdsp_cmpnt *cmpnt;
-	int ret, idx;
-
-	wdsp->ops = &wdsp_ops;
-
-	/* Setup ramdump device */
-	wdsp->dump_data.rd_dev = create_ramdump_device("wdsp", dev);
-	if (!wdsp->dump_data.rd_dev)
-		dev_info(dev, "%s: create_ramdump_device failed\n", __func__);
-
-	ret = component_bind_all(dev, wdsp->ops);
-	if (ret < 0)
-		WDSP_ERR(wdsp, "component_bind_all failed %d\n", ret);
-
-	/* Make sure all components registered ops */
-	for (idx = 0; idx < WDSP_CMPNT_TYPE_MAX; idx++) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, idx);
-		if (!cmpnt->cdev || !cmpnt->ops) {
-			WDSP_ERR(wdsp, "%s did not register ops\n",
-				 WDSP_GET_CMPNT_TYPE_STR(idx));
-			ret = -EINVAL;
-			component_unbind_all(dev, wdsp->ops);
-			break;
-		}
-	}
-
-	wdsp_mgr_debugfs_init(wdsp);
-
-	/* Schedule the work to download image if binding was successful. */
-	if (!ret)
-		schedule_work(&wdsp->load_fw_work);
-
-	return ret;
-}
-
-static void wdsp_mgr_unbind(struct device *dev)
-{
-	struct wdsp_mgr_priv *wdsp = dev_get_drvdata(dev);
-	struct wdsp_cmpnt *cmpnt;
-	int idx;
-
-	component_unbind_all(dev, wdsp->ops);
-
-	wdsp_mgr_debugfs_remove(wdsp);
-
-	if (wdsp->dump_data.rd_dev) {
-		destroy_ramdump_device(wdsp->dump_data.rd_dev);
-		wdsp->dump_data.rd_dev = NULL;
-	}
-
-	/* Clear all status bits */
-	wdsp->status = 0x00;
-
-	/* clean up the components */
-	for (idx = 0; idx < WDSP_CMPNT_TYPE_MAX; idx++) {
-		cmpnt = WDSP_GET_COMPONENT(wdsp, idx);
-		cmpnt->cdev = NULL;
-		cmpnt->ops = NULL;
-		cmpnt->priv_data = NULL;
-	}
-}
-
-static const struct component_master_ops wdsp_master_ops = {
-	.bind = wdsp_mgr_bind,
-	.unbind = wdsp_mgr_unbind,
-};
-
-static void *wdsp_mgr_parse_phandle(struct wdsp_mgr_priv *wdsp,
-				    int index)
-{
-	struct device *mdev = wdsp->mdev;
-	struct device_node *np;
-	struct wdsp_cmpnt *cmpnt = NULL;
-	struct of_phandle_args pargs;
-	u32 value;
-	int ret;
-
-	ret = of_parse_phandle_with_fixed_args(mdev->of_node,
-					      "qcom,wdsp-components", 1,
-					      index, &pargs);
-	if (ret) {
-		WDSP_ERR(wdsp, "parse_phandle at index %d failed %d",
-			 index, ret);
-		return NULL;
-	}
-
-	np = pargs.np;
-	value = pargs.args[0];
-
-	if (value >= WDSP_CMPNT_TYPE_MAX) {
-		WDSP_ERR(wdsp, "invalid phandle_arg to of_node %s", np->name);
-		goto done;
-	}
-
-	cmpnt = WDSP_GET_COMPONENT(wdsp, value);
-	if (cmpnt->np || cmpnt->cdev_name) {
-		WDSP_ERR(wdsp, "cmpnt %d already added", value);
-		cmpnt = NULL;
-		goto done;
-	}
-
-	cmpnt->np = np;
-	of_property_read_string(np, "qcom,wdsp-cmpnt-dev-name",
-				&cmpnt->cdev_name);
-done:
-	of_node_put(np);
-	return cmpnt;
-}
-
-static int wdsp_mgr_parse_dt_entries(struct wdsp_mgr_priv *wdsp)
-{
-	struct device *dev = wdsp->mdev;
-	void *match_data;
-	int ph_idx, ret;
-
-	ret = of_property_read_string(dev->of_node, "qcom,img-filename",
-				      &wdsp->img_fname);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Reading property %s failed, error = %d",
-			 "qcom,img-filename", ret);
-		return ret;
-	}
-
-	ret = of_count_phandle_with_args(dev->of_node,
-					 "qcom,wdsp-components",
-					 NULL);
-	if (ret == -ENOENT) {
-		WDSP_ERR(wdsp, "Property %s not defined in DT",
-			 "qcom,wdsp-components");
-		goto done;
-	} else if (ret != WDSP_CMPNT_TYPE_MAX * 2) {
-		WDSP_ERR(wdsp, "Invalid phandle + arg count %d, expected %d",
-			 ret, WDSP_CMPNT_TYPE_MAX * 2);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = 0;
-
-	for (ph_idx = 0; ph_idx < WDSP_CMPNT_TYPE_MAX; ph_idx++) {
-
-		match_data = wdsp_mgr_parse_phandle(wdsp, ph_idx);
-		if (!match_data) {
-			WDSP_ERR(wdsp, "component not found at idx %d", ph_idx);
-			ret = -EINVAL;
-			goto done;
-		}
-
-		component_match_add(dev, &wdsp->match,
-				    wdsp_mgr_compare_of, match_data);
-	}
-
-done:
-	return ret;
-}
-
-static int wdsp_mgr_probe(struct platform_device *pdev)
-{
-	struct wdsp_mgr_priv *wdsp;
-	struct device *mdev = &pdev->dev;
-	int ret;
-
-	wdsp = devm_kzalloc(mdev, sizeof(*wdsp), GFP_KERNEL);
-	if (!wdsp)
-		return -ENOMEM;
-	wdsp->mdev = mdev;
-	wdsp->seg_list = devm_kzalloc(mdev, sizeof(struct list_head),
-				      GFP_KERNEL);
-	if (!wdsp->seg_list) {
-		devm_kfree(mdev, wdsp);
-		return -ENOMEM;
-	}
-
-	ret = wdsp_mgr_parse_dt_entries(wdsp);
-	if (ret)
-		goto err_dt_parse;
-
-	INIT_WORK(&wdsp->load_fw_work, wdsp_load_fw_image);
-	INIT_LIST_HEAD(wdsp->seg_list);
-	mutex_init(&wdsp->api_mutex);
-	mutex_init(&wdsp->ssr_mutex);
-	wdsp->ssr_type = WDSP_SSR_TYPE_NO_SSR;
-	wdsp->ready_status = WDSP_SSR_STATUS_READY;
-	INIT_WORK(&wdsp->ssr_work, wdsp_ssr_work_fn);
-	init_completion(&wdsp->ready_compl);
-	arch_setup_dma_ops(wdsp->mdev, 0, 0, NULL, 0);
-	dev_set_drvdata(mdev, wdsp);
-
-	ret = component_master_add_with_match(mdev, &wdsp_master_ops,
-					      wdsp->match);
-	if (ret < 0) {
-		WDSP_ERR(wdsp, "Failed to add master, err = %d", ret);
-		goto err_master_add;
-	}
-
-	return 0;
-
-err_master_add:
-	mutex_destroy(&wdsp->api_mutex);
-	mutex_destroy(&wdsp->ssr_mutex);
-err_dt_parse:
-	devm_kfree(mdev, wdsp->seg_list);
-	devm_kfree(mdev, wdsp);
-	dev_set_drvdata(mdev, NULL);
-
-	return ret;
-}
-
-static int wdsp_mgr_remove(struct platform_device *pdev)
-{
-	struct device *mdev = &pdev->dev;
-	struct wdsp_mgr_priv *wdsp = dev_get_drvdata(mdev);
-
-	component_master_del(mdev, &wdsp_master_ops);
-
-	mutex_destroy(&wdsp->api_mutex);
-	mutex_destroy(&wdsp->ssr_mutex);
-	devm_kfree(mdev, wdsp->seg_list);
-	devm_kfree(mdev, wdsp);
-	dev_set_drvdata(mdev, NULL);
-
-	return 0;
-};
-
-static const struct of_device_id wdsp_mgr_dt_match[] = {
-	{.compatible = "qcom,wcd-dsp-mgr" },
-	{ }
-};
-
-static struct platform_driver wdsp_mgr_driver = {
-	.driver = {
-		.name = "wcd-dsp-mgr",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(wdsp_mgr_dt_match),
-	},
-	.probe = wdsp_mgr_probe,
-	.remove = wdsp_mgr_remove,
-};
-
-int wcd_dsp_mgr_init(void)
-{
-	return platform_driver_register(&wdsp_mgr_driver);
-}
-
-void wcd_dsp_mgr_exit(void)
-{
-	platform_driver_unregister(&wdsp_mgr_driver);
-}
-
-MODULE_DESCRIPTION("WCD DSP manager driver");
-MODULE_DEVICE_TABLE(of, wdsp_mgr_dt_match);
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd-dsp-utils.c b/sound/soc/codecs/wcd-dsp-utils.c
deleted file mode 100644
index 4eafd55..0000000
--- a/sound/soc/codecs/wcd-dsp-utils.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/firmware.h>
-#include <linux/elf.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include "wcd-dsp-utils.h"
-
-static bool wdsp_is_valid_elf_hdr(const struct elf32_hdr *ehdr,
-				  size_t fw_size)
-{
-	if (fw_size < sizeof(*ehdr)) {
-		pr_err("%s: Firmware too small\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
-		pr_err("%s: Not an ELF file\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
-		pr_err("%s: Not an executable image\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (ehdr->e_phnum == 0) {
-		pr_err("%s: no segments to load\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (sizeof(struct elf32_phdr) * ehdr->e_phnum +
-	    sizeof(struct elf32_hdr) > fw_size) {
-		pr_err("%s: Too small MDT file\n", __func__);
-		goto elf_check_fail;
-	}
-
-	return true;
-
-elf_check_fail:
-	return false;
-}
-
-static int wdsp_add_segment_to_list(struct device *dev,
-				    const char *img_fname,
-				    const struct elf32_phdr *phdr,
-				    int phdr_idx,
-				    struct list_head *seg_list)
-{
-	struct wdsp_img_segment *seg;
-	int ret = 0;
-
-	/* Do not load segments with zero size */
-	if (phdr->p_filesz == 0 || phdr->p_memsz == 0)
-		goto done;
-
-	seg = kzalloc(sizeof(*seg), GFP_KERNEL);
-	if (!seg) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(seg->split_fname, sizeof(seg->split_fname),
-		 "%s.b%02d", img_fname, phdr_idx);
-	ret = request_firmware(&seg->split_fw, seg->split_fname, dev);
-	if (ret < 0) {
-		dev_err(dev, "%s: firmware %s not found\n",
-			__func__, seg->split_fname);
-		goto bad_seg;
-	}
-
-	seg->load_addr = phdr->p_paddr;
-	seg->size = phdr->p_filesz;
-	seg->data = (u8 *) seg->split_fw->data;
-
-	list_add_tail(&seg->list, seg_list);
-done:
-	return ret;
-bad_seg:
-	kfree(seg);
-	return ret;
-}
-
-/*
- * wdsp_flush_segment_list: Flush the list of segments
- * @seg_list: List of segments to be flushed
- * This API will traverse through the list of segments provided in
- * seg_list, release the firmware for each segment and delete the
- * segment from the list.
- */
-void wdsp_flush_segment_list(struct list_head *seg_list)
-{
-	struct wdsp_img_segment *seg, *next;
-
-	list_for_each_entry_safe(seg, next, seg_list, list) {
-		release_firmware(seg->split_fw);
-		list_del(&seg->list);
-		kfree(seg);
-	}
-}
-EXPORT_SYMBOL(wdsp_flush_segment_list);
-
-/*
- * wdsp_get_segment_list: Get the list of requested segments
- * @dev: struct device pointer of caller
- * @img_fname: Image name for the mdt and split firmware files
- * @segment_type: Requested segment type, should be either
- *		  WDSP_ELF_FLAG_RE or WDSP_ELF_FLAG_WRITE
- * @seg_list: An initialized head for list of segmented to be returned
- * @entry_point: Pointer to return the entry point of the image
- * This API will parse the mdt file for img_fname and create
- * an struct wdsp_img_segment for each segment that matches segment_type
- * and add this structure to list pointed by seg_list
- */
-int wdsp_get_segment_list(struct device *dev,
-			  const char *img_fname,
-			  unsigned int segment_type,
-			  struct list_head *seg_list,
-			  u32 *entry_point)
-{
-	const struct firmware *fw;
-	const struct elf32_hdr *ehdr;
-	const struct elf32_phdr *phdr;
-	const u8 *elf_ptr;
-	char mdt_name[WDSP_IMG_NAME_LEN_MAX];
-	int ret, phdr_idx;
-	bool segment_match;
-
-	if (!dev) {
-		ret = -EINVAL;
-		pr_err("%s: Invalid device handle\n", __func__);
-		goto done;
-	}
-
-	if (!img_fname || !seg_list || !entry_point) {
-		ret = -EINVAL;
-		dev_err(dev, "%s: Invalid input params\n",
-			__func__);
-		goto done;
-	}
-
-	if (segment_type != WDSP_ELF_FLAG_RE &&
-	    segment_type != WDSP_ELF_FLAG_WRITE) {
-		dev_err(dev, "%s: Invalid request for segment_type %d\n",
-			__func__, segment_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snprintf(mdt_name, sizeof(mdt_name), "%s.mdt", img_fname);
-	ret = request_firmware(&fw, mdt_name, dev);
-	if (ret < 0) {
-		dev_err(dev, "%s: firmware %s not found\n",
-			__func__, mdt_name);
-		goto done;
-	}
-
-	ehdr = (struct elf32_hdr *) fw->data;
-	*entry_point = ehdr->e_entry;
-	if (!wdsp_is_valid_elf_hdr(ehdr, fw->size)) {
-		dev_err(dev, "%s: fw mdt %s is invalid\n",
-			__func__, mdt_name);
-		ret = -EINVAL;
-		goto bad_elf;
-	}
-
-	elf_ptr = fw->data + sizeof(*ehdr);
-	for (phdr_idx = 0; phdr_idx < ehdr->e_phnum; phdr_idx++) {
-		phdr = (struct elf32_phdr *) elf_ptr;
-		segment_match = false;
-
-		switch (segment_type) {
-		case WDSP_ELF_FLAG_RE:
-			/*
-			 * Flag can be READ or EXECUTE or both but
-			 * WRITE flag should not be set.
-			 */
-			if ((phdr->p_flags & segment_type) &&
-			    !(phdr->p_flags & WDSP_ELF_FLAG_WRITE))
-				segment_match = true;
-			break;
-		case WDSP_ELF_FLAG_WRITE:
-			/*
-			 * If WRITE flag is set, other flags do not
-			 * matter.
-			 */
-			if (phdr->p_flags & segment_type)
-				segment_match = true;
-			break;
-		}
-
-		if (segment_match) {
-			ret = wdsp_add_segment_to_list(dev, img_fname, phdr,
-						       phdr_idx, seg_list);
-			if (ret < 0) {
-				wdsp_flush_segment_list(seg_list);
-				goto bad_elf;
-			}
-		}
-		elf_ptr = elf_ptr + sizeof(*phdr);
-	}
-
-bad_elf:
-	release_firmware(fw);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(wdsp_get_segment_list);
diff --git a/sound/soc/codecs/wcd-dsp-utils.h b/sound/soc/codecs/wcd-dsp-utils.h
deleted file mode 100644
index a530a1c..0000000
--- a/sound/soc/codecs/wcd-dsp-utils.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_DSP_UTILS_H__
-#define __WCD_DSP_UTILS_H__
-
-#define WDSP_IMG_NAME_LEN_MAX    64
-
-#define WDSP_ELF_FLAG_EXECUTE    (1 << 0)
-#define WDSP_ELF_FLAG_WRITE      (1 << 1)
-#define WDSP_ELF_FLAG_READ       (1 << 2)
-
-#define WDSP_ELF_FLAG_RE (WDSP_ELF_FLAG_READ | WDSP_ELF_FLAG_EXECUTE)
-
-struct wdsp_img_segment {
-
-	/* Firmware for the slit image */
-	const struct firmware *split_fw;
-
-	/* Name of the split firmware file */
-	char split_fname[WDSP_IMG_NAME_LEN_MAX];
-
-	/* Address where the segment is to be loaded */
-	u32 load_addr;
-
-	/* Buffer to hold the data to be loaded */
-	u8 *data;
-
-	/* Size of the data to be loaded */
-	size_t size;
-
-	/* List node pointing to next segment */
-	struct list_head list;
-};
-
-int wdsp_get_segment_list(struct device *dev, const char *img_fname,
-			  unsigned int segment_type, struct list_head *seg_list,
-			  u32 *entry_point);
-void wdsp_flush_segment_list(struct list_head *seg_list);
-
-#endif /* __WCD_DSP_UTILS_H__ */
diff --git a/sound/soc/codecs/wcd-mbhc-adc.c b/sound/soc/codecs/wcd-mbhc-adc.c
deleted file mode 100644
index e44eec9..0000000
--- a/sound/soc/codecs/wcd-mbhc-adc.c
+++ /dev/null
@@ -1,1020 +0,0 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/list.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-#include <linux/kernel.h>
-#include <linux/input.h>
-#include <linux/firmware.h>
-#include <linux/completion.h>
-#include <sound/soc.h>
-#include <sound/jack.h>
-#include "wcd-mbhc-adc.h"
-#include "wcd-mbhc-v2.h"
-
-#define WCD_MBHC_ADC_HS_THRESHOLD_MV    1700
-#define WCD_MBHC_ADC_HPH_THRESHOLD_MV   75
-#define WCD_MBHC_ADC_MICBIAS_MV         1800
-
-static int wcd_mbhc_get_micbias(struct wcd_mbhc *mbhc)
-{
-	int micbias = 0;
-	u8 vout_ctl = 0;
-
-	/* Read MBHC Micbias (Mic Bias2) voltage */
-	WCD_MBHC_REG_READ(WCD_MBHC_MICB2_VOUT, vout_ctl);
-
-	/* Formula for getting micbias from vout
-	 * micbias = 1.0V + VOUT_CTL * 50mV
-	 */
-	micbias = 1000 + (vout_ctl * 50);
-	pr_debug("%s: vout_ctl: %d, micbias: %d\n",
-		 __func__, vout_ctl, micbias);
-
-	return micbias;
-}
-
-static int wcd_get_voltage_from_adc(u8 val, int micbias)
-{
-	/* Formula for calculating voltage from ADC
-	 * Voltage = ADC_RESULT*12.5mV*V_MICBIAS/1.8
-	 */
-	return ((val * 125 * micbias)/(WCD_MBHC_ADC_MICBIAS_MV * 10));
-}
-
-static int wcd_measure_adc_continuous(struct wcd_mbhc *mbhc)
-{
-	u8 adc_result = 0;
-	int output_mv = 0;
-	int retry = 3;
-	u8 adc_en = 0;
-
-	pr_debug("%s: enter\n", __func__);
-
-	/* Pre-requisites for ADC continuous measurement */
-	/* Read legacy electircal detection and disable */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0x00);
-	/* Set ADC to continuous measurement */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 1);
-	/* Read ADC Enable bit to restore after adc measurement */
-	WCD_MBHC_REG_READ(WCD_MBHC_ADC_EN, adc_en);
-	/* Disable ADC_ENABLE bit */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-	/* Disable MBHC FSM */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	/* Set the MUX selection to IN2P */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, MUX_CTL_IN2P);
-	/* Enable MBHC FSM */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	/* Enable ADC_ENABLE bit */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 1);
-
-	while (retry--) {
-		/* wait for 3 msec before reading ADC result */
-		usleep_range(3000, 3100);
-
-		/* Read ADC result */
-		WCD_MBHC_REG_READ(WCD_MBHC_ADC_RESULT, adc_result);
-	}
-
-	/* Restore ADC Enable */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, adc_en);
-	/* Get voltage from ADC result */
-	output_mv = wcd_get_voltage_from_adc(adc_result,
-					     wcd_mbhc_get_micbias(mbhc));
-	pr_debug("%s: adc_result: 0x%x, output_mv: %d\n",
-		 __func__, adc_result, output_mv);
-
-	return output_mv;
-}
-
-static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
-{
-	u8 adc_timeout = 0;
-	u8 adc_complete = 0;
-	u8 adc_result = 0;
-	int retry = 6;
-	int ret = 0;
-	int output_mv = 0;
-	u8 adc_en = 0;
-
-	pr_debug("%s: enter\n", __func__);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
-	/* Read ADC Enable bit to restore after adc measurement */
-	WCD_MBHC_REG_READ(WCD_MBHC_ADC_EN, adc_en);
-	/* Trigger ADC one time measurement */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	/* Set the appropriate MUX selection */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, mux_ctl);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 1);
-
-	while (retry--) {
-		/* wait for 600usec to get adc results */
-		usleep_range(600, 610);
-
-		/* check for ADC Timeout */
-		WCD_MBHC_REG_READ(WCD_MBHC_ADC_TIMEOUT, adc_timeout);
-		if (adc_timeout)
-			continue;
-
-		/* Read ADC complete bit */
-		WCD_MBHC_REG_READ(WCD_MBHC_ADC_COMPLETE, adc_complete);
-		if (!adc_complete)
-			continue;
-
-		/* Read ADC result */
-		WCD_MBHC_REG_READ(WCD_MBHC_ADC_RESULT, adc_result);
-
-		pr_debug("%s: ADC result: 0x%x\n", __func__, adc_result);
-		/* Get voltage from ADC result */
-		output_mv = wcd_get_voltage_from_adc(adc_result,
-						wcd_mbhc_get_micbias(mbhc));
-		break;
-	}
-
-	/* Restore ADC Enable */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, adc_en);
-
-	if (retry <= 0) {
-		pr_err("%s: adc complete: %d, adc timeout: %d\n",
-			__func__, adc_complete, adc_timeout);
-		ret = -EINVAL;
-	} else {
-		pr_debug("%s: adc complete: %d, adc timeout: %d output_mV: %d\n",
-			__func__, adc_complete, adc_timeout, output_mv);
-		ret = output_mv;
-	}
-
-	pr_debug("%s: leave\n", __func__);
-
-	return ret;
-}
-
-static bool wcd_mbhc_adc_detect_anc_plug_type(struct wcd_mbhc *mbhc)
-{
-	bool anc_mic_found = false;
-	u16 fsm_en = 0;
-	u8 det = 0;
-	unsigned long retry = 0;
-	int valid_plug_cnt = 0, invalid_plug_cnt = 0;
-	int ret = 0;
-	u8 elect_ctl = 0;
-	u8 adc_mode = 0;
-	u8 vref = 0;
-	int vref_mv[] = {1650, 1500, 1600, 1700};
-
-	if (mbhc->mbhc_cfg->anc_micbias < MIC_BIAS_1 ||
-	    mbhc->mbhc_cfg->anc_micbias > MIC_BIAS_4)
-		return false;
-
-	if (!mbhc->mbhc_cb->mbhc_micbias_control)
-		return false;
-
-	/* Disable Detection done for ADC operation */
-	WCD_MBHC_REG_READ(WCD_MBHC_DETECTION_DONE, det);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
-
-	/* Mask ADC COMPLETE interrupt */
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
-	mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
-					    mbhc->mbhc_cfg->anc_micbias,
-					    MICB_ENABLE);
-
-	/* Read legacy electircal detection and disable */
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0x00);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 1);
-	WCD_MBHC_REG_READ(WCD_MBHC_ADC_MODE, adc_mode);
-
-	/*
-	 * wait for button debounce time 20ms. If 4-pole plug is inserted
-	 * into 5-pole jack, then there will be a button press interrupt
-	 * during anc plug detection. In that case though Hs_comp_res is 0,
-	 * it should not be declared as ANC plug type
-	 */
-	usleep_range(20000, 20100);
-
-	/*
-	 * After enabling FSM, to handle slow insertion scenarios,
-	 * check IN3 voltage is below the Vref
-	 */
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_VREF, vref);
-
-	do {
-		if (wcd_swch_level_remove(mbhc)) {
-			pr_debug("%s: Switch level is low\n", __func__);
-			goto done;
-		}
-		pr_debug("%s: Retry attempt %lu\n", __func__, retry + 1);
-		ret = wcd_measure_adc_once(mbhc, MUX_CTL_IN3P);
-		/* TODO - check the logic */
-		if (ret && (ret < vref_mv[vref]))
-			valid_plug_cnt++;
-		else
-			invalid_plug_cnt++;
-		retry++;
-	} while (retry < ANC_DETECT_RETRY_CNT);
-
-	pr_debug("%s: valid: %d, invalid: %d\n", __func__, valid_plug_cnt,
-		 invalid_plug_cnt);
-
-	/* decision logic */
-	if (valid_plug_cnt > invalid_plug_cnt)
-		anc_mic_found = true;
-done:
-	/* Restore ADC mode */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, adc_mode);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	/* Set the MUX selection to AUTO */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, MUX_CTL_AUTO);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, fsm_en);
-	/* Restore detection done */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, det);
-
-	/* Restore electrical detection */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl);
-
-	mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
-					    mbhc->mbhc_cfg->anc_micbias,
-					    MICB_DISABLE);
-	pr_debug("%s: anc mic %sfound\n", __func__,
-		 anc_mic_found ? "" : "not ");
-
-	return anc_mic_found;
-}
-
-/* To determine if cross connection occurred */
-static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
-{
-	enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_NONE;
-	int hphl_adc_res = 0, hphr_adc_res = 0;
-	u8 fsm_en = 0;
-	int ret = 0;
-	u8 adc_mode = 0;
-	u8 elect_ctl = 0;
-	u8 adc_en = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	/* Check for button press and plug detection */
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low\n", __func__);
-		return -EINVAL;
-	}
-
-	/* If PA is enabled, dont check for cross-connection */
-	if (mbhc->mbhc_cb->hph_pa_on_status)
-		if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec))
-			return -EINVAL;
-
-	/* Read legacy electircal detection and disable */
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0x00);
-
-	/* Read and set ADC to single measurement */
-	WCD_MBHC_REG_READ(WCD_MBHC_ADC_MODE, adc_mode);
-	/* Read ADC Enable bit to restore after adc measurement */
-	WCD_MBHC_REG_READ(WCD_MBHC_ADC_EN, adc_en);
-	/* Read FSM status */
-	WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
-
-	/* Get adc result for HPH L */
-	hphl_adc_res = wcd_measure_adc_once(mbhc, MUX_CTL_HPH_L);
-	if (hphl_adc_res < 0) {
-		pr_err("%s: hphl_adc_res adc measurement failed\n", __func__);
-		ret = hphl_adc_res;
-		goto done;
-	}
-
-	/* Get adc result for HPH R in mV */
-	hphr_adc_res = wcd_measure_adc_once(mbhc, MUX_CTL_HPH_R);
-	if (hphr_adc_res < 0) {
-		pr_err("%s: hphr_adc_res adc measurement failed\n", __func__);
-		ret = hphr_adc_res;
-		goto done;
-	}
-
-	if (hphl_adc_res > 100 && hphr_adc_res > 100) {
-		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-		pr_debug("%s: Cross connection identified\n", __func__);
-	} else {
-		pr_debug("%s: No Cross connection found\n", __func__);
-	}
-
-done:
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	/* Set the MUX selection to Auto */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, MUX_CTL_AUTO);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-
-	/* Restore ADC Enable */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, adc_en);
-
-	/* Restore ADC mode */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, adc_mode);
-
-	/* Restore FSM state */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, fsm_en);
-
-	/* Restore electrical detection */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl);
-
-	pr_debug("%s: leave, plug type: %d\n", __func__,  plug_type);
-
-	return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? true : false;
-}
-
-static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc,
-					   int *spl_hs_cnt)
-{
-	bool spl_hs = false;
-	int output_mv = 0;
-	int adc_threshold = 0, adc_hph_threshold = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	if (!mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-		goto exit;
-
-	/* Bump up MB2 to 2.7V */
-	mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
-				mbhc->mbhc_cfg->mbhc_micbias, true);
-	usleep_range(10000, 10100);
-
-	/*
-	 * Use ADC single mode to minimize the chance of missing out
-	 * btn press/relesae for HEADSET type during correct work.
-	 */
-	output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P);
-	adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV *
-			  wcd_mbhc_get_micbias(mbhc))/WCD_MBHC_ADC_MICBIAS_MV);
-	adc_hph_threshold = ((WCD_MBHC_ADC_HPH_THRESHOLD_MV *
-			      wcd_mbhc_get_micbias(mbhc))/
-			      WCD_MBHC_ADC_MICBIAS_MV);
-
-	if (output_mv > adc_threshold || output_mv < adc_hph_threshold) {
-		spl_hs = false;
-	} else {
-		spl_hs = true;
-		if (spl_hs_cnt)
-			*spl_hs_cnt += 1;
-	}
-
-	/* MB2 back to 1.8v if the type is not special headset */
-	if (spl_hs_cnt && (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT)) {
-		mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
-				mbhc->mbhc_cfg->mbhc_micbias, false);
-		/* Add 10ms delay for micbias to settle */
-		usleep_range(10000, 10100);
-	}
-
-	if (spl_hs)
-		pr_debug("%s: Detected special HS (%d)\n", __func__, spl_hs);
-
-exit:
-	pr_debug("%s: leave\n", __func__);
-	return spl_hs;
-}
-
-static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
-{
-	int delay = 0;
-	bool ret = false;
-	bool is_spl_hs = false;
-	int output_mv = 0;
-	int adc_threshold = 0;
-
-	/*
-	 * Increase micbias to 2.7V to detect headsets with
-	 * threshold on microphone
-	 */
-	if (mbhc->mbhc_cb->mbhc_micbias_control &&
-	    !mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
-		pr_debug("%s: callback fn micb_ctrl_thr_mic not defined\n",
-			 __func__);
-		return false;
-	} else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
-		ret = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
-							MIC_BIAS_2, true);
-		if (ret) {
-			pr_err("%s: mbhc_micb_ctrl_thr_mic failed, ret: %d\n",
-				__func__, ret);
-			return false;
-		}
-	}
-
-	adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV *
-			  wcd_mbhc_get_micbias(mbhc)) /
-			  WCD_MBHC_ADC_MICBIAS_MV);
-
-	while (!is_spl_hs) {
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			break;
-		}
-		delay += 50;
-		/* Wait for 50ms for FSM to update result */
-		msleep(50);
-		output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P);
-		if (output_mv <= adc_threshold) {
-			pr_debug("%s: Special headset detected in %d msecs\n",
-					__func__, delay);
-			is_spl_hs = true;
-		}
-
-		if (delay == SPECIAL_HS_DETECT_TIME_MS) {
-			pr_debug("%s: Spl headset not found in 2 sec\n",
-				 __func__);
-			break;
-		}
-	}
-	if (is_spl_hs) {
-		pr_debug("%s: Headset with threshold found\n",  __func__);
-		mbhc->micbias_enable = true;
-		ret = true;
-	}
-	if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
-	    !mbhc->micbias_enable)
-		mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, MIC_BIAS_2,
-						      false);
-	pr_debug("%s: leave, micb_enable: %d\n", __func__,
-		  mbhc->micbias_enable);
-
-	return ret;
-}
-
-static void wcd_mbhc_adc_update_fsm_source(struct wcd_mbhc *mbhc,
-				       enum wcd_mbhc_plug_type plug_type)
-{
-	bool micbias2;
-
-	micbias2 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-							MIC_BIAS_2);
-	switch (plug_type) {
-	case MBHC_PLUG_TYPE_HEADPHONE:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		break;
-	case MBHC_PLUG_TYPE_HEADSET:
-	case MBHC_PLUG_TYPE_ANC_HEADPHONE:
-		if (!mbhc->is_hs_recording && !micbias2)
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		break;
-	default:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		break;
-
-	};
-}
-
-/* should be called under interrupt context that hold suspend */
-static void wcd_schedule_hs_detect_plug(struct wcd_mbhc *mbhc,
-					    struct work_struct *work)
-{
-	pr_debug("%s: scheduling correct_swch_plug\n", __func__);
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-	mbhc->hs_detect_work_stop = false;
-	mbhc->mbhc_cb->lock_sleep(mbhc, true);
-	schedule_work(work);
-}
-
-/* called under codec_resource_lock acquisition */
-static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc,
-					 struct work_struct *work)
-{
-	pr_debug("%s: Canceling correct_plug_swch\n", __func__);
-	mbhc->hs_detect_work_stop = true;
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	if (cancel_work_sync(work)) {
-		pr_debug("%s: correct_plug_swch is canceled\n",
-			 __func__);
-		mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	}
-	WCD_MBHC_RSC_LOCK(mbhc);
-}
-
-/* called under codec_resource_lock acquisition */
-static void wcd_mbhc_adc_detect_plug_type(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	pr_debug("%s: enter\n", __func__);
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	if (mbhc->mbhc_cb->hph_pull_down_ctrl)
-		mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
-
-	if (mbhc->mbhc_cb->mbhc_micbias_control) {
-		mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
-						    MICB_ENABLE);
-	} else {
-		pr_err("%s: Mic Bias is not enabled\n", __func__);
-		return;
-	}
-
-	/* Re-initialize button press completion object */
-	reinit_completion(&mbhc->btn_press_compl);
-	wcd_schedule_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
-	pr_debug("%s: leave\n", __func__);
-}
-
-static void wcd_micbias_disable(struct wcd_mbhc *mbhc)
-{
-	if (mbhc->micbias_enable) {
-		mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-			mbhc->codec, MIC_BIAS_2, false);
-		if (mbhc->mbhc_cb->set_micbias_value)
-			mbhc->mbhc_cb->set_micbias_value(
-					mbhc->codec);
-		mbhc->micbias_enable = false;
-	}
-}
-
-static int wcd_mbhc_get_plug_from_adc(int adc_result)
-
-{
-	enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID;
-
-	if (adc_result < WCD_MBHC_ADC_HPH_THRESHOLD_MV)
-		plug_type = MBHC_PLUG_TYPE_HEADPHONE;
-	else if (adc_result > WCD_MBHC_ADC_HS_THRESHOLD_MV)
-		plug_type = MBHC_PLUG_TYPE_HIGH_HPH;
-	else
-		plug_type = MBHC_PLUG_TYPE_HEADSET;
-	pr_debug("%s: plug type is %d found\n", __func__, plug_type);
-
-	return plug_type;
-}
-
-static void wcd_correct_swch_plug(struct work_struct *work)
-{
-	struct wcd_mbhc *mbhc;
-	struct snd_soc_codec *codec;
-	enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID;
-	unsigned long timeout;
-	bool wrk_complete = false;
-	int pt_gnd_mic_swap_cnt = 0;
-	int no_gnd_mic_swap_cnt = 0;
-	bool is_pa_on = false, spl_hs = false, spl_hs_reported = false;
-	int ret = 0;
-	int spl_hs_count = 0;
-	int output_mv = 0;
-	int cross_conn;
-	int try = 0;
-
-	pr_debug("%s: enter\n", __func__);
-
-	mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
-	codec = mbhc->codec;
-
-	WCD_MBHC_RSC_LOCK(mbhc);
-	/* Mask ADC COMPLETE interrupt */
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-
-	/* Check for cross connection */
-	do {
-		cross_conn = wcd_check_cross_conn(mbhc);
-		try++;
-	} while (try < GND_MIC_SWAP_THRESHOLD);
-
-	if (cross_conn > 0) {
-		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-		pr_debug("%s: cross connection found, Plug type %d\n",
-			 __func__, plug_type);
-		goto correct_plug_type;
-	}
-	/* Find plug type */
-	output_mv = wcd_measure_adc_continuous(mbhc);
-	plug_type = wcd_mbhc_get_plug_from_adc(output_mv);
-
-	/*
-	 * Report plug type if it is either headset or headphone
-	 * else start the 3 sec loop
-	 */
-	if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
-	     plug_type == MBHC_PLUG_TYPE_HEADPHONE) &&
-	    (!wcd_swch_level_remove(mbhc))) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		wcd_mbhc_find_plug_and_report(mbhc, plug_type);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-
-	/*
-	 * Set DETECTION_DONE bit for HEADSET and ANC_HEADPHONE,
-	 * so that btn press/release interrupt can be generated.
-	 */
-	if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET ||
-		mbhc->current_plug == MBHC_PLUG_TYPE_ANC_HEADPHONE) {
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 1);
-	}
-
-correct_plug_type:
-	timeout = jiffies + msecs_to_jiffies(HS_DETECT_PLUG_TIME_MS);
-	while (!time_after(jiffies, timeout)) {
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			wcd_micbias_disable(mbhc);
-			goto exit;
-		}
-
-		/* allow sometime and re-check stop requested again */
-		msleep(20);
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			wcd_micbias_disable(mbhc);
-			goto exit;
-		}
-
-		msleep(180);
-		/*
-		 * Use ADC single mode to minimize the chance of missing out
-		 * btn press/release for HEADSET type during correct work.
-		 */
-		output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P);
-
-		/*
-		 * instead of hogging system by contineous polling, wait for
-		 * sometime and re-check stop request again.
-		 */
-		plug_type = wcd_mbhc_get_plug_from_adc(output_mv);
-
-		if ((output_mv > WCD_MBHC_ADC_HS_THRESHOLD_MV) &&
-		    (spl_hs_count < WCD_MBHC_SPL_HS_CNT)) {
-			spl_hs = wcd_mbhc_adc_check_for_spl_headset(mbhc,
-								&spl_hs_count);
-
-			if (spl_hs_count == WCD_MBHC_SPL_HS_CNT) {
-				output_mv = WCD_MBHC_ADC_HS_THRESHOLD_MV;
-				spl_hs = true;
-				mbhc->micbias_enable = true;
-			}
-		}
-
-		if (mbhc->mbhc_cb->hph_pa_on_status)
-			is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec);
-
-		if ((output_mv <= WCD_MBHC_ADC_HS_THRESHOLD_MV) &&
-		    (!is_pa_on)) {
-			/* Check for cross connection*/
-			ret = wcd_check_cross_conn(mbhc);
-			if (ret < 0)
-				continue;
-			else if (ret > 0) {
-				pt_gnd_mic_swap_cnt++;
-				no_gnd_mic_swap_cnt = 0;
-				if (pt_gnd_mic_swap_cnt <
-						GND_MIC_SWAP_THRESHOLD) {
-					continue;
-				} else if (pt_gnd_mic_swap_cnt >
-					   GND_MIC_SWAP_THRESHOLD) {
-					/*
-					 * This is due to GND/MIC switch didn't
-					 * work,  Report unsupported plug.
-					 */
-					pr_debug("%s: switch did not work\n",
-						 __func__);
-					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-					goto report;
-				} else {
-					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-				}
-			} else {
-				no_gnd_mic_swap_cnt++;
-				pt_gnd_mic_swap_cnt = 0;
-				plug_type = wcd_mbhc_get_plug_from_adc(
-						output_mv);
-				if ((no_gnd_mic_swap_cnt <
-				    GND_MIC_SWAP_THRESHOLD) &&
-				    (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) {
-					continue;
-				} else {
-					no_gnd_mic_swap_cnt = 0;
-				}
-			}
-			if ((pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD) &&
-				(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
-				/*
-				 * if switch is toggled, check again,
-				 * otherwise report unsupported plug
-				 */
-				if (mbhc->mbhc_cfg->swap_gnd_mic &&
-					mbhc->mbhc_cfg->swap_gnd_mic(codec,
-					true)) {
-					pr_debug("%s: US_EU gpio present,flip switch\n"
-						, __func__);
-					continue;
-				}
-			}
-		}
-
-		if (output_mv > WCD_MBHC_ADC_HS_THRESHOLD_MV) {
-			pr_debug("%s: cable is extension cable\n", __func__);
-			plug_type = MBHC_PLUG_TYPE_HIGH_HPH;
-			wrk_complete = true;
-		} else {
-			pr_debug("%s: cable might be headset: %d\n", __func__,
-				 plug_type);
-			if (plug_type != MBHC_PLUG_TYPE_GND_MIC_SWAP) {
-				plug_type = wcd_mbhc_get_plug_from_adc(
-						output_mv);
-				if (!spl_hs_reported &&
-				    spl_hs_count == WCD_MBHC_SPL_HS_CNT) {
-					spl_hs_reported = true;
-					WCD_MBHC_RSC_LOCK(mbhc);
-					wcd_mbhc_find_plug_and_report(mbhc,
-								    plug_type);
-					WCD_MBHC_RSC_UNLOCK(mbhc);
-					continue;
-				} else if (spl_hs_reported)
-					continue;
-				/*
-				 * Report headset only if not already reported
-				 * and if there is not button press without
-				 * release
-				 */
-				if ((mbhc->current_plug !=
-				      MBHC_PLUG_TYPE_HEADSET) &&
-				     (mbhc->current_plug !=
-				     MBHC_PLUG_TYPE_ANC_HEADPHONE) &&
-				    !wcd_swch_level_remove(mbhc)) {
-					pr_debug("%s: cable is %s headset\n",
-						 __func__,
-						((spl_hs_count ==
-							WCD_MBHC_SPL_HS_CNT) ?
-							"special ":""));
-					goto report;
-				}
-			}
-			wrk_complete = false;
-		}
-	}
-	if (!wrk_complete) {
-		/*
-		 * If plug_tye is headset, we might have already reported either
-		 * in detect_plug-type or in above while loop, no need to report
-		 * again
-		 */
-		if ((plug_type == MBHC_PLUG_TYPE_HEADSET) ||
-		    (plug_type == MBHC_PLUG_TYPE_ANC_HEADPHONE)) {
-			pr_debug("%s: plug_type:0x%x already reported\n",
-				 __func__, mbhc->current_plug);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-			goto enable_supply;
-		}
-	}
-	if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH) {
-		if (wcd_is_special_headset(mbhc)) {
-			pr_debug("%s: Special headset found %d\n",
-					__func__, plug_type);
-			plug_type = MBHC_PLUG_TYPE_HEADSET;
-		} else {
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_ISRC_EN, 1);
-		}
-	}
-
-report:
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low\n", __func__);
-		goto exit;
-	}
-
-	pr_debug("%s: Valid plug found, plug type %d wrk_cmpt %d btn_intr %d\n",
-			__func__, plug_type, wrk_complete,
-			mbhc->btn_press_intr);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-
-	WCD_MBHC_RSC_LOCK(mbhc);
-	wcd_mbhc_find_plug_and_report(mbhc, plug_type);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-enable_supply:
-	/*
-	 * Set DETECTION_DONE bit for HEADSET and ANC_HEADPHONE,
-	 * so that btn press/release interrupt can be generated.
-	 * For other plug type, clear the bit.
-	 */
-	if (plug_type == MBHC_PLUG_TYPE_HEADSET ||
-	    plug_type == MBHC_PLUG_TYPE_ANC_HEADPHONE)
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 1);
-	else
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
-
-	if (mbhc->mbhc_cb->mbhc_micbias_control)
-		wcd_mbhc_adc_update_fsm_source(mbhc, plug_type);
-exit:
-	if (mbhc->mbhc_cb->mbhc_micbias_control &&
-	    !mbhc->micbias_enable)
-		mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
-						    MICB_DISABLE);
-
-	/*
-	 * If plug type is corrected from special headset to headphone,
-	 * clear the micbias enable flag, set micbias back to 1.8V and
-	 * disable micbias.
-	 */
-	if (plug_type == MBHC_PLUG_TYPE_HEADPHONE &&
-	    mbhc->micbias_enable) {
-		if (mbhc->mbhc_cb->mbhc_micbias_control)
-			mbhc->mbhc_cb->mbhc_micbias_control(
-					codec, MIC_BIAS_2,
-					MICB_DISABLE);
-		if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-			mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-					codec,
-					MIC_BIAS_2, false);
-		if (mbhc->mbhc_cb->set_micbias_value) {
-			mbhc->mbhc_cb->set_micbias_value(codec);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
-		}
-		mbhc->micbias_enable = false;
-	}
-
-	if (mbhc->mbhc_cfg->detect_extn_cable &&
-	    ((plug_type == MBHC_PLUG_TYPE_HEADPHONE) ||
-	     (plug_type == MBHC_PLUG_TYPE_HEADSET)) &&
-	    !mbhc->hs_detect_work_stop) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM, true);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-
-	/*
-	 * Enable ADC COMPLETE interrupt for HEADPHONE.
-	 * Btn release may happen after the correct work, ADC COMPLETE
-	 * interrupt needs to be captured to correct plug type.
-	 */
-	if (plug_type == MBHC_PLUG_TYPE_HEADPHONE) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS,
-				     true);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-
-	if (mbhc->mbhc_cb->hph_pull_down_ctrl)
-		mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true);
-
-	mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	pr_debug("%s: leave\n", __func__);
-}
-
-static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	unsigned long timeout;
-	int adc_threshold, output_mv, retry = 0;
-
-	pr_debug("%s: enter\n", __func__);
-	WCD_MBHC_RSC_LOCK(mbhc);
-
-	timeout = jiffies +
-		  msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS);
-	adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV *
-			  wcd_mbhc_get_micbias(mbhc)) /
-			  WCD_MBHC_ADC_MICBIAS_MV);
-	do {
-		retry++;
-		/*
-		 * read output_mv every 10ms to look for
-		 * any change in IN2_P
-		 */
-		usleep_range(10000, 10100);
-		output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P);
-
-		pr_debug("%s: Check for fake removal: output_mv %d\n",
-			 __func__, output_mv);
-		if ((output_mv <= adc_threshold) &&
-		    retry > FAKE_REM_RETRY_ATTEMPTS) {
-			pr_debug("%s: headset is NOT actually removed\n",
-				 __func__);
-			goto exit;
-		}
-	} while (!time_after(jiffies, timeout));
-
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low ", __func__);
-		goto exit;
-	}
-
-	/*
-	 * ADC COMPLETE and ELEC_REM interrupts are both enabled for HEADPHONE,
-	 * need to reject the ADC COMPLETE interrupt which follows ELEC_REM one
-	 * when HEADPHONE is removed.
-	 */
-	if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
-		mbhc->extn_cable_hph_rem = true;
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
-	wcd_mbhc_elec_hs_report_unplug(mbhc);
-exit:
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_mbhc_adc_hs_ins_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-
-	pr_debug("%s: enter\n", __func__);
-
-	/*
-	 * ADC COMPLETE and ELEC_REM interrupts are both enabled for HEADPHONE,
-	 * need to reject the ADC COMPLETE interrupt which follows ELEC_REM one
-	 * when HEADPHONE is removed.
-	 */
-	if (mbhc->extn_cable_hph_rem == true) {
-		mbhc->extn_cable_hph_rem = false;
-		pr_debug("%s: leave\n", __func__);
-		return IRQ_HANDLED;
-	}
-
-	WCD_MBHC_RSC_LOCK(mbhc);
-	/*
-	 * If current plug is headphone then there is no chance to
-	 * get ADC complete interrupt, so connected cable should be
-	 * headset not headphone.
-	 */
-	if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE) {
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 1);
-		wcd_mbhc_find_plug_and_report(mbhc, MBHC_PLUG_TYPE_HEADSET);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-		return IRQ_HANDLED;
-	}
-
-	if (!mbhc->mbhc_cfg->detect_extn_cable) {
-		pr_debug("%s: Returning as Extension cable feature not enabled\n",
-			__func__);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-		return IRQ_HANDLED;
-	}
-
-	pr_debug("%s: Disable electrical headset insertion interrupt\n",
-		 __func__);
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_ISRC_EN, 0);
-	mbhc->is_extn_cable = true;
-	mbhc->btn_press_intr = false;
-	wcd_mbhc_adc_detect_plug_type(mbhc);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-}
-
-static struct wcd_mbhc_fn mbhc_fn = {
-	.wcd_mbhc_hs_ins_irq = wcd_mbhc_adc_hs_ins_irq,
-	.wcd_mbhc_hs_rem_irq = wcd_mbhc_adc_hs_rem_irq,
-	.wcd_mbhc_detect_plug_type = wcd_mbhc_adc_detect_plug_type,
-	.wcd_mbhc_detect_anc_plug_type = wcd_mbhc_adc_detect_anc_plug_type,
-	.wcd_cancel_hs_detect_plug = wcd_cancel_hs_detect_plug,
-};
-
-/* Function: wcd_mbhc_adc_init
- * @mbhc: MBHC function pointer
- * Description: Initialize MBHC ADC related function pointers to MBHC structure
- */
-void wcd_mbhc_adc_init(struct wcd_mbhc *mbhc)
-{
-	if (!mbhc) {
-		pr_err("%s: mbhc is NULL\n", __func__);
-		return;
-	}
-	mbhc->mbhc_fn = &mbhc_fn;
-	INIT_WORK(&mbhc->correct_plug_swch, wcd_correct_swch_plug);
-}
-EXPORT_SYMBOL(wcd_mbhc_adc_init);
diff --git a/sound/soc/codecs/wcd-mbhc-adc.h b/sound/soc/codecs/wcd-mbhc-adc.h
deleted file mode 100644
index 3116108..0000000
--- a/sound/soc/codecs/wcd-mbhc-adc.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_MBHC_ADC_H__
-#define __WCD_MBHC_ADC_H__
-
-#include "wcd-mbhc-v2.h"
-
-enum wcd_mbhc_adc_mux_ctl {
-	MUX_CTL_AUTO = 0,
-	MUX_CTL_IN2P,
-	MUX_CTL_IN3P,
-	MUX_CTL_IN4P,
-	MUX_CTL_HPH_L,
-	MUX_CTL_HPH_R,
-	MUX_CTL_NONE,
-};
-
-#if IS_ENABLED(CONFIG_SND_SOC_WCD_MBHC_ADC)
-void wcd_mbhc_adc_init(struct wcd_mbhc *mbhc);
-#else
-static inline void wcd_mbhc_adc_init(struct wcd_mbhc *mbhc)
-{
-
-}
-#endif
-#endif /* __WCD_MBHC_ADC_H__ */
diff --git a/sound/soc/codecs/wcd-mbhc-legacy.c b/sound/soc/codecs/wcd-mbhc-legacy.c
deleted file mode 100644
index 745e2e8..0000000
--- a/sound/soc/codecs/wcd-mbhc-legacy.c
+++ /dev/null
@@ -1,975 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/list.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-#include <linux/kernel.h>
-#include <linux/input.h>
-#include <linux/firmware.h>
-#include <linux/completion.h>
-#include <sound/soc.h>
-#include <sound/jack.h>
-#include "wcd-mbhc-legacy.h"
-#include "wcd-mbhc-v2.h"
-
-static int det_extn_cable_en;
-module_param(det_extn_cable_en, int, 0664);
-MODULE_PARM_DESC(det_extn_cable_en, "enable/disable extn cable detect");
-
-static bool wcd_mbhc_detect_anc_plug_type(struct wcd_mbhc *mbhc)
-{
-	bool anc_mic_found = false;
-	u16 val, hs_comp_res, btn_status = 0;
-	unsigned long retry = 0;
-	int valid_plug_cnt = 0, invalid_plug_cnt = 0;
-	int btn_status_cnt = 0;
-	bool is_check_btn_press = false;
-
-
-	if (mbhc->mbhc_cfg->anc_micbias < MIC_BIAS_1 ||
-	    mbhc->mbhc_cfg->anc_micbias > MIC_BIAS_4)
-		return false;
-
-	if (!mbhc->mbhc_cb->mbhc_micbias_control)
-		return false;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, val);
-
-	if (val)
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-
-	mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
-					    mbhc->mbhc_cfg->anc_micbias,
-					    MICB_ENABLE);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x2);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 1);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	/*
-	 * wait for button debounce time 20ms. If 4-pole plug is inserted
-	 * into 5-pole jack, then there will be a button press interrupt
-	 * during anc plug detection. In that case though Hs_comp_res is 0,
-	 * it should not be declared as ANC plug type
-	 */
-	usleep_range(20000, 20100);
-
-	/*
-	 * After enabling FSM, to handle slow insertion scenarios,
-	 * check hs_comp_result for few times to see if the IN3 voltage
-	 * is below the Vref
-	 */
-	do {
-		if (wcd_swch_level_remove(mbhc)) {
-			pr_debug("%s: Switch level is low\n", __func__);
-			goto exit;
-		}
-		pr_debug("%s: Retry attempt %lu\n", __func__, retry + 1);
-		WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
-
-		if (!hs_comp_res) {
-			valid_plug_cnt++;
-			is_check_btn_press = true;
-		} else
-			invalid_plug_cnt++;
-		/* Wait 1ms before taking another reading */
-		usleep_range(1000, 1100);
-
-		WCD_MBHC_REG_READ(WCD_MBHC_FSM_STATUS, btn_status);
-		if (btn_status)
-			btn_status_cnt++;
-
-		retry++;
-	} while (retry < ANC_DETECT_RETRY_CNT);
-
-	pr_debug("%s: valid: %d, invalid: %d, btn_status_cnt: %d\n",
-		 __func__, valid_plug_cnt, invalid_plug_cnt, btn_status_cnt);
-
-	/* decision logic */
-	if ((valid_plug_cnt > invalid_plug_cnt) && is_check_btn_press &&
-	    (btn_status_cnt == 0))
-		anc_mic_found = true;
-exit:
-	if (!val)
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 0);
-
-	mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
-					    mbhc->mbhc_cfg->anc_micbias,
-					    MICB_DISABLE);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x0);
-	pr_debug("%s: anc mic %sfound\n", __func__,
-		 anc_mic_found ? "" : "not ");
-	return anc_mic_found;
-}
-
-/* To determine if cross connection occurred */
-static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
-{
-	u16 swap_res = 0;
-	enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_NONE;
-	s16 reg1 = 0;
-	bool hphl_sch_res = 0, hphr_sch_res = 0;
-
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low\n", __func__);
-		return -EINVAL;
-	}
-
-	/* If PA is enabled, dont check for cross-connection */
-	if (mbhc->mbhc_cb->hph_pa_on_status)
-		if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec))
-			return false;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_SCHMT_ISRC, reg1);
-	/*
-	 * Check if there is any cross connection,
-	 * Micbias and schmitt trigger (HPHL-HPHR)
-	 * needs to be enabled. For some codecs like wcd9335,
-	 * pull-up will already be enabled when this function
-	 * is called for cross-connection identification. No
-	 * need to enable micbias in that case.
-	 */
-	wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 2);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_RESULT, swap_res);
-	pr_debug("%s: swap_res%x\n", __func__, swap_res);
-
-	/*
-	 * Read reg hphl and hphr schmitt result with cross connection
-	 * bit. These bits will both be "0" in case of cross connection
-	 * otherwise, they stay at 1
-	 */
-	WCD_MBHC_REG_READ(WCD_MBHC_HPHL_SCHMT_RESULT, hphl_sch_res);
-	WCD_MBHC_REG_READ(WCD_MBHC_HPHR_SCHMT_RESULT, hphr_sch_res);
-	if (!(hphl_sch_res || hphr_sch_res)) {
-		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-		pr_debug("%s: Cross connection identified\n", __func__);
-	} else {
-		pr_debug("%s: No Cross connection found\n", __func__);
-	}
-
-	/* Disable schmitt trigger and restore micbias */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, reg1);
-	pr_debug("%s: leave, plug type: %d\n", __func__,  plug_type);
-
-	return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? true : false;
-}
-
-static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	int delay = 0, rc;
-	bool ret = false;
-	u16 hs_comp_res;
-	bool is_spl_hs = false;
-
-	/*
-	 * Increase micbias to 2.7V to detect headsets with
-	 * threshold on microphone
-	 */
-	if (mbhc->mbhc_cb->mbhc_micbias_control &&
-	    !mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
-		pr_debug("%s: callback fn micb_ctrl_thr_mic not defined\n",
-			 __func__);
-		return false;
-	} else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
-		rc = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec,
-							MIC_BIAS_2, true);
-		if (rc) {
-			pr_err("%s: Micbias control for thr mic failed, rc: %d\n",
-				__func__, rc);
-			return false;
-		}
-	}
-
-	wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-
-	pr_debug("%s: special headset, start register writes\n", __func__);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
-	while (!is_spl_hs)  {
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			break;
-		}
-		delay = delay + 50;
-		if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) {
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_PRECHARGE,
-					true);
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_SET_VAL,
-					true);
-		}
-		/* Wait for 50msec for MICBIAS to settle down */
-		msleep(50);
-		if (mbhc->mbhc_cb->set_auto_zeroing)
-			mbhc->mbhc_cb->set_auto_zeroing(codec, true);
-		/* Wait for 50msec for FSM to update result values */
-		msleep(50);
-		WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
-		if (!(hs_comp_res)) {
-			pr_debug("%s: Special headset detected in %d msecs\n",
-					__func__, (delay * 2));
-			is_spl_hs = true;
-		}
-		if (delay == SPECIAL_HS_DETECT_TIME_MS) {
-			pr_debug("%s: Spl headset didn't get detect in 4 sec\n",
-					__func__);
-			break;
-		}
-	}
-	if (is_spl_hs) {
-		pr_debug("%s: Headset with threshold found\n",  __func__);
-		mbhc->micbias_enable = true;
-		ret = true;
-	}
-	if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
-		mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-				MBHC_COMMON_MICB_PRECHARGE,
-				false);
-	if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable)
-		mbhc->mbhc_cb->set_micbias_value(codec);
-	if (mbhc->mbhc_cb->set_auto_zeroing)
-		mbhc->mbhc_cb->set_auto_zeroing(codec, false);
-
-	if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
-	    !mbhc->micbias_enable)
-		mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec, MIC_BIAS_2,
-						      false);
-
-	pr_debug("%s: leave, micb_enable: %d\n", __func__,
-		  mbhc->micbias_enable);
-	return ret;
-}
-
-static void wcd_mbhc_update_fsm_source(struct wcd_mbhc *mbhc,
-				       enum wcd_mbhc_plug_type plug_type)
-{
-	bool micbias2;
-
-	micbias2 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-							MIC_BIAS_2);
-	switch (plug_type) {
-	case MBHC_PLUG_TYPE_HEADPHONE:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		break;
-	case MBHC_PLUG_TYPE_HEADSET:
-	case MBHC_PLUG_TYPE_ANC_HEADPHONE:
-		if (!mbhc->is_hs_recording && !micbias2)
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		break;
-	default:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		break;
-
-	};
-}
-
-static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc,
-			enum wcd_mbhc_plug_type plug_type)
-{
-
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	/*
-	 * Do not disable micbias if recording is going on or
-	 * headset is inserted on the other side of the extn
-	 * cable. If headset has been detected current source
-	 * needs to be kept enabled for button detection to work.
-	 * If the accessory type is invalid or unsupported, we
-	 * dont need to enable either of them.
-	 */
-	if (det_extn_cable_en && mbhc->is_extn_cable &&
-		mbhc->mbhc_cb && mbhc->mbhc_cb->extn_use_mb &&
-		mbhc->mbhc_cb->extn_use_mb(codec)) {
-		if (plug_type == MBHC_PLUG_TYPE_HEADPHONE ||
-		    plug_type == MBHC_PLUG_TYPE_HEADSET)
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-	} else {
-		if (plug_type == MBHC_PLUG_TYPE_HEADSET) {
-			if (mbhc->is_hs_recording || mbhc->micbias_enable) {
-				wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-			} else if ((test_bit(WCD_MBHC_EVENT_PA_HPHL,
-					     &mbhc->event_state)) ||
-				   (test_bit(WCD_MBHC_EVENT_PA_HPHR,
-					     &mbhc->event_state))) {
-				wcd_enable_curr_micbias(mbhc,
-						WCD_MBHC_EN_PULLUP);
-			} else {
-				wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
-			}
-		} else if (plug_type == MBHC_PLUG_TYPE_HEADPHONE) {
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
-		} else {
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_NONE);
-		}
-	}
-}
-
-static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc,
-					   int *spl_hs_cnt)
-{
-	u16 hs_comp_res_1_8v = 0, hs_comp_res_2_7v = 0;
-	bool spl_hs = false;
-
-	if (!mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-		goto done;
-
-	if (!spl_hs_cnt) {
-		pr_err("%s: spl_hs_cnt is NULL\n", __func__);
-		goto done;
-	}
-	/* Read back hs_comp_res @ 1.8v Micbias */
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res_1_8v);
-	if (!hs_comp_res_1_8v) {
-		spl_hs = false;
-		goto done;
-	}
-
-	/* Bump up MB2 to 2.7v */
-	mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
-				mbhc->mbhc_cfg->mbhc_micbias, true);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	usleep_range(10000, 10100);
-
-	/* Read back HS_COMP_RESULT */
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res_2_7v);
-	if (!hs_comp_res_2_7v && hs_comp_res_1_8v)
-		spl_hs = true;
-
-	if (spl_hs)
-		*spl_hs_cnt += 1;
-
-	/* MB2 back to 1.8v */
-	if (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT) {
-		mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
-				mbhc->mbhc_cfg->mbhc_micbias, false);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-		usleep_range(10000, 10100);
-	}
-
-	if (spl_hs)
-		pr_debug("%s: Detected special HS (%d)\n", __func__, spl_hs);
-
-done:
-	return spl_hs;
-}
-
-/* should be called under interrupt context that hold suspend */
-static void wcd_schedule_hs_detect_plug(struct wcd_mbhc *mbhc,
-					    struct work_struct *work)
-{
-	pr_debug("%s: scheduling correct_swch_plug\n", __func__);
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-	mbhc->hs_detect_work_stop = false;
-	mbhc->mbhc_cb->lock_sleep(mbhc, true);
-	schedule_work(work);
-}
-
-/* called under codec_resource_lock acquisition */
-static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc,
-					 struct work_struct *work)
-{
-	pr_debug("%s: Canceling correct_plug_swch\n", __func__);
-	mbhc->hs_detect_work_stop = true;
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	if (cancel_work_sync(work)) {
-		pr_debug("%s: correct_plug_swch is canceled\n",
-			 __func__);
-		mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	}
-	WCD_MBHC_RSC_LOCK(mbhc);
-}
-
-/* called under codec_resource_lock acquisition */
-static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	bool micbias1 = false;
-
-	pr_debug("%s: enter\n", __func__);
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	if (mbhc->mbhc_cb->hph_pull_down_ctrl)
-		mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false);
-
-	if (mbhc->mbhc_cb->micbias_enable_status)
-		micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-								MIC_BIAS_1);
-
-	if (mbhc->mbhc_cb->set_cap_mode)
-		mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true);
-
-	if (mbhc->mbhc_cb->mbhc_micbias_control)
-		mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
-						    MICB_ENABLE);
-	else
-		wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-
-	/* Re-initialize button press completion object */
-	reinit_completion(&mbhc->btn_press_compl);
-	wcd_schedule_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
-	pr_debug("%s: leave\n", __func__);
-}
-
-static void wcd_correct_swch_plug(struct work_struct *work)
-{
-	struct wcd_mbhc *mbhc;
-	struct snd_soc_codec *codec;
-	enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID;
-	unsigned long timeout;
-	u16 hs_comp_res = 0, hphl_sch = 0, mic_sch = 0, btn_result = 0;
-	bool wrk_complete = false;
-	int pt_gnd_mic_swap_cnt = 0;
-	int no_gnd_mic_swap_cnt = 0;
-	bool is_pa_on = false, spl_hs = false, spl_hs_reported = false;
-	bool micbias2 = false;
-	bool micbias1 = false;
-	int ret = 0;
-	int rc, spl_hs_count = 0;
-	int cross_conn;
-	int try = 0;
-
-	pr_debug("%s: enter\n", __func__);
-
-	mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
-	codec = mbhc->codec;
-
-	/*
-	 * Enable micbias/pullup for detection in correct work.
-	 * This work will get scheduled from detect_plug_type which
-	 * will already request for pullup/micbias. If the pullup/micbias
-	 * is handled with ref-counts by individual codec drivers, there is
-	 * no need to enabale micbias/pullup here
-	 */
-
-	wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-
-	/* Enable HW FSM */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-	/*
-	 * Check for any button press interrupts before starting 3-sec
-	 * loop.
-	 */
-	rc = wait_for_completion_timeout(&mbhc->btn_press_compl,
-			msecs_to_jiffies(WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS));
-
-	WCD_MBHC_REG_READ(WCD_MBHC_BTN_RESULT, btn_result);
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
-
-	if (!rc) {
-		pr_debug("%s No btn press interrupt\n", __func__);
-		if (!btn_result && !hs_comp_res)
-			plug_type = MBHC_PLUG_TYPE_HEADSET;
-		else if (!btn_result && hs_comp_res)
-			plug_type = MBHC_PLUG_TYPE_HIGH_HPH;
-		else
-			plug_type = MBHC_PLUG_TYPE_INVALID;
-	} else {
-		if (!btn_result && !hs_comp_res)
-			plug_type = MBHC_PLUG_TYPE_HEADPHONE;
-		else
-			plug_type = MBHC_PLUG_TYPE_INVALID;
-	}
-
-	do {
-		cross_conn = wcd_check_cross_conn(mbhc);
-		try++;
-	} while (try < GND_MIC_SWAP_THRESHOLD);
-
-	/*
-	 * Check for cross connection 4 times.
-	 * Consider the result of the fourth iteration.
-	 */
-	if (cross_conn > 0) {
-		pr_debug("%s: cross con found, start polling\n",
-			 __func__);
-		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-		pr_debug("%s: Plug found, plug type is %d\n",
-			 __func__, plug_type);
-		goto correct_plug_type;
-	}
-
-	if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
-	     plug_type == MBHC_PLUG_TYPE_HEADPHONE) &&
-	    (!wcd_swch_level_remove(mbhc))) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		if (mbhc->current_plug ==  MBHC_PLUG_TYPE_HIGH_HPH)
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE,
-						 0);
-		wcd_mbhc_find_plug_and_report(mbhc, plug_type);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-
-correct_plug_type:
-
-	timeout = jiffies + msecs_to_jiffies(HS_DETECT_PLUG_TIME_MS);
-	while (!time_after(jiffies, timeout)) {
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			wcd_enable_curr_micbias(mbhc,
-						WCD_MBHC_EN_NONE);
-			if (mbhc->micbias_enable) {
-				mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-					mbhc->codec, MIC_BIAS_2, false);
-				if (mbhc->mbhc_cb->set_micbias_value)
-					mbhc->mbhc_cb->set_micbias_value(
-							mbhc->codec);
-				mbhc->micbias_enable = false;
-			}
-			goto exit;
-		}
-		if (mbhc->btn_press_intr) {
-			wcd_cancel_btn_work(mbhc);
-			mbhc->btn_press_intr = false;
-		}
-		/* Toggle FSM */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-
-		/* allow sometime and re-check stop requested again */
-		msleep(20);
-		if (mbhc->hs_detect_work_stop) {
-			pr_debug("%s: stop requested: %d\n", __func__,
-					mbhc->hs_detect_work_stop);
-			wcd_enable_curr_micbias(mbhc,
-						WCD_MBHC_EN_NONE);
-			if (mbhc->micbias_enable) {
-				mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-					mbhc->codec, MIC_BIAS_2, false);
-				if (mbhc->mbhc_cb->set_micbias_value)
-					mbhc->mbhc_cb->set_micbias_value(
-							mbhc->codec);
-				mbhc->micbias_enable = false;
-			}
-			goto exit;
-		}
-		WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
-
-		pr_debug("%s: hs_comp_res: %x\n", __func__, hs_comp_res);
-		if (mbhc->mbhc_cb->hph_pa_on_status)
-			is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec);
-
-		/*
-		 * instead of hogging system by contineous polling, wait for
-		 * sometime and re-check stop request again.
-		 */
-		msleep(180);
-		if (hs_comp_res && (spl_hs_count < WCD_MBHC_SPL_HS_CNT)) {
-			spl_hs = wcd_mbhc_check_for_spl_headset(mbhc,
-								&spl_hs_count);
-
-			if (spl_hs_count == WCD_MBHC_SPL_HS_CNT) {
-				hs_comp_res = 0;
-				spl_hs = true;
-				mbhc->micbias_enable = true;
-			}
-		}
-
-		if ((!hs_comp_res) && (!is_pa_on)) {
-			/* Check for cross connection*/
-			ret = wcd_check_cross_conn(mbhc);
-			if (ret < 0) {
-				continue;
-			} else if (ret > 0) {
-				pt_gnd_mic_swap_cnt++;
-				no_gnd_mic_swap_cnt = 0;
-				if (pt_gnd_mic_swap_cnt <
-						GND_MIC_SWAP_THRESHOLD) {
-					continue;
-				} else if (pt_gnd_mic_swap_cnt >
-						GND_MIC_SWAP_THRESHOLD) {
-					/*
-					 * This is due to GND/MIC switch didn't
-					 * work,  Report unsupported plug.
-					 */
-					pr_debug("%s: switch didn't work\n",
-						  __func__);
-					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-					goto report;
-				} else {
-					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-				}
-			} else {
-				no_gnd_mic_swap_cnt++;
-				pt_gnd_mic_swap_cnt = 0;
-				plug_type = MBHC_PLUG_TYPE_HEADSET;
-				if ((no_gnd_mic_swap_cnt <
-				    GND_MIC_SWAP_THRESHOLD) &&
-				    (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) {
-					continue;
-				} else {
-					no_gnd_mic_swap_cnt = 0;
-				}
-			}
-			if ((pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD) &&
-				(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
-				/*
-				 * if switch is toggled, check again,
-				 * otherwise report unsupported plug
-				 */
-				if (mbhc->mbhc_cfg->swap_gnd_mic &&
-					mbhc->mbhc_cfg->swap_gnd_mic(codec,
-					true)) {
-					pr_debug("%s: US_EU gpio present,flip switch\n"
-						, __func__);
-					continue;
-				}
-			}
-		}
-
-		WCD_MBHC_REG_READ(WCD_MBHC_HPHL_SCHMT_RESULT, hphl_sch);
-		WCD_MBHC_REG_READ(WCD_MBHC_MIC_SCHMT_RESULT, mic_sch);
-		if (hs_comp_res && !(hphl_sch || mic_sch)) {
-			pr_debug("%s: cable is extension cable\n", __func__);
-			plug_type = MBHC_PLUG_TYPE_HIGH_HPH;
-			wrk_complete = true;
-		} else {
-			pr_debug("%s: cable might be headset: %d\n", __func__,
-					plug_type);
-			if (!(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
-				plug_type = MBHC_PLUG_TYPE_HEADSET;
-				if (!spl_hs_reported &&
-				    spl_hs_count == WCD_MBHC_SPL_HS_CNT) {
-					spl_hs_reported = true;
-					WCD_MBHC_RSC_LOCK(mbhc);
-					wcd_mbhc_find_plug_and_report(mbhc,
-								    plug_type);
-					WCD_MBHC_RSC_UNLOCK(mbhc);
-					continue;
-				} else if (spl_hs_reported)
-					continue;
-				/*
-				 * Report headset only if not already reported
-				 * and if there is not button press without
-				 * release
-				 */
-				if (((mbhc->current_plug !=
-				      MBHC_PLUG_TYPE_HEADSET) &&
-				     (mbhc->current_plug !=
-				      MBHC_PLUG_TYPE_ANC_HEADPHONE)) &&
-				    !wcd_swch_level_remove(mbhc) &&
-				    !mbhc->btn_press_intr) {
-					pr_debug("%s: cable is %sheadset\n",
-						__func__,
-						((spl_hs_count ==
-							WCD_MBHC_SPL_HS_CNT) ?
-							"special ":""));
-					goto report;
-				}
-			}
-			wrk_complete = false;
-		}
-	}
-	if (!wrk_complete && mbhc->btn_press_intr) {
-		pr_debug("%s: Can be slow insertion of headphone\n", __func__);
-		wcd_cancel_btn_work(mbhc);
-		plug_type = MBHC_PLUG_TYPE_HEADPHONE;
-	}
-	/*
-	 * If plug_tye is headset, we might have already reported either in
-	 * detect_plug-type or in above while loop, no need to report again
-	 */
-	if (!wrk_complete && ((plug_type == MBHC_PLUG_TYPE_HEADSET) ||
-	    (plug_type == MBHC_PLUG_TYPE_ANC_HEADPHONE))) {
-		pr_debug("%s: plug_type:0x%x already reported\n",
-			 __func__, mbhc->current_plug);
-		goto enable_supply;
-	}
-
-	if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH &&
-		(!det_extn_cable_en)) {
-		if (wcd_is_special_headset(mbhc)) {
-			pr_debug("%s: Special headset found %d\n",
-					__func__, plug_type);
-			plug_type = MBHC_PLUG_TYPE_HEADSET;
-			goto report;
-		}
-	}
-
-report:
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low\n", __func__);
-		goto exit;
-	}
-	if (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP && mbhc->btn_press_intr) {
-		pr_debug("%s: insertion of headphone with swap\n", __func__);
-		wcd_cancel_btn_work(mbhc);
-		plug_type = MBHC_PLUG_TYPE_HEADPHONE;
-	}
-	pr_debug("%s: Valid plug found, plug type %d wrk_cmpt %d btn_intr %d\n",
-			__func__, plug_type, wrk_complete,
-			mbhc->btn_press_intr);
-	WCD_MBHC_RSC_LOCK(mbhc);
-	wcd_mbhc_find_plug_and_report(mbhc, plug_type);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-enable_supply:
-	if (mbhc->mbhc_cb->mbhc_micbias_control)
-		wcd_mbhc_update_fsm_source(mbhc, plug_type);
-	else
-		wcd_enable_mbhc_supply(mbhc, plug_type);
-exit:
-	if (mbhc->mbhc_cb->mbhc_micbias_control &&
-	    !mbhc->micbias_enable)
-		mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
-						    MICB_DISABLE);
-
-	/*
-	 * If plug type is corrected from special headset to headphone,
-	 * clear the micbias enable flag, set micbias back to 1.8V and
-	 * disable micbias.
-	 */
-	if (plug_type == MBHC_PLUG_TYPE_HEADPHONE &&
-	    mbhc->micbias_enable) {
-		if (mbhc->mbhc_cb->mbhc_micbias_control)
-			mbhc->mbhc_cb->mbhc_micbias_control(
-					codec, MIC_BIAS_2,
-					MICB_DISABLE);
-		if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-			mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-					codec,
-					MIC_BIAS_2, false);
-		if (mbhc->mbhc_cb->set_micbias_value) {
-			mbhc->mbhc_cb->set_micbias_value(codec);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
-		}
-		mbhc->micbias_enable = false;
-	}
-
-	if (mbhc->mbhc_cb->micbias_enable_status) {
-		micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-								MIC_BIAS_1);
-		micbias2 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-								MIC_BIAS_2);
-	}
-
-	if (mbhc->mbhc_cfg->detect_extn_cable &&
-	    ((plug_type == MBHC_PLUG_TYPE_HEADPHONE) ||
-	     (plug_type == MBHC_PLUG_TYPE_HEADSET)) &&
-	    !mbhc->hs_detect_work_stop) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM, true);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-	if (mbhc->mbhc_cb->set_cap_mode)
-		mbhc->mbhc_cb->set_cap_mode(codec, micbias1, micbias2);
-
-	if (mbhc->mbhc_cb->hph_pull_down_ctrl)
-		mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true);
-
-	mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	pr_debug("%s: leave\n", __func__);
-}
-
-static irqreturn_t wcd_mbhc_hs_rem_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	u8 hs_comp_result = 0, hphl_sch = 0, mic_sch = 0;
-	static u16 hphl_trigerred;
-	static u16 mic_trigerred;
-	unsigned long timeout;
-	bool removed = true;
-	int retry = 0;
-
-	pr_debug("%s: enter\n", __func__);
-
-	WCD_MBHC_RSC_LOCK(mbhc);
-
-	timeout = jiffies +
-		  msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS);
-	do {
-		retry++;
-		/*
-		 * read the result register every 10ms to look for
-		 * any change in HS_COMP_RESULT bit
-		 */
-		usleep_range(10000, 10100);
-		WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_result);
-		pr_debug("%s: Check result reg for fake removal: hs_comp_res %x\n",
-			 __func__, hs_comp_result);
-		if ((!hs_comp_result) &&
-		    retry > FAKE_REM_RETRY_ATTEMPTS) {
-			removed = false;
-			break;
-		}
-	} while (!time_after(jiffies, timeout));
-
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low ", __func__);
-		goto exit;
-	}
-	pr_debug("%s: headset %s actually removed\n", __func__,
-		removed ? "" : "not ");
-
-	WCD_MBHC_REG_READ(WCD_MBHC_HPHL_SCHMT_RESULT, hphl_sch);
-	WCD_MBHC_REG_READ(WCD_MBHC_MIC_SCHMT_RESULT, mic_sch);
-	WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_result);
-
-	if (removed) {
-		if (!(hphl_sch && mic_sch && hs_comp_result)) {
-			/*
-			 * extension cable is still plugged in
-			 * report it as LINEOUT device
-			 */
-			goto report_unplug;
-		} else {
-			if (!mic_sch) {
-				mic_trigerred++;
-				pr_debug("%s: Removal MIC trigerred %d\n",
-					 __func__, mic_trigerred);
-			}
-			if (!hphl_sch) {
-				hphl_trigerred++;
-				pr_debug("%s: Removal HPHL trigerred %d\n",
-					 __func__, hphl_trigerred);
-			}
-			if (mic_trigerred && hphl_trigerred) {
-				/*
-				 * extension cable is still plugged in
-				 * report it as LINEOUT device
-				 */
-				goto report_unplug;
-			}
-		}
-	}
-exit:
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-
-report_unplug:
-	wcd_mbhc_elec_hs_report_unplug(mbhc);
-	hphl_trigerred = 0;
-	mic_trigerred = 0;
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_mbhc_hs_ins_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	bool detection_type = 0, hphl_sch = 0, mic_sch = 0;
-	u16 elect_result = 0;
-	static u16 hphl_trigerred;
-	static u16 mic_trigerred;
-
-	pr_debug("%s: enter\n", __func__);
-	if (!mbhc->mbhc_cfg->detect_extn_cable) {
-		pr_debug("%s: Returning as Extension cable feature not enabled\n",
-			__func__);
-		return IRQ_HANDLED;
-	}
-	WCD_MBHC_RSC_LOCK(mbhc);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_DETECTION_TYPE, detection_type);
-	WCD_MBHC_REG_READ(WCD_MBHC_ELECT_RESULT, elect_result);
-
-	pr_debug("%s: detection_type %d, elect_result %x\n", __func__,
-				detection_type, elect_result);
-	if (detection_type) {
-		/* check if both Left and MIC Schmitt triggers are triggered */
-		WCD_MBHC_REG_READ(WCD_MBHC_HPHL_SCHMT_RESULT, hphl_sch);
-		WCD_MBHC_REG_READ(WCD_MBHC_MIC_SCHMT_RESULT, mic_sch);
-		if (hphl_sch && mic_sch) {
-			/* Go for plug type determination */
-			pr_debug("%s: Go for plug type determination\n",
-				  __func__);
-			goto determine_plug;
-
-		} else {
-			if (mic_sch) {
-				mic_trigerred++;
-				pr_debug("%s: Insertion MIC trigerred %d\n",
-					 __func__, mic_trigerred);
-				WCD_MBHC_REG_UPDATE_BITS(
-						WCD_MBHC_ELECT_SCHMT_ISRC,
-						0);
-				msleep(20);
-				WCD_MBHC_REG_UPDATE_BITS(
-						WCD_MBHC_ELECT_SCHMT_ISRC,
-						1);
-			}
-			if (hphl_sch) {
-				hphl_trigerred++;
-				pr_debug("%s: Insertion HPHL trigerred %d\n",
-					 __func__, hphl_trigerred);
-			}
-			if (mic_trigerred && hphl_trigerred) {
-				/* Go for plug type determination */
-				pr_debug("%s: Go for plug type determination\n",
-					 __func__);
-				goto determine_plug;
-			}
-		}
-	}
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-
-determine_plug:
-	/*
-	 * Disable HPHL trigger and MIC Schmitt triggers.
-	 * Setup for insertion detection.
-	 */
-	pr_debug("%s: Disable insertion interrupt\n", __func__);
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS,
-			     false);
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0);
-	hphl_trigerred = 0;
-	mic_trigerred = 0;
-	mbhc->is_extn_cable = true;
-	mbhc->btn_press_intr = false;
-	wcd_mbhc_detect_plug_type(mbhc);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return IRQ_HANDLED;
-}
-
-static struct wcd_mbhc_fn mbhc_fn = {
-	.wcd_mbhc_hs_ins_irq = wcd_mbhc_hs_ins_irq,
-	.wcd_mbhc_hs_rem_irq = wcd_mbhc_hs_rem_irq,
-	.wcd_mbhc_detect_plug_type = wcd_mbhc_detect_plug_type,
-	.wcd_mbhc_detect_anc_plug_type = wcd_mbhc_detect_anc_plug_type,
-	.wcd_cancel_hs_detect_plug = wcd_cancel_hs_detect_plug,
-};
-
-/* Function: wcd_mbhc_legacy_init
- * @mbhc: MBHC function pointer
- * Description: Initialize MBHC legacy based function pointers to MBHC structure
- */
-void wcd_mbhc_legacy_init(struct wcd_mbhc *mbhc)
-{
-	if (!mbhc) {
-		pr_err("%s: mbhc is NULL\n", __func__);
-		return;
-	}
-	mbhc->mbhc_fn = &mbhc_fn;
-	INIT_WORK(&mbhc->correct_plug_swch, wcd_correct_swch_plug);
-}
-EXPORT_SYMBOL(wcd_mbhc_legacy_init);
diff --git a/sound/soc/codecs/wcd-mbhc-legacy.h b/sound/soc/codecs/wcd-mbhc-legacy.h
deleted file mode 100644
index 594393d..0000000
--- a/sound/soc/codecs/wcd-mbhc-legacy.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_MBHC_LEGACY_H__
-#define __WCD_MBHC_LEGACY_H__
-
-#include "wcdcal-hwdep.h"
-#include "wcd-mbhc-v2.h"
-
-#ifdef CONFIG_SND_SOC_WCD_MBHC_LEGACY
-void wcd_mbhc_legacy_init(struct wcd_mbhc *mbhc);
-#else
-static inline void wcd_mbhc_legacy_init(struct wcd_mbhc *mbhc)
-{
-}
-#endif
-
-#endif /* __WCD_MBHC_LEGACY_H__ */
diff --git a/sound/soc/codecs/wcd-mbhc-v2-api.h b/sound/soc/codecs/wcd-mbhc-v2-api.h
deleted file mode 100644
index 7b6e945..0000000
--- a/sound/soc/codecs/wcd-mbhc-v2-api.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_MBHC_V2_API_H__
-#define __WCD_MBHC_V2_API_H__
-
-#include "wcd-mbhc-v2.h"
-
-#if IS_ENABLED(CONFIG_SND_SOC_WCD_MBHC)
-int wcd_mbhc_start(struct wcd_mbhc *mbhc,
-		       struct wcd_mbhc_config *mbhc_cfg);
-void wcd_mbhc_stop(struct wcd_mbhc *mbhc);
-int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
-		      const struct wcd_mbhc_cb *mbhc_cb,
-		      const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
-		      struct wcd_mbhc_register *wcd_mbhc_regs,
-		      bool impedance_det_en);
-int wcd_mbhc_get_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
-			   uint32_t *zr);
-void wcd_mbhc_deinit(struct wcd_mbhc *mbhc);
-
-#else
-static inline void wcd_mbhc_stop(struct wcd_mbhc *mbhc)
-{
-}
-int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
-		      const struct wcd_mbhc_cb *mbhc_cb,
-		      const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
-		      struct wcd_mbhc_register *wcd_mbhc_regs,
-		      bool impedance_det_en)
-{
-	return 0;
-}
-static inline int wcd_mbhc_start(struct wcd_mbhc *mbhc,
-				 struct wcd_mbhc_config *mbhc_cfg)
-{
-	return 0;
-}
-static inline int wcd_mbhc_get_impedance(struct wcd_mbhc *mbhc,
-					 uint32_t *zl,
-					 uint32_t *zr)
-{
-	*zl = 0;
-	*zr = 0;
-	return -EINVAL;
-}
-static inline void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
-{
-}
-#endif
-
-#endif /* __WCD_MBHC_V2_API_H__ */
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
deleted file mode 100644
index eb67de9..0000000
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ /dev/null
@@ -1,2110 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/list.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-#include <linux/kernel.h>
-#include <linux/input.h>
-#include <linux/firmware.h>
-#include <linux/completion.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/soc.h>
-#include <sound/jack.h>
-#include "wcdcal-hwdep.h"
-#include "wcd-mbhc-legacy.h"
-#include "wcd-mbhc-adc.h"
-#include "wcd-mbhc-v2-api.h"
-
-void wcd_mbhc_jack_report(struct wcd_mbhc *mbhc,
-			  struct snd_soc_jack *jack, int status, int mask)
-{
-	snd_soc_jack_report(jack, status, mask);
-}
-EXPORT_SYMBOL(wcd_mbhc_jack_report);
-
-static void __hphocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status,
-				int irq)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	dev_dbg(codec->dev, "%s: clear ocp status %x\n",
-		__func__, jack_status);
-
-	if (mbhc->hph_status & jack_status) {
-		mbhc->hph_status &= ~jack_status;
-		wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-				     mbhc->hph_status, WCD_MBHC_JACK_MASK);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1);
-		/*
-		 * reset retry counter as PA is turned off signifying
-		 * start of new OCP detection session
-		 */
-		if (mbhc->intr_ids->hph_left_ocp)
-			mbhc->hphlocp_cnt = 0;
-		else
-			mbhc->hphrocp_cnt = 0;
-		mbhc->mbhc_cb->irq_control(codec, irq, true);
-	}
-}
-
-static void hphrocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status)
-{
-	__hphocp_off_report(mbhc, SND_JACK_OC_HPHR,
-			    mbhc->intr_ids->hph_right_ocp);
-}
-
-static void hphlocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status)
-{
-	__hphocp_off_report(mbhc, SND_JACK_OC_HPHL,
-			    mbhc->intr_ids->hph_left_ocp);
-}
-
-static void wcd_program_hs_vref(struct wcd_mbhc *mbhc)
-{
-	struct wcd_mbhc_plug_type_cfg *plug_type_cfg;
-	struct snd_soc_codec *codec = mbhc->codec;
-	u32 reg_val;
-
-	plug_type_cfg = WCD_MBHC_CAL_PLUG_TYPE_PTR(mbhc->mbhc_cfg->calibration);
-	reg_val = ((plug_type_cfg->v_hs_max - HS_VREF_MIN_VAL) / 100);
-
-	dev_dbg(codec->dev, "%s: reg_val  = %x\n", __func__, reg_val);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_VREF, reg_val);
-}
-
-static void wcd_program_btn_threshold(const struct wcd_mbhc *mbhc, bool micbias)
-{
-	struct wcd_mbhc_btn_detect_cfg *btn_det;
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct snd_soc_card *card = codec->component.card;
-	s16 *btn_low, *btn_high;
-
-	if (mbhc->mbhc_cfg->calibration == NULL) {
-		dev_err(card->dev, "%s: calibration data is NULL\n", __func__);
-		return;
-	}
-
-	btn_det = WCD_MBHC_CAL_BTN_DET_PTR(mbhc->mbhc_cfg->calibration);
-	btn_low = btn_det->_v_btn_low;
-	btn_high = ((void *)&btn_det->_v_btn_low) +
-			(sizeof(btn_det->_v_btn_low[0]) * btn_det->num_btn);
-
-	mbhc->mbhc_cb->set_btn_thr(codec, btn_low, btn_high, btn_det->num_btn,
-				   micbias);
-}
-
-void wcd_enable_curr_micbias(const struct wcd_mbhc *mbhc,
-				const enum wcd_mbhc_cs_mb_en_flag cs_mb_en)
-{
-
-	/*
-	 * Some codecs handle micbias/pullup enablement in codec
-	 * drivers itself and micbias is not needed for regular
-	 * plug type detection. So if micbias_control callback function
-	 * is defined, just return.
-	 */
-	if (mbhc->mbhc_cb->mbhc_micbias_control)
-		return;
-
-	pr_debug("%s: enter, cs_mb_en: %d\n", __func__, cs_mb_en);
-
-	switch (cs_mb_en) {
-	case WCD_MBHC_EN_CS:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		/* Program Button threshold registers as per CS */
-		wcd_program_btn_threshold(mbhc, false);
-		break;
-	case WCD_MBHC_EN_MB:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-
-		/* Disable PULL_UP_EN & enable MICBIAS */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 2);
-		/* Program Button threshold registers as per MICBIAS */
-		wcd_program_btn_threshold(mbhc, true);
-		break;
-	case WCD_MBHC_EN_PULLUP:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 3);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 1);
-		/* Program Button threshold registers as per MICBIAS */
-		wcd_program_btn_threshold(mbhc, true);
-		break;
-	case WCD_MBHC_EN_NONE:
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
-		break;
-	default:
-		pr_debug("%s: Invalid parameter", __func__);
-		break;
-	}
-
-	pr_debug("%s: exit\n", __func__);
-}
-EXPORT_SYMBOL(wcd_enable_curr_micbias);
-
-static const char *wcd_mbhc_get_event_string(int event)
-{
-	switch (event) {
-	case WCD_EVENT_PRE_MICBIAS_2_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_MICBIAS_2_OFF);
-	case WCD_EVENT_POST_MICBIAS_2_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_MICBIAS_2_OFF);
-	case WCD_EVENT_PRE_MICBIAS_2_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_MICBIAS_2_ON);
-	case WCD_EVENT_POST_MICBIAS_2_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_MICBIAS_2_ON);
-	case WCD_EVENT_PRE_HPHL_PA_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_HPHL_PA_ON);
-	case WCD_EVENT_POST_HPHL_PA_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_HPHL_PA_OFF);
-	case WCD_EVENT_PRE_HPHR_PA_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_HPHR_PA_ON);
-	case WCD_EVENT_POST_HPHR_PA_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_HPHR_PA_OFF);
-	case WCD_EVENT_PRE_HPHR_PA_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_HPHR_PA_OFF);
-	case WCD_EVENT_PRE_HPHL_PA_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_HPHL_PA_OFF);
-	case WCD_EVENT_POST_DAPM_MICBIAS_2_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_DAPM_MICBIAS_2_ON);
-	case WCD_EVENT_PRE_DAPM_MICBIAS_2_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_DAPM_MICBIAS_2_ON);
-	case WCD_EVENT_POST_DAPM_MICBIAS_2_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_POST_DAPM_MICBIAS_2_OFF);
-	case WCD_EVENT_PRE_DAPM_MICBIAS_2_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_PRE_DAPM_MICBIAS_2_OFF);
-	case WCD_EVENT_OCP_OFF:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_OCP_OFF);
-	case WCD_EVENT_OCP_ON:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_OCP_ON);
-	case WCD_EVENT_INVALID:
-	default:
-		return WCD_MBHC_STRINGIFY(WCD_EVENT_INVALID);
-	}
-}
-
-static int wcd_event_notify(struct notifier_block *self, unsigned long val,
-			    void *data)
-{
-	struct wcd_mbhc *mbhc = (struct wcd_mbhc *)data;
-	enum wcd_notify_event event = (enum wcd_notify_event)val;
-	struct snd_soc_codec *codec = mbhc->codec;
-	bool micbias2 = false;
-	bool micbias1 = false;
-	u8 fsm_en = 0;
-
-	pr_debug("%s: event %s (%d)\n", __func__,
-		 wcd_mbhc_get_event_string(event), event);
-	if (mbhc->mbhc_cb->micbias_enable_status) {
-		micbias2 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-								MIC_BIAS_2);
-		micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-								MIC_BIAS_1);
-	}
-	switch (event) {
-	/* MICBIAS usage change */
-	case WCD_EVENT_POST_DAPM_MICBIAS_2_ON:
-		mbhc->is_hs_recording = true;
-		pr_debug("%s: is_capture: %d\n", __func__,
-			  mbhc->is_hs_recording);
-		break;
-	case WCD_EVENT_POST_MICBIAS_2_ON:
-		if (!mbhc->micbias_enable)
-			goto out_micb_en;
-		if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) {
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_PRECHARGE,
-					true);
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_SET_VAL,
-					true);
-			/*
-			 * Special headset needs MICBIAS as 2.7V so wait for
-			 * 50 msec for the MICBIAS to reach 2.7 volts.
-			 */
-			msleep(50);
-		}
-		if (mbhc->mbhc_cb->set_auto_zeroing)
-			mbhc->mbhc_cb->set_auto_zeroing(codec, true);
-		if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_PRECHARGE,
-					false);
-out_micb_en:
-		/* Disable current source if micbias enabled */
-		if (mbhc->mbhc_cb->mbhc_micbias_control) {
-			WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
-			if (fsm_en)
-				WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL,
-							 0);
-		} else {
-			mbhc->is_hs_recording = true;
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-		}
-		/* configure cap settings properly when micbias is enabled */
-		if (mbhc->mbhc_cb->set_cap_mode)
-			mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true);
-		break;
-	case WCD_EVENT_PRE_MICBIAS_2_OFF:
-		/*
-		 * Before MICBIAS_2 is turned off, if FSM is enabled,
-		 * make sure current source is enabled so as to detect
-		 * button press/release events
-		 */
-		if (mbhc->mbhc_cb->mbhc_micbias_control &&
-		    !mbhc->micbias_enable) {
-			WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
-			if (fsm_en)
-				WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL,
-							 3);
-		}
-		break;
-	/* MICBIAS usage change */
-	case WCD_EVENT_POST_DAPM_MICBIAS_2_OFF:
-		mbhc->is_hs_recording = false;
-		pr_debug("%s: is_capture: %d\n", __func__,
-			  mbhc->is_hs_recording);
-		break;
-	case WCD_EVENT_POST_MICBIAS_2_OFF:
-		if (!mbhc->mbhc_cb->mbhc_micbias_control)
-			mbhc->is_hs_recording = false;
-		if (mbhc->micbias_enable) {
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-			break;
-		}
-
-		if (mbhc->mbhc_cb->set_auto_zeroing)
-			mbhc->mbhc_cb->set_auto_zeroing(codec, false);
-		if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable)
-			mbhc->mbhc_cb->set_micbias_value(codec);
-		/* Enable PULL UP if PA's are enabled */
-		if ((test_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state)) ||
-				(test_bit(WCD_MBHC_EVENT_PA_HPHR,
-					  &mbhc->event_state)))
-			/* enable pullup and cs, disable mb */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
-		else
-			/* enable current source and disable mb, pullup*/
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
-
-		/* configure cap settings properly when micbias is disabled */
-		if (mbhc->mbhc_cb->set_cap_mode)
-			mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false);
-		break;
-	case WCD_EVENT_PRE_HPHL_PA_OFF:
-		mutex_lock(&mbhc->hphl_pa_lock);
-		break;
-	case WCD_EVENT_POST_HPHL_PA_OFF:
-		clear_bit(WCD_MBHC_HPHL_PA_OFF_ACK, &mbhc->hph_pa_dac_state);
-		if (mbhc->hph_status & SND_JACK_OC_HPHL)
-			hphlocp_off_report(mbhc, SND_JACK_OC_HPHL);
-		clear_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state);
-		/* check if micbias is enabled */
-		if (micbias2)
-			/* Disable cs, pullup & enable micbias */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-		else
-			/* Disable micbias, pullup & enable cs */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
-		mutex_unlock(&mbhc->hphl_pa_lock);
-		clear_bit(WCD_MBHC_ANC0_OFF_ACK, &mbhc->hph_anc_state);
-		break;
-	case WCD_EVENT_PRE_HPHR_PA_OFF:
-		mutex_lock(&mbhc->hphr_pa_lock);
-		break;
-	case WCD_EVENT_POST_HPHR_PA_OFF:
-		clear_bit(WCD_MBHC_HPHR_PA_OFF_ACK, &mbhc->hph_pa_dac_state);
-		if (mbhc->hph_status & SND_JACK_OC_HPHR)
-			hphrocp_off_report(mbhc, SND_JACK_OC_HPHR);
-		clear_bit(WCD_MBHC_EVENT_PA_HPHR, &mbhc->event_state);
-		/* check if micbias is enabled */
-		if (micbias2)
-			/* Disable cs, pullup & enable micbias */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-		else
-			/* Disable micbias, pullup & enable cs */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
-		mutex_unlock(&mbhc->hphr_pa_lock);
-		clear_bit(WCD_MBHC_ANC1_OFF_ACK, &mbhc->hph_anc_state);
-		break;
-	case WCD_EVENT_PRE_HPHL_PA_ON:
-		set_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state);
-		/* check if micbias is enabled */
-		if (micbias2)
-			/* Disable cs, pullup & enable micbias */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-		else
-			/* Disable micbias, enable pullup & cs */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
-		break;
-	case WCD_EVENT_PRE_HPHR_PA_ON:
-		set_bit(WCD_MBHC_EVENT_PA_HPHR, &mbhc->event_state);
-		/* check if micbias is enabled */
-		if (micbias2)
-			/* Disable cs, pullup & enable micbias */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-		else
-			/* Disable micbias, enable pullup & cs */
-			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
-		break;
-	case WCD_EVENT_OCP_OFF:
-		mbhc->mbhc_cb->irq_control(mbhc->codec,
-					   mbhc->intr_ids->hph_left_ocp,
-					   false);
-		break;
-	case WCD_EVENT_OCP_ON:
-		mbhc->mbhc_cb->irq_control(mbhc->codec,
-					   mbhc->intr_ids->hph_left_ocp,
-					   true);
-		break;
-	default:
-		break;
-	}
-	return 0;
-}
-
-int wcd_cancel_btn_work(struct wcd_mbhc *mbhc)
-{
-	int r;
-
-	r = cancel_delayed_work_sync(&mbhc->mbhc_btn_dwork);
-	/*
-	 * if scheduled mbhc.mbhc_btn_dwork is canceled from here,
-	 * we have to unlock from here instead btn_work
-	 */
-	if (r)
-		mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	return r;
-}
-EXPORT_SYMBOL(wcd_cancel_btn_work);
-
-bool wcd_swch_level_remove(struct wcd_mbhc *mbhc)
-{
-	u16 result2 = 0;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_SWCH_LEVEL_REMOVE, result2);
-	return (result2) ? true : false;
-}
-EXPORT_SYMBOL(wcd_swch_level_remove);
-
-static void wcd_mbhc_clr_and_turnon_hph_padac(struct wcd_mbhc *mbhc)
-{
-	bool pa_turned_on = false;
-	u8 wg_time = 0;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_HPH_CNP_WG_TIME, wg_time);
-	wg_time += 1;
-
-	mutex_lock(&mbhc->hphr_pa_lock);
-	if (test_and_clear_bit(WCD_MBHC_HPHR_PA_OFF_ACK,
-			       &mbhc->hph_pa_dac_state)) {
-		pr_debug("%s: HPHR clear flag and enable PA\n", __func__);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHR_PA_EN, 1);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHR_OCP_DET_EN, 1);
-		pa_turned_on = true;
-	}
-	mutex_unlock(&mbhc->hphr_pa_lock);
-	mutex_lock(&mbhc->hphl_pa_lock);
-	if (test_and_clear_bit(WCD_MBHC_HPHL_PA_OFF_ACK,
-			       &mbhc->hph_pa_dac_state)) {
-		pr_debug("%s: HPHL clear flag and enable PA\n", __func__);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_PA_EN, 1);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_OCP_DET_EN, 1);
-		pa_turned_on = true;
-	}
-	mutex_unlock(&mbhc->hphl_pa_lock);
-
-	if (pa_turned_on) {
-		pr_debug("%s: PA was turned on by MBHC and not by DAPM\n",
-			 __func__);
-		usleep_range(wg_time * 1000, wg_time * 1000 + 50);
-	}
-
-	if (test_and_clear_bit(WCD_MBHC_ANC0_OFF_ACK,
-				&mbhc->hph_anc_state)) {
-		usleep_range(20000, 20100);
-		pr_debug("%s: HPHL ANC clear flag and enable ANC_EN\n",
-			__func__);
-		if (mbhc->mbhc_cb->update_anc_state)
-			mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 0);
-	}
-
-	if (test_and_clear_bit(WCD_MBHC_ANC1_OFF_ACK,
-				&mbhc->hph_anc_state)) {
-		usleep_range(20000, 20100);
-		pr_debug("%s: HPHR ANC clear flag and enable ANC_EN\n",
-			__func__);
-		if (mbhc->mbhc_cb->update_anc_state)
-			mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 1);
-	}
-
-}
-
-static bool wcd_mbhc_is_hph_pa_on(struct wcd_mbhc *mbhc)
-{
-	bool hph_pa_on = false;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_HPH_PA_EN, hph_pa_on);
-
-	return (hph_pa_on) ? true : false;
-}
-
-static void wcd_mbhc_set_and_turnoff_hph_padac(struct wcd_mbhc *mbhc)
-{
-	u8 wg_time = 0;
-
-	WCD_MBHC_REG_READ(WCD_MBHC_HPH_CNP_WG_TIME, wg_time);
-	wg_time += 1;
-
-	/* If headphone PA is on, check if userspace receives
-	 * removal event to sync-up PA's state
-	 */
-	if (wcd_mbhc_is_hph_pa_on(mbhc)) {
-		pr_debug("%s PA is on, setting PA_OFF_ACK\n", __func__);
-		set_bit(WCD_MBHC_HPHL_PA_OFF_ACK, &mbhc->hph_pa_dac_state);
-		set_bit(WCD_MBHC_HPHR_PA_OFF_ACK, &mbhc->hph_pa_dac_state);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_OCP_DET_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHR_OCP_DET_EN, 0);
-	} else {
-		pr_debug("%s PA is off\n", __func__);
-	}
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPH_PA_EN, 0);
-	usleep_range(wg_time * 1000, wg_time * 1000 + 50);
-
-
-	if (mbhc->mbhc_cb->is_anc_on && mbhc->mbhc_cb->is_anc_on(mbhc)) {
-		usleep_range(20000, 20100);
-		pr_debug("%s ANC is on, setting ANC_OFF_ACK\n", __func__);
-		set_bit(WCD_MBHC_ANC0_OFF_ACK, &mbhc->hph_anc_state);
-		set_bit(WCD_MBHC_ANC1_OFF_ACK, &mbhc->hph_anc_state);
-		if (mbhc->mbhc_cb->update_anc_state) {
-			mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 0);
-			mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 1);
-		} else {
-			pr_debug("%s ANC is off\n", __func__);
-		}
-	}
-}
-
-int wcd_mbhc_get_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
-			uint32_t *zr)
-{
-	*zl = mbhc->zl;
-	*zr = mbhc->zr;
-
-	if (*zl && *zr)
-		return 0;
-	else
-		return -EINVAL;
-}
-EXPORT_SYMBOL(wcd_mbhc_get_impedance);
-
-void wcd_mbhc_hs_elec_irq(struct wcd_mbhc *mbhc, int irq_type,
-				 bool enable)
-{
-	int irq;
-
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	if (irq_type == WCD_MBHC_ELEC_HS_INS)
-		irq = mbhc->intr_ids->mbhc_hs_ins_intr;
-	else if (irq_type == WCD_MBHC_ELEC_HS_REM)
-		irq = mbhc->intr_ids->mbhc_hs_rem_intr;
-	else {
-		pr_debug("%s: irq_type: %d, enable: %d\n",
-			__func__, irq_type, enable);
-		return;
-	}
-
-	pr_debug("%s: irq: %d, enable: %d, intr_status:%lu\n",
-		 __func__, irq, enable, mbhc->intr_status);
-	if ((test_bit(irq_type, &mbhc->intr_status)) != enable) {
-		mbhc->mbhc_cb->irq_control(mbhc->codec, irq, enable);
-		if (enable)
-			set_bit(irq_type, &mbhc->intr_status);
-		else
-			clear_bit(irq_type, &mbhc->intr_status);
-	}
-}
-EXPORT_SYMBOL(wcd_mbhc_hs_elec_irq);
-
-static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
-				enum snd_jack_types jack_type)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	bool is_pa_on = false;
-	u8 fsm_en = 0;
-
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	pr_debug("%s: enter insertion %d hph_status %x\n",
-		 __func__, insertion, mbhc->hph_status);
-	if (!insertion) {
-		/* Report removal */
-		mbhc->hph_status &= ~jack_type;
-		/*
-		 * cancel possibly scheduled btn work and
-		 * report release if we reported button press
-		 */
-		if (wcd_cancel_btn_work(mbhc)) {
-			pr_debug("%s: button press is canceled\n", __func__);
-		} else if (mbhc->buttons_pressed) {
-			pr_debug("%s: release of button press%d\n",
-				 __func__, jack_type);
-			wcd_mbhc_jack_report(mbhc, &mbhc->button_jack, 0,
-					    mbhc->buttons_pressed);
-			mbhc->buttons_pressed &=
-				~WCD_MBHC_JACK_BUTTON_MASK;
-		}
-
-		if (mbhc->micbias_enable) {
-			if (mbhc->mbhc_cb->mbhc_micbias_control)
-				mbhc->mbhc_cb->mbhc_micbias_control(
-						codec, MIC_BIAS_2,
-						MICB_DISABLE);
-			if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-				mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-						codec,
-						MIC_BIAS_2, false);
-			if (mbhc->mbhc_cb->set_micbias_value) {
-				mbhc->mbhc_cb->set_micbias_value(codec);
-				WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
-			}
-			mbhc->micbias_enable = false;
-		}
-
-		mbhc->hph_type = WCD_MBHC_HPH_NONE;
-		mbhc->zl = mbhc->zr = 0;
-		pr_debug("%s: Reporting removal %d(%x)\n", __func__,
-			 jack_type, mbhc->hph_status);
-		wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-				mbhc->hph_status, WCD_MBHC_JACK_MASK);
-		wcd_mbhc_set_and_turnoff_hph_padac(mbhc);
-		hphrocp_off_report(mbhc, SND_JACK_OC_HPHR);
-		hphlocp_off_report(mbhc, SND_JACK_OC_HPHL);
-		mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
-	} else {
-		/*
-		 * Report removal of current jack type.
-		 * Headphone to headset shouldn't report headphone
-		 * removal.
-		 */
-		if (mbhc->mbhc_cfg->detect_extn_cable &&
-		    (mbhc->current_plug == MBHC_PLUG_TYPE_HIGH_HPH ||
-		    jack_type == SND_JACK_LINEOUT) &&
-		    (mbhc->hph_status && mbhc->hph_status != jack_type)) {
-
-			if (mbhc->micbias_enable &&
-			    mbhc->hph_status == SND_JACK_HEADSET) {
-				if (mbhc->mbhc_cb->mbhc_micbias_control)
-					mbhc->mbhc_cb->mbhc_micbias_control(
-						codec, MIC_BIAS_2,
-						MICB_DISABLE);
-				if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
-					mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
-						codec,
-						MIC_BIAS_2, false);
-				if (mbhc->mbhc_cb->set_micbias_value) {
-					mbhc->mbhc_cb->set_micbias_value(
-							codec);
-					WCD_MBHC_REG_UPDATE_BITS(
-							WCD_MBHC_MICB_CTRL, 0);
-				}
-				mbhc->micbias_enable = false;
-			}
-			mbhc->hph_type = WCD_MBHC_HPH_NONE;
-			mbhc->zl = mbhc->zr = 0;
-			pr_debug("%s: Reporting removal (%x)\n",
-				 __func__, mbhc->hph_status);
-			wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-					    0, WCD_MBHC_JACK_MASK);
-
-			if (mbhc->hph_status == SND_JACK_LINEOUT) {
-
-				pr_debug("%s: Enable micbias\n", __func__);
-				/* Disable current source and enable micbias */
-				wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
-				pr_debug("%s: set up elec removal detection\n",
-					  __func__);
-				usleep_range(200, 210);
-				wcd_mbhc_hs_elec_irq(mbhc,
-						     WCD_MBHC_ELEC_HS_REM,
-						     true);
-			}
-			mbhc->hph_status &= ~(SND_JACK_HEADSET |
-						SND_JACK_LINEOUT |
-						SND_JACK_ANC_HEADPHONE |
-						SND_JACK_UNSUPPORTED);
-		}
-
-		if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET &&
-			jack_type == SND_JACK_HEADPHONE)
-			mbhc->hph_status &= ~SND_JACK_HEADSET;
-
-		/* Report insertion */
-		if (jack_type == SND_JACK_HEADPHONE)
-			mbhc->current_plug = MBHC_PLUG_TYPE_HEADPHONE;
-		else if (jack_type == SND_JACK_UNSUPPORTED)
-			mbhc->current_plug = MBHC_PLUG_TYPE_GND_MIC_SWAP;
-		else if (jack_type == SND_JACK_HEADSET) {
-			mbhc->current_plug = MBHC_PLUG_TYPE_HEADSET;
-			mbhc->jiffies_atreport = jiffies;
-		} else if (jack_type == SND_JACK_LINEOUT) {
-			mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH;
-		} else if (jack_type == SND_JACK_ANC_HEADPHONE)
-			mbhc->current_plug = MBHC_PLUG_TYPE_ANC_HEADPHONE;
-
-		if (mbhc->mbhc_cb->hph_pa_on_status)
-			is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec);
-
-		if (mbhc->impedance_detect &&
-			mbhc->mbhc_cb->compute_impedance &&
-			(mbhc->mbhc_cfg->linein_th != 0) &&
-			(!is_pa_on)) {
-			/* Set MUX_CTL to AUTO for Z-det */
-			WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL,
-						 MUX_CTL_AUTO);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
-			mbhc->mbhc_cb->compute_impedance(mbhc,
-					&mbhc->zl, &mbhc->zr);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN,
-						 fsm_en);
-			if ((mbhc->zl > mbhc->mbhc_cfg->linein_th &&
-				mbhc->zl < MAX_IMPED) &&
-				(mbhc->zr > mbhc->mbhc_cfg->linein_th &&
-				 mbhc->zr < MAX_IMPED) &&
-				(jack_type == SND_JACK_HEADPHONE)) {
-				jack_type = SND_JACK_LINEOUT;
-				mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH;
-				if (mbhc->hph_status) {
-					mbhc->hph_status &= ~(SND_JACK_HEADSET |
-							SND_JACK_LINEOUT |
-							SND_JACK_UNSUPPORTED);
-					wcd_mbhc_jack_report(mbhc,
-							&mbhc->headset_jack,
-							mbhc->hph_status,
-							WCD_MBHC_JACK_MASK);
-				}
-				pr_debug("%s: Marking jack type as SND_JACK_LINEOUT\n",
-				__func__);
-			}
-		}
-
-		mbhc->hph_status |= jack_type;
-
-		pr_debug("%s: Reporting insertion %d(%x)\n", __func__,
-			 jack_type, mbhc->hph_status);
-		wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-				    (mbhc->hph_status | SND_JACK_MECHANICAL),
-				    WCD_MBHC_JACK_MASK);
-		wcd_mbhc_clr_and_turnon_hph_padac(mbhc);
-	}
-	pr_debug("%s: leave hph_status %x\n", __func__, mbhc->hph_status);
-}
-
-void wcd_mbhc_elec_hs_report_unplug(struct wcd_mbhc *mbhc)
-{
-	/* cancel pending button press */
-	if (wcd_cancel_btn_work(mbhc))
-		pr_debug("%s: button press is canceled\n", __func__);
-	/* cancel correct work function */
-	if (mbhc->mbhc_fn->wcd_cancel_hs_detect_plug)
-		mbhc->mbhc_fn->wcd_cancel_hs_detect_plug(mbhc,
-						&mbhc->correct_plug_swch);
-	else
-		pr_info("%s: hs_detect_plug work not cancelled\n", __func__);
-
-	pr_debug("%s: Report extension cable\n", __func__);
-	wcd_mbhc_report_plug(mbhc, 1, SND_JACK_LINEOUT);
-	/*
-	 * If PA is enabled HPHL schmitt trigger can
-	 * be unreliable, make sure to disable it
-	 */
-	if (test_bit(WCD_MBHC_EVENT_PA_HPHL,
-		&mbhc->event_state))
-		wcd_mbhc_set_and_turnoff_hph_padac(mbhc);
-	/*
-	 * Disable HPHL trigger and MIC Schmitt triggers.
-	 * Setup for insertion detection.
-	 */
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM,
-			     false);
-	wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_NONE);
-	/* Disable HW FSM */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 3);
-
-	/* Set the detection type appropriately */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE, 1);
-	wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS,
-			     true);
-}
-EXPORT_SYMBOL(wcd_mbhc_elec_hs_report_unplug);
-
-void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
-				   enum wcd_mbhc_plug_type plug_type)
-{
-	bool anc_mic_found = false;
-	enum snd_jack_types jack_type;
-
-	pr_debug("%s: enter current_plug(%d) new_plug(%d)\n",
-		 __func__, mbhc->current_plug, plug_type);
-
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	if (mbhc->current_plug == plug_type) {
-		pr_debug("%s: cable already reported, exit\n", __func__);
-		goto exit;
-	}
-
-	if (plug_type == MBHC_PLUG_TYPE_HEADPHONE) {
-		/*
-		 * Nothing was reported previously
-		 * report a headphone or unsupported
-		 */
-		wcd_mbhc_report_plug(mbhc, 1, SND_JACK_HEADPHONE);
-	} else if (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) {
-		if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
-			wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADPHONE);
-		if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET)
-			wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADSET);
-		wcd_mbhc_report_plug(mbhc, 1, SND_JACK_UNSUPPORTED);
-	} else if (plug_type == MBHC_PLUG_TYPE_HEADSET) {
-		if (mbhc->mbhc_cfg->enable_anc_mic_detect &&
-		    mbhc->mbhc_fn->wcd_mbhc_detect_anc_plug_type)
-			anc_mic_found =
-			mbhc->mbhc_fn->wcd_mbhc_detect_anc_plug_type(mbhc);
-		jack_type = SND_JACK_HEADSET;
-		if (anc_mic_found)
-			jack_type = SND_JACK_ANC_HEADPHONE;
-
-		/*
-		 * If Headphone was reported previously, this will
-		 * only report the mic line
-		 */
-		wcd_mbhc_report_plug(mbhc, 1, jack_type);
-	} else if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH) {
-		if (mbhc->mbhc_cfg->detect_extn_cable) {
-			/* High impedance device found. Report as LINEOUT */
-			wcd_mbhc_report_plug(mbhc, 1, SND_JACK_LINEOUT);
-			pr_debug("%s: setup mic trigger for further detection\n",
-				 __func__);
-
-			/* Disable HW FSM and current source */
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-			/* Setup for insertion detection */
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE,
-						 1);
-			/*
-			 * Enable HPHL trigger and MIC Schmitt triggers
-			 * and request for elec insertion interrupts
-			 */
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC,
-						 3);
-			wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS,
-					     true);
-		} else {
-			wcd_mbhc_report_plug(mbhc, 1, SND_JACK_LINEOUT);
-		}
-	} else {
-		WARN(1, "Unexpected current plug_type %d, plug_type %d\n",
-		     mbhc->current_plug, plug_type);
-	}
-exit:
-	pr_debug("%s: leave\n", __func__);
-}
-EXPORT_SYMBOL(wcd_mbhc_find_plug_and_report);
-
-static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
-{
-	bool detection_type = 0;
-	bool micbias1 = false;
-	struct snd_soc_codec *codec = mbhc->codec;
-	enum snd_jack_types jack_type;
-
-	dev_dbg(codec->dev, "%s: enter\n", __func__);
-	WCD_MBHC_RSC_LOCK(mbhc);
-	mbhc->in_swch_irq_handler = true;
-
-	/* cancel pending button press */
-	if (wcd_cancel_btn_work(mbhc))
-		pr_debug("%s: button press is canceled\n", __func__);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_MECH_DETECTION_TYPE, detection_type);
-
-	/* Set the detection type appropriately */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MECH_DETECTION_TYPE,
-				 !detection_type);
-
-	pr_debug("%s: mbhc->current_plug: %d detection_type: %d\n", __func__,
-			mbhc->current_plug, detection_type);
-	if (mbhc->mbhc_fn->wcd_cancel_hs_detect_plug)
-		mbhc->mbhc_fn->wcd_cancel_hs_detect_plug(mbhc,
-						&mbhc->correct_plug_swch);
-	else
-		pr_info("%s: hs_detect_plug work not cancelled\n", __func__);
-
-	if (mbhc->mbhc_cb->micbias_enable_status)
-		micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
-						MIC_BIAS_1);
-
-	if ((mbhc->current_plug == MBHC_PLUG_TYPE_NONE) &&
-	    detection_type) {
-		/* Make sure MASTER_BIAS_CTL is enabled */
-		mbhc->mbhc_cb->mbhc_bias(codec, true);
-
-		if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_TAIL_CURR, true);
-
-		if (!mbhc->mbhc_cfg->hs_ext_micbias &&
-		     mbhc->mbhc_cb->micb_internal)
-			/*
-			 * Enable Tx2 RBias if the headset
-			 * is using internal micbias
-			 */
-			mbhc->mbhc_cb->micb_internal(codec, 1, true);
-
-		/* Remove micbias pulldown */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 0);
-		/* Apply trim if needed on the device */
-		if (mbhc->mbhc_cb->trim_btn_reg)
-			mbhc->mbhc_cb->trim_btn_reg(codec);
-		/* Enable external voltage source to micbias if present */
-		if (mbhc->mbhc_cb->enable_mb_source)
-			mbhc->mbhc_cb->enable_mb_source(mbhc, true);
-		mbhc->btn_press_intr = false;
-		mbhc->is_btn_press = false;
-		if (mbhc->mbhc_fn)
-			mbhc->mbhc_fn->wcd_mbhc_detect_plug_type(mbhc);
-	} else if ((mbhc->current_plug != MBHC_PLUG_TYPE_NONE)
-			&& !detection_type) {
-		/* Disable external voltage source to micbias if present */
-		if (mbhc->mbhc_cb->enable_mb_source)
-			mbhc->mbhc_cb->enable_mb_source(mbhc, false);
-		/* Disable HW FSM */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
-			mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
-					MBHC_COMMON_MICB_TAIL_CURR, false);
-
-		if (mbhc->mbhc_cb->set_cap_mode)
-			mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false);
-
-		mbhc->btn_press_intr = false;
-		mbhc->is_btn_press = false;
-		switch (mbhc->current_plug) {
-		case MBHC_PLUG_TYPE_HEADPHONE:
-			jack_type = SND_JACK_HEADPHONE;
-			break;
-		case MBHC_PLUG_TYPE_GND_MIC_SWAP:
-			jack_type = SND_JACK_UNSUPPORTED;
-			break;
-		case MBHC_PLUG_TYPE_HEADSET:
-			/* make sure to turn off Rbias */
-			if (mbhc->mbhc_cb->micb_internal)
-				mbhc->mbhc_cb->micb_internal(codec, 1, false);
-			/* Pulldown micbias */
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 1);
-			jack_type = SND_JACK_HEADSET;
-			break;
-		case MBHC_PLUG_TYPE_HIGH_HPH:
-			mbhc->is_extn_cable = false;
-			jack_type = SND_JACK_LINEOUT;
-			break;
-		case MBHC_PLUG_TYPE_ANC_HEADPHONE:
-			jack_type = SND_JACK_ANC_HEADPHONE;
-			break;
-		default:
-			pr_info("%s: Invalid current plug: %d\n",
-				__func__, mbhc->current_plug);
-			jack_type = SND_JACK_UNSUPPORTED;
-			break;
-		}
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM, false);
-		wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE, 1);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0);
-		mbhc->extn_cable_hph_rem = false;
-		wcd_mbhc_report_plug(mbhc, 0, jack_type);
-
-	} else if (!detection_type) {
-		/* Disable external voltage source to micbias if present */
-		if (mbhc->mbhc_cb->enable_mb_source)
-			mbhc->mbhc_cb->enable_mb_source(mbhc, false);
-		/* Disable HW FSM */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
-		mbhc->extn_cable_hph_rem = false;
-	}
-
-	mbhc->in_swch_irq_handler = false;
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-}
-
-static irqreturn_t wcd_mbhc_mech_plug_detect_irq(int irq, void *data)
-{
-	int r = IRQ_HANDLED;
-	struct wcd_mbhc *mbhc = data;
-
-	pr_debug("%s: enter\n", __func__);
-	if (unlikely((mbhc->mbhc_cb->lock_sleep(mbhc, true)) == false)) {
-		pr_warn("%s: failed to hold suspend\n", __func__);
-		r = IRQ_NONE;
-	} else {
-		/* Call handler */
-		wcd_mbhc_swch_irq_handler(mbhc);
-		mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	}
-	pr_debug("%s: leave %d\n", __func__, r);
-	return r;
-}
-
-int wcd_mbhc_get_button_mask(struct wcd_mbhc *mbhc)
-{
-	int mask = 0;
-	int btn;
-
-	btn = mbhc->mbhc_cb->map_btn_code_to_num(mbhc->codec);
-
-	switch (btn) {
-	case 0:
-		mask = SND_JACK_BTN_0;
-		break;
-	case 1:
-		mask = SND_JACK_BTN_1;
-		break;
-	case 2:
-		mask = SND_JACK_BTN_2;
-		break;
-	case 3:
-		mask = SND_JACK_BTN_3;
-		break;
-	case 4:
-		mask = SND_JACK_BTN_4;
-		break;
-	case 5:
-		mask = SND_JACK_BTN_5;
-		break;
-	default:
-		break;
-	}
-
-	return mask;
-}
-EXPORT_SYMBOL(wcd_mbhc_get_button_mask);
-
-static void wcd_btn_lpress_fn(struct work_struct *work)
-{
-	struct delayed_work *dwork;
-	struct wcd_mbhc *mbhc;
-	s16 btn_result = 0;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	dwork = to_delayed_work(work);
-	mbhc = container_of(dwork, struct wcd_mbhc, mbhc_btn_dwork);
-
-	WCD_MBHC_REG_READ(WCD_MBHC_BTN_RESULT, btn_result);
-	if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET) {
-		pr_debug("%s: Reporting long button press event, btn_result: %d\n",
-			 __func__, btn_result);
-		wcd_mbhc_jack_report(mbhc, &mbhc->button_jack,
-				mbhc->buttons_pressed, mbhc->buttons_pressed);
-	}
-	pr_debug("%s: leave\n", __func__);
-	mbhc->mbhc_cb->lock_sleep(mbhc, false);
-}
-
-static bool wcd_mbhc_fw_validate(const void *data, size_t size)
-{
-	u32 cfg_offset;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	struct firmware_cal fw;
-
-	fw.data = (void *)data;
-	fw.size = size;
-
-	if (fw.size < WCD_MBHC_CAL_MIN_SIZE)
-		return false;
-
-	/*
-	 * Previous check guarantees that there is enough fw data up
-	 * to num_btn
-	 */
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(fw.data);
-	cfg_offset = (u32) ((void *) btn_cfg - (void *) fw.data);
-	if (fw.size < (cfg_offset + WCD_MBHC_CAL_BTN_SZ(btn_cfg)))
-		return false;
-
-	return true;
-}
-
-static irqreturn_t wcd_mbhc_btn_press_handler(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	int mask;
-	unsigned long msec_val;
-
-	pr_debug("%s: enter\n", __func__);
-	complete(&mbhc->btn_press_compl);
-	WCD_MBHC_RSC_LOCK(mbhc);
-	wcd_cancel_btn_work(mbhc);
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low ", __func__);
-		goto done;
-	}
-
-	mbhc->is_btn_press = true;
-	msec_val = jiffies_to_msecs(jiffies - mbhc->jiffies_atreport);
-	pr_debug("%s: msec_val = %ld\n", __func__, msec_val);
-	if (msec_val < MBHC_BUTTON_PRESS_THRESHOLD_MIN) {
-		pr_debug("%s: Too short, ignore button press\n", __func__);
-		goto done;
-	}
-
-	/* If switch interrupt already kicked in, ignore button press */
-	if (mbhc->in_swch_irq_handler) {
-		pr_debug("%s: Swtich level changed, ignore button press\n",
-			 __func__);
-		goto done;
-	}
-	mask = wcd_mbhc_get_button_mask(mbhc);
-	if (mask == SND_JACK_BTN_0)
-		mbhc->btn_press_intr = true;
-
-	if (mbhc->current_plug != MBHC_PLUG_TYPE_HEADSET) {
-		pr_debug("%s: Plug isn't headset, ignore button press\n",
-				__func__);
-		goto done;
-	}
-	mbhc->buttons_pressed |= mask;
-	mbhc->mbhc_cb->lock_sleep(mbhc, true);
-	if (schedule_delayed_work(&mbhc->mbhc_btn_dwork,
-				msecs_to_jiffies(400)) == 0) {
-		WARN(1, "Button pressed twice without release event\n");
-		mbhc->mbhc_cb->lock_sleep(mbhc, false);
-	}
-done:
-	pr_debug("%s: leave\n", __func__);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_mbhc_release_handler(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	int ret;
-
-	pr_debug("%s: enter\n", __func__);
-	WCD_MBHC_RSC_LOCK(mbhc);
-	if (wcd_swch_level_remove(mbhc)) {
-		pr_debug("%s: Switch level is low ", __func__);
-		goto exit;
-	}
-
-	if (mbhc->is_btn_press) {
-		mbhc->is_btn_press = false;
-	} else {
-		pr_debug("%s: This release is for fake btn press\n", __func__);
-		goto exit;
-	}
-
-	/*
-	 * If current plug is headphone then there is no chance to
-	 * get btn release interrupt, so connected cable should be
-	 * headset not headphone.
-	 * For ADC MBHC, ADC_COMPLETE interrupt will be generated
-	 * in this case. So skip the check here.
-	 */
-	if (mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY &&
-		mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE) {
-		wcd_mbhc_find_plug_and_report(mbhc, MBHC_PLUG_TYPE_HEADSET);
-		goto exit;
-
-	}
-	if (mbhc->buttons_pressed & WCD_MBHC_JACK_BUTTON_MASK) {
-		ret = wcd_cancel_btn_work(mbhc);
-		if (ret == 0) {
-			pr_debug("%s: Reporting long button release event\n",
-				 __func__);
-			wcd_mbhc_jack_report(mbhc, &mbhc->button_jack,
-					0, mbhc->buttons_pressed);
-		} else {
-			if (mbhc->in_swch_irq_handler) {
-				pr_debug("%s: Switch irq kicked in, ignore\n",
-					__func__);
-			} else {
-				pr_debug("%s: Reporting btn press\n",
-					 __func__);
-				wcd_mbhc_jack_report(mbhc,
-						     &mbhc->button_jack,
-						     mbhc->buttons_pressed,
-						     mbhc->buttons_pressed);
-				pr_debug("%s: Reporting btn release\n",
-					 __func__);
-				wcd_mbhc_jack_report(mbhc,
-						&mbhc->button_jack,
-						0, mbhc->buttons_pressed);
-			}
-		}
-		mbhc->buttons_pressed &= ~WCD_MBHC_JACK_BUTTON_MASK;
-	}
-exit:
-	pr_debug("%s: leave\n", __func__);
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_mbhc_hphl_ocp_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-	int val;
-
-	pr_debug("%s: received HPHL OCP irq\n", __func__);
-	if (mbhc) {
-		if (mbhc->mbhc_cb->hph_register_recovery) {
-			if (mbhc->mbhc_cb->hph_register_recovery(mbhc)) {
-				WCD_MBHC_REG_READ(WCD_MBHC_HPHR_OCP_STATUS,
-						  val);
-				if ((val != -EINVAL) && val)
-					mbhc->is_hph_ocp_pending = true;
-				goto done;
-			}
-		}
-
-		if (mbhc->hphlocp_cnt < OCP_ATTEMPT) {
-			mbhc->hphlocp_cnt++;
-			pr_debug("%s: retry, hphlocp_cnt: %d\n", __func__,
-				 mbhc->hphlocp_cnt);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0);
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1);
-		} else {
-			mbhc->mbhc_cb->irq_control(mbhc->codec,
-						   mbhc->intr_ids->hph_left_ocp,
-						   false);
-			mbhc->hph_status |= SND_JACK_OC_HPHL;
-			wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-					    mbhc->hph_status,
-					    WCD_MBHC_JACK_MASK);
-		}
-	} else {
-		pr_err("%s: Bad wcd9xxx_spmi private data\n", __func__);
-	}
-done:
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data)
-{
-	struct wcd_mbhc *mbhc = data;
-
-	pr_debug("%s: received HPHR OCP irq\n", __func__);
-
-	if (!mbhc) {
-		pr_err("%s: Bad mbhc private data\n", __func__);
-		goto done;
-	}
-
-	if (mbhc->is_hph_ocp_pending) {
-		mbhc->is_hph_ocp_pending = false;
-		goto done;
-	}
-
-	if (mbhc->mbhc_cb->hph_register_recovery) {
-		if (mbhc->mbhc_cb->hph_register_recovery(mbhc))
-			/* register corruption, hence reset registers */
-			goto done;
-	}
-	if (mbhc->hphrocp_cnt < OCP_ATTEMPT) {
-		mbhc->hphrocp_cnt++;
-		pr_debug("%s: retry, hphrocp_cnt: %d\n", __func__,
-			 mbhc->hphrocp_cnt);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0);
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1);
-	} else {
-		mbhc->mbhc_cb->irq_control(mbhc->codec,
-					   mbhc->intr_ids->hph_right_ocp,
-					   false);
-		mbhc->hph_status |= SND_JACK_OC_HPHR;
-		wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
-				    mbhc->hph_status, WCD_MBHC_JACK_MASK);
-	}
-done:
-	return IRQ_HANDLED;
-}
-
-static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	pr_debug("%s: enter\n", __func__);
-	WCD_MBHC_RSC_LOCK(mbhc);
-
-	/* enable HS detection */
-	if (mbhc->mbhc_cb->hph_pull_up_control)
-		mbhc->mbhc_cb->hph_pull_up_control(codec, I_DEFAULT);
-	else
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3);
-
-	if (mbhc->mbhc_cfg->moisture_en && mbhc->mbhc_cb->mbhc_moisture_config)
-		mbhc->mbhc_cb->mbhc_moisture_config(mbhc);
-
-	/*
-	 * For USB analog we need to override the switch configuration.
-	 * Also, disable hph_l pull-up current source as HS_DET_L is driven
-	 * by an external source
-	 */
-	if (mbhc->mbhc_cfg->enable_usbc_analog) {
-		mbhc->hphl_swh = 1;
-		mbhc->gnd_swh = 1;
-
-		if (mbhc->mbhc_cb->hph_pull_up_control)
-			mbhc->mbhc_cb->hph_pull_up_control(codec, I_OFF);
-		else
-			WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL,
-						 0);
-	}
-
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_PLUG_TYPE, mbhc->hphl_swh);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_PLUG_TYPE, mbhc->gnd_swh);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_SW_HPH_LP_100K_TO_GND, 1);
-	if (mbhc->mbhc_cfg->gnd_det_en && mbhc->mbhc_cb->mbhc_gnd_det_ctrl)
-		mbhc->mbhc_cb->mbhc_gnd_det_ctrl(codec, true);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1);
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1);
-
-	if (mbhc->mbhc_cfg->enable_usbc_analog) {
-		/* Insertion debounce set to 48ms */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 4);
-	} else {
-		/* Insertion debounce set to 96ms */
-		WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 6);
-	}
-
-	/* Button Debounce set to 16ms */
-	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_DBNC, 2);
-
-	/* Enable micbias ramp */
-	if (mbhc->mbhc_cb->mbhc_micb_ramp_control)
-		mbhc->mbhc_cb->mbhc_micb_ramp_control(codec, true);
-	/* enable bias */
-	mbhc->mbhc_cb->mbhc_bias(codec, true);
-	/* enable MBHC clock */
-	if (mbhc->mbhc_cb->clk_setup)
-		mbhc->mbhc_cb->clk_setup(codec, true);
-
-	/* program HS_VREF value */
-	wcd_program_hs_vref(mbhc);
-
-	wcd_program_btn_threshold(mbhc, false);
-
-
-	reinit_completion(&mbhc->btn_press_compl);
-
-	WCD_MBHC_RSC_UNLOCK(mbhc);
-	pr_debug("%s: leave\n", __func__);
-	return ret;
-}
-
-static void wcd_mbhc_fw_read(struct work_struct *work)
-{
-	struct delayed_work *dwork;
-	struct wcd_mbhc *mbhc;
-	struct snd_soc_codec *codec;
-	const struct firmware *fw;
-	struct firmware_cal *fw_data = NULL;
-	int ret = -1, retry = 0;
-	bool use_default_cal = false;
-
-	dwork = to_delayed_work(work);
-	mbhc = container_of(dwork, struct wcd_mbhc, mbhc_firmware_dwork);
-	codec = mbhc->codec;
-
-	while (retry < FW_READ_ATTEMPTS) {
-		retry++;
-		pr_debug("%s:Attempt %d to request MBHC firmware\n",
-			__func__, retry);
-		if (mbhc->mbhc_cb->get_hwdep_fw_cal)
-			fw_data = mbhc->mbhc_cb->get_hwdep_fw_cal(mbhc,
-					WCD9XXX_MBHC_CAL);
-		if (!fw_data)
-			ret = request_firmware(&fw, "wcd9320/wcd9320_mbhc.bin",
-				       codec->dev);
-		/*
-		 * if request_firmware and hwdep cal both fail then
-		 * sleep for 4sec for the userspace to send data to kernel
-		 * retry for few times before bailing out
-		 */
-		if ((ret != 0) && !fw_data) {
-			usleep_range(FW_READ_TIMEOUT, FW_READ_TIMEOUT +
-					WCD_MBHC_USLEEP_RANGE_MARGIN_US);
-		} else {
-			pr_debug("%s: MBHC Firmware read successful\n",
-					__func__);
-			break;
-		}
-	}
-	if (!fw_data)
-		pr_debug("%s: using request_firmware\n", __func__);
-	else
-		pr_debug("%s: using hwdep cal\n", __func__);
-
-	if (ret != 0 && !fw_data) {
-		pr_err("%s: Cannot load MBHC firmware use default cal\n",
-		       __func__);
-		use_default_cal = true;
-	}
-	if (!use_default_cal) {
-		const void *data;
-		size_t size;
-
-		if (fw_data) {
-			data = fw_data->data;
-			size = fw_data->size;
-		} else {
-			data = fw->data;
-			size = fw->size;
-		}
-		if (wcd_mbhc_fw_validate(data, size) == false) {
-			pr_err("%s: Invalid MBHC cal data size use default cal\n",
-				__func__);
-			if (!fw_data)
-				release_firmware(fw);
-		} else {
-			if (fw_data) {
-				mbhc->mbhc_cfg->calibration =
-					(void *)fw_data->data;
-				mbhc->mbhc_cal = fw_data;
-			} else {
-				mbhc->mbhc_cfg->calibration =
-					(void *)fw->data;
-				mbhc->mbhc_fw = fw;
-			}
-		}
-
-	}
-
-	(void) wcd_mbhc_initialise(mbhc);
-}
-
-static int wcd_mbhc_set_keycode(struct wcd_mbhc *mbhc)
-{
-	enum snd_jack_types type;
-	int i, ret, result = 0;
-	int *btn_key_code;
-
-	btn_key_code = mbhc->mbhc_cfg->key_code;
-
-	for (i = 0 ; i < WCD_MBHC_KEYCODE_NUM ; i++) {
-		if (btn_key_code[i] != 0) {
-			switch (i) {
-			case 0:
-				type = SND_JACK_BTN_0;
-				break;
-			case 1:
-				type = SND_JACK_BTN_1;
-				break;
-			case 2:
-				type = SND_JACK_BTN_2;
-				break;
-			case 3:
-				type = SND_JACK_BTN_3;
-				break;
-			case 4:
-				type = SND_JACK_BTN_4;
-				break;
-			case 5:
-				type = SND_JACK_BTN_5;
-				break;
-			default:
-				WARN_ONCE(1, "Wrong button number:%d\n", i);
-				result = -1;
-				return result;
-			}
-			ret = snd_jack_set_key(mbhc->button_jack.jack,
-							type,
-							btn_key_code[i]);
-			if (ret) {
-				pr_err("%s: Failed to set code for %d\n",
-					__func__, btn_key_code[i]);
-				result = -1;
-				return result;
-			}
-			input_set_capability(
-				mbhc->button_jack.jack->input_dev,
-				EV_KEY, btn_key_code[i]);
-			pr_debug("%s: set btn%d key code:%d\n", __func__,
-				i, btn_key_code[i]);
-		}
-	}
-	if (btn_key_code[0])
-		mbhc->is_btn_already_regd = true;
-	return result;
-}
-
-static int wcd_mbhc_usb_c_analog_setup_gpios(struct wcd_mbhc *mbhc,
-					     bool active)
-{
-	int rc = 0;
-	struct usbc_ana_audio_config *config =
-		&mbhc->mbhc_cfg->usbc_analog_cfg;
-	union power_supply_propval pval;
-
-	dev_dbg(mbhc->codec->dev, "%s: setting GPIOs active = %d\n",
-		__func__, active);
-
-	memset(&pval, 0, sizeof(pval));
-
-	if (active) {
-		pval.intval = POWER_SUPPLY_TYPEC_PR_SOURCE;
-		if (power_supply_set_property(mbhc->usb_psy,
-				POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, &pval))
-			dev_info(mbhc->codec->dev, "%s: force PR_SOURCE mode unsuccessful\n",
-				 __func__);
-		else
-			mbhc->usbc_force_pr_mode = true;
-
-		if (config->usbc_en1_gpio_p)
-			rc = msm_cdc_pinctrl_select_active_state(
-				config->usbc_en1_gpio_p);
-		if (rc == 0 && config->usbc_force_gpio_p)
-			rc = msm_cdc_pinctrl_select_active_state(
-				config->usbc_force_gpio_p);
-		mbhc->usbc_mode = POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER;
-	} else {
-		/* no delay is required when disabling GPIOs */
-		if (config->usbc_en1_gpio_p)
-			msm_cdc_pinctrl_select_sleep_state(
-				config->usbc_en1_gpio_p);
-		if (config->usbc_force_gpio_p)
-			msm_cdc_pinctrl_select_sleep_state(
-				config->usbc_force_gpio_p);
-
-		if (mbhc->usbc_force_pr_mode) {
-			pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL;
-			if (power_supply_set_property(mbhc->usb_psy,
-				POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, &pval))
-				dev_info(mbhc->codec->dev, "%s: force PR_DUAL mode unsuccessful\n",
-					 __func__);
-
-			mbhc->usbc_force_pr_mode = false;
-		}
-
-		mbhc->usbc_mode = POWER_SUPPLY_TYPEC_NONE;
-		if (mbhc->mbhc_cfg->swap_gnd_mic)
-			mbhc->mbhc_cfg->swap_gnd_mic(mbhc->codec, false);
-	}
-
-	return rc;
-}
-
-/* workqueue */
-static void wcd_mbhc_usbc_analog_work_fn(struct work_struct *work)
-{
-	struct wcd_mbhc *mbhc =
-		container_of(work, struct wcd_mbhc, usbc_analog_work);
-
-	wcd_mbhc_usb_c_analog_setup_gpios(mbhc,
-			mbhc->usbc_mode != POWER_SUPPLY_TYPEC_NONE);
-}
-
-/* this callback function is used to process PMI notification */
-static int wcd_mbhc_usb_c_event_changed(struct notifier_block *nb,
-					unsigned long evt, void *ptr)
-{
-	int ret;
-	union power_supply_propval mode;
-	struct wcd_mbhc *mbhc = container_of(nb, struct wcd_mbhc, psy_nb);
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	if (ptr != mbhc->usb_psy || evt != PSY_EVENT_PROP_CHANGED)
-		return 0;
-
-	ret = power_supply_get_property(mbhc->usb_psy,
-			POWER_SUPPLY_PROP_TYPEC_MODE, &mode);
-	if (ret) {
-		dev_err(codec->dev, "%s: Unable to read USB TYPEC_MODE: %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	dev_dbg(codec->dev, "%s: USB change event received\n",
-		__func__);
-	dev_dbg(codec->dev, "%s: supply mode %d, expected %d\n", __func__,
-		mode.intval, POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER);
-
-	switch (mode.intval) {
-	case POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER:
-	case POWER_SUPPLY_TYPEC_NONE:
-		dev_dbg(codec->dev, "%s: usbc_mode: %d; mode.intval: %d\n",
-			__func__, mbhc->usbc_mode, mode.intval);
-
-		if (mbhc->usbc_mode == mode.intval)
-			break; /* filter notifications received before */
-		mbhc->usbc_mode = mode.intval;
-
-		dev_dbg(codec->dev, "%s: queueing usbc_analog_work\n",
-			__func__);
-		schedule_work(&mbhc->usbc_analog_work);
-		break;
-	default:
-		break;
-	}
-	return ret;
-}
-
-/* PMI registration code */
-static int wcd_mbhc_usb_c_analog_init(struct wcd_mbhc *mbhc)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	dev_dbg(mbhc->codec->dev, "%s: usb-c analog setup start\n", __func__);
-	INIT_WORK(&mbhc->usbc_analog_work, wcd_mbhc_usbc_analog_work_fn);
-
-	mbhc->usb_psy = power_supply_get_by_name("usb");
-	if (IS_ERR_OR_NULL(mbhc->usb_psy)) {
-		dev_err(codec->dev, "%s: could not get USB psy info\n",
-			__func__);
-		ret = -EPROBE_DEFER;
-		if (IS_ERR(mbhc->usb_psy))
-			ret = PTR_ERR(mbhc->usb_psy);
-		mbhc->usb_psy = NULL;
-		goto err;
-	}
-
-	ret = wcd_mbhc_usb_c_analog_setup_gpios(mbhc, false);
-	if (ret) {
-		dev_err(codec->dev, "%s: error while setting USBC ana gpios\n",
-			__func__);
-		goto err;
-	}
-
-	mbhc->psy_nb.notifier_call = wcd_mbhc_usb_c_event_changed;
-	mbhc->psy_nb.priority = 0;
-	ret = power_supply_reg_notifier(&mbhc->psy_nb);
-	if (ret) {
-		dev_err(codec->dev, "%s: power supply registration failed\n",
-			__func__);
-		goto err;
-	}
-
-	/*
-	 * as part of the init sequence check if there is a connected
-	 * USB C analog adapter
-	 */
-	dev_dbg(mbhc->codec->dev, "%s: verify if USB adapter is already inserted\n",
-		__func__);
-	ret = wcd_mbhc_usb_c_event_changed(&mbhc->psy_nb,
-					   PSY_EVENT_PROP_CHANGED,
-					   mbhc->usb_psy);
-
-err:
-	return ret;
-}
-
-static int wcd_mbhc_usb_c_analog_deinit(struct wcd_mbhc *mbhc)
-{
-	wcd_mbhc_usb_c_analog_setup_gpios(mbhc, false);
-
-	/* deregister from PMI */
-	power_supply_unreg_notifier(&mbhc->psy_nb);
-
-	return 0;
-}
-
-static int wcd_mbhc_init_gpio(struct wcd_mbhc *mbhc,
-			      struct wcd_mbhc_config *mbhc_cfg,
-			      const char *gpio_dt_str,
-			      int *gpio, struct device_node **gpio_dn)
-{
-	int rc = 0;
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct snd_soc_card *card = codec->component.card;
-
-	dev_dbg(mbhc->codec->dev, "%s: gpio %s\n", __func__, gpio_dt_str);
-
-	*gpio_dn = of_parse_phandle(card->dev->of_node, gpio_dt_str, 0);
-
-	if (!(*gpio_dn)) {
-		*gpio = of_get_named_gpio(card->dev->of_node, gpio_dt_str, 0);
-		if (!gpio_is_valid(*gpio)) {
-			dev_err(card->dev, "%s, property %s not in node %s",
-				__func__, gpio_dt_str,
-				card->dev->of_node->full_name);
-			rc = -EINVAL;
-		}
-	}
-
-	return rc;
-}
-
-int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg)
-{
-	int rc = 0;
-	struct usbc_ana_audio_config *config;
-	struct snd_soc_codec *codec;
-	struct snd_soc_card *card;
-	const char *usb_c_dt = "qcom,msm-mbhc-usbc-audio-supported";
-
-	if (!mbhc || !mbhc_cfg)
-		return -EINVAL;
-
-	config = &mbhc_cfg->usbc_analog_cfg;
-	codec = mbhc->codec;
-	card = codec->component.card;
-
-	/* update the mbhc config */
-	mbhc->mbhc_cfg = mbhc_cfg;
-
-	dev_dbg(mbhc->codec->dev, "%s: enter\n", __func__);
-
-	/* check if USB C analog is defined on device tree */
-	mbhc_cfg->enable_usbc_analog = 0;
-	if (of_find_property(card->dev->of_node, usb_c_dt, NULL)) {
-		rc = of_property_read_u32(card->dev->of_node, usb_c_dt,
-				&mbhc_cfg->enable_usbc_analog);
-	}
-	if (mbhc_cfg->enable_usbc_analog == 0 || rc != 0) {
-		dev_info(card->dev,
-				"%s: %s in dt node is missing or false\n",
-				__func__, usb_c_dt);
-		dev_info(card->dev,
-			"%s: skipping USB c analog configuration\n", __func__);
-	}
-
-	/* initialize GPIOs */
-	if (mbhc_cfg->enable_usbc_analog) {
-		dev_dbg(mbhc->codec->dev, "%s: usbc analog enabled\n",
-				__func__);
-		rc = wcd_mbhc_init_gpio(mbhc, mbhc_cfg,
-				"qcom,usbc-analog-en1-gpio",
-				&config->usbc_en1_gpio,
-				&config->usbc_en1_gpio_p);
-		if (rc)
-			goto err;
-
-		if (of_find_property(card->dev->of_node,
-				     "qcom,usbc-analog-force_detect_gpio",
-				     NULL)) {
-			rc = wcd_mbhc_init_gpio(mbhc, mbhc_cfg,
-					"qcom,usbc-analog-force_detect_gpio",
-					&config->usbc_force_gpio,
-					&config->usbc_force_gpio_p);
-			if (rc)
-				goto err;
-		}
-
-		dev_dbg(mbhc->codec->dev, "%s: calling usb_c_analog_init\n",
-			__func__);
-		/* init PMI notifier */
-		rc = wcd_mbhc_usb_c_analog_init(mbhc);
-		if (rc) {
-			rc = EPROBE_DEFER;
-			goto err;
-		}
-	}
-
-	/* Set btn key code */
-	if ((!mbhc->is_btn_already_regd) && wcd_mbhc_set_keycode(mbhc))
-		pr_err("Set btn key code error!!!\n");
-
-	if (!mbhc->mbhc_cfg->read_fw_bin ||
-	    (mbhc->mbhc_cfg->read_fw_bin && mbhc->mbhc_fw) ||
-	    (mbhc->mbhc_cfg->read_fw_bin && mbhc->mbhc_cal)) {
-		rc = wcd_mbhc_initialise(mbhc);
-	} else {
-		if (!mbhc->mbhc_fw || !mbhc->mbhc_cal)
-			schedule_delayed_work(&mbhc->mbhc_firmware_dwork,
-				      usecs_to_jiffies(FW_READ_TIMEOUT));
-		else
-			pr_err("%s: Skipping to read mbhc fw, 0x%pK %pK\n",
-				 __func__, mbhc->mbhc_fw, mbhc->mbhc_cal);
-	}
-
-	return rc;
-err:
-	if (config->usbc_en1_gpio > 0) {
-		dev_dbg(card->dev, "%s free usb en1 gpio %d\n",
-			__func__, config->usbc_en1_gpio);
-		gpio_free(config->usbc_en1_gpio);
-		config->usbc_en1_gpio = 0;
-	}
-	if (config->usbc_force_gpio > 0) {
-		dev_dbg(card->dev, "%s free usb_force gpio %d\n",
-			__func__, config->usbc_force_gpio);
-		gpio_free(config->usbc_force_gpio);
-		config->usbc_force_gpio = 0;
-	}
-	if (config->usbc_en1_gpio_p)
-		of_node_put(config->usbc_en1_gpio_p);
-	if (config->usbc_force_gpio_p)
-		of_node_put(config->usbc_force_gpio_p);
-	dev_dbg(mbhc->codec->dev, "%s: leave %d\n", __func__, rc);
-	return rc;
-}
-EXPORT_SYMBOL(wcd_mbhc_start);
-
-void wcd_mbhc_stop(struct wcd_mbhc *mbhc)
-{
-	struct usbc_ana_audio_config *config = &mbhc->mbhc_cfg->usbc_analog_cfg;
-
-	pr_debug("%s: enter\n", __func__);
-
-	if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) {
-		if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect)
-			mbhc->mbhc_cb->skip_imped_detect(mbhc->codec);
-	}
-	mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
-	mbhc->hph_status = 0;
-	if (mbhc->mbhc_cb && mbhc->mbhc_cb->irq_control) {
-		mbhc->mbhc_cb->irq_control(mbhc->codec,
-				mbhc->intr_ids->hph_left_ocp,
-				false);
-		mbhc->mbhc_cb->irq_control(mbhc->codec,
-				mbhc->intr_ids->hph_right_ocp,
-				false);
-	}
-	if (mbhc->mbhc_fw || mbhc->mbhc_cal) {
-		cancel_delayed_work_sync(&mbhc->mbhc_firmware_dwork);
-		if (!mbhc->mbhc_cal)
-			release_firmware(mbhc->mbhc_fw);
-		mbhc->mbhc_fw = NULL;
-		mbhc->mbhc_cal = NULL;
-	}
-
-	if (mbhc->mbhc_cfg->enable_usbc_analog) {
-		wcd_mbhc_usb_c_analog_deinit(mbhc);
-		/* free GPIOs */
-		if (config->usbc_en1_gpio > 0)
-			gpio_free(config->usbc_en1_gpio);
-		if (config->usbc_force_gpio)
-			gpio_free(config->usbc_force_gpio);
-
-		if (config->usbc_en1_gpio_p)
-			of_node_put(config->usbc_en1_gpio_p);
-		if (config->usbc_force_gpio_p)
-			of_node_put(config->usbc_force_gpio_p);
-	}
-
-	pr_debug("%s: leave\n", __func__);
-}
-EXPORT_SYMBOL(wcd_mbhc_stop);
-
-/*
- * wcd_mbhc_init : initialize MBHC internal structures.
- *
- * NOTE: mbhc->mbhc_cfg is not YET configure so shouldn't be used
- */
-int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
-		      const struct wcd_mbhc_cb *mbhc_cb,
-		      const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
-		      struct wcd_mbhc_register *wcd_mbhc_regs,
-		      bool impedance_det_en)
-{
-	int ret = 0;
-	int hph_swh = 0;
-	int gnd_swh = 0;
-	u32 hph_moist_config[3];
-	struct snd_soc_card *card = codec->component.card;
-	const char *hph_switch = "qcom,msm-mbhc-hphl-swh";
-	const char *gnd_switch = "qcom,msm-mbhc-gnd-swh";
-
-	pr_debug("%s: enter\n", __func__);
-
-	ret = of_property_read_u32(card->dev->of_node, hph_switch, &hph_swh);
-	if (ret) {
-		dev_err(card->dev,
-			"%s: missing %s in dt node\n", __func__, hph_switch);
-		goto err;
-	}
-
-	ret = of_property_read_u32(card->dev->of_node, gnd_switch, &gnd_swh);
-	if (ret) {
-		dev_err(card->dev,
-			"%s: missing %s in dt node\n", __func__, gnd_switch);
-		goto err;
-	}
-
-	ret = of_property_read_u32_array(card->dev->of_node,
-					 "qcom,msm-mbhc-moist-cfg",
-					 hph_moist_config, 3);
-	if (ret) {
-		dev_dbg(card->dev, "%s: no qcom,msm-mbhc-moist-cfg in DT\n",
-			__func__);
-		mbhc->moist_vref = V_45_MV;
-		mbhc->moist_iref = I_3P0_UA;
-		mbhc->moist_rref = R_24_KOHM;
-	} else {
-		mbhc->moist_vref = hph_moist_config[0];
-		mbhc->moist_iref = hph_moist_config[1];
-		mbhc->moist_rref = hph_moist_config[2];
-	}
-
-	mbhc->in_swch_irq_handler = false;
-	mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
-	mbhc->is_btn_press = false;
-	mbhc->codec = codec;
-	mbhc->intr_ids = mbhc_cdc_intr_ids;
-	mbhc->impedance_detect = impedance_det_en;
-	mbhc->hphl_swh = hph_swh;
-	mbhc->gnd_swh = gnd_swh;
-	mbhc->micbias_enable = false;
-	mbhc->mbhc_cb = mbhc_cb;
-	mbhc->btn_press_intr = false;
-	mbhc->is_hs_recording = false;
-	mbhc->is_extn_cable = false;
-	mbhc->extn_cable_hph_rem = false;
-	mbhc->hph_type = WCD_MBHC_HPH_NONE;
-	mbhc->wcd_mbhc_regs = wcd_mbhc_regs;
-
-	if (mbhc->intr_ids == NULL) {
-		pr_err("%s: Interrupt mapping not provided\n", __func__);
-		return -EINVAL;
-	}
-	if (!mbhc->wcd_mbhc_regs) {
-		dev_err(codec->dev, "%s: mbhc registers are not defined\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	/* Check if IRQ and other required callbacks are defined or not */
-	if (!mbhc_cb || !mbhc_cb->request_irq || !mbhc_cb->irq_control ||
-	    !mbhc_cb->free_irq || !mbhc_cb->map_btn_code_to_num ||
-	    !mbhc_cb->lock_sleep || !mbhc_cb->mbhc_bias ||
-	    !mbhc_cb->set_btn_thr) {
-		dev_err(codec->dev, "%s: required mbhc callbacks are not defined\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	/* No need to create new sound card jacks if is is already created */
-	if (mbhc->headset_jack.jack == NULL) {
-		ret = snd_soc_card_jack_new(codec->component.card,
-					    "Headset Jack", WCD_MBHC_JACK_MASK,
-					    &mbhc->headset_jack, NULL, 0);
-		if (ret) {
-			pr_err("%s: Failed to create new jack\n", __func__);
-			return ret;
-		}
-
-		ret = snd_soc_card_jack_new(codec->component.card,
-					    "Button Jack",
-					    WCD_MBHC_JACK_BUTTON_MASK,
-					    &mbhc->button_jack, NULL, 0);
-		if (ret) {
-			pr_err("Failed to create new jack\n");
-			return ret;
-		}
-
-		ret = snd_jack_set_key(mbhc->button_jack.jack,
-				       SND_JACK_BTN_0,
-				       KEY_MEDIA);
-		if (ret) {
-			pr_err("%s: Failed to set code for btn-0\n",
-				__func__);
-			return ret;
-		}
-
-		INIT_DELAYED_WORK(&mbhc->mbhc_firmware_dwork,
-				  wcd_mbhc_fw_read);
-		INIT_DELAYED_WORK(&mbhc->mbhc_btn_dwork, wcd_btn_lpress_fn);
-	}
-	mutex_init(&mbhc->hphl_pa_lock);
-	mutex_init(&mbhc->hphr_pa_lock);
-	init_completion(&mbhc->btn_press_compl);
-
-	/* Register event notifier */
-	mbhc->nblock.notifier_call = wcd_event_notify;
-	if (mbhc->mbhc_cb->register_notifier) {
-		ret = mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock,
-						       true);
-		if (ret) {
-			pr_err("%s: Failed to register notifier %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-
-	init_waitqueue_head(&mbhc->wait_btn_press);
-	mutex_init(&mbhc->codec_resource_lock);
-
-	switch (mbhc->mbhc_detection_logic) {
-	case WCD_DETECTION_LEGACY:
-		wcd_mbhc_legacy_init(mbhc);
-		break;
-	case WCD_DETECTION_ADC:
-		wcd_mbhc_adc_init(mbhc);
-		break;
-	default:
-		pr_err("%s: Unknown detection logic type %d\n",
-			__func__, mbhc->mbhc_detection_logic);
-		break;
-	}
-
-	if (!mbhc->mbhc_fn ||
-	    !mbhc->mbhc_fn->wcd_mbhc_hs_ins_irq ||
-	    !mbhc->mbhc_fn->wcd_mbhc_hs_rem_irq ||
-	    !mbhc->mbhc_fn->wcd_mbhc_detect_plug_type ||
-	    !mbhc->mbhc_fn->wcd_cancel_hs_detect_plug) {
-		pr_err("%s: mbhc function pointer is NULL\n", __func__);
-		goto err_mbhc_sw_irq;
-	}
-	ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->mbhc_sw_intr,
-				  wcd_mbhc_mech_plug_detect_irq,
-				  "mbhc sw intr", mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d, ret = %d\n", __func__,
-		       mbhc->intr_ids->mbhc_sw_intr, ret);
-		goto err_mbhc_sw_irq;
-	}
-
-	ret = mbhc->mbhc_cb->request_irq(codec,
-					 mbhc->intr_ids->mbhc_btn_press_intr,
-					 wcd_mbhc_btn_press_handler,
-					 "Button Press detect", mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       mbhc->intr_ids->mbhc_btn_press_intr);
-		goto err_btn_press_irq;
-	}
-
-	ret = mbhc->mbhc_cb->request_irq(codec,
-					 mbhc->intr_ids->mbhc_btn_release_intr,
-					 wcd_mbhc_release_handler,
-					 "Button Release detect", mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-			mbhc->intr_ids->mbhc_btn_release_intr);
-		goto err_btn_release_irq;
-	}
-
-	ret = mbhc->mbhc_cb->request_irq(codec,
-					 mbhc->intr_ids->mbhc_hs_ins_intr,
-					 mbhc->mbhc_fn->wcd_mbhc_hs_ins_irq,
-					 "Elect Insert", mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       mbhc->intr_ids->mbhc_hs_ins_intr);
-		goto err_mbhc_hs_ins_irq;
-	}
-	mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_ins_intr,
-				   false);
-	clear_bit(WCD_MBHC_ELEC_HS_INS, &mbhc->intr_status);
-
-	ret = mbhc->mbhc_cb->request_irq(codec,
-					 mbhc->intr_ids->mbhc_hs_rem_intr,
-					 mbhc->mbhc_fn->wcd_mbhc_hs_rem_irq,
-					 "Elect Remove", mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       mbhc->intr_ids->mbhc_hs_rem_intr);
-		goto err_mbhc_hs_rem_irq;
-	}
-	mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_rem_intr,
-				   false);
-	clear_bit(WCD_MBHC_ELEC_HS_REM, &mbhc->intr_status);
-
-	ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_left_ocp,
-				  wcd_mbhc_hphl_ocp_irq, "HPH_L OCP detect",
-				  mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       mbhc->intr_ids->hph_left_ocp);
-		goto err_hphl_ocp_irq;
-	}
-
-	ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_right_ocp,
-				  wcd_mbhc_hphr_ocp_irq, "HPH_R OCP detect",
-				  mbhc);
-	if (ret) {
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       mbhc->intr_ids->hph_right_ocp);
-		goto err_hphr_ocp_irq;
-	}
-
-	pr_debug("%s: leave ret %d\n", __func__, ret);
-	return ret;
-
-err_hphr_ocp_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc);
-err_hphl_ocp_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc);
-err_mbhc_hs_rem_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc);
-err_mbhc_hs_ins_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr,
-				mbhc);
-err_btn_release_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr,
-				mbhc);
-err_btn_press_irq:
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc);
-err_mbhc_sw_irq:
-	if (mbhc->mbhc_cb->register_notifier)
-		mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false);
-	mutex_destroy(&mbhc->codec_resource_lock);
-err:
-	pr_debug("%s: leave ret %d\n", __func__, ret);
-	return ret;
-}
-EXPORT_SYMBOL(wcd_mbhc_init);
-
-void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr,
-				mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr,
-				mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc);
-	mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_right_ocp, mbhc);
-	if (mbhc->mbhc_cb && mbhc->mbhc_cb->register_notifier)
-		mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false);
-	if (mbhc->mbhc_fn->wcd_cancel_hs_detect_plug) {
-		WCD_MBHC_RSC_LOCK(mbhc);
-		mbhc->mbhc_fn->wcd_cancel_hs_detect_plug(mbhc,
-					&mbhc->correct_plug_swch);
-		WCD_MBHC_RSC_UNLOCK(mbhc);
-	}
-	mutex_destroy(&mbhc->codec_resource_lock);
-	mutex_destroy(&mbhc->hphl_pa_lock);
-	mutex_destroy(&mbhc->hphr_pa_lock);
-}
-EXPORT_SYMBOL(wcd_mbhc_deinit);
-
-MODULE_DESCRIPTION("wcd MBHC v2 module");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h
deleted file mode 100644
index c8714fc..0000000
--- a/sound/soc/codecs/wcd-mbhc-v2.h
+++ /dev/null
@@ -1,598 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_MBHC_V2_H__
-#define __WCD_MBHC_V2_H__
-
-#include <linux/wait.h>
-#include <linux/stringify.h>
-#include <linux/power_supply.h>
-#include "wcdcal-hwdep.h"
-
-#define TOMBAK_MBHC_NC	0
-#define TOMBAK_MBHC_NO	1
-#define WCD_MBHC_DEF_BUTTONS 8
-#define WCD_MBHC_KEYCODE_NUM 8
-#define WCD_MBHC_USLEEP_RANGE_MARGIN_US 100
-#define WCD_MBHC_THR_HS_MICB_MV  2700
-/* z value defined in Ohms */
-#define WCD_MONO_HS_MIN_THR	2
-#define WCD_MBHC_STRINGIFY(s)  __stringify(s)
-
-#define WCD_MBHC_REGISTER(rid, rreg, rmask, rshift, rinvert) \
-{ .id = rid, .reg = rreg, .mask = rmask, .offset = rshift, .invert = rinvert }
-
-#define WCD_MBHC_RSC_LOCK(mbhc)			\
-{							\
-	pr_debug("%s: Acquiring BCL\n", __func__);	\
-	mutex_lock(&mbhc->codec_resource_lock);		\
-	pr_debug("%s: Acquiring BCL done\n", __func__);	\
-}
-
-#define WCD_MBHC_RSC_UNLOCK(mbhc)			\
-{							\
-	pr_debug("%s: Release BCL\n", __func__);	\
-	mutex_unlock(&mbhc->codec_resource_lock);	\
-}
-
-#define WCD_MBHC_RSC_ASSERT_LOCKED(mbhc)		\
-{							\
-	WARN_ONCE(!mutex_is_locked(&mbhc->codec_resource_lock), \
-		  "%s: BCL should have acquired\n", __func__); \
-}
-
-/*
- * Macros to update and read mbhc register bits. Check for
- * "0" before updating or reading the register, because it
- * is possible that one codec wants to write to that bit and
- * other codec does not.
- */
-#define WCD_MBHC_REG_UPDATE_BITS(function, val)         \
-do {                                                    \
-	if (mbhc->wcd_mbhc_regs[function].reg) {        \
-		snd_soc_update_bits(mbhc->codec,	\
-		mbhc->wcd_mbhc_regs[function].reg,	\
-		mbhc->wcd_mbhc_regs[function].mask,	\
-		val << (mbhc->wcd_mbhc_regs[function].offset)); \
-	}                                               \
-} while (0)
-
-#define WCD_MBHC_REG_READ(function, val)	        \
-do {                                                    \
-	if (mbhc->wcd_mbhc_regs[function].reg) {        \
-		val = (((snd_soc_read(mbhc->codec,	\
-		mbhc->wcd_mbhc_regs[function].reg)) &	\
-		(mbhc->wcd_mbhc_regs[function].mask)) >> \
-		(mbhc->wcd_mbhc_regs[function].offset)); \
-	} else {                                         \
-		val = -EINVAL;                           \
-	}                                                \
-} while (0)
-
-#define WCD_MBHC_CAL_SIZE(buttons, rload) ( \
-	sizeof(struct wcd_mbhc_general_cfg) + \
-	sizeof(struct wcd_mbhc_plug_detect_cfg) + \
-	((sizeof(s16) + sizeof(s16)) * buttons) + \
-	    sizeof(struct wcd_mbhc_plug_type_cfg) + \
-	sizeof(struct wcd_mbhc_btn_detect_cfg) + \
-	sizeof(struct wcd_mbhc_imped_detect_cfg) + \
-		((sizeof(u16) + sizeof(u16)) * rload) \
-	)
-
-#define WCD_MBHC_CAL_GENERAL_PTR(cali) ( \
-	(struct wcd_mbhc_general_cfg *) cali)
-#define WCD_MBHC_CAL_PLUG_DET_PTR(cali) ( \
-	(struct wcd_mbhc_plug_detect_cfg *) \
-	&(WCD_MBHC_CAL_GENERAL_PTR(cali)[1]))
-#define WCD_MBHC_CAL_PLUG_TYPE_PTR(cali) ( \
-	(struct wcd_mbhc_plug_type_cfg *) \
-	&(WCD_MBHC_CAL_PLUG_DET_PTR(cali)[1]))
-#define WCD_MBHC_CAL_BTN_DET_PTR(cali) ( \
-	    (struct wcd_mbhc_btn_detect_cfg *) \
-	&(WCD_MBHC_CAL_PLUG_TYPE_PTR(cali)[1]))
-#define WCD_MBHC_CAL_IMPED_DET_PTR(cali) ( \
-	(struct wcd_mbhc_imped_detect_cfg *) \
-	(((void *)&WCD_MBHC_CAL_BTN_DET_PTR(cali)[1]) + \
-	(WCD_MBHC_CAL_BTN_DET_PTR(cali)->num_btn * \
-	(sizeof(WCD_MBHC_CAL_BTN_DET_PTR(cali)->_v_btn_low[0]) + \
-	sizeof(WCD_MBHC_CAL_BTN_DET_PTR(cali)->_v_btn_high[0])))) \
-	)
-
-#define WCD_MBHC_CAL_MIN_SIZE ( \
-	sizeof(struct wcd_mbhc_general_cfg) + \
-	sizeof(struct wcd_mbhc_plug_detect_cfg) + \
-	sizeof(struct wcd_mbhc_plug_type_cfg) + \
-	sizeof(struct wcd_mbhc_btn_detect_cfg) + \
-	sizeof(struct wcd_mbhc_imped_detect_cfg) + \
-	(sizeof(u16)*2)  \
-	)
-
-#define WCD_MBHC_CAL_BTN_SZ(cfg_ptr) ( \
-	sizeof(struct wcd_mbhc_btn_detect_cfg) + \
-	(cfg_ptr->num_btn * (sizeof(cfg_ptr->_v_btn_low[0]) + \
-			sizeof(cfg_ptr->_v_btn_high[0]))))
-
-#define WCD_MBHC_CAL_IMPED_MIN_SZ ( \
-	sizeof(struct wcd_mbhc_imped_detect_cfg) + sizeof(u16) * 2)
-
-#define WCD_MBHC_CAL_IMPED_SZ(cfg_ptr) ( \
-	sizeof(struct wcd_mbhc_imped_detect_cfg) + \
-	(cfg_ptr->_n_rload * \
-	(sizeof(cfg_ptr->_rload[0]) + sizeof(cfg_ptr->_alpha[0]))))
-
-#define WCD_MBHC_JACK_MASK (SND_JACK_HEADSET | SND_JACK_OC_HPHL | \
-			   SND_JACK_OC_HPHR | SND_JACK_LINEOUT | \
-			   SND_JACK_MECHANICAL | SND_JACK_MICROPHONE2 | \
-			   SND_JACK_UNSUPPORTED)
-
-#define WCD_MBHC_JACK_BUTTON_MASK (SND_JACK_BTN_0 | SND_JACK_BTN_1 | \
-				  SND_JACK_BTN_2 | SND_JACK_BTN_3 | \
-				  SND_JACK_BTN_4 | SND_JACK_BTN_5)
-#define OCP_ATTEMPT 20
-#define HS_DETECT_PLUG_TIME_MS (3 * 1000)
-#define SPECIAL_HS_DETECT_TIME_MS (2 * 1000)
-#define MBHC_BUTTON_PRESS_THRESHOLD_MIN 250
-#define GND_MIC_SWAP_THRESHOLD 4
-#define WCD_FAKE_REMOVAL_MIN_PERIOD_MS 100
-#define HS_VREF_MIN_VAL 1400
-#define FW_READ_ATTEMPTS 15
-#define FW_READ_TIMEOUT 4000000
-#define FAKE_REM_RETRY_ATTEMPTS 3
-#define MAX_IMPED 60000
-
-#define WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS  50
-#define ANC_DETECT_RETRY_CNT 7
-#define WCD_MBHC_SPL_HS_CNT  1
-
-enum wcd_mbhc_detect_logic {
-	WCD_DETECTION_LEGACY,
-	WCD_DETECTION_ADC,
-};
-
-enum wcd_mbhc_cs_mb_en_flag {
-	WCD_MBHC_EN_CS = 0,
-	WCD_MBHC_EN_MB,
-	WCD_MBHC_EN_PULLUP,
-	WCD_MBHC_EN_NONE,
-};
-
-enum {
-	WCD_MBHC_ELEC_HS_INS,
-	WCD_MBHC_ELEC_HS_REM,
-};
-
-struct wcd_mbhc;
-enum wcd_mbhc_register_function {
-	WCD_MBHC_L_DET_EN,
-	WCD_MBHC_GND_DET_EN,
-	WCD_MBHC_MECH_DETECTION_TYPE,
-	WCD_MBHC_MIC_CLAMP_CTL,
-	WCD_MBHC_ELECT_DETECTION_TYPE,
-	WCD_MBHC_HS_L_DET_PULL_UP_CTRL,
-	WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL,
-	WCD_MBHC_HPHL_PLUG_TYPE,
-	WCD_MBHC_GND_PLUG_TYPE,
-	WCD_MBHC_SW_HPH_LP_100K_TO_GND,
-	WCD_MBHC_ELECT_SCHMT_ISRC,
-	WCD_MBHC_FSM_EN,
-	WCD_MBHC_INSREM_DBNC,
-	WCD_MBHC_BTN_DBNC,
-	WCD_MBHC_HS_VREF,
-	WCD_MBHC_HS_COMP_RESULT,
-	WCD_MBHC_MIC_SCHMT_RESULT,
-	WCD_MBHC_HPHL_SCHMT_RESULT,
-	WCD_MBHC_HPHR_SCHMT_RESULT,
-	WCD_MBHC_OCP_FSM_EN,
-	WCD_MBHC_BTN_RESULT,
-	WCD_MBHC_BTN_ISRC_CTL,
-	WCD_MBHC_ELECT_RESULT,
-	WCD_MBHC_MICB_CTRL,    /* Pull-up and micb control */
-	WCD_MBHC_HPH_CNP_WG_TIME,
-	WCD_MBHC_HPHR_PA_EN,
-	WCD_MBHC_HPHL_PA_EN,
-	WCD_MBHC_HPH_PA_EN,
-	WCD_MBHC_SWCH_LEVEL_REMOVE,
-	WCD_MBHC_PULLDOWN_CTRL,
-	WCD_MBHC_ANC_DET_EN,
-	WCD_MBHC_FSM_STATUS,
-	WCD_MBHC_MUX_CTL,
-	WCD_MBHC_HPHL_OCP_DET_EN,
-	WCD_MBHC_HPHR_OCP_DET_EN,
-	WCD_MBHC_HPHL_OCP_STATUS,
-	WCD_MBHC_HPHR_OCP_STATUS,
-	WCD_MBHC_ADC_EN,
-	WCD_MBHC_ADC_COMPLETE,
-	WCD_MBHC_ADC_TIMEOUT,
-	WCD_MBHC_ADC_RESULT,
-	WCD_MBHC_MICB2_VOUT,
-	WCD_MBHC_ADC_MODE,
-	WCD_MBHC_DETECTION_DONE,
-	WCD_MBHC_ELECT_ISRC_EN,
-	WCD_MBHC_REG_FUNC_MAX,
-};
-
-enum wcd_mbhc_plug_type {
-	MBHC_PLUG_TYPE_INVALID = -1,
-	MBHC_PLUG_TYPE_NONE,
-	MBHC_PLUG_TYPE_HEADSET,
-	MBHC_PLUG_TYPE_HEADPHONE,
-	MBHC_PLUG_TYPE_HIGH_HPH,
-	MBHC_PLUG_TYPE_GND_MIC_SWAP,
-	MBHC_PLUG_TYPE_ANC_HEADPHONE,
-};
-
-enum pa_dac_ack_flags {
-	WCD_MBHC_HPHL_PA_OFF_ACK = 0,
-	WCD_MBHC_HPHR_PA_OFF_ACK,
-};
-
-enum anc_ack_flags {
-	WCD_MBHC_ANC0_OFF_ACK = 0,
-	WCD_MBHC_ANC1_OFF_ACK,
-};
-
-enum wcd_mbhc_btn_det_mem {
-	WCD_MBHC_BTN_DET_V_BTN_LOW,
-	WCD_MBHC_BTN_DET_V_BTN_HIGH
-};
-
-enum {
-	MIC_BIAS_1 = 1,
-	MIC_BIAS_2,
-	MIC_BIAS_3,
-	MIC_BIAS_4
-};
-
-enum {
-	MICB_PULLUP_ENABLE,
-	MICB_PULLUP_DISABLE,
-	MICB_ENABLE,
-	MICB_DISABLE,
-};
-
-enum {
-	MBHC_COMMON_MICB_PRECHARGE,
-	MBHC_COMMON_MICB_SET_VAL,
-	MBHC_COMMON_MICB_TAIL_CURR,
-};
-
-enum wcd_notify_event {
-	WCD_EVENT_INVALID,
-	/* events for micbias ON and OFF */
-	WCD_EVENT_PRE_MICBIAS_2_OFF,
-	WCD_EVENT_POST_MICBIAS_2_OFF,
-	WCD_EVENT_PRE_MICBIAS_2_ON,
-	WCD_EVENT_POST_MICBIAS_2_ON,
-	WCD_EVENT_PRE_DAPM_MICBIAS_2_OFF,
-	WCD_EVENT_POST_DAPM_MICBIAS_2_OFF,
-	WCD_EVENT_PRE_DAPM_MICBIAS_2_ON,
-	WCD_EVENT_POST_DAPM_MICBIAS_2_ON,
-	/* events for PA ON and OFF */
-	WCD_EVENT_PRE_HPHL_PA_ON,
-	WCD_EVENT_POST_HPHL_PA_OFF,
-	WCD_EVENT_PRE_HPHR_PA_ON,
-	WCD_EVENT_POST_HPHR_PA_OFF,
-	WCD_EVENT_PRE_HPHL_PA_OFF,
-	WCD_EVENT_PRE_HPHR_PA_OFF,
-	WCD_EVENT_OCP_OFF,
-	WCD_EVENT_OCP_ON,
-	WCD_EVENT_LAST,
-};
-
-enum wcd_mbhc_event_state {
-	WCD_MBHC_EVENT_PA_HPHL,
-	WCD_MBHC_EVENT_PA_HPHR,
-};
-
-struct wcd_mbhc_general_cfg {
-	u8 t_ldoh;
-	u8 t_bg_fast_settle;
-	u8 t_shutdown_plug_rem;
-	u8 mbhc_nsa;
-	u8 mbhc_navg;
-	u8 v_micbias_l;
-	u8 v_micbias;
-	u8 mbhc_reserved;
-	u16 settle_wait;
-	u16 t_micbias_rampup;
-	u16 t_micbias_rampdown;
-	u16 t_supply_bringup;
-} __packed;
-
-struct wcd_mbhc_plug_detect_cfg {
-	u32 mic_current;
-	u32 hph_current;
-	u16 t_mic_pid;
-	u16 t_ins_complete;
-	u16 t_ins_retry;
-	u16 v_removal_delta;
-	u8 micbias_slow_ramp;
-	u8 reserved0;
-	u8 reserved1;
-	u8 reserved2;
-} __packed;
-
-struct wcd_mbhc_plug_type_cfg {
-	u8 av_detect;
-	u8 mono_detect;
-	u8 num_ins_tries;
-	u8 reserved0;
-	s16 v_no_mic;
-	s16 v_av_min;
-	s16 v_av_max;
-	s16 v_hs_min;
-	s16 v_hs_max;
-	u16 reserved1;
-} __packed;
-
-struct wcd_mbhc_btn_detect_cfg {
-	s8 c[8];
-	u8 nc;
-	u8 n_meas;
-	u8 mbhc_nsc;
-	u8 n_btn_meas;
-	u8 n_btn_con;
-	u8 num_btn;
-	u8 reserved0;
-	u8 reserved1;
-	u16 t_poll;
-	u16 t_bounce_wait;
-	u16 t_rel_timeout;
-	s16 v_btn_press_delta_sta;
-	s16 v_btn_press_delta_cic;
-	u16 t_btn0_timeout;
-	s16 _v_btn_low[0]; /* v_btn_low[num_btn] */
-	s16 _v_btn_high[0]; /* v_btn_high[num_btn] */
-	u8 _n_ready[2];
-	u8 _n_cic[2];
-	u8 _gain[2];
-} __packed;
-
-struct wcd_mbhc_imped_detect_cfg {
-	u8 _hs_imped_detect;
-	u8 _n_rload;
-	u8 _hph_keep_on;
-	u8 _repeat_rload_calc;
-	u16 _t_dac_ramp_time;
-	u16 _rhph_high;
-	u16 _rhph_low;
-	u16 _rload[0]; /* rload[n_rload] */
-	u16 _alpha[0]; /* alpha[n_rload] */
-	u16 _beta[3];
-} __packed;
-
-enum wcd_mbhc_hph_type {
-	WCD_MBHC_HPH_NONE = 0,
-	WCD_MBHC_HPH_MONO,
-	WCD_MBHC_HPH_STEREO,
-};
-
-/*
- * These enum definitions are directly mapped to the register
- * definitions
- */
-enum mbhc_moisture_vref {
-	V_OFF,
-	V_45_MV,
-	V_100_MV,
-	V_225_MV,
-};
-
-enum mbhc_hs_pullup_iref {
-	I_DEFAULT = -1,
-	I_OFF = 0,
-	I_1P0_UA,
-	I_2P0_UA,
-	I_3P0_UA,
-};
-
-enum mbhc_moisture_rref {
-	R_OFF,
-	R_24_KOHM,
-	R_84_KOHM,
-	R_184_KOHM,
-};
-
-struct usbc_ana_audio_config {
-	int usbc_en1_gpio;
-	int usbc_en2_gpio;
-	int usbc_force_gpio;
-	struct device_node *usbc_en1_gpio_p; /* used by pinctrl API */
-	struct device_node *usbc_en2_gpio_p; /* used by pinctrl API */
-	struct device_node *usbc_force_gpio_p; /* used by pinctrl API */
-};
-
-struct wcd_mbhc_config {
-	bool read_fw_bin;
-	void *calibration;
-	bool detect_extn_cable;
-	bool mono_stero_detection;
-	bool (*swap_gnd_mic)(struct snd_soc_codec *codec, bool active);
-	bool hs_ext_micbias;
-	bool gnd_det_en;
-	int key_code[WCD_MBHC_KEYCODE_NUM];
-	uint32_t linein_th;
-	bool moisture_en;
-	int mbhc_micbias;
-	int anc_micbias;
-	bool enable_anc_mic_detect;
-	u32 enable_usbc_analog;
-	struct usbc_ana_audio_config usbc_analog_cfg;
-};
-
-struct wcd_mbhc_intr {
-	int mbhc_sw_intr;
-	int mbhc_btn_press_intr;
-	int mbhc_btn_release_intr;
-	int mbhc_hs_ins_intr;
-	int mbhc_hs_rem_intr;
-	int hph_left_ocp;
-	int hph_right_ocp;
-};
-
-struct wcd_mbhc_register {
-	const char *id;
-	u16 reg;
-	u8 mask;
-	u8 offset;
-	u8 invert;
-};
-
-struct wcd_mbhc_cb {
-	int (*enable_mb_source)(struct wcd_mbhc *, bool);
-	void (*trim_btn_reg)(struct snd_soc_codec *);
-	void (*compute_impedance)(struct wcd_mbhc *, uint32_t *, uint32_t *);
-	void (*set_micbias_value)(struct snd_soc_codec *);
-	void (*set_auto_zeroing)(struct snd_soc_codec *, bool);
-	struct firmware_cal * (*get_hwdep_fw_cal)(struct wcd_mbhc *,
-			enum wcd_cal_type);
-	void (*set_cap_mode)(struct snd_soc_codec *, bool, bool);
-	int (*register_notifier)(struct wcd_mbhc *,
-				 struct notifier_block *nblock,
-				 bool enable);
-	int (*request_irq)(struct snd_soc_codec *,
-			int, irq_handler_t, const char *, void *);
-	void (*irq_control)(struct snd_soc_codec *,
-			int irq, bool enable);
-	int (*free_irq)(struct snd_soc_codec *,
-			int irq, void *);
-	void (*clk_setup)(struct snd_soc_codec *, bool);
-	int (*map_btn_code_to_num)(struct snd_soc_codec *);
-	bool (*lock_sleep)(struct wcd_mbhc *, bool);
-	bool (*micbias_enable_status)(struct wcd_mbhc *, int);
-	void (*mbhc_bias)(struct snd_soc_codec *, bool);
-	void (*mbhc_common_micb_ctrl)(struct snd_soc_codec *,
-				      int event, bool);
-	void (*micb_internal)(struct snd_soc_codec *,
-			int micb_num, bool);
-	bool (*hph_pa_on_status)(struct snd_soc_codec *);
-	void (*set_btn_thr)(struct snd_soc_codec *, s16 *, s16 *,
-			    int num_btn, bool);
-	void (*hph_pull_up_control)(struct snd_soc_codec *,
-				    enum mbhc_hs_pullup_iref);
-	int (*mbhc_micbias_control)(struct snd_soc_codec *, int, int req);
-	void (*mbhc_micb_ramp_control)(struct snd_soc_codec *, bool);
-	void (*skip_imped_detect)(struct snd_soc_codec *);
-	bool (*extn_use_mb)(struct snd_soc_codec *);
-	int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool);
-	void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool);
-	void (*hph_pull_down_ctrl)(struct snd_soc_codec *, bool);
-	void (*mbhc_moisture_config)(struct wcd_mbhc *);
-	bool (*hph_register_recovery)(struct wcd_mbhc *);
-	void (*update_anc_state)(struct snd_soc_codec *codec,
-				 bool enable, int anc_num);
-	bool (*is_anc_on)(struct wcd_mbhc *mbhc);
-};
-
-struct wcd_mbhc_fn {
-	irqreturn_t (*wcd_mbhc_hs_ins_irq)(int irq, void *data);
-	irqreturn_t (*wcd_mbhc_hs_rem_irq)(int irq, void *data);
-	void (*wcd_mbhc_detect_plug_type)(struct wcd_mbhc *mbhc);
-	bool (*wcd_mbhc_detect_anc_plug_type)(struct wcd_mbhc *mbhc);
-	void (*wcd_cancel_hs_detect_plug)(struct wcd_mbhc *mbhc,
-					  struct work_struct *work);
-};
-
-struct wcd_mbhc {
-	/* Delayed work to report long button press */
-	struct delayed_work mbhc_btn_dwork;
-	int buttons_pressed;
-	struct wcd_mbhc_config *mbhc_cfg;
-	const struct wcd_mbhc_cb *mbhc_cb;
-
-	u32 hph_status; /* track headhpone status */
-	u8 hphlocp_cnt; /* headphone left ocp retry */
-	u8 hphrocp_cnt; /* headphone right ocp retry */
-
-	wait_queue_head_t wait_btn_press;
-	bool is_btn_press;
-	u8 current_plug;
-	bool in_swch_irq_handler;
-	bool hphl_swh; /*track HPHL switch NC / NO */
-	bool gnd_swh; /*track GND switch NC / NO */
-	u32 moist_vref;
-	u32 moist_iref;
-	u32 moist_rref;
-	u8 micbias1_cap_mode; /* track ext cap setting */
-	u8 micbias2_cap_mode; /* track ext cap setting */
-	bool hs_detect_work_stop;
-	bool micbias_enable;
-	bool btn_press_intr;
-	bool is_hs_recording;
-	bool is_extn_cable;
-	bool skip_imped_detection;
-	bool is_btn_already_regd;
-	bool extn_cable_hph_rem;
-
-	struct snd_soc_codec *codec;
-	/* Work to perform MBHC Firmware Read */
-	struct delayed_work mbhc_firmware_dwork;
-	const struct firmware *mbhc_fw;
-	struct firmware_cal *mbhc_cal;
-
-	/* track PA/DAC state to sync with userspace */
-	unsigned long hph_pa_dac_state;
-	unsigned long hph_anc_state;
-	unsigned long event_state;
-	unsigned long jiffies_atreport;
-
-	/* impedance of hphl and hphr */
-	uint32_t zl, zr;
-	bool impedance_detect;
-
-	/* Holds type of Headset - Mono/Stereo */
-	enum wcd_mbhc_hph_type hph_type;
-
-	struct snd_soc_jack headset_jack;
-	struct snd_soc_jack button_jack;
-	struct mutex codec_resource_lock;
-
-	/* Holds codec specific interrupt mapping */
-	const struct wcd_mbhc_intr *intr_ids;
-
-	/* Work to correct accessory type */
-	struct work_struct correct_plug_swch;
-	struct notifier_block nblock;
-
-	struct wcd_mbhc_register *wcd_mbhc_regs;
-
-	struct completion btn_press_compl;
-	struct mutex hphl_pa_lock;
-	struct mutex hphr_pa_lock;
-
-	/* Holds mbhc detection method - ADC/Legacy */
-	unsigned int mbhc_detection_logic;
-
-	unsigned long intr_status;
-	bool is_hph_ocp_pending;
-
-	bool usbc_force_pr_mode;
-	int usbc_mode;
-	struct notifier_block psy_nb;
-	struct power_supply *usb_psy;
-	struct work_struct usbc_analog_work;
-
-	struct wcd_mbhc_fn *mbhc_fn;
-};
-
-void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
-				   enum wcd_mbhc_plug_type plug_type);
-void wcd_mbhc_hs_elec_irq(struct wcd_mbhc *mbhc, int irq_type, bool enable);
-void wcd_mbhc_elec_hs_report_unplug(struct wcd_mbhc *mbhc);
-bool wcd_swch_level_remove(struct wcd_mbhc *mbhc);
-void wcd_enable_curr_micbias(const struct wcd_mbhc *mbhc,
-			     const enum wcd_mbhc_cs_mb_en_flag cs_mb_en);
-void wcd_mbhc_jack_report(struct wcd_mbhc *mbhc,
-			  struct snd_soc_jack *jack, int status, int mask);
-int wcd_cancel_btn_work(struct wcd_mbhc *mbhc);
-int wcd_mbhc_get_button_mask(struct wcd_mbhc *mbhc);
-
-#endif /* __WCD_MBHC_V2_H__ */
diff --git a/sound/soc/codecs/wcd-spi-registers.h b/sound/soc/codecs/wcd-spi-registers.h
deleted file mode 100644
index 4e57969..0000000
--- a/sound/soc/codecs/wcd-spi-registers.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD_SPI_REGISTERS_H__
-#define __WCD_SPI_REGISTERS_H__
-
-#include <linux/regmap.h>
-
-#define WCD_SPI_SLAVE_SANITY         (0x00)
-#define WCD_SPI_SLAVE_DEVICE_ID      (0x04)
-#define WCD_SPI_SLAVE_STATUS         (0x08)
-#define WCD_SPI_SLAVE_CONFIG         (0x0c)
-#define WCD_SPI_SLAVE_SW_RESET       (0x10)
-#define WCD_SPI_SLAVE_IRQ_STATUS     (0x14)
-#define WCD_SPI_SLAVE_IRQ_EN         (0x18)
-#define WCD_SPI_SLAVE_IRQ_CLR        (0x1c)
-#define WCD_SPI_SLAVE_IRQ_FORCE      (0x20)
-#define WCD_SPI_SLAVE_TX             (0x24)
-#define WCD_SPI_SLAVE_TEST_BUS_DATA  (0x2c)
-#define WCD_SPI_SLAVE_TEST_BUS_CTRL  (0x30)
-#define WCD_SPI_SLAVE_SW_RST_IRQ     (0x34)
-#define WCD_SPI_SLAVE_CHAR_CFG       (0x38)
-#define WCD_SPI_SLAVE_CHAR_DATA_MOSI (0x3c)
-#define WCD_SPI_SLAVE_CHAR_DATA_CS_N (0x40)
-#define WCD_SPI_SLAVE_CHAR_DATA_MISO (0x44)
-#define WCD_SPI_SLAVE_TRNS_BYTE_CNT  (0x4c)
-#define WCD_SPI_SLAVE_TRNS_LEN       (0x50)
-#define WCD_SPI_SLAVE_FIFO_LEVEL     (0x54)
-#define WCD_SPI_SLAVE_GENERICS       (0x58)
-#define WCD_SPI_SLAVE_EXT_BASE_ADDR  (0x5c)
-#define WCD_SPI_MAX_REGISTER         (0x5F)
-
-#endif /* End __WCD_SPI_REGISTERS_H__ */
diff --git a/sound/soc/codecs/wcd-spi.c b/sound/soc/codecs/wcd-spi.c
deleted file mode 100644
index 67cb46c..0000000
--- a/sound/soc/codecs/wcd-spi.c
+++ /dev/null
@@ -1,1539 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/bitops.h>
-#include <linux/spi/spi.h>
-#include <linux/regmap.h>
-#include <linux/component.h>
-#include <linux/ratelimit.h>
-#include <sound/wcd-dsp-mgr.h>
-#include <sound/wcd-spi.h>
-#include "wcd-spi-registers.h"
-
-/* Byte manipulations */
-#define SHIFT_1_BYTES    (8)
-#define SHIFT_2_BYTES    (16)
-#define SHIFT_3_BYTES    (24)
-
-/* Command opcodes */
-#define WCD_SPI_CMD_NOP     (0x00)
-#define WCD_SPI_CMD_WREN    (0x06)
-#define WCD_SPI_CMD_CLKREQ  (0xDA)
-#define WCD_SPI_CMD_RDSR    (0x05)
-#define WCD_SPI_CMD_IRR     (0x81)
-#define WCD_SPI_CMD_IRW     (0x82)
-#define WCD_SPI_CMD_MIOR    (0x83)
-#define WCD_SPI_CMD_FREAD   (0x0B)
-#define WCD_SPI_CMD_MIOW    (0x02)
-#define WCD_SPI_WRITE_FRAME_OPCODE \
-	(WCD_SPI_CMD_MIOW << SHIFT_3_BYTES)
-#define WCD_SPI_READ_FRAME_OPCODE \
-	(WCD_SPI_CMD_MIOR << SHIFT_3_BYTES)
-#define WCD_SPI_FREAD_FRAME_OPCODE \
-	(WCD_SPI_CMD_FREAD << SHIFT_3_BYTES)
-
-/* Command lengths */
-#define WCD_SPI_OPCODE_LEN       (0x01)
-#define WCD_SPI_CMD_NOP_LEN      (0x01)
-#define WCD_SPI_CMD_WREN_LEN     (0x01)
-#define WCD_SPI_CMD_CLKREQ_LEN   (0x04)
-#define WCD_SPI_CMD_IRR_LEN      (0x04)
-#define WCD_SPI_CMD_IRW_LEN      (0x06)
-#define WCD_SPI_WRITE_SINGLE_LEN (0x08)
-#define WCD_SPI_READ_SINGLE_LEN  (0x13)
-#define WCD_SPI_CMD_FREAD_LEN    (0x13)
-
-/* Command delays */
-#define WCD_SPI_CLKREQ_DELAY_USECS (500)
-#define WCD_SPI_CLK_OFF_TIMER_MS   (500)
-#define WCD_SPI_RESUME_TIMEOUT_MS 100
-
-/* Command masks */
-#define WCD_CMD_ADDR_MASK            \
-	(0xFF |                      \
-	 (0xFF << SHIFT_1_BYTES) |   \
-	 (0xFF << SHIFT_2_BYTES))
-
-/* Clock ctrl request related */
-#define WCD_SPI_CLK_ENABLE true
-#define WCD_SPI_CLK_DISABLE false
-#define WCD_SPI_CLK_FLAG_DELAYED    (1 << 0)
-#define WCD_SPI_CLK_FLAG_IMMEDIATE  (1 << 1)
-
-/* Internal addresses */
-#define WCD_SPI_ADDR_IPC_CTL_HOST (0x012014)
-
-/* Word sizes and min/max lengths */
-#define WCD_SPI_WORD_BYTE_CNT (4)
-#define WCD_SPI_RW_MULTI_MIN_LEN (16)
-
-/* Max size is 32 bytes less than 64Kbytes */
-#define WCD_SPI_RW_MULTI_MAX_LEN ((64 * 1024) - 32)
-
-/*
- * Max size for the pre-allocated buffers is the max
- * possible read/write length + 32 bytes for the SPI
- * read/write command header itself.
- */
-#define WCD_SPI_RW_MAX_BUF_SIZE (WCD_SPI_RW_MULTI_MAX_LEN + 32)
-
-/* Alignment requirements */
-#define WCD_SPI_RW_MIN_ALIGN    WCD_SPI_WORD_BYTE_CNT
-#define WCD_SPI_RW_MULTI_ALIGN  (16)
-
-/* Status mask bits */
-#define WCD_SPI_CLK_STATE_ENABLED BIT(0)
-#define WCD_SPI_IS_SUSPENDED BIT(1)
-
-/* Locking related */
-#define WCD_SPI_MUTEX_LOCK(spi, lock)              \
-{                                                  \
-	dev_vdbg(&spi->dev, "%s: mutex_lock(%s)\n", \
-		 __func__, __stringify_1(lock));    \
-	mutex_lock(&lock);                         \
-}
-
-#define WCD_SPI_MUTEX_UNLOCK(spi, lock)              \
-{                                                    \
-	dev_vdbg(&spi->dev, "%s: mutex_unlock(%s)\n", \
-		 __func__, __stringify_1(lock));      \
-	mutex_unlock(&lock);                         \
-}
-
-struct wcd_spi_debug_data {
-	struct dentry *dir;
-	u32 addr;
-	u32 size;
-};
-
-struct wcd_spi_priv {
-	struct spi_device *spi;
-	u32 mem_base_addr;
-
-	struct regmap *regmap;
-
-	/* Message for single transfer */
-	struct spi_message msg1;
-	struct spi_transfer xfer1;
-
-	/* Message for two transfers */
-	struct spi_message msg2;
-	struct spi_transfer xfer2[2];
-
-	/* Register access related */
-	u32 reg_bytes;
-	u32 val_bytes;
-
-	/* Clock requests related */
-	struct mutex clk_mutex;
-	int clk_users;
-	unsigned long status_mask;
-	struct delayed_work clk_dwork;
-
-	/* Transaction related */
-	struct mutex xfer_mutex;
-
-	struct device *m_dev;
-	struct wdsp_mgr_ops *m_ops;
-
-	/* Debugfs related information */
-	struct wcd_spi_debug_data debug_data;
-
-	/* Completion object to indicate system resume completion */
-	struct completion resume_comp;
-
-	/* Buffers to hold memory used for transfers */
-	void *tx_buf;
-	void *rx_buf;
-};
-
-enum xfer_request {
-	WCD_SPI_XFER_WRITE,
-	WCD_SPI_XFER_READ,
-};
-
-
-static char *wcd_spi_xfer_req_str(enum xfer_request req)
-{
-	if (req == WCD_SPI_XFER_WRITE)
-		return "xfer_write";
-	else if (req == WCD_SPI_XFER_READ)
-		return "xfer_read";
-	else
-		return "xfer_invalid";
-}
-
-static void wcd_spi_reinit_xfer(struct spi_transfer *xfer)
-{
-	xfer->tx_buf = NULL;
-	xfer->rx_buf = NULL;
-	xfer->delay_usecs = 0;
-	xfer->len = 0;
-}
-
-static bool wcd_spi_is_suspended(struct wcd_spi_priv *wcd_spi)
-{
-	return test_bit(WCD_SPI_IS_SUSPENDED, &wcd_spi->status_mask);
-}
-
-static bool wcd_spi_can_suspend(struct wcd_spi_priv *wcd_spi)
-{
-	struct spi_device *spi = wcd_spi->spi;
-
-	if (wcd_spi->clk_users > 0 ||
-	    test_bit(WCD_SPI_CLK_STATE_ENABLED, &wcd_spi->status_mask)) {
-		dev_err(&spi->dev, "%s: cannot suspend, clk_users = %d\n",
-			__func__, wcd_spi->clk_users);
-		return false;
-	}
-
-	return true;
-}
-
-static int wcd_spi_wait_for_resume(struct wcd_spi_priv *wcd_spi)
-{
-	struct spi_device *spi = wcd_spi->spi;
-	int rc = 0;
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	/* If the system is already in resumed state, return right away */
-	if (!wcd_spi_is_suspended(wcd_spi))
-		goto done;
-
-	/* If suspended then wait for resume to happen */
-	reinit_completion(&wcd_spi->resume_comp);
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-	rc = wait_for_completion_timeout(&wcd_spi->resume_comp,
-				msecs_to_jiffies(WCD_SPI_RESUME_TIMEOUT_MS));
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	if (rc == 0) {
-		dev_err(&spi->dev, "%s: failed to resume in %u msec\n",
-			__func__, WCD_SPI_RESUME_TIMEOUT_MS);
-		rc = -EIO;
-		goto done;
-	}
-
-	dev_dbg(&spi->dev, "%s: resume successful\n", __func__);
-	rc = 0;
-done:
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-	return rc;
-}
-
-static int wcd_spi_read_single(struct spi_device *spi,
-			       u32 remote_addr, u32 *val)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *tx_xfer = &wcd_spi->xfer2[0];
-	struct spi_transfer *rx_xfer = &wcd_spi->xfer2[1];
-	u8 *tx_buf = wcd_spi->tx_buf;
-	u32 frame = 0;
-	int ret;
-
-	dev_dbg(&spi->dev, "%s: remote_addr = 0x%x\n",
-		__func__, remote_addr);
-
-	if (!tx_buf) {
-		dev_err(&spi->dev, "%s: tx_buf not allocated\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	frame |= WCD_SPI_READ_FRAME_OPCODE;
-	frame |= remote_addr & WCD_CMD_ADDR_MASK;
-
-	wcd_spi_reinit_xfer(tx_xfer);
-	frame = cpu_to_be32(frame);
-	memcpy(tx_buf, &frame, sizeof(frame));
-	tx_xfer->tx_buf = tx_buf;
-	tx_xfer->len = WCD_SPI_READ_SINGLE_LEN;
-
-	wcd_spi_reinit_xfer(rx_xfer);
-	rx_xfer->rx_buf = val;
-	rx_xfer->len = sizeof(*val);
-
-	ret = spi_sync(spi, &wcd_spi->msg2);
-
-	return ret;
-}
-
-static int wcd_spi_read_multi(struct spi_device *spi,
-			      u32 remote_addr, u8 *data,
-			      size_t len)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *xfer = &wcd_spi->xfer1;
-	u8 *tx_buf = wcd_spi->tx_buf;
-	u8 *rx_buf = wcd_spi->rx_buf;
-	u32 frame = 0;
-	int ret;
-
-	dev_dbg(&spi->dev,  "%s: addr 0x%x, len = %zd\n",
-		__func__, remote_addr, len);
-
-	frame |= WCD_SPI_FREAD_FRAME_OPCODE;
-	frame |= remote_addr & WCD_CMD_ADDR_MASK;
-
-	if (!tx_buf || !rx_buf) {
-		dev_err(&spi->dev, "%s: %s not allocated\n", __func__,
-			(!tx_buf) ? "tx_buf" : "rx_buf");
-		return -ENOMEM;
-	}
-
-	wcd_spi_reinit_xfer(xfer);
-	frame = cpu_to_be32(frame);
-	memcpy(tx_buf, &frame, sizeof(frame));
-	xfer->tx_buf = tx_buf;
-	xfer->rx_buf = rx_buf;
-	xfer->len = WCD_SPI_CMD_FREAD_LEN + len;
-
-	ret = spi_sync(spi, &wcd_spi->msg1);
-	if (ret) {
-		dev_err(&spi->dev, "%s: failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	memcpy(data, rx_buf + WCD_SPI_CMD_FREAD_LEN, len);
-done:
-	return ret;
-}
-
-static int wcd_spi_write_single(struct spi_device *spi,
-				u32 remote_addr, u32 val)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *xfer = &wcd_spi->xfer1;
-	u8 buf[WCD_SPI_WRITE_SINGLE_LEN];
-	u32 frame = 0;
-
-	dev_dbg(&spi->dev, "%s: remote_addr = 0x%x, val = 0x%x\n",
-		__func__, remote_addr, val);
-
-	memset(buf, 0, WCD_SPI_WRITE_SINGLE_LEN);
-	frame |= WCD_SPI_WRITE_FRAME_OPCODE;
-	frame |= (remote_addr & WCD_CMD_ADDR_MASK);
-
-	frame = cpu_to_be32(frame);
-	memcpy(buf, &frame, sizeof(frame));
-	memcpy(buf + sizeof(frame), &val, sizeof(val));
-
-	wcd_spi_reinit_xfer(xfer);
-	xfer->tx_buf = buf;
-	xfer->len = WCD_SPI_WRITE_SINGLE_LEN;
-
-	return spi_sync(spi, &wcd_spi->msg1);
-}
-
-static int wcd_spi_write_multi(struct spi_device *spi,
-			       u32 remote_addr, u8 *data,
-			       size_t len)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *xfer = &wcd_spi->xfer1;
-	u32 frame = 0;
-	u8 *tx_buf = wcd_spi->tx_buf;
-	int xfer_len, ret;
-
-	dev_dbg(&spi->dev, "%s: addr = 0x%x len = %zd\n",
-		__func__, remote_addr, len);
-
-	frame |= WCD_SPI_WRITE_FRAME_OPCODE;
-	frame |= (remote_addr & WCD_CMD_ADDR_MASK);
-
-	frame = cpu_to_be32(frame);
-	xfer_len = len + sizeof(frame);
-
-	if (!tx_buf) {
-		dev_err(&spi->dev, "%s: tx_buf not allocated\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	memcpy(tx_buf, &frame, sizeof(frame));
-	memcpy(tx_buf + sizeof(frame), data, len);
-
-	wcd_spi_reinit_xfer(xfer);
-	xfer->tx_buf = tx_buf;
-	xfer->len = xfer_len;
-
-	ret = spi_sync(spi, &wcd_spi->msg1);
-	if (ret < 0)
-		dev_err(&spi->dev,
-			"%s: Failed, addr = 0x%x, len = %zd\n",
-			__func__, remote_addr, len);
-	return ret;
-}
-
-static int wcd_spi_transfer_split(struct spi_device *spi,
-				  struct wcd_spi_msg *data_msg,
-				  enum xfer_request xfer_req)
-{
-	u32 addr = data_msg->remote_addr;
-	u8 *data = data_msg->data;
-	int remain_size = data_msg->len;
-	int to_xfer, loop_cnt, ret = 0;
-
-	/* Perform single writes until multi word alignment is met */
-	loop_cnt = 1;
-	while (remain_size &&
-	       !IS_ALIGNED(addr, WCD_SPI_RW_MULTI_ALIGN)) {
-		if (xfer_req == WCD_SPI_XFER_WRITE)
-			ret = wcd_spi_write_single(spi, addr,
-						   (*(u32 *)data));
-		else
-			ret = wcd_spi_read_single(spi, addr,
-						  (u32 *)data);
-		if (ret < 0) {
-			dev_err(&spi->dev,
-				"%s: %s fail iter(%d) start-word addr (0x%x)\n",
-				__func__, wcd_spi_xfer_req_str(xfer_req),
-				loop_cnt, addr);
-			goto done;
-		}
-
-		addr += WCD_SPI_WORD_BYTE_CNT;
-		data += WCD_SPI_WORD_BYTE_CNT;
-		remain_size -= WCD_SPI_WORD_BYTE_CNT;
-		loop_cnt++;
-	}
-
-	/* Perform multi writes for max allowed multi writes */
-	loop_cnt = 1;
-	while (remain_size >= WCD_SPI_RW_MULTI_MAX_LEN) {
-		if (xfer_req == WCD_SPI_XFER_WRITE)
-			ret = wcd_spi_write_multi(spi, addr, data,
-						  WCD_SPI_RW_MULTI_MAX_LEN);
-		else
-			ret = wcd_spi_read_multi(spi, addr, data,
-						 WCD_SPI_RW_MULTI_MAX_LEN);
-		if (ret < 0) {
-			dev_err(&spi->dev,
-				"%s: %s fail iter(%d) max-write addr (0x%x)\n",
-				__func__, wcd_spi_xfer_req_str(xfer_req),
-				loop_cnt, addr);
-			goto done;
-		}
-
-		addr += WCD_SPI_RW_MULTI_MAX_LEN;
-		data += WCD_SPI_RW_MULTI_MAX_LEN;
-		remain_size -= WCD_SPI_RW_MULTI_MAX_LEN;
-		loop_cnt++;
-	}
-
-	/*
-	 * Perform write for max possible data that is multiple
-	 * of the minimum size for multi-write commands.
-	 */
-	to_xfer = remain_size - (remain_size % WCD_SPI_RW_MULTI_MIN_LEN);
-	if (remain_size >= WCD_SPI_RW_MULTI_MIN_LEN &&
-	    to_xfer > 0) {
-		if (xfer_req == WCD_SPI_XFER_WRITE)
-			ret = wcd_spi_write_multi(spi, addr, data, to_xfer);
-		else
-			ret = wcd_spi_read_multi(spi, addr, data, to_xfer);
-		if (ret < 0) {
-			dev_err(&spi->dev,
-				"%s: %s fail write addr (0x%x), size (0x%x)\n",
-				__func__, wcd_spi_xfer_req_str(xfer_req),
-				addr, to_xfer);
-			goto done;
-		}
-
-		addr += to_xfer;
-		data += to_xfer;
-		remain_size -= to_xfer;
-	}
-
-	/* Perform single writes for the last remaining data */
-	loop_cnt = 1;
-	while (remain_size > 0) {
-		if (xfer_req == WCD_SPI_XFER_WRITE)
-			ret = wcd_spi_write_single(spi, addr, (*((u32 *)data)));
-		else
-			ret = wcd_spi_read_single(spi, addr,  (u32 *) data);
-		if (ret < 0) {
-			dev_err(&spi->dev,
-				"%s: %s fail iter(%d) end-write addr (0x%x)\n",
-				__func__, wcd_spi_xfer_req_str(xfer_req),
-				loop_cnt, addr);
-			goto done;
-		}
-
-		addr += WCD_SPI_WORD_BYTE_CNT;
-		data += WCD_SPI_WORD_BYTE_CNT;
-		remain_size -= WCD_SPI_WORD_BYTE_CNT;
-		loop_cnt++;
-	}
-
-done:
-	return ret;
-}
-
-static int wcd_spi_cmd_nop(struct spi_device *spi)
-{
-	u8 nop = WCD_SPI_CMD_NOP;
-
-	return spi_write(spi, &nop, WCD_SPI_CMD_NOP_LEN);
-}
-
-static int wcd_spi_cmd_clkreq(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *xfer = &wcd_spi->xfer1;
-	u8 cmd[WCD_SPI_CMD_CLKREQ_LEN] = {
-		WCD_SPI_CMD_CLKREQ,
-		0xBA, 0x80, 0x00};
-
-	wcd_spi_reinit_xfer(xfer);
-	xfer->tx_buf = cmd;
-	xfer->len = WCD_SPI_CMD_CLKREQ_LEN;
-	xfer->delay_usecs = WCD_SPI_CLKREQ_DELAY_USECS;
-
-	return spi_sync(spi, &wcd_spi->msg1);
-}
-
-static int wcd_spi_cmd_wr_en(struct spi_device *spi)
-{
-	u8 wr_en = WCD_SPI_CMD_WREN;
-
-	return spi_write(spi, &wr_en, WCD_SPI_CMD_WREN_LEN);
-}
-
-static int wcd_spi_cmd_rdsr(struct spi_device *spi,
-			    u32 *rdsr_status)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *tx_xfer = &wcd_spi->xfer2[0];
-	struct spi_transfer *rx_xfer = &wcd_spi->xfer2[1];
-	u8 rdsr_cmd;
-	u32 status;
-	int ret;
-
-	rdsr_cmd = WCD_SPI_CMD_RDSR;
-	wcd_spi_reinit_xfer(tx_xfer);
-	tx_xfer->tx_buf = &rdsr_cmd;
-	tx_xfer->len = sizeof(rdsr_cmd);
-
-
-	wcd_spi_reinit_xfer(rx_xfer);
-	rx_xfer->rx_buf = &status;
-	rx_xfer->len = sizeof(status);
-
-	ret = spi_sync(spi, &wcd_spi->msg2);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: RDSR failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	*rdsr_status = be32_to_cpu(status);
-
-	dev_dbg(&spi->dev, "%s: RDSR success, value = 0x%x\n",
-		 __func__, *rdsr_status);
-done:
-	return ret;
-}
-
-static int wcd_spi_clk_enable(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret;
-	u32 rd_status = 0;
-
-	ret = wcd_spi_cmd_nop(spi);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: NOP1 failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ret = wcd_spi_cmd_clkreq(spi);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: CLK_REQ failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ret = wcd_spi_cmd_nop(spi);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: NOP2 failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-	wcd_spi_cmd_rdsr(spi, &rd_status);
-	/*
-	 * Read status zero means reads are not
-	 * happenning on the bus, possibly because
-	 * clock request failed.
-	 */
-	if (rd_status) {
-		set_bit(WCD_SPI_CLK_STATE_ENABLED,
-			&wcd_spi->status_mask);
-	} else {
-		dev_err(&spi->dev, "%s: RDSR status is zero\n",
-			__func__);
-		ret = -EIO;
-	}
-done:
-	return ret;
-}
-
-static int wcd_spi_clk_disable(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret;
-
-	ret = wcd_spi_write_single(spi, WCD_SPI_ADDR_IPC_CTL_HOST, 0x01);
-	if (ret < 0)
-		dev_err(&spi->dev, "%s: Failed, err = %d\n",
-			__func__, ret);
-	else
-		clear_bit(WCD_SPI_CLK_STATE_ENABLED, &wcd_spi->status_mask);
-
-	return ret;
-}
-
-static int wcd_spi_clk_ctrl(struct spi_device *spi,
-			    bool request, u32 flags)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret = 0;
-	const char *delay_str;
-
-	delay_str = (flags == WCD_SPI_CLK_FLAG_DELAYED) ?
-		    "delayed" : "immediate";
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-
-	/* Reject any unbalanced disable request */
-	if (wcd_spi->clk_users < 0 ||
-	    (!request && wcd_spi->clk_users == 0)) {
-		dev_err(&spi->dev, "%s: Unbalanced clk_users %d for %s\n",
-			 __func__, wcd_spi->clk_users,
-			request ? "enable" : "disable");
-		ret = -EINVAL;
-
-		/* Reset the clk_users to 0 */
-		wcd_spi->clk_users = 0;
-
-		goto done;
-	}
-
-	if (request == WCD_SPI_CLK_ENABLE) {
-		/*
-		 * If the SPI bus is suspended, then return error
-		 * as the transaction cannot be completed.
-		 */
-		if (wcd_spi_is_suspended(wcd_spi)) {
-			dev_err(&spi->dev,
-				"%s: SPI suspended, cannot enable clk\n",
-				__func__);
-			ret = -EIO;
-			goto done;
-		}
-
-		/* Cancel the disable clk work */
-		WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-		cancel_delayed_work_sync(&wcd_spi->clk_dwork);
-		WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-
-		wcd_spi->clk_users++;
-
-		/*
-		 * If clk state is already set,
-		 * then clk wasnt really disabled
-		 */
-		if (test_bit(WCD_SPI_CLK_STATE_ENABLED, &wcd_spi->status_mask))
-			goto done;
-		else if (wcd_spi->clk_users == 1)
-			ret = wcd_spi_clk_enable(spi);
-
-	} else {
-		wcd_spi->clk_users--;
-
-		/* Clock is still voted for */
-		if (wcd_spi->clk_users > 0)
-			goto done;
-
-		/*
-		 * If we are here, clk_users must be 0 and needs
-		 * to be disabled. Call the disable based on the
-		 * flags.
-		 */
-		if (flags == WCD_SPI_CLK_FLAG_DELAYED) {
-			schedule_delayed_work(&wcd_spi->clk_dwork,
-				msecs_to_jiffies(WCD_SPI_CLK_OFF_TIMER_MS));
-		} else {
-			ret = wcd_spi_clk_disable(spi);
-			if (ret < 0)
-				dev_err(&spi->dev,
-					"%s: Failed to disable clk err = %d\n",
-					__func__, ret);
-		}
-	}
-
-done:
-	dev_dbg(&spi->dev, "%s: updated clk_users = %d, request_%s %s\n",
-		__func__, wcd_spi->clk_users, request ? "enable" : "disable",
-		request ? "" : delay_str);
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-
-	return ret;
-}
-
-static int wcd_spi_init(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret;
-
-	ret = wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_ENABLE,
-			       WCD_SPI_CLK_FLAG_IMMEDIATE);
-	if (ret < 0)
-		goto done;
-
-	ret = wcd_spi_cmd_wr_en(spi);
-	if (ret < 0)
-		goto err_wr_en;
-
-	/*
-	 * In case spi_init is called after component deinit,
-	 * it is possible hardware register state is also reset.
-	 * Sync the regcache here so hardware state is updated
-	 * to reflect the cache.
-	 */
-	regcache_sync(wcd_spi->regmap);
-
-	regmap_write(wcd_spi->regmap, WCD_SPI_SLAVE_CONFIG,
-		     0x0F3D0800);
-
-	/* Write the MTU to max allowed size */
-	regmap_update_bits(wcd_spi->regmap,
-			   WCD_SPI_SLAVE_TRNS_LEN,
-			   0xFFFF0000, 0xFFFF0000);
-err_wr_en:
-	wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_DISABLE,
-			 WCD_SPI_CLK_FLAG_IMMEDIATE);
-done:
-	return ret;
-}
-
-static void wcd_spi_clk_work(struct work_struct *work)
-{
-	struct delayed_work *dwork;
-	struct wcd_spi_priv *wcd_spi;
-	struct spi_device *spi;
-	int ret;
-
-	dwork = to_delayed_work(work);
-	wcd_spi = container_of(dwork, struct wcd_spi_priv, clk_dwork);
-	spi = wcd_spi->spi;
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	ret = wcd_spi_clk_disable(spi);
-	if (ret < 0)
-		dev_err(&spi->dev,
-			"%s: Failed to disable clk, err = %d\n",
-			__func__, ret);
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-}
-
-static int __wcd_spi_data_xfer(struct spi_device *spi,
-			       struct wcd_spi_msg *msg,
-			       enum xfer_request xfer_req)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret;
-
-	/* Check for minimum alignment requirements */
-	if (!IS_ALIGNED(msg->remote_addr, WCD_SPI_RW_MIN_ALIGN)) {
-		dev_err(&spi->dev,
-			"%s addr 0x%x is not aligned to 0x%x\n",
-			__func__, msg->remote_addr, WCD_SPI_RW_MIN_ALIGN);
-		return -EINVAL;
-	} else if (msg->len % WCD_SPI_WORD_BYTE_CNT) {
-		dev_err(&spi->dev,
-			"%s len 0x%zx is not multiple of %d\n",
-			__func__, msg->len, WCD_SPI_WORD_BYTE_CNT);
-		return -EINVAL;
-	}
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->xfer_mutex);
-	if (msg->len == WCD_SPI_WORD_BYTE_CNT) {
-		if (xfer_req == WCD_SPI_XFER_WRITE)
-			ret = wcd_spi_write_single(spi, msg->remote_addr,
-						   (*((u32 *)msg->data)));
-		else
-			ret = wcd_spi_read_single(spi, msg->remote_addr,
-						  (u32 *) msg->data);
-	} else {
-		ret = wcd_spi_transfer_split(spi, msg, xfer_req);
-	}
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->xfer_mutex);
-
-	return ret;
-}
-
-static int wcd_spi_data_xfer(struct spi_device *spi,
-			     struct wcd_spi_msg *msg,
-			     enum xfer_request req)
-{
-	int ret, ret1;
-
-	if (msg->len <= 0) {
-		dev_err(&spi->dev, "%s: Invalid size %zd\n",
-			__func__, msg->len);
-		return -EINVAL;
-	}
-
-	/* Request for clock */
-	ret = wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_ENABLE,
-			       WCD_SPI_CLK_FLAG_IMMEDIATE);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: clk enable failed %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	/* Perform the transaction */
-	ret = __wcd_spi_data_xfer(spi, msg, req);
-	if (ret < 0)
-		dev_err(&spi->dev,
-			"%s: Failed %s, addr = 0x%x, size = 0x%zx, err = %d\n",
-			__func__, wcd_spi_xfer_req_str(req),
-			msg->remote_addr, msg->len, ret);
-
-	/* Release the clock even if xfer failed */
-	ret1 = wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_DISABLE,
-				WCD_SPI_CLK_FLAG_DELAYED);
-	if (ret1 < 0)
-		dev_err(&spi->dev, "%s: clk disable failed %d\n",
-			__func__, ret1);
-done:
-	return ret;
-}
-
-/*
- * wcd_spi_data_write: Write data to WCD SPI
- * @spi: spi_device struct
- * @msg: msg that needs to be written to WCD
- *
- * This API writes length of data to address specified. These details
- * about the write are encapsulated in @msg. Write size should be multiple
- * of 4 bytes and write address should be 4-byte aligned.
- */
-static int wcd_spi_data_write(struct spi_device *spi,
-		       struct wcd_spi_msg *msg)
-{
-	if (!spi || !msg) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!spi) ? "spi device" : "msg");
-		return -EINVAL;
-	}
-
-	dev_dbg_ratelimited(&spi->dev, "%s: addr = 0x%x, len = %zu\n",
-			    __func__, msg->remote_addr, msg->len);
-	return wcd_spi_data_xfer(spi, msg, WCD_SPI_XFER_WRITE);
-}
-
-/*
- * wcd_spi_data_read: Read data from WCD SPI
- * @spi: spi_device struct
- * @msg: msg that needs to be read from WCD
- *
- * This API reads length of data from address specified. These details
- * about the read are encapsulated in @msg. Read size should be multiple
- * of 4 bytes and read address should be 4-byte aligned.
- */
-static int wcd_spi_data_read(struct spi_device *spi,
-		      struct wcd_spi_msg *msg)
-{
-	if (!spi || !msg) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!spi) ? "spi device" : "msg");
-		return -EINVAL;
-	}
-
-	dev_dbg_ratelimited(&spi->dev, "%s: addr = 0x%x,len = %zu\n",
-			    __func__, msg->remote_addr, msg->len);
-	return wcd_spi_data_xfer(spi, msg, WCD_SPI_XFER_READ);
-}
-
-static int wdsp_spi_dload_section(struct spi_device *spi,
-				  void *data)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wdsp_img_section *sec = data;
-	struct wcd_spi_msg msg;
-	int ret;
-
-	dev_dbg(&spi->dev, "%s: addr = 0x%x, size = 0x%zx\n",
-		__func__, sec->addr, sec->size);
-
-	msg.remote_addr = sec->addr + wcd_spi->mem_base_addr;
-	msg.data = sec->data;
-	msg.len = sec->size;
-
-	ret = __wcd_spi_data_xfer(spi, &msg, WCD_SPI_XFER_WRITE);
-	if (ret < 0)
-		dev_err(&spi->dev, "%s: fail addr (0x%x) size (0x%zx)\n",
-			__func__, msg.remote_addr, msg.len);
-	return ret;
-}
-
-static int wdsp_spi_read_section(struct spi_device *spi, void *data)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wdsp_img_section *sec = data;
-	struct wcd_spi_msg msg;
-	int ret;
-
-	msg.remote_addr = sec->addr + wcd_spi->mem_base_addr;
-	msg.data = sec->data;
-	msg.len = sec->size;
-
-	dev_dbg(&spi->dev, "%s: addr = 0x%x, size = 0x%zx\n",
-		__func__, msg.remote_addr, msg.len);
-
-	ret = wcd_spi_data_xfer(spi, &msg, WCD_SPI_XFER_READ);
-	if (ret < 0)
-		dev_err(&spi->dev, "%s: fail addr (0x%x) size (0x%zx)\n",
-			__func__, msg.remote_addr, msg.len);
-	return ret;
-}
-
-static int wdsp_spi_event_handler(struct device *dev, void *priv_data,
-				  enum wdsp_event_type event,
-				  void *data)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wcd_spi_ops *spi_ops;
-	int ret = 0;
-
-	dev_dbg(&spi->dev, "%s: event type %d\n",
-		__func__, event);
-
-	switch (event) {
-	case WDSP_EVENT_POST_SHUTDOWN:
-		cancel_delayed_work_sync(&wcd_spi->clk_dwork);
-		WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-		if (test_bit(WCD_SPI_CLK_STATE_ENABLED, &wcd_spi->status_mask))
-			wcd_spi_clk_disable(spi);
-		wcd_spi->clk_users = 0;
-		WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-		break;
-
-	case WDSP_EVENT_PRE_DLOAD_CODE:
-	case WDSP_EVENT_PRE_DLOAD_DATA:
-		ret = wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_ENABLE,
-				       WCD_SPI_CLK_FLAG_IMMEDIATE);
-		if (ret < 0)
-			dev_err(&spi->dev, "%s: clk_req failed %d\n",
-				__func__, ret);
-		break;
-
-	case WDSP_EVENT_POST_DLOAD_CODE:
-	case WDSP_EVENT_POST_DLOAD_DATA:
-	case WDSP_EVENT_DLOAD_FAILED:
-
-		ret = wcd_spi_clk_ctrl(spi, WCD_SPI_CLK_DISABLE,
-				       WCD_SPI_CLK_FLAG_IMMEDIATE);
-		if (ret < 0)
-			dev_err(&spi->dev, "%s: clk unvote failed %d\n",
-				__func__, ret);
-		break;
-
-	case WDSP_EVENT_DLOAD_SECTION:
-		ret = wdsp_spi_dload_section(spi, data);
-		break;
-
-	case WDSP_EVENT_READ_SECTION:
-		ret = wdsp_spi_read_section(spi, data);
-		break;
-
-	case WDSP_EVENT_SUSPEND:
-		WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-		if (!wcd_spi_can_suspend(wcd_spi))
-			ret = -EBUSY;
-		WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-		break;
-
-	case WDSP_EVENT_RESUME:
-		ret = wcd_spi_wait_for_resume(wcd_spi);
-		break;
-
-	case WDSP_EVENT_GET_DEVOPS:
-		if (!data) {
-			dev_err(&spi->dev, "%s: invalid data\n",
-				__func__);
-			ret = -EINVAL;
-			break;
-		}
-
-		spi_ops = (struct wcd_spi_ops *) data;
-		spi_ops->spi_dev = spi;
-		spi_ops->read_dev = wcd_spi_data_read;
-		spi_ops->write_dev = wcd_spi_data_write;
-		break;
-
-	default:
-		dev_dbg(&spi->dev, "%s: Unhandled event %d\n",
-			__func__, event);
-		break;
-	}
-
-	return ret;
-}
-
-static int wcd_spi_bus_gwrite(void *context, const void *reg,
-			      size_t reg_len, const void *val,
-			      size_t val_len)
-{
-	struct device *dev = context;
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	u8 tx_buf[WCD_SPI_CMD_IRW_LEN];
-
-	if (!reg || !val || reg_len != wcd_spi->reg_bytes ||
-	    val_len != wcd_spi->val_bytes) {
-		dev_err(&spi->dev,
-			"%s: Invalid input, reg_len = %zd, val_len = %zd",
-			__func__, reg_len, val_len);
-		return -EINVAL;
-	}
-
-	tx_buf[0] = WCD_SPI_CMD_IRW;
-	tx_buf[1] = *((u8 *)reg);
-	memcpy(&tx_buf[WCD_SPI_OPCODE_LEN + reg_len],
-	       val, val_len);
-
-	return spi_write(spi, tx_buf, WCD_SPI_CMD_IRW_LEN);
-}
-
-static int wcd_spi_bus_write(void *context, const void *data,
-			     size_t count)
-{
-	struct device *dev = context;
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-
-	if (count < (wcd_spi->reg_bytes + wcd_spi->val_bytes)) {
-		dev_err(&spi->dev, "%s: Invalid size %zd\n",
-			__func__, count);
-		WARN_ON(1);
-		return -EINVAL;
-	}
-
-	return wcd_spi_bus_gwrite(context, data, wcd_spi->reg_bytes,
-				  data + wcd_spi->reg_bytes,
-				  count - wcd_spi->reg_bytes);
-}
-
-static int wcd_spi_bus_read(void *context, const void *reg,
-			    size_t reg_len, void *val,
-			    size_t val_len)
-{
-	struct device *dev = context;
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct spi_transfer *tx_xfer = &wcd_spi->xfer2[0];
-	struct spi_transfer *rx_xfer = &wcd_spi->xfer2[1];
-	u8 tx_buf[WCD_SPI_CMD_IRR_LEN];
-
-	if (!reg || !val || reg_len != wcd_spi->reg_bytes ||
-	    val_len != wcd_spi->val_bytes) {
-		dev_err(&spi->dev,
-			"%s: Invalid input, reg_len = %zd, val_len = %zd",
-			__func__, reg_len, val_len);
-		return -EINVAL;
-	}
-
-	memset(tx_buf, 0, WCD_SPI_OPCODE_LEN);
-	tx_buf[0] = WCD_SPI_CMD_IRR;
-	tx_buf[1] = *((u8 *)reg);
-
-	wcd_spi_reinit_xfer(tx_xfer);
-	tx_xfer->tx_buf = tx_buf;
-	tx_xfer->rx_buf = NULL;
-	tx_xfer->len = WCD_SPI_CMD_IRR_LEN;
-
-	wcd_spi_reinit_xfer(rx_xfer);
-	rx_xfer->tx_buf = NULL;
-	rx_xfer->rx_buf = val;
-	rx_xfer->len = val_len;
-
-	return spi_sync(spi, &wcd_spi->msg2);
-}
-
-static struct regmap_bus wcd_spi_regmap_bus = {
-	.write = wcd_spi_bus_write,
-	.gather_write = wcd_spi_bus_gwrite,
-	.read = wcd_spi_bus_read,
-	.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian_default = REGMAP_ENDIAN_BIG,
-};
-
-static int wcd_spi_state_show(struct seq_file *f, void *ptr)
-{
-	struct spi_device *spi = f->private;
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	const char *clk_state, *clk_mutex, *xfer_mutex;
-
-	if (test_bit(WCD_SPI_CLK_STATE_ENABLED, &wcd_spi->status_mask))
-		clk_state = "enabled";
-	else
-		clk_state = "disabled";
-
-	clk_mutex = mutex_is_locked(&wcd_spi->clk_mutex) ?
-		    "locked" : "unlocked";
-
-	xfer_mutex = mutex_is_locked(&wcd_spi->xfer_mutex) ?
-		     "locked" : "unlocked";
-
-	seq_printf(f, "clk_state = %s\nclk_users = %d\n"
-		   "clk_mutex = %s\nxfer_mutex = %s\n",
-		   clk_state, wcd_spi->clk_users, clk_mutex,
-		   xfer_mutex);
-	return 0;
-}
-
-static int wcd_spi_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, wcd_spi_state_show, inode->i_private);
-}
-
-static const struct file_operations state_fops = {
-	.open = wcd_spi_state_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static ssize_t wcd_spi_debugfs_mem_read(struct file *file, char __user *ubuf,
-					size_t count, loff_t *ppos)
-{
-	struct spi_device *spi = file->private_data;
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wcd_spi_debug_data *dbg_data = &wcd_spi->debug_data;
-	struct wcd_spi_msg msg;
-	ssize_t buf_size, read_count = 0;
-	char *buf;
-	int ret;
-
-	if (*ppos < 0 || !count)
-		return -EINVAL;
-
-	if (dbg_data->size == 0 || dbg_data->addr == 0) {
-		dev_err(&spi->dev,
-			"%s: Invalid request, size = %u, addr = 0x%x\n",
-			__func__, dbg_data->size, dbg_data->addr);
-		return 0;
-	}
-
-	buf_size = count < dbg_data->size ? count : dbg_data->size;
-	buf = kzalloc(buf_size, GFP_KERNEL);
-	if (!buf)
-		return -ENOMEM;
-
-	msg.data = buf;
-	msg.remote_addr = dbg_data->addr;
-	msg.len = buf_size;
-	msg.flags = 0;
-
-	ret = wcd_spi_data_read(spi, &msg);
-	if (ret < 0) {
-		dev_err(&spi->dev,
-			"%s: Failed to read %zu bytes from addr 0x%x\n",
-			__func__, buf_size, msg.remote_addr);
-		goto done;
-	}
-
-	read_count = simple_read_from_buffer(ubuf, count, ppos, buf, buf_size);
-
-done:
-	kfree(buf);
-	if (ret < 0)
-		return ret;
-	else
-		return read_count;
-}
-
-static const struct file_operations mem_read_fops = {
-	.open = simple_open,
-	.read = wcd_spi_debugfs_mem_read,
-};
-
-static int wcd_spi_debugfs_init(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wcd_spi_debug_data *dbg_data = &wcd_spi->debug_data;
-	int rc = 0;
-
-	dbg_data->dir = debugfs_create_dir("wcd_spi", NULL);
-	if (IS_ERR_OR_NULL(dbg_data->dir)) {
-		dbg_data->dir = NULL;
-		rc = -ENODEV;
-		goto done;
-	}
-
-	debugfs_create_file("state", 0444, dbg_data->dir, spi, &state_fops);
-	debugfs_create_u32("addr", 0644, dbg_data->dir,
-			   &dbg_data->addr);
-	debugfs_create_u32("size", 0644, dbg_data->dir,
-			   &dbg_data->size);
-
-	debugfs_create_file("mem_read", 0444, dbg_data->dir,
-			    spi, &mem_read_fops);
-done:
-	return rc;
-}
-
-
-static const struct reg_default wcd_spi_defaults[] = {
-	{WCD_SPI_SLAVE_SANITY, 0xDEADBEEF},
-	{WCD_SPI_SLAVE_DEVICE_ID, 0x00500000},
-	{WCD_SPI_SLAVE_STATUS, 0x80100000},
-	{WCD_SPI_SLAVE_CONFIG, 0x0F200808},
-	{WCD_SPI_SLAVE_SW_RESET, 0x00000000},
-	{WCD_SPI_SLAVE_IRQ_STATUS, 0x00000000},
-	{WCD_SPI_SLAVE_IRQ_EN, 0x00000000},
-	{WCD_SPI_SLAVE_IRQ_CLR, 0x00000000},
-	{WCD_SPI_SLAVE_IRQ_FORCE, 0x00000000},
-	{WCD_SPI_SLAVE_TX, 0x00000000},
-	{WCD_SPI_SLAVE_TEST_BUS_DATA, 0x00000000},
-	{WCD_SPI_SLAVE_TEST_BUS_CTRL, 0x00000000},
-	{WCD_SPI_SLAVE_SW_RST_IRQ, 0x00000000},
-	{WCD_SPI_SLAVE_CHAR_CFG, 0x00000000},
-	{WCD_SPI_SLAVE_CHAR_DATA_MOSI, 0x00000000},
-	{WCD_SPI_SLAVE_CHAR_DATA_CS_N, 0x00000000},
-	{WCD_SPI_SLAVE_CHAR_DATA_MISO, 0x00000000},
-	{WCD_SPI_SLAVE_TRNS_BYTE_CNT, 0x00000000},
-	{WCD_SPI_SLAVE_TRNS_LEN, 0x00000000},
-	{WCD_SPI_SLAVE_FIFO_LEVEL, 0x00000000},
-	{WCD_SPI_SLAVE_GENERICS, 0x80000000},
-	{WCD_SPI_SLAVE_EXT_BASE_ADDR, 0x00000000},
-};
-
-static bool wcd_spi_is_volatile_reg(struct device *dev,
-				    unsigned int reg)
-{
-	switch (reg) {
-	case WCD_SPI_SLAVE_SANITY:
-	case WCD_SPI_SLAVE_STATUS:
-	case WCD_SPI_SLAVE_IRQ_STATUS:
-	case WCD_SPI_SLAVE_TX:
-	case WCD_SPI_SLAVE_SW_RST_IRQ:
-	case WCD_SPI_SLAVE_TRNS_BYTE_CNT:
-	case WCD_SPI_SLAVE_FIFO_LEVEL:
-	case WCD_SPI_SLAVE_GENERICS:
-		return true;
-	}
-
-	return false;
-}
-
-static bool wcd_spi_is_readable_reg(struct device *dev,
-				    unsigned int reg)
-{
-	switch (reg) {
-	case WCD_SPI_SLAVE_SW_RESET:
-	case WCD_SPI_SLAVE_IRQ_CLR:
-	case WCD_SPI_SLAVE_IRQ_FORCE:
-		return false;
-	}
-
-	return true;
-}
-
-static struct regmap_config wcd_spi_regmap_cfg = {
-	.reg_bits = 8,
-	.val_bits = 32,
-	.cache_type = REGCACHE_RBTREE,
-	.reg_defaults = wcd_spi_defaults,
-	.num_reg_defaults = ARRAY_SIZE(wcd_spi_defaults),
-	.max_register = WCD_SPI_MAX_REGISTER,
-	.volatile_reg = wcd_spi_is_volatile_reg,
-	.readable_reg = wcd_spi_is_readable_reg,
-};
-
-static int wdsp_spi_init(struct device *dev, void *priv_data)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	int ret;
-
-	ret = wcd_spi_init(spi);
-	if (ret < 0)
-		dev_err(&spi->dev, "%s: Init failed, err = %d\n",
-			__func__, ret);
-	return ret;
-}
-
-static int wdsp_spi_deinit(struct device *dev, void *priv_data)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-
-	/*
-	 * Deinit means the hardware is reset. Mark the cache
-	 * as dirty here, so init will sync the cache
-	 */
-	regcache_mark_dirty(wcd_spi->regmap);
-
-	return 0;
-}
-
-static struct wdsp_cmpnt_ops wdsp_spi_ops = {
-	.init = wdsp_spi_init,
-	.deinit = wdsp_spi_deinit,
-	.event_handler = wdsp_spi_event_handler,
-};
-
-static int wcd_spi_component_bind(struct device *dev,
-				  struct device *master,
-				  void *data)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int ret = 0;
-
-	wcd_spi->m_dev = master;
-	wcd_spi->m_ops = data;
-
-	if (wcd_spi->m_ops &&
-	    wcd_spi->m_ops->register_cmpnt_ops)
-		ret = wcd_spi->m_ops->register_cmpnt_ops(master, dev,
-							 wcd_spi,
-							 &wdsp_spi_ops);
-	if (ret) {
-		dev_err(dev, "%s: register_cmpnt_ops failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	wcd_spi->reg_bytes = DIV_ROUND_UP(wcd_spi_regmap_cfg.reg_bits, 8);
-	wcd_spi->val_bytes = DIV_ROUND_UP(wcd_spi_regmap_cfg.val_bits, 8);
-
-	wcd_spi->regmap = devm_regmap_init(&spi->dev, &wcd_spi_regmap_bus,
-					   &spi->dev, &wcd_spi_regmap_cfg);
-	if (IS_ERR(wcd_spi->regmap)) {
-		ret = PTR_ERR(wcd_spi->regmap);
-		dev_err(&spi->dev, "%s: Failed to allocate regmap, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	if (wcd_spi_debugfs_init(spi))
-		dev_err(&spi->dev, "%s: Failed debugfs init\n", __func__);
-
-	spi_message_init(&wcd_spi->msg1);
-	spi_message_add_tail(&wcd_spi->xfer1, &wcd_spi->msg1);
-
-	spi_message_init(&wcd_spi->msg2);
-	spi_message_add_tail(&wcd_spi->xfer2[0], &wcd_spi->msg2);
-	spi_message_add_tail(&wcd_spi->xfer2[1], &wcd_spi->msg2);
-
-	/* Pre-allocate the buffers */
-	wcd_spi->tx_buf = kzalloc(WCD_SPI_RW_MAX_BUF_SIZE,
-				  GFP_KERNEL | GFP_DMA);
-	if (!wcd_spi->tx_buf) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	wcd_spi->rx_buf = kzalloc(WCD_SPI_RW_MAX_BUF_SIZE,
-				  GFP_KERNEL | GFP_DMA);
-	if (!wcd_spi->rx_buf) {
-		kfree(wcd_spi->tx_buf);
-		wcd_spi->tx_buf = NULL;
-		ret = -ENOMEM;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static void wcd_spi_component_unbind(struct device *dev,
-				     struct device *master,
-				     void *data)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	struct wcd_spi_debug_data *dbg_data = &wcd_spi->debug_data;
-
-	debugfs_remove_recursive(dbg_data->dir);
-	dbg_data->dir = NULL;
-
-	wcd_spi->m_dev = NULL;
-	wcd_spi->m_ops = NULL;
-
-	spi_transfer_del(&wcd_spi->xfer1);
-	spi_transfer_del(&wcd_spi->xfer2[0]);
-	spi_transfer_del(&wcd_spi->xfer2[1]);
-
-	kfree(wcd_spi->tx_buf);
-	kfree(wcd_spi->rx_buf);
-	wcd_spi->tx_buf = NULL;
-	wcd_spi->rx_buf = NULL;
-}
-
-static const struct component_ops wcd_spi_component_ops = {
-	.bind = wcd_spi_component_bind,
-	.unbind = wcd_spi_component_unbind,
-};
-
-static int wcd_spi_probe(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi;
-	int ret = 0;
-
-	wcd_spi = devm_kzalloc(&spi->dev, sizeof(*wcd_spi),
-			       GFP_KERNEL);
-	if (!wcd_spi)
-		return -ENOMEM;
-
-	ret = of_property_read_u32(spi->dev.of_node,
-				   "qcom,mem-base-addr",
-				   &wcd_spi->mem_base_addr);
-	if (ret < 0) {
-		dev_err(&spi->dev, "%s: Missing %s DT entry",
-			__func__, "qcom,mem-base-addr");
-		goto err_ret;
-	}
-
-	dev_dbg(&spi->dev,
-		"%s: mem_base_addr 0x%x\n", __func__, wcd_spi->mem_base_addr);
-
-	mutex_init(&wcd_spi->clk_mutex);
-	mutex_init(&wcd_spi->xfer_mutex);
-	INIT_DELAYED_WORK(&wcd_spi->clk_dwork, wcd_spi_clk_work);
-	init_completion(&wcd_spi->resume_comp);
-
-	wcd_spi->spi = spi;
-	spi_set_drvdata(spi, wcd_spi);
-
-	ret = component_add(&spi->dev, &wcd_spi_component_ops);
-	if (ret) {
-		dev_err(&spi->dev, "%s: component_add failed err = %d\n",
-			__func__, ret);
-		goto err_component_add;
-	}
-
-	return ret;
-
-err_component_add:
-	mutex_destroy(&wcd_spi->clk_mutex);
-	mutex_destroy(&wcd_spi->xfer_mutex);
-err_ret:
-	devm_kfree(&spi->dev, wcd_spi);
-	spi_set_drvdata(spi, NULL);
-	return ret;
-}
-
-static int wcd_spi_remove(struct spi_device *spi)
-{
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-
-	component_del(&spi->dev, &wcd_spi_component_ops);
-
-	mutex_destroy(&wcd_spi->clk_mutex);
-	mutex_destroy(&wcd_spi->xfer_mutex);
-
-	devm_kfree(&spi->dev, wcd_spi);
-	spi_set_drvdata(spi, NULL);
-
-	return 0;
-}
-
-#ifdef CONFIG_PM
-static int wcd_spi_suspend(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-	int rc = 0;
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	if (!wcd_spi_can_suspend(wcd_spi)) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/*
-	 * If we are here, it is okay to let the suspend go
-	 * through for this driver. But, still need to notify
-	 * the master to make sure all other components can suspend
-	 * as well.
-	 */
-	if (wcd_spi->m_dev && wcd_spi->m_ops &&
-	  wcd_spi->m_ops->suspend) {
-		WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-		rc = wcd_spi->m_ops->suspend(wcd_spi->m_dev);
-		WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	}
-
-	if (rc == 0)
-		set_bit(WCD_SPI_IS_SUSPENDED, &wcd_spi->status_mask);
-	else
-		dev_dbg(&spi->dev, "%s: cannot suspend, err = %d\n",
-			__func__, rc);
-done:
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-	return rc;
-}
-
-static int wcd_spi_resume(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
-
-	WCD_SPI_MUTEX_LOCK(spi, wcd_spi->clk_mutex);
-	clear_bit(WCD_SPI_IS_SUSPENDED, &wcd_spi->status_mask);
-	complete(&wcd_spi->resume_comp);
-	WCD_SPI_MUTEX_UNLOCK(spi, wcd_spi->clk_mutex);
-
-	return 0;
-}
-
-static const struct dev_pm_ops wcd_spi_pm_ops = {
-	.suspend = wcd_spi_suspend,
-	.resume = wcd_spi_resume,
-};
-#endif
-
-static const struct of_device_id wcd_spi_of_match[] = {
-	{ .compatible = "qcom,wcd-spi-v2", },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, wcd_spi_of_match);
-
-static struct spi_driver wcd_spi_driver = {
-	.driver = {
-		.name = "wcd-spi-v2",
-		.of_match_table = wcd_spi_of_match,
-#ifdef CONFIG_PM
-		.pm = &wcd_spi_pm_ops,
-#endif
-	},
-	.probe = wcd_spi_probe,
-	.remove = wcd_spi_remove,
-};
-
-module_spi_driver(wcd_spi_driver);
-
-MODULE_DESCRIPTION("WCD SPI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
deleted file mode 100644
index 3891624..0000000
--- a/sound/soc/codecs/wcd9335.c
+++ /dev/null
@@ -1,14205 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/firmware.h>
-#include <linux/slab.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/debugfs.h>
-#include <linux/wait.h>
-#include <linux/bitops.h>
-#include <linux/regmap.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include <linux/mfd/wcd9335/registers.h>
-#include <linux/mfd/wcd9335/irq.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/soundwire/swr-wcd.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include <sound/info.h>
-#include "wcd9335.h"
-#include "wcd-mbhc-v2.h"
-#include "wcd9xxx-common-v2.h"
-#include "wcd9xxx-resmgr-v2.h"
-#include "wcd_cpe_core.h"
-#include "wcdcal-hwdep.h"
-#include "wcd-mbhc-v2-api.h"
-
-#define TASHA_RX_PORT_START_NUMBER  16
-
-#define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
-			    SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
-			    SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
-/* Fractional Rates */
-#define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
-
-#define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
-				SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
-
-#define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
-				  SNDRV_PCM_FMTBIT_S24_LE | \
-				  SNDRV_PCM_FMTBIT_S24_3LE)
-
-#define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
-				  SNDRV_PCM_FMTBIT_S24_LE | \
-				  SNDRV_PCM_FMTBIT_S24_3LE | \
-				  SNDRV_PCM_FMTBIT_S32_LE)
-
-#define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
-
-/*
- * Timeout in milli seconds and it is the wait time for
- * slim channel removal interrupt to receive.
- */
-#define TASHA_SLIM_CLOSE_TIMEOUT 1000
-#define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
-#define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
-#define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
-#define TASHA_MCLK_CLK_12P288MHZ 12288000
-#define TASHA_MCLK_CLK_9P6MHZ 9600000
-
-#define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
-
-#define TASHA_NUM_INTERPOLATORS 9
-#define TASHA_NUM_DECIMATORS 9
-
-#define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
-#define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
-#define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
-#define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
-
-#define TASHA_CPE_FATAL_IRQS \
-	(TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
-	 TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
-
-#define SLIM_BW_CLK_GEAR_9 6200000
-#define SLIM_BW_UNVOTE 0
-
-#define CPE_FLL_CLK_75MHZ 75000000
-#define CPE_FLL_CLK_150MHZ 150000000
-#define WCD9335_REG_BITS 8
-
-#define WCD9335_MAX_VALID_ADC_MUX  13
-#define WCD9335_INVALID_ADC_MUX 9
-
-#define TASHA_DIG_CORE_REG_MIN  WCD9335_CDC_ANC0_CLK_RESET_CTL
-#define TASHA_DIG_CORE_REG_MAX  0xDFF
-
-/* Convert from vout ctl to micbias voltage in mV */
-#define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
-
-#define TASHA_ZDET_NUM_MEASUREMENTS 900
-#define TASHA_MBHC_GET_C1(c)  ((c & 0xC000) >> 14)
-#define TASHA_MBHC_GET_X1(x)  (x & 0x3FFF)
-/* z value compared in milliOhm */
-#define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
-#define TASHA_MBHC_ZDET_CONST  (86 * 16384)
-#define TASHA_MBHC_MOISTURE_VREF  V_45_MV
-#define TASHA_MBHC_MOISTURE_IREF  I_3P0_UA
-
-#define TASHA_VERSION_ENTRY_SIZE 17
-
-#define WCD9335_AMIC_PWR_LEVEL_LP 0
-#define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
-#define WCD9335_AMIC_PWR_LEVEL_HP 2
-#define WCD9335_AMIC_PWR_LVL_MASK 0x60
-#define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
-
-#define WCD9335_DEC_PWR_LVL_MASK 0x06
-#define WCD9335_DEC_PWR_LVL_LP 0x02
-#define WCD9335_DEC_PWR_LVL_HP 0x04
-#define WCD9335_DEC_PWR_LVL_DF 0x00
-#define WCD9335_STRING_LEN 100
-
-#define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
-
-static int cpe_debug_mode;
-
-#define TASHA_MAX_MICBIAS 4
-#define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
-#define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
-#define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
-#define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
-
-#define DAPM_LDO_H_STANDALONE "LDO_H"
-module_param(cpe_debug_mode, int, 0664);
-MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
-
-#define TASHA_DIG_CORE_COLLAPSE_TIMER_MS  (5 * 1000)
-
-#define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH    64
-
-static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
-	"cdc-vdd-mic-bias",
-};
-
-enum {
-	POWER_COLLAPSE,
-	POWER_RESUME,
-};
-
-enum tasha_sido_voltage {
-	SIDO_VOLTAGE_SVS_MV = 950,
-	SIDO_VOLTAGE_NOMINAL_MV = 1100,
-};
-
-static enum codec_variant codec_ver;
-
-static int dig_core_collapse_enable = 1;
-module_param(dig_core_collapse_enable, int, 0664);
-MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
-
-/* dig_core_collapse timer in seconds */
-static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
-module_param(dig_core_collapse_timer, int, 0664);
-MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
-
-/* SVS Scaling enable/disable */
-static int svs_scaling_enabled = 1;
-module_param(svs_scaling_enabled, int, 0664);
-MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
-
-/* SVS buck setting */
-static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
-module_param(sido_buck_svs_voltage, int, 0664);
-MODULE_PARM_DESC(sido_buck_svs_voltage,
-			"setting for SVS voltage for SIDO BUCK");
-
-#define TASHA_TX_UNMUTE_DELAY_MS	40
-
-static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
-module_param(tx_unmute_delay, int, 0664);
-MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
-
-static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
-	.minor_version = 1,
-	.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
-	.slave_dev_pgd_la = 0,
-	.slave_dev_intfdev_la = 0,
-	.bit_width = 16,
-	.data_format = 0,
-	.num_channels = 1
-};
-
-struct tasha_mbhc_zdet_param {
-	u16 ldo_ctl;
-	u16 noff;
-	u16 nshift;
-	u16 btn5;
-	u16 btn6;
-	u16 btn7;
-};
-
-static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
-	.minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
-	.enable = 1,
-	.proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
-};
-
-static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
-		HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
-		HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
-		HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
-		MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
-		MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
-		MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
-		MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
-		VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
-		VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
-		VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
-		VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
-		VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
-		VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
-		VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
-		VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
-		SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
-		SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
-		SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
-		SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
-	},
-	{	1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
-		AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
-	},
-	{	1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
-		AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
-	},
-	{
-		1,
-		(TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
-		AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
-	},
-};
-
-static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
-	.num_registers = ARRAY_SIZE(audio_reg_cfg),
-	.reg_data = audio_reg_cfg,
-};
-
-static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
-	.cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
-	.aanc_hw_version        = AANC_HW_BLOCK_VERSION_2,
-};
-
-enum {
-	VI_SENSE_1,
-	VI_SENSE_2,
-	AIF4_SWITCH_VALUE,
-	AUDIO_NOMINAL,
-	CPE_NOMINAL,
-	HPH_PA_DELAY,
-	ANC_MIC_AMIC1,
-	ANC_MIC_AMIC2,
-	ANC_MIC_AMIC3,
-	ANC_MIC_AMIC4,
-	ANC_MIC_AMIC5,
-	ANC_MIC_AMIC6,
-	CLASSH_CONFIG,
-};
-
-enum {
-	AIF1_PB = 0,
-	AIF1_CAP,
-	AIF2_PB,
-	AIF2_CAP,
-	AIF3_PB,
-	AIF3_CAP,
-	AIF4_PB,
-	AIF_MIX1_PB,
-	AIF4_MAD_TX,
-	AIF4_VIFEED,
-	AIF5_CPE_TX,
-	NUM_CODEC_DAIS,
-};
-
-enum {
-	INTn_1_MIX_INP_SEL_ZERO = 0,
-	INTn_1_MIX_INP_SEL_DEC0,
-	INTn_1_MIX_INP_SEL_DEC1,
-	INTn_1_MIX_INP_SEL_IIR0,
-	INTn_1_MIX_INP_SEL_IIR1,
-	INTn_1_MIX_INP_SEL_RX0,
-	INTn_1_MIX_INP_SEL_RX1,
-	INTn_1_MIX_INP_SEL_RX2,
-	INTn_1_MIX_INP_SEL_RX3,
-	INTn_1_MIX_INP_SEL_RX4,
-	INTn_1_MIX_INP_SEL_RX5,
-	INTn_1_MIX_INP_SEL_RX6,
-	INTn_1_MIX_INP_SEL_RX7,
-
-};
-
-#define IS_VALID_NATIVE_FIFO_PORT(inp) \
-	((inp >= INTn_1_MIX_INP_SEL_RX0) && \
-	 (inp <= INTn_1_MIX_INP_SEL_RX3))
-
-enum {
-	INTn_2_INP_SEL_ZERO = 0,
-	INTn_2_INP_SEL_RX0,
-	INTn_2_INP_SEL_RX1,
-	INTn_2_INP_SEL_RX2,
-	INTn_2_INP_SEL_RX3,
-	INTn_2_INP_SEL_RX4,
-	INTn_2_INP_SEL_RX5,
-	INTn_2_INP_SEL_RX6,
-	INTn_2_INP_SEL_RX7,
-	INTn_2_INP_SEL_PROXIMITY,
-};
-
-enum {
-	INTERP_EAR = 0,
-	INTERP_HPHL,
-	INTERP_HPHR,
-	INTERP_LO1,
-	INTERP_LO2,
-	INTERP_LO3,
-	INTERP_LO4,
-	INTERP_SPKR1,
-	INTERP_SPKR2,
-};
-
-struct interp_sample_rate {
-	int sample_rate;
-	int rate_val;
-};
-
-static struct interp_sample_rate int_prim_sample_rate_val[] = {
-	{8000, 0x0},	/* 8K */
-	{16000, 0x1},	/* 16K */
-	{24000, -EINVAL},/* 24K */
-	{32000, 0x3},	/* 32K */
-	{48000, 0x4},	/* 48K */
-	{96000, 0x5},	/* 96K */
-	{192000, 0x6},	/* 192K */
-	{384000, 0x7},	/* 384K */
-	{44100, 0x8}, /* 44.1K */
-};
-
-static struct interp_sample_rate int_mix_sample_rate_val[] = {
-	{48000, 0x4},	/* 48K */
-	{96000, 0x5},	/* 96K */
-	{192000, 0x6},	/* 192K */
-};
-
-static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
-	WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
-};
-
-static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
-	WCD9XXX_CH(0, 0),
-	WCD9XXX_CH(1, 1),
-	WCD9XXX_CH(2, 2),
-	WCD9XXX_CH(3, 3),
-	WCD9XXX_CH(4, 4),
-	WCD9XXX_CH(5, 5),
-	WCD9XXX_CH(6, 6),
-	WCD9XXX_CH(7, 7),
-	WCD9XXX_CH(8, 8),
-	WCD9XXX_CH(9, 9),
-	WCD9XXX_CH(10, 10),
-	WCD9XXX_CH(11, 11),
-	WCD9XXX_CH(12, 12),
-	WCD9XXX_CH(13, 13),
-	WCD9XXX_CH(14, 14),
-	WCD9XXX_CH(15, 15),
-};
-
-static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
-	/* Needs to define in the same order of DAI enum definitions */
-	0,
-	BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
-	0,
-	BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
-	0,
-	BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
-	0,
-	0,
-	BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
-	0,
-	BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
-};
-
-static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
-	0,			/* AIF1_PB */
-	BIT(AIF2_CAP),		/* AIF1_CAP */
-	0,			/* AIF2_PB */
-	BIT(AIF1_CAP),		/* AIF2_CAP */
-};
-
-/* Codec supports 2 IIR filters */
-enum {
-	IIR0 = 0,
-	IIR1,
-	IIR_MAX,
-};
-
-/* Each IIR has 5 Filter Stages */
-enum {
-	BAND1 = 0,
-	BAND2,
-	BAND3,
-	BAND4,
-	BAND5,
-	BAND_MAX,
-};
-
-enum {
-	COMPANDER_1, /* HPH_L */
-	COMPANDER_2, /* HPH_R */
-	COMPANDER_3, /* LO1_DIFF */
-	COMPANDER_4, /* LO2_DIFF */
-	COMPANDER_5, /* LO3_SE */
-	COMPANDER_6, /* LO4_SE */
-	COMPANDER_7, /* SWR SPK CH1 */
-	COMPANDER_8, /* SWR SPK CH2 */
-	COMPANDER_MAX,
-};
-
-enum {
-	SRC_IN_HPHL,
-	SRC_IN_LO1,
-	SRC_IN_HPHR,
-	SRC_IN_LO2,
-	SRC_IN_SPKRL,
-	SRC_IN_LO3,
-	SRC_IN_SPKRR,
-	SRC_IN_LO4,
-};
-
-enum {
-	SPLINE_SRC0,
-	SPLINE_SRC1,
-	SPLINE_SRC2,
-	SPLINE_SRC3,
-	SPLINE_SRC_MAX,
-};
-
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
-static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
-static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
-
-static struct snd_soc_dai_driver tasha_dai[];
-static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
-
-static int tasha_config_compander(struct snd_soc_codec *, int, int);
-static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
-static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
-				  bool enable);
-
-/* Hold instance to soundwire platform device */
-struct tasha_swr_ctrl_data {
-	struct platform_device *swr_pdev;
-	struct ida swr_ida;
-};
-
-struct wcd_swr_ctrl_platform_data {
-	void *handle; /* holds codec private data */
-	int (*read)(void *handle, int reg);
-	int (*write)(void *handle, int reg, int val);
-	int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
-	int (*clk)(void *handle, bool enable);
-	int (*handle_irq)(void *handle,
-			  irqreturn_t (*swrm_irq_handler)(int irq,
-							  void *data),
-			  void *swrm_handle,
-			  int action);
-};
-
-static struct wcd_mbhc_register
-	wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
-	WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
-			  WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
-			  WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
-			  WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
-			  WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
-			  WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
-			  WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
-			  WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
-			  WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
-			  WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
-			  WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
-			  WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
-			  WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
-			  WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
-			  WCD9335_MBHC_CTL_1, 0x03, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
-			  WCD9335_MBHC_CTL_2, 0x03, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
-			  WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
-			  WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
-			  WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
-			  WCD9335_ANA_MICB2, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
-			  WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
-			  WCD9335_ANA_HPH, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
-			  WCD9335_ANA_HPH, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
-			  WCD9335_ANA_HPH, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
-			  WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
-			  0, 0, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
-			  WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
-	/*
-	 * MBHC FSM status register is only available in Tasha 2.0.
-	 * So, init with 0 later once the version is known, then values
-	 * will be updated.
-	 */
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
-			  0, 0, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
-			  WCD9335_MBHC_CTL_2, 0x70, 4, 0),
-};
-
-static const struct wcd_mbhc_intr intr_ids = {
-	.mbhc_sw_intr =  WCD9335_IRQ_MBHC_SW_DET,
-	.mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
-	.mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
-	.mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
-	.mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
-	.hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
-	.hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
-};
-
-struct wcd_vbat {
-	bool is_enabled;
-	bool adc_config;
-	/* Variables to cache Vbat ADC output values */
-	u16 dcp1;
-	u16 dcp2;
-};
-
-struct hpf_work {
-	struct tasha_priv *tasha;
-	u8 decimator;
-	u8 hpf_cut_off_freq;
-	struct delayed_work dwork;
-};
-
-#define WCD9335_SPK_ANC_EN_DELAY_MS 350
-static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
-module_param(spk_anc_en_delay, int, 0664);
-MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
-
-struct spk_anc_work {
-	struct tasha_priv *tasha;
-	struct delayed_work dwork;
-};
-
-struct tx_mute_work {
-	struct tasha_priv *tasha;
-	u8 decimator;
-	struct delayed_work dwork;
-};
-
-struct tasha_priv {
-	struct device *dev;
-	struct wcd9xxx *wcd9xxx;
-
-	struct snd_soc_codec *codec;
-	u32 adc_count;
-	u32 rx_bias_count;
-	s32 dmic_0_1_clk_cnt;
-	s32 dmic_2_3_clk_cnt;
-	s32 dmic_4_5_clk_cnt;
-	s32 ldo_h_users;
-	s32 micb_ref[TASHA_MAX_MICBIAS];
-	s32 pullup_ref[TASHA_MAX_MICBIAS];
-
-	u32 anc_slot;
-	bool anc_func;
-
-	/* Vbat module */
-	struct wcd_vbat vbat;
-
-	/* cal info for codec */
-	struct fw_info *fw_data;
-
-	/*track tasha interface type*/
-	u8 intf_type;
-
-	/* num of slim ports required */
-	struct wcd9xxx_codec_dai_data  dai[NUM_CODEC_DAIS];
-
-	/* SoundWire data structure */
-	struct tasha_swr_ctrl_data *swr_ctrl_data;
-	int nr;
-
-	/*compander*/
-	int comp_enabled[COMPANDER_MAX];
-
-	/* Maintain the status of AUX PGA */
-	int aux_pga_cnt;
-	u8 aux_l_gain;
-	u8 aux_r_gain;
-
-	bool spkr_pa_widget_on;
-	struct regulator *spkdrv_reg;
-	struct regulator *spkdrv2_reg;
-
-	bool mbhc_started;
-	/* class h specific data */
-	struct wcd_clsh_cdc_data clsh_d;
-
-	struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
-
-	/*
-	 * list used to save/restore registers at start and
-	 * end of impedance measurement
-	 */
-	struct list_head reg_save_restore;
-
-	/* handle to cpe core */
-	struct wcd_cpe_core *cpe_core;
-	u32 current_cpe_clk_freq;
-	enum tasha_sido_voltage sido_voltage;
-	int sido_ccl_cnt;
-
-	u32 ana_rx_supplies;
-	/* Multiplication factor used for impedance detection */
-	int zdet_gain_mul_fact;
-
-	/* to track the status */
-	unsigned long status_mask;
-
-	struct work_struct tasha_add_child_devices_work;
-	struct wcd_swr_ctrl_platform_data swr_plat_data;
-
-	/* Port values for Rx and Tx codec_dai */
-	unsigned int rx_port_value[TASHA_RX_MAX];
-	unsigned int tx_port_value;
-
-	unsigned int vi_feed_value;
-	/* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
-	u32 hph_mode;
-
-	u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
-	int spl_src_users[SPLINE_SRC_MAX];
-
-	struct wcd9xxx_resmgr_v2 *resmgr;
-	struct delayed_work power_gate_work;
-	struct mutex power_lock;
-	struct mutex sido_lock;
-
-	/* mbhc module */
-	struct wcd_mbhc mbhc;
-	struct blocking_notifier_head notifier;
-	struct mutex micb_lock;
-
-	struct clk *wcd_ext_clk;
-	struct clk *wcd_native_clk;
-	struct mutex swr_read_lock;
-	struct mutex swr_write_lock;
-	struct mutex swr_clk_lock;
-	int swr_clk_users;
-	int native_clk_users;
-	int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
-
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-	int power_active_ref;
-
-	struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
-
-	int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
-				      enum wcd9335_codec_event);
-	int spkr_gain_offset;
-	int spkr_mode;
-	int ear_spkr_gain;
-	struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
-	struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
-	struct spk_anc_work spk_anc_dwork;
-	struct mutex codec_mutex;
-	int hph_l_gain;
-	int hph_r_gain;
-	int rx_7_count;
-	int rx_8_count;
-	bool clk_mode;
-	bool clk_internal;
-	/* Lock to prevent multiple functions voting at same time */
-	struct mutex sb_clk_gear_lock;
-	/* Count for functions voting or un-voting */
-	u32 ref_count;
-	/* Lock to protect mclk enablement */
-	struct mutex mclk_lock;
-};
-
-static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
-				   bool vote);
-
-static const struct tasha_reg_mask_val tasha_spkr_default[] = {
-	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
-	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
-	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
-	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
-	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
-	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
-};
-
-static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
-	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
-	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
-	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
-	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
-	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
-	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
-};
-
-/**
- * tasha_set_spkr_gain_offset - offset the speaker path
- * gain with the given offset value.
- *
- * @codec: codec instance
- * @offset: Indicates speaker path gain offset value.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	if (!priv)
-		return -EINVAL;
-
-	priv->spkr_gain_offset = offset;
-	return 0;
-}
-EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
-
-/**
- * tasha_set_spkr_mode - Configures speaker compander and smartboost
- * settings based on speaker mode.
- *
- * @codec: codec instance
- * @mode: Indicates speaker configuration mode.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-	int i;
-	const struct tasha_reg_mask_val *regs;
-	int size;
-
-	if (!priv)
-		return -EINVAL;
-
-	switch (mode) {
-	case SPKR_MODE_1:
-		regs = tasha_spkr_mode1;
-		size = ARRAY_SIZE(tasha_spkr_mode1);
-		break;
-	default:
-		regs = tasha_spkr_default;
-		size = ARRAY_SIZE(tasha_spkr_default);
-		break;
-	}
-
-	priv->spkr_mode = mode;
-	for (i = 0; i < size; i++)
-		snd_soc_update_bits(codec, regs[i].reg,
-				    regs[i].mask, regs[i].val);
-	return 0;
-}
-EXPORT_SYMBOL(tasha_set_spkr_mode);
-
-static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
-	snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
-	/* 100us sleep needed after IREF settings */
-	usleep_range(100, 110);
-	snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
-	/* 100us sleep needed after VREF settings */
-	usleep_range(100, 110);
-	tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
-}
-
-static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
-{
-	struct snd_soc_codec *codec = tasha->codec;
-
-	if (!codec)
-		return;
-
-	if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
-		dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
-			__func__);
-		return;
-	}
-	dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
-			__func__, tasha->sido_ccl_cnt, ccl_flag);
-	if (ccl_flag) {
-		if (++tasha->sido_ccl_cnt == 1)
-			snd_soc_update_bits(codec,
-				WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
-	} else {
-		if (tasha->sido_ccl_cnt == 0) {
-			dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
-				__func__);
-			return;
-		}
-		if (--tasha->sido_ccl_cnt == 0)
-			snd_soc_update_bits(codec,
-				WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
-	}
-}
-
-static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
-{
-	if (TASHA_IS_2_0(tasha->wcd9xxx) &&
-		svs_scaling_enabled)
-		return true;
-
-	return false;
-}
-
-static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
-				     bool enable)
-{
-	int ret = 0;
-
-	mutex_lock(&tasha->mclk_lock);
-	if (enable) {
-		tasha_cdc_sido_ccl_enable(tasha, true);
-		ret = clk_prepare_enable(tasha->wcd_ext_clk);
-		if (ret) {
-			dev_err(tasha->dev, "%s: ext clk enable failed\n",
-				__func__);
-			goto unlock_mutex;
-		}
-		/* get BG */
-		wcd_resmgr_enable_master_bias(tasha->resmgr);
-		/* get MCLK */
-		wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
-	} else {
-		/* put MCLK */
-		wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
-		/* put BG */
-		wcd_resmgr_disable_master_bias(tasha->resmgr);
-		clk_disable_unprepare(tasha->wcd_ext_clk);
-		tasha_cdc_sido_ccl_enable(tasha, false);
-	}
-unlock_mutex:
-	mutex_unlock(&tasha->mclk_lock);
-	return ret;
-}
-
-static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
-{
-	if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
-		(req_mv != SIDO_VOLTAGE_NOMINAL_MV))
-		return -EINVAL;
-
-	return 0;
-}
-
-static void tasha_codec_apply_sido_voltage(
-				struct tasha_priv *tasha,
-				enum tasha_sido_voltage req_mv)
-{
-	u32 vout_d_val;
-	struct snd_soc_codec *codec = tasha->codec;
-	int ret;
-
-	if (!codec)
-		return;
-
-	if (!tasha_cdc_is_svs_enabled(tasha))
-		return;
-
-	if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
-		(sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
-		sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
-
-	ret = tasha_cdc_check_sido_value(req_mv);
-	if (ret < 0) {
-		dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
-			__func__, req_mv);
-		return;
-	}
-	if (req_mv == tasha->sido_voltage) {
-		dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
-			__func__, req_mv);
-		return;
-	}
-	if (req_mv == sido_buck_svs_voltage) {
-		if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
-			test_bit(CPE_NOMINAL, &tasha->status_mask)) {
-			dev_dbg(codec->dev,
-				"%s: nominal client running, status_mask=%lu\n",
-				__func__, tasha->status_mask);
-			return;
-		}
-	}
-	/* compute the vout_d step value */
-	vout_d_val = CALCULATE_VOUT_D(req_mv);
-	snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
-	snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
-
-	/* 1 msec sleep required after SIDO Vout_D voltage change */
-	usleep_range(1000, 1100);
-	tasha->sido_voltage = req_mv;
-	dev_dbg(codec->dev,
-		"%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
-		__func__, tasha->sido_voltage, vout_d_val);
-
-	snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
-				0x80, 0x00);
-}
-
-static int tasha_codec_update_sido_voltage(
-				struct tasha_priv *tasha,
-				enum tasha_sido_voltage req_mv)
-{
-	int ret = 0;
-
-	if (!tasha_cdc_is_svs_enabled(tasha))
-		return ret;
-
-	mutex_lock(&tasha->sido_lock);
-	/* enable mclk before setting SIDO voltage */
-	ret = tasha_cdc_req_mclk_enable(tasha, true);
-	if (ret) {
-		dev_err(tasha->dev, "%s: ext clk enable failed\n",
-			__func__);
-		goto err;
-	}
-	tasha_codec_apply_sido_voltage(tasha, req_mv);
-	tasha_cdc_req_mclk_enable(tasha, false);
-
-err:
-	mutex_unlock(&tasha->sido_lock);
-	return ret;
-}
-
-int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	tasha_cdc_mclk_enable(codec, true, false);
-
-	if (!TASHA_IS_2_0(priv->wcd9xxx))
-		snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
-				    0x1E, 0x02);
-	snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
-			    0x01, 0x01);
-	/*
-	 * 5ms sleep required after enabling efuse control
-	 * before checking the status.
-	 */
-	usleep_range(5000, 5500);
-	if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
-		WARN(1, "%s: Efuse sense is not complete\n", __func__);
-
-	if (TASHA_IS_2_0(priv->wcd9xxx)) {
-		if (!(snd_soc_read(codec,
-			WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
-			snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
-					    0x04, 0x00);
-		tasha_enable_sido_buck(codec);
-	}
-
-	tasha_cdc_mclk_enable(codec, false, false);
-
-	return 0;
-}
-EXPORT_SYMBOL(tasha_enable_efuse_sensing);
-
-void *tasha_get_afe_config(struct snd_soc_codec *codec,
-			   enum afe_config_type config_type)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	switch (config_type) {
-	case AFE_SLIMBUS_SLAVE_CONFIG:
-		return &priv->slimbus_slave_cfg;
-	case AFE_CDC_REGISTERS_CONFIG:
-		return &tasha_audio_reg_cfg;
-	case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
-		return &tasha_slimbus_slave_port_cfg;
-	case AFE_AANC_VERSION:
-		return &tasha_cdc_aanc_version;
-	case AFE_CLIP_BANK_SEL:
-		return NULL;
-	case AFE_CDC_CLIP_REGISTERS_CONFIG:
-		return NULL;
-	case AFE_CDC_REGISTER_PAGE_CONFIG:
-		return &tasha_cdc_reg_page_cfg;
-	default:
-		dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
-			__func__, config_type);
-		return NULL;
-	}
-}
-EXPORT_SYMBOL(tasha_get_afe_config);
-
-/*
- * tasha_event_register: Registers a machine driver callback
- * function with codec private data for post ADSP sub-system
- * restart (SSR). This callback function will be called from
- * codec driver once codec comes out of reset after ADSP SSR.
- *
- * @machine_event_cb: callback function from machine driver
- * @codec: Codec instance
- *
- * Return: none
- */
-void tasha_event_register(
-	int (*machine_event_cb)(struct snd_soc_codec *codec,
-				enum wcd9335_codec_event),
-	struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (tasha)
-		tasha->machine_codec_event_cb = machine_event_cb;
-	else
-		dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
-}
-EXPORT_SYMBOL(tasha_event_register);
-
-static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
-				   int irq, irq_handler_t handler,
-				   const char *name, void *data)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	return wcd9xxx_request_irq(core_res, irq, handler, name, data);
-}
-
-static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
-				   int irq, bool enable)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-	if (enable)
-		wcd9xxx_enable_irq(core_res, irq);
-	else
-		wcd9xxx_disable_irq(core_res, irq);
-}
-
-static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
-			       int irq, void *data)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	wcd9xxx_free_irq(core_res, irq, data);
-	return 0;
-}
-
-static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
-				 bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
-				    0x80, 0x80);
-	else
-		snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
-				    0x80, 0x00);
-}
-
-static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
-{
-	return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
-}
-
-static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
-					 bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
-				    0x01, 0x01);
-	else
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
-				    0x01, 0x00);
-}
-
-static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
-				       s16 *btn_low, s16 *btn_high,
-				       int num_btn, bool is_micbias)
-{
-	int i;
-	int vth;
-
-	if (num_btn > WCD_MBHC_DEF_BUTTONS) {
-		dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
-			__func__, num_btn);
-		return;
-	}
-	/*
-	 * Tasha just needs one set of thresholds for button detection
-	 * due to micbias voltage ramp to pullup upon button press. So
-	 * btn_low and is_micbias are ignored and always program button
-	 * thresholds using btn_high.
-	 */
-	for (i = 0; i < num_btn; i++) {
-		vth = ((btn_high[i] * 2) / 25) & 0x3F;
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
-				    0xFC, vth << 2);
-		dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
-			__func__, i, btn_high[i], vth);
-	}
-}
-
-static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-	if (lock)
-		return wcd9xxx_lock_sleep(core_res);
-	else {
-		wcd9xxx_unlock_sleep(core_res);
-		return 0;
-	}
-}
-
-static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
-					struct notifier_block *nblock,
-					bool enable)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (enable)
-		return blocking_notifier_chain_register(&tasha->notifier,
-							nblock);
-	else
-		return blocking_notifier_chain_unregister(&tasha->notifier,
-							  nblock);
-}
-
-static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
-{
-	u8 val;
-
-	if (micb_num == MIC_BIAS_2) {
-		val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
-		if (val == 0x01)
-			return true;
-	}
-	return false;
-}
-
-static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
-{
-	return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
-}
-
-static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
-					enum mbhc_hs_pullup_iref pull_up_cur)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (!tasha)
-		return;
-
-	/* Default pull up current to 2uA */
-	if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
-	    pull_up_cur == I_DEFAULT)
-		pull_up_cur = I_2P0_UA;
-
-	dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
-		__func__, pull_up_cur);
-
-	if (TASHA_IS_2_0(tasha->wcd9xxx))
-		snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
-			    0xC0, pull_up_cur << 6);
-	else
-		snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
-			    0xC0, 0x40);
-}
-
-static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
-		bool turn_on)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-	struct on_demand_supply *supply;
-
-	if (!tasha)
-		return -EINVAL;
-
-	supply =  &tasha->on_demand_list[ON_DEMAND_MICBIAS];
-	if (!supply->supply) {
-		dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
-				__func__, "onDemand Micbias");
-		return ret;
-	}
-
-	dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
-		supply->ondemand_supply_count);
-
-	if (turn_on) {
-		if (!(supply->ondemand_supply_count)) {
-			ret = snd_soc_dapm_force_enable_pin(
-				snd_soc_codec_get_dapm(codec),
-				"MICBIAS_REGULATOR");
-			snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-		}
-		supply->ondemand_supply_count++;
-	} else {
-		if (supply->ondemand_supply_count > 0)
-			supply->ondemand_supply_count--;
-		if (!(supply->ondemand_supply_count)) {
-			ret = snd_soc_dapm_disable_pin(
-				snd_soc_codec_get_dapm(codec),
-				"MICBIAS_REGULATOR");
-		snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-		}
-	}
-
-	if (ret)
-		dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
-			__func__, turn_on ? "enable" : "disabled");
-	else
-		dev_dbg(codec->dev, "%s: %s external micbias source\n",
-			__func__, turn_on ? "Enabled" : "Disabled");
-
-	return ret;
-}
-
-static int tasha_micbias_control(struct snd_soc_codec *codec,
-				 int micb_num,
-				 int req, bool is_dapm)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int micb_index = micb_num - 1;
-	u16 micb_reg;
-	int pre_off_event = 0, post_off_event = 0;
-	int post_on_event = 0, post_dapm_off = 0;
-	int post_dapm_on = 0;
-
-	if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
-		dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
-			__func__, micb_index);
-		return -EINVAL;
-	}
-	switch (micb_num) {
-	case MIC_BIAS_1:
-		micb_reg = WCD9335_ANA_MICB1;
-		break;
-	case MIC_BIAS_2:
-		micb_reg = WCD9335_ANA_MICB2;
-		pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
-		post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
-		post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
-		post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
-		post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
-		break;
-	case MIC_BIAS_3:
-		micb_reg = WCD9335_ANA_MICB3;
-		break;
-	case MIC_BIAS_4:
-		micb_reg = WCD9335_ANA_MICB4;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
-			__func__, micb_num);
-		return -EINVAL;
-	}
-	mutex_lock(&tasha->micb_lock);
-
-	switch (req) {
-	case MICB_PULLUP_ENABLE:
-		tasha->pullup_ref[micb_index]++;
-		if ((tasha->pullup_ref[micb_index] == 1) &&
-		    (tasha->micb_ref[micb_index] == 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-		break;
-	case MICB_PULLUP_DISABLE:
-		if (tasha->pullup_ref[micb_index] > 0)
-			tasha->pullup_ref[micb_index]--;
-		if ((tasha->pullup_ref[micb_index] == 0) &&
-		    (tasha->micb_ref[micb_index] == 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
-		break;
-	case MICB_ENABLE:
-		tasha->micb_ref[micb_index]++;
-		if (tasha->micb_ref[micb_index] == 1) {
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
-			if (post_on_event)
-				blocking_notifier_call_chain(&tasha->notifier,
-						post_on_event, &tasha->mbhc);
-		}
-		if (is_dapm && post_dapm_on)
-			blocking_notifier_call_chain(&tasha->notifier,
-					post_dapm_on, &tasha->mbhc);
-		break;
-	case MICB_DISABLE:
-		if (tasha->micb_ref[micb_index] > 0)
-			tasha->micb_ref[micb_index]--;
-		if ((tasha->micb_ref[micb_index] == 0) &&
-		    (tasha->pullup_ref[micb_index] > 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-		else if ((tasha->micb_ref[micb_index] == 0) &&
-			 (tasha->pullup_ref[micb_index] == 0)) {
-			if (pre_off_event)
-				blocking_notifier_call_chain(&tasha->notifier,
-						pre_off_event, &tasha->mbhc);
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
-			if (post_off_event)
-				blocking_notifier_call_chain(&tasha->notifier,
-						post_off_event, &tasha->mbhc);
-		}
-		if (is_dapm && post_dapm_off)
-			blocking_notifier_call_chain(&tasha->notifier,
-					post_dapm_off, &tasha->mbhc);
-		break;
-	};
-
-	dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
-		__func__, micb_num, tasha->micb_ref[micb_index],
-		tasha->pullup_ref[micb_index]);
-
-	mutex_unlock(&tasha->micb_lock);
-
-	return 0;
-}
-
-static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
-				      int micb_num, int req)
-{
-	int ret;
-
-	/*
-	 * If micbias is requested, make sure that there
-	 * is vote to enable mclk
-	 */
-	if (req == MICB_ENABLE)
-		tasha_cdc_mclk_enable(codec, true, false);
-
-	ret = tasha_micbias_control(codec, micb_num, req, false);
-
-	/*
-	 * Release vote for mclk while requesting for
-	 * micbias disable
-	 */
-	if (req == MICB_DISABLE)
-		tasha_cdc_mclk_enable(codec, false, false);
-
-	return ret;
-}
-
-static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
-					bool enable)
-{
-	if (enable) {
-		snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
-				    0x1C, 0x0C);
-		snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
-				    0x80, 0x80);
-	} else {
-		snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
-				    0x80, 0x00);
-		snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
-				    0x1C, 0x00);
-	}
-}
-
-static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
-						   enum wcd_cal_type type)
-{
-	struct tasha_priv *tasha;
-	struct firmware_cal *hwdep_cal;
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer\n", __func__);
-		return NULL;
-	}
-	tasha = snd_soc_codec_get_drvdata(codec);
-	hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
-	if (!hwdep_cal)
-		dev_err(codec->dev, "%s: cal not sent by %d\n",
-			__func__, type);
-
-	return hwdep_cal;
-}
-
-static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
-					  int req_volt,
-					  int micb_num)
-{
-	int cur_vout_ctl, req_vout_ctl;
-	int micb_reg, micb_val, micb_en;
-
-	switch (micb_num) {
-	case MIC_BIAS_1:
-		micb_reg = WCD9335_ANA_MICB1;
-		break;
-	case MIC_BIAS_2:
-		micb_reg = WCD9335_ANA_MICB2;
-		break;
-	case MIC_BIAS_3:
-		micb_reg = WCD9335_ANA_MICB3;
-		break;
-	case MIC_BIAS_4:
-		micb_reg = WCD9335_ANA_MICB4;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/*
-	 * If requested micbias voltage is same as current micbias
-	 * voltage, then just return. Otherwise, adjust voltage as
-	 * per requested value. If micbias is already enabled, then
-	 * to avoid slow micbias ramp-up or down enable pull-up
-	 * momentarily, change the micbias value and then re-enable
-	 * micbias.
-	 */
-	micb_val = snd_soc_read(codec, micb_reg);
-	micb_en = (micb_val & 0xC0) >> 6;
-	cur_vout_ctl = micb_val & 0x3F;
-
-	req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
-	if (req_vout_ctl < 0)
-		return -EINVAL;
-	if (cur_vout_ctl == req_vout_ctl)
-		return 0;
-
-	dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
-		 __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
-		 req_volt, micb_en);
-
-	if (micb_en == 0x1)
-		snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-
-	snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
-
-	if (micb_en == 0x1) {
-		snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
-		/*
-		 * Add 2ms delay as per HW requirement after enabling
-		 * micbias
-		 */
-		usleep_range(2000, 2100);
-	}
-
-	return 0;
-}
-
-static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
-					      int micb_num, bool req_en)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-	int rc, micb_mv;
-
-	if (micb_num != MIC_BIAS_2)
-		return -EINVAL;
-
-	/*
-	 * If device tree micbias level is already above the minimum
-	 * voltage needed to detect threshold microphone, then do
-	 * not change the micbias, just return.
-	 */
-	if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
-		return 0;
-
-	micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
-
-	mutex_lock(&tasha->micb_lock);
-	rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
-	mutex_unlock(&tasha->micb_lock);
-
-	return rc;
-}
-
-static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
-						s16 *d1_a, u16 noff,
-						int32_t *zdet)
-{
-	int i;
-	int val, val1;
-	s16 c1;
-	s32 x1, d1;
-	int32_t denom;
-	int minCode_param[] = {
-			3277, 1639, 820, 410, 205, 103, 52, 26
-	};
-
-	regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
-	for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
-		regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
-		if (val & 0x80)
-			break;
-	}
-	val = val << 0x8;
-	regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
-	val |= val1;
-	regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
-	x1 = TASHA_MBHC_GET_X1(val);
-	c1 = TASHA_MBHC_GET_C1(val);
-	/* If ramp is not complete, give additional 5ms */
-	if ((c1 < 2) && x1)
-		usleep_range(5000, 5050);
-
-	if (!c1 || !x1) {
-		dev_dbg(wcd9xxx->dev,
-			"%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
-			__func__, c1, x1);
-		goto ramp_down;
-	}
-	d1 = d1_a[c1];
-	denom = (x1 * d1) - (1 << (14 - noff));
-	if (denom > 0)
-		*zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
-	else if (x1 < minCode_param[noff])
-		*zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
-
-	dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
-		__func__, d1, c1, x1, *zdet);
-ramp_down:
-	i = 0;
-	while (x1) {
-		regmap_bulk_read(wcd9xxx->regmap,
-				 WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
-		x1 = TASHA_MBHC_GET_X1(val);
-		i++;
-		if (i == TASHA_ZDET_NUM_MEASUREMENTS)
-			break;
-	}
-}
-
-/*
- * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
- * controlling the switch on hifi amps. Default switch state
- * will put a 51ohm load in parallel to the hph load. So,
- * impedance detection function will pull the gpio high
- * to make the switch open.
- *
- * @zdet_gpio_cb: callback function from machine driver
- * @codec: Codec instance
- *
- * Return: none
- */
-void tasha_mbhc_zdet_gpio_ctrl(
-		int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
-		struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	tasha->zdet_gpio_cb = zdet_gpio_cb;
-}
-EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
-
-static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
-				 struct tasha_mbhc_zdet_param *zdet_param,
-				 int32_t *zl, int32_t *zr, s16 *d1_a)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int32_t zdet = 0;
-
-	snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
-			    zdet_param->ldo_ctl << 4);
-	snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
-			    zdet_param->btn5);
-	snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
-			    zdet_param->btn6);
-	snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
-			    zdet_param->btn7);
-	snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
-			    zdet_param->noff);
-	snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
-			    zdet_param->nshift);
-
-	if (!zl)
-		goto z_right;
-	/* Start impedance measurement for HPH_L */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
-	dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
-					__func__, zdet_param->noff);
-	tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
-
-	*zl = zdet;
-
-z_right:
-	if (!zr)
-		return;
-	/* Start impedance measurement for HPH_R */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
-	dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
-					__func__, zdet_param->noff);
-	tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
-
-	*zr = zdet;
-}
-
-static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
-					int32_t *z_val, int flag_l_r)
-{
-	s16 q1;
-	int q1_cal;
-
-	if (*z_val < (TASHA_ZDET_VAL_400/1000))
-		q1 = snd_soc_read(codec,
-			WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
-	else
-		q1 = snd_soc_read(codec,
-			WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
-	if (q1 & 0x80)
-		q1_cal = (10000 - ((q1 & 0x7F) * 25));
-	else
-		q1_cal = (10000 + (q1 * 25));
-	if (q1_cal > 0)
-		*z_val = ((*z_val) * 10000) / q1_cal;
-}
-
-static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
-					  uint32_t *zr)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	s16 reg0, reg1, reg2, reg3, reg4;
-	int32_t z1L, z1R, z1Ls;
-	int zMono, z_diff1, z_diff2;
-	bool is_fsm_disable = false;
-	bool is_change = false;
-	struct tasha_mbhc_zdet_param zdet_param[] = {
-		{4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
-		{2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
-		{1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
-		{1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
-	};
-	struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
-	s16 d1_a[][4] = {
-		{0, 30, 90, 30},
-		{0, 30, 30, 5},
-		{0, 30, 30, 5},
-		{0, 30, 30, 5},
-	};
-	s16 *d1 = NULL;
-
-	if (!TASHA_IS_2_0(wcd9xxx)) {
-		dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
-					__func__);
-		*zl = 0;
-		*zr = 0;
-		return;
-	}
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	if (tasha->zdet_gpio_cb)
-		is_change = tasha->zdet_gpio_cb(codec, true);
-
-	reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
-	reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
-	reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
-	reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
-	reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
-
-	if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
-		is_fsm_disable = true;
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
-	}
-
-	/* For NO-jack, disable L_DET_EN before Z-det measurements */
-	if (mbhc->hphl_swh)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
-
-	/* Enable AZ */
-	snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
-	/* Turn off 100k pull down on HPHL */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
-
-	/* First get impedance on Left */
-	d1 = d1_a[1];
-	zdet_param_ptr = &zdet_param[1];
-	tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
-
-	if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
-		goto left_ch_impedance;
-
-	/* second ramp for left ch */
-	if (z1L < TASHA_ZDET_VAL_32) {
-		zdet_param_ptr = &zdet_param[0];
-		d1 = d1_a[0];
-	} else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
-		zdet_param_ptr = &zdet_param[2];
-		d1 = d1_a[2];
-	} else if (z1L > TASHA_ZDET_VAL_1200) {
-		zdet_param_ptr = &zdet_param[3];
-		d1 = d1_a[3];
-	}
-	tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
-
-left_ch_impedance:
-	if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
-		(z1L > TASHA_ZDET_VAL_100K)) {
-		*zl = TASHA_ZDET_FLOATING_IMPEDANCE;
-		zdet_param_ptr = &zdet_param[1];
-		d1 = d1_a[1];
-	} else {
-		*zl = z1L/1000;
-		tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
-	}
-	dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
-				__func__, *zl);
-
-	/* start of right impedance ramp and calculation */
-	tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
-	if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
-		if (((z1R > TASHA_ZDET_VAL_1200) &&
-			(zdet_param_ptr->noff == 0x6)) ||
-			((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
-			goto right_ch_impedance;
-		/* second ramp for right ch */
-		if (z1R < TASHA_ZDET_VAL_32) {
-			zdet_param_ptr = &zdet_param[0];
-			d1 = d1_a[0];
-		} else if ((z1R > TASHA_ZDET_VAL_400) &&
-			(z1R <= TASHA_ZDET_VAL_1200)) {
-			zdet_param_ptr = &zdet_param[2];
-			d1 = d1_a[2];
-		} else if (z1R > TASHA_ZDET_VAL_1200) {
-			zdet_param_ptr = &zdet_param[3];
-			d1 = d1_a[3];
-		}
-		tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
-	}
-right_ch_impedance:
-	if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
-		(z1R > TASHA_ZDET_VAL_100K)) {
-		*zr = TASHA_ZDET_FLOATING_IMPEDANCE;
-	} else {
-		*zr = z1R/1000;
-		tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
-	}
-	dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
-				__func__, *zr);
-
-	/* mono/stereo detection */
-	if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
-		(*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
-		dev_dbg(codec->dev,
-			"%s: plug type is invalid or extension cable\n",
-			__func__);
-		goto zdet_complete;
-	}
-	if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
-	    (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
-	    ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
-	    ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
-		dev_dbg(codec->dev,
-			"%s: Mono plug type with one ch floating or shorted to GND\n",
-			__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_MONO;
-		goto zdet_complete;
-	}
-	snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
-	snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
-	if (*zl < (TASHA_ZDET_VAL_32/1000))
-		tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
-	else
-		tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
-	snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
-	snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
-	z1Ls /= 1000;
-	tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
-	/* parallel of left Z and 9 ohm pull down resistor */
-	zMono = ((*zl) * 9) / ((*zl) + 9);
-	z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
-	z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
-	if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
-		dev_dbg(codec->dev, "%s: stereo plug type detected\n",
-				__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_STEREO;
-	} else {
-		dev_dbg(codec->dev, "%s: MONO plug type detected\n",
-			 __func__);
-		mbhc->hph_type = WCD_MBHC_HPH_MONO;
-	}
-
-zdet_complete:
-	snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
-	snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
-	snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
-	/* Turn on 100k pull down on HPHL */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
-
-	/* For NO-jack, re-enable L_DET_EN after Z-det measurements */
-	if (mbhc->hphl_swh)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
-
-	snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
-	snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
-	if (is_fsm_disable)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
-	if (tasha->zdet_gpio_cb && is_change)
-		tasha->zdet_gpio_cb(codec, false);
-}
-
-static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-	if (enable) {
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
-				    0x02, 0x02);
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
-				    0x40, 0x40);
-	} else {
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
-				    0x40, 0x00);
-		snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
-				    0x02, 0x00);
-	}
-}
-
-static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
-					  bool enable)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (enable) {
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
-				    0x40, 0x40);
-		if (TASHA_IS_2_0(tasha->wcd9xxx))
-			snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
-					    0x10, 0x10);
-	} else {
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
-				    0x40, 0x00);
-		if (TASHA_IS_2_0(tasha->wcd9xxx))
-			snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
-					    0x10, 0x00);
-	}
-}
-
-static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	if (mbhc->moist_vref == V_OFF)
-		return;
-
-	/* Donot enable moisture detection if jack type is NC */
-	if (!mbhc->hphl_swh) {
-		dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
-			__func__);
-		return;
-	}
-
-	snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
-			    0x0C, mbhc->moist_vref << 2);
-	tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
-}
-
-static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
-				   int anc_num)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
-				(20 * anc_num), 0x10, 0x10);
-	else
-		snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
-				(20 * anc_num), 0x10, 0x00);
-}
-
-static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
-{
-	bool anc_on = false;
-	u16 ancl, ancr;
-
-	ancl =
-	(snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
-	ancr =
-	(snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
-
-	anc_on = !!(ancl | ancr);
-
-	return anc_on;
-}
-
-static const struct wcd_mbhc_cb mbhc_cb = {
-	.request_irq = tasha_mbhc_request_irq,
-	.irq_control = tasha_mbhc_irq_control,
-	.free_irq = tasha_mbhc_free_irq,
-	.clk_setup = tasha_mbhc_clk_setup,
-	.map_btn_code_to_num = tasha_mbhc_btn_to_num,
-	.enable_mb_source = tasha_enable_ext_mb_source,
-	.mbhc_bias = tasha_mbhc_mbhc_bias_control,
-	.set_btn_thr = tasha_mbhc_program_btn_thr,
-	.lock_sleep = tasha_mbhc_lock_sleep,
-	.register_notifier = tasha_mbhc_register_notifier,
-	.micbias_enable_status = tasha_mbhc_micb_en_status,
-	.hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
-	.hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
-	.mbhc_micbias_control = tasha_mbhc_request_micbias,
-	.mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
-	.get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
-	.mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
-	.compute_impedance = tasha_wcd_mbhc_calc_impedance,
-	.mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
-	.hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
-	.mbhc_moisture_config = tasha_mbhc_moisture_config,
-	.update_anc_state = tasha_update_anc_state,
-	.is_anc_on = tasha_is_anc_on,
-};
-
-static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha->anc_slot;
-	return 0;
-}
-
-static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	tasha->anc_slot = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
-	return 0;
-}
-
-static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
-	mutex_lock(&tasha->codec_mutex);
-	tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
-
-	dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
-
-	if (tasha->anc_func == true) {
-		snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
-		snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
-		snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC EAR");
-		snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
-		snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
-		snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
-		snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
-		snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
-		snd_soc_dapm_disable_pin(dapm, "HPHR");
-		snd_soc_dapm_disable_pin(dapm, "HPHL");
-		snd_soc_dapm_disable_pin(dapm, "HPHR PA");
-		snd_soc_dapm_disable_pin(dapm, "HPHL PA");
-		snd_soc_dapm_disable_pin(dapm, "EAR PA");
-		snd_soc_dapm_disable_pin(dapm, "EAR");
-	} else {
-		snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
-		snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC EAR");
-		snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
-		snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
-		snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
-		snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
-		snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
-		snd_soc_dapm_enable_pin(dapm, "HPHR");
-		snd_soc_dapm_enable_pin(dapm, "HPHL");
-		snd_soc_dapm_enable_pin(dapm, "HPHR PA");
-		snd_soc_dapm_enable_pin(dapm, "HPHL PA");
-		snd_soc_dapm_enable_pin(dapm, "EAR PA");
-		snd_soc_dapm_enable_pin(dapm, "EAR");
-	}
-	mutex_unlock(&tasha->codec_mutex);
-	snd_soc_dapm_sync(dapm);
-	return 0;
-}
-
-static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.enumerated.item[0] = tasha->clk_mode;
-	dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
-
-	return 0;
-}
-
-static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	tasha->clk_mode = ucontrol->value.enumerated.item[0];
-	dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
-
-	return 0;
-}
-
-static int tasha_get_iir_enable_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	/* IIR filter band registers are at integer multiples of 16 */
-	u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
-
-	ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
-					    (1 << band_idx)) != 0;
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
-		iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	uint32_t zl, zr;
-	bool hphr;
-	struct soc_multi_mixer_control *mc;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
-	hphr = mc->shift;
-	wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
-	dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
-	ucontrol->value.integer.value[0] = hphr ? zr : zl;
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
-		       tasha_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
-		       tasha_hph_impedance_get, NULL),
-};
-
-static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-	struct wcd_mbhc *mbhc;
-
-	if (!priv) {
-		dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
-				__func__);
-		return 0;
-	}
-
-	mbhc = &priv->mbhc;
-	if (!mbhc) {
-		dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
-		return 0;
-	}
-
-	ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
-	dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
-		       tasha_get_hph_type, NULL),
-};
-
-static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
-
-	return 0;
-}
-
-static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = tasha_p->wcd9xxx;
-	struct soc_multi_mixer_control *mixer =
-		((struct soc_multi_mixer_control *)kcontrol->private_value);
-	u32 dai_id = widget->shift;
-	u32 port_id = mixer->shift;
-	u32 enable = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
-		__func__, enable, port_id, dai_id);
-
-	tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
-
-	mutex_lock(&tasha_p->codec_mutex);
-	if (enable) {
-		if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
-						&tasha_p->status_mask)) {
-			list_add_tail(&core->tx_chs[TASHA_TX14].list,
-					&tasha_p->dai[dai_id].wcd9xxx_ch_list);
-			set_bit(VI_SENSE_1, &tasha_p->status_mask);
-		}
-		if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
-						&tasha_p->status_mask)) {
-			list_add_tail(&core->tx_chs[TASHA_TX15].list,
-					&tasha_p->dai[dai_id].wcd9xxx_ch_list);
-			set_bit(VI_SENSE_2, &tasha_p->status_mask);
-		}
-	} else {
-		if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
-					&tasha_p->status_mask)) {
-			list_del_init(&core->tx_chs[TASHA_TX14].list);
-			clear_bit(VI_SENSE_1, &tasha_p->status_mask);
-		}
-		if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
-					&tasha_p->status_mask)) {
-			list_del_init(&core->tx_chs[TASHA_TX15].list);
-			clear_bit(VI_SENSE_2, &tasha_p->status_mask);
-		}
-	}
-	mutex_unlock(&tasha_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
-
-	return 0;
-}
-
-/* virtual port entries */
-static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
-	return 0;
-}
-
-static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
-	struct snd_soc_dapm_update *update = NULL;
-	struct soc_multi_mixer_control *mixer =
-		((struct soc_multi_mixer_control *)kcontrol->private_value);
-	u32 dai_id = widget->shift;
-	u32 port_id = mixer->shift;
-	u32 enable = ucontrol->value.integer.value[0];
-	u32 vtable;
-
-
-	dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
-		  __func__,
-		widget->name, ucontrol->id.name, tasha_p->tx_port_value,
-		widget->shift, ucontrol->value.integer.value[0]);
-
-	mutex_lock(&tasha_p->codec_mutex);
-
-	if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		if (dai_id != AIF1_CAP) {
-			dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
-				__func__);
-			mutex_unlock(&tasha_p->codec_mutex);
-			return -EINVAL;
-		}
-		vtable = vport_slim_check_table[dai_id];
-	} else {
-		if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
-			dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
-				__func__, dai_id);
-			return -EINVAL;
-		}
-		vtable = vport_i2s_check_table[dai_id];
-	}
-	switch (dai_id) {
-	case AIF1_CAP:
-	case AIF2_CAP:
-	case AIF3_CAP:
-		/* only add to the list if value not set */
-		if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
-
-			if (wcd9xxx_tx_vport_validation(vtable, port_id,
-					tasha_p->dai, NUM_CODEC_DAIS)) {
-				dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
-					__func__, port_id);
-				mutex_unlock(&tasha_p->codec_mutex);
-				return 0;
-			}
-			tasha_p->tx_port_value |= 1 << port_id;
-			list_add_tail(&core->tx_chs[port_id].list,
-			      &tasha_p->dai[dai_id].wcd9xxx_ch_list
-					      );
-		} else if (!enable && (tasha_p->tx_port_value &
-					1 << port_id)) {
-			tasha_p->tx_port_value &= ~(1 << port_id);
-			list_del_init(&core->tx_chs[port_id].list);
-		} else {
-			if (enable)
-				dev_dbg(codec->dev, "%s: TX%u port is used by\n"
-					"this virtual port\n",
-					__func__, port_id);
-			else
-				dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
-					"this virtual port\n",
-					__func__, port_id);
-			/* avoid update power function */
-			mutex_unlock(&tasha_p->codec_mutex);
-			return 0;
-		}
-		break;
-	case AIF4_MAD_TX:
-	case AIF5_CPE_TX:
-		break;
-	default:
-		pr_err("Unknown AIF %d\n", dai_id);
-		mutex_unlock(&tasha_p->codec_mutex);
-		return -EINVAL;
-	}
-	pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
-		widget->name, widget->sname, tasha_p->tx_port_value,
-		widget->shift);
-
-	mutex_unlock(&tasha_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
-
-	return 0;
-}
-
-static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.enumerated.item[0] =
-			tasha_p->rx_port_value[widget->shift];
-	return 0;
-}
-
-static const char *const slim_rx_mux_text[] = {
-	"ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
-};
-
-static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-	unsigned int rx_port_value;
-	u32 port_id = widget->shift;
-
-	tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
-	rx_port_value = tasha_p->rx_port_value[port_id];
-
-	pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
-		widget->name, ucontrol->id.name, rx_port_value,
-		widget->shift, ucontrol->value.integer.value[0]);
-
-	mutex_lock(&tasha_p->codec_mutex);
-
-	if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		if (rx_port_value > 2) {
-			dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
-				__func__);
-			goto err;
-		}
-	}
-	/* value need to match the Virtual port and AIF number */
-	switch (rx_port_value) {
-	case 0:
-		list_del_init(&core->rx_chs[port_id].list);
-		break;
-	case 1:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			TASHA_RX_PORT_START_NUMBER,
-			&tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
-		break;
-	case 2:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			TASHA_RX_PORT_START_NUMBER,
-			&tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
-		break;
-	case 3:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			TASHA_RX_PORT_START_NUMBER,
-			&tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
-		break;
-	case 4:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			TASHA_RX_PORT_START_NUMBER,
-			&tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
-		break;
-	case 5:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			TASHA_RX_PORT_START_NUMBER,
-			&tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
-		break;
-	default:
-		pr_err("Unknown AIF %d\n", rx_port_value);
-		goto err;
-	}
-rtn:
-	mutex_unlock(&tasha_p->codec_mutex);
-	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
-					rx_port_value, e, update);
-
-	return 0;
-err:
-	mutex_unlock(&tasha_p->codec_mutex);
-	return -EINVAL;
-}
-
-static const struct soc_enum slim_rx_mux_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
-
-static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
-	SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-	SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
-			  slim_rx_mux_get, slim_rx_mux_put),
-};
-
-static const struct snd_kcontrol_new aif4_vi_mixer[] = {
-	SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
-			tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
-	SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
-			tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif1_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif2_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif3_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif4_mad_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-
-};
-
-static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
-	SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
-	SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
-	SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
-	SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
-	SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
-};
-
-
-
-static int tasha_put_iir_enable_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	bool iir_band_en_status;
-	int value = ucontrol->value.integer.value[0];
-	u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
-
-	/* Mask first 5 bits, 6-8 are reserved */
-	snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
-			    (value << band_idx));
-
-	iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
-			      (1 << band_idx)) != 0);
-	pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
-		iir_idx, band_idx, iir_band_en_status);
-	return 0;
-}
-
-static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
-				int iir_idx, int band_idx,
-				int coeff_idx)
-{
-	uint32_t value = 0;
-
-	/* Address does not automatically update if reading */
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t)) & 0x7F);
-
-	value |= snd_soc_read(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
-
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 1) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-			       (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				16 * iir_idx)) << 8);
-
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 2) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-			       (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				16 * iir_idx)) << 16);
-
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 3) & 0x7F);
-
-	/* Mask bits top 2 bits since they are reserved */
-	value |= ((snd_soc_read(codec,
-				(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				 16 * iir_idx)) & 0x3F) << 24);
-
-	return value;
-}
-
-static int tasha_get_iir_band_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	ucontrol->value.integer.value[0] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0);
-	ucontrol->value.integer.value[1] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1);
-	ucontrol->value.integer.value[2] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2);
-	ucontrol->value.integer.value[3] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3);
-	ucontrol->value.integer.value[4] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4);
-
-	pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[1],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[2],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[3],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[4]);
-	return 0;
-}
-
-static void set_iir_band_coeff(struct snd_soc_codec *codec,
-				int iir_idx, int band_idx,
-				uint32_t value)
-{
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value & 0xFF));
-
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 8) & 0xFF);
-
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 16) & 0xFF);
-
-	/* Mask top 2 bits, 7-8 are reserved */
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 24) & 0x3F);
-}
-
-static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
-					struct snd_soc_codec *codec)
-{
-	struct wcd9xxx_ch *ch;
-	int port_num = 0;
-	unsigned short reg = 0;
-	u8 val = 0;
-	struct tasha_priv *tasha_p;
-
-	if (!dai || !codec) {
-		pr_err("%s: Invalid params\n", __func__);
-		return;
-	}
-
-	tasha_p = snd_soc_codec_get_drvdata(codec);
-	list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-		if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
-			port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
-			reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
-			val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
-				reg);
-			if (!(val & BYTE_BIT_MASK(port_num))) {
-				val |= BYTE_BIT_MASK(port_num);
-				wcd9xxx_interface_reg_write(
-					tasha_p->wcd9xxx, reg, val);
-				val = wcd9xxx_interface_reg_read(
-					tasha_p->wcd9xxx, reg);
-			}
-		} else {
-			port_num = ch->port;
-			reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
-			val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
-				reg);
-			if (!(val & BYTE_BIT_MASK(port_num))) {
-				val |= BYTE_BIT_MASK(port_num);
-				wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
-					reg, val);
-				val = wcd9xxx_interface_reg_read(
-					tasha_p->wcd9xxx, reg);
-			}
-		}
-	}
-}
-
-static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
-					  bool up)
-{
-	int ret = 0;
-	struct wcd9xxx_ch *ch;
-
-	if (up) {
-		list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-			ret = wcd9xxx_get_slave_port(ch->ch_num);
-			if (ret < 0) {
-				pr_err("%s: Invalid slave port ID: %d\n",
-				       __func__, ret);
-				ret = -EINVAL;
-			} else {
-				set_bit(ret, &dai->ch_mask);
-			}
-		}
-	} else {
-		ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
-					 msecs_to_jiffies(
-						TASHA_SLIM_CLOSE_TIMEOUT));
-		if (!ret) {
-			pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
-				__func__, dai->ch_mask);
-			ret = -ETIMEDOUT;
-		} else {
-			ret = 0;
-		}
-	}
-	return ret;
-}
-
-static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct wcd9xxx *core;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-	struct wcd9xxx_codec_dai_data *dai;
-
-	core = dev_get_drvdata(codec->dev->parent);
-
-	dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
-		"stream name %s event %d\n",
-		__func__, codec->component.name,
-		codec->component.num_dai, w->sname, event);
-
-	/* Execute the callback only if interface type is slimbus */
-	if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-		return 0;
-
-	dai = &tasha_p->dai[w->shift];
-	dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
-		 __func__, w->name, w->shift, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		dai->bus_down_in_recovery = false;
-		tasha_codec_enable_int_port(dai, codec);
-		(void) tasha_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		tasha_codec_vote_max_bw(codec, true);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
-					      dai->grph);
-		dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
-			__func__, ret);
-
-		if (!dai->bus_down_in_recovery)
-			ret = tasha_codec_enable_slim_chmask(dai, false);
-		else
-			dev_dbg(codec->dev,
-				"%s: bus in recovery skip enable slim_chmask",
-				__func__);
-		ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		break;
-	}
-	return ret;
-}
-
-static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
-					      struct snd_kcontrol *kcontrol,
-					      int event)
-{
-	struct wcd9xxx *core = NULL;
-	struct snd_soc_codec *codec = NULL;
-	struct tasha_priv *tasha_p = NULL;
-	int ret = 0;
-	struct wcd9xxx_codec_dai_data *dai = NULL;
-
-	if (!w) {
-		pr_err("%s invalid params\n", __func__);
-		return -EINVAL;
-	}
-	codec = snd_soc_dapm_to_codec(w->dapm);
-	tasha_p = snd_soc_codec_get_drvdata(codec);
-	core = tasha_p->wcd9xxx;
-
-	dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
-		__func__, codec->component.num_dai, w->sname);
-
-	/* Execute the callback only if interface type is slimbus */
-	if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		dev_err(codec->dev, "%s Interface is not correct", __func__);
-		return 0;
-	}
-
-	dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
-		__func__, w->name, event, w->shift);
-	if (w->shift != AIF4_VIFEED) {
-		pr_err("%s Error in enabling the tx path\n", __func__);
-		ret = -EINVAL;
-		goto out_vi;
-	}
-	dai = &tasha_p->dai[w->shift];
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
-			dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
-			pr_debug("%s: spkr2 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		dai->bus_down_in_recovery = false;
-		tasha_codec_enable_int_port(dai, codec);
-		(void) tasha_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		if (ret)
-			dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
-				__func__, ret);
-		if (!dai->bus_down_in_recovery)
-			ret = tasha_codec_enable_slim_chmask(dai, false);
-		if (ret < 0) {
-			ret = wcd9xxx_disconnect_port(core,
-				&dai->wcd9xxx_ch_list,
-				dai->grph);
-			dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
-				__func__, ret);
-		}
-		if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		break;
-	}
-out_vi:
-	return ret;
-}
-
-/*
- * __tasha_codec_enable_slimtx: Enable the slimbus slave port
- *				 for TX path
- * @codec: Handle to the codec for which the slave port is to be
- *	   enabled.
- * @dai_data: The dai specific data for dai which is enabled.
- */
-static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
-		int event, struct wcd9xxx_codec_dai_data *dai)
-{
-	struct wcd9xxx *core;
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	/* Execute the callback only if interface type is slimbus */
-	if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-		return 0;
-
-	dev_dbg(codec->dev,
-		"%s: event = %d\n", __func__, event);
-	core = dev_get_drvdata(codec->dev->parent);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		dai->bus_down_in_recovery = false;
-		tasha_codec_enable_int_port(dai, codec);
-		(void) tasha_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		if (!dai->bus_down_in_recovery)
-			ret = tasha_codec_enable_slim_chmask(dai, false);
-		if (ret < 0) {
-			ret = wcd9xxx_disconnect_port(core,
-						      &dai->wcd9xxx_ch_list,
-						      dai->grph);
-			pr_debug("%s: Disconnect TX port, ret = %d\n",
-				 __func__, ret);
-		}
-
-		break;
-	}
-
-	return ret;
-}
-
-static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_codec_dai_data *dai;
-
-	dev_dbg(codec->dev,
-		"%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
-		__func__, w->name, w->shift,
-		codec->component.num_dai, w->sname);
-
-	dai = &tasha_p->dai[w->shift];
-	return __tasha_codec_enable_slimtx(codec, event, dai);
-}
-
-static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
-{
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_codec_dai_data *dai;
-	u8 bit_width, rate, buf_period;
-
-	dai = &tasha_p->dai[AIF4_MAD_TX];
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		switch (dai->bit_width) {
-		case 32:
-			bit_width = 0xF;
-			break;
-		case 24:
-			bit_width = 0xE;
-			break;
-		case 20:
-			bit_width = 0xD;
-			break;
-		case 16:
-		default:
-			bit_width = 0x0;
-			break;
-		}
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
-				    bit_width);
-
-		switch (dai->rate) {
-		case 384000:
-			rate = 0x30;
-			break;
-		case 192000:
-			rate = 0x20;
-			break;
-		case 48000:
-			rate = 0x10;
-			break;
-		case 16000:
-		default:
-			rate = 0x00;
-			break;
-		}
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
-				    rate);
-
-		buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
-				    0xFF, buf_period);
-		dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
-			__func__, buf_period);
-		break;
-
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
-		snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
-		break;
-
-	default:
-		break;
-	}
-}
-
-/*
- * tasha_codec_get_mad_port_id: Callback function that will be invoked
- *	to get the port ID for MAD.
- * @codec: Handle to the codec
- * @port_id: cpe port_id needs to enable
- */
-static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
-				       u16 *port_id)
-{
-	struct tasha_priv *tasha_p;
-	struct wcd9xxx_codec_dai_data *dai;
-	struct wcd9xxx_ch *ch;
-
-	if (!port_id || !codec)
-		return -EINVAL;
-
-	tasha_p = snd_soc_codec_get_drvdata(codec);
-	if (!tasha_p)
-		return -EINVAL;
-
-	dai = &tasha_p->dai[AIF4_MAD_TX];
-	list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-		if (ch->port == TASHA_TX12)
-			*port_id = WCD_CPE_AFE_OUT_PORT_2;
-		else if (ch->port == TASHA_TX13)
-			*port_id = WCD_CPE_AFE_OUT_PORT_4;
-		else {
-			dev_err(codec->dev, "%s: invalid mad_port = %d\n",
-					__func__, ch->port);
-			return -EINVAL;
-		}
-	}
-	dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
-
-	return 0;
-}
-
-/*
- * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
- *	to setup the slave port for MAD.
- * @codec: Handle to the codec
- * @event: Indicates whether to enable or disable the slave port
- */
-static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
-					 u8 event)
-{
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_codec_dai_data *dai;
-	struct wcd9xxx_ch *ch;
-	int dapm_event = SND_SOC_DAPM_POST_PMU;
-	u16 port = 0;
-	int ret = 0;
-
-	dai = &tasha_p->dai[AIF4_MAD_TX];
-
-	if (event == 0)
-		dapm_event = SND_SOC_DAPM_POST_PMD;
-
-	dev_dbg(codec->dev,
-		"%s: mad_channel, event = 0x%x\n",
-		 __func__, event);
-
-	list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-		dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
-			__func__, ch->port, event);
-		if (ch->port == TASHA_TX13) {
-			tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
-			port = TASHA_TX13;
-			break;
-		}
-	}
-
-	ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
-
-	if (port == TASHA_TX13) {
-		switch (dapm_event) {
-		case SND_SOC_DAPM_POST_PMU:
-			snd_soc_update_bits(codec,
-				WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
-				0x20, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
-				0x03, 0x02);
-			snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
-					    0x80, 0x80);
-			break;
-		case SND_SOC_DAPM_POST_PMD:
-			snd_soc_update_bits(codec,
-				WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
-				0x20, 0x20);
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
-				0x03, 0x00);
-			snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
-					    0x80, 0x00);
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static int tasha_put_iir_band_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	/*
-	 * Mask top bit it is reserved
-	 * Updates addr automatically for each B2 write
-	 */
-	snd_soc_write(codec,
-		(WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
-
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-				ucontrol->value.integer.value[0]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-				ucontrol->value.integer.value[1]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-				ucontrol->value.integer.value[2]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-				ucontrol->value.integer.value[3]);
-	set_iir_band_coeff(codec, iir_idx, band_idx,
-				ucontrol->value.integer.value[4]);
-
-	pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4));
-	return 0;
-}
-
-static int tasha_get_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
-	return 0;
-}
-
-static int tasha_set_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	int value = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: Compander %d enable current %d, new %d\n",
-		 __func__, comp + 1, tasha->comp_enabled[comp], value);
-	tasha->comp_enabled[comp] = value;
-
-	/* Any specific register configuration for compander */
-	switch (comp) {
-	case COMPANDER_1:
-		/* Set Gain Source Select based on compander enable/disable */
-		snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_2:
-		snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_3:
-		break;
-	case COMPANDER_4:
-		break;
-	case COMPANDER_5:
-		snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_6:
-		snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_7:
-		break;
-	case COMPANDER_8:
-		break;
-	default:
-		/*
-		 * if compander is not enabled for any interpolator,
-		 * it does not cause any audio failure, so do not
-		 * return error in this case, but just print a log
-		 */
-		dev_warn(codec->dev, "%s: unknown compander: %d\n",
-			__func__, comp);
-	};
-	return 0;
-}
-
-static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
-{
-	snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
-	snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
-	snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
-	snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
-}
-
-static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tasha->rx_bias_count++;
-		if (tasha->rx_bias_count == 1) {
-			if (TASHA_IS_2_0(tasha->wcd9xxx))
-				tasha_codec_init_flyback(codec);
-			snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
-					    0x01, 0x01);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tasha->rx_bias_count--;
-		if (!tasha->rx_bias_count)
-			snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
-					    0x01, 0x00);
-		break;
-	};
-	dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
-		tasha->rx_bias_count);
-
-	return 0;
-}
-
-static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
-				    u16 reg1, u16 reg2)
-{
-	u8 val1, val2, tmpval1, tmpval2;
-
-	snd_soc_write(codec, reg1, 0x00);
-	tmpval1 = snd_soc_read(codec, reg2);
-	tmpval2 = snd_soc_read(codec, reg2);
-	snd_soc_write(codec, reg1, 0x00);
-	snd_soc_write(codec, reg2, 0xFF);
-	snd_soc_write(codec, reg1, 0x01);
-	snd_soc_write(codec, reg2, 0xFF);
-
-	snd_soc_write(codec, reg1, 0x00);
-	val1 = snd_soc_read(codec, reg2);
-	val2 = snd_soc_read(codec, reg2);
-
-	if (val1 == 0x0F && val2 == 0xFF) {
-		dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
-			__func__);
-		snd_soc_read(codec, reg2);
-		snd_soc_write(codec, reg1, 0x00);
-		snd_soc_write(codec, reg2, tmpval2);
-		snd_soc_write(codec, reg1, 0x01);
-		snd_soc_write(codec, reg2, tmpval1);
-	} else if (val1 == 0xFF && val2 == 0x0F) {
-		dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
-			__func__);
-		snd_soc_write(codec, reg1, 0x00);
-		snd_soc_write(codec, reg2, tmpval1);
-		snd_soc_write(codec, reg1, 0x01);
-		snd_soc_write(codec, reg2, tmpval2);
-	} else {
-		dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
-			__func__);
-	}
-}
-
-static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	const char *filename;
-	const struct firmware *fw;
-	int i;
-	int ret = 0;
-	int num_anc_slots;
-	struct wcd9xxx_anc_header *anc_head;
-	struct firmware_cal *hwdep_cal = NULL;
-	u32 anc_writes_size = 0;
-	u32 anc_cal_size = 0;
-	int anc_size_remaining;
-	u32 *anc_ptr;
-	u16 reg;
-	u8 mask, val;
-	size_t cal_size;
-	const void *data;
-
-	if (!tasha->anc_func)
-		return 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
-		if (hwdep_cal) {
-			data = hwdep_cal->data;
-			cal_size = hwdep_cal->size;
-			dev_dbg(codec->dev, "%s: using hwdep calibration\n",
-				__func__);
-		} else {
-			filename = "wcd9335/wcd9335_anc.bin";
-			ret = request_firmware(&fw, filename, codec->dev);
-			if (ret != 0) {
-				dev_err(codec->dev,
-				"Failed to acquire ANC data: %d\n", ret);
-				return -ENODEV;
-			}
-			if (!fw) {
-				dev_err(codec->dev, "failed to get anc fw");
-				return -ENODEV;
-			}
-			data = fw->data;
-			cal_size = fw->size;
-			dev_dbg(codec->dev,
-			"%s: using request_firmware calibration\n", __func__);
-		}
-		if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
-			dev_err(codec->dev, "Not enough data\n");
-			ret = -ENOMEM;
-			goto err;
-		}
-		/* First number is the number of register writes */
-		anc_head = (struct wcd9xxx_anc_header *)(data);
-		anc_ptr = (u32 *)(data +
-				  sizeof(struct wcd9xxx_anc_header));
-		anc_size_remaining = cal_size -
-				     sizeof(struct wcd9xxx_anc_header);
-		num_anc_slots = anc_head->num_anc_slots;
-
-		if (tasha->anc_slot >= num_anc_slots) {
-			dev_err(codec->dev, "Invalid ANC slot selected\n");
-			ret = -EINVAL;
-			goto err;
-		}
-		for (i = 0; i < num_anc_slots; i++) {
-			if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
-				dev_err(codec->dev,
-					"Invalid register format\n");
-				ret = -EINVAL;
-				goto err;
-			}
-			anc_writes_size = (u32)(*anc_ptr);
-			anc_size_remaining -= sizeof(u32);
-			anc_ptr += 1;
-
-			if (anc_writes_size * TASHA_PACKED_REG_SIZE
-				> anc_size_remaining) {
-				dev_err(codec->dev,
-					"Invalid register format\n");
-				ret = -EINVAL;
-				goto err;
-			}
-
-			if (tasha->anc_slot == i)
-				break;
-
-			anc_size_remaining -= (anc_writes_size *
-				TASHA_PACKED_REG_SIZE);
-			anc_ptr += anc_writes_size;
-		}
-		if (i == num_anc_slots) {
-			dev_err(codec->dev, "Selected ANC slot not present\n");
-			ret = -EINVAL;
-			goto err;
-		}
-
-		i = 0;
-		anc_cal_size = anc_writes_size;
-
-		if (!strcmp(w->name, "RX INT0 DAC") ||
-		    !strcmp(w->name, "ANC SPK1 PA"))
-			tasha_realign_anc_coeff(codec,
-					WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
-					WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
-
-		if (!strcmp(w->name, "RX INT1 DAC") ||
-			!strcmp(w->name, "RX INT3 DAC")) {
-			tasha_realign_anc_coeff(codec,
-					WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
-					WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
-			anc_writes_size = anc_cal_size / 2;
-			snd_soc_update_bits(codec,
-			WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
-		} else if (!strcmp(w->name, "RX INT2 DAC") ||
-				!strcmp(w->name, "RX INT4 DAC")) {
-			tasha_realign_anc_coeff(codec,
-					WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
-					WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
-			i = anc_cal_size / 2;
-			snd_soc_update_bits(codec,
-			WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
-		}
-
-		for (; i < anc_writes_size; i++) {
-			TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
-			snd_soc_write(codec, reg, (val & mask));
-		}
-		if (!strcmp(w->name, "RX INT1 DAC") ||
-			!strcmp(w->name, "RX INT3 DAC")) {
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
-		} else if (!strcmp(w->name, "RX INT2 DAC") ||
-				!strcmp(w->name, "RX INT4 DAC")) {
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
-		}
-
-		if (!hwdep_cal)
-			release_firmware(fw);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* Remove ANC Rx from reset */
-		snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
-				    0x08, 0x00);
-		snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
-				    0x08, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (!strcmp(w->name, "ANC HPHL PA") ||
-		    !strcmp(w->name, "ANC EAR PA") ||
-		    !strcmp(w->name, "ANC SPK1 PA") ||
-		    !strcmp(w->name, "ANC LINEOUT1 PA")) {
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
-			msleep(50);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
-		} else if (!strcmp(w->name, "ANC HPHR PA") ||
-			   !strcmp(w->name, "ANC LINEOUT2 PA")) {
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
-			msleep(50);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
-		}
-		break;
-	}
-
-	return 0;
-err:
-	if (!hwdep_cal)
-		release_firmware(fw);
-	return ret;
-}
-
-static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
-{
-	if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
-		tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
-}
-
-static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
-					   int mode, int event)
-{
-	u8 scale_val = 0;
-
-	if (!TASHA_IS_2_0(tasha->wcd9xxx))
-		return;
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		switch (mode) {
-		case CLS_H_HIFI:
-			scale_val = 0x3;
-			break;
-		case CLS_H_LOHIFI:
-			scale_val = 0x1;
-			break;
-		}
-		if (tasha->anc_func) {
-			/* Clear Tx FE HOLD if both PAs are enabled */
-			if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
-			     0xC0) == 0xC0) {
-				tasha_codec_clear_anc_tx_hold(tasha);
-			}
-		}
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		scale_val = 0x6;
-		break;
-	}
-
-	if (scale_val)
-		snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
-				    scale_val << 1);
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		if (tasha->comp_enabled[COMPANDER_1] ||
-		    tasha->comp_enabled[COMPANDER_2]) {
-			snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
-					    0x20, 0x00);
-			snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
-					    0x20, 0x00);
-			snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
-					    0x20, 0x20);
-		}
-		snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
-				    tasha->hph_l_gain);
-		snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
-				    tasha->hph_r_gain);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
-				    0x00);
-	}
-}
-
-static void tasha_codec_override(struct snd_soc_codec *codec,
-				 int mode,
-				 int event)
-{
-	if (mode == CLS_AB) {
-		switch (event) {
-		case SND_SOC_DAPM_POST_PMU:
-			if (!(snd_soc_read(codec,
-					WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
-				(!(snd_soc_read(codec,
-					WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
-				snd_soc_update_bits(codec,
-					WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
-		break;
-		case SND_SOC_DAPM_POST_PMD:
-			snd_soc_update_bits(codec,
-				WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
-		break;
-		}
-	}
-}
-
-static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int hph_mode = tasha->hph_mode;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
-		    (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
-			snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
-		}
-		set_bit(HPH_PA_DELAY, &tasha->status_mask);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if (!(strcmp(w->name, "ANC HPHR PA"))) {
-			if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
-							!= 0xC0)
-				/*
-				 * If PA_EN is not set (potentially in ANC case)
-				 * then do nothing for POST_PMU and let left
-				 * channel handle everything.
-				 */
-				break;
-		}
-		/*
-		 * 7ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
-			usleep_range(7000, 7100);
-			clear_bit(HPH_PA_DELAY, &tasha->status_mask);
-		}
-		tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
-		snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
-				  0x10)
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-
-		if (!(strcmp(w->name, "ANC HPHR PA"))) {
-			/* Do everything needed for left channel */
-			snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
-					    0x10, 0x00);
-			/* Remove mix path mute if it is enabled */
-			if ((snd_soc_read(codec,
-					  WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
-					  0x10)
-				snd_soc_update_bits(codec,
-						WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
-						0x10, 0x00);
-			/* Remove ANC Rx from reset */
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-		}
-		tasha_codec_override(codec, hph_mode, event);
-		break;
-
-	case SND_SOC_DAPM_PRE_PMD:
-		blocking_notifier_call_chain(&tasha->notifier,
-					WCD_EVENT_PRE_HPHR_PA_OFF,
-					&tasha->mbhc);
-		tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
-		if (!(strcmp(w->name, "ANC HPHR PA")))
-			snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		tasha_codec_override(codec, hph_mode, event);
-		blocking_notifier_call_chain(&tasha->notifier,
-					WCD_EVENT_POST_HPHR_PA_OFF,
-					&tasha->mbhc);
-
-		if (!(strcmp(w->name, "ANC HPHR PA"))) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int hph_mode = tasha->hph_mode;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
-		    (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
-			snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
-		}
-		set_bit(HPH_PA_DELAY, &tasha->status_mask);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
-								!= 0xC0)
-				/*
-				 * If PA_EN is not set (potentially in ANC case)
-				 * then do nothing for POST_PMU and let right
-				 * channel handle everything.
-				 */
-				break;
-		}
-		/*
-		 * 7ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
-			usleep_range(7000, 7100);
-			clear_bit(HPH_PA_DELAY, &tasha->status_mask);
-		}
-
-		tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
-		snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
-				  0x10)
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			/* Do everything needed for right channel */
-			snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
-					    0x10, 0x00);
-			/* Remove mix path mute if it is enabled */
-			if ((snd_soc_read(codec,
-					  WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
-					  0x10)
-				snd_soc_update_bits(codec,
-						WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
-						0x10, 0x00);
-
-			/* Remove ANC Rx from reset */
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-		}
-		tasha_codec_override(codec, hph_mode, event);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		blocking_notifier_call_chain(&tasha->notifier,
-					WCD_EVENT_PRE_HPHL_PA_OFF,
-					&tasha->mbhc);
-		tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
-		if (!(strcmp(w->name, "ANC HPHL PA")))
-			snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		tasha_codec_override(codec, hph_mode, event);
-		blocking_notifier_call_chain(&tasha->notifier,
-					WCD_EVENT_POST_HPHL_PA_OFF,
-					&tasha->mbhc);
-
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	if (w->reg == WCD9335_ANA_LO_1_2) {
-		if (w->shift == 7) {
-			lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
-		} else if (w->shift == 6) {
-			lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
-		}
-	} else if (w->reg == WCD9335_ANA_LO_3_4) {
-		if (w->shift == 7) {
-			lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
-		} else if (w->shift == 6) {
-			lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
-		}
-	} else {
-		dev_err(codec->dev, "%s: Error enabling lineout PA\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/* 5ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		snd_soc_update_bits(codec, lineout_vol_reg,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
-			snd_soc_update_bits(codec,
-					    lineout_mix_vol_reg,
-					    0x10, 0x00);
-		if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
-		    !(strcmp(w->name, "ANC LINEOUT2 PA")))
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-		tasha_codec_override(codec, CLS_AB, event);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		tasha_codec_override(codec, CLS_AB, event);
-		if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
-			!(strcmp(w->name, "ANC LINEOUT2 PA"))) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
-				snd_soc_update_bits(codec,
-				WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
-			else
-				snd_soc_update_bits(codec,
-				WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static void tasha_spk_anc_update_callback(struct work_struct *work)
-{
-	struct spk_anc_work *spk_anc_dwork;
-	struct tasha_priv *tasha;
-	struct delayed_work *delayed_work;
-	struct snd_soc_codec *codec;
-
-	delayed_work = to_delayed_work(work);
-	spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
-	tasha = spk_anc_dwork->tasha;
-	codec = tasha->codec;
-
-	snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
-}
-
-static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
-		tasha->anc_func);
-
-	if (!tasha->anc_func)
-		return 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		ret = tasha_codec_enable_anc(w, kcontrol, event);
-		schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
-				      msecs_to_jiffies(spk_anc_en_delay));
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
-		snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
-				    0x10, 0x00);
-		ret = tasha_codec_enable_anc(w, kcontrol, event);
-		break;
-	}
-	return ret;
-}
-
-static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/* 5ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
-		     0x10)
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-
-		if (!(strcmp(w->name, "ANC EAR PA"))) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
-					  u8 gain)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u8 hph_l_en, hph_r_en;
-	u8 l_val, r_val;
-	u8 hph_pa_status;
-	bool is_hphl_pa, is_hphr_pa;
-
-	hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
-	is_hphl_pa = hph_pa_status >> 7;
-	is_hphr_pa = (hph_pa_status & 0x40) >> 6;
-
-	hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
-	hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
-
-	l_val = (hph_l_en & 0xC0) | 0x20 | gain;
-	r_val = (hph_r_en & 0xC0) | 0x20 | gain;
-
-	/*
-	 * Set HPH_L & HPH_R gain source selection to REGISTER
-	 * for better click and pop only if corresponding PAs are
-	 * not enabled. Also cache the values of the HPHL/R
-	 * PA gains to be applied after PAs are enabled
-	 */
-	if ((l_val != hph_l_en) && !is_hphl_pa) {
-		snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
-		tasha->hph_l_gain = hph_l_en & 0x1F;
-	}
-
-	if ((r_val != hph_r_en) && !is_hphr_pa) {
-		snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
-		tasha->hph_r_gain = hph_r_en & 0x1F;
-	}
-}
-
-static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
-					  int event)
-{
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
-		snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
-				    0xF0, 0x40);
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
-		tasha_codec_hph_mode_gain_opt(codec, 0x11);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
-		snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
-		snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
-	}
-}
-
-static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
-				      int event)
-{
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
-		tasha_codec_hph_mode_gain_opt(codec, 0x10);
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
-		snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
-				    0x01);
-		snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
-				    0x10);
-		snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
-				    0x0F, 0x01);
-		snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
-				    0xF0, 0x10);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
-		snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
-		snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
-		snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
-	}
-}
-
-static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
-					int event)
-{
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
-		tasha_codec_hph_mode_gain_opt(codec, 0x11);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
-		snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
-	}
-}
-
-static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
-					int event, int mode)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (!TASHA_IS_2_0(tasha->wcd9xxx))
-		return;
-
-	switch (mode) {
-	case CLS_H_LP:
-		tasha_codec_hph_lp_config(codec, event);
-		break;
-	case CLS_H_LOHIFI:
-		tasha_codec_hph_lohifi_config(codec, event);
-		break;
-	case CLS_H_HIFI:
-		tasha_codec_hph_hifi_config(codec, event);
-		break;
-	}
-}
-
-static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int hph_mode = tasha->hph_mode;
-	u8 dem_inp;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
-		w->name, event, hph_mode);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tasha->anc_func) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			/* 40 msec delay is needed to avoid click and pop */
-			msleep(40);
-		}
-
-		/* Read DEM INP Select */
-		dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
-			  0x03;
-		if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
-		     (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
-			dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
-					__func__, hph_mode);
-			return -EINVAL;
-		}
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_HPHR,
-			     ((hph_mode == CLS_H_LOHIFI) ?
-			       CLS_H_HIFI : hph_mode));
-
-		tasha_codec_hph_mode_config(codec, event, hph_mode);
-
-		if (tasha->anc_func)
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
-
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-		if ((hph_mode == CLS_H_LP) &&
-		   (TASHA_IS_1_1(wcd9xxx))) {
-			snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
-					    0x03, 0x03);
-		}
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		if ((hph_mode == CLS_H_LP) &&
-		   (TASHA_IS_1_1(wcd9xxx))) {
-			snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
-					    0x03, 0x00);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-
-		if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
-		     WCD_CLSH_STATE_HPHL))
-			tasha_codec_hph_mode_config(codec, event, hph_mode);
-
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_HPHR,
-			     ((hph_mode == CLS_H_LOHIFI) ?
-			       CLS_H_HIFI : hph_mode));
-		break;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int hph_mode = tasha->hph_mode;
-	u8 dem_inp;
-	int ret = 0;
-	uint32_t impedl = 0, impedr = 0;
-
-	dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
-		w->name, event, hph_mode);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tasha->anc_func) {
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-			/* 40 msec delay is needed to avoid click and pop */
-			msleep(40);
-		}
-
-		/* Read DEM INP Select */
-		dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
-			  0x03;
-		if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
-		     (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
-			dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
-					__func__, hph_mode);
-			return -EINVAL;
-		}
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_HPHL,
-			     ((hph_mode == CLS_H_LOHIFI) ?
-			       CLS_H_HIFI : hph_mode));
-
-		tasha_codec_hph_mode_config(codec, event, hph_mode);
-
-		if (tasha->anc_func)
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
-
-		ret = wcd_mbhc_get_impedance(&tasha->mbhc,
-					&impedl, &impedr);
-		if (!ret) {
-			wcd_clsh_imped_config(codec, impedl, false);
-			set_bit(CLASSH_CONFIG, &tasha->status_mask);
-		} else {
-			dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
-						__func__, ret);
-			ret = 0;
-		}
-
-
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-		if ((hph_mode == CLS_H_LP) &&
-		   (TASHA_IS_1_1(wcd9xxx))) {
-			snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
-					    0x03, 0x03);
-		}
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		if ((hph_mode == CLS_H_LP) &&
-		   (TASHA_IS_1_1(wcd9xxx))) {
-			snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
-					    0x03, 0x00);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-
-		if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
-		     WCD_CLSH_STATE_HPHR))
-			tasha_codec_hph_mode_config(codec, event, hph_mode);
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_HPHL,
-			     ((hph_mode == CLS_H_LOHIFI) ?
-			       CLS_H_HIFI : hph_mode));
-
-		if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
-			wcd_clsh_imped_config(codec, impedl, true);
-			clear_bit(CLASSH_CONFIG, &tasha->status_mask);
-		} else
-			dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
-						__func__, ret);
-
-
-		break;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tasha->anc_func &&
-			(!strcmp(w->name, "RX INT3 DAC") ||
-				!strcmp(w->name, "RX INT4 DAC")))
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_LO,
-			     CLS_AB);
-
-		if (tasha->anc_func) {
-			if (!strcmp(w->name, "RX INT3 DAC"))
-				snd_soc_update_bits(codec,
-				WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
-			else if (!strcmp(w->name, "RX INT4 DAC"))
-				snd_soc_update_bits(codec,
-				WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_LO,
-			     CLS_AB);
-		break;
-	}
-
-	return 0;
-}
-
-static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
-	SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
-	0, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
-	0, 0, NULL, 0),
-};
-
-static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tasha->anc_func)
-			ret = tasha_codec_enable_anc(w, kcontrol, event);
-
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_EAR,
-			     CLS_H_NORMAL);
-		if (tasha->anc_func)
-			snd_soc_update_bits(codec,
-				WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
-
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		wcd_clsh_fsm(codec, &tasha->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_EAR,
-			     CLS_H_NORMAL);
-		break;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
-				struct snd_kcontrol *kcontrol,
-				int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 boost_path_ctl, boost_path_cfg1;
-	u16 reg, reg_mix;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	if (!strcmp(w->name, "RX INT7 CHAIN")) {
-		boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
-		boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
-		reg = WCD9335_CDC_RX7_RX_PATH_CTL;
-		reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
-	} else if (!strcmp(w->name, "RX INT8 CHAIN")) {
-		boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
-		boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
-		reg = WCD9335_CDC_RX8_RX_PATH_CTL;
-		reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
-	} else {
-		dev_err(codec->dev, "%s: unknown widget: %s\n",
-			__func__, w->name);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
-		snd_soc_update_bits(codec, reg, 0x10, 0x00);
-		if ((snd_soc_read(codec, reg_mix)) & 0x10)
-			snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
-		break;
-	};
-
-	return 0;
-}
-
-static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
-{
-	u16 prim_int_reg = 0;
-
-	switch (reg) {
-	case WCD9335_CDC_RX0_RX_PATH_CTL:
-	case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
-		*ind = 0;
-		break;
-	case WCD9335_CDC_RX1_RX_PATH_CTL:
-	case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
-		*ind = 1;
-		break;
-	case WCD9335_CDC_RX2_RX_PATH_CTL:
-	case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
-		*ind = 2;
-		break;
-	case WCD9335_CDC_RX3_RX_PATH_CTL:
-	case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
-		*ind = 3;
-		break;
-	case WCD9335_CDC_RX4_RX_PATH_CTL:
-	case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
-		*ind = 4;
-		break;
-	case WCD9335_CDC_RX5_RX_PATH_CTL:
-	case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
-		*ind = 5;
-		break;
-	case WCD9335_CDC_RX6_RX_PATH_CTL:
-	case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
-		*ind = 6;
-		break;
-	case WCD9335_CDC_RX7_RX_PATH_CTL:
-	case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
-		*ind = 7;
-		break;
-	case WCD9335_CDC_RX8_RX_PATH_CTL:
-	case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
-		prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
-		*ind = 8;
-		break;
-	};
-
-	return prim_int_reg;
-}
-
-static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
-				    u16 prim_int_reg, int event)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 hd2_scale_reg;
-	u16 hd2_enable_reg = 0;
-
-	if (!TASHA_IS_2_0(tasha->wcd9xxx))
-		return;
-
-	if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
-		hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
-		hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
-	}
-	if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
-		hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
-		hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
-	}
-}
-
-static int tasha_codec_enable_prim_interpolator(
-				struct snd_soc_codec *codec,
-				u16 reg, int event)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 prim_int_reg;
-	u16 ind = 0;
-
-	prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tasha->prim_int_users[ind]++;
-		if (tasha->prim_int_users[ind] == 1) {
-			snd_soc_update_bits(codec, prim_int_reg,
-					    0x10, 0x10);
-			tasha_codec_hd2_control(codec, prim_int_reg, event);
-			snd_soc_update_bits(codec, prim_int_reg,
-					    1 << 0x5, 1 << 0x5);
-		}
-		if ((reg != prim_int_reg) &&
-		    ((snd_soc_read(codec, prim_int_reg)) & 0x10))
-			snd_soc_update_bits(codec, reg, 0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tasha->prim_int_users[ind]--;
-		if (tasha->prim_int_users[ind] == 0) {
-			snd_soc_update_bits(codec, prim_int_reg,
-					1 << 0x5, 0 << 0x5);
-			snd_soc_update_bits(codec, prim_int_reg,
-					0x40, 0x40);
-			snd_soc_update_bits(codec, prim_int_reg,
-					0x40, 0x00);
-			tasha_codec_hd2_control(codec, prim_int_reg, event);
-		}
-		break;
-	};
-
-	dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
-		__func__, ind, tasha->prim_int_users[ind]);
-	return 0;
-}
-
-static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
-					 int src_num,
-					 int event)
-{
-	u16 src_paired_reg = 0;
-	struct tasha_priv *tasha;
-	u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
-	u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
-	int *src_users, count, spl_src = SPLINE_SRC0;
-	u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
-
-	tasha = snd_soc_codec_get_drvdata(codec);
-
-	switch (src_num) {
-	case SRC_IN_HPHL:
-		rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
-		spl_src = SPLINE_SRC0;
-		break;
-	case SRC_IN_LO1:
-		rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
-		spl_src = SPLINE_SRC0;
-		break;
-	case SRC_IN_HPHR:
-		rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
-		spl_src = SPLINE_SRC1;
-		break;
-	case SRC_IN_LO2:
-		rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
-		spl_src = SPLINE_SRC1;
-		break;
-	case SRC_IN_SPKRL:
-		rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
-		spl_src = SPLINE_SRC2;
-		break;
-	case SRC_IN_LO3:
-		rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
-		spl_src = SPLINE_SRC2;
-		break;
-	case SRC_IN_SPKRR:
-		rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
-		spl_src = SPLINE_SRC3;
-		break;
-	case SRC_IN_LO4:
-		rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
-		src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
-		src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
-		rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
-		spl_src = SPLINE_SRC3;
-		break;
-	};
-
-	src_users = &tasha->spl_src_users[spl_src];
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		count = *src_users;
-		count++;
-		if (count == 1) {
-			if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
-			    (snd_soc_read(codec, src_paired_reg) & 0x02)) {
-				snd_soc_update_bits(codec, src_clk_reg, 0x02,
-						    0x00);
-				snd_soc_update_bits(codec, src_paired_reg,
-						    0x02, 0x00);
-			}
-			snd_soc_update_bits(codec, src_clk_reg,	0x01, 0x01);
-			snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
-					    0x80);
-		}
-		*src_users = count;
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		count = *src_users;
-		count--;
-		if (count == 0) {
-			snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
-					    0x00);
-			snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
-			/* default sample rate */
-			snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
-					    0x04);
-		}
-		*src_users = count;
-		break;
-	};
-
-	dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
-		__func__, spl_src, *src_users);
-	return 0;
-}
-
-static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
-				struct snd_kcontrol *kcontrol,
-				int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-	u8 src_in;
-
-	src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
-	if (!(src_in & 0xFF)) {
-		dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
-			__func__, w->shift);
-		return -EINVAL;
-	}
-
-	switch (w->shift) {
-	case SPLINE_SRC0:
-		ret = tasha_codec_enable_spline_src(codec,
-			((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
-			event);
-		break;
-	case SPLINE_SRC1:
-		ret = tasha_codec_enable_spline_src(codec,
-			((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
-			event);
-		break;
-	case SPLINE_SRC2:
-		ret = tasha_codec_enable_spline_src(codec,
-			((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
-			event);
-		break;
-	case SPLINE_SRC3:
-		ret = tasha_codec_enable_spline_src(codec,
-			((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
-			event);
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
-			w->shift);
-		ret = -EINVAL;
-	};
-
-	return ret;
-}
-
-static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha;
-	int i, ch_cnt;
-
-	tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (!tasha->nr)
-		return 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
-		    !tasha->rx_7_count)
-			tasha->rx_7_count++;
-		if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
-		    !tasha->rx_8_count)
-			tasha->rx_8_count++;
-		ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
-
-		for (i = 0; i < tasha->nr; i++) {
-			swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
-					SWR_DEVICE_UP, NULL);
-			swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
-					SWR_SET_NUM_RX_CH, &ch_cnt);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
-		    tasha->rx_7_count)
-			tasha->rx_7_count--;
-		if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
-		    tasha->rx_8_count)
-			tasha->rx_8_count--;
-		ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
-
-		for (i = 0; i < tasha->nr; i++)
-			swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
-					SWR_SET_NUM_RX_CH, &ch_cnt);
-
-		break;
-	}
-	dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
-		__func__, tasha->rx_7_count + tasha->rx_8_count);
-
-	return 0;
-}
-
-static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
-					    int event, int gain_reg)
-{
-	int comp_gain_offset, val;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	switch (tasha->spkr_mode) {
-	/* Compander gain in SPKR_MODE1 case is 12 dB */
-	case SPKR_MODE_1:
-		comp_gain_offset = -12;
-		break;
-	/* Default case compander gain is 15 dB */
-	default:
-		comp_gain_offset = -15;
-		break;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/* Apply ear spkr gain only if compander is enabled */
-		if (tasha->comp_enabled[COMPANDER_7] &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
-		    (tasha->ear_spkr_gain != 0)) {
-			/* For example, val is -8(-12+5-1) for 4dB of gain */
-			val = comp_gain_offset + tasha->ear_spkr_gain - 1;
-			snd_soc_write(codec, gain_reg, val);
-
-			dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
-				__func__, val);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * Reset RX7 volume to 0 dB if compander is enabled and
-		 * ear_spkr_gain is non-zero.
-		 */
-		if (tasha->comp_enabled[COMPANDER_7] &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
-		    (tasha->ear_spkr_gain != 0)) {
-			snd_soc_write(codec, gain_reg, 0x0);
-
-			dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
-				__func__);
-		}
-		break;
-	}
-
-	return 0;
-}
-
-static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 gain_reg;
-	int offset_val = 0;
-	int val = 0;
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-
-	switch (w->reg) {
-	case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
-		break;
-	case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
-		gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
-		break;
-	default:
-		dev_err(codec->dev, "%s: No gain register avail for %s\n",
-			__func__, w->name);
-		return 0;
-	};
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tasha->comp_enabled[COMPANDER_7] ||
-		     tasha->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
-		     gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
-			snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			offset_val = -2;
-		}
-		val = snd_soc_read(codec, gain_reg);
-		val += offset_val;
-		snd_soc_write(codec, gain_reg, val);
-		tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tasha->comp_enabled[COMPANDER_7] ||
-		     tasha->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
-		     gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
-			snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			offset_val = 2;
-			val = snd_soc_read(codec, gain_reg);
-			val += offset_val;
-			snd_soc_write(codec, gain_reg, val);
-		}
-		tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	};
-
-	return 0;
-}
-
-static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
-					 bool enable)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = tasha->codec;
-
-	if (!tasha->wcd_native_clk) {
-		dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
-
-	if (enable) {
-		ret = clk_prepare_enable(tasha->wcd_native_clk);
-		if (ret) {
-			dev_err(tasha->dev, "%s: native clk enable failed\n",
-				__func__);
-			goto err;
-		}
-		if (++tasha->native_clk_users == 1) {
-			snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
-					    0x10, 0x10);
-			snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
-					    0x80, 0x80);
-			snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
-					    0x04, 0x00);
-			snd_soc_update_bits(codec,
-					WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x02, 0x02);
-		}
-	} else {
-		if (tasha->native_clk_users &&
-		    (--tasha->native_clk_users == 0)) {
-			snd_soc_update_bits(codec,
-					WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x02, 0x00);
-			snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
-					    0x04, 0x04);
-			snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
-					    0x80, 0x00);
-			snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
-					    0x10, 0x00);
-		}
-		clk_disable_unprepare(tasha->wcd_native_clk);
-	}
-
-	dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
-		tasha->native_clk_users);
-err:
-	return ret;
-}
-
-static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
-						 int interp_n)
-{
-	int mask = 0;
-	u16 reg;
-	u8 val1, val2, inp0 = 0;
-	u8 inp1 = 0, inp2 = 0;
-
-	reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
-
-	val1 = snd_soc_read(codec, reg);
-	val2 = snd_soc_read(codec, reg + 1);
-
-	inp0 = val1 & 0x0F;
-	inp1 = (val1 >> 4) & 0x0F;
-	inp2 = (val2 >> 4) & 0x0F;
-
-	if (IS_VALID_NATIVE_FIFO_PORT(inp0))
-		mask |= (1 << (inp0 - 5));
-	if (IS_VALID_NATIVE_FIFO_PORT(inp1))
-		mask |= (1 << (inp1 - 5));
-	if (IS_VALID_NATIVE_FIFO_PORT(inp2))
-		mask |= (1 << (inp2 - 5));
-
-	dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
-	if (!mask)
-		dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
-			interp_n, inp0, inp1, inp2);
-	return mask;
-}
-
-static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol, int event)
-{
-	int mask;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 interp_reg;
-
-	dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
-		w->shift);
-
-	if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
-		return -EINVAL;
-
-	interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
-
-	mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
-	if (!mask)
-		return -EINVAL;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* Adjust interpolator rate to 44P1_NATIVE */
-		snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
-		__tasha_cdc_native_clk_enable(tasha, true);
-		snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
-				    mask, mask);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
-				    mask, 0x0);
-		__tasha_cdc_native_clk_enable(tasha, false);
-		/* Adjust interpolator rate to default */
-		snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
-		break;
-	}
-
-	return 0;
-}
-
-static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 gain_reg;
-	u16 reg;
-	int val;
-	int offset_val = 0;
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-
-	if (!(strcmp(w->name, "RX INT0 INTERP"))) {
-		reg = WCD9335_CDC_RX0_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
-		reg = WCD9335_CDC_RX1_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
-		reg = WCD9335_CDC_RX2_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
-		reg = WCD9335_CDC_RX3_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
-		reg = WCD9335_CDC_RX4_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
-		reg = WCD9335_CDC_RX5_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
-		reg = WCD9335_CDC_RX6_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
-		reg = WCD9335_CDC_RX7_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
-	} else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
-		reg = WCD9335_CDC_RX8_RX_PATH_CTL;
-		gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
-	} else {
-		dev_err(codec->dev, "%s: Interpolator reg not found\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tasha_codec_vote_max_bw(codec, true);
-		/* Reset if needed */
-		tasha_codec_enable_prim_interpolator(codec, reg, event);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		tasha_config_compander(codec, w->shift, event);
-		/* apply gain after int clk is enabled */
-		if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tasha->comp_enabled[COMPANDER_7] ||
-		     tasha->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			offset_val = -2;
-		}
-		val = snd_soc_read(codec, gain_reg);
-		val += offset_val;
-		snd_soc_write(codec, gain_reg, val);
-		tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tasha_config_compander(codec, w->shift, event);
-		tasha_codec_enable_prim_interpolator(codec, reg, event);
-		if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tasha->comp_enabled[COMPANDER_7] ||
-		     tasha->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			offset_val = 2;
-			val = snd_soc_read(codec, gain_reg);
-			val += offset_val;
-			snd_soc_write(codec, gain_reg, val);
-		}
-		tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	};
-
-	return 0;
-}
-
-static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
-				    struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU: /* fall through */
-	case SND_SOC_DAPM_PRE_PMD:
-		if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
-		} else {
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
-			snd_soc_write(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
-				snd_soc_read(codec,
-				WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
-		}
-		break;
-	}
-	return 0;
-}
-
-static int tasha_codec_enable_on_demand_supply(
-	struct snd_soc_dapm_widget *w,
-	struct snd_kcontrol *kcontrol, int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct on_demand_supply *supply;
-
-	if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
-		dev_err(codec->dev, "%s: error index > MAX Demand supplies",
-			__func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
-		__func__, on_demand_supply_name[w->shift], event);
-
-	supply = &tasha->on_demand_list[w->shift];
-	WARN_ONCE(!supply->supply, "%s isn't defined\n",
-		on_demand_supply_name[w->shift]);
-	if (!supply->supply) {
-		dev_err(codec->dev, "%s: err supply not present ond for %d",
-			__func__, w->shift);
-		goto out;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		ret = regulator_enable(supply->supply);
-		if (ret)
-			dev_err(codec->dev, "%s: Failed to enable %s\n",
-				__func__,
-				on_demand_supply_name[w->shift]);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = regulator_disable(supply->supply);
-		if (ret)
-			dev_err(codec->dev, "%s: Failed to disable %s\n",
-				__func__,
-				on_demand_supply_name[w->shift]);
-		break;
-	default:
-		break;
-	};
-
-out:
-	return ret;
-}
-
-static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
-				       int adc_mux_n)
-{
-	u16 mask, shift, adc_mux_in_reg;
-	u16 amic_mux_sel_reg;
-	bool is_amic;
-
-	if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
-	    adc_mux_n == WCD9335_INVALID_ADC_MUX)
-		return 0;
-
-	/* Check whether adc mux input is AMIC or DMIC */
-	if (adc_mux_n < 4) {
-		adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
-				 2 * adc_mux_n;
-		amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
-				   2 * adc_mux_n;
-		mask = 0x03;
-		shift = 0;
-	} else {
-		adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				 adc_mux_n - 4;
-		amic_mux_sel_reg = adc_mux_in_reg;
-		mask = 0xC0;
-		shift = 6;
-	}
-	is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
-		    == 1);
-	if (!is_amic)
-		return 0;
-
-	return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
-}
-
-static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
-				    u16 amic_reg, bool set)
-{
-	u8 mask = 0x20;
-	u8 val;
-
-	if (amic_reg == WCD9335_ANA_AMIC1 ||
-	    amic_reg == WCD9335_ANA_AMIC3 ||
-	    amic_reg == WCD9335_ANA_AMIC5)
-		mask = 0x40;
-
-	val = set ? mask : 0x00;
-
-	switch (amic_reg) {
-	case WCD9335_ANA_AMIC1:
-	case WCD9335_ANA_AMIC2:
-		snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
-		break;
-	case WCD9335_ANA_AMIC3:
-	case WCD9335_ANA_AMIC4:
-		snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
-		break;
-	case WCD9335_ANA_AMIC5:
-	case WCD9335_ANA_AMIC6:
-		snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: invalid amic: %d\n",
-			__func__, amic_reg);
-		break;
-	}
-}
-
-static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	int adc_mux_n = w->shift;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int amic_n;
-
-	dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
-		if (amic_n) {
-			/*
-			 * Prevent ANC Rx pop by leaving Tx FE in HOLD
-			 * state until PA is up. Track AMIC being used
-			 * so we can release the HOLD later.
-			 */
-			set_bit(ANC_MIC_AMIC1 + amic_n - 1,
-				&tasha->status_mask);
-		}
-		break;
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
-{
-	u16 pwr_level_reg = 0;
-
-	switch (amic) {
-	case 1:
-	case 2:
-		pwr_level_reg = WCD9335_ANA_AMIC1;
-		break;
-
-	case 3:
-	case 4:
-		pwr_level_reg = WCD9335_ANA_AMIC3;
-		break;
-
-	case 5:
-	case 6:
-		pwr_level_reg = WCD9335_ANA_AMIC5;
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: invalid amic: %d\n",
-			__func__, amic);
-		break;
-	}
-
-	return pwr_level_reg;
-}
-
-#define  TX_HPF_CUT_OFF_FREQ_MASK	0x60
-#define  CF_MIN_3DB_4HZ			0x0
-#define  CF_MIN_3DB_75HZ		0x1
-#define  CF_MIN_3DB_150HZ		0x2
-
-static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
-{
-	struct delayed_work *hpf_delayed_work;
-	struct hpf_work *hpf_work;
-	struct tasha_priv *tasha;
-	struct snd_soc_codec *codec;
-	u16 dec_cfg_reg, amic_reg;
-	u8 hpf_cut_off_freq;
-	int amic_n;
-
-	hpf_delayed_work = to_delayed_work(work);
-	hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
-	tasha = hpf_work->tasha;
-	codec = tasha->codec;
-	hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
-
-	dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
-
-	dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
-		__func__, hpf_work->decimator, hpf_cut_off_freq);
-
-	amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
-	if (amic_n) {
-		amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
-		tasha_codec_set_tx_hold(codec, amic_reg, false);
-	}
-	tasha_codec_vote_max_bw(codec, true);
-	snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
-			    hpf_cut_off_freq << 5);
-	tasha_codec_vote_max_bw(codec, false);
-}
-
-static void tasha_tx_mute_update_callback(struct work_struct *work)
-{
-	struct tx_mute_work *tx_mute_dwork;
-	struct tasha_priv *tasha;
-	struct delayed_work *delayed_work;
-	struct snd_soc_codec *codec;
-	u16 tx_vol_ctl_reg, hpf_gate_reg;
-
-	delayed_work = to_delayed_work(work);
-	tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
-	tasha = tx_mute_dwork->tasha;
-	codec = tasha->codec;
-
-	tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
-					16 * tx_mute_dwork->decimator;
-	hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
-					16 * tx_mute_dwork->decimator;
-	snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
-	snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
-}
-
-static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
-	struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	unsigned int decimator;
-	char *dec_adc_mux_name = NULL;
-	char *widget_name = NULL;
-	char *wname;
-	int ret = 0, amic_n;
-	u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
-	u16 tx_gain_ctl_reg;
-	char *dec;
-	u8 hpf_cut_off_freq;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-
-	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
-	if (!widget_name)
-		return -ENOMEM;
-
-	wname = widget_name;
-	dec_adc_mux_name = strsep(&widget_name, " ");
-	if (!dec_adc_mux_name) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, w->name);
-		ret =  -EINVAL;
-		goto out;
-	}
-	dec_adc_mux_name = widget_name;
-
-	dec = strpbrk(dec_adc_mux_name, "012345678");
-	if (!dec) {
-		dev_err(codec->dev, "%s: decimator index not found\n",
-			__func__);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	ret = kstrtouint(dec, 10, &decimator);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, wname);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
-			w->name, decimator);
-
-	tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
-	hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
-	dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
-	tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		amic_n = tasha_codec_find_amic_input(codec, decimator);
-		if (amic_n)
-			pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
-								       amic_n);
-
-		if (pwr_level_reg) {
-			switch ((snd_soc_read(codec, pwr_level_reg) &
-					      WCD9335_AMIC_PWR_LVL_MASK) >>
-					      WCD9335_AMIC_PWR_LVL_SHIFT) {
-			case WCD9335_AMIC_PWR_LEVEL_LP:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD9335_DEC_PWR_LVL_MASK,
-						    WCD9335_DEC_PWR_LVL_LP);
-				break;
-
-			case WCD9335_AMIC_PWR_LEVEL_HP:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD9335_DEC_PWR_LVL_MASK,
-						    WCD9335_DEC_PWR_LVL_HP);
-				break;
-			case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
-			default:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD9335_DEC_PWR_LVL_MASK,
-						    WCD9335_DEC_PWR_LVL_DF);
-				break;
-			}
-		}
-		hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
-				   TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
-		tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
-							hpf_cut_off_freq;
-
-		if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
-			snd_soc_update_bits(codec, dec_cfg_reg,
-					    TX_HPF_CUT_OFF_FREQ_MASK,
-					    CF_MIN_3DB_150HZ << 5);
-		/* Enable TX PGA Mute */
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
-
-		if (decimator == 0) {
-			snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
-			snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
-			snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
-			snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
-		}
-		/* schedule work queue to Remove Mute */
-		schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
-				      msecs_to_jiffies(tx_unmute_delay));
-		if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
-							CF_MIN_3DB_150HZ)
-			schedule_delayed_work(
-					&tasha->tx_hpf_work[decimator].dwork,
-					msecs_to_jiffies(300));
-		/* apply gain after decimator is enabled */
-		snd_soc_write(codec, tx_gain_ctl_reg,
-			      snd_soc_read(codec, tx_gain_ctl_reg));
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		hpf_cut_off_freq =
-			tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
-		if (cancel_delayed_work_sync(
-		    &tasha->tx_hpf_work[decimator].dwork)) {
-			if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
-				tasha_codec_vote_max_bw(codec, true);
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    TX_HPF_CUT_OFF_FREQ_MASK,
-						    hpf_cut_off_freq << 5);
-				tasha_codec_vote_max_bw(codec, false);
-			}
-		}
-		cancel_delayed_work_sync(
-				&tasha->tx_mute_dwork[decimator].dwork);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
-		break;
-	};
-out:
-	kfree(wname);
-	return ret;
-}
-
-static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
-				unsigned int dmic, struct wcd9xxx_pdata *pdata)
-{
-	u8 tx_stream_fs;
-	u8 adc_mux_index = 0, adc_mux_sel = 0;
-	bool dec_found = false;
-	u16 adc_mux_ctl_reg, tx_fs_reg;
-	u32 dmic_fs;
-
-	while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
-		if (adc_mux_index < 4) {
-			adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
-						(adc_mux_index * 2);
-			adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
-						0x78) >> 3) - 1;
-		} else if (adc_mux_index < 9) {
-			adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-						((adc_mux_index - 4) * 1);
-			adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
-						0x38) >> 3) - 1;
-		} else if (adc_mux_index == 9) {
-			++adc_mux_index;
-			continue;
-		}
-		if (adc_mux_sel == dmic)
-			dec_found = true;
-		else
-			++adc_mux_index;
-	}
-
-	if (dec_found == true && adc_mux_index <= 8) {
-		tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
-		tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
-		dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
-					WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
-
-		/*
-		 * Check for ECPP path selection and DEC1 not connected to
-		 * any other audio path to apply ECPP DMIC sample rate
-		 */
-		if ((adc_mux_index == 1) &&
-		    ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
-				   & 0x0F) == 0x0A) &&
-		    ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
-				   & 0x0C) == 0x00)) {
-			dmic_fs = pdata->ecpp_dmic_sample_rate;
-		}
-	} else {
-		dmic_fs = pdata->dmic_sample_rate;
-	}
-
-	return dmic_fs;
-}
-
-static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
-				 u32 mclk_rate, u32 dmic_clk_rate)
-{
-	u32 div_factor;
-	u8 dmic_ctl_val;
-
-	dev_dbg(codec->dev,
-		"%s: mclk_rate = %d, dmic_sample_rate = %d\n",
-		__func__, mclk_rate, dmic_clk_rate);
-
-	/* Default value to return in case of error */
-	if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
-	else
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
-
-	if (dmic_clk_rate == 0) {
-		dev_err(codec->dev,
-			"%s: dmic_sample_rate cannot be 0\n",
-			__func__);
-		goto done;
-	}
-
-	div_factor = mclk_rate / dmic_clk_rate;
-	switch (div_factor) {
-	case 2:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
-		break;
-	case 3:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
-		break;
-	case 4:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
-		break;
-	case 6:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
-		break;
-	case 8:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
-		break;
-	case 16:
-		dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
-			__func__, div_factor, mclk_rate, dmic_clk_rate);
-		break;
-	}
-
-done:
-	return dmic_ctl_val;
-}
-
-static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tasha_codec_set_tx_hold(codec, w->reg, true);
-		break;
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-	u8  dmic_clk_en = 0x01;
-	u16 dmic_clk_reg;
-	s32 *dmic_clk_cnt;
-	u8 dmic_rate_val, dmic_rate_shift = 1;
-	unsigned int dmic;
-	u32 dmic_sample_rate;
-	int ret;
-	char *wname;
-
-	wname = strpbrk(w->name, "012345");
-	if (!wname) {
-		dev_err(codec->dev, "%s: widget not found\n", __func__);
-		return -EINVAL;
-	}
-
-	ret = kstrtouint(wname, 10, &dmic);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (dmic) {
-	case 0:
-	case 1:
-		dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
-		dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
-		break;
-	case 2:
-	case 3:
-		dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
-		dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
-		break;
-	case 4:
-	case 5:
-		dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
-		dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
-			__func__);
-		return -EINVAL;
-	};
-	dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
-			__func__, event,  dmic, *dmic_clk_cnt);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
-						pdata);
-		dmic_rate_val =
-			tasha_get_dmic_clk_val(codec,
-					pdata->mclk_rate,
-					dmic_sample_rate);
-
-		(*dmic_clk_cnt)++;
-		if (*dmic_clk_cnt == 1) {
-			snd_soc_update_bits(codec, dmic_clk_reg,
-				0x07 << dmic_rate_shift,
-				dmic_rate_val << dmic_rate_shift);
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					dmic_clk_en, dmic_clk_en);
-		}
-
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		dmic_rate_val =
-			tasha_get_dmic_clk_val(codec,
-					pdata->mclk_rate,
-					pdata->mad_dmic_sample_rate);
-		(*dmic_clk_cnt)--;
-		if (*dmic_clk_cnt  == 0) {
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					dmic_clk_en, 0);
-			snd_soc_update_bits(codec, dmic_clk_reg,
-				0x07 << dmic_rate_shift,
-				dmic_rate_val << dmic_rate_shift);
-		}
-		break;
-	};
-
-	return 0;
-}
-
-static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
-					int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int micb_num;
-
-	dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
-		__func__, w->name, event);
-
-	if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
-		micb_num = MIC_BIAS_1;
-	else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
-		micb_num = MIC_BIAS_2;
-	else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
-		micb_num = MIC_BIAS_3;
-	else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
-		micb_num = MIC_BIAS_4;
-	else
-		return -EINVAL;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/*
-		 * MIC BIAS can also be requested by MBHC,
-		 * so use ref count to handle micbias pullup
-		 * and enable requests
-		 */
-		tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* wait for cnp time */
-		usleep_range(1000, 1100);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
-		break;
-	};
-
-	return 0;
-}
-
-static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		tasha->ldo_h_users++;
-
-		if (tasha->ldo_h_users == 1)
-			snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
-					    0x80, 0x80);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		tasha->ldo_h_users--;
-
-		if (tasha->ldo_h_users < 0)
-			tasha->ldo_h_users = 0;
-
-		if (tasha->ldo_h_users == 0)
-			snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
-					    0x80, 0x00);
-	}
-
-	return 0;
-}
-
-static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
-					  struct snd_kcontrol *kcontrol,
-					  int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wcd_resmgr_enable_master_bias(tasha->resmgr);
-		tasha_codec_ldo_h_control(w, event);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tasha_codec_ldo_h_control(w, event);
-		wcd_resmgr_disable_master_bias(tasha->resmgr);
-		break;
-	}
-
-	return 0;
-}
-
-static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
-					    struct snd_kcontrol *kcontrol,
-					    int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wcd_resmgr_enable_master_bias(tasha->resmgr);
-		tasha_cdc_mclk_enable(codec, true, true);
-		ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
-		/* Wait for 1ms for better cnp */
-		usleep_range(1000, 1100);
-		tasha_cdc_mclk_enable(codec, false, true);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
-		wcd_resmgr_disable_master_bias(tasha->resmgr);
-		break;
-	}
-
-	return ret;
-}
-
-static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	return __tasha_codec_enable_micbias(w, event);
-}
-
-static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
-					       bool enable)
-{
-	int rc;
-
-	if (enable)
-		rc = snd_soc_dapm_force_enable_pin(
-					snd_soc_codec_get_dapm(codec),
-					DAPM_LDO_H_STANDALONE);
-	else
-		rc = snd_soc_dapm_disable_pin(
-					snd_soc_codec_get_dapm(codec),
-					DAPM_LDO_H_STANDALONE);
-
-	if (!rc)
-		snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-	else
-		dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
-			__func__, (enable ? "enable" : "disable"));
-
-	return rc;
-}
-
-/*
- * tasha_codec_enable_standalone_micbias - enable micbias standalone
- * @codec: pointer to codec instance
- * @micb_num: number of micbias to be enabled
- * @enable: true to enable micbias or false to disable
- *
- * This function is used to enable micbias (1, 2, 3 or 4) during
- * standalone independent of whether TX use-case is running or not
- *
- * Return: error code in case of failure or 0 for success
- */
-int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
-					  int micb_num,
-					  bool enable)
-{
-	const char * const micb_names[] = {
-		DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
-		DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
-	};
-	int micb_index = micb_num - 1;
-	int rc;
-
-	if (!codec) {
-		pr_err("%s: Codec memory is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
-		dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
-			__func__, micb_index);
-		return -EINVAL;
-	}
-
-	if (enable)
-		rc = snd_soc_dapm_force_enable_pin(
-						 snd_soc_codec_get_dapm(codec),
-						   micb_names[micb_index]);
-	else
-		rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
-					      micb_names[micb_index]);
-
-	if (!rc)
-		snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-	else
-		dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
-			__func__, micb_num, (enable ? "enable" : "disable"));
-
-	return rc;
-}
-EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
-
-static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
-static const struct soc_enum tasha_anc_func_enum =
-		SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
-
-static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
-static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
-
-/* Cutoff frequency for high pass filter */
-static const char * const cf_text[] = {
-	"CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
-};
-
-static const char * const rx_cf_text[] = {
-	"CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
-	"CF_NEG_3DB_0P48HZ"
-};
-
-static const struct soc_enum cf_dec0_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec2_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec3_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec4_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec5_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec6_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec7_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_dec8_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
-
-static const struct soc_enum cf_int0_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int1_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int2_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int3_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int4_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int5_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int6_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int7_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct soc_enum cf_int8_1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
-
-static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
-		     rx_cf_text);
-
-static const struct snd_soc_dapm_route audio_i2s_map[] = {
-	{"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
-	{"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
-	{"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
-	{"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
-
-	{"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
-	{"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
-	{"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
-	{"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
-};
-
-static const struct snd_soc_dapm_route audio_map[] = {
-
-	/* MAD */
-	{"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
-	{"MAD_SEL MUX", "MSM", "MADINPUT"},
-	{"MADONOFF", "Switch", "MAD_SEL MUX"},
-	{"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
-	{"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
-
-	/* CPE HW MAD bypass */
-	{"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
-
-	{"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
-	{"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
-	{"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
-	{"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
-	{"AIF4 MAD", NULL, "AIF4"},
-
-	{"EC BUF MUX INP", "DEC1", "ADC MUX1"},
-	{"AIF5 CPE", NULL, "EC BUF MUX INP"},
-
-	/* SLIMBUS Connections */
-	{"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
-	{"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
-	{"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
-
-	/* VI Feedback */
-	{"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
-	{"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
-	{"AIF4 VI", NULL, "AIF4_VI Mixer"},
-
-	/* SLIM_MIXER("AIF1_CAP Mixer"),*/
-	{"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
-	{"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
-	/* SLIM_MIXER("AIF2_CAP Mixer"),*/
-	{"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
-	{"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
-	/* SLIM_MIXER("AIF3_CAP Mixer"),*/
-	{"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
-	{"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
-
-	{"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
-	{"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
-	{"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
-
-	{"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
-	{"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
-	{"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
-
-	{"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
-	{"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
-	{"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
-
-	{"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
-	{"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
-	{"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
-
-	{"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
-	{"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
-	{"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
-
-	{"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
-	{"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
-	{"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
-
-	{"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
-	{"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
-	{"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
-
-	{"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
-	{"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
-	{"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
-
-	{"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
-	{"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
-	{"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
-
-	{"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
-	{"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
-	{"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
-	{"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
-
-	{"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
-	{"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
-	{"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
-
-	{"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
-	{"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
-	{"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
-
-	{"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
-	{"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
-	{"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
-	{"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
-
-	{"ADC US MUX0", "US_Switch", "ADC MUX0"},
-	{"ADC US MUX1", "US_Switch", "ADC MUX1"},
-	{"ADC US MUX2", "US_Switch", "ADC MUX2"},
-	{"ADC US MUX3", "US_Switch", "ADC MUX3"},
-	{"ADC US MUX4", "US_Switch", "ADC MUX4"},
-	{"ADC US MUX5", "US_Switch", "ADC MUX5"},
-	{"ADC US MUX6", "US_Switch", "ADC MUX6"},
-	{"ADC US MUX7", "US_Switch", "ADC MUX7"},
-	{"ADC US MUX8", "US_Switch", "ADC MUX8"},
-	{"ADC MUX0", "DMIC", "DMIC MUX0"},
-	{"ADC MUX0", "AMIC", "AMIC MUX0"},
-	{"ADC MUX1", "DMIC", "DMIC MUX1"},
-	{"ADC MUX1", "AMIC", "AMIC MUX1"},
-	{"ADC MUX2", "DMIC", "DMIC MUX2"},
-	{"ADC MUX2", "AMIC", "AMIC MUX2"},
-	{"ADC MUX3", "DMIC", "DMIC MUX3"},
-	{"ADC MUX3", "AMIC", "AMIC MUX3"},
-	{"ADC MUX4", "DMIC", "DMIC MUX4"},
-	{"ADC MUX4", "AMIC", "AMIC MUX4"},
-	{"ADC MUX5", "DMIC", "DMIC MUX5"},
-	{"ADC MUX5", "AMIC", "AMIC MUX5"},
-	{"ADC MUX6", "DMIC", "DMIC MUX6"},
-	{"ADC MUX6", "AMIC", "AMIC MUX6"},
-	{"ADC MUX7", "DMIC", "DMIC MUX7"},
-	{"ADC MUX7", "AMIC", "AMIC MUX7"},
-	{"ADC MUX8", "DMIC", "DMIC MUX8"},
-	{"ADC MUX8", "AMIC", "AMIC MUX8"},
-	{"ADC MUX10", "DMIC", "DMIC MUX10"},
-	{"ADC MUX10", "AMIC", "AMIC MUX10"},
-	{"ADC MUX11", "DMIC", "DMIC MUX11"},
-	{"ADC MUX11", "AMIC", "AMIC MUX11"},
-	{"ADC MUX12", "DMIC", "DMIC MUX12"},
-	{"ADC MUX12", "AMIC", "AMIC MUX12"},
-	{"ADC MUX13", "DMIC", "DMIC MUX13"},
-	{"ADC MUX13", "AMIC", "AMIC MUX13"},
-
-	{"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
-
-	{"DMIC MUX0", "DMIC0", "DMIC0"},
-	{"DMIC MUX0", "DMIC1", "DMIC1"},
-	{"DMIC MUX0", "DMIC2", "DMIC2"},
-	{"DMIC MUX0", "DMIC3", "DMIC3"},
-	{"DMIC MUX0", "DMIC4", "DMIC4"},
-	{"DMIC MUX0", "DMIC5", "DMIC5"},
-	{"AMIC MUX0", "ADC1", "ADC1"},
-	{"AMIC MUX0", "ADC2", "ADC2"},
-	{"AMIC MUX0", "ADC3", "ADC3"},
-	{"AMIC MUX0", "ADC4", "ADC4"},
-	{"AMIC MUX0", "ADC5", "ADC5"},
-	{"AMIC MUX0", "ADC6", "ADC6"},
-
-	{"DMIC MUX1", "DMIC0", "DMIC0"},
-	{"DMIC MUX1", "DMIC1", "DMIC1"},
-	{"DMIC MUX1", "DMIC2", "DMIC2"},
-	{"DMIC MUX1", "DMIC3", "DMIC3"},
-	{"DMIC MUX1", "DMIC4", "DMIC4"},
-	{"DMIC MUX1", "DMIC5", "DMIC5"},
-	{"AMIC MUX1", "ADC1", "ADC1"},
-	{"AMIC MUX1", "ADC2", "ADC2"},
-	{"AMIC MUX1", "ADC3", "ADC3"},
-	{"AMIC MUX1", "ADC4", "ADC4"},
-	{"AMIC MUX1", "ADC5", "ADC5"},
-	{"AMIC MUX1", "ADC6", "ADC6"},
-
-	{"DMIC MUX2", "DMIC0", "DMIC0"},
-	{"DMIC MUX2", "DMIC1", "DMIC1"},
-	{"DMIC MUX2", "DMIC2", "DMIC2"},
-	{"DMIC MUX2", "DMIC3", "DMIC3"},
-	{"DMIC MUX2", "DMIC4", "DMIC4"},
-	{"DMIC MUX2", "DMIC5", "DMIC5"},
-	{"AMIC MUX2", "ADC1", "ADC1"},
-	{"AMIC MUX2", "ADC2", "ADC2"},
-	{"AMIC MUX2", "ADC3", "ADC3"},
-	{"AMIC MUX2", "ADC4", "ADC4"},
-	{"AMIC MUX2", "ADC5", "ADC5"},
-	{"AMIC MUX2", "ADC6", "ADC6"},
-
-	{"DMIC MUX3", "DMIC0", "DMIC0"},
-	{"DMIC MUX3", "DMIC1", "DMIC1"},
-	{"DMIC MUX3", "DMIC2", "DMIC2"},
-	{"DMIC MUX3", "DMIC3", "DMIC3"},
-	{"DMIC MUX3", "DMIC4", "DMIC4"},
-	{"DMIC MUX3", "DMIC5", "DMIC5"},
-	{"AMIC MUX3", "ADC1", "ADC1"},
-	{"AMIC MUX3", "ADC2", "ADC2"},
-	{"AMIC MUX3", "ADC3", "ADC3"},
-	{"AMIC MUX3", "ADC4", "ADC4"},
-	{"AMIC MUX3", "ADC5", "ADC5"},
-	{"AMIC MUX3", "ADC6", "ADC6"},
-
-	{"DMIC MUX4", "DMIC0", "DMIC0"},
-	{"DMIC MUX4", "DMIC1", "DMIC1"},
-	{"DMIC MUX4", "DMIC2", "DMIC2"},
-	{"DMIC MUX4", "DMIC3", "DMIC3"},
-	{"DMIC MUX4", "DMIC4", "DMIC4"},
-	{"DMIC MUX4", "DMIC5", "DMIC5"},
-	{"AMIC MUX4", "ADC1", "ADC1"},
-	{"AMIC MUX4", "ADC2", "ADC2"},
-	{"AMIC MUX4", "ADC3", "ADC3"},
-	{"AMIC MUX4", "ADC4", "ADC4"},
-	{"AMIC MUX4", "ADC5", "ADC5"},
-	{"AMIC MUX4", "ADC6", "ADC6"},
-
-	{"DMIC MUX5", "DMIC0", "DMIC0"},
-	{"DMIC MUX5", "DMIC1", "DMIC1"},
-	{"DMIC MUX5", "DMIC2", "DMIC2"},
-	{"DMIC MUX5", "DMIC3", "DMIC3"},
-	{"DMIC MUX5", "DMIC4", "DMIC4"},
-	{"DMIC MUX5", "DMIC5", "DMIC5"},
-	{"AMIC MUX5", "ADC1", "ADC1"},
-	{"AMIC MUX5", "ADC2", "ADC2"},
-	{"AMIC MUX5", "ADC3", "ADC3"},
-	{"AMIC MUX5", "ADC4", "ADC4"},
-	{"AMIC MUX5", "ADC5", "ADC5"},
-	{"AMIC MUX5", "ADC6", "ADC6"},
-
-	{"DMIC MUX6", "DMIC0", "DMIC0"},
-	{"DMIC MUX6", "DMIC1", "DMIC1"},
-	{"DMIC MUX6", "DMIC2", "DMIC2"},
-	{"DMIC MUX6", "DMIC3", "DMIC3"},
-	{"DMIC MUX6", "DMIC4", "DMIC4"},
-	{"DMIC MUX6", "DMIC5", "DMIC5"},
-	{"AMIC MUX6", "ADC1", "ADC1"},
-	{"AMIC MUX6", "ADC2", "ADC2"},
-	{"AMIC MUX6", "ADC3", "ADC3"},
-	{"AMIC MUX6", "ADC4", "ADC4"},
-	{"AMIC MUX6", "ADC5", "ADC5"},
-	{"AMIC MUX6", "ADC6", "ADC6"},
-
-	{"DMIC MUX7", "DMIC0", "DMIC0"},
-	{"DMIC MUX7", "DMIC1", "DMIC1"},
-	{"DMIC MUX7", "DMIC2", "DMIC2"},
-	{"DMIC MUX7", "DMIC3", "DMIC3"},
-	{"DMIC MUX7", "DMIC4", "DMIC4"},
-	{"DMIC MUX7", "DMIC5", "DMIC5"},
-	{"AMIC MUX7", "ADC1", "ADC1"},
-	{"AMIC MUX7", "ADC2", "ADC2"},
-	{"AMIC MUX7", "ADC3", "ADC3"},
-	{"AMIC MUX7", "ADC4", "ADC4"},
-	{"AMIC MUX7", "ADC5", "ADC5"},
-	{"AMIC MUX7", "ADC6", "ADC6"},
-
-	{"DMIC MUX8", "DMIC0", "DMIC0"},
-	{"DMIC MUX8", "DMIC1", "DMIC1"},
-	{"DMIC MUX8", "DMIC2", "DMIC2"},
-	{"DMIC MUX8", "DMIC3", "DMIC3"},
-	{"DMIC MUX8", "DMIC4", "DMIC4"},
-	{"DMIC MUX8", "DMIC5", "DMIC5"},
-	{"AMIC MUX8", "ADC1", "ADC1"},
-	{"AMIC MUX8", "ADC2", "ADC2"},
-	{"AMIC MUX8", "ADC3", "ADC3"},
-	{"AMIC MUX8", "ADC4", "ADC4"},
-	{"AMIC MUX8", "ADC5", "ADC5"},
-	{"AMIC MUX8", "ADC6", "ADC6"},
-
-	{"DMIC MUX10", "DMIC0", "DMIC0"},
-	{"DMIC MUX10", "DMIC1", "DMIC1"},
-	{"DMIC MUX10", "DMIC2", "DMIC2"},
-	{"DMIC MUX10", "DMIC3", "DMIC3"},
-	{"DMIC MUX10", "DMIC4", "DMIC4"},
-	{"DMIC MUX10", "DMIC5", "DMIC5"},
-	{"AMIC MUX10", "ADC1", "ADC1"},
-	{"AMIC MUX10", "ADC2", "ADC2"},
-	{"AMIC MUX10", "ADC3", "ADC3"},
-	{"AMIC MUX10", "ADC4", "ADC4"},
-	{"AMIC MUX10", "ADC5", "ADC5"},
-	{"AMIC MUX10", "ADC6", "ADC6"},
-
-	{"DMIC MUX11", "DMIC0", "DMIC0"},
-	{"DMIC MUX11", "DMIC1", "DMIC1"},
-	{"DMIC MUX11", "DMIC2", "DMIC2"},
-	{"DMIC MUX11", "DMIC3", "DMIC3"},
-	{"DMIC MUX11", "DMIC4", "DMIC4"},
-	{"DMIC MUX11", "DMIC5", "DMIC5"},
-	{"AMIC MUX11", "ADC1", "ADC1"},
-	{"AMIC MUX11", "ADC2", "ADC2"},
-	{"AMIC MUX11", "ADC3", "ADC3"},
-	{"AMIC MUX11", "ADC4", "ADC4"},
-	{"AMIC MUX11", "ADC5", "ADC5"},
-	{"AMIC MUX11", "ADC6", "ADC6"},
-
-	{"DMIC MUX12", "DMIC0", "DMIC0"},
-	{"DMIC MUX12", "DMIC1", "DMIC1"},
-	{"DMIC MUX12", "DMIC2", "DMIC2"},
-	{"DMIC MUX12", "DMIC3", "DMIC3"},
-	{"DMIC MUX12", "DMIC4", "DMIC4"},
-	{"DMIC MUX12", "DMIC5", "DMIC5"},
-	{"AMIC MUX12", "ADC1", "ADC1"},
-	{"AMIC MUX12", "ADC2", "ADC2"},
-	{"AMIC MUX12", "ADC3", "ADC3"},
-	{"AMIC MUX12", "ADC4", "ADC4"},
-	{"AMIC MUX12", "ADC5", "ADC5"},
-	{"AMIC MUX12", "ADC6", "ADC6"},
-
-	{"DMIC MUX13", "DMIC0", "DMIC0"},
-	{"DMIC MUX13", "DMIC1", "DMIC1"},
-	{"DMIC MUX13", "DMIC2", "DMIC2"},
-	{"DMIC MUX13", "DMIC3", "DMIC3"},
-	{"DMIC MUX13", "DMIC4", "DMIC4"},
-	{"DMIC MUX13", "DMIC5", "DMIC5"},
-	{"AMIC MUX13", "ADC1", "ADC1"},
-	{"AMIC MUX13", "ADC2", "ADC2"},
-	{"AMIC MUX13", "ADC3", "ADC3"},
-	{"AMIC MUX13", "ADC4", "ADC4"},
-	{"AMIC MUX13", "ADC5", "ADC5"},
-	{"AMIC MUX13", "ADC6", "ADC6"},
-	/* ADC Connections */
-	{"ADC1", NULL, "AMIC1"},
-	{"ADC2", NULL, "AMIC2"},
-	{"ADC3", NULL, "AMIC3"},
-	{"ADC4", NULL, "AMIC4"},
-	{"ADC5", NULL, "AMIC5"},
-	{"ADC6", NULL, "AMIC6"},
-
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
-	{"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
-	{"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
-	{"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
-	{"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
-	{"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
-	{"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
-
-	{"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
-	{"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
-	{"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
-	{"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
-	{"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
-	{"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
-	{"RX INT0 DAC", NULL, "RX_BIAS"},
-	{"EAR PA", NULL, "RX INT0 DAC"},
-	{"EAR", NULL, "EAR PA"},
-
-	{"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
-	{"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
-	{"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
-	{"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
-	{"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
-	{"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
-	{"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
-	{"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
-	{"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
-	{"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
-	{"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
-	{"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
-	{"RX INT1 DAC", NULL, "RX_BIAS"},
-	{"HPHL PA", NULL, "RX INT1 DAC"},
-	{"HPHL", NULL, "HPHL PA"},
-
-	{"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
-	{"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
-	{"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
-	{"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
-	{"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
-	{"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
-	{"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
-	{"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
-	{"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
-	{"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
-	{"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
-	{"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
-	{"RX INT2 DAC", NULL, "RX_BIAS"},
-	{"HPHR PA", NULL, "RX INT2 DAC"},
-	{"HPHR", NULL, "HPHR PA"},
-
-	{"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
-	{"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
-	{"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
-	{"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
-	{"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
-	{"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
-	{"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
-	{"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
-	{"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
-	{"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
-	{"RX INT3 DAC", NULL, "RX INT3 INTERP"},
-	{"RX INT3 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT1 PA", NULL, "RX INT3 DAC"},
-	{"LINEOUT1", NULL, "LINEOUT1 PA"},
-
-	{"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
-	{"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
-	{"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
-	{"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
-	{"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
-	{"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
-	{"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
-	{"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
-	{"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
-	{"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
-	{"RX INT4 DAC", NULL, "RX INT4 INTERP"},
-	{"RX INT4 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT2 PA", NULL, "RX INT4 DAC"},
-	{"LINEOUT2", NULL, "LINEOUT2 PA"},
-
-	{"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
-	{"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
-	{"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
-	{"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
-	{"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
-	{"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
-
-	{"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
-	{"RX INT5 DAC", NULL, "RX INT5 VBAT"},
-
-	{"RX INT5 DAC", NULL, "RX INT5 INTERP"},
-	{"RX INT5 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT3 PA", NULL, "RX INT5 DAC"},
-	{"LINEOUT3", NULL, "LINEOUT3 PA"},
-
-	{"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
-	{"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
-	{"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
-	{"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
-	{"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
-	{"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
-
-	{"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
-	{"RX INT6 DAC", NULL, "RX INT6 VBAT"},
-
-	{"RX INT6 DAC", NULL, "RX INT6 INTERP"},
-	{"RX INT6 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT4 PA", NULL, "RX INT6 DAC"},
-	{"LINEOUT4", NULL, "LINEOUT4 PA"},
-
-	{"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
-	{"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
-	{"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
-	{"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
-	{"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
-	{"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
-
-	{"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
-
-	{"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
-	{"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
-
-	{"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
-	{"RX INT7 CHAIN", NULL, "RX_BIAS"},
-	{"SPK1 OUT", NULL, "RX INT7 CHAIN"},
-
-	{"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
-	{"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
-	{"SPK1 OUT", NULL, "ANC SPK1 PA"},
-
-	{"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
-	{"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
-	{"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
-	{"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
-	{"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
-
-	{"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
-	{"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
-
-	{"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
-	{"RX INT8 CHAIN", NULL, "RX_BIAS"},
-	{"SPK2 OUT", NULL, "RX INT8 CHAIN"},
-
-	{"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
-	{"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
-	{"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
-
-	{"ANC HPHL Enable", "Switch", "ADC MUX10"},
-	{"ANC HPHL Enable", "Switch", "ADC MUX11"},
-	{"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
-
-	{"ANC HPHR Enable", "Switch", "ADC MUX12"},
-	{"ANC HPHR Enable", "Switch", "ADC MUX13"},
-	{"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
-
-	{"ANC EAR Enable", "Switch", "ADC MUX10"},
-	{"ANC EAR Enable", "Switch", "ADC MUX11"},
-	{"RX INT0 MIX2", NULL, "ANC EAR Enable"},
-
-	{"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
-	{"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
-	{"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
-
-	{"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
-	{"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
-	{"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
-
-	{"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
-	{"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
-	{"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
-
-	{"ANC EAR PA", NULL, "RX INT0 DAC"},
-	{"ANC EAR", NULL, "ANC EAR PA"},
-	{"ANC HPHL PA", NULL, "RX INT1 DAC"},
-	{"ANC HPHL", NULL, "ANC HPHL PA"},
-	{"ANC HPHR PA", NULL, "RX INT2 DAC"},
-	{"ANC HPHR", NULL, "ANC HPHR PA"},
-	{"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
-	{"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
-	{"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
-	{"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
-
-	/* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
-	{"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
-	/* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
-	{"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
-	/* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
-	{"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
-	/* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
-	{"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
-
-	/* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
-	{"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-	{"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
-
-	{"SLIM RX0", NULL, "SLIM RX0 MUX"},
-	{"SLIM RX1", NULL, "SLIM RX1 MUX"},
-	{"SLIM RX2", NULL, "SLIM RX2 MUX"},
-	{"SLIM RX3", NULL, "SLIM RX3 MUX"},
-	{"SLIM RX4", NULL, "SLIM RX4 MUX"},
-	{"SLIM RX5", NULL, "SLIM RX5 MUX"},
-	{"SLIM RX6", NULL, "SLIM RX6 MUX"},
-	{"SLIM RX7", NULL, "SLIM RX7 MUX"},
-
-	{"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	/* MIXing path INT0 */
-	{"RX INT0_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT0_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT0_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT0_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT0_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT0_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT0_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT0_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
-
-	/* MIXing path INT1 */
-	{"RX INT1_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT1_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT1_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT1_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT1_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT1_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT1_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT1_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
-
-	/* MIXing path INT2 */
-	{"RX INT2_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT2_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT2_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT2_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT2_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT2_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT2_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT2_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
-
-	/* MIXing path INT3 */
-	{"RX INT3_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT3_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT3_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT3_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT3_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT3_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT3_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT3_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
-
-	/* MIXing path INT4 */
-	{"RX INT4_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT4_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT4_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT4_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT4_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT4_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT4_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT4_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
-
-	/* MIXing path INT5 */
-	{"RX INT5_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT5_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT5_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT5_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT5_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT5_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT5_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT5_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
-
-	/* MIXing path INT6 */
-	{"RX INT6_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT6_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT6_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT6_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT6_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT6_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT6_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT6_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
-
-	/* MIXing path INT7 */
-	{"RX INT7_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT7_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT7_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT7_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT7_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT7_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT7_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT7_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
-
-	/* MIXing path INT8 */
-	{"RX INT8_2 MUX", "RX0", "SLIM RX0"},
-	{"RX INT8_2 MUX", "RX1", "SLIM RX1"},
-	{"RX INT8_2 MUX", "RX2", "SLIM RX2"},
-	{"RX INT8_2 MUX", "RX3", "SLIM RX3"},
-	{"RX INT8_2 MUX", "RX4", "SLIM RX4"},
-	{"RX INT8_2 MUX", "RX5", "SLIM RX5"},
-	{"RX INT8_2 MUX", "RX6", "SLIM RX6"},
-	{"RX INT8_2 MUX", "RX7", "SLIM RX7"},
-	{"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
-
-	{"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
-	{"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
-	{"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
-	{"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
-	{"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
-	{"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
-	{"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
-	{"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
-	{"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
-	{"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
-	{"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
-	{"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
-	{"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
-	{"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
-	{"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
-	{"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
-	{"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
-	{"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
-	{"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
-	{"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
-	{"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
-	{"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
-	{"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
-	{"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
-	{"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	/* SRC0, SRC1 inputs to Sidetone RX Mixer
-	 * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
-	 */
-	{"IIR0", NULL, "IIR0 INP0 MUX"},
-	{"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
-	{"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
-	{"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
-	{"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
-	{"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
-	{"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
-	{"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
-	{"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
-	{"IIR0", NULL, "IIR0 INP1 MUX"},
-	{"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
-	{"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
-	{"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
-	{"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
-	{"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
-	{"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
-	{"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
-	{"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
-	{"IIR0", NULL, "IIR0 INP2 MUX"},
-	{"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
-	{"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
-	{"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
-	{"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
-	{"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
-	{"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
-	{"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
-	{"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
-	{"IIR0", NULL, "IIR0 INP3 MUX"},
-	{"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
-	{"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
-	{"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
-	{"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
-	{"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
-	{"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
-	{"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
-	{"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
-
-	{"IIR1", NULL, "IIR1 INP0 MUX"},
-	{"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
-	{"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
-	{"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
-	{"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
-	{"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
-	{"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
-	{"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
-	{"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
-	{"IIR1", NULL, "IIR1 INP1 MUX"},
-	{"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
-	{"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
-	{"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
-	{"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
-	{"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
-	{"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
-	{"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
-	{"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
-	{"IIR1", NULL, "IIR1 INP2 MUX"},
-	{"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
-	{"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
-	{"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
-	{"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
-	{"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
-	{"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
-	{"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
-	{"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
-	{"IIR1", NULL, "IIR1 INP3 MUX"},
-	{"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
-	{"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
-	{"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
-	{"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
-	{"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
-	{"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
-	{"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
-	{"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
-
-	{"SRC0", NULL, "IIR0"},
-	{"SRC1", NULL, "IIR1"},
-	{"RX INT0 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT0 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT1 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT1 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT2 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT2 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT3 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT3 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT4 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT4 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT7 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT7 MIX2 INP", "SRC1", "SRC1"},
-};
-
-static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u16 amic_reg;
-
-	if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC1;
-	if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC3;
-	if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC5;
-
-	ucontrol->value.integer.value[0] =
-		(snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
-			     WCD9335_AMIC_PWR_LVL_SHIFT;
-
-	return 0;
-}
-
-static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u32 mode_val;
-	u16 amic_reg;
-
-	mode_val = ucontrol->value.enumerated.item[0];
-
-	dev_dbg(codec->dev, "%s: mode: %d\n",
-		__func__, mode_val);
-
-	if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC1;
-	if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC3;
-	if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
-		amic_reg = WCD9335_ANA_AMIC5;
-
-	snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
-			    mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
-
-	return 0;
-}
-
-static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha->hph_mode;
-	return 0;
-}
-
-static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u32 mode_val;
-
-	mode_val = ucontrol->value.enumerated.item[0];
-
-	dev_dbg(codec->dev, "%s: mode: %d\n",
-		__func__, mode_val);
-
-	if (mode_val == 0) {
-		dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
-			__func__);
-		mode_val = CLS_H_HIFI;
-	}
-	tasha->hph_mode = mode_val;
-	return 0;
-}
-
-static const char *const tasha_conn_mad_text[] = {
-	"NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
-	"NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
-	"DMIC5", "NOTUSED3", "NOTUSED4"
-};
-
-static const struct soc_enum tasha_conn_mad_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
-			    tasha_conn_mad_text);
-
-static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u8 val = 0;
-
-	if (codec)
-		val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
-
-	ucontrol->value.integer.value[0] = !!val;
-
-	return 0;
-}
-
-static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int value = ucontrol->value.integer.value[0];
-	bool enable;
-
-	enable = !!value;
-	if (codec)
-		tasha_codec_enable_standalone_ldo_h(codec, enable);
-
-	return 0;
-}
-
-static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	u8 tasha_mad_input;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	tasha_mad_input = snd_soc_read(codec,
-				WCD9335_SOC_MAD_INP_SEL) & 0x0F;
-	ucontrol->value.integer.value[0] = tasha_mad_input;
-
-	dev_dbg(codec->dev,
-		"%s: tasha_mad_input = %s\n", __func__,
-		tasha_conn_mad_text[tasha_mad_input]);
-	return 0;
-}
-
-static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	u8 tasha_mad_input;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct snd_soc_card *card = codec->component.card;
-	char mad_amic_input_widget[6];
-	const char *mad_input_widget;
-	const char *source_widget = NULL;
-	u32 adc, i, mic_bias_found = 0;
-	int ret = 0;
-	char *mad_input;
-
-	tasha_mad_input = ucontrol->value.integer.value[0];
-
-	if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
-		dev_err(codec->dev,
-			"%s: tasha_mad_input = %d out of bounds\n",
-			__func__, tasha_mad_input);
-		return -EINVAL;
-	}
-
-	if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
-	    !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
-	    !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
-	    !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
-		dev_err(codec->dev,
-			"%s: Unsupported tasha_mad_input = %s\n",
-			__func__, tasha_conn_mad_text[tasha_mad_input]);
-		return -EINVAL;
-	}
-
-	if (strnstr(tasha_conn_mad_text[tasha_mad_input],
-		    "ADC", sizeof("ADC"))) {
-		mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
-				    "123456");
-		if (!mad_input) {
-			dev_err(codec->dev, "%s: Invalid MAD input %s\n",
-				__func__,
-				tasha_conn_mad_text[tasha_mad_input]);
-			return -EINVAL;
-		}
-		ret = kstrtouint(mad_input, 10, &adc);
-		if ((ret < 0) || (adc > 6)) {
-			dev_err(codec->dev,
-				"%s: Invalid ADC = %s\n", __func__,
-				tasha_conn_mad_text[tasha_mad_input]);
-			ret =  -EINVAL;
-		}
-
-		snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
-
-		mad_input_widget = mad_amic_input_widget;
-	} else {
-		/* DMIC type input widget*/
-		mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
-	}
-
-	dev_dbg(codec->dev,
-		"%s: tasha input widget = %s\n", __func__,
-		mad_input_widget);
-
-	for (i = 0; i < card->num_of_dapm_routes; i++) {
-		if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
-			source_widget = card->of_dapm_routes[i].source;
-			if (!source_widget) {
-				dev_err(codec->dev,
-					"%s: invalid source widget\n",
-					__func__);
-				return -EINVAL;
-			}
-
-			if (strnstr(source_widget,
-				"MIC BIAS1", sizeof("MIC BIAS1"))) {
-				mic_bias_found = 1;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS2", sizeof("MIC BIAS2"))) {
-				mic_bias_found = 2;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS3", sizeof("MIC BIAS3"))) {
-				mic_bias_found = 3;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS4", sizeof("MIC BIAS4"))) {
-				mic_bias_found = 4;
-				break;
-			}
-		}
-	}
-
-	if (!mic_bias_found) {
-		dev_err(codec->dev,
-			"%s: mic bias source not found for input = %s\n",
-			__func__, mad_input_widget);
-		return -EINVAL;
-	}
-
-	dev_dbg(codec->dev,
-		"%s: mic_bias found = %d\n", __func__,
-		mic_bias_found);
-
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
-			    0x0F, tasha_mad_input);
-	snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
-			    0x07, mic_bias_found);
-
-	return 0;
-}
-
-static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u16 ctl_reg;
-	u8 reg_val, pinctl_position;
-
-	pinctl_position = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	switch (pinctl_position >> 3) {
-	case 0:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
-		break;
-	case 1:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
-		break;
-	case 2:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
-		break;
-	case 3:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
-			__func__, pinctl_position);
-		return -EINVAL;
-	}
-
-	reg_val = snd_soc_read(codec, ctl_reg);
-	reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
-	ucontrol->value.integer.value[0] = reg_val;
-
-	return 0;
-}
-
-static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 ctl_reg, cfg_reg;
-	u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
-
-	/* 1- high or low; 0- high Z */
-	pinctl_mode = ucontrol->value.integer.value[0];
-	pinctl_position = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	switch (pinctl_position >> 3) {
-	case 0:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
-		break;
-	case 1:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
-		break;
-	case 2:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
-		break;
-	case 3:
-		ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
-			__func__, pinctl_position);
-		return -EINVAL;
-	}
-
-	ctl_val = pinctl_mode << (pinctl_position & 0x07);
-	mask = 1 << (pinctl_position & 0x07);
-	snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
-
-	cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
-	if (!pinctl_mode) {
-		if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-			cfg_val = 0x4;
-		else
-			cfg_val = 0xC;
-	} else {
-		cfg_val = 0;
-	}
-	snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
-
-	dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
-			__func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
-
-	return 0;
-}
-
-static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
-					struct snd_soc_codec *codec)
-{
-	u8 val1, val2;
-
-	/*
-	 * Measure dcp1 by using "ALT" branch of band gap
-	 * voltage(Vbg) and use it in FAST mode
-	 */
-	snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
-	snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
-	snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
-	snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
-	snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
-
-	snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
-	/* Wait 100 usec after calibration select as Vbg */
-	usleep_range(100, 110);
-
-	snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
-	val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
-	val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
-	snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
-
-	vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
-
-	snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
-	/* Wait 100 usec after selecting Vbg as 1.05V */
-	usleep_range(100, 110);
-
-	snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
-	val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
-	val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
-	snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
-
-	vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
-
-	dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
-		__func__, vbat->dcp1, vbat->dcp2);
-
-	snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
-	/* Wait 100 usec after selecting Vbg as 0.85V */
-	usleep_range(100, 110);
-
-	snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
-	snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
-	snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
-
-	snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
-	snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
-}
-
-static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
-					struct snd_soc_codec *codec)
-{
-	u8 val1, val2;
-
-	/*
-	 * Measure dcp1 by applying band gap voltage(Vbg)
-	 * of 0.85V
-	 */
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
-	snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
-	snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
-	/* Wait 2 sec after enabling band gap bias */
-	usleep_range(2000000, 2000100);
-
-	snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
-	snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
-	snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
-	snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
-	snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
-
-	snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
-	snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
-	snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
-	/* Wait 1 msec after calibration select as Vbg */
-	usleep_range(1000, 1100);
-
-	snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
-	val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
-	val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
-	snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
-
-	vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
-
-	/*
-	 * Measure dcp2 by applying band gap voltage(Vbg)
-	 * of 1.05V
-	 */
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
-	snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
-	/* Wait 2 msec after selecting Vbg as 1.05V */
-	usleep_range(2000, 2100);
-
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
-	/* Wait 1 sec after enabling band gap bias */
-	usleep_range(1000000, 1000100);
-
-	snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
-	val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
-	val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
-	snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
-
-	vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
-
-	dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
-		__func__, vbat->dcp1, vbat->dcp2);
-
-	/* Reset the Vbat ADC configuration */
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
-
-	snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
-	/* Wait 2 msec after selecting Vbg as 0.85V */
-	usleep_range(2000, 2100);
-
-	snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
-	/* Wait 1 sec after enabling band gap bias */
-	usleep_range(1000000, 1000100);
-
-	snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
-	snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
-	snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
-	snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
-
-	snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
-	snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
-	snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
-}
-
-static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
-				struct snd_soc_codec *codec)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!vbat->adc_config) {
-		tasha_cdc_mclk_enable(codec, true, false);
-
-		if (TASHA_IS_2_0(wcd9xxx))
-			wcd_vbat_adc_out_config_2_0(vbat, codec);
-		else
-			wcd_vbat_adc_out_config_1_x(vbat, codec);
-
-		tasha_cdc_mclk_enable(codec, false, false);
-		vbat->adc_config = true;
-	}
-}
-
-static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct firmware_cal *hwdep_cal = NULL;
-	struct vbat_monitor_reg *vbat_reg_ptr = NULL;
-	const void *data;
-	size_t cal_size, vbat_size_remaining;
-	int ret = 0, i;
-	u32 vbat_writes_size = 0;
-	u16 reg;
-	u8 mask, val, old_val;
-
-	hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
-	if (hwdep_cal) {
-		data = hwdep_cal->data;
-		cal_size = hwdep_cal->size;
-		dev_dbg(codec->dev, "%s: using hwdep calibration\n",
-			__func__);
-	} else {
-		dev_err(codec->dev, "%s: Vbat cal not received\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_size < sizeof(*vbat_reg_ptr)) {
-		dev_err(codec->dev,
-			"%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
-			__func__, cal_size, sizeof(*vbat_reg_ptr));
-		ret = -EINVAL;
-		goto done;
-	}
-
-	vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
-
-	if (!vbat_reg_ptr) {
-		dev_err(codec->dev,
-			"%s: Invalid calibration data for Vbat\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	vbat_writes_size = vbat_reg_ptr->size;
-	vbat_size_remaining = cal_size - sizeof(u32);
-	dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
-			__func__, vbat_writes_size, vbat_size_remaining);
-
-	if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
-					> vbat_size_remaining) {
-		pr_err("%s: Incorrect Vbat calibration data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for (i = 0 ; i < vbat_writes_size; i++) {
-		TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
-					reg, mask, val);
-		old_val = snd_soc_read(codec, reg);
-		snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
-	}
-
-done:
-	return ret;
-}
-
-static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	wcd_vbat_adc_out_config(&tasha->vbat, codec);
-
-	ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
-	ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
-
-	dev_dbg(codec->dev,
-		"%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
-		__func__, ucontrol->value.integer.value[0],
-		ucontrol->value.integer.value[1]);
-
-	return 0;
-}
-
-static const char * const tasha_vbat_gsm_mode_text[] = {
-	"OFF", "ON"};
-
-static const struct soc_enum tasha_vbat_gsm_mode_enum =
-	SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
-
-static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	ucontrol->value.integer.value[0] =
-		((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
-		  1 : 0);
-
-	dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
-		ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
-		ucontrol->value.integer.value[0]);
-
-	/* Set Vbat register configuration for GSM mode bit based on value */
-	if (ucontrol->value.integer.value[0])
-		snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
-						0x04, 0x04);
-	else
-		snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
-						0x04, 0x00);
-
-	return 0;
-}
-
-static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
-				struct snd_kcontrol *kcontrol,
-				int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
-
-	vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
-	vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
-	vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
-
-	if (!strcmp(w->name, "RX INT8 VBAT"))
-		vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
-	else if (!strcmp(w->name, "RX INT7 VBAT"))
-		vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
-	else if (!strcmp(w->name, "RX INT6 VBAT"))
-		vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
-	else if (!strcmp(w->name, "RX INT5 VBAT"))
-		vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		ret = tasha_update_vbat_reg_config(codec);
-		if (ret) {
-			dev_dbg(codec->dev,
-				"%s : VBAT isn't calibrated, So not enabling it\n",
-				__func__);
-			return 0;
-		}
-		snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
-		snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
-		snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
-		snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
-		tasha->vbat.is_enabled = true;
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (tasha->vbat.is_enabled) {
-			snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
-			snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
-			snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
-			snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
-			tasha->vbat.is_enabled = false;
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static const char * const rx_hph_mode_mux_text[] = {
-	"CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
-};
-
-static const struct soc_enum rx_hph_mode_mux_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
-			    rx_hph_mode_mux_text);
-
-static const char * const amic_pwr_lvl_text[] = {
-	"LOW_PWR", "DEFAULT", "HIGH_PERF"
-};
-
-static const struct soc_enum amic_pwr_lvl_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
-			    amic_pwr_lvl_text);
-
-static const struct snd_kcontrol_new tasha_snd_controls[] = {
-	SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
-		0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
-			  WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
-			  WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
-			  WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
-			  WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
-			  WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
-			  WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
-			  WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
-			  WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
-			  WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-
-	SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
-					  -84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
-			  WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
-			  WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
-			  WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
-			  WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
-			  WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
-			  WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
-			  WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
-			  40, digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
-			  WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
-			  40, digital_gain),
-
-	SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
-		       tasha_put_anc_slot),
-	SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
-		     tasha_put_anc_func),
-
-	SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
-		     tasha_put_clkmode),
-
-	SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
-	SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
-	SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
-	SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
-	SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
-	SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
-	SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
-	SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
-	SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
-
-	SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
-	SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
-	SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
-	SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
-	SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
-	SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
-	SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
-	SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
-	SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
-	SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
-	SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
-	SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
-	SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
-	SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
-	SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
-	SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
-	SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
-	SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
-
-	SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-	SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
-	tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
-
-	SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
-	tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
-
-	SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-	SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
-		       tasha_get_compander, tasha_set_compander),
-
-	SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
-		       tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
-
-	SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
-		     tasha_mad_input_get, tasha_mad_input_put),
-	SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
-			tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
-
-	SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-
-	SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-
-	SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-
-	SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-
-	SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-
-	SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
-		       tasha_pinctl_mode_get, tasha_pinctl_mode_put),
-	SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
-		       tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
-	SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
-		       tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
-	SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
-		       tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
-
-	SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
-			tasha_vbat_adc_data_get, NULL),
-
-	SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
-			tasha_vbat_gsm_mode_func_get,
-			tasha_vbat_gsm_mode_func_put),
-};
-
-static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
-	u16 mic_sel_reg;
-	u8 mic_sel;
-
-	val = ucontrol->value.enumerated.item[0];
-	if (val > e->items - 1)
-		return -EINVAL;
-
-	dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
-		widget->name, val);
-
-	switch (e->reg) {
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
-		mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
-		mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
-		mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
-		mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
-		mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
-		mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
-		mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
-		mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
-		break;
-	case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
-		mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
-		break;
-	default:
-		dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
-			__func__, e->reg);
-		return -EINVAL;
-	}
-
-	/* ADC: 0, DMIC: 1 */
-	mic_sel = val ? 0x0 : 0x1;
-	snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
-
-	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
-}
-
-static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
-	unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
-
-	val = ucontrol->value.enumerated.item[0];
-	if (val >= e->items)
-		return -EINVAL;
-
-	dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
-		widget->name, val);
-
-	if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
-	else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
-	else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
-
-	/* Set Look Ahead Delay */
-	snd_soc_update_bits(codec, look_ahead_dly_reg,
-			    0x08, (val ? 0x08 : 0x00));
-	/* Set DEM INP Select */
-	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
-}
-
-static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
-
-	ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
-
-	ucontrol->value.integer.value[0] = ear_pa_gain;
-
-	dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
-		ear_pa_gain);
-
-	return 0;
-}
-
-static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0]  = %ld\n",
-			__func__, ucontrol->value.integer.value[0]);
-
-	ear_pa_gain =  ucontrol->value.integer.value[0] << 4;
-
-	snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
-	return 0;
-}
-
-static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
-
-	dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0]  = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	tasha->ear_spkr_gain =  ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
-				  int event)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int comp;
-	u16 comp_ctl0_reg, rx_path_cfg0_reg;
-
-	/* EAR does not have compander */
-	if (!interp_n)
-		return 0;
-
-	comp = interp_n - 1;
-	dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
-		__func__, event, comp + 1, tasha->comp_enabled[comp]);
-
-	if (!tasha->comp_enabled[comp])
-		return 0;
-
-	comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
-	rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
-
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		/* Enable Compander Clock */
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
-	}
-
-	return 0;
-}
-
-static int tasha_codec_config_mad(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	int idx;
-	const struct firmware *fw;
-	struct firmware_cal *hwdep_cal = NULL;
-	struct wcd_mad_audio_cal *mad_cal = NULL;
-	const void *data;
-	const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	size_t cal_size;
-
-	hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
-	if (hwdep_cal) {
-		data = hwdep_cal->data;
-		cal_size = hwdep_cal->size;
-		dev_dbg(codec->dev, "%s: using hwdep calibration\n",
-			__func__);
-	} else {
-		ret = request_firmware(&fw, filename, codec->dev);
-		if (ret || !fw) {
-			dev_err(codec->dev,
-				"%s: MAD firmware acquire failed, err = %d\n",
-				__func__, ret);
-			return -ENODEV;
-		}
-		data = fw->data;
-		cal_size = fw->size;
-		dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
-			__func__);
-	}
-
-	if (cal_size < sizeof(*mad_cal)) {
-		dev_err(codec->dev,
-			"%s: Incorrect size %zd for MAD Cal, expected %zd\n",
-			__func__, cal_size, sizeof(*mad_cal));
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	mad_cal = (struct wcd_mad_audio_cal *) (data);
-	if (!mad_cal) {
-		dev_err(codec->dev,
-			"%s: Invalid calibration data\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
-		      mad_cal->microphone_info.cycle_time);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
-			    ((uint16_t)mad_cal->microphone_info.settle_time)
-			    << 3);
-
-	/* Audio */
-	snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
-		      mad_cal->audio_info.rms_omit_samples);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
-			    0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
-			    mad_cal->audio_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
-		      mad_cal->audio_info.rms_diff_threshold & 0x3F);
-	snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
-		      mad_cal->audio_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
-		      mad_cal->audio_info.rms_threshold_msb);
-
-	for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
-	     idx++) {
-		snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
-				    0x3F, idx);
-		snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
-			      mad_cal->audio_info.iir_coefficients[idx]);
-		dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
-			__func__, idx,
-			mad_cal->audio_info.iir_coefficients[idx]);
-	}
-
-	/* Beacon */
-	snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
-		      mad_cal->beacon_info.rms_omit_samples);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
-			    0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
-			    mad_cal->beacon_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
-		      mad_cal->beacon_info.rms_diff_threshold & 0x1F);
-	snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
-		      mad_cal->beacon_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
-		      mad_cal->beacon_info.rms_threshold_msb);
-
-	for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
-	     idx++) {
-		snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
-				    0x3F, idx);
-		snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
-			      mad_cal->beacon_info.iir_coefficients[idx]);
-		dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
-			__func__, idx,
-			mad_cal->beacon_info.iir_coefficients[idx]);
-	}
-
-	/* Ultrasound */
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
-			    0x07 << 4,
-			    mad_cal->ultrasound_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
-			    mad_cal->ultrasound_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
-		      mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
-	snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
-		      mad_cal->ultrasound_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
-		      mad_cal->ultrasound_info.rms_threshold_msb);
-
-done:
-	if (!hwdep_cal)
-		release_firmware(fw);
-
-	return ret;
-}
-
-static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
-	struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-
-	dev_dbg(codec->dev,
-		"%s: event = %d\n", __func__, event);
-
-	/* Return if CPE INPUT is DEC1 */
-	if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
-		return ret;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-
-		/* Turn on MAD clk */
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
-				    0x01, 0x01);
-
-		/* Undo reset for MAD */
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
-				    0x02, 0x00);
-		ret = tasha_codec_config_mad(codec);
-		if (ret)
-			dev_err(codec->dev,
-				"%s: Failed to config MAD, err = %d\n",
-				__func__, ret);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* Reset the MAD block */
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
-				    0x02, 0x02);
-		/* Turn off MAD clk */
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
-				    0x01, 0x00);
-		break;
-	}
-
-	return ret;
-}
-
-static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
-	struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev,
-		"%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* Configure CPE input as DEC1 */
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
-				    0x01, 0x01);
-
-		/* Configure DEC1 Tx out with sample rate as 16K */
-		snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
-				    0x0F, 0x01);
-
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* Reset DEC1 Tx out sample rate */
-		snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
-				    0x0F, 0x04);
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
-				    0x01, 0x00);
-
-		break;
-	}
-
-	return 0;
-}
-
-
-static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-
-	if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	if (ucontrol->value.integer.value[0]) {
-		snd_soc_dapm_mixer_update_power(widget->dapm,
-						kcontrol, 1, update);
-		set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
-	} else {
-		snd_soc_dapm_mixer_update_power(widget->dapm,
-						kcontrol, 0, update);
-		clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
-	}
-
-	return 1;
-}
-
-static const char * const tasha_ear_pa_gain_text[] = {
-	"G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
-	"G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
-};
-
-static const char * const tasha_ear_spkr_pa_gain_text[] = {
-	"G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
-	"G_5_DB", "G_6_DB"
-};
-
-static const struct soc_enum tasha_ear_pa_gain_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
-			tasha_ear_pa_gain_text);
-
-static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
-			    tasha_ear_spkr_pa_gain_text);
-
-static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
-	SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
-		tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
-
-	SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
-		     tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
-
-	SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
-		line_gain),
-	SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
-		line_gain),
-	SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
-			3, 16, 1, line_gain),
-	SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
-			3, 16, 1, line_gain),
-	SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
-			line_gain),
-	SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
-			line_gain),
-
-	SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
-			analog_gain),
-	SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
-			analog_gain),
-	SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
-			analog_gain),
-	SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
-			analog_gain),
-	SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
-			analog_gain),
-	SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
-			analog_gain),
-};
-
-static const char * const spl_src0_mux_text[] = {
-	"ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
-};
-
-static const char * const spl_src1_mux_text[] = {
-	"ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
-};
-
-static const char * const spl_src2_mux_text[] = {
-	"ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
-};
-
-static const char * const spl_src3_mux_text[] = {
-	"ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
-};
-
-static const char * const rx_int0_7_mix_mux_text[] = {
-	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
-	"RX6", "RX7", "PROXIMITY"
-};
-
-static const char * const rx_int_mix_mux_text[] = {
-	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
-	"RX6", "RX7"
-};
-
-static const char * const rx_prim_mix_text[] = {
-	"ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
-	"RX3", "RX4", "RX5", "RX6", "RX7"
-};
-
-static const char * const rx_sidetone_mix_text[] = {
-	"ZERO", "SRC0", "SRC1", "SRC_SUM"
-};
-
-static const char * const sb_tx0_mux_text[] = {
-	"ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
-};
-
-static const char * const sb_tx1_mux_text[] = {
-	"ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
-};
-
-static const char * const sb_tx2_mux_text[] = {
-	"ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
-};
-
-static const char * const sb_tx3_mux_text[] = {
-	"ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
-};
-
-static const char * const sb_tx4_mux_text[] = {
-	"ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
-};
-
-static const char * const sb_tx5_mux_text[] = {
-	"ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
-};
-
-static const char * const sb_tx6_mux_text[] = {
-	"ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
-};
-
-static const char * const sb_tx7_mux_text[] = {
-	"ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
-};
-
-static const char * const sb_tx8_mux_text[] = {
-	"ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
-};
-
-static const char * const sb_tx9_mux_text[] = {
-	"ZERO", "DEC7", "DEC7_192"
-};
-
-static const char * const sb_tx10_mux_text[] = {
-	"ZERO", "DEC6", "DEC6_192"
-};
-
-static const char * const sb_tx11_mux_text[] = {
-	"DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
-};
-
-static const char * const sb_tx11_inp1_mux_text[] = {
-	"ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
-	"DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
-};
-
-static const char * const sb_tx13_mux_text[] = {
-	"ZERO", "DEC5", "DEC5_192"
-};
-
-static const char * const tx13_inp_mux_text[] = {
-	"CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
-};
-
-static const char * const iir_inp_mux_text[] = {
-	"ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
-	"DEC7", "DEC8",	"RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
-};
-
-static const char * const rx_int_dem_inp_mux_text[] = {
-	"NORMAL_DSM_OUT", "CLSH_DSM_OUT",
-};
-
-static const char * const rx_int0_interp_mux_text[] = {
-	"ZERO", "RX INT0 MIX2",
-};
-
-static const char * const rx_int1_interp_mux_text[] = {
-	"ZERO", "RX INT1 MIX2",
-};
-
-static const char * const rx_int2_interp_mux_text[] = {
-	"ZERO", "RX INT2 MIX2",
-};
-
-static const char * const rx_int3_interp_mux_text[] = {
-	"ZERO", "RX INT3 MIX2",
-};
-
-static const char * const rx_int4_interp_mux_text[] = {
-	"ZERO", "RX INT4 MIX2",
-};
-
-static const char * const rx_int5_interp_mux_text[] = {
-	"ZERO", "RX INT5 MIX2",
-};
-
-static const char * const rx_int6_interp_mux_text[] = {
-	"ZERO", "RX INT6 MIX2",
-};
-
-static const char * const rx_int7_interp_mux_text[] = {
-	"ZERO", "RX INT7 MIX2",
-};
-
-static const char * const rx_int8_interp_mux_text[] = {
-	"ZERO", "RX INT8 SEC MIX"
-};
-
-static const char * const mad_sel_text[] = {
-	"SPE", "MSM"
-};
-
-static const char * const adc_mux_text[] = {
-	"DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
-};
-
-static const char * const dmic_mux_text[] = {
-	"ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
-	"SMIC0", "SMIC1", "SMIC2", "SMIC3"
-};
-
-static const char * const dmic_mux_alt_text[] = {
-	"ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
-};
-
-static const char * const amic_mux_text[] = {
-	"ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
-};
-
-static const char * const rx_echo_mux_text[] = {
-	"ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
-	"RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
-	"RX_MIX_VBAT6",	"RX_MIX_VBAT7", "RX_MIX_VBAT8"
-};
-
-static const char * const anc0_fb_mux_text[] = {
-	"ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
-	"ANC_IN_LO1"
-};
-
-static const char * const anc1_fb_mux_text[] = {
-	"ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
-};
-
-static const char * const native_mux_text[] = {
-	"OFF", "ON",
-};
-
-static const struct soc_enum spl_src0_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
-			spl_src0_mux_text);
-
-static const struct soc_enum spl_src1_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
-			spl_src1_mux_text);
-
-static const struct soc_enum spl_src2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
-			spl_src2_mux_text);
-
-static const struct soc_enum spl_src3_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
-			spl_src3_mux_text);
-
-static const struct soc_enum rx_int0_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
-			rx_int0_7_mix_mux_text);
-
-static const struct soc_enum rx_int1_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int2_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int3_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int4_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int5_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int6_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum rx_int7_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
-			rx_int0_7_mix_mux_text);
-
-static const struct soc_enum rx_int8_2_mux_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
-			rx_int_mix_mux_text);
-
-static const struct soc_enum int1_1_native_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
-			native_mux_text);
-
-static const struct soc_enum int2_1_native_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
-			native_mux_text);
-
-static const struct soc_enum int3_1_native_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
-			native_mux_text);
-
-static const struct soc_enum int4_1_native_enum =
-	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
-			native_mux_text);
-
-static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
-			rx_prim_mix_text);
-
-static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
-			rx_sidetone_mix_text);
-
-static const struct soc_enum tx_adc_mux0_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux1_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux2_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux3_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux4_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux5_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux6_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux7_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux8_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux10_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux11_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux12_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_adc_mux13_chain_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
-			adc_mux_text);
-
-static const struct soc_enum tx_dmic_mux0_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
-			dmic_mux_text);
-
-static const struct soc_enum tx_dmic_mux1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
-			dmic_mux_text);
-
-static const struct soc_enum tx_dmic_mux2_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
-			dmic_mux_text);
-
-static const struct soc_enum tx_dmic_mux3_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
-			dmic_mux_text);
-
-static const struct soc_enum tx_dmic_mux4_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux5_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux6_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux7_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux8_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux10_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux11_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux12_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_dmic_mux13_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
-			dmic_mux_alt_text);
-
-static const struct soc_enum tx_amic_mux0_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux1_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux2_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux3_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux4_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux5_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux6_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux7_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux8_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux10_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux11_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux12_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum tx_amic_mux13_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
-			amic_mux_text);
-
-static const struct soc_enum sb_tx0_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
-			sb_tx0_mux_text);
-
-static const struct soc_enum sb_tx1_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
-			sb_tx1_mux_text);
-
-static const struct soc_enum sb_tx2_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
-			sb_tx2_mux_text);
-
-static const struct soc_enum sb_tx3_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
-			sb_tx3_mux_text);
-
-static const struct soc_enum sb_tx4_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
-			sb_tx4_mux_text);
-
-static const struct soc_enum sb_tx5_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
-			sb_tx5_mux_text);
-
-static const struct soc_enum sb_tx6_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
-			sb_tx6_mux_text);
-
-static const struct soc_enum sb_tx7_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
-			sb_tx7_mux_text);
-
-static const struct soc_enum sb_tx8_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
-			sb_tx8_mux_text);
-
-static const struct soc_enum sb_tx9_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
-			sb_tx9_mux_text);
-
-static const struct soc_enum sb_tx10_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
-			sb_tx10_mux_text);
-
-static const struct soc_enum sb_tx11_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
-			sb_tx11_mux_text);
-
-static const struct soc_enum sb_tx11_inp1_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
-			sb_tx11_inp1_mux_text);
-
-static const struct soc_enum sb_tx13_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
-			sb_tx13_mux_text);
-
-static const struct soc_enum tx13_inp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
-			tx13_inp_mux_text);
-
-static const struct soc_enum rx_mix_tx0_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx1_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx2_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx3_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx4_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx5_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx6_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx7_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum rx_mix_tx8_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
-			rx_echo_mux_text);
-
-static const struct soc_enum iir0_inp0_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir0_inp1_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir0_inp2_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir0_inp3_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir1_inp0_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir1_inp1_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir1_inp2_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum iir1_inp3_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
-			iir_inp_mux_text);
-
-static const struct soc_enum rx_int0_dem_inp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
-			ARRAY_SIZE(rx_int_dem_inp_mux_text),
-			rx_int_dem_inp_mux_text);
-
-static const struct soc_enum rx_int1_dem_inp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
-			ARRAY_SIZE(rx_int_dem_inp_mux_text),
-			rx_int_dem_inp_mux_text);
-
-static const struct soc_enum rx_int2_dem_inp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
-			ARRAY_SIZE(rx_int_dem_inp_mux_text),
-			rx_int_dem_inp_mux_text);
-
-static const struct soc_enum rx_int0_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
-			rx_int0_interp_mux_text);
-
-static const struct soc_enum rx_int1_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
-			rx_int1_interp_mux_text);
-
-static const struct soc_enum rx_int2_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
-			rx_int2_interp_mux_text);
-
-static const struct soc_enum rx_int3_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
-			rx_int3_interp_mux_text);
-
-static const struct soc_enum rx_int4_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
-			rx_int4_interp_mux_text);
-
-static const struct soc_enum rx_int5_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
-			rx_int5_interp_mux_text);
-
-static const struct soc_enum rx_int6_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
-			rx_int6_interp_mux_text);
-
-static const struct soc_enum rx_int7_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
-			rx_int7_interp_mux_text);
-
-static const struct soc_enum rx_int8_interp_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
-			rx_int8_interp_mux_text);
-
-static const struct soc_enum mad_sel_enum =
-	SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
-
-static const struct soc_enum anc0_fb_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
-			anc0_fb_mux_text);
-
-static const struct soc_enum anc1_fb_mux_enum =
-	SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
-			anc1_fb_mux_text);
-
-static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
-	SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_int_dem_inp_mux_put);
-
-static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
-	SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_int_dem_inp_mux_put);
-
-static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
-	SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_int_dem_inp_mux_put);
-
-static const struct snd_kcontrol_new spl_src0_mux =
-	SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
-
-static const struct snd_kcontrol_new spl_src1_mux =
-	SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
-
-static const struct snd_kcontrol_new spl_src2_mux =
-	SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
-
-static const struct snd_kcontrol_new spl_src3_mux =
-	SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int0_2_mux =
-	SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int1_2_mux =
-	SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int2_2_mux =
-	SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int3_2_mux =
-	SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int4_2_mux =
-	SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int5_2_mux =
-	SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int6_2_mux =
-	SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int7_2_mux =
-	SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new rx_int8_2_mux =
-	SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
-
-static const struct snd_kcontrol_new int1_1_native_mux =
-	SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
-
-static const struct snd_kcontrol_new int2_1_native_mux =
-	SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
-
-static const struct snd_kcontrol_new int3_1_native_mux =
-	SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
-
-static const struct snd_kcontrol_new int4_1_native_mux =
-	SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
-
-static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
-	SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
-
-static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
-	SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
-
-static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
-	SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
-
-static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
-	SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux0 =
-	SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux1 =
-	SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux2 =
-	SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux3 =
-	SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux4 =
-	SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux5 =
-	SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux6 =
-	SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux7 =
-	SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux8 =
-	SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
-			  snd_soc_dapm_get_enum_double,
-			  tasha_put_dec_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux10 =
-	SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux11 =
-	SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux12 =
-	SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
-
-static const struct snd_kcontrol_new tx_adc_mux13 =
-	SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux0 =
-	SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux1 =
-	SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux2 =
-	SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux3 =
-	SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux4 =
-	SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux5 =
-	SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux6 =
-	SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux7 =
-	SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux8 =
-	SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux10 =
-	SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux11 =
-	SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux12 =
-	SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
-
-static const struct snd_kcontrol_new tx_dmic_mux13 =
-	SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux0 =
-	SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux1 =
-	SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux2 =
-	SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux3 =
-	SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux4 =
-	SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux5 =
-	SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux6 =
-	SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux7 =
-	SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux8 =
-	SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux10 =
-	SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux11 =
-	SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux12 =
-	SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
-
-static const struct snd_kcontrol_new tx_amic_mux13 =
-	SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
-
-static const struct snd_kcontrol_new sb_tx0_mux =
-	SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx1_mux =
-	SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx2_mux =
-	SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx3_mux =
-	SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx4_mux =
-	SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx5_mux =
-	SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx6_mux =
-	SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx7_mux =
-	SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx8_mux =
-	SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx9_mux =
-	SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx10_mux =
-	SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx11_mux =
-	SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx11_inp1_mux =
-	SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
-
-static const struct snd_kcontrol_new sb_tx13_mux =
-	SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
-
-static const struct snd_kcontrol_new tx13_inp_mux =
-	SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx0_mux =
-	SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx1_mux =
-	SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx2_mux =
-	SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx3_mux =
-	SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx4_mux =
-	SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx5_mux =
-	SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx6_mux =
-	SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx7_mux =
-	SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
-
-static const struct snd_kcontrol_new rx_mix_tx8_mux =
-	SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
-
-static const struct snd_kcontrol_new iir0_inp0_mux =
-	SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
-
-static const struct snd_kcontrol_new iir0_inp1_mux =
-	SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
-
-static const struct snd_kcontrol_new iir0_inp2_mux =
-	SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
-
-static const struct snd_kcontrol_new iir0_inp3_mux =
-	SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
-
-static const struct snd_kcontrol_new iir1_inp0_mux =
-	SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
-
-static const struct snd_kcontrol_new iir1_inp1_mux =
-	SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
-
-static const struct snd_kcontrol_new iir1_inp2_mux =
-	SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
-
-static const struct snd_kcontrol_new iir1_inp3_mux =
-	SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
-
-static const struct snd_kcontrol_new rx_int0_interp_mux =
-	SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int1_interp_mux =
-	SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int2_interp_mux =
-	SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int3_interp_mux =
-	SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int4_interp_mux =
-	SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int5_interp_mux =
-	SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int6_interp_mux =
-	SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int7_interp_mux =
-	SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
-
-static const struct snd_kcontrol_new rx_int8_interp_mux =
-	SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
-
-static const struct snd_kcontrol_new mad_sel_mux =
-	SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
-
-static const struct snd_kcontrol_new aif4_mad_switch =
-	SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
-
-static const struct snd_kcontrol_new mad_brdcst_switch =
-	SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
-
-static const struct snd_kcontrol_new aif4_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-			0, 1, 0, tasha_codec_aif4_mixer_switch_get,
-			tasha_codec_aif4_mixer_switch_put);
-
-static const struct snd_kcontrol_new anc_hphl_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_hphr_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_ear_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_ear_spkr_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_lineout1_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_lineout2_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_spkr_pa_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux0_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux1_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux2_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux3_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux4_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux5_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux6_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux7_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux8_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc0_fb_mux =
-	SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
-
-static const struct snd_kcontrol_new anc1_fb_mux =
-	SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
-
-static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: event = %d name = %s\n",
-		__func__, event, w->name);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
-		snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
-				    0x08, 0x08);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
-				    0x08, 0x00);
-		snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
-		snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
-		break;
-	}
-
-	return 0;
-};
-
-static const char * const ec_buf_mux_text[] = {
-	"ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
-	"I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
-	"DEC1"
-};
-
-static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
-			    0, ec_buf_mux_text);
-
-static const struct snd_kcontrol_new ec_buf_mux =
-	SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
-
-static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
-	SND_SOC_DAPM_OUTPUT("EAR"),
-	SND_SOC_DAPM_OUTPUT("ANC EAR"),
-	SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
-				AIF1_PB, 0, tasha_codec_enable_slimrx,
-				SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-				SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
-				AIF2_PB, 0, tasha_codec_enable_slimrx,
-				SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-				SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
-				AIF3_PB, 0, tasha_codec_enable_slimrx,
-				SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-				SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
-				AIF4_PB, 0, tasha_codec_enable_slimrx,
-				SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-				SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
-			       SND_SOC_NOPM, AIF_MIX1_PB, 0,
-			       tasha_codec_enable_slimrx,
-			       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
-			       SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
-				&slim_rx_mux[TASHA_RX0]),
-	SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
-				&slim_rx_mux[TASHA_RX1]),
-	SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
-				&slim_rx_mux[TASHA_RX2]),
-	SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
-				&slim_rx_mux[TASHA_RX3]),
-	SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
-				&slim_rx_mux[TASHA_RX4]),
-	SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
-				&slim_rx_mux[TASHA_RX5]),
-	SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
-				&slim_rx_mux[TASHA_RX6]),
-	SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
-				&slim_rx_mux[TASHA_RX7]),
-
-	SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
-			 &spl_src0_mux, tasha_codec_enable_spline_resampler,
-			 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
-			 &spl_src1_mux, tasha_codec_enable_spline_resampler,
-			 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
-			 &spl_src2_mux, tasha_codec_enable_spline_resampler,
-			 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
-			 &spl_src3_mux, tasha_codec_enable_spline_resampler,
-			 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
-			5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
-			5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
-			5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
-			5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
-			5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
-			5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
-			5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
-			5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-	SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
-			5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
-			SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int0_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int0_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int0_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int1_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int1_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int1_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int2_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int2_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int2_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int3_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int3_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int3_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int4_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int4_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int4_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int5_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int5_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int5_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int6_1_mix_inp0_mux),
-	SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int6_1_mix_inp1_mux),
-	SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int6_1_mix_inp2_mux),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int1_spline_mix_switch,
-			ARRAY_SIZE(rx_int1_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int2_spline_mix_switch,
-			ARRAY_SIZE(rx_int2_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int3_spline_mix_switch,
-			ARRAY_SIZE(rx_int3_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int4_spline_mix_switch,
-			ARRAY_SIZE(rx_int4_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int5_spline_mix_switch,
-			ARRAY_SIZE(rx_int5_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int6_spline_mix_switch,
-			ARRAY_SIZE(rx_int6_spline_mix_switch)),
-	SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int7_spline_mix_switch,
-			ARRAY_SIZE(rx_int7_spline_mix_switch)),
-
-	SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
-			rx_int8_spline_mix_switch,
-			ARRAY_SIZE(rx_int8_spline_mix_switch)),
-
-	SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
-			NULL, 0, tasha_codec_spk_boost_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
-			NULL, 0, tasha_codec_spk_boost_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
-			rx_int5_vbat_mix_switch,
-			ARRAY_SIZE(rx_int5_vbat_mix_switch),
-			tasha_codec_vbat_enable_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
-			rx_int6_vbat_mix_switch,
-			ARRAY_SIZE(rx_int6_vbat_mix_switch),
-			tasha_codec_vbat_enable_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
-			rx_int7_vbat_mix_switch,
-			ARRAY_SIZE(rx_int7_vbat_mix_switch),
-			tasha_codec_vbat_enable_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
-			rx_int8_vbat_mix_switch,
-			ARRAY_SIZE(rx_int8_vbat_mix_switch),
-			tasha_codec_vbat_enable_event,
-			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
-			   0, &rx_int0_mix2_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
-			   0, &rx_int1_mix2_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
-			   0, &rx_int2_mix2_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
-			   0, &rx_int3_mix2_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
-			   0, &rx_int4_mix2_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
-			   0, &rx_int7_mix2_inp_mux),
-
-	SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
-		&sb_tx0_mux),
-	SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
-		&sb_tx1_mux),
-	SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
-		&sb_tx2_mux),
-	SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
-		&sb_tx3_mux),
-	SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
-		&sb_tx4_mux),
-	SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
-		&sb_tx5_mux),
-	SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
-		&sb_tx6_mux),
-	SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
-		&sb_tx7_mux),
-	SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
-		&sb_tx8_mux),
-	SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
-		&sb_tx9_mux),
-	SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
-		&sb_tx10_mux),
-	SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
-		&sb_tx11_mux),
-	SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
-		&sb_tx11_inp1_mux),
-	SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
-		&sb_tx13_mux),
-	SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
-			 &tx13_inp_mux),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux0, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux1, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux2, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux3, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux4, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux5, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux6, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux7, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
-			   &tx_adc_mux8, tasha_codec_enable_dec,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
-			 &tx_adc_mux10, tasha_codec_tx_adc_cfg,
-			 SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
-			 &tx_adc_mux11, tasha_codec_tx_adc_cfg,
-			 SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
-			 &tx_adc_mux12, tasha_codec_tx_adc_cfg,
-			 SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
-			 &tx_adc_mux13, tasha_codec_tx_adc_cfg,
-			 SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux0),
-	SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux1),
-	SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux2),
-	SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux3),
-	SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux4),
-	SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux5),
-	SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux6),
-	SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux7),
-	SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux8),
-	SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux10),
-	SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux11),
-	SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux12),
-	SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
-		&tx_dmic_mux13),
-
-	SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux0),
-	SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux1),
-	SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux2),
-	SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux3),
-	SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux4),
-	SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux5),
-	SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux6),
-	SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux7),
-	SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux8),
-	SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux10),
-	SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux11),
-	SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux12),
-	SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
-		&tx_amic_mux13),
-
-	SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
-			   tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-
-	SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
-			    INTERP_HPHL, 0, tasha_enable_native_supply,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
-			    INTERP_HPHR, 0, tasha_enable_native_supply,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
-			    INTERP_LO1, 0, tasha_enable_native_supply,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
-			    INTERP_LO2, 0, tasha_enable_native_supply,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_INPUT("AMIC1"),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
-			       tasha_codec_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			       SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
-			       tasha_codec_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			       SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
-			       tasha_codec_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			       SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
-			       tasha_codec_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			       SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
-			       tasha_codec_force_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
-			       tasha_codec_force_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
-			       tasha_codec_force_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
-			       tasha_codec_force_enable_micbias,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
-			    tasha_codec_force_enable_ldo_h,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
-	SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
-
-	SND_SOC_DAPM_INPUT("AMIC2"),
-	SND_SOC_DAPM_INPUT("AMIC3"),
-	SND_SOC_DAPM_INPUT("AMIC4"),
-	SND_SOC_DAPM_INPUT("AMIC5"),
-	SND_SOC_DAPM_INPUT("AMIC6"),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
-		AIF1_CAP, 0, tasha_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
-		AIF2_CAP, 0, tasha_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
-		AIF3_CAP, 0, tasha_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
-		AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
-		aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
-
-	SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
-		aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
-
-	SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
-		aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
-
-	SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
-		aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
-
-	SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
-		aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
-
-	SND_SOC_DAPM_INPUT("VIINPUT"),
-
-	SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
-			     AIF5_CPE_TX, 0),
-
-	SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
-		tasha_codec_ec_buf_mux_enable,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	/* Digital Mic Inputs */
-	SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
-	SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
-	SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
-	SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
-	SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
-	SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
-	SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
-	SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
-
-	SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
-			     4, 0, NULL, 0, tasha_codec_set_iir_gain,
-			     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
-			     4, 0, NULL, 0, tasha_codec_set_iir_gain,
-			     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
-			     4, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
-			     4, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
-				cpe_in_mix_switch,
-				ARRAY_SIZE(cpe_in_mix_switch),
-				tasha_codec_configure_cpe_input,
-				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
-		&int1_1_native_mux),
-	SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
-		&int2_1_native_mux),
-	SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
-		&int3_1_native_mux),
-	SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
-		&int4_1_native_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx0_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx1_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx2_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx3_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx4_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx5_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx6_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx7_mux),
-	SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
-		&rx_mix_tx8_mux),
-
-	SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
-		&rx_int0_dem_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
-		&rx_int1_dem_inp_mux),
-	SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
-		&rx_int2_dem_inp_mux),
-
-	SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
-		INTERP_EAR, 0, &rx_int0_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
-		INTERP_HPHL, 0, &rx_int1_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
-		INTERP_HPHR, 0, &rx_int2_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
-		INTERP_LO1, 0, &rx_int3_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
-		INTERP_LO2, 0, &rx_int4_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
-		INTERP_LO3, 0, &rx_int5_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
-		INTERP_LO4, 0, &rx_int6_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
-		INTERP_SPKR1, 0, &rx_int7_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
-		INTERP_SPKR2, 0, &rx_int8_interp_mux,
-		tasha_codec_enable_interpolator,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tasha_codec_ear_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD9335_ANA_HPH,
-		5, 0, tasha_codec_hphl_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD9335_ANA_HPH,
-		4, 0, tasha_codec_hphr_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tasha_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tasha_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tasha_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tasha_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHL PA", WCD9335_ANA_HPH, 7, 0, NULL, 0,
-			   tasha_codec_enable_hphl_pa,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHR PA", WCD9335_ANA_HPH, 6, 0, NULL, 0,
-			   tasha_codec_enable_hphr_pa,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
-			   tasha_codec_enable_ear_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
-			   tasha_codec_enable_lineout_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
-			   tasha_codec_enable_lineout_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
-			   tasha_codec_enable_lineout_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
-			   tasha_codec_enable_lineout_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
-			   tasha_codec_enable_ear_pa,
-			   SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-			   tasha_codec_enable_hphl_pa,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-			   tasha_codec_enable_hphr_pa,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-			   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
-				7, 0, NULL, 0,
-				tasha_codec_enable_lineout_pa,
-				SND_SOC_DAPM_POST_PMU |
-				SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
-				6, 0, NULL, 0,
-				tasha_codec_enable_lineout_pa,
-				SND_SOC_DAPM_POST_PMU |
-				SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-			   tasha_codec_enable_spk_anc,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_OUTPUT("HPHL"),
-	SND_SOC_DAPM_OUTPUT("HPHR"),
-	SND_SOC_DAPM_OUTPUT("ANC HPHL"),
-	SND_SOC_DAPM_OUTPUT("ANC HPHR"),
-	SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
-		tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
-	SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT1"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT2"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT3"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT4"),
-	SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
-	SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
-	SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
-		ON_DEMAND_MICBIAS, 0,
-		tasha_codec_enable_on_demand_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux0_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux1_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux2_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux3_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux4_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux5_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux6_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux7_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
-			    0, &adc_us_mux8_switch),
-	/* MAD related widgets */
-	SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
-			       SND_SOC_NOPM, 0, 0,
-			       tasha_codec_enable_mad,
-			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
-			 &mad_sel_mux),
-	SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
-	SND_SOC_DAPM_INPUT("MADINPUT"),
-	SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
-			    &aif4_mad_switch),
-	SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
-			    &mad_brdcst_switch),
-	SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
-			    &aif4_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
-			&anc_hphl_switch),
-	SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
-			&anc_hphr_switch),
-	SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
-			&anc_ear_switch),
-	SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
-			    &anc_ear_spkr_switch),
-	SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
-			&anc_lineout1_switch),
-	SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
-			&anc_lineout2_switch),
-	SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
-			    &anc_spkr_pa_switch),
-};
-
-static int tasha_get_channel_map(struct snd_soc_dai *dai,
-				 unsigned int *tx_num, unsigned int *tx_slot,
-				 unsigned int *rx_num, unsigned int *rx_slot)
-{
-	struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
-	u32 i = 0;
-	struct wcd9xxx_ch *ch;
-
-	switch (dai->id) {
-	case AIF1_PB:
-	case AIF2_PB:
-	case AIF3_PB:
-	case AIF4_PB:
-	case AIF_MIX1_PB:
-		if (!rx_slot || !rx_num) {
-			pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
-				 __func__, rx_slot, rx_num);
-			return -EINVAL;
-		}
-		list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
-				    list) {
-			pr_debug("%s: slot_num %u ch->ch_num %d\n",
-				 __func__, i, ch->ch_num);
-			rx_slot[i++] = ch->ch_num;
-		}
-		pr_debug("%s: rx_num %d\n", __func__, i);
-		*rx_num = i;
-		break;
-	case AIF1_CAP:
-	case AIF2_CAP:
-	case AIF3_CAP:
-	case AIF4_MAD_TX:
-	case AIF4_VIFEED:
-		if (!tx_slot || !tx_num) {
-			pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
-				 __func__, tx_slot, tx_num);
-			return -EINVAL;
-		}
-		list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
-				    list) {
-			pr_debug("%s: slot_num %u ch->ch_num %d\n",
-				 __func__, i,  ch->ch_num);
-			tx_slot[i++] = ch->ch_num;
-		}
-		pr_debug("%s: tx_num %d\n", __func__, i);
-		*tx_num = i;
-		break;
-
-	default:
-		pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
-		break;
-	}
-
-	return 0;
-}
-
-static int tasha_set_channel_map(struct snd_soc_dai *dai,
-				 unsigned int tx_num, unsigned int *tx_slot,
-				 unsigned int rx_num, unsigned int *rx_slot)
-{
-	struct tasha_priv *tasha;
-	struct wcd9xxx *core;
-	struct wcd9xxx_codec_dai_data *dai_data = NULL;
-
-	if (!dai) {
-		pr_err("%s: dai is empty\n", __func__);
-		return -EINVAL;
-	}
-	tasha = snd_soc_codec_get_drvdata(dai->codec);
-	core = dev_get_drvdata(dai->codec->dev->parent);
-
-	if (!tx_slot || !rx_slot) {
-		pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
-			__func__, tx_slot, rx_slot);
-		return -EINVAL;
-	}
-	pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
-		 "tasha->intf_type %d\n",
-		 __func__, dai->name, dai->id, tx_num, rx_num,
-		 tasha->intf_type);
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		wcd9xxx_init_slimslave(core, core->slim->laddr,
-					   tx_num, tx_slot, rx_num, rx_slot);
-		/* Reserve TX12/TX13 for MAD data channel */
-		dai_data = &tasha->dai[AIF4_MAD_TX];
-		if (dai_data) {
-			if (TASHA_IS_2_0(tasha->wcd9xxx))
-				list_add_tail(&core->tx_chs[TASHA_TX13].list,
-					      &dai_data->wcd9xxx_ch_list);
-			else
-				list_add_tail(&core->tx_chs[TASHA_TX12].list,
-					      &dai_data->wcd9xxx_ch_list);
-		}
-	}
-	return 0;
-}
-
-static int tasha_startup(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	return 0;
-}
-
-static void tasha_shutdown(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
-		return;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		tasha_codec_vote_max_bw(dai->codec, false);
-}
-
-static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
-				    u8 tx_fs_rate_reg_val, u32 sample_rate)
-{
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u32 tx_port = 0;
-	u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
-	int decimator = -1;
-	u16 tx_port_reg = 0, tx_fs_reg = 0;
-
-	list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
-		tx_port = ch->port;
-		dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
-			__func__, dai->id, tx_port);
-
-		if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
-			dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
-				__func__, tx_port, dai->id);
-			return -EINVAL;
-		}
-		/* Find the SB TX MUX input - which decimator is connected */
-		if (tx_port < 4) {
-			tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
-			shift = (tx_port << 1);
-			shift_val = 0x03;
-		} else if ((tx_port >= 4) && (tx_port < 8)) {
-			tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
-			shift = ((tx_port - 4) << 1);
-			shift_val = 0x03;
-		} else if ((tx_port >= 8) && (tx_port < 11)) {
-			tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
-			shift = ((tx_port - 8) << 1);
-			shift_val = 0x03;
-		} else if (tx_port == 11) {
-			tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
-			shift = 0;
-			shift_val = 0x0F;
-		} else if (tx_port == 13) {
-			tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
-			shift = 4;
-			shift_val = 0x03;
-		}
-		tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
-					  (shift_val << shift);
-		tx_mux_sel = tx_mux_sel >> shift;
-
-		if (tx_port <= 8) {
-			if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
-				decimator = tx_port;
-		} else if (tx_port <= 10) {
-			if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
-				decimator = ((tx_port == 9) ? 7 : 6);
-		} else if (tx_port == 11) {
-			if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
-				decimator = tx_mux_sel - 1;
-		} else if (tx_port == 13) {
-			if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
-				decimator = 5;
-		}
-
-		if (decimator >= 0) {
-			tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
-				    16 * decimator;
-			dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
-				__func__, decimator, tx_port, sample_rate);
-			snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
-					    tx_fs_rate_reg_val);
-		} else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
-			/* Check if the TX Mux input is RX MIX TXn */
-			dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
-					__func__, tx_port, tx_port);
-		} else {
-			dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
-				__func__, decimator);
-			return -EINVAL;
-		}
-	}
-	return 0;
-}
-
-static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
-					   u8 int_mix_fs_rate_reg_val,
-					   u32 sample_rate)
-{
-	u8 int_2_inp;
-	u32 j;
-	u16 int_mux_cfg1, int_fs_reg;
-	u8 int_mux_cfg1_val;
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
-		int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
-				  TASHA_RX_PORT_START_NUMBER;
-		if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
-		   (int_2_inp > INTn_2_INP_SEL_RX7)) {
-			pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
-				__func__,
-				(ch->port - TASHA_RX_PORT_START_NUMBER),
-				dai->id);
-			return -EINVAL;
-		}
-
-		int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
-		for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
-			int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
-						0x0F;
-			if (int_mux_cfg1_val == int_2_inp) {
-				int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
-						20 * j;
-				pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
-					  __func__, dai->id, j);
-				pr_debug("%s: set INT%u_2 sample rate to %u\n",
-					__func__, j, sample_rate);
-				snd_soc_update_bits(codec, int_fs_reg,
-						0x0F, int_mix_fs_rate_reg_val);
-			}
-			int_mux_cfg1 += 2;
-		}
-	}
-	return 0;
-}
-
-static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
-					    u8 int_prim_fs_rate_reg_val,
-					    u32 sample_rate)
-{
-	u8 int_1_mix1_inp;
-	u32 j;
-	u16 int_mux_cfg0, int_mux_cfg1;
-	u16 int_fs_reg;
-	u8 int_mux_cfg0_val, int_mux_cfg1_val;
-	u8 inp0_sel, inp1_sel, inp2_sel;
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
-		int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
-				  TASHA_RX_PORT_START_NUMBER;
-		if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
-		   (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
-			pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
-				__func__,
-				(ch->port - TASHA_RX_PORT_START_NUMBER),
-				dai->id);
-			return -EINVAL;
-		}
-
-		int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
-
-		/*
-		 * Loop through all interpolator MUX inputs and find out
-		 * to which interpolator input, the slim rx port
-		 * is connected
-		 */
-		for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
-			int_mux_cfg1 = int_mux_cfg0 + 1;
-
-			int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
-			int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
-			inp0_sel = int_mux_cfg0_val & 0x0F;
-			inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
-			inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
-			if ((inp0_sel == int_1_mix1_inp) ||
-			    (inp1_sel == int_1_mix1_inp) ||
-			    (inp2_sel == int_1_mix1_inp)) {
-				int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
-					     20 * j;
-				pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
-					  __func__, dai->id, j);
-				pr_debug("%s: set INT%u_1 sample rate to %u\n",
-					__func__, j, sample_rate);
-				/* sample_rate is in Hz */
-				if ((j == 0) && (sample_rate == 44100)) {
-					pr_info("%s: Cannot set 44.1KHz on INT0\n",
-						__func__);
-				} else
-					snd_soc_update_bits(codec, int_fs_reg,
-						0x0F, int_prim_fs_rate_reg_val);
-			}
-			int_mux_cfg0 += 2;
-		}
-	}
-
-	return 0;
-}
-
-
-static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
-				       u32 sample_rate)
-{
-	int rate_val = 0;
-	int i, ret;
-
-	/* set mixing path rate */
-	for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
-		if (sample_rate ==
-				int_mix_sample_rate_val[i].sample_rate) {
-			rate_val =
-				int_mix_sample_rate_val[i].rate_val;
-			break;
-		}
-	}
-	if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
-			(rate_val < 0))
-		goto prim_rate;
-	ret = tasha_set_mix_interpolator_rate(dai,
-			(u8) rate_val, sample_rate);
-prim_rate:
-	/* set primary path sample rate */
-	for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
-		if (sample_rate ==
-				int_prim_sample_rate_val[i].sample_rate) {
-			rate_val =
-				int_prim_sample_rate_val[i].rate_val;
-			break;
-		}
-	}
-	if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
-			(rate_val < 0))
-		return -EINVAL;
-	ret = tasha_set_prim_interpolator_rate(dai,
-			(u8) rate_val, sample_rate);
-	return ret;
-}
-
-static int tasha_prepare(struct snd_pcm_substream *substream,
-			 struct snd_soc_dai *dai)
-{
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		tasha_codec_vote_max_bw(dai->codec, false);
-	return 0;
-}
-
-static int tasha_hw_params(struct snd_pcm_substream *substream,
-			   struct snd_pcm_hw_params *params,
-			   struct snd_soc_dai *dai)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
-	int ret;
-	int tx_fs_rate = -EINVAL;
-	int rx_fs_rate = -EINVAL;
-	int i2s_bit_mode;
-	struct snd_soc_codec *codec = dai->codec;
-
-	pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
-		 dai->name, dai->id, params_rate(params),
-		 params_channels(params));
-
-	switch (substream->stream) {
-	case SNDRV_PCM_STREAM_PLAYBACK:
-		ret = tasha_set_interpolator_rate(dai, params_rate(params));
-		if (ret) {
-			pr_err("%s: cannot set sample rate: %u\n",
-				__func__, params_rate(params));
-			return ret;
-		}
-		switch (params_width(params)) {
-		case 16:
-			tasha->dai[dai->id].bit_width = 16;
-			i2s_bit_mode = 0x01;
-			break;
-		case 24:
-			tasha->dai[dai->id].bit_width = 24;
-			i2s_bit_mode = 0x00;
-			break;
-		default:
-			return -EINVAL;
-		}
-		tasha->dai[dai->id].rate = params_rate(params);
-		if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-			switch (params_rate(params)) {
-			case 8000:
-				rx_fs_rate = 0;
-				break;
-			case 16000:
-				rx_fs_rate = 1;
-				break;
-			case 32000:
-				rx_fs_rate = 2;
-				break;
-			case 48000:
-				rx_fs_rate = 3;
-				break;
-			case 96000:
-				rx_fs_rate = 4;
-				break;
-			case 192000:
-				rx_fs_rate = 5;
-				break;
-			default:
-				dev_err(tasha->dev,
-				"%s: Invalid RX sample rate: %d\n",
-				__func__, params_rate(params));
-				return -EINVAL;
-			};
-			snd_soc_update_bits(codec,
-					WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
-					0x20, i2s_bit_mode << 5);
-			snd_soc_update_bits(codec,
-					WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
-					0x1c, (rx_fs_rate << 2));
-		}
-		break;
-	case SNDRV_PCM_STREAM_CAPTURE:
-		switch (params_rate(params)) {
-		case 8000:
-			tx_fs_rate = 0;
-			break;
-		case 16000:
-			tx_fs_rate = 1;
-			break;
-		case 32000:
-			tx_fs_rate = 3;
-			break;
-		case 48000:
-			tx_fs_rate = 4;
-			break;
-		case 96000:
-			tx_fs_rate = 5;
-			break;
-		case 192000:
-			tx_fs_rate = 6;
-			break;
-		case 384000:
-			tx_fs_rate = 7;
-			break;
-		default:
-			dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
-				__func__, params_rate(params));
-			return -EINVAL;
-
-		};
-		if (dai->id != AIF4_VIFEED &&
-		    dai->id != AIF4_MAD_TX) {
-			ret = tasha_set_decimator_rate(dai, tx_fs_rate,
-					params_rate(params));
-			if (ret < 0) {
-				dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
-					__func__, tx_fs_rate);
-				return ret;
-			}
-		}
-		tasha->dai[dai->id].rate = params_rate(params);
-		switch (params_width(params)) {
-		case 16:
-			tasha->dai[dai->id].bit_width = 16;
-			i2s_bit_mode = 0x01;
-			break;
-		case 24:
-			tasha->dai[dai->id].bit_width = 24;
-			i2s_bit_mode = 0x00;
-			break;
-		case 32:
-			tasha->dai[dai->id].bit_width = 32;
-			i2s_bit_mode = 0x00;
-			break;
-		default:
-			dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
-				__func__, params_width(params));
-			return -EINVAL;
-		};
-		if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
-				0x20, i2s_bit_mode << 5);
-			if (tx_fs_rate > 1)
-				tx_fs_rate--;
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
-				0x1c, tx_fs_rate << 2);
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
-				0x05, 0x05);
-
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
-				0x05, 0x05);
-
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
-				0x05, 0x05);
-
-			snd_soc_update_bits(codec,
-				WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
-				0x05, 0x05);
-		}
-		break;
-	default:
-		pr_err("%s: Invalid stream type %d\n", __func__,
-			substream->stream);
-		return -EINVAL;
-	};
-	if (dai->id == AIF4_VIFEED)
-		tasha->dai[dai->id].bit_width = 32;
-
-	return 0;
-}
-
-static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
-
-	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBS_CFS:
-		/* CPU is master */
-		if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-			if (dai->id == AIF1_CAP)
-				snd_soc_update_bits(dai->codec,
-					WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
-					0x2, 0);
-			else if (dai->id == AIF1_PB)
-				snd_soc_update_bits(dai->codec,
-					WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
-					0x2, 0);
-		}
-		break;
-	case SND_SOC_DAIFMT_CBM_CFM:
-		/* CPU is slave */
-		if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-			if (dai->id == AIF1_CAP)
-				snd_soc_update_bits(dai->codec,
-					WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
-					0x2, 0x2);
-			else if (dai->id == AIF1_PB)
-				snd_soc_update_bits(dai->codec,
-					WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
-					0x2, 0x2);
-		}
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
-		int clk_id, unsigned int freq, int dir)
-{
-	pr_debug("%s\n", __func__);
-	return 0;
-}
-
-static struct snd_soc_dai_ops tasha_dai_ops = {
-	.startup = tasha_startup,
-	.shutdown = tasha_shutdown,
-	.hw_params = tasha_hw_params,
-	.prepare = tasha_prepare,
-	.set_sysclk = tasha_set_dai_sysclk,
-	.set_fmt = tasha_set_dai_fmt,
-	.set_channel_map = tasha_set_channel_map,
-	.get_channel_map = tasha_get_channel_map,
-};
-
-static struct snd_soc_dai_driver tasha_dai[] = {
-	{
-		.name = "tasha_rx1",
-		.id = AIF1_PB,
-		.playback = {
-			.stream_name = "AIF1 Playback",
-			.rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_tx1",
-		.id = AIF1_CAP,
-		.capture = {
-			.stream_name = "AIF1 Capture",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_rx2",
-		.id = AIF2_PB,
-		.playback = {
-			.stream_name = "AIF2 Playback",
-			.rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_tx2",
-		.id = AIF2_CAP,
-		.capture = {
-			.stream_name = "AIF2 Capture",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 8,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_rx3",
-		.id = AIF3_PB,
-		.playback = {
-			.stream_name = "AIF3 Playback",
-			.rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_tx3",
-		.id = AIF3_CAP,
-		.capture = {
-			.stream_name = "AIF3 Capture",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 48000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_rx4",
-		.id = AIF4_PB,
-		.playback = {
-			.stream_name = "AIF4 Playback",
-			.rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_mix_rx1",
-		.id = AIF_MIX1_PB,
-		.playback = {
-			.stream_name = "AIF Mix Playback",
-			.rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 8,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_mad1",
-		.id = AIF4_MAD_TX,
-		.capture = {
-			.stream_name = "AIF4 MAD TX",
-			.rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
-				 SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
-			.formats = TASHA_FORMATS_S16_S24_S32_LE,
-			.rate_min = 16000,
-			.rate_max = 384000,
-			.channels_min = 1,
-			.channels_max = 1,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_vifeedback",
-		.id = AIF4_VIFEED,
-		.capture = {
-			.stream_name = "VIfeed",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
-			.formats = TASHA_FORMATS_S16_S24_S32_LE,
-			.rate_max = 48000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		 },
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_cpe",
-		.id = AIF5_CPE_TX,
-		.capture = {
-			.stream_name = "AIF5 CPE TX",
-			.rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
-			.formats = TASHA_FORMATS_S16_S24_S32_LE,
-			.rate_min = 16000,
-			.rate_max = 48000,
-			.channels_min = 1,
-			.channels_max = 1,
-		},
-	},
-};
-
-static struct snd_soc_dai_driver tasha_i2s_dai[] = {
-	{
-		.name = "tasha_i2s_rx1",
-		.id = AIF1_PB,
-		.playback = {
-			.stream_name = "AIF1 Playback",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_i2s_tx1",
-		.id = AIF1_CAP,
-		.capture = {
-			.stream_name = "AIF1 Capture",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_i2s_rx2",
-		.id = AIF2_PB,
-		.playback = {
-			.stream_name = "AIF2 Playback",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tasha_dai_ops,
-	},
-	{
-		.name = "tasha_i2s_tx2",
-		.id = AIF2_CAP,
-		.capture = {
-			.stream_name = "AIF2 Capture",
-			.rates = WCD9335_RATES_MASK,
-			.formats = TASHA_FORMATS_S16_S24_LE,
-			.rate_max = 192000,
-			.rate_min = 8000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tasha_dai_ops,
-	},
-};
-
-static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
-{
-	struct snd_soc_codec *codec = tasha->codec;
-
-	if (!codec)
-		return;
-
-	mutex_lock(&tasha->power_lock);
-	dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
-		__func__, tasha->power_active_ref);
-
-	if (tasha->power_active_ref > 0)
-		goto exit;
-
-	wcd9xxx_set_power_state(tasha->wcd9xxx,
-			WCD_REGION_POWER_COLLAPSE_BEGIN,
-			WCD9XXX_DIG_CORE_REGION_1);
-	snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			0x04, 0x04);
-	snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			0x01, 0x00);
-	snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
-			0x02, 0x00);
-	clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
-	tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
-	wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
-				WCD9XXX_DIG_CORE_REGION_1);
-exit:
-	dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
-		__func__, tasha->power_active_ref);
-	mutex_unlock(&tasha->power_lock);
-}
-
-static void tasha_codec_power_gate_work(struct work_struct *work)
-{
-	struct tasha_priv *tasha;
-	struct delayed_work *dwork;
-	struct snd_soc_codec *codec;
-
-	dwork = to_delayed_work(work);
-	tasha = container_of(dwork, struct tasha_priv, power_gate_work);
-	codec = tasha->codec;
-
-	if (!codec)
-		return;
-
-	tasha_codec_power_gate_digital_core(tasha);
-}
-
-/* called under power_lock acquisition */
-static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	tasha_codec_vote_max_bw(codec, true);
-	snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
-	snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
-	snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
-	snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
-	snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
-
-	wcd9xxx_set_power_state(tasha->wcd9xxx,
-			WCD_REGION_POWER_COLLAPSE_REMOVE,
-			WCD9XXX_DIG_CORE_REGION_1);
-	regcache_mark_dirty(codec->component.regmap);
-	regcache_sync_region(codec->component.regmap,
-			     TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
-	tasha_codec_vote_max_bw(codec, false);
-
-	return 0;
-}
-
-static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
-					 int req_state)
-{
-	struct snd_soc_codec *codec;
-	int cur_state;
-
-	/* Exit if feature is disabled */
-	if (!dig_core_collapse_enable)
-		return 0;
-
-	mutex_lock(&tasha->power_lock);
-	if (req_state == POWER_COLLAPSE)
-		tasha->power_active_ref--;
-	else if (req_state == POWER_RESUME)
-		tasha->power_active_ref++;
-	else
-		goto unlock_mutex;
-
-	if (tasha->power_active_ref < 0) {
-		dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
-			__func__);
-		goto unlock_mutex;
-	}
-
-	codec = tasha->codec;
-	if (!codec)
-		goto unlock_mutex;
-
-	if (req_state == POWER_COLLAPSE) {
-		if (tasha->power_active_ref == 0) {
-			schedule_delayed_work(&tasha->power_gate_work,
-			msecs_to_jiffies(dig_core_collapse_timer * 1000));
-		}
-	} else if (req_state == POWER_RESUME) {
-		if (tasha->power_active_ref == 1) {
-			/*
-			 * At this point, there can be two cases:
-			 * 1. Core already in power collapse state
-			 * 2. Timer kicked in and still did not expire or
-			 * waiting for the power_lock
-			 */
-			cur_state = wcd9xxx_get_current_power_state(
-						tasha->wcd9xxx,
-						WCD9XXX_DIG_CORE_REGION_1);
-			if (cur_state == WCD_REGION_POWER_DOWN)
-				tasha_dig_core_remove_power_collapse(codec);
-			else {
-				mutex_unlock(&tasha->power_lock);
-				cancel_delayed_work_sync(
-						&tasha->power_gate_work);
-				mutex_lock(&tasha->power_lock);
-			}
-		}
-	}
-
-unlock_mutex:
-	mutex_unlock(&tasha->power_lock);
-
-	return 0;
-}
-
-static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
-					  bool enable)
-{
-	int ret = 0;
-
-	if (!tasha->wcd_ext_clk) {
-		dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
-
-	if (enable) {
-		tasha_dig_core_power_collapse(tasha, POWER_RESUME);
-		ret = tasha_cdc_req_mclk_enable(tasha, true);
-		if (ret)
-			goto err;
-
-		set_bit(AUDIO_NOMINAL, &tasha->status_mask);
-		tasha_codec_apply_sido_voltage(tasha,
-				SIDO_VOLTAGE_NOMINAL_MV);
-	} else {
-		if (!dig_core_collapse_enable) {
-			clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
-			tasha_codec_update_sido_voltage(tasha,
-						sido_buck_svs_voltage);
-		}
-		tasha_cdc_req_mclk_enable(tasha, false);
-		tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
-	}
-
-err:
-	return ret;
-}
-
-static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
-				   bool enable)
-{
-	int ret;
-
-	WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
-	ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
-	WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
-
-	return ret;
-}
-
-int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	return __tasha_cdc_mclk_enable(tasha, enable);
-}
-EXPORT_SYMBOL(tasha_cdc_mclk_enable);
-
-int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
-		__func__, tasha->clk_mode, enable, tasha->clk_internal);
-	if (tasha->clk_mode || tasha->clk_internal) {
-		if (enable) {
-			tasha_cdc_sido_ccl_enable(tasha, true);
-			wcd_resmgr_enable_master_bias(tasha->resmgr);
-			tasha_dig_core_power_collapse(tasha, POWER_RESUME);
-			snd_soc_update_bits(codec,
-					WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x01, 0x01);
-			snd_soc_update_bits(codec,
-					WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x01, 0x01);
-			set_bit(CPE_NOMINAL, &tasha->status_mask);
-			tasha_codec_update_sido_voltage(tasha,
-						SIDO_VOLTAGE_NOMINAL_MV);
-			tasha->clk_internal = true;
-		} else {
-			tasha->clk_internal = false;
-			clear_bit(CPE_NOMINAL, &tasha->status_mask);
-			tasha_codec_update_sido_voltage(tasha,
-						sido_buck_svs_voltage);
-			tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
-			wcd_resmgr_disable_master_bias(tasha->resmgr);
-			tasha_cdc_sido_ccl_enable(tasha, false);
-		}
-	} else {
-		ret = __tasha_cdc_mclk_enable(tasha, enable);
-	}
-	return ret;
-}
-EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
-
-static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
-			       void *file_private_data, struct file *file,
-			       char __user *buf, size_t count, loff_t pos)
-{
-	struct tasha_priv *tasha;
-	struct wcd9xxx *wcd9xxx;
-	char buffer[TASHA_VERSION_ENTRY_SIZE];
-	int len = 0;
-
-	tasha = (struct tasha_priv *) entry->private_data;
-	if (!tasha) {
-		pr_err("%s: tasha priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	wcd9xxx = tasha->wcd9xxx;
-
-	if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
-		if (TASHA_IS_1_0(wcd9xxx))
-			len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
-		else if (TASHA_IS_1_1(wcd9xxx))
-			len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
-		else
-			snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-	} else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
-		len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
-	} else
-		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops tasha_codec_info_ops = {
-	.read = tasha_codec_version_read,
-};
-
-/*
- * tasha_codec_info_create_codec_entry - creates wcd9335 module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates wcd9335 module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct tasha_priv *tasha;
-	struct snd_soc_card *card;
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	tasha = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-	tasha->entry = snd_info_create_subdir(codec_root->module,
-					      "tasha", codec_root);
-	if (!tasha->entry) {
-		dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   tasha->entry);
-	if (!version_entry) {
-		dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = tasha;
-	version_entry->size = TASHA_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &tasha_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	tasha->version_entry = version_entry;
-
-	return 0;
-}
-EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
-
-static int __tasha_codec_internal_rco_ctrl(
-	struct snd_soc_codec *codec, bool enable)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	if (enable) {
-		tasha_cdc_sido_ccl_enable(tasha, true);
-		if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
-		    WCD_CLK_RCO) {
-			ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
-							  WCD_CLK_RCO);
-		} else {
-			ret = tasha_cdc_req_mclk_enable(tasha, true);
-			ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
-							   WCD_CLK_RCO);
-			ret |= tasha_cdc_req_mclk_enable(tasha, false);
-		}
-
-	} else {
-		ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
-						   WCD_CLK_RCO);
-		tasha_cdc_sido_ccl_enable(tasha, false);
-	}
-
-	if (ret) {
-		dev_err(codec->dev, "%s: Error in %s RCO\n",
-			__func__, (enable ? "enabling" : "disabling"));
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-/*
- * tasha_codec_internal_rco_ctrl()
- * Make sure that the caller does not acquire
- * BG_CLK_LOCK.
- */
-static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
-				  bool enable)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
-	ret = __tasha_codec_internal_rco_ctrl(codec, enable);
-	WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
-	return ret;
-}
-
-/*
- * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
- * @codec: handle to snd_soc_codec *
- * @mbhc_cfg: handle to mbhc configuration structure
- * return 0 if mbhc_start is success or error code in case of failure
- */
-int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
-			 struct wcd_mbhc_config *mbhc_cfg)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
-}
-EXPORT_SYMBOL(tasha_mbhc_hs_detect);
-
-/*
- * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
- * @codec: handle to snd_soc_codec *
- */
-void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	wcd_mbhc_stop(&tasha->mbhc);
-}
-EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
-
-static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
-{
-	/* min micbias voltage is 1V and maximum is 2.85V */
-	if (micb_mv < 1000 || micb_mv > 2850) {
-		pr_err("%s: unsupported micbias voltage\n", __func__);
-		return -EINVAL;
-	}
-
-	return (micb_mv - 1000) / 50;
-}
-
-static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
-	{WCD9335_RCO_CTRL_2, 0xFF, 0x47},
-	{WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
-	{WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
-	{WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
-	{WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
-	{WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
-	{WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
-	{WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
-	{WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
-	{WCD9335_FLYBACK_EN, 0xFF, 0x6E},
-	{WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
-	{WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
-	{WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
-	{WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
-	{WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
-	{WCD9335_RCO_CTRL_2, 0x0F, 0x08},
-	{WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
-	{WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
-	{WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
-	{WCD9335_HPH_L_TEST, 0x01, 0x01},
-	{WCD9335_HPH_R_TEST, 0x01, 0x01},
-	{WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
-	{WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
-	{WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
-	{WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
-	{WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
-	{WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
-	{WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
-	{WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
-	{WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
-	{WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
-	{WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
-	{WCD9335_SE_LO_COM1, 0xFF, 0xC0},
-	{WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
-	{WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
-	{WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
-	{WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
-	{WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
-	{WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
-	{WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
-	{WCD9335_ANA_CLK_TOP, 0x20, 0x20},
-	{WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
-	{WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
-	{WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
-	{WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
-	{WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
-	{WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
-	{WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
-	{WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
-	{WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
-	{WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
-	{WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
-	/* Rbuckfly/R_EAR(32) */
-	{WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
-	{WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
-	{WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
-	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
-	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
-	{WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
-	{WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
-	{WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
-	{WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
-	{WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
-	{WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
-	{WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
-	{WCD9335_EAR_CMBUFF, 0x08, 0x00},
-	{WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
-	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
-	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
-	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
-	{WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
-	{WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
-	{WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
-};
-
-static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
-	/* Enable TX HPF Filter & Linear Phase */
-	{WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
-	{WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
-	{WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
-	{WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
-	{WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
-	{WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
-	{WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
-	{WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
-	{WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
-	{WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
-	{WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
-	{WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
-	{WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
-	{WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
-	{WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
-	{WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
-	{WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
-	{WCD9335_SE_LO_COM2, 0xFF, 0x01},
-	{WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
-	{WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
-	{WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
-	{WCD9335_HPH_L_EN, 0x20, 0x20},
-	{WCD9335_HPH_R_EN, 0x20, 0x20},
-	{WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
-	{WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
-	{WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
-	{WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
-};
-
-static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
-{
-	u32 i;
-	struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
-
-	if (TASHA_IS_1_1(tasha_core)) {
-		for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
-		     i++)
-			snd_soc_write(codec,
-				      tasha_reg_update_reset_val_1_1[i].reg,
-				      tasha_reg_update_reset_val_1_1[i].val);
-	}
-}
-
-static void tasha_codec_init_reg(struct snd_soc_codec *codec)
-{
-	u32 i;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
-		snd_soc_update_bits(codec,
-				tasha_codec_reg_init_common_val[i].reg,
-				tasha_codec_reg_init_common_val[i].mask,
-				tasha_codec_reg_init_common_val[i].val);
-
-	if (TASHA_IS_1_1(wcd9xxx) ||
-	    TASHA_IS_1_0(wcd9xxx))
-		for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
-			snd_soc_update_bits(codec,
-					tasha_codec_reg_init_1_x_val[i].reg,
-					tasha_codec_reg_init_1_x_val[i].mask,
-					tasha_codec_reg_init_1_x_val[i].val);
-
-	if (TASHA_IS_1_1(wcd9xxx)) {
-		for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
-			snd_soc_update_bits(codec,
-					tasha_codec_reg_init_val_1_1[i].reg,
-					tasha_codec_reg_init_val_1_1[i].mask,
-					tasha_codec_reg_init_val_1_1[i].val);
-	} else if (TASHA_IS_1_0(wcd9xxx)) {
-		for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
-			snd_soc_update_bits(codec,
-					tasha_codec_reg_init_val_1_0[i].reg,
-					tasha_codec_reg_init_val_1_0[i].mask,
-					tasha_codec_reg_init_val_1_0[i].val);
-	} else if (TASHA_IS_2_0(wcd9xxx)) {
-		for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
-			snd_soc_update_bits(codec,
-					tasha_codec_reg_init_val_2_0[i].reg,
-					tasha_codec_reg_init_val_2_0[i].mask,
-					tasha_codec_reg_init_val_2_0[i].val);
-	}
-}
-
-static void tasha_update_reg_defaults(struct tasha_priv *tasha)
-{
-	u32 i;
-	struct wcd9xxx *wcd9xxx;
-
-	wcd9xxx = tasha->wcd9xxx;
-	for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
-		regmap_update_bits(wcd9xxx->regmap,
-				   tasha_codec_reg_defaults[i].reg,
-				   tasha_codec_reg_defaults[i].mask,
-				   tasha_codec_reg_defaults[i].val);
-
-	tasha->intf_type = wcd9xxx_get_intf_type();
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
-		for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
-			regmap_update_bits(wcd9xxx->regmap,
-					   tasha_codec_reg_i2c_defaults[i].reg,
-					   tasha_codec_reg_i2c_defaults[i].mask,
-					   tasha_codec_reg_i2c_defaults[i].val);
-
-}
-
-static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
-{
-	int i;
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
-		wcd9xxx_interface_reg_write(priv->wcd9xxx,
-					    TASHA_SLIM_PGD_PORT_INT_EN0 + i,
-					    0xFF);
-}
-
-static irqreturn_t tasha_slimbus_irq(int irq, void *data)
-{
-	struct tasha_priv *priv = data;
-	unsigned long status = 0;
-	int i, j, port_id, k;
-	u32 bit;
-	u8 val, int_val = 0;
-	bool tx, cleared;
-	unsigned short reg = 0;
-
-	for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
-	     i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
-		val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
-		status |= ((u32)val << (8 * j));
-	}
-
-	for_each_set_bit(j, &status, 32) {
-		tx = (j >= 16 ? true : false);
-		port_id = (tx ? j - 16 : j);
-		val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
-				TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
-		if (val) {
-			if (!tx)
-				reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
-					(port_id / 8);
-			else
-				reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
-					(port_id / 8);
-			int_val = wcd9xxx_interface_reg_read(
-				priv->wcd9xxx, reg);
-			/*
-			 * Ignore interrupts for ports for which the
-			 * interrupts are not specifically enabled.
-			 */
-			if (!(int_val & (1 << (port_id % 8))))
-				continue;
-		}
-		if (val & TASHA_SLIM_IRQ_OVERFLOW)
-			pr_err_ratelimited(
-			   "%s: overflow error on %s port %d, value %x\n",
-			   __func__, (tx ? "TX" : "RX"), port_id, val);
-		if (val & TASHA_SLIM_IRQ_UNDERFLOW)
-			pr_err_ratelimited(
-			   "%s: underflow error on %s port %d, value %x\n",
-			   __func__, (tx ? "TX" : "RX"), port_id, val);
-		if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
-			(val & TASHA_SLIM_IRQ_UNDERFLOW)) {
-			if (!tx)
-				reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
-					(port_id / 8);
-			else
-				reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
-					(port_id / 8);
-			int_val = wcd9xxx_interface_reg_read(
-				priv->wcd9xxx, reg);
-			if (int_val & (1 << (port_id % 8))) {
-				int_val = int_val ^ (1 << (port_id % 8));
-				wcd9xxx_interface_reg_write(priv->wcd9xxx,
-					reg, int_val);
-			}
-		}
-		if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
-			/*
-			 * INT SOURCE register starts from RX to TX
-			 * but port number in the ch_mask is in opposite way
-			 */
-			bit = (tx ? j - 16 : j + 16);
-			pr_debug("%s: %s port %d closed value %x, bit %u\n",
-				 __func__, (tx ? "TX" : "RX"), port_id, val,
-				 bit);
-			for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
-				pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
-					 __func__, k, priv->dai[k].ch_mask);
-				if (test_and_clear_bit(bit,
-						       &priv->dai[k].ch_mask)) {
-					cleared = true;
-					if (!priv->dai[k].ch_mask)
-						wake_up(&priv->dai[k].dai_wait);
-					/*
-					 * There are cases when multiple DAIs
-					 * might be using the same slimbus
-					 * channel. Hence don't break here.
-					 */
-				}
-			}
-			WARN(!cleared,
-			     "Couldn't find slimbus %s port %d for closing\n",
-			     (tx ? "TX" : "RX"), port_id);
-		}
-		wcd9xxx_interface_reg_write(priv->wcd9xxx,
-					    TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
-					    (j / 8),
-					    1 << (j % 8));
-	}
-
-	return IRQ_HANDLED;
-}
-
-static int tasha_setup_irqs(struct tasha_priv *tasha)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = tasha->codec;
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
-				  tasha_slimbus_irq, "SLIMBUS Slave", tasha);
-	if (ret)
-		pr_err("%s: Failed to request irq %d\n", __func__,
-		       WCD9XXX_IRQ_SLIMBUS);
-	else
-		tasha_slim_interface_init_reg(codec);
-
-	return ret;
-}
-
-static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-	struct afe_param_cdc_slimbus_slave_cfg *cfg;
-	struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
-	uint64_t eaddr = 0;
-
-	cfg = &priv->slimbus_slave_cfg;
-	cfg->minor_version = 1;
-	cfg->tx_slave_port_offset = 0;
-	cfg->rx_slave_port_offset = 16;
-
-	memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
-	WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
-	cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
-	cfg->device_enum_addr_msw = eaddr >> 32;
-
-	dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
-		__func__, eaddr);
-}
-
-static void tasha_cleanup_irqs(struct tasha_priv *tasha)
-{
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
-}
-
-static int tasha_handle_pdata(struct tasha_priv *tasha,
-			      struct wcd9xxx_pdata *pdata)
-{
-	struct snd_soc_codec *codec = tasha->codec;
-	u8 dmic_ctl_val, mad_dmic_ctl_val;
-	u8 anc_ctl_value;
-	u32 def_dmic_rate, dmic_clk_drv;
-	int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
-	int rc = 0;
-
-	if (!pdata) {
-		dev_err(codec->dev, "%s: NULL pdata\n", __func__);
-		return -ENODEV;
-	}
-
-	/* set micbias voltage */
-	vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
-	vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
-	vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
-	vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
-	if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
-	    vout_ctl_3 < 0 || vout_ctl_4 < 0) {
-		rc = -EINVAL;
-		goto done;
-	}
-	snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
-	snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
-	snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
-	snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
-
-	/* Set the DMIC sample rate */
-	switch (pdata->mclk_rate) {
-	case TASHA_MCLK_CLK_9P6MHZ:
-		def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
-		break;
-	case TASHA_MCLK_CLK_12P288MHZ:
-		def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
-		break;
-	default:
-		/* should never happen */
-		dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
-			__func__, pdata->mclk_rate);
-		rc = -EINVAL;
-		goto done;
-	};
-
-	if (pdata->dmic_sample_rate ==
-	    WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
-		dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
-			__func__, def_dmic_rate);
-		pdata->dmic_sample_rate = def_dmic_rate;
-	}
-	if (pdata->mad_dmic_sample_rate ==
-	    WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
-		dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
-			__func__, def_dmic_rate);
-		/*
-		 * use dmic_sample_rate as the default for MAD
-		 * if mad dmic sample rate is undefined
-		 */
-		pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
-	}
-	if (pdata->ecpp_dmic_sample_rate ==
-	    WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
-		dev_info(codec->dev,
-			 "%s: ecpp_dmic_rate invalid default = %d\n",
-			 __func__, def_dmic_rate);
-		/*
-		 * use dmic_sample_rate as the default for ECPP DMIC
-		 * if ecpp dmic sample rate is undefined
-		 */
-		pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
-	}
-
-	if (pdata->dmic_clk_drv ==
-	    WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
-		pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
-		dev_info(codec->dev,
-			 "%s: dmic_clk_strength invalid, default = %d\n",
-			 __func__, pdata->dmic_clk_drv);
-	}
-
-	switch (pdata->dmic_clk_drv) {
-	case 2:
-		dmic_clk_drv = 0;
-		break;
-	case 4:
-		dmic_clk_drv = 1;
-		break;
-	case 8:
-		dmic_clk_drv = 2;
-		break;
-	case 16:
-		dmic_clk_drv = 3;
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: invalid dmic_clk_drv %d, using default\n",
-			__func__, pdata->dmic_clk_drv);
-		dmic_clk_drv = 0;
-		break;
-	}
-
-	snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
-			    0x0C, dmic_clk_drv << 2);
-
-	/*
-	 * Default the DMIC clk rates to mad_dmic_sample_rate,
-	 * whereas, the anc/txfe dmic rates to dmic_sample_rate
-	 * since the anc/txfe are independent of mad block.
-	 */
-	mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
-				pdata->mclk_rate,
-				pdata->mad_dmic_sample_rate);
-	snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-	snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-	snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-
-	dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
-				pdata->mclk_rate,
-				pdata->dmic_sample_rate);
-
-	if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
-		anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
-	else
-		anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
-
-	snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
-			    0x40, anc_ctl_value << 6);
-	snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
-			    0x20, anc_ctl_value << 5);
-	snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
-			    0x40, anc_ctl_value << 6);
-	snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
-			    0x20, anc_ctl_value << 5);
-done:
-	return rc;
-}
-
-static struct wcd_cpe_core *tasha_codec_get_cpe_core(
-		struct snd_soc_codec *codec)
-{
-	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	return priv->cpe_core;
-}
-
-static int tasha_codec_cpe_fll_update_divider(
-	struct snd_soc_codec *codec, u32 cpe_fll_rate)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	u32 div_val = 0, l_val = 0;
-	u32 computed_cpe_fll;
-
-	if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
-	    cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
-		dev_err(codec->dev,
-			"%s: Invalid CPE fll rate request %u\n",
-			__func__, cpe_fll_rate);
-		return -EINVAL;
-	}
-
-	if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
-		/* update divider to 10 and enable 5x divider */
-		snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
-			      0x55);
-		div_val = 10;
-	} else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
-		/* update divider to 8 and enable 2x divider */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
-				    0x7C, 0x70);
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
-				    0xE0, 0x20);
-		div_val = 8;
-	} else {
-		dev_err(codec->dev,
-			"%s: Invalid MCLK rate %u\n",
-			__func__, wcd9xxx->mclk_rate);
-		return -EINVAL;
-	}
-
-	l_val = ((cpe_fll_rate / 1000) * div_val) /
-		 (wcd9xxx->mclk_rate / 1000);
-
-	/* If l_val was integer truncated, increment l_val once */
-	computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
-	if (computed_cpe_fll < cpe_fll_rate)
-		l_val++;
-
-
-	/* update L value LSB and MSB */
-	snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
-		      (l_val & 0xFF));
-	snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
-		      ((l_val >> 8) & 0xFF));
-
-	tasha->current_cpe_clk_freq = cpe_fll_rate;
-	dev_dbg(codec->dev,
-		"%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
-		__func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
-
-	return 0;
-}
-
-static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
-		u32 clk_freq)
-{
-	int ret = 0;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (!tasha_cdc_is_svs_enabled(tasha)) {
-		dev_dbg(codec->dev,
-			"%s: SVS not enabled or tasha is not 2p0, return\n",
-			__func__);
-		return 0;
-	}
-	dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
-
-	if (clk_freq == CPE_FLL_CLK_75MHZ) {
-		/* Change to SVS */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x08, 0x08);
-		if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
-			ret = -EINVAL;
-			goto done;
-		}
-
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x10, 0x10);
-
-		clear_bit(CPE_NOMINAL, &tasha->status_mask);
-		tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
-
-	} else if (clk_freq == CPE_FLL_CLK_150MHZ) {
-		/* change to nominal */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x08, 0x08);
-
-		set_bit(CPE_NOMINAL, &tasha->status_mask);
-		tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
-
-		if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
-			ret = -EINVAL;
-			goto done;
-		}
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x10, 0x10);
-	} else {
-		dev_err(codec->dev,
-			"%s: Invalid clk_freq request %d for CPE FLL\n",
-			__func__, clk_freq);
-		ret = -EINVAL;
-	}
-
-done:
-	snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-			    0x10, 0x00);
-	snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-			    0x08, 0x00);
-	return ret;
-}
-
-
-static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
-				   bool enable)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u8 clk_sel_reg_val = 0x00;
-
-	dev_dbg(codec->dev, "%s: enable = %s\n",
-			__func__, enable ? "true" : "false");
-
-	if (enable) {
-		if (tasha_cdc_is_svs_enabled(tasha)) {
-			/* FLL enable is always at SVS */
-			if (__tasha_cdc_change_cpe_clk(codec,
-					CPE_FLL_CLK_75MHZ)) {
-				dev_err(codec->dev,
-					"%s: clk change to %d failed\n",
-					__func__, CPE_FLL_CLK_75MHZ);
-				return -EINVAL;
-			}
-		} else {
-			if (tasha_codec_cpe_fll_update_divider(codec,
-							CPE_FLL_CLK_75MHZ)) {
-				dev_err(codec->dev,
-					"%s: clk change to %d failed\n",
-					__func__, CPE_FLL_CLK_75MHZ);
-				return -EINVAL;
-			}
-		}
-
-		if (TASHA_IS_1_0(wcd9xxx)) {
-			tasha_cdc_mclk_enable(codec, true, false);
-			clk_sel_reg_val = 0x02;
-		}
-
-		/* Setup CPE reference clk */
-		snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
-				    0x02, clk_sel_reg_val);
-
-		/* enable CPE FLL reference clk */
-		snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
-				    0x01, 0x01);
-
-		/* program the PLL */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
-				    0x01, 0x01);
-
-		/* TEST clk setting */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
-				    0x80, 0x80);
-		/* set FLL mode to HW controlled */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x60, 0x00);
-		snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
-	} else {
-		/* disable CPE FLL reference clk */
-		snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
-				    0x01, 0x00);
-		/* undo TEST clk setting */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
-				    0x80, 0x00);
-		/* undo FLL mode to HW control */
-		snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
-				    0x60, 0x20);
-		/* undo the PLL */
-		snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
-				    0x01, 0x00);
-
-		if (TASHA_IS_1_0(wcd9xxx))
-			tasha_cdc_mclk_enable(codec, false, false);
-
-		/*
-		 * FLL could get disabled while at nominal,
-		 * scale it back to SVS
-		 */
-		if (tasha_cdc_is_svs_enabled(tasha))
-			__tasha_cdc_change_cpe_clk(codec,
-						CPE_FLL_CLK_75MHZ);
-	}
-
-	return 0;
-
-}
-
-static void tasha_cdc_query_cpe_clk_plan(void *data,
-		struct cpe_svc_cfg_clk_plan *clk_freq)
-{
-	struct snd_soc_codec *codec = data;
-	struct tasha_priv *tasha;
-	u32 cpe_clk_khz;
-
-	if (!codec) {
-		pr_err("%s: Invalid codec handle\n",
-			__func__);
-		return;
-	}
-
-	tasha = snd_soc_codec_get_drvdata(codec);
-	cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
-
-	dev_dbg(codec->dev,
-		"%s: current_clk_freq = %u\n",
-		__func__, tasha->current_cpe_clk_freq);
-
-	clk_freq->current_clk_feq = cpe_clk_khz;
-	clk_freq->num_clk_freqs = 2;
-
-	if (tasha_cdc_is_svs_enabled(tasha)) {
-		clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
-		clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
-	} else {
-		clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
-		clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
-	}
-}
-
-static void tasha_cdc_change_cpe_clk(void *data,
-		u32 clk_freq)
-{
-	struct snd_soc_codec *codec = data;
-	struct tasha_priv *tasha;
-	u32 cpe_clk_khz, req_freq = 0;
-
-	if (!codec) {
-		pr_err("%s: Invalid codec handle\n",
-			__func__);
-		return;
-	}
-
-	tasha = snd_soc_codec_get_drvdata(codec);
-	cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
-
-	if (tasha_cdc_is_svs_enabled(tasha)) {
-		if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
-			req_freq = CPE_FLL_CLK_75MHZ;
-		else
-			req_freq = CPE_FLL_CLK_150MHZ;
-	}
-
-	dev_dbg(codec->dev,
-		"%s: requested clk_freq = %u, current clk_freq = %u\n",
-		__func__, clk_freq * 1000,
-		tasha->current_cpe_clk_freq);
-
-	if (tasha_cdc_is_svs_enabled(tasha)) {
-		if (__tasha_cdc_change_cpe_clk(codec, req_freq))
-			dev_err(codec->dev,
-				"%s: clock/voltage scaling failed\n",
-				__func__);
-	}
-}
-
-static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
-		u32 bw_ops, bool commit)
-{
-	struct wcd9xxx *wcd9xxx;
-
-	if (!codec) {
-		pr_err("%s: Invalid handle to codec\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!wcd9xxx) {
-		dev_err(codec->dev, "%s: Invalid parent drv_data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
-}
-
-static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
-			bool vote)
-{
-	u32 bw_ops;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
-		return 0;
-
-	mutex_lock(&tasha->sb_clk_gear_lock);
-	if (vote) {
-		tasha->ref_count++;
-		if (tasha->ref_count == 1) {
-			bw_ops = SLIM_BW_CLK_GEAR_9;
-			tasha_codec_slim_reserve_bw(codec,
-				bw_ops, true);
-		}
-	} else if (!vote && tasha->ref_count > 0) {
-		tasha->ref_count--;
-		if (tasha->ref_count == 0) {
-			bw_ops = SLIM_BW_UNVOTE;
-			tasha_codec_slim_reserve_bw(codec,
-				bw_ops, true);
-		}
-	};
-
-	dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
-		__func__, tasha->ref_count);
-
-	mutex_unlock(&tasha->sb_clk_gear_lock);
-
-	return 0;
-}
-
-static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
-	enum cpe_err_irq_cntl_type cntl_type, u8 *status)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	u8 irq_bits;
-
-	if (TASHA_IS_2_0(tasha->wcd9xxx))
-		irq_bits = 0xFF;
-	else
-		irq_bits = 0x3F;
-
-	if (status)
-		irq_bits = (*status) & irq_bits;
-
-	switch (cntl_type) {
-	case CPE_ERR_IRQ_MASK:
-		snd_soc_update_bits(codec,
-				    WCD9335_CPE_SS_SS_ERROR_INT_MASK,
-				    irq_bits, irq_bits);
-		break;
-	case CPE_ERR_IRQ_UNMASK:
-		snd_soc_update_bits(codec,
-				    WCD9335_CPE_SS_SS_ERROR_INT_MASK,
-				    irq_bits, 0x00);
-		break;
-	case CPE_ERR_IRQ_CLEAR:
-		snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
-			      irq_bits);
-		break;
-	case CPE_ERR_IRQ_STATUS:
-		if (!status)
-			return -EINVAL;
-		*status = snd_soc_read(codec,
-				       WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
-		break;
-	}
-
-	return 0;
-}
-
-static const struct wcd_cpe_cdc_cb cpe_cb = {
-	.cdc_clk_en = tasha_codec_internal_rco_ctrl,
-	.cpe_clk_en = tasha_codec_cpe_fll_enable,
-	.get_afe_out_port_id = tasha_codec_get_mad_port_id,
-	.lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
-	.cdc_ext_clk = tasha_cdc_mclk_enable,
-	.bus_vote_bw = tasha_codec_vote_max_bw,
-	.cpe_err_irq_control = tasha_cpe_err_irq_control,
-};
-
-static struct cpe_svc_init_param cpe_svc_params = {
-	.version = CPE_SVC_INIT_PARAM_V1,
-	.query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
-	.change_freq_plan_cb = tasha_cdc_change_cpe_clk,
-};
-
-static int tasha_cpe_initialize(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd_cpe_params cpe_params;
-
-	memset(&cpe_params, 0,
-	       sizeof(struct wcd_cpe_params));
-	cpe_params.codec = codec;
-	cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
-	cpe_params.cdc_cb = &cpe_cb;
-	cpe_params.dbg_mode = cpe_debug_mode;
-	cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
-	cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
-	cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
-
-	cpe_params.cdc_irq_info.cpe_engine_irq =
-			WCD9335_IRQ_SVA_OUTBOX1;
-	cpe_params.cdc_irq_info.cpe_err_irq =
-			WCD9335_IRQ_SVA_ERROR;
-	cpe_params.cdc_irq_info.cpe_fatal_irqs =
-			TASHA_CPE_FATAL_IRQS;
-
-	cpe_svc_params.context = codec;
-	cpe_params.cpe_svc_params = &cpe_svc_params;
-
-	tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
-					&cpe_params);
-	if (IS_ERR_OR_NULL(tasha->cpe_core)) {
-		dev_err(codec->dev,
-			"%s: Failed to enable CPE\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static const struct wcd_resmgr_cb tasha_resmgr_cb = {
-	.cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
-};
-
-static int tasha_device_down(struct wcd9xxx *wcd9xxx)
-{
-	struct snd_soc_codec *codec;
-	struct tasha_priv *priv;
-	int count;
-	int i = 0;
-
-	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
-	priv = snd_soc_codec_get_drvdata(codec);
-	wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
-	for (i = 0; i < priv->nr; i++)
-		swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
-				SWR_DEVICE_DOWN, NULL);
-	snd_soc_card_change_online_state(codec->component.card, 0);
-	for (count = 0; count < NUM_CODEC_DAIS; count++)
-		priv->dai[count].bus_down_in_recovery = true;
-
-	priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
-
-	return 0;
-}
-
-static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
-{
-	int i, ret = 0;
-	struct wcd9xxx *control;
-	struct snd_soc_codec *codec;
-	struct tasha_priv *tasha;
-	struct wcd9xxx_pdata *pdata;
-
-	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
-	tasha = snd_soc_codec_get_drvdata(codec);
-	control = dev_get_drvdata(codec->dev->parent);
-
-	wcd9xxx_set_power_state(tasha->wcd9xxx,
-				WCD_REGION_POWER_COLLAPSE_REMOVE,
-				WCD9XXX_DIG_CORE_REGION_1);
-
-	mutex_lock(&tasha->codec_mutex);
-
-	tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
-		control->slim_slave->laddr;
-	tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
-		control->slim->laddr;
-	tasha_init_slim_slave_cfg(codec);
-	if (tasha->machine_codec_event_cb)
-		tasha->machine_codec_event_cb(codec,
-				WCD9335_CODEC_EVENT_CODEC_UP);
-	snd_soc_card_change_online_state(codec->component.card, 1);
-
-	/* Class-H Init*/
-	wcd_clsh_init(&tasha->clsh_d);
-
-	for (i = 0; i < TASHA_MAX_MICBIAS; i++)
-		tasha->micb_ref[i] = 0;
-
-	tasha_update_reg_defaults(tasha);
-
-	tasha->codec = codec;
-
-	dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
-		__func__, control->mclk_rate);
-
-	if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
-		snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x00);
-	else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
-		snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x01);
-	tasha_codec_init_reg(codec);
-
-	wcd_resmgr_post_ssr_v2(tasha->resmgr);
-
-	tasha_enable_efuse_sensing(codec);
-
-	regcache_mark_dirty(codec->component.regmap);
-	regcache_sync(codec->component.regmap);
-
-	pdata = dev_get_platdata(codec->dev->parent);
-	ret = tasha_handle_pdata(tasha, pdata);
-	if (ret < 0)
-		dev_err(codec->dev, "%s: invalid pdata\n", __func__);
-
-	/* Reset reference counter for voting for max bw */
-	tasha->ref_count = 0;
-	/* MBHC Init */
-	wcd_mbhc_deinit(&tasha->mbhc);
-	tasha->mbhc_started = false;
-
-	/* Initialize MBHC module */
-	ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
-		      wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
-	if (ret)
-		dev_err(codec->dev, "%s: mbhc initialization failed\n",
-			__func__);
-	else
-		tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
-
-	tasha_cleanup_irqs(tasha);
-	ret = tasha_setup_irqs(tasha);
-	if (ret) {
-		dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
-			__func__, ret);
-		goto err;
-	}
-
-	tasha_set_spkr_mode(codec, tasha->spkr_mode);
-	wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
-
-err:
-	mutex_unlock(&tasha->codec_mutex);
-	return ret;
-}
-
-static struct regulator *tasha_codec_find_ondemand_regulator(
-		struct snd_soc_codec *codec, const char *name)
-{
-	int i;
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-
-	for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
-		if (pdata->regulator[i].ondemand &&
-			wcd9xxx->supplies[i].supply &&
-			!strcmp(wcd9xxx->supplies[i].supply, name))
-			return wcd9xxx->supplies[i].consumer;
-	}
-
-	dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
-		name);
-	return NULL;
-}
-
-static int tasha_codec_probe(struct snd_soc_codec *codec)
-{
-	struct wcd9xxx *control;
-	struct tasha_priv *tasha;
-	struct wcd9xxx_pdata *pdata;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	int i, ret;
-	void *ptr = NULL;
-	struct regulator *supply;
-
-	control = dev_get_drvdata(codec->dev->parent);
-
-	dev_info(codec->dev, "%s()\n", __func__);
-	tasha = snd_soc_codec_get_drvdata(codec);
-	tasha->intf_type = wcd9xxx_get_intf_type();
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		control->dev_down = tasha_device_down;
-		control->post_reset = tasha_post_reset_cb;
-		control->ssr_priv = (void *)codec;
-	}
-
-	/* Resource Manager post Init */
-	ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
-	if (ret) {
-		dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
-			__func__);
-		goto err;
-	}
-	/* Class-H Init*/
-	wcd_clsh_init(&tasha->clsh_d);
-	/* Default HPH Mode to Class-H HiFi */
-	tasha->hph_mode = CLS_H_HIFI;
-
-	tasha->codec = codec;
-	for (i = 0; i < COMPANDER_MAX; i++)
-		tasha->comp_enabled[i] = 0;
-
-	tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
-	tasha->intf_type = wcd9xxx_get_intf_type();
-	tasha_update_reg_reset_values(codec);
-	pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
-	if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
-		snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x00);
-	else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
-		snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x01);
-	tasha_codec_init_reg(codec);
-
-	tasha_enable_efuse_sensing(codec);
-
-	pdata = dev_get_platdata(codec->dev->parent);
-	ret = tasha_handle_pdata(tasha, pdata);
-	if (ret < 0) {
-		pr_err("%s: bad pdata\n", __func__);
-		goto err;
-	}
-
-	supply = tasha_codec_find_ondemand_regulator(codec,
-		on_demand_supply_name[ON_DEMAND_MICBIAS]);
-	if (supply) {
-		tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
-		tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
-				0;
-	}
-
-	tasha->fw_data = devm_kzalloc(codec->dev,
-				      sizeof(*(tasha->fw_data)), GFP_KERNEL);
-	if (!tasha->fw_data)
-		goto err;
-	set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
-	set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
-	set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
-	set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
-
-	ret = wcd_cal_create_hwdep(tasha->fw_data,
-				   WCD9XXX_CODEC_HWDEP_NODE, codec);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
-		goto err_hwdep;
-	}
-
-	/* Initialize MBHC module */
-	if (TASHA_IS_2_0(tasha->wcd9xxx)) {
-		wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
-			WCD9335_MBHC_FSM_STATUS;
-		wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
-	}
-	ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
-		      wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
-	if (ret) {
-		pr_err("%s: mbhc initialization failed\n", __func__);
-		goto err_hwdep;
-	}
-
-	ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
-			   sizeof(tasha_tx_chs)), GFP_KERNEL);
-	if (!ptr) {
-		ret = -ENOMEM;
-		goto err_hwdep;
-	}
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
-		snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
-			ARRAY_SIZE(tasha_dapm_i2s_widgets));
-		snd_soc_dapm_add_routes(dapm, audio_i2s_map,
-			ARRAY_SIZE(audio_i2s_map));
-		for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
-			INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
-			init_waitqueue_head(&tasha->dai[i].dai_wait);
-		}
-	} else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		for (i = 0; i < NUM_CODEC_DAIS; i++) {
-			INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
-			init_waitqueue_head(&tasha->dai[i].dai_wait);
-		}
-		tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
-					control->slim_slave->laddr;
-		tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
-					control->slim->laddr;
-		tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
-					TASHA_TX13;
-		tasha_init_slim_slave_cfg(codec);
-	}
-
-	snd_soc_add_codec_controls(codec, impedance_detect_controls,
-				   ARRAY_SIZE(impedance_detect_controls));
-	snd_soc_add_codec_controls(codec, hph_type_detect_controls,
-				   ARRAY_SIZE(hph_type_detect_controls));
-
-	snd_soc_add_codec_controls(codec,
-			tasha_analog_gain_controls,
-			ARRAY_SIZE(tasha_analog_gain_controls));
-	control->num_rx_port = TASHA_RX_MAX;
-	control->rx_chs = ptr;
-	memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
-	control->num_tx_port = TASHA_TX_MAX;
-	control->tx_chs = ptr + sizeof(tasha_rx_chs);
-	memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
-
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
-
-	if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
-		snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
-		snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
-		snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
-		snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
-		snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
-		snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
-		snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
-	}
-
-	snd_soc_dapm_sync(dapm);
-
-	ret = tasha_setup_irqs(tasha);
-	if (ret) {
-		pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
-		goto err_pdata;
-	}
-
-	ret = tasha_cpe_initialize(codec);
-	if (ret) {
-		dev_err(codec->dev,
-			"%s: cpe initialization failed, err = %d\n",
-			__func__, ret);
-		/* Do not fail probe if CPE failed */
-		ret = 0;
-	}
-
-	for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
-		tasha->tx_hpf_work[i].tasha = tasha;
-		tasha->tx_hpf_work[i].decimator = i;
-		INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
-			tasha_tx_hpf_corner_freq_callback);
-	}
-
-	for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
-		tasha->tx_mute_dwork[i].tasha = tasha;
-		tasha->tx_mute_dwork[i].decimator = i;
-		INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
-			  tasha_tx_mute_update_callback);
-	}
-
-	tasha->spk_anc_dwork.tasha = tasha;
-	INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
-			  tasha_spk_anc_update_callback);
-
-	mutex_lock(&tasha->codec_mutex);
-	snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
-	snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
-	snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC EAR");
-	snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
-	mutex_unlock(&tasha->codec_mutex);
-	snd_soc_dapm_sync(dapm);
-
-	return ret;
-
-err_pdata:
-	devm_kfree(codec->dev, ptr);
-	control->rx_chs = NULL;
-	control->tx_chs = NULL;
-err_hwdep:
-	devm_kfree(codec->dev, tasha->fw_data);
-	tasha->fw_data = NULL;
-err:
-	return ret;
-}
-
-static int tasha_codec_remove(struct snd_soc_codec *codec)
-{
-	struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *control;
-
-	control = dev_get_drvdata(codec->dev->parent);
-	control->rx_chs = NULL;
-	control->tx_chs = NULL;
-
-	tasha_cleanup_irqs(tasha);
-	/* Cleanup MBHC */
-	/* Cleanup resmgr */
-
-	return 0;
-}
-
-static struct regmap *tasha_get_regmap(struct device *dev)
-{
-	struct wcd9xxx *control = dev_get_drvdata(dev->parent);
-
-	return control->regmap;
-}
-
-static struct snd_soc_codec_driver soc_codec_dev_tasha = {
-	.probe = tasha_codec_probe,
-	.remove = tasha_codec_remove,
-	.get_regmap = tasha_get_regmap,
-	.component_driver = {
-		.controls = tasha_snd_controls,
-		.num_controls = ARRAY_SIZE(tasha_snd_controls),
-		.dapm_widgets = tasha_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
-		.dapm_routes = audio_map,
-		.num_dapm_routes = ARRAY_SIZE(audio_map),
-	},
-};
-
-#ifdef CONFIG_PM
-static int tasha_suspend(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tasha_priv *tasha = platform_get_drvdata(pdev);
-
-	dev_dbg(dev, "%s: system suspend\n", __func__);
-	if (cancel_delayed_work_sync(&tasha->power_gate_work))
-		tasha_codec_power_gate_digital_core(tasha);
-
-	return 0;
-}
-
-static int tasha_resume(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tasha_priv *tasha = platform_get_drvdata(pdev);
-
-	if (!tasha) {
-		dev_err(dev, "%s: tasha private data is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_dbg(dev, "%s: system resume\n", __func__);
-	return 0;
-}
-
-static const struct dev_pm_ops tasha_pm_ops = {
-	.suspend = tasha_suspend,
-	.resume = tasha_resume,
-};
-#endif
-
-static int tasha_swrm_read(void *handle, int reg)
-{
-	struct tasha_priv *tasha;
-	struct wcd9xxx *wcd9xxx;
-	unsigned short swr_rd_addr_base;
-	unsigned short swr_rd_data_base;
-	int val, ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tasha = (struct tasha_priv *)handle;
-	wcd9xxx = tasha->wcd9xxx;
-
-	dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
-		__func__, reg);
-	swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
-	swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
-	/* read_lock */
-	mutex_lock(&tasha->swr_read_lock);
-	ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
-				(u8 *)&reg, 4);
-	if (ret < 0) {
-		pr_err("%s: RD Addr Failure\n", __func__);
-		goto err;
-	}
-	/* Check for RD status */
-	ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
-			       (u8 *)&val, 4);
-	if (ret < 0) {
-		pr_err("%s: RD Data Failure\n", __func__);
-		goto err;
-	}
-	ret = val;
-err:
-	/* read_unlock */
-	mutex_unlock(&tasha->swr_read_lock);
-	return ret;
-}
-
-static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
-				struct wcd9xxx_reg_val *bulk_reg,
-				size_t len)
-{
-	int i, ret = 0;
-	unsigned short swr_wr_addr_base;
-	unsigned short swr_wr_data_base;
-
-	swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
-	swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
-
-	for (i = 0; i < (len * 2); i += 2) {
-		/* First Write the Data to register */
-		ret = regmap_bulk_write(wcd9xxx->regmap,
-			swr_wr_data_base, bulk_reg[i].buf, 4);
-		if (ret < 0) {
-			dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
-				__func__);
-			break;
-		}
-		/* Next Write Address */
-		ret = regmap_bulk_write(wcd9xxx->regmap,
-			swr_wr_addr_base, bulk_reg[i+1].buf, 4);
-		if (ret < 0) {
-			dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
-				__func__);
-			break;
-		}
-	}
-	return ret;
-}
-
-static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
-{
-	struct tasha_priv *tasha;
-	struct wcd9xxx *wcd9xxx;
-	struct wcd9xxx_reg_val *bulk_reg;
-	unsigned short swr_wr_addr_base;
-	unsigned short swr_wr_data_base;
-	int i, j, ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	if (len <= 0) {
-		pr_err("%s: Invalid size: %zu\n", __func__, len);
-		return -EINVAL;
-	}
-	tasha = (struct tasha_priv *)handle;
-	wcd9xxx = tasha->wcd9xxx;
-
-	swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
-	swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
-
-	bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
-			   GFP_KERNEL);
-	if (!bulk_reg)
-		return -ENOMEM;
-
-	for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
-		bulk_reg[i].reg = swr_wr_data_base;
-		bulk_reg[i].buf = (u8 *)(&val[j]);
-		bulk_reg[i].bytes = 4;
-		bulk_reg[i+1].reg = swr_wr_addr_base;
-		bulk_reg[i+1].buf = (u8 *)(&reg[j]);
-		bulk_reg[i+1].bytes = 4;
-	}
-	mutex_lock(&tasha->swr_write_lock);
-
-	if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
-		ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
-		if (ret) {
-			dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
-				__func__, ret);
-		}
-	} else {
-		ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
-				 (len * 2), false);
-		if (ret) {
-			dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
-				__func__, ret);
-		}
-	}
-
-	mutex_unlock(&tasha->swr_write_lock);
-	kfree(bulk_reg);
-
-	return ret;
-}
-
-static int tasha_swrm_write(void *handle, int reg, int val)
-{
-	struct tasha_priv *tasha;
-	struct wcd9xxx *wcd9xxx;
-	unsigned short swr_wr_addr_base;
-	unsigned short swr_wr_data_base;
-	struct wcd9xxx_reg_val bulk_reg[2];
-	int ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tasha = (struct tasha_priv *)handle;
-	wcd9xxx = tasha->wcd9xxx;
-
-	swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
-	swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
-
-	/* First Write the Data to register */
-	bulk_reg[0].reg = swr_wr_data_base;
-	bulk_reg[0].buf = (u8 *)(&val);
-	bulk_reg[0].bytes = 4;
-	bulk_reg[1].reg = swr_wr_addr_base;
-	bulk_reg[1].buf = (u8 *)(&reg);
-	bulk_reg[1].bytes = 4;
-
-	mutex_lock(&tasha->swr_write_lock);
-
-	if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
-		ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
-		if (ret) {
-			dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
-				__func__, ret);
-		}
-	} else {
-		ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
-		if (ret < 0)
-			pr_err("%s: WR Data Failure\n", __func__);
-	}
-
-	mutex_unlock(&tasha->swr_write_lock);
-	return ret;
-}
-
-static int tasha_swrm_clock(void *handle, bool enable)
-{
-	struct tasha_priv *tasha = (struct tasha_priv *) handle;
-
-	mutex_lock(&tasha->swr_clk_lock);
-
-	dev_dbg(tasha->dev, "%s: swrm clock %s\n",
-		__func__, (enable?"enable" : "disable"));
-	if (enable) {
-		tasha->swr_clk_users++;
-		if (tasha->swr_clk_users == 1) {
-			if (TASHA_IS_2_0(tasha->wcd9xxx))
-				regmap_update_bits(
-					tasha->wcd9xxx->regmap,
-					WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
-					0x10, 0x00);
-			__tasha_cdc_mclk_enable(tasha, true);
-			regmap_update_bits(tasha->wcd9xxx->regmap,
-				WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
-				0x01, 0x01);
-		}
-	} else {
-		tasha->swr_clk_users--;
-		if (tasha->swr_clk_users == 0) {
-			regmap_update_bits(tasha->wcd9xxx->regmap,
-				WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
-				0x01, 0x00);
-			__tasha_cdc_mclk_enable(tasha, false);
-			if (TASHA_IS_2_0(tasha->wcd9xxx))
-				regmap_update_bits(
-					tasha->wcd9xxx->regmap,
-					WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
-					0x10, 0x10);
-		}
-	}
-	dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
-		__func__, tasha->swr_clk_users);
-	mutex_unlock(&tasha->swr_clk_lock);
-	return 0;
-}
-
-static int tasha_swrm_handle_irq(void *handle,
-				   irqreturn_t (*swrm_irq_handler)(int irq,
-								   void *data),
-				    void *swrm_handle,
-				    int action)
-{
-	struct tasha_priv *tasha;
-	int ret = 0;
-	struct wcd9xxx *wcd9xxx;
-
-	if (!handle) {
-		pr_err("%s: null handle received\n", __func__);
-		return -EINVAL;
-	}
-	tasha = (struct tasha_priv *) handle;
-	wcd9xxx = tasha->wcd9xxx;
-
-	if (action) {
-		ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
-					  WCD9335_IRQ_SOUNDWIRE,
-					  swrm_irq_handler,
-					  "Tasha SWR Master", swrm_handle);
-		if (ret)
-			dev_err(tasha->dev, "%s: Failed to request irq %d\n",
-				__func__, WCD9335_IRQ_SOUNDWIRE);
-	} else
-		wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
-				 swrm_handle);
-
-	return ret;
-}
-
-static void tasha_add_child_devices(struct work_struct *work)
-{
-	struct tasha_priv *tasha;
-	struct platform_device *pdev;
-	struct device_node *node;
-	struct wcd9xxx *wcd9xxx;
-	struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
-	int ret, ctrl_num = 0;
-	struct wcd_swr_ctrl_platform_data *platdata;
-	char plat_dev_name[WCD9335_STRING_LEN];
-
-	tasha = container_of(work, struct tasha_priv,
-			     tasha_add_child_devices_work);
-	if (!tasha) {
-		pr_err("%s: Memory for WCD9335 does not exist\n",
-			__func__);
-		return;
-	}
-	wcd9xxx = tasha->wcd9xxx;
-	if (!wcd9xxx) {
-		pr_err("%s: Memory for WCD9XXX does not exist\n",
-			__func__);
-		return;
-	}
-	if (!wcd9xxx->dev->of_node) {
-		pr_err("%s: DT node for wcd9xxx does not exist\n",
-			__func__);
-		return;
-	}
-
-	platdata = &tasha->swr_plat_data;
-
-	for_each_child_of_node(wcd9xxx->dev->of_node, node) {
-		if (!strcmp(node->name, "swr_master"))
-			strlcpy(plat_dev_name, "tasha_swr_ctrl",
-				(WCD9335_STRING_LEN - 1));
-		else if (strnstr(node->name, "msm_cdc_pinctrl",
-				 strlen("msm_cdc_pinctrl")) != NULL)
-			strlcpy(plat_dev_name, node->name,
-				(WCD9335_STRING_LEN - 1));
-		else
-			continue;
-
-		pdev = platform_device_alloc(plat_dev_name, -1);
-		if (!pdev) {
-			dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
-				__func__);
-			ret = -ENOMEM;
-			goto err;
-		}
-		pdev->dev.parent = tasha->dev;
-		pdev->dev.of_node = node;
-
-		if (!strcmp(node->name, "swr_master")) {
-			ret = platform_device_add_data(pdev, platdata,
-						       sizeof(*platdata));
-			if (ret) {
-				dev_err(&pdev->dev,
-					"%s: cannot add plat data ctrl:%d\n",
-					__func__, ctrl_num);
-				goto fail_pdev_add;
-			}
-		}
-
-		ret = platform_device_add(pdev);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: Cannot add platform device\n",
-				__func__);
-			goto fail_pdev_add;
-		}
-
-		if (!strcmp(node->name, "swr_master")) {
-			temp = krealloc(swr_ctrl_data,
-					(ctrl_num + 1) * sizeof(
-					struct tasha_swr_ctrl_data),
-					GFP_KERNEL);
-			if (!temp) {
-				dev_err(wcd9xxx->dev, "out of memory\n");
-				ret = -ENOMEM;
-				goto err;
-			}
-			swr_ctrl_data = temp;
-			swr_ctrl_data[ctrl_num].swr_pdev = pdev;
-			ctrl_num++;
-			dev_dbg(&pdev->dev,
-				"%s: Added soundwire ctrl device(s)\n",
-				__func__);
-			tasha->nr = ctrl_num;
-			tasha->swr_ctrl_data = swr_ctrl_data;
-		}
-	}
-
-	return;
-fail_pdev_add:
-	platform_device_put(pdev);
-err:
-	return;
-}
-
-/*
- * tasha_codec_ver: to get tasha codec version
- * @codec: handle to snd_soc_codec *
- * return enum codec_variant - version
- */
-enum codec_variant tasha_codec_ver(void)
-{
-	return codec_ver;
-}
-EXPORT_SYMBOL(tasha_codec_ver);
-
-static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
-{
-	int val, rc;
-
-	__tasha_cdc_mclk_enable(tasha, true);
-
-	regmap_update_bits(tasha->wcd9xxx->regmap,
-			   WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
-	regmap_update_bits(tasha->wcd9xxx->regmap,
-			   WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
-
-	/*
-	 * 5ms sleep required after enabling efuse control
-	 * before checking the status.
-	 */
-	usleep_range(5000, 5500);
-	rc = regmap_read(tasha->wcd9xxx->regmap,
-			 WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
-
-	if (rc || (!(val & 0x01)))
-		WARN(1, "%s: Efuse sense is not complete\n", __func__);
-
-	__tasha_cdc_mclk_enable(tasha, false);
-
-	return rc;
-}
-
-void tasha_get_codec_ver(struct tasha_priv *tasha)
-{
-	int i;
-	int val;
-	struct tasha_reg_mask_val codec_reg[] = {
-		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
-		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
-		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
-	};
-
-	__tasha_enable_efuse_sensing(tasha);
-	for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
-		regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
-		if (!(val && codec_reg[i].val)) {
-			codec_ver = WCD9335;
-			goto ret;
-		}
-	}
-	codec_ver = WCD9326;
-ret:
-	pr_debug("%s: codec is %d\n", __func__, codec_ver);
-}
-EXPORT_SYMBOL(tasha_get_codec_ver);
-
-static int tasha_probe(struct platform_device *pdev)
-{
-	int ret = 0;
-	struct tasha_priv *tasha;
-	struct clk *wcd_ext_clk, *wcd_native_clk;
-	struct wcd9xxx_resmgr_v2 *resmgr;
-	struct wcd9xxx_power_region *cdc_pwr;
-
-	if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
-		if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
-			dev_err(&pdev->dev, "%s: dsp down\n", __func__);
-			return -EPROBE_DEFER;
-		}
-	}
-
-	tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
-			    GFP_KERNEL);
-	if (!tasha)
-		return -ENOMEM;
-	platform_set_drvdata(pdev, tasha);
-
-	tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
-	tasha->dev = &pdev->dev;
-	INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
-	mutex_init(&tasha->power_lock);
-	mutex_init(&tasha->sido_lock);
-	INIT_WORK(&tasha->tasha_add_child_devices_work,
-		  tasha_add_child_devices);
-	BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
-	mutex_init(&tasha->micb_lock);
-	mutex_init(&tasha->swr_read_lock);
-	mutex_init(&tasha->swr_write_lock);
-	mutex_init(&tasha->swr_clk_lock);
-	mutex_init(&tasha->sb_clk_gear_lock);
-	mutex_init(&tasha->mclk_lock);
-
-	cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
-			       GFP_KERNEL);
-	if (!cdc_pwr) {
-		ret = -ENOMEM;
-		goto err_cdc_pwr;
-	}
-	tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
-	cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
-	cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
-	wcd9xxx_set_power_state(tasha->wcd9xxx,
-				WCD_REGION_POWER_COLLAPSE_REMOVE,
-				WCD9XXX_DIG_CORE_REGION_1);
-
-	mutex_init(&tasha->codec_mutex);
-	/*
-	 * Init resource manager so that if child nodes such as SoundWire
-	 * requests for clock, resource manager can honor the request
-	 */
-	resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
-	if (IS_ERR(resmgr)) {
-		ret = PTR_ERR(resmgr);
-		dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
-			__func__);
-		goto err_resmgr;
-	}
-	tasha->resmgr = resmgr;
-	tasha->swr_plat_data.handle = (void *) tasha;
-	tasha->swr_plat_data.read = tasha_swrm_read;
-	tasha->swr_plat_data.write = tasha_swrm_write;
-	tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
-	tasha->swr_plat_data.clk = tasha_swrm_clock;
-	tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
-
-	/* Register for Clock */
-	wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
-	if (IS_ERR(wcd_ext_clk)) {
-		dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
-			__func__, "wcd_ext_clk");
-		goto err_clk;
-	}
-	tasha->wcd_ext_clk = wcd_ext_clk;
-	tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
-	set_bit(AUDIO_NOMINAL, &tasha->status_mask);
-	tasha->sido_ccl_cnt = 0;
-
-	/* Register native clk for 44.1 playback */
-	wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
-	if (IS_ERR(wcd_native_clk))
-		dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
-			__func__, "wcd_native_clk");
-	else
-		tasha->wcd_native_clk = wcd_native_clk;
-
-	if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-		ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
-					     tasha_dai, ARRAY_SIZE(tasha_dai));
-	else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
-		ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
-					     tasha_i2s_dai,
-					     ARRAY_SIZE(tasha_i2s_dai));
-	else
-		ret = -EINVAL;
-	if (ret) {
-		dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
-			__func__, ret);
-		goto err_cdc_reg;
-	}
-	/* Update codec register default values */
-	tasha_update_reg_defaults(tasha);
-	schedule_work(&tasha->tasha_add_child_devices_work);
-	tasha_get_codec_ver(tasha);
-
-	dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
-	return ret;
-
-err_cdc_reg:
-	clk_put(tasha->wcd_ext_clk);
-	if (tasha->wcd_native_clk)
-		clk_put(tasha->wcd_native_clk);
-err_clk:
-	wcd_resmgr_remove(tasha->resmgr);
-err_resmgr:
-	devm_kfree(&pdev->dev, cdc_pwr);
-err_cdc_pwr:
-	mutex_destroy(&tasha->mclk_lock);
-	devm_kfree(&pdev->dev, tasha);
-	return ret;
-}
-
-static int tasha_remove(struct platform_device *pdev)
-{
-	struct tasha_priv *tasha;
-
-	tasha = platform_get_drvdata(pdev);
-
-	mutex_destroy(&tasha->codec_mutex);
-	clk_put(tasha->wcd_ext_clk);
-	if (tasha->wcd_native_clk)
-		clk_put(tasha->wcd_native_clk);
-	mutex_destroy(&tasha->mclk_lock);
-	devm_kfree(&pdev->dev, tasha);
-	snd_soc_unregister_codec(&pdev->dev);
-	mutex_destroy(&tasha->sb_clk_gear_lock);
-	return 0;
-}
-
-static struct platform_driver tasha_codec_driver = {
-	.probe = tasha_probe,
-	.remove = tasha_remove,
-	.driver = {
-		.name = "tasha_codec",
-		.owner = THIS_MODULE,
-#ifdef CONFIG_PM
-		.pm = &tasha_pm_ops,
-#endif
-	},
-};
-
-module_platform_driver(tasha_codec_driver);
-
-MODULE_DESCRIPTION("Tasha Codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd9335.h b/sound/soc/codecs/wcd9335.h
deleted file mode 100644
index c76461e..0000000
--- a/sound/soc/codecs/wcd9335.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WCD9335_H
-#define WCD9335_H
-
-#include <sound/soc.h>
-#include <sound/jack.h>
-#include <sound/apr_audio-v2.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
-#include "wcd-mbhc-v2.h"
-
-#define TASHA_REG_VAL(reg, val)      {reg, 0, val}
-
-#define TASHA_REGISTER_START_OFFSET  0x800
-#define TASHA_SB_PGD_PORT_RX_BASE   0x40
-#define TASHA_SB_PGD_PORT_TX_BASE   0x50
-
-#define TASHA_ZDET_SUPPORTED true
-/* z value defined in milliohm */
-#define TASHA_ZDET_VAL_32	32000
-#define TASHA_ZDET_VAL_400	400000
-#define TASHA_ZDET_VAL_1200	1200000
-#define TASHA_ZDET_VAL_100K	100000000
-/* z floating defined in ohms */
-#define TASHA_ZDET_FLOATING_IMPEDANCE 0x0FFFFFFE
-
-#define WCD9335_DMIC_CLK_DIV_2  0x0
-#define WCD9335_DMIC_CLK_DIV_3  0x1
-#define WCD9335_DMIC_CLK_DIV_4  0x2
-#define WCD9335_DMIC_CLK_DIV_6  0x3
-#define WCD9335_DMIC_CLK_DIV_8  0x4
-#define WCD9335_DMIC_CLK_DIV_16  0x5
-#define WCD9335_DMIC_CLK_DRIVE_DEFAULT 0x02
-
-#define WCD9335_ANC_DMIC_X2_FULL_RATE 1
-#define WCD9335_ANC_DMIC_X2_HALF_RATE 0
-
-/* Number of input and output Slimbus port */
-enum {
-	TASHA_RX0 = 0,
-	TASHA_RX1,
-	TASHA_RX2,
-	TASHA_RX3,
-	TASHA_RX4,
-	TASHA_RX5,
-	TASHA_RX6,
-	TASHA_RX7,
-	TASHA_RX8,
-	TASHA_RX9,
-	TASHA_RX10,
-	TASHA_RX11,
-	TASHA_RX12,
-	TASHA_RX_MAX,
-};
-
-enum {
-	TASHA_TX0 = 0,
-	TASHA_TX1,
-	TASHA_TX2,
-	TASHA_TX3,
-	TASHA_TX4,
-	TASHA_TX5,
-	TASHA_TX6,
-	TASHA_TX7,
-	TASHA_TX8,
-	TASHA_TX9,
-	TASHA_TX10,
-	TASHA_TX11,
-	TASHA_TX12,
-	TASHA_TX13,
-	TASHA_TX14,
-	TASHA_TX15,
-	TASHA_TX_MAX,
-};
-
-enum wcd9335_codec_event {
-	WCD9335_CODEC_EVENT_CODEC_UP = 0,
-};
-
-enum tasha_on_demand_supply {
-	ON_DEMAND_MICBIAS = 0,
-	ON_DEMAND_SUPPLIES_MAX,
-};
-
-/* structure used to put the defined
- * ondemand supply for codec
- * and count being used.
- */
-struct on_demand_supply {
-	struct regulator *supply;
-	int ondemand_supply_count;
-};
-
-/* Dai data structure holds the
- * dai specific info like rate,
- * channel number etc.
- */
-struct tasha_codec_dai_data {
-	u32 rate;
-	u32 *ch_num;
-	u32 ch_act;
-	u32 ch_tot;
-};
-
-/* Structure used to update codec
- * register defaults after reset
- */
-struct tasha_reg_mask_val {
-	u16 reg;
-	u8 mask;
-	u8 val;
-};
-
-/* Selects compander and smart boost settings
- * for a given speaker mode
- */
-enum {
-	SPKR_MODE_DEFAULT,
-	SPKR_MODE_1,          /* COMP Gain = 12dB, Smartboost Max = 5.5V */
-};
-
-/*
- * Rx path gain offsets
- */
-enum {
-	RX_GAIN_OFFSET_M1P5_DB,
-	RX_GAIN_OFFSET_0_DB,
-};
-
-extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
-				  enum afe_config_type config_type);
-extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
-				 bool dapm);
-extern int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable,
-				    bool dapm);
-extern int tasha_enable_efuse_sensing(struct snd_soc_codec *codec);
-extern int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
-				struct wcd_mbhc_config *mbhc_cfg);
-extern void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
-extern void tasha_mbhc_zdet_gpio_ctrl(
-		int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
-		struct snd_soc_codec *codec);
-extern int tasha_codec_info_create_codec_entry(
-		struct snd_info_entry *codec_root,
-		struct snd_soc_codec *codec);
-extern void tasha_event_register(
-	int (*machine_event_cb)(struct snd_soc_codec *codec,
-				enum wcd9335_codec_event),
-	struct snd_soc_codec *codec);
-extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
-						 int micb_num,
-						 bool enable);
-extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
-extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
-extern enum codec_variant tasha_codec_ver(void);
-#endif
diff --git a/sound/soc/codecs/wcd934x/Makefile b/sound/soc/codecs/wcd934x/Makefile
deleted file mode 100644
index 12781f6..0000000
--- a/sound/soc/codecs/wcd934x/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile for wcd934x codec driver.
-#
-snd-soc-wcd934x-objs := wcd934x.o wcd934x-dsp-cntl.o \
-			wcd934x-mbhc.o wcd934x-dsd.o
-obj-$(CONFIG_SND_SOC_WCD934X) += snd-soc-wcd934x.o
diff --git a/sound/soc/codecs/wcd934x/wcd934x-dsd.c b/sound/soc/codecs/wcd934x/wcd934x-dsd.c
deleted file mode 100644
index 3e23e37..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-dsd.c
+++ /dev/null
@@ -1,772 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <sound/tlv.h>
-#include <sound/control.h>
-#include "wcd934x-dsd.h"
-
-#define DSD_VOLUME_MAX_0dB      0
-#define DSD_VOLUME_MIN_M110dB   -110
-
-#define DSD_VOLUME_RANGE_CHECK(x)   ((x >= DSD_VOLUME_MIN_M110dB) &&\
-				     (x <= DSD_VOLUME_MAX_0dB))
-#define DSD_VOLUME_STEPS            3
-#define DSD_VOLUME_UPDATE_DELAY_MS  30
-#define DSD_VOLUME_USLEEP_MARGIN_US 100
-#define DSD_VOLUME_STEP_DELAY_US    ((1000 * DSD_VOLUME_UPDATE_DELAY_MS) / \
-				     (2 * DSD_VOLUME_STEPS))
-
-#define TAVIL_VERSION_1_0  0
-#define TAVIL_VERSION_1_1  1
-
-static const DECLARE_TLV_DB_MINMAX(tavil_dsd_db_scale, DSD_VOLUME_MIN_M110dB,
-				   DSD_VOLUME_MAX_0dB);
-
-static const char *const dsd_if_text[] = {
-	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7",
-	"DSD_DATA_PAD"
-};
-
-static const char * const dsd_filt0_mux_text[] = {
-	"ZERO", "DSD_L IF MUX",
-};
-
-static const char * const dsd_filt1_mux_text[] = {
-	"ZERO", "DSD_R IF MUX",
-};
-
-static const struct soc_enum dsd_filt0_mux_enum =
-	SOC_ENUM_SINGLE(WCD934X_CDC_DSD0_PATH_CTL, 0,
-			ARRAY_SIZE(dsd_filt0_mux_text), dsd_filt0_mux_text);
-
-static const struct soc_enum dsd_filt1_mux_enum =
-	SOC_ENUM_SINGLE(WCD934X_CDC_DSD1_PATH_CTL, 0,
-			ARRAY_SIZE(dsd_filt1_mux_text), dsd_filt1_mux_text);
-
-static SOC_ENUM_SINGLE_DECL(dsd_l_if_enum, WCD934X_CDC_DSD0_CFG0,
-			    2, dsd_if_text);
-static SOC_ENUM_SINGLE_DECL(dsd_r_if_enum, WCD934X_CDC_DSD1_CFG0,
-			    2, dsd_if_text);
-
-static const struct snd_kcontrol_new dsd_filt0_mux =
-		SOC_DAPM_ENUM("DSD Filt0 Mux", dsd_filt0_mux_enum);
-
-static const struct snd_kcontrol_new dsd_filt1_mux =
-		SOC_DAPM_ENUM("DSD Filt1 Mux", dsd_filt1_mux_enum);
-
-static const struct snd_kcontrol_new dsd_l_if_mux =
-		SOC_DAPM_ENUM("DSD Left If Mux", dsd_l_if_enum);
-static const struct snd_kcontrol_new dsd_r_if_mux =
-		SOC_DAPM_ENUM("DSD Right If Mux", dsd_r_if_enum);
-
-static const struct snd_soc_dapm_route tavil_dsd_audio_map[] = {
-	{"DSD_L IF MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"DSD_L IF MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"DSD_L IF MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"DSD_L IF MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"DSD_L IF MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"DSD_L IF MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"DSD_L IF MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"DSD_L IF MUX", "RX7", "CDC_IF RX7 MUX"},
-
-	{"DSD_FILTER_0", NULL, "DSD_L IF MUX"},
-	{"DSD_FILTER_0", NULL, "RX INT1 NATIVE SUPPLY"},
-	{"RX INT1 MIX3", "DSD HPHL Switch", "DSD_FILTER_0"},
-
-	{"DSD_R IF MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"DSD_R IF MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"DSD_R IF MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"DSD_R IF MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"DSD_R IF MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"DSD_R IF MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"DSD_R IF MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"DSD_R IF MUX", "RX7", "CDC_IF RX7 MUX"},
-
-	{"DSD_FILTER_1", NULL, "DSD_R IF MUX"},
-	{"DSD_FILTER_1", NULL, "RX INT2 NATIVE SUPPLY"},
-	{"RX INT2 MIX3", "DSD HPHR Switch", "DSD_FILTER_1"},
-
-	{"DSD_FILTER_0", NULL, "RX INT3 NATIVE SUPPLY"},
-	{"RX INT3 MIX3", "DSD LO1 Switch", "DSD_FILTER_0"},
-	{"DSD_FILTER_1", NULL, "RX INT4 NATIVE SUPPLY"},
-	{"RX INT4 MIX3", "DSD LO2 Switch", "DSD_FILTER_1"},
-};
-
-static bool is_valid_dsd_interpolator(int interp_num)
-{
-	if ((interp_num == INTERP_HPHL) || (interp_num == INTERP_HPHR) ||
-	    (interp_num == INTERP_LO1) || (interp_num == INTERP_LO2))
-		return true;
-
-	return false;
-}
-
-/**
- * tavil_dsd_set_mixer_value - Set DSD HPH/LO mixer value
- *
- * @dsd_conf: pointer to dsd config
- * @interp_num: Interpolator number (HPHL/R, LO1/2)
- * @sw_value: Mixer switch value
- *
- * Returns 0 on success or -EINVAL on failure
- */
-int tavil_dsd_set_mixer_value(struct tavil_dsd_config *dsd_conf,
-			      int interp_num, int sw_value)
-{
-	if (!dsd_conf)
-		return -EINVAL;
-
-	if (!is_valid_dsd_interpolator(interp_num))
-		return -EINVAL;
-
-	dsd_conf->dsd_interp_mixer[interp_num] = !!sw_value;
-
-	return 0;
-}
-EXPORT_SYMBOL(tavil_dsd_set_mixer_value);
-
-/**
- * tavil_dsd_get_current_mixer_value - Get DSD HPH/LO mixer value
- *
- * @dsd_conf: pointer to dsd config
- * @interp_num: Interpolator number (HPHL/R, LO1/2)
- *
- * Returns current mixer val for success or -EINVAL for failure
- */
-int tavil_dsd_get_current_mixer_value(struct tavil_dsd_config *dsd_conf,
-				      int interp_num)
-{
-	if (!dsd_conf)
-		return -EINVAL;
-
-	if (!is_valid_dsd_interpolator(interp_num))
-		return -EINVAL;
-
-	return dsd_conf->dsd_interp_mixer[interp_num];
-}
-EXPORT_SYMBOL(tavil_dsd_get_current_mixer_value);
-
-/**
- * tavil_dsd_set_out_select - DSD0/1 out select to HPH or LO
- *
- * @dsd_conf: pointer to dsd config
- * @interp_num: Interpolator number (HPHL/R, LO1/2)
- *
- * Returns 0 for success or -EINVAL for failure
- */
-int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
-			     int interp_num)
-{
-	unsigned int reg, val;
-	struct snd_soc_codec *codec;
-
-	if (!dsd_conf || !dsd_conf->codec)
-		return -EINVAL;
-
-	codec = dsd_conf->codec;
-
-	if (!is_valid_dsd_interpolator(interp_num)) {
-		dev_err(codec->dev, "%s: Invalid Interpolator: %d for DSD\n",
-			__func__, interp_num);
-		return -EINVAL;
-	}
-
-	switch (interp_num) {
-	case INTERP_HPHL:
-		reg = WCD934X_CDC_DSD0_CFG0;
-		val = 0x00;
-		break;
-	case INTERP_HPHR:
-		reg = WCD934X_CDC_DSD1_CFG0;
-		val = 0x00;
-		break;
-	case INTERP_LO1:
-		reg = WCD934X_CDC_DSD0_CFG0;
-		val = 0x02;
-		break;
-	case INTERP_LO2:
-		reg = WCD934X_CDC_DSD1_CFG0;
-		val = 0x02;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	snd_soc_update_bits(codec, reg, 0x02, val);
-
-	return 0;
-}
-EXPORT_SYMBOL(tavil_dsd_set_out_select);
-
-/**
- * tavil_dsd_reset - Reset DSD block
- *
- * @dsd_conf: pointer to dsd config
- *
- */
-void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf)
-{
-	if (!dsd_conf || !dsd_conf->codec)
-		return;
-
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL,
-			    0x02, 0x02);
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL,
-			    0x01, 0x00);
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
-			    0x02, 0x02);
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
-			    0x01, 0x00);
-}
-EXPORT_SYMBOL(tavil_dsd_reset);
-
-/**
- * tavil_dsd_set_interp_rate - Set interpolator rate for DSD
- *
- * @dsd_conf: pointer to dsd config
- * @rx_port: RX port number
- * @sample_rate: Sample rate of the RX interpolator
- * @sample_rate_val: Interpolator rate value
- */
-void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
-			       u32 sample_rate, u8 sample_rate_val)
-{
-	u8 dsd_inp_sel;
-	u8 dsd0_inp, dsd1_inp;
-	u8 val0, val1;
-	u8 dsd0_out_sel, dsd1_out_sel;
-	u16 int_fs_reg, interp_num = 0;
-	struct snd_soc_codec *codec;
-
-	if (!dsd_conf || !dsd_conf->codec)
-		return;
-
-	codec = dsd_conf->codec;
-
-	dsd_inp_sel = DSD_INP_SEL_RX0 + rx_port - WCD934X_RX_PORT_START_NUMBER;
-
-	val0 = snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0);
-	val1 = snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0);
-	dsd0_inp = (val0 & 0x3C) >> 2;
-	dsd1_inp = (val1 & 0x3C) >> 2;
-	dsd0_out_sel = (val0 & 0x02) >> 1;
-	dsd1_out_sel = (val1 & 0x02) >> 1;
-
-	/* Set HPHL or LO1 interp rate based on out select */
-	if (dsd_inp_sel == dsd0_inp) {
-		interp_num = dsd0_out_sel ? INTERP_LO1 : INTERP_HPHL;
-		dsd_conf->base_sample_rate[DSD0] = sample_rate;
-	}
-
-	/* Set HPHR or LO2 interp rate based on out select */
-	if (dsd_inp_sel == dsd1_inp) {
-		interp_num = dsd1_out_sel ? INTERP_LO2 : INTERP_HPHR;
-		dsd_conf->base_sample_rate[DSD1] = sample_rate;
-	}
-
-	if (interp_num) {
-		int_fs_reg = WCD934X_CDC_RX0_RX_PATH_CTL + 20 * interp_num;
-		if ((snd_soc_read(codec, int_fs_reg) & 0x0f) < 0x09) {
-			dev_dbg(codec->dev, "%s: Set Interp %d to sample_rate val 0x%x\n",
-				__func__, interp_num, sample_rate_val);
-			snd_soc_update_bits(codec, int_fs_reg, 0x0F,
-					    sample_rate_val);
-		}
-	}
-}
-EXPORT_SYMBOL(tavil_dsd_set_interp_rate);
-
-static int tavil_set_dsd_mode(struct snd_soc_codec *codec, int dsd_num,
-			      u8 *pcm_rate_val)
-{
-	unsigned int dsd_out_sel_reg;
-	u8 dsd_mode;
-	u32 sample_rate;
-	struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
-
-	if (!dsd_conf)
-		return -EINVAL;
-
-	if ((dsd_num < 0) || (dsd_num > 1))
-		return -EINVAL;
-
-	sample_rate = dsd_conf->base_sample_rate[dsd_num];
-	dsd_out_sel_reg = WCD934X_CDC_DSD0_CFG0 + dsd_num * 16;
-
-	switch (sample_rate) {
-	case 176400:
-		dsd_mode = 0; /* DSD_64 */
-		*pcm_rate_val = 0xb;
-		break;
-	case 352800:
-		dsd_mode = 1; /* DSD_128 */
-		*pcm_rate_val = 0xc;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid DSD rate: %d\n",
-			__func__, sample_rate);
-		return -EINVAL;
-	}
-
-	snd_soc_update_bits(codec, dsd_out_sel_reg, 0x01, dsd_mode);
-
-	return 0;
-}
-
-static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num,
-				u8 pcm_rate_val, bool enable)
-{
-	u8 clk_en, mute_en;
-	u8 dsd_inp_sel;
-
-	if (enable) {
-		clk_en = 0x20;
-		mute_en = 0x10;
-	} else {
-		clk_en = 0x00;
-		mute_en = 0x00;
-	}
-
-	if (dsd_num & 0x01) {
-		snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
-				    0x20, clk_en);
-		dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) &
-				0x3C) >> 2;
-		dsd_inp_sel = (enable) ? dsd_inp_sel : 0;
-		if (dsd_inp_sel < 9) {
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1,
-					0x0F, dsd_inp_sel);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
-					0x0F, pcm_rate_val);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
-					0x10, mute_en);
-		}
-	}
-	if (dsd_num & 0x02) {
-		snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
-				    0x20, clk_en);
-		dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) &
-				0x3C) >> 2;
-		dsd_inp_sel = (enable) ? dsd_inp_sel : 0;
-		if (dsd_inp_sel < 9) {
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1,
-					0x0F, dsd_inp_sel);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
-					0x0F, pcm_rate_val);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
-					0x10, mute_en);
-		}
-	}
-}
-
-static void tavil_dsd_update_volume(struct tavil_dsd_config *dsd_conf)
-{
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
-			    0x01, 0x01);
-	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
-			    0x01, 0x00);
-}
-
-static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
-			    struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
-	int rc, clk_users;
-	int interp_idx;
-	u8 pcm_rate_val;
-
-	if (!dsd_conf) {
-		dev_err(codec->dev, "%s: null dsd_config pointer\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(codec->dev, "%s: DSD%d, event: %d\n", __func__,
-		w->shift, event);
-
-	if (w->shift == DSD0) {
-		/* Read out select */
-		if (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & 0x02)
-			interp_idx = INTERP_LO1;
-		else
-			interp_idx = INTERP_HPHL;
-	} else if (w->shift == DSD1) {
-		/* Read out select */
-		if (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & 0x02)
-			interp_idx = INTERP_LO2;
-		else
-			interp_idx = INTERP_HPHR;
-	} else {
-		dev_err(codec->dev, "%s: Unsupported DSD:%d\n",
-			__func__, w->shift);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		clk_users = tavil_codec_enable_interp_clk(codec, event,
-							  interp_idx);
-
-		rc = tavil_set_dsd_mode(codec, w->shift, &pcm_rate_val);
-		if (rc)
-			return rc;
-
-		tavil_dsd_data_pull(codec, (1 << w->shift), pcm_rate_val,
-				    true);
-
-		snd_soc_update_bits(codec,
-				    WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL, 0x01,
-				    0x01);
-		if (w->shift == DSD0) {
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
-					    0x02, 0x02);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
-					    0x02, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
-					    0x01, 0x01);
-			/* Apply Gain */
-			snd_soc_write(codec, WCD934X_CDC_DSD0_CFG1,
-				      dsd_conf->volume[DSD0]);
-			if (dsd_conf->version == TAVIL_VERSION_1_1)
-				tavil_dsd_update_volume(dsd_conf);
-
-		} else if (w->shift == DSD1) {
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
-					    0x02, 0x02);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
-					    0x02, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
-					    0x01, 0x01);
-			/* Apply Gain */
-			snd_soc_write(codec, WCD934X_CDC_DSD1_CFG1,
-				      dsd_conf->volume[DSD1]);
-			if (dsd_conf->version == TAVIL_VERSION_1_1)
-				tavil_dsd_update_volume(dsd_conf);
-		}
-		/* 10msec sleep required after DSD clock is set */
-		usleep_range(10000, 10100);
-
-		if (clk_users > 1) {
-			snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
-					    0x02, 0x02);
-			if (w->shift == DSD0)
-				snd_soc_update_bits(codec,
-						    WCD934X_CDC_DSD0_CFG2,
-						    0x04, 0x00);
-			if (w->shift == DSD1)
-				snd_soc_update_bits(codec,
-						    WCD934X_CDC_DSD1_CFG2,
-						    0x04, 0x00);
-
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (w->shift == DSD0) {
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2,
-					    0x04, 0x04);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
-					    0x01, 0x00);
-		} else if (w->shift == DSD1) {
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2,
-					    0x04, 0x04);
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
-					    0x01, 0x00);
-		}
-
-		tavil_codec_enable_interp_clk(codec, event, interp_idx);
-
-		if (!(snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01) &&
-		    !(snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) {
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL,
-					0x01, 0x00);
-			tavil_dsd_data_pull(codec, 0x03, 0x04, false);
-			tavil_dsd_reset(dsd_conf);
-		}
-		break;
-	}
-
-	return 0;
-}
-
-static int tavil_dsd_vol_info(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 2;
-	uinfo->value.integer.min = DSD_VOLUME_MIN_M110dB;
-	uinfo->value.integer.max = DSD_VOLUME_MAX_0dB;
-
-	return 0;
-}
-
-static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
-	int nv[DSD_MAX], cv[DSD_MAX];
-	int step_size, nv1;
-	int i, dsd_idx;
-
-	if (!dsd_conf)
-		return 0;
-
-	mutex_lock(&dsd_conf->vol_mutex);
-
-	for (dsd_idx = DSD0; dsd_idx < DSD_MAX; dsd_idx++) {
-		cv[dsd_idx] = dsd_conf->volume[dsd_idx];
-		nv[dsd_idx] = ucontrol->value.integer.value[dsd_idx];
-	}
-
-	if ((!DSD_VOLUME_RANGE_CHECK(nv[DSD0])) ||
-	    (!DSD_VOLUME_RANGE_CHECK(nv[DSD1])))
-		goto done;
-
-	for (dsd_idx = DSD0; dsd_idx < DSD_MAX; dsd_idx++) {
-		if (cv[dsd_idx] == nv[dsd_idx])
-			continue;
-
-		dev_dbg(codec->dev, "%s: DSD%d cur.vol: %d, new vol: %d\n",
-			__func__, dsd_idx, cv[dsd_idx], nv[dsd_idx]);
-
-		step_size =  (nv[dsd_idx] - cv[dsd_idx]) /
-			      DSD_VOLUME_STEPS;
-
-		nv1 = cv[dsd_idx];
-
-		for (i = 0; i < DSD_VOLUME_STEPS; i++) {
-			nv1 += step_size;
-			snd_soc_write(codec,
-				      WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
-				      nv1);
-			if (dsd_conf->version == TAVIL_VERSION_1_1)
-				tavil_dsd_update_volume(dsd_conf);
-
-			/* sleep required after each volume step */
-			usleep_range(DSD_VOLUME_STEP_DELAY_US,
-				     (DSD_VOLUME_STEP_DELAY_US +
-				      DSD_VOLUME_USLEEP_MARGIN_US));
-		}
-		if (nv1 != nv[dsd_idx]) {
-			snd_soc_write(codec,
-				      WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
-				      nv[dsd_idx]);
-
-			if (dsd_conf->version == TAVIL_VERSION_1_1)
-				tavil_dsd_update_volume(dsd_conf);
-		}
-
-		dsd_conf->volume[dsd_idx] = nv[dsd_idx];
-	}
-
-done:
-	mutex_unlock(&dsd_conf->vol_mutex);
-
-	return 0;
-}
-
-static int tavil_dsd_vol_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
-
-	if (dsd_conf) {
-		ucontrol->value.integer.value[0] = dsd_conf->volume[DSD0];
-		ucontrol->value.integer.value[1] = dsd_conf->volume[DSD1];
-	}
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new tavil_dsd_vol_controls[] = {
-	{
-	   .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	   .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
-		      SNDRV_CTL_ELEM_ACCESS_TLV_READ),
-	   .name = "DSD Volume",
-	   .info = tavil_dsd_vol_info,
-	   .get = tavil_dsd_vol_get,
-	   .put = tavil_dsd_vol_put,
-	   .tlv = { .p = tavil_dsd_db_scale },
-	},
-};
-
-static const struct snd_soc_dapm_widget tavil_dsd_widgets[] = {
-	SND_SOC_DAPM_MUX("DSD_L IF MUX", SND_SOC_NOPM, 0, 0, &dsd_l_if_mux),
-	SND_SOC_DAPM_MUX_E("DSD_FILTER_0", SND_SOC_NOPM, 0, 0, &dsd_filt0_mux,
-			   tavil_enable_dsd,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX("DSD_R IF MUX", SND_SOC_NOPM, 0, 0, &dsd_r_if_mux),
-	SND_SOC_DAPM_MUX_E("DSD_FILTER_1", SND_SOC_NOPM, 1, 0, &dsd_filt1_mux,
-			   tavil_enable_dsd,
-			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-};
-
-/**
- * tavil_dsd_post_ssr_init - DSD intialization after subsystem restart
- *
- * @codec: pointer to snd_soc_codec
- *
- * Returns 0 on success or error on failure
- */
-int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_conf)
-{
-	struct snd_soc_codec *codec;
-
-	if (!dsd_conf || !dsd_conf->codec)
-		return -EINVAL;
-
-	codec = dsd_conf->codec;
-	/* Disable DSD Interrupts */
-	snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08);
-
-	/* DSD registers init */
-	if (dsd_conf->version == TAVIL_VERSION_1_0) {
-		snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00);
-	}
-	/* DSD0: Mute EN */
-	snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04);
-	/* DSD1: Mute EN */
-	snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10,
-			    0x10);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10,
-			    0x10);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E,
-			    0x0A);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E,
-			    0x0A);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07,
-			    0x04);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07,
-			    0x04);
-
-	/* Enable DSD Interrupts */
-	snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00);
-
-	return 0;
-}
-EXPORT_SYMBOL(tavil_dsd_post_ssr_init);
-
-/**
- * tavil_dsd_init - DSD intialization
- *
- * @codec: pointer to snd_soc_codec
- *
- * Returns pointer to tavil_dsd_config for success or NULL for failure
- */
-struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)
-{
-	struct snd_soc_dapm_context *dapm;
-	struct tavil_dsd_config *dsd_conf;
-	u8 val;
-
-	if (!codec)
-		return NULL;
-
-	dapm = snd_soc_codec_get_dapm(codec);
-
-	/* Read efuse register to check if DSD is supported */
-	val = snd_soc_read(codec, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14);
-	if (val & 0x80) {
-		dev_info(codec->dev, "%s: DSD unsupported for this codec version\n",
-			 __func__);
-		return NULL;
-	}
-
-	dsd_conf = devm_kzalloc(codec->dev, sizeof(struct tavil_dsd_config),
-				GFP_KERNEL);
-	if (!dsd_conf)
-		return NULL;
-
-	dsd_conf->codec = codec;
-
-	/* Read version */
-	dsd_conf->version = snd_soc_read(codec,
-					 WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0);
-	/* DSD registers init */
-	if (dsd_conf->version == TAVIL_VERSION_1_0) {
-		snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00);
-	}
-	/* DSD0: Mute EN */
-	snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04);
-	/* DSD1: Mute EN */
-	snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10,
-			    0x10);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10,
-			    0x10);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E,
-			    0x0A);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E,
-			    0x0A);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07,
-			    0x04);
-	snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07,
-			    0x04);
-
-	snd_soc_dapm_new_controls(dapm, tavil_dsd_widgets,
-				  ARRAY_SIZE(tavil_dsd_widgets));
-
-	snd_soc_dapm_add_routes(dapm, tavil_dsd_audio_map,
-				ARRAY_SIZE(tavil_dsd_audio_map));
-
-	mutex_init(&dsd_conf->vol_mutex);
-	dsd_conf->volume[DSD0] = DSD_VOLUME_MAX_0dB;
-	dsd_conf->volume[DSD1] = DSD_VOLUME_MAX_0dB;
-
-	snd_soc_add_codec_controls(codec, tavil_dsd_vol_controls,
-				   ARRAY_SIZE(tavil_dsd_vol_controls));
-
-	/* Enable DSD Interrupts */
-	snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00);
-
-	return dsd_conf;
-}
-EXPORT_SYMBOL(tavil_dsd_init);
-
-/**
- * tavil_dsd_deinit - DSD de-intialization
- *
- * @dsd_conf: pointer to tavil_dsd_config
- */
-void tavil_dsd_deinit(struct tavil_dsd_config *dsd_conf)
-{
-	struct snd_soc_codec *codec;
-
-	if (!dsd_conf)
-		return;
-
-	codec = dsd_conf->codec;
-
-	mutex_destroy(&dsd_conf->vol_mutex);
-
-	/* Disable DSD Interrupts */
-	snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08);
-
-	devm_kfree(codec->dev, dsd_conf);
-}
-EXPORT_SYMBOL(tavil_dsd_deinit);
diff --git a/sound/soc/codecs/wcd934x/wcd934x-dsd.h b/sound/soc/codecs/wcd934x/wcd934x-dsd.h
deleted file mode 100644
index 834b96c..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-dsd.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD934X_DSD_H__
-#define __WCD934X_DSD_H__
-
-#include <sound/soc.h>
-#include "wcd934x.h"
-
-enum {
-	DSD0,
-	DSD1,
-	DSD_MAX,
-};
-
-enum {
-	DSD_INP_SEL_ZERO = 0,
-	DSD_INP_SEL_RX0,
-	DSD_INP_SEL_RX1,
-	DSD_INP_SEL_RX2,
-	DSD_INP_SEL_RX3,
-	DSD_INP_SEL_RX4,
-	DSD_INP_SEL_RX5,
-	DSD_INP_SEL_RX6,
-	DSD_INP_SEL_RX7,
-};
-
-struct tavil_dsd_config {
-	struct snd_soc_codec *codec;
-	unsigned int dsd_interp_mixer[INTERP_MAX];
-	u32 base_sample_rate[DSD_MAX];
-	int volume[DSD_MAX];
-	struct mutex vol_mutex;
-	int version;
-};
-
-#if IS_ENABLED(CONFIG_SND_SOC_WCD934X_DSD)
-int tavil_dsd_set_mixer_value(struct tavil_dsd_config *dsd_conf,
-			      int interp_num, int sw_value);
-int tavil_dsd_get_current_mixer_value(struct tavil_dsd_config *dsd_conf,
-				      int interp_num);
-int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
-			     int interp_num);
-void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf);
-void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
-			       u32 sample_rate, u8 sample_rate_val);
-struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec);
-void tavil_dsd_deinit(struct tavil_dsd_config *dsd_config);
-int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_config);
-#else
-int tavil_dsd_set_mixer_value(struct tavil_dsd_config *dsd_conf,
-			      int interp_num, int sw_value)
-{
-	return 0;
-}
-
-int tavil_dsd_get_current_mixer_value(struct tavil_dsd_config *dsd_conf,
-				      int interp_num)
-{
-	return 0;
-}
-
-int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
-			     int interp_num)
-{
-	return 0;
-}
-
-void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf)
-{  }
-
-void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
-			       u32 sample_rate, u8 sample_rate_val)
-{  }
-
-struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)
-{
-	return NULL;
-}
-
-void tavil_dsd_deinit(struct tavil_dsd_config *dsd_config)
-{  }
-int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_config)
-{
-	return 0;
-}
-#endif
-#endif
diff --git a/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.c b/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.c
deleted file mode 100644
index b62f26c..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.c
+++ /dev/null
@@ -1,1369 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/component.h>
-#include <linux/debugfs.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <sound/soc.h>
-#include <sound/wcd-dsp-mgr.h>
-#include "wcd934x.h"
-#include "wcd934x-dsp-cntl.h"
-
-#define WCD_CNTL_DIR_NAME_LEN_MAX 32
-#define WCD_CPE_FLL_MAX_RETRIES 5
-#define WCD_MEM_ENABLE_MAX_RETRIES 20
-#define WCD_DSP_BOOT_TIMEOUT_MS 3000
-#define WCD_SYSFS_ENTRY_MAX_LEN 8
-#define WCD_PROCFS_ENTRY_MAX_LEN 16
-#define WCD_934X_RAMDUMP_START_ADDR 0x20100000
-#define WCD_934X_RAMDUMP_SIZE ((1024 * 1024) - 128)
-
-#define WCD_CNTL_MUTEX_LOCK(codec, lock)             \
-{                                                    \
-	dev_dbg(codec->dev, "%s: mutex_lock(%s)\n",  \
-		__func__, __stringify_1(lock));      \
-	mutex_lock(&lock);                           \
-}
-
-#define WCD_CNTL_MUTEX_UNLOCK(codec, lock)            \
-{                                                     \
-	dev_dbg(codec->dev, "%s: mutex_unlock(%s)\n", \
-		__func__, __stringify_1(lock));       \
-	mutex_unlock(&lock);                          \
-}
-
-enum wcd_mem_type {
-	WCD_MEM_TYPE_ALWAYS_ON,
-	WCD_MEM_TYPE_SWITCHABLE,
-};
-
-struct wcd_cntl_attribute {
-	struct attribute attr;
-	ssize_t (*show)(struct wcd_dsp_cntl *cntl, char *buf);
-	ssize_t (*store)(struct wcd_dsp_cntl *cntl, const char *buf,
-			 ssize_t count);
-};
-
-#define WCD_CNTL_ATTR(_name, _mode, _show, _store) \
-static struct wcd_cntl_attribute cntl_attr_##_name = {	\
-	.attr = {.name = __stringify(_name), .mode = _mode},	\
-	.show = _show,	\
-	.store = _store,	\
-}
-
-#define to_wcd_cntl_attr(a) \
-	container_of((a), struct wcd_cntl_attribute, attr)
-
-#define to_wcd_cntl(kobj) \
-	container_of((kobj), struct wcd_dsp_cntl, wcd_kobj)
-
-static u8 mem_enable_values[] = {
-	0xFE, 0xFC, 0xF8, 0xF0,
-	0xE0, 0xC0, 0x80, 0x00,
-};
-
-static ssize_t wdsp_boot_show(struct wcd_dsp_cntl *cntl, char *buf)
-{
-	return snprintf(buf, WCD_SYSFS_ENTRY_MAX_LEN,
-			"%u", cntl->boot_reqs);
-}
-
-static ssize_t wdsp_boot_store(struct wcd_dsp_cntl *cntl,
-			       const char *buf, ssize_t count)
-{
-	u32 val;
-	bool vote;
-	int ret;
-
-	ret = kstrtou32(buf, 10, &val);
-	if (ret) {
-		dev_err(cntl->codec->dev,
-			"%s: Invalid entry, ret = %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	if (val > 0) {
-		cntl->boot_reqs++;
-		vote = true;
-	} else {
-		cntl->boot_reqs--;
-		vote = false;
-	}
-
-	if (cntl->m_dev && cntl->m_ops &&
-	    cntl->m_ops->vote_for_dsp)
-		ret = cntl->m_ops->vote_for_dsp(cntl->m_dev, vote);
-	else
-		ret = -EINVAL;
-
-	if (ret < 0)
-		dev_err(cntl->codec->dev,
-			"%s: failed to %s dsp\n", __func__,
-			vote ? "enable" : "disable");
-	return count;
-}
-
-WCD_CNTL_ATTR(boot, 0660, wdsp_boot_show, wdsp_boot_store);
-
-static ssize_t wcd_cntl_sysfs_show(struct kobject *kobj,
-				   struct attribute *attr, char *buf)
-{
-	struct wcd_cntl_attribute *wcd_attr = to_wcd_cntl_attr(attr);
-	struct wcd_dsp_cntl *cntl = to_wcd_cntl(kobj);
-	ssize_t ret = -EINVAL;
-
-	if (cntl && wcd_attr->show)
-		ret = wcd_attr->show(cntl, buf);
-
-	return ret;
-}
-
-static ssize_t wcd_cntl_sysfs_store(struct kobject *kobj,
-				    struct attribute *attr, const char *buf,
-				    size_t count)
-{
-	struct wcd_cntl_attribute *wcd_attr = to_wcd_cntl_attr(attr);
-	struct wcd_dsp_cntl *cntl = to_wcd_cntl(kobj);
-	ssize_t ret = -EINVAL;
-
-	if (cntl && wcd_attr->store)
-		ret = wcd_attr->store(cntl, buf, count);
-
-	return ret;
-}
-
-static const struct sysfs_ops wcd_cntl_sysfs_ops = {
-	.show = wcd_cntl_sysfs_show,
-	.store = wcd_cntl_sysfs_store,
-};
-
-static struct kobj_type wcd_cntl_ktype = {
-	.sysfs_ops = &wcd_cntl_sysfs_ops,
-};
-
-static void wcd_cntl_change_online_state(struct wcd_dsp_cntl *cntl,
-					 u8 online)
-{
-	struct wdsp_ssr_entry *ssr_entry = &cntl->ssr_entry;
-	unsigned long ret;
-
-	WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex);
-	ssr_entry->offline = !online;
-	/* Make sure the write is complete */
-	wmb();
-	ret = xchg(&ssr_entry->offline_change, 1);
-	wake_up_interruptible(&ssr_entry->offline_poll_wait);
-	dev_dbg(cntl->codec->dev,
-		"%s: requested %u, offline %u offline_change %u, ret = %ldn",
-		__func__, online, ssr_entry->offline,
-		ssr_entry->offline_change, ret);
-	WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex);
-}
-
-static ssize_t wdsp_ssr_entry_read(struct snd_info_entry *entry,
-				   void *file_priv_data, struct file *file,
-				   char __user *buf, size_t count, loff_t pos)
-{
-	int len = 0;
-	char buffer[WCD_PROCFS_ENTRY_MAX_LEN];
-	struct wcd_dsp_cntl *cntl;
-	struct wdsp_ssr_entry *ssr_entry;
-	ssize_t ret;
-	u8 offline;
-
-	cntl = (struct wcd_dsp_cntl *) entry->private_data;
-	if (!cntl) {
-		pr_err("%s: Invalid private data for SSR procfs entry\n",
-		       __func__);
-		return -EINVAL;
-	}
-
-	ssr_entry = &cntl->ssr_entry;
-
-	WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex);
-	offline = ssr_entry->offline;
-	/* Make sure the read is complete */
-	rmb();
-	dev_dbg(cntl->codec->dev, "%s: offline = %s\n", __func__,
-		offline ? "true" : "false");
-	len = snprintf(buffer, sizeof(buffer), "%s\n",
-		       offline ? "OFFLINE" : "ONLINE");
-	ret = simple_read_from_buffer(buf, count, &pos, buffer, len);
-	WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex);
-
-	return ret;
-}
-
-static unsigned int wdsp_ssr_entry_poll(struct snd_info_entry *entry,
-					void *private_data, struct file *file,
-					poll_table *wait)
-{
-	struct wcd_dsp_cntl *cntl;
-	struct wdsp_ssr_entry *ssr_entry;
-	unsigned int ret = 0;
-
-	if (!entry || !entry->private_data) {
-		pr_err("%s: %s is NULL\n", __func__,
-		       (!entry) ? "entry" : "private_data");
-		return -EINVAL;
-	}
-
-	cntl = (struct wcd_dsp_cntl *) entry->private_data;
-	ssr_entry = &cntl->ssr_entry;
-
-	dev_dbg(cntl->codec->dev, "%s: Poll wait, offline = %u\n",
-		__func__, ssr_entry->offline);
-	poll_wait(file, &ssr_entry->offline_poll_wait, wait);
-	dev_dbg(cntl->codec->dev, "%s: Woken up Poll wait, offline = %u\n",
-		__func__, ssr_entry->offline);
-
-	WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex);
-	if (xchg(&ssr_entry->offline_change, 0))
-		ret = POLLIN | POLLPRI | POLLRDNORM;
-	dev_dbg(cntl->codec->dev, "%s: ret (%d) from poll_wait\n",
-		__func__, ret);
-	WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex);
-
-	return ret;
-}
-
-static struct snd_info_entry_ops wdsp_ssr_entry_ops = {
-	.read = wdsp_ssr_entry_read,
-	.poll = wdsp_ssr_entry_poll,
-};
-
-static int wcd_cntl_cpe_fll_calibrate(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0, retry = 0;
-	u8 cal_lsb, cal_msb;
-	u8 lock_det;
-
-	/* Make sure clocks are gated */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL,
-			    0x05, 0x00);
-
-	/* Enable CPE FLL reference clock */
-	snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1,
-			    0x80, 0x80);
-
-	snd_soc_update_bits(codec, WCD934X_CPE_FLL_USER_CTL_5,
-			    0xF3, 0x13);
-	snd_soc_write(codec, WCD934X_CPE_FLL_L_VAL_CTL_0, 0x50);
-
-	/* Disable CPAR reset and Enable CPAR clk */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL,
-			    0x02, 0x02);
-
-	/* Write calibration l-value based on cdc clk rate */
-	if (cntl->clk_rate == 9600000) {
-		cal_lsb = 0x6d;
-		cal_msb = 0x00;
-	} else {
-		cal_lsb = 0x56;
-		cal_msb = 0x00;
-	}
-	snd_soc_write(codec, WCD934X_CPE_FLL_USER_CTL_6, cal_lsb);
-	snd_soc_write(codec, WCD934X_CPE_FLL_USER_CTL_7, cal_msb);
-
-	/* FLL mode to follow power up sequence */
-	snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE,
-			    0x60, 0x00);
-
-	/* HW controlled CPE FLL */
-	snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE,
-			    0x80, 0x80);
-
-	/* Force on CPE FLL */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG,
-			    0x04, 0x04);
-
-	do {
-		/* Time for FLL calibration to complete */
-		usleep_range(1000, 1100);
-		lock_det = snd_soc_read(codec, WCD934X_CPE_FLL_STATUS_3);
-		retry++;
-	} while (!(lock_det & 0x01) &&
-		 retry <= WCD_CPE_FLL_MAX_RETRIES);
-
-	if (!(lock_det & 0x01)) {
-		dev_err(codec->dev, "%s: lock detect not set, 0x%02x\n",
-			__func__, lock_det);
-		ret = -EIO;
-		goto err_lock_det;
-	}
-
-	snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE,
-			    0x60, 0x20);
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG,
-			    0x04, 0x00);
-	return ret;
-
-err_lock_det:
-	/* Undo the register settings */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG,
-			    0x04, 0x00);
-	snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE,
-			    0x80, 0x00);
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL,
-			    0x02, 0x00);
-	return ret;
-}
-
-static void wcd_cntl_config_cpar(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	u8 nom_lo, nom_hi, svs2_lo, svs2_hi;
-
-	/* Configure CPAR */
-	nom_hi = svs2_hi = 0;
-	if (cntl->clk_rate == 9600000) {
-		nom_lo = 0x90;
-		svs2_lo = 0x50;
-	} else {
-		nom_lo = 0x70;
-		svs2_lo = 0x3e;
-	}
-
-	snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_NOM_LOW, nom_lo);
-	snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_NOM_HIGH, nom_hi);
-	snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW, svs2_lo);
-	snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH, svs2_hi);
-
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_PWR_CPEFLL_CTL,
-			    0x03, 0x03);
-}
-
-static int wcd_cntl_cpe_fll_ctrl(struct wcd_dsp_cntl *cntl,
-				 bool enable)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0;
-
-	if (enable) {
-		ret = wcd_cntl_cpe_fll_calibrate(cntl);
-		if (ret < 0) {
-			dev_err(codec->dev,
-				"%s: cpe_fll_cal failed, err = %d\n",
-				__func__, ret);
-			goto done;
-		}
-
-		wcd_cntl_config_cpar(cntl);
-
-		/* Enable AHB CLK and CPE CLK*/
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL,
-				    0x05, 0x05);
-	} else {
-		/* Disable AHB CLK and CPE CLK */
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL,
-				    0x05, 0x00);
-		/* Reset the CPAR mode for CPE FLL */
-		snd_soc_write(codec, WCD934X_CPE_FLL_FLL_MODE, 0x20);
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG,
-				    0x04, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL,
-				    0x02, 0x00);
-	}
-done:
-	return ret;
-}
-
-static int wcd_cntl_clocks_enable(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret;
-
-	WCD_CNTL_MUTEX_LOCK(codec, cntl->clk_mutex);
-	/* Enable codec clock */
-	if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en)
-		ret = cntl->cdc_cb->cdc_clk_en(codec, true);
-	else
-		ret = -EINVAL;
-
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Failed to enable cdc clk, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-	/* Pull CPAR out of reset */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x00);
-
-	/* Configure and Enable CPE FLL clock */
-	ret = wcd_cntl_cpe_fll_ctrl(cntl, true);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Failed to enable cpe clk, err = %d\n",
-			__func__, ret);
-		goto err_cpe_clk;
-	}
-	cntl->is_clk_enabled = true;
-
-	/* Ungate the CPR clock  */
-	snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, 0x10, 0x00);
-done:
-	WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex);
-	return ret;
-
-err_cpe_clk:
-	if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en)
-		cntl->cdc_cb->cdc_clk_en(codec, false);
-
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x04);
-	WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex);
-	return ret;
-}
-
-static int wcd_cntl_clocks_disable(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0;
-
-	WCD_CNTL_MUTEX_LOCK(codec, cntl->clk_mutex);
-	if (!cntl->is_clk_enabled) {
-		dev_info(codec->dev, "%s: clocks already disabled\n",
-			__func__);
-		goto done;
-	}
-
-	/* Gate the CPR clock  */
-	snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, 0x10, 0x10);
-
-	/* Disable CPE FLL clock */
-	ret = wcd_cntl_cpe_fll_ctrl(cntl, false);
-	if (ret < 0)
-		dev_err(codec->dev,
-			"%s: Failed to disable cpe clk, err = %d\n",
-			__func__, ret);
-
-	/*
-	 * Even if CPE FLL disable failed, go ahead and disable
-	 * the codec clock
-	 */
-	if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en)
-		ret = cntl->cdc_cb->cdc_clk_en(codec, false);
-	else
-		ret = -EINVAL;
-
-	cntl->is_clk_enabled = false;
-
-	/* Put CPAR in reset */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x04);
-done:
-	WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex);
-	return ret;
-}
-
-static void wcd_cntl_cpar_ctrl(struct wcd_dsp_cntl *cntl,
-			       bool enable)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-
-	if (enable)
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x03);
-	else
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x00);
-}
-
-static int wcd_cntl_enable_memory(struct wcd_dsp_cntl *cntl,
-				  enum wcd_mem_type mem_type)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int loop_cnt = 0;
-	u8 status;
-	int ret = 0;
-
-
-	switch (mem_type) {
-
-	case WCD_MEM_TYPE_ALWAYS_ON:
-
-		/* 512KB of always on region */
-		wcd9xxx_slim_write_repeat(wcd9xxx,
-				WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0,
-				ARRAY_SIZE(mem_enable_values),
-				mem_enable_values);
-		wcd9xxx_slim_write_repeat(wcd9xxx,
-				WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1,
-				ARRAY_SIZE(mem_enable_values),
-				mem_enable_values);
-		break;
-
-	case WCD_MEM_TYPE_SWITCHABLE:
-
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL,
-				    0x04, 0x00);
-		snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_MEM_CTRL,
-				    0x80, 0x80);
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL,
-				    0x01, 0x01);
-		do {
-			loop_cnt++;
-			/* Time to enable the power domain for memory */
-			usleep_range(100, 150);
-			status = snd_soc_read(codec,
-					WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL);
-		} while ((status & 0x02) != 0x02 &&
-			  loop_cnt != WCD_MEM_ENABLE_MAX_RETRIES);
-
-		if ((status & 0x02) != 0x02) {
-			dev_err(cntl->codec->dev,
-				"%s: power domain not enabled, status = 0x%02x\n",
-				__func__, status);
-			ret = -EIO;
-			goto done;
-		}
-
-		/* Rest of the memory */
-		wcd9xxx_slim_write_repeat(wcd9xxx,
-				WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2,
-				ARRAY_SIZE(mem_enable_values),
-				mem_enable_values);
-		wcd9xxx_slim_write_repeat(wcd9xxx,
-				WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3,
-				ARRAY_SIZE(mem_enable_values),
-				mem_enable_values);
-
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN,
-			      0x05);
-		break;
-
-	default:
-		dev_err(cntl->codec->dev, "%s: Invalid mem_type %d\n",
-			__func__, mem_type);
-		ret = -EINVAL;
-		break;
-	}
-done:
-	/* Make sure Deep sleep of memories is enabled for all banks */
-	snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF);
-	snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F);
-
-	return ret;
-}
-
-static void wcd_cntl_disable_memory(struct wcd_dsp_cntl *cntl,
-				    enum wcd_mem_type mem_type)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	u8 val;
-
-	switch (mem_type) {
-	case WCD_MEM_TYPE_ALWAYS_ON:
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1,
-			      0xFF);
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0,
-			      0xFF);
-		break;
-	case WCD_MEM_TYPE_SWITCHABLE:
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3,
-			      0xFF);
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2,
-			      0xFF);
-		snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN,
-			      0x07);
-
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL,
-				    0x01, 0x00);
-		val = snd_soc_read(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL);
-		if (val & 0x02)
-			dev_err(codec->dev,
-				"%s: Disable switchable failed, val = 0x%02x",
-				__func__, val);
-
-		snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_MEM_CTRL,
-				    0x80, 0x00);
-		break;
-	default:
-		dev_err(cntl->codec->dev, "%s: Invalid mem_type %d\n",
-			__func__, mem_type);
-		break;
-	}
-
-	snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF);
-	snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F);
-}
-
-static void wcd_cntl_do_shutdown(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-
-	/* Disable WDOG */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG,
-			    0x3F, 0x01);
-
-	/* Put WDSP in reset state */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL,
-			    0x02, 0x00);
-
-	/* If DSP transitions from boot to shutdown, then vote for SVS */
-	if (cntl->is_wdsp_booted)
-		cntl->cdc_cb->cdc_vote_svs(codec, true);
-	cntl->is_wdsp_booted = false;
-}
-
-static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0;
-
-	/*
-	 * Debug mode is set from debugfs file node. If debug_mode
-	 * is set, then do not configure the watchdog timer. This
-	 * will be required for debugging the DSP firmware.
-	 */
-	if (cntl->debug_mode) {
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG,
-				    0x3F, 0x01);
-	} else {
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG,
-				    0x3F, 0x21);
-	}
-
-	/* Make sure all the error interrupts are cleared */
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A, 0xFF);
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B, 0xFF);
-
-	reinit_completion(&cntl->boot_complete);
-
-	/* Remove WDSP out of reset */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL,
-			    0x02, 0x02);
-
-	/*
-	 * In debug mode, DSP may not boot up normally,
-	 * wait indefinitely for DSP to boot.
-	 */
-	if (cntl->debug_mode) {
-		wait_for_completion(&cntl->boot_complete);
-		dev_dbg(codec->dev, "%s: WDSP booted in dbg mode\n", __func__);
-		cntl->is_wdsp_booted = true;
-		goto done;
-	}
-
-	/* Boot in normal mode */
-	ret = wait_for_completion_timeout(&cntl->boot_complete,
-				msecs_to_jiffies(WCD_DSP_BOOT_TIMEOUT_MS));
-	if (!ret) {
-		dev_err(codec->dev, "%s: WDSP boot timed out\n",
-			__func__);
-		ret = -ETIMEDOUT;
-		goto err_boot;
-	} else {
-		/*
-		 * Re-initialize the return code to 0, as in success case,
-		 * it will hold the remaining time for completion timeout
-		 */
-		ret = 0;
-	}
-
-	dev_dbg(codec->dev, "%s: WDSP booted in normal mode\n", __func__);
-	cntl->is_wdsp_booted = true;
-
-	/* Enable WDOG */
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG,
-			    0x10, 0x10);
-done:
-	/* If dsp booted up, then remove vote on SVS */
-	if (cntl->is_wdsp_booted)
-		cntl->cdc_cb->cdc_vote_svs(codec, false);
-
-	return ret;
-err_boot:
-	/* call shutdown to perform cleanup */
-	wcd_cntl_do_shutdown(cntl);
-	return ret;
-}
-
-static irqreturn_t wcd_cntl_ipc_irq(int irq, void *data)
-{
-	struct wcd_dsp_cntl *cntl = data;
-	int ret;
-
-	complete(&cntl->boot_complete);
-
-	if (cntl->m_dev && cntl->m_ops &&
-	    cntl->m_ops->signal_handler)
-		ret = cntl->m_ops->signal_handler(cntl->m_dev, WDSP_IPC1_INTR,
-						  NULL);
-	else
-		ret = -EINVAL;
-
-	if (ret < 0)
-		dev_err(cntl->codec->dev,
-			"%s: Failed to handle irq %d\n", __func__, irq);
-
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t wcd_cntl_err_irq(int irq, void *data)
-{
-	struct wcd_dsp_cntl *cntl = data;
-	struct snd_soc_codec *codec = cntl->codec;
-	struct wdsp_err_signal_arg arg;
-	u16 status = 0;
-	u8 reg_val;
-	int ret = 0;
-
-	reg_val = snd_soc_read(codec, WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A);
-	status = status | reg_val;
-
-	reg_val = snd_soc_read(codec, WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B);
-	status = status | (reg_val << 8);
-
-	dev_info(codec->dev, "%s: error interrupt status = 0x%x\n",
-		__func__, status);
-
-	if ((status & cntl->irqs.fatal_irqs) &&
-	    (cntl->m_dev && cntl->m_ops && cntl->m_ops->signal_handler)) {
-		arg.mem_dumps_enabled = cntl->ramdump_enable;
-		arg.remote_start_addr = WCD_934X_RAMDUMP_START_ADDR;
-		arg.dump_size = WCD_934X_RAMDUMP_SIZE;
-		ret = cntl->m_ops->signal_handler(cntl->m_dev, WDSP_ERR_INTR,
-						  &arg);
-		if (ret < 0)
-			dev_err(cntl->codec->dev,
-				"%s: Failed to handle fatal irq 0x%x\n",
-				__func__, status & cntl->irqs.fatal_irqs);
-		wcd_cntl_change_online_state(cntl, 0);
-	} else {
-		dev_err(cntl->codec->dev, "%s: Invalid signal_handler\n",
-			__func__);
-	}
-
-	return IRQ_HANDLED;
-}
-
-static int wcd_control_handler(struct device *dev, void *priv_data,
-			       enum wdsp_event_type event, void *data)
-{
-	struct wcd_dsp_cntl *cntl = priv_data;
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0;
-
-	switch (event) {
-	case WDSP_EVENT_POST_INIT:
-	case WDSP_EVENT_POST_DLOAD_CODE:
-	case WDSP_EVENT_DLOAD_FAILED:
-	case WDSP_EVENT_POST_SHUTDOWN:
-
-		/* Disable CPAR */
-		wcd_cntl_cpar_ctrl(cntl, false);
-		/* Disable all the clocks */
-		ret = wcd_cntl_clocks_disable(cntl);
-		if (ret < 0)
-			dev_err(codec->dev,
-				"%s: Failed to disable clocks, err = %d\n",
-				__func__, ret);
-
-		if (event == WDSP_EVENT_POST_DLOAD_CODE)
-			/* Mark DSP online since code download is complete */
-			wcd_cntl_change_online_state(cntl, 1);
-		break;
-
-	case WDSP_EVENT_PRE_DLOAD_DATA:
-	case WDSP_EVENT_PRE_DLOAD_CODE:
-
-		/* Enable all the clocks */
-		ret = wcd_cntl_clocks_enable(cntl);
-		if (ret < 0) {
-			dev_err(codec->dev,
-				"%s: Failed to enable clocks, err = %d\n",
-				__func__, ret);
-			goto done;
-		}
-
-		/* Enable CPAR */
-		wcd_cntl_cpar_ctrl(cntl, true);
-
-		if (event == WDSP_EVENT_PRE_DLOAD_CODE)
-			wcd_cntl_enable_memory(cntl, WCD_MEM_TYPE_ALWAYS_ON);
-		else if (event == WDSP_EVENT_PRE_DLOAD_DATA)
-			wcd_cntl_enable_memory(cntl, WCD_MEM_TYPE_SWITCHABLE);
-		break;
-
-	case WDSP_EVENT_DO_BOOT:
-
-		ret = wcd_cntl_do_boot(cntl);
-		if (ret < 0)
-			dev_err(codec->dev,
-				"%s: WDSP boot failed, err = %d\n",
-				__func__, ret);
-		break;
-
-	case WDSP_EVENT_DO_SHUTDOWN:
-
-		wcd_cntl_do_shutdown(cntl);
-		wcd_cntl_disable_memory(cntl, WCD_MEM_TYPE_SWITCHABLE);
-		break;
-
-	default:
-		dev_dbg(codec->dev, "%s: unhandled event %d\n",
-			__func__, event);
-	}
-
-done:
-	return ret;
-}
-
-static int wcd_cntl_sysfs_init(char *dir, struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-	int ret = 0;
-
-	ret = kobject_init_and_add(&cntl->wcd_kobj, &wcd_cntl_ktype,
-				   kernel_kobj, dir);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Failed to add kobject %s, err = %d\n",
-			__func__, dir, ret);
-		goto done;
-	}
-
-	ret = sysfs_create_file(&cntl->wcd_kobj, &cntl_attr_boot.attr);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Failed to add wdsp_boot sysfs entry to %s\n",
-			__func__, dir);
-		goto fail_create_file;
-	}
-
-	return ret;
-
-fail_create_file:
-	kobject_put(&cntl->wcd_kobj);
-done:
-	return ret;
-}
-
-static void wcd_cntl_sysfs_remove(struct wcd_dsp_cntl *cntl)
-{
-	sysfs_remove_file(&cntl->wcd_kobj, &cntl_attr_boot.attr);
-	kobject_put(&cntl->wcd_kobj);
-}
-
-static void wcd_cntl_debugfs_init(char *dir, struct wcd_dsp_cntl *cntl)
-{
-	struct snd_soc_codec *codec = cntl->codec;
-
-	cntl->entry = debugfs_create_dir(dir, NULL);
-	if (IS_ERR_OR_NULL(dir)) {
-		dev_err(codec->dev, "%s debugfs_create_dir failed for %s\n",
-			__func__, dir);
-		goto done;
-	}
-
-	debugfs_create_u32("debug_mode", 0644,
-			   cntl->entry, &cntl->debug_mode);
-	debugfs_create_bool("ramdump_enable", 0644,
-			    cntl->entry, &cntl->ramdump_enable);
-done:
-	return;
-}
-
-static void wcd_cntl_debugfs_remove(struct wcd_dsp_cntl *cntl)
-{
-	if (cntl)
-		debugfs_remove(cntl->entry);
-}
-
-static int wcd_miscdev_release(struct inode *inode, struct file *filep)
-{
-	struct wcd_dsp_cntl *cntl = container_of(filep->private_data,
-						 struct wcd_dsp_cntl, miscdev);
-	if (!cntl->m_dev || !cntl->m_ops ||
-	    !cntl->m_ops->vote_for_dsp) {
-		dev_err(cntl->codec->dev,
-			"%s: DSP not ready to boot\n", __func__);
-		return -EINVAL;
-	}
-
-	/* Make sure the DSP users goes to zero upon closing dev node */
-	while (cntl->boot_reqs > 0) {
-		cntl->m_ops->vote_for_dsp(cntl->m_dev, false);
-		cntl->boot_reqs--;
-	}
-
-	return 0;
-}
-
-static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf,
-				 size_t count, loff_t *pos)
-{
-	struct wcd_dsp_cntl *cntl = container_of(filep->private_data,
-						 struct wcd_dsp_cntl, miscdev);
-	char val[count];
-	bool vote;
-	int ret = 0;
-
-	if (count == 0 || count > 2) {
-		pr_err("%s: Invalid count = %zd\n", __func__, count);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = copy_from_user(val, ubuf, count);
-	if (ret < 0) {
-		dev_err(cntl->codec->dev,
-			"%s: copy_from_user failed, err = %d\n",
-			__func__, ret);
-		ret = -EFAULT;
-		goto done;
-	}
-
-	if (val[0] == '1') {
-		cntl->boot_reqs++;
-		vote = true;
-	} else if (val[0] == '0') {
-		if (cntl->boot_reqs == 0) {
-			dev_err(cntl->codec->dev,
-				"%s: WDSP already disabled\n", __func__);
-			ret = -EINVAL;
-			goto done;
-		}
-		cntl->boot_reqs--;
-		vote = false;
-	} else {
-		dev_err(cntl->codec->dev, "%s: Invalid value %s\n",
-			__func__, val);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	dev_dbg(cntl->codec->dev,
-		"%s: booted = %s, ref_cnt = %d, vote = %s\n",
-		__func__, cntl->is_wdsp_booted ? "true" : "false",
-		cntl->boot_reqs, vote ? "true" : "false");
-
-	if (cntl->m_dev && cntl->m_ops &&
-	    cntl->m_ops->vote_for_dsp)
-		ret = cntl->m_ops->vote_for_dsp(cntl->m_dev, vote);
-	else
-		ret = -EINVAL;
-done:
-	if (ret)
-		return ret;
-	else
-		return count;
-}
-
-static const struct file_operations wcd_miscdev_fops = {
-	.write = wcd_miscdev_write,
-	.release = wcd_miscdev_release,
-};
-
-static int wcd_cntl_miscdev_create(struct wcd_dsp_cntl *cntl)
-{
-	snprintf(cntl->miscdev_name, ARRAY_SIZE(cntl->miscdev_name),
-		"wcd_dsp%u_control", cntl->dsp_instance);
-	cntl->miscdev.minor = MISC_DYNAMIC_MINOR;
-	cntl->miscdev.name = cntl->miscdev_name;
-	cntl->miscdev.fops = &wcd_miscdev_fops;
-	cntl->miscdev.parent = cntl->codec->dev;
-
-	return misc_register(&cntl->miscdev);
-}
-
-static void wcd_cntl_miscdev_destroy(struct wcd_dsp_cntl *cntl)
-{
-	misc_deregister(&cntl->miscdev);
-}
-
-static int wcd_control_init(struct device *dev, void *priv_data)
-{
-	struct wcd_dsp_cntl *cntl = priv_data;
-	struct snd_soc_codec *codec = cntl->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
-	int ret;
-	bool err_irq_requested = false;
-
-	ret = wcd9xxx_request_irq(core_res,
-				  cntl->irqs.cpe_ipc1_irq,
-				  wcd_cntl_ipc_irq, "CPE IPC1",
-				  cntl);
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: Failed to request cpe ipc irq, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	/* Unmask the fatal irqs */
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A,
-		      ~(cntl->irqs.fatal_irqs & 0xFF));
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B,
-		      ~((cntl->irqs.fatal_irqs >> 8) & 0xFF));
-
-	/*
-	 * CPE ERR irq is used only for error reporting from WCD DSP,
-	 * even if this request fails, DSP can be function normally.
-	 * Continuing with init even if the CPE ERR irq request fails.
-	 */
-	if (wcd9xxx_request_irq(core_res, cntl->irqs.cpe_err_irq,
-				wcd_cntl_err_irq, "CPE ERR", cntl))
-		dev_info(codec->dev, "%s: Failed request_irq(cpe_err_irq)",
-			__func__);
-	else
-		err_irq_requested = true;
-
-
-	/* Enable all the clocks */
-	ret = wcd_cntl_clocks_enable(cntl);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Failed to enable clocks, err = %d\n",
-			__func__, ret);
-		goto err_clk_enable;
-	}
-	wcd_cntl_cpar_ctrl(cntl, true);
-
-	return 0;
-
-err_clk_enable:
-	/* Mask all error interrupts */
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, 0xFF);
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, 0xFF);
-
-	/* Free the irq's requested */
-	wcd9xxx_free_irq(core_res, cntl->irqs.cpe_ipc1_irq, cntl);
-
-	if (err_irq_requested)
-		wcd9xxx_free_irq(core_res, cntl->irqs.cpe_err_irq, cntl);
-done:
-	return ret;
-}
-
-static int wcd_control_deinit(struct device *dev, void *priv_data)
-{
-	struct wcd_dsp_cntl *cntl = priv_data;
-	struct snd_soc_codec *codec = cntl->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
-
-	wcd_cntl_clocks_disable(cntl);
-	wcd_cntl_cpar_ctrl(cntl, false);
-
-	/* Mask all error interrupts */
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, 0xFF);
-	snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, 0xFF);
-
-	/* Free the irq's requested */
-	wcd9xxx_free_irq(core_res, cntl->irqs.cpe_err_irq, cntl);
-	wcd9xxx_free_irq(core_res, cntl->irqs.cpe_ipc1_irq, cntl);
-
-	return 0;
-}
-
-static struct wdsp_cmpnt_ops control_ops = {
-	.init = wcd_control_init,
-	.deinit = wcd_control_deinit,
-	.event_handler = wcd_control_handler,
-};
-
-static int wcd_ctrl_component_bind(struct device *dev,
-				   struct device *master,
-				   void *data)
-{
-	struct wcd_dsp_cntl *cntl;
-	struct snd_soc_codec *codec;
-	struct snd_card *card;
-	struct snd_info_entry *entry;
-	char proc_name[WCD_PROCFS_ENTRY_MAX_LEN];
-	char wcd_cntl_dir_name[WCD_CNTL_DIR_NAME_LEN_MAX];
-	int ret = 0;
-
-	if (!dev || !master || !data) {
-		pr_err("%s: Invalid parameters\n", __func__);
-		return -EINVAL;
-	}
-
-	cntl = tavil_get_wcd_dsp_cntl(dev);
-	if (!cntl) {
-		dev_err(dev, "%s: Failed to get cntl reference\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	cntl->m_dev = master;
-	cntl->m_ops = data;
-
-	if (!cntl->m_ops->register_cmpnt_ops) {
-		dev_err(dev, "%s: invalid master callback register_cmpnt_ops\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cntl->m_ops->register_cmpnt_ops(master, dev, cntl, &control_ops);
-	if (ret) {
-		dev_err(dev, "%s: register_cmpnt_ops failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ret = wcd_cntl_miscdev_create(cntl);
-	if (ret < 0) {
-		dev_err(dev, "%s: misc dev register failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	snprintf(wcd_cntl_dir_name, WCD_CNTL_DIR_NAME_LEN_MAX,
-		 "%s%d", "wdsp", cntl->dsp_instance);
-	ret = wcd_cntl_sysfs_init(wcd_cntl_dir_name, cntl);
-	if (ret < 0) {
-		dev_err(dev, "%s: sysfs_init failed, err = %d\n",
-			__func__, ret);
-		goto err_sysfs_init;
-	}
-
-	wcd_cntl_debugfs_init(wcd_cntl_dir_name, cntl);
-
-	codec = cntl->codec;
-	card = codec->component.card->snd_card;
-	snprintf(proc_name, WCD_PROCFS_ENTRY_MAX_LEN, "%s%d%s", "cpe",
-		 cntl->dsp_instance, "_state");
-	entry = snd_info_create_card_entry(card, proc_name, card->proc_root);
-	if (!entry) {
-		/* Do not treat this as Fatal error */
-		dev_err(dev, "%s: Failed to create procfs entry %s\n",
-			__func__, proc_name);
-		goto err_sysfs_init;
-	}
-
-	cntl->ssr_entry.entry = entry;
-	cntl->ssr_entry.offline = 1;
-	entry->size = WCD_PROCFS_ENTRY_MAX_LEN;
-	entry->content = SNDRV_INFO_CONTENT_DATA;
-	entry->c.ops = &wdsp_ssr_entry_ops;
-	entry->private_data = cntl;
-	ret = snd_info_register(entry);
-	if (ret < 0) {
-		dev_err(dev, "%s: Failed to register entry %s, err = %d\n",
-			__func__, proc_name, ret);
-		snd_info_free_entry(entry);
-		/* Let bind still happen even if creating the entry failed */
-		ret = 0;
-	}
-done:
-	return ret;
-
-err_sysfs_init:
-	wcd_cntl_miscdev_destroy(cntl);
-	return ret;
-}
-
-static void wcd_ctrl_component_unbind(struct device *dev,
-				      struct device *master,
-				      void *data)
-{
-	struct wcd_dsp_cntl *cntl;
-
-	if (!dev) {
-		pr_err("%s: Invalid device\n", __func__);
-		return;
-	}
-
-	cntl = tavil_get_wcd_dsp_cntl(dev);
-	if (!cntl) {
-		dev_err(dev, "%s: Failed to get cntl reference\n",
-			__func__);
-		return;
-	}
-
-	cntl->m_dev = NULL;
-	cntl->m_ops = NULL;
-
-	/* Remove the sysfs entries */
-	wcd_cntl_sysfs_remove(cntl);
-
-	/* Remove the debugfs entries */
-	wcd_cntl_debugfs_remove(cntl);
-
-	/* Remove the misc device */
-	wcd_cntl_miscdev_destroy(cntl);
-}
-
-static const struct component_ops wcd_ctrl_component_ops = {
-	.bind = wcd_ctrl_component_bind,
-	.unbind = wcd_ctrl_component_unbind,
-};
-
-/*
- * wcd_dsp_ssr_event: handle the SSR event raised by caller.
- * @cntl: Handle to the wcd_dsp_cntl structure
- * @event: The SSR event to be handled
- *
- * Notifies the manager driver about the SSR event.
- * Returns 0 on success and negative error code on error.
- */
-int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event)
-{
-	int ret = 0;
-
-	if (!cntl) {
-		pr_err("%s: Invalid handle to control\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!cntl->m_dev || !cntl->m_ops || !cntl->m_ops->signal_handler) {
-		dev_err(cntl->codec->dev,
-			"%s: Invalid signal_handler callback\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case WCD_CDC_DOWN_EVENT:
-		ret = cntl->m_ops->signal_handler(cntl->m_dev,
-						  WDSP_CDC_DOWN_SIGNAL,
-						  NULL);
-		if (ret < 0)
-			dev_err(cntl->codec->dev,
-				"%s: WDSP_CDC_DOWN_SIGNAL failed, err = %d\n",
-				__func__, ret);
-		wcd_cntl_change_online_state(cntl, 0);
-		break;
-	case WCD_CDC_UP_EVENT:
-		ret = cntl->m_ops->signal_handler(cntl->m_dev,
-						  WDSP_CDC_UP_SIGNAL,
-						  NULL);
-		if (ret < 0)
-			dev_err(cntl->codec->dev,
-				"%s: WDSP_CDC_UP_SIGNAL failed, err = %d\n",
-				__func__, ret);
-		break;
-	default:
-		dev_err(cntl->codec->dev, "%s: Invalid event %d\n",
-			__func__, event);
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd_dsp_ssr_event);
-
-/*
- * wcd_dsp_cntl_init: Initialize the wcd-dsp control
- * @codec: pointer to the codec handle
- * @params: Parameters required to initialize wcd-dsp control
- *
- * This API is expected to be invoked by the codec driver and
- * provide information essential for the wcd dsp control to
- * configure and initialize the dsp
- */
-void wcd_dsp_cntl_init(struct snd_soc_codec *codec,
-		       struct wcd_dsp_params *params,
-		       struct wcd_dsp_cntl **cntl)
-{
-	struct wcd_dsp_cntl *control;
-	int ret;
-
-	if (!codec || !params) {
-		pr_err("%s: Invalid handle to %s\n", __func__,
-		       (!codec) ? "codec" : "params");
-		*cntl = NULL;
-		return;
-	}
-
-	if (*cntl) {
-		pr_err("%s: cntl is non NULL, maybe already initialized ?\n",
-			__func__);
-		return;
-	}
-
-	if (!params->cb || !params->cb->cdc_clk_en ||
-	    !params->cb->cdc_vote_svs) {
-		dev_err(codec->dev,
-			"%s: clk_en and vote_svs callbacks must be provided\n",
-			__func__);
-		return;
-	}
-
-	control = kzalloc(sizeof(*control), GFP_KERNEL);
-	if (!(control))
-		return;
-
-	control->codec = codec;
-	control->clk_rate = params->clk_rate;
-	control->cdc_cb = params->cb;
-	control->dsp_instance = params->dsp_instance;
-	memcpy(&control->irqs, &params->irqs, sizeof(control->irqs));
-	init_completion(&control->boot_complete);
-	mutex_init(&control->clk_mutex);
-	mutex_init(&control->ssr_mutex);
-	init_waitqueue_head(&control->ssr_entry.offline_poll_wait);
-
-	/*
-	 * The default state of WDSP is in SVS mode.
-	 * Vote for SVS now, the vote will be removed only
-	 * after DSP is booted up.
-	 */
-	control->cdc_cb->cdc_vote_svs(codec, true);
-
-	/*
-	 * If this is the last component needed by master to be ready,
-	 * then component_bind will be called within the component_add.
-	 * Hence, the data pointer should be assigned before component_add,
-	 * so that we can access it during this component's bind call.
-	 */
-	*cntl = control;
-	ret = component_add(codec->dev, &wcd_ctrl_component_ops);
-	if (ret) {
-		dev_err(codec->dev, "%s: component_add failed, err = %d\n",
-			__func__, ret);
-		kfree(*cntl);
-		*cntl = NULL;
-	}
-}
-EXPORT_SYMBOL(wcd_dsp_cntl_init);
-
-/*
- * wcd_dsp_cntl_deinit: De-initialize the wcd-dsp control
- * @cntl: The struct wcd_dsp_cntl to de-initialize
- *
- * This API is intended to be invoked by the codec driver
- * to de-initialize the wcd dsp control
- */
-void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl)
-{
-	struct wcd_dsp_cntl *control = *cntl;
-	struct snd_soc_codec *codec;
-
-	/* If control is NULL, there is nothing to de-initialize */
-	if (!control)
-		return;
-	codec = control->codec;
-
-	/*
-	 * Calling shutdown will cleanup all register states,
-	 * irrespective of DSP was booted up or not.
-	 */
-	wcd_cntl_do_shutdown(control);
-	wcd_cntl_disable_memory(control, WCD_MEM_TYPE_SWITCHABLE);
-	wcd_cntl_disable_memory(control, WCD_MEM_TYPE_ALWAYS_ON);
-
-	component_del(codec->dev, &wcd_ctrl_component_ops);
-
-	mutex_destroy(&control->clk_mutex);
-	mutex_destroy(&control->ssr_mutex);
-	kfree(*cntl);
-	*cntl = NULL;
-}
-EXPORT_SYMBOL(wcd_dsp_cntl_deinit);
diff --git a/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.h b/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.h
deleted file mode 100644
index e934638..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-dsp-cntl.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD934X_DSP_CNTL_H__
-#define __WCD934X_DSP_CNTL_H__
-
-#include <sound/soc.h>
-#include <sound/wcd-dsp-mgr.h>
-
-enum cdc_ssr_event {
-	WCD_CDC_DOWN_EVENT,
-	WCD_CDC_UP_EVENT,
-};
-
-struct wcd_dsp_cdc_cb {
-	/* Callback to enable codec clock */
-	int (*cdc_clk_en)(struct snd_soc_codec *, bool);
-	/* Callback to vote and unvote for SVS2 mode */
-	void (*cdc_vote_svs)(struct snd_soc_codec *, bool);
-};
-
-struct wcd_dsp_irq_info {
-	/* IPC interrupt */
-	int cpe_ipc1_irq;
-
-	/* CPE error summary interrupt */
-	int cpe_err_irq;
-
-	/*
-	 * Bit mask to indicate which of the
-	 * error interrupts are to be considered
-	 * as fatal.
-	 */
-	u16 fatal_irqs;
-};
-
-struct wcd_dsp_params {
-	struct wcd_dsp_cdc_cb *cb;
-	struct wcd_dsp_irq_info irqs;
-
-	/* Rate at which the codec clock operates */
-	u32 clk_rate;
-
-	/*
-	 * Represents the dsp instance, will be used
-	 * to create sysfs and debugfs entries with
-	 * directory wdsp<dsp-instance>
-	 */
-	u32 dsp_instance;
-};
-
-struct wdsp_ssr_entry {
-	u8 offline;
-	u8 offline_change;
-	wait_queue_head_t offline_poll_wait;
-	struct snd_info_entry *entry;
-};
-
-struct wcd_dsp_cntl {
-	/* Handle to codec */
-	struct snd_soc_codec *codec;
-
-	/* Clk rate of the codec clock */
-	u32 clk_rate;
-
-	/* Callbacks to codec driver */
-	const struct wcd_dsp_cdc_cb *cdc_cb;
-
-	/* Completion to indicate WDSP boot done */
-	struct completion boot_complete;
-
-	struct wcd_dsp_irq_info irqs;
-	u32 dsp_instance;
-
-	/* Sysfs entries related */
-	int boot_reqs;
-	struct kobject wcd_kobj;
-
-	/* Debugfs related */
-	struct dentry *entry;
-	u32 debug_mode;
-	bool ramdump_enable;
-
-	/* WDSP manager drivers data */
-	struct device *m_dev;
-	struct wdsp_mgr_ops *m_ops;
-
-	/* clk related */
-	struct mutex clk_mutex;
-	bool is_clk_enabled;
-
-	/* Keep track of WDSP boot status */
-	bool is_wdsp_booted;
-
-	/* SSR related */
-	struct wdsp_ssr_entry ssr_entry;
-	struct mutex ssr_mutex;
-
-	/* Misc device related */
-	char miscdev_name[256];
-	struct miscdevice miscdev;
-};
-
-void wcd_dsp_cntl_init(struct snd_soc_codec *codec,
-		       struct wcd_dsp_params *params,
-		       struct wcd_dsp_cntl **cntl);
-void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl);
-int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event);
-#endif /* end __WCD_DSP_CONTROL_H__ */
diff --git a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c b/sound/soc/codecs/wcd934x/wcd934x-mbhc.c
deleted file mode 100644
index bf6e7a1..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/delay.h>
-#include <linux/regmap.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <linux/mfd/wcd934x/irq.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include "wcd934x.h"
-#include "wcd934x-mbhc.h"
-#include "../wcdcal-hwdep.h"
-#include "../wcd-mbhc-v2-api.h"
-
-#define TAVIL_ZDET_SUPPORTED          true
-/* Z value defined in milliohm */
-#define TAVIL_ZDET_VAL_32             32000
-#define TAVIL_ZDET_VAL_400            400000
-#define TAVIL_ZDET_VAL_1200           1200000
-#define TAVIL_ZDET_VAL_100K           100000000
-/* Z floating defined in ohms */
-#define TAVIL_ZDET_FLOATING_IMPEDANCE 0x0FFFFFFE
-
-#define TAVIL_ZDET_NUM_MEASUREMENTS   900
-#define TAVIL_MBHC_GET_C1(c)          ((c & 0xC000) >> 14)
-#define TAVIL_MBHC_GET_X1(x)          (x & 0x3FFF)
-/* Z value compared in milliOhm */
-#define TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
-#define TAVIL_MBHC_ZDET_CONST         (86 * 16384)
-#define TAVIL_MBHC_MOISTURE_RREF      R_24_KOHM
-
-static struct wcd_mbhc_register
-	wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
-	WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
-			  WCD934X_ANA_MBHC_MECH, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
-			  WCD934X_ANA_MBHC_MECH, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
-			  WCD934X_ANA_MBHC_MECH, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
-			  WCD934X_MBHC_NEW_PLUG_DETECT_CTL, 0x30, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
-			  WCD934X_ANA_MBHC_ELECT, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
-			  WCD934X_MBHC_NEW_PLUG_DETECT_CTL, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
-			  WCD934X_ANA_MBHC_MECH, 0x04, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
-			  WCD934X_ANA_MBHC_MECH, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
-			  WCD934X_ANA_MBHC_MECH, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
-			  WCD934X_ANA_MBHC_MECH, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
-			  WCD934X_ANA_MBHC_ELECT, 0x06, 1, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
-			  WCD934X_ANA_MBHC_ELECT, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
-			  WCD934X_MBHC_NEW_PLUG_DETECT_CTL, 0x0F, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
-			  WCD934X_MBHC_NEW_CTL_1, 0x03, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
-			  WCD934X_MBHC_NEW_CTL_2, 0x03, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x20, 5, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
-			  WCD934X_HPH_OCP_CTL, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x07, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
-			  WCD934X_ANA_MBHC_ELECT, 0x70, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
-			  WCD934X_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
-			  WCD934X_ANA_MICB2, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
-			  WCD934X_HPH_CNP_WG_TIME, 0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
-			  WCD934X_ANA_HPH, 0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
-			  WCD934X_ANA_HPH, 0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
-			  WCD934X_ANA_HPH, 0xC0, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
-			  WCD934X_ANA_MBHC_RESULT_3, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
-			  0, 0, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
-			  WCD934X_MBHC_CTL_BCS, 0x02, 1, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
-			  WCD934X_MBHC_STATUS_SPARE_1, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
-			  WCD934X_MBHC_NEW_CTL_2, 0x70, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_OCP_DET_EN",
-			  WCD934X_HPH_L_TEST, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_OCP_DET_EN",
-			  WCD934X_HPH_R_TEST, 0x01, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_OCP_STATUS",
-			  WCD934X_INTR_PIN1_STATUS0, 0x04, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_HPHR_OCP_STATUS",
-			  WCD934X_INTR_PIN1_STATUS0, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ADC_EN",
-			  WCD934X_MBHC_NEW_CTL_1, 0x08, 3, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ADC_COMPLETE", WCD934X_MBHC_NEW_FSM_STATUS,
-			  0x40, 6, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ADC_TIMEOUT", WCD934X_MBHC_NEW_FSM_STATUS,
-			  0x80, 7, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ADC_RESULT", WCD934X_MBHC_NEW_ADC_RESULT,
-			  0xFF, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_MICB2_VOUT", WCD934X_ANA_MICB2, 0x3F, 0, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ADC_MODE",
-			  WCD934X_MBHC_NEW_CTL_1, 0x10, 4, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_DETECTION_DONE",
-			  WCD934X_MBHC_NEW_CTL_1, 0x04, 2, 0),
-	WCD_MBHC_REGISTER("WCD_MBHC_ELECT_ISRC_EN",
-			  WCD934X_ANA_MBHC_ZDET, 0x02, 1, 0),
-};
-
-static const struct wcd_mbhc_intr intr_ids = {
-	.mbhc_sw_intr =  WCD934X_IRQ_MBHC_SW_DET,
-	.mbhc_btn_press_intr = WCD934X_IRQ_MBHC_BUTTON_PRESS_DET,
-	.mbhc_btn_release_intr = WCD934X_IRQ_MBHC_BUTTON_RELEASE_DET,
-	.mbhc_hs_ins_intr = WCD934X_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
-	.mbhc_hs_rem_intr = WCD934X_IRQ_MBHC_ELECT_INS_REM_DET,
-	.hph_left_ocp = WCD934X_IRQ_HPH_PA_OCPL_FAULT,
-	.hph_right_ocp = WCD934X_IRQ_HPH_PA_OCPR_FAULT,
-};
-
-
-static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
-	"cdc-vdd-mic-bias",
-};
-
-struct tavil_mbhc_zdet_param {
-	u16 ldo_ctl;
-	u16 noff;
-	u16 nshift;
-	u16 btn5;
-	u16 btn6;
-	u16 btn7;
-};
-
-static int tavil_mbhc_request_irq(struct snd_soc_codec *codec,
-				  int irq, irq_handler_t handler,
-				  const char *name, void *data)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	return wcd9xxx_request_irq(core_res, irq, handler, name, data);
-}
-
-static void tavil_mbhc_irq_control(struct snd_soc_codec *codec,
-				   int irq, bool enable)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-	if (enable)
-		wcd9xxx_enable_irq(core_res, irq);
-	else
-		wcd9xxx_disable_irq(core_res, irq);
-}
-
-static int tavil_mbhc_free_irq(struct snd_soc_codec *codec,
-			       int irq, void *data)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	wcd9xxx_free_irq(core_res, irq, data);
-	return 0;
-}
-
-static void tavil_mbhc_clk_setup(struct snd_soc_codec *codec,
-				 bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1,
-				    0x80, 0x80);
-	else
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1,
-				    0x80, 0x00);
-}
-
-static int tavil_mbhc_btn_to_num(struct snd_soc_codec *codec)
-{
-	return snd_soc_read(codec, WCD934X_ANA_MBHC_RESULT_3) & 0x7;
-}
-
-static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc,
-				      bool turn_on)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc;
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct wcd934x_on_demand_supply *supply;
-	int ret = 0;
-
-	wcd934x_mbhc = container_of(mbhc, struct wcd934x_mbhc, wcd_mbhc);
-
-	supply =  &wcd934x_mbhc->on_demand_list[WCD934X_ON_DEMAND_MICBIAS];
-	if (!supply->supply) {
-		dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
-				__func__, "onDemand Micbias");
-		return ret;
-	}
-
-	dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
-		supply->ondemand_supply_count);
-
-	if (turn_on) {
-		if (!(supply->ondemand_supply_count)) {
-			ret = snd_soc_dapm_force_enable_pin(
-				snd_soc_codec_get_dapm(codec),
-				"MICBIAS_REGULATOR");
-			snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-		}
-		supply->ondemand_supply_count++;
-	} else {
-		if (supply->ondemand_supply_count > 0)
-			supply->ondemand_supply_count--;
-		if (!(supply->ondemand_supply_count)) {
-			ret = snd_soc_dapm_disable_pin(
-				snd_soc_codec_get_dapm(codec),
-				"MICBIAS_REGULATOR");
-		snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-		}
-	}
-
-	if (ret)
-		dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
-			__func__, turn_on ? "enable" : "disabled");
-	else
-		dev_dbg(codec->dev, "%s: %s external micbias source\n",
-			__func__, turn_on ? "Enabled" : "Disabled");
-
-	return ret;
-}
-
-static void tavil_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
-					 bool enable)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT,
-				    0x01, 0x01);
-	else
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT,
-				    0x01, 0x00);
-}
-
-static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec,
-				       s16 *btn_low, s16 *btn_high,
-				       int num_btn, bool is_micbias)
-{
-	int i;
-	int vth;
-
-	if (num_btn > WCD_MBHC_DEF_BUTTONS) {
-		dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
-			__func__, num_btn);
-		return;
-	}
-	/*
-	 * Tavil just needs one set of thresholds for button detection
-	 * due to micbias voltage ramp to pullup upon button press. So
-	 * btn_low and is_micbias are ignored and always program button
-	 * thresholds using btn_high.
-	 */
-	for (i = 0; i < num_btn; i++) {
-		vth = ((btn_high[i] * 2) / 25) & 0x3F;
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN0 + i,
-				    0xFC, vth << 2);
-		dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
-			__func__, i, btn_high[i], vth);
-	}
-}
-
-static bool tavil_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-	bool ret = 0;
-
-	if (lock)
-		ret = wcd9xxx_lock_sleep(core_res);
-	else
-		wcd9xxx_unlock_sleep(core_res);
-
-	return ret;
-}
-
-static int tavil_mbhc_register_notifier(struct wcd_mbhc *mbhc,
-					struct notifier_block *nblock,
-					bool enable)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc;
-
-	wcd934x_mbhc = container_of(mbhc, struct wcd934x_mbhc, wcd_mbhc);
-
-	if (enable)
-		return blocking_notifier_chain_register(&wcd934x_mbhc->notifier,
-							nblock);
-	else
-		return blocking_notifier_chain_unregister(
-				&wcd934x_mbhc->notifier, nblock);
-}
-
-static bool tavil_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
-{
-	u8 val;
-
-	if (micb_num == MIC_BIAS_2) {
-		val = (snd_soc_read(mbhc->codec, WCD934X_ANA_MICB2) >> 6);
-		if (val == 0x01)
-			return true;
-	}
-	return false;
-}
-
-static bool tavil_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
-{
-	return (snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0) ? true : false;
-}
-
-static void tavil_mbhc_hph_l_pull_up_control(
-		struct snd_soc_codec *codec,
-		enum mbhc_hs_pullup_iref pull_up_cur)
-{
-	/* Default pull up current to 2uA */
-	if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
-	    pull_up_cur == I_DEFAULT)
-		pull_up_cur = I_2P0_UA;
-
-	dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
-		__func__, pull_up_cur);
-
-	snd_soc_update_bits(codec, WCD934X_MBHC_NEW_PLUG_DETECT_CTL,
-			    0xC0, pull_up_cur << 6);
-}
-
-static int tavil_mbhc_request_micbias(struct snd_soc_codec *codec,
-				      int micb_num, int req)
-{
-	int ret;
-
-	/*
-	 * If micbias is requested, make sure that there
-	 * is vote to enable mclk
-	 */
-	if (req == MICB_ENABLE)
-		tavil_cdc_mclk_enable(codec, true);
-
-	ret = tavil_micbias_control(codec, micb_num, req, false);
-
-	/*
-	 * Release vote for mclk while requesting for
-	 * micbias disable
-	 */
-	if (req == MICB_DISABLE)
-		tavil_cdc_mclk_enable(codec, false);
-
-	return ret;
-}
-
-static void tavil_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
-					 bool enable)
-{
-	if (enable) {
-		snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
-				    0x1C, 0x0C);
-		snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
-				    0x80, 0x80);
-	} else {
-		snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
-				    0x80, 0x00);
-		snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
-				    0x1C, 0x00);
-	}
-}
-
-static struct firmware_cal *tavil_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
-						   enum wcd_cal_type type)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc;
-	struct firmware_cal *hwdep_cal;
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	wcd934x_mbhc = container_of(mbhc, struct wcd934x_mbhc, wcd_mbhc);
-
-	if (!codec) {
-		pr_err("%s: NULL codec pointer\n", __func__);
-		return NULL;
-	}
-	hwdep_cal = wcdcal_get_fw_cal(wcd934x_mbhc->fw_data, type);
-	if (!hwdep_cal)
-		dev_err(codec->dev, "%s: cal not sent by %d\n",
-			__func__, type);
-
-	return hwdep_cal;
-}
-
-static int tavil_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
-					      int micb_num, bool req_en)
-{
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-	int rc, micb_mv;
-
-	if (micb_num != MIC_BIAS_2)
-		return -EINVAL;
-
-	/*
-	 * If device tree micbias level is already above the minimum
-	 * voltage needed to detect threshold microphone, then do
-	 * not change the micbias, just return.
-	 */
-	if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
-		return 0;
-
-	micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
-
-	rc = tavil_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
-
-	return rc;
-}
-
-static inline void tavil_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
-						s16 *d1_a, u16 noff,
-						int32_t *zdet)
-{
-	int i;
-	int val, val1;
-	s16 c1;
-	s32 x1, d1;
-	int32_t denom;
-	int minCode_param[] = {
-			3277, 1639, 820, 410, 205, 103, 52, 26
-	};
-
-	regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x20);
-	for (i = 0; i < TAVIL_ZDET_NUM_MEASUREMENTS; i++) {
-		regmap_read(wcd9xxx->regmap, WCD934X_ANA_MBHC_RESULT_2, &val);
-		if (val & 0x80)
-			break;
-	}
-	val = val << 0x8;
-	regmap_read(wcd9xxx->regmap, WCD934X_ANA_MBHC_RESULT_1, &val1);
-	val |= val1;
-	regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x00);
-	x1 = TAVIL_MBHC_GET_X1(val);
-	c1 = TAVIL_MBHC_GET_C1(val);
-	/* If ramp is not complete, give additional 5ms */
-	if ((c1 < 2) && x1)
-		usleep_range(5000, 5050);
-
-	if (!c1 || !x1) {
-		dev_dbg(wcd9xxx->dev,
-			"%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
-			__func__, c1, x1);
-		goto ramp_down;
-	}
-	d1 = d1_a[c1];
-	denom = (x1 * d1) - (1 << (14 - noff));
-	if (denom > 0)
-		*zdet = (TAVIL_MBHC_ZDET_CONST * 1000) / denom;
-	else if (x1 < minCode_param[noff])
-		*zdet = TAVIL_ZDET_FLOATING_IMPEDANCE;
-
-	dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
-		__func__, d1, c1, x1, *zdet);
-ramp_down:
-	i = 0;
-	while (x1) {
-		regmap_bulk_read(wcd9xxx->regmap,
-				 WCD934X_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
-		x1 = TAVIL_MBHC_GET_X1(val);
-		i++;
-		if (i == TAVIL_ZDET_NUM_MEASUREMENTS)
-			break;
-	}
-}
-
-static void tavil_mbhc_zdet_ramp(struct snd_soc_codec *codec,
-				 struct tavil_mbhc_zdet_param *zdet_param,
-				 int32_t *zl, int32_t *zr, s16 *d1_a)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int32_t zdet = 0;
-
-	snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x70,
-			    zdet_param->ldo_ctl << 4);
-	snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN5, 0xFC,
-			    zdet_param->btn5);
-	snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN6, 0xFC,
-			    zdet_param->btn6);
-	snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN7, 0xFC,
-			    zdet_param->btn7);
-	snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x0F,
-			    zdet_param->noff);
-	snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_RAMP_CTL, 0x0F,
-			    zdet_param->nshift);
-
-	if (!zl)
-		goto z_right;
-	/* Start impedance measurement for HPH_L */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_ZDET, 0x80, 0x80);
-	dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
-		__func__, zdet_param->noff);
-	tavil_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_ZDET, 0x80, 0x00);
-
-	*zl = zdet;
-
-z_right:
-	if (!zr)
-		return;
-	/* Start impedance measurement for HPH_R */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_ZDET, 0x40, 0x40);
-	dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
-		__func__, zdet_param->noff);
-	tavil_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_ZDET, 0x40, 0x00);
-
-	*zr = zdet;
-}
-
-static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
-					    int32_t *z_val, int flag_l_r)
-{
-	s16 q1;
-	int q1_cal;
-
-	if (*z_val < (TAVIL_ZDET_VAL_400/1000))
-		q1 = snd_soc_read(codec,
-			WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
-	else
-		q1 = snd_soc_read(codec,
-			WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
-	if (q1 & 0x80)
-		q1_cal = (10000 - ((q1 & 0x7F) * 25));
-	else
-		q1_cal = (10000 + (q1 * 25));
-	if (q1_cal > 0)
-		*z_val = ((*z_val) * 10000) / q1_cal;
-}
-
-static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
-					  uint32_t *zr)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	s16 reg0, reg1, reg2, reg3, reg4;
-	int32_t z1L, z1R, z1Ls;
-	int zMono, z_diff1, z_diff2;
-	bool is_fsm_disable = false;
-	struct tavil_mbhc_zdet_param zdet_param[] = {
-		{4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
-		{2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
-		{1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
-		{1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
-	};
-	struct tavil_mbhc_zdet_param *zdet_param_ptr = NULL;
-	s16 d1_a[][4] = {
-		{0, 30, 90, 30},
-		{0, 30, 30, 5},
-		{0, 30, 30, 5},
-		{0, 30, 30, 5},
-	};
-	s16 *d1 = NULL;
-
-	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
-
-	reg0 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN5);
-	reg1 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN6);
-	reg2 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN7);
-	reg3 = snd_soc_read(codec, WCD934X_MBHC_CTL_CLK);
-	reg4 = snd_soc_read(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL);
-
-	if (snd_soc_read(codec, WCD934X_ANA_MBHC_ELECT) & 0x80) {
-		is_fsm_disable = true;
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD934X_ANA_MBHC_ELECT, 0x80, 0x00);
-	}
-
-	/* For NO-jack, disable L_DET_EN before Z-det measurements */
-	if (mbhc->hphl_swh)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD934X_ANA_MBHC_MECH, 0x80, 0x00);
-
-	/* Turn off 100k pull down on HPHL */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_MECH, 0x01, 0x00);
-
-	/* First get impedance on Left */
-	d1 = d1_a[1];
-	zdet_param_ptr = &zdet_param[1];
-	tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
-
-	if (!TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
-		goto left_ch_impedance;
-
-	/* Second ramp for left ch */
-	if (z1L < TAVIL_ZDET_VAL_32) {
-		zdet_param_ptr = &zdet_param[0];
-		d1 = d1_a[0];
-	} else if ((z1L > TAVIL_ZDET_VAL_400) && (z1L <= TAVIL_ZDET_VAL_1200)) {
-		zdet_param_ptr = &zdet_param[2];
-		d1 = d1_a[2];
-	} else if (z1L > TAVIL_ZDET_VAL_1200) {
-		zdet_param_ptr = &zdet_param[3];
-		d1 = d1_a[3];
-	}
-	tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
-
-left_ch_impedance:
-	if ((z1L == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
-		(z1L > TAVIL_ZDET_VAL_100K)) {
-		*zl = TAVIL_ZDET_FLOATING_IMPEDANCE;
-		zdet_param_ptr = &zdet_param[1];
-		d1 = d1_a[1];
-	} else {
-		*zl = z1L/1000;
-		tavil_wcd_mbhc_qfuse_cal(codec, zl, 0);
-	}
-	dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
-		__func__, *zl);
-
-	/* Start of right impedance ramp and calculation */
-	tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
-	if (TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
-		if (((z1R > TAVIL_ZDET_VAL_1200) &&
-			(zdet_param_ptr->noff == 0x6)) ||
-			((*zl) != TAVIL_ZDET_FLOATING_IMPEDANCE))
-			goto right_ch_impedance;
-		/* Second ramp for right ch */
-		if (z1R < TAVIL_ZDET_VAL_32) {
-			zdet_param_ptr = &zdet_param[0];
-			d1 = d1_a[0];
-		} else if ((z1R > TAVIL_ZDET_VAL_400) &&
-			(z1R <= TAVIL_ZDET_VAL_1200)) {
-			zdet_param_ptr = &zdet_param[2];
-			d1 = d1_a[2];
-		} else if (z1R > TAVIL_ZDET_VAL_1200) {
-			zdet_param_ptr = &zdet_param[3];
-			d1 = d1_a[3];
-		}
-		tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
-	}
-right_ch_impedance:
-	if ((z1R == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
-		(z1R > TAVIL_ZDET_VAL_100K)) {
-		*zr = TAVIL_ZDET_FLOATING_IMPEDANCE;
-	} else {
-		*zr = z1R/1000;
-		tavil_wcd_mbhc_qfuse_cal(codec, zr, 1);
-	}
-	dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
-		__func__, *zr);
-
-	/* Mono/stereo detection */
-	if ((*zl == TAVIL_ZDET_FLOATING_IMPEDANCE) &&
-		(*zr == TAVIL_ZDET_FLOATING_IMPEDANCE)) {
-		dev_dbg(codec->dev,
-			"%s: plug type is invalid or extension cable\n",
-			__func__);
-		goto zdet_complete;
-	}
-	if ((*zl == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
-	    (*zr == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
-	    ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
-	    ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
-		dev_dbg(codec->dev,
-			"%s: Mono plug type with one ch floating or shorted to GND\n",
-			__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_MONO;
-		goto zdet_complete;
-	}
-	snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x02);
-	snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x01);
-	if (*zl < (TAVIL_ZDET_VAL_32/1000))
-		tavil_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
-	else
-		tavil_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
-	snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x00);
-	snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x00);
-	z1Ls /= 1000;
-	tavil_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
-	/* Parallel of left Z and 9 ohm pull down resistor */
-	zMono = ((*zl) * 9) / ((*zl) + 9);
-	z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
-	z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
-	if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
-		dev_dbg(codec->dev, "%s: stereo plug type detected\n",
-			__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_STEREO;
-	} else {
-		dev_dbg(codec->dev, "%s: MONO plug type detected\n",
-			__func__);
-		mbhc->hph_type = WCD_MBHC_HPH_MONO;
-	}
-
-zdet_complete:
-	snd_soc_write(codec, WCD934X_ANA_MBHC_BTN5, reg0);
-	snd_soc_write(codec, WCD934X_ANA_MBHC_BTN6, reg1);
-	snd_soc_write(codec, WCD934X_ANA_MBHC_BTN7, reg2);
-	/* Turn on 100k pull down on HPHL */
-	regmap_update_bits(wcd9xxx->regmap,
-			   WCD934X_ANA_MBHC_MECH, 0x01, 0x01);
-
-	/* For NO-jack, re-enable L_DET_EN after Z-det measurements */
-	if (mbhc->hphl_swh)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD934X_ANA_MBHC_MECH, 0x80, 0x80);
-
-	snd_soc_write(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, reg4);
-	snd_soc_write(codec, WCD934X_MBHC_CTL_CLK, reg3);
-	if (is_fsm_disable)
-		regmap_update_bits(wcd9xxx->regmap,
-				   WCD934X_ANA_MBHC_ELECT, 0x80, 0x80);
-}
-
-static void tavil_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-	if (enable) {
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
-				    0x02, 0x02);
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
-				    0x40, 0x40);
-	} else {
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
-				    0x40, 0x00);
-		snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
-				    0x02, 0x00);
-	}
-}
-
-static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
-					  bool enable)
-{
-	if (enable) {
-		snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
-				    0x40, 0x40);
-		snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
-				    0x10, 0x10);
-	} else {
-		snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
-				    0x40, 0x00);
-		snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
-				    0x10, 0x00);
-	}
-}
-static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-
-	if ((mbhc->moist_rref == R_OFF) ||
-	    (mbhc->mbhc_cfg->enable_usbc_analog)) {
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
-				    0x0C, R_OFF << 2);
-		return;
-	}
-
-	/* Donot enable moisture detection if jack type is NC */
-	if (!mbhc->hphl_swh) {
-		dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
-			__func__);
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
-				    0x0C, R_OFF << 2);
-		return;
-	}
-
-	snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
-			    0x0C, mbhc->moist_rref << 2);
-}
-
-static bool tavil_hph_register_recovery(struct wcd_mbhc *mbhc)
-{
-	struct snd_soc_codec *codec = mbhc->codec;
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-
-	if (!wcd934x_mbhc)
-		return false;
-
-	wcd934x_mbhc->is_hph_recover = false;
-	snd_soc_dapm_force_enable_pin(snd_soc_codec_get_dapm(codec),
-				      "RESET_HPH_REGISTERS");
-	snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-
-	snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
-				 "RESET_HPH_REGISTERS");
-	snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-
-	return wcd934x_mbhc->is_hph_recover;
-}
-
-static void tavil_update_anc_state(struct snd_soc_codec *codec, bool enable,
-				   int anc_num)
-{
-	if (enable)
-		snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 +
-				(20 * anc_num), 0x10, 0x10);
-	else
-		snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 +
-				(20 * anc_num), 0x10, 0x00);
-}
-
-static bool tavil_is_anc_on(struct wcd_mbhc *mbhc)
-{
-	bool anc_on = false;
-	u16 ancl, ancr;
-
-	ancl =
-	(snd_soc_read(mbhc->codec, WCD934X_CDC_RX1_RX_PATH_CFG0)) & 0x10;
-	ancr =
-	(snd_soc_read(mbhc->codec, WCD934X_CDC_RX2_RX_PATH_CFG0)) & 0x10;
-
-	anc_on = !!(ancl | ancr);
-
-	return anc_on;
-}
-
-static const struct wcd_mbhc_cb mbhc_cb = {
-	.request_irq = tavil_mbhc_request_irq,
-	.irq_control = tavil_mbhc_irq_control,
-	.free_irq = tavil_mbhc_free_irq,
-	.clk_setup = tavil_mbhc_clk_setup,
-	.map_btn_code_to_num = tavil_mbhc_btn_to_num,
-	.enable_mb_source = tavil_enable_ext_mb_source,
-	.mbhc_bias = tavil_mbhc_mbhc_bias_control,
-	.set_btn_thr = tavil_mbhc_program_btn_thr,
-	.lock_sleep = tavil_mbhc_lock_sleep,
-	.register_notifier = tavil_mbhc_register_notifier,
-	.micbias_enable_status = tavil_mbhc_micb_en_status,
-	.hph_pa_on_status = tavil_mbhc_hph_pa_on_status,
-	.hph_pull_up_control = tavil_mbhc_hph_l_pull_up_control,
-	.mbhc_micbias_control = tavil_mbhc_request_micbias,
-	.mbhc_micb_ramp_control = tavil_mbhc_micb_ramp_control,
-	.get_hwdep_fw_cal = tavil_get_hwdep_fw_cal,
-	.mbhc_micb_ctrl_thr_mic = tavil_mbhc_micb_ctrl_threshold_mic,
-	.compute_impedance = tavil_wcd_mbhc_calc_impedance,
-	.mbhc_gnd_det_ctrl = tavil_mbhc_gnd_det_ctrl,
-	.hph_pull_down_ctrl = tavil_mbhc_hph_pull_down_ctrl,
-	.mbhc_moisture_config = tavil_mbhc_moisture_config,
-	.hph_register_recovery = tavil_hph_register_recovery,
-	.update_anc_state = tavil_update_anc_state,
-	.is_anc_on = tavil_is_anc_on,
-};
-
-static struct regulator *tavil_codec_find_ondemand_regulator(
-		struct snd_soc_codec *codec, const char *name)
-{
-	int i;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-
-	for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
-		if (pdata->regulator[i].ondemand &&
-		    wcd9xxx->supplies[i].supply &&
-		    !strcmp(wcd9xxx->supplies[i].supply, name))
-			return wcd9xxx->supplies[i].consumer;
-	}
-
-	dev_dbg(codec->dev, "Warning: regulator not found:%s\n",
-		name);
-	return NULL;
-}
-
-static int tavil_get_hph_type(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-	struct wcd_mbhc *mbhc;
-
-	if (!wcd934x_mbhc) {
-		dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
-		return -EINVAL;
-	}
-
-	mbhc = &wcd934x_mbhc->wcd_mbhc;
-
-	ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
-	dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
-
-	return 0;
-}
-
-static int tavil_hph_impedance_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	uint32_t zl, zr;
-	bool hphr;
-	struct soc_multi_mixer_control *mc;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-
-	if (!wcd934x_mbhc) {
-		dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
-		return -EINVAL;
-	}
-
-	mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
-	hphr = mc->shift;
-	wcd_mbhc_get_impedance(&wcd934x_mbhc->wcd_mbhc, &zl, &zr);
-	dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
-	ucontrol->value.integer.value[0] = hphr ? zr : zl;
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
-		       tavil_get_hph_type, NULL),
-};
-
-static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
-		       tavil_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
-		       tavil_hph_impedance_get, NULL),
-};
-
-/*
- * tavil_mbhc_get_impedance: get impedance of headphone left and right channels
- * @wcd934x_mbhc: handle to struct wcd934x_mbhc *
- * @zl: handle to left-ch impedance
- * @zr: handle to right-ch impedance
- * return 0 for success or error code in case of failure
- */
-int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
-			     uint32_t *zl, uint32_t *zr)
-{
-	if (!wcd934x_mbhc) {
-		pr_err("%s: mbhc not initialized!\n", __func__);
-		return -EINVAL;
-	}
-	if (!zl || !zr) {
-		pr_err("%s: zl or zr null!\n", __func__);
-		return -EINVAL;
-	}
-
-	return wcd_mbhc_get_impedance(&wcd934x_mbhc->wcd_mbhc, zl, zr);
-}
-EXPORT_SYMBOL(tavil_mbhc_get_impedance);
-
-/*
- * tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality
- * @codec: handle to snd_soc_codec *
- * @mbhc_cfg: handle to mbhc configuration structure
- * return 0 if mbhc_start is success or error code in case of failure
- */
-int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
-			 struct wcd_mbhc_config *mbhc_cfg)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-
-	if (!wcd934x_mbhc) {
-		dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
-		return -EINVAL;
-	}
-
-	return wcd_mbhc_start(&wcd934x_mbhc->wcd_mbhc, mbhc_cfg);
-}
-EXPORT_SYMBOL(tavil_mbhc_hs_detect);
-
-/*
- * tavil_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
- * @codec: handle to snd_soc_codec *
- */
-void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-
-	if (!wcd934x_mbhc) {
-		dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
-		return;
-	}
-	wcd_mbhc_stop(&wcd934x_mbhc->wcd_mbhc);
-}
-EXPORT_SYMBOL(tavil_mbhc_hs_detect_exit);
-
-/*
- * tavil_mbhc_post_ssr_init: initialize mbhc for tavil post subsystem restart
- * @mbhc: poniter to wcd934x_mbhc structure
- * @codec: handle to snd_soc_codec *
- *
- * return 0 if mbhc_init is success or error code in case of failure
- */
-int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
-			     struct snd_soc_codec *codec)
-{
-	int ret;
-	struct wcd_mbhc *wcd_mbhc;
-
-	if (!mbhc || !codec)
-		return -EINVAL;
-
-	wcd_mbhc = &mbhc->wcd_mbhc;
-	if (wcd_mbhc == NULL) {
-		pr_err("%s: wcd_mbhc is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	wcd_mbhc_deinit(wcd_mbhc);
-	ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids,
-			    wcd_mbhc_registers, TAVIL_ZDET_SUPPORTED);
-	if (ret) {
-		dev_err(codec->dev, "%s: mbhc initialization failed\n",
-			__func__);
-		goto done;
-	}
-	if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) {
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04);
-		snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01);
-	}
-
-done:
-	return ret;
-}
-EXPORT_SYMBOL(tavil_mbhc_post_ssr_init);
-
-/*
- * tavil_mbhc_init: initialize mbhc for tavil
- * @mbhc: poniter to wcd934x_mbhc struct pointer to store the configs
- * @codec: handle to snd_soc_codec *
- * @fw_data: handle to firmware data
- *
- * return 0 if mbhc_init is success or error code in case of failure
- */
-int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
-		    struct fw_info *fw_data)
-{
-	struct regulator *supply;
-	struct wcd934x_mbhc *wcd934x_mbhc;
-	struct wcd_mbhc *wcd_mbhc;
-	int ret;
-
-	wcd934x_mbhc = devm_kzalloc(codec->dev, sizeof(struct wcd934x_mbhc),
-				    GFP_KERNEL);
-	if (!wcd934x_mbhc)
-		return -ENOMEM;
-
-	wcd934x_mbhc->wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	wcd934x_mbhc->fw_data = fw_data;
-	BLOCKING_INIT_NOTIFIER_HEAD(&wcd934x_mbhc->notifier);
-	wcd_mbhc = &wcd934x_mbhc->wcd_mbhc;
-	if (wcd_mbhc == NULL) {
-		pr_err("%s: wcd_mbhc is NULL\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-
-	/* Setting default mbhc detection logic to ADC for Tavil */
-	wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC;
-
-	ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb,
-				&intr_ids, wcd_mbhc_registers,
-				TAVIL_ZDET_SUPPORTED);
-	if (ret) {
-		dev_err(codec->dev, "%s: mbhc initialization failed\n",
-			__func__);
-		goto err;
-	}
-
-	supply = tavil_codec_find_ondemand_regulator(codec,
-			on_demand_supply_name[WCD934X_ON_DEMAND_MICBIAS]);
-	if (supply) {
-		wcd934x_mbhc->on_demand_list[
-			WCD934X_ON_DEMAND_MICBIAS].supply =
-				supply;
-		wcd934x_mbhc->on_demand_list[
-			WCD934X_ON_DEMAND_MICBIAS].ondemand_supply_count =
-				0;
-	}
-
-	(*mbhc) = wcd934x_mbhc;
-	snd_soc_add_codec_controls(codec, impedance_detect_controls,
-				   ARRAY_SIZE(impedance_detect_controls));
-	snd_soc_add_codec_controls(codec, hph_type_detect_controls,
-				   ARRAY_SIZE(hph_type_detect_controls));
-
-	if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) {
-		snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04);
-		snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01);
-	}
-
-	return 0;
-err:
-	devm_kfree(codec->dev, wcd934x_mbhc);
-	return ret;
-}
-EXPORT_SYMBOL(tavil_mbhc_init);
-
-/*
- * tavil_mbhc_deinit: deinitialize mbhc for tavil
- * @codec: handle to snd_soc_codec *
- */
-void tavil_mbhc_deinit(struct snd_soc_codec *codec)
-{
-	struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
-
-	if (wcd934x_mbhc) {
-		wcd_mbhc_deinit(&wcd934x_mbhc->wcd_mbhc);
-		devm_kfree(codec->dev, wcd934x_mbhc);
-	}
-}
-EXPORT_SYMBOL(tavil_mbhc_deinit);
diff --git a/sound/soc/codecs/wcd934x/wcd934x-mbhc.h b/sound/soc/codecs/wcd934x/wcd934x-mbhc.h
deleted file mode 100644
index 53c886d..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-mbhc.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD934X_MBHC_H__
-#define __WCD934X_MBHC_H__
-#include "../wcd-mbhc-v2.h"
-
-enum wcd934x_on_demand_supply_name {
-	WCD934X_ON_DEMAND_MICBIAS = 0,
-	WCD934X_ON_DEMAND_SUPPLIES_MAX,
-};
-
-struct wcd934x_on_demand_supply {
-	struct regulator *supply;
-	int ondemand_supply_count;
-};
-
-struct wcd934x_mbhc {
-	struct wcd_mbhc wcd_mbhc;
-	struct blocking_notifier_head notifier;
-	struct wcd934x_on_demand_supply on_demand_list[
-			WCD934X_ON_DEMAND_SUPPLIES_MAX];
-	struct wcd9xxx *wcd9xxx;
-	struct fw_info *fw_data;
-	bool mbhc_started;
-	bool is_hph_recover;
-};
-
-#if IS_ENABLED(CONFIG_SND_SOC_WCD934X_MBHC)
-extern int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
-			   struct snd_soc_codec *codec,
-			   struct fw_info *fw_data);
-extern void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
-extern int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
-				struct wcd_mbhc_config *mbhc_cfg);
-extern void tavil_mbhc_deinit(struct snd_soc_codec *codec);
-extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
-				    struct snd_soc_codec *codec);
-extern int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
-				    uint32_t *zl, uint32_t *zr);
-#else
-static inline int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
-				  struct snd_soc_codec *codec,
-				  struct fw_info *fw_data)
-{
-	return 0;
-}
-static inline void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
-{
-}
-static inline int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
-				       struct wcd_mbhc_config *mbhc_cfg)
-{
-		return 0;
-}
-static inline void tavil_mbhc_deinit(struct snd_soc_codec *codec)
-{
-}
-static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
-					   struct snd_soc_codec *codec)
-{
-	return 0;
-}
-static inline int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
-					   uint32_t *zl, uint32_t *zr)
-{
-	if (zl)
-		*zl = 0;
-	if (zr)
-		*zr = 0;
-	return -EINVAL;
-}
-#endif
-
-#endif /* __WCD934X_MBHC_H__ */
diff --git a/sound/soc/codecs/wcd934x/wcd934x-routing.h b/sound/soc/codecs/wcd934x/wcd934x-routing.h
deleted file mode 100644
index 93a1ad3..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x-routing.h
+++ /dev/null
@@ -1,1235 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WCD934X_ROUTING_H
-#define WCD934X_ROUTING_H
-
-#include <sound/soc-dapm.h>
-
-const struct snd_soc_dapm_route tavil_slim_audio_map[] = {
-
-	/* Virtual input widgets */
-	{"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
-	{"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
-	{"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
-	{"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
-
-	/* Virtual input widget Mixer */
-	{"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0"},
-	{"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1"},
-	{"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2"},
-	{"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3"},
-	{"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4"},
-	{"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5"},
-	{"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6"},
-	{"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7"},
-	{"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8"},
-	{"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9"},
-	{"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10"},
-	{"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11"},
-	{"AIF1_CAP Mixer", "SLIM TX13", "SLIM TX13"},
-
-	{"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0"},
-	{"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1"},
-	{"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2"},
-	{"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3"},
-	{"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4"},
-	{"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5"},
-	{"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6"},
-	{"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7"},
-	{"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8"},
-	{"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9"},
-	{"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10"},
-	{"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11"},
-	{"AIF2_CAP Mixer", "SLIM TX13", "SLIM TX13"},
-
-	{"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0"},
-	{"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1"},
-	{"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2"},
-	{"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3"},
-	{"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4"},
-	{"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5"},
-	{"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6"},
-	{"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7"},
-	{"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8"},
-	{"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9"},
-	{"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10"},
-	{"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11"},
-	{"AIF3_CAP Mixer", "SLIM TX13", "SLIM TX13"},
-
-	{"AIF4_MAD Mixer", "SLIM TX13", "SLIM TX13"},
-
-	{"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
-	{"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
-
-	{"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
-	{"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
-
-	{"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
-	{"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
-
-	{"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
-	{"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
-
-	{"SLIM RX0", NULL, "SLIM RX0 MUX"},
-	{"SLIM RX1", NULL, "SLIM RX1 MUX"},
-	{"SLIM RX2", NULL, "SLIM RX2 MUX"},
-	{"SLIM RX3", NULL, "SLIM RX3 MUX"},
-	{"SLIM RX4", NULL, "SLIM RX4 MUX"},
-	{"SLIM RX5", NULL, "SLIM RX5 MUX"},
-	{"SLIM RX6", NULL, "SLIM RX6 MUX"},
-	{"SLIM RX7", NULL, "SLIM RX7 MUX"},
-
-};
-
-const struct snd_soc_dapm_route tavil_audio_map[] = {
-
-	/* WDMA3 */
-	{"WDMA3 PORT0 MUX", "DEC0", "ADC MUX0"},
-	{"WDMA3 PORT0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
-	{"WDMA3 PORT1 MUX", "DEC1", "ADC MUX1"},
-	{"WDMA3 PORT1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
-	{"WDMA3 PORT2 MUX", "DEC2", "ADC MUX2"},
-	{"WDMA3 PORT2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
-	{"WDMA3 PORT3 MUX", "DEC3", "ADC MUX3"},
-	{"WDMA3 PORT3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
-	{"WDMA3 PORT4 MUX", "DEC4", "ADC MUX4"},
-	{"WDMA3 PORT4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
-	{"WDMA3 PORT5 MUX", "DEC5", "ADC MUX5"},
-	{"WDMA3 PORT5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
-	{"WDMA3 PORT6 MUX", "DEC6", "ADC MUX6"},
-	{"WDMA3 PORT6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
-
-	{"WDMA3 CH0 MUX", "PORT_0", "WDMA3 PORT0 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_1", "WDMA3 PORT1 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_2", "WDMA3 PORT2 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_3", "WDMA3 PORT3 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_4", "WDMA3 PORT4 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_5", "WDMA3 PORT5 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_6", "WDMA3 PORT6 MUX"},
-	{"WDMA3 CH0 MUX", "PORT_7", "ADC MUX7"},
-	{"WDMA3 CH0 MUX", "PORT_8", "ADC MUX8"},
-
-	{"WDMA3 CH1 MUX", "PORT_0", "WDMA3 PORT0 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_1", "WDMA3 PORT1 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_2", "WDMA3 PORT2 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_3", "WDMA3 PORT3 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_4", "WDMA3 PORT4 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_5", "WDMA3 PORT5 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_6", "WDMA3 PORT6 MUX"},
-	{"WDMA3 CH1 MUX", "PORT_7", "ADC MUX7"},
-	{"WDMA3 CH1 MUX", "PORT_8", "ADC MUX8"},
-
-	{"WDMA3 CH2 MUX", "PORT_0", "WDMA3 PORT0 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_1", "WDMA3 PORT1 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_2", "WDMA3 PORT2 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_3", "WDMA3 PORT3 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_4", "WDMA3 PORT4 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_5", "WDMA3 PORT5 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_6", "WDMA3 PORT6 MUX"},
-	{"WDMA3 CH2 MUX", "PORT_7", "ADC MUX7"},
-	{"WDMA3 CH2 MUX", "PORT_8", "ADC MUX8"},
-
-	{"WDMA3 CH3 MUX", "PORT_0", "WDMA3 PORT0 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_1", "WDMA3 PORT1 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_2", "WDMA3 PORT2 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_3", "WDMA3 PORT3 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_4", "WDMA3 PORT4 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_5", "WDMA3 PORT5 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_6", "WDMA3 PORT6 MUX"},
-	{"WDMA3 CH3 MUX", "PORT_7", "ADC MUX7"},
-	{"WDMA3 CH3 MUX", "PORT_8", "ADC MUX8"},
-
-	{"WDMA3_CH_MIXER", NULL, "WDMA3 CH0 MUX"},
-	{"WDMA3_CH_MIXER", NULL, "WDMA3 CH1 MUX"},
-	{"WDMA3_CH_MIXER", NULL, "WDMA3 CH2 MUX"},
-	{"WDMA3_CH_MIXER", NULL, "WDMA3 CH3 MUX"},
-
-	{"WDMA3_ON_OFF", "Switch", "WDMA3_CH_MIXER"},
-	{"WDMA3_OUT", NULL, "WDMA3_ON_OFF"},
-
-	/* MAD */
-	{"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
-	{"MAD_SEL MUX", "MSM", "MADINPUT"},
-
-	{"MAD_INP MUX", "MAD", "MAD_SEL MUX"},
-	{"MAD_INP MUX", "DEC1", "ADC MUX1"},
-
-	{"MAD_BROADCAST", "Switch", "MAD_INP MUX"},
-	{"MAD_CPE1", "Switch", "MAD_INP MUX"},
-	{"MAD_CPE2", "Switch", "MAD_INP MUX"},
-
-	{"MAD_CPE_OUT1", NULL, "MAD_CPE1"},
-	{"MAD_CPE_OUT2", NULL, "MAD_CPE2"},
-
-	/* VI Feedback */
-	{"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
-	{"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
-	{"AIF4 VI", NULL, "AIF4_VI Mixer"},
-
-	/* CDC Tx interface with SLIMBUS */
-	{"SLIM TX0", NULL, "CDC_IF TX0 MUX"},
-	{"SLIM TX1", NULL, "CDC_IF TX1 MUX"},
-	{"SLIM TX2", NULL, "CDC_IF TX2 MUX"},
-	{"SLIM TX3", NULL, "CDC_IF TX3 MUX"},
-	{"SLIM TX4", NULL, "CDC_IF TX4 MUX"},
-	{"SLIM TX5", NULL, "CDC_IF TX5 MUX"},
-	{"SLIM TX6", NULL, "CDC_IF TX6 MUX"},
-	{"SLIM TX7", NULL, "CDC_IF TX7 MUX"},
-	{"SLIM TX8", NULL, "CDC_IF TX8 MUX"},
-	{"SLIM TX9", NULL, "CDC_IF TX9 MUX"},
-	{"SLIM TX10", NULL, "CDC_IF TX10 MUX"},
-	{"SLIM TX11", NULL, "CDC_IF TX11 MUX"},
-	{"SLIM TX13", NULL, "CDC_IF TX13 MUX"},
-
-	{"CDC_IF TX0 MUX", "DEC0", "ADC MUX0"},
-	{"CDC_IF TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
-	{"CDC_IF TX0 MUX", "DEC0_192", "ADC US MUX0"},
-
-	{"CDC_IF TX1 MUX", "DEC1", "ADC MUX1"},
-	{"CDC_IF TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
-	{"CDC_IF TX1 MUX", "DEC1_192", "ADC US MUX1"},
-
-	{"CDC_IF TX2 MUX", "DEC2", "ADC MUX2"},
-	{"CDC_IF TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
-	{"CDC_IF TX2 MUX", "DEC2_192", "ADC US MUX2"},
-
-	{"CDC_IF TX3 MUX", "DEC3", "ADC MUX3"},
-	{"CDC_IF TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
-	{"CDC_IF TX3 MUX", "DEC3_192", "ADC US MUX3"},
-
-	{"CDC_IF TX4 MUX", "DEC4", "ADC MUX4"},
-	{"CDC_IF TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
-	{"CDC_IF TX4 MUX", "DEC4_192", "ADC US MUX4"},
-
-	{"CDC_IF TX5 MUX", "DEC5", "ADC MUX5"},
-	{"CDC_IF TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
-	{"CDC_IF TX5 MUX", "DEC5_192", "ADC US MUX5"},
-
-	{"CDC_IF TX6 MUX", "DEC6", "ADC MUX6"},
-	{"CDC_IF TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
-	{"CDC_IF TX6 MUX", "DEC6_192", "ADC US MUX6"},
-
-	{"CDC_IF TX7 MUX", "DEC7", "ADC MUX7"},
-	{"CDC_IF TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
-	{"CDC_IF TX7 MUX", "DEC7_192", "ADC US MUX7"},
-
-	{"CDC_IF TX8 MUX", "DEC8", "ADC MUX8"},
-	{"CDC_IF TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
-	{"CDC_IF TX8 MUX", "DEC8_192", "ADC US MUX8"},
-
-	{"CDC_IF TX9 MUX", "DEC7", "ADC MUX7"},
-	{"CDC_IF TX9 MUX", "DEC7_192", "ADC US MUX7"},
-	{"CDC_IF TX10 MUX", "DEC6", "ADC MUX6"},
-	{"CDC_IF TX10 MUX", "DEC6_192", "ADC US MUX6"},
-
-	{"CDC_IF TX11 MUX", "DEC_0_5", "CDC_IF TX11 INP1 MUX"},
-	{"CDC_IF TX11 MUX", "DEC_9_12", "CDC_IF TX11 INP1 MUX"},
-	{"CDC_IF TX11 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"CDC_IF TX11 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"CDC_IF TX11 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"CDC_IF TX11 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"CDC_IF TX11 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"CDC_IF TX11 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"CDC_IF TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
-
-	{"CDC_IF TX13 MUX", "MAD_BRDCST", "MAD_BROADCAST"},
-	{"CDC_IF TX13 MUX", "CDC_DEC_5", "CDC_IF TX13 INP1 MUX"},
-	{"CDC_IF TX13 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"CDC_IF TX13 INP1 MUX", "DEC5_192", "ADC US MUX5"},
-
-	{"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
-	{"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
-
-	{"ADC US MUX0", "US_Switch", "ADC MUX0"},
-	{"ADC US MUX1", "US_Switch", "ADC MUX1"},
-	{"ADC US MUX2", "US_Switch", "ADC MUX2"},
-	{"ADC US MUX3", "US_Switch", "ADC MUX3"},
-	{"ADC US MUX4", "US_Switch", "ADC MUX4"},
-	{"ADC US MUX5", "US_Switch", "ADC MUX5"},
-	{"ADC US MUX6", "US_Switch", "ADC MUX6"},
-	{"ADC US MUX7", "US_Switch", "ADC MUX7"},
-	{"ADC US MUX8", "US_Switch", "ADC MUX8"},
-
-	{"ADC MUX0", "DMIC", "DMIC MUX0"},
-	{"ADC MUX0", "AMIC", "AMIC MUX0"},
-	{"ADC MUX1", "DMIC", "DMIC MUX1"},
-	{"ADC MUX1", "AMIC", "AMIC MUX1"},
-	{"ADC MUX2", "DMIC", "DMIC MUX2"},
-	{"ADC MUX2", "AMIC", "AMIC MUX2"},
-	{"ADC MUX3", "DMIC", "DMIC MUX3"},
-	{"ADC MUX3", "AMIC", "AMIC MUX3"},
-	{"ADC MUX4", "DMIC", "DMIC MUX4"},
-	{"ADC MUX4", "AMIC", "AMIC MUX4"},
-	{"ADC MUX5", "DMIC", "DMIC MUX5"},
-	{"ADC MUX5", "AMIC", "AMIC MUX5"},
-	{"ADC MUX6", "DMIC", "DMIC MUX6"},
-	{"ADC MUX6", "AMIC", "AMIC MUX6"},
-	{"ADC MUX7", "DMIC", "DMIC MUX7"},
-	{"ADC MUX7", "AMIC", "AMIC MUX7"},
-	{"ADC MUX8", "DMIC", "DMIC MUX8"},
-	{"ADC MUX8", "AMIC", "AMIC MUX8"},
-	{"ADC MUX10", "DMIC", "DMIC MUX10"},
-	{"ADC MUX10", "AMIC", "AMIC MUX10"},
-	{"ADC MUX11", "DMIC", "DMIC MUX11"},
-	{"ADC MUX11", "AMIC", "AMIC MUX11"},
-	{"ADC MUX12", "DMIC", "DMIC MUX12"},
-	{"ADC MUX12", "AMIC", "AMIC MUX12"},
-	{"ADC MUX13", "DMIC", "DMIC MUX13"},
-	{"ADC MUX13", "AMIC", "AMIC MUX13"},
-
-	{"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
-	{"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
-	{"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
-	{"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
-	{"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
-
-	{"DMIC MUX0", "DMIC0", "DMIC0"},
-	{"DMIC MUX0", "DMIC1", "DMIC1"},
-	{"DMIC MUX0", "DMIC2", "DMIC2"},
-	{"DMIC MUX0", "DMIC3", "DMIC3"},
-	{"DMIC MUX0", "DMIC4", "DMIC4"},
-	{"DMIC MUX0", "DMIC5", "DMIC5"},
-	{"AMIC MUX0", "ADC1", "ADC1"},
-	{"AMIC MUX0", "ADC2", "ADC2"},
-	{"AMIC MUX0", "ADC3", "ADC3"},
-	{"AMIC MUX0", "ADC4", "ADC4"},
-
-	{"DMIC MUX1", "DMIC0", "DMIC0"},
-	{"DMIC MUX1", "DMIC1", "DMIC1"},
-	{"DMIC MUX1", "DMIC2", "DMIC2"},
-	{"DMIC MUX1", "DMIC3", "DMIC3"},
-	{"DMIC MUX1", "DMIC4", "DMIC4"},
-	{"DMIC MUX1", "DMIC5", "DMIC5"},
-	{"AMIC MUX1", "ADC1", "ADC1"},
-	{"AMIC MUX1", "ADC2", "ADC2"},
-	{"AMIC MUX1", "ADC3", "ADC3"},
-	{"AMIC MUX1", "ADC4", "ADC4"},
-
-	{"DMIC MUX2", "DMIC0", "DMIC0"},
-	{"DMIC MUX2", "DMIC1", "DMIC1"},
-	{"DMIC MUX2", "DMIC2", "DMIC2"},
-	{"DMIC MUX2", "DMIC3", "DMIC3"},
-	{"DMIC MUX2", "DMIC4", "DMIC4"},
-	{"DMIC MUX2", "DMIC5", "DMIC5"},
-	{"AMIC MUX2", "ADC1", "ADC1"},
-	{"AMIC MUX2", "ADC2", "ADC2"},
-	{"AMIC MUX2", "ADC3", "ADC3"},
-	{"AMIC MUX2", "ADC4", "ADC4"},
-
-	{"DMIC MUX3", "DMIC0", "DMIC0"},
-	{"DMIC MUX3", "DMIC1", "DMIC1"},
-	{"DMIC MUX3", "DMIC2", "DMIC2"},
-	{"DMIC MUX3", "DMIC3", "DMIC3"},
-	{"DMIC MUX3", "DMIC4", "DMIC4"},
-	{"DMIC MUX3", "DMIC5", "DMIC5"},
-	{"AMIC MUX3", "ADC1", "ADC1"},
-	{"AMIC MUX3", "ADC2", "ADC2"},
-	{"AMIC MUX3", "ADC3", "ADC3"},
-	{"AMIC MUX3", "ADC4", "ADC4"},
-
-	{"DMIC MUX4", "DMIC0", "DMIC0"},
-	{"DMIC MUX4", "DMIC1", "DMIC1"},
-	{"DMIC MUX4", "DMIC2", "DMIC2"},
-	{"DMIC MUX4", "DMIC3", "DMIC3"},
-	{"DMIC MUX4", "DMIC4", "DMIC4"},
-	{"DMIC MUX4", "DMIC5", "DMIC5"},
-	{"AMIC MUX4", "ADC1", "ADC1"},
-	{"AMIC MUX4", "ADC2", "ADC2"},
-	{"AMIC MUX4", "ADC3", "ADC3"},
-	{"AMIC MUX4", "ADC4", "ADC4"},
-
-	{"DMIC MUX5", "DMIC0", "DMIC0"},
-	{"DMIC MUX5", "DMIC1", "DMIC1"},
-	{"DMIC MUX5", "DMIC2", "DMIC2"},
-	{"DMIC MUX5", "DMIC3", "DMIC3"},
-	{"DMIC MUX5", "DMIC4", "DMIC4"},
-	{"DMIC MUX5", "DMIC5", "DMIC5"},
-	{"AMIC MUX5", "ADC1", "ADC1"},
-	{"AMIC MUX5", "ADC2", "ADC2"},
-	{"AMIC MUX5", "ADC3", "ADC3"},
-	{"AMIC MUX5", "ADC4", "ADC4"},
-
-	{"DMIC MUX6", "DMIC0", "DMIC0"},
-	{"DMIC MUX6", "DMIC1", "DMIC1"},
-	{"DMIC MUX6", "DMIC2", "DMIC2"},
-	{"DMIC MUX6", "DMIC3", "DMIC3"},
-	{"DMIC MUX6", "DMIC4", "DMIC4"},
-	{"DMIC MUX6", "DMIC5", "DMIC5"},
-	{"AMIC MUX6", "ADC1", "ADC1"},
-	{"AMIC MUX6", "ADC2", "ADC2"},
-	{"AMIC MUX6", "ADC3", "ADC3"},
-	{"AMIC MUX6", "ADC4", "ADC4"},
-
-	{"DMIC MUX7", "DMIC0", "DMIC0"},
-	{"DMIC MUX7", "DMIC1", "DMIC1"},
-	{"DMIC MUX7", "DMIC2", "DMIC2"},
-	{"DMIC MUX7", "DMIC3", "DMIC3"},
-	{"DMIC MUX7", "DMIC4", "DMIC4"},
-	{"DMIC MUX7", "DMIC5", "DMIC5"},
-	{"AMIC MUX7", "ADC1", "ADC1"},
-	{"AMIC MUX7", "ADC2", "ADC2"},
-	{"AMIC MUX7", "ADC3", "ADC3"},
-	{"AMIC MUX7", "ADC4", "ADC4"},
-
-	{"DMIC MUX8", "DMIC0", "DMIC0"},
-	{"DMIC MUX8", "DMIC1", "DMIC1"},
-	{"DMIC MUX8", "DMIC2", "DMIC2"},
-	{"DMIC MUX8", "DMIC3", "DMIC3"},
-	{"DMIC MUX8", "DMIC4", "DMIC4"},
-	{"DMIC MUX8", "DMIC5", "DMIC5"},
-	{"AMIC MUX8", "ADC1", "ADC1"},
-	{"AMIC MUX8", "ADC2", "ADC2"},
-	{"AMIC MUX8", "ADC3", "ADC3"},
-	{"AMIC MUX8", "ADC4", "ADC4"},
-
-	{"DMIC MUX10", "DMIC0", "DMIC0"},
-	{"DMIC MUX10", "DMIC1", "DMIC1"},
-	{"DMIC MUX10", "DMIC2", "DMIC2"},
-	{"DMIC MUX10", "DMIC3", "DMIC3"},
-	{"DMIC MUX10", "DMIC4", "DMIC4"},
-	{"DMIC MUX10", "DMIC5", "DMIC5"},
-	{"AMIC MUX10", "ADC1", "ADC1"},
-	{"AMIC MUX10", "ADC2", "ADC2"},
-	{"AMIC MUX10", "ADC3", "ADC3"},
-	{"AMIC MUX10", "ADC4", "ADC4"},
-
-	{"DMIC MUX11", "DMIC0", "DMIC0"},
-	{"DMIC MUX11", "DMIC1", "DMIC1"},
-	{"DMIC MUX11", "DMIC2", "DMIC2"},
-	{"DMIC MUX11", "DMIC3", "DMIC3"},
-	{"DMIC MUX11", "DMIC4", "DMIC4"},
-	{"DMIC MUX11", "DMIC5", "DMIC5"},
-	{"AMIC MUX11", "ADC1", "ADC1"},
-	{"AMIC MUX11", "ADC2", "ADC2"},
-	{"AMIC MUX11", "ADC3", "ADC3"},
-	{"AMIC MUX11", "ADC4", "ADC4"},
-
-	{"DMIC MUX12", "DMIC0", "DMIC0"},
-	{"DMIC MUX12", "DMIC1", "DMIC1"},
-	{"DMIC MUX12", "DMIC2", "DMIC2"},
-	{"DMIC MUX12", "DMIC3", "DMIC3"},
-	{"DMIC MUX12", "DMIC4", "DMIC4"},
-	{"DMIC MUX12", "DMIC5", "DMIC5"},
-	{"AMIC MUX12", "ADC1", "ADC1"},
-	{"AMIC MUX12", "ADC2", "ADC2"},
-	{"AMIC MUX12", "ADC3", "ADC3"},
-	{"AMIC MUX12", "ADC4", "ADC4"},
-
-	{"DMIC MUX13", "DMIC0", "DMIC0"},
-	{"DMIC MUX13", "DMIC1", "DMIC1"},
-	{"DMIC MUX13", "DMIC2", "DMIC2"},
-	{"DMIC MUX13", "DMIC3", "DMIC3"},
-	{"DMIC MUX13", "DMIC4", "DMIC4"},
-	{"DMIC MUX13", "DMIC5", "DMIC5"},
-	{"AMIC MUX13", "ADC1", "ADC1"},
-	{"AMIC MUX13", "ADC2", "ADC2"},
-	{"AMIC MUX13", "ADC3", "ADC3"},
-	{"AMIC MUX13", "ADC4", "ADC4"},
-
-	{"AMIC4_5 SEL", "AMIC4", "AMIC4"},
-	{"AMIC4_5 SEL", "AMIC5", "AMIC5"},
-
-	{"ADC1", NULL, "AMIC1"},
-	{"ADC2", NULL, "AMIC2"},
-	{"ADC3", NULL, "AMIC3"},
-	{"ADC4", NULL, "AMIC4_5 SEL"},
-
-	/* CDC Rx interface with SLIMBUS */
-	{"CDC_IF RX0 MUX", "SLIM RX0", "SLIM RX0"},
-	{"CDC_IF RX1 MUX", "SLIM RX1", "SLIM RX1"},
-	{"CDC_IF RX2 MUX", "SLIM RX2", "SLIM RX2"},
-	{"CDC_IF RX3 MUX", "SLIM RX3", "SLIM RX3"},
-	{"CDC_IF RX4 MUX", "SLIM RX4", "SLIM RX4"},
-	{"CDC_IF RX5 MUX", "SLIM RX5", "SLIM RX5"},
-	{"CDC_IF RX6 MUX", "SLIM RX6", "SLIM RX6"},
-	{"CDC_IF RX7 MUX", "SLIM RX7", "SLIM RX7"},
-
-	{"RX INT0_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT0_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT0_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT0_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT0_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT0_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT1_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT1_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT1_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT1_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT1_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT1_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT2_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT2_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT2_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT2_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT3_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT3_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT3_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT3_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT3_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT3_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT4_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT4_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT4_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT4_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT4_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT4_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT7_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT7_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT7_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT7_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT7_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT7_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT8_1 MIX1 INP0", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT8_1 MIX1 INP0", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
-	{"RX INT8_1 MIX1 INP1", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT8_1 MIX1 INP1", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
-	{"RX INT8_1 MIX1 INP2", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT8_1 MIX1 INP2", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
-	{"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
-
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
-	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
-	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
-	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
-	{"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
-	{"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
-	{"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
-	{"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
-
-	/* Mixing path INT0 */
-	{"RX INT0_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT0_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT0_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT0_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT0_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT0_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT0_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT0_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT0_2 INTERP", NULL, "RX INT0_2 MUX"},
-	{"RX INT0 SEC MIX", NULL, "RX INT0_2 INTERP"},
-
-	/* Mixing path INT1 */
-	{"RX INT1_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT1_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT1_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT1_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT1_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT1_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT1_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT1_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT1_2 INTERP", NULL, "RX INT1_2 MUX"},
-	{"RX INT1 SEC MIX", NULL, "RX INT1_2 INTERP"},
-
-	/* Mixing path INT2 */
-	{"RX INT2_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT2_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT2_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT2_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT2_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT2_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT2_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT2_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT2_2 INTERP", NULL, "RX INT2_2 MUX"},
-	{"RX INT2 SEC MIX", NULL, "RX INT2_2 INTERP"},
-
-	/* Mixing path INT3 */
-	{"RX INT3_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT3_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT3_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT3_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT3_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT3_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT3_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT3_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT3_2 INTERP", NULL, "RX INT3_2 MUX"},
-	{"RX INT3 SEC MIX", NULL, "RX INT3_2 INTERP"},
-
-	/* Mixing path INT4 */
-	{"RX INT4_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT4_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT4_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT4_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT4_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT4_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT4_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT4_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT4_2 INTERP", NULL, "RX INT4_2 MUX"},
-	{"RX INT4 SEC MIX", NULL, "RX INT4_2 INTERP"},
-
-	/* Mixing path INT7 */
-	{"RX INT7_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT7_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT7_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT7_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT7_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT7_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT7_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT7_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT7_2 INTERP", NULL, "RX INT7_2 MUX"},
-	{"RX INT7 SEC MIX", NULL, "RX INT7_2 INTERP"},
-
-	/* Mixing path INT8 */
-	{"RX INT8_2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"RX INT8_2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"RX INT8_2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"RX INT8_2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"RX INT8_2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"RX INT8_2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"RX INT8_2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"RX INT8_2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"RX INT8_2 INTERP", NULL, "RX INT8_2 MUX"},
-	{"RX INT8 SEC MIX", NULL, "RX INT8_2 INTERP"},
-
-	{"RX INT0_1 INTERP", NULL, "RX INT0_1 MIX1"},
-	{"RX INT0 SEC MIX", NULL, "RX INT0_1 INTERP"},
-	{"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
-	{"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
-	{"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"},
-	{"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
-	{"RX INT0 DAC", NULL, "RX_BIAS"},
-	{"EAR PA", NULL, "RX INT0 DAC"},
-	{"EAR", NULL, "EAR PA"},
-
-	{"RX INT1_1 INTERP", NULL, "RX INT1_1 MIX1"},
-	{"RX INT1 SEC MIX", NULL, "RX INT1_1 INTERP"},
-	{"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
-	{"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
-	{"RX INT1 MIX3", NULL, "RX INT1 MIX2"},
-	{"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX3"},
-	{"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
-	{"RX INT1 DAC", NULL, "RX_BIAS"},
-	{"HPHL PA", NULL, "RX INT1 DAC"},
-	{"HPHL", NULL, "HPHL PA"},
-
-	{"RX INT2_1 INTERP", NULL, "RX INT2_1 MIX1"},
-	{"RX INT2 SEC MIX", NULL, "RX INT2_1 INTERP"},
-	{"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
-	{"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
-	{"RX INT2 MIX3", NULL, "RX INT2 MIX2"},
-	{"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 MIX3"},
-	{"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
-	{"RX INT2 DAC", NULL, "RX_BIAS"},
-	{"HPHR PA", NULL, "RX INT2 DAC"},
-	{"HPHR", NULL, "HPHR PA"},
-
-	{"RX INT3_1 INTERP", NULL, "RX INT3_1 MIX1"},
-	{"RX INT3 SEC MIX", NULL, "RX INT3_1 INTERP"},
-	{"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
-	{"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
-	{"RX INT3 MIX3", NULL, "RX INT3 MIX2"},
-	{"RX INT3 DAC", NULL, "RX INT3 MIX3"},
-	{"RX INT3 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT1 PA", NULL, "RX INT3 DAC"},
-	{"LINEOUT1", NULL, "LINEOUT1 PA"},
-
-	{"RX INT4_1 INTERP", NULL, "RX INT4_1 MIX1"},
-	{"RX INT4 SEC MIX", NULL, "RX INT4_1 INTERP"},
-	{"RX INT4 SEC MIX", NULL, "RX INT4_1 MIX1"},
-	{"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
-	{"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
-	{"RX INT4 MIX3", NULL, "RX INT4 MIX2"},
-	{"RX INT4 DAC", NULL, "RX INT4 MIX3"},
-	{"RX INT4 DAC", NULL, "RX_BIAS"},
-	{"LINEOUT2 PA", NULL, "RX INT4 DAC"},
-	{"LINEOUT2", NULL, "LINEOUT2 PA"},
-
-	{"RX INT7_1 INTERP", NULL, "RX INT7_1 MIX1"},
-	{"RX INT7 SEC MIX", NULL, "RX INT7_1 INTERP"},
-	{"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
-	{"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
-	{"RX INT7 CHAIN", NULL, "RX INT7 MIX2"},
-	{"RX INT7 CHAIN", NULL, "RX_BIAS"},
-	{"SPK1 OUT", NULL, "RX INT7 CHAIN"},
-
-	{"RX INT8_1 INTERP", NULL, "RX INT8_1 MIX1"},
-	{"RX INT8 SEC MIX", NULL, "RX INT8_1 INTERP"},
-	{"RX INT8 SEC MIX", NULL, "RX INT8_1 MIX1"},
-	{"RX INT8 CHAIN", NULL, "RX INT8 SEC MIX"},
-	{"RX INT8 CHAIN", NULL, "RX_BIAS"},
-	{"SPK2 OUT", NULL, "RX INT8 CHAIN"},
-
-	/* ANC Routing */
-	{"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
-	{"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
-	{"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
-	{"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
-
-	{"ANC OUT EAR Enable", "Switch", "ADC MUX10"},
-	{"ANC OUT EAR Enable", "Switch", "ADC MUX11"},
-	{"RX INT0 MIX2", NULL, "ANC OUT EAR Enable"},
-
-	{"ANC OUT HPHL Enable", "Switch", "ADC MUX10"},
-	{"ANC OUT HPHL Enable", "Switch", "ADC MUX11"},
-	{"RX INT1 MIX2", NULL, "ANC OUT HPHL Enable"},
-
-	{"ANC OUT HPHR Enable", "Switch", "ADC MUX12"},
-	{"ANC OUT HPHR Enable", "Switch", "ADC MUX13"},
-	{"RX INT2 MIX2", NULL, "ANC OUT HPHR Enable"},
-
-	{"ANC EAR PA", NULL, "RX INT0 DAC"},
-	{"ANC EAR", NULL, "ANC EAR PA"},
-
-	{"ANC HPHL PA", NULL, "RX INT1 DAC"},
-	{"ANC HPHL", NULL, "ANC HPHL PA"},
-
-	{"ANC HPHR PA", NULL, "RX INT2 DAC"},
-	{"ANC HPHR", NULL, "ANC HPHR PA"},
-
-	{"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
-	{"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
-	{"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
-
-	{"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
-	{"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
-	{"SPK1 OUT", NULL, "ANC SPK1 PA"},
-
-	/*
-	 * SRC0, SRC1 inputs to Sidetone RX Mixer
-	 * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
-	 */
-	{"IIR0", NULL, "IIR0 INP0 MUX"},
-	{"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP0 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR0 INP0 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR0 INP0 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR0 INP0 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR0 INP0 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR0 INP0 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR0 INP0 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR0 INP0 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR0", NULL, "IIR0 INP1 MUX"},
-	{"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP1 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR0 INP1 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR0 INP1 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR0 INP1 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR0 INP1 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR0 INP1 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR0 INP1 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR0 INP1 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR0", NULL, "IIR0 INP2 MUX"},
-	{"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR0 INP2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR0 INP2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR0 INP2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR0 INP2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR0 INP2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR0 INP2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR0 INP2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR0", NULL, "IIR0 INP3 MUX"},
-	{"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
-	{"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
-	{"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
-	{"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
-	{"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
-	{"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
-	{"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
-	{"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
-	{"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
-	{"IIR0 INP3 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR0 INP3 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR0 INP3 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR0 INP3 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR0 INP3 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR0 INP3 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR0 INP3 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR0 INP3 MUX", "RX7", "CDC_IF RX7 MUX"},
-
-	{"IIR1", NULL, "IIR1 INP0 MUX"},
-	{"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP0 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR1 INP0 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR1 INP0 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR1 INP0 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR1 INP0 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR1 INP0 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR1 INP0 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR1 INP0 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR1", NULL, "IIR1 INP1 MUX"},
-	{"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP1 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR1 INP1 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR1 INP1 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR1 INP1 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR1 INP1 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR1 INP1 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR1 INP1 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR1 INP1 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR1", NULL, "IIR1 INP2 MUX"},
-	{"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP2 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR1 INP2 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR1 INP2 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR1 INP2 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR1 INP2 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR1 INP2 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR1 INP2 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR1 INP2 MUX", "RX7", "CDC_IF RX7 MUX"},
-	{"IIR1", NULL, "IIR1 INP3 MUX"},
-	{"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
-	{"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
-	{"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
-	{"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
-	{"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
-	{"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
-	{"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
-	{"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
-	{"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
-	{"IIR1 INP3 MUX", "RX0", "CDC_IF RX0 MUX"},
-	{"IIR1 INP3 MUX", "RX1", "CDC_IF RX1 MUX"},
-	{"IIR1 INP3 MUX", "RX2", "CDC_IF RX2 MUX"},
-	{"IIR1 INP3 MUX", "RX3", "CDC_IF RX3 MUX"},
-	{"IIR1 INP3 MUX", "RX4", "CDC_IF RX4 MUX"},
-	{"IIR1 INP3 MUX", "RX5", "CDC_IF RX5 MUX"},
-	{"IIR1 INP3 MUX", "RX6", "CDC_IF RX6 MUX"},
-	{"IIR1 INP3 MUX", "RX7", "CDC_IF RX7 MUX"},
-
-	{"SRC0", NULL, "IIR0"},
-	{"SRC1", NULL, "IIR1"},
-	{"RX INT0 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT0 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT1 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT1 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT2 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT2 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT3 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT3 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT4 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT4 MIX2 INP", "SRC1", "SRC1"},
-	{"RX INT7 MIX2 INP", "SRC0", "SRC0"},
-	{"RX INT7 MIX2 INP", "SRC1", "SRC1"},
-
-	/* Native clk main path routing */
-	{"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
-	{"RX INT1_1 INTERP", NULL, "RX INT1_1 NATIVE MUX"},
-	{"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
-
-	{"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
-	{"RX INT2_1 INTERP", NULL, "RX INT2_1 NATIVE MUX"},
-	{"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
-
-	{"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
-	{"RX INT3_1 INTERP", NULL, "RX INT3_1 NATIVE MUX"},
-	{"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
-
-	{"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
-	{"RX INT4_1 INTERP", NULL, "RX INT4_1 NATIVE MUX"},
-	{"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
-
-	/* Native clk mix path routing */
-	{"RX INT1_2 NATIVE MUX", "ON", "RX INT1_2 MUX"},
-	{"RX INT1_2 INTERP", NULL, "RX INT1_2 NATIVE MUX"},
-	{"RX INT1_2 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
-
-	{"RX INT2_2 NATIVE MUX", "ON", "RX INT2_2 MUX"},
-	{"RX INT2_2 INTERP", NULL, "RX INT2_2 NATIVE MUX"},
-	{"RX INT2_2 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
-
-	{"RX INT3_2 NATIVE MUX", "ON", "RX INT3_2 MUX"},
-	{"RX INT3_2 INTERP", NULL, "RX INT3_2 NATIVE MUX"},
-	{"RX INT3_2 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
-
-	{"RX INT4_2 NATIVE MUX", "ON", "RX INT4_2 MUX"},
-	{"RX INT4_2 INTERP", NULL, "RX INT4_2 NATIVE MUX"},
-	{"RX INT4_2 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
-
-	{"RX INT7_2 NATIVE MUX", "ON", "RX INT7_2 MUX"},
-	{"RX INT7_2 INTERP", NULL, "RX INT7_2 NATIVE MUX"},
-	{"RX INT7_2 NATIVE MUX", NULL, "RX INT7 NATIVE SUPPLY"},
-
-	{"RX INT8_2 NATIVE MUX", "ON", "RX INT8_2 MUX"},
-	{"RX INT8_2 INTERP", NULL, "RX INT8_2 NATIVE MUX"},
-	{"RX INT8_2 NATIVE MUX", NULL, "RX INT8 NATIVE SUPPLY"},
-
-	/* ASRC Routing */
-	{"ASRC0 MUX", "ASRC_IN_HPHL", "RX INT1_2 INTERP"},
-	{"RX INT1 SEC MIX", "HPHL Switch", "ASRC0 MUX"},
-
-	{"ASRC1 MUX", "ASRC_IN_HPHR", "RX INT2_2 INTERP"},
-	{"RX INT2 SEC MIX", "HPHR Switch", "ASRC1 MUX"},
-
-	{"ASRC0 MUX", "ASRC_IN_LO1", "RX INT3_2 INTERP"},
-	{"RX INT3 SEC MIX", "LO1 Switch", "ASRC0 MUX"},
-
-	{"ASRC1 MUX", "ASRC_IN_LO2", "RX INT4_2 INTERP"},
-	{"RX INT4 SEC MIX", "LO2 Switch", "ASRC1 MUX"},
-
-	{"ASRC2 MUX", "ASRC_IN_SPKR1", "RX INT7_2 INTERP"},
-	{"RX INT7 SEC MIX", NULL, "ASRC2 MUX"},
-
-	{"ASRC3 MUX", "ASRC_IN_SPKR2", "RX INT8_2 INTERP"},
-	{"RX INT8 SEC MIX", NULL, "ASRC3 MUX"},
-};
-
-#endif
diff --git a/sound/soc/codecs/wcd934x/wcd934x.c b/sound/soc/codecs/wcd934x/wcd934x.c
deleted file mode 100644
index 2fc26dc..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x.c
+++ /dev/null
@@ -1,10149 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/firmware.h>
-#include <linux/slab.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/ratelimit.h>
-#include <linux/debugfs.h>
-#include <linux/wait.h>
-#include <linux/bitops.h>
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/regmap.h>
-#include <linux/spi/spi.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <linux/mfd/wcd934x/irq.h>
-#include <linux/mfd/wcd9xxx/pdata.h>
-#include <linux/regulator/consumer.h>
-#include <linux/soundwire/swr-wcd.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include <sound/info.h>
-#include "wcd934x.h"
-#include "wcd934x-mbhc.h"
-#include "wcd934x-routing.h"
-#include "wcd934x-dsp-cntl.h"
-#include "../wcd9xxx-common-v2.h"
-#include "../wcd9xxx-resmgr-v2.h"
-#include "../wcdcal-hwdep.h"
-#include "wcd934x-dsd.h"
-
-#define WCD934X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
-			    SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
-			    SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
-			    SNDRV_PCM_RATE_384000)
-/* Fractional Rates */
-#define WCD934X_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
-				 SNDRV_PCM_RATE_176400)
-
-#define WCD934X_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
-				    SNDRV_PCM_FMTBIT_S24_LE)
-
-#define WCD934X_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
-					SNDRV_PCM_FMTBIT_S24_LE | \
-					SNDRV_PCM_FMTBIT_S32_LE)
-
-#define WCD934X_FORMATS_S16_LE (SNDRV_PCM_FMTBIT_S16_LE)
-
-/* Macros for packing register writes into a U32 */
-#define WCD934X_PACKED_REG_SIZE sizeof(u32)
-#define WCD934X_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
-	do { \
-		((reg) = ((packed >> 16) & (0xffff))); \
-		((mask) = ((packed >> 8) & (0xff))); \
-		((val) = ((packed) & (0xff))); \
-	} while (0)
-
-#define STRING(name) #name
-#define WCD_DAPM_ENUM(name, reg, offset, text) \
-static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
-static const struct snd_kcontrol_new name##_mux = \
-		SOC_DAPM_ENUM(STRING(name), name##_enum)
-
-#define WCD_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
-static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
-static const struct snd_kcontrol_new name##_mux = \
-		SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
-
-#define WCD_DAPM_MUX(name, shift, kctl) \
-		SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
-
-/*
- * Timeout in milli seconds and it is the wait time for
- * slim channel removal interrupt to receive.
- */
-#define WCD934X_SLIM_CLOSE_TIMEOUT 1000
-#define WCD934X_SLIM_IRQ_OVERFLOW (1 << 0)
-#define WCD934X_SLIM_IRQ_UNDERFLOW (1 << 1)
-#define WCD934X_SLIM_IRQ_PORT_CLOSED (1 << 2)
-#define WCD934X_MCLK_CLK_12P288MHZ 12288000
-#define WCD934X_MCLK_CLK_9P6MHZ 9600000
-
-#define WCD934X_INTERP_MUX_NUM_INPUTS 3
-#define WCD934X_NUM_INTERPOLATORS 9
-#define WCD934X_NUM_DECIMATORS 9
-#define WCD934X_RX_PATH_CTL_OFFSET 20
-
-#define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
-
-#define WCD934X_REG_BITS 8
-#define WCD934X_MAX_VALID_ADC_MUX  13
-#define WCD934X_INVALID_ADC_MUX 9
-
-#define WCD934X_AMIC_PWR_LEVEL_LP 0
-#define WCD934X_AMIC_PWR_LEVEL_DEFAULT 1
-#define WCD934X_AMIC_PWR_LEVEL_HP 2
-#define WCD934X_AMIC_PWR_LVL_MASK 0x60
-#define WCD934X_AMIC_PWR_LVL_SHIFT 0x5
-
-#define WCD934X_DEC_PWR_LVL_MASK 0x06
-#define WCD934X_DEC_PWR_LVL_LP 0x02
-#define WCD934X_DEC_PWR_LVL_HP 0x04
-#define WCD934X_DEC_PWR_LVL_DF 0x00
-#define WCD934X_STRING_LEN 100
-
-#define WCD934X_CDC_SIDETONE_IIR_COEFF_MAX 5
-#define WCD934X_DIG_CORE_REG_MIN  WCD934X_CDC_ANC0_CLK_RESET_CTL
-#define WCD934X_DIG_CORE_REG_MAX  0xFFF
-
-#define WCD934X_CHILD_DEVICES_MAX	6
-
-#define WCD934X_MAX_MICBIAS 4
-#define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
-#define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
-#define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
-#define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
-
-#define  TX_HPF_CUT_OFF_FREQ_MASK	0x60
-#define  CF_MIN_3DB_4HZ			0x0
-#define  CF_MIN_3DB_75HZ		0x1
-#define  CF_MIN_3DB_150HZ		0x2
-
-#define CPE_ERR_WDOG_BITE BIT(0)
-#define CPE_FATAL_IRQS CPE_ERR_WDOG_BITE
-
-#define WCD934X_MAD_AUDIO_FIRMWARE_PATH "wcd934x/wcd934x_mad_audio.bin"
-
-#define TAVIL_VERSION_ENTRY_SIZE 17
-
-#define WCD934X_DIG_CORE_COLLAPSE_TIMER_MS  (5 * 1000)
-
-enum {
-	POWER_COLLAPSE,
-	POWER_RESUME,
-};
-
-static int dig_core_collapse_enable = 1;
-module_param(dig_core_collapse_enable, int, 0664);
-MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
-
-/* dig_core_collapse timer in seconds */
-static int dig_core_collapse_timer = (WCD934X_DIG_CORE_COLLAPSE_TIMER_MS/1000);
-module_param(dig_core_collapse_timer, int, 0664);
-MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
-
-#define TAVIL_HPH_REG_RANGE_1  (WCD934X_HPH_R_DAC_CTL - WCD934X_HPH_CNP_EN + 1)
-#define TAVIL_HPH_REG_RANGE_2  (WCD934X_HPH_NEW_ANA_HPH3 -\
-				WCD934X_HPH_NEW_ANA_HPH2 + 1)
-#define TAVIL_HPH_REG_RANGE_3  (WCD934X_HPH_NEW_INT_PA_RDAC_MISC3 -\
-				WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL + 1)
-#define TAVIL_HPH_TOTAL_REG    (TAVIL_HPH_REG_RANGE_1 + TAVIL_HPH_REG_RANGE_2 +\
-				TAVIL_HPH_REG_RANGE_3)
-
-enum {
-	VI_SENSE_1,
-	VI_SENSE_2,
-	AUDIO_NOMINAL,
-	HPH_PA_DELAY,
-	CLSH_Z_CONFIG,
-	ANC_MIC_AMIC1,
-	ANC_MIC_AMIC2,
-	ANC_MIC_AMIC3,
-	ANC_MIC_AMIC4,
-	CLK_INTERNAL,
-	CLK_MODE,
-};
-
-enum {
-	AIF1_PB = 0,
-	AIF1_CAP,
-	AIF2_PB,
-	AIF2_CAP,
-	AIF3_PB,
-	AIF3_CAP,
-	AIF4_PB,
-	AIF4_VIFEED,
-	AIF4_MAD_TX,
-	NUM_CODEC_DAIS,
-};
-
-enum {
-	INTn_1_INP_SEL_ZERO = 0,
-	INTn_1_INP_SEL_DEC0,
-	INTn_1_INP_SEL_DEC1,
-	INTn_1_INP_SEL_IIR0,
-	INTn_1_INP_SEL_IIR1,
-	INTn_1_INP_SEL_RX0,
-	INTn_1_INP_SEL_RX1,
-	INTn_1_INP_SEL_RX2,
-	INTn_1_INP_SEL_RX3,
-	INTn_1_INP_SEL_RX4,
-	INTn_1_INP_SEL_RX5,
-	INTn_1_INP_SEL_RX6,
-	INTn_1_INP_SEL_RX7,
-};
-
-enum {
-	INTn_2_INP_SEL_ZERO = 0,
-	INTn_2_INP_SEL_RX0,
-	INTn_2_INP_SEL_RX1,
-	INTn_2_INP_SEL_RX2,
-	INTn_2_INP_SEL_RX3,
-	INTn_2_INP_SEL_RX4,
-	INTn_2_INP_SEL_RX5,
-	INTn_2_INP_SEL_RX6,
-	INTn_2_INP_SEL_RX7,
-	INTn_2_INP_SEL_PROXIMITY,
-};
-
-enum {
-	INTERP_MAIN_PATH,
-	INTERP_MIX_PATH,
-};
-
-struct tavil_idle_detect_config {
-	u8 hph_idle_thr;
-	u8 hph_idle_detect_en;
-};
-
-struct tavil_cpr_reg_defaults {
-	int wr_data;
-	int wr_addr;
-};
-
-struct interp_sample_rate {
-	int sample_rate;
-	int rate_val;
-};
-
-static struct interp_sample_rate sr_val_tbl[] = {
-	{8000, 0x0}, {16000, 0x1}, {32000, 0x3}, {48000, 0x4}, {96000, 0x5},
-	{192000, 0x6}, {384000, 0x7}, {44100, 0x9}, {88200, 0xA},
-	{176400, 0xB}, {352800, 0xC},
-};
-
-static const struct wcd9xxx_ch tavil_rx_chs[WCD934X_RX_MAX] = {
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER, 0),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 1, 1),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 2, 2),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 3, 3),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 4, 4),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 5, 5),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 6, 6),
-	WCD9XXX_CH(WCD934X_RX_PORT_START_NUMBER + 7, 7),
-};
-
-static const struct wcd9xxx_ch tavil_tx_chs[WCD934X_TX_MAX] = {
-	WCD9XXX_CH(0, 0),
-	WCD9XXX_CH(1, 1),
-	WCD9XXX_CH(2, 2),
-	WCD9XXX_CH(3, 3),
-	WCD9XXX_CH(4, 4),
-	WCD9XXX_CH(5, 5),
-	WCD9XXX_CH(6, 6),
-	WCD9XXX_CH(7, 7),
-	WCD9XXX_CH(8, 8),
-	WCD9XXX_CH(9, 9),
-	WCD9XXX_CH(10, 10),
-	WCD9XXX_CH(11, 11),
-	WCD9XXX_CH(12, 12),
-	WCD9XXX_CH(13, 13),
-	WCD9XXX_CH(14, 14),
-	WCD9XXX_CH(15, 15),
-};
-
-static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
-	0,							/* AIF1_PB */
-	BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),	/* AIF1_CAP */
-	0,							/* AIF2_PB */
-	BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),	/* AIF2_CAP */
-	0,							/* AIF3_PB */
-	BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX),	/* AIF3_CAP */
-	0,							/* AIF4_PB */
-};
-
-/* Codec supports 2 IIR filters */
-enum {
-	IIR0 = 0,
-	IIR1,
-	IIR_MAX,
-};
-
-/* Each IIR has 5 Filter Stages */
-enum {
-	BAND1 = 0,
-	BAND2,
-	BAND3,
-	BAND4,
-	BAND5,
-	BAND_MAX,
-};
-
-enum {
-	COMPANDER_1, /* HPH_L */
-	COMPANDER_2, /* HPH_R */
-	COMPANDER_3, /* LO1_DIFF */
-	COMPANDER_4, /* LO2_DIFF */
-	COMPANDER_5, /* LO3_SE - not used in Tavil */
-	COMPANDER_6, /* LO4_SE - not used in Tavil */
-	COMPANDER_7, /* SWR SPK CH1 */
-	COMPANDER_8, /* SWR SPK CH2 */
-	COMPANDER_MAX,
-};
-
-enum {
-	ASRC_IN_HPHL,
-	ASRC_IN_LO1,
-	ASRC_IN_HPHR,
-	ASRC_IN_LO2,
-	ASRC_IN_SPKR1,
-	ASRC_IN_SPKR2,
-	ASRC_INVALID,
-};
-
-enum {
-	ASRC0,
-	ASRC1,
-	ASRC2,
-	ASRC3,
-	ASRC_MAX,
-};
-
-enum {
-	CONV_88P2K_TO_384K,
-	CONV_96K_TO_352P8K,
-	CONV_352P8K_TO_384K,
-	CONV_384K_TO_352P8K,
-	CONV_384K_TO_384K,
-	CONV_96K_TO_384K,
-};
-
-static struct afe_param_slimbus_slave_port_cfg tavil_slimbus_slave_port_cfg = {
-	.minor_version = 1,
-	.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
-	.slave_dev_pgd_la = 0,
-	.slave_dev_intfdev_la = 0,
-	.bit_width = 16,
-	.data_format = 0,
-	.num_channels = 1
-};
-
-static struct afe_param_cdc_reg_page_cfg tavil_cdc_reg_page_cfg = {
-	.minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
-	.enable = 1,
-	.proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
-};
-
-static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SOC_MAD_MAIN_CTL_1),
-		HW_MAD_AUDIO_ENABLE, 0x1, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SOC_MAD_AUDIO_CTL_3),
-		HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SOC_MAD_AUDIO_CTL_4),
-		HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_INTR_CFG),
-		MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_INTR_PIN2_MASK3),
-		MAD_AUDIO_INT_MASK_REG, 0x1, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_INTR_PIN2_STATUS3),
-		MAD_AUDIO_INT_STATUS_REG, 0x1, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_INTR_PIN2_CLEAR3),
-		MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SB_PGD_PORT_TX_BASE),
-		SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD934X_REG_BITS, 0x1
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SB_PGD_PORT_TX_BASE),
-		SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD934X_REG_BITS, 0x1
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SB_PGD_PORT_RX_BASE),
-		SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD934X_REG_BITS, 0x1
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET + WCD934X_SB_PGD_PORT_RX_BASE),
-		SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD934X_REG_BITS, 0x1
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 WCD934X_CDC_ANC0_IIR_ADAPT_CTL),
-		AANC_FF_GAIN_ADAPTIVE, 0x4, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 WCD934X_CDC_ANC0_IIR_ADAPT_CTL),
-		AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 WCD934X_CDC_ANC0_FF_A_GAIN_CTL),
-		AANC_GAIN_CONTROL, 0xFF, WCD934X_REG_BITS, 0
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 SB_PGD_TX_PORT_MULTI_CHANNEL_0(0)),
-		SB_PGD_TX_PORTn_MULTI_CHNL_0, 0xFF, WCD934X_REG_BITS, 0x4
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 SB_PGD_TX_PORT_MULTI_CHANNEL_1(0)),
-		SB_PGD_TX_PORTn_MULTI_CHNL_1, 0xFF, WCD934X_REG_BITS, 0x4
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 SB_PGD_RX_PORT_MULTI_CHANNEL_0(0x180, 0)),
-		SB_PGD_RX_PORTn_MULTI_CHNL_0, 0xFF, WCD934X_REG_BITS, 0x4
-	},
-	{
-		1,
-		(WCD934X_REGISTER_START_OFFSET +
-		 SB_PGD_RX_PORT_MULTI_CHANNEL_0(0x181, 0)),
-		SB_PGD_RX_PORTn_MULTI_CHNL_1, 0xFF, WCD934X_REG_BITS, 0x4
-	},
-};
-
-static struct afe_param_cdc_reg_cfg_data tavil_audio_reg_cfg = {
-	.num_registers = ARRAY_SIZE(audio_reg_cfg),
-	.reg_data = audio_reg_cfg,
-};
-
-static struct afe_param_id_cdc_aanc_version tavil_cdc_aanc_version = {
-	.cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
-	.aanc_hw_version        = AANC_HW_BLOCK_VERSION_2,
-};
-
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
-static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
-static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
-
-#define WCD934X_TX_UNMUTE_DELAY_MS 40
-
-static int tx_unmute_delay = WCD934X_TX_UNMUTE_DELAY_MS;
-module_param(tx_unmute_delay, int, 0664);
-MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
-
-static void tavil_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
-
-/* Hold instance to soundwire platform device */
-struct tavil_swr_ctrl_data {
-	struct platform_device *swr_pdev;
-};
-
-struct wcd_swr_ctrl_platform_data {
-	void *handle; /* holds codec private data */
-	int (*read)(void *handle, int reg);
-	int (*write)(void *handle, int reg, int val);
-	int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
-	int (*clk)(void *handle, bool enable);
-	int (*handle_irq)(void *handle,
-			  irqreturn_t (*swrm_irq_handler)(int irq, void *data),
-			  void *swrm_handle, int action);
-};
-
-/* Holds all Soundwire and speaker related information */
-struct wcd934x_swr {
-	struct tavil_swr_ctrl_data *ctrl_data;
-	struct wcd_swr_ctrl_platform_data plat_data;
-	struct mutex read_mutex;
-	struct mutex write_mutex;
-	struct mutex clk_mutex;
-	int spkr_gain_offset;
-	int spkr_mode;
-	int clk_users;
-	int rx_7_count;
-	int rx_8_count;
-};
-
-struct tx_mute_work {
-	struct tavil_priv *tavil;
-	u8 decimator;
-	struct delayed_work dwork;
-};
-
-#define WCD934X_SPK_ANC_EN_DELAY_MS 350
-static int spk_anc_en_delay = WCD934X_SPK_ANC_EN_DELAY_MS;
-module_param(spk_anc_en_delay, int, 0664);
-MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
-
-struct spk_anc_work {
-	struct tavil_priv *tavil;
-	struct delayed_work dwork;
-};
-
-struct hpf_work {
-	struct tavil_priv *tavil;
-	u8 decimator;
-	u8 hpf_cut_off_freq;
-	struct delayed_work dwork;
-};
-
-struct tavil_priv {
-	struct device *dev;
-	struct wcd9xxx *wcd9xxx;
-	struct snd_soc_codec *codec;
-	u32 rx_bias_count;
-	s32 dmic_0_1_clk_cnt;
-	s32 dmic_2_3_clk_cnt;
-	s32 dmic_4_5_clk_cnt;
-	s32 micb_ref[TAVIL_MAX_MICBIAS];
-	s32 pullup_ref[TAVIL_MAX_MICBIAS];
-
-	/* ANC related */
-	u32 anc_slot;
-	bool anc_func;
-
-	/* compander */
-	int comp_enabled[COMPANDER_MAX];
-	int ear_spkr_gain;
-
-	/* class h specific data */
-	struct wcd_clsh_cdc_data clsh_d;
-	/* Tavil Interpolator Mode Select for EAR, HPH_L and HPH_R */
-	u32 hph_mode;
-
-	/* Mad switch reference count */
-	int mad_switch_cnt;
-
-	/* track tavil interface type */
-	u8 intf_type;
-
-	/* to track the status */
-	unsigned long status_mask;
-
-	struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
-
-	/* num of slim ports required */
-	struct wcd9xxx_codec_dai_data  dai[NUM_CODEC_DAIS];
-	/* Port values for Rx and Tx codec_dai */
-	unsigned int rx_port_value[WCD934X_RX_MAX];
-	unsigned int tx_port_value;
-
-	struct wcd9xxx_resmgr_v2 *resmgr;
-	struct wcd934x_swr swr;
-	struct mutex micb_lock;
-
-	struct delayed_work power_gate_work;
-	struct mutex power_lock;
-
-	struct clk *wcd_ext_clk;
-
-	/* mbhc module */
-	struct wcd934x_mbhc *mbhc;
-
-	struct mutex codec_mutex;
-	struct work_struct tavil_add_child_devices_work;
-	struct hpf_work tx_hpf_work[WCD934X_NUM_DECIMATORS];
-	struct tx_mute_work tx_mute_dwork[WCD934X_NUM_DECIMATORS];
-	struct spk_anc_work spk_anc_dwork;
-
-	unsigned int vi_feed_value;
-
-	/* DSP control */
-	struct wcd_dsp_cntl *wdsp_cntl;
-
-	/* cal info for codec */
-	struct fw_info *fw_data;
-
-	/* Entry for version info */
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-
-	/* SVS voting related */
-	struct mutex svs_mutex;
-	int svs_ref_cnt;
-
-	int native_clk_users;
-	/* ASRC users count */
-	int asrc_users[ASRC_MAX];
-	int asrc_output_mode[ASRC_MAX];
-	/* Main path clock users count */
-	int main_clk_users[WCD934X_NUM_INTERPOLATORS];
-	struct tavil_dsd_config *dsd_config;
-	struct tavil_idle_detect_config idle_det_cfg;
-
-	int power_active_ref;
-	int sidetone_coeff_array[IIR_MAX][BAND_MAX]
-		[WCD934X_CDC_SIDETONE_IIR_COEFF_MAX];
-
-	struct spi_device *spi;
-	struct platform_device *pdev_child_devices
-		[WCD934X_CHILD_DEVICES_MAX];
-	int child_count;
-};
-
-static const struct tavil_reg_mask_val tavil_spkr_default[] = {
-	{WCD934X_CDC_COMPANDER7_CTL3, 0x80, 0x80},
-	{WCD934X_CDC_COMPANDER8_CTL3, 0x80, 0x80},
-	{WCD934X_CDC_COMPANDER7_CTL7, 0x01, 0x01},
-	{WCD934X_CDC_COMPANDER8_CTL7, 0x01, 0x01},
-	{WCD934X_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
-	{WCD934X_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
-};
-
-static const struct tavil_reg_mask_val tavil_spkr_mode1[] = {
-	{WCD934X_CDC_COMPANDER7_CTL3, 0x80, 0x00},
-	{WCD934X_CDC_COMPANDER8_CTL3, 0x80, 0x00},
-	{WCD934X_CDC_COMPANDER7_CTL7, 0x01, 0x00},
-	{WCD934X_CDC_COMPANDER8_CTL7, 0x01, 0x00},
-	{WCD934X_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
-	{WCD934X_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
-};
-
-static int __tavil_enable_efuse_sensing(struct tavil_priv *tavil);
-
-/**
- * tavil_set_spkr_gain_offset - offset the speaker path
- * gain with the given offset value.
- *
- * @codec: codec instance
- * @offset: Indicates speaker path gain offset value.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
-{
-	struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	if (!priv)
-		return -EINVAL;
-
-	priv->swr.spkr_gain_offset = offset;
-	return 0;
-}
-EXPORT_SYMBOL(tavil_set_spkr_gain_offset);
-
-/**
- * tavil_set_spkr_mode - Configures speaker compander and smartboost
- * settings based on speaker mode.
- *
- * @codec: codec instance
- * @mode: Indicates speaker configuration mode.
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode)
-{
-	struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec);
-	int i;
-	const struct tavil_reg_mask_val *regs;
-	int size;
-
-	if (!priv)
-		return -EINVAL;
-
-	switch (mode) {
-	case WCD934X_SPKR_MODE_1:
-		regs = tavil_spkr_mode1;
-		size = ARRAY_SIZE(tavil_spkr_mode1);
-		break;
-	default:
-		regs = tavil_spkr_default;
-		size = ARRAY_SIZE(tavil_spkr_default);
-		break;
-	}
-
-	priv->swr.spkr_mode = mode;
-	for (i = 0; i < size; i++)
-		snd_soc_update_bits(codec, regs[i].reg,
-				    regs[i].mask, regs[i].val);
-	return 0;
-}
-EXPORT_SYMBOL(tavil_set_spkr_mode);
-
-/**
- * tavil_get_afe_config - returns specific codec configuration to afe to write
- *
- * @codec: codec instance
- * @config_type: Indicates type of configuration to write.
- */
-void *tavil_get_afe_config(struct snd_soc_codec *codec,
-			   enum afe_config_type config_type)
-{
-	struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	switch (config_type) {
-	case AFE_SLIMBUS_SLAVE_CONFIG:
-		return &priv->slimbus_slave_cfg;
-	case AFE_CDC_REGISTERS_CONFIG:
-		return &tavil_audio_reg_cfg;
-	case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
-		return &tavil_slimbus_slave_port_cfg;
-	case AFE_AANC_VERSION:
-		return &tavil_cdc_aanc_version;
-	case AFE_CDC_REGISTER_PAGE_CONFIG:
-		return &tavil_cdc_reg_page_cfg;
-	default:
-		dev_info(codec->dev, "%s: Unknown config_type 0x%x\n",
-			__func__, config_type);
-		return NULL;
-	}
-}
-EXPORT_SYMBOL(tavil_get_afe_config);
-
-static bool is_tavil_playback_dai(int dai_id)
-{
-	if ((dai_id == AIF1_PB) || (dai_id == AIF2_PB) ||
-	    (dai_id == AIF3_PB) || (dai_id == AIF4_PB))
-		return true;
-
-	return false;
-}
-
-static int tavil_find_playback_dai_id_for_port(int port_id,
-					       struct tavil_priv *tavil)
-{
-	struct wcd9xxx_codec_dai_data *dai;
-	struct wcd9xxx_ch *ch;
-	int i, slv_port_id;
-
-	for (i = AIF1_PB; i < NUM_CODEC_DAIS; i++) {
-		if (!is_tavil_playback_dai(i))
-			continue;
-
-		dai = &tavil->dai[i];
-		list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-			slv_port_id = wcd9xxx_get_slave_port(ch->ch_num);
-			if ((slv_port_id > 0) && (slv_port_id == port_id))
-				return i;
-		}
-	}
-
-	return -EINVAL;
-}
-
-static void tavil_vote_svs(struct tavil_priv *tavil, bool vote)
-{
-	struct wcd9xxx *wcd9xxx;
-
-	wcd9xxx = tavil->wcd9xxx;
-
-	mutex_lock(&tavil->svs_mutex);
-	if (vote) {
-		tavil->svs_ref_cnt++;
-		if (tavil->svs_ref_cnt == 1)
-			regmap_update_bits(wcd9xxx->regmap,
-					   WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0,
-					   0x01, 0x01);
-	} else {
-		/* Do not decrement ref count if it is already 0 */
-		if (tavil->svs_ref_cnt == 0)
-			goto done;
-
-		tavil->svs_ref_cnt--;
-		if (tavil->svs_ref_cnt == 0)
-			regmap_update_bits(wcd9xxx->regmap,
-					   WCD934X_CPE_SS_PWR_SYS_PSTATE_CTL_0,
-					   0x01, 0x00);
-	}
-done:
-	dev_dbg(tavil->dev, "%s: vote = %s, updated ref cnt = %u\n", __func__,
-		vote ? "vote" : "Unvote", tavil->svs_ref_cnt);
-	mutex_unlock(&tavil->svs_mutex);
-}
-
-static int tavil_get_anc_slot(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil->anc_slot;
-	return 0;
-}
-
-static int tavil_put_anc_slot(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	tavil->anc_slot = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static int tavil_get_anc_func(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = (tavil->anc_func == true ? 1 : 0);
-	return 0;
-}
-
-static int tavil_put_anc_func(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
-	mutex_lock(&tavil->codec_mutex);
-	tavil->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
-	dev_dbg(codec->dev, "%s: anc_func %x", __func__, tavil->anc_func);
-
-	if (tavil->anc_func == true) {
-		snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC EAR");
-		snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
-		snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
-		snd_soc_dapm_disable_pin(dapm, "EAR PA");
-		snd_soc_dapm_disable_pin(dapm, "EAR");
-		snd_soc_dapm_disable_pin(dapm, "HPHL PA");
-		snd_soc_dapm_disable_pin(dapm, "HPHR PA");
-		snd_soc_dapm_disable_pin(dapm, "HPHL");
-		snd_soc_dapm_disable_pin(dapm, "HPHR");
-	} else {
-		snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC EAR");
-		snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
-		snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
-		snd_soc_dapm_enable_pin(dapm, "EAR PA");
-		snd_soc_dapm_enable_pin(dapm, "EAR");
-		snd_soc_dapm_enable_pin(dapm, "HPHL");
-		snd_soc_dapm_enable_pin(dapm, "HPHR");
-		snd_soc_dapm_enable_pin(dapm, "HPHL PA");
-		snd_soc_dapm_enable_pin(dapm, "HPHR PA");
-	}
-	mutex_unlock(&tavil->codec_mutex);
-
-	snd_soc_dapm_sync(dapm);
-	return 0;
-}
-
-static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	const char *filename;
-	const struct firmware *fw;
-	int i;
-	int ret = 0;
-	int num_anc_slots;
-	struct wcd9xxx_anc_header *anc_head;
-	struct firmware_cal *hwdep_cal = NULL;
-	u32 anc_writes_size = 0;
-	u32 anc_cal_size = 0;
-	int anc_size_remaining;
-	u32 *anc_ptr;
-	u16 reg;
-	u8 mask, val;
-	size_t cal_size;
-	const void *data;
-
-	if (!tavil->anc_func)
-		return 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		hwdep_cal = wcdcal_get_fw_cal(tavil->fw_data, WCD9XXX_ANC_CAL);
-		if (hwdep_cal) {
-			data = hwdep_cal->data;
-			cal_size = hwdep_cal->size;
-			dev_dbg(codec->dev, "%s: using hwdep calibration, cal_size %zd",
-				__func__, cal_size);
-		} else {
-			filename = "WCD934X/WCD934X_anc.bin";
-			ret = request_firmware(&fw, filename, codec->dev);
-			if (ret < 0) {
-				dev_err(codec->dev, "%s: Failed to acquire ANC data: %d\n",
-					__func__, ret);
-				return ret;
-			}
-			if (!fw) {
-				dev_err(codec->dev, "%s: Failed to get anc fw\n",
-					__func__);
-				return -ENODEV;
-			}
-			data = fw->data;
-			cal_size = fw->size;
-			dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
-				__func__);
-		}
-		if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
-			dev_err(codec->dev, "%s: Invalid cal_size %zd\n",
-				__func__, cal_size);
-			ret = -EINVAL;
-			goto err;
-		}
-		/* First number is the number of register writes */
-		anc_head = (struct wcd9xxx_anc_header *)(data);
-		anc_ptr = (u32 *)(data + sizeof(struct wcd9xxx_anc_header));
-		anc_size_remaining = cal_size -
-				     sizeof(struct wcd9xxx_anc_header);
-		num_anc_slots = anc_head->num_anc_slots;
-
-		if (tavil->anc_slot >= num_anc_slots) {
-			dev_err(codec->dev, "%s: Invalid ANC slot selected\n",
-				__func__);
-			ret = -EINVAL;
-			goto err;
-		}
-		for (i = 0; i < num_anc_slots; i++) {
-			if (anc_size_remaining < WCD934X_PACKED_REG_SIZE) {
-				dev_err(codec->dev, "%s: Invalid register format\n",
-					__func__);
-				ret = -EINVAL;
-				goto err;
-			}
-			anc_writes_size = (u32)(*anc_ptr);
-			anc_size_remaining -= sizeof(u32);
-			anc_ptr += 1;
-
-			if ((anc_writes_size * WCD934X_PACKED_REG_SIZE) >
-			    anc_size_remaining) {
-				dev_err(codec->dev, "%s: Invalid register format\n",
-					__func__);
-				ret = -EINVAL;
-				goto err;
-			}
-
-			if (tavil->anc_slot == i)
-				break;
-
-			anc_size_remaining -= (anc_writes_size *
-				WCD934X_PACKED_REG_SIZE);
-			anc_ptr += anc_writes_size;
-		}
-		if (i == num_anc_slots) {
-			dev_err(codec->dev, "%s: Selected ANC slot not present\n",
-				__func__);
-			ret = -EINVAL;
-			goto err;
-		}
-
-		anc_cal_size = anc_writes_size;
-		for (i = 0; i < anc_writes_size; i++) {
-			WCD934X_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
-			snd_soc_write(codec, reg, (val & mask));
-		}
-
-		/* Rate converter clk enable and set bypass mode */
-		if (!strcmp(w->name, "RX INT0 DAC") ||
-		    !strcmp(w->name, "RX INT1 DAC") ||
-		    !strcmp(w->name, "ANC SPK1 PA")) {
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC0_RC_COMMON_CTL,
-					    0x05, 0x05);
-			if (!strcmp(w->name, "RX INT1 DAC")) {
-				snd_soc_update_bits(codec,
-					WCD934X_CDC_ANC0_FIFO_COMMON_CTL,
-					0x66, 0x66);
-			}
-		} else if (!strcmp(w->name, "RX INT2 DAC")) {
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_RC_COMMON_CTL,
-					    0x05, 0x05);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_FIFO_COMMON_CTL,
-					    0x66, 0x66);
-		}
-		if (!strcmp(w->name, "RX INT1 DAC"))
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
-		else if (!strcmp(w->name, "RX INT2 DAC"))
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
-
-		if (!hwdep_cal)
-			release_firmware(fw);
-		break;
-
-	case SND_SOC_DAPM_POST_PMU:
-		if (!strcmp(w->name, "ANC HPHL PA") ||
-		    !strcmp(w->name, "ANC HPHR PA")) {
-			/* Remove ANC Rx from reset */
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC0_CLK_RESET_CTL,
-					    0x08, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_CLK_RESET_CTL,
-					    0x08, 0x00);
-		}
-
-		break;
-
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, WCD934X_CDC_ANC0_RC_COMMON_CTL,
-				    0x05, 0x00);
-		if (!strcmp(w->name, "ANC EAR PA") ||
-		    !strcmp(w->name, "ANC SPK1 PA") ||
-		    !strcmp(w->name, "ANC HPHL PA")) {
-			snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_1_CTL,
-					    0x30, 0x00);
-			msleep(50);
-			snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_1_CTL,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC0_CLK_RESET_CTL,
-					    0x38, 0x38);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC0_CLK_RESET_CTL,
-					    0x07, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC0_CLK_RESET_CTL,
-					    0x38, 0x00);
-		} else if (!strcmp(w->name, "ANC HPHR PA")) {
-			snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_1_CTL,
-					    0x30, 0x00);
-			msleep(50);
-			snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_1_CTL,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_CLK_RESET_CTL,
-					    0x38, 0x38);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_CLK_RESET_CTL,
-					    0x07, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_ANC1_CLK_RESET_CTL,
-					    0x38, 0x00);
-		}
-		break;
-	}
-
-	return 0;
-err:
-	if (!hwdep_cal)
-		release_firmware(fw);
-	return ret;
-}
-
-static int tavil_get_clkmode(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-
-	if (test_bit(CLK_MODE, &tavil_p->status_mask))
-		ucontrol->value.enumerated.item[0] = 1;
-	else
-		ucontrol->value.enumerated.item[0] = 0;
-
-	dev_dbg(codec->dev, "%s: is_low_power_clock: %s\n", __func__,
-		test_bit(CLK_MODE, &tavil_p->status_mask) ? "true" : "false");
-
-	return 0;
-}
-
-static int tavil_put_clkmode(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-
-	if (ucontrol->value.enumerated.item[0])
-		set_bit(CLK_MODE, &tavil_p->status_mask);
-	else
-		clear_bit(CLK_MODE, &tavil_p->status_mask);
-
-	dev_dbg(codec->dev, "%s: is_low_power_clock: %s\n", __func__,
-		test_bit(CLK_MODE, &tavil_p->status_mask) ? "true" : "false");
-
-	return 0;
-}
-
-static int tavil_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil_p->vi_feed_value;
-
-	return 0;
-}
-
-static int tavil_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
-	struct soc_multi_mixer_control *mixer =
-		((struct soc_multi_mixer_control *)kcontrol->private_value);
-	u32 dai_id = widget->shift;
-	u32 port_id = mixer->shift;
-	u32 enable = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
-		__func__, enable, port_id, dai_id);
-
-	tavil_p->vi_feed_value = ucontrol->value.integer.value[0];
-
-	mutex_lock(&tavil_p->codec_mutex);
-	if (enable) {
-		if (port_id == WCD934X_TX14 && !test_bit(VI_SENSE_1,
-						&tavil_p->status_mask)) {
-			list_add_tail(&core->tx_chs[WCD934X_TX14].list,
-					&tavil_p->dai[dai_id].wcd9xxx_ch_list);
-			set_bit(VI_SENSE_1, &tavil_p->status_mask);
-		}
-		if (port_id == WCD934X_TX15 && !test_bit(VI_SENSE_2,
-						&tavil_p->status_mask)) {
-			list_add_tail(&core->tx_chs[WCD934X_TX15].list,
-					&tavil_p->dai[dai_id].wcd9xxx_ch_list);
-			set_bit(VI_SENSE_2, &tavil_p->status_mask);
-		}
-	} else {
-		if (port_id == WCD934X_TX14 && test_bit(VI_SENSE_1,
-					&tavil_p->status_mask)) {
-			list_del_init(&core->tx_chs[WCD934X_TX14].list);
-			clear_bit(VI_SENSE_1, &tavil_p->status_mask);
-		}
-		if (port_id == WCD934X_TX15 && test_bit(VI_SENSE_2,
-					&tavil_p->status_mask)) {
-			list_del_init(&core->tx_chs[WCD934X_TX15].list);
-			clear_bit(VI_SENSE_2, &tavil_p->status_mask);
-		}
-	}
-	mutex_unlock(&tavil_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
-
-	return 0;
-}
-
-static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil_p->tx_port_value;
-	return 0;
-}
-
-static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
-	struct snd_soc_dapm_update *update = NULL;
-	struct soc_multi_mixer_control *mixer =
-		((struct soc_multi_mixer_control *)kcontrol->private_value);
-	u32 dai_id = widget->shift;
-	u32 port_id = mixer->shift;
-	u32 enable = ucontrol->value.integer.value[0];
-	u32 vtable;
-
-	dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
-		  __func__,
-		widget->name, ucontrol->id.name, tavil_p->tx_port_value,
-		widget->shift, ucontrol->value.integer.value[0]);
-
-	mutex_lock(&tavil_p->codec_mutex);
-	if (dai_id >= ARRAY_SIZE(vport_slim_check_table)) {
-		dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
-			__func__, dai_id);
-		mutex_unlock(&tavil_p->codec_mutex);
-		return -EINVAL;
-	}
-	vtable = vport_slim_check_table[dai_id];
-
-	switch (dai_id) {
-	case AIF1_CAP:
-	case AIF2_CAP:
-	case AIF3_CAP:
-		/* only add to the list if value not set */
-		if (enable && !(tavil_p->tx_port_value & 1 << port_id)) {
-			if (wcd9xxx_tx_vport_validation(vtable, port_id,
-			    tavil_p->dai, NUM_CODEC_DAIS)) {
-				dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
-					__func__, port_id);
-				mutex_unlock(&tavil_p->codec_mutex);
-				return 0;
-			}
-			tavil_p->tx_port_value |= 1 << port_id;
-			list_add_tail(&core->tx_chs[port_id].list,
-				      &tavil_p->dai[dai_id].wcd9xxx_ch_list);
-		} else if (!enable && (tavil_p->tx_port_value &
-			   1 << port_id)) {
-			tavil_p->tx_port_value &= ~(1 << port_id);
-			list_del_init(&core->tx_chs[port_id].list);
-		} else {
-			if (enable)
-				dev_dbg(codec->dev, "%s: TX%u port is used by\n"
-					"this virtual port\n",
-					__func__, port_id);
-			else
-				dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
-					"this virtual port\n",
-					__func__, port_id);
-			/* avoid update power function */
-			mutex_unlock(&tavil_p->codec_mutex);
-			return 0;
-		}
-		break;
-	case AIF4_MAD_TX:
-		break;
-	default:
-		dev_err(codec->dev, "Unknown AIF %d\n", dai_id);
-		mutex_unlock(&tavil_p->codec_mutex);
-		return -EINVAL;
-	}
-	dev_dbg(codec->dev, "%s: name %s sname %s updated value %u shift %d\n",
-		__func__, widget->name, widget->sname, tavil_p->tx_port_value,
-		widget->shift);
-
-	mutex_unlock(&tavil_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
-
-	return 0;
-}
-
-static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.enumerated.item[0] =
-				tavil_p->rx_port_value[widget->shift];
-	return 0;
-}
-
-static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-	unsigned int rx_port_value;
-	u32 port_id = widget->shift;
-
-	tavil_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
-	rx_port_value = tavil_p->rx_port_value[port_id];
-
-	mutex_lock(&tavil_p->codec_mutex);
-	dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
-		__func__, widget->name, ucontrol->id.name,
-		rx_port_value, widget->shift,
-		ucontrol->value.integer.value[0]);
-
-	/* value need to match the Virtual port and AIF number */
-	switch (rx_port_value) {
-	case 0:
-		list_del_init(&core->rx_chs[port_id].list);
-		break;
-	case 1:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			WCD934X_RX_PORT_START_NUMBER,
-			&tavil_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tavil_p->dai[AIF1_PB].wcd9xxx_ch_list);
-		break;
-	case 2:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			WCD934X_RX_PORT_START_NUMBER,
-			&tavil_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tavil_p->dai[AIF2_PB].wcd9xxx_ch_list);
-		break;
-	case 3:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			WCD934X_RX_PORT_START_NUMBER,
-			&tavil_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tavil_p->dai[AIF3_PB].wcd9xxx_ch_list);
-		break;
-	case 4:
-		if (wcd9xxx_rx_vport_validation(port_id +
-			WCD934X_RX_PORT_START_NUMBER,
-			&tavil_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
-			dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
-				__func__, port_id);
-			goto rtn;
-		}
-		list_add_tail(&core->rx_chs[port_id].list,
-			      &tavil_p->dai[AIF4_PB].wcd9xxx_ch_list);
-		break;
-	default:
-		dev_err(codec->dev, "Unknown AIF %d\n", rx_port_value);
-		goto err;
-	}
-rtn:
-	mutex_unlock(&tavil_p->codec_mutex);
-	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
-				      rx_port_value, e, update);
-
-	return 0;
-err:
-	mutex_unlock(&tavil_p->codec_mutex);
-	return -EINVAL;
-}
-
-static void tavil_codec_enable_slim_port_intr(
-					struct wcd9xxx_codec_dai_data *dai,
-					struct snd_soc_codec *codec)
-{
-	struct wcd9xxx_ch *ch;
-	int port_num = 0;
-	unsigned short reg = 0;
-	u8 val = 0;
-	struct tavil_priv *tavil_p;
-
-	if (!dai || !codec) {
-		pr_err("%s: Invalid params\n", __func__);
-		return;
-	}
-
-	tavil_p = snd_soc_codec_get_drvdata(codec);
-	list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-		if (ch->port >= WCD934X_RX_PORT_START_NUMBER) {
-			port_num = ch->port - WCD934X_RX_PORT_START_NUMBER;
-			reg = WCD934X_SLIM_PGD_PORT_INT_RX_EN0 + (port_num / 8);
-			val = wcd9xxx_interface_reg_read(tavil_p->wcd9xxx,
-				reg);
-			if (!(val & BYTE_BIT_MASK(port_num))) {
-				val |= BYTE_BIT_MASK(port_num);
-				wcd9xxx_interface_reg_write(
-					tavil_p->wcd9xxx, reg, val);
-				val = wcd9xxx_interface_reg_read(
-					tavil_p->wcd9xxx, reg);
-			}
-		} else {
-			port_num = ch->port;
-			reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
-			val = wcd9xxx_interface_reg_read(tavil_p->wcd9xxx,
-				reg);
-			if (!(val & BYTE_BIT_MASK(port_num))) {
-				val |= BYTE_BIT_MASK(port_num);
-				wcd9xxx_interface_reg_write(tavil_p->wcd9xxx,
-					reg, val);
-				val = wcd9xxx_interface_reg_read(
-					tavil_p->wcd9xxx, reg);
-			}
-		}
-	}
-}
-
-static int tavil_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
-					  bool up)
-{
-	int ret = 0;
-	struct wcd9xxx_ch *ch;
-
-	if (up) {
-		list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
-			ret = wcd9xxx_get_slave_port(ch->ch_num);
-			if (ret < 0) {
-				pr_err("%s: Invalid slave port ID: %d\n",
-				       __func__, ret);
-				ret = -EINVAL;
-			} else {
-				set_bit(ret, &dai->ch_mask);
-			}
-		}
-	} else {
-		ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
-					 msecs_to_jiffies(
-						WCD934X_SLIM_CLOSE_TIMEOUT));
-		if (!ret) {
-			pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
-				__func__, dai->ch_mask);
-			ret = -ETIMEDOUT;
-		} else {
-			ret = 0;
-		}
-	}
-	return ret;
-}
-
-static void tavil_codec_mute_dsd(struct snd_soc_codec *codec,
-				 struct list_head *ch_list)
-{
-	u8 dsd0_in;
-	u8 dsd1_in;
-	struct wcd9xxx_ch *ch;
-
-	/* Read DSD Input Ports */
-	dsd0_in = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & 0x3C) >> 2;
-	dsd1_in = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & 0x3C) >> 2;
-
-	if ((dsd0_in == 0) && (dsd1_in == 0))
-		return;
-
-	/*
-	 * Check if the ports getting disabled are connected to DSD inputs.
-	 * If connected, enable DSD mute to avoid DC entering into DSD Filter
-	 */
-	list_for_each_entry(ch, ch_list, list) {
-		if (ch->port == (dsd0_in + WCD934X_RX_PORT_START_NUMBER - 1))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2,
-					    0x04, 0x04);
-		if (ch->port == (dsd1_in + WCD934X_RX_PORT_START_NUMBER - 1))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2,
-					    0x04, 0x04);
-	}
-}
-
-static int tavil_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct wcd9xxx *core;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-	struct wcd9xxx_codec_dai_data *dai;
-	struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config;
-
-	core = dev_get_drvdata(codec->dev->parent);
-
-	dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
-		"stream name %s event %d\n",
-		__func__, codec->component.name,
-		codec->component.num_dai, w->sname, event);
-
-	dai = &tavil_p->dai[w->shift];
-	dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
-		 __func__, w->name, w->shift, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		dai->bus_down_in_recovery = false;
-		tavil_codec_enable_slim_port_intr(dai, codec);
-		(void) tavil_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (dsd_conf)
-			tavil_codec_mute_dsd(codec, &dai->wcd9xxx_ch_list);
-
-		ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
-					      dai->grph);
-		dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
-			__func__, ret);
-
-		if (!dai->bus_down_in_recovery)
-			ret = tavil_codec_enable_slim_chmask(dai, false);
-		else
-			dev_dbg(codec->dev,
-				"%s: bus in recovery skip enable slim_chmask",
-				__func__);
-		ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		break;
-	}
-	return ret;
-}
-
-static int tavil_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_codec_dai_data *dai;
-	struct wcd9xxx *core;
-	int ret = 0;
-
-	dev_dbg(codec->dev,
-		"%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
-		__func__, w->name, w->shift,
-		codec->component.num_dai, w->sname);
-
-	dai = &tavil_p->dai[w->shift];
-	core = dev_get_drvdata(codec->dev->parent);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		dai->bus_down_in_recovery = false;
-		tavil_codec_enable_slim_port_intr(dai, codec);
-		(void) tavil_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		if (!dai->bus_down_in_recovery)
-			ret = tavil_codec_enable_slim_chmask(dai, false);
-		if (ret < 0) {
-			ret = wcd9xxx_disconnect_port(core,
-						      &dai->wcd9xxx_ch_list,
-						      dai->grph);
-			dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
-				 __func__, ret);
-		}
-		break;
-	}
-	return ret;
-}
-
-static int tavil_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
-					      struct snd_kcontrol *kcontrol,
-					      int event)
-{
-	struct wcd9xxx *core = NULL;
-	struct snd_soc_codec *codec = NULL;
-	struct tavil_priv *tavil_p = NULL;
-	int ret = 0;
-	struct wcd9xxx_codec_dai_data *dai = NULL;
-
-	codec = snd_soc_dapm_to_codec(w->dapm);
-	tavil_p = snd_soc_codec_get_drvdata(codec);
-	core = dev_get_drvdata(codec->dev->parent);
-
-	dev_dbg(codec->dev,
-		"%s: num_dai %d stream name %s w->name %s event %d shift %d\n",
-		__func__, codec->component.num_dai, w->sname,
-		w->name, event, w->shift);
-
-	if (w->shift != AIF4_VIFEED) {
-		pr_err("%s Error in enabling the tx path\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	dai = &tavil_p->dai[w->shift];
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		if (test_bit(VI_SENSE_1, &tavil_p->status_mask)) {
-			dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &tavil_p->status_mask)) {
-			pr_debug("%s: spkr2 enabled\n", __func__);
-			/* Enable V&I sensing */
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x10);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x00);
-		}
-		dai->bus_down_in_recovery = false;
-		tavil_codec_enable_slim_port_intr(dai, codec);
-		(void) tavil_codec_enable_slim_chmask(dai, true);
-		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-					      dai->rate, dai->bit_width,
-					      &dai->grph);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
-						dai->grph);
-		if (ret)
-			dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
-				__func__, ret);
-		if (!dai->bus_down_in_recovery)
-			ret = tavil_codec_enable_slim_chmask(dai, false);
-		if (ret < 0) {
-			ret = wcd9xxx_disconnect_port(core,
-				&dai->wcd9xxx_ch_list,
-				dai->grph);
-			dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
-				__func__, ret);
-		}
-		if (test_bit(VI_SENSE_1, &tavil_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		if (test_bit(VI_SENSE_2, &tavil_p->status_mask)) {
-			/* Disable V&I sensing */
-			dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
-				0x20);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
-				0x00);
-		}
-		break;
-	}
-done:
-	return ret;
-}
-
-static int tavil_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil->rx_bias_count++;
-		if (tavil->rx_bias_count == 1) {
-			snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
-					    0x01, 0x01);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tavil->rx_bias_count--;
-		if (!tavil->rx_bias_count)
-			snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
-					    0x01, 0x00);
-		break;
-	};
-	dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
-		tavil->rx_bias_count);
-
-	return 0;
-}
-
-static void tavil_spk_anc_update_callback(struct work_struct *work)
-{
-	struct spk_anc_work *spk_anc_dwork;
-	struct tavil_priv *tavil;
-	struct delayed_work *delayed_work;
-	struct snd_soc_codec *codec;
-
-	delayed_work = to_delayed_work(work);
-	spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
-	tavil = spk_anc_dwork->tavil;
-	codec = tavil->codec;
-
-	snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
-}
-
-static int tavil_codec_enable_spkr_anc(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	if (!tavil->anc_func)
-		return 0;
-
-	dev_dbg(codec->dev, "%s: w: %s event: %d anc: %d\n", __func__,
-		w->name, event, tavil->anc_func);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		ret = tavil_codec_enable_anc(w, kcontrol, event);
-		schedule_delayed_work(&tavil->spk_anc_dwork.dwork,
-				      msecs_to_jiffies(spk_anc_en_delay));
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		cancel_delayed_work_sync(&tavil->spk_anc_dwork.dwork);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_CFG0,
-				    0x10, 0x00);
-		ret = tavil_codec_enable_anc(w, kcontrol, event);
-		break;
-	}
-	return ret;
-}
-
-static int tavil_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/*
-		 * 5ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD934X_CDC_RX0_RX_PATH_MIX_CTL)) &
-		     0x10)
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX0_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-
-		if (!(strcmp(w->name, "ANC EAR PA"))) {
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CFG0,
-					    0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static void tavil_codec_override(struct snd_soc_codec *codec, int mode,
-				 int event)
-{
-	if (mode == CLS_AB || mode == CLS_AB_HIFI) {
-		switch (event) {
-		case SND_SOC_DAPM_PRE_PMU:
-		case SND_SOC_DAPM_POST_PMU:
-			snd_soc_update_bits(codec,
-				WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
-		break;
-		case SND_SOC_DAPM_POST_PMD:
-			snd_soc_update_bits(codec,
-				WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
-		break;
-		}
-	}
-}
-
-static void tavil_codec_clear_anc_tx_hold(struct tavil_priv *tavil)
-{
-	if (test_and_clear_bit(ANC_MIC_AMIC1, &tavil->status_mask))
-		tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC1, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC2, &tavil->status_mask))
-		tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC2, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC3, &tavil->status_mask))
-		tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC3, false);
-	if (test_and_clear_bit(ANC_MIC_AMIC4, &tavil->status_mask))
-		tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC4, false);
-}
-
-static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
-					    0x06, (0x03 << 1));
-
-		if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
-		    (test_bit(HPH_PA_DELAY, &tavil->status_mask)))
-			snd_soc_update_bits(codec, WCD934X_ANA_HPH, 0xC0, 0xC0);
-
-		set_bit(HPH_PA_DELAY, &tavil->status_mask);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) {
-			/* Set regulator mode to AB if DSD is enabled */
-			snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
-					    0x02, 0x02);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if ((!(strcmp(w->name, "ANC HPHR PA")))) {
-			if ((snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0)
-					!= 0xC0)
-				/*
-				 * If PA_EN is not set (potentially in ANC case)
-				 * then do nothing for POST_PMU and let left
-				 * channel handle everything.
-				 */
-				break;
-		}
-		/*
-		 * 7ms sleep is required after PA is enabled as per
-		 * HW requirement. If compander is disabled, then
-		 * 20ms delay is needed.
-		 */
-		if (test_bit(HPH_PA_DELAY, &tavil->status_mask)) {
-			if (!tavil->comp_enabled[COMPANDER_2])
-				usleep_range(20000, 20100);
-			else
-				usleep_range(7000, 7100);
-			clear_bit(HPH_PA_DELAY, &tavil->status_mask);
-		}
-		if (tavil->anc_func) {
-			/* Clear Tx FE HOLD if both PAs are enabled */
-			if ((snd_soc_read(tavil->codec, WCD934X_ANA_HPH) &
-					0xC0) == 0xC0)
-				tavil_codec_clear_anc_tx_hold(tavil);
-		}
-
-		snd_soc_update_bits(codec, WCD934X_HPH_R_TEST, 0x01, 0x01);
-
-		/* Remove mute */
-		snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Enable GM3 boost */
-		snd_soc_update_bits(codec, WCD934X_HPH_CNP_WG_CTL,
-				    0x80, 0x80);
-		/* Enable AutoChop timer at the end of power up */
-		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
-				    0x02, 0x02);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) &
-				  0x10)
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX2_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2,
-					    0x04, 0x00);
-		if (!(strcmp(w->name, "ANC HPHR PA"))) {
-			pr_debug("%s:Do everything needed for left channel\n",
-				__func__);
-			/* Do everything needed for left channel */
-			snd_soc_update_bits(codec, WCD934X_HPH_L_TEST,
-					    0x01, 0x01);
-
-			/* Remove mute */
-			snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL,
-					    0x10, 0x00);
-
-			/* Remove mix path mute if it is enabled */
-			if ((snd_soc_read(codec,
-					WCD934X_CDC_RX1_RX_PATH_MIX_CTL)) &
-					0x10)
-				snd_soc_update_bits(codec,
-					WCD934X_CDC_RX1_RX_PATH_MIX_CTL,
-					0x10, 0x00);
-
-			if (dsd_conf && (snd_soc_read(codec,
-						WCD934X_CDC_DSD0_PATH_CTL) &
-						0x01))
-				snd_soc_update_bits(codec,
-						    WCD934X_CDC_DSD0_CFG2,
-						    0x04, 0x00);
-			/* Remove ANC Rx from reset */
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-		}
-		tavil_codec_override(codec, tavil->hph_mode, event);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					     WCD_EVENT_PRE_HPHR_PA_OFF,
-					     &tavil->mbhc->wcd_mbhc);
-		/* Enable DSD Mute before PA disable */
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2,
-					    0x04, 0x04);
-		snd_soc_update_bits(codec, WCD934X_HPH_R_TEST, 0x01, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL,
-				    0x10, 0x10);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_MIX_CTL,
-				    0x10, 0x10);
-		if (!(strcmp(w->name, "ANC HPHR PA")))
-			snd_soc_update_bits(codec, WCD934X_ANA_HPH, 0x40, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * 5ms sleep is required after PA disable. If compander is
-		 * disabled, then 20ms delay is needed after PA disable.
-		 */
-		if (!tavil->comp_enabled[COMPANDER_2])
-			usleep_range(20000, 20100);
-		else
-			usleep_range(5000, 5100);
-		tavil_codec_override(codec, tavil->hph_mode, event);
-		blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					     WCD_EVENT_POST_HPHR_PA_OFF,
-					     &tavil->mbhc->wcd_mbhc);
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
-					    0x06, 0x0);
-		if (!(strcmp(w->name, "ANC HPHR PA"))) {
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX2_RX_PATH_CFG0,
-					    0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
-					    0x06, (0x03 << 1));
-		if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
-		    (test_bit(HPH_PA_DELAY, &tavil->status_mask)))
-			snd_soc_update_bits(codec, WCD934X_ANA_HPH,
-					    0xC0, 0xC0);
-		set_bit(HPH_PA_DELAY, &tavil->status_mask);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) {
-			/* Set regulator mode to AB if DSD is enabled */
-			snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
-					    0x02, 0x02);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			if ((snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0)
-								!= 0xC0)
-				/*
-				 * If PA_EN is not set (potentially in ANC
-				 * case) then do nothing for POST_PMU and
-				 * let right channel handle everything.
-				 */
-				break;
-		}
-		/*
-		 * 7ms sleep is required after PA is enabled as per
-		 * HW requirement. If compander is disabled, then
-		 * 20ms delay is needed.
-		 */
-		if (test_bit(HPH_PA_DELAY, &tavil->status_mask)) {
-			if (!tavil->comp_enabled[COMPANDER_1])
-				usleep_range(20000, 20100);
-			else
-				usleep_range(7000, 7100);
-			clear_bit(HPH_PA_DELAY, &tavil->status_mask);
-		}
-		if (tavil->anc_func) {
-			/* Clear Tx FE HOLD if both PAs are enabled */
-			if ((snd_soc_read(tavil->codec, WCD934X_ANA_HPH) &
-					0xC0) == 0xC0)
-				tavil_codec_clear_anc_tx_hold(tavil);
-		}
-
-		snd_soc_update_bits(codec, WCD934X_HPH_L_TEST, 0x01, 0x01);
-		/* Remove Mute on primary path */
-		snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL,
-				    0x10, 0x00);
-		/* Enable GM3 boost */
-		snd_soc_update_bits(codec, WCD934X_HPH_CNP_WG_CTL,
-				    0x80, 0x80);
-		/* Enable AutoChop timer at the end of power up */
-		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
-				    0x02, 0x02);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, WCD934X_CDC_RX1_RX_PATH_MIX_CTL)) &
-				  0x10)
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX1_RX_PATH_MIX_CTL,
-					    0x10, 0x00);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2,
-					    0x04, 0x00);
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			pr_debug("%s:Do everything needed for right channel\n",
-				__func__);
-
-			/* Do everything needed for right channel */
-			snd_soc_update_bits(codec, WCD934X_HPH_R_TEST,
-					    0x01, 0x01);
-
-			/* Remove mute */
-			snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL,
-						0x10, 0x00);
-
-			/* Remove mix path mute if it is enabled */
-			if ((snd_soc_read(codec,
-					WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) &
-					0x10)
-				snd_soc_update_bits(codec,
-						WCD934X_CDC_RX2_RX_PATH_MIX_CTL,
-						0x10, 0x00);
-			if (dsd_conf && (snd_soc_read(codec,
-					WCD934X_CDC_DSD1_PATH_CTL) & 0x01))
-				snd_soc_update_bits(codec,
-						    WCD934X_CDC_DSD1_CFG2,
-						    0x04, 0x00);
-			/* Remove ANC Rx from reset */
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-		}
-		tavil_codec_override(codec, tavil->hph_mode, event);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					     WCD_EVENT_PRE_HPHL_PA_OFF,
-					     &tavil->mbhc->wcd_mbhc);
-		/* Enable DSD Mute before PA disable */
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01))
-			snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2,
-					    0x04, 0x04);
-
-		snd_soc_update_bits(codec, WCD934X_HPH_L_TEST, 0x01, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL,
-				    0x10, 0x10);
-		snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_MIX_CTL,
-				    0x10, 0x10);
-		if (!(strcmp(w->name, "ANC HPHL PA")))
-			snd_soc_update_bits(codec, WCD934X_ANA_HPH,
-					    0x80, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * 5ms sleep is required after PA disable. If compander is
-		 * disabled, then 20ms delay is needed after PA disable.
-		 */
-		if (!tavil->comp_enabled[COMPANDER_1])
-			usleep_range(20000, 20100);
-		else
-			usleep_range(5000, 5100);
-		tavil_codec_override(codec, tavil->hph_mode, event);
-		blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					     WCD_EVENT_POST_HPHL_PA_OFF,
-					     &tavil->mbhc->wcd_mbhc);
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
-					    0x06, 0x0);
-		if (!(strcmp(w->name, "ANC HPHL PA"))) {
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-			snd_soc_update_bits(codec,
-				WCD934X_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
-		}
-		break;
-	};
-
-	return ret;
-}
-
-static int tavil_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
-	u16 dsd_mute_reg = 0, dsd_clk_reg = 0;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	if (w->reg == WCD934X_ANA_LO_1_2) {
-		if (w->shift == 7) {
-			lineout_vol_reg = WCD934X_CDC_RX3_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD934X_CDC_RX3_RX_PATH_MIX_CTL;
-			dsd_mute_reg = WCD934X_CDC_DSD0_CFG2;
-			dsd_clk_reg = WCD934X_CDC_DSD0_PATH_CTL;
-		} else if (w->shift == 6) {
-			lineout_vol_reg = WCD934X_CDC_RX4_RX_PATH_CTL;
-			lineout_mix_vol_reg = WCD934X_CDC_RX4_RX_PATH_MIX_CTL;
-			dsd_mute_reg = WCD934X_CDC_DSD1_CFG2;
-			dsd_clk_reg = WCD934X_CDC_DSD1_PATH_CTL;
-		}
-	} else {
-		dev_err(codec->dev, "%s: Error enabling lineout PA\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil_codec_override(codec, CLS_AB, event);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/*
-		 * 5ms sleep is required after PA is enabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		snd_soc_update_bits(codec, lineout_vol_reg,
-				    0x10, 0x00);
-		/* Remove mix path mute if it is enabled */
-		if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
-			snd_soc_update_bits(codec,
-					    lineout_mix_vol_reg,
-					    0x10, 0x00);
-		if (dsd_conf && (snd_soc_read(codec, dsd_clk_reg) & 0x01))
-			snd_soc_update_bits(codec, dsd_mute_reg, 0x04, 0x00);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		if (dsd_conf && (snd_soc_read(codec, dsd_clk_reg) & 0x01))
-			snd_soc_update_bits(codec, dsd_mute_reg, 0x04, 0x04);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * 5ms sleep is required after PA is disabled as per
-		 * HW requirement
-		 */
-		usleep_range(5000, 5500);
-		tavil_codec_override(codec, CLS_AB, event);
-	default:
-		break;
-	};
-
-	return 0;
-}
-
-static int tavil_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
-				     struct snd_kcontrol *kcontrol,
-				     int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* Disable AutoChop timer during power up */
-		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
-				    0x02, 0x00);
-
-		if (tavil->anc_func)
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_EAR,
-			     CLS_H_NORMAL);
-		if (tavil->anc_func)
-			snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CFG0,
-					    0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_EAR,
-			     CLS_H_NORMAL);
-		break;
-	default:
-		break;
-	};
-
-	return ret;
-}
-
-static int tavil_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int hph_mode = tavil->hph_mode;
-	u8 dem_inp;
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-	int ret = 0;
-
-	dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
-		w->name, event, hph_mode);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tavil->anc_func) {
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-			/* 40 msec delay is needed to avoid click and pop */
-			msleep(40);
-		}
-		/* Read DEM INP Select */
-		dem_inp = snd_soc_read(codec, WCD934X_CDC_RX2_RX_PATH_SEC0) &
-			  0x03;
-		if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
-		     (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
-			dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
-					__func__, hph_mode);
-			return -EINVAL;
-		}
-		if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP))
-			/* Ripple freq control enable */
-			snd_soc_update_bits(codec,
-					     WCD934X_SIDO_NEW_VOUT_D_FREQ2,
-					     0x01, 0x01);
-		/* Disable AutoChop timer during power up */
-		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
-				    0x02, 0x00);
-		/* Set RDAC gain */
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec,
-					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
-					    0xF0, 0x40);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01))
-			hph_mode = CLS_H_HIFI;
-
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_HPHR,
-			     hph_mode);
-		if (tavil->anc_func)
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX2_RX_PATH_CFG0,
-					    0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_HPHR,
-			     hph_mode);
-		if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP))
-			/* Ripple freq control disable */
-			snd_soc_update_bits(codec,
-					    WCD934X_SIDO_NEW_VOUT_D_FREQ2,
-					    0x01, 0x0);
-		/* Re-set RDAC gain */
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec,
-					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
-					    0xF0, 0x0);
-		break;
-	default:
-		break;
-	};
-
-	return 0;
-}
-
-static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int hph_mode = tavil->hph_mode;
-	u8 dem_inp;
-	int ret = 0;
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-	uint32_t impedl = 0, impedr = 0;
-
-	dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
-		w->name, event, hph_mode);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tavil->anc_func) {
-			ret = tavil_codec_enable_anc(w, kcontrol, event);
-			/* 40 msec delay is needed to avoid click and pop */
-			msleep(40);
-		}
-		/* Read DEM INP Select */
-		dem_inp = snd_soc_read(codec, WCD934X_CDC_RX1_RX_PATH_SEC0) &
-			  0x03;
-		if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
-		     (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
-			dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
-					__func__, hph_mode);
-			return -EINVAL;
-		}
-		if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP))
-			/* Ripple freq control enable */
-			snd_soc_update_bits(codec,
-					     WCD934X_SIDO_NEW_VOUT_D_FREQ2,
-					     0x01, 0x01);
-		/* Disable AutoChop timer during power up */
-		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
-				    0x02, 0x00);
-		/* Set RDAC gain */
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec,
-					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
-					    0xF0, 0x40);
-		if (dsd_conf &&
-		    (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01))
-			hph_mode = CLS_H_HIFI;
-
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_HPHL,
-			     hph_mode);
-
-		if (tavil->anc_func)
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX1_RX_PATH_CFG0,
-					    0x10, 0x10);
-
-		ret = tavil_mbhc_get_impedance(tavil->mbhc,
-					       &impedl, &impedr);
-		if (!ret) {
-			wcd_clsh_imped_config(codec, impedl, false);
-			set_bit(CLSH_Z_CONFIG, &tavil->status_mask);
-		} else {
-			dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
-				__func__, ret);
-			ret = 0;
-		}
-
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* 1000us required as per HW requirement */
-		usleep_range(1000, 1100);
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_HPHL,
-			     hph_mode);
-		if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP))
-			/* Ripple freq control disable */
-			snd_soc_update_bits(codec,
-					    WCD934X_SIDO_NEW_VOUT_D_FREQ2,
-					    0x01, 0x0);
-		/* Re-set RDAC gain */
-		if (TAVIL_IS_1_0(tavil->wcd9xxx))
-			snd_soc_update_bits(codec,
-					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
-					    0xF0, 0x0);
-
-		if (test_bit(CLSH_Z_CONFIG, &tavil->status_mask)) {
-			wcd_clsh_imped_config(codec, impedl, true);
-			clear_bit(CLSH_Z_CONFIG, &tavil->status_mask);
-		}
-		break;
-	default:
-		break;
-	};
-
-	return ret;
-}
-
-static int tavil_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
-					 struct snd_kcontrol *kcontrol,
-					 int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_PRE_DAC,
-			     WCD_CLSH_STATE_LO,
-			     CLS_AB);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		wcd_clsh_fsm(codec, &tavil->clsh_d,
-			     WCD_CLSH_EVENT_POST_PA,
-			     WCD_CLSH_STATE_LO,
-			     CLS_AB);
-		break;
-	}
-
-	return 0;
-}
-
-static int tavil_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
-					struct snd_kcontrol *kcontrol,
-					int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 boost_path_ctl, boost_path_cfg1;
-	u16 reg, reg_mix;
-
-	dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
-
-	if (!strcmp(w->name, "RX INT7 CHAIN")) {
-		boost_path_ctl = WCD934X_CDC_BOOST0_BOOST_PATH_CTL;
-		boost_path_cfg1 = WCD934X_CDC_RX7_RX_PATH_CFG1;
-		reg = WCD934X_CDC_RX7_RX_PATH_CTL;
-		reg_mix = WCD934X_CDC_RX7_RX_PATH_MIX_CTL;
-	} else if (!strcmp(w->name, "RX INT8 CHAIN")) {
-		boost_path_ctl = WCD934X_CDC_BOOST1_BOOST_PATH_CTL;
-		boost_path_cfg1 = WCD934X_CDC_RX8_RX_PATH_CFG1;
-		reg = WCD934X_CDC_RX8_RX_PATH_CTL;
-		reg_mix = WCD934X_CDC_RX8_RX_PATH_MIX_CTL;
-	} else {
-		dev_err(codec->dev, "%s: unknown widget: %s\n",
-			__func__, w->name);
-		return -EINVAL;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
-		snd_soc_update_bits(codec, reg, 0x10, 0x00);
-		if ((snd_soc_read(codec, reg_mix)) & 0x10)
-			snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
-		snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
-		break;
-	};
-
-	return 0;
-}
-
-static int __tavil_codec_enable_swr(struct snd_soc_dapm_widget *w, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil;
-	int ch_cnt = 0;
-
-	tavil = snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) ||
-			(strnstr(w->name, "INT7 MIX2",
-						sizeof("RX INT7 MIX2")))))
-			tavil->swr.rx_7_count++;
-		if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
-		    !tavil->swr.rx_8_count)
-			tavil->swr.rx_8_count++;
-		ch_cnt = !!(tavil->swr.rx_7_count) + tavil->swr.rx_8_count;
-
-		swrm_wcd_notify(tavil->swr.ctrl_data[0].swr_pdev,
-				SWR_DEVICE_UP, NULL);
-		swrm_wcd_notify(tavil->swr.ctrl_data[0].swr_pdev,
-				SWR_SET_NUM_RX_CH, &ch_cnt);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if ((strnstr(w->name, "INT7_", sizeof("RX INT7_")))  ||
-			(strnstr(w->name, "INT7 MIX2",
-			sizeof("RX INT7 MIX2"))))
-			tavil->swr.rx_7_count--;
-		if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
-		    tavil->swr.rx_8_count)
-			tavil->swr.rx_8_count--;
-		ch_cnt = !!(tavil->swr.rx_7_count) + tavil->swr.rx_8_count;
-
-		swrm_wcd_notify(tavil->swr.ctrl_data[0].swr_pdev,
-				SWR_SET_NUM_RX_CH, &ch_cnt);
-
-		break;
-	}
-	dev_dbg(tavil->dev, "%s: %s: current swr ch cnt: %d\n",
-		__func__, w->name, ch_cnt);
-
-	return 0;
-}
-
-static int tavil_codec_enable_swr(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	return __tavil_codec_enable_swr(w, event);
-}
-
-static int tavil_codec_config_mad(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	int idx;
-	const struct firmware *fw;
-	struct firmware_cal *hwdep_cal = NULL;
-	struct wcd_mad_audio_cal *mad_cal = NULL;
-	const void *data;
-	const char *filename = WCD934X_MAD_AUDIO_FIRMWARE_PATH;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	size_t cal_size;
-
-	hwdep_cal = wcdcal_get_fw_cal(tavil->fw_data, WCD9XXX_MAD_CAL);
-	if (hwdep_cal) {
-		data = hwdep_cal->data;
-		cal_size = hwdep_cal->size;
-		dev_dbg(codec->dev, "%s: using hwdep calibration\n",
-			__func__);
-	} else {
-		ret = request_firmware(&fw, filename, codec->dev);
-		if (ret || !fw) {
-			dev_err(codec->dev,
-				"%s: MAD firmware acquire failed, err = %d\n",
-				__func__, ret);
-			return -ENODEV;
-		}
-		data = fw->data;
-		cal_size = fw->size;
-		dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
-			__func__);
-	}
-
-	if (cal_size < sizeof(*mad_cal)) {
-		dev_err(codec->dev,
-			"%s: Incorrect size %zd for MAD Cal, expected %zd\n",
-			__func__, cal_size, sizeof(*mad_cal));
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	mad_cal = (struct wcd_mad_audio_cal *) (data);
-	if (!mad_cal) {
-		dev_err(codec->dev,
-			"%s: Invalid calibration data\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snd_soc_write(codec, WCD934X_SOC_MAD_MAIN_CTL_2,
-		      mad_cal->microphone_info.cycle_time);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
-			    ((uint16_t)mad_cal->microphone_info.settle_time)
-			    << 3);
-
-	/* Audio */
-	snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_8,
-		      mad_cal->audio_info.rms_omit_samples);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_1,
-			    0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
-			    mad_cal->audio_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_7,
-		      mad_cal->audio_info.rms_diff_threshold & 0x3F);
-	snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_5,
-		      mad_cal->audio_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_6,
-		      mad_cal->audio_info.rms_threshold_msb);
-
-	for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
-	     idx++) {
-		snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR,
-				    0x3F, idx);
-		snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL,
-			      mad_cal->audio_info.iir_coefficients[idx]);
-		dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
-			__func__, idx,
-			mad_cal->audio_info.iir_coefficients[idx]);
-	}
-
-	/* Beacon */
-	snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_8,
-		      mad_cal->beacon_info.rms_omit_samples);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_CTL_1,
-			    0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
-			    mad_cal->beacon_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_7,
-		      mad_cal->beacon_info.rms_diff_threshold & 0x1F);
-	snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_5,
-		      mad_cal->beacon_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_6,
-		      mad_cal->beacon_info.rms_threshold_msb);
-
-	for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
-	     idx++) {
-		snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR,
-				    0x3F, idx);
-		snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL,
-			      mad_cal->beacon_info.iir_coefficients[idx]);
-		dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
-			__func__, idx,
-			mad_cal->beacon_info.iir_coefficients[idx]);
-	}
-
-	/* Ultrasound */
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_ULTR_CTL_1,
-			    0x07 << 4,
-			    mad_cal->ultrasound_info.rms_comp_time << 4);
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
-			    mad_cal->ultrasound_info.detection_mechanism << 2);
-	snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_7,
-		      mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
-	snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_5,
-		      mad_cal->ultrasound_info.rms_threshold_lsb);
-	snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_6,
-		      mad_cal->ultrasound_info.rms_threshold_msb);
-
-done:
-	if (!hwdep_cal)
-		release_firmware(fw);
-
-	return ret;
-}
-
-static int __tavil_codec_enable_mad(struct snd_soc_codec *codec, bool enable)
-{
-	int rc = 0;
-
-	/* Return if CPE INPUT is DEC1 */
-	if (snd_soc_read(codec, WCD934X_CPE_SS_SVA_CFG) & 0x04) {
-		dev_dbg(codec->dev, "%s: MAD is bypassed, skip mad %s\n",
-			__func__, enable ? "enable" : "disable");
-		return rc;
-	}
-
-	dev_dbg(codec->dev, "%s: enable = %s\n", __func__,
-		enable ? "enable" : "disable");
-
-	if (enable) {
-		snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2,
-				    0x03, 0x03);
-		rc = tavil_codec_config_mad(codec);
-		if (rc < 0) {
-			snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2,
-					    0x03, 0x00);
-			goto done;
-		}
-
-		/* Turn on MAD clk */
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL,
-				    0x01, 0x01);
-
-		/* Undo reset for MAD */
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL,
-				    0x02, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-					0x04, 0x04);
-	} else {
-		snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2,
-				    0x03, 0x00);
-		/* Reset the MAD block */
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL,
-				    0x02, 0x02);
-		/* Turn off MAD clk */
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL,
-				    0x01, 0x00);
-		snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-					0x04, 0x00);
-	}
-done:
-	return rc;
-}
-
-static int tavil_codec_ape_enable_mad(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol,
-				      int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int rc = 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x40, 0x40);
-		rc = __tavil_codec_enable_mad(codec, true);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x40, 0x00);
-		__tavil_codec_enable_mad(codec, false);
-		break;
-	}
-
-	dev_dbg(tavil->dev, "%s: event = %d\n", __func__, event);
-	return rc;
-}
-
-static int tavil_codec_cpe_mad_ctl(struct snd_soc_dapm_widget *w,
-				   struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int rc = 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil->mad_switch_cnt++;
-		if (tavil->mad_switch_cnt != 1)
-			goto done;
-
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x20, 0x20);
-		rc = __tavil_codec_enable_mad(codec, true);
-		if (rc < 0) {
-			tavil->mad_switch_cnt--;
-			goto done;
-		}
-
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		tavil->mad_switch_cnt--;
-		if (tavil->mad_switch_cnt != 0)
-			goto done;
-
-		snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x20, 0x00);
-		__tavil_codec_enable_mad(codec, false);
-		break;
-	}
-done:
-	dev_dbg(tavil->dev, "%s: event = %d, mad_switch_cnt = %d\n",
-		__func__, event, tavil->mad_switch_cnt);
-	return rc;
-}
-
-static int tavil_get_asrc_mode(struct tavil_priv *tavil, int asrc,
-			       u8 main_sr, u8 mix_sr)
-{
-	u8 asrc_output_mode;
-	int asrc_mode = CONV_88P2K_TO_384K;
-
-	if ((asrc < 0) || (asrc >= ASRC_MAX))
-		return 0;
-
-	asrc_output_mode = tavil->asrc_output_mode[asrc];
-
-	if (asrc_output_mode) {
-		/*
-		 * If Mix sample rate is < 96KHz, use 96K to 352.8K
-		 * conversion, or else use 384K to 352.8K conversion
-		 */
-		if (mix_sr < 5)
-			asrc_mode = CONV_96K_TO_352P8K;
-		else
-			asrc_mode = CONV_384K_TO_352P8K;
-	} else {
-		/* Integer main and Fractional mix path */
-		if (main_sr < 8 && mix_sr > 9) {
-			asrc_mode = CONV_352P8K_TO_384K;
-		} else if (main_sr > 8 && mix_sr < 8) {
-			/* Fractional main and Integer mix path */
-			if (mix_sr < 5)
-				asrc_mode = CONV_96K_TO_352P8K;
-			else
-				asrc_mode = CONV_384K_TO_352P8K;
-		} else if (main_sr < 8 && mix_sr < 8) {
-			/* Integer main and Integer mix path */
-			asrc_mode = CONV_96K_TO_384K;
-		}
-	}
-
-	return asrc_mode;
-}
-
-static int tavil_codec_wdma3_ctl(struct snd_soc_dapm_widget *w,
-				   struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/* Fix to 16KHz */
-		snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3,
-				    0xF0, 0x10);
-		/* Select mclk_1 */
-		snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3,
-				    0x02, 0x00);
-		/* Enable DMA */
-		snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3,
-				    0x01, 0x01);
-		break;
-
-	case SND_SOC_DAPM_POST_PMD:
-		/* Disable DMA */
-		snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3,
-				    0x01, 0x00);
-		break;
-
-	};
-
-	return 0;
-}
-
-static int tavil_codec_enable_asrc(struct snd_soc_codec *codec,
-				   int asrc_in, int event)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u16 cfg_reg, ctl_reg, clk_reg, asrc_ctl, mix_ctl_reg;
-	int asrc, ret = 0;
-	u8 main_sr, mix_sr, asrc_mode = 0;
-
-	switch (asrc_in) {
-	case ASRC_IN_HPHL:
-		cfg_reg = WCD934X_CDC_RX1_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX1_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC0_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC0_CTL1;
-		asrc = ASRC0;
-		break;
-	case ASRC_IN_LO1:
-		cfg_reg = WCD934X_CDC_RX3_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX3_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC0_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC0_CTL1;
-		asrc = ASRC0;
-		break;
-	case ASRC_IN_HPHR:
-		cfg_reg = WCD934X_CDC_RX2_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX2_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC1_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC1_CTL1;
-		asrc = ASRC1;
-		break;
-	case ASRC_IN_LO2:
-		cfg_reg = WCD934X_CDC_RX4_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX4_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC1_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC1_CTL1;
-		asrc = ASRC1;
-		break;
-	case ASRC_IN_SPKR1:
-		cfg_reg = WCD934X_CDC_RX7_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX7_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC2_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC2_CTL1;
-		asrc = ASRC2;
-		break;
-	case ASRC_IN_SPKR2:
-		cfg_reg = WCD934X_CDC_RX8_RX_PATH_CFG0;
-		ctl_reg = WCD934X_CDC_RX8_RX_PATH_CTL;
-		clk_reg = WCD934X_MIXING_ASRC3_CLK_RST_CTL;
-		asrc_ctl = WCD934X_MIXING_ASRC3_CTL1;
-		asrc = ASRC3;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid asrc input :%d\n", __func__,
-			asrc_in);
-		ret = -EINVAL;
-		goto done;
-	};
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (tavil->asrc_users[asrc] == 0) {
-			snd_soc_update_bits(codec, cfg_reg, 0x80, 0x80);
-			snd_soc_update_bits(codec, clk_reg, 0x01, 0x01);
-			main_sr = snd_soc_read(codec, ctl_reg) & 0x0F;
-			mix_ctl_reg = ctl_reg + 5;
-			mix_sr = snd_soc_read(codec, mix_ctl_reg) & 0x0F;
-			asrc_mode = tavil_get_asrc_mode(tavil, asrc,
-							main_sr, mix_sr);
-			dev_dbg(codec->dev, "%s: main_sr:%d mix_sr:%d asrc_mode %d\n",
-				__func__, main_sr, mix_sr, asrc_mode);
-			snd_soc_update_bits(codec, asrc_ctl, 0x07, asrc_mode);
-		}
-		tavil->asrc_users[asrc]++;
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tavil->asrc_users[asrc]--;
-		if (tavil->asrc_users[asrc] <= 0) {
-			tavil->asrc_users[asrc] = 0;
-			snd_soc_update_bits(codec, asrc_ctl, 0x07, 0x00);
-			snd_soc_update_bits(codec, cfg_reg, 0x80, 0x00);
-			snd_soc_update_bits(codec, clk_reg, 0x01, 0x00);
-		}
-		break;
-	};
-
-	dev_dbg(codec->dev, "%s: ASRC%d, users: %d\n",
-		__func__, asrc, tavil->asrc_users[asrc]);
-
-done:
-	return ret;
-}
-
-static int tavil_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w,
-					     struct snd_kcontrol *kcontrol,
-					     int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-	u8 cfg, asrc_in;
-
-	cfg = snd_soc_read(codec, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0);
-	if (!(cfg & 0xFF)) {
-		dev_err(codec->dev, "%s: ASRC%u input not selected\n",
-			__func__, w->shift);
-		return -EINVAL;
-	}
-
-	switch (w->shift) {
-	case ASRC0:
-		asrc_in = ((cfg & 0x03) == 1) ? ASRC_IN_HPHL : ASRC_IN_LO1;
-		ret = tavil_codec_enable_asrc(codec, asrc_in, event);
-		break;
-	case ASRC1:
-		asrc_in = ((cfg & 0x0C) == 4) ? ASRC_IN_HPHR : ASRC_IN_LO2;
-		ret = tavil_codec_enable_asrc(codec, asrc_in, event);
-		break;
-	case ASRC2:
-		asrc_in = ((cfg & 0x30) == 0x20) ? ASRC_IN_SPKR1 : ASRC_INVALID;
-		ret = tavil_codec_enable_asrc(codec, asrc_in, event);
-		break;
-	case ASRC3:
-		asrc_in = ((cfg & 0xC0) == 0x80) ? ASRC_IN_SPKR2 : ASRC_INVALID;
-		ret = tavil_codec_enable_asrc(codec, asrc_in, event);
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid asrc:%u\n", __func__,
-			w->shift);
-		ret = -EINVAL;
-		break;
-	};
-
-	return ret;
-}
-
-static int tavil_enable_native_supply(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (++tavil->native_clk_users == 1) {
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_PLL_ENABLES,
-					    0x01, 0x01);
-			usleep_range(100, 120);
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1,
-					    0x06, 0x02);
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE,
-					    0x04, 0x00);
-			usleep_range(30, 50);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x02, 0x02);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x10, 0x10);
-		}
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		if (tavil->native_clk_users &&
-		    (--tavil->native_clk_users == 0)) {
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x10, 0x00);
-			snd_soc_update_bits(codec,
-					WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x02, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE,
-					    0x04, 0x04);
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1,
-					    0x06, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CLK_SYS_PLL_ENABLES,
-					    0x01, 0x00);
-		}
-		break;
-	}
-
-	dev_dbg(codec->dev, "%s: native_clk_users: %d, event: %d\n",
-		__func__, tavil->native_clk_users, event);
-
-	return 0;
-}
-
-static void tavil_codec_hphdelay_lutbypass(struct snd_soc_codec *codec,
-				    u16 interp_idx, int event)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u8 hph_dly_mask;
-	u16 hph_lut_bypass_reg = 0;
-	u16 hph_comp_ctrl7 = 0;
-
-
-	switch (interp_idx) {
-	case INTERP_HPHL:
-		hph_dly_mask = 1;
-		hph_lut_bypass_reg = WCD934X_CDC_TOP_HPHL_COMP_LUT;
-		hph_comp_ctrl7 = WCD934X_CDC_COMPANDER1_CTL7;
-		break;
-	case INTERP_HPHR:
-		hph_dly_mask = 2;
-		hph_lut_bypass_reg = WCD934X_CDC_TOP_HPHR_COMP_LUT;
-		hph_comp_ctrl7 = WCD934X_CDC_COMPANDER2_CTL7;
-		break;
-	default:
-		break;
-	}
-
-	if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, WCD934X_CDC_CLSH_TEST0,
-				    hph_dly_mask, 0x0);
-		snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x80);
-		if (tavil->hph_mode == CLS_H_ULP)
-			snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x20);
-	}
-
-	if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, WCD934X_CDC_CLSH_TEST0,
-				    hph_dly_mask, hph_dly_mask);
-		snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x00);
-		snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x0);
-	}
-}
-
-static void tavil_codec_hd2_control(struct tavil_priv *priv,
-				    u16 interp_idx, int event)
-{
-	u16 hd2_scale_reg;
-	u16 hd2_enable_reg = 0;
-	struct snd_soc_codec *codec = priv->codec;
-
-	if (TAVIL_IS_1_1(priv->wcd9xxx))
-		return;
-
-	switch (interp_idx) {
-	case INTERP_HPHL:
-		hd2_scale_reg = WCD934X_CDC_RX1_RX_PATH_SEC3;
-		hd2_enable_reg = WCD934X_CDC_RX1_RX_PATH_CFG0;
-		break;
-	case INTERP_HPHR:
-		hd2_scale_reg = WCD934X_CDC_RX2_RX_PATH_SEC3;
-		hd2_enable_reg = WCD934X_CDC_RX2_RX_PATH_CFG0;
-		break;
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x14);
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
-	}
-
-	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
-		snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
-	}
-}
-
-static int tavil_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
-					    int event, int gain_reg)
-{
-	int comp_gain_offset, val;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	switch (tavil->swr.spkr_mode) {
-	/* Compander gain in SPKR_MODE1 case is 12 dB */
-	case WCD934X_SPKR_MODE_1:
-		comp_gain_offset = -12;
-		break;
-	/* Default case compander gain is 15 dB */
-	default:
-		comp_gain_offset = -15;
-		break;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		/* Apply ear spkr gain only if compander is enabled */
-		if (tavil->comp_enabled[COMPANDER_7] &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL) &&
-		    (tavil->ear_spkr_gain != 0)) {
-			/* For example, val is -8(-12+5-1) for 4dB of gain */
-			val = comp_gain_offset + tavil->ear_spkr_gain - 1;
-			snd_soc_write(codec, gain_reg, val);
-
-			dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
-				__func__, val);
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/*
-		 * Reset RX7 volume to 0 dB if compander is enabled and
-		 * ear_spkr_gain is non-zero.
-		 */
-		if (tavil->comp_enabled[COMPANDER_7] &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL) &&
-		    (tavil->ear_spkr_gain != 0)) {
-			snd_soc_write(codec, gain_reg, 0x0);
-
-			dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
-				__func__);
-		}
-		break;
-	}
-
-	return 0;
-}
-
-static int tavil_config_compander(struct snd_soc_codec *codec, int interp_n,
-				  int event)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int comp;
-	u16 comp_ctl0_reg, rx_path_cfg0_reg;
-
-	/* EAR does not have compander */
-	if (!interp_n)
-		return 0;
-
-	comp = interp_n - 1;
-	dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
-		__func__, event, comp + 1, tavil->comp_enabled[comp]);
-
-	if (!tavil->comp_enabled[comp])
-		return 0;
-
-	comp_ctl0_reg = WCD934X_CDC_COMPANDER1_CTL0 + (comp * 8);
-	rx_path_cfg0_reg = WCD934X_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
-
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		/* Enable Compander Clock */
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
-		snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
-	}
-
-	return 0;
-}
-
-static void tavil_codec_idle_detect_control(struct snd_soc_codec *codec,
-					    int interp, int event)
-{
-	int reg = 0, mask, val;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	if (!tavil->idle_det_cfg.hph_idle_detect_en)
-		return;
-
-	if (interp == INTERP_HPHL) {
-		reg = WCD934X_CDC_RX_IDLE_DET_PATH_CTL;
-		mask = 0x01;
-		val = 0x01;
-	}
-	if (interp == INTERP_HPHR) {
-		reg = WCD934X_CDC_RX_IDLE_DET_PATH_CTL;
-		mask = 0x02;
-		val = 0x02;
-	}
-
-	if (reg && SND_SOC_DAPM_EVENT_ON(event))
-		snd_soc_update_bits(codec, reg, mask, val);
-
-	if (reg && SND_SOC_DAPM_EVENT_OFF(event)) {
-		snd_soc_update_bits(codec, reg, mask, 0x00);
-		tavil->idle_det_cfg.hph_idle_thr = 0;
-		snd_soc_write(codec, WCD934X_CDC_RX_IDLE_DET_CFG3, 0x0);
-	}
-}
-
-/**
- * tavil_codec_enable_interp_clk - Enable main path Interpolator
- * clock.
- *
- * @codec:    Codec instance
- * @event:    Indicates speaker path gain offset value
- * @intp_idx: Interpolator index
- * Returns number of main clock users
- */
-int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
-				  int event, int interp_idx)
-{
-	struct tavil_priv *tavil;
-	u16 main_reg;
-
-	if (!codec) {
-		pr_err("%s: codec is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	tavil  = snd_soc_codec_get_drvdata(codec);
-	main_reg = WCD934X_CDC_RX0_RX_PATH_CTL + (interp_idx * 20);
-
-	if (SND_SOC_DAPM_EVENT_ON(event)) {
-		if (tavil->main_clk_users[interp_idx] == 0) {
-			/* Main path PGA mute enable */
-			snd_soc_update_bits(codec, main_reg, 0x10, 0x10);
-			/* Clk enable */
-			snd_soc_update_bits(codec, main_reg, 0x20, 0x20);
-			tavil_codec_idle_detect_control(codec, interp_idx,
-							event);
-			tavil_codec_hd2_control(tavil, interp_idx, event);
-			tavil_codec_hphdelay_lutbypass(codec, interp_idx,
-						       event);
-			tavil_config_compander(codec, interp_idx, event);
-		}
-		tavil->main_clk_users[interp_idx]++;
-	}
-
-	if (SND_SOC_DAPM_EVENT_OFF(event)) {
-		tavil->main_clk_users[interp_idx]--;
-		if (tavil->main_clk_users[interp_idx] <= 0) {
-			tavil->main_clk_users[interp_idx] = 0;
-			tavil_config_compander(codec, interp_idx, event);
-			tavil_codec_hphdelay_lutbypass(codec, interp_idx,
-						       event);
-			tavil_codec_hd2_control(tavil, interp_idx, event);
-			tavil_codec_idle_detect_control(codec, interp_idx,
-							event);
-			/* Clk Disable */
-			snd_soc_update_bits(codec, main_reg, 0x20, 0x00);
-			/* Reset enable and disable */
-			snd_soc_update_bits(codec, main_reg, 0x40, 0x40);
-			snd_soc_update_bits(codec, main_reg, 0x40, 0x00);
-			/* Reset rate to 48K*/
-			snd_soc_update_bits(codec, main_reg, 0x0F, 0x04);
-		}
-	}
-
-	dev_dbg(codec->dev, "%s event %d main_clk_users %d\n",
-		__func__,  event, tavil->main_clk_users[interp_idx]);
-
-	return tavil->main_clk_users[interp_idx];
-}
-EXPORT_SYMBOL(tavil_codec_enable_interp_clk);
-
-static int tavil_anc_out_switch_cb(struct snd_soc_dapm_widget *w,
-				   struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	tavil_codec_enable_interp_clk(codec, event, w->shift);
-
-	return 0;
-}
-static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec,
-					   int interp, int path_type)
-{
-	int port_id[4] = { 0, 0, 0, 0 };
-	int *port_ptr, num_ports;
-	int bit_width = 0, i;
-	int mux_reg, mux_reg_val;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int dai_id, idle_thr;
-
-	if ((interp != INTERP_HPHL) && (interp != INTERP_HPHR))
-		return 0;
-
-	if (!tavil->idle_det_cfg.hph_idle_detect_en)
-		return 0;
-
-	port_ptr = &port_id[0];
-	num_ports = 0;
-
-	/*
-	 * Read interpolator MUX input registers and find
-	 * which slimbus port is connected and store the port
-	 * numbers in port_id array.
-	 */
-	if (path_type == INTERP_MIX_PATH) {
-		mux_reg = WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1 +
-			  2 * (interp - 1);
-		mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f;
-
-		if ((mux_reg_val >= INTn_2_INP_SEL_RX0) &&
-		   (mux_reg_val < INTn_2_INP_SEL_PROXIMITY)) {
-			*port_ptr++ = mux_reg_val +
-				      WCD934X_RX_PORT_START_NUMBER - 1;
-			num_ports++;
-		}
-	}
-
-	if (path_type == INTERP_MAIN_PATH) {
-		mux_reg = WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0 +
-			  2 * (interp - 1);
-		mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f;
-		i = WCD934X_INTERP_MUX_NUM_INPUTS;
-
-		while (i) {
-			if ((mux_reg_val >= INTn_1_INP_SEL_RX0) &&
-			    (mux_reg_val <= INTn_1_INP_SEL_RX7)) {
-				*port_ptr++ = mux_reg_val +
-					WCD934X_RX_PORT_START_NUMBER -
-					INTn_1_INP_SEL_RX0;
-				num_ports++;
-			}
-			mux_reg_val = (snd_soc_read(codec, mux_reg) &
-						    0xf0) >> 4;
-			mux_reg += 1;
-			i--;
-		}
-	}
-
-	dev_dbg(codec->dev, "%s: num_ports: %d, ports[%d %d %d %d]\n",
-		__func__, num_ports, port_id[0], port_id[1],
-		port_id[2], port_id[3]);
-
-	i = 0;
-	while (num_ports) {
-		dai_id = tavil_find_playback_dai_id_for_port(port_id[i++],
-							     tavil);
-
-		if ((dai_id >= 0) && (dai_id < NUM_CODEC_DAIS)) {
-			dev_dbg(codec->dev, "%s: dai_id: %d bit_width: %d\n",
-				__func__, dai_id,
-				tavil->dai[dai_id].bit_width);
-
-			if (tavil->dai[dai_id].bit_width > bit_width)
-				bit_width = tavil->dai[dai_id].bit_width;
-		}
-
-		num_ports--;
-	}
-
-	switch (bit_width) {
-	case 16:
-		idle_thr = 0xff; /* F16 */
-		break;
-	case 24:
-	case 32:
-		idle_thr = 0x03; /* F22 */
-		break;
-	default:
-		idle_thr = 0x00;
-		break;
-	}
-
-	dev_dbg(codec->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n",
-		__func__, idle_thr, tavil->idle_det_cfg.hph_idle_thr);
-
-	if ((tavil->idle_det_cfg.hph_idle_thr == 0) ||
-	    (idle_thr < tavil->idle_det_cfg.hph_idle_thr)) {
-		snd_soc_write(codec, WCD934X_CDC_RX_IDLE_DET_CFG3, idle_thr);
-		tavil->idle_det_cfg.hph_idle_thr = idle_thr;
-	}
-
-	return 0;
-}
-
-static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
-				       struct snd_kcontrol *kcontrol,
-				       int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u16 gain_reg, mix_reg;
-	int offset_val = 0;
-	int val = 0;
-
-	if (w->shift >= WCD934X_NUM_INTERPOLATORS ||
-	    w->shift == INTERP_LO3_NA || w->shift == INTERP_LO4_NA) {
-		dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n",
-			__func__, w->shift, w->name);
-		return -EINVAL;
-	};
-
-	gain_reg = WCD934X_CDC_RX0_RX_VOL_MIX_CTL +
-					(w->shift * WCD934X_RX_PATH_CTL_OFFSET);
-	mix_reg = WCD934X_CDC_RX0_RX_PATH_MIX_CTL +
-					(w->shift * WCD934X_RX_PATH_CTL_OFFSET);
-
-	if (w->shift == INTERP_SPKR1 ||  w->shift == INTERP_SPKR2)
-		__tavil_codec_enable_swr(w, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil_codec_set_idle_detect_thr(codec, w->shift,
-						INTERP_MIX_PATH);
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-		/* Clk enable */
-		snd_soc_update_bits(codec, mix_reg, 0x20, 0x20);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if ((tavil->swr.spkr_gain_offset ==
-		     WCD934X_RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tavil->comp_enabled[COMPANDER_7] ||
-		     tavil->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL ||
-		     gain_reg == WCD934X_CDC_RX8_RX_VOL_MIX_CTL)) {
-			snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			offset_val = -2;
-		}
-		val = snd_soc_read(codec, gain_reg);
-		val += offset_val;
-		snd_soc_write(codec, gain_reg, val);
-		tavil_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		/* Clk Disable */
-		snd_soc_update_bits(codec, mix_reg, 0x20, 0x00);
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-		/* Reset enable and disable */
-		snd_soc_update_bits(codec, mix_reg, 0x40, 0x40);
-		snd_soc_update_bits(codec, mix_reg, 0x40, 0x00);
-
-		if ((tavil->swr.spkr_gain_offset ==
-		     WCD934X_RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tavil->comp_enabled[COMPANDER_7] ||
-		     tavil->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL ||
-		     gain_reg == WCD934X_CDC_RX8_RX_VOL_MIX_CTL)) {
-			snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			offset_val = 2;
-			val = snd_soc_read(codec, gain_reg);
-			val += offset_val;
-			snd_soc_write(codec, gain_reg, val);
-		}
-		tavil_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	};
-	dev_dbg(codec->dev, "%s event %d name %s\n", __func__, event, w->name);
-
-	return 0;
-}
-
-/**
- * tavil_get_dsd_config - Get pointer to dsd config structure
- *
- * @codec: pointer to snd_soc_codec structure
- *
- * Returns pointer to tavil_dsd_config structure
- */
-struct tavil_dsd_config *tavil_get_dsd_config(struct snd_soc_codec *codec)
-{
-	struct tavil_priv *tavil;
-
-	if (!codec)
-		return NULL;
-
-	tavil = snd_soc_codec_get_drvdata(codec);
-
-	if (!tavil)
-		return NULL;
-
-	return tavil->dsd_config;
-}
-EXPORT_SYMBOL(tavil_get_dsd_config);
-
-static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w,
-					struct snd_kcontrol *kcontrol,
-					int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u16 gain_reg;
-	u16 reg;
-	int val;
-	int offset_val = 0;
-
-	dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
-
-	if (w->shift >= WCD934X_NUM_INTERPOLATORS ||
-	    w->shift == INTERP_LO3_NA || w->shift == INTERP_LO4_NA) {
-		dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n",
-			__func__, w->shift, w->name);
-		return -EINVAL;
-	};
-
-	reg = WCD934X_CDC_RX0_RX_PATH_CTL + (w->shift *
-					     WCD934X_RX_PATH_CTL_OFFSET);
-	gain_reg = WCD934X_CDC_RX0_RX_VOL_CTL + (w->shift *
-						 WCD934X_RX_PATH_CTL_OFFSET);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil_codec_set_idle_detect_thr(codec, w->shift,
-						INTERP_MAIN_PATH);
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* apply gain after int clk is enabled */
-		if ((tavil->swr.spkr_gain_offset ==
-					WCD934X_RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tavil->comp_enabled[COMPANDER_7] ||
-		     tavil->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD934X_CDC_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x01);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x01);
-			offset_val = -2;
-		}
-		val = snd_soc_read(codec, gain_reg);
-		val += offset_val;
-		snd_soc_write(codec, gain_reg, val);
-		tavil_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-
-		if ((tavil->swr.spkr_gain_offset ==
-					WCD934X_RX_GAIN_OFFSET_M1P5_DB) &&
-		    (tavil->comp_enabled[COMPANDER_7] ||
-		     tavil->comp_enabled[COMPANDER_8]) &&
-		    (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL ||
-		     gain_reg == WCD934X_CDC_RX8_RX_VOL_CTL)) {
-			snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX7_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1,
-					    0x01, 0x00);
-			snd_soc_update_bits(codec,
-					    WCD934X_CDC_RX8_RX_PATH_MIX_SEC0,
-					    0x01, 0x00);
-			offset_val = 2;
-			val = snd_soc_read(codec, gain_reg);
-			val += offset_val;
-			snd_soc_write(codec, gain_reg, val);
-		}
-		tavil_codec_config_ear_spkr_gain(codec, event, gain_reg);
-		break;
-	};
-
-	return 0;
-}
-
-static int tavil_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
-				    struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU: /* fall through */
-	case SND_SOC_DAPM_PRE_PMD:
-		if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
-		} else {
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
-			snd_soc_write(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
-			snd_soc_read(codec,
-				WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
-		}
-		break;
-	}
-	return 0;
-}
-
-static int tavil_codec_find_amic_input(struct snd_soc_codec *codec,
-				       int adc_mux_n)
-{
-	u16 mask, shift, adc_mux_in_reg;
-	u16 amic_mux_sel_reg;
-	bool is_amic;
-
-	if (adc_mux_n < 0 || adc_mux_n > WCD934X_MAX_VALID_ADC_MUX ||
-	    adc_mux_n == WCD934X_INVALID_ADC_MUX)
-		return 0;
-
-	if (adc_mux_n < 3) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
-				 adc_mux_n;
-		mask = 0x03;
-		shift = 0;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
-				   2 * adc_mux_n;
-	} else if (adc_mux_n < 4) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1;
-		mask = 0x03;
-		shift = 0;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
-				   2 * adc_mux_n;
-	} else if (adc_mux_n < 7) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
-				 (adc_mux_n - 4);
-		mask = 0x0C;
-		shift = 2;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				   adc_mux_n - 4;
-	} else if (adc_mux_n < 8) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1;
-		mask = 0x0C;
-		shift = 2;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				   adc_mux_n - 4;
-	} else if (adc_mux_n < 12) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
-				 ((adc_mux_n == 8) ? (adc_mux_n - 8) :
-				  (adc_mux_n - 9));
-		mask = 0x30;
-		shift = 4;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				   adc_mux_n - 4;
-	} else if (adc_mux_n < 13) {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1;
-		mask = 0x30;
-		shift = 4;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				   adc_mux_n - 4;
-	} else {
-		adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1;
-		mask = 0xC0;
-		shift = 6;
-		amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-				   adc_mux_n - 4;
-	}
-
-	is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
-		    == 1);
-	if (!is_amic)
-		return 0;
-
-	return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
-}
-
-static void tavil_codec_set_tx_hold(struct snd_soc_codec *codec,
-				    u16 amic_reg, bool set)
-{
-	u8 mask = 0x20;
-	u8 val;
-
-	if (amic_reg == WCD934X_ANA_AMIC1 ||
-	    amic_reg == WCD934X_ANA_AMIC3)
-		mask = 0x40;
-
-	val = set ? mask : 0x00;
-
-	switch (amic_reg) {
-	case WCD934X_ANA_AMIC1:
-	case WCD934X_ANA_AMIC2:
-		snd_soc_update_bits(codec, WCD934X_ANA_AMIC2, mask, val);
-		break;
-	case WCD934X_ANA_AMIC3:
-	case WCD934X_ANA_AMIC4:
-		snd_soc_update_bits(codec, WCD934X_ANA_AMIC4, mask, val);
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: invalid amic: %d\n",
-			__func__, amic_reg);
-		break;
-	}
-}
-
-static int tavil_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	int adc_mux_n = w->shift;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int amic_n;
-
-	dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		amic_n = tavil_codec_find_amic_input(codec, adc_mux_n);
-		if (amic_n) {
-			/*
-			 * Prevent ANC Rx pop by leaving Tx FE in HOLD
-			 * state until PA is up. Track AMIC being used
-			 * so we can release the HOLD later.
-			 */
-			set_bit(ANC_MIC_AMIC1 + amic_n - 1,
-				&tavil->status_mask);
-		}
-		break;
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-static u16 tavil_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
-{
-	u16 pwr_level_reg = 0;
-
-	switch (amic) {
-	case 1:
-	case 2:
-		pwr_level_reg = WCD934X_ANA_AMIC1;
-		break;
-
-	case 3:
-	case 4:
-		pwr_level_reg = WCD934X_ANA_AMIC3;
-		break;
-	default:
-		dev_dbg(codec->dev, "%s: invalid amic: %d\n",
-			__func__, amic);
-		break;
-	}
-
-	return pwr_level_reg;
-}
-
-#define  TX_HPF_CUT_OFF_FREQ_MASK 0x60
-#define  CF_MIN_3DB_4HZ     0x0
-#define  CF_MIN_3DB_75HZ    0x1
-#define  CF_MIN_3DB_150HZ   0x2
-
-static void tavil_tx_hpf_corner_freq_callback(struct work_struct *work)
-{
-	struct delayed_work *hpf_delayed_work;
-	struct hpf_work *hpf_work;
-	struct tavil_priv *tavil;
-	struct snd_soc_codec *codec;
-	u16 dec_cfg_reg, amic_reg, go_bit_reg;
-	u8 hpf_cut_off_freq;
-	int amic_n;
-
-	hpf_delayed_work = to_delayed_work(work);
-	hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
-	tavil = hpf_work->tavil;
-	codec = tavil->codec;
-	hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
-
-	dec_cfg_reg = WCD934X_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
-	go_bit_reg = dec_cfg_reg + 7;
-
-	dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
-		__func__, hpf_work->decimator, hpf_cut_off_freq);
-
-	amic_n = tavil_codec_find_amic_input(codec, hpf_work->decimator);
-	if (amic_n) {
-		amic_reg = WCD934X_ANA_AMIC1 + amic_n - 1;
-		tavil_codec_set_tx_hold(codec, amic_reg, false);
-	}
-	snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
-			    hpf_cut_off_freq << 5);
-	snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x02);
-	/* Minimum 1 clk cycle delay is required as per HW spec */
-	usleep_range(1000, 1010);
-	snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x00);
-}
-
-static void tavil_tx_mute_update_callback(struct work_struct *work)
-{
-	struct tx_mute_work *tx_mute_dwork;
-	struct tavil_priv *tavil;
-	struct delayed_work *delayed_work;
-	struct snd_soc_codec *codec;
-	u16 tx_vol_ctl_reg, hpf_gate_reg;
-
-	delayed_work = to_delayed_work(work);
-	tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
-	tavil = tx_mute_dwork->tavil;
-	codec = tavil->codec;
-
-	tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL +
-			 16 * tx_mute_dwork->decimator;
-	hpf_gate_reg = WCD934X_CDC_TX0_TX_PATH_SEC2 +
-		       16 * tx_mute_dwork->decimator;
-	snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
-}
-
-static int tavil_codec_enable_rx_path_clk(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	u16 sidetone_reg;
-
-	dev_dbg(codec->dev, "%s %d %d\n", __func__, event, w->shift);
-	sidetone_reg = WCD934X_CDC_RX0_RX_PATH_CFG1 + 0x14*(w->shift);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		if (!strcmp(w->name, "RX INT7 MIX2 INP"))
-			__tavil_codec_enable_swr(w, event);
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-		snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x00);
-		tavil_codec_enable_interp_clk(codec, event, w->shift);
-		if (!strcmp(w->name, "RX INT7 MIX2 INP"))
-			__tavil_codec_enable_swr(w, event);
-		break;
-	default:
-		break;
-	};
-	return 0;
-}
-
-static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	unsigned int decimator;
-	char *dec_adc_mux_name = NULL;
-	char *widget_name = NULL;
-	char *wname;
-	int ret = 0, amic_n;
-	u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
-	u16 tx_gain_ctl_reg;
-	char *dec;
-	u8 hpf_cut_off_freq;
-
-	dev_dbg(codec->dev, "%s %d\n", __func__, event);
-
-	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
-	if (!widget_name)
-		return -ENOMEM;
-
-	wname = widget_name;
-	dec_adc_mux_name = strsep(&widget_name, " ");
-	if (!dec_adc_mux_name) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, w->name);
-		ret =  -EINVAL;
-		goto out;
-	}
-	dec_adc_mux_name = widget_name;
-
-	dec = strpbrk(dec_adc_mux_name, "012345678");
-	if (!dec) {
-		dev_err(codec->dev, "%s: decimator index not found\n",
-			__func__);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	ret = kstrtouint(dec, 10, &decimator);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Invalid decimator = %s\n",
-			__func__, wname);
-		ret =  -EINVAL;
-		goto out;
-	}
-
-	dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
-			w->name, decimator);
-
-	tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator;
-	hpf_gate_reg = WCD934X_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
-	dec_cfg_reg = WCD934X_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
-	tx_gain_ctl_reg = WCD934X_CDC_TX0_TX_VOL_CTL + 16 * decimator;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		amic_n = tavil_codec_find_amic_input(codec, decimator);
-		if (amic_n)
-			pwr_level_reg = tavil_codec_get_amic_pwlvl_reg(codec,
-								       amic_n);
-
-		if (pwr_level_reg) {
-			switch ((snd_soc_read(codec, pwr_level_reg) &
-					      WCD934X_AMIC_PWR_LVL_MASK) >>
-					      WCD934X_AMIC_PWR_LVL_SHIFT) {
-			case WCD934X_AMIC_PWR_LEVEL_LP:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD934X_DEC_PWR_LVL_MASK,
-						    WCD934X_DEC_PWR_LVL_LP);
-				break;
-
-			case WCD934X_AMIC_PWR_LEVEL_HP:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD934X_DEC_PWR_LVL_MASK,
-						    WCD934X_DEC_PWR_LVL_HP);
-				break;
-			case WCD934X_AMIC_PWR_LEVEL_DEFAULT:
-			default:
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    WCD934X_DEC_PWR_LVL_MASK,
-						    WCD934X_DEC_PWR_LVL_DF);
-				break;
-			}
-		}
-		/* Enable TX PGA Mute */
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
-				   TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
-
-		tavil->tx_hpf_work[decimator].hpf_cut_off_freq =
-							hpf_cut_off_freq;
-		if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
-			snd_soc_update_bits(codec, dec_cfg_reg,
-					    TX_HPF_CUT_OFF_FREQ_MASK,
-					    CF_MIN_3DB_150HZ << 5);
-			snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02);
-			/*
-			 * Minimum 1 clk cycle delay is required as per
-			 * HW spec.
-			 */
-			usleep_range(1000, 1010);
-			snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00);
-		}
-		/* schedule work queue to Remove Mute */
-		schedule_delayed_work(&tavil->tx_mute_dwork[decimator].dwork,
-				      msecs_to_jiffies(tx_unmute_delay));
-		if (tavil->tx_hpf_work[decimator].hpf_cut_off_freq !=
-							CF_MIN_3DB_150HZ)
-			schedule_delayed_work(
-					&tavil->tx_hpf_work[decimator].dwork,
-					msecs_to_jiffies(300));
-		/* apply gain after decimator is enabled */
-		snd_soc_write(codec, tx_gain_ctl_reg,
-			      snd_soc_read(codec, tx_gain_ctl_reg));
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		hpf_cut_off_freq =
-			tavil->tx_hpf_work[decimator].hpf_cut_off_freq;
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
-		if (cancel_delayed_work_sync(
-		    &tavil->tx_hpf_work[decimator].dwork)) {
-			if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
-				snd_soc_update_bits(codec, dec_cfg_reg,
-						    TX_HPF_CUT_OFF_FREQ_MASK,
-						    hpf_cut_off_freq << 5);
-				snd_soc_update_bits(codec, hpf_gate_reg,
-						    0x02, 0x02);
-				/*
-				 * Minimum 1 clk cycle delay is required as per
-				 * HW spec.
-				 */
-				usleep_range(1000, 1010);
-				snd_soc_update_bits(codec, hpf_gate_reg,
-						    0x02, 0x00);
-			}
-		}
-		cancel_delayed_work_sync(
-				&tavil->tx_mute_dwork[decimator].dwork);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
-		snd_soc_update_bits(codec, dec_cfg_reg,
-				    WCD934X_DEC_PWR_LVL_MASK,
-				    WCD934X_DEC_PWR_LVL_DF);
-		break;
-	};
-out:
-	kfree(wname);
-	return ret;
-}
-
-static u32 tavil_get_dmic_sample_rate(struct snd_soc_codec *codec,
-				      unsigned int dmic,
-				      struct wcd9xxx_pdata *pdata)
-{
-	u8 tx_stream_fs;
-	u8 adc_mux_index = 0, adc_mux_sel = 0;
-	bool dec_found = false;
-	u16 adc_mux_ctl_reg, tx_fs_reg;
-	u32 dmic_fs;
-
-	while (dec_found == 0 && adc_mux_index < WCD934X_MAX_VALID_ADC_MUX) {
-		if (adc_mux_index < 4) {
-			adc_mux_ctl_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
-						(adc_mux_index * 2);
-		} else if (adc_mux_index < WCD934X_INVALID_ADC_MUX) {
-			adc_mux_ctl_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
-						adc_mux_index - 4;
-		} else if (adc_mux_index == WCD934X_INVALID_ADC_MUX) {
-			++adc_mux_index;
-			continue;
-		}
-		adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
-					0xF8) >> 3) - 1;
-
-		if (adc_mux_sel == dmic) {
-			dec_found = true;
-			break;
-		}
-
-		++adc_mux_index;
-	}
-
-	if (dec_found && adc_mux_index <= 8) {
-		tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
-		tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
-		if (tx_stream_fs <= 4)  {
-			if (pdata->dmic_sample_rate <=
-					WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ)
-				dmic_fs = pdata->dmic_sample_rate;
-			else
-				dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ;
-		} else
-			dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
-	} else {
-		dmic_fs = pdata->dmic_sample_rate;
-	}
-
-	return dmic_fs;
-}
-
-static u8 tavil_get_dmic_clk_val(struct snd_soc_codec *codec,
-				 u32 mclk_rate, u32 dmic_clk_rate)
-{
-	u32 div_factor;
-	u8 dmic_ctl_val;
-
-	dev_dbg(codec->dev,
-		"%s: mclk_rate = %d, dmic_sample_rate = %d\n",
-		__func__, mclk_rate, dmic_clk_rate);
-
-	/* Default value to return in case of error */
-	if (mclk_rate == WCD934X_MCLK_CLK_9P6MHZ)
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_2;
-	else
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_3;
-
-	if (dmic_clk_rate == 0) {
-		dev_err(codec->dev,
-			"%s: dmic_sample_rate cannot be 0\n",
-			__func__);
-		goto done;
-	}
-
-	div_factor = mclk_rate / dmic_clk_rate;
-	switch (div_factor) {
-	case 2:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_2;
-		break;
-	case 3:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_3;
-		break;
-	case 4:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_4;
-		break;
-	case 6:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_6;
-		break;
-	case 8:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_8;
-		break;
-	case 16:
-		dmic_ctl_val = WCD934X_DMIC_CLK_DIV_16;
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
-			__func__, div_factor, mclk_rate, dmic_clk_rate);
-		break;
-	}
-
-done:
-	return dmic_ctl_val;
-}
-
-static int tavil_codec_enable_adc(struct snd_soc_dapm_widget *w,
-				  struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		tavil_codec_set_tx_hold(codec, w->reg, true);
-		break;
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-static int tavil_codec_enable_dmic(struct snd_soc_dapm_widget *w,
-				   struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
-	u8  dmic_clk_en = 0x01;
-	u16 dmic_clk_reg;
-	s32 *dmic_clk_cnt;
-	u8 dmic_rate_val, dmic_rate_shift = 1;
-	unsigned int dmic;
-	u32 dmic_sample_rate;
-	int ret;
-	char *wname;
-
-	wname = strpbrk(w->name, "012345");
-	if (!wname) {
-		dev_err(codec->dev, "%s: widget not found\n", __func__);
-		return -EINVAL;
-	}
-
-	ret = kstrtouint(wname, 10, &dmic);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	switch (dmic) {
-	case 0:
-	case 1:
-		dmic_clk_cnt = &(tavil->dmic_0_1_clk_cnt);
-		dmic_clk_reg = WCD934X_CPE_SS_DMIC0_CTL;
-		break;
-	case 2:
-	case 3:
-		dmic_clk_cnt = &(tavil->dmic_2_3_clk_cnt);
-		dmic_clk_reg = WCD934X_CPE_SS_DMIC1_CTL;
-		break;
-	case 4:
-	case 5:
-		dmic_clk_cnt = &(tavil->dmic_4_5_clk_cnt);
-		dmic_clk_reg = WCD934X_CPE_SS_DMIC2_CTL;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
-			__func__);
-		return -EINVAL;
-	};
-	dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
-			__func__, event,  dmic, *dmic_clk_cnt);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		dmic_sample_rate = tavil_get_dmic_sample_rate(codec, dmic,
-							      pdata);
-		dmic_rate_val =
-			tavil_get_dmic_clk_val(codec,
-					       pdata->mclk_rate,
-					       dmic_sample_rate);
-
-		(*dmic_clk_cnt)++;
-		if (*dmic_clk_cnt == 1) {
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					    0x07 << dmic_rate_shift,
-					    dmic_rate_val << dmic_rate_shift);
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					    dmic_clk_en, dmic_clk_en);
-		}
-
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		dmic_rate_val =
-			tavil_get_dmic_clk_val(codec,
-					       pdata->mclk_rate,
-					       pdata->mad_dmic_sample_rate);
-		(*dmic_clk_cnt)--;
-		if (*dmic_clk_cnt  == 0) {
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					    dmic_clk_en, 0);
-			snd_soc_update_bits(codec, dmic_clk_reg,
-					    0x07 << dmic_rate_shift,
-					    dmic_rate_val << dmic_rate_shift);
-		}
-		break;
-	};
-
-	return 0;
-}
-
-/*
- * tavil_mbhc_micb_adjust_voltage: adjust specific micbias voltage
- * @codec: handle to snd_soc_codec *
- * @req_volt: micbias voltage to be set
- * @micb_num: micbias to be set, e.g. micbias1 or micbias2
- *
- * return 0 if adjustment is success or error code in case of failure
- */
-int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
-				   int req_volt, int micb_num)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int cur_vout_ctl, req_vout_ctl;
-	int micb_reg, micb_val, micb_en;
-	int ret = 0;
-
-	switch (micb_num) {
-	case MIC_BIAS_1:
-		micb_reg = WCD934X_ANA_MICB1;
-		break;
-	case MIC_BIAS_2:
-		micb_reg = WCD934X_ANA_MICB2;
-		break;
-	case MIC_BIAS_3:
-		micb_reg = WCD934X_ANA_MICB3;
-		break;
-	case MIC_BIAS_4:
-		micb_reg = WCD934X_ANA_MICB4;
-		break;
-	default:
-		return -EINVAL;
-	}
-	mutex_lock(&tavil->micb_lock);
-
-	/*
-	 * If requested micbias voltage is same as current micbias
-	 * voltage, then just return. Otherwise, adjust voltage as
-	 * per requested value. If micbias is already enabled, then
-	 * to avoid slow micbias ramp-up or down enable pull-up
-	 * momentarily, change the micbias value and then re-enable
-	 * micbias.
-	 */
-	micb_val = snd_soc_read(codec, micb_reg);
-	micb_en = (micb_val & 0xC0) >> 6;
-	cur_vout_ctl = micb_val & 0x3F;
-
-	req_vout_ctl = wcd934x_get_micb_vout_ctl_val(req_volt);
-	if (req_vout_ctl < 0) {
-		ret = -EINVAL;
-		goto exit;
-	}
-	if (cur_vout_ctl == req_vout_ctl) {
-		ret = 0;
-		goto exit;
-	}
-
-	dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
-		 __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
-		 req_volt, micb_en);
-
-	if (micb_en == 0x1)
-		snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-
-	snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
-
-	if (micb_en == 0x1) {
-		snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
-		/*
-		 * Add 2ms delay as per HW requirement after enabling
-		 * micbias
-		 */
-		usleep_range(2000, 2100);
-	}
-exit:
-	mutex_unlock(&tavil->micb_lock);
-	return ret;
-}
-EXPORT_SYMBOL(tavil_mbhc_micb_adjust_voltage);
-
-/*
- * tavil_micbias_control: enable/disable micbias
- * @codec: handle to snd_soc_codec *
- * @micb_num: micbias to be enabled/disabled, e.g. micbias1 or micbias2
- * @req: control requested, enable/disable or pullup enable/disable
- * @is_dapm: triggered by dapm or not
- *
- * return 0 if control is success or error code in case of failure
- */
-int tavil_micbias_control(struct snd_soc_codec *codec,
-			  int micb_num, int req, bool is_dapm)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int micb_index = micb_num - 1;
-	u16 micb_reg;
-	int pre_off_event = 0, post_off_event = 0;
-	int post_on_event = 0, post_dapm_off = 0;
-	int post_dapm_on = 0;
-
-	if ((micb_index < 0) || (micb_index > TAVIL_MAX_MICBIAS - 1)) {
-		dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
-			__func__, micb_index);
-		return -EINVAL;
-	}
-
-	switch (micb_num) {
-	case MIC_BIAS_1:
-		micb_reg = WCD934X_ANA_MICB1;
-		break;
-	case MIC_BIAS_2:
-		micb_reg = WCD934X_ANA_MICB2;
-		pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
-		post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
-		post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
-		post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
-		post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
-		break;
-	case MIC_BIAS_3:
-		micb_reg = WCD934X_ANA_MICB3;
-		break;
-	case MIC_BIAS_4:
-		micb_reg = WCD934X_ANA_MICB4;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
-			__func__, micb_num);
-		return -EINVAL;
-	}
-	mutex_lock(&tavil->micb_lock);
-
-	switch (req) {
-	case MICB_PULLUP_ENABLE:
-		tavil->pullup_ref[micb_index]++;
-		if ((tavil->pullup_ref[micb_index] == 1) &&
-		    (tavil->micb_ref[micb_index] == 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-		break;
-	case MICB_PULLUP_DISABLE:
-		if (tavil->pullup_ref[micb_index] > 0)
-			tavil->pullup_ref[micb_index]--;
-		if ((tavil->pullup_ref[micb_index] == 0) &&
-		    (tavil->micb_ref[micb_index] == 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
-		break;
-	case MICB_ENABLE:
-		tavil->micb_ref[micb_index]++;
-		if (tavil->micb_ref[micb_index] == 1) {
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
-			if (post_on_event && tavil->mbhc)
-				blocking_notifier_call_chain(
-						&tavil->mbhc->notifier,
-						post_on_event,
-						&tavil->mbhc->wcd_mbhc);
-		}
-		if (is_dapm && post_dapm_on && tavil->mbhc)
-			blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					post_dapm_on, &tavil->mbhc->wcd_mbhc);
-		break;
-	case MICB_DISABLE:
-		if (tavil->micb_ref[micb_index] > 0)
-			tavil->micb_ref[micb_index]--;
-		if ((tavil->micb_ref[micb_index] == 0) &&
-		    (tavil->pullup_ref[micb_index] > 0))
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
-		else if ((tavil->micb_ref[micb_index] == 0) &&
-			 (tavil->pullup_ref[micb_index] == 0)) {
-			if (pre_off_event && tavil->mbhc)
-				blocking_notifier_call_chain(
-						&tavil->mbhc->notifier,
-						pre_off_event,
-						&tavil->mbhc->wcd_mbhc);
-			snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
-			if (post_off_event && tavil->mbhc)
-				blocking_notifier_call_chain(
-						&tavil->mbhc->notifier,
-						post_off_event,
-						&tavil->mbhc->wcd_mbhc);
-		}
-		if (is_dapm && post_dapm_off && tavil->mbhc)
-			blocking_notifier_call_chain(&tavil->mbhc->notifier,
-					post_dapm_off, &tavil->mbhc->wcd_mbhc);
-		break;
-	};
-
-	dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
-		__func__, micb_num, tavil->micb_ref[micb_index],
-		tavil->pullup_ref[micb_index]);
-
-	mutex_unlock(&tavil->micb_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(tavil_micbias_control);
-
-static int __tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w,
-					int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int micb_num;
-
-	dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
-		__func__, w->name, event);
-
-	if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
-		micb_num = MIC_BIAS_1;
-	else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
-		micb_num = MIC_BIAS_2;
-	else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
-		micb_num = MIC_BIAS_3;
-	else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
-		micb_num = MIC_BIAS_4;
-	else
-		return -EINVAL;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		/*
-		 * MIC BIAS can also be requested by MBHC,
-		 * so use ref count to handle micbias pullup
-		 * and enable requests
-		 */
-		tavil_micbias_control(codec, micb_num, MICB_ENABLE, true);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		/* wait for cnp time */
-		usleep_range(1000, 1100);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tavil_micbias_control(codec, micb_num, MICB_DISABLE, true);
-		break;
-	};
-
-	return 0;
-}
-
-/*
- * tavil_codec_enable_standalone_micbias - enable micbias standalone
- * @codec: pointer to codec instance
- * @micb_num: number of micbias to be enabled
- * @enable: true to enable micbias or false to disable
- *
- * This function is used to enable micbias (1, 2, 3 or 4) during
- * standalone independent of whether TX use-case is running or not
- *
- * Return: error code in case of failure or 0 for success
- */
-int tavil_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
-					  int micb_num,
-					  bool enable)
-{
-	const char * const micb_names[] = {
-		DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
-		DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
-	};
-	int micb_index = micb_num - 1;
-	int rc;
-
-	if (!codec) {
-		pr_err("%s: Codec memory is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if ((micb_index < 0) || (micb_index > TAVIL_MAX_MICBIAS - 1)) {
-		dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
-			__func__, micb_index);
-		return -EINVAL;
-	}
-
-	if (enable)
-		rc = snd_soc_dapm_force_enable_pin(
-						snd_soc_codec_get_dapm(codec),
-						micb_names[micb_index]);
-	else
-		rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
-					      micb_names[micb_index]);
-
-	if (!rc)
-		snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
-	else
-		dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
-			__func__, micb_num, (enable ? "enable" : "disable"));
-
-	return rc;
-}
-EXPORT_SYMBOL(tavil_codec_enable_standalone_micbias);
-
-static int tavil_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
-					    struct snd_kcontrol *kcontrol,
-					    int event)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wcd_resmgr_enable_master_bias(tavil->resmgr);
-		tavil_cdc_mclk_enable(codec, true);
-		ret = __tavil_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
-		/* Wait for 1ms for better cnp */
-		usleep_range(1000, 1100);
-		tavil_cdc_mclk_enable(codec, false);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = __tavil_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
-		wcd_resmgr_disable_master_bias(tavil->resmgr);
-		break;
-	}
-
-	return ret;
-}
-
-static int tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w,
-				      struct snd_kcontrol *kcontrol, int event)
-{
-	return __tavil_codec_enable_micbias(w, event);
-}
-
-
-static const struct reg_sequence tavil_hph_reset_tbl[] = {
-	{ WCD934X_HPH_CNP_EN, 0x80 },
-	{ WCD934X_HPH_CNP_WG_CTL, 0x9A },
-	{ WCD934X_HPH_CNP_WG_TIME, 0x14 },
-	{ WCD934X_HPH_OCP_CTL, 0x28 },
-	{ WCD934X_HPH_AUTO_CHOP, 0x16 },
-	{ WCD934X_HPH_CHOP_CTL, 0x83 },
-	{ WCD934X_HPH_PA_CTL1, 0x46 },
-	{ WCD934X_HPH_PA_CTL2, 0x50 },
-	{ WCD934X_HPH_L_EN, 0x80 },
-	{ WCD934X_HPH_L_TEST, 0xE0 },
-	{ WCD934X_HPH_L_ATEST, 0x50 },
-	{ WCD934X_HPH_R_EN, 0x80 },
-	{ WCD934X_HPH_R_TEST, 0xE0 },
-	{ WCD934X_HPH_R_ATEST, 0x54 },
-	{ WCD934X_HPH_RDAC_CLK_CTL1, 0x99 },
-	{ WCD934X_HPH_RDAC_CLK_CTL2, 0x9B },
-	{ WCD934X_HPH_RDAC_LDO_CTL, 0x33 },
-	{ WCD934X_HPH_RDAC_CHOP_CLK_LP_CTL, 0x00 },
-	{ WCD934X_HPH_REFBUFF_UHQA_CTL, 0xA8 },
-};
-
-static const struct reg_sequence tavil_hph_reset_tbl_1_0[] = {
-	{ WCD934X_HPH_REFBUFF_LP_CTL, 0x0A },
-	{ WCD934X_HPH_L_DAC_CTL, 0x00 },
-	{ WCD934X_HPH_R_DAC_CTL, 0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH2, 0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH3, 0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL, 0xA0 },
-	{ WCD934X_HPH_NEW_INT_RDAC_VREF_CTL, 0x10 },
-	{ WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL, 0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_MISC1, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC1, 0x22 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC2, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC, 0x00 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1, 0xFE },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER2, 0x2 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER3, 0x4e},
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER4, 0x54 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC2, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC3, 0x00 },
-};
-
-static const struct reg_sequence tavil_hph_reset_tbl_1_1[] = {
-	{ WCD934X_HPH_REFBUFF_LP_CTL, 0x0E },
-	{ WCD934X_HPH_L_DAC_CTL, 0x00 },
-	{ WCD934X_HPH_R_DAC_CTL, 0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH2, 0x00 },
-	{ WCD934X_HPH_NEW_ANA_HPH3, 0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0x40 },
-	{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL, 0x81 },
-	{ WCD934X_HPH_NEW_INT_RDAC_VREF_CTL, 0x10 },
-	{ WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL, 0x00 },
-	{ WCD934X_HPH_NEW_INT_RDAC_MISC1, 0x81 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC1, 0x22 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC2, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC, 0x00 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1, 0xFE },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER2, 0x2 },
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER3, 0x4e},
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER4, 0x54 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC2, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_RDAC_MISC3, 0x00 },
-};
-
-static const struct tavil_reg_mask_val tavil_pa_disable[] = {
-	{ WCD934X_CDC_RX1_RX_PATH_CTL, 0x30, 0x10 }, /* RX1 mute enable */
-	{ WCD934X_CDC_RX2_RX_PATH_CTL, 0x30, 0x10 }, /* RX2 mute enable */
-	{ WCD934X_HPH_CNP_WG_CTL, 0x80, 0x00 }, /* GM3 boost disable */
-	{ WCD934X_ANA_HPH, 0x80, 0x00 }, /* HPHL PA disable */
-	{ WCD934X_ANA_HPH, 0x40, 0x00 }, /* HPHR PA disable */
-	{ WCD934X_ANA_HPH, 0x20, 0x00 }, /* HPHL REF dsable */
-	{ WCD934X_ANA_HPH, 0x10, 0x00 }, /* HPHR REF disable */
-};
-
-static const struct tavil_reg_mask_val tavil_ocp_en_seq[] = {
-	{ WCD934X_RX_OCP_CTL, 0x0F, 0x02 }, /* OCP number of attempts is 2 */
-	{ WCD934X_HPH_OCP_CTL, 0xFA, 0x3A }, /* OCP current limit */
-	{ WCD934X_HPH_L_TEST, 0x01, 0x01 }, /* Enable HPHL OCP */
-	{ WCD934X_HPH_R_TEST, 0x01, 0x01 }, /* Enable HPHR OCP */
-};
-
-static const struct tavil_reg_mask_val tavil_ocp_en_seq_1[] = {
-	{ WCD934X_RX_OCP_CTL, 0x0F, 0x02 }, /* OCP number of attempts is 2 */
-	{ WCD934X_HPH_OCP_CTL, 0xFA, 0x3A }, /* OCP current limit */
-};
-
-/* LO-HIFI */
-static const struct tavil_reg_mask_val tavil_pre_pa_en_lohifi[] = {
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1, 0x02, 0x00 },
-	{ WCD934X_FLYBACK_VNEG_CTRL_4, 0xf0, 0x80 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC2, 0x20, 0x20 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0xf0, 0x40 },
-	{ WCD934X_HPH_CNP_WG_CTL, 0x80, 0x00 },
-	{ WCD934X_RX_BIAS_HPH_LOWPOWER, 0xf0, 0xc0 },
-	{ WCD934X_HPH_PA_CTL1, 0x0e, 0x02 },
-	{ WCD934X_HPH_REFBUFF_LP_CTL, 0x06, 0x06 },
-};
-
-static const struct tavil_reg_mask_val tavil_pre_pa_en[] = {
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1, 0x02, 0x00 },
-	{ WCD934X_HPH_NEW_INT_PA_MISC2, 0x20, 0x0 },
-	{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0xf0, 0x40 },
-	{ WCD934X_HPH_CNP_WG_CTL, 0x80, 0x00 },
-	{ WCD934X_RX_BIAS_HPH_LOWPOWER, 0xf0, 0x80 },
-	{ WCD934X_HPH_PA_CTL1, 0x0e, 0x06 },
-	{ WCD934X_HPH_REFBUFF_LP_CTL, 0x06, 0x06 },
-};
-
-static const struct tavil_reg_mask_val tavil_post_pa_en[] = {
-	{ WCD934X_HPH_L_TEST, 0x01, 0x01 }, /* Enable HPHL OCP */
-	{ WCD934X_HPH_R_TEST, 0x01, 0x01 }, /* Enable HPHR OCP */
-	{ WCD934X_CDC_RX1_RX_PATH_CTL, 0x30, 0x20 }, /* RX1 mute disable */
-	{ WCD934X_CDC_RX2_RX_PATH_CTL, 0x30, 0x20 }, /* RX2 mute disable */
-	{ WCD934X_HPH_CNP_WG_CTL, 0x80, 0x80 }, /* GM3 boost enable */
-	{ WCD934X_HPH_NEW_INT_HPH_TIMER1, 0x02, 0x02 },
-};
-
-static void tavil_codec_hph_reg_range_read(struct regmap *map, u8 *buf)
-{
-	regmap_bulk_read(map, WCD934X_HPH_CNP_EN, buf, TAVIL_HPH_REG_RANGE_1);
-	regmap_bulk_read(map, WCD934X_HPH_NEW_ANA_HPH2,
-			 buf + TAVIL_HPH_REG_RANGE_1, TAVIL_HPH_REG_RANGE_2);
-	regmap_bulk_read(map, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
-			 buf + TAVIL_HPH_REG_RANGE_1 + TAVIL_HPH_REG_RANGE_2,
-			 TAVIL_HPH_REG_RANGE_3);
-}
-
-static void tavil_codec_hph_reg_recover(struct tavil_priv *tavil,
-					struct regmap *map, int pa_status)
-{
-	int i;
-	unsigned int reg;
-
-	blocking_notifier_call_chain(&tavil->mbhc->notifier,
-				     WCD_EVENT_OCP_OFF,
-				     &tavil->mbhc->wcd_mbhc);
-
-	if (pa_status & 0xC0)
-		goto pa_en_restore;
-
-	dev_dbg(tavil->dev, "%s: HPH PA in disable state (0x%x)\n",
-		__func__, pa_status);
-
-	regmap_write_bits(map, WCD934X_CDC_RX1_RX_PATH_CTL, 0x10, 0x10);
-	regmap_write_bits(map, WCD934X_CDC_RX2_RX_PATH_CTL, 0x10, 0x10);
-	regmap_write_bits(map, WCD934X_ANA_HPH, 0xC0, 0x00);
-	regmap_write_bits(map, WCD934X_ANA_HPH, 0x30, 0x00);
-	regmap_write_bits(map, WCD934X_CDC_RX1_RX_PATH_CTL, 0x10, 0x00);
-	regmap_write_bits(map, WCD934X_CDC_RX2_RX_PATH_CTL, 0x10, 0x00);
-
-	/* Restore to HW defaults */
-	regmap_multi_reg_write(map, tavil_hph_reset_tbl,
-			       ARRAY_SIZE(tavil_hph_reset_tbl));
-	if (TAVIL_IS_1_1(tavil->wcd9xxx))
-		regmap_multi_reg_write(map, tavil_hph_reset_tbl_1_1,
-				ARRAY_SIZE(tavil_hph_reset_tbl_1_1));
-	if (TAVIL_IS_1_0(tavil->wcd9xxx))
-		regmap_multi_reg_write(map, tavil_hph_reset_tbl_1_0,
-				ARRAY_SIZE(tavil_hph_reset_tbl_1_0));
-
-	for (i = 0; i < ARRAY_SIZE(tavil_ocp_en_seq); i++)
-		regmap_write_bits(map, tavil_ocp_en_seq[i].reg,
-				  tavil_ocp_en_seq[i].mask,
-				  tavil_ocp_en_seq[i].val);
-	goto end;
-
-
-pa_en_restore:
-	dev_dbg(tavil->dev, "%s: HPH PA in enable state (0x%x)\n",
-		__func__, pa_status);
-
-	/* Disable PA and other registers before restoring */
-	for (i = 0; i < ARRAY_SIZE(tavil_pa_disable); i++) {
-		if (TAVIL_IS_1_1(tavil->wcd9xxx) &&
-		    (tavil_pa_disable[i].reg == WCD934X_HPH_CNP_WG_CTL))
-			continue;
-		regmap_write_bits(map, tavil_pa_disable[i].reg,
-				  tavil_pa_disable[i].mask,
-				  tavil_pa_disable[i].val);
-	}
-
-	regmap_multi_reg_write(map, tavil_hph_reset_tbl,
-			       ARRAY_SIZE(tavil_hph_reset_tbl));
-	if (TAVIL_IS_1_1(tavil->wcd9xxx))
-		regmap_multi_reg_write(map, tavil_hph_reset_tbl_1_1,
-				ARRAY_SIZE(tavil_hph_reset_tbl_1_1));
-	if (TAVIL_IS_1_0(tavil->wcd9xxx))
-		regmap_multi_reg_write(map, tavil_hph_reset_tbl_1_0,
-				ARRAY_SIZE(tavil_hph_reset_tbl_1_0));
-
-	for (i = 0; i < ARRAY_SIZE(tavil_ocp_en_seq_1); i++)
-		regmap_write_bits(map, tavil_ocp_en_seq_1[i].reg,
-				  tavil_ocp_en_seq_1[i].mask,
-				  tavil_ocp_en_seq_1[i].val);
-
-	if (tavil->hph_mode == CLS_H_LOHIFI) {
-		for (i = 0; i < ARRAY_SIZE(tavil_pre_pa_en_lohifi); i++) {
-			reg = tavil_pre_pa_en_lohifi[i].reg;
-			if ((TAVIL_IS_1_1(tavil->wcd9xxx)) &&
-			    ((reg == WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL) ||
-			     (reg == WCD934X_HPH_CNP_WG_CTL) ||
-			     (reg == WCD934X_HPH_REFBUFF_LP_CTL)))
-				continue;
-			regmap_write_bits(map,
-					  tavil_pre_pa_en_lohifi[i].reg,
-					  tavil_pre_pa_en_lohifi[i].mask,
-					  tavil_pre_pa_en_lohifi[i].val);
-		}
-	} else {
-		for (i = 0; i < ARRAY_SIZE(tavil_pre_pa_en); i++) {
-			reg = tavil_pre_pa_en[i].reg;
-			if ((TAVIL_IS_1_1(tavil->wcd9xxx)) &&
-			    ((reg == WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL) ||
-			     (reg == WCD934X_HPH_CNP_WG_CTL) ||
-			     (reg == WCD934X_HPH_REFBUFF_LP_CTL)))
-				continue;
-			regmap_write_bits(map, tavil_pre_pa_en[i].reg,
-					  tavil_pre_pa_en[i].mask,
-					  tavil_pre_pa_en[i].val);
-		}
-	}
-
-	if (TAVIL_IS_1_1(tavil->wcd9xxx)) {
-		regmap_write(map, WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x84);
-		regmap_write(map, WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x84);
-	}
-
-	regmap_write_bits(map, WCD934X_ANA_HPH, 0x0C, pa_status & 0x0C);
-	regmap_write_bits(map, WCD934X_ANA_HPH, 0x30, 0x30);
-	/* wait for 100usec after HPH DAC is enabled */
-	usleep_range(100, 110);
-	regmap_write(map, WCD934X_ANA_HPH, pa_status);
-	/* Sleep for 7msec after PA is enabled */
-	usleep_range(7000, 7100);
-
-	for (i = 0; i < ARRAY_SIZE(tavil_post_pa_en); i++) {
-		if ((TAVIL_IS_1_1(tavil->wcd9xxx)) &&
-		    (tavil_post_pa_en[i].reg == WCD934X_HPH_CNP_WG_CTL))
-			continue;
-		regmap_write_bits(map, tavil_post_pa_en[i].reg,
-				  tavil_post_pa_en[i].mask,
-				  tavil_post_pa_en[i].val);
-	}
-
-end:
-	tavil->mbhc->is_hph_recover = true;
-	blocking_notifier_call_chain(
-			&tavil->mbhc->notifier,
-			WCD_EVENT_OCP_ON,
-			&tavil->mbhc->wcd_mbhc);
-}
-
-static int tavil_codec_reset_hph_registers(struct snd_soc_dapm_widget *w,
-					   struct snd_kcontrol *kcontrol,
-					   int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	u8 cache_val[TAVIL_HPH_TOTAL_REG];
-	u8 hw_val[TAVIL_HPH_TOTAL_REG];
-	int pa_status;
-	int ret;
-
-	dev_dbg(wcd9xxx->dev, "%s: event: %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		memset(cache_val, 0, TAVIL_HPH_TOTAL_REG);
-		memset(hw_val, 0, TAVIL_HPH_TOTAL_REG);
-
-		regmap_read(wcd9xxx->regmap, WCD934X_ANA_HPH, &pa_status);
-
-		tavil_codec_hph_reg_range_read(wcd9xxx->regmap, cache_val);
-
-		/* Read register values from HW directly */
-		regcache_cache_bypass(wcd9xxx->regmap, true);
-		tavil_codec_hph_reg_range_read(wcd9xxx->regmap, hw_val);
-		regcache_cache_bypass(wcd9xxx->regmap, false);
-
-		/* compare both the registers to know if there is corruption */
-		ret = memcmp(cache_val, hw_val, TAVIL_HPH_TOTAL_REG);
-
-		/* If both the values are same, it means no corruption */
-		if (ret) {
-			dev_dbg(codec->dev, "%s: cache and hw reg are not same\n",
-				__func__);
-			tavil_codec_hph_reg_recover(tavil, wcd9xxx->regmap,
-						    pa_status);
-		} else {
-			dev_dbg(codec->dev, "%s: cache and hw reg are same\n",
-				__func__);
-			tavil->mbhc->is_hph_recover = false;
-		}
-		break;
-	default:
-		break;
-	};
-
-	return 0;
-}
-
-static int tavil_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	/* IIR filter band registers are at integer multiples of 16 */
-	u16 iir_reg = WCD934X_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
-
-	ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
-					    (1 << band_idx)) != 0;
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
-		iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int tavil_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	bool iir_band_en_status;
-	int value = ucontrol->value.integer.value[0];
-	u16 iir_reg = WCD934X_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
-
-	/* Mask first 5 bits, 6-8 are reserved */
-	snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
-			    (value << band_idx));
-
-	iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
-			      (1 << band_idx)) != 0);
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
-		iir_idx, band_idx, iir_band_en_status);
-	return 0;
-}
-
-static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
-				   int iir_idx, int band_idx,
-				   int coeff_idx)
-{
-	uint32_t value = 0;
-
-	/* Address does not automatically update if reading */
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t)) & 0x7F);
-
-	value |= snd_soc_read(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
-
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 1) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-			       (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				16 * iir_idx)) << 8);
-
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 2) & 0x7F);
-
-	value |= (snd_soc_read(codec,
-			       (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				16 * iir_idx)) << 16);
-
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		((band_idx * BAND_MAX + coeff_idx)
-		* sizeof(uint32_t) + 3) & 0x7F);
-
-	/* Mask bits top 2 bits since they are reserved */
-	value |= ((snd_soc_read(codec,
-				(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
-				 16 * iir_idx)) & 0x3F) << 24);
-
-	return value;
-}
-
-static int tavil_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	ucontrol->value.integer.value[0] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0);
-	ucontrol->value.integer.value[1] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1);
-	ucontrol->value.integer.value[2] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2);
-	ucontrol->value.integer.value[3] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3);
-	ucontrol->value.integer.value[4] =
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4);
-
-	dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[0],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[1],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[2],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[3],
-		__func__, iir_idx, band_idx,
-		(uint32_t)ucontrol->value.integer.value[4]);
-	return 0;
-}
-
-static void set_iir_band_coeff(struct snd_soc_codec *codec,
-			       int iir_idx, int band_idx,
-			       uint32_t value)
-{
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value & 0xFF));
-
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 8) & 0xFF);
-
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 16) & 0xFF);
-
-	/* Mask top 2 bits, 7-8 are reserved */
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
-		(value >> 24) & 0x3F);
-}
-
-static int tavil_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int iir_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-	int coeff_idx;
-
-	/*
-	 * Mask top bit it is reserved
-	 * Updates addr automatically for each B2 write
-	 */
-	snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
-
-	/* Store the coefficients in sidetone coeff array */
-	for (coeff_idx = 0; coeff_idx < WCD934X_CDC_SIDETONE_IIR_COEFF_MAX;
-		coeff_idx++) {
-		tavil->sidetone_coeff_array[iir_idx][band_idx][coeff_idx] =
-			ucontrol->value.integer.value[coeff_idx];
-		set_iir_band_coeff(codec, iir_idx, band_idx,
-			tavil->sidetone_coeff_array[iir_idx][band_idx]
-							[coeff_idx]);
-	}
-
-	pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
-		"%s: IIR #%d band #%d b1 = 0x%x\n"
-		"%s: IIR #%d band #%d b2 = 0x%x\n"
-		"%s: IIR #%d band #%d a1 = 0x%x\n"
-		"%s: IIR #%d band #%d a2 = 0x%x\n",
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 0),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 1),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 2),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 3),
-		__func__, iir_idx, band_idx,
-		get_iir_band_coeff(codec, iir_idx, band_idx, 4));
-	return 0;
-}
-
-static void tavil_restore_iir_coeff(struct tavil_priv *tavil, int iir_idx)
-{
-	int band_idx = 0, coeff_idx = 0;
-	struct snd_soc_codec *codec = tavil->codec;
-
-	/*
-	 * snd_soc_write call crashes at rmmod if there is no machine
-	 * driver and hence no codec pointer available
-	 */
-	if (!codec)
-		return;
-
-	for (band_idx = 0; band_idx < BAND_MAX; band_idx++) {
-		snd_soc_write(codec,
-		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
-		(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
-
-		for (coeff_idx = 0;
-			coeff_idx < WCD934X_CDC_SIDETONE_IIR_COEFF_MAX;
-			coeff_idx++) {
-			set_iir_band_coeff(codec, iir_idx, band_idx,
-				tavil->sidetone_coeff_array[iir_idx][band_idx]
-								[coeff_idx]);
-		}
-	}
-}
-
-static int tavil_compander_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil->comp_enabled[comp];
-	return 0;
-}
-
-static int tavil_compander_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int comp = ((struct soc_multi_mixer_control *)
-		    kcontrol->private_value)->shift;
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n",
-		 __func__, comp + 1, tavil->comp_enabled[comp], value);
-	tavil->comp_enabled[comp] = value;
-
-	/* Any specific register configuration for compander */
-	switch (comp) {
-	case COMPANDER_1:
-		/* Set Gain Source Select based on compander enable/disable */
-		snd_soc_update_bits(codec, WCD934X_HPH_L_EN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_2:
-		snd_soc_update_bits(codec, WCD934X_HPH_R_EN, 0x20,
-				(value ? 0x00:0x20));
-		break;
-	case COMPANDER_3:
-	case COMPANDER_4:
-	case COMPANDER_7:
-	case COMPANDER_8:
-		break;
-	default:
-		/*
-		 * if compander is not enabled for any interpolator,
-		 * it does not cause any audio failure, so do not
-		 * return error in this case, but just print a log
-		 */
-		dev_warn(codec->dev, "%s: unknown compander: %d\n",
-			__func__, comp);
-	};
-	return 0;
-}
-
-static int tavil_hph_asrc_mode_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int index = -EINVAL;
-
-	if (!strcmp(kcontrol->id.name, "ASRC0 Output Mode"))
-		index = ASRC0;
-	if (!strcmp(kcontrol->id.name, "ASRC1 Output Mode"))
-		index = ASRC1;
-
-	if (tavil && (index >= 0) && (index < ASRC_MAX))
-		tavil->asrc_output_mode[index] =
-			ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int tavil_hph_asrc_mode_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int val = 0;
-	int index = -EINVAL;
-
-	if (!strcmp(kcontrol->id.name, "ASRC0 Output Mode"))
-		index = ASRC0;
-	if (!strcmp(kcontrol->id.name, "ASRC1 Output Mode"))
-		index = ASRC1;
-
-	if (tavil && (index >= 0) && (index < ASRC_MAX))
-		val = tavil->asrc_output_mode[index];
-
-	ucontrol->value.integer.value[0] = val;
-
-	return 0;
-}
-
-static int tavil_hph_idle_detect_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int val = 0;
-
-	if (tavil)
-		val = tavil->idle_det_cfg.hph_idle_detect_en;
-
-	ucontrol->value.integer.value[0] = val;
-
-	return 0;
-}
-
-static int tavil_hph_idle_detect_put(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	if (tavil)
-		tavil->idle_det_cfg.hph_idle_detect_en =
-			ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int tavil_dmic_pin_mode_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u16 dmic_pin;
-	u8 reg_val, pinctl_position;
-
-	pinctl_position = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	dmic_pin = pinctl_position & 0x07;
-	reg_val = snd_soc_read(codec,
-			WCD934X_TLMM_DMIC1_CLK_PINCFG + dmic_pin - 1);
-
-	ucontrol->value.integer.value[0] = !!reg_val;
-
-	return 0;
-}
-
-static int tavil_dmic_pin_mode_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u16 ctl_reg, cfg_reg, dmic_pin;
-	u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
-
-	/* 0- high or low; 1- high Z */
-	pinctl_mode = ucontrol->value.integer.value[0];
-	pinctl_position = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	switch (pinctl_position >> 3) {
-	case 0:
-		ctl_reg = WCD934X_TEST_DEBUG_PIN_CTL_OE_0;
-		break;
-	case 1:
-		ctl_reg = WCD934X_TEST_DEBUG_PIN_CTL_OE_1;
-		break;
-	case 2:
-		ctl_reg = WCD934X_TEST_DEBUG_PIN_CTL_OE_2;
-		break;
-	case 3:
-		ctl_reg = WCD934X_TEST_DEBUG_PIN_CTL_OE_3;
-		break;
-	default:
-		dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
-			__func__, pinctl_position);
-		return -EINVAL;
-	}
-
-	ctl_val = ~(pinctl_mode << (pinctl_position & 0x07));
-	mask = 1 << (pinctl_position & 0x07);
-	snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
-
-	dmic_pin = pinctl_position & 0x07;
-	cfg_reg = WCD934X_TLMM_DMIC1_CLK_PINCFG + dmic_pin - 1;
-	if (pinctl_mode) {
-		if (tavil->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
-			cfg_val = 0x6;
-		else
-			cfg_val = 0xD;
-	} else
-		cfg_val = 0;
-	snd_soc_update_bits(codec, cfg_reg, 0x1F, cfg_val);
-
-	dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
-			__func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
-
-	return 0;
-}
-
-static int tavil_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u16 amic_reg = 0;
-
-	if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
-		amic_reg = WCD934X_ANA_AMIC1;
-	if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
-		amic_reg = WCD934X_ANA_AMIC3;
-
-	if (amic_reg)
-		ucontrol->value.integer.value[0] =
-			(snd_soc_read(codec, amic_reg) &
-			 WCD934X_AMIC_PWR_LVL_MASK) >>
-			  WCD934X_AMIC_PWR_LVL_SHIFT;
-	return 0;
-}
-
-static int tavil_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u32 mode_val;
-	u16 amic_reg = 0;
-
-	mode_val = ucontrol->value.enumerated.item[0];
-
-	dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val);
-
-	if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
-		amic_reg = WCD934X_ANA_AMIC1;
-	if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
-		amic_reg = WCD934X_ANA_AMIC3;
-
-	if (amic_reg)
-		snd_soc_update_bits(codec, amic_reg, WCD934X_AMIC_PWR_LVL_MASK,
-				    mode_val << WCD934X_AMIC_PWR_LVL_SHIFT);
-	return 0;
-}
-
-static const char *const tavil_conn_mad_text[] = {
-	"NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "NOTUSED5",
-	"NOTUSED6", "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
-	"DMIC4", "DMIC5", "NOTUSED3", "NOTUSED4"
-};
-
-static const struct soc_enum tavil_conn_mad_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tavil_conn_mad_text),
-			    tavil_conn_mad_text);
-
-static int tavil_mad_input_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	u8 tavil_mad_input;
-
-	tavil_mad_input = snd_soc_read(codec, WCD934X_SOC_MAD_INP_SEL) & 0x0F;
-	ucontrol->value.integer.value[0] = tavil_mad_input;
-
-	dev_dbg(codec->dev, "%s: tavil_mad_input = %s\n", __func__,
-		tavil_conn_mad_text[tavil_mad_input]);
-
-	return 0;
-}
-
-static int tavil_mad_input_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct snd_soc_card *card = codec->component.card;
-	u8 tavil_mad_input;
-	char mad_amic_input_widget[6];
-	const char *mad_input_widget;
-	const char *source_widget = NULL;
-	u32 adc, i, mic_bias_found = 0;
-	int ret = 0;
-	char *mad_input;
-	bool is_adc_input = false;
-
-	tavil_mad_input = ucontrol->value.integer.value[0];
-
-	if (tavil_mad_input >= sizeof(tavil_conn_mad_text)/
-	    sizeof(tavil_conn_mad_text[0])) {
-		dev_err(codec->dev,
-			"%s: tavil_mad_input = %d out of bounds\n",
-			__func__, tavil_mad_input);
-		return -EINVAL;
-	}
-
-	if (strnstr(tavil_conn_mad_text[tavil_mad_input], "NOTUSED",
-				sizeof("NOTUSED"))) {
-		dev_dbg(codec->dev,
-			"%s: Unsupported tavil_mad_input = %s\n",
-			__func__, tavil_conn_mad_text[tavil_mad_input]);
-		/* Make sure the MAD register is updated */
-		snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP,
-				    0x88, 0x00);
-		return -EINVAL;
-	}
-
-	if (strnstr(tavil_conn_mad_text[tavil_mad_input],
-		    "ADC", sizeof("ADC"))) {
-		mad_input = strpbrk(tavil_conn_mad_text[tavil_mad_input],
-				    "1234");
-		if (!mad_input) {
-			dev_err(codec->dev, "%s: Invalid MAD input %s\n",
-				__func__, tavil_conn_mad_text[tavil_mad_input]);
-			return -EINVAL;
-		}
-
-		ret = kstrtouint(mad_input, 10, &adc);
-		if ((ret < 0) || (adc > 4)) {
-			dev_err(codec->dev, "%s: Invalid ADC = %s\n", __func__,
-				tavil_conn_mad_text[tavil_mad_input]);
-			return -EINVAL;
-		}
-
-		/*AMIC4 and AMIC5 share ADC4*/
-		if ((adc == 4) &&
-		    (snd_soc_read(codec, WCD934X_TX_NEW_AMIC_4_5_SEL) & 0x10))
-			adc = 5;
-
-		snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
-
-		mad_input_widget = mad_amic_input_widget;
-		is_adc_input = true;
-	} else {
-		/* DMIC type input widget*/
-		mad_input_widget = tavil_conn_mad_text[tavil_mad_input];
-	}
-
-	dev_dbg(codec->dev,
-		"%s: tavil input widget = %s, adc_input = %s\n", __func__,
-		mad_input_widget, is_adc_input ? "true" : "false");
-
-	for (i = 0; i < card->num_of_dapm_routes; i++) {
-		if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
-			source_widget = card->of_dapm_routes[i].source;
-			if (!source_widget) {
-				dev_err(codec->dev,
-					"%s: invalid source widget\n",
-					__func__);
-				return -EINVAL;
-			}
-
-			if (strnstr(source_widget,
-				"MIC BIAS1", sizeof("MIC BIAS1"))) {
-				mic_bias_found = 1;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS2", sizeof("MIC BIAS2"))) {
-				mic_bias_found = 2;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS3", sizeof("MIC BIAS3"))) {
-				mic_bias_found = 3;
-				break;
-			} else if (strnstr(source_widget,
-				"MIC BIAS4", sizeof("MIC BIAS4"))) {
-				mic_bias_found = 4;
-				break;
-			}
-		}
-	}
-
-	if (!mic_bias_found) {
-		dev_err(codec->dev, "%s: mic bias not found for input %s\n",
-			__func__, mad_input_widget);
-		return -EINVAL;
-	}
-
-	dev_dbg(codec->dev, "%s: mic_bias found = %d\n", __func__,
-		mic_bias_found);
-
-	snd_soc_update_bits(codec, WCD934X_SOC_MAD_INP_SEL,
-			    0x0F, tavil_mad_input);
-	snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP,
-			    0x07, mic_bias_found);
-	/* for all adc inputs, mad should be in micbias mode with BG enabled */
-	if (is_adc_input)
-		snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP,
-				    0x88, 0x88);
-	else
-		snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP,
-				    0x88, 0x00);
-	return 0;
-}
-
-static int tavil_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	ear_pa_gain = snd_soc_read(codec, WCD934X_ANA_EAR);
-
-	ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
-
-	ucontrol->value.integer.value[0] = ear_pa_gain;
-
-	dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
-		ear_pa_gain);
-
-	return 0;
-}
-
-static int tavil_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	u8 ear_pa_gain;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0]  = %ld\n",
-			__func__, ucontrol->value.integer.value[0]);
-
-	ear_pa_gain =  ucontrol->value.integer.value[0] << 4;
-
-	snd_soc_update_bits(codec, WCD934X_ANA_EAR, 0x70, ear_pa_gain);
-	return 0;
-}
-
-static int tavil_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil->ear_spkr_gain;
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int tavil_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	tavil->ear_spkr_gain =  ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: gain = %d\n", __func__, tavil->ear_spkr_gain);
-
-	return 0;
-}
-
-static int tavil_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = tavil->hph_mode;
-	return 0;
-}
-
-static int tavil_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u32 mode_val;
-
-	mode_val = ucontrol->value.enumerated.item[0];
-
-	dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val);
-
-	if (mode_val == 0) {
-		dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H LOHiFi\n",
-			__func__);
-		mode_val = CLS_H_LOHIFI;
-	}
-	tavil->hph_mode = mode_val;
-	return 0;
-}
-
-static const char * const rx_hph_mode_mux_text[] = {
-	"CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI",
-	"CLS_H_ULP", "CLS_AB_HIFI",
-};
-
-static const struct soc_enum rx_hph_mode_mux_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
-			    rx_hph_mode_mux_text);
-
-static const char *const tavil_anc_func_text[] = {"OFF", "ON"};
-static const struct soc_enum tavil_anc_func_enum =
-	SOC_ENUM_SINGLE_EXT(2, tavil_anc_func_text);
-
-static const char *const tavil_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
-static SOC_ENUM_SINGLE_EXT_DECL(tavil_clkmode_enum, tavil_clkmode_text);
-
-/* Cutoff frequency for high pass filter */
-static const char * const cf_text[] = {
-	"CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
-};
-
-static const char * const rx_cf_text[] = {
-	"CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
-	"CF_NEG_3DB_0P48HZ"
-};
-
-static const char * const amic_pwr_lvl_text[] = {
-	"LOW_PWR", "DEFAULT", "HIGH_PERF"
-};
-
-static const char * const hph_idle_detect_text[] = {
-	"OFF", "ON"
-};
-
-static const char * const asrc_mode_text[] = {
-	"INT", "FRAC"
-};
-
-static const char * const tavil_ear_pa_gain_text[] = {
-	"G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
-	"G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
-};
-
-static const char * const tavil_ear_spkr_pa_gain_text[] = {
-	"G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB",
-	"G_4_DB", "G_5_DB", "G_6_DB"
-};
-
-static SOC_ENUM_SINGLE_EXT_DECL(tavil_ear_pa_gain_enum, tavil_ear_pa_gain_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tavil_ear_spkr_pa_gain_enum,
-				tavil_ear_spkr_pa_gain_text);
-static SOC_ENUM_SINGLE_EXT_DECL(amic_pwr_lvl_enum, amic_pwr_lvl_text);
-static SOC_ENUM_SINGLE_EXT_DECL(hph_idle_detect_enum, hph_idle_detect_text);
-static SOC_ENUM_SINGLE_EXT_DECL(asrc_mode_enum, asrc_mode_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec0_enum, WCD934X_CDC_TX0_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec1_enum, WCD934X_CDC_TX1_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec2_enum, WCD934X_CDC_TX2_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec3_enum, WCD934X_CDC_TX3_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec4_enum, WCD934X_CDC_TX4_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec5_enum, WCD934X_CDC_TX5_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec6_enum, WCD934X_CDC_TX6_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec7_enum, WCD934X_CDC_TX7_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_dec8_enum, WCD934X_CDC_TX8_TX_PATH_CFG0, 5,
-							cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int0_1_enum, WCD934X_CDC_RX0_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD934X_CDC_RX0_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int1_1_enum, WCD934X_CDC_RX1_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD934X_CDC_RX1_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int2_1_enum, WCD934X_CDC_RX2_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD934X_CDC_RX2_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int3_1_enum, WCD934X_CDC_RX3_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD934X_CDC_RX3_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int4_1_enum, WCD934X_CDC_RX4_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD934X_CDC_RX4_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int7_1_enum, WCD934X_CDC_RX7_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD934X_CDC_RX7_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int8_1_enum, WCD934X_CDC_RX8_RX_PATH_CFG2, 0,
-							rx_cf_text);
-static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD934X_CDC_RX8_RX_PATH_MIX_CFG, 2,
-							rx_cf_text);
-
-static const struct snd_kcontrol_new tavil_snd_controls[] = {
-	SOC_ENUM_EXT("EAR PA Gain", tavil_ear_pa_gain_enum,
-		tavil_ear_pa_gain_get, tavil_ear_pa_gain_put),
-	SOC_ENUM_EXT("EAR SPKR PA Gain", tavil_ear_spkr_pa_gain_enum,
-		     tavil_ear_spkr_pa_gain_get, tavil_ear_spkr_pa_gain_put),
-	SOC_SINGLE_TLV("HPHL Volume", WCD934X_HPH_L_EN, 0, 20, 1, line_gain),
-	SOC_SINGLE_TLV("HPHR Volume", WCD934X_HPH_R_EN, 0, 20, 1, line_gain),
-	SOC_SINGLE_TLV("LINEOUT1 Volume", WCD934X_DIFF_LO_LO1_COMPANDER,
-		3, 16, 1, line_gain),
-	SOC_SINGLE_TLV("LINEOUT2 Volume", WCD934X_DIFF_LO_LO2_COMPANDER,
-		3, 16, 1, line_gain),
-	SOC_SINGLE_TLV("ADC1 Volume", WCD934X_ANA_AMIC1, 0, 20, 0, analog_gain),
-	SOC_SINGLE_TLV("ADC2 Volume", WCD934X_ANA_AMIC2, 0, 20, 0, analog_gain),
-	SOC_SINGLE_TLV("ADC3 Volume", WCD934X_ANA_AMIC3, 0, 20, 0, analog_gain),
-	SOC_SINGLE_TLV("ADC4 Volume", WCD934X_ANA_AMIC4, 0, 20, 0, analog_gain),
-
-	SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD934X_CDC_RX0_RX_VOL_CTL,
-		0, -84, 40, digital_gain), /* -84dB min - 40dB max */
-	SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD934X_CDC_RX1_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD934X_CDC_RX2_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD934X_CDC_RX3_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD934X_CDC_RX4_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD934X_CDC_RX7_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD934X_CDC_RX8_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
-		WCD934X_CDC_RX0_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
-		WCD934X_CDC_RX1_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
-		WCD934X_CDC_RX2_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
-		WCD934X_CDC_RX3_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
-		WCD934X_CDC_RX4_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
-		WCD934X_CDC_RX7_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
-		WCD934X_CDC_RX8_RX_VOL_MIX_CTL, 0, -84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("DEC0 Volume", WCD934X_CDC_TX0_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC1 Volume", WCD934X_CDC_TX1_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC2 Volume", WCD934X_CDC_TX2_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC3 Volume", WCD934X_CDC_TX3_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC4 Volume", WCD934X_CDC_TX4_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC5 Volume", WCD934X_CDC_TX5_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC6 Volume", WCD934X_CDC_TX6_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC7 Volume", WCD934X_CDC_TX7_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-	SOC_SINGLE_SX_TLV("DEC8 Volume", WCD934X_CDC_TX8_TX_VOL_CTL, 0,
-		-84, 40, digital_gain),
-
-	SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
-		WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
-		WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
-		WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
-		WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
-		WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
-		WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
-		WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84, 40,
-		digital_gain),
-	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
-		WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84, 40,
-		digital_gain),
-
-	SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tavil_get_anc_slot,
-		tavil_put_anc_slot),
-	SOC_ENUM_EXT("ANC Function", tavil_anc_func_enum, tavil_get_anc_func,
-		tavil_put_anc_func),
-
-	SOC_ENUM_EXT("CLK MODE", tavil_clkmode_enum, tavil_get_clkmode,
-		     tavil_put_clkmode),
-
-	SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
-	SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
-	SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
-	SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
-	SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
-	SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
-	SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
-	SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
-	SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
-
-	SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
-	SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
-	SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
-	SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
-	SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
-	SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
-	SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
-	SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
-	SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
-	SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
-	SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
-	SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
-	SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
-	SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
-
-	SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
-		tavil_rx_hph_mode_get, tavil_rx_hph_mode_put),
-
-	SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-	SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
-		tavil_iir_enable_audio_mixer_get,
-		tavil_iir_enable_audio_mixer_put),
-
-	SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-	SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
-		tavil_iir_band_audio_mixer_get, tavil_iir_band_audio_mixer_put),
-
-	SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-	SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-	SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-	SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-	SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-	SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
-		tavil_compander_get, tavil_compander_put),
-
-	SOC_ENUM_EXT("ASRC0 Output Mode", asrc_mode_enum,
-		tavil_hph_asrc_mode_get, tavil_hph_asrc_mode_put),
-	SOC_ENUM_EXT("ASRC1 Output Mode", asrc_mode_enum,
-		tavil_hph_asrc_mode_get, tavil_hph_asrc_mode_put),
-
-	SOC_ENUM_EXT("HPH Idle Detect", hph_idle_detect_enum,
-		tavil_hph_idle_detect_get, tavil_hph_idle_detect_put),
-
-	SOC_ENUM_EXT("MAD Input", tavil_conn_mad_enum,
-		     tavil_mad_input_get, tavil_mad_input_put),
-
-	SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-
-	SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-
-	SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-
-	SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-
-	SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-
-	SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
-		tavil_dmic_pin_mode_get, tavil_dmic_pin_mode_put),
-	SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
-		tavil_amic_pwr_lvl_get, tavil_amic_pwr_lvl_put),
-	SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
-		tavil_amic_pwr_lvl_get, tavil_amic_pwr_lvl_put),
-	SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
-		tavil_amic_pwr_lvl_get, tavil_amic_pwr_lvl_put),
-};
-
-static int tavil_dec_enum_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
-	u16 mic_sel_reg = 0;
-	u8 mic_sel;
-
-	val = ucontrol->value.enumerated.item[0];
-	if (val > e->items - 1)
-		return -EINVAL;
-
-	dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
-		widget->name, val);
-
-	switch (e->reg) {
-	case WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
-		if (e->shift_l == 0)
-			mic_sel_reg = WCD934X_CDC_TX0_TX_PATH_CFG0;
-		else if (e->shift_l == 2)
-			mic_sel_reg = WCD934X_CDC_TX4_TX_PATH_CFG0;
-		else if (e->shift_l == 4)
-			mic_sel_reg = WCD934X_CDC_TX8_TX_PATH_CFG0;
-		break;
-	case WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
-		if (e->shift_l == 0)
-			mic_sel_reg = WCD934X_CDC_TX1_TX_PATH_CFG0;
-		else if (e->shift_l == 2)
-			mic_sel_reg = WCD934X_CDC_TX5_TX_PATH_CFG0;
-		break;
-	case WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
-		if (e->shift_l == 0)
-			mic_sel_reg = WCD934X_CDC_TX2_TX_PATH_CFG0;
-		else if (e->shift_l == 2)
-			mic_sel_reg = WCD934X_CDC_TX6_TX_PATH_CFG0;
-		break;
-	case WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
-		if (e->shift_l == 0)
-			mic_sel_reg = WCD934X_CDC_TX3_TX_PATH_CFG0;
-		else if (e->shift_l == 2)
-			mic_sel_reg = WCD934X_CDC_TX7_TX_PATH_CFG0;
-		break;
-	default:
-		dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
-			__func__, e->reg);
-		return -EINVAL;
-	}
-
-	/* ADC: 0, DMIC: 1 */
-	mic_sel = val ? 0x0 : 0x1;
-	if (mic_sel_reg)
-		snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
-
-	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
-}
-
-static int tavil_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
-	unsigned short look_ahead_dly_reg = WCD934X_CDC_RX0_RX_PATH_CFG0;
-
-	val = ucontrol->value.enumerated.item[0];
-	if (val >= e->items)
-		return -EINVAL;
-
-	dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
-		widget->name, val);
-
-	if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD934X_CDC_RX0_RX_PATH_CFG0;
-	else if (e->reg == WCD934X_CDC_RX1_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD934X_CDC_RX1_RX_PATH_CFG0;
-	else if (e->reg == WCD934X_CDC_RX2_RX_PATH_SEC0)
-		look_ahead_dly_reg = WCD934X_CDC_RX2_RX_PATH_CFG0;
-
-	/* Set Look Ahead Delay */
-	snd_soc_update_bits(codec, look_ahead_dly_reg,
-			    0x08, (val ? 0x08 : 0x00));
-	/* Set DEM INP Select */
-	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
-}
-
-static const char * const rx_int0_7_mix_mux_text[] = {
-	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
-	"RX6", "RX7", "PROXIMITY"
-};
-
-static const char * const rx_int_mix_mux_text[] = {
-	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
-	"RX6", "RX7"
-};
-
-static const char * const rx_prim_mix_text[] = {
-	"ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
-	"RX3", "RX4", "RX5", "RX6", "RX7"
-};
-
-static const char * const rx_sidetone_mix_text[] = {
-	"ZERO", "SRC0", "SRC1", "SRC_SUM"
-};
-
-static const char * const cdc_if_tx0_mux_text[] = {
-	"ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
-};
-static const char * const cdc_if_tx1_mux_text[] = {
-	"ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
-};
-static const char * const cdc_if_tx2_mux_text[] = {
-	"ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
-};
-static const char * const cdc_if_tx3_mux_text[] = {
-	"ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
-};
-static const char * const cdc_if_tx4_mux_text[] = {
-	"ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
-};
-static const char * const cdc_if_tx5_mux_text[] = {
-	"ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
-};
-static const char * const cdc_if_tx6_mux_text[] = {
-	"ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
-};
-static const char * const cdc_if_tx7_mux_text[] = {
-	"ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
-};
-static const char * const cdc_if_tx8_mux_text[] = {
-	"ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
-};
-static const char * const cdc_if_tx9_mux_text[] = {
-	"ZERO", "DEC7", "DEC7_192"
-};
-static const char * const cdc_if_tx10_mux_text[] = {
-	"ZERO", "DEC6", "DEC6_192"
-};
-static const char * const cdc_if_tx11_mux_text[] = {
-	"DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
-};
-static const char * const cdc_if_tx11_inp1_mux_text[] = {
-	"ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
-	"DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
-};
-static const char * const cdc_if_tx13_mux_text[] = {
-	"CDC_DEC_5", "MAD_BRDCST"
-};
-static const char * const cdc_if_tx13_inp1_mux_text[] = {
-	"ZERO", "DEC5", "DEC5_192"
-};
-
-static const char * const iir_inp_mux_text[] = {
-	"ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
-	"DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
-};
-
-static const char * const rx_int_dem_inp_mux_text[] = {
-	"NORMAL_DSM_OUT", "CLSH_DSM_OUT",
-};
-
-static const char * const rx_int0_1_interp_mux_text[] = {
-	"ZERO", "RX INT0_1 MIX1",
-};
-
-static const char * const rx_int1_1_interp_mux_text[] = {
-	"ZERO", "RX INT1_1 MIX1",
-};
-
-static const char * const rx_int2_1_interp_mux_text[] = {
-	"ZERO", "RX INT2_1 MIX1",
-};
-
-static const char * const rx_int3_1_interp_mux_text[] = {
-	"ZERO", "RX INT3_1 MIX1",
-};
-
-static const char * const rx_int4_1_interp_mux_text[] = {
-	"ZERO", "RX INT4_1 MIX1",
-};
-
-static const char * const rx_int7_1_interp_mux_text[] = {
-	"ZERO", "RX INT7_1 MIX1",
-};
-
-static const char * const rx_int8_1_interp_mux_text[] = {
-	"ZERO", "RX INT8_1 MIX1",
-};
-
-static const char * const rx_int0_2_interp_mux_text[] = {
-	"ZERO", "RX INT0_2 MUX",
-};
-
-static const char * const rx_int1_2_interp_mux_text[] = {
-	"ZERO", "RX INT1_2 MUX",
-};
-
-static const char * const rx_int2_2_interp_mux_text[] = {
-	"ZERO", "RX INT2_2 MUX",
-};
-
-static const char * const rx_int3_2_interp_mux_text[] = {
-	"ZERO", "RX INT3_2 MUX",
-};
-
-static const char * const rx_int4_2_interp_mux_text[] = {
-	"ZERO", "RX INT4_2 MUX",
-};
-
-static const char * const rx_int7_2_interp_mux_text[] = {
-	"ZERO", "RX INT7_2 MUX",
-};
-
-static const char * const rx_int8_2_interp_mux_text[] = {
-	"ZERO", "RX INT8_2 MUX",
-};
-
-static const char * const mad_sel_txt[] = {
-	"SPE", "MSM"
-};
-
-static const char * const mad_inp_mux_txt[] = {
-	"MAD", "DEC1"
-};
-
-static const char * const adc_mux_text[] = {
-	"DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
-};
-
-static const char * const dmic_mux_text[] = {
-	"ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5"
-};
-
-static const char * const amic_mux_text[] = {
-	"ZERO", "ADC1", "ADC2", "ADC3", "ADC4"
-};
-
-static const char * const amic4_5_sel_text[] = {
-	"AMIC4", "AMIC5"
-};
-
-static const char * const anc0_fb_mux_text[] = {
-	"ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
-	"ANC_IN_LO1"
-};
-
-static const char * const anc1_fb_mux_text[] = {
-	"ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
-};
-
-static const char * const rx_echo_mux_text[] = {
-	"ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
-	"RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8"
-};
-
-static const char *const slim_rx_mux_text[] = {
-	"ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB"
-};
-
-static const char *const cdc_if_rx0_mux_text[] = {
-	"SLIM RX0", "I2S_0 RX0"
-};
-static const char *const cdc_if_rx1_mux_text[] = {
-	"SLIM RX1", "I2S_0 RX1"
-};
-static const char *const cdc_if_rx2_mux_text[] = {
-	"SLIM RX2", "I2S_0 RX2"
-};
-static const char *const cdc_if_rx3_mux_text[] = {
-	"SLIM RX3", "I2S_0 RX3"
-};
-static const char *const cdc_if_rx4_mux_text[] = {
-	"SLIM RX4", "I2S_0 RX4"
-};
-static const char *const cdc_if_rx5_mux_text[] = {
-	"SLIM RX5", "I2S_0 RX5"
-};
-static const char *const cdc_if_rx6_mux_text[] = {
-	"SLIM RX6", "I2S_0 RX6"
-};
-static const char *const cdc_if_rx7_mux_text[] = {
-	"SLIM RX7", "I2S_0 RX7"
-};
-
-static const char * const asrc0_mux_text[] = {
-	"ZERO", "ASRC_IN_HPHL", "ASRC_IN_LO1",
-};
-
-static const char * const asrc1_mux_text[] = {
-	"ZERO", "ASRC_IN_HPHR", "ASRC_IN_LO2",
-};
-
-static const char * const asrc2_mux_text[] = {
-	"ZERO", "ASRC_IN_SPKR1",
-};
-
-static const char * const asrc3_mux_text[] = {
-	"ZERO", "ASRC_IN_SPKR2",
-};
-
-static const char * const native_mux_text[] = {
-	"OFF", "ON",
-};
-
-static const char *const wdma3_port0_text[] = {
-	"RX_MIX_TX0", "DEC0"
-};
-
-static const char *const wdma3_port1_text[] = {
-	"RX_MIX_TX1", "DEC1"
-};
-
-static const char *const wdma3_port2_text[] = {
-	"RX_MIX_TX2", "DEC2"
-};
-
-static const char *const wdma3_port3_text[] = {
-	"RX_MIX_TX3", "DEC3"
-};
-
-static const char *const wdma3_port4_text[] = {
-	"RX_MIX_TX4", "DEC4"
-};
-
-static const char *const wdma3_port5_text[] = {
-	"RX_MIX_TX5", "DEC5"
-};
-
-static const char *const wdma3_port6_text[] = {
-	"RX_MIX_TX6", "DEC6"
-};
-
-static const char *const wdma3_ch_text[] = {
-	"PORT_0", "PORT_1", "PORT_2", "PORT_3", "PORT_4",
-	"PORT_5", "PORT_6", "PORT_7", "PORT_8",
-};
-
-static const struct snd_kcontrol_new aif4_vi_mixer[] = {
-	SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, WCD934X_TX14, 1, 0,
-			tavil_vi_feed_mixer_get, tavil_vi_feed_mixer_put),
-	SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, WCD934X_TX15, 1, 0,
-			tavil_vi_feed_mixer_get, tavil_vi_feed_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif1_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif2_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif3_cap_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-static const struct snd_kcontrol_new aif4_mad_mixer[] = {
-	SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0,
-			slim_tx_mixer_get, slim_tx_mixer_put),
-};
-
-WCD_DAPM_ENUM_EXT(slim_rx0, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx1, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx2, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx3, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx4, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx5, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx6, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-WCD_DAPM_ENUM_EXT(slim_rx7, SND_SOC_NOPM, 0, slim_rx_mux_text,
-	slim_rx_mux_get, slim_rx_mux_put);
-
-WCD_DAPM_ENUM(cdc_if_rx0, SND_SOC_NOPM, 0, cdc_if_rx0_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx1, SND_SOC_NOPM, 0, cdc_if_rx1_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx2, SND_SOC_NOPM, 0, cdc_if_rx2_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx3, SND_SOC_NOPM, 0, cdc_if_rx3_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx4, SND_SOC_NOPM, 0, cdc_if_rx4_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx5, SND_SOC_NOPM, 0, cdc_if_rx5_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx6, SND_SOC_NOPM, 0, cdc_if_rx6_mux_text);
-WCD_DAPM_ENUM(cdc_if_rx7, SND_SOC_NOPM, 0, cdc_if_rx7_mux_text);
-
-WCD_DAPM_ENUM(rx_int0_2, WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1, 0,
-	rx_int0_7_mix_mux_text);
-WCD_DAPM_ENUM(rx_int1_2, WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1, 0,
-	rx_int_mix_mux_text);
-WCD_DAPM_ENUM(rx_int2_2, WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1, 0,
-	rx_int_mix_mux_text);
-WCD_DAPM_ENUM(rx_int3_2, WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1, 0,
-	rx_int_mix_mux_text);
-WCD_DAPM_ENUM(rx_int4_2, WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1, 0,
-	rx_int_mix_mux_text);
-WCD_DAPM_ENUM(rx_int7_2, WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1, 0,
-	rx_int0_7_mix_mux_text);
-WCD_DAPM_ENUM(rx_int8_2, WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1, 0,
-	rx_int_mix_mux_text);
-
-WCD_DAPM_ENUM(rx_int0_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int0_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int0_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int1_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int1_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int1_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int2_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int2_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int2_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int3_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int3_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int3_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int4_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int4_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int4_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int7_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int7_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int7_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int8_1_mix_inp0, WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0, 0,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int8_1_mix_inp1, WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0, 4,
-	rx_prim_mix_text);
-WCD_DAPM_ENUM(rx_int8_1_mix_inp2, WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1, 4,
-	rx_prim_mix_text);
-
-WCD_DAPM_ENUM(rx_int0_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0,
-	rx_sidetone_mix_text);
-WCD_DAPM_ENUM(rx_int1_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2,
-	rx_sidetone_mix_text);
-WCD_DAPM_ENUM(rx_int2_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4,
-	rx_sidetone_mix_text);
-WCD_DAPM_ENUM(rx_int3_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6,
-	rx_sidetone_mix_text);
-WCD_DAPM_ENUM(rx_int4_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0,
-	rx_sidetone_mix_text);
-WCD_DAPM_ENUM(rx_int7_mix2_inp, WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2,
-	rx_sidetone_mix_text);
-
-WCD_DAPM_ENUM(tx_adc_mux10, WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 4,
-	adc_mux_text);
-WCD_DAPM_ENUM(tx_adc_mux11, WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 4,
-	adc_mux_text);
-WCD_DAPM_ENUM(tx_adc_mux12, WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 4,
-	adc_mux_text);
-WCD_DAPM_ENUM(tx_adc_mux13, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 6,
-	adc_mux_text);
-
-
-WCD_DAPM_ENUM(tx_dmic_mux0, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux1, WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux2, WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux3, WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux4, WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux5, WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux6, WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux7, WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux8, WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux10, WCD934X_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux11, WCD934X_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux12, WCD934X_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3,
-	dmic_mux_text);
-WCD_DAPM_ENUM(tx_dmic_mux13, WCD934X_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3,
-	dmic_mux_text);
-
-
-WCD_DAPM_ENUM(tx_amic_mux0, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux1, WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux2, WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux3, WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux4, WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux5, WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux6, WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux7, WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux8, WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux10, WCD934X_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux11, WCD934X_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux12, WCD934X_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0,
-	amic_mux_text);
-WCD_DAPM_ENUM(tx_amic_mux13, WCD934X_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0,
-	amic_mux_text);
-
-WCD_DAPM_ENUM(tx_amic4_5, WCD934X_TX_NEW_AMIC_4_5_SEL, 7, amic4_5_sel_text);
-
-WCD_DAPM_ENUM(cdc_if_tx0, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 0,
-	cdc_if_tx0_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx1, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 2,
-	cdc_if_tx1_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx2, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 4,
-	cdc_if_tx2_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx3, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 6,
-	cdc_if_tx3_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx4, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 0,
-	cdc_if_tx4_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx5, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 2,
-	cdc_if_tx5_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx6, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 4,
-	cdc_if_tx6_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx7, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 6,
-	cdc_if_tx7_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx8, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 0,
-	cdc_if_tx8_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx9, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 2,
-	cdc_if_tx9_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx10, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 4,
-	cdc_if_tx10_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx11_inp1, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3, 0,
-	cdc_if_tx11_inp1_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx11, WCD934X_DATA_HUB_SB_TX11_INP_CFG, 0,
-	cdc_if_tx11_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx13_inp1, WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3, 4,
-	cdc_if_tx13_inp1_mux_text);
-WCD_DAPM_ENUM(cdc_if_tx13, WCD934X_DATA_HUB_SB_TX13_INP_CFG, 0,
-	cdc_if_tx13_mux_text);
-
-WCD_DAPM_ENUM(rx_mix_tx0, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG0, 0,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx1, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG0, 4,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx2, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG1, 0,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx3, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG1, 4,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx4, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG2, 0,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx5, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG2, 4,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx6, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG3, 0,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx7, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG3, 4,
-	rx_echo_mux_text);
-WCD_DAPM_ENUM(rx_mix_tx8, WCD934X_CDC_RX_INP_MUX_RX_MIX_CFG4, 0,
-	rx_echo_mux_text);
-
-WCD_DAPM_ENUM(iir0_inp0, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir0_inp1, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir0_inp2, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir0_inp3, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir1_inp0, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir1_inp1, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir1_inp2, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0,
-	iir_inp_mux_text);
-WCD_DAPM_ENUM(iir1_inp3, WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0,
-	iir_inp_mux_text);
-
-WCD_DAPM_ENUM(rx_int0_1_interp, SND_SOC_NOPM, 0, rx_int0_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int1_1_interp, SND_SOC_NOPM, 0, rx_int1_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int2_1_interp, SND_SOC_NOPM, 0, rx_int2_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int3_1_interp, SND_SOC_NOPM, 0, rx_int3_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int4_1_interp, SND_SOC_NOPM, 0, rx_int4_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int7_1_interp, SND_SOC_NOPM, 0, rx_int7_1_interp_mux_text);
-WCD_DAPM_ENUM(rx_int8_1_interp, SND_SOC_NOPM, 0, rx_int8_1_interp_mux_text);
-
-WCD_DAPM_ENUM(rx_int0_2_interp, SND_SOC_NOPM, 0, rx_int0_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int1_2_interp, SND_SOC_NOPM, 0, rx_int1_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int2_2_interp, SND_SOC_NOPM, 0, rx_int2_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int3_2_interp, SND_SOC_NOPM, 0, rx_int3_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int4_2_interp, SND_SOC_NOPM, 0, rx_int4_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int7_2_interp, SND_SOC_NOPM, 0, rx_int7_2_interp_mux_text);
-WCD_DAPM_ENUM(rx_int8_2_interp, SND_SOC_NOPM, 0, rx_int8_2_interp_mux_text);
-
-WCD_DAPM_ENUM(mad_sel, WCD934X_CPE_SS_SVA_CFG, 0,
-	mad_sel_txt);
-
-WCD_DAPM_ENUM(mad_inp_mux, WCD934X_CPE_SS_SVA_CFG, 2,
-	mad_inp_mux_txt);
-
-WCD_DAPM_ENUM_EXT(rx_int0_dem_inp, WCD934X_CDC_RX0_RX_PATH_SEC0, 0,
-	rx_int_dem_inp_mux_text, snd_soc_dapm_get_enum_double,
-	tavil_int_dem_inp_mux_put);
-WCD_DAPM_ENUM_EXT(rx_int1_dem_inp, WCD934X_CDC_RX1_RX_PATH_SEC0, 0,
-	rx_int_dem_inp_mux_text, snd_soc_dapm_get_enum_double,
-	tavil_int_dem_inp_mux_put);
-WCD_DAPM_ENUM_EXT(rx_int2_dem_inp, WCD934X_CDC_RX2_RX_PATH_SEC0, 0,
-	rx_int_dem_inp_mux_text, snd_soc_dapm_get_enum_double,
-	tavil_int_dem_inp_mux_put);
-
-WCD_DAPM_ENUM_EXT(tx_adc_mux0, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux1, WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux2, WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux3, WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux4, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 2,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux5, WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 2,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux6, WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 2,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux7, WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 2,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-WCD_DAPM_ENUM_EXT(tx_adc_mux8, WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 4,
-	adc_mux_text, snd_soc_dapm_get_enum_double, tavil_dec_enum_put);
-
-WCD_DAPM_ENUM(asrc0, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0, 0,
-	asrc0_mux_text);
-WCD_DAPM_ENUM(asrc1, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0, 2,
-	asrc1_mux_text);
-WCD_DAPM_ENUM(asrc2, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0, 4,
-	asrc2_mux_text);
-WCD_DAPM_ENUM(asrc3, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0, 6,
-	asrc3_mux_text);
-
-WCD_DAPM_ENUM(int1_1_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int2_1_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int3_1_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int4_1_native, SND_SOC_NOPM, 0, native_mux_text);
-
-WCD_DAPM_ENUM(int1_2_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int2_2_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int3_2_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int4_2_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int7_2_native, SND_SOC_NOPM, 0, native_mux_text);
-WCD_DAPM_ENUM(int8_2_native, SND_SOC_NOPM, 0, native_mux_text);
-
-WCD_DAPM_ENUM(anc0_fb, WCD934X_CDC_RX_INP_MUX_ANC_CFG0, 0, anc0_fb_mux_text);
-WCD_DAPM_ENUM(anc1_fb, WCD934X_CDC_RX_INP_MUX_ANC_CFG0, 3, anc1_fb_mux_text);
-
-
-WCD_DAPM_ENUM(wdma3_port0, WCD934X_DMA_WDMA3_PRT_CFG, 0, wdma3_port0_text);
-WCD_DAPM_ENUM(wdma3_port1, WCD934X_DMA_WDMA3_PRT_CFG, 1, wdma3_port1_text);
-WCD_DAPM_ENUM(wdma3_port2, WCD934X_DMA_WDMA3_PRT_CFG, 2, wdma3_port2_text);
-WCD_DAPM_ENUM(wdma3_port3, WCD934X_DMA_WDMA3_PRT_CFG, 3, wdma3_port3_text);
-WCD_DAPM_ENUM(wdma3_port4, WCD934X_DMA_WDMA3_PRT_CFG, 4, wdma3_port4_text);
-WCD_DAPM_ENUM(wdma3_port5, WCD934X_DMA_WDMA3_PRT_CFG, 5, wdma3_port5_text);
-WCD_DAPM_ENUM(wdma3_port6, WCD934X_DMA_WDMA3_PRT_CFG, 6, wdma3_port6_text);
-
-WCD_DAPM_ENUM(wdma3_ch0, WCD934X_DMA_CH_0_1_CFG_WDMA_3, 0, wdma3_ch_text);
-WCD_DAPM_ENUM(wdma3_ch1, WCD934X_DMA_CH_0_1_CFG_WDMA_3, 4, wdma3_ch_text);
-WCD_DAPM_ENUM(wdma3_ch2, WCD934X_DMA_CH_2_3_CFG_WDMA_3, 0, wdma3_ch_text);
-WCD_DAPM_ENUM(wdma3_ch3, WCD934X_DMA_CH_2_3_CFG_WDMA_3, 4, wdma3_ch_text);
-
-static const struct snd_kcontrol_new anc_ear_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_ear_spkr_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_spkr_pa_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_hphl_pa_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new anc_hphr_pa_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new mad_cpe1_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new mad_cpe2_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new mad_brdcst_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux0_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux1_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux2_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux3_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux4_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux5_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux6_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux7_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new adc_us_mux8_switch =
-	SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static const struct snd_kcontrol_new rx_int1_asrc_switch[] = {
-	SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0),
-};
-
-static const struct snd_kcontrol_new rx_int2_asrc_switch[] = {
-	SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0),
-};
-
-static const struct snd_kcontrol_new rx_int3_asrc_switch[] = {
-	SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0),
-};
-
-static const struct snd_kcontrol_new rx_int4_asrc_switch[] = {
-	SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0),
-};
-
-static const struct snd_kcontrol_new wdma3_onoff_switch =
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
-
-static int tavil_dsd_mixer_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_context *dapm =
-				snd_soc_dapm_kcontrol_dapm(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config;
-	int val;
-
-	val = tavil_dsd_get_current_mixer_value(dsd_conf, mc->shift);
-
-	ucontrol->value.integer.value[0] = ((val < 0) ? 0 : val);
-
-	return 0;
-}
-
-static int tavil_dsd_mixer_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_dapm_kcontrol_dapm(kcontrol);
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
-	struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec);
-	unsigned int wval = ucontrol->value.integer.value[0];
-	struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config;
-
-	if (!dsd_conf)
-		return 0;
-
-	mutex_lock(&tavil_p->codec_mutex);
-
-	tavil_dsd_set_out_select(dsd_conf, mc->shift);
-	tavil_dsd_set_mixer_value(dsd_conf, mc->shift, wval);
-
-	mutex_unlock(&tavil_p->codec_mutex);
-	snd_soc_dapm_mixer_update_power(dapm, kcontrol, wval, NULL);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new hphl_mixer[] = {
-	SOC_SINGLE_EXT("DSD HPHL Switch", SND_SOC_NOPM, INTERP_HPHL, 1, 0,
-			tavil_dsd_mixer_get, tavil_dsd_mixer_put),
-};
-
-static const struct snd_kcontrol_new hphr_mixer[] = {
-	SOC_SINGLE_EXT("DSD HPHR Switch", SND_SOC_NOPM, INTERP_HPHR, 1, 0,
-			tavil_dsd_mixer_get, tavil_dsd_mixer_put),
-};
-
-static const struct snd_kcontrol_new lo1_mixer[] = {
-	SOC_SINGLE_EXT("DSD LO1 Switch", SND_SOC_NOPM, INTERP_LO1, 1, 0,
-			tavil_dsd_mixer_get, tavil_dsd_mixer_put),
-};
-
-static const struct snd_kcontrol_new lo2_mixer[] = {
-	SOC_SINGLE_EXT("DSD LO2 Switch", SND_SOC_NOPM, INTERP_LO2, 1, 0,
-			tavil_dsd_mixer_get, tavil_dsd_mixer_put),
-};
-
-static const struct snd_soc_dapm_widget tavil_dapm_widgets[] = {
-	SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
-		AIF1_PB, 0, tavil_codec_enable_slimrx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
-		AIF2_PB, 0, tavil_codec_enable_slimrx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
-		AIF3_PB, 0, tavil_codec_enable_slimrx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
-		AIF4_PB, 0, tavil_codec_enable_slimrx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	WCD_DAPM_MUX("SLIM RX0 MUX", WCD934X_RX0, slim_rx0),
-	WCD_DAPM_MUX("SLIM RX1 MUX", WCD934X_RX1, slim_rx1),
-	WCD_DAPM_MUX("SLIM RX2 MUX", WCD934X_RX2, slim_rx2),
-	WCD_DAPM_MUX("SLIM RX3 MUX", WCD934X_RX3, slim_rx3),
-	WCD_DAPM_MUX("SLIM RX4 MUX", WCD934X_RX4, slim_rx4),
-	WCD_DAPM_MUX("SLIM RX5 MUX", WCD934X_RX5, slim_rx5),
-	WCD_DAPM_MUX("SLIM RX6 MUX", WCD934X_RX6, slim_rx6),
-	WCD_DAPM_MUX("SLIM RX7 MUX", WCD934X_RX7, slim_rx7),
-
-	SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	WCD_DAPM_MUX("CDC_IF RX0 MUX", WCD934X_RX0, cdc_if_rx0),
-	WCD_DAPM_MUX("CDC_IF RX1 MUX", WCD934X_RX1, cdc_if_rx1),
-	WCD_DAPM_MUX("CDC_IF RX2 MUX", WCD934X_RX2, cdc_if_rx2),
-	WCD_DAPM_MUX("CDC_IF RX3 MUX", WCD934X_RX3, cdc_if_rx3),
-	WCD_DAPM_MUX("CDC_IF RX4 MUX", WCD934X_RX4, cdc_if_rx4),
-	WCD_DAPM_MUX("CDC_IF RX5 MUX", WCD934X_RX5, cdc_if_rx5),
-	WCD_DAPM_MUX("CDC_IF RX6 MUX", WCD934X_RX6, cdc_if_rx6),
-	WCD_DAPM_MUX("CDC_IF RX7 MUX", WCD934X_RX7, cdc_if_rx7),
-
-	SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM, INTERP_EAR, 0,
-		&rx_int0_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM, INTERP_HPHL, 0,
-		&rx_int1_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM, INTERP_HPHR, 0,
-		&rx_int2_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", SND_SOC_NOPM, INTERP_LO1, 0,
-		&rx_int3_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", SND_SOC_NOPM, INTERP_LO2, 0,
-		&rx_int4_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", SND_SOC_NOPM, INTERP_SPKR1, 0,
-		&rx_int7_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", SND_SOC_NOPM, INTERP_SPKR2, 0,
-		&rx_int8_2_mux, tavil_codec_enable_mix_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	WCD_DAPM_MUX("RX INT0_1 MIX1 INP0", 0, rx_int0_1_mix_inp0),
-	WCD_DAPM_MUX("RX INT0_1 MIX1 INP1", 0, rx_int0_1_mix_inp1),
-	WCD_DAPM_MUX("RX INT0_1 MIX1 INP2", 0, rx_int0_1_mix_inp2),
-	WCD_DAPM_MUX("RX INT1_1 MIX1 INP0", 0, rx_int1_1_mix_inp0),
-	WCD_DAPM_MUX("RX INT1_1 MIX1 INP1", 0, rx_int1_1_mix_inp1),
-	WCD_DAPM_MUX("RX INT1_1 MIX1 INP2", 0, rx_int1_1_mix_inp2),
-	WCD_DAPM_MUX("RX INT2_1 MIX1 INP0", 0, rx_int2_1_mix_inp0),
-	WCD_DAPM_MUX("RX INT2_1 MIX1 INP1", 0, rx_int2_1_mix_inp1),
-	WCD_DAPM_MUX("RX INT2_1 MIX1 INP2", 0, rx_int2_1_mix_inp2),
-	WCD_DAPM_MUX("RX INT3_1 MIX1 INP0", 0, rx_int3_1_mix_inp0),
-	WCD_DAPM_MUX("RX INT3_1 MIX1 INP1", 0, rx_int3_1_mix_inp1),
-	WCD_DAPM_MUX("RX INT3_1 MIX1 INP2", 0, rx_int3_1_mix_inp2),
-	WCD_DAPM_MUX("RX INT4_1 MIX1 INP0", 0, rx_int4_1_mix_inp0),
-	WCD_DAPM_MUX("RX INT4_1 MIX1 INP1", 0, rx_int4_1_mix_inp1),
-	WCD_DAPM_MUX("RX INT4_1 MIX1 INP2", 0, rx_int4_1_mix_inp2),
-
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp0_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp1_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int7_1_mix_inp2_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp0_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp1_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
-		&rx_int8_1_mix_inp2_mux, tavil_codec_enable_swr,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0,
-		rx_int1_asrc_switch, ARRAY_SIZE(rx_int1_asrc_switch)),
-	SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0,
-		rx_int2_asrc_switch, ARRAY_SIZE(rx_int2_asrc_switch)),
-	SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0,
-		rx_int3_asrc_switch, ARRAY_SIZE(rx_int3_asrc_switch)),
-	SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0,
-		rx_int4_asrc_switch, ARRAY_SIZE(rx_int4_asrc_switch)),
-	SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT1 MIX3", SND_SOC_NOPM, 0, 0, hphl_mixer,
-			   ARRAY_SIZE(hphl_mixer)),
-	SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT2 MIX3", SND_SOC_NOPM, 0, 0, hphr_mixer,
-			   ARRAY_SIZE(hphr_mixer)),
-	SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT3 MIX3", SND_SOC_NOPM, 0, 0, lo1_mixer,
-			   ARRAY_SIZE(lo1_mixer)),
-	SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("RX INT4 MIX3", SND_SOC_NOPM, 0, 0, lo2_mixer,
-			   ARRAY_SIZE(lo2_mixer)),
-	SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
-		NULL, 0, tavil_codec_spk_boost_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
-		NULL, 0, tavil_codec_spk_boost_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("RX INT0 MIX2 INP", SND_SOC_NOPM, INTERP_EAR,
-		0, &rx_int0_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT1 MIX2 INP", SND_SOC_NOPM, INTERP_HPHL,
-		0, &rx_int1_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT2 MIX2 INP", SND_SOC_NOPM, INTERP_HPHR,
-		0, &rx_int2_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT3 MIX2 INP", SND_SOC_NOPM, INTERP_LO1,
-		0, &rx_int3_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT4 MIX2 INP", SND_SOC_NOPM, INTERP_LO2,
-		0, &rx_int4_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7 MIX2 INP", SND_SOC_NOPM, INTERP_SPKR1,
-		0, &rx_int7_mix2_inp_mux, tavil_codec_enable_rx_path_clk,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	WCD_DAPM_MUX("CDC_IF TX0 MUX", WCD934X_TX0, cdc_if_tx0),
-	WCD_DAPM_MUX("CDC_IF TX1 MUX", WCD934X_TX1, cdc_if_tx1),
-	WCD_DAPM_MUX("CDC_IF TX2 MUX", WCD934X_TX2, cdc_if_tx2),
-	WCD_DAPM_MUX("CDC_IF TX3 MUX", WCD934X_TX3, cdc_if_tx3),
-	WCD_DAPM_MUX("CDC_IF TX4 MUX", WCD934X_TX4, cdc_if_tx4),
-	WCD_DAPM_MUX("CDC_IF TX5 MUX", WCD934X_TX5, cdc_if_tx5),
-	WCD_DAPM_MUX("CDC_IF TX6 MUX", WCD934X_TX6, cdc_if_tx6),
-	WCD_DAPM_MUX("CDC_IF TX7 MUX", WCD934X_TX7, cdc_if_tx7),
-	WCD_DAPM_MUX("CDC_IF TX8 MUX", WCD934X_TX8, cdc_if_tx8),
-	WCD_DAPM_MUX("CDC_IF TX9 MUX", WCD934X_TX9, cdc_if_tx9),
-	WCD_DAPM_MUX("CDC_IF TX10 MUX", WCD934X_TX10, cdc_if_tx10),
-	WCD_DAPM_MUX("CDC_IF TX11 MUX", WCD934X_TX11, cdc_if_tx11),
-	WCD_DAPM_MUX("CDC_IF TX11 INP1 MUX", WCD934X_TX11, cdc_if_tx11_inp1),
-	WCD_DAPM_MUX("CDC_IF TX13 MUX", WCD934X_TX13, cdc_if_tx13),
-	WCD_DAPM_MUX("CDC_IF TX13 INP1 MUX", WCD934X_TX13, cdc_if_tx13_inp1),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX0", WCD934X_CDC_TX0_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux0_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX1", WCD934X_CDC_TX1_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux1_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX2", WCD934X_CDC_TX2_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux2_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX3", WCD934X_CDC_TX3_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux3_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX4", WCD934X_CDC_TX4_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux4_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX5", WCD934X_CDC_TX5_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux5_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX6", WCD934X_CDC_TX6_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux6_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX7", WCD934X_CDC_TX7_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux7_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX8", WCD934X_CDC_TX8_TX_PATH_CTL, 5, 0,
-		&tx_adc_mux8_mux, tavil_codec_enable_dec,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0, &tx_adc_mux10_mux,
-		tavil_codec_tx_adc_cfg, SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0, &tx_adc_mux11_mux,
-		tavil_codec_tx_adc_cfg, SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0, &tx_adc_mux12_mux,
-		tavil_codec_tx_adc_cfg, SND_SOC_DAPM_POST_PMU),
-
-	SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0, &tx_adc_mux13_mux,
-		tavil_codec_tx_adc_cfg, SND_SOC_DAPM_POST_PMU),
-
-	WCD_DAPM_MUX("DMIC MUX0", 0, tx_dmic_mux0),
-	WCD_DAPM_MUX("DMIC MUX1", 0, tx_dmic_mux1),
-	WCD_DAPM_MUX("DMIC MUX2", 0, tx_dmic_mux2),
-	WCD_DAPM_MUX("DMIC MUX3", 0, tx_dmic_mux3),
-	WCD_DAPM_MUX("DMIC MUX4", 0, tx_dmic_mux4),
-	WCD_DAPM_MUX("DMIC MUX5", 0, tx_dmic_mux5),
-	WCD_DAPM_MUX("DMIC MUX6", 0, tx_dmic_mux6),
-	WCD_DAPM_MUX("DMIC MUX7", 0, tx_dmic_mux7),
-	WCD_DAPM_MUX("DMIC MUX8", 0, tx_dmic_mux8),
-	WCD_DAPM_MUX("DMIC MUX10", 0, tx_dmic_mux10),
-	WCD_DAPM_MUX("DMIC MUX11", 0, tx_dmic_mux11),
-	WCD_DAPM_MUX("DMIC MUX12", 0, tx_dmic_mux12),
-	WCD_DAPM_MUX("DMIC MUX13", 0, tx_dmic_mux13),
-
-	WCD_DAPM_MUX("AMIC MUX0", 0, tx_amic_mux0),
-	WCD_DAPM_MUX("AMIC MUX1", 0, tx_amic_mux1),
-	WCD_DAPM_MUX("AMIC MUX2", 0, tx_amic_mux2),
-	WCD_DAPM_MUX("AMIC MUX3", 0, tx_amic_mux3),
-	WCD_DAPM_MUX("AMIC MUX4", 0, tx_amic_mux4),
-	WCD_DAPM_MUX("AMIC MUX5", 0, tx_amic_mux5),
-	WCD_DAPM_MUX("AMIC MUX6", 0, tx_amic_mux6),
-	WCD_DAPM_MUX("AMIC MUX7", 0, tx_amic_mux7),
-	WCD_DAPM_MUX("AMIC MUX8", 0, tx_amic_mux8),
-	WCD_DAPM_MUX("AMIC MUX10", 0, tx_amic_mux10),
-	WCD_DAPM_MUX("AMIC MUX11", 0, tx_amic_mux11),
-	WCD_DAPM_MUX("AMIC MUX12", 0, tx_amic_mux12),
-	WCD_DAPM_MUX("AMIC MUX13", 0, tx_amic_mux13),
-
-	SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD934X_ANA_AMIC1, 7, 0,
-		tavil_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD934X_ANA_AMIC2, 7, 0,
-		tavil_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD934X_ANA_AMIC3, 7, 0,
-		tavil_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-	SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD934X_ANA_AMIC4, 7, 0,
-		tavil_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
-
-	WCD_DAPM_MUX("AMIC4_5 SEL", 0, tx_amic4_5),
-
-	WCD_DAPM_MUX("ANC0 FB MUX", 0, anc0_fb),
-	WCD_DAPM_MUX("ANC1 FB MUX", 0, anc1_fb),
-
-	SND_SOC_DAPM_INPUT("AMIC1"),
-	SND_SOC_DAPM_INPUT("AMIC2"),
-	SND_SOC_DAPM_INPUT("AMIC3"),
-	SND_SOC_DAPM_INPUT("AMIC4"),
-	SND_SOC_DAPM_INPUT("AMIC5"),
-
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	/*
-	 * Not supply widget, this is used to recover HPH registers.
-	 * It is not connected to any other widgets
-	 */
-	SND_SOC_DAPM_SUPPLY("RESET_HPH_REGISTERS", SND_SOC_NOPM,
-		0, 0, tavil_codec_reset_hph_registers,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
-		tavil_codec_force_enable_micbias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
-		tavil_codec_force_enable_micbias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
-		tavil_codec_force_enable_micbias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
-		tavil_codec_force_enable_micbias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
-		AIF1_CAP, 0, tavil_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
-		AIF2_CAP, 0, tavil_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
-		AIF3_CAP, 0, tavil_codec_enable_slimtx,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
-		aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
-	SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
-		aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
-	SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
-		aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
-	SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
-		aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
-
-	SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
-		AIF4_VIFEED, 0, tavil_codec_enable_slimvi_feedback,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_AIF_OUT("AIF4 MAD", "AIF4 MAD TX", 0,
-		SND_SOC_NOPM, 0, 0),
-
-	SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
-		aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
-	SND_SOC_DAPM_INPUT("VIINPUT"),
-
-	SND_SOC_DAPM_MIXER("SLIM TX0", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX1", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX2", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX3", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX4", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX5", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX6", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX7", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX8", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX9", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX10", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX11", SND_SOC_NOPM, 0, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SLIM TX13", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	/* Digital Mic Inputs */
-	SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_dmic,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	WCD_DAPM_MUX("IIR0 INP0 MUX", 0, iir0_inp0),
-	WCD_DAPM_MUX("IIR0 INP1 MUX", 0, iir0_inp1),
-	WCD_DAPM_MUX("IIR0 INP2 MUX", 0, iir0_inp2),
-	WCD_DAPM_MUX("IIR0 INP3 MUX", 0, iir0_inp3),
-	WCD_DAPM_MUX("IIR1 INP0 MUX", 0, iir1_inp0),
-	WCD_DAPM_MUX("IIR1 INP1 MUX", 0, iir1_inp1),
-	WCD_DAPM_MUX("IIR1 INP2 MUX", 0, iir1_inp2),
-	WCD_DAPM_MUX("IIR1 INP3 MUX", 0, iir1_inp3),
-
-	SND_SOC_DAPM_MIXER_E("IIR0", WCD934X_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
-		4, 0, NULL, 0, tavil_codec_set_iir_gain,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_MIXER_E("IIR1", WCD934X_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
-		4, 0, NULL, 0, tavil_codec_set_iir_gain,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_MIXER("SRC0", WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
-		4, 0, NULL, 0),
-	SND_SOC_DAPM_MIXER("SRC1", WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
-		4, 0, NULL, 0),
-
-	WCD_DAPM_MUX("RX MIX TX0 MUX", 0, rx_mix_tx0),
-	WCD_DAPM_MUX("RX MIX TX1 MUX", 0, rx_mix_tx1),
-	WCD_DAPM_MUX("RX MIX TX2 MUX", 0, rx_mix_tx2),
-	WCD_DAPM_MUX("RX MIX TX3 MUX", 0, rx_mix_tx3),
-	WCD_DAPM_MUX("RX MIX TX4 MUX", 0, rx_mix_tx4),
-	WCD_DAPM_MUX("RX MIX TX5 MUX", 0, rx_mix_tx5),
-	WCD_DAPM_MUX("RX MIX TX6 MUX", 0, rx_mix_tx6),
-	WCD_DAPM_MUX("RX MIX TX7 MUX", 0, rx_mix_tx7),
-	WCD_DAPM_MUX("RX MIX TX8 MUX", 0, rx_mix_tx8),
-	WCD_DAPM_MUX("RX INT0 DEM MUX", 0, rx_int0_dem_inp),
-	WCD_DAPM_MUX("RX INT1 DEM MUX", 0, rx_int1_dem_inp),
-	WCD_DAPM_MUX("RX INT2 DEM MUX", 0, rx_int2_dem_inp),
-
-	SND_SOC_DAPM_MUX_E("RX INT0_1 INTERP", SND_SOC_NOPM, INTERP_EAR, 0,
-		&rx_int0_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT1_1 INTERP", SND_SOC_NOPM, INTERP_HPHL, 0,
-		&rx_int1_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT2_1 INTERP", SND_SOC_NOPM, INTERP_HPHR, 0,
-		&rx_int2_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT3_1 INTERP", SND_SOC_NOPM, INTERP_LO1, 0,
-		&rx_int3_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT4_1 INTERP", SND_SOC_NOPM, INTERP_LO2, 0,
-		&rx_int4_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT7_1 INTERP", SND_SOC_NOPM, INTERP_SPKR1, 0,
-		&rx_int7_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("RX INT8_1 INTERP", SND_SOC_NOPM, INTERP_SPKR2, 0,
-		&rx_int8_1_interp_mux, tavil_codec_enable_main_path,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_POST_PMD),
-
-	WCD_DAPM_MUX("RX INT0_2 INTERP", 0, rx_int0_2_interp),
-	WCD_DAPM_MUX("RX INT1_2 INTERP", 0, rx_int1_2_interp),
-	WCD_DAPM_MUX("RX INT2_2 INTERP", 0, rx_int2_2_interp),
-	WCD_DAPM_MUX("RX INT3_2 INTERP", 0, rx_int3_2_interp),
-	WCD_DAPM_MUX("RX INT4_2 INTERP", 0, rx_int4_2_interp),
-	WCD_DAPM_MUX("RX INT7_2 INTERP", 0, rx_int7_2_interp),
-	WCD_DAPM_MUX("RX INT8_2 INTERP", 0, rx_int8_2_interp),
-
-	SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD934X_CDC_TX0_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux0_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD934X_CDC_TX1_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux1_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD934X_CDC_TX2_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux2_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD934X_CDC_TX3_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux3_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD934X_CDC_TX4_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux4_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD934X_CDC_TX5_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux5_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD934X_CDC_TX6_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux6_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD934X_CDC_TX7_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux7_switch),
-	SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD934X_CDC_TX8_TX_PATH_192_CTL, 0,
-		0, &adc_us_mux8_switch),
-
-	/* MAD related widgets */
-	SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
-	SND_SOC_DAPM_INPUT("MADINPUT"),
-
-	WCD_DAPM_MUX("MAD_SEL MUX", 0, mad_sel),
-	WCD_DAPM_MUX("MAD_INP MUX", 0, mad_inp_mux),
-
-	SND_SOC_DAPM_SWITCH_E("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
-			      &mad_brdcst_switch, tavil_codec_ape_enable_mad,
-			      SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_SWITCH_E("MAD_CPE1", SND_SOC_NOPM, 0, 0,
-			      &mad_cpe1_switch, tavil_codec_cpe_mad_ctl,
-			      SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SWITCH_E("MAD_CPE2", SND_SOC_NOPM, 0, 0,
-			      &mad_cpe2_switch, tavil_codec_cpe_mad_ctl,
-			      SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT1"),
-	SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT2"),
-
-	SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tavil_codec_ear_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD934X_ANA_HPH,
-		5, 0, tavil_codec_hphl_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD934X_ANA_HPH,
-		4, 0, tavil_codec_hphr_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tavil_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
-		0, 0, tavil_codec_lineout_dac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_PGA_E("EAR PA", WCD934X_ANA_EAR, 7, 0, NULL, 0,
-		tavil_codec_enable_ear_pa,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHL PA", WCD934X_ANA_HPH, 7, 0, NULL, 0,
-		tavil_codec_enable_hphl_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("HPHR PA", WCD934X_ANA_HPH, 6, 0, NULL, 0,
-		tavil_codec_enable_hphr_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD934X_ANA_LO_1_2, 7, 0, NULL, 0,
-		tavil_codec_enable_lineout_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD934X_ANA_LO_1_2, 6, 0, NULL, 0,
-		tavil_codec_enable_lineout_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD934X_ANA_EAR, 7, 0, NULL, 0,
-		tavil_codec_enable_ear_pa, SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-		tavil_codec_enable_spkr_anc,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-		tavil_codec_enable_hphl_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
-		tavil_codec_enable_hphr_pa,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_OUTPUT("EAR"),
-	SND_SOC_DAPM_OUTPUT("HPHL"),
-	SND_SOC_DAPM_OUTPUT("HPHR"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT1"),
-	SND_SOC_DAPM_OUTPUT("LINEOUT2"),
-	SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
-	SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
-	SND_SOC_DAPM_OUTPUT("ANC EAR"),
-	SND_SOC_DAPM_OUTPUT("ANC HPHL"),
-	SND_SOC_DAPM_OUTPUT("ANC HPHR"),
-
-	SND_SOC_DAPM_SWITCH("ANC OUT EAR Enable", SND_SOC_NOPM, 0, 0,
-		&anc_ear_switch),
-	SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
-		&anc_ear_spkr_switch),
-	SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
-		&anc_spkr_pa_switch),
-
-	SND_SOC_DAPM_SWITCH_E("ANC OUT HPHL Enable", SND_SOC_NOPM, INTERP_HPHL,
-		0, &anc_hphl_pa_switch, tavil_anc_out_switch_cb,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	 SND_SOC_DAPM_SWITCH_E("ANC OUT HPHR Enable", SND_SOC_NOPM, INTERP_HPHR,
-		0, &anc_hphr_pa_switch, tavil_anc_out_switch_cb,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
-		tavil_codec_enable_rx_bias,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_HPHL, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_HPHR, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_LO1, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_LO2, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SUPPLY("RX INT7 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_SPKR1, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SUPPLY("RX INT8 NATIVE SUPPLY", SND_SOC_NOPM,
-		INTERP_SPKR2, 0, tavil_enable_native_supply,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-
-	WCD_DAPM_MUX("RX INT1_1 NATIVE MUX", 0, int1_1_native),
-	WCD_DAPM_MUX("RX INT2_1 NATIVE MUX", 0, int2_1_native),
-	WCD_DAPM_MUX("RX INT3_1 NATIVE MUX", 0, int3_1_native),
-	WCD_DAPM_MUX("RX INT4_1 NATIVE MUX", 0, int4_1_native),
-
-	WCD_DAPM_MUX("RX INT1_2 NATIVE MUX", 0, int1_2_native),
-	WCD_DAPM_MUX("RX INT2_2 NATIVE MUX", 0, int2_2_native),
-	WCD_DAPM_MUX("RX INT3_2 NATIVE MUX", 0, int3_2_native),
-	WCD_DAPM_MUX("RX INT4_2 NATIVE MUX", 0, int4_2_native),
-	WCD_DAPM_MUX("RX INT7_2 NATIVE MUX", 0, int7_2_native),
-	WCD_DAPM_MUX("RX INT8_2 NATIVE MUX", 0, int8_2_native),
-
-	SND_SOC_DAPM_MUX_E("ASRC0 MUX", SND_SOC_NOPM, ASRC0, 0,
-		&asrc0_mux, tavil_codec_enable_asrc_resampler,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("ASRC1 MUX", SND_SOC_NOPM, ASRC1, 0,
-		&asrc1_mux, tavil_codec_enable_asrc_resampler,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("ASRC2 MUX", SND_SOC_NOPM, ASRC2, 0,
-		&asrc2_mux, tavil_codec_enable_asrc_resampler,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MUX_E("ASRC3 MUX", SND_SOC_NOPM, ASRC3, 0,
-		&asrc3_mux, tavil_codec_enable_asrc_resampler,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	/* WDMA3 widgets */
-	WCD_DAPM_MUX("WDMA3 PORT0 MUX", 0, wdma3_port0),
-	WCD_DAPM_MUX("WDMA3 PORT1 MUX", 1, wdma3_port1),
-	WCD_DAPM_MUX("WDMA3 PORT2 MUX", 2, wdma3_port2),
-	WCD_DAPM_MUX("WDMA3 PORT3 MUX", 3, wdma3_port3),
-	WCD_DAPM_MUX("WDMA3 PORT4 MUX", 4, wdma3_port4),
-	WCD_DAPM_MUX("WDMA3 PORT5 MUX", 5, wdma3_port5),
-	WCD_DAPM_MUX("WDMA3 PORT6 MUX", 6, wdma3_port6),
-
-	WCD_DAPM_MUX("WDMA3 CH0 MUX", 0, wdma3_ch0),
-	WCD_DAPM_MUX("WDMA3 CH1 MUX", 4, wdma3_ch1),
-	WCD_DAPM_MUX("WDMA3 CH2 MUX", 0, wdma3_ch2),
-	WCD_DAPM_MUX("WDMA3 CH3 MUX", 4, wdma3_ch3),
-
-	SND_SOC_DAPM_MIXER("WDMA3_CH_MIXER", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-	SND_SOC_DAPM_SWITCH_E("WDMA3_ON_OFF", SND_SOC_NOPM, 0, 0,
-			      &wdma3_onoff_switch, tavil_codec_wdma3_ctl,
-			      SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_OUTPUT("WDMA3_OUT"),
-};
-
-static int tavil_get_channel_map(struct snd_soc_dai *dai,
-				 unsigned int *tx_num, unsigned int *tx_slot,
-				 unsigned int *rx_num, unsigned int *rx_slot)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec);
-	u32 i = 0;
-	struct wcd9xxx_ch *ch;
-	int ret = 0;
-
-	switch (dai->id) {
-	case AIF1_PB:
-	case AIF2_PB:
-	case AIF3_PB:
-	case AIF4_PB:
-		if (!rx_slot || !rx_num) {
-			dev_err(tavil->dev, "%s: Invalid rx_slot 0x%pK or rx_num 0x%pK\n",
-				 __func__, rx_slot, rx_num);
-			ret = -EINVAL;
-			break;
-		}
-		list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list,
-				    list) {
-			dev_dbg(tavil->dev, "%s: slot_num %u ch->ch_num %d\n",
-				 __func__, i, ch->ch_num);
-			rx_slot[i++] = ch->ch_num;
-		}
-		*rx_num = i;
-		dev_dbg(tavil->dev, "%s: dai_name = %s dai_id = %x  rx_num = %d\n",
-			__func__, dai->name, dai->id, i);
-		if (*rx_num == 0) {
-			dev_err(tavil->dev, "%s: Channel list empty for dai_name = %s dai_id = %x\n",
-				__func__, dai->name, dai->id);
-			ret = -EINVAL;
-		}
-		break;
-	case AIF1_CAP:
-	case AIF2_CAP:
-	case AIF3_CAP:
-	case AIF4_MAD_TX:
-	case AIF4_VIFEED:
-		if (!tx_slot || !tx_num) {
-			dev_err(tavil->dev, "%s: Invalid tx_slot 0x%pK or tx_num 0x%pK\n",
-				 __func__, tx_slot, tx_num);
-			ret = -EINVAL;
-			break;
-		}
-		list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list,
-				    list) {
-			dev_dbg(tavil->dev, "%s: slot_num %u ch->ch_num %d\n",
-				 __func__, i,  ch->ch_num);
-			tx_slot[i++] = ch->ch_num;
-		}
-		*tx_num = i;
-		dev_dbg(tavil->dev, "%s: dai_name = %s dai_id = %x  tx_num = %d\n",
-			 __func__, dai->name, dai->id, i);
-		if (*tx_num == 0) {
-			dev_err(tavil->dev, "%s: Channel list empty for dai_name = %s dai_id = %x\n",
-				 __func__, dai->name, dai->id);
-			ret = -EINVAL;
-		}
-		break;
-	default:
-		dev_err(tavil->dev, "%s: Invalid DAI ID %x\n",
-			__func__, dai->id);
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static int tavil_set_channel_map(struct snd_soc_dai *dai,
-				 unsigned int tx_num, unsigned int *tx_slot,
-				 unsigned int rx_num, unsigned int *rx_slot)
-{
-	struct tavil_priv *tavil;
-	struct wcd9xxx *core;
-	struct wcd9xxx_codec_dai_data *dai_data = NULL;
-
-	tavil = snd_soc_codec_get_drvdata(dai->codec);
-	core = dev_get_drvdata(dai->codec->dev->parent);
-
-	if (!tx_slot || !rx_slot) {
-		dev_err(tavil->dev, "%s: Invalid tx_slot 0x%pK, rx_slot 0x%pK\n",
-			__func__, tx_slot, rx_slot);
-		return -EINVAL;
-	}
-	dev_dbg(tavil->dev, "%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n",
-		 __func__, dai->name, dai->id, tx_num, rx_num);
-
-	wcd9xxx_init_slimslave(core, core->slim->laddr,
-				tx_num, tx_slot, rx_num, rx_slot);
-	/* Reserve TX13 for MAD data channel */
-	dai_data = &tavil->dai[AIF4_MAD_TX];
-	if (dai_data)
-		list_add_tail(&core->tx_chs[WCD934X_TX13].list,
-			      &dai_data->wcd9xxx_ch_list);
-
-	return 0;
-}
-
-static int tavil_startup(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	return 0;
-}
-
-static void tavil_shutdown(struct snd_pcm_substream *substream,
-			   struct snd_soc_dai *dai)
-{
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-}
-
-static int tavil_set_decimator_rate(struct snd_soc_dai *dai,
-				    u32 sample_rate)
-{
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	u32 tx_port = 0, tx_fs_rate = 0;
-	u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
-	int decimator = -1;
-	u16 tx_port_reg = 0, tx_fs_reg = 0;
-
-	switch (sample_rate) {
-	case 8000:
-		tx_fs_rate = 0;
-		break;
-	case 16000:
-		tx_fs_rate = 1;
-		break;
-	case 32000:
-		tx_fs_rate = 3;
-		break;
-	case 48000:
-		tx_fs_rate = 4;
-		break;
-	case 96000:
-		tx_fs_rate = 5;
-		break;
-	case 192000:
-		tx_fs_rate = 6;
-		break;
-	default:
-		dev_err(tavil->dev, "%s: Invalid TX sample rate: %d\n",
-			__func__, sample_rate);
-		return -EINVAL;
-
-	};
-
-	list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) {
-		tx_port = ch->port;
-		dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
-			__func__, dai->id, tx_port);
-
-		if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
-			dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
-				__func__, tx_port, dai->id);
-			return -EINVAL;
-		}
-		/* Find the SB TX MUX input - which decimator is connected */
-		if (tx_port < 4) {
-			tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0;
-			shift = (tx_port << 1);
-			shift_val = 0x03;
-		} else if ((tx_port >= 4) && (tx_port < 8)) {
-			tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1;
-			shift = ((tx_port - 4) << 1);
-			shift_val = 0x03;
-		} else if ((tx_port >= 8) && (tx_port < 11)) {
-			tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2;
-			shift = ((tx_port - 8) << 1);
-			shift_val = 0x03;
-		} else if (tx_port == 11) {
-			tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3;
-			shift = 0;
-			shift_val = 0x0F;
-		} else if (tx_port == 13) {
-			tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3;
-			shift = 4;
-			shift_val = 0x03;
-		}
-		tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
-					  (shift_val << shift);
-		tx_mux_sel = tx_mux_sel >> shift;
-
-		if (tx_port <= 8) {
-			if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
-				decimator = tx_port;
-		} else if (tx_port <= 10) {
-			if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
-				decimator = ((tx_port == 9) ? 7 : 6);
-		} else if (tx_port == 11) {
-			if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
-				decimator = tx_mux_sel - 1;
-		} else if (tx_port == 13) {
-			if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
-				decimator = 5;
-		}
-
-		if (decimator >= 0) {
-			tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL +
-				    16 * decimator;
-			dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
-				__func__, decimator, tx_port, sample_rate);
-			snd_soc_update_bits(codec, tx_fs_reg, 0x0F, tx_fs_rate);
-		} else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
-			/* Check if the TX Mux input is RX MIX TXn */
-			dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to CDC_IF TX%u\n",
-					__func__, tx_port, tx_port);
-		} else {
-			dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
-				__func__, decimator);
-			return -EINVAL;
-		}
-	}
-	return 0;
-}
-
-static int tavil_set_mix_interpolator_rate(struct snd_soc_dai *dai,
-					   u8 rate_reg_val,
-					   u32 sample_rate)
-{
-	u8 int_2_inp;
-	u32 j;
-	u16 int_mux_cfg1, int_fs_reg;
-	u8 int_mux_cfg1_val;
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) {
-		int_2_inp = INTn_2_INP_SEL_RX0 + ch->port -
-						WCD934X_RX_PORT_START_NUMBER;
-		if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
-		    (int_2_inp > INTn_2_INP_SEL_RX7)) {
-			dev_err(codec->dev, "%s: Invalid RX%u port, Dai ID is %d\n",
-				__func__,
-				(ch->port - WCD934X_RX_PORT_START_NUMBER),
-				dai->id);
-			return -EINVAL;
-		}
-
-		int_mux_cfg1 = WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1;
-		for (j = 0; j < WCD934X_NUM_INTERPOLATORS; j++) {
-			/* Interpolators 5 and 6 are not aviliable in Tavil */
-			if (j == INTERP_LO3_NA || j == INTERP_LO4_NA) {
-				int_mux_cfg1 += 2;
-				continue;
-			}
-			int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
-									0x0F;
-			if (int_mux_cfg1_val == int_2_inp) {
-				/*
-				 * Ear mix path supports only 48, 96, 192,
-				 * 384KHz only
-				 */
-				if ((j == INTERP_EAR) &&
-				    (rate_reg_val < 0x4 ||
-				     rate_reg_val > 0x7)) {
-					dev_err_ratelimited(codec->dev,
-					"%s: Invalid rate for AIF_PB DAI(%d)\n",
-					  __func__, dai->id);
-					return -EINVAL;
-				}
-
-				int_fs_reg = WCD934X_CDC_RX0_RX_PATH_MIX_CTL +
-									20 * j;
-				dev_dbg(codec->dev, "%s: AIF_PB DAI(%d) connected to INT%u_2\n",
-					  __func__, dai->id, j);
-				dev_dbg(codec->dev, "%s: set INT%u_2 sample rate to %u\n",
-					__func__, j, sample_rate);
-				snd_soc_update_bits(codec, int_fs_reg, 0x0F,
-						    rate_reg_val);
-			}
-			int_mux_cfg1 += 2;
-		}
-	}
-	return 0;
-}
-
-static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai,
-					    u8 rate_reg_val,
-					    u32 sample_rate)
-{
-	u8 int_1_mix1_inp;
-	u32 j;
-	u16 int_mux_cfg0, int_mux_cfg1;
-	u16 int_fs_reg;
-	u8 int_mux_cfg0_val, int_mux_cfg1_val;
-	u8 inp0_sel, inp1_sel, inp2_sel;
-	struct snd_soc_codec *codec = dai->codec;
-	struct wcd9xxx_ch *ch;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	struct tavil_dsd_config *dsd_conf = tavil->dsd_config;
-
-	list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) {
-		int_1_mix1_inp = INTn_1_INP_SEL_RX0 + ch->port -
-						WCD934X_RX_PORT_START_NUMBER;
-		if ((int_1_mix1_inp < INTn_1_INP_SEL_RX0) ||
-		    (int_1_mix1_inp > INTn_1_INP_SEL_RX7)) {
-			dev_err(codec->dev, "%s: Invalid RX%u port, Dai ID is %d\n",
-				__func__,
-				(ch->port - WCD934X_RX_PORT_START_NUMBER),
-				dai->id);
-			return -EINVAL;
-		}
-
-		int_mux_cfg0 = WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0;
-
-		/*
-		 * Loop through all interpolator MUX inputs and find out
-		 * to which interpolator input, the slim rx port
-		 * is connected
-		 */
-		for (j = 0; j < WCD934X_NUM_INTERPOLATORS; j++) {
-			/* Interpolators 5 and 6 are not aviliable in Tavil */
-			if (j == INTERP_LO3_NA || j == INTERP_LO4_NA) {
-				int_mux_cfg0 += 2;
-				continue;
-			}
-			int_mux_cfg1 = int_mux_cfg0 + 1;
-
-			int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
-			int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
-			inp0_sel = int_mux_cfg0_val & 0x0F;
-			inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
-			inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
-			if ((inp0_sel == int_1_mix1_inp) ||
-			    (inp1_sel == int_1_mix1_inp) ||
-			    (inp2_sel == int_1_mix1_inp)) {
-				/*
-				 * Ear and speaker primary path does not support
-				 * native sample rates
-				 */
-				if ((j == INTERP_EAR || j == INTERP_SPKR1 ||
-					j == INTERP_SPKR2) &&
-					(rate_reg_val > 0x7)) {
-					dev_err_ratelimited(codec->dev,
-					"%s: Invalid rate for AIF_PB DAI(%d)\n",
-					  __func__, dai->id);
-					return -EINVAL;
-				}
-
-				int_fs_reg = WCD934X_CDC_RX0_RX_PATH_CTL +
-									20 * j;
-				dev_dbg(codec->dev,
-				"%s: AIF_PB DAI(%d) connected to INT%u_1\n",
-				  __func__, dai->id, j);
-				dev_dbg(codec->dev,
-					"%s: set INT%u_1 sample rate to %u\n",
-					__func__, j, sample_rate);
-				snd_soc_update_bits(codec, int_fs_reg, 0x0F,
-						    rate_reg_val);
-			}
-			int_mux_cfg0 += 2;
-		}
-		if (dsd_conf)
-			tavil_dsd_set_interp_rate(dsd_conf, ch->port,
-						  sample_rate, rate_reg_val);
-	}
-
-	return 0;
-}
-
-
-static int tavil_set_interpolator_rate(struct snd_soc_dai *dai,
-				       u32 sample_rate)
-{
-	struct snd_soc_codec *codec = dai->codec;
-	int rate_val = 0;
-	int i, ret;
-
-	for (i = 0; i < ARRAY_SIZE(sr_val_tbl); i++) {
-		if (sample_rate == sr_val_tbl[i].sample_rate) {
-			rate_val = sr_val_tbl[i].rate_val;
-			break;
-		}
-	}
-	if ((i == ARRAY_SIZE(sr_val_tbl)) || (rate_val < 0)) {
-		dev_err(codec->dev, "%s: Unsupported sample rate: %d\n",
-			__func__, sample_rate);
-		return -EINVAL;
-	}
-
-	ret = tavil_set_prim_interpolator_rate(dai, (u8)rate_val, sample_rate);
-	if (ret)
-		return ret;
-	ret = tavil_set_mix_interpolator_rate(dai, (u8)rate_val, sample_rate);
-	if (ret)
-		return ret;
-
-	return ret;
-}
-
-static int tavil_prepare(struct snd_pcm_substream *substream,
-			 struct snd_soc_dai *dai)
-{
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-	return 0;
-}
-
-static int tavil_vi_hw_params(struct snd_pcm_substream *substream,
-			      struct snd_pcm_hw_params *params,
-			      struct snd_soc_dai *dai)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec);
-
-	dev_dbg(tavil->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n",
-		 __func__, dai->name, dai->id, params_rate(params),
-		 params_channels(params));
-
-	tavil->dai[dai->id].rate = params_rate(params);
-	tavil->dai[dai->id].bit_width = 32;
-
-	return 0;
-}
-
-static int tavil_hw_params(struct snd_pcm_substream *substream,
-			   struct snd_pcm_hw_params *params,
-			   struct snd_soc_dai *dai)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec);
-	int ret = 0;
-
-	dev_dbg(tavil->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n",
-		 __func__, dai->name, dai->id, params_rate(params),
-		 params_channels(params));
-
-	switch (substream->stream) {
-	case SNDRV_PCM_STREAM_PLAYBACK:
-		ret = tavil_set_interpolator_rate(dai, params_rate(params));
-		if (ret) {
-			dev_err(tavil->dev, "%s: cannot set sample rate: %u\n",
-				__func__, params_rate(params));
-			return ret;
-		}
-		switch (params_width(params)) {
-		case 16:
-			tavil->dai[dai->id].bit_width = 16;
-			break;
-		case 24:
-			tavil->dai[dai->id].bit_width = 24;
-			break;
-		case 32:
-			tavil->dai[dai->id].bit_width = 32;
-			break;
-		default:
-			return -EINVAL;
-		}
-		tavil->dai[dai->id].rate = params_rate(params);
-		break;
-	case SNDRV_PCM_STREAM_CAPTURE:
-		if (dai->id != AIF4_MAD_TX)
-			ret = tavil_set_decimator_rate(dai,
-						       params_rate(params));
-		if (ret) {
-			dev_err(tavil->dev, "%s: cannot set TX Decimator rate: %d\n",
-				__func__, ret);
-			return ret;
-		}
-		switch (params_width(params)) {
-		case 16:
-			tavil->dai[dai->id].bit_width = 16;
-			break;
-		case 24:
-			tavil->dai[dai->id].bit_width = 24;
-			break;
-		default:
-			dev_err(tavil->dev, "%s: Invalid format 0x%x\n",
-				__func__, params_width(params));
-			return -EINVAL;
-		};
-		tavil->dai[dai->id].rate = params_rate(params);
-		break;
-	default:
-		dev_err(tavil->dev, "%s: Invalid stream type %d\n", __func__,
-			substream->stream);
-		return -EINVAL;
-	};
-
-	return 0;
-}
-
-static struct snd_soc_dai_ops tavil_dai_ops = {
-	.startup = tavil_startup,
-	.shutdown = tavil_shutdown,
-	.hw_params = tavil_hw_params,
-	.prepare = tavil_prepare,
-	.set_channel_map = tavil_set_channel_map,
-	.get_channel_map = tavil_get_channel_map,
-};
-
-static struct snd_soc_dai_ops tavil_vi_dai_ops = {
-	.hw_params = tavil_vi_hw_params,
-	.set_channel_map = tavil_set_channel_map,
-	.get_channel_map = tavil_get_channel_map,
-};
-
-static struct snd_soc_dai_driver tavil_dai[] = {
-	{
-		.name = "tavil_rx1",
-		.id = AIF1_PB,
-		.playback = {
-			.stream_name = "AIF1 Playback",
-			.rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_S32_LE,
-			.rate_min = 8000,
-			.rate_max = 384000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_tx1",
-		.id = AIF1_CAP,
-		.capture = {
-			.stream_name = "AIF1 Capture",
-			.rates = WCD934X_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_rx2",
-		.id = AIF2_PB,
-		.playback = {
-			.stream_name = "AIF2 Playback",
-			.rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_S32_LE,
-			.rate_min = 8000,
-			.rate_max = 384000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_tx2",
-		.id = AIF2_CAP,
-		.capture = {
-			.stream_name = "AIF2 Capture",
-			.rates = WCD934X_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_rx3",
-		.id = AIF3_PB,
-		.playback = {
-			.stream_name = "AIF3 Playback",
-			.rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_S32_LE,
-			.rate_min = 8000,
-			.rate_max = 384000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_tx3",
-		.id = AIF3_CAP,
-		.capture = {
-			.stream_name = "AIF3 Capture",
-			.rates = WCD934X_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_LE,
-			.rate_min = 8000,
-			.rate_max = 192000,
-			.channels_min = 1,
-			.channels_max = 4,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_rx4",
-		.id = AIF4_PB,
-		.playback = {
-			.stream_name = "AIF4 Playback",
-			.rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK,
-			.formats = WCD934X_FORMATS_S16_S24_S32_LE,
-			.rate_min = 8000,
-			.rate_max = 384000,
-			.channels_min = 1,
-			.channels_max = 2,
-		},
-		.ops = &tavil_dai_ops,
-	},
-	{
-		.name = "tavil_vifeedback",
-		.id = AIF4_VIFEED,
-		.capture = {
-			.stream_name = "VIfeed",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
-			.formats = WCD934X_FORMATS_S16_S24_S32_LE,
-			.rate_min = 8000,
-			.rate_max = 48000,
-			.channels_min = 1,
-			.channels_max = 4,
-		 },
-		.ops = &tavil_vi_dai_ops,
-	},
-	{
-		.name = "tavil_mad1",
-		.id = AIF4_MAD_TX,
-		.capture = {
-			.stream_name = "AIF4 MAD TX",
-			.rates = SNDRV_PCM_RATE_16000,
-			.formats = WCD934X_FORMATS_S16_LE,
-			.rate_min = 16000,
-			.rate_max = 16000,
-			.channels_min = 1,
-			.channels_max = 1,
-		},
-		.ops = &tavil_dai_ops,
-	},
-};
-
-static void tavil_codec_power_gate_digital_core(struct tavil_priv *tavil)
-{
-	mutex_lock(&tavil->power_lock);
-	dev_dbg(tavil->dev, "%s: Entering power gating function, %d\n",
-		__func__, tavil->power_active_ref);
-
-	if (tavil->power_active_ref > 0)
-		goto exit;
-
-	wcd9xxx_set_power_state(tavil->wcd9xxx,
-			WCD_REGION_POWER_COLLAPSE_BEGIN,
-			WCD9XXX_DIG_CORE_REGION_1);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x04, 0x04);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x01, 0x00);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x02, 0x00);
-	wcd9xxx_set_power_state(tavil->wcd9xxx, WCD_REGION_POWER_DOWN,
-				WCD9XXX_DIG_CORE_REGION_1);
-exit:
-	dev_dbg(tavil->dev, "%s: Exiting power gating function, %d\n",
-		__func__, tavil->power_active_ref);
-	mutex_unlock(&tavil->power_lock);
-}
-
-static void tavil_codec_power_gate_work(struct work_struct *work)
-{
-	struct tavil_priv *tavil;
-	struct delayed_work *dwork;
-
-	dwork = to_delayed_work(work);
-	tavil = container_of(dwork, struct tavil_priv, power_gate_work);
-
-	tavil_codec_power_gate_digital_core(tavil);
-}
-
-/* called under power_lock acquisition */
-static int tavil_dig_core_remove_power_collapse(struct tavil_priv *tavil)
-{
-	regmap_write(tavil->wcd9xxx->regmap,
-		     WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x05);
-	regmap_write(tavil->wcd9xxx->regmap,
-		     WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x07);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x00);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x02);
-	regmap_write(tavil->wcd9xxx->regmap,
-		     WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x03);
-
-	wcd9xxx_set_power_state(tavil->wcd9xxx,
-			WCD_REGION_POWER_COLLAPSE_REMOVE,
-			WCD9XXX_DIG_CORE_REGION_1);
-	regcache_mark_dirty(tavil->wcd9xxx->regmap);
-	regcache_sync_region(tavil->wcd9xxx->regmap,
-			     WCD934X_DIG_CORE_REG_MIN,
-			     WCD934X_DIG_CORE_REG_MAX);
-
-	tavil_restore_iir_coeff(tavil, IIR0);
-	tavil_restore_iir_coeff(tavil, IIR1);
-	return 0;
-}
-
-static int tavil_dig_core_power_collapse(struct tavil_priv *tavil,
-					 int req_state)
-{
-	int cur_state;
-
-	/* Exit if feature is disabled */
-	if (!dig_core_collapse_enable)
-		return 0;
-
-	mutex_lock(&tavil->power_lock);
-	if (req_state == POWER_COLLAPSE)
-		tavil->power_active_ref--;
-	else if (req_state == POWER_RESUME)
-		tavil->power_active_ref++;
-	else
-		goto unlock_mutex;
-
-	if (tavil->power_active_ref < 0) {
-		dev_dbg(tavil->dev, "%s: power_active_ref is negative\n",
-			__func__);
-		goto unlock_mutex;
-	}
-
-	if (req_state == POWER_COLLAPSE) {
-		if (tavil->power_active_ref == 0) {
-			schedule_delayed_work(&tavil->power_gate_work,
-			msecs_to_jiffies(dig_core_collapse_timer * 1000));
-		}
-	} else if (req_state == POWER_RESUME) {
-		if (tavil->power_active_ref == 1) {
-			/*
-			 * At this point, there can be two cases:
-			 * 1. Core already in power collapse state
-			 * 2. Timer kicked in and still did not expire or
-			 * waiting for the power_lock
-			 */
-			cur_state = wcd9xxx_get_current_power_state(
-						tavil->wcd9xxx,
-						WCD9XXX_DIG_CORE_REGION_1);
-			if (cur_state == WCD_REGION_POWER_DOWN) {
-				tavil_dig_core_remove_power_collapse(tavil);
-			} else {
-				mutex_unlock(&tavil->power_lock);
-				cancel_delayed_work_sync(
-						&tavil->power_gate_work);
-				mutex_lock(&tavil->power_lock);
-			}
-		}
-	}
-
-unlock_mutex:
-	mutex_unlock(&tavil->power_lock);
-
-	return 0;
-}
-
-static int tavil_cdc_req_mclk_enable(struct tavil_priv *tavil,
-				     bool enable)
-{
-	int ret = 0;
-
-	if (enable) {
-		ret = clk_prepare_enable(tavil->wcd_ext_clk);
-		if (ret) {
-			dev_err(tavil->dev, "%s: ext clk enable failed\n",
-				__func__);
-			goto done;
-		}
-		/* get BG */
-		wcd_resmgr_enable_master_bias(tavil->resmgr);
-		/* get MCLK */
-		wcd_resmgr_enable_clk_block(tavil->resmgr, WCD_CLK_MCLK);
-	} else {
-		/* put MCLK */
-		wcd_resmgr_disable_clk_block(tavil->resmgr, WCD_CLK_MCLK);
-		/* put BG */
-		wcd_resmgr_disable_master_bias(tavil->resmgr);
-		clk_disable_unprepare(tavil->wcd_ext_clk);
-	}
-
-done:
-	return ret;
-}
-
-static int __tavil_cdc_mclk_enable_locked(struct tavil_priv *tavil,
-					  bool enable)
-{
-	int ret = 0;
-
-	if (!tavil->wcd_ext_clk) {
-		dev_err(tavil->dev, "%s: wcd ext clock is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(tavil->dev, "%s: mclk_enable = %u\n", __func__, enable);
-
-	if (enable) {
-		tavil_dig_core_power_collapse(tavil, POWER_RESUME);
-		tavil_vote_svs(tavil, true);
-		ret = tavil_cdc_req_mclk_enable(tavil, true);
-		if (ret)
-			goto done;
-	} else {
-		tavil_cdc_req_mclk_enable(tavil, false);
-		tavil_vote_svs(tavil, false);
-		tavil_dig_core_power_collapse(tavil, POWER_COLLAPSE);
-	}
-
-done:
-	return ret;
-}
-
-static int __tavil_cdc_mclk_enable(struct tavil_priv *tavil,
-				   bool enable)
-{
-	int ret;
-
-	WCD9XXX_V2_BG_CLK_LOCK(tavil->resmgr);
-	ret = __tavil_cdc_mclk_enable_locked(tavil, enable);
-	if (enable)
-		wcd_resmgr_set_sido_input_src(tavil->resmgr,
-						     SIDO_SOURCE_RCO_BG);
-	WCD9XXX_V2_BG_CLK_UNLOCK(tavil->resmgr);
-
-	return ret;
-}
-
-static ssize_t tavil_codec_version_read(struct snd_info_entry *entry,
-					void *file_private_data,
-					struct file *file,
-					char __user *buf, size_t count,
-					loff_t pos)
-{
-	struct tavil_priv *tavil;
-	struct wcd9xxx *wcd9xxx;
-	char buffer[TAVIL_VERSION_ENTRY_SIZE];
-	int len = 0;
-
-	tavil = (struct tavil_priv *) entry->private_data;
-	if (!tavil) {
-		pr_err("%s: tavil priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	wcd9xxx = tavil->wcd9xxx;
-
-	switch (wcd9xxx->version) {
-	case TAVIL_VERSION_WCD9340_1_0:
-		len = snprintf(buffer, sizeof(buffer), "WCD9340_1_0\n");
-		break;
-	case TAVIL_VERSION_WCD9341_1_0:
-		len = snprintf(buffer, sizeof(buffer), "WCD9341_1_0\n");
-		break;
-	case TAVIL_VERSION_WCD9340_1_1:
-		len = snprintf(buffer, sizeof(buffer), "WCD9340_1_1\n");
-		break;
-	case TAVIL_VERSION_WCD9341_1_1:
-		len = snprintf(buffer, sizeof(buffer), "WCD9341_1_1\n");
-		break;
-	default:
-		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
-	}
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops tavil_codec_info_ops = {
-	.read = tavil_codec_version_read,
-};
-
-/*
- * tavil_codec_info_create_codec_entry - creates wcd934x module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates wcd934x module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int tavil_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct tavil_priv *tavil;
-	struct snd_soc_card *card;
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	tavil = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-	tavil->entry = snd_info_create_subdir(codec_root->module,
-					      "tavil", codec_root);
-	if (!tavil->entry) {
-		dev_dbg(codec->dev, "%s: failed to create wcd934x entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   tavil->entry);
-	if (!version_entry) {
-		dev_dbg(codec->dev, "%s: failed to create wcd934x version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = tavil;
-	version_entry->size = TAVIL_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &tavil_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	tavil->version_entry = version_entry;
-
-	return 0;
-}
-EXPORT_SYMBOL(tavil_codec_info_create_codec_entry);
-
-/**
- * tavil_cdc_mclk_enable - Enable/disable codec mclk
- *
- * @codec: codec instance
- * @enable: Indicates clk enable or disable
- *
- * Returns 0 on Success and error on failure
- */
-int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	return __tavil_cdc_mclk_enable(tavil, enable);
-}
-EXPORT_SYMBOL(tavil_cdc_mclk_enable);
-
-static int __tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
-					   bool enable)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	if (enable) {
-		if (wcd_resmgr_get_clk_type(tavil->resmgr) ==
-		    WCD_CLK_RCO) {
-			ret = wcd_resmgr_enable_clk_block(tavil->resmgr,
-							  WCD_CLK_RCO);
-		} else {
-			ret = tavil_cdc_req_mclk_enable(tavil, true);
-			if (ret) {
-				dev_err(codec->dev,
-					"%s: mclk_enable failed, err = %d\n",
-					__func__, ret);
-				goto done;
-			}
-			wcd_resmgr_set_sido_input_src(tavil->resmgr,
-							SIDO_SOURCE_RCO_BG);
-			ret = wcd_resmgr_enable_clk_block(tavil->resmgr,
-							   WCD_CLK_RCO);
-			ret |= tavil_cdc_req_mclk_enable(tavil, false);
-		}
-
-	} else {
-		ret = wcd_resmgr_disable_clk_block(tavil->resmgr,
-						   WCD_CLK_RCO);
-	}
-
-	if (ret) {
-		dev_err(codec->dev, "%s: Error in %s RCO\n",
-			__func__, (enable ? "enabling" : "disabling"));
-		ret = -EINVAL;
-	}
-
-done:
-	return ret;
-}
-
-/*
- * tavil_codec_internal_rco_ctrl: Enable/Disable codec's RCO clock
- * @codec: Handle to the codec
- * @enable: Indicates whether clock should be enabled or disabled
- */
-static int tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
-					 bool enable)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-	int ret = 0;
-
-	WCD9XXX_V2_BG_CLK_LOCK(tavil->resmgr);
-	ret = __tavil_codec_internal_rco_ctrl(codec, enable);
-	WCD9XXX_V2_BG_CLK_UNLOCK(tavil->resmgr);
-	return ret;
-}
-
-/*
- * tavil_cdc_mclk_tx_enable: Enable/Disable codec's clock for TX path
- * @codec: Handle to codec
- * @enable: Indicates whether clock should be enabled or disabled
- */
-int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable)
-{
-	struct tavil_priv *tavil_p;
-	int ret = 0;
-	bool clk_mode;
-	bool clk_internal;
-
-	if (!codec)
-		return -EINVAL;
-
-	tavil_p = snd_soc_codec_get_drvdata(codec);
-	clk_mode = test_bit(CLK_MODE, &tavil_p->status_mask);
-	clk_internal = test_bit(CLK_INTERNAL, &tavil_p->status_mask);
-
-	dev_dbg(codec->dev, "%s: clkmode: %d, enable: %d, clk_internal: %d\n",
-		__func__, clk_mode, enable, clk_internal);
-
-	if (clk_mode || clk_internal) {
-		if (enable) {
-			wcd_resmgr_enable_master_bias(tavil_p->resmgr);
-			tavil_dig_core_power_collapse(tavil_p, POWER_RESUME);
-			tavil_vote_svs(tavil_p, true);
-			ret = tavil_codec_internal_rco_ctrl(codec, enable);
-			set_bit(CLK_INTERNAL, &tavil_p->status_mask);
-		} else {
-			clear_bit(CLK_INTERNAL, &tavil_p->status_mask);
-			tavil_codec_internal_rco_ctrl(codec, enable);
-			tavil_vote_svs(tavil_p, false);
-			tavil_dig_core_power_collapse(tavil_p, POWER_COLLAPSE);
-			wcd_resmgr_disable_master_bias(tavil_p->resmgr);
-		}
-	} else {
-		ret = __tavil_cdc_mclk_enable(tavil_p, enable);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(tavil_cdc_mclk_tx_enable);
-
-static const struct wcd_resmgr_cb tavil_resmgr_cb = {
-	.cdc_rco_ctrl = __tavil_codec_internal_rco_ctrl,
-};
-
-static const struct tavil_reg_mask_val tavil_codec_mclk2_1_1_defaults[] = {
-	{WCD934X_CLK_SYS_MCLK2_PRG1, 0x60, 0x20},
-};
-
-static const struct tavil_reg_mask_val tavil_codec_mclk2_1_0_defaults[] = {
-	/*
-	 * PLL Settings:
-	 * Clock Root: MCLK2,
-	 * Clock Source: EXT_CLK,
-	 * Clock Destination: MCLK2
-	 * Clock Freq In: 19.2MHz,
-	 * Clock Freq Out: 11.2896MHz
-	 */
-	{WCD934X_CLK_SYS_MCLK2_PRG1, 0x60, 0x20},
-	{WCD934X_CLK_SYS_INT_POST_DIV_REG0, 0xFF, 0x5E},
-	{WCD934X_CLK_SYS_INT_POST_DIV_REG1, 0x1F, 0x1F},
-	{WCD934X_CLK_SYS_INT_REF_DIV_REG0, 0xFF, 0x54},
-	{WCD934X_CLK_SYS_INT_REF_DIV_REG1, 0xFF, 0x01},
-	{WCD934X_CLK_SYS_INT_FILTER_REG1, 0x07, 0x04},
-	{WCD934X_CLK_SYS_INT_PLL_L_VAL, 0xFF, 0x93},
-	{WCD934X_CLK_SYS_INT_PLL_N_VAL, 0xFF, 0xFA},
-	{WCD934X_CLK_SYS_INT_TEST_REG0, 0xFF, 0x90},
-	{WCD934X_CLK_SYS_INT_PFD_CP_DSM_PROG, 0xFF, 0x7E},
-	{WCD934X_CLK_SYS_INT_VCO_PROG, 0xFF, 0xF8},
-	{WCD934X_CLK_SYS_INT_TEST_REG1, 0xFF, 0x68},
-	{WCD934X_CLK_SYS_INT_LDO_LOCK_CFG, 0xFF, 0x40},
-	{WCD934X_CLK_SYS_INT_DIG_LOCK_DET_CFG, 0xFF, 0x32},
-};
-
-static const struct tavil_reg_mask_val tavil_codec_reg_defaults[] = {
-	{WCD934X_BIAS_VBG_FINE_ADJ, 0xFF, 0x75},
-	{WCD934X_CODEC_CPR_SVS_CX_VDD, 0xFF, 0x7C}, /* value in svs mode */
-	{WCD934X_CODEC_CPR_SVS2_CX_VDD, 0xFF, 0x58}, /* value in svs2 mode */
-	{WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL, 0x01, 0x01},
-	{WCD934X_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
-	{WCD934X_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
-	{WCD934X_CDC_RX0_RX_PATH_SEC0, 0x08, 0x0},
-	{WCD934X_CDC_CLSH_DECAY_CTRL, 0x03, 0x0},
-	{WCD934X_MICB1_TEST_CTL_2, 0x07, 0x01},
-	{WCD934X_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
-	{WCD934X_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
-	{WCD934X_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
-	{WCD934X_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
-	{WCD934X_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD, 0x1F, 0x09},
-	{WCD934X_CDC_TX0_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX1_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX2_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX3_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX4_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX5_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX6_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX7_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_CDC_TX8_TX_PATH_CFG1, 0x01, 0x00},
-	{WCD934X_RX_OCP_CTL, 0x0F, 0x02}, /* OCP number of attempts is 2 */
-	{WCD934X_HPH_OCP_CTL, 0xFF, 0x3A}, /* OCP current limit */
-	{WCD934X_HPH_L_TEST, 0x01, 0x01},
-	{WCD934X_HPH_R_TEST, 0x01, 0x01},
-	{WCD934X_CPE_FLL_CONFIG_CTL_2, 0xFF, 0x20},
-	{WCD934X_MBHC_NEW_CTL_2, 0x0C, 0x00},
-};
-
-static const struct tavil_reg_mask_val tavil_codec_reg_init_1_1_val[] = {
-	{WCD934X_CDC_COMPANDER1_CTL7, 0x1E, 0x06},
-	{WCD934X_CDC_COMPANDER2_CTL7, 0x1E, 0x06},
-	{WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0xFF, 0x84},
-	{WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0xFF, 0x84},
-	{WCD934X_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
-	{WCD934X_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
-};
-
-static const struct tavil_cpr_reg_defaults cpr_defaults[] = {
-	{ 0x00000820, 0x00000094 },
-	{ 0x00000fC0, 0x00000048 },
-	{ 0x0000f000, 0x00000044 },
-	{ 0x0000bb80, 0xC0000178 },
-	{ 0x00000000, 0x00000160 },
-	{ 0x10854522, 0x00000060 },
-	{ 0x10854509, 0x00000064 },
-	{ 0x108544dd, 0x00000068 },
-	{ 0x108544ad, 0x0000006C },
-	{ 0x0000077E, 0x00000070 },
-	{ 0x000007da, 0x00000074 },
-	{ 0x00000000, 0x00000078 },
-	{ 0x00000000, 0x0000007C },
-	{ 0x00042029, 0x00000080 },
-	{ 0x4002002A, 0x00000090 },
-	{ 0x4002002B, 0x00000090 },
-};
-
-static const struct tavil_reg_mask_val tavil_codec_reg_init_common_val[] = {
-	{WCD934X_CDC_CLSH_K2_MSB, 0x0F, 0x00},
-	{WCD934X_CDC_CLSH_K2_LSB, 0xFF, 0x60},
-	{WCD934X_CPE_SS_DMIC_CFG, 0x80, 0x00},
-	{WCD934X_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
-	{WCD934X_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
-	{WCD934X_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
-	{WCD934X_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
-	{WCD934X_CDC_TOP_TOP_CFG1, 0x02, 0x02},
-	{WCD934X_CDC_TOP_TOP_CFG1, 0x01, 0x01},
-	{WCD934X_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD934X_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD934X_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD934X_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
-	{WCD934X_DATA_HUB_SB_TX11_INP_CFG, 0x01, 0x01},
-	{WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x01, 0x01},
-	{WCD934X_CDC_COMPANDER7_CTL3, 0x80, 0x80},
-	{WCD934X_CDC_COMPANDER8_CTL3, 0x80, 0x80},
-	{WCD934X_CDC_COMPANDER7_CTL7, 0x01, 0x01},
-	{WCD934X_CDC_COMPANDER8_CTL7, 0x01, 0x01},
-	{WCD934X_CODEC_RPM_CLK_GATE, 0x08, 0x00},
-	{WCD934X_TLMM_DMIC3_CLK_PINCFG, 0xFF, 0x0a},
-	{WCD934X_TLMM_DMIC3_DATA_PINCFG, 0xFF, 0x0a},
-	{WCD934X_CPE_SS_SVA_CFG, 0x60, 0x00},
-	{WCD934X_CPE_SS_CPAR_CFG, 0x10, 0x10},
-};
-
-static void tavil_codec_init_reg(struct tavil_priv *priv)
-{
-	struct snd_soc_codec *codec = priv->codec;
-	u32 i;
-
-	for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_common_val); i++)
-		snd_soc_update_bits(codec,
-				    tavil_codec_reg_init_common_val[i].reg,
-				    tavil_codec_reg_init_common_val[i].mask,
-				    tavil_codec_reg_init_common_val[i].val);
-
-	if (TAVIL_IS_1_1(priv->wcd9xxx)) {
-		for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_1_1_val); i++)
-			snd_soc_update_bits(codec,
-					tavil_codec_reg_init_1_1_val[i].reg,
-					tavil_codec_reg_init_1_1_val[i].mask,
-					tavil_codec_reg_init_1_1_val[i].val);
-	}
-}
-
-static void tavil_update_reg_defaults(struct tavil_priv *tavil)
-{
-	u32 i;
-	struct wcd9xxx *wcd9xxx;
-
-	wcd9xxx = tavil->wcd9xxx;
-	for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_defaults); i++)
-		regmap_update_bits(wcd9xxx->regmap,
-				   tavil_codec_reg_defaults[i].reg,
-				   tavil_codec_reg_defaults[i].mask,
-				   tavil_codec_reg_defaults[i].val);
-}
-
-static void tavil_update_cpr_defaults(struct tavil_priv *tavil)
-{
-	int i;
-	struct wcd9xxx *wcd9xxx;
-
-	wcd9xxx = tavil->wcd9xxx;
-	if (!TAVIL_IS_1_1(wcd9xxx))
-		return;
-
-	__tavil_cdc_mclk_enable(tavil, true);
-
-	regmap_write(wcd9xxx->regmap, WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD, 0x2C);
-	regmap_update_bits(wcd9xxx->regmap, WCD934X_CODEC_RPM_CLK_GATE,
-			   0x10, 0x00);
-
-	for (i = 0; i < ARRAY_SIZE(cpr_defaults); i++) {
-		regmap_bulk_write(wcd9xxx->regmap,
-				WCD934X_CODEC_CPR_WR_DATA_0,
-				(u8 *)&cpr_defaults[i].wr_data, 4);
-		regmap_bulk_write(wcd9xxx->regmap,
-				WCD934X_CODEC_CPR_WR_ADDR_0,
-				(u8 *)&cpr_defaults[i].wr_addr, 4);
-	}
-
-	__tavil_cdc_mclk_enable(tavil, false);
-}
-
-static void tavil_slim_interface_init_reg(struct snd_soc_codec *codec)
-{
-	int i;
-	struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec);
-
-	for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
-		wcd9xxx_interface_reg_write(priv->wcd9xxx,
-				    WCD934X_SLIM_PGD_PORT_INT_RX_EN0 + i,
-				    0xFF);
-}
-
-static irqreturn_t tavil_misc_irq(int irq, void *data)
-{
-	struct tavil_priv *tavil = data;
-	int misc_val;
-
-	/* Find source of interrupt */
-	regmap_read(tavil->wcd9xxx->regmap, WCD934X_INTR_CODEC_MISC_STATUS,
-		    &misc_val);
-
-	if (misc_val & 0x08) {
-		dev_info(tavil->dev, "%s: irq: %d, DSD DC detected!\n",
-			 __func__, irq);
-		/* DSD DC interrupt, reset DSD path */
-		tavil_dsd_reset(tavil->dsd_config);
-	} else {
-		dev_err(tavil->dev, "%s: Codec misc irq: %d, val: 0x%x\n",
-			__func__, irq, misc_val);
-	}
-
-	/* Clear interrupt status */
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			   WCD934X_INTR_CODEC_MISC_CLEAR, misc_val, 0x00);
-
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t tavil_slimbus_irq(int irq, void *data)
-{
-	struct tavil_priv *tavil = data;
-	unsigned long status = 0;
-	int i, j, port_id, k;
-	u32 bit;
-	u8 val, int_val = 0;
-	bool tx, cleared;
-	unsigned short reg = 0;
-
-	for (i = WCD934X_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
-	     i <= WCD934X_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
-		val = wcd9xxx_interface_reg_read(tavil->wcd9xxx, i);
-		status |= ((u32)val << (8 * j));
-	}
-
-	for_each_set_bit(j, &status, 32) {
-		tx = (j >= 16 ? true : false);
-		port_id = (tx ? j - 16 : j);
-		val = wcd9xxx_interface_reg_read(tavil->wcd9xxx,
-				WCD934X_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
-		if (val) {
-			if (!tx)
-				reg = WCD934X_SLIM_PGD_PORT_INT_RX_EN0 +
-					(port_id / 8);
-			else
-				reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 +
-					(port_id / 8);
-			int_val = wcd9xxx_interface_reg_read(
-				tavil->wcd9xxx, reg);
-			/*
-			 * Ignore interrupts for ports for which the
-			 * interrupts are not specifically enabled.
-			 */
-			if (!(int_val & (1 << (port_id % 8))))
-				continue;
-		}
-		if (val & WCD934X_SLIM_IRQ_OVERFLOW)
-			dev_err_ratelimited(tavil->dev, "%s: overflow error on %s port %d, value %x\n",
-			   __func__, (tx ? "TX" : "RX"), port_id, val);
-		if (val & WCD934X_SLIM_IRQ_UNDERFLOW)
-			dev_err_ratelimited(tavil->dev, "%s: underflow error on %s port %d, value %x\n",
-			   __func__, (tx ? "TX" : "RX"), port_id, val);
-		if ((val & WCD934X_SLIM_IRQ_OVERFLOW) ||
-			(val & WCD934X_SLIM_IRQ_UNDERFLOW)) {
-			if (!tx)
-				reg = WCD934X_SLIM_PGD_PORT_INT_RX_EN0 +
-					(port_id / 8);
-			else
-				reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 +
-					(port_id / 8);
-			int_val = wcd9xxx_interface_reg_read(
-				tavil->wcd9xxx, reg);
-			if (int_val & (1 << (port_id % 8))) {
-				int_val = int_val ^ (1 << (port_id % 8));
-				wcd9xxx_interface_reg_write(tavil->wcd9xxx,
-					reg, int_val);
-			}
-		}
-		if (val & WCD934X_SLIM_IRQ_PORT_CLOSED) {
-			/*
-			 * INT SOURCE register starts from RX to TX
-			 * but port number in the ch_mask is in opposite way
-			 */
-			bit = (tx ? j - 16 : j + 16);
-			dev_dbg(tavil->dev, "%s: %s port %d closed value %x, bit %u\n",
-				 __func__, (tx ? "TX" : "RX"), port_id, val,
-				 bit);
-			for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
-				dev_dbg(tavil->dev, "%s: tavil->dai[%d].ch_mask = 0x%lx\n",
-					 __func__, k, tavil->dai[k].ch_mask);
-				if (test_and_clear_bit(bit,
-						&tavil->dai[k].ch_mask)) {
-					cleared = true;
-					if (!tavil->dai[k].ch_mask)
-						wake_up(
-						      &tavil->dai[k].dai_wait);
-					/*
-					 * There are cases when multiple DAIs
-					 * might be using the same slimbus
-					 * channel. Hence don't break here.
-					 */
-				}
-			}
-			WARN(!cleared,
-			     "Couldn't find slimbus %s port %d for closing\n",
-			     (tx ? "TX" : "RX"), port_id);
-		}
-		wcd9xxx_interface_reg_write(tavil->wcd9xxx,
-					    WCD934X_SLIM_PGD_PORT_INT_CLR_RX_0 +
-					    (j / 8),
-					    1 << (j % 8));
-	}
-
-	return IRQ_HANDLED;
-}
-
-static int tavil_setup_irqs(struct tavil_priv *tavil)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = tavil->codec;
-	struct wcd9xxx *wcd9xxx = tavil->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
-				  tavil_slimbus_irq, "SLIMBUS Slave", tavil);
-	if (ret)
-		dev_err(codec->dev, "%s: Failed to request irq %d\n", __func__,
-		       WCD9XXX_IRQ_SLIMBUS);
-	else
-		tavil_slim_interface_init_reg(codec);
-
-	/* Register for misc interrupts as well */
-	ret = wcd9xxx_request_irq(core_res, WCD934X_IRQ_MISC,
-				  tavil_misc_irq, "CDC MISC Irq", tavil);
-	if (ret)
-		dev_err(codec->dev, "%s: Failed to request cdc misc irq\n",
-			__func__);
-
-	return ret;
-}
-
-static void tavil_init_slim_slave_cfg(struct snd_soc_codec *codec)
-{
-	struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec);
-	struct afe_param_cdc_slimbus_slave_cfg *cfg;
-	struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
-	uint64_t eaddr = 0;
-
-	cfg = &priv->slimbus_slave_cfg;
-	cfg->minor_version = 1;
-	cfg->tx_slave_port_offset = 0;
-	cfg->rx_slave_port_offset = 16;
-
-	memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
-	WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
-	cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
-	cfg->device_enum_addr_msw = eaddr >> 32;
-
-	dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
-		__func__, eaddr);
-}
-
-static void tavil_cleanup_irqs(struct tavil_priv *tavil)
-{
-	struct wcd9xxx *wcd9xxx = tavil->wcd9xxx;
-	struct wcd9xxx_core_resource *core_res =
-				&wcd9xxx->core_res;
-
-	wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tavil);
-	wcd9xxx_free_irq(core_res, WCD934X_IRQ_MISC, tavil);
-}
-
-/*
- * wcd934x_get_micb_vout_ctl_val: converts micbias from volts to register value
- * @micb_mv: micbias in mv
- *
- * return register value converted
- */
-int wcd934x_get_micb_vout_ctl_val(u32 micb_mv)
-{
-	/* min micbias voltage is 1V and maximum is 2.85V */
-	if (micb_mv < 1000 || micb_mv > 2850) {
-		pr_err("%s: unsupported micbias voltage\n", __func__);
-		return -EINVAL;
-	}
-
-	return (micb_mv - 1000) / 50;
-}
-EXPORT_SYMBOL(wcd934x_get_micb_vout_ctl_val);
-
-static int tavil_handle_pdata(struct tavil_priv *tavil,
-			      struct wcd9xxx_pdata *pdata)
-{
-	struct snd_soc_codec *codec = tavil->codec;
-	u8 mad_dmic_ctl_val;
-	u8 anc_ctl_value;
-	u32 def_dmic_rate, dmic_clk_drv;
-	int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
-	int rc = 0;
-
-	if (!pdata) {
-		dev_err(codec->dev, "%s: NULL pdata\n", __func__);
-		return -ENODEV;
-	}
-
-	/* set micbias voltage */
-	vout_ctl_1 = wcd934x_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
-	vout_ctl_2 = wcd934x_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
-	vout_ctl_3 = wcd934x_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
-	vout_ctl_4 = wcd934x_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
-	if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
-	    vout_ctl_3 < 0 || vout_ctl_4 < 0) {
-		rc = -EINVAL;
-		goto done;
-	}
-	snd_soc_update_bits(codec, WCD934X_ANA_MICB1, 0x3F, vout_ctl_1);
-	snd_soc_update_bits(codec, WCD934X_ANA_MICB2, 0x3F, vout_ctl_2);
-	snd_soc_update_bits(codec, WCD934X_ANA_MICB3, 0x3F, vout_ctl_3);
-	snd_soc_update_bits(codec, WCD934X_ANA_MICB4, 0x3F, vout_ctl_4);
-
-	/* Set the DMIC sample rate */
-	switch (pdata->mclk_rate) {
-	case WCD934X_MCLK_CLK_9P6MHZ:
-		def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
-		break;
-	case WCD934X_MCLK_CLK_12P288MHZ:
-		def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
-		break;
-	default:
-		/* should never happen */
-		dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
-			__func__, pdata->mclk_rate);
-		rc = -EINVAL;
-		goto done;
-	};
-
-	if (pdata->dmic_sample_rate ==
-	    WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
-		dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
-			__func__, def_dmic_rate);
-		pdata->dmic_sample_rate = def_dmic_rate;
-	}
-	if (pdata->mad_dmic_sample_rate ==
-	    WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
-		dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
-			__func__, def_dmic_rate);
-		/*
-		 * use dmic_sample_rate as the default for MAD
-		 * if mad dmic sample rate is undefined
-		 */
-		pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
-	}
-
-	if (pdata->dmic_clk_drv ==
-	    WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
-		pdata->dmic_clk_drv = WCD934X_DMIC_CLK_DRIVE_DEFAULT;
-		dev_dbg(codec->dev,
-			 "%s: dmic_clk_strength invalid, default = %d\n",
-			 __func__, pdata->dmic_clk_drv);
-	}
-
-	switch (pdata->dmic_clk_drv) {
-	case 2:
-		dmic_clk_drv = 0;
-		break;
-	case 4:
-		dmic_clk_drv = 1;
-		break;
-	case 8:
-		dmic_clk_drv = 2;
-		break;
-	case 16:
-		dmic_clk_drv = 3;
-		break;
-	default:
-		dev_err(codec->dev,
-			"%s: invalid dmic_clk_drv %d, using default\n",
-			__func__, pdata->dmic_clk_drv);
-		dmic_clk_drv = 0;
-		break;
-	}
-
-	snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_PAD_DRVCTL_0,
-			    0x0C, dmic_clk_drv << 2);
-
-	/*
-	 * Default the DMIC clk rates to mad_dmic_sample_rate,
-	 * whereas, the anc/txfe dmic rates to dmic_sample_rate
-	 * since the anc/txfe are independent of mad block.
-	 */
-	mad_dmic_ctl_val = tavil_get_dmic_clk_val(tavil->codec,
-				pdata->mclk_rate,
-				pdata->mad_dmic_sample_rate);
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC0_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC1_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-	snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC2_CTL,
-		0x0E, mad_dmic_ctl_val << 1);
-
-	if (dmic_clk_drv == WCD934X_DMIC_CLK_DIV_2)
-		anc_ctl_value = WCD934X_ANC_DMIC_X2_FULL_RATE;
-	else
-		anc_ctl_value = WCD934X_ANC_DMIC_X2_HALF_RATE;
-
-	snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_2_CTL,
-			    0x40, anc_ctl_value << 6);
-	snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_2_CTL,
-			    0x20, anc_ctl_value << 5);
-	snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_2_CTL,
-			    0x40, anc_ctl_value << 6);
-	snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_2_CTL,
-			    0x20, anc_ctl_value << 5);
-
-done:
-	return rc;
-}
-
-static void tavil_cdc_vote_svs(struct snd_soc_codec *codec, bool vote)
-{
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	return tavil_vote_svs(tavil, vote);
-}
-
-struct wcd_dsp_cdc_cb cdc_cb = {
-	.cdc_clk_en = tavil_codec_internal_rco_ctrl,
-	.cdc_vote_svs = tavil_cdc_vote_svs,
-};
-
-static int tavil_wdsp_initialize(struct snd_soc_codec *codec)
-{
-	struct wcd9xxx *control;
-	struct tavil_priv *tavil;
-	struct wcd_dsp_params params;
-	int ret = 0;
-
-	control = dev_get_drvdata(codec->dev->parent);
-	tavil = snd_soc_codec_get_drvdata(codec);
-
-	params.cb = &cdc_cb;
-	params.irqs.cpe_ipc1_irq = WCD934X_IRQ_CPE1_INTR;
-	params.irqs.cpe_err_irq = WCD934X_IRQ_CPE_ERROR;
-	params.irqs.fatal_irqs = CPE_FATAL_IRQS;
-	params.clk_rate = control->mclk_rate;
-	params.dsp_instance = 0;
-
-	wcd_dsp_cntl_init(codec, &params, &tavil->wdsp_cntl);
-	if (!tavil->wdsp_cntl) {
-		dev_err(tavil->dev, "%s: wcd-dsp-control init failed\n",
-			__func__);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-/*
- * tavil_soc_get_mbhc: get wcd934x_mbhc handle of corresponding codec
- * @codec: handle to snd_soc_codec *
- *
- * return wcd934x_mbhc handle or error code in case of failure
- */
-struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec)
-{
-	struct tavil_priv *tavil;
-
-	if (!codec) {
-		pr_err("%s: Invalid params, NULL codec\n", __func__);
-		return NULL;
-	}
-	tavil = snd_soc_codec_get_drvdata(codec);
-
-	if (!tavil) {
-		pr_err("%s: Invalid params, NULL tavil\n", __func__);
-		return NULL;
-	}
-
-	return tavil->mbhc;
-}
-EXPORT_SYMBOL(tavil_soc_get_mbhc);
-
-static void tavil_mclk2_reg_defaults(struct tavil_priv *tavil)
-{
-	int i;
-	struct snd_soc_codec *codec = tavil->codec;
-
-	if (TAVIL_IS_1_0(tavil->wcd9xxx)) {
-		/* MCLK2 configuration */
-		for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_0_defaults); i++)
-			snd_soc_update_bits(codec,
-					tavil_codec_mclk2_1_0_defaults[i].reg,
-					tavil_codec_mclk2_1_0_defaults[i].mask,
-					tavil_codec_mclk2_1_0_defaults[i].val);
-	}
-	if (TAVIL_IS_1_1(tavil->wcd9xxx)) {
-		/* MCLK2 configuration */
-		for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_1_defaults); i++)
-			snd_soc_update_bits(codec,
-					tavil_codec_mclk2_1_1_defaults[i].reg,
-					tavil_codec_mclk2_1_1_defaults[i].mask,
-					tavil_codec_mclk2_1_1_defaults[i].val);
-	}
-}
-
-static int tavil_device_down(struct wcd9xxx *wcd9xxx)
-{
-	struct snd_soc_codec *codec;
-	struct tavil_priv *priv;
-	int count;
-
-	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
-	priv = snd_soc_codec_get_drvdata(codec);
-	if (priv->swr.ctrl_data)
-		swrm_wcd_notify(priv->swr.ctrl_data[0].swr_pdev,
-				SWR_DEVICE_DOWN, NULL);
-	tavil_dsd_reset(priv->dsd_config);
-	snd_soc_card_change_online_state(codec->component.card, 0);
-	for (count = 0; count < NUM_CODEC_DAIS; count++)
-		priv->dai[count].bus_down_in_recovery = true;
-	wcd_dsp_ssr_event(priv->wdsp_cntl, WCD_CDC_DOWN_EVENT);
-	wcd_resmgr_set_sido_input_src_locked(priv->resmgr,
-					     SIDO_SOURCE_INTERNAL);
-
-	return 0;
-}
-
-static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx)
-{
-	int i, ret = 0;
-	struct wcd9xxx *control;
-	struct snd_soc_codec *codec;
-	struct tavil_priv *tavil;
-	struct wcd9xxx_pdata *pdata;
-	struct wcd_mbhc *mbhc;
-
-	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
-	tavil = snd_soc_codec_get_drvdata(codec);
-	control = dev_get_drvdata(codec->dev->parent);
-
-	wcd9xxx_set_power_state(tavil->wcd9xxx,
-				WCD_REGION_POWER_COLLAPSE_REMOVE,
-				WCD9XXX_DIG_CORE_REGION_1);
-
-	mutex_lock(&tavil->codec_mutex);
-
-	tavil_vote_svs(tavil, true);
-	tavil_slimbus_slave_port_cfg.slave_dev_intfdev_la =
-				control->slim_slave->laddr;
-	tavil_slimbus_slave_port_cfg.slave_dev_pgd_la =
-					control->slim->laddr;
-	tavil_init_slim_slave_cfg(codec);
-	snd_soc_card_change_online_state(codec->component.card, 1);
-
-	for (i = 0; i < TAVIL_MAX_MICBIAS; i++)
-		tavil->micb_ref[i] = 0;
-
-	dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
-		__func__, control->mclk_rate);
-
-	if (control->mclk_rate == WCD934X_MCLK_CLK_12P288MHZ)
-		snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x00);
-	else if (control->mclk_rate == WCD934X_MCLK_CLK_9P6MHZ)
-		snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-				    0x03, 0x01);
-	wcd_resmgr_post_ssr_v2(tavil->resmgr);
-	tavil_update_reg_defaults(tavil);
-	tavil_codec_init_reg(tavil);
-	__tavil_enable_efuse_sensing(tavil);
-	tavil_mclk2_reg_defaults(tavil);
-
-	__tavil_cdc_mclk_enable(tavil, true);
-	regcache_mark_dirty(codec->component.regmap);
-	regcache_sync(codec->component.regmap);
-	__tavil_cdc_mclk_enable(tavil, false);
-
-	tavil_update_cpr_defaults(tavil);
-
-	pdata = dev_get_platdata(codec->dev->parent);
-	ret = tavil_handle_pdata(tavil, pdata);
-	if (ret < 0)
-		dev_err(codec->dev, "%s: invalid pdata\n", __func__);
-
-	/* Initialize MBHC module */
-	mbhc = &tavil->mbhc->wcd_mbhc;
-	ret = tavil_mbhc_post_ssr_init(tavil->mbhc, codec);
-	if (ret) {
-		dev_err(codec->dev, "%s: mbhc initialization failed\n",
-			__func__);
-		goto done;
-	} else {
-		tavil_mbhc_hs_detect(codec, mbhc->mbhc_cfg);
-	}
-
-	/* DSD initialization */
-	ret = tavil_dsd_post_ssr_init(tavil->dsd_config);
-	if (ret)
-		dev_dbg(tavil->dev, "%s: DSD init failed\n", __func__);
-
-	tavil_cleanup_irqs(tavil);
-	ret = tavil_setup_irqs(tavil);
-	if (ret) {
-		dev_err(codec->dev, "%s: tavil irq setup failed %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	tavil_set_spkr_mode(codec, tavil->swr.spkr_mode);
-	/*
-	 * Once the codec initialization is completed, the svs vote
-	 * can be released allowing the codec to go to SVS2.
-	 */
-	tavil_vote_svs(tavil, false);
-	wcd_dsp_ssr_event(tavil->wdsp_cntl, WCD_CDC_UP_EVENT);
-
-done:
-	mutex_unlock(&tavil->codec_mutex);
-	return ret;
-}
-
-static int tavil_soc_codec_probe(struct snd_soc_codec *codec)
-{
-	struct wcd9xxx *control;
-	struct tavil_priv *tavil;
-	struct wcd9xxx_pdata *pdata;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	int i, ret;
-	void *ptr = NULL;
-
-	control = dev_get_drvdata(codec->dev->parent);
-
-	dev_info(codec->dev, "%s()\n", __func__);
-	tavil = snd_soc_codec_get_drvdata(codec);
-	tavil->intf_type = wcd9xxx_get_intf_type();
-
-	control->dev_down = tavil_device_down;
-	control->post_reset = tavil_post_reset_cb;
-	control->ssr_priv = (void *)codec;
-
-	/* Resource Manager post Init */
-	ret = wcd_resmgr_post_init(tavil->resmgr, &tavil_resmgr_cb, codec);
-	if (ret) {
-		dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
-			__func__);
-		goto err;
-	}
-	/* Class-H Init */
-	wcd_clsh_init(&tavil->clsh_d);
-	/* Default HPH Mode to Class-H Low HiFi */
-	tavil->hph_mode = CLS_H_LOHIFI;
-
-	tavil->fw_data = devm_kzalloc(codec->dev, sizeof(*(tavil->fw_data)),
-				      GFP_KERNEL);
-	if (!tavil->fw_data)
-		goto err;
-
-	set_bit(WCD9XXX_ANC_CAL, tavil->fw_data->cal_bit);
-	set_bit(WCD9XXX_MBHC_CAL, tavil->fw_data->cal_bit);
-	set_bit(WCD9XXX_MAD_CAL, tavil->fw_data->cal_bit);
-	set_bit(WCD9XXX_VBAT_CAL, tavil->fw_data->cal_bit);
-
-	ret = wcd_cal_create_hwdep(tavil->fw_data,
-				   WCD9XXX_CODEC_HWDEP_NODE, codec);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
-		goto err_hwdep;
-	}
-
-	/* Initialize MBHC module */
-	ret = tavil_mbhc_init(&tavil->mbhc, codec, tavil->fw_data);
-	if (ret) {
-		pr_err("%s: mbhc initialization failed\n", __func__);
-		goto err_hwdep;
-	}
-
-	tavil->codec = codec;
-	for (i = 0; i < COMPANDER_MAX; i++)
-		tavil->comp_enabled[i] = 0;
-
-	tavil_codec_init_reg(tavil);
-
-	pdata = dev_get_platdata(codec->dev->parent);
-	ret = tavil_handle_pdata(tavil, pdata);
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: bad pdata\n", __func__);
-		goto err_hwdep;
-	}
-
-	ptr = devm_kzalloc(codec->dev, (sizeof(tavil_rx_chs) +
-			   sizeof(tavil_tx_chs)), GFP_KERNEL);
-	if (!ptr) {
-		ret = -ENOMEM;
-		goto err_hwdep;
-	}
-
-	snd_soc_dapm_add_routes(dapm, tavil_slim_audio_map,
-			ARRAY_SIZE(tavil_slim_audio_map));
-	for (i = 0; i < NUM_CODEC_DAIS; i++) {
-		INIT_LIST_HEAD(&tavil->dai[i].wcd9xxx_ch_list);
-		init_waitqueue_head(&tavil->dai[i].dai_wait);
-	}
-	tavil_slimbus_slave_port_cfg.slave_dev_intfdev_la =
-				control->slim_slave->laddr;
-	tavil_slimbus_slave_port_cfg.slave_dev_pgd_la =
-				control->slim->laddr;
-	tavil_slimbus_slave_port_cfg.slave_port_mapping[0] =
-				WCD934X_TX13;
-	tavil_init_slim_slave_cfg(codec);
-
-	control->num_rx_port = WCD934X_RX_MAX;
-	control->rx_chs = ptr;
-	memcpy(control->rx_chs, tavil_rx_chs, sizeof(tavil_rx_chs));
-	control->num_tx_port = WCD934X_TX_MAX;
-	control->tx_chs = ptr + sizeof(tavil_rx_chs);
-	memcpy(control->tx_chs, tavil_tx_chs, sizeof(tavil_tx_chs));
-
-	ret = tavil_setup_irqs(tavil);
-	if (ret) {
-		dev_err(tavil->dev, "%s: tavil irq setup failed %d\n",
-			__func__, ret);
-		goto err_pdata;
-	}
-
-	for (i = 0; i < WCD934X_NUM_DECIMATORS; i++) {
-		tavil->tx_hpf_work[i].tavil = tavil;
-		tavil->tx_hpf_work[i].decimator = i;
-		INIT_DELAYED_WORK(&tavil->tx_hpf_work[i].dwork,
-				  tavil_tx_hpf_corner_freq_callback);
-
-		tavil->tx_mute_dwork[i].tavil = tavil;
-		tavil->tx_mute_dwork[i].decimator = i;
-		INIT_DELAYED_WORK(&tavil->tx_mute_dwork[i].dwork,
-				  tavil_tx_mute_update_callback);
-	}
-
-	tavil->spk_anc_dwork.tavil = tavil;
-	INIT_DELAYED_WORK(&tavil->spk_anc_dwork.dwork,
-			  tavil_spk_anc_update_callback);
-
-	tavil_mclk2_reg_defaults(tavil);
-
-	/* DSD initialization */
-	tavil->dsd_config = tavil_dsd_init(codec);
-	if (IS_ERR_OR_NULL(tavil->dsd_config))
-		dev_dbg(tavil->dev, "%s: DSD init failed\n", __func__);
-
-	mutex_lock(&tavil->codec_mutex);
-	snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC EAR");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
-	snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
-	snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
-	mutex_unlock(&tavil->codec_mutex);
-
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
-	snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
-
-	snd_soc_dapm_sync(dapm);
-
-	tavil_wdsp_initialize(codec);
-
-	/*
-	 * Once the codec initialization is completed, the svs vote
-	 * can be released allowing the codec to go to SVS2.
-	 */
-	tavil_vote_svs(tavil, false);
-
-	return ret;
-
-err_pdata:
-	devm_kfree(codec->dev, ptr);
-	control->rx_chs = NULL;
-	control->tx_chs = NULL;
-err_hwdep:
-	devm_kfree(codec->dev, tavil->fw_data);
-	tavil->fw_data = NULL;
-err:
-	return ret;
-}
-
-static int tavil_soc_codec_remove(struct snd_soc_codec *codec)
-{
-	struct wcd9xxx *control;
-	struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec);
-
-	control = dev_get_drvdata(codec->dev->parent);
-	devm_kfree(codec->dev, control->rx_chs);
-	/* slimslave deinit in wcd core looks for this value */
-	control->num_rx_port = 0;
-	control->num_tx_port = 0;
-	control->rx_chs = NULL;
-	control->tx_chs = NULL;
-	tavil_cleanup_irqs(tavil);
-
-	if (tavil->wdsp_cntl)
-		wcd_dsp_cntl_deinit(&tavil->wdsp_cntl);
-
-	/* Deinitialize MBHC module */
-	tavil_mbhc_deinit(codec);
-	tavil->mbhc = NULL;
-
-	return 0;
-}
-
-static struct regmap *tavil_get_regmap(struct device *dev)
-{
-	struct wcd9xxx *control = dev_get_drvdata(dev->parent);
-
-	return control->regmap;
-}
-
-static struct snd_soc_codec_driver soc_codec_dev_tavil = {
-	.probe = tavil_soc_codec_probe,
-	.remove = tavil_soc_codec_remove,
-	.get_regmap = tavil_get_regmap,
-	.component_driver = {
-		.controls = tavil_snd_controls,
-		.num_controls = ARRAY_SIZE(tavil_snd_controls),
-		.dapm_widgets = tavil_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(tavil_dapm_widgets),
-		.dapm_routes = tavil_audio_map,
-		.num_dapm_routes = ARRAY_SIZE(tavil_audio_map),
-	},
-};
-
-#ifdef CONFIG_PM
-static int tavil_suspend(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tavil_priv *tavil = platform_get_drvdata(pdev);
-
-	if (!tavil) {
-		dev_err(dev, "%s: tavil private data is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_dbg(dev, "%s: system suspend\n", __func__);
-	if (delayed_work_pending(&tavil->power_gate_work) &&
-	    cancel_delayed_work_sync(&tavil->power_gate_work))
-		tavil_codec_power_gate_digital_core(tavil);
-	return 0;
-}
-
-static int tavil_resume(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tavil_priv *tavil = platform_get_drvdata(pdev);
-
-	if (!tavil) {
-		dev_err(dev, "%s: tavil private data is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_dbg(dev, "%s: system resume\n", __func__);
-	return 0;
-}
-
-static const struct dev_pm_ops tavil_pm_ops = {
-	.suspend = tavil_suspend,
-	.resume = tavil_resume,
-};
-#endif
-
-static int tavil_swrm_read(void *handle, int reg)
-{
-	struct tavil_priv *tavil;
-	struct wcd9xxx *wcd9xxx;
-	unsigned short swr_rd_addr_base;
-	unsigned short swr_rd_data_base;
-	int val, ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tavil = (struct tavil_priv *)handle;
-	wcd9xxx = tavil->wcd9xxx;
-
-	dev_dbg(tavil->dev, "%s: Reading soundwire register, 0x%x\n",
-		__func__, reg);
-	swr_rd_addr_base = WCD934X_SWR_AHB_BRIDGE_RD_ADDR_0;
-	swr_rd_data_base = WCD934X_SWR_AHB_BRIDGE_RD_DATA_0;
-
-	mutex_lock(&tavil->swr.read_mutex);
-	ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
-				 (u8 *)&reg, 4);
-	if (ret < 0) {
-		dev_err(tavil->dev, "%s: RD Addr Failure\n", __func__);
-		goto done;
-	}
-	ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
-				(u8 *)&val, 4);
-	if (ret < 0) {
-		dev_err(tavil->dev, "%s: RD Data Failure\n", __func__);
-		goto done;
-	}
-	ret = val;
-done:
-	mutex_unlock(&tavil->swr.read_mutex);
-
-	return ret;
-}
-
-static int tavil_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
-{
-	struct tavil_priv *tavil;
-	struct wcd9xxx *wcd9xxx;
-	struct wcd9xxx_reg_val *bulk_reg;
-	unsigned short swr_wr_addr_base;
-	unsigned short swr_wr_data_base;
-	int i, j, ret;
-
-	if (!handle || !reg || !val) {
-		pr_err("%s: NULL parameter\n", __func__);
-		return -EINVAL;
-	}
-	if (len <= 0) {
-		pr_err("%s: Invalid size: %zu\n", __func__, len);
-		return -EINVAL;
-	}
-	tavil = (struct tavil_priv *)handle;
-	wcd9xxx = tavil->wcd9xxx;
-
-	swr_wr_addr_base = WCD934X_SWR_AHB_BRIDGE_WR_ADDR_0;
-	swr_wr_data_base = WCD934X_SWR_AHB_BRIDGE_WR_DATA_0;
-
-	bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
-			   GFP_KERNEL);
-	if (!bulk_reg)
-		return -ENOMEM;
-
-	for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
-		bulk_reg[i].reg = swr_wr_data_base;
-		bulk_reg[i].buf = (u8 *)(&val[j]);
-		bulk_reg[i].bytes = 4;
-		bulk_reg[i+1].reg = swr_wr_addr_base;
-		bulk_reg[i+1].buf = (u8 *)(&reg[j]);
-		bulk_reg[i+1].bytes = 4;
-	}
-
-	mutex_lock(&tavil->swr.write_mutex);
-	ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
-			 (len * 2), false);
-	if (ret) {
-		dev_err(tavil->dev, "%s: swrm bulk write failed, ret: %d\n",
-			__func__, ret);
-	}
-	mutex_unlock(&tavil->swr.write_mutex);
-
-	kfree(bulk_reg);
-	return ret;
-}
-
-static int tavil_swrm_write(void *handle, int reg, int val)
-{
-	struct tavil_priv *tavil;
-	struct wcd9xxx *wcd9xxx;
-	unsigned short swr_wr_addr_base;
-	unsigned short swr_wr_data_base;
-	struct wcd9xxx_reg_val bulk_reg[2];
-	int ret;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tavil = (struct tavil_priv *)handle;
-	wcd9xxx = tavil->wcd9xxx;
-
-	swr_wr_addr_base = WCD934X_SWR_AHB_BRIDGE_WR_ADDR_0;
-	swr_wr_data_base = WCD934X_SWR_AHB_BRIDGE_WR_DATA_0;
-
-	/* First Write the Data to register */
-	bulk_reg[0].reg = swr_wr_data_base;
-	bulk_reg[0].buf = (u8 *)(&val);
-	bulk_reg[0].bytes = 4;
-	bulk_reg[1].reg = swr_wr_addr_base;
-	bulk_reg[1].buf = (u8 *)(&reg);
-	bulk_reg[1].bytes = 4;
-
-	mutex_lock(&tavil->swr.write_mutex);
-	ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
-	if (ret < 0)
-		dev_err(tavil->dev, "%s: WR Data Failure\n", __func__);
-	mutex_unlock(&tavil->swr.write_mutex);
-
-	return ret;
-}
-
-static int tavil_swrm_clock(void *handle, bool enable)
-{
-	struct tavil_priv *tavil;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tavil = (struct tavil_priv *)handle;
-
-	mutex_lock(&tavil->swr.clk_mutex);
-	dev_dbg(tavil->dev, "%s: swrm clock %s\n",
-		__func__, (enable?"enable" : "disable"));
-	if (enable) {
-		tavil->swr.clk_users++;
-		if (tavil->swr.clk_users == 1) {
-			regmap_update_bits(tavil->wcd9xxx->regmap,
-					WCD934X_TEST_DEBUG_NPL_DLY_TEST_1,
-					0x10, 0x00);
-			__tavil_cdc_mclk_enable(tavil, true);
-			regmap_update_bits(tavil->wcd9xxx->regmap,
-				WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL,
-				0x01, 0x01);
-		}
-	} else {
-		tavil->swr.clk_users--;
-		if (tavil->swr.clk_users == 0) {
-			regmap_update_bits(tavil->wcd9xxx->regmap,
-				WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL,
-				0x01, 0x00);
-			__tavil_cdc_mclk_enable(tavil, false);
-			regmap_update_bits(tavil->wcd9xxx->regmap,
-					WCD934X_TEST_DEBUG_NPL_DLY_TEST_1,
-					0x10, 0x10);
-		}
-	}
-	dev_dbg(tavil->dev, "%s: swrm clock users %d\n",
-		__func__, tavil->swr.clk_users);
-	mutex_unlock(&tavil->swr.clk_mutex);
-
-	return 0;
-}
-
-static int tavil_swrm_handle_irq(void *handle,
-				 irqreturn_t (*swrm_irq_handler)(int irq,
-								 void *data),
-				 void *swrm_handle,
-				 int action)
-{
-	struct tavil_priv *tavil;
-	int ret = 0;
-	struct wcd9xxx *wcd9xxx;
-
-	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
-		return -EINVAL;
-	}
-	tavil = (struct tavil_priv *) handle;
-	wcd9xxx = tavil->wcd9xxx;
-
-	if (action) {
-		ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
-					  WCD934X_IRQ_SOUNDWIRE,
-					  swrm_irq_handler,
-					  "Tavil SWR Master", swrm_handle);
-		if (ret)
-			dev_err(tavil->dev, "%s: Failed to request irq %d\n",
-				__func__, WCD934X_IRQ_SOUNDWIRE);
-	} else
-		wcd9xxx_free_irq(&wcd9xxx->core_res, WCD934X_IRQ_SOUNDWIRE,
-				 swrm_handle);
-
-	return ret;
-}
-
-static void tavil_codec_add_spi_device(struct tavil_priv *tavil,
-				       struct device_node *node)
-{
-	struct spi_master *master;
-	struct spi_device *spi;
-	u32 prop_value;
-	int rc;
-
-	/* Read the master bus num from DT node */
-	rc = of_property_read_u32(node, "qcom,master-bus-num",
-				  &prop_value);
-	if (rc < 0) {
-		dev_err(tavil->dev, "%s: prop %s not found in node %s",
-			__func__, "qcom,master-bus-num", node->full_name);
-		goto done;
-	}
-
-	/* Get the reference to SPI master */
-	master = spi_busnum_to_master(prop_value);
-	if (!master) {
-		dev_err(tavil->dev, "%s: Invalid spi_master for bus_num %u\n",
-			__func__, prop_value);
-		goto done;
-	}
-
-	/* Allocate the spi device */
-	spi = spi_alloc_device(master);
-	if (!spi) {
-		dev_err(tavil->dev, "%s: spi_alloc_device failed\n",
-			__func__);
-		goto err_spi_alloc_dev;
-	}
-
-	/* Initialize device properties */
-	if (of_modalias_node(node, spi->modalias,
-			     sizeof(spi->modalias)) < 0) {
-		dev_err(tavil->dev, "%s: cannot find modalias for %s\n",
-			__func__, node->full_name);
-		goto err_dt_parse;
-	}
-
-	rc = of_property_read_u32(node, "qcom,chip-select",
-				  &prop_value);
-	if (rc < 0) {
-		dev_err(tavil->dev, "%s: prop %s not found in node %s",
-			__func__, "qcom,chip-select", node->full_name);
-		goto err_dt_parse;
-	}
-	spi->chip_select = prop_value;
-
-	rc = of_property_read_u32(node, "qcom,max-frequency",
-				  &prop_value);
-	if (rc < 0) {
-		dev_err(tavil->dev, "%s: prop %s not found in node %s",
-			__func__, "qcom,max-frequency", node->full_name);
-		goto err_dt_parse;
-	}
-	spi->max_speed_hz = prop_value;
-
-	spi->dev.of_node = node;
-
-	rc = spi_add_device(spi);
-	if (rc < 0) {
-		dev_err(tavil->dev, "%s: spi_add_device failed\n", __func__);
-		goto err_dt_parse;
-	}
-
-	tavil->spi = spi;
-	/* Put the reference to SPI master */
-	put_device(&master->dev);
-
-	return;
-
-err_dt_parse:
-	spi_dev_put(spi);
-
-err_spi_alloc_dev:
-	/* Put the reference to SPI master */
-	put_device(&master->dev);
-done:
-	return;
-}
-
-static void tavil_add_child_devices(struct work_struct *work)
-{
-	struct tavil_priv *tavil;
-	struct platform_device *pdev;
-	struct device_node *node;
-	struct wcd9xxx *wcd9xxx;
-	struct tavil_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
-	int ret, ctrl_num = 0;
-	struct wcd_swr_ctrl_platform_data *platdata;
-	char plat_dev_name[WCD934X_STRING_LEN];
-
-	tavil = container_of(work, struct tavil_priv,
-			     tavil_add_child_devices_work);
-	if (!tavil) {
-		pr_err("%s: Memory for WCD934X does not exist\n",
-			__func__);
-		return;
-	}
-	wcd9xxx = tavil->wcd9xxx;
-	if (!wcd9xxx) {
-		pr_err("%s: Memory for WCD9XXX does not exist\n",
-			__func__);
-		return;
-	}
-	if (!wcd9xxx->dev->of_node) {
-		dev_err(wcd9xxx->dev, "%s: DT node for wcd9xxx does not exist\n",
-			__func__);
-		return;
-	}
-
-	platdata = &tavil->swr.plat_data;
-	tavil->child_count = 0;
-
-	for_each_child_of_node(wcd9xxx->dev->of_node, node) {
-
-		/* Parse and add the SPI device node */
-		if (!strcmp(node->name, "wcd_spi")) {
-			tavil_codec_add_spi_device(tavil, node);
-			continue;
-		}
-
-		/* Parse other child device nodes and add platform device */
-		if (!strcmp(node->name, "swr_master"))
-			strlcpy(plat_dev_name, "tavil_swr_ctrl",
-				(WCD934X_STRING_LEN - 1));
-		else if (strnstr(node->name, "msm_cdc_pinctrl",
-				 strlen("msm_cdc_pinctrl")) != NULL)
-			strlcpy(plat_dev_name, node->name,
-				(WCD934X_STRING_LEN - 1));
-		else
-			continue;
-
-		pdev = platform_device_alloc(plat_dev_name, -1);
-		if (!pdev) {
-			dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
-				__func__);
-			ret = -ENOMEM;
-			goto err_mem;
-		}
-		pdev->dev.parent = tavil->dev;
-		pdev->dev.of_node = node;
-
-		if (strcmp(node->name, "swr_master") == 0) {
-			ret = platform_device_add_data(pdev, platdata,
-						       sizeof(*platdata));
-			if (ret) {
-				dev_err(&pdev->dev,
-					"%s: cannot add plat data ctrl:%d\n",
-					__func__, ctrl_num);
-				goto err_pdev_add;
-			}
-		}
-
-		ret = platform_device_add(pdev);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: Cannot add platform device\n",
-				__func__);
-			goto err_pdev_add;
-		}
-
-		if (strcmp(node->name, "swr_master") == 0) {
-			temp = krealloc(swr_ctrl_data,
-					(ctrl_num + 1) * sizeof(
-					struct tavil_swr_ctrl_data),
-					GFP_KERNEL);
-			if (!temp) {
-				dev_err(wcd9xxx->dev, "out of memory\n");
-				ret = -ENOMEM;
-				goto err_pdev_add;
-			}
-			swr_ctrl_data = temp;
-			swr_ctrl_data[ctrl_num].swr_pdev = pdev;
-			ctrl_num++;
-			dev_dbg(&pdev->dev,
-				"%s: Added soundwire ctrl device(s)\n",
-				__func__);
-			tavil->swr.ctrl_data = swr_ctrl_data;
-		}
-		if (tavil->child_count < WCD934X_CHILD_DEVICES_MAX)
-			tavil->pdev_child_devices[tavil->child_count++] = pdev;
-		else
-			goto err_mem;
-	}
-
-	return;
-
-err_pdev_add:
-	platform_device_put(pdev);
-err_mem:
-	return;
-}
-
-static int __tavil_enable_efuse_sensing(struct tavil_priv *tavil)
-{
-	int val, rc;
-
-	WCD9XXX_V2_BG_CLK_LOCK(tavil->resmgr);
-	__tavil_cdc_mclk_enable_locked(tavil, true);
-
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			WCD934X_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x10);
-	regmap_update_bits(tavil->wcd9xxx->regmap,
-			WCD934X_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
-	/*
-	 * 5ms sleep required after enabling efuse control
-	 * before checking the status.
-	 */
-	usleep_range(5000, 5500);
-	wcd_resmgr_set_sido_input_src(tavil->resmgr,
-					     SIDO_SOURCE_RCO_BG);
-
-	WCD9XXX_V2_BG_CLK_UNLOCK(tavil->resmgr);
-
-	rc = regmap_read(tavil->wcd9xxx->regmap,
-			 WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
-	if (rc || (!(val & 0x01)))
-		WARN(1, "%s: Efuse sense is not complete val=%x, ret=%d\n",
-			__func__, val, rc);
-
-	__tavil_cdc_mclk_enable(tavil, false);
-
-	return rc;
-}
-
-static void ___tavil_get_codec_fine_version(struct tavil_priv *tavil)
-{
-	int val1, val2, version;
-	struct regmap *regmap;
-	u16 id_minor;
-	u32 version_mask = 0;
-
-	regmap = tavil->wcd9xxx->regmap;
-	version = tavil->wcd9xxx->version;
-	id_minor = tavil->wcd9xxx->codec_type->id_minor;
-
-	regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14, &val1);
-	regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15, &val2);
-
-	dev_dbg(tavil->dev, "%s: chip version :0x%x 0x:%x\n",
-		__func__, val1, val2);
-
-	version_mask |= (!!((u8)val1 & 0x80)) << DSD_DISABLED_MASK;
-	version_mask |= (!!((u8)val2 & 0x01)) << SLNQ_DISABLED_MASK;
-
-	switch (version_mask) {
-	case DSD_DISABLED | SLNQ_DISABLED:
-		if (id_minor == cpu_to_le16(0))
-			version = TAVIL_VERSION_WCD9340_1_0;
-		else if (id_minor == cpu_to_le16(0x01))
-			version = TAVIL_VERSION_WCD9340_1_1;
-		break;
-	case SLNQ_DISABLED:
-		if (id_minor == cpu_to_le16(0))
-			version = TAVIL_VERSION_WCD9341_1_0;
-		else if (id_minor == cpu_to_le16(0x01))
-			version = TAVIL_VERSION_WCD9341_1_1;
-		break;
-	}
-
-	tavil->wcd9xxx->version = version;
-	tavil->wcd9xxx->codec_type->version = version;
-}
-
-/*
- * tavil_get_wcd_dsp_cntl: Get the reference to wcd_dsp_cntl
- * @dev: Device pointer for codec device
- *
- * This API gets the reference to codec's struct wcd_dsp_cntl
- */
-struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev)
-{
-	struct platform_device *pdev;
-	struct tavil_priv *tavil;
-
-	if (!dev) {
-		pr_err("%s: Invalid device\n", __func__);
-		return NULL;
-	}
-
-	pdev = to_platform_device(dev);
-	tavil = platform_get_drvdata(pdev);
-
-	return tavil->wdsp_cntl;
-}
-EXPORT_SYMBOL(tavil_get_wcd_dsp_cntl);
-
-static int tavil_probe(struct platform_device *pdev)
-{
-	int ret = 0;
-	struct tavil_priv *tavil;
-	struct clk *wcd_ext_clk;
-	struct wcd9xxx_resmgr_v2 *resmgr;
-	struct wcd9xxx_power_region *cdc_pwr;
-
-	tavil = devm_kzalloc(&pdev->dev, sizeof(struct tavil_priv),
-			    GFP_KERNEL);
-	if (!tavil)
-		return -ENOMEM;
-
-	platform_set_drvdata(pdev, tavil);
-
-	tavil->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
-	tavil->dev = &pdev->dev;
-	INIT_DELAYED_WORK(&tavil->power_gate_work, tavil_codec_power_gate_work);
-	mutex_init(&tavil->power_lock);
-	INIT_WORK(&tavil->tavil_add_child_devices_work,
-		  tavil_add_child_devices);
-	mutex_init(&tavil->micb_lock);
-	mutex_init(&tavil->swr.read_mutex);
-	mutex_init(&tavil->swr.write_mutex);
-	mutex_init(&tavil->swr.clk_mutex);
-	mutex_init(&tavil->codec_mutex);
-	mutex_init(&tavil->svs_mutex);
-
-	/*
-	 * Codec hardware by default comes up in SVS mode.
-	 * Initialize the svs_ref_cnt to 1 to reflect the hardware
-	 * state in the driver.
-	 */
-	tavil->svs_ref_cnt = 1;
-
-	cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
-				GFP_KERNEL);
-	if (!cdc_pwr) {
-		ret = -ENOMEM;
-		goto err_resmgr;
-	}
-	tavil->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
-	cdc_pwr->pwr_collapse_reg_min = WCD934X_DIG_CORE_REG_MIN;
-	cdc_pwr->pwr_collapse_reg_max = WCD934X_DIG_CORE_REG_MAX;
-	wcd9xxx_set_power_state(tavil->wcd9xxx,
-				WCD_REGION_POWER_COLLAPSE_REMOVE,
-				WCD9XXX_DIG_CORE_REGION_1);
-	/*
-	 * Init resource manager so that if child nodes such as SoundWire
-	 * requests for clock, resource manager can honor the request
-	 */
-	resmgr = wcd_resmgr_init(&tavil->wcd9xxx->core_res, NULL);
-	if (IS_ERR(resmgr)) {
-		ret = PTR_ERR(resmgr);
-		dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
-			__func__);
-		goto err_resmgr;
-	}
-	tavil->resmgr = resmgr;
-	tavil->swr.plat_data.handle = (void *) tavil;
-	tavil->swr.plat_data.read = tavil_swrm_read;
-	tavil->swr.plat_data.write = tavil_swrm_write;
-	tavil->swr.plat_data.bulk_write = tavil_swrm_bulk_write;
-	tavil->swr.plat_data.clk = tavil_swrm_clock;
-	tavil->swr.plat_data.handle_irq = tavil_swrm_handle_irq;
-	tavil->swr.spkr_gain_offset = WCD934X_RX_GAIN_OFFSET_0_DB;
-
-	/* Register for Clock */
-	wcd_ext_clk = clk_get(tavil->wcd9xxx->dev, "wcd_clk");
-	if (IS_ERR(wcd_ext_clk)) {
-		dev_err(tavil->wcd9xxx->dev, "%s: clk get %s failed\n",
-			__func__, "wcd_ext_clk");
-		goto err_clk;
-	}
-	tavil->wcd_ext_clk = wcd_ext_clk;
-	set_bit(AUDIO_NOMINAL, &tavil->status_mask);
-	/* Update codec register default values */
-	dev_dbg(&pdev->dev, "%s: MCLK Rate = %x\n", __func__,
-		tavil->wcd9xxx->mclk_rate);
-	if (tavil->wcd9xxx->mclk_rate == WCD934X_MCLK_CLK_12P288MHZ)
-		regmap_update_bits(tavil->wcd9xxx->regmap,
-				   WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-				   0x03, 0x00);
-	else if (tavil->wcd9xxx->mclk_rate == WCD934X_MCLK_CLK_9P6MHZ)
-		regmap_update_bits(tavil->wcd9xxx->regmap,
-				   WCD934X_CODEC_RPM_CLK_MCLK_CFG,
-				   0x03, 0x01);
-	tavil_update_reg_defaults(tavil);
-	__tavil_enable_efuse_sensing(tavil);
-	___tavil_get_codec_fine_version(tavil);
-	tavil_update_cpr_defaults(tavil);
-
-	/* Register with soc framework */
-	ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tavil,
-				  tavil_dai, ARRAY_SIZE(tavil_dai));
-	if (ret) {
-		dev_err(&pdev->dev, "%s: Codec registration failed\n",
-		 __func__);
-		goto err_cdc_reg;
-	}
-	schedule_work(&tavil->tavil_add_child_devices_work);
-
-	return ret;
-
-err_cdc_reg:
-	clk_put(tavil->wcd_ext_clk);
-err_clk:
-	wcd_resmgr_remove(tavil->resmgr);
-err_resmgr:
-	mutex_destroy(&tavil->micb_lock);
-	mutex_destroy(&tavil->svs_mutex);
-	mutex_destroy(&tavil->codec_mutex);
-	mutex_destroy(&tavil->swr.read_mutex);
-	mutex_destroy(&tavil->swr.write_mutex);
-	mutex_destroy(&tavil->swr.clk_mutex);
-	devm_kfree(&pdev->dev, tavil);
-
-	return ret;
-}
-
-static int tavil_remove(struct platform_device *pdev)
-{
-	struct tavil_priv *tavil;
-	int count = 0;
-
-	tavil = platform_get_drvdata(pdev);
-	if (!tavil)
-		return -EINVAL;
-
-	/* do dsd deinit before codec->component->regmap becomes freed */
-	if (tavil->dsd_config) {
-		tavil_dsd_deinit(tavil->dsd_config);
-		tavil->dsd_config = NULL;
-	}
-
-	if (tavil->spi)
-		spi_unregister_device(tavil->spi);
-	for (count = 0; count < tavil->child_count &&
-				count < WCD934X_CHILD_DEVICES_MAX; count++)
-		platform_device_unregister(tavil->pdev_child_devices[count]);
-
-	mutex_destroy(&tavil->micb_lock);
-	mutex_destroy(&tavil->svs_mutex);
-	mutex_destroy(&tavil->codec_mutex);
-	mutex_destroy(&tavil->swr.read_mutex);
-	mutex_destroy(&tavil->swr.write_mutex);
-	mutex_destroy(&tavil->swr.clk_mutex);
-
-	snd_soc_unregister_codec(&pdev->dev);
-	clk_put(tavil->wcd_ext_clk);
-	wcd_resmgr_remove(tavil->resmgr);
-	devm_kfree(&pdev->dev, tavil);
-	return 0;
-}
-
-static struct platform_driver tavil_codec_driver = {
-	.probe = tavil_probe,
-	.remove = tavil_remove,
-	.driver = {
-		.name = "tavil_codec",
-		.owner = THIS_MODULE,
-#ifdef CONFIG_PM
-		.pm = &tavil_pm_ops,
-#endif
-	},
-};
-
-module_platform_driver(tavil_codec_driver);
-
-MODULE_DESCRIPTION("Tavil Codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd934x/wcd934x.h b/sound/soc/codecs/wcd934x/wcd934x.h
deleted file mode 100644
index 27c21f1..0000000
--- a/sound/soc/codecs/wcd934x/wcd934x.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WCD934X_H
-#define WCD934X_H
-
-#include <sound/apr_audio-v2.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
-#include "wcd934x-dsp-cntl.h"
-#include "../wcd9xxx-common-v2.h"
-#include "../wcd-mbhc-v2.h"
-
-#define WCD934X_REGISTER_START_OFFSET  0x800
-#define WCD934X_SB_PGD_PORT_RX_BASE   0x40
-#define WCD934X_SB_PGD_PORT_TX_BASE   0x50
-#define WCD934X_RX_PORT_START_NUMBER  16
-
-#define WCD934X_DMIC_CLK_DIV_2  0x0
-#define WCD934X_DMIC_CLK_DIV_3  0x1
-#define WCD934X_DMIC_CLK_DIV_4  0x2
-#define WCD934X_DMIC_CLK_DIV_6  0x3
-#define WCD934X_DMIC_CLK_DIV_8  0x4
-#define WCD934X_DMIC_CLK_DIV_16  0x5
-#define WCD934X_DMIC_CLK_DRIVE_DEFAULT 0x02
-
-#define WCD934X_ANC_DMIC_X2_FULL_RATE 1
-#define WCD934X_ANC_DMIC_X2_HALF_RATE 0
-
-#define TAVIL_MAX_MICBIAS 4
-#define TAVIL_NUM_INTERPOLATORS 9
-#define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH    64
-
-/* Convert from vout ctl to micbias voltage in mV */
-#define  WCD_VOUT_CTL_TO_MICB(v)  (1000 + v * 50)
-
-/* Feature masks to distinguish codec version */
-#define DSD_DISABLED_MASK   0
-#define SLNQ_DISABLED_MASK  1
-
-#define DSD_DISABLED   (1 << DSD_DISABLED_MASK)
-#define SLNQ_DISABLED  (1 << SLNQ_DISABLED_MASK)
-
-/* Number of input and output Slimbus port */
-enum {
-	WCD934X_RX0 = 0,
-	WCD934X_RX1,
-	WCD934X_RX2,
-	WCD934X_RX3,
-	WCD934X_RX4,
-	WCD934X_RX5,
-	WCD934X_RX6,
-	WCD934X_RX7,
-	WCD934X_RX_MAX,
-};
-
-enum {
-	WCD934X_TX0 = 0,
-	WCD934X_TX1,
-	WCD934X_TX2,
-	WCD934X_TX3,
-	WCD934X_TX4,
-	WCD934X_TX5,
-	WCD934X_TX6,
-	WCD934X_TX7,
-	WCD934X_TX8,
-	WCD934X_TX9,
-	WCD934X_TX10,
-	WCD934X_TX11,
-	WCD934X_TX12,
-	WCD934X_TX13,
-	WCD934X_TX14,
-	WCD934X_TX15,
-	WCD934X_TX_MAX,
-};
-
-enum {
-	INTERP_EAR = 0,
-	INTERP_HPHL,
-	INTERP_HPHR,
-	INTERP_LO1,
-	INTERP_LO2,
-	INTERP_LO3_NA, /* LO3 not avalible in Tavil*/
-	INTERP_LO4_NA,
-	INTERP_SPKR1,
-	INTERP_SPKR2,
-	INTERP_MAX,
-};
-
-/*
- * Selects compander and smart boost settings
- * for a given speaker mode
- */
-enum {
-	WCD934X_SPKR_MODE_DEFAULT,
-	WCD934X_SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
-};
-
-/*
- * Rx path gain offsets
- */
-enum {
-	WCD934X_RX_GAIN_OFFSET_M1P5_DB,
-	WCD934X_RX_GAIN_OFFSET_0_DB,
-};
-
-/*
- * Dai data structure holds the
- * dai specific info like rate,
- * channel number etc.
- */
-struct tavil_codec_dai_data {
-	u32 rate;
-	u32 *ch_num;
-	u32 ch_act;
-	u32 ch_tot;
-};
-
-/*
- * Structure used to update codec
- * register defaults after reset
- */
-struct tavil_reg_mask_val {
-	u16 reg;
-	u8 mask;
-	u8 val;
-};
-
-extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
-				  enum afe_config_type config_type);
-extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
-extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
-extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode);
-extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
-extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev);
-extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv);
-extern int tavil_micbias_control(struct snd_soc_codec *codec,
-				 int micb_num,
-				 int req, bool is_dapm);
-extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
-					  int req_volt,
-					  int micb_num);
-extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec);
-extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
-					 int event, int intp_idx);
-extern struct tavil_dsd_config *tavil_get_dsd_config(
-				struct snd_soc_codec *codec);
-extern int tavil_codec_info_create_codec_entry(
-				struct snd_info_entry *codec_root,
-				struct snd_soc_codec *codec);
-#endif
diff --git a/sound/soc/codecs/wcd9xxx-common-v2.c b/sound/soc/codecs/wcd9xxx-common-v2.c
deleted file mode 100644
index 6216657..0000000
--- a/sound/soc/codecs/wcd9xxx-common-v2.c
+++ /dev/null
@@ -1,1367 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <sound/soc.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-#include "wcd9xxx-common-v2.h"
-
-#define WCD_USLEEP_RANGE 50
-#define MAX_IMPED_PARAMS 6
-
-enum {
-	DAC_GAIN_0DB = 0,
-	DAC_GAIN_0P2DB,
-	DAC_GAIN_0P4DB,
-	DAC_GAIN_0P6DB,
-	DAC_GAIN_0P8DB,
-	DAC_GAIN_M0P2DB,
-	DAC_GAIN_M0P4DB,
-	DAC_GAIN_M0P6DB,
-};
-
-enum {
-	VREF_FILT_R_0OHM = 0,
-	VREF_FILT_R_25KOHM,
-	VREF_FILT_R_50KOHM,
-	VREF_FILT_R_100KOHM,
-};
-
-enum {
-	DELTA_I_0MA,
-	DELTA_I_10MA,
-	DELTA_I_20MA,
-	DELTA_I_30MA,
-	DELTA_I_40MA,
-	DELTA_I_50MA,
-};
-
-struct wcd_imped_val {
-	u32 imped_val;
-	u8 index;
-};
-
-static const struct wcd_reg_mask_val imped_table[][MAX_IMPED_PARAMS] = {
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf5},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf5},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf5},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf5},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x0},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x0},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfe},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfe},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfe},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfe},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xff},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xff},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xff},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xff},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-};
-
-static const struct wcd_reg_mask_val imped_table_tavil[][MAX_IMPED_PARAMS] = {
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf2},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf2},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf2},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf2},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf4},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf4},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf4},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf4},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf7},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xf9},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfa},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfb},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfc},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x00},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x00},
-	},
-	{
-		{WCD9XXX_CDC_RX1_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX1_RX_PATH_SEC1, 0x01, 0x01},
-		{WCD9XXX_CDC_RX2_RX_VOL_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_VOL_MIX_CTL, 0xff, 0xfd},
-		{WCD9XXX_CDC_RX2_RX_PATH_SEC1, 0x01, 0x01},
-	},
-};
-
-static const struct wcd_imped_val imped_index[] = {
-	{4, 0},
-	{5, 1},
-	{6, 2},
-	{7, 3},
-	{8, 4},
-	{9, 5},
-	{10, 6},
-	{11, 7},
-	{12, 8},
-	{13, 9},
-};
-
-static void (*clsh_state_fp[NUM_CLSH_STATES_V2])(struct snd_soc_codec *,
-					      struct wcd_clsh_cdc_data *,
-					      u8 req_state, bool en, int mode);
-
-static int get_impedance_index(int imped)
-{
-	int i = 0;
-
-	if (imped < imped_index[i].imped_val) {
-		pr_debug("%s, detected impedance is less than 4 Ohm\n",
-				__func__);
-		i = 0;
-		goto ret;
-	}
-	if (imped >= imped_index[ARRAY_SIZE(imped_index) - 1].imped_val) {
-		pr_debug("%s, detected impedance is greater than 12 Ohm\n",
-				__func__);
-		i = ARRAY_SIZE(imped_index) - 1;
-		goto ret;
-	}
-	for (i = 0; i < ARRAY_SIZE(imped_index) - 1; i++) {
-		if (imped >= imped_index[i].imped_val &&
-			imped < imped_index[i + 1].imped_val)
-			break;
-	}
-ret:
-	pr_debug("%s: selected impedance index = %d\n",
-			__func__, imped_index[i].index);
-	return imped_index[i].index;
-}
-
-/*
- * Function: wcd_clsh_imped_config
- * Params: codec, imped, reset
- * Description:
- * This function updates HPHL and HPHR gain settings
- * according to the impedance value.
- */
-void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
-{
-	int i;
-	int index = 0;
-	int table_size;
-
-	static const struct wcd_reg_mask_val
-				(*imped_table_ptr)[MAX_IMPED_PARAMS];
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (IS_CODEC_TYPE(wcd9xxx, WCD934X)) {
-		table_size = ARRAY_SIZE(imped_table_tavil);
-		imped_table_ptr = imped_table_tavil;
-	} else {
-		table_size = ARRAY_SIZE(imped_table);
-		imped_table_ptr = imped_table;
-	}
-
-	/* reset = 1, which means request is to reset the register values */
-	if (reset) {
-		for (i = 0; i < MAX_IMPED_PARAMS; i++)
-			snd_soc_update_bits(codec,
-				imped_table_ptr[index][i].reg,
-				imped_table_ptr[index][i].mask, 0);
-		return;
-	}
-	index = get_impedance_index(imped);
-	if (index >= (ARRAY_SIZE(imped_index) - 1)) {
-		pr_debug("%s, impedance not in range = %d\n", __func__, imped);
-		return;
-	}
-	if (index >= table_size) {
-		pr_debug("%s, impedance index not in range = %d\n", __func__,
-			index);
-		return;
-	}
-	for (i = 0; i < MAX_IMPED_PARAMS; i++)
-		snd_soc_update_bits(codec,
-				imped_table_ptr[index][i].reg,
-				imped_table_ptr[index][i].mask,
-				imped_table_ptr[index][i].val);
-}
-EXPORT_SYMBOL(wcd_clsh_imped_config);
-
-static bool is_native_44_1_active(struct snd_soc_codec *codec)
-{
-	bool native_active = false;
-	u8 native_clk, rx1_rate, rx2_rate;
-
-	native_clk = snd_soc_read(codec,
-				 WCD9XXX_CDC_CLK_RST_CTRL_MCLK_CONTROL);
-	rx1_rate = snd_soc_read(codec, WCD9XXX_CDC_RX1_RX_PATH_CTL);
-	rx2_rate = snd_soc_read(codec, WCD9XXX_CDC_RX2_RX_PATH_CTL);
-
-	dev_dbg(codec->dev, "%s: native_clk %x rx1_rate= %x rx2_rate= %x",
-		__func__, native_clk, rx1_rate, rx2_rate);
-
-	if ((native_clk & 0x2) &&
-	    ((rx1_rate & 0x0F) == 0x9 || (rx2_rate & 0x0F) == 0x9))
-		native_active = true;
-
-	return native_active;
-}
-
-static const char *mode_to_str(int mode)
-{
-	switch (mode) {
-	case CLS_H_NORMAL:
-		return "CLS_H_NORMAL";
-	case CLS_H_HIFI:
-		return "CLS_H_HIFI";
-	case CLS_H_LOHIFI:
-		return "CLS_H_LOHIFI";
-	case CLS_H_LP:
-		return "CLS_H_LP";
-	case CLS_H_ULP:
-		return "CLS_H_ULP";
-	case CLS_AB:
-		return "CLS_AB";
-	case CLS_AB_HIFI:
-		return "CLS_AB_HIFI";
-	default:
-		return "CLS_H_INVALID";
-	};
-}
-
-static const char *state_to_str(u8 state, char *buf, size_t buflen)
-{
-	int i;
-	int cnt = 0;
-	/*
-	 * This array of strings should match with enum wcd_clsh_state_bit.
-	 */
-	static const char *const states[] = {
-		"STATE_EAR",
-		"STATE_HPH_L",
-		"STATE_HPH_R",
-		"STATE_LO",
-	};
-
-	if (state == WCD_CLSH_STATE_IDLE) {
-		snprintf(buf, buflen, "[STATE_IDLE]");
-		goto done;
-	}
-
-	buf[0] = '\0';
-	for (i = 0; i < ARRAY_SIZE(states); i++) {
-		if (!(state & (1 << i)))
-			continue;
-		cnt = snprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
-			       buf[0] == '\0' ? "[" : "|",
-			       states[i]);
-	}
-	if (cnt > 0)
-		strlcat(buf + cnt, "]", buflen);
-
-done:
-	if (buf[0] == '\0')
-		snprintf(buf, buflen, "[STATE_UNKNOWN]");
-	return buf;
-}
-
-static inline void
-wcd_enable_clsh_block(struct snd_soc_codec *codec,
-		      struct wcd_clsh_cdc_data *clsh_d, bool enable)
-{
-	if ((enable && ++clsh_d->clsh_users == 1) ||
-	    (!enable && --clsh_d->clsh_users == 0))
-		snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_CRC, 0x01,
-				    (u8) enable);
-	if (clsh_d->clsh_users < 0)
-		clsh_d->clsh_users = 0;
-	dev_dbg(codec->dev, "%s: clsh_users %d, enable %d", __func__,
-		clsh_d->clsh_users, enable);
-}
-
-static inline bool wcd_clsh_enable_status(struct snd_soc_codec *codec)
-{
-	return snd_soc_read(codec, WCD9XXX_A_CDC_CLSH_CRC) & 0x01;
-}
-
-static inline int wcd_clsh_get_int_mode(struct wcd_clsh_cdc_data *clsh_d,
-					int clsh_state)
-{
-	int mode;
-
-	if ((clsh_state != WCD_CLSH_STATE_EAR) &&
-	    (clsh_state != WCD_CLSH_STATE_HPHL) &&
-	    (clsh_state != WCD_CLSH_STATE_HPHR) &&
-	    (clsh_state != WCD_CLSH_STATE_LO))
-		mode = CLS_NONE;
-	else
-		mode = clsh_d->interpolator_modes[ffs(clsh_state)];
-
-	return mode;
-}
-
-static inline void wcd_clsh_set_int_mode(struct wcd_clsh_cdc_data *clsh_d,
-					int clsh_state, int mode)
-{
-	if ((clsh_state != WCD_CLSH_STATE_EAR) &&
-	    (clsh_state != WCD_CLSH_STATE_HPHL) &&
-	    (clsh_state != WCD_CLSH_STATE_HPHR) &&
-	    (clsh_state != WCD_CLSH_STATE_LO))
-		return;
-
-	clsh_d->interpolator_modes[ffs(clsh_state)] = mode;
-}
-
-static inline void wcd_clsh_set_buck_mode(struct snd_soc_codec *codec,
-					  int mode)
-{
-	if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
-	    mode == CLS_AB_HIFI || mode == CLS_AB)
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    0x08, 0x08); /* set to HIFI */
-	else
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    0x08, 0x00); /* set to default */
-}
-
-static inline void wcd_clsh_set_flyback_mode(struct snd_soc_codec *codec,
-					     int mode)
-{
-	if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
-	    mode == CLS_AB_HIFI || mode == CLS_AB)
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    0x04, 0x04); /* set to HIFI */
-	else
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    0x04, 0x00); /* set to Default */
-}
-
-static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec,
-					      int mode)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!IS_CODEC_TYPE(wcd9xxx, WCD934X))
-		return;
-
-	if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
-	    mode == CLS_AB_HIFI || mode == CLS_AB) {
-		if (TAVIL_IS_1_0(wcd9xxx))
-			snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL,
-					    0x80, 0x0); /* disable GM3 Boost */
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
-				    0xF0, 0x80);
-	} else {
-		snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL,
-				    0x80, 0x80); /* set to Default */
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
-				    0xF0, 0x70);
-	}
-}
-
-
-static inline void wcd_clsh_force_iq_ctl(struct snd_soc_codec *codec,
-					 int mode)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!IS_CODEC_TYPE(wcd9xxx, WCD934X))
-		return;
-
-	if (mode == CLS_H_LOHIFI || mode == CLS_AB) {
-		snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
-				    0x20, 0x20);
-		snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
-				    0xF0, 0xC0);
-		snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
-				    0x0E, 0x02);
-	} else {
-
-		snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
-				    0x20, 0x0);
-		snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
-				    0xF0, 0x80);
-		snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
-				    0x0E, 0x06);
-	}
-}
-
-static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec,
-			       struct wcd_clsh_cdc_data *clsh_d,
-			       int mode,
-			       bool enable)
-{
-	/* enable/disable buck */
-	if ((enable && (++clsh_d->buck_users == 1)) ||
-	   (!enable && (--clsh_d->buck_users == 0)))
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    (1 << 7), (enable << 7));
-	dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s",
-		__func__, clsh_d->buck_users, enable, mode_to_str(mode));
-	/*
-	 * 500us sleep is required after buck enable/disable
-	 * as per HW requirement
-	 */
-	usleep_range(500, 500 + WCD_USLEEP_RANGE);
-}
-
-static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec,
-				  struct wcd_clsh_cdc_data *clsh_d,
-				  int mode,
-				  bool enable)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_reg_val bulk_reg[2];
-	u8 vneg[] = {0x00, 0x40};
-
-	/* enable/disable flyback */
-	if ((enable && (++clsh_d->flyback_users == 1)) ||
-	   (!enable && (--clsh_d->flyback_users == 0))) {
-		snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-				    (1 << 6), (enable << 6));
-		/* 100usec delay is needed as per HW requirement */
-		usleep_range(100, 110);
-		if (enable && (TASHA_IS_1_1(wcd9xxx))) {
-			wcd_clsh_set_flyback_mode(codec, CLS_H_HIFI);
-			snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
-					    0x60, 0x40);
-			snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
-					    0x10, 0x10);
-			vneg[0] = snd_soc_read(codec,
-					       WCD9XXX_A_ANA_RX_SUPPLIES);
-			vneg[0] &= ~(0x40);
-			vneg[1] = vneg[0] | 0x40;
-			bulk_reg[0].reg = WCD9XXX_A_ANA_RX_SUPPLIES;
-			bulk_reg[0].buf = &vneg[0];
-			bulk_reg[0].bytes = 1;
-			bulk_reg[1].reg = WCD9XXX_A_ANA_RX_SUPPLIES;
-			bulk_reg[1].buf = &vneg[1];
-			bulk_reg[1].bytes = 1;
-			/* 500usec delay is needed as per HW requirement */
-			usleep_range(500, 510);
-			wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2,
-						false);
-			snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
-					    0x10, 0x00);
-			wcd_clsh_set_flyback_mode(codec, mode);
-		}
-
-	}
-	dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s",
-		__func__, clsh_d->flyback_users, enable, mode_to_str(mode));
-	/*
-	 * 500us sleep is required after flyback enable/disable
-	 * as per HW requirement
-	 */
-	usleep_range(500, 500 + WCD_USLEEP_RANGE);
-}
-
-static void wcd_clsh_set_gain_path(struct snd_soc_codec *codec,
-				   int mode)
-{
-	u8 val = 0;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!TASHA_IS_2_0(wcd9xxx))
-		return;
-
-	switch (mode) {
-	case CLS_H_NORMAL:
-	case CLS_AB:
-		val = 0x00;
-		break;
-	case CLS_H_HIFI:
-		val = 0x02;
-		break;
-	case CLS_H_LP:
-		val = 0x01;
-		break;
-	default:
-		return;
-	};
-	snd_soc_update_bits(codec, WCD9XXX_HPH_L_EN, 0xC0, (val << 6));
-	snd_soc_update_bits(codec, WCD9XXX_HPH_R_EN, 0xC0, (val << 6));
-}
-
-static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec,
-				  int mode)
-{
-	u8 val = 0;
-	u8 gain = 0;
-	u8 res_val = VREF_FILT_R_0OHM;
-	u8 ipeak = DELTA_I_50MA;
-
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	switch (mode) {
-	case CLS_H_NORMAL:
-		res_val = VREF_FILT_R_50KOHM;
-		val = 0x00;
-		gain = DAC_GAIN_0DB;
-		ipeak = DELTA_I_50MA;
-		break;
-	case CLS_AB:
-		val = 0x00;
-		gain = DAC_GAIN_0DB;
-		ipeak = DELTA_I_50MA;
-		break;
-	case CLS_AB_HIFI:
-		val = 0x08;
-		break;
-	case CLS_H_HIFI:
-		val = 0x08;
-		gain = DAC_GAIN_M0P2DB;
-		ipeak = DELTA_I_50MA;
-		break;
-	case CLS_H_LOHIFI:
-		val = 0x00;
-		if ((IS_CODEC_TYPE(wcd9xxx, WCD9335)) ||
-		    (IS_CODEC_TYPE(wcd9xxx, WCD9326))) {
-			val = 0x08;
-			gain = DAC_GAIN_M0P2DB;
-			ipeak = DELTA_I_50MA;
-		}
-		break;
-	case CLS_H_ULP:
-		val = 0x0C;
-		break;
-	case CLS_H_LP:
-		val = 0x04;
-		ipeak = DELTA_I_30MA;
-		break;
-	default:
-		return;
-	};
-
-	/*
-	 * For tavil set mode to Lower_power for
-	 * CLS_H_LOHIFI and CLS_AB
-	 */
-	if ((IS_CODEC_TYPE(wcd9xxx, WCD934X)) &&
-	    (mode == CLS_H_LOHIFI || mode == CLS_AB))
-		val = 0x04;
-
-	snd_soc_update_bits(codec, WCD9XXX_A_ANA_HPH, 0x0C, val);
-	if (TASHA_IS_2_0(wcd9xxx)) {
-		snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_VCL_2,
-				    0x30, (res_val << 4));
-		if (mode != CLS_H_LP)
-			snd_soc_update_bits(codec, WCD9XXX_HPH_REFBUFF_UHQA_CTL,
-					    0x07, gain);
-		snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_CCL_1,
-				    0xF0, (ipeak << 4));
-	}
-}
-
-static void wcd_clsh_set_flyback_vneg_ctl(struct snd_soc_codec *codec,
-					  bool enable)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!TASHA_IS_2_0(wcd9xxx))
-		return;
-
-	if (enable) {
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0,
-				    0x00);
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
-				    0xE0, (0x07 << 5));
-	} else {
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0,
-				    (0x07 << 5));
-		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
-				    0xE0, (0x02 << 5));
-	}
-}
-
-static void wcd_clsh_set_flyback_current(struct snd_soc_codec *codec, int mode)
-{
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-
-	if (!TASHA_IS_2_0(wcd9xxx))
-		return;
-
-	snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0x0F, 0x0A);
-	snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0xF0, 0xA0);
-	/* Sleep needed to avoid click and pop as per HW requirement */
-	usleep_range(100, 110);
-}
-
-static void wcd_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec,
-					     int mode)
-{
-	snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
-			    0x02, 0x00);
-}
-
-static void wcd_clsh_state_lo(struct snd_soc_codec *codec,
-			      struct wcd_clsh_cdc_data *clsh_d,
-			      u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-		dev_err(codec->dev, "%s: LO cannot be in this mode: %d\n",
-			__func__, mode);
-		return;
-	}
-
-	if (is_enable) {
-		wcd_clsh_set_buck_regulator_mode(codec, mode);
-		wcd_clsh_set_flyback_vneg_ctl(codec, true);
-		wcd_clsh_set_buck_mode(codec, mode);
-		wcd_clsh_set_flyback_mode(codec, mode);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_flyback_current(codec, mode);
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
-	} else {
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, false);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false);
-		wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_flyback_vneg_ctl(codec, false);
-		wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
-	}
-}
-
-static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec,
-				   struct wcd_clsh_cdc_data *clsh_d,
-				   u8 req_state, bool is_enable, int mode)
-{
-	int hph_mode = 0;
-
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (is_enable) {
-		if (req_state == WCD_CLSH_STATE_EAR) {
-			/* If HPH is running in CLS-AB when
-			 * EAR comes, let it continue to run
-			 * in Class-AB, no need to enable Class-H
-			 * for EAR.
-			 */
-			if (clsh_d->state & WCD_CLSH_STATE_HPHL)
-				hph_mode = wcd_clsh_get_int_mode(clsh_d,
-						WCD_CLSH_STATE_HPHL);
-			else if (clsh_d->state & WCD_CLSH_STATE_HPHR)
-				hph_mode = wcd_clsh_get_int_mode(clsh_d,
-						WCD_CLSH_STATE_HPHR);
-			else
-				return;
-			if (hph_mode != CLS_AB && hph_mode != CLS_AB_HIFI
-			    && !is_native_44_1_active(codec))
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-						0x40, 0x40);
-		}
-
-		if (is_native_44_1_active(codec)) {
-			snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x39);
-			snd_soc_update_bits(codec,
-					WCD9XXX_CDC_RX0_RX_PATH_SEC0,
-					0x03, 0x00);
-			if ((req_state == WCD_CLSH_STATE_HPHL) ||
-			    (req_state == WCD_CLSH_STATE_HPHR))
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-						0x40, 0x00);
-		}
-
-		if (req_state == WCD_CLSH_STATE_HPHL)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x40);
-		if (req_state == WCD_CLSH_STATE_HPHR)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x40);
-		if ((req_state == WCD_CLSH_STATE_HPHL) ||
-		    (req_state == WCD_CLSH_STATE_HPHR)) {
-			wcd_clsh_set_gain_path(codec, mode);
-			wcd_clsh_set_flyback_mode(codec, mode);
-			wcd_clsh_set_buck_mode(codec, mode);
-		}
-	} else {
-		if (req_state == WCD_CLSH_STATE_EAR) {
-			/*
-			 * If EAR goes away, disable EAR Channel Enable
-			 * if HPH running in Class-H otherwise
-			 * and if HPH requested mode is CLS_AB then
-			 * no need to disable EAR channel enable bit.
-			 */
-			if (wcd_clsh_enable_status(codec))
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-						0x40, 0x00);
-		}
-
-		if (is_native_44_1_active(codec)) {
-			snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x1C);
-			snd_soc_update_bits(codec,
-					WCD9XXX_CDC_RX0_RX_PATH_SEC0,
-					0x03, 0x01);
-			if (((clsh_d->state & WCD_CLSH_STATE_HPH_ST)
-				  != WCD_CLSH_STATE_HPH_ST) &&
-			    ((req_state == WCD_CLSH_STATE_HPHL) ||
-			     (req_state == WCD_CLSH_STATE_HPHR)))
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-						0x40, 0x40);
-		}
-
-		if (req_state == WCD_CLSH_STATE_HPHL)
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					0x40, 0x00);
-		if (req_state == WCD_CLSH_STATE_HPHR)
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					0x40, 0x00);
-		if ((req_state & WCD_CLSH_STATE_HPH_ST) &&
-		    !wcd_clsh_enable_status(codec)) {
-			/* If Class-H is not enabled when HPH is turned
-			 * off, enable it as EAR is in progress
-			 */
-			wcd_enable_clsh_block(codec, clsh_d, true);
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-					0x40, 0x40);
-			wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-			wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-		}
-	}
-}
-
-static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec,
-				  struct wcd_clsh_cdc_data *clsh_d,
-				  u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (is_enable) {
-		/* LO powerup is taken care in PA sequence.
-		 * No need to change to class AB here.
-		 */
-		if (req_state == WCD_CLSH_STATE_EAR) {
-			/* EAR powerup.*/
-			if (!wcd_clsh_enable_status(codec)) {
-				wcd_enable_clsh_block(codec, clsh_d, true);
-				wcd_clsh_set_buck_mode(codec, mode);
-				wcd_clsh_set_flyback_mode(codec, mode);
-			}
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-					0x40, 0x40);
-		}
-	} else {
-		if (req_state == WCD_CLSH_STATE_EAR) {
-			/* EAR powerdown.*/
-			wcd_enable_clsh_block(codec, clsh_d, false);
-			wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-			wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-					0x40, 0x00);
-		}
-		/* LO powerdown is taken care in PA sequence.
-		 * No need to change to class H here.
-		 */
-	}
-}
-
-static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
-				  struct wcd_clsh_cdc_data *clsh_d,
-				  u8 req_state, bool is_enable, int mode)
-{
-	int hph_mode = 0;
-
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (is_enable) {
-		/*
-		 * If requested state is LO, put regulator
-		 * in class-AB or if requested state is HPH,
-		 * which means LO is already enabled, keep
-		 * the regulator config the same at class-AB
-		 * and just set the power modes for flyback
-		 * and buck.
-		 */
-		if (req_state == WCD_CLSH_STATE_LO)
-			wcd_clsh_set_buck_regulator_mode(codec, CLS_AB);
-		else {
-			if (!wcd_clsh_enable_status(codec)) {
-				wcd_enable_clsh_block(codec, clsh_d, true);
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_CLSH_K1_MSB,
-						0x0F, 0x00);
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_CLSH_K1_LSB,
-						0xFF, 0xC0);
-				wcd_clsh_set_flyback_mode(codec, mode);
-				wcd_clsh_set_flyback_vneg_ctl(codec, false);
-				wcd_clsh_set_buck_mode(codec, mode);
-				wcd_clsh_set_hph_mode(codec, mode);
-				wcd_clsh_set_gain_path(codec, mode);
-			} else {
-				dev_dbg(codec->dev, "%s:clsh is already enabled\n",
-					__func__);
-			}
-			if (req_state == WCD_CLSH_STATE_HPHL)
-				snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					0x40, 0x40);
-			if (req_state == WCD_CLSH_STATE_HPHR)
-				snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					0x40, 0x40);
-		}
-	} else {
-		if ((req_state == WCD_CLSH_STATE_HPHL) ||
-		    (req_state == WCD_CLSH_STATE_HPHR)) {
-			if (req_state == WCD_CLSH_STATE_HPHL)
-				snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x00);
-			if (req_state == WCD_CLSH_STATE_HPHR)
-				snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x00);
-			/*
-			 * If HPH is powering down first, then disable clsh,
-			 * set the buck/flyback mode to default and keep the
-			 * regulator at Class-AB
-			 */
-			if ((clsh_d->state & WCD_CLSH_STATE_HPH_ST)
-				!= WCD_CLSH_STATE_HPH_ST) {
-				wcd_enable_clsh_block(codec, clsh_d, false);
-				wcd_clsh_set_flyback_vneg_ctl(codec, true);
-				wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-				wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-			}
-		} else {
-			/* LO powerdown.
-			 * If HPH mode also is CLS-AB, no need
-			 * to turn-on class-H, otherwise enable
-			 * Class-H configuration.
-			 */
-			if (clsh_d->state & WCD_CLSH_STATE_HPHL)
-				hph_mode = wcd_clsh_get_int_mode(clsh_d,
-						WCD_CLSH_STATE_HPHL);
-			else if (clsh_d->state & WCD_CLSH_STATE_HPHR)
-				hph_mode = wcd_clsh_get_int_mode(clsh_d,
-						WCD_CLSH_STATE_HPHR);
-			else
-				return;
-			dev_dbg(codec->dev, "%s: hph_mode = %d\n", __func__,
-				hph_mode);
-
-			if ((hph_mode == CLS_AB) ||
-			   (hph_mode == CLS_AB_HIFI) ||
-			   (hph_mode == CLS_NONE))
-				goto end;
-
-			/*
-			 * If Class-H is already enabled (HPH ON and then
-			 * LO ON), no need to turn on again, just set the
-			 * regulator mode.
-			 */
-			if (wcd_clsh_enable_status(codec)) {
-				wcd_clsh_set_buck_regulator_mode(codec,
-								 hph_mode);
-				goto end;
-			} else {
-				dev_dbg(codec->dev, "%s: clsh is not enabled\n",
-					__func__);
-			}
-
-			wcd_enable_clsh_block(codec, clsh_d, true);
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_CLSH_K1_MSB,
-					0x0F, 0x00);
-			snd_soc_update_bits(codec,
-					WCD9XXX_A_CDC_CLSH_K1_LSB,
-					0xFF, 0xC0);
-			wcd_clsh_set_buck_regulator_mode(codec,
-							 hph_mode);
-			if (clsh_d->state & WCD_CLSH_STATE_HPHL)
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-						0x40, 0x40);
-			if (clsh_d->state & WCD_CLSH_STATE_HPHR)
-				snd_soc_update_bits(codec,
-						WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-						0x40, 0x40);
-			wcd_clsh_set_hph_mode(codec, hph_mode);
-		}
-	}
-end:
-	return;
-}
-
-static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec,
-				  struct wcd_clsh_cdc_data *clsh_d,
-				  u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (mode == CLS_AB || mode == CLS_AB_HIFI)
-		return;
-
-	if (is_enable) {
-		if (req_state == WCD_CLSH_STATE_HPHL)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x40);
-		if (req_state == WCD_CLSH_STATE_HPHR)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x40);
-	} else {
-		if (req_state == WCD_CLSH_STATE_HPHL)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x00);
-		if (req_state == WCD_CLSH_STATE_HPHR)
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x00);
-	}
-}
-
-static void wcd_clsh_state_hph_r(struct snd_soc_codec *codec,
-				 struct wcd_clsh_cdc_data *clsh_d,
-				 u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (mode == CLS_H_NORMAL) {
-		dev_err(codec->dev, "%s: Normal mode not applicable for hph_r\n",
-			__func__);
-		return;
-	}
-
-	if (is_enable) {
-		if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-			wcd_enable_clsh_block(codec, clsh_d, true);
-			/*
-			 * These K1 values depend on the Headphone Impedance
-			 * For now it is assumed to be 16 ohm
-			 */
-			snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_MSB,
-					    0x0F, 0x00);
-			snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB,
-					    0xFF, 0xC0);
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x40);
-		}
-		wcd_clsh_set_buck_regulator_mode(codec, mode);
-		wcd_clsh_set_flyback_mode(codec, mode);
-		wcd_clsh_gm3_boost_disable(codec, mode);
-		wcd_clsh_force_iq_ctl(codec, mode);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_flyback_current(codec, mode);
-		wcd_clsh_set_buck_mode(codec, mode);
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_hph_mode(codec, mode);
-		wcd_clsh_set_gain_path(codec, mode);
-	} else {
-		wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
-
-		if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
-					    0x40, 0x00);
-			wcd_enable_clsh_block(codec, clsh_d, false);
-		}
-		/* buck and flyback set to default mode and disable */
-		wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
-		wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
-		wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
-		wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
-	}
-}
-
-static void wcd_clsh_state_hph_l(struct snd_soc_codec *codec,
-				 struct wcd_clsh_cdc_data *clsh_d,
-				 u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (mode == CLS_H_NORMAL) {
-		dev_err(codec->dev, "%s: Normal mode not applicable for hph_l\n",
-			__func__);
-		return;
-	}
-
-	if (is_enable) {
-		if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-			wcd_enable_clsh_block(codec, clsh_d, true);
-			/*
-			 * These K1 values depend on the Headphone Impedance
-			 * For now it is assumed to be 16 ohm
-			 */
-			snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_MSB,
-					    0x0F, 0x00);
-			snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB,
-					    0xFF, 0xC0);
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x40);
-		}
-		wcd_clsh_set_buck_regulator_mode(codec, mode);
-		wcd_clsh_set_flyback_mode(codec, mode);
-		wcd_clsh_gm3_boost_disable(codec, mode);
-		wcd_clsh_force_iq_ctl(codec, mode);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_flyback_current(codec, mode);
-		wcd_clsh_set_buck_mode(codec, mode);
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_hph_mode(codec, mode);
-		wcd_clsh_set_gain_path(codec, mode);
-	} else {
-		wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
-
-		if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-			snd_soc_update_bits(codec,
-					    WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
-					    0x40, 0x00);
-			wcd_enable_clsh_block(codec, clsh_d, false);
-		}
-		/* set buck and flyback to Default Mode */
-		wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
-		wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
-		wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
-		wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
-	}
-}
-
-static void wcd_clsh_state_ear(struct snd_soc_codec *codec,
-		struct wcd_clsh_cdc_data *clsh_d,
-		u8 req_state, bool is_enable, int mode)
-{
-	dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
-		is_enable ? "enable" : "disable");
-
-	if (mode != CLS_H_NORMAL) {
-		dev_err(codec->dev, "%s: mode: %s cannot be used for EAR\n",
-			__func__, mode_to_str(mode));
-		return;
-	}
-
-	if (is_enable) {
-		wcd_enable_clsh_block(codec, clsh_d, true);
-		snd_soc_update_bits(codec,
-				    WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-				    0x40, 0x40);
-		wcd_clsh_set_buck_mode(codec, mode);
-		wcd_clsh_set_flyback_mode(codec, mode);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
-		wcd_clsh_set_flyback_current(codec, mode);
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
-	} else {
-		snd_soc_update_bits(codec,
-				    WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
-				    0x40, 0x00);
-		wcd_enable_clsh_block(codec, clsh_d, false);
-		wcd_clsh_buck_ctrl(codec, clsh_d, mode, false);
-		wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false);
-		wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
-		wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
-	}
-}
-
-static void wcd_clsh_state_err(struct snd_soc_codec *codec,
-		struct wcd_clsh_cdc_data *clsh_d,
-		u8 req_state, bool is_enable, int mode)
-{
-	char msg[128];
-
-	dev_err(codec->dev,
-		"%s Wrong request for class H state machine requested to %s %s",
-		__func__, is_enable ? "enable" : "disable",
-		state_to_str(req_state, msg, sizeof(msg)));
-	WARN_ON(1);
-}
-
-/*
- * Function: wcd_clsh_is_state_valid
- * Params: state
- * Description:
- * Provides information on valid states of Class H configuration
- */
-static bool wcd_clsh_is_state_valid(u8 state)
-{
-	switch (state) {
-	case WCD_CLSH_STATE_IDLE:
-	case WCD_CLSH_STATE_EAR:
-	case WCD_CLSH_STATE_HPHL:
-	case WCD_CLSH_STATE_HPHR:
-	case WCD_CLSH_STATE_HPH_ST:
-	case WCD_CLSH_STATE_LO:
-	case WCD_CLSH_STATE_HPHL_EAR:
-	case WCD_CLSH_STATE_HPHR_EAR:
-	case WCD_CLSH_STATE_HPH_ST_EAR:
-	case WCD_CLSH_STATE_HPHL_LO:
-	case WCD_CLSH_STATE_HPHR_LO:
-	case WCD_CLSH_STATE_HPH_ST_LO:
-	case WCD_CLSH_STATE_EAR_LO:
-		return true;
-	default:
-		return false;
-	};
-}
-
-/*
- * Function: wcd_clsh_fsm
- * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event
- * Description:
- * This function handles PRE DAC and POST DAC conditions of different devices
- * and updates class H configuration of different combination of devices
- * based on validity of their states. cdc_clsh_d will contain current
- * class h state information
- */
-void wcd_clsh_fsm(struct snd_soc_codec *codec,
-		struct wcd_clsh_cdc_data *cdc_clsh_d,
-		u8 clsh_event, u8 req_state,
-		int int_mode)
-{
-	u8 old_state, new_state;
-	char msg0[128], msg1[128];
-
-	switch (clsh_event) {
-	case WCD_CLSH_EVENT_PRE_DAC:
-		old_state = cdc_clsh_d->state;
-		new_state = old_state | req_state;
-
-		if (!wcd_clsh_is_state_valid(new_state)) {
-			dev_err(codec->dev,
-				"%s: Class-H not a valid new state: %s\n",
-				__func__,
-				state_to_str(new_state, msg0, sizeof(msg0)));
-			return;
-		}
-		if (new_state == old_state) {
-			dev_err(codec->dev,
-				"%s: Class-H already in requested state: %s\n",
-				__func__,
-				state_to_str(new_state, msg0, sizeof(msg0)));
-			return;
-		}
-		cdc_clsh_d->state = new_state;
-		wcd_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode);
-		(*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state,
-					     CLSH_REQ_ENABLE, int_mode);
-		dev_dbg(codec->dev,
-			"%s: ClassH state transition from %s to %s\n",
-			__func__, state_to_str(old_state, msg0, sizeof(msg0)),
-			state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1)));
-		break;
-	case WCD_CLSH_EVENT_POST_PA:
-		old_state = cdc_clsh_d->state;
-		new_state = old_state & (~req_state);
-		if (new_state < NUM_CLSH_STATES_V2) {
-			if (!wcd_clsh_is_state_valid(old_state)) {
-				dev_err(codec->dev,
-					"%s:Invalid old state:%s\n",
-					__func__,
-					state_to_str(old_state, msg0,
-						     sizeof(msg0)));
-				return;
-			}
-			if (new_state == old_state) {
-				dev_err(codec->dev,
-					"%s: Class-H already in requested state: %s\n",
-					__func__,
-					state_to_str(new_state, msg0,
-						     sizeof(msg0)));
-				return;
-			}
-			(*clsh_state_fp[old_state]) (codec, cdc_clsh_d,
-					req_state, CLSH_REQ_DISABLE,
-					int_mode);
-			cdc_clsh_d->state = new_state;
-			wcd_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE);
-			dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
-				__func__, state_to_str(old_state, msg0,
-						       sizeof(msg0)),
-				state_to_str(cdc_clsh_d->state, msg1,
-					     sizeof(msg1)));
-		}
-		break;
-	};
-}
-EXPORT_SYMBOL(wcd_clsh_fsm);
-
-int wcd_clsh_get_clsh_state(struct wcd_clsh_cdc_data *clsh)
-{
-	return clsh->state;
-}
-EXPORT_SYMBOL(wcd_clsh_get_clsh_state);
-
-void wcd_clsh_init(struct wcd_clsh_cdc_data *clsh)
-{
-	int i;
-
-	clsh->state = WCD_CLSH_STATE_IDLE;
-
-	for (i = 0; i < NUM_CLSH_STATES_V2; i++)
-		clsh_state_fp[i] = wcd_clsh_state_err;
-
-	clsh_state_fp[WCD_CLSH_STATE_EAR] = wcd_clsh_state_ear;
-	clsh_state_fp[WCD_CLSH_STATE_HPHL] =
-						wcd_clsh_state_hph_l;
-	clsh_state_fp[WCD_CLSH_STATE_HPHR] =
-						wcd_clsh_state_hph_r;
-	clsh_state_fp[WCD_CLSH_STATE_HPH_ST] =
-						wcd_clsh_state_hph_st;
-	clsh_state_fp[WCD_CLSH_STATE_LO] = wcd_clsh_state_lo;
-	clsh_state_fp[WCD_CLSH_STATE_HPHL_EAR] =
-						wcd_clsh_state_hph_ear;
-	clsh_state_fp[WCD_CLSH_STATE_HPHR_EAR] =
-						wcd_clsh_state_hph_ear;
-	clsh_state_fp[WCD_CLSH_STATE_HPH_ST_EAR] =
-						wcd_clsh_state_hph_ear;
-	clsh_state_fp[WCD_CLSH_STATE_HPHL_LO] = wcd_clsh_state_hph_lo;
-	clsh_state_fp[WCD_CLSH_STATE_HPHR_LO] = wcd_clsh_state_hph_lo;
-	clsh_state_fp[WCD_CLSH_STATE_HPH_ST_LO] =
-						wcd_clsh_state_hph_lo;
-	clsh_state_fp[WCD_CLSH_STATE_EAR_LO] = wcd_clsh_state_ear_lo;
-	/* Set interpolaotr modes to NONE */
-	wcd_clsh_set_int_mode(clsh, WCD_CLSH_STATE_EAR, CLS_NONE);
-	wcd_clsh_set_int_mode(clsh, WCD_CLSH_STATE_HPHL, CLS_NONE);
-	wcd_clsh_set_int_mode(clsh, WCD_CLSH_STATE_HPHR, CLS_NONE);
-	wcd_clsh_set_int_mode(clsh, WCD_CLSH_STATE_LO, CLS_NONE);
-	clsh->flyback_users = 0;
-	clsh->buck_users = 0;
-	clsh->clsh_users = 0;
-}
-EXPORT_SYMBOL(wcd_clsh_init);
-
-MODULE_DESCRIPTION("WCD9XXX Common Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd9xxx-common-v2.h b/sound/soc/codecs/wcd9xxx-common-v2.h
deleted file mode 100644
index 53c9a84..0000000
--- a/sound/soc/codecs/wcd9xxx-common-v2.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _WCD9XXX_COMMON_V2
-
-#define _WCD9XXX_COMMON_V2
-
-#define CLSH_REQ_ENABLE true
-#define CLSH_REQ_DISABLE false
-
-#define WCD_CLSH_EVENT_PRE_DAC 0x01
-#define WCD_CLSH_EVENT_POST_PA 0x02
-#define MAX_VBAT_MONITOR_WRITES 17
-/*
- * Basic states for Class H state machine.
- * represented as a bit mask within a u8 data type
- * bit 0: EAR mode
- * bit 1: HPH Left mode
- * bit 2: HPH Right mode
- * bit 3: Lineout mode
- */
-#define	WCD_CLSH_STATE_IDLE 0x00
-#define	WCD_CLSH_STATE_EAR (0x01 << 0)
-#define	WCD_CLSH_STATE_HPHL (0x01 << 1)
-#define	WCD_CLSH_STATE_HPHR (0x01 << 2)
-#define	WCD_CLSH_STATE_LO (0x01 << 3)
-
-/*
- * Though number of CLSH states are 4, max state shoulbe be 5
- * because state array index starts from 1.
- */
-#define WCD_CLSH_STATE_MAX 5
-#define NUM_CLSH_STATES_V2 (0x01 << WCD_CLSH_STATE_MAX)
-
-
-/* Derived State: Bits 1 and 2 should be set for Headphone stereo */
-#define WCD_CLSH_STATE_HPH_ST (WCD_CLSH_STATE_HPHL | \
-			       WCD_CLSH_STATE_HPHR)
-
-#define WCD_CLSH_STATE_HPHL_LO (WCD_CLSH_STATE_HPHL | \
-				    WCD_CLSH_STATE_LO)
-#define WCD_CLSH_STATE_HPHR_LO (WCD_CLSH_STATE_HPHR | \
-				    WCD_CLSH_STATE_LO)
-#define WCD_CLSH_STATE_HPH_ST_LO (WCD_CLSH_STATE_HPH_ST | \
-				      WCD_CLSH_STATE_LO)
-#define WCD_CLSH_STATE_EAR_LO (WCD_CLSH_STATE_EAR | \
-				   WCD_CLSH_STATE_LO)
-#define WCD_CLSH_STATE_HPHL_EAR (WCD_CLSH_STATE_HPHL | \
-				     WCD_CLSH_STATE_EAR)
-#define WCD_CLSH_STATE_HPHR_EAR (WCD_CLSH_STATE_HPHR | \
-				     WCD_CLSH_STATE_EAR)
-#define WCD_CLSH_STATE_HPH_ST_EAR (WCD_CLSH_STATE_HPH_ST | \
-				       WCD_CLSH_STATE_EAR)
-
-enum {
-	CLS_H_NORMAL = 0, /* Class-H Default */
-	CLS_H_HIFI, /* Class-H HiFi */
-	CLS_H_LP, /* Class-H Low Power */
-	CLS_AB, /* Class-AB Low HIFI*/
-	CLS_H_LOHIFI, /* LoHIFI */
-	CLS_H_ULP, /* Ultra Low power */
-	CLS_AB_HIFI, /* Class-AB */
-	CLS_NONE, /* None of the above modes */
-};
-
-/* Class H data that the codec driver will maintain */
-struct wcd_clsh_cdc_data {
-	u8 state;
-	int flyback_users;
-	int buck_users;
-	int clsh_users;
-	int interpolator_modes[WCD_CLSH_STATE_MAX];
-};
-
-struct wcd_mad_audio_header {
-	u32 reserved[3];
-	u32 num_reg_cfg;
-};
-
-struct wcd_mad_microphone_info {
-	uint8_t input_microphone;
-	uint8_t cycle_time;
-	uint8_t settle_time;
-	uint8_t padding;
-} __packed;
-
-struct wcd_mad_micbias_info {
-	uint8_t micbias;
-	uint8_t k_factor;
-	uint8_t external_bypass_capacitor;
-	uint8_t internal_biasing;
-	uint8_t cfilter;
-	uint8_t padding[3];
-} __packed;
-
-struct wcd_mad_rms_audio_beacon_info {
-	uint8_t rms_omit_samples;
-	uint8_t rms_comp_time;
-	uint8_t detection_mechanism;
-	uint8_t rms_diff_threshold;
-	uint8_t rms_threshold_lsb;
-	uint8_t rms_threshold_msb;
-	uint8_t padding[2];
-	uint8_t iir_coefficients[36];
-} __packed;
-
-struct wcd_mad_rms_ultrasound_info {
-	uint8_t rms_comp_time;
-	uint8_t detection_mechanism;
-	uint8_t rms_diff_threshold;
-	uint8_t rms_threshold_lsb;
-	uint8_t rms_threshold_msb;
-	uint8_t padding[3];
-	uint8_t iir_coefficients[36];
-} __packed;
-
-struct wcd_mad_audio_cal {
-	uint32_t version;
-	struct wcd_mad_microphone_info microphone_info;
-	struct wcd_mad_micbias_info micbias_info;
-	struct wcd_mad_rms_audio_beacon_info audio_info;
-	struct wcd_mad_rms_audio_beacon_info beacon_info;
-	struct wcd_mad_rms_ultrasound_info ultrasound_info;
-} __packed;
-
-struct wcd9xxx_anc_header {
-	u32 reserved[3];
-	u32 num_anc_slots;
-};
-
-struct vbat_monitor_reg {
-	u32 size;
-	u32 writes[MAX_VBAT_MONITOR_WRITES];
-} __packed;
-
-struct wcd_reg_mask_val {
-	u16	reg;
-	u8	mask;
-	u8	val;
-};
-
-extern void wcd_clsh_fsm(struct snd_soc_codec *codec,
-		struct wcd_clsh_cdc_data *cdc_clsh_d,
-		u8 clsh_event, u8 req_state,
-		int int_mode);
-
-extern void wcd_clsh_init(struct wcd_clsh_cdc_data *clsh);
-extern int wcd_clsh_get_clsh_state(struct wcd_clsh_cdc_data *clsh);
-extern void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped,
-		bool reset);
-
-enum {
-	RESERVED = 0,
-	AANC_LPF_FF_FB = 1,
-	AANC_LPF_COEFF_MSB,
-	AANC_LPF_COEFF_LSB,
-	HW_MAD_AUDIO_ENABLE,
-	HW_MAD_ULTR_ENABLE,
-	HW_MAD_BEACON_ENABLE,
-	HW_MAD_AUDIO_SLEEP_TIME,
-	HW_MAD_ULTR_SLEEP_TIME,
-	HW_MAD_BEACON_SLEEP_TIME,
-	HW_MAD_TX_AUDIO_SWITCH_OFF,
-	HW_MAD_TX_ULTR_SWITCH_OFF,
-	HW_MAD_TX_BEACON_SWITCH_OFF,
-	MAD_AUDIO_INT_DEST_SELECT_REG,
-	MAD_ULT_INT_DEST_SELECT_REG,
-	MAD_BEACON_INT_DEST_SELECT_REG,
-	MAD_CLIP_INT_DEST_SELECT_REG,
-	VBAT_INT_DEST_SELECT_REG,
-	MAD_AUDIO_INT_MASK_REG,
-	MAD_ULT_INT_MASK_REG,
-	MAD_BEACON_INT_MASK_REG,
-	MAD_CLIP_INT_MASK_REG,
-	VBAT_INT_MASK_REG,
-	MAD_AUDIO_INT_STATUS_REG,
-	MAD_ULT_INT_STATUS_REG,
-	MAD_BEACON_INT_STATUS_REG,
-	MAD_CLIP_INT_STATUS_REG,
-	VBAT_INT_STATUS_REG,
-	MAD_AUDIO_INT_CLEAR_REG,
-	MAD_ULT_INT_CLEAR_REG,
-	MAD_BEACON_INT_CLEAR_REG,
-	MAD_CLIP_INT_CLEAR_REG,
-	VBAT_INT_CLEAR_REG,
-	SB_PGD_PORT_TX_WATERMARK_N,
-	SB_PGD_PORT_TX_ENABLE_N,
-	SB_PGD_PORT_RX_WATERMARK_N,
-	SB_PGD_PORT_RX_ENABLE_N,
-	SB_PGD_TX_PORTn_MULTI_CHNL_0,
-	SB_PGD_TX_PORTn_MULTI_CHNL_1,
-	SB_PGD_RX_PORTn_MULTI_CHNL_0,
-	SB_PGD_RX_PORTn_MULTI_CHNL_1,
-	AANC_FF_GAIN_ADAPTIVE,
-	AANC_FFGAIN_ADAPTIVE_EN,
-	AANC_GAIN_CONTROL,
-	SPKR_CLIP_PIPE_BANK_SEL,
-	SPKR_CLIPDET_VAL0,
-	SPKR_CLIPDET_VAL1,
-	SPKR_CLIPDET_VAL2,
-	SPKR_CLIPDET_VAL3,
-	SPKR_CLIPDET_VAL4,
-	SPKR_CLIPDET_VAL5,
-	SPKR_CLIPDET_VAL6,
-	SPKR_CLIPDET_VAL7,
-	VBAT_RELEASE_INT_DEST_SELECT_REG,
-	VBAT_RELEASE_INT_MASK_REG,
-	VBAT_RELEASE_INT_STATUS_REG,
-	VBAT_RELEASE_INT_CLEAR_REG,
-	MAD2_CLIP_INT_DEST_SELECT_REG,
-	MAD2_CLIP_INT_MASK_REG,
-	MAD2_CLIP_INT_STATUS_REG,
-	MAD2_CLIP_INT_CLEAR_REG,
-	SPKR2_CLIP_PIPE_BANK_SEL,
-	SPKR2_CLIPDET_VAL0,
-	SPKR2_CLIPDET_VAL1,
-	SPKR2_CLIPDET_VAL2,
-	SPKR2_CLIPDET_VAL3,
-	SPKR2_CLIPDET_VAL4,
-	SPKR2_CLIPDET_VAL5,
-	SPKR2_CLIPDET_VAL6,
-	SPKR2_CLIPDET_VAL7,
-	MAX_CFG_REGISTERS,
-};
-
-#endif
diff --git a/sound/soc/codecs/wcd9xxx-resmgr-v2.c b/sound/soc/codecs/wcd9xxx-resmgr-v2.c
deleted file mode 100644
index feef0a4..0000000
--- a/sound/soc/codecs/wcd9xxx-resmgr-v2.c
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9335/registers.h>
-#include <linux/mfd/wcd934x/registers.h>
-#include <sound/soc.h>
-#include "wcd9xxx-resmgr-v2.h"
-
-#define WCD9XXX_RCO_CALIBRATION_DELAY_INC_US 5000
-#define WCD93XX_ANA_BIAS 0x0601
-#define WCD93XX_CDC_CLK_RST_CTRL_MCLK_CONTROL 0x0d41
-#define WCD93XX_CDC_CLK_RST_CTRL_FS_CNT_CONTROL 0x0d42
-
-
-static const char *wcd_resmgr_clk_type_to_str(enum wcd_clock_type clk_type)
-{
-	if (clk_type == WCD_CLK_OFF)
-		return "WCD_CLK_OFF";
-	else if (clk_type == WCD_CLK_RCO)
-		return "WCD_CLK_RCO";
-	else if (clk_type == WCD_CLK_MCLK)
-		return "WCD_CLK_MCLK";
-	else
-		return "WCD_CLK_UNDEFINED";
-}
-
-static int wcd_resmgr_codec_reg_update_bits(struct wcd9xxx_resmgr_v2 *resmgr,
-					    u16 reg, u8 mask, u8 val)
-{
-	bool change;
-	int ret;
-
-	if (resmgr->codec_type == WCD934X) {
-		/* Tavil does not support ANA_CLK_TOP register */
-		if (reg == WCD9335_ANA_CLK_TOP)
-			return 0;
-	} else {
-		/* Tasha does not support CLK_SYS_MCLK_PRG register */
-		if (reg == WCD934X_CLK_SYS_MCLK_PRG)
-			return 0;
-	}
-	if (resmgr->codec) {
-		ret = snd_soc_update_bits(resmgr->codec, reg, mask, val);
-	} else if (resmgr->core_res->wcd_core_regmap) {
-		ret = regmap_update_bits_check(
-				resmgr->core_res->wcd_core_regmap,
-				reg, mask, val, &change);
-		if (!ret)
-			ret = change;
-	} else {
-		pr_err("%s: codec/regmap not defined\n", __func__);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int wcd_resmgr_codec_reg_read(struct wcd9xxx_resmgr_v2 *resmgr,
-				     unsigned int reg)
-{
-	int val, ret;
-
-	if (resmgr->codec_type == WCD934X) {
-		if (reg == WCD9335_ANA_CLK_TOP)
-			return 0;
-	} else {
-		if (reg == WCD934X_CLK_SYS_MCLK_PRG)
-			return 0;
-	}
-	if (resmgr->codec) {
-		val = snd_soc_read(resmgr->codec, reg);
-	} else if (resmgr->core_res->wcd_core_regmap) {
-		ret = regmap_read(resmgr->core_res->wcd_core_regmap,
-				  reg, &val);
-		if (ret)
-			val = ret;
-	} else {
-		pr_err("%s: wcd regmap is null\n", __func__);
-		return -EINVAL;
-	}
-
-	return val;
-}
-
-/*
- * wcd_resmgr_get_clk_type()
- * Returns clk type that is currently enabled
- */
-int wcd_resmgr_get_clk_type(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	if (!resmgr) {
-		pr_err("%s: resmgr not initialized\n", __func__);
-		return -EINVAL;
-	}
-	return resmgr->clk_type;
-}
-EXPORT_SYMBOL(wcd_resmgr_get_clk_type);
-
-static void wcd_resmgr_cdc_specific_get_clk(struct wcd9xxx_resmgr_v2 *resmgr,
-						int clk_users)
-{
-	/* Caller of this function should have acquired BG_CLK lock */
-	if (clk_users) {
-		if (resmgr->resmgr_cb &&
-		    resmgr->resmgr_cb->cdc_rco_ctrl) {
-			while (clk_users--)
-				resmgr->resmgr_cb->cdc_rco_ctrl(resmgr->codec,
-								true);
-		}
-	}
-}
-
-/*
- * wcd_resmgr_post_ssr_v2
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- */
-void wcd_resmgr_post_ssr_v2(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	int old_bg_audio_users;
-	int old_clk_rco_users, old_clk_mclk_users;
-
-	WCD9XXX_V2_BG_CLK_LOCK(resmgr);
-
-	old_bg_audio_users = resmgr->master_bias_users;
-	old_clk_mclk_users = resmgr->clk_mclk_users;
-	old_clk_rco_users = resmgr->clk_rco_users;
-	resmgr->master_bias_users = 0;
-	resmgr->clk_mclk_users = 0;
-	resmgr->clk_rco_users = 0;
-	resmgr->clk_type = WCD_CLK_OFF;
-
-	pr_debug("%s: old_bg_audio_users=%d old_clk_mclk_users=%d old_clk_rco_users=%d\n",
-		 __func__, old_bg_audio_users,
-		 old_clk_mclk_users, old_clk_rco_users);
-
-	if (old_bg_audio_users) {
-		while (old_bg_audio_users--)
-			wcd_resmgr_enable_master_bias(resmgr);
-	}
-
-	if (old_clk_mclk_users) {
-		while (old_clk_mclk_users--)
-			wcd_resmgr_enable_clk_block(resmgr, WCD_CLK_MCLK);
-	}
-
-	if (old_clk_rco_users)
-		wcd_resmgr_cdc_specific_get_clk(resmgr, old_clk_rco_users);
-
-	WCD9XXX_V2_BG_CLK_UNLOCK(resmgr);
-}
-EXPORT_SYMBOL(wcd_resmgr_post_ssr_v2);
-
-/*
- * wcd_resmgr_enable_master_bias: enable codec master bias
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- */
-int wcd_resmgr_enable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	mutex_lock(&resmgr->master_bias_lock);
-
-	resmgr->master_bias_users++;
-	if (resmgr->master_bias_users == 1) {
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD93XX_ANA_BIAS,
-						 0x80, 0x80);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD93XX_ANA_BIAS,
-						 0x40, 0x40);
-		/*
-		 * 1ms delay is required after pre-charge is enabled
-		 * as per HW requirement
-		 */
-		usleep_range(1000, 1100);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD93XX_ANA_BIAS,
-						 0x40, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-						WCD93XX_ANA_BIAS, 0x20, 0x00);
-	}
-
-	pr_debug("%s: current master bias users: %d\n", __func__,
-		 resmgr->master_bias_users);
-
-	mutex_unlock(&resmgr->master_bias_lock);
-	return 0;
-}
-EXPORT_SYMBOL(wcd_resmgr_enable_master_bias);
-
-/*
- * wcd_resmgr_disable_master_bias: disable codec master bias
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- */
-int wcd_resmgr_disable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	mutex_lock(&resmgr->master_bias_lock);
-	if (resmgr->master_bias_users <= 0) {
-		mutex_unlock(&resmgr->master_bias_lock);
-		return -EINVAL;
-	}
-
-	resmgr->master_bias_users--;
-	if (resmgr->master_bias_users == 0) {
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD93XX_ANA_BIAS,
-						 0x80, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-						WCD93XX_ANA_BIAS, 0x20, 0x00);
-	}
-	mutex_unlock(&resmgr->master_bias_lock);
-	return 0;
-}
-EXPORT_SYMBOL(wcd_resmgr_disable_master_bias);
-
-static int wcd_resmgr_enable_clk_mclk(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	/* Enable mclk requires master bias to be enabled first */
-	if (resmgr->master_bias_users <= 0) {
-		pr_err("%s: Cannot turn on MCLK, BG is not enabled\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (((resmgr->clk_mclk_users == 0) &&
-	     (resmgr->clk_type == WCD_CLK_MCLK)) ||
-	    ((resmgr->clk_mclk_users > 0) &&
-	    (resmgr->clk_type != WCD_CLK_MCLK))) {
-		pr_err("%s: Error enabling MCLK, clk_type: %s\n",
-			__func__,
-			wcd_resmgr_clk_type_to_str(resmgr->clk_type));
-		return -EINVAL;
-	}
-
-	if (++resmgr->clk_mclk_users == 1) {
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-				WCD9335_ANA_CLK_TOP, 0x80, 0x80);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-				WCD9335_ANA_CLK_TOP, 0x08, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-				WCD9335_ANA_CLK_TOP, 0x04, 0x04);
-		if (resmgr->codec_type == WCD934X) {
-			/*
-			 * In tavil clock contrl register is changed
-			 * to CLK_SYS_MCLK_PRG
-			 */
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x80, 0x80);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x30, 0x10);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x02, 0x00);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x01, 0x01);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x02, 0x00);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD93XX_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x01, 0x01);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD93XX_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x01, 0x01);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD93XX_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x01, 0x01);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CODEC_RPM_CLK_GATE, 0x03, 0x00);
-		} else {
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD93XX_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
-					0x01, 0x01);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD93XX_CDC_CLK_RST_CTRL_MCLK_CONTROL,
-					0x01, 0x01);
-		}
-		/*
-		 * 10us sleep is required after clock is enabled
-		 * as per HW requirement
-		 */
-		usleep_range(10, 15);
-	}
-
-	resmgr->clk_type = WCD_CLK_MCLK;
-
-	pr_debug("%s: mclk_users: %d, clk_type: %s\n", __func__,
-		 resmgr->clk_mclk_users,
-		 wcd_resmgr_clk_type_to_str(resmgr->clk_type));
-
-	return 0;
-}
-
-static int wcd_resmgr_disable_clk_mclk(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	if (resmgr->clk_mclk_users <= 0) {
-		pr_err("%s: No mclk users, cannot disable mclk\n", __func__);
-		return -EINVAL;
-	}
-
-	if (--resmgr->clk_mclk_users == 0) {
-		if (resmgr->clk_rco_users > 0) {
-			/* MCLK to RCO switch */
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD9335_ANA_CLK_TOP,
-					0x08, 0x08);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x02, 0x02);
-			/* Disable clock buffer */
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x80, 0x00);
-			resmgr->clk_type = WCD_CLK_RCO;
-		} else {
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD9335_ANA_CLK_TOP,
-					0x04, 0x00);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-					WCD934X_CLK_SYS_MCLK_PRG, 0x81, 0x00);
-			resmgr->clk_type = WCD_CLK_OFF;
-		}
-
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_CLK_TOP,
-						 0x80, 0x00);
-	}
-
-	if ((resmgr->codec_type == WCD934X) &&
-	    (resmgr->clk_type == WCD_CLK_OFF))
-		wcd_resmgr_set_sido_input_src(resmgr, SIDO_SOURCE_INTERNAL);
-
-	pr_debug("%s: mclk_users: %d, clk_type: %s\n", __func__,
-		 resmgr->clk_mclk_users,
-		 wcd_resmgr_clk_type_to_str(resmgr->clk_type));
-
-	return 0;
-}
-
-static void wcd_resmgr_set_buck_accuracy(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-					 0x02, 0x02);
-	/* 100us sleep needed after HIGH_ACCURACY_PRE_EN1 */
-	usleep_range(100, 110);
-	wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-					 0x01, 0x01);
-	/* 100us sleep needed after HIGH_ACCURACY_PRE_EN2 */
-	usleep_range(100, 110);
-	wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-					 0x04, 0x04);
-	/* 100us sleep needed after HIGH_ACCURACY_EN */
-	usleep_range(100, 110);
-}
-
-static int wcd_resmgr_enable_clk_rco(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	bool rco_cal_done = true;
-
-	resmgr->clk_rco_users++;
-	if ((resmgr->clk_rco_users == 1) &&
-	    ((resmgr->clk_type == WCD_CLK_OFF) ||
-	     (resmgr->clk_mclk_users == 0))) {
-		pr_warn("%s: RCO enable requires MCLK to be ON first\n",
-			__func__);
-		resmgr->clk_rco_users--;
-		return -EINVAL;
-	} else if ((resmgr->clk_rco_users == 1) &&
-		   (resmgr->clk_mclk_users)) {
-		/* RCO Enable */
-		if (resmgr->sido_input_src == SIDO_SOURCE_INTERNAL) {
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-							 WCD9335_ANA_RCO,
-							 0x80, 0x80);
-			if (resmgr->codec_type == WCD934X)
-				wcd_resmgr_set_buck_accuracy(resmgr);
-		}
-
-		/*
-		 * 20us required after RCO BG is enabled as per HW
-		 * requirements
-		 */
-		usleep_range(20, 25);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_RCO,
-						 0x40, 0x40);
-		/*
-		 * 20us required after RCO is enabled as per HW
-		 * requirements
-		 */
-		usleep_range(20, 25);
-		/* RCO Calibration */
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_RCO,
-						 0x04, 0x04);
-		if (resmgr->codec_type == WCD934X)
-			/*
-			 * For wcd934x codec, 20us sleep is needed
-			 * after enabling RCO calibration
-			 */
-			usleep_range(20, 25);
-
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_RCO,
-						 0x04, 0x00);
-		if (resmgr->codec_type == WCD934X)
-			/*
-			 * For wcd934x codec, 20us sleep is needed
-			 * after disabling RCO calibration
-			 */
-			usleep_range(20, 25);
-
-		/* RCO calibration takes app. 5ms to complete */
-		usleep_range(WCD9XXX_RCO_CALIBRATION_DELAY_INC_US,
-		       WCD9XXX_RCO_CALIBRATION_DELAY_INC_US + 100);
-		if (wcd_resmgr_codec_reg_read(resmgr, WCD9335_ANA_RCO) & 0x02)
-			rco_cal_done = false;
-
-		WARN((!rco_cal_done), "RCO Calibration failed\n");
-
-		/* Switch MUX to RCO */
-		if (resmgr->clk_mclk_users == 1) {
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-							WCD9335_ANA_CLK_TOP,
-							0x08, 0x08);
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-						 WCD934X_CLK_SYS_MCLK_PRG,
-						 0x02, 0x02);
-			resmgr->clk_type = WCD_CLK_RCO;
-		}
-	}
-	pr_debug("%s: rco clk users: %d, clk_type: %s\n", __func__,
-		 resmgr->clk_rco_users,
-		 wcd_resmgr_clk_type_to_str(resmgr->clk_type));
-
-	return 0;
-}
-
-static int wcd_resmgr_disable_clk_rco(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	if ((resmgr->clk_rco_users <= 0) ||
-	    (resmgr->clk_type == WCD_CLK_OFF)) {
-		pr_err("%s: rco_clk_users = %d, clk_type = %d, cannot disable\n",
-			__func__, resmgr->clk_rco_users, resmgr->clk_type);
-		return -EINVAL;
-	}
-
-	resmgr->clk_rco_users--;
-
-	if ((resmgr->clk_rco_users == 0) &&
-	    (resmgr->clk_type == WCD_CLK_RCO)) {
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_CLK_TOP,
-						 0x08, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-						 WCD934X_CLK_SYS_MCLK_PRG,
-						 0x02, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_CLK_TOP,
-						 0x04, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_RCO,
-						 0x40, 0x00);
-		if (resmgr->sido_input_src == SIDO_SOURCE_INTERNAL)
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-							 WCD9335_ANA_RCO,
-							 0x80, 0x00);
-		wcd_resmgr_codec_reg_update_bits(resmgr,
-						 WCD934X_CLK_SYS_MCLK_PRG,
-						 0x01, 0x00);
-		resmgr->clk_type = WCD_CLK_OFF;
-	} else if ((resmgr->clk_rco_users == 0) &&
-	      (resmgr->clk_mclk_users)) {
-		/* Disable RCO while MCLK is ON */
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD9335_ANA_RCO,
-						 0x40, 0x00);
-		if (resmgr->sido_input_src == SIDO_SOURCE_INTERNAL)
-			wcd_resmgr_codec_reg_update_bits(resmgr,
-							 WCD9335_ANA_RCO,
-							 0x80, 0x00);
-	}
-
-	if ((resmgr->codec_type == WCD934X) &&
-	    (resmgr->clk_type == WCD_CLK_OFF))
-		wcd_resmgr_set_sido_input_src(resmgr, SIDO_SOURCE_INTERNAL);
-
-	pr_debug("%s: rco clk users: %d, clk_type: %s\n", __func__,
-		 resmgr->clk_rco_users,
-		 wcd_resmgr_clk_type_to_str(resmgr->clk_type));
-
-	return 0;
-}
-
-/*
- * wcd_resmgr_enable_clk_block: enable MCLK or RCO
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- * @type: Clock type to enable
- */
-int wcd_resmgr_enable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
-				enum wcd_clock_type type)
-{
-	int ret;
-
-	switch (type) {
-	case WCD_CLK_MCLK:
-		ret = wcd_resmgr_enable_clk_mclk(resmgr);
-		break;
-	case WCD_CLK_RCO:
-		ret = wcd_resmgr_enable_clk_rco(resmgr);
-		break;
-	default:
-		pr_err("%s: Unknown Clock type: %s\n", __func__,
-			wcd_resmgr_clk_type_to_str(type));
-		ret = -EINVAL;
-		break;
-	};
-
-	if (ret)
-		pr_err("%s: Enable clock %s failed\n", __func__,
-			wcd_resmgr_clk_type_to_str(type));
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd_resmgr_enable_clk_block);
-
-void wcd_resmgr_set_sido_input_src(struct wcd9xxx_resmgr_v2 *resmgr,
-					  int sido_src)
-{
-	if (!resmgr)
-		return;
-
-	if (sido_src == resmgr->sido_input_src)
-		return;
-
-	if (sido_src == SIDO_SOURCE_INTERNAL) {
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-						 0x04, 0x00);
-		usleep_range(100, 110);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-						 0x03, 0x00);
-		usleep_range(100, 110);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_RCO,
-						 0x80, 0x00);
-		usleep_range(100, 110);
-		resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
-		pr_debug("%s: sido input src to internal\n", __func__);
-	} else if (sido_src == SIDO_SOURCE_RCO_BG) {
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_RCO,
-						 0x80, 0x80);
-		usleep_range(100, 110);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-						 0x02, 0x02);
-		usleep_range(100, 110);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-						 0x01, 0x01);
-		usleep_range(100, 110);
-		wcd_resmgr_codec_reg_update_bits(resmgr, WCD934X_ANA_BUCK_CTL,
-						 0x04, 0x04);
-		usleep_range(100, 110);
-		resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
-		pr_debug("%s: sido input src to external\n", __func__);
-	}
-}
-EXPORT_SYMBOL(wcd_resmgr_set_sido_input_src);
-
-/*
- * wcd_resmgr_set_sido_input_src_locked:
- *   Set SIDO input in BG_CLK locked context
- *
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- * @sido_src: Select the SIDO input source
- */
-void wcd_resmgr_set_sido_input_src_locked(struct wcd9xxx_resmgr_v2 *resmgr,
-					  int sido_src)
-{
-	if (!resmgr)
-		return;
-
-	WCD9XXX_V2_BG_CLK_LOCK(resmgr);
-	wcd_resmgr_set_sido_input_src(resmgr, sido_src);
-	WCD9XXX_V2_BG_CLK_UNLOCK(resmgr);
-}
-EXPORT_SYMBOL(wcd_resmgr_set_sido_input_src_locked);
-
-/*
- * wcd_resmgr_disable_clk_block: disable MCLK or RCO
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- * @type: Clock type to disable
- */
-int wcd_resmgr_disable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
-				enum wcd_clock_type type)
-{
-	int ret;
-
-	switch (type) {
-	case WCD_CLK_MCLK:
-		ret = wcd_resmgr_disable_clk_mclk(resmgr);
-		break;
-	case WCD_CLK_RCO:
-		ret = wcd_resmgr_disable_clk_rco(resmgr);
-		break;
-	default:
-		pr_err("%s: Unknown Clock type: %s\n", __func__,
-			wcd_resmgr_clk_type_to_str(type));
-		ret = -EINVAL;
-		break;
-	};
-
-	if (ret)
-		pr_err("%s: Disable clock %s failed\n", __func__,
-			wcd_resmgr_clk_type_to_str(type));
-
-	return ret;
-}
-EXPORT_SYMBOL(wcd_resmgr_disable_clk_block);
-
-/*
- * wcd_resmgr_init: initialize wcd resource manager
- * @core_res: handle to struct wcd9xxx_core_resource
- *
- * Early init call without a handle to snd_soc_codec *
- */
-struct wcd9xxx_resmgr_v2 *wcd_resmgr_init(
-		struct wcd9xxx_core_resource *core_res,
-		struct snd_soc_codec *codec)
-{
-	struct wcd9xxx_resmgr_v2 *resmgr;
-	struct wcd9xxx *wcd9xxx;
-
-	resmgr = kzalloc(sizeof(struct wcd9xxx_resmgr_v2), GFP_KERNEL);
-	if (!resmgr)
-		return ERR_PTR(-ENOMEM);
-
-	wcd9xxx = container_of(core_res, struct wcd9xxx, core_res);
-	if (!wcd9xxx) {
-		kfree(resmgr);
-		pr_err("%s: Cannot get wcd9xx pointer\n", __func__);
-		return ERR_PTR(-EINVAL);
-	}
-
-	mutex_init(&resmgr->codec_bg_clk_lock);
-	mutex_init(&resmgr->master_bias_lock);
-	resmgr->master_bias_users = 0;
-	resmgr->clk_mclk_users = 0;
-	resmgr->clk_rco_users = 0;
-	resmgr->master_bias_users = 0;
-	resmgr->codec = codec;
-	resmgr->core_res = core_res;
-	resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
-	resmgr->codec_type = wcd9xxx->type;
-
-	return resmgr;
-}
-EXPORT_SYMBOL(wcd_resmgr_init);
-
-/*
- * wcd_resmgr_remove: Clean-up wcd resource manager
- * @resmgr: handle to struct wcd9xxx_resmgr_v2
- */
-void wcd_resmgr_remove(struct wcd9xxx_resmgr_v2 *resmgr)
-{
-	mutex_destroy(&resmgr->master_bias_lock);
-	kfree(resmgr);
-}
-EXPORT_SYMBOL(wcd_resmgr_remove);
-
-/*
- * wcd_resmgr_post_init: post init call to assign codec handle
- * @resmgr: handle to struct wcd9xxx_resmgr_v2 created during early init
- * @resmgr_cb: codec callback function for resmgr
- * @codec: handle to struct snd_soc_codec
- */
-int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr,
-			 const struct wcd_resmgr_cb *resmgr_cb,
-			 struct snd_soc_codec *codec)
-{
-	if (!resmgr) {
-		pr_err("%s: resmgr not allocated\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!codec) {
-		pr_err("%s: Codec memory is NULL, nothing to post init\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	resmgr->codec = codec;
-	resmgr->resmgr_cb = resmgr_cb;
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd_resmgr_post_init);
-
-MODULE_DESCRIPTION("wcd9xxx resmgr v2 module");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd9xxx-resmgr-v2.h b/sound/soc/codecs/wcd9xxx-resmgr-v2.h
deleted file mode 100644
index e831ba6..0000000
--- a/sound/soc/codecs/wcd9xxx-resmgr-v2.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9XXX_COMMON_V2_H__
-#define __WCD9XXX_COMMON_V2_H__
-
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
-
-enum wcd_clock_type {
-	WCD_CLK_OFF,
-	WCD_CLK_RCO,
-	WCD_CLK_MCLK,
-};
-
-enum {
-	SIDO_SOURCE_INTERNAL,
-	SIDO_SOURCE_RCO_BG,
-};
-
-struct wcd_resmgr_cb {
-	int (*cdc_rco_ctrl)(struct snd_soc_codec *, bool);
-};
-
-struct wcd9xxx_resmgr_v2 {
-	struct snd_soc_codec *codec;
-	struct wcd9xxx_core_resource *core_res;
-
-	int master_bias_users;
-	int clk_mclk_users;
-	int clk_rco_users;
-
-	struct mutex codec_bg_clk_lock;
-	struct mutex master_bias_lock;
-
-	enum codec_variant codec_type;
-	enum wcd_clock_type clk_type;
-
-	const struct wcd_resmgr_cb *resmgr_cb;
-	int sido_input_src;
-};
-
-#define WCD9XXX_V2_BG_CLK_LOCK(resmgr)			\
-{							\
-	struct wcd9xxx_resmgr_v2 *__resmgr = resmgr;	\
-	pr_debug("%s: Acquiring BG_CLK\n", __func__);	\
-	mutex_lock(&__resmgr->codec_bg_clk_lock);	\
-	pr_debug("%s: Acquiring BG_CLK done\n", __func__);	\
-}
-
-#define WCD9XXX_V2_BG_CLK_UNLOCK(resmgr)			\
-{							\
-	struct wcd9xxx_resmgr_v2 *__resmgr = resmgr;	\
-	pr_debug("%s: Releasing BG_CLK\n", __func__);	\
-	mutex_unlock(&__resmgr->codec_bg_clk_lock);	\
-}
-
-#define WCD9XXX_V2_BG_CLK_ASSERT_LOCKED(resmgr)		\
-{							\
-	WARN_ONCE(!mutex_is_locked(&resmgr->codec_bg_clk_lock), \
-		  "%s: BG_CLK lock should have acquired\n", __func__); \
-}
-
-int wcd_resmgr_enable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr);
-int wcd_resmgr_disable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr);
-struct wcd9xxx_resmgr_v2 *wcd_resmgr_init(
-		struct wcd9xxx_core_resource *core_res,
-		struct snd_soc_codec *codec);
-void wcd_resmgr_remove(struct wcd9xxx_resmgr_v2 *resmgr);
-int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr,
-			 const struct wcd_resmgr_cb *resmgr_cb,
-			 struct snd_soc_codec *codec);
-int wcd_resmgr_enable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
-				enum wcd_clock_type type);
-int wcd_resmgr_disable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
-				enum wcd_clock_type type);
-int wcd_resmgr_get_clk_type(struct wcd9xxx_resmgr_v2 *resmgr);
-void wcd_resmgr_post_ssr_v2(struct wcd9xxx_resmgr_v2 *resmgr);
-void wcd_resmgr_set_sido_input_src_locked(struct wcd9xxx_resmgr_v2 *resmgr,
-					  int sido_src);
-void wcd_resmgr_set_sido_input_src(struct wcd9xxx_resmgr_v2 *resmgr,
-					  int sido_src);
-
-#endif
diff --git a/sound/soc/codecs/wcd9xxx-soc-init.c b/sound/soc/codecs/wcd9xxx-soc-init.c
deleted file mode 100644
index fa8abb7..0000000
--- a/sound/soc/codecs/wcd9xxx-soc-init.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <sound/wcd-dsp-mgr.h>
-#include "audio-ext-clk-up.h"
-
-static int __init wcd9xxx_soc_init(void)
-{
-	int ret = 0;
-
-	ret = wcd_dsp_mgr_init();
-	if (!ret) {
-		ret = audio_ref_clk_platform_init();
-		if (ret) {
-			pr_err("%s: init extclk fail: %d\n", __func__, ret);
-			wcd_dsp_mgr_exit();
-		}
-	} else {
-		pr_err("%s: init dsp mgr fail: %d\n", __func__, ret);
-	}
-
-	return ret;
-}
-module_init(wcd9xxx_soc_init);
-
-static void __exit wcd9xxx_soc_exit(void)
-{
-	audio_ref_clk_platform_exit();
-	wcd_dsp_mgr_exit();
-}
-module_exit(wcd9xxx_soc_exit);
-
-MODULE_DESCRIPTION("WCD9XXX CODEC soc init driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd_cmi_api.h b/sound/soc/codecs/wcd_cmi_api.h
deleted file mode 100644
index 39be641..0000000
--- a/sound/soc/codecs/wcd_cmi_api.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CMI_API__
-#define __CMI_API__
-
-enum cmi_api_result {
-	CMI_API_FAILED = 1,
-	CMI_API_BUSY,
-	CMI_API_NO_MEMORY,
-	CMI_API_NOT_READY,
-};
-
-enum cmi_api_event {
-	CMI_API_MSG = 1,
-	CMI_API_OFFLINE,
-	CMI_API_ONLINE,
-	CMI_API_DEINITIALIZED,
-};
-
-struct cmi_api_notification {
-	enum cmi_api_event event;
-	enum cmi_api_result result;
-	void *message;
-};
-
-void *cmi_register(
-	void notification_callback
-		(const struct cmi_api_notification *parameter),
-	u32 service);
-enum cmi_api_result cmi_deregister(void *reg_handle);
-enum cmi_api_result cmi_send_msg(void *message);
-
-#endif /*__CMI_API__*/
diff --git a/sound/soc/codecs/wcd_cpe_core.c b/sound/soc/codecs/wcd_cpe_core.c
deleted file mode 100644
index f2a20d51..0000000
--- a/sound/soc/codecs/wcd_cpe_core.c
+++ /dev/null
@@ -1,4579 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/firmware.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/elf.h>
-#include <linux/wait.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/pm_qos.h>
-#include <linux/dma-mapping.h>
-#include <sound/soc.h>
-#include <sound/info.h>
-#include <sound/lsm_params.h>
-#include <sound/cpe_core.h>
-#include <sound/cpe_cmi.h>
-#include <sound/cpe_err.h>
-#include <soc/qcom/pm.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/mfd/wcd9xxx/wcd9xxx-irq.h>
-#include <sound/audio_cal_utils.h>
-#include "wcd_cpe_core.h"
-#include "wcd_cpe_services.h"
-#include "wcd_cmi_api.h"
-
-#define CMI_CMD_TIMEOUT (10 * HZ)
-#define WCD_CPE_LSM_MAX_SESSIONS 2
-#define WCD_CPE_AFE_MAX_PORTS 4
-#define AFE_SVC_EXPLICIT_PORT_START 1
-#define WCD_CPE_EC_PP_BUF_SIZE	480 /* 5 msec buffer */
-
-#define ELF_FLAG_EXECUTE (1 << 0)
-#define ELF_FLAG_WRITE (1 << 1)
-#define ELF_FLAG_READ (1 << 2)
-
-#define ELF_FLAG_RW (ELF_FLAG_READ | ELF_FLAG_WRITE)
-
-#define WCD_CPE_GRAB_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock acquire\n",	\
-		 __func__, name);		\
-	mutex_lock(lock);			\
-}
-
-#define WCD_CPE_REL_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock release\n",	\
-		 __func__, name);		\
-	mutex_unlock(lock);			\
-}
-
-#define WCD_CPE_STATE_MAX_LEN 11
-#define CPE_OFFLINE_WAIT_TIMEOUT (2 * HZ)
-#define CPE_READY_WAIT_TIMEOUT (3 * HZ)
-#define WCD_CPE_SYSFS_DIR_MAX_LENGTH 32
-
-#define CPE_ERR_IRQ_CB(core) \
-	(core->cpe_cdc_cb->cpe_err_irq_control)
-
-/*
- * AFE output buffer size is always
- * (sample_rate * number of bytes per sample/2*1000)
- */
-#define AFE_OUT_BUF_SIZE(bit_width, sample_rate) \
-	(((sample_rate) * (bit_width / BITS_PER_BYTE))/(2*1000))
-
-enum afe_port_state {
-	AFE_PORT_STATE_DEINIT = 0,
-	AFE_PORT_STATE_INIT,
-	AFE_PORT_STATE_CONFIG,
-	AFE_PORT_STATE_STARTED,
-	AFE_PORT_STATE_SUSPENDED,
-};
-
-struct wcd_cmi_afe_port_data {
-	u8 port_id;
-	struct mutex afe_lock;
-	struct completion afe_cmd_complete;
-	enum afe_port_state port_state;
-	u8 cmd_result;
-	u32 mem_handle;
-};
-
-struct cpe_lsm_ids {
-	u32 module_id;
-	u32 param_id;
-};
-
-static struct wcd_cpe_core *core_d;
-static struct cpe_lsm_session
-		*lsm_sessions[WCD_CPE_LSM_MAX_SESSIONS + 1];
-struct wcd_cpe_core * (*wcd_get_cpe_core)(struct snd_soc_codec *);
-static struct wcd_cmi_afe_port_data afe_ports[WCD_CPE_AFE_MAX_PORTS + 1];
-static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param);
-static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core);
-static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core);
-static ssize_t cpe_ftm_test_trigger(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos);
-static u32 ramdump_enable;
-static u32 cpe_ftm_test_status;
-static const struct file_operations cpe_ftm_test_trigger_fops = {
-	.open = simple_open,
-	.write = cpe_ftm_test_trigger,
-};
-
-static int wcd_cpe_afe_svc_cmd_mode(void *core_handle,
-				    u8 mode);
-struct wcd_cpe_attribute {
-	struct attribute attr;
-	ssize_t (*show)(struct wcd_cpe_core *core, char *buf);
-	ssize_t (*store)(struct wcd_cpe_core *core, const char *buf,
-			 ssize_t count);
-};
-
-#define WCD_CPE_ATTR(_name, _mode, _show, _store) \
-static struct wcd_cpe_attribute cpe_attr_##_name = { \
-	.attr = {.name = __stringify(_name), .mode = _mode}, \
-	.show = _show, \
-	.store = _store, \
-}
-
-#define to_wcd_cpe_attr(a) \
-	container_of((a), struct wcd_cpe_attribute, attr)
-
-#define kobj_to_cpe_core(kobj) \
-	container_of((kobj), struct wcd_cpe_core, cpe_kobj)
-
-/* wcd_cpe_lsm_session_active: check if any session is active
- * return true if any session is active.
- */
-static bool wcd_cpe_lsm_session_active(void)
-{
-	int index = 1;
-	bool lsm_active = false;
-
-	/* session starts from index 1 */
-	for (; index <= WCD_CPE_LSM_MAX_SESSIONS; index++) {
-		if (lsm_sessions[index] != NULL) {
-			lsm_active = true;
-			break;
-		} else {
-			lsm_active = false;
-		}
-	}
-	return lsm_active;
-}
-
-static int wcd_cpe_get_sfr_dump(struct wcd_cpe_core *core)
-{
-	struct cpe_svc_mem_segment dump_seg;
-	int rc;
-	u8 *sfr_dump;
-
-	sfr_dump = kzalloc(core->sfr_buf_size, GFP_KERNEL);
-	if (!sfr_dump)
-		goto done;
-
-	dump_seg.type = CPE_SVC_DATA_MEM;
-	dump_seg.cpe_addr = core->sfr_buf_addr;
-	dump_seg.size = core->sfr_buf_size;
-	dump_seg.data = sfr_dump;
-	dev_dbg(core->dev,
-		"%s: reading SFR from CPE, size = %zu\n",
-		__func__, core->sfr_buf_size);
-
-	rc = cpe_svc_ramdump(core->cpe_handle, &dump_seg);
-	if (rc < 0) {
-		dev_err(core->dev,
-			"%s: Failed to read cpe sfr_dump, err = %d\n",
-			__func__, rc);
-		goto free_sfr_dump;
-	}
-
-	dev_info(core->dev,
-		 "%s: cpe_sfr = %s\n", __func__, sfr_dump);
-
-free_sfr_dump:
-	kfree(sfr_dump);
-done:
-	/* Even if SFR dump failed, do not return error */
-	return 0;
-}
-
-static int wcd_cpe_collect_ramdump(struct wcd_cpe_core *core)
-{
-	struct cpe_svc_mem_segment dump_seg;
-	int rc;
-
-	if (!core->cpe_ramdump_dev || !core->cpe_dump_v_addr ||
-	    core->hw_info.dram_size == 0) {
-		dev_err(core->dev,
-			"%s: Ramdump devices not set up, size = %zu\n",
-			__func__, core->hw_info.dram_size);
-		return -EINVAL;
-	}
-
-	dump_seg.type = CPE_SVC_DATA_MEM;
-	dump_seg.cpe_addr = core->hw_info.dram_offset;
-	dump_seg.size = core->hw_info.dram_size;
-	dump_seg.data = core->cpe_dump_v_addr;
-
-	dev_dbg(core->dev,
-		"%s: Reading ramdump from CPE\n",
-		__func__);
-
-	rc = cpe_svc_ramdump(core->cpe_handle, &dump_seg);
-	if (rc < 0) {
-		dev_err(core->dev,
-			"%s: Failed to read CPE ramdump, err = %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	dev_dbg(core->dev,
-		"%s: completed reading ramdump from CPE\n",
-		__func__);
-
-	core->cpe_ramdump_seg.address = (unsigned long) core->cpe_dump_addr;
-	core->cpe_ramdump_seg.size = core->hw_info.dram_size;
-	core->cpe_ramdump_seg.v_address = core->cpe_dump_v_addr;
-
-	rc = do_ramdump(core->cpe_ramdump_dev,
-			&core->cpe_ramdump_seg, 1);
-	if (rc)
-		dev_err(core->dev,
-			"%s: fail to dump cpe ram to device, err = %d\n",
-			__func__, rc);
-	return rc;
-}
-
-/* wcd_cpe_is_valid_elf_hdr: check if the ELF header is valid
- * @core: handle to wcd_cpe_core
- * @fw_size: size of firmware from request_firmware
- * @ehdr: the elf header to be checked for
- * return true if all checks pass, true if any elf check fails
- */
-static bool wcd_cpe_is_valid_elf_hdr(struct wcd_cpe_core *core, size_t fw_size,
-				     const struct elf32_hdr *ehdr)
-{
-	if (fw_size < sizeof(*ehdr)) {
-		dev_err(core->dev, "%s:Firmware too small\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
-		dev_err(core->dev, "%s: Not an ELF file\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
-		dev_err(core->dev, "%s: Not a executable image\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (ehdr->e_phnum == 0) {
-		dev_err(core->dev, "%s: no segments to load\n", __func__);
-		goto elf_check_fail;
-	}
-
-	if (sizeof(struct elf32_phdr) * ehdr->e_phnum +
-	    sizeof(struct elf32_hdr) > fw_size) {
-		dev_err(core->dev, "%s: Too small MDT file\n", __func__);
-		goto elf_check_fail;
-	}
-
-	return true;
-
-elf_check_fail:
-	return false;
-}
-
-/*
- * wcd_cpe_load_each_segment: download segment to CPE
- * @core: handle to struct wcd_cpe_core
- * @file_idx: index of split firmware image file name
- * @phdr: program header from metadata
- */
-static int wcd_cpe_load_each_segment(struct wcd_cpe_core *core,
-			  int file_idx, const struct elf32_phdr *phdr)
-{
-	const struct firmware *split_fw;
-	char split_fname[32];
-	int ret = 0;
-	struct cpe_svc_mem_segment *segment;
-
-	if (!core || !phdr) {
-		pr_err("%s: Invalid params\n", __func__);
-		return -EINVAL;
-	}
-
-	/* file size can be 0 for bss segments */
-	if (phdr->p_filesz == 0 || phdr->p_memsz == 0)
-		return 0;
-
-	segment = kzalloc(sizeof(struct cpe_svc_mem_segment), GFP_KERNEL);
-	if (!segment)
-		return -ENOMEM;
-
-	snprintf(split_fname, sizeof(split_fname), "%s.b%02d",
-		 core->fname, file_idx);
-
-	ret = request_firmware(&split_fw, split_fname, core->dev);
-	if (ret) {
-		dev_err(core->dev, "firmware %s not found\n",
-			split_fname);
-		ret = -EIO;
-		goto fw_req_fail;
-	}
-
-	if (phdr->p_flags & ELF_FLAG_EXECUTE)
-		segment->type = CPE_SVC_INSTRUCTION_MEM;
-	else if (phdr->p_flags & ELF_FLAG_RW)
-		segment->type = CPE_SVC_DATA_MEM;
-	else {
-		dev_err(core->dev, "%s invalid flags 0x%x\n",
-			__func__, phdr->p_flags);
-		goto done;
-	}
-
-	segment->cpe_addr = phdr->p_paddr;
-	segment->size = phdr->p_filesz;
-	segment->data = (u8 *) split_fw->data;
-
-	dev_dbg(core->dev,
-		"%s: cpe segment type %s read from firmware\n", __func__,
-		(segment->type == CPE_SVC_INSTRUCTION_MEM) ?
-			"INSTRUCTION" : "DATA");
-
-	ret = cpe_svc_download_segment(core->cpe_handle, segment);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Failed to download %s, error = %d\n",
-			__func__, split_fname, ret);
-		goto done;
-	}
-
-done:
-	release_firmware(split_fw);
-
-fw_req_fail:
-	kfree(segment);
-	return ret;
-}
-
-/*
- * wcd_cpe_enable_cpe_clks: enable the clocks for CPE
- * @core: handle to wcd_cpe_core
- * @enable: flag indicating whether to enable/disable cpe clocks
- */
-static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable)
-{
-	int ret, ret1;
-
-	if (!core || !core->cpe_cdc_cb ||
-	    !core->cpe_cdc_cb->cpe_clk_en) {
-		pr_err("%s: invalid handle\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	ret = core->cpe_cdc_cb->cdc_clk_en(core->codec, enable);
-	if (ret) {
-		dev_err(core->dev, "%s: Failed to enable RCO\n",
-			__func__);
-		return ret;
-	}
-
-	if (!enable && core->cpe_clk_ref > 0)
-		core->cpe_clk_ref--;
-
-	/*
-	 * CPE clk will be enabled at the first time
-	 * and be disabled at the last time.
-	 */
-	if (core->cpe_clk_ref == 0) {
-		ret = core->cpe_cdc_cb->cpe_clk_en(core->codec, enable);
-		if (ret) {
-			dev_err(core->dev,
-				"%s: cpe_clk_en() failed, err = %d\n",
-				__func__, ret);
-			goto cpe_clk_fail;
-		}
-	}
-
-	if (enable)
-		core->cpe_clk_ref++;
-
-	return 0;
-
-cpe_clk_fail:
-	/* Release the codec clk if CPE clk enable failed */
-	if (enable) {
-		ret1 = core->cpe_cdc_cb->cdc_clk_en(core->codec, !enable);
-		if (ret1)
-			dev_err(core->dev,
-				"%s: Fail to release codec clk, err = %d\n",
-				__func__, ret1);
-	}
-
-	return ret;
-}
-
-/*
- * wcd_cpe_bus_vote_max_bw: Function to vote for max bandwidth on codec bus
- * @core: handle to core for cpe
- * @vote: flag to indicate enable/disable of vote
- *
- * This function will try to use the codec provided callback to
- * vote/unvote for the max bandwidth of the bus that is used by
- * the codec for register reads/writes.
- */
-static int wcd_cpe_bus_vote_max_bw(struct wcd_cpe_core *core,
-		bool vote)
-{
-	if (!core || !core->cpe_cdc_cb) {
-		pr_err("%s: Invalid handle to %s\n",
-			__func__,
-			(!core) ? "core" : "codec callbacks");
-		return -EINVAL;
-	}
-
-	if (core->cpe_cdc_cb->bus_vote_bw) {
-		dev_dbg(core->dev, "%s: %s cdc bus max bandwidth\n",
-			 __func__, vote ? "Vote" : "Unvote");
-		core->cpe_cdc_cb->bus_vote_bw(core->codec, vote);
-	}
-
-	return 0;
-}
-
-/*
- * wcd_cpe_load_fw: Function to load the fw image
- * @core: cpe core pointer
- * @load_type: indicates whether to load to data section
- *	       or the instruction section
- *
- * Parse the mdt file to look for program headers, load each
- * split file corresponding to the program headers.
- */
-static int wcd_cpe_load_fw(struct wcd_cpe_core *core,
-	unsigned int load_type)
-{
-
-	int ret, phdr_idx;
-	struct snd_soc_codec *codec = NULL;
-	struct wcd9xxx *wcd9xxx = NULL;
-	const struct elf32_hdr *ehdr;
-	const struct elf32_phdr *phdr;
-	const struct firmware *fw;
-	const u8 *elf_ptr;
-	char mdt_name[64];
-	bool img_dload_fail = false;
-	bool load_segment;
-
-	if (!core || !core->cpe_handle) {
-		pr_err("%s: Error CPE core %pK\n", __func__,
-		       core);
-		return -EINVAL;
-	}
-	codec = core->codec;
-	wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	snprintf(mdt_name, sizeof(mdt_name), "%s.mdt", core->fname);
-	ret = request_firmware(&fw, mdt_name, core->dev);
-	if (ret < 0) {
-		dev_err(core->dev, "firmware %s not found\n", mdt_name);
-		return ret;
-	}
-
-	ehdr = (struct elf32_hdr *) fw->data;
-	if (!wcd_cpe_is_valid_elf_hdr(core, fw->size, ehdr)) {
-		dev_err(core->dev, "%s: fw mdt %s is invalid\n",
-			__func__, mdt_name);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	elf_ptr = fw->data + sizeof(*ehdr);
-
-	if (load_type == ELF_FLAG_EXECUTE) {
-		/* Reset CPE first */
-		ret = cpe_svc_reset(core->cpe_handle);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: Failed to reset CPE with error %d\n",
-				__func__, ret);
-			goto done;
-		}
-	}
-
-	dev_dbg(core->dev, "%s: start image dload, name = %s, load_type = 0x%x\n",
-		__func__, core->fname, load_type);
-
-	wcd_cpe_bus_vote_max_bw(core, true);
-
-	/* parse every program header and request corresponding firmware */
-	for (phdr_idx = 0; phdr_idx < ehdr->e_phnum; phdr_idx++) {
-		phdr = (struct elf32_phdr *)elf_ptr;
-		load_segment = false;
-
-		dev_dbg(core->dev,
-			"index = %d, vaddr = 0x%x, paddr = 0x%x, filesz = 0x%x, memsz = 0x%x, flags = 0x%x\n"
-			, phdr_idx, phdr->p_vaddr, phdr->p_paddr,
-			phdr->p_filesz, phdr->p_memsz, phdr->p_flags);
-
-		switch (load_type) {
-		case ELF_FLAG_EXECUTE:
-			if (phdr->p_flags & load_type)
-				load_segment = true;
-			break;
-		case ELF_FLAG_RW:
-			if (!(phdr->p_flags & ELF_FLAG_EXECUTE) &&
-			    (phdr->p_flags & load_type))
-				load_segment = true;
-			break;
-		default:
-			pr_err("%s: Invalid load_type 0x%x\n",
-				__func__, load_type);
-			ret = -EINVAL;
-			goto rel_bus_vote;
-		}
-
-		if (load_segment) {
-			ret = wcd_cpe_load_each_segment(core,
-						phdr_idx, phdr);
-			if (ret < 0) {
-				dev_err(core->dev,
-					"Failed to load segment %d, aborting img dload\n",
-					phdr_idx);
-				img_dload_fail = true;
-				goto rel_bus_vote;
-			}
-		} else {
-			dev_dbg(core->dev,
-				"%s: skipped segment with index %d\n",
-				__func__, phdr_idx);
-		}
-
-		elf_ptr = elf_ptr + sizeof(*phdr);
-	}
-	if (load_type == ELF_FLAG_EXECUTE)
-		core->ssr_type = WCD_CPE_IMEM_DOWNLOADED;
-
-rel_bus_vote:
-	wcd_cpe_bus_vote_max_bw(core, false);
-
-done:
-	release_firmware(fw);
-	return ret;
-}
-
-/*
- * wcd_cpe_change_online_state - mark cpe online/offline state
- * @core: core session to mark
- * @online: whether online of offline
- *
- */
-static void wcd_cpe_change_online_state(struct wcd_cpe_core *core,
-			int online)
-{
-	struct wcd_cpe_ssr_entry *ssr_entry = NULL;
-	unsigned long ret;
-
-	if (!core) {
-		pr_err("%s: Invalid core handle\n",
-			__func__);
-		return;
-	}
-
-	ssr_entry = &core->ssr_entry;
-	WCD_CPE_GRAB_LOCK(&core->ssr_lock, "SSR");
-	ssr_entry->offline = !online;
-
-	/* Make sure write to offline state is completed. */
-	wmb();
-	ret = xchg(&ssr_entry->offline_change, 1);
-	wake_up_interruptible(&ssr_entry->offline_poll_wait);
-	WCD_CPE_REL_LOCK(&core->ssr_lock, "SSR");
-	pr_debug("%s: change state 0x%x offline_change 0x%x\n"
-		 " core->offline 0x%x, ret = %ld\n",
-		 __func__, online,
-		 ssr_entry->offline_change,
-		 core->ssr_entry.offline, ret);
-}
-
-/*
- * wcd_cpe_load_fw_image: work function to load the fw image
- * @work: work that is scheduled to perform the image loading
- *
- * Parse the mdt file to look for program headers, load each
- * split file corresponding to the program headers.
- */
-static void wcd_cpe_load_fw_image(struct work_struct *work)
-{
-	struct wcd_cpe_core *core;
-	int ret = 0;
-
-	core = container_of(work, struct wcd_cpe_core, load_fw_work);
-	ret = wcd_cpe_load_fw(core, ELF_FLAG_EXECUTE);
-	if (!ret)
-		wcd_cpe_change_online_state(core, 1);
-	else
-		pr_err("%s: failed to load instruction section, err = %d\n",
-			__func__, ret);
-}
-
-/*
- * wcd_cpe_get_core_handle: get the handle to wcd_cpe_core
- * @codec: codec from which this handle is to be obtained
- * Codec driver should provide a callback function to obtain
- * handle to wcd_cpe_core during initialization of wcd_cpe_core
- */
-void *wcd_cpe_get_core_handle(
-	struct snd_soc_codec *codec)
-{
-	struct wcd_cpe_core *core = NULL;
-
-	if (!codec) {
-		pr_err("%s: Invalid codec handle\n",
-			__func__);
-		goto done;
-	}
-
-	if (!wcd_get_cpe_core) {
-		dev_err(codec->dev,
-			"%s: codec callback not available\n",
-			__func__);
-		goto done;
-	}
-
-	core = wcd_get_cpe_core(codec);
-
-	if (!core)
-		dev_err(codec->dev,
-			"%s: handle to core not available\n",
-			__func__);
-done:
-	return core;
-}
-EXPORT_SYMBOL(wcd_cpe_get_core_handle);
-
-/*
- * svass_engine_irq: threaded interrupt handler for svass engine irq
- * @irq: interrupt number
- * @data: data pointer passed during irq registration
- */
-static irqreturn_t svass_engine_irq(int irq, void *data)
-{
-	struct wcd_cpe_core *core = data;
-	int ret = 0;
-
-	if (!core) {
-		pr_err("%s: Invalid data for interrupt handler\n",
-			__func__);
-		goto done;
-	}
-
-	ret = cpe_svc_process_irq(core->cpe_handle, CPE_IRQ_OUTBOX_IRQ);
-	if (ret < 0)
-		dev_err(core->dev,
-			"%s: Error processing irq from cpe_Services\n",
-			__func__);
-done:
-	return IRQ_HANDLED;
-}
-
-/*
- * wcd_cpe_state_read - update read status in procfs
- * @entry: snd_info_entry
- * @buf: buffer where the read status is updated.
- *
- */
-static ssize_t wcd_cpe_state_read(struct snd_info_entry *entry,
-			       void *file_private_data, struct file *file,
-			       char __user *buf, size_t count, loff_t pos)
-{
-	int len = 0;
-	char buffer[WCD_CPE_STATE_MAX_LEN];
-	struct wcd_cpe_core *core = NULL;
-	struct wcd_cpe_ssr_entry *ssr_entry = NULL;
-
-	core = (struct wcd_cpe_core *) entry->private_data;
-	if (!core) {
-		pr_err("%s: CPE core NULL\n", __func__);
-		return -EINVAL;
-	}
-	ssr_entry = &core->ssr_entry;
-
-	/* Make sure read from ssr_entry is completed. */
-	rmb();
-	dev_dbg(core->dev,
-		"%s: Offline 0x%x\n", __func__,
-		 ssr_entry->offline);
-
-	WCD_CPE_GRAB_LOCK(&core->ssr_lock, "SSR");
-	len = snprintf(buffer, sizeof(buffer), "%s\n",
-		       ssr_entry->offline ? "OFFLINE" : "ONLINE");
-	WCD_CPE_REL_LOCK(&core->ssr_lock, "SSR");
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-/*
- * wcd_cpe_state_poll - polls for change state
- * @entry: snd_info_entry
- * @wait: wait for duration for poll wait
- *
- */
-static unsigned int wcd_cpe_state_poll(struct snd_info_entry *entry,
-					void *private_data, struct file *file,
-					poll_table *wait)
-{
-	struct wcd_cpe_core *core = NULL;
-	struct wcd_cpe_ssr_entry *ssr_entry = NULL;
-	int ret = 0;
-
-	core = (struct wcd_cpe_core *) entry->private_data;
-	if (!core) {
-		pr_err("%s: CPE core NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	ssr_entry = &core->ssr_entry;
-
-	dev_dbg(core->dev, "%s: CPE Poll wait\n",
-	       __func__);
-	poll_wait(file, &ssr_entry->offline_poll_wait, wait);
-	dev_dbg(core->dev, "%s: Wake-up Poll wait\n",
-	       __func__);
-	WCD_CPE_GRAB_LOCK(&core->ssr_lock, "SSR");
-
-	if (xchg(&ssr_entry->offline_change, 0))
-		ret = POLLIN | POLLPRI | POLLRDNORM;
-
-	WCD_CPE_REL_LOCK(&core->ssr_lock, "SSR");
-
-	dev_dbg(core->dev, "%s: ret (%d) from poll_wait\n",
-		__func__, ret);
-	return ret;
-}
-
-/*
- * wcd_cpe_is_online_state - return true if card is online state
- * @core: core offline to query
- */
-static bool wcd_cpe_is_online_state(void *core_handle)
-{
-	struct wcd_cpe_core *core = core_handle;
-
-	if (core_handle) {
-		return !core->ssr_entry.offline;
-	} else {
-		pr_err("%s: Core handle NULL\n", __func__);
-		/* still return 1- offline if core ptr null */
-		return false;
-	}
-}
-
-static struct snd_info_entry_ops wcd_cpe_state_proc_ops = {
-	.read = wcd_cpe_state_read,
-	.poll = wcd_cpe_state_poll,
-};
-
-static int wcd_cpe_check_new_image(struct wcd_cpe_core *core)
-{
-	int rc = 0;
-	char temp_img_name[WCD_CPE_IMAGE_FNAME_MAX];
-
-	if (!strcmp(core->fname, core->dyn_fname) &&
-	    core->ssr_type != WCD_CPE_INITIALIZED) {
-		dev_dbg(core->dev,
-			"%s: Firmware unchanged, fname = %s, ssr_type 0x%x\n",
-			__func__, core->fname, core->ssr_type);
-		goto done;
-	}
-
-	/*
-	 * Different firmware name requested,
-	 * Re-load the instruction section
-	 */
-	strlcpy(temp_img_name, core->fname,
-		WCD_CPE_IMAGE_FNAME_MAX);
-	strlcpy(core->fname, core->dyn_fname,
-		WCD_CPE_IMAGE_FNAME_MAX);
-
-	rc = wcd_cpe_load_fw(core, ELF_FLAG_EXECUTE);
-	if (rc) {
-		dev_err(core->dev,
-			"%s: Failed to dload new image %s, err = %d\n",
-			__func__, core->fname, rc);
-		/* If new image download failed, revert back to old image */
-		strlcpy(core->fname, temp_img_name,
-			WCD_CPE_IMAGE_FNAME_MAX);
-		rc = wcd_cpe_load_fw(core, ELF_FLAG_EXECUTE);
-		if (rc)
-			dev_err(core->dev,
-				"%s: Failed to re-dload image %s, err = %d\n",
-				__func__, core->fname, rc);
-	} else {
-		dev_info(core->dev, "%s: fw changed to %s\n",
-			 __func__, core->fname);
-	}
-done:
-	return rc;
-}
-
-static int wcd_cpe_enable(struct wcd_cpe_core *core,
-		bool enable)
-{
-	int ret = 0;
-
-	if (enable) {
-		/* Reset CPE first */
-		ret = cpe_svc_reset(core->cpe_handle);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: CPE Reset failed, error = %d\n",
-				__func__, ret);
-			goto done;
-		}
-
-		ret = wcd_cpe_setup_irqs(core);
-		if (ret) {
-			dev_err(core->dev,
-				"%s: CPE IRQs setup failed, error = %d\n",
-				__func__, ret);
-			goto done;
-		}
-		ret = wcd_cpe_check_new_image(core);
-		if (ret)
-			goto fail_boot;
-
-		/* Dload data section */
-		ret = wcd_cpe_load_fw(core, ELF_FLAG_RW);
-		if (ret) {
-			dev_err(core->dev,
-				"%s: Failed to dload data section, err = %d\n",
-				__func__, ret);
-			goto fail_boot;
-		}
-
-		ret = wcd_cpe_enable_cpe_clks(core, true);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: CPE clk enable failed, err = %d\n",
-				__func__, ret);
-			goto fail_boot;
-		}
-
-		ret = cpe_svc_boot(core->cpe_handle,
-				   core->cpe_debug_mode);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: Failed to boot CPE\n",
-				__func__);
-			goto fail_boot;
-		}
-
-		/* wait for CPE to be online */
-		dev_dbg(core->dev,
-			"%s: waiting for CPE bootup\n",
-			__func__);
-
-		wait_for_completion(&core->online_compl);
-
-		dev_dbg(core->dev,
-			"%s: CPE bootup done\n",
-			__func__);
-
-		core->ssr_type = WCD_CPE_ENABLED;
-	} else {
-		if (core->ssr_type == WCD_CPE_BUS_DOWN_EVENT ||
-		    core->ssr_type == WCD_CPE_SSR_EVENT) {
-			/*
-			 * If this disable vote is when
-			 * SSR is in progress, do not disable CPE here,
-			 * instead SSR handler will control CPE.
-			 */
-			wcd_cpe_enable_cpe_clks(core, false);
-			wcd_cpe_cleanup_irqs(core);
-			goto done;
-		}
-
-		ret = cpe_svc_shutdown(core->cpe_handle);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: CPE shutdown failed, error %d\n",
-				__func__, ret);
-			goto done;
-		}
-
-		wcd_cpe_enable_cpe_clks(core, false);
-		wcd_cpe_cleanup_irqs(core);
-		core->ssr_type = WCD_CPE_IMEM_DOWNLOADED;
-	}
-
-	return ret;
-
-fail_boot:
-	wcd_cpe_cleanup_irqs(core);
-
-done:
-	return ret;
-}
-
-/*
- * wcd_cpe_boot_ssr: Load the images to CPE after ssr and bootup cpe
- * @core: handle to the core
- */
-static int wcd_cpe_boot_ssr(struct wcd_cpe_core *core)
-{
-	int rc = 0;
-
-	if (!core || !core->cpe_handle) {
-		pr_err("%s: Invalid handle\n", __func__);
-		rc = -EINVAL;
-		goto fail;
-	}
-	/* Load the instruction section and mark CPE as online */
-	rc = wcd_cpe_load_fw(core, ELF_FLAG_EXECUTE);
-	if (rc) {
-		dev_err(core->dev,
-			"%s: Failed to load instruction, err = %d\n",
-			__func__, rc);
-		goto fail;
-	} else {
-		wcd_cpe_change_online_state(core, 1);
-	}
-
-fail:
-	return rc;
-}
-
-/*
- * wcd_cpe_clr_ready_status:
- *	Clear the value from the ready status for CPE
- * @core: handle to the core
- * @value: flag/bitmask that is to be cleared
- *
- * This function should not be invoked with ssr_lock acquired
- */
-static void wcd_cpe_clr_ready_status(struct wcd_cpe_core *core,
-			       u8 value)
-{
-	WCD_CPE_GRAB_LOCK(&core->ssr_lock, "SSR");
-	core->ready_status &= ~(value);
-	dev_dbg(core->dev,
-		"%s: ready_status = 0x%x\n",
-		__func__, core->ready_status);
-	WCD_CPE_REL_LOCK(&core->ssr_lock, "SSR");
-}
-
-/*
- * wcd_cpe_set_and_complete:
- *	Set the ready status with the provided value and
- *	flag the completion object if ready status moves
- *	to ready to download
- * @core: handle to the core
- * @value: flag/bitmask that is to be set
- */
-static void wcd_cpe_set_and_complete(struct wcd_cpe_core *core,
-				u8 value)
-{
-	WCD_CPE_GRAB_LOCK(&core->ssr_lock, "SSR");
-	core->ready_status |= value;
-	if ((core->ready_status & WCD_CPE_READY_TO_DLOAD) ==
-	    WCD_CPE_READY_TO_DLOAD) {
-		dev_dbg(core->dev,
-			"%s: marking ready, status = 0x%x\n",
-			__func__, core->ready_status);
-		complete(&core->ready_compl);
-	}
-	WCD_CPE_REL_LOCK(&core->ssr_lock, "SSR");
-}
-
-
-/*
- * wcd_cpe_ssr_work: work function to handle CPE SSR
- * @work: work that is scheduled to perform CPE shutdown
- *	and restart
- */
-static void wcd_cpe_ssr_work(struct work_struct *work)
-{
-
-	int rc = 0;
-	u32 irq = 0;
-	struct wcd_cpe_core *core = NULL;
-	u8 status = 0;
-
-	core = container_of(work, struct wcd_cpe_core, ssr_work);
-	if (!core) {
-		pr_err("%s: Core handle NULL\n", __func__);
-		return;
-	}
-
-	/* Obtain pm request up in case of suspend mode */
-	pm_qos_add_request(&core->pm_qos_req,
-			   PM_QOS_CPU_DMA_LATENCY,
-			   PM_QOS_DEFAULT_VALUE);
-	pm_qos_update_request(&core->pm_qos_req,
-			msm_cpuidle_get_deep_idle_latency());
-
-	dev_dbg(core->dev,
-		"%s: CPE SSR with event %d\n",
-		__func__, core->ssr_type);
-
-	if (core->ssr_type == WCD_CPE_SSR_EVENT) {
-		if (CPE_ERR_IRQ_CB(core))
-			core->cpe_cdc_cb->cpe_err_irq_control(
-					core->codec,
-					CPE_ERR_IRQ_STATUS,
-					&status);
-		if (status & core->irq_info.cpe_fatal_irqs)
-			irq = CPE_IRQ_WDOG_BITE;
-	} else {
-		/* If bus is down, cdc reg cannot be read */
-		irq = CPE_IRQ_WDOG_BITE;
-	}
-
-	if (core->cpe_users > 0) {
-		rc = cpe_svc_process_irq(core->cpe_handle, irq);
-		if (rc < 0)
-			/*
-			 * Even if process_irq fails,
-			 * wait for cpe to move to offline state
-			 */
-			dev_err(core->dev,
-				"%s: irq processing failed, error = %d\n",
-				__func__, rc);
-
-		rc = wait_for_completion_timeout(&core->offline_compl,
-						 CPE_OFFLINE_WAIT_TIMEOUT);
-		if (!rc) {
-			dev_err(core->dev,
-				"%s: wait for cpe offline timed out\n",
-				__func__);
-			goto err_ret;
-		}
-		if (core->ssr_type != WCD_CPE_BUS_DOWN_EVENT) {
-			wcd_cpe_get_sfr_dump(core);
-
-			/*
-			 * Ramdump has to be explicitly enabled
-			 * through debugfs and cannot be collected
-			 * when bus is down.
-			 */
-			if (ramdump_enable)
-				wcd_cpe_collect_ramdump(core);
-		}
-	} else {
-		pr_err("%s: no cpe users, mark as offline\n", __func__);
-		wcd_cpe_change_online_state(core, 0);
-		wcd_cpe_set_and_complete(core,
-					 WCD_CPE_BLK_READY);
-	}
-
-	rc = wait_for_completion_timeout(&core->ready_compl,
-					 CPE_READY_WAIT_TIMEOUT);
-	if (!rc) {
-		dev_err(core->dev,
-			"%s: ready to online timed out, status = %u\n",
-			__func__, core->ready_status);
-		goto err_ret;
-	}
-
-	rc = wcd_cpe_boot_ssr(core);
-
-	/* Once image are downloaded make sure all
-	 * error interrupts are cleared
-	 */
-	if (CPE_ERR_IRQ_CB(core))
-		core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
-					CPE_ERR_IRQ_CLEAR, NULL);
-
-err_ret:
-	/* remove after default pm qos */
-	pm_qos_update_request(&core->pm_qos_req,
-			      PM_QOS_DEFAULT_VALUE);
-	pm_qos_remove_request(&core->pm_qos_req);
-}
-
-/*
- * wcd_cpe_ssr_handle: handle SSR events here.
- * @core_handle: handle to the cpe core
- * @event: indicates ADSP or CDSP SSR.
- */
-int wcd_cpe_ssr_event(void *core_handle,
-		      enum wcd_cpe_ssr_state_event event)
-{
-	struct wcd_cpe_core *core = core_handle;
-
-	if (!core) {
-		pr_err("%s: Invalid handle to core\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	/*
-	 * If CPE is not even enabled, the SSR event for
-	 * CPE needs to be ignored
-	 */
-	if (core->ssr_type == WCD_CPE_INITIALIZED) {
-		dev_info(core->dev,
-			"%s: CPE initialized but not enabled, skip CPE ssr\n",
-			 __func__);
-		return 0;
-	}
-
-	dev_dbg(core->dev,
-		"%s: Schedule ssr work, event = %d\n",
-		__func__, core->ssr_type);
-
-	switch (event) {
-	case WCD_CPE_BUS_DOWN_EVENT:
-		/*
-		 * If bus down, then CPE block is also
-		 * treated to be down
-		 */
-		wcd_cpe_clr_ready_status(core, WCD_CPE_READY_TO_DLOAD);
-		core->ssr_type = event;
-		schedule_work(&core->ssr_work);
-		break;
-
-	case WCD_CPE_SSR_EVENT:
-		wcd_cpe_clr_ready_status(core, WCD_CPE_BLK_READY);
-		core->ssr_type = event;
-		schedule_work(&core->ssr_work);
-		break;
-
-	case WCD_CPE_BUS_UP_EVENT:
-		wcd_cpe_set_and_complete(core, WCD_CPE_BUS_READY);
-		/*
-		 * In case of bus up event ssr_type will be changed
-		 * to WCD_CPE_ACTIVE once CPE is online
-		 */
-		break;
-
-	default:
-		dev_err(core->dev,
-			"%s: unhandled SSR event %d\n",
-			__func__, event);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd_cpe_ssr_event);
-
-/*
- * svass_exception_irq: threaded irq handler for sva error interrupts
- * @irq: interrupt number
- * @data: data pointer passed during irq registration
- *
- * Once a error interrupt is received, it is not cleared, since
- * clearing this interrupt will raise spurious interrupts unless
- * CPE is reset.
- */
-static irqreturn_t svass_exception_irq(int irq, void *data)
-{
-	struct wcd_cpe_core *core = data;
-	u8 status = 0;
-
-	if (!core || !CPE_ERR_IRQ_CB(core)) {
-		pr_err("%s: Invalid %s\n",
-		       __func__,
-		       (!core) ? "core" : "cdc control");
-		return IRQ_HANDLED;
-	}
-
-	core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
-			CPE_ERR_IRQ_STATUS, &status);
-
-	while (status != 0) {
-		if (status & core->irq_info.cpe_fatal_irqs) {
-			dev_err(core->dev,
-				"%s: CPE SSR event,err_status = 0x%02x\n",
-				__func__, status);
-			wcd_cpe_ssr_event(core, WCD_CPE_SSR_EVENT);
-			/*
-			 * If fatal interrupt is received,
-			 * trigger SSR and stop processing
-			 * further interrupts
-			 */
-			break;
-		}
-		/*
-		 * Mask the interrupt that was raised to
-		 * avoid spurious interrupts
-		 */
-		core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
-					CPE_ERR_IRQ_MASK, &status);
-
-		/* Clear only the interrupt that was raised */
-		core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
-					CPE_ERR_IRQ_CLEAR, &status);
-		dev_err(core->dev,
-			"%s: err_interrupt status = 0x%x\n",
-			__func__, status);
-
-		/* Read status for pending interrupts */
-		core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
-					CPE_ERR_IRQ_STATUS, &status);
-	}
-
-	return IRQ_HANDLED;
-}
-
-/*
- * wcd_cpe_cmi_afe_cb: callback called on response to afe commands
- * @param: parameter containing the response code, etc
- *
- * Process the request to the command sent to CPE and wakeup the
- * command send wait.
- */
-static void wcd_cpe_cmi_afe_cb(const struct cmi_api_notification *param)
-{
-	struct cmi_hdr *hdr;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	u8 port_id;
-
-	if (!param) {
-		pr_err("%s: param is null\n", __func__);
-		return;
-	}
-
-	if (param->event != CMI_API_MSG) {
-		pr_err("%s: unhandled event 0x%x\n",
-			__func__, param->event);
-		return;
-	}
-
-	pr_debug("%s: param->result = %d\n",
-		 __func__, param->result);
-
-	hdr = (struct cmi_hdr *) param->message;
-
-	/*
-	 * for AFE cmd response, port id is
-	 * stored at session id field of header
-	 */
-	port_id = CMI_HDR_GET_SESSION_ID(hdr);
-	if (port_id > WCD_CPE_AFE_MAX_PORTS) {
-		pr_err("%s: invalid port_id %d\n",
-			__func__, port_id);
-		return;
-	}
-
-	afe_port_d = &(afe_ports[port_id]);
-
-	if (hdr->opcode == CPE_CMI_BASIC_RSP_OPCODE) {
-
-		u8 *payload = ((u8 *)param->message) + (sizeof(struct cmi_hdr));
-		u8 result = payload[0];
-
-		afe_port_d->cmd_result = result;
-		complete(&afe_port_d->afe_cmd_complete);
-
-	} else if (hdr->opcode == CPE_AFE_PORT_CMDRSP_SHARED_MEM_ALLOC) {
-
-		struct cpe_cmdrsp_shmem_alloc *cmdrsp_shmem_alloc =
-			(struct cpe_cmdrsp_shmem_alloc *) param->message;
-
-		if (cmdrsp_shmem_alloc->addr == 0) {
-			pr_err("%s: Failed AFE shared mem alloc\n", __func__);
-			afe_port_d->cmd_result = CMI_SHMEM_ALLOC_FAILED;
-		} else {
-			pr_debug("%s AFE shared mem addr = 0x%x\n",
-				 __func__, cmdrsp_shmem_alloc->addr);
-			afe_port_d->mem_handle = cmdrsp_shmem_alloc->addr;
-			afe_port_d->cmd_result = 0;
-		}
-		complete(&afe_port_d->afe_cmd_complete);
-	}
-}
-
-/*
- * wcd_cpe_initialize_afe_port_data: Initialize all AFE ports
- *
- * Initialize the data for all the afe ports. Assign the
- * afe port state to INIT state.
- */
-static void wcd_cpe_initialize_afe_port_data(void)
-{
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int i;
-
-	for (i = 0; i <= WCD_CPE_AFE_MAX_PORTS; i++) {
-		afe_port_d = &afe_ports[i];
-		afe_port_d->port_id = i;
-		init_completion(&afe_port_d->afe_cmd_complete);
-		afe_port_d->port_state = AFE_PORT_STATE_INIT;
-		mutex_init(&afe_port_d->afe_lock);
-	}
-}
-
-/*
- * wcd_cpe_deinitialize_afe_port_data: De-initialize all AFE ports
- *
- * De-Initialize the data for all the afe ports. Assign the
- * afe port state to DEINIT state.
- */
-static void wcd_cpe_deinitialize_afe_port_data(void)
-{
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int i;
-
-	for (i = 0; i <= WCD_CPE_AFE_MAX_PORTS; i++) {
-		afe_port_d = &afe_ports[i];
-		afe_port_d->port_state = AFE_PORT_STATE_DEINIT;
-		mutex_destroy(&afe_port_d->afe_lock);
-	}
-}
-
-/*
- * wcd_cpe_svc_event_cb: callback from cpe services, indicating
- * CPE is online or offline.
- * @param: parameter / payload for event to be notified
- */
-static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param)
-{
-	struct snd_soc_codec *codec;
-	struct wcd_cpe_core *core;
-	struct cpe_svc_boot_event *boot_data;
-	bool active_sessions;
-
-	if (!param) {
-		pr_err("%s: Invalid event\n", __func__);
-		return;
-	}
-
-	codec = param->private_data;
-	if (!codec) {
-		pr_err("%s: Invalid handle to codec\n",
-			__func__);
-		return;
-	}
-
-	core = wcd_cpe_get_core_handle(codec);
-	if (!core) {
-		pr_err("%s: Invalid handle to core\n",
-			__func__);
-		return;
-	}
-
-	dev_dbg(core->dev,
-		"%s: event = 0x%x, ssr_type = 0x%x\n",
-		__func__, param->event, core->ssr_type);
-
-	switch (param->event) {
-	case CPE_SVC_BOOT:
-		boot_data = (struct cpe_svc_boot_event *)
-				param->payload;
-		core->sfr_buf_addr = boot_data->debug_address;
-		core->sfr_buf_size = boot_data->debug_buffer_size;
-		dev_dbg(core->dev,
-			"%s: CPE booted, sfr_addr = %d, sfr_size = %zu\n",
-			__func__, core->sfr_buf_addr,
-			core->sfr_buf_size);
-		break;
-	case CPE_SVC_ONLINE:
-		core->ssr_type = WCD_CPE_ACTIVE;
-		dev_dbg(core->dev, "%s CPE is now online\n",
-			 __func__);
-		complete(&core->online_compl);
-		break;
-	case CPE_SVC_OFFLINE:
-		/*
-		 * offline can happen during normal shutdown,
-		 * but we are interested in offline only during
-		 * SSR.
-		 */
-		if (core->ssr_type != WCD_CPE_SSR_EVENT &&
-		    core->ssr_type != WCD_CPE_BUS_DOWN_EVENT)
-			break;
-
-		active_sessions = wcd_cpe_lsm_session_active();
-		wcd_cpe_change_online_state(core, 0);
-		complete(&core->offline_compl);
-		dev_err(core->dev, "%s: CPE is now offline\n",
-			 __func__);
-		break;
-	case CPE_SVC_CMI_CLIENTS_DEREG:
-
-		/*
-		 * Only when either CPE SSR is in progress,
-		 * or the bus is down, we need to mark the CPE
-		 * as ready. In all other cases, this event is
-		 * ignored
-		 */
-		if (core->ssr_type == WCD_CPE_SSR_EVENT ||
-		    core->ssr_type == WCD_CPE_BUS_DOWN_EVENT)
-			wcd_cpe_set_and_complete(core,
-						 WCD_CPE_BLK_READY);
-		break;
-	default:
-		dev_err(core->dev,
-			"%s: unhandled notification\n",
-			__func__);
-		break;
-	}
-}
-
-/*
- * wcd_cpe_cleanup_irqs: free the irq resources required by cpe
- * @core: handle the cpe core
- *
- * This API will free the IRQs for CPE but does not mask the
- * CPE interrupts. If masking is needed, it has to be done
- * explicity by caller.
- */
-static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core)
-{
-
-	struct snd_soc_codec *codec = core->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
-
-	wcd9xxx_free_irq(core_res,
-			 core->irq_info.cpe_engine_irq,
-			 core);
-	wcd9xxx_free_irq(core_res,
-			 core->irq_info.cpe_err_irq,
-			 core);
-
-}
-
-/*
- * wcd_cpe_setup_sva_err_intr: setup the irqs for CPE
- * @core: handle to wcd_cpe_core
- * All interrupts needed for CPE are acquired. If any
- * request_irq fails, then all irqs are free'd
- */
-static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core)
-{
-	int ret;
-	struct snd_soc_codec *codec = core->codec;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
-
-	ret = wcd9xxx_request_irq(core_res,
-				  core->irq_info.cpe_engine_irq,
-				  svass_engine_irq, "SVASS_Engine", core);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Failed to request svass engine irq\n",
-			__func__);
-		goto fail_engine_irq;
-	}
-
-	/* Make sure all error interrupts are cleared */
-	if (CPE_ERR_IRQ_CB(core))
-		core->cpe_cdc_cb->cpe_err_irq_control(
-					core->codec,
-					CPE_ERR_IRQ_CLEAR,
-					NULL);
-
-	/* Enable required error interrupts */
-	if (CPE_ERR_IRQ_CB(core))
-		core->cpe_cdc_cb->cpe_err_irq_control(
-					core->codec,
-					CPE_ERR_IRQ_UNMASK,
-					NULL);
-
-	ret = wcd9xxx_request_irq(core_res,
-				  core->irq_info.cpe_err_irq,
-				  svass_exception_irq, "SVASS_Exception", core);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Failed to request svass err irq\n",
-			__func__);
-		goto fail_exception_irq;
-	}
-
-	return 0;
-
-fail_exception_irq:
-	wcd9xxx_free_irq(core_res,
-			 core->irq_info.cpe_engine_irq, core);
-
-fail_engine_irq:
-	return ret;
-}
-
-static int wcd_cpe_get_cal_index(int32_t cal_type)
-{
-	int cal_index = -EINVAL;
-
-	if (cal_type == ULP_AFE_CAL_TYPE)
-		cal_index = WCD_CPE_LSM_CAL_AFE;
-	else if (cal_type == ULP_LSM_CAL_TYPE)
-		cal_index = WCD_CPE_LSM_CAL_LSM;
-	else if (cal_type == ULP_LSM_TOPOLOGY_ID_CAL_TYPE)
-		cal_index = WCD_CPE_LSM_CAL_TOPOLOGY_ID;
-	else
-		pr_err("%s: invalid cal_type %d\n",
-			__func__, cal_type);
-
-	return cal_index;
-}
-
-static int wcd_cpe_alloc_cal(int32_t cal_type, size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = wcd_cpe_get_cal_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: invalid caltype %d\n",
-			__func__, cal_type);
-		return -EINVAL;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-				  core_d->cal_data[cal_index],
-				  0, NULL);
-	if (ret < 0)
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-	return ret;
-}
-
-static int wcd_cpe_dealloc_cal(int32_t cal_type, size_t data_size,
-			   void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = wcd_cpe_get_cal_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: invalid caltype %d\n",
-			__func__, cal_type);
-		return -EINVAL;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-				    core_d->cal_data[cal_index]);
-	if (ret < 0)
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-	return ret;
-}
-
-static int wcd_cpe_set_cal(int32_t cal_type, size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = wcd_cpe_get_cal_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: invalid caltype %d\n",
-			__func__, cal_type);
-		return -EINVAL;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-				core_d->cal_data[cal_index],
-				0, NULL);
-	if (ret < 0)
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-	return ret;
-}
-
-static int wcd_cpe_cal_init(struct wcd_cpe_core *core)
-{
-	int ret = 0;
-
-	struct cal_type_info cal_type_info[] = {
-		{{ULP_AFE_CAL_TYPE,
-		 {wcd_cpe_alloc_cal, wcd_cpe_dealloc_cal, NULL,
-		  wcd_cpe_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{ULP_LSM_CAL_TYPE,
-		 {wcd_cpe_alloc_cal, wcd_cpe_dealloc_cal, NULL,
-		  wcd_cpe_set_cal, NULL, NULL} },
-		 {NULL, NULL, cal_utils_match_buf_num} },
-
-		{{ULP_LSM_TOPOLOGY_ID_CAL_TYPE,
-		 {wcd_cpe_alloc_cal, wcd_cpe_dealloc_cal, NULL,
-		  wcd_cpe_set_cal, NULL, NULL} },
-		 {NULL, NULL, cal_utils_match_buf_num} },
-	};
-
-	ret = cal_utils_create_cal_types(WCD_CPE_LSM_CAL_MAX,
-					 core->cal_data,
-					 cal_type_info);
-	if (ret < 0)
-		pr_err("%s: could not create cal type!\n",
-		       __func__);
-	return ret;
-}
-
-/*
- * wcd_cpe_enable: setup the cpe interrupts and schedule
- *	the work to download image and bootup the CPE.
- * core: handle to cpe core structure
- */
-static int wcd_cpe_vote(struct wcd_cpe_core *core,
-		bool enable)
-{
-	int ret = 0;
-
-	if (!core) {
-		pr_err("%s: Invalid handle to core\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	dev_dbg(core->dev,
-		"%s: enter, enable = %s, cpe_users = %u\n",
-		__func__, (enable ? "true" : "false"),
-		core->cpe_users);
-
-	if (enable) {
-		core->cpe_users++;
-		if (core->cpe_users == 1) {
-			ret = wcd_cpe_enable(core, enable);
-			if (ret) {
-				dev_err(core->dev,
-					"%s: CPE enable failed, err = %d\n",
-					__func__, ret);
-				goto done;
-			}
-		} else {
-			dev_dbg(core->dev,
-				"%s: cpe already enabled, users = %u\n",
-				__func__, core->cpe_users);
-			goto done;
-		}
-	} else {
-		core->cpe_users--;
-		if (core->cpe_users == 0) {
-			ret = wcd_cpe_enable(core, enable);
-			if (ret) {
-				dev_err(core->dev,
-					"%s: CPE disable failed, err = %d\n",
-					__func__, ret);
-				goto done;
-			}
-		} else {
-			dev_dbg(core->dev,
-				"%s: %u valid users on cpe\n",
-				__func__, core->cpe_users);
-			goto done;
-		}
-	}
-
-	dev_dbg(core->dev,
-		"%s: leave, enable = %s, cpe_users = %u\n",
-		__func__, (enable ? "true" : "false"),
-		core->cpe_users);
-
-done:
-	return ret;
-}
-
-static int wcd_cpe_debugfs_init(struct wcd_cpe_core *core)
-{
-	int rc = 0;
-
-	struct dentry *dir = debugfs_create_dir("wcd_cpe", NULL);
-
-	if (IS_ERR_OR_NULL(dir)) {
-		dir = NULL;
-		rc = -ENODEV;
-		goto err_create_dir;
-	}
-
-	if (!debugfs_create_u32("ramdump_enable", 0644,
-				dir, &ramdump_enable)) {
-		dev_err(core->dev, "%s: Failed to create debugfs node %s\n",
-			__func__, "ramdump_enable");
-		rc = -ENODEV;
-		goto err_create_entry;
-	}
-
-	if (!debugfs_create_file("cpe_ftm_test_trigger", 0200,
-				dir, core, &cpe_ftm_test_trigger_fops)) {
-		dev_err(core->dev, "%s: Failed to create debugfs node %s\n",
-			__func__, "cpe_ftm_test_trigger");
-		rc = -ENODEV;
-		goto err_create_entry;
-	}
-
-	if (!debugfs_create_u32("cpe_ftm_test_status", 0444,
-				dir, &cpe_ftm_test_status)) {
-		dev_err(core->dev, "%s: Failed to create debugfs node %s\n",
-			__func__, "cpe_ftm_test_status");
-		rc = -ENODEV;
-		goto err_create_entry;
-	}
-
-err_create_entry:
-	debugfs_remove(dir);
-
-err_create_dir:
-	return rc;
-}
-
-static ssize_t fw_name_show(struct wcd_cpe_core *core, char *buf)
-{
-	return snprintf(buf, WCD_CPE_IMAGE_FNAME_MAX, "%s",
-			core->dyn_fname);
-}
-
-static ssize_t fw_name_store(struct wcd_cpe_core *core,
-		const char *buf, ssize_t count)
-{
-	int copy_count = count;
-	const char *pos;
-
-	pos = memchr(buf, '\n', count);
-	if (pos)
-		copy_count = pos - buf;
-
-	if (copy_count > (WCD_CPE_IMAGE_FNAME_MAX - 1)) {
-		dev_err(core->dev,
-			"%s: Invalid length %d, max allowed %d\n",
-			__func__, copy_count, WCD_CPE_IMAGE_FNAME_MAX - 1);
-		return -EINVAL;
-	}
-
-	strlcpy(core->dyn_fname, buf, copy_count + 1);
-
-	return count;
-}
-
-WCD_CPE_ATTR(fw_name, 0660, fw_name_show, fw_name_store);
-
-static ssize_t wcd_cpe_sysfs_show(struct kobject *kobj,
-		struct attribute *attr, char *buf)
-{
-	struct wcd_cpe_attribute *cpe_attr = to_wcd_cpe_attr(attr);
-	struct wcd_cpe_core *core = kobj_to_cpe_core(kobj);
-	ssize_t ret = -EINVAL;
-
-	if (core && cpe_attr->show)
-		ret = cpe_attr->show(core, buf);
-
-	return ret;
-}
-
-static ssize_t wcd_cpe_sysfs_store(struct kobject *kobj,
-		struct attribute *attr, const char *buf,
-		size_t count)
-{
-	struct wcd_cpe_attribute *cpe_attr = to_wcd_cpe_attr(attr);
-	struct wcd_cpe_core *core = kobj_to_cpe_core(kobj);
-	ssize_t ret = -EINVAL;
-
-	if (core && cpe_attr->store)
-		ret = cpe_attr->store(core, buf, count);
-
-	return ret;
-}
-
-static const struct sysfs_ops wcd_cpe_sysfs_ops = {
-	.show = wcd_cpe_sysfs_show,
-	.store = wcd_cpe_sysfs_store,
-};
-
-static struct kobj_type wcd_cpe_ktype = {
-	.sysfs_ops = &wcd_cpe_sysfs_ops,
-};
-
-static int wcd_cpe_sysfs_init(struct wcd_cpe_core *core, int id)
-{
-	char sysfs_dir_name[WCD_CPE_SYSFS_DIR_MAX_LENGTH];
-	int rc = 0;
-
-	snprintf(sysfs_dir_name, WCD_CPE_SYSFS_DIR_MAX_LENGTH,
-		 "%s%d", "wcd_cpe", id);
-
-	rc = kobject_init_and_add(&core->cpe_kobj, &wcd_cpe_ktype,
-				  kernel_kobj,
-				  sysfs_dir_name);
-	if (unlikely(rc)) {
-		dev_err(core->dev,
-			"%s: Failed to add kobject %s, err = %d\n",
-			__func__, sysfs_dir_name, rc);
-		goto done;
-	}
-
-	rc = sysfs_create_file(&core->cpe_kobj, &cpe_attr_fw_name.attr);
-	if (rc) {
-		dev_err(core->dev,
-			"%s: Failed to fw_name sysfs entry to %s\n",
-			__func__, sysfs_dir_name);
-		goto fail_create_file;
-	}
-
-	return 0;
-
-fail_create_file:
-	kobject_put(&core->cpe_kobj);
-done:
-	return rc;
-}
-
-static ssize_t cpe_ftm_test_trigger(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
-{
-	struct wcd_cpe_core *core = file->private_data;
-	int ret = 0;
-
-	/* Enable the clks for cpe */
-	ret = wcd_cpe_enable_cpe_clks(core, true);
-	if (ret < 0) {
-		dev_err(core->dev,
-			"%s: CPE clk enable failed, err = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	/* Get the CPE_STATUS */
-	ret = cpe_svc_ftm_test(core->cpe_handle, &cpe_ftm_test_status);
-	if (ret < 0) {
-		dev_err(core->dev,
-			"%s: CPE FTM test failed, err = %d\n",
-			__func__, ret);
-		if (ret == CPE_SVC_BUSY) {
-			cpe_ftm_test_status = 1;
-			ret = 0;
-		}
-	}
-
-	/* Disable the clks for cpe */
-	ret = wcd_cpe_enable_cpe_clks(core, false);
-	if (ret < 0) {
-		dev_err(core->dev,
-			"%s: CPE clk disable failed, err = %d\n",
-			__func__, ret);
-	}
-
-done:
-	if (ret < 0)
-		return ret;
-	else
-		return count;
-}
-
-static int wcd_cpe_validate_params(
-	struct snd_soc_codec *codec,
-	struct wcd_cpe_params *params)
-{
-
-	if (!codec) {
-		pr_err("%s: Invalid codec\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!params) {
-		dev_err(codec->dev,
-			"%s: No params supplied for codec %s\n",
-			__func__, codec->component.name);
-		return -EINVAL;
-	}
-
-	if (!params->codec || !params->get_cpe_core ||
-	    !params->cdc_cb) {
-		dev_err(codec->dev,
-			"%s: Invalid params for codec %s\n",
-			__func__, codec->component.name);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-/*
- * wcd_cpe_init: Initialize CPE related structures
- * @img_fname: filename for firmware image
- * @codec: handle to codec requesting for image download
- * @params: parameter structure passed from caller
- *
- * This API will initialize the cpe core but will not
- * download the image or boot the cpe core.
- */
-struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
-	struct snd_soc_codec *codec,
-	struct wcd_cpe_params *params)
-{
-	struct wcd_cpe_core *core;
-	int ret = 0;
-	struct snd_card *card = NULL;
-	struct snd_info_entry *entry = NULL;
-	char proc_name[WCD_CPE_STATE_MAX_LEN];
-	const char *cpe_name = "cpe";
-	const char *state_name = "_state";
-	const struct cpe_svc_hw_cfg *hw_info;
-	int id = 0;
-
-	if (wcd_cpe_validate_params(codec, params))
-		return NULL;
-
-	core = kzalloc(sizeof(struct wcd_cpe_core), GFP_KERNEL);
-	if (!core)
-		return NULL;
-
-	snprintf(core->fname, sizeof(core->fname), "%s", img_fname);
-	strlcpy(core->dyn_fname, core->fname, WCD_CPE_IMAGE_FNAME_MAX);
-
-	wcd_get_cpe_core = params->get_cpe_core;
-
-	core->codec = params->codec;
-	core->dev = params->codec->dev;
-	core->cpe_debug_mode = params->dbg_mode;
-
-	core->cdc_info.major_version = params->cdc_major_ver;
-	core->cdc_info.minor_version = params->cdc_minor_ver;
-	core->cdc_info.id = params->cdc_id;
-
-	core->cpe_cdc_cb = params->cdc_cb;
-
-	memcpy(&core->irq_info, &params->cdc_irq_info,
-	       sizeof(core->irq_info));
-
-	INIT_WORK(&core->load_fw_work, wcd_cpe_load_fw_image);
-	INIT_WORK(&core->ssr_work, wcd_cpe_ssr_work);
-	init_completion(&core->offline_compl);
-	init_completion(&core->ready_compl);
-	init_completion(&core->online_compl);
-	init_waitqueue_head(&core->ssr_entry.offline_poll_wait);
-	mutex_init(&core->ssr_lock);
-	core->cpe_users = 0;
-	core->cpe_clk_ref = 0;
-
-	/*
-	 * By default, during probe, it is assumed that
-	 * both CPE hardware block and underlying bus to codec
-	 * are ready
-	 */
-	core->ready_status = WCD_CPE_READY_TO_DLOAD;
-
-	core->cpe_handle = cpe_svc_initialize(NULL, &core->cdc_info,
-					      params->cpe_svc_params);
-	if (!core->cpe_handle) {
-		dev_err(core->dev,
-			"%s: failed to initialize cpe services\n",
-			__func__);
-		goto fail_cpe_initialize;
-	}
-
-	core->cpe_reg_handle = cpe_svc_register(core->cpe_handle,
-					wcd_cpe_svc_event_cb,
-					CPE_SVC_ONLINE | CPE_SVC_OFFLINE |
-					CPE_SVC_BOOT |
-					CPE_SVC_CMI_CLIENTS_DEREG,
-					"codec cpe handler");
-	if (!core->cpe_reg_handle) {
-		dev_err(core->dev,
-			"%s: failed to register cpe service\n",
-			__func__);
-		goto fail_cpe_register;
-	}
-
-	card = codec->component.card->snd_card;
-	snprintf(proc_name, (sizeof("cpe") + sizeof("_state") +
-		 sizeof(id) - 2), "%s%d%s", cpe_name, id, state_name);
-	entry = snd_info_create_card_entry(card, proc_name,
-					   card->proc_root);
-	if (entry) {
-		core->ssr_entry.entry = entry;
-		core->ssr_entry.offline = 1;
-		entry->size = WCD_CPE_STATE_MAX_LEN;
-		entry->content = SNDRV_INFO_CONTENT_DATA;
-		entry->c.ops = &wcd_cpe_state_proc_ops;
-		entry->private_data = core;
-		ret = snd_info_register(entry);
-		if (ret < 0) {
-			dev_err(core->dev,
-				"%s: snd_info_register failed (%d)\n",
-				 __func__, ret);
-			snd_info_free_entry(entry);
-			entry = NULL;
-		}
-	} else {
-		dev_err(core->dev,
-			"%s: Failed to create CPE SSR status entry\n",
-			__func__);
-		/*
-		 * Even if SSR entry creation fails, continue
-		 * with image download
-		 */
-	}
-
-	core_d = core;
-	ret = wcd_cpe_cal_init(core);
-	if (ret < 0) {
-		dev_err(core->dev,
-			"%s: CPE calibration init failed, err = %d\n",
-			__func__, ret);
-		goto fail_cpe_reset;
-	}
-
-	wcd_cpe_debugfs_init(core);
-
-	wcd_cpe_sysfs_init(core, id);
-
-	hw_info = cpe_svc_get_hw_cfg(core->cpe_handle);
-	if (!hw_info) {
-		dev_err(core->dev,
-			"%s: hw info not available\n",
-			__func__);
-		goto schedule_dload_work;
-	} else {
-		core->hw_info.dram_offset = hw_info->DRAM_offset;
-		core->hw_info.dram_size = hw_info->DRAM_size;
-		core->hw_info.iram_offset = hw_info->IRAM_offset;
-		core->hw_info.iram_size = hw_info->IRAM_size;
-	}
-
-	/* Setup the ramdump device and buffer */
-	core->cpe_ramdump_dev = create_ramdump_device("cpe",
-						      core->dev);
-	if (!core->cpe_ramdump_dev) {
-		dev_err(core->dev,
-			"%s: Failed to create ramdump device\n",
-			__func__);
-		goto schedule_dload_work;
-	}
-
-	arch_setup_dma_ops(core->dev, 0, 0, NULL, 0);
-	core->cpe_dump_v_addr = dma_alloc_coherent(core->dev,
-						   core->hw_info.dram_size,
-						   &core->cpe_dump_addr,
-						   GFP_KERNEL);
-	if (!core->cpe_dump_v_addr) {
-		dev_err(core->dev,
-			"%s: Failed to alloc memory for cpe dump, size = %zd\n",
-			__func__, core->hw_info.dram_size);
-		goto schedule_dload_work;
-	} else {
-		memset(core->cpe_dump_v_addr, 0, core->hw_info.dram_size);
-	}
-
-schedule_dload_work:
-	core->ssr_type = WCD_CPE_INITIALIZED;
-	schedule_work(&core->load_fw_work);
-	return core;
-
-fail_cpe_reset:
-	cpe_svc_deregister(core->cpe_handle, core->cpe_reg_handle);
-
-fail_cpe_register:
-	cpe_svc_deinitialize(core->cpe_handle);
-
-fail_cpe_initialize:
-	kfree(core);
-	return NULL;
-}
-EXPORT_SYMBOL(wcd_cpe_init);
-
-/*
- * wcd_cpe_cmi_lsm_callback: callback called from cpe services
- *			     to notify command response for lsm
- *			     service
- * @param: param containing the response code and status
- *
- * This callback is registered with cpe services while registering
- * the LSM service
- */
-static void wcd_cpe_cmi_lsm_callback(const struct cmi_api_notification *param)
-{
-	struct cmi_hdr *hdr;
-	struct cpe_lsm_session *lsm_session;
-	u8 session_id;
-
-	if (!param) {
-		pr_err("%s: param is null\n", __func__);
-		return;
-	}
-
-	if (param->event != CMI_API_MSG) {
-		pr_err("%s: unhandled event 0x%x\n", __func__, param->event);
-		return;
-	}
-
-	hdr = (struct cmi_hdr *) param->message;
-	session_id = CMI_HDR_GET_SESSION_ID(hdr);
-
-	if (session_id > WCD_CPE_LSM_MAX_SESSIONS) {
-		pr_err("%s: invalid lsm session id = %d\n",
-			__func__, session_id);
-		return;
-	}
-
-	lsm_session = lsm_sessions[session_id];
-
-	if (hdr->opcode == CPE_CMI_BASIC_RSP_OPCODE) {
-
-		u8 *payload = ((u8 *)param->message) + (sizeof(struct cmi_hdr));
-		u8 result = payload[0];
-
-		lsm_session->cmd_err_code = result;
-		complete(&lsm_session->cmd_comp);
-
-	} else if (hdr->opcode == CPE_LSM_SESSION_CMDRSP_SHARED_MEM_ALLOC) {
-
-		struct cpe_cmdrsp_shmem_alloc *cmdrsp_shmem_alloc =
-			(struct cpe_cmdrsp_shmem_alloc *) param->message;
-
-		if (cmdrsp_shmem_alloc->addr == 0) {
-			pr_err("%s: Failed LSM shared mem alloc\n", __func__);
-			lsm_session->cmd_err_code = CMI_SHMEM_ALLOC_FAILED;
-
-		} else {
-
-			pr_debug("%s LSM shared mem addr = 0x%x\n",
-				__func__, cmdrsp_shmem_alloc->addr);
-			lsm_session->lsm_mem_handle = cmdrsp_shmem_alloc->addr;
-			lsm_session->cmd_err_code = 0;
-		}
-
-		complete(&lsm_session->cmd_comp);
-
-	} else if (hdr->opcode == CPE_LSM_SESSION_EVENT_DETECTION_STATUS_V2) {
-
-		struct cpe_lsm_event_detect_v2 *event_detect_v2 =
-			(struct cpe_lsm_event_detect_v2 *) param->message;
-
-		if (!lsm_session->priv_d) {
-			pr_err("%s: private data is not present\n",
-				__func__);
-			return;
-		}
-
-		pr_debug("%s: event payload, status = %u, size = %u\n",
-			__func__, event_detect_v2->detection_status,
-			event_detect_v2->size);
-
-		if (lsm_session->event_cb)
-			lsm_session->event_cb(
-				lsm_session->priv_d,
-				event_detect_v2->detection_status,
-				event_detect_v2->size,
-				event_detect_v2->payload);
-	}
-}
-
-/*
- * wcd_cpe_cmi_send_lsm_msg: send a message to lsm service
- * @core: handle to cpe core
- * @session: session on which to send the message
- * @message: actual message containing header and payload
- *
- * Sends message to lsm service for specified session and wait
- * for response back on the message.
- * should be called after acquiring session specific mutex
- */
-static int wcd_cpe_cmi_send_lsm_msg(
-			struct wcd_cpe_core *core,
-			struct cpe_lsm_session *session,
-			void *message)
-{
-	int ret = 0;
-	struct cmi_hdr *hdr = message;
-
-	pr_debug("%s: sending message with opcode 0x%x\n",
-		 __func__, hdr->opcode);
-
-	if (unlikely(!wcd_cpe_is_online_state(core))) {
-		dev_err(core->dev,
-			"%s: MSG not sent, CPE offline\n",
-			 __func__);
-		goto done;
-	}
-
-	if (CMI_HDR_GET_OBM_FLAG(hdr))
-		wcd_cpe_bus_vote_max_bw(core, true);
-
-	reinit_completion(&session->cmd_comp);
-	ret = cmi_send_msg(message);
-	if (ret) {
-		pr_err("%s: msg opcode (0x%x) send failed (%d)\n",
-			__func__, hdr->opcode, ret);
-		goto rel_bus_vote;
-	}
-
-	ret = wait_for_completion_timeout(&session->cmd_comp,
-					  CMI_CMD_TIMEOUT);
-	if (ret > 0) {
-		pr_debug("%s: command 0x%x, received response 0x%x\n",
-			__func__, hdr->opcode, session->cmd_err_code);
-		if (session->cmd_err_code == CMI_SHMEM_ALLOC_FAILED)
-			session->cmd_err_code = CPE_ENOMEMORY;
-		if (session->cmd_err_code > 0)
-			pr_err("%s: CPE returned error[%s]\n",
-				__func__, cpe_err_get_err_str(
-				session->cmd_err_code));
-		ret = cpe_err_get_lnx_err_code(session->cmd_err_code);
-		goto rel_bus_vote;
-	} else {
-		pr_err("%s: command (0x%x) send timed out\n",
-			__func__, hdr->opcode);
-		ret = -ETIMEDOUT;
-		goto rel_bus_vote;
-	}
-
-
-rel_bus_vote:
-
-	if (CMI_HDR_GET_OBM_FLAG(hdr))
-		wcd_cpe_bus_vote_max_bw(core, false);
-
-done:
-	return ret;
-}
-
-
-/*
- * fill_cmi_header: fill the cmi header with specified values
- *
- * @hdr: header to be updated with values
- * @session_id: session id of the header,
- *		in case of AFE service it is port_id
- * @service_id: afe/lsm, etc
- * @version: update the version field in header
- * @payload_size: size of the payload following after header
- * @opcode: opcode of the message
- * @obm_flag: indicates if this header is for obm message
- *
- */
-static int fill_cmi_header(struct cmi_hdr *hdr,
-			   u8 session_id, u8 service_id,
-			   bool version, u8 payload_size,
-			   u16 opcode, bool obm_flag)
-{
-	/* sanitize the data */
-	if (!IS_VALID_SESSION_ID(session_id) ||
-	    !IS_VALID_SERVICE_ID(service_id) ||
-	    !IS_VALID_PLD_SIZE(payload_size)) {
-		pr_err("Invalid header creation request\n");
-		return -EINVAL;
-	}
-
-	CMI_HDR_SET_SESSION(hdr, session_id);
-	CMI_HDR_SET_SERVICE(hdr, service_id);
-	if (version)
-		CMI_HDR_SET_VERSION(hdr, 1);
-	else
-		CMI_HDR_SET_VERSION(hdr, 0);
-
-	CMI_HDR_SET_PAYLOAD_SIZE(hdr, payload_size);
-
-	hdr->opcode = opcode;
-
-	if (obm_flag)
-		CMI_HDR_SET_OBM(hdr, CMI_OBM_FLAG_OUT_BAND);
-	else
-		CMI_HDR_SET_OBM(hdr, CMI_OBM_FLAG_IN_BAND);
-
-	return 0;
-}
-
-/*
- * fill_lsm_cmd_header_v0_inband:
- *	Given the header, fill the header with information
- *	for lsm service, version 0 and inband message
- * @hdr: the cmi header to be filled.
- * @session_id: ID for the lsm session
- * @payload_size: size for cmi message payload
- * @opcode: opcode for cmi message
- */
-static int fill_lsm_cmd_header_v0_inband(struct cmi_hdr *hdr,
-		u8 session_id, u8 payload_size, u16 opcode)
-{
-	return fill_cmi_header(hdr, session_id,
-			       CMI_CPE_LSM_SERVICE_ID, false,
-			       payload_size, opcode, false);
-}
-
-/*
- * wcd_cpe_is_valid_lsm_session:
- *	Check session parameters to identify validity for the sesion
- * @core: handle to cpe core
- * @session: handle to the lsm session
- * @func: invoking function to be printed in error logs
- */
-static int wcd_cpe_is_valid_lsm_session(struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		const char *func)
-{
-	if (unlikely(IS_ERR_OR_NULL(core))) {
-		pr_err("%s: invalid handle to core\n",
-			func);
-		return -EINVAL;
-	}
-
-	if (unlikely(IS_ERR_OR_NULL(session))) {
-		dev_err(core->dev, "%s: invalid session\n",
-			func);
-		return -EINVAL;
-	}
-
-	if (session->id > WCD_CPE_LSM_MAX_SESSIONS) {
-		dev_err(core->dev, "%s: invalid session id (%u)\n",
-			func, session->id);
-		return -EINVAL;
-	}
-
-	dev_dbg(core->dev, "%s: session_id = %u\n",
-		func, session->id);
-	return 0;
-}
-
-static int wcd_cpe_cmd_lsm_open_tx_v2(
-	struct wcd_cpe_core *core,
-	struct cpe_lsm_session *session)
-{
-	struct cpe_lsm_cmd_open_tx_v2 cmd_open_tx_v2;
-	struct cal_block_data *top_cal = NULL;
-	struct audio_cal_info_lsm_top *lsm_top;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	if (core->cal_data[WCD_CPE_LSM_CAL_TOPOLOGY_ID] == NULL) {
-		dev_err(core->dev,
-			"%s: LSM_TOPOLOGY cal not allocated!\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&core->cal_data[WCD_CPE_LSM_CAL_TOPOLOGY_ID]->lock);
-	top_cal = cal_utils_get_only_cal_block(
-			core->cal_data[WCD_CPE_LSM_CAL_TOPOLOGY_ID]);
-	if (!top_cal) {
-		dev_err(core->dev,
-			"%s: Failed to get LSM TOPOLOGY cal block\n",
-			__func__);
-		ret = -EINVAL;
-		goto unlock_cal_mutex;
-	}
-
-	lsm_top = (struct audio_cal_info_lsm_top *)
-			top_cal->cal_info;
-
-	if (!lsm_top) {
-		dev_err(core->dev,
-			"%s: cal_info for LSM_TOPOLOGY not found\n",
-			__func__);
-		ret = -EINVAL;
-		goto unlock_cal_mutex;
-	}
-
-	dev_dbg(core->dev,
-		"%s: topology_id = 0x%x, acdb_id = 0x%x, app_type = 0x%x\n",
-		__func__, lsm_top->topology, lsm_top->acdb_id,
-		lsm_top->app_type);
-
-	if (lsm_top->topology == 0) {
-		dev_err(core->dev,
-			"%s: topology id not sent for app_type 0x%x\n",
-			__func__, lsm_top->app_type);
-		ret = -EINVAL;
-		goto unlock_cal_mutex;
-	}
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_open_tx_v2, 0, sizeof(struct cpe_lsm_cmd_open_tx_v2));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_open_tx_v2.hdr,
-				session->id, OPEN_V2_CMD_PAYLOAD_SIZE,
-				CPE_LSM_SESSION_CMD_OPEN_TX_V2)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_open_tx_v2.topology_id = lsm_top->topology;
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_open_tx_v2);
-	if (ret)
-		dev_err(core->dev,
-			"%s: failed to send open_tx_v2 cmd, err = %d\n",
-			__func__, ret);
-	else
-		session->is_topology_used = true;
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-
-unlock_cal_mutex:
-	mutex_unlock(&core->cal_data[WCD_CPE_LSM_CAL_TOPOLOGY_ID]->lock);
-	return ret;
-}
-
-/*
- * wcd_cpe_cmd_lsm_open_tx: compose and send lsm open command
- * @core_handle: handle to cpe core
- * @session: session for which the command needs to be sent
- * @app_id: application id part of the command
- * @sample_rate: sample rate for this session
- */
-static int wcd_cpe_cmd_lsm_open_tx(void *core_handle,
-		struct cpe_lsm_session *session,
-		u16 app_id, u16 sample_rate)
-{
-	struct cpe_lsm_cmd_open_tx cmd_open_tx;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	/* Try to open with topology first */
-	ret = wcd_cpe_cmd_lsm_open_tx_v2(core, session);
-	if (!ret)
-		goto done;
-
-	dev_dbg(core->dev, "%s: Try open_tx without topology\n",
-		__func__);
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_open_tx, 0, sizeof(struct cpe_lsm_cmd_open_tx));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_open_tx.hdr,
-				session->id, OPEN_CMD_PAYLOAD_SIZE,
-				CPE_LSM_SESSION_CMD_OPEN_TX)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_open_tx.app_id = app_id;
-	cmd_open_tx.sampling_rate = sample_rate;
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_open_tx);
-	if (ret)
-		dev_err(core->dev,
-			"%s: failed to send open_tx cmd, err = %d\n",
-			__func__, ret);
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-done:
-	return ret;
-}
-
-/*
- * wcd_cpe_cmd_close_tx: compose and send lsm close command
- * @core_handle: handle to cpe core
- * @session: session for which the command needs to be sent
- */
-static int wcd_cpe_cmd_lsm_close_tx(void *core_handle,
-			struct cpe_lsm_session *session)
-{
-	struct cmi_hdr cmd_close_tx;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_close_tx, 0, sizeof(cmd_close_tx));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_close_tx, session->id,
-			    0, CPE_LSM_SESSION_CMD_CLOSE_TX)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_close_tx);
-	if (ret)
-		dev_err(core->dev,
-			"%s: lsm close_tx cmd failed, err = %d\n",
-			__func__, ret);
-	else
-		session->is_topology_used = false;
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_cmd_shmem_alloc: compose and send lsm shared
- *			    memory allocation command
- * @core_handle: handle to cpe core
- * @session: session for which the command needs to be sent
- * @size: size of memory to be allocated
- */
-static int wcd_cpe_cmd_lsm_shmem_alloc(void *core_handle,
-			struct cpe_lsm_session *session,
-			u32 size)
-{
-	struct cpe_cmd_shmem_alloc cmd_shmem_alloc;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_shmem_alloc, 0, sizeof(cmd_shmem_alloc));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_shmem_alloc.hdr, session->id,
-			    SHMEM_ALLOC_CMD_PLD_SIZE,
-			    CPE_LSM_SESSION_CMD_SHARED_MEM_ALLOC)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_shmem_alloc.size = size;
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_shmem_alloc);
-	if (ret)
-		dev_err(core->dev,
-			"%s: lsm_shmem_alloc cmd send fail, %d\n",
-			__func__, ret);
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_cmd_lsm_shmem_dealloc: deallocate the shared memory
- *				  for the specified session
- * @core_handle: handle to cpe core
- * @session: session for which memory needs to be deallocated.
- */
-static int wcd_cpe_cmd_lsm_shmem_dealloc(void *core_handle,
-		struct cpe_lsm_session *session)
-{
-	struct cpe_cmd_shmem_dealloc cmd_dealloc;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_dealloc, 0, sizeof(cmd_dealloc));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_dealloc.hdr, session->id,
-			    SHMEM_DEALLOC_CMD_PLD_SIZE,
-			    CPE_LSM_SESSION_CMD_SHARED_MEM_DEALLOC)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_dealloc.addr = session->lsm_mem_handle;
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_dealloc);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: lsm_shmem_dealloc cmd failed, rc %d\n",
-			__func__, ret);
-		goto end_ret;
-	}
-
-	memset(&session->lsm_mem_handle, 0,
-	       sizeof(session->lsm_mem_handle));
-
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_send_lsm_cal: send the calibration for lsm service
- *			      from acdb to the cpe
- * @core: handle to cpe core
- * @session: session for which the calibration needs to be set.
- */
-static int wcd_cpe_send_lsm_cal(
-			struct wcd_cpe_core *core,
-			struct cpe_lsm_session *session)
-{
-
-	u8 *msg_pld;
-	struct cmi_hdr *hdr;
-	struct cal_block_data *lsm_cal = NULL;
-	void *inb_msg;
-	int rc = 0;
-
-	if (core->cal_data[WCD_CPE_LSM_CAL_LSM] == NULL) {
-		pr_err("%s: LSM cal not allocated!\n", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&core->cal_data[WCD_CPE_LSM_CAL_LSM]->lock);
-	lsm_cal = cal_utils_get_only_cal_block(
-			core->cal_data[WCD_CPE_LSM_CAL_LSM]);
-	if (!lsm_cal) {
-		pr_err("%s: failed to get lsm cal block\n", __func__);
-		rc = -EINVAL;
-		goto unlock_cal_mutex;
-	}
-
-	if (lsm_cal->cal_data.size == 0) {
-		dev_dbg(core->dev, "%s: No LSM cal to send\n",
-			__func__);
-		rc = 0;
-		goto unlock_cal_mutex;
-	}
-
-	inb_msg = kzalloc(sizeof(struct cmi_hdr) + lsm_cal->cal_data.size,
-			  GFP_KERNEL);
-	if (!inb_msg) {
-		rc = -ENOMEM;
-		goto unlock_cal_mutex;
-	}
-
-	hdr = (struct cmi_hdr *) inb_msg;
-
-	rc = fill_lsm_cmd_header_v0_inband(hdr, session->id,
-			lsm_cal->cal_data.size,
-			CPE_LSM_SESSION_CMD_SET_PARAMS);
-	if (rc) {
-		pr_err("%s: invalid params for header, err = %d\n",
-			__func__, rc);
-		goto free_msg;
-	}
-
-	msg_pld = ((u8 *) inb_msg) + sizeof(struct cmi_hdr);
-	memcpy(msg_pld, lsm_cal->cal_data.kvaddr,
-	       lsm_cal->cal_data.size);
-
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, inb_msg);
-	if (rc)
-		pr_err("%s: acdb lsm_params send failed, err = %d\n",
-			__func__, rc);
-
-free_msg:
-	kfree(inb_msg);
-
-unlock_cal_mutex:
-	mutex_unlock(&core->cal_data[WCD_CPE_LSM_CAL_LSM]->lock);
-	return rc;
-
-}
-
-static void wcd_cpe_set_param_data(struct cpe_param_data *param_d,
-		struct cpe_lsm_ids *ids, u32 p_size,
-		u32 set_param_cmd)
-{
-	param_d->module_id = ids->module_id;
-	param_d->param_id = ids->param_id;
-
-	switch (set_param_cmd) {
-	case CPE_LSM_SESSION_CMD_SET_PARAMS_V2:
-		param_d->p_size.param_size = p_size;
-		break;
-	case CPE_LSM_SESSION_CMD_SET_PARAMS:
-	default:
-		param_d->p_size.sr.param_size =
-			(u16) p_size;
-		param_d->p_size.sr.reserved = 0;
-		break;
-	}
-}
-
-static int wcd_cpe_send_param_epd_thres(struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		void *data, struct cpe_lsm_ids *ids)
-{
-	struct snd_lsm_ep_det_thres *ep_det_data;
-	struct cpe_lsm_param_epd_thres epd_cmd;
-	struct cmi_hdr *msg_hdr = &epd_cmd.hdr;
-	struct cpe_param_data *param_d =
-				&epd_cmd.param;
-	int rc;
-
-	memset(&epd_cmd, 0, sizeof(epd_cmd));
-	ep_det_data = (struct snd_lsm_ep_det_thres *) data;
-	if (fill_lsm_cmd_header_v0_inband(msg_hdr,
-				session->id,
-				CPE_CMD_EPD_THRES_PLD_SIZE,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-
-	wcd_cpe_set_param_data(param_d, ids,
-			       CPE_EPD_THRES_PARAM_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	epd_cmd.minor_version = 1;
-	epd_cmd.epd_begin = ep_det_data->epd_begin;
-	epd_cmd.epd_end = ep_det_data->epd_end;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, &epd_cmd);
-	if (unlikely(rc))
-		dev_err(core->dev,
-			"%s: set_param(EPD Threshold) failed, rc %dn",
-			__func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	return rc;
-}
-
-static int wcd_cpe_send_param_opmode(struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		void *data, struct cpe_lsm_ids *ids)
-{
-	struct snd_lsm_detect_mode *opmode_d;
-	struct cpe_lsm_param_opmode opmode_cmd;
-	struct cmi_hdr *msg_hdr = &opmode_cmd.hdr;
-	struct cpe_param_data *param_d =
-				&opmode_cmd.param;
-	int rc;
-
-	memset(&opmode_cmd, 0, sizeof(opmode_cmd));
-	opmode_d = (struct snd_lsm_detect_mode *) data;
-	if (fill_lsm_cmd_header_v0_inband(msg_hdr,
-				session->id,
-				CPE_CMD_OPMODE_PLD_SIZE,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-
-	wcd_cpe_set_param_data(param_d, ids,
-			       CPE_OPMODE_PARAM_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	opmode_cmd.minor_version = 1;
-	if (opmode_d->mode == LSM_MODE_KEYWORD_ONLY_DETECTION)
-		opmode_cmd.mode = 1;
-	else
-		opmode_cmd.mode = 3;
-
-	if (opmode_d->detect_failure)
-		opmode_cmd.mode |= 0x04;
-
-	opmode_cmd.reserved = 0;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, &opmode_cmd);
-	if (unlikely(rc))
-		dev_err(core->dev,
-			"%s: set_param(operation_mode) failed, rc %dn",
-			__func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	return rc;
-}
-
-static int wcd_cpe_send_param_gain(struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		void *data, struct cpe_lsm_ids *ids)
-{
-	struct snd_lsm_gain *gain_d;
-	struct cpe_lsm_param_gain gain_cmd;
-	struct cmi_hdr *msg_hdr = &gain_cmd.hdr;
-	struct cpe_param_data *param_d =
-				&gain_cmd.param;
-	int rc;
-
-	memset(&gain_cmd, 0, sizeof(gain_cmd));
-	gain_d = (struct snd_lsm_gain *) data;
-	if (fill_lsm_cmd_header_v0_inband(msg_hdr,
-				session->id,
-				CPE_CMD_GAIN_PLD_SIZE,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-
-	wcd_cpe_set_param_data(param_d, ids,
-			       CPE_GAIN_PARAM_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	gain_cmd.minor_version = 1;
-	gain_cmd.gain = gain_d->gain;
-	gain_cmd.reserved = 0;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, &gain_cmd);
-	if (unlikely(rc))
-		dev_err(core->dev,
-			"%s: set_param(lsm_gain) failed, rc %dn",
-			__func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	return rc;
-}
-
-static int wcd_cpe_send_param_connectport(struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		void *data, struct cpe_lsm_ids *ids, u16 port_id)
-{
-	struct cpe_lsm_param_connectport con_port_cmd;
-	struct cmi_hdr *msg_hdr = &con_port_cmd.hdr;
-	struct cpe_param_data *param_d =
-				&con_port_cmd.param;
-	int rc;
-
-	memset(&con_port_cmd, 0, sizeof(con_port_cmd));
-	if (fill_lsm_cmd_header_v0_inband(msg_hdr,
-				session->id,
-				CPE_CMD_CONNECTPORT_PLD_SIZE,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-
-	wcd_cpe_set_param_data(param_d, ids,
-			       CPE_CONNECTPORT_PARAM_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	con_port_cmd.minor_version = 1;
-	con_port_cmd.afe_port_id = port_id;
-	con_port_cmd.reserved = 0;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, &con_port_cmd);
-	if (unlikely(rc))
-		dev_err(core->dev,
-			"%s: set_param(connect_port) failed, rc %dn",
-			__func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	return rc;
-}
-
-static int wcd_cpe_send_param_conf_levels(
-		struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		struct cpe_lsm_ids *ids)
-{
-	struct cpe_lsm_conf_level conf_level_data;
-	struct cmi_hdr *hdr = &(conf_level_data.hdr);
-	struct cpe_param_data *param_d = &(conf_level_data.param);
-	u8 pld_size = 0;
-	u8 pad_bytes = 0;
-	void *message;
-	int ret = 0;
-
-	memset(&conf_level_data, 0, sizeof(conf_level_data));
-
-	pld_size = (sizeof(struct cpe_lsm_conf_level) - sizeof(struct cmi_hdr));
-	pld_size += session->num_confidence_levels;
-	pad_bytes = ((4 - (pld_size % 4)) % 4);
-	pld_size += pad_bytes;
-
-	fill_cmi_header(hdr, session->id, CMI_CPE_LSM_SERVICE_ID,
-			false, pld_size,
-			CPE_LSM_SESSION_CMD_SET_PARAMS_V2, false);
-
-	wcd_cpe_set_param_data(param_d, ids,
-			       pld_size - sizeof(struct cpe_param_data),
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	conf_level_data.num_active_models = session->num_confidence_levels;
-
-	message = kzalloc(sizeof(struct cpe_lsm_conf_level) +
-			   conf_level_data.num_active_models + pad_bytes,
-			   GFP_KERNEL);
-	if (!message) {
-		pr_err("%s: no memory for conf_level\n", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(message, &conf_level_data,
-	       sizeof(struct cpe_lsm_conf_level));
-	memcpy(((u8 *) message) + sizeof(struct cpe_lsm_conf_level),
-		session->conf_levels, conf_level_data.num_active_models);
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, message);
-	if (ret)
-		pr_err("%s: lsm_set_conf_levels failed, err = %d\n",
-			__func__, ret);
-	kfree(message);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-static int wcd_cpe_send_param_snd_model(struct wcd_cpe_core *core,
-	struct cpe_lsm_session *session, struct cpe_lsm_ids *ids)
-{
-	int ret = 0;
-	struct cmi_obm_msg obm_msg;
-	struct cpe_param_data *param_d;
-
-
-	ret = fill_cmi_header(&obm_msg.hdr, session->id,
-			CMI_CPE_LSM_SERVICE_ID, 0, 20,
-			CPE_LSM_SESSION_CMD_SET_PARAMS_V2, true);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Invalid parameters, rc = %d\n",
-			__func__, ret);
-		goto err_ret;
-	}
-
-	obm_msg.pld.version = 0;
-	obm_msg.pld.size = session->snd_model_size;
-	obm_msg.pld.data_ptr.kvaddr = session->snd_model_data;
-	obm_msg.pld.mem_handle = session->lsm_mem_handle;
-
-	param_d = (struct cpe_param_data *) session->snd_model_data;
-	wcd_cpe_set_param_data(param_d, ids,
-			(session->snd_model_size - sizeof(*param_d)),
-			CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &obm_msg);
-	if (ret)
-		dev_err(core->dev,
-			"%s: snd_model_register failed, %d\n",
-			__func__, ret);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-
-err_ret:
-	return ret;
-}
-
-static int wcd_cpe_send_param_dereg_model(
-	struct wcd_cpe_core *core,
-	struct cpe_lsm_session *session,
-	struct cpe_lsm_ids *ids)
-{
-	struct cmi_hdr *hdr;
-	struct cpe_param_data *param_d;
-	u8 *message;
-	u32 pld_size;
-	int rc = 0;
-
-	pld_size = sizeof(*hdr) + sizeof(*param_d);
-
-	message = kzalloc(pld_size, GFP_KERNEL);
-	if (!message)
-		return -ENOMEM;
-
-	hdr = (struct cmi_hdr *) message;
-	param_d = (struct cpe_param_data *)
-			(((u8 *) message) + sizeof(*hdr));
-
-	if (fill_lsm_cmd_header_v0_inband(hdr,
-				session->id,
-				sizeof(*param_d),
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-	wcd_cpe_set_param_data(param_d, ids, 0,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, message);
-	if (rc)
-		dev_err(core->dev,
-			"%s: snd_model_deregister failed, %d\n",
-			__func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	kfree(message);
-	return rc;
-}
-
-static int wcd_cpe_send_custom_param(
-	struct wcd_cpe_core *core,
-	struct cpe_lsm_session *session,
-	void *data, u32 msg_size)
-{
-	u8 *msg;
-	struct cmi_hdr *hdr;
-	u8 *msg_pld;
-	int rc;
-
-	if (msg_size > CMI_INBAND_MESSAGE_SIZE) {
-		dev_err(core->dev,
-			"%s: out of band custom params not supported\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	msg = kzalloc(sizeof(*hdr) + msg_size, GFP_KERNEL);
-	if (!msg)
-		return -ENOMEM;
-
-	hdr = (struct cmi_hdr *) msg;
-	msg_pld = msg + sizeof(struct cmi_hdr);
-
-	if (fill_lsm_cmd_header_v0_inband(hdr,
-				session->id,
-				msg_size,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		rc = -EINVAL;
-		goto err_ret;
-	}
-
-	memcpy(msg_pld, data, msg_size);
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	rc = wcd_cpe_cmi_send_lsm_msg(core, session, msg);
-	if (rc)
-		dev_err(core->dev,
-			"%s: custom params send failed, err = %d\n",
-			 __func__, rc);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-err_ret:
-	kfree(msg);
-	return rc;
-}
-
-static int wcd_cpe_set_one_param(void *core_handle,
-	struct cpe_lsm_session *session, struct lsm_params_info *p_info,
-	void *data, uint32_t param_type)
-{
-	struct wcd_cpe_core *core = core_handle;
-	int rc = 0;
-	struct cpe_lsm_ids ids;
-
-	memset(&ids, 0, sizeof(ids));
-	ids.module_id = p_info->module_id;
-	ids.param_id = p_info->param_id;
-
-	switch (param_type) {
-	case LSM_ENDPOINT_DETECT_THRESHOLD:
-		rc = wcd_cpe_send_param_epd_thres(core, session,
-						data, &ids);
-		break;
-	case LSM_OPERATION_MODE:
-		rc = wcd_cpe_send_param_opmode(core, session, data, &ids);
-		break;
-	case LSM_GAIN:
-		rc = wcd_cpe_send_param_gain(core, session, data, &ids);
-		break;
-	case LSM_MIN_CONFIDENCE_LEVELS:
-		rc = wcd_cpe_send_param_conf_levels(core, session, &ids);
-		break;
-	case LSM_REG_SND_MODEL:
-		rc = wcd_cpe_send_param_snd_model(core, session, &ids);
-		break;
-	case LSM_DEREG_SND_MODEL:
-		rc = wcd_cpe_send_param_dereg_model(core, session, &ids);
-		break;
-	case LSM_CUSTOM_PARAMS:
-		rc = wcd_cpe_send_custom_param(core, session,
-					       data, p_info->param_size);
-		break;
-	default:
-		pr_err("%s: wrong param_type 0x%x\n",
-			__func__, param_type);
-	}
-
-	if (rc)
-		dev_err(core->dev,
-			"%s: send_param(%d) failed, err %d\n",
-			 __func__, param_type, rc);
-	return rc;
-}
-
-/*
- * wcd_cpe_lsm_set_params: set the parameters for lsm service
- * @core: handle to cpe core
- * @session: session for which the parameters are to be set
- * @detect_mode: mode for detection
- * @detect_failure: flag indicating failure detection enabled/disabled
- *
- */
-static int wcd_cpe_lsm_set_params(struct wcd_cpe_core *core,
-	struct cpe_lsm_session *session,
-	enum lsm_detection_mode detect_mode, bool detect_failure)
-{
-	struct cpe_lsm_ids ids;
-	struct snd_lsm_detect_mode det_mode;
-
-	int ret = 0;
-
-	/* Send lsm calibration */
-	ret = wcd_cpe_send_lsm_cal(core, session);
-	if (ret) {
-		pr_err("%s: fail to sent acdb cal, err = %d",
-			__func__, ret);
-		goto err_ret;
-	}
-
-	/* Send operation mode */
-	ids.module_id = CPE_LSM_MODULE_ID_VOICE_WAKEUP;
-	ids.param_id = CPE_LSM_PARAM_ID_OPERATION_MODE;
-	det_mode.mode = detect_mode;
-	det_mode.detect_failure = detect_failure;
-	ret = wcd_cpe_send_param_opmode(core, session,
-					&det_mode, &ids);
-	if (ret)
-		dev_err(core->dev,
-			"%s: Failed to set opmode, err=%d\n",
-			__func__, ret);
-
-err_ret:
-	return ret;
-}
-
-static int wcd_cpe_lsm_set_data(void *core_handle,
-				struct cpe_lsm_session *session,
-				enum lsm_detection_mode detect_mode,
-				bool detect_failure)
-{
-	struct wcd_cpe_core *core = core_handle;
-	struct cpe_lsm_ids ids;
-	int ret = 0;
-
-	if (session->num_confidence_levels > 0) {
-		ret = wcd_cpe_lsm_set_params(core, session, detect_mode,
-				       detect_failure);
-		if (ret) {
-			dev_err(core->dev,
-				"%s: lsm set params failed, rc = %d\n",
-				__func__, ret);
-			goto err_ret;
-		}
-
-		ids.module_id = CPE_LSM_MODULE_ID_VOICE_WAKEUP;
-		ids.param_id = CPE_LSM_PARAM_ID_MIN_CONFIDENCE_LEVELS;
-		ret = wcd_cpe_send_param_conf_levels(core, session, &ids);
-		if (ret) {
-			dev_err(core->dev,
-				"%s: lsm confidence levels failed, rc = %d\n",
-				__func__, ret);
-			goto err_ret;
-		}
-	} else {
-		dev_dbg(core->dev,
-			"%s: no conf levels to set\n",
-			__func__);
-	}
-
-err_ret:
-	return ret;
-}
-
-/*
- * wcd_cpe_lsm_reg_snd_model: register the sound model for listen
- * @session: session for which to register the sound model
- * @detect_mode: detection mode, user dependent/independent
- * @detect_failure: flag to indicate if failure detection is enabled
- *
- * The memory required for sound model should be pre-allocated on CPE
- * before this function is invoked.
- */
-static int wcd_cpe_lsm_reg_snd_model(void *core_handle,
-				 struct cpe_lsm_session *session,
-				 enum lsm_detection_mode detect_mode,
-				 bool detect_failure)
-{
-	int ret = 0;
-	struct cmi_obm_msg obm_msg;
-	struct wcd_cpe_core *core = core_handle;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	ret = wcd_cpe_lsm_set_data(core_handle, session,
-				   detect_mode, detect_failure);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: fail to set lsm data, err = %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	ret = fill_cmi_header(&obm_msg.hdr, session->id,
-			CMI_CPE_LSM_SERVICE_ID, 0, 20,
-			CPE_LSM_SESSION_CMD_REGISTER_SOUND_MODEL, true);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Invalid parameters, rc = %d\n",
-			__func__, ret);
-		goto err_ret;
-	}
-
-	obm_msg.pld.version = 0;
-	obm_msg.pld.size = session->snd_model_size;
-	obm_msg.pld.data_ptr.kvaddr = session->snd_model_data;
-	obm_msg.pld.mem_handle = session->lsm_mem_handle;
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &obm_msg);
-	if (ret)
-		dev_err(core->dev,
-			"%s: snd_model_register failed, %d\n",
-			__func__, ret);
-err_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_lsm_dereg_snd_model: deregister the sound model for listen
- * @core_handle: handle to cpe core
- * @session: session for which to deregister the sound model
- *
- */
-static int wcd_cpe_lsm_dereg_snd_model(void *core_handle,
-				struct cpe_lsm_session *session)
-{
-	struct cmi_hdr cmd_dereg_snd_model;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_dereg_snd_model, 0, sizeof(cmd_dereg_snd_model));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_dereg_snd_model, session->id,
-			    0, CPE_LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_dereg_snd_model);
-	if (ret)
-		dev_err(core->dev,
-			"%s: failed to send dereg_snd_model cmd\n",
-			__func__);
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_lsm_get_afe_out_port_id: get afe output port id
- * @core_handle: handle to the CPE core
- * @session: session for which port id needs to get
- */
-static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle,
-					   struct cpe_lsm_session *session)
-{
-	struct wcd_cpe_core *core = core_handle;
-	struct snd_soc_codec *codec;
-	int rc = 0;
-
-	if (!core || !core->codec) {
-		pr_err("%s: Invalid handle to %s\n",
-			__func__,
-			(!core) ? "core" : "codec");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (!session) {
-		dev_err(core->dev, "%s: Invalid session\n",
-			__func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (!core->cpe_cdc_cb ||
-		!core->cpe_cdc_cb->get_afe_out_port_id) {
-		session->afe_out_port_id = WCD_CPE_AFE_OUT_PORT_2;
-		dev_dbg(core->dev,
-			"%s: callback not defined, default port_id = %d\n",
-			__func__, session->afe_out_port_id);
-		goto done;
-	}
-
-	codec = core->codec;
-	rc = core->cpe_cdc_cb->get_afe_out_port_id(codec,
-						   &session->afe_out_port_id);
-	if (rc) {
-		dev_err(core->dev,
-			"%s: failed to get port id, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-	dev_dbg(core->dev, "%s: port_id: %d\n", __func__,
-		session->afe_out_port_id);
-
-done:
-	return rc;
-}
-
-/*
- * wcd_cpe_cmd_lsm_start: send the start command to lsm
- * @core_handle: handle to the CPE core
- * @session: session for which start command to be sent
- *
- */
-static int wcd_cpe_cmd_lsm_start(void *core_handle,
-			struct cpe_lsm_session *session)
-{
-	struct cmi_hdr cmd_lsm_start;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_lsm_start, 0, sizeof(struct cmi_hdr));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_lsm_start, session->id, 0,
-					  CPE_LSM_SESSION_CMD_START)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_lsm_start);
-	if (ret)
-		dev_err(core->dev, "failed to send lsm_start cmd\n");
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_cmd_lsm_stop: send the stop command for LSM service
- * @core_handle: handle to the cpe core
- * @session: session for which stop command to be sent
- *
- */
-static int wcd_cpe_cmd_lsm_stop(void *core_handle,
-		struct cpe_lsm_session *session)
-{
-	struct cmi_hdr cmd_lsm_stop;
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session,
-					   __func__);
-	if (ret)
-		return ret;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&cmd_lsm_stop, 0, sizeof(struct cmi_hdr));
-	if (fill_lsm_cmd_header_v0_inband(&cmd_lsm_stop, session->id, 0,
-					  CPE_LSM_SESSION_CMD_STOP)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cmd_lsm_stop);
-	if (ret)
-		dev_err(core->dev,
-			"%s: failed to send lsm_stop cmd\n",
-			__func__);
-end_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-
-}
-
-/*
- * wcd_cpe_alloc_lsm_session: allocate a lsm session
- * @core: handle to wcd_cpe_core
- * @lsm_priv_d: lsm private data
- */
-static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session(
-	void *core_handle, void *client_data,
-	void (*event_cb)(void *, u8, u8, u8 *))
-{
-	struct cpe_lsm_session *session;
-	int i, session_id = -1;
-	struct wcd_cpe_core *core = core_handle;
-	bool afe_register_service = false;
-	int ret = 0;
-
-	/*
-	 * Even if multiple listen sessions can be
-	 * allocated, the AFE service registration
-	 * should be done only once as CPE can only
-	 * have one instance of AFE service.
-	 *
-	 * If this is the first session to be allocated,
-	 * only then register the afe service.
-	 */
-	if (!wcd_cpe_lsm_session_active())
-		afe_register_service = true;
-
-	for (i = 1; i <= WCD_CPE_LSM_MAX_SESSIONS; i++) {
-		if (!lsm_sessions[i]) {
-			session_id = i;
-			break;
-		}
-	}
-
-	if (session_id < 0) {
-		dev_err(core->dev,
-			"%s: max allowed sessions already allocated\n",
-			__func__);
-		return NULL;
-	}
-
-	ret = wcd_cpe_vote(core, true);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: Failed to enable cpe, err = %d\n",
-			__func__, ret);
-		return NULL;
-	}
-
-	session = kzalloc(sizeof(struct cpe_lsm_session), GFP_KERNEL);
-	if (!session)
-		goto err_session_alloc;
-
-	session->id = session_id;
-	session->event_cb = event_cb;
-	session->cmi_reg_handle = cmi_register(wcd_cpe_cmi_lsm_callback,
-						CMI_CPE_LSM_SERVICE_ID);
-	if (!session->cmi_reg_handle) {
-		dev_err(core->dev,
-			"%s: Failed to register LSM service with CMI\n",
-			__func__);
-		goto err_ret;
-	}
-	session->priv_d = client_data;
-	mutex_init(&session->lsm_lock);
-	if (afe_register_service) {
-		/* Register for AFE Service */
-		core->cmi_afe_handle = cmi_register(wcd_cpe_cmi_afe_cb,
-						CMI_CPE_AFE_SERVICE_ID);
-		wcd_cpe_initialize_afe_port_data();
-		if (!core->cmi_afe_handle) {
-			dev_err(core->dev,
-				"%s: Failed to register AFE service with CMI\n",
-				__func__);
-			goto err_afe_svc_reg;
-		}
-
-		/* Once AFE service is registered, send the mode command */
-		ret = wcd_cpe_afe_svc_cmd_mode(core,
-				AFE_SVC_EXPLICIT_PORT_START);
-		if (ret)
-			goto err_afe_mode_cmd;
-	}
-
-	session->lsm_mem_handle = 0;
-	init_completion(&session->cmd_comp);
-
-	lsm_sessions[session_id] = session;
-	return session;
-
-err_afe_mode_cmd:
-	cmi_deregister(core->cmi_afe_handle);
-
-err_afe_svc_reg:
-	cmi_deregister(session->cmi_reg_handle);
-	mutex_destroy(&session->lsm_lock);
-
-err_ret:
-	kfree(session);
-
-err_session_alloc:
-	wcd_cpe_vote(core, false);
-	return NULL;
-}
-
-/*
- * wcd_cpe_lsm_config_lab_latency: send lab latency value
- * @core: handle to wcd_cpe_core
- * @session: lsm session
- * @latency: the value of latency for lab setup in msec
- */
-static int wcd_cpe_lsm_config_lab_latency(
-		struct wcd_cpe_core *core,
-		struct cpe_lsm_session *session,
-		u32 latency)
-{
-	int ret = 0, pld_size = CPE_PARAM_LSM_LAB_LATENCY_SIZE;
-	struct cpe_lsm_lab_latency_config cpe_lab_latency;
-	struct cpe_lsm_lab_config *lab_lat = &cpe_lab_latency.latency_cfg;
-	struct cpe_param_data *param_d = &lab_lat->param;
-	struct cpe_lsm_ids ids;
-
-	if (fill_lsm_cmd_header_v0_inband(&cpe_lab_latency.hdr, session->id,
-		(u8) pld_size, CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		pr_err("%s: Failed to create header\n", __func__);
-		return -EINVAL;
-	}
-	if (latency == 0x00 || latency > WCD_CPE_LAB_MAX_LATENCY) {
-		pr_err("%s: Invalid latency %u\n",
-			__func__, latency);
-		return -EINVAL;
-	}
-
-	lab_lat->latency = latency;
-	lab_lat->minor_ver = 1;
-	ids.module_id = CPE_LSM_MODULE_ID_LAB;
-	ids.param_id = CPE_LSM_PARAM_ID_LAB_CONFIG;
-	wcd_cpe_set_param_data(param_d, &ids,
-			       PARAM_SIZE_LSM_LATENCY_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	pr_debug("%s: Module 0x%x Param 0x%x size %zu pld_size 0x%x\n",
-		  __func__, lab_lat->param.module_id,
-		 lab_lat->param.param_id, PARAM_SIZE_LSM_LATENCY_SIZE,
-		 pld_size);
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cpe_lab_latency);
-	if (ret != 0)
-		pr_err("%s: lsm_set_params failed, error = %d\n",
-		       __func__, ret);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-	return ret;
-}
-
-/*
- * wcd_cpe_lsm_lab_control: enable/disable lab
- * @core: handle to wcd_cpe_core
- * @session: lsm session
- * @enable: Indicates whether to enable / disable lab
- */
-static int wcd_cpe_lsm_lab_control(
-		void *core_handle,
-		struct cpe_lsm_session *session,
-		bool enable)
-{
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0, pld_size = CPE_PARAM_SIZE_LSM_LAB_CONTROL;
-	struct cpe_lsm_control_lab cpe_lab_enable;
-	struct cpe_lsm_lab_enable *lab_enable = &cpe_lab_enable.lab_enable;
-	struct cpe_param_data *param_d = &lab_enable->param;
-	struct cpe_lsm_ids ids;
-
-	pr_debug("%s: enter payload_size = %d Enable %d\n",
-		 __func__, pld_size, enable);
-
-	memset(&cpe_lab_enable, 0, sizeof(cpe_lab_enable));
-
-	if (fill_lsm_cmd_header_v0_inband(&cpe_lab_enable.hdr, session->id,
-		(u8) pld_size, CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		return -EINVAL;
-	}
-	if (enable == true)
-		lab_enable->enable = 1;
-	else
-		lab_enable->enable = 0;
-
-	ids.module_id = CPE_LSM_MODULE_ID_LAB;
-	ids.param_id = CPE_LSM_PARAM_ID_LAB_ENABLE;
-	wcd_cpe_set_param_data(param_d, &ids,
-			PARAM_SIZE_LSM_CONTROL_SIZE,
-			CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	pr_debug("%s: Module 0x%x, Param 0x%x size %zu pld_size 0x%x\n",
-		 __func__, lab_enable->param.module_id,
-		 lab_enable->param.param_id, PARAM_SIZE_LSM_CONTROL_SIZE,
-		 pld_size);
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &cpe_lab_enable);
-	if (ret != 0) {
-		pr_err("%s: lsm_set_params failed, error = %d\n",
-			__func__, ret);
-		WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-		goto done;
-	}
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-
-	if (lab_enable->enable)
-		ret = wcd_cpe_lsm_config_lab_latency(core, session,
-					       WCD_CPE_LAB_MAX_LATENCY);
-done:
-	return ret;
-}
-
-/*
- * wcd_cpe_lsm_eob: stop lab
- * @core: handle to wcd_cpe_core
- * @session: lsm session to be deallocated
- */
-static int wcd_cpe_lsm_eob(
-			struct wcd_cpe_core *core,
-			struct cpe_lsm_session *session)
-{
-	int ret = 0;
-	struct cmi_hdr lab_eob;
-
-	if (fill_lsm_cmd_header_v0_inband(&lab_eob, session->id,
-		0, CPE_LSM_SESSION_CMD_EOB)) {
-		return -EINVAL;
-	}
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &lab_eob);
-	if (ret != 0)
-		pr_err("%s: lsm_set_params failed\n", __func__);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-
-	return ret;
-}
-
-/*
- * wcd_cpe_dealloc_lsm_session: deallocate lsm session
- * @core: handle to wcd_cpe_core
- * @session: lsm session to be deallocated
- */
-static int wcd_cpe_dealloc_lsm_session(void *core_handle,
-			struct cpe_lsm_session *session)
-{
-	struct wcd_cpe_core *core = core_handle;
-	int ret = 0;
-
-	if (!session) {
-		dev_err(core->dev,
-			"%s: Invalid lsm session\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(core->dev, "%s: session %d being deallocated\n",
-		__func__, session->id);
-	if (session->id > WCD_CPE_LSM_MAX_SESSIONS) {
-		dev_err(core->dev,
-			"%s: Wrong session id %d max allowed = %d\n",
-			__func__, session->id,
-			WCD_CPE_LSM_MAX_SESSIONS);
-		return -EINVAL;
-	}
-
-	cmi_deregister(session->cmi_reg_handle);
-	mutex_destroy(&session->lsm_lock);
-	lsm_sessions[session->id] = NULL;
-	kfree(session);
-
-	if (!wcd_cpe_lsm_session_active()) {
-		cmi_deregister(core->cmi_afe_handle);
-		core->cmi_afe_handle = NULL;
-		wcd_cpe_deinitialize_afe_port_data();
-	}
-
-	ret = wcd_cpe_vote(core, false);
-	if (ret)
-		dev_dbg(core->dev,
-			"%s: Failed to un-vote cpe, err = %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int wcd_cpe_lab_ch_setup(void *core_handle,
-		struct cpe_lsm_session *session,
-		enum wcd_cpe_event event)
-{
-	struct wcd_cpe_core *core = core_handle;
-	struct snd_soc_codec *codec;
-	int rc = 0;
-	u8 cpe_intr_bits;
-
-	if (!core || !core->codec) {
-		pr_err("%s: Invalid handle to %s\n",
-			__func__,
-			(!core) ? "core" : "codec");
-		rc = EINVAL;
-		goto done;
-	}
-
-	if (!core->cpe_cdc_cb ||
-	    !core->cpe_cdc_cb->cdc_ext_clk ||
-	    !core->cpe_cdc_cb->lab_cdc_ch_ctl) {
-		dev_err(core->dev,
-			"%s: Invalid codec callbacks\n",
-			__func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	codec = core->codec;
-	dev_dbg(core->dev,
-		"%s: event = 0x%x\n",
-		__func__, event);
-
-	switch (event) {
-	case WCD_CPE_PRE_ENABLE:
-		rc = core->cpe_cdc_cb->cdc_ext_clk(codec, true, false);
-		if (rc) {
-			dev_err(core->dev,
-				"%s: failed to enable cdc clk, err = %d\n",
-				__func__, rc);
-			goto done;
-		}
-
-		rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec,
-						      true);
-		if (rc) {
-			dev_err(core->dev,
-				"%s: failed to enable cdc port, err = %d\n",
-				__func__, rc);
-			rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false);
-			goto done;
-		}
-
-		break;
-
-	case WCD_CPE_POST_ENABLE:
-		rc = cpe_svc_toggle_lab(core->cpe_handle, true);
-		if (rc)
-			dev_err(core->dev,
-			"%s: Failed to enable lab\n", __func__);
-		break;
-
-	case WCD_CPE_PRE_DISABLE:
-		/*
-		 * Mask the non-fatal interrupts in CPE as they will
-		 * be generated during lab teardown and may flood.
-		 */
-		cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF);
-		if (CPE_ERR_IRQ_CB(core))
-			core->cpe_cdc_cb->cpe_err_irq_control(
-						core->codec,
-						CPE_ERR_IRQ_MASK,
-						&cpe_intr_bits);
-
-		rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec,
-						      false);
-		if (rc)
-			dev_err(core->dev,
-				"%s: failed to disable cdc port, err = %d\n",
-				__func__, rc);
-		break;
-
-	case WCD_CPE_POST_DISABLE:
-		rc = wcd_cpe_lsm_eob(core, session);
-		if (rc)
-			dev_err(core->dev,
-				"%s: eob send failed, err = %d\n",
-				__func__, rc);
-
-		/* Continue teardown even if eob failed */
-		rc = cpe_svc_toggle_lab(core->cpe_handle, false);
-		if (rc)
-			dev_err(core->dev,
-			"%s: Failed to disable lab\n", __func__);
-
-		/* Continue with disabling even if toggle lab fails */
-		rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false);
-		if (rc)
-			dev_err(core->dev,
-				"%s: failed to disable cdc clk, err = %d\n",
-				__func__, rc);
-
-		/* Unmask non-fatal CPE interrupts */
-		cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF);
-		if (CPE_ERR_IRQ_CB(core))
-			core->cpe_cdc_cb->cpe_err_irq_control(
-						core->codec,
-						CPE_ERR_IRQ_UNMASK,
-						&cpe_intr_bits);
-		break;
-
-	default:
-		dev_err(core->dev,
-			"%s: Invalid event 0x%x\n",
-			__func__, event);
-		rc = -EINVAL;
-		break;
-	}
-
-done:
-	return rc;
-}
-
-static int wcd_cpe_lsm_set_fmt_cfg(void *core_handle,
-			struct cpe_lsm_session *session)
-{
-	int ret;
-	struct cpe_lsm_output_format_cfg out_fmt_cfg;
-	struct wcd_cpe_core *core = core_handle;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session, __func__);
-	if (ret)
-		goto done;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-
-	memset(&out_fmt_cfg, 0, sizeof(out_fmt_cfg));
-	if (fill_lsm_cmd_header_v0_inband(&out_fmt_cfg.hdr,
-			session->id, OUT_FMT_CFG_CMD_PAYLOAD_SIZE,
-			CPE_LSM_SESSION_CMD_TX_BUFF_OUTPUT_CONFIG)) {
-		ret = -EINVAL;
-		goto err_ret;
-	}
-
-	out_fmt_cfg.format = session->out_fmt_cfg.format;
-	out_fmt_cfg.packing = session->out_fmt_cfg.pack_mode;
-	out_fmt_cfg.data_path_events = session->out_fmt_cfg.data_path_events;
-
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &out_fmt_cfg);
-	if (ret)
-		dev_err(core->dev,
-			"%s: lsm_set_output_format_cfg failed, err = %d\n",
-			__func__, ret);
-
-err_ret:
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-done:
-	return ret;
-}
-
-static void wcd_cpe_snd_model_offset(void *core_handle,
-		struct cpe_lsm_session *session, size_t *offset)
-{
-	*offset = sizeof(struct cpe_param_data);
-}
-
-static int wcd_cpe_lsm_set_media_fmt_params(void *core_handle,
-					  struct cpe_lsm_session *session,
-					  struct lsm_hw_params *param)
-{
-	struct cpe_lsm_media_fmt_param media_fmt;
-	struct cmi_hdr *msg_hdr = &media_fmt.hdr;
-	struct wcd_cpe_core *core = core_handle;
-	struct cpe_param_data *param_d = &media_fmt.param;
-	struct cpe_lsm_ids ids;
-	int ret;
-
-	memset(&media_fmt, 0, sizeof(media_fmt));
-	if (fill_lsm_cmd_header_v0_inband(msg_hdr,
-				session->id,
-				CPE_MEDIA_FMT_PLD_SIZE,
-				CPE_LSM_SESSION_CMD_SET_PARAMS_V2)) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memset(&ids, 0, sizeof(ids));
-	ids.module_id = CPE_LSM_MODULE_FRAMEWORK;
-	ids.param_id = CPE_LSM_PARAM_ID_MEDIA_FMT;
-
-	wcd_cpe_set_param_data(param_d, &ids, CPE_MEDIA_FMT_PARAM_SIZE,
-			       CPE_LSM_SESSION_CMD_SET_PARAMS_V2);
-
-	media_fmt.minor_version = 1;
-	media_fmt.sample_rate = param->sample_rate;
-	media_fmt.num_channels = param->num_chs;
-	media_fmt.bit_width = param->bit_width;
-
-	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
-	ret = wcd_cpe_cmi_send_lsm_msg(core, session, &media_fmt);
-	if (ret)
-		dev_err(core->dev,
-			"%s: Set_param(media_format) failed, err=%d\n",
-			__func__, ret);
-	WCD_CPE_REL_LOCK(&session->lsm_lock, "lsm");
-done:
-	return ret;
-}
-
-static int wcd_cpe_lsm_set_port(void *core_handle,
-				struct cpe_lsm_session *session, void *data)
-{
-	u32 port_id;
-	int ret;
-	struct cpe_lsm_ids ids;
-	struct wcd_cpe_core *core = core_handle;
-
-	ret = wcd_cpe_is_valid_lsm_session(core, session, __func__);
-	if (ret)
-		goto done;
-
-	if (!data) {
-		dev_err(core->dev, "%s: data is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	port_id = *(u32 *)data;
-	dev_dbg(core->dev, "%s: port_id: %d\n", __func__, port_id);
-
-	memset(&ids, 0, sizeof(ids));
-	ids.module_id = LSM_MODULE_ID_FRAMEWORK;
-	ids.param_id = LSM_PARAM_ID_CONNECT_TO_PORT;
-
-	ret = wcd_cpe_send_param_connectport(core, session, NULL,
-					     &ids, port_id);
-	if (ret)
-		dev_err(core->dev,
-			"%s: send_param_connectport failed, err %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-/*
- * wcd_cpe_get_lsm_ops: register lsm driver to codec
- * @lsm_ops: structure with lsm callbacks
- * @codec: codec to which this lsm driver is registered to
- */
-int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops)
-{
-	lsm_ops->lsm_alloc_session = wcd_cpe_alloc_lsm_session;
-	lsm_ops->lsm_dealloc_session = wcd_cpe_dealloc_lsm_session;
-	lsm_ops->lsm_open_tx = wcd_cpe_cmd_lsm_open_tx;
-	lsm_ops->lsm_close_tx = wcd_cpe_cmd_lsm_close_tx;
-	lsm_ops->lsm_shmem_alloc = wcd_cpe_cmd_lsm_shmem_alloc;
-	lsm_ops->lsm_shmem_dealloc = wcd_cpe_cmd_lsm_shmem_dealloc;
-	lsm_ops->lsm_register_snd_model = wcd_cpe_lsm_reg_snd_model;
-	lsm_ops->lsm_deregister_snd_model = wcd_cpe_lsm_dereg_snd_model;
-	lsm_ops->lsm_get_afe_out_port_id = wcd_cpe_lsm_get_afe_out_port_id;
-	lsm_ops->lsm_start = wcd_cpe_cmd_lsm_start;
-	lsm_ops->lsm_stop = wcd_cpe_cmd_lsm_stop;
-	lsm_ops->lsm_lab_control = wcd_cpe_lsm_lab_control;
-	lsm_ops->lab_ch_setup = wcd_cpe_lab_ch_setup;
-	lsm_ops->lsm_set_data = wcd_cpe_lsm_set_data;
-	lsm_ops->lsm_set_fmt_cfg = wcd_cpe_lsm_set_fmt_cfg;
-	lsm_ops->lsm_set_one_param = wcd_cpe_set_one_param;
-	lsm_ops->lsm_get_snd_model_offset = wcd_cpe_snd_model_offset;
-	lsm_ops->lsm_set_media_fmt_params = wcd_cpe_lsm_set_media_fmt_params;
-	lsm_ops->lsm_set_port = wcd_cpe_lsm_set_port;
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd_cpe_get_lsm_ops);
-
-static int fill_afe_cmd_header(struct cmi_hdr *hdr, u8 port_id,
-				u16 opcode, u8 pld_size,
-				bool obm_flag)
-{
-	CMI_HDR_SET_SESSION(hdr, port_id);
-	CMI_HDR_SET_SERVICE(hdr, CMI_CPE_AFE_SERVICE_ID);
-
-	CMI_HDR_SET_PAYLOAD_SIZE(hdr, pld_size);
-
-	hdr->opcode = opcode;
-
-	if (obm_flag)
-		CMI_HDR_SET_OBM(hdr, CMI_OBM_FLAG_OUT_BAND);
-	else
-		CMI_HDR_SET_OBM(hdr, CMI_OBM_FLAG_IN_BAND);
-
-	return 0;
-}
-
-/*
- * wcd_cpe_cmi_send_afe_msg: send message to AFE service
- * @core: wcd cpe core handle
- * @port_cfg: configuration data for the afe port
- *	      for which this message is to be sent
- * @message: actual message with header and payload
- *
- * Port specific lock needs to be acquired before this
- * function can be invoked
- */
-static int wcd_cpe_cmi_send_afe_msg(
-	struct wcd_cpe_core *core,
-	struct wcd_cmi_afe_port_data *port_d,
-	void *message)
-{
-	int ret = 0;
-	struct cmi_hdr *hdr = message;
-
-	pr_debug("%s: sending message with opcode 0x%x\n",
-		__func__, hdr->opcode);
-
-	if (unlikely(!wcd_cpe_is_online_state(core))) {
-		dev_err(core->dev, "%s: CPE offline\n", __func__);
-		return 0;
-	}
-
-	if (CMI_HDR_GET_OBM_FLAG(hdr))
-		wcd_cpe_bus_vote_max_bw(core, true);
-
-	ret = cmi_send_msg(message);
-	if (ret) {
-		pr_err("%s: cmd 0x%x send failed, err = %d\n",
-			__func__, hdr->opcode, ret);
-		goto rel_bus_vote;
-	}
-
-	ret = wait_for_completion_timeout(&port_d->afe_cmd_complete,
-					  CMI_CMD_TIMEOUT);
-	if (ret > 0) {
-		pr_debug("%s: command 0x%x, received response 0x%x\n",
-			 __func__, hdr->opcode, port_d->cmd_result);
-		if (port_d->cmd_result == CMI_SHMEM_ALLOC_FAILED)
-			port_d->cmd_result = CPE_ENOMEMORY;
-		if (port_d->cmd_result > 0)
-			pr_err("%s: CPE returned error[%s]\n",
-				__func__, cpe_err_get_err_str(
-				port_d->cmd_result));
-		ret = cpe_err_get_lnx_err_code(port_d->cmd_result);
-		goto rel_bus_vote;
-	} else {
-		pr_err("%s: command 0x%x send timed out\n",
-			__func__, hdr->opcode);
-		ret = -ETIMEDOUT;
-		goto rel_bus_vote;
-	}
-
-rel_bus_vote:
-	reinit_completion(&port_d->afe_cmd_complete);
-
-	if (CMI_HDR_GET_OBM_FLAG(hdr))
-		wcd_cpe_bus_vote_max_bw(core, false);
-
-	return ret;
-}
-
-
-
-/*
- * wcd_cpe_afe_shmem_alloc: allocate the cpe memory for afe service
- * @core: handle to cpe core
- * @port_cfg: configuration data for the port which needs
- *	      memory to be allocated on CPE
- * @size: size of the memory to be allocated
- */
-static int wcd_cpe_afe_shmem_alloc(
-	struct wcd_cpe_core *core,
-	struct wcd_cmi_afe_port_data *port_d,
-	u32 size)
-{
-	struct cpe_cmd_shmem_alloc cmd_shmem_alloc;
-	int ret = 0;
-
-	pr_debug("%s: enter: size = %d\n", __func__, size);
-
-	memset(&cmd_shmem_alloc, 0, sizeof(cmd_shmem_alloc));
-	if (fill_afe_cmd_header(&cmd_shmem_alloc.hdr, port_d->port_id,
-			    CPE_AFE_PORT_CMD_SHARED_MEM_ALLOC,
-			    SHMEM_ALLOC_CMD_PLD_SIZE, false)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_shmem_alloc.size = size;
-
-	ret = wcd_cpe_cmi_send_afe_msg(core, port_d, &cmd_shmem_alloc);
-	if (ret) {
-		pr_err("%s: afe_shmem_alloc fail,ret = %d\n",
-			__func__, ret);
-		goto end_ret;
-	}
-
-	pr_debug("%s: completed %s, mem_handle = 0x%x\n",
-		__func__, "CPE_AFE_CMD_SHARED_MEM_ALLOC",
-		port_d->mem_handle);
-
-end_ret:
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_shmem_dealloc: deallocate the cpe memory for
- *			      afe service
- * @core: handle to cpe core
- * @port_d: configuration data for the port which needs
- *	      memory to be deallocated on CPE
- * The memory handle to be de-allocated is saved in the
- * port configuration data
- */
-static int wcd_cpe_afe_shmem_dealloc(
-	struct wcd_cpe_core *core,
-	struct wcd_cmi_afe_port_data *port_d)
-{
-	struct cpe_cmd_shmem_dealloc cmd_dealloc;
-	int ret = 0;
-
-	pr_debug("%s: enter, port_id = %d\n",
-		 __func__, port_d->port_id);
-
-	memset(&cmd_dealloc, 0, sizeof(cmd_dealloc));
-	if (fill_afe_cmd_header(&cmd_dealloc.hdr, port_d->port_id,
-				CPE_AFE_PORT_CMD_SHARED_MEM_DEALLOC,
-				SHMEM_DEALLOC_CMD_PLD_SIZE, false)) {
-		ret = -EINVAL;
-		goto end_ret;
-	}
-
-	cmd_dealloc.addr = port_d->mem_handle;
-	ret = wcd_cpe_cmi_send_afe_msg(core, port_d, &cmd_dealloc);
-	if (ret) {
-		pr_err("failed to send shmem_dealloc cmd\n");
-		goto end_ret;
-	}
-	memset(&port_d->mem_handle, 0,
-	       sizeof(port_d->mem_handle));
-
-end_ret:
-	return ret;
-}
-
-/*
- * wcd_cpe_send_afe_cal: send the acdb calibration to AFE port
- * @core: handle to cpe core
- * @port_d: configuration data for the port for which the
- *	      calibration needs to be appplied
- */
-static int wcd_cpe_send_afe_cal(void *core_handle,
-		struct wcd_cmi_afe_port_data *port_d)
-{
-
-	struct cal_block_data *afe_cal = NULL;
-	struct wcd_cpe_core *core = core_handle;
-	struct cmi_obm_msg obm_msg;
-	void *inb_msg = NULL;
-	void *msg;
-	int rc = 0;
-	bool is_obm_msg;
-
-	if (core->cal_data[WCD_CPE_LSM_CAL_AFE] == NULL) {
-		pr_err("%s: LSM cal not allocated!\n",
-			__func__);
-		rc = -EINVAL;
-		goto rel_cal_mutex;
-	}
-
-	mutex_lock(&core->cal_data[WCD_CPE_LSM_CAL_AFE]->lock);
-	afe_cal = cal_utils_get_only_cal_block(
-			core->cal_data[WCD_CPE_LSM_CAL_AFE]);
-	if (!afe_cal) {
-		pr_err("%s: failed to get afe cal block\n",
-			__func__);
-		rc = -EINVAL;
-		goto rel_cal_mutex;
-	}
-
-	if (afe_cal->cal_data.size == 0) {
-		dev_dbg(core->dev, "%s: No AFE cal to send\n",
-			__func__);
-		rc = 0;
-		goto rel_cal_mutex;
-	}
-
-	is_obm_msg = (afe_cal->cal_data.size >
-		      CMI_INBAND_MESSAGE_SIZE) ? true : false;
-
-	if (is_obm_msg) {
-		struct cmi_hdr *hdr = &(obm_msg.hdr);
-		struct cmi_obm *pld = &(obm_msg.pld);
-
-		rc = wcd_cpe_afe_shmem_alloc(core, port_d,
-					afe_cal->cal_data.size);
-		if (rc) {
-			dev_err(core->dev,
-				"%s: AFE shmem alloc fail %d\n",
-				__func__, rc);
-			goto rel_cal_mutex;
-		}
-
-		rc = fill_afe_cmd_header(hdr, port_d->port_id,
-					 CPE_AFE_CMD_SET_PARAM,
-					 CPE_AFE_PARAM_PAYLOAD_SIZE,
-					 true);
-		if (rc) {
-			dev_err(core->dev,
-				"%s: invalid params for header, err = %d\n",
-				__func__, rc);
-			wcd_cpe_afe_shmem_dealloc(core, port_d);
-			goto rel_cal_mutex;
-		}
-
-		pld->version = 0;
-		pld->size = afe_cal->cal_data.size;
-		pld->data_ptr.kvaddr = afe_cal->cal_data.kvaddr;
-		pld->mem_handle = port_d->mem_handle;
-		msg = &obm_msg;
-
-	} else {
-		u8 *msg_pld;
-		struct cmi_hdr *hdr;
-
-		inb_msg = kzalloc(sizeof(struct cmi_hdr) +
-					afe_cal->cal_data.size,
-				  GFP_KERNEL);
-		if (!inb_msg) {
-			dev_err(core->dev,
-				"%s: no memory for afe cal inband\n",
-				__func__);
-			rc = -ENOMEM;
-			goto rel_cal_mutex;
-		}
-
-		hdr = (struct cmi_hdr *) inb_msg;
-
-		rc = fill_afe_cmd_header(hdr, port_d->port_id,
-					 CPE_AFE_CMD_SET_PARAM,
-					 CPE_AFE_PARAM_PAYLOAD_SIZE,
-					 false);
-		if (rc) {
-			dev_err(core->dev,
-				"%s: invalid params for header, err = %d\n",
-				__func__, rc);
-			kfree(inb_msg);
-			inb_msg = NULL;
-			goto rel_cal_mutex;
-		}
-
-		msg_pld = ((u8 *) inb_msg) + sizeof(struct cmi_hdr);
-		memcpy(msg_pld, afe_cal->cal_data.kvaddr,
-		       afe_cal->cal_data.size);
-
-		msg = inb_msg;
-	}
-
-	rc = wcd_cpe_cmi_send_afe_msg(core, port_d, msg);
-	if (rc)
-		pr_err("%s: afe cal for listen failed, rc = %d\n",
-			__func__, rc);
-
-	if (is_obm_msg) {
-		wcd_cpe_afe_shmem_dealloc(core, port_d);
-		port_d->mem_handle = 0;
-	} else {
-		kfree(inb_msg);
-		inb_msg = NULL;
-	}
-
-rel_cal_mutex:
-	mutex_unlock(&core->cal_data[WCD_CPE_LSM_CAL_AFE]->lock);
-	return rc;
-}
-
-/*
- * wcd_cpe_is_valid_port: check validity of afe port id
- * @core: handle to core to check for validity
- * @afe_cfg: client provided afe configuration
- * @func: function name invoking this validity check,
- *	  used for logging purpose only.
- */
-static int wcd_cpe_is_valid_port(struct wcd_cpe_core *core,
-		struct wcd_cpe_afe_port_cfg *afe_cfg,
-		const char *func)
-{
-	if (unlikely(IS_ERR_OR_NULL(core))) {
-		pr_err("%s: Invalid core handle\n", func);
-		return -EINVAL;
-	}
-
-	if (afe_cfg->port_id > WCD_CPE_AFE_MAX_PORTS) {
-		dev_err(core->dev,
-			"%s: invalid afe port (%u)\n",
-			func, afe_cfg->port_id);
-		return -EINVAL;
-	}
-
-	dev_dbg(core->dev,
-		"%s: port_id = %u\n",
-		func, afe_cfg->port_id);
-
-	return 0;
-}
-
-static int wcd_cpe_afe_svc_cmd_mode(void *core_handle,
-				    u8 mode)
-{
-	struct cpe_afe_svc_cmd_mode afe_mode;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret;
-
-	afe_port_d = &afe_ports[0];
-	/*
-	 * AFE SVC mode command is for the service and not port
-	 * specific, hence use AFE port as 0 so the command will
-	 * be applied to all AFE ports on CPE.
-	 */
-	afe_port_d->port_id = 0;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-	memset(&afe_mode, 0, sizeof(afe_mode));
-	if (fill_afe_cmd_header(&afe_mode.hdr, afe_port_d->port_id,
-				CPE_AFE_SVC_CMD_LAB_MODE,
-				CPE_AFE_CMD_MODE_PAYLOAD_SIZE,
-				false)) {
-		ret = -EINVAL;
-		goto err_ret;
-	}
-
-	afe_mode.mode = mode;
-
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &afe_mode);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_svc_mode cmd failed, err = %d\n",
-			__func__, ret);
-
-err_ret:
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-}
-
-static int wcd_cpe_afe_cmd_port_cfg(void *core_handle,
-		struct wcd_cpe_afe_port_cfg *afe_cfg)
-{
-	struct cpe_afe_cmd_port_cfg port_cfg_cmd;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret;
-
-	ret = wcd_cpe_is_valid_port(core, afe_cfg, __func__);
-	if (ret)
-		goto done;
-
-	afe_port_d = &afe_ports[afe_cfg->port_id];
-	afe_port_d->port_id = afe_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-	memset(&port_cfg_cmd, 0, sizeof(port_cfg_cmd));
-	if (fill_afe_cmd_header(&port_cfg_cmd.hdr,
-			afe_cfg->port_id,
-			CPE_AFE_PORT_CMD_GENERIC_CONFIG,
-			CPE_AFE_CMD_PORT_CFG_PAYLOAD_SIZE,
-			false)) {
-		ret = -EINVAL;
-		goto err_ret;
-	}
-
-	port_cfg_cmd.bit_width = afe_cfg->bit_width;
-	port_cfg_cmd.num_channels = afe_cfg->num_channels;
-	port_cfg_cmd.sample_rate = afe_cfg->sample_rate;
-
-	if (afe_port_d->port_id == CPE_AFE_PORT_3_TX)
-		port_cfg_cmd.buffer_size = WCD_CPE_EC_PP_BUF_SIZE;
-	else
-		port_cfg_cmd.buffer_size = AFE_OUT_BUF_SIZE(afe_cfg->bit_width,
-							afe_cfg->sample_rate);
-
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &port_cfg_cmd);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_port_config failed, err = %d\n",
-			__func__, ret);
-
-err_ret:
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-done:
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_set_params: set the parameters for afe port
- * @afe_cfg: configuration data for the port for which the
- *	      parameters are to be set
- */
-static int wcd_cpe_afe_set_params(void *core_handle,
-		struct wcd_cpe_afe_port_cfg *afe_cfg, bool afe_mad_ctl)
-{
-	struct cpe_afe_params afe_params;
-	struct cpe_afe_hw_mad_ctrl *hw_mad_ctrl = &afe_params.hw_mad_ctrl;
-	struct cpe_afe_port_cfg *port_cfg = &afe_params.port_cfg;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret = 0, pld_size = 0;
-
-	ret = wcd_cpe_is_valid_port(core, afe_cfg, __func__);
-	if (ret)
-		return ret;
-
-	afe_port_d = &afe_ports[afe_cfg->port_id];
-	afe_port_d->port_id = afe_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-
-	ret = wcd_cpe_send_afe_cal(core, afe_port_d);
-	if (ret) {
-		dev_err(core->dev,
-			"%s: afe acdb cal send failed, err = %d\n",
-			__func__, ret);
-		goto err_ret;
-	}
-
-	pld_size = CPE_AFE_PARAM_PAYLOAD_SIZE;
-	memset(&afe_params, 0, sizeof(afe_params));
-
-	if (fill_afe_cmd_header(&afe_params.hdr,
-				afe_cfg->port_id,
-				CPE_AFE_CMD_SET_PARAM,
-				(u8) pld_size, false)) {
-		ret = -EINVAL;
-		goto err_ret;
-	}
-
-	hw_mad_ctrl->param.module_id = CPE_AFE_MODULE_HW_MAD;
-	hw_mad_ctrl->param.param_id = CPE_AFE_PARAM_ID_HW_MAD_CTL;
-	hw_mad_ctrl->param.p_size.sr.param_size = PARAM_SIZE_AFE_HW_MAD_CTRL;
-	hw_mad_ctrl->param.p_size.sr.reserved = 0;
-	hw_mad_ctrl->minor_version = 1;
-	hw_mad_ctrl->mad_type = MAD_TYPE_AUDIO;
-	hw_mad_ctrl->mad_enable = afe_mad_ctl;
-
-	port_cfg->param.module_id = CPE_AFE_MODULE_AUDIO_DEV_INTERFACE;
-	port_cfg->param.param_id = CPE_AFE_PARAM_ID_GENERIC_PORT_CONFIG;
-	port_cfg->param.p_size.sr.param_size = PARAM_SIZE_AFE_PORT_CFG;
-	port_cfg->param.p_size.sr.reserved = 0;
-	port_cfg->minor_version = 1;
-	port_cfg->bit_width = afe_cfg->bit_width;
-	port_cfg->num_channels = afe_cfg->num_channels;
-	port_cfg->sample_rate = afe_cfg->sample_rate;
-
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &afe_params);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_port_config failed, err = %d\n",
-			__func__, ret);
-err_ret:
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_port_start: send the start command to afe service
- * @core_handle: handle to the cpe core
- * @port_cfg: configuration data for the afe port which needs
- *	      to be started.
- */
-static int wcd_cpe_afe_port_start(void *core_handle,
-			struct wcd_cpe_afe_port_cfg *port_cfg)
-{
-
-	struct cmi_hdr hdr;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_port(core, port_cfg, __func__);
-	if (ret)
-		return ret;
-
-	afe_port_d = &afe_ports[port_cfg->port_id];
-	afe_port_d->port_id = port_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-
-	memset(&hdr, 0, sizeof(struct cmi_hdr));
-	fill_afe_cmd_header(&hdr, port_cfg->port_id,
-			    CPE_AFE_PORT_CMD_START,
-			    0, false);
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &hdr);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_port_start cmd failed, err = %d\n",
-			__func__, ret);
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_port_stop: send stop command to afe service
- * @core_handle: handle to the cpe core
- * @port_cfg: configuration data for the afe port which needs
- *	      to be stopped.
- */
-static int wcd_cpe_afe_port_stop(void *core_handle,
-	struct wcd_cpe_afe_port_cfg *port_cfg)
-{
-	struct cmi_hdr hdr;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_port(core, port_cfg, __func__);
-	if (ret)
-		return ret;
-
-	afe_port_d = &afe_ports[port_cfg->port_id];
-	afe_port_d->port_id = port_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-
-	memset(&hdr, 0, sizeof(hdr));
-	fill_afe_cmd_header(&hdr, port_cfg->port_id,
-			    CPE_AFE_PORT_CMD_STOP,
-			    0, false);
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &hdr);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_stop cmd failed, err = %d\n",
-			__func__, ret);
-
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_port_suspend: send suspend command to afe service
- * @core_handle: handle to the cpe core
- * @port_cfg: configuration data for the afe port which needs
- *	      to be suspended.
- */
-static int wcd_cpe_afe_port_suspend(void *core_handle,
-		struct wcd_cpe_afe_port_cfg *port_cfg)
-{
-	struct cmi_hdr hdr;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_port(core, port_cfg, __func__);
-	if (ret)
-		return ret;
-
-	afe_port_d = &afe_ports[port_cfg->port_id];
-	afe_port_d->port_id = port_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-
-	memset(&hdr, 0, sizeof(struct cmi_hdr));
-	fill_afe_cmd_header(&hdr, port_cfg->port_id,
-			    CPE_AFE_PORT_CMD_SUSPEND,
-			    0, false);
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &hdr);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_suspend cmd failed, err = %d\n",
-			__func__, ret);
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-}
-
-/*
- * wcd_cpe_afe_port_resume: send the resume command to afe service
- * @core_handle: handle to the cpe core
- * @port_cfg: configuration data for the afe port which needs
- *	      to be resumed.
- */
-static int wcd_cpe_afe_port_resume(void *core_handle,
-		struct wcd_cpe_afe_port_cfg *port_cfg)
-{
-	struct cmi_hdr hdr;
-	struct wcd_cpe_core *core = core_handle;
-	struct wcd_cmi_afe_port_data *afe_port_d;
-	int ret = 0;
-
-	ret = wcd_cpe_is_valid_port(core, port_cfg, __func__);
-	if (ret)
-		return ret;
-
-	afe_port_d = &afe_ports[port_cfg->port_id];
-	afe_port_d->port_id = port_cfg->port_id;
-
-	WCD_CPE_GRAB_LOCK(&afe_port_d->afe_lock, "afe");
-
-	memset(&hdr, 0, sizeof(hdr));
-	fill_afe_cmd_header(&hdr, port_cfg->port_id,
-			    CPE_AFE_PORT_CMD_RESUME,
-			    0, false);
-	ret = wcd_cpe_cmi_send_afe_msg(core, afe_port_d, &hdr);
-	if (ret)
-		dev_err(core->dev,
-			"%s: afe_resume cmd failed, err = %d\n",
-			__func__, ret);
-	WCD_CPE_REL_LOCK(&afe_port_d->afe_lock, "afe");
-	return ret;
-
-}
-
-/*
- * wcd_cpe_register_afe_driver: register lsm driver to codec
- * @cpe_ops: structure with lsm callbacks
- * @codec: codec to which this lsm driver is registered to
- */
-int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops)
-{
-	afe_ops->afe_set_params = wcd_cpe_afe_set_params;
-	afe_ops->afe_port_start = wcd_cpe_afe_port_start;
-	afe_ops->afe_port_stop = wcd_cpe_afe_port_stop;
-	afe_ops->afe_port_suspend = wcd_cpe_afe_port_suspend;
-	afe_ops->afe_port_resume = wcd_cpe_afe_port_resume;
-	afe_ops->afe_port_cmd_cfg = wcd_cpe_afe_cmd_port_cfg;
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd_cpe_get_afe_ops);
-
-MODULE_DESCRIPTION("WCD CPE Core");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd_cpe_core.h b/sound/soc/codecs/wcd_cpe_core.h
deleted file mode 100644
index 3d672b8..0000000
--- a/sound/soc/codecs/wcd_cpe_core.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WCD_CPE_CORE_H
-#define WCD_CPE_CORE_H
-
-#include <soc/qcom/ramdump.h>
-#include <linux/dma-mapping.h>
-#include "wcd_cpe_services.h"
-
-#define WCD_CPE_LAB_MAX_LATENCY 250
-#define WCD_CPE_MAD_SLIM_CHANNEL 140
-
-/* Indicates CPE block is ready for image re-download */
-#define WCD_CPE_BLK_READY  (1 << 0)
-/* Indicates the underlying bus is ready */
-#define WCD_CPE_BUS_READY (1 << 1)
-
-/*
- * only when the underlying bus and CPE block both are ready,
- * the state will be ready to download
- */
-#define WCD_CPE_READY_TO_DLOAD	\
-	(WCD_CPE_BLK_READY | WCD_CPE_BUS_READY)
-
-#define WCD_CPE_LOAD_IMEM (1 << 0)
-#define WCD_CPE_LOAD_DATA (1 << 1)
-#define WCD_CPE_LOAD_ALL \
-	(WCD_CPE_LOAD_IMEM | WCD_CPE_LOAD_DATA)
-
-#define WCD_CPE_IMAGE_FNAME_MAX 64
-
-#define WCD_CPE_AFE_OUT_PORT_2 2
-#define WCD_CPE_AFE_OUT_PORT_4 4
-
-enum {
-	WCD_CPE_LSM_CAL_AFE = 0,
-	WCD_CPE_LSM_CAL_LSM,
-	WCD_CPE_LSM_CAL_TOPOLOGY_ID,
-	WCD_CPE_LSM_CAL_MAX,
-};
-
-enum cpe_err_irq_cntl_type {
-	CPE_ERR_IRQ_MASK = 0,
-	CPE_ERR_IRQ_UNMASK,
-	CPE_ERR_IRQ_CLEAR,
-	CPE_ERR_IRQ_STATUS,
-};
-
-struct wcd_cpe_cdc_cb {
-	/* codec provided callback to enable RCO */
-	int (*cdc_clk_en)(struct snd_soc_codec *, bool);
-
-	/* callback for FLL setup for codec */
-	int (*cpe_clk_en)(struct snd_soc_codec *, bool);
-	int (*cdc_ext_clk)(struct snd_soc_codec *codec, int enable, bool dapm);
-	int (*lab_cdc_ch_ctl)(struct snd_soc_codec *codec, u8 event);
-	int (*get_afe_out_port_id)(struct snd_soc_codec *codec, u16 *port_id);
-	int (*bus_vote_bw)(struct snd_soc_codec *codec,
-			   bool vote);
-
-	/* Callback to control the cpe error interrupt mask/status/clear */
-	int (*cpe_err_irq_control)(struct snd_soc_codec *codec,
-				    enum cpe_err_irq_cntl_type cntl_type,
-				    u8 *status);
-};
-
-enum wcd_cpe_ssr_state_event {
-	/* Indicates CPE is initialized */
-	WCD_CPE_INITIALIZED = 0,
-	/* Indicates that IMEM is downloaded to CPE */
-	WCD_CPE_IMEM_DOWNLOADED,
-	/* Indicates CPE is enabled */
-	WCD_CPE_ENABLED,
-	/* Indicates that CPE is currently active */
-	WCD_CPE_ACTIVE,
-	/* Event from underlying bus notifying bus is down */
-	WCD_CPE_BUS_DOWN_EVENT,
-	/* Event from CPE block, notifying CPE is down */
-	WCD_CPE_SSR_EVENT,
-	/* Event from underlying bus notifying bus is up */
-	WCD_CPE_BUS_UP_EVENT,
-};
-
-struct wcd_cpe_ssr_entry {
-	int offline;
-	u32 offline_change;
-	wait_queue_head_t offline_poll_wait;
-	struct snd_info_entry *entry;
-};
-
-struct wcd_cpe_irq_info {
-	int cpe_engine_irq;
-	int cpe_err_irq;
-	u8 cpe_fatal_irqs;
-};
-
-struct wcd_cpe_hw_info {
-	u32 dram_offset;
-	size_t dram_size;
-	u32 iram_offset;
-	size_t iram_size;
-};
-
-struct wcd_cpe_core {
-	/* handle to cpe services */
-	void *cpe_handle;
-
-	/* registration handle to cpe services */
-	void *cpe_reg_handle;
-
-	/* cmi registration handle for afe service */
-	void *cmi_afe_handle;
-
-	/* handle to codec */
-	struct snd_soc_codec *codec;
-
-	/* codec device */
-	struct device *dev;
-
-	/* firmware image file name */
-	char fname[WCD_CPE_IMAGE_FNAME_MAX];
-
-	/* firmware image file name from sysfs */
-	char dyn_fname[WCD_CPE_IMAGE_FNAME_MAX];
-
-	/* codec information needed by cpe services */
-	struct cpe_svc_codec_info_v1 cdc_info;
-
-	/* work to perform image download */
-	struct work_struct load_fw_work;
-
-	/* flag to indicate mode in which cpe needs to be booted */
-	int cpe_debug_mode;
-
-	/* callbacks for codec specific implementation */
-	const struct wcd_cpe_cdc_cb *cpe_cdc_cb;
-
-	/* work to handle CPE SSR*/
-	struct work_struct ssr_work;
-
-	/* PM handle for suspend mode during SSR */
-	struct pm_qos_request pm_qos_req;
-
-	/* completion event indicating CPE OFFLINE */
-	struct completion offline_compl;
-
-	/* entry into snd card procfs indicating cpe status */
-	struct wcd_cpe_ssr_entry ssr_entry;
-
-	/*
-	 * completion event to signal CPE is
-	 * ready for image re-download
-	 */
-	struct completion ready_compl;
-
-	/* maintains the status for cpe ssr */
-	u8 ready_status;
-
-	/* Indicate SSR type */
-	enum wcd_cpe_ssr_state_event ssr_type;
-
-	/* mutex to protect cpe ssr status variables */
-	struct mutex ssr_lock;
-
-	/* Store the calibration data needed for cpe */
-	struct cal_type_data *cal_data[WCD_CPE_LSM_CAL_MAX];
-
-	/* completion event to signal CPE is online */
-	struct completion online_compl;
-
-	/* reference counter for cpe usage */
-	u8 cpe_users;
-
-	/* Ramdump support */
-	void *cpe_ramdump_dev;
-	struct ramdump_segment cpe_ramdump_seg;
-	dma_addr_t cpe_dump_addr;
-	void *cpe_dump_v_addr;
-
-	/* SFR support */
-	u32 sfr_buf_addr;
-	size_t sfr_buf_size;
-
-	/* IRQ information for CPE interrupts */
-	struct wcd_cpe_irq_info irq_info;
-
-	/* Kobject for sysfs entry */
-	struct kobject cpe_kobj;
-
-	/* Reference count for cpe clk*/
-	int cpe_clk_ref;
-
-	/* codec based hardware info */
-	struct wcd_cpe_hw_info hw_info;
-};
-
-struct wcd_cpe_params {
-	struct snd_soc_codec *codec;
-	struct wcd_cpe_core * (*get_cpe_core)(
-				struct snd_soc_codec *);
-	const struct wcd_cpe_cdc_cb *cdc_cb;
-	int dbg_mode;
-	u16 cdc_major_ver;
-	u16 cdc_minor_ver;
-	u32 cdc_id;
-
-	struct wcd_cpe_irq_info cdc_irq_info;
-
-	struct cpe_svc_init_param *cpe_svc_params;
-};
-
-int wcd_cpe_ssr_event(void *core_handle,
-		      enum wcd_cpe_ssr_state_event event);
-struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
-struct snd_soc_codec *codec, struct wcd_cpe_params *params);
-#endif
diff --git a/sound/soc/codecs/wcd_cpe_services.c b/sound/soc/codecs/wcd_cpe_services.c
deleted file mode 100644
index ad8962b..0000000
--- a/sound/soc/codecs/wcd_cpe_services.c
+++ /dev/null
@@ -1,2725 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/completion.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <sound/cpe_cmi.h>
-#include <sound/soc.h>
-#include <linux/mfd/wcd9335/registers.h>
-#include "wcd_cpe_services.h"
-#include "wcd_cmi_api.h"
-
-#define CPE_MSG_BUFFER_SIZE 132
-#define CPE_NO_SERVICE 0
-
-#define CMI_DRIVER_SUPPORTED_VERSION 0
-#define CMI_API_SUCCESS 0
-#define CMI_MSG_TRANSPORT (0x0002)
-#define CPE_SVC_INACTIVE_STATE_RETRIES_MAX 10
-
-#define TOMTOM_A_SVASS_SPE_DRAM_OFFSET				0x50000
-#define TOMTOM_A_SVASS_SPE_DRAM_SIZE				0x30000
-#define TOMTOM_A_SVASS_SPE_IRAM_OFFSET				0x80000
-#define TOMTOM_A_SVASS_SPE_IRAM_SIZE				0xC000
-#define TOMTOM_A_SVASS_SPE_INBOX_SIZE				12
-#define TOMTOM_A_SVASS_SPE_OUTBOX_SIZE				12
-
-#define MEM_ACCESS_NONE_VAL			0x0
-#define MEM_ACCESS_IRAM_VAL			0x1
-#define MEM_ACCESS_DRAM_VAL			0x2
-#define LISTEN_CTL_SPE_VAL			0x0
-#define LISTEN_CTL_MSM_VAL			0x1
-
-#define WCD9335_CPE_SS_SPE_DRAM_OFFSET		0x48000
-#define WCD9335_CPE_SS_SPE_DRAM_SIZE		0x34000
-#define WCD9335_CPE_SS_SPE_IRAM_OFFSET		0x80000
-#define WCD9335_CPE_SS_SPE_IRAM_SIZE		0x20000
-
-#define WCD9335_CPE_SS_SPE_INBOX_SIZE		16
-#define WCD9335_CPE_SS_SPE_OUTBOX_SIZE		16
-#define WCD9335_CPE_SS_SPE_MEM_BANK_SIZ		16
-
-#define WCD9335_CPE_SS_SPE_INBOX1(N)	(WCD9335_CPE_SS_INBOX1_0 + (N))
-#define WCD9335_CPE_SS_SPE_OUTBOX1(N)	(WCD9335_CPE_SS_OUTBOX1_0 + (N))
-#define WCD9335_CPE_SS_MEM_BANK(N)	(WCD9335_CPE_SS_MEM_BANK_0 + (N))
-
-#define CHUNK_SIZE 16
-
-#define CPE_SVC_GRAB_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock acquire\n",	\
-		 __func__, name);		\
-	mutex_lock(lock);			\
-}
-
-#define CPE_SVC_REL_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock release\n",	\
-		 __func__, name);		\
-	mutex_unlock(lock);			\
-}
-
-static const struct cpe_svc_hw_cfg cpe_svc_tomtom_info = {
-	TOMTOM_A_SVASS_SPE_DRAM_SIZE,
-	TOMTOM_A_SVASS_SPE_DRAM_OFFSET,
-	TOMTOM_A_SVASS_SPE_IRAM_SIZE,
-	TOMTOM_A_SVASS_SPE_IRAM_OFFSET,
-	TOMTOM_A_SVASS_SPE_INBOX_SIZE,
-	TOMTOM_A_SVASS_SPE_OUTBOX_SIZE
-};
-
-static const struct cpe_svc_hw_cfg cpe_svc_wcd9335_info = {
-	WCD9335_CPE_SS_SPE_DRAM_SIZE,
-	WCD9335_CPE_SS_SPE_DRAM_OFFSET,
-	WCD9335_CPE_SS_SPE_IRAM_SIZE,
-	WCD9335_CPE_SS_SPE_IRAM_OFFSET,
-	WCD9335_CPE_SS_SPE_INBOX_SIZE,
-	WCD9335_CPE_SS_SPE_OUTBOX_SIZE
-};
-
-enum cpe_state {
-	CPE_STATE_UNINITIALIZED = 0,
-	CPE_STATE_INITIALIZED,
-	CPE_STATE_IDLE,
-	CPE_STATE_DOWNLOADING,
-	CPE_STATE_BOOTING,
-	CPE_STATE_SENDING_MSG,
-	CPE_STATE_OFFLINE,
-	CPE_STATE_BUFFERING,
-	CPE_STATE_BUFFERING_CANCELLED
-};
-
-enum cpe_substate {
-	CPE_SS_IDLE = 0,
-	CPE_SS_MSG_REQUEST_ACCESS,
-	CPE_SS_MSG_SEND_INBOX,
-	CPE_SS_MSG_SENT,
-	CPE_SS_DL_DOWNLOADING,
-	CPE_SS_DL_COMPLETED,
-	CPE_SS_BOOT,
-	CPE_SS_BOOT_INIT,
-	CPE_SS_ONLINE
-};
-
-enum cpe_command {
-	CPE_CMD_KILL_THREAD = 0,
-	CPE_CMD_BOOT,
-	CPE_CMD_BOOT_INITIALIZE,
-	CPE_CMD_BOOT_COMPLETE,
-	CPE_CMD_SEND_MSG,
-	CPE_CMD_SEND_TRANS_MSG,
-	CPE_CMD_SEND_MSG_COMPLETE,
-	CPE_CMD_PROCESS_IRQ,
-	CPE_CMD_RAMDUMP,
-	CPE_CMD_DL_SEGMENT,
-	CPE_CMD_SHUTDOWN,
-	CPE_CMD_RESET,
-	CPE_CMD_DEINITIALIZE,
-	CPE_CMD_READ,
-	CPE_CMD_ENABLE_LAB,
-	CPE_CMD_DISABLE_LAB,
-	CPE_CMD_SWAP_BUFFER,
-	CPE_LAB_CFG_SB,
-	CPE_CMD_CANCEL_MEMACCESS,
-	CPE_CMD_PROC_INCOMING_MSG,
-	CPE_CMD_FTM_TEST,
-};
-
-enum cpe_process_result {
-	CPE_PROC_SUCCESS = 0,
-	CPE_PROC_FAILED,
-	CPE_PROC_KILLED,
-	CPE_PROC_QUEUED,
-};
-
-struct cpe_command_node {
-	enum cpe_command command;
-	enum cpe_svc_result result;
-	void *data;
-	struct list_head list;
-};
-
-struct cpe_info {
-	struct list_head main_queue;
-	struct completion cmd_complete;
-	struct completion thread_comp;
-	void *thread_handler;
-	bool stop_thread;
-	struct mutex msg_lock;
-	enum cpe_state state;
-	enum cpe_substate substate;
-	struct list_head client_list;
-	enum cpe_process_result (*cpe_process_command)
-			(struct cpe_command_node *command_node);
-	enum cpe_svc_result (*cpe_cmd_validate)
-				(const struct cpe_info *i,
-				 enum cpe_command command);
-	enum cpe_svc_result (*cpe_start_notification)
-			     (struct cpe_info *i);
-	u32 initialized;
-	struct cpe_svc_tgt_abstraction *tgt;
-	void *pending;
-	void *data;
-	void *client_context;
-	u32 codec_id;
-	struct work_struct clk_plan_work;
-	struct completion core_svc_cmd_compl;
-};
-
-struct cpe_tgt_waiti_info {
-	u8 tgt_waiti_size;
-	u8 *tgt_waiti_data;
-};
-
-struct cpe_svc_tgt_abstraction {
-	enum cpe_svc_result (*tgt_boot)(int debug_mode);
-
-	u32 (*tgt_cpar_init_done)(void);
-
-	u32 (*tgt_is_active)(void);
-
-	enum cpe_svc_result (*tgt_reset)(void);
-
-	enum cpe_svc_result (*tgt_stop)(void);
-
-	enum cpe_svc_result (*tgt_read_mailbox)
-				(u8 *buffer, size_t size);
-
-	enum cpe_svc_result (*tgt_write_mailbox)
-				(u8 *buffer, size_t size);
-
-	enum cpe_svc_result (*tgt_read_ram)
-				(struct cpe_info *c,
-				 struct cpe_svc_mem_segment *data);
-
-	enum cpe_svc_result (*tgt_write_ram)
-				(struct cpe_info *c,
-				const struct cpe_svc_mem_segment *data);
-
-	enum cpe_svc_result (*tgt_route_notification)
-				(enum cpe_svc_module module,
-				 enum cpe_svc_route_dest dest);
-
-	enum cpe_svc_result (*tgt_set_debug_mode)(u32 enable);
-	const struct cpe_svc_hw_cfg *(*tgt_get_cpe_info)(void);
-	enum cpe_svc_result (*tgt_deinit)
-				(struct cpe_svc_tgt_abstraction *param);
-	enum cpe_svc_result (*tgt_voice_tx_lab)
-				(bool);
-	u8 *inbox;
-	u8 *outbox;
-	struct cpe_tgt_waiti_info *tgt_waiti_info;
-};
-
-static enum cpe_svc_result cpe_tgt_tomtom_init(
-	struct cpe_svc_codec_info_v1 *codec_info,
-	struct cpe_svc_tgt_abstraction *param);
-
-static enum cpe_svc_result cpe_tgt_wcd9335_init(
-	struct cpe_svc_codec_info_v1 *codec_info,
-	struct cpe_svc_tgt_abstraction *param);
-
-struct cpe_send_msg {
-	u8 *payload;
-	u32 isobm;
-	u32 address;
-	size_t size;
-};
-
-struct cpe_read_handle {
-	void *registration;
-	struct cpe_info t_info;
-	struct list_head buffers;
-	void *config;
-};
-
-struct generic_notification {
-	void (*notification)
-		(const struct cpe_svc_notification *parameter);
-	void (*cmi_notification)
-		(const struct cmi_api_notification *parameter);
-};
-
-struct cpe_notif_node {
-	struct generic_notification notif;
-	u32 mask;
-	u32 service;
-	const struct cpe_info *context;
-	const char *name;
-	u32 disabled;
-	struct list_head list;
-};
-
-struct cpe_priv {
-	struct cpe_info *cpe_default_handle;
-	void (*cpe_irq_control_callback)(u32 enable);
-	void (*cpe_query_freq_plans_cb)
-		(void *cdc_priv,
-		 struct cpe_svc_cfg_clk_plan *clk_freq);
-	void (*cpe_change_freq_plan_cb)(void *cdc_priv,
-			u32 clk_freq);
-	u32 cpe_msg_buffer;
-	void *cpe_cmi_handle;
-	struct mutex cpe_api_mutex;
-	struct mutex cpe_svc_lock;
-	struct cpe_svc_boot_event cpe_debug_vector;
-	void *cdc_priv;
-};
-
-static struct cpe_priv cpe_d;
-
-static enum cpe_svc_result __cpe_svc_shutdown(void *cpe_handle);
-
-static enum cpe_svc_result cpe_is_command_valid(
-		const struct cpe_info *t_info,
-		enum cpe_command command);
-
-static int cpe_register_read(u32 reg, u8 *val)
-{
-	*(val) = snd_soc_read(cpe_d.cdc_priv, reg);
-	return 0;
-}
-
-static enum cpe_svc_result cpe_update_bits(u32 reg,
-		u32 mask, u32 value)
-{
-	int ret = 0;
-
-	ret = snd_soc_update_bits(cpe_d.cdc_priv, reg,
-				  mask, value);
-	if (ret < 0)
-		return CPE_SVC_FAILED;
-
-	return CPE_SVC_SUCCESS;
-}
-
-static int cpe_register_write(u32 reg, u32 val)
-{
-	int ret = 0;
-
-	if (reg != WCD9335_CPE_SS_MEM_BANK_0)
-		pr_debug("%s: reg = 0x%x, value = 0x%x\n",
-			  __func__, reg, val);
-
-	ret = snd_soc_write(cpe_d.cdc_priv, reg, val);
-	if (ret < 0)
-		return CPE_SVC_FAILED;
-
-	return CPE_SVC_SUCCESS;
-}
-
-static int cpe_register_write_repeat(u32 reg, u8 *ptr, u32 to_write)
-{
-	struct snd_soc_codec *codec = cpe_d.cdc_priv;
-	struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
-	int ret = 0;
-
-	ret = wcd9xxx_slim_write_repeat(wcd9xxx, reg, to_write, ptr);
-	if (ret != 0)
-		pr_err("%s: slim_write_repeat failed\n", __func__);
-
-	if (ret < 0)
-		return CPE_SVC_FAILED;
-
-	return CPE_SVC_SUCCESS;
-}
-
-static bool cpe_register_read_autoinc_supported(void)
-{
-	return true;
-}
-
-
-/* Called under msgq locked context */
-static void cpe_cmd_received(struct cpe_info *t_info)
-{
-	struct cpe_command_node *node = NULL;
-	enum cpe_process_result proc_rc = CPE_PROC_SUCCESS;
-
-	if (!t_info) {
-		pr_err("%s: Invalid thread info\n",
-			__func__);
-		return;
-	}
-
-	while (!list_empty(&t_info->main_queue)) {
-		if (proc_rc != CPE_PROC_SUCCESS)
-			break;
-		node = list_first_entry(&t_info->main_queue,
-					struct cpe_command_node, list);
-		if (!node)
-			break;
-		list_del(&node->list);
-		proc_rc = t_info->cpe_process_command(node);
-		pr_debug("%s: process command return %d\n",
-			 __func__, proc_rc);
-
-		switch (proc_rc) {
-		case CPE_PROC_SUCCESS:
-			kfree(node);
-			break;
-		case CPE_PROC_FAILED:
-			kfree(node);
-			pr_err("%s: cmd failed\n", __func__);
-			break;
-		case CPE_PROC_KILLED:
-			break;
-		default:
-			list_add(&node->list, &(t_info->main_queue));
-
-		}
-	}
-}
-
-static int cpe_worker_thread(void *context)
-{
-	struct cpe_info *t_info = (struct cpe_info *)context;
-
-	/*
-	 * Thread will run until requested to stop explicitly
-	 * by setting the t_info->stop_thread flag
-	 */
-	while (1) {
-		/* Wait for command to be processed */
-		wait_for_completion(&t_info->cmd_complete);
-
-		CPE_SVC_GRAB_LOCK(&t_info->msg_lock, "msg_lock");
-		cpe_cmd_received(t_info);
-		reinit_completion(&t_info->cmd_complete);
-		/* Check if thread needs to be stopped */
-		if (t_info->stop_thread)
-			goto unlock_and_exit;
-		CPE_SVC_REL_LOCK(&t_info->msg_lock, "msg_lock");
-	};
-
-unlock_and_exit:
-	pr_debug("%s: thread stopped\n", __func__);
-	CPE_SVC_REL_LOCK(&t_info->msg_lock, "msg_lock");
-	complete_and_exit(&t_info->thread_comp, 0);
-}
-
-static void cpe_create_worker_thread(struct cpe_info *t_info)
-{
-	INIT_LIST_HEAD(&t_info->main_queue);
-	init_completion(&t_info->cmd_complete);
-	init_completion(&t_info->thread_comp);
-	t_info->stop_thread = false;
-	t_info->thread_handler = kthread_run(cpe_worker_thread,
-		(void *)t_info, "cpe-worker-thread");
-	pr_debug("%s: Created new worker thread\n",
-		 __func__);
-}
-
-static void cpe_cleanup_worker_thread(struct cpe_info *t_info)
-{
-	if (!t_info->thread_handler) {
-		pr_err("%s: thread not created\n", __func__);
-		return;
-	}
-
-	/*
-	 * Wake up the command handler in case
-	 * it is waiting for an command to be processed.
-	 */
-	CPE_SVC_GRAB_LOCK(&t_info->msg_lock, "msg_lock");
-	t_info->stop_thread = true;
-	complete(&t_info->cmd_complete);
-	CPE_SVC_REL_LOCK(&t_info->msg_lock, "msg_lock");
-
-	/* Wait for the thread to exit */
-	wait_for_completion(&t_info->thread_comp);
-	t_info->thread_handler = NULL;
-
-	pr_debug("%s: Thread cleaned up successfully\n",
-		 __func__);
-}
-
-static enum cpe_svc_result
-cpe_send_cmd_to_thread(struct cpe_info *t_info,
-	enum cpe_command command, void *data,
-	bool high_prio)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_command_node *cmd = NULL;
-
-	rc = cpe_is_command_valid(t_info, command);
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: Invalid command %d\n",
-			__func__, command);
-		return rc;
-	}
-
-	cmd = kzalloc(sizeof(struct cpe_command_node),
-		      GFP_ATOMIC);
-	if (!cmd)
-		return CPE_SVC_NO_MEMORY;
-
-	cmd->command = command;
-	cmd->data = data;
-
-	CPE_SVC_GRAB_LOCK(&t_info->msg_lock, "msg_lock");
-	if (high_prio)
-		list_add(&(cmd->list),
-			 &(t_info->main_queue));
-	else
-		list_add_tail(&(cmd->list),
-			      &(t_info->main_queue));
-	complete(&t_info->cmd_complete);
-	CPE_SVC_REL_LOCK(&t_info->msg_lock, "msg_lock");
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_change_state(
-	struct cpe_info *t_info,
-	enum cpe_state state, enum cpe_substate ss)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	t_info->state = state;
-	t_info->substate = ss;
-
-	pr_debug("%s: current state: %d,%d, new_state: %d,%d\n",
-		 __func__, t_info->state, t_info->substate,
-		 state, ss);
-
-	return rc;
-}
-
-static enum cpe_svc_result
-cpe_is_command_valid(const struct cpe_info *t_info,
-		enum cpe_command command)
-{
-	enum cpe_svc_result rc = CPE_SVC_INVALID_HANDLE;
-
-	if (t_info && t_info->cpe_cmd_validate)
-		rc = t_info->cpe_cmd_validate(t_info, command);
-	else
-		pr_err("%s: invalid handle or callback\n",
-			__func__);
-	return rc;
-}
-
-static void cpe_notify_client(struct cpe_notif_node *client,
-		struct cpe_svc_notification *payload)
-{
-	if (!client || !payload) {
-		pr_err("%s: invalid client or payload\n",
-			__func__);
-		return;
-	}
-
-	if (!(client->mask & payload->event)) {
-		pr_debug("%s: client mask 0x%x not registered for event 0x%x\n",
-			 __func__, client->mask, payload->event);
-		return;
-	}
-
-	if (client->notif.notification && !client->disabled)
-		client->notif.notification(payload);
-
-	if ((client->mask & CPE_SVC_CMI_MSG) &&
-	     client->notif.cmi_notification)
-		client->notif.cmi_notification(
-			(const struct cmi_api_notification *)payload);
-}
-
-static void cpe_broadcast_notification(const struct cpe_info *t_info,
-		struct cpe_svc_notification *payload)
-{
-	struct cpe_notif_node *n = NULL;
-
-	if (!t_info || !payload) {
-		pr_err("%s: invalid handle\n", __func__);
-		return;
-	}
-
-	pr_debug("%s: notify clients, event = %d\n",
-		 __func__, payload->event);
-	payload->private_data = cpe_d.cdc_priv;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-	list_for_each_entry(n, &t_info->client_list, list) {
-		if (!(n->mask & CPE_SVC_CMI_MSG))
-			cpe_notify_client(n, payload);
-	}
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-}
-
-static void *cpe_register_generic(struct cpe_info *t_info,
-		void notification_callback(
-			const struct cpe_svc_notification *parameter),
-		void cmi_callback(
-			const struct cmi_api_notification *parameter),
-		u32 mask, u32 service, const char *name)
-{
-	struct cpe_notif_node *n = NULL;
-
-	n = kzalloc(sizeof(struct cpe_notif_node),
-		    GFP_KERNEL);
-	if (!n)
-		return NULL;
-	n->mask = mask;
-	n->service = service;
-	n->notif.notification = notification_callback;
-	n->notif.cmi_notification = cmi_callback;
-	n->context = t_info;
-	n->disabled = false;
-	n->name = name;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-	/* Make sure CPE core service is first */
-	if (service == CMI_CPE_CORE_SERVICE_ID)
-		list_add(&n->list, &t_info->client_list);
-	else
-		list_add_tail(&n->list, &t_info->client_list);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-
-	return n;
-}
-
-static enum cpe_svc_result cpe_deregister_generic(struct cpe_info *t_info,
-		void *reg_handle)
-{
-	struct cpe_notif_node *n = (struct cpe_notif_node *)reg_handle;
-
-	if (!t_info || !reg_handle) {
-		pr_err("%s: invalid handle\n", __func__);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	list_del(&(n->list));
-	kfree(reg_handle);
-
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_svc_tgt_init(struct cpe_svc_codec_info_v1 *i,
-		struct cpe_svc_tgt_abstraction *abs)
-{
-	if (!i || !abs) {
-		pr_err("%s: Incorrect information provided\n",
-			__func__);
-		return CPE_SVC_FAILED;
-	}
-
-	switch (i->id) {
-	case CPE_SVC_CODEC_TOMTOM:
-		return cpe_tgt_tomtom_init(i, abs);
-	case CPE_SVC_CODEC_WCD9335:
-		return cpe_tgt_wcd9335_init(i, abs);
-	default:
-		pr_err("%s: Codec type %d not supported\n",
-			__func__, i->id);
-		return CPE_SVC_FAILED;
-	}
-
-	return CPE_SVC_SUCCESS;
-}
-
-static void cpe_notify_cmi_client(struct cpe_info *t_info, u8 *payload,
-		enum cpe_svc_result result)
-{
-	struct cpe_notif_node *n = NULL;
-	struct cmi_api_notification notif;
-	struct cmi_hdr *hdr;
-	u8 service = 0;
-
-	if (!t_info || !payload) {
-		pr_err("%s: invalid payload/handle\n",
-			__func__);
-		return;
-	}
-
-	hdr = CMI_GET_HEADER(payload);
-	service = CMI_HDR_GET_SERVICE(hdr);
-
-	notif.event = CPE_SVC_CMI_MSG;
-	notif.result = result;
-	notif.message = payload;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-	list_for_each_entry(n, &t_info->client_list, list) {
-
-		if ((n->mask & CPE_SVC_CMI_MSG) &&
-		    n->service == service &&
-		    n->notif.cmi_notification) {
-			n->notif.cmi_notification(&notif);
-			break;
-		}
-	}
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-}
-
-static void cpe_toggle_irq_notification(struct cpe_info *t_info, u32 value)
-{
-	if (cpe_d.cpe_irq_control_callback)
-		cpe_d.cpe_irq_control_callback(value);
-}
-
-static void cpe_command_cleanup(struct cpe_command_node *command_node)
-{
-	switch (command_node->command) {
-	case CPE_CMD_SEND_MSG:
-	case CPE_CMD_SEND_TRANS_MSG:
-	case CPE_CMD_SEND_MSG_COMPLETE:
-	case CPE_CMD_SHUTDOWN:
-	case CPE_CMD_READ:
-		kfree(command_node->data);
-		command_node->data = NULL;
-		break;
-	default:
-		pr_err("%s: unhandled command\n",
-			__func__);
-		break;
-	}
-}
-
-static enum cpe_svc_result cpe_send_msg_to_inbox(
-		struct cpe_info *t_info, u32 opcode,
-		struct cpe_send_msg *msg)
-{
-	size_t bytes = 0;
-	size_t inbox_size =
-		t_info->tgt->tgt_get_cpe_info()->inbox_size;
-	struct cmi_hdr *hdr;
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	memset(t_info->tgt->inbox, 0, inbox_size);
-	hdr = CMI_GET_HEADER(t_info->tgt->inbox);
-	CMI_HDR_SET_SESSION(hdr, 1);
-	CMI_HDR_SET_SERVICE(hdr, CMI_CPE_CORE_SERVICE_ID);
-	CMI_HDR_SET_VERSION(hdr, CMI_DRIVER_SUPPORTED_VERSION);
-	CMI_HDR_SET_OBM(hdr, CMI_OBM_FLAG_IN_BAND);
-
-	switch (opcode) {
-	case CPE_CORE_SVC_CMD_SHARED_MEM_ALLOC: {
-		struct cmi_core_svc_cmd_shared_mem_alloc *m;
-
-		CMI_HDR_SET_OPCODE(hdr,
-			CPE_CORE_SVC_CMD_SHARED_MEM_ALLOC);
-		CMI_HDR_SET_PAYLOAD_SIZE(hdr,
-			sizeof(struct cmi_core_svc_cmd_shared_mem_alloc));
-		m = (struct cmi_core_svc_cmd_shared_mem_alloc *)
-			CMI_GET_PAYLOAD(t_info->tgt->inbox);
-		m->size = CPE_MSG_BUFFER_SIZE;
-		pr_debug("send shared mem alloc msg to cpe inbox\n");
-		}
-		break;
-	case CPE_CORE_SVC_CMD_DRAM_ACCESS_REQ:
-		CMI_HDR_SET_OPCODE(hdr,
-			CPE_CORE_SVC_CMD_DRAM_ACCESS_REQ);
-		CMI_HDR_SET_PAYLOAD_SIZE(hdr, 0);
-		pr_debug("%s: Creating DRAM acces request msg\n",
-			 __func__);
-		break;
-
-	case CPE_CMI_BASIC_RSP_OPCODE: {
-		struct cmi_basic_rsp_result *rsp;
-
-		CMI_HDR_SET_OPCODE(hdr,
-			       CPE_CMI_BASIC_RSP_OPCODE);
-		CMI_HDR_SET_PAYLOAD_SIZE(hdr,
-			sizeof(struct cmi_basic_rsp_result));
-		rsp = (struct cmi_basic_rsp_result *)
-				CMI_GET_PAYLOAD(t_info->tgt->inbox);
-		rsp->status = 0;
-		pr_debug("%s: send basic response\n", __func__);
-		}
-		break;
-
-	default:
-		if (msg->address != 0) {
-			struct cmi_msg_transport *m = NULL;
-			struct cpe_svc_mem_segment mem_seg;
-
-			mem_seg.type = CPE_SVC_DATA_MEM;
-			if (msg->isobm) {
-				struct cmi_obm *obm = (struct cmi_obm *)
-
-				CMI_GET_PAYLOAD(msg->payload);
-				mem_seg.cpe_addr = obm->mem_handle;
-				mem_seg.data = (u8 *)obm->data_ptr.kvaddr;
-				mem_seg.size = obm->size;
-				t_info->tgt->tgt_write_ram(t_info, &mem_seg);
-			}
-
-			mem_seg.cpe_addr = msg->address;
-			mem_seg.data = msg->payload;
-			mem_seg.size = msg->size;
-			t_info->tgt->tgt_write_ram(t_info, &mem_seg);
-
-			hdr = CMI_GET_HEADER(t_info->tgt->inbox);
-			CMI_HDR_SET_OPCODE(hdr, CMI_MSG_TRANSPORT);
-			m = (struct cmi_msg_transport *)
-				CMI_GET_PAYLOAD(t_info->tgt->inbox);
-			m->addr = msg->address;
-			m->size = msg->size;
-			CMI_HDR_SET_PAYLOAD_SIZE(hdr,
-				sizeof(struct cmi_msg_transport));
-		} else {
-			memcpy(t_info->tgt->inbox, msg->payload,
-			       msg->size);
-		}
-
-		break;
-	}
-
-	pr_debug("%s: sending message to cpe inbox\n",
-		  __func__);
-	bytes = sizeof(struct cmi_hdr);
-	hdr = CMI_GET_HEADER(t_info->tgt->inbox);
-	bytes += CMI_HDR_GET_PAYLOAD_SIZE(hdr);
-	rc = t_info->tgt->tgt_write_mailbox(t_info->tgt->inbox, bytes);
-
-	return rc;
-}
-
-static bool cpe_is_cmd_clk_req(void *cmd)
-{
-	struct cmi_hdr *hdr;
-
-	hdr = CMI_GET_HEADER(cmd);
-
-	if ((CMI_HDR_GET_SERVICE(hdr) ==
-	    CMI_CPE_CORE_SERVICE_ID)) {
-		if (CMI_GET_OPCODE(cmd) ==
-		    CPE_CORE_SVC_CMD_CLK_FREQ_REQUEST)
-			return true;
-	}
-
-	return false;
-}
-
-static enum cpe_svc_result cpe_process_clk_change_req(
-		struct cpe_info *t_info)
-{
-	struct cmi_core_svc_cmd_clk_freq_request *req;
-
-	req = (struct cmi_core_svc_cmd_clk_freq_request *)
-			CMI_GET_PAYLOAD(t_info->tgt->outbox);
-
-	if (!cpe_d.cpe_change_freq_plan_cb) {
-		pr_err("%s: No support for clk freq change\n",
-			__func__);
-		return CPE_SVC_FAILED;
-	}
-
-	cpe_d.cpe_change_freq_plan_cb(cpe_d.cdc_priv,
-				      req->clk_freq);
-
-	/*send a basic response*/
-	cpe_send_msg_to_inbox(t_info,
-		CPE_CMI_BASIC_RSP_OPCODE, NULL);
-
-	return CPE_SVC_SUCCESS;
-}
-
-static void cpe_process_irq_int(u32 irq,
-		struct cpe_info *t_info)
-{
-	struct cpe_command_node temp_node;
-	struct cpe_send_msg *m;
-	u8 size = 0;
-	bool err_irq = false;
-	struct cmi_hdr *hdr;
-
-	pr_debug("%s: irq = %u\n", __func__, irq);
-
-	if (!t_info) {
-		pr_err("%s: Invalid handle\n",
-			__func__);
-		return;
-	}
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	switch (irq) {
-	case CPE_IRQ_OUTBOX_IRQ:
-		size = t_info->tgt->tgt_get_cpe_info()->outbox_size;
-		t_info->tgt->tgt_read_mailbox(t_info->tgt->outbox, size);
-		break;
-
-	case CPE_IRQ_MEM_ACCESS_ERROR:
-		err_irq = true;
-		cpe_change_state(t_info, CPE_STATE_OFFLINE, CPE_SS_IDLE);
-		break;
-
-	case CPE_IRQ_WDOG_BITE:
-	case CPE_IRQ_RCO_WDOG_INT:
-		err_irq = true;
-		__cpe_svc_shutdown(t_info);
-		break;
-
-	case CPE_IRQ_FLL_LOCK_LOST:
-	default:
-		err_irq = true;
-		break;
-	}
-
-	if (err_irq) {
-		pr_err("%s: CPE error IRQ %u occurred\n",
-			__func__, irq);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return;
-	}
-
-	switch (t_info->state) {
-	case CPE_STATE_BOOTING:
-
-		switch (t_info->substate) {
-		case CPE_SS_BOOT:
-			temp_node.command = CPE_CMD_BOOT_INITIALIZE;
-			temp_node.result = CPE_SVC_SUCCESS;
-			t_info->substate = CPE_SS_BOOT_INIT;
-			t_info->cpe_process_command(&temp_node);
-			break;
-
-		case CPE_SS_BOOT_INIT:
-			temp_node.command = CPE_CMD_BOOT_COMPLETE;
-			temp_node.result = CPE_SVC_SUCCESS;
-			t_info->substate = CPE_SS_ONLINE;
-			t_info->cpe_process_command(&temp_node);
-			break;
-
-		default:
-			pr_debug("%s: unhandled substate %d for state %d\n",
-				 __func__, t_info->state, t_info->substate);
-			break;
-		}
-		break;
-
-	case CPE_STATE_SENDING_MSG:
-		hdr = CMI_GET_HEADER(t_info->tgt->outbox);
-		if (CMI_GET_OPCODE(t_info->tgt->outbox) ==
-		    CPE_LSM_SESSION_EVENT_DETECTION_STATUS_V2) {
-			pr_debug("%s: session_id: %u, state: %d,%d, event received\n",
-				 __func__, CMI_HDR_GET_SESSION_ID(hdr),
-				t_info->state, t_info->substate);
-			temp_node.command = CPE_CMD_PROC_INCOMING_MSG;
-			temp_node.data = NULL;
-			t_info->cpe_process_command(&temp_node);
-			break;
-		}
-
-		m = (struct cpe_send_msg *)t_info->pending;
-
-		switch (t_info->substate) {
-		case CPE_SS_MSG_REQUEST_ACCESS:
-			cpe_send_cmd_to_thread(t_info,
-				CPE_CMD_SEND_TRANS_MSG, m, true);
-			break;
-
-		case CPE_SS_MSG_SEND_INBOX:
-			if (cpe_is_cmd_clk_req(t_info->tgt->outbox))
-				cpe_process_clk_change_req(t_info);
-			else
-				cpe_send_cmd_to_thread(t_info,
-					CPE_CMD_SEND_MSG_COMPLETE, m, true);
-			break;
-
-		default:
-			pr_debug("%s: unhandled substate %d for state %d\n",
-				 __func__, t_info->state, t_info->substate);
-			break;
-		}
-		break;
-
-	case CPE_STATE_IDLE:
-		pr_debug("%s: Message received, notifying client\n",
-			 __func__);
-		temp_node.command = CPE_CMD_PROC_INCOMING_MSG;
-		temp_node.data = NULL;
-		t_info->cpe_process_command(&temp_node);
-		break;
-
-	default:
-		pr_debug("%s: unhandled state %d\n",
-			 __func__, t_info->state);
-		break;
-	}
-
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-}
-
-
-static void broacast_boot_failed(void)
-{
-	struct cpe_info *t_info = cpe_d.cpe_default_handle;
-	struct cpe_svc_notification payload;
-
-	payload.event = CPE_SVC_BOOT_FAILED;
-	payload.result = CPE_SVC_FAILED;
-	payload.payload = NULL;
-	if (t_info)
-		payload.private_data =
-			t_info->client_context;
-	cpe_broadcast_notification(t_info, &payload);
-}
-
-static enum cpe_svc_result broadcast_boot_event(
-		struct cpe_info *t_info)
-{
-	struct cpe_svc_notification payload;
-
-	payload.event = CPE_SVC_ONLINE;
-	payload.result = CPE_SVC_SUCCESS;
-	payload.payload = NULL;
-	if (t_info)
-		payload.private_data =
-			t_info->client_context;
-	cpe_broadcast_notification(t_info, &payload);
-
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_process_result cpe_boot_initialize(struct cpe_info *t_info,
-	enum cpe_svc_result *cpe_rc)
-{
-	enum cpe_process_result rc = CPE_SVC_FAILED;
-	struct cpe_svc_notification payload;
-	struct cmi_core_svc_event_system_boot *p = NULL;
-
-	if (CMI_GET_OPCODE(t_info->tgt->outbox) !=
-		CPE_CORE_SVC_EVENT_SYSTEM_BOOT) {
-		broacast_boot_failed();
-		return rc;
-	}
-
-	p = (struct cmi_core_svc_event_system_boot *)
-		CMI_GET_PAYLOAD(t_info->tgt->outbox);
-	if (p->status != CPE_BOOT_SUCCESS) {
-		pr_err("%s: cpe boot failed, status = %d\n",
-			__func__, p->status);
-		broacast_boot_failed();
-		return rc;
-	}
-
-	/* boot was successful */
-	if (p->version ==
-	    CPE_CORE_VERSION_SYSTEM_BOOT_EVENT) {
-		cpe_d.cpe_debug_vector.debug_address =
-				p->sfr_buff_address;
-		cpe_d.cpe_debug_vector.debug_buffer_size =
-				p->sfr_buff_size;
-		cpe_d.cpe_debug_vector.status = p->status;
-		payload.event = CPE_SVC_BOOT;
-		payload.result = CPE_SVC_SUCCESS;
-		payload.payload = (void *)&cpe_d.cpe_debug_vector;
-		payload.private_data = t_info->client_context;
-		cpe_broadcast_notification(t_info, &payload);
-	}
-	cpe_change_state(t_info, CPE_STATE_BOOTING,
-			 CPE_SS_BOOT_INIT);
-	(*cpe_rc) = cpe_send_msg_to_inbox(t_info,
-			CPE_CORE_SVC_CMD_SHARED_MEM_ALLOC, NULL);
-	rc = CPE_PROC_SUCCESS;
-	return rc;
-}
-
-static void cpe_svc_core_cmi_handler(
-		const struct cmi_api_notification *parameter)
-{
-	struct cmi_hdr *hdr;
-
-	if (!parameter)
-		return;
-
-	pr_debug("%s: event = %d\n",
-		 __func__, parameter->event);
-
-	if (parameter->event != CMI_API_MSG)
-		return;
-
-	hdr = (struct cmi_hdr *) parameter->message;
-
-	if (hdr->opcode == CPE_CMI_BASIC_RSP_OPCODE) {
-		struct cmi_basic_rsp_result *result;
-
-		result = (struct cmi_basic_rsp_result *)
-			((u8 *)parameter->message) + (sizeof(*hdr));
-		if (result->status)
-			pr_err("%s: error response, error code = %u\n",
-				__func__, result->status);
-		complete(&cpe_d.cpe_default_handle->core_svc_cmd_compl);
-	}
-}
-
-static void cpe_clk_plan_work(struct work_struct *work)
-{
-	struct cpe_info *t_info = NULL;
-	size_t size = 0;
-	struct cpe_svc_cfg_clk_plan plan;
-	u8 *cmi_msg;
-	struct cmi_hdr *hdr;
-	int rc;
-
-	t_info = container_of(work, struct cpe_info, clk_plan_work);
-	if (!t_info) {
-		pr_err("%s: Invalid handle for cpe_info\n",
-			__func__);
-		return;
-	}
-
-	/* Register the core service */
-	cpe_d.cpe_cmi_handle = cmi_register(
-					cpe_svc_core_cmi_handler,
-					CMI_CPE_CORE_SERVICE_ID);
-
-	/* send the clk plan command */
-	if (!cpe_d.cpe_query_freq_plans_cb) {
-		pr_err("%s: No support for querying clk plans\n",
-			__func__);
-		return;
-	}
-
-	cpe_d.cpe_query_freq_plans_cb(cpe_d.cdc_priv, &plan);
-	size = sizeof(plan.current_clk_feq) +
-		sizeof(plan.num_clk_freqs);
-	size += plan.num_clk_freqs *
-		  sizeof(plan.clk_freqs[0]);
-	cmi_msg = kzalloc(size + sizeof(struct cmi_hdr),
-			  GFP_KERNEL);
-	if (!cmi_msg)
-		return;
-
-	hdr = (struct cmi_hdr *) cmi_msg;
-	CMI_HDR_SET_OPCODE(hdr,
-			   CPE_CORE_SVC_CMD_CFG_CLK_PLAN);
-	CMI_HDR_SET_SERVICE(hdr, CMI_CPE_CORE_SERVICE_ID);
-		CMI_HDR_SET_SESSION(hdr, 1);
-	CMI_HDR_SET_VERSION(hdr, CMI_DRIVER_SUPPORTED_VERSION);
-	CMI_HDR_SET_PAYLOAD_SIZE(hdr, size);
-	memcpy(CMI_GET_PAYLOAD(cmi_msg), &plan,
-	       size);
-	cmi_send_msg(cmi_msg);
-
-	/* Wait for clk plan command to complete */
-	rc = wait_for_completion_timeout(&t_info->core_svc_cmd_compl,
-					 (10 * HZ));
-	if (!rc) {
-		pr_err("%s: clk plan cmd timed out\n",
-			__func__);
-		goto cmd_fail;
-	}
-
-	/* clk plan cmd is successful, send start notification */
-	if (t_info->cpe_start_notification)
-		t_info->cpe_start_notification(t_info);
-	else
-		pr_err("%s: no start notification\n",
-			 __func__);
-
-cmd_fail:
-	kfree(cmi_msg);
-	cmi_deregister(cpe_d.cpe_cmi_handle);
-}
-
-static enum cpe_process_result cpe_boot_complete(
-		struct cpe_info *t_info)
-{
-	struct cmi_core_svc_cmdrsp_shared_mem_alloc *p = NULL;
-
-	if (CMI_GET_OPCODE(t_info->tgt->outbox) !=
-		CPE_CORE_SVC_CMDRSP_SHARED_MEM_ALLOC) {
-		broacast_boot_failed();
-		return CPE_PROC_FAILED;
-	}
-
-	p = (struct cmi_core_svc_cmdrsp_shared_mem_alloc *)
-		CMI_GET_PAYLOAD(t_info->tgt->outbox);
-	cpe_d.cpe_msg_buffer = p->addr;
-
-	if (cpe_d.cpe_msg_buffer == 0) {
-		pr_err("%s: Invalid cpe buffer for message\n",
-			__func__);
-		broacast_boot_failed();
-		return CPE_PROC_FAILED;
-	}
-
-	cpe_change_state(t_info, CPE_STATE_IDLE, CPE_SS_IDLE);
-	cpe_create_worker_thread(t_info);
-
-	if (t_info->codec_id != CPE_SVC_CODEC_TOMTOM) {
-		schedule_work(&t_info->clk_plan_work);
-	} else {
-		if (t_info->cpe_start_notification)
-			t_info->cpe_start_notification(t_info);
-		else
-			pr_err("%s: no start notification\n",
-				__func__);
-	}
-
-	pr_debug("%s: boot complete\n", __func__);
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_process_result cpe_process_send_msg(
-	struct cpe_info *t_info,
-	enum cpe_svc_result *cpe_rc,
-	struct cpe_command_node *command_node)
-{
-	enum cpe_process_result rc = CPE_PROC_SUCCESS;
-	struct cpe_send_msg *m =
-		(struct cpe_send_msg *)command_node->data;
-	u32 size = m->size;
-
-	if (t_info->pending) {
-		pr_debug("%s: message queued\n", __func__);
-		*cpe_rc = CPE_SVC_SUCCESS;
-		return CPE_PROC_QUEUED;
-	}
-
-	pr_debug("%s: Send CMI message, size = %u\n",
-		 __func__, size);
-
-	if (size <= t_info->tgt->tgt_get_cpe_info()->inbox_size) {
-		pr_debug("%s: Msg fits mailbox, size %u\n",
-			 __func__, size);
-		cpe_change_state(t_info, CPE_STATE_SENDING_MSG,
-			CPE_SS_MSG_SEND_INBOX);
-		t_info->pending = m;
-		*cpe_rc = cpe_send_msg_to_inbox(t_info, 0, m);
-	} else if (size < CPE_MSG_BUFFER_SIZE) {
-		m->address = cpe_d.cpe_msg_buffer;
-		pr_debug("%s: Message req CMI mem access\n",
-			 __func__);
-		t_info->pending = m;
-		cpe_change_state(t_info, CPE_STATE_SENDING_MSG,
-			CPE_SS_MSG_REQUEST_ACCESS);
-		*cpe_rc = cpe_send_msg_to_inbox(t_info,
-			CPE_CORE_SVC_CMD_DRAM_ACCESS_REQ, m);
-	} else {
-		pr_debug("%s: Invalid msg size %u\n",
-			 __func__, size);
-		cpe_command_cleanup(command_node);
-		rc = CPE_PROC_FAILED;
-		cpe_change_state(t_info, CPE_STATE_IDLE,
-			CPE_SS_IDLE);
-	}
-
-	return rc;
-}
-
-static enum cpe_process_result cpe_process_incoming(
-		struct cpe_info *t_info)
-{
-	enum cpe_process_result rc = CPE_PROC_FAILED;
-	struct cmi_hdr *hdr;
-
-	hdr = CMI_GET_HEADER(t_info->tgt->outbox);
-
-	if (CMI_HDR_GET_SERVICE(hdr) ==
-	    CMI_CPE_CORE_SERVICE_ID) {
-		pr_debug("%s: core service message received\n",
-			 __func__);
-
-		switch (CMI_GET_OPCODE(t_info->tgt->outbox)) {
-		case CPE_CORE_SVC_CMD_CLK_FREQ_REQUEST:
-			cpe_process_clk_change_req(t_info);
-			rc = CPE_PROC_SUCCESS;
-			break;
-		case CMI_MSG_TRANSPORT:
-			pr_debug("%s: transport msg received\n",
-				 __func__);
-			rc = CPE_PROC_SUCCESS;
-			break;
-		case CPE_CMI_BASIC_RSP_OPCODE:
-			pr_debug("%s: received basic rsp\n",
-				 __func__);
-			rc = CPE_PROC_SUCCESS;
-			break;
-		default:
-			pr_debug("%s: unknown message received\n",
-				 __func__);
-			break;
-		}
-	} else {
-		/* if service id if for a CMI client, notify client */
-		pr_debug("%s: Message received, notifying client\n",
-			 __func__);
-		cpe_notify_cmi_client(t_info,
-			t_info->tgt->outbox, CPE_SVC_SUCCESS);
-		rc = CPE_PROC_SUCCESS;
-	}
-
-	return rc;
-}
-
-static enum cpe_process_result cpe_process_kill_thread(
-	struct cpe_info *t_info,
-	struct cpe_command_node *command_node)
-{
-	struct cpe_svc_notification payload;
-
-	cpe_d.cpe_msg_buffer = 0;
-	payload.result = CPE_SVC_SHUTTING_DOWN;
-	payload.event = CPE_SVC_OFFLINE;
-	payload.payload = NULL;
-	payload.private_data = t_info->client_context;
-	/*
-	 * Make state as offline before broadcasting
-	 * the message to clients.
-	 */
-	cpe_change_state(t_info, CPE_STATE_OFFLINE,
-			 CPE_SS_IDLE);
-	cpe_broadcast_notification(t_info, &payload);
-
-	return CPE_PROC_KILLED;
-}
-
-static enum cpe_process_result cpe_mt_process_cmd(
-		struct cpe_command_node *command_node)
-{
-	struct cpe_info *t_info = cpe_d.cpe_default_handle;
-	enum cpe_svc_result cpe_rc = CPE_SVC_SUCCESS;
-	enum cpe_process_result rc = CPE_PROC_SUCCESS;
-	struct cpe_send_msg *m;
-	struct cmi_hdr *hdr;
-	u8 service = 0;
-	u8 retries = 0;
-
-	if (!t_info || !command_node) {
-		pr_err("%s: Invalid handle/command node\n",
-			__func__);
-		return CPE_PROC_FAILED;
-	}
-
-	pr_debug("%s: cmd = %u\n", __func__, command_node->command);
-
-	cpe_rc = cpe_is_command_valid(t_info, command_node->command);
-
-	if (cpe_rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: Invalid command %d, err = %d\n",
-			__func__, command_node->command, cpe_rc);
-		return CPE_PROC_FAILED;
-	}
-
-	switch (command_node->command) {
-
-	case CPE_CMD_BOOT_INITIALIZE:
-		rc = cpe_boot_initialize(t_info, &cpe_rc);
-		break;
-
-	case CPE_CMD_BOOT_COMPLETE:
-		rc = cpe_boot_complete(t_info);
-		break;
-
-	case CPE_CMD_SEND_MSG:
-		rc = cpe_process_send_msg(t_info, &cpe_rc,
-					  command_node);
-		break;
-
-	case CPE_CMD_SEND_TRANS_MSG:
-		m = (struct cpe_send_msg *)command_node->data;
-
-		while (retries < CPE_SVC_INACTIVE_STATE_RETRIES_MAX) {
-			if (t_info->tgt->tgt_is_active()) {
-				++retries;
-				/* Wait for CPE to be inactive */
-				usleep_range(5000, 5100);
-			} else {
-				break;
-			}
-		}
-
-		pr_debug("%s: cpe inactive after %d attempts\n",
-			 __func__, retries);
-
-		cpe_change_state(t_info, CPE_STATE_SENDING_MSG,
-				CPE_SS_MSG_SEND_INBOX);
-		rc = cpe_send_msg_to_inbox(t_info, 0, m);
-		break;
-
-	case CPE_CMD_SEND_MSG_COMPLETE:
-		hdr = CMI_GET_HEADER(t_info->tgt->outbox);
-		service = CMI_HDR_GET_SERVICE(hdr);
-		pr_debug("%s: msg send success, notifying clients\n",
-			 __func__);
-		cpe_command_cleanup(command_node);
-		t_info->pending = NULL;
-		cpe_change_state(t_info,
-				 CPE_STATE_IDLE, CPE_SS_IDLE);
-		cpe_notify_cmi_client(t_info,
-			t_info->tgt->outbox, CPE_SVC_SUCCESS);
-		break;
-
-	case CPE_CMD_PROC_INCOMING_MSG:
-		rc = cpe_process_incoming(t_info);
-		break;
-
-	case CPE_CMD_KILL_THREAD:
-		rc = cpe_process_kill_thread(t_info, command_node);
-		break;
-
-	default:
-		pr_err("%s: unhandled cpe cmd = %d\n",
-			__func__, command_node->command);
-		break;
-	}
-
-	if (cpe_rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: failed to execute command\n", __func__);
-		if (t_info->pending) {
-			m = (struct cpe_send_msg *)t_info->pending;
-			cpe_notify_cmi_client(t_info, m->payload,
-					      CPE_SVC_FAILED);
-			t_info->pending = NULL;
-		}
-
-		cpe_command_cleanup(command_node);
-		rc = CPE_PROC_FAILED;
-		cpe_change_state(t_info, CPE_STATE_IDLE,
-			CPE_SS_IDLE);
-	}
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_mt_validate_cmd(
-		const struct cpe_info *t_info,
-		enum cpe_command command)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	if ((t_info == NULL) || t_info->initialized == false) {
-		pr_err("%s: cpe service is not ready\n",
-			__func__);
-		return CPE_SVC_NOT_READY;
-	}
-
-	switch (t_info->state) {
-	case CPE_STATE_UNINITIALIZED:
-	case CPE_STATE_INITIALIZED:
-		switch (command) {
-		case CPE_CMD_RESET:
-		case CPE_CMD_DL_SEGMENT:
-		case CPE_CMD_RAMDUMP:
-		case CPE_CMD_PROCESS_IRQ:
-		case CPE_CMD_KILL_THREAD:
-		case CPE_CMD_DEINITIALIZE:
-		case CPE_CMD_FTM_TEST:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		default:
-			rc = CPE_SVC_NOT_READY;
-			break;
-		}
-		break;
-
-	case CPE_STATE_DOWNLOADING:
-		switch (command) {
-		case CPE_CMD_RESET:
-		case CPE_CMD_DL_SEGMENT:
-		case CPE_CMD_BOOT:
-		case CPE_CMD_FTM_TEST:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		default:
-			rc = CPE_SVC_NOT_READY;
-			break;
-		}
-		break;
-
-	case CPE_STATE_BOOTING:
-		switch (command) {
-		case CPE_CMD_PROCESS_IRQ:
-		case CPE_CMD_BOOT_INITIALIZE:
-		case CPE_CMD_BOOT_COMPLETE:
-		case CPE_CMD_SHUTDOWN:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		case CPE_CMD_FTM_TEST:
-			rc = CPE_SVC_BUSY;
-			break;
-		default:
-			rc = CPE_SVC_NOT_READY;
-			break;
-		}
-		break;
-
-	case CPE_STATE_IDLE:
-		switch (command) {
-		case CPE_CMD_SEND_MSG:
-		case CPE_CMD_SEND_TRANS_MSG:
-		case CPE_CMD_SEND_MSG_COMPLETE:
-		case CPE_CMD_PROCESS_IRQ:
-		case CPE_CMD_RESET:
-		case CPE_CMD_SHUTDOWN:
-		case CPE_CMD_KILL_THREAD:
-		case CPE_CMD_PROC_INCOMING_MSG:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		case CPE_CMD_FTM_TEST:
-			rc = CPE_SVC_BUSY;
-			break;
-		default:
-			rc = CPE_SVC_FAILED;
-			break;
-		}
-		break;
-
-	case CPE_STATE_SENDING_MSG:
-		switch (command) {
-		case CPE_CMD_SEND_MSG:
-		case CPE_CMD_SEND_TRANS_MSG:
-		case CPE_CMD_SEND_MSG_COMPLETE:
-		case CPE_CMD_PROCESS_IRQ:
-		case CPE_CMD_SHUTDOWN:
-		case CPE_CMD_KILL_THREAD:
-		case CPE_CMD_PROC_INCOMING_MSG:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		case CPE_CMD_FTM_TEST:
-			rc = CPE_SVC_BUSY;
-			break;
-		default:
-			rc = CPE_SVC_FAILED;
-			break;
-		}
-		break;
-
-	case CPE_STATE_OFFLINE:
-		switch (command) {
-		case CPE_CMD_RESET:
-		case CPE_CMD_RAMDUMP:
-		case CPE_CMD_KILL_THREAD:
-			rc = CPE_SVC_SUCCESS;
-			break;
-		default:
-			rc = CPE_SVC_NOT_READY;
-			break;
-		}
-		break;
-
-	default:
-		pr_debug("%s: unhandled state %d\n",
-			 __func__, t_info->state);
-		break;
-	}
-
-	if (rc != CPE_SVC_SUCCESS)
-		pr_err("%s: invalid command %d, state = %d\n",
-			__func__, command, t_info->state);
-	return rc;
-}
-
-void *cpe_svc_initialize(
-		void irq_control_callback(u32 enable),
-		const void *codec_info, void *context)
-{
-	struct cpe_info *t_info = NULL;
-	const struct cpe_svc_hw_cfg *cap = NULL;
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_svc_init_param *init_context =
-		(struct cpe_svc_init_param *) context;
-	void *client_context = NULL;
-
-	if (cpe_d.cpe_default_handle &&
-	    cpe_d.cpe_default_handle->initialized == true)
-		return (void *)cpe_d.cpe_default_handle;
-	cpe_d.cpe_query_freq_plans_cb = NULL;
-	cpe_d.cpe_change_freq_plan_cb = NULL;
-
-	if (context) {
-		client_context = init_context->context;
-		switch (init_context->version) {
-		case CPE_SVC_INIT_PARAM_V1:
-			cpe_d.cpe_query_freq_plans_cb =
-				init_context->query_freq_plans_cb;
-			cpe_d.cpe_change_freq_plan_cb =
-				init_context->change_freq_plan_cb;
-			break;
-		default:
-			break;
-		}
-	}
-
-	if (!cpe_d.cpe_default_handle) {
-		cpe_d.cpe_default_handle = kzalloc(sizeof(struct cpe_info),
-					     GFP_KERNEL);
-		if (!cpe_d.cpe_default_handle)
-			goto err_register;
-
-		memset(cpe_d.cpe_default_handle, 0,
-		       sizeof(struct cpe_info));
-	}
-
-	t_info = cpe_d.cpe_default_handle;
-	t_info->client_context = client_context;
-
-	INIT_LIST_HEAD(&t_info->client_list);
-	cpe_d.cdc_priv = client_context;
-	INIT_WORK(&t_info->clk_plan_work, cpe_clk_plan_work);
-	init_completion(&t_info->core_svc_cmd_compl);
-
-	t_info->tgt = kzalloc(sizeof(struct cpe_svc_tgt_abstraction),
-			      GFP_KERNEL);
-	if (!t_info->tgt)
-		goto err_tgt_alloc;
-	t_info->codec_id =
-		((struct cpe_svc_codec_info_v1 *) codec_info)->id;
-
-	rc = cpe_svc_tgt_init((struct cpe_svc_codec_info_v1 *)codec_info,
-			t_info->tgt);
-
-	if (rc != CPE_SVC_SUCCESS)
-		goto err_tgt_init;
-
-	cap = t_info->tgt->tgt_get_cpe_info();
-
-	memset(t_info->tgt->outbox, 0, cap->outbox_size);
-	memset(t_info->tgt->inbox, 0, cap->inbox_size);
-	mutex_init(&t_info->msg_lock);
-	cpe_d.cpe_irq_control_callback = irq_control_callback;
-	t_info->cpe_process_command = cpe_mt_process_cmd;
-	t_info->cpe_cmd_validate = cpe_mt_validate_cmd;
-	t_info->cpe_start_notification = broadcast_boot_event;
-	mutex_init(&cpe_d.cpe_api_mutex);
-	mutex_init(&cpe_d.cpe_svc_lock);
-	pr_debug("%s: cpe services initialized\n", __func__);
-	t_info->state = CPE_STATE_INITIALIZED;
-	t_info->initialized = true;
-
-	return t_info;
-
-err_tgt_init:
-	kfree(t_info->tgt);
-
-err_tgt_alloc:
-	kfree(cpe_d.cpe_default_handle);
-	cpe_d.cpe_default_handle = NULL;
-
-err_register:
-	return NULL;
-}
-
-enum cpe_svc_result cpe_svc_deinitialize(void *cpe_handle)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_DEINITIALIZE);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: Invalid command %d\n",
-			__func__, CPE_CMD_DEINITIALIZE);
-		return rc;
-	}
-
-	if (cpe_d.cpe_default_handle == t_info)
-		cpe_d.cpe_default_handle = NULL;
-
-	t_info->tgt->tgt_deinit(t_info->tgt);
-	cpe_change_state(t_info, CPE_STATE_UNINITIALIZED,
-			 CPE_SS_IDLE);
-	mutex_destroy(&t_info->msg_lock);
-	kfree(t_info->tgt);
-	kfree(t_info);
-	mutex_destroy(&cpe_d.cpe_api_mutex);
-	mutex_destroy(&cpe_d.cpe_svc_lock);
-
-	return rc;
-}
-
-void *cpe_svc_register(void *cpe_handle,
-		void (*notification_callback)
-			(const struct cpe_svc_notification *parameter),
-		u32 mask, const char *name)
-{
-	void *reg_handle;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!cpe_d.cpe_default_handle) {
-		cpe_d.cpe_default_handle = kzalloc(sizeof(struct cpe_info),
-					     GFP_KERNEL);
-		if (!cpe_d.cpe_default_handle) {
-			CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-			return NULL;
-		}
-
-		memset(cpe_d.cpe_default_handle, 0,
-			sizeof(struct cpe_info));
-	}
-
-	if (!cpe_handle)
-		cpe_handle = cpe_d.cpe_default_handle;
-
-	reg_handle = cpe_register_generic((struct cpe_info *)cpe_handle,
-					   notification_callback,
-					   NULL,
-					   mask, CPE_NO_SERVICE, name);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return reg_handle;
-}
-
-enum cpe_svc_result cpe_svc_deregister(void *cpe_handle, void *reg_handle)
-{
-	enum cpe_svc_result rc;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!cpe_handle)
-		cpe_handle = cpe_d.cpe_default_handle;
-
-	rc = cpe_deregister_generic((struct cpe_info *)cpe_handle,
-				    reg_handle);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_download_segment(void *cpe_handle,
-	const struct cpe_svc_mem_segment *segment)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_DL_SEGMENT);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_DL_SEGMENT);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return rc;
-	}
-
-	cpe_toggle_irq_notification(t_info, false);
-	t_info->state = CPE_STATE_DOWNLOADING;
-	t_info->substate = CPE_SS_DL_DOWNLOADING;
-	rc = t_info->tgt->tgt_write_ram(t_info, segment);
-	cpe_toggle_irq_notification(t_info, true);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_boot(void *cpe_handle, int debug_mode)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_BOOT);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_BOOT);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return rc;
-	}
-
-	if (rc == CPE_SVC_SUCCESS) {
-		t_info->tgt->tgt_boot(debug_mode);
-		t_info->state = CPE_STATE_BOOTING;
-		t_info->substate = CPE_SS_BOOT;
-		pr_debug("%s: cpe service booting\n",
-			 __func__);
-	}
-
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_process_irq(void *cpe_handle, u32 cpe_irq)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	cpe_toggle_irq_notification(t_info, false);
-	cpe_process_irq_int(cpe_irq, t_info);
-	cpe_toggle_irq_notification(t_info, true);
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_route_notification(void *cpe_handle,
-		enum cpe_svc_module module, enum cpe_svc_route_dest dest)
-{
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-	enum cpe_svc_result rc = CPE_SVC_NOT_READY;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	if (t_info->tgt)
-		rc = t_info->tgt->tgt_route_notification(module, dest);
-
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-static enum cpe_svc_result __cpe_svc_shutdown(void *cpe_handle)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-	struct cpe_command_node *n = NULL;
-	struct cpe_command_node kill_cmd;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_SHUTDOWN);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_SHUTDOWN);
-		return rc;
-	}
-
-	while (!list_empty(&t_info->main_queue)) {
-		n = list_first_entry(&t_info->main_queue,
-				     struct cpe_command_node, list);
-
-		if (n->command == CPE_CMD_SEND_MSG) {
-			cpe_notify_cmi_client(t_info, (u8 *)n->data,
-				CPE_SVC_SHUTTING_DOWN);
-		}
-		/*
-		 * Since command cannot be processed,
-		 * delete it from the list and perform cleanup
-		 */
-		list_del(&n->list);
-		cpe_command_cleanup(n);
-		kfree(n);
-	}
-
-	pr_debug("%s: cpe service OFFLINE state\n", __func__);
-
-	t_info->state = CPE_STATE_OFFLINE;
-	t_info->substate = CPE_SS_IDLE;
-
-	memset(&kill_cmd, 0, sizeof(kill_cmd));
-	kill_cmd.command = CPE_CMD_KILL_THREAD;
-
-	if (t_info->pending) {
-		struct cpe_send_msg *m =
-			(struct cpe_send_msg *)t_info->pending;
-		cpe_notify_cmi_client(t_info, m->payload,
-			CPE_SVC_SHUTTING_DOWN);
-		kfree(t_info->pending);
-		t_info->pending = NULL;
-	}
-
-	cpe_cleanup_worker_thread(t_info);
-	t_info->cpe_process_command(&kill_cmd);
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_shutdown(void *cpe_handle)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	rc = __cpe_svc_shutdown(cpe_handle);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_reset(void *cpe_handle)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_RESET);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_RESET);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return rc;
-	}
-
-	if (t_info && t_info->tgt) {
-		rc = t_info->tgt->tgt_reset();
-		pr_debug("%s: cpe services in INITIALIZED state\n",
-			 __func__);
-		t_info->state = CPE_STATE_INITIALIZED;
-		t_info->substate = CPE_SS_IDLE;
-	}
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_ramdump(void *cpe_handle,
-		struct cpe_svc_mem_segment *buffer)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_RAMDUMP);
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_RAMDUMP);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return rc;
-	}
-
-	if (t_info->tgt) {
-		rc = t_info->tgt->tgt_read_ram(t_info, buffer);
-	} else {
-		pr_err("%s: cpe service not ready\n", __func__);
-		rc = CPE_SVC_NOT_READY;
-	}
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_set_debug_mode(void *cpe_handle, u32 mode)
-{
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-	enum cpe_svc_result rc = CPE_SVC_INVALID_HANDLE;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	if (t_info->tgt)
-		rc = t_info->tgt->tgt_set_debug_mode(mode);
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return rc;
-}
-
-const struct cpe_svc_hw_cfg *cpe_svc_get_hw_cfg(void *cpe_handle)
-{
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	if (t_info->tgt)
-		return t_info->tgt->tgt_get_cpe_info();
-
-	return NULL;
-}
-
-void *cmi_register(
-		void notification_callback(
-			const struct cmi_api_notification *parameter),
-		u32 service)
-{
-	void *reg_handle = NULL;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	reg_handle = cpe_register_generic(cpe_d.cpe_default_handle,
-			NULL,
-			notification_callback,
-			(CPE_SVC_CMI_MSG | CPE_SVC_OFFLINE |
-			 CPE_SVC_ONLINE),
-			service,
-			"CMI_CLIENT");
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-
-	return reg_handle;
-}
-
-enum cmi_api_result cmi_deregister(void *reg_handle)
-{
-	u32 clients = 0;
-	struct cpe_notif_node *n = NULL;
-	enum cmi_api_result rc = CMI_API_SUCCESS;
-	struct cpe_svc_notification payload;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	rc = (enum cmi_api_result) cpe_deregister_generic(
-		cpe_d.cpe_default_handle, reg_handle);
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-	list_for_each_entry(n, &cpe_d.cpe_default_handle->client_list, list) {
-		if (n->mask & CPE_SVC_CMI_MSG)
-			clients++;
-	}
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
-
-	if (clients == 0) {
-		payload.event = CPE_SVC_CMI_CLIENTS_DEREG;
-		payload.payload = NULL;
-		payload.result = CPE_SVC_SUCCESS;
-		cpe_broadcast_notification(cpe_d.cpe_default_handle, &payload);
-	}
-
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-enum cmi_api_result cmi_send_msg(void *message)
-{
-	enum cmi_api_result rc = CMI_API_SUCCESS;
-	struct cpe_send_msg *msg = NULL;
-	struct cmi_hdr *hdr;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	hdr = CMI_GET_HEADER(message);
-	msg = kzalloc(sizeof(struct cpe_send_msg),
-		      GFP_ATOMIC);
-	if (!msg) {
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return CPE_SVC_NO_MEMORY;
-	}
-
-	if (CMI_HDR_GET_OBM_FLAG(hdr) == CMI_OBM_FLAG_OUT_BAND)
-		msg->isobm = 1;
-	else
-		msg->isobm = 0;
-
-	msg->size = sizeof(struct cmi_hdr) +
-			CMI_HDR_GET_PAYLOAD_SIZE(hdr);
-
-	msg->payload = kzalloc(msg->size, GFP_ATOMIC);
-	if (!msg->payload) {
-		kfree(msg);
-		CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-		return CPE_SVC_NO_MEMORY;
-	}
-
-	msg->address = 0;
-	memcpy((void *)msg->payload, message, msg->size);
-
-	rc = (enum cmi_api_result) cpe_send_cmd_to_thread(
-			cpe_d.cpe_default_handle,
-			CPE_CMD_SEND_MSG,
-			(void *)msg, false);
-
-	if (rc != 0) {
-		pr_err("%s: Failed to queue message\n", __func__);
-		kfree(msg->payload);
-		kfree(msg);
-	}
-
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-enum cpe_svc_result cpe_svc_ftm_test(void *cpe_handle, u32 *status)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-	struct cpe_svc_mem_segment backup_seg;
-	struct cpe_svc_mem_segment waiti_seg;
-	u8 *backup_data = NULL;
-
-	CPE_SVC_GRAB_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	rc = cpe_is_command_valid(t_info, CPE_CMD_FTM_TEST);
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: cmd validation fail, cmd = %d\n",
-			__func__, CPE_CMD_FTM_TEST);
-		goto fail_cmd;
-	}
-
-	if (t_info && t_info->tgt) {
-		backup_data = kzalloc(
-				t_info->tgt->tgt_waiti_info->tgt_waiti_size,
-				GFP_KERNEL);
-
-		/* CPE reset */
-		rc = t_info->tgt->tgt_reset();
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: CPE reset fail! err = %d\n",
-				__func__, rc);
-			goto err_return;
-		}
-
-		/* Back up the 4 byte IRAM data first */
-		backup_seg.type = CPE_SVC_INSTRUCTION_MEM;
-		backup_seg.cpe_addr =
-			t_info->tgt->tgt_get_cpe_info()->IRAM_offset;
-		backup_seg.size = t_info->tgt->tgt_waiti_info->tgt_waiti_size;
-		backup_seg.data = backup_data;
-
-		pr_debug("%s: Backing up IRAM data from CPE\n",
-			__func__);
-
-		rc = t_info->tgt->tgt_read_ram(t_info, &backup_seg);
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: Fail to backup CPE IRAM data, err = %d\n",
-				__func__, rc);
-			goto err_return;
-		}
-
-		pr_debug("%s: Complete backing up IRAM data from CPE\n",
-			__func__);
-
-		/* Write the WAITI instruction data */
-		waiti_seg.type = CPE_SVC_INSTRUCTION_MEM;
-		waiti_seg.cpe_addr =
-			t_info->tgt->tgt_get_cpe_info()->IRAM_offset;
-		waiti_seg.size = t_info->tgt->tgt_waiti_info->tgt_waiti_size;
-		waiti_seg.data = t_info->tgt->tgt_waiti_info->tgt_waiti_data;
-
-		rc = t_info->tgt->tgt_write_ram(t_info, &waiti_seg);
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: Fail to write the WAITI data, err = %d\n",
-				__func__, rc);
-			goto restore_iram;
-		}
-
-		/* Boot up cpe to execute the WAITI instructions */
-		rc = t_info->tgt->tgt_boot(1);
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: Fail to boot CPE, err = %d\n",
-				__func__, rc);
-			goto reset;
-		}
-
-		/*
-		 * 1ms delay is suggested by the hw team to
-		 * wait for cpe to boot up.
-		 */
-		usleep_range(1000, 1100);
-
-		/* Check if the cpe init is done after executing the WAITI */
-		*status = t_info->tgt->tgt_cpar_init_done();
-
-reset:
-		/* Set the cpe back to reset state */
-		rc = t_info->tgt->tgt_reset();
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: CPE reset fail! err = %d\n",
-				__func__, rc);
-			goto restore_iram;
-		}
-
-restore_iram:
-		/* Restore the IRAM 4 bytes data */
-		rc = t_info->tgt->tgt_write_ram(t_info, &backup_seg);
-		if (rc != CPE_SVC_SUCCESS) {
-			pr_err("%s: Fail to restore the IRAM data, err = %d\n",
-				__func__, rc);
-			goto err_return;
-		}
-	}
-
-err_return:
-	kfree(backup_data);
-fail_cmd:
-	CPE_SVC_REL_LOCK(&cpe_d.cpe_api_mutex, "cpe_api");
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_boot(int debug_mode)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static u32 cpe_tgt_tomtom_is_cpar_init_done(void)
-{
-	return 0;
-}
-
-static u32 cpe_tgt_tomtom_is_active(void)
-{
-	return 0;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_reset(void)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-enum cpe_svc_result cpe_tgt_tomtom_voicetx(bool enable)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-enum cpe_svc_result cpe_svc_toggle_lab(void *cpe_handle, bool enable)
-{
-
-	struct cpe_info *t_info = (struct cpe_info *)cpe_handle;
-
-	if (!t_info)
-		t_info = cpe_d.cpe_default_handle;
-
-	if (t_info->tgt)
-		return t_info->tgt->tgt_voice_tx_lab(enable);
-	else
-		return CPE_SVC_INVALID_HANDLE;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_read_mailbox(u8 *buffer,
-	size_t size)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_write_mailbox(u8 *buffer,
-	size_t size)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_read_RAM(struct cpe_info *t_info,
-		struct cpe_svc_mem_segment *mem_seg)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_write_RAM(struct cpe_info *t_info,
-		const struct cpe_svc_mem_segment *mem_seg)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_route_notification(
-		enum cpe_svc_module module,
-		enum cpe_svc_route_dest dest)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_set_debug_mode(u32 enable)
-{
-	return CPE_SVC_SUCCESS;
-}
-
-static const struct cpe_svc_hw_cfg *cpe_tgt_tomtom_get_cpe_info(void)
-{
-	return &cpe_svc_tomtom_info;
-}
-
-static enum cpe_svc_result cpe_tgt_tomtom_deinit(
-		struct cpe_svc_tgt_abstraction *param)
-{
-	kfree(param->inbox);
-	param->inbox = NULL;
-	kfree(param->outbox);
-	param->outbox = NULL;
-	memset(param, 0, sizeof(struct cpe_svc_tgt_abstraction));
-	return CPE_SVC_SUCCESS;
-}
-
-static u8 cpe_tgt_tomtom_waiti_data[] = {0x00, 0x70, 0x00, 0x00};
-
-static struct cpe_tgt_waiti_info cpe_tgt_tomtom_waiti_info = {
-	.tgt_waiti_size = ARRAY_SIZE(cpe_tgt_tomtom_waiti_data),
-	.tgt_waiti_data = cpe_tgt_tomtom_waiti_data,
-};
-
-static enum cpe_svc_result cpe_tgt_tomtom_init(
-		struct cpe_svc_codec_info_v1 *codec_info,
-		struct cpe_svc_tgt_abstraction *param)
-{
-	if (!codec_info)
-		return CPE_SVC_INVALID_HANDLE;
-	if (!param)
-		return CPE_SVC_INVALID_HANDLE;
-
-	if (codec_info->id == CPE_SVC_CODEC_TOMTOM) {
-		param->tgt_boot      = cpe_tgt_tomtom_boot;
-		param->tgt_cpar_init_done = cpe_tgt_tomtom_is_cpar_init_done;
-		param->tgt_is_active = cpe_tgt_tomtom_is_active;
-		param->tgt_reset = cpe_tgt_tomtom_reset;
-		param->tgt_read_mailbox = cpe_tgt_tomtom_read_mailbox;
-		param->tgt_write_mailbox = cpe_tgt_tomtom_write_mailbox;
-		param->tgt_read_ram = cpe_tgt_tomtom_read_RAM;
-		param->tgt_write_ram = cpe_tgt_tomtom_write_RAM;
-		param->tgt_route_notification =
-			cpe_tgt_tomtom_route_notification;
-		param->tgt_set_debug_mode = cpe_tgt_tomtom_set_debug_mode;
-		param->tgt_get_cpe_info = cpe_tgt_tomtom_get_cpe_info;
-		param->tgt_deinit = cpe_tgt_tomtom_deinit;
-		param->tgt_voice_tx_lab = cpe_tgt_tomtom_voicetx;
-		param->tgt_waiti_info = &cpe_tgt_tomtom_waiti_info;
-
-		param->inbox = kzalloc(TOMTOM_A_SVASS_SPE_INBOX_SIZE,
-				       GFP_KERNEL);
-		if (!param->inbox)
-			return CPE_SVC_NO_MEMORY;
-
-		param->outbox = kzalloc(TOMTOM_A_SVASS_SPE_OUTBOX_SIZE,
-					GFP_KERNEL);
-		if (!param->outbox) {
-			kfree(param->inbox);
-			return CPE_SVC_NO_MEMORY;
-		}
-	}
-
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_boot(int debug_mode)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	if (!debug_mode)
-		rc |= cpe_update_bits(
-				WCD9335_CPE_SS_WDOG_CFG,
-				0x3f, 0x31);
-	else
-		pr_info("%s: CPE in debug mode, WDOG disabled\n",
-			__func__);
-
-	rc |= cpe_register_write(WCD9335_CPE_SS_CPARMAD_BUFRDY_INT_PERIOD, 19);
-	rc |= cpe_update_bits(WCD9335_CPE_SS_CPAR_CTL, 0x04, 0x00);
-	rc |= cpe_update_bits(WCD9335_CPE_SS_CPAR_CTL, 0x02, 0x02);
-	rc |= cpe_update_bits(WCD9335_CPE_SS_CPAR_CTL, 0x01, 0x01);
-
-	if (unlikely(rc)) {
-		pr_err("%s: Failed to boot, err = %d\n",
-			__func__, rc);
-		rc = CPE_SVC_FAILED;
-	}
-
-	return rc;
-}
-
-static u32 cpe_tgt_wcd9335_is_cpar_init_done(void)
-{
-	u8 temp = 0;
-
-	cpe_register_read(WCD9335_CPE_SS_STATUS, &temp);
-	return temp & 0x1;
-}
-
-static u32 cpe_tgt_wcd9335_is_active(void)
-{
-	u8 temp = 0;
-
-	cpe_register_read(WCD9335_CPE_SS_STATUS, &temp);
-	return temp & 0x4;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_reset(void)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	rc |= cpe_update_bits(WCD9335_CPE_SS_CPAR_CFG, 0x01, 0x00);
-
-	rc |= cpe_register_write(
-		WCD9335_CODEC_RPM_PWR_CPE_IRAM_SHUTDOWN, 0x00);
-	rc |= cpe_register_write(
-		WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN, 0x00);
-	rc |= cpe_register_write(
-		WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_1, 0x00);
-	rc |= cpe_register_write(
-		WCD9335_CODEC_RPM_PWR_CPE_DRAM0_SHUTDOWN_2, 0x00);
-
-	rc |= cpe_update_bits(WCD9335_CPE_SS_CPAR_CTL, 0x04, 0x04);
-
-	if (unlikely(rc)) {
-		pr_err("%s: failed to reset cpe, err = %d\n",
-			__func__, rc);
-		rc = CPE_SVC_FAILED;
-	}
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_read_mailbox(u8 *buffer,
-	size_t size)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u32 cnt = 0;
-
-	pr_debug("%s: size=%zd\n", __func__, size);
-
-	if (size > WCD9335_CPE_SS_SPE_OUTBOX_SIZE)
-		size = WCD9335_CPE_SS_SPE_OUTBOX_SIZE;
-
-	for (cnt = 0; (cnt < size) && (rc == CPE_SVC_SUCCESS); cnt++)
-		rc = cpe_register_read(WCD9335_CPE_SS_SPE_OUTBOX1(cnt),
-				       &buffer[cnt]);
-
-	rc = cpe_register_write(WCD9335_CPE_SS_OUTBOX1_ACK, 0x01);
-
-	if (unlikely(rc)) {
-		pr_err("%s: failed to ACK outbox, err = %d\n",
-			__func__, rc);
-		rc = CPE_SVC_FAILED;
-	}
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_write_mailbox(u8 *buffer,
-	size_t size)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u32 cnt = 0;
-
-	pr_debug("%s: size = %zd\n", __func__, size);
-	if (size > WCD9335_CPE_SS_SPE_INBOX_SIZE)
-		size = WCD9335_CPE_SS_SPE_INBOX_SIZE;
-	for (cnt = 0; (cnt < size) && (rc == CPE_SVC_SUCCESS); cnt++) {
-		rc |= cpe_register_write(WCD9335_CPE_SS_SPE_INBOX1(cnt),
-			buffer[cnt]);
-	}
-
-	if (unlikely(rc)) {
-		pr_err("%s: Error %d writing mailbox registers\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = cpe_register_write(WCD9335_CPE_SS_INBOX1_TRG, 1);
-	return rc;
-}
-
-static enum cpe_svc_result cpe_wcd9335_get_mem_addr(struct cpe_info *t_info,
-		const struct cpe_svc_mem_segment *mem_seg,
-		u32 *addr, u8 *mem)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u32 offset, mem_sz, address;
-	u8 mem_type;
-
-	switch (mem_seg->type) {
-	case CPE_SVC_DATA_MEM:
-		mem_type = MEM_ACCESS_DRAM_VAL;
-		offset = WCD9335_CPE_SS_SPE_DRAM_OFFSET;
-		mem_sz = WCD9335_CPE_SS_SPE_DRAM_SIZE;
-		break;
-
-	case CPE_SVC_INSTRUCTION_MEM:
-		mem_type = MEM_ACCESS_IRAM_VAL;
-		offset = WCD9335_CPE_SS_SPE_IRAM_OFFSET;
-		mem_sz = WCD9335_CPE_SS_SPE_IRAM_SIZE;
-		break;
-
-	default:
-		pr_err("%s: Invalid mem type = %u\n",
-			__func__, mem_seg->type);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	if (mem_seg->cpe_addr < offset) {
-		pr_err("%s: Invalid addr %x for mem type %u\n",
-			__func__, mem_seg->cpe_addr, mem_type);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	address = mem_seg->cpe_addr - offset;
-	if (address + mem_seg->size > mem_sz) {
-		pr_err("%s: wrong size %zu, start address %x, mem_type %u\n",
-			__func__, mem_seg->size, address, mem_type);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	(*addr) = address;
-	(*mem) = mem_type;
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_read_RAM(struct cpe_info *t_info,
-		struct cpe_svc_mem_segment *mem_seg)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u8 temp = 0;
-	u32 cnt = 0;
-	u8 mem = 0x0;
-	u32 addr = 0;
-	u32 lastaddr = 0;
-	u32 ptr_update = true;
-	bool autoinc;
-
-	if (!mem_seg) {
-		pr_err("%s: Invalid buffer\n", __func__);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	rc = cpe_wcd9335_get_mem_addr(t_info, mem_seg, &addr, &mem);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: Cannot obtain address, mem_type %u\n",
-			__func__, mem_seg->type);
-		return rc;
-	}
-
-	rc |= cpe_register_write(WCD9335_CPE_SS_MEM_CTRL, 0);
-	autoinc = cpe_register_read_autoinc_supported();
-
-	if (autoinc)
-		temp = 0x18;
-	else
-		temp = 0x10;
-
-	temp |= mem;
-
-	lastaddr = ~addr;
-	do {
-		if (!autoinc || (ptr_update)) {
-			/* write LSB only if modified */
-			if ((lastaddr & 0xFF) != (addr & 0xFF))
-				rc |= cpe_register_write(
-						WCD9335_CPE_SS_MEM_PTR_0,
-						(addr & 0xFF));
-			/* write middle byte only if modified */
-			if (((lastaddr >> 8) & 0xFF) != ((addr >> 8) & 0xFF))
-				rc |= cpe_register_write(
-						WCD9335_CPE_SS_MEM_PTR_1,
-						((addr>>8) & 0xFF));
-			/* write MSB only if modified */
-			if (((lastaddr >> 16) & 0xFF) != ((addr >> 16) & 0xFF))
-				rc |= cpe_register_write(
-						WCD9335_CPE_SS_MEM_PTR_2,
-						((addr>>16) & 0xFF));
-
-			rc |= cpe_register_write(WCD9335_CPE_SS_MEM_CTRL, temp);
-			lastaddr = addr;
-			addr++;
-			ptr_update = false;
-		}
-
-		rc |= cpe_register_read(WCD9335_CPE_SS_MEM_BANK_0,
-				       &mem_seg->data[cnt]);
-
-		if (!autoinc)
-			rc |= cpe_register_write(WCD9335_CPE_SS_MEM_CTRL, 0);
-	} while ((++cnt < mem_seg->size) ||
-		 (rc != CPE_SVC_SUCCESS));
-
-	rc |= cpe_register_write(WCD9335_CPE_SS_MEM_CTRL, 0);
-
-	if (rc)
-		pr_err("%s: Failed to read registers, err = %d\n",
-			__func__, rc);
-
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_write_RAM(struct cpe_info *t_info,
-		const struct cpe_svc_mem_segment *mem_seg)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u8 mem_reg_val = 0;
-	u8 mem = MEM_ACCESS_NONE_VAL;
-	u32 addr = 0;
-	u8 *temp_ptr = NULL;
-	u32 temp_size = 0;
-	bool autoinc;
-
-	if (!mem_seg) {
-		pr_err("%s: Invalid mem segment\n",
-			__func__);
-		return CPE_SVC_INVALID_HANDLE;
-	}
-
-	rc = cpe_wcd9335_get_mem_addr(t_info, mem_seg, &addr, &mem);
-
-	if (rc != CPE_SVC_SUCCESS) {
-		pr_err("%s: Cannot obtain address, mem_type %u\n",
-			__func__, mem_seg->type);
-		return rc;
-	}
-
-	autoinc = cpe_register_read_autoinc_supported();
-	if (autoinc)
-		mem_reg_val = 0x18;
-	else
-		mem_reg_val = 0x10;
-
-	mem_reg_val |= mem;
-
-	rc = cpe_update_bits(WCD9335_CPE_SS_MEM_CTRL,
-			     0x0F, mem_reg_val);
-
-	rc = cpe_register_write(WCD9335_CPE_SS_MEM_PTR_0,
-				(addr & 0xFF));
-	rc = cpe_register_write(WCD9335_CPE_SS_MEM_PTR_1,
-				((addr >> 8) & 0xFF));
-
-	rc = cpe_register_write(WCD9335_CPE_SS_MEM_PTR_2,
-				((addr >> 16) & 0xFF));
-
-	temp_size = 0;
-	temp_ptr = mem_seg->data;
-
-	while (temp_size <= mem_seg->size) {
-		u32 to_write = (mem_seg->size >= temp_size+CHUNK_SIZE)
-			? CHUNK_SIZE : (mem_seg->size - temp_size);
-
-		if (t_info->state == CPE_STATE_OFFLINE) {
-			pr_err("%s: CPE is offline\n", __func__);
-			return CPE_SVC_FAILED;
-		}
-
-		cpe_register_write_repeat(WCD9335_CPE_SS_MEM_BANK_0,
-			temp_ptr, to_write);
-		temp_size += CHUNK_SIZE;
-		temp_ptr += CHUNK_SIZE;
-	}
-
-	rc = cpe_register_write(WCD9335_CPE_SS_MEM_CTRL, 0);
-
-	if (rc)
-		pr_err("%s: Failed to write registers, err = %d\n",
-			__func__, rc);
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_route_notification(
-		enum cpe_svc_module module,
-		enum cpe_svc_route_dest dest)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	pr_debug("%s: Module = %d, Destination = %d\n",
-		 __func__, module, dest);
-
-	switch (module) {
-	case CPE_SVC_LISTEN_PROC:
-		switch (dest) {
-		case CPE_SVC_EXTERNAL:
-			rc = cpe_update_bits(WCD9335_CPE_SS_CFG, 0x01, 0x01);
-			break;
-		case CPE_SVC_INTERNAL:
-			rc = cpe_update_bits(WCD9335_CPE_SS_CFG, 0x01, 0x00);
-			break;
-		default:
-			pr_err("%s: Invalid destination %d\n",
-				__func__, dest);
-			return CPE_SVC_FAILED;
-		}
-		break;
-	default:
-		pr_err("%s: Invalid module %d\n",
-			__func__, module);
-		rc = CPE_SVC_FAILED;
-		break;
-	}
-	return rc;
-}
-
-static enum cpe_svc_result cpe_tgt_wcd9335_set_debug_mode(u32 enable)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-
-	pr_debug("%s: enable = %s\n", __func__,
-		 (enable) ? "true" : "false");
-
-	return rc;
-}
-
-static const struct cpe_svc_hw_cfg *cpe_tgt_wcd9335_get_cpe_info(void)
-{
-	return &cpe_svc_wcd9335_info;
-}
-
-static enum cpe_svc_result
-cpe_tgt_wcd9335_deinit(struct cpe_svc_tgt_abstraction *param)
-{
-	kfree(param->inbox);
-	param->inbox = NULL;
-	kfree(param->outbox);
-	param->outbox = NULL;
-	memset(param, 0, sizeof(struct cpe_svc_tgt_abstraction));
-
-	return CPE_SVC_SUCCESS;
-}
-
-static enum cpe_svc_result
-	cpe_tgt_wcd9335_voicetx(bool enable)
-{
-	enum cpe_svc_result rc = CPE_SVC_SUCCESS;
-	u8 val = 0;
-
-	pr_debug("%s: enable = %u\n", __func__, enable);
-	if (enable)
-		val = 0x02;
-	else
-		val = 0x00;
-
-	rc = cpe_update_bits(WCD9335_CPE_SS_CFG, 0x02, val);
-	val = 0;
-	cpe_register_read(WCD9335_CPE_SS_CFG, &val);
-
-	return rc;
-}
-
-static u8 cpe_tgt_wcd9335_waiti_data[] = {0x00, 0x70, 0x00, 0x00};
-
-static struct cpe_tgt_waiti_info cpe_tgt_wcd9335_waiti_info = {
-	.tgt_waiti_size = ARRAY_SIZE(cpe_tgt_wcd9335_waiti_data),
-	.tgt_waiti_data = cpe_tgt_wcd9335_waiti_data,
-};
-
-static enum cpe_svc_result cpe_tgt_wcd9335_init(
-		struct cpe_svc_codec_info_v1 *codec_info,
-		struct cpe_svc_tgt_abstraction *param)
-{
-	if (!codec_info)
-		return CPE_SVC_INVALID_HANDLE;
-	if (!param)
-		return CPE_SVC_INVALID_HANDLE;
-
-	if (codec_info->id == CPE_SVC_CODEC_WCD9335) {
-		param->tgt_boot = cpe_tgt_wcd9335_boot;
-		param->tgt_cpar_init_done = cpe_tgt_wcd9335_is_cpar_init_done;
-		param->tgt_is_active = cpe_tgt_wcd9335_is_active;
-		param->tgt_reset = cpe_tgt_wcd9335_reset;
-		param->tgt_read_mailbox = cpe_tgt_wcd9335_read_mailbox;
-		param->tgt_write_mailbox = cpe_tgt_wcd9335_write_mailbox;
-		param->tgt_read_ram = cpe_tgt_wcd9335_read_RAM;
-		param->tgt_write_ram = cpe_tgt_wcd9335_write_RAM;
-		param->tgt_route_notification =
-			cpe_tgt_wcd9335_route_notification;
-		param->tgt_set_debug_mode = cpe_tgt_wcd9335_set_debug_mode;
-		param->tgt_get_cpe_info = cpe_tgt_wcd9335_get_cpe_info;
-		param->tgt_deinit = cpe_tgt_wcd9335_deinit;
-		param->tgt_voice_tx_lab = cpe_tgt_wcd9335_voicetx;
-		param->tgt_waiti_info = &cpe_tgt_wcd9335_waiti_info;
-
-		param->inbox = kzalloc(WCD9335_CPE_SS_SPE_INBOX_SIZE,
-				       GFP_KERNEL);
-		if (!param->inbox)
-			return CPE_SVC_NO_MEMORY;
-
-		param->outbox = kzalloc(WCD9335_CPE_SS_SPE_OUTBOX_SIZE,
-					GFP_KERNEL);
-		if (!param->outbox) {
-			kfree(param->inbox);
-			return CPE_SVC_NO_MEMORY;
-		}
-	}
-
-	return CPE_SVC_SUCCESS;
-}
-
-MODULE_DESCRIPTION("WCD CPE Services");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wcd_cpe_services.h b/sound/soc/codecs/wcd_cpe_services.h
deleted file mode 100644
index 68eb619..0000000
--- a/sound/soc/codecs/wcd_cpe_services.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __CPE_SERVICES__
-#define __CPE_SERVICES__
-
-#define CPE_IRQ_OUTBOX_IRQ		0x01
-#define CPE_IRQ_MEM_ACCESS_ERROR	0x02
-#define CPE_IRQ_WDOG_BITE		0x04
-#define CPE_IRQ_BUFFER_OVERFLOW		0x08
-#define CPE_IRQ_LAB_OVFUNF		0x10
-#define CPE_IRQ_FLL_LOCK_LOST		0x20
-#define CPE_IRQ_RCO_WDOG_INT		0x40
-
-#define EFAILED (MAX_ERRNO - 1)
-#define ENOTREADY (MAX_ERRNO - 2)
-
-#define MAX_SUPPORTED_CLKFREQ 8
-#define CPE_SVC_INIT_PARAM_V1 1
-
-enum cpe_svc_result {
-	CPE_SVC_SUCCESS			= 0,
-	CPE_SVC_FAILED			= -EFAILED,
-	CPE_SVC_NO_MEMORY		= -ENOMEM,
-	CPE_SVC_INVALID_HANDLE		= -EINVAL,
-	CPE_SVC_NOT_READY		= -ENOTREADY,
-	CPE_SVC_SHUTTING_DOWN		= -ESHUTDOWN,
-	CPE_SVC_BUSY			= -EBUSY,
-};
-
-enum cpe_svc_event {
-	CPE_SVC_CMI_MSG			= 0x01,
-	CPE_SVC_OFFLINE			= 0x02,
-	CPE_SVC_ONLINE			= 0x04,
-	CPE_SVC_BOOT_FAILED		= 0x08,
-	CPE_SVC_READ_COMPLETE		= 0x10,
-	CPE_SVC_READ_ERROR		= 0x20,
-	CPE_SVC_BOOT			= 0x40,
-	CPE_SVC_CMI_CLIENTS_DEREG	= 0x100,
-	CPE_SVC_EVENT_ANCHOR		= 0x7FFF
-};
-
-enum cpe_svc_module {
-	CPE_SVC_LISTEN_PROC		= 1,
-	CPE_SVC_MODULE_ANCHOR		= 0x7F
-};
-
-enum cpe_svc_route_dest {
-	CPE_SVC_EXTERNAL		= 1,
-	CPE_SVC_INTERNAL		= 2,
-	CPE_SVC_ROUTE_ANCHOR		= 0x7F
-};
-
-enum cpe_svc_mem_type {
-	CPE_SVC_DATA_MEM		= 1,
-	CPE_SVC_INSTRUCTION_MEM		= 2,
-	CPE_SVC_IPC_MEM			= 3,
-	CPE_SVC_MEM_TYPE_ANCHOR		= 0x7F
-};
-
-enum cpe_svc_codec_id {
-	CPE_SVC_CODEC_TOMTOM		= 5,
-	CPE_SVC_CODEC_WCD9335		= 7,
-	CPE_SVC_CODEC_WCD9326		= 8,
-	CPE_SVC_CODEC_ID_ANCHOR		= 0x7ffffff
-};
-
-enum cpe_svc_codec_version {
-	CPE_SVC_CODEC_V1P0		= 1,
-	CPE_SVC_CODEC_VERSION_ANCHOR	= 0x7fffffff
-};
-
-struct cpe_svc_codec_info_v1 {
-	u16			major_version;/*must be 1*/
-	u16			minor_version;/*must be 0*/
-	u32			id;
-	u32			version;
-	/*Add 1.1 version fields after this line*/
-};
-
-struct cpe_svc_notification {
-	enum cpe_svc_event event;
-	enum cpe_svc_result result;
-	void *payload;
-	void *private_data;
-};
-
-struct cpe_svc_msg_payload {
-	u8    *cmi_msg;
-};
-
-struct cpe_svc_read_complete {
-	u8    *buffer;
-	size_t   size;
-};
-
-struct cpe_svc_boot_event {
-	u32 debug_address;
-	size_t debug_buffer_size;
-	u32 status;
-};
-
-struct cpe_svc_mem_segment {
-	enum cpe_svc_mem_type type;
-	u32 cpe_addr;
-	size_t size;
-	u8 *data;
-};
-
-struct cpe_svc_hw_cfg {
-	size_t DRAM_size;
-	u32 DRAM_offset;
-	size_t IRAM_size;
-	u32 IRAM_offset;
-	u8 inbox_size;
-	u8 outbox_size;
-};
-
-struct cpe_svc_cfg_clk_plan {
-	u32 current_clk_feq;
-	u32 num_clk_freqs;
-	u32 clk_freqs[MAX_SUPPORTED_CLKFREQ];
-};
-
-struct cpe_svc_init_param {
-	void *context;
-	u32 version;
-	void (*query_freq_plans_cb)(void *cdc_priv,
-			struct cpe_svc_cfg_clk_plan *clk_freq);
-	void (*change_freq_plan_cb)(void *cdc_priv,
-			u32 clk_freq);
-};
-
-
-void *cpe_svc_initialize(
-		void irq_control_callback(u32 enable),
-		const void *codec_info, void *context);
-enum cpe_svc_result cpe_svc_deinitialize(void *cpe_handle);
-
-void *cpe_svc_register(void *cpe_handle,
-		void (*notification_callback)(
-			const struct cpe_svc_notification *parameter),
-		u32 mask, const char *name);
-
-enum cpe_svc_result cpe_svc_deregister(void *cpe_handle, void *reg_handle);
-
-enum cpe_svc_result cpe_svc_download_segment(void *cpe_handle,
-		const struct cpe_svc_mem_segment *segment);
-
-enum cpe_svc_result cpe_svc_boot(void *cpe_handle, int debug_mode);
-
-enum cpe_svc_result cpe_svc_shutdown(void *cpe_handle);
-
-enum cpe_svc_result cpe_svc_reset(void *cpe_handle);
-
-enum cpe_svc_result cpe_svc_process_irq(void *cpe_handle, u32 cpe_irq);
-
-enum cpe_svc_result
-cpe_svc_route_notification(void *cpe_handle, enum cpe_svc_module module,
-		enum cpe_svc_route_dest dest);
-
-enum cpe_svc_result cpe_svc_ramdump(void *cpe_handle,
-		struct cpe_svc_mem_segment *buffer);
-
-enum cpe_svc_result cpe_svc_set_debug_mode(void *cpe_handle, u32 mode);
-
-const struct cpe_svc_hw_cfg *cpe_svc_get_hw_cfg(void *cpe_handle);
-enum cpe_svc_result cpe_svc_toggle_lab(void *cpe_handle, bool enable);
-enum cpe_svc_result cpe_svc_ftm_test(void *cpe_handle, u32 *status);
-#endif /*__CPE_SERVICES__*/
diff --git a/sound/soc/codecs/wcdcal-hwdep.c b/sound/soc/codecs/wcdcal-hwdep.c
deleted file mode 100644
index 31eae69..0000000
--- a/sound/soc/codecs/wcdcal-hwdep.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/ioctl.h>
-#include <linux/bitops.h>
-#include <sound/hwdep.h>
-#include <sound/msmcal-hwdep.h>
-#include <sound/soc.h>
-#include "wcdcal-hwdep.h"
-
-const int cal_size_info[WCD9XXX_MAX_CAL] = {
-	[WCD9XXX_ANC_CAL] = 16384,
-	[WCD9XXX_MBHC_CAL] = 4096,
-	[WCD9XXX_MAD_CAL] = 4096,
-	[WCD9XXX_VBAT_CAL] = 72,
-};
-
-const char *cal_name_info[WCD9XXX_MAX_CAL] = {
-	[WCD9XXX_ANC_CAL] = "anc",
-	[WCD9XXX_MBHC_CAL] = "mbhc",
-	[WCD9XXX_MAD_CAL] = "mad",
-	[WCD9XXX_VBAT_CAL] = "vbat",
-};
-
-struct firmware_cal *wcdcal_get_fw_cal(struct fw_info *fw_data,
-					enum wcd_cal_type type)
-{
-	if (!fw_data) {
-		pr_err("%s: fw_data is NULL\n", __func__);
-		return NULL;
-	}
-	if (type >= WCD9XXX_MAX_CAL ||
-		type < WCD9XXX_MIN_CAL) {
-		pr_err("%s: wrong cal type sent %d\n", __func__, type);
-		return NULL;
-	}
-	mutex_lock(&fw_data->lock);
-	if (!test_bit(WCDCAL_RECIEVED,
-		&fw_data->wcdcal_state[type])) {
-		pr_err("%s: cal not sent by userspace %d\n",
-			__func__, type);
-		mutex_unlock(&fw_data->lock);
-		return NULL;
-	}
-	mutex_unlock(&fw_data->lock);
-	return fw_data->fw[type];
-}
-EXPORT_SYMBOL(wcdcal_get_fw_cal);
-
-static int wcdcal_hwdep_ioctl_shared(struct snd_hwdep *hw,
-			struct wcdcal_ioctl_buffer fw_user)
-{
-	struct fw_info *fw_data = hw->private_data;
-	struct firmware_cal **fw = fw_data->fw;
-	void *data;
-
-	if (!test_bit(fw_user.cal_type, fw_data->cal_bit)) {
-		pr_err("%s: codec didn't set this %d!!\n",
-				__func__, fw_user.cal_type);
-		return -EFAULT;
-	}
-	if (fw_user.cal_type >= WCD9XXX_MAX_CAL ||
-		fw_user.cal_type < WCD9XXX_MIN_CAL) {
-		pr_err("%s: wrong cal type sent %d\n",
-				__func__, fw_user.cal_type);
-		return -EFAULT;
-	}
-	if (fw_user.size > cal_size_info[fw_user.cal_type] ||
-		fw_user.size <= 0) {
-		pr_err("%s: incorrect firmware size %d for %s\n",
-			__func__, fw_user.size,
-			cal_name_info[fw_user.cal_type]);
-		return -EFAULT;
-	}
-	data = fw[fw_user.cal_type]->data;
-	if (copy_from_user(data, fw_user.buffer, fw_user.size))
-		return -EFAULT;
-	fw[fw_user.cal_type]->size = fw_user.size;
-	mutex_lock(&fw_data->lock);
-	set_bit(WCDCAL_RECIEVED, &fw_data->wcdcal_state[fw_user.cal_type]);
-	mutex_unlock(&fw_data->lock);
-	return 0;
-}
-
-#ifdef CONFIG_COMPAT
-struct wcdcal_ioctl_buffer32 {
-	u32 size;
-	compat_uptr_t buffer;
-	enum wcd_cal_type cal_type;
-};
-
-enum {
-	SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE32 =
-		_IOW('U', 0x1, struct wcdcal_ioctl_buffer32),
-};
-
-static int wcdcal_hwdep_ioctl_compat(struct snd_hwdep *hw, struct file *file,
-		unsigned int cmd, unsigned long arg)
-{
-	struct wcdcal_ioctl_buffer __user *argp = (void __user *)arg;
-	struct wcdcal_ioctl_buffer32 fw_user32;
-	struct wcdcal_ioctl_buffer fw_user_compat;
-
-	if (cmd != SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE32) {
-		pr_err("%s: wrong ioctl command sent %u!\n", __func__, cmd);
-		return -ENOIOCTLCMD;
-	}
-	if (copy_from_user(&fw_user32, argp, sizeof(fw_user32))) {
-		pr_err("%s: failed to copy\n", __func__);
-		return -EFAULT;
-	}
-	fw_user_compat.size = fw_user32.size;
-	fw_user_compat.buffer = compat_ptr(fw_user32.buffer);
-	fw_user_compat.cal_type = fw_user32.cal_type;
-	return wcdcal_hwdep_ioctl_shared(hw, fw_user_compat);
-}
-#else
-#define wcdcal_hwdep_ioctl_compat NULL
-#endif
-
-static int wcdcal_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
-		unsigned int cmd, unsigned long arg)
-{
-	struct wcdcal_ioctl_buffer __user *argp = (void __user *)arg;
-	struct wcdcal_ioctl_buffer fw_user;
-
-	if (cmd != SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE) {
-		pr_err("%s: wrong ioctl command sent %d!\n", __func__, cmd);
-		return -ENOIOCTLCMD;
-	}
-	if (copy_from_user(&fw_user, argp, sizeof(fw_user))) {
-		pr_err("%s: failed to copy\n", __func__);
-		return -EFAULT;
-	}
-	return wcdcal_hwdep_ioctl_shared(hw, fw_user);
-}
-
-static int wcdcal_hwdep_release(struct snd_hwdep *hw, struct file *file)
-{
-	struct fw_info *fw_data = hw->private_data;
-
-	mutex_lock(&fw_data->lock);
-	/* clear all the calibrations */
-	memset(fw_data->wcdcal_state, 0,
-		sizeof(fw_data->wcdcal_state));
-	mutex_unlock(&fw_data->lock);
-	return 0;
-}
-
-int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec)
-{
-	char hwname[40];
-	struct snd_hwdep *hwdep;
-	struct firmware_cal **fw;
-	struct fw_info *fw_data = data;
-	int err, cal_bit;
-
-	if (!fw_data || !codec) {
-		pr_err("%s: wrong arguments passed\n", __func__);
-		return -EINVAL;
-	}
-
-	fw = fw_data->fw;
-	snprintf(hwname, strlen("Codec %s"), "Codec %s",
-		 codec->component.name);
-	err = snd_hwdep_new(codec->component.card->snd_card,
-			    hwname, node, &hwdep);
-	if (err < 0) {
-		dev_err(codec->dev, "%s: new hwdep failed %d\n",
-				__func__, err);
-		return err;
-	}
-	snprintf(hwdep->name, strlen("Codec %s"), "Codec %s",
-		 codec->component.name);
-	hwdep->iface = SNDRV_HWDEP_IFACE_AUDIO_CODEC;
-	hwdep->private_data = fw_data;
-	hwdep->ops.ioctl_compat = wcdcal_hwdep_ioctl_compat;
-	hwdep->ops.ioctl = wcdcal_hwdep_ioctl;
-	hwdep->ops.release = wcdcal_hwdep_release;
-	mutex_init(&fw_data->lock);
-
-	for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) {
-		set_bit(WCDCAL_UNINITIALISED,
-				&fw_data->wcdcal_state[cal_bit]);
-		fw[cal_bit] = kzalloc(sizeof *(fw[cal_bit]), GFP_KERNEL);
-		if (!fw[cal_bit]) {
-			dev_err(codec->dev, "%s: no memory for %s cal\n",
-				__func__, cal_name_info[cal_bit]);
-			goto end;
-		}
-	}
-	for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) {
-		fw[cal_bit]->data = kzalloc(cal_size_info[cal_bit],
-						GFP_KERNEL);
-		if (!fw[cal_bit]->data)
-			goto exit;
-		set_bit(WCDCAL_INITIALISED,
-			&fw_data->wcdcal_state[cal_bit]);
-	}
-	return 0;
-exit:
-	for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) {
-		kfree(fw[cal_bit]->data);
-		fw[cal_bit]->data = NULL;
-	}
-end:
-	for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) {
-		kfree(fw[cal_bit]);
-		fw[cal_bit] = NULL;
-	}
-	return -ENOMEM;
-}
-EXPORT_SYMBOL(wcd_cal_create_hwdep);
diff --git a/sound/soc/codecs/wcdcal-hwdep.h b/sound/soc/codecs/wcdcal-hwdep.h
deleted file mode 100644
index 632e2f1..0000000
--- a/sound/soc/codecs/wcdcal-hwdep.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __WCD9XXX_HWDEP_H__
-#define __WCD9XXX_HWDEP_H__
-#include <sound/msmcal-hwdep.h>
-
-enum wcd_cal_states {
-	WCDCAL_UNINITIALISED,
-	WCDCAL_INITIALISED,
-	WCDCAL_RECIEVED
-};
-
-struct fw_info {
-	struct firmware_cal *fw[WCD9XXX_MAX_CAL];
-	DECLARE_BITMAP(cal_bit, WCD9XXX_MAX_CAL);
-	/* for calibration tracking */
-	unsigned long wcdcal_state[WCD9XXX_MAX_CAL];
-	struct mutex lock;
-};
-
-struct firmware_cal {
-	u8 *data;
-	size_t size;
-};
-
-struct snd_soc_codec;
-int wcd_cal_create_hwdep(void *fw, int node, struct snd_soc_codec *codec);
-struct firmware_cal *wcdcal_get_fw_cal(struct fw_info *fw_data,
-					enum wcd_cal_type type);
-#endif /* __WCD9XXX_HWDEP_H__ */
diff --git a/sound/soc/codecs/wsa881x-registers.h b/sound/soc/codecs/wsa881x-registers.h
deleted file mode 100644
index 825a5f0..0000000
--- a/sound/soc/codecs/wsa881x-registers.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WSA881X_REGISTERS_H
-#define WSA881X_REGISTERS_H
-
-#define WSA881X_DIGITAL_BASE		0x3000
-#define WSA881X_ANALOG_BASE		0x3100
-
-/* Digital register address space */
-#define WSA881X_CHIP_ID0			(WSA881X_DIGITAL_BASE+0x0000)
-#define WSA881X_CHIP_ID1			(WSA881X_DIGITAL_BASE+0x0001)
-#define WSA881X_CHIP_ID2			(WSA881X_DIGITAL_BASE+0x0002)
-#define WSA881X_CHIP_ID3			(WSA881X_DIGITAL_BASE+0x0003)
-#define WSA881X_BUS_ID				(WSA881X_DIGITAL_BASE+0x0004)
-#define WSA881X_CDC_RST_CTL			(WSA881X_DIGITAL_BASE+0x0005)
-#define WSA881X_CDC_TOP_CLK_CTL			(WSA881X_DIGITAL_BASE+0x0006)
-#define WSA881X_CDC_ANA_CLK_CTL			(WSA881X_DIGITAL_BASE+0x0007)
-#define WSA881X_CDC_DIG_CLK_CTL			(WSA881X_DIGITAL_BASE+0x0008)
-#define WSA881X_CLOCK_CONFIG			(WSA881X_DIGITAL_BASE+0x0009)
-#define WSA881X_ANA_CTL				(WSA881X_DIGITAL_BASE+0x000A)
-#define WSA881X_SWR_RESET_EN			(WSA881X_DIGITAL_BASE+0x000B)
-#define WSA881X_RESET_CTL			(WSA881X_DIGITAL_BASE+0x000C)
-#define WSA881X_TADC_VALUE_CTL			(WSA881X_DIGITAL_BASE+0x000F)
-#define WSA881X_TEMP_DETECT_CTL			(WSA881X_DIGITAL_BASE+0x0010)
-#define WSA881X_TEMP_MSB			(WSA881X_DIGITAL_BASE+0x0011)
-#define WSA881X_TEMP_LSB			(WSA881X_DIGITAL_BASE+0x0012)
-#define WSA881X_TEMP_CONFIG0			(WSA881X_DIGITAL_BASE+0x0013)
-#define WSA881X_TEMP_CONFIG1			(WSA881X_DIGITAL_BASE+0x0014)
-#define WSA881X_CDC_CLIP_CTL			(WSA881X_DIGITAL_BASE+0x0015)
-#define WSA881X_SDM_PDM9_LSB			(WSA881X_DIGITAL_BASE+0x0016)
-#define WSA881X_SDM_PDM9_MSB			(WSA881X_DIGITAL_BASE+0x0017)
-#define WSA881X_CDC_RX_CTL			(WSA881X_DIGITAL_BASE+0x0018)
-#define WSA881X_DEM_BYPASS_DATA0		(WSA881X_DIGITAL_BASE+0x0019)
-#define WSA881X_DEM_BYPASS_DATA1		(WSA881X_DIGITAL_BASE+0x001A)
-#define WSA881X_DEM_BYPASS_DATA2		(WSA881X_DIGITAL_BASE+0x001B)
-#define WSA881X_DEM_BYPASS_DATA3		(WSA881X_DIGITAL_BASE+0x001C)
-#define WSA881X_OTP_CTRL0			(WSA881X_DIGITAL_BASE+0x001D)
-#define WSA881X_OTP_CTRL1			(WSA881X_DIGITAL_BASE+0x001E)
-#define WSA881X_HDRIVE_CTL_GROUP1		(WSA881X_DIGITAL_BASE+0x001F)
-#define WSA881X_INTR_MODE			(WSA881X_DIGITAL_BASE+0x0020)
-#define WSA881X_INTR_MASK			(WSA881X_DIGITAL_BASE+0x0021)
-#define WSA881X_INTR_STATUS			(WSA881X_DIGITAL_BASE+0x0022)
-#define WSA881X_INTR_CLEAR			(WSA881X_DIGITAL_BASE+0x0023)
-#define WSA881X_INTR_LEVEL			(WSA881X_DIGITAL_BASE+0x0024)
-#define WSA881X_INTR_SET			(WSA881X_DIGITAL_BASE+0x0025)
-#define WSA881X_INTR_TEST			(WSA881X_DIGITAL_BASE+0x0026)
-#define WSA881X_PDM_TEST_MODE			(WSA881X_DIGITAL_BASE+0x0030)
-#define WSA881X_ATE_TEST_MODE			(WSA881X_DIGITAL_BASE+0x0031)
-#define WSA881X_PIN_CTL_MODE			(WSA881X_DIGITAL_BASE+0x0032)
-#define WSA881X_PIN_CTL_OE			(WSA881X_DIGITAL_BASE+0x0033)
-#define WSA881X_PIN_WDATA_IOPAD			(WSA881X_DIGITAL_BASE+0x0034)
-#define WSA881X_PIN_STATUS			(WSA881X_DIGITAL_BASE+0x0035)
-#define WSA881X_DIG_DEBUG_MODE			(WSA881X_DIGITAL_BASE+0x0037)
-#define WSA881X_DIG_DEBUG_SEL			(WSA881X_DIGITAL_BASE+0x0038)
-#define WSA881X_DIG_DEBUG_EN			(WSA881X_DIGITAL_BASE+0x0039)
-#define WSA881X_SWR_HM_TEST1			(WSA881X_DIGITAL_BASE+0x003B)
-#define WSA881X_SWR_HM_TEST2			(WSA881X_DIGITAL_BASE+0x003C)
-#define WSA881X_TEMP_DETECT_DBG_CTL		(WSA881X_DIGITAL_BASE+0x003D)
-#define WSA881X_TEMP_DEBUG_MSB			(WSA881X_DIGITAL_BASE+0x003E)
-#define WSA881X_TEMP_DEBUG_LSB			(WSA881X_DIGITAL_BASE+0x003F)
-#define WSA881X_SAMPLE_EDGE_SEL			(WSA881X_DIGITAL_BASE+0x0044)
-#define WSA881X_IOPAD_CTL			(WSA881X_DIGITAL_BASE+0x0045)
-#define WSA881X_SPARE_0				(WSA881X_DIGITAL_BASE+0x0050)
-#define WSA881X_SPARE_1				(WSA881X_DIGITAL_BASE+0x0051)
-#define WSA881X_SPARE_2				(WSA881X_DIGITAL_BASE+0x0052)
-#define WSA881X_OTP_REG_0			(WSA881X_DIGITAL_BASE+0x0080)
-#define WSA881X_OTP_REG_1			(WSA881X_DIGITAL_BASE+0x0081)
-#define WSA881X_OTP_REG_2			(WSA881X_DIGITAL_BASE+0x0082)
-#define WSA881X_OTP_REG_3			(WSA881X_DIGITAL_BASE+0x0083)
-#define WSA881X_OTP_REG_4			(WSA881X_DIGITAL_BASE+0x0084)
-#define WSA881X_OTP_REG_5			(WSA881X_DIGITAL_BASE+0x0085)
-#define WSA881X_OTP_REG_6			(WSA881X_DIGITAL_BASE+0x0086)
-#define WSA881X_OTP_REG_7			(WSA881X_DIGITAL_BASE+0x0087)
-#define WSA881X_OTP_REG_8			(WSA881X_DIGITAL_BASE+0x0088)
-#define WSA881X_OTP_REG_9			(WSA881X_DIGITAL_BASE+0x0089)
-#define WSA881X_OTP_REG_10			(WSA881X_DIGITAL_BASE+0x008A)
-#define WSA881X_OTP_REG_11			(WSA881X_DIGITAL_BASE+0x008B)
-#define WSA881X_OTP_REG_12			(WSA881X_DIGITAL_BASE+0x008C)
-#define WSA881X_OTP_REG_13			(WSA881X_DIGITAL_BASE+0x008D)
-#define WSA881X_OTP_REG_14			(WSA881X_DIGITAL_BASE+0x008E)
-#define WSA881X_OTP_REG_15			(WSA881X_DIGITAL_BASE+0x008F)
-#define WSA881X_OTP_REG_16			(WSA881X_DIGITAL_BASE+0x0090)
-#define WSA881X_OTP_REG_17			(WSA881X_DIGITAL_BASE+0x0091)
-#define WSA881X_OTP_REG_18			(WSA881X_DIGITAL_BASE+0x0092)
-#define WSA881X_OTP_REG_19			(WSA881X_DIGITAL_BASE+0x0093)
-#define WSA881X_OTP_REG_20			(WSA881X_DIGITAL_BASE+0x0094)
-#define WSA881X_OTP_REG_21			(WSA881X_DIGITAL_BASE+0x0095)
-#define WSA881X_OTP_REG_22			(WSA881X_DIGITAL_BASE+0x0096)
-#define WSA881X_OTP_REG_23			(WSA881X_DIGITAL_BASE+0x0097)
-#define WSA881X_OTP_REG_24			(WSA881X_DIGITAL_BASE+0x0098)
-#define WSA881X_OTP_REG_25			(WSA881X_DIGITAL_BASE+0x0099)
-#define WSA881X_OTP_REG_26			(WSA881X_DIGITAL_BASE+0x009A)
-#define WSA881X_OTP_REG_27			(WSA881X_DIGITAL_BASE+0x009B)
-#define WSA881X_OTP_REG_28			(WSA881X_DIGITAL_BASE+0x009C)
-#define WSA881X_OTP_REG_29			(WSA881X_DIGITAL_BASE+0x009D)
-#define WSA881X_OTP_REG_30			(WSA881X_DIGITAL_BASE+0x009E)
-#define WSA881X_OTP_REG_31			(WSA881X_DIGITAL_BASE+0x009F)
-#define WSA881X_OTP_REG_63			(WSA881X_DIGITAL_BASE+0x00BF)
-
-/* Analog Register address space */
-#define WSA881X_BIAS_REF_CTRL			(WSA881X_ANALOG_BASE+0x0000)
-#define WSA881X_BIAS_TEST			(WSA881X_ANALOG_BASE+0x0001)
-#define WSA881X_BIAS_BIAS			(WSA881X_ANALOG_BASE+0x0002)
-#define WSA881X_TEMP_OP				(WSA881X_ANALOG_BASE+0x0003)
-#define WSA881X_TEMP_IREF_CTRL			(WSA881X_ANALOG_BASE+0x0004)
-#define WSA881X_TEMP_ISENS_CTRL			(WSA881X_ANALOG_BASE+0x0005)
-#define WSA881X_TEMP_CLK_CTRL			(WSA881X_ANALOG_BASE+0x0006)
-#define WSA881X_TEMP_TEST			(WSA881X_ANALOG_BASE+0x0007)
-#define WSA881X_TEMP_BIAS			(WSA881X_ANALOG_BASE+0x0008)
-#define WSA881X_TEMP_ADC_CTRL			(WSA881X_ANALOG_BASE+0x0009)
-#define WSA881X_TEMP_DOUT_MSB			(WSA881X_ANALOG_BASE+0x000A)
-#define WSA881X_TEMP_DOUT_LSB			(WSA881X_ANALOG_BASE+0x000B)
-#define WSA881X_ADC_EN_MODU_V			(WSA881X_ANALOG_BASE+0x0010)
-#define WSA881X_ADC_EN_MODU_I			(WSA881X_ANALOG_BASE+0x0011)
-#define WSA881X_ADC_EN_DET_TEST_V		(WSA881X_ANALOG_BASE+0x0012)
-#define WSA881X_ADC_EN_DET_TEST_I		(WSA881X_ANALOG_BASE+0x0013)
-#define WSA881X_ADC_SEL_IBIAS			(WSA881X_ANALOG_BASE+0x0014)
-#define WSA881X_ADC_EN_SEL_IBAIS		(WSA881X_ANALOG_BASE+0x0015)
-#define WSA881X_SPKR_DRV_EN			(WSA881X_ANALOG_BASE+0x001A)
-#define WSA881X_SPKR_DRV_GAIN			(WSA881X_ANALOG_BASE+0x001B)
-#define WSA881X_SPKR_DAC_CTL			(WSA881X_ANALOG_BASE+0x001C)
-#define WSA881X_SPKR_DRV_DBG			(WSA881X_ANALOG_BASE+0x001D)
-#define WSA881X_SPKR_PWRSTG_DBG			(WSA881X_ANALOG_BASE+0x001E)
-#define WSA881X_SPKR_OCP_CTL			(WSA881X_ANALOG_BASE+0x001F)
-#define WSA881X_SPKR_CLIP_CTL			(WSA881X_ANALOG_BASE+0x0020)
-#define WSA881X_SPKR_BBM_CTL			(WSA881X_ANALOG_BASE+0x0021)
-#define WSA881X_SPKR_MISC_CTL1			(WSA881X_ANALOG_BASE+0x0022)
-#define WSA881X_SPKR_MISC_CTL2			(WSA881X_ANALOG_BASE+0x0023)
-#define WSA881X_SPKR_BIAS_INT			(WSA881X_ANALOG_BASE+0x0024)
-#define WSA881X_SPKR_PA_INT			(WSA881X_ANALOG_BASE+0x0025)
-#define WSA881X_SPKR_BIAS_CAL			(WSA881X_ANALOG_BASE+0x0026)
-#define WSA881X_SPKR_BIAS_PSRR			(WSA881X_ANALOG_BASE+0x0027)
-#define WSA881X_SPKR_STATUS1			(WSA881X_ANALOG_BASE+0x0028)
-#define WSA881X_SPKR_STATUS2			(WSA881X_ANALOG_BASE+0x0029)
-#define WSA881X_BOOST_EN_CTL			(WSA881X_ANALOG_BASE+0x002A)
-#define WSA881X_BOOST_CURRENT_LIMIT		(WSA881X_ANALOG_BASE+0x002B)
-#define WSA881X_BOOST_PS_CTL			(WSA881X_ANALOG_BASE+0x002C)
-#define WSA881X_BOOST_PRESET_OUT1		(WSA881X_ANALOG_BASE+0x002D)
-#define WSA881X_BOOST_PRESET_OUT2		(WSA881X_ANALOG_BASE+0x002E)
-#define WSA881X_BOOST_FORCE_OUT			(WSA881X_ANALOG_BASE+0x002F)
-#define WSA881X_BOOST_LDO_PROG			(WSA881X_ANALOG_BASE+0x0030)
-#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB	(WSA881X_ANALOG_BASE+0x0031)
-#define WSA881X_BOOST_RON_CTL			(WSA881X_ANALOG_BASE+0x0032)
-#define WSA881X_BOOST_LOOP_STABILITY		(WSA881X_ANALOG_BASE+0x0033)
-#define WSA881X_BOOST_ZX_CTL			(WSA881X_ANALOG_BASE+0x0034)
-#define WSA881X_BOOST_START_CTL			(WSA881X_ANALOG_BASE+0x0035)
-#define WSA881X_BOOST_MISC1_CTL			(WSA881X_ANALOG_BASE+0x0036)
-#define WSA881X_BOOST_MISC2_CTL			(WSA881X_ANALOG_BASE+0x0037)
-#define WSA881X_BOOST_MISC3_CTL			(WSA881X_ANALOG_BASE+0x0038)
-#define WSA881X_BOOST_ATEST_CTL			(WSA881X_ANALOG_BASE+0x0039)
-#define WSA881X_SPKR_PROT_FE_GAIN		(WSA881X_ANALOG_BASE+0x003A)
-#define WSA881X_SPKR_PROT_FE_CM_LDO_SET		(WSA881X_ANALOG_BASE+0x003B)
-#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1	(WSA881X_ANALOG_BASE+0x003C)
-#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2	(WSA881X_ANALOG_BASE+0x003D)
-#define WSA881X_SPKR_PROT_ATEST1		(WSA881X_ANALOG_BASE+0x003E)
-#define WSA881X_SPKR_PROT_ATEST2		(WSA881X_ANALOG_BASE+0x003F)
-#define WSA881X_SPKR_PROT_FE_VSENSE_VCM		(WSA881X_ANALOG_BASE+0x0040)
-#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1	(WSA881X_ANALOG_BASE+0x0041)
-#define WSA881X_BONGO_RESRV_REG1		(WSA881X_ANALOG_BASE+0x0042)
-#define WSA881X_BONGO_RESRV_REG2		(WSA881X_ANALOG_BASE+0x0043)
-#define WSA881X_SPKR_PROT_SAR			(WSA881X_ANALOG_BASE+0x0044)
-#define WSA881X_SPKR_STATUS3			(WSA881X_ANALOG_BASE+0x0045)
-
-#define WSA881X_NUM_REGISTERS			(WSA881X_SPKR_STATUS3+1)
-#define WSA881X_MAX_REGISTER			(WSA881X_NUM_REGISTERS-1)
-#define WSA881X_CACHE_SIZE			WSA881X_NUM_REGISTERS
-
-#endif /* WSA881X_REGISTERS_H */
diff --git a/sound/soc/codecs/wsa881x-regmap.c b/sound/soc/codecs/wsa881x-regmap.c
deleted file mode 100644
index 63bbbfa..0000000
--- a/sound/soc/codecs/wsa881x-regmap.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/regmap.h>
-#include <linux/device.h>
-#include "wsa881x-registers.h"
-#include "wsa881x.h"
-
-/*
- * Default register reset values that are common across different versions
- * are defined here. If a register reset value is changed based on version
- * then remove it from this structure and add it in version specific
- * structures.
- */
-static struct reg_default wsa881x_defaults[] = {
-	{WSA881X_CHIP_ID0, 0x00},
-	{WSA881X_CHIP_ID1, 0x00},
-	{WSA881X_CHIP_ID2, 0x00},
-	{WSA881X_CHIP_ID3, 0x02},
-	{WSA881X_BUS_ID, 0x00},
-	{WSA881X_CDC_RST_CTL, 0x00},
-	{WSA881X_CDC_TOP_CLK_CTL, 0x03},
-	{WSA881X_CDC_ANA_CLK_CTL, 0x00},
-	{WSA881X_CDC_DIG_CLK_CTL, 0x00},
-	{WSA881X_CLOCK_CONFIG, 0x00},
-	{WSA881X_ANA_CTL, 0x08},
-	{WSA881X_SWR_RESET_EN, 0x00},
-	{WSA881X_TEMP_DETECT_CTL, 0x01},
-	{WSA881X_TEMP_MSB, 0x00},
-	{WSA881X_TEMP_LSB, 0x00},
-	{WSA881X_TEMP_CONFIG0, 0x00},
-	{WSA881X_TEMP_CONFIG1, 0x00},
-	{WSA881X_CDC_CLIP_CTL, 0x03},
-	{WSA881X_SDM_PDM9_LSB, 0x00},
-	{WSA881X_SDM_PDM9_MSB, 0x00},
-	{WSA881X_CDC_RX_CTL, 0x7E},
-	{WSA881X_DEM_BYPASS_DATA0, 0x00},
-	{WSA881X_DEM_BYPASS_DATA1, 0x00},
-	{WSA881X_DEM_BYPASS_DATA2, 0x00},
-	{WSA881X_DEM_BYPASS_DATA3, 0x00},
-	{WSA881X_OTP_CTRL0, 0x00},
-	{WSA881X_OTP_CTRL1, 0x00},
-	{WSA881X_HDRIVE_CTL_GROUP1, 0x00},
-	{WSA881X_INTR_MODE, 0x00},
-	{WSA881X_INTR_STATUS, 0x00},
-	{WSA881X_INTR_CLEAR, 0x00},
-	{WSA881X_INTR_LEVEL, 0x00},
-	{WSA881X_INTR_SET, 0x00},
-	{WSA881X_INTR_TEST, 0x00},
-	{WSA881X_PDM_TEST_MODE, 0x00},
-	{WSA881X_ATE_TEST_MODE, 0x00},
-	{WSA881X_PIN_CTL_MODE, 0x00},
-	{WSA881X_PIN_CTL_OE, 0x00},
-	{WSA881X_PIN_WDATA_IOPAD, 0x00},
-	{WSA881X_PIN_STATUS, 0x00},
-	{WSA881X_DIG_DEBUG_MODE, 0x00},
-	{WSA881X_DIG_DEBUG_SEL, 0x00},
-	{WSA881X_DIG_DEBUG_EN, 0x00},
-	{WSA881X_SWR_HM_TEST1, 0x08},
-	{WSA881X_SWR_HM_TEST2, 0x00},
-	{WSA881X_TEMP_DETECT_DBG_CTL, 0x00},
-	{WSA881X_TEMP_DEBUG_MSB, 0x00},
-	{WSA881X_TEMP_DEBUG_LSB, 0x00},
-	{WSA881X_SAMPLE_EDGE_SEL, 0x0C},
-	{WSA881X_SPARE_0, 0x00},
-	{WSA881X_SPARE_1, 0x00},
-	{WSA881X_SPARE_2, 0x00},
-	{WSA881X_OTP_REG_0, 0x01},
-	{WSA881X_OTP_REG_1, 0xFF},
-	{WSA881X_OTP_REG_2, 0xC0},
-	{WSA881X_OTP_REG_3, 0xFF},
-	{WSA881X_OTP_REG_4, 0xC0},
-	{WSA881X_OTP_REG_5, 0xFF},
-	{WSA881X_OTP_REG_6, 0xFF},
-	{WSA881X_OTP_REG_7, 0xFF},
-	{WSA881X_OTP_REG_8, 0xFF},
-	{WSA881X_OTP_REG_9, 0xFF},
-	{WSA881X_OTP_REG_10, 0xFF},
-	{WSA881X_OTP_REG_11, 0xFF},
-	{WSA881X_OTP_REG_12, 0xFF},
-	{WSA881X_OTP_REG_13, 0xFF},
-	{WSA881X_OTP_REG_14, 0xFF},
-	{WSA881X_OTP_REG_15, 0xFF},
-	{WSA881X_OTP_REG_16, 0xFF},
-	{WSA881X_OTP_REG_17, 0xFF},
-	{WSA881X_OTP_REG_18, 0xFF},
-	{WSA881X_OTP_REG_19, 0xFF},
-	{WSA881X_OTP_REG_20, 0xFF},
-	{WSA881X_OTP_REG_21, 0xFF},
-	{WSA881X_OTP_REG_22, 0xFF},
-	{WSA881X_OTP_REG_23, 0xFF},
-	{WSA881X_OTP_REG_24, 0x03},
-	{WSA881X_OTP_REG_25, 0x01},
-	{WSA881X_OTP_REG_26, 0x03},
-	{WSA881X_OTP_REG_27, 0x11},
-	{WSA881X_OTP_REG_63, 0x40},
-	/* WSA881x Analog registers */
-	{WSA881X_BIAS_REF_CTRL, 0x6C},
-	{WSA881X_BIAS_TEST, 0x16},
-	{WSA881X_BIAS_BIAS, 0xF0},
-	{WSA881X_TEMP_OP, 0x00},
-	{WSA881X_TEMP_IREF_CTRL, 0x56},
-	{WSA881X_TEMP_ISENS_CTRL, 0x47},
-	{WSA881X_TEMP_CLK_CTRL, 0x87},
-	{WSA881X_TEMP_TEST, 0x00},
-	{WSA881X_TEMP_BIAS, 0x51},
-	{WSA881X_TEMP_DOUT_MSB, 0x00},
-	{WSA881X_TEMP_DOUT_LSB, 0x00},
-	{WSA881X_ADC_EN_MODU_V, 0x00},
-	{WSA881X_ADC_EN_MODU_I, 0x00},
-	{WSA881X_ADC_EN_DET_TEST_V, 0x00},
-	{WSA881X_ADC_EN_DET_TEST_I, 0x00},
-	{WSA881X_ADC_EN_SEL_IBAIS, 0x10},
-	{WSA881X_SPKR_DRV_EN, 0x74},
-	{WSA881X_SPKR_DRV_DBG, 0x15},
-	{WSA881X_SPKR_PWRSTG_DBG, 0x00},
-	{WSA881X_SPKR_OCP_CTL, 0xD4},
-	{WSA881X_SPKR_CLIP_CTL, 0x90},
-	{WSA881X_SPKR_PA_INT, 0x54},
-	{WSA881X_SPKR_BIAS_CAL, 0xAC},
-	{WSA881X_SPKR_STATUS1, 0x00},
-	{WSA881X_SPKR_STATUS2, 0x00},
-	{WSA881X_BOOST_EN_CTL, 0x18},
-	{WSA881X_BOOST_CURRENT_LIMIT, 0x7A},
-	{WSA881X_BOOST_PRESET_OUT2, 0x70},
-	{WSA881X_BOOST_FORCE_OUT, 0x0E},
-	{WSA881X_BOOST_LDO_PROG, 0x16},
-	{WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x71},
-	{WSA881X_BOOST_RON_CTL, 0x0F},
-	{WSA881X_BOOST_ZX_CTL, 0x34},
-	{WSA881X_BOOST_START_CTL, 0x23},
-	{WSA881X_BOOST_MISC1_CTL, 0x80},
-	{WSA881X_BOOST_MISC2_CTL, 0x00},
-	{WSA881X_BOOST_MISC3_CTL, 0x00},
-	{WSA881X_BOOST_ATEST_CTL, 0x00},
-	{WSA881X_SPKR_PROT_FE_GAIN, 0x46},
-	{WSA881X_SPKR_PROT_FE_CM_LDO_SET, 0x3B},
-	{WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1, 0x8D},
-	{WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2, 0x8D},
-	{WSA881X_SPKR_PROT_ATEST1, 0x01},
-	{WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x8D},
-	{WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1, 0x4D},
-	{WSA881X_SPKR_PROT_SAR, 0x00},
-	{WSA881X_SPKR_STATUS3, 0x00},
-};
-
-/* Default register reset values for WSA881x rev 2.0 */
-static struct reg_sequence wsa881x_rev_2_0[] = {
-	{WSA881X_RESET_CTL, 0x00, 0x00},
-	{WSA881X_TADC_VALUE_CTL, 0x01, 0x00},
-	{WSA881X_INTR_MASK, 0x1B, 0x00},
-	{WSA881X_IOPAD_CTL, 0x00, 0x00},
-	{WSA881X_OTP_REG_28, 0x3F, 0x00},
-	{WSA881X_OTP_REG_29, 0x3F, 0x00},
-	{WSA881X_OTP_REG_30, 0x01, 0x00},
-	{WSA881X_OTP_REG_31, 0x01, 0x00},
-	{WSA881X_TEMP_ADC_CTRL, 0x03, 0x00},
-	{WSA881X_ADC_SEL_IBIAS, 0x45, 0x00},
-	{WSA881X_SPKR_DRV_GAIN, 0xC1, 0x00},
-	{WSA881X_SPKR_DAC_CTL, 0x42, 0x00},
-	{WSA881X_SPKR_BBM_CTL, 0x02, 0x00},
-	{WSA881X_SPKR_MISC_CTL1, 0x40, 0x00},
-	{WSA881X_SPKR_MISC_CTL2, 0x07, 0x00},
-	{WSA881X_SPKR_BIAS_INT, 0x5F, 0x00},
-	{WSA881X_SPKR_BIAS_PSRR, 0x44, 0x00},
-	{WSA881X_BOOST_PS_CTL, 0xA0, 0x00},
-	{WSA881X_BOOST_PRESET_OUT1, 0xB7, 0x00},
-	{WSA881X_BOOST_LOOP_STABILITY, 0x8D, 0x00},
-	{WSA881X_SPKR_PROT_ATEST2, 0x02, 0x00},
-	{WSA881X_BONGO_RESRV_REG1, 0x5E, 0x00},
-	{WSA881X_BONGO_RESRV_REG2, 0x07, 0x00},
-};
-
-/*
- * wsa881x_regmap_defaults - update regmap default register values
- * @regmap: pointer to regmap structure
- * @version: wsa881x version id
- *
- * Update regmap default register values based on version id
- *
- */
-void wsa881x_regmap_defaults(struct regmap *regmap, u8 version)
-{
-	u16 ret = 0;
-
-	if (!regmap) {
-		pr_debug("%s: regmap structure is NULL\n", __func__);
-		return;
-	}
-
-	regcache_cache_only(regmap, true);
-	ret = regmap_multi_reg_write(regmap, wsa881x_rev_2_0,
-				     ARRAY_SIZE(wsa881x_rev_2_0));
-	regcache_cache_only(regmap, false);
-
-	if (ret)
-		pr_debug("%s: Failed to update regmap defaults ret= %d\n",
-			 __func__, ret);
-}
-EXPORT_SYMBOL(wsa881x_regmap_defaults);
-
-static bool wsa881x_readable_register(struct device *dev, unsigned int reg)
-{
-	return wsa881x_reg_readable[reg];
-}
-
-static bool wsa881x_volatile_register(struct device *dev, unsigned int reg)
-{
-	switch (reg) {
-	case WSA881X_CHIP_ID0:
-	case WSA881X_CHIP_ID1:
-	case WSA881X_CHIP_ID2:
-	case WSA881X_CHIP_ID3:
-	case WSA881X_BUS_ID:
-	case WSA881X_TEMP_MSB:
-	case WSA881X_TEMP_LSB:
-	case WSA881X_SDM_PDM9_LSB:
-	case WSA881X_SDM_PDM9_MSB:
-	case WSA881X_OTP_CTRL1:
-	case WSA881X_INTR_STATUS:
-	case WSA881X_ATE_TEST_MODE:
-	case WSA881X_PIN_STATUS:
-	case WSA881X_SWR_HM_TEST2:
-	case WSA881X_SPKR_STATUS1:
-	case WSA881X_SPKR_STATUS2:
-	case WSA881X_SPKR_STATUS3:
-	case WSA881X_OTP_REG_0:
-	case WSA881X_OTP_REG_1:
-	case WSA881X_OTP_REG_2:
-	case WSA881X_OTP_REG_3:
-	case WSA881X_OTP_REG_4:
-	case WSA881X_OTP_REG_5:
-	case WSA881X_OTP_REG_31:
-	case WSA881X_TEMP_DOUT_MSB:
-	case WSA881X_TEMP_DOUT_LSB:
-	case WSA881X_TEMP_OP:
-	case WSA881X_SPKR_PROT_SAR:
-		return true;
-	default:
-		return false;
-	}
-}
-
-struct regmap_config wsa881x_regmap_config = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.cache_type = REGCACHE_RBTREE,
-	.reg_defaults = wsa881x_defaults,
-	.num_reg_defaults = ARRAY_SIZE(wsa881x_defaults),
-	.max_register = WSA881X_MAX_REGISTER,
-	.volatile_reg = wsa881x_volatile_register,
-	.readable_reg = wsa881x_readable_register,
-	.reg_format_endian = REGMAP_ENDIAN_NATIVE,
-	.val_format_endian = REGMAP_ENDIAN_NATIVE,
-	.can_multi_write = true,
-};
diff --git a/sound/soc/codecs/wsa881x-tables.c b/sound/soc/codecs/wsa881x-tables.c
deleted file mode 100644
index 4f1212b..0000000
--- a/sound/soc/codecs/wsa881x-tables.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/regmap.h>
-#include <linux/device.h>
-#include "wsa881x-registers.h"
-
-const u8 wsa881x_reg_readable[WSA881X_CACHE_SIZE] = {
-	[WSA881X_CHIP_ID0] = 1,
-	[WSA881X_CHIP_ID1] = 1,
-	[WSA881X_CHIP_ID2] = 1,
-	[WSA881X_CHIP_ID3] = 1,
-	[WSA881X_BUS_ID] = 1,
-	[WSA881X_CDC_RST_CTL] = 1,
-	[WSA881X_CDC_TOP_CLK_CTL] = 1,
-	[WSA881X_CDC_ANA_CLK_CTL] = 1,
-	[WSA881X_CDC_DIG_CLK_CTL] = 1,
-	[WSA881X_CLOCK_CONFIG] = 1,
-	[WSA881X_ANA_CTL] = 1,
-	[WSA881X_SWR_RESET_EN] = 1,
-	[WSA881X_RESET_CTL] = 1,
-	[WSA881X_TADC_VALUE_CTL] = 1,
-	[WSA881X_TEMP_DETECT_CTL] = 1,
-	[WSA881X_TEMP_MSB] = 1,
-	[WSA881X_TEMP_LSB] = 1,
-	[WSA881X_TEMP_CONFIG0] = 1,
-	[WSA881X_TEMP_CONFIG1] = 1,
-	[WSA881X_CDC_CLIP_CTL] = 1,
-	[WSA881X_SDM_PDM9_LSB] = 1,
-	[WSA881X_SDM_PDM9_MSB] = 1,
-	[WSA881X_CDC_RX_CTL] = 1,
-	[WSA881X_DEM_BYPASS_DATA0] = 1,
-	[WSA881X_DEM_BYPASS_DATA1] = 1,
-	[WSA881X_DEM_BYPASS_DATA2] = 1,
-	[WSA881X_DEM_BYPASS_DATA3] = 1,
-	[WSA881X_OTP_CTRL0] = 1,
-	[WSA881X_OTP_CTRL1] = 1,
-	[WSA881X_HDRIVE_CTL_GROUP1] = 1,
-	[WSA881X_INTR_MODE] = 1,
-	[WSA881X_INTR_MASK] = 1,
-	[WSA881X_INTR_STATUS] = 1,
-	[WSA881X_INTR_CLEAR] = 1,
-	[WSA881X_INTR_LEVEL] = 1,
-	[WSA881X_INTR_SET] = 1,
-	[WSA881X_INTR_TEST] = 1,
-	[WSA881X_PDM_TEST_MODE] = 1,
-	[WSA881X_ATE_TEST_MODE] = 1,
-	[WSA881X_PIN_CTL_MODE] = 1,
-	[WSA881X_PIN_CTL_OE] = 1,
-	[WSA881X_PIN_WDATA_IOPAD] = 1,
-	[WSA881X_PIN_STATUS] = 1,
-	[WSA881X_DIG_DEBUG_MODE] = 1,
-	[WSA881X_DIG_DEBUG_SEL] = 1,
-	[WSA881X_DIG_DEBUG_EN] = 1,
-	[WSA881X_SWR_HM_TEST1] = 1,
-	[WSA881X_SWR_HM_TEST2] = 1,
-	[WSA881X_TEMP_DETECT_DBG_CTL] = 1,
-	[WSA881X_TEMP_DEBUG_MSB] = 1,
-	[WSA881X_TEMP_DEBUG_LSB] = 1,
-	[WSA881X_SAMPLE_EDGE_SEL] = 1,
-	[WSA881X_IOPAD_CTL] = 1,
-	[WSA881X_SPARE_0] = 1,
-	[WSA881X_SPARE_1] = 1,
-	[WSA881X_SPARE_2] = 1,
-	[WSA881X_OTP_REG_0] = 1,
-	[WSA881X_OTP_REG_1] = 1,
-	[WSA881X_OTP_REG_2] = 1,
-	[WSA881X_OTP_REG_3] = 1,
-	[WSA881X_OTP_REG_4] = 1,
-	[WSA881X_OTP_REG_5] = 1,
-	[WSA881X_OTP_REG_6] = 1,
-	[WSA881X_OTP_REG_7] = 1,
-	[WSA881X_OTP_REG_8] = 1,
-	[WSA881X_OTP_REG_9] = 1,
-	[WSA881X_OTP_REG_10] = 1,
-	[WSA881X_OTP_REG_11] = 1,
-	[WSA881X_OTP_REG_12] = 1,
-	[WSA881X_OTP_REG_13] = 1,
-	[WSA881X_OTP_REG_14] = 1,
-	[WSA881X_OTP_REG_15] = 1,
-	[WSA881X_OTP_REG_16] = 1,
-	[WSA881X_OTP_REG_17] = 1,
-	[WSA881X_OTP_REG_18] = 1,
-	[WSA881X_OTP_REG_19] = 1,
-	[WSA881X_OTP_REG_20] = 1,
-	[WSA881X_OTP_REG_21] = 1,
-	[WSA881X_OTP_REG_22] = 1,
-	[WSA881X_OTP_REG_23] = 1,
-	[WSA881X_OTP_REG_24] = 1,
-	[WSA881X_OTP_REG_25] = 1,
-	[WSA881X_OTP_REG_26] = 1,
-	[WSA881X_OTP_REG_27] = 1,
-	[WSA881X_OTP_REG_28] = 1,
-	[WSA881X_OTP_REG_29] = 1,
-	[WSA881X_OTP_REG_30] = 1,
-	[WSA881X_OTP_REG_31] = 1,
-	[WSA881X_OTP_REG_63] = 1,
-	/* Analog Registers */
-	[WSA881X_BIAS_REF_CTRL] = 1,
-	[WSA881X_BIAS_TEST] = 1,
-	[WSA881X_BIAS_BIAS] = 1,
-	[WSA881X_TEMP_OP] = 1,
-	[WSA881X_TEMP_IREF_CTRL] = 1,
-	[WSA881X_TEMP_ISENS_CTRL] = 1,
-	[WSA881X_TEMP_CLK_CTRL] = 1,
-	[WSA881X_TEMP_TEST] = 1,
-	[WSA881X_TEMP_BIAS] = 1,
-	[WSA881X_TEMP_ADC_CTRL] = 1,
-	[WSA881X_TEMP_DOUT_MSB] = 1,
-	[WSA881X_TEMP_DOUT_LSB] = 1,
-	[WSA881X_ADC_EN_MODU_V] = 1,
-	[WSA881X_ADC_EN_MODU_I] = 1,
-	[WSA881X_ADC_EN_DET_TEST_V] = 1,
-	[WSA881X_ADC_EN_DET_TEST_I] = 1,
-	[WSA881X_ADC_SEL_IBIAS] = 1,
-	[WSA881X_ADC_EN_SEL_IBAIS] = 1,
-	[WSA881X_SPKR_DRV_EN] = 1,
-	[WSA881X_SPKR_DRV_GAIN] = 1,
-	[WSA881X_SPKR_DAC_CTL] = 1,
-	[WSA881X_SPKR_DRV_DBG] = 1,
-	[WSA881X_SPKR_PWRSTG_DBG] = 1,
-	[WSA881X_SPKR_OCP_CTL] = 1,
-	[WSA881X_SPKR_CLIP_CTL] = 1,
-	[WSA881X_SPKR_BBM_CTL] = 1,
-	[WSA881X_SPKR_MISC_CTL1] = 1,
-	[WSA881X_SPKR_MISC_CTL2] = 1,
-	[WSA881X_SPKR_BIAS_INT] = 1,
-	[WSA881X_SPKR_PA_INT] = 1,
-	[WSA881X_SPKR_BIAS_CAL] = 1,
-	[WSA881X_SPKR_BIAS_PSRR] = 1,
-	[WSA881X_SPKR_STATUS1] = 1,
-	[WSA881X_SPKR_STATUS2] = 1,
-	[WSA881X_BOOST_EN_CTL] = 1,
-	[WSA881X_BOOST_CURRENT_LIMIT] = 1,
-	[WSA881X_BOOST_PS_CTL] = 1,
-	[WSA881X_BOOST_PRESET_OUT1] = 1,
-	[WSA881X_BOOST_PRESET_OUT2] = 1,
-	[WSA881X_BOOST_FORCE_OUT] = 1,
-	[WSA881X_BOOST_LDO_PROG] = 1,
-	[WSA881X_BOOST_SLOPE_COMP_ISENSE_FB] = 1,
-	[WSA881X_BOOST_RON_CTL] = 1,
-	[WSA881X_BOOST_LOOP_STABILITY] = 1,
-	[WSA881X_BOOST_ZX_CTL] = 1,
-	[WSA881X_BOOST_START_CTL] = 1,
-	[WSA881X_BOOST_MISC1_CTL] = 1,
-	[WSA881X_BOOST_MISC2_CTL] = 1,
-	[WSA881X_BOOST_MISC3_CTL] = 1,
-	[WSA881X_BOOST_ATEST_CTL] = 1,
-	[WSA881X_SPKR_PROT_FE_GAIN] = 1,
-	[WSA881X_SPKR_PROT_FE_CM_LDO_SET] = 1,
-	[WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1] = 1,
-	[WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2] = 1,
-	[WSA881X_SPKR_PROT_ATEST1] = 1,
-	[WSA881X_SPKR_PROT_ATEST2] = 1,
-	[WSA881X_SPKR_PROT_FE_VSENSE_VCM] = 1,
-	[WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1] = 1,
-	[WSA881X_BONGO_RESRV_REG1] = 1,
-	[WSA881X_BONGO_RESRV_REG2] = 1,
-	[WSA881X_SPKR_PROT_SAR] = 1,
-	[WSA881X_SPKR_STATUS3] = 1,
-};
diff --git a/sound/soc/codecs/wsa881x-temp-sensor.c b/sound/soc/codecs/wsa881x-temp-sensor.c
deleted file mode 100644
index 5ab0ecf..0000000
--- a/sound/soc/codecs/wsa881x-temp-sensor.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/bitops.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/thermal.h>
-#include <sound/soc.h>
-#include "wsa881x-temp-sensor.h"
-
-#define T1_TEMP -10
-#define T2_TEMP 150
-#define LOW_TEMP_THRESHOLD 5
-#define HIGH_TEMP_THRESHOLD 45
-#define TEMP_INVALID	0xFFFF
-#define WSA881X_TEMP_RETRY 3
-/*
- * wsa881x_get_temp - get wsa temperature
- * @thermal: thermal zone device
- * @temp: temperature value
- *
- * Get the temperature of wsa881x.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int wsa881x_get_temp(struct thermal_zone_device *thermal,
-		     int *temp)
-{
-	struct wsa881x_tz_priv *pdata;
-	struct snd_soc_codec *codec;
-	struct wsa_temp_register reg;
-	int dmeas, d1, d2;
-	int ret = 0;
-	int temp_val;
-	int t1 = T1_TEMP;
-	int t2 = T2_TEMP;
-	u8 retry = WSA881X_TEMP_RETRY;
-
-	if (!thermal)
-		return -EINVAL;
-
-	if (thermal->devdata) {
-		pdata = thermal->devdata;
-		if (pdata->codec) {
-			codec = pdata->codec;
-		} else {
-			pr_err("%s: codec is NULL\n", __func__);
-			return -EINVAL;
-		}
-	} else {
-		pr_err("%s: pdata is NULL\n", __func__);
-		return -EINVAL;
-	}
-temp_retry:
-	if (pdata->wsa_temp_reg_read) {
-		ret = pdata->wsa_temp_reg_read(codec, &reg);
-		if (ret) {
-			pr_err("%s: temperature register read failed: %d\n",
-				__func__, ret);
-			return ret;
-		}
-	} else {
-		pr_err("%s: wsa_temp_reg_read is NULL\n", __func__);
-		return -EINVAL;
-	}
-	/*
-	 * Temperature register values are expected to be in the
-	 * following range.
-	 * d1_msb  = 68 - 92 and d1_lsb  = 0, 64, 128, 192
-	 * d2_msb  = 185 -218 and  d2_lsb  = 0, 64, 128, 192
-	 */
-	if ((reg.d1_msb < 68 || reg.d1_msb > 92) ||
-	    (!(reg.d1_lsb == 0 || reg.d1_lsb == 64 || reg.d1_lsb == 128 ||
-		reg.d1_lsb == 192)) ||
-	    (reg.d2_msb < 185 || reg.d2_msb > 218) ||
-	    (!(reg.d2_lsb == 0 || reg.d2_lsb == 64 || reg.d2_lsb == 128 ||
-		reg.d2_lsb == 192))) {
-		printk_ratelimited("%s: Temperature registers[%d %d %d %d] are out of range\n",
-				   __func__, reg.d1_msb, reg.d1_lsb, reg.d2_msb,
-				   reg.d2_lsb);
-	}
-	dmeas = ((reg.dmeas_msb << 0x8) | reg.dmeas_lsb) >> 0x6;
-	d1 = ((reg.d1_msb << 0x8) | reg.d1_lsb) >> 0x6;
-	d2 = ((reg.d2_msb << 0x8) | reg.d2_lsb) >> 0x6;
-
-	if (d1 == d2)
-		temp_val = TEMP_INVALID;
-	else
-		temp_val = t1 + (((dmeas - d1) * (t2 - t1))/(d2 - d1));
-
-	if (temp_val <= LOW_TEMP_THRESHOLD ||
-		temp_val >= HIGH_TEMP_THRESHOLD) {
-		printk_ratelimited("%s: T0: %d is out of range[%d, %d]\n",
-				   __func__, temp_val, LOW_TEMP_THRESHOLD,
-				   HIGH_TEMP_THRESHOLD);
-		if (retry--) {
-			msleep(20);
-			goto temp_retry;
-		}
-	}
-	if (temp)
-		*temp = temp_val;
-	pr_debug("%s: t0 measured: %d dmeas = %d, d1 = %d, d2 = %d\n",
-		  __func__, temp_val, dmeas, d1, d2);
-	return ret;
-}
-EXPORT_SYMBOL(wsa881x_get_temp);
-
-static struct thermal_zone_device_ops wsa881x_thermal_ops = {
-	.get_temp = wsa881x_get_temp,
-};
-
-int wsa881x_init_thermal(struct wsa881x_tz_priv *tz_pdata)
-{
-	struct thermal_zone_device *tz_dev;
-
-	if (tz_pdata == NULL) {
-		pr_err("%s: thermal pdata is NULL\n", __func__);
-		return -EINVAL;
-	}
-	/* Register with the thermal zone */
-	tz_dev = thermal_zone_device_register(tz_pdata->name,
-				0, 0, tz_pdata,
-				&wsa881x_thermal_ops, NULL, 0, 0);
-	if (IS_ERR(tz_dev)) {
-		pr_err("%s: thermal device register failed.\n", __func__);
-		return -EINVAL;
-	}
-	tz_pdata->tz_dev = tz_dev;
-	return 0;
-}
-EXPORT_SYMBOL(wsa881x_init_thermal);
-
-void wsa881x_deinit_thermal(struct thermal_zone_device *tz_dev)
-{
-	if (tz_dev)
-		thermal_zone_device_unregister(tz_dev);
-}
-EXPORT_SYMBOL(wsa881x_deinit_thermal);
diff --git a/sound/soc/codecs/wsa881x-temp-sensor.h b/sound/soc/codecs/wsa881x-temp-sensor.h
deleted file mode 100644
index d6c1eb7..0000000
--- a/sound/soc/codecs/wsa881x-temp-sensor.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 WSA881X_TEMP_SENSOR_H
-#define WSA881X_TEMP_SENSOR_H
-
-#include <linux/thermal.h>
-#include <sound/soc.h>
-
-struct wsa_temp_register {
-	u8 d1_msb;
-	u8 d1_lsb;
-	u8 d2_msb;
-	u8 d2_lsb;
-	u8 dmeas_msb;
-	u8 dmeas_lsb;
-};
-typedef int32_t (*wsa_temp_register_read)(struct snd_soc_codec *codec,
-					struct wsa_temp_register *wsa_temp_reg);
-struct wsa881x_tz_priv {
-	struct thermal_zone_device *tz_dev;
-	struct snd_soc_codec *codec;
-	struct wsa_temp_register *wsa_temp_reg;
-	char name[80];
-	wsa_temp_register_read wsa_temp_reg_read;
-};
-
-int wsa881x_get_temp(struct thermal_zone_device *tz_dev, int *temp);
-int wsa881x_init_thermal(struct wsa881x_tz_priv *tz_pdata);
-void wsa881x_deinit_thermal(struct thermal_zone_device *tz_dev);
-#endif
diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c
deleted file mode 100644
index 77aea10..0000000
--- a/sound/soc/codecs/wsa881x.c
+++ /dev/null
@@ -1,1439 +0,0 @@
-/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/platform_device.h>
-#include <linux/device.h>
-#include <linux/printk.h>
-#include <linux/bitops.h>
-#include <linux/regulator/consumer.h>
-#include <linux/pm_runtime.h>
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <linux/regmap.h>
-#include <linux/debugfs.h>
-#include <linux/soundwire/soundwire.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include "wsa881x.h"
-#include "wsa881x-temp-sensor.h"
-
-#define WSA881X_NUM_RETRY	5
-
-enum {
-	G_18DB = 0,
-	G_16P5DB,
-	G_15DB,
-	G_13P5DB,
-	G_12DB,
-	G_10P5DB,
-	G_9DB,
-	G_7P5DB,
-	G_6DB,
-	G_4P5DB,
-	G_3DB,
-	G_1P5DB,
-	G_0DB,
-};
-
-enum {
-	DISABLE = 0,
-	ENABLE,
-};
-
-enum {
-	SWR_DAC_PORT,
-	SWR_COMP_PORT,
-	SWR_BOOST_PORT,
-	SWR_VISENSE_PORT,
-};
-
-struct swr_port {
-	u8 port_id;
-	u8 ch_mask;
-	u32 ch_rate;
-	u8 num_ch;
-};
-
-enum {
-	WSA881X_DEV_DOWN,
-	WSA881X_DEV_UP,
-};
-
-/*
- * Private data Structure for wsa881x. All parameters related to
- * WSA881X codec needs to be defined here.
- */
-struct wsa881x_priv {
-	struct regmap *regmap;
-	struct device *dev;
-	struct swr_device *swr_slave;
-	struct snd_soc_codec *codec;
-	bool comp_enable;
-	bool boost_enable;
-	bool visense_enable;
-	u8 pa_gain;
-	struct swr_port port[WSA881X_MAX_SWR_PORTS];
-	int pd_gpio;
-	struct wsa881x_tz_priv tz_pdata;
-	int bg_cnt;
-	int clk_cnt;
-	int version;
-	struct mutex bg_lock;
-	struct mutex res_lock;
-	struct snd_info_entry *entry;
-	struct snd_info_entry *version_entry;
-	int state;
-	struct delayed_work ocp_ctl_work;
-	struct device_node *wsa_rst_np;
-	int pa_mute;
-};
-
-#define SWR_SLV_MAX_REG_ADDR	0x390
-#define SWR_SLV_START_REG_ADDR	0x40
-#define SWR_SLV_MAX_BUF_LEN	20
-#define BYTES_PER_LINE		12
-#define SWR_SLV_RD_BUF_LEN	8
-#define SWR_SLV_WR_BUF_LEN	32
-#define SWR_SLV_MAX_DEVICES	2
-
-#define WSA881X_VERSION_ENTRY_SIZE 27
-#define WSA881X_OCP_CTL_TIMER_SEC 2
-#define WSA881X_OCP_CTL_TEMP_CELSIUS 25
-#define WSA881X_OCP_CTL_POLL_TIMER_SEC 60
-
-static int wsa881x_ocp_poll_timer_sec = WSA881X_OCP_CTL_POLL_TIMER_SEC;
-module_param(wsa881x_ocp_poll_timer_sec, int, 0664);
-MODULE_PARM_DESC(wsa881x_ocp_poll_timer_sec, "timer for ocp ctl polling");
-
-static struct wsa881x_priv *dbgwsa881x;
-static struct dentry *debugfs_wsa881x_dent;
-static struct dentry *debugfs_peek;
-static struct dentry *debugfs_poke;
-static struct dentry *debugfs_reg_dump;
-static unsigned int read_data;
-static unsigned int devnum;
-
-static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
-						bool enable);
-
-static const char * const wsa_pa_gain_text[] = {
-	"G_18_DB", "G_16P5_DB", "G_15_DB", "G_13P5_DB", "G_12_DB", "G_10P5_DB",
-	"G_9_DB", "G_7P5_DB", "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
-	"G_0_DB"
-};
-
-static const struct soc_enum wsa_pa_gain_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa_pa_gain_text), wsa_pa_gain_text);
-
-static int wsa_pa_gain_get(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = wsa881x->pa_gain;
-
-	dev_dbg(codec->dev, "%s: PA gain = 0x%x\n", __func__, wsa881x->pa_gain);
-
-	return 0;
-}
-
-static int wsa_pa_gain_put(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0]  = %ld\n",
-		__func__, ucontrol->value.integer.value[0]);
-
-	wsa881x->pa_gain =  ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int wsa881x_get_mute(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = wsa881x->pa_mute;
-
-	return 0;
-}
-
-static int wsa881x_set_mute(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: mute current %d, new %d\n",
-		__func__, wsa881x->pa_mute, value);
-
-	if (value)
-		snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x80, 0x00);
-	wsa881x->pa_mute = value;
-
-	return 0;
-}
-
-
-static const struct snd_kcontrol_new wsa_snd_controls[] = {
-	SOC_ENUM_EXT("WSA PA Gain", wsa_pa_gain_enum,
-		     wsa_pa_gain_get, wsa_pa_gain_put),
-	SOC_SINGLE_EXT("WSA PA Mute", SND_SOC_NOPM, 0, 1, 0,
-		wsa881x_get_mute, wsa881x_set_mute),
-};
-
-static int codec_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static int get_parameters(char *buf, u32 *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (kstrtou32(token, base, &param1[cnt]) != 0)
-				return -EINVAL;
-
-			token = strsep(&buf, " ");
-		} else
-			return -EINVAL;
-	}
-	return 0;
-}
-
-static ssize_t wsa881x_codec_version_read(struct snd_info_entry *entry,
-			       void *file_private_data, struct file *file,
-			       char __user *buf, size_t count, loff_t pos)
-{
-	struct wsa881x_priv *wsa881x;
-	char buffer[WSA881X_VERSION_ENTRY_SIZE];
-	int len;
-
-	wsa881x = (struct wsa881x_priv *) entry->private_data;
-	if (!wsa881x) {
-		pr_err("%s: wsa881x priv is null\n", __func__);
-		return -EINVAL;
-	}
-
-	len = snprintf(buffer, sizeof(buffer), "WSA881X-SOUNDWIRE_2_0\n");
-
-	return simple_read_from_buffer(buf, count, &pos, buffer, len);
-}
-
-static struct snd_info_entry_ops wsa881x_codec_info_ops = {
-	.read = wsa881x_codec_version_read,
-};
-
-/*
- * wsa881x_codec_info_create_codec_entry - creates wsa881x module
- * @codec_root: The parent directory
- * @codec: Codec instance
- *
- * Creates wsa881x module and version entry under the given
- * parent directory.
- *
- * Return: 0 on success or negative error code on failure.
- */
-int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
-					  struct snd_soc_codec *codec)
-{
-	struct snd_info_entry *version_entry;
-	struct wsa881x_priv *wsa881x;
-	struct snd_soc_card *card;
-	char name[80];
-
-	if (!codec_root || !codec)
-		return -EINVAL;
-
-	wsa881x = snd_soc_codec_get_drvdata(codec);
-	card = codec->component.card;
-	snprintf(name, sizeof(name), "%s.%x", "wsa881x",
-		 (u32)wsa881x->swr_slave->addr);
-
-	wsa881x->entry = snd_info_create_subdir(codec_root->module,
-						(const char *)name,
-						codec_root);
-	if (!wsa881x->entry) {
-		dev_dbg(codec->dev, "%s: failed to create wsa881x entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry = snd_info_create_card_entry(card->snd_card,
-						   "version",
-						   wsa881x->entry);
-	if (!version_entry) {
-		dev_dbg(codec->dev, "%s: failed to create wsa881x version entry\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	version_entry->private_data = wsa881x;
-	version_entry->size = WSA881X_VERSION_ENTRY_SIZE;
-	version_entry->content = SNDRV_INFO_CONTENT_DATA;
-	version_entry->c.ops = &wsa881x_codec_info_ops;
-
-	if (snd_info_register(version_entry) < 0) {
-		snd_info_free_entry(version_entry);
-		return -ENOMEM;
-	}
-	wsa881x->version_entry = version_entry;
-
-	return 0;
-}
-EXPORT_SYMBOL(wsa881x_codec_info_create_codec_entry);
-
-static bool is_swr_slv_reg_readable(int reg)
-{
-	bool ret = true;
-
-	if (((reg > 0x46) && (reg < 0x4A)) ||
-	    ((reg > 0x4A) && (reg < 0x50)) ||
-	    ((reg > 0x55) && (reg < 0xE0)) ||
-	    ((reg > 0xE0) && (reg < 0xF0)) ||
-	    ((reg > 0xF0) && (reg < 0x100)) ||
-	    ((reg > 0x105) && (reg < 0x120)) ||
-	    ((reg > 0x128) && (reg < 0x130)) ||
-	    ((reg > 0x138) && (reg < 0x200)) ||
-	    ((reg > 0x205) && (reg < 0x220)) ||
-	    ((reg > 0x228) && (reg < 0x230)) ||
-	    ((reg > 0x238) && (reg < 0x300)) ||
-	    ((reg > 0x305) && (reg < 0x320)) ||
-	    ((reg > 0x328) && (reg < 0x330)) ||
-	    ((reg > 0x338) && (reg < 0x400)) ||
-	    ((reg > 0x405) && (reg < 0x420)))
-		ret = false;
-
-	return ret;
-}
-
-static ssize_t wsa881x_swrslave_reg_show(char __user *ubuf, size_t count,
-					  loff_t *ppos)
-{
-	int i, reg_val, len;
-	ssize_t total = 0;
-	char tmp_buf[SWR_SLV_MAX_BUF_LEN];
-
-	if (!ubuf || !ppos || (devnum == 0))
-		return 0;
-
-	for (i = (((int) *ppos / BYTES_PER_LINE) + SWR_SLV_START_REG_ADDR);
-		i <= SWR_SLV_MAX_REG_ADDR; i++) {
-		if (!is_swr_slv_reg_readable(i))
-			continue;
-		swr_read(dbgwsa881x->swr_slave, devnum,
-			i, &reg_val, 1);
-		len = snprintf(tmp_buf, 25, "0x%.3x: 0x%.2x\n", i,
-			       (reg_val & 0xFF));
-		if ((total + len) >= count - 1)
-			break;
-		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
-			total = -EFAULT;
-			goto copy_err;
-		}
-		*ppos += len;
-		total += len;
-	}
-
-copy_err:
-	return total;
-}
-
-static ssize_t codec_debug_read(struct file *file, char __user *ubuf,
-				size_t count, loff_t *ppos)
-{
-	char lbuf[SWR_SLV_RD_BUF_LEN];
-	char *access_str;
-	ssize_t ret_cnt;
-
-	if (!count || !file || !ppos || !ubuf)
-		return -EINVAL;
-
-	access_str = file->private_data;
-	if (*ppos < 0)
-		return -EINVAL;
-
-	if (!strcmp(access_str, "swrslave_peek")) {
-		snprintf(lbuf, sizeof(lbuf), "0x%x\n", (read_data & 0xFF));
-		ret_cnt = simple_read_from_buffer(ubuf, count, ppos, lbuf,
-					       strnlen(lbuf, 7));
-	} else if (!strcmp(access_str, "swrslave_reg_dump")) {
-		ret_cnt = wsa881x_swrslave_reg_show(ubuf, count, ppos);
-	} else {
-		pr_err("%s: %s not permitted to read\n", __func__, access_str);
-		ret_cnt = -EPERM;
-	}
-	return ret_cnt;
-}
-
-static ssize_t codec_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char lbuf[SWR_SLV_WR_BUF_LEN];
-	int rc;
-	u32 param[5];
-	char *access_str;
-
-	if (!filp || !ppos || !ubuf)
-		return -EINVAL;
-
-	access_str = filp->private_data;
-	if (cnt > sizeof(lbuf) - 1)
-		return -EINVAL;
-
-	rc = copy_from_user(lbuf, ubuf, cnt);
-	if (rc)
-		return -EFAULT;
-
-	lbuf[cnt] = '\0';
-	if (!strcmp(access_str, "swrslave_poke")) {
-		/* write */
-		rc = get_parameters(lbuf, param, 3);
-		if ((param[0] <= SWR_SLV_MAX_REG_ADDR) && (param[1] <= 0xFF) &&
-			(rc == 0))
-			swr_write(dbgwsa881x->swr_slave, param[2],
-				param[0], &param[1]);
-		else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "swrslave_peek")) {
-		/* read */
-		rc = get_parameters(lbuf, param, 2);
-		if ((param[0] <= SWR_SLV_MAX_REG_ADDR) && (rc == 0))
-			swr_read(dbgwsa881x->swr_slave, param[1],
-				param[0], &read_data, 1);
-		else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "swrslave_reg_dump")) {
-		/* reg dump */
-		rc = get_parameters(lbuf, param, 1);
-		if ((rc == 0) && (param[0] > 0) &&
-		    (param[0] <= SWR_SLV_MAX_DEVICES))
-			devnum = param[0];
-		else
-			rc = -EINVAL;
-	}
-	if (rc == 0)
-		rc = cnt;
-	else
-		pr_err("%s: rc = %d\n", __func__, rc);
-
-	return rc;
-}
-
-static const struct file_operations codec_debug_ops = {
-	.open = codec_debug_open,
-	.write = codec_debug_write,
-	.read = codec_debug_read,
-};
-
-static const struct reg_sequence wsa881x_pre_pmu_pa[] = {
-	{WSA881X_SPKR_DRV_GAIN, 0x41, 0},
-	{WSA881X_SPKR_MISC_CTL1, 0x01, 0},
-	{WSA881X_ADC_EN_DET_TEST_I, 0x01, 0},
-	{WSA881X_ADC_EN_MODU_V, 0x02, 0},
-	{WSA881X_ADC_EN_DET_TEST_V, 0x10, 0},
-	{WSA881X_SPKR_PWRSTG_DBG, 0xA0, 0},
-};
-
-static const struct reg_sequence wsa881x_pre_pmu_pa_2_0[] = {
-	{WSA881X_SPKR_DRV_GAIN, 0x41, 0},
-	{WSA881X_SPKR_MISC_CTL1, 0x87, 0},
-};
-
-static const struct reg_sequence wsa881x_post_pmu_pa[] = {
-	{WSA881X_SPKR_PWRSTG_DBG, 0x00, 0},
-	{WSA881X_ADC_EN_DET_TEST_V, 0x00, 0},
-	{WSA881X_ADC_EN_MODU_V, 0x00, 0},
-	{WSA881X_ADC_EN_DET_TEST_I, 0x00, 0},
-};
-
-static const struct reg_sequence wsa881x_vi_txfe_en[] = {
-	{WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x85, 0},
-	{WSA881X_SPKR_PROT_ATEST2, 0x0A, 0},
-	{WSA881X_SPKR_PROT_FE_GAIN, 0xCF, 0},
-};
-
-static const struct reg_sequence wsa881x_vi_txfe_en_2_0[] = {
-	{WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x85, 0},
-	{WSA881X_SPKR_PROT_ATEST2, 0x0A, 0},
-	{WSA881X_SPKR_PROT_FE_GAIN, 0x47, 0},
-};
-
-static int wsa881x_boost_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-	dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable);
-	if (enable)
-		snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x80);
-	else
-		snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x00);
-	/*
-	 * 1.5ms sleep is needed after boost enable/disable as per
-	 * HW requirement
-	 */
-	usleep_range(1500, 1510);
-	return 0;
-}
-
-static int wsa881x_visense_txfe_ctrl(struct snd_soc_codec *codec, bool enable,
-				     u8 isense1_gain, u8 isense2_gain,
-				     u8 vsense_gain)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev,
-		"%s: enable:%d, isense1 gain: %d, isense2 gain: %d, vsense_gain %d\n",
-		__func__, enable, isense1_gain, isense2_gain, vsense_gain);
-
-	if (enable) {
-		regmap_multi_reg_write(wsa881x->regmap,
-				wsa881x_vi_txfe_en_2_0,
-				ARRAY_SIZE(wsa881x_vi_txfe_en_2_0));
-	} else {
-		snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_VSENSE_VCM,
-				    0x08, 0x08);
-		/*
-		 * 200us sleep is needed after visense txfe disable as per
-		 * HW requirement.
-		 */
-		usleep_range(200, 210);
-		snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_GAIN,
-				    0x01, 0x00);
-	}
-	return 0;
-}
-
-static int wsa881x_visense_adc_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-
-	dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable);
-	snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_V, (0x01 << 7),
-			    (enable << 7));
-	snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_I, (0x01 << 7),
-			    (enable << 7));
-	return 0;
-}
-
-static void wsa881x_bandgap_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: enable:%d, bg_count:%d\n", __func__,
-		enable, wsa881x->bg_cnt);
-	mutex_lock(&wsa881x->bg_lock);
-	if (enable) {
-		++wsa881x->bg_cnt;
-		if (wsa881x->bg_cnt == 1) {
-			snd_soc_update_bits(codec, WSA881X_TEMP_OP,
-					    0x08, 0x08);
-			/* 400usec sleep is needed as per HW requirement */
-			usleep_range(400, 410);
-			snd_soc_update_bits(codec, WSA881X_TEMP_OP,
-					    0x04, 0x04);
-		}
-	} else {
-		--wsa881x->bg_cnt;
-		if (wsa881x->bg_cnt <= 0) {
-			WARN_ON(wsa881x->bg_cnt < 0);
-			wsa881x->bg_cnt = 0;
-			snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x04, 0x00);
-			snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x08, 0x00);
-		}
-	}
-	mutex_unlock(&wsa881x->bg_lock);
-}
-
-static void wsa881x_clk_ctrl(struct snd_soc_codec *codec, bool enable)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: enable:%d, clk_count:%d\n", __func__,
-		enable, wsa881x->clk_cnt);
-	mutex_lock(&wsa881x->res_lock);
-	if (enable) {
-		++wsa881x->clk_cnt;
-		if (wsa881x->clk_cnt == 1) {
-			snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x01);
-			snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x01);
-		}
-	} else {
-		--wsa881x->clk_cnt;
-		if (wsa881x->clk_cnt <= 0) {
-			WARN_ON(wsa881x->clk_cnt < 0);
-			wsa881x->clk_cnt = 0;
-			snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x00);
-			snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x00);
-		}
-	}
-	mutex_unlock(&wsa881x->res_lock);
-}
-
-static int wsa881x_get_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = wsa881x->comp_enable;
-	return 0;
-}
-
-static int wsa881x_set_compander(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: Compander enable current %d, new %d\n",
-		 __func__, wsa881x->comp_enable, value);
-	wsa881x->comp_enable = value;
-	return 0;
-}
-
-static int wsa881x_get_boost(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = wsa881x->boost_enable;
-	return 0;
-}
-
-static int wsa881x_set_boost(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: Boost enable current %d, new %d\n",
-		 __func__, wsa881x->boost_enable, value);
-	wsa881x->boost_enable = value;
-	return 0;
-}
-
-static int wsa881x_get_visense(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	ucontrol->value.integer.value[0] = wsa881x->visense_enable;
-	return 0;
-}
-
-static int wsa881x_set_visense(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int value = ucontrol->value.integer.value[0];
-
-	dev_dbg(codec->dev, "%s: VIsense enable current %d, new %d\n",
-		 __func__, wsa881x->visense_enable, value);
-	wsa881x->visense_enable = value;
-	return 0;
-}
-
-static const struct snd_kcontrol_new wsa881x_snd_controls[] = {
-	SOC_SINGLE_EXT("COMP Switch", SND_SOC_NOPM, 0, 1, 0,
-		wsa881x_get_compander, wsa881x_set_compander),
-
-	SOC_SINGLE_EXT("BOOST Switch", SND_SOC_NOPM, 0, 1, 0,
-		wsa881x_get_boost, wsa881x_set_boost),
-
-	SOC_SINGLE_EXT("VISENSE Switch", SND_SOC_NOPM, 0, 1, 0,
-		wsa881x_get_visense, wsa881x_set_visense),
-};
-
-static const struct snd_kcontrol_new swr_dac_port[] = {
-	SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
-};
-
-static int wsa881x_set_port(struct snd_soc_codec *codec, int port_idx,
-			u8 *port_id, u8 *num_ch, u8 *ch_mask, u32 *ch_rate)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	*port_id = wsa881x->port[port_idx].port_id;
-	*num_ch = wsa881x->port[port_idx].num_ch;
-	*ch_mask = wsa881x->port[port_idx].ch_mask;
-	*ch_rate = wsa881x->port[port_idx].ch_rate;
-	return 0;
-}
-
-static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
-	struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	u8 port_id[WSA881X_MAX_SWR_PORTS];
-	u8 num_ch[WSA881X_MAX_SWR_PORTS];
-	u8 ch_mask[WSA881X_MAX_SWR_PORTS];
-	u32 ch_rate[WSA881X_MAX_SWR_PORTS];
-	u8 num_port = 0;
-
-	dev_dbg(codec->dev, "%s: event %d name %s\n", __func__,
-		event, w->name);
-	if (wsa881x == NULL)
-		return -EINVAL;
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wsa881x_set_port(codec, SWR_DAC_PORT,
-				&port_id[num_port], &num_ch[num_port],
-				&ch_mask[num_port], &ch_rate[num_port]);
-		++num_port;
-
-		if (wsa881x->comp_enable) {
-			wsa881x_set_port(codec, SWR_COMP_PORT,
-					&port_id[num_port], &num_ch[num_port],
-					&ch_mask[num_port], &ch_rate[num_port]);
-			++num_port;
-		}
-		if (wsa881x->boost_enable) {
-			wsa881x_set_port(codec, SWR_BOOST_PORT,
-					&port_id[num_port], &num_ch[num_port],
-					&ch_mask[num_port], &ch_rate[num_port]);
-			++num_port;
-		}
-		if (wsa881x->visense_enable) {
-			wsa881x_set_port(codec, SWR_VISENSE_PORT,
-					&port_id[num_port], &num_ch[num_port],
-					&ch_mask[num_port], &ch_rate[num_port]);
-			++num_port;
-		}
-		swr_connect_port(wsa881x->swr_slave, &port_id[0], num_port,
-				&ch_mask[0], &ch_rate[0], &num_ch[0]);
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		port_id[num_port] = wsa881x->port[SWR_DAC_PORT].port_id;
-		++num_port;
-		if (wsa881x->comp_enable) {
-			port_id[num_port] =
-				wsa881x->port[SWR_COMP_PORT].port_id;
-			++num_port;
-		}
-		if (wsa881x->boost_enable) {
-			port_id[num_port] =
-				wsa881x->port[SWR_BOOST_PORT].port_id;
-			++num_port;
-		}
-		if (wsa881x->visense_enable) {
-			port_id[num_port] =
-				wsa881x->port[SWR_VISENSE_PORT].port_id;
-			++num_port;
-		}
-		swr_disconnect_port(wsa881x->swr_slave, &port_id[0], num_port);
-		break;
-	default:
-		break;
-	}
-	return 0;
-}
-
-static int wsa881x_rdac_event(struct snd_soc_dapm_widget *w,
-			struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	dev_dbg(codec->dev, "%s: %s %d boost %d visense %d\n", __func__,
-		w->name, event,	wsa881x->boost_enable,
-		wsa881x->visense_enable);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		wsa881x_resource_acquire(codec, ENABLE);
-		wsa881x_boost_ctrl(codec, ENABLE);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		swr_slvdev_datapath_control(wsa881x->swr_slave,
-					    wsa881x->swr_slave->dev_num,
-					    false);
-		wsa881x_boost_ctrl(codec, DISABLE);
-		wsa881x_resource_acquire(codec, DISABLE);
-		break;
-	}
-	return 0;
-}
-
-static int wsa881x_ramp_pa_gain(struct snd_soc_codec *codec,
-				int min_gain, int max_gain, int udelay)
-{
-	int val;
-
-	for (val = min_gain; max_gain <= val; val--) {
-		snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
-				    0xF0, val << 4);
-		/*
-		 * 1ms delay is needed for every step change in gain as per
-		 * HW requirement.
-		 */
-		usleep_range(udelay, udelay+10);
-	}
-	return 0;
-}
-
-static void wsa881x_ocp_ctl_work(struct work_struct *work)
-{
-	struct wsa881x_priv *wsa881x;
-	struct delayed_work *dwork;
-	struct snd_soc_codec *codec;
-	int temp_val;
-
-	dwork = to_delayed_work(work);
-	wsa881x = container_of(dwork, struct wsa881x_priv, ocp_ctl_work);
-
-	codec = wsa881x->codec;
-	wsa881x_get_temp(wsa881x->tz_pdata.tz_dev, &temp_val);
-	dev_dbg(codec->dev, " temp = %d\n", temp_val);
-
-	if (temp_val <= WSA881X_OCP_CTL_TEMP_CELSIUS)
-		snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x00);
-	else
-		snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0);
-
-	schedule_delayed_work(&wsa881x->ocp_ctl_work,
-			msecs_to_jiffies(wsa881x_ocp_poll_timer_sec * 1000));
-}
-
-static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w,
-			struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int min_gain, max_gain;
-
-	dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x80);
-		regmap_multi_reg_write(wsa881x->regmap,
-				wsa881x_pre_pmu_pa_2_0,
-				ARRAY_SIZE(wsa881x_pre_pmu_pa_2_0));
-		swr_slvdev_datapath_control(wsa881x->swr_slave,
-					    wsa881x->swr_slave->dev_num,
-					    true);
-		/* Set register mode if compander is not enabled */
-		if (!wsa881x->comp_enable)
-			snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
-					    0x08, 0x08);
-		else
-			snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
-					    0x08, 0x00);
-
-		break;
-	case SND_SOC_DAPM_POST_PMU:
-		if (!wsa881x->comp_enable) {
-			max_gain = wsa881x->pa_gain;
-			/*
-			 * Gain has to set incrementally in 4 steps
-			 * as per HW sequence
-			 */
-			if (max_gain > G_4P5DB)
-				min_gain = G_0DB;
-			else
-				min_gain = max_gain + 3;
-			/*
-			 * 1ms delay is needed before change in gain
-			 * as per HW requirement.
-			 */
-			usleep_range(1000, 1010);
-			wsa881x_ramp_pa_gain(codec, min_gain, max_gain, 1000);
-		}
-		if (wsa881x->visense_enable) {
-			wsa881x_visense_txfe_ctrl(codec, ENABLE,
-						0x00, 0x03, 0x01);
-			snd_soc_update_bits(codec, WSA881X_ADC_EN_SEL_IBAIS,
-					    0x07, 0x01);
-			wsa881x_visense_adc_ctrl(codec, ENABLE);
-		}
-		schedule_delayed_work(&wsa881x->ocp_ctl_work,
-			msecs_to_jiffies(WSA881X_OCP_CTL_TIMER_SEC * 1000));
-		/* Force remove group */
-		swr_remove_from_group(wsa881x->swr_slave,
-				      wsa881x->swr_slave->dev_num);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		if (wsa881x->visense_enable) {
-			wsa881x_visense_adc_ctrl(codec, DISABLE);
-			wsa881x_visense_txfe_ctrl(codec, DISABLE,
-						0x00, 0x01, 0x01);
-		}
-		cancel_delayed_work_sync(&wsa881x->ocp_ctl_work);
-		snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0);
-		break;
-	}
-	return 0;
-}
-
-static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = {
-	SND_SOC_DAPM_INPUT("IN"),
-
-	SND_SOC_DAPM_MIXER_E("SWR DAC_Port", SND_SOC_NOPM, 0, 0, swr_dac_port,
-		ARRAY_SIZE(swr_dac_port), wsa881x_enable_swr_dac_port,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
-		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_DAC_E("RDAC", NULL, WSA881X_SPKR_DAC_CTL, 7, 0,
-		wsa881x_rdac_event,
-		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_PGA_E("SPKR PGA", WSA881X_SPKR_DRV_EN, 7, 0, NULL, 0,
-			wsa881x_spkr_pa_event, SND_SOC_DAPM_PRE_PMU |
-			SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_OUTPUT("SPKR"),
-};
-
-static const struct snd_soc_dapm_route wsa881x_audio_map[] = {
-	{"SWR DAC_Port", "Switch", "IN"},
-	{"RDAC", NULL, "SWR DAC_Port"},
-	{"SPKR PGA", NULL, "RDAC"},
-	{"SPKR", NULL, "SPKR PGA"},
-};
-
-int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, u8 num_port,
-				unsigned int *ch_mask, unsigned int *ch_rate)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	int i;
-
-	if (!port || !ch_mask || !ch_rate ||
-		(num_port > WSA881X_MAX_SWR_PORTS)) {
-		dev_err(codec->dev,
-			"%s: Invalid port=%pK, ch_mask=%pK, ch_rate=%pK\n",
-			__func__, port, ch_mask, ch_rate);
-		return -EINVAL;
-	}
-	for (i = 0; i < num_port; i++) {
-		wsa881x->port[i].port_id = port[i];
-		wsa881x->port[i].ch_mask = ch_mask[i];
-		wsa881x->port[i].ch_rate = ch_rate[i];
-		wsa881x->port[i].num_ch = __sw_hweight8(ch_mask[i]);
-	}
-	return 0;
-}
-EXPORT_SYMBOL(wsa881x_set_channel_map);
-
-static void wsa881x_init(struct snd_soc_codec *codec)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	wsa881x->version = snd_soc_read(codec, WSA881X_CHIP_ID1);
-	wsa881x_regmap_defaults(wsa881x->regmap, wsa881x->version);
-	/* Bring out of analog reset */
-	snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x02, 0x02);
-	/* Bring out of digital reset */
-	snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x01, 0x01);
-
-	snd_soc_update_bits(codec, WSA881X_CLOCK_CONFIG, 0x10, 0x10);
-	snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x02, 0x02);
-	snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80);
-	snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06);
-	snd_soc_update_bits(codec, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00);
-	snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0xF0, 0x40);
-	snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0x0E, 0x0E);
-	snd_soc_update_bits(codec, WSA881X_BOOST_LOOP_STABILITY,
-			    0x03, 0x03);
-	snd_soc_update_bits(codec, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14);
-	snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x80, 0x80);
-	snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x03, 0x00);
-	snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
-			    0x0C, 0x04);
-	snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
-			    0x03, 0x00);
-	if (snd_soc_read(codec, WSA881X_OTP_REG_0))
-		snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT1,
-				    0xF0, 0x70);
-	snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT2,
-			    0xF0, 0x30);
-	snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x08, 0x08);
-	snd_soc_update_bits(codec, WSA881X_BOOST_CURRENT_LIMIT,
-			    0x0F, 0x08);
-	snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x30, 0x30);
-	snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00);
-	snd_soc_update_bits(codec, WSA881X_OTP_REG_28, 0x3F, 0x3A);
-	snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG1,
-			    0xFF, 0xB2);
-	snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG2,
-			    0xFF, 0x05);
-}
-
-static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
-						bool enable)
-{
-	wsa881x_clk_ctrl(codec, enable);
-	wsa881x_bandgap_ctrl(codec, enable);
-	return 0;
-}
-
-static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
-				     struct wsa_temp_register *wsa_temp_reg)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	struct swr_device *dev;
-	u8 retry = WSA881X_NUM_RETRY;
-	u8 devnum = 0;
-
-	if (!wsa881x) {
-		dev_err(codec->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev = wsa881x->swr_slave;
-	if (dev && (wsa881x->state == WSA881X_DEV_DOWN)) {
-		while (swr_get_logical_dev_num(dev, dev->addr, &devnum) &&
-		       retry--) {
-			/* Retry after 1 msec delay */
-			usleep_range(1000, 1100);
-		}
-		if (retry == 0) {
-			dev_err(codec->dev,
-				"%s get devnum %d for dev addr %lx failed\n",
-				__func__, devnum, dev->addr);
-			return -EINVAL;
-		}
-	}
-	mutex_lock(&wsa881x->res_lock);
-	if (!wsa881x->clk_cnt) {
-		regcache_mark_dirty(wsa881x->regmap);
-		regcache_sync(wsa881x->regmap);
-	}
-	mutex_unlock(&wsa881x->res_lock);
-
-	wsa881x_resource_acquire(codec, ENABLE);
-
-	snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x00);
-	wsa_temp_reg->dmeas_msb = snd_soc_read(codec, WSA881X_TEMP_MSB);
-	wsa_temp_reg->dmeas_lsb = snd_soc_read(codec, WSA881X_TEMP_LSB);
-	snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x01);
-	wsa_temp_reg->d1_msb = snd_soc_read(codec, WSA881X_OTP_REG_1);
-	wsa_temp_reg->d1_lsb = snd_soc_read(codec, WSA881X_OTP_REG_2);
-	wsa_temp_reg->d2_msb = snd_soc_read(codec, WSA881X_OTP_REG_3);
-	wsa_temp_reg->d2_lsb = snd_soc_read(codec, WSA881X_OTP_REG_4);
-
-	wsa881x_resource_acquire(codec, DISABLE);
-
-	return 0;
-}
-
-static int wsa881x_probe(struct snd_soc_codec *codec)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-	struct swr_device *dev;
-
-	if (!wsa881x)
-		return -EINVAL;
-
-	dev = wsa881x->swr_slave;
-	wsa881x->codec = codec;
-	mutex_init(&wsa881x->bg_lock);
-	mutex_init(&wsa881x->res_lock);
-	wsa881x_init(codec);
-	snprintf(wsa881x->tz_pdata.name, sizeof(wsa881x->tz_pdata.name),
-		"%s.%x", "wsatz", (u8)dev->addr);
-	wsa881x->bg_cnt = 0;
-	wsa881x->clk_cnt = 0;
-	wsa881x->tz_pdata.codec = codec;
-	wsa881x->tz_pdata.wsa_temp_reg_read = wsa881x_temp_reg_read;
-	wsa881x_init_thermal(&wsa881x->tz_pdata);
-	snd_soc_add_codec_controls(codec, wsa_snd_controls,
-				   ARRAY_SIZE(wsa_snd_controls));
-	INIT_DELAYED_WORK(&wsa881x->ocp_ctl_work, wsa881x_ocp_ctl_work);
-	return 0;
-}
-
-static int wsa881x_remove(struct snd_soc_codec *codec)
-{
-	struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
-
-	if (wsa881x->tz_pdata.tz_dev)
-		wsa881x_deinit_thermal(wsa881x->tz_pdata.tz_dev);
-	mutex_destroy(&wsa881x->bg_lock);
-	mutex_destroy(&wsa881x->res_lock);
-
-	return 0;
-}
-
-static struct regmap *wsa881x_get_regmap(struct device *dev)
-{
-	struct wsa881x_priv *control = swr_get_dev_data(to_swr_device(dev));
-
-	if (!control)
-		return NULL;
-
-	return control->regmap;
-}
-
-static struct snd_soc_codec_driver soc_codec_dev_wsa881x = {
-	.probe = wsa881x_probe,
-	.remove = wsa881x_remove,
-	.get_regmap = wsa881x_get_regmap,
-	.component_driver = {
-		.controls = wsa881x_snd_controls,
-		.num_controls = ARRAY_SIZE(wsa881x_snd_controls),
-		.dapm_widgets = wsa881x_dapm_widgets,
-		.num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets),
-		.dapm_routes = wsa881x_audio_map,
-		.num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map),
-	},
-};
-
-static int wsa881x_gpio_ctrl(struct wsa881x_priv *wsa881x, bool enable)
-{
-	int ret = 0;
-
-	if (wsa881x->pd_gpio < 0) {
-		dev_err(wsa881x->dev, "%s: gpio is not valid %d\n",
-			__func__, wsa881x->pd_gpio);
-		return -EINVAL;
-	}
-
-	if (wsa881x->wsa_rst_np) {
-		if (enable)
-			ret = msm_cdc_pinctrl_select_active_state(
-							wsa881x->wsa_rst_np);
-		else
-			ret = msm_cdc_pinctrl_select_sleep_state(
-							wsa881x->wsa_rst_np);
-		if (ret != 0)
-			dev_err(wsa881x->dev,
-				"%s: Failed to turn state %d; ret=%d\n",
-				__func__, enable, ret);
-	} else {
-		if (gpio_is_valid(wsa881x->pd_gpio))
-			gpio_direction_output(wsa881x->pd_gpio, enable);
-	}
-
-	return ret;
-}
-
-static int wsa881x_gpio_init(struct swr_device *pdev)
-{
-	int ret = 0;
-	struct wsa881x_priv *wsa881x;
-
-	wsa881x = swr_get_dev_data(pdev);
-	if (!wsa881x) {
-		dev_err(&pdev->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_dbg(&pdev->dev, "%s: gpio %d request with name %s\n",
-		__func__, wsa881x->pd_gpio, dev_name(&pdev->dev));
-	ret = gpio_request(wsa881x->pd_gpio, dev_name(&pdev->dev));
-	if (ret) {
-		if (ret == -EBUSY) {
-			/* GPIO was already requested */
-			dev_dbg(&pdev->dev,
-				 "%s: gpio %d is already set to high\n",
-				 __func__, wsa881x->pd_gpio);
-			ret = 0;
-		} else {
-			dev_err(&pdev->dev, "%s: Failed to request gpio %d, err: %d\n",
-				__func__, wsa881x->pd_gpio, ret);
-		}
-	}
-	return ret;
-}
-
-static int wsa881x_swr_probe(struct swr_device *pdev)
-{
-	int ret = 0;
-	struct wsa881x_priv *wsa881x;
-	u8 devnum = 0;
-	bool pin_state_current = false;
-
-	wsa881x = devm_kzalloc(&pdev->dev, sizeof(struct wsa881x_priv),
-			    GFP_KERNEL);
-	if (!wsa881x)
-		return -ENOMEM;
-	wsa881x->wsa_rst_np = of_parse_phandle(pdev->dev.of_node,
-					     "qcom,spkr-sd-n-node", 0);
-	if (!wsa881x->wsa_rst_np) {
-		dev_dbg(&pdev->dev, "%s: Not using pinctrl, fallback to gpio\n",
-			__func__);
-		wsa881x->pd_gpio = of_get_named_gpio(pdev->dev.of_node,
-						     "qcom,spkr-sd-n-gpio", 0);
-		if (wsa881x->pd_gpio < 0) {
-			dev_err(&pdev->dev, "%s: %s property is not found %d\n",
-				__func__, "qcom,spkr-sd-n-gpio",
-				wsa881x->pd_gpio);
-			goto err;
-		}
-		dev_dbg(&pdev->dev, "%s: reset gpio %d\n", __func__,
-			wsa881x->pd_gpio);
-	}
-	swr_set_dev_data(pdev, wsa881x);
-
-	wsa881x->swr_slave = pdev;
-
-	if (!wsa881x->wsa_rst_np) {
-		ret = wsa881x_gpio_init(pdev);
-		if (ret)
-			goto err;
-	}
-	if (wsa881x->wsa_rst_np)
-		pin_state_current = msm_cdc_pinctrl_get_state(
-						wsa881x->wsa_rst_np);
-	wsa881x_gpio_ctrl(wsa881x, true);
-	wsa881x->state = WSA881X_DEV_UP;
-
-	if (!debugfs_wsa881x_dent) {
-		dbgwsa881x = wsa881x;
-		debugfs_wsa881x_dent = debugfs_create_dir(
-						"wsa881x_swr_slave", 0);
-		if (!IS_ERR(debugfs_wsa881x_dent)) {
-			debugfs_peek = debugfs_create_file("swrslave_peek",
-					S_IFREG | 0444, debugfs_wsa881x_dent,
-					(void *) "swrslave_peek",
-					&codec_debug_ops);
-
-			debugfs_poke = debugfs_create_file("swrslave_poke",
-					S_IFREG | 0444, debugfs_wsa881x_dent,
-					(void *) "swrslave_poke",
-					&codec_debug_ops);
-
-			debugfs_reg_dump = debugfs_create_file(
-						"swrslave_reg_dump",
-						S_IFREG | 0444,
-						debugfs_wsa881x_dent,
-						(void *) "swrslave_reg_dump",
-						&codec_debug_ops);
-		}
-	}
-
-	/*
-	 * Add 5msec delay to provide sufficient time for
-	 * soundwire auto enumeration of slave devices as
-	 * as per HW requirement.
-	 */
-	usleep_range(5000, 5010);
-	ret = swr_get_logical_dev_num(pdev, pdev->addr, &devnum);
-	if (ret) {
-		dev_dbg(&pdev->dev,
-			"%s get devnum %d for dev addr %lx failed\n",
-			__func__, devnum, pdev->addr);
-		goto dev_err;
-	}
-	pdev->dev_num = devnum;
-
-	wsa881x->regmap = devm_regmap_init_swr(pdev,
-					       &wsa881x_regmap_config);
-	if (IS_ERR(wsa881x->regmap)) {
-		ret = PTR_ERR(wsa881x->regmap);
-		dev_err(&pdev->dev, "%s: regmap_init failed %d\n",
-			__func__, ret);
-		goto dev_err;
-	}
-
-	ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wsa881x,
-				     NULL, 0);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: Codec registration failed\n",
-			__func__);
-		goto dev_err;
-	}
-
-	return 0;
-
-dev_err:
-	if (pin_state_current == false)
-		wsa881x_gpio_ctrl(wsa881x, false);
-	swr_remove_device(pdev);
-err:
-	return ret;
-}
-
-static int wsa881x_swr_remove(struct swr_device *pdev)
-{
-	struct wsa881x_priv *wsa881x;
-
-	wsa881x = swr_get_dev_data(pdev);
-	if (!wsa881x) {
-		dev_err(&pdev->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	debugfs_remove_recursive(debugfs_wsa881x_dent);
-	debugfs_wsa881x_dent = NULL;
-	snd_soc_unregister_codec(&pdev->dev);
-	if (wsa881x->pd_gpio)
-		gpio_free(wsa881x->pd_gpio);
-	swr_set_dev_data(pdev, NULL);
-	return 0;
-}
-
-static int wsa881x_swr_up(struct swr_device *pdev)
-{
-	int ret;
-	struct wsa881x_priv *wsa881x;
-
-	wsa881x = swr_get_dev_data(pdev);
-	if (!wsa881x) {
-		dev_err(&pdev->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	ret = wsa881x_gpio_ctrl(wsa881x, true);
-	if (ret)
-		dev_err(&pdev->dev, "%s: Failed to enable gpio\n", __func__);
-	else
-		wsa881x->state = WSA881X_DEV_UP;
-
-	return ret;
-}
-
-static int wsa881x_swr_down(struct swr_device *pdev)
-{
-	struct wsa881x_priv *wsa881x;
-	int ret;
-
-	wsa881x = swr_get_dev_data(pdev);
-	if (!wsa881x) {
-		dev_err(&pdev->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (delayed_work_pending(&wsa881x->ocp_ctl_work))
-		cancel_delayed_work_sync(&wsa881x->ocp_ctl_work);
-	ret = wsa881x_gpio_ctrl(wsa881x, false);
-	if (ret)
-		dev_err(&pdev->dev, "%s: Failed to disable gpio\n", __func__);
-	else
-		wsa881x->state = WSA881X_DEV_DOWN;
-
-	return ret;
-}
-
-static int wsa881x_swr_reset(struct swr_device *pdev)
-{
-	struct wsa881x_priv *wsa881x;
-	u8 retry = WSA881X_NUM_RETRY;
-	u8 devnum = 0;
-
-	wsa881x = swr_get_dev_data(pdev);
-	if (!wsa881x) {
-		dev_err(&pdev->dev, "%s: wsa881x is NULL\n", __func__);
-		return -EINVAL;
-	}
-	wsa881x->bg_cnt = 0;
-	wsa881x->clk_cnt = 0;
-	while (swr_get_logical_dev_num(pdev, pdev->addr, &devnum) && retry--) {
-		/* Retry after 1 msec delay */
-		usleep_range(1000, 1100);
-	}
-	pdev->dev_num = devnum;
-	regcache_mark_dirty(wsa881x->regmap);
-	regcache_sync(wsa881x->regmap);
-	return 0;
-}
-
-#ifdef CONFIG_PM_SLEEP
-static int wsa881x_swr_suspend(struct device *dev)
-{
-	dev_dbg(dev, "%s: system suspend\n", __func__);
-	return 0;
-}
-
-static int wsa881x_swr_resume(struct device *dev)
-{
-	struct wsa881x_priv *wsa881x = swr_get_dev_data(to_swr_device(dev));
-
-	if (!wsa881x) {
-		dev_err(dev, "%s: wsa881x private data is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dev_dbg(dev, "%s: system resume\n", __func__);
-	return 0;
-}
-#endif /* CONFIG_PM_SLEEP */
-
-static const struct dev_pm_ops wsa881x_swr_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(wsa881x_swr_suspend, wsa881x_swr_resume)
-};
-
-static const struct swr_device_id wsa881x_swr_id[] = {
-	{"wsa881x", 0},
-	{}
-};
-
-static const struct of_device_id wsa881x_swr_dt_match[] = {
-	{
-		.compatible = "qcom,wsa881x",
-	},
-	{}
-};
-
-static struct swr_driver wsa881x_codec_driver = {
-	.driver = {
-		.name = "wsa881x",
-		.owner = THIS_MODULE,
-		.pm = &wsa881x_swr_pm_ops,
-		.of_match_table = wsa881x_swr_dt_match,
-	},
-	.probe = wsa881x_swr_probe,
-	.remove = wsa881x_swr_remove,
-	.id_table = wsa881x_swr_id,
-	.device_up = wsa881x_swr_up,
-	.device_down = wsa881x_swr_down,
-	.reset_device = wsa881x_swr_reset,
-};
-
-static int __init wsa881x_codec_init(void)
-{
-	return swr_driver_register(&wsa881x_codec_driver);
-}
-
-static void __exit wsa881x_codec_exit(void)
-{
-	swr_driver_unregister(&wsa881x_codec_driver);
-}
-
-module_init(wsa881x_codec_init);
-module_exit(wsa881x_codec_exit);
-
-MODULE_DESCRIPTION("WSA881x Codec driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wsa881x.h b/sound/soc/codecs/wsa881x.h
deleted file mode 100644
index fbc60d8..0000000
--- a/sound/soc/codecs/wsa881x.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _WSA881X_H
-#define _WSA881X_H
-
-#include <linux/regmap.h>
-#include <sound/soc.h>
-#include <sound/info.h>
-#include "wsa881x-registers.h"
-
-#define WSA881X_MAX_SWR_PORTS   4
-
-#if IS_ENABLED(CONFIG_SND_SOC_WSA881X)
-extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port,
-				   u8 num_port, unsigned int *ch_mask,
-				   unsigned int *ch_rate);
-
-extern const u8 wsa881x_reg_readable[WSA881X_CACHE_SIZE];
-extern struct regmap_config wsa881x_regmap_config;
-extern int wsa881x_codec_info_create_codec_entry(
-					struct snd_info_entry *codec_root,
-					struct snd_soc_codec *codec);
-void wsa881x_regmap_defaults(struct regmap *regmap, u8 version);
-
-#else
-extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port,
-				   u8 num_port, unsigned int *ch_mask,
-				   unsigned int *ch_rate)
-{
-	return 0;
-}
-
-extern int wsa881x_codec_info_create_codec_entry(
-					struct snd_info_entry *codec_root,
-					struct snd_soc_codec *codec)
-{
-	return 0;
-}
-
-void wsa881x_regmap_defaults(struct regmap *regmap, u8 version)
-{
-}
-
-#endif
-
-#endif /* _WSA881X_H */
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 5034943..fde08660 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -224,6 +224,12 @@
  * @dbg_stats: Debugging statistics
  *
  * @soc: SoC specific data
+ *
+ * @fifo_watermark: the FIFO watermark setting.  Notifies DMA when
+ *             there are @fifo_watermark or fewer words in TX fifo or
+ *             @fifo_watermark or more empty words in RX fifo.
+ * @dma_maxburst: max number of words to transfer in one go.  So far,
+ *             this is always the same as fifo_watermark.
  */
 struct fsl_ssi_private {
 	struct regmap *regs;
@@ -263,6 +269,9 @@
 
 	const struct fsl_ssi_soc_data *soc;
 	struct device *dev;
+
+	u32 fifo_watermark;
+	u32 dma_maxburst;
 };
 
 /*
@@ -1051,21 +1060,7 @@
 	regmap_write(regs, CCSR_SSI_SRCR, srcr);
 	regmap_write(regs, CCSR_SSI_SCR, scr);
 
-	/*
-	 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
-	 * use FIFO 1. We program the transmit water to signal a DMA transfer
-	 * if there are only two (or fewer) elements left in the FIFO. Two
-	 * elements equals one frame (left channel, right channel). This value,
-	 * however, depends on the depth of the transmit buffer.
-	 *
-	 * We set the watermark on the same level as the DMA burstsize.  For
-	 * fiq it is probably better to use the biggest possible watermark
-	 * size.
-	 */
-	if (ssi_private->use_dma)
-		wm = ssi_private->fifo_depth - 2;
-	else
-		wm = ssi_private->fifo_depth;
+	wm = ssi_private->fifo_watermark;
 
 	regmap_write(regs, CCSR_SSI_SFCSR,
 			CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
@@ -1373,12 +1368,8 @@
 		dev_dbg(&pdev->dev, "could not get baud clock: %ld\n",
 			 PTR_ERR(ssi_private->baudclk));
 
-	/*
-	 * We have burstsize be "fifo_depth - 2" to match the SSI
-	 * watermark setting in fsl_ssi_startup().
-	 */
-	ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2;
-	ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2;
+	ssi_private->dma_params_tx.maxburst = ssi_private->dma_maxburst;
+	ssi_private->dma_params_rx.maxburst = ssi_private->dma_maxburst;
 	ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0;
 	ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0;
 
@@ -1543,6 +1534,47 @@
                 /* Older 8610 DTs didn't have the fifo-depth property */
 		ssi_private->fifo_depth = 8;
 
+	/*
+	 * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
+	 * use FIFO 1 but set the watermark appropriately nontheless.
+	 * We program the transmit water to signal a DMA transfer
+	 * if there are N elements left in the FIFO. For chips with 15-deep
+	 * FIFOs, set watermark to 8.  This allows the SSI to operate at a
+	 * high data rate without channel slipping. Behavior is unchanged
+	 * for the older chips with a fifo depth of only 8.  A value of 4
+	 * might be appropriate for the older chips, but is left at
+	 * fifo_depth-2 until sombody has a chance to test.
+	 *
+	 * We set the watermark on the same level as the DMA burstsize.  For
+	 * fiq it is probably better to use the biggest possible watermark
+	 * size.
+	 */
+	switch (ssi_private->fifo_depth) {
+	case 15:
+		/*
+		 * 2 samples is not enough when running at high data
+		 * rates (like 48kHz @ 16 bits/channel, 16 channels)
+		 * 8 seems to split things evenly and leave enough time
+		 * for the DMA to fill the FIFO before it's over/under
+		 * run.
+		 */
+		ssi_private->fifo_watermark = 8;
+		ssi_private->dma_maxburst = 8;
+		break;
+	case 8:
+	default:
+		/*
+		 * maintain old behavior for older chips.
+		 * Keeping it the same because I don't have an older
+		 * board to test with.
+		 * I suspect this could be changed to be something to
+		 * leave some more space in the fifo.
+		 */
+		ssi_private->fifo_watermark = ssi_private->fifo_depth - 2;
+		ssi_private->dma_maxburst = ssi_private->fifo_depth - 2;
+		break;
+	}
+
 	dev_set_drvdata(&pdev->dev, ssi_private);
 
 	if (ssi_private->soc->imx) {
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index d5873ee..bd19fad 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -142,7 +142,7 @@
 		 * for Jack detection and button press
 		 */
 		ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK,
-					     0,
+					     48000 * 512,
 					     SND_SOC_CLOCK_IN);
 		if (!ret) {
 			if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk)
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 8fc3178..b30bd38 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -515,6 +515,9 @@
 
 void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
 {
+
+	if (ctx->dsp->fw)
+		release_firmware(ctx->dsp->fw);
 	skl_clear_module_table(ctx->dsp);
 	skl_freeup_uuid_list(ctx);
 	skl_ipc_free(&ctx->ipc);
diff --git a/sound/soc/msm/Kconfig b/sound/soc/msm/Kconfig
deleted file mode 100644
index 547330c..0000000
--- a/sound/soc/msm/Kconfig
+++ /dev/null
@@ -1,252 +0,0 @@
-menu "MSM SoC Audio support"
-
-config SND_SOC_MSM_HOSTLESS_PCM
-	tristate
-
-config SND_SOC_MSM_QDSP6V2_INTF
-	bool "SoC Q6 audio driver for MSM/APQ"
-	depends on MSM_QDSP6_APRV2_GLINK
-	help
-	 To add support for SoC audio on MSM/APQ.
-	 This will enable all the platform specific
-	 interactions towards DSP. It includes asm,
-	 adm and afe interfaces on the DSP.
-
-config SND_SOC_QDSP6V2
-	tristate "SoC ALSA audio driver for QDSP6V2"
-	select SND_SOC_MSM_QDSP6V2_INTF
-	select SND_SOC_COMPRESS
-	help
-	 To add support for MSM QDSP6V2 Soc Audio.
-	 This will enable sound soc platform specific
-	 audio drivers. This includes q6asm, q6adm,
-	 q6afe interfaces to DSP using apr.
-
-config SND_SOC_QDSP_DEBUG
-	bool "QDSP Audio Driver Debug Feature"
-	help
-	 Configuration to enable debugging utilities for
-	 QDSP6 based audio drivers. One debugging utility
-	 is inducing kernel panic upon encountering critical
-	 errors from DSP audio modules
-
-config DOLBY_DS2
-	bool "Enable Dolby DS2"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	help
-	 To add support for dolby DAP post processing.
-	 This support is to configure the post processing parameters
-	 to DSP. The configuration includes sending the end point
-	 device, end point dependent post processing parameters and
-	 the various posrt processing parameters
-
-config DOLBY_LICENSE
-	bool "Enable Dolby LICENSE"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	help
-	 To add support for dolby DAP post processing,
-	 and retain DAP set license functionality only.
-	 This is required by Dolby GEF implementation which needs
-	 nothing but dolby license validation functionality in driver.
-
-config DTS_EAGLE
-	bool "Enable DTS Eagle Support"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	select SND_HWDEP
-	help
-	 To add DTS Eagle support on QDSP6 targets.
-	 Eagle is a DTS pre/post processing
-	 package that includes HeadphoneX. The configuration
-	 includes sending tuning parameters of various modules.
-
-config DTS_SRS_TM
-	bool "Enable DTS SRS"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	help
-	 To add support for DTS SRS post processing.
-	 This support is to configure the post processing
-	 parameters to DSP. The configuration includes sending
-	 tuning parameters of various modules.
-
-config QTI_PP
-	bool "Enable QTI PP"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	help
-	 To add support for default QTI post processing.
-	 This support is to configure the post processing
-	 parameters to DSP. The configuration includes sending
-	 tuning parameters of various modules such as equalizer,
-	 customized mixing.
-
-config QTI_PP_AUDIOSPHERE
-	bool "Enable QTI AUDIOSPHERE PP"
-	depends on SND_SOC_MSM_QDSP6V2_INTF
-	help
-	 To add support for QTI audio sphere post processing.
-	 This support is to configure the post processing
-	 parameters to DSP. The configuration includes sending
-	 tuning parameters of audio sphere module.
-
-config SND_SOC_CPE
-	tristate "CPE drivers"
-	depends on SND_SOC_WCD_CPE
-	help
-	 To add support for Codec Processing Engine. This support
-	 is to enable CPE block on the codec and this config needs
-	 to be added to codecs that contain the CPE hardware block.
-	 The configuration includes the cpe lsm driver to enable
-	 listen on codec.
-
-config SND_SOC_INT_CODEC
-	tristate "SoC Machine driver for SDM660_INT"
-	depends on ARCH_QCOM
-	select SND_SOC_QDSP6V2
-	select SND_SOC_MSM_STUB
-	select SND_SOC_MSM_HOSTLESS_PCM
-	select SND_DYNAMIC_MINORS
-	select MSM_QDSP6_APRV2_GLINK
-	select MSM_QDSP6_SSR
-	select MSM_QDSP6_PDR
-	select MSM_QDSP6_NOTIFIER
-	select MSM_QDSP6V2_CODECS
-	select MSM_CDC_PINCTRL
-	select SND_SOC_MSM_SDW
-	select SND_SOC_SDM660_CDC
-	select QTI_PP
-	select DTS_SRS_TM
-	select DOLBY_LICENSE
-	select SND_HWDEP
-	select MSM_ULTRASOUND
-	select DTS_EAGLE
-	select SND_SOC_COMPRESS
-	select PINCTRL_LPI
-	help
-	To add support for SoC audio on MSM_INT.
-	This will enable sound soc drivers which
-	interfaces with DSP, also it will enable
-	the machine driver and the corresponding
-	DAI-links
-
-config SND_SOC_EXT_CODEC
-	tristate "SoC Machine driver for SDM660_EXT"
-	depends on ARCH_QCOM
-	select SND_SOC_QDSP6V2
-	select SND_SOC_MSM_STUB
-	select SND_SOC_MSM_HOSTLESS_PCM
-	select SND_DYNAMIC_MINORS
-	select MSM_QDSP6_APRV2_GLINK
-	select MSM_QDSP6_SSR
-	select MSM_QDSP6_PDR
-	select MSM_QDSP6_NOTIFIER
-	select MSM_QDSP6V2_CODECS
-	select SND_SOC_WCD9335
-	select SND_SOC_WCD934X
-	select SND_SOC_WSA881X
-	select MFD_CORE
-	select QTI_PP
-	select DTS_SRS_TM
-	select DOLBY_LICENSE
-	select SND_SOC_CPE
-	select SND_SOC_WCD_CPE
-	select SND_HWDEP
-	select MSM_ULTRASOUND
-	select DTS_EAGLE
-	select SND_SOC_COMPRESS
-	select PINCTRL_LPI
-	help
-	To add support for SoC audio on MSM_EXT.
-	This will enable sound soc drivers which
-	interfaces with DSP, also it will enable
-	the machine driver and the corresponding
-	DAI-links
-
-config SND_SOC_MACHINE_MSM8998
-	tristate "SoC Machine driver for MSM8998 boards"
-	select SND_SOC_WSA881X
-	select SND_SOC_WCD9335
-	select SND_SOC_WCD934X
-	select SND_SOC_CPE
-
-	help
-	To enable the machine driver and the
-	corresponding DAI-links on MSM8998.
-	All platform specific audio modules are
-	enabled here.
-
-config SND_SOC_MSM8998
-	tristate "Sound SoC drivers to interface with DSP"
-	depends on ARCH_QCOM
-	select SND_SOC_COMPRESS
-	select SND_SOC_QDSP6V2
-	select SND_SOC_MSM_STUB
-	select SND_SOC_MSM_HOSTLESS_PCM
-	select SND_DYNAMIC_MINORS
-	select MSM_QDSP6_APRV2_GLINK
-	select MSM_QDSP6_SSR
-	select MSM_QDSP6_PDR
-	select MSM_QDSP6_NOTIFIER
-	select MSM_QDSP6V2_CODECS
-	select SND_SOC_MSM_HDMI_CODEC_RX
-	select DTS_SRS_TM
-	select QTI_PP
-	select MSM_ULTRASOUND
-	select DOLBY_LICENSE
-	select SND_HWDEP
-        select DTS_EAGLE
-	help
-	 To add support for SoC audio on MSM8998.
-	 This will enable sound soc drivers which
-	 interfaces with DSP, also it will enable
-	 the machine driver and the corresponding
-	 DAI-links
-
-config SND_SOC_660
-	tristate "SoC Machine driver for SDM660/670 boards"
-	depends on ARCH_QCOM
-	select SND_SOC_INT_CODEC
-	select SND_SOC_EXT_CODEC
-	help
-	 To add support for SoC audio on SDM660/670.
-	 This will enable sound soc drivers which
-	 interfaces with DSP, also it will enable
-	 the machine driver and the corresponding
-	 DAI-links
-
-config SND_SOC_MACHINE_SDM845
-	tristate "SoC Machine driver for SDM845 boards"
-	select SND_SOC_WSA881X
-	select SND_SOC_WCD934X
-
-	help
-	To enable the machine driver and the
-	corresponding DAI-links on SDM845.
-	All platform specific audio modules are
-	enabled here.
-
-config SND_SOC_SDM845
-	tristate "SoC Machine driver for SDM845 boards"
-	depends on ARCH_QCOM
-	select SND_SOC_COMPRESS
-	select SND_SOC_QDSP6V2
-	select SND_SOC_MSM_STUB
-	select SND_SOC_MSM_HOSTLESS_PCM
-	select SND_DYNAMIC_MINORS
-	select MSM_QDSP6_APRV2_GLINK
-	select MSM_QDSP6_SSR
-	select MSM_QDSP6_PDR
-	select MSM_QDSP6_NOTIFIER
-	select MSM_QDSP6V2_CODECS
-	select SND_SOC_MSM_HDMI_CODEC_RX
-	select DTS_SRS_TM
-	select QTI_PP
-	select MSM_ULTRASOUND
-	select DOLBY_DS2
-	select SND_HWDEP
-        select DTS_EAGLE
-	help
-	 To add support for SoC audio on SDM845.
-	 This enables sound soc drivers that interfaces
-	 with DSP. This also enables the machine driver
-	 and the corresponding DAI-links.
-
-endmenu
diff --git a/sound/soc/msm/Makefile b/sound/soc/msm/Makefile
deleted file mode 100644
index 93fddb5..0000000
--- a/sound/soc/msm/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-# MSM Machine Support
-
-snd-soc-hostless-pcm-objs := msm-pcm-hostless.o
-obj-$(CONFIG_SND_SOC_MSM_HOSTLESS_PCM) += snd-soc-hostless-pcm.o
-
-obj-$(CONFIG_SND_SOC_MSM_QDSP6V2_INTF) += qdsp6v2/
-
-snd-soc-qdsp6v2-objs := msm-dai-fe.o
-obj-$(CONFIG_SND_SOC_QDSP6V2) += snd-soc-qdsp6v2.o
-
-#for CPE drivers
-snd-soc-cpe-objs := msm-cpe-lsm.o
-obj-$(CONFIG_SND_SOC_CPE) += snd-soc-cpe.o
-
-# for MSM8998 sound card driver
-snd-soc-msm8998-objs := msm8998.o
-obj-$(CONFIG_SND_SOC_MACHINE_MSM8998) += snd-soc-msm8998.o
-
-# for SDM660 sound card driver
-snd-soc-sdm660-common-objs := sdm660-common.o
-obj-$(CONFIG_SND_SOC_660) += snd-soc-sdm660-common.o
-
-# for SDM660 sound card driver
-snd-soc-int-codec-objs := sdm660-internal.o
-obj-$(CONFIG_SND_SOC_INT_CODEC) += snd-soc-sdm660-common.o
-obj-$(CONFIG_SND_SOC_INT_CODEC) += snd-soc-int-codec.o
-
-# for SDM660 sound card driver
-snd-soc-ext-codec-objs := sdm660-external.o sdm660-ext-dai-links.o
-obj-$(CONFIG_SND_SOC_EXT_CODEC) += snd-soc-sdm660-common.o
-obj-$(CONFIG_SND_SOC_EXT_CODEC) += snd-soc-ext-codec.o
-
-# for SDM845 sound card driver
-snd-soc-sdm845-objs := sdm845.o
-obj-$(CONFIG_SND_SOC_MACHINE_SDM845) += snd-soc-sdm845.o
diff --git a/sound/soc/msm/device_event.h b/sound/soc/msm/device_event.h
deleted file mode 100644
index 408d114..0000000
--- a/sound/soc/msm/device_event.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __DEVICE_EVENT_H
-#define __DEVICE_EVENT_H
-
-#define QC_AUDIO_EXTERNAL_SPK_1_EVENT "qc_ext_spk_1"
-#define QC_AUDIO_EXTERNAL_SPK_2_EVENT "qc_ext_spk_2"
-#define QC_AUDIO_EXTERNAL_MIC_EVENT "qc_ext_mic"
-
-#endif /* __DEVICE_EVENT_H */
diff --git a/sound/soc/msm/msm-cpe-lsm.c b/sound/soc/msm/msm-cpe-lsm.c
deleted file mode 100644
index 7b65dda..0000000
--- a/sound/soc/msm/msm-cpe-lsm.c
+++ /dev/null
@@ -1,3342 +0,0 @@
-/*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/kthread.h>
-#include <linux/platform_device.h>
-#include <linux/of.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/freezer.h>
-#include <sound/soc.h>
-#include <sound/cpe_core.h>
-#include <sound/lsm_params.h>
-#include <sound/pcm_params.h>
-#include <sound/msm-slim-dma.h>
-
-#define SAMPLE_RATE_48KHZ 48000
-#define SAMPLE_RATE_16KHZ 16000
-#define LSM_VOICE_WAKEUP_APP_V2 2
-#define AFE_PORT_ID_1 1
-#define AFE_PORT_ID_3 3
-#define AFE_OUT_PORT_2 2
-#define LISTEN_MIN_NUM_PERIODS     2
-#define LISTEN_MAX_NUM_PERIODS     12
-#define LISTEN_MAX_PERIOD_SIZE     61440
-#define LISTEN_MIN_PERIOD_SIZE     320
-#define LISTEN_MAX_STATUS_PAYLOAD_SIZE 256
-#define MSM_CPE_MAX_CUSTOM_PARAM_SIZE 2048
-
-#define MSM_CPE_LAB_THREAD_TIMEOUT (3 * (HZ/10))
-
-#define MSM_CPE_LSM_GRAB_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock acquire\n",	\
-		 __func__, name);		\
-	mutex_lock(lock);			\
-}
-
-#define MSM_CPE_LSM_REL_LOCK(lock, name)		\
-{						\
-	pr_debug("%s: %s lock release\n",	\
-		 __func__, name);		\
-	mutex_unlock(lock);			\
-}
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	8000, 16000, 48000, 192000, 384000
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-
-static struct snd_pcm_hardware msm_pcm_hardware_listen = {
-	.info =	(SNDRV_PCM_INFO_BLOCK_TRANSFER |
-		 SNDRV_PCM_INFO_MMAP_VALID |
-		 SNDRV_PCM_INFO_INTERLEAVED |
-		 SNDRV_PCM_INFO_PAUSE |
-		 SNDRV_PCM_INFO_RESUME),
-	.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-		    SNDRV_PCM_FMTBIT_S24_LE |
-		    SNDRV_PCM_FMTBIT_S32_LE),
-	.rates = (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
-		  SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000),
-	.rate_min = 16000,
-	.rate_max = 384000,
-	.channels_min =	1,
-	.channels_max =	1,
-	.buffer_bytes_max = LISTEN_MAX_NUM_PERIODS *
-			    LISTEN_MAX_PERIOD_SIZE,
-	.period_bytes_min = LISTEN_MIN_PERIOD_SIZE,
-	.period_bytes_max = LISTEN_MAX_PERIOD_SIZE,
-	.periods_min = LISTEN_MIN_NUM_PERIODS,
-	.periods_max = LISTEN_MAX_NUM_PERIODS,
-	.fifo_size = 0,
-};
-
-enum {
-	AFE_CMD_INVALID = 0,
-	AFE_CMD_PORT_START,
-	AFE_CMD_PORT_SUSPEND,
-	AFE_CMD_PORT_RESUME,
-	AFE_CMD_PORT_STOP,
-};
-
-enum cpe_lab_thread_status {
-	MSM_LSM_LAB_THREAD_STOP,
-	MSM_LSM_LAB_THREAD_RUNNING,
-	MSM_LSM_LAB_THREAD_ERROR,
-};
-
-struct cpe_hw_params {
-	u32 sample_rate;
-	u16 sample_size;
-	u32 buf_sz;
-	u32 period_count;
-	u16 channels;
-};
-
-struct cpe_data_pcm_buf {
-	u8 *mem;
-	phys_addr_t phys;
-};
-
-struct cpe_lsm_lab {
-	atomic_t in_count;
-	atomic_t abort_read;
-	u32 dma_write;
-	u32 buf_idx;
-	u32 pcm_size;
-	enum cpe_lab_thread_status thread_status;
-	struct cpe_data_pcm_buf *pcm_buf;
-	wait_queue_head_t period_wait;
-	struct completion comp;
-	struct completion thread_complete;
-};
-
-struct cpe_priv {
-	void *core_handle;
-	struct snd_soc_codec *codec;
-	struct wcd_cpe_lsm_ops lsm_ops;
-	struct wcd_cpe_afe_ops afe_ops;
-	bool afe_mad_ctl;
-	u32 input_port_id;
-};
-
-struct cpe_lsm_data {
-	struct device *dev;
-	struct cpe_lsm_session *lsm_session;
-	struct mutex lsm_api_lock;
-	struct cpe_lsm_lab lab;
-	struct cpe_hw_params hw_params;
-	struct snd_pcm_substream *substream;
-
-	wait_queue_head_t event_wait;
-	atomic_t event_avail;
-	atomic_t event_stop;
-
-	u8 ev_det_status;
-	u8 ev_det_pld_size;
-	u8 *ev_det_payload;
-
-	bool cpe_prepared;
-};
-
-static int msm_cpe_afe_mad_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct cpe_priv *cpe = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] = cpe->afe_mad_ctl;
-	return 0;
-}
-
-static int msm_cpe_afe_mad_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct cpe_priv *cpe = kcontrol->private_data;
-
-	cpe->afe_mad_ctl = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static struct snd_kcontrol_new msm_cpe_kcontrols[] = {
-	SOC_SINGLE_EXT("CPE AFE MAD Enable", SND_SOC_NOPM, 0, 1, 0,
-			msm_cpe_afe_mad_ctl_get, msm_cpe_afe_mad_ctl_put),
-};
-
-/*
- * cpe_get_private_data: obtain ASoC platform driver private data
- * @substream: ASoC substream for which private data to be obtained
- */
-static struct cpe_priv *cpe_get_private_data(
-	struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: %s is invalid\n",
-			__func__,
-			(!substream) ? "substream" : "private_data");
-		goto err_ret;
-	}
-
-	rtd = substream->private_data;
-
-	if (!rtd || !rtd->platform) {
-		pr_err("%s: %s is invalid\n",
-			 __func__,
-			(!rtd) ? "runtime" : "platform");
-		goto err_ret;
-	}
-
-	return snd_soc_platform_get_drvdata(rtd->platform);
-
-err_ret:
-	return NULL;
-}
-
-/*
- * cpe_get_lsm_data: obtain the lsm session data given the substream
- * @substream: ASoC substream for which lsm session data to be obtained
- */
-static struct cpe_lsm_data *cpe_get_lsm_data(
-	struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-
-	return runtime->private_data;
-}
-
-static void msm_cpe_process_event_status(void *data,
-		u8 detect_status, u8 size, u8 *payload)
-{
-	struct cpe_lsm_data *lsm_d = data;
-
-	lsm_d->ev_det_status = detect_status;
-	lsm_d->ev_det_pld_size = size;
-
-	lsm_d->ev_det_payload = kzalloc(size, GFP_KERNEL);
-	if (!lsm_d->ev_det_payload)
-		return;
-
-	memcpy(lsm_d->ev_det_payload, payload, size);
-
-	atomic_set(&lsm_d->event_avail, 1);
-	wake_up(&lsm_d->event_wait);
-}
-
-static void msm_cpe_process_event_status_done(struct cpe_lsm_data *lsm_data)
-{
-	kfree(lsm_data->ev_det_payload);
-	lsm_data->ev_det_payload = NULL;
-
-	lsm_data->ev_det_status = 0;
-	lsm_data->ev_det_pld_size = 0;
-}
-
-/*
- * msm_cpe_afe_port_cntl: Perform the afe port control
- * @substream: substream for which afe port command to be performed
- * @core_handle: handle to core
- * @afe_ops: handle to the afe operations
- * @afe_cfg: afe port configuration data
- * @cmd: command to be sent to AFE
- *
- */
-static int msm_cpe_afe_port_cntl(
-		struct snd_pcm_substream *substream,
-		void *core_handle,
-		struct wcd_cpe_afe_ops *afe_ops,
-		struct wcd_cpe_afe_port_cfg *afe_cfg,
-		int cmd)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-
-	if (!afe_cfg->port_id) {
-		/*
-		 * It is possible driver can get closed without prepare,
-		 * in which case afe ports will not be initialized.
-		 */
-		dev_dbg(rtd->dev,
-			"%s: Invalid afe port id\n",
-			__func__);
-		return 0;
-	}
-
-	switch (cmd) {
-	case AFE_CMD_PORT_START:
-		rc = afe_ops->afe_port_start(core_handle, afe_cfg);
-		if (rc != 0)
-			dev_err(rtd->dev,
-				"%s: AFE port start failed\n",
-				__func__);
-		break;
-	case AFE_CMD_PORT_SUSPEND:
-		rc = afe_ops->afe_port_suspend(core_handle, afe_cfg);
-		if (rc != 0)
-			dev_err(rtd->dev,
-				"%s: afe_suspend failed, err = %d\n",
-				__func__, rc);
-		break;
-	case AFE_CMD_PORT_RESUME:
-		rc = afe_ops->afe_port_resume(core_handle, afe_cfg);
-		if (rc != 0)
-			dev_err(rtd->dev,
-				"%s: afe_resume failed, err = %d\n",
-				__func__, rc);
-		break;
-	case AFE_CMD_PORT_STOP:
-		rc = afe_ops->afe_port_stop(core_handle, afe_cfg);
-		if (rc != 0)
-			dev_err(rtd->dev,
-				"%s: afe_stopfailed, err = %d\n",
-				__func__, rc);
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_cpe_lsm_lab_stop(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct cpe_lsm_session *session;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct msm_slim_dma_data *dma_data = NULL;
-	int rc;
-
-	/*
-	 * the caller is not aware of LAB status and will
-	 * try to stop lab even if it is already stopped.
-	 * return success right away is LAB is already stopped
-	 */
-	if (lab_d->thread_status == MSM_LSM_LAB_THREAD_STOP) {
-		dev_dbg(rtd->dev,
-			"%s: lab already stopped\n",
-			__func__);
-		return 0;
-	}
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	lsm_ops = &cpe->lsm_ops;
-	afe_ops = &cpe->afe_ops;
-	session = lsm_d->lsm_session;
-	if (rtd->cpu_dai)
-		dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai,
-					substream);
-	if (!dma_data || !dma_data->dai_channel_ctl) {
-		dev_err(rtd->dev,
-			"%s: dma_data is not set\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (lab_d->thread_status == MSM_LSM_LAB_THREAD_RUNNING) {
-		dev_dbg(rtd->dev, "%s: stopping lab thread\n",
-			__func__);
-		rc = kthread_stop(session->lsm_lab_thread);
-
-		/*
-		 * kthread_stop returns EINTR if the thread_fn
-		 * was not scheduled before calling kthread_stop.
-		 * In this case, we dont need to wait for lab
-		 * thread to complete as lab thread will not be
-		 * scheduled at all.
-		 */
-		if (rc == -EINTR)
-			goto done;
-
-		/* Wait for the lab thread to exit */
-		rc = wait_for_completion_timeout(
-				&lab_d->thread_complete,
-				MSM_CPE_LAB_THREAD_TIMEOUT);
-		if (!rc) {
-			dev_err(rtd->dev,
-				"%s: Wait for lab thread timedout\n",
-				__func__);
-			return -ETIMEDOUT;
-		}
-	}
-
-	rc = lsm_ops->lab_ch_setup(cpe->core_handle,
-				   session,
-				   WCD_CPE_PRE_DISABLE);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: PRE ch teardown failed, err = %d\n",
-			__func__, rc);
-	/* continue with teardown even if any intermediate step fails */
-	rc = dma_data->dai_channel_ctl(dma_data, rtd->cpu_dai, false);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: open data failed %d\n", __func__, rc);
-	dma_data->ph = 0;
-
-	/*
-	 * Even though LAB stop failed,
-	 * output AFE port needs to be stopped
-	 */
-	rc = afe_ops->afe_port_stop(cpe->core_handle,
-				    &session->afe_out_port_cfg);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: AFE out port stop failed, err = %d\n",
-			__func__, rc);
-
-	rc = lsm_ops->lab_ch_setup(cpe->core_handle,
-				   session,
-				   WCD_CPE_POST_DISABLE);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: POST ch teardown failed, err = %d\n",
-			__func__, rc);
-
-done:
-	lab_d->thread_status = MSM_LSM_LAB_THREAD_STOP;
-	lab_d->buf_idx = 0;
-	atomic_set(&lab_d->in_count, 0);
-	lab_d->dma_write = 0;
-
-	return 0;
-}
-
-static int msm_cpe_lab_buf_alloc(struct snd_pcm_substream *substream,
-		struct cpe_lsm_session *session,
-		struct msm_slim_dma_data *dma_data)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct cpe_hw_params *hw_params = &lsm_d->hw_params;
-	struct cpe_data_pcm_buf *pcm_buf = NULL;
-	int rc = 0;
-	int dma_alloc = 0;
-	u32 count = 0;
-	u32 bufsz, bufcnt;
-
-	if (lab_d->pcm_buf &&
-	    lab_d->pcm_buf->mem) {
-		dev_dbg(rtd->dev,
-			"%s: LAB buf already allocated\n",
-			__func__);
-		goto exit;
-	}
-
-	bufsz = hw_params->buf_sz;
-	bufcnt = hw_params->period_count;
-
-	dev_dbg(rtd->dev,
-		"%s:Buf Size %d Buf count %d\n",
-		 __func__,
-		bufsz, bufcnt);
-
-	pcm_buf = kzalloc(((sizeof(struct cpe_data_pcm_buf)) * bufcnt),
-			  GFP_KERNEL);
-	if (!pcm_buf) {
-		rc = -ENOMEM;
-		goto exit;
-	}
-
-	lab_d->pcm_buf = pcm_buf;
-	dma_alloc = bufsz * bufcnt;
-	pcm_buf->mem = NULL;
-	pcm_buf->mem = dma_alloc_coherent(dma_data->sdev->dev.parent,
-					  dma_alloc,
-					  &(pcm_buf->phys),
-					  GFP_KERNEL);
-	if (!pcm_buf->mem) {
-		dev_err(rtd->dev,
-			"%s:DMA alloc failed size = %x\n",
-			__func__, dma_alloc);
-		rc = -ENOMEM;
-		goto fail;
-	}
-
-	count = 0;
-	while (count < bufcnt) {
-		pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz);
-		pcm_buf[count].phys = pcm_buf[0].phys + (count * bufsz);
-		dev_dbg(rtd->dev,
-			"%s: pcm_buf[%d].mem %pK pcm_buf[%d].phys %pK\n",
-			 __func__, count,
-			(void *)pcm_buf[count].mem,
-			count, &(pcm_buf[count].phys));
-		count++;
-	}
-
-	return 0;
-fail:
-	if (pcm_buf) {
-		if (pcm_buf->mem)
-			dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc,
-					  pcm_buf->mem, pcm_buf->phys);
-		kfree(pcm_buf);
-		lab_d->pcm_buf = NULL;
-	}
-exit:
-	return rc;
-}
-
-static int msm_cpe_lab_buf_dealloc(struct snd_pcm_substream *substream,
-	struct cpe_lsm_session *session, struct msm_slim_dma_data *dma_data)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct cpe_hw_params *hw_params = &lsm_d->hw_params;
-	int rc = 0;
-	int dma_alloc = 0;
-	struct cpe_data_pcm_buf *pcm_buf = NULL;
-	int bufsz, bufcnt;
-
-	bufsz = hw_params->buf_sz;
-	bufcnt = hw_params->period_count;
-
-	dev_dbg(rtd->dev,
-		"%s:Buf Size %d Buf count %d\n", __func__,
-		bufsz, bufcnt);
-
-	if (bufcnt <= 0 || bufsz <= 0) {
-		dev_err(rtd->dev,
-			"%s: Invalid params, bufsz = %u, bufcnt = %u\n",
-			__func__, bufsz, bufcnt);
-		return -EINVAL;
-	}
-
-	pcm_buf = lab_d->pcm_buf;
-	dma_alloc = bufsz * bufcnt;
-	if (dma_data && pcm_buf)
-		dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc,
-				  pcm_buf->mem, pcm_buf->phys);
-	kfree(pcm_buf);
-	lab_d->pcm_buf = NULL;
-	return rc;
-}
-
-/*
- * msm_cpe_lab_thread: Initiated on KW detection
- * @data: lab data
- *
- * Start lab thread and call CPE core API for SLIM
- * read operations.
- */
-static int msm_cpe_lab_thread(void *data)
-{
-	struct cpe_lsm_data *lsm_d = data;
-	struct cpe_lsm_session *session = lsm_d->lsm_session;
-	struct snd_pcm_substream *substream = lsm_d->substream;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct cpe_hw_params *hw_params = &lsm_d->hw_params;
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct cpe_data_pcm_buf *cur_buf, *next_buf;
-	struct msm_slim_dma_data *dma_data = NULL;
-	struct snd_soc_pcm_runtime *rtd = NULL;
-	bool wait_timedout = false;
-	int rc = 0;
-	u32 done_len = 0;
-	u32 buf_count = 0;
-	u32 prd_cnt;
-
-	allow_signal(SIGKILL);
-	set_current_state(TASK_INTERRUPTIBLE);
-
-	pr_debug("%s: Lab thread start\n", __func__);
-	init_completion(&lab_d->comp);
-
-	if (PCM_RUNTIME_CHECK(substream)) {
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (!cpe || !cpe->core_handle) {
-		pr_err("%s: Handle to %s is invalid\n",
-			__func__,
-			(!cpe) ? "cpe" : "core");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	rtd = substream->private_data;
-	if (rtd->cpu_dai)
-		dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai,
-					substream);
-	if (!dma_data || !dma_data->dai_channel_ctl) {
-		pr_err("%s: dma_data is not set\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	lsm_ops = &cpe->lsm_ops;
-	afe_ops = &cpe->afe_ops;
-
-	rc = lsm_ops->lab_ch_setup(cpe->core_handle,
-				   session,
-				   WCD_CPE_PRE_ENABLE);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: PRE ch setup failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	rc = dma_data->dai_channel_ctl(dma_data, rtd->cpu_dai, true);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: open data failed %d\n", __func__, rc);
-		goto done;
-	}
-
-	dev_dbg(rtd->dev, "%s: Established data channel\n",
-		__func__);
-
-	init_waitqueue_head(&lab_d->period_wait);
-	memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size);
-
-	rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
-			    lab_d->pcm_buf[0].phys,
-			    hw_params->buf_sz, &lab_d->comp);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: buf[0] slim_port_xfer failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
-			    lab_d->pcm_buf[1].phys,
-			    hw_params->buf_sz, &lab_d->comp);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: buf[0] slim_port_xfer failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	cur_buf = &lab_d->pcm_buf[0];
-	next_buf = &lab_d->pcm_buf[2];
-	prd_cnt = hw_params->period_count;
-	rc = lsm_ops->lab_ch_setup(cpe->core_handle,
-				   session,
-				   WCD_CPE_POST_ENABLE);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: POST ch setup failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	rc = afe_ops->afe_port_start(cpe->core_handle,
-			&session->afe_out_port_cfg);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: AFE out port start failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	while (!kthread_should_stop() &&
-	       lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) {
-
-		rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
-				    next_buf->phys,
-				    hw_params->buf_sz, &lab_d->comp);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: slim_port_xfer failed, err = %d\n",
-				__func__, rc);
-			lab_d->thread_status = MSM_LSM_LAB_THREAD_ERROR;
-		}
-
-		rc = wait_for_completion_timeout(&lab_d->comp, (2 * HZ/10));
-		if (!rc) {
-			dev_err(rtd->dev,
-				"%s: wait timedout for slim buffer\n",
-				__func__);
-			wait_timedout = true;
-		} else {
-			wait_timedout = false;
-		}
-
-		rc = slim_port_get_xfer_status(dma_data->sdev,
-					       dma_data->ph,
-					       &cur_buf->phys, &done_len);
-		if (rc ||
-		    (!rc && wait_timedout)) {
-			dev_err(rtd->dev,
-				"%s: xfer_status failure, rc = %d, wait_timedout = %s\n",
-				__func__, rc,
-				(wait_timedout ? "true" : "false"));
-			lab_d->thread_status = MSM_LSM_LAB_THREAD_ERROR;
-		}
-
-		if (done_len ||
-		    ((!done_len) &&
-		     lab_d->thread_status == MSM_LSM_LAB_THREAD_ERROR)) {
-			atomic_inc(&lab_d->in_count);
-			lab_d->dma_write += snd_pcm_lib_period_bytes(substream);
-			snd_pcm_period_elapsed(substream);
-			wake_up(&lab_d->period_wait);
-			buf_count++;
-
-			cur_buf = &lab_d->pcm_buf[buf_count % prd_cnt];
-			next_buf = &lab_d->pcm_buf[(buf_count + 2) % prd_cnt];
-			dev_dbg(rtd->dev,
-				"%s: Cur buf.mem = %pK Next Buf.mem = %pK\n"
-				" buf count = 0x%x\n", __func__,
-				cur_buf->mem, next_buf->mem, buf_count);
-		} else {
-			dev_err(rtd->dev,
-				"%s: SB get status, invalid len = 0x%x\n",
-				__func__, done_len);
-		}
-		done_len = 0;
-	}
-
-done:
-	if (rc)
-		lab_d->thread_status = MSM_LSM_LAB_THREAD_ERROR;
-	pr_debug("%s: Exit lab_thread, exit_status=%d, thread_status=%d\n",
-		 __func__, rc, lab_d->thread_status);
-	complete(&lab_d->thread_complete);
-
-	return 0;
-}
-
-/*
- * msm_cpe_lsm_open: ASoC call to open the stream
- * @substream: substream that is to be opened
- *
- * Create session data for lsm session and open the lsm session
- * on CPE.
- */
-static int msm_cpe_lsm_open(struct snd_pcm_substream *substream)
-{
-	struct cpe_lsm_data *lsm_d;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	int rc = 0;
-
-	if (!cpe || !cpe->codec) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	runtime->hw = msm_pcm_hardware_listen;
-
-	rc = snd_pcm_hw_constraint_list(runtime, 0,
-				SNDRV_PCM_HW_PARAM_RATE,
-				&constraints_sample_rates);
-	if (rc < 0) {
-		pr_err("snd_pcm_hw_constraint_list failed rc %d\n", rc);
-		return -EINVAL;
-	}
-
-	/* Ensure that buffer size is a multiple of period size */
-	rc = snd_pcm_hw_constraint_integer(runtime,
-					   SNDRV_PCM_HW_PARAM_PERIODS);
-	if (rc < 0) {
-		pr_err("%s: Unable to set pcm_param_periods, rc %d\n",
-			__func__, rc);
-		return -EINVAL;
-	}
-
-	rc = snd_pcm_hw_constraint_minmax(runtime,
-		SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-		LISTEN_MIN_NUM_PERIODS * LISTEN_MIN_PERIOD_SIZE,
-		LISTEN_MAX_NUM_PERIODS * LISTEN_MAX_PERIOD_SIZE);
-	if (rc < 0) {
-		pr_err("%s: Unable to set pcm constraints, rc %d\n",
-			__func__, rc);
-		return -EINVAL;
-	}
-
-	cpe->core_handle = wcd_cpe_get_core_handle(cpe->codec);
-
-	if (!cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid handle to codec core\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	lsm_ops = &cpe->lsm_ops;
-	lsm_d = kzalloc(sizeof(struct cpe_lsm_data), GFP_KERNEL);
-	if (!lsm_d) {
-		dev_err(rtd->dev,
-			"%s: ENOMEM for lsm session, size = %zd\n",
-			__func__, sizeof(struct cpe_lsm_data));
-		rc = -ENOMEM;
-		goto fail_return;
-	}
-	mutex_init(&lsm_d->lsm_api_lock);
-
-	lsm_d->lsm_session = lsm_ops->lsm_alloc_session(cpe->core_handle,
-					lsm_d, msm_cpe_process_event_status);
-	if (!lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: session allocation failed",
-			__func__);
-		rc = -EINVAL;
-		goto fail_session_alloc;
-	}
-	/* Explicitly Assign the LAB thread to STOP state */
-	lsm_d->lab.thread_status = MSM_LSM_LAB_THREAD_STOP;
-	lsm_d->lsm_session->started = false;
-	lsm_d->substream = substream;
-	init_waitqueue_head(&lsm_d->lab.period_wait);
-	lsm_d->cpe_prepared = false;
-
-	dev_dbg(rtd->dev, "%s: allocated session with id = %d\n",
-		__func__, lsm_d->lsm_session->id);
-
-
-	rc = lsm_ops->lsm_open_tx(cpe->core_handle, lsm_d->lsm_session,
-				   LSM_VOICE_WAKEUP_APP_V2, 16000);
-	if (rc  < 0) {
-		dev_err(rtd->dev,
-			"%s: OPEN_TX cmd failed, err = %d\n",
-			__func__, rc);
-		goto fail_open_tx;
-	}
-
-	init_waitqueue_head(&lsm_d->event_wait);
-	atomic_set(&lsm_d->event_avail, 0);
-	atomic_set(&lsm_d->event_stop, 0);
-	runtime->private_data = lsm_d;
-
-	return 0;
-
-fail_open_tx:
-	lsm_ops->lsm_dealloc_session(cpe->core_handle, lsm_d->lsm_session);
-
-fail_session_alloc:
-	mutex_destroy(&lsm_d->lsm_api_lock);
-	kfree(lsm_d);
-fail_return:
-	return rc;
-}
-
-/*
- * msm_cpe_lsm_close: ASoC call to close/cleanup the stream
- * @substream: substream that is to be closed
- *
- * Deallocate the session and release the AFE port. It is not
- * required to deregister the sound model as long as we close
- * the lsm session on CPE.
- */
-static int msm_cpe_lsm_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct cpe_lsm_session *session;
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct wcd_cpe_afe_port_cfg *afe_cfg;
-	int rc = 0;
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	lsm_ops = &cpe->lsm_ops;
-	session = lsm_d->lsm_session;
-	afe_ops = &cpe->afe_ops;
-	afe_cfg = &(lsm_d->lsm_session->afe_port_cfg);
-
-	/*
-	 * If driver is closed without stopping LAB,
-	 * explicitly stop LAB before cleaning up the
-	 * driver resources.
-	 */
-	rc = msm_cpe_lsm_lab_stop(substream);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: Failed to stop lab, error = %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = msm_cpe_afe_port_cntl(substream,
-				   cpe->core_handle,
-				   afe_ops, afe_cfg,
-				   AFE_CMD_PORT_STOP);
-
-	lsm_d->cpe_prepared = false;
-
-	rc = lsm_ops->lsm_close_tx(cpe->core_handle, session);
-	if (rc != 0) {
-		dev_err(rtd->dev,
-			"%s: lsm_close fail, err = %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	lsm_ops->lsm_dealloc_session(cpe->core_handle, session);
-	runtime->private_data = NULL;
-	mutex_destroy(&lsm_d->lsm_api_lock);
-	kfree(lsm_d);
-
-	return rc;
-}
-
-static int msm_cpe_lsm_get_conf_levels(
-		struct cpe_lsm_session *session,
-		u8 *conf_levels_ptr)
-{
-	int rc = 0;
-
-	if (session->num_confidence_levels <= 0) {
-		pr_debug("%s: conf_levels (%u), skip set params\n",
-			 __func__,
-			session->num_confidence_levels);
-		goto done;
-	}
-
-	session->conf_levels = kzalloc(session->num_confidence_levels,
-				       GFP_KERNEL);
-	if (!session->conf_levels) {
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	if (copy_from_user(session->conf_levels,
-			   conf_levels_ptr,
-			   session->num_confidence_levels)) {
-		pr_err("%s: copy_from_user failed for confidence levels %u\n",
-			__func__, session->num_confidence_levels);
-		kfree(session->conf_levels);
-		session->conf_levels = NULL;
-		rc = -EFAULT;
-		goto done;
-	}
-
-done:
-	return rc;
-}
-
-static int msm_cpe_lsm_validate_out_format(
-	struct snd_pcm_substream *substream,
-	struct snd_lsm_output_format_cfg *cfg)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-
-	if (!cfg) {
-		dev_err(rtd->dev,
-			"%s: Invalid lsm out cfg\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (cfg->format != LSM_OUT_FORMAT_PCM &&
-	    cfg->format != LSM_OUT_FORMAT_ADPCM) {
-		dev_err(rtd->dev,
-			"%s: Invalid format %u\n",
-			__func__, cfg->format);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (cfg->packing != LSM_OUT_DATA_RAW &&
-	    cfg->packing != LSM_OUT_DATA_PACKED) {
-		dev_err(rtd->dev,
-			"%s: Invalid packing method %u\n",
-			__func__, cfg->packing);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (cfg->events != LSM_OUT_DATA_EVENTS_DISABLED &&
-	    cfg->events != LSM_OUT_DATA_EVENTS_ENABLED) {
-		dev_err(rtd->dev,
-			"%s: Invalid events provided %u\n",
-			__func__, cfg->events);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (cfg->mode != LSM_OUT_TRANSFER_MODE_RT &&
-	    cfg->mode != LSM_OUT_TRANSFER_MODE_FTRT) {
-		dev_err(rtd->dev,
-			"%s: Invalid transfer mode %u\n",
-			__func__, cfg->mode);
-		rc = -EINVAL;
-		goto done;
-	}
-
-done:
-	return rc;
-}
-
-/*
- * msm_cpe_lsm_ioctl_shared: Shared IOCTL for this platform driver
- * @substream: ASoC substream for which the operation is invoked
- * @cmd: command for the ioctl
- * @arg: argument for the ioctl
- *
- * Perform dedicated listen functions like register sound model,
- * deregister sound model, etc
- * Called with lsm_api_lock acquired.
- */
-static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	struct snd_lsm_sound_model_v2 snd_model;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct cpe_lsm_session *session;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct msm_slim_dma_data *dma_data = NULL;
-	struct snd_lsm_detection_params det_params;
-	int rc = 0;
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	switch (cmd) {
-	case SNDRV_LSM_STOP_LAB:
-		dev_dbg(rtd->dev,
-			"%s: %s, lab_enable = %d, lab_thread_ststus = %d\n",
-			__func__, "SNDRV_LSM_STOP_LAB",
-			session->lab_enable,
-			lab_d->thread_status);
-
-		if (session->lab_enable &&
-		    lab_d->thread_status != MSM_LSM_LAB_THREAD_STOP) {
-			atomic_inc(&lab_d->abort_read);
-			wake_up(&lab_d->period_wait);
-			rc = msm_cpe_lsm_lab_stop(substream);
-			if (rc) {
-				dev_err(rtd->dev,
-					"%s: stop LAB failed, error = %d\n",
-					__func__, rc);
-				return rc;
-			}
-		} else if (!session->lab_enable) {
-			dev_dbg(rtd->dev,
-				"%s: LAB already stopped\n",
-				__func__);
-		}
-
-		break;
-
-	case SNDRV_LSM_LAB_CONTROL:
-		if (copy_from_user(&session->lab_enable, (void *)arg,
-				   sizeof(u32))) {
-			dev_err(rtd->dev,
-				"%s: copy_from_user failed, size %zd\n",
-				__func__, sizeof(u32));
-			return -EFAULT;
-		}
-
-		dev_dbg(rtd->dev,
-			"%s: %s, lab_enable = %d\n",
-			__func__, "SNDRV_LSM_LAB_CONTROL",
-			session->lab_enable);
-		if (rtd->cpu_dai)
-			dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai,
-						substream);
-		if (!dma_data || !dma_data->dai_channel_ctl) {
-			dev_err(rtd->dev,
-				"%s: dma_data is not set\n", __func__);
-			return -EINVAL;
-		}
-
-		if (session->lab_enable) {
-			rc = msm_cpe_lab_buf_alloc(substream,
-						   session, dma_data);
-			if (rc < 0) {
-				dev_err(rtd->dev,
-					"%s: lab buffer alloc failed, err = %d\n",
-					__func__, rc);
-				return rc;
-			}
-
-			dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-			dma_buf->dev.dev = substream->pcm->card->dev;
-			dma_buf->private_data = NULL;
-			dma_buf->area = lab_d->pcm_buf[0].mem;
-			dma_buf->addr =  lab_d->pcm_buf[0].phys;
-			dma_buf->bytes = (lsm_d->hw_params.buf_sz *
-					lsm_d->hw_params.period_count);
-			init_completion(&lab_d->thread_complete);
-			snd_pcm_set_runtime_buffer(substream,
-						   &substream->dma_buffer);
-			rc = lsm_ops->lsm_lab_control(cpe->core_handle,
-					session, true);
-			if (rc < 0) {
-				dev_err(rtd->dev,
-					"%s: Lab Enable Failed rc %d\n",
-					__func__, rc);
-				return rc;
-			}
-		} else {
-			/*
-			 * It is possible that lab is still enabled
-			 * when trying to de-allocate the lab buffer.
-			 * Make sure to disable lab before de-allocating
-			 * the lab buffer.
-			 */
-			rc = msm_cpe_lsm_lab_stop(substream);
-			if (rc < 0) {
-				dev_err(rtd->dev,
-					"%s: LAB stop failed, error = %d\n",
-					__func__, rc);
-				return rc;
-			}
-			/*
-			 * Buffer has to be de-allocated even if
-			 * lab_control failed.
-			 */
-			rc = msm_cpe_lab_buf_dealloc(substream,
-						     session, dma_data);
-			if (rc < 0) {
-				dev_err(rtd->dev,
-					"%s: lab buffer free failed, err = %d\n",
-					__func__, rc);
-				return rc;
-			}
-		}
-	break;
-	case SNDRV_LSM_REG_SND_MODEL_V2:
-		dev_dbg(rtd->dev,
-			"%s: %s\n",
-			__func__, "SNDRV_LSM_REG_SND_MODEL_V2");
-
-		memcpy(&snd_model, arg,
-			sizeof(struct snd_lsm_sound_model_v2));
-
-		session->num_confidence_levels =
-				snd_model.num_confidence_levels;
-		rc = msm_cpe_lsm_get_conf_levels(session,
-				snd_model.confidence_level);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: %s get_conf_levels fail, err = %d\n",
-				__func__, "SNDRV_LSM_REG_SND_MODEL_V2",
-				rc);
-			break;
-		}
-
-		session->snd_model_data = kzalloc(snd_model.data_size,
-						  GFP_KERNEL);
-		if (!session->snd_model_data) {
-			kfree(session->conf_levels);
-			session->conf_levels = NULL;
-			return -ENOMEM;
-		}
-		session->snd_model_size = snd_model.data_size;
-
-		if (copy_from_user(session->snd_model_data,
-				   snd_model.data, snd_model.data_size)) {
-			dev_err(rtd->dev,
-				"%s: copy_from_user failed for snd_model\n",
-				__func__);
-			kfree(session->conf_levels);
-			kfree(session->snd_model_data);
-			session->conf_levels = NULL;
-			session->snd_model_data = NULL;
-			return -EFAULT;
-		}
-
-		rc = lsm_ops->lsm_shmem_alloc(cpe->core_handle, session,
-					       session->snd_model_size);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: shared memory allocation failed, err = %d\n",
-			       __func__, rc);
-			kfree(session->snd_model_data);
-			kfree(session->conf_levels);
-			session->snd_model_data = NULL;
-			session->conf_levels = NULL;
-			return rc;
-		}
-
-		rc = lsm_ops->lsm_register_snd_model(cpe->core_handle, session,
-						snd_model.detection_mode,
-						snd_model.detect_failure);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: snd_model_reg failed, err = %d\n",
-			       __func__, rc);
-			lsm_ops->lsm_shmem_dealloc(cpe->core_handle, session);
-			kfree(session->snd_model_data);
-			kfree(session->conf_levels);
-			session->snd_model_data = NULL;
-			session->conf_levels = NULL;
-			return rc;
-		}
-
-		break;
-
-	case SNDRV_LSM_DEREG_SND_MODEL:
-		dev_dbg(rtd->dev,
-			"%s: %s\n",
-			__func__, "SNDRV_LSM_DEREG_SND_MODEL");
-
-		if (session->lab_enable) {
-			/*
-			 * It is possible that lab is still enabled
-			 * when trying to deregister sound model.
-			 * Make sure to disable lab before de-allocating
-			 * the lab buffer.
-			 */
-			rc = msm_cpe_lsm_lab_stop(substream);
-			if (rc) {
-				dev_err(rtd->dev,
-					"%s: LAB stop failed, error = %d\n",
-					__func__, rc);
-				return rc;
-			}
-
-			rc = lsm_ops->lsm_lab_control(cpe->core_handle,
-					session, false);
-			if (rc)
-				dev_err(rtd->dev,
-					"%s: Lab Disable Failed rc %d\n",
-				       __func__, rc);
-
-			dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai,
-							substream);
-			if (!dma_data || !dma_data->dai_channel_ctl)
-				dev_err(rtd->dev,
-					"%s: dma_data is not set\n", __func__);
-
-			/*
-			 * Buffer has to be de-allocated even if
-			 * lab_control failed and/or dma data is invalid.
-			 */
-			rc = msm_cpe_lab_buf_dealloc(substream,
-						session, dma_data);
-			if (rc < 0)
-				dev_err(rtd->dev,
-					"%s: lab buffer free failed, err = %d\n",
-					__func__, rc);
-		}
-
-		rc = lsm_ops->lsm_deregister_snd_model(
-				cpe->core_handle, session);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: snd_model de-reg failed, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		kfree(session->snd_model_data);
-		kfree(session->conf_levels);
-		session->snd_model_data = NULL;
-		session->conf_levels = NULL;
-
-		rc = lsm_ops->lsm_shmem_dealloc(cpe->core_handle, session);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: LSM shared memory dealloc failed, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		break;
-
-	case SNDRV_LSM_EVENT_STATUS:
-	case SNDRV_LSM_EVENT_STATUS_V3: {
-		struct snd_lsm_event_status *user;
-		struct snd_lsm_event_status_v3 *user_v3;
-
-		dev_dbg(rtd->dev,
-			"%s: %s\n",
-			__func__, "SNDRV_LSM_EVENT_STATUS(_V3)");
-		if (!arg) {
-			dev_err(rtd->dev,
-				"%s: Invalid argument to ioctl %s\n",
-				__func__,
-				"SNDRV_LSM_EVENT_STATUS(_V3)");
-			return -EINVAL;
-		}
-
-		/*
-		 * Release the api lock before wait to allow
-		 * other IOCTLs to be invoked while waiting
-		 * for event
-		 */
-		MSM_CPE_LSM_REL_LOCK(&lsm_d->lsm_api_lock,
-				     "lsm_api_lock");
-
-		rc = wait_event_freezable(lsm_d->event_wait,
-				(atomic_read(&lsm_d->event_avail) == 1) ||
-				(atomic_read(&lsm_d->event_stop) == 1));
-
-		MSM_CPE_LSM_GRAB_LOCK(&lsm_d->lsm_api_lock,
-				      "lsm_api_lock");
-
-		if (!rc) {
-			if (atomic_read(&lsm_d->event_avail) == 1) {
-				rc = 0;
-				atomic_set(&lsm_d->event_avail, 0);
-
-				if (cmd == SNDRV_LSM_EVENT_STATUS) {
-					user = arg;
-					if (lsm_d->ev_det_pld_size >
-						user->payload_size) {
-						dev_err(rtd->dev,
-							"%s: avail pld_bytes = %u, needed = %u\n",
-							__func__,
-							user->payload_size,
-							lsm_d->ev_det_pld_size);
-						return -EINVAL;
-					}
-
-					user->status = lsm_d->ev_det_status;
-					user->payload_size =
-							lsm_d->ev_det_pld_size;
-					memcpy(user->payload,
-					       lsm_d->ev_det_payload,
-					       lsm_d->ev_det_pld_size);
-				} else {
-					user_v3 = arg;
-					if (lsm_d->ev_det_pld_size >
-						user_v3->payload_size) {
-						dev_err(rtd->dev,
-							"%s: avail pld_bytes = %u, needed = %u\n",
-							__func__,
-							user_v3->payload_size,
-							lsm_d->ev_det_pld_size);
-						return -EINVAL;
-					}
-					/* event status timestamp not supported
-					 * on CPE mode. Set msw and lsw to 0.
-					 */
-					user_v3->timestamp_lsw = 0;
-					user_v3->timestamp_msw = 0;
-					user_v3->status = lsm_d->ev_det_status;
-					user_v3->payload_size =
-							lsm_d->ev_det_pld_size;
-					memcpy(user_v3->payload,
-					       lsm_d->ev_det_payload,
-					       lsm_d->ev_det_pld_size);
-				}
-			} else if (atomic_read(&lsm_d->event_stop) == 1) {
-				dev_dbg(rtd->dev,
-					"%s: wait_aborted\n", __func__);
-				if (cmd == SNDRV_LSM_EVENT_STATUS) {
-					user = arg;
-					user->payload_size = 0;
-				} else {
-					user_v3 = arg;
-					user_v3->payload_size = 0;
-				}
-				rc = 0;
-			}
-		}
-	}
-		break;
-
-	case SNDRV_LSM_ABORT_EVENT:
-		dev_dbg(rtd->dev,
-			"%s: %s\n",
-			__func__, "SNDRV_LSM_ABORT_EVENT");
-		atomic_set(&lsm_d->event_stop, 1);
-		wake_up(&lsm_d->event_wait);
-		break;
-
-	case SNDRV_LSM_START:
-		dev_dbg(rtd->dev,
-			"%s: %s\n",
-			__func__, "SNDRV_LSM_START");
-		rc = lsm_ops->lsm_start(cpe->core_handle, session);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: lsm_start fail, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-		session->started = true;
-		break;
-
-	case SNDRV_LSM_STOP:
-		dev_dbg(rtd->dev,
-			"%s: %s, lab_enable = %d, lab_thread_status = %d\n",
-			__func__, "SNDRV_LSM_STOP",
-			session->lab_enable,
-			lab_d->thread_status);
-		if ((session->lab_enable &&
-		     lab_d->thread_status ==
-		     MSM_LSM_LAB_THREAD_RUNNING)) {
-			/* Explicitly stop LAB */
-			rc = msm_cpe_lsm_lab_stop(substream);
-			if (rc) {
-				dev_err(rtd->dev,
-					"%s: lab_stop failed, err = %d\n",
-					__func__, rc);
-				return rc;
-			}
-		}
-
-		rc = lsm_ops->lsm_stop(cpe->core_handle, session);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: lsm_stop fail err = %d\n",
-				__func__, rc);
-
-			return rc;
-		}
-		session->started = false;
-		break;
-
-	case SNDRV_LSM_SET_PARAMS:
-		memcpy(&det_params, arg,
-			sizeof(det_params));
-		if (det_params.num_confidence_levels <= 0) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid confidence levels %u\n",
-				__func__, "SNDRV_LSM_SET_PARAMS",
-				det_params.num_confidence_levels);
-			return -EINVAL;
-		}
-
-		session->num_confidence_levels =
-				det_params.num_confidence_levels;
-		rc = msm_cpe_lsm_get_conf_levels(session,
-						det_params.conf_level);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: %s get_conf_levels fail, err = %d\n",
-				__func__, "SNDRV_LSM_SET_PARAMS",
-				rc);
-			break;
-		}
-
-		rc = lsm_ops->lsm_set_data(cpe->core_handle, session,
-					   det_params.detect_mode,
-					   det_params.detect_failure);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: lsm_set_data failed, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		kfree(session->conf_levels);
-		session->conf_levels = NULL;
-
-		break;
-
-		case SNDRV_LSM_OUT_FORMAT_CFG: {
-			struct snd_lsm_output_format_cfg u_fmt_cfg;
-
-			if (!arg) {
-				dev_err(rtd->dev,
-					"%s: Invalid argument to ioctl %s\n",
-					__func__, "SNDRV_LSM_OUT_FORMAT_CFG");
-				return -EINVAL;
-			}
-
-			if (copy_from_user(&u_fmt_cfg, arg,
-					   sizeof(u_fmt_cfg))) {
-				dev_err(rtd->dev,
-					"%s: copy_from_user failed for out_fmt_cfg\n",
-					__func__);
-				return -EFAULT;
-			}
-
-			if (msm_cpe_lsm_validate_out_format(substream,
-							    &u_fmt_cfg))
-				return -EINVAL;
-
-			session->out_fmt_cfg.format = u_fmt_cfg.format;
-			session->out_fmt_cfg.pack_mode = u_fmt_cfg.packing;
-			session->out_fmt_cfg.data_path_events =
-						u_fmt_cfg.events;
-			session->out_fmt_cfg.transfer_mode = u_fmt_cfg.mode;
-
-			rc = lsm_ops->lsm_set_fmt_cfg(cpe->core_handle,
-						      session);
-			if (rc) {
-				dev_err(rtd->dev,
-					"%s: lsm_set_fmt_cfg failed, err = %d\n",
-					__func__, rc);
-				return rc;
-			}
-		}
-		break;
-
-	case SNDRV_LSM_SET_PORT: {
-		u32 port_id = cpe->input_port_id;
-
-		dev_dbg(rtd->dev, "%s: %s\n", __func__, "SNDRV_LSM_SET_PORT");
-		rc = lsm_ops->lsm_set_port(cpe->core_handle, session, &port_id);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: lsm_set_port failed, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-	}
-	break;
-
-	default:
-		dev_dbg(rtd->dev,
-			"%s: Default snd_lib_ioctl cmd 0x%x\n",
-			__func__, cmd);
-		rc = snd_pcm_lib_ioctl(substream, cmd, arg);
-	}
-
-	return rc;
-}
-
-static int msm_cpe_lsm_lab_start(struct snd_pcm_substream *substream,
-		u16 event_det_status)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct cpe_lsm_lab *lab_d = NULL;
-	struct cpe_hw_params *hw_params;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct wcd_cpe_afe_port_cfg *out_port;
-	int rc;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: invalid substream (%pK)\n",
-			__func__, substream);
-		return -EINVAL;
-	}
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-	lab_d = &lsm_d->lab;
-	afe_ops = &cpe->afe_ops;
-	hw_params = &lsm_d->hw_params;
-
-	if (!session->started) {
-		dev_dbg(rtd->dev,
-			"%s: Session is stopped, cannot start LAB\n",
-			__func__);
-		return 0;
-	}
-
-	reinit_completion(&lab_d->thread_complete);
-
-	if (session->lab_enable &&
-	    event_det_status ==
-	    LSM_VOICE_WAKEUP_STATUS_DETECTED) {
-		out_port = &session->afe_out_port_cfg;
-		out_port->port_id = session->afe_out_port_id;
-		out_port->bit_width = hw_params->sample_size;
-		out_port->num_channels = hw_params->channels;
-		out_port->sample_rate = hw_params->sample_rate;
-		dev_dbg(rtd->dev, "%s: port_id= %u, bit_width= %u, rate= %u\n",
-			 __func__, out_port->port_id, out_port->bit_width,
-			out_port->sample_rate);
-
-		rc = afe_ops->afe_port_cmd_cfg(cpe->core_handle,
-					       out_port);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: Failed afe generic config v2, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		atomic_set(&lab_d->abort_read, 0);
-		dev_dbg(rtd->dev,
-			"%s: KW detected, scheduling LAB thread\n",
-			__func__);
-
-		/*
-		 * Even though thread might be only scheduled and
-		 * not currently running, mark the internal driver
-		 * status to running so driver can cancel this thread
-		 * if it needs to before the thread gets chance to run.
-		 */
-		lab_d->thread_status = MSM_LSM_LAB_THREAD_RUNNING;
-		session->lsm_lab_thread = kthread_run(
-				msm_cpe_lab_thread,
-				lsm_d,
-				"lab_thread");
-	}
-
-	return 0;
-}
-
-static bool msm_cpe_lsm_is_valid_stream(struct snd_pcm_substream *substream,
-		const char *func)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: invalid substream (%pK)\n",
-			func, substream);
-		return false;
-	}
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			func);
-		return false;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			func);
-		return false;
-	}
-
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	if (!lsm_ops) {
-		dev_err(rtd->dev,
-			"%s: Invalid lsm_ops\n", func);
-		return false;
-	}
-
-	return true;
-}
-
-static int msm_cpe_lsm_set_epd(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct snd_lsm_ep_det_thres epd_thres;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	if (p_info->param_size != sizeof(epd_thres)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&epd_thres, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, &epd_thres,
-				LSM_ENDPOINT_DETECT_THRESHOLD);
-	if (unlikely(rc))
-		dev_err(rtd->dev,
-			"%s: set_one_param(epd_threshold) failed, rc %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_cpe_lsm_set_mode(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct snd_lsm_detect_mode det_mode;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	if (p_info->param_size != sizeof(det_mode)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&det_mode, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, &det_mode,
-				LSM_OPERATION_MODE);
-	if (unlikely(rc))
-		dev_err(rtd->dev,
-			"%s: set_one_param(epd_threshold) failed, rc %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_cpe_lsm_set_gain(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	struct snd_lsm_gain gain;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	if (p_info->param_size != sizeof(gain)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&gain, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, &gain,
-				LSM_GAIN);
-	if (unlikely(rc))
-		dev_err(rtd->dev,
-			"%s: set_one_param(epd_threshold) failed, rc %d\n",
-			__func__, rc);
-done:
-	return rc;
-
-}
-
-static int msm_cpe_lsm_set_conf(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	session->num_confidence_levels =
-			p_info->param_size;
-	rc = msm_cpe_lsm_get_conf_levels(session,
-			p_info->param_data);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: get_conf_levels failed, err = %d\n",
-			__func__, rc);
-		goto done;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, NULL,
-				LSM_MIN_CONFIDENCE_LEVELS);
-	if (unlikely(rc))
-		dev_err(rtd->dev,
-			"%s: set_one_param(conf_levels) failed, rc %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_cpe_lsm_reg_model(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	int rc;
-	size_t offset;
-	u8 *snd_model_ptr;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	lsm_ops->lsm_get_snd_model_offset(cpe->core_handle,
-			session, &offset);
-	/* Check if 'p_info->param_size + offset' crosses U32_MAX. */
-	if (p_info->param_size > U32_MAX - offset) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		return -EINVAL;
-	}
-	session->snd_model_size = p_info->param_size + offset;
-
-	session->snd_model_data = vzalloc(session->snd_model_size);
-	if (!session->snd_model_data)
-		return -ENOMEM;
-
-	snd_model_ptr = ((u8 *) session->snd_model_data) + offset;
-
-	if (copy_from_user(snd_model_ptr,
-			   p_info->param_data, p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user for snd_model failed\n",
-			__func__);
-		rc = -EFAULT;
-		goto free_snd_model_data;
-	}
-
-	rc = lsm_ops->lsm_shmem_alloc(cpe->core_handle, session,
-				      session->snd_model_size);
-	if (rc != 0) {
-		dev_err(rtd->dev,
-			"%s: shared memory allocation failed, err = %d\n",
-		       __func__, rc);
-		rc = -EINVAL;
-		goto free_snd_model_data;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, NULL,
-				LSM_REG_SND_MODEL);
-	if (unlikely(rc)) {
-		dev_err(rtd->dev,
-			"%s: set_one_param(snd_model) failed, rc %d\n",
-			__func__, rc);
-		goto dealloc_shmem;
-	}
-	return 0;
-
-dealloc_shmem:
-	lsm_ops->lsm_shmem_dealloc(cpe->core_handle, session);
-
-free_snd_model_data:
-	vfree(session->snd_model_data);
-	return rc;
-}
-
-static int msm_cpe_lsm_dereg_model(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, NULL,
-				LSM_DEREG_SND_MODEL);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: dereg_snd_model failed\n",
-			__func__);
-	return lsm_ops->lsm_shmem_dealloc(cpe->core_handle, session);
-}
-
-static int msm_cpe_lsm_set_custom(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-	u8 *data;
-	int rc;
-
-	if (!msm_cpe_lsm_is_valid_stream(substream, __func__))
-		return -EINVAL;
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	if (p_info->param_size > MSM_CPE_MAX_CUSTOM_PARAM_SIZE) {
-		dev_err(rtd->dev,
-			"%s: invalid size %d, max allowed %d\n",
-			__func__, p_info->param_size,
-			MSM_CPE_MAX_CUSTOM_PARAM_SIZE);
-		return -EINVAL;
-	}
-
-	data = kzalloc(p_info->param_size, GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	if (copy_from_user(data, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed for custom params, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto err_ret;
-	}
-
-	rc = lsm_ops->lsm_set_one_param(cpe->core_handle,
-				session, p_info, data,
-				LSM_CUSTOM_PARAMS);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: custom_params failed, err = %d\n",
-			__func__, rc);
-err_ret:
-	kfree(data);
-	return rc;
-}
-
-static int msm_cpe_lsm_process_params(struct snd_pcm_substream *substream,
-		struct snd_lsm_module_params *p_data,
-		void *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct lsm_params_info *p_info;
-	int i;
-	int rc = 0;
-
-	p_info = (struct lsm_params_info *) params;
-
-	for (i = 0; i < p_data->num_params; i++) {
-		dev_dbg(rtd->dev,
-			"%s: param (%d), module_id = 0x%x, param_id = 0x%x, param_size = 0x%x, param_type = 0x%x\n",
-			__func__, i, p_info->module_id,
-			p_info->param_id, p_info->param_size,
-			p_info->param_type);
-
-		switch (p_info->param_type) {
-		case LSM_ENDPOINT_DETECT_THRESHOLD:
-			rc = msm_cpe_lsm_set_epd(substream, p_info);
-			break;
-		case LSM_OPERATION_MODE:
-			rc = msm_cpe_lsm_set_mode(substream, p_info);
-			break;
-		case LSM_GAIN:
-			rc = msm_cpe_lsm_set_gain(substream, p_info);
-			break;
-		case LSM_MIN_CONFIDENCE_LEVELS:
-			rc = msm_cpe_lsm_set_conf(substream, p_info);
-			break;
-		case LSM_REG_SND_MODEL:
-			rc = msm_cpe_lsm_reg_model(substream, p_info);
-			break;
-		case LSM_DEREG_SND_MODEL:
-			rc = msm_cpe_lsm_dereg_model(substream, p_info);
-			break;
-		case LSM_CUSTOM_PARAMS:
-			rc = msm_cpe_lsm_set_custom(substream, p_info);
-			break;
-		default:
-			dev_err(rtd->dev,
-				"%s: Invalid param_type %d\n",
-				__func__, p_info->param_type);
-			rc = -EINVAL;
-			break;
-		}
-		if (rc) {
-			pr_err("%s: set_param fail for param_type %d\n",
-				__func__, p_info->param_type);
-			return rc;
-		}
-
-		p_info++;
-	}
-
-	return rc;
-}
-
-static int msm_cpe_lsm_ioctl(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	int err = 0;
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: invalid substream (%pK)\n",
-			__func__, substream);
-		return -EINVAL;
-	}
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	MSM_CPE_LSM_GRAB_LOCK(&lsm_d->lsm_api_lock,
-			      "lsm_api_lock");
-
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	switch (cmd) {
-	case SNDRV_LSM_REG_SND_MODEL_V2: {
-		struct snd_lsm_sound_model_v2 snd_model;
-
-		if (session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "LSM_REG_SND_MODEL_V2");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&snd_model, (void *)arg,
-				   sizeof(struct snd_lsm_sound_model_v2))) {
-			dev_err(rtd->dev,
-				"%s: copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_sound_model_v2));
-			err = -EFAULT;
-			goto done;
-		}
-
-		err = msm_cpe_lsm_ioctl_shared(substream, cmd,
-					       &snd_model);
-	}
-		break;
-	case SNDRV_LSM_EVENT_STATUS: {
-		struct snd_lsm_event_status u_event_status;
-		struct snd_lsm_event_status *event_status = NULL;
-		int u_pld_size = 0;
-
-		if (copy_from_user(&u_event_status, (void *)arg,
-				   sizeof(struct snd_lsm_event_status))) {
-			dev_err(rtd->dev,
-				"%s: event status copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_event_status));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (u_event_status.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			dev_err(rtd->dev,
-				"%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, u_event_status.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		u_pld_size = sizeof(struct snd_lsm_event_status) +
-				u_event_status.payload_size;
-
-		event_status = kzalloc(u_pld_size, GFP_KERNEL);
-		if (!event_status) {
-			err = -ENOMEM;
-			goto done;
-		} else {
-			event_status->payload_size =
-				u_event_status.payload_size;
-			err = msm_cpe_lsm_ioctl_shared(substream,
-						       cmd, event_status);
-		}
-
-		if (!err  && copy_to_user(arg, event_status, u_pld_size)) {
-			dev_err(rtd->dev,
-				"%s: copy to user failed\n",
-				__func__);
-			kfree(event_status);
-			err = -EFAULT;
-			goto done;
-		}
-
-		msm_cpe_lsm_lab_start(substream, event_status->status);
-		msm_cpe_process_event_status_done(lsm_d);
-		kfree(event_status);
-	}
-		break;
-	case SNDRV_LSM_EVENT_STATUS_V3: {
-		struct snd_lsm_event_status_v3 u_event_status;
-		struct snd_lsm_event_status_v3 *event_status = NULL;
-		int u_pld_size = 0;
-
-		if (copy_from_user(&u_event_status, (void *)arg,
-				   sizeof(struct snd_lsm_event_status_v3))) {
-			dev_err(rtd->dev,
-				"%s: event status copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_event_status_v3));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (u_event_status.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			dev_err(rtd->dev,
-				"%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, u_event_status.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		u_pld_size = sizeof(struct snd_lsm_event_status_v3) +
-				u_event_status.payload_size;
-
-		event_status = kzalloc(u_pld_size, GFP_KERNEL);
-		if (!event_status) {
-			err = -ENOMEM;
-			goto done;
-		} else {
-			event_status->payload_size =
-				u_event_status.payload_size;
-			err = msm_cpe_lsm_ioctl_shared(substream,
-						       cmd, event_status);
-		}
-
-		if (!err  && copy_to_user(arg, event_status, u_pld_size)) {
-			dev_err(rtd->dev,
-				"%s: copy to user failed\n",
-				__func__);
-			kfree(event_status);
-			err = -EFAULT;
-			goto done;
-		}
-
-		msm_cpe_lsm_lab_start(substream, event_status->status);
-		msm_cpe_process_event_status_done(lsm_d);
-		kfree(event_status);
-	}
-		break;
-	case SNDRV_LSM_SET_PARAMS: {
-		struct snd_lsm_detection_params det_params;
-
-		if (session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "SNDRV_LSM_SET_PARAMS");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&det_params, (void *) arg,
-				   sizeof(det_params))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "SNDRV_LSM_SET_PARAMS",
-				sizeof(det_params));
-			err = -EFAULT;
-			goto done;
-		}
-
-		err = msm_cpe_lsm_ioctl_shared(substream, cmd,
-					       &det_params);
-	}
-		break;
-
-	case SNDRV_LSM_SET_MODULE_PARAMS: {
-		struct snd_lsm_module_params p_data;
-		size_t p_size;
-		u8 *params;
-
-		if (!session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if not using topology\n",
-				__func__, "SET_MODULE_PARAMS");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (!arg) {
-			dev_err(rtd->dev,
-				"%s: %s: No Param data to set\n",
-				__func__, "SET_MODULE_PARAMS");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&p_data, arg,
-				   sizeof(p_data))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "p_data", sizeof(p_data));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (p_data.num_params > LSM_PARAMS_MAX) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid num_params %d\n",
-				__func__, "SET_MODULE_PARAMS",
-				p_data.num_params);
-			err = -EINVAL;
-			goto done;
-		}
-
-		p_size = p_data.num_params *
-			 sizeof(struct lsm_params_info);
-
-		if (p_data.data_size != p_size) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid size %zd\n",
-				__func__, "SET_MODULE_PARAMS", p_size);
-
-			err = -EFAULT;
-			goto done;
-		}
-
-		params = kzalloc(p_size, GFP_KERNEL);
-		if (!params) {
-			err = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(params, p_data.params,
-				   p_data.data_size)) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %d\n",
-				__func__, "params", p_data.data_size);
-			kfree(params);
-			err = -EFAULT;
-			goto done;
-		}
-
-		err = msm_cpe_lsm_process_params(substream, &p_data, params);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: %s: Failed to set params, err = %d\n",
-				__func__, "SET_MODULE_PARAMS", err);
-		kfree(params);
-		break;
-	}
-	default:
-		err = msm_cpe_lsm_ioctl_shared(substream, cmd, arg);
-		break;
-	}
-
-done:
-	MSM_CPE_LSM_REL_LOCK(&lsm_d->lsm_api_lock,
-			     "lsm_api_lock");
-	return err;
-}
-
-#ifdef CONFIG_COMPAT
-struct snd_lsm_sound_model_v2_32 {
-	compat_uptr_t data;
-	compat_uptr_t confidence_level;
-	u32 data_size;
-	enum lsm_detection_mode detection_mode;
-	u8 num_confidence_levels;
-	bool detect_failure;
-};
-
-struct snd_lsm_detection_params_32 {
-	compat_uptr_t conf_level;
-	enum lsm_detection_mode detect_mode;
-	u8 num_confidence_levels;
-	bool detect_failure;
-};
-
-struct lsm_params_info_32 {
-	u32 module_id;
-	u32 param_id;
-	u32 param_size;
-	compat_uptr_t param_data;
-	uint32_t param_type;
-};
-
-struct snd_lsm_module_params_32 {
-	compat_uptr_t params;
-	u32 num_params;
-	u32 data_size;
-};
-
-enum {
-	SNDRV_LSM_REG_SND_MODEL_V2_32 =
-		_IOW('U', 0x07, struct snd_lsm_sound_model_v2_32),
-	SNDRV_LSM_SET_PARAMS32 =
-		_IOW('U', 0x0A, struct snd_lsm_detection_params_32),
-	SNDRV_LSM_SET_MODULE_PARAMS_32 =
-		_IOW('U', 0x0B, struct snd_lsm_module_params_32),
-};
-
-static int msm_cpe_lsm_ioctl_compat(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	int err = 0;
-	struct snd_soc_pcm_runtime *rtd;
-	struct cpe_priv *cpe = NULL;
-	struct cpe_lsm_data *lsm_d = NULL;
-	struct cpe_lsm_session *session = NULL;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: invalid substream (%pK)\n",
-			__func__, substream);
-		return -EINVAL;
-	}
-
-	rtd = substream->private_data;
-	lsm_d = cpe_get_lsm_data(substream);
-	cpe = cpe_get_private_data(substream);
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	MSM_CPE_LSM_GRAB_LOCK(&lsm_d->lsm_api_lock,
-			      "lsm_api_lock");
-
-	session = lsm_d->lsm_session;
-	lsm_ops = &cpe->lsm_ops;
-
-	switch (cmd) {
-	case SNDRV_LSM_REG_SND_MODEL_V2_32: {
-		struct snd_lsm_sound_model_v2 snd_model;
-		struct snd_lsm_sound_model_v2_32 snd_model32;
-
-		if (session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "LSM_REG_SND_MODEL_V2_32");
-			err = -EINVAL;
-			goto done;
-		}
-
-		dev_dbg(rtd->dev,
-			"%s: ioctl %s\n", __func__,
-			"SNDRV_LSM_REG_SND_MODEL_V2_32");
-
-		if (copy_from_user(&snd_model32, (void *)arg,
-				   sizeof(snd_model32))) {
-			dev_err(rtd->dev,
-				"%s: copy from user failed, size %zd\n",
-				__func__,
-				sizeof(snd_model32));
-			err = -EFAULT;
-			goto done;
-		}
-
-		snd_model.data = compat_ptr(snd_model32.data);
-		snd_model.confidence_level =
-			compat_ptr(snd_model32.confidence_level);
-		snd_model.data_size = snd_model32.data_size;
-		snd_model.detect_failure = snd_model32.detect_failure;
-		snd_model.num_confidence_levels =
-			snd_model32.num_confidence_levels;
-		snd_model.detection_mode = snd_model32.detection_mode;
-
-		cmd = SNDRV_LSM_REG_SND_MODEL_V2;
-		err = msm_cpe_lsm_ioctl_shared(substream, cmd, &snd_model);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: %s failed, error = %d\n",
-				__func__,
-				"SNDRV_LSM_REG_SND_MODEL_V2_32",
-				err);
-	}
-		break;
-	case SNDRV_LSM_EVENT_STATUS: {
-		struct snd_lsm_event_status *event_status = NULL;
-		struct snd_lsm_event_status u_event_status32;
-		struct snd_lsm_event_status *udata_32 = NULL;
-		int u_pld_size = 0;
-
-		dev_dbg(rtd->dev,
-			"%s: ioctl %s\n", __func__,
-			"SNDRV_LSM_EVENT_STATUS32");
-
-		if (copy_from_user(&u_event_status32, (void *)arg,
-				   sizeof(struct snd_lsm_event_status))) {
-			dev_err(rtd->dev,
-				"%s: event status copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_event_status));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (u_event_status32.payload_size >
-		   LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			dev_err(rtd->dev,
-				"%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, u_event_status32.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		u_pld_size = sizeof(struct snd_lsm_event_status) +
-				u_event_status32.payload_size;
-		event_status = kzalloc(u_pld_size, GFP_KERNEL);
-		if (!event_status) {
-			dev_err(rtd->dev,
-				"%s: No memory for event status\n",
-				__func__);
-			err = -ENOMEM;
-			goto done;
-		} else {
-			event_status->payload_size =
-				u_event_status32.payload_size;
-			err = msm_cpe_lsm_ioctl_shared(substream,
-						       cmd, event_status);
-			if (err)
-				dev_err(rtd->dev,
-					"%s: %s failed, error = %d\n",
-					__func__,
-					"SNDRV_LSM_EVENT_STATUS32",
-					err);
-		}
-
-		if (!err) {
-			udata_32 = kzalloc(u_pld_size, GFP_KERNEL);
-			if (!udata_32) {
-				dev_err(rtd->dev,
-					"%s: nomem for udata\n",
-					__func__);
-				err = -EFAULT;
-			} else {
-				udata_32->status = event_status->status;
-				udata_32->payload_size =
-					event_status->payload_size;
-				memcpy(udata_32->payload,
-				       event_status->payload,
-				       u_pld_size);
-			}
-		}
-
-		if (!err  && copy_to_user(arg, udata_32,
-					  u_pld_size)) {
-			dev_err(rtd->dev,
-				"%s: copy to user failed\n",
-				__func__);
-			kfree(event_status);
-			kfree(udata_32);
-			err = -EFAULT;
-			goto done;
-		}
-
-		msm_cpe_lsm_lab_start(substream, event_status->status);
-		msm_cpe_process_event_status_done(lsm_d);
-		kfree(event_status);
-		kfree(udata_32);
-	}
-		break;
-	case SNDRV_LSM_EVENT_STATUS_V3: {
-		struct snd_lsm_event_status_v3 *event_status = NULL;
-		struct snd_lsm_event_status_v3 u_event_status32;
-		struct snd_lsm_event_status_v3 *udata_32 = NULL;
-		int u_pld_size = 0;
-
-		dev_dbg(rtd->dev,
-			"%s: ioctl %s\n", __func__,
-			"SNDRV_LSM_EVENT_STATUS_V3_32");
-
-		if (copy_from_user(&u_event_status32, (void *)arg,
-				   sizeof(struct snd_lsm_event_status_v3))) {
-			dev_err(rtd->dev,
-				"%s: event status copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_event_status_v3));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (u_event_status32.payload_size >
-		   LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			dev_err(rtd->dev,
-				"%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, u_event_status32.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		u_pld_size = sizeof(struct snd_lsm_event_status_v3) +
-				u_event_status32.payload_size;
-		event_status = kzalloc(u_pld_size, GFP_KERNEL);
-		if (!event_status) {
-			dev_err(rtd->dev,
-				"%s: No memory for event status\n",
-				__func__);
-			err = -ENOMEM;
-			goto done;
-		} else {
-			event_status->payload_size =
-				u_event_status32.payload_size;
-			err = msm_cpe_lsm_ioctl_shared(substream,
-						       cmd, event_status);
-			if (err)
-				dev_err(rtd->dev,
-					"%s: %s failed, error = %d\n",
-					__func__,
-					"SNDRV_LSM_EVENT_STATUS_V3_32",
-					err);
-		}
-
-		if (!err) {
-			udata_32 = kzalloc(u_pld_size, GFP_KERNEL);
-			if (!udata_32) {
-				dev_err(rtd->dev,
-					"%s: nomem for udata\n",
-					__func__);
-				err = -EFAULT;
-			} else {
-				udata_32->timestamp_lsw =
-					event_status->timestamp_lsw;
-				udata_32->timestamp_msw =
-					event_status->timestamp_msw;
-				udata_32->status = event_status->status;
-				udata_32->payload_size =
-					event_status->payload_size;
-				memcpy(udata_32->payload,
-				       event_status->payload,
-				       u_pld_size);
-			}
-		}
-
-		if (!err  && copy_to_user(arg, udata_32,
-					  u_pld_size)) {
-			dev_err(rtd->dev,
-				"%s: copy to user failed\n",
-				__func__);
-			kfree(event_status);
-			kfree(udata_32);
-			err = -EFAULT;
-			goto done;
-		}
-
-		msm_cpe_lsm_lab_start(substream, event_status->status);
-		msm_cpe_process_event_status_done(lsm_d);
-		kfree(event_status);
-		kfree(udata_32);
-	}
-		break;
-	case SNDRV_LSM_SET_PARAMS32: {
-		struct snd_lsm_detection_params_32 det_params32;
-		struct snd_lsm_detection_params det_params;
-
-		if (session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "SNDRV_LSM_SET_PARAMS32");
-
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&det_params32, arg,
-				   sizeof(det_params32))) {
-			err = -EFAULT;
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "SNDRV_LSM_SET_PARAMS_32",
-				sizeof(det_params32));
-		} else {
-			det_params.conf_level =
-				compat_ptr(det_params32.conf_level);
-			det_params.detect_mode =
-				det_params32.detect_mode;
-			det_params.num_confidence_levels =
-				det_params32.num_confidence_levels;
-			det_params.detect_failure =
-				det_params32.detect_failure;
-			cmd = SNDRV_LSM_SET_PARAMS;
-			err = msm_cpe_lsm_ioctl_shared(substream, cmd,
-						  &det_params);
-			if (err)
-				dev_err(rtd->dev,
-					"%s: ioctl %s failed\n", __func__,
-					"SNDRV_LSM_SET_PARAMS");
-		}
-
-		break;
-	}
-
-	case SNDRV_LSM_SET_MODULE_PARAMS_32: {
-		struct snd_lsm_module_params_32 p_data_32;
-		struct snd_lsm_module_params p_data;
-		u8 *params, *params32;
-		size_t p_size;
-		struct lsm_params_info_32 *p_info_32;
-		struct lsm_params_info *p_info;
-		int i;
-
-		if (!session->is_topology_used) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if not using topology\n",
-				__func__, "SET_MODULE_PARAMS_32");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&p_data_32, arg,
-				   sizeof(p_data_32))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				sizeof(p_data_32));
-			err = -EFAULT;
-			goto done;
-		}
-
-		p_data.params = compat_ptr(p_data_32.params);
-		p_data.num_params = p_data_32.num_params;
-		p_data.data_size = p_data_32.data_size;
-
-		if (p_data.num_params > LSM_PARAMS_MAX) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid num_params %d\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				p_data.num_params);
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (p_data.data_size !=
-		    (p_data.num_params * sizeof(struct lsm_params_info_32))) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid size %d\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				p_data.data_size);
-			err = -EINVAL;
-			goto done;
-		}
-
-		p_size = sizeof(struct lsm_params_info_32) *
-			 p_data.num_params;
-
-		params32 = kzalloc(p_size, GFP_KERNEL);
-		if (!params32) {
-			err = -ENOMEM;
-			goto done;
-		}
-
-		p_size = sizeof(struct lsm_params_info) * p_data.num_params;
-		params = kzalloc(p_size, GFP_KERNEL);
-		if (!params) {
-			kfree(params32);
-			err = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(params32, p_data.params,
-				   p_data.data_size)) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %d\n",
-				__func__, "params32", p_data.data_size);
-			kfree(params32);
-			kfree(params);
-			err = -EFAULT;
-			goto done;
-		}
-
-		p_info_32 = (struct lsm_params_info_32 *) params32;
-		p_info = (struct lsm_params_info *) params;
-		for (i = 0; i < p_data.num_params; i++) {
-			p_info->module_id = p_info_32->module_id;
-			p_info->param_id = p_info_32->param_id;
-			p_info->param_size = p_info_32->param_size;
-			p_info->param_data = compat_ptr(p_info_32->param_data);
-			p_info->param_type = p_info_32->param_type;
-
-			p_info_32++;
-			p_info++;
-		}
-
-		err = msm_cpe_lsm_process_params(substream,
-					     &p_data, params);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: Failed to process params, err = %d\n",
-				__func__, err);
-		kfree(params);
-		kfree(params32);
-		break;
-	}
-	case SNDRV_LSM_REG_SND_MODEL_V2:
-	case SNDRV_LSM_SET_PARAMS:
-	case SNDRV_LSM_SET_MODULE_PARAMS:
-		/*
-		 * In ideal cases, the compat_ioctl should never be called
-		 * with the above unlocked ioctl commands. Print error
-		 * and return error if it does.
-		 */
-		dev_err(rtd->dev,
-			"%s: Invalid cmd for compat_ioctl\n",
-			__func__);
-		err = -EINVAL;
-		break;
-	default:
-		err = msm_cpe_lsm_ioctl_shared(substream, cmd, arg);
-		break;
-	}
-done:
-	MSM_CPE_LSM_REL_LOCK(&lsm_d->lsm_api_lock,
-			     "lsm_api_lock");
-	return err;
-}
-
-#else
-#define msm_cpe_lsm_ioctl_compat NULL
-#endif
-
-/*
- * msm_cpe_lsm_prepare: prepare call from ASoC core for this platform
- * @substream: ASoC substream for which the operation is invoked
- *
- * start the AFE port on CPE associated for this listen session
- */
-static int msm_cpe_lsm_prepare(struct snd_pcm_substream *substream)
-{
-	int rc = 0;
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct wcd_cpe_afe_port_cfg *afe_cfg;
-	struct cpe_lsm_session *lsm_session;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_hw_params lsm_param;
-	struct wcd_cpe_lsm_ops *lsm_ops;
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-	if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
-	    runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-		pr_err("%s: XRUN ignore for now\n", __func__);
-		return 0;
-	}
-
-	lsm_session = lsm_d->lsm_session;
-	lab_d->pcm_size = snd_pcm_lib_buffer_bytes(substream);
-
-	dev_dbg(rtd->dev,
-		"%s: pcm_size 0x%x", __func__, lab_d->pcm_size);
-
-	if (lsm_d->cpe_prepared) {
-		dev_dbg(rtd->dev, "%s: CPE is alredy prepared\n",
-			__func__);
-		return 0;
-	}
-
-	lsm_ops = &cpe->lsm_ops;
-	afe_ops = &cpe->afe_ops;
-	afe_cfg = &(lsm_d->lsm_session->afe_port_cfg);
-
-	switch (cpe->input_port_id) {
-	case AFE_PORT_ID_3:
-		afe_cfg->port_id = AFE_PORT_ID_3;
-		afe_cfg->bit_width = 16;
-		afe_cfg->num_channels = 1;
-		afe_cfg->sample_rate = SAMPLE_RATE_48KHZ;
-		rc = afe_ops->afe_port_cmd_cfg(cpe->core_handle, afe_cfg);
-		break;
-	case AFE_PORT_ID_1:
-	default:
-		afe_cfg->port_id = AFE_PORT_ID_1;
-		afe_cfg->bit_width = 16;
-		afe_cfg->num_channels = 1;
-		afe_cfg->sample_rate = SAMPLE_RATE_16KHZ;
-		rc = afe_ops->afe_set_params(cpe->core_handle,
-					     afe_cfg, cpe->afe_mad_ctl);
-		break;
-	}
-
-	if (rc != 0) {
-		dev_err(rtd->dev,
-			"%s: cpe afe params failed for port = %d, err = %d\n",
-			 __func__, afe_cfg->port_id, rc);
-		return rc;
-	}
-	lsm_param.sample_rate = afe_cfg->sample_rate;
-	lsm_param.num_chs = afe_cfg->num_channels;
-	lsm_param.bit_width = afe_cfg->bit_width;
-	rc = lsm_ops->lsm_set_media_fmt_params(cpe->core_handle, lsm_session,
-					       &lsm_param);
-	if (rc)
-		dev_dbg(rtd->dev,
-			"%s: failed to set lsm media fmt params, err = %d\n",
-			__func__, rc);
-
-	/* Send connect to port (input) */
-	rc = lsm_ops->lsm_set_port(cpe->core_handle, lsm_session,
-				   &cpe->input_port_id);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: Failed to set connect input port, err=%d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	if (cpe->input_port_id != 3) {
-		rc = lsm_ops->lsm_get_afe_out_port_id(cpe->core_handle,
-						      lsm_session);
-		if (rc != 0) {
-			dev_err(rtd->dev,
-				"%s: failed to get port id, err = %d\n",
-				__func__, rc);
-			return rc;
-		}
-		/* Send connect to port (output) */
-		rc = lsm_ops->lsm_set_port(cpe->core_handle, lsm_session,
-					   &lsm_session->afe_out_port_id);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: Failed to set connect output port, err=%d\n",
-				__func__, rc);
-			return rc;
-		}
-	}
-	rc = msm_cpe_afe_port_cntl(substream,
-				   cpe->core_handle,
-				   afe_ops, afe_cfg,
-				   AFE_CMD_PORT_START);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: cpe_afe_port start failed, err = %d\n",
-			__func__, rc);
-	else
-		lsm_d->cpe_prepared = true;
-
-	return rc;
-}
-
-/*
- * msm_cpe_lsm_trigger: trigger call from ASoC core for this platform
- * @substream: ASoC substream for which the operation is invoked
- * @cmd: the trigger command from framework
- *
- * suspend/resume the AFE port on CPE associated with listen session
- */
-static int msm_cpe_lsm_trigger(struct snd_pcm_substream *substream,
-			       int cmd)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct wcd_cpe_afe_ops *afe_ops;
-	struct wcd_cpe_afe_port_cfg *afe_cfg;
-	int afe_cmd = AFE_CMD_INVALID;
-	int rc = 0;
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid private data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid session data\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	afe_ops = &cpe->afe_ops;
-	afe_cfg = &(lsm_d->lsm_session->afe_port_cfg);
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		afe_cmd = AFE_CMD_PORT_SUSPEND;
-		break;
-
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		afe_cmd = AFE_CMD_PORT_RESUME;
-		break;
-
-	default:
-		afe_cmd = AFE_CMD_INVALID;
-		dev_dbg(rtd->dev,
-			"%s: unhandled trigger cmd %d\n",
-			__func__, cmd);
-		break;
-	}
-
-	if (afe_cmd != AFE_CMD_INVALID)
-		rc = msm_cpe_afe_port_cntl(substream,
-					   cpe->core_handle,
-					   afe_ops, afe_cfg,
-					   afe_cmd);
-
-	return rc;
-}
-
-static int msm_cpe_lsm_hwparams(struct snd_pcm_substream *substream,
-					struct snd_pcm_hw_params *params)
-{
-
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct cpe_priv *cpe = cpe_get_private_data(substream);
-	struct cpe_lsm_session *session = NULL;
-	struct cpe_hw_params *hw_params = NULL;
-
-	if (!cpe || !cpe->core_handle) {
-		dev_err(rtd->dev,
-			"%s: Invalid %s\n",
-			__func__,
-			(!cpe) ? "cpe" : "core");
-		return -EINVAL;
-	}
-
-	if (!lsm_d || !lsm_d->lsm_session) {
-		dev_err(rtd->dev,
-			"%s: Invalid %s\n",
-			__func__,
-			(!lsm_d) ? "priv_data" : "session");
-		return -EINVAL;
-	}
-
-	session = lsm_d->lsm_session;
-	hw_params = &lsm_d->hw_params;
-	hw_params->buf_sz = (params_buffer_bytes(params)
-				/ params_periods(params));
-	hw_params->period_count = params_periods(params);
-	hw_params->channels = params_channels(params);
-	hw_params->sample_rate = params_rate(params);
-
-	if (params_format(params) == SNDRV_PCM_FORMAT_S16_LE)
-		hw_params->sample_size = 16;
-	else if (params_format(params) ==
-		 SNDRV_PCM_FORMAT_S24_LE)
-		hw_params->sample_size = 24;
-	else if (params_format(params) ==
-		 SNDRV_PCM_FORMAT_S32_LE)
-		hw_params->sample_size = 32;
-	else {
-		dev_err(rtd->dev,
-			"%s: Invalid Format 0x%x\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	dev_dbg(rtd->dev,
-		"%s: Format %d buffer size(bytes) %d period count %d\n"
-		" Channel %d period in bytes 0x%x Period Size 0x%x rate = %d\n",
-		__func__, params_format(params), params_buffer_bytes(params),
-		params_periods(params), params_channels(params),
-		params_period_bytes(params), params_period_size(params),
-		params_rate(params));
-
-	return 0;
-}
-
-static snd_pcm_uframes_t msm_cpe_lsm_pointer(
-				struct snd_pcm_substream *substream)
-{
-
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct cpe_lsm_session *session;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-
-	session = lsm_d->lsm_session;
-	if (lab_d->dma_write  >= lab_d->pcm_size)
-		lab_d->dma_write = 0;
-	dev_dbg(rtd->dev,
-		"%s:pcm_dma_pos = %d\n",
-		__func__, lab_d->dma_write);
-
-	return bytes_to_frames(runtime, (lab_d->dma_write));
-}
-
-static int msm_cpe_lsm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct cpe_lsm_session *session;
-	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
-	char *pcm_buf;
-	int fbytes = 0;
-	int rc = 0;
-
-	fbytes = frames_to_bytes(runtime, frames);
-	if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
-	   runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-		pr_err("%s: XRUN ignore for now\n", __func__);
-		return 0;
-	}
-	session = lsm_d->lsm_session;
-
-	/* Check if buffer reading is already in error state */
-	if (lab_d->thread_status == MSM_LSM_LAB_THREAD_ERROR) {
-		dev_err(rtd->dev,
-			"%s: Bufferring is in error state\n",
-			__func__);
-		/*
-		 * Advance the period so there is no wait in case
-		 * read is invoked even after error is propogated
-		 */
-		atomic_inc(&lab_d->in_count);
-		lab_d->dma_write += snd_pcm_lib_period_bytes(substream);
-		snd_pcm_period_elapsed(substream);
-		return -ENETRESET;
-	} else if (lab_d->thread_status == MSM_LSM_LAB_THREAD_STOP) {
-		dev_err(rtd->dev,
-			"%s: Buferring is in stopped\n",
-			__func__);
-		return -EIO;
-	}
-
-	rc = wait_event_timeout(lab_d->period_wait,
-			(atomic_read(&lab_d->in_count) ||
-			atomic_read(&lab_d->abort_read)),
-			(2 * HZ));
-	if (atomic_read(&lab_d->abort_read)) {
-		pr_debug("%s: LSM LAB Abort read\n", __func__);
-		return -EIO;
-	}
-	if (lab_d->thread_status != MSM_LSM_LAB_THREAD_RUNNING) {
-		pr_err("%s: Lab stopped\n", __func__);
-		return -EIO;
-	}
-	if (!rc) {
-		pr_err("%s:LAB err wait_event_timeout\n", __func__);
-		rc = -EAGAIN;
-		goto fail;
-	}
-	if (lab_d->buf_idx >= (lsm_d->hw_params.period_count))
-		lab_d->buf_idx = 0;
-	pcm_buf = (lab_d->pcm_buf[lab_d->buf_idx].mem);
-	pr_debug("%s: Buf IDX = 0x%x pcm_buf %pK\n",
-		 __func__,  lab_d->buf_idx, pcm_buf);
-	if (pcm_buf) {
-		if (copy_to_user(buf, pcm_buf, fbytes)) {
-			pr_err("Failed to copy buf to user\n");
-			rc = -EFAULT;
-			goto fail;
-		}
-	}
-	lab_d->buf_idx++;
-	atomic_dec(&lab_d->in_count);
-	return 0;
-fail:
-	return rc;
-}
-
-/*
- * msm_asoc_cpe_lsm_probe: ASoC framework for lsm platform driver
- * @platform: platform registered with ASoC core
- *
- * Allocate the private data for this platform and obtain the ops for
- * lsm and afe modules from underlying driver. Also find the codec
- * for this platform as specified by machine driver for ASoC framework.
- */
-static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform)
-{
-	struct snd_soc_card *card;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_soc_codec *codec;
-	struct cpe_priv *cpe_priv;
-	const struct snd_kcontrol_new *kcontrol;
-	bool found_runtime = false;
-	const char *cpe_dev_id = "qcom,msm-cpe-lsm-id";
-	u32 port_id = 0;
-	int ret = 0;
-
-	if (!platform || !platform->component.card) {
-		pr_err("%s: Invalid platform or card\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	card = platform->component.card;
-
-	/* Match platform to codec */
-	list_for_each_entry(rtd, &card->rtd_list, list) {
-		if (!rtd->platform)
-			continue;
-		if (!strcmp(rtd->platform->component.name,
-			    platform->component.name)) {
-			found_runtime = true;
-			break;
-		}
-	}
-
-	if (!found_runtime) {
-		dev_err(platform->dev,
-			"%s: Failed to find runtime for platform\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	ret = of_property_read_u32(platform->dev->of_node, cpe_dev_id,
-				  &port_id);
-	if (ret) {
-		dev_dbg(platform->dev,
-			"%s: missing 0x%x in dt node\n", __func__, port_id);
-		port_id = 1;
-	}
-
-	codec = rtd->codec;
-
-	cpe_priv = kzalloc(sizeof(struct cpe_priv),
-			   GFP_KERNEL);
-	if (!cpe_priv)
-		return -ENOMEM;
-
-	cpe_priv->codec = codec;
-	cpe_priv->input_port_id = port_id;
-	wcd_cpe_get_lsm_ops(&cpe_priv->lsm_ops);
-	wcd_cpe_get_afe_ops(&cpe_priv->afe_ops);
-
-	snd_soc_platform_set_drvdata(platform, cpe_priv);
-	kcontrol = &msm_cpe_kcontrols[0];
-	snd_ctl_add(card->snd_card, snd_ctl_new1(kcontrol, cpe_priv));
-	return 0;
-}
-
-static const struct snd_pcm_ops msm_cpe_lsm_ops = {
-	.open = msm_cpe_lsm_open,
-	.close = msm_cpe_lsm_close,
-	.ioctl = msm_cpe_lsm_ioctl,
-	.prepare = msm_cpe_lsm_prepare,
-	.trigger = msm_cpe_lsm_trigger,
-	.pointer = msm_cpe_lsm_pointer,
-	.copy = msm_cpe_lsm_copy,
-	.hw_params = msm_cpe_lsm_hwparams,
-	.compat_ioctl = msm_cpe_lsm_ioctl_compat,
-};
-
-static struct snd_soc_platform_driver msm_soc_cpe_platform = {
-	.ops = &msm_cpe_lsm_ops,
-	.probe = msm_asoc_cpe_lsm_probe,
-};
-
-/*
- * msm_cpe_lsm_probe: platform driver probe
- * @pdev: platform device
- *
- * Register the ASoC platform driver with ASoC core
- */
-static int msm_cpe_lsm_probe(struct platform_device *pdev)
-{
-
-	return snd_soc_register_platform(&pdev->dev,
-					 &msm_soc_cpe_platform);
-}
-
-/*
- * msm_cpe_lsm_remove: platform driver remove
- * @pdev: platform device
- *
- * Deregister the ASoC platform driver
- */
-static int msm_cpe_lsm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_cpe_lsm_dt_match[] = {
-	{.compatible = "qcom,msm-cpe-lsm" },
-	{ }
-};
-
-static struct platform_driver msm_cpe_lsm_driver = {
-	.driver = {
-		.name = "msm-cpe-lsm",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(msm_cpe_lsm_dt_match),
-	},
-	.probe = msm_cpe_lsm_probe,
-	.remove = msm_cpe_lsm_remove,
-};
-module_platform_driver(msm_cpe_lsm_driver);
-
-MODULE_DESCRIPTION("CPE LSM platform driver");
-MODULE_DEVICE_TABLE(of, msm_cpe_lsm_dt_match);
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/msm-dai-fe.c b/sound/soc/msm/msm-dai-fe.c
deleted file mode 100644
index 89a9cc2..0000000
--- a/sound/soc/msm/msm-dai-fe.c
+++ /dev/null
@@ -1,2715 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-
-static struct snd_soc_dai_ops msm_fe_dai_ops = {};
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
-	88200, 96000, 176400, 192000, 352800, 384000
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static int multimedia_startup(struct snd_pcm_substream *substream,
-	struct snd_soc_dai *dai)
-{
-	snd_pcm_hw_constraint_list(substream->runtime, 0,
-		SNDRV_PCM_HW_PARAM_RATE,
-		&constraints_sample_rates);
-	return 0;
-}
-
-static int fe_dai_probe(struct snd_soc_dai *dai)
-{
-	struct snd_soc_dapm_route intercon;
-	struct snd_soc_dapm_context *dapm;
-
-	if (!dai || !dai->driver) {
-		pr_err("%s invalid params\n", __func__);
-		return -EINVAL;
-	}
-	dapm = snd_soc_component_get_dapm(dai->component);
-	memset(&intercon, 0, sizeof(intercon));
-	if (dai->driver->playback.stream_name &&
-		dai->driver->playback.aif_name) {
-		dev_dbg(dai->dev, "%s add route for widget %s",
-			   __func__, dai->driver->playback.stream_name);
-		intercon.source = dai->driver->playback.stream_name;
-		intercon.sink = dai->driver->playback.aif_name;
-		dev_dbg(dai->dev, "%s src %s sink %s\n",
-			   __func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		snd_soc_dapm_ignore_suspend(dapm, intercon.source);
-	}
-	if (dai->driver->capture.stream_name &&
-	   dai->driver->capture.aif_name) {
-		dev_dbg(dai->dev, "%s add route for widget %s",
-			   __func__, dai->driver->capture.stream_name);
-		intercon.sink = dai->driver->capture.stream_name;
-		intercon.source = dai->driver->capture.aif_name;
-		dev_dbg(dai->dev, "%s src %s sink %s\n",
-			   __func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
-	}
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_fe_Multimedia_dai_ops = {
-	.startup	= multimedia_startup,
-};
-
-static const struct snd_soc_component_driver msm_fe_dai_component = {
-	.name		= "msm-dai-fe",
-};
-
-static struct snd_soc_dai_driver msm_fe_dais[] = {
-	{
-		.playback = {
-			.stream_name = "MultiMedia1 Playback",
-			.aif_name = "MM_DL1",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia1 Capture",
-			.aif_name = "MM_UL1",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia1",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia2 Playback",
-			.aif_name = "MM_DL2",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia2 Capture",
-			.aif_name = "MM_UL2",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia2",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "CS-VOICE Playback",
-			.aif_name = "CS-VOICE_DL1",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "CS-VOICE Capture",
-			.aif_name = "CS-VOICE_UL1",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "CS-VOICE",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VoIP Playback",
-			.aif_name = "VOIP_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-					SNDRV_PCM_FMTBIT_SPECIAL,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =	8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "VoIP Capture",
-			.aif_name = "VOIP_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-					SNDRV_PCM_FMTBIT_SPECIAL,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =	8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VoIP",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia3 Playback",
-			.aif_name = "MM_DL3",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 6,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia3 Capture",
-			.aif_name = "MM_UL3",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia3",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia4 Playback",
-			.aif_name = "MM_DL4",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia4",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia5 Playback",
-			.aif_name = "MM_DL5",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia5 Capture",
-			.aif_name = "MM_UL5",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia5",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia6 Playback",
-			.aif_name = "MM_DL6",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia6 Capture",
-			.aif_name = "MM_UL6",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia6",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia7 Playback",
-			.aif_name = "MM_DL7",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia7",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia8 Playback",
-			.aif_name = "MM_DL8",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE |
-						SNDRV_PCM_FMTBIT_S24_3LE |
-						SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia8 Capture",
-			.aif_name = "MM_UL8",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia8",
-		.probe = fe_dai_probe,
-	},
-	/* FE DAIs created for hostless operation purpose */
-	{
-		.playback = {
-			.stream_name = "SLIMBUS0_HOSTLESS Playback",
-			.aif_name = "SLIM0_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS0_HOSTLESS Capture",
-			.aif_name = "SLIM0_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_96000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS1_HOSTLESS Playback",
-			.aif_name = "SLIM1_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS1_HOSTLESS Capture",
-			.aif_name = "SLIM1_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS3_HOSTLESS Playback",
-			.aif_name = "SLIM3_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS3_HOSTLESS Capture",
-			.aif_name = "SLIM3_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS4_HOSTLESS Playback",
-			.aif_name = "SLIM4_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-						SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS4_HOSTLESS Capture",
-			.aif_name = "SLIM4_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS6_HOSTLESS Playback",
-			.aif_name = "SLIM6_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS7_HOSTLESS Playback",
-			.aif_name = "SLIM7_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS7_HOSTLESS Capture",
-			.aif_name = "SLIM7_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SLIMBUS8_HOSTLESS Playback",
-			.aif_name = "SLIM8_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "SLIMBUS8_HOSTLESS Capture",
-			.aif_name = "SLIM8_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SLIMBUS8_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "INT_FM_HOSTLESS Playback",
-			.aif_name = "INTFM_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT_FM_HOSTLESS Capture",
-			.aif_name = "INTFM_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "INT_FM_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "INT_HFP_BT Hostless Playback",
-			.aif_name = "INTHFP_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     16000,
-		},
-		.capture = {
-			.stream_name = "INT_HFP_BT Hostless Capture",
-			.aif_name = "INTHFP_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     16000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "INT_HFP_BT_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "USBAUDIO_HOSTLESS Playback",
-			.aif_name = "USBAUDIO_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-				SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-				SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
-				SNDRV_PCM_RATE_384000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE |
-				SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "USBAUDIO_HOSTLESS Capture",
-			.aif_name = "USBAUDIO_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-				SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-				SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
-				SNDRV_PCM_RATE_384000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE |
-				SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "USBAUDIO_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "AFE Playback",
-			.aif_name = "PCM_RX",
-			.rates = (SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_48000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "AFE Capture",
-			.aif_name = "PCM_TX",
-			.rates = (SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_48000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "AFE-PROXY",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "HDMI_HOSTLESS Playback",
-			.aif_name = "HDMI_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "HDMI_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "AUXPCM_HOSTLESS Playback",
-			.aif_name = "AUXPCM_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_min =     8000,
-			.rate_max =     16000,
-		},
-		.capture = {
-			.stream_name = "AUXPCM_HOSTLESS Capture",
-			.aif_name = "AUXPCM_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_min =     8000,
-			.rate_max =    16000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "AUXPCM_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VOICE_STUB Playback",
-			.aif_name = "VOICE_STUB_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "VOICE_STUB Capture",
-			.aif_name = "VOICE_STUB_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VOICE_STUB",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VoLTE Playback",
-			.aif_name = "VoLTE_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "VoLTE Capture",
-			.aif_name = "VoLTE_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VoLTE",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MI2S_RX_HOSTLESS Playback",
-			.aif_name = "MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "MI2S_TX_HOSTLESS Capture",
-			.aif_name = "MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "SEC_I2S_RX_HOSTLESS Playback",
-			.aif_name = "SEC_I2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =    48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_I2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary MI2S_TX Hostless Capture",
-			.aif_name = "PRI_MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary MI2S_RX Hostless Playback",
-			.aif_name = "PRI_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =    384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary MI2S_TX Hostless Capture",
-			.aif_name = "SEC_MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary MI2S_RX Hostless Playback",
-			.aif_name = "SEC_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary MI2S_TX Hostless Capture",
-			.aif_name = "TERT_MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary MI2S_RX Hostless Playback",
-			.aif_name = "TERT_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =	8000,
-			.rate_max =    384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary MI2S_TX Hostless Capture",
-			.aif_name = "QUAT_MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary MI2S_RX Hostless Playback",
-			.aif_name = "QUAT_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "INT0 MI2S_RX Hostless Playback",
-			.aif_name = "INT0_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_192000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =    192000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "INT0_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "INT4 MI2S_RX Hostless Playback",
-			.aif_name = "INT4_MI2S_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_192000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min =     8000,
-			.rate_max =    192000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "INT4_MI2S_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "INT3 MI2S_TX Hostless Capture",
-			.aif_name = "INT3_MI2S_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "INT3_MI2S_TX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	/* TDM Hostless */
-	{
-		.capture = {
-			.stream_name = "Primary TDM0 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_0_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM0 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_0_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM1 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_1_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM1 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_1_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM2 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_2_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM2 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_2_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM3 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_3_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM3 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_3_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM4 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_4_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM4 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_4_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM5 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_5_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM5 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_5_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM6 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_6_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM6 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_6_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM7 Hostless Capture",
-			.aif_name = "PRI_TDM_TX_7_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_TX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM7 Hostless Playback",
-			.aif_name = "PRI_TDM_RX_7_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "PRI_TDM_RX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM0 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_0_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM0 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_0_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM1 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_1_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM1 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_1_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM2 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_2_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM2 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_2_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM3 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_3_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM3 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_3_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM4 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_4_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM4 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_4_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM5 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_5_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM5 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_5_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM6 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_6_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM6 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_6_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM7 Hostless Capture",
-			.aif_name = "SEC_TDM_TX_7_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_TX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM7 Hostless Playback",
-			.aif_name = "SEC_TDM_RX_7_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "SEC_TDM_RX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM0 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_0_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM0 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_0_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM1 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_1_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM1 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_1_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM2 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_2_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM2 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_2_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM3 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_3_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM3 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_3_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM4 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_4_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM4 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_4_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM5 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_5_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM5 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_5_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM6 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_6_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM6 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_6_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM7 Hostless Capture",
-			.aif_name = "TERT_TDM_TX_7_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_TX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM7 Hostless Playback",
-			.aif_name = "TERT_TDM_RX_7_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "TERT_TDM_RX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM0 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_0_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM0 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_0_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_0_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM1 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_1_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM1 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_1_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_1_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM2 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_2_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM2 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_2_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_2_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM3 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_3_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM3 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_3_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_3_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM4 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_4_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM4 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_4_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_4_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM5 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_5_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM5 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_5_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_5_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM6 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_6_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM6 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_6_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_6_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM7 Hostless Capture",
-			.aif_name = "QUAT_TDM_TX_7_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_TX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM7 Hostless Playback",
-			.aif_name = "QUAT_TDM_RX_7_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QUAT_TDM_RX_7_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Voice2 Playback",
-			.aif_name = "VOICE2_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "Voice2 Capture",
-			.aif_name = "VOICE2_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "Voice2",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "Pseudo Playback",
-			.aif_name = "MM_DL9",
-			.rates = (SNDRV_PCM_RATE_8000_48000 |
-					SNDRV_PCM_RATE_KNOT),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "Pseudo Capture",
-			.aif_name = "MM_UL9",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "Pseudo",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "DTMF_RX_HOSTLESS Playback",
-			.aif_name = "DTMF_DL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =	8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "DTMF_RX_HOSTLESS",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "CPE Listen Audio capture",
-			.aif_name = "CPE_LSM_UL_HL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "CPE_LSM_NOHOST",
-	},
-	{
-		.playback = {
-			.stream_name = "VOLTE_STUB Playback",
-			.aif_name = "VOLTE_STUB_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "VOLTE_STUB Capture",
-			.aif_name = "VOLTE_STUB_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VOLTE_STUB",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VOICE2_STUB Playback",
-			.aif_name = "VOICE2_STUB_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "VOICE2_STUB Capture",
-			.aif_name = "VOICE2_STUB_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VOICE2_STUB",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia9 Playback",
-			.aif_name = "MM_DL9",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia9 Capture",
-			.aif_name = "MM_UL9",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia9",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "QCHAT Playback",
-			.aif_name = "QCHAT_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "QCHAT Capture",
-			.aif_name = "QCHAT_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "QCHAT",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 1 Audio Service Capture",
-			.aif_name = "LSM1_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM1",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 2 Audio Service Capture",
-			.aif_name = "LSM2_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM2",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 3 Audio Service Capture",
-			.aif_name = "LSM3_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM3",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 4 Audio Service Capture",
-			.aif_name = "LSM4_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM4",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 5 Audio Service Capture",
-			.aif_name = "LSM5_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM5",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 6 Audio Service Capture",
-			.aif_name = "LSM6_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM6",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 7 Audio Service Capture",
-			.aif_name = "LSM7_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM7",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "Listen 8 Audio Service Capture",
-			.aif_name = "LSM8_UL_HL",
-			.rates = (SNDRV_PCM_RATE_16000 |
-				  SNDRV_PCM_RATE_48000),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE),
-			.channels_min = 1,
-			.channels_max = 4,
-			.rate_min = 16000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "LSM8",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VoWLAN Playback",
-			.aif_name = "VoWLAN_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.capture = {
-			.stream_name = "VoWLAN Capture",
-			.aif_name = "VoWLAN_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VoWLAN",
-		.probe = fe_dai_probe,
-	},
-	/* FE DAIs created for multiple instances of offload playback */
-	{
-		.playback = {
-			.stream_name = "MultiMedia10 Playback",
-			.aif_name = "MM_DL10",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia10 Capture",
-			.aif_name = "MM_UL10",
-			.rates = (SNDRV_PCM_RATE_8000_48000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia10",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia11 Playback",
-			.aif_name = "MM_DL11",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia11",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia12 Playback",
-			.aif_name = "MM_DL12",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia12",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia13 Playback",
-			.aif_name = "MM_DL13",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia13",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia14 Playback",
-			.aif_name = "MM_DL14",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia14",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia15 Playback",
-			.aif_name = "MM_DL15",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia15",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia16 Playback",
-			.aif_name = "MM_DL16",
-			.rates = (SNDRV_PCM_RATE_8000_384000 |
-				  SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =	8000,
-			.rate_max = 384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia16 Capture",
-			.aif_name = "MM_UL16",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia16",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VoiceMMode1 Playback",
-			.aif_name = "VOICEMMODE1_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-	 },
-		.capture = {
-			.stream_name = "VoiceMMode1 Capture",
-			.aif_name = "VOICEMMODE1_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VoiceMMode1",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "VoiceMMode2 Playback",
-			.aif_name = "VOICEMMODE2_DL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "VoiceMMode2 Capture",
-			.aif_name = "VOICEMMODE2_UL",
-			.rates = SNDRV_PCM_RATE_8000_48000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_dai_ops,
-		.name = "VoiceMMode2",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "MultiMedia17 Capture",
-			.aif_name = "MM_UL17",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia17",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "MultiMedia18 Capture",
-			.aif_name = "MM_UL18",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia18",
-		.probe = fe_dai_probe,
-	},
-	{
-		.capture = {
-			.stream_name = "MultiMedia19 Capture",
-			.aif_name = "MM_UL19",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.compress_new = snd_soc_new_compress,
-		.name = "MultiMedia19",
-		.probe = fe_dai_probe,
-	},
-	{
-		.playback = {
-			.stream_name = "MultiMedia20 Playback",
-			.aif_name = "MM_DL20",
-			.rates = (SNDRV_PCM_RATE_8000_384000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     384000,
-		},
-		.capture = {
-			.stream_name = "MultiMedia20 Capture",
-			.aif_name = "MM_UL20",
-			.rates = (SNDRV_PCM_RATE_8000_48000|
-					SNDRV_PCM_RATE_KNOT),
-			.formats = (SNDRV_PCM_FMTBIT_S16_LE |
-				    SNDRV_PCM_FMTBIT_S24_LE |
-				    SNDRV_PCM_FMTBIT_S24_3LE |
-				    SNDRV_PCM_FMTBIT_S32_LE),
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_fe_Multimedia_dai_ops,
-		.name = "MultiMedia20",
-		.probe = fe_dai_probe,
-	},
-};
-
-static int msm_fe_dai_dev_probe(struct platform_device *pdev)
-{
-
-	dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
-		dev_name(&pdev->dev));
-	return snd_soc_register_component(&pdev->dev, &msm_fe_dai_component,
-		msm_fe_dais, ARRAY_SIZE(msm_fe_dais));
-}
-
-static int msm_fe_dai_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_dai_fe_dt_match[] = {
-	{.compatible = "qcom,msm-dai-fe"},
-	{}
-};
-
-static struct platform_driver msm_fe_dai_driver = {
-	.probe  = msm_fe_dai_dev_probe,
-	.remove = msm_fe_dai_dev_remove,
-	.driver = {
-		.name = "msm-dai-fe",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_fe_dt_match,
-	},
-};
-
-static int __init msm_fe_dai_init(void)
-{
-	return platform_driver_register(&msm_fe_dai_driver);
-}
-module_init(msm_fe_dai_init);
-
-static void __exit msm_fe_dai_exit(void)
-{
-	platform_driver_unregister(&msm_fe_dai_driver);
-}
-module_exit(msm_fe_dai_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("MSM Frontend DAI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/msm-pcm-hostless.c b/sound/soc/msm/msm-pcm-hostless.c
deleted file mode 100644
index 35766b4..0000000
--- a/sound/soc/msm/msm-pcm-hostless.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-
-
-static int msm_pcm_hostless_prepare(struct snd_pcm_substream *substream)
-{
-	if (!substream) {
-		pr_err("%s: invalid params\n", __func__);
-		return -EINVAL;
-	}
-	pm_qos_remove_request(&substream->latency_pm_qos_req);
-	return 0;
-}
-
-static const struct snd_pcm_ops msm_pcm_hostless_ops = {
-	.prepare = msm_pcm_hostless_prepare
-};
-
-static struct snd_soc_platform_driver msm_soc_hostless_platform = {
-	.ops		= &msm_pcm_hostless_ops,
-};
-
-static int msm_pcm_hostless_probe(struct platform_device *pdev)
-{
-
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev,
-				   &msm_soc_hostless_platform);
-}
-
-static int msm_pcm_hostless_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_pcm_hostless_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-hostless"},
-	{}
-};
-
-static struct platform_driver msm_pcm_hostless_driver = {
-	.driver = {
-		.name = "msm-pcm-hostless",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_hostless_dt_match,
-	},
-	.probe = msm_pcm_hostless_probe,
-	.remove = msm_pcm_hostless_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_pcm_hostless_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_hostless_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("Hostless platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/msm8998.c b/sound/soc/msm/msm8998.c
deleted file mode 100644
index 05b7d30..0000000
--- a/sound/soc/msm/msm8998.c
+++ /dev/null
@@ -1,7483 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/regulator/consumer.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/switch.h>
-#include <linux/input.h>
-#include <linux/of_device.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/jack.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6core.h>
-#include <sound/pcm_params.h>
-#include <sound/info.h>
-#include <device_event.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "../codecs/wcd9335.h"
-#include "../codecs/wcd934x/wcd934x.h"
-#include "../codecs/wcd934x/wcd934x-mbhc.h"
-#include "../codecs/wsa881x.h"
-
-#define DRV_NAME "msm8998-asoc-snd"
-
-#define __CHIPSET__ "MSM8998 "
-#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
-
-#define SAMPLING_RATE_8KHZ      8000
-#define SAMPLING_RATE_11P025KHZ 11025
-#define SAMPLING_RATE_16KHZ     16000
-#define SAMPLING_RATE_22P05KHZ  22050
-#define SAMPLING_RATE_32KHZ     32000
-#define SAMPLING_RATE_44P1KHZ   44100
-#define SAMPLING_RATE_48KHZ     48000
-#define SAMPLING_RATE_88P2KHZ   88200
-#define SAMPLING_RATE_96KHZ     96000
-#define SAMPLING_RATE_176P4KHZ  176400
-#define SAMPLING_RATE_192KHZ    192000
-#define SAMPLING_RATE_352P8KHZ  352800
-#define SAMPLING_RATE_384KHZ    384000
-
-#define WCD9XXX_MBHC_DEF_BUTTONS    8
-#define WCD9XXX_MBHC_DEF_RLOADS     5
-#define CODEC_EXT_CLK_RATE          9600000
-#define ADSP_STATE_READY_TIMEOUT_MS 3000
-#define DEV_NAME_STR_LEN            32
-
-#define WSA8810_NAME_1 "wsa881x.20170211"
-#define WSA8810_NAME_2 "wsa881x.20170212"
-
-#define WCN_CDC_SLIM_RX_CH_MAX 2
-#define WCN_CDC_SLIM_TX_CH_MAX 3
-
-#define TDM_CHANNEL_MAX 8
-#define TDM_SLOT_OFFSET_MAX 8
-
-#define MSM_HIFI_ON 1
-
-enum {
-	SLIM_RX_0 = 0,
-	SLIM_RX_1,
-	SLIM_RX_2,
-	SLIM_RX_3,
-	SLIM_RX_4,
-	SLIM_RX_5,
-	SLIM_RX_6,
-	SLIM_RX_7,
-	SLIM_RX_MAX,
-};
-
-enum {
-	SLIM_TX_0 = 0,
-	SLIM_TX_1,
-	SLIM_TX_2,
-	SLIM_TX_3,
-	SLIM_TX_4,
-	SLIM_TX_5,
-	SLIM_TX_6,
-	SLIM_TX_7,
-	SLIM_TX_8,
-	SLIM_TX_MAX,
-};
-
-enum {
-	PRIM_MI2S = 0,
-	SEC_MI2S,
-	TERT_MI2S,
-	QUAT_MI2S,
-	MI2S_MAX,
-};
-
-enum {
-	PRIM_AUX_PCM = 0,
-	SEC_AUX_PCM,
-	TERT_AUX_PCM,
-	QUAT_AUX_PCM,
-	AUX_PCM_MAX,
-};
-
-enum {
-	PCM_I2S_SEL_PRIM = 0,
-	PCM_I2S_SEL_SEC,
-	PCM_I2S_SEL_TERT,
-	PCM_I2S_SEL_QUAT,
-	PCM_I2S_SEL_MAX,
-};
-
-struct mi2s_aux_pcm_common_conf {
-	struct mutex lock;
-	void *pcm_i2s_sel_vt_addr;
-};
-
-struct mi2s_conf {
-	struct mutex lock;
-	u32 ref_cnt;
-	u32 msm_is_mi2s_master;
-};
-
-struct auxpcm_conf {
-	struct mutex lock;
-	u32 ref_cnt;
-};
-
-struct dev_config {
-	u32 sample_rate;
-	u32 bit_format;
-	u32 channels;
-};
-
-enum {
-	HDMI_RX_IDX = 0,
-	DP_RX_IDX,
-	EXT_DISP_RX_IDX_MAX,
-};
-
-struct msm_wsa881x_dev_info {
-	struct device_node *of_node;
-	u32 index;
-};
-
-enum pinctrl_pin_state {
-	STATE_DISABLE = 0, /* All pins are in sleep state */
-	STATE_MI2S_ACTIVE,  /* IS2 = active, TDM = sleep */
-	STATE_TDM_ACTIVE,  /* IS2 = sleep, TDM = active */
-};
-
-struct msm_pinctrl_info {
-	struct pinctrl *pinctrl;
-	struct pinctrl_state *mi2s_disable;
-	struct pinctrl_state *tdm_disable;
-	struct pinctrl_state *mi2s_active;
-	struct pinctrl_state *tdm_active;
-	enum pinctrl_pin_state curr_state;
-};
-
-struct msm_asoc_mach_data {
-	u32 mclk_freq;
-	int us_euro_gpio; /* used by gpio driver API */
-	struct device_node *us_euro_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
-	struct snd_info_entry *codec_root;
-	struct msm_pinctrl_info pinctrl_info;
-};
-
-struct msm_asoc_wcd93xx_codec {
-	void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
-				   enum afe_config_type config_type);
-	void (*mbhc_hs_detect_exit)(struct snd_soc_codec *codec);
-};
-
-static const char *const pin_states[] = {"sleep", "i2s-active",
-					 "tdm-active"};
-
-enum {
-	TDM_0 = 0,
-	TDM_1,
-	TDM_2,
-	TDM_3,
-	TDM_4,
-	TDM_5,
-	TDM_6,
-	TDM_7,
-	TDM_PORT_MAX,
-};
-
-enum {
-	TDM_PRI = 0,
-	TDM_SEC,
-	TDM_TERT,
-	TDM_QUAT,
-	TDM_INTERFACE_MAX,
-};
-
-struct tdm_port {
-	u32 mode;
-	u32 channel;
-};
-
-/* TDM default config */
-static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	}
-};
-
-/* TDM default config */
-static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	}
-};
-
-/*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */
-static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
-	{0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */
-};
-
-/* Default configuration of slimbus channels */
-static struct dev_config slim_rx_cfg[] = {
-	[SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config slim_tx_cfg[] = {
-	[SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-
-/* Default configuration of external display BE */
-static struct dev_config ext_disp_rx_cfg[] = {
-	[HDMI_RX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[DP_RX_IDX] =   {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config usb_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-static struct dev_config usb_tx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 1,
-};
-
-static struct dev_config proxy_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-/* Default configuration of MI2S channels */
-static struct dev_config mi2s_rx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config mi2s_tx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_rx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_tx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static int msm_vi_feed_tx_ch = 2;
-static const char *const slim_rx_ch_text[] = {"One", "Two"};
-static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
-						"Five", "Six", "Seven",
-						"Eight"};
-static const char *const vi_feed_ch_text[] = {"One", "Two"};
-static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
-					  "S32_LE"};
-static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE"};
-static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_88P2", "KHZ_96", "KHZ_176P4",
-					"KHZ_192", "KHZ_352P8", "KHZ_384"};
-static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"};
-static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static char const *ch_text[] = {"Two", "Three", "Four", "Five",
-					"Six", "Seven", "Eight"};
-static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
-					"KHZ_16", "KHZ_22P05",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_88P2", "KHZ_96", "KHZ_176P4",
-					"KHZ_192", "KHZ_352P8", "KHZ_384"};
-static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
-					"KHZ_192", "KHZ_32", "KHZ_44P1",
-					"KHZ_88P2", "KHZ_176P4"};
-static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
-				    "Five", "Six", "Seven", "Eight"};
-static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
-static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
-					     "KHZ_44P1", "KHZ_48", "KHZ_96",
-					     "KHZ_192", "KHZ_352P8", "KHZ_384"};
-static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
-static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_16",
-				      "KHZ_32", "KHZ_44P1", "KHZ_48",
-				      "KHZ_96", "KHZ_192"};
-static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static const char *const hifi_text[] = {"Off", "On"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
-				ext_disp_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(hifi_function, hifi_text);
-
-static struct platform_device *spdev;
-static int msm_hifi_control;
-
-static bool is_initial_boot;
-static bool codec_reg_done;
-static struct snd_soc_aux_dev *msm_aux_dev;
-static struct snd_soc_codec_conf *msm_codec_conf;
-static struct msm_asoc_wcd93xx_codec msm_codec_fn;
-
-static void *def_tasha_mbhc_cal(void);
-static void *def_tavil_mbhc_cal(void);
-static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
-					int enable, bool dapm);
-static int msm_wsa881x_init(struct snd_soc_component *component);
-
-/*
- * Need to report LINEIN
- * if R/L channel impedance is larger than 5K ohm
- */
-static struct wcd_mbhc_config wcd_mbhc_cfg = {
-	.read_fw_bin = false,
-	.calibration = NULL,
-	.detect_extn_cable = true,
-	.mono_stero_detection = false,
-	.swap_gnd_mic = NULL,
-	.hs_ext_micbias = true,
-	.key_code[0] = KEY_MEDIA,
-	.key_code[1] = KEY_VOICECOMMAND,
-	.key_code[2] = KEY_VOLUMEUP,
-	.key_code[3] = KEY_VOLUMEDOWN,
-	.key_code[4] = 0,
-	.key_code[5] = 0,
-	.key_code[6] = 0,
-	.key_code[7] = 0,
-	.linein_th = 5000,
-	.moisture_en = true,
-	.mbhc_micbias = MIC_BIAS_2,
-	.anc_micbias = MIC_BIAS_2,
-	.enable_anc_mic_detect = false,
-};
-
-static struct snd_soc_dapm_route wcd_audio_paths_tasha[] = {
-	{"MIC BIAS1", NULL, "MCLK TX"},
-	{"MIC BIAS2", NULL, "MCLK TX"},
-	{"MIC BIAS3", NULL, "MCLK TX"},
-	{"MIC BIAS4", NULL, "MCLK TX"},
-};
-
-static struct snd_soc_dapm_route wcd_audio_paths[] = {
-	{"MIC BIAS1", NULL, "MCLK"},
-	{"MIC BIAS2", NULL, "MCLK"},
-	{"MIC BIAS3", NULL, "MCLK"},
-	{"MIC BIAS4", NULL, "MCLK"},
-};
-
-static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	}
-};
-
-static struct mi2s_aux_pcm_common_conf mi2s_auxpcm_conf[PCM_I2S_SEL_MAX];
-static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
-static struct auxpcm_conf auxpcm_intf_conf[AUX_PCM_MAX];
-
-static int slim_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 10;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int slim_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int slim_get_bit_format_val(int bit_format)
-{
-	int val = 0;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		val = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		val = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		val = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		val = 0;
-		break;
-	}
-	return val;
-}
-
-static int slim_get_bit_format(int val)
-{
-	int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-
-	switch (val) {
-	case 0:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return bit_fmt;
-}
-
-static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int port_id = 0;
-
-	if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX")))
-		port_id = SLIM_RX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_2_RX", sizeof("SLIM_2_RX")))
-		port_id = SLIM_RX_2;
-	else if (strnstr(kcontrol->id.name, "SLIM_5_RX", sizeof("SLIM_5_RX")))
-		port_id = SLIM_RX_5;
-	else if (strnstr(kcontrol->id.name, "SLIM_6_RX", sizeof("SLIM_6_RX")))
-		port_id = SLIM_RX_6;
-	else if (strnstr(kcontrol->id.name, "SLIM_0_TX", sizeof("SLIM_0_TX")))
-		port_id = SLIM_TX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_1_TX", sizeof("SLIM_1_TX")))
-		port_id = SLIM_TX_1;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	return port_id;
-}
-
-static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].sample_rate =
-		slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate = 0;
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-	if (sample_rate == SAMPLING_RATE_44P1KHZ) {
-		pr_err("%s: Unsupported sample rate %d: for Tx path\n",
-			__func__, sample_rate);
-		return -EINVAL;
-	}
-	slim_tx_cfg[ch_num].sample_rate = sample_rate;
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_slim_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_tx_ch  = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
-	pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
-	return 1;
-}
-
-static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	/*
-	 * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
-	 * when used for BT_SCO use case. Return either Rx or Tx sample rate
-	 * value.
-	 */
-	switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
-	case SAMPLING_RATE_48KHZ:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: sample rate = %d", __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate);
-
-	return 0;
-}
-
-static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 0:
-	default:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
-		 __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate,
-		 slim_tx_cfg[SLIM_TX_7].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_rx_ch  = %d\n", __func__,
-		 usb_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_rx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 12;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 11;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 10;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
-		 usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 12:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 11:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_rx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_tx_ch  = %d\n", __func__,
-		 usb_tx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_tx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 12;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 11;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 10;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	default:
-		sample_rate_val = 6;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
-		 usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 12:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 11:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_tx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "HDMI_RX", sizeof("HDMI_RX")))
-		idx = HDMI_RX_IDX;
-	else if (strnstr(kcontrol->id.name, "Display Port RX",
-			 sizeof("Display Port RX")))
-		idx = DP_RX_IDX;
-	else {
-		pr_err("%s: unsupported BE: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].bit_format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.integer.value[0] =
-			ext_disp_rx_cfg[idx].channels - 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ext_disp_rx_cfg[idx].channels =
-			ucontrol->value.integer.value[0] + 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-	return 1;
-}
-
-static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].sample_rate) {
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 6;
-		break;
-
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 5;
-		break;
-
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 4;
-		break;
-
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 3;
-		break;
-
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 2;
-		break;
-
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 1;
-		break;
-
-	case SAMPLING_RATE_48KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].sample_rate);
-
-	return 0;
-}
-
-static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 6:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 5:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 4:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 3:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 2:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 1:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
-		 __func__, ucontrol->value.integer.value[0], idx,
-		 ext_disp_rx_cfg[idx].sample_rate);
-	return 0;
-}
-
-static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
-
-	return 0;
-}
-
-static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-
-	return 1;
-}
-
-static int tdm_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int aux_pcm_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 0:
-	default:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int tdm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 8;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int aux_pcm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
-			    struct tdm_port *port)
-{
-	if (port) {
-		if (strnstr(kcontrol->id.name, "PRI",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_PRI;
-		} else if (strnstr(kcontrol->id.name, "SEC",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_SEC;
-		} else if (strnstr(kcontrol->id.name, "TERT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_TERT;
-		} else if (strnstr(kcontrol->id.name, "QUAT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_QUAT;
-		} else {
-			pr_err("%s: unsupported mode in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-
-		if (strnstr(kcontrol->id.name, "RX_0",
-		    sizeof(kcontrol->id.name)) ||
-		    strnstr(kcontrol->id.name, "TX_0",
-		    sizeof(kcontrol->id.name))) {
-			port->channel = TDM_0;
-		} else if (strnstr(kcontrol->id.name, "RX_1",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_1",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_1;
-		} else if (strnstr(kcontrol->id.name, "RX_2",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_2",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_2;
-		} else if (strnstr(kcontrol->id.name, "RX_3",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_3",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_3;
-		} else if (strnstr(kcontrol->id.name, "RX_4",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_4",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_4;
-		} else if (strnstr(kcontrol->id.name, "RX_5",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_5",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_5;
-		} else if (strnstr(kcontrol->id.name, "RX_6",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_6",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_6;
-		} else if (strnstr(kcontrol->id.name, "RX_7",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_7",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_7;
-		} else {
-			pr_err("%s: unsupported channel in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-	} else
-		return -EINVAL;
-	return 0;
-}
-
-static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_rx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_tx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_get_format(int value)
-{
-	int format = 0;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int tdm_get_format_val(int format)
-{
-	int value = 0;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 2;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_rx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_tx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-
-		ucontrol->value.enumerated.item[0] =
-			tdm_rx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] =
-			tdm_tx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
-		    sizeof("PRIM_AUX_PCM")))
-		idx = PRIM_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
-			 sizeof("SEC_AUX_PCM")))
-		idx = SEC_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
-			 sizeof("TERT_AUX_PCM")))
-		idx = TERT_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
-			 sizeof("QUAT_AUX_PCM")))
-		idx = QUAT_AUX_PCM;
-	else {
-		pr_err("%s: unsupported port: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_rx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_tx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
-	    sizeof("PRIM_MI2S_RX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
-		 sizeof("SEC_MI2S_RX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
-		 sizeof("TERT_MI2S_RX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
-		 sizeof("QUAT_MI2S_RX")))
-		idx = QUAT_MI2S;
-	else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
-		 sizeof("PRIM_MI2S_TX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
-		 sizeof("SEC_MI2S_TX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
-		 sizeof("TERT_MI2S_TX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
-		 sizeof("QUAT_MI2S_TX")))
-		idx = QUAT_MI2S;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int mi2s_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int mi2s_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int mi2s_get_format(int value)
-{
-	int format;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int mi2s_get_format_value(int format)
-{
-	int value;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		value = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 3;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_format_value(mi2s_rx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		idx, mi2s_rx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].bit_format =
-		mi2s_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_rx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_format_value(mi2s_tx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		idx, mi2s_tx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].bit_format =
-		mi2s_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_tx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_hifi_ctrl(struct snd_soc_codec *codec)
-{
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	pr_debug("%s: msm_hifi_control = %d", __func__,
-		 msm_hifi_control);
-
-	if (!pdata || !pdata->hph_en1_gpio_p) {
-		pr_err("%s: hph_en1_gpio is invalid\n", __func__);
-		return -EINVAL;
-	}
-	if (msm_hifi_control == MSM_HIFI_ON) {
-		msm_cdc_pinctrl_select_active_state(pdata->hph_en1_gpio_p);
-		/* 5msec delay needed as per HW requirement */
-		usleep_range(5000, 5010);
-	} else {
-		msm_cdc_pinctrl_select_sleep_state(pdata->hph_en1_gpio_p);
-	}
-	snd_soc_dapm_sync(dapm);
-
-	return 0;
-}
-
-static int msm_hifi_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: msm_hifi_control = %d\n",
-		 __func__, msm_hifi_control);
-	ucontrol->value.integer.value[0] = msm_hifi_control;
-
-	return 0;
-}
-
-static int msm_hifi_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	pr_debug("%s() ucontrol->value.integer.value[0] = %ld\n",
-		 __func__, ucontrol->value.integer.value[0]);
-
-	msm_hifi_control = ucontrol->value.integer.value[0];
-	msm_hifi_ctrl(codec);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new msm_snd_controls[] = {
-	SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
-			msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
-			usb_audio_rx_ch_get, usb_audio_rx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
-			usb_audio_tx_ch_get, usb_audio_tx_ch_put),
-	SOC_ENUM_EXT("HDMI_RX Channels", ext_disp_rx_chs,
-			ext_disp_rx_ch_get, ext_disp_rx_ch_put),
-	SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
-			ext_disp_rx_ch_get, ext_disp_rx_ch_put),
-	SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
-			proxy_rx_ch_get, proxy_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
-			slim_tx_bit_format_get, slim_tx_bit_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
-			usb_audio_rx_format_get, usb_audio_rx_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
-			usb_audio_tx_format_get, usb_audio_tx_format_put),
-	SOC_ENUM_EXT("HDMI_RX Bit Format", ext_disp_rx_format,
-			ext_disp_rx_format_get, ext_disp_rx_format_put),
-	SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
-			ext_disp_rx_format_get, ext_disp_rx_format_put),
-	SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
-			slim_tx_sample_rate_get, slim_tx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
-			msm_bt_sample_rate_get,
-			msm_bt_sample_rate_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
-			usb_audio_rx_sample_rate_get,
-			usb_audio_rx_sample_rate_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
-			usb_audio_tx_sample_rate_get,
-			usb_audio_tx_sample_rate_put),
-	SOC_ENUM_EXT("HDMI_RX SampleRate", ext_disp_rx_sample_rate,
-			ext_disp_rx_sample_rate_get,
-			ext_disp_rx_sample_rate_put),
-	SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
-			ext_disp_rx_sample_rate_get,
-			ext_disp_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("HiFi Function", hifi_function, msm_hifi_get,
-			msm_hifi_put),
-};
-
-static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
-					int enable, bool dapm)
-{
-	int ret = 0;
-
-	if (!strcmp(dev_name(codec->dev), "tasha_codec"))
-		ret = tasha_cdc_mclk_enable(codec, enable, dapm);
-	else if (!strcmp(dev_name(codec->dev), "tavil_codec"))
-		ret = tavil_cdc_mclk_enable(codec, enable);
-	else {
-		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_codec *codec,
-					   int enable, bool dapm)
-{
-	int ret = 0;
-
-	if (!strcmp(dev_name(codec->dev), "tasha_codec"))
-		ret = tasha_cdc_mclk_tx_enable(codec, enable, dapm);
-	else {
-		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
-				 struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_mclk_event(struct snd_soc_dapm_widget *w,
-				 struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_snd_enable_codec_ext_clk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_snd_enable_codec_ext_clk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
-			       struct snd_kcontrol *k, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	pr_debug("%s: msm_hifi_control = %d", __func__, msm_hifi_control);
-
-	if (!pdata || !pdata->hph_en0_gpio_p) {
-		pr_err("%s: hph_en0_gpio is invalid\n", __func__);
-		return -EINVAL;
-	}
-
-	if (msm_hifi_control != MSM_HIFI_ON) {
-		pr_debug("%s: HiFi mixer control is not set\n",
-			 __func__);
-		return 0;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		msm_cdc_pinctrl_select_active_state(pdata->hph_en0_gpio_p);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		msm_cdc_pinctrl_select_sleep_state(pdata->hph_en0_gpio_p);
-		break;
-	}
-
-	return 0;
-}
-
-static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
-
-	SND_SOC_DAPM_SUPPLY("MCLK",  SND_SOC_NOPM, 0, 0,
-			    msm_mclk_event,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SUPPLY("MCLK TX",  SND_SOC_NOPM, 0, 0,
-	msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_3 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_4 amp", NULL),
-	SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
-	SND_SOC_DAPM_MIC("Handset Mic", NULL),
-	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic5", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic6", NULL),
-
-	SND_SOC_DAPM_MIC("Digital Mic0", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic1", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic2", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic3", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic4", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic5", NULL),
-};
-
-static inline int param_is_mask(int p)
-{
-	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
-			(p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
-}
-
-static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
-					     int n)
-{
-	return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
-}
-
-static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
-{
-	if (bit >= SNDRV_MASK_MAX)
-		return;
-	if (param_is_mask(n)) {
-		struct snd_mask *m = param_to_mask(p, n);
-
-		m->bits[0] = 0;
-		m->bits[1] = 0;
-		m->bits[bit >> 5] |= (1 << (bit & 31));
-	}
-}
-
-static int msm_slim_get_ch_from_beid(int32_t be_id)
-{
-	int ch_id = 0;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-		ch_id = SLIM_RX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-		ch_id = SLIM_RX_1;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-		ch_id = SLIM_RX_2;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-		ch_id = SLIM_RX_3;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-		ch_id = SLIM_RX_4;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		ch_id = SLIM_RX_6;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-		ch_id = SLIM_TX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		ch_id = SLIM_TX_3;
-		break;
-	default:
-		ch_id = SLIM_RX_0;
-		break;
-	}
-
-	return ch_id;
-}
-
-static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
-{
-	int idx;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_HDMI_RX:
-		idx = HDMI_RX_IDX;
-		break;
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = DP_RX_IDX;
-		break;
-	default:
-		pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
-		idx = -EINVAL;
-		break;
-	}
-
-	return idx;
-}
-
-static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-	int rc = 0;
-	int idx;
-	void *config = NULL;
-	struct snd_soc_codec *codec = NULL;
-
-	pr_debug("%s: format = %d, rate = %d\n",
-		  __func__, params_format(params), params_rate(params));
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_1_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[1].bit_format);
-		rate->min = rate->max = slim_tx_cfg[1].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[1].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_4_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       SNDRV_PCM_FORMAT_S32_LE);
-		rate->min = rate->max = SAMPLING_RATE_8KHZ;
-		channels->min = channels->max = msm_vi_feed_tx_ch;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[5].bit_format);
-		rate->min = rate->max = slim_rx_cfg[5].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[5].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_TX:
-		codec = rtd->codec;
-		rate->min = rate->max = SAMPLING_RATE_16KHZ;
-		channels->min = channels->max = 1;
-
-		config = msm_codec_fn.get_afe_config_fn(codec,
-					AFE_SLIMBUS_SLAVE_PORT_CONFIG);
-		if (config) {
-			rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
-					    config, SLIMBUS_5_TX);
-			if (rc)
-				pr_err("%s: Failed to set slimbus slave port config %d\n",
-					__func__, rc);
-		}
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[SLIM_RX_7].bit_format);
-		rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
-		channels->min = channels->max =
-			slim_rx_cfg[SLIM_RX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_8_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_8].channels;
-		break;
-
-	case MSM_BACKEND_DAI_USB_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_rx_cfg.bit_format);
-		rate->min = rate->max = usb_rx_cfg.sample_rate;
-		channels->min = channels->max = usb_rx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_USB_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_tx_cfg.bit_format);
-		rate->min = rate->max = usb_tx_cfg.sample_rate;
-		channels->min = channels->max = usb_tx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_HDMI_RX:
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
-		if (idx < 0) {
-			pr_err("%s: Incorrect ext disp idx %d\n",
-			       __func__, idx);
-			rc = idx;
-			goto done;
-		}
-
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				ext_disp_rx_cfg[idx].bit_format);
-		rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AFE_PCM_RX:
-		channels->min = channels->max = proxy_rx_cfg.channels;
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[PRIM_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[PRIM_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[PRIM_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[PRIM_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[SEC_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[SEC_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[SEC_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[SEC_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[TERT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[TERT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[TERT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[TERT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[QUAT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[QUAT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[QUAT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[QUAT_MI2S].channels;
-		break;
-
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-done:
-	return rc;
-}
-
-static bool msm_swap_gnd_mic(struct snd_soc_codec *codec)
-{
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-	int value = 0;
-
-	if (pdata->us_euro_gpio_p) {
-		value = msm_cdc_pinctrl_get_state(pdata->us_euro_gpio_p);
-		if (value)
-			msm_cdc_pinctrl_select_sleep_state(
-							pdata->us_euro_gpio_p);
-		else
-			msm_cdc_pinctrl_select_active_state(
-							pdata->us_euro_gpio_p);
-	} else if (pdata->us_euro_gpio >= 0) {
-		value = gpio_get_value_cansleep(pdata->us_euro_gpio);
-		gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
-	}
-	pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
-	return true;
-}
-
-static int msm_afe_set_config(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	void *config_data = NULL;
-
-	if (!msm_codec_fn.get_afe_config_fn) {
-		dev_err(codec->dev, "%s: codec get afe config not init'ed\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTERS_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
-		if (ret) {
-			dev_err(codec->dev,
-				"%s: Failed to set codec registers config %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTER_PAGE_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
-				    0);
-		if (ret)
-			dev_err(codec->dev,
-				"%s: Failed to set cdc register page config\n",
-				__func__);
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_SLIMBUS_SLAVE_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
-		if (ret) {
-			dev_err(codec->dev,
-				"%s: Failed to set slimbus slave config %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static void msm_afe_clear_config(void)
-{
-	afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
-	afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
-}
-
-static int msm_adsp_power_up_config(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	unsigned long timeout;
-	int adsp_ready = 0;
-
-	timeout = jiffies +
-		msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
-
-	do {
-		if (q6core_is_adsp_ready()) {
-			pr_debug("%s: ADSP Audio is ready\n", __func__);
-			adsp_ready = 1;
-			break;
-		}
-		/*
-		 * ADSP will be coming up after subsystem restart and
-		 * it might not be fully up when the control reaches
-		 * here. So, wait for 50msec before checking ADSP state
-		 */
-		msleep(50);
-	} while (time_after(timeout, jiffies));
-
-	if (!adsp_ready) {
-		pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
-		ret = -ETIMEDOUT;
-		goto err_fail;
-	}
-
-	ret = msm_afe_set_config(codec);
-	if (ret)
-		pr_err("%s: Failed to set AFE config. err %d\n",
-			__func__, ret);
-
-	return 0;
-
-err_fail:
-	return ret;
-}
-
-static int msm8998_notifier_service_cb(struct notifier_block *this,
-					 unsigned long opcode, void *ptr)
-{
-	int ret;
-	struct snd_soc_card *card = NULL;
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_soc_codec *codec;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		/*
-		 * Use flag to ignore initial boot notifications
-		 * On initial boot msm_adsp_power_up_config is
-		 * called on init. There is no need to clear
-		 * and set the config again on initial boot.
-		 */
-		if (is_initial_boot)
-			break;
-		msm_afe_clear_config();
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (is_initial_boot) {
-			is_initial_boot = false;
-			break;
-		}
-		if (!spdev)
-			return -EINVAL;
-
-		card = platform_get_drvdata(spdev);
-		rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-		if (!rtd) {
-			dev_err(card->dev,
-				"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-				__func__, be_dl_name);
-			ret = -EINVAL;
-			goto done;
-		}
-		codec = rtd->codec;
-
-		ret = msm_adsp_power_up_config(codec);
-		if (ret < 0) {
-			dev_err(card->dev,
-				"%s: msm_adsp_power_up_config failed ret = %d!\n",
-				__func__, ret);
-			goto done;
-		}
-		break;
-	default:
-		break;
-	}
-done:
-	return NOTIFY_OK;
-}
-
-static struct notifier_block service_nb = {
-	.notifier_call  = msm8998_notifier_service_cb,
-	.priority = -INT_MAX,
-};
-
-static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	void *config_data;
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_component *aux_comp;
-	struct snd_card *card;
-	struct snd_info_entry *entry;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(rtd->card);
-
-	/* Codec SLIMBUS configuration
-	 * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
-	 * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
-	 * TX14, TX15, TX16
-	 */
-	unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
-					    151, 152, 153, 154, 155, 156};
-	unsigned int tx_ch[TASHA_TX_MAX] = {128, 129, 130, 131, 132, 133,
-					    134, 135, 136, 137, 138, 139,
-					    140, 141, 142, 143};
-
-	/* Tavil Codec SLIMBUS configuration
-	 * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
-	 * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
-	 * TX14, TX15, TX16
-	 */
-	unsigned int rx_ch_tavil[WCD934X_RX_MAX] = {144, 145, 146, 147, 148,
-						    149, 150, 151};
-	unsigned int tx_ch_tavil[WCD934X_TX_MAX] = {128, 129, 130, 131, 132,
-						    133, 134, 135, 136, 137,
-						    138, 139, 140, 141, 142,
-						    143};
-
-	pr_info("%s: dev_name%s\n", __func__, dev_name(cpu_dai->dev));
-
-	rtd->pmdown_time = 0;
-
-	ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
-					 ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		pr_err("%s: add_codec_controls failed, err %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
-				ARRAY_SIZE(msm_dapm_widgets));
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec"))
-		snd_soc_dapm_add_routes(dapm, wcd_audio_paths_tasha,
-					ARRAY_SIZE(wcd_audio_paths_tasha));
-	else
-		snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
-					ARRAY_SIZE(wcd_audio_paths));
-
-	snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic6");
-	snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT2");
-	snd_soc_dapm_ignore_suspend(dapm, "EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHL");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHR");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
-	snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
-		snd_soc_dapm_ignore_suspend(dapm, "LINEOUT3");
-		snd_soc_dapm_ignore_suspend(dapm, "LINEOUT4");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT1");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT2");
-	}
-
-	snd_soc_dapm_sync(dapm);
-
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch_tavil),
-					tx_ch_tavil, ARRAY_SIZE(rx_ch_tavil),
-					rx_ch_tavil);
-	} else {
-		snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					tx_ch, ARRAY_SIZE(rx_ch),
-					rx_ch);
-	}
-
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
-	} else {
-		msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
-		msm_codec_fn.mbhc_hs_detect_exit = tasha_mbhc_hs_detect_exit;
-	}
-
-	ret = msm_adsp_power_up_config(codec);
-	if (ret) {
-		pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
-		goto err_afe_cfg;
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-						     AFE_AANC_VERSION);
-	if (config_data) {
-		ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
-		if (ret) {
-			pr_err("%s: Failed to set aanc version %d\n",
-				__func__, ret);
-			goto err_afe_cfg;
-		}
-	}
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
-		config_data = msm_codec_fn.get_afe_config_fn(codec,
-						AFE_CDC_CLIP_REGISTERS_CONFIG);
-		if (config_data) {
-			ret = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
-						 config_data, 0);
-			if (ret) {
-				pr_err("%s: Failed to set clip registers %d\n",
-					__func__, ret);
-				goto err_afe_cfg;
-			}
-		}
-		config_data = msm_codec_fn.get_afe_config_fn(codec,
-				AFE_CLIP_BANK_SEL);
-		if (config_data) {
-			ret = afe_set_config(AFE_CLIP_BANK_SEL, config_data, 0);
-			if (ret) {
-				pr_err("%s: Failed to set AFE bank selection %d\n",
-					__func__, ret);
-				goto err_afe_cfg;
-			}
-		}
-	}
-
-	/*
-	 * Send speaker configuration only for WSA8810.
-	 * Defalut configuration is for WSA8815.
-	 */
-	pr_debug("%s: Number of aux devices: %d\n",
-		__func__, rtd->card->num_aux_devs);
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		if (rtd->card->num_aux_devs &&
-		    !list_empty(&rtd->card->aux_comp_list)) {
-			aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-					struct snd_soc_component, list_aux);
-			if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-			    !strcmp(aux_comp->name, WSA8810_NAME_2)) {
-				tavil_set_spkr_mode(rtd->codec,
-						    WCD934X_SPKR_MODE_1);
-				tavil_set_spkr_gain_offset(rtd->codec,
-						WCD934X_RX_GAIN_OFFSET_M1P5_DB);
-			}
-		}
-		card = rtd->card->snd_card;
-		entry = snd_info_create_subdir(card->module, "codecs",
-						 card->proc_root);
-		if (!entry) {
-			pr_debug("%s: Cannot create codecs module entry\n",
-				 __func__);
-			pdata->codec_root = NULL;
-			goto done;
-		}
-		pdata->codec_root = entry;
-		tavil_codec_info_create_codec_entry(pdata->codec_root, codec);
-	} else {
-		if (rtd->card->num_aux_devs &&
-		    !list_empty(&rtd->card->aux_comp_list)) {
-			aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-					struct snd_soc_component, list_aux);
-			if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-			    !strcmp(aux_comp->name, WSA8810_NAME_2)) {
-				tasha_set_spkr_mode(rtd->codec, SPKR_MODE_1);
-				tasha_set_spkr_gain_offset(rtd->codec,
-							RX_GAIN_OFFSET_M1P5_DB);
-			}
-		}
-		card = rtd->card->snd_card;
-		entry = snd_info_create_subdir(card->module, "codecs",
-						 card->proc_root);
-		if (!entry) {
-			pr_debug("%s: Cannot create codecs module entry\n",
-				 __func__);
-			ret = 0;
-			goto err_snd_module;
-		}
-		pdata->codec_root = entry;
-		tasha_codec_info_create_codec_entry(pdata->codec_root, codec);
-	}
-done:
-	codec_reg_done = true;
-	return 0;
-
-err_snd_module:
-err_afe_cfg:
-	return ret;
-}
-
-static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
-{
-	unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
-	unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX]  = {159, 160, 161};
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-
-	return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					   tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
-}
-
-static void *def_tasha_mbhc_cal(void)
-{
-	void *tasha_wcd_cal;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	u16 *btn_high;
-
-	tasha_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
-				WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
-	if (!tasha_wcd_cal)
-		return NULL;
-
-#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(tasha_wcd_cal)->X) = (Y))
-	S(v_hs_max, 1600);
-#undef S
-#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(tasha_wcd_cal)->X) = (Y))
-	S(num_btn, WCD_MBHC_DEF_BUTTONS);
-#undef S
-
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(tasha_wcd_cal);
-	btn_high = ((void *)&btn_cfg->_v_btn_low) +
-		(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
-
-	btn_high[0] = 75;
-	btn_high[1] = 150;
-	btn_high[2] = 237;
-	btn_high[3] = 500;
-	btn_high[4] = 500;
-	btn_high[5] = 500;
-	btn_high[6] = 500;
-	btn_high[7] = 500;
-
-	return tasha_wcd_cal;
-}
-
-static void *def_tavil_mbhc_cal(void)
-{
-	void *tavil_wcd_cal;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	u16 *btn_high;
-
-	tavil_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
-				WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
-	if (!tavil_wcd_cal)
-		return NULL;
-
-#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(tavil_wcd_cal)->X) = (Y))
-	S(v_hs_max, 1600);
-#undef S
-#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal)->X) = (Y))
-	S(num_btn, WCD_MBHC_DEF_BUTTONS);
-#undef S
-
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal);
-	btn_high = ((void *)&btn_cfg->_v_btn_low) +
-		(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
-
-	btn_high[0] = 75;
-	btn_high[1] = 150;
-	btn_high[2] = 237;
-	btn_high[3] = 500;
-	btn_high[4] = 500;
-	btn_high[5] = 500;
-	btn_high[6] = 500;
-	btn_high[7] = 500;
-
-	return tavil_wcd_cal;
-}
-
-static int msm_snd_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
-	int ret = 0;
-	u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	u32 user_set_tx_ch = 0;
-	u32 rx_ch_count;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
-			pr_debug("%s: rx_5_ch=%d\n", __func__,
-				  slim_rx_cfg[5].channels);
-			rx_ch_count = slim_rx_cfg[5].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
-			pr_debug("%s: rx_2_ch=%d\n", __func__,
-				 slim_rx_cfg[2].channels);
-			rx_ch_count = slim_rx_cfg[2].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
-			pr_debug("%s: rx_6_ch=%d\n", __func__,
-				  slim_rx_cfg[6].channels);
-			rx_ch_count = slim_rx_cfg[6].channels;
-		} else {
-			pr_debug("%s: rx_0_ch=%d\n", __func__,
-				  slim_rx_cfg[0].channels);
-			rx_ch_count = slim_rx_cfg[0].channels;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-						  rx_ch_count, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-	} else {
-
-		pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
-			 codec_dai->name, codec_dai->id, user_set_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map\n, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		/* For <codec>_tx1 case */
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
-			user_set_tx_ch = slim_tx_cfg[0].channels;
-		/* For <codec>_tx3 case */
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
-			user_set_tx_ch = slim_tx_cfg[1].channels;
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
-			user_set_tx_ch = msm_vi_feed_tx_ch;
-		else
-			user_set_tx_ch = tx_ch_cnt;
-
-		pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
-			 __func__,  slim_tx_cfg[0].channels, user_set_tx_ch,
-			 tx_ch_cnt, dai_link->id);
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-						  user_set_tx_ch, tx_ch, 0, 0);
-		if (ret < 0)
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-	}
-
-err_ch_map:
-	return ret;
-}
-
-static int msm_snd_cpe_hw_params(struct snd_pcm_substream *substream,
-				 struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
-	int ret = 0;
-	u32 tx_ch[SLIM_MAX_TX_PORTS];
-	u32 tx_ch_cnt = 0;
-	u32 user_set_tx_ch = 0;
-
-	if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) {
-		pr_err("%s: Invalid stream type %d\n",
-			__func__, substream->stream);
-		ret = -EINVAL;
-		goto err_stream_type;
-	}
-
-	pr_debug("%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, NULL, NULL);
-	if (ret < 0) {
-		pr_err("%s: failed to get codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto err_ch_map;
-	}
-
-	user_set_tx_ch = tx_ch_cnt;
-
-	pr_debug("%s: tx_ch_cnt(%d) BE id %d\n",
-		 __func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  user_set_tx_ch, tx_ch, 0, 0);
-	if (ret < 0)
-		pr_err("%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-err_ch_map:
-err_stream_type:
-	return ret;
-}
-
-static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream,
-					  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
-	unsigned int num_tx_ch = 0;
-	unsigned int num_rx_ch = 0;
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		num_rx_ch =  params_channels(params);
-		pr_debug("%s: %s rx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_rx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-				num_rx_ch, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-	} else {
-		num_tx_ch =  params_channels(params);
-		pr_debug("%s: %s  tx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-				num_tx_ch, tx_ch, 0, 0);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-	}
-
-err_ch_map:
-	return ret;
-}
-
-static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	int ret;
-
-	dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-	if (ret) {
-		dev_err(rtd->dev,
-			"%s: failed to get BTFM codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto exit;
-	}
-
-	dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
-		__func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
-	if (ret)
-		dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-
-exit:
-	return ret;
-}
-
-static int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int index = cpu_dai->id - 1;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		cpu_dai->name, cpu_dai->id);
-
-	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
-		ret = -EINVAL;
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, cpu_dai->id);
-		goto done;
-	}
-
-	mutex_lock(&auxpcm_intf_conf[index].lock);
-	if (++auxpcm_intf_conf[index].ref_cnt == 1) {
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(1,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
-				__func__);
-			ret = -EINVAL;
-		}
-	}
-	if (ret < 0)
-		auxpcm_intf_conf[index].ref_cnt--;
-
-	mutex_unlock(&auxpcm_intf_conf[index].lock);
-
-done:
-	return ret;
-}
-
-static void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int index = rtd->cpu_dai->id - 1;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__,
-		substream->name, substream->stream,
-		rtd->cpu_dai->name, rtd->cpu_dai->id);
-
-	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, rtd->cpu_dai->id);
-		return;
-	}
-
-	mutex_lock(&auxpcm_intf_conf[index].lock);
-	if (--auxpcm_intf_conf[index].ref_cnt == 0) {
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(0,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
-				__func__);
-		}
-	}
-	mutex_unlock(&auxpcm_intf_conf[index].lock);
-}
-
-static int msm_get_port_id(int be_id)
-{
-	int afe_port_id;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	default:
-		pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
-		afe_port_id = -EINVAL;
-	}
-
-	return afe_port_id;
-}
-
-static u32 get_mi2s_bits_per_sample(u32 bit_format)
-{
-	u32 bit_per_sample;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bit_per_sample = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bit_per_sample = 16;
-		break;
-	}
-
-	return bit_per_sample;
-}
-
-static void update_mi2s_clk_val(int dai_id, int stream)
-{
-	u32 bit_per_sample;
-
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	} else {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	}
-}
-
-static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int port_id = 0;
-	int index = cpu_dai->id;
-
-	port_id = msm_get_port_id(rtd->dai_link->id);
-	if (port_id < 0) {
-		dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
-		ret = port_id;
-		goto done;
-	}
-
-	if (enable) {
-		update_mi2s_clk_val(index, substream->stream);
-		dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
-			mi2s_clk[index].clk_freq_in_hz);
-	}
-
-	mi2s_clk[index].enable = enable;
-	ret = afe_set_lpass_clock_v2(port_id,
-				     &mi2s_clk[index]);
-	if (ret < 0) {
-		dev_err(rtd->card->dev,
-			"%s: afe lpass clock failed for port 0x%x , err:%d\n",
-			__func__, port_id, ret);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_set_pinctrl(struct msm_pinctrl_info *pinctrl_info,
-				enum pinctrl_pin_state new_state)
-{
-	int ret = 0;
-	int curr_state = 0;
-
-	if (pinctrl_info == NULL) {
-		pr_err("%s: pinctrl_info is NULL\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	if (pinctrl_info->pinctrl == NULL) {
-		pr_err("%s: pinctrl_info->pinctrl is NULL\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	curr_state = pinctrl_info->curr_state;
-	pinctrl_info->curr_state = new_state;
-	pr_debug("%s: curr_state = %s new_state = %s\n", __func__,
-		 pin_states[curr_state], pin_states[pinctrl_info->curr_state]);
-
-	if (curr_state == pinctrl_info->curr_state) {
-		pr_debug("%s: Already in same state\n", __func__);
-		goto err;
-	}
-
-	if (curr_state != STATE_DISABLE &&
-		pinctrl_info->curr_state != STATE_DISABLE) {
-		pr_debug("%s: state already active cannot switch\n", __func__);
-		ret = -EIO;
-		goto err;
-	}
-
-	switch (pinctrl_info->curr_state) {
-	case STATE_MI2S_ACTIVE:
-		ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_active);
-		if (ret) {
-			pr_err("%s: MI2S state select failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	case STATE_TDM_ACTIVE:
-		ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->tdm_active);
-		if (ret) {
-			pr_err("%s: TDM state select failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	case STATE_DISABLE:
-		if (curr_state == STATE_MI2S_ACTIVE) {
-			ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_disable);
-		} else {
-			ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->tdm_disable);
-		}
-		if (ret) {
-			pr_err("%s:  state disable failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	default:
-		pr_err("%s: TLMM pin state is invalid\n", __func__);
-		return -EINVAL;
-	}
-
-err:
-	return ret;
-}
-
-static void msm_release_pinctrl(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	if (pinctrl_info->pinctrl) {
-		devm_pinctrl_put(pinctrl_info->pinctrl);
-		pinctrl_info->pinctrl = NULL;
-	}
-}
-
-static int msm_get_pinctrl(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = NULL;
-	struct pinctrl *pinctrl;
-	int ret;
-
-	pinctrl_info = &pdata->pinctrl_info;
-
-	if (pinctrl_info == NULL) {
-		pr_err("%s: pinctrl_info is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pinctrl = devm_pinctrl_get(&pdev->dev);
-	if (IS_ERR_OR_NULL(pinctrl)) {
-		pr_err("%s: Unable to get pinctrl handle\n", __func__);
-		return -EINVAL;
-	}
-	pinctrl_info->pinctrl = pinctrl;
-
-	/* get all the states handles from Device Tree */
-	pinctrl_info->mi2s_disable = pinctrl_lookup_state(pinctrl,
-						"quat-mi2s-sleep");
-	if (IS_ERR(pinctrl_info->mi2s_disable)) {
-		pr_err("%s: could not get mi2s_disable pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->mi2s_active = pinctrl_lookup_state(pinctrl,
-						"quat-mi2s-active");
-	if (IS_ERR(pinctrl_info->mi2s_active)) {
-		pr_err("%s: could not get mi2s_active pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->tdm_disable = pinctrl_lookup_state(pinctrl,
-						"quat-tdm-sleep");
-	if (IS_ERR(pinctrl_info->tdm_disable)) {
-		pr_err("%s: could not get tdm_disable pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->tdm_active = pinctrl_lookup_state(pinctrl,
-						"quat-tdm-active");
-	if (IS_ERR(pinctrl_info->tdm_active)) {
-		pr_err("%s: could not get tdm_active pinstate\n",
-			__func__);
-		goto err;
-	}
-	/* Reset the TLMM pins to a default state */
-	ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_disable);
-	if (ret != 0) {
-		pr_err("%s: Disable TLMM pins failed with %d\n",
-			__func__, ret);
-		ret = -EIO;
-		goto err;
-	}
-	pinctrl_info->curr_state = STATE_DISABLE;
-
-	return 0;
-
-err:
-	devm_pinctrl_put(pinctrl);
-	pinctrl_info->pinctrl = NULL;
-	return -EINVAL;
-}
-
-static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				      struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	if (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) {
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
-	} else if (cpu_dai->id == AFE_PORT_ID_SECONDARY_TDM_RX) {
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
-	} else {
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
-		__func__, cpu_dai->id, channels->max, rate->max,
-		params_format(params));
-
-	return 0;
-}
-
-static int msm8998_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	slots = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-	/*2 slot config - bits 0 and 1 set for the first two slots */
-	slot_mask = 0x0000FFFF >> (16-slots);
-	slot_width = 32;
-	channels = slots;
-
-	pr_debug("%s: slot_width %d slots %d\n", __func__, slot_width, slots);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		pr_debug("%s: slot_width %d\n", __func__, slot_width);
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-			slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-			0, NULL, channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		pr_err("%s: invalid use case, err:%d\n",
-			__func__, ret);
-	}
-
-end:
-	return ret;
-}
-
-static int msm8998_tdm_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	ret = msm_set_pinctrl(pinctrl_info, STATE_TDM_ACTIVE);
-	if (ret)
-		pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static void msm8998_tdm_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	ret = msm_set_pinctrl(pinctrl_info, STATE_DISABLE);
-	if (ret)
-		pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-			__func__, ret);
-
-}
-
-static struct snd_soc_ops msm8998_tdm_be_ops = {
-	.hw_params = msm8998_tdm_snd_hw_params,
-	.startup = msm8998_tdm_snd_startup,
-	.shutdown = msm8998_tdm_snd_shutdown
-};
-
-static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int index = cpu_dai->id;
-	unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-	int ret_pinctrl = 0;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		cpu_dai->name, cpu_dai->id);
-
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		ret = -EINVAL;
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, cpu_dai->id);
-		goto done;
-	}
-	if (index == QUAT_MI2S) {
-		ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_MI2S_ACTIVE);
-		if (ret_pinctrl) {
-			pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-				__func__, ret_pinctrl);
-		}
-	}
-
-	/*
-	 * Muxtex protection in case the same MI2S
-	 * interface using for both TX and RX  so
-	 * that the same clock won't be enable twice.
-	 */
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (++mi2s_intf_conf[index].ref_cnt == 1) {
-		ret = msm_mi2s_set_sclk(substream, true);
-		if (ret < 0) {
-			dev_err(rtd->card->dev,
-				"%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
-				__func__, ret);
-			goto clean_up;
-		}
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(0,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_muxsel_virt_addr is NULL for dai %d\n",
-				__func__, index);
-			ret = -EINVAL;
-			goto clk_off;
-		}
-		/* Check if msm needs to provide the clock to the interface */
-		if (!mi2s_intf_conf[index].msm_is_mi2s_master)
-			fmt = SND_SOC_DAIFMT_CBM_CFM;
-		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
-		if (ret < 0) {
-			pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
-				__func__, index, ret);
-			goto clk_off;
-		}
-	}
-clk_off:
-	if (ret < 0)
-		msm_mi2s_set_sclk(substream, false);
-clean_up:
-	if (ret < 0)
-		mi2s_intf_conf[index].ref_cnt--;
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-done:
-	return ret;
-}
-
-static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int index = rtd->cpu_dai->id;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-	int ret_pinctrl = 0;
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
-		return;
-	}
-
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (--mi2s_intf_conf[index].ref_cnt == 0) {
-		ret = msm_mi2s_set_sclk(substream, false);
-		if (ret < 0)
-			pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
-				__func__, index, ret);
-	}
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-
-	if (index == QUAT_MI2S) {
-		ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_DISABLE);
-		if (ret_pinctrl)
-			pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-				__func__, ret_pinctrl);
-	}
-}
-
-static struct snd_soc_ops msm_mi2s_be_ops = {
-	.startup = msm_mi2s_snd_startup,
-	.shutdown = msm_mi2s_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_aux_pcm_be_ops = {
-	.startup = msm_aux_pcm_snd_startup,
-	.shutdown = msm_aux_pcm_snd_shutdown,
-};
-
-static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width,
-					    int slots)
-{
-	unsigned int slot_mask = 0;
-	int i, j;
-	unsigned int *slot_offset;
-
-	for (i = TDM_0; i < TDM_PORT_MAX; i++) {
-		slot_offset = tdm_slot_offset[i];
-
-		for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) {
-			if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-				slot_mask |=
-				(1 << ((slot_offset[j] * 8) / slot_width));
-			else
-				break;
-		}
-	}
-
-	return slot_mask;
-}
-
-static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int *slot_offset;
-	int offset_channels = 0;
-	int i;
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	channels = params_channels(params);
-	switch (channels) {
-	case 1:
-	case 2:
-	case 3:
-	case 4:
-	case 5:
-	case 6:
-	case 7:
-	case 8:
-		switch (params_format(params)) {
-		case SNDRV_PCM_FORMAT_S32_LE:
-		case SNDRV_PCM_FORMAT_S24_LE:
-		case SNDRV_PCM_FORMAT_S16_LE:
-		/*
-		 * up to 8 channels HW config should
-		 * use 32 bit slot width for max support of
-		 * stream bit width. (slot_width > bit_width)
-		 */
-			slot_width = 32;
-			break;
-		default:
-			pr_err("%s: invalid param format 0x%x\n",
-				__func__, params_format(params));
-			return -EINVAL;
-		}
-		slots = 8;
-		slot_mask = tdm_param_set_slot_mask(cpu_dai->id,
-						    slot_width,
-						    slots);
-		if (!slot_mask) {
-			pr_err("%s: invalid slot_mask 0x%x\n",
-				__func__, slot_mask);
-			return -EINVAL;
-		}
-		break;
-	default:
-		pr_err("%s: invalid param channels %d\n",
-			__func__, channels);
-		return -EINVAL;
-	}
-	/* currently only supporting TDM_RX_0 and TDM_TX_0 */
-	switch (cpu_dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		slot_offset = tdm_slot_offset[TDM_0];
-		break;
-	default:
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
-		if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-			offset_channels++;
-		else
-			break;
-	}
-
-	if (offset_channels == 0) {
-		pr_err("%s: slot offset not supported, offset_channels %d\n",
-			__func__, offset_channels);
-		return -EINVAL;
-	}
-
-	if (channels > offset_channels) {
-		pr_err("%s: channels %d exceed offset_channels %d\n",
-			__func__, channels, offset_channels);
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
-						  channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
-						  slot_offset, 0, NULL);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	}
-end:
-	return ret;
-}
-
-static struct snd_soc_ops msm_be_ops = {
-	.hw_params = msm_snd_hw_params,
-};
-
-static struct snd_soc_ops msm_cpe_ops = {
-	.hw_params = msm_snd_cpe_hw_params,
-};
-
-static struct snd_soc_ops msm_slimbus_2_be_ops = {
-	.hw_params = msm_slimbus_2_hw_params,
-};
-
-static struct snd_soc_ops msm_wcn_ops = {
-	.hw_params = msm_wcn_hw_params,
-};
-
-static struct snd_soc_ops msm_tdm_be_ops = {
-	.hw_params = msm_tdm_snd_hw_params
-};
-
-/* Digital audio interface glue - connects codec <---> CPU */
-static struct snd_soc_dai_link msm_common_dai_links[] = {
-	/* FrontEnd DAI Links */
-	{
-		.name = MSM_DAILINK_NAME(Media1),
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name = "MultiMedia1",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-	{
-		.name = MSM_DAILINK_NAME(Media2),
-		.stream_name = "MultiMedia2",
-		.cpu_dai_name = "MultiMedia2",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA2,
-	},
-	{
-		.name = "VoiceMMode1",
-		.stream_name = "VoiceMMode1",
-		.cpu_dai_name = "VoiceMMode1",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE1,
-	},
-	{
-		.name = "MSM VoIP",
-		.stream_name = "VoIP",
-		.cpu_dai_name = "VoIP",
-		.platform_name = "msm-voip-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_VOIP,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL),
-		.stream_name = "MultiMedia3",
-		.cpu_dai_name = "MultiMedia3",
-		.platform_name = "msm-pcm-dsp.2",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA3,
-	},
-	/* Hostless PCM purpose */
-	{
-		.name = "SLIMBUS_0 Hostless",
-		.stream_name = "SLIMBUS_0 Hostless",
-		.cpu_dai_name = "SLIMBUS0_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "MSM AFE-PCM RX",
-		.stream_name = "AFE-PROXY RX",
-		.cpu_dai_name = "msm-dai-q6-dev.241",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.platform_name = "msm-pcm-afe",
-		.dpcm_playback = 1,
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = "MSM AFE-PCM TX",
-		.stream_name = "AFE-PROXY TX",
-		.cpu_dai_name = "msm-dai-q6-dev.240",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.platform_name  = "msm-pcm-afe",
-		.dpcm_capture = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress1),
-		.stream_name = "Compress1",
-		.cpu_dai_name = "MultiMedia4",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA4,
-	},
-	{
-		.name = "AUXPCM Hostless",
-		.stream_name = "AUXPCM Hostless",
-		.cpu_dai_name = "AUXPCM_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_1 Hostless",
-		.stream_name = "SLIMBUS_1 Hostless",
-		.cpu_dai_name = "SLIMBUS1_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_3 Hostless",
-		.stream_name = "SLIMBUS_3 Hostless",
-		.cpu_dai_name = "SLIMBUS3_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_4 Hostless",
-		.stream_name = "SLIMBUS_4 Hostless",
-		.cpu_dai_name = "SLIMBUS4_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = MSM_DAILINK_NAME(LowLatency),
-		.stream_name = "MultiMedia5",
-		.cpu_dai_name = "MultiMedia5",
-		.platform_name = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA5,
-	},
-	{
-		.name = "Listen 1 Audio Service",
-		.stream_name = "Listen 1 Audio Service",
-		.cpu_dai_name = "LSM1",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-			     SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM1,
-	},
-	/* Multiple Tunnel instances */
-	{
-		.name = MSM_DAILINK_NAME(Compress2),
-		.stream_name = "Compress2",
-		.cpu_dai_name = "MultiMedia7",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA7,
-	},
-	{
-		.name = MSM_DAILINK_NAME(MultiMedia10),
-		.stream_name = "MultiMedia10",
-		.cpu_dai_name = "MultiMedia10",
-		.platform_name = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA10,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ),
-		.stream_name = "MM_NOIRQ",
-		.cpu_dai_name = "MultiMedia8",
-		.platform_name = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA8,
-	},
-	/* HDMI Hostless */
-	{
-		.name = "HDMI_RX_HOSTLESS",
-		.stream_name = "HDMI_RX_HOSTLESS",
-		.cpu_dai_name = "HDMI_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "VoiceMMode2",
-		.stream_name = "VoiceMMode2",
-		.cpu_dai_name = "VoiceMMode2",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE2,
-	},
-	/* LSM FE */
-	{
-		.name = "Listen 2 Audio Service",
-		.stream_name = "Listen 2 Audio Service",
-		.cpu_dai_name = "LSM2",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM2,
-	},
-	{
-		.name = "Listen 3 Audio Service",
-		.stream_name = "Listen 3 Audio Service",
-		.cpu_dai_name = "LSM3",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM3,
-	},
-	{
-		.name = "Listen 4 Audio Service",
-		.stream_name = "Listen 4 Audio Service",
-		.cpu_dai_name = "LSM4",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM4,
-	},
-	{
-		.name = "Listen 5 Audio Service",
-		.stream_name = "Listen 5 Audio Service",
-		.cpu_dai_name = "LSM5",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM5,
-	},
-	{
-		.name = "Listen 6 Audio Service",
-		.stream_name = "Listen 6 Audio Service",
-		.cpu_dai_name = "LSM6",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM6,
-	},
-	{
-		.name = "Listen 7 Audio Service",
-		.stream_name = "Listen 7 Audio Service",
-		.cpu_dai_name = "LSM7",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM7,
-	},
-	{
-		.name = "Listen 8 Audio Service",
-		.stream_name = "Listen 8 Audio Service",
-		.cpu_dai_name = "LSM8",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM8,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Media9),
-		.stream_name = "MultiMedia9",
-		.cpu_dai_name = "MultiMedia9",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA9,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress4),
-		.stream_name = "Compress4",
-		.cpu_dai_name = "MultiMedia11",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA11,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress5),
-		.stream_name = "Compress5",
-		.cpu_dai_name = "MultiMedia12",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA12,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress6),
-		.stream_name = "Compress6",
-		.cpu_dai_name = "MultiMedia13",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA13,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress7),
-		.stream_name = "Compress7",
-		.cpu_dai_name = "MultiMedia14",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA14,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress8),
-		.stream_name = "Compress8",
-		.cpu_dai_name = "MultiMedia15",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA15,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
-		.stream_name = "MM_NOIRQ_2",
-		.cpu_dai_name = "MultiMedia16",
-		.platform_name = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA16,
-	},
-	{
-		.name = "SLIMBUS_8 Hostless",
-		.stream_name = "SLIMBUS8_HOSTLESS Capture",
-		.cpu_dai_name = "SLIMBUS8_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-};
-
-static struct snd_soc_dai_link msm_tasha_fe_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_4_TX,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-	},
-	/* Ultrasound RX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Playback",
-		.stream_name = "SLIMBUS_2 Hostless Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-	/* Ultrasound TX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Capture",
-		.stream_name = "SLIMBUS_2 Hostless Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16389",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-	/* CPE LSM direct dai-link */
-	{
-		.name = "CPE Listen service",
-		.stream_name = "CPE Listen Audio Service",
-		.cpu_dai_name = "msm-dai-slim",
-		.platform_name = "msm-cpe-lsm",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "tasha_mad1",
-		.codec_name = "tasha_codec",
-		.ops = &msm_cpe_ops,
-	},
-	{
-		.name = "SLIMBUS_6 Hostless Playback",
-		.stream_name = "SLIMBUS_6 Hostless",
-		.cpu_dai_name = "SLIMBUS6_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	/* CPE LSM EC PP direct dai-link */
-	{
-		.name = "CPE Listen service ECPP",
-		.stream_name = "CPE Listen Audio Service ECPP",
-		.cpu_dai_name = "CPE_LSM_NOHOST",
-		.platform_name = "msm-cpe-lsm.3",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "tasha_cpe",
-		.codec_name = "tasha_codec",
-	},
-};
-
-static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_4_TX,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-	},
-	/* Ultrasound RX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Playback",
-		.stream_name = "SLIMBUS_2 Hostless Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-	/* Ultrasound TX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Capture",
-		.stream_name = "SLIMBUS_2 Hostless Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16389",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
-	{
-		.name = MSM_DAILINK_NAME(ASM Loopback),
-		.stream_name = "MultiMedia6",
-		.cpu_dai_name = "MultiMedia6",
-		.platform_name = "msm-pcm-loopback",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_pmdown_time = 1,
-		.be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
-	},
-	{
-		.name = "USB Audio Hostless",
-		.stream_name = "USB Audio Hostless",
-		.cpu_dai_name = "USBAUDIO_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = MSM_DAILINK_NAME(Transcode Loopback Playback),
-		.stream_name = "Transcode Loopback Playback",
-		.cpu_dai_name = "MultiMedia14",
-		.platform_name = "msm-transcode-loopback",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA14,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Transcode Loopback Capture),
-		.stream_name = "Transcode Loopback Capture",
-		.cpu_dai_name = "MultiMedia18",
-		.platform_name = "msm-transcode-loopback",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA18,
-	},
-};
-
-static struct snd_soc_dai_link msm_common_be_dai_links[] = {
-	/* Backend AFE DAI Links */
-	{
-		.name = LPASS_BE_AFE_PCM_RX,
-		.stream_name = "AFE Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.224",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_AFE_PCM_TX,
-		.stream_name = "AFE Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.225",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Uplink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_TX,
-		.stream_name = "Voice Uplink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32772",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Downlink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_RX,
-		.stream_name = "Voice Downlink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32771",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE_PLAYBACK_TX,
-		.stream_name = "Voice Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32773",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music 2 BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE2_PLAYBACK_TX,
-		.stream_name = "Voice2 Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32770",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_RX,
-		.stream_name = "USB Audio Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.28672",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_USB_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_TX,
-		.stream_name = "USB Audio Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.28673",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_USB_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_RX_0,
-		.stream_name = "Primary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36864",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_TX_0,
-		.stream_name = "Primary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36865",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_RX_0,
-		.stream_name = "Secondary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36880",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_TX_0,
-		.stream_name = "Secondary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36881",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_RX_0,
-		.stream_name = "Tertiary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36896",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_TX_0,
-		.stream_name = "Tertiary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36897",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_RX_0,
-		.stream_name = "Quaternary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36912",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		.be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
-		.ops = &msm8998_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_TX_0,
-		.stream_name = "Quaternary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36913",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_tasha_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_RX,
-		.stream_name = "Slimbus1 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16386",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_TX,
-		.stream_name = "Slimbus1 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16387",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx3",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_RX,
-		.stream_name = "Slimbus3 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16390",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_TX,
-		.stream_name = "Slimbus3 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16391",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_4_RX,
-		.stream_name = "Slimbus4 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16392",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_5_RX,
-		.stream_name = "Slimbus5 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16394",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx3",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* MAD BE */
-	{
-		.name = LPASS_BE_SLIMBUS_5_TX,
-		.stream_name = "Slimbus5 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16395",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mad1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_6_RX,
-		.stream_name = "Slimbus6 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16396",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx4",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* Slimbus VI Recording */
-	{
-		.name = LPASS_BE_SLIMBUS_TX_VI,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_vifeedback",
-		.be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.ignore_pmdown_time = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_RX,
-		.stream_name = "Slimbus1 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16386",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_TX,
-		.stream_name = "Slimbus1 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16387",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx3",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_2_RX,
-		.stream_name = "Slimbus2 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_RX,
-		.stream_name = "Slimbus3 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16390",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_TX,
-		.stream_name = "Slimbus3 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16391",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_4_RX,
-		.stream_name = "Slimbus4 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16392",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_5_RX,
-		.stream_name = "Slimbus5 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16394",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx3",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* MAD BE */
-	{
-		.name = LPASS_BE_SLIMBUS_5_TX,
-		.stream_name = "Slimbus5 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16395",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_mad1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_6_RX,
-		.stream_name = "Slimbus6 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16396",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx4",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* Slimbus VI Recording */
-	{
-		.name = LPASS_BE_SLIMBUS_TX_VI,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_vifeedback",
-		.be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.ignore_pmdown_time = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_7_RX,
-		.stream_name = "Slimbus7 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16398",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		/* BT codec driver determines capabilities based on
-		 * dai name, bt codecdai name should always contains
-		 * supported usecase information
-		 */
-		.codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_7_TX,
-		.stream_name = "Slimbus7 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16399",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_bt_sco_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_8_TX,
-		.stream_name = "Slimbus8 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16401",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_fm_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.init = &msm_wcn_init,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
-	/* HDMI BACK END DAI Link */
-	{
-		.name = LPASS_BE_HDMI,
-		.stream_name = "HDMI Playback",
-		.cpu_dai_name = "msm-dai-q6-hdmi.8",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-ext-disp-audio-codec-rx",
-		.codec_dai_name = "msm_hdmi_audio_codec_rx_dai",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_HDMI_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* DISP PORT BACK END DAI Link */
-	{
-		.name = LPASS_BE_DISPLAY_PORT,
-		.stream_name = "Display Port Playback",
-		.cpu_dai_name = "msm-dai-q6-dp.24608",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-ext-disp-audio-codec-rx",
-		.codec_dai_name = "msm_dp_audio_codec_rx_dai",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
-	{
-		.name = LPASS_BE_PRI_MI2S_RX,
-		.stream_name = "Primary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_MI2S_TX,
-		.stream_name = "Primary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_RX,
-		.stream_name = "Secondary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_TX,
-		.stream_name = "Secondary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_RX,
-		.stream_name = "Tertiary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_TX,
-		.stream_name = "Tertiary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_RX,
-		.stream_name = "Quaternary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_TX,
-		.stream_name = "Quaternary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
-	/* Primary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_AUXPCM_RX,
-		.stream_name = "AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_AUXPCM_TX,
-		.stream_name = "AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Secondary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_SEC_AUXPCM_RX,
-		.stream_name = "Sec AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SEC_AUXPCM_TX,
-		.stream_name = "Sec AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Tertiary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_TERT_AUXPCM_RX,
-		.stream_name = "Tert AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_TERT_AUXPCM_TX,
-		.stream_name = "Tert AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Quaternary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_RX,
-		.stream_name = "Quat AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_TX,
-		.stream_name = "Quat AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_tasha_dai_links[
-			 ARRAY_SIZE(msm_common_dai_links) +
-			 ARRAY_SIZE(msm_tasha_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_misc_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_be_dai_links) +
-			 ARRAY_SIZE(msm_tasha_be_dai_links) +
-			 ARRAY_SIZE(msm_wcn_be_dai_links) +
-			 ARRAY_SIZE(ext_disp_be_dai_link) +
-			 ARRAY_SIZE(msm_mi2s_be_dai_links) +
-			 ARRAY_SIZE(msm_auxpcm_be_dai_links)];
-
-static struct snd_soc_dai_link msm_tavil_dai_links[
-			 ARRAY_SIZE(msm_common_dai_links) +
-			 ARRAY_SIZE(msm_tavil_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_misc_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_be_dai_links) +
-			 ARRAY_SIZE(msm_tavil_be_dai_links) +
-			 ARRAY_SIZE(msm_wcn_be_dai_links) +
-			 ARRAY_SIZE(ext_disp_be_dai_link) +
-			 ARRAY_SIZE(msm_mi2s_be_dai_links) +
-			 ARRAY_SIZE(msm_auxpcm_be_dai_links)];
-
-static int msm_snd_card_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-	void *mbhc_calibration;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		ret = -EINVAL;
-		goto err_pcm_runtime;
-	}
-
-	mbhc_calibration = def_tasha_mbhc_cal();
-	if (!mbhc_calibration) {
-		ret = -ENOMEM;
-		goto err_mbhc_cal;
-	}
-	wcd_mbhc_cfg.calibration = mbhc_calibration;
-	ret = tasha_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
-	if (ret) {
-		dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
-			__func__, ret);
-		goto err_hs_detect;
-	}
-	return 0;
-
-err_hs_detect:
-	kfree(mbhc_calibration);
-err_mbhc_cal:
-err_pcm_runtime:
-	return ret;
-}
-
-static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-	void *mbhc_calibration;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		ret = -EINVAL;
-		goto err_pcm_runtime;
-	}
-
-	mbhc_calibration = def_tavil_mbhc_cal();
-	if (!mbhc_calibration) {
-		ret = -ENOMEM;
-		goto err_mbhc_cal;
-	}
-	wcd_mbhc_cfg.calibration = mbhc_calibration;
-	ret = tavil_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
-	if (ret) {
-		dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
-			__func__, ret);
-		goto err_hs_detect;
-	}
-	return 0;
-
-err_hs_detect:
-	kfree(mbhc_calibration);
-err_mbhc_cal:
-err_pcm_runtime:
-	return ret;
-}
-
-struct snd_soc_card snd_soc_card_tasha_msm = {
-	.name		= "msm8998-tasha-snd-card",
-	.late_probe	= msm_snd_card_late_probe,
-};
-
-struct snd_soc_card snd_soc_card_tavil_msm = {
-	.name		= "msm8998-tavil-snd-card",
-	.late_probe	= msm_snd_card_tavil_late_probe,
-};
-
-static int msm_populate_dai_link_component_of_node(
-					struct snd_soc_card *card)
-{
-	int i, index, ret = 0;
-	struct device *cdev = card->dev;
-	struct snd_soc_dai_link *dai_link = card->dai_link;
-	struct device_node *np;
-
-	if (!cdev) {
-		pr_err("%s: Sound card device memory NULL\n", __func__);
-		return -ENODEV;
-	}
-
-	for (i = 0; i < card->num_links; i++) {
-		if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
-			continue;
-
-		/* populate platform_of_node for snd card dai links */
-		if (dai_link[i].platform_name &&
-		    !dai_link[i].platform_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						"asoc-platform-names",
-						dai_link[i].platform_name);
-			if (index < 0) {
-				pr_err("%s: No match found for platform name: %s\n",
-					__func__, dai_link[i].platform_name);
-				ret = index;
-				goto err;
-			}
-			np = of_parse_phandle(cdev->of_node, "asoc-platform",
-					      index);
-			if (!np) {
-				pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
-					__func__, dai_link[i].platform_name,
-					index);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].platform_of_node = np;
-			dai_link[i].platform_name = NULL;
-		}
-
-		/* populate cpu_of_node for snd card dai links */
-		if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						 "asoc-cpu-names",
-						 dai_link[i].cpu_dai_name);
-			if (index >= 0) {
-				np = of_parse_phandle(cdev->of_node, "asoc-cpu",
-						index);
-				if (!np) {
-					pr_err("%s: retrieving phandle for cpu dai %s failed\n",
-						__func__,
-						dai_link[i].cpu_dai_name);
-					ret = -ENODEV;
-					goto err;
-				}
-				dai_link[i].cpu_of_node = np;
-				dai_link[i].cpu_dai_name = NULL;
-			}
-		}
-
-		/* populate codec_of_node for snd card dai links */
-		if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						 "asoc-codec-names",
-						 dai_link[i].codec_name);
-			if (index < 0)
-				continue;
-			np = of_parse_phandle(cdev->of_node, "asoc-codec",
-					      index);
-			if (!np) {
-				pr_err("%s: retrieving phandle for codec %s failed\n",
-					__func__, dai_link[i].codec_name);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].codec_of_node = np;
-			dai_link[i].codec_name = NULL;
-		}
-	}
-
-err:
-	return ret;
-}
-
-static int msm_prepare_us_euro(struct snd_soc_card *card)
-{
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-	int ret = 0;
-
-	if (pdata->us_euro_gpio >= 0) {
-		dev_dbg(card->dev, "%s: us_euro gpio request %d", __func__,
-			pdata->us_euro_gpio);
-		ret = gpio_request(pdata->us_euro_gpio, "TASHA_CODEC_US_EURO");
-		if (ret) {
-			dev_err(card->dev,
-				"%s: Failed to request codec US/EURO gpio %d error %d\n",
-				__func__, pdata->us_euro_gpio, ret);
-		}
-	}
-
-	return ret;
-}
-
-static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
-	ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
-					 ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		dev_err(codec->dev, "%s: add_codec_controls failed, err%d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
-				ARRAY_SIZE(msm_dapm_widgets));
-
-	return 0;
-}
-
-static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-
-	int ret = 0;
-	unsigned int rx_ch[] = {144, 145, 146, 147, 148, 149, 150,
-				151, 152, 153, 154, 155, 156};
-	unsigned int tx_ch[] = {128, 129, 130, 131, 132, 133,
-				134, 135, 136, 137, 138, 139,
-				140, 141, 142, 143};
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-						  slim_rx_cfg[0].channels,
-						  rx_ch);
-		if (ret < 0)
-			pr_err("%s: RX failed to set cpu chan map error %d\n",
-				__func__, ret);
-	} else {
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-						  slim_tx_cfg[0].channels,
-						  tx_ch, 0, 0);
-		if (ret < 0)
-			pr_err("%s: TX failed to set cpu chan map error %d\n",
-				__func__, ret);
-	}
-
-	return ret;
-}
-
-static struct snd_soc_ops msm_stub_be_ops = {
-	.hw_params = msm_snd_stub_hw_params,
-};
-
-static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
-
-	/* FrontEnd DAI Links */
-	{
-		.name = "MSMSTUB Media1",
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name = "MultiMedia1",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-};
-
-static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
-
-	/* Backend DAI Links */
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_stub_init,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.ignore_suspend = 1,
-		.ops = &msm_stub_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_stub_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_stub_dai_links[
-			 ARRAY_SIZE(msm_stub_fe_dai_links) +
-			 ARRAY_SIZE(msm_stub_be_dai_links)];
-
-struct snd_soc_card snd_soc_card_stub_msm = {
-	.name		= "msm8998-stub-snd-card",
-};
-
-static const struct of_device_id msm8998_asoc_machine_of_match[]  = {
-	{ .compatible = "qcom,msm8998-asoc-snd-tasha",
-	  .data = "tasha_codec"},
-	{ .compatible = "qcom,msm8998-asoc-snd-tavil",
-	  .data = "tavil_codec"},
-	{ .compatible = "qcom,msm8998-asoc-snd-stub",
-	  .data = "stub_codec"},
-	{},
-};
-
-static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
-{
-	struct snd_soc_card *card = NULL;
-	struct snd_soc_dai_link *dailink;
-	int len_1, len_2, len_3, len_4;
-	int total_links;
-	const struct of_device_id *match;
-
-	match = of_match_node(msm8998_asoc_machine_of_match, dev->of_node);
-	if (!match) {
-		dev_err(dev, "%s: No DT match found for sound card\n",
-			__func__);
-		return NULL;
-	}
-
-	if (!strcmp(match->data, "tasha_codec")) {
-		card = &snd_soc_card_tasha_msm;
-		len_1 = ARRAY_SIZE(msm_common_dai_links);
-		len_2 = len_1 + ARRAY_SIZE(msm_tasha_fe_dai_links);
-		len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
-		len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
-		total_links = len_4 + ARRAY_SIZE(msm_tasha_be_dai_links);
-		memcpy(msm_tasha_dai_links,
-		       msm_common_dai_links,
-		       sizeof(msm_common_dai_links));
-		memcpy(msm_tasha_dai_links + len_1,
-		       msm_tasha_fe_dai_links,
-		       sizeof(msm_tasha_fe_dai_links));
-		memcpy(msm_tasha_dai_links + len_2,
-		       msm_common_misc_fe_dai_links,
-		       sizeof(msm_common_misc_fe_dai_links));
-		memcpy(msm_tasha_dai_links + len_3,
-		       msm_common_be_dai_links,
-		       sizeof(msm_common_be_dai_links));
-		memcpy(msm_tasha_dai_links + len_4,
-		       msm_tasha_be_dai_links,
-		       sizeof(msm_tasha_be_dai_links));
-
-		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-			dev_dbg(dev, "%s(): WCN BTFM support present\n",
-				__func__);
-			memcpy(msm_tasha_dai_links + total_links,
-			       msm_wcn_be_dai_links,
-			       sizeof(msm_wcn_be_dai_links));
-			total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
-		}
-
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,ext-disp-audio-rx")) {
-			dev_dbg(dev, "%s(): External display audio support present\n",
-				__func__);
-			memcpy(msm_tasha_dai_links + total_links,
-			ext_disp_be_dai_link,
-			sizeof(ext_disp_be_dai_link));
-			total_links += ARRAY_SIZE(ext_disp_be_dai_link);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,mi2s-audio-intf")) {
-			memcpy(msm_tasha_dai_links + total_links,
-			       msm_mi2s_be_dai_links,
-			       sizeof(msm_mi2s_be_dai_links));
-			total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,auxpcm-audio-intf")) {
-			memcpy(msm_tasha_dai_links + total_links,
-			       msm_auxpcm_be_dai_links,
-			       sizeof(msm_auxpcm_be_dai_links));
-			total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-		}
-		dailink = msm_tasha_dai_links;
-	}  else if (!strcmp(match->data, "tavil_codec")) {
-		card = &snd_soc_card_tavil_msm;
-		len_1 = ARRAY_SIZE(msm_common_dai_links);
-		len_2 = len_1 + ARRAY_SIZE(msm_tavil_fe_dai_links);
-		len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
-		len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
-		total_links = len_4 + ARRAY_SIZE(msm_tavil_be_dai_links);
-		memcpy(msm_tavil_dai_links,
-		       msm_common_dai_links,
-		       sizeof(msm_common_dai_links));
-		memcpy(msm_tavil_dai_links + len_1,
-		       msm_tavil_fe_dai_links,
-		       sizeof(msm_tavil_fe_dai_links));
-		memcpy(msm_tavil_dai_links + len_2,
-		       msm_common_misc_fe_dai_links,
-		       sizeof(msm_common_misc_fe_dai_links));
-		memcpy(msm_tavil_dai_links + len_3,
-		       msm_common_be_dai_links,
-		       sizeof(msm_common_be_dai_links));
-		memcpy(msm_tavil_dai_links + len_4,
-		       msm_tavil_be_dai_links,
-		       sizeof(msm_tavil_be_dai_links));
-
-		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-			dev_dbg(dev, "%s(): WCN BTFM support present\n",
-				__func__);
-			memcpy(msm_tavil_dai_links + total_links,
-			       msm_wcn_be_dai_links,
-			       sizeof(msm_wcn_be_dai_links));
-			total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
-		}
-
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,ext-disp-audio-rx")) {
-			dev_dbg(dev, "%s(): ext disp audio support present\n",
-				__func__);
-			memcpy(msm_tavil_dai_links + total_links,
-			       ext_disp_be_dai_link,
-			       sizeof(ext_disp_be_dai_link));
-			total_links += ARRAY_SIZE(ext_disp_be_dai_link);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,mi2s-audio-intf")) {
-			memcpy(msm_tavil_dai_links + total_links,
-			       msm_mi2s_be_dai_links,
-			       sizeof(msm_mi2s_be_dai_links));
-			total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,auxpcm-audio-intf")) {
-			memcpy(msm_tavil_dai_links + total_links,
-			msm_auxpcm_be_dai_links,
-			sizeof(msm_auxpcm_be_dai_links));
-			total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-		}
-		dailink = msm_tavil_dai_links;
-	} else if (!strcmp(match->data, "stub_codec")) {
-		card = &snd_soc_card_stub_msm;
-		len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
-		len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
-
-		memcpy(msm_stub_dai_links,
-		       msm_stub_fe_dai_links,
-		       sizeof(msm_stub_fe_dai_links));
-		memcpy(msm_stub_dai_links + len_1,
-		       msm_stub_be_dai_links,
-		       sizeof(msm_stub_be_dai_links));
-
-		dailink = msm_stub_dai_links;
-		total_links = len_2;
-	}
-
-	if (card) {
-		card->dai_link = dailink;
-		card->num_links = total_links;
-	}
-
-	return card;
-}
-
-static int msm_wsa881x_init(struct snd_soc_component *component)
-{
-	u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
-	u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
-	unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
-	unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
-	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
-	struct msm_asoc_mach_data *pdata;
-	struct snd_soc_dapm_context *dapm;
-	int ret = 0;
-
-	if (!codec) {
-		pr_err("%s codec is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dapm = snd_soc_codec_get_dapm(codec);
-
-	if (!strcmp(component->name_prefix, "SpkrLeft")) {
-		dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
-			__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkleft_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
-		}
-	} else if (!strcmp(component->name_prefix, "SpkrRight")) {
-		dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
-			__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkright_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
-		}
-	} else {
-		dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
-			codec->component.name);
-		ret = -EINVAL;
-		goto err_codec;
-	}
-	pdata = snd_soc_card_get_drvdata(component->card);
-	if (pdata && pdata->codec_root)
-		wsa881x_codec_info_create_codec_entry(pdata->codec_root,
-						      codec);
-
-err_codec:
-	return ret;
-}
-
-static int msm_init_wsa_dev(struct platform_device *pdev,
-				struct snd_soc_card *card)
-{
-	struct device_node *wsa_of_node;
-	u32 wsa_max_devs;
-	u32 wsa_dev_cnt;
-	int i;
-	struct msm_wsa881x_dev_info *wsa881x_dev_info;
-	const char *wsa_auxdev_name_prefix[1];
-	char *dev_name_str = NULL;
-	int found = 0;
-	int ret = 0;
-
-	/* Get maximum WSA device count for this platform */
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "qcom,wsa-max-devs", &wsa_max_devs);
-	if (ret) {
-		dev_dbg(&pdev->dev,
-			 "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
-			 __func__, pdev->dev.of_node->full_name, ret);
-		goto err_dt;
-	}
-	if (wsa_max_devs == 0) {
-		dev_warn(&pdev->dev,
-			 "%s: Max WSA devices is 0 for this target?\n",
-			 __func__);
-		goto err_dt;
-	}
-
-	/* Get count of WSA device phandles for this platform */
-	wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
-						 "qcom,wsa-devs", NULL);
-	if (wsa_dev_cnt == -ENOENT) {
-		dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
-			 __func__);
-		goto err_dt;
-	} else if (wsa_dev_cnt <= 0) {
-		dev_err(&pdev->dev,
-			"%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
-			__func__, wsa_dev_cnt);
-		ret = -EINVAL;
-		goto err_dt;
-	}
-
-	/*
-	 * Expect total phandles count to be NOT less than maximum possible
-	 * WSA count. However, if it is less, then assign same value to
-	 * max count as well.
-	 */
-	if (wsa_dev_cnt < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
-			__func__, wsa_max_devs, wsa_dev_cnt);
-		wsa_max_devs = wsa_dev_cnt;
-	}
-
-	/* Make sure prefix string passed for each WSA device */
-	ret = of_property_count_strings(pdev->dev.of_node,
-					"qcom,wsa-aux-dev-prefix");
-	if (ret != wsa_dev_cnt) {
-		dev_err(&pdev->dev,
-			"%s: expecting %d wsa prefix. Defined only %d in DT\n",
-			__func__, wsa_dev_cnt, ret);
-		ret = -EINVAL;
-		goto err_dt;
-	}
-
-	/*
-	 * Alloc mem to store phandle and index info of WSA device, if already
-	 * registered with ALSA core
-	 */
-	wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
-					sizeof(struct msm_wsa881x_dev_info),
-					GFP_KERNEL);
-	if (!wsa881x_dev_info) {
-		ret = -ENOMEM;
-		goto err_mem;
-	}
-
-	/*
-	 * search and check whether all WSA devices are already
-	 * registered with ALSA core or not. If found a node, store
-	 * the node and the index in a local array of struct for later
-	 * use.
-	 */
-	for (i = 0; i < wsa_dev_cnt; i++) {
-		wsa_of_node = of_parse_phandle(pdev->dev.of_node,
-					    "qcom,wsa-devs", i);
-		if (unlikely(!wsa_of_node)) {
-			/* we should not be here */
-			dev_err(&pdev->dev,
-				"%s: wsa dev node is not present\n",
-				__func__);
-			ret = -EINVAL;
-			goto err_dev_node;
-		}
-		if (soc_find_component(wsa_of_node, NULL)) {
-			/* WSA device registered with ALSA core */
-			wsa881x_dev_info[found].of_node = wsa_of_node;
-			wsa881x_dev_info[found].index = i;
-			found++;
-			if (found == wsa_max_devs)
-				break;
-		}
-	}
-
-	if (found < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: failed to find %d components. Found only %d\n",
-			__func__, wsa_max_devs, found);
-		return -EPROBE_DEFER;
-	}
-	dev_info(&pdev->dev,
-		"%s: found %d wsa881x devices registered with ALSA core\n",
-		__func__, found);
-
-	card->num_aux_devs = wsa_max_devs;
-	card->num_configs = wsa_max_devs;
-
-	/* Alloc array of AUX devs struct */
-	msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-				       sizeof(struct snd_soc_aux_dev),
-				       GFP_KERNEL);
-	if (!msm_aux_dev) {
-		ret = -ENOMEM;
-		goto err_auxdev_mem;
-	}
-
-	/* Alloc array of codec conf struct */
-	msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-					  sizeof(struct snd_soc_codec_conf),
-					  GFP_KERNEL);
-	if (!msm_codec_conf) {
-		ret = -ENOMEM;
-		goto err_codec_conf;
-	}
-
-	for (i = 0; i < card->num_aux_devs; i++) {
-		dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
-					    GFP_KERNEL);
-		if (!dev_name_str) {
-			ret = -ENOMEM;
-			goto err_dev_str;
-		}
-
-		ret = of_property_read_string_index(pdev->dev.of_node,
-						    "qcom,wsa-aux-dev-prefix",
-						    wsa881x_dev_info[i].index,
-						    wsa_auxdev_name_prefix);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: failed to read wsa aux dev prefix, ret = %d\n",
-				__func__, ret);
-			ret = -EINVAL;
-			goto err_dt_prop;
-		}
-
-		snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
-		msm_aux_dev[i].name = dev_name_str;
-		msm_aux_dev[i].codec_name = NULL;
-		msm_aux_dev[i].codec_of_node =
-					wsa881x_dev_info[i].of_node;
-		msm_aux_dev[i].init = msm_wsa881x_init;
-		msm_codec_conf[i].dev_name = NULL;
-		msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
-		msm_codec_conf[i].of_node =
-				wsa881x_dev_info[i].of_node;
-	}
-	card->codec_conf = msm_codec_conf;
-	card->aux_dev = msm_aux_dev;
-
-	return 0;
-
-err_dt_prop:
-	devm_kfree(&pdev->dev, dev_name_str);
-err_dev_str:
-	devm_kfree(&pdev->dev, msm_codec_conf);
-err_codec_conf:
-	devm_kfree(&pdev->dev, msm_aux_dev);
-err_auxdev_mem:
-err_dev_node:
-	devm_kfree(&pdev->dev, wsa881x_dev_info);
-err_mem:
-err_dt:
-	return ret;
-}
-
-static void i2s_auxpcm_init(struct platform_device *pdev)
-{
-	struct resource *muxsel;
-	int count;
-	u32 mi2s_master_slave[MI2S_MAX];
-	int ret;
-	char *str[PCM_I2S_SEL_MAX] = {
-		"lpaif_pri_mode_muxsel",
-		"lpaif_sec_mode_muxsel",
-		"lpaif_tert_mode_muxsel",
-		"lpaif_quat_mode_muxsel"
-	};
-
-	for (count = 0; count < MI2S_MAX; count++) {
-		mutex_init(&mi2s_intf_conf[count].lock);
-		mi2s_intf_conf[count].ref_cnt = 0;
-	}
-
-	for (count = 0; count < AUX_PCM_MAX; count++) {
-		mutex_init(&auxpcm_intf_conf[count].lock);
-		auxpcm_intf_conf[count].ref_cnt = 0;
-	}
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
-		mutex_init(&mi2s_auxpcm_conf[count].lock);
-		mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr = NULL;
-	}
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
-		muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						      str[count]);
-		if (muxsel) {
-			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr
-				= ioremap(muxsel->start, resource_size(muxsel));
-		}
-	}
-
-	ret = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-mi2s-master",
-			mi2s_master_slave, MI2S_MAX);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
-			__func__);
-	} else {
-		for (count = 0; count < MI2S_MAX; count++) {
-			mi2s_intf_conf[count].msm_is_mi2s_master =
-				mi2s_master_slave[count];
-		}
-	}
-}
-
-static void i2s_auxpcm_deinit(void)
-{
-	int count;
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++)
-		if (mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr !=
-			NULL)
-			iounmap(
-			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr);
-}
-
-static int msm_asoc_machine_probe(struct platform_device *pdev)
-{
-	struct snd_soc_card *card;
-	struct msm_asoc_mach_data *pdata;
-	const char *mbhc_audio_jack_type = NULL;
-	char *mclk_freq_prop_name;
-	const struct of_device_id *match;
-	int ret;
-
-	if (!pdev->dev.of_node) {
-		dev_err(&pdev->dev, "No platform supplied from device tree\n");
-		return -EINVAL;
-	}
-
-	pdata = devm_kzalloc(&pdev->dev,
-			sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	card = populate_snd_card_dailinks(&pdev->dev);
-	if (!card) {
-		dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-	card->dev = &pdev->dev;
-	platform_set_drvdata(pdev, card);
-	snd_soc_card_set_drvdata(card, pdata);
-
-	ret = snd_soc_of_parse_card_name(card, "qcom,model");
-	if (ret) {
-		dev_err(&pdev->dev, "parse card name failed, err:%d\n",
-			ret);
-		goto err;
-	}
-
-	ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
-	if (ret) {
-		dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
-			ret);
-		goto err;
-	}
-
-	match = of_match_node(msm8998_asoc_machine_of_match,
-			pdev->dev.of_node);
-	if (!match) {
-		dev_err(&pdev->dev, "%s: no matched codec is found.\n",
-			__func__);
-		goto err;
-	}
-
-	if (!strcmp(match->data, "tasha_codec"))
-		mclk_freq_prop_name = "qcom,tasha-mclk-clk-freq";
-	else
-		mclk_freq_prop_name = "qcom,tavil-mclk-clk-freq";
-
-	ret = of_property_read_u32(pdev->dev.of_node,
-			mclk_freq_prop_name, &pdata->mclk_freq);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"Looking up %s property in node %s failed, err%d\n",
-			mclk_freq_prop_name,
-			pdev->dev.of_node->full_name, ret);
-		goto err;
-	}
-
-	if (pdata->mclk_freq != CODEC_EXT_CLK_RATE) {
-		dev_err(&pdev->dev, "unsupported mclk freq %u\n",
-			pdata->mclk_freq);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	ret = msm_populate_dai_link_component_of_node(card);
-	if (ret) {
-		ret = -EPROBE_DEFER;
-		goto err;
-	}
-	ret = msm_init_wsa_dev(pdev, card);
-	if (ret)
-		goto err;
-
-	ret = devm_snd_soc_register_card(&pdev->dev, card);
-	if (ret == -EPROBE_DEFER) {
-		if (codec_reg_done)
-			ret = -EINVAL;
-		goto err;
-	} else if (ret) {
-		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
-			ret);
-		goto err;
-	}
-	dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
-	spdev = pdev;
-
-	ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: failed to add child nodes, ret=%d\n",
-			__func__, ret);
-	} else {
-		pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
-							"qcom,hph-en1-gpio", 0);
-		if (!pdata->hph_en1_gpio_p) {
-			dev_dbg(&pdev->dev, "property %s not detected in node %s",
-				"qcom,hph-en1-gpio",
-				pdev->dev.of_node->full_name);
-		}
-
-		pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
-							"qcom,hph-en0-gpio", 0);
-		if (!pdata->hph_en0_gpio_p) {
-			dev_dbg(&pdev->dev, "property %s not detected in node %s",
-				"qcom,hph-en0-gpio",
-				pdev->dev.of_node->full_name);
-		}
-	}
-
-	ret = of_property_read_string(pdev->dev.of_node,
-		"qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
-	if (ret) {
-		dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
-			"qcom,mbhc-audio-jack-type",
-			pdev->dev.of_node->full_name);
-		dev_dbg(&pdev->dev, "Jack type properties set to default");
-	} else {
-		if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = false;
-			dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
-		} else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = true;
-			dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
-		} else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = true;
-			dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
-		} else {
-			wcd_mbhc_cfg.enable_anc_mic_detect = false;
-			dev_dbg(&pdev->dev, "Unknown value, set to default");
-		}
-	}
-	/*
-	 * Parse US-Euro gpio info from DT. Report no error if us-euro
-	 * entry is not found in DT file as some targets do not support
-	 * US-Euro detection
-	 */
-	pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
-				"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio))
-		pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio) && (!pdata->us_euro_gpio_p)) {
-		dev_dbg(&pdev->dev, "property %s not detected in node %s",
-			"qcom,us-euro-gpios", pdev->dev.of_node->full_name);
-	} else {
-		dev_dbg(&pdev->dev, "%s detected",
-			"qcom,us-euro-gpios");
-		wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
-	}
-
-	ret = msm_prepare_us_euro(card);
-	if (ret)
-		dev_dbg(&pdev->dev, "msm_prepare_us_euro failed (%d)\n",
-			ret);
-
-	/* Parse pinctrl info from devicetree */
-	ret = msm_get_pinctrl(pdev);
-	if (!ret) {
-		pr_debug("%s: pinctrl parsing successful\n", __func__);
-	} else {
-		dev_dbg(&pdev->dev,
-			"%s: Parsing pinctrl failed with %d. Cannot use Ports\n",
-			__func__, ret);
-		ret = 0;
-	}
-
-	i2s_auxpcm_init(pdev);
-
-	is_initial_boot = true;
-	ret = audio_notifier_register("msm8998", AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &service_nb);
-	if (ret < 0)
-		pr_err("%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-
-	return 0;
-err:
-	if (pdata->us_euro_gpio > 0) {
-		dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
-			__func__, pdata->us_euro_gpio);
-		gpio_free(pdata->us_euro_gpio);
-		pdata->us_euro_gpio = 0;
-	}
-	msm_release_pinctrl(pdev);
-	devm_kfree(&pdev->dev, pdata);
-	return ret;
-}
-
-static int msm_asoc_machine_remove(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	if (gpio_is_valid(pdata->us_euro_gpio))
-		gpio_free(pdata->us_euro_gpio);
-	i2s_auxpcm_deinit();
-
-	snd_soc_unregister_card(card);
-	audio_notifier_deregister("msm8998");
-	return 0;
-}
-
-static struct platform_driver msm8998_asoc_machine_driver = {
-	.driver = {
-		.name = DRV_NAME,
-		.owner = THIS_MODULE,
-		.pm = &snd_soc_pm_ops,
-		.of_match_table = msm8998_asoc_machine_of_match,
-	},
-	.probe = msm_asoc_machine_probe,
-	.remove = msm_asoc_machine_remove,
-};
-module_platform_driver(msm8998_asoc_machine_driver);
-
-MODULE_DESCRIPTION("ALSA SoC msm");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
-MODULE_DEVICE_TABLE(of, msm8998_asoc_machine_of_match);
diff --git a/sound/soc/msm/qdsp6v2/Makefile b/sound/soc/msm/qdsp6v2/Makefile
deleted file mode 100644
index ceb6b50..0000000
--- a/sound/soc/msm/qdsp6v2/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-snd-soc-qdsp6v2-objs += msm-dai-q6-v2.o msm-pcm-q6-v2.o \
-			msm-pcm-routing-v2.o msm-compress-q6-v2.o \
-			msm-pcm-afe-v2.o msm-pcm-voip-v2.o \
-			msm-pcm-voice-v2.o msm-dai-q6-hdmi-v2.o \
-			msm-lsm-client.o msm-pcm-host-voice-v2.o \
-			msm-audio-effects-q6-v2.o msm-pcm-loopback-v2.o \
-			msm-dai-slim.o msm-transcode-loopback-q6-v2.o \
-			adsp_err.o
-obj-$(CONFIG_SND_SOC_QDSP6V2) += snd-soc-qdsp6v2.o msm-pcm-dtmf-v2.o \
-				 msm-dai-stub-v2.o
-obj-$(CONFIG_SND_HWDEP) += msm-pcm-routing-devdep.o
-obj-$(CONFIG_DOLBY_DAP) += msm-dolby-dap-config.o
-obj-$(CONFIG_DOLBY_DS2) += msm-ds2-dap-config.o
-obj-$(CONFIG_DOLBY_LICENSE) += msm-ds2-dap-config.o
-obj-$(CONFIG_DTS_SRS_TM) += msm-dts-srs-tm-config.o
-obj-$(CONFIG_QTI_PP) += msm-qti-pp-config.o
-obj-y += audio_calibration.o audio_cal_utils.o q6adm.o q6afe.o q6asm.o \
-	q6audio-v2.o q6voice.o q6core.o rtac.o q6lsm.o audio_slimslave.o \
-	msm-pcm-q6-noirq.o
-ocmem-audio-objs += audio_ocmem.o
-obj-$(CONFIG_AUDIO_OCMEM) += ocmem-audio.o
diff --git a/sound/soc/msm/qdsp6v2/adsp_err.c b/sound/soc/msm/qdsp6v2/adsp_err.c
deleted file mode 100644
index d17bd6a..0000000
--- a/sound/soc/msm/qdsp6v2/adsp_err.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/errno.h>
-#include <linux/uaccess.h>
-#include <linux/debugfs.h>
-#include <sound/apr_audio-v2.h>
-
-
-/* ERROR STRING */
-/* Success. The operation completed with no errors. */
-#define ADSP_EOK_STR          "ADSP_EOK"
-/* General failure. */
-#define ADSP_EFAILED_STR      "ADSP_EFAILED"
-/* Bad operation parameter. */
-#define ADSP_EBADPARAM_STR    "ADSP_EBADPARAM"
-/* Unsupported routine or operation. */
-#define ADSP_EUNSUPPORTED_STR "ADSP_EUNSUPPORTED"
-/* Unsupported version. */
-#define ADSP_EVERSION_STR     "ADSP_EVERSION"
-/* Unexpected problem encountered. */
-#define ADSP_EUNEXPECTED_STR  "ADSP_EUNEXPECTED"
-/* Unhandled problem occurred. */
-#define ADSP_EPANIC_STR       "ADSP_EPANIC"
-/* Unable to allocate resource. */
-#define ADSP_ENORESOURCE_STR  "ADSP_ENORESOURCE"
-/* Invalid handle. */
-#define ADSP_EHANDLE_STR      "ADSP_EHANDLE"
-/* Operation is already processed. */
-#define ADSP_EALREADY_STR     "ADSP_EALREADY"
-/* Operation is not ready to be processed. */
-#define ADSP_ENOTREADY_STR    "ADSP_ENOTREADY"
-/* Operation is pending completion. */
-#define ADSP_EPENDING_STR     "ADSP_EPENDING"
-/* Operation could not be accepted or processed. */
-#define ADSP_EBUSY_STR        "ADSP_EBUSY"
-/* Operation aborted due to an error. */
-#define ADSP_EABORTED_STR     "ADSP_EABORTED"
-/* Operation preempted by a higher priority. */
-#define ADSP_EPREEMPTED_STR   "ADSP_EPREEMPTED"
-/* Operation requests intervention to complete. */
-#define ADSP_ECONTINUE_STR    "ADSP_ECONTINUE"
-/* Operation requests immediate intervention to complete. */
-#define ADSP_EIMMEDIATE_STR   "ADSP_EIMMEDIATE"
-/* Operation is not implemented. */
-#define ADSP_ENOTIMPL_STR     "ADSP_ENOTIMPL"
-/* Operation needs more data or resources. */
-#define ADSP_ENEEDMORE_STR    "ADSP_ENEEDMORE"
-/* Operation does not have memory. */
-#define ADSP_ENOMEMORY_STR    "ADSP_ENOMEMORY"
-/* Item does not exist. */
-#define ADSP_ENOTEXIST_STR    "ADSP_ENOTEXIST"
-/* Unexpected error code. */
-#define ADSP_ERR_MAX_STR      "ADSP_ERR_MAX"
-
-#ifdef CONFIG_SND_SOC_QDSP_DEBUG
-static bool adsp_err_panic;
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_adsp_err;
-
-static ssize_t adsp_err_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char cmd;
-
-	if (copy_from_user(&cmd, ubuf, 1))
-		return -EFAULT;
-
-	if (cmd == '0')
-		adsp_err_panic = false;
-	else
-		adsp_err_panic = true;
-
-	return cnt;
-}
-
-static const struct file_operations adsp_err_debug_ops = {
-	.write = adsp_err_debug_write,
-};
-#endif
-#endif
-
-struct adsp_err_code {
-	int		lnx_err_code;
-	char	*adsp_err_str;
-};
-
-
-static struct adsp_err_code adsp_err_code_info[ADSP_ERR_MAX+1] = {
-	{ 0, ADSP_EOK_STR},
-	{ -ENOTRECOVERABLE, ADSP_EFAILED_STR},
-	{ -EINVAL, ADSP_EBADPARAM_STR},
-	{ -EOPNOTSUPP, ADSP_EUNSUPPORTED_STR},
-	{ -ENOPROTOOPT, ADSP_EVERSION_STR},
-	{ -ENOTRECOVERABLE, ADSP_EUNEXPECTED_STR},
-	{ -ENOTRECOVERABLE, ADSP_EPANIC_STR},
-	{ -ENOSPC, ADSP_ENORESOURCE_STR},
-	{ -EBADR, ADSP_EHANDLE_STR},
-	{ -EALREADY, ADSP_EALREADY_STR},
-	{ -EPERM, ADSP_ENOTREADY_STR},
-	{ -EINPROGRESS, ADSP_EPENDING_STR},
-	{ -EBUSY, ADSP_EBUSY_STR},
-	{ -ECANCELED, ADSP_EABORTED_STR},
-	{ -EAGAIN, ADSP_EPREEMPTED_STR},
-	{ -EAGAIN, ADSP_ECONTINUE_STR},
-	{ -EAGAIN, ADSP_EIMMEDIATE_STR},
-	{ -EAGAIN, ADSP_ENOTIMPL_STR},
-	{ -ENODATA, ADSP_ENEEDMORE_STR},
-	{ -EADV, ADSP_ERR_MAX_STR},
-	{ -ENOMEM, ADSP_ENOMEMORY_STR},
-	{ -ENODEV, ADSP_ENOTEXIST_STR},
-	{ -EADV, ADSP_ERR_MAX_STR},
-};
-
-#ifdef CONFIG_SND_SOC_QDSP_DEBUG
-static inline void adsp_err_check_panic(u32 adsp_error)
-{
-	if (adsp_err_panic && adsp_error != ADSP_EALREADY)
-		panic("%s: encounter adsp_err=0x%x\n", __func__, adsp_error);
-}
-#else
-static inline void adsp_err_check_panic(u32 adsp_error) {}
-#endif
-
-int adsp_err_get_lnx_err_code(u32 adsp_error)
-{
-	adsp_err_check_panic(adsp_error);
-
-	if (adsp_error > ADSP_ERR_MAX)
-		return adsp_err_code_info[ADSP_ERR_MAX].lnx_err_code;
-	else
-		return adsp_err_code_info[adsp_error].lnx_err_code;
-}
-
-char *adsp_err_get_err_str(u32 adsp_error)
-{
-	if (adsp_error > ADSP_ERR_MAX)
-		return adsp_err_code_info[ADSP_ERR_MAX].adsp_err_str;
-	else
-		return adsp_err_code_info[adsp_error].adsp_err_str;
-}
-
-#if defined(CONFIG_SND_SOC_QDSP_DEBUG) && defined(CONFIG_DEBUG_FS)
-static int __init adsp_err_init(void)
-{
-
-
-	debugfs_adsp_err = debugfs_create_file("msm_adsp_audio_debug",
-					       S_IFREG | 0444, NULL, NULL,
-					       &adsp_err_debug_ops);
-
-	return 0;
-}
-
-device_initcall(adsp_err_init);
-#endif
diff --git a/sound/soc/msm/qdsp6v2/audio_cal_utils.c b/sound/soc/msm/qdsp6v2/audio_cal_utils.c
deleted file mode 100644
index 7e69a7f..0000000
--- a/sound/soc/msm/qdsp6v2/audio_cal_utils.c
+++ /dev/null
@@ -1,1030 +0,0 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/mutex.h>
-#include <sound/audio_cal_utils.h>
-
-static int unmap_memory(struct cal_type_data *cal_type,
-			struct cal_block_data *cal_block);
-
-size_t get_cal_info_size(int32_t cal_type)
-{
-	size_t size = 0;
-
-	switch (cal_type) {
-	case CVP_VOC_RX_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_voc_top);
-		break;
-	case CVP_VOC_TX_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_voc_top);
-		break;
-	case CVP_VOCPROC_STATIC_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_vocproc);
-		break;
-	case CVP_VOCPROC_DYNAMIC_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_vocvol);
-		break;
-	case CVS_VOCSTRM_STATIC_CAL_TYPE:
-		size = 0;
-		break;
-	case CVP_VOCDEV_CFG_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_vocdev_cfg);
-		break;
-	case CVP_VOCPROC_STATIC_COL_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_voc_col);
-		break;
-	case CVP_VOCPROC_DYNAMIC_COL_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_voc_col);
-		break;
-	case CVS_VOCSTRM_STATIC_COL_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_voc_col);
-		break;
-	case ADM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_adm_top);
-		break;
-	case ADM_CUST_TOPOLOGY_CAL_TYPE:
-	case CORE_CUSTOM_TOPOLOGIES_CAL_TYPE:
-		size = 0;
-		break;
-	case ADM_AUDPROC_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_audproc);
-		break;
-	case ADM_AUDVOL_CAL_TYPE:
-	case ADM_RTAC_AUDVOL_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_audvol);
-		break;
-	case ASM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_asm_top);
-		break;
-	case ASM_CUST_TOPOLOGY_CAL_TYPE:
-		size = 0;
-		break;
-	case ASM_AUDSTRM_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_audstrm);
-		break;
-	case AFE_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_afe_top);
-		break;
-	case AFE_CUST_TOPOLOGY_CAL_TYPE:
-		size = 0;
-		break;
-	case AFE_COMMON_RX_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_afe);
-		break;
-	case AFE_COMMON_TX_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_afe);
-		break;
-	case AFE_FB_SPKR_PROT_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_spk_prot_cfg);
-		break;
-	case AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE:
-		/*
-		 * Since get and set parameter structures are different in size
-		 * use the maximum size of get and set parameter structure
-		 */
-		size = max(sizeof(struct audio_cal_info_sp_th_vi_ftm_cfg),
-			   sizeof(struct audio_cal_info_sp_th_vi_param));
-		break;
-	case AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE:
-		/*
-		 * Since get and set parameter structures are different in size
-		 * use the maximum size of get and set parameter structure
-		 */
-		size = max(sizeof(struct audio_cal_info_sp_ex_vi_ftm_cfg),
-			   sizeof(struct audio_cal_info_sp_ex_vi_param));
-		break;
-	case AFE_ANC_CAL_TYPE:
-		size = 0;
-		break;
-	case AFE_AANC_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_aanc);
-		break;
-	case AFE_HW_DELAY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_hw_delay);
-		break;
-	case AFE_SIDETONE_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_sidetone);
-		break;
-	case AFE_SIDETONE_IIR_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_sidetone_iir);
-		break;
-	case LSM_CUST_TOPOLOGY_CAL_TYPE:
-		size = 0;
-		break;
-	case LSM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_lsm_top);
-		break;
-	case ULP_LSM_TOPOLOGY_ID_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_lsm_top);
-		break;
-	case LSM_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_lsm);
-		break;
-	case ADM_RTAC_INFO_CAL_TYPE:
-		size = 0;
-		break;
-	case VOICE_RTAC_INFO_CAL_TYPE:
-		size = 0;
-		break;
-	case ADM_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case ASM_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case VOICE_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case MAD_CAL_TYPE:
-		size = 0;
-		break;
-	case ULP_AFE_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_afe);
-		break;
-	case ULP_LSM_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_lsm);
-		break;
-	case AUDIO_CORE_METAINFO_CAL_TYPE:
-		size = sizeof(struct audio_cal_info_metainfo);
-		break;
-	case SRS_TRUMEDIA_CAL_TYPE:
-		size = 0;
-		break;
-	default:
-		pr_err("%s:Invalid cal type %d!",
-			__func__, cal_type);
-	}
-	return size;
-}
-
-size_t get_user_cal_type_size(int32_t cal_type)
-{
-	size_t size = 0;
-
-	switch (cal_type) {
-	case CVP_VOC_RX_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_voc_top);
-		break;
-	case CVP_VOC_TX_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_voc_top);
-		break;
-	case CVP_VOCPROC_STATIC_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_vocproc);
-		break;
-	case CVP_VOCPROC_DYNAMIC_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_vocvol);
-		break;
-	case CVS_VOCSTRM_STATIC_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_basic);
-		break;
-	case CVP_VOCDEV_CFG_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_vocdev_cfg);
-		break;
-	case CVP_VOCPROC_STATIC_COL_CAL_TYPE:
-	case CVP_VOCPROC_DYNAMIC_COL_CAL_TYPE:
-	case CVS_VOCSTRM_STATIC_COL_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_voc_col);
-		break;
-	case ADM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_adm_top);
-		break;
-	case ADM_CUST_TOPOLOGY_CAL_TYPE:
-	case CORE_CUSTOM_TOPOLOGIES_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_basic);
-		break;
-	case ADM_AUDPROC_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_audproc);
-		break;
-	case ADM_AUDVOL_CAL_TYPE:
-	case ADM_RTAC_AUDVOL_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_audvol);
-		break;
-	case ASM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_asm_top);
-		break;
-	case ASM_CUST_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_basic);
-		break;
-	case ASM_AUDSTRM_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_audstrm);
-		break;
-	case AFE_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_afe_top);
-		break;
-	case AFE_CUST_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_basic);
-		break;
-	case AFE_COMMON_RX_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_afe);
-		break;
-	case AFE_COMMON_TX_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_afe);
-		break;
-	case AFE_FB_SPKR_PROT_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_fb_spk_prot_cfg);
-		break;
-	case AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE:
-		/*
-		 * Since get and set parameter structures are different in size
-		 * use the maximum size of get and set parameter structure
-		 */
-		size = max(sizeof(struct audio_cal_type_sp_th_vi_ftm_cfg),
-			   sizeof(struct audio_cal_type_sp_th_vi_param));
-		break;
-	case AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE:
-		/*
-		 * Since get and set parameter structures are different in size
-		 * use the maximum size of get and set parameter structure
-		 */
-		size = max(sizeof(struct audio_cal_type_sp_ex_vi_ftm_cfg),
-			   sizeof(struct audio_cal_type_sp_ex_vi_param));
-		break;
-	case AFE_ANC_CAL_TYPE:
-		size = 0;
-		break;
-	case AFE_AANC_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_aanc);
-		break;
-	case AFE_HW_DELAY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_hw_delay);
-		break;
-	case AFE_SIDETONE_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_sidetone);
-		break;
-	case AFE_SIDETONE_IIR_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_sidetone_iir);
-		break;
-	case LSM_CUST_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_basic);
-		break;
-	case LSM_TOPOLOGY_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_lsm_top);
-		break;
-	case ULP_LSM_TOPOLOGY_ID_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_lsm_top);
-		break;
-	case LSM_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_lsm);
-		break;
-	case ADM_RTAC_INFO_CAL_TYPE:
-		size = 0;
-		break;
-	case VOICE_RTAC_INFO_CAL_TYPE:
-		size = 0;
-		break;
-	case ADM_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case ASM_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case VOICE_RTAC_APR_CAL_TYPE:
-		size = 0;
-		break;
-	case MAD_CAL_TYPE:
-		size = 0;
-		break;
-	case ULP_AFE_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_afe);
-		break;
-	case ULP_LSM_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_lsm);
-		break;
-	case AUDIO_CORE_METAINFO_CAL_TYPE:
-		size = sizeof(struct audio_cal_type_metainfo);
-		break;
-	case SRS_TRUMEDIA_CAL_TYPE:
-		size = 0;
-		break;
-	default:
-		pr_err("%s:Invalid cal type %d!",
-			__func__, cal_type);
-	}
-	return size;
-}
-
-int32_t cal_utils_get_cal_type_version(void *cal_type_data)
-{
-	struct audio_cal_type_basic *data = NULL;
-
-	data = (struct audio_cal_type_basic *)cal_type_data;
-
-	return data->cal_hdr.version;
-}
-
-static struct cal_type_data *create_cal_type_data(
-				struct cal_type_info *info)
-{
-	struct cal_type_data	*cal_type = NULL;
-
-	if ((info->reg.cal_type < 0) ||
-		(info->reg.cal_type >= MAX_CAL_TYPES)) {
-		pr_err("%s: cal type %d is Invalid!\n",
-			__func__, info->reg.cal_type);
-		goto done;
-	}
-
-	if (info->cal_util_callbacks.match_block == NULL) {
-		pr_err("%s: cal type %d no method to match blocks!\n",
-			__func__, info->reg.cal_type);
-		goto done;
-	}
-
-	cal_type = kmalloc(sizeof(*cal_type), GFP_KERNEL);
-	if (cal_type == NULL)
-		goto done;
-
-	INIT_LIST_HEAD(&cal_type->cal_blocks);
-	mutex_init(&cal_type->lock);
-	memcpy(&cal_type->info, info,
-		sizeof(cal_type->info));
-done:
-	return cal_type;
-}
-
-/**
- * cal_utils_create_cal_types
- *
- * @num_cal_types: number of types
- * @cal_type: pointer to the cal types pointer
- * @info: pointer to info
- *
- * Returns 0 on success, EINVAL otherwise
- */
-int cal_utils_create_cal_types(int num_cal_types,
-			struct cal_type_data **cal_type,
-			struct cal_type_info *info)
-{
-	int ret = 0;
-	int i;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if (info == NULL) {
-		pr_err("%s: info is NULL!\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if ((num_cal_types <= 0) ||
-		(num_cal_types > MAX_CAL_TYPES)) {
-		pr_err("%s: num_cal_types of %d is Invalid!\n",
-			__func__, num_cal_types);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for (i = 0; i < num_cal_types; i++) {
-		if ((info[i].reg.cal_type < 0) ||
-			(info[i].reg.cal_type >= MAX_CAL_TYPES)) {
-			pr_err("%s: cal type %d at index %d is Invalid!\n",
-				__func__, info[i].reg.cal_type, i);
-			ret = -EINVAL;
-			goto done;
-		}
-
-		cal_type[i] = create_cal_type_data(&info[i]);
-		if (cal_type[i] == NULL) {
-			pr_err("%s: Could not allocate cal_type of index %d!\n",
-				__func__, i);
-			ret = -EINVAL;
-			goto done;
-		}
-
-		ret = audio_cal_register(1, &info[i].reg);
-		if (ret < 0) {
-			pr_err("%s: audio_cal_register failed, ret = %d!\n",
-				__func__, ret);
-			ret = -EINVAL;
-			goto done;
-		}
-		pr_debug("%s: cal type %d at index %d!\n",
-			__func__, info[i].reg.cal_type, i);
-	}
-done:
-	return ret;
-}
-EXPORT_SYMBOL(cal_utils_create_cal_types);
-
-static void delete_cal_block(struct cal_block_data *cal_block)
-{
-	pr_debug("%s\n", __func__);
-
-	if (cal_block == NULL)
-		goto done;
-
-	list_del(&cal_block->list);
-	kfree(cal_block->client_info);
-	cal_block->client_info = NULL;
-	kfree(cal_block->cal_info);
-	cal_block->cal_info = NULL;
-	if (cal_block->map_data.ion_client  != NULL) {
-		msm_audio_ion_free(cal_block->map_data.ion_client,
-			cal_block->map_data.ion_handle);
-		cal_block->map_data.ion_client = NULL;
-		cal_block->map_data.ion_handle = NULL;
-	}
-	kfree(cal_block);
-done:
-	return;
-}
-
-static void destroy_all_cal_blocks(struct cal_type_data *cal_type)
-{
-	int ret = 0;
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block;
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		ret = unmap_memory(cal_type, cal_block);
-		if (ret < 0) {
-			pr_err("%s: unmap_memory failed, cal type %d, ret = %d!\n",
-				__func__,
-			       cal_type->info.reg.cal_type,
-				ret);
-		}
-		delete_cal_block(cal_block);
-		cal_block = NULL;
-	}
-}
-
-static void destroy_cal_type_data(struct cal_type_data *cal_type)
-{
-	if (cal_type == NULL)
-		goto done;
-
-	destroy_all_cal_blocks(cal_type);
-	list_del(&cal_type->cal_blocks);
-	kfree(cal_type);
-done:
-	return;
-}
-
-void cal_utils_destroy_cal_types(int num_cal_types,
-			struct cal_type_data **cal_type)
-{
-	int i;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n", __func__);
-		goto done;
-	} else if ((num_cal_types <= 0) ||
-		(num_cal_types > MAX_CAL_TYPES)) {
-		pr_err("%s: num_cal_types of %d is Invalid!\n",
-			__func__, num_cal_types);
-		goto done;
-	}
-
-	for (i = 0; i < num_cal_types; i++) {
-		audio_cal_deregister(1, &cal_type[i]->info.reg);
-		destroy_cal_type_data(cal_type[i]);
-		cal_type[i] = NULL;
-	}
-done:
-	return;
-}
-
-/**
- * cal_utils_get_only_cal_block
- *
- * @cal_type: pointer to the cal type
- *
- * Returns cal_block structure
- */
-struct cal_block_data *cal_utils_get_only_cal_block(
-			struct cal_type_data *cal_type)
-{
-	struct list_head		*ptr, *next;
-	struct cal_block_data		*cal_block = NULL;
-
-	if (cal_type == NULL)
-		goto done;
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-		break;
-	}
-done:
-	return cal_block;
-}
-EXPORT_SYMBOL(cal_utils_get_only_cal_block);
-
-/**
- * cal_utils_get_only_cal_block
- *
- * @cal_block: pointer to cal block struct
- * @user_data: pointer to user data
- *
- * Returns true on match
- */
-bool cal_utils_match_buf_num(struct cal_block_data *cal_block,
-					void *user_data)
-{
-	bool ret = false;
-	struct audio_cal_type_basic	*data = user_data;
-
-	if (cal_block->buffer_number == data->cal_hdr.buffer_number)
-		ret = true;
-
-	return ret;
-}
-EXPORT_SYMBOL(cal_utils_match_buf_num);
-
-static struct cal_block_data *get_matching_cal_block(
-					struct cal_type_data *cal_type,
-					void *data)
-{
-	struct list_head		*ptr, *next;
-	struct cal_block_data		*cal_block = NULL;
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (cal_type->info.cal_util_callbacks.
-			match_block(cal_block, data))
-			return cal_block;
-	}
-
-	return NULL;
-}
-
-static int cal_block_ion_alloc(struct cal_block_data *cal_block)
-{
-	int	ret = 0;
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = msm_audio_ion_import("audio_cal_client",
-		&cal_block->map_data.ion_client,
-		&cal_block->map_data.ion_handle,
-		cal_block->map_data.ion_map_handle,
-		NULL, 0,
-		&cal_block->cal_data.paddr,
-		&cal_block->map_data.map_size,
-		&cal_block->cal_data.kvaddr);
-	if (ret) {
-		pr_err("%s: audio ION import failed, rc = %d\n",
-			__func__, ret);
-		ret = -ENOMEM;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static struct cal_block_data *create_cal_block(struct cal_type_data *cal_type,
-				struct audio_cal_type_basic *basic_cal,
-				size_t client_info_size, void *client_info)
-{
-	struct cal_block_data	*cal_block = NULL;
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n", __func__);
-		goto done;
-	} else if (basic_cal == NULL) {
-		pr_err("%s: basic_cal is NULL!\n", __func__);
-		goto done;
-	}
-
-	cal_block = kzalloc(sizeof(*cal_block),
-		GFP_KERNEL);
-	if (cal_block == NULL)
-		goto done;
-
-	INIT_LIST_HEAD(&cal_block->list);
-
-	cal_block->map_data.ion_map_handle = basic_cal->cal_data.mem_handle;
-	if (basic_cal->cal_data.mem_handle > 0) {
-		if (cal_block_ion_alloc(cal_block)) {
-			pr_err("%s: cal_block_ion_alloc failed!\n",
-				__func__);
-			goto err;
-		}
-	}
-	if (client_info_size > 0) {
-		cal_block->client_info_size = client_info_size;
-		cal_block->client_info = kmalloc(client_info_size, GFP_KERNEL);
-		if (cal_block->client_info == NULL) {
-			pr_err("%s: could not allocats client_info!\n",
-				__func__);
-			goto err;
-		}
-		if (client_info != NULL)
-			memcpy(cal_block->client_info, client_info,
-				client_info_size);
-	}
-
-	cal_block->cal_info = kzalloc(
-		get_cal_info_size(cal_type->info.reg.cal_type),
-		GFP_KERNEL);
-	if (cal_block->cal_info == NULL) {
-		pr_err("%s: could not allocats cal_info!\n",
-			__func__);
-		goto err;
-	}
-	cal_block->buffer_number = basic_cal->cal_hdr.buffer_number;
-	list_add_tail(&cal_block->list, &cal_type->cal_blocks);
-	pr_debug("%s: created block for cal type %d, buf num %d, map handle %d, map size %zd paddr 0x%pK!\n",
-		__func__, cal_type->info.reg.cal_type,
-		cal_block->buffer_number,
-		cal_block->map_data.ion_map_handle,
-		cal_block->map_data.map_size,
-		&cal_block->cal_data.paddr);
-done:
-	return cal_block;
-err:
-	kfree(cal_block->cal_info);
-	cal_block->cal_info = NULL;
-	kfree(cal_block->client_info);
-	cal_block->client_info = NULL;
-	kfree(cal_block);
-	cal_block = NULL;
-	return cal_block;
-}
-
-void cal_utils_clear_cal_block_q6maps(int num_cal_types,
-					struct cal_type_data **cal_type)
-{
-	int i = 0;
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n", __func__);
-		goto done;
-	} else if ((num_cal_types <= 0) ||
-		(num_cal_types > MAX_CAL_TYPES)) {
-		pr_err("%s: num_cal_types of %d is Invalid!\n",
-			__func__, num_cal_types);
-		goto done;
-	}
-
-	for (; i < num_cal_types; i++) {
-		if (cal_type[i] == NULL)
-			continue;
-
-		mutex_lock(&cal_type[i]->lock);
-		list_for_each_safe(ptr, next,
-			&cal_type[i]->cal_blocks) {
-
-			cal_block = list_entry(ptr,
-				struct cal_block_data, list);
-
-			cal_block->map_data.q6map_handle = 0;
-		}
-		mutex_unlock(&cal_type[i]->lock);
-	}
-done:
-	return;
-}
-
-
-
-static int realloc_memory(struct cal_block_data *cal_block)
-{
-	int ret = 0;
-
-	msm_audio_ion_free(cal_block->map_data.ion_client,
-		cal_block->map_data.ion_handle);
-	cal_block->map_data.ion_client = NULL;
-	cal_block->map_data.ion_handle = NULL;
-	cal_block->cal_data.size = 0;
-
-	ret = cal_block_ion_alloc(cal_block);
-	if (ret < 0)
-		pr_err("%s: realloc_memory failed!\n",
-			__func__);
-	return ret;
-}
-
-static int map_memory(struct cal_type_data *cal_type,
-			struct cal_block_data *cal_block)
-{
-	int ret = 0;
-
-
-	if (cal_type->info.cal_util_callbacks.map_cal != NULL) {
-		if ((cal_block->map_data.ion_map_handle < 0) ||
-			(cal_block->map_data.map_size <= 0) ||
-			(cal_block->map_data.q6map_handle != 0)) {
-			goto done;
-		}
-
-		pr_debug("%s: cal type %d call map\n",
-			__func__, cal_type->info.reg.cal_type);
-		ret = cal_type->info.cal_util_callbacks.
-			map_cal(cal_type->info.reg.cal_type, cal_block);
-		if (ret < 0) {
-			pr_err("%s: map_cal failed, cal type %d, ret = %d!\n",
-				__func__, cal_type->info.reg.cal_type,
-				ret);
-			goto done;
-		}
-	}
-done:
-	return ret;
-}
-
-static int unmap_memory(struct cal_type_data *cal_type,
-			struct cal_block_data *cal_block)
-{
-	int ret = 0;
-
-	if (cal_type->info.cal_util_callbacks.unmap_cal != NULL) {
-		if ((cal_block->map_data.ion_map_handle < 0) ||
-			(cal_block->map_data.map_size <= 0) ||
-			(cal_block->map_data.q6map_handle == 0)) {
-			goto done;
-		}
-		pr_debug("%s: cal type %d call unmap\n",
-			__func__, cal_type->info.reg.cal_type);
-		ret = cal_type->info.cal_util_callbacks.
-			unmap_cal(cal_type->info.reg.cal_type, cal_block);
-		if (ret < 0) {
-			pr_err("%s: unmap_cal failed, cal type %d, ret = %d!\n",
-				__func__, cal_type->info.reg.cal_type,
-				ret);
-			goto done;
-		}
-	}
-done:
-	return ret;
-}
-
-/**
- * cal_utils_alloc_cal
- *
- * @data_size: size of data to allocate
- * @data: data pointer
- * @cal_type: pointer to the cal type
- * @client_info_size: client info size
- * @client_info: pointer to client info
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int cal_utils_alloc_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type,
-			size_t client_info_size, void *client_info)
-{
-	int ret = 0;
-	struct cal_block_data *cal_block;
-	struct audio_cal_type_alloc *alloc_data = data;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (data_size < sizeof(struct audio_cal_type_alloc)) {
-		pr_err("%s: data_size of %zd does not equal alloc struct size of %zd!\n",
-			__func__, data_size,
-		       sizeof(struct audio_cal_type_alloc));
-		ret = -EINVAL;
-		goto done;
-	}
-	if ((client_info_size > 0) && (client_info == NULL)) {
-		pr_err("%s: User info pointer is NULL but size is %zd!\n",
-			__func__, client_info_size);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (alloc_data->cal_data.mem_handle < 0) {
-		pr_err("%s: mem_handle %d invalid!\n",
-			__func__, alloc_data->cal_data.mem_handle);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&cal_type->lock);
-
-	cal_block = get_matching_cal_block(cal_type,
-		data);
-	if (cal_block != NULL) {
-		ret = unmap_memory(cal_type, cal_block);
-		if (ret < 0)
-			goto err;
-		ret = realloc_memory(cal_block);
-		if (ret < 0)
-			goto err;
-	} else {
-		cal_block = create_cal_block(cal_type,
-			(struct audio_cal_type_basic *)alloc_data,
-			client_info_size, client_info);
-		if (cal_block == NULL) {
-			pr_err("%s: create_cal_block failed for %d!\n",
-				__func__, alloc_data->cal_data.mem_handle);
-			ret = -EINVAL;
-			goto err;
-		}
-	}
-
-	ret = map_memory(cal_type, cal_block);
-	if (ret < 0)
-		goto err;
-err:
-	mutex_unlock(&cal_type->lock);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(cal_utils_alloc_cal);
-
-/**
- * cal_utils_dealloc_cal
- *
- * @data_size: size of data to allocate
- * @data: data pointer
- * @cal_type: pointer to the cal type
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int cal_utils_dealloc_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type)
-{
-	int ret = 0;
-	struct cal_block_data *cal_block;
-	struct audio_cal_type_dealloc *dealloc_data = data;
-
-	pr_debug("%s\n", __func__);
-
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (data_size < sizeof(struct audio_cal_type_dealloc)) {
-		pr_err("%s: data_size of %zd does not equal struct size of %zd!\n",
-			__func__, data_size,
-			sizeof(struct audio_cal_type_dealloc));
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((dealloc_data->cal_data.mem_handle == -1) &&
-		(dealloc_data->cal_hdr.buffer_number == ALL_CAL_BLOCKS)) {
-		destroy_all_cal_blocks(cal_type);
-		goto done;
-	}
-
-	if (dealloc_data->cal_data.mem_handle < 0) {
-		pr_err("%s: mem_handle %d invalid!\n",
-			__func__, dealloc_data->cal_data.mem_handle);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&cal_type->lock);
-	cal_block = get_matching_cal_block(
-		cal_type,
-		data);
-	if (cal_block == NULL) {
-		pr_err("%s: allocation does not exist for %d!\n",
-			__func__, dealloc_data->cal_data.mem_handle);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	ret = unmap_memory(cal_type, cal_block);
-	if (ret < 0)
-		goto err;
-
-	delete_cal_block(cal_block);
-err:
-	mutex_unlock(&cal_type->lock);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(cal_utils_dealloc_cal);
-
-/**
- * cal_utils_set_cal
- *
- * @data_size: size of data to allocate
- * @data: data pointer
- * @cal_type: pointer to the cal type
- * @client_info_size: client info size
- * @client_info: pointer to client info
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int cal_utils_set_cal(size_t data_size, void *data,
-			struct cal_type_data *cal_type,
-			size_t client_info_size, void *client_info)
-{
-	int ret = 0;
-	struct cal_block_data *cal_block;
-	struct audio_cal_type_basic *basic_data = data;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type == NULL) {
-		pr_err("%s: cal_type is NULL!\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((client_info_size > 0) && (client_info == NULL)) {
-		pr_err("%s: User info pointer is NULL but size is %zd!\n",
-			__func__, client_info_size);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((data_size > get_user_cal_type_size(
-		cal_type->info.reg.cal_type)) || (data_size < 0)) {
-		pr_err("%s: cal_type %d, data_size of %zd is invalid, expecting %zd!\n",
-			__func__, cal_type->info.reg.cal_type, data_size,
-			get_user_cal_type_size(cal_type->info.reg.cal_type));
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&cal_type->lock);
-	cal_block = get_matching_cal_block(
-		cal_type,
-		data);
-	if (cal_block == NULL) {
-		if (basic_data->cal_data.mem_handle > 0) {
-			pr_err("%s: allocation does not exist for %d!\n",
-				__func__, basic_data->cal_data.mem_handle);
-			ret = -EINVAL;
-			goto err;
-		} else {
-			cal_block = create_cal_block(
-				cal_type,
-				basic_data,
-				client_info_size, client_info);
-			if (cal_block == NULL) {
-				pr_err("%s: create_cal_block failed for cal type %d!\n",
-					__func__,
-				       cal_type->info.reg.cal_type);
-				ret = -EINVAL;
-				goto err;
-			}
-		}
-	}
-
-	ret = map_memory(cal_type, cal_block);
-	if (ret < 0)
-		goto err;
-
-	cal_block->cal_data.size = basic_data->cal_data.cal_size;
-
-	if (client_info_size > 0) {
-		memcpy(cal_block->client_info,
-			client_info,
-			client_info_size);
-	}
-
-	memcpy(cal_block->cal_info,
-		((uint8_t *)data + sizeof(struct audio_cal_type_basic)),
-		data_size - sizeof(struct audio_cal_type_basic));
-
-err:
-	mutex_unlock(&cal_type->lock);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(cal_utils_set_cal);
diff --git a/sound/soc/msm/qdsp6v2/audio_calibration.c b/sound/soc/msm/qdsp6v2/audio_calibration.c
deleted file mode 100644
index d709b09..0000000
--- a/sound/soc/msm/qdsp6v2/audio_calibration.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/mutex.h>
-#include <linux/msm_ion.h>
-#include <linux/msm_audio_ion.h>
-#include <sound/audio_calibration.h>
-#include <sound/audio_cal_utils.h>
-
-struct audio_cal_client_info {
-	struct list_head		list;
-	struct audio_cal_callbacks	*callbacks;
-};
-
-struct audio_cal_info {
-	struct mutex			common_lock;
-	struct mutex			cal_mutex[MAX_CAL_TYPES];
-	struct list_head		client_info[MAX_CAL_TYPES];
-	int				ref_count;
-};
-
-static struct audio_cal_info	audio_cal;
-
-
-static bool callbacks_are_equal(struct audio_cal_callbacks *callback1,
-				struct audio_cal_callbacks *callback2)
-{
-	bool ret = true;
-	struct audio_cal_callbacks *call1 = callback1;
-	struct audio_cal_callbacks *call2 = callback2;
-
-	pr_debug("%s\n", __func__);
-
-	if ((call1 == NULL) && (call2 == NULL))
-		ret = true;
-	else if ((call1 == NULL) || (call2 == NULL))
-		ret = false;
-	else if ((call1->alloc != call2->alloc) ||
-		(call1->dealloc != call2->dealloc) ||
-		(call1->pre_cal != call2->pre_cal) ||
-		(call1->set_cal != call2->set_cal) ||
-		(call1->get_cal != call2->get_cal) ||
-		(call1->post_cal != call2->post_cal))
-		ret = false;
-	return ret;
-}
-
-int audio_cal_deregister(int num_cal_types,
-			 struct audio_cal_reg *reg_data)
-{
-	int ret = 0;
-	int i = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (reg_data == NULL) {
-		pr_err("%s: reg_data is NULL!\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if ((num_cal_types <= 0) ||
-		(num_cal_types > MAX_CAL_TYPES)) {
-		pr_err("%s: num_cal_types of %d is Invalid!\n",
-			__func__, num_cal_types);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for (; i < num_cal_types; i++) {
-		if ((reg_data[i].cal_type < 0) ||
-			(reg_data[i].cal_type >= MAX_CAL_TYPES)) {
-			pr_err("%s: cal type %d at index %d is Invalid!\n",
-				__func__, reg_data[i].cal_type, i);
-			ret = -EINVAL;
-			continue;
-		}
-
-		mutex_lock(&audio_cal.cal_mutex[reg_data[i].cal_type]);
-		list_for_each_safe(ptr, next,
-			&audio_cal.client_info[reg_data[i].cal_type]) {
-
-			client_info_node = list_entry(ptr,
-				struct audio_cal_client_info, list);
-			if (callbacks_are_equal(client_info_node->callbacks,
-				&reg_data[i].callbacks)) {
-				list_del(&client_info_node->list);
-				kfree(client_info_node->callbacks);
-				client_info_node->callbacks = NULL;
-				kfree(client_info_node);
-				client_info_node = NULL;
-				break;
-			}
-		}
-		mutex_unlock(&audio_cal.cal_mutex[reg_data[i].cal_type]);
-	}
-done:
-	return ret;
-}
-
-
-int audio_cal_register(int num_cal_types,
-			 struct audio_cal_reg *reg_data)
-{
-	int ret = 0;
-	int i = 0;
-	struct audio_cal_client_info *client_info_node = NULL;
-	struct audio_cal_callbacks *callback_node = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (reg_data == NULL) {
-		pr_err("%s: callbacks are NULL!\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if ((num_cal_types <= 0) ||
-		(num_cal_types > MAX_CAL_TYPES)) {
-		pr_err("%s: num_cal_types of %d is Invalid!\n",
-			__func__, num_cal_types);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for (; i < num_cal_types; i++) {
-		if ((reg_data[i].cal_type < 0) ||
-			(reg_data[i].cal_type >= MAX_CAL_TYPES)) {
-			pr_err("%s: cal type %d at index %d is Invalid!\n",
-				__func__, reg_data[i].cal_type, i);
-			ret = -EINVAL;
-			goto err;
-		}
-
-		client_info_node = kmalloc(sizeof(*client_info_node),
-			GFP_KERNEL);
-		if (client_info_node == NULL) {
-			ret = -ENOMEM;
-			goto err;
-		}
-		INIT_LIST_HEAD(&client_info_node->list);
-
-		callback_node = kmalloc(sizeof(*callback_node),
-			GFP_KERNEL);
-		if (callback_node == NULL) {
-			ret = -ENOMEM;
-			goto err;
-		}
-
-		memcpy(callback_node, &reg_data[i].callbacks,
-			sizeof(*callback_node));
-		client_info_node->callbacks = callback_node;
-
-		mutex_lock(&audio_cal.cal_mutex[reg_data[i].cal_type]);
-		list_add_tail(&client_info_node->list,
-			&audio_cal.client_info[reg_data[i].cal_type]);
-		mutex_unlock(&audio_cal.cal_mutex[reg_data[i].cal_type]);
-	}
-done:
-	return ret;
-err:
-	audio_cal_deregister(num_cal_types, reg_data);
-	return ret;
-}
-
-static int call_allocs(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->alloc == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			alloc(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: alloc failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int call_deallocs(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s cal type %d\n", __func__, cal_type);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->dealloc == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			dealloc(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: dealloc failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int call_pre_cals(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s cal type %d\n", __func__, cal_type);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->pre_cal == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			pre_cal(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: pre_cal failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int call_post_cals(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s cal type %d\n", __func__, cal_type);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->post_cal == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			post_cal(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: post_cal failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int call_set_cals(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s cal type %d\n", __func__, cal_type);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->set_cal == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			set_cal(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: set_cal failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int call_get_cals(int32_t cal_type,
-				size_t cal_type_size, void *data)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node = NULL;
-
-	pr_debug("%s cal type %d\n", __func__, cal_type);
-
-	list_for_each_safe(ptr, next,
-			&audio_cal.client_info[cal_type]) {
-
-		client_info_node = list_entry(ptr,
-			struct audio_cal_client_info, list);
-
-		if (client_info_node->callbacks->get_cal == NULL)
-			continue;
-
-		ret2 = client_info_node->callbacks->
-			get_cal(cal_type, cal_type_size, data);
-		if (ret2 < 0) {
-			pr_err("%s: get_cal failed!\n", __func__);
-			ret = ret2;
-		}
-	}
-	return ret;
-}
-
-static int audio_cal_open(struct inode *inode, struct file *f)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&audio_cal.common_lock);
-	audio_cal.ref_count++;
-	mutex_unlock(&audio_cal.common_lock);
-
-	return ret;
-}
-
-static void dealloc_all_clients(void)
-{
-	int i = 0;
-	struct audio_cal_type_dealloc dealloc_data;
-
-	pr_debug("%s\n", __func__);
-
-	dealloc_data.cal_hdr.version = VERSION_0_0;
-	dealloc_data.cal_hdr.buffer_number = ALL_CAL_BLOCKS;
-	dealloc_data.cal_data.mem_handle = -1;
-
-	for (; i < MAX_CAL_TYPES; i++)
-		call_deallocs(i, sizeof(dealloc_data), &dealloc_data);
-}
-
-static int audio_cal_release(struct inode *inode, struct file *f)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&audio_cal.common_lock);
-	audio_cal.ref_count--;
-	if (audio_cal.ref_count <= 0) {
-		audio_cal.ref_count = 0;
-		dealloc_all_clients();
-	}
-	mutex_unlock(&audio_cal.common_lock);
-
-	return ret;
-}
-
-static long audio_cal_shared_ioctl(struct file *file, unsigned int cmd,
-							void __user *arg)
-{
-	int ret = 0;
-	int32_t size;
-	struct audio_cal_basic *data = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	switch (cmd) {
-	case AUDIO_ALLOCATE_CALIBRATION:
-	case AUDIO_DEALLOCATE_CALIBRATION:
-	case AUDIO_PREPARE_CALIBRATION:
-	case AUDIO_SET_CALIBRATION:
-	case AUDIO_GET_CALIBRATION:
-	case AUDIO_POST_CALIBRATION:
-		break;
-	default:
-		pr_err("%s: ioctl not found!\n", __func__);
-		ret = -EFAULT;
-		goto done;
-	}
-
-	if (copy_from_user(&size, (void *)arg, sizeof(size))) {
-		pr_err("%s: Could not copy size value from user\n", __func__);
-		ret = -EFAULT;
-		goto done;
-	} else if ((size < sizeof(struct audio_cal_basic))
-		|| (size > MAX_IOCTL_CMD_SIZE)) {
-		pr_err("%s: Invalid size sent to driver: %d, max size is %d, min size is %zd\n",
-			__func__, size, MAX_IOCTL_CMD_SIZE,
-			sizeof(struct audio_cal_basic));
-		ret = -EINVAL;
-		goto done;
-	}
-
-	data = kmalloc(size, GFP_KERNEL);
-	if (data == NULL) {
-		ret = -ENOMEM;
-		goto done;
-	} else if (copy_from_user(data, (void *)arg, size)) {
-		pr_err("%s: Could not copy data from user\n",
-			__func__);
-		ret = -EFAULT;
-		goto done;
-	} else if ((data->hdr.cal_type < 0) ||
-		(data->hdr.cal_type >= MAX_CAL_TYPES)) {
-		pr_err("%s: cal type %d is Invalid!\n",
-			__func__, data->hdr.cal_type);
-		ret = -EINVAL;
-		goto done;
-	} else if ((data->hdr.cal_type_size <
-		sizeof(struct audio_cal_type_basic)) ||
-		(data->hdr.cal_type_size >
-		get_user_cal_type_size(data->hdr.cal_type))) {
-		pr_err("%s: cal type size %d is Invalid! Max is %zd!\n",
-			__func__, data->hdr.cal_type_size,
-			get_user_cal_type_size(data->hdr.cal_type));
-		ret = -EINVAL;
-		goto done;
-	} else if (data->cal_type.cal_hdr.buffer_number < 0) {
-		pr_err("%s: cal type %d Invalid buffer number %d!\n",
-			__func__, data->hdr.cal_type,
-			data->cal_type.cal_hdr.buffer_number);
-		ret = -EINVAL;
-		goto done;
-	} else if ((data->hdr.cal_type_size + sizeof(data->hdr)) > size) {
-		pr_err("%s: cal type hdr size %zd + cal type size %d is greater than user buffer size %d\n",
-			__func__, sizeof(data->hdr), data->hdr.cal_type_size,
-			size);
-		ret = -EFAULT;
-		goto done;
-	}
-
-
-	mutex_lock(&audio_cal.cal_mutex[data->hdr.cal_type]);
-
-	switch (cmd) {
-	case AUDIO_ALLOCATE_CALIBRATION:
-		ret = call_allocs(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	case AUDIO_DEALLOCATE_CALIBRATION:
-		ret = call_deallocs(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	case AUDIO_PREPARE_CALIBRATION:
-		ret = call_pre_cals(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	case AUDIO_SET_CALIBRATION:
-		ret = call_set_cals(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	case AUDIO_GET_CALIBRATION:
-		ret = call_get_cals(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	case AUDIO_POST_CALIBRATION:
-		ret = call_post_cals(data->hdr.cal_type,
-			data->hdr.cal_type_size, &data->cal_type);
-		break;
-	}
-
-	if (cmd == AUDIO_GET_CALIBRATION) {
-		if (data->hdr.cal_type_size == 0)
-			goto unlock;
-		if (data == NULL)
-			goto unlock;
-		if (copy_to_user(arg, data,
-			sizeof(data->hdr) + data->hdr.cal_type_size)) {
-			pr_err("%s: Could not copy cal type to user\n",
-				__func__);
-			ret = -EFAULT;
-			goto unlock;
-		}
-	}
-
-unlock:
-	mutex_unlock(&audio_cal.cal_mutex[data->hdr.cal_type]);
-done:
-	kfree(data);
-	return ret;
-}
-
-static long audio_cal_ioctl(struct file *f,
-		unsigned int cmd, unsigned long arg)
-{
-	return audio_cal_shared_ioctl(f, cmd, (void __user *)arg);
-}
-
-#ifdef CONFIG_COMPAT
-
-#define AUDIO_ALLOCATE_CALIBRATION32	_IOWR(CAL_IOCTL_MAGIC, \
-							200, compat_uptr_t)
-#define AUDIO_DEALLOCATE_CALIBRATION32	_IOWR(CAL_IOCTL_MAGIC, \
-							201, compat_uptr_t)
-#define AUDIO_PREPARE_CALIBRATION32	_IOWR(CAL_IOCTL_MAGIC, \
-							202, compat_uptr_t)
-#define AUDIO_SET_CALIBRATION32		_IOWR(CAL_IOCTL_MAGIC, \
-							203, compat_uptr_t)
-#define AUDIO_GET_CALIBRATION32		_IOWR(CAL_IOCTL_MAGIC, \
-							204, compat_uptr_t)
-#define AUDIO_POST_CALIBRATION32	_IOWR(CAL_IOCTL_MAGIC, \
-							205, compat_uptr_t)
-
-static long audio_cal_compat_ioctl(struct file *f,
-		unsigned int cmd, unsigned long arg)
-{
-	unsigned int cmd64;
-	int ret = 0;
-
-	switch (cmd) {
-	case AUDIO_ALLOCATE_CALIBRATION32:
-		cmd64 = AUDIO_ALLOCATE_CALIBRATION;
-		break;
-	case AUDIO_DEALLOCATE_CALIBRATION32:
-		cmd64 = AUDIO_DEALLOCATE_CALIBRATION;
-		break;
-	case AUDIO_PREPARE_CALIBRATION32:
-		cmd64 = AUDIO_PREPARE_CALIBRATION;
-		break;
-	case AUDIO_SET_CALIBRATION32:
-		cmd64 = AUDIO_SET_CALIBRATION;
-		break;
-	case AUDIO_GET_CALIBRATION32:
-		cmd64 = AUDIO_GET_CALIBRATION;
-		break;
-	case AUDIO_POST_CALIBRATION32:
-		cmd64 = AUDIO_POST_CALIBRATION;
-		break;
-	default:
-		pr_err("%s: ioctl not found!\n", __func__);
-		ret = -EFAULT;
-		goto done;
-	}
-
-	ret = audio_cal_shared_ioctl(f, cmd64, compat_ptr(arg));
-done:
-	return ret;
-}
-#endif
-
-static const struct file_operations audio_cal_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_cal_open,
-	.release = audio_cal_release,
-	.unlocked_ioctl = audio_cal_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl =   audio_cal_compat_ioctl,
-#endif
-};
-
-struct miscdevice audio_cal_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_cal",
-	.fops	= &audio_cal_fops,
-};
-
-static int __init audio_cal_init(void)
-{
-	int i = 0;
-
-	pr_debug("%s\n", __func__);
-
-	memset(&audio_cal, 0, sizeof(audio_cal));
-	mutex_init(&audio_cal.common_lock);
-	for (; i < MAX_CAL_TYPES; i++) {
-		INIT_LIST_HEAD(&audio_cal.client_info[i]);
-		mutex_init(&audio_cal.cal_mutex[i]);
-	}
-
-	return misc_register(&audio_cal_misc);
-}
-
-static void __exit audio_cal_exit(void)
-{
-	int i = 0;
-	struct list_head *ptr, *next;
-	struct audio_cal_client_info *client_info_node;
-
-	for (; i < MAX_CAL_TYPES; i++) {
-		list_for_each_safe(ptr, next,
-			&audio_cal.client_info[i]) {
-			client_info_node = list_entry(ptr,
-				struct audio_cal_client_info, list);
-			list_del(&client_info_node->list);
-			kfree(client_info_node->callbacks);
-			client_info_node->callbacks = NULL;
-			kfree(client_info_node);
-			client_info_node = NULL;
-		}
-	}
-}
-
-subsys_initcall(audio_cal_init);
-module_exit(audio_cal_exit);
-
-MODULE_DESCRIPTION("SoC QDSP6v2 Audio Calibration driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/audio_slimslave.c b/sound/soc/msm/qdsp6v2/audio_slimslave.c
deleted file mode 100644
index e9ecfd5..0000000
--- a/sound/soc/msm/qdsp6v2/audio_slimslave.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/mutex.h>
-#include <linux/miscdevice.h>
-#include <sound/audio_slimslave.h>
-#include <linux/slimbus/slimbus.h>
-#include <linux/pm_runtime.h>
-
-static struct slim_device *slim;
-static int vote_count;
-struct mutex suspend_lock;
-bool suspend;
-
-static int audio_slim_open(struct inode *inode, struct file *file)
-{
-	pr_debug("%s:\n", __func__);
-
-	if (vote_count) {
-		pr_debug("%s: unvote: vote_count=%d\n", __func__, vote_count);
-		pm_runtime_mark_last_busy(slim->dev.parent);
-		pm_runtime_put(slim->dev.parent);
-		vote_count--;
-	}
-	return 0;
-};
-
-static int audio_slim_release(struct inode *inode, struct file *file)
-{
-	pr_debug("%s:\n", __func__);
-
-	if (vote_count) {
-		pr_debug("%s: unvote: vote_count=%d\n", __func__, vote_count);
-		pm_runtime_mark_last_busy(slim->dev.parent);
-		pm_runtime_put(slim->dev.parent);
-		vote_count--;
-	} else {
-		pr_debug("%s: vote: vote_count=%d\n", __func__, vote_count);
-		pm_runtime_get_sync(slim->dev.parent);
-		vote_count++;
-	}
-	return 0;
-};
-
-static long audio_slim_ioctl(struct file *file, unsigned int cmd,
-			     unsigned long u_arg)
-{
-	switch (cmd) {
-	case AUDIO_SLIMSLAVE_VOTE:
-		mutex_lock(&suspend_lock);
-		if (!vote_count && !suspend) {
-			pr_debug("%s:AUDIO_SLIMSLAVE_VOTE\n", __func__);
-			pm_runtime_get_sync(slim->dev.parent);
-			vote_count++;
-		} else {
-			pr_err("%s:Invalid vote: vote_count=%d suspend=%d\n",
-				 __func__, vote_count, suspend);
-		}
-		mutex_unlock(&suspend_lock);
-		break;
-	case AUDIO_SLIMSLAVE_UNVOTE:
-		mutex_lock(&suspend_lock);
-		if (vote_count && !suspend) {
-			pr_debug("%s:AUDIO_SLIMSLAVE_UNVOTE\n", __func__);
-			pm_runtime_mark_last_busy(slim->dev.parent);
-			pm_runtime_put(slim->dev.parent);
-			vote_count--;
-		} else {
-			pr_err("%s:Invalid unvote: vote_count=%d suspend=%d\n",
-				 __func__, vote_count, suspend);
-		}
-		mutex_unlock(&suspend_lock);
-		break;
-	default:
-		pr_debug("%s: Invalid ioctl cmd: %d\n", __func__, cmd);
-		break;
-	}
-	return 0;
-}
-
-static const struct file_operations audio_slimslave_fops = {
-	.open =                 audio_slim_open,
-	.unlocked_ioctl =       audio_slim_ioctl,
-	.release =              audio_slim_release,
-};
-
-struct miscdevice audio_slimslave_misc = {
-	.minor  =       MISC_DYNAMIC_MINOR,
-	.name   =       AUDIO_SLIMSLAVE_IOCTL_NAME,
-	.fops   =       &audio_slimslave_fops,
-};
-
-static int audio_slimslave_probe(struct slim_device *audio_slim)
-{
-	pr_debug("%s:\n", __func__);
-
-	mutex_init(&suspend_lock);
-	suspend = false;
-	slim = audio_slim;
-	misc_register(&audio_slimslave_misc);
-	return 0;
-}
-
-static int audio_slimslave_remove(struct slim_device *audio_slim)
-{
-	pr_debug("%s:\n", __func__);
-
-	misc_deregister(&audio_slimslave_misc);
-	return 0;
-}
-
-static int audio_slimslave_resume(struct slim_device *audio_slim)
-{
-	pr_debug("%s:\n", __func__);
-
-	mutex_lock(&suspend_lock);
-	suspend = false;
-	mutex_unlock(&suspend_lock);
-	return 0;
-}
-
-static int audio_slimslave_suspend(struct slim_device *audio_slim,
-				   pm_message_t pmesg)
-{
-	pr_debug("%s:\n", __func__);
-
-	mutex_lock(&suspend_lock);
-	suspend = true;
-	mutex_unlock(&suspend_lock);
-	return 0;
-}
-
-static const struct slim_device_id audio_slimslave_dt_match[] = {
-	{"audio-slimslave", 0},
-	{}
-};
-
-static struct slim_driver audio_slimslave_driver = {
-	.driver = {
-		.name = "audio-slimslave",
-		.owner = THIS_MODULE,
-	},
-	.probe = audio_slimslave_probe,
-	.remove = audio_slimslave_remove,
-	.id_table = audio_slimslave_dt_match,
-	.resume = audio_slimslave_resume,
-	.suspend = audio_slimslave_suspend,
-};
-
-static int __init audio_slimslave_init(void)
-{
-	return slim_driver_register(&audio_slimslave_driver);
-}
-module_init(audio_slimslave_init);
-
-static void __exit audio_slimslave_exit(void)
-{
-
-}
-module_exit(audio_slimslave_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("Audio side Slimbus slave driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-audio-effects-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-audio-effects-q6-v2.c
deleted file mode 100644
index 9b845ee..0000000
--- a/sound/soc/msm/qdsp6v2/msm-audio-effects-q6-v2.c
+++ /dev/null
@@ -1,1378 +0,0 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/slab.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/q6asm-v2.h>
-#include <sound/compress_params.h>
-#include <sound/msm-audio-effects-q6-v2.h>
-#include <sound/devdep_params.h>
-
-#define MAX_ENABLE_CMD_SIZE 32
-
-#define GET_NEXT(ptr, upper_limit, rc)                                  \
-({                                                                      \
-	if (((ptr) + 1) > (upper_limit)) {                              \
-		pr_err("%s: param list out of boundary\n", __func__);   \
-		(rc) = -EINVAL;                                         \
-	}                                                               \
-	((rc) == 0) ? *(ptr)++ :  -EINVAL;                              \
-})
-
-#define CHECK_PARAM_LEN(len, max_len, tag, rc)                          \
-do {                                                                    \
-	if ((len) > (max_len)) {                                        \
-		pr_err("%s: params length overflows\n", (tag));         \
-		(rc) = -EINVAL;                                         \
-	}                                                               \
-} while (0)
-
-
-bool msm_audio_effects_is_effmodule_supp_in_top(int effect_module,
-						int topology)
-{
-	switch (effect_module) {
-	case VIRTUALIZER_MODULE:
-	case REVERB_MODULE:
-	case BASS_BOOST_MODULE:
-	case PBE_MODULE:
-	case EQ_MODULE:
-		switch (topology) {
-		case ASM_STREAM_POSTPROC_TOPO_ID_SA_PLUS:
-			return true;
-		default:
-			return false;
-		}
-	default:
-		return false;
-	}
-}
-
-int msm_audio_effects_enable_extn(struct audio_client *ac,
-				struct msm_nt_eff_all_config *effects,
-				bool flag)
-{
-	uint32_t updt_params[MAX_ENABLE_CMD_SIZE] = {0};
-	uint32_t params_length;
-	int rc = 0;
-
-	pr_debug("%s\n", __func__);
-	if (!ac) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params_length = 0;
-	updt_params[0] = AUDPROC_MODULE_ID_VIRTUALIZER;
-	updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
-	updt_params[2] = VIRTUALIZER_ENABLE_PARAM_SZ;
-	updt_params[3] = flag;
-	params_length += COMMAND_PAYLOAD_SZ + VIRTUALIZER_ENABLE_PARAM_SZ;
-	if (effects->virtualizer.enable_flag)
-		q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
-					params_length);
-	memset(updt_params, 0, MAX_ENABLE_CMD_SIZE);
-	params_length = 0;
-	updt_params[0] = AUDPROC_MODULE_ID_BASS_BOOST;
-	updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
-	updt_params[2] = BASS_BOOST_ENABLE_PARAM_SZ;
-	updt_params[3] = flag;
-	params_length += COMMAND_PAYLOAD_SZ + BASS_BOOST_ENABLE_PARAM_SZ;
-	if (effects->bass_boost.enable_flag)
-		q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
-					params_length);
-	memset(updt_params, 0, MAX_ENABLE_CMD_SIZE);
-	params_length = 0;
-	updt_params[0] = AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
-	updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
-	updt_params[2] = EQ_ENABLE_PARAM_SZ;
-	updt_params[3] = flag;
-	params_length += COMMAND_PAYLOAD_SZ + EQ_ENABLE_PARAM_SZ;
-	if (effects->equalizer.enable_flag)
-		q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
-					params_length);
-	return rc;
-}
-
-int msm_audio_effects_virtualizer_handler(struct audio_client *ac,
-				struct virtualizer_params *virtualizer,
-				long *values)
-{
-	long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	char *params = NULL;
-	int rc = 0;
-	int devices = GET_NEXT(values, param_max_offset, rc);
-	int num_commands = GET_NEXT(values, param_max_offset, rc);
-	int *updt_params, i, prev_enable_flag;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-
-	pr_debug("%s\n", __func__);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	pr_debug("%s: device: %d\n", __func__, devices);
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		switch (command_id) {
-		case VIRTUALIZER_ENABLE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("VIRT ENABLE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			prev_enable_flag = virtualizer->enable_flag;
-			virtualizer->enable_flag =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s:VIRT ENABLE prev:%d, new:%d\n", __func__,
-				prev_enable_flag, virtualizer->enable_flag);
-			if (prev_enable_flag != virtualizer->enable_flag) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					VIRTUALIZER_ENABLE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VIRT ENABLE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-				AUDPROC_MODULE_ID_VIRTUALIZER;
-				*updt_params++ =
-				AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE;
-				*updt_params++ =
-				VIRTUALIZER_ENABLE_PARAM_SZ;
-				*updt_params++ =
-				virtualizer->enable_flag;
-			}
-			break;
-		case VIRTUALIZER_STRENGTH:
-			if (length != 1 || index_offset != 0) {
-				pr_err("VIRT STRENGTH:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			virtualizer->strength =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: VIRT STRENGTH val: %d\n",
-					__func__, virtualizer->strength);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					VIRTUALIZER_STRENGTH_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VIRT STRENGTH", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_VIRTUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH;
-				*updt_params++ =
-					VIRTUALIZER_STRENGTH_PARAM_SZ;
-				*updt_params++ =
-					virtualizer->strength;
-			}
-			break;
-		case VIRTUALIZER_OUT_TYPE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("VIRT OUT_TYPE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			virtualizer->out_type =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: VIRT OUT_TYPE val:%d\n",
-				__func__, virtualizer->out_type);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					VIRTUALIZER_OUT_TYPE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VIRT OUT_TYPE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_VIRTUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE;
-				*updt_params++ =
-					VIRTUALIZER_OUT_TYPE_PARAM_SZ;
-				*updt_params++ =
-					virtualizer->out_type;
-			}
-			break;
-		case VIRTUALIZER_GAIN_ADJUST:
-			if (length != 1 || index_offset != 0) {
-				pr_err("VIRT GAIN_ADJUST: invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			virtualizer->gain_adjust =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: VIRT GAIN_ADJUST val:%d\n",
-				__func__, virtualizer->gain_adjust);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VIRT GAIN_ADJUST", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-				AUDPROC_MODULE_ID_VIRTUALIZER;
-				*updt_params++ =
-				AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST;
-				*updt_params++ =
-				VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
-				*updt_params++ =
-				virtualizer->gain_adjust;
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command to set config\n", __func__);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-	else
-		pr_debug("%s: did not send pp params\n", __func__);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-int msm_audio_effects_reverb_handler(struct audio_client *ac,
-				     struct reverb_params *reverb,
-				     long *values)
-{
-	long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	char *params = NULL;
-	int rc = 0;
-	int devices = GET_NEXT(values, param_max_offset, rc);
-	int num_commands = GET_NEXT(values, param_max_offset, rc);
-	int *updt_params, i, prev_enable_flag;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-
-	pr_debug("%s\n", __func__);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	pr_debug("%s: device: %d\n", __func__, devices);
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		switch (command_id) {
-		case REVERB_ENABLE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_ENABLE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			prev_enable_flag = reverb->enable_flag;
-			reverb->enable_flag =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s:REVERB_ENABLE prev:%d,new:%d\n", __func__,
-					prev_enable_flag, reverb->enable_flag);
-			if (prev_enable_flag != reverb->enable_flag) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_ENABLE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_ENABLE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_ENABLE;
-				*updt_params++ =
-					REVERB_ENABLE_PARAM_SZ;
-				*updt_params++ =
-					reverb->enable_flag;
-			}
-			break;
-		case REVERB_MODE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_MODE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->mode =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_MODE val:%d\n",
-				__func__, reverb->mode);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_MODE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_MODE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_MODE;
-				*updt_params++ =
-					REVERB_MODE_PARAM_SZ;
-				*updt_params++ =
-					reverb->mode;
-			}
-			break;
-		case REVERB_PRESET:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_PRESET:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->preset =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_PRESET val:%d\n",
-					__func__, reverb->preset);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_PRESET_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_PRESET", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_PRESET;
-				*updt_params++ =
-					REVERB_PRESET_PARAM_SZ;
-				*updt_params++ =
-					reverb->preset;
-			}
-			break;
-		case REVERB_WET_MIX:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_WET_MIX:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->wet_mix =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_WET_MIX val:%d\n",
-				__func__, reverb->wet_mix);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_WET_MIX_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_WET_MIX", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_WET_MIX;
-				*updt_params++ =
-					REVERB_WET_MIX_PARAM_SZ;
-				*updt_params++ =
-					reverb->wet_mix;
-			}
-			break;
-		case REVERB_GAIN_ADJUST:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_GAIN_ADJUST:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->gain_adjust =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_GAIN_ADJUST val:%d\n",
-					__func__, reverb->gain_adjust);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_GAIN_ADJUST_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_GAIN_ADJUST", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST;
-				*updt_params++ =
-					REVERB_GAIN_ADJUST_PARAM_SZ;
-				*updt_params++ =
-					reverb->gain_adjust;
-			}
-			break;
-		case REVERB_ROOM_LEVEL:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_ROOM_LEVEL:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->room_level =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_ROOM_LEVEL val:%d\n",
-				__func__, reverb->room_level);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_ROOM_LEVEL_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_ROOM_LEVEL", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL;
-				*updt_params++ =
-					REVERB_ROOM_LEVEL_PARAM_SZ;
-				*updt_params++ =
-					reverb->room_level;
-			}
-			break;
-		case REVERB_ROOM_HF_LEVEL:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_ROOM_HF_LEVEL:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->room_hf_level =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_ROOM_HF_LEVEL val%d\n",
-				__func__, reverb->room_hf_level);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_ROOM_HF_LEVEL_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_ROOM_HF_LEVEL", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL;
-				*updt_params++ =
-					REVERB_ROOM_HF_LEVEL_PARAM_SZ;
-				*updt_params++ =
-					reverb->room_hf_level;
-			}
-			break;
-		case REVERB_DECAY_TIME:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_DECAY_TIME:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->decay_time =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_DECAY_TIME val:%d\n",
-				__func__, reverb->decay_time);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_DECAY_TIME_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_DECAY_TIME", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_DECAY_TIME;
-				*updt_params++ =
-					REVERB_DECAY_TIME_PARAM_SZ;
-				*updt_params++ =
-					reverb->decay_time;
-			}
-			break;
-		case REVERB_DECAY_HF_RATIO:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_DECAY_HF_RATIOinvalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->decay_hf_ratio =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_DECAY_HF_RATIO val%d\n",
-				__func__, reverb->decay_hf_ratio);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_DECAY_HF_RATIO_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_DECAY_HF_RATIO", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO;
-				*updt_params++ =
-					REVERB_DECAY_HF_RATIO_PARAM_SZ;
-				*updt_params++ =
-					reverb->decay_hf_ratio;
-			}
-			break;
-		case REVERB_REFLECTIONS_LEVEL:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_REFLECTION_LVLinvalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->reflections_level =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_REFLECTIONS_LEVEL val:%d\n",
-				__func__, reverb->reflections_level);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_REFLECTIONS_LEVEL_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_REFLECTIONS_LEVEL", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-				AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-				AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL;
-				*updt_params++ =
-				REVERB_REFLECTIONS_LEVEL_PARAM_SZ;
-				*updt_params++ =
-				reverb->reflections_level;
-			}
-			break;
-		case REVERB_REFLECTIONS_DELAY:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_REFLECTION_DLYinvalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->reflections_delay =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_REFLECTIONS_DELAY val:%d\n",
-				__func__, reverb->reflections_delay);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_REFLECTIONS_DELAY_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_REFLECTIONS_DELAY", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-				AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-				AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY;
-				*updt_params++ =
-				REVERB_REFLECTIONS_DELAY_PARAM_SZ;
-				*updt_params++ =
-				reverb->reflections_delay;
-			}
-			break;
-		case REVERB_LEVEL:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_LEVEL:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->level =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_LEVEL val:%d\n",
-				__func__, reverb->level);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_LEVEL_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_LEVEL", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_LEVEL;
-				*updt_params++ =
-					REVERB_LEVEL_PARAM_SZ;
-				*updt_params++ =
-					reverb->level;
-			}
-			break;
-		case REVERB_DELAY:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_DELAY:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->delay =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s:REVERB_DELAY val:%d\n",
-					__func__, reverb->delay);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_DELAY_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_DELAY", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_DELAY;
-				*updt_params++ =
-					REVERB_DELAY_PARAM_SZ;
-				*updt_params++ =
-					reverb->delay;
-			}
-			break;
-		case REVERB_DIFFUSION:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_DIFFUSION:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->diffusion =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_DIFFUSION val:%d\n",
-				__func__, reverb->diffusion);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_DIFFUSION_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_DIFFUSION", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_DIFFUSION;
-				*updt_params++ =
-					REVERB_DIFFUSION_PARAM_SZ;
-				*updt_params++ =
-					reverb->diffusion;
-			}
-			break;
-		case REVERB_DENSITY:
-			if (length != 1 || index_offset != 0) {
-				pr_err("REVERB_DENSITY:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			reverb->density =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: REVERB_DENSITY val:%d\n",
-				__func__, reverb->density);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					REVERB_DENSITY_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"REVERB_DENSITY", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_REVERB;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_REVERB_DENSITY;
-				*updt_params++ =
-					REVERB_DENSITY_PARAM_SZ;
-				*updt_params++ =
-					reverb->density;
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command to set config\n", __func__);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-	else
-		pr_debug("%s: did not send pp params\n", __func__);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-int msm_audio_effects_bass_boost_handler(struct audio_client *ac,
-					struct bass_boost_params *bass_boost,
-					long *values)
-{
-	long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	char *params = NULL;
-	int rc = 0;
-	int devices = GET_NEXT(values, param_max_offset, rc);
-	int num_commands = GET_NEXT(values, param_max_offset, rc);
-	int *updt_params, i, prev_enable_flag;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-
-	pr_debug("%s\n", __func__);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	pr_debug("%s: device: %d\n", __func__, devices);
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		switch (command_id) {
-		case BASS_BOOST_ENABLE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("BASS_BOOST_ENABLE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			prev_enable_flag = bass_boost->enable_flag;
-			bass_boost->enable_flag =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: BASS_BOOST_ENABLE prev:%d new:%d\n",
-				__func__, prev_enable_flag,
-				bass_boost->enable_flag);
-			if (prev_enable_flag != bass_boost->enable_flag) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					BASS_BOOST_ENABLE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"BASS_BOOST_ENABLE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_BASS_BOOST;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_BASS_BOOST_ENABLE;
-				*updt_params++ =
-					BASS_BOOST_ENABLE_PARAM_SZ;
-				*updt_params++ =
-					bass_boost->enable_flag;
-			}
-			break;
-		case BASS_BOOST_MODE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("BASS_BOOST_MODE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			bass_boost->mode =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: BASS_BOOST_MODE val:%d\n",
-				__func__, bass_boost->mode);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					BASS_BOOST_MODE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"BASS_BOOST_MODE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_BASS_BOOST;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_BASS_BOOST_MODE;
-				*updt_params++ =
-					BASS_BOOST_MODE_PARAM_SZ;
-				*updt_params++ =
-					bass_boost->mode;
-			}
-			break;
-		case BASS_BOOST_STRENGTH:
-			if (length != 1 || index_offset != 0) {
-				pr_err("BASS_BOOST_STRENGTH:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			bass_boost->strength =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: BASS_BOOST_STRENGTH val:%d\n",
-				__func__, bass_boost->strength);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					BASS_BOOST_STRENGTH_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"BASS_BOOST_STRENGTH", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_BASS_BOOST;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH;
-				*updt_params++ =
-					BASS_BOOST_STRENGTH_PARAM_SZ;
-				*updt_params++ =
-					bass_boost->strength;
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command to set config\n", __func__);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-	else
-		pr_debug("%s: did not send pp params\n", __func__);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-int msm_audio_effects_pbe_handler(struct audio_client *ac,
-					struct pbe_params *pbe,
-					long *values)
-{
-	long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	char *params = NULL;
-	int rc = 0;
-	int devices = GET_NEXT(values, param_max_offset, rc);
-	int num_commands = GET_NEXT(values, param_max_offset, rc);
-	int *updt_params, i, j, prev_enable_flag;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-
-	pr_debug("%s\n", __func__);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	pr_debug("%s: device: %d\n", __func__, devices);
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		switch (command_id) {
-		case PBE_ENABLE:
-			pr_debug("%s: PBE_ENABLE\n", __func__);
-			if (length != 1 || index_offset != 0) {
-				pr_err("no valid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			prev_enable_flag = pbe->enable_flag;
-			pbe->enable_flag =
-				GET_NEXT(values, param_max_offset, rc);
-			if (prev_enable_flag != pbe->enable_flag) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					PBE_ENABLE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"PBE_ENABLE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_PBE;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_PBE_ENABLE;
-				*updt_params++ =
-					PBE_ENABLE_PARAM_SZ;
-				*updt_params++ =
-					pbe->enable_flag;
-			}
-			break;
-		case PBE_CONFIG:
-			pr_debug("%s: PBE_PARAM length %u\n", __func__, length);
-			if (length > sizeof(struct pbe_config_t) ||
-				length < PBE_CONFIG_PARAM_LEN ||
-				index_offset != 0) {
-				pr_err("no valid params, len %d\n", length);
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ + length;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"PBE_PARAM", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_PBE;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_PBE_PARAM_CONFIG;
-				*updt_params++ =
-					length;
-				for (j = 0; j < length; ) {
-					j += sizeof(*updt_params);
-					*updt_params++ =
-						GET_NEXT(
-						values,
-						param_max_offset,
-						rc);
-				}
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command to set config\n", __func__);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-int msm_audio_effects_popless_eq_handler(struct audio_client *ac,
-					 struct eq_params *eq,
-					 long *values)
-{
-	long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	char *params = NULL;
-	int rc = 0;
-	int devices = GET_NEXT(values, param_max_offset, rc);
-	int num_commands = GET_NEXT(values, param_max_offset, rc);
-	int *updt_params, i, prev_enable_flag;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-
-	pr_debug("%s\n", __func__);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	pr_debug("%s: device: %d\n", __func__, devices);
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t idx;
-		int j;
-
-		switch (command_id) {
-		case EQ_ENABLE:
-			if (length != 1 || index_offset != 0) {
-				pr_err("EQ_ENABLE:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			prev_enable_flag = eq->enable_flag;
-			eq->enable_flag =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: EQ_ENABLE prev:%d new:%d\n", __func__,
-				prev_enable_flag, eq->enable_flag);
-			if (prev_enable_flag != eq->enable_flag) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					EQ_ENABLE_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"EQ_ENABLE", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_EQ_ENABLE;
-				*updt_params++ =
-					EQ_ENABLE_PARAM_SZ;
-				*updt_params++ =
-					eq->enable_flag;
-			}
-			break;
-		case EQ_CONFIG:
-			if (length < EQ_CONFIG_PARAM_LEN || index_offset != 0) {
-				pr_err("EQ_CONFIG:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			pr_debug("%s: EQ_CONFIG bands:%d, pgain:%d, pset:%d\n",
-				 __func__, eq->config.num_bands,
-				eq->config.eq_pregain, eq->config.preset_id);
-			for (idx = 0; idx < MAX_EQ_BANDS; idx++)
-				eq->per_band_cfg[idx].band_idx = -1;
-			eq->config.eq_pregain =
-				GET_NEXT(values, param_max_offset, rc);
-			eq->config.preset_id =
-				GET_NEXT(values, param_max_offset, rc);
-			eq->config.num_bands =
-				GET_NEXT(values, param_max_offset, rc);
-			if (eq->config.num_bands > MAX_EQ_BANDS) {
-				pr_err("EQ_CONFIG:invalid num of bands\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			if (eq->config.num_bands &&
-			    (((length - EQ_CONFIG_PARAM_LEN)/
-				EQ_CONFIG_PER_BAND_PARAM_LEN)
-				!= eq->config.num_bands)) {
-				pr_err("EQ_CONFIG:invalid length per band\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			for (j = 0; j < eq->config.num_bands; j++) {
-				idx = GET_NEXT(values, param_max_offset, rc);
-				if (idx >= MAX_EQ_BANDS) {
-					pr_err("EQ_CONFIG:invalid band index\n");
-					rc = -EINVAL;
-					goto invalid_config;
-				}
-				eq->per_band_cfg[idx].band_idx = idx;
-				eq->per_band_cfg[idx].filter_type =
-					GET_NEXT(values, param_max_offset, rc);
-				eq->per_band_cfg[idx].freq_millihertz =
-					GET_NEXT(values, param_max_offset, rc);
-				eq->per_band_cfg[idx].gain_millibels =
-					GET_NEXT(values, param_max_offset, rc);
-				eq->per_band_cfg[idx].quality_factor =
-					GET_NEXT(values, param_max_offset, rc);
-			}
-			if (command_config_state == CONFIG_SET) {
-				int config_param_length = EQ_CONFIG_PARAM_SZ +
-					(EQ_CONFIG_PER_BAND_PARAM_SZ*
-					 eq->config.num_bands);
-				params_length += COMMAND_PAYLOAD_SZ +
-						config_param_length;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"EQ_CONFIG", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_EQ_CONFIG;
-				*updt_params++ =
-					config_param_length;
-				*updt_params++ =
-					eq->config.eq_pregain;
-				*updt_params++ =
-					eq->config.preset_id;
-				*updt_params++ =
-					eq->config.num_bands;
-				for (idx = 0; idx < MAX_EQ_BANDS; idx++) {
-					if (eq->per_band_cfg[idx].band_idx < 0)
-						continue;
-					*updt_params++ =
-					eq->per_band_cfg[idx].filter_type;
-					*updt_params++ =
-					eq->per_band_cfg[idx].freq_millihertz;
-					*updt_params++ =
-					eq->per_band_cfg[idx].gain_millibels;
-					*updt_params++ =
-					eq->per_band_cfg[idx].quality_factor;
-					*updt_params++ =
-					eq->per_band_cfg[idx].band_idx;
-				}
-			}
-			break;
-		case EQ_BAND_INDEX:
-			if (length != 1 || index_offset != 0) {
-				pr_err("EQ_BAND_INDEX:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			idx = GET_NEXT(values, param_max_offset, rc);
-			if (idx > MAX_EQ_BANDS) {
-				pr_err("EQ_BAND_INDEX:invalid band index\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			eq->band_index = idx;
-			pr_debug("%s: EQ_BAND_INDEX val:%d\n",
-				__func__, eq->band_index);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					EQ_BAND_INDEX_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"EQ_BAND_INDEX", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_EQ_BAND_INDEX;
-				*updt_params++ =
-					EQ_BAND_INDEX_PARAM_SZ;
-				*updt_params++ =
-					eq->band_index;
-			}
-			break;
-		case EQ_SINGLE_BAND_FREQ:
-			if (length != 1 || index_offset != 0) {
-				pr_err("EQ_SINGLE_BAND_FREQ:invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			if (eq->band_index > MAX_EQ_BANDS) {
-				pr_err("EQ_SINGLE_BAND_FREQ:invalid index\n");
-				break;
-			}
-			eq->freq_millihertz =
-				GET_NEXT(values, param_max_offset, rc);
-			pr_debug("%s: EQ_SINGLE_BAND_FREQ idx:%d, val:%d\n",
-				__func__, eq->band_index, eq->freq_millihertz);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-					EQ_SINGLE_BAND_FREQ_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"EQ_SINGLE_BAND_FREQ", rc);
-				if (rc != 0)
-					goto invalid_config;
-				*updt_params++ =
-					AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
-				*updt_params++ =
-					AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ;
-				*updt_params++ =
-					EQ_SINGLE_BAND_FREQ_PARAM_SZ;
-				*updt_params++ =
-					eq->freq_millihertz;
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command to set config\n", __func__);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-	else
-		pr_debug("%s: did not send pp params\n", __func__);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-static int __msm_audio_effects_volume_handler(struct audio_client *ac,
-					      struct soft_volume_params *vol,
-					      long *values,
-					      int instance)
-{
-	int devices;
-	int num_commands;
-	char *params = NULL;
-	int *updt_params, i;
-	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
-	long *param_max_offset;
-	int rc = 0;
-
-	pr_debug("%s: instance: %d\n", __func__, instance);
-	if (!values) {
-		pr_err("%s: set audio effects failed, no valid data\n",
-			__func__);
-		return -EINVAL;
-	}
-	param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
-	devices = GET_NEXT(values, param_max_offset, rc);
-	num_commands = GET_NEXT(values, param_max_offset, rc);
-	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	params = kzalloc(params_length, GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-
-	updt_params = (int *)params;
-	params_length = 0;
-	for (i = 0; i < num_commands; i++) {
-		uint32_t command_id =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t command_config_state =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t index_offset =
-			GET_NEXT(values, param_max_offset, rc);
-		uint32_t length =
-			GET_NEXT(values, param_max_offset, rc);
-		switch (command_id) {
-		case SOFT_VOLUME_GAIN_2CH:
-		case SOFT_VOLUME2_GAIN_2CH:
-			if (length != 2 || index_offset != 0) {
-				pr_err("VOLUME_GAIN_2CH: invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			vol->left_gain = GET_NEXT(values, param_max_offset, rc);
-			vol->right_gain =
-				GET_NEXT(values, param_max_offset, rc);
-			vol->master_gain = 0x2000;
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-						SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
-				params_length += COMMAND_PAYLOAD_SZ +
-					SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VOLUME/VOLUME2_GAIN_2CH",
-						rc);
-				if (rc != 0)
-					goto invalid_config;
-				if (instance == SOFT_VOLUME_INSTANCE_2)
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL2;
-				else
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL;
-				*updt_params++ =
-					ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN;
-				*updt_params++ =
-					SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
-				*updt_params++ =
-					(vol->left_gain << 16) |
-						vol->right_gain;
-				if (instance == SOFT_VOLUME_INSTANCE_2)
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL2;
-				else
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL;
-				*updt_params++ =
-					ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
-				*updt_params++ =
-					SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
-				*updt_params++ =
-					vol->master_gain;
-			}
-			break;
-		case SOFT_VOLUME_GAIN_MASTER:
-		case SOFT_VOLUME2_GAIN_MASTER:
-			if (length != 1 || index_offset != 0) {
-				pr_err("VOLUME_GAIN_MASTER: invalid params\n");
-				rc = -EINVAL;
-				goto invalid_config;
-			}
-			vol->left_gain = 0x2000;
-			vol->right_gain = 0x2000;
-			vol->master_gain =
-				GET_NEXT(values, param_max_offset, rc);
-			if (command_config_state == CONFIG_SET) {
-				params_length += COMMAND_PAYLOAD_SZ +
-						SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
-				params_length += COMMAND_PAYLOAD_SZ +
-					SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
-				CHECK_PARAM_LEN(params_length,
-						MAX_INBAND_PARAM_SZ,
-						"VOLUME/VOLUME2_GAIN_MASTER",
-						rc);
-				if (rc != 0)
-					goto invalid_config;
-				if (instance == SOFT_VOLUME_INSTANCE_2)
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL2;
-				else
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL;
-				*updt_params++ =
-					ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN;
-				*updt_params++ =
-					SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
-				*updt_params++ =
-					(vol->left_gain << 16) |
-						vol->right_gain;
-				if (instance == SOFT_VOLUME_INSTANCE_2)
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL2;
-				else
-					*updt_params++ =
-						ASM_MODULE_ID_VOL_CTRL;
-				*updt_params++ =
-					ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
-				*updt_params++ =
-					SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
-				*updt_params++ =
-					vol->master_gain;
-			}
-			break;
-		default:
-			pr_err("%s: Invalid command id: %d to set config\n",
-				__func__, command_id);
-			break;
-		}
-	}
-	if (params_length && (rc == 0))
-		q6asm_send_audio_effects_params(ac, params,
-						params_length);
-invalid_config:
-	kfree(params);
-	return rc;
-}
-
-int msm_audio_effects_volume_handler(struct audio_client *ac,
-				     struct soft_volume_params *vol,
-				     long *values)
-{
-	return __msm_audio_effects_volume_handler(ac, vol, values,
-						  SOFT_VOLUME_INSTANCE_1);
-}
-
-int msm_audio_effects_volume_handler_v2(struct audio_client *ac,
-					struct soft_volume_params *vol,
-					long *values, int instance)
-{
-	return __msm_audio_effects_volume_handler(ac, vol, values, instance);
-}
diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
deleted file mode 100644
index 503af58..0000000
--- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
+++ /dev/null
@@ -1,4561 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/time.h>
-#include <linux/math64.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6asm-v2.h>
-#include <sound/pcm_params.h>
-#include <sound/audio_effects.h>
-#include <asm/dma.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/msm_audio.h>
-
-#include <sound/timer.h>
-#include <sound/tlv.h>
-
-#include <sound/apr_audio-v2.h>
-#include <sound/q6asm-v2.h>
-#include <sound/compress_params.h>
-#include <sound/compress_offload.h>
-#include <sound/compress_driver.h>
-#include <sound/msm-audio-effects-q6-v2.h>
-#include "msm-pcm-routing-v2.h"
-#include "msm-qti-pp-config.h"
-
-#define DSP_PP_BUFFERING_IN_MSEC	25
-#define PARTIAL_DRAIN_ACK_EARLY_BY_MSEC	150
-#define MP3_OUTPUT_FRAME_SZ		1152
-#define AAC_OUTPUT_FRAME_SZ		1024
-#define AC3_OUTPUT_FRAME_SZ		1536
-#define EAC3_OUTPUT_FRAME_SZ		1536
-#define DSP_NUM_OUTPUT_FRAME_BUFFERED	2
-#define FLAC_BLK_SIZE_LIMIT		65535
-
-/* Timestamp mode payload offsets */
-#define CAPTURE_META_DATA_TS_OFFSET_LSW	6
-#define CAPTURE_META_DATA_TS_OFFSET_MSW	7
-
-/* decoder parameter length */
-#define DDP_DEC_MAX_NUM_PARAM		18
-
-/* Default values used if user space does not set */
-#define COMPR_PLAYBACK_MIN_FRAGMENT_SIZE (8 * 1024)
-#define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024)
-#define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4)
-#define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4)
-
-#define COMPRESSED_LR_VOL_MAX_STEPS	0x2000
-const DECLARE_TLV_DB_LINEAR(msm_compr_vol_gain, 0,
-				COMPRESSED_LR_VOL_MAX_STEPS);
-
-/* Stream id switches between 1 and 2 */
-#define NEXT_STREAM_ID(stream_id) ((stream_id & 1) + 1)
-
-#define STREAM_ARRAY_INDEX(stream_id) (stream_id - 1)
-
-#define MAX_NUMBER_OF_STREAMS 2
-
-struct msm_compr_gapless_state {
-	bool set_next_stream_id;
-	int32_t stream_opened[MAX_NUMBER_OF_STREAMS];
-	uint32_t initial_samples_drop;
-	uint32_t trailing_samples_drop;
-	uint32_t gapless_transition;
-	bool use_dsp_gapless_mode;
-	union snd_codec_options codec_options;
-};
-
-static unsigned int supported_sample_rates[] = {
-	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000,
-	88200, 96000, 128000, 144000, 176400, 192000, 352800, 384000, 2822400,
-	5644800
-};
-
-struct msm_compr_pdata {
-	struct snd_compr_stream *cstream[MSM_FRONTEND_DAI_MAX];
-	uint32_t volume[MSM_FRONTEND_DAI_MAX][2]; /* For both L & R */
-	struct msm_compr_audio_effects *audio_effects[MSM_FRONTEND_DAI_MAX];
-	bool use_dsp_gapless_mode;
-	bool use_legacy_api; /* indicates use older asm apis*/
-	struct msm_compr_dec_params *dec_params[MSM_FRONTEND_DAI_MAX];
-	struct msm_compr_ch_map *ch_map[MSM_FRONTEND_DAI_MAX];
-};
-
-struct msm_compr_audio {
-	struct snd_compr_stream *cstream;
-	struct snd_compr_caps compr_cap;
-	struct snd_compr_codec_caps codec_caps;
-	struct snd_compr_params codec_param;
-	struct audio_client *audio_client;
-
-	uint32_t codec;
-	uint32_t compr_passthr;
-	void    *buffer; /* virtual address */
-	phys_addr_t buffer_paddr; /* physical address */
-	uint32_t app_pointer;
-	uint32_t buffer_size;
-	uint32_t byte_offset;
-	uint64_t copied_total; /* bytes consumed by DSP */
-	uint64_t bytes_received; /* from userspace */
-	uint64_t bytes_sent; /* to DSP */
-
-	uint64_t received_total; /* bytes received from DSP */
-	uint64_t bytes_copied; /* to userspace */
-	uint64_t bytes_read; /* from DSP */
-	uint32_t bytes_read_offset; /* bytes read offset */
-
-	uint32_t ts_header_offset; /* holds the timestamp header offset */
-
-	int32_t first_buffer;
-	int32_t last_buffer;
-	int32_t partial_drain_delay;
-
-	uint16_t session_id;
-
-	uint32_t sample_rate;
-	uint32_t num_channels;
-
-	/*
-	 * convention - commands coming from the same thread
-	 * can use the common cmd_ack var. Others (e.g drain/EOS)
-	 * must use separate vars to track command status.
-	 */
-	uint32_t cmd_ack;
-	uint32_t cmd_interrupt;
-	uint32_t drain_ready;
-	uint32_t eos_ack;
-
-	uint32_t stream_available;
-	uint32_t next_stream;
-
-	uint32_t run_mode;
-	uint32_t start_delay_lsw;
-	uint32_t start_delay_msw;
-
-	uint64_t marker_timestamp;
-
-	struct msm_compr_gapless_state gapless_state;
-
-	atomic_t start;
-	atomic_t eos;
-	atomic_t drain;
-	atomic_t xrun;
-	atomic_t close;
-	atomic_t wait_on_close;
-	atomic_t error;
-
-	wait_queue_head_t eos_wait;
-	wait_queue_head_t drain_wait;
-	wait_queue_head_t close_wait;
-	wait_queue_head_t wait_for_stream_avail;
-
-	spinlock_t lock;
-};
-
-const u32 compr_codecs[] = {
-	SND_AUDIOCODEC_AC3, SND_AUDIOCODEC_EAC3, SND_AUDIOCODEC_DTS,
-	SND_AUDIOCODEC_DSD, SND_AUDIOCODEC_TRUEHD, SND_AUDIOCODEC_IEC61937};
-
-struct query_audio_effect {
-	uint32_t mod_id;
-	uint32_t parm_id;
-	uint32_t size;
-	uint32_t offset;
-	uint32_t device;
-};
-
-struct msm_compr_audio_effects {
-	struct bass_boost_params bass_boost;
-	struct pbe_params pbe;
-	struct virtualizer_params virtualizer;
-	struct reverb_params reverb;
-	struct eq_params equalizer;
-	struct soft_volume_params volume;
-	struct query_audio_effect query;
-};
-
-struct msm_compr_dec_params {
-	struct snd_dec_ddp ddp_params;
-};
-
-struct msm_compr_ch_map {
-	bool set_ch_map;
-	char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL];
-};
-
-static int msm_compr_send_dec_params(struct snd_compr_stream *cstream,
-				     struct msm_compr_dec_params *dec_params,
-				     int stream_id);
-
-static int msm_compr_set_render_mode(struct msm_compr_audio *prtd,
-				     uint32_t render_mode) {
-	int ret = -EINVAL;
-	struct audio_client *ac = prtd->audio_client;
-
-	pr_debug("%s, got render mode %u\n", __func__, render_mode);
-
-	if (render_mode == SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER) {
-		render_mode = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_DEFAULT;
-	} else if (render_mode == SNDRV_COMPRESS_RENDER_MODE_STC_MASTER) {
-		render_mode = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_LOCAL_STC;
-		prtd->run_mode = ASM_SESSION_CMD_RUN_STARTIME_RUN_WITH_DELAY;
-	} else {
-		pr_err("%s, Invalid render mode %u\n", __func__,
-			render_mode);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	ret = q6asm_send_mtmx_strtr_render_mode(ac, render_mode);
-	if (ret) {
-		pr_err("%s, Render mode can't be set error %d\n", __func__,
-			ret);
-	}
-exit:
-	return ret;
-}
-
-static int msm_compr_set_clk_rec_mode(struct audio_client *ac,
-				     uint32_t clk_rec_mode) {
-	int ret = -EINVAL;
-
-	pr_debug("%s, got clk rec mode %u\n", __func__, clk_rec_mode);
-
-	if (clk_rec_mode == SNDRV_COMPRESS_CLK_REC_MODE_NONE) {
-		clk_rec_mode = ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_NONE;
-	} else if (clk_rec_mode == SNDRV_COMPRESS_CLK_REC_MODE_AUTO) {
-		clk_rec_mode = ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_AUTO;
-	} else {
-		pr_err("%s, Invalid clk rec_mode mode %u\n", __func__,
-			clk_rec_mode);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	ret = q6asm_send_mtmx_strtr_clk_rec_mode(ac, clk_rec_mode);
-	if (ret) {
-		pr_err("%s, clk rec mode can't be set, error %d\n", __func__,
-			ret);
-	}
-
-exit:
-	return ret;
-}
-
-static int msm_compr_set_render_window(struct audio_client *ac,
-		uint32_t ws_lsw, uint32_t ws_msw,
-		uint32_t we_lsw, uint32_t we_msw)
-{
-	int ret = -EINVAL;
-	struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window;
-	uint32_t param_id;
-
-	pr_debug("%s, ws_lsw 0x%x ws_msw 0x%x we_lsw 0x%x we_ms 0x%x\n",
-		 __func__, ws_lsw, ws_msw, we_lsw, we_msw);
-
-	memset(&asm_mtmx_strtr_window, 0,
-	       sizeof(struct asm_session_mtmx_strtr_param_window_v2_t));
-	asm_mtmx_strtr_window.window_lsw = ws_lsw;
-	asm_mtmx_strtr_window.window_msw = ws_msw;
-	param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2;
-	ret = q6asm_send_mtmx_strtr_window(ac, &asm_mtmx_strtr_window,
-					   param_id);
-	if (ret) {
-		pr_err("%s, start window can't be set error %d\n", __func__,
-			ret);
-		goto exit;
-	}
-
-	asm_mtmx_strtr_window.window_lsw = we_lsw;
-	asm_mtmx_strtr_window.window_msw = we_msw;
-	param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2;
-	ret = q6asm_send_mtmx_strtr_window(ac, &asm_mtmx_strtr_window,
-					   param_id);
-	if (ret) {
-		pr_err("%s, end window can't be set error %d\n", __func__,
-			ret);
-	}
-
-exit:
-	return ret;
-}
-
-static int msm_compr_enable_adjust_session_clock(struct audio_client *ac,
-		bool enable)
-{
-	int ret;
-
-	pr_debug("%s, enable adjust_session %d\n", __func__, enable);
-
-	ret = q6asm_send_mtmx_strtr_enable_adjust_session_clock(ac, enable);
-	if (ret)
-		pr_err("%s, adjust session clock can't be set error %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_compr_adjust_session_clock(struct audio_client *ac,
-		uint32_t adjust_session_lsw, uint32_t adjust_session_msw)
-{
-	int ret;
-
-	pr_debug("%s, adjust_session_time_msw 0x%x adjust_session_time_lsw 0x%x\n",
-		 __func__, adjust_session_msw, adjust_session_lsw);
-
-	ret = q6asm_adjust_session_clock(ac,
-			adjust_session_lsw,
-			adjust_session_msw);
-	if (ret)
-		pr_err("%s, adjust session clock can't be set error %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_compr_set_volume(struct snd_compr_stream *cstream,
-				uint32_t volume_l, uint32_t volume_r)
-{
-	struct msm_compr_audio *prtd;
-	int rc = 0;
-	uint32_t avg_vol, gain_list[VOLUME_CONTROL_MAX_CHANNELS];
-	uint32_t num_channels;
-	struct snd_soc_pcm_runtime *rtd;
-	struct msm_compr_pdata *pdata;
-	bool use_default = true;
-	u8 *chmap = NULL;
-
-	pr_debug("%s: volume_l %d volume_r %d\n",
-		__func__, volume_l, volume_r);
-	if (!cstream || !cstream->runtime) {
-		pr_err("%s: session not active\n", __func__);
-		return -EPERM;
-	}
-	rtd = cstream->private_data;
-	prtd = cstream->runtime->private_data;
-
-	if (!rtd || !rtd->platform || !prtd || !prtd->audio_client) {
-		pr_err("%s: invalid rtd, prtd or audio client", __func__);
-		return rc;
-	}
-	pdata = snd_soc_platform_get_drvdata(rtd->platform);
-
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		pr_debug("%s: No volume config for passthrough %d\n",
-			 __func__, prtd->compr_passthr);
-		return rc;
-	}
-
-	use_default = !(pdata->ch_map[rtd->dai_link->id]->set_ch_map);
-	chmap = pdata->ch_map[rtd->dai_link->id]->channel_map;
-	num_channels = prtd->num_channels;
-
-	if (prtd->num_channels > 2) {
-		/*
-		 * Currently the left and right gains are averaged an applied
-		 * to all channels. This might not be desirable. But currently,
-		 * there exists no API in userspace to send a list of gains for
-		 * each channel either. If such an API does become available,
-		 * the mixer control must be updated to accept more than 2
-		 * channel gains.
-		 *
-		 */
-		avg_vol = (volume_l + volume_r) / 2;
-		rc = q6asm_set_volume(prtd->audio_client, avg_vol);
-	} else {
-		gain_list[0] = volume_l;
-		gain_list[1] = volume_r;
-		/* force sending FR/FL/FC volume for mono */
-		if (prtd->num_channels == 1) {
-			gain_list[2] = volume_l;
-			num_channels = 3;
-			use_default = true;
-		}
-		rc = q6asm_set_multich_gain(prtd->audio_client, num_channels,
-					gain_list, chmap, use_default);
-	}
-
-	if (rc < 0)
-		pr_err("%s: Send vol gain command failed rc=%d\n",
-		       __func__, rc);
-
-	return rc;
-}
-
-static int msm_compr_send_ddp_cfg(struct audio_client *ac,
-				  struct snd_dec_ddp *ddp,
-				  int stream_id)
-{
-	int i, rc;
-
-	pr_debug("%s\n", __func__);
-	for (i = 0; i < ddp->params_length; i++) {
-		rc = q6asm_ds1_set_stream_endp_params(ac, ddp->params_id[i],
-						      ddp->params_value[i],
-						      stream_id);
-		if (rc) {
-			pr_err("sending params_id: %d failed\n",
-				ddp->params_id[i]);
-			return rc;
-		}
-	}
-	return 0;
-}
-
-static int msm_compr_send_buffer(struct msm_compr_audio *prtd)
-{
-	int buffer_length;
-	uint64_t bytes_available;
-	struct audio_aio_write_param param;
-	struct snd_codec_metadata *buff_addr;
-
-	if (!atomic_read(&prtd->start)) {
-		pr_err("%s: stream is not in started state\n", __func__);
-		return -EINVAL;
-	}
-
-
-	if (atomic_read(&prtd->xrun)) {
-		WARN(1, "%s called while xrun is true", __func__);
-		return -EPERM;
-	}
-
-	pr_debug("%s: bytes_received = %llu copied_total = %llu\n",
-		__func__, prtd->bytes_received, prtd->copied_total);
-	if (prtd->first_buffer &&  prtd->gapless_state.use_dsp_gapless_mode &&
-		prtd->compr_passthr == LEGACY_PCM)
-		q6asm_stream_send_meta_data(prtd->audio_client,
-				prtd->audio_client->stream_id,
-				prtd->gapless_state.initial_samples_drop,
-				prtd->gapless_state.trailing_samples_drop);
-
-	buffer_length = prtd->codec_param.buffer.fragment_size;
-	bytes_available = prtd->bytes_received - prtd->copied_total;
-	if (bytes_available < prtd->codec_param.buffer.fragment_size)
-		buffer_length = bytes_available;
-
-	if (prtd->byte_offset + buffer_length > prtd->buffer_size) {
-		buffer_length = (prtd->buffer_size - prtd->byte_offset);
-		pr_debug("%s: wrap around situation, send partial data %d now",
-			 __func__, buffer_length);
-	}
-
-	if (buffer_length) {
-		param.paddr = prtd->buffer_paddr + prtd->byte_offset;
-		WARN(prtd->byte_offset % 32 != 0, "offset %x not multiple of 32\n",
-		prtd->byte_offset);
-	} else {
-		param.paddr = prtd->buffer_paddr;
-	}
-	param.len	= buffer_length;
-	if (prtd->ts_header_offset) {
-		buff_addr = (struct snd_codec_metadata *)
-					(prtd->buffer + prtd->byte_offset);
-		param.len = buff_addr->length;
-		param.msw_ts = (uint32_t)
-			((buff_addr->timestamp & 0xFFFFFFFF00000000LL) >> 32);
-		param.lsw_ts = (uint32_t) (buff_addr->timestamp & 0xFFFFFFFFLL);
-		param.paddr += prtd->ts_header_offset;
-		param.flags = SET_TIMESTAMP;
-		param.metadata_len = prtd->ts_header_offset;
-	} else {
-		param.msw_ts = 0;
-		param.lsw_ts = 0;
-		param.flags = NO_TIMESTAMP;
-		param.metadata_len = 0;
-	}
-	param.uid	= buffer_length;
-	param.last_buffer = prtd->last_buffer;
-
-	pr_debug("%s: sending %d bytes to DSP byte_offset = %d\n",
-		__func__, param.len, prtd->byte_offset);
-	if (q6asm_async_write(prtd->audio_client, &param) < 0) {
-		pr_err("%s:q6asm_async_write failed\n", __func__);
-	} else {
-		prtd->bytes_sent += buffer_length;
-		if (prtd->first_buffer)
-			prtd->first_buffer = 0;
-	}
-
-	return 0;
-}
-
-static int msm_compr_read_buffer(struct msm_compr_audio *prtd)
-{
-	int buffer_length;
-	uint64_t bytes_available;
-	uint64_t buffer_sent;
-	struct audio_aio_read_param param;
-	int ret;
-
-	if (!atomic_read(&prtd->start)) {
-		pr_err("%s: stream is not in started state\n", __func__);
-		return -EINVAL;
-	}
-
-	buffer_length = prtd->codec_param.buffer.fragment_size -
-						 prtd->ts_header_offset;
-	bytes_available = prtd->received_total - prtd->bytes_copied;
-	buffer_sent = prtd->bytes_read - prtd->bytes_copied;
-	if (buffer_sent + buffer_length + prtd->ts_header_offset
-						> prtd->buffer_size) {
-		pr_debug(" %s : Buffer is Full bytes_available: %llu\n",
-				__func__, bytes_available);
-		return 0;
-	}
-
-	memset(&param, 0x0, sizeof(struct audio_aio_read_param));
-	param.paddr = prtd->buffer_paddr + prtd->bytes_read_offset +
-						prtd->ts_header_offset;
-	param.len = buffer_length;
-	param.uid = buffer_length;
-	param.flags = prtd->codec_param.codec.flags;
-
-	pr_debug("%s: reading %d bytes from DSP byte_offset = %llu\n",
-			__func__, buffer_length, prtd->bytes_read);
-	ret = q6asm_async_read(prtd->audio_client, &param);
-	if (ret < 0) {
-		pr_err("%s: q6asm_async_read failed - %d\n",
-			__func__, ret);
-		return ret;
-	}
-	prtd->bytes_read += buffer_length;
-	prtd->bytes_read_offset += buffer_length;
-	if (prtd->bytes_read_offset >= prtd->buffer_size)
-		prtd->bytes_read_offset -= prtd->buffer_size;
-
-	return 0;
-}
-
-static void compr_event_handler(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv)
-{
-	struct msm_compr_audio *prtd = priv;
-	struct snd_compr_stream *cstream;
-	struct audio_client *ac;
-	uint32_t chan_mode = 0;
-	uint32_t sample_rate = 0;
-	uint64_t bytes_available;
-	int stream_id;
-	uint32_t stream_index;
-	unsigned long flags;
-	uint64_t read_size;
-	uint32_t *buff_addr;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-
-	if (!prtd) {
-		pr_err("%s: prtd is NULL\n", __func__);
-		return;
-	}
-	cstream = prtd->cstream;
-	if (!cstream) {
-		pr_err("%s: cstream is NULL\n", __func__);
-		return;
-	}
-
-	ac = prtd->audio_client;
-
-	/*
-	 * Token for rest of the compressed commands use to set
-	 * session id, stream id, dir etc.
-	 */
-	stream_id = q6asm_get_stream_id_from_token(token);
-
-	pr_debug("%s opcode =%08x\n", __func__, opcode);
-	switch (opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2:
-		spin_lock_irqsave(&prtd->lock, flags);
-
-		if (payload[3]) {
-			pr_err("%s: WRITE FAILED w/ err 0x%x !, paddr 0x%x, byte_offset=%d,copied_total=%llu,token=%d\n",
-				__func__,
-				payload[3],
-				payload[0],
-				prtd->byte_offset,
-				prtd->copied_total, token);
-
-			if (atomic_cmpxchg(&prtd->drain, 1, 0) &&
-			    prtd->last_buffer) {
-				pr_debug("%s: wake up on drain\n", __func__);
-				prtd->drain_ready = 1;
-				wake_up(&prtd->drain_wait);
-				prtd->last_buffer = 0;
-			} else {
-				atomic_set(&prtd->start, 0);
-			}
-		} else {
-			pr_debug("ASM_DATA_EVENT_WRITE_DONE_V2 offset %d, length %d\n",
-				 prtd->byte_offset, token);
-		}
-
-		/*
-		 * Token for WRITE command represents the amount of data
-		 * written to ADSP in the last write, update offset and
-		 * total copied data accordingly.
-		 */
-		if (prtd->ts_header_offset) {
-			/* Always assume that the data will be sent to DSP on
-			 * frame boundary.
-			 * i.e, one frame of userspace write will result in
-			 * one kernel write to DSP. This is needed as
-			 * timestamp will be sent per frame.
-			 */
-			prtd->byte_offset +=
-					prtd->codec_param.buffer.fragment_size;
-			prtd->copied_total +=
-					prtd->codec_param.buffer.fragment_size;
-		} else {
-			prtd->byte_offset += token;
-			prtd->copied_total += token;
-		}
-		if (prtd->byte_offset >= prtd->buffer_size)
-			prtd->byte_offset -= prtd->buffer_size;
-
-		snd_compr_fragment_elapsed(cstream);
-
-		if (!atomic_read(&prtd->start)) {
-			/* Writes must be restarted from _copy() */
-			pr_debug("write_done received while not started, treat as xrun");
-			atomic_set(&prtd->xrun, 1);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-
-		bytes_available = prtd->bytes_received - prtd->copied_total;
-		if (bytes_available < cstream->runtime->fragment_size) {
-			pr_debug("WRITE_DONE Insufficient data to send. break out\n");
-			atomic_set(&prtd->xrun, 1);
-
-			if (prtd->last_buffer)
-				prtd->last_buffer = 0;
-			if (atomic_read(&prtd->drain)) {
-				pr_debug("wake up on drain\n");
-				prtd->drain_ready = 1;
-				wake_up(&prtd->drain_wait);
-				atomic_set(&prtd->drain, 0);
-			}
-		} else if ((bytes_available == cstream->runtime->fragment_size)
-			   && atomic_read(&prtd->drain)) {
-			prtd->last_buffer = 1;
-			msm_compr_send_buffer(prtd);
-			prtd->last_buffer = 0;
-		} else
-			msm_compr_send_buffer(prtd);
-
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		break;
-
-	case ASM_DATA_EVENT_READ_DONE_V2:
-		spin_lock_irqsave(&prtd->lock, flags);
-
-		pr_debug("ASM_DATA_EVENT_READ_DONE_V2 offset %d, length %d\n",
-				 prtd->byte_offset, payload[4]);
-
-		if (prtd->ts_header_offset) {
-			/* Update the header for received buffer */
-			buff_addr = prtd->buffer + prtd->byte_offset;
-			/* Write the length of the buffer */
-			*buff_addr = prtd->codec_param.buffer.fragment_size
-						 - prtd->ts_header_offset;
-			buff_addr++;
-			/* Write the offset */
-			*buff_addr = prtd->ts_header_offset;
-			buff_addr++;
-			/* Write the TS LSW */
-			*buff_addr = payload[CAPTURE_META_DATA_TS_OFFSET_LSW];
-			buff_addr++;
-			/* Write the TS MSW */
-			*buff_addr = payload[CAPTURE_META_DATA_TS_OFFSET_MSW];
-		}
-		/* Always assume read_size is same as fragment_size */
-		read_size = prtd->codec_param.buffer.fragment_size;
-		prtd->byte_offset += read_size;
-		prtd->received_total += read_size;
-		if (prtd->byte_offset >= prtd->buffer_size)
-			prtd->byte_offset -= prtd->buffer_size;
-
-		snd_compr_fragment_elapsed(cstream);
-
-		if (!atomic_read(&prtd->start)) {
-			pr_debug("read_done received while not started, treat as xrun");
-			atomic_set(&prtd->xrun, 1);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-		msm_compr_read_buffer(prtd);
-
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		break;
-
-	case ASM_DATA_EVENT_RENDERED_EOS:
-		spin_lock_irqsave(&prtd->lock, flags);
-		pr_debug("%s: ASM_DATA_CMDRSP_EOS token 0x%x,stream id %d\n",
-			  __func__, token, stream_id);
-		if (atomic_read(&prtd->eos) &&
-		    !prtd->gapless_state.set_next_stream_id) {
-			pr_debug("ASM_DATA_CMDRSP_EOS wake up\n");
-			prtd->eos_ack = 1;
-			wake_up(&prtd->eos_wait);
-		}
-		atomic_set(&prtd->eos, 0);
-		stream_index = STREAM_ARRAY_INDEX(stream_id);
-		if (stream_index >= MAX_NUMBER_OF_STREAMS ||
-		    stream_index < 0) {
-			pr_err("%s: Invalid stream index %d", __func__,
-				stream_index);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-
-		if (prtd->gapless_state.set_next_stream_id &&
-			prtd->gapless_state.stream_opened[stream_index]) {
-			pr_debug("%s: CMD_CLOSE stream_id %d\n",
-				  __func__, stream_id);
-			q6asm_stream_cmd_nowait(ac, CMD_CLOSE, stream_id);
-			atomic_set(&prtd->close, 1);
-			prtd->gapless_state.stream_opened[stream_index] = 0;
-			prtd->gapless_state.set_next_stream_id = false;
-		}
-		if (prtd->gapless_state.gapless_transition)
-			prtd->gapless_state.gapless_transition = 0;
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		break;
-	case ASM_STREAM_PP_EVENT:
-	case ASM_STREAM_CMD_ENCDEC_EVENTS:
-		pr_debug("%s: ASM_STREAM_EVENT(0x%x)\n", __func__, opcode);
-		rtd = cstream->private_data;
-		if (!rtd) {
-			pr_err("%s: rtd is NULL\n", __func__);
-			return;
-		}
-
-		ret = msm_adsp_inform_mixer_ctl(rtd, payload);
-		if (ret) {
-			pr_err("%s: failed to inform mixer ctrl. err = %d\n",
-				__func__, ret);
-			return;
-		}
-		break;
-	case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
-	case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY: {
-		pr_debug("ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY\n");
-		chan_mode = payload[1] >> 16;
-		sample_rate = payload[2] >> 16;
-		if (prtd && (chan_mode != prtd->num_channels ||
-				sample_rate != prtd->sample_rate)) {
-			prtd->num_channels = chan_mode;
-			prtd->sample_rate = sample_rate;
-		}
-	}
-		/* Fallthrough here */
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-		case ASM_SESSION_CMD_RUN_V2:
-			/* check if the first buffer need to be sent to DSP */
-			pr_debug("ASM_SESSION_CMD_RUN_V2\n");
-
-			/* FIXME: A state is a better way, dealing with this */
-			spin_lock_irqsave(&prtd->lock, flags);
-
-			if (cstream->direction == SND_COMPRESS_CAPTURE) {
-				atomic_set(&prtd->start, 1);
-				msm_compr_read_buffer(prtd);
-				spin_unlock_irqrestore(&prtd->lock, flags);
-				break;
-			}
-
-			if (!prtd->bytes_sent) {
-				bytes_available = prtd->bytes_received -
-						  prtd->copied_total;
-				if (bytes_available <
-				    cstream->runtime->fragment_size) {
-					pr_debug("CMD_RUN_V2 Insufficient data to send. break out\n");
-					atomic_set(&prtd->xrun, 1);
-				} else {
-					msm_compr_send_buffer(prtd);
-				}
-			}
-
-			/*
-			 * The condition below ensures playback finishes in the
-			 * follow cornercase
-			 * WRITE(last buffer)
-			 * WAIT_FOR_DRAIN
-			 * PAUSE
-			 * WRITE_DONE(X)
-			 * RESUME
-			 */
-			if ((prtd->copied_total == prtd->bytes_sent) &&
-			    atomic_read(&prtd->drain)) {
-				pr_debug("RUN ack, wake up & continue pending drain\n");
-
-				if (prtd->last_buffer)
-					prtd->last_buffer = 0;
-
-				prtd->drain_ready = 1;
-				wake_up(&prtd->drain_wait);
-				atomic_set(&prtd->drain, 0);
-			}
-
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		case ASM_STREAM_CMD_FLUSH:
-			pr_debug("%s: ASM_STREAM_CMD_FLUSH:", __func__);
-			pr_debug("token 0x%x, stream id %d\n", token,
-				  stream_id);
-			prtd->cmd_ack = 1;
-			break;
-		case ASM_DATA_CMD_REMOVE_INITIAL_SILENCE:
-			pr_debug("%s: ASM_DATA_CMD_REMOVE_INITIAL_SILENCE:",
-				   __func__);
-			pr_debug("token 0x%x, stream id = %d\n", token,
-				  stream_id);
-			break;
-		case ASM_DATA_CMD_REMOVE_TRAILING_SILENCE:
-			pr_debug("%s: ASM_DATA_CMD_REMOVE_TRAILING_SILENCE:",
-				  __func__);
-			pr_debug("token = 0x%x,	stream id = %d\n", token,
-				  stream_id);
-			break;
-		case ASM_STREAM_CMD_CLOSE:
-			pr_debug("%s: ASM_DATA_CMD_CLOSE:", __func__);
-			pr_debug("token 0x%x, stream id %d\n", token,
-				  stream_id);
-			/*
-			 * wakeup wait for stream avail on stream 3
-			 * after stream 1 ends.
-			 */
-			if (prtd->next_stream) {
-				pr_debug("%s:CLOSE:wakeup wait for stream\n",
-					  __func__);
-				prtd->stream_available = 1;
-				wake_up(&prtd->wait_for_stream_avail);
-				prtd->next_stream = 0;
-			}
-			if (atomic_read(&prtd->close) &&
-			    atomic_read(&prtd->wait_on_close)) {
-				prtd->cmd_ack = 1;
-				wake_up(&prtd->close_wait);
-			}
-			atomic_set(&prtd->close, 0);
-			break;
-		case ASM_STREAM_CMD_REGISTER_PP_EVENTS:
-			pr_debug("%s: ASM_STREAM_CMD_REGISTER_PP_EVENTS:",
-				__func__);
-			break;
-		default:
-			break;
-		}
-		break;
-	}
-	case ASM_SESSION_CMDRSP_GET_SESSIONTIME_V3:
-		pr_debug("%s: ASM_SESSION_CMDRSP_GET_SESSIONTIME_V3\n",
-			  __func__);
-		break;
-	case RESET_EVENTS:
-		pr_err("%s: Received reset events CB, move to error state",
-			__func__);
-		spin_lock_irqsave(&prtd->lock, flags);
-		/*
-		 * Since ADSP is down, let this driver pretend that it copied
-		 * all the bytes received, so that next write will be triggered
-		 */
-		prtd->copied_total = prtd->bytes_received;
-		snd_compr_fragment_elapsed(cstream);
-		atomic_set(&prtd->error, 1);
-		wake_up(&prtd->drain_wait);
-		if (atomic_cmpxchg(&prtd->eos, 1, 0)) {
-			pr_debug("%s:unblock eos wait queues", __func__);
-			wake_up(&prtd->eos_wait);
-		}
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		break;
-	default:
-		pr_debug("%s: Not Supported Event opcode[0x%x]\n",
-			  __func__, opcode);
-		break;
-	}
-}
-
-static int msm_compr_get_partial_drain_delay(int frame_sz, int sample_rate)
-{
-	int delay_time_ms = 0;
-
-	delay_time_ms = ((DSP_NUM_OUTPUT_FRAME_BUFFERED * frame_sz * 1000) /
-			sample_rate) + DSP_PP_BUFFERING_IN_MSEC;
-	delay_time_ms = delay_time_ms > PARTIAL_DRAIN_ACK_EARLY_BY_MSEC ?
-			delay_time_ms - PARTIAL_DRAIN_ACK_EARLY_BY_MSEC : 0;
-
-	pr_debug("%s: frame_sz %d, sample_rate %d, partial drain delay %d\n",
-		__func__, frame_sz, sample_rate, delay_time_ms);
-	return delay_time_ms;
-}
-
-static void populate_codec_list(struct msm_compr_audio *prtd)
-{
-	pr_debug("%s\n", __func__);
-	prtd->compr_cap.direction = SND_COMPRESS_PLAYBACK;
-	prtd->compr_cap.min_fragment_size =
-			COMPR_PLAYBACK_MIN_FRAGMENT_SIZE;
-	prtd->compr_cap.max_fragment_size =
-			COMPR_PLAYBACK_MAX_FRAGMENT_SIZE;
-	prtd->compr_cap.min_fragments =
-			COMPR_PLAYBACK_MIN_NUM_FRAGMENTS;
-	prtd->compr_cap.max_fragments =
-			COMPR_PLAYBACK_MAX_NUM_FRAGMENTS;
-	prtd->compr_cap.num_codecs = 17;
-	prtd->compr_cap.codecs[0] = SND_AUDIOCODEC_MP3;
-	prtd->compr_cap.codecs[1] = SND_AUDIOCODEC_AAC;
-	prtd->compr_cap.codecs[2] = SND_AUDIOCODEC_AC3;
-	prtd->compr_cap.codecs[3] = SND_AUDIOCODEC_EAC3;
-	prtd->compr_cap.codecs[4] = SND_AUDIOCODEC_MP2;
-	prtd->compr_cap.codecs[5] = SND_AUDIOCODEC_PCM;
-	prtd->compr_cap.codecs[6] = SND_AUDIOCODEC_WMA;
-	prtd->compr_cap.codecs[7] = SND_AUDIOCODEC_WMA_PRO;
-	prtd->compr_cap.codecs[8] = SND_AUDIOCODEC_FLAC;
-	prtd->compr_cap.codecs[9] = SND_AUDIOCODEC_VORBIS;
-	prtd->compr_cap.codecs[10] = SND_AUDIOCODEC_ALAC;
-	prtd->compr_cap.codecs[11] = SND_AUDIOCODEC_APE;
-	prtd->compr_cap.codecs[12] = SND_AUDIOCODEC_DTS;
-	prtd->compr_cap.codecs[13] = SND_AUDIOCODEC_DSD;
-	prtd->compr_cap.codecs[14] = SND_AUDIOCODEC_APTX;
-	prtd->compr_cap.codecs[15] = SND_AUDIOCODEC_TRUEHD;
-	prtd->compr_cap.codecs[16] = SND_AUDIOCODEC_IEC61937;
-}
-
-static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
-					     int stream_id,
-					     bool use_gapless_codec_options)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct msm_compr_pdata *pdata =
-			snd_soc_platform_get_drvdata(rtd->platform);
-	struct asm_aac_cfg aac_cfg;
-	struct asm_wma_cfg wma_cfg;
-	struct asm_wmapro_cfg wma_pro_cfg;
-	struct asm_flac_cfg flac_cfg;
-	struct asm_vorbis_cfg vorbis_cfg;
-	struct asm_alac_cfg alac_cfg;
-	struct asm_ape_cfg ape_cfg;
-	struct asm_dsd_cfg dsd_cfg;
-	struct aptx_dec_bt_addr_cfg aptx_cfg;
-	union snd_codec_options *codec_options;
-
-	int ret = 0;
-	uint16_t bit_width;
-	bool use_default_chmap = true;
-	char *chmap = NULL;
-	uint16_t sample_word_size;
-
-	pr_debug("%s: use_gapless_codec_options %d\n",
-			__func__, use_gapless_codec_options);
-
-	if (use_gapless_codec_options)
-		codec_options = &(prtd->gapless_state.codec_options);
-	else
-		codec_options = &(prtd->codec_param.codec.options);
-
-	if (!codec_options) {
-		pr_err("%s: codec_options is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (prtd->codec) {
-	case FORMAT_LINEAR_PCM:
-		pr_debug("SND_AUDIOCODEC_PCM\n");
-		if (pdata->ch_map[rtd->dai_link->id]) {
-			use_default_chmap =
-			    !(pdata->ch_map[rtd->dai_link->id]->set_ch_map);
-			chmap =
-			    pdata->ch_map[rtd->dai_link->id]->channel_map;
-		}
-
-		switch (prtd->codec_param.codec.format) {
-		case SNDRV_PCM_FORMAT_S32_LE:
-			bit_width = 32;
-			sample_word_size = 32;
-			break;
-		case SNDRV_PCM_FORMAT_S24_LE:
-			bit_width = 24;
-			sample_word_size = 32;
-			break;
-		case SNDRV_PCM_FORMAT_S24_3LE:
-			bit_width = 24;
-			sample_word_size = 24;
-			break;
-		case SNDRV_PCM_FORMAT_S16_LE:
-		default:
-			bit_width = 16;
-			sample_word_size = 16;
-			break;
-		}
-		ret = q6asm_media_format_block_pcm_format_support_v4(
-							prtd->audio_client,
-							prtd->sample_rate,
-							prtd->num_channels,
-							bit_width, stream_id,
-							use_default_chmap,
-							chmap,
-							sample_word_size,
-							ASM_LITTLE_ENDIAN,
-							DEFAULT_QF);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed\n", __func__);
-
-		break;
-	case FORMAT_MP3:
-		pr_debug("SND_AUDIOCODEC_MP3\n");
-		/* no media format block needed */
-		break;
-	case FORMAT_MPEG4_AAC:
-		pr_debug("SND_AUDIOCODEC_AAC\n");
-		memset(&aac_cfg, 0x0, sizeof(struct asm_aac_cfg));
-		aac_cfg.aot = AAC_ENC_MODE_EAAC_P;
-		if (prtd->codec_param.codec.format ==
-					SND_AUDIOSTREAMFORMAT_MP4ADTS)
-			aac_cfg.format = 0x0;
-		else if (prtd->codec_param.codec.format ==
-					SND_AUDIOSTREAMFORMAT_MP4LATM)
-			aac_cfg.format = 0x04;
-		else
-			aac_cfg.format = 0x03;
-		aac_cfg.ch_cfg = prtd->num_channels;
-		aac_cfg.sample_rate = prtd->sample_rate;
-		ret = q6asm_stream_media_format_block_aac(prtd->audio_client,
-							  &aac_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed\n", __func__);
-		break;
-	case FORMAT_AC3:
-		pr_debug("SND_AUDIOCODEC_AC3\n");
-		break;
-	case FORMAT_EAC3:
-		pr_debug("SND_AUDIOCODEC_EAC3\n");
-		break;
-	case FORMAT_WMA_V9:
-		pr_debug("SND_AUDIOCODEC_WMA\n");
-		memset(&wma_cfg, 0x0, sizeof(struct asm_wma_cfg));
-		wma_cfg.format_tag = prtd->codec_param.codec.format;
-		wma_cfg.ch_cfg = prtd->codec_param.codec.ch_in;
-		wma_cfg.sample_rate = prtd->sample_rate;
-		wma_cfg.avg_bytes_per_sec = codec_options->wma.avg_bit_rate/8;
-		wma_cfg.block_align = codec_options->wma.super_block_align;
-		wma_cfg.valid_bits_per_sample =
-			codec_options->wma.bits_per_sample;
-		wma_cfg.ch_mask = codec_options->wma.channelmask;
-		wma_cfg.encode_opt = codec_options->wma.encodeopt;
-		ret = q6asm_media_format_block_wma(prtd->audio_client,
-					&wma_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed\n", __func__);
-		break;
-	case FORMAT_WMA_V10PRO:
-		pr_debug("SND_AUDIOCODEC_WMA_PRO\n");
-		memset(&wma_pro_cfg, 0x0, sizeof(struct asm_wmapro_cfg));
-		wma_pro_cfg.format_tag = prtd->codec_param.codec.format;
-		wma_pro_cfg.ch_cfg = prtd->codec_param.codec.ch_in;
-		wma_pro_cfg.sample_rate = prtd->sample_rate;
-		wma_cfg.avg_bytes_per_sec = codec_options->wma.avg_bit_rate/8;
-		wma_pro_cfg.block_align = codec_options->wma.super_block_align;
-		wma_pro_cfg.valid_bits_per_sample =
-			codec_options->wma.bits_per_sample;
-		wma_pro_cfg.ch_mask = codec_options->wma.channelmask;
-		wma_pro_cfg.encode_opt = codec_options->wma.encodeopt;
-		wma_pro_cfg.adv_encode_opt = codec_options->wma.encodeopt1;
-		wma_pro_cfg.adv_encode_opt2 = codec_options->wma.encodeopt2;
-		ret = q6asm_media_format_block_wmapro(prtd->audio_client,
-				&wma_pro_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed\n", __func__);
-		break;
-	case FORMAT_MP2:
-		pr_debug("%s: SND_AUDIOCODEC_MP2\n", __func__);
-		break;
-	case FORMAT_FLAC:
-		pr_debug("%s: SND_AUDIOCODEC_FLAC\n", __func__);
-		memset(&flac_cfg, 0x0, sizeof(struct asm_flac_cfg));
-		flac_cfg.ch_cfg = prtd->num_channels;
-		flac_cfg.sample_rate = prtd->sample_rate;
-		flac_cfg.stream_info_present = 1;
-		flac_cfg.sample_size = codec_options->flac_dec.sample_size;
-		flac_cfg.min_blk_size = codec_options->flac_dec.min_blk_size;
-		flac_cfg.max_blk_size = codec_options->flac_dec.max_blk_size;
-		flac_cfg.max_frame_size =
-			codec_options->flac_dec.max_frame_size;
-		flac_cfg.min_frame_size =
-			codec_options->flac_dec.min_frame_size;
-
-		ret = q6asm_stream_media_format_block_flac(prtd->audio_client,
-							&flac_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed ret %d\n",
-				__func__, ret);
-
-		break;
-	case FORMAT_VORBIS:
-		pr_debug("%s: SND_AUDIOCODEC_VORBIS\n", __func__);
-		memset(&vorbis_cfg, 0x0, sizeof(struct asm_vorbis_cfg));
-		vorbis_cfg.bit_stream_fmt =
-			codec_options->vorbis_dec.bit_stream_fmt;
-
-		ret = q6asm_stream_media_format_block_vorbis(
-					prtd->audio_client, &vorbis_cfg,
-					stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed ret %d\n",
-					__func__, ret);
-
-		break;
-	case FORMAT_ALAC:
-		pr_debug("%s: SND_AUDIOCODEC_ALAC\n", __func__);
-		memset(&alac_cfg, 0x0, sizeof(struct asm_alac_cfg));
-		alac_cfg.num_channels = prtd->num_channels;
-		alac_cfg.sample_rate = prtd->sample_rate;
-		alac_cfg.frame_length = codec_options->alac.frame_length;
-		alac_cfg.compatible_version =
-			codec_options->alac.compatible_version;
-		alac_cfg.bit_depth = codec_options->alac.bit_depth;
-		alac_cfg.pb = codec_options->alac.pb;
-		alac_cfg.mb = codec_options->alac.mb;
-		alac_cfg.kb = codec_options->alac.kb;
-		alac_cfg.max_run = codec_options->alac.max_run;
-		alac_cfg.max_frame_bytes = codec_options->alac.max_frame_bytes;
-		alac_cfg.avg_bit_rate = codec_options->alac.avg_bit_rate;
-		alac_cfg.channel_layout_tag =
-			codec_options->alac.channel_layout_tag;
-
-		ret = q6asm_media_format_block_alac(prtd->audio_client,
-							&alac_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed ret %d\n",
-					__func__, ret);
-		break;
-	case FORMAT_APE:
-		pr_debug("%s: SND_AUDIOCODEC_APE\n", __func__);
-		memset(&ape_cfg, 0x0, sizeof(struct asm_ape_cfg));
-		ape_cfg.num_channels = prtd->num_channels;
-		ape_cfg.sample_rate = prtd->sample_rate;
-		ape_cfg.compatible_version =
-			codec_options->ape.compatible_version;
-		ape_cfg.compression_level =
-			codec_options->ape.compression_level;
-		ape_cfg.format_flags = codec_options->ape.format_flags;
-		ape_cfg.blocks_per_frame = codec_options->ape.blocks_per_frame;
-		ape_cfg.final_frame_blocks =
-			codec_options->ape.final_frame_blocks;
-		ape_cfg.total_frames = codec_options->ape.total_frames;
-		ape_cfg.bits_per_sample = codec_options->ape.bits_per_sample;
-		ape_cfg.seek_table_present =
-			codec_options->ape.seek_table_present;
-
-		ret = q6asm_media_format_block_ape(prtd->audio_client,
-							&ape_cfg, stream_id);
-
-		if (ret < 0)
-			pr_err("%s: CMD Format block failed ret %d\n",
-					__func__, ret);
-		break;
-	case FORMAT_DTS:
-		pr_debug("SND_AUDIOCODEC_DTS\n");
-		/* no media format block needed */
-		break;
-	case FORMAT_DSD:
-		pr_debug("%s: SND_AUDIOCODEC_DSD\n", __func__);
-		memset(&dsd_cfg, 0x0, sizeof(struct asm_dsd_cfg));
-		dsd_cfg.num_channels = prtd->num_channels;
-		dsd_cfg.dsd_data_rate = prtd->sample_rate;
-		dsd_cfg.num_version = 0;
-		dsd_cfg.is_bitwise_big_endian = 1;
-		dsd_cfg.dsd_channel_block_size = 1;
-		ret = q6asm_media_format_block_dsd(prtd->audio_client,
-						   &dsd_cfg, stream_id);
-		if (ret < 0)
-			pr_err("%s: CMD DSD Format block failed ret %d\n",
-				__func__, ret);
-		break;
-	case FORMAT_TRUEHD:
-		pr_debug("SND_AUDIOCODEC_TRUEHD\n");
-		/* no media format block needed */
-		break;
-	case FORMAT_IEC61937:
-		pr_debug("SND_AUDIOCODEC_IEC61937\n");
-		ret = q6asm_media_format_block_iec(prtd->audio_client,
-						   prtd->sample_rate,
-						   prtd->num_channels);
-		if (ret < 0)
-			pr_err("%s: CMD IEC61937 Format block failed ret %d\n",
-				__func__, ret);
-		break;
-	case FORMAT_APTX:
-		pr_debug("SND_AUDIOCODEC_APTX\n");
-		memset(&aptx_cfg, 0x0, sizeof(struct aptx_dec_bt_addr_cfg));
-		ret = q6asm_stream_media_format_block_aptx_dec(
-							prtd->audio_client,
-							prtd->sample_rate,
-							stream_id);
-		if (ret >= 0) {
-			aptx_cfg.nap = codec_options->aptx_dec.nap;
-			aptx_cfg.uap = codec_options->aptx_dec.uap;
-			aptx_cfg.lap = codec_options->aptx_dec.lap;
-			q6asm_set_aptx_dec_bt_addr(prtd->audio_client,
-							&aptx_cfg);
-		} else {
-			pr_err("%s: CMD Format block failed ret %d\n",
-					 __func__, ret);
-		}
-		break;
-	default:
-		pr_debug("%s, unsupported format, skip", __func__);
-		break;
-	}
-	return ret;
-}
-
-static int msm_compr_init_pp_params(struct snd_compr_stream *cstream,
-				    struct audio_client *ac)
-{
-	int ret = 0;
-	struct asm_softvolume_params softvol = {
-		.period = SOFT_VOLUME_PERIOD,
-		.step = SOFT_VOLUME_STEP,
-		.rampingcurve = SOFT_VOLUME_CURVE_LINEAR,
-	};
-
-	switch (ac->topology) {
-	default:
-		ret = q6asm_set_softvolume_v2(ac, &softvol,
-					      SOFT_VOLUME_INSTANCE_1);
-		if (ret < 0)
-			pr_err("%s: Send SoftVolume Param failed ret=%d\n",
-			__func__, ret);
-
-		break;
-	}
-	return ret;
-}
-
-static int msm_compr_configure_dsp_for_playback
-			(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *soc_prtd = cstream->private_data;
-	uint16_t bits_per_sample = 16;
-	int dir = IN, ret = 0;
-	struct audio_client *ac = prtd->audio_client;
-	uint32_t stream_index;
-	struct asm_softpause_params softpause = {
-		.enable = SOFT_PAUSE_ENABLE,
-		.period = SOFT_PAUSE_PERIOD,
-		.step = SOFT_PAUSE_STEP,
-		.rampingcurve = SOFT_PAUSE_CURVE_LINEAR,
-	};
-	struct asm_softvolume_params softvol = {
-		.period = SOFT_VOLUME_PERIOD,
-		.step = SOFT_VOLUME_STEP,
-		.rampingcurve = SOFT_VOLUME_CURVE_LINEAR,
-	};
-	struct snd_kcontrol *kctl;
-	struct snd_ctl_elem_value kctl_elem_value;
-	uint16_t target_asm_bit_width = 0;
-
-	pr_debug("%s: stream_id %d\n", __func__, ac->stream_id);
-	stream_index = STREAM_ARRAY_INDEX(ac->stream_id);
-	if (stream_index >= MAX_NUMBER_OF_STREAMS || stream_index < 0) {
-		pr_err("%s: Invalid stream index:%d", __func__, stream_index);
-		return -EINVAL;
-	}
-
-	kctl = snd_soc_card_get_kcontrol(soc_prtd->card,
-		DSP_BIT_WIDTH_MIXER_CTL);
-	if (kctl) {
-		kctl->get(kctl, &kctl_elem_value);
-		target_asm_bit_width = kctl_elem_value.value.integer.value[0];
-		if (target_asm_bit_width > 0) {
-			pr_debug("%s enforce ASM bitwidth to %d from %d\n",
-				__func__,
-				target_asm_bit_width,
-				bits_per_sample);
-			bits_per_sample = target_asm_bit_width;
-		}
-	} else {
-		pr_info("%s: failed to get mixer ctl for %s.\n",
-			__func__, DSP_BIT_WIDTH_MIXER_CTL);
-	}
-
-	if ((prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S24_LE) ||
-		(prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S24_3LE))
-		bits_per_sample = 24;
-	else if (prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S32_LE)
-		bits_per_sample = 32;
-
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		ret = q6asm_open_write_compressed(ac, prtd->codec,
-						  prtd->compr_passthr);
-		if (ret < 0) {
-			pr_err("%s:ASM open write err[%d] for compr_type[%d]\n",
-				__func__, ret, prtd->compr_passthr);
-			return ret;
-		}
-		prtd->gapless_state.stream_opened[stream_index] = 1;
-
-		ret = msm_pcm_routing_reg_phy_compr_stream(
-				soc_prtd->dai_link->id,
-				ac->perf_mode,
-				prtd->session_id,
-				SNDRV_PCM_STREAM_PLAYBACK,
-				prtd->compr_passthr);
-		if (ret) {
-			pr_err("%s: compr stream reg failed:%d\n", __func__,
-				ret);
-			return ret;
-		}
-	} else {
-		pr_debug("%s: stream_id %d bits_per_sample %d\n",
-				__func__, ac->stream_id, bits_per_sample);
-		ret = q6asm_stream_open_write_v4(ac,
-				prtd->codec, bits_per_sample,
-				ac->stream_id,
-				prtd->gapless_state.use_dsp_gapless_mode);
-		if (ret < 0) {
-			pr_err("%s:ASM open write err[%d] for compr type[%d]\n",
-				__func__, ret, prtd->compr_passthr);
-			return -ENOMEM;
-		}
-		prtd->gapless_state.stream_opened[stream_index] = 1;
-
-		pr_debug("%s: BE id %d\n", __func__, soc_prtd->dai_link->id);
-		ret = msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->id,
-				ac->perf_mode,
-				prtd->session_id,
-				SNDRV_PCM_STREAM_PLAYBACK);
-		if (ret) {
-			pr_err("%s: stream reg failed:%d\n", __func__, ret);
-			return ret;
-		}
-	}
-
-	ret = msm_compr_set_volume(cstream, 0, 0);
-	if (ret < 0)
-		pr_err("%s : Set Volume failed : %d", __func__, ret);
-
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		pr_debug("%s : Don't send cal and PP params for compress path",
-				__func__);
-	} else {
-		ret = q6asm_send_cal(ac);
-		if (ret < 0)
-			pr_debug("%s : Send cal failed : %d", __func__, ret);
-
-		ret = q6asm_set_softpause(ac, &softpause);
-		if (ret < 0)
-			pr_err("%s: Send SoftPause Param failed ret=%d\n",
-					__func__, ret);
-
-		ret = q6asm_set_softvolume(ac, &softvol);
-		if (ret < 0)
-			pr_err("%s: Send SoftVolume Param failed ret=%d\n",
-					__func__, ret);
-	}
-	ret = q6asm_set_io_mode(ac, (COMPRESSED_STREAM_IO | ASYNC_IO_MODE));
-	if (ret < 0) {
-		pr_err("%s: Set IO mode failed\n", __func__);
-		return -EINVAL;
-	}
-
-	runtime->fragments = prtd->codec_param.buffer.fragments;
-	runtime->fragment_size = prtd->codec_param.buffer.fragment_size;
-	pr_debug("allocate %d buffers each of size %d\n",
-			runtime->fragments,
-			runtime->fragment_size);
-	ret = q6asm_audio_client_buf_alloc_contiguous(dir, ac,
-					runtime->fragment_size,
-					runtime->fragments);
-	if (ret < 0) {
-		pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret);
-		return -ENOMEM;
-	}
-
-	prtd->byte_offset  = 0;
-	prtd->copied_total = 0;
-	prtd->app_pointer  = 0;
-	prtd->bytes_received = 0;
-	prtd->bytes_sent = 0;
-	prtd->buffer       = ac->port[dir].buf[0].data;
-	prtd->buffer_paddr = ac->port[dir].buf[0].phys;
-	prtd->buffer_size  = runtime->fragments * runtime->fragment_size;
-
-	/* Bit-0 of flags represent timestamp mode */
-	if (prtd->codec_param.codec.flags & COMPRESSED_TIMESTAMP_FLAG)
-		prtd->ts_header_offset = sizeof(struct snd_codec_metadata);
-	else
-		prtd->ts_header_offset = 0;
-
-	ret = msm_compr_send_media_format_block(cstream, ac->stream_id, false);
-	if (ret < 0)
-		pr_err("%s, failed to send media format block\n", __func__);
-
-	return ret;
-}
-
-static int msm_compr_configure_dsp_for_capture(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *soc_prtd = cstream->private_data;
-	uint16_t bits_per_sample;
-	uint16_t sample_word_size;
-	int dir = OUT, ret = 0;
-	struct audio_client *ac = prtd->audio_client;
-	uint32_t stream_index;
-
-	switch (prtd->codec_param.codec.format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bits_per_sample = 24;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		bits_per_sample = 24;
-		sample_word_size = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		bits_per_sample = 32;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bits_per_sample = 16;
-		sample_word_size = 16;
-		break;
-	}
-
-	pr_debug("%s: stream_id %d bits_per_sample %d\n",
-			__func__, ac->stream_id, bits_per_sample);
-
-	if (prtd->codec_param.codec.flags & COMPRESSED_TIMESTAMP_FLAG) {
-		ret = q6asm_open_read_v4(prtd->audio_client, FORMAT_LINEAR_PCM,
-			bits_per_sample, true);
-	} else {
-		ret = q6asm_open_read_v4(prtd->audio_client, FORMAT_LINEAR_PCM,
-			bits_per_sample, false);
-	}
-	if (ret < 0) {
-		pr_err("%s: q6asm_open_read failed:%d\n", __func__, ret);
-		return ret;
-	}
-
-	ret = msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->id,
-			ac->perf_mode,
-			prtd->session_id,
-			SNDRV_PCM_STREAM_CAPTURE);
-	if (ret) {
-		pr_err("%s: stream reg failed:%d\n", __func__, ret);
-		return ret;
-	}
-
-	ret = q6asm_set_io_mode(ac, (COMPRESSED_STREAM_IO | ASYNC_IO_MODE));
-	if (ret < 0) {
-		pr_err("%s: Set IO mode failed\n", __func__);
-		return -EINVAL;
-	}
-
-	stream_index = STREAM_ARRAY_INDEX(ac->stream_id);
-	if (stream_index >= MAX_NUMBER_OF_STREAMS || stream_index < 0) {
-		pr_err("%s: Invalid stream index:%d", __func__, stream_index);
-		return -EINVAL;
-	}
-
-	runtime->fragments = prtd->codec_param.buffer.fragments;
-	runtime->fragment_size = prtd->codec_param.buffer.fragment_size;
-	pr_debug("%s: allocate %d buffers each of size %d\n",
-			__func__, runtime->fragments,
-			runtime->fragment_size);
-	ret = q6asm_audio_client_buf_alloc_contiguous(dir, ac,
-					runtime->fragment_size,
-					runtime->fragments);
-	if (ret < 0) {
-		pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret);
-		return -ENOMEM;
-	}
-
-	prtd->byte_offset    = 0;
-	prtd->received_total = 0;
-	prtd->app_pointer    = 0;
-	prtd->bytes_copied   = 0;
-	prtd->bytes_read     = 0;
-	prtd->bytes_read_offset = 0;
-	prtd->buffer         = ac->port[dir].buf[0].data;
-	prtd->buffer_paddr   = ac->port[dir].buf[0].phys;
-	prtd->buffer_size    = runtime->fragments * runtime->fragment_size;
-
-	/* Bit-0 of flags represent timestamp mode */
-	if (prtd->codec_param.codec.flags & COMPRESSED_TIMESTAMP_FLAG)
-		prtd->ts_header_offset = sizeof(struct snd_codec_metadata);
-	else
-		prtd->ts_header_offset = 0;
-
-	pr_debug("%s: sample_rate = %d channels = %d bps = %d sample_word_size = %d\n",
-			__func__, prtd->sample_rate, prtd->num_channels,
-					 bits_per_sample, sample_word_size);
-	ret = q6asm_enc_cfg_blk_pcm_format_support_v3(prtd->audio_client,
-					prtd->sample_rate, prtd->num_channels,
-					bits_per_sample, sample_word_size);
-
-	return ret;
-}
-
-static int msm_compr_playback_open(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct msm_compr_audio *prtd;
-	struct msm_compr_pdata *pdata =
-			snd_soc_platform_get_drvdata(rtd->platform);
-
-	pr_debug("%s\n", __func__);
-	prtd = kzalloc(sizeof(struct msm_compr_audio), GFP_KERNEL);
-	if (prtd == NULL) {
-		pr_err("Failed to allocate memory for msm_compr_audio\n");
-		return -ENOMEM;
-	}
-
-	runtime->private_data = NULL;
-	prtd->cstream = cstream;
-	pdata->cstream[rtd->dai_link->id] = cstream;
-	pdata->audio_effects[rtd->dai_link->id] =
-		 kzalloc(sizeof(struct msm_compr_audio_effects), GFP_KERNEL);
-	if (!pdata->audio_effects[rtd->dai_link->id]) {
-		pr_err("%s: Could not allocate memory for effects\n", __func__);
-		pdata->cstream[rtd->dai_link->id] = NULL;
-		kfree(prtd);
-		return -ENOMEM;
-	}
-	pdata->dec_params[rtd->dai_link->id] =
-		 kzalloc(sizeof(struct msm_compr_dec_params), GFP_KERNEL);
-	if (!pdata->dec_params[rtd->dai_link->id]) {
-		pr_err("%s: Could not allocate memory for dec params\n",
-			__func__);
-		kfree(pdata->audio_effects[rtd->dai_link->id]);
-		pdata->cstream[rtd->dai_link->id] = NULL;
-		kfree(prtd);
-		return -ENOMEM;
-	}
-	prtd->codec = FORMAT_MP3;
-	prtd->bytes_received = 0;
-	prtd->bytes_sent = 0;
-	prtd->copied_total = 0;
-	prtd->byte_offset = 0;
-	prtd->sample_rate = 44100;
-	prtd->num_channels = 2;
-	prtd->drain_ready = 0;
-	prtd->last_buffer = 0;
-	prtd->first_buffer = 1;
-	prtd->partial_drain_delay = 0;
-	prtd->next_stream = 0;
-	memset(&prtd->gapless_state, 0, sizeof(struct msm_compr_gapless_state));
-	/*
-	 * Update the use_dsp_gapless_mode from gapless struture with the value
-	 * part of platform data.
-	 */
-	prtd->gapless_state.use_dsp_gapless_mode = pdata->use_dsp_gapless_mode;
-
-	pr_debug("%s: gapless mode %d", __func__, pdata->use_dsp_gapless_mode);
-
-	spin_lock_init(&prtd->lock);
-
-	atomic_set(&prtd->eos, 0);
-	atomic_set(&prtd->start, 0);
-	atomic_set(&prtd->drain, 0);
-	atomic_set(&prtd->xrun, 0);
-	atomic_set(&prtd->close, 0);
-	atomic_set(&prtd->wait_on_close, 0);
-	atomic_set(&prtd->error, 0);
-
-	init_waitqueue_head(&prtd->eos_wait);
-	init_waitqueue_head(&prtd->drain_wait);
-	init_waitqueue_head(&prtd->close_wait);
-	init_waitqueue_head(&prtd->wait_for_stream_avail);
-
-	runtime->private_data = prtd;
-	populate_codec_list(prtd);
-	prtd->audio_client = q6asm_audio_client_alloc(
-				(app_cb)compr_event_handler, prtd);
-	if (!prtd->audio_client) {
-		pr_err("%s: Could not allocate memory for client\n", __func__);
-		kfree(pdata->audio_effects[rtd->dai_link->id]);
-		kfree(pdata->dec_params[rtd->dai_link->id]);
-		pdata->cstream[rtd->dai_link->id] = NULL;
-		runtime->private_data = NULL;
-		kfree(prtd);
-		return -ENOMEM;
-	}
-	pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session);
-	prtd->audio_client->perf_mode = false;
-	prtd->session_id = prtd->audio_client->session;
-	msm_adsp_init_mixer_ctl_pp_event_queue(rtd);
-
-	return 0;
-}
-
-static int msm_compr_capture_open(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct msm_compr_audio *prtd;
-	struct msm_compr_pdata *pdata =
-			snd_soc_platform_get_drvdata(rtd->platform);
-
-	pr_debug("%s\n", __func__);
-	prtd = kzalloc(sizeof(struct msm_compr_audio), GFP_KERNEL);
-	if (prtd == NULL) {
-		pr_err("Failed to allocate memory for msm_compr_audio\n");
-		return -ENOMEM;
-	}
-
-	runtime->private_data = NULL;
-	prtd->cstream = cstream;
-	pdata->cstream[rtd->dai_link->id] = cstream;
-
-	prtd->audio_client = q6asm_audio_client_alloc(
-				(app_cb)compr_event_handler, prtd);
-	if (!prtd->audio_client) {
-		pr_err("%s: Could not allocate memory for client\n", __func__);
-		pdata->cstream[rtd->dai_link->id] = NULL;
-		kfree(prtd);
-		return -ENOMEM;
-	}
-	pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session);
-	prtd->audio_client->perf_mode = false;
-	prtd->session_id = prtd->audio_client->session;
-	prtd->codec = FORMAT_LINEAR_PCM;
-	prtd->bytes_copied = 0;
-	prtd->bytes_read = 0;
-	prtd->bytes_read_offset = 0;
-	prtd->received_total = 0;
-	prtd->byte_offset = 0;
-	prtd->sample_rate = 48000;
-	prtd->num_channels = 2;
-	prtd->first_buffer = 0;
-
-	spin_lock_init(&prtd->lock);
-
-	atomic_set(&prtd->eos, 0);
-	atomic_set(&prtd->start, 0);
-	atomic_set(&prtd->drain, 0);
-	atomic_set(&prtd->xrun, 0);
-	atomic_set(&prtd->close, 0);
-	atomic_set(&prtd->wait_on_close, 0);
-	atomic_set(&prtd->error, 0);
-
-	runtime->private_data = prtd;
-
-	return 0;
-}
-
-static int msm_compr_open(struct snd_compr_stream *cstream)
-{
-	int ret = 0;
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		ret = msm_compr_playback_open(cstream);
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		ret = msm_compr_capture_open(cstream);
-	return ret;
-}
-
-static int msm_compr_playback_free(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime;
-	struct msm_compr_audio *prtd;
-	struct snd_soc_pcm_runtime *soc_prtd;
-	struct msm_compr_pdata *pdata;
-	struct audio_client *ac;
-	int dir = IN, ret = 0, stream_id;
-	unsigned long flags;
-	uint32_t stream_index;
-
-	pr_debug("%s\n", __func__);
-
-	if (!cstream) {
-		pr_err("%s cstream is null\n", __func__);
-		return 0;
-	}
-	runtime = cstream->runtime;
-	soc_prtd = cstream->private_data;
-	if (!runtime || !soc_prtd || !(soc_prtd->platform)) {
-		pr_err("%s runtime or soc_prtd or platform is null\n",
-			__func__);
-		return 0;
-	}
-	prtd = runtime->private_data;
-	if (!prtd) {
-		pr_err("%s prtd is null\n", __func__);
-		return 0;
-	}
-	prtd->cmd_interrupt = 1;
-	wake_up(&prtd->drain_wait);
-	pdata = snd_soc_platform_get_drvdata(soc_prtd->platform);
-	ac = prtd->audio_client;
-	if (!pdata || !ac) {
-		pr_err("%s pdata or ac is null\n", __func__);
-		return 0;
-	}
-	if (atomic_read(&prtd->eos)) {
-		ret = wait_event_timeout(prtd->eos_wait,
-					 prtd->eos_ack, 5 * HZ);
-		if (!ret)
-			pr_err("%s: CMD_EOS failed\n", __func__);
-	}
-	if (atomic_read(&prtd->close)) {
-		prtd->cmd_ack = 0;
-		atomic_set(&prtd->wait_on_close, 1);
-		ret = wait_event_timeout(prtd->close_wait,
-					prtd->cmd_ack, 5 * HZ);
-		if (!ret)
-			pr_err("%s: CMD_CLOSE failed\n", __func__);
-	}
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	stream_id = ac->stream_id;
-	stream_index = STREAM_ARRAY_INDEX(NEXT_STREAM_ID(stream_id));
-
-	if ((stream_index < MAX_NUMBER_OF_STREAMS && stream_index >= 0) &&
-	    (prtd->gapless_state.stream_opened[stream_index])) {
-		prtd->gapless_state.stream_opened[stream_index] = 0;
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		pr_debug(" close stream %d", NEXT_STREAM_ID(stream_id));
-		q6asm_stream_cmd(ac, CMD_CLOSE, NEXT_STREAM_ID(stream_id));
-		spin_lock_irqsave(&prtd->lock, flags);
-	}
-
-	stream_index = STREAM_ARRAY_INDEX(stream_id);
-	if ((stream_index < MAX_NUMBER_OF_STREAMS && stream_index >= 0) &&
-	    (prtd->gapless_state.stream_opened[stream_index])) {
-		prtd->gapless_state.stream_opened[stream_index] = 0;
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		pr_debug("close stream %d", stream_id);
-		q6asm_stream_cmd(ac, CMD_CLOSE, stream_id);
-		spin_lock_irqsave(&prtd->lock, flags);
-	}
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	pdata->cstream[soc_prtd->dai_link->id] = NULL;
-	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-		msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->id,
-						SNDRV_PCM_STREAM_PLAYBACK);
-	}
-
-	q6asm_audio_client_buf_free_contiguous(dir, ac);
-
-	q6asm_audio_client_free(ac);
-	msm_adsp_clean_mixer_ctl_pp_event_queue(soc_prtd);
-	kfree(pdata->audio_effects[soc_prtd->dai_link->id]);
-	pdata->audio_effects[soc_prtd->dai_link->id] = NULL;
-	kfree(pdata->dec_params[soc_prtd->dai_link->id]);
-	pdata->dec_params[soc_prtd->dai_link->id] = NULL;
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_compr_capture_free(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime;
-	struct msm_compr_audio *prtd;
-	struct snd_soc_pcm_runtime *soc_prtd;
-	struct msm_compr_pdata *pdata;
-	struct audio_client *ac;
-	int dir = OUT, stream_id;
-	unsigned long flags;
-	uint32_t stream_index;
-
-	if (!cstream) {
-		pr_err("%s cstream is null\n", __func__);
-		return 0;
-	}
-	runtime = cstream->runtime;
-	soc_prtd = cstream->private_data;
-	if (!runtime || !soc_prtd || !(soc_prtd->platform)) {
-		pr_err("%s runtime or soc_prtd or platform is null\n",
-			__func__);
-		return 0;
-	}
-	prtd = runtime->private_data;
-	if (!prtd) {
-		pr_err("%s prtd is null\n", __func__);
-		return 0;
-	}
-	pdata = snd_soc_platform_get_drvdata(soc_prtd->platform);
-	ac = prtd->audio_client;
-	if (!pdata || !ac) {
-		pr_err("%s pdata or ac is null\n", __func__);
-		return 0;
-	}
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	stream_id = ac->stream_id;
-
-	stream_index = STREAM_ARRAY_INDEX(stream_id);
-	if ((stream_index < MAX_NUMBER_OF_STREAMS && stream_index >= 0)) {
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		pr_debug("close stream %d", stream_id);
-		q6asm_stream_cmd(ac, CMD_CLOSE, stream_id);
-		spin_lock_irqsave(&prtd->lock, flags);
-	}
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	pdata->cstream[soc_prtd->dai_link->id] = NULL;
-	msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->id,
-					SNDRV_PCM_STREAM_CAPTURE);
-
-	q6asm_audio_client_buf_free_contiguous(dir, ac);
-
-	q6asm_audio_client_free(ac);
-
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_compr_free(struct snd_compr_stream *cstream)
-{
-	int ret = 0;
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		ret = msm_compr_playback_free(cstream);
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		ret = msm_compr_capture_free(cstream);
-	return ret;
-}
-
-static bool msm_compr_validate_codec_compr(__u32 codec_id)
-{
-	int32_t i;
-
-	for (i = 0; i < ARRAY_SIZE(compr_codecs); i++) {
-		if (compr_codecs[i] == codec_id)
-			return true;
-	}
-	return false;
-}
-
-/* compress stream operations */
-static int msm_compr_set_params(struct snd_compr_stream *cstream,
-				struct snd_compr_params *params)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	int ret = 0, frame_sz = 0;
-	int i, num_rates;
-	bool is_format_gapless = false;
-
-	pr_debug("%s\n", __func__);
-
-	num_rates = sizeof(supported_sample_rates)/sizeof(unsigned int);
-	for (i = 0; i < num_rates; i++)
-		if (params->codec.sample_rate == supported_sample_rates[i])
-			break;
-	if (i == num_rates)
-		return -EINVAL;
-
-	memcpy(&prtd->codec_param, params, sizeof(struct snd_compr_params));
-	/* ToDo: remove duplicates */
-	prtd->num_channels = prtd->codec_param.codec.ch_in;
-	prtd->sample_rate = prtd->codec_param.codec.sample_rate;
-	pr_debug("%s: sample_rate %d\n", __func__, prtd->sample_rate);
-
-	if ((prtd->codec_param.codec.compr_passthr >= LEGACY_PCM &&
-	    prtd->codec_param.
-	    codec.compr_passthr <= COMPRESSED_PASSTHROUGH_DSD) ||
-	    (prtd->codec_param.
-	    codec.compr_passthr == COMPRESSED_PASSTHROUGH_IEC61937))
-		prtd->compr_passthr = prtd->codec_param.codec.compr_passthr;
-	else
-		prtd->compr_passthr = LEGACY_PCM;
-	pr_debug("%s: compr_passthr = %d", __func__, prtd->compr_passthr);
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		pr_debug("%s: Reset gapless mode playback for compr_type[%d]\n",
-			__func__, prtd->compr_passthr);
-		prtd->gapless_state.use_dsp_gapless_mode = 0;
-		if (!msm_compr_validate_codec_compr(params->codec.id)) {
-			pr_err("%s codec not supported in passthrough,id =%d\n",
-				 __func__, params->codec.id);
-			return -EINVAL;
-		}
-	}
-
-	switch (params->codec.id) {
-	case SND_AUDIOCODEC_PCM: {
-		pr_debug("SND_AUDIOCODEC_PCM\n");
-		prtd->codec = FORMAT_LINEAR_PCM;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_MP3: {
-		pr_debug("SND_AUDIOCODEC_MP3\n");
-		prtd->codec = FORMAT_MP3;
-		frame_sz = MP3_OUTPUT_FRAME_SZ;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_AAC: {
-		pr_debug("SND_AUDIOCODEC_AAC\n");
-		prtd->codec = FORMAT_MPEG4_AAC;
-		frame_sz = AAC_OUTPUT_FRAME_SZ;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_AC3: {
-		pr_debug("SND_AUDIOCODEC_AC3\n");
-		prtd->codec = FORMAT_AC3;
-		frame_sz = AC3_OUTPUT_FRAME_SZ;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_EAC3: {
-		pr_debug("SND_AUDIOCODEC_EAC3\n");
-		prtd->codec = FORMAT_EAC3;
-		frame_sz = EAC3_OUTPUT_FRAME_SZ;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_MP2: {
-		pr_debug("SND_AUDIOCODEC_MP2\n");
-		prtd->codec = FORMAT_MP2;
-		break;
-	}
-
-	case SND_AUDIOCODEC_WMA: {
-		pr_debug("SND_AUDIOCODEC_WMA\n");
-		prtd->codec = FORMAT_WMA_V9;
-		break;
-	}
-
-	case SND_AUDIOCODEC_WMA_PRO: {
-		pr_debug("SND_AUDIOCODEC_WMA_PRO\n");
-		prtd->codec = FORMAT_WMA_V10PRO;
-		break;
-	}
-
-	case SND_AUDIOCODEC_FLAC: {
-		pr_debug("%s: SND_AUDIOCODEC_FLAC\n", __func__);
-		prtd->codec = FORMAT_FLAC;
-		/*
-		 * DSP bufferring is based on blk size,
-		 * consider mininum buffering to rule out any false wait
-		 */
-		frame_sz =
-			prtd->codec_param.codec.options.flac_dec.min_blk_size;
-		is_format_gapless = true;
-		break;
-	}
-
-	case SND_AUDIOCODEC_VORBIS: {
-		pr_debug("%s: SND_AUDIOCODEC_VORBIS\n", __func__);
-		prtd->codec = FORMAT_VORBIS;
-		break;
-	}
-
-	case SND_AUDIOCODEC_ALAC: {
-		pr_debug("%s: SND_AUDIOCODEC_ALAC\n", __func__);
-		prtd->codec = FORMAT_ALAC;
-		break;
-	}
-
-	case SND_AUDIOCODEC_APE: {
-		pr_debug("%s: SND_AUDIOCODEC_APE\n", __func__);
-		prtd->codec = FORMAT_APE;
-		break;
-	}
-
-	case SND_AUDIOCODEC_DTS: {
-		pr_debug("%s: SND_AUDIOCODEC_DTS\n", __func__);
-		prtd->codec = FORMAT_DTS;
-		break;
-	}
-
-	case SND_AUDIOCODEC_DSD: {
-		pr_debug("%s: SND_AUDIOCODEC_DSD\n", __func__);
-		prtd->codec = FORMAT_DSD;
-		break;
-	}
-
-	case SND_AUDIOCODEC_TRUEHD: {
-		pr_debug("%s: SND_AUDIOCODEC_TRUEHD\n", __func__);
-		prtd->codec = FORMAT_TRUEHD;
-		break;
-	}
-
-	case SND_AUDIOCODEC_IEC61937: {
-		pr_debug("%s: SND_AUDIOCODEC_IEC61937\n", __func__);
-		prtd->codec = FORMAT_IEC61937;
-		break;
-	}
-
-	case SND_AUDIOCODEC_APTX: {
-		pr_debug("%s: SND_AUDIOCODEC_APTX\n", __func__);
-		prtd->codec = FORMAT_APTX;
-		break;
-	}
-
-	default:
-		pr_err("codec not supported, id =%d\n", params->codec.id);
-		return -EINVAL;
-	}
-
-	if (!is_format_gapless)
-		prtd->gapless_state.use_dsp_gapless_mode = false;
-
-	prtd->partial_drain_delay =
-		msm_compr_get_partial_drain_delay(frame_sz, prtd->sample_rate);
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		ret = msm_compr_configure_dsp_for_playback(cstream);
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		ret = msm_compr_configure_dsp_for_capture(cstream);
-
-	return ret;
-}
-
-static int msm_compr_drain_buffer(struct msm_compr_audio *prtd,
-				  unsigned long *flags)
-{
-	int rc = 0;
-
-	atomic_set(&prtd->drain, 1);
-	prtd->drain_ready = 0;
-	spin_unlock_irqrestore(&prtd->lock, *flags);
-	pr_debug("%s: wait for buffer to be drained\n",  __func__);
-	rc = wait_event_interruptible(prtd->drain_wait,
-					prtd->drain_ready ||
-					prtd->cmd_interrupt ||
-					atomic_read(&prtd->xrun) ||
-					atomic_read(&prtd->error));
-	pr_debug("%s: out of buffer drain wait with ret %d\n", __func__, rc);
-	spin_lock_irqsave(&prtd->lock, *flags);
-	if (prtd->cmd_interrupt) {
-		pr_debug("%s: buffer drain interrupted by flush)\n", __func__);
-		rc = -EINTR;
-		prtd->cmd_interrupt = 0;
-	}
-	if (atomic_read(&prtd->error)) {
-		pr_err("%s: Got RESET EVENTS notification, return\n",
-			__func__);
-		rc = -ENETRESET;
-	}
-	return rc;
-}
-
-static int msm_compr_wait_for_stream_avail(struct msm_compr_audio *prtd,
-				    unsigned long *flags)
-{
-	int rc = 0;
-
-	pr_debug("next session is already in opened state\n");
-	prtd->next_stream = 1;
-	prtd->cmd_interrupt = 0;
-	spin_unlock_irqrestore(&prtd->lock, *flags);
-	/*
-	 * Wait for stream to be available, or the wait to be interrupted by
-	 * commands like flush or till a timeout of one second.
-	 */
-	rc = wait_event_timeout(prtd->wait_for_stream_avail,
-		prtd->stream_available || prtd->cmd_interrupt, 1 * HZ);
-	pr_err("%s:prtd->stream_available %d, prtd->cmd_interrupt %d rc %d\n",
-		   __func__, prtd->stream_available, prtd->cmd_interrupt, rc);
-
-	spin_lock_irqsave(&prtd->lock, *flags);
-	if (rc == 0) {
-		pr_err("%s: wait_for_stream_avail timed out\n",
-						__func__);
-		rc =  -ETIMEDOUT;
-	} else if (prtd->cmd_interrupt == 1) {
-		/*
-		 * This scenario might not happen as we do not allow
-		 * flush in transition state.
-		 */
-		pr_debug("%s: wait_for_stream_avail interrupted\n", __func__);
-		prtd->cmd_interrupt = 0;
-		prtd->stream_available = 0;
-		rc = -EINTR;
-	} else {
-		prtd->stream_available = 0;
-		rc = 0;
-	}
-	pr_debug("%s : rc = %d",  __func__, rc);
-	return rc;
-}
-
-static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct msm_compr_pdata *pdata =
-			snd_soc_platform_get_drvdata(rtd->platform);
-	uint32_t *volume = pdata->volume[rtd->dai_link->id];
-	struct audio_client *ac = prtd->audio_client;
-	unsigned long fe_id = rtd->dai_link->id;
-	int rc = 0;
-	int bytes_to_write;
-	unsigned long flags;
-	int stream_id;
-	uint32_t stream_index;
-	uint16_t bits_per_sample = 16;
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	if (atomic_read(&prtd->error)) {
-		pr_err("%s Got RESET EVENTS notification, return immediately",
-			__func__);
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		return 0;
-	}
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-		pr_debug("%s: SNDRV_PCM_TRIGGER_START\n", __func__);
-		atomic_set(&prtd->start, 1);
-
-		/*
-		 * compr_set_volume and compr_init_pp_params
-		 * are used to configure ASM volume hence not
-		 * needed for compress passthrough playback.
-		 *
-		 * compress passthrough volume is controlled in
-		 * ADM by adm_send_compressed_device_mute()
-		 */
-		if (prtd->compr_passthr == LEGACY_PCM &&
-			cstream->direction == SND_COMPRESS_PLAYBACK) {
-			/* set volume for the stream before RUN */
-			rc = msm_compr_set_volume(cstream,
-				volume[0], volume[1]);
-			if (rc)
-				pr_err("%s : Set Volume failed : %d\n",
-					__func__, rc);
-
-			rc = msm_compr_init_pp_params(cstream, ac);
-			if (rc)
-				pr_err("%s : init PP params failed : %d\n",
-					__func__, rc);
-		} else {
-			msm_compr_read_buffer(prtd);
-		}
-		/* issue RUN command for the stream */
-		q6asm_run_nowait(prtd->audio_client, prtd->run_mode,
-				 prtd->start_delay_msw, prtd->start_delay_lsw);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		spin_lock_irqsave(&prtd->lock, flags);
-		pr_debug("%s: SNDRV_PCM_TRIGGER_STOP transition %d\n", __func__,
-					prtd->gapless_state.gapless_transition);
-		stream_id = ac->stream_id;
-		atomic_set(&prtd->start, 0);
-		if (cstream->direction == SND_COMPRESS_CAPTURE) {
-			q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE);
-			atomic_set(&prtd->xrun, 0);
-			prtd->received_total = 0;
-			prtd->bytes_copied = 0;
-			prtd->bytes_read = 0;
-			prtd->bytes_read_offset = 0;
-			prtd->byte_offset  = 0;
-			prtd->app_pointer  = 0;
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-		if (prtd->next_stream) {
-			pr_debug("%s: interrupt next track wait queues\n",
-								__func__);
-			prtd->cmd_interrupt = 1;
-			wake_up(&prtd->wait_for_stream_avail);
-			prtd->next_stream = 0;
-		}
-		if (atomic_read(&prtd->eos)) {
-			pr_debug("%s: interrupt eos wait queues", __func__);
-			/*
-			 * Gapless playback does not wait for eos, do not set
-			 * cmd_int and do not wake up eos_wait during gapless
-			 * transition
-			 */
-			if (!prtd->gapless_state.gapless_transition) {
-				prtd->cmd_interrupt = 1;
-				wake_up(&prtd->eos_wait);
-			}
-			atomic_set(&prtd->eos, 0);
-		}
-		if (atomic_read(&prtd->drain)) {
-			pr_debug("%s: interrupt drain wait queues", __func__);
-			prtd->cmd_interrupt = 1;
-			prtd->drain_ready = 1;
-			wake_up(&prtd->drain_wait);
-			atomic_set(&prtd->drain, 0);
-		}
-		prtd->last_buffer = 0;
-		prtd->cmd_ack = 0;
-		if (!prtd->gapless_state.gapless_transition) {
-			pr_debug("issue CMD_FLUSH stream_id %d\n", stream_id);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			q6asm_stream_cmd(
-				prtd->audio_client, CMD_FLUSH, stream_id);
-			spin_lock_irqsave(&prtd->lock, flags);
-		} else {
-			prtd->first_buffer = 0;
-		}
-		/* FIXME. only reset if flush was successful */
-		prtd->byte_offset  = 0;
-		prtd->copied_total = 0;
-		prtd->app_pointer  = 0;
-		prtd->bytes_received = 0;
-		prtd->bytes_sent = 0;
-		prtd->marker_timestamp = 0;
-
-		atomic_set(&prtd->xrun, 0);
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		break;
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		pr_debug("SNDRV_PCM_TRIGGER_PAUSE_PUSH transition %d\n",
-				prtd->gapless_state.gapless_transition);
-		if (!prtd->gapless_state.gapless_transition) {
-			pr_debug("issue CMD_PAUSE stream_id %d\n",
-				  ac->stream_id);
-			q6asm_stream_cmd_nowait(ac, CMD_PAUSE, ac->stream_id);
-			atomic_set(&prtd->start, 0);
-		}
-		break;
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		pr_debug("SNDRV_PCM_TRIGGER_PAUSE_RELEASE transition %d\n",
-				   prtd->gapless_state.gapless_transition);
-		if (!prtd->gapless_state.gapless_transition) {
-			atomic_set(&prtd->start, 1);
-			q6asm_run_nowait(prtd->audio_client, prtd->run_mode,
-					 0, 0);
-		}
-		break;
-	case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
-		pr_debug("%s: SND_COMPR_TRIGGER_PARTIAL_DRAIN\n", __func__);
-		if (!prtd->gapless_state.use_dsp_gapless_mode) {
-			pr_debug("%s: set partial drain as drain\n", __func__);
-			cmd = SND_COMPR_TRIGGER_DRAIN;
-		}
-	case SND_COMPR_TRIGGER_DRAIN:
-		pr_debug("%s: SNDRV_COMPRESS_DRAIN\n", __func__);
-		/* Make sure all the data is sent to DSP before sending EOS */
-		spin_lock_irqsave(&prtd->lock, flags);
-
-		if (!atomic_read(&prtd->start)) {
-			pr_err("%s: stream is not in started state\n",
-				__func__);
-			rc = -EPERM;
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-		if (prtd->bytes_received > prtd->copied_total) {
-			pr_debug("%s: wait till all the data is sent to dsp\n",
-				__func__);
-			rc = msm_compr_drain_buffer(prtd, &flags);
-			if (rc || !atomic_read(&prtd->start)) {
-				if (rc != -ENETRESET)
-					rc = -EINTR;
-				spin_unlock_irqrestore(&prtd->lock, flags);
-				break;
-			}
-			/*
-			 * FIXME: Bug.
-			 * Write(32767)
-			 * Start
-			 * Drain <- Indefinite wait
-			 * sol1 : if (prtd->copied_total) then wait?
-			 * sol2 : (prtd->cmd_interrupt || prtd->drain_ready ||
-			 *	   atomic_read(xrun)
-			 */
-			bytes_to_write = prtd->bytes_received
-						- prtd->copied_total;
-			WARN(bytes_to_write > runtime->fragment_size,
-			     "last write %d cannot be > than fragment_size",
-			     bytes_to_write);
-
-			if (bytes_to_write > 0) {
-				pr_debug("%s: send %d partial bytes at the end",
-				       __func__, bytes_to_write);
-				atomic_set(&prtd->xrun, 0);
-				prtd->last_buffer = 1;
-				msm_compr_send_buffer(prtd);
-			}
-		}
-
-		if ((cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN) &&
-		    (prtd->gapless_state.set_next_stream_id)) {
-			/* wait for the last buffer to be returned */
-
-			if (prtd->last_buffer) {
-				pr_debug("%s: last buffer drain\n", __func__);
-				rc = msm_compr_drain_buffer(prtd, &flags);
-				if (rc || !atomic_read(&prtd->start)) {
-					spin_unlock_irqrestore(&prtd->lock,
-									flags);
-					break;
-				}
-			}
-			/* send EOS */
-			prtd->eos_ack = 0;
-			atomic_set(&prtd->eos, 1);
-			pr_debug("issue CMD_EOS stream_id %d\n", ac->stream_id);
-			q6asm_stream_cmd_nowait(ac, CMD_EOS, ac->stream_id);
-			pr_info("PARTIAL DRAIN, do not wait for EOS ack\n");
-
-			/* send a zero length buffer */
-			atomic_set(&prtd->xrun, 0);
-			msm_compr_send_buffer(prtd);
-
-			/* wait for the zero length buffer to be returned */
-			pr_debug("%s: zero length buffer drain\n", __func__);
-			rc = msm_compr_drain_buffer(prtd, &flags);
-			if (rc || !atomic_read(&prtd->start)) {
-				spin_unlock_irqrestore(&prtd->lock, flags);
-				break;
-			}
-
-			/* sleep for additional duration partial drain */
-			atomic_set(&prtd->drain, 1);
-			prtd->drain_ready = 0;
-			pr_debug("%s, additional sleep: %d\n", __func__,
-				 prtd->partial_drain_delay);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			rc = wait_event_timeout(prtd->drain_wait,
-				prtd->drain_ready || prtd->cmd_interrupt,
-				msecs_to_jiffies(prtd->partial_drain_delay));
-			pr_debug("%s: out of additional wait for low sample rate\n",
-				 __func__);
-			spin_lock_irqsave(&prtd->lock, flags);
-			if (prtd->cmd_interrupt) {
-				pr_debug("%s: additional wait interrupted by flush)\n",
-					 __func__);
-				rc = -EINTR;
-				prtd->cmd_interrupt = 0;
-				spin_unlock_irqrestore(&prtd->lock, flags);
-				break;
-			}
-
-			/* move to next stream and reset vars */
-			pr_debug("%s: Moving to next stream in gapless\n",
-								__func__);
-			ac->stream_id = NEXT_STREAM_ID(ac->stream_id);
-			prtd->byte_offset = 0;
-			prtd->app_pointer  = 0;
-			prtd->first_buffer = 1;
-			prtd->last_buffer = 0;
-			/*
-			 * Set gapless transition flag only if EOS hasn't been
-			 * acknowledged already.
-			 */
-			if (atomic_read(&prtd->eos))
-				prtd->gapless_state.gapless_transition = 1;
-			prtd->marker_timestamp = 0;
-
-			/*
-			 * Don't reset these as these vars map to
-			 * total_bytes_transferred and total_bytes_available
-			 * directly, only total_bytes_transferred will be
-			 * updated in the next avail() ioctl
-			 *	prtd->copied_total = 0;
-			 *	prtd->bytes_received = 0;
-			 */
-			atomic_set(&prtd->drain, 0);
-			atomic_set(&prtd->xrun, 1);
-			pr_debug("%s: issue CMD_RUN", __func__);
-			q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			break;
-		}
-		/*
-		 * moving to next stream failed, so reset the gapless state
-		 * set next stream id for the same session so that the same
-		 * stream can be used for gapless playback
-		 */
-		prtd->gapless_state.set_next_stream_id = false;
-		prtd->gapless_state.gapless_transition = 0;
-		pr_debug("%s:CMD_EOS stream_id %d\n", __func__, ac->stream_id);
-
-		prtd->eos_ack = 0;
-		atomic_set(&prtd->eos, 1);
-		q6asm_stream_cmd_nowait(ac, CMD_EOS, ac->stream_id);
-
-		spin_unlock_irqrestore(&prtd->lock, flags);
-
-
-		/* Wait indefinitely for  DRAIN. Flush can also signal this*/
-		rc = wait_event_interruptible(prtd->eos_wait,
-						(prtd->eos_ack ||
-						prtd->cmd_interrupt ||
-						atomic_read(&prtd->error)));
-
-		if (rc < 0)
-			pr_err("%s: EOS wait failed\n", __func__);
-
-		pr_debug("%s: SNDRV_COMPRESS_DRAIN  out of wait for EOS\n",
-			  __func__);
-
-		if (prtd->cmd_interrupt)
-			rc = -EINTR;
-
-		if (atomic_read(&prtd->error)) {
-			pr_err("%s: Got RESET EVENTS notification, return\n",
-				__func__);
-			rc = -ENETRESET;
-		}
-
-		/*FIXME : what if a flush comes while PC is here */
-		if (rc == 0) {
-			/*
-			 * Failed to open second stream in DSP for gapless
-			 * so prepare the current stream in session
-			 * for gapless playback
-			 */
-			spin_lock_irqsave(&prtd->lock, flags);
-			pr_debug("%s:issue CMD_PAUSE stream_id %d",
-					  __func__, ac->stream_id);
-			q6asm_stream_cmd_nowait(ac, CMD_PAUSE, ac->stream_id);
-			prtd->cmd_ack = 0;
-			spin_unlock_irqrestore(&prtd->lock, flags);
-
-			/*
-			 * Cache this time as last known time
-			 */
-			if (pdata->use_legacy_api)
-				q6asm_get_session_time_legacy(
-							prtd->audio_client,
-						       &prtd->marker_timestamp);
-			else
-				q6asm_get_session_time(prtd->audio_client,
-						       &prtd->marker_timestamp);
-
-			spin_lock_irqsave(&prtd->lock, flags);
-			/*
-			 * Don't reset these as these vars map to
-			 * total_bytes_transferred and total_bytes_available.
-			 * Just total_bytes_transferred will be updated
-			 * in the next avail() ioctl.
-			 * prtd->copied_total = 0;
-			 * prtd->bytes_received = 0;
-			 * do not reset prtd->bytes_sent as well as the same
-			 * session is used for gapless playback
-			 */
-			prtd->byte_offset = 0;
-
-			prtd->app_pointer  = 0;
-			prtd->first_buffer = 1;
-			prtd->last_buffer = 0;
-			atomic_set(&prtd->drain, 0);
-			atomic_set(&prtd->xrun, 1);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-
-			pr_debug("%s:issue CMD_FLUSH ac->stream_id %d",
-					      __func__, ac->stream_id);
-			q6asm_stream_cmd(ac, CMD_FLUSH, ac->stream_id);
-
-			q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
-		}
-		prtd->cmd_interrupt = 0;
-		break;
-	case SND_COMPR_TRIGGER_NEXT_TRACK:
-		if (!prtd->gapless_state.use_dsp_gapless_mode) {
-			pr_debug("%s: ignore trigger next track\n", __func__);
-			rc = 0;
-			break;
-		}
-		pr_debug("%s: SND_COMPR_TRIGGER_NEXT_TRACK\n", __func__);
-		spin_lock_irqsave(&prtd->lock, flags);
-		rc = 0;
-		/* next stream in gapless */
-		stream_id = NEXT_STREAM_ID(ac->stream_id);
-		/*
-		 * Wait if stream 1 has not completed before honoring next
-		 * track for stream 3. Scenario happens if second clip is
-		 * small and fills in one buffer so next track will be
-		 * called immediately.
-		 */
-		stream_index = STREAM_ARRAY_INDEX(stream_id);
-		if (stream_index >= MAX_NUMBER_OF_STREAMS ||
-		    stream_index < 0) {
-			pr_err("%s: Invalid stream index: %d", __func__,
-				stream_index);
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (prtd->gapless_state.stream_opened[stream_index]) {
-			if (prtd->gapless_state.gapless_transition) {
-				rc = msm_compr_wait_for_stream_avail(prtd,
-								    &flags);
-			} else {
-				/*
-				 * If session is already opened break out if
-				 * the state is not gapless transition. This
-				 * is when seek happens after the last buffer
-				 * is sent to the driver. Next track would be
-				 * called again after last buffer is sent.
-				 */
-				pr_debug("next session is in opened state\n");
-				spin_unlock_irqrestore(&prtd->lock, flags);
-				break;
-			}
-		}
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		if (rc < 0) {
-			/*
-			 * if return type EINTR  then reset to zero. Tiny
-			 * compress treats EINTR as error and prevents PARTIAL
-			 * DRAIN. EINTR is not an error. wait for stream avail
-			 * is interrupted by some other command like FLUSH.
-			 */
-			if (rc == -EINTR) {
-				pr_debug("%s: EINTR reset rc to 0\n", __func__);
-				rc = 0;
-			}
-			break;
-		}
-
-		if (prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S24_LE)
-			bits_per_sample = 24;
-		else if (prtd->codec_param.codec.format ==
-			 SNDRV_PCM_FORMAT_S32_LE)
-			bits_per_sample = 32;
-
-		pr_debug("%s: open_write stream_id %d bits_per_sample %d",
-				__func__, stream_id, bits_per_sample);
-		rc = q6asm_stream_open_write_v4(prtd->audio_client,
-				prtd->codec, bits_per_sample,
-				stream_id,
-				prtd->gapless_state.use_dsp_gapless_mode);
-		if (rc < 0) {
-			pr_err("%s: Session out open failed for gapless\n",
-				 __func__);
-			break;
-		}
-
-		spin_lock_irqsave(&prtd->lock, flags);
-		prtd->gapless_state.stream_opened[stream_index] = 1;
-		prtd->gapless_state.set_next_stream_id = true;
-		spin_unlock_irqrestore(&prtd->lock, flags);
-
-		rc = msm_compr_send_media_format_block(cstream,
-						stream_id, false);
-		if (rc < 0) {
-			pr_err("%s, failed to send media format block\n",
-				__func__);
-			break;
-		}
-		msm_compr_send_dec_params(cstream, pdata->dec_params[fe_id],
-					  stream_id);
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_compr_pointer(struct snd_compr_stream *cstream,
-					struct snd_compr_tstamp *arg)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	struct msm_compr_pdata *pdata = NULL;
-	struct snd_compr_tstamp tstamp;
-	uint64_t timestamp = 0;
-	int rc = 0, first_buffer;
-	unsigned long flags;
-	uint32_t gapless_transition;
-
-	pdata = snd_soc_platform_get_drvdata(rtd->platform);
-	pr_debug("%s\n", __func__);
-	memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	tstamp.sampling_rate = prtd->sample_rate;
-	tstamp.byte_offset = prtd->byte_offset;
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		tstamp.copied_total = prtd->copied_total;
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		tstamp.copied_total = prtd->received_total;
-	first_buffer = prtd->first_buffer;
-	if (atomic_read(&prtd->error)) {
-		pr_err("%s Got RESET EVENTS notification, return error\n",
-			__func__);
-		if (cstream->direction == SND_COMPRESS_PLAYBACK)
-			runtime->total_bytes_transferred = tstamp.copied_total;
-		else
-			runtime->total_bytes_available = tstamp.copied_total;
-		tstamp.pcm_io_frames = 0;
-		memcpy(arg, &tstamp, sizeof(struct snd_compr_tstamp));
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		return -ENETRESET;
-	}
-	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-
-		gapless_transition = prtd->gapless_state.gapless_transition;
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		if (gapless_transition)
-			pr_debug("%s session time in gapless transition",
-				__func__);
-		/*
-		 *- Do not query if no buffer has been given.
-		 *- Do not query on a gapless transition.
-		 *  Playback for the 2nd stream can start (thus returning time
-		 *  starting from 0) before the driver knows about EOS of first
-		 *  stream.
-		 */
-		if (!first_buffer || gapless_transition) {
-
-			if (pdata->use_legacy_api)
-				rc = q6asm_get_session_time_legacy(
-				prtd->audio_client, &prtd->marker_timestamp);
-			else
-				rc = q6asm_get_session_time(
-				prtd->audio_client, &prtd->marker_timestamp);
-			if (rc < 0) {
-				pr_err("%s: Get Session Time return =%lld\n",
-					__func__, timestamp);
-				if (atomic_read(&prtd->error))
-					return -ENETRESET;
-				else
-					return -EAGAIN;
-			}
-		}
-	} else {
-		spin_unlock_irqrestore(&prtd->lock, flags);
-	}
-	timestamp = prtd->marker_timestamp;
-
-	/* DSP returns timestamp in usec */
-	pr_debug("%s: timestamp = %lld usec\n", __func__, timestamp);
-	timestamp *= prtd->sample_rate;
-	tstamp.pcm_io_frames = (snd_pcm_uframes_t)div64_u64(timestamp, 1000000);
-	memcpy(arg, &tstamp, sizeof(struct snd_compr_tstamp));
-
-	return 0;
-}
-
-static int msm_compr_ack(struct snd_compr_stream *cstream,
-			size_t count)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	void *src, *dstn;
-	size_t copy;
-	unsigned long flags;
-
-	WARN(1, "This path is untested");
-	return -EINVAL;
-
-	pr_debug("%s: count = %zd\n", __func__, count);
-	if (!prtd->buffer) {
-		pr_err("%s: Buffer is not allocated yet ??\n", __func__);
-		return -EINVAL;
-	}
-	src = runtime->buffer + prtd->app_pointer;
-	dstn = prtd->buffer + prtd->app_pointer;
-	if (count < prtd->buffer_size - prtd->app_pointer) {
-		memcpy(dstn, src, count);
-		prtd->app_pointer += count;
-	} else {
-		copy = prtd->buffer_size - prtd->app_pointer;
-		memcpy(dstn, src, copy);
-		memcpy(prtd->buffer, runtime->buffer, count - copy);
-		prtd->app_pointer = count - copy;
-	}
-
-	/*
-	 * If the stream is started and all the bytes received were
-	 * copied to DSP, the newly received bytes should be
-	 * sent right away
-	 */
-	spin_lock_irqsave(&prtd->lock, flags);
-
-	if (atomic_read(&prtd->start) &&
-		prtd->bytes_received == prtd->copied_total) {
-		prtd->bytes_received += count;
-		msm_compr_send_buffer(prtd);
-	} else
-		prtd->bytes_received += count;
-
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	return 0;
-}
-
-static int msm_compr_playback_copy(struct snd_compr_stream *cstream,
-				  char __user *buf, size_t count)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	void *dstn;
-	size_t copy;
-	uint64_t bytes_available = 0;
-	unsigned long flags;
-
-	pr_debug("%s: count = %zd\n", __func__, count);
-	if (!prtd->buffer) {
-		pr_err("%s: Buffer is not allocated yet ??", __func__);
-		return 0;
-	}
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	if (atomic_read(&prtd->error)) {
-		pr_err("%s Got RESET EVENTS notification", __func__);
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		return -ENETRESET;
-	}
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	dstn = prtd->buffer + prtd->app_pointer;
-	if (count < prtd->buffer_size - prtd->app_pointer) {
-		if (copy_from_user(dstn, buf, count))
-			return -EFAULT;
-		prtd->app_pointer += count;
-	} else {
-		copy = prtd->buffer_size - prtd->app_pointer;
-		if (copy_from_user(dstn, buf, copy))
-			return -EFAULT;
-		if (copy_from_user(prtd->buffer, buf + copy, count - copy))
-			return -EFAULT;
-		prtd->app_pointer = count - copy;
-	}
-
-	/*
-	 * If stream is started and there has been an xrun,
-	 * since the available bytes fits fragment_size, copy the data
-	 * right away.
-	 */
-	spin_lock_irqsave(&prtd->lock, flags);
-	prtd->bytes_received += count;
-	if (atomic_read(&prtd->start)) {
-		if (atomic_read(&prtd->xrun)) {
-			pr_debug("%s: in xrun, count = %zd\n", __func__, count);
-			bytes_available = prtd->bytes_received -
-					  prtd->copied_total;
-			if (bytes_available >= runtime->fragment_size) {
-				pr_debug("%s: handle xrun, bytes_to_write = %llu\n",
-					 __func__, bytes_available);
-				atomic_set(&prtd->xrun, 0);
-				msm_compr_send_buffer(prtd);
-			} /* else not sufficient data */
-		} /* writes will continue on the next write_done */
-	}
-
-	spin_unlock_irqrestore(&prtd->lock, flags);
-
-	return count;
-}
-
-static int msm_compr_capture_copy(struct snd_compr_stream *cstream,
-					char __user *buf, size_t count)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	void *source;
-	unsigned long flags;
-
-	pr_debug("%s: count = %zd\n", __func__, count);
-	if (!prtd->buffer) {
-		pr_err("%s: Buffer is not allocated yet ??", __func__);
-		return 0;
-	}
-
-	spin_lock_irqsave(&prtd->lock, flags);
-	if (atomic_read(&prtd->error)) {
-		pr_err("%s Got RESET EVENTS notification", __func__);
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		return -ENETRESET;
-	}
-
-	source = prtd->buffer + prtd->app_pointer;
-	/* check if we have requested amount of data to copy to user*/
-	if (count <= prtd->received_total - prtd->bytes_copied)	{
-		spin_unlock_irqrestore(&prtd->lock, flags);
-		if (copy_to_user(buf, source, count)) {
-			pr_err("copy_to_user failed");
-			return -EFAULT;
-		}
-		spin_lock_irqsave(&prtd->lock, flags);
-		prtd->app_pointer += count;
-		if (prtd->app_pointer >= prtd->buffer_size)
-			prtd->app_pointer -= prtd->buffer_size;
-		prtd->bytes_copied += count;
-	}
-	msm_compr_read_buffer(prtd);
-
-	spin_unlock_irqrestore(&prtd->lock, flags);
-	return count;
-}
-
-static int msm_compr_copy(struct snd_compr_stream *cstream,
-				char __user *buf, size_t count)
-{
-	int ret = 0;
-
-	pr_debug(" In %s\n", __func__);
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		ret = msm_compr_playback_copy(cstream, buf, count);
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		ret = msm_compr_capture_copy(cstream, buf, count);
-	return ret;
-}
-
-static int msm_compr_get_caps(struct snd_compr_stream *cstream,
-				struct snd_compr_caps *arg)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_compr_audio *prtd = runtime->private_data;
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	if ((arg != NULL) && (prtd != NULL)) {
-		memcpy(arg, &prtd->compr_cap, sizeof(struct snd_compr_caps));
-	} else {
-		ret = -EINVAL;
-		pr_err("%s: arg (0x%pK), prtd (0x%pK)\n", __func__, arg, prtd);
-	}
-
-	return ret;
-}
-
-static int msm_compr_get_codec_caps(struct snd_compr_stream *cstream,
-				struct snd_compr_codec_caps *codec)
-{
-	pr_debug("%s\n", __func__);
-
-	switch (codec->codec) {
-	case SND_AUDIOCODEC_MP3:
-		codec->num_descriptors = 2;
-		codec->descriptor[0].max_ch = 2;
-		memcpy(codec->descriptor[0].sample_rates,
-		       supported_sample_rates,
-		       sizeof(supported_sample_rates));
-		codec->descriptor[0].num_sample_rates =
-			sizeof(supported_sample_rates)/sizeof(unsigned int);
-		codec->descriptor[0].bit_rate[0] = 320; /* 320kbps */
-		codec->descriptor[0].bit_rate[1] = 128;
-		codec->descriptor[0].num_bitrates = 2;
-		codec->descriptor[0].profiles = 0;
-		codec->descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO;
-		codec->descriptor[0].formats = 0;
-		break;
-	case SND_AUDIOCODEC_AAC:
-		codec->num_descriptors = 2;
-		codec->descriptor[1].max_ch = 2;
-		memcpy(codec->descriptor[1].sample_rates,
-		       supported_sample_rates,
-		       sizeof(supported_sample_rates));
-		codec->descriptor[1].num_sample_rates =
-			sizeof(supported_sample_rates)/sizeof(unsigned int);
-		codec->descriptor[1].bit_rate[0] = 320; /* 320kbps */
-		codec->descriptor[1].bit_rate[1] = 128;
-		codec->descriptor[1].num_bitrates = 2;
-		codec->descriptor[1].profiles = 0;
-		codec->descriptor[1].modes = 0;
-		codec->descriptor[1].formats =
-			(SND_AUDIOSTREAMFORMAT_MP4ADTS |
-				SND_AUDIOSTREAMFORMAT_RAW);
-		break;
-	case SND_AUDIOCODEC_AC3:
-	case SND_AUDIOCODEC_EAC3:
-	case SND_AUDIOCODEC_FLAC:
-	case SND_AUDIOCODEC_VORBIS:
-	case SND_AUDIOCODEC_ALAC:
-	case SND_AUDIOCODEC_APE:
-	case SND_AUDIOCODEC_DTS:
-	case SND_AUDIOCODEC_DSD:
-	case SND_AUDIOCODEC_TRUEHD:
-	case SND_AUDIOCODEC_IEC61937:
-	case SND_AUDIOCODEC_APTX:
-		break;
-	default:
-		pr_err("%s: Unsupported audio codec %d\n",
-			__func__, codec->codec);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_compr_set_metadata(struct snd_compr_stream *cstream,
-				struct snd_compr_metadata *metadata)
-{
-	struct msm_compr_audio *prtd;
-	struct audio_client *ac;
-	pr_debug("%s\n", __func__);
-
-	if (!metadata || !cstream)
-		return -EINVAL;
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd || !prtd->audio_client) {
-		pr_err("%s: prtd or audio client is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (((metadata->key == SNDRV_COMPRESS_ENCODER_PADDING) ||
-	     (metadata->key == SNDRV_COMPRESS_ENCODER_DELAY)) &&
-	     (prtd->compr_passthr != LEGACY_PCM)) {
-		pr_debug("%s: No trailing silence for compress_type[%d]\n",
-			__func__, prtd->compr_passthr);
-		return 0;
-	}
-
-	ac = prtd->audio_client;
-	if (metadata->key == SNDRV_COMPRESS_ENCODER_PADDING) {
-		pr_debug("%s, got encoder padding %u",
-			 __func__, metadata->value[0]);
-		prtd->gapless_state.trailing_samples_drop = metadata->value[0];
-	} else if (metadata->key == SNDRV_COMPRESS_ENCODER_DELAY) {
-		pr_debug("%s, got encoder delay %u",
-			 __func__, metadata->value[0]);
-		prtd->gapless_state.initial_samples_drop = metadata->value[0];
-	} else if (metadata->key == SNDRV_COMPRESS_RENDER_MODE) {
-		return msm_compr_set_render_mode(prtd, metadata->value[0]);
-	} else if (metadata->key == SNDRV_COMPRESS_CLK_REC_MODE) {
-		return msm_compr_set_clk_rec_mode(ac, metadata->value[0]);
-	} else if (metadata->key == SNDRV_COMPRESS_RENDER_WINDOW) {
-		return msm_compr_set_render_window(
-				ac,
-				metadata->value[0],
-				metadata->value[1],
-				metadata->value[2],
-				metadata->value[3]);
-	} else if (metadata->key == SNDRV_COMPRESS_START_DELAY) {
-		prtd->start_delay_lsw = metadata->value[0];
-		prtd->start_delay_msw = metadata->value[1];
-	} else if (metadata->key ==
-				SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK) {
-		return msm_compr_enable_adjust_session_clock(ac,
-				metadata->value[0]);
-	} else if (metadata->key == SNDRV_COMPRESS_ADJUST_SESSION_CLOCK) {
-		return msm_compr_adjust_session_clock(ac,
-				metadata->value[0],
-				metadata->value[1]);
-	}
-
-	return 0;
-}
-
-static int msm_compr_get_metadata(struct snd_compr_stream *cstream,
-				struct snd_compr_metadata *metadata)
-{
-	struct msm_compr_audio *prtd;
-	struct audio_client *ac;
-	int ret = -EINVAL;
-
-	pr_debug("%s\n", __func__);
-
-	if (!metadata || !cstream || !cstream->runtime)
-		return ret;
-
-	if (metadata->key != SNDRV_COMPRESS_PATH_DELAY) {
-		pr_err("%s, unsupported key %d\n", __func__, metadata->key);
-		return ret;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd || !prtd->audio_client) {
-		pr_err("%s: prtd or audio client is NULL\n", __func__);
-		return ret;
-	}
-
-	ac = prtd->audio_client;
-	ret = q6asm_get_path_delay(prtd->audio_client);
-	if (ret) {
-		pr_err("%s: get_path_delay failed, ret=%d\n", __func__, ret);
-		return ret;
-	}
-
-	pr_debug("%s, path delay(in us) %u\n", __func__, ac->path_delay);
-
-	metadata->value[0] = ac->path_delay;
-
-	return ret;
-}
-
-
-static int msm_compr_set_next_track_param(struct snd_compr_stream *cstream,
-				union snd_codec_options *codec_options)
-{
-	struct msm_compr_audio *prtd;
-	struct audio_client *ac;
-	int ret = 0;
-
-	if (!codec_options || !cstream)
-		return -EINVAL;
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd || !prtd->audio_client) {
-		pr_err("%s: prtd or audio client is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	ac = prtd->audio_client;
-
-	pr_debug("%s: got codec options for codec type %u",
-		__func__, prtd->codec);
-	switch (prtd->codec) {
-	case FORMAT_WMA_V9:
-	case FORMAT_WMA_V10PRO:
-	case FORMAT_FLAC:
-	case FORMAT_VORBIS:
-	case FORMAT_ALAC:
-	case FORMAT_APE:
-		memcpy(&(prtd->gapless_state.codec_options),
-			codec_options,
-			sizeof(union snd_codec_options));
-		ret = msm_compr_send_media_format_block(cstream,
-						ac->stream_id, true);
-		if (ret < 0) {
-			pr_err("%s: failed to send media format block\n",
-				__func__);
-		}
-		break;
-
-	default:
-		pr_debug("%s: Ignore sending CMD Format block\n",
-			__func__);
-		break;
-	}
-
-	return ret;
-}
-
-static int msm_compr_volume_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	uint32_t *volume = NULL;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		return -EINVAL;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	volume = pdata->volume[fe_id];
-
-	volume[0] = ucontrol->value.integer.value[0];
-	volume[1] = ucontrol->value.integer.value[1];
-	pr_debug("%s: fe_id %lu left_vol %d right_vol %d\n",
-		 __func__, fe_id, volume[0], volume[1]);
-	if (cstream)
-		msm_compr_set_volume(cstream, volume[0], volume[1]);
-	return 0;
-}
-
-static int msm_compr_volume_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-
-	struct msm_compr_pdata *pdata =
-		snd_soc_component_get_drvdata(comp);
-	uint32_t *volume = NULL;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bound fe_id %lu\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	volume = pdata->volume[fe_id];
-	pr_debug("%s: fe_id %lu\n", __func__, fe_id);
-	ucontrol->value.integer.value[0] = volume[0];
-	ucontrol->value.integer.value[1] = volume[1];
-
-	return 0;
-}
-
-static int msm_compr_audio_effects_config_put(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct msm_compr_audio_effects *audio_effects = NULL;
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd = NULL;
-	long *values = &(ucontrol->value.integer.value[0]);
-	int effects_module;
-
-	pr_debug("%s\n", __func__);
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		return -EINVAL;
-	}
-	cstream = pdata->cstream[fe_id];
-	audio_effects = pdata->audio_effects[fe_id];
-	if (!cstream || !audio_effects) {
-		pr_err("%s: stream or effects inactive\n", __func__);
-		return -EINVAL;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		pr_debug("%s: No effects for compr_type[%d]\n",
-			__func__, prtd->compr_passthr);
-		return 0;
-	}
-	pr_debug("%s: Effects supported for compr_type[%d]\n",
-		 __func__, prtd->compr_passthr);
-
-	effects_module = *values++;
-	switch (effects_module) {
-	case VIRTUALIZER_MODULE:
-		pr_debug("%s: VIRTUALIZER_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_virtualizer_handler(
-						prtd->audio_client,
-						&(audio_effects->virtualizer),
-						values);
-		break;
-	case REVERB_MODULE:
-		pr_debug("%s: REVERB_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_reverb_handler(prtd->audio_client,
-						 &(audio_effects->reverb),
-						 values);
-		break;
-	case BASS_BOOST_MODULE:
-		pr_debug("%s: BASS_BOOST_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_bass_boost_handler(prtd->audio_client,
-						   &(audio_effects->bass_boost),
-						     values);
-		break;
-	case PBE_MODULE:
-		pr_debug("%s: PBE_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_pbe_handler(prtd->audio_client,
-						   &(audio_effects->pbe),
-						     values);
-		break;
-	case EQ_MODULE:
-		pr_debug("%s: EQ_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_popless_eq_handler(prtd->audio_client,
-						    &(audio_effects->equalizer),
-						     values);
-		break;
-	case SOFT_VOLUME_MODULE:
-		pr_debug("%s: SOFT_VOLUME_MODULE\n", __func__);
-		break;
-	case SOFT_VOLUME2_MODULE:
-		pr_debug("%s: SOFT_VOLUME2_MODULE\n", __func__);
-		if (msm_audio_effects_is_effmodule_supp_in_top(effects_module,
-						prtd->audio_client->topology))
-			msm_audio_effects_volume_handler_v2(prtd->audio_client,
-						&(audio_effects->volume),
-						values, SOFT_VOLUME_INSTANCE_2);
-		break;
-	default:
-		pr_err("%s Invalid effects config module\n", __func__);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int msm_compr_audio_effects_config_get(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct msm_compr_audio_effects *audio_effects = NULL;
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd = NULL;
-
-	pr_debug("%s\n", __func__);
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		return -EINVAL;
-	}
-	cstream = pdata->cstream[fe_id];
-	audio_effects = pdata->audio_effects[fe_id];
-	if (!cstream || !audio_effects) {
-		pr_err("%s: stream or effects inactive\n", __func__);
-		return -EINVAL;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_compr_query_audio_effect_put(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct msm_compr_audio_effects *audio_effects = NULL;
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd = NULL;
-	long *values = &(ucontrol->value.integer.value[0]);
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		return -EINVAL;
-	}
-	cstream = pdata->cstream[fe_id];
-	audio_effects = pdata->audio_effects[fe_id];
-	if (!cstream || !audio_effects) {
-		pr_err("%s: stream or effects inactive\n", __func__);
-		return -EINVAL;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	if (prtd->compr_passthr != LEGACY_PCM) {
-		pr_err("%s: No effects for compr_type[%d]\n",
-			__func__, prtd->compr_passthr);
-		return -EPERM;
-	}
-	audio_effects->query.mod_id = (u32)*values++;
-	audio_effects->query.parm_id = (u32)*values++;
-	audio_effects->query.size = (u32)*values++;
-	audio_effects->query.offset = (u32)*values++;
-	audio_effects->query.device = (u32)*values++;
-	return 0;
-}
-
-static int msm_compr_query_audio_effect_get(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct msm_compr_audio_effects *audio_effects = NULL;
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd = NULL;
-	long *values = &(ucontrol->value.integer.value[0]);
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		return -EINVAL;
-	}
-	cstream = pdata->cstream[fe_id];
-	audio_effects = pdata->audio_effects[fe_id];
-	if (!cstream || !audio_effects) {
-		pr_debug("%s: stream or effects inactive\n", __func__);
-		return -EINVAL;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set audio effects\n", __func__);
-		return -EINVAL;
-	}
-	values[0] = (long)audio_effects->query.mod_id;
-	values[1] = (long)audio_effects->query.parm_id;
-	values[2] = (long)audio_effects->query.size;
-	values[3] = (long)audio_effects->query.offset;
-	values[4] = (long)audio_effects->query.device;
-	return 0;
-}
-
-static int msm_compr_send_dec_params(struct snd_compr_stream *cstream,
-				     struct msm_compr_dec_params *dec_params,
-				     int stream_id)
-{
-
-	int rc = 0;
-	struct msm_compr_audio *prtd = NULL;
-	struct snd_dec_ddp *ddp = &dec_params->ddp_params;
-
-	if (!cstream || !dec_params) {
-		pr_err("%s: stream or dec_params inactive\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set dec_params\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	switch (prtd->codec) {
-	case FORMAT_MP3:
-	case FORMAT_MPEG4_AAC:
-	case FORMAT_TRUEHD:
-	case FORMAT_IEC61937:
-	case FORMAT_APTX:
-		pr_debug("%s: no runtime parameters for codec: %d\n", __func__,
-			 prtd->codec);
-		break;
-	case FORMAT_AC3:
-	case FORMAT_EAC3:
-		if (prtd->compr_passthr != LEGACY_PCM) {
-			pr_debug("%s: No DDP param for compr_type[%d]\n",
-				 __func__, prtd->compr_passthr);
-			break;
-		}
-		rc = msm_compr_send_ddp_cfg(prtd->audio_client, ddp, stream_id);
-		if (rc < 0)
-			pr_err("%s: DDP CMD CFG failed %d\n", __func__, rc);
-		break;
-	default:
-		break;
-	}
-end:
-	return rc;
-
-}
-static int msm_compr_dec_params_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	struct msm_compr_dec_params *dec_params = NULL;
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd = NULL;
-	long *values = &(ucontrol->value.integer.value[0]);
-	int rc = 0;
-
-	pr_debug("%s\n", __func__);
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %lu\n",
-			__func__, fe_id);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	dec_params = pdata->dec_params[fe_id];
-
-	if (!cstream || !dec_params) {
-		pr_err("%s: stream or dec_params inactive\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: cannot set dec_params\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	switch (prtd->codec) {
-	case FORMAT_MP3:
-	case FORMAT_MPEG4_AAC:
-	case FORMAT_FLAC:
-	case FORMAT_VORBIS:
-	case FORMAT_ALAC:
-	case FORMAT_APE:
-	case FORMAT_DTS:
-	case FORMAT_DSD:
-	case FORMAT_TRUEHD:
-	case FORMAT_IEC61937:
-	case FORMAT_APTX:
-		pr_debug("%s: no runtime parameters for codec: %d\n", __func__,
-			 prtd->codec);
-		break;
-	case FORMAT_AC3:
-	case FORMAT_EAC3: {
-		struct snd_dec_ddp *ddp = &dec_params->ddp_params;
-		int cnt;
-
-		if (prtd->compr_passthr != LEGACY_PCM) {
-			pr_debug("%s: No DDP param for compr_type[%d]\n",
-				__func__, prtd->compr_passthr);
-			break;
-		}
-
-		ddp->params_length = (*values++);
-		if (ddp->params_length > DDP_DEC_MAX_NUM_PARAM) {
-			pr_err("%s: invalid num of params:: %d\n", __func__,
-				ddp->params_length);
-			rc = -EINVAL;
-			goto end;
-		}
-		for (cnt = 0; cnt < ddp->params_length; cnt++) {
-			ddp->params_id[cnt] = *values++;
-			ddp->params_value[cnt] = *values++;
-		}
-		prtd = cstream->runtime->private_data;
-		if (prtd && prtd->audio_client)
-			rc = msm_compr_send_dec_params(cstream, dec_params,
-						prtd->audio_client->stream_id);
-		break;
-	}
-	default:
-		break;
-	}
-end:
-	pr_debug("%s: ret %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_compr_dec_params_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	/* dummy function */
-	return 0;
-}
-
-static int msm_compr_playback_app_type_cfg_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_compr_playback_app_type_cfg_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_compr_capture_app_type_cfg_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_compr_capture_app_type_cfg_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_compr_channel_map_put(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	u64 fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	int rc = 0, i;
-
-	pr_debug("%s: fe_id- %llu\n", __func__, fe_id);
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds fe_id %llu\n",
-			__func__, fe_id);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (pdata->ch_map[fe_id]) {
-		pdata->ch_map[fe_id]->set_ch_map = true;
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			pdata->ch_map[fe_id]->channel_map[i] =
-				(char)(ucontrol->value.integer.value[i]);
-	} else {
-		pr_debug("%s: no memory for ch_map, default will be set\n",
-			__func__);
-	}
-end:
-	pr_debug("%s: ret %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_compr_channel_map_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	u64 fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-			snd_soc_component_get_drvdata(comp);
-	int rc = 0, i;
-
-	pr_debug("%s: fe_id- %llu\n", __func__, fe_id);
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s: Received out of bounds fe_id %llu\n",
-			__func__, fe_id);
-		rc = -EINVAL;
-		goto end;
-	}
-	if (pdata->ch_map[fe_id]) {
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			ucontrol->value.integer.value[i] =
-				pdata->ch_map[fe_id]->channel_map[i];
-	}
-end:
-	pr_debug("%s: ret %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_compr_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-				snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd;
-	int ret = 0;
-	struct msm_adsp_event_data *event_data = NULL;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data;
-	if ((event_data->event_type < ADSP_STREAM_PP_EVENT) ||
-	    (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) {
-		pr_err("%s: invalid event_type=%d",
-			__func__, event_data->event_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
-					sizeof(ucontrol->value.bytes.data)) {
-		pr_err("%s param length=%d  exceeds limit",
-			__func__, event_data->payload_len);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = q6asm_send_stream_cmd(prtd->audio_client, event_data);
-	if (ret < 0)
-		pr_err("%s: failed to send stream event cmd, err = %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-static int msm_compr_ion_fd_map_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-				snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd;
-	int fd;
-	int ret = 0;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(&fd, ucontrol->value.bytes.data, sizeof(fd));
-	ret = q6asm_send_ion_fd(prtd->audio_client, fd);
-	if (ret < 0)
-		pr_err("%s: failed to register ion fd\n", __func__);
-done:
-	return ret;
-}
-
-static int msm_compr_rtic_event_ack_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-					snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_compr_audio *prtd;
-	int ret = 0;
-	int param_length = 0;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(&param_length, ucontrol->value.bytes.data,
-		sizeof(param_length));
-	if ((param_length + sizeof(param_length))
-		>= sizeof(ucontrol->value.bytes.data)) {
-		pr_err("%s param length=%d  exceeds limit",
-			__func__, param_length);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = q6asm_send_rtic_event_ack(prtd->audio_client,
-			ucontrol->value.bytes.data + sizeof(param_length),
-			param_length);
-	if (ret < 0)
-		pr_err("%s: failed to send rtic event ack, err = %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-static int msm_compr_gapless_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	struct msm_compr_pdata *pdata = (struct msm_compr_pdata *)
-		snd_soc_component_get_drvdata(comp);
-	pdata->use_dsp_gapless_mode =  ucontrol->value.integer.value[0];
-	pr_debug("%s: value: %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_compr_gapless_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	struct msm_compr_pdata *pdata =
-		snd_soc_component_get_drvdata(comp);
-	pr_debug("%s:gapless mode %d\n", __func__, pdata->use_dsp_gapless_mode);
-	ucontrol->value.integer.value[0] = pdata->use_dsp_gapless_mode;
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new msm_compr_gapless_controls[] = {
-	SOC_SINGLE_EXT("Compress Gapless Playback",
-			0, 0, 1, 0,
-			msm_compr_gapless_get,
-			msm_compr_gapless_put),
-};
-
-static int msm_compr_probe(struct snd_soc_platform *platform)
-{
-	struct msm_compr_pdata *pdata;
-	int i;
-	int rc;
-	const char *qdsp_version;
-
-	pr_debug("%s\n", __func__);
-	pdata = (struct msm_compr_pdata *)
-			kzalloc(sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	snd_soc_platform_set_drvdata(platform, pdata);
-
-	for (i = 0; i < MSM_FRONTEND_DAI_MAX; i++) {
-		pdata->volume[i][0] = COMPRESSED_LR_VOL_MAX_STEPS;
-		pdata->volume[i][1] = COMPRESSED_LR_VOL_MAX_STEPS;
-		pdata->audio_effects[i] = NULL;
-		pdata->dec_params[i] = NULL;
-		pdata->cstream[i] = NULL;
-		pdata->ch_map[i] = NULL;
-	}
-
-	snd_soc_add_platform_controls(platform, msm_compr_gapless_controls,
-				      ARRAY_SIZE(msm_compr_gapless_controls));
-
-	rc =  of_property_read_string(platform->dev->of_node,
-		"qcom,adsp-version", &qdsp_version);
-	if (!rc) {
-		if (!strcmp(qdsp_version, "MDSP 1.2"))
-			pdata->use_legacy_api = true;
-		else
-			pdata->use_legacy_api = false;
-	} else
-		pdata->use_legacy_api = false;
-
-	pr_debug("%s: use legacy api %d\n", __func__, pdata->use_legacy_api);
-	/*
-	 * use_dsp_gapless_mode part of platform data(pdata) is updated from HAL
-	 * through a mixer control before compress driver is opened. The mixer
-	 * control is used to decide if dsp gapless mode needs to be enabled.
-	 * Gapless is disabled by default.
-	 */
-	pdata->use_dsp_gapless_mode = false;
-	return 0;
-}
-
-static int msm_compr_volume_info(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 2;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = COMPRESSED_LR_VOL_MAX_STEPS;
-	return 0;
-}
-
-static int msm_compr_audio_effects_config_info(struct snd_kcontrol *kcontrol,
-					       struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = MAX_PP_PARAMS_SZ;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0xFFFFFFFF;
-	return 0;
-}
-
-static int msm_compr_query_audio_effect_info(struct snd_kcontrol *kcontrol,
-					     struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 128;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0xFFFFFFFF;
-	return 0;
-}
-
-static int msm_compr_dec_params_info(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 128;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0xFFFFFFFF;
-	return 0;
-}
-
-static int msm_compr_app_type_cfg_info(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 5;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0xFFFFFFFF;
-	return 0;
-}
-
-static int msm_compr_channel_map_info(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 8;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0xFFFFFFFF;
-	return 0;
-}
-
-static int msm_compr_add_volume_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Compress Playback";
-	const char *deviceNo       = "NN";
-	const char *suffix         = "Volume";
-	char *mixer_str = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_volume_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			  SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_volume_info,
-		.tlv.p = msm_compr_vol_gain,
-		.get = msm_compr_volume_get,
-		.put = msm_compr_volume_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		return 0;
-	}
-	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1 +
-		  strlen(suffix) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		pr_err("failed to allocate mixer ctrl str of len %d", ctl_len);
-		return 0;
-	}
-	snprintf(mixer_str, ctl_len, "%s %d %s", mixer_ctl_name,
-		 rtd->pcm->device, suffix);
-	fe_volume_control[0].name = mixer_str;
-	fe_volume_control[0].private_value = rtd->dai_link->id;
-	pr_debug("Registering new mixer ctl %s", mixer_str);
-	snd_soc_add_platform_controls(rtd->platform, fe_volume_control,
-				      ARRAY_SIZE(fe_volume_control));
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_audio_effects_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Audio Effects Config";
-	const char *deviceNo       = "NN";
-	char *mixer_str = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_audio_effects_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_audio_effects_config_info,
-		.get = msm_compr_audio_effects_config_get,
-		.put = msm_compr_audio_effects_config_put,
-		.private_value = 0,
-		}
-	};
-
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return 0;
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-
-	fe_audio_effects_config_control[0].name = mixer_str;
-	fe_audio_effects_config_control[0].private_value = rtd->dai_link->id;
-	pr_debug("Registering new mixer ctl %s\n", mixer_str);
-	snd_soc_add_platform_controls(rtd->platform,
-				fe_audio_effects_config_control,
-				ARRAY_SIZE(fe_audio_effects_config_control));
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_query_audio_effect_control(
-					struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Query Audio Effect Param";
-	const char *deviceNo       = "NN";
-	char *mixer_str = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_query_audio_effect_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_query_audio_effect_info,
-		.get = msm_compr_query_audio_effect_get,
-		.put = msm_compr_query_audio_effect_put,
-		.private_value = 0,
-		}
-	};
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		return 0;
-	}
-	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		pr_err("failed to allocate mixer ctrl str of len %d", ctl_len);
-		return 0;
-	}
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_query_audio_effect_control[0].name = mixer_str;
-	fe_query_audio_effect_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: registering new mixer ctl %s\n", __func__, mixer_str);
-	snd_soc_add_platform_controls(rtd->platform,
-				fe_query_audio_effect_control,
-				ARRAY_SIZE(fe_query_audio_effect_control));
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_audio_adsp_stream_cmd_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CMD;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_audio_adsp_stream_cmd_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_compr_adsp_stream_cmd_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_audio_adsp_stream_cmd_config_control[0].name = mixer_str;
-	fe_audio_adsp_stream_cmd_config_control[0].private_value =
-				rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-		fe_audio_adsp_stream_cmd_config_control,
-		ARRAY_SIZE(fe_audio_adsp_stream_cmd_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_compr_add_audio_adsp_stream_callback_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol *kctl;
-
-	struct snd_kcontrol_new fe_audio_adsp_callback_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_callback_info,
-		.get = msm_adsp_stream_callback_get,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s: rtd is  NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_audio_adsp_callback_config_control[0].name = mixer_str;
-	fe_audio_adsp_callback_config_control[0].private_value =
-					rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-			fe_audio_adsp_callback_config_control,
-			ARRAY_SIZE(fe_audio_adsp_callback_config_control));
-	if (ret < 0) {
-		pr_err("%s: failed to add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl %s.\n", __func__, mixer_str);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl->private_data = NULL;
-
-free_mixer_str:
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_compr_add_dec_runtime_params_control(
-						struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name	= "Audio Stream";
-	const char *deviceNo		= "NN";
-	const char *suffix		= "Dec Params";
-	char *mixer_str = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_dec_params_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_dec_params_info,
-		.get = msm_compr_dec_params_get,
-		.put = msm_compr_dec_params_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1 +
-		  strlen(suffix) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return 0;
-
-	snprintf(mixer_str, ctl_len, "%s %d %s", mixer_ctl_name,
-		 rtd->pcm->device, suffix);
-
-	fe_dec_params_control[0].name = mixer_str;
-	fe_dec_params_control[0].private_value = rtd->dai_link->id;
-	pr_debug("Registering new mixer ctl %s", mixer_str);
-	snd_soc_add_platform_controls(rtd->platform,
-				      fe_dec_params_control,
-				      ARRAY_SIZE(fe_dec_params_control));
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_app_type_cfg_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *playback_mixer_ctl_name	= "Audio Stream";
-	const char *capture_mixer_ctl_name	= "Audio Stream Capture";
-	const char *deviceNo		= "NN";
-	const char *suffix		= "App Type Cfg";
-	char *mixer_str = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_app_type_cfg_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_app_type_cfg_info,
-		.put = msm_compr_playback_app_type_cfg_put,
-		.get = msm_compr_playback_app_type_cfg_get,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: added new compr FE ctl with name %s, id %d, cpu dai %s, device no %d\n",
-		__func__, rtd->dai_link->name, rtd->dai_link->id,
-			rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-	if (rtd->compr->direction == SND_COMPRESS_PLAYBACK)
-		ctl_len = strlen(playback_mixer_ctl_name) + 1 + strlen(deviceNo)
-			 + 1 + strlen(suffix) + 1;
-	else
-		ctl_len = strlen(capture_mixer_ctl_name) + 1 + strlen(deviceNo)
-			+ 1 + strlen(suffix) + 1;
-
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return 0;
-
-	if (rtd->compr->direction == SND_COMPRESS_PLAYBACK)
-		snprintf(mixer_str, ctl_len, "%s %d %s",
-			 playback_mixer_ctl_name, rtd->pcm->device, suffix);
-	else
-		snprintf(mixer_str, ctl_len, "%s %d %s",
-			 capture_mixer_ctl_name, rtd->pcm->device, suffix);
-
-	fe_app_type_cfg_control[0].name = mixer_str;
-	fe_app_type_cfg_control[0].private_value = rtd->dai_link->id;
-
-	if (rtd->compr->direction == SND_COMPRESS_PLAYBACK) {
-		fe_app_type_cfg_control[0].put =
-					 msm_compr_playback_app_type_cfg_put;
-		fe_app_type_cfg_control[0].get =
-					 msm_compr_playback_app_type_cfg_get;
-	} else {
-		fe_app_type_cfg_control[0].put =
-					 msm_compr_capture_app_type_cfg_put;
-		fe_app_type_cfg_control[0].get =
-					 msm_compr_capture_app_type_cfg_get;
-	}
-	pr_debug("Registering new mixer ctl %s", mixer_str);
-	snd_soc_add_platform_controls(rtd->platform,
-				fe_app_type_cfg_control,
-				ARRAY_SIZE(fe_app_type_cfg_control));
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_channel_map_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback Channel Map";
-	const char *deviceNo       = "NN";
-	char *mixer_str = NULL;
-	struct msm_compr_pdata *pdata = NULL;
-	int ctl_len;
-	struct snd_kcontrol_new fe_channel_map_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_compr_channel_map_info,
-		.get = msm_compr_channel_map_get,
-		.put = msm_compr_channel_map_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s: NULL rtd\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: added new compr FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-
-	ctl_len = strlen(mixer_ctl_name) + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return -ENOMEM;
-
-	snprintf(mixer_str, ctl_len, "%s%d", mixer_ctl_name, rtd->pcm->device);
-
-	fe_channel_map_control[0].name = mixer_str;
-	fe_channel_map_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	snd_soc_add_platform_controls(rtd->platform,
-				fe_channel_map_control,
-				ARRAY_SIZE(fe_channel_map_control));
-
-	pdata = snd_soc_platform_get_drvdata(rtd->platform);
-	pdata->ch_map[rtd->dai_link->id] =
-		 kzalloc(sizeof(struct msm_compr_ch_map), GFP_KERNEL);
-	if (!pdata->ch_map[rtd->dai_link->id]) {
-		pr_err("%s: Could not allocate memory for channel map\n",
-			__func__);
-		kfree(mixer_str);
-		return -ENOMEM;
-	}
-	kfree(mixer_str);
-	return 0;
-}
-
-static int msm_compr_add_io_fd_cmd_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback ION FD";
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_ion_fd_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_compr_ion_fd_map_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_ion_fd_config_control[0].name = mixer_str;
-	fe_ion_fd_config_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-				fe_ion_fd_config_control,
-				ARRAY_SIZE(fe_ion_fd_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s\n", __func__, mixer_str);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_compr_add_event_ack_cmd_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback Event Ack";
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_event_ack_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_compr_rtic_event_ack_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_event_ack_config_control[0].name = mixer_str;
-	fe_event_ack_config_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-				fe_event_ack_config_control,
-				ARRAY_SIZE(fe_event_ack_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s\n", __func__, mixer_str);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_compr_new(struct snd_soc_pcm_runtime *rtd)
-{
-	int rc;
-
-	rc = msm_compr_add_volume_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr Volume Control\n", __func__);
-
-	rc = msm_compr_add_audio_effects_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr Audio Effects Control\n",
-			__func__);
-
-	rc = msm_compr_add_audio_adsp_stream_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr ADSP Stream Cmd Control\n",
-			__func__);
-
-	rc = msm_compr_add_audio_adsp_stream_callback_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr ADSP Stream Callback Control\n",
-			__func__);
-
-	rc = msm_compr_add_io_fd_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr ion fd Control\n",
-			__func__);
-
-	rc = msm_compr_add_event_ack_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr event ack Control\n",
-			__func__);
-
-	rc = msm_compr_add_query_audio_effect_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr Query Audio Effect Control\n",
-			__func__);
-
-	rc = msm_compr_add_dec_runtime_params_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr Dec runtime params Control\n",
-			__func__);
-	rc = msm_compr_add_app_type_cfg_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr App Type Cfg Control\n",
-			__func__);
-	rc = msm_compr_add_channel_map_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add Compr Channel Map Control\n",
-			__func__);
-	return 0;
-}
-
-static struct snd_compr_ops msm_compr_ops = {
-	.open			= msm_compr_open,
-	.free			= msm_compr_free,
-	.trigger		= msm_compr_trigger,
-	.pointer		= msm_compr_pointer,
-	.set_params		= msm_compr_set_params,
-	.set_metadata		= msm_compr_set_metadata,
-	.get_metadata		= msm_compr_get_metadata,
-	.set_next_track_param	= msm_compr_set_next_track_param,
-	.ack			= msm_compr_ack,
-	.copy			= msm_compr_copy,
-	.get_caps		= msm_compr_get_caps,
-	.get_codec_caps		= msm_compr_get_codec_caps,
-};
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.probe		= msm_compr_probe,
-	.compr_ops	= &msm_compr_ops,
-	.pcm_new	= msm_compr_new,
-};
-
-static int msm_compr_dev_probe(struct platform_device *pdev)
-{
-
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev,
-					&msm_soc_platform);
-}
-
-static int msm_compr_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_compr_dt_match[] = {
-	{.compatible = "qcom,msm-compress-dsp"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_compr_dt_match);
-
-static struct platform_driver msm_compr_driver = {
-	.driver = {
-		.name = "msm-compress-dsp",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_compr_dt_match,
-	},
-	.probe = msm_compr_dev_probe,
-	.remove = msm_compr_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_compr_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_compr_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("Compress Offload platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-hdmi-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-hdmi-v2.c
deleted file mode 100644
index deb1798..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dai-q6-hdmi-v2.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-#include <linux/bitops.h>
-#include <linux/slab.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/msm-dai-q6-v2.h>
-#include <sound/pcm_params.h>
-
-#define HDMI_RX_CA_MAX 0x32
-
-enum {
-	STATUS_PORT_STARTED, /* track if AFE port has started */
-	STATUS_MAX
-};
-
-struct msm_ext_disp_ca {
-	bool set_ca;
-	u32 ca;
-};
-
-struct msm_dai_q6_hdmi_dai_data {
-	DECLARE_BITMAP(status_mask, STATUS_MAX);
-	u32 rate;
-	u32 channels;
-	struct msm_ext_disp_ca ca;
-	union afe_port_config port_config;
-};
-
-static int msm_dai_q6_ext_disp_format_put(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	if (!dai_data) {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dai_data->port_config.hdmi_multi_ch.datatype = value;
-	pr_debug("%s: value = %d\n", __func__, value);
-
-	return 0;
-}
-
-static int msm_dai_q6_ext_disp_format_get(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
-
-	if (!dai_data) {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	ucontrol->value.integer.value[0] =
-		dai_data->port_config.hdmi_multi_ch.datatype;
-	pr_debug("%s: value = %ld\n",
-		 __func__, ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_dai_q6_ext_disp_ca_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
-
-	if (!dai_data) {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dai_data->ca.ca = ucontrol->value.integer.value[0];
-	dai_data->ca.set_ca = true;
-	pr_debug("%s: ca = %d\n", __func__, dai_data->ca.ca);
-	return 0;
-}
-
-static int msm_dai_q6_ext_disp_ca_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data;
-
-	if (!dai_data) {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	ucontrol->value.integer.value[0] = dai_data->ca.ca;
-	pr_debug("%s: ca = %d\n", __func__, dai_data->ca.ca);
-	return 0;
-}
-
-/* HDMI format field for AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG command
- *  0: linear PCM
- *  1: non-linear PCM
- */
-static const char * const hdmi_format[] = {
-	"LPCM",
-	"Compr"
-};
-
-static const struct soc_enum hdmi_config_enum[] = {
-	SOC_ENUM_SINGLE_EXT(2, hdmi_format),
-};
-
-static int msm_dai_q6_ext_disp_drift_info(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
-
-	return 0;
-}
-
-static int msm_dai_q6_ext_disp_drift_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = -EINVAL;
-	struct afe_param_id_dev_timing_stats timing_stats;
-	struct snd_soc_dai *dai = kcontrol->private_data;
-	struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_err("%s:  afe port not started. status_mask = %ld\n",
-			__func__, *dai_data->status_mask);
-		goto done;
-	}
-
-	memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
-	ret = afe_get_av_dev_drift(&timing_stats, dai->id);
-	if (ret) {
-		pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
-			__func__, dai->id, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
-	       sizeof(struct afe_param_id_dev_timing_stats));
-done:
-	return ret;
-}
-
-static const struct snd_kcontrol_new hdmi_config_controls[] = {
-	SOC_ENUM_EXT("HDMI RX Format", hdmi_config_enum[0],
-				 msm_dai_q6_ext_disp_format_get,
-				 msm_dai_q6_ext_disp_format_put),
-	SOC_SINGLE_MULTI_EXT("HDMI RX CA", SND_SOC_NOPM, 0,
-				 HDMI_RX_CA_MAX, 0, 1,
-				 msm_dai_q6_ext_disp_ca_get,
-				 msm_dai_q6_ext_disp_ca_put),
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_PCM,
-		.name	= "HDMI DRIFT",
-		.info	= msm_dai_q6_ext_disp_drift_info,
-		.get	= msm_dai_q6_ext_disp_drift_get,
-	},
-};
-
-static const struct snd_kcontrol_new display_port_config_controls[] = {
-	SOC_ENUM_EXT("Display Port RX Format", hdmi_config_enum[0],
-				 msm_dai_q6_ext_disp_format_get,
-				 msm_dai_q6_ext_disp_format_put),
-	SOC_SINGLE_MULTI_EXT("Display Port RX CA", SND_SOC_NOPM, 0,
-				 HDMI_RX_CA_MAX, 0, 1,
-				 msm_dai_q6_ext_disp_ca_get,
-				 msm_dai_q6_ext_disp_ca_put),
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_PCM,
-		.name	= "DISPLAY_PORT DRIFT",
-		.info	= msm_dai_q6_ext_disp_drift_info,
-		.get	= msm_dai_q6_ext_disp_drift_get,
-	},
-};
-
-/* Current implementation assumes hw_param is called once
- * This may not be the case but what to do when ADM and AFE
- * port are already opened and parameter changes
- */
-static int msm_dai_q6_hdmi_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-	dai_data->port_config.hdmi_multi_ch.reserved = 0;
-	dai_data->port_config.hdmi_multi_ch.hdmi_cfg_minor_version = 1;
-	dai_data->port_config.hdmi_multi_ch.sample_rate = dai_data->rate;
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		dai_data->port_config.hdmi_multi_ch.bit_width = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		dai_data->port_config.hdmi_multi_ch.bit_width = 24;
-		break;
-	}
-
-	/*refer to HDMI spec CEA-861-E: Table 28 Audio InfoFrame Data Byte 4*/
-	switch (dai_data->channels) {
-	case 2:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0;
-		break;
-	case 3:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x02;
-		break;
-	case 4:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x06;
-		break;
-	case 5:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x0A;
-		break;
-	case 6:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x0B;
-		break;
-	case 7:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x12;
-		break;
-	case 8:
-		dai_data->port_config.hdmi_multi_ch.channel_allocation = 0x13;
-		break;
-	default:
-		dev_err(dai->dev, "invalid Channels = %u\n",
-				dai_data->channels);
-		return -EINVAL;
-	}
-	dev_dbg(dai->dev, "%s() minor version: %u samplerate: %u bitwidth: %u\n"
-		"num_ch = %u channel_allocation = %u datatype = %d\n", __func__,
-		dai_data->port_config.hdmi_multi_ch.hdmi_cfg_minor_version,
-		dai_data->port_config.hdmi_multi_ch.sample_rate,
-		dai_data->port_config.hdmi_multi_ch.bit_width,
-		dai_data->channels,
-		dai_data->port_config.hdmi_multi_ch.channel_allocation,
-		dai_data->port_config.hdmi_multi_ch.datatype);
-
-	return 0;
-}
-
-
-static void msm_dai_q6_hdmi_shutdown(struct snd_pcm_substream *substream,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_info("%s:  afe port not started. dai_data->status_mask = %ld\n",
-		 __func__, *dai_data->status_mask);
-		return;
-	}
-
-	rc = afe_close(dai->id); /* can block */
-	if (rc < 0)
-		dev_err(dai->dev, "fail to close AFE port\n");
-
-	pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
-			*dai_data->status_mask);
-
-	clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-}
-
-
-static int msm_dai_q6_hdmi_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (dai_data->ca.set_ca)
-		dai_data->port_config.hdmi_multi_ch.channel_allocation =
-							      dai_data->ca.ca;
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_port_start(dai->id, &dai_data->port_config,
-				    dai_data->rate);
-		if (rc < 0)
-			dev_err(dai->dev, "fail to open AFE port %x\n",
-				dai->id);
-		else
-			set_bit(STATUS_PORT_STARTED,
-				dai_data->status_mask);
-	}
-
-	return rc;
-}
-
-static inline void msm_dai_q6_hdmi_set_dai_id(struct snd_soc_dai *dai)
-{
-	if (!dai->driver->id) {
-		dev_warn(dai->dev, "DAI driver id is not set\n");
-		return;
-	}
-	dai->id = dai->driver->id;
-}
-
-static int msm_dai_q6_hdmi_dai_probe(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data;
-	const struct snd_kcontrol_new *kcontrol;
-	int rc = 0;
-	struct snd_soc_dapm_route intercon;
-	struct snd_soc_dapm_context *dapm;
-
-	if (!dai || !dai->driver) {
-		pr_err("%s: dai or dai->driver is NULL\n", __func__);
-		return -EINVAL;
-	}
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_hdmi_dai_data),
-		GFP_KERNEL);
-
-	if (!dai_data) {
-		dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
-		dai->id);
-		rc = -ENOMEM;
-	} else
-		dev_set_drvdata(dai->dev, dai_data);
-
-	msm_dai_q6_hdmi_set_dai_id(dai);
-
-	if (dai->driver->id == HDMI_RX) {
-		kcontrol = &hdmi_config_controls[0];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(kcontrol, dai_data));
-
-		kcontrol = &hdmi_config_controls[1];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(kcontrol, dai_data));
-
-		kcontrol = &hdmi_config_controls[2];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(kcontrol, dai));
-	} else if (dai->driver->id == DISPLAY_PORT_RX) {
-		kcontrol = &display_port_config_controls[0];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(kcontrol, dai_data));
-
-		kcontrol = &display_port_config_controls[1];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(kcontrol, dai_data));
-
-		kcontrol = &display_port_config_controls[2];
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(kcontrol, dai));
-	} else {
-		dev_err(dai->dev, "%s: Invalid id:%d\n",
-			__func__, dai->driver->id);
-		kfree(dai_data);
-		dev_set_drvdata(dai->dev, NULL);
-		return -EINVAL;
-	}
-
-	dapm = snd_soc_component_get_dapm(dai->component);
-	memset(&intercon, 0, sizeof(intercon));
-	if (!rc) {
-		if (dai->driver->playback.stream_name &&
-			dai->driver->playback.aif_name) {
-			dev_dbg(dai->dev, "%s add route for widget %s",
-				   __func__, dai->driver->playback.stream_name);
-			intercon.source = dai->driver->playback.aif_name;
-			intercon.sink = dai->driver->playback.stream_name;
-			dev_dbg(dai->dev, "%s src %s sink %s\n",
-				   __func__, intercon.source, intercon.sink);
-			snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		}
-		if (dai->driver->capture.stream_name &&
-		   dai->driver->capture.aif_name) {
-			dev_dbg(dai->dev, "%s add route for widget %s",
-				   __func__, dai->driver->capture.stream_name);
-			intercon.sink = dai->driver->capture.aif_name;
-			intercon.source = dai->driver->capture.stream_name;
-			dev_dbg(dai->dev, "%s src %s sink %s\n",
-				   __func__, intercon.source, intercon.sink);
-			snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		}
-	}
-	return rc;
-}
-
-static int msm_dai_q6_hdmi_dai_remove(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_hdmi_dai_data *dai_data;
-	int rc;
-
-	dai_data = dev_get_drvdata(dai->dev);
-
-	/* If AFE port is still up, close it */
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_close(dai->id); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AFE port\n");
-
-		clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-	}
-	kfree(dai_data);
-
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_hdmi_ops = {
-	.prepare	= msm_dai_q6_hdmi_prepare,
-	.hw_params	= msm_dai_q6_hdmi_hw_params,
-	.shutdown	= msm_dai_q6_hdmi_shutdown,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_hdmi_hdmi_rx_dai = {
-	.playback = {
-		.stream_name = "HDMI Playback",
-		.aif_name = "HDMI",
-		.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-			 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-			 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-			 SNDRV_PCM_RATE_192000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
-		.channels_min = 2,
-		.channels_max = 8,
-		.rate_max = 192000,
-		.rate_min = 48000,
-	},
-	.ops = &msm_dai_q6_hdmi_ops,
-	.id = HDMI_RX,
-	.probe = msm_dai_q6_hdmi_dai_probe,
-	.remove = msm_dai_q6_hdmi_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_display_port_rx_dai[] = {
-	{
-		.playback = {
-			.stream_name = "Display Port Playback",
-			.aif_name = "DISPLAY_PORT",
-			.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-				 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 2,
-			.channels_max = 8,
-			.rate_max =     192000,
-			.rate_min =     48000,
-		},
-		.ops = &msm_dai_q6_hdmi_ops,
-		.id = DISPLAY_PORT_RX,
-		.probe = msm_dai_q6_hdmi_dai_probe,
-		.remove = msm_dai_q6_hdmi_dai_remove,
-	},
-};
-
-static const struct snd_soc_component_driver msm_dai_hdmi_q6_component = {
-	.name		= "msm-dai-q6-hdmi",
-};
-
-/* To do: change to register DAIs as batch */
-static int msm_dai_q6_hdmi_dev_probe(struct platform_device *pdev)
-{
-	int rc, id;
-	const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
-
-	rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: missing %s in dt node\n", __func__, q6_dev_id);
-		return rc;
-	}
-
-	pdev->id = id;
-
-	pr_debug("%s: dev name %s, id:%d\n", __func__,
-			dev_name(&pdev->dev), pdev->id);
-
-	switch (pdev->id) {
-	case HDMI_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_hdmi_q6_component,
-			&msm_dai_q6_hdmi_hdmi_rx_dai, 1);
-		break;
-	case DISPLAY_PORT_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_hdmi_q6_component,
-			&msm_dai_q6_display_port_rx_dai[0],
-			ARRAY_SIZE(msm_dai_q6_display_port_rx_dai));
-		break;
-	default:
-		dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
-		rc = -ENODEV;
-		break;
-	}
-	return rc;
-}
-
-static int msm_dai_q6_hdmi_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_dai_q6_hdmi_dt_match[] = {
-	{.compatible = "qcom,msm-dai-q6-hdmi"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_dai_q6_hdmi_dt_match);
-
-static struct platform_driver msm_dai_q6_hdmi_driver = {
-	.probe  = msm_dai_q6_hdmi_dev_probe,
-	.remove = msm_dai_q6_hdmi_dev_remove,
-	.driver = {
-		.name = "msm-dai-q6-hdmi",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_hdmi_dt_match,
-	},
-};
-
-static int __init msm_dai_q6_hdmi_init(void)
-{
-	return platform_driver_register(&msm_dai_q6_hdmi_driver);
-}
-module_init(msm_dai_q6_hdmi_init);
-
-static void __exit msm_dai_q6_hdmi_exit(void)
-{
-	platform_driver_unregister(&msm_dai_q6_hdmi_driver);
-}
-module_exit(msm_dai_q6_hdmi_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("MSM DSP HDMI DAI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c
deleted file mode 100644
index 543bc31..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c
+++ /dev/null
@@ -1,8252 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/bitops.h>
-#include <linux/slab.h>
-#include <linux/clk.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/msm-dai-q6-v2.h>
-#include <sound/pcm_params.h>
-
-#define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
-#define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
-#define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
-#define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
-
-
-#define spdif_clock_value(rate) (2*rate*32*2)
-#define CHANNEL_STATUS_SIZE 24
-#define CHANNEL_STATUS_MASK_INIT 0x0
-#define CHANNEL_STATUS_MASK 0x4
-#define AFE_API_VERSION_CLOCK_SET 1
-
-#define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
-				    SNDRV_PCM_FMTBIT_S24_LE | \
-				    SNDRV_PCM_FMTBIT_S32_LE)
-
-enum {
-	ENC_FMT_NONE,
-	ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
-	ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
-	ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
-	ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
-};
-
-enum {
-	SPKR_1,
-	SPKR_2,
-};
-
-static const struct afe_clk_set lpass_clk_set_default = {
-	AFE_API_VERSION_CLOCK_SET,
-	Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
-	Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
-	Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	0,
-};
-
-static const struct afe_clk_cfg lpass_clk_cfg_default = {
-	AFE_API_VERSION_I2S_CONFIG,
-	Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
-	0,
-	Q6AFE_LPASS_CLK_SRC_INTERNAL,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	Q6AFE_LPASS_MODE_CLK1_VALID,
-	0,
-};
-enum {
-	STATUS_PORT_STARTED, /* track if AFE port has started */
-	/* track AFE Tx port status for bi-directional transfers */
-	STATUS_TX_PORT,
-	/* track AFE Rx port status for bi-directional transfers */
-	STATUS_RX_PORT,
-	STATUS_MAX
-};
-
-enum {
-	RATE_8KHZ,
-	RATE_16KHZ,
-	RATE_MAX_NUM_OF_AUX_PCM_RATES,
-};
-
-enum {
-	IDX_PRIMARY_TDM_RX_0,
-	IDX_PRIMARY_TDM_RX_1,
-	IDX_PRIMARY_TDM_RX_2,
-	IDX_PRIMARY_TDM_RX_3,
-	IDX_PRIMARY_TDM_RX_4,
-	IDX_PRIMARY_TDM_RX_5,
-	IDX_PRIMARY_TDM_RX_6,
-	IDX_PRIMARY_TDM_RX_7,
-	IDX_PRIMARY_TDM_TX_0,
-	IDX_PRIMARY_TDM_TX_1,
-	IDX_PRIMARY_TDM_TX_2,
-	IDX_PRIMARY_TDM_TX_3,
-	IDX_PRIMARY_TDM_TX_4,
-	IDX_PRIMARY_TDM_TX_5,
-	IDX_PRIMARY_TDM_TX_6,
-	IDX_PRIMARY_TDM_TX_7,
-	IDX_SECONDARY_TDM_RX_0,
-	IDX_SECONDARY_TDM_RX_1,
-	IDX_SECONDARY_TDM_RX_2,
-	IDX_SECONDARY_TDM_RX_3,
-	IDX_SECONDARY_TDM_RX_4,
-	IDX_SECONDARY_TDM_RX_5,
-	IDX_SECONDARY_TDM_RX_6,
-	IDX_SECONDARY_TDM_RX_7,
-	IDX_SECONDARY_TDM_TX_0,
-	IDX_SECONDARY_TDM_TX_1,
-	IDX_SECONDARY_TDM_TX_2,
-	IDX_SECONDARY_TDM_TX_3,
-	IDX_SECONDARY_TDM_TX_4,
-	IDX_SECONDARY_TDM_TX_5,
-	IDX_SECONDARY_TDM_TX_6,
-	IDX_SECONDARY_TDM_TX_7,
-	IDX_TERTIARY_TDM_RX_0,
-	IDX_TERTIARY_TDM_RX_1,
-	IDX_TERTIARY_TDM_RX_2,
-	IDX_TERTIARY_TDM_RX_3,
-	IDX_TERTIARY_TDM_RX_4,
-	IDX_TERTIARY_TDM_RX_5,
-	IDX_TERTIARY_TDM_RX_6,
-	IDX_TERTIARY_TDM_RX_7,
-	IDX_TERTIARY_TDM_TX_0,
-	IDX_TERTIARY_TDM_TX_1,
-	IDX_TERTIARY_TDM_TX_2,
-	IDX_TERTIARY_TDM_TX_3,
-	IDX_TERTIARY_TDM_TX_4,
-	IDX_TERTIARY_TDM_TX_5,
-	IDX_TERTIARY_TDM_TX_6,
-	IDX_TERTIARY_TDM_TX_7,
-	IDX_QUATERNARY_TDM_RX_0,
-	IDX_QUATERNARY_TDM_RX_1,
-	IDX_QUATERNARY_TDM_RX_2,
-	IDX_QUATERNARY_TDM_RX_3,
-	IDX_QUATERNARY_TDM_RX_4,
-	IDX_QUATERNARY_TDM_RX_5,
-	IDX_QUATERNARY_TDM_RX_6,
-	IDX_QUATERNARY_TDM_RX_7,
-	IDX_QUATERNARY_TDM_TX_0,
-	IDX_QUATERNARY_TDM_TX_1,
-	IDX_QUATERNARY_TDM_TX_2,
-	IDX_QUATERNARY_TDM_TX_3,
-	IDX_QUATERNARY_TDM_TX_4,
-	IDX_QUATERNARY_TDM_TX_5,
-	IDX_QUATERNARY_TDM_TX_6,
-	IDX_QUATERNARY_TDM_TX_7,
-	IDX_TDM_MAX,
-};
-
-enum {
-	IDX_GROUP_PRIMARY_TDM_RX,
-	IDX_GROUP_PRIMARY_TDM_TX,
-	IDX_GROUP_SECONDARY_TDM_RX,
-	IDX_GROUP_SECONDARY_TDM_TX,
-	IDX_GROUP_TERTIARY_TDM_RX,
-	IDX_GROUP_TERTIARY_TDM_TX,
-	IDX_GROUP_QUATERNARY_TDM_RX,
-	IDX_GROUP_QUATERNARY_TDM_TX,
-	IDX_GROUP_TDM_MAX,
-};
-
-struct msm_dai_q6_dai_data {
-	DECLARE_BITMAP(status_mask, STATUS_MAX);
-	DECLARE_BITMAP(hwfree_status, STATUS_MAX);
-	u32 rate;
-	u32 channels;
-	u32 bitwidth;
-	u32 cal_mode;
-	u32 afe_in_channels;
-	u16 afe_in_bitformat;
-	struct afe_enc_config enc_config;
-	union afe_port_config port_config;
-	u16 vi_feed_mono;
-};
-
-struct msm_dai_q6_spdif_dai_data {
-	DECLARE_BITMAP(status_mask, STATUS_MAX);
-	u32 rate;
-	u32 channels;
-	u32 bitwidth;
-	struct afe_spdif_port_config spdif_port;
-};
-
-struct msm_dai_q6_mi2s_dai_config {
-	u16 pdata_mi2s_lines;
-	struct msm_dai_q6_dai_data mi2s_dai_data;
-};
-
-struct msm_dai_q6_mi2s_dai_data {
-	struct msm_dai_q6_mi2s_dai_config tx_dai;
-	struct msm_dai_q6_mi2s_dai_config rx_dai;
-};
-
-struct msm_dai_q6_auxpcm_dai_data {
-	/* BITMAP to track Rx and Tx port usage count */
-	DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
-	struct mutex rlock; /* auxpcm dev resource lock */
-	u16 rx_pid; /* AUXPCM RX AFE port ID */
-	u16 tx_pid; /* AUXPCM TX AFE port ID */
-	u16 afe_clk_ver;
-	struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
-	struct afe_clk_set clk_set; /* hold LPASS clock configuration */
-	struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
-};
-
-struct msm_dai_q6_tdm_dai_data {
-	DECLARE_BITMAP(status_mask, STATUS_MAX);
-	u32 rate;
-	u32 channels;
-	u32 bitwidth;
-	u32 num_group_ports;
-	struct afe_clk_set clk_set; /* hold LPASS clock config. */
-	union afe_port_group_config group_cfg; /* hold tdm group config */
-	struct afe_tdm_port_config port_cfg; /* hold tdm config */
-};
-
-/* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
- *  0: linear PCM
- *  1: non-linear PCM
- *  2: PCM data in IEC 60968 container
- *  3: compressed data in IEC 60958 container
- */
-static const char *const mi2s_format[] = {
-	"LPCM",
-	"Compr",
-	"LPCM-60958",
-	"Compr-60958"
-};
-
-static const char *const mi2s_vi_feed_mono[] = {
-	"Left",
-	"Right",
-};
-
-static const struct soc_enum mi2s_config_enum[] = {
-	SOC_ENUM_SINGLE_EXT(4, mi2s_format),
-	SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
-};
-
-static const char *const sb_format[] = {
-	"UNPACKED",
-	"PACKED_16B",
-	"DSD_DOP",
-};
-
-static const struct soc_enum sb_config_enum[] = {
-	SOC_ENUM_SINGLE_EXT(3, sb_format),
-};
-
-static const char *const tdm_data_format[] = {
-	"LPCM",
-	"Compr",
-	"Gen Compr"
-};
-
-static const char *const tdm_header_type[] = {
-	"Invalid",
-	"Default",
-	"Entertainment",
-};
-
-static const struct soc_enum tdm_config_enum[] = {
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
-};
-
-static DEFINE_MUTEX(tdm_mutex);
-
-static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
-
-/* cache of group cfg per parent node */
-static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
-	AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
-	AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
-	0,
-	{AFE_PORT_ID_QUATERNARY_TDM_RX,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_1,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_2,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_3,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_4,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_5,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_6,
-	AFE_PORT_ID_QUATERNARY_TDM_RX_7},
-	8,
-	48000,
-	32,
-	8,
-	32,
-	0xFF,
-};
-
-static u32 num_tdm_group_ports;
-
-static struct afe_clk_set tdm_clk_set = {
-	AFE_API_VERSION_CLOCK_SET,
-	Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
-	Q6AFE_LPASS_IBIT_CLK_DISABLE,
-	Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
-	Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-	0,
-};
-
-int msm_dai_q6_get_group_idx(u16 id)
-{
-	switch (id) {
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-		return IDX_GROUP_PRIMARY_TDM_RX;
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-		return IDX_GROUP_PRIMARY_TDM_TX;
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-		return IDX_GROUP_SECONDARY_TDM_RX;
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-		return IDX_GROUP_SECONDARY_TDM_TX;
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-		return IDX_GROUP_TERTIARY_TDM_RX;
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-		return IDX_GROUP_TERTIARY_TDM_TX;
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		return IDX_GROUP_QUATERNARY_TDM_RX;
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		return IDX_GROUP_QUATERNARY_TDM_TX;
-	default: return -EINVAL;
-	}
-}
-
-int msm_dai_q6_get_port_idx(u16 id)
-{
-	switch (id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-		return IDX_PRIMARY_TDM_RX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-		return IDX_PRIMARY_TDM_TX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-		return IDX_PRIMARY_TDM_RX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-		return IDX_PRIMARY_TDM_TX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-		return IDX_PRIMARY_TDM_RX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-		return IDX_PRIMARY_TDM_TX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-		return IDX_PRIMARY_TDM_RX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-		return IDX_PRIMARY_TDM_TX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-		return IDX_PRIMARY_TDM_RX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-		return IDX_PRIMARY_TDM_TX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-		return IDX_PRIMARY_TDM_RX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-		return IDX_PRIMARY_TDM_TX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-		return IDX_PRIMARY_TDM_RX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-		return IDX_PRIMARY_TDM_TX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-		return IDX_PRIMARY_TDM_RX_7;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-		return IDX_PRIMARY_TDM_TX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-		return IDX_SECONDARY_TDM_RX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-		return IDX_SECONDARY_TDM_TX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-		return IDX_SECONDARY_TDM_RX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-		return IDX_SECONDARY_TDM_TX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-		return IDX_SECONDARY_TDM_RX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-		return IDX_SECONDARY_TDM_TX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-		return IDX_SECONDARY_TDM_RX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-		return IDX_SECONDARY_TDM_TX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-		return IDX_SECONDARY_TDM_RX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-		return IDX_SECONDARY_TDM_TX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-		return IDX_SECONDARY_TDM_RX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-		return IDX_SECONDARY_TDM_TX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-		return IDX_SECONDARY_TDM_RX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-		return IDX_SECONDARY_TDM_TX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-		return IDX_SECONDARY_TDM_RX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-		return IDX_SECONDARY_TDM_TX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-		return IDX_TERTIARY_TDM_RX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-		return IDX_TERTIARY_TDM_TX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-		return IDX_TERTIARY_TDM_RX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-		return IDX_TERTIARY_TDM_TX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-		return IDX_TERTIARY_TDM_RX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-		return IDX_TERTIARY_TDM_TX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-		return IDX_TERTIARY_TDM_RX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-		return IDX_TERTIARY_TDM_TX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-		return IDX_TERTIARY_TDM_RX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-		return IDX_TERTIARY_TDM_TX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-		return IDX_TERTIARY_TDM_RX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-		return IDX_TERTIARY_TDM_TX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-		return IDX_TERTIARY_TDM_RX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-		return IDX_TERTIARY_TDM_TX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-		return IDX_TERTIARY_TDM_RX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-		return IDX_TERTIARY_TDM_TX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-		return IDX_QUATERNARY_TDM_RX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		return IDX_QUATERNARY_TDM_TX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-		return IDX_QUATERNARY_TDM_RX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-		return IDX_QUATERNARY_TDM_TX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-		return IDX_QUATERNARY_TDM_RX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-		return IDX_QUATERNARY_TDM_TX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-		return IDX_QUATERNARY_TDM_RX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-		return IDX_QUATERNARY_TDM_TX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-		return IDX_QUATERNARY_TDM_RX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-		return IDX_QUATERNARY_TDM_TX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-		return IDX_QUATERNARY_TDM_RX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-		return IDX_QUATERNARY_TDM_TX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-		return IDX_QUATERNARY_TDM_RX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-		return IDX_QUATERNARY_TDM_TX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		return IDX_QUATERNARY_TDM_RX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		return IDX_QUATERNARY_TDM_TX_7;
-	default: return -EINVAL;
-	}
-}
-
-static u16 msm_dai_q6_max_num_slot(int frame_rate)
-{
-	/* Max num of slots is bits per frame divided
-	 * by bits per sample which is 16
-	 */
-	switch (frame_rate) {
-	case AFE_PORT_PCM_BITS_PER_FRAME_8:
-		return 0;
-	case AFE_PORT_PCM_BITS_PER_FRAME_16:
-		return 1;
-	case AFE_PORT_PCM_BITS_PER_FRAME_32:
-		return 2;
-	case AFE_PORT_PCM_BITS_PER_FRAME_64:
-		return 4;
-	case AFE_PORT_PCM_BITS_PER_FRAME_128:
-		return 8;
-	case AFE_PORT_PCM_BITS_PER_FRAME_256:
-		return 16;
-	default:
-		pr_err("%s Invalid bits per frame %d\n",
-			__func__, frame_rate);
-		return 0;
-	}
-}
-
-static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
-{
-	struct snd_soc_dapm_route intercon;
-	struct snd_soc_dapm_context *dapm;
-
-	if (!dai) {
-		pr_err("%s: Invalid params dai\n", __func__);
-		return -EINVAL;
-	}
-	if (!dai->driver) {
-		pr_err("%s: Invalid params dai driver\n", __func__);
-		return -EINVAL;
-	}
-	dapm = snd_soc_component_get_dapm(dai->component);
-	memset(&intercon, 0, sizeof(intercon));
-	if (dai->driver->playback.stream_name &&
-		dai->driver->playback.aif_name) {
-		dev_dbg(dai->dev, "%s: add route for widget %s",
-				__func__, dai->driver->playback.stream_name);
-		intercon.source = dai->driver->playback.aif_name;
-		intercon.sink = dai->driver->playback.stream_name;
-		dev_dbg(dai->dev, "%s: src %s sink %s\n",
-				__func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-	}
-	if (dai->driver->capture.stream_name &&
-		dai->driver->capture.aif_name) {
-		dev_dbg(dai->dev, "%s: add route for widget %s",
-				__func__, dai->driver->capture.stream_name);
-		intercon.sink = dai->driver->capture.aif_name;
-		intercon.source = dai->driver->capture.stream_name;
-		dev_dbg(dai->dev, "%s: src %s sink %s\n",
-				__func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-	}
-	return 0;
-}
-
-static int msm_dai_q6_auxpcm_hw_params(
-				struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
-			dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
-	struct msm_dai_auxpcm_pdata *auxpcm_pdata =
-			(struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
-	int rc = 0, slot_mapping_copy_len = 0;
-
-	if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
-	    params_rate(params) != 16000)) {
-		dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
-			__func__, params_channels(params), params_rate(params));
-		return -EINVAL;
-	}
-
-	mutex_lock(&aux_dai_data->rlock);
-
-	if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
-	    test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
-		/* AUXPCM DAI in use */
-		if (dai_data->rate != params_rate(params)) {
-			dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
-			__func__);
-			rc = -EINVAL;
-		}
-		mutex_unlock(&aux_dai_data->rlock);
-		return rc;
-	}
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	if (dai_data->rate == 8000) {
-		dai_data->port_config.pcm.pcm_cfg_minor_version =
-				AFE_API_VERSION_PCM_CONFIG;
-		dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
-		dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
-		dai_data->port_config.pcm.frame_setting =
-					auxpcm_pdata->mode_8k.frame;
-		dai_data->port_config.pcm.quantype =
-					 auxpcm_pdata->mode_8k.quant;
-		dai_data->port_config.pcm.ctrl_data_out_enable =
-					 auxpcm_pdata->mode_8k.data;
-		dai_data->port_config.pcm.sample_rate = dai_data->rate;
-		dai_data->port_config.pcm.num_channels = dai_data->channels;
-		dai_data->port_config.pcm.bit_width = 16;
-		if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
-		    auxpcm_pdata->mode_8k.num_slots)
-			slot_mapping_copy_len =
-				ARRAY_SIZE(
-				dai_data->port_config.pcm.slot_number_mapping)
-				 * sizeof(uint16_t);
-		else
-			slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
-				* sizeof(uint16_t);
-
-		if (auxpcm_pdata->mode_8k.slot_mapping) {
-			memcpy(dai_data->port_config.pcm.slot_number_mapping,
-			       auxpcm_pdata->mode_8k.slot_mapping,
-			       slot_mapping_copy_len);
-		} else {
-			dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
-				__func__);
-			mutex_unlock(&aux_dai_data->rlock);
-			return -EINVAL;
-		}
-	} else {
-		dai_data->port_config.pcm.pcm_cfg_minor_version =
-				AFE_API_VERSION_PCM_CONFIG;
-		dai_data->port_config.pcm.aux_mode =
-					auxpcm_pdata->mode_16k.mode;
-		dai_data->port_config.pcm.sync_src =
-					auxpcm_pdata->mode_16k.sync;
-		dai_data->port_config.pcm.frame_setting =
-					auxpcm_pdata->mode_16k.frame;
-		dai_data->port_config.pcm.quantype =
-					auxpcm_pdata->mode_16k.quant;
-		dai_data->port_config.pcm.ctrl_data_out_enable =
-					auxpcm_pdata->mode_16k.data;
-		dai_data->port_config.pcm.sample_rate = dai_data->rate;
-		dai_data->port_config.pcm.num_channels = dai_data->channels;
-		dai_data->port_config.pcm.bit_width = 16;
-		if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
-		    auxpcm_pdata->mode_16k.num_slots)
-			slot_mapping_copy_len =
-				ARRAY_SIZE(
-				dai_data->port_config.pcm.slot_number_mapping)
-				 * sizeof(uint16_t);
-		else
-			slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
-				* sizeof(uint16_t);
-
-		if (auxpcm_pdata->mode_16k.slot_mapping) {
-			memcpy(dai_data->port_config.pcm.slot_number_mapping,
-			       auxpcm_pdata->mode_16k.slot_mapping,
-			       slot_mapping_copy_len);
-		} else {
-			dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
-				__func__);
-			mutex_unlock(&aux_dai_data->rlock);
-			return -EINVAL;
-		}
-	}
-
-	dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
-		__func__, dai_data->port_config.pcm.aux_mode,
-		dai_data->port_config.pcm.sync_src,
-		dai_data->port_config.pcm.frame_setting);
-	dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
-		"num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
-		__func__, dai_data->port_config.pcm.quantype,
-		dai_data->port_config.pcm.ctrl_data_out_enable,
-		dai_data->port_config.pcm.slot_number_mapping[0],
-		dai_data->port_config.pcm.slot_number_mapping[1],
-		dai_data->port_config.pcm.slot_number_mapping[2],
-		dai_data->port_config.pcm.slot_number_mapping[3]);
-
-	mutex_unlock(&aux_dai_data->rlock);
-	return rc;
-}
-
-static int msm_dai_q6_auxpcm_set_clk(
-		struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
-		u16 port_id, bool enable)
-{
-	int rc;
-
-	pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
-		 aux_dai_data->afe_clk_ver, port_id, enable);
-	if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
-		aux_dai_data->clk_set.enable = enable;
-		rc = afe_set_lpass_clock_v2(port_id,
-					&aux_dai_data->clk_set);
-	} else {
-		if (!enable)
-			aux_dai_data->clk_cfg.clk_val1 = 0;
-		rc = afe_set_lpass_clock(port_id,
-					&aux_dai_data->clk_cfg);
-	}
-	return rc;
-}
-
-static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
-				struct snd_soc_dai *dai)
-{
-	int rc = 0;
-	struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
-		dev_get_drvdata(dai->dev);
-
-	mutex_lock(&aux_dai_data->rlock);
-
-	if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
-	      test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
-		dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
-				__func__, dai->id);
-		goto exit;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
-			clear_bit(STATUS_TX_PORT,
-				  aux_dai_data->auxpcm_port_status);
-		else {
-			dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
-				__func__);
-			goto exit;
-		}
-	} else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
-			clear_bit(STATUS_RX_PORT,
-				  aux_dai_data->auxpcm_port_status);
-		else {
-			dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
-				__func__);
-			goto exit;
-		}
-	}
-	if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
-	    test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
-		dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
-			__func__);
-		goto exit;
-	}
-
-	dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
-			__func__, dai->id);
-
-	rc = afe_close(aux_dai_data->rx_pid); /* can block */
-	if (rc < 0)
-		dev_err(dai->dev, "fail to close PCM_RX  AFE port\n");
-
-	rc = afe_close(aux_dai_data->tx_pid);
-	if (rc < 0)
-		dev_err(dai->dev, "fail to close AUX PCM TX port\n");
-
-	msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
-	msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
-exit:
-	mutex_unlock(&aux_dai_data->rlock);
-}
-
-static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
-		dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
-	struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
-	int rc = 0;
-	u32 pcm_clk_rate;
-
-	auxpcm_pdata = dai->dev->platform_data;
-	mutex_lock(&aux_dai_data->rlock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		if (test_bit(STATUS_TX_PORT,
-				aux_dai_data->auxpcm_port_status)) {
-			dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
-				__func__);
-			goto exit;
-		} else
-			set_bit(STATUS_TX_PORT,
-				  aux_dai_data->auxpcm_port_status);
-	} else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		if (test_bit(STATUS_RX_PORT,
-				aux_dai_data->auxpcm_port_status)) {
-			dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
-				__func__);
-			goto exit;
-		} else
-			set_bit(STATUS_RX_PORT,
-				  aux_dai_data->auxpcm_port_status);
-	}
-	if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
-	    test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
-		dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
-		goto exit;
-	}
-
-	dev_dbg(dai->dev, "%s: dai->id:%d  opening afe ports\n",
-			__func__, dai->id);
-
-	rc = afe_q6_interface_prepare();
-	if (rc < 0) {
-		dev_err(dai->dev, "fail to open AFE APR\n");
-		goto fail;
-	}
-
-	/*
-	 * For AUX PCM Interface the below sequence of clk
-	 * settings and afe_open is a strict requirement.
-	 *
-	 * Also using afe_open instead of afe_port_start_nowait
-	 * to make sure the port is open before deasserting the
-	 * clock line. This is required because pcm register is
-	 * not written before clock deassert. Hence the hw does
-	 * not get updated with new setting if the below clock
-	 * assert/deasset and afe_open sequence is not followed.
-	 */
-
-	if (dai_data->rate == 8000) {
-		pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
-	} else if (dai_data->rate == 16000) {
-		pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
-	} else {
-		dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
-			dai_data->rate);
-		rc = -EINVAL;
-		goto fail;
-	}
-	if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
-		memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
-				sizeof(struct afe_clk_set));
-		aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
-
-		switch (dai->id) {
-		case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
-			if (pcm_clk_rate)
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
-			else
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
-			break;
-		case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
-			if (pcm_clk_rate)
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
-			else
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
-			break;
-		case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
-			if (pcm_clk_rate)
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
-			else
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
-			break;
-		case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
-			if (pcm_clk_rate)
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
-			else
-				aux_dai_data->clk_set.clk_id =
-					Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
-			break;
-		default:
-			dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
-				__func__, dai->id);
-			break;
-		}
-	} else {
-		memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
-				sizeof(struct afe_clk_cfg));
-		aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
-	}
-
-	rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
-				       aux_dai_data->rx_pid, true);
-	if (rc < 0) {
-		dev_err(dai->dev,
-			"%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
-			__func__);
-		goto fail;
-	}
-
-	rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
-				       aux_dai_data->tx_pid, true);
-	if (rc < 0) {
-		dev_err(dai->dev,
-			"%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
-			__func__);
-		goto fail;
-	}
-
-	afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
-	afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
-	goto exit;
-
-fail:
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
-	else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
-
-exit:
-	mutex_unlock(&aux_dai_data->rlock);
-	return rc;
-}
-
-static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
-		int cmd, struct snd_soc_dai *dai)
-{
-	int rc = 0;
-
-	pr_debug("%s:port:%d  cmd:%d\n",
-		__func__, dai->id, cmd);
-
-	switch (cmd) {
-
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		/* afe_open will be called from prepare */
-		return 0;
-
-	case SNDRV_PCM_TRIGGER_STOP:
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		return 0;
-
-	default:
-		pr_err("%s: cmd %d\n", __func__, cmd);
-		rc = -EINVAL;
-	}
-
-	return rc;
-
-}
-
-static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
-	int rc;
-
-	aux_dai_data = dev_get_drvdata(dai->dev);
-
-	dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
-		__func__, dai->id);
-
-	if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
-	    test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
-		rc = afe_close(aux_dai_data->rx_pid); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
-		rc = afe_close(aux_dai_data->tx_pid);
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
-		clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
-		clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
-	}
-	msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
-	msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
-	return 0;
-}
-
-static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
-{
-	int rc = 0;
-
-	if (!dai) {
-		pr_err("%s: Invalid params dai\n", __func__);
-		return -EINVAL;
-	}
-	if (!dai->dev) {
-		pr_err("%s: Invalid params dai dev\n", __func__);
-		return -EINVAL;
-	}
-	if (!dai->driver->id) {
-		dev_warn(dai->dev, "DAI driver id is not set\n");
-		return -EINVAL;
-	}
-	dai->id = dai->driver->id;
-	rc = msm_dai_q6_dai_add_route(dai);
-	return rc;
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
-	.prepare	= msm_dai_q6_auxpcm_prepare,
-	.trigger	= msm_dai_q6_auxpcm_trigger,
-	.hw_params	= msm_dai_q6_auxpcm_hw_params,
-	.shutdown	= msm_dai_q6_auxpcm_shutdown,
-};
-
-static const struct snd_soc_component_driver
-	msm_dai_q6_aux_pcm_dai_component = {
-	.name		= "msm-auxpcm-dev",
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
-	{
-		.playback = {
-			.stream_name = "AUX PCM Playback",
-			.aif_name = "AUX_PCM_RX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.capture = {
-			.stream_name = "AUX PCM Capture",
-			.aif_name = "AUX_PCM_TX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
-		.ops = &msm_dai_q6_auxpcm_ops,
-		.probe = msm_dai_q6_aux_pcm_probe,
-		.remove = msm_dai_q6_dai_auxpcm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Sec AUX PCM Playback",
-			.aif_name = "SEC_AUX_PCM_RX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.capture = {
-			.stream_name = "Sec AUX PCM Capture",
-			.aif_name = "SEC_AUX_PCM_TX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
-		.ops = &msm_dai_q6_auxpcm_ops,
-		.probe = msm_dai_q6_aux_pcm_probe,
-		.remove = msm_dai_q6_dai_auxpcm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tert AUX PCM Playback",
-			.aif_name = "TERT_AUX_PCM_RX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.capture = {
-			.stream_name = "Tert AUX PCM Capture",
-			.aif_name = "TERT_AUX_PCM_TX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
-		.ops = &msm_dai_q6_auxpcm_ops,
-		.probe = msm_dai_q6_aux_pcm_probe,
-		.remove = msm_dai_q6_dai_auxpcm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quat AUX PCM Playback",
-			.aif_name = "QUAT_AUX_PCM_RX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.capture = {
-			.stream_name = "Quat AUX PCM Capture",
-			.aif_name = "QUAT_AUX_PCM_TX",
-			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 1,
-			.rate_max = 16000,
-			.rate_min = 8000,
-		},
-		.id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
-		.ops = &msm_dai_q6_auxpcm_ops,
-		.probe = msm_dai_q6_aux_pcm_probe,
-		.remove = msm_dai_q6_dai_auxpcm_remove,
-	},
-};
-
-static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	dai_data->spdif_port.cfg.data_format = value;
-	pr_debug("%s: value = %d\n", __func__, value);
-	return 0;
-}
-
-static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] =
-		dai_data->spdif_port.cfg.data_format;
-	return 0;
-}
-
-static const char * const spdif_format[] = {
-	"LPCM",
-	"Compr"
-};
-
-static const struct soc_enum spdif_config_enum[] = {
-	SOC_ENUM_SINGLE_EXT(2, spdif_format),
-};
-
-static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
-	int ret = 0;
-
-	dai_data->spdif_port.ch_status.status_type =
-		AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
-	memset(dai_data->spdif_port.ch_status.status_mask,
-			CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
-	dai_data->spdif_port.ch_status.status_mask[0] =
-		CHANNEL_STATUS_MASK;
-
-	memcpy(dai_data->spdif_port.ch_status.status_bits,
-			ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
-
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_debug("%s: Port already started. Dynamic update\n",
-				__func__);
-		ret = afe_send_spdif_ch_status_cfg(
-				&dai_data->spdif_port.ch_status,
-				AFE_PORT_ID_SPDIF_RX);
-	}
-	return ret;
-}
-
-static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-
-	struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
-
-	memcpy(ucontrol->value.iec958.status,
-			dai_data->spdif_port.ch_status.status_bits,
-			CHANNEL_STATUS_SIZE);
-	return 0;
-}
-
-static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
-	uinfo->count = 1;
-	return 0;
-}
-
-static const struct snd_kcontrol_new spdif_config_controls[] = {
-	{
-		.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
-				SNDRV_CTL_ELEM_ACCESS_INACTIVE),
-		.iface  =   SNDRV_CTL_ELEM_IFACE_PCM,
-		.name   =   SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
-		.info   =   msm_dai_q6_spdif_chstatus_info,
-		.get    =   msm_dai_q6_spdif_chstatus_get,
-		.put    =   msm_dai_q6_spdif_chstatus_put,
-	},
-	SOC_ENUM_EXT("SPDIF RX Format", spdif_config_enum[0],
-			msm_dai_q6_spdif_format_get,
-			msm_dai_q6_spdif_format_put)
-};
-
-
-static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
-		struct snd_pcm_hw_params *params,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai->id = AFE_PORT_ID_SPDIF_RX;
-	dai_data->channels = params_channels(params);
-	dai_data->spdif_port.cfg.num_channels = dai_data->channels;
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		dai_data->spdif_port.cfg.bit_width = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->spdif_port.cfg.bit_width = 24;
-		break;
-	default:
-		pr_err("%s: format %d\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	dai_data->rate = params_rate(params);
-	dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
-	dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
-	dai_data->spdif_port.cfg.spdif_cfg_minor_version =
-		AFE_API_VERSION_SPDIF_CONFIG;
-	dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
-			dai_data->channels, dai_data->rate,
-			dai_data->spdif_port.cfg.bit_width);
-	dai_data->spdif_port.cfg.reserved = 0;
-	return 0;
-}
-
-static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_info("%s:  afe port not started. dai_data->status_mask = %ld\n",
-				__func__, *dai_data->status_mask);
-		return;
-	}
-
-	rc = afe_close(dai->id);
-	if (rc < 0)
-		dev_err(dai->dev, "fail to close AFE port\n");
-
-	pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
-			*dai_data->status_mask);
-
-	clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-}
-
-
-static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
-				dai_data->rate);
-		if (rc < 0)
-			dev_err(dai->dev, "fail to open AFE port 0x%x\n",
-					dai->id);
-		else
-			set_bit(STATUS_PORT_STARTED,
-					dai_data->status_mask);
-	}
-
-	return rc;
-}
-
-static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data;
-	const struct snd_kcontrol_new *kcontrol;
-	int rc = 0;
-	struct snd_soc_dapm_route intercon;
-	struct snd_soc_dapm_context *dapm;
-
-	if (!dai) {
-		pr_err("%s: dai not found!!\n", __func__);
-		return -EINVAL;
-	}
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
-			GFP_KERNEL);
-
-	if (!dai_data) {
-		dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
-				AFE_PORT_ID_SPDIF_RX);
-		rc = -ENOMEM;
-	} else
-		dev_set_drvdata(dai->dev, dai_data);
-
-	kcontrol = &spdif_config_controls[1];
-	dapm = snd_soc_component_get_dapm(dai->component);
-
-	rc = snd_ctl_add(dai->component->card->snd_card,
-			snd_ctl_new1(kcontrol, dai_data));
-
-	memset(&intercon, 0, sizeof(intercon));
-	if (!rc && dai && dai->driver) {
-		if (dai->driver->playback.stream_name &&
-				dai->driver->playback.aif_name) {
-			dev_dbg(dai->dev, "%s: add route for widget %s",
-				__func__, dai->driver->playback.stream_name);
-			intercon.source = dai->driver->playback.aif_name;
-			intercon.sink = dai->driver->playback.stream_name;
-			dev_dbg(dai->dev, "%s: src %s sink %s\n",
-				__func__, intercon.source, intercon.sink);
-			snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		}
-		if (dai->driver->capture.stream_name &&
-				dai->driver->capture.aif_name) {
-			dev_dbg(dai->dev, "%s: add route for widget %s",
-				__func__, dai->driver->capture.stream_name);
-			intercon.sink = dai->driver->capture.aif_name;
-			intercon.source = dai->driver->capture.stream_name;
-			dev_dbg(dai->dev, "%s: src %s sink %s\n",
-				__func__, intercon.source, intercon.sink);
-			snd_soc_dapm_add_routes(dapm, &intercon, 1);
-		}
-	}
-	return rc;
-}
-
-static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_spdif_dai_data *dai_data;
-	int rc;
-
-	dai_data = dev_get_drvdata(dai->dev);
-
-	/* If AFE port is still up, close it */
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_close(dai->id); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AFE port\n");
-
-		clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-	}
-	kfree(dai_data);
-
-	return 0;
-}
-
-
-static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
-	.prepare	= msm_dai_q6_spdif_prepare,
-	.hw_params	= msm_dai_q6_spdif_hw_params,
-	.shutdown	= msm_dai_q6_spdif_shutdown,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai = {
-	.playback = {
-		.stream_name = "SPDIF Playback",
-		.aif_name = "SPDIF_RX",
-		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
-		.channels_min = 1,
-		.channels_max = 4,
-		.rate_min = 8000,
-		.rate_max = 48000,
-	},
-	.ops = &msm_dai_q6_spdif_ops,
-	.probe = msm_dai_q6_spdif_dai_probe,
-	.remove = msm_dai_q6_spdif_dai_remove,
-};
-
-static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
-	.name		= "msm-dai-q6-spdif",
-};
-
-static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		if (dai_data->enc_config.format != ENC_FMT_NONE) {
-			int bitwidth = 0;
-
-			if (dai_data->afe_in_bitformat ==
-			    SNDRV_PCM_FORMAT_S24_LE)
-				bitwidth = 24;
-			else if (dai_data->afe_in_bitformat ==
-				 SNDRV_PCM_FORMAT_S16_LE)
-				bitwidth = 16;
-			pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
-				 __func__, dai_data->enc_config.format);
-			rc = afe_port_start_v2(dai->id, &dai_data->port_config,
-					       dai_data->rate,
-					       dai_data->afe_in_channels,
-					       bitwidth,
-					       &dai_data->enc_config);
-			if (rc < 0)
-				pr_err("%s: afe_port_start_v2 failed error: %d\n",
-					__func__, rc);
-		} else {
-			rc = afe_port_start(dai->id, &dai_data->port_config,
-						dai_data->rate);
-		}
-		if (rc < 0)
-			dev_err(dai->dev, "fail to open AFE port 0x%x\n",
-				dai->id);
-		else
-			set_bit(STATUS_PORT_STARTED,
-				dai_data->status_mask);
-	}
-	return rc;
-}
-
-static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
-				    struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	switch (dai_data->channels) {
-	case 2:
-		dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
-		break;
-	case 1:
-		dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
-		break;
-	default:
-		return -EINVAL;
-		pr_err("%s: err channels %d\n",
-			__func__, dai_data->channels);
-		break;
-	}
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-	case SNDRV_PCM_FORMAT_SPECIAL:
-		dai_data->port_config.i2s.bit_width = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->port_config.i2s.bit_width = 24;
-		break;
-	default:
-		pr_err("%s: format %d\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	dai_data->rate = params_rate(params);
-	dai_data->port_config.i2s.sample_rate = dai_data->rate;
-	dai_data->port_config.i2s.i2s_cfg_minor_version =
-						AFE_API_VERSION_I2S_CONFIG;
-	dai_data->port_config.i2s.data_format =  AFE_LINEAR_PCM_DATA;
-	dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
-	dai_data->channels, dai_data->rate);
-
-	dai_data->port_config.i2s.channel_mode = 1;
-	return 0;
-}
-
-static u8 num_of_bits_set(u8 sd_line_mask)
-{
-	u8 num_bits_set = 0;
-
-	while (sd_line_mask) {
-		num_bits_set++;
-		sd_line_mask = sd_line_mask & (sd_line_mask - 1);
-	}
-	return num_bits_set;
-}
-
-static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
-				    struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	struct msm_i2s_data *i2s_pdata =
-			(struct msm_i2s_data *) dai->dev->platform_data;
-
-	dai_data->channels = params_channels(params);
-	if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
-		switch (dai_data->channels) {
-		case 2:
-			dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
-			break;
-		case 1:
-			dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
-			break;
-		default:
-			pr_warn("%s: greater than stereo has not been validated %d",
-				__func__, dai_data->channels);
-			break;
-		}
-	}
-	dai_data->rate = params_rate(params);
-	dai_data->port_config.i2s.sample_rate = dai_data->rate;
-	dai_data->port_config.i2s.i2s_cfg_minor_version =
-						AFE_API_VERSION_I2S_CONFIG;
-	dai_data->port_config.i2s.data_format =  AFE_LINEAR_PCM_DATA;
-	/* Q6 only supports 16 as now */
-	dai_data->port_config.i2s.bit_width = 16;
-	dai_data->port_config.i2s.channel_mode = 1;
-
-	return 0;
-}
-
-static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
-				    struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-	case SNDRV_PCM_FORMAT_SPECIAL:
-		dai_data->port_config.slim_sch.bit_width = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->port_config.slim_sch.bit_width = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		dai_data->port_config.slim_sch.bit_width = 32;
-		break;
-	default:
-		pr_err("%s: format %d\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	dai_data->port_config.slim_sch.sb_cfg_minor_version =
-				AFE_API_VERSION_SLIMBUS_CONFIG;
-	dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
-	dai_data->port_config.slim_sch.num_channels = dai_data->channels;
-
-	switch (dai->id) {
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-		dai_data->port_config.slim_sch.slimbus_dev_id =
-			AFE_SLIMBUS_DEVICE_2;
-		break;
-	default:
-		dai_data->port_config.slim_sch.slimbus_dev_id =
-			AFE_SLIMBUS_DEVICE_1;
-		break;
-	}
-
-	dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
-		"num_channel %hu  shared_ch_mapping[0]  %hu\n"
-		"slave_port_mapping[1]  %hu slave_port_mapping[2]  %hu\n"
-		"sample_rate %d\n", __func__,
-		dai_data->port_config.slim_sch.slimbus_dev_id,
-		dai_data->port_config.slim_sch.bit_width,
-		dai_data->port_config.slim_sch.data_format,
-		dai_data->port_config.slim_sch.num_channels,
-		dai_data->port_config.slim_sch.shared_ch_mapping[0],
-		dai_data->port_config.slim_sch.shared_ch_mapping[1],
-		dai_data->port_config.slim_sch.shared_ch_mapping[2],
-		dai_data->rate);
-
-	return 0;
-}
-
-static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
-					  struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-	case SNDRV_PCM_FORMAT_SPECIAL:
-		dai_data->port_config.usb_audio.bit_width = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->port_config.usb_audio.bit_width = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		dai_data->port_config.usb_audio.bit_width = 32;
-		break;
-
-	default:
-		dev_err(dai->dev, "%s: invalid format %d\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-	dai_data->port_config.usb_audio.cfg_minor_version =
-					AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
-	dai_data->port_config.usb_audio.num_channels = dai_data->channels;
-	dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
-
-	dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
-		"num_channel %hu  sample_rate %d\n", __func__,
-		dai_data->port_config.usb_audio.dev_token,
-		dai_data->port_config.usb_audio.bit_width,
-		dai_data->port_config.usb_audio.data_format,
-		dai_data->port_config.usb_audio.num_channels,
-		dai_data->port_config.usb_audio.sample_rate);
-
-	return 0;
-}
-
-static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
-		dai_data->channels, dai_data->rate);
-
-	memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
-
-	pr_debug("%s: setting bt_fm parameters\n", __func__);
-
-	dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
-					AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
-	dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
-	dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
-	dai_data->port_config.int_bt_fm.bit_width = 16;
-
-	return 0;
-}
-
-static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->rate = params_rate(params);
-	dai_data->port_config.rtproxy.num_channels = params_channels(params);
-	dai_data->port_config.rtproxy.sample_rate = params_rate(params);
-
-	pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
-	dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
-
-	dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
-				AFE_API_VERSION_RT_PROXY_CONFIG;
-	dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
-	dai_data->port_config.rtproxy.interleaved = 1;
-	dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
-	dai_data->port_config.rtproxy.jitter_allowance =
-				dai_data->port_config.rtproxy.frame_size/2;
-	dai_data->port_config.rtproxy.low_water_mark = 0;
-	dai_data->port_config.rtproxy.high_water_mark = 0;
-
-	return 0;
-}
-
-static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
-				    struct snd_soc_dai *dai, int stream)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	/* Q6 only supports 16 as now */
-	dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
-				AFE_API_VERSION_PSEUDO_PORT_CONFIG;
-	dai_data->port_config.pseudo_port.num_channels =
-				params_channels(params);
-	dai_data->port_config.pseudo_port.bit_width = 16;
-	dai_data->port_config.pseudo_port.data_format = 0;
-	dai_data->port_config.pseudo_port.timing_mode =
-				AFE_PSEUDOPORT_TIMING_MODE_TIMER;
-	dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
-
-	dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
-		"timing Mode %hu sample_rate %d\n", __func__,
-		dai_data->port_config.pseudo_port.bit_width,
-		dai_data->port_config.pseudo_port.num_channels,
-		dai_data->port_config.pseudo_port.data_format,
-		dai_data->port_config.pseudo_port.timing_mode,
-		dai_data->port_config.pseudo_port.sample_rate);
-
-	return 0;
-}
-
-/* Current implementation assumes hw_param is called once
- * This may not be the case but what to do when ADM and AFE
- * port are already opened and parameter changes
- */
-static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	int rc = 0;
-
-	switch (dai->id) {
-	case PRIMARY_I2S_TX:
-	case PRIMARY_I2S_RX:
-	case SECONDARY_I2S_RX:
-		rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
-		break;
-	case MI2S_RX:
-		rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
-		break;
-	case SLIMBUS_0_RX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_TX:
-		rc = msm_dai_q6_slim_bus_hw_params(params, dai,
-				substream->stream);
-		break;
-	case INT_BT_SCO_RX:
-	case INT_BT_SCO_TX:
-	case INT_BT_A2DP_RX:
-	case INT_FM_RX:
-	case INT_FM_TX:
-		rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
-		break;
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-		rc = msm_dai_q6_usb_audio_hw_params(params, dai,
-						    substream->stream);
-		break;
-	case RT_PROXY_DAI_001_TX:
-	case RT_PROXY_DAI_001_RX:
-	case RT_PROXY_DAI_002_TX:
-	case RT_PROXY_DAI_002_RX:
-		rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
-		break;
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case VOICE_RECORD_RX:
-	case VOICE_RECORD_TX:
-		rc = msm_dai_q6_pseudo_port_hw_params(params,
-						dai, substream->stream);
-		break;
-	default:
-		dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	int rc = 0;
-
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_debug("%s: stop pseudo port:%d\n", __func__,  dai->id);
-		rc = afe_close(dai->id); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AFE port\n");
-		pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
-			*dai_data->status_mask);
-		clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-	}
-}
-
-static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBS_CFS:
-		dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
-		break;
-	case SND_SOC_DAIFMT_CBM_CFM:
-		dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
-		break;
-	default:
-		pr_err("%s: fmt 0x%x\n",
-			__func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
-	int rc = 0;
-
-	dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
-							dai->id, fmt);
-	switch (dai->id) {
-	case PRIMARY_I2S_TX:
-	case PRIMARY_I2S_RX:
-	case MI2S_RX:
-	case SECONDARY_I2S_RX:
-		rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
-		break;
-	default:
-		dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
-				unsigned int tx_num, unsigned int *tx_slot,
-				unsigned int rx_num, unsigned int *rx_slot)
-
-{
-	int rc = 0;
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-	unsigned int i = 0;
-
-	dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
-	switch (dai->id) {
-	case SLIMBUS_0_RX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_8_RX:
-		/*
-		 * channel number to be between 128 and 255.
-		 * For RX port use channel numbers
-		 * from 138 to 144 for pre-Taiko
-		 * from 144 to 159 for Taiko
-		 */
-		if (!rx_slot) {
-			pr_err("%s: rx slot not found\n", __func__);
-			return -EINVAL;
-		}
-		if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
-			pr_err("%s: invalid rx num %d\n", __func__, rx_num);
-			return -EINVAL;
-		}
-
-		for (i = 0; i < rx_num; i++) {
-			dai_data->port_config.slim_sch.shared_ch_mapping[i] =
-			    rx_slot[i];
-			pr_debug("%s: find number of channels[%d] ch[%d]\n",
-			       __func__, i, rx_slot[i]);
-		}
-		dai_data->port_config.slim_sch.num_channels = rx_num;
-		pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
-			(dai->id - SLIMBUS_0_RX) / 2, rx_num,
-			dai_data->port_config.slim_sch.shared_ch_mapping[0],
-			dai_data->port_config.slim_sch.shared_ch_mapping[1]);
-
-		break;
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_TX:
-		/*
-		 * channel number to be between 128 and 255.
-		 * For TX port use channel numbers
-		 * from 128 to 137 for pre-Taiko
-		 * from 128 to 143 for Taiko
-		 */
-		if (!tx_slot) {
-			pr_err("%s: tx slot not found\n", __func__);
-			return -EINVAL;
-		}
-		if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
-			pr_err("%s: invalid tx num %d\n", __func__, tx_num);
-			return -EINVAL;
-		}
-
-		for (i = 0; i < tx_num; i++) {
-			dai_data->port_config.slim_sch.shared_ch_mapping[i] =
-			    tx_slot[i];
-			pr_debug("%s: find number of channels[%d] ch[%d]\n",
-				 __func__, i, tx_slot[i]);
-		}
-		dai_data->port_config.slim_sch.num_channels = tx_num;
-		pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
-			(dai->id - SLIMBUS_0_TX) / 2, tx_num,
-			dai_data->port_config.slim_sch.shared_ch_mapping[0],
-			dai_data->port_config.slim_sch.shared_ch_mapping[1]);
-		break;
-	default:
-		dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_ops = {
-	.prepare	= msm_dai_q6_prepare,
-	.hw_params	= msm_dai_q6_hw_params,
-	.shutdown	= msm_dai_q6_shutdown,
-	.set_fmt	= msm_dai_q6_set_fmt,
-	.set_channel_map = msm_dai_q6_set_channel_map,
-};
-
-/*
- * For single CPU DAI registration, the dai id needs to be
- * set explicitly in the dai probe as ASoC does not read
- * the cpu->driver->id field rather it assigns the dai id
- * from the device name that is in the form %s.%d. This dai
- * id should be assigned to back-end AFE port id and used
- * during dai prepare. For multiple dai registration, it
- * is not required to call this function, however the dai->
- * driver->id field must be defined and set to corresponding
- * AFE Port id.
- */
-static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
-{
-	if (!dai->driver->id) {
-		dev_warn(dai->dev, "DAI driver id is not set\n");
-		return;
-	}
-	dai->id = dai->driver->id;
-}
-
-static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	u16 port_id = ((struct soc_enum *)
-					kcontrol->private_value)->reg;
-
-	dai_data->cal_mode = ucontrol->value.integer.value[0];
-	pr_debug("%s: setting cal_mode to %d\n",
-		__func__, dai_data->cal_mode);
-	afe_set_cal_mode(port_id, dai_data->cal_mode);
-
-	return 0;
-}
-
-static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] = dai_data->cal_mode;
-	return 0;
-}
-
-static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	if (dai_data) {
-		dai_data->port_config.slim_sch.data_format = value;
-		pr_debug("%s: format = %d\n",  __func__, value);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data)
-		ucontrol->value.integer.value[0] =
-			dai_data->port_config.slim_sch.data_format;
-
-	return 0;
-}
-
-static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	u32 val = ucontrol->value.integer.value[0];
-
-	if (dai_data) {
-		dai_data->port_config.usb_audio.dev_token = val;
-		pr_debug("%s: dev_token = 0x%x\n",  __func__,
-				 dai_data->port_config.usb_audio.dev_token);
-	} else {
-		pr_err("%s: dai_data is NULL\n", __func__);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		ucontrol->value.integer.value[0] =
-			 dai_data->port_config.usb_audio.dev_token;
-		pr_debug("%s: dev_token = 0x%x\n",  __func__,
-				 dai_data->port_config.usb_audio.dev_token);
-	} else {
-		pr_err("%s: dai_data is NULL\n", __func__);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	u32 val = ucontrol->value.integer.value[0];
-
-	if (dai_data) {
-		dai_data->port_config.usb_audio.endian = val;
-		pr_debug("%s: endian = 0x%x\n",  __func__,
-				 dai_data->port_config.usb_audio.endian);
-	} else {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		ucontrol->value.integer.value[0] =
-			 dai_data->port_config.usb_audio.endian;
-		pr_debug("%s: endian = 0x%x\n",  __func__,
-				 dai_data->port_config.usb_audio.endian);
-	} else {
-		pr_err("%s: dai_data is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int  msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(struct afe_enc_config);
-
-	return 0;
-}
-
-static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		int format_size = sizeof(dai_data->enc_config.format);
-
-		pr_debug("%s:encoder config for %d format\n",
-			 __func__, dai_data->enc_config.format);
-		memcpy(ucontrol->value.bytes.data,
-			&dai_data->enc_config.format,
-			format_size);
-		switch (dai_data->enc_config.format) {
-		case ENC_FMT_SBC:
-			memcpy(ucontrol->value.bytes.data + format_size,
-				&dai_data->enc_config.data,
-				sizeof(struct asm_sbc_enc_cfg_t));
-			break;
-		case ENC_FMT_AAC_V2:
-			memcpy(ucontrol->value.bytes.data + format_size,
-				&dai_data->enc_config.data,
-				sizeof(struct asm_aac_enc_cfg_v2_t));
-			break;
-		case ENC_FMT_APTX:
-		case ENC_FMT_APTX_HD:
-			memcpy(ucontrol->value.bytes.data + format_size,
-				&dai_data->enc_config.data,
-				sizeof(struct asm_aac_enc_cfg_v2_t));
-			break;
-		default:
-			pr_debug("%s: unknown format = %d\n",
-				 __func__, dai_data->enc_config.format);
-			ret = -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		int format_size = sizeof(dai_data->enc_config.format);
-
-		memset(&dai_data->enc_config, 0x0,
-			sizeof(struct afe_enc_config));
-		memcpy(&dai_data->enc_config.format,
-			ucontrol->value.bytes.data,
-			format_size);
-		pr_debug("%s: Received encoder config for %d format\n",
-			 __func__, dai_data->enc_config.format);
-		switch (dai_data->enc_config.format) {
-		case ENC_FMT_SBC:
-			memcpy(&dai_data->enc_config.data,
-				ucontrol->value.bytes.data + format_size,
-				sizeof(struct asm_sbc_enc_cfg_t));
-			break;
-		case ENC_FMT_AAC_V2:
-			memcpy(&dai_data->enc_config.data,
-				ucontrol->value.bytes.data + format_size,
-				sizeof(struct asm_aac_enc_cfg_v2_t));
-			break;
-		case ENC_FMT_APTX:
-		case ENC_FMT_APTX_HD:
-			memcpy(&dai_data->enc_config.data,
-				ucontrol->value.bytes.data + format_size,
-				sizeof(struct asm_custom_enc_cfg_aptx_t));
-			break;
-		default:
-			pr_debug("%s: Ignore enc config for unknown format = %d\n",
-				 __func__, dai_data->enc_config.format);
-			ret = -EINVAL;
-			break;
-		}
-	} else
-		ret = -EINVAL;
-
-	return ret;
-}
-
-static const char *const afe_input_chs_text[] = {"Zero", "One", "Two"};
-
-static const struct soc_enum afe_input_chs_enum[] = {
-	SOC_ENUM_SINGLE_EXT(3, afe_input_chs_text),
-};
-
-static const char *const afe_input_bit_format_text[] = {"S16_LE", "S24_LE"};
-
-static const struct soc_enum afe_input_bit_format_enum[] = {
-	SOC_ENUM_SINGLE_EXT(2, afe_input_bit_format_text),
-};
-
-static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		ucontrol->value.integer.value[0] = dai_data->afe_in_channels;
-		pr_debug("%s:afe input channel = %d\n",
-			  __func__, dai_data->afe_in_channels);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (dai_data) {
-		dai_data->afe_in_channels = ucontrol->value.integer.value[0];
-		pr_debug("%s: updating afe input channel : %d\n",
-			__func__, dai_data->afe_in_channels);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_afe_input_bit_format_get(
-			struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (!dai_data) {
-		pr_err("%s: Invalid dai data\n", __func__);
-		return -EINVAL;
-	}
-
-	switch (dai_data->afe_in_bitformat) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: afe input bit format : %ld\n",
-		  __func__, ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_dai_q6_afe_input_bit_format_put(
-			struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	if (!dai_data) {
-		pr_err("%s: Invalid dai data\n", __func__);
-		return -EINVAL;
-	}
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: updating afe input bit format : %d\n",
-		__func__, dai_data->afe_in_bitformat);
-
-	return 0;
-}
-
-
-static const struct snd_kcontrol_new afe_enc_config_controls[] = {
-	{
-		.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
-			   SNDRV_CTL_ELEM_ACCESS_INACTIVE),
-		.iface = SNDRV_CTL_ELEM_IFACE_PCM,
-		.name = "SLIM_7_RX Encoder Config",
-		.info = msm_dai_q6_afe_enc_cfg_info,
-		.get = msm_dai_q6_afe_enc_cfg_get,
-		.put = msm_dai_q6_afe_enc_cfg_put,
-	},
-	SOC_ENUM_EXT("AFE Input Channels", afe_input_chs_enum[0],
-		     msm_dai_q6_afe_input_channel_get,
-		     msm_dai_q6_afe_input_channel_put),
-	SOC_ENUM_EXT("AFE Input Bit Format", afe_input_bit_format_enum[0],
-		     msm_dai_q6_afe_input_bit_format_get,
-		     msm_dai_q6_afe_input_bit_format_put),
-};
-
-static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
-
-	return 0;
-}
-
-static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = -EINVAL;
-	struct afe_param_id_dev_timing_stats timing_stats;
-	struct snd_soc_dai *dai = kcontrol->private_data;
-	struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_err("%s: afe port not started. dai_data->status_mask = %ld\n",
-			__func__, *dai_data->status_mask);
-		goto done;
-	}
-
-	memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
-	ret = afe_get_av_dev_drift(&timing_stats, dai->id);
-	if (ret) {
-		pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
-			__func__, dai->id, ret);
-
-		goto done;
-	}
-
-	memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
-			sizeof(struct afe_param_id_dev_timing_stats));
-done:
-	return ret;
-}
-
-static const char * const afe_cal_mode_text[] = {
-	"CAL_MODE_DEFAULT", "CAL_MODE_NONE"
-};
-
-static const struct soc_enum slim_2_rx_enum =
-	SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
-			afe_cal_mode_text);
-
-static const struct soc_enum rt_proxy_1_rx_enum =
-	SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
-			afe_cal_mode_text);
-
-static const struct soc_enum rt_proxy_1_tx_enum =
-	SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
-			afe_cal_mode_text);
-
-static const struct snd_kcontrol_new sb_config_controls[] = {
-	SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
-		     msm_dai_q6_sb_format_get,
-		     msm_dai_q6_sb_format_put),
-	SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
-		     msm_dai_q6_cal_info_get,
-		     msm_dai_q6_cal_info_put),
-	SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
-		     msm_dai_q6_sb_format_get,
-		     msm_dai_q6_sb_format_put)
-};
-
-static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
-	SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
-		     msm_dai_q6_cal_info_get,
-		     msm_dai_q6_cal_info_put),
-	SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
-		     msm_dai_q6_cal_info_get,
-		     msm_dai_q6_cal_info_put),
-};
-
-static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
-	SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
-			msm_dai_q6_usb_audio_cfg_get,
-			msm_dai_q6_usb_audio_cfg_put),
-	SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
-			msm_dai_q6_usb_audio_endian_cfg_get,
-			msm_dai_q6_usb_audio_endian_cfg_put),
-	SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
-			msm_dai_q6_usb_audio_cfg_get,
-			msm_dai_q6_usb_audio_cfg_put),
-	SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
-			msm_dai_q6_usb_audio_endian_cfg_get,
-			msm_dai_q6_usb_audio_endian_cfg_put),
-};
-
-static const struct snd_kcontrol_new avd_drift_config_controls[] = {
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_PCM,
-		.name	= "SLIMBUS_0_RX DRIFT",
-		.info	= msm_dai_q6_slim_rx_drift_info,
-		.get	= msm_dai_q6_slim_rx_drift_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_PCM,
-		.name	= "SLIMBUS_6_RX DRIFT",
-		.info	= msm_dai_q6_slim_rx_drift_info,
-		.get	= msm_dai_q6_slim_rx_drift_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_PCM,
-		.name	= "SLIMBUS_7_RX DRIFT",
-		.info	= msm_dai_q6_slim_rx_drift_info,
-		.get	= msm_dai_q6_slim_rx_drift_get,
-	},
-};
-static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_dai_data *dai_data;
-	int rc = 0;
-
-	if (!dai) {
-		pr_err("%s: Invalid params dai\n", __func__);
-		return -EINVAL;
-	}
-	if (!dai->dev) {
-		pr_err("%s: Invalid params dai dev\n", __func__);
-		return -EINVAL;
-	}
-
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
-
-	if (!dai_data)
-		rc = -ENOMEM;
-	else
-		dev_set_drvdata(dai->dev, dai_data);
-
-	msm_dai_q6_set_dai_id(dai);
-
-	switch (dai->id) {
-	case SLIMBUS_4_TX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&sb_config_controls[0],
-				 dai_data));
-		break;
-	case SLIMBUS_2_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&sb_config_controls[1],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&sb_config_controls[2],
-				 dai_data));
-		break;
-	case SLIMBUS_7_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&afe_enc_config_controls[0],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&afe_enc_config_controls[1],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&afe_enc_config_controls[2],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(&avd_drift_config_controls[2],
-					dai));
-		break;
-	case RT_PROXY_DAI_001_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&rt_proxy_config_controls[0],
-				 dai_data));
-		break;
-	case RT_PROXY_DAI_001_TX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&rt_proxy_config_controls[1],
-				 dai_data));
-		break;
-	case AFE_PORT_ID_USB_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&usb_audio_cfg_controls[0],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&usb_audio_cfg_controls[1],
-				 dai_data));
-		break;
-	case AFE_PORT_ID_USB_TX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&usb_audio_cfg_controls[2],
-				 dai_data));
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 snd_ctl_new1(&usb_audio_cfg_controls[3],
-				 dai_data));
-		break;
-	case SLIMBUS_0_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(&avd_drift_config_controls[0],
-					dai));
-		break;
-	case SLIMBUS_6_RX:
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(&avd_drift_config_controls[1],
-					dai));
-		break;
-	}
-	if (rc < 0)
-		dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
-			__func__, dai->name);
-
-	rc = msm_dai_q6_dai_add_route(dai);
-	return rc;
-}
-
-static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_dai_data *dai_data;
-	int rc;
-
-	dai_data = dev_get_drvdata(dai->dev);
-
-	/* If AFE port is still up, close it */
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		pr_debug("%s: stop pseudo port:%d\n", __func__,  dai->id);
-		rc = afe_close(dai->id); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AFE port\n");
-		clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-	}
-	kfree(dai_data);
-
-	return 0;
-}
-
-static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
-	{
-		.playback = {
-			.stream_name = "AFE Playback",
-			.aif_name = "PCM_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-			SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = RT_PROXY_DAI_001_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			 .stream_name = "AFE-PROXY RX",
-			 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			 SNDRV_PCM_RATE_16000,
-			 .formats = SNDRV_PCM_FMTBIT_S16_LE |
-			 SNDRV_PCM_FMTBIT_S24_LE,
-			 .channels_min = 1,
-			 .channels_max = 2,
-			 .rate_min =     8000,
-			 .rate_max =	48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = RT_PROXY_DAI_002_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
-	{
-		.capture = {
-			.stream_name = "AFE Capture",
-			.aif_name = "PCM_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = RT_PROXY_DAI_002_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "AFE-PROXY TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min =     8000,
-			.rate_max =	48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = RT_PROXY_DAI_001_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
-	.playback = {
-		.stream_name = "Internal BT-SCO Playback",
-		.aif_name = "INT_BT_SCO_RX",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 1,
-		.channels_max = 1,
-		.rate_max = 16000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = INT_BT_SCO_RX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
-	.playback = {
-		.stream_name = "Internal BT-A2DP Playback",
-		.aif_name = "INT_BT_A2DP_RX",
-		.rates = SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 1,
-		.channels_max = 2,
-		.rate_max = 48000,
-		.rate_min = 48000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = INT_BT_A2DP_RX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
-	.capture = {
-		.stream_name = "Internal BT-SCO Capture",
-		.aif_name = "INT_BT_SCO_TX",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 1,
-		.channels_max = 1,
-		.rate_max = 16000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = INT_BT_SCO_TX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
-	.playback = {
-		.stream_name = "Internal FM Playback",
-		.aif_name = "INT_FM_RX",
-		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-		SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 2,
-		.channels_max = 2,
-		.rate_max = 48000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = INT_FM_RX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
-	.capture = {
-		.stream_name = "Internal FM Capture",
-		.aif_name = "INT_FM_TX",
-		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-		SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 2,
-		.channels_max = 2,
-		.rate_max = 48000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = INT_FM_TX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
-	{
-		.playback = {
-			.stream_name = "Voice Farend Playback",
-			.aif_name = "VOICE_PLAYBACK_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				 SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = VOICE_PLAYBACK_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Voice2 Farend Playback",
-			.aif_name = "VOICE2_PLAYBACK_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				 SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = VOICE2_PLAYBACK_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
-	{
-		.capture = {
-			.stream_name = "Voice Uplink Capture",
-			.aif_name = "INCALL_RECORD_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = VOICE_RECORD_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Voice Downlink Capture",
-			.aif_name = "INCALL_RECORD_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = VOICE_RECORD_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
-	.playback = {
-		.stream_name = "USB Audio Playback",
-		.aif_name = "USB_AUDIO_RX",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-			 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-			 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-			 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-			 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-			 SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
-			 SNDRV_PCM_RATE_384000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
-			   SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
-		.channels_min = 1,
-		.channels_max = 8,
-		.rate_max = 384000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = AFE_PORT_ID_USB_RX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
-	.capture = {
-		.stream_name = "USB Audio Capture",
-		.aif_name = "USB_AUDIO_TX",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-			 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-			 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-			 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
-			 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
-			 SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
-			 SNDRV_PCM_RATE_384000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
-			   SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
-		.channels_min = 1,
-		.channels_max = 8,
-		.rate_max = 384000,
-		.rate_min = 8000,
-	},
-	.ops = &msm_dai_q6_ops,
-	.id = AFE_PORT_ID_USB_TX,
-	.probe = msm_dai_q6_dai_probe,
-	.remove = msm_dai_q6_dai_remove,
-};
-
-static int msm_auxpcm_dev_probe(struct platform_device *pdev)
-{
-	struct msm_dai_q6_auxpcm_dai_data *dai_data;
-	struct msm_dai_auxpcm_pdata *auxpcm_pdata;
-	uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
-	uint32_t val = 0;
-	const char *intf_name;
-	int rc = 0, i = 0, len = 0;
-	const uint32_t *slot_mapping_array = NULL;
-	u32 array_length = 0;
-
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
-			   GFP_KERNEL);
-	if (!dai_data)
-		return -ENOMEM;
-
-	auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
-				GFP_KERNEL);
-
-	if (!auxpcm_pdata) {
-		dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
-		goto fail_pdata_nomem;
-	}
-
-	dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
-		__func__, &pdev->dev, dai_data, auxpcm_pdata);
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-mode",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-sync",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-frame",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-quant",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-num-slots",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
-
-	if (auxpcm_pdata->mode_8k.num_slots >
-	    msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
-		dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
-			 __func__,
-			msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
-			auxpcm_pdata->mode_8k.num_slots);
-		rc = -EINVAL;
-		goto fail_invalid_dt;
-	}
-	auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
-
-	if (auxpcm_pdata->mode_16k.num_slots >
-	    msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
-		dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
-			__func__,
-			msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
-			auxpcm_pdata->mode_16k.num_slots);
-		rc = -EINVAL;
-		goto fail_invalid_dt;
-	}
-
-	slot_mapping_array = of_get_property(pdev->dev.of_node,
-				"qcom,msm-cpudai-auxpcm-slot-mapping", &len);
-
-	if (slot_mapping_array == NULL) {
-		dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
-			__func__);
-		rc = -EINVAL;
-		goto fail_invalid_dt;
-	}
-
-	array_length = auxpcm_pdata->mode_8k.num_slots +
-		       auxpcm_pdata->mode_16k.num_slots;
-
-	if (len != sizeof(uint32_t) * array_length) {
-		dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
-			__func__, len, sizeof(uint32_t) * array_length);
-		rc = -EINVAL;
-		goto fail_invalid_dt;
-	}
-
-	auxpcm_pdata->mode_8k.slot_mapping =
-					kzalloc(sizeof(uint16_t) *
-					    auxpcm_pdata->mode_8k.num_slots,
-					    GFP_KERNEL);
-	if (!auxpcm_pdata->mode_8k.slot_mapping) {
-		dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
-			__func__);
-		rc = -ENOMEM;
-		goto fail_invalid_dt;
-	}
-
-	for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
-		auxpcm_pdata->mode_8k.slot_mapping[i] =
-				(u16)be32_to_cpu(slot_mapping_array[i]);
-
-	auxpcm_pdata->mode_16k.slot_mapping =
-					kzalloc(sizeof(uint16_t) *
-					     auxpcm_pdata->mode_16k.num_slots,
-					     GFP_KERNEL);
-
-	if (!auxpcm_pdata->mode_16k.slot_mapping) {
-		dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
-			__func__);
-		rc = -ENOMEM;
-		goto fail_invalid_16k_slot_mapping;
-	}
-
-	for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
-		auxpcm_pdata->mode_16k.slot_mapping[i] =
-			(u16)be32_to_cpu(slot_mapping_array[i +
-					auxpcm_pdata->mode_8k.num_slots]);
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-data",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
-			__func__);
-		goto fail_invalid_dt1;
-	}
-	auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
-
-	rc = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-cpudai-auxpcm-pcm-clk-rate",
-			val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
-			__func__);
-		goto fail_invalid_dt1;
-	}
-	auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
-	auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
-
-	rc = of_property_read_string(pdev->dev.of_node,
-			"qcom,msm-auxpcm-interface", &intf_name);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: qcom,msm-auxpcm-interface missing in DT node\n",
-			__func__);
-		goto fail_nodev_intf;
-	}
-
-	if (!strcmp(intf_name, "primary")) {
-		dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
-		dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
-		pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
-		i = 0;
-	} else if (!strcmp(intf_name, "secondary")) {
-		dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
-		dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
-		pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
-		i = 1;
-	} else if (!strcmp(intf_name, "tertiary")) {
-		dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
-		dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
-		pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
-		i = 2;
-	} else if (!strcmp(intf_name, "quaternary")) {
-		dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
-		dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
-		pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
-		i = 3;
-	} else {
-		dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
-			__func__, intf_name);
-		goto fail_invalid_intf;
-	}
-	rc = of_property_read_u32(pdev->dev.of_node,
-				  "qcom,msm-cpudai-afe-clk-ver", &val);
-	if (rc)
-		dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
-	else
-		dai_data->afe_clk_ver = val;
-
-	mutex_init(&dai_data->rlock);
-	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
-
-	dev_set_drvdata(&pdev->dev, dai_data);
-	pdev->dev.platform_data = (void *) auxpcm_pdata;
-
-	rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_aux_pcm_dai_component,
-			&msm_dai_q6_aux_pcm_dai[i], 1);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
-				__func__, rc);
-		goto fail_reg_dai;
-	}
-
-	return rc;
-
-fail_reg_dai:
-fail_invalid_intf:
-fail_nodev_intf:
-fail_invalid_dt1:
-	kfree(auxpcm_pdata->mode_16k.slot_mapping);
-fail_invalid_16k_slot_mapping:
-	kfree(auxpcm_pdata->mode_8k.slot_mapping);
-fail_invalid_dt:
-	kfree(auxpcm_pdata);
-fail_pdata_nomem:
-	kfree(dai_data);
-	return rc;
-}
-
-static int msm_auxpcm_dev_remove(struct platform_device *pdev)
-{
-	struct msm_dai_q6_auxpcm_dai_data *dai_data;
-
-	dai_data = dev_get_drvdata(&pdev->dev);
-
-	snd_soc_unregister_component(&pdev->dev);
-
-	mutex_destroy(&dai_data->rlock);
-	kfree(dai_data);
-	kfree(pdev->dev.platform_data);
-
-	return 0;
-}
-
-static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
-	{ .compatible = "qcom,msm-auxpcm-dev", },
-	{}
-};
-
-
-static struct platform_driver msm_auxpcm_dev_driver = {
-	.probe  = msm_auxpcm_dev_probe,
-	.remove = msm_auxpcm_dev_remove,
-	.driver = {
-		.name = "msm-auxpcm-dev",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_auxpcm_dev_dt_match,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
-	{
-		.playback = {
-			.stream_name = "Slimbus Playback",
-			.aif_name = "SLIMBUS_0_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_0_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus1 Playback",
-			.aif_name = "SLIMBUS_1_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_1_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus2 Playback",
-			.aif_name = "SLIMBUS_2_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_2_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus3 Playback",
-			.aif_name = "SLIMBUS_3_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_3_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus4 Playback",
-			.aif_name = "SLIMBUS_4_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_4_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus6 Playback",
-			.aif_name = "SLIMBUS_6_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_6_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus5 Playback",
-			.aif_name = "SLIMBUS_5_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_5_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus7 Playback",
-			.aif_name = "SLIMBUS_7_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_7_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Slimbus8 Playback",
-			.aif_name = "SLIMBUS_8_RX",
-			.rates = SNDRV_PCM_RATE_8000_384000,
-			.formats = DAI_FORMATS_S16_S24_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 384000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_8_RX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
-	{
-		.capture = {
-			.stream_name = "Slimbus Capture",
-			.aif_name = "SLIMBUS_0_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S24_3LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_0_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus1 Capture",
-			.aif_name = "SLIMBUS_1_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S24_3LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_1_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus2 Capture",
-			.aif_name = "SLIMBUS_2_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_2_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus3 Capture",
-			.aif_name = "SLIMBUS_3_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 2,
-			.channels_max = 4,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_3_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus4 Capture",
-			.aif_name = "SLIMBUS_4_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 2,
-			.channels_max = 4,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_4_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus5 Capture",
-			.aif_name = "SLIMBUS_5_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_5_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus6 Capture",
-			.aif_name = "SLIMBUS_6_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_6_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus7 Capture",
-			.aif_name = "SLIMBUS_7_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_7_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Slimbus8 Capture",
-			.aif_name = "SLIMBUS_8_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 192000,
-		},
-		.ops = &msm_dai_q6_ops,
-		.id = SLIMBUS_8_TX,
-		.probe = msm_dai_q6_dai_probe,
-		.remove = msm_dai_q6_dai_remove,
-	},
-};
-
-static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	dai_data->port_config.i2s.data_format = value;
-	pr_debug("%s: value = %d, channel = %d, line = %d\n",
-		 __func__, value, dai_data->port_config.i2s.mono_stereo,
-		 dai_data->port_config.i2s.channel_mode);
-	return 0;
-}
-
-static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] =
-		dai_data->port_config.i2s.data_format;
-	return 0;
-}
-
-static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	dai_data->vi_feed_mono = value;
-	pr_debug("%s: value = %d\n", __func__, value);
-	return 0;
-}
-
-static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
-	return 0;
-}
-
-static const struct snd_kcontrol_new mi2s_config_controls[] = {
-	SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-	SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
-		     msm_dai_q6_mi2s_format_get,
-		     msm_dai_q6_mi2s_format_put),
-};
-
-static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
-	SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
-		     msm_dai_q6_mi2s_vi_feed_mono_get,
-		     msm_dai_q6_mi2s_vi_feed_mono_put),
-};
-
-static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-			dev_get_drvdata(dai->dev);
-	struct msm_mi2s_pdata *mi2s_pdata =
-			(struct msm_mi2s_pdata *) dai->dev->platform_data;
-	struct snd_kcontrol *kcontrol = NULL;
-	int rc = 0;
-	const struct snd_kcontrol_new *ctrl = NULL;
-	const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
-
-	dai->id = mi2s_pdata->intf_id;
-
-	if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
-		if (dai->id == MSM_PRIM_MI2S)
-			ctrl = &mi2s_config_controls[0];
-		if (dai->id == MSM_SEC_MI2S)
-			ctrl = &mi2s_config_controls[1];
-		if (dai->id == MSM_TERT_MI2S)
-			ctrl = &mi2s_config_controls[2];
-		if (dai->id == MSM_QUAT_MI2S)
-			ctrl = &mi2s_config_controls[3];
-		if (dai->id == MSM_QUIN_MI2S)
-			ctrl = &mi2s_config_controls[4];
-	}
-
-	if (ctrl) {
-		kcontrol = snd_ctl_new1(ctrl,
-					&mi2s_dai_data->rx_dai.mi2s_dai_data);
-		rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
-		if (rc < 0) {
-			dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
-				__func__, dai->name);
-			goto rtn;
-		}
-	}
-
-	ctrl = NULL;
-	if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
-		if (dai->id == MSM_PRIM_MI2S)
-			ctrl = &mi2s_config_controls[4];
-		if (dai->id == MSM_SEC_MI2S)
-			ctrl = &mi2s_config_controls[5];
-		if (dai->id == MSM_TERT_MI2S)
-			ctrl = &mi2s_config_controls[6];
-		if (dai->id == MSM_QUAT_MI2S)
-			ctrl = &mi2s_config_controls[7];
-		if (dai->id == MSM_QUIN_MI2S)
-			ctrl = &mi2s_config_controls[9];
-		if (dai->id == MSM_SENARY_MI2S)
-			ctrl = &mi2s_config_controls[10];
-		if (dai->id == MSM_INT5_MI2S)
-			ctrl = &mi2s_config_controls[11];
-	}
-
-	if (ctrl) {
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(ctrl,
-				&mi2s_dai_data->tx_dai.mi2s_dai_data));
-		if (rc < 0) {
-			if (kcontrol)
-				snd_ctl_remove(dai->component->card->snd_card,
-						kcontrol);
-			dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
-				__func__, dai->name);
-		}
-	}
-
-	if (dai->id == MSM_INT5_MI2S)
-		vi_feed_ctrl = &mi2s_vi_feed_controls[0];
-
-	if (vi_feed_ctrl) {
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				snd_ctl_new1(vi_feed_ctrl,
-				&mi2s_dai_data->tx_dai.mi2s_dai_data));
-
-		if (rc < 0) {
-			dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
-				__func__, dai->name);
-		}
-	}
-
-	rc = msm_dai_q6_dai_add_route(dai);
-rtn:
-	return rc;
-}
-
-
-static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-		dev_get_drvdata(dai->dev);
-	int rc;
-
-	/* If AFE port is still up, close it */
-	if (test_bit(STATUS_PORT_STARTED,
-		     mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
-		rc = afe_close(MI2S_RX); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close MI2S_RX port\n");
-		clear_bit(STATUS_PORT_STARTED,
-			  mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
-	}
-	if (test_bit(STATUS_PORT_STARTED,
-		     mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
-		rc = afe_close(MI2S_TX); /* can block */
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close MI2S_TX port\n");
-		clear_bit(STATUS_PORT_STARTED,
-			  mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
-	}
-	return 0;
-}
-
-static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
-				   struct snd_soc_dai *dai)
-{
-
-	return 0;
-}
-
-
-static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
-{
-	int ret = 0;
-
-	switch (stream) {
-	case SNDRV_PCM_STREAM_PLAYBACK:
-		switch (mi2s_id) {
-		case MSM_PRIM_MI2S:
-			*port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-			break;
-		case MSM_SEC_MI2S:
-			*port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
-			break;
-		case MSM_TERT_MI2S:
-			*port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
-			break;
-		case MSM_QUAT_MI2S:
-			*port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
-			break;
-		case MSM_SEC_MI2S_SD1:
-			*port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
-			break;
-		case MSM_QUIN_MI2S:
-			*port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
-			break;
-		case MSM_INT0_MI2S:
-			*port_id = AFE_PORT_ID_INT0_MI2S_RX;
-			break;
-		case MSM_INT1_MI2S:
-			*port_id = AFE_PORT_ID_INT1_MI2S_RX;
-			break;
-		case MSM_INT2_MI2S:
-			*port_id = AFE_PORT_ID_INT2_MI2S_RX;
-			break;
-		case MSM_INT3_MI2S:
-			*port_id = AFE_PORT_ID_INT3_MI2S_RX;
-			break;
-		case MSM_INT4_MI2S:
-			*port_id = AFE_PORT_ID_INT4_MI2S_RX;
-			break;
-		case MSM_INT5_MI2S:
-			*port_id = AFE_PORT_ID_INT5_MI2S_RX;
-			break;
-		case MSM_INT6_MI2S:
-			*port_id = AFE_PORT_ID_INT6_MI2S_RX;
-			break;
-		default:
-			pr_err("%s: playback err id 0x%x\n",
-				__func__, mi2s_id);
-			ret = -1;
-			break;
-		}
-	break;
-	case SNDRV_PCM_STREAM_CAPTURE:
-		switch (mi2s_id) {
-		case MSM_PRIM_MI2S:
-			*port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-			break;
-		case MSM_SEC_MI2S:
-			*port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-			break;
-		case MSM_TERT_MI2S:
-			*port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-			break;
-		case MSM_QUAT_MI2S:
-			*port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-			break;
-		case MSM_QUIN_MI2S:
-			*port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
-			break;
-		case MSM_SENARY_MI2S:
-			*port_id = AFE_PORT_ID_SENARY_MI2S_TX;
-			break;
-		case MSM_INT0_MI2S:
-			*port_id = AFE_PORT_ID_INT0_MI2S_TX;
-			break;
-		case MSM_INT1_MI2S:
-			*port_id = AFE_PORT_ID_INT1_MI2S_TX;
-			break;
-		case MSM_INT2_MI2S:
-			*port_id = AFE_PORT_ID_INT2_MI2S_TX;
-			break;
-		case MSM_INT3_MI2S:
-			*port_id = AFE_PORT_ID_INT3_MI2S_TX;
-			break;
-		case MSM_INT4_MI2S:
-			*port_id = AFE_PORT_ID_INT4_MI2S_TX;
-			break;
-		case MSM_INT5_MI2S:
-			*port_id = AFE_PORT_ID_INT5_MI2S_TX;
-			break;
-		case MSM_INT6_MI2S:
-			*port_id = AFE_PORT_ID_INT6_MI2S_TX;
-			break;
-		default:
-			pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
-			ret = -1;
-			break;
-		}
-	break;
-	default:
-		pr_err("%s: default err %d\n", __func__, stream);
-		ret = -1;
-	break;
-	}
-	pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
-	return ret;
-}
-
-static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-		dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_dai_data *dai_data =
-		(substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-		 &mi2s_dai_data->rx_dai.mi2s_dai_data :
-		 &mi2s_dai_data->tx_dai.mi2s_dai_data);
-	u16 port_id = 0;
-	int rc = 0;
-
-	if (msm_mi2s_get_port_id(dai->id, substream->stream,
-				 &port_id) != 0) {
-		dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
-				__func__, port_id);
-		return -EINVAL;
-	}
-
-	dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
-		"dai_data->channels = %u sample_rate = %u\n", __func__,
-		dai->id, port_id, dai_data->channels, dai_data->rate);
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		/* PORT START should be set if prepare called
-		 * in active state.
-		 */
-		rc = afe_port_start(port_id, &dai_data->port_config,
-				    dai_data->rate);
-		if (rc < 0)
-			dev_err(dai->dev, "fail to open AFE port 0x%x\n",
-				dai->id);
-		else
-			set_bit(STATUS_PORT_STARTED,
-				dai_data->status_mask);
-	}
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
-		set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
-		dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
-				__func__);
-	}
-	return rc;
-}
-
-static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-		dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
-		(substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-		&mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
-	struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
-	struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
-
-	dai_data->channels = params_channels(params);
-	switch (dai_data->channels) {
-	case 8:
-	case 7:
-		if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
-			goto error_invalid_data;
-		dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_8CHS;
-		break;
-	case 6:
-	case 5:
-		if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
-			goto error_invalid_data;
-		dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
-		break;
-	case 4:
-	case 3:
-		if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_QUAD01)
-			goto error_invalid_data;
-		if (mi2s_dai_config->pdata_mi2s_lines == AFE_PORT_I2S_QUAD23)
-			dai_data->port_config.i2s.channel_mode =
-				mi2s_dai_config->pdata_mi2s_lines;
-		else
-			dai_data->port_config.i2s.channel_mode =
-					AFE_PORT_I2S_QUAD01;
-		break;
-	case 2:
-	case 1:
-		if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
-			goto error_invalid_data;
-		switch (mi2s_dai_config->pdata_mi2s_lines) {
-		case AFE_PORT_I2S_SD0:
-		case AFE_PORT_I2S_SD1:
-		case AFE_PORT_I2S_SD2:
-		case AFE_PORT_I2S_SD3:
-			dai_data->port_config.i2s.channel_mode =
-				mi2s_dai_config->pdata_mi2s_lines;
-			break;
-		case AFE_PORT_I2S_QUAD01:
-		case AFE_PORT_I2S_6CHS:
-		case AFE_PORT_I2S_8CHS:
-			if (dai_data->vi_feed_mono == SPKR_1)
-				dai_data->port_config.i2s.channel_mode =
-							AFE_PORT_I2S_SD0;
-			else
-				dai_data->port_config.i2s.channel_mode =
-							AFE_PORT_I2S_SD1;
-			break;
-		case AFE_PORT_I2S_QUAD23:
-			dai_data->port_config.i2s.channel_mode =
-						AFE_PORT_I2S_SD2;
-			break;
-		}
-		if (dai_data->channels == 2)
-			dai_data->port_config.i2s.mono_stereo =
-						MSM_AFE_CH_STEREO;
-		else
-			dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
-		break;
-	default:
-		pr_err("%s: default err channels %d\n",
-			__func__, dai_data->channels);
-		goto error_invalid_data;
-	}
-	dai_data->rate = params_rate(params);
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-	case SNDRV_PCM_FORMAT_SPECIAL:
-		dai_data->port_config.i2s.bit_width = 16;
-		dai_data->bitwidth = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->port_config.i2s.bit_width = 24;
-		dai_data->bitwidth = 24;
-		break;
-	default:
-		pr_err("%s: format %d\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	dai_data->port_config.i2s.i2s_cfg_minor_version =
-			AFE_API_VERSION_I2S_CONFIG;
-	dai_data->port_config.i2s.sample_rate = dai_data->rate;
-	if ((test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
-	    test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
-	    (test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
-	    test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
-		if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
-		    mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
-		   (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
-		    mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
-			dev_err(dai->dev, "%s: Error mismatch in HW params\n"
-				"Tx sample_rate = %u bit_width = %hu\n"
-				"Rx sample_rate = %u bit_width = %hu\n"
-				, __func__,
-				mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
-				mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
-				mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
-				mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
-			return -EINVAL;
-		}
-	}
-	dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
-		"sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
-		"bit_width = %hu  channel_mode = 0x%x mono_stereo = %#x\n"
-		"ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
-		"reserved = %u\n", __func__, dai->id, dai_data->channels,
-		dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
-		i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
-		i2s->sample_rate, i2s->data_format, i2s->reserved);
-
-	return 0;
-
-error_invalid_data:
-	pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
-		 dai_data->channels, dai_data->port_config.i2s.channel_mode);
-	return -EINVAL;
-}
-
-
-static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-	dev_get_drvdata(dai->dev);
-
-	if (test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
-	    test_bit(STATUS_PORT_STARTED,
-	    mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
-		dev_err(dai->dev, "%s: err chg i2s mode while dai running",
-			__func__);
-		return -EPERM;
-	}
-
-	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBS_CFS:
-		mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
-		mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
-		break;
-	case SND_SOC_DAIFMT_CBM_CFM:
-		mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
-		mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
-		break;
-	default:
-		pr_err("%s: fmt %d\n",
-			__func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-			dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_dai_data *dai_data =
-		(substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-		 &mi2s_dai_data->rx_dai.mi2s_dai_data :
-		 &mi2s_dai_data->tx_dai.mi2s_dai_data);
-
-	if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
-		clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
-		dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
-	}
-	return 0;
-}
-
-static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
-				     struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
-			dev_get_drvdata(dai->dev);
-	struct msm_dai_q6_dai_data *dai_data =
-		(substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-		 &mi2s_dai_data->rx_dai.mi2s_dai_data :
-		 &mi2s_dai_data->tx_dai.mi2s_dai_data);
-	 u16 port_id = 0;
-	int rc = 0;
-
-	if (msm_mi2s_get_port_id(dai->id, substream->stream,
-				 &port_id) != 0) {
-		dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
-				__func__, port_id);
-	}
-
-	dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
-			__func__, port_id);
-
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_close(port_id);
-		if (rc < 0)
-			dev_err(dai->dev, "fail to close AFE port\n");
-		clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
-	}
-	if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
-		clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
-	.startup	= msm_dai_q6_mi2s_startup,
-	.prepare	= msm_dai_q6_mi2s_prepare,
-	.hw_params	= msm_dai_q6_mi2s_hw_params,
-	.hw_free	= msm_dai_q6_mi2s_hw_free,
-	.set_fmt	= msm_dai_q6_mi2s_set_fmt,
-	.shutdown	= msm_dai_q6_mi2s_shutdown,
-};
-
-/* Channel min and max are initialized base on platform data */
-static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
-	{
-		.playback = {
-			.stream_name = "Primary MI2S Playback",
-			.aif_name = "PRI_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "Primary MI2S Capture",
-			.aif_name = "PRI_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_PRIM_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary MI2S Playback",
-			.aif_name = "SEC_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "Secondary MI2S Capture",
-			.aif_name = "SEC_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_SEC_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary MI2S Playback",
-			.aif_name = "TERT_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "Tertiary MI2S Capture",
-			.aif_name = "TERT_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_TERT_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary MI2S Playback",
-			.aif_name = "QUAT_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "Quaternary MI2S Capture",
-			.aif_name = "QUAT_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
-				 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-				 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
-				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
-				 SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_QUAT_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary MI2S Playback SD1",
-			.aif_name = "SEC_MI2S_RX_SD1",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.id = MSM_SEC_MI2S_SD1,
-	},
-	{
-		.playback = {
-			.stream_name = "Quinary MI2S Playback",
-			.aif_name = "QUIN_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "Quinary MI2S Capture",
-			.aif_name = "QUIN_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_QUIN_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Senary_mi2s Capture",
-			.aif_name = "SENARY_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_SENARY_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT0 MI2S Playback",
-			.aif_name = "INT0_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
-			SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "INT0 MI2S Capture",
-			.aif_name = "INT0_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT0_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT1 MI2S Playback",
-			.aif_name = "INT1_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT1 MI2S Capture",
-			.aif_name = "INT1_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT1_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT2 MI2S Playback",
-			.aif_name = "INT2_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT2 MI2S Capture",
-			.aif_name = "INT2_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT2_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT3 MI2S Playback",
-			.aif_name = "INT3_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT3 MI2S Capture",
-			.aif_name = "INT3_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT3_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT4 MI2S Playback",
-			.aif_name = "INT4_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
-			SNDRV_PCM_RATE_192000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     192000,
-		},
-		.capture = {
-			.stream_name = "INT4 MI2S Capture",
-			.aif_name = "INT4_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT4_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT5 MI2S Playback",
-			.aif_name = "INT5_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT5 MI2S Capture",
-			.aif_name = "INT5_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT5_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "INT6 MI2S Playback",
-			.aif_name = "INT6_MI2S_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.capture = {
-			.stream_name = "INT6 MI2S Capture",
-			.aif_name = "INT6_MI2S_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.rate_min =     8000,
-			.rate_max =     48000,
-		},
-		.ops = &msm_dai_q6_mi2s_ops,
-		.id = MSM_INT6_MI2S,
-		.probe = msm_dai_q6_dai_mi2s_probe,
-		.remove = msm_dai_q6_dai_mi2s_remove,
-	},
-};
-
-
-static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
-					  unsigned int *ch_cnt)
-{
-	u8 num_of_sd_lines;
-
-	num_of_sd_lines = num_of_bits_set(sd_lines);
-	switch (num_of_sd_lines) {
-	case 0:
-		pr_debug("%s: no line is assigned\n", __func__);
-		break;
-	case 1:
-		switch (sd_lines) {
-		case MSM_MI2S_SD0:
-			*config_ptr = AFE_PORT_I2S_SD0;
-			break;
-		case MSM_MI2S_SD1:
-			*config_ptr = AFE_PORT_I2S_SD1;
-			break;
-		case MSM_MI2S_SD2:
-			*config_ptr = AFE_PORT_I2S_SD2;
-			break;
-		case MSM_MI2S_SD3:
-			*config_ptr = AFE_PORT_I2S_SD3;
-			break;
-		default:
-			pr_err("%s: invalid SD lines %d\n",
-				   __func__, sd_lines);
-			goto error_invalid_data;
-		}
-		break;
-	case 2:
-		switch (sd_lines) {
-		case MSM_MI2S_SD0 | MSM_MI2S_SD1:
-			*config_ptr = AFE_PORT_I2S_QUAD01;
-			break;
-		case MSM_MI2S_SD2 | MSM_MI2S_SD3:
-			*config_ptr = AFE_PORT_I2S_QUAD23;
-			break;
-		default:
-			pr_err("%s: invalid SD lines %d\n",
-				   __func__, sd_lines);
-			goto error_invalid_data;
-		}
-		break;
-	case 3:
-		switch (sd_lines) {
-		case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
-			*config_ptr = AFE_PORT_I2S_6CHS;
-			break;
-		default:
-			pr_err("%s: invalid SD lines %d\n",
-				   __func__, sd_lines);
-			goto error_invalid_data;
-		}
-		break;
-	case 4:
-		switch (sd_lines) {
-		case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
-			*config_ptr = AFE_PORT_I2S_8CHS;
-			break;
-		default:
-			pr_err("%s: invalid SD lines %d\n",
-				   __func__, sd_lines);
-			goto error_invalid_data;
-		}
-		break;
-	default:
-		pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
-		goto error_invalid_data;
-	}
-	*ch_cnt = num_of_sd_lines;
-	return 0;
-
-error_invalid_data:
-	pr_err("%s: invalid data\n", __func__);
-	return -EINVAL;
-}
-
-static int msm_dai_q6_mi2s_platform_data_validation(
-	struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
-{
-	struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
-	struct msm_mi2s_pdata *mi2s_pdata =
-			(struct msm_mi2s_pdata *) pdev->dev.platform_data;
-	unsigned int ch_cnt;
-	int rc = 0;
-	u16 sd_line;
-
-	if (mi2s_pdata == NULL) {
-		pr_err("%s: mi2s_pdata NULL", __func__);
-		return -EINVAL;
-	}
-
-	rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
-					    &sd_line, &ch_cnt);
-	if (rc < 0) {
-		dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
-		goto rtn;
-	}
-
-	if (ch_cnt) {
-		dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
-		sd_line;
-		dai_data->rx_dai.pdata_mi2s_lines = sd_line;
-		dai_driver->playback.channels_min = 1;
-		dai_driver->playback.channels_max = ch_cnt << 1;
-	} else {
-		dai_driver->playback.channels_min = 0;
-		dai_driver->playback.channels_max = 0;
-	}
-	rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
-					    &sd_line, &ch_cnt);
-	if (rc < 0) {
-		dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
-		goto rtn;
-	}
-
-	if (ch_cnt) {
-		dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
-		sd_line;
-		dai_data->tx_dai.pdata_mi2s_lines = sd_line;
-		dai_driver->capture.channels_min = 1;
-		dai_driver->capture.channels_max = ch_cnt << 1;
-	} else {
-		dai_driver->capture.channels_min = 0;
-		dai_driver->capture.channels_max = 0;
-	}
-
-	dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
-		__func__, dai_data->rx_dai.pdata_mi2s_lines,
-		dai_data->tx_dai.pdata_mi2s_lines);
-	dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
-		__func__, dai_driver->playback.channels_max,
-		dai_driver->capture.channels_max);
-rtn:
-	return rc;
-}
-
-static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
-	.name		= "msm-dai-q6-mi2s",
-};
-static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
-{
-	struct msm_dai_q6_mi2s_dai_data *dai_data;
-	const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
-	u32 tx_line = 0;
-	u32  rx_line = 0;
-	u32 mi2s_intf = 0;
-	struct msm_mi2s_pdata *mi2s_pdata;
-	int rc;
-
-	rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
-				  &mi2s_intf);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
-		goto rtn;
-	}
-
-	dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
-		mi2s_intf);
-
-	if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
-		|| (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
-		dev_err(&pdev->dev,
-			"%s: Invalid MI2S ID %u from Device Tree\n",
-			__func__, mi2s_intf);
-		rc = -ENXIO;
-		goto rtn;
-	}
-
-	pdev->id = mi2s_intf;
-
-	mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
-	if (!mi2s_pdata) {
-		rc = -ENOMEM;
-		goto rtn;
-	}
-
-	rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
-				  &rx_line);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
-			"qcom,msm-mi2s-rx-lines");
-		goto free_pdata;
-	}
-
-	rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
-				  &tx_line);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
-			"qcom,msm-mi2s-tx-lines");
-		goto free_pdata;
-	}
-	dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
-		dev_name(&pdev->dev), rx_line, tx_line);
-	mi2s_pdata->rx_sd_lines = rx_line;
-	mi2s_pdata->tx_sd_lines = tx_line;
-	mi2s_pdata->intf_id = mi2s_intf;
-
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
-			   GFP_KERNEL);
-	if (!dai_data) {
-		rc = -ENOMEM;
-		goto free_pdata;
-	} else
-		dev_set_drvdata(&pdev->dev, dai_data);
-
-	pdev->dev.platform_data = mi2s_pdata;
-
-	rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
-			&msm_dai_q6_mi2s_dai[mi2s_intf]);
-	if (rc < 0)
-		goto free_dai_data;
-
-	rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
-	&msm_dai_q6_mi2s_dai[mi2s_intf], 1);
-	if (rc < 0)
-		goto err_register;
-	return 0;
-
-err_register:
-	dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
-free_dai_data:
-	kfree(dai_data);
-free_pdata:
-	kfree(mi2s_pdata);
-rtn:
-	return rc;
-}
-
-static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct snd_soc_component_driver msm_dai_q6_component = {
-	.name		= "msm-dai-q6-dev",
-};
-
-static int msm_dai_q6_dev_probe(struct platform_device *pdev)
-{
-	int rc, id, i, len;
-	const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
-	char stream_name[80];
-
-	rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: missing %s in dt node\n", __func__, q6_dev_id);
-		return rc;
-	}
-
-	pdev->id = id;
-
-	pr_debug("%s: dev name %s, id:%d\n", __func__,
-		 dev_name(&pdev->dev), pdev->id);
-
-	switch (id) {
-	case SLIMBUS_0_RX:
-		strlcpy(stream_name, "Slimbus Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_2_RX:
-		strlcpy(stream_name, "Slimbus2 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_1_RX:
-		strlcpy(stream_name, "Slimbus1 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_3_RX:
-		strlcpy(stream_name, "Slimbus3 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_4_RX:
-		strlcpy(stream_name, "Slimbus4 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_5_RX:
-		strlcpy(stream_name, "Slimbus5 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_6_RX:
-		strlcpy(stream_name, "Slimbus6 Playback", 80);
-		goto register_slim_playback;
-	case SLIMBUS_7_RX:
-		strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
-		goto register_slim_playback;
-	case SLIMBUS_8_RX:
-		strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
-		goto register_slim_playback;
-register_slim_playback:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
-			if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
-				!strcmp(stream_name,
-				msm_dai_q6_slimbus_rx_dai[i]
-				.playback.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-				&msm_dai_q6_component,
-				&msm_dai_q6_slimbus_rx_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s: Device not found stream name %s\n",
-				__func__, stream_name);
-		break;
-	case SLIMBUS_0_TX:
-		strlcpy(stream_name, "Slimbus Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_1_TX:
-		strlcpy(stream_name, "Slimbus1 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_2_TX:
-		strlcpy(stream_name, "Slimbus2 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_3_TX:
-		strlcpy(stream_name, "Slimbus3 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_4_TX:
-		strlcpy(stream_name, "Slimbus4 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_5_TX:
-		strlcpy(stream_name, "Slimbus5 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_6_TX:
-		strlcpy(stream_name, "Slimbus6 Capture", 80);
-		goto register_slim_capture;
-	case SLIMBUS_7_TX:
-		strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
-		goto register_slim_capture;
-	case SLIMBUS_8_TX:
-		strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
-		goto register_slim_capture;
-register_slim_capture:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
-			if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
-				!strcmp(stream_name,
-				msm_dai_q6_slimbus_tx_dai[i]
-				.capture.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-				&msm_dai_q6_component,
-				&msm_dai_q6_slimbus_tx_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s: Device not found stream name %s\n",
-				__func__, stream_name);
-		break;
-	case INT_BT_SCO_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
-		break;
-	case INT_BT_SCO_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
-		break;
-	case INT_BT_A2DP_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
-		break;
-	case INT_FM_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
-		break;
-	case INT_FM_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
-		break;
-	case AFE_PORT_ID_USB_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
-		break;
-	case AFE_PORT_ID_USB_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
-		break;
-	case RT_PROXY_DAI_001_RX:
-		strlcpy(stream_name, "AFE Playback", 80);
-		goto register_afe_playback;
-	case RT_PROXY_DAI_002_RX:
-		strlcpy(stream_name, "AFE-PROXY RX", 80);
-register_afe_playback:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
-			if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
-			    !strcmp(stream_name,
-			    msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-					&msm_dai_q6_component,
-					&msm_dai_q6_afe_rx_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s: Device not found stream name %s\n",
-			__func__, stream_name);
-		break;
-	case RT_PROXY_DAI_001_TX:
-		strlcpy(stream_name, "AFE-PROXY TX", 80);
-		goto register_afe_capture;
-	case RT_PROXY_DAI_002_TX:
-		strlcpy(stream_name, "AFE Capture", 80);
-register_afe_capture:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
-			if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
-				!strcmp(stream_name,
-				msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-					&msm_dai_q6_component,
-					&msm_dai_q6_afe_tx_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s: Device not found stream name %s\n",
-			__func__, stream_name);
-		break;
-	case VOICE_PLAYBACK_TX:
-		strlcpy(stream_name, "Voice Farend Playback", 80);
-		goto register_voice_playback;
-	case VOICE2_PLAYBACK_TX:
-		strlcpy(stream_name, "Voice2 Farend Playback", 80);
-register_voice_playback:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
-			if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
-			    && !strcmp(stream_name,
-			 msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-					&msm_dai_q6_component,
-					&msm_dai_q6_voc_playback_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s Device not found stream name %s\n",
-			       __func__, stream_name);
-		break;
-	case VOICE_RECORD_RX:
-		strlcpy(stream_name, "Voice Downlink Capture", 80);
-		goto register_uplink_capture;
-	case VOICE_RECORD_TX:
-		strlcpy(stream_name, "Voice Uplink Capture", 80);
-register_uplink_capture:
-		rc = -ENODEV;
-		len = strnlen(stream_name, 80);
-		for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
-			if (msm_dai_q6_incall_record_dai[i].capture.stream_name
-			    && !strcmp(stream_name,
-			    msm_dai_q6_incall_record_dai[i].
-			    capture.stream_name)) {
-				rc = snd_soc_register_component(&pdev->dev,
-					&msm_dai_q6_component,
-					&msm_dai_q6_incall_record_dai[i], 1);
-				break;
-			}
-		}
-		if (rc)
-			pr_err("%s: Device not found stream name %s\n",
-			__func__, stream_name);
-		break;
-
-	default:
-		rc = -ENODEV;
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_dai_q6_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-q6-dev", },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
-
-static struct platform_driver msm_dai_q6_dev = {
-	.probe  = msm_dai_q6_dev_probe,
-	.remove = msm_dai_q6_dev_remove,
-	.driver = {
-		.name = "msm-dai-q6-dev",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_dev_dt_match,
-	},
-};
-
-static int msm_dai_q6_probe(struct platform_device *pdev)
-{
-	int rc;
-
-	pr_debug("%s: dev name %s, id:%d\n", __func__,
-		 dev_name(&pdev->dev), pdev->id);
-	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
-			__func__, rc);
-	} else
-		dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
-
-	return rc;
-}
-
-static int msm_dai_q6_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static const struct of_device_id msm_dai_q6_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-q6", },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
-static struct platform_driver msm_dai_q6 = {
-	.probe  = msm_dai_q6_probe,
-	.remove = msm_dai_q6_remove,
-	.driver = {
-		.name = "msm-dai-q6",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_dt_match,
-	},
-};
-
-static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
-{
-	int rc;
-
-	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
-			__func__, rc);
-	} else
-		dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
-	return rc;
-}
-
-static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static const struct of_device_id msm_dai_mi2s_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-mi2s", },
-	{ }
-};
-
-MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
-
-static struct platform_driver msm_dai_mi2s_q6 = {
-	.probe  = msm_dai_mi2s_q6_probe,
-	.remove = msm_dai_mi2s_q6_remove,
-	.driver = {
-		.name = "msm-dai-mi2s",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_mi2s_dt_match,
-	},
-};
-
-static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-q6-mi2s", },
-	{ }
-};
-
-MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
-
-static struct platform_driver msm_dai_q6_mi2s_driver = {
-	.probe  = msm_dai_q6_mi2s_dev_probe,
-	.remove  = msm_dai_q6_mi2s_dev_remove,
-	.driver = {
-		.name = "msm-dai-q6-mi2s",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_mi2s_dev_dt_match,
-	},
-};
-
-static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
-{
-	int rc;
-
-	pdev->id = AFE_PORT_ID_SPDIF_RX;
-
-	pr_debug("%s: dev name %s, id:%d\n", __func__,
-			dev_name(&pdev->dev), pdev->id);
-
-	rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_spdif_q6_component,
-			&msm_dai_q6_spdif_spdif_rx_dai, 1);
-	return rc;
-}
-
-static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
-	{.compatible = "qcom,msm-dai-q6-spdif"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
-
-static struct platform_driver msm_dai_q6_spdif_driver = {
-	.probe  = msm_dai_q6_spdif_dev_probe,
-	.remove = msm_dai_q6_spdif_dev_remove,
-	.driver = {
-		.name = "msm-dai-q6-spdif",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_spdif_dt_match,
-	},
-};
-
-static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
-					struct afe_clk_set *clk_set, u32 mode)
-{
-	switch (group_id) {
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
-		if (mode)
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
-		else
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
-		break;
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
-		if (mode)
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
-		else
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
-		break;
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
-		if (mode)
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
-		else
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
-		break;
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
-		if (mode)
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
-		else
-			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	const uint32_t *port_id_array = NULL;
-	uint32_t array_length = 0;
-	int i = 0;
-	int group_idx = 0;
-	u32 clk_mode = 0;
-
-	/* extract tdm group info into static */
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-group-id",
-		(u32 *)&tdm_group_cfg.group_id);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-group-id");
-		goto rtn;
-	}
-	dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
-		__func__, tdm_group_cfg.group_id);
-
-	dev_info(&pdev->dev, "%s: dev_name: %s group_id: 0x%x\n",
-		__func__, dev_name(&pdev->dev), tdm_group_cfg.group_id);
-
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-group-num-ports",
-		&num_tdm_group_ports);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-group-num-ports");
-		goto rtn;
-	}
-	dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
-		__func__, num_tdm_group_ports);
-
-	if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
-		dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
-			__func__, num_tdm_group_ports,
-			AFE_GROUP_DEVICE_NUM_PORTS);
-		rc = -EINVAL;
-		goto rtn;
-	}
-
-	port_id_array = of_get_property(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-group-port-id",
-		&array_length);
-	if (port_id_array == NULL) {
-		dev_err(&pdev->dev, "%s port_id_array is not valid\n",
-			__func__);
-		rc = -EINVAL;
-		goto rtn;
-	}
-	if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
-		dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
-			__func__, array_length,
-			sizeof(uint32_t) * num_tdm_group_ports);
-		rc = -EINVAL;
-		goto rtn;
-	}
-
-	for (i = 0; i < num_tdm_group_ports; i++)
-		tdm_group_cfg.port_id[i] =
-			(u16)be32_to_cpu(port_id_array[i]);
-	/* Unused index should be filled with 0 or AFE_PORT_INVALID */
-	for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
-		tdm_group_cfg.port_id[i] =
-			AFE_PORT_INVALID;
-
-	/* extract tdm clk info into static */
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-clk-rate",
-		&tdm_clk_set.clk_freq_in_hz);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-clk-rate");
-		goto rtn;
-	}
-	dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
-		__func__, tdm_clk_set.clk_freq_in_hz);
-
-	/* extract tdm clk src master/slave info into static */
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-clk-internal",
-		&clk_mode);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-clk-internal");
-		goto rtn;
-	}
-	dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
-		__func__, clk_mode);
-
-	rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
-					  &tdm_clk_set, clk_mode);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
-			__func__, tdm_group_cfg.group_id);
-		goto rtn;
-	}
-
-	/* other initializations within device group */
-	group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
-	if (group_idx < 0) {
-		dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
-			__func__, tdm_group_cfg.group_id);
-		rc = -EINVAL;
-		goto rtn;
-	}
-	atomic_set(&tdm_group_ref[group_idx], 0);
-
-	/* probe child node info */
-	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
-			__func__, rc);
-		goto rtn;
-	} else
-		dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
-
-rtn:
-	return rc;
-}
-
-static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static const struct of_device_id msm_dai_tdm_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-tdm", },
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
-
-static struct platform_driver msm_dai_tdm_q6 = {
-	.probe  = msm_dai_tdm_q6_probe,
-	.remove = msm_dai_tdm_q6_remove,
-	.driver = {
-		.name = "msm-dai-tdm",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_tdm_dt_match,
-	},
-};
-
-static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	switch (value) {
-	case 0:
-		dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
-		break;
-	case 1:
-		dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
-		break;
-	case 2:
-		dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
-		break;
-	default:
-		pr_err("%s: data_format invalid\n", __func__);
-		break;
-	}
-	pr_debug("%s: data_format = %d\n",
-		__func__, dai_data->port_cfg.tdm.data_format);
-	return 0;
-}
-
-static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] =
-		dai_data->port_cfg.tdm.data_format;
-	pr_debug("%s: data_format = %d\n",
-		__func__, dai_data->port_cfg.tdm.data_format);
-	return 0;
-}
-
-static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-	int value = ucontrol->value.integer.value[0];
-
-	dai_data->port_cfg.custom_tdm_header.header_type = value;
-	pr_debug("%s: header_type = %d\n",
-		__func__,
-		dai_data->port_cfg.custom_tdm_header.header_type);
-	return 0;
-}
-
-static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-
-	ucontrol->value.integer.value[0] =
-		dai_data->port_cfg.custom_tdm_header.header_type;
-	pr_debug("%s: header_type = %d\n",
-		__func__,
-		dai_data->port_cfg.custom_tdm_header.header_type);
-	return 0;
-}
-
-static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-	int i = 0;
-
-	for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
-		dai_data->port_cfg.custom_tdm_header.header[i] =
-			(u16)ucontrol->value.integer.value[i];
-		pr_debug("%s: header #%d = 0x%x\n",
-			__func__, i,
-			dai_data->port_cfg.custom_tdm_header.header[i]);
-	}
-	return 0;
-}
-
-static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
-	int i = 0;
-
-	for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
-		ucontrol->value.integer.value[i] =
-			dai_data->port_cfg.custom_tdm_header.header[i];
-		pr_debug("%s: header #%d = 0x%x\n",
-			__func__, i,
-			dai_data->port_cfg.custom_tdm_header.header[i]);
-	}
-	return 0;
-}
-
-static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
-			msm_dai_q6_tdm_data_format_get,
-			msm_dai_q6_tdm_data_format_put),
-};
-
-static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
-			msm_dai_q6_tdm_header_type_get,
-			msm_dai_q6_tdm_header_type_put),
-};
-
-static const struct snd_kcontrol_new tdm_config_controls_header[] = {
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-	SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
-			SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
-			msm_dai_q6_tdm_header_get,
-			msm_dai_q6_tdm_header_put),
-};
-
-static int msm_dai_q6_tdm_set_clk(
-		struct msm_dai_q6_tdm_dai_data *dai_data,
-		u16 port_id, bool enable)
-{
-	int rc = 0;
-
-	dai_data->clk_set.enable = enable;
-
-	rc = afe_set_lpass_clock_v2(port_id,
-		&dai_data->clk_set);
-	if (rc < 0)
-		pr_err("%s: afe lpass clock failed, err:%d\n",
-			__func__, rc);
-
-	return rc;
-}
-
-static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
-			dev_get_drvdata(dai->dev);
-	struct snd_kcontrol *data_format_kcontrol = NULL;
-	struct snd_kcontrol *header_type_kcontrol = NULL;
-	struct snd_kcontrol *header_kcontrol = NULL;
-	int port_idx = 0;
-	const struct snd_kcontrol_new *data_format_ctrl = NULL;
-	const struct snd_kcontrol_new *header_type_ctrl = NULL;
-	const struct snd_kcontrol_new *header_ctrl = NULL;
-
-	msm_dai_q6_set_dai_id(dai);
-
-	port_idx = msm_dai_q6_get_port_idx(dai->id);
-	if (port_idx < 0) {
-		dev_err(dai->dev, "%s port id 0x%x not supported\n",
-			__func__, dai->id);
-		rc = -EINVAL;
-		goto rtn;
-	}
-
-	data_format_ctrl =
-		&tdm_config_controls_data_format[port_idx];
-	header_type_ctrl =
-		&tdm_config_controls_header_type[port_idx];
-	header_ctrl =
-		&tdm_config_controls_header[port_idx];
-
-	if (data_format_ctrl) {
-		data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
-					tdm_dai_data);
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 data_format_kcontrol);
-		if (rc < 0) {
-			dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
-				__func__, dai->name);
-			goto rtn;
-		}
-	}
-
-	if (header_type_ctrl) {
-		header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
-					tdm_dai_data);
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 header_type_kcontrol);
-		if (rc < 0) {
-			if (data_format_kcontrol)
-				snd_ctl_remove(dai->component->card->snd_card,
-					data_format_kcontrol);
-			dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
-				__func__, dai->name);
-			goto rtn;
-		}
-	}
-
-	if (header_ctrl) {
-		header_kcontrol = snd_ctl_new1(header_ctrl,
-					tdm_dai_data);
-		rc = snd_ctl_add(dai->component->card->snd_card,
-				 header_kcontrol);
-		if (rc < 0) {
-			if (header_type_kcontrol)
-				snd_ctl_remove(dai->component->card->snd_card,
-					header_type_kcontrol);
-			if (data_format_kcontrol)
-				snd_ctl_remove(dai->component->card->snd_card,
-					data_format_kcontrol);
-			dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
-				__func__, dai->name);
-			goto rtn;
-		}
-	}
-
-	rc = msm_dai_q6_dai_add_route(dai);
-
-rtn:
-	return rc;
-}
-
-
-static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
-		dev_get_drvdata(dai->dev);
-	u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
-	int group_idx = 0;
-	atomic_t *group_ref = NULL;
-
-	group_idx = msm_dai_q6_get_group_idx(dai->id);
-	if (group_idx < 0) {
-		dev_err(dai->dev, "%s port id 0x%x not supported\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	group_ref = &tdm_group_ref[group_idx];
-
-	/* If AFE port is still up, close it */
-	if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
-		rc = afe_close(dai->id); /* can block */
-		if (rc < 0) {
-			dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
-				__func__, dai->id);
-		}
-		atomic_dec(group_ref);
-		clear_bit(STATUS_PORT_STARTED,
-			  tdm_dai_data->status_mask);
-
-		if (atomic_read(group_ref) == 0) {
-			rc = afe_port_group_enable(group_id,
-				NULL, false);
-			if (rc < 0) {
-				dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
-					group_id);
-			}
-			rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
-				dai->id, false);
-			if (rc < 0) {
-				dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
-					__func__, dai->id);
-			}
-		}
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
-				unsigned int tx_mask,
-				unsigned int rx_mask,
-				int slots, int slot_width)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(dai->dev);
-	struct afe_param_id_group_device_tdm_cfg *tdm_group =
-		&dai_data->group_cfg.tdm_cfg;
-	unsigned int cap_mask;
-
-	dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
-
-	/* HW only supports 16 and 32 bit slot width configuration */
-	if ((slot_width != 16) && (slot_width != 32)) {
-		dev_err(dai->dev, "%s: invalid slot_width %d\n",
-			__func__, slot_width);
-		return -EINVAL;
-	}
-
-	/* HW only supports 16 and 8 slots configuration */
-	switch (slots) {
-	case 2:
-		cap_mask = 0x03;
-		break;
-	case 8:
-		cap_mask = 0xFF;
-		break;
-	case 16:
-		cap_mask = 0xFFFF;
-		break;
-	default:
-		dev_err(dai->dev, "%s: invalid slots %d\n",
-			__func__, slots);
-		return -EINVAL;
-	}
-
-	switch (dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		tdm_group->nslots_per_frame = slots;
-		tdm_group->slot_width = slot_width;
-		tdm_group->slot_mask = rx_mask & cap_mask;
-		break;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		tdm_group->nslots_per_frame = slots;
-		tdm_group->slot_width = slot_width;
-		tdm_group->slot_mask = tx_mask & cap_mask;
-		break;
-	default:
-		dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	return rc;
-}
-
-static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
-				unsigned int tx_num, unsigned int *tx_slot,
-				unsigned int rx_num, unsigned int *rx_slot)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(dai->dev);
-	struct afe_param_id_slot_mapping_cfg *slot_mapping =
-		&dai_data->port_cfg.slot_mapping;
-	int i = 0;
-
-	dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
-
-	switch (dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		if (!rx_slot) {
-			dev_err(dai->dev, "%s: rx slot not found\n", __func__);
-			return -EINVAL;
-		}
-		if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
-			dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
-				rx_num);
-			return -EINVAL;
-		}
-
-		for (i = 0; i < rx_num; i++)
-			slot_mapping->offset[i] = rx_slot[i];
-		for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
-			slot_mapping->offset[i] =
-				AFE_SLOT_MAPPING_OFFSET_INVALID;
-
-		slot_mapping->num_channel = rx_num;
-		break;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		if (!tx_slot) {
-			dev_err(dai->dev, "%s: tx slot not found\n", __func__);
-			return -EINVAL;
-		}
-		if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
-			dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
-				tx_num);
-			return -EINVAL;
-		}
-
-		for (i = 0; i < tx_num; i++)
-			slot_mapping->offset[i] = tx_slot[i];
-		for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
-			slot_mapping->offset[i] =
-				AFE_SLOT_MAPPING_OFFSET_INVALID;
-
-		slot_mapping->num_channel = tx_num;
-		break;
-	default:
-		dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	return rc;
-}
-
-static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params,
-				struct snd_soc_dai *dai)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(dai->dev);
-
-	struct afe_param_id_group_device_tdm_cfg *tdm_group =
-		&dai_data->group_cfg.tdm_cfg;
-	struct afe_param_id_tdm_cfg *tdm =
-		&dai_data->port_cfg.tdm;
-	struct afe_param_id_slot_mapping_cfg *slot_mapping =
-		&dai_data->port_cfg.slot_mapping;
-	struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
-		&dai_data->port_cfg.custom_tdm_header;
-
-	pr_debug("%s: dev_name: %s\n",
-		__func__, dev_name(dai->dev));
-
-	if ((params_channels(params) == 0) ||
-		(params_channels(params) > 8)) {
-		dev_err(dai->dev, "%s: invalid param channels %d\n",
-			__func__, params_channels(params));
-		return -EINVAL;
-	}
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		dai_data->bitwidth = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		dai_data->bitwidth = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		dai_data->bitwidth = 32;
-		break;
-	default:
-		dev_err(dai->dev, "%s: invalid param format 0x%x\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-	dai_data->channels = params_channels(params);
-	dai_data->rate = params_rate(params);
-
-	/*
-	 * update tdm group config param
-	 * NOTE: group config is set to the same as slot config.
-	 */
-	tdm_group->bit_width = tdm_group->slot_width;
-	tdm_group->num_channels = tdm_group->nslots_per_frame;
-	tdm_group->sample_rate = dai_data->rate;
-
-	pr_debug("%s: TDM GROUP:\n"
-		"num_channels=%d sample_rate=%d bit_width=%d\n"
-		"nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
-		__func__,
-		tdm_group->num_channels,
-		tdm_group->sample_rate,
-		tdm_group->bit_width,
-		tdm_group->nslots_per_frame,
-		tdm_group->slot_width,
-		tdm_group->slot_mask);
-	pr_debug("%s: TDM GROUP:\n"
-		"port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
-		"port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
-		__func__,
-		tdm_group->port_id[0],
-		tdm_group->port_id[1],
-		tdm_group->port_id[2],
-		tdm_group->port_id[3],
-		tdm_group->port_id[4],
-		tdm_group->port_id[5],
-		tdm_group->port_id[6],
-		tdm_group->port_id[7]);
-
-	/*
-	 * update tdm config param
-	 * NOTE: channels/rate/bitwidth are per stream property
-	 */
-	tdm->num_channels = dai_data->channels;
-	tdm->sample_rate = dai_data->rate;
-	tdm->bit_width = dai_data->bitwidth;
-	/*
-	 * port slot config is the same as group slot config
-	 * port slot mask should be set according to offset
-	 */
-	tdm->nslots_per_frame = tdm_group->nslots_per_frame;
-	tdm->slot_width = tdm_group->slot_width;
-	tdm->slot_mask = tdm_group->slot_mask;
-
-	pr_debug("%s: TDM:\n"
-		"num_channels=%d sample_rate=%d bit_width=%d\n"
-		"nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
-		"data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
-		"data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
-		__func__,
-		tdm->num_channels,
-		tdm->sample_rate,
-		tdm->bit_width,
-		tdm->nslots_per_frame,
-		tdm->slot_width,
-		tdm->slot_mask,
-		tdm->data_format,
-		tdm->sync_mode,
-		tdm->sync_src,
-		tdm->ctrl_data_out_enable,
-		tdm->ctrl_invert_sync_pulse,
-		tdm->ctrl_sync_data_delay);
-
-	/*
-	 * update slot mapping config param
-	 * NOTE: channels/rate/bitwidth are per stream property
-	 */
-	slot_mapping->bitwidth = dai_data->bitwidth;
-
-	pr_debug("%s: SLOT MAPPING:\n"
-		"num_channel=%d bitwidth=%d data_align=0x%x\n",
-		__func__,
-		slot_mapping->num_channel,
-		slot_mapping->bitwidth,
-		slot_mapping->data_align_type);
-	pr_debug("%s: SLOT MAPPING:\n"
-		"offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
-		"offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
-		__func__,
-		slot_mapping->offset[0],
-		slot_mapping->offset[1],
-		slot_mapping->offset[2],
-		slot_mapping->offset[3],
-		slot_mapping->offset[4],
-		slot_mapping->offset[5],
-		slot_mapping->offset[6],
-		slot_mapping->offset[7]);
-
-	/*
-	 * update custom header config param
-	 * NOTE: channels/rate/bitwidth are per playback stream property.
-	 * custom tdm header only applicable to playback stream.
-	 */
-	if (custom_tdm_header->header_type !=
-		AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
-		pr_debug("%s: CUSTOM TDM HEADER:\n"
-			"start_offset=0x%x header_width=%d\n"
-			"num_frame_repeat=%d header_type=0x%x\n",
-			__func__,
-			custom_tdm_header->start_offset,
-			custom_tdm_header->header_width,
-			custom_tdm_header->num_frame_repeat,
-			custom_tdm_header->header_type);
-		pr_debug("%s: CUSTOM TDM HEADER:\n"
-			"header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
-			"header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
-			__func__,
-			custom_tdm_header->header[0],
-			custom_tdm_header->header[1],
-			custom_tdm_header->header[2],
-			custom_tdm_header->header[3],
-			custom_tdm_header->header[4],
-			custom_tdm_header->header[5],
-			custom_tdm_header->header[6],
-			custom_tdm_header->header[7]);
-	}
-
-	return 0;
-}
-
-static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(dai->dev);
-	u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
-	int group_idx = 0;
-	atomic_t *group_ref = NULL;
-
-	group_idx = msm_dai_q6_get_group_idx(dai->id);
-	if (group_idx < 0) {
-		dev_err(dai->dev, "%s port id 0x%x not supported\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	mutex_lock(&tdm_mutex);
-
-	group_ref = &tdm_group_ref[group_idx];
-
-	if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		/* PORT START should be set if prepare called
-		 * in active state.
-		 */
-		if (atomic_read(group_ref) == 0) {
-			/* TX and RX share the same clk.
-			 * AFE clk is enabled per group to simplify the logic.
-			 * DSP will monitor the clk count.
-			 */
-			rc = msm_dai_q6_tdm_set_clk(dai_data,
-				dai->id, true);
-			if (rc < 0) {
-				dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
-					__func__, dai->id);
-				goto rtn;
-			}
-
-			/*
-			 * if only one port, don't do group enable as there
-			 * is no group need for only one port
-			 */
-			if (dai_data->num_group_ports > 1) {
-				rc = afe_port_group_enable(group_id,
-					&dai_data->group_cfg, true);
-				if (rc < 0) {
-					dev_err(dai->dev,
-					"%s: fail to enable AFE group 0x%x\n",
-					__func__, group_id);
-					goto rtn;
-				}
-			}
-		}
-
-		rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
-			dai_data->rate, dai_data->num_group_ports);
-		if (rc < 0) {
-			if (atomic_read(group_ref) == 0) {
-				afe_port_group_enable(group_id,
-					NULL, false);
-				msm_dai_q6_tdm_set_clk(dai_data,
-					dai->id, false);
-			}
-			dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
-				__func__, dai->id);
-		} else {
-			set_bit(STATUS_PORT_STARTED,
-				dai_data->status_mask);
-			atomic_inc(group_ref);
-		}
-
-		/* TODO: need to monitor PCM/MI2S/TDM HW status */
-		/* NOTE: AFE should error out if HW resource contention */
-
-	}
-
-rtn:
-	mutex_unlock(&tdm_mutex);
-	return rc;
-}
-
-static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
-				     struct snd_soc_dai *dai)
-{
-	int rc = 0;
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(dai->dev);
-	u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
-	int group_idx = 0;
-	atomic_t *group_ref = NULL;
-
-	group_idx = msm_dai_q6_get_group_idx(dai->id);
-	if (group_idx < 0) {
-		dev_err(dai->dev, "%s port id 0x%x not supported\n",
-			__func__, dai->id);
-		return;
-	}
-
-	mutex_lock(&tdm_mutex);
-
-	group_ref = &tdm_group_ref[group_idx];
-
-	if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
-		rc = afe_close(dai->id);
-		if (rc < 0) {
-			dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
-				__func__, dai->id);
-		}
-		atomic_dec(group_ref);
-		clear_bit(STATUS_PORT_STARTED,
-			dai_data->status_mask);
-
-		if (atomic_read(group_ref) == 0) {
-			rc = afe_port_group_enable(group_id,
-				NULL, false);
-			if (rc < 0) {
-				dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
-					__func__, group_id);
-			}
-			rc = msm_dai_q6_tdm_set_clk(dai_data,
-				dai->id, false);
-			if (rc < 0) {
-				dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
-					__func__, dai->id);
-			}
-		}
-
-		/* TODO: need to monitor PCM/MI2S/TDM HW status */
-		/* NOTE: AFE should error out if HW resource contention */
-
-	}
-
-	mutex_unlock(&tdm_mutex);
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
-	.prepare          = msm_dai_q6_tdm_prepare,
-	.hw_params        = msm_dai_q6_tdm_hw_params,
-	.set_tdm_slot     = msm_dai_q6_tdm_set_tdm_slot,
-	.set_channel_map  = msm_dai_q6_tdm_set_channel_map,
-	.shutdown         = msm_dai_q6_tdm_shutdown,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
-	{
-		.playback = {
-			.stream_name = "Primary TDM0 Playback",
-			.aif_name = "PRI_TDM_RX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM1 Playback",
-			.aif_name = "PRI_TDM_RX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM2 Playback",
-			.aif_name = "PRI_TDM_RX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM3 Playback",
-			.aif_name = "PRI_TDM_RX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM4 Playback",
-			.aif_name = "PRI_TDM_RX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM5 Playback",
-			.aif_name = "PRI_TDM_RX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM6 Playback",
-			.aif_name = "PRI_TDM_RX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Primary TDM7 Playback",
-			.aif_name = "PRI_TDM_RX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM0 Capture",
-			.aif_name = "PRI_TDM_TX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM1 Capture",
-			.aif_name = "PRI_TDM_TX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM2 Capture",
-			.aif_name = "PRI_TDM_TX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM3 Capture",
-			.aif_name = "PRI_TDM_TX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM4 Capture",
-			.aif_name = "PRI_TDM_TX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM5 Capture",
-			.aif_name = "PRI_TDM_TX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM6 Capture",
-			.aif_name = "PRI_TDM_TX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Primary TDM7 Capture",
-			.aif_name = "PRI_TDM_TX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM0 Playback",
-			.aif_name = "SEC_TDM_RX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM1 Playback",
-			.aif_name = "SEC_TDM_RX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM2 Playback",
-			.aif_name = "SEC_TDM_RX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM3 Playback",
-			.aif_name = "SEC_TDM_RX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM4 Playback",
-			.aif_name = "SEC_TDM_RX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM5 Playback",
-			.aif_name = "SEC_TDM_RX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM6 Playback",
-			.aif_name = "SEC_TDM_RX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Secondary TDM7 Playback",
-			.aif_name = "SEC_TDM_RX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM0 Capture",
-			.aif_name = "SEC_TDM_TX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM1 Capture",
-			.aif_name = "SEC_TDM_TX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM2 Capture",
-			.aif_name = "SEC_TDM_TX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM3 Capture",
-			.aif_name = "SEC_TDM_TX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM4 Capture",
-			.aif_name = "SEC_TDM_TX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM5 Capture",
-			.aif_name = "SEC_TDM_TX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM6 Capture",
-			.aif_name = "SEC_TDM_TX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Secondary TDM7 Capture",
-			.aif_name = "SEC_TDM_TX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM0 Playback",
-			.aif_name = "TERT_TDM_RX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM1 Playback",
-			.aif_name = "TERT_TDM_RX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM2 Playback",
-			.aif_name = "TERT_TDM_RX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM3 Playback",
-			.aif_name = "TERT_TDM_RX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM4 Playback",
-			.aif_name = "TERT_TDM_RX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM5 Playback",
-			.aif_name = "TERT_TDM_RX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM6 Playback",
-			.aif_name = "TERT_TDM_RX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Tertiary TDM7 Playback",
-			.aif_name = "TERT_TDM_RX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM0 Capture",
-			.aif_name = "TERT_TDM_TX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM1 Capture",
-			.aif_name = "TERT_TDM_TX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM2 Capture",
-			.aif_name = "TERT_TDM_TX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM3 Capture",
-			.aif_name = "TERT_TDM_TX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM4 Capture",
-			.aif_name = "TERT_TDM_TX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM5 Capture",
-			.aif_name = "TERT_TDM_TX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM6 Capture",
-			.aif_name = "TERT_TDM_TX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Tertiary TDM7 Capture",
-			.aif_name = "TERT_TDM_TX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM0 Playback",
-			.aif_name = "QUAT_TDM_RX_0",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM1 Playback",
-			.aif_name = "QUAT_TDM_RX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM2 Playback",
-			.aif_name = "QUAT_TDM_RX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM3 Playback",
-			.aif_name = "QUAT_TDM_RX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM4 Playback",
-			.aif_name = "QUAT_TDM_RX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM5 Playback",
-			.aif_name = "QUAT_TDM_RX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM6 Playback",
-			.aif_name = "QUAT_TDM_RX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "Quaternary TDM7 Playback",
-			.aif_name = "QUAT_TDM_RX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM0 Capture",
-			.aif_name = "QUAT_TDM_TX_0",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM1 Capture",
-			.aif_name = "QUAT_TDM_TX_1",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM2 Capture",
-			.aif_name = "QUAT_TDM_TX_2",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM3 Capture",
-			.aif_name = "QUAT_TDM_TX_3",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM4 Capture",
-			.aif_name = "QUAT_TDM_TX_4",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM5 Capture",
-			.aif_name = "QUAT_TDM_TX_5",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM6 Capture",
-			.aif_name = "QUAT_TDM_TX_6",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Quaternary TDM7 Capture",
-			.aif_name = "QUAT_TDM_TX_7",
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE |
-				   SNDRV_PCM_FMTBIT_S24_LE |
-				   SNDRV_PCM_FMTBIT_S32_LE,
-			.channels_min = 1,
-			.channels_max = 8,
-			.rate_min = 8000,
-			.rate_max = 352800,
-		},
-		.ops = &msm_dai_q6_tdm_ops,
-		.id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
-		.probe = msm_dai_q6_dai_tdm_probe,
-		.remove = msm_dai_q6_dai_tdm_remove,
-	},
-};
-
-static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
-	.name		= "msm-dai-q6-tdm",
-};
-
-static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
-	struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
-	int rc = 0;
-	u32 tdm_dev_id = 0;
-	int port_idx = 0;
-	struct device_node *tdm_parent_node = NULL;
-
-	/* retrieve device/afe id */
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-dev-id",
-		&tdm_dev_id);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
-			__func__);
-		goto rtn;
-	}
-	if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
-		(tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
-		dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
-			__func__, tdm_dev_id);
-		rc = -ENXIO;
-		goto rtn;
-	}
-	pdev->id = tdm_dev_id;
-
-	dev_info(&pdev->dev, "%s: dev_name: %s dev_id: 0x%x\n",
-		__func__, dev_name(&pdev->dev), tdm_dev_id);
-
-	dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
-				GFP_KERNEL);
-	if (!dai_data) {
-		rc = -ENOMEM;
-		dev_err(&pdev->dev,
-			"%s Failed to allocate memory for tdm dai_data\n",
-			__func__);
-		goto rtn;
-	}
-	memset(dai_data, 0, sizeof(*dai_data));
-
-	/* TDM CFG */
-	tdm_parent_node = of_get_parent(pdev->dev.of_node);
-	rc = of_property_read_u32(tdm_parent_node,
-		"qcom,msm-cpudai-tdm-sync-mode",
-		(u32 *)&dai_data->port_cfg.tdm.sync_mode);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-sync-mode");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.tdm.sync_mode);
-
-	rc = of_property_read_u32(tdm_parent_node,
-		"qcom,msm-cpudai-tdm-sync-src",
-		(u32 *)&dai_data->port_cfg.tdm.sync_src);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-sync-src");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.tdm.sync_src);
-
-	rc = of_property_read_u32(tdm_parent_node,
-		"qcom,msm-cpudai-tdm-data-out",
-		(u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-data-out");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
-
-	rc = of_property_read_u32(tdm_parent_node,
-		"qcom,msm-cpudai-tdm-invert-sync",
-		(u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-invert-sync");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
-
-	rc = of_property_read_u32(tdm_parent_node,
-		"qcom,msm-cpudai-tdm-data-delay",
-		(u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
-			__func__, "qcom,msm-cpudai-tdm-data-delay");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
-
-	/* TDM CFG -- set default */
-	dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
-	dai_data->port_cfg.tdm.tdm_cfg_minor_version =
-		AFE_API_VERSION_TDM_CONFIG;
-
-	/* TDM SLOT MAPPING CFG */
-	rc = of_property_read_u32(pdev->dev.of_node,
-		"qcom,msm-cpudai-tdm-data-align",
-		&dai_data->port_cfg.slot_mapping.data_align_type);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
-			__func__,
-			"qcom,msm-cpudai-tdm-data-align");
-		goto free_dai_data;
-	}
-	dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
-		__func__, dai_data->port_cfg.slot_mapping.data_align_type);
-
-	/* TDM SLOT MAPPING CFG -- set default */
-	dai_data->port_cfg.slot_mapping.minor_version =
-		AFE_API_VERSION_SLOT_MAPPING_CONFIG;
-
-	/* CUSTOM TDM HEADER CFG */
-	custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
-	if (of_find_property(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
-		of_find_property(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-width", NULL) &&
-		of_find_property(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
-		/* if the property exist */
-		rc = of_property_read_u32(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-start-offset",
-			(u32 *)&custom_tdm_header->start_offset);
-		if (rc) {
-			dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
-				__func__,
-				"qcom,msm-cpudai-tdm-header-start-offset");
-			goto free_dai_data;
-		}
-		dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
-			__func__, custom_tdm_header->start_offset);
-
-		rc = of_property_read_u32(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-width",
-			(u32 *)&custom_tdm_header->header_width);
-		if (rc) {
-			dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
-				__func__, "qcom,msm-cpudai-tdm-header-width");
-			goto free_dai_data;
-		}
-		dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
-			__func__, custom_tdm_header->header_width);
-
-		rc = of_property_read_u32(pdev->dev.of_node,
-			"qcom,msm-cpudai-tdm-header-num-frame-repeat",
-			(u32 *)&custom_tdm_header->num_frame_repeat);
-		if (rc) {
-			dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
-				__func__,
-				"qcom,msm-cpudai-tdm-header-num-frame-repeat");
-			goto free_dai_data;
-		}
-		dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
-			__func__, custom_tdm_header->num_frame_repeat);
-
-		/* CUSTOM TDM HEADER CFG -- set default */
-		custom_tdm_header->minor_version =
-			AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
-		custom_tdm_header->header_type =
-			AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
-	} else {
-		dev_info(&pdev->dev,
-			"%s: Custom tdm header not supported\n", __func__);
-		/* CUSTOM TDM HEADER CFG -- set default */
-		custom_tdm_header->header_type =
-			AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
-		/* proceed with probe */
-	}
-
-	/* copy static clk per parent node */
-	dai_data->clk_set = tdm_clk_set;
-	/* copy static group cfg per parent node */
-	dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
-	/* copy static num group ports per parent node */
-	dai_data->num_group_ports = num_tdm_group_ports;
-
-
-	dev_set_drvdata(&pdev->dev, dai_data);
-
-	port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
-	if (port_idx < 0) {
-		dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
-			__func__, tdm_dev_id);
-		rc = -EINVAL;
-		goto free_dai_data;
-	}
-
-	rc = snd_soc_register_component(&pdev->dev,
-		&msm_q6_tdm_dai_component,
-		&msm_dai_q6_tdm_dai[port_idx], 1);
-
-	if (rc) {
-		dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
-			__func__, tdm_dev_id, rc);
-		goto err_register;
-	}
-
-	return 0;
-
-err_register:
-free_dai_data:
-	kfree(dai_data);
-rtn:
-	return rc;
-}
-
-static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
-{
-	struct msm_dai_q6_tdm_dai_data *dai_data =
-		dev_get_drvdata(&pdev->dev);
-
-	snd_soc_unregister_component(&pdev->dev);
-
-	kfree(dai_data);
-
-	return 0;
-}
-
-static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-q6-tdm", },
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
-
-static struct platform_driver msm_dai_q6_tdm_driver = {
-	.probe  = msm_dai_q6_tdm_dev_probe,
-	.remove  = msm_dai_q6_tdm_dev_remove,
-	.driver = {
-		.name = "msm-dai-q6-tdm",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_q6_tdm_dev_dt_match,
-	},
-};
-
-static int __init msm_dai_q6_init(void)
-{
-	int rc;
-
-	rc = platform_driver_register(&msm_auxpcm_dev_driver);
-	if (rc) {
-		pr_err("%s: fail to register auxpcm dev driver", __func__);
-		goto fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_q6);
-	if (rc) {
-		pr_err("%s: fail to register dai q6 driver", __func__);
-		goto dai_q6_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_q6_dev);
-	if (rc) {
-		pr_err("%s: fail to register dai q6 dev driver", __func__);
-		goto dai_q6_dev_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
-	if (rc) {
-		pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
-		goto dai_q6_mi2s_drv_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_mi2s_q6);
-	if (rc) {
-		pr_err("%s: fail to register dai MI2S\n", __func__);
-		goto dai_mi2s_q6_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_q6_spdif_driver);
-	if (rc) {
-		pr_err("%s: fail to register dai SPDIF\n", __func__);
-		goto dai_spdif_q6_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_q6_tdm_driver);
-	if (rc) {
-		pr_err("%s: fail to register dai TDM dev drv\n", __func__);
-		goto dai_q6_tdm_drv_fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_tdm_q6);
-	if (rc) {
-		pr_err("%s: fail to register dai TDM\n", __func__);
-		goto dai_tdm_q6_fail;
-	}
-	return rc;
-
-dai_tdm_q6_fail:
-	platform_driver_unregister(&msm_dai_q6_tdm_driver);
-dai_q6_tdm_drv_fail:
-	platform_driver_unregister(&msm_dai_q6_spdif_driver);
-dai_spdif_q6_fail:
-	platform_driver_unregister(&msm_dai_mi2s_q6);
-dai_mi2s_q6_fail:
-	platform_driver_unregister(&msm_dai_q6_mi2s_driver);
-dai_q6_mi2s_drv_fail:
-	platform_driver_unregister(&msm_dai_q6_dev);
-dai_q6_dev_fail:
-	platform_driver_unregister(&msm_dai_q6);
-dai_q6_fail:
-	platform_driver_unregister(&msm_auxpcm_dev_driver);
-fail:
-	return rc;
-}
-module_init(msm_dai_q6_init);
-
-static void __exit msm_dai_q6_exit(void)
-{
-	platform_driver_unregister(&msm_dai_q6_dev);
-	platform_driver_unregister(&msm_dai_q6);
-	platform_driver_unregister(&msm_auxpcm_dev_driver);
-	platform_driver_unregister(&msm_dai_q6_spdif_driver);
-}
-module_exit(msm_dai_q6_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("MSM DSP DAI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-slim.c b/sound/soc/msm/qdsp6v2/msm-dai-slim.c
deleted file mode 100644
index 8115fee..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dai-slim.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/bitops.h>
-#include <linux/slimbus/slimbus.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/msm-slim-dma.h>
-
-#define SLIM_DEV_NAME "msm-dai-slim"
-
-#define SLIM_DAI_RATES (SNDRV_PCM_RATE_48000 | \
-			SNDRV_PCM_RATE_8000 | \
-			SNDRV_PCM_RATE_16000 | \
-			SNDRV_PCM_RATE_96000 | \
-			SNDRV_PCM_RATE_192000 | \
-			SNDRV_PCM_RATE_384000)
-
-#define SLIM_DAI_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
-			  SNDRV_PCM_FMTBIT_S24_LE | \
-			  SNDRV_PCM_FMTBIT_S32_LE)
-
-#define DAI_STATE_INITIALIZED (0x01 << 0)
-#define DAI_STATE_PREPARED (0x01 << 1)
-#define DAI_STATE_RUNNING (0x01 << 2)
-
-#define SET_DAI_STATE(status, state) \
-	(status |= state)
-
-#define CLR_DAI_STATE(status, state) \
-	(status = status & (~state))
-
-enum {
-	MSM_DAI_SLIM0 = 0,
-	NUM_SLIM_DAIS,
-};
-
-struct msm_slim_dai_data {
-	unsigned int dai_id;
-	u16 *chan_h;
-	u16 *sh_ch;
-	u16 grph;
-	u32 rate;
-	u16 bits;
-	u16 ch_cnt;
-	u8 status;
-	struct snd_soc_dai_driver *dai_drv;
-	struct msm_slim_dma_data dma_data;
-	struct slim_port_cfg port_cfg;
-};
-
-struct msm_dai_slim_drv_data {
-	struct slim_device *sdev;
-	u16 num_dais;
-	struct msm_slim_dai_data slim_dai_data[NUM_SLIM_DAIS];
-};
-
-struct msm_slim_dai_data *msm_slim_get_dai_data(
-	struct msm_dai_slim_drv_data *drv_data,
-	struct snd_soc_dai *dai)
-{
-	struct msm_slim_dai_data *dai_data_t;
-	int i;
-
-	for (i = 0; i < drv_data->num_dais; i++) {
-		dai_data_t = &drv_data->slim_dai_data[i];
-		if (dai_data_t->dai_id == dai->id)
-			return dai_data_t;
-	}
-
-	dev_err(dai->dev,
-		"%s: no dai data found for dai_id %d\n",
-		__func__, dai->id);
-	return NULL;
-}
-
-static int msm_dai_slim_ch_ctl(struct msm_slim_dma_data *dma_data,
-	struct snd_soc_dai *dai, bool enable)
-{
-	struct slim_device *sdev;
-	struct msm_dai_slim_drv_data *drv_data;
-	struct msm_slim_dai_data *dai_data;
-	int rc, rc1, i;
-
-	if (!dma_data || !dma_data->sdev) {
-		pr_err("%s: Invalid %s\n", __func__,
-		       (!dma_data) ? "dma_data" : "slim_device");
-		return -EINVAL;
-	}
-
-	sdev = dma_data->sdev;
-	drv_data = dev_get_drvdata(&sdev->dev);
-	dai_data = msm_slim_get_dai_data(drv_data, dai);
-
-	if (!dai_data) {
-		dev_err(dai->dev,
-			"%s: Invalid dai_data for dai_id %d\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	dev_dbg(&sdev->dev,
-		"%s: enable = %s, rate = %u\n", __func__,
-		enable ? "true" : "false",
-		dai_data->rate);
-
-	if (enable) {
-		if (!(dai_data->status & DAI_STATE_PREPARED)) {
-			dev_err(&sdev->dev,
-				"%s: dai id (%d) has invalid state 0x%x\n",
-				__func__, dai->id, dai_data->status);
-			return -EINVAL;
-		}
-
-		rc = slim_alloc_mgrports(sdev,
-					 SLIM_REQ_DEFAULT, dai_data->ch_cnt,
-					 &(dma_data->ph),
-					 sizeof(dma_data->ph));
-		if (rc < 0) {
-			dev_err(&sdev->dev,
-				"%s:alloc mgrport failed rc %d\n",
-				__func__, rc);
-			goto done;
-		}
-
-		rc = slim_config_mgrports(sdev, &(dma_data->ph),
-					  dai_data->ch_cnt,
-					  &(dai_data->port_cfg));
-		if (rc < 0) {
-			dev_err(&sdev->dev,
-				"%s: config mgrport failed rc %d\n",
-				__func__, rc);
-			goto err_done;
-		}
-
-		for (i = 0; i < dai_data->ch_cnt; i++) {
-			rc = slim_connect_sink(sdev,
-					       &dma_data->ph, 1,
-					       dai_data->chan_h[i]);
-			if (rc < 0) {
-				dev_err(&sdev->dev,
-					"%s: slim_connect_sink failed, ch = %d, err = %d\n",
-					__func__, i, rc);
-				goto err_done;
-			}
-		}
-
-		rc = slim_control_ch(sdev,
-				     dai_data->grph,
-				     SLIM_CH_ACTIVATE, true);
-		if (rc < 0) {
-			dev_err(&sdev->dev,
-				"%s: slim activate ch failed, err = %d\n",
-				__func__, rc);
-			goto err_done;
-		}
-		/* Mark dai status as running */
-		SET_DAI_STATE(dai_data->status, DAI_STATE_RUNNING);
-	} else {
-		if (!(dai_data->status & DAI_STATE_RUNNING)) {
-			dev_err(&sdev->dev,
-				"%s: dai id (%d) has invalid state 0x%x\n",
-				__func__, dai->id, dai_data->status);
-			return -EINVAL;
-		}
-
-		rc = slim_control_ch(sdev,
-				     dai_data->grph,
-				     SLIM_CH_REMOVE, true);
-		if (rc < 0) {
-			dev_err(&sdev->dev,
-				"%s: slim activate ch failed, err = %d\n",
-				__func__, rc);
-			goto done;
-		}
-
-		rc = slim_dealloc_mgrports(sdev,
-					   &dma_data->ph, 1);
-		if (rc < 0) {
-			dev_err(&sdev->dev,
-				"%s: dealloc mgrport failed, err = %d\n",
-				__func__, rc);
-			goto done;
-		}
-		/* clear running state for dai*/
-		CLR_DAI_STATE(dai_data->status, DAI_STATE_RUNNING);
-	}
-
-	return rc;
-
-err_done:
-	rc1 = slim_dealloc_mgrports(sdev,
-				   &dma_data->ph, 1);
-	if (rc1 < 0)
-		dev_err(&sdev->dev,
-			"%s: dealloc mgrport failed, err = %d\n",
-			__func__, rc1);
-done:
-	return rc;
-}
-
-static int msm_dai_slim_hw_params(
-		struct snd_pcm_substream *substream,
-		struct snd_pcm_hw_params *params,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
-	struct msm_slim_dai_data *dai_data;
-	int rc = 0;
-
-	dai_data = msm_slim_get_dai_data(drv_data, dai);
-	if (!dai_data) {
-		dev_err(dai->dev,
-			"%s: Invalid dai_data for dai_id %d\n",
-			__func__, dai->id);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (!dai_data->ch_cnt || dai_data->ch_cnt != params_channels(params)) {
-		dev_err(dai->dev, "%s: invalid ch_cnt %d %d\n",
-			__func__, dai_data->ch_cnt, params_channels(params));
-		rc = -EINVAL;
-		goto done;
-	}
-
-	dai_data->rate = params_rate(params);
-	dai_data->port_cfg.port_opts = SLIM_OPT_NONE;
-	if (dai_data->rate >= SNDRV_PCM_RATE_48000)
-		dai_data->port_cfg.watermark = 16;
-	else
-		dai_data->port_cfg.watermark = 8;
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		dai_data->bits = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		dai_data->bits = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		dai_data->bits = 32;
-		break;
-	default:
-		dev_err(dai->dev, "%s: invalid format %d\n", __func__,
-			params_format(params));
-		rc = -EINVAL;
-		goto done;
-	}
-
-	dev_dbg(dai->dev, "%s: ch_cnt=%u rate=%u, bit_width = %u\n",
-		__func__, dai_data->ch_cnt, dai_data->rate,
-		dai_data->bits);
-done:
-	return rc;
-}
-
-static int msm_dai_slim_set_channel_map(struct snd_soc_dai *dai,
-	unsigned int tx_num, unsigned int *tx_slot,
-	unsigned int rx_num, unsigned int *rx_slot)
-{
-	struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
-	struct msm_slim_dai_data *dai_data;
-	struct snd_soc_dai_driver *dai_drv;
-	u8 i = 0;
-
-	dev_dbg(dai->dev,
-		"%s: tx_num=%u, rx_num=%u\n",
-		__func__, tx_num, rx_num);
-
-	dai_data = msm_slim_get_dai_data(drv_data, dai);
-	if (!dai_data) {
-		dev_err(dai->dev,
-			"%s: Invalid dai_data for dai_id %d\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	dai_drv = dai_data->dai_drv;
-
-	if (tx_num > dai_drv->capture.channels_max) {
-		dev_err(dai->dev, "%s: tx_num %u max out master port cnt\n",
-			__func__, tx_num);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < tx_num; i++)
-		dai_data->sh_ch[i] = tx_slot[i];
-
-	dai_data->ch_cnt = tx_num;
-	return 0;
-}
-
-static int msm_dai_slim_prepare(struct snd_pcm_substream *substream,
-				   struct snd_soc_dai *dai)
-{
-	struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
-	struct msm_slim_dma_data *dma_data;
-	struct msm_slim_dai_data *dai_data = NULL;
-	struct slim_ch prop;
-	int rc;
-	u8 i, j;
-
-	dai_data = msm_slim_get_dai_data(drv_data, dai);
-	if (!dai_data) {
-		dev_err(dai->dev,
-			"%s: Invalid dai_data for dai %d\n",
-			__func__, dai->id);
-		return -EINVAL;
-	}
-
-	if (!(dai_data->status & DAI_STATE_INITIALIZED)) {
-		dev_err(dai->dev,
-			"%s: dai id (%d) has invalid state 0x%x\n",
-			__func__, dai->id, dai_data->status);
-		return -EINVAL;
-	}
-
-	if (dai_data->status & DAI_STATE_PREPARED) {
-		dev_dbg(dai->dev,
-			"%s: dai id (%d) has already prepared.\n",
-			__func__, dai->id);
-		return 0;
-	}
-
-	dma_data = &dai_data->dma_data;
-	snd_soc_dai_set_dma_data(dai, substream, dma_data);
-
-	for (i = 0; i < dai_data->ch_cnt; i++) {
-		rc = slim_query_ch(drv_data->sdev, dai_data->sh_ch[i],
-				   &dai_data->chan_h[i]);
-		if (rc) {
-			dev_err(dai->dev, "%s:query chan handle failed rc %d\n",
-				__func__, rc);
-			goto error_chan_query;
-		}
-	}
-
-	prop.prot = SLIM_AUTO_ISO;
-	prop.baser = SLIM_RATE_4000HZ;
-	prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
-	prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
-	prop.ratem = (dai_data->rate/4000);
-	prop.sampleszbits = dai_data->bits;
-
-	rc = slim_define_ch(drv_data->sdev, &prop, dai_data->chan_h,
-			    dai_data->ch_cnt, true, &dai_data->grph);
-
-	if (rc) {
-		dev_err(dai->dev, "%s:define chan failed rc %d\n",
-				__func__, rc);
-		goto error_define_chan;
-	}
-
-	/* Mark stream status as prepared */
-	SET_DAI_STATE(dai_data->status, DAI_STATE_PREPARED);
-
-	return rc;
-
-error_define_chan:
-error_chan_query:
-	for (j = 0; j < i; j++)
-		slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[j]);
-	return rc;
-}
-
-static void msm_dai_slim_shutdown(struct snd_pcm_substream *stream,
-		struct snd_soc_dai *dai)
-{
-	struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev);
-	struct msm_slim_dma_data *dma_data = NULL;
-	struct msm_slim_dai_data *dai_data;
-	int i, rc = 0;
-
-	dai_data = msm_slim_get_dai_data(drv_data, dai);
-	dma_data = snd_soc_dai_get_dma_data(dai, stream);
-	if (!dma_data || !dai_data) {
-		dev_err(dai->dev,
-			"%s: Invalid %s\n", __func__,
-			(!dma_data) ? "dma_data" : "dai_data");
-		return;
-	}
-
-	if ((!(dai_data->status & DAI_STATE_PREPARED)) ||
-	     dai_data->status & DAI_STATE_RUNNING) {
-		dev_err(dai->dev,
-			"%s: dai id (%d) has invalid state 0x%x\n",
-			__func__, dai->id, dai_data->status);
-		return;
-	}
-
-	for (i = 0; i < dai_data->ch_cnt; i++) {
-		rc = slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[i]);
-		if (rc) {
-			dev_err(dai->dev,
-				"%s: dealloc_ch failed, err = %d\n",
-				__func__, rc);
-		}
-	}
-
-	snd_soc_dai_set_dma_data(dai, stream, NULL);
-	/* clear prepared state for the dai */
-	CLR_DAI_STATE(dai_data->status, DAI_STATE_PREPARED);
-}
-
-static const struct snd_soc_component_driver msm_dai_slim_component = {
-	.name		= "msm-dai-slim-cmpnt",
-};
-
-static struct snd_soc_dai_ops msm_dai_slim_ops = {
-	.prepare	= msm_dai_slim_prepare,
-	.hw_params	= msm_dai_slim_hw_params,
-	.shutdown	= msm_dai_slim_shutdown,
-	.set_channel_map = msm_dai_slim_set_channel_map,
-};
-
-static struct snd_soc_dai_driver msm_slim_dais[] = {
-	{
-		/*
-		 * The first dai name should be same as device name
-		 * to support registering single and multile dais.
-		 */
-		.name = SLIM_DEV_NAME,
-		.id = MSM_DAI_SLIM0,
-		.capture = {
-			.rates = SLIM_DAI_RATES,
-			.formats = SLIM_DAI_FORMATS,
-			.channels_min = 1,
-			/*
-			 * max channels allowed is
-			 * dependent on platform and
-			 * will be updated before this
-			 * dai driver is registered.
-			 */
-			.channels_max = 1,
-			.rate_min = 8000,
-			.rate_max = 384000,
-			.stream_name = "SLIM_DAI0 Capture",
-		},
-		.ops = &msm_dai_slim_ops,
-	},
-	/*
-	 * If multiple dais are needed,
-	 * add dais here and update the
-	 * dai_id enum.
-	 */
-};
-
-static void msm_dai_slim_remove_dai_data(
-		struct device *dev,
-		struct msm_dai_slim_drv_data *drv_data)
-{
-	int i;
-	struct msm_slim_dai_data *dai_data_t;
-
-	for (i = 0; i < drv_data->num_dais; i++) {
-		dai_data_t = &drv_data->slim_dai_data[i];
-
-		kfree(dai_data_t->chan_h);
-		dai_data_t->chan_h = NULL;
-		kfree(dai_data_t->sh_ch);
-		dai_data_t->sh_ch = NULL;
-	}
-}
-
-static int msm_dai_slim_populate_dai_data(struct device *dev,
-		struct msm_dai_slim_drv_data *drv_data)
-{
-	struct snd_soc_dai_driver *dai_drv;
-	struct msm_slim_dai_data *dai_data_t;
-	u8 num_ch;
-	int i, j, rc;
-
-	for (i = 0; i < drv_data->num_dais; i++) {
-		num_ch = 0;
-		dai_drv = &msm_slim_dais[i];
-		num_ch += dai_drv->capture.channels_max;
-		num_ch += dai_drv->playback.channels_max;
-
-		dai_data_t = &drv_data->slim_dai_data[i];
-		dai_data_t->dai_drv = dai_drv;
-		dai_data_t->dai_id = dai_drv->id;
-		dai_data_t->dma_data.sdev = drv_data->sdev;
-		dai_data_t->dma_data.dai_channel_ctl =
-				msm_dai_slim_ch_ctl;
-		SET_DAI_STATE(dai_data_t->status,
-			      DAI_STATE_INITIALIZED);
-
-		dai_data_t->chan_h = devm_kzalloc(dev,
-					sizeof(u16) * num_ch,
-					GFP_KERNEL);
-		if (!dai_data_t->chan_h) {
-			dev_err(dev,
-				"%s: DAI ID %d, Failed to alloc channel handles\n",
-				__func__, i);
-			rc = -ENOMEM;
-			goto err_mem_alloc;
-		}
-
-		dai_data_t->sh_ch = devm_kzalloc(dev,
-					sizeof(u16) * num_ch,
-					GFP_KERNEL);
-		if (!dai_data_t->sh_ch) {
-			dev_err(dev,
-				"%s: DAI ID %d, Failed to alloc sh_ch\n",
-				__func__, i);
-			rc = -ENOMEM;
-			goto err_mem_alloc;
-		}
-	}
-	return 0;
-
-err_mem_alloc:
-	for (j = 0; j < i; j++) {
-		dai_data_t = &drv_data->slim_dai_data[i];
-
-		devm_kfree(dev, dai_data_t->chan_h);
-		dai_data_t->chan_h = NULL;
-
-		devm_kfree(dev, dai_data_t->sh_ch);
-		dai_data_t->sh_ch = NULL;
-	}
-	return rc;
-}
-
-static int msm_dai_slim_dev_probe(struct slim_device *sdev)
-{
-	int rc, i;
-	u8 max_channels;
-	u32 apps_ch_pipes;
-	struct msm_dai_slim_drv_data *drv_data;
-	struct device *dev = &sdev->dev;
-	struct snd_soc_dai_driver *dai_drv;
-
-	if (!dev->of_node ||
-	    !dev->of_node->parent) {
-		dev_err(dev,
-			"%s: Invalid %s\n", __func__,
-			(!dev->of_node) ? "of_node" : "parent_of_node");
-		return -EINVAL;
-	}
-
-	rc = of_property_read_u32(dev->of_node->parent,
-					 "qcom,apps-ch-pipes",
-					 &apps_ch_pipes);
-	if (rc) {
-		dev_err(dev,
-			"%s: Failed to lookup property %s in node %s, err = %d\n",
-			__func__, "qcom,apps-ch-pipes",
-			dev->of_node->parent->full_name, rc);
-		goto err_ret;
-	}
-
-	max_channels = hweight_long(apps_ch_pipes);
-	if (max_channels <= 0) {
-		dev_err(dev,
-			"%s: Invalid apps owned ports %d\n",
-			__func__, max_channels);
-		goto err_ret;
-	}
-
-	dev_dbg(dev, "%s: max channels = %u\n",
-		__func__, max_channels);
-
-	for (i = 0; i < ARRAY_SIZE(msm_slim_dais); i++) {
-		dai_drv = &msm_slim_dais[i];
-		dai_drv->capture.channels_max = max_channels;
-		dai_drv->playback.channels_max = max_channels;
-	}
-
-	drv_data = devm_kzalloc(dev, sizeof(*drv_data),
-				GFP_KERNEL);
-	if (!drv_data) {
-		rc = -ENOMEM;
-		goto err_ret;
-	}
-
-	drv_data->sdev = sdev;
-	drv_data->num_dais = NUM_SLIM_DAIS;
-
-	rc = msm_dai_slim_populate_dai_data(dev, drv_data);
-	if (rc) {
-		dev_err(dev,
-			"%s: failed to setup dai_data, err = %d\n",
-			__func__, rc);
-		goto err_populate_dai;
-	}
-
-	rc = snd_soc_register_component(&sdev->dev, &msm_dai_slim_component,
-					msm_slim_dais, NUM_SLIM_DAIS);
-	if (rc < 0) {
-		dev_err(dev, "%s: failed to register DAI, err = %d\n",
-			__func__, rc);
-		goto err_reg_comp;
-	}
-
-	dev_set_drvdata(dev, drv_data);
-	return rc;
-
-err_reg_comp:
-	msm_dai_slim_remove_dai_data(dev, drv_data);
-
-err_populate_dai:
-	devm_kfree(dev, drv_data);
-
-err_ret:
-	return rc;
-}
-
-static int msm_dai_slim_dev_remove(struct slim_device *sdev)
-{
-	snd_soc_unregister_component(&sdev->dev);
-	return 0;
-}
-
-static const struct slim_device_id msm_dai_slim_dt_match[] = {
-	{SLIM_DEV_NAME, 0 },
-	{}
-};
-
-static struct slim_driver msm_dai_slim_driver = {
-	.driver = {
-		.name = SLIM_DEV_NAME,
-		.owner = THIS_MODULE,
-	},
-	.probe = msm_dai_slim_dev_probe,
-	.remove = msm_dai_slim_dev_remove,
-	.id_table = msm_dai_slim_dt_match,
-};
-
-static int __init msm_dai_slim_init(void)
-{
-	int rc;
-
-	rc = slim_driver_register(&msm_dai_slim_driver);
-	if (rc)
-		pr_err("%s: failed to register with slimbus driver rc = %d",
-			__func__, rc);
-	return rc;
-}
-module_init(msm_dai_slim_init);
-
-static void __exit msm_dai_slim_exit(void)
-{
-}
-module_exit(msm_dai_slim_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("Slimbus apps-owned channel handling driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-stub-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-stub-v2.c
deleted file mode 100644
index 3a2c3d3..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dai-stub-v2.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/* Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/of_device.h>
-#include <linux/platform_device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-
-enum {
-	STUB_RX,
-	STUB_TX,
-	STUB_1_RX,
-	STUB_1_TX,
-	STUB_DTMF_TX,
-	STUB_HOST_RX_CAPTURE_TX,
-	STUB_HOST_RX_PLAYBACK_RX,
-	STUB_HOST_TX_CAPTURE_TX,
-	STUB_HOST_TX_PLAYBACK_RX,
-};
-
-static int msm_dai_stub_set_channel_map(struct snd_soc_dai *dai,
-		unsigned int tx_num, unsigned int *tx_slot,
-		unsigned int rx_num, unsigned int *rx_slot)
-{
-	pr_debug("%s:\n", __func__);
-
-	return 0;
-}
-
-static struct snd_soc_dai_ops msm_dai_stub_ops = {
-	.set_channel_map = msm_dai_stub_set_channel_map,
-};
-
-static int msm_dai_stub_add_route(struct snd_soc_dai *dai)
-{
-	struct snd_soc_dapm_route intercon;
-	struct snd_soc_dapm_context *dapm;
-
-	if (!dai || !dai->driver) {
-		pr_err("%s Invalid params\n", __func__);
-		return -EINVAL;
-	}
-	dapm = snd_soc_component_get_dapm(dai->component);
-	memset(&intercon, 0, sizeof(intercon));
-	if (dai->driver->playback.stream_name &&
-		dai->driver->playback.aif_name) {
-		dev_dbg(dai->dev, "%s add route for widget %s",
-			__func__, dai->driver->playback.stream_name);
-		intercon.source = dai->driver->playback.aif_name;
-		intercon.sink = dai->driver->playback.stream_name;
-		dev_dbg(dai->dev, "%s src %s sink %s\n",
-			__func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-	}
-	if (dai->driver->capture.stream_name &&
-		dai->driver->capture.aif_name) {
-		dev_dbg(dai->dev, "%s add route for widget %s",
-			__func__, dai->driver->capture.stream_name);
-		intercon.sink = dai->driver->capture.aif_name;
-		intercon.source = dai->driver->capture.stream_name;
-		dev_dbg(dai->dev, "%s src %s sink %s\n",
-			__func__, intercon.source, intercon.sink);
-		snd_soc_dapm_add_routes(dapm, &intercon, 1);
-	}
-	return 0;
-}
-
-static int msm_dai_stub_dai_probe(struct snd_soc_dai *dai)
-{
-	return msm_dai_stub_add_route(dai);
-}
-
-static int msm_dai_stub_dai_remove(struct snd_soc_dai *dai)
-{
-	pr_debug("%s:\n", __func__);
-	return 0;
-}
-
-static struct snd_soc_dai_driver msm_dai_stub_dai_rx = {
-	.playback = {
-		.stream_name = "Stub Playback",
-		.aif_name = "STUB_RX",
-		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 1,
-		.channels_max = 2,
-		.rate_min = 8000,
-		.rate_max = 48000,
-	},
-	.ops = &msm_dai_stub_ops,
-	.probe = &msm_dai_stub_dai_probe,
-	.remove = &msm_dai_stub_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_stub_dai_tx[] = {
-	{
-		.capture = {
-			.stream_name = "Stub Capture",
-			.aif_name = "STUB_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "Stub1 Capture",
-			.aif_name = "STUB_1_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	}
-};
-
-static struct snd_soc_dai_driver msm_dai_stub_dtmf_tx_dai = {
-	.capture = {
-		.stream_name = "DTMF TX",
-		.aif_name = "STUB_DTMF_TX",
-		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-			 SNDRV_PCM_RATE_16000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.channels_min = 1,
-		.channels_max = 2,
-		.rate_min = 8000,
-		.rate_max = 48000,
-	},
-	.ops = &msm_dai_stub_ops,
-	.probe = &msm_dai_stub_dai_probe,
-	.remove = &msm_dai_stub_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_stub_host_capture_tx_dai[] = {
-	{
-		.capture = {
-			.stream_name = "CS-VOICE HOST RX CAPTURE",
-			.aif_name = "STUB_HOST_RX_CAPTURE_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	},
-	{
-		.capture = {
-			.stream_name = "CS-VOICE HOST TX CAPTURE",
-			.aif_name = "STUB_HOST_TX_CAPTURE_TX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	},
-};
-
-static struct snd_soc_dai_driver msm_dai_stub_host_playback_rx_dai[] = {
-	{
-		.playback = {
-			.stream_name = "CS-VOICE HOST RX PLAYBACK",
-			.aif_name = "STUB_HOST_RX_PLAYBACK_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				 SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	},
-	{
-		.playback = {
-			.stream_name = "CS-VOICE HOST TX PLAYBACK",
-			.aif_name = "STUB_HOST_TX_PLAYBACK_RX",
-			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
-				 SNDRV_PCM_RATE_16000,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
-			.channels_min = 1,
-			.channels_max = 2,
-			.rate_min = 8000,
-			.rate_max = 48000,
-		},
-		.ops = &msm_dai_stub_ops,
-		.probe = &msm_dai_stub_dai_probe,
-		.remove = &msm_dai_stub_dai_remove,
-	},
-};
-
-static const struct snd_soc_component_driver msm_dai_stub_component = {
-	.name		= "msm-dai-stub-dev",
-};
-
-static int msm_dai_stub_dev_probe(struct platform_device *pdev)
-{
-	int rc, id = -1;
-	const char *stub_dev_id = "qcom,msm-dai-stub-dev-id";
-
-	rc = of_property_read_u32(pdev->dev.of_node, stub_dev_id, &id);
-	if (rc) {
-		dev_err(&pdev->dev,
-			"%s: missing %s in dt node\n", __func__, stub_dev_id);
-		return rc;
-	}
-
-	pdev->id = id;
-
-	pr_debug("%s: dev name %s, id:%d\n", __func__,
-		 dev_name(&pdev->dev), pdev->id);
-
-	switch (id) {
-	case STUB_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component, &msm_dai_stub_dai_rx, 1);
-		break;
-	case STUB_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component, &msm_dai_stub_dai_tx[0], 1);
-		break;
-	case STUB_1_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component, &msm_dai_stub_dai_tx[1], 1);
-		break;
-	case STUB_DTMF_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component,
-			&msm_dai_stub_dtmf_tx_dai, 1);
-		break;
-	case STUB_HOST_RX_CAPTURE_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component,
-			&msm_dai_stub_host_capture_tx_dai[0], 1);
-		break;
-	case STUB_HOST_TX_CAPTURE_TX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component,
-			&msm_dai_stub_host_capture_tx_dai[1], 1);
-		break;
-	case STUB_HOST_RX_PLAYBACK_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component,
-			&msm_dai_stub_host_playback_rx_dai[0], 1);
-		break;
-	case STUB_HOST_TX_PLAYBACK_RX:
-		rc = snd_soc_register_component(&pdev->dev,
-			&msm_dai_stub_component,
-			&msm_dai_stub_host_playback_rx_dai[1], 1);
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_dai_stub_dev_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_component(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_dai_stub_dev_dt_match[] = {
-	{ .compatible = "qcom,msm-dai-stub-dev", },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, msm_dai_stub_dev_dt_match);
-
-static struct platform_driver msm_dai_stub_dev = {
-	.probe  = msm_dai_stub_dev_probe,
-	.remove = msm_dai_stub_dev_remove,
-	.driver = {
-		.name = "msm-dai-stub-dev",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_stub_dev_dt_match,
-	},
-};
-
-static int msm_dai_stub_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-
-	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
-
-	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
-			__func__, rc);
-	} else
-		dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
-
-	return rc;
-}
-
-static int msm_dai_stub_remove(struct platform_device *pdev)
-{
-	pr_debug("%s:\n", __func__);
-
-	return 0;
-}
-
-static const struct of_device_id msm_dai_stub_dt_match[] = {
-	{.compatible = "qcom,msm-dai-stub"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_dai_stub_dt_match);
-
-
-static struct platform_driver msm_dai_stub_driver = {
-	.probe  = msm_dai_stub_probe,
-	.remove = msm_dai_stub_remove,
-	.driver = {
-		.name = "msm-dai-stub",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_dai_stub_dt_match,
-	},
-};
-
-static int __init msm_dai_stub_init(void)
-{
-	int rc = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	rc = platform_driver_register(&msm_dai_stub_driver);
-	if (rc) {
-		pr_err("%s: fail to register dai q6 driver", __func__);
-		goto fail;
-	}
-
-	rc = platform_driver_register(&msm_dai_stub_dev);
-	if (rc) {
-		pr_err("%s: fail to register dai q6 dev driver", __func__);
-		goto dai_stub_dev_fail;
-	}
-	return rc;
-
-dai_stub_dev_fail:
-	platform_driver_unregister(&msm_dai_stub_driver);
-fail:
-	return rc;
-}
-module_init(msm_dai_stub_init);
-
-static void __exit msm_dai_stub_exit(void)
-{
-	pr_debug("%s:\n", __func__);
-
-	platform_driver_unregister(&msm_dai_stub_dev);
-	platform_driver_unregister(&msm_dai_stub_driver);
-}
-module_exit(msm_dai_stub_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("MSM Stub DSP DAI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-dolby-common.h b/sound/soc/msm/qdsp6v2/msm-dolby-common.h
deleted file mode 100644
index f14e42e..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dolby-common.h
+++ /dev/null
@@ -1,266 +0,0 @@
-
-/* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_DOLBY_COMMON_H_
-#define _MSM_DOLBY_COMMON_H_
-
-#include <sound/soc.h>
-
-
-#define DOLBY_BUNDLE_MODULE_ID		0x00010723
-#define DOLBY_VISUALIZER_MODULE_ID	0x0001072B
-
-#define DOLBY_PARAM_ID_VDHE		0x0001074D
-#define DOLBY_PARAM_ID_VSPE		0x00010750
-#define DOLBY_PARAM_ID_DSSF		0x00010753
-#define DOLBY_PARAM_ID_DVLI		0x0001073E
-#define DOLBY_PARAM_ID_DVLO		0x0001073F
-#define DOLBY_PARAM_ID_DVLE		0x0001073C
-#define DOLBY_PARAM_ID_DVMC		0x00010741
-#define DOLBY_PARAM_ID_DVME		0x00010740
-#define DOLBY_PARAM_ID_IENB		0x00010744
-#define DOLBY_PARAM_ID_IEBF		0x00010745
-#define DOLBY_PARAM_ID_IEON		0x00010743
-#define DOLBY_PARAM_ID_DEON		0x00010738
-#define DOLBY_PARAM_ID_NGON		0x00010736
-#define DOLBY_PARAM_ID_GEON		0x00010748
-#define DOLBY_PARAM_ID_GENB		0x00010749
-#define DOLBY_PARAM_ID_GEBF		0x0001074A
-#define DOLBY_PARAM_ID_AONB		0x0001075B
-#define DOLBY_PARAM_ID_AOBF		0x0001075C
-#define DOLBY_PARAM_ID_AOBG		0x0001075D
-#define DOLBY_PARAM_ID_AOON		0x00010759
-#define DOLBY_PARAM_ID_ARNB		0x0001075F
-#define DOLBY_PARAM_ID_ARBF		0x00010760
-#define DOLBY_PARAM_ID_PLB		0x00010768
-#define DOLBY_PARAM_ID_PLMD		0x00010767
-#define DOLBY_PARAM_ID_DHSB		0x0001074E
-#define DOLBY_PARAM_ID_DHRG		0x0001074F
-#define DOLBY_PARAM_ID_DSSB		0x00010751
-#define DOLBY_PARAM_ID_DSSA		0x00010752
-#define DOLBY_PARAM_ID_DVLA		0x0001073D
-#define DOLBY_PARAM_ID_IEBT		0x00010746
-#define DOLBY_PARAM_ID_IEA		0x0001076A
-#define DOLBY_PARAM_ID_DEA		0x00010739
-#define DOLBY_PARAM_ID_DED		0x0001073A
-#define DOLBY_PARAM_ID_GEBG		0x0001074B
-#define DOLBY_PARAM_ID_AOCC		0x0001075A
-#define DOLBY_PARAM_ID_ARBI		0x00010761
-#define DOLBY_PARAM_ID_ARBL		0x00010762
-#define DOLBY_PARAM_ID_ARBH		0x00010763
-#define DOLBY_PARAM_ID_AROD		0x00010764
-#define DOLBY_PARAM_ID_ARTP		0x00010765
-#define DOLBY_PARAM_ID_VMON		0x00010756
-#define DOLBY_PARAM_ID_VMB		0x00010757
-#define DOLBY_PARAM_ID_VCNB		0x00010733
-#define DOLBY_PARAM_ID_VCBF		0x00010734
-#define DOLBY_PARAM_ID_PREG		0x00010728
-#define DOLBY_PARAM_ID_VEN		0x00010732
-#define DOLBY_PARAM_ID_PSTG		0x00010729
-#define DOLBY_PARAM_ID_INIT_ENDP	0x00010727
-
-/* Not Used with Set Param kcontrol, only to query using Get Param */
-#define DOLBY_PARAM_ID_VER		0x00010726
-
-#define DOLBY_PARAM_ID_VCBG		0x00010730
-#define DOLBY_PARAM_ID_VCBE		0x00010731
-
-/* DOLBY DAP control params */
-#define DOLBY_COMMIT_ALL_TO_DSP		0x70000001
-#define DOLBY_COMMIT_TO_DSP		0x70000002
-#define DOLBY_USE_CACHE			0x70000003
-#define DOLBY_AUTO_ENDP			0x70000004
-#define DOLBY_AUTO_ENDDEP_PARAMS	0x70000005
-#define DOLBY_DAP_BYPASS		0x70000006
-
-#define DOLBY_ENABLE_CUSTOM_STEREO	0x000108c7
-
-/* DOLBY DAP offsets start */
-#define DOLBY_PARAM_VDHE_LENGTH   1
-#define DOLBY_PARAM_VDHE_OFFSET   0
-#define DOLBY_PARAM_VSPE_LENGTH   1
-#define DOLBY_PARAM_VSPE_OFFSET   (DOLBY_PARAM_VDHE_OFFSET + \
-					DOLBY_PARAM_VDHE_LENGTH)
-#define DOLBY_PARAM_DSSF_LENGTH   1
-#define DOLBY_PARAM_DSSF_OFFSET   (DOLBY_PARAM_VSPE_OFFSET + \
-					DOLBY_PARAM_VSPE_LENGTH)
-#define DOLBY_PARAM_DVLI_LENGTH   1
-#define DOLBY_PARAM_DVLI_OFFSET   (DOLBY_PARAM_DSSF_OFFSET + \
-					DOLBY_PARAM_DSSF_LENGTH)
-#define DOLBY_PARAM_DVLO_LENGTH   1
-#define DOLBY_PARAM_DVLO_OFFSET   (DOLBY_PARAM_DVLI_OFFSET + \
-					DOLBY_PARAM_DVLI_LENGTH)
-#define DOLBY_PARAM_DVLE_LENGTH   1
-#define DOLBY_PARAM_DVLE_OFFSET   (DOLBY_PARAM_DVLO_OFFSET + \
-					DOLBY_PARAM_DVLO_LENGTH)
-#define DOLBY_PARAM_DVMC_LENGTH   1
-#define DOLBY_PARAM_DVMC_OFFSET   (DOLBY_PARAM_DVLE_OFFSET + \
-					DOLBY_PARAM_DVLE_LENGTH)
-#define DOLBY_PARAM_DVME_LENGTH   1
-#define DOLBY_PARAM_DVME_OFFSET   (DOLBY_PARAM_DVMC_OFFSET + \
-					DOLBY_PARAM_DVMC_LENGTH)
-#define DOLBY_PARAM_IENB_LENGTH   1
-#define DOLBY_PARAM_IENB_OFFSET   (DOLBY_PARAM_DVME_OFFSET + \
-					DOLBY_PARAM_DVME_LENGTH)
-#define DOLBY_PARAM_IEBF_LENGTH   40
-#define DOLBY_PARAM_IEBF_OFFSET   (DOLBY_PARAM_IENB_OFFSET + \
-					DOLBY_PARAM_IENB_LENGTH)
-#define DOLBY_PARAM_IEON_LENGTH   1
-#define DOLBY_PARAM_IEON_OFFSET   (DOLBY_PARAM_IEBF_OFFSET + \
-					DOLBY_PARAM_IEBF_LENGTH)
-#define DOLBY_PARAM_DEON_LENGTH   1
-#define DOLBY_PARAM_DEON_OFFSET   (DOLBY_PARAM_IEON_OFFSET + \
-					DOLBY_PARAM_IEON_LENGTH)
-#define DOLBY_PARAM_NGON_LENGTH   1
-#define DOLBY_PARAM_NGON_OFFSET   (DOLBY_PARAM_DEON_OFFSET + \
-					DOLBY_PARAM_DEON_LENGTH)
-#define DOLBY_PARAM_GEON_LENGTH   1
-#define DOLBY_PARAM_GEON_OFFSET   (DOLBY_PARAM_NGON_OFFSET + \
-					DOLBY_PARAM_NGON_LENGTH)
-#define DOLBY_PARAM_GENB_LENGTH   1
-#define DOLBY_PARAM_GENB_OFFSET   (DOLBY_PARAM_GEON_OFFSET + \
-					DOLBY_PARAM_GEON_LENGTH)
-#define DOLBY_PARAM_GEBF_LENGTH   40
-#define DOLBY_PARAM_GEBF_OFFSET   (DOLBY_PARAM_GENB_OFFSET + \
-					DOLBY_PARAM_GENB_LENGTH)
-#define DOLBY_PARAM_AONB_LENGTH   1
-#define DOLBY_PARAM_AONB_OFFSET   (DOLBY_PARAM_GEBF_OFFSET + \
-					DOLBY_PARAM_GEBF_LENGTH)
-#define DOLBY_PARAM_AOBF_LENGTH   40
-#define DOLBY_PARAM_AOBF_OFFSET   (DOLBY_PARAM_AONB_OFFSET + \
-					DOLBY_PARAM_AONB_LENGTH)
-#define DOLBY_PARAM_AOBG_LENGTH   329
-#define DOLBY_PARAM_AOBG_OFFSET   (DOLBY_PARAM_AOBF_OFFSET + \
-					DOLBY_PARAM_AOBF_LENGTH)
-#define DOLBY_PARAM_AOON_LENGTH   1
-#define DOLBY_PARAM_AOON_OFFSET   (DOLBY_PARAM_AOBG_OFFSET + \
-					DOLBY_PARAM_AOBG_LENGTH)
-#define DOLBY_PARAM_ARNB_LENGTH   1
-#define DOLBY_PARAM_ARNB_OFFSET   (DOLBY_PARAM_AOON_OFFSET + \
-					DOLBY_PARAM_AOON_LENGTH)
-#define DOLBY_PARAM_ARBF_LENGTH   40
-#define DOLBY_PARAM_ARBF_OFFSET   (DOLBY_PARAM_ARNB_OFFSET + \
-					DOLBY_PARAM_ARNB_LENGTH)
-#define DOLBY_PARAM_PLB_LENGTH    1
-#define DOLBY_PARAM_PLB_OFFSET    (DOLBY_PARAM_ARBF_OFFSET + \
-					DOLBY_PARAM_ARBF_LENGTH)
-#define DOLBY_PARAM_PLMD_LENGTH   1
-#define DOLBY_PARAM_PLMD_OFFSET   (DOLBY_PARAM_PLB_OFFSET + \
-					DOLBY_PARAM_PLB_LENGTH)
-#define DOLBY_PARAM_DHSB_LENGTH   1
-#define DOLBY_PARAM_DHSB_OFFSET   (DOLBY_PARAM_PLMD_OFFSET + \
-					DOLBY_PARAM_PLMD_LENGTH)
-#define DOLBY_PARAM_DHRG_LENGTH   1
-#define DOLBY_PARAM_DHRG_OFFSET   (DOLBY_PARAM_DHSB_OFFSET + \
-					DOLBY_PARAM_DHSB_LENGTH)
-#define DOLBY_PARAM_DSSB_LENGTH   1
-#define DOLBY_PARAM_DSSB_OFFSET   (DOLBY_PARAM_DHRG_OFFSET + \
-					DOLBY_PARAM_DHRG_LENGTH)
-#define DOLBY_PARAM_DSSA_LENGTH   1
-#define DOLBY_PARAM_DSSA_OFFSET   (DOLBY_PARAM_DSSB_OFFSET + \
-					DOLBY_PARAM_DSSB_LENGTH)
-#define DOLBY_PARAM_DVLA_LENGTH   1
-#define DOLBY_PARAM_DVLA_OFFSET   (DOLBY_PARAM_DSSA_OFFSET + \
-					DOLBY_PARAM_DSSA_LENGTH)
-#define DOLBY_PARAM_IEBT_LENGTH   40
-#define DOLBY_PARAM_IEBT_OFFSET   (DOLBY_PARAM_DVLA_OFFSET + \
-					DOLBY_PARAM_DVLA_LENGTH)
-#define DOLBY_PARAM_IEA_LENGTH    1
-#define DOLBY_PARAM_IEA_OFFSET    (DOLBY_PARAM_IEBT_OFFSET + \
-					DOLBY_PARAM_IEBT_LENGTH)
-#define DOLBY_PARAM_DEA_LENGTH    1
-#define DOLBY_PARAM_DEA_OFFSET    (DOLBY_PARAM_IEA_OFFSET + \
-					DOLBY_PARAM_IEA_LENGTH)
-#define DOLBY_PARAM_DED_LENGTH    1
-#define DOLBY_PARAM_DED_OFFSET    (DOLBY_PARAM_DEA_OFFSET + \
-					DOLBY_PARAM_DEA_LENGTH)
-#define DOLBY_PARAM_GEBG_LENGTH   40
-#define DOLBY_PARAM_GEBG_OFFSET   (DOLBY_PARAM_DED_OFFSET + \
-					DOLBY_PARAM_DED_LENGTH)
-#define DOLBY_PARAM_AOCC_LENGTH   1
-#define DOLBY_PARAM_AOCC_OFFSET   (DOLBY_PARAM_GEBG_OFFSET + \
-					DOLBY_PARAM_GEBG_LENGTH)
-#define DOLBY_PARAM_ARBI_LENGTH   40
-#define DOLBY_PARAM_ARBI_OFFSET   (DOLBY_PARAM_AOCC_OFFSET + \
-					DOLBY_PARAM_AOCC_LENGTH)
-#define DOLBY_PARAM_ARBL_LENGTH   40
-#define DOLBY_PARAM_ARBL_OFFSET   (DOLBY_PARAM_ARBI_OFFSET + \
-					DOLBY_PARAM_ARBI_LENGTH)
-#define DOLBY_PARAM_ARBH_LENGTH   40
-#define DOLBY_PARAM_ARBH_OFFSET   (DOLBY_PARAM_ARBL_OFFSET + \
-					DOLBY_PARAM_ARBL_LENGTH)
-#define DOLBY_PARAM_AROD_LENGTH   1
-#define DOLBY_PARAM_AROD_OFFSET   (DOLBY_PARAM_ARBH_OFFSET + \
-					DOLBY_PARAM_ARBH_LENGTH)
-#define DOLBY_PARAM_ARTP_LENGTH   1
-#define DOLBY_PARAM_ARTP_OFFSET   (DOLBY_PARAM_AROD_OFFSET + \
-					DOLBY_PARAM_AROD_LENGTH)
-#define DOLBY_PARAM_VMON_LENGTH   1
-#define DOLBY_PARAM_VMON_OFFSET   (DOLBY_PARAM_ARTP_OFFSET + \
-					DOLBY_PARAM_ARTP_LENGTH)
-#define DOLBY_PARAM_VMB_LENGTH    1
-#define DOLBY_PARAM_VMB_OFFSET    (DOLBY_PARAM_VMON_OFFSET + \
-					DOLBY_PARAM_VMON_LENGTH)
-#define DOLBY_PARAM_VCNB_LENGTH   1
-#define DOLBY_PARAM_VCNB_OFFSET   (DOLBY_PARAM_VMB_OFFSET + \
-					DOLBY_PARAM_VMB_LENGTH)
-#define DOLBY_PARAM_VCBF_LENGTH   20
-#define DOLBY_PARAM_VCBF_OFFSET   (DOLBY_PARAM_VCNB_OFFSET + \
-					DOLBY_PARAM_VCNB_LENGTH)
-#define DOLBY_PARAM_PREG_LENGTH   1
-#define DOLBY_PARAM_PREG_OFFSET   (DOLBY_PARAM_VCBF_OFFSET + \
-					DOLBY_PARAM_VCBF_LENGTH)
-#define DOLBY_PARAM_VEN_LENGTH    1
-#define DOLBY_PARAM_VEN_OFFSET    (DOLBY_PARAM_PREG_OFFSET + \
-					DOLBY_PARAM_PREG_LENGTH)
-#define DOLBY_PARAM_PSTG_LENGTH   1
-#define DOLBY_PARAM_PSTG_OFFSET   (DOLBY_PARAM_VEN_OFFSET + \
-					DOLBY_PARAM_VEN_LENGTH)
-
-#define DOLBY_PARAM_INT_ENDP_LENGTH		1
-#define DOLBY_PARAM_PAYLOAD_SIZE		3
-#define DOLBY_MAX_LENGTH_INDIVIDUAL_PARAM	329
-
-#define TOTAL_LENGTH_DOLBY_PARAM		745
-#define DOLBY_VIS_PARAM_HEADER_SIZE		25
-#define DOLBY_PARAM_VCNB_MAX_LENGTH		40
-
-#define DOLBY_INVALID_PORT_ID			-1
-
-enum {
-	DEVICE_NONE			= 0x0,
-	/* output devices */
-	EARPIECE			= 0x1,
-	SPEAKER				= 0x2,
-	WIRED_HEADSET			= 0x4,
-	WIRED_HEADPHONE			= 0x8,
-	BLUETOOTH_SCO			= 0x10,
-	BLUETOOTH_SCO_HEADSET		= 0x20,
-	BLUETOOTH_SCO_CARKIT		= 0x40,
-	BLUETOOTH_A2DP			= 0x80,
-	BLUETOOTH_A2DP_HEADPHONES	= 0x100,
-	BLUETOOTH_A2DP_SPEAKER		= 0x200,
-	AUX_DIGITAL			= 0x400,
-	ANLG_DOCK_HEADSET		= 0x800,
-	DGTL_DOCK_HEADSET		= 0x1000,
-	USB_ACCESSORY			= 0x2000,
-	USB_DEVICE			= 0x4000,
-	REMOTE_SUBMIX			= 0x8000,
-	ANC_HEADSET			= 0x10000,
-	ANC_HEADPHONE			= 0x20000,
-	PROXY				= 0x2000000,
-	FM				= 0x100000,
-	FM_TX				= 0x1000000,
-	DEVICE_OUT_DEFAULT		= 0x40000000,
-	DEVICE_OUT_ALL			= 0x403FFFFF,
-};
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-dolby-dap-config.h b/sound/soc/msm/qdsp6v2/msm-dolby-dap-config.h
deleted file mode 100644
index ca6310a..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dolby-dap-config.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_DOLBY_DAP_CONFIG_H_
-#define _MSM_DOLBY_DAP_CONFIG_H_
-
-#include <sound/soc.h>
-#include "msm-dolby-common.h"
-
-#ifdef CONFIG_DOLBY_DAP
-/* DOLBY DOLBY GUIDS */
-#define DOLBY_ADM_COPP_TOPOLOGY_ID	0x0001033B
-#define NUM_DOLBY_ENDP_DEVICE                 23
-
-#define DOLBY_NUM_ENDP_DEPENDENT_PARAMS	  3
-#define DOLBY_ENDDEP_PARAM_DVLO_OFFSET	  0
-#define DOLBY_ENDDEP_PARAM_DVLO_LENGTH	  1
-#define DOLBY_ENDDEP_PARAM_DVLI_OFFSET    (DOLBY_ENDDEP_PARAM_DVLO_OFFSET + \
-						DOLBY_ENDDEP_PARAM_DVLO_LENGTH)
-#define DOLBY_ENDDEP_PARAM_DVLI_LENGTH    1
-#define DOLBY_ENDDEP_PARAM_VMB_OFFSET     (DOLBY_ENDDEP_PARAM_DVLI_OFFSET + \
-						DOLBY_ENDDEP_PARAM_DVLI_LENGTH)
-#define DOLBY_ENDDEP_PARAM_VMB_LENGTH     1
-#define DOLBY_ENDDEP_PARAM_LENGTH         (DOLBY_ENDDEP_PARAM_DVLO_LENGTH + \
-		DOLBY_ENDDEP_PARAM_DVLI_LENGTH + DOLBY_ENDDEP_PARAM_VMB_LENGTH)
-
-#define MAX_DOLBY_PARAMS			47
-#define MAX_DOLBY_CTRL_PARAMS			5
-#define ALL_DOLBY_PARAMS			(MAX_DOLBY_PARAMS + \
-							MAX_DOLBY_CTRL_PARAMS)
-#define DOLBY_COMMIT_ALL_IDX			MAX_DOLBY_PARAMS
-#define DOLBY_COMMIT_IDX			(MAX_DOLBY_PARAMS+1)
-#define DOLBY_USE_CACHE_IDX			(MAX_DOLBY_PARAMS+2)
-#define DOLBY_AUTO_ENDP_IDX			(MAX_DOLBY_PARAMS+3)
-#define DOLBY_AUTO_ENDDEP_IDX			(MAX_DOLBY_PARAMS+4)
-
-/* DOLBY device definitions */
-enum {
-	DOLBY_ENDP_INT_SPEAKERS = 0,
-	DOLBY_ENDP_EXT_SPEAKERS,
-	DOLBY_ENDP_HEADPHONES,
-	DOLBY_ENDP_HDMI,
-	DOLBY_ENDP_SPDIF,
-	DOLBY_ENDP_DLNA,
-	DOLBY_ENDP_ANALOG,
-};
-
-/* DOLBY device definitions end */
-
-struct dolby_dap_params {
-	uint32_t value[TOTAL_LENGTH_DOLBY_PARAM + MAX_DOLBY_PARAMS];
-} __packed;
-
-int msm_dolby_dap_init(int port_id, int copp_idx, int channels,
-		       bool is_custom_stereo_on);
-void msm_dolby_dap_deinit(int port_id);
-void msm_dolby_dap_add_controls(struct snd_soc_platform *platform);
-int dolby_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
-				      bool is_custom_stereo_enabled);
-/* Dolby DOLBY end */
-#else
-int msm_dolby_dap_init(int port_id, int copp_idx, int channels,
-		       bool is_custom_stereo_on)
-{
-	return 0;
-}
-void msm_dolby_dap_deinit(int port_id) { }
-void msm_dolby_dap_add_controls(struct snd_soc_platform *platform) { }
-int dolby_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
-				      bool is_custom_stereo_enabled)
-{
-	return 0;
-}
-#endif
-
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.c b/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.c
deleted file mode 100644
index b7e69fa..0000000
--- a/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.c
+++ /dev/null
@@ -1,2315 +0,0 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/bitops.h>
-#include <sound/control.h>
-#include <sound/q6adm-v2.h>
-
-#include "msm-ds2-dap-config.h"
-#include "msm-pcm-routing-v2.h"
-#include <sound/q6core.h>
-
-
-#if defined(CONFIG_DOLBY_DS2) || defined(CONFIG_DOLBY_LICENSE)
-
-/* ramp up/down for 30ms    */
-#define DOLBY_SOFT_VOLUME_PERIOD	40
-/* Step value 0ms or 0us */
-#define DOLBY_SOFT_VOLUME_STEP		1000
-#define DOLBY_ADDITIONAL_RAMP_WAIT	10
-#define SOFT_VOLUME_PARAM_SIZE		3
-#define PARAM_PAYLOAD_SIZE		3
-
-enum {
-	DOLBY_SOFT_VOLUME_CURVE_LINEAR = 0,
-	DOLBY_SOFT_VOLUME_CURVE_EXP,
-	DOLBY_SOFT_VOLUME_CURVE_LOG,
-};
-
-#define VOLUME_ZERO_GAIN     0x0
-#define VOLUME_UNITY_GAIN    0x2000
-/* Wait time for module enable/disble */
-#define DOLBY_MODULE_ENABLE_PERIOD     50
-
-/* DOLBY device definitions end */
-enum {
-	DOLBY_OFF_CACHE = 0,
-	DOLBY_SPEAKER_CACHE,
-	DOLBY_HEADPHONE_CACHE,
-	DOLBY_HDMI_CACHE,
-	DOLBY_WFD_CACHE,
-	DOLBY_FM_CACHE,
-	DOLBY_MAX_CACHE,
-};
-
-enum {
-	DAP_SOFT_BYPASS = 0,
-	DAP_HARD_BYPASS,
-};
-
-enum {
-	MODULE_DISABLE = 0,
-	MODULE_ENABLE,
-};
-/* dolby param ids to/from dsp */
-static uint32_t	ds2_dap_params_id[MAX_DS2_PARAMS] = {
-	DOLBY_PARAM_ID_VDHE, DOLBY_PARAM_ID_VSPE, DOLBY_PARAM_ID_DSSF,
-	DOLBY_PARAM_ID_DVLI, DOLBY_PARAM_ID_DVLO, DOLBY_PARAM_ID_DVLE,
-	DOLBY_PARAM_ID_DVMC, DOLBY_PARAM_ID_DVME, DOLBY_PARAM_ID_IENB,
-	DOLBY_PARAM_ID_IEBF, DOLBY_PARAM_ID_IEON, DOLBY_PARAM_ID_DEON,
-	DOLBY_PARAM_ID_NGON, DOLBY_PARAM_ID_GEON, DOLBY_PARAM_ID_GENB,
-	DOLBY_PARAM_ID_GEBF, DOLBY_PARAM_ID_AONB, DOLBY_PARAM_ID_AOBF,
-	DOLBY_PARAM_ID_AOBG, DOLBY_PARAM_ID_AOON, DOLBY_PARAM_ID_ARNB,
-	DOLBY_PARAM_ID_ARBF, DOLBY_PARAM_ID_PLB,  DOLBY_PARAM_ID_PLMD,
-	DOLBY_PARAM_ID_DHSB, DOLBY_PARAM_ID_DHRG, DOLBY_PARAM_ID_DSSB,
-	DOLBY_PARAM_ID_DSSA, DOLBY_PARAM_ID_DVLA, DOLBY_PARAM_ID_IEBT,
-	DOLBY_PARAM_ID_IEA,  DOLBY_PARAM_ID_DEA,  DOLBY_PARAM_ID_DED,
-	DOLBY_PARAM_ID_GEBG, DOLBY_PARAM_ID_AOCC, DOLBY_PARAM_ID_ARBI,
-	DOLBY_PARAM_ID_ARBL, DOLBY_PARAM_ID_ARBH, DOLBY_PARAM_ID_AROD,
-	DOLBY_PARAM_ID_ARTP, DOLBY_PARAM_ID_VMON, DOLBY_PARAM_ID_VMB,
-	DOLBY_PARAM_ID_VCNB, DOLBY_PARAM_ID_VCBF, DOLBY_PARAM_ID_PREG,
-	DOLBY_PARAM_ID_VEN,  DOLBY_PARAM_ID_PSTG, DOLBY_PARAM_ID_INIT_ENDP,
-};
-
-/* modifed state:	0x00000000 - Not updated
- *			> 0x00000000 && < 0x00010000
- *				Updated and not committed to DSP
- *			0x00010001 - Updated and committed to DSP
- *			> 0x00010001 - Modified the committed value
- */
-/* param offset */
-static uint32_t	ds2_dap_params_offset[MAX_DS2_PARAMS] = {
-	DOLBY_PARAM_VDHE_OFFSET, DOLBY_PARAM_VSPE_OFFSET,
-	DOLBY_PARAM_DSSF_OFFSET, DOLBY_PARAM_DVLI_OFFSET,
-	DOLBY_PARAM_DVLO_OFFSET, DOLBY_PARAM_DVLE_OFFSET,
-	DOLBY_PARAM_DVMC_OFFSET, DOLBY_PARAM_DVME_OFFSET,
-	DOLBY_PARAM_IENB_OFFSET, DOLBY_PARAM_IEBF_OFFSET,
-	DOLBY_PARAM_IEON_OFFSET, DOLBY_PARAM_DEON_OFFSET,
-	DOLBY_PARAM_NGON_OFFSET, DOLBY_PARAM_GEON_OFFSET,
-	DOLBY_PARAM_GENB_OFFSET, DOLBY_PARAM_GEBF_OFFSET,
-	DOLBY_PARAM_AONB_OFFSET, DOLBY_PARAM_AOBF_OFFSET,
-	DOLBY_PARAM_AOBG_OFFSET, DOLBY_PARAM_AOON_OFFSET,
-	DOLBY_PARAM_ARNB_OFFSET, DOLBY_PARAM_ARBF_OFFSET,
-	DOLBY_PARAM_PLB_OFFSET,  DOLBY_PARAM_PLMD_OFFSET,
-	DOLBY_PARAM_DHSB_OFFSET, DOLBY_PARAM_DHRG_OFFSET,
-	DOLBY_PARAM_DSSB_OFFSET, DOLBY_PARAM_DSSA_OFFSET,
-	DOLBY_PARAM_DVLA_OFFSET, DOLBY_PARAM_IEBT_OFFSET,
-	DOLBY_PARAM_IEA_OFFSET,  DOLBY_PARAM_DEA_OFFSET,
-	DOLBY_PARAM_DED_OFFSET,  DOLBY_PARAM_GEBG_OFFSET,
-	DOLBY_PARAM_AOCC_OFFSET, DOLBY_PARAM_ARBI_OFFSET,
-	DOLBY_PARAM_ARBL_OFFSET, DOLBY_PARAM_ARBH_OFFSET,
-	DOLBY_PARAM_AROD_OFFSET, DOLBY_PARAM_ARTP_OFFSET,
-	DOLBY_PARAM_VMON_OFFSET, DOLBY_PARAM_VMB_OFFSET,
-	DOLBY_PARAM_VCNB_OFFSET, DOLBY_PARAM_VCBF_OFFSET,
-	DOLBY_PARAM_PREG_OFFSET, DOLBY_PARAM_VEN_OFFSET,
-	DOLBY_PARAM_PSTG_OFFSET, DOLBY_PARAM_INT_ENDP_OFFSET,
-};
-/* param_length */
-static uint32_t	ds2_dap_params_length[MAX_DS2_PARAMS] = {
-	DOLBY_PARAM_VDHE_LENGTH, DOLBY_PARAM_VSPE_LENGTH,
-	DOLBY_PARAM_DSSF_LENGTH, DOLBY_PARAM_DVLI_LENGTH,
-	DOLBY_PARAM_DVLO_LENGTH, DOLBY_PARAM_DVLE_LENGTH,
-	DOLBY_PARAM_DVMC_LENGTH, DOLBY_PARAM_DVME_LENGTH,
-	DOLBY_PARAM_IENB_LENGTH, DOLBY_PARAM_IEBF_LENGTH,
-	DOLBY_PARAM_IEON_LENGTH, DOLBY_PARAM_DEON_LENGTH,
-	DOLBY_PARAM_NGON_LENGTH, DOLBY_PARAM_GEON_LENGTH,
-	DOLBY_PARAM_GENB_LENGTH, DOLBY_PARAM_GEBF_LENGTH,
-	DOLBY_PARAM_AONB_LENGTH, DOLBY_PARAM_AOBF_LENGTH,
-	DOLBY_PARAM_AOBG_LENGTH, DOLBY_PARAM_AOON_LENGTH,
-	DOLBY_PARAM_ARNB_LENGTH, DOLBY_PARAM_ARBF_LENGTH,
-	DOLBY_PARAM_PLB_LENGTH,  DOLBY_PARAM_PLMD_LENGTH,
-	DOLBY_PARAM_DHSB_LENGTH, DOLBY_PARAM_DHRG_LENGTH,
-	DOLBY_PARAM_DSSB_LENGTH, DOLBY_PARAM_DSSA_LENGTH,
-	DOLBY_PARAM_DVLA_LENGTH, DOLBY_PARAM_IEBT_LENGTH,
-	DOLBY_PARAM_IEA_LENGTH,  DOLBY_PARAM_DEA_LENGTH,
-	DOLBY_PARAM_DED_LENGTH,  DOLBY_PARAM_GEBG_LENGTH,
-	DOLBY_PARAM_AOCC_LENGTH, DOLBY_PARAM_ARBI_LENGTH,
-	DOLBY_PARAM_ARBL_LENGTH, DOLBY_PARAM_ARBH_LENGTH,
-	DOLBY_PARAM_AROD_LENGTH, DOLBY_PARAM_ARTP_LENGTH,
-	DOLBY_PARAM_VMON_LENGTH, DOLBY_PARAM_VMB_LENGTH,
-	DOLBY_PARAM_VCNB_LENGTH, DOLBY_PARAM_VCBF_LENGTH,
-	DOLBY_PARAM_PREG_LENGTH, DOLBY_PARAM_VEN_LENGTH,
-	DOLBY_PARAM_PSTG_LENGTH, DOLBY_PARAM_INT_ENDP_LENGTH,
-};
-
-struct ds2_dap_params_s {
-	int32_t params_val[TOTAL_LENGTH_DS2_PARAM];
-	int32_t dap_params_modified[MAX_DS2_PARAMS];
-};
-
-struct audio_rx_cal_data {
-	char aud_proc_data[AUD_PROC_BLOCK_SIZE];
-	int32_t  aud_proc_size;
-	char aud_vol_data[AUD_VOL_BLOCK_SIZE];
-	int32_t aud_vol_size;
-};
-
-static struct ds2_dap_params_s ds2_dap_params[DOLBY_MAX_CACHE];
-
-struct ds2_device_mapping {
-	int32_t device_id; /* audio_out_... */
-	int port_id; /* afe port. constant for a target variant. routing-v2*/
-	/*Only one Dolby COPP  for a specific port*/
-	int copp_idx; /* idx for the copp port on which ds2 is active */
-	int cache_dev; /* idx to a shared parameter array dependent on device*/
-	uint32_t stream_ref_count;
-	bool active;
-	void *cal_data;
-};
-
-static struct ds2_device_mapping dev_map[DS2_DEVICES_ALL];
-
-struct ds2_dap_params_states_s {
-	bool use_cache;
-	bool dap_bypass;
-	bool dap_bypass_type;
-	bool node_opened;
-	int32_t  device;
-	bool custom_stereo_onoff;
-};
-
-static struct ds2_dap_params_states_s ds2_dap_params_states = {true, false,
-				false, DEVICE_NONE};
-
-static int all_supported_devices = EARPIECE|SPEAKER|WIRED_HEADSET|
-			WIRED_HEADPHONE|BLUETOOTH_SCO|AUX_DIGITAL|
-			ANLG_DOCK_HEADSET|DGTL_DOCK_HEADSET|
-			REMOTE_SUBMIX|ANC_HEADSET|ANC_HEADPHONE|
-			PROXY|FM|FM_TX|DEVICE_NONE|
-			BLUETOOTH_SCO_HEADSET|BLUETOOTH_SCO_CARKIT;
-
-
-static void msm_ds2_dap_check_and_update_ramp_wait(int port_id, int copp_idx,
-						   int *ramp_wait)
-{
-
-	int32_t *update_params_value = NULL;
-	uint32_t params_length = SOFT_VOLUME_PARAM_SIZE * sizeof(uint32_t);
-	uint32_t param_payload_len = PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
-	int rc = 0;
-
-	update_params_value = kzalloc(params_length + param_payload_len,
-				      GFP_KERNEL);
-	if (!update_params_value)
-		goto end;
-
-	rc = adm_get_params(port_id, copp_idx,
-			    AUDPROC_MODULE_ID_VOL_CTRL,
-			    AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS,
-			    params_length + param_payload_len,
-			    (char *) update_params_value);
-	if (rc == 0) {
-		pr_debug("%s: params_value [0x%x, 0x%x, 0x%x]\n",
-			__func__, update_params_value[0],
-			update_params_value[1],
-			update_params_value[2]);
-		*ramp_wait = update_params_value[0];
-	}
-end:
-	kfree(update_params_value);
-	/*
-	 * No error returned as we do not need to error out from dap on/dap
-	 * bypass. The default ramp parameter will be used to wait during
-	 * ramp down.
-	 */
-}
-
-static int msm_ds2_dap_set_vspe_vdhe(int dev_map_idx,
-				     bool is_custom_stereo_enabled)
-{
-	int32_t *update_params_value = NULL;
-	int32_t *param_val = NULL;
-	int idx, i, j, rc = 0, cdev;
-	uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
-				2 * DOLBY_PARAM_PAYLOAD_SIZE) *
-				sizeof(uint32_t);
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
-		pr_err("%s: Invalid port id\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].copp_idx < 0) ||
-		(dev_map[dev_map_idx].copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: Invalid copp_idx\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].port_id != SLIMBUS_0_RX) &&
-	     (dev_map[dev_map_idx].port_id != RT_PROXY_PORT_001_RX)) {
-		pr_debug("%s:No Custom stereo for port:0x%x\n",
-			 __func__, dev_map[dev_map_idx].port_id);
-		goto end;
-	}
-
-	update_params_value = kzalloc(params_length, GFP_KERNEL);
-	if (!update_params_value) {
-		rc = -ENOMEM;
-		goto end;
-	}
-	params_length = 0;
-	param_val = update_params_value;
-	cdev = dev_map[dev_map_idx].cache_dev;
-	/* for VDHE and VSPE DAP params at index 0 and 1 in table */
-	for (i = 0; i < 2; i++) {
-		*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
-		*update_params_value++ = ds2_dap_params_id[i];
-		*update_params_value++ = ds2_dap_params_length[i] *
-					sizeof(uint32_t);
-		idx = ds2_dap_params_offset[i];
-		for (j = 0; j < ds2_dap_params_length[i]; j++) {
-			if (is_custom_stereo_enabled)
-				*update_params_value++ = 0;
-			else
-				*update_params_value++ =
-					ds2_dap_params[cdev].params_val[idx+j];
-		}
-		params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
-				  ds2_dap_params_length[i]) *
-				  sizeof(uint32_t);
-	}
-
-	pr_debug("%s: valid param length: %d\n", __func__, params_length);
-	if (params_length) {
-		rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
-					       dev_map[dev_map_idx].copp_idx,
-					       (char *)param_val,
-					       params_length);
-		if (rc) {
-			pr_err("%s: send vdhe/vspe params failed with rc=%d\n",
-				__func__, rc);
-			rc = -EINVAL;
-			goto end;
-		}
-	}
-end:
-	kfree(param_val);
-	return rc;
-}
-
-int qti_set_custom_stereo_on(int port_id, int copp_idx,
-			     bool is_custom_stereo_on)
-{
-
-	uint16_t op_FL_ip_FL_weight;
-	uint16_t op_FL_ip_FR_weight;
-	uint16_t op_FR_ip_FL_weight;
-	uint16_t op_FR_ip_FR_weight;
-
-	int32_t *update_params_value32 = NULL, rc = 0;
-	int32_t *param_val = NULL;
-	int16_t *update_params_value16 = 0;
-	uint32_t params_length_bytes = CUSTOM_STEREO_PAYLOAD_SIZE *
-				       sizeof(uint32_t);
-	uint32_t avail_length = params_length_bytes;
-
-	if ((port_id != SLIMBUS_0_RX) &&
-	     (port_id != RT_PROXY_PORT_001_RX)) {
-		pr_debug("%s:No Custom stereo for port:0x%x\n",
-			 __func__, port_id);
-		goto skip_send_cmd;
-	}
-
-	pr_debug("%s: port 0x%x, copp_idx %d, is_custom_stereo_on %d\n",
-		 __func__, port_id, copp_idx, is_custom_stereo_on);
-	if (is_custom_stereo_on) {
-		op_FL_ip_FL_weight =
-			Q14_GAIN_ZERO_POINT_FIVE;
-		op_FL_ip_FR_weight =
-			Q14_GAIN_ZERO_POINT_FIVE;
-		op_FR_ip_FL_weight =
-			Q14_GAIN_ZERO_POINT_FIVE;
-		op_FR_ip_FR_weight =
-			Q14_GAIN_ZERO_POINT_FIVE;
-	} else {
-		op_FL_ip_FL_weight = Q14_GAIN_UNITY;
-		op_FL_ip_FR_weight = 0;
-		op_FR_ip_FL_weight = 0;
-		op_FR_ip_FR_weight = Q14_GAIN_UNITY;
-	}
-
-	update_params_value32 = kzalloc(params_length_bytes, GFP_KERNEL);
-	if (!update_params_value32) {
-		rc = -ENOMEM;
-		goto skip_send_cmd;
-	}
-	param_val = update_params_value32;
-	if (avail_length < 2 * sizeof(uint32_t))
-		goto skip_send_cmd;
-	*update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
-	*update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
-	avail_length = avail_length - (2 * sizeof(uint32_t));
-
-	update_params_value16 = (int16_t *)update_params_value32;
-	if (avail_length < 10 * sizeof(uint16_t))
-		goto skip_send_cmd;
-	*update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE;
-	/* for alignment only*/
-	*update_params_value16++ = 0;
-	/* index is 32-bit param in little endian*/
-	*update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM;
-	*update_params_value16++ = 0;
-	/* for stereo mixing num out ch*/
-	*update_params_value16++ = CUSTOM_STEREO_NUM_OUT_CH;
-	/* for stereo mixing num in ch*/
-	*update_params_value16++ = CUSTOM_STEREO_NUM_IN_CH;
-
-	/* Out ch map FL/FR*/
-	*update_params_value16++ = PCM_CHANNEL_FL;
-	*update_params_value16++ = PCM_CHANNEL_FR;
-
-	/* In ch map FL/FR*/
-	*update_params_value16++ = PCM_CHANNEL_FL;
-	*update_params_value16++ = PCM_CHANNEL_FR;
-	avail_length = avail_length - (10 * sizeof(uint16_t));
-	/* weighting coefficients as name suggests,
-	 * mixing will be done according to these coefficients
-	 */
-	if (avail_length < 4 * sizeof(uint16_t))
-		goto skip_send_cmd;
-	*update_params_value16++ = op_FL_ip_FL_weight;
-	*update_params_value16++ = op_FL_ip_FR_weight;
-	*update_params_value16++ = op_FR_ip_FL_weight;
-	*update_params_value16++ = op_FR_ip_FR_weight;
-	avail_length = avail_length - (4 * sizeof(uint16_t));
-	if (params_length_bytes != 0) {
-		rc = adm_dolby_dap_send_params(port_id, copp_idx,
-				(char *)param_val,
-				params_length_bytes);
-		if (rc) {
-			pr_err("%s: send params failed rc=%d\n", __func__, rc);
-			rc = -EINVAL;
-			goto skip_send_cmd;
-		}
-	}
-	kfree(param_val);
-	return 0;
-skip_send_cmd:
-		pr_err("%s: insufficient memory, send cmd failed\n",
-			__func__);
-		kfree(param_val);
-		return rc;
-}
-static int dap_set_custom_stereo_onoff(int dev_map_idx,
-					bool is_custom_stereo_enabled)
-{
-
-	int32_t *update_params_value = NULL, rc = 0;
-	int32_t *param_val = NULL;
-	uint32_t params_length_bytes = (TOTAL_LENGTH_DOLBY_PARAM +
-				DOLBY_PARAM_PAYLOAD_SIZE) * sizeof(uint32_t);
-	if ((dev_map[dev_map_idx].port_id != SLIMBUS_0_RX) &&
-	     (dev_map[dev_map_idx].port_id != RT_PROXY_PORT_001_RX)) {
-		pr_debug("%s:No Custom stereo for port:0x%x\n",
-			 __func__, dev_map[dev_map_idx].port_id);
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].copp_idx < 0) ||
-		(dev_map[dev_map_idx].copp_idx >= MAX_COPPS_PER_PORT)) {
-		rc = -EINVAL;
-		goto end;
-	}
-
-	/* DAP custom stereo */
-	msm_ds2_dap_set_vspe_vdhe(dev_map_idx,
-				  is_custom_stereo_enabled);
-	update_params_value = kzalloc(params_length_bytes, GFP_KERNEL);
-	if (!update_params_value) {
-		pr_err("%s: params memory alloc failed\n", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-	params_length_bytes = 0;
-	param_val = update_params_value;
-	*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
-	*update_params_value++ = DOLBY_ENABLE_CUSTOM_STEREO;
-	*update_params_value++ = sizeof(uint32_t);
-	if (is_custom_stereo_enabled)
-		*update_params_value++ = 1;
-	else
-		*update_params_value++ = 0;
-	params_length_bytes += (DOLBY_PARAM_PAYLOAD_SIZE + 1) *
-				sizeof(uint32_t);
-	pr_debug("%s: valid param length: %d\n", __func__, params_length_bytes);
-	if (params_length_bytes) {
-		rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
-					       dev_map[dev_map_idx].copp_idx,
-					       (char *)param_val,
-					       params_length_bytes);
-		if (rc) {
-			pr_err("%s: custom stereo param failed with rc=%d\n",
-				__func__, rc);
-			rc = -EINVAL;
-			goto end;
-		}
-	}
-end:
-	kfree(param_val);
-	return rc;
-
-}
-
-
-static int set_custom_stereo_onoff(int dev_map_idx,
-					bool is_custom_stereo_enabled)
-{
-	int rc = 0;
-
-	pr_debug("%s: map index %d, custom stereo %d\n", __func__, dev_map_idx,
-		 is_custom_stereo_enabled);
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
-		pr_err("%s: invalid port id\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].copp_idx < 0) ||
-		(dev_map[dev_map_idx].copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: invalid copp idx\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (ds2_dap_params_states.dap_bypass == true &&
-		ds2_dap_params_states.dap_bypass_type == DAP_HARD_BYPASS) {
-
-		rc = qti_set_custom_stereo_on(dev_map[dev_map_idx].port_id,
-					      dev_map[dev_map_idx].copp_idx,
-					      is_custom_stereo_enabled);
-		if (rc < 0) {
-			pr_err("%s:qti_set_custom_stereo_on_copp failed C.S %d",
-				__func__, is_custom_stereo_enabled);
-		}
-		goto end;
-
-	}
-
-	if (ds2_dap_params_states.dap_bypass == false) {
-		rc = dap_set_custom_stereo_onoff(dev_map_idx,
-						 is_custom_stereo_enabled);
-		if (rc < 0) {
-			pr_err("%s:qti_set_custom_stereo_on_copp failed C.S %d",
-				__func__, is_custom_stereo_enabled);
-		}
-		goto end;
-	}
-end:
-	return rc;
-}
-
-static int msm_ds2_dap_alloc_and_store_cal_data(int dev_map_idx, int path,
-					    int perf_mode)
-{
-	int rc = 0;
-	struct audio_rx_cal_data *aud_cal_data;
-
-	pr_debug("%s: path %d, perf_mode %d, dev_map_idx %d\n",
-		__func__, path, perf_mode, dev_map_idx);
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	aud_cal_data = kzalloc(sizeof(struct audio_rx_cal_data), GFP_KERNEL);
-	if (!aud_cal_data) {
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	rc = adm_store_cal_data(dev_map[dev_map_idx].port_id,
-				dev_map[dev_map_idx].copp_idx, path, perf_mode,
-				ADM_AUDPROC_CAL, aud_cal_data->aud_proc_data,
-				&aud_cal_data->aud_proc_size);
-	if (rc < 0) {
-		pr_err("%s: store cal data err %d\n", __func__, rc);
-		kfree(aud_cal_data);
-		goto end;
-	}
-
-	rc = adm_store_cal_data(dev_map[dev_map_idx].port_id,
-				dev_map[dev_map_idx].copp_idx, path, perf_mode,
-				ADM_AUDVOL_CAL, aud_cal_data->aud_vol_data,
-				&aud_cal_data->aud_vol_size);
-	if (rc < 0) {
-		pr_err("%s: store cal data err %d\n", __func__, rc);
-		kfree(aud_cal_data);
-		goto end;
-	}
-
-	dev_map[dev_map_idx].cal_data = (void *)aud_cal_data;
-
-end:
-	pr_debug("%s: ret %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_ds2_dap_free_cal_data(int dev_map_idx)
-{
-	int rc = 0;
-	struct audio_rx_cal_data *aud_cal_data;
-
-	pr_debug("%s: dev_map_idx %d\n", __func__, dev_map_idx);
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-	aud_cal_data = (struct audio_rx_cal_data *)
-				dev_map[dev_map_idx].cal_data;
-	kfree(aud_cal_data);
-	dev_map[dev_map_idx].cal_data = NULL;
-
-end:
-	return rc;
-}
-
-static int msm_ds2_dap_send_cal_data(int dev_map_idx)
-{
-	int rc = 0;
-	struct audio_rx_cal_data *aud_cal_data = NULL;
-
-	pr_debug("%s: devmap index %d\n", __func__, dev_map_idx);
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (dev_map[dev_map_idx].cal_data == NULL) {
-		pr_err("%s: No valid calibration data stored for idx %d\n",
-			__func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	/* send aud proc cal */
-	aud_cal_data = (struct audio_rx_cal_data *)
-				dev_map[dev_map_idx].cal_data;
-	rc = adm_send_calibration(dev_map[dev_map_idx].port_id,
-				  dev_map[dev_map_idx].copp_idx,
-				  ADM_PATH_PLAYBACK, 0,
-				  ADM_AUDPROC_CAL,
-				  aud_cal_data->aud_proc_data,
-				  aud_cal_data->aud_proc_size);
-	if (rc < 0) {
-		pr_err("%s: adm_send_calibration failed %d\n", __func__, rc);
-		goto end;
-	}
-
-	/* send aud volume cal*/
-	rc = adm_send_calibration(dev_map[dev_map_idx].port_id,
-				  dev_map[dev_map_idx].copp_idx,
-				  ADM_PATH_PLAYBACK, 0,
-				  ADM_AUDVOL_CAL,
-				  aud_cal_data->aud_vol_data,
-				  aud_cal_data->aud_vol_size);
-	if (rc < 0)
-		pr_err("%s: adm_send_calibration failed %d\n", __func__, rc);
-end:
-	pr_debug("%s: return  %d\n", __func__, rc);
-	return rc;
-}
-
-static inline int msm_ds2_dap_can_enable_module(int32_t module_id)
-{
-	if (module_id == MTMX_MODULE_ID_DEFAULT_CHMIXER ||
-		module_id == AUDPROC_MODULE_ID_RESAMPLER ||
-		module_id == AUDPROC_MODULE_ID_VOL_CTRL) {
-		return false;
-	}
-	return true;
-}
-
-static int msm_ds2_dap_init_modules_in_topology(int dev_map_idx)
-{
-	int rc = 0, i = 0, port_id, copp_idx;
-	/* Account for 32 bit integer allocation */
-	int32_t param_sz = (ADM_GET_TOPO_MODULE_LIST_LENGTH / sizeof(uint32_t));
-	int32_t *update_param_val = NULL;
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	port_id = dev_map[dev_map_idx].port_id;
-	copp_idx = dev_map[dev_map_idx].copp_idx;
-	pr_debug("%s: port_id 0x%x copp_idx %d\n", __func__, port_id, copp_idx);
-	update_param_val = kzalloc(ADM_GET_TOPO_MODULE_LIST_LENGTH, GFP_KERNEL);
-	if (!update_param_val) {
-		pr_err("%s, param memory alloc failed\n", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	if (!ds2_dap_params_states.dap_bypass) {
-		/* get modules from dsp */
-		rc = adm_get_pp_topo_module_list(port_id, copp_idx,
-			ADM_GET_TOPO_MODULE_LIST_LENGTH,
-			(char *)update_param_val);
-		if (rc < 0) {
-			pr_err("%s:topo list port %d, err %d,copp_idx %d\n",
-				__func__, port_id, copp_idx, rc);
-			goto end;
-		}
-
-		if (update_param_val[0] > (param_sz - 1)) {
-			pr_err("%s:max modules exp/ret [%d: %d]\n",
-				__func__, (param_sz - 1),
-				update_param_val[0]);
-			rc = -EINVAL;
-			goto end;
-		}
-		/* Turn off modules */
-		for (i = 1; i < update_param_val[0]; i++) {
-			if (!msm_ds2_dap_can_enable_module(
-				update_param_val[i]) ||
-				(update_param_val[i] == DS2_MODULE_ID)) {
-				pr_debug("%s: Do not enable/disable %d\n",
-					 __func__, update_param_val[i]);
-				continue;
-			}
-
-			pr_debug("%s: param disable %d\n",
-				__func__, update_param_val[i]);
-			adm_param_enable(port_id, copp_idx, update_param_val[i],
-					 MODULE_DISABLE);
-		}
-	} else {
-		msm_ds2_dap_send_cal_data(dev_map_idx);
-
-	}
-	adm_param_enable(port_id, copp_idx, DS2_MODULE_ID,
-			 !ds2_dap_params_states.dap_bypass);
-end:
-	kfree(update_param_val);
-	return rc;
-}
-
-static bool msm_ds2_dap_check_is_param_modified(int32_t *dap_params_modified,
-				    int32_t idx, int32_t commit)
-{
-	if ((dap_params_modified[idx] == 0) ||
-		(commit &&
-		((dap_params_modified[idx] & 0x00010000) &&
-		((dap_params_modified[idx] & 0x0000FFFF) <= 1)))) {
-		pr_debug("%s: not modified at idx %d\n", __func__, idx);
-		return false;
-	}
-	pr_debug("%s: modified at idx %d\n", __func__, idx);
-	return true;
-}
-
-static int msm_ds2_dap_map_device_to_dolby_cache_devices(int32_t device_id)
-{
-	int32_t cache_dev = -1;
-
-	switch (device_id) {
-	case DEVICE_NONE:
-		cache_dev = DOLBY_OFF_CACHE;
-		break;
-	case EARPIECE:
-	case SPEAKER:
-		cache_dev = DOLBY_SPEAKER_CACHE;
-		break;
-	case WIRED_HEADSET:
-	case WIRED_HEADPHONE:
-	case ANLG_DOCK_HEADSET:
-	case DGTL_DOCK_HEADSET:
-	case ANC_HEADSET:
-	case ANC_HEADPHONE:
-	case BLUETOOTH_SCO:
-	case BLUETOOTH_SCO_HEADSET:
-	case BLUETOOTH_SCO_CARKIT:
-		cache_dev = DOLBY_HEADPHONE_CACHE;
-		break;
-	case FM:
-	case FM_TX:
-		cache_dev = DOLBY_FM_CACHE;
-		break;
-	case AUX_DIGITAL:
-		cache_dev = DOLBY_HDMI_CACHE;
-		break;
-	case PROXY:
-	case REMOTE_SUBMIX:
-		cache_dev = DOLBY_WFD_CACHE;
-		break;
-	default:
-		pr_err("%s: invalid cache device\n", __func__);
-	}
-	pr_debug("%s: cache device %d\n", __func__, cache_dev);
-	return cache_dev;
-}
-
-static int msm_ds2_dap_update_num_devices(struct dolby_param_data *dolby_data,
-				      int32_t *num_device, int32_t *dev_arr,
-				      int32_t array_size)
-{
-	int32_t idx = 0;
-	int supported_devices = 0;
-
-	if (!array_size) {
-		pr_err("%s: array size zero\n", __func__);
-		return -EINVAL;
-	}
-
-	if (dolby_data->device_id == DEVICE_OUT_ALL ||
-		dolby_data->device_id == DEVICE_OUT_DEFAULT)
-		supported_devices = all_supported_devices;
-	else
-		supported_devices = dolby_data->device_id;
-
-	if ((idx < array_size) && (supported_devices & EARPIECE))
-		dev_arr[idx++] = EARPIECE;
-	if ((idx < array_size) && (supported_devices & SPEAKER))
-		dev_arr[idx++] = SPEAKER;
-	if ((idx < array_size) && (supported_devices & WIRED_HEADSET))
-		dev_arr[idx++] = WIRED_HEADSET;
-	if ((idx < array_size) && (supported_devices & WIRED_HEADPHONE))
-		dev_arr[idx++] = WIRED_HEADPHONE;
-	if ((idx < array_size) && (supported_devices & BLUETOOTH_SCO))
-		dev_arr[idx++] = BLUETOOTH_SCO;
-	if ((idx < array_size) && (supported_devices & BLUETOOTH_SCO_CARKIT))
-		dev_arr[idx++] = BLUETOOTH_SCO_CARKIT;
-	if ((idx < array_size) && (supported_devices & BLUETOOTH_SCO_HEADSET))
-		dev_arr[idx++] = BLUETOOTH_SCO_HEADSET;
-	if ((idx < array_size) && (supported_devices & AUX_DIGITAL))
-		dev_arr[idx++] = AUX_DIGITAL;
-	if ((idx < array_size) && (supported_devices & ANLG_DOCK_HEADSET))
-		dev_arr[idx++] = ANLG_DOCK_HEADSET;
-	if ((idx < array_size) && (supported_devices & DGTL_DOCK_HEADSET))
-		dev_arr[idx++] = DGTL_DOCK_HEADSET;
-	if ((idx < array_size) && (supported_devices & REMOTE_SUBMIX))
-		dev_arr[idx++] = REMOTE_SUBMIX;
-	if ((idx < array_size) && (supported_devices & ANC_HEADSET))
-		dev_arr[idx++] = ANC_HEADSET;
-	if ((idx < array_size) && (supported_devices & ANC_HEADPHONE))
-		dev_arr[idx++] = ANC_HEADPHONE;
-	if ((idx < array_size) && (supported_devices & PROXY))
-		dev_arr[idx++] = PROXY;
-	if ((idx < array_size) && (supported_devices & FM))
-		dev_arr[idx++] = FM;
-	if ((idx < array_size) && (supported_devices & FM_TX))
-		dev_arr[idx++] = FM_TX;
-	/* CHECK device none separately */
-	if ((idx < array_size) && (supported_devices == DEVICE_NONE))
-		dev_arr[idx++] = DEVICE_NONE;
-	pr_debug("%s: dev id 0x%x, idx %d\n", __func__,
-		 supported_devices, idx);
-	*num_device = idx;
-	return 0;
-}
-
-static int msm_ds2_dap_get_port_id(
-		int32_t device_id, int32_t be_id)
-{
-	struct msm_pcm_routing_bdai_data bedais;
-	int port_id = DOLBY_INVALID_PORT_ID;
-	int port_type = 0;
-
-	if (be_id < 0) {
-		port_id = -1;
-		goto end;
-	}
-
-	msm_pcm_routing_get_bedai_info(be_id, &bedais);
-	pr_debug("%s: be port_id %d\n", __func__, bedais.port_id);
-	port_id = bedais.port_id;
-	port_type = afe_get_port_type(bedais.port_id);
-	if (port_type != MSM_AFE_PORT_TYPE_RX)
-		port_id = DOLBY_INVALID_PORT_ID;
-end:
-	pr_debug("%s: device_id 0x%x, be_id %d, port_id %d\n",
-		 __func__, device_id, be_id, port_id);
-	return port_id;
-}
-
-static int msm_ds2_dap_update_dev_map_port_id(int32_t device_id, int port_id)
-{
-	int i;
-
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		if (dev_map[i].device_id == device_id)
-			dev_map[i].port_id = port_id;
-	}
-	pr_debug("%s: port_id %d, device_id 0x%x\n",
-		 __func__, port_id, device_id);
-	return 0;
-}
-
-static int msm_ds2_dap_handle_bypass_wait(int port_id, int copp_idx,
-					  int wait_time)
-{
-	int ret = 0;
-
-	adm_set_wait_parameters(port_id, copp_idx);
-	msm_pcm_routing_release_lock();
-	ret = adm_wait_timeout(port_id, copp_idx, wait_time);
-	msm_pcm_routing_acquire_lock();
-	/* Reset the parameters if wait has timed out */
-	if (ret == 0)
-		adm_reset_wait_parameters(port_id, copp_idx);
-	return ret;
-}
-
-static int msm_ds2_dap_handle_bypass(struct dolby_param_data *dolby_data)
-{
-	int rc = 0, i = 0, j = 0;
-	/*Account for 32 bit integer allocation  */
-	int32_t param_sz = (ADM_GET_TOPO_MODULE_LIST_LENGTH / sizeof(uint32_t));
-	int32_t *mod_list = NULL;
-	int port_id = 0, copp_idx = -1;
-	bool cs_onoff = ds2_dap_params_states.custom_stereo_onoff;
-	int ramp_wait = DOLBY_SOFT_VOLUME_PERIOD;
-
-	pr_debug("%s: bypass type %d bypass %d custom stereo %d\n", __func__,
-		 ds2_dap_params_states.dap_bypass_type,
-		 ds2_dap_params_states.dap_bypass,
-		 ds2_dap_params_states.custom_stereo_onoff);
-	mod_list = kzalloc(ADM_GET_TOPO_MODULE_LIST_LENGTH, GFP_KERNEL);
-	if (!mod_list) {
-		pr_err("%s: param memory alloc failed\n", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		pr_debug("%s: active dev %d\n", __func__, dev_map[i].active);
-		if (dev_map[i].active) {
-			port_id = dev_map[i].port_id;
-			copp_idx = dev_map[i].copp_idx;
-
-			if (port_id == DOLBY_INVALID_PORT_ID) {
-				pr_err("%s: invalid port\n", __func__);
-				rc = 0;
-				goto end;
-			}
-
-			if ((copp_idx < 0) ||
-				(copp_idx >= MAX_COPPS_PER_PORT)) {
-				pr_err("%s: Invalid copp_idx\n", __func__);
-				rc = 0;
-				goto end;
-			}
-
-			/* getmodules from dsp */
-			rc = adm_get_pp_topo_module_list(port_id, copp_idx,
-				    ADM_GET_TOPO_MODULE_LIST_LENGTH,
-				    (char *)mod_list);
-			if (rc < 0) {
-				pr_err("%s:adm get topo list port %d",
-					__func__, port_id);
-				pr_err("copp_idx %d, err %d\n",
-					copp_idx, rc);
-				goto end;
-			}
-			if (mod_list[0] > (param_sz - 1)) {
-				pr_err("%s:max modules exp/ret [%d: %d]\n",
-					__func__, (param_sz - 1),
-					mod_list[0]);
-				rc = -EINVAL;
-				goto end;
-			}
-			/*
-			 * get ramp parameters
-			 * check for change in ramp parameters
-			 * update ramp wait
-			 */
-			msm_ds2_dap_check_and_update_ramp_wait(port_id,
-							       copp_idx,
-							       &ramp_wait);
-
-			/* Mute before switching modules */
-			rc = adm_set_volume(port_id, copp_idx,
-					    VOLUME_ZERO_GAIN);
-			if (rc < 0) {
-				/*
-				 * Not Fatal can continue bypass operations.
-				 * Do not need to block playback
-				 */
-				pr_info("%s :Set volume port_id %d",
-					__func__, port_id);
-				pr_info("copp_idx %d, error %d\n",
-					copp_idx, rc);
-			}
-
-			rc = msm_ds2_dap_handle_bypass_wait(port_id, copp_idx,
-					    (ramp_wait +
-					     DOLBY_ADDITIONAL_RAMP_WAIT));
-			if (rc == -EINTR) {
-				pr_info("%s:bypass interrupted-ignore,port %d",
-					__func__, port_id);
-				pr_info("copp_idx %d\n", copp_idx);
-				rc = 0;
-				continue;
-			}
-
-			/* if dap bypass is set */
-			if (ds2_dap_params_states.dap_bypass) {
-				/* Turn off dap module */
-				adm_param_enable(port_id, copp_idx,
-						 DS2_MODULE_ID, MODULE_DISABLE);
-				/*
-				 * If custom stereo is on at the time of bypass,
-				 * switch off custom stereo on dap and turn on
-				 * custom stereo on qti channel mixer.
-				 */
-				if (cs_onoff) {
-					rc = dap_set_custom_stereo_onoff(i,
-								!cs_onoff);
-					if (rc < 0) {
-						pr_info("%s:D_CS i %d,rc %d\n",
-							__func__, i, rc);
-					}
-					rc = qti_set_custom_stereo_on(port_id,
-								      copp_idx,
-								      cs_onoff);
-					if (rc < 0) {
-						pr_info("%s:Q_CS port id 0x%x",
-							 __func__, port_id);
-						pr_info("copp idx %d, rc %d\n",
-							copp_idx, rc);
-					}
-				}
-				/* Turn on qti modules */
-				for (j = 1; j < mod_list[0]; j++) {
-					if (!msm_ds2_dap_can_enable_module(
-						mod_list[j]) ||
-						mod_list[j] ==
-						DS2_MODULE_ID)
-						continue;
-					pr_debug("%s: param enable %d\n",
-						__func__, mod_list[j]);
-					adm_param_enable(port_id, copp_idx,
-							 mod_list[j],
-							 MODULE_ENABLE);
-				}
-
-				/* Add adm api to resend calibration on port */
-				rc = msm_ds2_dap_send_cal_data(i);
-				if (rc < 0) {
-					/*
-					 * Not fatal,continue bypass operations.
-					 * Do not need to block playback
-					 */
-					pr_info("%s:send cal err %d index %d\n",
-						__func__, rc, i);
-				}
-			} else {
-				/* Turn off qti modules */
-				for (j = 1; j < mod_list[0]; j++) {
-					if (!msm_ds2_dap_can_enable_module(
-						mod_list[j]) ||
-						mod_list[j] ==
-						DS2_MODULE_ID)
-						continue;
-					pr_debug("%s: param disable %d\n",
-						__func__, mod_list[j]);
-					adm_param_enable(port_id, copp_idx,
-							 mod_list[j],
-							 MODULE_DISABLE);
-				}
-
-				/* Enable DAP modules */
-				pr_debug("%s:DS2 param enable\n", __func__);
-				adm_param_enable(port_id, copp_idx,
-						 DS2_MODULE_ID, MODULE_ENABLE);
-				/*
-				 * If custom stereo is on at the time of dap on,
-				 * switch off custom stereo on qti channel mixer
-				 * and turn on custom stereo on DAP.
-				 * mixer(qti).
-				 */
-				if (cs_onoff) {
-					rc = qti_set_custom_stereo_on(port_id,
-								copp_idx,
-								!cs_onoff);
-					if (rc < 0) {
-						pr_info("%s:Q_CS port_id 0x%x",
-							__func__, port_id);
-						pr_info("copp_idx %d rc %d\n",
-							copp_idx, rc);
-					}
-					rc = dap_set_custom_stereo_onoff(i,
-								cs_onoff);
-					if (rc < 0) {
-						pr_info("%s:D_CS i %d,rc %d\n",
-							__func__, i, rc);
-					}
-				}
-			}
-
-			rc = msm_ds2_dap_handle_bypass_wait(port_id, copp_idx,
-				DOLBY_MODULE_ENABLE_PERIOD);
-			if (rc == -EINTR) {
-				pr_info("%s:bypass interrupted port_id %d copp_idx %d\n",
-					__func__, port_id, copp_idx);
-				/* Interrupted ignore bypass */
-				rc = 0;
-				continue;
-			}
-
-			/* set volume to unity gain after module on/off */
-			rc = adm_set_volume(port_id, copp_idx,
-					    VOLUME_UNITY_GAIN);
-			if (rc < 0) {
-				/*
-				 * Not Fatal can continue bypass operations.
-				 * Do not need to block playback
-				 */
-				pr_info("%s: Set vol port %d copp %d, rc %d\n",
-					__func__, port_id, copp_idx, rc);
-				rc = 0;
-			}
-		}
-	}
-
-end:
-	kfree(mod_list);
-	pr_debug("%s:return rc=%d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_ds2_dap_send_end_point(int dev_map_idx, int endp_idx)
-{
-	int rc = 0;
-	int32_t  *update_params_value = NULL, *params_value = NULL;
-	uint32_t params_length = (DOLBY_PARAM_INT_ENDP_LENGTH +
-				DOLBY_PARAM_PAYLOAD_SIZE) * sizeof(uint32_t);
-	int cache_device = 0;
-	struct ds2_dap_params_s *ds2_ap_params_obj = NULL;
-	int32_t *modified_param = NULL;
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		rc = -EINVAL;
-		goto end;
-	}
-	cache_device = dev_map[dev_map_idx].cache_dev;
-
-	ds2_ap_params_obj = &ds2_dap_params[cache_device];
-	pr_debug("%s: cache dev %d, dev_map_idx %d\n", __func__,
-		 cache_device, dev_map_idx);
-	pr_debug("%s: endp - %pK %pK\n",  __func__,
-		 &ds2_dap_params[cache_device], ds2_ap_params_obj);
-
-	params_value = kzalloc(params_length, GFP_KERNEL);
-	if (!params_value) {
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
-		pr_err("%s: invalid port\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].copp_idx < 0) ||
-		(dev_map[dev_map_idx].copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: Invalid copp_idx\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	update_params_value = params_value;
-	*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
-	*update_params_value++ = DOLBY_PARAM_ID_INIT_ENDP;
-	*update_params_value++ = DOLBY_PARAM_INT_ENDP_LENGTH * sizeof(uint32_t);
-	*update_params_value++ = ds2_ap_params_obj->params_val[
-					ds2_dap_params_offset[endp_idx]];
-	pr_debug("%s: off %d, length %d\n", __func__,
-		 ds2_dap_params_offset[endp_idx],
-		 ds2_dap_params_length[endp_idx]);
-	pr_debug("%s: param 0x%x, param val %d\n", __func__,
-		 ds2_dap_params_id[endp_idx], ds2_ap_params_obj->
-		 params_val[ds2_dap_params_offset[endp_idx]]);
-	rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
-				       dev_map[dev_map_idx].copp_idx,
-				       (char *)params_value, params_length);
-	if (rc) {
-		pr_err("%s: send dolby params failed rc %d\n", __func__, rc);
-		rc = -EINVAL;
-	}
-	modified_param = ds2_ap_params_obj->dap_params_modified;
-	if (modified_param == NULL) {
-		pr_err("%s: modified param structure invalid\n",
-		       __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (msm_ds2_dap_check_is_param_modified(modified_param, endp_idx, 0))
-		ds2_ap_params_obj->dap_params_modified[endp_idx] = 0x00010001;
-
-end:
-	kfree(params_value);
-	return rc;
-}
-
-static int msm_ds2_dap_send_cached_params(int dev_map_idx,
-					  int commit)
-{
-	int32_t *update_params_value = NULL, *params_value = NULL;
-	uint32_t idx, i, j, ret = 0;
-	uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
-				(MAX_DS2_PARAMS - 1) *
-				DOLBY_PARAM_PAYLOAD_SIZE) *
-				sizeof(uint32_t);
-	int cache_device = 0;
-	struct ds2_dap_params_s *ds2_ap_params_obj = NULL;
-	int32_t *modified_param = NULL;
-
-	if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
-		pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
-		ret = -EINVAL;
-		goto end;
-	}
-	cache_device = dev_map[dev_map_idx].cache_dev;
-
-	/* Use off profile cache in only for soft bypass */
-	if (ds2_dap_params_states.dap_bypass_type == DAP_SOFT_BYPASS &&
-		ds2_dap_params_states.dap_bypass == true) {
-		pr_debug("%s: use bypass cache 0\n", __func__);
-		cache_device =  dev_map[0].cache_dev;
-	}
-
-	ds2_ap_params_obj = &ds2_dap_params[cache_device];
-	pr_debug("%s: cached param - %pK %pK, cache_device %d\n", __func__,
-		 &ds2_dap_params[cache_device], ds2_ap_params_obj,
-		 cache_device);
-	params_value = kzalloc(params_length, GFP_KERNEL);
-	if (!params_value) {
-		pr_err("%s: params memory alloc failed\n", __func__);
-		ret =  -ENOMEM;
-		goto end;
-	}
-
-	if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
-		pr_err("%s: invalid port id\n", __func__);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	if ((dev_map[dev_map_idx].copp_idx < 0) ||
-		(dev_map[dev_map_idx].copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: Invalid copp_idx\n", __func__);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	update_params_value = params_value;
-	params_length = 0;
-	for (i = 0; i < (MAX_DS2_PARAMS-1); i++) {
-		/*get the pointer to the param modified array in the cache*/
-		modified_param = ds2_ap_params_obj->dap_params_modified;
-		if (modified_param == NULL) {
-			pr_err("%s: modified param structure invalid\n",
-			       __func__);
-			ret = -EINVAL;
-			goto end;
-		}
-		if (!msm_ds2_dap_check_is_param_modified(modified_param, i,
-							 commit))
-			continue;
-		*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
-		*update_params_value++ = ds2_dap_params_id[i];
-		*update_params_value++ = ds2_dap_params_length[i] *
-						sizeof(uint32_t);
-		idx = ds2_dap_params_offset[i];
-		for (j = 0; j < ds2_dap_params_length[i]; j++) {
-			*update_params_value++ =
-					ds2_ap_params_obj->params_val[idx+j];
-			pr_debug("%s: id 0x%x,val %d\n", __func__,
-				 ds2_dap_params_id[i],
-				 ds2_ap_params_obj->params_val[idx+j]);
-		}
-		params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
-				ds2_dap_params_length[i]) * sizeof(uint32_t);
-	}
-
-	pr_debug("%s: valid param length: %d\n", __func__, params_length);
-	if (params_length) {
-		ret = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
-						dev_map[dev_map_idx].copp_idx,
-						(char *)params_value,
-						params_length);
-		if (ret) {
-			pr_err("%s: send dolby params failed ret %d\n",
-				__func__, ret);
-			ret = -EINVAL;
-			goto end;
-		}
-		for (i = 0; i < MAX_DS2_PARAMS-1; i++) {
-			/*get pointer to the param modified array in the cache*/
-			modified_param = ds2_ap_params_obj->dap_params_modified;
-			if (modified_param == NULL) {
-				pr_err("%s: modified param struct invalid\n",
-					__func__);
-				ret = -EINVAL;
-				goto end;
-			}
-			if (!msm_ds2_dap_check_is_param_modified(
-					modified_param, i, commit))
-				continue;
-			ds2_ap_params_obj->dap_params_modified[i] = 0x00010001;
-		}
-	}
-end:
-	kfree(params_value);
-	return ret;
-}
-
-static int msm_ds2_dap_commit_params(struct dolby_param_data *dolby_data,
-				 int commit)
-{
-	int ret = 0, i, idx;
-	struct ds2_dap_params_s *ds2_ap_params_obj =  NULL;
-	int32_t *modified_param = NULL;
-
-	/* Do not commit params if in hard bypass */
-	if (ds2_dap_params_states.dap_bypass_type == DAP_HARD_BYPASS &&
-		ds2_dap_params_states.dap_bypass == true) {
-		pr_debug("%s: called in bypass", __func__);
-		ret = -EINVAL;
-		goto end;
-	}
-	for (idx = 0; idx < MAX_DS2_PARAMS; idx++) {
-		if (ds2_dap_params_id[idx] == DOLBY_PARAM_ID_INIT_ENDP)
-			break;
-	}
-	if (idx >= MAX_DS2_PARAMS || idx < 0) {
-		pr_err("%s: index of DS2 Param not found idx %d\n",
-			__func__, idx);
-		ret = -EINVAL;
-		goto end;
-	}
-	pr_debug("%s: found endp - idx %d 0x%x\n", __func__, idx,
-		ds2_dap_params_id[idx]);
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		pr_debug("%s:dev[0x%x,0x%x],i:%d,active:%d,bypass:%d,type:%d\n",
-			__func__, dolby_data->device_id, dev_map[i].device_id,
-			i, dev_map[i].active, ds2_dap_params_states.dap_bypass,
-			ds2_dap_params_states.dap_bypass_type);
-
-		if (((dev_map[i].device_id & ds2_dap_params_states.device) ||
-			((ds2_dap_params_states.dap_bypass_type ==
-			DAP_SOFT_BYPASS) &&
-			(ds2_dap_params_states.dap_bypass == true))) &&
-			(dev_map[i].active == true)) {
-
-			/*get ptr to the cache storing the params for device*/
-			if ((ds2_dap_params_states.dap_bypass_type ==
-				DAP_SOFT_BYPASS) &&
-				(ds2_dap_params_states.dap_bypass == true))
-				ds2_ap_params_obj =
-					&ds2_dap_params[dev_map[0].cache_dev];
-			else
-				ds2_ap_params_obj =
-					&ds2_dap_params[dev_map[i].cache_dev];
-
-			/*get the pointer to the param modified array in cache*/
-			modified_param = ds2_ap_params_obj->dap_params_modified;
-			if (modified_param == NULL) {
-				pr_err("%s: modified_param NULL\n", __func__);
-				ret = -EINVAL;
-				goto end;
-			}
-
-			/*
-			 * Send the endp param if use cache is set
-			 * or if param is modified
-			 */
-			if (!commit || msm_ds2_dap_check_is_param_modified(
-					modified_param, idx, commit)) {
-				msm_ds2_dap_send_end_point(i, idx);
-				commit = 0;
-			}
-			ret = msm_ds2_dap_send_cached_params(i, commit);
-			if (ret < 0) {
-				pr_err("%s: send cached param %d\n",
-					__func__, ret);
-				goto end;
-			}
-		}
-	}
-end:
-	return ret;
-}
-
-static int msm_ds2_dap_handle_commands(u32 cmd, void *arg)
-{
-	int ret  = 0, port_id = 0;
-	int32_t data;
-	struct dolby_param_data *dolby_data = (struct dolby_param_data *)arg;
-
-	if (get_user(data, &dolby_data->data[0])) {
-		pr_debug("%s error getting data\n", __func__);
-		ret = -EFAULT;
-		goto end;
-	}
-
-	pr_debug("%s: param_id %d,be_id %d,device_id 0x%x,length %d,data %d\n",
-		 __func__, dolby_data->param_id, dolby_data->be_id,
-		dolby_data->device_id, dolby_data->length, data);
-
-	switch (dolby_data->param_id) {
-	case DAP_CMD_COMMIT_ALL:
-		msm_ds2_dap_commit_params(dolby_data, 0);
-	break;
-
-	case DAP_CMD_COMMIT_CHANGED:
-		msm_ds2_dap_commit_params(dolby_data, 1);
-	break;
-
-	case DAP_CMD_USE_CACHE_FOR_INIT:
-		ds2_dap_params_states.use_cache = data;
-	break;
-
-	case DAP_CMD_SET_BYPASS:
-		pr_debug("%s: bypass %d bypass type %d, data %d\n", __func__,
-			 ds2_dap_params_states.dap_bypass,
-			 ds2_dap_params_states.dap_bypass_type,
-			 data);
-		/* Do not perform bypass operation if bypass state is same*/
-		if (ds2_dap_params_states.dap_bypass == data)
-			break;
-		ds2_dap_params_states.dap_bypass = data;
-		/* hard bypass */
-		if (ds2_dap_params_states.dap_bypass_type == DAP_HARD_BYPASS)
-			msm_ds2_dap_handle_bypass(dolby_data);
-		/* soft bypass */
-		msm_ds2_dap_commit_params(dolby_data, 0);
-	break;
-
-	case DAP_CMD_SET_BYPASS_TYPE:
-		if (data == true)
-			ds2_dap_params_states.dap_bypass_type =
-				DAP_HARD_BYPASS;
-		else
-			ds2_dap_params_states.dap_bypass_type =
-				DAP_SOFT_BYPASS;
-		pr_debug("%s: bypass type %d", __func__,
-			 ds2_dap_params_states.dap_bypass_type);
-	break;
-
-	case DAP_CMD_SET_ACTIVE_DEVICE:
-		pr_debug("%s: DAP_CMD_SET_ACTIVE_DEVICE length %d\n",
-			__func__, dolby_data->length);
-		/* TODO: need to handle multiple instance*/
-		ds2_dap_params_states.device |= dolby_data->device_id;
-		port_id = msm_ds2_dap_get_port_id(
-						  dolby_data->device_id,
-						  dolby_data->be_id);
-		pr_debug("%s: device id 0x%x all_dev 0x%x port_id %d\n",
-			__func__, dolby_data->device_id,
-			ds2_dap_params_states.device, port_id);
-		msm_ds2_dap_update_dev_map_port_id(dolby_data->device_id,
-					   port_id);
-		if (port_id == DOLBY_INVALID_PORT_ID) {
-			pr_err("%s: invalid port id %d\n", __func__, port_id);
-			ret = -EINVAL;
-			goto end;
-		}
-	break;
-	}
-end:
-	return ret;
-
-}
-
-static int msm_ds2_dap_set_param(u32 cmd, void *arg)
-{
-	int rc = 0, idx, i, j, off, port_id = 0, cdev = 0;
-	int32_t num_device = 0;
-	int32_t data = 0;
-	int32_t dev_arr[DS2_DSP_SUPPORTED_ENDP_DEVICE] = {0};
-	struct dolby_param_data *dolby_data =  (struct dolby_param_data *)arg;
-
-	rc = msm_ds2_dap_update_num_devices(dolby_data, &num_device, dev_arr,
-				   DS2_DSP_SUPPORTED_ENDP_DEVICE);
-	if (num_device == 0 || rc < 0) {
-		pr_err("%s: num devices 0\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	for (i = 0; i < num_device; i++) {
-		port_id = msm_ds2_dap_get_port_id(dev_arr[i],
-						  dolby_data->be_id);
-		if (port_id != DOLBY_INVALID_PORT_ID)
-			msm_ds2_dap_update_dev_map_port_id(dev_arr[i], port_id);
-
-		cdev = msm_ds2_dap_map_device_to_dolby_cache_devices(
-							  dev_arr[i]);
-		if (cdev < 0 || cdev >= DOLBY_MAX_CACHE) {
-			pr_err("%s: Invalid cache device %d for device 0x%x\n",
-				__func__, cdev, dev_arr[i]);
-			rc = -EINVAL;
-			goto end;
-		}
-		pr_debug("%s:port:%d,be:%d,dev:0x%x,cdev:%d,param:0x%x,len:%d\n"
-			 , __func__, port_id, dolby_data->be_id, dev_arr[i],
-			 cdev, dolby_data->param_id, dolby_data->length);
-		for (idx = 0; idx < MAX_DS2_PARAMS; idx++) {
-			/*paramid from user space*/
-			if (dolby_data->param_id == ds2_dap_params_id[idx])
-				break;
-		}
-		if (idx > MAX_DS2_PARAMS-1) {
-			pr_err("%s: invalid param id 0x%x at idx %d\n",
-				__func__, dolby_data->param_id, idx);
-			rc = -EINVAL;
-			goto end;
-		}
-
-		off = ds2_dap_params_offset[idx];
-		if ((dolby_data->length <= 0) ||
-			(dolby_data->length > TOTAL_LENGTH_DS2_PARAM - off)) {
-			pr_err("%s: invalid length %d at idx %d\n",
-				__func__, dolby_data->length, idx);
-			rc = -EINVAL;
-			goto end;
-		}
-
-		/* cache the parameters */
-		ds2_dap_params[cdev].dap_params_modified[idx] += 1;
-		for (j = 0; j <  dolby_data->length; j++) {
-			if (get_user(data, &dolby_data->data[j])) {
-				pr_debug("%s:error getting data\n", __func__);
-				rc = -EFAULT;
-				goto end;
-			}
-			ds2_dap_params[cdev].params_val[off + j] = data;
-				pr_debug("%s:off %d,val[i/p:o/p]-[%d / %d]\n",
-					 __func__, off, data,
-					 ds2_dap_params[cdev].
-					 params_val[off + j]);
-		}
-	}
-end:
-	return rc;
-}
-
-static int msm_ds2_dap_get_param(u32 cmd, void *arg)
-{
-	int rc = 0, i, port_id = 0, copp_idx = -1;
-	struct dolby_param_data *dolby_data = (struct dolby_param_data *)arg;
-	int32_t *update_params_value = NULL, *params_value = NULL;
-	uint32_t params_length = DOLBY_MAX_LENGTH_INDIVIDUAL_PARAM *
-					sizeof(uint32_t);
-	uint32_t param_payload_len =
-			DOLBY_PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
-
-	/* Return error on get param in soft or hard bypass */
-	if (ds2_dap_params_states.dap_bypass == true) {
-		pr_err("%s: called in bypass_type %d bypass %d\n", __func__,
-			ds2_dap_params_states.dap_bypass_type,
-			ds2_dap_params_states.dap_bypass);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	/* Return if invalid length */
-	if ((dolby_data->length >
-	      (DOLBY_MAX_LENGTH_INDIVIDUAL_PARAM - DOLBY_PARAM_PAYLOAD_SIZE)) ||
-	      (dolby_data->length <= 0)) {
-		pr_err("Invalid length %d", dolby_data->length);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		if ((dev_map[i].active) &&
-			(dev_map[i].device_id & dolby_data->device_id)) {
-			port_id = dev_map[i].port_id;
-			copp_idx = dev_map[i].copp_idx;
-			break;
-		}
-	}
-
-	if (port_id == DOLBY_INVALID_PORT_ID) {
-		pr_err("%s: Invalid port\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if ((copp_idx < 0) || (copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: Invalid copp_idx\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	pr_debug("%s: port_id 0x%x, copp_idx %d, dev_map[i].device_id %x\n",
-		 __func__, port_id, copp_idx, dev_map[i].device_id);
-
-	params_value = kzalloc(params_length + param_payload_len,
-				GFP_KERNEL);
-	if (!params_value) {
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	if (dolby_data->param_id == DOLBY_PARAM_ID_VER) {
-		rc = adm_get_params(port_id, copp_idx,
-				    DOLBY_BUNDLE_MODULE_ID,
-				    DOLBY_PARAM_ID_VER,
-				    params_length + param_payload_len,
-				    (char *)params_value);
-	} else {
-		for (i = 0; i < MAX_DS2_PARAMS; i++)
-			if (ds2_dap_params_id[i] ==
-				dolby_data->param_id)
-				break;
-		if (i > MAX_DS2_PARAMS-1) {
-			pr_err("%s: invalid param id 0x%x at id %d\n", __func__,
-				dolby_data->param_id, i);
-			rc = -EINVAL;
-			goto end;
-		} else {
-			params_length =
-			ds2_dap_params_length[i] * sizeof(uint32_t);
-
-			rc = adm_get_params(port_id, copp_idx,
-					    DOLBY_BUNDLE_MODULE_ID,
-					    ds2_dap_params_id[i],
-					    params_length +
-					    param_payload_len,
-					    (char *)params_value);
-		}
-	}
-	if (rc) {
-		pr_err("%s: get parameters failed rc %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto end;
-	}
-	update_params_value = params_value;
-	if (copy_to_user((void *)dolby_data->data,
-			&update_params_value[DOLBY_PARAM_PAYLOAD_SIZE],
-			(dolby_data->length * sizeof(uint32_t)))) {
-		pr_err("%s: error getting param\n", __func__);
-		rc = -EFAULT;
-		goto end;
-	}
-end:
-	kfree(params_value);
-	return rc;
-}
-
-static int msm_ds2_dap_param_visualizer_control_get(u32 cmd, void *arg)
-{
-	int32_t *visualizer_data = NULL;
-	int  i = 0, ret = 0, port_id = -1, cache_dev = -1, copp_idx = -1;
-	int32_t *update_visualizer_data = NULL;
-	struct dolby_param_data *dolby_data = (struct dolby_param_data *)arg;
-	uint32_t offset, length, params_length;
-	uint32_t param_payload_len =
-		DOLBY_PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
-
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		if ((dev_map[i].active))  {
-			port_id = dev_map[i].port_id;
-			cache_dev = dev_map[i].cache_dev;
-			copp_idx = dev_map[i].copp_idx;
-			break;
-		}
-	}
-
-	if (port_id == DOLBY_INVALID_PORT_ID ||
-		(copp_idx < 0) || (copp_idx >= MAX_COPPS_PER_PORT)) {
-		ret = 0;
-		dolby_data->length = 0;
-		pr_err("%s: no device active\n", __func__);
-		goto end;
-	}
-
-	length = ds2_dap_params[cache_dev].params_val[DOLBY_PARAM_VCNB_OFFSET];
-
-	if (length > DOLBY_PARAM_VCNB_MAX_LENGTH || length <= 0) {
-		ret = 0;
-		dolby_data->length = 0;
-		pr_err("%s Incorrect VCNB length", __func__);
-		return -EINVAL;
-	}
-
-	params_length = (2*length + DOLBY_VIS_PARAM_HEADER_SIZE) *
-							 sizeof(uint32_t);
-
-	visualizer_data = kzalloc(params_length, GFP_KERNEL);
-	if (!visualizer_data) {
-		ret = -ENOMEM;
-		dolby_data->length = 0;
-		goto end;
-	}
-	memset(visualizer_data, 0x0, params_length);
-
-	/* Return error on get param in soft or hard bypass */
-	if (ds2_dap_params_states.dap_bypass == true) {
-		pr_debug("%s: visualizer called in bypass, return 0\n",
-			 __func__);
-		ret = 0;
-		dolby_data->length = 0;
-		goto end;
-	}
-
-	offset = 0;
-	params_length = length * sizeof(uint32_t);
-	ret = adm_get_params(port_id, copp_idx,
-			    DOLBY_BUNDLE_MODULE_ID,
-			    DOLBY_PARAM_ID_VCBG,
-			    params_length + param_payload_len,
-			    (((char *)(visualizer_data)) + offset));
-	if (ret) {
-		pr_err("%s: get parameters failed ret %d\n", __func__, ret);
-		ret = -EINVAL;
-		dolby_data->length = 0;
-		goto end;
-	}
-	offset = length * sizeof(uint32_t);
-	ret = adm_get_params(port_id, copp_idx,
-			    DOLBY_BUNDLE_MODULE_ID,
-			    DOLBY_PARAM_ID_VCBE,
-			    params_length + param_payload_len,
-			    (((char *)(visualizer_data)) + offset));
-	if (ret) {
-		pr_err("%s: get parameters failed ret %d\n", __func__, ret);
-		ret = -EINVAL;
-		dolby_data->length = 0;
-		goto end;
-	}
-	update_visualizer_data = visualizer_data;
-	dolby_data->length = 2 * length;
-
-	if (copy_to_user((void *)dolby_data->data,
-			(void *)update_visualizer_data,
-			(dolby_data->length * sizeof(uint32_t)))) {
-		pr_err("%s: copy to user failed for data\n", __func__);
-		dolby_data->length = 0;
-		ret = -EFAULT;
-		goto end;
-	}
-
-end:
-	kfree(visualizer_data);
-	return ret;
-}
-
-int msm_ds2_dap_set_security_control(u32 cmd, void *arg)
-{
-	struct dolby_param_license *dolby_license =
-				 ((struct dolby_param_license *)arg);
-	pr_debug("%s: dmid %d license key %d\n", __func__,
-		dolby_license->dmid, dolby_license->license_key);
-	core_set_dolby_manufacturer_id(dolby_license->dmid);
-	core_set_license(dolby_license->license_key, DOLBY_DS1_LICENSE_ID);
-	return 0;
-}
-
-int msm_ds2_dap_update_port_parameters(struct snd_hwdep *hw,  struct file *file,
-				       bool open)
-{
-	int  i = 0, dev_id = 0;
-
-	pr_debug("%s: open %d\n", __func__, open);
-	ds2_dap_params_states.node_opened = open;
-	ds2_dap_params_states.dap_bypass = true;
-	ds2_dap_params_states.dap_bypass_type = 0;
-	ds2_dap_params_states.use_cache = 0;
-	ds2_dap_params_states.device = 0;
-	ds2_dap_params_states.custom_stereo_onoff = 0;
-	for (i = 0; i < DS2_DEVICES_ALL; i++) {
-		if (i == 0)
-			dev_map[i].device_id = 0;
-		else {
-			dev_id = (1 << (i-1));
-			if (all_supported_devices & dev_id)
-				dev_map[i].device_id = dev_id;
-			else
-				continue;
-		}
-		dev_map[i].cache_dev =
-			msm_ds2_dap_map_device_to_dolby_cache_devices(
-				    dev_map[i].device_id);
-		if (dev_map[i].cache_dev < 0 ||
-				dev_map[i].cache_dev >= DOLBY_MAX_CACHE)
-			pr_err("%s: Invalid cache device %d for device 0x%x\n",
-						__func__,
-						dev_map[i].cache_dev,
-						dev_map[i].device_id);
-		dev_map[i].port_id = -1;
-		dev_map[i].active = false;
-		dev_map[i].stream_ref_count = 0;
-		dev_map[i].cal_data = NULL;
-		dev_map[i].copp_idx = -1;
-		pr_debug("%s: device_id 0x%x, cache_dev %d act  %d\n", __func__,
-			 dev_map[i].device_id, dev_map[i].cache_dev,
-			 dev_map[i].active);
-	}
-	return 0;
-
-}
-
-int msm_ds2_dap_ioctl_shared(struct snd_hwdep *hw, struct file *file,
-			     u32 cmd, void *arg)
-{
-	int ret = 0;
-
-	pr_debug("%s: cmd: 0x%x\n", __func__, cmd);
-	switch (cmd) {
-	case SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM:
-		ret = msm_ds2_dap_set_param(cmd, arg);
-	break;
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM:
-		ret = msm_ds2_dap_get_param(cmd, arg);
-	break;
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND:
-		ret = msm_ds2_dap_handle_commands(cmd, arg);
-	break;
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE:
-		ret = msm_ds2_dap_set_security_control(cmd, arg);
-	break;
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER:
-		ret = msm_ds2_dap_param_visualizer_control_get(cmd, arg);
-	break;
-	default:
-		pr_err("%s: called with invalid control 0x%x\n", __func__, cmd);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-int msm_ds2_dap_ioctl(struct snd_hwdep *hw, struct file *file,
-		      u32 cmd, void *arg)
-{
-
-	int ret = 0;
-
-	pr_debug("%s: cmd: 0x%x\n", __func__, cmd);
-	if (!arg) {
-		pr_err("%s: Invalid params event status\n", __func__);
-		ret = -EINVAL;
-		goto end;
-	}
-	switch (cmd) {
-	case SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM:
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND: {
-		struct dolby_param_data dolby_data;
-
-		if (copy_from_user((void *)&dolby_data, (void *)arg,
-				sizeof(struct dolby_param_data))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret =  -EFAULT;
-			goto end;
-		}
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_data);
-		break;
-	}
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE: {
-		struct dolby_param_license dolby_license;
-
-		if (copy_from_user((void *)&dolby_license, (void *)arg,
-				sizeof(struct dolby_param_license))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret = -EFAULT;
-			goto end;
-		}
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_license);
-		break;
-	}
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM:
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER: {
-		struct dolby_param_data dolby_data;
-
-		if (copy_from_user((void *)&dolby_data, (void *)arg,
-				sizeof(struct dolby_param_data))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret =  -EFAULT;
-			goto end;
-		}
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_data);
-		if (ret < 0)
-			pr_err("%s: ioctl cmd %d returned err %d\n",
-				__func__, cmd, ret);
-		if (copy_to_user((void *)arg, &dolby_data,
-			sizeof(struct dolby_param_data))) {
-			pr_err("%s: Copy to user failed\n", __func__);
-			ret = -EFAULT;
-			goto end;
-		}
-		break;
-	}
-	default:
-		pr_err("%s: called with invalid control 0x%x\n", __func__, cmd);
-		ret = -EINVAL;
-	}
-end:
-	return ret;
-
-}
-#ifdef CONFIG_COMPAT
-int msm_ds2_dap_compat_ioctl(struct snd_hwdep *hw, struct file *file,
-			     u32 cmd, void *arg)
-{
-	int ret = 0;
-
-	pr_debug("%s: cmd: 0x%x\n", __func__, cmd);
-	switch (cmd) {
-	case SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM32:
-		cmd = SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM;
-		goto handle_set_ioctl;
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND32:
-		cmd = SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND;
-handle_set_ioctl:
-	{
-		struct dolby_param_data32 dolby_data32;
-		struct dolby_param_data dolby_data;
-
-		memset(&dolby_data32, 0, sizeof(dolby_data32));
-		memset(&dolby_data, 0, sizeof(dolby_data));
-		if (copy_from_user(&dolby_data32, (void *)arg,
-				sizeof(struct dolby_param_data32))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret =  -EFAULT;
-			goto end;
-		}
-		dolby_data.version = dolby_data32.version;
-		dolby_data.device_id = dolby_data32.device_id;
-		dolby_data.be_id = dolby_data32.be_id;
-		dolby_data.param_id = dolby_data32.param_id;
-		dolby_data.length = dolby_data32.length;
-		dolby_data.data = compat_ptr(dolby_data32.data);
-
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_data);
-		break;
-	}
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM32:
-		cmd = SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM;
-		goto handle_get_ioctl;
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER32:
-		cmd = SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER;
-handle_get_ioctl:
-	{
-		struct dolby_param_data32 dolby_data32;
-		struct dolby_param_data dolby_data;
-
-		memset(&dolby_data32, 0, sizeof(dolby_data32));
-		memset(&dolby_data, 0, sizeof(dolby_data));
-		if (copy_from_user(&dolby_data32, (void *)arg,
-				sizeof(struct dolby_param_data32))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret =  -EFAULT;
-			goto end;
-		}
-		dolby_data.version = dolby_data32.version;
-		dolby_data.device_id = dolby_data32.device_id;
-		dolby_data.be_id = dolby_data32.be_id;
-		dolby_data.param_id = dolby_data32.param_id;
-		dolby_data.length = dolby_data32.length;
-		dolby_data.data = compat_ptr(dolby_data32.data);
-
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_data);
-		if (ret < 0)
-			pr_err("%s: ioctl cmd %d, returned err %d\n",
-				__func__, cmd, ret);
-		dolby_data32.length = dolby_data.length;
-		if (copy_to_user((void *)arg, &dolby_data32,
-			sizeof(struct dolby_param_data32))) {
-			pr_err("%s: Copy to user failed\n", __func__);
-			ret = -EFAULT;
-			goto end;
-		}
-		break;
-	}
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE32: {
-		struct dolby_param_license32 dolby_license32;
-		struct dolby_param_license dolby_license;
-
-		cmd = SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE;
-		if (copy_from_user((void *)&dolby_license32, (void *)arg,
-			sizeof(struct dolby_param_license32))) {
-			pr_err("%s: Copy from user failed\n", __func__);
-			ret = -EFAULT;
-			goto end;
-		}
-		dolby_license.dmid = dolby_license32.dmid;
-		dolby_license.license_key = dolby_license32.license_key;
-		ret = msm_ds2_dap_ioctl_shared(hw, file, cmd, &dolby_license);
-		break;
-	}
-	default:
-		pr_err("%s: called with invalid control 0x%x\n",
-			__func__, cmd);
-		ret = -EINVAL;
-	}
-end:
-	return ret;
-
-}
-#endif
-
-int msm_ds2_dap_init(int port_id, int copp_idx, int channels,
-		     bool is_custom_stereo_on)
-{
-	int ret = 0, idx = -1, i;
-	struct dolby_param_data dolby_data;
-
-	struct audproc_softvolume_params softvol = {
-		.period = DOLBY_SOFT_VOLUME_PERIOD,
-		.step = DOLBY_SOFT_VOLUME_STEP,
-		.rampingcurve = DOLBY_SOFT_VOLUME_CURVE_EXP,
-	};
-
-	pr_debug("%s: port id  %d, copp_idx %d\n", __func__, port_id, copp_idx);
-
-	if (port_id != DOLBY_INVALID_PORT_ID) {
-		for (i = 0; i < DS2_DEVICES_ALL; i++) {
-			if ((dev_map[i].port_id == port_id) &&
-				/* device part of active device */
-				(dev_map[i].device_id &
-				ds2_dap_params_states.device)) {
-				idx = i;
-				/* Give priority to headset in case of
-				 * combo device
-				 */
-				if (dev_map[i].device_id == SPEAKER)
-					continue;
-				else
-					break;
-			}
-		}
-		if (idx < 0) {
-			pr_err("%s: invalid index for port %d\n",
-				__func__, port_id);
-			ret = -EINVAL;
-			goto end;
-		}
-		pr_debug("%s:index %d, dev[0x%x,0x%x]\n", __func__, idx,
-			 dev_map[idx].device_id, ds2_dap_params_states.device);
-		dev_map[idx].active = true;
-		dev_map[idx].copp_idx = copp_idx;
-		dolby_data.param_id = DOLBY_COMMIT_ALL_TO_DSP;
-		dolby_data.length = 0;
-		dolby_data.data = NULL;
-		dolby_data.device_id = dev_map[idx].device_id;
-		pr_debug("%s:  idx  %d, active %d, dev id 0x%x, ref count %d\n",
-			 __func__, idx, dev_map[idx].active,
-			 dev_map[idx].device_id,
-			 dev_map[idx].stream_ref_count);
-		if (dev_map[idx].stream_ref_count == 0) {
-			/*perform next 3 func only if hard bypass enabled*/
-			if (ds2_dap_params_states.dap_bypass_type ==
-				DAP_HARD_BYPASS) {
-				ret = msm_ds2_dap_alloc_and_store_cal_data(idx,
-						       ADM_PATH_PLAYBACK, 0);
-				if (ret < 0) {
-					pr_err("%s: Failed to alloc and store cal data for idx %d, device %d, copp_idx %d",
-					       __func__,
-					       idx, dev_map[idx].device_id,
-					       dev_map[idx].copp_idx);
-					dev_map[idx].active = false;
-					dev_map[idx].copp_idx = -1;
-					goto end;
-				}
-
-				ret = adm_set_softvolume(port_id, copp_idx,
-							 &softvol);
-				if (ret < 0) {
-					pr_err("%s: Soft volume ret error %d\n",
-						__func__, ret);
-					dev_map[idx].active = false;
-					dev_map[idx].copp_idx = -1;
-					goto end;
-				}
-
-				ret = msm_ds2_dap_init_modules_in_topology(
-							idx);
-				if (ret < 0) {
-					pr_err("%s: Failed to init modules in topolofy for idx %d, device %d, copp_idx %d\n",
-					       __func__, idx,
-					       dev_map[idx].device_id,
-					       dev_map[idx].copp_idx);
-					dev_map[idx].active = false;
-					dev_map[idx].copp_idx = -1;
-					goto end;
-				}
-			}
-
-			ret =  msm_ds2_dap_commit_params(&dolby_data, 0);
-			if (ret < 0) {
-				pr_debug("%s: commit params ret %d\n",
-					__func__, ret);
-				ret = 0;
-			}
-		}
-		dev_map[idx].stream_ref_count++;
-		if (is_custom_stereo_on) {
-			ds2_dap_params_states.custom_stereo_onoff =
-				is_custom_stereo_on;
-			set_custom_stereo_onoff(idx,
-						is_custom_stereo_on);
-		}
-	}
-
-end:
-	return ret;
-}
-
-void msm_ds2_dap_deinit(int port_id)
-{
-	/*
-	 * Get the active port corrresponding to the active device
-	 * Check if this is same as incoming port
-	 * Set it to invalid
-	 */
-	int idx = -1, i;
-
-	pr_debug("%s: port_id %d\n", __func__, port_id);
-	if (port_id != DOLBY_INVALID_PORT_ID) {
-		for (i = 0; i < DS2_DEVICES_ALL; i++) {
-			/* Active port */
-			if ((dev_map[i].port_id == port_id) &&
-				/* device part of active device */
-				(dev_map[i].device_id &
-				ds2_dap_params_states.device) &&
-				/*
-				 * Need this check to avoid race condition of
-				 * active device being set and playback
-				 * instance opened
-				 */
-				/* active device*/
-				dev_map[i].active) {
-				idx = i;
-				if (dev_map[i].device_id == SPEAKER)
-					continue;
-				else
-					break;
-			}
-		}
-		if (idx < 0) {
-			pr_err("%s: invalid index for port %d\n",
-				__func__, port_id);
-			return;
-		}
-		pr_debug("%s:index %d, dev [0x%x, 0x%x]\n", __func__, idx,
-			 dev_map[idx].device_id, ds2_dap_params_states.device);
-		dev_map[idx].stream_ref_count--;
-		if (dev_map[idx].stream_ref_count == 0) {
-			/*perform next func only if hard bypass enabled*/
-			if (ds2_dap_params_states.dap_bypass_type ==
-				DAP_HARD_BYPASS) {
-				msm_ds2_dap_free_cal_data(idx);
-			}
-			ds2_dap_params_states.device &= ~dev_map[idx].device_id;
-			dev_map[idx].active = false;
-			dev_map[idx].copp_idx = -1;
-		}
-		pr_debug("%s:idx  %d, active %d, dev id 0x%x ref count %d\n",
-			 __func__, idx, dev_map[idx].active,
-			 dev_map[idx].device_id, dev_map[idx].stream_ref_count);
-	}
-}
-
-int msm_ds2_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
-					bool is_custom_stereo_enabled)
-{
-	int idx = -1, rc = 0, i;
-
-	pr_debug("%s: port_id %d\n", __func__, port_id);
-	if (port_id != DOLBY_INVALID_PORT_ID) {
-		for (i = 0; i < DS2_DEVICES_ALL; i++) {
-			if ((dev_map[i].port_id == port_id) &&
-				/* device part of active device */
-				(dev_map[i].device_id &
-				ds2_dap_params_states.device)) {
-				idx = i;
-				if (dev_map[i].device_id == SPEAKER)
-					continue;
-				else
-					break;
-			}
-		}
-		if (idx < 0) {
-			pr_err("%s: invalid index for port %d\n",
-				__func__, port_id);
-			return rc;
-		}
-		ds2_dap_params_states.custom_stereo_onoff =
-			is_custom_stereo_enabled;
-		rc = set_custom_stereo_onoff(idx,
-					is_custom_stereo_enabled);
-		if (rc < 0) {
-			pr_err("%s: Custom stereo err %d on port %d\n",
-				__func__, rc, port_id);
-		}
-	}
-	return rc;
-}
-
-#else
-
-static int msm_ds2_dap_alloc_and_store_cal_data(int dev_map_idx, int path,
-					    int perf_mode)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_free_cal_data(int dev_map_idx)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_send_cal_data(int dev_map_idx)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_can_enable_module(int32_t module_id)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_init_modules_in_topology(int dev_map_idx)
-{
-	return 0;
-}
-
-static bool msm_ds2_dap_check_is_param_modified(int32_t *dap_params_modified,
-				    int32_t idx, int32_t commit)
-{
-	return false;
-}
-
-
-static int msm_ds2_dap_map_device_to_dolby_cache_devices(int32_t device_id)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_update_num_devices(struct dolby_param_data *dolby_data,
-				      int32_t *num_device, int32_t *dev_arr,
-				      int32_t array_size)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_commit_params(struct dolby_param_data *dolby_data,
-				 int commit)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_handle_commands(u32 cmd, void *arg)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_set_param(u32 cmd, void *arg)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_get_param(u32 cmd, void *arg)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_send_end_point(int dev_map_idx, int endp_idx)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_send_cached_params(int dev_map_idx,
-					  int commit)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_set_vspe_vdhe(int dev_map_idx,
-				     bool is_custom_stereo_enabled)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_param_visualizer_control_get(
-			u32 cmd, void *arg,
-			struct msm_pcm_routing_bdai_data *bedais)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_set_security_control(u32 cmd, void *arg)
-{
-	return 0
-}
-
-static int msm_ds2_dap_update_dev_map_port_id(int32_t device_id, int port_id)
-{
-	return 0;
-}
-
-static int32_t msm_ds2_dap_get_port_id(
-		int32_t device_id, int32_t be_id)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_handle_bypass(struct dolby_param_data *dolby_data)
-{
-	return 0;
-}
-
-static int msm_ds2_dap_handle_bypass_wait(int port_id, int copp_idx,
-					  int wait_time)
-{
-	return 0;
-}
-
-static int dap_set_custom_stereo_onoff(int dev_map_idx,
-					bool is_custom_stereo_enabled)
-{
-	return 0;
-}
-int qti_set_custom_stereo_on(int port_id, int copp_idx,
-			     bool is_custom_stereo_on)
-{
-	return 0;
-}
-int set_custom_stereo_onoff(int dev_map_idx,
-			    bool is_custom_stereo_enabled)
-{
-	return 0;
-}
-int msm_ds2_dap_ioctl_shared(struct snd_hwdep *hw, struct file *file,
-			     u32 cmd, void *arg)
-{
-	return 0;
-}
-#endif /* CONFIG_DOLBY_DS2 || CONFIG_DOLBY_LICENSE */
diff --git a/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.h b/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.h
deleted file mode 100644
index 5e8c3a6..0000000
--- a/sound/soc/msm/qdsp6v2/msm-ds2-dap-config.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_DS2_DAP_CONFIG_H_
-#define _MSM_DS2_DAP_CONFIG_H_
-
-#include <sound/soc.h>
-#include "msm-dolby-common.h"
-#include <sound/hwdep.h>
-#include <uapi/sound/devdep_params.h>
-
-#ifdef CONFIG_COMPAT
-struct dolby_param_data32 {
-	s32 version;
-	s32 device_id;
-	s32 be_id;
-	s32 param_id;
-	s32 length;
-	compat_uptr_t data;
-};
-
-struct dolby_param_license32 {
-	compat_uptr_t dmid;
-	compat_uptr_t license_key;
-};
-
-
-#define SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM32\
-		_IOWR('U', 0x10, struct dolby_param_data32)
-#define SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM32\
-		_IOR('U', 0x11, struct dolby_param_data32)
-#define SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND32\
-		_IOWR('U', 0x13, struct dolby_param_data32)
-#define SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE32\
-		_IOWR('U', 0x14, struct dolby_param_license32)
-#define SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER32\
-		_IOR('U', 0x15, struct dolby_param_data32)
-#endif
-
-#if defined(CONFIG_DOLBY_DS2) || defined(CONFIG_DOLBY_LICENSE)
-/* DOLBY DOLBY GUIDS */
-#define DS2_MODULE_ID			0x00010775
-
-#define DS2_DSP_SUPPORTED_ENDP_DEVICE		17
-#define DS2_DEVICES_ALL				32 /* enum val is 4 bytes */
-
-enum {
-
-	DAP_CMD_COMMIT_ALL         = 0,
-	DAP_CMD_COMMIT_CHANGED     = 1,
-	DAP_CMD_USE_CACHE_FOR_INIT = 2,
-	DAP_CMD_SET_BYPASS         = 3,
-	DAP_CMD_SET_ACTIVE_DEVICE  = 4,
-	DAP_CMD_SET_BYPASS_TYPE    = 5,
-};
-
-#define DOLBY_PARAM_INT_ENDP_LENGTH             1
-#define DOLBY_PARAM_INT_ENDP_OFFSET		(DOLBY_PARAM_PSTG_OFFSET + \
-							DOLBY_PARAM_PSTG_LENGTH)
-#define MAX_DS2_PARAMS				48
-#define MAX_DS2_CTRL_PARAMS			4
-#define ALL_DS2_PARAMS				(MAX_DS2_PARAMS + \
-							MAX_DS2_CTRL_PARAMS)
-#define TOTAL_LENGTH_DS2_PARAM (TOTAL_LENGTH_DOLBY_PARAM + 1)
-
-int msm_ds2_dap_update_port_parameters(struct snd_hwdep *hw,  struct file *file,
-				       bool open);
-int msm_ds2_dap_ioctl(struct snd_hwdep *hw, struct file *file,
-		      u32 cmd, void *arg);
-int msm_ds2_dap_compat_ioctl(struct snd_hwdep *hw,
-			     struct file *file,
-			     u32 cmd, void *arg);
-int msm_ds2_dap_init(int port_id, int copp_idx, int channels,
-		     bool is_custom_stereo_on);
-void msm_ds2_dap_deinit(int port_id);
-int msm_ds2_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
-					bool is_custom_stereo_enabled);
-/* Dolby DOLBY end */
-#else
-
-static inline int msm_ds2_dap_update_port_parameters(struct snd_hwdep *hw,
-					       struct file *file,
-					       bool open)
-{
-	return 0;
-}
-
-static inline int msm_ds2_dap_ioctl(struct snd_hwdep *hw, struct file *file,
-				    u32 cmd, void *arg)
-{
-	return 0;
-}
-
-static inline int msm_ds2_dap_compat_ioctl(struct snd_hwdep *hw,
-					   struct file *file,
-					   u32 cmd, void *arg)
-{
-	return 0;
-}
-static inline int msm_ds2_dap_init(int port_id, int copp_idx, int channels,
-		     bool is_custom_stereo_on)
-{
-	return 0;
-}
-
-static inline void msm_ds2_dap_deinit(int port_id) { }
-
-static inline int msm_ds2_dap_set_custom_stereo_onoff(int port_id, int copp_idx,
-				    bool is_custom_stereo_enabled)
-{
-	return 0;
-}
-#endif
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.c b/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.c
deleted file mode 100644
index 159f44c..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* Copyright (c) 2012-2014, 2016-2017, The Linux Foundation.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/bitops.h>
-#include <linux/mutex.h>
-#include <linux/atomic.h>
-#include <linux/msm_audio_ion.h>
-#include <sound/control.h>
-#include <sound/q6adm-v2.h>
-#include <sound/asound.h>
-#include "msm-dts-srs-tm-config.h"
-#include "msm-pcm-routing-v2.h"
-
-static int srs_port_id[AFE_MAX_PORTS] = {-1};
-static int srs_copp_idx[AFE_MAX_PORTS] = {-1};
-static union srs_trumedia_params_u msm_srs_trumedia_params;
-static struct ion_client *ion_client;
-static struct ion_handle *ion_handle;
-static struct param_outband po;
-static atomic_t ref_cnt;
-#define ION_MEM_SIZE	(8 * 1024)
-
-static int set_port_id(int port_id, int copp_idx)
-{
-	int index = adm_validate_and_get_port_index(port_id);
-
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
-			port_id);
-		return -EINVAL;
-	}
-	srs_port_id[index] = port_id;
-	srs_copp_idx[index] = copp_idx;
-	return 0;
-}
-
-static void msm_dts_srs_tm_send_params(__s32 port_id, __u32 techs)
-{
-	__s32 index = adm_validate_and_get_port_index(port_id);
-
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id 0x%x\n",
-			__func__, index, port_id);
-		return;
-	}
-	if ((srs_copp_idx[index] < 0) ||
-	    (srs_copp_idx[index] >= MAX_COPPS_PER_PORT)) {
-		pr_debug("%s: send params called before copp open. so, caching\n",
-			 __func__);
-		return;
-	}
-	pr_debug("SRS %s: called, port_id = %d, techs flags = %u\n",
-		__func__, port_id, techs);
-	/* force all if techs is set to 1 */
-	if (techs == 1)
-		techs = 0xFFFFFFFF;
-
-	if (techs & (1 << SRS_ID_WOWHD))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_WOWHD,
-			(void *)&msm_srs_trumedia_params.srs_params.wowhd);
-	if (techs & (1 << SRS_ID_CSHP))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_CSHP,
-			(void *)&msm_srs_trumedia_params.srs_params.cshp);
-	if (techs & (1 << SRS_ID_HPF))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_HPF,
-			(void *)&msm_srs_trumedia_params.srs_params.hpf);
-	if (techs & (1 << SRS_ID_AEQ))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_AEQ,
-			(void *)&msm_srs_trumedia_params.srs_params.aeq);
-	if (techs & (1 << SRS_ID_HL))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_HL,
-			(void *)&msm_srs_trumedia_params.srs_params.hl);
-	if (techs & (1 << SRS_ID_GEQ))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_GEQ,
-			(void *)&msm_srs_trumedia_params.srs_params.geq);
-	if (techs & (1 << SRS_ID_GLOBAL))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_GLOBAL,
-			(void *)&msm_srs_trumedia_params.srs_params.global);
-}
-
-
-static int msm_dts_srs_trumedia_control_get(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = 0;
-	return 0;
-}
-
-static int msm_dts_srs_trumedia_control_set_(int port_id,
-					    struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-
-	__u16 offset, value, max = sizeof(msm_srs_trumedia_params) >> 1;
-
-	if (SRS_CMD_UPLOAD ==
-		(ucontrol->value.integer.value[0] & SRS_CMD_UPLOAD)) {
-		__u32 techs = ucontrol->value.integer.value[0] & 0xFF;
-		__s32 index = adm_validate_and_get_port_index(port_id);
-
-		if (index < 0) {
-			pr_err("%s: Invalid port idx %d port_id 0x%x\n",
-					__func__, index, port_id);
-				return -EINVAL;
-			}
-		pr_debug("SRS %s: send params request, flag = %u\n",
-					__func__, techs);
-		if (srs_port_id[index] >= 0 && techs)
-			msm_dts_srs_tm_send_params(port_id, techs);
-		return 0;
-	}
-	offset = (__u16)((ucontrol->value.integer.value[0] &
-			SRS_PARAM_OFFSET_MASK) >> 16);
-	value = (__u16)(ucontrol->value.integer.value[0] &
-			SRS_PARAM_VALUE_MASK);
-	if (offset < max) {
-		msm_srs_trumedia_params.raw_params[offset] = value;
-		pr_debug("SRS %s: index set... (max %d, requested %d, value 0x%X)\n",
-			 __func__, max, offset, value);
-	} else {
-		pr_err("SRS %s: index out of bounds! (max %d, requested %d)\n",
-		       __func__, max, offset);
-	}
-	return 0;
-}
-
-static int msm_dts_srs_trumedia_control_set(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control normal called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = SLIMBUS_0_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_i2s_set(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control I2S called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = PRIMARY_I2S_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_mi2s_set(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control MI2S called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_hdmi_set(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control HDMI called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = HDMI_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_hdmi[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia HDMI",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_hdmi_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_i2s[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia I2S",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-		SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_i2s_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_mi2s[] = {
-	{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "SRS TruMedia MI2S",
-		.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = snd_soc_info_volsw,
-		.get = msm_dts_srs_trumedia_control_get,
-		.put = msm_dts_srs_trumedia_control_mi2s_set,
-		.private_value = ((unsigned long)&(struct soc_mixer_control)
-		{
-			.reg = SND_SOC_NOPM,
-			.rreg = SND_SOC_NOPM,
-			.shift = 0,
-			.rshift = 0,
-			.max = 0xFFFFFFFF,
-			.platform_max = 0xFFFFFFFF,
-			.invert = 0
-		})
-	}
-};
-
-void msm_dts_srs_tm_add_controls(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls,
-			ARRAY_SIZE(lpa_srs_trumedia_controls));
-
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_hdmi,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_hdmi));
-
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_i2s,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_i2s));
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_mi2s,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_mi2s));
-}
-
-static int reg_ion_mem(void)
-{
-	int rc;
-
-	rc = msm_audio_ion_alloc("SRS_TRUMEDIA", &ion_client, &ion_handle,
-				 ION_MEM_SIZE, &po.paddr, (size_t *)&po.size,
-				 &po.kvaddr);
-	if (rc != 0)
-		pr_err("%s: failed to allocate memory.\n", __func__);
-		pr_debug("%s: exited ion_client = %pK, ion_handle = %pK, phys_addr = %lu, length = %d, vaddr = %pK, rc = 0x%x\n",
-			__func__, ion_client, ion_handle, (long)po.paddr,
-			(unsigned int)po.size, po.kvaddr, rc);
-	return rc;
-}
-
-void msm_dts_srs_tm_ion_memmap(struct param_outband *po_)
-{
-	if (po.kvaddr == NULL) {
-		pr_debug("%s: callingreg_ion_mem()\n", __func__);
-		reg_ion_mem();
-	}
-	po_->size = ION_MEM_SIZE;
-	po_->kvaddr = po.kvaddr;
-	po_->paddr = po.paddr;
-}
-
-static void unreg_ion_mem(void)
-{
-	msm_audio_ion_free(ion_client, ion_handle);
-	po.kvaddr = NULL;
-	po.paddr = 0;
-	po.size = 0;
-}
-
-void msm_dts_srs_tm_deinit(int port_id)
-{
-	set_port_id(port_id, -1);
-	atomic_dec(&ref_cnt);
-	if (po.kvaddr != NULL) {
-		if (!atomic_read(&ref_cnt)) {
-			pr_debug("%s: calling unreg_ion_mem()\n", __func__);
-			unreg_ion_mem();
-		}
-	}
-}
-
-void msm_dts_srs_tm_init(int port_id, int copp_idx)
-{
-	int cur_ref_cnt = 0;
-
-	if (set_port_id(port_id, copp_idx) < 0) {
-		pr_err("%s: Invalid port_id: %d\n", __func__, port_id);
-		return;
-	}
-
-	cur_ref_cnt = atomic_read(&ref_cnt);
-	atomic_inc(&ref_cnt);
-	if (!cur_ref_cnt && po.kvaddr == NULL) {
-		pr_debug("%s: calling reg_ion_mem()\n", __func__);
-		if (reg_ion_mem() != 0) {
-			atomic_dec(&ref_cnt);
-			po.kvaddr = NULL;
-			return;
-		}
-	}
-	msm_dts_srs_tm_send_params(port_id, 1);
-}
diff --git a/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.h b/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.h
deleted file mode 100644
index 1dd7aed..0000000
--- a/sound/soc/msm/qdsp6v2/msm-dts-srs-tm-config.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2012-2014, 2017 The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_DTS_SRS_TM_CONFIG_H_
-#define _MSM_DTS_SRS_TM_CONFIG_H_
-
-#include <sound/soc.h>
-
-struct param_outband;
-
-#ifdef CONFIG_DTS_SRS_TM
-
-union srs_trumedia_params_u {
-	struct srs_trumedia_params srs_params;
-	__u16 raw_params[1];
-};
-
-void msm_dts_srs_tm_ion_memmap(struct param_outband *po_);
-void msm_dts_srs_tm_init(int port_id, int copp_idx);
-void msm_dts_srs_tm_deinit(int port_id);
-void msm_dts_srs_tm_add_controls(struct snd_soc_platform *platform);
-#else
-static inline void msm_dts_srs_tm_ion_memmap(struct param_outband *po_) { }
-static inline void msm_dts_srs_tm_init(int port_id, int copp_idx) { }
-static inline void msm_dts_srs_tm_deinit(int port_id) { }
-static inline void msm_dts_srs_tm_add_controls(
-					struct snd_soc_platform *platform) { }
-
-#endif
-
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-lsm-client.c b/sound/soc/msm/qdsp6v2/msm-lsm-client.c
deleted file mode 100644
index ef3475c..0000000
--- a/sound/soc/msm/qdsp6v2/msm-lsm-client.c
+++ /dev/null
@@ -1,2418 +0,0 @@
-/*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <linux/of.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/freezer.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/timer.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6lsm.h>
-#include <sound/lsm_params.h>
-#include <sound/pcm_params.h>
-#include "msm-pcm-routing-v2.h"
-
-#define CAPTURE_MIN_NUM_PERIODS     2
-#define CAPTURE_MAX_NUM_PERIODS     8
-#define CAPTURE_MAX_PERIOD_SIZE     61440
-#define CAPTURE_MIN_PERIOD_SIZE     320
-#define LISTEN_MAX_STATUS_PAYLOAD_SIZE 256
-
-#define LAB_BUFFER_ALLOC 1
-#define LAB_BUFFER_DEALLOC 0
-
-static struct snd_pcm_hardware msm_pcm_hardware_capture = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
-	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE),
-	.rates =		(SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_48000),
-	.rate_min =             16000,
-	.rate_max =             48000,
-	.channels_min =         1,
-	.channels_max =         4,
-	.buffer_bytes_max =     CAPTURE_MAX_NUM_PERIODS *
-				CAPTURE_MAX_PERIOD_SIZE,
-	.period_bytes_min =	CAPTURE_MIN_PERIOD_SIZE,
-	.period_bytes_max =     CAPTURE_MAX_PERIOD_SIZE,
-	.periods_min =          CAPTURE_MIN_NUM_PERIODS,
-	.periods_max =          CAPTURE_MAX_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	16000, 48000,
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-struct lsm_priv {
-	struct snd_pcm_substream *substream;
-	struct lsm_client *lsm_client;
-	struct snd_lsm_event_status_v3 *event_status;
-	spinlock_t event_lock;
-	wait_queue_head_t event_wait;
-	unsigned long event_avail;
-	atomic_t event_wait_stop;
-	atomic_t buf_count;
-	atomic_t read_abort;
-	wait_queue_head_t period_wait;
-	struct mutex lsm_api_lock;
-	int appl_cnt;
-	int dma_write;
-};
-
-enum { /* lsm session states */
-	IDLE = 0,
-	RUNNING,
-};
-
-static int msm_lsm_queue_lab_buffer(struct lsm_priv *prtd, int i)
-{
-	int rc = 0;
-	struct lsm_cmd_read cmd_read;
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!prtd || !prtd->lsm_client) {
-		pr_err("%s: Invalid params prtd %pK lsm client %pK\n",
-			__func__, prtd, ((!prtd) ? NULL : prtd->lsm_client));
-		return -EINVAL;
-	}
-	if (!prtd->substream || !prtd->substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!prtd->substream) ? "substream" : "private_data");
-		return -EINVAL;
-	}
-	rtd = prtd->substream->private_data;
-
-	if (!prtd->lsm_client->lab_buffer ||
-		i >= prtd->lsm_client->hw_params.period_count) {
-		dev_err(rtd->dev,
-			"%s: Lab buffer not setup %pK incorrect index %d period count %d\n",
-			__func__, prtd->lsm_client->lab_buffer, i,
-			prtd->lsm_client->hw_params.period_count);
-		return -EINVAL;
-	}
-	cmd_read.buf_addr_lsw =
-		lower_32_bits(prtd->lsm_client->lab_buffer[i].phys);
-	cmd_read.buf_addr_msw =
-		msm_audio_populate_upper_32_bits(
-				prtd->lsm_client->lab_buffer[i].phys);
-	cmd_read.buf_size = prtd->lsm_client->lab_buffer[i].size;
-	cmd_read.mem_map_handle =
-		prtd->lsm_client->lab_buffer[i].mem_map_handle;
-	rc = q6lsm_read(prtd->lsm_client, &cmd_read);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: error in queuing the lab buffer rc %d\n",
-			__func__, rc);
-	return rc;
-}
-
-static int lsm_lab_buffer_sanity(struct lsm_priv *prtd,
-		struct lsm_cmd_read_done *read_done, int *index)
-{
-	int i = 0, rc = -EINVAL;
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!prtd || !read_done || !index) {
-		pr_err("%s: Invalid params prtd %pK read_done %pK index %pK\n",
-			__func__, prtd, read_done, index);
-		return -EINVAL;
-	}
-
-	if (!prtd->substream || !prtd->substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!prtd->substream) ? "substream" : "private_data");
-		return -EINVAL;
-	}
-	rtd = prtd->substream->private_data;
-
-	if (!prtd->lsm_client->lab_enable || !prtd->lsm_client->lab_buffer) {
-		dev_err(rtd->dev,
-			"%s: Lab not enabled %d invalid lab buffer %pK\n",
-			__func__, prtd->lsm_client->lab_enable,
-			prtd->lsm_client->lab_buffer);
-		return -EINVAL;
-	}
-	for (i = 0; i < prtd->lsm_client->hw_params.period_count; i++) {
-		if ((lower_32_bits(prtd->lsm_client->lab_buffer[i].phys) ==
-			read_done->buf_addr_lsw) &&
-			(msm_audio_populate_upper_32_bits
-				(prtd->lsm_client->lab_buffer[i].phys) ==
-			read_done->buf_addr_msw) &&
-			(prtd->lsm_client->lab_buffer[i].mem_map_handle ==
-			read_done->mem_map_handle)) {
-			dev_dbg(rtd->dev,
-				"%s: Buffer found %pK memmap handle %d\n",
-				__func__, &prtd->lsm_client->lab_buffer[i].phys,
-			prtd->lsm_client->lab_buffer[i].mem_map_handle);
-			if (read_done->total_size >
-				prtd->lsm_client->lab_buffer[i].size) {
-				dev_err(rtd->dev,
-					"%s: Size mismatch call back size %d actual size %zd\n",
-					__func__, read_done->total_size,
-				prtd->lsm_client->lab_buffer[i].size);
-				rc = -EINVAL;
-				break;
-			} else {
-				*index = i;
-				rc = 0;
-				break;
-			}
-		}
-	}
-	return rc;
-}
-
-static void lsm_event_handler(uint32_t opcode, uint32_t token,
-			      void *payload, void *priv)
-{
-	unsigned long flags;
-	struct lsm_priv *prtd = priv;
-	struct snd_pcm_substream *substream = prtd->substream;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_lsm_event_status_v3 *temp;
-	uint16_t status = 0;
-	uint16_t payload_size = 0;
-	uint16_t index = 0;
-	uint32_t event_ts_lsw = 0;
-	uint32_t event_ts_msw = 0;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!substream) ? "substream" : "private_data");
-		return;
-	}
-	rtd = substream->private_data;
-
-	switch (opcode) {
-	case LSM_DATA_EVENT_READ_DONE: {
-		int rc;
-		struct lsm_cmd_read_done *read_done = payload;
-		int buf_index = 0;
-
-		if (prtd->lsm_client->session != token ||
-		    !read_done) {
-			dev_err(rtd->dev,
-				"%s: EVENT_READ_DONE invalid callback, session %d callback %d payload %pK",
-				__func__, prtd->lsm_client->session,
-				token, read_done);
-			return;
-		}
-		if (atomic_read(&prtd->read_abort)) {
-			dev_dbg(rtd->dev,
-				"%s: read abort set skip data\n", __func__);
-			return;
-		}
-		if (!lsm_lab_buffer_sanity(prtd, read_done, &buf_index)) {
-			dev_dbg(rtd->dev,
-				"%s: process read done index %d\n",
-				__func__, buf_index);
-			if (buf_index >=
-				prtd->lsm_client->hw_params.period_count) {
-				dev_err(rtd->dev,
-					"%s: Invalid index %d buf_index max cnt %d\n",
-					__func__, buf_index,
-				prtd->lsm_client->hw_params.period_count);
-				return;
-			}
-			prtd->dma_write += read_done->total_size;
-			atomic_inc(&prtd->buf_count);
-			snd_pcm_period_elapsed(substream);
-			wake_up(&prtd->period_wait);
-			/* queue the next period buffer */
-			buf_index = (buf_index + 1) %
-			prtd->lsm_client->hw_params.period_count;
-			rc = msm_lsm_queue_lab_buffer(prtd, buf_index);
-			if (rc)
-				dev_err(rtd->dev,
-					"%s: error in queuing the lab buffer rc %d\n",
-					__func__, rc);
-		} else
-			dev_err(rtd->dev, "%s: Invalid lab buffer returned by dsp\n",
-				__func__);
-		break;
-	}
-
-	case LSM_SESSION_EVENT_DETECTION_STATUS:
-		status = (uint16_t)((uint8_t *)payload)[0];
-		payload_size = (uint16_t)((uint8_t *)payload)[2];
-		index = 4;
-		dev_dbg(rtd->dev,
-			"%s: event detect status = %d payload size = %d\n",
-			__func__, status, payload_size);
-	break;
-
-	case LSM_SESSION_EVENT_DETECTION_STATUS_V2:
-		status = (uint16_t)((uint8_t *)payload)[0];
-		payload_size = (uint16_t)((uint8_t *)payload)[1];
-		index = 2;
-		dev_dbg(rtd->dev,
-			"%s: event detect status = %d payload size = %d\n",
-			__func__, status, payload_size);
-		break;
-
-	case LSM_SESSION_EVENT_DETECTION_STATUS_V3:
-		event_ts_lsw = ((uint32_t *)payload)[0];
-		event_ts_msw = ((uint32_t *)payload)[1];
-		status = (uint16_t)((uint8_t *)payload)[8];
-		payload_size = (uint16_t)((uint8_t *)payload)[9];
-		index = 10;
-		dev_dbg(rtd->dev,
-			"%s: ts_msw = %u, ts_lsw = %u, event detect status = %d payload size = %d\n",
-			__func__, event_ts_msw, event_ts_lsw, status,
-			payload_size);
-		break;
-
-	default:
-		break;
-	}
-
-	if (opcode == LSM_SESSION_EVENT_DETECTION_STATUS ||
-		opcode == LSM_SESSION_EVENT_DETECTION_STATUS_V2 ||
-		opcode == LSM_SESSION_EVENT_DETECTION_STATUS_V3) {
-		spin_lock_irqsave(&prtd->event_lock, flags);
-		temp = krealloc(prtd->event_status,
-				sizeof(struct snd_lsm_event_status_v3) +
-				payload_size, GFP_ATOMIC);
-		if (!temp) {
-			dev_err(rtd->dev, "%s: no memory for event status\n",
-				__func__);
-			return;
-		}
-		/*
-		 * event status timestamp will be non-zero and valid if
-		 * opcode is LSM_SESSION_EVENT_DETECTION_STATUS_V3
-		 */
-		prtd->event_status = temp;
-		prtd->event_status->timestamp_lsw = event_ts_lsw;
-		prtd->event_status->timestamp_msw = event_ts_msw;
-		prtd->event_status->status = status;
-		prtd->event_status->payload_size = payload_size;
-
-		if (likely(prtd->event_status)) {
-			memcpy(prtd->event_status->payload,
-			       &((uint8_t *)payload)[index],
-			       payload_size);
-			prtd->event_avail = 1;
-			spin_unlock_irqrestore(&prtd->event_lock, flags);
-			wake_up(&prtd->event_wait);
-		} else {
-			spin_unlock_irqrestore(&prtd->event_lock, flags);
-			dev_err(rtd->dev,
-				"%s: Couldn't allocate %d bytes of memory\n",
-				__func__, payload_size);
-		}
-		if (substream->timer_running)
-			snd_timer_interrupt(substream->timer, 1);
-	}
-}
-
-static int msm_lsm_lab_buffer_alloc(struct lsm_priv *lsm, int alloc)
-{
-	int ret = 0;
-	struct snd_dma_buffer *dma_buf = NULL;
-
-	if (!lsm) {
-		pr_err("%s: Invalid param lsm %pK\n", __func__, lsm);
-		return -EINVAL;
-	}
-	if (alloc) {
-		if (!lsm->substream) {
-			pr_err("%s: substream is NULL\n", __func__);
-			return -EINVAL;
-		}
-		ret = q6lsm_lab_buffer_alloc(lsm->lsm_client, alloc);
-		if (ret) {
-			pr_err("%s: alloc lab buffer failed ret %d\n",
-				__func__, ret);
-			goto exit;
-		}
-		dma_buf = &lsm->substream->dma_buffer;
-		dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-		dma_buf->dev.dev = lsm->substream->pcm->card->dev;
-		dma_buf->private_data = NULL;
-		dma_buf->area = lsm->lsm_client->lab_buffer[0].data;
-		dma_buf->addr = lsm->lsm_client->lab_buffer[0].phys;
-		dma_buf->bytes = lsm->lsm_client->hw_params.buf_sz *
-		lsm->lsm_client->hw_params.period_count;
-		snd_pcm_set_runtime_buffer(lsm->substream, dma_buf);
-	} else {
-		ret = q6lsm_lab_buffer_alloc(lsm->lsm_client, alloc);
-		if (ret)
-			pr_err("%s: free lab buffer failed ret %d\n",
-				__func__, ret);
-		kfree(lsm->lsm_client->lab_buffer);
-		lsm->lsm_client->lab_buffer = NULL;
-	}
-exit:
-	return ret;
-}
-
-static int msm_lsm_get_conf_levels(struct lsm_client *client,
-				   u8 *conf_levels_ptr)
-{
-	int rc = 0;
-
-	if (client->num_confidence_levels == 0) {
-		pr_debug("%s: no confidence levels provided\n",
-			__func__);
-		client->confidence_levels = NULL;
-		goto done;
-	}
-
-	client->confidence_levels =
-		kzalloc((sizeof(uint8_t) * client->num_confidence_levels),
-			 GFP_KERNEL);
-	if (!client->confidence_levels) {
-		pr_err("%s: No memory for confidence\n"
-			"levels num of level from user = %d\n",
-			__func__, client->num_confidence_levels);
-			rc = -ENOMEM;
-			goto done;
-	}
-
-	if (copy_from_user(client->confidence_levels,
-			   conf_levels_ptr,
-			   client->num_confidence_levels)) {
-		pr_err("%s: copy from user failed, size = %d\n",
-		       __func__, client->num_confidence_levels);
-		rc = -EFAULT;
-		goto copy_err;
-	}
-
-	return rc;
-
-copy_err:
-	kfree(client->confidence_levels);
-	client->confidence_levels = NULL;
-done:
-	return rc;
-
-}
-
-static int msm_lsm_set_epd(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-	struct snd_lsm_ep_det_thres epd_th;
-
-	if (p_info->param_size != sizeof(epd_th)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&epd_th, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 &epd_th, LSM_ENDPOINT_DETECT_THRESHOLD);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set epd param, err = %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_lsm_set_mode(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_lsm_detect_mode mode;
-	int rc = 0;
-
-	if (p_info->param_size != sizeof(mode)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&mode, p_info->param_data,
-			   sizeof(mode))) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %zd\n",
-			__func__, sizeof(mode));
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 &mode, LSM_OPERATION_MODE);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set det_mode param, err = %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_lsm_set_gain(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_lsm_gain gain;
-	int rc = 0;
-
-	if (p_info->param_size != sizeof(gain)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&gain, p_info->param_data,
-			   sizeof(gain))) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %zd\n",
-			__func__, sizeof(gain));
-		rc = -EFAULT;
-		goto done;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 &gain, LSM_GAIN);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set det_mode param, err = %d\n",
-			__func__, rc);
-done:
-	return rc;
-}
-
-static int msm_lsm_set_conf(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-
-	if (p_info->param_size > MAX_NUM_CONFIDENCE) {
-		dev_err(rtd->dev,
-			"%s: invalid confidence levels %d\n",
-			__func__, p_info->param_size);
-		return -EINVAL;
-	}
-
-	prtd->lsm_client->num_confidence_levels =
-			p_info->param_size;
-	rc = msm_lsm_get_conf_levels(prtd->lsm_client,
-				     p_info->param_data);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: get_conf_levels failed, err = %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 prtd->lsm_client->confidence_levels,
-				 LSM_MIN_CONFIDENCE_LEVELS);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set min_conf_levels, err = %d\n",
-			__func__, rc);
-
-	return rc;
-}
-
-static int msm_lsm_reg_model(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-	u8 *snd_model_ptr;
-	size_t offset;
-
-	rc = q6lsm_snd_model_buf_alloc(prtd->lsm_client,
-				       p_info->param_size,
-				       true);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: snd_model buf alloc failed, size = %d\n",
-			__func__, p_info->param_size);
-		return rc;
-	}
-
-	q6lsm_sm_set_param_data(prtd->lsm_client, p_info, &offset);
-
-	/*
-	 * For set_param, advance the sound model data with the
-	 * number of bytes required by param_data.
-	 */
-	snd_model_ptr = ((u8 *) prtd->lsm_client->sound_model.data) + offset;
-
-	if (copy_from_user(snd_model_ptr,
-			   p_info->param_data, p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user for snd_model failed, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto err_copy;
-	}
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info, NULL,
-				 LSM_REG_SND_MODEL);
-	if (rc) {
-		dev_err(rtd->dev,
-			"%s: Failed to set sound_model, err = %d\n",
-			__func__, rc);
-		goto err_copy;
-	}
-	return rc;
-
-err_copy:
-	q6lsm_snd_model_buf_free(prtd->lsm_client);
-	return rc;
-}
-
-static int msm_lsm_dereg_model(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int rc = 0;
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 NULL, LSM_DEREG_SND_MODEL);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set det_mode param, err = %d\n",
-			__func__, rc);
-
-	q6lsm_snd_model_buf_free(prtd->lsm_client);
-
-	return rc;
-}
-
-static int msm_lsm_set_custom(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	u8 *data;
-	int rc = 0;
-
-	data = kzalloc(p_info->param_size, GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	if (copy_from_user(data, p_info->param_data,
-			   p_info->param_size)) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed for custom params, size = %d\n",
-			__func__, p_info->param_size);
-		rc = -EFAULT;
-		goto err_ret;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 data, LSM_CUSTOM_PARAMS);
-	if (rc)
-		dev_err(rtd->dev,
-			"%s: Failed to set custom param, err = %d\n",
-			__func__, rc);
-
-err_ret:
-	kfree(data);
-	return rc;
-}
-
-static int msm_lsm_set_poll_enable(struct snd_pcm_substream *substream,
-		struct lsm_params_info *p_info)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_lsm_poll_enable poll_enable;
-	int rc = 0;
-
-	if (p_info->param_size != sizeof(poll_enable)) {
-		dev_err(rtd->dev,
-			"%s: Invalid param_size %d\n",
-			__func__, p_info->param_size);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (copy_from_user(&poll_enable, p_info->param_data,
-			   sizeof(poll_enable))) {
-		dev_err(rtd->dev,
-			"%s: copy_from_user failed, size = %zd\n",
-			__func__, sizeof(poll_enable));
-		rc = -EFAULT;
-		goto done;
-	}
-
-	if (prtd->lsm_client->poll_enable == poll_enable.poll_en) {
-		dev_dbg(rtd->dev,
-			"%s: Polling for session %d already %s\n",
-			__func__, prtd->lsm_client->session,
-			(poll_enable.poll_en ? "enabled" : "disabled"));
-		rc = 0;
-		goto done;
-	}
-
-	rc = q6lsm_set_one_param(prtd->lsm_client, p_info,
-				 &poll_enable, LSM_POLLING_ENABLE);
-	if (!rc) {
-		prtd->lsm_client->poll_enable = poll_enable.poll_en;
-	} else {
-		dev_err(rtd->dev,
-			"%s: Failed to set poll enable, err = %d\n",
-			__func__, rc);
-	}
-done:
-	return rc;
-}
-
-static int msm_lsm_process_params(struct snd_pcm_substream *substream,
-		struct snd_lsm_module_params *p_data,
-		void *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct lsm_params_info *p_info;
-	int i;
-	int rc = 0;
-
-	p_info = (struct lsm_params_info *) params;
-
-	for (i = 0; i < p_data->num_params; i++) {
-		dev_dbg(rtd->dev,
-			"%s: param (%d), module_id = 0x%x, param_id = 0x%x, param_size = 0x%x, param_type = 0x%x\n",
-			__func__, i, p_info->module_id,
-			p_info->param_id, p_info->param_size,
-			p_info->param_type);
-
-		switch (p_info->param_type) {
-		case LSM_ENDPOINT_DETECT_THRESHOLD:
-			rc = msm_lsm_set_epd(substream, p_info);
-			break;
-		case LSM_OPERATION_MODE:
-			rc = msm_lsm_set_mode(substream, p_info);
-			break;
-		case LSM_GAIN:
-			rc = msm_lsm_set_gain(substream, p_info);
-			break;
-		case LSM_MIN_CONFIDENCE_LEVELS:
-			rc = msm_lsm_set_conf(substream, p_info);
-			break;
-		case LSM_REG_SND_MODEL:
-			rc = msm_lsm_reg_model(substream, p_info);
-			break;
-		case LSM_DEREG_SND_MODEL:
-			rc = msm_lsm_dereg_model(substream, p_info);
-			break;
-		case LSM_CUSTOM_PARAMS:
-			rc = msm_lsm_set_custom(substream, p_info);
-			break;
-		case LSM_POLLING_ENABLE:
-			rc = msm_lsm_set_poll_enable(substream, p_info);
-			break;
-		default:
-			dev_err(rtd->dev,
-				"%s: Invalid param_type %d\n",
-				__func__, p_info->param_type);
-			rc = -EINVAL;
-			break;
-		}
-		if (rc) {
-			pr_err("%s: set_param fail for param_type %d\n",
-				__func__, p_info->param_type);
-			return rc;
-		}
-
-		p_info++;
-	}
-
-	return rc;
-}
-
-static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	struct snd_soc_pcm_runtime *rtd;
-	unsigned long flags;
-	int ret;
-	struct snd_lsm_sound_model_v2 snd_model_v2;
-	struct snd_lsm_session_data session_data;
-	int rc = 0;
-	int xchg = 0;
-	struct snd_pcm_runtime *runtime;
-	struct lsm_priv *prtd;
-	struct snd_lsm_detection_params det_params;
-	uint8_t *confidence_level = NULL;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!substream) ? "substream" : "private_data");
-		return -EINVAL;
-	}
-
-	runtime = substream->runtime;
-	prtd = runtime->private_data;
-	rtd = substream->private_data;
-
-	switch (cmd) {
-	case SNDRV_LSM_SET_SESSION_DATA:
-		dev_dbg(rtd->dev, "%s: set session data\n", __func__);
-		if (copy_from_user(&session_data, arg,
-				   sizeof(session_data))) {
-			dev_err(rtd->dev, "%s: %s: copy_from_user failed\n",
-				__func__, "LSM_SET_SESSION_DATA");
-			return -EFAULT;
-		}
-
-		if (session_data.app_id != LSM_VOICE_WAKEUP_APP_ID_V2) {
-			dev_err(rtd->dev,
-				"%s:Invalid App id %d for Listen client\n",
-			       __func__, session_data.app_id);
-			rc = -EINVAL;
-			break;
-		}
-
-		prtd->lsm_client->app_id = session_data.app_id;
-		ret = q6lsm_open(prtd->lsm_client,
-				 prtd->lsm_client->app_id);
-		if (ret < 0) {
-			dev_err(rtd->dev,
-				"%s: lsm open failed, %d\n",
-				__func__, ret);
-			return ret;
-		}
-		prtd->lsm_client->opened = true;
-		dev_dbg(rtd->dev, "%s: Session_ID = %d, APP ID = %d\n",
-			__func__,
-			prtd->lsm_client->session,
-			prtd->lsm_client->app_id);
-		break;
-	case SNDRV_LSM_REG_SND_MODEL_V2:
-		dev_dbg(rtd->dev, "%s: Registering sound model V2\n",
-			__func__);
-		memcpy(&snd_model_v2, arg,
-		       sizeof(struct snd_lsm_sound_model_v2));
-		if (snd_model_v2.num_confidence_levels >
-		    MAX_NUM_CONFIDENCE) {
-			dev_err(rtd->dev,
-				"%s: Invalid conf_levels = %d, maximum allowed = %d\n",
-				__func__, snd_model_v2.num_confidence_levels,
-				MAX_NUM_CONFIDENCE);
-			rc = -EINVAL;
-			break;
-		}
-		rc = q6lsm_snd_model_buf_alloc(prtd->lsm_client,
-					       snd_model_v2.data_size, false);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: q6lsm buffer alloc failed V2, size %d\n",
-			       __func__, snd_model_v2.data_size);
-			break;
-		}
-		if (copy_from_user(prtd->lsm_client->sound_model.data,
-			   snd_model_v2.data, snd_model_v2.data_size)) {
-			dev_err(rtd->dev,
-				"%s: copy from user data failed\n"
-			       "data %pK size %d\n", __func__,
-			       snd_model_v2.data, snd_model_v2.data_size);
-			q6lsm_snd_model_buf_free(prtd->lsm_client);
-			rc = -EFAULT;
-			break;
-		}
-
-		dev_dbg(rtd->dev, "SND Model Magic no byte[0] %x,\n"
-			 "byte[1] %x, byte[2] %x byte[3] %x\n",
-			 snd_model_v2.data[0], snd_model_v2.data[1],
-			 snd_model_v2.data[2], snd_model_v2.data[3]);
-		prtd->lsm_client->num_confidence_levels =
-			snd_model_v2.num_confidence_levels;
-
-		rc = msm_lsm_get_conf_levels(prtd->lsm_client,
-				snd_model_v2.confidence_level);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: get_conf_levels failed, err = %d\n",
-				__func__, rc);
-			break;
-		}
-
-		rc = q6lsm_register_sound_model(prtd->lsm_client,
-					snd_model_v2.detection_mode,
-					snd_model_v2.detect_failure);
-		if (rc < 0) {
-			dev_err(rtd->dev,
-				"%s: Register snd Model v2 failed =%d\n",
-			       __func__, rc);
-			kfree(confidence_level);
-			q6lsm_snd_model_buf_free(prtd->lsm_client);
-		}
-
-		kfree(prtd->lsm_client->confidence_levels);
-		prtd->lsm_client->confidence_levels = NULL;
-		break;
-
-	case SNDRV_LSM_SET_PARAMS:
-		dev_dbg(rtd->dev, "%s: set_params\n", __func__);
-		memcpy(&det_params, arg,
-			sizeof(det_params));
-		if (det_params.num_confidence_levels >
-		    MAX_NUM_CONFIDENCE) {
-			rc = -EINVAL;
-			break;
-		}
-
-		prtd->lsm_client->num_confidence_levels =
-			det_params.num_confidence_levels;
-
-		rc = msm_lsm_get_conf_levels(prtd->lsm_client,
-				det_params.conf_level);
-		if (rc) {
-			dev_err(rtd->dev,
-				"%s: Failed to get conf_levels, err = %d\n",
-				__func__, rc);
-			break;
-		}
-
-		rc = q6lsm_set_data(prtd->lsm_client,
-			       det_params.detect_mode,
-			       det_params.detect_failure);
-		if (rc)
-			dev_err(rtd->dev,
-				"%s: Failed to set params, err = %d\n",
-				__func__, rc);
-
-		kfree(prtd->lsm_client->confidence_levels);
-		prtd->lsm_client->confidence_levels = NULL;
-
-		break;
-
-	case SNDRV_LSM_DEREG_SND_MODEL:
-		dev_dbg(rtd->dev, "%s: Deregistering sound model\n",
-			__func__);
-		rc = q6lsm_deregister_sound_model(prtd->lsm_client);
-		if (rc)
-			dev_err(rtd->dev,
-				"%s: Sound model de-register failed, err = %d\n",
-				__func__, rc);
-		break;
-
-	case SNDRV_LSM_EVENT_STATUS:
-	case SNDRV_LSM_EVENT_STATUS_V3: {
-		uint32_t ts_lsw, ts_msw;
-		uint16_t status = 0, payload_size = 0;
-
-		dev_dbg(rtd->dev, "%s: Get event status\n", __func__);
-		atomic_set(&prtd->event_wait_stop, 0);
-
-		/*
-		 * Release the api lock before wait to allow
-		 * other IOCTLs to be invoked while waiting
-		 * for event
-		 */
-		mutex_unlock(&prtd->lsm_api_lock);
-		rc = wait_event_freezable(prtd->event_wait,
-				(cmpxchg(&prtd->event_avail, 1, 0) ||
-				 (xchg = atomic_cmpxchg(&prtd->event_wait_stop,
-							1, 0))));
-		mutex_lock(&prtd->lsm_api_lock);
-		dev_dbg(rtd->dev, "%s: wait_event_freezable %d event_wait_stop %d\n",
-			 __func__, rc, xchg);
-		if (!rc && !xchg) {
-			dev_dbg(rtd->dev, "%s: New event available %ld\n",
-				__func__, prtd->event_avail);
-			spin_lock_irqsave(&prtd->event_lock, flags);
-
-			if (prtd->event_status) {
-				payload_size = prtd->event_status->payload_size;
-				ts_lsw = prtd->event_status->timestamp_lsw;
-				ts_msw = prtd->event_status->timestamp_msw;
-				status = prtd->event_status->status;
-				spin_unlock_irqrestore(&prtd->event_lock,
-						       flags);
-			} else {
-				spin_unlock_irqrestore(&prtd->event_lock,
-						       flags);
-				rc = -EINVAL;
-				dev_err(rtd->dev,
-					"%s: prtd->event_status is NULL\n",
-					__func__);
-				break;
-			}
-
-			if (cmd == SNDRV_LSM_EVENT_STATUS) {
-				struct snd_lsm_event_status *user = arg;
-
-				if (user->payload_size < payload_size) {
-					dev_dbg(rtd->dev,
-						"%s: provided %d bytes isn't enough, needs %d bytes\n",
-						__func__, user->payload_size,
-						payload_size);
-					rc = -ENOMEM;
-				} else {
-					user->status = status;
-					user->payload_size = payload_size;
-					memcpy(user->payload,
-						prtd->event_status->payload,
-						payload_size);
-				}
-			} else {
-				struct snd_lsm_event_status_v3 *user_v3 = arg;
-
-				if (user_v3->payload_size < payload_size) {
-					dev_dbg(rtd->dev,
-						"%s: provided %d bytes isn't enough, needs %d bytes\n",
-						__func__, user_v3->payload_size,
-						payload_size);
-					rc = -ENOMEM;
-				} else {
-					user_v3->timestamp_lsw = ts_lsw;
-					user_v3->timestamp_msw = ts_msw;
-					user_v3->status = status;
-					user_v3->payload_size = payload_size;
-					memcpy(user_v3->payload,
-						prtd->event_status->payload,
-						payload_size);
-				}
-			}
-			if (!rc) {
-				if (prtd->lsm_client->lab_enable
-					&& !prtd->lsm_client->lab_started
-					&& prtd->event_status->status ==
-					LSM_VOICE_WAKEUP_STATUS_DETECTED) {
-					atomic_set(&prtd->read_abort, 0);
-					atomic_set(&prtd->buf_count, 0);
-					prtd->appl_cnt = 0;
-					prtd->dma_write = 0;
-					rc = msm_lsm_queue_lab_buffer(prtd,
-						0);
-					if (rc)
-						dev_err(rtd->dev,
-							"%s: Queue buffer failed for lab rc = %d\n",
-							__func__, rc);
-					else
-						prtd->lsm_client->lab_started
-						= true;
-				}
-			}
-		} else if (xchg) {
-			dev_dbg(rtd->dev, "%s: Wait aborted\n", __func__);
-			rc = 0;
-		}
-		break;
-	}
-
-	case SNDRV_LSM_ABORT_EVENT:
-		dev_dbg(rtd->dev, "%s: Aborting event status wait\n",
-			__func__);
-		atomic_set(&prtd->event_wait_stop, 1);
-		wake_up(&prtd->event_wait);
-		break;
-
-	case SNDRV_LSM_START:
-		dev_dbg(rtd->dev, "%s: Starting LSM client session\n",
-			__func__);
-		if (!prtd->lsm_client->started) {
-			ret = q6lsm_start(prtd->lsm_client, true);
-			if (!ret) {
-				prtd->lsm_client->started = true;
-				dev_dbg(rtd->dev, "%s: LSM client session started\n",
-					 __func__);
-			}
-		}
-		break;
-
-	case SNDRV_LSM_STOP: {
-		dev_dbg(rtd->dev,
-			"%s: Stopping LSM client session\n",
-			__func__);
-		if (prtd->lsm_client->started) {
-			if (prtd->lsm_client->lab_enable) {
-				atomic_set(&prtd->read_abort, 1);
-				if (prtd->lsm_client->lab_started) {
-					ret = q6lsm_stop_lab(prtd->lsm_client);
-					if (ret)
-						dev_err(rtd->dev,
-							"%s: stop lab failed ret %d\n",
-							__func__, ret);
-					prtd->lsm_client->lab_started = false;
-				}
-			}
-			ret = q6lsm_stop(prtd->lsm_client, true);
-			if (!ret)
-				dev_dbg(rtd->dev,
-					"%s: LSM client session stopped %d\n",
-					__func__, ret);
-			prtd->lsm_client->started = false;
-		}
-		break;
-	}
-	case SNDRV_LSM_LAB_CONTROL: {
-		u32 enable;
-
-		if (copy_from_user(&enable, arg, sizeof(enable))) {
-			dev_err(rtd->dev, "%s: %s: copy_frm_user failed\n",
-				__func__, "LSM_LAB_CONTROL");
-			return -EFAULT;
-		}
-
-		dev_dbg(rtd->dev, "%s: ioctl %s, enable = %d\n",
-			 __func__, "SNDRV_LSM_LAB_CONTROL", enable);
-		if (!prtd->lsm_client->started) {
-			if (prtd->lsm_client->lab_enable == enable) {
-				dev_dbg(rtd->dev,
-					"%s: Lab for session %d already %s\n",
-					__func__, prtd->lsm_client->session,
-					enable ? "enabled" : "disabled");
-				rc = 0;
-				break;
-			}
-			rc = q6lsm_lab_control(prtd->lsm_client, enable);
-			if (rc) {
-				dev_err(rtd->dev,
-					"%s: ioctl %s failed rc %d to %s lab for session %d\n",
-					__func__, "SNDRV_LAB_CONTROL", rc,
-					enable ? "enable" : "disable",
-					prtd->lsm_client->session);
-			} else {
-				rc = msm_lsm_lab_buffer_alloc(prtd,
-					enable ? LAB_BUFFER_ALLOC
-					: LAB_BUFFER_DEALLOC);
-				if (rc)
-					dev_err(rtd->dev,
-						"%s: msm_lsm_lab_buffer_alloc failed rc %d for %s",
-						__func__, rc,
-						enable ? "ALLOC" : "DEALLOC");
-				if (!rc)
-					prtd->lsm_client->lab_enable = enable;
-			}
-		} else {
-			dev_err(rtd->dev, "%s: ioctl %s issued after start",
-				__func__, "SNDRV_LSM_LAB_CONTROL");
-			rc = -EINVAL;
-		}
-		break;
-	}
-	case SNDRV_LSM_STOP_LAB:
-		dev_dbg(rtd->dev, "%s: stopping LAB\n", __func__);
-		if (prtd->lsm_client->lab_enable &&
-			prtd->lsm_client->lab_started) {
-			atomic_set(&prtd->read_abort, 1);
-			rc = q6lsm_stop_lab(prtd->lsm_client);
-			if (rc)
-				dev_err(rtd->dev,
-					"%s: Lab stop failed for session %d rc %d\n",
-					__func__,
-					prtd->lsm_client->session, rc);
-			prtd->lsm_client->lab_started = false;
-		}
-	break;
-
-	case SNDRV_LSM_SET_PORT:
-		dev_dbg(rtd->dev, "%s: set LSM port\n", __func__);
-		rc = q6lsm_set_port_connected(prtd->lsm_client);
-		break;
-
-	case SNDRV_LSM_SET_FWK_MODE_CONFIG: {
-		u32 mode;
-
-		if (copy_from_user(&mode, arg, sizeof(mode))) {
-			dev_err(rtd->dev, "%s: %s: copy_frm_user failed\n",
-				__func__, "LSM_SET_FWK_MODE_CONFIG");
-			return -EFAULT;
-		}
-
-		dev_dbg(rtd->dev, "%s: ioctl %s, enable = %d\n",
-			__func__, "SNDRV_LSM_SET_FWK_MODE_CONFIG", mode);
-		if (prtd->lsm_client->event_mode == mode) {
-			dev_dbg(rtd->dev,
-				"%s: mode for %d already set to %d\n",
-				__func__, prtd->lsm_client->session, mode);
-			rc = 0;
-		} else {
-			dev_dbg(rtd->dev, "%s: Event mode = %d\n",
-				 __func__, mode);
-			rc = q6lsm_set_fwk_mode_cfg(prtd->lsm_client, mode);
-			if (!rc)
-				prtd->lsm_client->event_mode = mode;
-			else
-				dev_err(rtd->dev,
-					"%s: set event mode failed %d\n",
-					__func__, rc);
-		}
-		break;
-	}
-
-	default:
-		dev_dbg(rtd->dev,
-			"%s: Falling into default snd_lib_ioctl cmd 0x%x\n",
-			 __func__, cmd);
-		rc = snd_pcm_lib_ioctl(substream, cmd, arg);
-		break;
-	}
-
-	if (!rc)
-		dev_dbg(rtd->dev, "%s: leave (%d)\n",
-			__func__, rc);
-	else
-		dev_err(rtd->dev, "%s: cmd 0x%x failed %d\n",
-			__func__, cmd, rc);
-
-	return rc;
-}
-#ifdef CONFIG_COMPAT
-
-struct snd_lsm_event_status32 {
-	u16 status;
-	u16 payload_size;
-	u8 payload[0];
-};
-
-struct snd_lsm_event_status_v3_32 {
-	u32 timestamp_lsw;
-	u32 timestamp_msw;
-	u16 status;
-	u16 payload_size;
-	u8 payload[0];
-};
-
-struct snd_lsm_sound_model_v2_32 {
-	compat_uptr_t data;
-	compat_uptr_t confidence_level;
-	u32 data_size;
-	enum lsm_detection_mode detection_mode;
-	u8 num_confidence_levels;
-	bool detect_failure;
-};
-
-struct snd_lsm_detection_params_32 {
-	compat_uptr_t conf_level;
-	enum lsm_detection_mode detect_mode;
-	u8 num_confidence_levels;
-	bool detect_failure;
-};
-
-struct lsm_params_info_32 {
-	u32 module_id;
-	u32 param_id;
-	u32 param_size;
-	compat_uptr_t param_data;
-	uint32_t param_type;
-};
-
-struct snd_lsm_module_params_32 {
-	compat_uptr_t params;
-	u32 num_params;
-	u32 data_size;
-};
-
-enum {
-	SNDRV_LSM_REG_SND_MODEL_V2_32 =
-		_IOW('U', 0x07, struct snd_lsm_sound_model_v2_32),
-	SNDRV_LSM_SET_PARAMS_32 =
-		_IOW('U', 0x0A, struct snd_lsm_detection_params_32),
-	SNDRV_LSM_SET_MODULE_PARAMS_32 =
-		_IOW('U', 0x0B, struct snd_lsm_module_params_32),
-	SNDRV_LSM_EVENT_STATUS_V3_32 =
-		_IOW('U', 0x0F, struct snd_lsm_event_status_v3_32),
-};
-
-static int msm_lsm_ioctl_compat(struct snd_pcm_substream *substream,
-			  unsigned int cmd, void __user *arg)
-{
-	struct snd_pcm_runtime *runtime;
-	struct lsm_priv *prtd;
-	struct snd_soc_pcm_runtime *rtd;
-	int err = 0;
-	u32 size = 0;
-
-	if (PCM_RUNTIME_CHECK(substream))
-		return -ENXIO;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!substream) ? "substream" : "private_data");
-		return -EINVAL;
-	}
-	runtime = substream->runtime;
-	rtd = substream->private_data;
-	prtd = runtime->private_data;
-
-	mutex_lock(&prtd->lsm_api_lock);
-
-	switch (cmd) {
-	case SNDRV_LSM_EVENT_STATUS: {
-		struct snd_lsm_event_status *user = NULL, userarg32;
-		struct snd_lsm_event_status *user32 = NULL;
-
-		if (copy_from_user(&userarg32, arg, sizeof(userarg32))) {
-			dev_err(rtd->dev, "%s: err copyuser ioctl %s\n",
-				__func__, "SNDRV_LSM_EVENT_STATUS");
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (userarg32.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			pr_err("%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, userarg32.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		size = sizeof(*user) + userarg32.payload_size;
-		user = kzalloc(size, GFP_KERNEL);
-		if (!user) {
-			dev_err(rtd->dev,
-				"%s: Allocation failed event status size %d\n",
-				__func__, size);
-			err = -EFAULT;
-			goto done;
-		} else {
-			cmd = SNDRV_LSM_EVENT_STATUS;
-			user->payload_size = userarg32.payload_size;
-			err = msm_lsm_ioctl_shared(substream, cmd, user);
-		}
-
-		/* Update size with actual payload size */
-		size = sizeof(userarg32) + user->payload_size;
-		if (!err && !access_ok(VERIFY_WRITE, arg, size)) {
-			dev_err(rtd->dev,
-				"%s: write verify failed size %d\n",
-				__func__, size);
-			err = -EFAULT;
-		}
-		if (!err) {
-			user32 = kzalloc(size, GFP_KERNEL);
-			if (!user32) {
-				dev_err(rtd->dev,
-					"%s: Allocation event user status size %d\n",
-					__func__, size);
-				err = -EFAULT;
-			} else {
-				user32->status = user->status;
-				user32->payload_size = user->payload_size;
-				memcpy(user32->payload,
-				user->payload, user32->payload_size);
-			}
-		}
-		if (!err && (copy_to_user(arg, user32, size))) {
-			dev_err(rtd->dev, "%s: failed to copy payload %d",
-				__func__, size);
-			err = -EFAULT;
-		}
-		kfree(user);
-		kfree(user32);
-		if (err)
-			dev_err(rtd->dev, "%s: lsmevent failed %d",
-				__func__, err);
-		break;
-	}
-
-	case SNDRV_LSM_EVENT_STATUS_V3_32: {
-		struct snd_lsm_event_status_v3_32 userarg32, *user32 = NULL;
-		struct snd_lsm_event_status_v3 *user = NULL;
-
-		if (copy_from_user(&userarg32, arg, sizeof(userarg32))) {
-			dev_err(rtd->dev, "%s: err copyuser ioctl %s\n",
-				__func__, "SNDRV_LSM_EVENT_STATUS_V3_32");
-			return -EFAULT;
-		}
-
-		if (userarg32.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			pr_err("%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, userarg32.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			return -EINVAL;
-		}
-
-		size = sizeof(*user) + userarg32.payload_size;
-		user = kzalloc(size, GFP_KERNEL);
-		if (!user) {
-			dev_err(rtd->dev,
-				"%s: Allocation failed event status size %d\n",
-				__func__, size);
-			return -EFAULT;
-		}
-		cmd = SNDRV_LSM_EVENT_STATUS_V3;
-		user->payload_size = userarg32.payload_size;
-		err = msm_lsm_ioctl_shared(substream, cmd, user);
-
-		/* Update size with actual payload size */
-		size = sizeof(userarg32) + user->payload_size;
-		if (!err && !access_ok(VERIFY_WRITE, arg, size)) {
-			dev_err(rtd->dev,
-				"%s: write verify failed size %d\n",
-				__func__, size);
-			err = -EFAULT;
-		}
-		if (!err) {
-			user32 = kzalloc(size, GFP_KERNEL);
-			if (!user32) {
-				dev_err(rtd->dev,
-					"%s: Allocation event user status size %d\n",
-					__func__, size);
-				err = -EFAULT;
-			} else {
-				user32->timestamp_lsw = user->timestamp_lsw;
-				user32->timestamp_msw = user->timestamp_msw;
-				user32->status = user->status;
-				user32->payload_size = user->payload_size;
-				memcpy(user32->payload,
-				user->payload, user32->payload_size);
-			}
-		}
-		if (!err && (copy_to_user(arg, user32, size))) {
-			dev_err(rtd->dev, "%s: failed to copy payload %d",
-				__func__, size);
-			err = -EFAULT;
-		}
-		kfree(user);
-		kfree(user32);
-		if (err)
-			dev_err(rtd->dev, "%s: lsmevent failed %d",
-				__func__, err);
-		break;
-	}
-
-	case SNDRV_LSM_REG_SND_MODEL_V2_32: {
-		struct snd_lsm_sound_model_v2_32 snd_modelv232;
-		struct snd_lsm_sound_model_v2 snd_modelv2;
-
-		if (prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "REG_SND_MODEL_V2");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&snd_modelv232, arg,
-			sizeof(snd_modelv232))) {
-			err = -EFAULT;
-			dev_err(rtd->dev,
-				"%s: copy user failed, size %zd %s\n",
-				__func__,
-				sizeof(struct snd_lsm_sound_model_v2_32),
-				"SNDRV_LSM_REG_SND_MODEL_V2_32");
-		} else {
-			snd_modelv2.confidence_level =
-			compat_ptr(snd_modelv232.confidence_level);
-			snd_modelv2.data = compat_ptr(snd_modelv232.data);
-			snd_modelv2.data_size = snd_modelv232.data_size;
-			snd_modelv2.detect_failure =
-			snd_modelv232.detect_failure;
-			snd_modelv2.detection_mode =
-			snd_modelv232.detection_mode;
-			snd_modelv2.num_confidence_levels =
-			snd_modelv232.num_confidence_levels;
-			cmd = SNDRV_LSM_REG_SND_MODEL_V2;
-			err = msm_lsm_ioctl_shared(substream, cmd,
-				&snd_modelv2);
-			if (err)
-				dev_err(rtd->dev,
-					"%s: ioctl %s failed\n", __func__,
-					"SNDDRV_LSM_REG_SND_MODEL_V2_32");
-		}
-		break;
-	}
-
-	case SNDRV_LSM_SET_PARAMS_32:{
-		struct snd_lsm_detection_params_32 det_params32;
-		struct snd_lsm_detection_params det_params;
-
-		if (prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "SET_PARAMS_32");
-			err = -EINVAL;
-		}
-
-		if (copy_from_user(&det_params32, arg,
-				   sizeof(det_params32))) {
-			err = -EFAULT;
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "SNDRV_LSM_SET_PARAMS_32",
-				sizeof(det_params32));
-		} else {
-			det_params.conf_level =
-				compat_ptr(det_params32.conf_level);
-			det_params.detect_mode =
-				det_params32.detect_mode;
-			det_params.num_confidence_levels =
-				det_params32.num_confidence_levels;
-			det_params.detect_failure =
-				det_params32.detect_failure;
-			cmd = SNDRV_LSM_SET_PARAMS;
-			err = msm_lsm_ioctl_shared(substream, cmd,
-					&det_params);
-			if (err)
-				dev_err(rtd->dev,
-					"%s: ioctl %s failed\n", __func__,
-					"SNDRV_LSM_SET_PARAMS");
-		}
-		break;
-	}
-
-	case SNDRV_LSM_SET_MODULE_PARAMS_32: {
-		struct snd_lsm_module_params_32 p_data_32;
-		struct snd_lsm_module_params p_data;
-		u8 *params, *params32;
-		size_t p_size;
-		struct lsm_params_info_32 *p_info_32;
-		struct lsm_params_info *p_info;
-		int i;
-
-		if (!prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if not using topology\n",
-				__func__, "SET_MODULE_PARAMS_32");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&p_data_32, arg,
-				   sizeof(p_data_32))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				sizeof(p_data_32));
-			err = -EFAULT;
-			goto done;
-		}
-
-		p_data.params = compat_ptr(p_data_32.params);
-		p_data.num_params = p_data_32.num_params;
-		p_data.data_size = p_data_32.data_size;
-
-		if (p_data.num_params > LSM_PARAMS_MAX) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid num_params %d\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				p_data.num_params);
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (p_data.data_size !=
-		    (p_data.num_params * sizeof(struct lsm_params_info_32))) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid size %d\n",
-				__func__, "SET_MODULE_PARAMS_32",
-				p_data.data_size);
-			err = -EINVAL;
-			goto done;
-		}
-
-		p_size = sizeof(struct lsm_params_info_32) *
-			 p_data.num_params;
-
-		params32 = kzalloc(p_size, GFP_KERNEL);
-		if (!params32) {
-			err = -ENOMEM;
-			goto done;
-		}
-
-		p_size = sizeof(struct lsm_params_info) * p_data.num_params;
-		params = kzalloc(p_size, GFP_KERNEL);
-		if (!params) {
-			dev_err(rtd->dev,
-				"%s: no memory for params, size = %zd\n",
-				__func__, p_size);
-			kfree(params32);
-			err = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(params32, p_data.params,
-				   p_data.data_size)) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %d\n",
-				__func__, "params32", p_data.data_size);
-			kfree(params32);
-			kfree(params);
-			err = -EFAULT;
-			goto done;
-		}
-
-		p_info_32 = (struct lsm_params_info_32 *) params32;
-		p_info = (struct lsm_params_info *) params;
-		for (i = 0; i < p_data.num_params; i++) {
-			p_info->module_id = p_info_32->module_id;
-			p_info->param_id = p_info_32->param_id;
-			p_info->param_size = p_info_32->param_size;
-			p_info->param_data = compat_ptr(p_info_32->param_data);
-			p_info->param_type = p_info_32->param_type;
-
-			p_info_32++;
-			p_info++;
-		}
-
-		err = msm_lsm_process_params(substream,
-					     &p_data, params);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: Failed to process params, err = %d\n",
-				__func__, err);
-		kfree(params);
-		kfree(params32);
-		break;
-	}
-	case SNDRV_LSM_REG_SND_MODEL_V2:
-	case SNDRV_LSM_SET_PARAMS:
-	case SNDRV_LSM_SET_MODULE_PARAMS:
-		/*
-		 * In ideal cases, the compat_ioctl should never be called
-		 * with the above unlocked ioctl commands. Print error
-		 * and return error if it does.
-		 */
-		dev_err(rtd->dev,
-			"%s: Invalid cmd for compat_ioctl\n",
-			__func__);
-		err = -EINVAL;
-		break;
-	default:
-		err = msm_lsm_ioctl_shared(substream, cmd, arg);
-		break;
-	}
-done:
-	mutex_unlock(&prtd->lsm_api_lock);
-	return err;
-}
-#else
-#define msm_lsm_ioctl_compat NULL
-#endif
-
-static int msm_lsm_ioctl(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	int err = 0;
-	u32 size = 0;
-	struct snd_pcm_runtime *runtime;
-	struct snd_soc_pcm_runtime *rtd;
-	struct lsm_priv *prtd;
-
-	if (!substream || !substream->private_data) {
-		pr_err("%s: Invalid %s\n", __func__,
-			(!substream) ? "substream" : "private_data");
-		return -EINVAL;
-	}
-	runtime = substream->runtime;
-	prtd = runtime->private_data;
-	rtd = substream->private_data;
-
-	mutex_lock(&prtd->lsm_api_lock);
-	switch (cmd) {
-	case SNDRV_LSM_REG_SND_MODEL_V2: {
-		struct snd_lsm_sound_model_v2 snd_model_v2;
-
-		if (prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "REG_SND_MODEL_V2");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&snd_model_v2, arg, sizeof(snd_model_v2))) {
-			err = -EFAULT;
-			dev_err(rtd->dev,
-				"%s: copy from user failed, size %zd\n",
-				__func__,
-				sizeof(struct snd_lsm_sound_model_v2));
-		}
-		if (!err)
-			err = msm_lsm_ioctl_shared(substream, cmd,
-						   &snd_model_v2);
-		if (err)
-			dev_err(rtd->dev,
-				"%s REG_SND_MODEL failed err %d\n",
-				__func__, err);
-		goto done;
-		}
-		break;
-	case SNDRV_LSM_SET_PARAMS: {
-		struct snd_lsm_detection_params det_params;
-
-		if (prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if using topology\n",
-				__func__, "SET_PARAMS");
-			err = -EINVAL;
-			goto done;
-		}
-
-		pr_debug("%s: SNDRV_LSM_SET_PARAMS\n", __func__);
-
-		if (copy_from_user(&det_params, arg,
-				   sizeof(det_params))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size %zd\n",
-				__func__, "SNDRV_LSM_SET_PARAMS",
-				sizeof(det_params));
-			err = -EFAULT;
-		}
-
-		if (!err)
-			err = msm_lsm_ioctl_shared(substream, cmd,
-						   &det_params);
-		else
-			dev_err(rtd->dev,
-				"%s: LSM_SET_PARAMS failed, err %d\n",
-				__func__, err);
-
-		goto done;
-	}
-
-	case SNDRV_LSM_SET_MODULE_PARAMS: {
-		struct snd_lsm_module_params p_data;
-		size_t p_size;
-		u8 *params;
-
-		if (!prtd->lsm_client->use_topology) {
-			dev_err(rtd->dev,
-				"%s: %s: not supported if not using topology\n",
-				__func__, "SET_MODULE_PARAMS");
-			err = -EINVAL;
-			goto done;
-		}
-
-		if (copy_from_user(&p_data, arg,
-				   sizeof(p_data))) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %zd\n",
-				__func__, "p_data", sizeof(p_data));
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (p_data.num_params > LSM_PARAMS_MAX) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid num_params %d\n",
-				__func__, "SET_MODULE_PARAMS",
-				p_data.num_params);
-			err = -EINVAL;
-			goto done;
-		}
-
-		p_size = p_data.num_params *
-			 sizeof(struct lsm_params_info);
-
-		if (p_data.data_size != p_size) {
-			dev_err(rtd->dev,
-				"%s: %s: Invalid size %zd\n",
-				__func__, "SET_MODULE_PARAMS", p_size);
-
-			err = -EFAULT;
-			goto done;
-		}
-
-		params = kzalloc(p_size, GFP_KERNEL);
-		if (!params) {
-			err = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(params, p_data.params,
-				   p_data.data_size)) {
-			dev_err(rtd->dev,
-				"%s: %s: copy_from_user failed, size = %d\n",
-				__func__, "params", p_data.data_size);
-			kfree(params);
-			err = -EFAULT;
-			goto done;
-		}
-
-		err = msm_lsm_process_params(substream, &p_data, params);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: %s: Failed to set params, err = %d\n",
-				__func__, "SET_MODULE_PARAMS", err);
-		kfree(params);
-		break;
-	}
-
-	case SNDRV_LSM_EVENT_STATUS: {
-		struct snd_lsm_event_status *user = NULL, userarg;
-
-		dev_dbg(rtd->dev,
-			"%s: SNDRV_LSM_EVENT_STATUS\n", __func__);
-		if (copy_from_user(&userarg, arg, sizeof(userarg))) {
-			dev_err(rtd->dev,
-				"%s: err copyuser event_status\n",
-				__func__);
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (userarg.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			pr_err("%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, userarg.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		size = sizeof(struct snd_lsm_event_status) +
-		userarg.payload_size;
-		user = kzalloc(size, GFP_KERNEL);
-		if (!user) {
-			dev_err(rtd->dev,
-				"%s: Allocation failed event status size %d\n",
-				__func__, size);
-			err = -EFAULT;
-			goto done;
-		}
-		user->payload_size = userarg.payload_size;
-		err = msm_lsm_ioctl_shared(substream, cmd, user);
-
-		/* Update size with actual payload size */
-		size = sizeof(*user) + user->payload_size;
-		if (!err && !access_ok(VERIFY_WRITE, arg, size)) {
-			dev_err(rtd->dev,
-				"%s: write verify failed size %d\n",
-				__func__, size);
-			err = -EFAULT;
-		}
-		if (!err && (copy_to_user(arg, user, size))) {
-			dev_err(rtd->dev,
-				"%s: failed to copy payload %d",
-				__func__, size);
-			err = -EFAULT;
-		}
-		kfree(user);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: lsmevent failed %d", __func__, err);
-		goto done;
-	}
-
-	case SNDRV_LSM_EVENT_STATUS_V3: {
-		struct snd_lsm_event_status_v3 *user = NULL;
-		struct snd_lsm_event_status_v3 userarg;
-
-		dev_dbg(rtd->dev,
-			"%s: SNDRV_LSM_EVENT_STATUS_V3\n", __func__);
-		if (!arg) {
-			dev_err(rtd->dev,
-				"%s: Invalid params event_status_v3\n",
-				__func__);
-			err = -EINVAL;
-			goto done;
-		}
-		if (copy_from_user(&userarg, arg, sizeof(userarg))) {
-			dev_err(rtd->dev,
-				"%s: err copyuser event_status_v3\n",
-				__func__);
-			err = -EFAULT;
-			goto done;
-		}
-
-		if (userarg.payload_size >
-		    LISTEN_MAX_STATUS_PAYLOAD_SIZE) {
-			pr_err("%s: payload_size %d is invalid, max allowed = %d\n",
-				__func__, userarg.payload_size,
-				LISTEN_MAX_STATUS_PAYLOAD_SIZE);
-			err = -EINVAL;
-			goto done;
-		}
-
-		size = sizeof(struct snd_lsm_event_status_v3) +
-			userarg.payload_size;
-		user = kzalloc(size, GFP_KERNEL);
-		if (!user) {
-			dev_err(rtd->dev,
-				"%s: Allocation failed event status size %d\n",
-				__func__, size);
-			err = -EFAULT;
-			goto done;
-		}
-		user->payload_size = userarg.payload_size;
-		err = msm_lsm_ioctl_shared(substream, cmd, user);
-
-		/* Update size with actual payload size */
-		size = sizeof(*user) + user->payload_size;
-		if (!err && !access_ok(VERIFY_WRITE, arg, size)) {
-			dev_err(rtd->dev,
-				"%s: write verify failed size %d\n",
-				__func__, size);
-			err = -EFAULT;
-		}
-		if (!err && (copy_to_user(arg, user, size))) {
-			dev_err(rtd->dev,
-				"%s: failed to copy payload %d",
-				__func__, size);
-			err = -EFAULT;
-		}
-		kfree(user);
-		if (err)
-			dev_err(rtd->dev,
-				"%s: lsm_event_v3 failed %d", __func__, err);
-		break;
-	}
-
-	default:
-		err = msm_lsm_ioctl_shared(substream, cmd, arg);
-	break;
-	}
-done:
-	mutex_unlock(&prtd->lsm_api_lock);
-	return err;
-}
-
-static int msm_lsm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd;
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	prtd = kzalloc(sizeof(struct lsm_priv), GFP_KERNEL);
-	if (!prtd) {
-		pr_err("%s: Failed to allocate memory for lsm_priv\n",
-		       __func__);
-		return -ENOMEM;
-	}
-	mutex_init(&prtd->lsm_api_lock);
-	spin_lock_init(&prtd->event_lock);
-	init_waitqueue_head(&prtd->event_wait);
-	init_waitqueue_head(&prtd->period_wait);
-	prtd->substream = substream;
-	runtime->private_data = prtd;
-	runtime->hw = msm_pcm_hardware_capture;
-
-	ret = snd_pcm_hw_constraint_list(runtime, 0,
-				SNDRV_PCM_HW_PARAM_RATE,
-				&constraints_sample_rates);
-	if (ret < 0)
-		pr_info("%s: snd_pcm_hw_constraint_list failed ret %d\n",
-			 __func__, ret);
-	/* Ensure that buffer size is a multiple of period size */
-	ret = snd_pcm_hw_constraint_integer(runtime,
-			    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
-		pr_info("%s: snd_pcm_hw_constraint_integer failed ret %d\n",
-			__func__, ret);
-
-	ret = snd_pcm_hw_constraint_minmax(runtime,
-		SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-		CAPTURE_MIN_NUM_PERIODS * CAPTURE_MIN_PERIOD_SIZE,
-		CAPTURE_MAX_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE);
-	if (ret < 0)
-		pr_info("%s: constraint for buffer bytes min max ret = %d\n",
-			__func__, ret);
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
-	if (ret < 0) {
-		pr_info("%s: constraint for period bytes step ret = %d\n",
-			__func__, ret);
-	}
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
-	if (ret < 0)
-		pr_info("%s: constraint for buffer bytes step ret = %d\n",
-			__func__, ret);
-	prtd->lsm_client = q6lsm_client_alloc(
-				(lsm_app_cb)lsm_event_handler, prtd);
-	if (!prtd->lsm_client) {
-		pr_err("%s: Could not allocate memory\n", __func__);
-		kfree(prtd);
-		runtime->private_data = NULL;
-		return -ENOMEM;
-	}
-	prtd->lsm_client->opened = false;
-	prtd->lsm_client->session_state = IDLE;
-	prtd->lsm_client->poll_enable = true;
-	prtd->lsm_client->perf_mode = 0;
-	prtd->lsm_client->event_mode = LSM_EVENT_NON_TIME_STAMP_MODE;
-
-	return 0;
-}
-
-static int msm_lsm_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-
-	if (!substream->private_data) {
-		pr_err("%s: Invalid private_data", __func__);
-		return -EINVAL;
-	}
-
-	rtd = prtd->substream->private_data;
-
-	if (!prtd->lsm_client) {
-		dev_err(rtd->dev,
-			"%s: LSM client data ptr is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (q6lsm_set_media_fmt_params(prtd->lsm_client))
-		dev_dbg(rtd->dev,
-			"%s: failed to set lsm media fmt params\n", __func__);
-
-	if (prtd->lsm_client->session_state == IDLE) {
-		ret = msm_pcm_routing_reg_phy_compr_stream(
-				rtd->dai_link->id,
-				prtd->lsm_client->perf_mode,
-				prtd->lsm_client->session,
-				SNDRV_PCM_STREAM_CAPTURE,
-				LISTEN);
-		if (ret) {
-			dev_err(rtd->dev,
-				"%s: register phy compr stream failed %d\n",
-					__func__, ret);
-			return ret;
-		}
-	}
-
-	prtd->lsm_client->session_state = RUNNING;
-	prtd->lsm_client->started = false;
-	runtime->private_data = prtd;
-	return ret;
-}
-
-static int msm_lsm_close(struct snd_pcm_substream *substream)
-{
-	unsigned long flags;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-
-	if (!substream->private_data) {
-		pr_err("%s: Invalid private_data", __func__);
-		return -EINVAL;
-	}
-	if (!prtd || !prtd->lsm_client) {
-		pr_err("%s: No LSM session active\n", __func__);
-		return -EINVAL;
-	}
-	rtd = substream->private_data;
-
-	dev_dbg(rtd->dev, "%s\n", __func__);
-	if (prtd->lsm_client->started) {
-		ret = q6lsm_stop(prtd->lsm_client, true);
-		if (ret)
-			dev_err(rtd->dev,
-				"%s: session stop failed, err = %d\n",
-				__func__, ret);
-		else
-			dev_dbg(rtd->dev,
-				"%s: LSM client session stopped %d\n",
-				 __func__, ret);
-
-		/*
-		 * Go Ahead and try de-register sound model,
-		 * even if stop failed
-		 */
-		prtd->lsm_client->started = false;
-
-		ret = q6lsm_deregister_sound_model(prtd->lsm_client);
-		if (ret)
-			dev_err(rtd->dev,
-				"%s: dereg_snd_model failed, err = %d\n",
-				__func__, ret);
-		else
-			dev_dbg(rtd->dev, "%s: dereg_snd_model successful\n",
-				 __func__);
-	}
-
-	msm_pcm_routing_dereg_phy_stream(rtd->dai_link->id,
-					SNDRV_PCM_STREAM_CAPTURE);
-
-	if (prtd->lsm_client->opened) {
-		q6lsm_close(prtd->lsm_client);
-		prtd->lsm_client->opened = false;
-	}
-	q6lsm_client_free(prtd->lsm_client);
-
-	spin_lock_irqsave(&prtd->event_lock, flags);
-	kfree(prtd->event_status);
-	prtd->event_status = NULL;
-	spin_unlock_irqrestore(&prtd->event_lock, flags);
-	mutex_destroy(&prtd->lsm_api_lock);
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_lsm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct lsm_hw_params *hw_params = NULL;
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!substream->private_data) {
-		pr_err("%s: Invalid private_data", __func__);
-		return -EINVAL;
-	}
-	rtd = substream->private_data;
-
-	if (!prtd || !params) {
-		dev_err(rtd->dev,
-			"%s: invalid params prtd %pK params %pK",
-			 __func__, prtd, params);
-		return -EINVAL;
-	}
-	hw_params = &prtd->lsm_client->hw_params;
-	hw_params->num_chs = params_channels(params);
-	hw_params->period_count = params_periods(params);
-	hw_params->sample_rate = params_rate(params);
-	if (((hw_params->sample_rate != 16000) &&
-		(hw_params->sample_rate != 48000)) ||
-		(hw_params->period_count == 0)) {
-		dev_err(rtd->dev,
-			"%s: Invalid Params sample rate %d period count %d\n",
-			__func__, hw_params->sample_rate,
-			hw_params->period_count);
-		return -EINVAL;
-	}
-
-	if (params_format(params) == SNDRV_PCM_FORMAT_S16_LE) {
-		hw_params->sample_size = 16;
-	} else if (params_format(params) == SNDRV_PCM_FORMAT_S24_LE) {
-		hw_params->sample_size = 24;
-	} else {
-		dev_err(rtd->dev, "%s: Invalid Format 0x%x\n",
-			__func__, params_format(params));
-		return -EINVAL;
-	}
-
-	hw_params->buf_sz = params_buffer_bytes(params) /
-			hw_params->period_count;
-	dev_dbg(rtd->dev,
-		"%s: channels %d sample rate %d sample size %d buffer size %d period count %d\n",
-		__func__, hw_params->num_chs, hw_params->sample_rate,
-		hw_params->sample_size, hw_params->buf_sz,
-		hw_params->period_count);
-	return 0;
-}
-
-static snd_pcm_uframes_t msm_lsm_pcm_pointer(
-	struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!substream->private_data) {
-		pr_err("%s: Invalid private_data", __func__);
-		return -EINVAL;
-	}
-	rtd = substream->private_data;
-
-	if (!prtd) {
-		dev_err(rtd->dev,
-			"%s: Invalid param %pK\n", __func__, prtd);
-		return 0;
-	}
-
-	if (prtd->dma_write >= snd_pcm_lib_buffer_bytes(substream))
-		prtd->dma_write = 0;
-	dev_dbg(rtd->dev,
-		"%s: dma post = %d\n", __func__, prtd->dma_write);
-	return bytes_to_frames(runtime, prtd->dma_write);
-}
-
-static int msm_lsm_pcm_copy(struct snd_pcm_substream *substream, int ch,
-	snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct lsm_priv *prtd = runtime->private_data;
-	char *pcm_buf = NULL;
-	int fbytes = 0, rc = 0;
-	struct snd_soc_pcm_runtime *rtd;
-
-	if (!substream->private_data) {
-		pr_err("%s: Invalid private_data", __func__);
-		return -EINVAL;
-	}
-	rtd = substream->private_data;
-
-	if (!prtd) {
-		dev_err(rtd->dev,
-			"%s: Invalid param %pK\n", __func__, prtd);
-		return -EINVAL;
-	}
-
-	fbytes = frames_to_bytes(runtime, frames);
-	if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
-	    runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-		dev_err(rtd->dev,
-			"%s: runtime state incorrect %d", __func__,
-			runtime->status->state);
-		return 0;
-	}
-	rc = wait_event_timeout(prtd->period_wait,
-		(atomic_read(&prtd->buf_count) |
-		atomic_read(&prtd->read_abort)), (2 * HZ));
-	if (!rc) {
-		dev_err(rtd->dev,
-			"%s: timeout for read retry\n", __func__);
-		return -EAGAIN;
-	}
-	if (atomic_read(&prtd->read_abort)) {
-		dev_err(rtd->dev,
-			"%s: Read abort received\n", __func__);
-		return -EIO;
-	}
-	prtd->appl_cnt = prtd->appl_cnt %
-		prtd->lsm_client->hw_params.period_count;
-	pcm_buf = prtd->lsm_client->lab_buffer[prtd->appl_cnt].data;
-	dev_dbg(rtd->dev,
-		"%s: copy the pcm data size %d\n",
-		__func__, fbytes);
-	if (pcm_buf) {
-		if (copy_to_user(buf, pcm_buf, fbytes)) {
-			dev_err(rtd->dev,
-				"%s: failed to copy bytes %d\n",
-				__func__, fbytes);
-			return -EINVAL;
-		}
-	} else {
-		dev_err(rtd->dev,
-			"%s: Invalid pcm buffer\n", __func__);
-		return -EINVAL;
-	}
-	prtd->appl_cnt = (prtd->appl_cnt + 1) %
-		prtd->lsm_client->hw_params.period_count;
-	atomic_dec(&prtd->buf_count);
-	return 0;
-}
-
-static int msm_lsm_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	cfg_data.sample_rate = ucontrol->value.integer.value[2];
-
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return 0;
-}
-
-static int msm_lsm_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_lsm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_usr *app_type_info;
-	struct snd_kcontrol *kctl;
-	const char *mixer_ctl_name	= "Listen Stream";
-	const char *deviceNo		= "NN";
-	const char *suffix		= "App Type Cfg";
-	int ctl_len, ret = 0;
-
-	ctl_len = strlen(mixer_ctl_name) + 1 +
-			strlen(deviceNo) + 1 + strlen(suffix) + 1;
-	pr_debug("%s: Listen app type cntrl add\n", __func__);
-	ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
-				NULL, 1, ctl_len, rtd->dai_link->id,
-				&app_type_info);
-	if (ret < 0) {
-		pr_err("%s: Listen app type cntrl add failed: %d\n",
-			__func__, ret);
-		return ret;
-	}
-	kctl = app_type_info->kctl;
-	snprintf(kctl->id.name, ctl_len, "%s %d %s",
-		mixer_ctl_name, rtd->pcm->device, suffix);
-	kctl->put = msm_lsm_app_type_cfg_ctl_put;
-	kctl->get = msm_lsm_app_type_cfg_ctl_get;
-	return 0;
-}
-
-static int msm_lsm_add_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-
-	ret = msm_lsm_add_app_type_controls(rtd);
-	if (ret)
-		pr_err("%s, add  app type controls failed:%d\n", __func__, ret);
-
-	return ret;
-}
-
-static const struct snd_pcm_ops msm_lsm_ops = {
-	.open           = msm_lsm_open,
-	.close          = msm_lsm_close,
-	.ioctl          = msm_lsm_ioctl,
-	.prepare	= msm_lsm_prepare,
-	.compat_ioctl   = msm_lsm_ioctl_compat,
-	.hw_params      = msm_lsm_hw_params,
-	.copy           = msm_lsm_pcm_copy,
-	.pointer        = msm_lsm_pcm_pointer,
-};
-
-static int msm_asoc_lsm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	ret = msm_lsm_add_controls(rtd);
-	if (ret)
-		pr_err("%s, kctl add failed:%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int msm_asoc_lsm_probe(struct snd_soc_platform *platform)
-{
-	pr_debug("enter %s\n", __func__);
-
-	return 0;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_lsm_ops,
-	.pcm_new	= msm_asoc_lsm_new,
-	.probe		= msm_asoc_lsm_probe,
-};
-
-static int msm_lsm_probe(struct platform_device *pdev)
-{
-
-	return snd_soc_register_platform(&pdev->dev, &msm_soc_platform);
-}
-
-static int msm_lsm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-
-	return 0;
-}
-
-static const struct of_device_id msm_lsm_client_dt_match[] = {
-	{.compatible = "qcom,msm-lsm-client" },
-	{ }
-};
-
-static struct platform_driver msm_lsm_driver = {
-	.driver = {
-		.name = "msm-lsm-client",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(msm_lsm_client_dt_match),
-	},
-	.probe = msm_lsm_probe,
-	.remove = msm_lsm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_lsm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_lsm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("LSM client platform driver");
-MODULE_DEVICE_TABLE(of, msm_lsm_client_dt_match);
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c
deleted file mode 100644
index ab9b310..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c
+++ /dev/null
@@ -1,922 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_ion.h>
-
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6adm-v2.h>
-#include <asm/dma.h>
-#include "msm-pcm-afe-v2.h"
-
-#define MIN_PLAYBACK_PERIOD_SIZE (128 * 2)
-#define MAX_PLAYBACK_PERIOD_SIZE (128 * 2 * 2 * 6)
-#define MIN_PLAYBACK_NUM_PERIODS (4)
-#define MAX_PLAYBACK_NUM_PERIODS (384)
-
-#define MIN_CAPTURE_PERIOD_SIZE (128 * 2)
-#define MAX_CAPTURE_PERIOD_SIZE (192 * 2 * 2 * 8 * 4)
-#define MIN_CAPTURE_NUM_PERIODS (4)
-#define MAX_CAPTURE_NUM_PERIODS (384)
-
-static struct snd_pcm_hardware msm_afe_hardware_playback = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE|
-				SNDRV_PCM_FMTBIT_S24_LE,
-	.rates =                (SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_48000),
-	.rate_min =             8000,
-	.rate_max =             48000,
-	.channels_min =         1,
-	.channels_max =         6,
-	.buffer_bytes_max =     MAX_PLAYBACK_PERIOD_SIZE *
-				MAX_PLAYBACK_NUM_PERIODS,
-	.period_bytes_min =     MIN_PLAYBACK_PERIOD_SIZE,
-	.period_bytes_max =     MAX_PLAYBACK_PERIOD_SIZE,
-	.periods_min =          MIN_PLAYBACK_NUM_PERIODS,
-	.periods_max =          MAX_PLAYBACK_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-static struct snd_pcm_hardware msm_afe_hardware_capture = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE|
-				SNDRV_PCM_FMTBIT_S24_LE,
-	.rates =                (SNDRV_PCM_RATE_8000 |
-				SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_48000),
-	.rate_min =             8000,
-	.rate_max =             48000,
-	.channels_min =         1,
-	.channels_max =         6,
-	.buffer_bytes_max =     MAX_CAPTURE_PERIOD_SIZE *
-				MAX_CAPTURE_NUM_PERIODS,
-	.period_bytes_min =     MIN_CAPTURE_PERIOD_SIZE,
-	.period_bytes_max =     MAX_CAPTURE_PERIOD_SIZE,
-	.periods_min =          MIN_CAPTURE_NUM_PERIODS,
-	.periods_max =          MAX_CAPTURE_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-
-static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt);
-static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt);
-
-static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt)
-{
-	struct pcm_afe_info *prtd =
-		container_of(hrt, struct pcm_afe_info, hrt);
-	struct snd_pcm_substream *substream = prtd->substream;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	u32 mem_map_handle = 0;
-
-	mem_map_handle = afe_req_mmap_handle(prtd->audio_client);
-	if (!mem_map_handle)
-		pr_err("%s: mem_map_handle is NULL\n", __func__);
-
-	if (prtd->start) {
-		pr_debug("sending frame to DSP: poll_time: %d\n",
-				prtd->poll_time);
-		if (prtd->dsp_cnt == runtime->periods)
-			prtd->dsp_cnt = 0;
-		pr_debug("%s: mem_map_handle 0x%x\n", __func__, mem_map_handle);
-		afe_rt_proxy_port_write(
-		(prtd->dma_addr +
-		(prtd->dsp_cnt *
-		snd_pcm_lib_period_bytes(prtd->substream))), mem_map_handle,
-		snd_pcm_lib_period_bytes(prtd->substream));
-		prtd->dsp_cnt++;
-		hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
-					* 1000));
-
-		return HRTIMER_RESTART;
-	} else
-		return HRTIMER_NORESTART;
-}
-static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt)
-{
-	struct pcm_afe_info *prtd =
-		container_of(hrt, struct pcm_afe_info, hrt);
-	struct snd_pcm_substream *substream = prtd->substream;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	u32 mem_map_handle = 0;
-	int ret;
-
-	mem_map_handle = afe_req_mmap_handle(prtd->audio_client);
-	if (!mem_map_handle)
-		pr_err("%s: mem_map_handle is NULL\n", __func__);
-
-	if (prtd->start) {
-		if (prtd->dsp_cnt == runtime->periods)
-			prtd->dsp_cnt = 0;
-		pr_debug("%s: mem_map_handle 0x%x\n", __func__, mem_map_handle);
-		ret = afe_rt_proxy_port_read(
-		(prtd->dma_addr + (prtd->dsp_cnt
-		* snd_pcm_lib_period_bytes(prtd->substream))), mem_map_handle,
-		snd_pcm_lib_period_bytes(prtd->substream));
-		if (ret < 0) {
-			pr_err("%s: AFE port read fails: %d\n", __func__, ret);
-			prtd->start = 0;
-			return HRTIMER_NORESTART;
-		}
-		prtd->dsp_cnt++;
-		pr_debug("sending frame rec to DSP: poll_time: %d\n",
-				prtd->poll_time);
-		hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
-				* 1000));
-
-		return HRTIMER_RESTART;
-	} else
-		return HRTIMER_NORESTART;
-}
-static void pcm_afe_process_tx_pkt(uint32_t opcode,
-		uint32_t token, uint32_t *payload,
-		 void *priv)
-{
-	struct pcm_afe_info *prtd = priv;
-	unsigned long dsp_flags;
-	struct snd_pcm_substream *substream = NULL;
-	struct snd_pcm_runtime *runtime = NULL;
-	uint16_t event;
-	uint64_t period_bytes;
-	uint64_t bytes_one_sec;
-
-	if (prtd == NULL)
-		return;
-	substream =  prtd->substream;
-	runtime = substream->runtime;
-	pr_debug("%s\n", __func__);
-	spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-	switch (opcode) {
-	case AFE_EVENT_RT_PROXY_PORT_STATUS: {
-		event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10);
-			switch (event) {
-			case AFE_EVENT_RTPORT_START: {
-				prtd->dsp_cnt = 0;
-				/* Calculate poll time.
-				 * Split steps to avoid overflow.
-				 * Poll time-time corresponding to one period
-				 * in bytes.
-				 * (Samplerate * channelcount * format) =
-				 * bytes in 1 sec.
-				 * Poll time =
-				 *	(period bytes / bytes in one sec) *
-				 *	 1000000 micro seconds.
-				 * Multiplication by 1000000 is done in two
-				 * steps to keep the accuracy of poll time.
-				 */
-				if (prtd->mmap_flag) {
-					period_bytes = ((uint64_t)(
-						(snd_pcm_lib_period_bytes(
-							prtd->substream)) *
-							1000));
-					bytes_one_sec = (runtime->rate
-						* runtime->channels * 2);
-					bytes_one_sec =
-						div_u64(bytes_one_sec, 1000);
-					prtd->poll_time =
-						div_u64(period_bytes,
-						bytes_one_sec);
-					pr_debug("prtd->poll_time: %d",
-							prtd->poll_time);
-				}
-				break;
-			}
-			case AFE_EVENT_RTPORT_STOP:
-				pr_debug("%s: event!=0\n", __func__);
-				prtd->start = 0;
-				snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-				break;
-			case AFE_EVENT_RTPORT_LOW_WM:
-				pr_debug("%s: Underrun\n", __func__);
-				break;
-			case AFE_EVENT_RTPORT_HI_WM:
-				pr_debug("%s: Overrun\n", __func__);
-				break;
-			default:
-				break;
-			}
-			break;
-	}
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-		case AFE_PORT_DATA_CMD_RT_PROXY_PORT_WRITE_V2:
-			pr_debug("write done\n");
-			prtd->pcm_irq_pos += snd_pcm_lib_period_bytes
-							(prtd->substream);
-			snd_pcm_period_elapsed(prtd->substream);
-			break;
-		default:
-			break;
-		}
-		break;
-	}
-	case RESET_EVENTS:
-		prtd->pcm_irq_pos += snd_pcm_lib_period_bytes
-						(prtd->substream);
-		prtd->reset_event = true;
-		snd_pcm_period_elapsed(prtd->substream);
-		break;
-	default:
-		break;
-	}
-	spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-}
-
-static void pcm_afe_process_rx_pkt(uint32_t opcode,
-		uint32_t token, uint32_t *payload,
-		 void *priv)
-{
-	struct pcm_afe_info *prtd = priv;
-	unsigned long dsp_flags;
-	struct snd_pcm_substream *substream = NULL;
-	struct snd_pcm_runtime *runtime = NULL;
-	uint16_t event;
-	uint64_t period_bytes;
-	uint64_t bytes_one_sec;
-	uint32_t mem_map_handle = 0;
-
-	if (prtd == NULL)
-		return;
-	substream =  prtd->substream;
-	runtime = substream->runtime;
-	pr_debug("%s\n", __func__);
-	spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-	switch (opcode) {
-	case AFE_EVENT_RT_PROXY_PORT_STATUS: {
-		event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10);
-		switch (event) {
-		case AFE_EVENT_RTPORT_START: {
-			prtd->dsp_cnt = 0;
-			/* Calculate poll time. Split steps to avoid overflow.
-			 * Poll time-time corresponding to one period in bytes.
-			 * (Samplerate * channelcount * format)=bytes in 1 sec.
-			 * Poll time =  (period bytes / bytes in one sec) *
-			 * 1000000 micro seconds.
-			 * Multiplication by 1000000 is done in two steps to
-			 * keep the accuracy of poll time.
-			 */
-			if (prtd->mmap_flag) {
-				period_bytes = ((uint64_t)(
-					(snd_pcm_lib_period_bytes(
-					prtd->substream)) * 1000));
-				bytes_one_sec = (runtime->rate *
-						runtime->channels * 2);
-				bytes_one_sec = div_u64(bytes_one_sec, 1000);
-				prtd->poll_time =
-					div_u64(period_bytes, bytes_one_sec);
-				pr_debug("prtd->poll_time : %d\n",
-					prtd->poll_time);
-			} else {
-				mem_map_handle =
-					afe_req_mmap_handle(prtd->audio_client);
-				if (!mem_map_handle)
-					pr_err("%s:mem_map_handle is NULL\n",
-							 __func__);
-				/* Do initial read to start transfer */
-				afe_rt_proxy_port_read((prtd->dma_addr +
-					(prtd->dsp_cnt *
-					snd_pcm_lib_period_bytes(
-						prtd->substream))),
-					mem_map_handle,
-					snd_pcm_lib_period_bytes(
-						prtd->substream));
-				prtd->dsp_cnt++;
-			}
-			break;
-		}
-		case AFE_EVENT_RTPORT_STOP:
-			pr_debug("%s: event!=0\n", __func__);
-			prtd->start = 0;
-			snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-			break;
-		case AFE_EVENT_RTPORT_LOW_WM:
-			pr_debug("%s: Underrun\n", __func__);
-			break;
-		case AFE_EVENT_RTPORT_HI_WM:
-			pr_debug("%s: Overrun\n", __func__);
-			break;
-		default:
-			break;
-		}
-		break;
-	}
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-		case AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2:
-			pr_debug("%s :Read done\n", __func__);
-			prtd->pcm_irq_pos += snd_pcm_lib_period_bytes
-							(prtd->substream);
-			if (!prtd->mmap_flag) {
-				atomic_set(&prtd->rec_bytes_avail, 1);
-				wake_up(&prtd->read_wait);
-			}
-			snd_pcm_period_elapsed(prtd->substream);
-			break;
-		default:
-			break;
-		}
-		break;
-	}
-	case RESET_EVENTS:
-		prtd->pcm_irq_pos += snd_pcm_lib_period_bytes
-							(prtd->substream);
-		prtd->reset_event = true;
-		if (!prtd->mmap_flag) {
-			atomic_set(&prtd->rec_bytes_avail, 1);
-			wake_up(&prtd->read_wait);
-		}
-		snd_pcm_period_elapsed(prtd->substream);
-		break;
-	default:
-		break;
-	}
-	spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-}
-
-static int msm_afe_playback_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *dai = rtd->cpu_dai;
-	int ret = 0;
-
-	pr_debug("%s: sample_rate=%d\n", __func__, runtime->rate);
-
-	pr_debug("%s: dai->id =%x\n", __func__, dai->id);
-	ret = afe_register_get_events(dai->id,
-			pcm_afe_process_tx_pkt, prtd);
-	if (ret < 0) {
-		pr_err("afe-pcm:register for events failed\n");
-		return ret;
-	}
-	pr_debug("%s:success\n", __func__);
-	prtd->prepared++;
-	return ret;
-}
-
-static int msm_afe_capture_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *dai = rtd->cpu_dai;
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	pr_debug("%s: dai->id =%x\n", __func__, dai->id);
-	ret = afe_register_get_events(dai->id,
-			pcm_afe_process_rx_pkt, prtd);
-	if (ret < 0) {
-		pr_err("afe-pcm:register for events failed\n");
-		return ret;
-	}
-	pr_debug("%s:success\n", __func__);
-	prtd->prepared++;
-	return 0;
-}
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	8000, 16000, 48000
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static int msm_afe_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = NULL;
-	int ret = 0;
-
-	prtd = kzalloc(sizeof(struct pcm_afe_info), GFP_KERNEL);
-	if (prtd == NULL)
-		return -ENOMEM;
-	pr_debug("prtd %pK\n", prtd);
-
-	mutex_init(&prtd->lock);
-	spin_lock_init(&prtd->dsp_lock);
-	prtd->dsp_cnt = 0;
-
-	mutex_lock(&prtd->lock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		runtime->hw = msm_afe_hardware_playback;
-	else
-		runtime->hw = msm_afe_hardware_capture;
-
-	prtd->substream = substream;
-	runtime->private_data = prtd;
-	prtd->audio_client = q6afe_audio_client_alloc(prtd);
-	if (!prtd->audio_client) {
-		pr_debug("%s: Could not allocate memory\n", __func__);
-		mutex_unlock(&prtd->lock);
-		kfree(prtd);
-		return -ENOMEM;
-	}
-
-	atomic_set(&prtd->rec_bytes_avail, 0);
-	init_waitqueue_head(&prtd->read_wait);
-
-	hrtimer_init(&prtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		prtd->hrt.function = afe_hrtimer_callback;
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		prtd->hrt.function = afe_hrtimer_rec_callback;
-
-	mutex_unlock(&prtd->lock);
-	ret = snd_pcm_hw_constraint_list(runtime, 0,
-				SNDRV_PCM_HW_PARAM_RATE,
-				&constraints_sample_rates);
-	if (ret < 0)
-		pr_err("snd_pcm_hw_constraint_list failed\n");
-	/* Ensure that buffer size is a multiple of period size */
-	ret = snd_pcm_hw_constraint_integer(runtime,
-					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
-		pr_err("snd_pcm_hw_constraint_integer failed\n");
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		ret = snd_pcm_hw_constraint_minmax(runtime,
-			SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-			MIN_CAPTURE_NUM_PERIODS * MIN_CAPTURE_PERIOD_SIZE,
-			MAX_CAPTURE_NUM_PERIODS * MAX_CAPTURE_PERIOD_SIZE);
-
-		if (ret < 0) {
-			pr_err("constraint for buffer bytes min max ret = %d\n",
-			      ret);
-		}
-	}
-
-	prtd->reset_event = false;
-	return 0;
-}
-
-static int msm_afe_playback_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
-	u32 mem_map_handle = 0;
-
-	pr_debug("%s : appl_ptr 0x%lx hw_ptr 0x%lx dest_to_copy 0x%pK\n",
-		__func__,
-		runtime->control->appl_ptr, runtime->status->hw_ptr, hwbuf);
-
-	if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) {
-		pr_err("%s :Failed to copy audio from user buffer\n",
-			__func__);
-
-		ret = -EFAULT;
-		goto fail;
-	}
-
-	if (!prtd->mmap_flag) {
-		mem_map_handle = afe_req_mmap_handle(prtd->audio_client);
-		if (!mem_map_handle) {
-			pr_err("%s: mem_map_handle is NULL\n", __func__);
-			ret = -EFAULT;
-			goto fail;
-		}
-
-		pr_debug("%s : prtd-> dma_addr 0x%lx dsp_cnt %d\n", __func__,
-			prtd->dma_addr, prtd->dsp_cnt);
-
-		if (prtd->dsp_cnt == runtime->periods)
-			prtd->dsp_cnt = 0;
-
-		ret = afe_rt_proxy_port_write(
-				(prtd->dma_addr + (prtd->dsp_cnt *
-				snd_pcm_lib_period_bytes(prtd->substream))),
-				mem_map_handle,
-				snd_pcm_lib_period_bytes(prtd->substream));
-
-		if (ret) {
-			pr_err("%s: AFE proxy port write failed %d\n",
-				__func__, ret);
-			goto fail;
-		}
-		prtd->dsp_cnt++;
-	}
-fail:
-	return ret;
-}
-
-static int msm_afe_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
-	u32 mem_map_handle = 0;
-
-	if (!prtd->mmap_flag) {
-		mem_map_handle = afe_req_mmap_handle(prtd->audio_client);
-
-		if (!mem_map_handle) {
-			pr_err("%s: mem_map_handle is NULL\n", __func__);
-			ret = -EFAULT;
-			goto fail;
-		}
-
-		if (prtd->dsp_cnt == runtime->periods)
-			prtd->dsp_cnt = 0;
-
-		ret = afe_rt_proxy_port_read((prtd->dma_addr +
-				(prtd->dsp_cnt *
-				snd_pcm_lib_period_bytes(prtd->substream))),
-				mem_map_handle,
-				snd_pcm_lib_period_bytes(prtd->substream));
-
-		if (ret) {
-			pr_err("%s: AFE proxy port read failed %d\n",
-				__func__, ret);
-			goto fail;
-		}
-
-		prtd->dsp_cnt++;
-		ret = wait_event_timeout(prtd->read_wait,
-				atomic_read(&prtd->rec_bytes_avail), 5 * HZ);
-		if (ret < 0) {
-			pr_err("%s: wait_event_timeout failed\n", __func__);
-
-			ret = -ETIMEDOUT;
-			goto fail;
-		}
-		atomic_set(&prtd->rec_bytes_avail, 0);
-	}
-	pr_debug("%s:appl_ptr 0x%lx hw_ptr 0x%lx src_to_copy 0x%pK\n",
-			__func__, runtime->control->appl_ptr,
-			runtime->status->hw_ptr, hwbuf);
-
-	if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) {
-		pr_err("%s: copy to user failed\n", __func__);
-
-		goto fail;
-		ret = -EFAULT;
-	}
-
-fail:
-	return ret;
-}
-
-static int msm_afe_copy(struct snd_pcm_substream *substream, int channel,
-			snd_pcm_uframes_t hwoff, void __user *buf,
-			snd_pcm_uframes_t frames)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-
-	int ret = 0;
-
-	if (prtd->reset_event) {
-		pr_debug("%s: reset events received from ADSP, return error\n",
-			__func__);
-		return -ENETRESET;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_afe_playback_copy(substream, channel, hwoff,
-					buf, frames);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_afe_capture_copy(substream, channel, hwoff,
-					buf, frames);
-	return ret;
-}
-
-static int msm_afe_close(struct snd_pcm_substream *substream)
-{
-	int rc = 0;
-	struct snd_dma_buffer *dma_buf;
-	struct snd_pcm_runtime *runtime;
-	struct pcm_afe_info *prtd;
-	struct snd_soc_pcm_runtime *rtd = NULL;
-	struct snd_soc_dai *dai = NULL;
-	int dir = IN;
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	if (substream == NULL) {
-		pr_err("substream is NULL\n");
-		return -EINVAL;
-	}
-	rtd = substream->private_data;
-	dai = rtd->cpu_dai;
-	runtime = substream->runtime;
-	prtd = runtime->private_data;
-
-	mutex_lock(&prtd->lock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		dir = IN;
-		ret =  afe_unregister_get_events(dai->id);
-		if (ret < 0)
-			pr_err("AFE unregister for events failed\n");
-	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		dir = OUT;
-		ret =  afe_unregister_get_events(dai->id);
-		if (ret < 0)
-			pr_err("AFE unregister for events failed\n");
-	}
-	if (prtd->mmap_flag)
-		hrtimer_cancel(&prtd->hrt);
-
-	rc = afe_cmd_memory_unmap(afe_req_mmap_handle(prtd->audio_client));
-	if (rc < 0)
-		pr_err("AFE memory unmap failed\n");
-
-	pr_debug("release all buffer\n");
-	dma_buf = &substream->dma_buffer;
-	if (dma_buf == NULL) {
-		pr_debug("dma_buf is NULL\n");
-			goto done;
-	}
-
-	if (dma_buf->area)
-		dma_buf->area = NULL;
-	q6afe_audio_client_buf_free_contiguous(dir, prtd->audio_client);
-done:
-	pr_debug("%s: dai->id =%x\n", __func__, dai->id);
-	q6afe_audio_client_free(prtd->audio_client);
-	mutex_unlock(&prtd->lock);
-	prtd->prepared--;
-	kfree(prtd);
-	runtime->private_data = NULL;
-	return 0;
-}
-static int msm_afe_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-
-	prtd->pcm_irq_pos = 0;
-	if (prtd->prepared)
-		return 0;
-	mutex_lock(&prtd->lock);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_afe_playback_prepare(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_afe_capture_prepare(substream);
-	mutex_unlock(&prtd->lock);
-	return ret;
-}
-static int msm_afe_mmap(struct snd_pcm_substream *substream,
-				struct vm_area_struct *vma)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	struct afe_audio_client *ac = prtd->audio_client;
-	struct afe_audio_port_data *apd = ac->port;
-	struct afe_audio_buffer *ab;
-	int dir = -1;
-
-	pr_debug("%s\n", __func__);
-	prtd->mmap_flag = 1;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-	ab = &(apd[dir].buf[0]);
-
-	return msm_audio_ion_mmap((struct audio_buffer *)ab, vma);
-}
-static int msm_afe_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		pr_debug("%s: SNDRV_PCM_TRIGGER_START\n", __func__);
-		prtd->start = 1;
-		if (prtd->mmap_flag)
-			hrtimer_start(&prtd->hrt, ns_to_ktime(0),
-					HRTIMER_MODE_REL);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		pr_debug("%s: SNDRV_PCM_TRIGGER_STOP\n", __func__);
-		prtd->start = 0;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-	return ret;
-}
-static int msm_afe_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct pcm_afe_info *prtd = runtime->private_data;
-	struct afe_audio_buffer *buf;
-	int dir, rc;
-
-	pr_debug("%s:\n", __func__);
-
-	mutex_lock(&prtd->lock);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-
-	rc = q6afe_audio_client_buf_alloc_contiguous(dir,
-		prtd->audio_client,
-		(params_buffer_bytes(params) / params_periods(params)),
-		params_periods(params));
-	pr_debug("params_buffer_bytes(params) = %d\n",
-			(params_buffer_bytes(params)));
-	pr_debug("params_periods(params) = %d\n",
-			(params_periods(params)));
-	pr_debug("params_periodsize(params) = %d\n",
-		(params_buffer_bytes(params) / params_periods(params)));
-
-	if (rc < 0) {
-		pr_err("Audio Start: Buffer Allocation failed rc = %d\n", rc);
-		mutex_unlock(&prtd->lock);
-		return -ENOMEM;
-	}
-	buf = prtd->audio_client->port[dir].buf;
-
-	if (buf == NULL || buf[0].data == NULL) {
-		mutex_unlock(&prtd->lock);
-		return -ENOMEM;
-	}
-
-	pr_debug("%s:buf = %pK\n", __func__, buf);
-	dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-	dma_buf->dev.dev = substream->pcm->card->dev;
-	dma_buf->private_data = NULL;
-	dma_buf->area = buf[0].data;
-	dma_buf->addr = buf[0].phys;
-
-	dma_buf->bytes = params_buffer_bytes(params);
-
-	if (!dma_buf->area) {
-		pr_err("%s:MSM AFE physical memory allocation failed\n",
-							__func__);
-		mutex_unlock(&prtd->lock);
-		return -ENOMEM;
-	}
-
-	memset(dma_buf->area, 0,  params_buffer_bytes(params));
-
-	prtd->dma_addr = (phys_addr_t) dma_buf->addr;
-
-	mutex_unlock(&prtd->lock);
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
-	rc = afe_memory_map(dma_buf->addr, dma_buf->bytes, prtd->audio_client);
-	if (rc < 0)
-		pr_err("fail to map memory to DSP\n");
-
-	return rc;
-}
-static snd_pcm_uframes_t msm_afe_pointer(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct pcm_afe_info *prtd = runtime->private_data;
-
-	if (prtd->pcm_irq_pos >= snd_pcm_lib_buffer_bytes(substream))
-		prtd->pcm_irq_pos = 0;
-
-	if (prtd->reset_event) {
-		pr_debug("%s: reset events received from ADSP, return XRUN\n",
-			__func__);
-		return SNDRV_PCM_POS_XRUN;
-	}
-
-	pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos);
-	return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
-}
-
-static const struct snd_pcm_ops msm_afe_ops = {
-	.open           = msm_afe_open,
-	.copy           = msm_afe_copy,
-	.hw_params	= msm_afe_hw_params,
-	.trigger	= msm_afe_trigger,
-	.close          = msm_afe_close,
-	.prepare        = msm_afe_prepare,
-	.mmap		= msm_afe_mmap,
-	.pointer	= msm_afe_pointer,
-};
-
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-	return ret;
-}
-
-static int msm_afe_afe_probe(struct snd_soc_platform *platform)
-{
-	pr_debug("%s\n", __func__);
-	return 0;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_afe_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.probe		= msm_afe_afe_probe,
-};
-
-static int msm_afe_probe(struct platform_device *pdev)
-{
-
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev,
-				   &msm_soc_platform);
-}
-
-static int msm_afe_remove(struct platform_device *pdev)
-{
-	pr_debug("%s\n", __func__);
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-static const struct of_device_id msm_pcm_afe_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-afe"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_pcm_afe_dt_match);
-
-static struct platform_driver msm_afe_driver = {
-	.driver = {
-		.name = "msm-pcm-afe",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_afe_dt_match,
-	},
-	.probe = msm_afe_probe,
-	.remove = msm_afe_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	pr_debug("%s\n", __func__);
-	return platform_driver_register(&msm_afe_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	pr_debug("%s\n", __func__);
-	platform_driver_unregister(&msm_afe_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("AFE PCM module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.h
deleted file mode 100644
index 84a4c3c..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (c) 2012,2015-2016 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_PCM_AFE_H
-#define _MSM_PCM_AFE_H
-#include <sound/apr_audio-v2.h>
-#include <sound/q6afe-v2.h>
-
-
-struct pcm_afe_info {
-	unsigned long dma_addr;
-	struct snd_pcm_substream *substream;
-	unsigned int pcm_irq_pos;       /* IRQ position */
-	struct mutex lock;
-	spinlock_t dsp_lock;
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint8_t start;
-	uint32_t dsp_cnt;
-	uint32_t buf_phys;
-	int32_t mmap_flag;
-	int prepared;
-	struct hrtimer hrt;
-	int poll_time;
-	struct afe_audio_client *audio_client;
-	wait_queue_head_t read_wait;
-	atomic_t rec_bytes_avail;
-	bool reset_event;
-};
-
-
-#define MSM_EXT(xname, fp_info, fp_get, fp_put, addr) \
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
-	.name = xname, \
-	.info = fp_info,\
-	.get = fp_get, .put = fp_put, \
-	.private_value = addr, \
-	}
-
-#endif /*_MSM_PCM_AFE_H*/
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-dtmf-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-dtmf-v2.c
deleted file mode 100644
index f4e03fe..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-dtmf-v2.c
+++ /dev/null
@@ -1,596 +0,0 @@
-/* Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-#include <sound/q6afe-v2.h>
-
-#include "msm-pcm-q6-v2.h"
-#include "msm-pcm-routing-v2.h"
-#include "q6voice.h"
-
-enum {
-	DTMF_IN_RX,
-	DTMF_IN_TX,
-};
-
-enum format {
-	FORMAT_S16_LE = 2
-};
-
-struct dtmf_det_info {
-	char     session[MAX_SESSION_NAME_LEN];
-	uint8_t  dir;
-	uint16_t high_freq;
-	uint16_t low_freq;
-};
-
-struct dtmf_buf_node {
-	struct list_head list;
-	struct dtmf_det_info dtmf_det_pkt;
-};
-
-enum dtmf_state {
-	DTMF_GEN_RX_STOPPED,
-	DTMF_GEN_RX_STARTED,
-};
-
-#define DTMF_MAX_Q_LEN 10
-#define DTMF_PKT_SIZE sizeof(struct dtmf_det_info)
-
-struct dtmf_drv_info {
-	enum  dtmf_state state;
-	struct snd_pcm_substream *capture_substream;
-
-	struct list_head out_queue;
-	struct list_head free_out_queue;
-
-	wait_queue_head_t out_wait;
-
-	struct mutex lock;
-	spinlock_t dsp_lock;
-
-	uint8_t capture_start;
-	uint8_t capture_instance;
-
-	unsigned int pcm_capture_size;
-	unsigned int pcm_capture_count;
-	unsigned int pcm_capture_irq_pos;
-	unsigned int pcm_capture_buf_pos;
-};
-
-static struct snd_pcm_hardware msm_pcm_hardware = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				 SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				 SNDRV_PCM_INFO_MMAP_VALID |
-				 SNDRV_PCM_INFO_INTERLEAVED),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE,
-	.channels_min =         1,
-	.channels_max =         1,
-	.buffer_bytes_max =	(sizeof(struct dtmf_buf_node) * DTMF_MAX_Q_LEN),
-	.period_bytes_min =	DTMF_PKT_SIZE,
-	.period_bytes_max =	DTMF_PKT_SIZE,
-	.periods_min =		DTMF_MAX_Q_LEN,
-	.periods_max =		DTMF_MAX_Q_LEN,
-	.fifo_size =            0,
-};
-
-static int msm_dtmf_rx_generate_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	uint16_t low_freq = ucontrol->value.integer.value[0];
-	uint16_t high_freq = ucontrol->value.integer.value[1];
-	int64_t duration = ucontrol->value.integer.value[2];
-	uint16_t gain = ucontrol->value.integer.value[3];
-
-	pr_debug("%s: low_freq=%d high_freq=%d duration=%d gain=%d\n",
-		 __func__, low_freq, high_freq, (int)duration, gain);
-	afe_dtmf_generate_rx(duration, high_freq, low_freq, gain);
-	return 0;
-}
-
-static int msm_dtmf_rx_generate_get(struct  snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s:\n", __func__);
-	ucontrol->value.integer.value[0] = 0;
-	return 0;
-}
-
-static int msm_dtmf_detect_voice_rx_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int enable = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: enable=%d\n", __func__, enable);
-	voc_enable_dtmf_rx_detection(voc_get_session_id(VOICE_SESSION_NAME),
-				     enable);
-
-	return 0;
-}
-
-static int msm_dtmf_detect_voice_rx_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = 0;
-	return 0;
-}
-
-static int msm_dtmf_detect_volte_rx_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int enable = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: enable=%d\n", __func__, enable);
-	voc_enable_dtmf_rx_detection(voc_get_session_id(VOLTE_SESSION_NAME),
-				     enable);
-
-	return 0;
-}
-
-static int msm_dtmf_detect_volte_rx_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = 0;
-	return 0;
-}
-
-static struct snd_kcontrol_new msm_dtmf_controls[] = {
-	SOC_SINGLE_MULTI_EXT("DTMF_Generate Rx Low High Duration Gain",
-			     SND_SOC_NOPM, 0, 5000, 0, 4,
-			     msm_dtmf_rx_generate_get,
-			     msm_dtmf_rx_generate_put),
-	SOC_SINGLE_EXT("DTMF_Detect Rx Voice enable", SND_SOC_NOPM, 0, 1, 0,
-				msm_dtmf_detect_voice_rx_get,
-				msm_dtmf_detect_voice_rx_put),
-	SOC_SINGLE_EXT("DTMF_Detect Rx VoLTE enable", SND_SOC_NOPM, 0, 1, 0,
-				msm_dtmf_detect_volte_rx_get,
-				msm_dtmf_detect_volte_rx_put),
-};
-
-static int msm_pcm_dtmf_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, msm_dtmf_controls,
-				      ARRAY_SIZE(msm_dtmf_controls));
-	return 0;
-}
-
-static void dtmf_rx_detected_cb(uint8_t *pkt,
-				char *session,
-				void *private_data)
-{
-	struct dtmf_buf_node *buf_node = NULL;
-	struct vss_istream_evt_rx_dtmf_detected *dtmf_det_pkt =
-		(struct vss_istream_evt_rx_dtmf_detected *)pkt;
-	struct dtmf_drv_info *prtd = private_data;
-	unsigned long dsp_flags;
-
-	pr_debug("%s\n", __func__);
-	if (prtd->capture_substream == NULL)
-		return;
-
-	/* Copy dtmf detected info into out_queue. */
-	spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-	/* discarding dtmf detection info till start is received */
-	if (!list_empty(&prtd->free_out_queue) && prtd->capture_start) {
-		buf_node = list_first_entry(&prtd->free_out_queue,
-					    struct dtmf_buf_node, list);
-		list_del(&buf_node->list);
-		buf_node->dtmf_det_pkt.high_freq = dtmf_det_pkt->high_freq;
-		buf_node->dtmf_det_pkt.low_freq = dtmf_det_pkt->low_freq;
-		if (session != NULL)
-			strlcpy(buf_node->dtmf_det_pkt.session,
-				session, MAX_SESSION_NAME_LEN);
-
-		buf_node->dtmf_det_pkt.dir = DTMF_IN_RX;
-		pr_debug("high =%d, low=%d session=%s\n",
-			 buf_node->dtmf_det_pkt.high_freq,
-			 buf_node->dtmf_det_pkt.low_freq,
-			 buf_node->dtmf_det_pkt.session);
-		list_add_tail(&buf_node->list, &prtd->out_queue);
-		prtd->pcm_capture_irq_pos += prtd->pcm_capture_count;
-		spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-		snd_pcm_period_elapsed(prtd->capture_substream);
-	} else {
-		spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-		pr_err("DTMF detection pkt in Rx  dropped, no free node available\n");
-	}
-
-	wake_up(&prtd->out_wait);
-}
-
-static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	int count = 0;
-	struct dtmf_buf_node *buf_node = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-	unsigned long dsp_flags;
-
-	count = frames_to_bytes(runtime, frames);
-
-	ret = wait_event_interruptible_timeout(prtd->out_wait,
-				(!list_empty(&prtd->out_queue)),
-				1 * HZ);
-
-	if (ret > 0) {
-		if (count <= DTMF_PKT_SIZE) {
-			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-			buf_node = list_first_entry(&prtd->out_queue,
-					struct dtmf_buf_node, list);
-			list_del(&buf_node->list);
-			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-			ret = copy_to_user(buf,
-					   &buf_node->dtmf_det_pkt,
-					   count);
-			if (ret) {
-				pr_err("%s: Copy to user returned %d\n",
-					__func__, ret);
-				ret = -EFAULT;
-			}
-			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-			list_add_tail(&buf_node->list,
-				      &prtd->free_out_queue);
-			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-
-		} else {
-			pr_err("%s: Read count %d > DTMF_PKT_SIZE\n",
-				__func__, count);
-			ret = -ENOMEM;
-		}
-	} else if (ret == 0) {
-		pr_err("%s: No UL data available\n", __func__);
-		ret = -ETIMEDOUT;
-	} else {
-		pr_err("%s: Read was interrupted\n", __func__);
-		ret = -ERESTARTSYS;
-	}
-	return ret;
-}
-
-static int msm_pcm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-
-	pr_debug("%s() DTMF\n", __func__);
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
-
-	return ret;
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = NULL;
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		prtd = kzalloc(sizeof(struct dtmf_drv_info), GFP_KERNEL);
-
-		if (prtd == NULL) {
-			ret = -ENOMEM;
-			goto done;
-		}
-
-		mutex_init(&prtd->lock);
-		spin_lock_init(&prtd->dsp_lock);
-		init_waitqueue_head(&prtd->out_wait);
-		INIT_LIST_HEAD(&prtd->out_queue);
-		INIT_LIST_HEAD(&prtd->free_out_queue);
-
-		runtime->hw = msm_pcm_hardware;
-
-		ret = snd_pcm_hw_constraint_integer(runtime,
-						    SNDRV_PCM_HW_PARAM_PERIODS);
-		if (ret < 0)
-			pr_info("snd_pcm_hw_constraint_integer failed\n");
-
-		prtd->capture_substream = substream;
-		prtd->capture_instance++;
-		runtime->private_data = prtd;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-	struct dtmf_buf_node *buf_node = NULL;
-	struct snd_dma_buffer *c_dma_buf;
-	struct snd_pcm_substream *c_substream;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-	unsigned long dsp_flags;
-
-	pr_debug("%s() DTMF\n", __func__);
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		mutex_lock(&prtd->lock);
-		wake_up(&prtd->out_wait);
-
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			prtd->capture_instance--;
-
-		if (!prtd->capture_instance) {
-			if (prtd->state == DTMF_GEN_RX_STARTED) {
-				prtd->state = DTMF_GEN_RX_STOPPED;
-				voc_disable_dtmf_det_on_active_sessions();
-				voc_register_dtmf_rx_detection_cb(NULL, NULL);
-			}
-			/* release all buffer */
-			/* release out_queue and free_out_queue */
-			pr_debug("release all buffer\n");
-			c_substream = prtd->capture_substream;
-			if (c_substream == NULL) {
-				pr_debug("c_substream is NULL\n");
-				mutex_unlock(&prtd->lock);
-				return -EINVAL;
-			}
-
-			c_dma_buf = &c_substream->dma_buffer;
-			if (c_dma_buf == NULL) {
-				pr_debug("c_dma_buf is NULL.\n");
-				mutex_unlock(&prtd->lock);
-				return -EINVAL;
-			}
-
-			if (c_dma_buf->area != NULL) {
-				spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-				list_for_each_safe(ptr, next,
-							&prtd->out_queue) {
-					buf_node = list_entry(ptr,
-						   struct dtmf_buf_node, list);
-					list_del(&buf_node->list);
-				}
-
-				list_for_each_safe(ptr, next,
-						   &prtd->free_out_queue) {
-					buf_node = list_entry(ptr,
-						   struct dtmf_buf_node, list);
-					list_del(&buf_node->list);
-				}
-
-				spin_unlock_irqrestore(&prtd->dsp_lock,
-						       dsp_flags);
-				dma_free_coherent(c_substream->pcm->card->dev,
-						  runtime->hw.buffer_bytes_max,
-						  c_dma_buf->area,
-						  c_dma_buf->addr);
-				c_dma_buf->area = NULL;
-			}
-		}
-		prtd->capture_substream = NULL;
-		mutex_unlock(&prtd->lock);
-	}
-
-	return ret;
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct dtmf_buf_node *buf_node = NULL;
-	int i = 0, offset = 0;
-	int ret = 0;
-
-	pr_debug("%s: DTMF\n", __func__);
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		mutex_lock(&prtd->lock);
-		dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-		dma_buf->dev.dev = substream->pcm->card->dev;
-		dma_buf->private_data = NULL;
-
-		dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev,
-						runtime->hw.buffer_bytes_max,
-						&dma_buf->addr, GFP_KERNEL);
-		if (!dma_buf->area) {
-			pr_err("%s:MSM DTMF dma_alloc failed\n", __func__);
-			mutex_unlock(&prtd->lock);
-			return -ENOMEM;
-		}
-
-		dma_buf->bytes = runtime->hw.buffer_bytes_max;
-		memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max);
-
-		for (i = 0; i < DTMF_MAX_Q_LEN; i++) {
-			pr_debug("node =%d\n", i);
-			buf_node = (void *) dma_buf->area + offset;
-			list_add_tail(&buf_node->list,
-				      &prtd->free_out_queue);
-			offset = offset + sizeof(struct dtmf_buf_node);
-		}
-
-		snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-		mutex_unlock(&prtd->lock);
-	}
-
-	return ret;
-}
-
-static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-
-	pr_debug("%s: DTMF\n", __func__);
-	prtd->pcm_capture_size  = snd_pcm_lib_buffer_bytes(substream);
-	prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream);
-	prtd->pcm_capture_irq_pos = 0;
-	prtd->pcm_capture_buf_pos = 0;
-	return 0;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-
-	pr_debug("%s: DTMF\n", __func__);
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		mutex_lock(&prtd->lock);
-
-		msm_pcm_capture_prepare(substream);
-
-		if (runtime->format != FORMAT_S16_LE) {
-			pr_err("format:%u doesn't match %d\n",
-			       (uint32_t)runtime->format, FORMAT_S16_LE);
-			mutex_unlock(&prtd->lock);
-			return -EINVAL;
-		}
-
-		if (prtd->capture_instance &&
-			(prtd->state != DTMF_GEN_RX_STARTED)) {
-			voc_register_dtmf_rx_detection_cb(dtmf_rx_detected_cb,
-							  prtd);
-			prtd->state = DTMF_GEN_RX_STARTED;
-		}
-		mutex_unlock(&prtd->lock);
-	}
-
-	return 0;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-		pr_debug("%s: Trigger start\n", __func__);
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			prtd->capture_start = 1;
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("SNDRV_PCM_TRIGGER_STOP\n");
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			prtd->capture_start = 0;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
-{
-	snd_pcm_uframes_t ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct dtmf_drv_info *prtd = runtime->private_data;
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		if (prtd->pcm_capture_irq_pos >= prtd->pcm_capture_size)
-			prtd->pcm_capture_irq_pos = 0;
-		ret = bytes_to_frames(runtime, (prtd->pcm_capture_irq_pos));
-	}
-
-	return ret;
-}
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
-	.hw_params	= msm_pcm_hw_params,
-	.close          = msm_pcm_close,
-	.prepare        = msm_pcm_prepare,
-	.trigger        = msm_pcm_trigger,
-	.pointer        = msm_pcm_pointer,
-};
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-	return ret;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.probe		= msm_pcm_dtmf_probe,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-
-	return snd_soc_register_platform(&pdev->dev,
-					 &msm_soc_platform);
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_pcm_dtmf_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-dtmf"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_pcm_dtmf_dt_match);
-
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-pcm-dtmf",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_dtmf_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("DTMF platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-host-voice-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-host-voice-v2.c
deleted file mode 100644
index 2f60db9..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-host-voice-v2.c
+++ /dev/null
@@ -1,1553 +0,0 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <asm/dma.h>
-#include <linux/msm_audio_ion.h>
-#include "q6voice.h"
-
-#define HPCM_MAX_Q_LEN 2
-#define HPCM_MIN_VOC_PKT_SIZE 320
-#define HPCM_MAX_VOC_PKT_SIZE 640
-#define VHPCM_BLOCK_SIZE 4096
-#define CACHE_ALIGNMENT_SIZE 128
-#define CACHE_ALIGNMENT_MASK 0xFFFFFF80
-
-#define VOICE_TX_CAPTURE_DAI_ID  "CS-VOICE HOST TX CAPTURE"
-#define VOICE_TX_PLAYBACK_DAI_ID "CS-VOICE HOST TX PLAYBACK"
-#define VOICE_RX_CAPTURE_DAI_ID  "CS-VOICE HOST RX CAPTURE"
-#define VOICE_RX_PLAYBACK_DAI_ID "CS-VOICE HOST RX PLAYBACK"
-
-#define VOLTE_TX_CAPTURE_DAI_ID  "VOLTE HOST TX CAPTURE"
-#define VOLTE_TX_PLAYBACK_DAI_ID "VOLTE HOST TX PLAYBACK"
-#define VOLTE_RX_CAPTURE_DAI_ID  "VOLTE HOST RX CAPTURE"
-#define VOLTE_RX_PLAYBACK_DAI_ID "VOLTE HOST RX PLAYBACK"
-
-
-#define VoMMode1_TX_CAPTURE_DAI_ID  "VoiceMMode1 HOST TX CAPTURE"
-#define VoMMode1_TX_PLAYBACK_DAI_ID "VoiceMMode1 HOST TX PLAYBACK"
-#define VoMMode1_RX_CAPTURE_DAI_ID  "VoiceMMode1 HOST RX CAPTURE"
-#define VoMMode1_RX_PLAYBACK_DAI_ID "VoiceMMode1 HOST RX PLAYBACK"
-
-#define VoMMode2_TX_CAPTURE_DAI_ID  "VoiceMMode2 HOST TX CAPTURE"
-#define VoMMode2_TX_PLAYBACK_DAI_ID "VoiceMMode2 HOST TX PLAYBACK"
-#define VoMMode2_RX_CAPTURE_DAI_ID  "VoiceMMode2 HOST RX CAPTURE"
-#define VoMMode2_RX_PLAYBACK_DAI_ID "VoiceMMode2 HOST RX PLAYBACK"
-
-enum {
-	RX = 1,
-	TX,
-};
-
-enum {
-	VOICE_INDEX = 0,
-	VOLTE_INDEX,
-	VOMMODE1_INDEX,
-	VOMMODE2_INDEX,
-	MAX_SESSION
-};
-
-enum hpcm_state {
-	HPCM_STOPPED = 1,
-	HPCM_CLOSED,
-	HPCM_PREPARED,
-	HPCM_STARTED,
-};
-
-struct hpcm_frame {
-	uint32_t len;
-	uint8_t voc_pkt[HPCM_MAX_VOC_PKT_SIZE];
-};
-
-struct hpcm_buf_node {
-	struct list_head list;
-	struct hpcm_frame frame;
-};
-
-struct vocpcm_ion_buffer {
-	/* Physical address */
-	phys_addr_t paddr;
-	/* Kernel virtual address */
-	void *kvaddr;
-};
-
-struct dai_data {
-	enum  hpcm_state state;
-	struct snd_pcm_substream *substream;
-	struct list_head filled_queue;
-	struct list_head free_queue;
-	wait_queue_head_t queue_wait;
-	spinlock_t dsp_lock;
-	uint32_t pcm_size;
-	uint32_t pcm_count;
-	/* IRQ position */
-	uint32_t pcm_irq_pos;
-	/* Position in buffer */
-	uint32_t pcm_buf_pos;
-	struct vocpcm_ion_buffer vocpcm_ion_buffer;
-};
-
-struct tap_point {
-	struct dai_data playback_dai_data;
-	struct dai_data capture_dai_data;
-};
-
-struct session {
-	struct tap_point tx_tap_point;
-	struct tap_point rx_tap_point;
-	phys_addr_t sess_paddr;
-	void *sess_kvaddr;
-	struct ion_handle *ion_handle;
-	struct mem_map_table tp_mem_table;
-};
-
-struct tappnt_mxr_data {
-	bool enable;
-	uint16_t direction;
-	uint16_t sample_rate;
-};
-
-/* Values from mixer ctl are cached in this structure */
-struct mixer_conf {
-	int8_t sess_indx;
-	struct tappnt_mxr_data rx;
-	struct tappnt_mxr_data tx;
-};
-
-struct start_cmd {
-	struct vss_ivpcm_tap_point tap_pnt[2];
-	uint32_t no_of_tapoints;
-};
-
-struct hpcm_drv {
-	struct mutex lock;
-	struct session session[MAX_SESSION];
-	struct mixer_conf mixer_conf;
-	struct ion_client *ion_client;
-	struct start_cmd start_cmd;
-};
-
-static struct hpcm_drv hpcm_drv;
-
-static struct snd_pcm_hardware msm_pcm_hardware = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_SPECIAL,
-	.rates =                SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-	.rate_min =             8000,
-	.rate_max =             16000,
-	.channels_min =         1,
-	.channels_max =         1,
-	.buffer_bytes_max =	sizeof(struct hpcm_buf_node) * HPCM_MAX_Q_LEN,
-	.period_bytes_min =	HPCM_MIN_VOC_PKT_SIZE,
-	.period_bytes_max =	HPCM_MAX_VOC_PKT_SIZE,
-	.periods_min =		HPCM_MAX_Q_LEN,
-	.periods_max =		HPCM_MAX_Q_LEN,
-	.fifo_size =            0,
-};
-
-static char *hpcm_get_sess_name(int sess_indx)
-{
-	char *sess_name = NULL;
-
-	if (sess_indx == VOICE_INDEX)
-		sess_name = VOICE_SESSION_NAME;
-	else if (sess_indx == VOLTE_INDEX)
-		sess_name = VOLTE_SESSION_NAME;
-	else if (sess_indx == VOMMODE1_INDEX)
-		sess_name = VOICEMMODE1_NAME;
-	else if (sess_indx == VOMMODE2_INDEX)
-		sess_name = VOICEMMODE2_NAME;
-	else
-		pr_err("%s:, Invalid sess_index\n", __func__);
-
-	return sess_name;
-}
-
-static void hpcm_reset_mixer_config(struct hpcm_drv *prtd)
-{
-	prtd->mixer_conf.sess_indx = -1;
-	prtd->mixer_conf.rx.enable = false;
-	prtd->mixer_conf.rx.direction = -1;
-	prtd->mixer_conf.rx.sample_rate = 0;
-
-	prtd->mixer_conf.tx.enable = false;
-	prtd->mixer_conf.tx.direction = -1;
-	prtd->mixer_conf.tx.sample_rate = 0;
-}
-
-/* Check for valid mixer control values */
-static bool hpcm_is_valid_config(int sess_indx, int tap_point,
-				 uint16_t direction, uint16_t samplerate)
-{
-	if (sess_indx < VOICE_INDEX || sess_indx > VOMMODE2_INDEX) {
-		pr_err("%s: invalid sess_indx :%d\n", __func__, sess_indx);
-		goto error;
-	}
-
-	if (samplerate != VSS_IVPCM_SAMPLING_RATE_8K &&
-	    samplerate != VSS_IVPCM_SAMPLING_RATE_16K) {
-		pr_err("%s: invalid sample rate :%d\n", __func__, samplerate);
-		goto error;
-	}
-
-	if ((tap_point != RX) && (tap_point != TX)) {
-		pr_err("%s: invalid tappoint :%d\n", __func__, tap_point);
-		goto error;
-	}
-
-	if ((direction != VSS_IVPCM_TAP_POINT_DIR_IN) &&
-	    (direction != VSS_IVPCM_TAP_POINT_DIR_OUT) &&
-	    (direction != VSS_IVPCM_TAP_POINT_DIR_OUT_IN)) {
-		pr_err("%s: invalid direction :%d\n", __func__, direction);
-		goto error;
-	}
-
-	return true;
-
-error:
-	return false;
-}
-
-
-static struct dai_data *hpcm_get_dai_data(char *pcm_id, struct hpcm_drv *prtd)
-{
-	struct dai_data *dai_data = NULL;
-	size_t size = 0;
-
-	if (pcm_id) {
-		size = strlen(pcm_id);
-		/* Check for Voice DAI */
-		if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOICE_INDEX].tx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOICE_INDEX].tx_tap_point.playback_dai_data;
-		} else if (strnstr(pcm_id, VOICE_RX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOICE_INDEX].rx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VOICE_RX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOICE_INDEX].rx_tap_point.playback_dai_data;
-		/* Check for VoLTE DAI */
-		} else if (strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOLTE_INDEX].tx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOLTE_INDEX].tx_tap_point.playback_dai_data;
-		} else if (strnstr(pcm_id, VOLTE_RX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOLTE_INDEX].rx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VOLTE_RX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOLTE_INDEX].rx_tap_point.playback_dai_data;
-		/* check for VoiceMMode1 DAI */
-		} else if (strnstr(pcm_id, VoMMode1_TX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE1_INDEX].tx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VoMMode1_TX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE1_INDEX].tx_tap_point.playback_dai_data;
-		} else if (strnstr(pcm_id, VoMMode1_RX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE1_INDEX].rx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VoMMode1_RX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE1_INDEX].rx_tap_point.playback_dai_data;
-		/* check for VOiceMMode2 DAI */
-		} else if (strnstr(pcm_id, VoMMode2_TX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE2_INDEX].tx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VoMMode2_TX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE2_INDEX].tx_tap_point.playback_dai_data;
-		} else if (strnstr(pcm_id, VoMMode2_RX_CAPTURE_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE2_INDEX].rx_tap_point.capture_dai_data;
-		} else if (strnstr(pcm_id, VoMMode2_RX_PLAYBACK_DAI_ID, size)) {
-			dai_data =
-		&prtd->session[VOMMODE2_INDEX].rx_tap_point.playback_dai_data;
-
-		} else {
-			pr_err("%s: Wrong dai id\n", __func__);
-		}
-	}
-
-	return dai_data;
-}
-
-static struct tap_point *hpcm_get_tappoint_data(char *pcm_id,
-						struct hpcm_drv *prtd)
-{
-	struct tap_point *tp = NULL;
-	size_t size = 0;
-
-	if (pcm_id) {
-		size = strlen(pcm_id);
-		/* Check for Voice DAI */
-		if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOICE_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOICE_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VOICE_RX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOICE_INDEX].rx_tap_point;
-		} else if (strnstr(pcm_id, VOICE_RX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOICE_INDEX].rx_tap_point;
-		/* Check for VoLTE DAI */
-		} else if (strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOLTE_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOLTE_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VOLTE_RX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOLTE_INDEX].rx_tap_point;
-		} else if (strnstr(pcm_id, VOLTE_RX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOLTE_INDEX].rx_tap_point;
-		/* check for VoiceMMode1 */
-		} else if (strnstr(pcm_id, VoMMode1_TX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE1_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode1_TX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE1_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode1_RX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE1_INDEX].rx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode1_RX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE1_INDEX].rx_tap_point;
-		/* check for VoiceMMode2 */
-		} else if (strnstr(pcm_id, VoMMode2_TX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE2_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode2_TX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE2_INDEX].tx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode2_RX_CAPTURE_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE2_INDEX].rx_tap_point;
-		} else if (strnstr(pcm_id, VoMMode2_RX_PLAYBACK_DAI_ID, size)) {
-			tp = &prtd->session[VOMMODE2_INDEX].rx_tap_point;
-		} else {
-			pr_err("%s: wrong dai id\n", __func__);
-		}
-	}
-
-	return tp;
-}
-
-static struct tappnt_mxr_data *hpcm_get_tappnt_mixer_data(char *pcm_id,
-						struct hpcm_drv *prtd)
-{
-
-	if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode1_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode1_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode2_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode2_TX_PLAYBACK_DAI_ID, strlen(pcm_id))) {
-		return &prtd->mixer_conf.tx;
-	} else {
-		return &prtd->mixer_conf.rx;
-	}
-}
-
-static int get_tappnt_value(char *pcm_id)
-{
-
-	if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode1_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode1_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode2_TX_CAPTURE_DAI_ID, strlen(pcm_id)) ||
-	    strnstr(pcm_id, VoMMode2_TX_PLAYBACK_DAI_ID, strlen(pcm_id))) {
-		return TX;
-	} else {
-		return RX;
-	}
-}
-
-static bool hpcm_all_dais_are_ready(uint16_t direction, struct tap_point *tp,
-				    enum hpcm_state state)
-{
-	bool dais_started = false;
-
-	/*
-	 * Based on the direction set per tap point in the mixer control,
-	 * all the dais per tap point should meet the required state for the
-	 * commands such as vpcm_map_memory/vpcm_start to be executed.
-	 */
-	switch (direction) {
-	case VSS_IVPCM_TAP_POINT_DIR_OUT_IN:
-		if ((tp->playback_dai_data.state >= state) &&
-		    (tp->capture_dai_data.state >= state)) {
-			dais_started = true;
-		}
-		break;
-
-	case VSS_IVPCM_TAP_POINT_DIR_IN:
-		if (tp->playback_dai_data.state >= state)
-			dais_started = true;
-		break;
-
-	case VSS_IVPCM_TAP_POINT_DIR_OUT:
-		if (tp->capture_dai_data.state >= state)
-			dais_started = true;
-		break;
-
-	default:
-		pr_err("invalid direction\n");
-	}
-
-	return dais_started;
-}
-
-static void hpcm_create_free_queue(struct snd_dma_buffer *dma_buf,
-				   struct dai_data *dai_data)
-{
-	struct hpcm_buf_node *buf_node = NULL;
-	int i = 0, offset = 0;
-
-	for (i = 0; i < HPCM_MAX_Q_LEN; i++) {
-		buf_node = (void *)dma_buf->area + offset;
-		list_add_tail(&buf_node->list,
-			      &dai_data->free_queue);
-		offset = offset + sizeof(struct hpcm_buf_node);
-	}
-}
-
-static void hpcm_free_allocated_mem(struct hpcm_drv *prtd)
-{
-	phys_addr_t paddr = 0;
-	struct tap_point *txtp = NULL;
-	struct tap_point *rxtp = NULL;
-	struct session *sess = NULL;
-
-	sess = &prtd->session[prtd->mixer_conf.sess_indx];
-	txtp = &sess->tx_tap_point;
-	rxtp = &sess->rx_tap_point;
-	paddr = sess->sess_paddr;
-
-	if (paddr) {
-		msm_audio_ion_free(prtd->ion_client, sess->ion_handle);
-		prtd->ion_client = NULL;
-		sess->ion_handle = NULL;
-		msm_audio_ion_free(sess->tp_mem_table.client,
-				   sess->tp_mem_table.handle);
-		sess->tp_mem_table.client = NULL;
-		sess->tp_mem_table.handle = NULL;
-		sess->sess_paddr = 0;
-		sess->sess_kvaddr = 0;
-		sess->ion_handle = 0;
-		prtd->ion_client = 0;
-		sess->tp_mem_table.client = 0;
-		sess->tp_mem_table.handle = 0;
-
-		txtp->capture_dai_data.vocpcm_ion_buffer.paddr = 0;
-		txtp->capture_dai_data.vocpcm_ion_buffer.kvaddr = 0;
-
-		txtp->playback_dai_data.vocpcm_ion_buffer.paddr = 0;
-		txtp->playback_dai_data.vocpcm_ion_buffer.kvaddr = 0;
-
-		rxtp->capture_dai_data.vocpcm_ion_buffer.paddr = 0;
-		rxtp->capture_dai_data.vocpcm_ion_buffer.kvaddr = 0;
-
-		rxtp->playback_dai_data.vocpcm_ion_buffer.paddr = 0;
-		rxtp->playback_dai_data.vocpcm_ion_buffer.kvaddr = 0;
-	} else {
-		pr_debug("%s, paddr = 0, nothing to free\n", __func__);
-	}
-}
-
-static void hpcm_unmap_and_free_shared_memory(struct hpcm_drv *prtd)
-
-{
-	phys_addr_t paddr = 0;
-	char *sess_name = hpcm_get_sess_name(prtd->mixer_conf.sess_indx);
-
-	if (prtd->mixer_conf.sess_indx >= 0)
-		paddr = prtd->session[prtd->mixer_conf.sess_indx].sess_paddr;
-	else
-		paddr = 0;
-
-	if (paddr) {
-		voc_send_cvp_unmap_vocpcm_memory(voc_get_session_id(sess_name));
-		hpcm_free_allocated_mem(prtd);
-	} else {
-		pr_debug("%s, paddr = 0, nothing to unmap/free\n", __func__);
-	}
-}
-
-static int hpcm_map_vocpcm_memory(struct hpcm_drv *prtd)
-{
-	int ret = 0;
-	char *sess_name = hpcm_get_sess_name(prtd->mixer_conf.sess_indx);
-	struct session *sess = NULL;
-
-	sess = &prtd->session[prtd->mixer_conf.sess_indx];
-
-	ret = voc_send_cvp_map_vocpcm_memory(voc_get_session_id(sess_name),
-					     &sess->tp_mem_table,
-					     sess->sess_paddr,
-					     VHPCM_BLOCK_SIZE);
-
-	return ret;
-}
-
-static int hpcm_allocate_shared_memory(struct hpcm_drv *prtd)
-{
-	int result;
-	int ret = 0;
-	size_t mem_len;
-	size_t len;
-	struct tap_point *txtp = NULL;
-	struct tap_point *rxtp = NULL;
-	struct session *sess = NULL;
-
-	sess = &prtd->session[prtd->mixer_conf.sess_indx];
-	txtp = &sess->tx_tap_point;
-	rxtp = &sess->rx_tap_point;
-
-	result = msm_audio_ion_alloc("host_pcm_buffer",
-				     &prtd->ion_client,
-				     &sess->ion_handle,
-				     VHPCM_BLOCK_SIZE,
-				     &sess->sess_paddr,
-				     &mem_len,
-				     &sess->sess_kvaddr);
-	if (result) {
-		pr_err("%s: msm_audio_ion_alloc error, rc = %d\n",
-			__func__, result);
-		sess->sess_paddr = 0;
-		sess->sess_kvaddr = 0;
-		ret = -ENOMEM;
-		goto done;
-	}
-	pr_debug("%s: Host PCM memory block allocated\n", __func__);
-
-	/* Allocate mem_map_table for tap point */
-	result = msm_audio_ion_alloc("host_pcm_table",
-			&sess->tp_mem_table.client,
-			&sess->tp_mem_table.handle,
-			sizeof(struct vss_imemory_table_t),
-			&sess->tp_mem_table.phys,
-			&len,
-			&sess->tp_mem_table.data);
-
-	if (result) {
-		pr_err("%s: msm_audio_ion_alloc error, rc = %d\n",
-			__func__, result);
-		msm_audio_ion_free(prtd->ion_client, sess->ion_handle);
-		prtd->ion_client = NULL;
-		sess->ion_handle = NULL;
-		sess->sess_paddr = 0;
-		sess->sess_kvaddr = 0;
-		ret = -ENOMEM;
-		goto done;
-	}
-	pr_debug("%s:  Host PCM memory table allocated\n", __func__);
-
-	memset(sess->tp_mem_table.data, 0,
-	       sizeof(struct vss_imemory_table_t));
-
-	sess->tp_mem_table.size = sizeof(struct vss_imemory_table_t);
-
-	pr_debug("%s: data %pK phys %pK\n", __func__,
-		 sess->tp_mem_table.data, &sess->tp_mem_table.phys);
-
-	/* Split 4096 block into four 1024 byte blocks for each dai */
-	txtp->capture_dai_data.vocpcm_ion_buffer.paddr =
-	sess->sess_paddr;
-	txtp->capture_dai_data.vocpcm_ion_buffer.kvaddr =
-	sess->sess_kvaddr;
-
-	txtp->playback_dai_data.vocpcm_ion_buffer.paddr =
-	sess->sess_paddr + VHPCM_BLOCK_SIZE/4;
-	txtp->playback_dai_data.vocpcm_ion_buffer.kvaddr =
-	sess->sess_kvaddr + VHPCM_BLOCK_SIZE/4;
-
-	rxtp->capture_dai_data.vocpcm_ion_buffer.paddr =
-	sess->sess_paddr + (VHPCM_BLOCK_SIZE/4) * 2;
-	rxtp->capture_dai_data.vocpcm_ion_buffer.kvaddr =
-	sess->sess_kvaddr + (VHPCM_BLOCK_SIZE/4) * 2;
-
-	rxtp->playback_dai_data.vocpcm_ion_buffer.paddr =
-	sess->sess_paddr + (VHPCM_BLOCK_SIZE/4) * 3;
-	rxtp->playback_dai_data.vocpcm_ion_buffer.kvaddr =
-	sess->sess_kvaddr + (VHPCM_BLOCK_SIZE/4) * 3;
-
-done:
-	return ret;
-}
-
-static int hpcm_start_vocpcm(char *pcm_id, struct hpcm_drv *prtd,
-			     struct tap_point *tp)
-{
-	int indx = prtd->mixer_conf.sess_indx;
-	uint32_t *no_of_tp = &prtd->start_cmd.no_of_tapoints;
-	struct vss_ivpcm_tap_point *tap_pnt = &prtd->start_cmd.tap_pnt[0];
-	uint32_t no_of_tp_req = 0;
-	char *sess_name = hpcm_get_sess_name(indx);
-
-	if (prtd->mixer_conf.rx.enable)
-		no_of_tp_req++;
-	if (prtd->mixer_conf.tx.enable)
-		no_of_tp_req++;
-
-	if (prtd->mixer_conf.rx.enable && (get_tappnt_value(pcm_id) == RX)) {
-		if (hpcm_all_dais_are_ready(prtd->mixer_conf.rx.direction,
-					    tp, HPCM_PREPARED)) {
-			pr_debug("%s: RX conditions met\n", __func__);
-			tap_pnt[*no_of_tp].tap_point =
-					VSS_IVPCM_TAP_POINT_RX_DEFAULT;
-			tap_pnt[*no_of_tp].direction =
-					prtd->mixer_conf.rx.direction;
-			tap_pnt[*no_of_tp].sampling_rate =
-					prtd->mixer_conf.rx.sample_rate;
-			(*no_of_tp)++;
-		}
-	}
-
-	if (prtd->mixer_conf.tx.enable && (get_tappnt_value(pcm_id) == TX)) {
-		if (hpcm_all_dais_are_ready(prtd->mixer_conf.tx.direction,
-					    tp, HPCM_PREPARED)) {
-			pr_debug("%s: TX conditions met\n", __func__);
-			tap_pnt[*no_of_tp].tap_point =
-						VSS_IVPCM_TAP_POINT_TX_DEFAULT;
-			tap_pnt[*no_of_tp].direction =
-						prtd->mixer_conf.tx.direction;
-			tap_pnt[*no_of_tp].sampling_rate =
-						prtd->mixer_conf.tx.sample_rate;
-			(*no_of_tp)++;
-		}
-	}
-
-	if ((prtd->mixer_conf.tx.enable || prtd->mixer_conf.rx.enable) &&
-	    *no_of_tp == no_of_tp_req) {
-		voc_send_cvp_start_vocpcm(voc_get_session_id(sess_name),
-					  tap_pnt, *no_of_tp);
-		/* Reset the start command so that it is not called twice */
-		memset(&prtd->start_cmd, 0, sizeof(struct start_cmd));
-	} else {
-		pr_debug("%s: required pcm handles not opened yet\n", __func__);
-	}
-
-	return 0;
-}
-
-/* Playback path*/
-static void hpcm_copy_playback_data_from_queue(struct dai_data *dai_data,
-					       uint32_t *len)
-{
-	struct hpcm_buf_node *buf_node = NULL;
-	unsigned long dsp_flags;
-
-	if (dai_data->substream == NULL)
-		return;
-
-	spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-
-	if (!list_empty(&dai_data->filled_queue)) {
-		buf_node = list_first_entry(&dai_data->filled_queue,
-				struct hpcm_buf_node, list);
-		list_del(&buf_node->list);
-		*len = buf_node->frame.len;
-		memcpy((u8 *)dai_data->vocpcm_ion_buffer.kvaddr,
-		       &buf_node->frame.voc_pkt[0],
-		       buf_node->frame.len);
-
-		list_add_tail(&buf_node->list, &dai_data->free_queue);
-		dai_data->pcm_irq_pos += dai_data->pcm_count;
-		spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		snd_pcm_period_elapsed(dai_data->substream);
-	} else {
-		*len = 0;
-		spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		pr_err("IN data not available\n");
-	}
-
-	wake_up(&dai_data->queue_wait);
-}
-
-/* Capture path*/
-static void hpcm_copy_capture_data_to_queue(struct dai_data *dai_data,
-					    uint32_t len)
-{
-	struct hpcm_buf_node *buf_node = NULL;
-	unsigned long dsp_flags;
-
-	if (dai_data->substream == NULL)
-		return;
-
-	/* Copy out buffer packet into free_queue */
-	spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-
-	if (!list_empty(&dai_data->free_queue)) {
-		buf_node = list_first_entry(&dai_data->free_queue,
-					struct hpcm_buf_node, list);
-		list_del(&buf_node->list);
-		buf_node->frame.len = len;
-		memcpy(&buf_node->frame.voc_pkt[0],
-		       (uint8_t *)dai_data->vocpcm_ion_buffer.kvaddr,
-		       buf_node->frame.len);
-		list_add_tail(&buf_node->list, &dai_data->filled_queue);
-		dai_data->pcm_irq_pos += dai_data->pcm_count;
-		spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		snd_pcm_period_elapsed(dai_data->substream);
-	} else {
-		spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		pr_err("OUTPUT data dropped\n");
-	}
-
-	wake_up(&dai_data->queue_wait);
-}
-
-void hpcm_notify_evt_processing(uint8_t *data, char *session,
-				void *private_data)
-{
-	struct hpcm_drv *prtd = (struct hpcm_drv *)private_data;
-	struct vss_ivpcm_evt_notify_v2_t *notify_evt =
-				(struct vss_ivpcm_evt_notify_v2_t *)data;
-	struct vss_ivpcm_evt_push_buffer_v2_t push_buff_event;
-	struct tap_point *tp = NULL;
-	int in_buf_len = 0;
-	struct tappnt_mxr_data *tmd = NULL;
-	char *sess_name = hpcm_get_sess_name(prtd->mixer_conf.sess_indx);
-
-	/* If it's not a timetick, it's a error notification, drop the event */
-	if ((notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_TIMETICK) == 0) {
-		pr_err("%s: Error notification. mask=%d\n", __func__,
-			notify_evt->notify_mask);
-		return;
-	}
-
-	if (notify_evt->tap_point == VSS_IVPCM_TAP_POINT_TX_DEFAULT) {
-		tp = &prtd->session[prtd->mixer_conf.sess_indx].tx_tap_point;
-		tmd = &prtd->mixer_conf.tx;
-	} else if (notify_evt->tap_point == VSS_IVPCM_TAP_POINT_RX_DEFAULT) {
-		tp = &prtd->session[prtd->mixer_conf.sess_indx].rx_tap_point;
-		tmd = &prtd->mixer_conf.rx;
-	}
-
-	if (tp == NULL || tmd == NULL) {
-		pr_err("%s: tp = %pK or tmd = %pK is null\n", __func__,
-		       tp, tmd);
-
-		return;
-	}
-
-	if (notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_OUTPUT_BUFFER) {
-		hpcm_copy_capture_data_to_queue(&tp->capture_dai_data,
-						notify_evt->filled_out_size);
-	}
-
-	if (notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_INPUT_BUFFER) {
-		hpcm_copy_playback_data_from_queue(&tp->playback_dai_data,
-						   &in_buf_len);
-	}
-
-	switch (tmd->direction) {
-	/*
-	 * When the dir is OUT_IN, for the first notify mask, pushbuf mask
-	 * should be set to VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER since we
-	 * atleast need one buffer's worth data before we can send IN buffer.
-	 * For the consecutive notify evts, the push buf mask will set for both
-	 * VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER and
-	 * VSS_IVPCM_PUSH_BUFFER_MASK_IN_BUFFER.
-	 */
-	case VSS_IVPCM_TAP_POINT_DIR_OUT_IN:
-		if (notify_evt->notify_mask ==
-		    VSS_IVPCM_NOTIFY_MASK_TIMETICK) {
-			push_buff_event.push_buf_mask =
-				VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER;
-		} else {
-			push_buff_event.push_buf_mask =
-			   VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER |
-			   VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER;
-		}
-		break;
-
-	case VSS_IVPCM_TAP_POINT_DIR_IN:
-		push_buff_event.push_buf_mask =
-			VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER;
-		break;
-
-	case VSS_IVPCM_TAP_POINT_DIR_OUT:
-		push_buff_event.push_buf_mask =
-			 VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER;
-		break;
-	}
-
-	push_buff_event.tap_point = notify_evt->tap_point;
-	push_buff_event.out_buf_mem_address =
-		      tp->capture_dai_data.vocpcm_ion_buffer.paddr;
-	push_buff_event.in_buf_mem_address =
-		      tp->playback_dai_data.vocpcm_ion_buffer.paddr;
-	push_buff_event.sampling_rate = notify_evt->sampling_rate;
-	push_buff_event.num_in_channels = 1;
-
-	/*
-	 * ADSP must read and write from a cache aligned (128 byte) location,
-	 * and in blocks of the cache alignment size. The 128 byte cache
-	 * alignment requirement is guaranteed due to 4096 byte memory
-	 * alignment requirement during memory allocation/mapping. The output
-	 * buffer (ADSP write) size mask ensures that a 128 byte multiple
-	 * worth of will be written.  Internally, the input buffer (ADSP read)
-	 * size will also be a multiple of 128 bytes.  However it is the
-	 * application's responsibility to ensure no other data is written in
-	 * the specified length of memory.
-	 */
-	push_buff_event.out_buf_mem_size = ((notify_evt->request_buf_size) +
-				CACHE_ALIGNMENT_SIZE) & CACHE_ALIGNMENT_MASK;
-	push_buff_event.in_buf_mem_size = in_buf_len;
-
-	voc_send_cvp_vocpcm_push_buf_evt(voc_get_session_id(sess_name),
-					 &push_buff_event);
-}
-
-static int msm_hpcm_configure_voice_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-
-	int tap_point = ucontrol->value.integer.value[0];
-	uint16_t direction = ucontrol->value.integer.value[1];
-	uint16_t sample_rate = ucontrol->value.integer.value[2];
-	struct tappnt_mxr_data *tmd = NULL;
-	int ret = 0;
-
-	mutex_lock(&hpcm_drv.lock);
-	pr_debug("%s: tap_point = %d direction = %d sample_rate = %d\n",
-		 __func__, tap_point, direction, sample_rate);
-
-	if (!hpcm_is_valid_config(VOICE_INDEX, tap_point, direction,
-				  sample_rate)) {
-		pr_err("Invalid vpcm mixer control voice values\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (tap_point == RX)
-		tmd = &hpcm_drv.mixer_conf.rx;
-	else
-		tmd = &hpcm_drv.mixer_conf.tx;
-
-	tmd->enable = true;
-	tmd->direction = direction;
-	tmd->sample_rate = sample_rate;
-	hpcm_drv.mixer_conf.sess_indx = VOICE_INDEX;
-
-done:
-	mutex_unlock(&hpcm_drv.lock);
-	return ret;
-}
-
-static int msm_hpcm_configure_vmmode1_put(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-
-	int tap_point = ucontrol->value.integer.value[0];
-	uint16_t direction = ucontrol->value.integer.value[1];
-	uint16_t sample_rate = ucontrol->value.integer.value[2];
-	struct tappnt_mxr_data *tmd = NULL;
-	int ret = 0;
-
-	mutex_lock(&hpcm_drv.lock);
-	pr_debug("%s: tap_point = %d direction = %d sample_rate = %d\n",
-		 __func__, tap_point, direction, sample_rate);
-
-	if (!hpcm_is_valid_config(VOMMODE1_INDEX, tap_point, direction,
-				  sample_rate)) {
-		pr_err("Invalid vpcm mixer control voice values\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (tap_point == RX)
-		tmd = &hpcm_drv.mixer_conf.rx;
-	else
-		tmd = &hpcm_drv.mixer_conf.tx;
-
-	tmd->enable = true;
-	tmd->direction = direction;
-	tmd->sample_rate = sample_rate;
-	hpcm_drv.mixer_conf.sess_indx = VOMMODE1_INDEX;
-
-done:
-	mutex_unlock(&hpcm_drv.lock);
-	return ret;
-}
-
-static int msm_hpcm_configure_vmmode2_put(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-
-	int tap_point = ucontrol->value.integer.value[0];
-	uint16_t direction = ucontrol->value.integer.value[1];
-	uint16_t sample_rate = ucontrol->value.integer.value[2];
-	struct tappnt_mxr_data *tmd = NULL;
-	int ret = 0;
-
-	mutex_lock(&hpcm_drv.lock);
-	pr_debug("%s: tap_point = %d direction = %d sample_rate = %d\n",
-		 __func__, tap_point, direction, sample_rate);
-
-	if (!hpcm_is_valid_config(VOMMODE2_INDEX, tap_point, direction,
-				  sample_rate)) {
-		pr_err("Invalid vpcm mixer control voice values\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (tap_point == RX)
-		tmd = &hpcm_drv.mixer_conf.rx;
-	else
-		tmd = &hpcm_drv.mixer_conf.tx;
-
-	tmd->enable = true;
-	tmd->direction = direction;
-	tmd->sample_rate = sample_rate;
-	hpcm_drv.mixer_conf.sess_indx = VOMMODE2_INDEX;
-
-done:
-	mutex_unlock(&hpcm_drv.lock);
-	return ret;
-}
-
-static int msm_hpcm_configure_volte_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-
-	int tap_point = ucontrol->value.integer.value[0];
-	uint16_t direction = ucontrol->value.integer.value[1];
-	uint16_t sample_rate = ucontrol->value.integer.value[2];
-	struct tappnt_mxr_data *tmd = NULL;
-	int ret = 0;
-
-	mutex_lock(&hpcm_drv.lock);
-	pr_debug("%s: tap_point=%d direction=%d sample_rate=%d\n",
-		 __func__, tap_point, direction, sample_rate);
-
-	if (!hpcm_is_valid_config(VOLTE_INDEX, tap_point, direction,
-				  sample_rate)) {
-		pr_err("Invalid vpcm mixer control volte values\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (tap_point == RX)
-		tmd = &hpcm_drv.mixer_conf.rx;
-	else
-		tmd = &hpcm_drv.mixer_conf.tx;
-
-	tmd->enable = true;
-	tmd->direction = direction;
-	tmd->sample_rate = sample_rate;
-	hpcm_drv.mixer_conf.sess_indx = VOLTE_INDEX;
-
-done:
-	mutex_unlock(&hpcm_drv.lock);
-	return ret;
-
-}
-
-static struct snd_kcontrol_new msm_hpcm_controls[] = {
-	SOC_SINGLE_MULTI_EXT("HPCM_Voice tappoint direction samplerate",
-			     SND_SOC_NOPM, 0, 16000, 0, 3,
-			     NULL, msm_hpcm_configure_voice_put),
-	SOC_SINGLE_MULTI_EXT("HPCM_VoLTE tappoint direction samplerate",
-			     SND_SOC_NOPM, 0, 16000, 0, 3,
-			     NULL, msm_hpcm_configure_volte_put),
-	SOC_SINGLE_MULTI_EXT("HPCM_VMMode1 tappoint direction samplerate",
-			     SND_SOC_NOPM, 0, 16000, 0, 3,
-			     NULL, msm_hpcm_configure_vmmode1_put),
-	SOC_SINGLE_MULTI_EXT("HPCM_VMMode2 tappoint direction samplerate",
-			     SND_SOC_NOPM, 0, 16000, 0, 3,
-			     NULL, msm_hpcm_configure_vmmode2_put),
-};
-
-/* Sample rates supported */
-static unsigned int supported_sample_rates[] = {8000, 16000};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-	struct hpcm_buf_node *buf_node = NULL;
-	struct snd_dma_buffer *dma_buf;
-	struct snd_pcm_runtime *runtime;
-	struct hpcm_drv *prtd;
-	unsigned long dsp_flags;
-	struct dai_data *dai_data = NULL;
-	struct tap_point *tp = NULL;
-	struct tappnt_mxr_data *tmd = NULL;
-	char *sess_name = NULL;
-
-	if (substream == NULL) {
-		pr_err("substream is NULL\n");
-		return -EINVAL;
-	}
-
-	pr_debug("%s, %s\n", __func__, substream->pcm->id);
-	runtime = substream->runtime;
-	prtd = runtime->private_data;
-	sess_name = hpcm_get_sess_name(prtd->mixer_conf.sess_indx);
-	dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	wake_up(&dai_data->queue_wait);
-	mutex_lock(&prtd->lock);
-
-	tmd = hpcm_get_tappnt_mixer_data(substream->pcm->id, prtd);
-
-	tp = hpcm_get_tappoint_data(substream->pcm->id, prtd);
-	/* Send stop command */
-	voc_send_cvp_stop_vocpcm(voc_get_session_id(sess_name));
-	/* Memory unmap/free takes place only when called the first time */
-	hpcm_unmap_and_free_shared_memory(prtd);
-	/* Unregister host PCM event callback function */
-	voc_deregister_hpcm_evt_cb();
-	/* Reset the cached start cmd */
-	memset(&prtd->start_cmd, 0, sizeof(struct start_cmd));
-	/* Release all buffer */
-	pr_debug("%s: Release all buffer\n", __func__);
-	substream = dai_data->substream;
-	if (substream == NULL) {
-		pr_debug("%s: substream is NULL\n", __func__);
-		goto done;
-	}
-	dma_buf = &substream->dma_buffer;
-	if (dma_buf == NULL) {
-		pr_debug("%s: dma_buf is NULL\n", __func__);
-		goto done;
-	}
-	if (dma_buf->area != NULL) {
-		spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-		list_for_each_safe(ptr, next, &dai_data->filled_queue) {
-			buf_node = list_entry(ptr,
-					struct hpcm_buf_node, list);
-			list_del(&buf_node->list);
-		}
-		list_for_each_safe(ptr, next, &dai_data->free_queue) {
-			buf_node = list_entry(ptr,
-					struct hpcm_buf_node, list);
-			list_del(&buf_node->list);
-		}
-		spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		dma_free_coherent(substream->pcm->card->dev,
-			runtime->hw.buffer_bytes_max, dma_buf->area,
-			dma_buf->addr);
-		dma_buf->area = NULL;
-	}
-	dai_data->substream = NULL;
-	dai_data->pcm_buf_pos = 0;
-	dai_data->pcm_count = 0;
-	dai_data->pcm_irq_pos = 0;
-	dai_data->pcm_size = 0;
-	dai_data->state = HPCM_CLOSED;
-	hpcm_reset_mixer_config(prtd);
-
-done:
-	mutex_unlock(&prtd->lock);
-	return ret;
-}
-
-static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
-				 snd_pcm_uframes_t hwoff, void __user *buf,
-				 snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	struct hpcm_buf_node *buf_node = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = runtime->private_data;
-	struct dai_data *dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-	unsigned long dsp_flags;
-
-	int count = frames_to_bytes(runtime, frames);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_interruptible_timeout(dai_data->queue_wait,
-				(!list_empty(&dai_data->free_queue) ||
-				dai_data->state == HPCM_STOPPED),
-				1 * HZ);
-	if (ret > 0) {
-		if (count <= HPCM_MAX_VOC_PKT_SIZE) {
-			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-			buf_node =
-				list_first_entry(&dai_data->free_queue,
-						struct hpcm_buf_node, list);
-			list_del(&buf_node->list);
-			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-			ret = copy_from_user(&buf_node->frame.voc_pkt, buf,
-					     count);
-			buf_node->frame.len = count;
-			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-			list_add_tail(&buf_node->list, &dai_data->filled_queue);
-			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-		} else {
-			pr_err("%s: Write cnt %d is > HPCM_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
-			ret = -ENOMEM;
-		}
-	} else if (ret == 0) {
-		pr_err("%s: No free Playback buffer\n", __func__);
-		ret = -ETIMEDOUT;
-	} else {
-		pr_err("%s: playback copy  was interrupted\n", __func__);
-	}
-
-done:
-	return  ret;
-}
-
-static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	int count = 0;
-	struct hpcm_buf_node *buf_node = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = runtime->private_data;
-	struct dai_data *dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-	unsigned long dsp_flags;
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	count = frames_to_bytes(runtime, frames);
-
-	ret = wait_event_interruptible_timeout(dai_data->queue_wait,
-				(!list_empty(&dai_data->filled_queue) ||
-				dai_data->state == HPCM_STOPPED),
-				1 * HZ);
-
-	if (ret > 0) {
-		if (count <= HPCM_MAX_VOC_PKT_SIZE) {
-			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-			buf_node = list_first_entry(&dai_data->filled_queue,
-					struct hpcm_buf_node, list);
-			list_del(&buf_node->list);
-			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-			ret = copy_to_user(buf, &buf_node->frame.voc_pkt,
-					   buf_node->frame.len);
-			if (ret) {
-				pr_err("%s: Copy to user returned %d\n",
-					__func__, ret);
-				ret = -EFAULT;
-			}
-			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
-			list_add_tail(&buf_node->list, &dai_data->free_queue);
-			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
-
-		} else {
-			pr_err("%s: Read count %d > HPCM_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
-			ret = -ENOMEM;
-		}
-
-	} else if (ret == 0) {
-		pr_err("%s: No Caputre data available\n", __func__);
-		ret = -ETIMEDOUT;
-	} else {
-		pr_err("%s: Read was interrupted\n", __func__);
-		ret = -ERESTARTSYS;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_pcm_copy(struct snd_pcm_substream *substream, int channel,
-			snd_pcm_uframes_t hwoff, void __user *buf,
-			snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_copy(substream, channel,
-					    hwoff, buf, frames);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, channel,
-					   hwoff, buf, frames);
-
-	return ret;
-}
-
-static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
-{
-	struct dai_data *dai_data = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = runtime->private_data;
-	snd_pcm_uframes_t ret;
-
-	dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = 0;
-		goto done;
-	}
-
-	if (dai_data->pcm_irq_pos >= dai_data->pcm_size)
-		dai_data->pcm_irq_pos = 0;
-
-	ret = bytes_to_frames(runtime, (dai_data->pcm_irq_pos));
-
-done:
-	return ret;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = runtime->private_data;
-	struct dai_data *dai_data =
-			hpcm_get_dai_data(substream->pcm->id, prtd);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s, %s\n", __func__, substream->pcm->id);
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-		pr_debug("SNDRV_PCM_TRIGGER_START\n");
-		dai_data->state = HPCM_STARTED;
-		break;
-
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("SNDRV_PCM_TRIGGER_STOP\n");
-		dai_data->state = HPCM_STOPPED;
-		break;
-
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = runtime->private_data;
-	struct dai_data *dai_data = NULL;
-	struct tap_point *tp = NULL;
-
-	pr_debug("%s, %s\n", __func__, substream->pcm->id);
-	mutex_lock(&prtd->lock);
-
-	dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	dai_data->pcm_size  = snd_pcm_lib_buffer_bytes(substream);
-	dai_data->pcm_count = snd_pcm_lib_period_bytes(substream);
-	dai_data->pcm_irq_pos = 0;
-	dai_data->pcm_buf_pos = 0;
-	dai_data->state = HPCM_PREPARED;
-
-	/* Register event notify processing callback in prepare instead of
-	 * init() as q6voice module's init() can be called at a later point
-	 */
-	voc_register_hpcm_evt_cb(hpcm_notify_evt_processing, &hpcm_drv);
-
-	tp = hpcm_get_tappoint_data(substream->pcm->id, prtd);
-	if (tp != NULL) {
-		ret = hpcm_start_vocpcm(substream->pcm->id, prtd, tp);
-		if (ret) {
-			pr_err("error sending start cmd err=%d\n", ret);
-			goto done;
-		}
-	} else {
-		pr_err("%s tp is NULL\n", __func__);
-	}
-done:
-	mutex_unlock(&prtd->lock);
-	return ret;
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct hpcm_drv *prtd = (struct hpcm_drv *)runtime->private_data;
-	int ret = 0;
-
-	pr_debug("%s: %s\n", __func__, substream->pcm->id);
-	mutex_lock(&prtd->lock);
-
-	/* Allocate and map voice host PCM ion buffer */
-	if (prtd->session[prtd->mixer_conf.sess_indx].sess_paddr == 0) {
-		ret = hpcm_allocate_shared_memory(prtd);
-		if (ret) {
-			pr_err("error creating shared memory err=%d\n", ret);
-			goto done;
-		}
-
-		ret = hpcm_map_vocpcm_memory(prtd);
-		if (ret) {
-			pr_err("error mapping shared memory err=%d\n", ret);
-			hpcm_free_allocated_mem(prtd);
-			goto done;
-		}
-	} else {
-		pr_debug("%s, VHPCM memory allocation/mapping not performed\n"
-			 , __func__);
-	}
-
-	dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-	dma_buf->dev.dev = substream->pcm->card->dev;
-	dma_buf->private_data = NULL;
-
-	dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev,
-			runtime->hw.buffer_bytes_max,
-			&dma_buf->addr, GFP_KERNEL);
-
-	if (!dma_buf->area) {
-		pr_err("%s:MSM dma_alloc failed\n", __func__);
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	dma_buf->bytes = runtime->hw.buffer_bytes_max;
-	memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max);
-
-	hpcm_create_free_queue(dma_buf,
-		hpcm_get_dai_data(substream->pcm->id, prtd));
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
-done:
-	mutex_unlock(&prtd->lock);
-	return ret;
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hpcm_drv *prtd = &hpcm_drv;
-	struct tappnt_mxr_data *tmd = NULL;
-	struct dai_data *dai_data = NULL;
-	int ret = 0;
-	int tp_val = 0;
-
-	pr_debug("%s, %s\n", __func__, substream->pcm->id);
-	mutex_lock(&prtd->lock);
-
-	dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
-
-	if (dai_data == NULL) {
-		pr_err("%s, dai_data is null\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	runtime->hw = msm_pcm_hardware;
-
-	ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
-					 &constraints_sample_rates);
-	if (ret < 0)
-		pr_debug("snd_pcm_hw_constraint_list failed\n");
-
-	ret = snd_pcm_hw_constraint_integer(runtime,
-					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0) {
-		pr_debug("snd_pcm_hw_constraint_integer failed\n");
-		goto done;
-	}
-
-	tp_val = get_tappnt_value(substream->pcm->id);
-	tmd = hpcm_get_tappnt_mixer_data(substream->pcm->id, prtd);
-
-	/* Check wheather the kcontrol values set are valid */
-	if (!tmd ||
-	    !(tmd->enable) ||
-	    !hpcm_is_valid_config(prtd->mixer_conf.sess_indx,
-				  tp_val, tmd->direction,
-				  tmd->sample_rate)) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	dai_data->substream = substream;
-	runtime->private_data = prtd;
-
-done:
-	mutex_unlock(&prtd->lock);
-	return ret;
-}
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.hw_params      = msm_pcm_hw_params,
-	.prepare        = msm_pcm_prepare,
-	.trigger        = msm_pcm_trigger,
-	.pointer        = msm_pcm_pointer,
-	.copy           = msm_pcm_copy,
-	.close          = msm_pcm_close,
-};
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-
-	pr_debug("%s:\n", __func__);
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	return 0;
-}
-
-static int msm_pcm_hpcm_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, msm_hpcm_controls,
-				ARRAY_SIZE(msm_hpcm_controls));
-
-	return 0;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.probe		= msm_pcm_hpcm_probe,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-
-	pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev, &msm_soc_platform);
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_voice_host_pcm_dt_match[] = {
-	{.compatible = "qcom,msm-voice-host-pcm"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_voice_host_pcm_dt_match);
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-voice-host-pcm",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_voice_host_pcm_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	int i = 0;
-	struct session *s = NULL;
-
-	memset(&hpcm_drv, 0, sizeof(hpcm_drv));
-	mutex_init(&hpcm_drv.lock);
-
-	for (i = 0; i < MAX_SESSION; i++) {
-		s = &hpcm_drv.session[i];
-		spin_lock_init(&s->rx_tap_point.capture_dai_data.dsp_lock);
-		spin_lock_init(&s->rx_tap_point.playback_dai_data.dsp_lock);
-		spin_lock_init(&s->tx_tap_point.capture_dai_data.dsp_lock);
-		spin_lock_init(&s->tx_tap_point.playback_dai_data.dsp_lock);
-
-		init_waitqueue_head(
-			&s->rx_tap_point.capture_dai_data.queue_wait);
-		init_waitqueue_head(
-			&s->rx_tap_point.playback_dai_data.queue_wait);
-		init_waitqueue_head(
-			&s->tx_tap_point.capture_dai_data.queue_wait);
-		init_waitqueue_head(
-			&s->tx_tap_point.playback_dai_data.queue_wait);
-
-		INIT_LIST_HEAD(&s->rx_tap_point.capture_dai_data.filled_queue);
-		INIT_LIST_HEAD(&s->rx_tap_point.capture_dai_data.free_queue);
-		INIT_LIST_HEAD(&s->rx_tap_point.playback_dai_data.filled_queue);
-		INIT_LIST_HEAD(&s->rx_tap_point.playback_dai_data.free_queue);
-
-		INIT_LIST_HEAD(&s->tx_tap_point.capture_dai_data.filled_queue);
-		INIT_LIST_HEAD(&s->tx_tap_point.capture_dai_data.free_queue);
-		INIT_LIST_HEAD(&s->tx_tap_point.playback_dai_data.filled_queue);
-		INIT_LIST_HEAD(&s->tx_tap_point.playback_dai_data.free_queue);
-	}
-
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("PCM module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c
deleted file mode 100644
index 7ef1ca8..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c
+++ /dev/null
@@ -1,801 +0,0 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/q6asm-v2.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/tlv.h>
-#include <asm/dma.h>
-#include <sound/q6audio-v2.h>
-
-#include "msm-pcm-routing-v2.h"
-
-#define LOOPBACK_VOL_MAX_STEPS 0x2000
-#define LOOPBACK_SESSION_MAX 4
-
-static DEFINE_MUTEX(loopback_session_lock);
-static const DECLARE_TLV_DB_LINEAR(loopback_rx_vol_gain, 0,
-				LOOPBACK_VOL_MAX_STEPS);
-
-struct msm_pcm_loopback {
-	struct snd_pcm_substream *playback_substream;
-	struct snd_pcm_substream *capture_substream;
-
-	int instance;
-
-	struct mutex lock;
-
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-
-	int playback_start;
-	int capture_start;
-	int session_id;
-	struct audio_client *audio_client;
-	uint32_t volume;
-};
-
-struct fe_dai_session_map {
-	char stream_name[32];
-	struct msm_pcm_loopback *loopback_priv;
-};
-
-static struct fe_dai_session_map session_map[LOOPBACK_SESSION_MAX] = {
-	{ {}, NULL},
-	{ {}, NULL},
-	{ {}, NULL},
-	{ {}, NULL},
-};
-
-static u32 hfp_tx_mute;
-
-struct msm_pcm_pdata {
-	int perf_mode;
-};
-
-static void stop_pcm(struct msm_pcm_loopback *pcm);
-static int msm_pcm_loopback_get_session(struct snd_soc_pcm_runtime *rtd,
-					struct msm_pcm_loopback **pcm);
-
-static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event,
-					void *priv_data)
-{
-	struct msm_pcm_loopback *pcm = priv_data;
-
-	WARN_ON(!pcm);
-
-	pr_debug("%s: event 0x%x\n", __func__, event);
-
-	switch (event) {
-	case MSM_PCM_RT_EVT_DEVSWITCH:
-		q6asm_cmd(pcm->audio_client, CMD_PAUSE);
-		q6asm_cmd(pcm->audio_client, CMD_FLUSH);
-		q6asm_run(pcm->audio_client, 0, 0, 0);
-		/* fallthrough */
-	default:
-		pr_err("%s: default event 0x%x\n", __func__, event);
-		break;
-	}
-}
-
-static void msm_pcm_loopback_event_handler(uint32_t opcode, uint32_t token,
-					   uint32_t *payload, void *priv)
-{
-	pr_debug("%s:\n", __func__);
-	switch (opcode) {
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-			break;
-		default:
-			break;
-		}
-	}
-		break;
-	default:
-		pr_err("%s: Not Supported Event opcode[0x%x]\n",
-			__func__, opcode);
-		break;
-	}
-}
-
-static int msm_loopback_session_mute_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = hfp_tx_mute;
-	return 0;
-}
-
-static int msm_loopback_session_mute_put(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0, n = 0;
-	int mute = ucontrol->value.integer.value[0];
-	struct msm_pcm_loopback *pcm = NULL;
-
-	if ((mute < 0) || (mute > 1)) {
-		pr_err(" %s Invalid arguments", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: mute=%d\n", __func__, mute);
-	hfp_tx_mute = mute;
-	for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
-		if (!strcmp(session_map[n].stream_name, "MultiMedia6"))
-			pcm = session_map[n].loopback_priv;
-	}
-	if (pcm && pcm->audio_client) {
-		ret = q6asm_set_mute(pcm->audio_client, mute);
-		if (ret < 0)
-			pr_err("%s: Send mute command failed rc=%d\n",
-				__func__, ret);
-	}
-done:
-	return ret;
-}
-
-static struct snd_kcontrol_new msm_loopback_controls[] = {
-	SOC_SINGLE_EXT("HFP TX Mute", SND_SOC_NOPM, 0, 1, 0,
-			msm_loopback_session_mute_get,
-			msm_loopback_session_mute_put),
-};
-
-static int msm_pcm_loopback_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, msm_loopback_controls,
-				      ARRAY_SIZE(msm_loopback_controls));
-
-	return 0;
-}
-static int pcm_loopback_set_volume(struct msm_pcm_loopback *prtd,
-				   uint32_t volume)
-{
-	int rc = -EINVAL;
-
-	pr_debug("%s: Setting volume 0x%x\n", __func__, volume);
-
-	if (prtd && prtd->audio_client) {
-		rc = q6asm_set_volume(prtd->audio_client, volume);
-		if (rc < 0) {
-			pr_err("%s: Send Volume command failed rc = %d\n",
-				__func__, rc);
-			return rc;
-		}
-		prtd->volume = volume;
-	}
-	return rc;
-}
-
-static int msm_pcm_loopback_get_session(struct snd_soc_pcm_runtime *rtd,
-					struct msm_pcm_loopback **pcm)
-{
-	int ret = 0;
-	int n, index = -1;
-
-	dev_dbg(rtd->platform->dev, "%s: stream %s\n", __func__,
-		rtd->dai_link->stream_name);
-
-	mutex_lock(&loopback_session_lock);
-	for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
-		if (!strcmp(rtd->dai_link->stream_name,
-		    session_map[n].stream_name)) {
-			*pcm = session_map[n].loopback_priv;
-			goto exit;
-		}
-		/*
-		 * Store the min index value for allocating a new session.
-		 * Here, if session stream name is not found in the
-		 * existing entries after the loop iteration, then this
-		 * index will be used to allocate the new session.
-		 * This index variable is expected to point to the topmost
-		 * available free session.
-		 */
-		if (!(session_map[n].stream_name[0]) && (index < 0))
-			index = n;
-	}
-
-	if (index < 0) {
-		dev_err(rtd->platform->dev, "%s: Max Sessions allocated\n",
-				 __func__);
-		ret = -EAGAIN;
-		goto exit;
-	}
-
-	session_map[index].loopback_priv = kzalloc(
-		sizeof(struct msm_pcm_loopback), GFP_KERNEL);
-	if (!session_map[index].loopback_priv) {
-		ret = -ENOMEM;
-		goto exit;
-	}
-
-	strlcpy(session_map[index].stream_name,
-		rtd->dai_link->stream_name,
-		sizeof(session_map[index].stream_name));
-	dev_dbg(rtd->platform->dev, "%s: stream %s index %d\n",
-		__func__, session_map[index].stream_name, index);
-
-	mutex_init(&session_map[index].loopback_priv->lock);
-	*pcm = session_map[index].loopback_priv;
-exit:
-	mutex_unlock(&loopback_session_lock);
-	return ret;
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
-	struct msm_pcm_loopback *pcm = NULL;
-	int ret = 0;
-	uint16_t bits_per_sample = 16;
-	struct msm_pcm_routing_evt event;
-	struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window;
-	uint32_t param_id;
-	struct msm_pcm_pdata *pdata;
-
-	ret =  msm_pcm_loopback_get_session(rtd, &pcm);
-	if (ret)
-		return ret;
-
-	mutex_lock(&pcm->lock);
-
-	pcm->volume = 0x2000;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		pcm->playback_substream = substream;
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		pcm->capture_substream = substream;
-
-	pcm->instance++;
-	dev_dbg(rtd->platform->dev, "%s: pcm out open: %d,%d\n", __func__,
-			pcm->instance, substream->stream);
-	if (pcm->instance == 2) {
-		struct snd_soc_pcm_runtime *soc_pcm_rx =
-				pcm->playback_substream->private_data;
-		struct snd_soc_pcm_runtime *soc_pcm_tx =
-				pcm->capture_substream->private_data;
-		if (pcm->audio_client != NULL)
-			stop_pcm(pcm);
-
-		pdata = (struct msm_pcm_pdata *)
-			dev_get_drvdata(rtd->platform->dev);
-		if (!pdata) {
-			dev_err(rtd->platform->dev,
-				"%s: platform data not populated\n", __func__);
-			mutex_unlock(&pcm->lock);
-			return -EINVAL;
-		}
-
-		pcm->audio_client = q6asm_audio_client_alloc(
-				(app_cb)msm_pcm_loopback_event_handler, pcm);
-		if (!pcm->audio_client) {
-			dev_err(rtd->platform->dev,
-				"%s: Could not allocate memory\n", __func__);
-			mutex_unlock(&pcm->lock);
-			return -ENOMEM;
-		}
-		pcm->session_id = pcm->audio_client->session;
-		pcm->audio_client->perf_mode = pdata->perf_mode;
-		ret = q6asm_open_loopback_v2(pcm->audio_client,
-					     bits_per_sample);
-		if (ret < 0) {
-			dev_err(rtd->platform->dev,
-				"%s: pcm out open failed\n", __func__);
-			q6asm_audio_client_free(pcm->audio_client);
-			mutex_unlock(&pcm->lock);
-			return -ENOMEM;
-		}
-		event.event_func = msm_pcm_route_event_handler;
-		event.priv_data = (void *) pcm;
-		msm_pcm_routing_reg_phy_stream(soc_pcm_tx->dai_link->id,
-			pcm->audio_client->perf_mode,
-			pcm->session_id, pcm->capture_substream->stream);
-		msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->id,
-			pcm->audio_client->perf_mode,
-			pcm->session_id, pcm->playback_substream->stream,
-			event);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-			pcm->playback_substream = substream;
-			ret = pcm_loopback_set_volume(pcm, pcm->volume);
-			if (ret < 0)
-				dev_err(rtd->platform->dev,
-					"Error %d setting volume", ret);
-		}
-		/* Set to largest negative value */
-		asm_mtmx_strtr_window.window_lsw = 0x00000000;
-		asm_mtmx_strtr_window.window_msw = 0x80000000;
-		param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2;
-		q6asm_send_mtmx_strtr_window(pcm->audio_client,
-					     &asm_mtmx_strtr_window,
-					     param_id);
-		/* Set to largest positive value */
-		asm_mtmx_strtr_window.window_lsw = 0xffffffff;
-		asm_mtmx_strtr_window.window_msw = 0x7fffffff;
-		param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2;
-		q6asm_send_mtmx_strtr_window(pcm->audio_client,
-					     &asm_mtmx_strtr_window,
-					     param_id);
-	}
-	dev_info(rtd->platform->dev, "%s: Instance = %d, Stream ID = %s\n",
-			__func__, pcm->instance, substream->pcm->id);
-	runtime->private_data = pcm;
-
-	mutex_unlock(&pcm->lock);
-
-	return 0;
-}
-
-static void stop_pcm(struct msm_pcm_loopback *pcm)
-{
-	struct snd_soc_pcm_runtime *soc_pcm_rx;
-	struct snd_soc_pcm_runtime *soc_pcm_tx;
-
-	if (pcm->audio_client == NULL)
-		return;
-	q6asm_cmd(pcm->audio_client, CMD_CLOSE);
-
-	if (pcm->playback_substream != NULL) {
-		soc_pcm_rx = pcm->playback_substream->private_data;
-		msm_pcm_routing_dereg_phy_stream(soc_pcm_rx->dai_link->id,
-				SNDRV_PCM_STREAM_PLAYBACK);
-	}
-	if (pcm->capture_substream != NULL) {
-		soc_pcm_tx = pcm->capture_substream->private_data;
-		msm_pcm_routing_dereg_phy_stream(soc_pcm_tx->dai_link->id,
-				SNDRV_PCM_STREAM_CAPTURE);
-	}
-	q6asm_audio_client_free(pcm->audio_client);
-	pcm->audio_client = NULL;
-}
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_pcm_loopback *pcm = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
-	int ret = 0, n;
-	bool found = false;
-
-	mutex_lock(&pcm->lock);
-
-	dev_dbg(rtd->platform->dev, "%s: end pcm call:%d\n",
-		__func__, substream->stream);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		pcm->playback_start = 0;
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		pcm->capture_start = 0;
-
-	pcm->instance--;
-	if (!pcm->playback_start || !pcm->capture_start) {
-		dev_dbg(rtd->platform->dev, "%s: end pcm call\n", __func__);
-		stop_pcm(pcm);
-	}
-
-	if (!pcm->instance) {
-		mutex_lock(&loopback_session_lock);
-		for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
-			if (!strcmp(rtd->dai_link->stream_name,
-					session_map[n].stream_name)) {
-				found = true;
-				break;
-			}
-		}
-		if (found) {
-			memset(session_map[n].stream_name, 0,
-				sizeof(session_map[n].stream_name));
-			mutex_unlock(&pcm->lock);
-			mutex_destroy(&session_map[n].loopback_priv->lock);
-			session_map[n].loopback_priv = NULL;
-			kfree(pcm);
-			dev_dbg(rtd->platform->dev, "%s: stream freed %s\n",
-				__func__, rtd->dai_link->stream_name);
-			mutex_unlock(&loopback_session_lock);
-			return 0;
-		}
-		mutex_unlock(&loopback_session_lock);
-	}
-	mutex_unlock(&pcm->lock);
-	return ret;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_pcm_loopback *pcm = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
-
-	mutex_lock(&pcm->lock);
-
-	dev_dbg(rtd->platform->dev, "%s: ASM loopback stream:%d\n",
-		__func__, substream->stream);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		if (!pcm->playback_start)
-			pcm->playback_start = 1;
-	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		if (!pcm->capture_start)
-			pcm->capture_start = 1;
-	}
-	mutex_unlock(&pcm->lock);
-
-	return ret;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_pcm_loopback *pcm = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		dev_dbg(rtd->platform->dev,
-			"%s: playback_start:%d,capture_start:%d\n", __func__,
-			pcm->playback_start, pcm->capture_start);
-		if (pcm->playback_start && pcm->capture_start)
-			q6asm_run_nowait(pcm->audio_client, 0, 0, 0);
-		break;
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-	case SNDRV_PCM_TRIGGER_STOP:
-		dev_dbg(rtd->platform->dev,
-			"%s:Pause/Stop - playback_start:%d,capture_start:%d\n",
-			__func__, pcm->playback_start, pcm->capture_start);
-		if (pcm->playback_start && pcm->capture_start)
-			q6asm_cmd_nowait(pcm->audio_client, CMD_PAUSE);
-		break;
-	default:
-		pr_err("%s: default cmd %d\n", __func__, cmd);
-		break;
-	}
-
-	return 0;
-}
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.close          = msm_pcm_close,
-	.prepare        = msm_pcm_prepare,
-	.trigger        = msm_pcm_trigger,
-};
-
-static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	struct snd_pcm_volume *vol = kcontrol->private_data;
-	struct snd_pcm_substream *substream = vol->pcm->streams[0].substream;
-	struct msm_pcm_loopback *prtd;
-	int volume = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: volume : 0x%x\n", __func__, volume);
-	if ((!substream) || (!substream->runtime)) {
-		pr_err("%s substream or runtime not found\n", __func__);
-		rc = -ENODEV;
-		goto exit;
-	}
-	prtd = substream->runtime->private_data;
-	if (!prtd) {
-		rc = -ENODEV;
-		goto exit;
-	}
-	rc = pcm_loopback_set_volume(prtd, volume);
-
-exit:
-	return rc;
-}
-
-static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
-	struct snd_pcm_substream *substream =
-		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	struct msm_pcm_loopback *prtd;
-
-	pr_debug("%s\n", __func__);
-	if ((!substream) || (!substream->runtime)) {
-		pr_err("%s substream or runtime not found\n", __func__);
-		rc = -ENODEV;
-		goto exit;
-	}
-	prtd = substream->runtime->private_data;
-	if (!prtd) {
-		rc = -ENODEV;
-		goto exit;
-	}
-	ucontrol->value.integer.value[0] = prtd->volume;
-
-exit:
-	return rc;
-}
-
-static int msm_pcm_add_volume_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
-	struct snd_pcm_volume *volume_info;
-	struct snd_kcontrol *kctl;
-	int ret = 0;
-
-	dev_dbg(rtd->dev, "%s, Volume cntrl add\n", __func__);
-	ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-				      NULL, 1,
-				      rtd->dai_link->id,
-				      &volume_info);
-	if (ret < 0)
-		return ret;
-	kctl = volume_info->kctl;
-	kctl->put = msm_pcm_volume_ctl_put;
-	kctl->get = msm_pcm_volume_ctl_get;
-	kctl->tlv.p = loopback_rx_vol_gain;
-	return 0;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
-	struct snd_pcm_usr *app_type_info;
-	struct snd_kcontrol *kctl;
-	const char *playback_mixer_ctl_name	= "Audio Stream";
-	const char *capture_mixer_ctl_name	= "Audio Stream Capture";
-	const char *deviceNo		= "NN";
-	const char *suffix		= "App Type Cfg";
-	int ctl_len, ret = 0;
-
-	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
-		ctl_len = strlen(playback_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 + strlen(suffix) + 1;
-		pr_debug("%s: Playback app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-					NULL, 1, ctl_len, rtd->dai_link->id,
-					&app_type_info);
-		if (ret < 0)
-			return ret;
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-			playback_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_playback_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_playback_app_type_cfg_ctl_get;
-	}
-
-	if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
-		ctl_len = strlen(capture_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 + strlen(suffix) + 1;
-		pr_debug("%s: Capture app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
-					NULL, 1, ctl_len, rtd->dai_link->id,
-					&app_type_info);
-		if (ret < 0)
-			return ret;
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-			capture_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_capture_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_capture_app_type_cfg_ctl_get;
-	}
-
-	return 0;
-}
-
-static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	ret = msm_pcm_add_volume_controls(rtd);
-	if (ret)
-		pr_err("%s: pcm add volume controls failed:%d\n",
-			__func__, ret);
-	ret = msm_pcm_add_app_type_controls(rtd);
-	if (ret)
-		pr_err("%s: pcm add app type controls failed:%d\n",
-			__func__, ret);
-	return ret;
-}
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	ret = msm_pcm_add_controls(rtd);
-	if (ret)
-		dev_err(rtd->dev, "%s, kctl add failed\n", __func__);
-	return ret;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops            = &msm_pcm_ops,
-	.pcm_new        = msm_asoc_pcm_new,
-	.probe          = msm_pcm_loopback_probe,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	struct msm_pcm_pdata *pdata;
-
-	dev_dbg(&pdev->dev, "%s: dev name %s\n",
-		__func__, dev_name(&pdev->dev));
-
-	pdata = kzalloc(sizeof(struct msm_pcm_pdata), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	if (of_property_read_bool(pdev->dev.of_node,
-				"qcom,msm-pcm-loopback-low-latency"))
-		pdata->perf_mode = LOW_LATENCY_PCM_MODE;
-	else
-		pdata->perf_mode = LEGACY_PCM_MODE;
-
-	dev_set_drvdata(&pdev->dev, pdata);
-
-	return snd_soc_register_platform(&pdev->dev,
-				   &msm_soc_platform);
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_pcm_loopback_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-loopback"},
-	{}
-};
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-pcm-loopback",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_loopback_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("PCM loopback platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c
deleted file mode 100644
index 75a2bff..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c
+++ /dev/null
@@ -1,1284 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/of_device.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_ion.h>
-
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6audio-v2.h>
-#include <sound/timer.h>
-#include <sound/hwdep.h>
-
-#include <asm/dma.h>
-#include <sound/tlv.h>
-#include <sound/pcm_params.h>
-#include <sound/devdep_params.h>
-
-#include "msm-pcm-q6-v2.h"
-#include "msm-pcm-routing-v2.h"
-
-#define PCM_MASTER_VOL_MAX_STEPS	0x2000
-static const DECLARE_TLV_DB_LINEAR(msm_pcm_vol_gain, 0,
-			PCM_MASTER_VOL_MAX_STEPS);
-
-struct snd_msm {
-	struct snd_card *card;
-	struct snd_pcm *pcm;
-};
-
-#define CMD_EOS_MIN_TIMEOUT_LENGTH  50
-#define CMD_EOS_TIMEOUT_MULTIPLIER  (HZ * 50)
-
-#define ATRACE_END() \
-	trace_printk("tracing_mark_write: E\n")
-#define ATRACE_BEGIN(name) \
-	trace_printk("tracing_mark_write: B|%d|%s\n", current->tgid, name)
-#define ATRACE_FUNC() ATRACE_BEGIN(__func__)
-#define ATRACE_INT(name, value) \
-	trace_printk("tracing_mark_write: C|%d|%s|%d\n", \
-			current->tgid, name, (int)(value))
-
-#define SIO_PLAYBACK_MAX_PERIOD_SIZE PLAYBACK_MAX_PERIOD_SIZE
-#define SIO_PLAYBACK_MIN_PERIOD_SIZE 48
-#define SIO_PLAYBACK_MAX_NUM_PERIODS 512
-#define SIO_PLAYBACK_MIN_NUM_PERIODS PLAYBACK_MIN_NUM_PERIODS
-#define SIO_PLAYBACK_MIN_BYTES (SIO_PLAYBACK_MIN_NUM_PERIODS *	\
-				SIO_PLAYBACK_MIN_PERIOD_SIZE)
-
-#define SIO_PLAYBACK_MAX_BYTES ((SIO_PLAYBACK_MAX_NUM_PERIODS) *	\
-				(SIO_PLAYBACK_MAX_PERIOD_SIZE))
-
-#define SIO_CAPTURE_MAX_PERIOD_SIZE CAPTURE_MAX_PERIOD_SIZE
-#define SIO_CAPTURE_MIN_PERIOD_SIZE 48
-#define SIO_CAPTURE_MAX_NUM_PERIODS 512
-#define SIO_CAPTURE_MIN_NUM_PERIODS CAPTURE_MIN_NUM_PERIODS
-
-#define SIO_CAPTURE_MIN_BYTES (SIO_CAPTURE_MIN_NUM_PERIODS *	\
-			       SIO_CAPTURE_MIN_PERIOD_SIZE)
-
-#define SIO_CAPTURE_MAX_BYTES (SIO_CAPTURE_MAX_NUM_PERIODS *	\
-				SIO_CAPTURE_MAX_PERIOD_SIZE)
-
-static struct snd_pcm_hardware msm_pcm_hardware_playback = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
-				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
-	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE),
-	.rates =                SNDRV_PCM_RATE_8000_192000,
-	.rate_min =             8000,
-	.rate_max =             192000,
-	.channels_min =         1,
-	.channels_max =         8,
-	.buffer_bytes_max =     SIO_PLAYBACK_MAX_NUM_PERIODS *
-				SIO_PLAYBACK_MAX_PERIOD_SIZE,
-	.period_bytes_min =	SIO_PLAYBACK_MIN_PERIOD_SIZE,
-	.period_bytes_max =     SIO_PLAYBACK_MAX_PERIOD_SIZE,
-	.periods_min =          SIO_PLAYBACK_MIN_NUM_PERIODS,
-	.periods_max =          SIO_PLAYBACK_MAX_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-static struct snd_pcm_hardware msm_pcm_hardware_capture = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
-				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
-	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE),
-	.rates =                SNDRV_PCM_RATE_8000_48000,
-	.rate_min =             8000,
-	.rate_max =             48000,
-	.channels_min =         1,
-	.channels_max =         4,
-	.buffer_bytes_max =     SIO_CAPTURE_MAX_NUM_PERIODS *
-				SIO_CAPTURE_MAX_PERIOD_SIZE,
-	.period_bytes_min =	SIO_CAPTURE_MIN_PERIOD_SIZE,
-	.period_bytes_max =     SIO_CAPTURE_MAX_PERIOD_SIZE,
-	.periods_min =          SIO_CAPTURE_MIN_NUM_PERIODS,
-	.periods_max =          SIO_CAPTURE_MAX_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
-	88200, 96000, 176400, 192000
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static unsigned long msm_pcm_fe_topology[MSM_FRONTEND_DAI_MAX];
-
-/* default value is DTS (i.e read from device tree) */
-static char const *msm_pcm_fe_topology_text[] = {
-	"DTS", "ULL", "ULL_PP", "LL" };
-
-static const struct soc_enum msm_pcm_fe_topology_enum[] = {
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(msm_pcm_fe_topology_text),
-			    msm_pcm_fe_topology_text),
-};
-
-static void event_handler(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv)
-{
-	uint32_t *ptrmem = (uint32_t *)payload;
-
-	switch (opcode) {
-	case ASM_DATA_EVENT_WATERMARK:
-		pr_debug("%s: Watermark level = 0x%08x\n", __func__, *ptrmem);
-		break;
-	case APR_BASIC_RSP_RESULT:
-		pr_debug("%s: Payload = [0x%x]stat[0x%x]\n",
-				__func__, payload[0], payload[1]);
-		switch (payload[0]) {
-		case ASM_SESSION_CMD_RUN_V2:
-		case ASM_SESSION_CMD_PAUSE:
-		case ASM_STREAM_CMD_FLUSH:
-			break;
-		default:
-			break;
-		}
-		break;
-	default:
-		pr_debug("Not Supported Event opcode[0x%x]\n", opcode);
-		break;
-	}
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd;
-	int ret = 0;
-
-	prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL);
-
-	if (prtd == NULL)
-		return -ENOMEM;
-
-	prtd->substream = substream;
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		runtime->hw = msm_pcm_hardware_playback;
-	else
-		runtime->hw = msm_pcm_hardware_capture;
-
-	ret = snd_pcm_hw_constraint_list(runtime, 0,
-				SNDRV_PCM_HW_PARAM_RATE,
-				&constraints_sample_rates);
-	if (ret)
-		pr_info("snd_pcm_hw_constraint_list failed\n");
-
-	ret = snd_pcm_hw_constraint_integer(runtime,
-					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret)
-		pr_info("snd_pcm_hw_constraint_integer failed\n");
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_pcm_hw_constraint_minmax(runtime,
-			SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-			SIO_PLAYBACK_MIN_BYTES,
-			SIO_PLAYBACK_MAX_BYTES);
-		if (ret) {
-			pr_info("%s: P buffer bytes minmax constraint ret %d\n",
-			       __func__, ret);
-		}
-	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		ret = snd_pcm_hw_constraint_minmax(runtime,
-			   SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-			   SIO_CAPTURE_MIN_BYTES,
-			   SIO_CAPTURE_MAX_BYTES);
-		if (ret) {
-			pr_info("%s: C buffer bytes minmax constraint ret %d\n",
-			       __func__, ret);
-		}
-	}
-
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
-	if (ret) {
-		pr_err("%s: Constraint for period bytes step ret = %d\n",
-				__func__, ret);
-	}
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
-	if (ret) {
-		pr_err("%s: Constraint for buffer bytes step ret = %d\n",
-				__func__, ret);
-	}
-	prtd->audio_client = q6asm_audio_client_alloc(
-				(app_cb)event_handler, prtd);
-	if (!prtd->audio_client) {
-		pr_err("%s: client alloc failed\n", __func__);
-		ret = -ENOMEM;
-		goto fail_cmd;
-	}
-	prtd->dsp_cnt = 0;
-	prtd->set_channel_map = false;
-	runtime->private_data = prtd;
-	return 0;
-
-fail_cmd:
-	kfree(prtd);
-	return ret;
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd = runtime->private_data;
-	struct msm_plat_data *pdata;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct audio_buffer *buf;
-	struct shared_io_config config;
-	uint16_t sample_word_size;
-	uint16_t bits_per_sample;
-	int ret;
-	int dir = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? IN : OUT;
-	unsigned long topology;
-	int perf_mode;
-
-	pdata = (struct msm_plat_data *)
-		dev_get_drvdata(soc_prtd->platform->dev);
-	if (!pdata) {
-		ret = -EINVAL;
-		pr_err("%s: platform data not populated ret: %d\n", __func__,
-		       ret);
-		return ret;
-	}
-
-	topology = msm_pcm_fe_topology[soc_prtd->dai_link->id];
-
-	if (!strcmp(msm_pcm_fe_topology_text[topology], "ULL_PP"))
-		perf_mode = ULL_POST_PROCESSING_PCM_MODE;
-	else if (!strcmp(msm_pcm_fe_topology_text[topology], "ULL"))
-		perf_mode = ULTRA_LOW_LATENCY_PCM_MODE;
-	else if (!strcmp(msm_pcm_fe_topology_text[topology], "LL"))
-		perf_mode = LOW_LATENCY_PCM_MODE;
-	else
-		/* use the default from the device tree */
-		perf_mode = pdata->perf_mode;
-
-
-	/* need to set LOW_LATENCY_PCM_MODE for capture since
-	 * push mode does not support ULL
-	 */
-	prtd->audio_client->perf_mode = (dir == IN) ?
-					perf_mode :
-					LOW_LATENCY_PCM_MODE;
-
-	/* rate and channels are sent to audio driver */
-	prtd->samp_rate = params_rate(params);
-	prtd->channel_mode = params_channels(params);
-	if (prtd->enabled)
-		return 0;
-
-	switch (runtime->format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bits_per_sample = 24;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		bits_per_sample = 24;
-		sample_word_size = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bits_per_sample = 16;
-		sample_word_size = 16;
-		break;
-	}
-
-	config.format = FORMAT_LINEAR_PCM;
-	config.bits_per_sample = bits_per_sample;
-	config.rate = params_rate(params);
-	config.channels = params_channels(params);
-	config.sample_word_size = sample_word_size;
-	config.bufsz = params_buffer_bytes(params) / params_periods(params);
-	config.bufcnt = params_periods(params);
-
-	ret = q6asm_open_shared_io(prtd->audio_client, &config, dir);
-	if (ret) {
-		pr_err("%s: q6asm_open_write_shared_io failed ret: %d\n",
-		       __func__, ret);
-		return ret;
-	}
-
-	prtd->pcm_size = params_buffer_bytes(params);
-	prtd->pcm_count = params_buffer_bytes(params);
-	prtd->pcm_irq_pos = 0;
-
-	buf = prtd->audio_client->port[dir].buf;
-	dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-	dma_buf->dev.dev = substream->pcm->card->dev;
-	dma_buf->private_data = NULL;
-	dma_buf->area = buf->data;
-	dma_buf->addr = buf->phys;
-	dma_buf->bytes = prtd->pcm_size;
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
-	pr_debug("%s: session ID %d, perf %d\n", __func__,
-	       prtd->audio_client->session,
-		prtd->audio_client->perf_mode);
-	prtd->session_id = prtd->audio_client->session;
-
-	pr_debug("msm_pcm_routing_reg_phy_stream w/ id %d\n",
-		 soc_prtd->dai_link->id);
-	ret = msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->id,
-				       prtd->audio_client->perf_mode,
-				       prtd->session_id, substream->stream);
-
-	if (ret) {
-		pr_err("%s: stream reg failed ret:%d\n", __func__, ret);
-		return ret;
-	}
-
-	atomic_set(&prtd->out_count, runtime->periods);
-	prtd->enabled = 1;
-	prtd->cmd_pending = 0;
-	prtd->cmd_interrupt = 0;
-
-	return 0;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	int dir = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1;
-	struct audio_buffer *buf;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		pr_debug("%s: %s Trigger start\n", __func__,
-			 dir == 0 ? "P" : "C");
-		ret = q6asm_run(prtd->audio_client, 0, 0, 0);
-		if (ret)
-			break;
-		atomic_set(&prtd->start, 1);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("%s: SNDRV_PCM_TRIGGER_STOP\n", __func__);
-		atomic_set(&prtd->start, 0);
-		q6asm_cmd(prtd->audio_client, CMD_PAUSE);
-		q6asm_cmd(prtd->audio_client, CMD_FLUSH);
-		buf = q6asm_shared_io_buf(prtd->audio_client, dir);
-		if (buf == NULL) {
-			pr_err("%s: shared IO buffer is null\n", __func__);
-			ret = -EINVAL;
-			break;
-		}
-		memset(buf->data, 0, buf->actual_size);
-		break;
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		pr_debug("%s: SNDRV_PCM_TRIGGER_PAUSE\n", __func__);
-		ret = q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE);
-		atomic_set(&prtd->start, 0);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-	return ret;
-}
-
-
-static int msm_pcm_mmap_fd(struct snd_pcm_substream *substream,
-			   struct snd_pcm_mmap_fd *mmap_fd)
-{
-	struct msm_audio *prtd;
-	struct audio_port_data *apd;
-	struct audio_buffer *ab;
-	int dir = -1;
-
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return -EFAULT;
-	}
-
-	prtd = substream->runtime->private_data;
-	if (!prtd || !prtd->audio_client || !prtd->mmap_flag) {
-		pr_err("%s no audio client or not an mmap session\n", __func__);
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-
-	apd = prtd->audio_client->port;
-	ab = &(apd[dir].buf[0]);
-	mmap_fd->fd = ion_share_dma_buf_fd(ab->client, ab->handle);
-	if (mmap_fd->fd >= 0) {
-		mmap_fd->dir = dir;
-		mmap_fd->actual_size = ab->actual_size;
-		mmap_fd->size = ab->size;
-	}
-	return mmap_fd->fd < 0 ? -EFAULT : 0;
-}
-
-static int msm_pcm_ioctl(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	int dir = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1;
-	struct audio_buffer *buf;
-
-	switch (cmd) {
-	case SNDRV_PCM_IOCTL1_RESET:
-		pr_debug("%s: %s SNDRV_PCM_IOCTL1_RESET\n", __func__,
-		       dir == 0 ? "P" : "C");
-		buf = q6asm_shared_io_buf(prtd->audio_client, dir);
-
-		if (buf && buf->data)
-			memset(buf->data, 0, buf->actual_size);
-		break;
-	default:
-		break;
-	}
-
-	return snd_pcm_lib_ioctl(substream, cmd, arg);
-}
-
-#ifdef CONFIG_COMPAT
-static int msm_pcm_compat_ioctl(struct snd_pcm_substream *substream,
-				unsigned int cmd, void *arg)
-{
-	/* we only handle RESET which is common for both modes */
-	return msm_pcm_ioctl(substream, cmd, arg);
-}
-#endif
-
-static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	uint32_t read_index, wall_clk_msw, wall_clk_lsw;
-	/*these are offsets, unlike ASoC's full values*/
-	snd_pcm_sframes_t hw_ptr;
-	snd_pcm_sframes_t period_size;
-	int ret;
-	int retries = 10;
-	struct msm_audio *prtd = runtime->private_data;
-
-	period_size = runtime->period_size;
-
-	do {
-		ret = q6asm_get_shared_pos(prtd->audio_client,
-					   &read_index, &wall_clk_msw,
-					   &wall_clk_lsw);
-	} while (ret == -EAGAIN && --retries);
-
-	if (ret || !period_size) {
-		pr_err("get_shared_pos error or zero period size\n");
-		return 0;
-	}
-
-	hw_ptr = bytes_to_frames(substream->runtime,
-				 read_index);
-
-	if (runtime->control->appl_ptr == 0) {
-		pr_debug("ptr(%s): appl(0), hw = %lu read_index = %u\n",
-			 prtd->substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-			 "P" : "C",
-			 hw_ptr, read_index);
-	}
-	return (hw_ptr/period_size) * period_size;
-}
-
-static int msm_pcm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	return -EINVAL;
-}
-
-static int msm_pcm_mmap(struct snd_pcm_substream *substream,
-				struct vm_area_struct *vma)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	struct audio_client *ac = prtd->audio_client;
-	struct audio_port_data *apd = ac->port;
-	struct audio_buffer *ab;
-	int dir = -1;
-	int ret;
-
-	pr_debug("%s: mmap begin\n", __func__);
-	prtd->mmap_flag = 1;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-
-	ab = &(apd[dir].buf[0]);
-
-	ret = msm_audio_ion_mmap(ab, vma);
-
-	if (ret)
-		prtd->mmap_flag = 0;
-
-	return ret;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-
-	if (!prtd || !prtd->mmap_flag)
-		return -EIO;
-
-	return 0;
-}
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd = runtime->private_data;
-	struct audio_client *ac = prtd->audio_client;
-	uint32_t timeout;
-	int dir = 0;
-	int ret = 0;
-
-	if (ac) {
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-			dir = IN;
-		else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			dir = OUT;
-
-		/* determine timeout length */
-		if (runtime->frame_bits == 0 || runtime->rate == 0) {
-			timeout = CMD_EOS_MIN_TIMEOUT_LENGTH;
-		} else {
-			timeout = (runtime->period_size *
-					CMD_EOS_TIMEOUT_MULTIPLIER) /
-					((runtime->frame_bits / 8) *
-					 runtime->rate);
-			if (timeout < CMD_EOS_MIN_TIMEOUT_LENGTH)
-				timeout = CMD_EOS_MIN_TIMEOUT_LENGTH;
-		}
-
-		q6asm_cmd(ac, CMD_CLOSE);
-
-		ret = q6asm_shared_io_free(ac, dir);
-
-		if (ret) {
-			pr_err("%s: Failed to close pull mode, ret %d\n",
-					__func__, ret);
-		}
-		q6asm_audio_client_free(ac);
-	}
-	msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->id,
-					 dir == IN ?
-					 SNDRV_PCM_STREAM_PLAYBACK :
-					 SNDRV_PCM_STREAM_CAPTURE);
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_pcm_set_volume(struct msm_audio *prtd, uint32_t volume)
-{
-	int rc = 0;
-
-	if (prtd && prtd->audio_client) {
-		pr_debug("%s: channels %d volume 0x%x\n", __func__,
-				prtd->channel_mode, volume);
-		rc = q6asm_set_volume(prtd->audio_client, volume);
-		if (rc < 0) {
-			pr_err("%s: Send Volume command failed rc=%d\n",
-					__func__, rc);
-		}
-	}
-	return rc;
-}
-
-static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
-		      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
-	struct snd_pcm_substream *substream =
-		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s\n", __func__);
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -ENODEV;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd)
-		ucontrol->value.integer.value[0] = prtd->volume;
-	return 0;
-}
-
-static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
-	struct snd_pcm_substream *substream =
-		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	struct msm_audio *prtd;
-	int volume = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: volume : 0x%x\n", __func__, volume);
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -ENODEV;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd) {
-		rc = msm_pcm_set_volume(prtd, volume);
-		prtd->volume = volume;
-	}
-	return rc;
-}
-
-static int msm_pcm_add_volume_control(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_volume *volume_info;
-	struct snd_kcontrol *kctl;
-
-	dev_dbg(rtd->dev, "%s, Volume control add\n", __func__);
-	ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-			NULL, 1, rtd->dai_link->id,
-			&volume_info);
-	if (ret < 0) {
-		pr_err("%s volume control failed ret %d\n", __func__, ret);
-		return ret;
-	}
-	kctl = volume_info->kctl;
-	kctl->put = msm_pcm_volume_ctl_put;
-	kctl->get = msm_pcm_volume_ctl_get;
-	kctl->tlv.p = msm_pcm_vol_gain;
-	return 0;
-}
-
-static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s", __func__);
-	substream = snd_pcm_chmap_substream(info, idx);
-	if (!substream)
-		return -ENODEV;
-	if (!substream->runtime)
-		return 0;
-
-	prtd = substream->runtime->private_data;
-	if (prtd) {
-		prtd->set_channel_map = true;
-			for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-				prtd->channel_map[i] =
-				(char)(ucontrol->value.integer.value[i]);
-	}
-	return 0;
-}
-
-static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s", __func__);
-	substream = snd_pcm_chmap_substream(info, idx);
-	if (!substream)
-		return -ENODEV;
-	memset(ucontrol->value.integer.value, 0,
-		sizeof(ucontrol->value.integer.value));
-	if (!substream->runtime)
-		return 0; /* no channels set */
-
-	prtd = substream->runtime->private_data;
-
-	if (prtd && prtd->set_channel_map == true) {
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			ucontrol->value.integer.value[i] =
-					(int)prtd->channel_map[i];
-	} else {
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			ucontrol->value.integer.value[i] = 0;
-	}
-
-	return 0;
-}
-
-static int msm_pcm_add_chmap_control(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_chmap *chmap_info;
-	struct snd_kcontrol *kctl;
-	char device_num[12];
-	int i, ret;
-
-	pr_debug("%s, Channel map cntrl add\n", __func__);
-	ret = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-				     snd_pcm_std_chmaps,
-				     PCM_FORMAT_MAX_NUM_CHANNEL, 0,
-				     &chmap_info);
-	if (ret)
-		return ret;
-
-	kctl = chmap_info->kctl;
-	for (i = 0; i < kctl->count; i++)
-		kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE;
-	snprintf(device_num, sizeof(device_num), "%d", pcm->device);
-	strlcat(kctl->id.name, device_num, sizeof(kctl->id.name));
-	pr_debug("%s, Overwriting channel map control name to: %s",
-		__func__, kctl->id.name);
-	kctl->put = msm_pcm_chmap_ctl_put;
-	kctl->get = msm_pcm_chmap_ctl_get;
-	return 0;
-}
-
-static int msm_pcm_fe_topology_info(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_info *uinfo)
-{
-	const struct soc_enum *e = &msm_pcm_fe_topology_enum[0];
-
-	return snd_ctl_enum_info(uinfo, 1, e->items, e->texts);
-}
-
-static int msm_pcm_fe_topology_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	unsigned long fe_id = kcontrol->private_value;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bound fe_id %lu\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: %lu topology %s\n", __func__, fe_id,
-		 msm_pcm_fe_topology_text[msm_pcm_fe_topology[fe_id]]);
-	ucontrol->value.enumerated.item[0] = msm_pcm_fe_topology[fe_id];
-	return 0;
-}
-
-static int msm_pcm_fe_topology_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	unsigned long fe_id = kcontrol->private_value;
-	unsigned int item;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bound fe_id %lu\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	item = ucontrol->value.enumerated.item[0];
-	if (item >= ARRAY_SIZE(msm_pcm_fe_topology_text)) {
-		pr_err("%s Received out of bound topology %lu\n", __func__,
-		       fe_id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: %lu new topology %s\n", __func__, fe_id,
-		 msm_pcm_fe_topology_text[item]);
-	msm_pcm_fe_topology[fe_id] = item;
-	return 0;
-}
-
-static int msm_pcm_add_fe_topology_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "PCM_Dev";
-	const char *deviceNo       = "NN";
-	const char *topo_text      = "Topology";
-	char *mixer_str = NULL;
-	int ctl_len;
-	int ret;
-	struct snd_kcontrol_new topology_control[1] = {
-		{
-			.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-			.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-			.name =  "?",
-			.info =  msm_pcm_fe_topology_info,
-			.get = msm_pcm_fe_topology_get,
-			.put = msm_pcm_fe_topology_put,
-			.private_value = 0,
-		},
-	};
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1 +
-		  strlen(topo_text) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return -ENOMEM;
-
-	snprintf(mixer_str, ctl_len, "%s %d %s", mixer_ctl_name,
-		 rtd->pcm->device, topo_text);
-
-	topology_control[0].name = mixer_str;
-	topology_control[0].private_value = rtd->dai_link->id;
-	ret = snd_soc_add_platform_controls(rtd->platform, topology_control,
-					    ARRAY_SIZE(topology_control));
-	msm_pcm_fe_topology[rtd->dai_link->id] = 0;
-	kfree(mixer_str);
-	return ret;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-		       __func__, ret);
-	return ret;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-		       __func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-		       __func__, ret);
-
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-		       __func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_usr *app_type_info;
-	struct snd_kcontrol *kctl;
-	const char *playback_mixer_ctl_name = "Audio Stream";
-	const char *capture_mixer_ctl_name = "Audio Stream Capture";
-	const char *deviceNo = "NN";
-	const char *suffix = "App Type Cfg";
-	int ctl_len, ret = 0;
-
-	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
-		ctl_len = strlen(playback_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 +
-				strlen(suffix) + 1;
-		pr_debug("%s: Playback app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-				NULL, 1, ctl_len, rtd->dai_link->id,
-				&app_type_info);
-		if (ret < 0) {
-			pr_err("%s: playback app type cntrl add failed, err: %d\n",
-				__func__, ret);
-			return ret;
-		}
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-			     playback_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_playback_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_playback_app_type_cfg_ctl_get;
-	}
-
-	if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
-		ctl_len = strlen(capture_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 + strlen(suffix) + 1;
-		pr_debug("%s: Capture app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
-				NULL, 1, ctl_len, rtd->dai_link->id,
-				&app_type_info);
-		if (ret < 0) {
-			pr_err("%s: capture app type cntrl add failed, err: %d\n",
-				__func__, ret);
-			return ret;
-		}
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-		 capture_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_capture_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_capture_app_type_cfg_ctl_get;
-	}
-
-	return 0;
-}
-
-static int msm_pcm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
-			       unsigned int cmd, unsigned long arg)
-{
-	int ret = 0;
-	struct snd_pcm *pcm = hw->private_data;
-	struct snd_pcm_mmap_fd __user *_mmap_fd = NULL;
-	struct snd_pcm_mmap_fd mmap_fd;
-	struct snd_pcm_substream *substream = NULL;
-	int32_t dir = -1;
-
-	switch (cmd) {
-	case SNDRV_PCM_IOCTL_MMAP_DATA_FD:
-		_mmap_fd = (struct snd_pcm_mmap_fd __user *)arg;
-		if (get_user(dir, (int32_t __user *)&(_mmap_fd->dir))) {
-			pr_err("%s: error copying mmap_fd from user\n",
-			       __func__);
-			ret = -EFAULT;
-			break;
-		}
-		if (dir != OUT && dir != IN) {
-			pr_err("%s invalid stream dir\n", __func__);
-			ret = -EINVAL;
-			break;
-		}
-		substream = pcm->streams[dir].substream;
-		if (!substream) {
-			pr_err("%s substream not found\n", __func__);
-			ret = -ENODEV;
-			break;
-		}
-		pr_debug("%s : %s MMAP Data fd\n", __func__,
-		       dir == 0 ? "P" : "C");
-		if (msm_pcm_mmap_fd(substream, &mmap_fd) < 0) {
-			pr_err("%s: error getting fd\n",
-			       __func__);
-			ret = -EFAULT;
-			break;
-		}
-		if (put_user(mmap_fd.fd, &_mmap_fd->fd) ||
-		    put_user(mmap_fd.size, &_mmap_fd->size) ||
-		    put_user(mmap_fd.actual_size, &_mmap_fd->actual_size)) {
-			pr_err("%s: error copying fd\n", __func__);
-			return -EFAULT;
-		}
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-	return ret;
-}
-
-#ifdef CONFIG_COMPAT
-static int msm_pcm_hwdep_compat_ioctl(struct snd_hwdep *hw,
-				      struct file *file,
-				      unsigned int cmd,
-				      unsigned long arg)
-{
-	/* we only support mmap fd. Handling is common in both modes */
-	return msm_pcm_hwdep_ioctl(hw, file, cmd, arg);
-}
-#else
-static int msm_pcm_hwdep_compat_ioctl(struct snd_hwdep *hw,
-				      struct file *file,
-				      unsigned int cmd,
-				      unsigned long arg)
-{
-	return -EINVAL;
-}
-#endif
-
-static int msm_pcm_add_hwdep_dev(struct snd_soc_pcm_runtime *runtime)
-{
-	struct snd_hwdep *hwdep;
-	int rc;
-	char id[] = "NOIRQ_NN";
-
-	snprintf(id, sizeof(id), "NOIRQ_%d", runtime->pcm->device);
-	pr_debug("%s: pcm dev %d\n", __func__, runtime->pcm->device);
-	rc = snd_hwdep_new(runtime->card->snd_card,
-			   &id[0],
-			   HWDEP_FE_BASE + runtime->pcm->device,
-			   &hwdep);
-	if (!hwdep || rc < 0) {
-		pr_err("%s: hwdep intf failed to create %s - hwdep\n", __func__,
-		       id);
-		return rc;
-	}
-
-	hwdep->iface = SNDRV_HWDEP_IFACE_AUDIO_BE; /* for lack of a FE iface */
-	hwdep->private_data = runtime->pcm; /* of type struct snd_pcm */
-	hwdep->ops.ioctl = msm_pcm_hwdep_ioctl;
-	hwdep->ops.ioctl_compat = msm_pcm_hwdep_compat_ioctl;
-	return 0;
-}
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	struct snd_pcm *pcm = rtd->pcm;
-	int ret;
-
-	pr_debug("%s , register new control\n", __func__);
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	ret = msm_pcm_add_chmap_control(rtd);
-	if (ret) {
-		pr_err("%s failed to add chmap cntls\n", __func__);
-		goto exit;
-	}
-	ret = msm_pcm_add_volume_control(rtd);
-	if (ret) {
-		pr_err("%s: Could not add pcm Volume Control %d\n",
-			__func__, ret);
-	}
-
-	ret = msm_pcm_add_fe_topology_control(rtd);
-	if (ret) {
-		pr_err("%s: Could not add pcm topology control %d\n",
-			__func__, ret);
-	}
-
-	ret = msm_pcm_add_app_type_controls(rtd);
-	if (ret) {
-		pr_err("%s: Could not add app type controls failed %d\n",
-			__func__, ret);
-	}
-	ret = msm_pcm_add_hwdep_dev(rtd);
-	if (ret)
-		pr_err("%s: Could not add hw dep node\n", __func__);
-	pcm->nonatomic = true;
-exit:
-	return ret;
-}
-
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.prepare        = msm_pcm_prepare,
-	.copy           = msm_pcm_copy,
-	.hw_params	= msm_pcm_hw_params,
-	.ioctl          = msm_pcm_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl   = msm_pcm_compat_ioctl,
-#endif
-	.trigger        = msm_pcm_trigger,
-	.pointer        = msm_pcm_pointer,
-	.mmap           = msm_pcm_mmap,
-	.close          = msm_pcm_close,
-};
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	int rc;
-	struct msm_plat_data *pdata;
-	const char *latency_level;
-	int perf_mode = LOW_LATENCY_PCM_MODE;
-
-	dev_dbg(&pdev->dev, "Pull mode driver probe\n");
-
-	if (of_property_read_bool(pdev->dev.of_node,
-				  "qcom,msm-pcm-low-latency")) {
-
-		rc = of_property_read_string(pdev->dev.of_node,
-			"qcom,latency-level", &latency_level);
-		if (!rc) {
-			if (!strcmp(latency_level, "ultra"))
-				perf_mode = ULTRA_LOW_LATENCY_PCM_MODE;
-			else if (!strcmp(latency_level, "ull-pp"))
-				perf_mode = ULL_POST_PROCESSING_PCM_MODE;
-		}
-	}
-
-	pdata = devm_kzalloc(&pdev->dev,
-			     sizeof(struct msm_plat_data), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	pdata->perf_mode = perf_mode;
-
-	dev_set_drvdata(&pdev->dev, pdata);
-
-	dev_dbg(&pdev->dev, "%s: dev name %s\n",
-				__func__, dev_name(&pdev->dev));
-	dev_dbg(&pdev->dev, "Pull mode driver register\n");
-	rc = snd_soc_register_platform(&pdev->dev,
-				       &msm_soc_platform);
-
-	if (rc)
-		dev_err(&pdev->dev, "Failed to register pull mode driver\n");
-
-	return rc;
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	struct msm_plat_data *pdata;
-
-	dev_dbg(&pdev->dev, "Pull mode remove\n");
-	pdata = dev_get_drvdata(&pdev->dev);
-	devm_kfree(&pdev->dev, pdata);
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-static const struct of_device_id msm_pcm_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-dsp-noirq"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_pcm_dt_match);
-
-static struct platform_driver msm_pcm_driver_noirq = {
-	.driver = {
-		.name = "msm-pcm-dsp-noirq",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	return platform_driver_register(&msm_pcm_driver_noirq);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver_noirq);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("PCM NOIRQ module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
deleted file mode 100644
index 74e99d3..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ /dev/null
@@ -1,1884 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6audio-v2.h>
-#include <sound/timer.h>
-#include <asm/dma.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/msm_audio.h>
-
-#include <linux/of_device.h>
-#include <sound/tlv.h>
-#include <sound/pcm_params.h>
-
-#include "msm-pcm-q6-v2.h"
-#include "msm-pcm-routing-v2.h"
-#include "msm-qti-pp-config.h"
-
-enum stream_state {
-	IDLE = 0,
-	STOPPED,
-	RUNNING,
-};
-
-static struct audio_locks the_locks;
-
-#define PCM_MASTER_VOL_MAX_STEPS	0x2000
-static const DECLARE_TLV_DB_LINEAR(msm_pcm_vol_gain, 0,
-			PCM_MASTER_VOL_MAX_STEPS);
-
-struct snd_msm {
-	struct snd_card *card;
-	struct snd_pcm *pcm;
-};
-
-#define CMD_EOS_MIN_TIMEOUT_LENGTH  50
-#define CMD_EOS_TIMEOUT_MULTIPLIER  (HZ * 50)
-#define MAX_PB_COPY_RETRIES         3
-
-static struct snd_pcm_hardware msm_pcm_hardware_capture = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
-	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE |
-				SNDRV_PCM_FMTBIT_S32_LE),
-	.rates =                SNDRV_PCM_RATE_8000_384000,
-	.rate_min =             8000,
-	.rate_max =             384000,
-	.channels_min =         1,
-	.channels_max =         4,
-	.buffer_bytes_max =     CAPTURE_MAX_NUM_PERIODS *
-				CAPTURE_MAX_PERIOD_SIZE,
-	.period_bytes_min =	CAPTURE_MIN_PERIOD_SIZE,
-	.period_bytes_max =     CAPTURE_MAX_PERIOD_SIZE,
-	.periods_min =          CAPTURE_MIN_NUM_PERIODS,
-	.periods_max =          CAPTURE_MAX_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-static struct snd_pcm_hardware msm_pcm_hardware_playback = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
-	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_S24_LE |
-				SNDRV_PCM_FMTBIT_S24_3LE |
-				SNDRV_PCM_FMTBIT_S32_LE),
-	.rates =                SNDRV_PCM_RATE_8000_384000,
-	.rate_min =             8000,
-	.rate_max =             384000,
-	.channels_min =         1,
-	.channels_max =         8,
-	.buffer_bytes_max =     PLAYBACK_MAX_NUM_PERIODS *
-				PLAYBACK_MAX_PERIOD_SIZE,
-	.period_bytes_min =	PLAYBACK_MIN_PERIOD_SIZE,
-	.period_bytes_max =     PLAYBACK_MAX_PERIOD_SIZE,
-	.periods_min =          PLAYBACK_MIN_NUM_PERIODS,
-	.periods_max =          PLAYBACK_MAX_NUM_PERIODS,
-	.fifo_size =            0,
-};
-
-/* Conventional and unconventional sample rate supported */
-static unsigned int supported_sample_rates[] = {
-	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
-	88200, 96000, 176400, 192000, 352800, 384000
-};
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event,
-					void *priv_data)
-{
-	struct msm_audio *prtd = priv_data;
-
-	WARN_ON(!prtd);
-
-	pr_debug("%s: event %x\n", __func__, event);
-
-	switch (event) {
-	case MSM_PCM_RT_EVT_BUF_RECFG:
-		q6asm_cmd(prtd->audio_client, CMD_PAUSE);
-		q6asm_cmd(prtd->audio_client, CMD_FLUSH);
-		q6asm_run(prtd->audio_client, 0, 0, 0);
-		/* fallthrough */
-	default:
-		break;
-	}
-}
-
-static void event_handler(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv)
-{
-	struct msm_audio *prtd = priv;
-	struct snd_pcm_substream *substream = prtd->substream;
-	uint32_t *ptrmem = (uint32_t *)payload;
-	uint32_t idx = 0;
-	uint32_t size = 0;
-	uint8_t buf_index;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-
-	switch (opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2: {
-		pr_debug("ASM_DATA_EVENT_WRITE_DONE_V2\n");
-		pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem);
-		prtd->pcm_irq_pos += prtd->pcm_count;
-		if (atomic_read(&prtd->start))
-			snd_pcm_period_elapsed(substream);
-		atomic_inc(&prtd->out_count);
-		wake_up(&the_locks.write_wait);
-		if (!atomic_read(&prtd->start))
-			break;
-		if (!prtd->mmap_flag || prtd->reset_event)
-			break;
-		if (q6asm_is_cpu_buf_avail_nolock(IN,
-				prtd->audio_client,
-				&size, &idx)) {
-			pr_debug("%s:writing %d bytes of buffer to dsp 2\n",
-					__func__, prtd->pcm_count);
-			q6asm_write_nolock(prtd->audio_client,
-				prtd->pcm_count, 0, 0, NO_TIMESTAMP);
-		}
-		break;
-	}
-	case ASM_DATA_EVENT_RENDERED_EOS:
-		pr_debug("ASM_DATA_EVENT_RENDERED_EOS\n");
-		clear_bit(CMD_EOS, &prtd->cmd_pending);
-		wake_up(&the_locks.eos_wait);
-		break;
-	case ASM_DATA_EVENT_READ_DONE_V2: {
-		pr_debug("ASM_DATA_EVENT_READ_DONE_V2\n");
-		buf_index = q6asm_get_buf_index_from_token(token);
-		pr_debug("%s: token=0x%08x buf_index=0x%08x\n",
-			 __func__, token, buf_index);
-		prtd->in_frame_info[buf_index].size = payload[4];
-		prtd->in_frame_info[buf_index].offset = payload[5];
-		/* assume data size = 0 during flushing */
-		if (prtd->in_frame_info[buf_index].size) {
-			prtd->pcm_irq_pos +=
-				prtd->in_frame_info[buf_index].size;
-			pr_debug("pcm_irq_pos=%d\n", prtd->pcm_irq_pos);
-			if (atomic_read(&prtd->start))
-				snd_pcm_period_elapsed(substream);
-			if (atomic_read(&prtd->in_count) <= prtd->periods)
-				atomic_inc(&prtd->in_count);
-			wake_up(&the_locks.read_wait);
-			if (prtd->mmap_flag &&
-			    q6asm_is_cpu_buf_avail_nolock(OUT,
-				prtd->audio_client,
-				&size, &idx) &&
-			    (substream->runtime->status->state ==
-			     SNDRV_PCM_STATE_RUNNING))
-				q6asm_read_nolock(prtd->audio_client);
-		} else {
-			pr_debug("%s: reclaim flushed buf in_count %x\n",
-				__func__, atomic_read(&prtd->in_count));
-			prtd->pcm_irq_pos += prtd->pcm_count;
-			if (prtd->mmap_flag) {
-				if (q6asm_is_cpu_buf_avail_nolock(OUT,
-				    prtd->audio_client,
-				    &size, &idx) &&
-				    (substream->runtime->status->state ==
-				    SNDRV_PCM_STATE_RUNNING))
-					q6asm_read_nolock(prtd->audio_client);
-			} else {
-				atomic_inc(&prtd->in_count);
-			}
-			if (atomic_read(&prtd->in_count) == prtd->periods) {
-				pr_info("%s: reclaimed all bufs\n", __func__);
-				if (atomic_read(&prtd->start))
-					snd_pcm_period_elapsed(substream);
-				wake_up(&the_locks.read_wait);
-			}
-		}
-		break;
-	}
-	case ASM_STREAM_PP_EVENT:
-	case ASM_STREAM_CMD_ENCDEC_EVENTS: {
-		pr_debug("%s: ASM_STREAM_EVENT (0x%x)\n", __func__, opcode);
-		if (!substream) {
-			pr_err("%s: substream is NULL.\n", __func__);
-			return;
-		}
-
-		rtd = substream->private_data;
-		if (!rtd) {
-			pr_err("%s: rtd is NULL\n", __func__);
-			return;
-		}
-
-		ret = msm_adsp_inform_mixer_ctl(rtd, payload);
-		if (ret) {
-			pr_err("%s: failed to inform mixer ctl. err = %d\n",
-				__func__, ret);
-			return;
-		}
-
-		break;
-	}
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-		case ASM_SESSION_CMD_RUN_V2:
-			if (substream->stream
-				!= SNDRV_PCM_STREAM_PLAYBACK) {
-				atomic_set(&prtd->start, 1);
-				break;
-			}
-			if (prtd->mmap_flag) {
-				pr_debug("%s:writing %d bytes of buffer to dsp\n",
-					__func__,
-					prtd->pcm_count);
-				q6asm_write_nolock(prtd->audio_client,
-					prtd->pcm_count,
-					0, 0, NO_TIMESTAMP);
-			} else {
-				while (atomic_read(&prtd->out_needed)) {
-					pr_debug("%s:writing %d bytes of buffer to dsp\n",
-						__func__,
-						prtd->pcm_count);
-					q6asm_write_nolock(prtd->audio_client,
-						prtd->pcm_count,
-						0, 0, NO_TIMESTAMP);
-					atomic_dec(&prtd->out_needed);
-					wake_up(&the_locks.write_wait);
-				};
-			}
-			atomic_set(&prtd->start, 1);
-			break;
-		case ASM_STREAM_CMD_REGISTER_PP_EVENTS:
-			pr_debug("%s: ASM_STREAM_CMD_REGISTER_PP_EVENTS:",
-				__func__);
-			break;
-		default:
-			pr_debug("%s:Payload = [0x%x]stat[0x%x]\n",
-				__func__, payload[0], payload[1]);
-			break;
-		}
-	}
-	break;
-	case RESET_EVENTS:
-		pr_debug("%s RESET_EVENTS\n", __func__);
-		prtd->pcm_irq_pos += prtd->pcm_count;
-		atomic_inc(&prtd->out_count);
-		atomic_inc(&prtd->in_count);
-		prtd->reset_event = true;
-		if (atomic_read(&prtd->start))
-			snd_pcm_period_elapsed(substream);
-		wake_up(&the_locks.eos_wait);
-		wake_up(&the_locks.write_wait);
-		wake_up(&the_locks.read_wait);
-		break;
-	default:
-		pr_debug("Not Supported Event opcode[0x%x]\n", opcode);
-		break;
-	}
-}
-
-static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd = runtime->private_data;
-	struct msm_plat_data *pdata;
-	struct snd_pcm_hw_params *params;
-	int ret;
-	uint32_t fmt_type = FORMAT_LINEAR_PCM;
-	uint16_t bits_per_sample;
-	uint16_t sample_word_size;
-
-	pdata = (struct msm_plat_data *)
-		dev_get_drvdata(soc_prtd->platform->dev);
-	if (!pdata) {
-		pr_err("%s: platform data not populated\n", __func__);
-		return -EINVAL;
-	}
-	if (!prtd || !prtd->audio_client) {
-		pr_err("%s: private data null or audio client freed\n",
-			__func__);
-		return -EINVAL;
-	}
-	params = &soc_prtd->dpcm[substream->stream].hw_params;
-
-	pr_debug("%s\n", __func__);
-	prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream);
-	prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
-	prtd->pcm_irq_pos = 0;
-	/* rate and channels are sent to audio driver */
-	prtd->samp_rate = runtime->rate;
-	prtd->channel_mode = runtime->channels;
-	if (prtd->enabled)
-		return 0;
-
-	prtd->audio_client->perf_mode = pdata->perf_mode;
-	pr_debug("%s: perf: %x\n", __func__, pdata->perf_mode);
-
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		bits_per_sample = 32;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bits_per_sample = 24;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		bits_per_sample = 24;
-		sample_word_size = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bits_per_sample = 16;
-		sample_word_size = 16;
-		break;
-	}
-	if (prtd->compress_enable) {
-		fmt_type = FORMAT_GEN_COMPR;
-		pr_debug("%s: Compressed enabled!\n", __func__);
-		ret = q6asm_open_write_compressed(prtd->audio_client, fmt_type,
-				COMPRESSED_PASSTHROUGH_GEN);
-		if (ret < 0) {
-			pr_err("%s: q6asm_open_write_compressed failed (%d)\n",
-			__func__, ret);
-			q6asm_audio_client_free(prtd->audio_client);
-			prtd->audio_client = NULL;
-			return -ENOMEM;
-		}
-	} else {
-		ret = q6asm_open_write_v4(prtd->audio_client,
-			fmt_type, bits_per_sample);
-
-		if (ret < 0) {
-			pr_err("%s: q6asm_open_write_v4 failed (%d)\n",
-			__func__, ret);
-			q6asm_audio_client_free(prtd->audio_client);
-			prtd->audio_client = NULL;
-			return -ENOMEM;
-		}
-
-		ret = q6asm_send_cal(prtd->audio_client);
-		if (ret < 0)
-			pr_debug("%s : Send cal failed : %d", __func__, ret);
-	}
-	pr_debug("%s: session ID %d\n", __func__,
-			prtd->audio_client->session);
-	prtd->session_id = prtd->audio_client->session;
-
-	if (prtd->compress_enable) {
-		ret = msm_pcm_routing_reg_phy_compr_stream(
-				soc_prtd->dai_link->id,
-				prtd->audio_client->perf_mode,
-				prtd->session_id,
-				SNDRV_PCM_STREAM_PLAYBACK,
-				COMPRESSED_PASSTHROUGH_GEN);
-	} else {
-		ret = msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->id,
-			prtd->audio_client->perf_mode,
-			prtd->session_id, substream->stream);
-	}
-	if (ret) {
-		pr_err("%s: stream reg failed ret:%d\n", __func__, ret);
-		return ret;
-	}
-	if (prtd->compress_enable) {
-		ret = q6asm_media_format_block_gen_compr(
-			prtd->audio_client, runtime->rate,
-			runtime->channels, !prtd->set_channel_map,
-			prtd->channel_map, bits_per_sample);
-	} else {
-		ret = q6asm_media_format_block_multi_ch_pcm_v4(
-				prtd->audio_client, runtime->rate,
-				runtime->channels, !prtd->set_channel_map,
-				prtd->channel_map, bits_per_sample,
-				sample_word_size, ASM_LITTLE_ENDIAN,
-				DEFAULT_QF);
-	}
-	if (ret < 0)
-		pr_info("%s: CMD Format block failed\n", __func__);
-
-	atomic_set(&prtd->out_count, runtime->periods);
-
-	prtd->enabled = 1;
-	prtd->cmd_pending = 0;
-	prtd->cmd_interrupt = 0;
-
-	return 0;
-}
-
-static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_plat_data *pdata;
-	struct snd_pcm_hw_params *params;
-	struct msm_pcm_routing_evt event;
-	int ret = 0;
-	int i = 0;
-	uint16_t bits_per_sample = 16;
-	uint16_t sample_word_size;
-
-	pdata = (struct msm_plat_data *)
-		dev_get_drvdata(soc_prtd->platform->dev);
-	if (!pdata) {
-		pr_err("%s: platform data not populated\n", __func__);
-		return -EINVAL;
-	}
-	if (!prtd || !prtd->audio_client) {
-		pr_err("%s: private data null or audio client freed\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	if (prtd->enabled == IDLE) {
-		pr_debug("%s:perf_mode=%d periods=%d\n", __func__,
-			pdata->perf_mode, runtime->periods);
-		params = &soc_prtd->dpcm[substream->stream].hw_params;
-		if ((params_format(params) == SNDRV_PCM_FORMAT_S24_LE) ||
-			(params_format(params) == SNDRV_PCM_FORMAT_S24_3LE))
-			bits_per_sample = 24;
-		else if (params_format(params) == SNDRV_PCM_FORMAT_S32_LE)
-			bits_per_sample = 32;
-
-		/* ULL mode is not supported in capture path */
-		if (pdata->perf_mode == LEGACY_PCM_MODE)
-			prtd->audio_client->perf_mode = LEGACY_PCM_MODE;
-		else
-			prtd->audio_client->perf_mode = LOW_LATENCY_PCM_MODE;
-
-		pr_debug("%s Opening %d-ch PCM read stream, perf_mode %d\n",
-				__func__, params_channels(params),
-				prtd->audio_client->perf_mode);
-
-		ret = q6asm_open_read_v4(prtd->audio_client, FORMAT_LINEAR_PCM,
-				bits_per_sample, false);
-		if (ret < 0) {
-			pr_err("%s: q6asm_open_read failed\n", __func__);
-			q6asm_audio_client_free(prtd->audio_client);
-			prtd->audio_client = NULL;
-			return -ENOMEM;
-		}
-
-		ret = q6asm_send_cal(prtd->audio_client);
-		if (ret < 0)
-			pr_debug("%s : Send cal failed : %d", __func__, ret);
-
-		pr_debug("%s: session ID %d\n",
-				__func__, prtd->audio_client->session);
-		prtd->session_id = prtd->audio_client->session;
-		event.event_func = msm_pcm_route_event_handler;
-		event.priv_data = (void *) prtd;
-		ret = msm_pcm_routing_reg_phy_stream_v2(
-				soc_prtd->dai_link->id,
-				prtd->audio_client->perf_mode,
-				prtd->session_id, substream->stream,
-				event);
-		if (ret) {
-			pr_err("%s: stream reg failed ret:%d\n", __func__, ret);
-			return ret;
-		}
-	}
-
-	prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream);
-	prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
-	prtd->pcm_irq_pos = 0;
-	/* rate and channels are sent to audio driver */
-	prtd->samp_rate = runtime->rate;
-	prtd->channel_mode = runtime->channels;
-
-	if (prtd->enabled == IDLE || prtd->enabled == STOPPED) {
-		for (i = 0; i < runtime->periods; i++)
-			q6asm_read(prtd->audio_client);
-		prtd->periods = runtime->periods;
-	}
-
-	if (prtd->enabled != IDLE)
-		return 0;
-
-	switch (runtime->format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		bits_per_sample = 32;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bits_per_sample = 24;
-		sample_word_size = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		bits_per_sample = 24;
-		sample_word_size = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bits_per_sample = 16;
-		sample_word_size = 16;
-		break;
-	}
-
-	pr_debug("%s: Samp_rate = %d Channel = %d bit width = %d, word size = %d\n",
-			__func__, prtd->samp_rate, prtd->channel_mode,
-			bits_per_sample, sample_word_size);
-	ret = q6asm_enc_cfg_blk_pcm_format_support_v4(prtd->audio_client,
-						      prtd->samp_rate,
-						      prtd->channel_mode,
-						      bits_per_sample,
-						      sample_word_size,
-						      ASM_LITTLE_ENDIAN,
-						      DEFAULT_QF);
-	if (ret < 0)
-		pr_debug("%s: cmd cfg pcm was block failed", __func__);
-
-	prtd->enabled = RUNNING;
-
-	return ret;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		pr_debug("%s: Trigger start\n", __func__);
-		ret = q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("SNDRV_PCM_TRIGGER_STOP\n");
-		atomic_set(&prtd->start, 0);
-		if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) {
-			prtd->enabled = STOPPED;
-			ret = q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE);
-			break;
-		}
-		/* pending CMD_EOS isn't expected */
-		WARN_ON_ONCE(test_bit(CMD_EOS, &prtd->cmd_pending));
-		set_bit(CMD_EOS, &prtd->cmd_pending);
-		ret = q6asm_cmd_nowait(prtd->audio_client, CMD_EOS);
-		if (ret)
-			clear_bit(CMD_EOS, &prtd->cmd_pending);
-		break;
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n");
-		ret = q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE);
-		atomic_set(&prtd->start, 0);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd;
-	int ret = 0;
-
-	prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL);
-	if (prtd == NULL)
-		return -ENOMEM;
-
-	prtd->substream = substream;
-	prtd->audio_client = q6asm_audio_client_alloc(
-				(app_cb)event_handler, prtd);
-	if (!prtd->audio_client) {
-		pr_info("%s: Could not allocate memory\n", __func__);
-		kfree(prtd);
-		return -ENOMEM;
-	}
-
-	prtd->audio_client->dev = soc_prtd->platform->dev;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		runtime->hw = msm_pcm_hardware_playback;
-
-	/* Capture path */
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		runtime->hw = msm_pcm_hardware_capture;
-	else {
-		pr_err("Invalid Stream type %d\n", substream->stream);
-		return -EINVAL;
-	}
-
-	ret = snd_pcm_hw_constraint_list(runtime, 0,
-				SNDRV_PCM_HW_PARAM_RATE,
-				&constraints_sample_rates);
-	if (ret < 0)
-		pr_info("snd_pcm_hw_constraint_list failed\n");
-	/* Ensure that buffer size is a multiple of period size */
-	ret = snd_pcm_hw_constraint_integer(runtime,
-					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
-		pr_info("snd_pcm_hw_constraint_integer failed\n");
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_pcm_hw_constraint_minmax(runtime,
-			SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-			PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE,
-			PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE);
-		if (ret < 0) {
-			pr_err("constraint for buffer bytes min max ret = %d\n",
-									ret);
-		}
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		ret = snd_pcm_hw_constraint_minmax(runtime,
-			SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-			CAPTURE_MIN_NUM_PERIODS * CAPTURE_MIN_PERIOD_SIZE,
-			CAPTURE_MAX_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE);
-		if (ret < 0) {
-			pr_err("constraint for buffer bytes min max ret = %d\n",
-									ret);
-		}
-	}
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
-	if (ret < 0) {
-		pr_err("constraint for period bytes step ret = %d\n",
-								ret);
-	}
-	ret = snd_pcm_hw_constraint_step(runtime, 0,
-		SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
-	if (ret < 0) {
-		pr_err("constraint for buffer bytes step ret = %d\n",
-								ret);
-	}
-
-	prtd->enabled = IDLE;
-	prtd->dsp_cnt = 0;
-	prtd->set_channel_map = false;
-	prtd->reset_event = false;
-	runtime->private_data = prtd;
-	msm_adsp_init_mixer_ctl_pp_event_queue(soc_prtd);
-
-	return 0;
-}
-
-static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
-	snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	int fbytes = 0;
-	int xfer = 0;
-	char *bufptr = NULL;
-	void *data = NULL;
-	uint32_t idx = 0;
-	uint32_t size = 0;
-	uint32_t retries = 0;
-
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-
-	fbytes = frames_to_bytes(runtime, frames);
-	pr_debug("%s: prtd->out_count = %d\n",
-				__func__, atomic_read(&prtd->out_count));
-
-	while ((fbytes > 0) && (retries < MAX_PB_COPY_RETRIES)) {
-		if (prtd->reset_event) {
-			pr_err("%s: In SSR return ENETRESET before wait\n",
-				__func__);
-			return -ENETRESET;
-		}
-
-		ret = wait_event_timeout(the_locks.write_wait,
-				(atomic_read(&prtd->out_count)), 5 * HZ);
-		if (!ret) {
-			pr_err("%s: wait_event_timeout failed\n", __func__);
-			ret = -ETIMEDOUT;
-			goto fail;
-		}
-		ret = 0;
-
-		if (prtd->reset_event) {
-			pr_err("%s: In SSR return ENETRESET after wait\n",
-				__func__);
-			return -ENETRESET;
-		}
-
-		if (!atomic_read(&prtd->out_count)) {
-			pr_err("%s: pcm stopped out_count 0\n", __func__);
-			return 0;
-		}
-
-		data = q6asm_is_cpu_buf_avail(IN, prtd->audio_client, &size,
-			&idx);
-		if (data == NULL) {
-			retries++;
-			continue;
-		} else {
-			retries = 0;
-		}
-
-		if (fbytes > size)
-			xfer = size;
-		else
-			xfer = fbytes;
-
-		bufptr = data;
-		if (bufptr) {
-			pr_debug("%s:fbytes =%d: xfer=%d size=%d\n",
-						__func__, fbytes, xfer, size);
-			if (copy_from_user(bufptr, buf, xfer)) {
-				ret = -EFAULT;
-				pr_err("%s: copy_from_user failed\n",
-					__func__);
-				q6asm_cpu_buf_release(IN, prtd->audio_client);
-				goto fail;
-			}
-			buf += xfer;
-			fbytes -= xfer;
-			pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes,
-				xfer);
-			if (atomic_read(&prtd->start)) {
-				pr_debug("%s:writing %d bytes of buffer to dsp\n",
-						__func__, xfer);
-				ret = q6asm_write(prtd->audio_client, xfer,
-							0, 0, NO_TIMESTAMP);
-				if (ret < 0) {
-					ret = -EFAULT;
-					q6asm_cpu_buf_release(IN,
-						prtd->audio_client);
-					goto fail;
-				}
-			} else
-				atomic_inc(&prtd->out_needed);
-			atomic_dec(&prtd->out_count);
-		}
-	}
-fail:
-	if (retries >= MAX_PB_COPY_RETRIES)
-		ret = -ENOMEM;
-
-	return  ret;
-}
-
-static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd = runtime->private_data;
-	uint32_t timeout;
-	int dir = 0;
-	int ret = 0;
-
-	pr_debug("%s: cmd_pending 0x%lx\n", __func__, prtd->cmd_pending);
-
-	if (prtd->audio_client) {
-		dir = IN;
-
-		/* determine timeout length */
-		if (runtime->frame_bits == 0 || runtime->rate == 0) {
-			timeout = CMD_EOS_MIN_TIMEOUT_LENGTH;
-		} else {
-			timeout = (runtime->period_size *
-					CMD_EOS_TIMEOUT_MULTIPLIER) /
-					((runtime->frame_bits / 8) *
-					 runtime->rate);
-			if (timeout < CMD_EOS_MIN_TIMEOUT_LENGTH)
-				timeout = CMD_EOS_MIN_TIMEOUT_LENGTH;
-		}
-		pr_debug("%s: CMD_EOS timeout is %d\n", __func__, timeout);
-
-		ret = wait_event_timeout(the_locks.eos_wait,
-					 !test_bit(CMD_EOS, &prtd->cmd_pending),
-					 timeout);
-		if (!ret)
-			pr_err("%s: CMD_EOS failed, cmd_pending 0x%lx\n",
-			       __func__, prtd->cmd_pending);
-		q6asm_cmd(prtd->audio_client, CMD_CLOSE);
-		q6asm_audio_client_buf_free_contiguous(dir,
-					prtd->audio_client);
-		q6asm_audio_client_free(prtd->audio_client);
-	}
-	msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->id,
-						SNDRV_PCM_STREAM_PLAYBACK);
-	msm_adsp_clean_mixer_ctl_pp_event_queue(soc_prtd);
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-		 int channel, snd_pcm_uframes_t hwoff, void __user *buf,
-						 snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	int fbytes = 0;
-	int xfer;
-	char *bufptr;
-	void *data = NULL;
-	static uint32_t idx;
-	static uint32_t size;
-	uint32_t offset = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = substream->runtime->private_data;
-
-
-	pr_debug("%s\n", __func__);
-	fbytes = frames_to_bytes(runtime, frames);
-
-	pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr);
-	pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr);
-	pr_debug("avail_min %d\n", (int)runtime->control->avail_min);
-
-	if (prtd->reset_event) {
-		pr_err("%s: In SSR return ENETRESET before wait\n", __func__);
-		return -ENETRESET;
-	}
-	ret = wait_event_timeout(the_locks.read_wait,
-			(atomic_read(&prtd->in_count)), 5 * HZ);
-	if (!ret) {
-		pr_debug("%s: wait_event_timeout failed\n", __func__);
-		goto fail;
-	}
-	if (prtd->reset_event) {
-		pr_err("%s: In SSR return ENETRESET after wait\n", __func__);
-		return -ENETRESET;
-	}
-	if (!atomic_read(&prtd->in_count)) {
-		pr_debug("%s: pcm stopped in_count 0\n", __func__);
-		return 0;
-	}
-	pr_debug("Checking if valid buffer is available...%pK\n",
-						data);
-	data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx);
-	bufptr = data;
-	pr_debug("Size = %d\n", size);
-	pr_debug("fbytes = %d\n", fbytes);
-	pr_debug("idx = %d\n", idx);
-	if (bufptr) {
-		xfer = fbytes;
-		if (xfer > size)
-			xfer = size;
-		offset = prtd->in_frame_info[idx].offset;
-		pr_debug("Offset value = %d\n", offset);
-		if (copy_to_user(buf, bufptr+offset, xfer)) {
-			pr_err("Failed to copy buf to user\n");
-			ret = -EFAULT;
-			q6asm_cpu_buf_release(OUT, prtd->audio_client);
-			goto fail;
-		}
-		fbytes -= xfer;
-		size -= xfer;
-		prtd->in_frame_info[idx].offset += xfer;
-		pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n",
-					__func__, fbytes, size, xfer);
-		pr_debug(" Sending next buffer to dsp\n");
-		memset(&prtd->in_frame_info[idx], 0,
-		       sizeof(struct msm_audio_in_frame_info));
-		atomic_dec(&prtd->in_count);
-		ret = q6asm_read(prtd->audio_client);
-		if (ret < 0) {
-			pr_err("q6asm read failed\n");
-			ret = -EFAULT;
-			q6asm_cpu_buf_release(OUT, prtd->audio_client);
-			goto fail;
-		}
-	} else
-		pr_err("No valid buffer\n");
-
-	pr_debug("Returning from capture_copy... %d\n", ret);
-fail:
-	return ret;
-}
-
-static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
-	struct msm_audio *prtd = runtime->private_data;
-	int dir = OUT;
-
-	pr_debug("%s\n", __func__);
-	if (prtd->audio_client) {
-		q6asm_cmd(prtd->audio_client, CMD_CLOSE);
-		q6asm_audio_client_buf_free_contiguous(dir,
-				prtd->audio_client);
-		q6asm_audio_client_free(prtd->audio_client);
-	}
-
-	msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->id,
-		SNDRV_PCM_STREAM_CAPTURE);
-	kfree(prtd);
-	runtime->private_data = NULL;
-
-	return 0;
-}
-
-static int msm_pcm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
-	return ret;
-}
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_close(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_close(substream);
-	return ret;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_prepare(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_prepare(substream);
-	return ret;
-}
-
-static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
-{
-
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-
-	if (prtd->pcm_irq_pos >= prtd->pcm_size)
-		prtd->pcm_irq_pos = 0;
-
-	pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos);
-	return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
-}
-
-static int msm_pcm_mmap(struct snd_pcm_substream *substream,
-				struct vm_area_struct *vma)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	struct audio_client *ac = prtd->audio_client;
-	struct audio_port_data *apd = ac->port;
-	struct audio_buffer *ab;
-	int dir = -1;
-
-	prtd->mmap_flag = 1;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-	ab = &(apd[dir].buf[0]);
-
-	return msm_audio_ion_mmap(ab, vma);
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct audio_buffer *buf;
-	int dir, ret;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		dir = IN;
-	else
-		dir = OUT;
-	ret = q6asm_audio_client_buf_alloc_contiguous(dir,
-			prtd->audio_client,
-			(params_buffer_bytes(params) / params_periods(params)),
-			 params_periods(params));
-	if (ret < 0) {
-		pr_err("Audio Start: Buffer Allocation failed rc = %d\n",
-							ret);
-		return -ENOMEM;
-	}
-	buf = prtd->audio_client->port[dir].buf;
-	if (buf == NULL || buf[0].data == NULL)
-		return -ENOMEM;
-
-	pr_debug("%s:buf = %pK\n", __func__, buf);
-	dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-	dma_buf->dev.dev = substream->pcm->card->dev;
-	dma_buf->private_data = NULL;
-	dma_buf->area = buf[0].data;
-	dma_buf->addr =  buf[0].phys;
-	dma_buf->bytes = params_buffer_bytes(params);
-	if (!dma_buf->area)
-		return -ENOMEM;
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-	return 0;
-}
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
-	.hw_params	= msm_pcm_hw_params,
-	.close          = msm_pcm_close,
-	.ioctl          = snd_pcm_lib_ioctl,
-	.prepare        = msm_pcm_prepare,
-	.trigger        = msm_pcm_trigger,
-	.pointer        = msm_pcm_pointer,
-	.mmap		= msm_pcm_mmap,
-};
-
-static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *pcm = snd_kcontrol_chip(kcontrol);
-	struct snd_soc_platform *platform = snd_soc_component_to_platform(pcm);
-	struct msm_plat_data *pdata = dev_get_drvdata(platform->dev);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-	int ret = 0;
-	struct msm_adsp_event_data *event_data = NULL;
-
-	if (!pdata) {
-		pr_err("%s pdata is NULL\n", __func__);
-		ret = -ENODEV;
-		goto done;
-	}
-
-	substream = pdata->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = substream->runtime->private_data;
-	if (prtd->audio_client == NULL) {
-		pr_err("%s prtd is null.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data;
-	if ((event_data->event_type < ADSP_STREAM_PP_EVENT) ||
-	    (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) {
-		pr_err("%s: invalid event_type=%d",
-			__func__, event_data->event_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
-					sizeof(ucontrol->value.bytes.data)) {
-		pr_err("%s param length=%d  exceeds limit",
-			__func__, event_data->payload_len);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = q6asm_send_stream_cmd(prtd->audio_client, event_data);
-	if (ret < 0)
-		pr_err("%s: failed to send stream event cmd, err = %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-static int msm_pcm_add_audio_adsp_stream_cmd_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CMD;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_audio_adsp_stream_cmd_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_pcm_adsp_stream_cmd_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s rtd is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_audio_adsp_stream_cmd_config_control[0].name = mixer_str;
-	fe_audio_adsp_stream_cmd_config_control[0].private_value =
-		rtd->dai_link->id;
-	pr_debug("Registering new mixer ctl %s\n", mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-		fe_audio_adsp_stream_cmd_config_control,
-		ARRAY_SIZE(fe_audio_adsp_stream_cmd_config_control));
-	if (ret < 0)
-		pr_err("%s: failed add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_pcm_add_audio_adsp_stream_callback_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol *kctl;
-
-	struct snd_kcontrol_new fe_audio_adsp_callback_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_callback_info,
-		.get = msm_adsp_stream_callback_get,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: added new pcm FE with name %s, id %d, cpu dai %s, device no %d\n",
-		 __func__, rtd->dai_link->name, rtd->dai_link->id,
-		 rtd->dai_link->cpu_dai_name, rtd->pcm->device);
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_audio_adsp_callback_config_control[0].name = mixer_str;
-	fe_audio_adsp_callback_config_control[0].private_value =
-		rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-			fe_audio_adsp_callback_config_control,
-			ARRAY_SIZE(fe_audio_adsp_callback_config_control));
-	if (ret < 0) {
-		pr_err("%s: failed to add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl %s.\n", __func__, mixer_str);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl->private_data = NULL;
-
-free_mixer_str:
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_pcm_set_volume(struct msm_audio *prtd, uint32_t volume)
-{
-	int rc = 0;
-
-	if (prtd && prtd->audio_client) {
-		pr_debug("%s: channels %d volume 0x%x\n", __func__,
-				prtd->channel_mode, volume);
-		rc = q6asm_set_volume(prtd->audio_client, volume);
-		if (rc < 0) {
-			pr_err("%s: Send Volume command failed rc=%d\n",
-					__func__, rc);
-		}
-	}
-	return rc;
-}
-
-static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
-		      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
-	struct snd_pcm_substream *substream =
-		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s\n", __func__);
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -ENODEV;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd)
-		ucontrol->value.integer.value[0] = prtd->volume;
-	return 0;
-}
-
-static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
-	struct snd_pcm_substream *substream =
-		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	struct msm_audio *prtd;
-	int volume = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: volume : 0x%x\n", __func__, volume);
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -ENODEV;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd) {
-		rc = msm_pcm_set_volume(prtd, volume);
-		prtd->volume = volume;
-	}
-	return rc;
-}
-
-static int msm_pcm_add_volume_control(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_volume *volume_info;
-	struct snd_kcontrol *kctl;
-
-	dev_dbg(rtd->dev, "%s, Volume control add\n", __func__);
-	ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-			NULL, 1, rtd->dai_link->id,
-			&volume_info);
-	if (ret < 0) {
-		pr_err("%s volume control failed ret %d\n", __func__, ret);
-		return ret;
-	}
-	kctl = volume_info->kctl;
-	kctl->put = msm_pcm_volume_ctl_put;
-	kctl->get = msm_pcm_volume_ctl_get;
-	kctl->tlv.p = msm_pcm_vol_gain;
-	return 0;
-}
-
-static int msm_pcm_compress_ctl_info(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = 1;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = 0x2000;
-	return 0;
-}
-
-static int msm_pcm_compress_ctl_get(struct snd_kcontrol *kcontrol,
-		      struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	struct snd_soc_platform *platform = snd_soc_component_to_platform(comp);
-	struct msm_plat_data *pdata = dev_get_drvdata(platform->dev);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-
-	if (!pdata) {
-		pr_err("%s pdata is NULL\n", __func__);
-		return -ENODEV;
-	}
-	substream = pdata->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -EINVAL;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd)
-		ucontrol->value.integer.value[0] = prtd->compress_enable;
-	return 0;
-}
-
-static int msm_pcm_compress_ctl_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	struct snd_soc_platform *platform = snd_soc_component_to_platform(comp);
-	struct msm_plat_data *pdata = dev_get_drvdata(platform->dev);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-	int compress = ucontrol->value.integer.value[0];
-
-	if (!pdata) {
-		pr_err("%s pdata is NULL\n", __func__);
-		return -ENODEV;
-	}
-	substream = pdata->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	pr_debug("%s: compress : 0x%x\n", __func__, compress);
-	if (!substream) {
-		pr_err("%s substream not found\n", __func__);
-		return -EINVAL;
-	}
-	if (!substream->runtime) {
-		pr_err("%s substream runtime not found\n", __func__);
-		return 0;
-	}
-	prtd = substream->runtime->private_data;
-	if (prtd) {
-		pr_debug("%s: setting compress flag to 0x%x\n",
-		__func__, compress);
-		prtd->compress_enable = compress;
-	}
-	return rc;
-}
-
-static int msm_pcm_add_compress_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback ";
-	const char *mixer_ctl_end_name = " Compress";
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len;
-	int ret = 0;
-	struct msm_plat_data *pdata;
-	struct snd_kcontrol_new pcm_compress_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_pcm_compress_ctl_info,
-		.get = msm_pcm_compress_ctl_get,
-		.put = msm_pcm_compress_ctl_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s: NULL rtd\n", __func__);
-		return -EINVAL;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + strlen(deviceNo) +
-		  strlen(mixer_ctl_end_name) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-
-	if (!mixer_str)
-		return -ENOMEM;
-
-	snprintf(mixer_str, ctl_len, "%s%d%s", mixer_ctl_name,
-			rtd->pcm->device, mixer_ctl_end_name);
-
-	pcm_compress_control[0].name = mixer_str;
-	pcm_compress_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	pdata = dev_get_drvdata(rtd->platform->dev);
-	if (pdata) {
-		if (!pdata->pcm) {
-			pdata->pcm = rtd->pcm;
-			snd_soc_add_platform_controls(rtd->platform,
-						      pcm_compress_control,
-						      ARRAY_SIZE
-						      (pcm_compress_control));
-			pr_debug("%s: add control success plt = %pK\n",
-				 __func__, rtd->platform);
-		}
-	} else {
-		pr_err("%s: NULL pdata\n", __func__);
-		ret = -EINVAL;
-	}
-	kfree(mixer_str);
-	return ret;
-}
-
-static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s", __func__);
-	substream = snd_pcm_chmap_substream(info, idx);
-	if (!substream)
-		return -ENODEV;
-	if (!substream->runtime)
-		return 0;
-
-	prtd = substream->runtime->private_data;
-	if (prtd) {
-		prtd->set_channel_map = true;
-			for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-				prtd->channel_map[i] =
-				(char)(ucontrol->value.integer.value[i]);
-	}
-	return 0;
-}
-
-static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-	struct snd_pcm_substream *substream;
-	struct msm_audio *prtd;
-
-	pr_debug("%s", __func__);
-	substream = snd_pcm_chmap_substream(info, idx);
-	if (!substream)
-		return -ENODEV;
-	memset(ucontrol->value.integer.value, 0,
-		sizeof(ucontrol->value.integer.value));
-	if (!substream->runtime)
-		return 0; /* no channels set */
-
-	prtd = substream->runtime->private_data;
-
-	if (prtd && prtd->set_channel_map == true) {
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			ucontrol->value.integer.value[i] =
-					(int)prtd->channel_map[i];
-	} else {
-		for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-			ucontrol->value.integer.value[i] = 0;
-	}
-
-	return 0;
-}
-
-static int msm_pcm_add_chmap_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_chmap *chmap_info;
-	struct snd_kcontrol *kctl;
-	char device_num[12];
-	int i, ret = 0;
-
-	pr_debug("%s, Channel map cntrl add\n", __func__);
-	ret = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-				     snd_pcm_std_chmaps,
-				     PCM_FORMAT_MAX_NUM_CHANNEL, 0,
-				     &chmap_info);
-	if (ret < 0) {
-		pr_err("%s, channel map cntrl add failed\n", __func__);
-		return ret;
-	}
-	kctl = chmap_info->kctl;
-	for (i = 0; i < kctl->count; i++)
-		kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE;
-	snprintf(device_num, sizeof(device_num), "%d", pcm->device);
-	strlcat(kctl->id.name, device_num, sizeof(kctl->id.name));
-	pr_debug("%s, Overwriting channel map control name to: %s\n",
-		__func__, kctl->id.name);
-	kctl->put = msm_pcm_chmap_ctl_put;
-	kctl->get = msm_pcm_chmap_ctl_get;
-	return 0;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_RX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = ucontrol->value.integer.value[3];
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
-	int ret = 0;
-
-	cfg_data.app_type = ucontrol->value.integer.value[0];
-	cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
-	if (ucontrol->value.integer.value[2] != 0)
-		cfg_data.sample_rate = ucontrol->value.integer.value[2];
-	pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-	ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
-						      be_id, &cfg_data);
-	if (ret < 0)
-		pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u64 fe_id = kcontrol->private_value;
-	int session_type = SESSION_TYPE_TX;
-	int be_id = 0;
-	struct msm_pcm_stream_app_type_cfg cfg_data = {0};
-	int ret = 0;
-
-	ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
-						      &be_id, &cfg_data);
-	if (ret < 0) {
-		pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ucontrol->value.integer.value[0] = cfg_data.app_type;
-	ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
-	ucontrol->value.integer.value[2] = cfg_data.sample_rate;
-	ucontrol->value.integer.value[3] = be_id;
-	pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fe_id, session_type, be_id,
-		cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
-done:
-	return ret;
-}
-
-static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_pcm *pcm = rtd->pcm;
-	struct snd_pcm_usr *app_type_info;
-	struct snd_kcontrol *kctl;
-	const char *playback_mixer_ctl_name	= "Audio Stream";
-	const char *capture_mixer_ctl_name	= "Audio Stream Capture";
-	const char *deviceNo		= "NN";
-	const char *suffix		= "App Type Cfg";
-	int ctl_len, ret = 0;
-
-	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
-		ctl_len = strlen(playback_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 + strlen(suffix) + 1;
-		pr_debug("%s: Playback app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-					NULL, 1, ctl_len, rtd->dai_link->id,
-					&app_type_info);
-		if (ret < 0) {
-			pr_err("%s: playback app type cntrl add failed: %d\n",
-				__func__, ret);
-			return ret;
-		}
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-			playback_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_playback_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_playback_app_type_cfg_ctl_get;
-	}
-
-	if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
-		ctl_len = strlen(capture_mixer_ctl_name) + 1 +
-				strlen(deviceNo) + 1 + strlen(suffix) + 1;
-		pr_debug("%s: Capture app type cntrl add\n", __func__);
-		ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
-					NULL, 1, ctl_len, rtd->dai_link->id,
-					&app_type_info);
-		if (ret < 0) {
-			pr_err("%s: capture app type cntrl add failed: %d\n",
-				__func__, ret);
-			return ret;
-		}
-		kctl = app_type_info->kctl;
-		snprintf(kctl->id.name, ctl_len, "%s %d %s",
-			capture_mixer_ctl_name, rtd->pcm->device, suffix);
-		kctl->put = msm_pcm_capture_app_type_cfg_ctl_put;
-		kctl->get = msm_pcm_capture_app_type_cfg_ctl_get;
-	}
-
-	return 0;
-}
-
-static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-	ret = msm_pcm_add_chmap_controls(rtd);
-	if (ret)
-		pr_err("%s: pcm add controls failed:%d\n", __func__, ret);
-	ret = msm_pcm_add_app_type_controls(rtd);
-	if (ret)
-		pr_err("%s: pcm add app type controls failed:%d\n",
-			__func__, ret);
-	return ret;
-}
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	ret = msm_pcm_add_controls(rtd);
-	if (ret) {
-		pr_err("%s, kctl add failed:%d\n", __func__, ret);
-		return ret;
-	}
-
-	ret = msm_pcm_add_volume_control(rtd);
-	if (ret)
-		pr_err("%s: Could not add pcm Volume Control %d\n",
-			__func__, ret);
-
-	ret = msm_pcm_add_compress_control(rtd);
-	if (ret)
-		pr_err("%s: Could not add pcm Compress Control %d\n",
-			__func__, ret);
-
-	ret = msm_pcm_add_audio_adsp_stream_cmd_control(rtd);
-	if (ret)
-		pr_err("%s: Could not add pcm ADSP Stream Cmd Control\n",
-			__func__);
-
-	ret = msm_pcm_add_audio_adsp_stream_callback_control(rtd);
-	if (ret)
-		pr_err("%s: Could not add pcm ADSP Stream Callback Control\n",
-			__func__);
-
-	return ret;
-}
-
-static snd_pcm_sframes_t msm_pcm_delay_blk(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_audio *prtd = runtime->private_data;
-	struct audio_client *ac = prtd->audio_client;
-	snd_pcm_sframes_t frames;
-	int ret;
-
-	ret = q6asm_get_path_delay(prtd->audio_client);
-	if (ret) {
-		pr_err("%s: get_path_delay failed, ret=%d\n", __func__, ret);
-		return 0;
-	}
-
-	/* convert microseconds to frames */
-	frames = ac->path_delay / 1000 * runtime->rate / 1000;
-
-	/* also convert the remainder from the initial division */
-	frames += ac->path_delay % 1000 * runtime->rate / 1000000;
-
-	/* overcompensate for the loss of precision (empirical) */
-	frames += 2;
-
-	return frames;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.delay_blk      = msm_pcm_delay_blk,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	int rc;
-	int id;
-	struct msm_plat_data *pdata;
-	const char *latency_level;
-
-	rc = of_property_read_u32(pdev->dev.of_node,
-				"qcom,msm-pcm-dsp-id", &id);
-	if (rc) {
-		dev_err(&pdev->dev, "%s: qcom,msm-pcm-dsp-id missing in DT node\n",
-					__func__);
-		return rc;
-	}
-
-	pdata = kzalloc(sizeof(struct msm_plat_data), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	if (of_property_read_bool(pdev->dev.of_node,
-				"qcom,msm-pcm-low-latency")) {
-
-		pdata->perf_mode = LOW_LATENCY_PCM_MODE;
-		rc = of_property_read_string(pdev->dev.of_node,
-			"qcom,latency-level", &latency_level);
-		if (!rc) {
-			if (!strcmp(latency_level, "ultra"))
-				pdata->perf_mode = ULTRA_LOW_LATENCY_PCM_MODE;
-			else if (!strcmp(latency_level, "ull-pp"))
-				pdata->perf_mode =
-					ULL_POST_PROCESSING_PCM_MODE;
-		}
-	} else {
-		pdata->perf_mode = LEGACY_PCM_MODE;
-	}
-
-	dev_set_drvdata(&pdev->dev, pdata);
-
-
-	dev_dbg(&pdev->dev, "%s: dev name %s\n",
-				__func__, dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev,
-				   &msm_soc_platform);
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	struct msm_plat_data *pdata;
-
-	pdata = dev_get_drvdata(&pdev->dev);
-	kfree(pdata);
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-static const struct of_device_id msm_pcm_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-dsp"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_pcm_dt_match);
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-pcm-dsp",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	init_waitqueue_head(&the_locks.enable_wait);
-	init_waitqueue_head(&the_locks.eos_wait);
-	init_waitqueue_head(&the_locks.write_wait);
-	init_waitqueue_head(&the_locks.read_wait);
-
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("PCM module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.h
deleted file mode 100644
index 3b3f048..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- */
-
-#ifndef _MSM_PCM_H
-#define _MSM_PCM_H
-#include <sound/apr_audio-v2.h>
-#include <sound/q6asm-v2.h>
-
-
-
-/* Support unconventional sample rates 12000, 24000 as well */
-#define USE_RATE                \
-			(SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT)
-
-extern int copy_count;
-
-struct buffer {
-	void *data;
-	unsigned int size;
-	unsigned int used;
-	unsigned int addr;
-};
-
-struct buffer_rec {
-	void *data;
-	unsigned int size;
-	unsigned int read;
-	unsigned int addr;
-};
-
-struct audio_locks {
-	spinlock_t event_lock;
-	wait_queue_head_t read_wait;
-	wait_queue_head_t write_wait;
-	wait_queue_head_t eos_wait;
-	wait_queue_head_t enable_wait;
-	wait_queue_head_t flush_wait;
-};
-
-struct msm_audio_in_frame_info {
-	uint32_t size;
-	uint32_t offset;
-};
-
-#define PLAYBACK_MIN_NUM_PERIODS    2
-#define PLAYBACK_MAX_NUM_PERIODS    8
-#define PLAYBACK_MAX_PERIOD_SIZE    122880
-#define PLAYBACK_MIN_PERIOD_SIZE    128
-#define CAPTURE_MIN_NUM_PERIODS     2
-#define CAPTURE_MAX_NUM_PERIODS     8
-#define CAPTURE_MAX_PERIOD_SIZE     122880
-#define CAPTURE_MIN_PERIOD_SIZE     320
-
-struct msm_audio {
-	struct snd_pcm_substream *substream;
-	unsigned int pcm_size;
-	unsigned int pcm_count;
-	unsigned int pcm_irq_pos;       /* IRQ position */
-	uint16_t source; /* Encoding source bit mask */
-
-	struct audio_client *audio_client;
-
-	uint16_t session_id;
-
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t dsp_cnt;
-
-	int abort; /* set when error, like sample rate mismatch */
-
-	bool reset_event;
-	int enabled;
-	int close_ack;
-	int cmd_ack;
-	/*
-	 * cmd_ack doesn't tell if paticular command has been sent so can't
-	 * determine if it needs to wait for completion.
-	 * Use cmd_pending instead when checking whether a command is been
-	 * sent or not.
-	 */
-	unsigned long cmd_pending;
-	atomic_t start;
-	atomic_t stop;
-	atomic_t out_count;
-	atomic_t in_count;
-	atomic_t out_needed;
-	atomic_t eos;
-	int out_head;
-	int periods;
-	int mmap_flag;
-	atomic_t pending_buffer;
-	bool set_channel_map;
-	char channel_map[8];
-	int cmd_interrupt;
-	bool meta_data_mode;
-	uint32_t volume;
-	bool compress_enable;
-	/* array of frame info */
-	struct msm_audio_in_frame_info in_frame_info[CAPTURE_MAX_NUM_PERIODS];
-};
-
-struct output_meta_data_st {
-	uint32_t meta_data_length;
-	uint32_t frame_size;
-	uint32_t timestamp_lsw;
-	uint32_t timestamp_msw;
-	uint32_t reserved[12];
-};
-
-struct msm_plat_data {
-	int perf_mode;
-	struct snd_pcm *pcm;
-};
-
-#endif /*_MSM_PCM_H*/
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.c
deleted file mode 100644
index 7335951..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <sound/hwdep.h>
-#include <sound/devdep_params.h>
-#include "msm-pcm-routing-devdep.h"
-#include "msm-ds2-dap-config.h"
-
-#ifdef CONFIG_SND_HWDEP
-static int msm_pcm_routing_hwdep_open(struct snd_hwdep *hw, struct file *file)
-{
-	pr_debug("%s\n", __func__);
-	msm_ds2_dap_update_port_parameters(hw, file, true);
-	return 0;
-}
-
-static int msm_pcm_routing_hwdep_release(struct snd_hwdep *hw,
-					 struct file *file)
-{
-	pr_debug("%s\n", __func__);
-	msm_ds2_dap_update_port_parameters(hw, file, false);
-	return 0;
-}
-
-static int msm_pcm_routing_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
-				       unsigned int cmd, unsigned long arg)
-{
-	int ret = 0;
-	void __user *argp = (void __user *)arg;
-
-	pr_debug("%s:cmd %x\n", __func__, cmd);
-	switch (cmd) {
-	case SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM:
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM:
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND:
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE:
-		msm_pcm_routing_acquire_lock();
-		ret = msm_ds2_dap_ioctl(hw, file, cmd, argp);
-		msm_pcm_routing_release_lock();
-		break;
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER:
-		ret = msm_ds2_dap_ioctl(hw, file, cmd, argp);
-		break;
-	default:
-		pr_err("%s called with invalid control 0x%X\n", __func__, cmd);
-		ret = -EINVAL;
-		break;
-	}
-	return ret;
-}
-
-void msm_pcm_routing_hwdep_free(struct snd_pcm *pcm)
-{
-	pr_debug("%s\n", __func__);
-}
-
-#ifdef CONFIG_COMPAT
-static int msm_pcm_routing_hwdep_compat_ioctl(struct snd_hwdep *hw,
-					      struct file *file,
-					      unsigned int cmd,
-					      unsigned long arg)
-{
-	int ret = 0;
-	void __user *argp = (void __user *)arg;
-
-	pr_debug("%s:cmd %x\n", __func__, cmd);
-	switch (cmd) {
-	case SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM32:
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM32:
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_COMMAND32:
-	case SNDRV_DEVDEP_DAP_IOCTL_DAP_LICENSE32:
-		msm_pcm_routing_acquire_lock();
-		ret = msm_ds2_dap_compat_ioctl(hw, file, cmd, argp);
-		msm_pcm_routing_release_lock();
-		break;
-	case SNDRV_DEVDEP_DAP_IOCTL_GET_VISUALIZER32:
-		ret = msm_ds2_dap_compat_ioctl(hw, file, cmd, argp);
-		break;
-	default:
-		pr_err("%s called with invalid control 0x%X\n", __func__, cmd);
-		ret = -EINVAL;
-		break;
-	}
-	return ret;
-}
-#endif
-
-int msm_pcm_routing_hwdep_new(struct snd_soc_pcm_runtime *runtime,
-			      struct msm_pcm_routing_bdai_data *msm_bedais)
-{
-	struct snd_hwdep *hwdep;
-	struct snd_soc_dai_link *dai_link = runtime->dai_link;
-	int rc;
-
-	if (dai_link->id < 0 ||
-		dai_link->id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s:BE id %d invalid index\n",
-			__func__, dai_link->id);
-		return -EINVAL;
-	}
-	pr_debug("%s BE id %d\n", __func__, dai_link->id);
-	rc = snd_hwdep_new(runtime->card->snd_card,
-			   msm_bedais[dai_link->id].name,
-			   dai_link->id, &hwdep);
-	if (hwdep == NULL) {
-		pr_err("%s: hwdep intf failed to create %s- hwdep NULL\n",
-			__func__, msm_bedais[dai_link->id].name);
-		return rc;
-	}
-	if (rc < 0) {
-		pr_err("%s: hwdep intf failed to create %s rc %d\n", __func__,
-			msm_bedais[dai_link->id].name, rc);
-		return rc;
-	}
-
-	hwdep->iface = SNDRV_HWDEP_IFACE_AUDIO_BE;
-	hwdep->private_data = &msm_bedais[dai_link->id];
-	hwdep->ops.open = msm_pcm_routing_hwdep_open;
-	hwdep->ops.ioctl = msm_pcm_routing_hwdep_ioctl;
-	hwdep->ops.release = msm_pcm_routing_hwdep_release;
-#ifdef CONFIG_COMPAT
-	hwdep->ops.ioctl_compat = msm_pcm_routing_hwdep_compat_ioctl;
-#endif
-	return rc;
-}
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.h b/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.h
deleted file mode 100644
index d93d048..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-devdep.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (c) 2014-2015, 2017 The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_PCM_ROUTING_DEVDEP_H_
-#define _MSM_PCM_ROUTING_DEVDEP_H_
-
-#include <sound/soc.h>
-#include "msm-pcm-routing-v2.h"
-
-#ifdef CONFIG_SND_HWDEP
-int msm_pcm_routing_hwdep_new(struct snd_soc_pcm_runtime *runtime,
-			      struct msm_pcm_routing_bdai_data *msm_bedais);
-void msm_pcm_routing_hwdep_free(struct snd_pcm *pcm);
-#else
-static inline int msm_pcm_routing_hwdep_new(struct snd_soc_pcm_runtime *runtime,
-				struct msm_pcm_routing_bdai_data *msm_bedais)
-{
-	return 0;
-}
-
-static inline void msm_pcm_routing_hwdep_free(struct snd_pcm *pcm)
-{
-}
-#endif
-#endif
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
deleted file mode 100644
index 16f82ce..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
+++ /dev/null
@@ -1,15993 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/platform_device.h>
-#include <linux/bitops.h>
-#include <linux/mutex.h>
-#include <linux/of_device.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6adm-v2.h>
-#include <sound/q6asm-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/tlv.h>
-#include <sound/asound.h>
-#include <sound/pcm_params.h>
-#include <sound/q6core.h>
-#include <sound/audio_cal_utils.h>
-#include <sound/audio_effects.h>
-#include <sound/hwdep.h>
-
-#include "msm-pcm-routing-v2.h"
-#include "msm-pcm-routing-devdep.h"
-#include "msm-qti-pp-config.h"
-#include "msm-dts-srs-tm-config.h"
-#include "msm-dolby-dap-config.h"
-#include "msm-ds2-dap-config.h"
-#include "q6voice.h"
-#include "sound/q6lsm.h"
-
-#ifndef CONFIG_DOLBY_DAP
-#undef DOLBY_ADM_COPP_TOPOLOGY_ID
-#define DOLBY_ADM_COPP_TOPOLOGY_ID 0xFFFFFFFE
-#endif
-
-#ifndef CONFIG_DOLBY_DS2
-#undef DS2_ADM_COPP_TOPOLOGY_ID
-#define DS2_ADM_COPP_TOPOLOGY_ID 0xFFFFFFFF
-#endif
-
-static struct mutex routing_lock;
-
-static struct cal_type_data *cal_data;
-
-static int fm_switch_enable;
-static int hfp_switch_enable;
-static int int0_mi2s_switch_enable;
-static int int4_mi2s_switch_enable;
-static int pri_mi2s_switch_enable;
-static int sec_mi2s_switch_enable;
-static int tert_mi2s_switch_enable;
-static int quat_mi2s_switch_enable;
-static int fm_pcmrx_switch_enable;
-static int usb_switch_enable;
-static int lsm_port_index;
-static int slim0_rx_aanc_fb_port;
-static int msm_route_ec_ref_rx;
-static int msm_ec_ref_ch = 4;
-static int msm_ec_ref_bit_format = SNDRV_PCM_FORMAT_S16_LE;
-static int msm_ec_ref_sampling_rate = 48000;
-static uint32_t voc_session_id = ALL_SESSION_VSID;
-static int msm_route_ext_ec_ref;
-static bool is_custom_stereo_on;
-static bool is_ds2_on;
-static bool swap_ch;
-
-#define WEIGHT_0_DB 0x4000
-/* all the FEs which can support channel mixer */
-static struct msm_pcm_channel_mixer channel_mixer[MSM_FRONTEND_DAI_MM_SIZE];
-/* input BE for each FE */
-static int channel_input[MSM_FRONTEND_DAI_MM_SIZE][ADM_MAX_CHANNELS];
-
-enum {
-	MADNONE,
-	MADAUDIO,
-	MADBEACON,
-	MADULTRASOUND,
-	MADSWAUDIO,
-};
-
-#define ADM_LSM_PORT_INDEX 9
-
-#define SLIMBUS_0_TX_TEXT "SLIMBUS_0_TX"
-#define SLIMBUS_1_TX_TEXT "SLIMBUS_1_TX"
-#define SLIMBUS_2_TX_TEXT "SLIMBUS_2_TX"
-#define SLIMBUS_3_TX_TEXT "SLIMBUS_3_TX"
-#define SLIMBUS_4_TX_TEXT "SLIMBUS_4_TX"
-#define SLIMBUS_5_TX_TEXT "SLIMBUS_5_TX"
-#define TERT_MI2S_TX_TEXT "TERT_MI2S_TX"
-#define QUAT_MI2S_TX_TEXT "QUAT_MI2S_TX"
-#define ADM_LSM_TX_TEXT "ADM_LSM_TX"
-#define INT3_MI2S_TX_TEXT "INT3_MI2S_TX"
-
-#define LSM_FUNCTION_TEXT "LSM Function"
-static const char * const lsm_port_text[] = {
-	"None",
-	SLIMBUS_0_TX_TEXT, SLIMBUS_1_TX_TEXT, SLIMBUS_2_TX_TEXT,
-	SLIMBUS_3_TX_TEXT, SLIMBUS_4_TX_TEXT, SLIMBUS_5_TX_TEXT,
-	TERT_MI2S_TX_TEXT, QUAT_MI2S_TX_TEXT, ADM_LSM_TX_TEXT,
-	INT3_MI2S_TX_TEXT
-};
-
-struct msm_pcm_route_bdai_pp_params {
-	u16 port_id; /* AFE port ID */
-	unsigned long pp_params_config;
-	bool mute_on;
-	int latency;
-};
-
-static struct msm_pcm_route_bdai_pp_params
-	msm_bedais_pp_params[MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX] = {
-	{HDMI_RX, 0, 0, 0},
-	{DISPLAY_PORT_RX, 0, 0, 0},
-};
-
-/*
- * The be_dai_name_table is passed to HAL so that it can specify the
- * BE ID for the BE it wants to enable based on the name. Thus there
- * is a matching table and structure in HAL that need to be updated
- * if any changes to these are made.
- */
-struct msm_pcm_route_bdai_name {
-	unsigned int be_id;
-	char be_name[LPASS_BE_NAME_MAX_LENGTH];
-};
-static struct msm_pcm_route_bdai_name be_dai_name_table[MSM_BACKEND_DAI_MAX];
-
-static int msm_routing_send_device_pp_params(int port_id,  int copp_idx,
-					     int fe_id);
-
-static int msm_routing_get_bit_width(unsigned int format)
-{
-	int bit_width;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		bit_width = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		bit_width = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bit_width = 16;
-	}
-	return bit_width;
-}
-
-static bool msm_is_resample_needed(int input_sr, int output_sr)
-{
-	bool rc = false;
-
-	if (input_sr != output_sr)
-		rc = true;
-
-	pr_debug("perform resampling (%s) for copp rate (%d)afe rate (%d)",
-		(rc ? "oh yes" : "not really"),
-		input_sr, output_sr);
-
-	return rc;
-}
-
-static void msm_pcm_routing_cfg_pp(int port_id, int copp_idx, int topology,
-				   int channels)
-{
-	int rc = 0;
-
-	switch (topology) {
-	case SRS_TRUMEDIA_TOPOLOGY_ID:
-		pr_debug("%s: SRS_TRUMEDIA_TOPOLOGY_ID\n", __func__);
-		msm_dts_srs_tm_init(port_id, copp_idx);
-		break;
-	case DS2_ADM_COPP_TOPOLOGY_ID:
-		pr_debug("%s: DS2_ADM_COPP_TOPOLOGY %d\n",
-			 __func__, DS2_ADM_COPP_TOPOLOGY_ID);
-		rc = msm_ds2_dap_init(port_id, copp_idx, channels,
-				      is_custom_stereo_on);
-		if (rc < 0)
-			pr_err("%s: DS2 topo_id 0x%x, port %d, CS %d rc %d\n",
-				__func__, topology, port_id,
-				is_custom_stereo_on, rc);
-		break;
-	case DOLBY_ADM_COPP_TOPOLOGY_ID:
-		if (is_ds2_on) {
-			pr_debug("%s: DS2_ADM_COPP_TOPOLOGY\n", __func__);
-			rc = msm_ds2_dap_init(port_id, copp_idx, channels,
-				is_custom_stereo_on);
-			if (rc < 0)
-				pr_err("%s:DS2 topo_id 0x%x, port %d, rc %d\n",
-					__func__, topology, port_id, rc);
-		} else {
-			pr_debug("%s: DOLBY_ADM_COPP_TOPOLOGY_ID\n", __func__);
-			rc = msm_dolby_dap_init(port_id, copp_idx, channels,
-						is_custom_stereo_on);
-			if (rc < 0)
-				pr_err("%s: DS1 topo_id 0x%x, port %d, rc %d\n",
-					__func__, topology, port_id, rc);
-		}
-		break;
-	case ADM_CMD_COPP_OPEN_TOPOLOGY_ID_AUDIOSPHERE:
-		pr_debug("%s: TOPOLOGY_ID_AUDIOSPHERE\n", __func__);
-		rc = msm_qti_pp_asphere_init(port_id, copp_idx);
-		if (rc < 0)
-			pr_err("%s: topo_id 0x%x, port %d, copp %d, rc %d\n",
-				__func__, topology, port_id, copp_idx, rc);
-		break;
-	default:
-		/* custom topology specific feature param handlers */
-		break;
-	}
-}
-
-static void msm_pcm_routing_deinit_pp(int port_id, int topology)
-{
-	switch (topology) {
-	case SRS_TRUMEDIA_TOPOLOGY_ID:
-		pr_debug("%s: SRS_TRUMEDIA_TOPOLOGY_ID\n", __func__);
-		msm_dts_srs_tm_deinit(port_id);
-		break;
-	case DS2_ADM_COPP_TOPOLOGY_ID:
-		pr_debug("%s: DS2_ADM_COPP_TOPOLOGY_ID %d\n",
-			 __func__, DS2_ADM_COPP_TOPOLOGY_ID);
-		msm_ds2_dap_deinit(port_id);
-		break;
-	case DOLBY_ADM_COPP_TOPOLOGY_ID:
-		if (is_ds2_on) {
-			pr_debug("%s: DS2_ADM_COPP_TOPOLOGY_ID\n", __func__);
-			msm_ds2_dap_deinit(port_id);
-		} else {
-			pr_debug("%s: DOLBY_ADM_COPP_TOPOLOGY_ID\n", __func__);
-			msm_dolby_dap_deinit(port_id);
-		}
-		break;
-	case ADM_CMD_COPP_OPEN_TOPOLOGY_ID_AUDIOSPHERE:
-		pr_debug("%s: TOPOLOGY_ID_AUDIOSPHERE\n", __func__);
-		msm_qti_pp_asphere_deinit(port_id);
-		break;
-	default:
-		/* custom topology specific feature deinit handlers */
-		break;
-	}
-}
-
-static void msm_pcm_routng_cfg_matrix_map_pp(struct route_payload payload,
-					     int path_type, int perf_mode)
-{
-	int itr = 0, rc = 0;
-
-	if ((path_type == ADM_PATH_PLAYBACK) &&
-	    (perf_mode == LEGACY_PCM_MODE) &&
-	    is_custom_stereo_on) {
-		for (itr = 0; itr < payload.num_copps; itr++) {
-			if ((payload.port_id[itr] != SLIMBUS_0_RX) &&
-			    (payload.port_id[itr] != RT_PROXY_PORT_001_RX)) {
-				continue;
-			}
-
-			rc = msm_qti_pp_send_stereo_to_custom_stereo_cmd(
-				payload.port_id[itr],
-				payload.copp_idx[itr],
-				payload.session_id,
-				Q14_GAIN_ZERO_POINT_FIVE,
-				Q14_GAIN_ZERO_POINT_FIVE,
-				Q14_GAIN_ZERO_POINT_FIVE,
-				Q14_GAIN_ZERO_POINT_FIVE);
-			if (rc < 0)
-				pr_err("%s: err setting custom stereo\n",
-					__func__);
-		}
-	}
-}
-
-#define SLIMBUS_EXTPROC_RX AFE_PORT_INVALID
-struct msm_pcm_routing_bdai_data msm_bedais[MSM_BACKEND_DAI_MAX] = {
-	{ PRIMARY_I2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_PRI_I2S_RX},
-	{ PRIMARY_I2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_PRI_I2S_TX},
-	{ SLIMBUS_0_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_0_RX},
-	{ SLIMBUS_0_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_0_TX},
-	{ HDMI_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_HDMI},
-	{ INT_BT_SCO_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_INT_BT_SCO_RX},
-	{ INT_BT_SCO_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_INT_BT_SCO_TX},
-	{ INT_FM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_INT_FM_RX},
-	{ INT_FM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_INT_FM_TX},
-	{ RT_PROXY_PORT_001_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_AFE_PCM_RX},
-	{ RT_PROXY_PORT_001_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_AFE_PCM_TX},
-	{ AFE_PORT_ID_PRIMARY_PCM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_AUXPCM_RX},
-	{ AFE_PORT_ID_PRIMARY_PCM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_AUXPCM_TX},
-	{ VOICE_PLAYBACK_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_VOICE_PLAYBACK_TX},
-	{ VOICE2_PLAYBACK_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_VOICE2_PLAYBACK_TX},
-	{ VOICE_RECORD_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INCALL_RECORD_RX},
-	{ VOICE_RECORD_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INCALL_RECORD_TX},
-	{ MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_MI2S_RX},
-	{ MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_MI2S_TX},
-	{ SECONDARY_I2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SEC_I2S_RX},
-	{ SLIMBUS_1_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_1_RX},
-	{ SLIMBUS_1_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_1_TX},
-	{ SLIMBUS_2_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_2_RX},
-	{ SLIMBUS_2_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_2_TX},
-	{ SLIMBUS_3_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_3_RX},
-	{ SLIMBUS_3_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_3_TX},
-	{ SLIMBUS_4_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_4_RX},
-	{ SLIMBUS_4_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_4_TX},
-	{ SLIMBUS_5_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_5_RX},
-	{ SLIMBUS_5_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_5_TX},
-	{ SLIMBUS_6_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_6_RX},
-	{ SLIMBUS_6_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_6_TX},
-	{ SLIMBUS_7_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_7_RX},
-	{ SLIMBUS_7_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_7_TX},
-	{ SLIMBUS_8_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_8_RX},
-	{ SLIMBUS_8_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_SLIMBUS_8_TX},
-	{ SLIMBUS_EXTPROC_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_STUB_RX},
-	{ SLIMBUS_EXTPROC_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_STUB_TX},
-	{ SLIMBUS_EXTPROC_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_STUB_1_TX},
-	{ AFE_PORT_ID_QUATERNARY_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_MI2S_RX},
-	{ AFE_PORT_ID_QUATERNARY_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_MI2S_TX},
-	{ AFE_PORT_ID_SECONDARY_MI2S_RX,  0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_MI2S_RX},
-	{ AFE_PORT_ID_SECONDARY_MI2S_TX,  0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_MI2S_TX},
-	{ AFE_PORT_ID_PRIMARY_MI2S_RX,    0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_MI2S_RX},
-	{ AFE_PORT_ID_PRIMARY_MI2S_TX,    0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_MI2S_TX},
-	{ AFE_PORT_ID_TERTIARY_MI2S_RX,   0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_MI2S_RX},
-	{ AFE_PORT_ID_TERTIARY_MI2S_TX,   0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_MI2S_TX},
-	{ AUDIO_PORT_ID_I2S_RX,           0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_AUDIO_I2S_RX},
-	{ AFE_PORT_ID_SECONDARY_PCM_RX,	  0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_AUXPCM_RX},
-	{ AFE_PORT_ID_SECONDARY_PCM_TX,   0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_AUXPCM_TX},
-	{ AFE_PORT_ID_SPDIF_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SPDIF_RX},
-	{ AFE_PORT_ID_SECONDARY_MI2S_RX_SD1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_MI2S_RX_SD1},
-	{ AFE_PORT_ID_QUINARY_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUIN_MI2S_RX},
-	{ AFE_PORT_ID_QUINARY_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUIN_MI2S_TX},
-	{ AFE_PORT_ID_SENARY_MI2S_TX,   0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SENARY_MI2S_TX},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_0},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_0},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_1},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_1},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_2},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_2},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_3},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_3},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_4},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_4},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_5},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_5},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_6},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_6},
-	{ AFE_PORT_ID_PRIMARY_TDM_RX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_RX_7},
-	{ AFE_PORT_ID_PRIMARY_TDM_TX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_PRI_TDM_TX_7},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_0},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_0},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_1},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_1},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_2},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_2},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_3},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_3},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_4},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_4},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_5},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_5},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_6},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_6},
-	{ AFE_PORT_ID_SECONDARY_TDM_RX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_RX_7},
-	{ AFE_PORT_ID_SECONDARY_TDM_TX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_SEC_TDM_TX_7},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_0},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_0},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_1},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_1},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_2},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_2},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_3},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_3},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_4},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_4},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_5},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_5},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_6},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_6},
-	{ AFE_PORT_ID_TERTIARY_TDM_RX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_RX_7},
-	{ AFE_PORT_ID_TERTIARY_TDM_TX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_TDM_TX_7},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_0},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_0},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_1},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_1, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_1},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_2},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_2, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_2},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_3},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_3, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_3},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_4},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_4, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_4},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_5},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_5, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_5},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_6},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_6, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_6},
-	{ AFE_PORT_ID_QUATERNARY_TDM_RX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_RX_7},
-	{ AFE_PORT_ID_QUATERNARY_TDM_TX_7, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_TDM_TX_7},
-	{ INT_BT_A2DP_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT_BT_A2DP_RX},
-	{ AFE_PORT_ID_USB_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_USB_AUDIO_RX},
-	{ AFE_PORT_ID_USB_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_USB_AUDIO_TX},
-	{ DISPLAY_PORT_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_DISPLAY_PORT},
-	{ AFE_PORT_ID_TERTIARY_PCM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_AUXPCM_RX},
-	{ AFE_PORT_ID_TERTIARY_PCM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_TERT_AUXPCM_TX},
-	{ AFE_PORT_ID_QUATERNARY_PCM_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_AUXPCM_RX},
-	{ AFE_PORT_ID_QUATERNARY_PCM_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_QUAT_AUXPCM_TX},
-	{ AFE_PORT_ID_INT0_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT0_MI2S_RX},
-	{ AFE_PORT_ID_INT0_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT0_MI2S_TX},
-	{ AFE_PORT_ID_INT1_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT1_MI2S_RX},
-	{ AFE_PORT_ID_INT1_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT1_MI2S_TX},
-	{ AFE_PORT_ID_INT2_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT2_MI2S_RX},
-	{ AFE_PORT_ID_INT2_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT2_MI2S_TX},
-	{ AFE_PORT_ID_INT3_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT3_MI2S_RX},
-	{ AFE_PORT_ID_INT3_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT3_MI2S_TX},
-	{ AFE_PORT_ID_INT4_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT4_MI2S_RX},
-	{ AFE_PORT_ID_INT4_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT4_MI2S_TX},
-	{ AFE_PORT_ID_INT5_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT5_MI2S_RX},
-	{ AFE_PORT_ID_INT5_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT5_MI2S_TX},
-	{ AFE_PORT_ID_INT6_MI2S_RX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT6_MI2S_RX},
-	{ AFE_PORT_ID_INT6_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0},
-	  LPASS_BE_INT6_MI2S_TX},
-};
-
-/* Track ASM playback & capture sessions of DAI
- * Track LSM listen sessions
- */
-static struct msm_pcm_routing_fdai_data
-	fe_dai_map[MSM_FRONTEND_DAI_MAX][2] = {
-	/* MULTIMEDIA1 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA2 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA3 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA4 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA5 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA6 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA7*/
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA8 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA9 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA10 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA11 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA12 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA13 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA14 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA15 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA16 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA17 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA18 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA19 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* MULTIMEDIA20 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* CS_VOICE */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOIP */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* AFE_RX */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* AFE_TX */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOICE_STUB */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOLTE */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* DTMF_RX */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOICE2 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* QCHAT */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOLTE_STUB */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM1 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM2 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM3 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM4 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM5 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM6 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM7 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* LSM8 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOICE2_STUB */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOWLAN */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOICEMMODE1 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-	/* VOICEMMODE2 */
-	{{0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} },
-	 {0, INVALID_SESSION, LEGACY_PCM_MODE, {NULL, NULL} } },
-};
-
-static unsigned long session_copp_map[MSM_FRONTEND_DAI_MAX][2]
-				     [MSM_BACKEND_DAI_MAX];
-static struct msm_pcm_routing_app_type_data app_type_cfg[MAX_APP_TYPES];
-static struct msm_pcm_routing_app_type_data lsm_app_type_cfg[MAX_APP_TYPES];
-static struct msm_pcm_stream_app_type_cfg
-	fe_dai_app_type_cfg[MSM_FRONTEND_DAI_MAX][2][MSM_BACKEND_DAI_MAX];
-
-static int last_be_id_configured[MSM_FRONTEND_DAI_MAX][MAX_SESSION_TYPES];
-
-/* The caller of this should aqcuire routing lock */
-void msm_pcm_routing_get_bedai_info(int be_idx,
-				    struct msm_pcm_routing_bdai_data *be_dai)
-{
-	if (be_idx >= 0 && be_idx < MSM_BACKEND_DAI_MAX)
-		memcpy(be_dai, &msm_bedais[be_idx],
-		       sizeof(struct msm_pcm_routing_bdai_data));
-}
-
-/* The caller of this should aqcuire routing lock */
-void msm_pcm_routing_get_fedai_info(int fe_idx, int sess_type,
-				    struct msm_pcm_routing_fdai_data *fe_dai)
-{
-	if ((sess_type == SESSION_TYPE_TX) || (sess_type == SESSION_TYPE_RX))
-		memcpy(fe_dai, &fe_dai_map[fe_idx][sess_type],
-		       sizeof(struct msm_pcm_routing_fdai_data));
-}
-
-void msm_pcm_routing_acquire_lock(void)
-{
-	mutex_lock(&routing_lock);
-}
-
-void msm_pcm_routing_release_lock(void)
-{
-	mutex_unlock(&routing_lock);
-}
-
-static int msm_pcm_routing_get_app_type_idx(int app_type)
-{
-	int idx;
-
-	pr_debug("%s: app_type: %d\n", __func__, app_type);
-	for (idx = 0; idx < MAX_APP_TYPES; idx++) {
-		if (app_type_cfg[idx].app_type == app_type)
-			return idx;
-	}
-	pr_info("%s: App type not available, fallback to default\n", __func__);
-	return 0;
-}
-
-static int msm_pcm_routing_get_lsm_app_type_idx(int app_type)
-{
-	int idx;
-
-	pr_debug("%s: app_type: %d\n", __func__, app_type);
-	for (idx = 0; idx < MAX_APP_TYPES; idx++) {
-		if (lsm_app_type_cfg[idx].app_type == app_type)
-			return idx;
-	}
-	pr_debug("%s: App type not available, fallback to default\n", __func__);
-	return 0;
-}
-
-static bool is_mm_lsm_fe_id(int fe_id)
-{
-	bool rc = true;
-
-	if (fe_id > MSM_FRONTEND_DAI_MM_MAX_ID &&
-		((fe_id < MSM_FRONTEND_DAI_LSM1) ||
-		 (fe_id > MSM_FRONTEND_DAI_LSM8))) {
-		rc = false;
-	}
-	return rc;
-}
-
-int msm_pcm_routing_reg_stream_app_type_cfg(
-	int fedai_id, int session_type, int be_id,
-	struct msm_pcm_stream_app_type_cfg *cfg_data)
-{
-	int ret = 0;
-
-	if (cfg_data == NULL) {
-		pr_err("%s: Received NULL pointer for cfg_data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fedai_id, session_type, be_id,
-		cfg_data->app_type, cfg_data->acdb_dev_id,
-		cfg_data->sample_rate);
-
-	if (!is_mm_lsm_fe_id(fedai_id)) {
-		pr_err("%s: Invalid machine driver ID %d\n",
-			__func__, fedai_id);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (session_type != SESSION_TYPE_RX &&
-		session_type != SESSION_TYPE_TX) {
-		pr_err("%s: Invalid session type %d\n",
-			__func__, session_type);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: Received out of bounds be_id %d\n",
-			__func__, be_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	fe_dai_app_type_cfg[fedai_id][session_type][be_id] = *cfg_data;
-
-	/*
-	 * Store the BE ID of the configuration information set as the latest so
-	 * the get mixer control knows what to return.
-	 */
-	last_be_id_configured[fedai_id][session_type] = be_id;
-
-done:
-	return ret;
-}
-EXPORT_SYMBOL(msm_pcm_routing_reg_stream_app_type_cfg);
-
-/**
- * msm_pcm_routing_get_stream_app_type_cfg
- *
- * Receives fedai_id, session_type, be_id, and populates app_type,
- * acdb_dev_id, & sample rate. Returns 0 on success. On failure returns
- * -EINVAL and does not alter passed values.
- *
- * fedai_id - Passed value, front end ID for which app type config is wanted
- * session_type - Passed value, session type for which app type config
- *                is wanted
- * be_id - Returned value, back end device id the app type config data is for
- * cfg_data - Returned value, configuration data used by app type config
- */
-int msm_pcm_routing_get_stream_app_type_cfg(
-	int fedai_id, int session_type, int *bedai_id,
-	struct msm_pcm_stream_app_type_cfg *cfg_data)
-{
-	int be_id;
-	int ret = 0;
-
-	if (bedai_id == NULL) {
-		pr_err("%s: Received NULL pointer for backend ID\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if (cfg_data == NULL) {
-		pr_err("%s: NULL pointer sent for cfg_data\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	} else if (!is_mm_lsm_fe_id(fedai_id)) {
-		pr_err("%s: Invalid FE ID %d\n", __func__, fedai_id);
-		ret = -EINVAL;
-		goto done;
-	} else if (session_type != SESSION_TYPE_RX &&
-		   session_type != SESSION_TYPE_TX) {
-		pr_err("%s: Invalid session type %d\n", __func__, session_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	be_id = last_be_id_configured[fedai_id][session_type];
-	if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: Invalid BE ID %d\n", __func__, be_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	*bedai_id = be_id;
-	*cfg_data = fe_dai_app_type_cfg[fedai_id][session_type][be_id];
-	pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
-		__func__, fedai_id, session_type, *bedai_id,
-		cfg_data->app_type, cfg_data->acdb_dev_id,
-		cfg_data->sample_rate);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(msm_pcm_routing_get_stream_app_type_cfg);
-
-static struct cal_block_data *msm_routing_find_topology_by_path(int path)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&cal_data->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (((struct audio_cal_info_adm_top *)cal_block->cal_info)
-			->path == path) {
-			return cal_block;
-		}
-	}
-	pr_debug("%s: Can't find topology for path %d\n", __func__, path);
-	return NULL;
-}
-
-static struct cal_block_data *msm_routing_find_topology(int path,
-							int app_type,
-							int acdb_id)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_adm_top *cal_info;
-
-	pr_debug("%s\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&cal_data->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		cal_info = (struct audio_cal_info_adm_top *)
-			cal_block->cal_info;
-		if ((cal_info->path == path)  &&
-			(cal_info->app_type == app_type) &&
-			(cal_info->acdb_id == acdb_id)) {
-			return cal_block;
-		}
-	}
-	pr_debug("%s: Can't find topology for path %d, app %d, acdb_id %d defaulting to search by path\n",
-		__func__, path, app_type, acdb_id);
-	return msm_routing_find_topology_by_path(path);
-}
-
-static int msm_routing_get_adm_topology(int fedai_id, int session_type,
-					int be_id)
-{
-	int topology = NULL_COPP_TOPOLOGY;
-	struct cal_block_data *cal_block = NULL;
-	int app_type = 0, acdb_dev_id = 0;
-
-
-	pr_debug("%s: fedai_id %d, session_type %d, be_id %d\n",
-	       __func__, fedai_id, session_type, be_id);
-
-	if (cal_data == NULL)
-		goto done;
-
-	mutex_lock(&cal_data->lock);
-
-	app_type = fe_dai_app_type_cfg[fedai_id][session_type][be_id].app_type;
-	acdb_dev_id =
-		fe_dai_app_type_cfg[fedai_id][session_type][be_id].acdb_dev_id;
-
-	cal_block = msm_routing_find_topology(session_type, app_type,
-					      acdb_dev_id);
-	if (cal_block == NULL)
-		goto unlock;
-
-	topology = ((struct audio_cal_info_adm_top *)
-		cal_block->cal_info)->topology;
-unlock:
-	mutex_unlock(&cal_data->lock);
-done:
-	pr_debug("%s: Using topology %d\n", __func__, topology);
-	return topology;
-}
-
-static uint8_t is_be_dai_extproc(int be_dai)
-{
-	if (be_dai == MSM_BACKEND_DAI_EXTPROC_RX ||
-	   be_dai == MSM_BACKEND_DAI_EXTPROC_TX ||
-	   be_dai == MSM_BACKEND_DAI_EXTPROC_EC_TX)
-		return 1;
-	else
-		return 0;
-}
-
-static void msm_pcm_routing_build_matrix(int fedai_id, int sess_type,
-					 int path_type, int perf_mode,
-					 uint32_t passthr_mode)
-{
-	int i, port_type, j, num_copps = 0;
-	struct route_payload payload;
-
-	port_type = ((path_type == ADM_PATH_PLAYBACK ||
-		      path_type == ADM_PATH_COMPRESSED_RX) ?
-		MSM_AFE_PORT_TYPE_RX : MSM_AFE_PORT_TYPE_TX);
-
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (!is_be_dai_extproc(i) &&
-		   (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
-		   (msm_bedais[i].active) &&
-		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
-			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-				unsigned long copp =
-				      session_copp_map[fedai_id][sess_type][i];
-				if (test_bit(j, &copp)) {
-					payload.port_id[num_copps] =
-							msm_bedais[i].port_id;
-					payload.copp_idx[num_copps] = j;
-					payload.app_type[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][sess_type][i]
-								.app_type;
-					payload.acdb_dev_id[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][sess_type][i]
-								.acdb_dev_id;
-					payload.sample_rate[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][sess_type][i]
-								.sample_rate;
-					num_copps++;
-				}
-			}
-		}
-	}
-
-	if (num_copps) {
-		payload.num_copps = num_copps;
-		payload.session_id = fe_dai_map[fedai_id][sess_type].strm_id;
-		adm_matrix_map(path_type, payload, perf_mode, passthr_mode);
-		msm_pcm_routng_cfg_matrix_map_pp(payload, path_type, perf_mode);
-	}
-}
-
-void msm_pcm_routing_reg_psthr_stream(int fedai_id, int dspst_id,
-				      int stream_type)
-{
-	int i, session_type, path_type, port_type;
-	u32 mode = 0;
-
-	if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
-		/* bad ID assigned in machine driver */
-		pr_err("%s: bad MM ID\n", __func__);
-		return;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
-		session_type = SESSION_TYPE_RX;
-		path_type = ADM_PATH_PLAYBACK;
-		port_type = MSM_AFE_PORT_TYPE_RX;
-	} else {
-		session_type = SESSION_TYPE_TX;
-		path_type = ADM_PATH_LIVE_REC;
-		port_type = MSM_AFE_PORT_TYPE_TX;
-	}
-
-	mutex_lock(&routing_lock);
-
-	fe_dai_map[fedai_id][session_type].strm_id = dspst_id;
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (!is_be_dai_extproc(i) &&
-		    (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
-		    (msm_bedais[i].active) &&
-		    (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
-			mode = afe_get_port_type(msm_bedais[i].port_id);
-			adm_connect_afe_port(mode, dspst_id,
-					     msm_bedais[i].port_id);
-			break;
-		}
-	}
-	mutex_unlock(&routing_lock);
-}
-
-static bool route_check_fe_id_adm_support(int fe_id)
-{
-	bool rc = true;
-
-	if ((fe_id >= MSM_FRONTEND_DAI_LSM1) &&
-		 (fe_id <= MSM_FRONTEND_DAI_LSM8)) {
-		/* fe id is listen while port is set to afe */
-		if (lsm_port_index != ADM_LSM_PORT_INDEX) {
-			pr_debug("%s: fe_id %d, lsm mux slim port %d\n",
-				__func__, fe_id, lsm_port_index);
-			rc = false;
-		}
-	}
-
-	return rc;
-}
-
-int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
-					  int dspst_id, int stream_type,
-					  uint32_t passthr_mode)
-{
-	int i, j, session_type, path_type, port_type, topology;
-	int num_copps = 0;
-	struct route_payload payload;
-	u32 channels, sample_rate;
-	u16 bit_width = 16;
-	bool is_lsm;
-
-	pr_debug("%s:fe_id[%d] perf_mode[%d] id[%d] stream_type[%d] passt[%d]",
-		 __func__, fe_id, perf_mode, dspst_id,
-		 stream_type, passthr_mode);
-	if (!is_mm_lsm_fe_id(fe_id)) {
-		/* bad ID assigned in machine driver */
-		pr_err("%s: bad MM ID %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	if (!route_check_fe_id_adm_support(fe_id)) {
-		/* ignore adm open if not supported for fe_id */
-		pr_debug("%s: No ADM support for fe id %d\n", __func__, fe_id);
-		return 0;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
-		session_type = SESSION_TYPE_RX;
-		if (passthr_mode != LEGACY_PCM)
-			path_type = ADM_PATH_COMPRESSED_RX;
-		else
-			path_type = ADM_PATH_PLAYBACK;
-		port_type = MSM_AFE_PORT_TYPE_RX;
-	} else if (stream_type == SNDRV_PCM_STREAM_CAPTURE) {
-		session_type = SESSION_TYPE_TX;
-		if ((passthr_mode != LEGACY_PCM) && (passthr_mode != LISTEN))
-			path_type = ADM_PATH_COMPRESSED_TX;
-		else
-			path_type = ADM_PATH_LIVE_REC;
-		port_type = MSM_AFE_PORT_TYPE_TX;
-	} else {
-		pr_err("%s: invalid stream type %d\n", __func__, stream_type);
-		return -EINVAL;
-	}
-
-	is_lsm = (fe_id >= MSM_FRONTEND_DAI_LSM1) &&
-			 (fe_id <= MSM_FRONTEND_DAI_LSM8);
-	mutex_lock(&routing_lock);
-
-	payload.num_copps = 0; /* only RX needs to use payload */
-	fe_dai_map[fe_id][session_type].strm_id = dspst_id;
-	/* re-enable EQ if active */
-	msm_qti_pp_send_eq_values(fe_id);
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (test_bit(fe_id, &msm_bedais[i].fe_sessions[0]))
-			msm_bedais[i].passthr_mode[fe_id] = passthr_mode;
-
-		if (!is_be_dai_extproc(i) &&
-			(afe_get_port_type(msm_bedais[i].port_id) ==
-			port_type) &&
-			(msm_bedais[i].active) &&
-			(test_bit(fe_id, &msm_bedais[i].fe_sessions[0]))) {
-			int app_type, app_type_idx, copp_idx, acdb_dev_id;
-
-			/*
-			 * check if ADM needs to be configured with different
-			 * channel mapping than backend
-			 */
-			if (!msm_bedais[i].adm_override_ch)
-				channels = msm_bedais[i].channel;
-			else
-				channels = msm_bedais[i].adm_override_ch;
-
-			bit_width = msm_routing_get_bit_width(
-						msm_bedais[i].format);
-			app_type =
-			fe_dai_app_type_cfg[fe_id][session_type][i].app_type;
-			if (app_type && is_lsm) {
-				app_type_idx =
-				msm_pcm_routing_get_lsm_app_type_idx(app_type);
-				sample_rate =
-				fe_dai_app_type_cfg[fe_id][session_type][i]
-					.sample_rate;
-				bit_width =
-				lsm_app_type_cfg[app_type_idx].bit_width;
-			} else if (app_type) {
-				app_type_idx =
-					msm_pcm_routing_get_app_type_idx(
-						app_type);
-				sample_rate =
-			fe_dai_app_type_cfg[fe_id][session_type][i].sample_rate;
-				bit_width =
-					app_type_cfg[app_type_idx].bit_width;
-			} else {
-				sample_rate = msm_bedais[i].sample_rate;
-			}
-			acdb_dev_id =
-			fe_dai_app_type_cfg[fe_id][session_type][i].acdb_dev_id;
-			topology = msm_routing_get_adm_topology(fe_id,
-								session_type,
-								i);
-			if ((passthr_mode == COMPRESSED_PASSTHROUGH_DSD)
-			     || (passthr_mode ==
-			     COMPRESSED_PASSTHROUGH_GEN))
-				topology = COMPRESSED_PASSTHROUGH_NONE_TOPOLOGY;
-			pr_debug("%s: Before adm open topology %d\n", __func__,
-				topology);
-
-			copp_idx =
-				adm_open(msm_bedais[i].port_id,
-					 path_type, sample_rate, channels,
-					 topology, perf_mode, bit_width,
-					 app_type, acdb_dev_id);
-			if ((copp_idx < 0) ||
-				(copp_idx >= MAX_COPPS_PER_PORT)) {
-				pr_err("%s:adm open failed coppid:%d\n",
-				__func__, copp_idx);
-				mutex_unlock(&routing_lock);
-				return -EINVAL;
-			}
-			pr_debug("%s: set idx bit of fe:%d, type: %d, be:%d\n",
-				 __func__, fe_id, session_type, i);
-			set_bit(copp_idx,
-				&session_copp_map[fe_id][session_type][i]);
-
-			if (msm_is_resample_needed(
-				sample_rate,
-				msm_bedais[i].sample_rate))
-				adm_copp_mfc_cfg(
-					msm_bedais[i].port_id, copp_idx,
-					msm_bedais[i].sample_rate);
-
-			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-				unsigned long copp =
-				session_copp_map[fe_id][session_type][i];
-				if (test_bit(j, &copp)) {
-					payload.port_id[num_copps] =
-					msm_bedais[i].port_id;
-					payload.copp_idx[num_copps] = j;
-					payload.app_type[num_copps] =
-						fe_dai_app_type_cfg
-							[fe_id][session_type][i]
-								.app_type;
-					payload.acdb_dev_id[num_copps] =
-						fe_dai_app_type_cfg
-							[fe_id][session_type][i]
-								.acdb_dev_id;
-					payload.sample_rate[num_copps] =
-						fe_dai_app_type_cfg
-							[fe_id][session_type][i]
-								.sample_rate;
-					num_copps++;
-				}
-			}
-			if (passthr_mode != COMPRESSED_PASSTHROUGH_DSD
-			    && passthr_mode !=
-			    COMPRESSED_PASSTHROUGH_GEN) {
-				msm_routing_send_device_pp_params(
-				msm_bedais[i].port_id,
-				copp_idx, fe_id);
-			}
-		}
-	}
-	if (num_copps) {
-		payload.num_copps = num_copps;
-		payload.session_id = fe_dai_map[fe_id][session_type].strm_id;
-		adm_matrix_map(path_type, payload, perf_mode, passthr_mode);
-		msm_pcm_routng_cfg_matrix_map_pp(payload, path_type, perf_mode);
-	}
-	mutex_unlock(&routing_lock);
-	return 0;
-}
-
-static u32 msm_pcm_routing_get_voc_sessionid(u16 val)
-{
-	u32 session_id;
-
-	switch (val) {
-	case MSM_FRONTEND_DAI_CS_VOICE:
-		session_id = voc_get_session_id(VOICE_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOLTE:
-		session_id = voc_get_session_id(VOLTE_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOWLAN:
-		session_id = voc_get_session_id(VOWLAN_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOICE2:
-		session_id = voc_get_session_id(VOICE2_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_QCHAT:
-		session_id = voc_get_session_id(QCHAT_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOIP:
-		session_id = voc_get_session_id(VOIP_SESSION_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOICEMMODE1:
-		session_id = voc_get_session_id(VOICEMMODE1_NAME);
-		break;
-	case MSM_FRONTEND_DAI_VOICEMMODE2:
-		session_id = voc_get_session_id(VOICEMMODE2_NAME);
-		break;
-	default:
-		session_id = 0;
-	}
-
-	pr_debug("%s session_id 0x%x", __func__, session_id);
-	return session_id;
-}
-
-static int msm_pcm_routing_channel_mixer(int fe_id, bool perf_mode,
-				int dspst_id, int stream_type)
-{
-	int copp_idx = 0;
-	int sess_type = 0;
-	int i = 0, j = 0, be_id;
-	int ret = 0;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return 0;
-	}
-
-	if (!(channel_mixer[fe_id].enable)) {
-		pr_debug("%s: channel mixer not enabled for FE %d\n",
-			__func__, fe_id);
-		return 0;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK)
-		sess_type = SESSION_TYPE_RX;
-	else
-		sess_type = SESSION_TYPE_TX;
-
-	for (i = 0; i < ADM_MAX_CHANNELS && channel_input[fe_id][i] > 0;
-		++i) {
-		be_id = channel_input[fe_id][i] - 1;
-		channel_mixer[fe_id].input_channels[i] =
-						msm_bedais[be_id].channel;
-
-		if ((msm_bedais[be_id].active) &&
-			test_bit(fe_id,
-			&msm_bedais[be_id].fe_sessions[0])) {
-			unsigned long copp =
-				session_copp_map[fe_id][sess_type][be_id];
-			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-				if (test_bit(j, &copp)) {
-					copp_idx = j;
-					break;
-				}
-			}
-
-			pr_debug("%s: fe %d, be %d, channel %d, copp %d\n",
-				__func__,
-				fe_id, be_id, msm_bedais[be_id].channel,
-				copp_idx);
-			ret = adm_programable_channel_mixer(
-					msm_bedais[be_id].port_id,
-					copp_idx, dspst_id, sess_type,
-					channel_mixer + fe_id, i);
-		}
-	}
-
-	return ret;
-}
-
-int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
-					int dspst_id, int stream_type)
-{
-	int i, j, session_type, path_type, port_type, topology, num_copps = 0;
-	struct route_payload payload;
-	u32 channels, sample_rate;
-	uint16_t bits_per_sample = 16;
-	uint32_t passthr_mode = LEGACY_PCM;
-	int ret = 0;
-
-	if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
-		/* bad ID assigned in machine driver */
-		pr_err("%s: bad MM ID %d\n", __func__, fedai_id);
-		return -EINVAL;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
-		session_type = SESSION_TYPE_RX;
-		path_type = ADM_PATH_PLAYBACK;
-		port_type = MSM_AFE_PORT_TYPE_RX;
-	} else {
-		session_type = SESSION_TYPE_TX;
-		path_type = ADM_PATH_LIVE_REC;
-		port_type = MSM_AFE_PORT_TYPE_TX;
-	}
-
-	mutex_lock(&routing_lock);
-
-	payload.num_copps = 0; /* only RX needs to use payload */
-	fe_dai_map[fedai_id][session_type].strm_id = dspst_id;
-	fe_dai_map[fedai_id][session_type].perf_mode = perf_mode;
-
-	/* re-enable EQ if active */
-	msm_qti_pp_send_eq_values(fedai_id);
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (!is_be_dai_extproc(i) &&
-		   (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
-		   (msm_bedais[i].active) &&
-		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
-			int app_type, app_type_idx, copp_idx, acdb_dev_id;
-			/*
-			 * check if ADM needs to be configured with different
-			 * channel mapping than backend
-			 */
-			if (!msm_bedais[i].adm_override_ch)
-				channels = msm_bedais[i].channel;
-			else
-				channels = msm_bedais[i].adm_override_ch;
-			msm_bedais[i].passthr_mode[fedai_id] =
-				LEGACY_PCM;
-
-			bits_per_sample = msm_routing_get_bit_width(
-						msm_bedais[i].format);
-
-			app_type =
-			fe_dai_app_type_cfg[fedai_id][session_type][i].app_type;
-			if (app_type) {
-				app_type_idx =
-				msm_pcm_routing_get_app_type_idx(app_type);
-				sample_rate =
-				fe_dai_app_type_cfg[fedai_id][session_type][i]
-					.sample_rate;
-				bits_per_sample =
-					app_type_cfg[app_type_idx].bit_width;
-			} else
-				sample_rate = msm_bedais[i].sample_rate;
-
-			acdb_dev_id =
-			fe_dai_app_type_cfg[fedai_id][session_type][i]
-				.acdb_dev_id;
-			topology = msm_routing_get_adm_topology(fedai_id,
-								session_type,
-								i);
-			copp_idx = adm_open(msm_bedais[i].port_id, path_type,
-					    sample_rate, channels, topology,
-					    perf_mode, bits_per_sample,
-					    app_type, acdb_dev_id);
-			if ((copp_idx < 0) ||
-				(copp_idx >= MAX_COPPS_PER_PORT)) {
-				pr_err("%s: adm open failed copp_idx:%d\n",
-					__func__, copp_idx);
-				mutex_unlock(&routing_lock);
-				return -EINVAL;
-			}
-			pr_debug("%s: setting idx bit of fe:%d, type: %d, be:%d\n",
-				 __func__, fedai_id, session_type, i);
-			set_bit(copp_idx,
-				&session_copp_map[fedai_id][session_type][i]);
-
-			if (msm_is_resample_needed(
-				sample_rate,
-				msm_bedais[i].sample_rate))
-				adm_copp_mfc_cfg(
-					msm_bedais[i].port_id, copp_idx,
-					msm_bedais[i].sample_rate);
-
-			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-				unsigned long copp =
-				    session_copp_map[fedai_id][session_type][i];
-				if (test_bit(j, &copp)) {
-					payload.port_id[num_copps] =
-							msm_bedais[i].port_id;
-					payload.copp_idx[num_copps] = j;
-					payload.app_type[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][session_type]
-							[i].app_type;
-					payload.acdb_dev_id[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][session_type]
-							[i].acdb_dev_id;
-					payload.sample_rate[num_copps] =
-						fe_dai_app_type_cfg
-							[fedai_id][session_type]
-							[i].sample_rate;
-					num_copps++;
-				}
-			}
-			if ((perf_mode == LEGACY_PCM_MODE) &&
-				(msm_bedais[i].passthr_mode[fedai_id] ==
-				LEGACY_PCM))
-				msm_pcm_routing_cfg_pp(msm_bedais[i].port_id,
-						       copp_idx, topology,
-						       channels);
-		}
-	}
-	if (num_copps) {
-		payload.num_copps = num_copps;
-		payload.session_id = fe_dai_map[fedai_id][session_type].strm_id;
-		adm_matrix_map(path_type, payload, perf_mode, passthr_mode);
-		msm_pcm_routng_cfg_matrix_map_pp(payload, path_type, perf_mode);
-	}
-
-	ret = msm_pcm_routing_channel_mixer(fedai_id, perf_mode,
-				dspst_id, stream_type);
-	mutex_unlock(&routing_lock);
-	return ret;
-}
-
-int msm_pcm_routing_reg_phy_stream_v2(int fedai_id, int perf_mode,
-				      int dspst_id, int stream_type,
-				      struct msm_pcm_routing_evt event_info)
-{
-	if (msm_pcm_routing_reg_phy_stream(fedai_id, perf_mode, dspst_id,
-				       stream_type)) {
-		pr_err("%s: failed to reg phy stream\n", __func__);
-		return -EINVAL;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK)
-		fe_dai_map[fedai_id][SESSION_TYPE_RX].event_info = event_info;
-	else
-		fe_dai_map[fedai_id][SESSION_TYPE_TX].event_info = event_info;
-	return 0;
-}
-
-void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
-{
-	int i, port_type, session_type, path_type, topology;
-	struct msm_pcm_routing_fdai_data *fdai;
-
-	if (!is_mm_lsm_fe_id(fedai_id)) {
-		/* bad ID assigned in machine driver */
-		pr_err("%s: bad MM ID\n", __func__);
-		return;
-	}
-
-	if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
-		port_type = MSM_AFE_PORT_TYPE_RX;
-		session_type = SESSION_TYPE_RX;
-		path_type = ADM_PATH_PLAYBACK;
-	} else {
-		port_type = MSM_AFE_PORT_TYPE_TX;
-		session_type = SESSION_TYPE_TX;
-		path_type = ADM_PATH_LIVE_REC;
-	}
-
-	mutex_lock(&routing_lock);
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (!is_be_dai_extproc(i) &&
-		   (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
-		   (msm_bedais[i].active) &&
-		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
-			int idx;
-			unsigned long copp =
-				session_copp_map[fedai_id][session_type][i];
-			fdai = &fe_dai_map[fedai_id][session_type];
-
-			for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
-				if (test_bit(idx, &copp))
-					break;
-
-			if (idx >= MAX_COPPS_PER_PORT || idx < 0) {
-				pr_debug("%s: copp idx is invalid, exiting\n",
-								__func__);
-				continue;
-			}
-			topology = adm_get_topology_for_port_copp_idx(
-					msm_bedais[i].port_id, idx);
-			adm_close(msm_bedais[i].port_id, fdai->perf_mode, idx);
-			pr_debug("%s:copp:%ld,idx bit fe:%d,type:%d,be:%d\n",
-				 __func__, copp, fedai_id, session_type, i);
-			clear_bit(idx,
-				  &session_copp_map[fedai_id][session_type][i]);
-			if ((topology == DOLBY_ADM_COPP_TOPOLOGY_ID ||
-				topology == DS2_ADM_COPP_TOPOLOGY_ID) &&
-			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
-			    (msm_bedais[i].passthr_mode[fedai_id] ==
-					LEGACY_PCM))
-				msm_pcm_routing_deinit_pp(msm_bedais[i].port_id,
-							  topology);
-		}
-	}
-
-	fe_dai_map[fedai_id][session_type].strm_id = INVALID_SESSION;
-	fe_dai_map[fedai_id][session_type].be_srate = 0;
-	mutex_unlock(&routing_lock);
-}
-
-/* Check if FE/BE route is set */
-static bool msm_pcm_routing_route_is_set(u16 be_id, u16 fe_id)
-{
-	bool rc = false;
-
-	if (!is_mm_lsm_fe_id(fe_id)) {
-		/* recheck FE ID in the mixer control defined in this file */
-		pr_err("%s: bad MM ID\n", __func__);
-		return rc;
-	}
-
-	if (test_bit(fe_id, &msm_bedais[be_id].fe_sessions[0]))
-		rc = true;
-
-	return rc;
-}
-
-static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
-{
-	int session_type, path_type, topology;
-	u32 channels, sample_rate;
-	uint16_t bits_per_sample = 16;
-	struct msm_pcm_routing_fdai_data *fdai;
-	uint32_t passthr_mode;
-	bool is_lsm;
-
-	pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set);
-
-	if (!is_mm_lsm_fe_id(val)) {
-		/* recheck FE ID in the mixer control defined in this file */
-		pr_err("%s: bad MM ID\n", __func__);
-		return;
-	}
-
-	if (!route_check_fe_id_adm_support(val)) {
-		/* ignore adm open if not supported for fe_id */
-		pr_debug("%s: No ADM support for fe id %d\n", __func__, val);
-		return;
-	}
-
-	passthr_mode = msm_bedais[reg].passthr_mode[val];
-	if (afe_get_port_type(msm_bedais[reg].port_id) ==
-		MSM_AFE_PORT_TYPE_RX) {
-		session_type = SESSION_TYPE_RX;
-		if (passthr_mode != LEGACY_PCM)
-			path_type = ADM_PATH_COMPRESSED_RX;
-		else
-			path_type = ADM_PATH_PLAYBACK;
-	} else {
-		session_type = SESSION_TYPE_TX;
-		if (passthr_mode != LEGACY_PCM)
-			path_type = ADM_PATH_COMPRESSED_TX;
-		else
-			path_type = ADM_PATH_LIVE_REC;
-	}
-	is_lsm = (val >= MSM_FRONTEND_DAI_LSM1) &&
-			 (val <= MSM_FRONTEND_DAI_LSM8);
-
-	mutex_lock(&routing_lock);
-	if (set) {
-		if (!test_bit(val, &msm_bedais[reg].fe_sessions[0]) &&
-			((msm_bedais[reg].port_id == VOICE_PLAYBACK_TX) ||
-			(msm_bedais[reg].port_id == VOICE2_PLAYBACK_TX)))
-			voc_start_playback(set, msm_bedais[reg].port_id);
-
-		set_bit(val, &msm_bedais[reg].fe_sessions[0]);
-		fdai = &fe_dai_map[val][session_type];
-		if (msm_bedais[reg].active && fdai->strm_id !=
-			INVALID_SESSION) {
-			int app_type, app_type_idx, copp_idx, acdb_dev_id;
-			/*
-			 * check if ADM needs to be configured with different
-			 * channel mapping than backend
-			 */
-			if (!msm_bedais[reg].adm_override_ch)
-				channels = msm_bedais[reg].channel;
-			else
-				channels = msm_bedais[reg].adm_override_ch;
-			if (session_type == SESSION_TYPE_TX &&
-			    fdai->be_srate &&
-			    (fdai->be_srate != msm_bedais[reg].sample_rate)) {
-				pr_debug("%s: flush strm %d diff BE rates\n",
-					__func__, fdai->strm_id);
-
-				if (fdai->event_info.event_func)
-					fdai->event_info.event_func(
-						MSM_PCM_RT_EVT_BUF_RECFG,
-						fdai->event_info.priv_data);
-				fdai->be_srate = 0; /* might not need it */
-			}
-
-			bits_per_sample = msm_routing_get_bit_width(
-						msm_bedais[reg].format);
-
-			app_type =
-			fe_dai_app_type_cfg[val][session_type][reg].app_type;
-			if (app_type && is_lsm) {
-				app_type_idx =
-				msm_pcm_routing_get_lsm_app_type_idx(app_type);
-				sample_rate =
-				fe_dai_app_type_cfg[val][session_type][reg]
-					.sample_rate;
-				bits_per_sample =
-				lsm_app_type_cfg[app_type_idx].bit_width;
-			} else if (app_type) {
-				app_type_idx =
-				msm_pcm_routing_get_app_type_idx(app_type);
-				sample_rate =
-				fe_dai_app_type_cfg[val][session_type][reg]
-					.sample_rate;
-				bits_per_sample =
-					app_type_cfg[app_type_idx].bit_width;
-			} else
-				sample_rate = msm_bedais[reg].sample_rate;
-
-			topology = msm_routing_get_adm_topology(val,
-								session_type,
-								reg);
-			acdb_dev_id =
-			fe_dai_app_type_cfg[val][session_type][reg].acdb_dev_id;
-			copp_idx = adm_open(msm_bedais[reg].port_id, path_type,
-					    sample_rate, channels, topology,
-					    fdai->perf_mode, bits_per_sample,
-					    app_type, acdb_dev_id);
-			if ((copp_idx < 0) ||
-			    (copp_idx >= MAX_COPPS_PER_PORT)) {
-				pr_err("%s: adm open failed\n", __func__);
-				mutex_unlock(&routing_lock);
-				return;
-			}
-			pr_debug("%s: setting idx bit of fe:%d, type: %d, be:%d\n",
-				 __func__, val, session_type, reg);
-			set_bit(copp_idx,
-				&session_copp_map[val][session_type][reg]);
-
-			if (msm_is_resample_needed(
-				sample_rate,
-				msm_bedais[reg].sample_rate))
-				adm_copp_mfc_cfg(
-					msm_bedais[reg].port_id, copp_idx,
-					msm_bedais[reg].sample_rate);
-
-			if (session_type == SESSION_TYPE_RX &&
-			    fdai->event_info.event_func)
-				fdai->event_info.event_func(
-					MSM_PCM_RT_EVT_DEVSWITCH,
-					fdai->event_info.priv_data);
-
-			msm_pcm_routing_build_matrix(val, session_type,
-						     path_type,
-						     fdai->perf_mode,
-						     passthr_mode);
-			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
-				(passthr_mode == LEGACY_PCM))
-				msm_pcm_routing_cfg_pp(msm_bedais[reg].port_id,
-						       copp_idx, topology,
-						       channels);
-		}
-	} else {
-		if (test_bit(val, &msm_bedais[reg].fe_sessions[0]) &&
-			((msm_bedais[reg].port_id == VOICE_PLAYBACK_TX) ||
-			(msm_bedais[reg].port_id == VOICE2_PLAYBACK_TX)))
-			voc_start_playback(set, msm_bedais[reg].port_id);
-		clear_bit(val, &msm_bedais[reg].fe_sessions[0]);
-		fdai = &fe_dai_map[val][session_type];
-		if (msm_bedais[reg].active && fdai->strm_id !=
-			INVALID_SESSION) {
-			int idx;
-			int port_id;
-			unsigned long copp =
-				session_copp_map[val][session_type][reg];
-			for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
-				if (test_bit(idx, &copp))
-					break;
-
-			port_id = msm_bedais[reg].port_id;
-			topology = adm_get_topology_for_port_copp_idx(port_id,
-								      idx);
-			adm_close(msm_bedais[reg].port_id, fdai->perf_mode,
-				  idx);
-			pr_debug("%s: copp: %ld, reset idx bit fe:%d, type: %d, be:%d topology=0x%x\n",
-				 __func__, copp, val, session_type, reg,
-				 topology);
-			clear_bit(idx,
-				  &session_copp_map[val][session_type][reg]);
-			if ((topology == DOLBY_ADM_COPP_TOPOLOGY_ID ||
-				topology == DS2_ADM_COPP_TOPOLOGY_ID) &&
-			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
-			    (passthr_mode == LEGACY_PCM))
-				msm_pcm_routing_deinit_pp(
-						msm_bedais[reg].port_id,
-						topology);
-			msm_pcm_routing_build_matrix(val, session_type,
-						     path_type,
-						     fdai->perf_mode,
-						     passthr_mode);
-		}
-	}
-	if ((msm_bedais[reg].port_id == VOICE_RECORD_RX)
-			|| (msm_bedais[reg].port_id == VOICE_RECORD_TX))
-		voc_start_record(msm_bedais[reg].port_id, set, voc_session_id);
-
-	mutex_unlock(&routing_lock);
-}
-
-static int msm_routing_get_audio_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-	ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-
-	if (ucontrol->value.integer.value[0] &&
-	   msm_pcm_routing_route_is_set(mc->reg, mc->shift) == false) {
-		msm_pcm_routing_process_audio(mc->reg, mc->shift, 1);
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-			update);
-	} else if (!ucontrol->value.integer.value[0] &&
-		  msm_pcm_routing_route_is_set(mc->reg, mc->shift) == true) {
-		msm_pcm_routing_process_audio(mc->reg, mc->shift, 0);
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-			update);
-	}
-
-	return 1;
-}
-
-static int msm_routing_get_listen_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-		ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_routing_put_listen_mixer(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-		ucontrol->value.integer.value[0]);
-
-	if (ucontrol->value.integer.value[0]) {
-		if (msm_pcm_routing_route_is_set(mc->reg, mc->shift) == false)
-			msm_pcm_routing_process_audio(mc->reg, mc->shift, 1);
-		snd_soc_dapm_mixer_update_power(widget->dapm,
-						kcontrol, 1, update);
-	} else if (!ucontrol->value.integer.value[0]) {
-		if (msm_pcm_routing_route_is_set(mc->reg, mc->shift) == true)
-			msm_pcm_routing_process_audio(mc->reg, mc->shift, 0);
-		snd_soc_dapm_mixer_update_power(widget->dapm,
-						kcontrol, 0, update);
-	}
-
-	return 1;
-}
-
-static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set)
-{
-	u32 session_id = 0;
-	u16 path_type;
-	struct media_format_info voc_be_media_format;
-
-	pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set);
-
-	session_id = msm_pcm_routing_get_voc_sessionid(val);
-
-	pr_debug("%s: FE DAI 0x%x session_id 0x%x\n",
-		__func__, val, session_id);
-
-	mutex_lock(&routing_lock);
-
-	if (set)
-		set_bit(val, &msm_bedais[reg].fe_sessions[0]);
-	else
-		clear_bit(val, &msm_bedais[reg].fe_sessions[0]);
-
-	if (val == MSM_FRONTEND_DAI_DTMF_RX &&
-	    afe_get_port_type(msm_bedais[reg].port_id) ==
-						MSM_AFE_PORT_TYPE_RX) {
-		pr_debug("%s(): set=%d port id=0x%x for dtmf generation\n",
-			 __func__, set, msm_bedais[reg].port_id);
-		afe_set_dtmf_gen_rx_portid(msm_bedais[reg].port_id, set);
-	}
-
-	if (afe_get_port_type(msm_bedais[reg].port_id) ==
-						MSM_AFE_PORT_TYPE_RX)
-		path_type = RX_PATH;
-	else
-		path_type = TX_PATH;
-
-	if (set) {
-		if (msm_bedais[reg].active) {
-			voc_set_route_flag(session_id, path_type, 1);
-
-			memset(&voc_be_media_format, 0,
-			       sizeof(struct media_format_info));
-
-			voc_be_media_format.port_id = msm_bedais[reg].port_id;
-			voc_be_media_format.num_channels =
-						msm_bedais[reg].channel;
-			voc_be_media_format.sample_rate =
-						msm_bedais[reg].sample_rate;
-			voc_be_media_format.bits_per_sample =
-						msm_bedais[reg].format;
-			/* Defaulting this to 1 for voice call usecases */
-			voc_be_media_format.channel_mapping[0] = 1;
-
-			voc_set_device_config(session_id, path_type,
-					      &voc_be_media_format);
-
-			if (voc_get_route_flag(session_id, TX_PATH) &&
-				voc_get_route_flag(session_id, RX_PATH))
-				voc_enable_device(session_id);
-		} else {
-			pr_debug("%s BE is not active\n", __func__);
-		}
-	} else {
-		voc_set_route_flag(session_id, path_type, 0);
-		voc_disable_device(session_id);
-	}
-
-	mutex_unlock(&routing_lock);
-
-}
-
-static int msm_routing_get_voice_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	mutex_lock(&routing_lock);
-
-	if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	mutex_unlock(&routing_lock);
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-			ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_routing_put_voice_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-
-	if (ucontrol->value.integer.value[0]) {
-		msm_pcm_routing_process_voice(mc->reg, mc->shift, 1);
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	} else {
-		msm_pcm_routing_process_voice(mc->reg, mc->shift, 0);
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	}
-
-	return 1;
-}
-
-static int msm_routing_get_voice_stub_mixer(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-
-	mutex_lock(&routing_lock);
-
-	if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	mutex_unlock(&routing_lock);
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-		ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_routing_put_voice_stub_mixer(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-
-	if (ucontrol->value.integer.value[0]) {
-		mutex_lock(&routing_lock);
-		set_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]);
-		mutex_unlock(&routing_lock);
-
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	} else {
-		mutex_lock(&routing_lock);
-		clear_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions[0]);
-		mutex_unlock(&routing_lock);
-
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	}
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-		ucontrol->value.integer.value[0]);
-
-	return 1;
-}
-
-/*
- * Return the mapping between port ID and backend ID to enable the AFE callback
- * to determine the acdb_dev_id from the port id
- */
-int msm_pcm_get_be_id_from_port_id(int port_id)
-{
-	int i;
-	int be_id = -EINVAL;
-
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (msm_bedais[i].port_id == port_id) {
-			be_id = i;
-			break;
-		}
-	}
-
-	return be_id;
-}
-
-/*
- * Return the registered dev_acdb_id given a port ID to enable identifying the
- * correct AFE calibration information by comparing the header information.
- */
-static int msm_pcm_get_dev_acdb_id_by_port_id(int port_id)
-{
-	int acdb_id = -EINVAL;
-	int i = 0;
-	int session;
-	int port_type = afe_get_port_type(port_id);
-	int be_id = msm_pcm_get_be_id_from_port_id(port_id);
-
-	pr_debug("%s:port_id %d be_id %d, port_type 0x%x\n",
-		  __func__, port_id, be_id, port_type);
-
-	if (port_type == MSM_AFE_PORT_TYPE_TX) {
-		session = SESSION_TYPE_TX;
-	} else if (port_type == MSM_AFE_PORT_TYPE_RX) {
-		session = SESSION_TYPE_RX;
-	} else {
-		pr_err("%s: Invalid port type %d\n", __func__, port_type);
-		acdb_id = -EINVAL;
-		goto exit;
-	}
-
-	if (be_id < 0) {
-		pr_err("%s: Error getting backend id %d\n", __func__, be_id);
-		goto exit;
-	}
-
-	mutex_lock(&routing_lock);
-	i = find_first_bit(&msm_bedais[be_id].fe_sessions[0],
-			   MSM_FRONTEND_DAI_MAX);
-	if (i < MSM_FRONTEND_DAI_MAX)
-		acdb_id = fe_dai_app_type_cfg[i][session][be_id].acdb_dev_id;
-
-	pr_debug("%s: FE[%d] session[%d] BE[%d] acdb_id(%d)\n",
-		 __func__, i, session, be_id, acdb_id);
-	mutex_unlock(&routing_lock);
-exit:
-	return acdb_id;
-}
-
-static int msm_routing_get_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = fm_switch_enable;
-	pr_debug("%s: FM Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: FM Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	fm_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_hfp_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = hfp_switch_enable;
-	pr_debug("%s: HFP Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_hfp_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: HFP Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
-						1, update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
-						0, update);
-	hfp_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_int0_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = int0_mi2s_switch_enable;
-	pr_debug("%s: INT0 MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_int0_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: INT0 MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	int0_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_int4_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = int4_mi2s_switch_enable;
-	pr_debug("%s: INT4 MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_int4_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: INT4 MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	int4_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_usb_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = usb_switch_enable;
-	pr_debug("%s: HFP Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_usb_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: USB Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
-						1, update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
-						0, update);
-	usb_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_pri_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = pri_mi2s_switch_enable;
-	pr_debug("%s: PRI MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_pri_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: PRI MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	pri_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_sec_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = sec_mi2s_switch_enable;
-	pr_debug("%s: SEC MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_sec_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: SEC MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	sec_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_tert_mi2s_switch_mixer(
-				struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = tert_mi2s_switch_enable;
-	pr_debug("%s: TERT MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_tert_mi2s_switch_mixer(
-				struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: TERT MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	tert_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_quat_mi2s_switch_mixer(
-				struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = quat_mi2s_switch_enable;
-	pr_debug("%s: QUAT MI2S Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_quat_mi2s_switch_mixer(
-				struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: QUAT MI2S Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	quat_mi2s_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_get_fm_pcmrx_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = fm_pcmrx_switch_enable;
-	pr_debug("%s: FM Switch enable %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_put_fm_pcmrx_switch_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct snd_soc_dapm_update *update = NULL;
-
-	pr_debug("%s: FM Switch enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 1,
-						update);
-	else
-		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, 0,
-						update);
-	fm_pcmrx_switch_enable = ucontrol->value.integer.value[0];
-	return 1;
-}
-
-static int msm_routing_lsm_port_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = lsm_port_index;
-	return 0;
-}
-
-static int msm_routing_lsm_port_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	int mux = ucontrol->value.enumerated.item[0];
-	int lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX;
-
-	if (mux >= e->items) {
-		pr_err("%s: Invalid mux value %d\n", __func__, mux);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: LSM enable %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX;
-		break;
-	case 2:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX;
-		break;
-	case 3:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX;
-		break;
-	case 4:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX;
-		break;
-	case 5:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX;
-		break;
-	case 6:
-		lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX;
-		break;
-	case 7:
-		lsm_port = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case 8:
-		lsm_port = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	case 9:
-		lsm_port = ADM_LSM_PORT_ID;
-		break;
-	case 10:
-		lsm_port = AFE_PORT_ID_INT3_MI2S_TX;
-		break;
-	default:
-		pr_err("Default lsm port");
-		break;
-	}
-	set_lsm_port(lsm_port);
-	lsm_port_index = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_routing_lsm_func_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	u16 port_id;
-	enum afe_mad_type mad_type;
-
-	pr_debug("%s: enter\n", __func__);
-	for (i = 0; i < ARRAY_SIZE(lsm_port_text); i++)
-		if (!strnstr(kcontrol->id.name, lsm_port_text[i],
-			    strlen(lsm_port_text[i])))
-			break;
-
-	if (i-- == ARRAY_SIZE(lsm_port_text)) {
-		WARN(1, "Invalid id name %s\n", kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	port_id = i * 2 + 1 + SLIMBUS_0_RX;
-
-	/*Check for Tertiary/Quaternary/INT3 TX port*/
-	if (strnstr(kcontrol->id.name, lsm_port_text[7],
-			strlen(lsm_port_text[7])))
-		port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-
-	if (strnstr(kcontrol->id.name, lsm_port_text[8],
-			strlen(lsm_port_text[8])))
-		port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-
-	if (strnstr(kcontrol->id.name, lsm_port_text[10],
-			strlen(lsm_port_text[10])))
-		port_id = AFE_PORT_ID_INT3_MI2S_TX;
-
-	mad_type = afe_port_get_mad_type(port_id);
-	pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
-		 mad_type);
-	switch (mad_type) {
-	case MAD_HW_NONE:
-		ucontrol->value.integer.value[0] = MADNONE;
-		break;
-	case MAD_HW_AUDIO:
-		ucontrol->value.integer.value[0] = MADAUDIO;
-		break;
-	case MAD_HW_BEACON:
-		ucontrol->value.integer.value[0] = MADBEACON;
-		break;
-	case MAD_HW_ULTRASOUND:
-		ucontrol->value.integer.value[0] = MADULTRASOUND;
-		break;
-	case MAD_SW_AUDIO:
-		ucontrol->value.integer.value[0] = MADSWAUDIO;
-	break;
-	default:
-		WARN(1, "Unknown\n");
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int msm_routing_lsm_func_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	int i;
-	u16 port_id;
-	enum afe_mad_type mad_type;
-
-	pr_debug("%s: enter\n", __func__);
-	for (i = 0; i < ARRAY_SIZE(lsm_port_text); i++)
-		if (strnstr(kcontrol->id.name, lsm_port_text[i],
-			    strlen(lsm_port_text[i])))
-			break;
-
-	if (i-- == ARRAY_SIZE(lsm_port_text)) {
-		WARN(1, "Invalid id name %s\n", kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	port_id = i * 2 + 1 + SLIMBUS_0_RX;
-	switch (ucontrol->value.integer.value[0]) {
-	case MADNONE:
-		mad_type = MAD_HW_NONE;
-		break;
-	case MADAUDIO:
-		mad_type = MAD_HW_AUDIO;
-		break;
-	case MADBEACON:
-		mad_type = MAD_HW_BEACON;
-		break;
-	case MADULTRASOUND:
-		mad_type = MAD_HW_ULTRASOUND;
-		break;
-	case MADSWAUDIO:
-		mad_type = MAD_SW_AUDIO;
-		break;
-	default:
-		WARN(1, "Unknown\n");
-		return -EINVAL;
-	}
-
-	/*Check for Tertiary/Quaternary/INT3 TX port*/
-	if (strnstr(kcontrol->id.name, lsm_port_text[7],
-			strlen(lsm_port_text[7])))
-		port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-
-	if (strnstr(kcontrol->id.name, lsm_port_text[8],
-			strlen(lsm_port_text[8])))
-		port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-
-	if (strnstr(kcontrol->id.name, lsm_port_text[10],
-			strlen(lsm_port_text[10])))
-		port_id = AFE_PORT_ID_INT3_MI2S_TX;
-
-	pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
-		 mad_type);
-	return afe_port_set_mad_type(port_id, mad_type);
-}
-
-static const char *const adm_override_chs_text[] = {"Zero", "One", "Two"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(slim_7_rx_adm_override_chs,
-				adm_override_chs_text);
-
-static int msm_routing_adm_get_backend_idx(struct snd_kcontrol *kcontrol)
-{
-	int backend_id;
-
-	if (strnstr(kcontrol->id.name, "SLIM7_RX", sizeof("SLIM7_RX"))) {
-		backend_id = MSM_BACKEND_DAI_SLIMBUS_7_RX;
-	} else {
-		pr_err("%s: unsupported backend id: %s",
-			__func__, kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	return backend_id;
-}
-static int msm_routing_adm_channel_config_get(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int backend_id = msm_routing_adm_get_backend_idx(kcontrol);
-
-	if (backend_id >= 0) {
-		mutex_lock(&routing_lock);
-		ucontrol->value.integer.value[0] =
-			 msm_bedais[backend_id].adm_override_ch;
-		pr_debug("%s: adm channel count %ld for BE:%d\n", __func__,
-			 ucontrol->value.integer.value[0], backend_id);
-		 mutex_unlock(&routing_lock);
-	}
-
-	return 0;
-}
-
-static int msm_routing_adm_channel_config_put(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int backend_id = msm_routing_adm_get_backend_idx(kcontrol);
-
-	if (backend_id >= 0) {
-		mutex_lock(&routing_lock);
-		msm_bedais[backend_id].adm_override_ch =
-				 ucontrol->value.integer.value[0];
-		pr_debug("%s:updating BE :%d  adm channels: %d\n",
-			  __func__, backend_id,
-			  msm_bedais[backend_id].adm_override_ch);
-		mutex_unlock(&routing_lock);
-	}
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new adm_channel_config_controls[] = {
-	SOC_ENUM_EXT("SLIM7_RX ADM Channels", slim_7_rx_adm_override_chs,
-			msm_routing_adm_channel_config_get,
-			msm_routing_adm_channel_config_put),
-};
-
-static int msm_routing_slim_0_rx_aanc_mux_get(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-
-	mutex_lock(&routing_lock);
-	ucontrol->value.integer.value[0] = slim0_rx_aanc_fb_port;
-	mutex_unlock(&routing_lock);
-	pr_debug("%s: AANC Mux Port %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-};
-
-static int msm_routing_slim_0_rx_aanc_mux_put(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct aanc_data aanc_info;
-
-	mutex_lock(&routing_lock);
-	memset(&aanc_info, 0x00, sizeof(aanc_info));
-	pr_debug("%s: AANC Mux Port %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	slim0_rx_aanc_fb_port = ucontrol->value.integer.value[0];
-	if (ucontrol->value.integer.value[0] == 0) {
-		aanc_info.aanc_active = false;
-		aanc_info.aanc_tx_port = 0;
-		aanc_info.aanc_rx_port = 0;
-	} else {
-		aanc_info.aanc_active = true;
-		aanc_info.aanc_rx_port = SLIMBUS_0_RX;
-		aanc_info.aanc_tx_port =
-			(SLIMBUS_0_RX - 1 + (slim0_rx_aanc_fb_port * 2));
-	}
-	afe_set_aanc_info(&aanc_info);
-	mutex_unlock(&routing_lock);
-	return 0;
-};
-static int msm_routing_get_port_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = 0, shift = 0;
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	idx = mc->shift/(sizeof(msm_bedais[mc->reg].port_sessions[0]) * 8);
-	shift = mc->shift%(sizeof(msm_bedais[mc->reg].port_sessions[0]) * 8);
-
-	if (idx >= BE_DAI_PORT_SESSIONS_IDX_MAX) {
-		pr_err("%s: Invalid idx = %d\n", __func__, idx);
-		return -EINVAL;
-	}
-
-	if (test_bit(shift,
-		(unsigned long *)&msm_bedais[mc->reg].port_sessions[idx]))
-		ucontrol->value.integer.value[0] = 1;
-	else
-		ucontrol->value.integer.value[0] = 0;
-
-	pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift,
-	ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int msm_routing_put_port_mixer(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = 0, shift = 0;
-	struct soc_mixer_control *mc =
-		(struct soc_mixer_control *)kcontrol->private_value;
-
-	idx = mc->shift/(sizeof(msm_bedais[mc->reg].port_sessions[0]) * 8);
-	shift = mc->shift%(sizeof(msm_bedais[mc->reg].port_sessions[0]) * 8);
-
-	if (idx >= BE_DAI_PORT_SESSIONS_IDX_MAX) {
-		pr_err("%s: Invalid idx = %d\n", __func__, idx);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: reg 0x%x shift 0x%x val %ld idx %d reminder shift %d\n",
-		 __func__, mc->reg, mc->shift,
-		 ucontrol->value.integer.value[0], idx, shift);
-
-	if (ucontrol->value.integer.value[0]) {
-		afe_loopback(1, msm_bedais[mc->reg].port_id,
-			    msm_bedais[mc->shift].port_id);
-		set_bit(shift,
-		(unsigned long *)&msm_bedais[mc->reg].port_sessions[idx]);
-	} else {
-		afe_loopback(0, msm_bedais[mc->reg].port_id,
-			    msm_bedais[mc->shift].port_id);
-		clear_bit(shift,
-		(unsigned long *)&msm_bedais[mc->reg].port_sessions[idx]);
-	}
-
-	return 1;
-}
-
-static int msm_pcm_get_channel_rule_index(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_mixer_control *)
-			kcontrol->private_value)->shift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	ucontrol->value.integer.value[0] = channel_mixer[fe_id].rule;
-
-	return 0;
-}
-
-static int msm_pcm_put_channel_rule_index(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_mixer_control *)
-			kcontrol->private_value)->shift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	channel_mixer[fe_id].rule = ucontrol->value.integer.value[0];
-
-	return 1;
-}
-
-static int msm_pcm_get_out_chs(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->shift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	ucontrol->value.integer.value[0] =
-		channel_mixer[fe_id].output_channel;
-	return 0;
-}
-
-static int msm_pcm_put_out_chs(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->shift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: fe_id is %d, output channels = %d\n", __func__,
-			fe_id,
-			(unsigned int)(ucontrol->value.integer.value[0]));
-	channel_mixer[fe_id].output_channel =
-			(unsigned int)(ucontrol->value.integer.value[0]);
-
-	return 1;
-}
-
-static const char *const ch_mixer[] = {"Disable", "Enable"};
-
-/* If new backend is added, need update this array */
-static const char *const be_name[] = {
-"ZERO", "PRI_I2S_RX", "PRI_I2S_TX", "SLIM_0_RX",
-"SLIM_0_TX", "HDMI_RX", "INT_BT_SCO_RX", "INT_BT_SCO_TX",
-"INT_FM_RX", "INT_FM_TX", "AFE_PCM_RX", "AFE_PCM_TX",
-"AUXPCM_RX", "AUXPCM_TX", "VOICE_PLAYBACK_TX", "VOICE2_PLAYBACK_TX",
-"INCALL_RECORD_RX", "INCALL_RECORD_TX", "MI2S_RX", "MI2S_TX",
-"SEC_I2S_RX", "SLIM_1_RX", "SLIM_1_TX", "SLIM_2_RX",
-"SLIM_2_TX", "SLIM_3_RX", "SLIM_3_TX", "SLIM_4_RX",
-"SLIM_4_TX", "SLIM_5_RX", "SLIM_5_TX", "SLIM_6_RX",
-"SLIM_6_TX", "SLIM_7_RX", "SLIM_7_TX", "SLIM_8_RX",
-"SLIM_8_TX", "EXTPROC_RX", "EXTPROC_TX", "EXPROC_EC_TX",
-"QUAT_MI2S_RX", "QUAT_MI2S_TX", "SECOND_MI2S_RX", "SECOND_MI2S_TX",
-"PRI_MI2S_RX", "PRI_MI2S_TX", "TERT_MI2S_RX", "TERT_MI2S_TX",
-"AUDIO_I2S_RX", "SEC_AUXPCM_RX", "SEC_AUXPCM_TX", "SPDIF_RX",
-"SECOND_MI2S_RX_SD1", "QUIN_MI2S_RX", "QUIN_MI2S_TX", "SENARY_MI2S_TX",
-"PRI_TDM_RX_0", "PRI_TDM_TX_0", "PRI_TDM_RX_1", "PRI_TDM_TX_1",
-"PRI_TDM_RX_2", "PRI_TDM_TX_2", "PRI_TDM_RX_3", "PRI_TDM_TX_3",
-"PRI_TDM_RX_4", "PRI_TDM_TX_4", "PRI_TDM_RX_5", "PRI_TDM_TX_5",
-"PRI_TDM_RX_6", "PRI_TDM_TX_6", "PRI_TDM_RX_7", "PRI_TDM_TX_7",
-"SEC_TDM_RX_0", "SEC_TDM_TX_0", "SEC_TDM_RX_1", "SEC_TDM_TX_1",
-"SEC_TDM_RX_2", "SEC_TDM_TX_2", "SEC_TDM_RX_3", "SEC_TDM_TX_3",
-"SEC_TDM_RX_4", "SEC_TDM_TX_4", "SEC_TDM_RX_5", "SEC_TDM_TX_5",
-"SEC_TDM_RX_6", "SEC_TDM_TX_6", "SEC_TDM_RX_7", "SEC_TDM_TX_7",
-"TERT_TDM_RX_0", "TERT_TDM_TX_0", "TERT_TDM_RX_1", "TERT_TDM_TX_1",
-"TERT_TDM_RX_2", "TERT_TDM_TX_2", "TERT_TDM_RX_3", "TERT_TDM_TX_3",
-"TERT_TDM_RX_4", "TERT_TDM_TX_4", "TERT_TDM_RX_5", "TERT_TDM_TX_5",
-"TERT_TDM_RX_6", "TERT_TDM_TX_6", "TERT_TDM_RX_7", "TERT_TDM_TX_7",
-"QUAT_TDM_RX_0", "QUAT_TDM_TX_0", "QUAT_TDM_RX_1", "QUAT_TDM_TX_1",
-"QUAT_TDM_RX_2", "QUAT_TDM_TX_2", "QUAT_TDM_RX_3", "QUAT_TDM_TX_3",
-"QUAT_TDM_RX_4", "QUAT_TDM_TX_4", "QUAT_TDM_RX_5", "QUAT_TDM_TX_5",
-"QUAT_TDM_RX_6", "QUAT_TDM_TX_6", "QUAT_TDM_RX_7", "QUAT_TDM_TX_7",
-"INT_BT_A2DP_RX", "USB_RX", "USB_TX", "DISPLAY_PORT_RX",
-"TERT_AUXPCM_RX", "TERT_AUXPCM_TX", "QUAT_AUXPCM_RX", "QUAT_AUXPCM_TX",
-"INT0_MI2S_RX", "INT0_MI2S_TX", "INT1_MI2S_RX", "INT1_MI2S_TX",
-"INT2_MI2S_RX", "INT2_MI2S_TX", "INT3_MI2S_RX", "INT3_MI2S_TX",
-"INT4_MI2S_RX", "INT4_MI2S_TX", "INT5_MI2S_RX", "INT5_MI2S_TX",
-"INT6_MI2S_RX", "INT6_MI2S_TX"
-};
-
-static SOC_ENUM_SINGLE_DECL(mm1_channel_mux,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, ch_mixer);
-static SOC_ENUM_SINGLE_DECL(mm2_channel_mux,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA2, ch_mixer);
-static SOC_ENUM_SINGLE_DECL(mm3_channel_mux,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA3, ch_mixer);
-static SOC_ENUM_SINGLE_DECL(mm4_channel_mux,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA4, ch_mixer);
-
-static SOC_ENUM_DOUBLE_DECL(mm1_ch1_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 0, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch2_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 1, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch3_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 2, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch4_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 3, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch5_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 4, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch6_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 5, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch7_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 6, be_name);
-static SOC_ENUM_DOUBLE_DECL(mm1_ch8_enum,
-	SND_SOC_NOPM, MSM_FRONTEND_DAI_MULTIMEDIA1, 7, be_name);
-
-static int msm_pcm_get_ctl_enum_info(struct snd_ctl_elem_info *uinfo,
-		unsigned int channels,
-		unsigned int items, const char *const names[])
-{
-	if (uinfo->value.enumerated.item >= items)
-		uinfo->value.enumerated.item = items - 1;
-
-	WARN(strlen(names[uinfo->value.enumerated.item]) >=
-		sizeof(uinfo->value.enumerated.name),
-		"ALSA: too long item name '%s'\n",
-		names[uinfo->value.enumerated.item]);
-	strlcpy(uinfo->value.enumerated.name,
-		names[uinfo->value.enumerated.item],
-		sizeof(uinfo->value.enumerated.name));
-	return 0;
-}
-
-static int msm_pcm_channel_mixer_info(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_info *uinfo)
-{
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-	uinfo->count = 1;
-
-	uinfo->value.enumerated.items = ARRAY_SIZE(ch_mixer);
-	msm_pcm_get_ctl_enum_info(uinfo, 1, e->items, e->texts);
-
-	return 0;
-}
-static int msm_pcm_channel_mixer_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_enum *)
-			kcontrol->private_value)->shift_l;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: FE %d %s\n", __func__,
-		fe_id,
-		channel_mixer[fe_id].enable ? "Enabled" : "Disabled");
-	ucontrol->value.enumerated.item[0] = channel_mixer[fe_id].enable;
-	return 0;
-}
-
-static int msm_pcm_channel_mixer_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0;
-
-	fe_id = ((struct soc_enum *)
-			kcontrol->private_value)->shift_l;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-
-	channel_mixer[fe_id].enable = ucontrol->value.enumerated.item[0];
-	pr_debug("%s: %s FE %d\n", __func__,
-		channel_mixer[fe_id].enable ? "Enable" : "Disable",
-		fe_id);
-	return 0;
-}
-
-static int msm_pcm_channel_input_be_info(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_info *uinfo)
-{
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-	uinfo->count = 1;
-
-	uinfo->value.enumerated.items = ARRAY_SIZE(be_name);
-	msm_pcm_get_ctl_enum_info(uinfo, 1, e->items, e->texts);
-
-	return 0;
-}
-
-static int msm_pcm_channel_input_be_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	u16 fe_id = 0, in_ch = 0;
-
-	fe_id = e->shift_l;
-	in_ch = e->shift_r;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-	if (in_ch >= ADM_MAX_CHANNELS) {
-		pr_err("%s: invalid input channel %d\n", __func__, in_ch);
-		return -EINVAL;
-	}
-
-	channel_input[fe_id][in_ch] = ucontrol->value.enumerated.item[0];
-	return 1;
-}
-
-static int msm_pcm_channel_input_be_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	u16 fe_id = 0, in_ch = 0;
-
-	fe_id = e->shift_l;
-	in_ch = e->shift_r;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-	if (in_ch >= ADM_MAX_CHANNELS) {
-		pr_err("%s: invalid input channel %d\n", __func__, in_ch);
-		return -EINVAL;
-	}
-
-	ucontrol->value.enumerated.item[0] = channel_input[fe_id][in_ch];
-	return 1;
-}
-
-
-static int msm_pcm_channel_weight_info(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-	uinfo->count = ADM_MAX_CHANNELS;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = WEIGHT_0_DB;
-
-	return 0;
-}
-
-static int msm_pcm_channel_weight_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0, out_ch = 0;
-	int i, weight;
-
-	fe_id = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->shift;
-	out_ch = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->rshift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-	if (out_ch >= ADM_MAX_CHANNELS) {
-		pr_err("%s: invalid input channel %d\n", __func__, out_ch);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: FE_ID: %d, channel weight %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
-		__func__, fe_id,
-		ucontrol->value.integer.value[0],
-		ucontrol->value.integer.value[1],
-		ucontrol->value.integer.value[2],
-		ucontrol->value.integer.value[3],
-		ucontrol->value.integer.value[4],
-		ucontrol->value.integer.value[5],
-		ucontrol->value.integer.value[6],
-		ucontrol->value.integer.value[7]);
-
-	for (i = 0; i < ADM_MAX_CHANNELS; ++i) {
-		weight = ucontrol->value.integer.value[i];
-		channel_mixer[fe_id].channel_weight[out_ch][i] = weight;
-		pr_debug("%s: FE_ID %d, output %d input %d weight %d\n",
-			__func__, fe_id, out_ch, i,
-			channel_mixer[fe_id].channel_weight[out_ch][i]);
-	}
-
-	return 0;
-}
-
-static int msm_pcm_channel_weight_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	u16 fe_id = 0, out_ch = 0;
-	int i;
-
-	fe_id = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->shift;
-	out_ch = ((struct soc_multi_mixer_control *)
-			kcontrol->private_value)->rshift;
-	if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: invalid FE %d\n", __func__, fe_id);
-		return -EINVAL;
-	}
-	if (out_ch >= ADM_MAX_CHANNELS) {
-		pr_err("%s: invalid input channel %d\n", __func__, out_ch);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < ADM_MAX_CHANNELS; ++i)
-		ucontrol->value.integer.value[i] =
-			channel_mixer[fe_id].channel_weight[out_ch][i];
-
-	pr_debug("%s: FE_ID: %d, weight  %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld",
-		__func__, fe_id,
-		ucontrol->value.integer.value[0],
-		ucontrol->value.integer.value[1],
-		ucontrol->value.integer.value[2],
-		ucontrol->value.integer.value[3],
-		ucontrol->value.integer.value[4],
-		ucontrol->value.integer.value[5],
-		ucontrol->value.integer.value[6],
-		ucontrol->value.integer.value[7]);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new channel_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA1, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-	SOC_SINGLE_EXT("MultiMedia2 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA2, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-	SOC_SINGLE_EXT("MultiMedia3 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA3, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-	SOC_SINGLE_EXT("MultiMedia4 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA4, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-	SOC_SINGLE_EXT("MultiMedia5 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA5, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-	SOC_SINGLE_EXT("MultiMedia6 Channel Rule", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA6, 8, 0,
-			msm_pcm_get_channel_rule_index,
-			msm_pcm_put_channel_rule_index),
-
-	SOC_SINGLE_EXT("MultiMedia1 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA1, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	SOC_SINGLE_EXT("MultiMedia2 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA2, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	SOC_SINGLE_EXT("MultiMedia3 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA3, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	SOC_SINGLE_EXT("MultiMedia4 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA4, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	SOC_SINGLE_EXT("MultiMedia5 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA5, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	SOC_SINGLE_EXT("MultiMedia6 Channels", SND_SOC_NOPM,
-			MSM_FRONTEND_DAI_MULTIMEDIA6, 8, 0,
-			msm_pcm_get_out_chs,
-			msm_pcm_put_out_chs),
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel Mixer",
-	.info = msm_pcm_channel_mixer_info,
-	.get = msm_pcm_channel_mixer_get,
-	.put = msm_pcm_channel_mixer_put,
-	.private_value = (unsigned long)&(mm1_channel_mux)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia2 Channel Mixer",
-	.info = msm_pcm_channel_mixer_info,
-	.get = msm_pcm_channel_mixer_get,
-	.put = msm_pcm_channel_mixer_put,
-	.private_value = (unsigned long)&(mm2_channel_mux)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia3 Channel Mixer",
-	.info = msm_pcm_channel_mixer_info,
-	.get = msm_pcm_channel_mixer_get,
-	.put = msm_pcm_channel_mixer_put,
-	.private_value = (unsigned long)&(mm3_channel_mux)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia4 Channel Mixer",
-	.info = msm_pcm_channel_mixer_info,
-	.get = msm_pcm_channel_mixer_get,
-	.put = msm_pcm_channel_mixer_put,
-	.private_value = (unsigned long)&(mm4_channel_mux)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel1",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 0,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel2",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 1, }
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel3",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 2,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel4",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 3,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel5",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 4,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel6",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 5,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel7",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 6,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Output Channel8",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{ .shift = MSM_FRONTEND_DAI_MULTIMEDIA1, .rshift = 7,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia2 Output Channel1",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{.shift = MSM_FRONTEND_DAI_MULTIMEDIA2, .rshift = 0,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia2 Output Channel2",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{.shift = MSM_FRONTEND_DAI_MULTIMEDIA2, .rshift = 1,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia2 Output Channel3",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{.shift = MSM_FRONTEND_DAI_MULTIMEDIA2, .rshift = 2,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia3 Output Channel1",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{.shift = MSM_FRONTEND_DAI_MULTIMEDIA3, .rshift = 0,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia3 Output Channel2",
-	.info = msm_pcm_channel_weight_info,
-	.get = msm_pcm_channel_weight_get,
-	.put = msm_pcm_channel_weight_put,
-	.private_value = (unsigned long)&(struct soc_multi_mixer_control)
-		{.shift = MSM_FRONTEND_DAI_MULTIMEDIA3, .rshift = 1,}
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel1",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch1_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel2",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch2_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel3",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch3_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel4",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch4_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel5",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch5_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel6",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch6_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel7",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch7_enum)
-	},
-	{
-	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.name = "MultiMedia1 Channel8",
-	.info = msm_pcm_channel_input_be_info,
-	.get = msm_pcm_channel_input_be_get,
-	.put = msm_pcm_channel_input_be_put,
-	.private_value = (unsigned long)&(mm1_ch8_enum)
-	},
-};
-static int msm_ec_ref_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_ec_ref_ch;
-	pr_debug("%s: msm_ec_ref_ch = %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_ec_ref_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	msm_ec_ref_ch = ucontrol->value.integer.value[0];
-	pr_debug("%s: msm_ec_ref_ch = %d\n", __func__, msm_ec_ref_ch);
-	adm_num_ec_ref_rx_chans(msm_ec_ref_ch);
-	return 0;
-}
-
-static const char *const ec_ref_ch_text[] = {"Zero", "One", "Two", "Three",
-	"Four", "Five", "Six", "Seven", "Eight"};
-
-static int msm_ec_ref_bit_format_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	switch (msm_ec_ref_bit_format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: msm_ec_ref_bit_format = %ld\n",
-		 __func__, ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_ec_ref_bit_format_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	u16 bit_width = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 2:
-		msm_ec_ref_bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 1:
-		msm_ec_ref_bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	default:
-		msm_ec_ref_bit_format = 0;
-		break;
-	}
-
-	if (msm_ec_ref_bit_format == SNDRV_PCM_FORMAT_S16_LE)
-		bit_width = 16;
-	else if (msm_ec_ref_bit_format == SNDRV_PCM_FORMAT_S24_LE)
-		bit_width = 24;
-
-	pr_debug("%s: msm_ec_ref_bit_format = %d\n",
-		 __func__, msm_ec_ref_bit_format);
-	adm_ec_ref_rx_bit_width(bit_width);
-	return 0;
-}
-
-static char const *ec_ref_bit_format_text[] = {"0", "S16_LE", "S24_LE"};
-
-static int msm_ec_ref_rate_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_ec_ref_sampling_rate;
-	pr_debug("%s: msm_ec_ref_sampling_rate = %ld\n",
-		 __func__, ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_ec_ref_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		msm_ec_ref_sampling_rate = 0;
-		break;
-	case 1:
-		msm_ec_ref_sampling_rate = 8000;
-		break;
-	case 2:
-		msm_ec_ref_sampling_rate = 16000;
-		break;
-	case 3:
-		msm_ec_ref_sampling_rate = 32000;
-		break;
-	case 4:
-		msm_ec_ref_sampling_rate = 44100;
-		break;
-	case 5:
-		msm_ec_ref_sampling_rate = 48000;
-		break;
-	case 6:
-		msm_ec_ref_sampling_rate = 96000;
-		break;
-	case 7:
-		msm_ec_ref_sampling_rate = 192000;
-		break;
-	case 8:
-		msm_ec_ref_sampling_rate = 384000;
-		break;
-	default:
-		msm_ec_ref_sampling_rate = 48000;
-		break;
-	}
-	pr_debug("%s: msm_ec_ref_sampling_rate = %d\n",
-		 __func__, msm_ec_ref_sampling_rate);
-	adm_ec_ref_rx_sampling_rate(msm_ec_ref_sampling_rate);
-	return 0;
-}
-
-static const char *const ec_ref_rate_text[] = {"0", "8000", "16000",
-	"32000", "44100", "48000", "96000", "192000", "384000"};
-
-static const struct soc_enum msm_route_ec_ref_params_enum[] = {
-	SOC_ENUM_SINGLE_EXT(9, ec_ref_ch_text),
-	SOC_ENUM_SINGLE_EXT(3, ec_ref_bit_format_text),
-	SOC_ENUM_SINGLE_EXT(9, ec_ref_rate_text),
-};
-
-static const struct snd_kcontrol_new ec_ref_param_controls[] = {
-	SOC_ENUM_EXT("EC Reference Channels", msm_route_ec_ref_params_enum[0],
-		msm_ec_ref_ch_get, msm_ec_ref_ch_put),
-	SOC_ENUM_EXT("EC Reference Bit Format", msm_route_ec_ref_params_enum[1],
-		msm_ec_ref_bit_format_get, msm_ec_ref_bit_format_put),
-	SOC_ENUM_EXT("EC Reference SampleRate", msm_route_ec_ref_params_enum[2],
-		msm_ec_ref_rate_get, msm_ec_ref_rate_put),
-};
-
-static int msm_routing_ec_ref_rx_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: ec_ref_rx  = %d", __func__, msm_route_ec_ref_rx);
-	mutex_lock(&routing_lock);
-	ucontrol->value.integer.value[0] = msm_route_ec_ref_rx;
-	mutex_unlock(&routing_lock);
-	return 0;
-}
-
-static int msm_routing_ec_ref_rx_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int ec_ref_port_id;
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	struct snd_soc_dapm_update *update = NULL;
-
-
-	mutex_lock(&routing_lock);
-	switch (ucontrol->value.integer.value[0]) {
-	case 0:
-		msm_route_ec_ref_rx = 0;
-		ec_ref_port_id = AFE_PORT_INVALID;
-		break;
-	case 1:
-		msm_route_ec_ref_rx = 1;
-		ec_ref_port_id = SLIMBUS_0_RX;
-		break;
-	case 2:
-		msm_route_ec_ref_rx = 2;
-		ec_ref_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-		break;
-	case 3:
-		msm_route_ec_ref_rx = 3;
-		ec_ref_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-		break;
-	case 4:
-		msm_route_ec_ref_rx = 4;
-		ec_ref_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-		break;
-	case 5:
-		msm_route_ec_ref_rx = 5;
-		ec_ref_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case 6:
-		msm_route_ec_ref_rx = 6;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	case 7:
-		msm_route_ec_ref_rx = 7;
-		ec_ref_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
-		break;
-	case 9:
-		msm_route_ec_ref_rx = 9;
-		ec_ref_port_id = SLIMBUS_5_RX;
-		break;
-	case 10:
-		msm_route_ec_ref_rx = 10;
-		ec_ref_port_id = SLIMBUS_1_TX;
-		break;
-	case 11:
-		msm_route_ec_ref_rx = 11;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_TDM_TX_1;
-		break;
-	case 12:
-		msm_route_ec_ref_rx = 12;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_TDM_RX;
-		break;
-	case 13:
-		msm_route_ec_ref_rx = 13;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_TDM_RX_1;
-		break;
-	case 14:
-		msm_route_ec_ref_rx = 14;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_TDM_RX_2;
-		break;
-	case 15:
-		msm_route_ec_ref_rx = 15;
-		ec_ref_port_id = SLIMBUS_6_RX;
-		break;
-	case 16:
-		msm_route_ec_ref_rx = 16;
-		ec_ref_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
-		break;
-	case 17:
-		msm_route_ec_ref_rx = 17;
-		ec_ref_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
-		break;
-	case 18:
-		msm_route_ec_ref_rx = 18;
-		ec_ref_port_id = AFE_PORT_ID_TERTIARY_TDM_TX;
-		break;
-	case 19:
-		msm_route_ec_ref_rx = 19;
-		ec_ref_port_id = AFE_PORT_ID_USB_RX;
-		break;
-	case 20:
-		msm_route_ec_ref_rx = 20;
-		ec_ref_port_id = AFE_PORT_ID_INT0_MI2S_RX;
-		break;
-	case 21:
-		msm_route_ec_ref_rx = 21;
-		ec_ref_port_id = AFE_PORT_ID_INT4_MI2S_RX;
-		break;
-	case 22:
-		msm_route_ec_ref_rx = 22;
-		ec_ref_port_id = AFE_PORT_ID_INT3_MI2S_TX;
-		break;
-	default:
-		msm_route_ec_ref_rx = 0; /* NONE */
-		pr_err("%s EC ref rx %ld not valid\n",
-			__func__, ucontrol->value.integer.value[0]);
-		ec_ref_port_id = AFE_PORT_INVALID;
-		break;
-	}
-	adm_ec_ref_rx_id(ec_ref_port_id);
-	pr_debug("%s: msm_route_ec_ref_rx = %d\n",
-	    __func__, msm_route_ec_ref_rx);
-	mutex_unlock(&routing_lock);
-	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
-					msm_route_ec_ref_rx, e, update);
-	return 0;
-}
-
-static const char *const ec_ref_rx[] = { "None", "SLIM_RX", "I2S_RX",
-	"PRI_MI2S_TX", "SEC_MI2S_TX",
-	"TERT_MI2S_TX", "QUAT_MI2S_TX", "SEC_I2S_RX", "PROXY_RX",
-	"SLIM_5_RX", "SLIM_1_TX", "QUAT_TDM_TX_1",
-	"QUAT_TDM_RX_0", "QUAT_TDM_RX_1", "QUAT_TDM_RX_2", "SLIM_6_RX",
-	"TERT_MI2S_RX", "QUAT_MI2S_RX", "TERT_TDM_TX_0", "USB_AUDIO_RX",
-	"INT0_MI2S_RX", "INT4_MI2S_RX", "INT3_MI2S_TX"};
-
-static const struct soc_enum msm_route_ec_ref_rx_enum[] = {
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ec_ref_rx), ec_ref_rx),
-};
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul1 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL1 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul2 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL2 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul3 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL3 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul4 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL4 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul5 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL5 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul6 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL6 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul8 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL8 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul9 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL9 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul16 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL16 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul10 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL10 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul17 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL17 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul18 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL18 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static const struct snd_kcontrol_new ext_ec_ref_mux_ul19 =
-	SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL19 MUX Mux",
-		msm_route_ec_ref_rx_enum[0],
-		msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put);
-
-static int msm_routing_ext_ec_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: ext_ec_ref_rx  = %x\n", __func__, msm_route_ext_ec_ref);
-
-	mutex_lock(&routing_lock);
-	ucontrol->value.integer.value[0] = msm_route_ext_ec_ref;
-	mutex_unlock(&routing_lock);
-	return 0;
-}
-
-static int msm_routing_ext_ec_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_dapm_widget *widget =
-		snd_soc_dapm_kcontrol_widget(kcontrol);
-	int mux = ucontrol->value.enumerated.item[0];
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	int ret = 1;
-	bool state = true;
-	uint16_t ext_ec_ref_port_id;
-	struct snd_soc_dapm_update *update = NULL;
-
-	if (mux >= e->items) {
-		pr_err("%s: Invalid mux value %d\n", __func__, mux);
-		return -EINVAL;
-	}
-
-	mutex_lock(&routing_lock);
-	msm_route_ext_ec_ref = ucontrol->value.integer.value[0];
-
-	switch (msm_route_ext_ec_ref) {
-	case EXT_EC_REF_PRI_MI2S_TX:
-		ext_ec_ref_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-		break;
-	case EXT_EC_REF_SEC_MI2S_TX:
-		ext_ec_ref_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-		break;
-	case EXT_EC_REF_TERT_MI2S_TX:
-		ext_ec_ref_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case EXT_EC_REF_QUAT_MI2S_TX:
-		ext_ec_ref_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	case EXT_EC_REF_QUIN_MI2S_TX:
-		ext_ec_ref_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
-		break;
-	case EXT_EC_REF_SLIM_1_TX:
-		ext_ec_ref_port_id = SLIMBUS_1_TX;
-		break;
-	case EXT_EC_REF_NONE:
-	default:
-		ext_ec_ref_port_id = AFE_PORT_INVALID;
-		state = false;
-		break;
-	}
-
-	pr_debug("%s: val = %d ext_ec_ref_port_id = 0x%0x state = %d\n",
-		 __func__, msm_route_ext_ec_ref, ext_ec_ref_port_id, state);
-
-	if (!voc_set_ext_ec_ref_port_id(ext_ec_ref_port_id, state)) {
-		mutex_unlock(&routing_lock);
-		snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, mux, e,
-						update);
-	} else {
-		ret = -EINVAL;
-		mutex_unlock(&routing_lock);
-	}
-	return ret;
-}
-
-static const char * const ext_ec_ref_rx[] = {"NONE", "PRI_MI2S_TX",
-					"SEC_MI2S_TX", "TERT_MI2S_TX",
-					"QUAT_MI2S_TX", "QUIN_MI2S_TX",
-					"SLIM_1_TX"};
-
-static const struct soc_enum msm_route_ext_ec_ref_rx_enum[] = {
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ext_ec_ref_rx), ext_ec_ref_rx),
-};
-
-static const struct snd_kcontrol_new voc_ext_ec_mux =
-	SOC_DAPM_ENUM_EXT("VOC_EXT_EC MUX Mux", msm_route_ext_ec_ref_rx_enum[0],
-			  msm_routing_ext_ec_get, msm_routing_ext_ec_put);
-
-
-static const struct snd_kcontrol_new pri_i2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_i2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new spdif_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-
-};
-
-static const struct snd_kcontrol_new slimbus_2_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_5_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quinary_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new secondary_mi2s_rx2_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SECONDARY_MI2S_RX_SD1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new secondary_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new primary_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new int0_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new int4_mi2s_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new hdmi_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new display_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-	/* incall music delivery mixer */
-static const struct snd_kcontrol_new incall_music_delivery_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new incall_music2_delivery_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_4_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_4_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_4_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_4_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_4_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_6_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_7_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new usb_audio_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new int_bt_sco_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new int_bt_a2dp_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new int_fm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new afe_pcm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new auxpcm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_auxpcm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia17", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia18", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia19", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_auxpcm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_auxpcm_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_1_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_2_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_3_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_tx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_1_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_2_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_3_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_tx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_tx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_1_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_2_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_3_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_4_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia20", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_tx_0_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_1_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia20", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_2_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia20", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_3_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia9", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia10", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia11", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA11, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia12", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA12, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia13", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA13, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia14", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA14, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia15", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA15, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia16", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia20", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul1_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX", MSM_BACKEND_DAI_PRI_I2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUIN_MI2S_TX", MSM_BACKEND_DAI_QUINARY_MI2S_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-		MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
-		msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul2_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUIN_MI2S_TX", MSM_BACKEND_DAI_QUINARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul3_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul4_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul5_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul6_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul8_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul16_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT2_MI2S_TX", MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA16, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul9_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA9, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul10_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SLIM_6_TX", MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA10, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-static const struct snd_kcontrol_new mmul17_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul18_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA18, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul19_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA19, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new mmul20_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_FRONTEND_DAI_MULTIMEDIA20, 1, 0, msm_routing_get_audio_mixer,
-	msm_routing_put_audio_mixer),
-};
-
-static const struct snd_kcontrol_new pri_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_PRI_I2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new sec_i2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new sec_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_6_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new usb_audio_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_USB_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new bt_sco_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new pri_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new int0_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new int4_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tert_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new quat_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new quin_mi2s_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new afe_pcm_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new aux_pcm_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new sec_aux_pcm_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tert_aux_pcm_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new quat_aux_pcm_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new hdmi_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_7_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_8_rx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoWLAN", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QCHAT", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("VoiceMMode2", MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_2_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("VoiceMMode1", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new stub_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_EXTPROC_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_EXTPROC_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_EXTPROC_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_1_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new slimbus_3_rx_mixer_controls[] = {
-	SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voice_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_Voice", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_Voice", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_Voice", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voice",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_CS_VOICE, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_Voice", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_Voice", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voice", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_Voice", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_Voice", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_Voice", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX_Voice", MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_Voice", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_Voice", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_Voice", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_Voice", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voice2_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_Voice2", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_Voice2", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_Voice2", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voice2",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOICE2, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_Voice2", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_Voice2", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_Voice2", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_Voice2", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_Voice2", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_Voice2", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_volte_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_VoLTE", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_VoLTE", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_VoLTE",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOLTE, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_VoLTE", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_VoLTE", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_VoLTE", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_VoLTE", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_VoLTE", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_VoLTE", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_VoLTE", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_vowlan_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_VoWLAN", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_VoWLAN", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_VoWLAN",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOWLAN, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_VoWLAN", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_VoWLAN", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_VoWLAN", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_VoWLAN", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_VoWLAN", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_VoWLAN", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_VoWLAN", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_VoWLAN", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_VoWLAN", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_VoWLAN", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_VoWLAN", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_VOWLAN, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voicemmode1_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_MMode1", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_MMode1", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_MMode1",
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT_BT_SCO_TX_MMode1",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_MMode1",
-	MSM_BACKEND_DAI_AFE_PCM_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_MMode1",
-	MSM_BACKEND_DAI_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_MMode1",
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_MMode1",
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_MMode1",
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_MMode1",
-	MSM_BACKEND_DAI_PRI_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_MMode1",
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE1,
-	1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX_MMode1",
-	MSM_BACKEND_DAI_INT3_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE1,
-	1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_MMode1",
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_MMode1",
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_MMode1", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0_MMode1",
-	MSM_BACKEND_DAI_QUAT_TDM_TX_0, MSM_FRONTEND_DAI_VOICEMMODE1,
-	1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voicemmode2_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_MMode2", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_MMode2", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_MMode2",
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT_BT_SCO_TX_MMode2",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_MMode2",
-	MSM_BACKEND_DAI_AFE_PCM_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_MMode2",
-	MSM_BACKEND_DAI_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_MMode2",
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_MMode2",
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_MMode2",
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_MMode2",
-	MSM_BACKEND_DAI_PRI_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_MMode2",
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE2,
-	1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX_MMode2",
-	MSM_BACKEND_DAI_INT3_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE2,
-	1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_MMode2",
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_MMode2",
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_MMode2",
-	MSM_BACKEND_DAI_USB_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1,
-	0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voip_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_Voip", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_Voip", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_Voip", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voip", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_Voip", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_Voip", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voip", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_Voip", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_Voip", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_Voip", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_Voip", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX_Voip", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_Voip", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_Voip", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_Voip", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voice_stub_mixer_controls[] = {
-	SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new tx_voice2_stub_mixer_controls[] = {
-	SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new tx_volte_stub_mixer_controls[] = {
-	SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer,
-	msm_routing_put_voice_stub_mixer),
-};
-
-static const struct snd_kcontrol_new tx_qchat_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_TX_QCHAT", MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX_QCHAT", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_QCHAT",
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_QCHAT, 1, 0,
-	msm_routing_get_voice_mixer, msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX_QCHAT", MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_TX_QCHAT", MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_TX_QCHAT", MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_AUX_PCM_TX_QCHAT", MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("QUAT_AUX_PCM_TX_QCHAT", MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("MI2S_TX_QCHAT", MSM_BACKEND_DAI_MI2S_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX_QCHAT", MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX_QCHAT", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX_QCHAT", MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX_QCHAT", MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX_QCHAT", MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-	SOC_SINGLE_EXT("USB_AUDIO_TX_QCHAT", MSM_BACKEND_DAI_USB_TX,
-	MSM_FRONTEND_DAI_QCHAT, 1, 0, msm_routing_get_voice_mixer,
-	msm_routing_put_voice_mixer),
-};
-
-static const struct snd_kcontrol_new int0_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_INT3_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new int4_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_INT3_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sbus_0_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_RX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_RX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_RX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_RX", MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new aux_pcm_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_auxpcm_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_auxpcm_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_auxpcm_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sbus_1_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_AUXPCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_AUXPCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sbus_3_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_AFE_PCM_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_AUXPCM_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_RX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sbus_6_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_7_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SLIMBUS_7_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new bt_sco_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new afe_pcm_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-
-static const struct snd_kcontrol_new hdmi_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_HDMI_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new display_port_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_i2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_RX,
-	MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new primary_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUIN_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_QUINARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new usb_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("USB_AUDIO_TX", MSM_BACKEND_DAI_USB_RX,
-	MSM_BACKEND_DAI_USB_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_0_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_1_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_2_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new pri_tdm_rx_3_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("PRI_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_PRI_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_0_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_1_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_2_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_tdm_rx_3_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_SEC_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_0_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_1_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_2_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_tdm_rx_3_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_TERT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_0_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_1_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_2_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new quat_tdm_rx_3_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_FM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_SEC_AUXPCM_TX, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_TERT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_0", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_0, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_1", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_1, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_2", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_2, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_TDM_TX_3", MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-		MSM_BACKEND_DAI_QUAT_TDM_TX_3, 1, 0,
-		msm_routing_get_port_mixer,
-		msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new tert_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new sec_mi2s_rx_port_mixer_controls[] = {
-	SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SEC_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-	SOC_SINGLE_EXT("SLIM_8_TX", MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX, 1, 0, msm_routing_get_port_mixer,
-	msm_routing_put_port_mixer),
-};
-
-static const struct snd_kcontrol_new lsm1_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM1, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm2_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM2, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm3_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM3, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm4_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM4, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm5_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM5, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm6_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM6, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm7_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM7, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new lsm8_mixer_controls[] = {
-	SOC_SINGLE_EXT("SLIMBUS_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("SLIMBUS_5_TX", MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("TERT_MI2S_TX", MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("QUAT_MI2S_TX", MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-	SOC_SINGLE_EXT("INT3_MI2S_TX", MSM_BACKEND_DAI_INT3_MI2S_TX,
-		MSM_FRONTEND_DAI_LSM8, 1, 0, msm_routing_get_listen_mixer,
-		msm_routing_put_listen_mixer),
-};
-
-static const struct snd_kcontrol_new slim_fm_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_switch_mixer,
-	msm_routing_put_switch_mixer);
-
-static const struct snd_kcontrol_new slim1_fm_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_switch_mixer,
-	msm_routing_put_switch_mixer);
-
-static const struct snd_kcontrol_new slim3_fm_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_switch_mixer,
-	msm_routing_put_switch_mixer);
-
-static const struct snd_kcontrol_new slim4_fm_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_switch_mixer,
-	msm_routing_put_switch_mixer);
-
-static const struct snd_kcontrol_new slim6_fm_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_switch_mixer,
-	msm_routing_put_switch_mixer);
-
-static const struct snd_kcontrol_new pcm_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_fm_pcmrx_switch_mixer,
-	msm_routing_put_fm_pcmrx_switch_mixer);
-
-static const struct snd_kcontrol_new int0_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_int0_mi2s_switch_mixer,
-	msm_routing_put_int0_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new int4_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_int4_mi2s_switch_mixer,
-	msm_routing_put_int4_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new pri_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_pri_mi2s_switch_mixer,
-	msm_routing_put_pri_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new sec_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_sec_mi2s_switch_mixer,
-	msm_routing_put_sec_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new tert_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_tert_mi2s_switch_mixer,
-	msm_routing_put_tert_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new quat_mi2s_rx_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_quat_mi2s_switch_mixer,
-	msm_routing_put_quat_mi2s_switch_mixer);
-
-static const struct snd_kcontrol_new hfp_pri_aux_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_hfp_switch_mixer,
-	msm_routing_put_hfp_switch_mixer);
-
-static const struct snd_kcontrol_new hfp_aux_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_hfp_switch_mixer,
-	msm_routing_put_hfp_switch_mixer);
-
-static const struct snd_kcontrol_new hfp_int_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_hfp_switch_mixer,
-	msm_routing_put_hfp_switch_mixer);
-
-static const struct snd_kcontrol_new hfp_slim7_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_hfp_switch_mixer,
-	msm_routing_put_hfp_switch_mixer);
-
-static const struct snd_kcontrol_new usb_switch_mixer_controls =
-	SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
-	0, 1, 0, msm_routing_get_usb_switch_mixer,
-	msm_routing_put_usb_switch_mixer);
-
-static const struct soc_enum lsm_port_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lsm_port_text), lsm_port_text);
-
-static const char * const lsm_func_text[] = {
-	"None", "AUDIO", "BEACON", "ULTRASOUND", "SWAUDIO",
-};
-static const struct soc_enum lsm_func_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lsm_func_text), lsm_func_text);
-
-static const struct snd_kcontrol_new lsm_controls[] = {
-	/* kcontrol of lsm_function */
-	SOC_ENUM_EXT(SLIMBUS_0_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(SLIMBUS_1_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(SLIMBUS_2_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(SLIMBUS_3_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(SLIMBUS_4_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(SLIMBUS_5_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		     msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(TERT_MI2S_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		    msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(QUAT_MI2S_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		    msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	SOC_ENUM_EXT(INT3_MI2S_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum,
-		    msm_routing_lsm_func_get, msm_routing_lsm_func_put),
-	/* kcontrol of lsm_port */
-	SOC_ENUM_EXT("LSM1 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM2 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM3 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM4 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM5 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM6 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM7 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-	SOC_ENUM_EXT("LSM8 Port", lsm_port_enum,
-			  msm_routing_lsm_port_get,
-			  msm_routing_lsm_port_put),
-};
-
-static const char * const aanc_slim_0_rx_text[] = {
-	"ZERO", "SLIMBUS_0_TX", "SLIMBUS_1_TX", "SLIMBUS_2_TX", "SLIMBUS_3_TX",
-	"SLIMBUS_4_TX", "SLIMBUS_5_TX", "SLIMBUS_6_TX"
-};
-
-static const struct soc_enum aanc_slim_0_rx_enum =
-	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(aanc_slim_0_rx_text),
-				aanc_slim_0_rx_text);
-
-static const struct snd_kcontrol_new aanc_slim_0_rx_mux[] = {
-	SOC_ENUM_EXT("AANC_SLIM_0_RX MUX", aanc_slim_0_rx_enum,
-		msm_routing_slim_0_rx_aanc_mux_get,
-		msm_routing_slim_0_rx_aanc_mux_put)
-};
-
-static int msm_routing_get_stereo_to_custom_stereo_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = is_custom_stereo_on;
-	return 0;
-}
-
-static int msm_routing_put_stereo_to_custom_stereo_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int flag = 0, i = 0, rc = 0, idx = 0;
-	int be_index = 0, port_id, topo_id;
-	unsigned int session_id = 0;
-	uint16_t op_FL_ip_FL_weight = 0;
-	uint16_t op_FL_ip_FR_weight = 0;
-	uint16_t op_FR_ip_FL_weight = 0;
-	uint16_t op_FR_ip_FR_weight = 0;
-
-	flag = ucontrol->value.integer.value[0];
-	pr_debug("%s E flag %d\n", __func__, flag);
-
-	if ((is_custom_stereo_on && flag) || (!is_custom_stereo_on && !flag)) {
-		pr_err("%s: is_custom_stereo_on %d, flag %d\n",
-			__func__, is_custom_stereo_on, flag);
-		return 0;
-	}
-	is_custom_stereo_on = flag ? true : false;
-	pr_debug("%s:is_custom_stereo_on %d\n", __func__, is_custom_stereo_on);
-	for (be_index = 0; be_index < MSM_BACKEND_DAI_MAX; be_index++) {
-		port_id = msm_bedais[be_index].port_id;
-		if (!msm_bedais[be_index].active)
-			continue;
-		if ((port_id != SLIMBUS_0_RX) &&
-		     (port_id != RT_PROXY_PORT_001_RX) &&
-			(port_id != AFE_PORT_ID_PRIMARY_MI2S_RX) &&
-			(port_id != AFE_PORT_ID_INT4_MI2S_RX))
-			continue;
-
-		for_each_set_bit(i, &msm_bedais[be_index].fe_sessions[0],
-				MSM_FRONTEND_DAI_MM_SIZE) {
-			if (fe_dai_map[i][SESSION_TYPE_RX].perf_mode !=
-			    LEGACY_PCM_MODE)
-				goto skip_send_custom_stereo;
-			session_id =
-				fe_dai_map[i][SESSION_TYPE_RX].strm_id;
-			if (is_custom_stereo_on) {
-				op_FL_ip_FL_weight =
-					Q14_GAIN_ZERO_POINT_FIVE;
-				op_FL_ip_FR_weight =
-					Q14_GAIN_ZERO_POINT_FIVE;
-				op_FR_ip_FL_weight =
-					Q14_GAIN_ZERO_POINT_FIVE;
-				op_FR_ip_FR_weight =
-					Q14_GAIN_ZERO_POINT_FIVE;
-			} else {
-				op_FL_ip_FL_weight = Q14_GAIN_UNITY;
-				op_FL_ip_FR_weight = 0;
-				op_FR_ip_FL_weight = 0;
-				op_FR_ip_FR_weight = Q14_GAIN_UNITY;
-			}
-			for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-				unsigned long copp =
-					session_copp_map[i]
-					[SESSION_TYPE_RX][be_index];
-				if (!test_bit(idx, &copp))
-					goto skip_send_custom_stereo;
-				topo_id = adm_get_topology_for_port_copp_idx(
-					msm_bedais[be_index].port_id, idx);
-				if (topo_id < 0)
-					pr_debug("%s:Err:custom stereo topo %d",
-						 __func__, topo_id);
-					pr_debug("idx %d\n", idx);
-				if (topo_id == DS2_ADM_COPP_TOPOLOGY_ID)
-					rc = msm_ds2_dap_set_custom_stereo_onoff
-						(msm_bedais[be_index].port_id,
-						idx, is_custom_stereo_on);
-				else if (topo_id == DOLBY_ADM_COPP_TOPOLOGY_ID)
-					rc = dolby_dap_set_custom_stereo_onoff(
-						msm_bedais[be_index].port_id,
-						idx, is_custom_stereo_on);
-				else
-				rc = msm_qti_pp_send_stereo_to_custom_stereo_cmd
-						(msm_bedais[be_index].port_id,
-						idx, session_id,
-						op_FL_ip_FL_weight,
-						op_FL_ip_FR_weight,
-						op_FR_ip_FL_weight,
-						op_FR_ip_FR_weight);
-				if (rc < 0)
-skip_send_custom_stereo:
-					pr_err("%s: err setting custom stereo\n",
-						__func__);
-			}
-
-		}
-	}
-	return 0;
-}
-
-static const struct snd_kcontrol_new stereo_to_custom_stereo_controls[] = {
-	SOC_SINGLE_EXT("Set Custom Stereo OnOff", SND_SOC_NOPM, 0,
-	1, 0, msm_routing_get_stereo_to_custom_stereo_control,
-	msm_routing_put_stereo_to_custom_stereo_control),
-};
-
-static int msm_routing_get_app_type_cfg_control(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	return 0;
-}
-
-static int msm_routing_put_app_type_cfg_control(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int i = 0, j;
-	int num_app_types = ucontrol->value.integer.value[i++];
-
-	pr_debug("%s\n", __func__);
-
-	memset(app_type_cfg, 0, MAX_APP_TYPES*
-				sizeof(struct msm_pcm_routing_app_type_data));
-	if (num_app_types > MAX_APP_TYPES) {
-		pr_err("%s: number of app types exceed the max supported\n",
-			__func__);
-		return -EINVAL;
-	}
-	for (j = 0; j < num_app_types; j++) {
-		app_type_cfg[j].app_type =
-				ucontrol->value.integer.value[i++];
-		app_type_cfg[j].sample_rate =
-				ucontrol->value.integer.value[i++];
-		app_type_cfg[j].bit_width =
-				ucontrol->value.integer.value[i++];
-	}
-
-	return 0;
-}
-
-static int msm_routing_put_app_type_gain_control(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int j, fe_id, be_id, port_type;
-	int ret = 0;
-	unsigned long copp;
-	struct msm_pcm_routing_bdai_data *bedai;
-	int dir = ucontrol->value.integer.value[0] ? SESSION_TYPE_TX :
-						     SESSION_TYPE_RX;
-	int app_type = ucontrol->value.integer.value[1];
-	int gain = (ucontrol->value.integer.value[2] +
-		    ucontrol->value.integer.value[3])/2;
-
-	port_type = (dir == SESSION_TYPE_RX) ? MSM_AFE_PORT_TYPE_RX :
-					       MSM_AFE_PORT_TYPE_TX;
-
-	mutex_lock(&routing_lock);
-	for (be_id = 0; be_id < MSM_BACKEND_DAI_MAX; be_id++) {
-		if (is_be_dai_extproc(be_id))
-			continue;
-
-		bedai = &msm_bedais[be_id];
-		if (afe_get_port_type(bedai->port_id) != port_type)
-			continue;
-
-		if (!bedai->active)
-			continue;
-
-		for (fe_id = 0; fe_id < MSM_FRONTEND_DAI_MAX; fe_id++) {
-			if (!test_bit(fe_id, &bedai->fe_sessions[0]))
-				continue;
-
-			if (app_type !=
-			    fe_dai_app_type_cfg[fe_id][dir][be_id].app_type)
-				continue;
-
-			copp = session_copp_map[fe_id][dir][be_id];
-			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-				if (!test_bit(j, &copp))
-					continue;
-				ret |= adm_set_volume(bedai->port_id, j, gain);
-			}
-		}
-	}
-	mutex_unlock(&routing_lock);
-	return ret ? -EINVAL : 0;
-}
-
-static const struct snd_kcontrol_new app_type_cfg_controls[] = {
-	SOC_SINGLE_MULTI_EXT("App Type Config", SND_SOC_NOPM, 0,
-	0xFFFFFFFF, 0, 128, msm_routing_get_app_type_cfg_control,
-	msm_routing_put_app_type_cfg_control),
-	SOC_SINGLE_MULTI_EXT("App Type Gain", SND_SOC_NOPM, 0,
-	0x2000, 0, 4, NULL, msm_routing_put_app_type_gain_control)
-};
-
-static int msm_routing_get_lsm_app_type_cfg_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	return 0;
-}
-
-static int msm_routing_put_lsm_app_type_cfg_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int i = 0, j;
-	int num_app_types = ucontrol->value.integer.value[i++];
-
-	memset(lsm_app_type_cfg, 0, MAX_APP_TYPES*
-				sizeof(struct msm_pcm_routing_app_type_data));
-	if (num_app_types > MAX_APP_TYPES) {
-		pr_err("%s: number of app types exceed the max supported\n",
-			__func__);
-		return -EINVAL;
-	}
-	for (j = 0; j < num_app_types; j++) {
-		lsm_app_type_cfg[j].app_type =
-				ucontrol->value.integer.value[i++];
-		lsm_app_type_cfg[j].sample_rate =
-				ucontrol->value.integer.value[i++];
-		lsm_app_type_cfg[j].bit_width =
-				ucontrol->value.integer.value[i++];
-	}
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new lsm_app_type_cfg_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Listen App Type Config", SND_SOC_NOPM, 0,
-	0xFFFFFFFF, 0, 128, msm_routing_get_lsm_app_type_cfg_control,
-	msm_routing_put_lsm_app_type_cfg_control),
-};
-
-static int msm_routing_get_use_ds1_or_ds2_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = is_ds2_on;
-	return 0;
-}
-
-static int msm_routing_put_use_ds1_or_ds2_control(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	is_ds2_on = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static const struct snd_kcontrol_new use_ds1_or_ds2_controls[] = {
-	SOC_SINGLE_EXT("DS2 OnOff", SND_SOC_NOPM, 0,
-	1, 0, msm_routing_get_use_ds1_or_ds2_control,
-	msm_routing_put_use_ds1_or_ds2_control),
-};
-
-int msm_routing_get_rms_value_control(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol) {
-	int rc = 0;
-	int be_idx = 0;
-	char *param_value;
-	int *update_param_value;
-	uint32_t param_length = sizeof(uint32_t);
-	uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
-
-	param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
-	if (!param_value)
-		return -ENOMEM;
-
-	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++)
-		if (msm_bedais[be_idx].port_id == SLIMBUS_0_TX)
-			break;
-	if ((be_idx < MSM_BACKEND_DAI_MAX) && msm_bedais[be_idx].active) {
-		rc = adm_get_params(SLIMBUS_0_TX, 0,
-				RMS_MODULEID_APPI_PASSTHRU,
-				RMS_PARAM_FIRST_SAMPLE,
-				param_length + param_payload_len,
-				param_value);
-		if (rc) {
-			pr_err("%s: get parameters failed:%d\n", __func__, rc);
-			kfree(param_value);
-			return -EINVAL;
-		}
-		update_param_value = (int *)param_value;
-		ucontrol->value.integer.value[0] = update_param_value[0];
-
-		pr_debug("%s: FROM DSP value[0] 0x%x\n",
-			  __func__, update_param_value[0]);
-	}
-	kfree(param_value);
-	return 0;
-}
-
-static int msm_voc_session_id_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	voc_session_id = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: voc_session_id=%u\n", __func__, voc_session_id);
-
-	return 0;
-}
-
-static int msm_voc_session_id_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = voc_session_id;
-
-	return 0;
-}
-
-static struct snd_kcontrol_new msm_voc_session_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Voc VSID", SND_SOC_NOPM, 0,
-			     0xFFFFFFFF, 0, 1, msm_voc_session_id_get,
-			     msm_voc_session_id_put),
-};
-
-static int msm_sound_focus_info(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(struct sound_focus_param);
-
-	return 0;
-}
-
-static int msm_voice_sound_focus_put(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct sound_focus_param soundFocusData;
-
-	memcpy((void *)&soundFocusData, ucontrol->value.bytes.data,
-		sizeof(struct sound_focus_param));
-	ret = voc_set_sound_focus(soundFocusData);
-	if (ret) {
-		pr_err("%s: Error setting Sound Focus Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int msm_voice_sound_focus_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct sound_focus_param soundFocusData;
-
-	memset(&soundFocusData, 0, sizeof(struct sound_focus_param));
-
-	ret = voc_get_sound_focus(&soundFocusData);
-	if (ret) {
-		pr_err("%s: Error getting Sound Focus Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	memcpy(ucontrol->value.bytes.data, (void *)&soundFocusData,
-		sizeof(struct sound_focus_param));
-
-done:
-	return ret;
-}
-
-static int msm_source_tracking_info(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(struct source_tracking_param);
-
-	return 0;
-}
-
-static int msm_voice_source_tracking_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct source_tracking_param sourceTrackingData;
-
-	memset(&sourceTrackingData, 0, sizeof(struct source_tracking_param));
-
-	ret = voc_get_source_tracking(&sourceTrackingData);
-	if (ret) {
-		pr_err("%s: Error getting Source Tracking Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	memcpy(ucontrol->value.bytes.data, (void *)&sourceTrackingData,
-		sizeof(struct source_tracking_param));
-
-done:
-	return ret;
-}
-
-static int msm_audio_get_copp_idx_from_port_id(int port_id, int session_type,
-					 int *copp_idx)
-{
-	int i, idx, be_idx;
-	int ret = 0;
-	unsigned long copp;
-
-	pr_debug("%s: Enter, port_id=%d\n", __func__, port_id);
-
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port validation failed id 0x%x ret %d\n",
-			__func__, port_id, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
-		if (msm_bedais[be_idx].port_id == port_id)
-			break;
-	}
-	if (be_idx >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: Invalid be id %d\n", __func__, be_idx);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for_each_set_bit(i, &msm_bedais[be_idx].fe_sessions[0],
-			 MSM_FRONTEND_DAI_MM_SIZE) {
-		for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-			copp = session_copp_map[i]
-				[session_type][be_idx];
-			if (test_bit(idx, &copp))
-				break;
-		}
-		if (idx >= MAX_COPPS_PER_PORT)
-			continue;
-		else
-			break;
-	}
-	if (i >= MSM_FRONTEND_DAI_MM_SIZE) {
-		pr_err("%s: Invalid FE, exiting\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	*copp_idx = idx;
-	pr_debug("%s: copp_idx=%d\n", __func__, *copp_idx);
-
-done:
-	return ret;
-}
-
-static int msm_audio_sound_focus_derive_port_id(struct snd_kcontrol *kcontrol,
-					    const char *prefix, int *port_id)
-{
-	int ret = 0;
-
-	pr_debug("%s: Enter, prefix:%s\n", __func__, prefix);
-
-	/*
-	 * Mixer control name will be like "Sound Focus Audio Tx SLIMBUS_0"
-	 * where the prefix is "Sound Focus Audio Tx ". Skip the prefix
-	 * and compare the string with the backend name to derive the port id.
-	 */
-	if (!strcmp(kcontrol->id.name + strlen(prefix),
-					"SLIMBUS_0")) {
-		*port_id = SLIMBUS_0_TX;
-	} else if (!strcmp(kcontrol->id.name + strlen(prefix),
-					"TERT_MI2S")) {
-		*port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-	} else if (!strcmp(kcontrol->id.name + strlen(prefix),
-					"INT3_MI2S")) {
-		*port_id = AFE_PORT_ID_INT3_MI2S_TX;
-	} else {
-		pr_err("%s: mixer ctl name=%s, could not derive valid port id\n",
-			__func__, kcontrol->id.name);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	pr_debug("%s: mixer ctl name=%s, derived port_id=%d\n",
-		  __func__, kcontrol->id.name, *port_id);
-
-done:
-	return ret;
-}
-
-static int msm_audio_sound_focus_put(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct sound_focus_param soundFocusData;
-	int port_id, copp_idx;
-
-	ret = msm_audio_sound_focus_derive_port_id(kcontrol,
-				"Sound Focus Audio Tx ", &port_id);
-	if (ret != 0) {
-		pr_err("%s: Error in deriving port id, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = msm_audio_get_copp_idx_from_port_id(port_id, SESSION_TYPE_TX,
-					    &copp_idx);
-	if (ret) {
-		pr_err("%s: Could not get copp idx for port_id=%d\n",
-			__func__, port_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy((void *)&soundFocusData, ucontrol->value.bytes.data,
-		sizeof(struct sound_focus_param));
-
-	ret = adm_set_sound_focus(port_id, copp_idx, soundFocusData);
-	if (ret) {
-		pr_err("%s: Error setting Sound Focus Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_audio_sound_focus_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct sound_focus_param soundFocusData;
-	int port_id, copp_idx;
-
-	ret = msm_audio_sound_focus_derive_port_id(kcontrol,
-				"Sound Focus Audio Tx ", &port_id);
-	if (ret) {
-		pr_err("%s: Error in deriving port id, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = msm_audio_get_copp_idx_from_port_id(port_id, SESSION_TYPE_TX,
-					    &copp_idx);
-	if (ret) {
-		pr_err("%s: Could not get copp idx for port_id=%d\n",
-			__func__, port_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = adm_get_sound_focus(port_id, copp_idx, &soundFocusData);
-	if (ret) {
-		pr_err("%s: Error getting Sound Focus Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(ucontrol->value.bytes.data, (void *)&soundFocusData,
-		sizeof(struct sound_focus_param));
-
-done:
-	return ret;
-}
-
-static int msm_audio_source_tracking_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	struct source_tracking_param sourceTrackingData;
-	int port_id, copp_idx;
-
-	ret = msm_audio_sound_focus_derive_port_id(kcontrol,
-				"Source Tracking Audio Tx ", &port_id);
-	if (ret) {
-		pr_err("%s: Error in deriving port id, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = msm_audio_get_copp_idx_from_port_id(port_id, SESSION_TYPE_TX,
-					    &copp_idx);
-	if (ret) {
-		pr_err("%s: Could not get copp idx for port_id=%d\n",
-			__func__, port_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = adm_get_source_tracking(port_id, copp_idx, &sourceTrackingData);
-	if (ret) {
-		pr_err("%s: Error getting Source Tracking Params, err=%d\n",
-			  __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(ucontrol->value.bytes.data, (void *)&sourceTrackingData,
-		sizeof(struct source_tracking_param));
-
-done:
-	return ret;
-}
-
-static const struct snd_kcontrol_new msm_source_tracking_controls[] = {
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Voice Tx SLIMBUS_0",
-		.info	= msm_sound_focus_info,
-		.get	= msm_voice_sound_focus_get,
-		.put	= msm_voice_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Voice Tx SLIMBUS_0",
-		.info	= msm_source_tracking_info,
-		.get	= msm_voice_source_tracking_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Audio Tx SLIMBUS_0",
-		.info	= msm_sound_focus_info,
-		.get	= msm_audio_sound_focus_get,
-		.put	= msm_audio_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Audio Tx SLIMBUS_0",
-		.info	= msm_source_tracking_info,
-		.get	= msm_audio_source_tracking_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Voice Tx TERT_MI2S",
-		.info	= msm_sound_focus_info,
-		.get	= msm_voice_sound_focus_get,
-		.put	= msm_voice_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Voice Tx TERT_MI2S",
-		.info	= msm_source_tracking_info,
-		.get	= msm_voice_source_tracking_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Audio Tx TERT_MI2S",
-		.info	= msm_sound_focus_info,
-		.get	= msm_audio_sound_focus_get,
-		.put	= msm_audio_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Audio Tx TERT_MI2S",
-		.info	= msm_source_tracking_info,
-		.get	= msm_audio_source_tracking_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Voice Tx INT3_MI2S",
-		.info	= msm_sound_focus_info,
-		.get	= msm_voice_sound_focus_get,
-		.put	= msm_voice_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Voice Tx INT3_MI2S",
-		.info	= msm_source_tracking_info,
-		.get	= msm_voice_source_tracking_get,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Sound Focus Audio Tx INT3_MI2S",
-		.info	= msm_sound_focus_info,
-		.get	= msm_audio_sound_focus_get,
-		.put	= msm_audio_sound_focus_put,
-	},
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "Source Tracking Audio Tx INT3_MI2S",
-		.info	= msm_source_tracking_info,
-		.get	= msm_audio_source_tracking_get,
-	},
-};
-
-static int spkr_prot_put_vi_lch_port(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int item;
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-
-	pr_debug("%s item is %d\n", __func__,
-		   ucontrol->value.enumerated.item[0]);
-	mutex_lock(&routing_lock);
-	item = ucontrol->value.enumerated.item[0];
-	if (item < e->items) {
-		pr_debug("%s RX DAI ID %d TX DAI id %d\n",
-			__func__, e->shift_l, e->values[item]);
-		if (e->shift_l < MSM_BACKEND_DAI_MAX &&
-			e->values[item] < MSM_BACKEND_DAI_MAX)
-			/* Enable feedback TX path */
-			ret = afe_spk_prot_feed_back_cfg(
-			   msm_bedais[e->values[item]].port_id,
-			   msm_bedais[e->shift_l].port_id, 1, 0, 1);
-		else {
-			pr_debug("%s values are out of range item %d\n",
-			__func__, e->values[item]);
-			/* Disable feedback TX path */
-			if (e->values[item] == MSM_BACKEND_DAI_MAX)
-				ret = afe_spk_prot_feed_back_cfg(0, 0, 0, 0, 0);
-			else
-				ret = -EINVAL;
-		}
-	} else {
-		pr_err("%s item value is out of range item\n", __func__);
-		ret = -EINVAL;
-	}
-	mutex_unlock(&routing_lock);
-	return ret;
-}
-
-static int spkr_prot_put_vi_rch_port(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int item;
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-
-	pr_debug("%s item is %d\n", __func__,
-			ucontrol->value.enumerated.item[0]);
-	mutex_lock(&routing_lock);
-	item = ucontrol->value.enumerated.item[0];
-	if (item < e->items) {
-		pr_debug("%s RX DAI ID %d TX DAI id %d\n",
-				__func__, e->shift_l, e->values[item]);
-		if (e->shift_l < MSM_BACKEND_DAI_MAX &&
-				e->values[item] < MSM_BACKEND_DAI_MAX)
-			/* Enable feedback TX path */
-			ret = afe_spk_prot_feed_back_cfg(
-					msm_bedais[e->values[item]].port_id,
-					msm_bedais[e->shift_l].port_id,
-					1, 1, 1);
-		else {
-			pr_debug("%s values are out of range item %d\n",
-					__func__, e->values[item]);
-			/* Disable feedback TX path */
-			if (e->values[item] == MSM_BACKEND_DAI_MAX)
-				ret = afe_spk_prot_feed_back_cfg(0,
-						0, 0, 0, 0);
-			else
-				ret = -EINVAL;
-		}
-	} else {
-		pr_err("%s item value is out of range item\n", __func__);
-		ret = -EINVAL;
-	}
-	mutex_unlock(&routing_lock);
-	return ret;
-}
-
-static int spkr_prot_get_vi_lch_port(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s\n", __func__);
-	return 0;
-}
-
-static int spkr_prot_get_vi_rch_port(struct snd_kcontrol *kcontrol,
-		struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s\n", __func__);
-	ucontrol->value.enumerated.item[0] = 0;
-	return 0;
-}
-
-static const char * const slim0_rx_vi_fb_tx_lch_mux_text[] = {
-	"ZERO", "SLIM4_TX"
-};
-
-static const char * const slim0_rx_vi_fb_tx_rch_mux_text[] = {
-	"ZERO", "SLIM4_TX"
-};
-
-static const char * const mi2s_rx_vi_fb_tx_mux_text[] = {
-	"ZERO", "SENARY_TX"
-};
-
-static const char * const int4_mi2s_rx_vi_fb_tx_mono_mux_text[] = {
-	"ZERO", "INT5_MI2S_TX"
-};
-
-static const char * const int4_mi2s_rx_vi_fb_tx_stereo_mux_text[] = {
-	"ZERO", "INT5_MI2S_TX"
-};
-
-static const int const slim0_rx_vi_fb_tx_lch_value[] = {
-	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_SLIMBUS_4_TX
-};
-
-static const int const slim0_rx_vi_fb_tx_rch_value[] = {
-	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_SLIMBUS_4_TX
-};
-
-static const int const mi2s_rx_vi_fb_tx_value[] = {
-	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_SENARY_MI2S_TX
-};
-
-static const int const int4_mi2s_rx_vi_fb_tx_mono_ch_value[] = {
-	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_INT5_MI2S_TX
-};
-
-static const int const int4_mi2s_rx_vi_fb_tx_stereo_ch_value[] = {
-	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_INT5_MI2S_TX
-};
-
-static const struct soc_enum slim0_rx_vi_fb_lch_mux_enum =
-	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0,
-	ARRAY_SIZE(slim0_rx_vi_fb_tx_lch_mux_text),
-	slim0_rx_vi_fb_tx_lch_mux_text, slim0_rx_vi_fb_tx_lch_value);
-
-static const struct soc_enum slim0_rx_vi_fb_rch_mux_enum =
-	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0,
-	ARRAY_SIZE(slim0_rx_vi_fb_tx_rch_mux_text),
-	slim0_rx_vi_fb_tx_rch_mux_text, slim0_rx_vi_fb_tx_rch_value);
-
-static const struct soc_enum mi2s_rx_vi_fb_mux_enum =
-	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_PRI_MI2S_RX, 0, 0,
-	ARRAY_SIZE(mi2s_rx_vi_fb_tx_mux_text),
-	mi2s_rx_vi_fb_tx_mux_text, mi2s_rx_vi_fb_tx_value);
-
-static const struct soc_enum int4_mi2s_rx_vi_fb_mono_ch_mux_enum =
-	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0,
-	ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_mono_mux_text),
-	int4_mi2s_rx_vi_fb_tx_mono_mux_text,
-	int4_mi2s_rx_vi_fb_tx_mono_ch_value);
-
-static const struct soc_enum int4_mi2s_rx_vi_fb_stereo_ch_mux_enum =
-	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0,
-	ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_stereo_mux_text),
-	int4_mi2s_rx_vi_fb_tx_stereo_mux_text,
-	int4_mi2s_rx_vi_fb_tx_stereo_ch_value);
-
-static const struct snd_kcontrol_new slim0_rx_vi_fb_lch_mux =
-	SOC_DAPM_ENUM_EXT("SLIM0_RX_VI_FB_LCH_MUX",
-	slim0_rx_vi_fb_lch_mux_enum, spkr_prot_get_vi_lch_port,
-	spkr_prot_put_vi_lch_port);
-
-static const struct snd_kcontrol_new slim0_rx_vi_fb_rch_mux =
-	SOC_DAPM_ENUM_EXT("SLIM0_RX_VI_FB_RCH_MUX",
-	slim0_rx_vi_fb_rch_mux_enum, spkr_prot_get_vi_rch_port,
-	spkr_prot_put_vi_rch_port);
-
-static const struct snd_kcontrol_new mi2s_rx_vi_fb_mux =
-	SOC_DAPM_ENUM_EXT("PRI_MI2S_RX_VI_FB_MUX",
-	mi2s_rx_vi_fb_mux_enum, spkr_prot_get_vi_lch_port,
-	spkr_prot_put_vi_lch_port);
-
-static const struct snd_kcontrol_new int4_mi2s_rx_vi_fb_mono_ch_mux =
-	SOC_DAPM_ENUM_EXT("INT4_MI2S_RX_VI_FB_MONO_CH_MUX",
-	int4_mi2s_rx_vi_fb_mono_ch_mux_enum, spkr_prot_get_vi_lch_port,
-	spkr_prot_put_vi_lch_port);
-
-static const struct snd_kcontrol_new int4_mi2s_rx_vi_fb_stereo_ch_mux =
-	SOC_DAPM_ENUM_EXT("INT4_MI2S_RX_VI_FB_STEREO_CH_MUX",
-	int4_mi2s_rx_vi_fb_stereo_ch_mux_enum, spkr_prot_get_vi_rch_port,
-	spkr_prot_put_vi_rch_port);
-
-static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
-	/* Frontend AIF */
-	/* Widget name equals to Front-End DAI name<Need confirmation>,
-	 * Stream name must contains substring of front-end dai name
-	 */
-	SND_SOC_DAPM_AIF_IN("MM_DL1", "MultiMedia1 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL2", "MultiMedia2 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL3", "MultiMedia3 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL4", "MultiMedia4 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL5", "MultiMedia5 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL6", "MultiMedia6 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL7", "MultiMedia7 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL8", "MultiMedia8 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL9", "MultiMedia9 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL10", "MultiMedia10 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL11", "MultiMedia11 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL12", "MultiMedia12 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL13", "MultiMedia13 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL14", "MultiMedia14 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL15", "MultiMedia15 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL16", "MultiMedia16 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MM_DL20", "MultiMedia20 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOIP_DL", "VoIP Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL1", "MultiMedia1 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL2", "MultiMedia2 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL3", "MultiMedia3 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL4", "MultiMedia4 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL5", "MultiMedia5 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL6", "MultiMedia6 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL8", "MultiMedia8 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL9", "MultiMedia9 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL10", "MultiMedia10 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL16", "MultiMedia16 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL17", "MultiMedia17 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL18", "MultiMedia18 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL19", "MultiMedia19 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MM_UL20", "MultiMedia20 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("CS-VOICE_DL1", "CS-VOICE Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("CS-VOICE_UL1", "CS-VOICE Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOICE2_DL", "Voice2 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICE2_UL", "Voice2 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VoLTE_DL", "VoLTE Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VoLTE_UL", "VoLTE Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VoWLAN_DL", "VoWLAN Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VoWLAN_UL", "VoWLAN Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOIP_UL", "VoIP Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOICEMMODE1_DL",
-		"VoiceMMode1 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICEMMODE1_UL",
-		"VoiceMMode1 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOICEMMODE2_DL",
-		"VoiceMMode2 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICEMMODE2_UL",
-		"VoiceMMode2 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM0_DL_HL", "SLIMBUS0_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM0_UL_HL", "SLIMBUS0_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("CPE_LSM_UL_HL", "CPE LSM capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM1_DL_HL", "SLIMBUS1_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM1_UL_HL", "SLIMBUS1_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM3_DL_HL", "SLIMBUS3_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM3_UL_HL", "SLIMBUS3_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM4_DL_HL", "SLIMBUS4_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM4_UL_HL", "SLIMBUS4_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM6_DL_HL", "SLIMBUS6_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM6_UL_HL", "SLIMBUS6_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM7_DL_HL", "SLIMBUS7_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM7_UL_HL", "SLIMBUS7_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIM8_DL_HL", "SLIMBUS8_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIM8_UL_HL", "SLIMBUS8_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INTFM_DL_HL", "INT_FM_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INTFM_UL_HL", "INT_FM_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INTHFP_DL_HL", "INT_HFP_BT_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INTHFP_UL_HL", "INT_HFP_BT_HOSTLESS Capture",
-	0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("USBAUDIO_DL_HL", "USBAUDIO_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("USBAUDIO_UL_HL", "USBAUDIO_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("HDMI_DL_HL", "HDMI_HOSTLESS Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_I2S_DL_HL", "SEC_I2S_RX_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT0_MI2S_DL_HL",
-		"INT0 MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT4_MI2S_DL_HL",
-		"INT4 MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_MI2S_DL_HL",
-		"Primary MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_MI2S_DL_HL",
-		"Secondary MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_MI2S_DL_HL",
-		"Tertiary MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_MI2S_DL_HL",
-		"Quaternary MI2S_RX Hostless Playback",
-		0, 0, 0, 0),
-
-	SND_SOC_DAPM_AIF_IN("AUXPCM_DL_HL", "AUXPCM_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("AUXPCM_UL_HL", "AUXPCM_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MI2S_UL_HL", "MI2S_TX_HOSTLESS Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT3_MI2S_UL_HL",
-		"INT3 MI2S_TX Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_MI2S_UL_HL",
-		"Tertiary MI2S_TX Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_MI2S_UL_HL",
-		"Secondary MI2S_TX Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_MI2S_UL_HL",
-		"Primary MI2S_TX Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MI2S_DL_HL", "MI2S_RX_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("DTMF_DL_HL", "DTMF_RX_HOSTLESS Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_MI2S_UL_HL",
-		"Quaternary MI2S_TX Hostless Capture",
-		0, 0, 0, 0),
-
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_0_DL_HL",
-		"Primary TDM0 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_0_UL_HL",
-		"Primary TDM0 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_1_DL_HL",
-		"Primary TDM1 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_1_UL_HL",
-		"Primary TDM1 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_2_DL_HL",
-		"Primary TDM2 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_2_UL_HL",
-		"Primary TDM2 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_3_DL_HL",
-		"Primary TDM3 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_3_UL_HL",
-		"Primary TDM3 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_4_DL_HL",
-		"Primary TDM4 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_4_UL_HL",
-		"Primary TDM4 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_5_DL_HL",
-		"Primary TDM5 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_5_UL_HL",
-		"Primary TDM5 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_6_DL_HL",
-		"Primary TDM6 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_6_UL_HL",
-		"Primary TDM6 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_RX_7_DL_HL",
-		"Primary TDM7 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_TX_7_UL_HL",
-		"Primary TDM7 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_0_DL_HL",
-		"Secondary TDM0 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_0_UL_HL",
-		"Secondary TDM0 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_1_DL_HL",
-		"Secondary TDM1 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_1_UL_HL",
-		"Secondary TDM1 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_2_DL_HL",
-		"Secondary TDM2 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_2_UL_HL",
-		"Secondary TDM2 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_3_DL_HL",
-		"Secondary TDM3 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_3_UL_HL",
-		"Secondary TDM3 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_4_DL_HL",
-		"Secondary TDM4 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_4_UL_HL",
-		"Secondary TDM4 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_5_DL_HL",
-		"Secondary TDM5 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_5_UL_HL",
-		"Secondary TDM5 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_6_DL_HL",
-		"Secondary TDM6 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_6_UL_HL",
-		"Secondary TDM6 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_7_DL_HL",
-		"Secondary TDM7 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_7_UL_HL",
-		"Secondary TDM7 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_0_DL_HL",
-		"Tertiary TDM0 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_0_UL_HL",
-		"Tertiary TDM0 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_1_DL_HL",
-		"Tertiary TDM1 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_1_UL_HL",
-		"Tertiary TDM1 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_2_DL_HL",
-		"Tertiary TDM2 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_2_UL_HL",
-		"Tertiary TDM2 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_3_DL_HL",
-		"Tertiary TDM3 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_3_UL_HL",
-		"Tertiary TDM3 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_4_DL_HL",
-		"Tertiary TDM4 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_4_UL_HL",
-		"Tertiary TDM4 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_5_DL_HL",
-		"Tertiary TDM5 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_5_UL_HL",
-		"Tertiary TDM5 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_6_DL_HL",
-		"Tertiary TDM6 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_6_UL_HL",
-		"Tertiary TDM6 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_7_DL_HL",
-		"Tertiary TDM7 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_7_UL_HL",
-		"Tertiary TDM7 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_0_DL_HL",
-		"Quaternary TDM0 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_0_UL_HL",
-		"Quaternary TDM0 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_1_DL_HL",
-		"Quaternary TDM1 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_1_UL_HL",
-		"Quaternary TDM1 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_2_DL_HL",
-		"Quaternary TDM2 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_2_UL_HL",
-		"Quaternary TDM2 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_3_DL_HL",
-		"Quaternary TDM3 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_3_UL_HL",
-		"Quaternary TDM3 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_4_DL_HL",
-		"Quaternary TDM4 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_4_UL_HL",
-		"Quaternary TDM4 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_5_DL_HL",
-		"Quaternary TDM5 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_5_UL_HL",
-		"Quaternary TDM5 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_6_DL_HL",
-		"Quaternary TDM6 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_6_UL_HL",
-		"Quaternary TDM6 Hostless Capture",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_7_DL_HL",
-		"Quaternary TDM7 Hostless Playback",
-		0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_7_UL_HL",
-		"Quaternary TDM7 Hostless Capture",
-		0, 0, 0, 0),
-
-	/* LSM */
-	SND_SOC_DAPM_AIF_OUT("LSM1_UL_HL", "Listen 1 Audio Service Capture",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM2_UL_HL", "Listen 2 Audio Service Capture",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM3_UL_HL", "Listen 3 Audio Service Capture",
-				 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM4_UL_HL", "Listen 4 Audio Service Capture",
-						 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM5_UL_HL", "Listen 5 Audio Service Capture",
-				 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM6_UL_HL", "Listen 6 Audio Service Capture",
-				 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM7_UL_HL", "Listen 7 Audio Service Capture",
-				 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("LSM8_UL_HL", "Listen 8 Audio Service Capture",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QCHAT_DL", "QCHAT Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QCHAT_UL", "QCHAT Capture", 0, 0, 0, 0),
-	/* Backend AIF */
-	/* Stream name equals to backend dai link stream name */
-	SND_SOC_DAPM_AIF_OUT("PRI_I2S_RX", "Primary I2S Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_I2S_RX", "Secondary I2S Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SPDIF_RX", "SPDIF Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_0_RX", "Slimbus Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_2_RX", "Slimbus2 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_5_RX", "Slimbus5 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("HDMI", "HDMI Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("DISPLAY_PORT", "Display Port Playback",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("MI2S_RX", "MI2S Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_MI2S_RX", "Quaternary MI2S Playback",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_MI2S_RX", "Tertiary MI2S Playback",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_MI2S_RX", "Secondary MI2S Playback",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_MI2S_RX_SD1",
-			"Secondary MI2S Playback SD1",
-			0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_MI2S_RX", "Primary MI2S Playback",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT0_MI2S_RX", "INT0 MI2S Playback",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT4_MI2S_RX", "INT4 MI2S Playback",
-			     0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUIN_MI2S_RX", "Quinary MI2S Playback",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_I2S_TX", "Primary I2S Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("MI2S_TX", "MI2S Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_MI2S_TX", "Quaternary MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_MI2S_TX", "Primary MI2S Capture",
-			    0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_MI2S_TX", "Tertiary MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT2_MI2S_TX", "INT2 MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT3_MI2S_TX", "INT3 MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_MI2S_TX", "Secondary MI2S Capture",
-			    0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_0_TX", "Slimbus Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_2_TX", "Slimbus2 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUIN_MI2S_TX", "Quinary MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SENARY_MI2S_TX", "Senary MI2S Capture",
-						0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT_BT_SCO_RX", "Internal BT-SCO Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT_BT_SCO_TX", "Internal BT-SCO Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT_BT_A2DP_RX", "Internal BT-A2DP Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("INT_FM_RX", "Internal FM Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT_FM_TX", "Internal FM Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PCM_RX", "AFE Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PCM_TX", "AFE Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_0", "Primary TDM0 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_0", "Primary TDM0 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_1", "Primary TDM1 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_1", "Primary TDM1 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_2", "Primary TDM2 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_2", "Primary TDM2 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_3", "Primary TDM3 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_3", "Primary TDM3 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_4", "Primary TDM4 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_4", "Primary TDM4 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_5", "Primary TDM5 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_5", "Primary TDM5 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_6", "Primary TDM6 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_6", "Primary TDM6 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("PRI_TDM_RX_7", "Primary TDM7 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("PRI_TDM_TX_7", "Primary TDM7 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_0", "Secondary TDM0 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_0", "Secondary TDM0 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_1", "Secondary TDM1 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_1", "Secondary TDM1 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_2", "Secondary TDM2 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_2", "Secondary TDM2 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_3", "Secondary TDM3 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_3", "Secondary TDM3 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_4", "Secondary TDM4 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_4", "Secondary TDM4 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_5", "Secondary TDM5 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_5", "Secondary TDM5 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_6", "Secondary TDM6 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_6", "Secondary TDM6 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_TDM_RX_7", "Secondary TDM7 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_TDM_TX_7", "Secondary TDM7 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_0", "Tertiary TDM0 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_0", "Tertiary TDM0 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_1", "Tertiary TDM1 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_1", "Tertiary TDM1 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_2", "Tertiary TDM2 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_2", "Tertiary TDM2 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_3", "Tertiary TDM3 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_3", "Tertiary TDM3 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_4", "Tertiary TDM4 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_4", "Tertiary TDM4 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_5", "Tertiary TDM5 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_5", "Tertiary TDM5 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_6", "Tertiary TDM6 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_6", "Tertiary TDM6 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_TDM_RX_7", "Tertiary TDM7 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_TDM_TX_7", "Tertiary TDM7 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_0", "Quaternary TDM0 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_0", "Quaternary TDM0 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_1", "Quaternary TDM1 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_1", "Quaternary TDM1 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_2", "Quaternary TDM2 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_2", "Quaternary TDM2 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_3", "Quaternary TDM3 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_3", "Quaternary TDM3 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_4", "Quaternary TDM4 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_4", "Quaternary TDM4 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_5", "Quaternary TDM5 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_5", "Quaternary TDM5 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_6", "Quaternary TDM6 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_6", "Quaternary TDM6 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_RX_7", "Quaternary TDM7 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_TDM_TX_7", "Quaternary TDM7 Capture",
-				0, 0, 0, 0),
-	/* incall */
-	SND_SOC_DAPM_AIF_OUT("VOICE_PLAYBACK_TX", "Voice Farend Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICE2_PLAYBACK_TX", "Voice2 Farend Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_RX", "Slimbus4 Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INCALL_RECORD_TX", "Voice Uplink Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INCALL_RECORD_RX", "Voice Downlink Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_4_TX", "Slimbus4 Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SENARY_TX", "Senary_mi2s Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("INT5_MI2S_TX", "INT5 MI2S Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_5_TX", "Slimbus5 Capture", 0, 0, 0, 0),
-
-	SND_SOC_DAPM_AIF_OUT("AUX_PCM_RX", "AUX PCM Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("AUX_PCM_TX", "AUX PCM Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SEC_AUX_PCM_RX", "Sec AUX PCM Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SEC_AUX_PCM_TX", "Sec AUX PCM Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("TERT_AUX_PCM_RX", "Tert AUX PCM Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("TERT_AUX_PCM_TX", "Tert AUX PCM Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("QUAT_AUX_PCM_RX", "Quat AUX PCM Playback",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("QUAT_AUX_PCM_TX", "Quat AUX PCM Capture",
-				0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOICE_STUB_DL", "VOICE_STUB Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICE_STUB_UL", "VOICE_STUB Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOICE2_STUB_DL", "VOICE2_STUB Playback",
-			    0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOICE2_STUB_UL", "VOICE2_STUB Capture",
-			    0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("VOLTE_STUB_DL", "VOLTE_STUB Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("VOLTE_STUB_UL", "VOLTE_STUB Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("STUB_RX", "Stub Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("STUB_TX", "Stub Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_1_RX", "Slimbus1 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_1_TX", "Slimbus1 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("STUB_1_TX", "Stub1 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_3_RX", "Slimbus3 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_3_TX", "Slimbus3 Capture", 0, 0, 0, 0),
-	/* In- call recording */
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_6_RX", "Slimbus6 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_6_TX", "Slimbus6 Capture", 0, 0, 0, 0),
-
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_7_RX", "Slimbus7 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_7_TX", "Slimbus7 Capture", 0, 0, 0, 0),
-
-	SND_SOC_DAPM_AIF_OUT("SLIMBUS_8_RX", "Slimbus8 Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("SLIMBUS_8_TX", "Slimbus8 Capture", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_OUT("USB_AUDIO_RX", "USB Audio Playback", 0, 0, 0, 0),
-	SND_SOC_DAPM_AIF_IN("USB_AUDIO_TX", "USB Audio Capture", 0, 0, 0, 0),
-
-	/* Switch Definitions */
-	SND_SOC_DAPM_SWITCH("SLIMBUS_DL_HL", SND_SOC_NOPM, 0, 0,
-				&slim_fm_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("SLIMBUS1_DL_HL", SND_SOC_NOPM, 0, 0,
-				&slim1_fm_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("SLIMBUS3_DL_HL", SND_SOC_NOPM, 0, 0,
-				&slim3_fm_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("SLIMBUS4_DL_HL", SND_SOC_NOPM, 0, 0,
-				&slim4_fm_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("SLIMBUS6_DL_HL", SND_SOC_NOPM, 0, 0,
-				&slim6_fm_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("PCM_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&pcm_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("INT0_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&int0_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("INT4_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&int4_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("PRI_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&pri_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("SEC_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&sec_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("TERT_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&tert_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("QUAT_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
-				&quat_mi2s_rx_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("HFP_PRI_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
-				&hfp_pri_aux_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("HFP_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
-				&hfp_aux_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("HFP_INT_UL_HL", SND_SOC_NOPM, 0, 0,
-				&hfp_int_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("HFP_SLIM7_UL_HL", SND_SOC_NOPM, 0, 0,
-				&hfp_slim7_switch_mixer_controls),
-	SND_SOC_DAPM_SWITCH("USB_DL_HL", SND_SOC_NOPM, 0, 0,
-				&usb_switch_mixer_controls),
-
-	/* Mixer definitions */
-	SND_SOC_DAPM_MIXER("PRI_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	pri_i2s_rx_mixer_controls, ARRAY_SIZE(pri_i2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	sec_i2s_rx_mixer_controls, ARRAY_SIZE(sec_i2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_rx_mixer_controls, ARRAY_SIZE(slimbus_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_2_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_2_rx_mixer_controls, ARRAY_SIZE(slimbus_2_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_5_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_5_rx_mixer_controls, ARRAY_SIZE(slimbus_5_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_7_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_7_rx_mixer_controls, ARRAY_SIZE(slimbus_7_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("HDMI Mixer", SND_SOC_NOPM, 0, 0,
-	hdmi_mixer_controls, ARRAY_SIZE(hdmi_mixer_controls)),
-	SND_SOC_DAPM_MIXER("DISPLAY_PORT Mixer", SND_SOC_NOPM, 0, 0,
-	display_port_mixer_controls, ARRAY_SIZE(display_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SPDIF_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	spdif_rx_mixer_controls, ARRAY_SIZE(spdif_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	mi2s_rx_mixer_controls, ARRAY_SIZE(mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quaternary_mi2s_rx_mixer_controls,
-				ARRAY_SIZE(quaternary_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tertiary_mi2s_rx_mixer_controls,
-				ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-			   secondary_mi2s_rx_mixer_controls,
-			   ARRAY_SIZE(secondary_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_MI2S_RX_SD1 Audio Mixer", SND_SOC_NOPM, 0, 0,
-			   secondary_mi2s_rx2_mixer_controls,
-			   ARRAY_SIZE(secondary_mi2s_rx2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-			   primary_mi2s_rx_mixer_controls,
-			   ARRAY_SIZE(primary_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT0_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-			   int0_mi2s_rx_mixer_controls,
-			   ARRAY_SIZE(int0_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT4_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-			   int4_mi2s_rx_mixer_controls,
-			   ARRAY_SIZE(int4_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUIN_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quinary_mi2s_rx_mixer_controls,
-				ARRAY_SIZE(quinary_mi2s_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				pri_tdm_rx_0_mixer_controls,
-				ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				pri_tdm_rx_1_mixer_controls,
-				ARRAY_SIZE(pri_tdm_rx_1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				pri_tdm_rx_2_mixer_controls,
-				ARRAY_SIZE(pri_tdm_rx_2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				pri_tdm_rx_3_mixer_controls,
-				ARRAY_SIZE(pri_tdm_rx_3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_TX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				pri_tdm_tx_0_mixer_controls,
-				ARRAY_SIZE(pri_tdm_tx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				sec_tdm_rx_0_mixer_controls,
-				ARRAY_SIZE(sec_tdm_rx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				sec_tdm_rx_1_mixer_controls,
-				ARRAY_SIZE(sec_tdm_rx_1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				sec_tdm_rx_2_mixer_controls,
-				ARRAY_SIZE(sec_tdm_rx_2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				sec_tdm_rx_3_mixer_controls,
-				ARRAY_SIZE(sec_tdm_rx_3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_TX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				sec_tdm_tx_0_mixer_controls,
-				ARRAY_SIZE(sec_tdm_tx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_rx_0_mixer_controls,
-				ARRAY_SIZE(tert_tdm_rx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_TX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_tx_0_mixer_controls,
-				ARRAY_SIZE(tert_tdm_tx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_rx_1_mixer_controls,
-				ARRAY_SIZE(tert_tdm_rx_1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_rx_2_mixer_controls,
-				ARRAY_SIZE(tert_tdm_rx_2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_rx_3_mixer_controls,
-				ARRAY_SIZE(tert_tdm_rx_3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				tert_tdm_rx_4_mixer_controls,
-				ARRAY_SIZE(tert_tdm_rx_4_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quat_tdm_rx_0_mixer_controls,
-				ARRAY_SIZE(quat_tdm_rx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_TX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quat_tdm_tx_0_mixer_controls,
-				ARRAY_SIZE(quat_tdm_tx_0_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quat_tdm_rx_1_mixer_controls,
-				ARRAY_SIZE(quat_tdm_rx_1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quat_tdm_rx_2_mixer_controls,
-				ARRAY_SIZE(quat_tdm_rx_2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
-				quat_tdm_rx_3_mixer_controls,
-				ARRAY_SIZE(quat_tdm_rx_3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul1_mixer_controls, ARRAY_SIZE(mmul1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul2_mixer_controls, ARRAY_SIZE(mmul2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia3 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul3_mixer_controls, ARRAY_SIZE(mmul3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia4 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul4_mixer_controls, ARRAY_SIZE(mmul4_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul5_mixer_controls, ARRAY_SIZE(mmul5_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia6 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul6_mixer_controls, ARRAY_SIZE(mmul6_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul8_mixer_controls, ARRAY_SIZE(mmul8_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia9 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul9_mixer_controls, ARRAY_SIZE(mmul9_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia10 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul10_mixer_controls, ARRAY_SIZE(mmul10_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia16 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul16_mixer_controls, ARRAY_SIZE(mmul16_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia17 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul17_mixer_controls, ARRAY_SIZE(mmul17_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia18 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul18_mixer_controls, ARRAY_SIZE(mmul18_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia19 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul19_mixer_controls, ARRAY_SIZE(mmul19_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MultiMedia20 Mixer", SND_SOC_NOPM, 0, 0,
-	mmul20_mixer_controls, ARRAY_SIZE(mmul20_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	auxpcm_rx_mixer_controls, ARRAY_SIZE(auxpcm_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	sec_auxpcm_rx_mixer_controls, ARRAY_SIZE(sec_auxpcm_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	tert_auxpcm_rx_mixer_controls,
-	ARRAY_SIZE(tert_auxpcm_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	quat_auxpcm_rx_mixer_controls,
-	ARRAY_SIZE(quat_auxpcm_rx_mixer_controls)),
-	/* incall */
-	SND_SOC_DAPM_MIXER("Incall_Music Audio Mixer", SND_SOC_NOPM, 0, 0,
-	incall_music_delivery_mixer_controls,
-	ARRAY_SIZE(incall_music_delivery_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Incall_Music_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
-	incall_music2_delivery_mixer_controls,
-	ARRAY_SIZE(incall_music2_delivery_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_4_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_4_rx_mixer_controls,
-	ARRAY_SIZE(slimbus_4_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_6_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_6_rx_mixer_controls,
-	ARRAY_SIZE(slimbus_6_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("USB_AUDIO_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	usb_audio_rx_mixer_controls,
-	ARRAY_SIZE(usb_audio_rx_mixer_controls)),
-	/* Voice Mixer */
-	SND_SOC_DAPM_MIXER("PRI_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0, pri_rx_voice_mixer_controls,
-				ARRAY_SIZE(pri_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				sec_i2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(sec_i2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				sec_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(sec_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIM_0_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				slimbus_rx_voice_mixer_controls,
-				ARRAY_SIZE(slimbus_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				bt_sco_rx_voice_mixer_controls,
-				ARRAY_SIZE(bt_sco_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AFE_PCM_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				afe_pcm_rx_voice_mixer_controls,
-				ARRAY_SIZE(afe_pcm_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AUX_PCM_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				aux_pcm_rx_voice_mixer_controls,
-				ARRAY_SIZE(aux_pcm_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX_Voice Mixer",
-			      SND_SOC_NOPM, 0, 0,
-			      sec_aux_pcm_rx_voice_mixer_controls,
-			      ARRAY_SIZE(sec_aux_pcm_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_AUX_PCM_RX_Voice Mixer",
-			      SND_SOC_NOPM, 0, 0,
-			      tert_aux_pcm_rx_voice_mixer_controls,
-			      ARRAY_SIZE(tert_aux_pcm_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_AUX_PCM_RX_Voice Mixer",
-			      SND_SOC_NOPM, 0, 0,
-			      quat_aux_pcm_rx_voice_mixer_controls,
-			      ARRAY_SIZE(quat_aux_pcm_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("HDMI_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				hdmi_rx_voice_mixer_controls,
-				ARRAY_SIZE(hdmi_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				pri_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(pri_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT0_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				int0_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(int0_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT4_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				int4_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(int4_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				tert_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(tert_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				quat_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(quat_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUIN_MI2S_RX_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				quin_mi2s_rx_voice_mixer_controls,
-				ARRAY_SIZE(quin_mi2s_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_2_Voice Mixer",
-				SND_SOC_NOPM, 0, 0,
-				quat_tdm_rx_2_voice_mixer_controls,
-				ARRAY_SIZE(quat_tdm_rx_2_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Voice_Tx Mixer",
-				SND_SOC_NOPM, 0, 0, tx_voice_mixer_controls,
-				ARRAY_SIZE(tx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Voice2_Tx Mixer",
-			   SND_SOC_NOPM, 0, 0, tx_voice2_mixer_controls,
-			   ARRAY_SIZE(tx_voice2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Voip_Tx Mixer",
-				SND_SOC_NOPM, 0, 0, tx_voip_mixer_controls,
-				ARRAY_SIZE(tx_voip_mixer_controls)),
-	SND_SOC_DAPM_MIXER("VoLTE_Tx Mixer",
-				SND_SOC_NOPM, 0, 0, tx_volte_mixer_controls,
-				ARRAY_SIZE(tx_volte_mixer_controls)),
-	SND_SOC_DAPM_MIXER("VoWLAN_Tx Mixer",
-				SND_SOC_NOPM, 0, 0, tx_vowlan_mixer_controls,
-				ARRAY_SIZE(tx_vowlan_mixer_controls)),
-	SND_SOC_DAPM_MIXER("VoiceMMode1_Tx Mixer",
-			   SND_SOC_NOPM, 0, 0, tx_voicemmode1_mixer_controls,
-			   ARRAY_SIZE(tx_voicemmode1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("VoiceMMode2_Tx Mixer",
-			   SND_SOC_NOPM, 0, 0, tx_voicemmode2_mixer_controls,
-			   ARRAY_SIZE(tx_voicemmode2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	int_bt_sco_rx_mixer_controls, ARRAY_SIZE(int_bt_sco_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INTERNAL_A2DP_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-			int_bt_a2dp_rx_mixer_controls,
-			ARRAY_SIZE(int_bt_a2dp_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INTERNAL_FM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	int_fm_rx_mixer_controls, ARRAY_SIZE(int_fm_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AFE_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
-	afe_pcm_rx_mixer_controls, ARRAY_SIZE(afe_pcm_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Voice Stub Tx Mixer", SND_SOC_NOPM, 0, 0,
-	tx_voice_stub_mixer_controls, ARRAY_SIZE(tx_voice_stub_mixer_controls)),
-	SND_SOC_DAPM_MIXER("Voice2 Stub Tx Mixer", SND_SOC_NOPM, 0, 0,
-			   tx_voice2_stub_mixer_controls,
-			   ARRAY_SIZE(tx_voice2_stub_mixer_controls)),
-	SND_SOC_DAPM_MIXER("VoLTE Stub Tx Mixer", SND_SOC_NOPM, 0, 0,
-	tx_volte_stub_mixer_controls, ARRAY_SIZE(tx_volte_stub_mixer_controls)),
-	SND_SOC_DAPM_MIXER("STUB_RX Mixer", SND_SOC_NOPM, 0, 0,
-	stub_rx_mixer_controls, ARRAY_SIZE(stub_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_1_rx_mixer_controls, ARRAY_SIZE(slimbus_1_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_3_RX_Voice Mixer", SND_SOC_NOPM, 0, 0,
-	slimbus_3_rx_mixer_controls, ARRAY_SIZE(slimbus_3_rx_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIM_6_RX_Voice Mixer",
-			SND_SOC_NOPM, 0, 0,
-			slimbus_6_rx_voice_mixer_controls,
-			ARRAY_SIZE(slimbus_6_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIM_7_RX_Voice Mixer", SND_SOC_NOPM, 0, 0,
-			   slimbus_7_rx_voice_mixer_controls,
-			   ARRAY_SIZE(slimbus_7_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIM_8_RX_Voice Mixer", SND_SOC_NOPM, 0, 0,
-			   slimbus_8_rx_voice_mixer_controls,
-			   ARRAY_SIZE(slimbus_8_rx_voice_mixer_controls)),
-	/* port mixer */
-	SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, sbus_0_rx_port_mixer_controls,
-	ARRAY_SIZE(sbus_0_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AUX_PCM_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, aux_pcm_rx_port_mixer_controls,
-	ARRAY_SIZE(aux_pcm_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_AUXPCM_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, sec_auxpcm_rx_port_mixer_controls,
-	ARRAY_SIZE(sec_auxpcm_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_AUXPCM_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, tert_auxpcm_rx_port_mixer_controls,
-	ARRAY_SIZE(tert_auxpcm_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_AUXPCM_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, quat_auxpcm_rx_port_mixer_controls,
-	ARRAY_SIZE(quat_auxpcm_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	sbus_1_rx_port_mixer_controls,
-	ARRAY_SIZE(sbus_1_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	bt_sco_rx_port_mixer_controls,
-	ARRAY_SIZE(bt_sco_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("AFE_PCM_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, afe_pcm_rx_port_mixer_controls,
-	ARRAY_SIZE(afe_pcm_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("HDMI_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, hdmi_rx_port_mixer_controls,
-	ARRAY_SIZE(hdmi_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("DISPLAY_PORT_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, display_port_rx_port_mixer_controls,
-	ARRAY_SIZE(display_port_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_I2S_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, sec_i2s_rx_port_mixer_controls,
-	ARRAY_SIZE(sec_i2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_3_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, sbus_3_rx_port_mixer_controls,
-	ARRAY_SIZE(sbus_3_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SLIMBUS_6_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, sbus_6_rx_port_mixer_controls,
-	ARRAY_SIZE(sbus_6_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	mi2s_rx_port_mixer_controls, ARRAY_SIZE(mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	primary_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(primary_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	sec_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(sec_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	tert_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(tert_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	quat_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(quat_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_0 Port Mixer", SND_SOC_NOPM, 0, 0,
-	pri_tdm_rx_0_port_mixer_controls,
-	ARRAY_SIZE(pri_tdm_rx_0_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_1 Port Mixer", SND_SOC_NOPM, 0, 0,
-	pri_tdm_rx_1_port_mixer_controls,
-	ARRAY_SIZE(pri_tdm_rx_1_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_2 Port Mixer", SND_SOC_NOPM, 0, 0,
-	pri_tdm_rx_2_port_mixer_controls,
-	ARRAY_SIZE(pri_tdm_rx_2_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("PRI_TDM_RX_3 Port Mixer", SND_SOC_NOPM, 0, 0,
-	pri_tdm_rx_3_port_mixer_controls,
-	ARRAY_SIZE(pri_tdm_rx_3_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_0 Port Mixer", SND_SOC_NOPM, 0, 0,
-	sec_tdm_rx_0_port_mixer_controls,
-	ARRAY_SIZE(sec_tdm_rx_0_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_1 Port Mixer", SND_SOC_NOPM, 0, 0,
-	sec_tdm_rx_1_port_mixer_controls,
-	ARRAY_SIZE(sec_tdm_rx_1_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_2 Port Mixer", SND_SOC_NOPM, 0, 0,
-	sec_tdm_rx_2_port_mixer_controls,
-	ARRAY_SIZE(sec_tdm_rx_2_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("SEC_TDM_RX_3 Port Mixer", SND_SOC_NOPM, 0, 0,
-	sec_tdm_rx_3_port_mixer_controls,
-	ARRAY_SIZE(sec_tdm_rx_3_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_0 Port Mixer", SND_SOC_NOPM, 0, 0,
-	tert_tdm_rx_0_port_mixer_controls,
-	ARRAY_SIZE(tert_tdm_rx_0_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_1 Port Mixer", SND_SOC_NOPM, 0, 0,
-	tert_tdm_rx_1_port_mixer_controls,
-	ARRAY_SIZE(tert_tdm_rx_1_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_2 Port Mixer", SND_SOC_NOPM, 0, 0,
-	tert_tdm_rx_2_port_mixer_controls,
-	ARRAY_SIZE(tert_tdm_rx_2_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("TERT_TDM_RX_3 Port Mixer", SND_SOC_NOPM, 0, 0,
-	tert_tdm_rx_3_port_mixer_controls,
-	ARRAY_SIZE(tert_tdm_rx_3_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_0 Port Mixer", SND_SOC_NOPM, 0, 0,
-	quat_tdm_rx_0_port_mixer_controls,
-	ARRAY_SIZE(quat_tdm_rx_0_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_1 Port Mixer", SND_SOC_NOPM, 0, 0,
-	quat_tdm_rx_1_port_mixer_controls,
-	ARRAY_SIZE(quat_tdm_rx_1_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_2 Port Mixer", SND_SOC_NOPM, 0, 0,
-	quat_tdm_rx_2_port_mixer_controls,
-	ARRAY_SIZE(quat_tdm_rx_2_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_3 Port Mixer", SND_SOC_NOPM, 0, 0,
-	quat_tdm_rx_3_port_mixer_controls,
-	ARRAY_SIZE(quat_tdm_rx_3_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT0_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	int0_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(int0_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("INT4_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0,
-	int4_mi2s_rx_port_mixer_controls,
-	ARRAY_SIZE(int4_mi2s_rx_port_mixer_controls)),
-	SND_SOC_DAPM_MIXER("QCHAT_Tx Mixer",
-	SND_SOC_NOPM, 0, 0, tx_qchat_mixer_controls,
-	ARRAY_SIZE(tx_qchat_mixer_controls)),
-	SND_SOC_DAPM_MIXER("USB_AUDIO_RX_Voice Mixer",
-	SND_SOC_NOPM, 0, 0, usb_audio_rx_voice_mixer_controls,
-	ARRAY_SIZE(usb_audio_rx_voice_mixer_controls)),
-	SND_SOC_DAPM_MIXER("USB_AUDIO_RX Port Mixer",
-	SND_SOC_NOPM, 0, 0, usb_rx_port_mixer_controls,
-	ARRAY_SIZE(usb_rx_port_mixer_controls)),
-	/* lsm mixer definitions */
-	SND_SOC_DAPM_MIXER("LSM1 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm1_mixer_controls, ARRAY_SIZE(lsm1_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM2 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm2_mixer_controls, ARRAY_SIZE(lsm2_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM3 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm3_mixer_controls, ARRAY_SIZE(lsm3_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM4 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm4_mixer_controls, ARRAY_SIZE(lsm4_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM5 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm5_mixer_controls, ARRAY_SIZE(lsm5_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM6 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm6_mixer_controls, ARRAY_SIZE(lsm6_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM7 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm7_mixer_controls, ARRAY_SIZE(lsm7_mixer_controls)),
-	SND_SOC_DAPM_MIXER("LSM8 Mixer", SND_SOC_NOPM, 0, 0,
-	lsm8_mixer_controls, ARRAY_SIZE(lsm8_mixer_controls)),
-	/* Virtual Pins to force backends ON atm */
-	SND_SOC_DAPM_OUTPUT("BE_OUT"),
-	SND_SOC_DAPM_INPUT("BE_IN"),
-
-	SND_SOC_DAPM_MUX("SLIM0_RX_VI_FB_LCH_MUX", SND_SOC_NOPM, 0, 0,
-				&slim0_rx_vi_fb_lch_mux),
-	SND_SOC_DAPM_MUX("SLIM0_RX_VI_FB_RCH_MUX", SND_SOC_NOPM, 0, 0,
-				&slim0_rx_vi_fb_rch_mux),
-	SND_SOC_DAPM_MUX("PRI_MI2S_RX_VI_FB_MUX", SND_SOC_NOPM, 0, 0,
-				&mi2s_rx_vi_fb_mux),
-	SND_SOC_DAPM_MUX("INT4_MI2S_RX_VI_FB_MONO_CH_MUX", SND_SOC_NOPM, 0, 0,
-				&int4_mi2s_rx_vi_fb_mono_ch_mux),
-	SND_SOC_DAPM_MUX("INT4_MI2S_RX_VI_FB_STEREO_CH_MUX", SND_SOC_NOPM, 0, 0,
-				&int4_mi2s_rx_vi_fb_stereo_ch_mux),
-
-	SND_SOC_DAPM_MUX("VOC_EXT_EC MUX", SND_SOC_NOPM, 0, 0,
-			 &voc_ext_ec_mux),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL1 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul1),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL2 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul2),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL3 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul3),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL4 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul4),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL5 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul5),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL6 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul6),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL8 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul8),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL9 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul9),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL10 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul10),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL16 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul16),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL17 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul17),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL18 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul18),
-	SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL19 MUX", SND_SOC_NOPM, 0, 0,
-		&ext_ec_ref_mux_ul19),
-};
-
-static const struct snd_soc_dapm_route intercon[] = {
-	{"PRI_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_I2S_RX", NULL, "PRI_RX Audio Mixer"},
-
-	{"SEC_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_I2S_RX", NULL, "SEC_RX Audio Mixer"},
-
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SLIMBUS_0_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Audio Mixer"},
-
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SLIMBUS_2_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SLIMBUS_2_RX", NULL, "SLIMBUS_2_RX Audio Mixer"},
-
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SLIMBUS_5_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SLIMBUS_5_RX", NULL, "SLIMBUS_5_RX Audio Mixer"},
-
-	{"HDMI Mixer", "MultiMedia1", "MM_DL1"},
-	{"HDMI Mixer", "MultiMedia2", "MM_DL2"},
-	{"HDMI Mixer", "MultiMedia3", "MM_DL3"},
-	{"HDMI Mixer", "MultiMedia4", "MM_DL4"},
-	{"HDMI Mixer", "MultiMedia5", "MM_DL5"},
-	{"HDMI Mixer", "MultiMedia6", "MM_DL6"},
-	{"HDMI Mixer", "MultiMedia7", "MM_DL7"},
-	{"HDMI Mixer", "MultiMedia8", "MM_DL8"},
-	{"HDMI Mixer", "MultiMedia9", "MM_DL9"},
-	{"HDMI Mixer", "MultiMedia10", "MM_DL10"},
-	{"HDMI Mixer", "MultiMedia11", "MM_DL11"},
-	{"HDMI Mixer", "MultiMedia12", "MM_DL12"},
-	{"HDMI Mixer", "MultiMedia13", "MM_DL13"},
-	{"HDMI Mixer", "MultiMedia14", "MM_DL14"},
-	{"HDMI Mixer", "MultiMedia15", "MM_DL15"},
-	{"HDMI Mixer", "MultiMedia16", "MM_DL16"},
-	{"HDMI", NULL, "HDMI Mixer"},
-
-	{"DISPLAY_PORT Mixer", "MultiMedia1", "MM_DL1"},
-	{"DISPLAY_PORT Mixer", "MultiMedia2", "MM_DL2"},
-	{"DISPLAY_PORT Mixer", "MultiMedia3", "MM_DL3"},
-	{"DISPLAY_PORT Mixer", "MultiMedia4", "MM_DL4"},
-	{"DISPLAY_PORT Mixer", "MultiMedia5", "MM_DL5"},
-	{"DISPLAY_PORT Mixer", "MultiMedia6", "MM_DL6"},
-	{"DISPLAY_PORT Mixer", "MultiMedia7", "MM_DL7"},
-	{"DISPLAY_PORT Mixer", "MultiMedia8", "MM_DL8"},
-	{"DISPLAY_PORT Mixer", "MultiMedia9", "MM_DL9"},
-	{"DISPLAY_PORT Mixer", "MultiMedia10", "MM_DL10"},
-	{"DISPLAY_PORT Mixer", "MultiMedia11", "MM_DL11"},
-	{"DISPLAY_PORT Mixer", "MultiMedia12", "MM_DL12"},
-	{"DISPLAY_PORT Mixer", "MultiMedia13", "MM_DL13"},
-	{"DISPLAY_PORT Mixer", "MultiMedia14", "MM_DL14"},
-	{"DISPLAY_PORT Mixer", "MultiMedia15", "MM_DL15"},
-	{"DISPLAY_PORT Mixer", "MultiMedia16", "MM_DL16"},
-	{"DISPLAY_PORT", NULL, "DISPLAY_PORT Mixer"},
-
-	{"SPDIF_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SPDIF_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SPDIF_RX", NULL, "SPDIF_RX Audio Mixer"},
-
-	/* incall */
-	{"Incall_Music Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"Incall_Music Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"Incall_Music Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"Incall_Music Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"VOICE_PLAYBACK_TX", NULL, "Incall_Music Audio Mixer"},
-	{"Incall_Music_2 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"Incall_Music_2 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"Incall_Music_2 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"Incall_Music_2 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"VOICE2_PLAYBACK_TX", NULL, "Incall_Music_2 Audio Mixer"},
-	{"SLIMBUS_4_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_4_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_4_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_4_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_4_RX", NULL, "SLIMBUS_4_RX Audio Mixer"},
-
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SLIMBUS_6_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SLIMBUS_6_RX", NULL, "SLIMBUS_6_RX Audio Mixer"},
-
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SLIMBUS_7_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SLIMBUS_7_RX", NULL, "SLIMBUS_7_RX Audio Mixer"},
-
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"USB_AUDIO_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"USB_AUDIO_RX", NULL, "USB_AUDIO_RX Audio Mixer"},
-
-	{"MultiMedia1 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
-	{"MultiMedia4 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
-	{"MultiMedia8 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
-	{"MultiMedia1 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
-	{"MultiMedia4 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
-	{"MultiMedia8 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
-	{"MultiMedia1 Mixer", "SLIM_4_TX", "SLIMBUS_4_TX"},
-	{"MultiMedia1 Mixer", "SLIM_6_TX", "SLIMBUS_6_TX"},
-	{"MultiMedia1 Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"MultiMedia1 Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"MultiMedia8 Mixer", "SLIM_6_TX", "SLIMBUS_6_TX"},
-	{"MultiMedia8 Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"MultiMedia4 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia17 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia18 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia19 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia8 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia2 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia4 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia17 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia18 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia19 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia8 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia18 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"MultiMedia8 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia3 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia5 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia10 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia16 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia5 Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"MultiMedia5 Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"MultiMedia10 Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"MI2S_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"MI2S_RX", NULL, "MI2S_RX Audio Mixer"},
-
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_MI2S_RX", NULL, "QUAT_MI2S_RX Audio Mixer"},
-
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_MI2S_RX", NULL, "TERT_MI2S_RX Audio Mixer"},
-
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_MI2S_RX", NULL, "SEC_MI2S_RX Audio Mixer"},
-
-	{"SEC_MI2S_RX_SD1 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_MI2S_RX_SD1", NULL, "SEC_MI2S_RX_SD1 Audio Mixer"},
-
-	{"SEC_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX Audio Mixer"},
-
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"INT0_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"INT0_MI2S_RX", NULL, "INT0_MI2S_RX Audio Mixer"},
-
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"INT4_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX Audio Mixer"},
-
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUIN_MI2S_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUIN_MI2S_RX", NULL, "QUIN_MI2S_RX Audio Mixer"},
-
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_RX_0", NULL, "PRI_TDM_RX_0 Audio Mixer"},
-
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_RX_1 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_RX_1", NULL, "PRI_TDM_RX_1 Audio Mixer"},
-
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_RX_2 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_RX_2", NULL, "PRI_TDM_RX_2 Audio Mixer"},
-
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_RX_3 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_RX_3", NULL, "PRI_TDM_RX_3 Audio Mixer"},
-
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_TX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_TX_0", NULL, "PRI_TDM_TX_0 Audio Mixer"},
-
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_RX_0", NULL, "SEC_TDM_RX_0 Audio Mixer"},
-
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_RX_1 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_RX_1", NULL, "SEC_TDM_RX_1 Audio Mixer"},
-
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_RX_2 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_RX_2", NULL, "SEC_TDM_RX_2 Audio Mixer"},
-
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_RX_3 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_RX_3", NULL, "SEC_TDM_RX_3 Audio Mixer"},
-
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_TX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_TX_0", NULL, "SEC_TDM_TX_0 Audio Mixer"},
-
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_RX_0", NULL, "TERT_TDM_RX_0 Audio Mixer"},
-
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_TX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_TX_0", NULL, "TERT_TDM_TX_0 Audio Mixer"},
-
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_RX_1 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_RX_1", NULL, "TERT_TDM_RX_1 Audio Mixer"},
-
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_RX_2 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_RX_2", NULL, "TERT_TDM_RX_2 Audio Mixer"},
-
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_RX_3 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_RX_3", NULL, "TERT_TDM_RX_3 Audio Mixer"},
-
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_TDM_RX_4 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_TDM_RX_4", NULL, "TERT_TDM_RX_4 Audio Mixer"},
-
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_TDM_RX_0 Audio Mixer", "MultiMedia20", "MM_DL20"},
-	{"QUAT_TDM_RX_0", NULL, "QUAT_TDM_RX_0 Audio Mixer"},
-
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"PRI_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PRI_TDM_RX_0", NULL, "PRI_TDM_RX_0 Audio Mixer"},
-
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_TDM_RX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_TDM_RX_0", NULL, "SEC_TDM_RX_0 Audio Mixer"},
-
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_TDM_TX_0 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_TDM_TX_0", NULL, "QUAT_TDM_TX_0 Audio Mixer"},
-
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_TDM_RX_1 Audio Mixer", "MultiMedia20", "MM_DL20"},
-	{"QUAT_TDM_RX_1", NULL, "QUAT_TDM_RX_1 Audio Mixer"},
-
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_TDM_RX_2 Audio Mixer", "MultiMedia20", "MM_DL20"},
-	{"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2 Audio Mixer"},
-
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_TDM_RX_3 Audio Mixer", "MultiMedia20", "MM_DL20"},
-	{"QUAT_TDM_RX_3", NULL, "QUAT_TDM_RX_3 Audio Mixer"},
-
-	{"MultiMedia1 Mixer", "PRI_TX", "PRI_I2S_TX"},
-	{"MultiMedia1 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia2 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia3 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia5 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia10 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia16 Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MultiMedia1 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"MultiMedia2 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"MultiMedia6 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"MultiMedia1 Mixer", "QUIN_MI2S_TX", "QUIN_MI2S_TX"},
-	{"MultiMedia2 Mixer", "QUIN_MI2S_TX", "QUIN_MI2S_TX"},
-	{"MultiMedia1 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia2 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia1 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia2 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia1 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia2 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia1 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia1 Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"MultiMedia3 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"},
-	{"MultiMedia5 Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"MultiMedia10 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"},
-	{"MultiMedia1 Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia3 Mixer", "SEC_AUX_PCM_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia5 Mixer", "SEC_AUX_PCM_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia10 Mixer", "SEC_AUX_PCM_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia16 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"},
-	{"MultiMedia16 Mixer", "SEC_AUX_PCM_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia1 Mixer", "TERT_AUXPCM_UL_TX", "TERT_AUX_PCM_TX"},
-	{"MultiMedia3 Mixer", "TERT_AUX_PCM_TX", "TERT_AUX_PCM_TX"},
-	{"MultiMedia5 Mixer", "TERT_AUX_PCM_TX", "TERT_AUX_PCM_TX"},
-	{"MultiMedia10 Mixer", "TERT_AUX_PCM_TX", "TERT_AUX_PCM_TX"},
-	{"MultiMedia1 Mixer", "QUAT_AUXPCM_UL_TX", "QUAT_AUX_PCM_TX"},
-	{"MultiMedia3 Mixer", "QUAT_AUX_PCM_TX", "QUAT_AUX_PCM_TX"},
-	{"MultiMedia5 Mixer", "QUAT_AUX_PCM_TX", "QUAT_AUX_PCM_TX"},
-	{"MultiMedia10 Mixer", "QUAT_AUX_PCM_TX", "QUAT_AUX_PCM_TX"},
-	{"MultiMedia16 Mixer", "QUAT_AUX_PCM_TX", "QUAT_AUX_PCM_TX"},
-	{"MultiMedia2 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia2 Mixer", "SLIM_6_TX", "SLIMBUS_6_TX"},
-	{"MultiMedia2 Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"MultiMedia2 Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"MultiMedia1 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"MultiMedia1 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia2 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"MultiMedia6 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"MultiMedia6 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia3 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia5 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia10 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia6 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia3 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia5 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia10 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia16 Mixer", "INT2_MI2S_TX", "INT2_MI2S_TX"},
-	{"MultiMedia6 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia3 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia5 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia10 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia16 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"MultiMedia6 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia6 Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"MultiMedia6 Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"MultiMedia6 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-
-	{"MultiMedia1 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia1 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia1 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia1 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia1 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia1 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia1 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia1 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia1 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia1 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia1 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia1 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia1 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia1 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia1 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia1 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia2 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia2 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia2 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia2 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia2 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia2 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia2 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia2 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia2 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia2 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia2 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia2 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia2 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia2 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia2 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia2 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia3 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia3 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia3 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia3 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia3 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia3 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia3 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia3 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia3 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia3 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia3 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia3 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia3 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia3 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia3 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia3 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia4 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia4 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia4 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia4 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia4 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia4 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia4 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia4 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia4 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia4 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia4 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia4 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia4 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia4 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia4 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia4 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia5 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia5 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia5 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia5 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia5 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia5 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia5 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia5 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia5 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia5 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia5 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia5 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia5 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia5 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia5 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia5 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia6 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia6 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia6 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia6 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia6 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia6 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia6 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia6 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia6 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia6 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia6 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia6 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia6 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia6 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia6 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia6 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia8 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia8 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia8 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia8 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia8 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia8 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia8 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia8 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia8 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia8 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia8 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia8 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia8 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia8 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia8 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia8 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia9 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia9 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia9 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia9 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia9 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia9 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia9 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia9 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia10 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia10 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia10 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia10 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia10 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia10 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia10 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia10 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"MultiMedia20 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"MultiMedia20 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"MultiMedia20 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"MultiMedia20 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"MultiMedia20 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia20 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia20 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia20 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia20 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia20 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia20 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia20 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia20 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia20 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia20 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia20 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia20 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia20 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia20 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia20 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-
-	{"MultiMedia1 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia2 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia4 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia5 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia6 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia8 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"MultiMedia10 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-
-	{"MultiMedia16 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"MultiMedia16 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"MultiMedia16 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"MultiMedia16 Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"MultiMedia16 Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"MultiMedia16 Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"MultiMedia16 Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"MultiMedia16 Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"MultiMedia16 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"MultiMedia16 Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"MultiMedia16 Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"MultiMedia16 Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"MultiMedia16 Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"MultiMedia16 Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"MultiMedia16 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"MultiMedia16 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"MultiMedia16 Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia6", "MM_UL6"},
-	{"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Audio Mixer"},
-
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"INTERNAL_A2DP_RX Audio Mixer", "MultiMedia6", "MM_UL6"},
-	{"INT_BT_A2DP_RX", NULL, "INTERNAL_A2DP_RX Audio Mixer"},
-
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"INTERNAL_FM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"INT_FM_RX", NULL, "INTERNAL_FM_RX Audio Mixer"},
-
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"AFE_PCM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"PCM_RX", NULL, "AFE_PCM_RX Audio Mixer"},
-
-	{"MultiMedia1 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia3 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia4 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia10 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia17 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia18 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia19 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia5 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia8 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia16 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"MultiMedia1 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia4 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia16 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia17 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia18 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia19 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia5 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia6 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MultiMedia8 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-
-	{"MultiMedia1 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia3 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia4 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia10 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia17 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia18 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia19 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia5 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia8 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MultiMedia16 Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"MM_UL1", NULL, "MultiMedia1 Mixer"},
-	{"MultiMedia2 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"MM_UL2", NULL, "MultiMedia2 Mixer"},
-	{"MM_UL3", NULL, "MultiMedia3 Mixer"},
-	{"MM_UL4", NULL, "MultiMedia4 Mixer"},
-	{"MM_UL5", NULL, "MultiMedia5 Mixer"},
-	{"MM_UL6", NULL, "MultiMedia6 Mixer"},
-	{"MM_UL8", NULL, "MultiMedia8 Mixer"},
-	{"MM_UL9", NULL, "MultiMedia9 Mixer"},
-	{"MM_UL10", NULL, "MultiMedia10 Mixer"},
-	{"MM_UL16", NULL, "MultiMedia16 Mixer"},
-	{"MM_UL17", NULL, "MultiMedia17 Mixer"},
-	{"MM_UL18", NULL, "MultiMedia18 Mixer"},
-	{"MM_UL19", NULL, "MultiMedia19 Mixer"},
-	{"MM_UL20", NULL, "MultiMedia20 Mixer"},
-
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"AUX_PCM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"AUX_PCM_RX", NULL, "AUX_PCM_RX Audio Mixer"},
-
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"SEC_AUX_PCM_RX", NULL, "SEC_AUX_PCM_RX Audio Mixer"},
-
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"TERT_AUX_PCM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"TERT_AUX_PCM_RX", NULL, "TERT_AUX_PCM_RX Audio Mixer"},
-
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia11", "MM_DL11"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia12", "MM_DL12"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia13", "MM_DL13"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia14", "MM_DL14"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia15", "MM_DL15"},
-	{"QUAT_AUX_PCM_RX Audio Mixer", "MultiMedia16", "MM_DL16"},
-	{"QUAT_AUX_PCM_RX", NULL, "QUAT_AUX_PCM_RX Audio Mixer"},
-
-	{"MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"},
-
-	{"PRI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"PRI_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"PRI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"PRI_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"PRI_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"PRI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"PRI_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"PRI_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"PRI_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"PRI_I2S_RX", NULL, "PRI_RX_Voice Mixer"},
-
-	{"SEC_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SEC_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SEC_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SEC_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SEC_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SEC_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SEC_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SEC_I2S_RX", NULL, "SEC_RX_Voice Mixer"},
-
-	{"SEC_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SEC_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SEC_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SEC_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SEC_MI2S_RX", NULL, "SEC_MI2S_RX_Voice Mixer"},
-
-	{"SLIM_0_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SLIM_0_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SLIM_0_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SLIM_0_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SLIM_0_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SLIM_0_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SLIM_0_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIM_0_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIM_0_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIM_0_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SLIM_0_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SLIM_0_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SLIMBUS_0_RX", NULL, "SLIM_0_RX_Voice Mixer"},
-
-	{"SLIM_6_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SLIM_6_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SLIM_6_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SLIM_6_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SLIM_6_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SLIM_6_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SLIM_6_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIM_6_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIM_6_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIM_6_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SLIM_6_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SLIM_6_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SLIMBUS_6_RX", NULL, "SLIM_6_RX_Voice Mixer"},
-
-	{"USB_AUDIO_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"USB_AUDIO_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"USB_AUDIO_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"USB_AUDIO_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"USB_AUDIO_RX", NULL, "USB_AUDIO_RX_Voice Mixer"},
-
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX_Voice Mixer"},
-
-	{"AFE_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"AFE_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"AFE_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"PCM_RX", NULL, "AFE_PCM_RX_Voice Mixer"},
-
-	{"AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"AUX_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"AUX_PCM_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"AUX_PCM_RX", NULL, "AUX_PCM_RX_Voice Mixer"},
-
-	{"SEC_AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SEC_AUX_PCM_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SEC_AUX_PCM_RX", NULL, "SEC_AUX_PCM_RX_Voice Mixer"},
-
-	{"TERT_AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"TERT_AUX_PCM_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"TERT_AUX_PCM_RX", NULL, "TERT_AUX_PCM_RX_Voice Mixer"},
-
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"QUAT_AUX_PCM_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"QUAT_AUX_PCM_RX", NULL, "QUAT_AUX_PCM_RX_Voice Mixer"},
-
-	{"HDMI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"HDMI_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"HDMI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"HDMI_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"HDMI_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"HDMI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"HDMI_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"HDMI_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"HDMI_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"HDMI", NULL, "HDMI_RX_Voice Mixer"},
-	{"HDMI", NULL, "HDMI_DL_HL"},
-
-	{"MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"},
-
-	{"PRI_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"PRI_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"PRI_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"PRI_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX_Voice Mixer"},
-
-	{"INT0_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"INT0_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"INT0_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"INT0_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"INT0_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"INT0_MI2S_RX", NULL, "INT0_MI2S_RX_Voice Mixer"},
-
-	{"INT4_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"INT4_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"INT4_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"INT4_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"INT4_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_Voice Mixer"},
-
-	{"TERT_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"TERT_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"TERT_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"TERT_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"TERT_MI2S_RX", NULL, "TERT_MI2S_RX_Voice Mixer"},
-
-	{"QUAT_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"QUAT_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"QUAT_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"QUAT_MI2S_RX", NULL, "QUAT_MI2S_RX_Voice Mixer"},
-
-	{"QUIN_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"QUIN_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"QUIN_MI2S_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"QUIN_MI2S_RX", NULL, "QUIN_MI2S_RX_Voice Mixer"},
-
-	{"QUAT_TDM_RX_2_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2_Voice Mixer"},
-
-	{"VOC_EXT_EC MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"VOC_EXT_EC MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"VOC_EXT_EC MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"VOC_EXT_EC MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"VOC_EXT_EC MUX", "SLIM_1_TX",    "SLIMBUS_1_TX"},
-	{"CS-VOICE_UL1", NULL, "VOC_EXT_EC MUX"},
-	{"VOIP_UL", NULL, "VOC_EXT_EC MUX"},
-	{"VoLTE_UL", NULL, "VOC_EXT_EC MUX"},
-	{"VOICE2_UL", NULL, "VOC_EXT_EC MUX"},
-	{"VoWLAN_UL", NULL, "VOC_EXT_EC MUX"},
-	{"VOICEMMODE1_UL", NULL, "VOC_EXT_EC MUX"},
-	{"VOICEMMODE2_UL", NULL, "VOC_EXT_EC MUX"},
-
-	{"AUDIO_REF_EC_UL1 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL1 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL1 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL1 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL1 MUX", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"AUDIO_REF_EC_UL1 MUX", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"AUDIO_REF_EC_UL1 MUX", "QUAT_TDM_RX_0", "QUAT_TDM_RX_0"},
-	{"AUDIO_REF_EC_UL1 MUX", "QUAT_TDM_RX_1", "QUAT_TDM_RX_1"},
-	{"AUDIO_REF_EC_UL1 MUX", "QUAT_TDM_RX_2", "QUAT_TDM_RX_2"},
-	{"AUDIO_REF_EC_UL1 MUX", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-
-	{"AUDIO_REF_EC_UL2 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL2 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL2 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL2 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL3 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL3 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL3 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL3 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL4 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL4 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL4 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL4 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL5 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL5 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL5 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL5 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL6 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL6 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL6 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL6 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL8 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL8 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL8 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL8 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL9 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL9 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL9 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL9 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL10 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL10 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL10 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL10 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL10 MUX", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"AUDIO_REF_EC_UL10 MUX", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"AUDIO_REF_EC_UL10 MUX", "QUAT_TDM_RX_0", "QUAT_TDM_RX_0"},
-	{"AUDIO_REF_EC_UL10 MUX", "QUAT_TDM_RX_1", "QUAT_TDM_RX_1"},
-	{"AUDIO_REF_EC_UL10 MUX", "QUAT_TDM_RX_2", "QUAT_TDM_RX_2"},
-	{"AUDIO_REF_EC_UL10 MUX", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"AUDIO_REF_EC_UL17 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL17 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL17 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL17 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL18 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL18 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL18 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL18 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"AUDIO_REF_EC_UL19 MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"AUDIO_REF_EC_UL19 MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"AUDIO_REF_EC_UL19 MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"AUDIO_REF_EC_UL19 MUX", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-
-	{"MM_UL1", NULL, "AUDIO_REF_EC_UL1 MUX"},
-	{"MM_UL2", NULL, "AUDIO_REF_EC_UL2 MUX"},
-	{"MM_UL3", NULL, "AUDIO_REF_EC_UL3 MUX"},
-	{"MM_UL4", NULL, "AUDIO_REF_EC_UL4 MUX"},
-	{"MM_UL5", NULL, "AUDIO_REF_EC_UL5 MUX"},
-	{"MM_UL6", NULL, "AUDIO_REF_EC_UL6 MUX"},
-	{"MM_UL8", NULL, "AUDIO_REF_EC_UL8 MUX"},
-	{"MM_UL9", NULL, "AUDIO_REF_EC_UL9 MUX"},
-	{"MM_UL10", NULL, "AUDIO_REF_EC_UL10 MUX"},
-	{"MM_UL16", NULL, "AUDIO_REF_EC_UL16 MUX"},
-	{"MM_UL17", NULL, "AUDIO_REF_EC_UL17 MUX"},
-	{"MM_UL18", NULL, "AUDIO_REF_EC_UL18 MUX"},
-	{"MM_UL19", NULL, "AUDIO_REF_EC_UL19 MUX"},
-
-	{"Voice_Tx Mixer", "PRI_TX_Voice", "PRI_I2S_TX"},
-	{"Voice_Tx Mixer", "PRI_MI2S_TX_Voice", "PRI_MI2S_TX"},
-	{"Voice_Tx Mixer", "MI2S_TX_Voice", "MI2S_TX"},
-	{"Voice_Tx Mixer", "TERT_MI2S_TX_Voice", "TERT_MI2S_TX"},
-	{"Voice_Tx Mixer", "SLIM_0_TX_Voice", "SLIMBUS_0_TX"},
-	{"Voice_Tx Mixer", "SLIM_7_TX_Voice", "SLIMBUS_7_TX"},
-	{"Voice_Tx Mixer", "SLIM_8_TX_Voice", "SLIMBUS_8_TX"},
-	{"Voice_Tx Mixer", "USB_AUDIO_TX_Voice", "USB_AUDIO_TX"},
-	{"Voice_Tx Mixer", "INTERNAL_BT_SCO_TX_Voice", "INT_BT_SCO_TX"},
-	{"Voice_Tx Mixer", "AFE_PCM_TX_Voice", "PCM_TX"},
-	{"Voice_Tx Mixer", "AUX_PCM_TX_Voice", "AUX_PCM_TX"},
-	{"Voice_Tx Mixer", "SEC_AUX_PCM_TX_Voice", "SEC_AUX_PCM_TX"},
-	{"Voice_Tx Mixer", "TERT_AUX_PCM_TX_Voice", "TERT_AUX_PCM_TX"},
-	{"Voice_Tx Mixer", "QUAT_AUX_PCM_TX_Voice", "QUAT_AUX_PCM_TX"},
-	{"Voice_Tx Mixer", "SEC_MI2S_TX_Voice", "SEC_MI2S_TX"},
-	{"CS-VOICE_UL1", NULL, "Voice_Tx Mixer"},
-
-	{"Voice2_Tx Mixer", "PRI_TX_Voice2", "PRI_I2S_TX"},
-	{"Voice2_Tx Mixer", "PRI_MI2S_TX_Voice2", "PRI_MI2S_TX"},
-	{"Voice2_Tx Mixer", "MI2S_TX_Voice2", "MI2S_TX"},
-	{"Voice2_Tx Mixer", "TERT_MI2S_TX_Voice2", "TERT_MI2S_TX"},
-	{"Voice2_Tx Mixer", "SLIM_0_TX_Voice2", "SLIMBUS_0_TX"},
-	{"Voice2_Tx Mixer", "SLIM_7_TX_Voice2", "SLIMBUS_7_TX"},
-	{"Voice2_Tx Mixer", "SLIM_8_TX_Voice2", "SLIMBUS_8_TX"},
-	{"Voice2_Tx Mixer", "USB_AUDIO_TX_Voice2", "USB_AUDIO_TX"},
-	{"Voice2_Tx Mixer", "INTERNAL_BT_SCO_TX_Voice2", "INT_BT_SCO_TX"},
-	{"Voice2_Tx Mixer", "AFE_PCM_TX_Voice2", "PCM_TX"},
-	{"Voice2_Tx Mixer", "AUX_PCM_TX_Voice2", "AUX_PCM_TX"},
-	{"Voice2_Tx Mixer", "SEC_AUX_PCM_TX_Voice2", "SEC_AUX_PCM_TX"},
-	{"Voice2_Tx Mixer", "TERT_AUX_PCM_TX_Voice2", "TERT_AUX_PCM_TX"},
-	{"Voice2_Tx Mixer", "QUAT_AUX_PCM_TX_Voice2", "QUAT_AUX_PCM_TX"},
-	{"VOICE2_UL", NULL, "Voice2_Tx Mixer"},
-
-	{"VoLTE_Tx Mixer", "PRI_TX_VoLTE", "PRI_I2S_TX"},
-	{"VoLTE_Tx Mixer", "SLIM_0_TX_VoLTE", "SLIMBUS_0_TX"},
-	{"VoLTE_Tx Mixer", "SLIM_7_TX_VoLTE", "SLIMBUS_7_TX"},
-	{"VoLTE_Tx Mixer", "SLIM_8_TX_VoLTE", "SLIMBUS_8_TX"},
-	{"VoLTE_Tx Mixer", "USB_AUDIO_TX_VoLTE", "USB_AUDIO_TX"},
-	{"VoLTE_Tx Mixer", "INTERNAL_BT_SCO_TX_VoLTE", "INT_BT_SCO_TX"},
-	{"VoLTE_Tx Mixer", "AFE_PCM_TX_VoLTE", "PCM_TX"},
-	{"VoLTE_Tx Mixer", "AUX_PCM_TX_VoLTE", "AUX_PCM_TX"},
-	{"VoLTE_Tx Mixer", "SEC_AUX_PCM_TX_VoLTE", "SEC_AUX_PCM_TX"},
-	{"VoLTE_Tx Mixer", "TERT_AUX_PCM_TX_VoLTE", "TERT_AUX_PCM_TX"},
-	{"VoLTE_Tx Mixer", "QUAT_AUX_PCM_TX_VoLTE", "QUAT_AUX_PCM_TX"},
-	{"VoLTE_Tx Mixer", "MI2S_TX_VoLTE", "MI2S_TX"},
-	{"VoLTE_Tx Mixer", "PRI_MI2S_TX_VoLTE", "PRI_MI2S_TX"},
-	{"VoLTE_Tx Mixer", "TERT_MI2S_TX_VoLTE", "TERT_MI2S_TX"},
-	{"VoLTE_UL", NULL, "VoLTE_Tx Mixer"},
-
-	{"VoWLAN_Tx Mixer", "PRI_TX_VoWLAN", "PRI_I2S_TX"},
-	{"VoWLAN_Tx Mixer", "SLIM_0_TX_VoWLAN", "SLIMBUS_0_TX"},
-	{"VoWLAN_Tx Mixer", "SLIM_7_TX_VoWLAN", "SLIMBUS_7_TX"},
-	{"VoWLAN_Tx Mixer", "SLIM_8_TX_VoWLAN", "SLIMBUS_8_TX"},
-	{"VoWLAN_Tx Mixer", "USB_AUDIO_TX_VoWLAN", "USB_AUDIO_TX"},
-	{"VoWLAN_Tx Mixer", "INTERNAL_BT_SCO_TX_VoWLAN", "INT_BT_SCO_TX"},
-	{"VoWLAN_Tx Mixer", "AFE_PCM_TX_VoWLAN", "PCM_TX"},
-	{"VoWLAN_Tx Mixer", "AUX_PCM_TX_VoWLAN", "AUX_PCM_TX"},
-	{"VoWLAN_Tx Mixer", "SEC_AUX_PCM_TX_VoWLAN", "SEC_AUX_PCM_TX"},
-	{"VoWLAN_Tx Mixer", "TERT_AUX_PCM_TX_VoWLAN", "TERT_AUX_PCM_TX"},
-	{"VoWLAN_Tx Mixer", "QUAT_AUX_PCM_TX_VoWLAN", "QUAT_AUX_PCM_TX"},
-	{"VoWLAN_Tx Mixer", "MI2S_TX_VoWLAN", "MI2S_TX"},
-	{"VoWLAN_Tx Mixer", "PRI_MI2S_TX_VoWLAN", "PRI_MI2S_TX"},
-	{"VoWLAN_Tx Mixer", "TERT_MI2S_TX_VoWLAN", "TERT_MI2S_TX"},
-	{"VoWLAN_UL", NULL, "VoWLAN_Tx Mixer"},
-
-	{"VoiceMMode1_Tx Mixer", "PRI_TX_MMode1", "PRI_I2S_TX"},
-	{"VoiceMMode1_Tx Mixer", "PRI_MI2S_TX_MMode1", "PRI_MI2S_TX"},
-	{"VoiceMMode1_Tx Mixer", "MI2S_TX_MMode1", "MI2S_TX"},
-	{"VoiceMMode1_Tx Mixer", "TERT_MI2S_TX_MMode1", "TERT_MI2S_TX"},
-	{"VoiceMMode1_Tx Mixer", "INT3_MI2S_TX_MMode1", "INT3_MI2S_TX"},
-	{"VoiceMMode1_Tx Mixer", "SLIM_0_TX_MMode1", "SLIMBUS_0_TX"},
-	{"VoiceMMode1_Tx Mixer", "SLIM_7_TX_MMode1", "SLIMBUS_7_TX"},
-	{"VoiceMMode1_Tx Mixer", "SLIM_8_TX_MMode1", "SLIMBUS_8_TX"},
-	{"VoiceMMode1_Tx Mixer", "USB_AUDIO_TX_MMode1", "USB_AUDIO_TX"},
-	{"VoiceMMode1_Tx Mixer", "INT_BT_SCO_TX_MMode1", "INT_BT_SCO_TX"},
-	{"VoiceMMode1_Tx Mixer", "AFE_PCM_TX_MMode1", "PCM_TX"},
-	{"VoiceMMode1_Tx Mixer", "AUX_PCM_TX_MMode1", "AUX_PCM_TX"},
-	{"VoiceMMode1_Tx Mixer", "SEC_AUX_PCM_TX_MMode1", "SEC_AUX_PCM_TX"},
-	{"VoiceMMode1_Tx Mixer", "TERT_AUX_PCM_TX_MMode1", "TERT_AUX_PCM_TX"},
-	{"VoiceMMode1_Tx Mixer", "QUAT_AUX_PCM_TX_MMode1", "QUAT_AUX_PCM_TX"},
-	{"VoiceMMode1_Tx Mixer", "QUAT_TDM_TX_0_MMode1", "QUAT_TDM_TX_0"},
-	{"VOICEMMODE1_UL", NULL, "VoiceMMode1_Tx Mixer"},
-
-	{"VoiceMMode2_Tx Mixer", "PRI_TX_MMode2", "PRI_I2S_TX"},
-	{"VoiceMMode2_Tx Mixer", "PRI_MI2S_TX_MMode2", "PRI_MI2S_TX"},
-	{"VoiceMMode2_Tx Mixer", "MI2S_TX_MMode2", "MI2S_TX"},
-	{"VoiceMMode2_Tx Mixer", "TERT_MI2S_TX_MMode2", "TERT_MI2S_TX"},
-	{"VoiceMMode2_Tx Mixer", "INT3_MI2S_TX_MMode2", "INT3_MI2S_TX"},
-	{"VoiceMMode2_Tx Mixer", "SLIM_0_TX_MMode2", "SLIMBUS_0_TX"},
-	{"VoiceMMode2_Tx Mixer", "SLIM_7_TX_MMode2", "SLIMBUS_7_TX"},
-	{"VoiceMMode2_Tx Mixer", "SLIM_8_TX_MMode2", "SLIMBUS_8_TX"},
-	{"VoiceMMode2_Tx Mixer", "USB_AUDIO_TX_MMode2", "USB_AUDIO_TX"},
-	{"VoiceMMode2_Tx Mixer", "INT_BT_SCO_TX_MMode2", "INT_BT_SCO_TX"},
-	{"VoiceMMode2_Tx Mixer", "AFE_PCM_TX_MMode2", "PCM_TX"},
-	{"VoiceMMode2_Tx Mixer", "AUX_PCM_TX_MMode2", "AUX_PCM_TX"},
-	{"VoiceMMode2_Tx Mixer", "SEC_AUX_PCM_TX_MMode2", "SEC_AUX_PCM_TX"},
-	{"VoiceMMode2_Tx Mixer", "TERT_AUX_PCM_TX_MMode2", "TERT_AUX_PCM_TX"},
-	{"VoiceMMode2_Tx Mixer", "QUAT_AUX_PCM_TX_MMode2", "QUAT_AUX_PCM_TX"},
-	{"VOICEMMODE2_UL", NULL, "VoiceMMode2_Tx Mixer"},
-
-	{"Voip_Tx Mixer", "PRI_TX_Voip", "PRI_I2S_TX"},
-	{"Voip_Tx Mixer", "MI2S_TX_Voip", "MI2S_TX"},
-	{"Voip_Tx Mixer", "TERT_MI2S_TX_Voip", "TERT_MI2S_TX"},
-	{"Voip_Tx Mixer", "INT3_MI2S_TX_Voip", "INT3_MI2S_TX"},
-	{"Voip_Tx Mixer", "SLIM_0_TX_Voip", "SLIMBUS_0_TX"},
-	{"Voip_Tx Mixer", "SLIM_7_TX_Voip", "SLIMBUS_7_TX"},
-	{"Voip_Tx Mixer", "SLIM_8_TX_Voip", "SLIMBUS_8_TX"},
-	{"Voip_Tx Mixer", "USB_AUDIO_TX_Voip", "USB_AUDIO_TX"},
-	{"Voip_Tx Mixer", "INTERNAL_BT_SCO_TX_Voip", "INT_BT_SCO_TX"},
-	{"Voip_Tx Mixer", "AFE_PCM_TX_Voip", "PCM_TX"},
-	{"Voip_Tx Mixer", "AUX_PCM_TX_Voip", "AUX_PCM_TX"},
-	{"Voip_Tx Mixer", "SEC_AUX_PCM_TX_Voip", "SEC_AUX_PCM_TX"},
-	{"Voip_Tx Mixer", "TERT_AUX_PCM_TX_Voip", "TERT_AUX_PCM_TX"},
-	{"Voip_Tx Mixer", "QUAT_AUX_PCM_TX_Voip", "QUAT_AUX_PCM_TX"},
-	{"Voip_Tx Mixer", "PRI_MI2S_TX_Voip", "PRI_MI2S_TX"},
-	{"VOIP_UL", NULL, "Voip_Tx Mixer"},
-
-	{"SLIMBUS_DL_HL", "Switch", "SLIM0_DL_HL"},
-	{"SLIMBUS_0_RX", NULL, "SLIMBUS_DL_HL"},
-	{"SLIMBUS1_DL_HL", "Switch", "SLIM1_DL_HL"},
-	{"SLIMBUS_1_RX", NULL, "SLIMBUS1_DL_HL"},
-	{"SLIMBUS3_DL_HL", "Switch", "SLIM3_DL_HL"},
-	{"SLIMBUS_3_RX", NULL, "SLIMBUS3_DL_HL"},
-	{"SLIMBUS4_DL_HL", "Switch", "SLIM4_DL_HL"},
-	{"SLIMBUS_4_RX", NULL, "SLIMBUS4_DL_HL"},
-	{"SLIMBUS6_DL_HL", "Switch", "SLIM0_DL_HL"},
-	{"SLIMBUS_6_RX", NULL, "SLIMBUS6_DL_HL"},
-	{"SLIM0_UL_HL", NULL, "SLIMBUS_0_TX"},
-	{"SLIM1_UL_HL", NULL, "SLIMBUS_1_TX"},
-	{"SLIM3_UL_HL", NULL, "SLIMBUS_3_TX"},
-	{"SLIM4_UL_HL", NULL, "SLIMBUS_4_TX"},
-	{"SLIM8_UL_HL", NULL, "SLIMBUS_8_TX"},
-
-	{"LSM1 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM1 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM1 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM1 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM1 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM1 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"LSM1 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM1 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"LSM1_UL_HL", NULL, "LSM1 Mixer"},
-
-	{"LSM2 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM2 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM2 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM2 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM2 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM2 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"LSM2 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM2 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"LSM2_UL_HL", NULL, "LSM2 Mixer"},
-
-
-	{"LSM3 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM3 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM3 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM3 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM3 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM3 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"LSM3 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM3 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"LSM3_UL_HL", NULL, "LSM3 Mixer"},
-
-
-	{"LSM4 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM4 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM4 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM4 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM4 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM4 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"LSM4 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM4 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"LSM4_UL_HL", NULL, "LSM4 Mixer"},
-
-	{"LSM5 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM5 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM5 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM5 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM5 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM5 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"LSM5 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM5 Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"LSM5_UL_HL", NULL, "LSM5 Mixer"},
-
-	{"LSM6 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM6 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM6 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM6 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM6 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM6 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM6_UL_HL", NULL, "LSM6 Mixer"},
-
-	{"LSM7 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM7 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM7 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM7 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM7 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM7 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM7_UL_HL", NULL, "LSM7 Mixer"},
-
-	{"LSM8 Mixer", "SLIMBUS_0_TX", "SLIMBUS_0_TX"},
-	{"LSM8 Mixer", "SLIMBUS_1_TX", "SLIMBUS_1_TX"},
-	{"LSM8 Mixer", "SLIMBUS_3_TX", "SLIMBUS_3_TX"},
-	{"LSM8 Mixer", "SLIMBUS_4_TX", "SLIMBUS_4_TX"},
-	{"LSM8 Mixer", "SLIMBUS_5_TX", "SLIMBUS_5_TX"},
-	{"LSM8 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"LSM8_UL_HL", NULL, "LSM8 Mixer"},
-
-
-	{"CPE_LSM_UL_HL", NULL, "BE_IN"},
-	{"QCHAT_Tx Mixer", "PRI_TX_QCHAT", "PRI_I2S_TX"},
-	{"QCHAT_Tx Mixer", "SLIM_0_TX_QCHAT", "SLIMBUS_0_TX"},
-	{"QCHAT_Tx Mixer", "SLIM_7_TX_QCHAT", "SLIMBUS_7_TX"},
-	{"QCHAT_Tx Mixer", "SLIM_8_TX_QCHAT", "SLIMBUS_8_TX"},
-	{"QCHAT_Tx Mixer", "INTERNAL_BT_SCO_TX_QCHAT", "INT_BT_SCO_TX"},
-	{"QCHAT_Tx Mixer", "AFE_PCM_TX_QCHAT", "PCM_TX"},
-	{"QCHAT_Tx Mixer", "AUX_PCM_TX_QCHAT", "AUX_PCM_TX"},
-	{"QCHAT_Tx Mixer", "SEC_AUX_PCM_TX_QCHAT", "SEC_AUX_PCM_TX"},
-	{"QCHAT_Tx Mixer", "TERT_AUX_PCM_TX_QCHAT", "TERT_AUX_PCM_TX"},
-	{"QCHAT_Tx Mixer", "QUAT_AUX_PCM_TX_QCHAT", "QUAT_AUX_PCM_TX"},
-	{"QCHAT_Tx Mixer", "MI2S_TX_QCHAT", "MI2S_TX"},
-	{"QCHAT_Tx Mixer", "PRI_MI2S_TX_QCHAT", "PRI_MI2S_TX"},
-	{"QCHAT_Tx Mixer", "TERT_MI2S_TX_QCHAT", "TERT_MI2S_TX"},
-	{"QCHAT_Tx Mixer", "INT3_MI2S_TX_QCHAT", "INT3_MI2S_TX"},
-	{"QCHAT_Tx Mixer", "USB_AUDIO_TX_QCHAT", "USB_AUDIO_TX"},
-	{"QCHAT_UL", NULL, "QCHAT_Tx Mixer"},
-
-	{"INT_FM_RX", NULL, "INTFM_DL_HL"},
-	{"INTFM_UL_HL", NULL, "INT_FM_TX"},
-	{"INTHFP_UL_HL", NULL, "HFP_PRI_AUX_UL_HL"},
-	{"HFP_PRI_AUX_UL_HL", "Switch", "AUX_PCM_TX"},
-	{"INTHFP_UL_HL", NULL, "HFP_AUX_UL_HL"},
-	{"HFP_AUX_UL_HL", "Switch", "SEC_AUX_PCM_TX"},
-	{"INTHFP_UL_HL", NULL, "HFP_INT_UL_HL"},
-	{"HFP_INT_UL_HL", "Switch", "INT_BT_SCO_TX"},
-	{"SLIM7_UL_HL", NULL, "HFP_SLIM7_UL_HL"},
-	{"HFP_SLIM7_UL_HL", "Switch", "SLIMBUS_7_TX"},
-	{"AUX_PCM_RX", NULL, "AUXPCM_DL_HL"},
-	{"AUX_PCM_RX", NULL, "INTHFP_DL_HL"},
-	{"AUXPCM_UL_HL", NULL, "AUX_PCM_TX"},
-	{"MI2S_RX", NULL, "MI2S_DL_HL"},
-	{"MI2S_UL_HL", NULL, "MI2S_TX"},
-	{"PCM_RX_DL_HL", "Switch", "SLIM0_DL_HL"},
-	{"PCM_RX", NULL, "PCM_RX_DL_HL"},
-
-	/* connect to INT4_MI2S_DL_HL since same pcm_id */
-	{"INT0_MI2S_RX_DL_HL", "Switch", "INT4_MI2S_DL_HL"},
-	{"INT0_MI2S_RX", NULL, "INT0_MI2S_RX_DL_HL"},
-	{"INT4_MI2S_RX_DL_HL", "Switch", "INT4_MI2S_DL_HL"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_DL_HL"},
-	{"PRI_MI2S_RX_DL_HL", "Switch", "PRI_MI2S_DL_HL"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX_DL_HL"},
-	{"SEC_MI2S_RX_DL_HL", "Switch", "SEC_MI2S_DL_HL"},
-	{"SEC_MI2S_RX", NULL, "SEC_MI2S_RX_DL_HL"},
-	{"TERT_MI2S_RX_DL_HL", "Switch", "TERT_MI2S_DL_HL"},
-	{"TERT_MI2S_RX", NULL, "TERT_MI2S_RX_DL_HL"},
-
-	{"QUAT_MI2S_RX_DL_HL", "Switch", "QUAT_MI2S_DL_HL"},
-	{"QUAT_MI2S_RX", NULL, "QUAT_MI2S_RX_DL_HL"},
-	{"MI2S_UL_HL", NULL, "TERT_MI2S_TX"},
-	{"INT3_MI2S_UL_HL", NULL, "INT3_MI2S_TX"},
-	{"TERT_MI2S_UL_HL", NULL, "TERT_MI2S_TX"},
-	{"SEC_I2S_RX", NULL, "SEC_I2S_DL_HL"},
-	{"PRI_MI2S_UL_HL", NULL, "PRI_MI2S_TX"},
-	{"SEC_MI2S_UL_HL", NULL, "SEC_MI2S_TX"},
-	{"SEC_MI2S_RX", NULL, "SEC_MI2S_DL_HL"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_DL_HL"},
-	{"TERT_MI2S_RX", NULL, "TERT_MI2S_DL_HL"},
-	{"QUAT_MI2S_UL_HL", NULL, "QUAT_MI2S_TX"},
-
-	{"PRI_TDM_TX_0_UL_HL", NULL, "PRI_TDM_TX_0"},
-	{"PRI_TDM_TX_1_UL_HL", NULL, "PRI_TDM_TX_1"},
-	{"PRI_TDM_TX_2_UL_HL", NULL, "PRI_TDM_TX_2"},
-	{"PRI_TDM_TX_3_UL_HL", NULL, "PRI_TDM_TX_3"},
-	{"PRI_TDM_RX_0", NULL, "PRI_TDM_RX_0_DL_HL"},
-	{"PRI_TDM_RX_1", NULL, "PRI_TDM_RX_1_DL_HL"},
-	{"PRI_TDM_RX_2", NULL, "PRI_TDM_RX_2_DL_HL"},
-	{"PRI_TDM_RX_3", NULL, "PRI_TDM_RX_3_DL_HL"},
-	{"SEC_TDM_TX_0_UL_HL", NULL, "SEC_TDM_TX_0"},
-	{"SEC_TDM_TX_1_UL_HL", NULL, "SEC_TDM_TX_1"},
-	{"SEC_TDM_TX_2_UL_HL", NULL, "SEC_TDM_TX_2"},
-	{"SEC_TDM_TX_3_UL_HL", NULL, "SEC_TDM_TX_3"},
-	{"SEC_TDM_RX_0", NULL, "SEC_TDM_RX_0_DL_HL"},
-	{"SEC_TDM_RX_1", NULL, "SEC_TDM_RX_1_DL_HL"},
-	{"SEC_TDM_RX_2", NULL, "SEC_TDM_RX_2_DL_HL"},
-	{"SEC_TDM_RX_3", NULL, "SEC_TDM_RX_3_DL_HL"},
-	{"TERT_TDM_TX_0_UL_HL", NULL, "TERT_TDM_TX_0"},
-	{"TERT_TDM_TX_1_UL_HL", NULL, "TERT_TDM_TX_1"},
-	{"TERT_TDM_TX_2_UL_HL", NULL, "TERT_TDM_TX_2"},
-	{"TERT_TDM_TX_3_UL_HL", NULL, "TERT_TDM_TX_3"},
-	{"TERT_TDM_RX_0", NULL, "TERT_TDM_RX_0_DL_HL"},
-	{"TERT_TDM_RX_1", NULL, "TERT_TDM_RX_1_DL_HL"},
-	{"TERT_TDM_RX_2", NULL, "TERT_TDM_RX_2_DL_HL"},
-	{"TERT_TDM_RX_3", NULL, "TERT_TDM_RX_3_DL_HL"},
-	{"QUAT_TDM_TX_0_UL_HL", NULL, "QUAT_TDM_TX_0"},
-	{"QUAT_TDM_TX_1_UL_HL", NULL, "QUAT_TDM_TX_1"},
-	{"QUAT_TDM_TX_2_UL_HL", NULL, "QUAT_TDM_TX_2"},
-	{"QUAT_TDM_TX_3_UL_HL", NULL, "QUAT_TDM_TX_3"},
-	{"QUAT_TDM_RX_0", NULL, "QUAT_TDM_RX_0_DL_HL"},
-	{"QUAT_TDM_RX_1", NULL, "QUAT_TDM_RX_1_DL_HL"},
-	{"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2_DL_HL"},
-	{"QUAT_TDM_RX_3", NULL, "QUAT_TDM_RX_3_DL_HL"},
-
-	{"PRI_TDM_RX_0 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"PRI_TDM_RX_0 Port Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"PRI_TDM_RX_0 Port Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"PRI_TDM_RX_0 Port Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"PRI_TDM_RX_0 Port Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"PRI_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"PRI_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"PRI_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"PRI_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"PRI_TDM_RX_0", NULL, "PRI_TDM_RX_0 Port Mixer"},
-
-	{"PRI_TDM_RX_1 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"PRI_TDM_RX_1 Port Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"PRI_TDM_RX_1 Port Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"PRI_TDM_RX_1 Port Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"PRI_TDM_RX_1 Port Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"PRI_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"PRI_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"PRI_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"PRI_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"PRI_TDM_RX_1", NULL, "PRI_TDM_RX_1 Port Mixer"},
-
-	{"PRI_TDM_RX_2 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"PRI_TDM_RX_2 Port Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"PRI_TDM_RX_2 Port Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"PRI_TDM_RX_2 Port Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"PRI_TDM_RX_2 Port Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"PRI_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"PRI_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"PRI_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"PRI_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"PRI_TDM_RX_2", NULL, "PRI_TDM_RX_2 Port Mixer"},
-
-	{"PRI_TDM_RX_3 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"PRI_TDM_RX_3 Port Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"},
-	{"PRI_TDM_RX_3 Port Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"},
-	{"PRI_TDM_RX_3 Port Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"},
-	{"PRI_TDM_RX_3 Port Mixer", "PRI_TDM_TX_3", "PRI_TDM_TX_3"},
-	{"PRI_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"PRI_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"PRI_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"PRI_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"PRI_TDM_RX_3", NULL, "PRI_TDM_RX_3 Port Mixer"},
-
-	{"SEC_TDM_RX_0 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"SEC_TDM_RX_0 Port Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"SEC_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"SEC_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"SEC_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"SEC_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"SEC_TDM_RX_0", NULL, "SEC_TDM_RX_0 Port Mixer"},
-
-	{"SEC_TDM_RX_1 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"SEC_TDM_RX_1 Port Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"SEC_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"SEC_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"SEC_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"SEC_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"SEC_TDM_RX_1", NULL, "SEC_TDM_RX_1 Port Mixer"},
-
-	{"SEC_TDM_RX_2 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"SEC_TDM_RX_2 Port Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"SEC_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"SEC_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"SEC_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"SEC_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"SEC_TDM_RX_2", NULL, "SEC_TDM_RX_2 Port Mixer"},
-
-	{"SEC_TDM_RX_3 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_TDM_TX_0", "SEC_TDM_TX_0"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_TDM_TX_1", "SEC_TDM_TX_1"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_TDM_TX_2", "SEC_TDM_TX_2"},
-	{"SEC_TDM_RX_3 Port Mixer", "SEC_TDM_TX_3", "SEC_TDM_TX_3"},
-	{"SEC_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"SEC_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"SEC_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"SEC_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"SEC_TDM_RX_3", NULL, "SEC_TDM_RX_3 Port Mixer"},
-
-	{"TERT_TDM_RX_0 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"TERT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"TERT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"TERT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"TERT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"TERT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"TERT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"TERT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"TERT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"TERT_TDM_RX_0", NULL, "TERT_TDM_RX_0 Port Mixer"},
-
-	{"TERT_TDM_RX_1 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"TERT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"TERT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"TERT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"TERT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"TERT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"TERT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"TERT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"TERT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"TERT_TDM_RX_1", NULL, "TERT_TDM_RX_1 Port Mixer"},
-
-	{"TERT_TDM_RX_2 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"TERT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"TERT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"TERT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"TERT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"TERT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"TERT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"TERT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"TERT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"TERT_TDM_RX_2", NULL, "TERT_TDM_RX_2 Port Mixer"},
-
-	{"TERT_TDM_RX_3 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"TERT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"TERT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"TERT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"TERT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"TERT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"TERT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"TERT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"TERT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"TERT_TDM_RX_3", NULL, "TERT_TDM_RX_3 Port Mixer"},
-
-	{"QUAT_TDM_RX_0 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"QUAT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"QUAT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"QUAT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"QUAT_TDM_RX_0 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"QUAT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"QUAT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"QUAT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"QUAT_TDM_RX_0 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"QUAT_TDM_RX_0", NULL, "QUAT_TDM_RX_0 Port Mixer"},
-
-	{"QUAT_TDM_RX_1 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"QUAT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"QUAT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"QUAT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"QUAT_TDM_RX_1 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"QUAT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"QUAT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"QUAT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"QUAT_TDM_RX_1 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"QUAT_TDM_RX_1", NULL, "QUAT_TDM_RX_1 Port Mixer"},
-
-	{"QUAT_TDM_RX_2 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"QUAT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"QUAT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"QUAT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"QUAT_TDM_RX_2 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"QUAT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"QUAT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"QUAT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"QUAT_TDM_RX_2 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2 Port Mixer"},
-
-	{"QUAT_TDM_RX_3 Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"QUAT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"},
-	{"QUAT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_1", "TERT_TDM_TX_1"},
-	{"QUAT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_2", "TERT_TDM_TX_2"},
-	{"QUAT_TDM_RX_3 Port Mixer", "TERT_TDM_TX_3", "TERT_TDM_TX_3"},
-	{"QUAT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"QUAT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},
-	{"QUAT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},
-	{"QUAT_TDM_RX_3 Port Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},
-	{"QUAT_TDM_RX_3", NULL, "QUAT_TDM_RX_3 Port Mixer"},
-
-	{"INT0_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"INT0_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"INT0_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"INT0_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"INT0_MI2S_RX Port Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"INT0_MI2S_RX Port Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"INT0_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"INT0_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"INT0_MI2S_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"INT0_MI2S_RX", NULL, "INT0_MI2S_RX Port Mixer"},
-
-	{"INT4_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"INT4_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"INT4_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"INT4_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"INT4_MI2S_RX Port Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"INT4_MI2S_RX Port Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"INT4_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"INT4_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"INT4_MI2S_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX Port Mixer"},
-
-	{"SLIMBUS_0_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "TERT_AUXPCM_UL_TX", "TERT_AUX_PCM_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "QUAT_AUXPCM_UL_TX", "QUAT_AUX_PCM_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SLIMBUS_0_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Port Mixer"},
-	{"AFE_PCM_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"AFE_PCM_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"PCM_RX", NULL, "AFE_PCM_RX Port Mixer"},
-	{"USB_AUDIO_RX Port Mixer", "USB_AUDIO_TX", "USB_AUDIO_TX"},
-	{"USB_AUDIO_RX", NULL, "USB_AUDIO_RX Port Mixer"},
-	{"USB_DL_HL", "Switch", "USBAUDIO_DL_HL"},
-	{"USB_AUDIO_RX", NULL, "USB_DL_HL"},
-	{"USBAUDIO_UL_HL", NULL, "USB_AUDIO_TX"},
-
-
-	{"AUX_PCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"AUX_PCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"AUX_PCM_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"AUX_PCM_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"AUX_PCM_RX Port Mixer", "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},
-	{"AUX_PCM_RX", NULL, "AUX_PCM_RX Port Mixer"},
-
-	{"SEC_AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SEC_AUXPCM_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SEC_AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"SEC_AUX_PCM_RX", NULL, "SEC_AUXPCM_RX Port Mixer"},
-
-	{"TERT_AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"TERT_AUXPCM_RX Port Mixer", "TERT_AUXPCM_UL_TX", "TERT_AUX_PCM_TX"},
-	{"TERT_AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"TERT_AUX_PCM_RX", NULL, "TERT_AUXPCM_RX Port Mixer"},
-
-	{"QUAT_AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_AUXPCM_RX Port Mixer", "QUAT_AUXPCM_UL_TX", "QUAT_AUX_PCM_TX"},
-	{"QUAT_AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"QUAT_AUX_PCM_RX", NULL, "QUAT_AUXPCM_RX Port Mixer"},
-
-	{"Voice Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"},
-	{"Voice Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"Voice Stub Tx Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"Voice Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"},
-	{"Voice Stub Tx Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"Voice Stub Tx Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"Voice Stub Tx Mixer", "TERT_AUXPCM_UL_TX", "TERT_AUX_PCM_TX"},
-	{"Voice Stub Tx Mixer", "QUAT_AUXPCM_UL_TX", "QUAT_AUX_PCM_TX"},
-	{"Voice Stub Tx Mixer", "MI2S_TX", "MI2S_TX"},
-	{"Voice Stub Tx Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"Voice Stub Tx Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"Voice Stub Tx Mixer", "INT3_MI2S_TX", "INT3_MI2S_TX"},
-	{"Voice Stub Tx Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"Voice Stub Tx Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"Voice Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"},
-	{"Voice Stub Tx Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"Voice Stub Tx Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"Voice Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"VOICE_STUB_UL", NULL, "Voice Stub Tx Mixer"},
-
-	{"VoLTE Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"},
-	{"VoLTE Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"VoLTE Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"},
-	{"VoLTE Stub Tx Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"VoLTE Stub Tx Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"VoLTE Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"},
-	{"VoLTE Stub Tx Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"VoLTE Stub Tx Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"VoLTE Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"VoLTE Stub Tx Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"VoLTE Stub Tx Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"VOLTE_STUB_UL", NULL, "VoLTE Stub Tx Mixer"},
-
-	{"Voice2 Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"},
-	{"Voice2 Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"Voice2 Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"},
-	{"Voice2 Stub Tx Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"Voice2 Stub Tx Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"Voice2 Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"},
-	{"Voice2 Stub Tx Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"Voice2 Stub Tx Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"Voice2 Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"Voice2 Stub Tx Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"Voice2 Stub Tx Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"VOICE2_STUB_UL", NULL, "Voice2 Stub Tx Mixer"},
-
-	{"STUB_RX Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"STUB_RX Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"STUB_RX Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"STUB_RX", NULL, "STUB_RX Mixer"},
-	{"SLIMBUS_1_RX Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIMBUS_1_RX Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIMBUS_1_RX Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Mixer"},
-	{"AFE_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"AFE_PCM_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIMBUS_3_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIMBUS_3_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIMBUS_3_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX_Voice Mixer"},
-
-	{"SLIM_7_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SLIM_7_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SLIM_7_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SLIM_7_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SLIM_7_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SLIM_7_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SLIM_7_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIM_7_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIM_7_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIM_7_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SLIM_7_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SLIM_7_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SLIMBUS_7_RX", NULL, "SLIM_7_RX_Voice Mixer"},
-
-	{"SLIM_8_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"},
-	{"SLIM_8_RX_Voice Mixer", "Voice2", "VOICE2_DL"},
-	{"SLIM_8_RX_Voice Mixer", "VoLTE", "VoLTE_DL"},
-	{"SLIM_8_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"},
-	{"SLIM_8_RX_Voice Mixer", "Voip", "VOIP_DL"},
-	{"SLIM_8_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"},
-	{"SLIM_8_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"},
-	{"SLIM_8_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"},
-	{"SLIM_8_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"},
-	{"SLIM_8_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
-	{"SLIM_8_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"},
-	{"SLIM_8_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"},
-	{"SLIMBUS_8_RX", NULL, "SLIM_8_RX_Voice Mixer"},
-
-	{"SLIMBUS_1_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SLIMBUS_1_RX Port Mixer", "AFE_PCM_TX", "PCM_TX"},
-	{"SLIMBUS_1_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Port Mixer"},
-	{"INTERNAL_BT_SCO_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"INTERNAL_BT_SCO_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Port Mixer"},
-	{"SLIMBUS_3_RX Port Mixer", "INTERNAL_BT_SCO_RX", "INT_BT_SCO_RX"},
-	{"SLIMBUS_3_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"SLIMBUS_3_RX Port Mixer", "AFE_PCM_RX", "PCM_RX"},
-	{"SLIMBUS_3_RX Port Mixer", "AUX_PCM_RX", "AUX_PCM_RX"},
-	{"SLIMBUS_3_RX Port Mixer", "SLIM_0_RX", "SLIMBUS_0_RX"},
-	{"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX Port Mixer"},
-
-	{"SLIMBUS_6_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SLIMBUS_6_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"SLIMBUS_6_RX", NULL, "SLIMBUS_6_RX Port Mixer"},
-
-	{"HDMI_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"HDMI", NULL, "HDMI_RX Port Mixer"},
-
-	{"DISPLAY_PORT_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"DISPLAY_PORT", NULL, "DISPLAY_PORT_RX Port Mixer"},
-
-	{"SEC_I2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"SEC_I2S_RX", NULL, "SEC_I2S_RX Port Mixer"},
-
-	{"MI2S_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"},
-	{"MI2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"},
-	{"MI2S_RX", NULL, "MI2S_RX Port Mixer"},
-
-	{"PRI_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"PRI_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"PRI_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"PRI_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"PRI_MI2S_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"PRI_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"PRI_MI2S_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
-	{"PRI_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX Port Mixer"},
-
-	{"SEC_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"SEC_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"SEC_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"SEC_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"SEC_MI2S_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"SEC_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"SEC_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"SEC_MI2S_RX", NULL, "SEC_MI2S_RX Port Mixer"},
-
-	{"TERT_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"TERT_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"TERT_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"TERT_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"TERT_MI2S_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"TERT_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"TERT_MI2S_RX", NULL, "TERT_MI2S_RX Port Mixer"},
-
-	{"QUAT_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"},
-	{"QUAT_MI2S_RX Port Mixer", "SLIM_8_TX", "SLIMBUS_8_TX"},
-	{"QUAT_MI2S_RX", NULL, "QUAT_MI2S_RX Port Mixer"},
-
-	/* Backend Enablement */
-
-	{"BE_OUT", NULL, "PRI_I2S_RX"},
-	{"BE_OUT", NULL, "SEC_I2S_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_0_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_1_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_2_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_3_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_4_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_5_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_6_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_7_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_8_RX"},
-	{"BE_OUT", NULL, "USB_AUDIO_RX"},
-	{"BE_OUT", NULL, "HDMI"},
-	{"BE_OUT", NULL, "DISPLAY_PORT"},
-	{"BE_OUT", NULL, "SPDIF_RX"},
-	{"BE_OUT", NULL, "MI2S_RX"},
-	{"BE_OUT", NULL, "QUAT_MI2S_RX"},
-	{"BE_OUT", NULL, "QUIN_MI2S_RX"},
-	{"BE_OUT", NULL, "TERT_MI2S_RX"},
-	{"BE_OUT", NULL, "SEC_MI2S_RX"},
-	{"BE_OUT", NULL, "SEC_MI2S_RX_SD1"},
-	{"BE_OUT", NULL, "PRI_MI2S_RX"},
-	{"BE_OUT", NULL, "INT0_MI2S_RX"},
-	{"BE_OUT", NULL, "INT4_MI2S_RX"},
-	{"BE_OUT", NULL, "INT_BT_SCO_RX"},
-	{"BE_OUT", NULL, "INT_BT_A2DP_RX"},
-	{"BE_OUT", NULL, "INT_FM_RX"},
-	{"BE_OUT", NULL, "PCM_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_3_RX"},
-	{"BE_OUT", NULL, "AUX_PCM_RX"},
-	{"BE_OUT", NULL, "SEC_AUX_PCM_RX"},
-	{"BE_OUT", NULL, "TERT_AUX_PCM_RX"},
-	{"BE_OUT", NULL, "QUAT_AUX_PCM_RX"},
-	{"BE_OUT", NULL, "INT_BT_SCO_RX"},
-	{"BE_OUT", NULL, "INT_FM_RX"},
-	{"BE_OUT", NULL, "PCM_RX"},
-	{"BE_OUT", NULL, "SLIMBUS_3_RX"},
-	{"BE_OUT", NULL, "VOICE_PLAYBACK_TX"},
-	{"BE_OUT", NULL, "VOICE2_PLAYBACK_TX"},
-	{"BE_OUT", NULL, "PRI_TDM_RX_0"},
-	{"BE_OUT", NULL, "PRI_TDM_RX_1"},
-	{"BE_OUT", NULL, "PRI_TDM_RX_2"},
-	{"BE_OUT", NULL, "PRI_TDM_RX_3"},
-	{"BE_OUT", NULL, "SEC_TDM_RX_0"},
-	{"BE_OUT", NULL, "SEC_TDM_RX_1"},
-	{"BE_OUT", NULL, "SEC_TDM_RX_2"},
-	{"BE_OUT", NULL, "SEC_TDM_RX_3"},
-	{"BE_OUT", NULL, "TERT_TDM_RX_0"},
-	{"BE_OUT", NULL, "TERT_TDM_RX_1"},
-	{"BE_OUT", NULL, "TERT_TDM_RX_2"},
-	{"BE_OUT", NULL, "TERT_TDM_RX_3"},
-	{"BE_OUT", NULL, "TERT_TDM_RX_4"},
-	{"BE_OUT", NULL, "QUAT_TDM_RX_0"},
-	{"BE_OUT", NULL, "QUAT_TDM_RX_1"},
-	{"BE_OUT", NULL, "QUAT_TDM_RX_2"},
-	{"BE_OUT", NULL, "QUAT_TDM_RX_3"},
-
-	{"PRI_I2S_TX", NULL, "BE_IN"},
-	{"MI2S_TX", NULL, "BE_IN"},
-	{"QUAT_MI2S_TX", NULL, "BE_IN"},
-	{"QUIN_MI2S_TX", NULL, "BE_IN"},
-	{"PRI_MI2S_TX", NULL, "BE_IN"},
-	{"TERT_MI2S_TX", NULL, "BE_IN"},
-	{"INT2_MI2S_TX", NULL, "BE_IN"},
-	{"INT3_MI2S_TX", NULL, "BE_IN"},
-	{"INT5_MI2S_TX", NULL, "BE_IN"},
-	{"SEC_MI2S_TX", NULL, "BE_IN"},
-	{"SENARY_MI2S_TX", NULL, "BE_IN" },
-	{"SLIMBUS_0_TX", NULL, "BE_IN" },
-	{"SLIMBUS_1_TX", NULL, "BE_IN" },
-	{"SLIMBUS_3_TX", NULL, "BE_IN" },
-	{"SLIMBUS_4_TX", NULL, "BE_IN" },
-	{"SLIMBUS_5_TX", NULL, "BE_IN" },
-	{"SLIMBUS_6_TX", NULL, "BE_IN" },
-	{"SLIMBUS_7_TX", NULL, "BE_IN" },
-	{"SLIMBUS_8_TX", NULL, "BE_IN" },
-	{"USB_AUDIO_TX", NULL, "BE_IN" },
-	{"INT_BT_SCO_TX", NULL, "BE_IN"},
-	{"INT_FM_TX", NULL, "BE_IN"},
-	{"PCM_TX", NULL, "BE_IN"},
-	{"BE_OUT", NULL, "SLIMBUS_3_RX"},
-	{"BE_OUT", NULL, "STUB_RX"},
-	{"STUB_TX", NULL, "BE_IN"},
-	{"STUB_1_TX", NULL, "BE_IN"},
-	{"BE_OUT", NULL, "AUX_PCM_RX"},
-	{"AUX_PCM_TX", NULL, "BE_IN"},
-	{"SEC_AUX_PCM_TX", NULL, "BE_IN"},
-	{"TERT_AUX_PCM_TX", NULL, "BE_IN"},
-	{"QUAT_AUX_PCM_TX", NULL, "BE_IN"},
-	{"INCALL_RECORD_TX", NULL, "BE_IN"},
-	{"INCALL_RECORD_RX", NULL, "BE_IN"},
-	{"SLIM0_RX_VI_FB_LCH_MUX", "SLIM4_TX", "SLIMBUS_4_TX"},
-	{"SLIM0_RX_VI_FB_RCH_MUX", "SLIM4_TX", "SLIMBUS_4_TX"},
-	{"PRI_MI2S_RX_VI_FB_MUX", "SENARY_TX", "SENARY_TX"},
-	{"INT4_MI2S_RX_VI_FB_MONO_CH_MUX", "INT5_MI2S_TX", "INT5_MI2S_TX"},
-	{"INT4_MI2S_RX_VI_FB_STEREO_CH_MUX", "INT5_MI2S_TX", "INT5_MI2S_TX"},
-	{"SLIMBUS_0_RX", NULL, "SLIM0_RX_VI_FB_LCH_MUX"},
-	{"SLIMBUS_0_RX", NULL, "SLIM0_RX_VI_FB_RCH_MUX"},
-	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX_VI_FB_MUX"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_VI_FB_MONO_CH_MUX"},
-	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_VI_FB_STEREO_CH_MUX"},
-	{"PRI_TDM_TX_0", NULL, "BE_IN"},
-	{"PRI_TDM_TX_1", NULL, "BE_IN"},
-	{"PRI_TDM_TX_2", NULL, "BE_IN"},
-	{"PRI_TDM_TX_3", NULL, "BE_IN"},
-	{"SEC_TDM_TX_0", NULL, "BE_IN"},
-	{"SEC_TDM_TX_1", NULL, "BE_IN"},
-	{"SEC_TDM_TX_2", NULL, "BE_IN"},
-	{"SEC_TDM_TX_3", NULL, "BE_IN"},
-	{"TERT_TDM_TX_0", NULL, "BE_IN"},
-	{"TERT_TDM_TX_1", NULL, "BE_IN"},
-	{"TERT_TDM_TX_2", NULL, "BE_IN"},
-	{"TERT_TDM_TX_3", NULL, "BE_IN"},
-	{"QUAT_TDM_TX_0", NULL, "BE_IN"},
-	{"QUAT_TDM_TX_1", NULL, "BE_IN"},
-	{"QUAT_TDM_TX_2", NULL, "BE_IN"},
-	{"QUAT_TDM_TX_3", NULL, "BE_IN"},
-};
-
-static int msm_pcm_routing_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	unsigned int be_id = rtd->dai_link->id;
-
-	if (be_id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: unexpected BE id %d\n", __func__, be_id);
-		return -EINVAL;
-	}
-
-	mutex_lock(&routing_lock);
-	msm_bedais[be_id].sample_rate = params_rate(params);
-	msm_bedais[be_id].channel = params_channels(params);
-	msm_bedais[be_id].format = params_format(params);
-	pr_debug("%s: BE Sample Rate (%d) format (%d) BE id %d\n",
-		__func__, msm_bedais[be_id].sample_rate,
-		msm_bedais[be_id].format, be_id);
-	mutex_unlock(&routing_lock);
-	return 0;
-}
-
-static int msm_pcm_routing_close(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	unsigned int be_id = rtd->dai_link->id;
-	int i, session_type, path_type, topology;
-	struct msm_pcm_routing_bdai_data *bedai;
-	struct msm_pcm_routing_fdai_data *fdai;
-
-	pr_debug("%s: substream->pcm->id:%s\n",
-		 __func__, substream->pcm->id);
-
-	if (be_id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: unexpected BE id %d\n", __func__, be_id);
-		return -EINVAL;
-	}
-
-	bedai = &msm_bedais[be_id];
-	session_type = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-		0 : 1);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		path_type = ADM_PATH_PLAYBACK;
-	else
-		path_type = ADM_PATH_LIVE_REC;
-
-	mutex_lock(&routing_lock);
-	for_each_set_bit(i, &bedai->fe_sessions[0], MSM_FRONTEND_DAI_MAX) {
-		if (!is_mm_lsm_fe_id(i))
-			continue;
-		fdai = &fe_dai_map[i][session_type];
-		if (fdai->strm_id != INVALID_SESSION) {
-			int idx;
-			int port_id;
-			unsigned long copp =
-				session_copp_map[i][session_type][be_id];
-			for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
-				if (test_bit(idx, &copp))
-					break;
-			fdai->be_srate = bedai->sample_rate;
-			port_id = bedai->port_id;
-			topology = adm_get_topology_for_port_copp_idx(port_id,
-								     idx);
-			adm_close(bedai->port_id, fdai->perf_mode, idx);
-			pr_debug("%s: copp:%ld,idx bit fe:%d, type:%d,be:%d topology=0x%x\n",
-				 __func__, copp, i, session_type, be_id,
-				 topology);
-			clear_bit(idx,
-				  &session_copp_map[i][session_type][be_id]);
-			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
-				(bedai->passthr_mode[i] == LEGACY_PCM))
-				msm_pcm_routing_deinit_pp(bedai->port_id,
-							  topology);
-		}
-	}
-
-	bedai->active = 0;
-	bedai->sample_rate = 0;
-	bedai->channel = 0;
-	for (i = 0; i < MSM_FRONTEND_DAI_MAX; i++) {
-		if (bedai->passthr_mode[i] != LISTEN)
-			bedai->passthr_mode[i] = LEGACY_PCM;
-	}
-	mutex_unlock(&routing_lock);
-
-	return 0;
-}
-
-static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	unsigned int be_id = rtd->dai_link->id;
-	int i, path_type, topology;
-	int session_type = INVALID_SESSION;
-	struct msm_pcm_routing_bdai_data *bedai;
-	u32 channels, sample_rate;
-	uint16_t bits_per_sample = 16, voc_path_type;
-	struct msm_pcm_routing_fdai_data *fdai;
-	u32 session_id;
-	struct media_format_info voc_be_media_format;
-	bool is_lsm;
-
-	pr_debug("%s: substream->pcm->id:%s\n",
-		 __func__, substream->pcm->id);
-
-	if (be_id >= MSM_BACKEND_DAI_MAX) {
-		pr_err("%s: unexpected BE id %d\n", __func__, be_id);
-		return -EINVAL;
-	}
-
-	bedai = &msm_bedais[be_id];
-
-	mutex_lock(&routing_lock);
-	if (bedai->active == 1)
-		goto done; /* Ignore prepare if back-end already active */
-
-	/* AFE port is not active at this point. However, still
-	 * go ahead setting active flag under the notion that
-	 * QDSP6 is able to handle ADM starting before AFE port
-	 * is started.
-	 */
-	bedai->active = 1;
-
-	for_each_set_bit(i, &bedai->fe_sessions[0], MSM_FRONTEND_DAI_MAX) {
-		if (!(is_mm_lsm_fe_id(i) &&
-				route_check_fe_id_adm_support(i)))
-			continue;
-
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-			if (bedai->passthr_mode[i] != LEGACY_PCM)
-				path_type = ADM_PATH_COMPRESSED_RX;
-			else
-				path_type = ADM_PATH_PLAYBACK;
-			session_type = SESSION_TYPE_RX;
-		} else {
-			path_type = ADM_PATH_LIVE_REC;
-			session_type = SESSION_TYPE_TX;
-		}
-
-		is_lsm = (i >= MSM_FRONTEND_DAI_LSM1) &&
-				 (i <= MSM_FRONTEND_DAI_LSM8);
-		fdai = &fe_dai_map[i][session_type];
-		if (fdai->strm_id != INVALID_SESSION) {
-			int app_type, app_type_idx, copp_idx, acdb_dev_id;
-
-			if (session_type == SESSION_TYPE_TX &&
-			    fdai->be_srate &&
-			    (fdai->be_srate != bedai->sample_rate)) {
-				pr_debug("%s: flush strm %d diff BE rates\n",
-					__func__,
-					fdai->strm_id);
-
-				if (fdai->event_info.event_func)
-					fdai->event_info.event_func(
-						MSM_PCM_RT_EVT_BUF_RECFG,
-						fdai->event_info.priv_data);
-				fdai->be_srate = 0; /* might not need it */
-			}
-			bits_per_sample = msm_routing_get_bit_width(
-						bedai->format);
-
-			app_type =
-			fe_dai_app_type_cfg[i][session_type][be_id].app_type;
-			if (app_type && is_lsm) {
-				app_type_idx =
-				msm_pcm_routing_get_lsm_app_type_idx(app_type);
-				sample_rate =
-				fe_dai_app_type_cfg[i][session_type][be_id]
-					.sample_rate;
-				bits_per_sample =
-				lsm_app_type_cfg[app_type_idx].bit_width;
-			} else if (app_type) {
-				app_type_idx =
-				msm_pcm_routing_get_app_type_idx(app_type);
-				sample_rate =
-					fe_dai_app_type_cfg[i][session_type]
-							   [be_id].sample_rate;
-				bits_per_sample =
-					app_type_cfg[app_type_idx].bit_width;
-			} else
-				sample_rate = bedai->sample_rate;
-			/*
-			 * check if ADM needs to be configured with different
-			 * channel mapping than backend
-			 */
-			if (!bedai->adm_override_ch)
-				channels = bedai->channel;
-			else
-				channels = bedai->adm_override_ch;
-			acdb_dev_id =
-			fe_dai_app_type_cfg[i][session_type][be_id].acdb_dev_id;
-			topology = msm_routing_get_adm_topology(i, session_type,
-								be_id);
-			copp_idx = adm_open(bedai->port_id, path_type,
-					    sample_rate, channels, topology,
-					    fdai->perf_mode, bits_per_sample,
-					    app_type, acdb_dev_id);
-			if ((copp_idx < 0) ||
-				(copp_idx >= MAX_COPPS_PER_PORT)) {
-				pr_err("%s: adm open failed\n", __func__);
-				mutex_unlock(&routing_lock);
-				return -EINVAL;
-			}
-			pr_debug("%s: setting idx bit of fe:%d, type: %d, be:%d\n",
-				 __func__, i, session_type, be_id);
-			set_bit(copp_idx,
-				&session_copp_map[i][session_type][be_id]);
-
-			if (msm_is_resample_needed(
-				sample_rate,
-				bedai->sample_rate))
-				adm_copp_mfc_cfg(
-					bedai->port_id, copp_idx,
-					bedai->sample_rate);
-
-			msm_pcm_routing_build_matrix(i, session_type, path_type,
-						     fdai->perf_mode,
-						     bedai->passthr_mode[i]);
-			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
-				(bedai->passthr_mode[i] == LEGACY_PCM))
-				msm_pcm_routing_cfg_pp(bedai->port_id, copp_idx,
-						       topology, channels);
-		}
-	}
-
-	for_each_set_bit(i, &bedai->fe_sessions[0], MSM_FRONTEND_DAI_MAX) {
-		session_id = msm_pcm_routing_get_voc_sessionid(i);
-		if (session_id) {
-			pr_debug("%s voice session_id: 0x%x\n", __func__,
-				 session_id);
-
-			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-				voc_path_type = RX_PATH;
-			else
-				voc_path_type = TX_PATH;
-
-			voc_set_route_flag(session_id, voc_path_type, 1);
-
-			memset(&voc_be_media_format, 0,
-			       sizeof(struct media_format_info));
-
-			voc_be_media_format.port_id = bedai->port_id;
-			voc_be_media_format.num_channels = bedai->channel;
-			voc_be_media_format.sample_rate = bedai->sample_rate;
-			voc_be_media_format.bits_per_sample = bedai->format;
-			/* Defaulting this to 1 for voice call usecases */
-			voc_be_media_format.channel_mapping[0] = 1;
-
-			voc_set_device_config(session_id, voc_path_type,
-					      &voc_be_media_format);
-
-			if (voc_get_route_flag(session_id, RX_PATH) &&
-			    voc_get_route_flag(session_id, TX_PATH))
-				voc_enable_device(session_id);
-		}
-	}
-
-	/* Check if backend is an external ec ref port and set as needed */
-	if (unlikely(bedai->port_id == voc_get_ext_ec_ref_port_id())) {
-
-		memset(&voc_be_media_format, 0,
-		       sizeof(struct media_format_info));
-
-		/* Get format info for ec ref port from msm_bedais[] */
-		voc_be_media_format.port_id = bedai->port_id;
-		voc_be_media_format.num_channels = bedai->channel;
-		voc_be_media_format.bits_per_sample = bedai->format;
-		voc_be_media_format.sample_rate = bedai->sample_rate;
-		/* Defaulting this to 1 for voice call usecases */
-		voc_be_media_format.channel_mapping[0] = 1;
-		voc_set_ext_ec_ref_media_fmt_info(&voc_be_media_format);
-		pr_debug("%s: EC Ref media format info set to port_id=%d, num_channels=%d, bits_per_sample=%d, sample_rate=%d\n",
-			 __func__, voc_be_media_format.port_id,
-			 voc_be_media_format.num_channels,
-			 voc_be_media_format.bits_per_sample,
-			 voc_be_media_format.sample_rate);
-	}
-
-done:
-	mutex_unlock(&routing_lock);
-
-	return 0;
-}
-
-static int msm_routing_send_device_pp_params(int port_id, int copp_idx,
-					     int fe_id)
-{
-	int index, topo_id, be_idx;
-	unsigned long pp_config = 0;
-	bool mute_on;
-	int latency;
-	bool compr_passthr_mode = true;
-
-	pr_debug("%s: port_id %d, copp_idx %d\n", __func__, port_id, copp_idx);
-
-	if (port_id != HDMI_RX && port_id != DISPLAY_PORT_RX) {
-		pr_err("%s: Device pp params on invalid port %d\n",
-			__func__, port_id);
-		return  -EINVAL;
-	}
-
-	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
-		if (port_id == msm_bedais[be_idx].port_id)
-			break;
-	}
-
-	if (be_idx >= MSM_BACKEND_DAI_MAX) {
-		pr_debug("%s: Invalid be id %d\n", __func__, be_idx);
-		return  -EINVAL;
-	}
-
-	for (index = 0; index < MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX; index++) {
-		if (msm_bedais_pp_params[index].port_id == port_id)
-			break;
-	}
-	if (index >= MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX) {
-		pr_err("%s: Invalid backend pp params index %d\n",
-			__func__, index);
-		return -EINVAL;
-	}
-
-	topo_id = adm_get_topology_for_port_copp_idx(port_id, copp_idx);
-	if (topo_id != COMPRESSED_PASSTHROUGH_DEFAULT_TOPOLOGY) {
-		pr_err("%s: Invalid passthrough topology 0x%x\n",
-			__func__, topo_id);
-		return -EINVAL;
-	}
-
-	if ((msm_bedais[be_idx].passthr_mode[fe_id] == LEGACY_PCM) ||
-		(msm_bedais[be_idx].passthr_mode[fe_id] == LISTEN))
-		compr_passthr_mode = false;
-
-	pp_config = msm_bedais_pp_params[index].pp_params_config;
-	if (test_bit(ADM_PP_PARAM_MUTE_BIT, &pp_config)) {
-		pr_debug("%s: ADM_PP_PARAM_MUTE\n", __func__);
-		clear_bit(ADM_PP_PARAM_MUTE_BIT, &pp_config);
-		mute_on = msm_bedais_pp_params[index].mute_on;
-		if ((msm_bedais[be_idx].active) && compr_passthr_mode)
-			adm_send_compressed_device_mute(port_id,
-								copp_idx,
-								mute_on);
-	}
-	if (test_bit(ADM_PP_PARAM_LATENCY_BIT, &pp_config)) {
-		pr_debug("%s: ADM_PP_PARAM_LATENCY\n", __func__);
-		clear_bit(ADM_PP_PARAM_LATENCY_BIT,
-			  &pp_config);
-		latency = msm_bedais_pp_params[index].latency;
-		if ((msm_bedais[be_idx].active) && compr_passthr_mode)
-			adm_send_compressed_device_latency(port_id,
-							   copp_idx,
-							   latency);
-	}
-	return 0;
-}
-
-static int msm_routing_put_device_pp_params_mixer(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int pp_id = ucontrol->value.integer.value[0];
-	int port_id = 0;
-	int index, be_idx, i, topo_id, idx;
-	bool mute;
-	int latency;
-	bool compr_passthr_mode = true;
-
-	pr_debug("%s: pp_id: 0x%x\n", __func__, pp_id);
-
-	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
-		port_id = msm_bedais[be_idx].port_id;
-		if (port_id == HDMI_RX || port_id == DISPLAY_PORT_RX)
-			break;
-	}
-
-	if (be_idx >= MSM_BACKEND_DAI_MAX) {
-		pr_debug("%s: Invalid be id %d\n", __func__, be_idx);
-		return  -EINVAL;
-	}
-
-	for (index = 0; index < MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX; index++) {
-		if (msm_bedais_pp_params[index].port_id == port_id)
-			break;
-	}
-	if (index >= MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX) {
-		pr_err("%s: Invalid pp params backend index %d\n",
-			__func__, index);
-		return -EINVAL;
-	}
-
-	for_each_set_bit(i, &msm_bedais[be_idx].fe_sessions[0],
-				MSM_FRONTEND_DAI_MM_SIZE) {
-		if ((msm_bedais[be_idx].passthr_mode[i] == LEGACY_PCM) ||
-			(msm_bedais[be_idx].passthr_mode[i] == LISTEN))
-			compr_passthr_mode = false;
-
-		for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-			unsigned long copp =
-				session_copp_map[i]
-				[SESSION_TYPE_RX][be_idx];
-			if (!test_bit(idx, &copp))
-				continue;
-			topo_id = adm_get_topology_for_port_copp_idx(port_id,
-								     idx);
-			if (topo_id != COMPRESSED_PASSTHROUGH_DEFAULT_TOPOLOGY)
-				continue;
-		pr_debug("%s: port: 0x%x, copp %ld, be active: %d, passt: %d\n",
-			 __func__, port_id, copp, msm_bedais[be_idx].active,
-			 msm_bedais[be_idx].passthr_mode[i]);
-		switch (pp_id) {
-		case ADM_PP_PARAM_MUTE_ID:
-			pr_debug("%s: ADM_PP_PARAM_MUTE\n", __func__);
-			mute = ucontrol->value.integer.value[1] ? true : false;
-			msm_bedais_pp_params[index].mute_on = mute;
-			set_bit(ADM_PP_PARAM_MUTE_BIT,
-				&msm_bedais_pp_params[index].pp_params_config);
-			if ((msm_bedais[be_idx].active) && compr_passthr_mode)
-				adm_send_compressed_device_mute(port_id,
-					idx, mute);
-			break;
-		case ADM_PP_PARAM_LATENCY_ID:
-			pr_debug("%s: ADM_PP_PARAM_LATENCY\n", __func__);
-			msm_bedais_pp_params[index].latency =
-				ucontrol->value.integer.value[1];
-			set_bit(ADM_PP_PARAM_LATENCY_BIT,
-				&msm_bedais_pp_params[index].pp_params_config);
-			latency = msm_bedais_pp_params[index].latency =
-				ucontrol->value.integer.value[1];
-			if ((msm_bedais[be_idx].active) && compr_passthr_mode)
-				adm_send_compressed_device_latency(port_id,
-					idx, latency);
-			break;
-		default:
-			pr_info("%s, device pp param %d not supported\n",
-				__func__, pp_id);
-			break;
-		}
-		}
-	}
-	return 0;
-}
-
-static int msm_routing_get_device_pp_params_mixer(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s:msm_routing_get_device_pp_params_mixer", __func__);
-	return 0;
-}
-
-static const struct snd_kcontrol_new device_pp_params_mixer_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Device PP Params", SND_SOC_NOPM, 0, 0xFFFFFFFF,
-	0, 3, msm_routing_get_device_pp_params_mixer,
-	msm_routing_put_device_pp_params_mixer),
-};
-
-static int msm_aptx_dec_license_control_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] =
-			core_get_license_status(ASM_MEDIA_FMT_APTX);
-	pr_debug("%s: status %ld\n", __func__,
-			ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_aptx_dec_license_control_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int32_t status = 0;
-
-	status = core_set_license(ucontrol->value.integer.value[0],
-				APTX_CLASSIC_DEC_LICENSE_ID);
-	pr_debug("%s: status %d\n", __func__, status);
-	return status;
-}
-
-static const struct snd_kcontrol_new aptx_dec_license_controls[] = {
-	SOC_SINGLE_EXT("APTX Dec License", SND_SOC_NOPM, 0,
-	0xFFFF, 0, msm_aptx_dec_license_control_get,
-	msm_aptx_dec_license_control_put),
-};
-
-static int msm_routing_be_dai_name_table_info(struct snd_kcontrol *kcontrol,
-					      struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = sizeof(be_dai_name_table);
-	return 0;
-}
-
-static int msm_routing_be_dai_name_table_tlv_get(struct snd_kcontrol *kcontrol,
-						 unsigned int __user *bytes,
-						 unsigned int size)
-{
-	int i;
-	int ret;
-
-	if (size < sizeof(be_dai_name_table)) {
-		pr_err("%s: invalid size %d requested, returning\n",
-			__func__, size);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/*
-	 * Fill be_dai_name_table from msm_bedais table to reduce code changes
-	 * needed when adding new backends
-	 */
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		be_dai_name_table[i].be_id = i;
-		strlcpy(be_dai_name_table[i].be_name,
-			msm_bedais[i].name,
-			LPASS_BE_NAME_MAX_LENGTH);
-	}
-
-	ret = copy_to_user(bytes, &be_dai_name_table,
-			   sizeof(be_dai_name_table));
-	if (ret) {
-		pr_err("%s: failed to copy be_dai_name_table\n", __func__);
-		ret = -EFAULT;
-	}
-
-done:
-	return ret;
-}
-
-static const struct snd_kcontrol_new
-	msm_routing_be_dai_name_table_mixer_controls[] = {
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
-		.info = msm_routing_be_dai_name_table_info,
-		.name = "Backend DAI Name Table",
-		.tlv.c = snd_soc_bytes_tlv_callback,
-		.private_value = (unsigned long) &(struct soc_bytes_ext) {
-			.max = sizeof(be_dai_name_table),
-			.get = msm_routing_be_dai_name_table_tlv_get,
-		}
-	},
-};
-
-static int msm_routing_stereo_channel_reverse_control_get(
-			struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = swap_ch;
-	pr_debug("%s: Swap channel value: %ld\n", __func__,
-				ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_routing_stereo_channel_reverse_control_put(
-			struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	int i, idx, be_index, port_id;
-	int ret = 0;
-	unsigned long copp;
-
-	pr_debug("%s Swap channel value:%ld\n", __func__,
-				ucontrol->value.integer.value[0]);
-
-	swap_ch = ucontrol->value.integer.value[0];
-
-	mutex_lock(&routing_lock);
-	for (be_index = 0; be_index < MSM_BACKEND_DAI_MAX; be_index++) {
-		port_id = msm_bedais[be_index].port_id;
-		if (!msm_bedais[be_index].active)
-			continue;
-
-		for_each_set_bit(i, &msm_bedais[be_index].fe_sessions[0],
-				MSM_FRONTEND_DAI_MM_SIZE) {
-			copp = session_copp_map[i][SESSION_TYPE_RX][be_index];
-			for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-				if (!test_bit(idx, &copp))
-					continue;
-
-				pr_debug("%s: swap channel control of portid:%d, coppid:%d\n",
-					 __func__, port_id, idx);
-				ret = adm_swap_speaker_channels(
-					port_id, idx,
-					msm_bedais[be_index].sample_rate,
-					swap_ch);
-				if (ret) {
-					pr_err("%s:Swap_channel failed, err=%d\n",
-						 __func__, ret);
-					goto done;
-				}
-			}
-		}
-	}
-done:
-	mutex_unlock(&routing_lock);
-	return ret;
-}
-
-static const struct snd_kcontrol_new stereo_channel_reverse_control[] = {
-	SOC_SINGLE_EXT("Swap channel", SND_SOC_NOPM, 0,
-	1, 0, msm_routing_stereo_channel_reverse_control_get,
-	msm_routing_stereo_channel_reverse_control_put),
-};
-
-static const struct snd_pcm_ops msm_routing_pcm_ops = {
-	.hw_params	= msm_pcm_routing_hw_params,
-	.close          = msm_pcm_routing_close,
-	.prepare        = msm_pcm_routing_prepare,
-};
-
-/* Not used but frame seems to require it */
-static int msm_routing_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_dapm_new_controls(&platform->component.dapm, msm_qdsp6_widgets,
-			   ARRAY_SIZE(msm_qdsp6_widgets));
-	snd_soc_dapm_add_routes(&platform->component.dapm, intercon,
-		ARRAY_SIZE(intercon));
-
-	snd_soc_dapm_new_widgets(platform->component.dapm.card);
-
-	snd_soc_add_platform_controls(platform, lsm_controls,
-				      ARRAY_SIZE(lsm_controls));
-
-	snd_soc_add_platform_controls(platform, aanc_slim_0_rx_mux,
-				      ARRAY_SIZE(aanc_slim_0_rx_mux));
-
-	snd_soc_add_platform_controls(platform, msm_voc_session_controls,
-				      ARRAY_SIZE(msm_voc_session_controls));
-
-	snd_soc_add_platform_controls(platform, app_type_cfg_controls,
-				      ARRAY_SIZE(app_type_cfg_controls));
-
-	snd_soc_add_platform_controls(platform, lsm_app_type_cfg_controls,
-				      ARRAY_SIZE(lsm_app_type_cfg_controls));
-
-	snd_soc_add_platform_controls(platform,
-				stereo_to_custom_stereo_controls,
-			ARRAY_SIZE(stereo_to_custom_stereo_controls));
-
-	snd_soc_add_platform_controls(platform, ec_ref_param_controls,
-				ARRAY_SIZE(ec_ref_param_controls));
-
-	snd_soc_add_platform_controls(platform, channel_mixer_controls,
-				ARRAY_SIZE(channel_mixer_controls));
-
-	msm_qti_pp_add_controls(platform);
-
-	msm_dts_srs_tm_add_controls(platform);
-
-	msm_dolby_dap_add_controls(platform);
-
-	snd_soc_add_platform_controls(platform,
-			use_ds1_or_ds2_controls,
-			ARRAY_SIZE(use_ds1_or_ds2_controls));
-
-	snd_soc_add_platform_controls(platform,
-				device_pp_params_mixer_controls,
-				ARRAY_SIZE(device_pp_params_mixer_controls));
-
-	snd_soc_add_platform_controls(platform,
-		msm_routing_be_dai_name_table_mixer_controls,
-		ARRAY_SIZE(msm_routing_be_dai_name_table_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, msm_source_tracking_controls,
-				ARRAY_SIZE(msm_source_tracking_controls));
-	snd_soc_add_platform_controls(platform, adm_channel_config_controls,
-				ARRAY_SIZE(adm_channel_config_controls));
-
-	snd_soc_add_platform_controls(platform, aptx_dec_license_controls,
-					ARRAY_SIZE(aptx_dec_license_controls));
-	snd_soc_add_platform_controls(platform, stereo_channel_reverse_control,
-				ARRAY_SIZE(stereo_channel_reverse_control));
-	return 0;
-}
-
-int msm_routing_pcm_new(struct snd_soc_pcm_runtime *runtime)
-{
-	return msm_pcm_routing_hwdep_new(runtime, msm_bedais);
-}
-
-void msm_routing_pcm_free(struct snd_pcm *pcm)
-{
-	msm_pcm_routing_hwdep_free(pcm);
-}
-
-static struct snd_soc_platform_driver msm_soc_routing_platform = {
-	.ops		= &msm_routing_pcm_ops,
-	.probe		= msm_routing_probe,
-	.pcm_new	= msm_routing_pcm_new,
-	.pcm_free	= msm_routing_pcm_free,
-};
-
-static int msm_routing_pcm_probe(struct platform_device *pdev)
-{
-
-	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
-	return snd_soc_register_platform(&pdev->dev,
-				  &msm_soc_routing_platform);
-}
-
-static int msm_routing_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_pcm_routing_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-routing"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_pcm_routing_dt_match);
-
-static struct platform_driver msm_routing_pcm_driver = {
-	.driver = {
-		.name = "msm-pcm-routing",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_routing_dt_match,
-	},
-	.probe = msm_routing_pcm_probe,
-	.remove = msm_routing_pcm_remove,
-};
-
-int msm_routing_check_backend_enabled(int fedai_id)
-{
-	int i;
-
-	if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
-		/* bad ID assigned in machine driver */
-		pr_err("%s: bad MM ID\n", __func__);
-		return 0;
-	}
-	for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) {
-		if (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))
-			return msm_bedais[i].active;
-	}
-	return 0;
-}
-
-static int msm_routing_set_cal(int32_t cal_type,
-					size_t data_size, void *data)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	ret = cal_utils_set_cal(data_size, data, cal_data, 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static void msm_routing_delete_cal_data(void)
-{
-	pr_debug("%s\n", __func__);
-
-	cal_utils_destroy_cal_types(1, &cal_data);
-}
-
-static int msm_routing_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info cal_type_info = {
-		{ADM_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL,
-		msm_routing_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num}
-	};
-	pr_debug("%s\n", __func__);
-
-	ret = cal_utils_create_cal_types(1, &cal_data,
-		&cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type!\n",
-			__func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	msm_routing_delete_cal_data();
-	return ret;
-}
-
-static int __init msm_soc_routing_platform_init(void)
-{
-	mutex_init(&routing_lock);
-	if (msm_routing_init_cal_data())
-		pr_err("%s: could not init cal data!\n", __func__);
-
-	afe_set_routing_callback(
-		(routing_cb)msm_pcm_get_dev_acdb_id_by_port_id);
-
-	memset(&be_dai_name_table, 0, sizeof(be_dai_name_table));
-	memset(&last_be_id_configured, 0, sizeof(last_be_id_configured));
-
-	return platform_driver_register(&msm_routing_pcm_driver);
-}
-module_init(msm_soc_routing_platform_init);
-
-static void __exit msm_soc_routing_platform_exit(void)
-{
-	msm_routing_delete_cal_data();
-	memset(&be_dai_name_table, 0, sizeof(be_dai_name_table));
-	mutex_destroy(&routing_lock);
-	platform_driver_unregister(&msm_routing_pcm_driver);
-}
-module_exit(msm_soc_routing_platform_exit);
-
-MODULE_DESCRIPTION("MSM routing platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h
deleted file mode 100644
index 19e7260..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h
+++ /dev/null
@@ -1,486 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_PCM_ROUTING_H
-#define _MSM_PCM_ROUTING_H
-#include <sound/apr_audio-v2.h>
-
-/*
- * These names are used by HAL to specify the BE. If any changes are
- * made to the string names or the max name length corresponding
- * changes need to be made in the HAL to ensure they still match.
- */
-#define LPASS_BE_NAME_MAX_LENGTH 24
-#define LPASS_BE_PRI_I2S_RX "PRIMARY_I2S_RX"
-#define LPASS_BE_PRI_I2S_TX "PRIMARY_I2S_TX"
-#define LPASS_BE_SLIMBUS_0_RX "SLIMBUS_0_RX"
-#define LPASS_BE_SLIMBUS_0_TX "SLIMBUS_0_TX"
-#define LPASS_BE_HDMI "HDMI"
-#define LPASS_BE_DISPLAY_PORT "DISPLAY_PORT"
-#define LPASS_BE_INT_BT_SCO_RX "INT_BT_SCO_RX"
-#define LPASS_BE_INT_BT_SCO_TX "INT_BT_SCO_TX"
-#define LPASS_BE_INT_BT_A2DP_RX "INT_BT_A2DP_RX"
-#define LPASS_BE_INT_FM_RX "INT_FM_RX"
-#define LPASS_BE_INT_FM_TX "INT_FM_TX"
-#define LPASS_BE_AFE_PCM_RX "RT_PROXY_DAI_001_RX"
-#define LPASS_BE_AFE_PCM_TX "RT_PROXY_DAI_002_TX"
-#define LPASS_BE_AUXPCM_RX "AUX_PCM_RX"
-#define LPASS_BE_AUXPCM_TX "AUX_PCM_TX"
-#define LPASS_BE_SEC_AUXPCM_RX "SEC_AUX_PCM_RX"
-#define LPASS_BE_SEC_AUXPCM_TX "SEC_AUX_PCM_TX"
-#define LPASS_BE_TERT_AUXPCM_RX "TERT_AUX_PCM_RX"
-#define LPASS_BE_TERT_AUXPCM_TX "TERT_AUX_PCM_TX"
-#define LPASS_BE_QUAT_AUXPCM_RX "QUAT_AUX_PCM_RX"
-#define LPASS_BE_QUAT_AUXPCM_TX "QUAT_AUX_PCM_TX"
-#define LPASS_BE_VOICE_PLAYBACK_TX "VOICE_PLAYBACK_TX"
-#define LPASS_BE_VOICE2_PLAYBACK_TX "VOICE2_PLAYBACK_TX"
-#define LPASS_BE_INCALL_RECORD_RX "INCALL_RECORD_RX"
-#define LPASS_BE_INCALL_RECORD_TX "INCALL_RECORD_TX"
-#define LPASS_BE_SEC_I2S_RX "SECONDARY_I2S_RX"
-#define LPASS_BE_SPDIF_RX "SPDIF_RX"
-
-#define LPASS_BE_MI2S_RX "MI2S_RX"
-#define LPASS_BE_MI2S_TX "MI2S_TX"
-#define LPASS_BE_QUAT_MI2S_RX "QUAT_MI2S_RX"
-#define LPASS_BE_QUAT_MI2S_TX "QUAT_MI2S_TX"
-#define LPASS_BE_SEC_MI2S_RX "SEC_MI2S_RX"
-#define LPASS_BE_SEC_MI2S_RX_SD1 "SEC_MI2S_RX_SD1"
-#define LPASS_BE_SEC_MI2S_TX "SEC_MI2S_TX"
-#define LPASS_BE_PRI_MI2S_RX "PRI_MI2S_RX"
-#define LPASS_BE_PRI_MI2S_TX "PRI_MI2S_TX"
-#define LPASS_BE_TERT_MI2S_RX "TERTIARY_MI2S_RX"
-#define LPASS_BE_TERT_MI2S_TX "TERTIARY_MI2S_TX"
-#define LPASS_BE_AUDIO_I2S_RX "AUDIO_I2S_RX"
-#define LPASS_BE_STUB_RX "STUB_RX"
-#define LPASS_BE_STUB_TX "STUB_TX"
-#define LPASS_BE_SLIMBUS_1_RX "SLIMBUS_1_RX"
-#define LPASS_BE_SLIMBUS_1_TX "SLIMBUS_1_TX"
-#define LPASS_BE_STUB_1_TX "STUB_1_TX"
-#define LPASS_BE_SLIMBUS_2_RX "SLIMBUS_2_RX"
-#define LPASS_BE_SLIMBUS_2_TX "SLIMBUS_2_TX"
-#define LPASS_BE_SLIMBUS_3_RX "SLIMBUS_3_RX"
-#define LPASS_BE_SLIMBUS_3_TX "SLIMBUS_3_TX"
-#define LPASS_BE_SLIMBUS_4_RX "SLIMBUS_4_RX"
-#define LPASS_BE_SLIMBUS_4_TX "SLIMBUS_4_TX"
-#define LPASS_BE_SLIMBUS_TX_VI "SLIMBUS_TX_VI"
-#define LPASS_BE_SLIMBUS_5_RX "SLIMBUS_5_RX"
-#define LPASS_BE_SLIMBUS_5_TX "SLIMBUS_5_TX"
-#define LPASS_BE_SLIMBUS_6_RX "SLIMBUS_6_RX"
-#define LPASS_BE_SLIMBUS_6_TX "SLIMBUS_6_TX"
-#define LPASS_BE_QUIN_MI2S_RX "QUIN_MI2S_RX"
-#define LPASS_BE_QUIN_MI2S_TX "QUIN_MI2S_TX"
-#define LPASS_BE_SENARY_MI2S_TX "SENARY_MI2S_TX"
-
-#define LPASS_BE_PRI_TDM_RX_0 "PRI_TDM_RX_0"
-#define LPASS_BE_PRI_TDM_TX_0 "PRI_TDM_TX_0"
-#define LPASS_BE_PRI_TDM_RX_1 "PRI_TDM_RX_1"
-#define LPASS_BE_PRI_TDM_TX_1 "PRI_TDM_TX_1"
-#define LPASS_BE_PRI_TDM_RX_2 "PRI_TDM_RX_2"
-#define LPASS_BE_PRI_TDM_TX_2 "PRI_TDM_TX_2"
-#define LPASS_BE_PRI_TDM_RX_3 "PRI_TDM_RX_3"
-#define LPASS_BE_PRI_TDM_TX_3 "PRI_TDM_TX_3"
-#define LPASS_BE_PRI_TDM_RX_4 "PRI_TDM_RX_4"
-#define LPASS_BE_PRI_TDM_TX_4 "PRI_TDM_TX_4"
-#define LPASS_BE_PRI_TDM_RX_5 "PRI_TDM_RX_5"
-#define LPASS_BE_PRI_TDM_TX_5 "PRI_TDM_TX_5"
-#define LPASS_BE_PRI_TDM_RX_6 "PRI_TDM_RX_6"
-#define LPASS_BE_PRI_TDM_TX_6 "PRI_TDM_TX_6"
-#define LPASS_BE_PRI_TDM_RX_7 "PRI_TDM_RX_7"
-#define LPASS_BE_PRI_TDM_TX_7 "PRI_TDM_TX_7"
-#define LPASS_BE_SEC_TDM_RX_0 "SEC_TDM_RX_0"
-#define LPASS_BE_SEC_TDM_TX_0 "SEC_TDM_TX_0"
-#define LPASS_BE_SEC_TDM_RX_1 "SEC_TDM_RX_1"
-#define LPASS_BE_SEC_TDM_TX_1 "SEC_TDM_TX_1"
-#define LPASS_BE_SEC_TDM_RX_2 "SEC_TDM_RX_2"
-#define LPASS_BE_SEC_TDM_TX_2 "SEC_TDM_TX_2"
-#define LPASS_BE_SEC_TDM_RX_3 "SEC_TDM_RX_3"
-#define LPASS_BE_SEC_TDM_TX_3 "SEC_TDM_TX_3"
-#define LPASS_BE_SEC_TDM_RX_4 "SEC_TDM_RX_4"
-#define LPASS_BE_SEC_TDM_TX_4 "SEC_TDM_TX_4"
-#define LPASS_BE_SEC_TDM_RX_5 "SEC_TDM_RX_5"
-#define LPASS_BE_SEC_TDM_TX_5 "SEC_TDM_TX_5"
-#define LPASS_BE_SEC_TDM_RX_6 "SEC_TDM_RX_6"
-#define LPASS_BE_SEC_TDM_TX_6 "SEC_TDM_TX_6"
-#define LPASS_BE_SEC_TDM_RX_7 "SEC_TDM_RX_7"
-#define LPASS_BE_SEC_TDM_TX_7 "SEC_TDM_TX_7"
-#define LPASS_BE_TERT_TDM_RX_0 "TERT_TDM_RX_0"
-#define LPASS_BE_TERT_TDM_TX_0 "TERT_TDM_TX_0"
-#define LPASS_BE_TERT_TDM_RX_1 "TERT_TDM_RX_1"
-#define LPASS_BE_TERT_TDM_TX_1 "TERT_TDM_TX_1"
-#define LPASS_BE_TERT_TDM_RX_2 "TERT_TDM_RX_2"
-#define LPASS_BE_TERT_TDM_TX_2 "TERT_TDM_TX_2"
-#define LPASS_BE_TERT_TDM_RX_3 "TERT_TDM_RX_3"
-#define LPASS_BE_TERT_TDM_TX_3 "TERT_TDM_TX_3"
-#define LPASS_BE_TERT_TDM_RX_4 "TERT_TDM_RX_4"
-#define LPASS_BE_TERT_TDM_TX_4 "TERT_TDM_TX_4"
-#define LPASS_BE_TERT_TDM_RX_5 "TERT_TDM_RX_5"
-#define LPASS_BE_TERT_TDM_TX_5 "TERT_TDM_TX_5"
-#define LPASS_BE_TERT_TDM_RX_6 "TERT_TDM_RX_6"
-#define LPASS_BE_TERT_TDM_TX_6 "TERT_TDM_TX_6"
-#define LPASS_BE_TERT_TDM_RX_7 "TERT_TDM_RX_7"
-#define LPASS_BE_TERT_TDM_TX_7 "TERT_TDM_TX_7"
-#define LPASS_BE_QUAT_TDM_RX_0 "QUAT_TDM_RX_0"
-#define LPASS_BE_QUAT_TDM_TX_0 "QUAT_TDM_TX_0"
-#define LPASS_BE_QUAT_TDM_RX_1 "QUAT_TDM_RX_1"
-#define LPASS_BE_QUAT_TDM_TX_1 "QUAT_TDM_TX_1"
-#define LPASS_BE_QUAT_TDM_RX_2 "QUAT_TDM_RX_2"
-#define LPASS_BE_QUAT_TDM_TX_2 "QUAT_TDM_TX_2"
-#define LPASS_BE_QUAT_TDM_RX_3 "QUAT_TDM_RX_3"
-#define LPASS_BE_QUAT_TDM_TX_3 "QUAT_TDM_TX_3"
-#define LPASS_BE_QUAT_TDM_RX_4 "QUAT_TDM_RX_4"
-#define LPASS_BE_QUAT_TDM_TX_4 "QUAT_TDM_TX_4"
-#define LPASS_BE_QUAT_TDM_RX_5 "QUAT_TDM_RX_5"
-#define LPASS_BE_QUAT_TDM_TX_5 "QUAT_TDM_TX_5"
-#define LPASS_BE_QUAT_TDM_RX_6 "QUAT_TDM_RX_6"
-#define LPASS_BE_QUAT_TDM_TX_6 "QUAT_TDM_TX_6"
-#define LPASS_BE_QUAT_TDM_RX_7 "QUAT_TDM_RX_7"
-#define LPASS_BE_QUAT_TDM_TX_7 "QUAT_TDM_TX_7"
-
-#define LPASS_BE_SLIMBUS_7_RX "SLIMBUS_7_RX"
-#define LPASS_BE_SLIMBUS_7_TX "SLIMBUS_7_TX"
-#define LPASS_BE_SLIMBUS_8_RX "SLIMBUS_8_RX"
-#define LPASS_BE_SLIMBUS_8_TX "SLIMBUS_8_TX"
-
-#define LPASS_BE_USB_AUDIO_RX "USB_AUDIO_RX"
-#define LPASS_BE_USB_AUDIO_TX "USB_AUDIO_TX"
-
-#define LPASS_BE_INT0_MI2S_RX "INT0_MI2S_RX"
-#define LPASS_BE_INT0_MI2S_TX "INT0_MI2S_TX"
-#define LPASS_BE_INT1_MI2S_RX "INT1_MI2S_RX"
-#define LPASS_BE_INT1_MI2S_TX "INT1_MI2S_TX"
-#define LPASS_BE_INT2_MI2S_RX "INT2_MI2S_RX"
-#define LPASS_BE_INT2_MI2S_TX "INT2_MI2S_TX"
-#define LPASS_BE_INT3_MI2S_RX "INT3_MI2S_RX"
-#define LPASS_BE_INT3_MI2S_TX "INT3_MI2S_TX"
-#define LPASS_BE_INT4_MI2S_RX "INT4_MI2S_RX"
-#define LPASS_BE_INT4_MI2S_TX "INT4_MI2S_TX"
-#define LPASS_BE_INT5_MI2S_RX "INT5_MI2S_RX"
-#define LPASS_BE_INT5_MI2S_TX "INT5_MI2S_TX"
-#define LPASS_BE_INT6_MI2S_RX "INT6_MI2S_RX"
-#define LPASS_BE_INT6_MI2S_TX "INT6_MI2S_TX"
-/* For multimedia front-ends, asm session is allocated dynamically.
- * Hence, asm session/multimedia front-end mapping has to be maintained.
- * Due to this reason, additional multimedia front-end must be placed before
- * non-multimedia front-ends.
- */
-
-enum {
-	MSM_FRONTEND_DAI_MULTIMEDIA1 = 0,
-	MSM_FRONTEND_DAI_MULTIMEDIA2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3,
-	MSM_FRONTEND_DAI_MULTIMEDIA4,
-	MSM_FRONTEND_DAI_MULTIMEDIA5,
-	MSM_FRONTEND_DAI_MULTIMEDIA6,
-	MSM_FRONTEND_DAI_MULTIMEDIA7,
-	MSM_FRONTEND_DAI_MULTIMEDIA8,
-	MSM_FRONTEND_DAI_MULTIMEDIA9,
-	MSM_FRONTEND_DAI_MULTIMEDIA10,
-	MSM_FRONTEND_DAI_MULTIMEDIA11,
-	MSM_FRONTEND_DAI_MULTIMEDIA12,
-	MSM_FRONTEND_DAI_MULTIMEDIA13,
-	MSM_FRONTEND_DAI_MULTIMEDIA14,
-	MSM_FRONTEND_DAI_MULTIMEDIA15,
-	MSM_FRONTEND_DAI_MULTIMEDIA16,
-	MSM_FRONTEND_DAI_MULTIMEDIA17,
-	MSM_FRONTEND_DAI_MULTIMEDIA18,
-	MSM_FRONTEND_DAI_MULTIMEDIA19,
-	MSM_FRONTEND_DAI_MULTIMEDIA20,
-	MSM_FRONTEND_DAI_CS_VOICE,
-	MSM_FRONTEND_DAI_VOIP,
-	MSM_FRONTEND_DAI_AFE_RX,
-	MSM_FRONTEND_DAI_AFE_TX,
-	MSM_FRONTEND_DAI_VOICE_STUB,
-	MSM_FRONTEND_DAI_VOLTE,
-	MSM_FRONTEND_DAI_DTMF_RX,
-	MSM_FRONTEND_DAI_VOICE2,
-	MSM_FRONTEND_DAI_QCHAT,
-	MSM_FRONTEND_DAI_VOLTE_STUB,
-	MSM_FRONTEND_DAI_LSM1,
-	MSM_FRONTEND_DAI_LSM2,
-	MSM_FRONTEND_DAI_LSM3,
-	MSM_FRONTEND_DAI_LSM4,
-	MSM_FRONTEND_DAI_LSM5,
-	MSM_FRONTEND_DAI_LSM6,
-	MSM_FRONTEND_DAI_LSM7,
-	MSM_FRONTEND_DAI_LSM8,
-	MSM_FRONTEND_DAI_VOICE2_STUB,
-	MSM_FRONTEND_DAI_VOWLAN,
-	MSM_FRONTEND_DAI_VOICEMMODE1,
-	MSM_FRONTEND_DAI_VOICEMMODE2,
-	MSM_FRONTEND_DAI_MAX,
-};
-
-#define MSM_FRONTEND_DAI_MM_SIZE (MSM_FRONTEND_DAI_MULTIMEDIA20 + 1)
-#define MSM_FRONTEND_DAI_MM_MAX_ID MSM_FRONTEND_DAI_MULTIMEDIA20
-
-enum {
-	MSM_BACKEND_DAI_PRI_I2S_RX = 0,
-	MSM_BACKEND_DAI_PRI_I2S_TX,
-	MSM_BACKEND_DAI_SLIMBUS_0_RX,
-	MSM_BACKEND_DAI_SLIMBUS_0_TX,
-	MSM_BACKEND_DAI_HDMI_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_RX,
-	MSM_BACKEND_DAI_INT_BT_SCO_TX,
-	MSM_BACKEND_DAI_INT_FM_RX,
-	MSM_BACKEND_DAI_INT_FM_TX,
-	MSM_BACKEND_DAI_AFE_PCM_RX,
-	MSM_BACKEND_DAI_AFE_PCM_TX,
-	MSM_BACKEND_DAI_AUXPCM_RX,
-	MSM_BACKEND_DAI_AUXPCM_TX,
-	MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-	MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-	MSM_BACKEND_DAI_INCALL_RECORD_RX,
-	MSM_BACKEND_DAI_INCALL_RECORD_TX,
-	MSM_BACKEND_DAI_MI2S_RX,
-	MSM_BACKEND_DAI_MI2S_TX,
-	MSM_BACKEND_DAI_SEC_I2S_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_RX,
-	MSM_BACKEND_DAI_SLIMBUS_1_TX,
-	MSM_BACKEND_DAI_SLIMBUS_2_RX,
-	MSM_BACKEND_DAI_SLIMBUS_2_TX,
-	MSM_BACKEND_DAI_SLIMBUS_3_RX,
-	MSM_BACKEND_DAI_SLIMBUS_3_TX,
-	MSM_BACKEND_DAI_SLIMBUS_4_RX,
-	MSM_BACKEND_DAI_SLIMBUS_4_TX,
-	MSM_BACKEND_DAI_SLIMBUS_5_RX,
-	MSM_BACKEND_DAI_SLIMBUS_5_TX,
-	MSM_BACKEND_DAI_SLIMBUS_6_RX,
-	MSM_BACKEND_DAI_SLIMBUS_6_TX,
-	MSM_BACKEND_DAI_SLIMBUS_7_RX,
-	MSM_BACKEND_DAI_SLIMBUS_7_TX,
-	MSM_BACKEND_DAI_SLIMBUS_8_RX,
-	MSM_BACKEND_DAI_SLIMBUS_8_TX,
-	MSM_BACKEND_DAI_EXTPROC_RX,
-	MSM_BACKEND_DAI_EXTPROC_TX,
-	MSM_BACKEND_DAI_EXTPROC_EC_TX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-	MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-	MSM_BACKEND_DAI_PRI_MI2S_RX,
-	MSM_BACKEND_DAI_PRI_MI2S_TX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-	MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-	MSM_BACKEND_DAI_AUDIO_I2S_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-	MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-	MSM_BACKEND_DAI_SPDIF_RX,
-	MSM_BACKEND_DAI_SECONDARY_MI2S_RX_SD1,
-	MSM_BACKEND_DAI_QUINARY_MI2S_RX,
-	MSM_BACKEND_DAI_QUINARY_MI2S_TX,
-	MSM_BACKEND_DAI_SENARY_MI2S_TX,
-	MSM_BACKEND_DAI_PRI_TDM_RX_0,
-	MSM_BACKEND_DAI_PRI_TDM_TX_0,
-	MSM_BACKEND_DAI_PRI_TDM_RX_1,
-	MSM_BACKEND_DAI_PRI_TDM_TX_1,
-	MSM_BACKEND_DAI_PRI_TDM_RX_2,
-	MSM_BACKEND_DAI_PRI_TDM_TX_2,
-	MSM_BACKEND_DAI_PRI_TDM_RX_3,
-	MSM_BACKEND_DAI_PRI_TDM_TX_3,
-	MSM_BACKEND_DAI_PRI_TDM_RX_4,
-	MSM_BACKEND_DAI_PRI_TDM_TX_4,
-	MSM_BACKEND_DAI_PRI_TDM_RX_5,
-	MSM_BACKEND_DAI_PRI_TDM_TX_5,
-	MSM_BACKEND_DAI_PRI_TDM_RX_6,
-	MSM_BACKEND_DAI_PRI_TDM_TX_6,
-	MSM_BACKEND_DAI_PRI_TDM_RX_7,
-	MSM_BACKEND_DAI_PRI_TDM_TX_7,
-	MSM_BACKEND_DAI_SEC_TDM_RX_0,
-	MSM_BACKEND_DAI_SEC_TDM_TX_0,
-	MSM_BACKEND_DAI_SEC_TDM_RX_1,
-	MSM_BACKEND_DAI_SEC_TDM_TX_1,
-	MSM_BACKEND_DAI_SEC_TDM_RX_2,
-	MSM_BACKEND_DAI_SEC_TDM_TX_2,
-	MSM_BACKEND_DAI_SEC_TDM_RX_3,
-	MSM_BACKEND_DAI_SEC_TDM_TX_3,
-	MSM_BACKEND_DAI_SEC_TDM_RX_4,
-	MSM_BACKEND_DAI_SEC_TDM_TX_4,
-	MSM_BACKEND_DAI_SEC_TDM_RX_5,
-	MSM_BACKEND_DAI_SEC_TDM_TX_5,
-	MSM_BACKEND_DAI_SEC_TDM_RX_6,
-	MSM_BACKEND_DAI_SEC_TDM_TX_6,
-	MSM_BACKEND_DAI_SEC_TDM_RX_7,
-	MSM_BACKEND_DAI_SEC_TDM_TX_7,
-	MSM_BACKEND_DAI_TERT_TDM_RX_0,
-	MSM_BACKEND_DAI_TERT_TDM_TX_0,
-	MSM_BACKEND_DAI_TERT_TDM_RX_1,
-	MSM_BACKEND_DAI_TERT_TDM_TX_1,
-	MSM_BACKEND_DAI_TERT_TDM_RX_2,
-	MSM_BACKEND_DAI_TERT_TDM_TX_2,
-	MSM_BACKEND_DAI_TERT_TDM_RX_3,
-	MSM_BACKEND_DAI_TERT_TDM_TX_3,
-	MSM_BACKEND_DAI_TERT_TDM_RX_4,
-	MSM_BACKEND_DAI_TERT_TDM_TX_4,
-	MSM_BACKEND_DAI_TERT_TDM_RX_5,
-	MSM_BACKEND_DAI_TERT_TDM_TX_5,
-	MSM_BACKEND_DAI_TERT_TDM_RX_6,
-	MSM_BACKEND_DAI_TERT_TDM_TX_6,
-	MSM_BACKEND_DAI_TERT_TDM_RX_7,
-	MSM_BACKEND_DAI_TERT_TDM_TX_7,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_1,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_1,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_2,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_2,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_3,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_3,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_4,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_4,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_5,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_5,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_6,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_6,
-	MSM_BACKEND_DAI_QUAT_TDM_RX_7,
-	MSM_BACKEND_DAI_QUAT_TDM_TX_7,
-	MSM_BACKEND_DAI_INT_BT_A2DP_RX,
-	MSM_BACKEND_DAI_USB_RX,
-	MSM_BACKEND_DAI_USB_TX,
-	MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-	MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-	MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-	MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-	MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-	MSM_BACKEND_DAI_INT0_MI2S_RX,
-	MSM_BACKEND_DAI_INT0_MI2S_TX,
-	MSM_BACKEND_DAI_INT1_MI2S_RX,
-	MSM_BACKEND_DAI_INT1_MI2S_TX,
-	MSM_BACKEND_DAI_INT2_MI2S_RX,
-	MSM_BACKEND_DAI_INT2_MI2S_TX,
-	MSM_BACKEND_DAI_INT3_MI2S_RX,
-	MSM_BACKEND_DAI_INT3_MI2S_TX,
-	MSM_BACKEND_DAI_INT4_MI2S_RX,
-	MSM_BACKEND_DAI_INT4_MI2S_TX,
-	MSM_BACKEND_DAI_INT5_MI2S_RX,
-	MSM_BACKEND_DAI_INT5_MI2S_TX,
-	MSM_BACKEND_DAI_INT6_MI2S_RX,
-	MSM_BACKEND_DAI_INT6_MI2S_TX,
-	MSM_BACKEND_DAI_MAX,
-};
-
-enum msm_pcm_routing_event {
-	MSM_PCM_RT_EVT_BUF_RECFG,
-	MSM_PCM_RT_EVT_DEVSWITCH,
-	MSM_PCM_RT_EVT_MAX,
-};
-
-enum {
-	EXT_EC_REF_NONE = 0,
-	EXT_EC_REF_PRI_MI2S_TX,
-	EXT_EC_REF_SEC_MI2S_TX,
-	EXT_EC_REF_TERT_MI2S_TX,
-	EXT_EC_REF_QUAT_MI2S_TX,
-	EXT_EC_REF_QUIN_MI2S_TX,
-	EXT_EC_REF_SLIM_1_TX,
-};
-
-#define INVALID_SESSION -1
-#define SESSION_TYPE_RX 0
-#define SESSION_TYPE_TX 1
-#define MAX_SESSION_TYPES 2
-#define INT_RX_VOL_MAX_STEPS 0x2000
-#define INT_RX_VOL_GAIN 0x2000
-
-#define RELEASE_LOCK	0
-#define ACQUIRE_LOCK	1
-
-#define MSM_BACKEND_DAI_PP_PARAMS_REQ_MAX	2
-#define HDMI_RX_ID				0x8001
-#define ADM_PP_PARAM_MUTE_ID			0
-#define ADM_PP_PARAM_MUTE_BIT			1
-#define ADM_PP_PARAM_LATENCY_ID			1
-#define ADM_PP_PARAM_LATENCY_BIT		2
-#define BE_DAI_PORT_SESSIONS_IDX_MAX		4
-#define BE_DAI_FE_SESSIONS_IDX_MAX		2
-
-struct msm_pcm_routing_evt {
-	void (*event_func)(enum msm_pcm_routing_event, void *);
-	void *priv_data;
-};
-
-struct msm_pcm_routing_bdai_data {
-	u16 port_id; /* AFE port ID */
-	u8 active; /* track if this backend is enabled */
-
-	/* Front-end sessions */
-	unsigned long fe_sessions[BE_DAI_FE_SESSIONS_IDX_MAX];
-	/*
-	 * Track Tx BE ports -> Rx BE ports.
-	 * port_sessions[0] used to track BE 0 to BE 63.
-	 * port_sessions[1] used to track BE 64 to BE 127.
-	 * port_sessions[2] used to track BE 128 to BE 191.
-	 * port_sessions[3] used to track BE 192 to BE 255.
-	 */
-	u64 port_sessions[BE_DAI_PORT_SESSIONS_IDX_MAX];
-
-	unsigned int  sample_rate;
-	unsigned int  channel;
-	unsigned int  format;
-	unsigned int  adm_override_ch;
-	u32 passthr_mode[MSM_FRONTEND_DAI_MAX];
-	char *name;
-};
-
-struct msm_pcm_routing_fdai_data {
-	u16 be_srate; /* track prior backend sample rate for flushing purpose */
-	int strm_id; /* ASM stream ID */
-	int perf_mode;
-	struct msm_pcm_routing_evt event_info;
-};
-
-#define MAX_APP_TYPES	16
-struct msm_pcm_routing_app_type_data {
-	int app_type;
-	u32 sample_rate;
-	int bit_width;
-};
-
-struct msm_pcm_stream_app_type_cfg {
-	int app_type;
-	int acdb_dev_id;
-	int sample_rate;
-};
-
-/* dai_id: front-end ID,
- * dspst_id:  DSP audio stream ID
- * stream_type: playback or capture
- */
-int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, int dspst_id,
-				   int stream_type);
-void msm_pcm_routing_reg_psthr_stream(int fedai_id, int dspst_id,
-		int stream_type);
-int msm_pcm_routing_reg_phy_compr_stream(int fedai_id, int perf_mode,
-					  int dspst_id, int stream_type,
-					  uint32_t compr_passthr);
-
-int msm_pcm_routing_reg_phy_stream_v2(int fedai_id, int perf_mode,
-				      int dspst_id, int stream_type,
-				      struct msm_pcm_routing_evt event_info);
-
-void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type);
-
-int msm_routing_check_backend_enabled(int fedai_id);
-
-
-void msm_pcm_routing_get_bedai_info(int be_idx,
-				    struct msm_pcm_routing_bdai_data *bedai);
-void msm_pcm_routing_get_fedai_info(int fe_idx, int sess_type,
-				    struct msm_pcm_routing_fdai_data *fe_dai);
-void msm_pcm_routing_acquire_lock(void);
-void msm_pcm_routing_release_lock(void);
-
-int msm_pcm_routing_reg_stream_app_type_cfg(
-	int fedai_id, int session_type, int be_id,
-	struct msm_pcm_stream_app_type_cfg *cfg_data);
-int msm_pcm_routing_get_stream_app_type_cfg(
-	int fedai_id, int session_type, int *be_id,
-	struct msm_pcm_stream_app_type_cfg *cfg_data);
-#endif /*_MSM_PCM_H*/
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c
deleted file mode 100644
index 654806e..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <asm/dma.h>
-#include <linux/of_device.h>
-
-#include "msm-pcm-voice-v2.h"
-#include "q6voice.h"
-
-static struct msm_voice voice_info[VOICE_SESSION_INDEX_MAX];
-
-static struct snd_pcm_hardware msm_pcm_hardware = {
-
-	.info =                 (SNDRV_PCM_INFO_INTERLEAVED |
-				SNDRV_PCM_INFO_PAUSE |
-				SNDRV_PCM_INFO_RESUME),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE,
-	.rates =                SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
-	.rate_min =             8000,
-	.rate_max =             16000,
-	.channels_min =         1,
-	.channels_max =         1,
-
-	.buffer_bytes_max =     4096 * 2,
-	.period_bytes_min =     2048,
-	.period_bytes_max =     4096,
-	.periods_min =          2,
-	.periods_max =          4,
-
-	.fifo_size =            0,
-};
-static bool is_volte(struct msm_voice *pvolte)
-{
-	if (pvolte == &voice_info[VOLTE_SESSION_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static bool is_voice2(struct msm_voice *pvoice2)
-{
-	if (pvoice2 == &voice_info[VOICE2_SESSION_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static bool is_qchat(struct msm_voice *pqchat)
-{
-	if (pqchat == &voice_info[QCHAT_SESSION_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static bool is_vowlan(struct msm_voice *pvowlan)
-{
-	if (pvowlan == &voice_info[VOWLAN_SESSION_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static bool is_voicemmode1(struct msm_voice *pvoicemmode1)
-{
-	if (pvoicemmode1 == &voice_info[VOICEMMODE1_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static bool is_voicemmode2(struct msm_voice *pvoicemmode2)
-{
-	if (pvoicemmode2 == &voice_info[VOICEMMODE2_INDEX])
-		return true;
-	else
-		return false;
-}
-
-static uint32_t get_session_id(struct msm_voice *pvoc)
-{
-	uint32_t session_id = 0;
-
-	if (is_volte(pvoc))
-		session_id = voc_get_session_id(VOLTE_SESSION_NAME);
-	else if (is_voice2(pvoc))
-		session_id = voc_get_session_id(VOICE2_SESSION_NAME);
-	else if (is_qchat(pvoc))
-		session_id = voc_get_session_id(QCHAT_SESSION_NAME);
-	else if (is_vowlan(pvoc))
-		session_id = voc_get_session_id(VOWLAN_SESSION_NAME);
-	else if (is_voicemmode1(pvoc))
-		session_id = voc_get_session_id(VOICEMMODE1_NAME);
-	else if (is_voicemmode2(pvoc))
-		session_id = voc_get_session_id(VOICEMMODE2_NAME);
-	else
-		session_id = voc_get_session_id(VOICE_SESSION_NAME);
-
-	return session_id;
-}
-
-
-static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-
-	pr_debug("%s\n", __func__);
-
-	if (!prtd->playback_start)
-		prtd->playback_start = 1;
-
-	return 0;
-}
-
-static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-
-	pr_debug("%s\n", __func__);
-
-	if (!prtd->capture_start)
-		prtd->capture_start = 1;
-
-	return 0;
-}
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *voice;
-
-	if (!strncmp("VoLTE", substream->pcm->id, 5)) {
-		voice = &voice_info[VOLTE_SESSION_INDEX];
-		pr_debug("%s: Open VoLTE Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else if (!strncmp("Voice2", substream->pcm->id, 6)) {
-		voice = &voice_info[VOICE2_SESSION_INDEX];
-		pr_debug("%s: Open Voice2 Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else if (!strncmp("QCHAT", substream->pcm->id, 5)) {
-		voice = &voice_info[QCHAT_SESSION_INDEX];
-		pr_debug("%s: Open QCHAT Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else if (!strncmp("VoWLAN", substream->pcm->id, 6)) {
-		voice = &voice_info[VOWLAN_SESSION_INDEX];
-		pr_debug("%s: Open VoWLAN Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else if (!strncmp("VoiceMMode1", substream->pcm->id, 11)) {
-		voice = &voice_info[VOICEMMODE1_INDEX];
-		pr_debug("%s: Open VoiceMMode1 Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else if (!strncmp("VoiceMMode2", substream->pcm->id, 11)) {
-		voice = &voice_info[VOICEMMODE2_INDEX];
-		pr_debug("%s: Open VoiceMMode2 Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	} else {
-		voice = &voice_info[VOICE_SESSION_INDEX];
-		pr_debug("%s: Open VOICE Substream Id=%s\n",
-			 __func__, substream->pcm->id);
-	}
-	mutex_lock(&voice->lock);
-
-	runtime->hw = msm_pcm_hardware;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		voice->playback_substream = substream;
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		voice->capture_substream = substream;
-
-	voice->instance++;
-	pr_debug("%s: Instance = %d, Stream ID = %s\n",
-			__func__, voice->instance, substream->pcm->id);
-	runtime->private_data = voice;
-
-	mutex_unlock(&voice->lock);
-
-	return 0;
-}
-static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-
-	pr_debug("%s\n", __func__);
-
-	if (prtd->playback_start)
-		prtd->playback_start = 0;
-
-	prtd->playback_substream = NULL;
-
-	return 0;
-}
-static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-
-	pr_debug("%s\n", __func__);
-
-	if (prtd->capture_start)
-		prtd->capture_start = 0;
-	prtd->capture_substream = NULL;
-
-	return 0;
-}
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-	uint32_t session_id = 0;
-	int ret = 0;
-
-	mutex_lock(&prtd->lock);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_close(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_close(substream);
-
-	prtd->instance--;
-	if (!prtd->playback_start && !prtd->capture_start) {
-		pr_debug("end voice call\n");
-
-		session_id = get_session_id(prtd);
-		if (session_id)
-			voc_end_voice_call(session_id);
-	}
-	mutex_unlock(&prtd->lock);
-
-	return ret;
-}
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-	uint32_t session_id = 0;
-
-	mutex_lock(&prtd->lock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_prepare(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_prepare(substream);
-
-	if (prtd->playback_start && prtd->capture_start) {
-		session_id = get_session_id(prtd);
-		if (session_id)
-			voc_start_voice_call(session_id);
-	}
-	mutex_unlock(&prtd->lock);
-
-	return ret;
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-
-	pr_debug("%s: Voice\n", __func__);
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
-	return 0;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-	uint32_t session_id = 0;
-
-	pr_debug("%s: cmd = %d\n", __func__, cmd);
-
-	session_id = get_session_id(prtd);
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("Start & Stop Voice call not handled in Trigger.\n");
-	break;
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		pr_debug("%s: resume call session_id = %d\n", __func__,
-			 session_id);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-			ret = msm_pcm_playback_prepare(substream);
-		else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			ret = msm_pcm_capture_prepare(substream);
-		if (prtd->playback_start && prtd->capture_start) {
-			if (session_id)
-				voc_resume_voice_call(session_id);
-		}
-	break;
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		pr_debug("%s: pause call session_id=%d\n",
-			 __func__, session_id);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-			if (prtd->playback_start)
-				prtd->playback_start = 0;
-		} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-			if (prtd->capture_start)
-				prtd->capture_start = 0;
-		}
-		if (session_id)
-			voc_standby_voice_call(session_id);
-		break;
-	default:
-		ret = -EINVAL;
-	break;
-	}
-	return ret;
-}
-
-static int msm_pcm_ioctl(struct snd_pcm_substream *substream,
-			 unsigned int cmd, void *arg)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct msm_voice *prtd = runtime->private_data;
-	uint32_t session_id = get_session_id(prtd);
-	enum voice_lch_mode lch_mode;
-	int ret = 0;
-
-	switch (cmd) {
-	case SNDRV_VOICE_IOCTL_LCH:
-		if (copy_from_user(&lch_mode, (void *)arg,
-				   sizeof(enum voice_lch_mode))) {
-			pr_err("%s: Copy from user failed, size %zd\n",
-				__func__, sizeof(enum voice_lch_mode));
-
-			ret = -EFAULT;
-			break;
-		}
-
-		pr_debug("%s: %s lch_mode:%d\n",
-			 __func__, substream->pcm->id, lch_mode);
-
-		switch (lch_mode) {
-		case VOICE_LCH_START:
-		case VOICE_LCH_STOP:
-			ret = voc_set_lch(session_id, lch_mode);
-			break;
-
-		default:
-			pr_err("%s: Invalid LCH MODE %d\n", __func__, lch_mode);
-
-			ret = -EFAULT;
-		}
-
-		break;
-	default:
-		pr_debug("%s: Falling into default snd_lib_ioctl cmd 0x%x\n",
-			 __func__, cmd);
-
-		ret = snd_pcm_lib_ioctl(substream, cmd, arg);
-		break;
-	}
-
-	if (!ret)
-		pr_debug("%s: ret %d\n", __func__, ret);
-	else
-		pr_err("%s: cmd 0x%x failed %d\n", __func__, cmd, ret);
-
-	return ret;
-}
-
-static int msm_voice_sidetone_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int ret;
-	long value = ucontrol->value.integer.value[0];
-	bool sidetone_enable = value;
-	uint32_t session_id = ALL_SESSION_VSID;
-
-	if (value < 0) {
-		pr_err("%s: Invalid arguments sidetone enable %ld\n",
-			 __func__, value);
-		ret = -EINVAL;
-		return ret;
-	}
-	ret = voc_set_afe_sidetone(session_id, sidetone_enable);
-	pr_debug("%s: AFE Sidetone enable=%d session_id=0x%x ret=%d\n",
-		 __func__, sidetone_enable, session_id, ret);
-	return ret;
-}
-
-static int msm_voice_sidetone_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = voc_get_afe_sidetone();
-	return 0;
-}
-
-static int msm_voice_gain_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int volume = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-	int ramp_duration = ucontrol->value.integer.value[2];
-
-	if ((volume < 0) || (ramp_duration < 0)
-		|| (ramp_duration > MAX_RAMP_DURATION)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: volume: %d session_id: %#x ramp_duration: %d\n", __func__,
-		volume, session_id, ramp_duration);
-
-	voc_set_rx_vol_step(session_id, RX_PATH, volume, ramp_duration);
-
-done:
-	return ret;
-}
-
-static int msm_voice_mute_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int mute = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-	int ramp_duration = ucontrol->value.integer.value[2];
-
-	if ((mute < 0) || (mute > 1) || (ramp_duration < 0)
-		|| (ramp_duration > MAX_RAMP_DURATION)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: mute=%d session_id=%#x ramp_duration=%d\n", __func__,
-		mute, session_id, ramp_duration);
-
-	ret = voc_set_tx_mute(session_id, TX_PATH, mute, ramp_duration);
-
-done:
-	return ret;
-}
-
-static int msm_voice_tx_device_mute_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int mute = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-	int ramp_duration = ucontrol->value.integer.value[2];
-
-	if ((mute < 0) || (mute > 1) || (ramp_duration < 0) ||
-	    (ramp_duration > MAX_RAMP_DURATION)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: mute=%d session_id=%#x ramp_duration=%d\n", __func__,
-		 mute, session_id, ramp_duration);
-
-	ret = voc_set_device_mute(session_id, VSS_IVOLUME_DIRECTION_TX,
-				  mute, ramp_duration);
-
-done:
-	return ret;
-}
-
-static int msm_voice_rx_device_mute_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int mute = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-	int ramp_duration = ucontrol->value.integer.value[2];
-
-	if ((mute < 0) || (mute > 1) || (ramp_duration < 0) ||
-	    (ramp_duration > MAX_RAMP_DURATION)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: mute=%d session_id=%#x ramp_duration=%d\n", __func__,
-		 mute, session_id, ramp_duration);
-
-	voc_set_device_mute(session_id, VSS_IVOLUME_DIRECTION_RX,
-			    mute, ramp_duration);
-
-done:
-	return ret;
-}
-
-
-
-static const char * const tty_mode[] = {"OFF", "HCO", "VCO", "FULL"};
-static const struct soc_enum msm_tty_mode_enum[] = {
-		SOC_ENUM_SINGLE_EXT(4, tty_mode),
-};
-
-static int msm_voice_tty_mode_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] =
-		voc_get_tty_mode(voc_get_session_id(VOICE_SESSION_NAME));
-	return 0;
-}
-
-static int msm_voice_tty_mode_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int tty_mode = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: tty_mode=%d\n", __func__, tty_mode);
-
-	voc_set_tty_mode(voc_get_session_id(VOICE_SESSION_NAME), tty_mode);
-	voc_set_tty_mode(voc_get_session_id(VOICE2_SESSION_NAME), tty_mode);
-	voc_set_tty_mode(voc_get_session_id(VOLTE_SESSION_NAME), tty_mode);
-	voc_set_tty_mode(voc_get_session_id(VOWLAN_SESSION_NAME), tty_mode);
-	voc_set_tty_mode(voc_get_session_id(VOICEMMODE1_NAME), tty_mode);
-	voc_set_tty_mode(voc_get_session_id(VOICEMMODE2_NAME), tty_mode);
-
-	return 0;
-}
-
-static int msm_voice_slowtalk_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	int st_enable = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-
-	pr_debug("%s: st enable=%d session_id=%#x\n", __func__, st_enable,
-		 session_id);
-
-	voc_set_pp_enable(session_id,
-			  MODULE_ID_VOICE_MODULE_ST, st_enable);
-
-	return 0;
-}
-
-static int msm_voice_hd_voice_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	uint32_t hd_enable = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-
-	pr_debug("%s: HD Voice enable=%d session_id=%#x\n", __func__, hd_enable,
-		 session_id);
-
-	ret = voc_set_hd_enable(session_id, hd_enable);
-
-	return ret;
-}
-
-static int msm_voice_topology_disable_put(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int disable = ucontrol->value.integer.value[0];
-	uint32_t session_id = ucontrol->value.integer.value[1];
-
-	if ((disable < 0) || (disable > 1)) {
-		pr_err(" %s Invalid arguments: %d\n", __func__, disable);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	pr_debug("%s: disable = %d, session_id = %d\n", __func__, disable,
-		 session_id);
-
-	ret = voc_disable_topology(session_id, disable);
-
-done:
-	return ret;
-}
-
-static int msm_voice_cvd_version_info(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_info *uinfo)
-{
-	int ret = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count = CVD_VERSION_STRING_MAX_SIZE;
-
-	return ret;
-}
-
-static int msm_voice_cvd_version_get(struct snd_kcontrol *kcontrol,
-				     struct snd_ctl_elem_value *ucontrol)
-{
-	char cvd_version[CVD_VERSION_STRING_MAX_SIZE] = CVD_VERSION_DEFAULT;
-	int ret;
-
-	pr_debug("%s:\n", __func__);
-
-	ret = voc_get_cvd_version(cvd_version);
-
-	if (ret)
-		pr_err("%s: Error retrieving CVD version, error:%d\n",
-			__func__, ret);
-
-	memcpy(ucontrol->value.bytes.data, cvd_version, sizeof(cvd_version));
-
-	return 0;
-}
-static struct snd_kcontrol_new msm_voice_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Voice Rx Device Mute", SND_SOC_NOPM, 0, VSID_MAX,
-				0, 3, NULL, msm_voice_rx_device_mute_put),
-	SOC_SINGLE_MULTI_EXT("Voice Tx Device Mute", SND_SOC_NOPM, 0, VSID_MAX,
-				0, 3, NULL, msm_voice_tx_device_mute_put),
-	SOC_SINGLE_MULTI_EXT("Voice Tx Mute", SND_SOC_NOPM, 0, VSID_MAX,
-				0, 3, NULL, msm_voice_mute_put),
-	SOC_SINGLE_MULTI_EXT("Voice Rx Gain", SND_SOC_NOPM, 0, VSID_MAX, 0, 3,
-				NULL, msm_voice_gain_put),
-	SOC_ENUM_EXT("TTY Mode", msm_tty_mode_enum[0], msm_voice_tty_mode_get,
-				msm_voice_tty_mode_put),
-	SOC_SINGLE_MULTI_EXT("Slowtalk Enable", SND_SOC_NOPM, 0, VSID_MAX, 0, 2,
-				NULL, msm_voice_slowtalk_put),
-	SOC_SINGLE_MULTI_EXT("Voice Topology Disable", SND_SOC_NOPM, 0,
-			     VSID_MAX, 0, 2, NULL,
-			     msm_voice_topology_disable_put),
-	SOC_SINGLE_MULTI_EXT("HD Voice Enable", SND_SOC_NOPM, 0, VSID_MAX, 0, 2,
-			     NULL, msm_voice_hd_voice_put),
-	{
-		.access = SNDRV_CTL_ELEM_ACCESS_READ,
-		.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name	= "CVD Version",
-		.info	= msm_voice_cvd_version_info,
-		.get	= msm_voice_cvd_version_get,
-	},
-	SOC_SINGLE_MULTI_EXT("Voice Sidetone Enable", SND_SOC_NOPM, 0, 1, 0, 1,
-			     msm_voice_sidetone_get, msm_voice_sidetone_put),
-};
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open			= msm_pcm_open,
-	.hw_params		= msm_pcm_hw_params,
-	.close			= msm_pcm_close,
-	.prepare		= msm_pcm_prepare,
-	.trigger		= msm_pcm_trigger,
-	.ioctl			= msm_pcm_ioctl,
-	.compat_ioctl		= msm_pcm_ioctl,
-};
-
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-	return ret;
-}
-
-static int msm_pcm_voice_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, msm_voice_controls,
-					ARRAY_SIZE(msm_voice_controls));
-
-	return 0;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.probe		= msm_pcm_voice_probe,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	int rc;
-	bool destroy_cvd = false;
-	const char *is_destroy_cvd = "qcom,destroy-cvd";
-
-	if (!is_voc_initialized()) {
-		pr_debug("%s: voice module not initialized yet, deferring probe()\n",
-		       __func__);
-
-		rc = -EPROBE_DEFER;
-		goto done;
-	}
-
-	rc = voc_alloc_cal_shared_memory();
-	if (rc == -EPROBE_DEFER) {
-		pr_debug("%s: memory allocation for calibration deferred %d\n",
-			 __func__, rc);
-
-		goto done;
-	} else if (rc < 0) {
-		pr_err("%s: memory allocation for calibration failed %d\n",
-		       __func__, rc);
-	}
-
-	pr_debug("%s: dev name %s\n",
-			__func__, dev_name(&pdev->dev));
-	destroy_cvd = of_property_read_bool(pdev->dev.of_node,
-						is_destroy_cvd);
-	voc_set_destroy_cvd_flag(destroy_cvd);
-
-	rc = snd_soc_register_platform(&pdev->dev,
-				       &msm_soc_platform);
-
-done:
-	return rc;
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_voice_dt_match[] = {
-	{.compatible = "qcom,msm-pcm-voice"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_voice_dt_match);
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-pcm-voice",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_voice_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	int i = 0;
-
-	memset(&voice_info, 0, sizeof(voice_info));
-
-	for (i = 0; i < VOICE_SESSION_INDEX_MAX; i++)
-		mutex_init(&voice_info[i].lock);
-
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("Voice PCM module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.h
deleted file mode 100644
index e00cebc..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_PCM_VOICE_H
-#define _MSM_PCM_VOICE_H
-#include <sound/apr_audio-v2.h>
-
-enum {
-	VOICE_SESSION_INDEX,
-	VOLTE_SESSION_INDEX,
-	VOICE2_SESSION_INDEX,
-	QCHAT_SESSION_INDEX,
-	VOWLAN_SESSION_INDEX,
-	VOICEMMODE1_INDEX,
-	VOICEMMODE2_INDEX,
-	VOICE_SESSION_INDEX_MAX,
-};
-
-struct msm_voice {
-	struct snd_pcm_substream *playback_substream;
-	struct snd_pcm_substream *capture_substream;
-
-	int instance;
-
-	struct mutex lock;
-
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-
-	int playback_start;
-	int capture_start;
-};
-
-#endif /*_MSM_PCM_VOICE_H*/
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c
deleted file mode 100644
index 02225f0..0000000
--- a/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c
+++ /dev/null
@@ -1,1715 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <linux/of_device.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <asm/dma.h>
-
-#include "msm-pcm-q6-v2.h"
-#include "msm-pcm-routing-v2.h"
-#include "q6voice.h"
-
-#define SHARED_MEM_BUF 2
-#define VOIP_MAX_Q_LEN 10
-#define VOIP_MAX_VOC_PKT_SIZE 4096
-#define VOIP_MIN_VOC_PKT_SIZE 320
-
-/* Length of the DSP frame info header added to the voc packet. */
-#define DSP_FRAME_HDR_LEN 1
-
-#define MODE_IS127		0x2
-#define MODE_4GV_NB		0x3
-#define MODE_4GV_WB		0x4
-#define MODE_AMR		0x5
-#define MODE_AMR_WB		0xD
-#define MODE_PCM		0xC
-#define MODE_4GV_NW		0xE
-#define MODE_G711		0xA
-#define MODE_G711A		0xF
-
-enum msm_audio_g711a_frame_type {
-	MVS_G711A_SPEECH_GOOD,
-	MVS_G711A_SID,
-	MVS_G711A_NO_DATA,
-	MVS_G711A_ERASURE
-};
-
-enum msm_audio_g711a_mode {
-	MVS_G711A_MODE_MULAW,
-	MVS_G711A_MODE_ALAW
-};
-
-enum msm_audio_g711_mode {
-	MVS_G711_MODE_MULAW,
-	MVS_G711_MODE_ALAW
-};
-
-#define VOIP_MODE_MAX		MODE_G711A
-#define VOIP_RATE_MAX		23850
-
-enum format {
-	FORMAT_S16_LE = 2,
-	FORMAT_SPECIAL = 31,
-};
-
-
-enum amr_rate_type {
-	AMR_RATE_4750, /* AMR 4.75 kbps */
-	AMR_RATE_5150, /* AMR 5.15 kbps */
-	AMR_RATE_5900, /* AMR 5.90 kbps */
-	AMR_RATE_6700, /* AMR 6.70 kbps */
-	AMR_RATE_7400, /* AMR 7.40 kbps */
-	AMR_RATE_7950, /* AMR 7.95 kbps */
-	AMR_RATE_10200, /* AMR 10.20 kbps */
-	AMR_RATE_12200, /* AMR 12.20 kbps */
-	AMR_RATE_6600, /* AMR-WB 6.60 kbps */
-	AMR_RATE_8850, /* AMR-WB 8.85 kbps */
-	AMR_RATE_12650, /* AMR-WB 12.65 kbps */
-	AMR_RATE_14250, /* AMR-WB 14.25 kbps */
-	AMR_RATE_15850, /* AMR-WB 15.85 kbps */
-	AMR_RATE_18250, /* AMR-WB 18.25 kbps */
-	AMR_RATE_19850, /* AMR-WB 19.85 kbps */
-	AMR_RATE_23050, /* AMR-WB 23.05 kbps */
-	AMR_RATE_23850, /* AMR-WB 23.85 kbps */
-	AMR_RATE_UNDEF
-};
-
-enum voip_state {
-	VOIP_STOPPED,
-	VOIP_STARTED,
-};
-
-struct voip_frame_hdr {
-	uint32_t timestamp;
-	union {
-		/*
-		 * Bits 0-3: Frame type
-		 * [optional] Bits 16-19: Frame rate
-		 */
-		uint32_t frame_type;
-		uint32_t packet_rate;
-	};
-};
-struct voip_frame {
-	struct voip_frame_hdr frm_hdr;
-	uint32_t pktlen;
-	uint8_t voc_pkt[VOIP_MAX_VOC_PKT_SIZE];
-};
-
-struct voip_buf_node {
-	struct list_head list;
-	struct voip_frame frame;
-};
-
-struct voip_drv_info {
-	enum  voip_state state;
-
-	struct snd_pcm_substream *playback_substream;
-	struct snd_pcm_substream *capture_substream;
-
-	struct list_head in_queue;
-	struct list_head free_in_queue;
-
-	struct list_head out_queue;
-	struct list_head free_out_queue;
-
-	wait_queue_head_t out_wait;
-	wait_queue_head_t in_wait;
-
-	struct mutex lock;
-
-	spinlock_t dsp_lock;
-	spinlock_t dsp_ul_lock;
-
-	bool voip_reset;
-	uint32_t mode;
-	uint32_t rate_type;
-	uint32_t rate;
-	uint32_t dtx_mode;
-
-	uint8_t capture_start;
-	uint8_t playback_start;
-
-	uint8_t playback_prepare;
-	uint8_t capture_prepare;
-
-	unsigned int play_samp_rate;
-	unsigned int cap_samp_rate;
-
-	unsigned int pcm_size;
-	unsigned int pcm_count;
-	unsigned int pcm_playback_irq_pos;      /* IRQ position */
-	unsigned int pcm_playback_buf_pos;      /* position in buffer */
-
-	unsigned int pcm_capture_size;
-	unsigned int pcm_capture_count;
-	unsigned int pcm_capture_irq_pos;       /* IRQ position */
-	unsigned int pcm_capture_buf_pos;       /* position in buffer */
-
-	uint32_t evrc_min_rate;
-	uint32_t evrc_max_rate;
-};
-
-static int voip_get_media_type(uint32_t mode, uint32_t rate_type,
-				unsigned int samp_rate,
-				unsigned int *media_type);
-static int voip_get_rate_type(uint32_t mode,
-				uint32_t rate,
-				uint32_t *rate_type);
-static int voip_config_vocoder(struct snd_pcm_substream *substream);
-static int msm_voip_mode_config_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol);
-static int msm_voip_mode_config_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol);
-static int msm_voip_rate_config_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol);
-static int msm_voip_evrc_min_max_rate_config_put(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol);
-static int msm_voip_evrc_min_max_rate_config_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol);
-
-static struct voip_drv_info voip_info;
-
-static struct snd_pcm_hardware msm_pcm_hardware = {
-	.info =                 (SNDRV_PCM_INFO_MMAP |
-				SNDRV_PCM_INFO_BLOCK_TRANSFER |
-				SNDRV_PCM_INFO_MMAP_VALID |
-				SNDRV_PCM_INFO_INTERLEAVED),
-	.formats =              SNDRV_PCM_FMTBIT_S16_LE |
-				SNDRV_PCM_FMTBIT_SPECIAL,
-	.rates =                SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-				SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000,
-	.rate_min =             8000,
-	.rate_max =             48000,
-	.channels_min =         1,
-	.channels_max =         1,
-	.buffer_bytes_max =	sizeof(struct voip_buf_node) * VOIP_MAX_Q_LEN,
-	.period_bytes_min =	VOIP_MIN_VOC_PKT_SIZE,
-	.period_bytes_max =	VOIP_MAX_VOC_PKT_SIZE,
-	.periods_min =		VOIP_MAX_Q_LEN,
-	.periods_max =		VOIP_MAX_Q_LEN,
-	.fifo_size =            0,
-};
-
-
-static int msm_voip_mute_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int mute = ucontrol->value.integer.value[0];
-	int ramp_duration = ucontrol->value.integer.value[1];
-
-	if ((mute < 0) || (mute > 1) || (ramp_duration < 0)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: mute=%d ramp_duration=%d\n", __func__, mute,
-		ramp_duration);
-
-	voc_set_tx_mute(voc_get_session_id(VOIP_SESSION_NAME), TX_PATH, mute,
-					ramp_duration);
-
-done:
-	return ret;
-}
-
-static int msm_voip_gain_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int volume = ucontrol->value.integer.value[0];
-	int ramp_duration = ucontrol->value.integer.value[1];
-
-	if ((volume < 0) || (ramp_duration < 0)) {
-		pr_err(" %s Invalid arguments", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	pr_debug("%s: volume: %d ramp_duration: %d\n", __func__, volume,
-		ramp_duration);
-
-	voc_set_rx_vol_step(voc_get_session_id(VOIP_SESSION_NAME),
-						RX_PATH,
-						volume,
-						ramp_duration);
-
-done:
-	return ret;
-}
-
-static int msm_voip_dtx_mode_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	voip_info.dtx_mode  = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: dtx: %d\n", __func__, voip_info.dtx_mode);
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-static int msm_voip_dtx_mode_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	ucontrol->value.integer.value[0] = voip_info.dtx_mode;
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-
-static struct snd_kcontrol_new msm_voip_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Voip Tx Mute", SND_SOC_NOPM, 0,
-			     MAX_RAMP_DURATION,
-			     0, 2, NULL, msm_voip_mute_put),
-	SOC_SINGLE_MULTI_EXT("Voip Rx Gain", SND_SOC_NOPM, 0,
-			     MAX_RAMP_DURATION,
-			     0, 2, NULL, msm_voip_gain_put),
-	SOC_SINGLE_EXT("Voip Mode Config", SND_SOC_NOPM, 0, VOIP_MODE_MAX, 0,
-		       msm_voip_mode_config_get, msm_voip_mode_config_put),
-	SOC_SINGLE_EXT("Voip Rate Config", SND_SOC_NOPM, 0, VOIP_RATE_MAX, 0,
-		       NULL, msm_voip_rate_config_put),
-	SOC_SINGLE_MULTI_EXT("Voip Evrc Min Max Rate Config", SND_SOC_NOPM,
-			     0, VOC_1_RATE, 0, 2,
-			     msm_voip_evrc_min_max_rate_config_get,
-			     msm_voip_evrc_min_max_rate_config_put),
-	SOC_SINGLE_EXT("Voip Dtx Mode", SND_SOC_NOPM, 0, 1, 0,
-		       msm_voip_dtx_mode_get, msm_voip_dtx_mode_put),
-};
-
-static int msm_pcm_voip_probe(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, msm_voip_controls,
-					ARRAY_SIZE(msm_voip_controls));
-
-	return 0;
-}
-
-/* sample rate supported */
-static unsigned int supported_sample_rates[] = {8000, 16000, 32000, 48000};
-
-static void voip_ssr_cb_fn(uint32_t opcode, void *private_data)
-{
-
-	/* Notify ASoC to send next playback/Capture to unblock write/read */
-	struct voip_drv_info *prtd = private_data;
-
-	if (opcode == 0xFFFFFFFF) {
-
-		prtd->voip_reset = true;
-		pr_debug("%s: Notify ASoC to send next playback/Capture\n",
-			__func__);
-
-		prtd->pcm_playback_irq_pos += prtd->pcm_count;
-		if (prtd->state == VOIP_STARTED)
-			snd_pcm_period_elapsed(prtd->playback_substream);
-		wake_up(&prtd->out_wait);
-
-		prtd->pcm_capture_irq_pos += prtd->pcm_capture_count;
-		if (prtd->state == VOIP_STARTED)
-			snd_pcm_period_elapsed(prtd->capture_substream);
-		wake_up(&prtd->in_wait);
-
-	} else {
-		pr_err("%s: Invalid opcode during reset : %d\n",
-			__func__, opcode);
-	}
-}
-
-/* capture path */
-static void voip_process_ul_pkt(uint8_t *voc_pkt,
-				uint32_t pkt_len,
-				uint32_t timestamp,
-				void *private_data)
-{
-	struct voip_buf_node *buf_node = NULL;
-	struct voip_drv_info *prtd = private_data;
-	unsigned long dsp_flags;
-
-	if (prtd->capture_substream == NULL)
-		return;
-
-	/* Copy up-link packet into out_queue. */
-	spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
-
-	/* discarding UL packets till start is received */
-	if (!list_empty(&prtd->free_out_queue) && prtd->capture_start) {
-		buf_node = list_first_entry(&prtd->free_out_queue,
-					struct voip_buf_node, list);
-		list_del(&buf_node->list);
-		switch (prtd->mode) {
-		case MODE_AMR_WB:
-		case MODE_AMR: {
-			/* Remove the DSP frame info header. Header format:
-			 * Bits 0-3: Frame rate
-			 * Bits 4-7: Frame type
-			 */
-			buf_node->frame.frm_hdr.timestamp = timestamp;
-			buf_node->frame.frm_hdr.frame_type =
-						((*voc_pkt) & 0xF0) >> 4;
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-			buf_node->frame.pktlen = pkt_len - DSP_FRAME_HDR_LEN;
-			memcpy(&buf_node->frame.voc_pkt[0],
-				voc_pkt,
-				buf_node->frame.pktlen);
-
-			list_add_tail(&buf_node->list, &prtd->out_queue);
-			break;
-		}
-		case MODE_IS127:
-		case MODE_4GV_NB:
-		case MODE_4GV_WB:
-		case MODE_4GV_NW: {
-			/* Remove the DSP frame info header.
-			 * Header format:
-			 * Bits 0-3: frame rate
-			 */
-			buf_node->frame.frm_hdr.timestamp = timestamp;
-			buf_node->frame.frm_hdr.packet_rate = (*voc_pkt) & 0x0F;
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-			buf_node->frame.pktlen = pkt_len - DSP_FRAME_HDR_LEN;
-
-			memcpy(&buf_node->frame.voc_pkt[0],
-				voc_pkt,
-				buf_node->frame.pktlen);
-
-			list_add_tail(&buf_node->list, &prtd->out_queue);
-			break;
-		}
-		case MODE_G711:
-		case MODE_G711A:{
-			/* G711 frames are 10ms each, but the DSP works with
-			 * 20ms frames and sends two 10ms frames per buffer.
-			 * Extract the two frames and put them in separate
-			 * buffers.
-			 */
-			/* Remove the first DSP frame info header.
-			 * Header format: G711A
-			 * Bits 0-1: Frame type
-			 * Bits 2-3: Frame rate
-			 *
-			 * Header format: G711
-			 * Bits 2-3: Frame rate
-			 */
-			if (prtd->mode == MODE_G711A)
-				buf_node->frame.frm_hdr.frame_type =
-							(*voc_pkt) & 0x03;
-			buf_node->frame.frm_hdr.timestamp = timestamp;
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-
-			/* There are two frames in the buffer. Length of the
-			 * first frame:
-			 */
-			buf_node->frame.pktlen = (pkt_len -
-						  2 * DSP_FRAME_HDR_LEN) / 2;
-
-			memcpy(&buf_node->frame.voc_pkt[0],
-			       voc_pkt,
-			       buf_node->frame.pktlen);
-			voc_pkt = voc_pkt + buf_node->frame.pktlen;
-
-			list_add_tail(&buf_node->list, &prtd->out_queue);
-
-			/* Get another buffer from the free Q and fill in the
-			 * second frame.
-			 */
-			if (!list_empty(&prtd->free_out_queue)) {
-				buf_node =
-					list_first_entry(&prtd->free_out_queue,
-							 struct voip_buf_node,
-							 list);
-				list_del(&buf_node->list);
-
-				/* Remove the second DSP frame info header.
-				 * Header format:
-				 * Bits 0-1: Frame type
-				 * Bits 2-3: Frame rate
-				 */
-
-				if (prtd->mode == MODE_G711A)
-					buf_node->frame.frm_hdr.frame_type =
-							(*voc_pkt) & 0x03;
-				buf_node->frame.frm_hdr.timestamp = timestamp;
-				voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-
-				/* There are two frames in the buffer. Length
-				 * of the second frame:
-				 */
-				buf_node->frame.pktlen = (pkt_len -
-						2 * DSP_FRAME_HDR_LEN) / 2;
-
-				memcpy(&buf_node->frame.voc_pkt[0],
-				       voc_pkt,
-				       buf_node->frame.pktlen);
-
-				list_add_tail(&buf_node->list,
-					      &prtd->out_queue);
-			} else {
-				/* Drop the second frame */
-				pr_err("%s: UL data dropped, read is slow\n",
-				       __func__);
-			}
-			break;
-		}
-		default: {
-			buf_node->frame.frm_hdr.timestamp = timestamp;
-			buf_node->frame.pktlen = pkt_len;
-			memcpy(&buf_node->frame.voc_pkt[0],
-			       voc_pkt,
-			       buf_node->frame.pktlen);
-			list_add_tail(&buf_node->list, &prtd->out_queue);
-		}
-		}
-		pr_debug("%s: pkt_len =%d, frame.pktlen=%d, timestamp=%d\n",
-			 __func__, pkt_len, buf_node->frame.pktlen, timestamp);
-
-		if (prtd->mode == MODE_PCM)
-			prtd->pcm_capture_irq_pos += buf_node->frame.pktlen;
-		else
-			prtd->pcm_capture_irq_pos += prtd->pcm_capture_count;
-
-		spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
-		snd_pcm_period_elapsed(prtd->capture_substream);
-	} else {
-		spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
-		pr_err("UL data dropped\n");
-	}
-
-	wake_up(&prtd->out_wait);
-}
-
-/* playback path */
-static void voip_process_dl_pkt(uint8_t *voc_pkt, void *private_data)
-{
-	struct voip_buf_node *buf_node = NULL;
-	struct voip_drv_info *prtd = private_data;
-	unsigned long dsp_flags;
-	uint32_t rate_type;
-	uint32_t frame_rate;
-	u32 pkt_len;
-	u8 *voc_addr = NULL;
-
-	if (prtd->playback_substream == NULL)
-		return;
-
-	spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-
-	if (!list_empty(&prtd->in_queue) && prtd->playback_start) {
-		buf_node = list_first_entry(&prtd->in_queue,
-				struct voip_buf_node, list);
-		list_del(&buf_node->list);
-		switch (prtd->mode) {
-		case MODE_AMR:
-		case MODE_AMR_WB: {
-			*((uint32_t *)voc_pkt) = buf_node->frame.pktlen +
-							DSP_FRAME_HDR_LEN;
-			/* Advance to the header of voip packet */
-			voc_pkt = voc_pkt + sizeof(uint32_t);
-			/*
-			 * Add the DSP frame info header. Header format:
-			 * Bits 0-3: Frame rate
-			 * Bits 4-7: Frame type
-			 */
-			*voc_pkt = ((buf_node->frame.frm_hdr.frame_type &
-				   0x0F) << 4);
-			frame_rate = (buf_node->frame.frm_hdr.frame_type &
-				     0xFFFF0000) >> 16;
-			if (frame_rate) {
-				if (voip_get_rate_type(prtd->mode, frame_rate,
-						       &rate_type)) {
-					pr_err("%s(): fail at getting rate_type\n",
-						__func__);
-				} else
-					prtd->rate_type = rate_type;
-			}
-			*voc_pkt |= prtd->rate_type & 0x0F;
-
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-			memcpy(voc_pkt,
-				&buf_node->frame.voc_pkt[0],
-				buf_node->frame.pktlen);
-			list_add_tail(&buf_node->list, &prtd->free_in_queue);
-			break;
-		}
-		case MODE_IS127:
-		case MODE_4GV_NB:
-		case MODE_4GV_WB:
-		case MODE_4GV_NW: {
-			*((uint32_t *)voc_pkt) = buf_node->frame.pktlen +
-							 DSP_FRAME_HDR_LEN;
-			/* Advance to the header of voip packet */
-			voc_pkt = voc_pkt + sizeof(uint32_t);
-			/*
-			 * Add the DSP frame info header. Header format:
-			 * Bits 0-3 : Frame rate
-			 */
-			*voc_pkt = buf_node->frame.frm_hdr.packet_rate & 0x0F;
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-
-			memcpy(voc_pkt,
-				&buf_node->frame.voc_pkt[0],
-				buf_node->frame.pktlen);
-
-			list_add_tail(&buf_node->list, &prtd->free_in_queue);
-			break;
-		}
-		case MODE_G711:
-		case MODE_G711A:{
-			/* G711 frames are 10ms each but the DSP expects 20ms
-			 * worth of data, so send two 10ms frames per buffer.
-			 */
-			/* Add the first DSP frame info header. Header format:
-			 * Bits 0-1: Frame type
-			 * Bits 2-3: Frame rate
-			 */
-			voc_addr = voc_pkt;
-			voc_pkt = voc_pkt + sizeof(uint32_t);
-
-			*voc_pkt = ((prtd->rate_type  & 0x0F) << 2) |
-				    (buf_node->frame.frm_hdr.frame_type & 0x03);
-			voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-
-			pkt_len = buf_node->frame.pktlen + DSP_FRAME_HDR_LEN;
-
-			memcpy(voc_pkt,
-			       &buf_node->frame.voc_pkt[0],
-			       buf_node->frame.pktlen);
-			voc_pkt = voc_pkt + buf_node->frame.pktlen;
-
-			list_add_tail(&buf_node->list, &prtd->free_in_queue);
-
-			if (!list_empty(&prtd->in_queue)) {
-				/* Get the second buffer. */
-				buf_node = list_first_entry(&prtd->in_queue,
-							struct voip_buf_node,
-							list);
-				list_del(&buf_node->list);
-
-				/* Add the second DSP frame info header.
-				 * Header format:
-				 * Bits 0-1: Frame type
-				 * Bits 2-3: Frame rate
-				 */
-				*voc_pkt = ((prtd->rate_type & 0x0F) << 2) |
-				(buf_node->frame.frm_hdr.frame_type & 0x03);
-				voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN;
-
-				pkt_len = pkt_len + buf_node->frame.pktlen +
-					   DSP_FRAME_HDR_LEN;
-
-				memcpy(voc_pkt,
-				       &buf_node->frame.voc_pkt[0],
-				       buf_node->frame.pktlen);
-
-				list_add_tail(&buf_node->list,
-					      &prtd->free_in_queue);
-			} else {
-				/* Only 10ms worth of data is available, signal
-				 * erasure frame.
-				 */
-				*voc_pkt = ((prtd->rate_type & 0x0F) << 2) |
-					    (MVS_G711A_ERASURE & 0x03);
-
-				pkt_len = pkt_len + DSP_FRAME_HDR_LEN;
-				pr_debug("%s, Only 10ms read, erase 2nd frame\n",
-					 __func__);
-			}
-			*((uint32_t *)voc_addr) = pkt_len;
-			break;
-		}
-		default: {
-			*((uint32_t *)voc_pkt) = buf_node->frame.pktlen;
-			voc_pkt = voc_pkt + sizeof(uint32_t);
-			memcpy(voc_pkt,
-			       &buf_node->frame.voc_pkt[0],
-			       buf_node->frame.pktlen);
-			list_add_tail(&buf_node->list, &prtd->free_in_queue);
-		}
-		}
-		pr_debug("%s: frame.pktlen=%d\n", __func__,
-			 buf_node->frame.pktlen);
-
-		if (prtd->mode == MODE_PCM)
-			prtd->pcm_playback_irq_pos += buf_node->frame.pktlen;
-		else
-			prtd->pcm_playback_irq_pos += prtd->pcm_count;
-
-		spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-		snd_pcm_period_elapsed(prtd->playback_substream);
-	} else {
-		*((uint32_t *)voc_pkt) = 0;
-		spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-		pr_err_ratelimited("DL data not available\n");
-	}
-	wake_up(&prtd->in_wait);
-}
-
-static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
-	.count = ARRAY_SIZE(supported_sample_rates),
-	.list = supported_sample_rates,
-	.mask = 0,
-};
-
-static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-
-	prtd->play_samp_rate = runtime->rate;
-	prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream);
-	prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
-	prtd->pcm_playback_irq_pos = 0;
-	prtd->pcm_playback_buf_pos = 0;
-	prtd->playback_prepare = 1;
-
-	return 0;
-}
-
-static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-	int ret = 0;
-
-	prtd->cap_samp_rate = runtime->rate;
-	prtd->pcm_capture_size  = snd_pcm_lib_buffer_bytes(substream);
-	prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream);
-	prtd->pcm_capture_irq_pos = 0;
-	prtd->pcm_capture_buf_pos = 0;
-	prtd->capture_prepare = 1;
-	return ret;
-}
-
-static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-		pr_debug("%s: Trigger start\n", __func__);
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-			prtd->capture_start = 1;
-		else
-			prtd->playback_start = 1;
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("SNDRV_PCM_TRIGGER_STOP\n");
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-			prtd->playback_start = 0;
-		else
-			prtd->capture_start = 0;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static int msm_pcm_open(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = &voip_info;
-	int ret = 0;
-
-	pr_debug("%s, VoIP\n", __func__);
-	mutex_lock(&prtd->lock);
-
-	runtime->hw = msm_pcm_hardware;
-
-	ret = snd_pcm_hw_constraint_list(runtime, 0,
-					SNDRV_PCM_HW_PARAM_RATE,
-					&constraints_sample_rates);
-	if (ret < 0)
-		pr_debug("snd_pcm_hw_constraint_list failed\n");
-
-	ret = snd_pcm_hw_constraint_integer(runtime,
-					SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0) {
-		pr_debug("snd_pcm_hw_constraint_integer failed\n");
-		goto err;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		prtd->playback_substream = substream;
-	else
-		prtd->capture_substream = substream;
-
-	runtime->private_data = prtd;
-err:
-	mutex_unlock(&prtd->lock);
-
-	return ret;
-}
-
-static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
-	snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	struct voip_buf_node *buf_node = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-	unsigned long dsp_flags;
-
-	int count = frames_to_bytes(runtime, frames);
-
-	pr_debug("%s: count = %d, frames=%d\n", __func__, count, (int)frames);
-
-	if (prtd->voip_reset) {
-		pr_debug("%s: RESET event happened during VoIP\n", __func__);
-		return -ENETRESET;
-	}
-
-	ret = wait_event_interruptible_timeout(prtd->in_wait,
-				(!list_empty(&prtd->free_in_queue) ||
-				prtd->state == VOIP_STOPPED),
-				1 * HZ);
-	if (prtd->voip_reset) {
-		pr_debug("%s: RESET event happened during VoIP\n", __func__);
-		return -ENETRESET;
-	}
-
-	if (ret > 0) {
-		if (count <= VOIP_MAX_VOC_PKT_SIZE) {
-			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-			buf_node =
-				list_first_entry(&prtd->free_in_queue,
-						struct voip_buf_node, list);
-			list_del(&buf_node->list);
-			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-			if (prtd->mode == MODE_PCM) {
-				ret = copy_from_user(&buf_node->frame.voc_pkt,
-							buf, count);
-				if (ret) {
-					pr_err("%s: copy from user failed %d\n",
-					       __func__, ret);
-					return -EFAULT;
-				}
-				buf_node->frame.pktlen = count;
-			} else {
-				ret = copy_from_user(&buf_node->frame,
-							buf, count);
-				if (ret) {
-					pr_err("%s: copy from user failed %d\n",
-					       __func__, ret);
-					return -EFAULT;
-				}
-				if (buf_node->frame.pktlen >= count)
-					buf_node->frame.pktlen = count -
-					(sizeof(buf_node->frame.frm_hdr) +
-					 sizeof(buf_node->frame.pktlen));
-			}
-			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-			list_add_tail(&buf_node->list, &prtd->in_queue);
-			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-		} else {
-			pr_err("%s: Write cnt %d is > VOIP_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
-			ret = -ENOMEM;
-		}
-
-	} else if (ret == 0) {
-		pr_err("%s: No free DL buffs\n", __func__);
-		ret = -ETIMEDOUT;
-	} else {
-		pr_err("%s: playback copy was interrupted %d\n", __func__, ret);
-	}
-
-	return  ret;
-}
-static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-		int channel, snd_pcm_uframes_t hwoff, void __user *buf,
-						snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-	int count = 0;
-	struct voip_buf_node *buf_node = NULL;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-	unsigned long dsp_flags;
-	int size;
-
-	count = frames_to_bytes(runtime, frames);
-
-	pr_debug("%s: count = %d\n", __func__, count);
-
-	if (prtd->voip_reset) {
-		pr_debug("%s: RESET event happened during VoIP\n", __func__);
-		return -ENETRESET;
-	}
-
-	ret = wait_event_interruptible_timeout(prtd->out_wait,
-				(!list_empty(&prtd->out_queue) ||
-				prtd->state == VOIP_STOPPED),
-				1 * HZ);
-
-	if (prtd->voip_reset) {
-		pr_debug("%s: RESET event happened during VoIP\n", __func__);
-		return -ENETRESET;
-	}
-
-	if (ret > 0) {
-
-		if (count <= VOIP_MAX_VOC_PKT_SIZE) {
-			spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
-			buf_node = list_first_entry(&prtd->out_queue,
-					struct voip_buf_node, list);
-			list_del(&buf_node->list);
-			spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
-			if (prtd->mode == MODE_PCM) {
-				ret = copy_to_user(buf,
-						   &buf_node->frame.voc_pkt,
-						   buf_node->frame.pktlen);
-			} else {
-				size = sizeof(buf_node->frame.frm_hdr) +
-				       sizeof(buf_node->frame.pktlen) +
-				       buf_node->frame.pktlen;
-
-				ret = copy_to_user(buf,
-						   &buf_node->frame,
-						   size);
-			}
-			if (ret) {
-				pr_err("%s: Copy to user returned %d\n",
-					__func__, ret);
-				ret = -EFAULT;
-			}
-			spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
-			list_add_tail(&buf_node->list,
-						&prtd->free_out_queue);
-			spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
-		} else {
-			pr_err("%s: Read count %d > VOIP_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
-			ret = -ENOMEM;
-		}
-
-
-	} else if (ret == 0) {
-		pr_err_ratelimited("%s: No UL data available\n", __func__);
-		ret = -ETIMEDOUT;
-	} else {
-		pr_err("%s: Read was interrupted\n", __func__);
-		ret = -ERESTARTSYS;
-	}
-	return ret;
-}
-static int msm_pcm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
-{
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
-
-	return ret;
-}
-
-static int msm_pcm_close(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-	struct voip_buf_node *buf_node = NULL;
-	struct snd_dma_buffer *p_dma_buf, *c_dma_buf;
-	struct snd_pcm_substream *p_substream, *c_substream;
-	struct snd_pcm_runtime *runtime;
-	struct voip_drv_info *prtd;
-	unsigned long dsp_flags;
-
-	if (substream == NULL) {
-		pr_err("substream is NULL\n");
-		return -EINVAL;
-	}
-	runtime = substream->runtime;
-	prtd = runtime->private_data;
-
-	wake_up(&prtd->out_wait);
-
-	mutex_lock(&prtd->lock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		prtd->playback_prepare = 0;
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		prtd->capture_prepare = 0;
-
-	if (!prtd->playback_prepare && !prtd->capture_prepare) {
-		if (prtd->state == VOIP_STARTED) {
-			prtd->voip_reset = false;
-			prtd->state = VOIP_STOPPED;
-			voc_end_voice_call(
-					voc_get_session_id(VOIP_SESSION_NAME));
-			voc_register_mvs_cb(NULL, NULL, NULL, prtd);
-		}
-		/* release all buffer */
-		/* release in_queue and free_in_queue */
-		pr_debug("release all buffer\n");
-		p_substream = prtd->playback_substream;
-		if (p_substream == NULL) {
-			pr_debug("p_substream is NULL\n");
-			goto capt;
-		}
-		p_dma_buf = &p_substream->dma_buffer;
-		if (p_dma_buf == NULL) {
-			pr_debug("p_dma_buf is NULL\n");
-			goto capt;
-		}
-		if (p_dma_buf->area != NULL) {
-			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
-			list_for_each_safe(ptr, next, &prtd->in_queue) {
-				buf_node = list_entry(ptr,
-						struct voip_buf_node, list);
-				list_del(&buf_node->list);
-			}
-			list_for_each_safe(ptr, next, &prtd->free_in_queue) {
-				buf_node = list_entry(ptr,
-						struct voip_buf_node, list);
-				list_del(&buf_node->list);
-			}
-			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
-			dma_free_coherent(p_substream->pcm->card->dev,
-				runtime->hw.buffer_bytes_max, p_dma_buf->area,
-				p_dma_buf->addr);
-			p_dma_buf->area = NULL;
-		}
-		/* release out_queue and free_out_queue */
-capt:		c_substream = prtd->capture_substream;
-		if (c_substream == NULL) {
-			pr_debug("c_substream is NULL\n");
-			goto done;
-		}
-		c_dma_buf = &c_substream->dma_buffer;
-		if (c_substream == NULL) {
-			pr_debug("c_dma_buf is NULL.\n");
-			goto done;
-		}
-		if (c_dma_buf->area != NULL) {
-			spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
-			list_for_each_safe(ptr, next, &prtd->out_queue) {
-				buf_node = list_entry(ptr,
-						struct voip_buf_node, list);
-				list_del(&buf_node->list);
-			}
-			list_for_each_safe(ptr, next, &prtd->free_out_queue) {
-				buf_node = list_entry(ptr,
-						struct voip_buf_node, list);
-				list_del(&buf_node->list);
-			}
-			spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
-			dma_free_coherent(c_substream->pcm->card->dev,
-				runtime->hw.buffer_bytes_max, c_dma_buf->area,
-				c_dma_buf->addr);
-			c_dma_buf->area = NULL;
-		}
-done:
-		prtd->capture_substream = NULL;
-		prtd->playback_substream = NULL;
-	}
-	mutex_unlock(&prtd->lock);
-
-	return ret;
-}
-
-static int voip_config_vocoder(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-	uint32_t media_type = 0;
-	uint32_t rate_type = 0;
-	uint32_t evrc_min_rate_type = 0;
-	uint32_t evrc_max_rate_type = 0;
-
-	pr_debug("%s(): mode=%d, playback rate=%d, capture rate=%d\n",
-		 __func__, prtd->mode, prtd->play_samp_rate,
-		 prtd->cap_samp_rate);
-
-	if ((runtime->format != FORMAT_S16_LE &&
-	     runtime->format != FORMAT_SPECIAL) &&
-	    ((prtd->mode == MODE_AMR) || (prtd->mode == MODE_AMR_WB) ||
-	    (prtd->mode == MODE_IS127) || (prtd->mode == MODE_4GV_NB) ||
-	    (prtd->mode == MODE_4GV_WB) || (prtd->mode == MODE_4GV_NW) ||
-	    (prtd->mode == MODE_G711) || (prtd->mode == MODE_G711A))) {
-		pr_err("%s(): mode:%d and format:%u are not matched\n",
-			__func__, prtd->mode, (uint32_t)runtime->format);
-
-		ret =  -EINVAL;
-		goto done;
-	}
-
-	if (runtime->format != FORMAT_S16_LE && (prtd->mode == MODE_PCM)) {
-		pr_err("%s(): mode:%d and format:%u are not matched\n",
-		       __func__, prtd->mode, runtime->format);
-
-		ret =  -EINVAL;
-		goto done;
-	}
-
-	if ((prtd->mode == MODE_PCM) ||
-	    (prtd->mode == MODE_AMR) ||
-	    (prtd->mode == MODE_AMR_WB) ||
-	    (prtd->mode == MODE_G711) ||
-	    (prtd->mode == MODE_G711A)) {
-		ret = voip_get_rate_type(prtd->mode,
-					 prtd->rate,
-					 &rate_type);
-		if (ret < 0) {
-			pr_err("%s(): fail at getting rate_type, ret=%d\n",
-				__func__, ret);
-
-			ret = -EINVAL;
-			goto done;
-		}
-		prtd->rate_type = rate_type;
-		pr_debug("rate_type=%d\n", rate_type);
-
-	} else if ((prtd->mode == MODE_IS127) ||
-		   (prtd->mode == MODE_4GV_NB) ||
-		   (prtd->mode == MODE_4GV_WB) ||
-		   (prtd->mode == MODE_4GV_NW)) {
-		ret = voip_get_rate_type(prtd->mode,
-					 prtd->evrc_min_rate,
-					 &evrc_min_rate_type);
-		if (ret < 0) {
-			pr_err("%s(): fail at getting min rate, ret=%d\n",
-				__func__, ret);
-
-			ret = -EINVAL;
-			goto done;
-		}
-		if (evrc_min_rate_type == VOC_0_RATE)
-			evrc_min_rate_type = VOC_8_RATE;
-
-		ret = voip_get_rate_type(prtd->mode,
-					 prtd->evrc_max_rate,
-					 &evrc_max_rate_type);
-		if (ret < 0) {
-			pr_err("%s(): fail at getting max rate, ret=%d\n",
-				__func__, ret);
-
-			ret = -EINVAL;
-			goto done;
-		}
-		if (evrc_max_rate_type == VOC_0_RATE)
-			evrc_max_rate_type = VOC_1_RATE;
-
-		if (evrc_max_rate_type < evrc_min_rate_type) {
-			pr_err("%s(): Invalid EVRC min max rates: %d, %d\n",
-				__func__, evrc_min_rate_type,
-				evrc_max_rate_type);
-
-			ret = -EINVAL;
-			goto done;
-		}
-		pr_debug("%s(): min rate=%d, max rate=%d\n",
-			  __func__, evrc_min_rate_type, evrc_max_rate_type);
-	}
-	ret = voip_get_media_type(prtd->mode,
-				  prtd->rate_type,
-				  prtd->play_samp_rate,
-				  &media_type);
-	if (ret < 0) {
-		pr_err("%s(): fail at getting media_type, ret=%d\n",
-		       __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	pr_debug("%s(): media_type=%d\n", __func__, media_type);
-
-	if ((prtd->play_samp_rate == 8000 && prtd->cap_samp_rate == 8000) ||
-	    (prtd->play_samp_rate == 16000 && prtd->cap_samp_rate == 16000) ||
-	    (prtd->play_samp_rate == 32000 && prtd->cap_samp_rate == 32000) ||
-	    (prtd->play_samp_rate == 48000 && prtd->cap_samp_rate == 48000)) {
-		voc_config_vocoder(media_type, rate_type,
-				   VSS_NETWORK_ID_VOIP,
-				   voip_info.dtx_mode,
-				   evrc_min_rate_type,
-				   evrc_max_rate_type);
-	} else {
-		pr_debug("%s: Invalid rate playback %d, capture %d\n",
-			 __func__, prtd->play_samp_rate,
-			 prtd->cap_samp_rate);
-
-		ret = -EINVAL;
-	}
-done:
-
-	return ret;
-}
-
-static int msm_pcm_prepare(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-
-	mutex_lock(&prtd->lock);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_prepare(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_prepare(substream);
-
-	if (prtd->playback_prepare && prtd->capture_prepare
-	    && (prtd->state != VOIP_STARTED)) {
-		ret = voip_config_vocoder(substream);
-		if (ret < 0) {
-			pr_err("%s(): fail at configuring vocoder for voip, ret=%d\n",
-				__func__, ret);
-
-			goto done;
-		}
-
-		/* Initialaizing cb variables */
-		voc_register_mvs_cb(voip_process_ul_pkt,
-				    voip_process_dl_pkt,
-				    voip_ssr_cb_fn, prtd);
-
-		ret = voc_start_voice_call(
-				voc_get_session_id(VOIP_SESSION_NAME));
-
-		if (ret < 0) {
-			pr_err("%s: voc_start_voice_call() failed err %d",
-			       __func__, ret);
-
-			goto done;
-		}
-		prtd->state = VOIP_STARTED;
-	}
-done:
-	mutex_unlock(&prtd->lock);
-
-	return ret;
-}
-
-static snd_pcm_uframes_t
-msm_pcm_playback_pointer(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-
-	pr_debug("%s\n", __func__);
-	if (prtd->pcm_playback_irq_pos >= prtd->pcm_size)
-		prtd->pcm_playback_irq_pos = 0;
-	return bytes_to_frames(runtime, (prtd->pcm_playback_irq_pos));
-}
-
-static snd_pcm_uframes_t
-msm_pcm_capture_pointer(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct voip_drv_info *prtd = runtime->private_data;
-
-	if (prtd->pcm_capture_irq_pos >= prtd->pcm_capture_size)
-		prtd->pcm_capture_irq_pos = 0;
-	return bytes_to_frames(runtime, (prtd->pcm_capture_irq_pos));
-}
-
-static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
-{
-	snd_pcm_uframes_t ret = 0;
-
-	pr_debug("%s\n", __func__);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_pointer(substream);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_pointer(substream);
-	return ret;
-}
-
-static int msm_pcm_mmap(struct snd_pcm_substream *substream,
-			struct vm_area_struct *vma)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-
-	pr_debug("%s\n", __func__);
-	dma_mmap_coherent(substream->pcm->card->dev, vma,
-				     runtime->dma_area,
-				     runtime->dma_addr,
-				     runtime->dma_bytes);
-	return 0;
-}
-
-static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
-	struct voip_buf_node *buf_node = NULL;
-	int i = 0, offset = 0;
-
-	pr_debug("%s: voip\n", __func__);
-
-	mutex_lock(&voip_info.lock);
-
-	dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
-	dma_buf->dev.dev = substream->pcm->card->dev;
-	dma_buf->private_data = NULL;
-
-	dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev,
-			runtime->hw.buffer_bytes_max,
-			&dma_buf->addr, GFP_KERNEL);
-	if (!dma_buf->area) {
-		pr_err("%s:MSM VOIP dma_alloc failed\n", __func__);
-		mutex_unlock(&voip_info.lock);
-		return -ENOMEM;
-	}
-
-	dma_buf->bytes = runtime->hw.buffer_bytes_max;
-	memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		for (i = 0; i < VOIP_MAX_Q_LEN; i++) {
-			buf_node = (void *)dma_buf->area + offset;
-
-			list_add_tail(&buf_node->list,
-					&voip_info.free_in_queue);
-			offset = offset + sizeof(struct voip_buf_node);
-		}
-	} else {
-		for (i = 0; i < VOIP_MAX_Q_LEN; i++) {
-			buf_node = (void *) dma_buf->area + offset;
-			list_add_tail(&buf_node->list,
-					&voip_info.free_out_queue);
-			offset = offset + sizeof(struct voip_buf_node);
-		}
-	}
-
-	mutex_unlock(&voip_info.lock);
-
-	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
-	return 0;
-}
-
-static int msm_voip_mode_config_get(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	ucontrol->value.integer.value[0] = voip_info.mode;
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-
-static int msm_voip_mode_config_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	voip_info.mode = ucontrol->value.integer.value[0];
-
-	pr_debug("%s: mode=%d\n", __func__, voip_info.mode);
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-
-static int msm_voip_rate_config_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int rate = ucontrol->value.integer.value[0];
-
-	mutex_lock(&voip_info.lock);
-
-	if (voip_info.rate != rate) {
-		voip_info.rate = rate;
-		pr_debug("%s: rate=%d\n", __func__, voip_info.rate);
-
-		if (voip_info.state == VOIP_STARTED &&
-		   (voip_info.mode == MODE_AMR ||
-		    voip_info.mode == MODE_AMR_WB)) {
-			ret = voip_config_vocoder(
-					voip_info.capture_substream);
-			if (ret) {
-				pr_err("%s:Failed to configure vocoder, ret=%d\n",
-					__func__, ret);
-
-				goto done;
-			}
-
-			ret = voc_update_amr_vocoder_rate(
-					voc_get_session_id(VOIP_SESSION_NAME));
-			if (ret) {
-				pr_err("%s:Failed to update AMR rate, ret=%d\n",
-					__func__, ret);
-			}
-		}
-	}
-
-done:
-	mutex_unlock(&voip_info.lock);
-
-	return ret;
-}
-
-static int msm_voip_evrc_min_max_rate_config_get(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	ucontrol->value.integer.value[0] = voip_info.evrc_min_rate;
-	ucontrol->value.integer.value[1] = voip_info.evrc_max_rate;
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-
-static int msm_voip_evrc_min_max_rate_config_put(struct snd_kcontrol *kcontrol,
-					 struct snd_ctl_elem_value *ucontrol)
-{
-	mutex_lock(&voip_info.lock);
-
-	voip_info.evrc_min_rate = ucontrol->value.integer.value[0];
-	voip_info.evrc_max_rate = ucontrol->value.integer.value[1];
-
-	pr_debug("%s(): evrc_min_rate=%d,evrc_max_rate=%d\n", __func__,
-		  voip_info.evrc_min_rate, voip_info.evrc_max_rate);
-
-	mutex_unlock(&voip_info.lock);
-
-	return 0;
-}
-
-static int voip_get_rate_type(uint32_t mode, uint32_t rate,
-				 uint32_t *rate_type)
-{
-	int ret = 0;
-
-	switch (mode) {
-	case MODE_AMR: {
-		switch (rate) {
-		case 4750:
-			*rate_type = AMR_RATE_4750;
-			break;
-		case 5150:
-			*rate_type = AMR_RATE_5150;
-			break;
-		case 5900:
-			*rate_type = AMR_RATE_5900;
-			break;
-		case 6700:
-			*rate_type = AMR_RATE_6700;
-			break;
-		case 7400:
-			*rate_type = AMR_RATE_7400;
-			break;
-		case 7950:
-			*rate_type = AMR_RATE_7950;
-			break;
-		case 10200:
-			*rate_type = AMR_RATE_10200;
-			break;
-		case 12200:
-			*rate_type = AMR_RATE_12200;
-			break;
-		default:
-			pr_err("wrong rate for AMR NB.\n");
-			ret = -EINVAL;
-			break;
-		}
-		break;
-	}
-	case MODE_AMR_WB: {
-		switch (rate) {
-		case 6600:
-			*rate_type = AMR_RATE_6600 - AMR_RATE_6600;
-			break;
-		case 8850:
-			*rate_type = AMR_RATE_8850 - AMR_RATE_6600;
-			break;
-		case 12650:
-			*rate_type = AMR_RATE_12650 - AMR_RATE_6600;
-			break;
-		case 14250:
-			*rate_type = AMR_RATE_14250 - AMR_RATE_6600;
-			break;
-		case 15850:
-			*rate_type = AMR_RATE_15850 - AMR_RATE_6600;
-			break;
-		case 18250:
-			*rate_type = AMR_RATE_18250 - AMR_RATE_6600;
-			break;
-		case 19850:
-			*rate_type = AMR_RATE_19850 - AMR_RATE_6600;
-			break;
-		case 23050:
-			*rate_type = AMR_RATE_23050 - AMR_RATE_6600;
-			break;
-		case 23850:
-			*rate_type = AMR_RATE_23850 - AMR_RATE_6600;
-			break;
-		default:
-			pr_err("wrong rate for AMR_WB.\n");
-			ret = -EINVAL;
-			break;
-		}
-		break;
-	}
-	case MODE_PCM: {
-		*rate_type = 0;
-		break;
-	}
-	case MODE_IS127:
-	case MODE_4GV_NB:
-	case MODE_4GV_WB: {
-		switch (rate) {
-		case VOC_0_RATE:
-		case VOC_8_RATE:
-		case VOC_4_RATE:
-		case VOC_2_RATE:
-		case VOC_1_RATE:
-			*rate_type = rate;
-			break;
-		default:
-			pr_err("wrong rate for IS127/4GV_NB/WB.\n");
-			ret = -EINVAL;
-			break;
-		}
-		break;
-	}
-	case MODE_4GV_NW: {
-		switch (rate) {
-		case VOC_0_RATE:
-		case VOC_8_RATE:
-		case VOC_4_RATE:
-		case VOC_2_RATE:
-		case VOC_1_RATE:
-		case VOC_8_RATE_NC:
-			*rate_type = rate;
-			break;
-		default:
-			pr_err("wrong rate for 4GV_NW.\n");
-			ret = -EINVAL;
-			break;
-		}
-		break;
-	}
-	case MODE_G711:
-	case MODE_G711A:
-		*rate_type = rate;
-		break;
-	default:
-		pr_err("wrong mode type.\n");
-		ret = -EINVAL;
-	}
-	pr_debug("%s, mode=%d, rate=%u, rate_type=%d\n",
-		__func__, mode, rate, *rate_type);
-	return ret;
-}
-
-static int voip_get_media_type(uint32_t mode, uint32_t rate_type,
-			       unsigned int samp_rate,
-			       unsigned int *media_type)
-{
-	int ret = 0;
-
-	pr_debug("%s: mode=%d, samp_rate=%d\n", __func__,
-		mode, samp_rate);
-	switch (mode) {
-	case MODE_AMR:
-		*media_type = VSS_MEDIA_ID_AMR_NB_MODEM;
-		break;
-	case MODE_AMR_WB:
-		*media_type = VSS_MEDIA_ID_AMR_WB_MODEM;
-		break;
-	case MODE_PCM:
-		if (samp_rate == 8000)
-			*media_type = VSS_MEDIA_ID_PCM_8_KHZ;
-		else if (samp_rate == 16000)
-			*media_type = VSS_MEDIA_ID_PCM_16_KHZ;
-		else if (samp_rate == 32000)
-			*media_type = VSS_MEDIA_ID_PCM_32_KHZ;
-		else
-			*media_type = VSS_MEDIA_ID_PCM_48_KHZ;
-		break;
-	case MODE_IS127: /* EVRC-A */
-		*media_type = VSS_MEDIA_ID_EVRC_MODEM;
-		break;
-	case MODE_4GV_NB: /* EVRC-B */
-		*media_type = VSS_MEDIA_ID_4GV_NB_MODEM;
-		break;
-	case MODE_4GV_WB: /* EVRC-WB */
-		*media_type = VSS_MEDIA_ID_4GV_WB_MODEM;
-		break;
-	case MODE_4GV_NW: /* EVRC-NW */
-		*media_type = VSS_MEDIA_ID_4GV_NW_MODEM;
-		break;
-	case MODE_G711:
-	case MODE_G711A:
-		if (rate_type == MVS_G711A_MODE_MULAW)
-			*media_type = VSS_MEDIA_ID_G711_MULAW;
-		else
-			*media_type = VSS_MEDIA_ID_G711_ALAW;
-		break;
-	default:
-		pr_debug(" input mode is not supported\n");
-		ret = -EINVAL;
-	}
-
-	pr_debug("%s: media_type is 0x%x\n", __func__, *media_type);
-
-	return ret;
-}
-
-
-static const struct snd_pcm_ops msm_pcm_ops = {
-	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
-	.hw_params	= msm_pcm_hw_params,
-	.close          = msm_pcm_close,
-	.prepare        = msm_pcm_prepare,
-	.trigger        = msm_pcm_trigger,
-	.pointer        = msm_pcm_pointer,
-	.mmap		= msm_pcm_mmap,
-};
-
-static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_card *card = rtd->card->snd_card;
-	int ret = 0;
-
-	pr_debug("msm_asoc_pcm_new\n");
-	if (!card->dev->coherent_dma_mask)
-		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-	return ret;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.ops		= &msm_pcm_ops,
-	.pcm_new	= msm_asoc_pcm_new,
-	.probe		= msm_pcm_voip_probe,
-};
-
-static int msm_pcm_probe(struct platform_device *pdev)
-{
-	int rc;
-
-	if (!is_voc_initialized()) {
-		pr_debug("%s: voice module not initialized yet, deferring probe()\n",
-		       __func__);
-
-		rc = -EPROBE_DEFER;
-		goto done;
-	}
-
-	rc = voc_alloc_cal_shared_memory();
-	if (rc == -EPROBE_DEFER) {
-		pr_debug("%s: memory allocation for calibration deferred %d\n",
-			 __func__, rc);
-
-		goto done;
-	} else if (rc < 0) {
-		pr_err("%s: memory allocation for calibration failed %d\n",
-		       __func__, rc);
-	}
-
-	rc = voc_alloc_voip_shared_memory();
-	if (rc < 0) {
-		pr_err("%s: error allocating shared mem err %d\n",
-		       __func__, rc);
-	}
-
-
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	rc = snd_soc_register_platform(&pdev->dev,
-				       &msm_soc_platform);
-
-done:
-	return rc;
-}
-
-static int msm_pcm_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_voip_dt_match[] = {
-	{.compatible = "qcom,msm-voip-dsp"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_voip_dt_match);
-
-static struct platform_driver msm_pcm_driver = {
-	.driver = {
-		.name = "msm-voip-dsp",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_voip_dt_match,
-	},
-	.probe = msm_pcm_probe,
-	.remove = msm_pcm_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	memset(&voip_info, 0, sizeof(voip_info));
-	voip_info.mode = MODE_PCM;
-	mutex_init(&voip_info.lock);
-
-	spin_lock_init(&voip_info.dsp_lock);
-	spin_lock_init(&voip_info.dsp_ul_lock);
-
-	init_waitqueue_head(&voip_info.out_wait);
-	init_waitqueue_head(&voip_info.in_wait);
-
-	INIT_LIST_HEAD(&voip_info.in_queue);
-	INIT_LIST_HEAD(&voip_info.free_in_queue);
-	INIT_LIST_HEAD(&voip_info.out_queue);
-	INIT_LIST_HEAD(&voip_info.free_out_queue);
-
-	return platform_driver_register(&msm_pcm_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	platform_driver_unregister(&msm_pcm_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("PCM module platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c b/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c
deleted file mode 100644
index 53826fe..0000000
--- a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c
+++ /dev/null
@@ -1,1448 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/bitops.h>
-#include <linux/mutex.h>
-#include <sound/control.h>
-#include <sound/q6adm-v2.h>
-#include <sound/q6asm-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/asound.h>
-#include <sound/q6audio-v2.h>
-#include <sound/tlv.h>
-
-#include "msm-qti-pp-config.h"
-#include "msm-pcm-routing-v2.h"
-
-/* EQUALIZER */
-/* Equal to Frontend after last of the MULTIMEDIA SESSIONS */
-#define MAX_EQ_SESSIONS		MSM_FRONTEND_DAI_CS_VOICE
-
-enum {
-	EQ_BAND1 = 0,
-	EQ_BAND2,
-	EQ_BAND3,
-	EQ_BAND4,
-	EQ_BAND5,
-	EQ_BAND6,
-	EQ_BAND7,
-	EQ_BAND8,
-	EQ_BAND9,
-	EQ_BAND10,
-	EQ_BAND11,
-	EQ_BAND12,
-	EQ_BAND_MAX,
-};
-
-/* Audio Sphere data structures */
-struct msm_audio_pp_asphere_state_s {
-	uint32_t enabled;
-	uint32_t strength;
-	uint32_t mode;
-	uint32_t version;
-	int  port_id[AFE_MAX_PORTS];
-	int  copp_idx[AFE_MAX_PORTS];
-	bool  initialized;
-	uint32_t enabled_prev;
-	uint32_t strength_prev;
-};
-
-static struct msm_audio_pp_asphere_state_s asphere_state;
-
-struct msm_audio_eq_stream_config	eq_data[MAX_EQ_SESSIONS];
-
-static int msm_route_hfp_vol_control;
-static const DECLARE_TLV_DB_LINEAR(hfp_rx_vol_gain, 0,
-				INT_RX_VOL_MAX_STEPS);
-
-static int msm_route_icc_vol_control;
-static const DECLARE_TLV_DB_LINEAR(icc_rx_vol_gain, 0,
-				INT_RX_VOL_MAX_STEPS);
-
-static int msm_route_pri_auxpcm_lb_vol_ctrl;
-static const DECLARE_TLV_DB_LINEAR(pri_auxpcm_lb_vol_gain, 0,
-				INT_RX_VOL_MAX_STEPS);
-
-static int msm_route_sec_auxpcm_lb_vol_ctrl;
-static const DECLARE_TLV_DB_LINEAR(sec_auxpcm_lb_vol_gain, 0,
-				INT_RX_VOL_MAX_STEPS);
-
-static int msm_multichannel_ec_primary_mic_ch;
-
-static void msm_qti_pp_send_eq_values_(int eq_idx)
-{
-	int result;
-	struct msm_pcm_routing_fdai_data fe_dai;
-	struct audio_client *ac = NULL;
-
-	msm_pcm_routing_get_fedai_info(eq_idx, SESSION_TYPE_RX, &fe_dai);
-	ac = q6asm_get_audio_client(fe_dai.strm_id);
-
-	if (ac == NULL) {
-		pr_err("%s: Could not get audio client for session: %d\n",
-		      __func__, fe_dai.strm_id);
-		goto done;
-	}
-
-	result = q6asm_equalizer(ac, &eq_data[eq_idx]);
-
-	if (result < 0)
-		pr_err("%s: Call to ASM equalizer failed, returned = %d\n",
-		      __func__, result);
-done:
-	return;
-}
-
-static int msm_qti_pp_get_eq_enable_mixer(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
-		return -EINVAL;
-
-	ucontrol->value.integer.value[0] = eq_data[eq_idx].enable;
-
-	pr_debug("%s: EQ #%d enable %d\n", __func__,
-		eq_idx, eq_data[eq_idx].enable);
-	return 0;
-}
-
-static int msm_qti_pp_put_eq_enable_mixer(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int value = ucontrol->value.integer.value[0];
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
-		return -EINVAL;
-	pr_debug("%s: EQ #%d enable %d\n", __func__,
-		eq_idx, value);
-	eq_data[eq_idx].enable = value;
-	msm_pcm_routing_acquire_lock();
-	msm_qti_pp_send_eq_values_(eq_idx);
-	msm_pcm_routing_release_lock();
-	return 0;
-}
-
-static int msm_qti_pp_get_eq_band_count_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
-		return -EINVAL;
-	ucontrol->value.integer.value[0] = eq_data[eq_idx].num_bands;
-
-	pr_debug("%s: EQ #%d bands %d\n", __func__,
-		eq_idx, eq_data[eq_idx].num_bands);
-	return eq_data[eq_idx].num_bands;
-}
-
-static int msm_qti_pp_put_eq_band_count_audio_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int value = ucontrol->value.integer.value[0];
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
-		return -EINVAL;
-
-	pr_debug("%s: EQ #%d bands %d\n", __func__,
-		eq_idx, value);
-	eq_data[eq_idx].num_bands = value;
-	return 0;
-}
-
-static int msm_qti_pp_get_eq_band_audio_mixer(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) ||
-	    (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX))
-		return -EINVAL;
-
-	ucontrol->value.integer.value[0] =
-			eq_data[eq_idx].eq_bands[band_idx].band_idx;
-	ucontrol->value.integer.value[1] =
-			eq_data[eq_idx].eq_bands[band_idx].filter_type;
-	ucontrol->value.integer.value[2] =
-			eq_data[eq_idx].eq_bands[band_idx].center_freq_hz;
-	ucontrol->value.integer.value[3] =
-			eq_data[eq_idx].eq_bands[band_idx].filter_gain;
-	ucontrol->value.integer.value[4] =
-			eq_data[eq_idx].eq_bands[band_idx].q_factor;
-
-	pr_debug("%s: band_idx = %d\n", __func__,
-			eq_data[eq_idx].eq_bands[band_idx].band_idx);
-	pr_debug("%s: filter_type = %d\n", __func__,
-			eq_data[eq_idx].eq_bands[band_idx].filter_type);
-	pr_debug("%s: center_freq_hz = %d\n", __func__,
-			eq_data[eq_idx].eq_bands[band_idx].center_freq_hz);
-	pr_debug("%s: filter_gain = %d\n", __func__,
-			eq_data[eq_idx].eq_bands[band_idx].filter_gain);
-	pr_debug("%s: q_factor = %d\n", __func__,
-			eq_data[eq_idx].eq_bands[band_idx].q_factor);
-	return 0;
-}
-
-static int msm_qti_pp_put_eq_band_audio_mixer(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int eq_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->reg;
-	int band_idx = ((struct soc_multi_mixer_control *)
-					kcontrol->private_value)->shift;
-
-	if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) ||
-	    (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX))
-		return -EINVAL;
-
-	eq_data[eq_idx].eq_bands[band_idx].band_idx =
-					ucontrol->value.integer.value[0];
-	eq_data[eq_idx].eq_bands[band_idx].filter_type =
-					ucontrol->value.integer.value[1];
-	eq_data[eq_idx].eq_bands[band_idx].center_freq_hz =
-					ucontrol->value.integer.value[2];
-	eq_data[eq_idx].eq_bands[band_idx].filter_gain =
-					ucontrol->value.integer.value[3];
-	eq_data[eq_idx].eq_bands[band_idx].q_factor =
-					ucontrol->value.integer.value[4];
-	return 0;
-}
-
-#ifdef CONFIG_QTI_PP
-void msm_qti_pp_send_eq_values(int fedai_id)
-{
-	if (eq_data[fedai_id].enable)
-		msm_qti_pp_send_eq_values_(fedai_id);
-}
-
-/* CUSTOM MIXING */
-int msm_qti_pp_send_stereo_to_custom_stereo_cmd(int port_id, int copp_idx,
-						unsigned int session_id,
-						uint16_t op_FL_ip_FL_weight,
-						uint16_t op_FL_ip_FR_weight,
-						uint16_t op_FR_ip_FL_weight,
-						uint16_t op_FR_ip_FR_weight)
-{
-	char *params_value;
-	int *update_params_value32, rc = 0;
-	int16_t *update_params_value16 = 0;
-	uint32_t params_length = CUSTOM_STEREO_PAYLOAD_SIZE * sizeof(uint32_t);
-	uint32_t avail_length = params_length;
-
-	pr_debug("%s: port_id - %d, session id - %d\n", __func__, port_id,
-		 session_id);
-	params_value = kzalloc(params_length, GFP_KERNEL);
-	if (!params_value) {
-		pr_err("%s, params memory alloc failed\n", __func__);
-		return -ENOMEM;
-	}
-	update_params_value32 = (int *)params_value;
-	if (avail_length < 2 * sizeof(uint32_t))
-		goto skip_send_cmd;
-	*update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
-	*update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
-	avail_length = avail_length - (2 * sizeof(uint32_t));
-
-	update_params_value16 = (int16_t *)update_params_value32;
-	if (avail_length < 10 * sizeof(uint16_t))
-		goto skip_send_cmd;
-	*update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE;
-	/*for alignment only*/
-	*update_params_value16++ = 0;
-	/*index is 32-bit param in little endian*/
-	*update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM;
-	*update_params_value16++ = 0;
-	/*for stereo mixing num out ch*/
-	*update_params_value16++ = CUSTOM_STEREO_NUM_OUT_CH;
-	/*for stereo mixing num in ch*/
-	*update_params_value16++ = CUSTOM_STEREO_NUM_IN_CH;
-
-	/* Out ch map FL/FR*/
-	*update_params_value16++ = PCM_CHANNEL_FL;
-	*update_params_value16++ = PCM_CHANNEL_FR;
-
-	/* In ch map FL/FR*/
-	*update_params_value16++ = PCM_CHANNEL_FL;
-	*update_params_value16++ = PCM_CHANNEL_FR;
-	avail_length = avail_length - (10 * sizeof(uint16_t));
-	/* weighting coefficients as name suggests,
-	 * mixing will be done according to these coefficients
-	 */
-	if (avail_length < 4 * sizeof(uint16_t))
-		goto skip_send_cmd;
-	*update_params_value16++ = op_FL_ip_FL_weight;
-	*update_params_value16++ = op_FL_ip_FR_weight;
-	*update_params_value16++ = op_FR_ip_FL_weight;
-	*update_params_value16++ = op_FR_ip_FR_weight;
-	avail_length = avail_length - (4 * sizeof(uint16_t));
-	if (params_length) {
-		rc = adm_set_stereo_to_custom_stereo(port_id,
-						     copp_idx,
-						     session_id,
-						     params_value,
-						     params_length);
-		if (rc) {
-			pr_err("%s: send params failed rc=%d\n", __func__, rc);
-			kfree(params_value);
-			return -EINVAL;
-		}
-	}
-	kfree(params_value);
-	return 0;
-skip_send_cmd:
-		pr_err("%s: insufficient memory, send cmd failed\n",
-			__func__);
-		kfree(params_value);
-		return -ENOMEM;
-}
-#endif /* CONFIG_QTI_PP */
-
-/* RMS */
-static int msm_qti_pp_get_rms_value_control(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-	int be_idx = 0, copp_idx;
-	char *param_value;
-	int *update_param_value;
-	uint32_t param_length = sizeof(uint32_t);
-	uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
-	struct msm_pcm_routing_bdai_data msm_bedai;
-
-	param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
-	if (!param_value)
-		return -ENOMEM;
-
-	msm_pcm_routing_acquire_lock();
-	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
-		msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
-		if (msm_bedai.port_id == SLIMBUS_0_TX)
-			break;
-	}
-	if ((be_idx >= MSM_BACKEND_DAI_MAX) || !msm_bedai.active) {
-		pr_err("%s, back not active to query rms be_idx:%d\n",
-			__func__, be_idx);
-		rc = -EINVAL;
-		goto get_rms_value_err;
-	}
-	copp_idx = adm_get_default_copp_idx(SLIMBUS_0_TX);
-	if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) {
-		pr_err("%s, no active copp to query rms copp_idx:%d\n",
-			__func__, copp_idx);
-		rc = -EINVAL;
-		goto get_rms_value_err;
-	}
-	rc = adm_get_params(SLIMBUS_0_TX, copp_idx,
-			RMS_MODULEID_APPI_PASSTHRU,
-			RMS_PARAM_FIRST_SAMPLE,
-			param_length + param_payload_len,
-			param_value);
-	if (rc) {
-		pr_err("%s: get parameters failed rc=%d\n", __func__, rc);
-		rc = -EINVAL;
-		goto get_rms_value_err;
-	}
-	update_param_value = (int *)param_value;
-	ucontrol->value.integer.value[0] = update_param_value[0];
-
-	pr_debug("%s: FROM DSP value[0] 0x%x\n",
-		__func__, update_param_value[0]);
-get_rms_value_err:
-	msm_pcm_routing_release_lock();
-	kfree(param_value);
-	return rc;
-}
-
-static int msm_qti_pp_put_rms_value_control(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	/* not used */
-	return 0;
-}
-
-/* VOLUME */
-static int msm_route_fm_vol_control;
-static int msm_afe_lb_vol_ctrl;
-static int msm_afe_sec_mi2s_lb_vol_ctrl;
-static int msm_afe_tert_mi2s_lb_vol_ctrl;
-static int msm_afe_quat_mi2s_lb_vol_ctrl;
-static int msm_afe_slimbus_7_lb_vol_ctrl;
-static int msm_afe_slimbus_8_lb_vol_ctrl;
-static int msm_asm_bit_width;
-static const DECLARE_TLV_DB_LINEAR(fm_rx_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
-static const DECLARE_TLV_DB_LINEAR(afe_lb_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
-
-static int msm_qti_pp_get_fm_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_route_fm_vol_control;
-	return 0;
-}
-
-static int msm_qti_pp_set_fm_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(INT_FM_TX, ucontrol->value.integer.value[0]);
-
-	msm_route_fm_vol_control = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_asm_bit_width_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s get ASM bitwidth = %d\n",
-		__func__, msm_asm_bit_width);
-
-	ucontrol->value.integer.value[0] = msm_asm_bit_width;
-
-	return 0;
-}
-
-static int msm_asm_bit_width_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 16:
-		msm_asm_bit_width = 16;
-		break;
-	case 24:
-		msm_asm_bit_width = 24;
-		break;
-	case 32:
-		msm_asm_bit_width = 32;
-		break;
-	default:
-		msm_asm_bit_width = 0;
-		break;
-	}
-
-	return 0;
-}
-
-static int msm_qti_pp_get_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(AFE_PORT_ID_PRIMARY_MI2S_TX,
-			  ucontrol->value.integer.value[0]);
-
-	msm_afe_lb_vol_ctrl = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_sec_mi2s_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(AFE_PORT_ID_SECONDARY_MI2S_TX,
-			  ucontrol->value.integer.value[0]);
-	msm_afe_sec_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_tert_mi2s_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(AFE_PORT_ID_TERTIARY_MI2S_TX,
-			  ucontrol->value.integer.value[0]);
-	msm_afe_tert_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static int msm_qti_pp_get_slimbus_7_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_slimbus_7_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_slimbus_7_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = afe_loopback_gain(SLIMBUS_7_TX,
-				ucontrol->value.integer.value[0]);
-
-	if (ret)
-		pr_err("%s: failed to set LB vol for SLIMBUS_7_TX, err %d\n",
-			__func__, ret);
-	else
-		msm_afe_slimbus_7_lb_vol_ctrl =
-				ucontrol->value.integer.value[0];
-
-	return ret;
-}
-
-static int msm_qti_pp_get_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_slimbus_8_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-
-	ret = afe_loopback_gain(SLIMBUS_8_TX,
-				ucontrol->value.integer.value[0]);
-
-	if (ret)
-		pr_err("%s: failed to set LB vol for SLIMBUS_8_TX", __func__);
-	else
-		msm_afe_slimbus_8_lb_vol_ctrl =
-				ucontrol->value.integer.value[0];
-
-	return ret;
-}
-
-static int msm_qti_pp_get_icc_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_route_icc_vol_control;
-	return 0;
-}
-
-static int msm_qti_pp_set_icc_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	adm_set_mic_gain(AFE_PORT_ID_QUATERNARY_TDM_TX,
-		adm_get_default_copp_idx(AFE_PORT_ID_QUATERNARY_TDM_TX),
-		ucontrol->value.integer.value[0]);
-	msm_route_icc_vol_control = ucontrol->value.integer.value[0];
-	return 0;
-}
-
-static int msm_qti_pp_get_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_afe_quat_mi2s_lb_vol_ctrl;
-	return 0;
-}
-
-static int msm_qti_pp_set_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol,
-			    struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(AFE_PORT_ID_QUATERNARY_MI2S_TX,
-			  ucontrol->value.integer.value[0]);
-
-	msm_afe_quat_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_hfp_vol_mixer(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_route_hfp_vol_control;
-	return 0;
-}
-
-static int msm_qti_pp_set_hfp_vol_mixer(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	afe_loopback_gain(INT_BT_SCO_TX, ucontrol->value.integer.value[0]);
-
-	msm_route_hfp_vol_control = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_pri_auxpcm_lb_vol_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_route_pri_auxpcm_lb_vol_ctrl;
-	pr_debug("%s: Volume = %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_qti_pp_set_pri_auxpcm_lb_vol_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]);
-
-	msm_route_pri_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_sec_auxpcm_lb_vol_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_route_sec_auxpcm_lb_vol_ctrl;
-	pr_debug("%s: Volume = %ld\n", __func__,
-		ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_qti_pp_set_sec_auxpcm_lb_vol_mixer(
-					struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc =
-	(struct soc_mixer_control *)kcontrol->private_value;
-
-	afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]);
-
-	msm_route_sec_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0];
-
-	return 0;
-}
-
-static int msm_qti_pp_get_channel_map_mixer(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL] = {0};
-	int i;
-
-	adm_get_multi_ch_map(channel_map, ADM_PATH_PLAYBACK);
-	for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-		ucontrol->value.integer.value[i] =
-			(unsigned int) channel_map[i];
-	return 0;
-}
-
-static int msm_qti_pp_put_channel_map_mixer(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL];
-	int i;
-
-	for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++)
-		channel_map[i] = (char)(ucontrol->value.integer.value[i]);
-	adm_set_multi_ch_map(channel_map, ADM_PATH_PLAYBACK);
-
-	return 0;
-}
-
-/* Audio Sphere functions */
-
-static void msm_qti_pp_asphere_init_state(void)
-{
-	int i;
-
-	if (asphere_state.initialized)
-		return;
-	asphere_state.initialized = true;
-	for (i = 0; i < AFE_MAX_PORTS; i++) {
-		asphere_state.port_id[i] = -1;
-		asphere_state.copp_idx[i] = -1;
-	}
-	asphere_state.enabled = 0;
-	asphere_state.strength = 0;
-	asphere_state.mode = 0;
-	asphere_state.version = 0;
-	asphere_state.enabled_prev = 0;
-	asphere_state.strength_prev = 0;
-}
-
-static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force)
-{
-	char *params_value = NULL;
-	uint32_t *update_params_value = NULL;
-	uint32_t param_size = sizeof(uint32_t) +
-			sizeof(struct adm_param_data_v5);
-	int params_length = 0, param_count = 0, ret = 0;
-	bool set_enable = force ||
-			(asphere_state.enabled != asphere_state.enabled_prev);
-	bool set_strength = asphere_state.enabled == 1 && (set_enable ||
-		(asphere_state.strength != asphere_state.strength_prev));
-
-	if (set_enable)
-		param_count++;
-	if (set_strength)
-		param_count++;
-	params_length = param_count * param_size;
-
-	pr_debug("%s: port_id %d, copp_id %d, forced %d, param_count %d\n",
-			__func__, port_id, copp_idx, force, param_count);
-	pr_debug("%s: enable prev:%u cur:%u, strength prev:%u cur:%u\n",
-		__func__, asphere_state.enabled_prev, asphere_state.enabled,
-		asphere_state.strength_prev, asphere_state.strength);
-
-	if (params_length > 0)
-		params_value = kzalloc(params_length, GFP_KERNEL);
-	if (!params_value) {
-		pr_err("%s, params memory alloc failed\n", __func__);
-		return -ENOMEM;
-	}
-	update_params_value = (uint32_t *)params_value;
-	params_length = 0;
-	if (set_strength) {
-		/* add strength command */
-		*update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
-		*update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
-		*update_params_value++ = sizeof(uint32_t);
-		*update_params_value++ = asphere_state.strength;
-		params_length += param_size;
-	}
-	if (set_enable) {
-		/* add enable command */
-		*update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
-		*update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
-		*update_params_value++ = sizeof(uint32_t);
-		*update_params_value++ = asphere_state.enabled;
-		params_length += param_size;
-	}
-	pr_debug("%s, param length: %d\n", __func__, params_length);
-	if (params_length) {
-		ret = adm_send_params_v5(port_id, copp_idx,
-					params_value, params_length);
-		if (ret) {
-			pr_err("%s: setting param failed with err=%d\n",
-				__func__, ret);
-			kfree(params_value);
-			return -EINVAL;
-		}
-	}
-	kfree(params_value);
-	return 0;
-}
-
-#if defined(CONFIG_QTI_PP) && defined(CONFIG_QTI_PP_AUDIOSPHERE)
-int msm_qti_pp_asphere_init(int port_id, int copp_idx)
-{
-	int index = adm_validate_and_get_port_index(port_id);
-
-	pr_debug("%s, port_id %d, copp_id %d\n", __func__, port_id, copp_idx);
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
-			port_id);
-		return -EINVAL;
-	}
-	msm_qti_pp_asphere_init_state();
-
-	asphere_state.port_id[index] = port_id;
-	asphere_state.copp_idx[index] = copp_idx;
-
-	if (asphere_state.enabled)
-		msm_qti_pp_asphere_send_params(port_id, copp_idx, true);
-
-	return 0;
-}
-
-void msm_qti_pp_asphere_deinit(int port_id)
-{
-	int index = adm_validate_and_get_port_index(port_id);
-
-	pr_debug("%s, port_id %d\n", __func__, port_id);
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
-			port_id);
-		return;
-	}
-
-	if (asphere_state.port_id[index] == port_id) {
-		asphere_state.port_id[index] = -1;
-		asphere_state.copp_idx[index] = -1;
-	}
-}
-#endif
-
-static int msm_qti_pp_asphere_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	if (!asphere_state.initialized)
-		return -EAGAIN;
-	ucontrol->value.integer.value[0] = asphere_state.enabled;
-	ucontrol->value.integer.value[1] = asphere_state.strength;
-	pr_debug("%s, enable %u, strength %u\n", __func__,
-			asphere_state.enabled, asphere_state.strength);
-	return 0;
-}
-
-static int msm_qti_pp_asphere_set(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	int32_t enable = ucontrol->value.integer.value[0];
-	int32_t strength = ucontrol->value.integer.value[1];
-	int i;
-
-	pr_debug("%s, enable %u, strength %u\n", __func__, enable, strength);
-
-	msm_qti_pp_asphere_init_state();
-
-	if (enable == 0 || enable == 1) {
-		asphere_state.enabled_prev = asphere_state.enabled;
-		asphere_state.enabled = enable;
-	}
-
-	if (strength >= 0 && strength <= 1000) {
-		asphere_state.strength_prev = asphere_state.strength;
-		asphere_state.strength = strength;
-	}
-
-	if (asphere_state.strength != asphere_state.strength_prev ||
-		asphere_state.enabled != asphere_state.enabled_prev) {
-		for (i = 0; i < AFE_MAX_PORTS; i++) {
-			if (asphere_state.port_id[i] >= 0)
-				msm_qti_pp_asphere_send_params(
-					asphere_state.port_id[i],
-					asphere_state.copp_idx[i],
-					false);
-		}
-	}
-	return 0;
-}
-
-int msm_adsp_init_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_kcontrol *kctl;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	struct dsp_stream_callback_prtd *kctl_prtd = NULL;
-
-	if (!rtd) {
-		pr_err("%s: rtd is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
-		rtd->pcm->device);
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	kfree(mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (kctl->private_data != NULL) {
-		pr_err("%s: kctl_prtd is not NULL at initialization.\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	kctl_prtd = kzalloc(sizeof(struct dsp_stream_callback_prtd),
-			GFP_KERNEL);
-	if (!kctl_prtd) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	spin_lock_init(&kctl_prtd->prtd_spin_lock);
-	INIT_LIST_HEAD(&kctl_prtd->event_queue);
-	kctl_prtd->event_count = 0;
-	kctl->private_data = kctl_prtd;
-
-done:
-	return ret;
-}
-
-int msm_adsp_clean_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_kcontrol *kctl;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct dsp_stream_callback_list *node, *n;
-	unsigned long spin_flags;
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	struct dsp_stream_callback_prtd *kctl_prtd = NULL;
-
-	if (!rtd) {
-		pr_err("%s: rtd is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
-		rtd->pcm->device);
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	kfree(mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	kctl_prtd = (struct dsp_stream_callback_prtd *)
-			kctl->private_data;
-	if (kctl_prtd != NULL) {
-		spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
-		/* clean the queue */
-		list_for_each_entry_safe(node, n,
-				&kctl_prtd->event_queue, list) {
-			list_del(&node->list);
-			kctl_prtd->event_count--;
-			pr_debug("%s: %d remaining events after del.\n",
-				__func__, kctl_prtd->event_count);
-			kfree(node);
-		}
-		spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
-	}
-
-	kfree(kctl_prtd);
-	kctl->private_data = NULL;
-
-done:
-	return ret;
-}
-
-int msm_adsp_inform_mixer_ctl(struct snd_soc_pcm_runtime *rtd,
-			uint32_t *payload)
-{
-	/* adsp pp event notifier */
-	struct snd_kcontrol *kctl;
-	struct snd_ctl_elem_value control;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct dsp_stream_callback_list *new_event;
-	struct dsp_stream_callback_list *oldest_event;
-	unsigned long spin_flags;
-	struct dsp_stream_callback_prtd *kctl_prtd = NULL;
-	struct msm_adsp_event_data *event_data = NULL;
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	struct snd_ctl_elem_info kctl_info;
-
-	if (!rtd || !payload) {
-		pr_err("%s: %s is NULL\n", __func__,
-			(!rtd) ? "rtd" : "payload");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (rtd->card->snd_card == NULL) {
-		pr_err("%s: snd_card is null.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_ATOMIC);
-	if (!mixer_str) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
-		rtd->pcm->device);
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	kfree(mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	event_data = (struct msm_adsp_event_data *)payload;
-	kctl->info(kctl, &kctl_info);
-	if (sizeof(struct msm_adsp_event_data)
-		+ event_data->payload_len > kctl_info.count) {
-		pr_err("%s: payload length exceeds limit of %u bytes.\n",
-			__func__, kctl_info.count);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	kctl_prtd = (struct dsp_stream_callback_prtd *)
-			kctl->private_data;
-	if (kctl_prtd == NULL) {
-		/* queue is not initialized */
-		ret = -EINVAL;
-		pr_err("%s: event queue is not initialized.\n", __func__);
-		goto done;
-	}
-
-	new_event = kzalloc(sizeof(struct dsp_stream_callback_list)
-			+ event_data->payload_len,
-			GFP_ATOMIC);
-	if (new_event == NULL) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	memcpy((void *)&new_event->event, (void *)payload,
-		   event_data->payload_len
-		   + sizeof(struct msm_adsp_event_data));
-
-	spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
-	while (kctl_prtd->event_count >= DSP_STREAM_CALLBACK_QUEUE_SIZE) {
-		pr_info("%s: queue of size %d is full. delete oldest one.\n",
-			__func__, DSP_STREAM_CALLBACK_QUEUE_SIZE);
-		oldest_event = list_first_entry(&kctl_prtd->event_queue,
-				struct dsp_stream_callback_list, list);
-		pr_info("%s: event deleted: type %d length %d\n",
-			__func__, oldest_event->event.event_type,
-			oldest_event->event.payload_len);
-		list_del(&oldest_event->list);
-		kctl_prtd->event_count--;
-		kfree(oldest_event);
-	}
-
-	list_add_tail(&new_event->list, &kctl_prtd->event_queue);
-	kctl_prtd->event_count++;
-	spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
-
-	control.id = kctl->id;
-	snd_ctl_notify(rtd->card->snd_card,
-			SNDRV_CTL_EVENT_MASK_INFO,
-			&control.id);
-
-done:
-	return ret;
-}
-
-int msm_adsp_stream_cmd_info(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count =
-		sizeof(((struct snd_ctl_elem_value *)0)->value.bytes.data);
-
-	return 0;
-}
-
-int msm_adsp_stream_callback_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	uint32_t payload_size = 0;
-	struct dsp_stream_callback_list *oldest_event;
-	unsigned long spin_flags;
-	struct dsp_stream_callback_prtd *kctl_prtd = NULL;
-	int ret = 0;
-
-	kctl_prtd = (struct dsp_stream_callback_prtd *)
-			kcontrol->private_data;
-	if (kctl_prtd == NULL) {
-		pr_err("%s: ASM Stream PP event queue is not initialized.\n",
-			__func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
-	pr_debug("%s: %d events in queue.\n", __func__, kctl_prtd->event_count);
-	if (list_empty(&kctl_prtd->event_queue)) {
-		pr_err("%s: ASM Stream PP event queue is empty.\n", __func__);
-		ret = -EINVAL;
-		spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
-		goto done;
-	}
-
-	oldest_event = list_first_entry(&kctl_prtd->event_queue,
-			struct dsp_stream_callback_list, list);
-	list_del(&oldest_event->list);
-	kctl_prtd->event_count--;
-	spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
-
-	payload_size = oldest_event->event.payload_len;
-	pr_debug("%s: event fetched: type %d length %d\n",
-			__func__, oldest_event->event.event_type,
-			oldest_event->event.payload_len);
-	memcpy(ucontrol->value.bytes.data, &oldest_event->event,
-		sizeof(struct msm_adsp_event_data) + payload_size);
-	kfree(oldest_event);
-
-done:
-	return ret;
-}
-
-int msm_adsp_stream_callback_info(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_info *uinfo)
-{
-	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-	uinfo->count =
-		sizeof(((struct snd_ctl_elem_value *)0)->value.bytes.data);
-
-	return 0;
-}
-
-static int msm_multichannel_ec_primary_mic_ch_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = 0;
-	int copp_idx = 0;
-	int port_id = AFE_PORT_ID_QUATERNARY_TDM_TX;
-
-	msm_multichannel_ec_primary_mic_ch = ucontrol->value.integer.value[0];
-	pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %u\n",
-		__func__, msm_multichannel_ec_primary_mic_ch);
-	copp_idx = adm_get_default_copp_idx(port_id);
-	if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) {
-		pr_err("%s : no active copp to query multichannel ec copp_idx: %u\n",
-			__func__, copp_idx);
-		return -EINVAL;
-	}
-	adm_send_set_multichannel_ec_primary_mic_ch(port_id, copp_idx,
-		msm_multichannel_ec_primary_mic_ch);
-
-	return ret;
-}
-
-static int msm_multichannel_ec_primary_mic_ch_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_multichannel_ec_primary_mic_ch;
-	pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %lu\n",
-		__func__, ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static const struct  snd_kcontrol_new msm_multichannel_ec_controls[] = {
-	SOC_SINGLE_EXT("Multichannel EC Primary Mic Ch", SND_SOC_NOPM, 0,
-		0xFFFFFFFF, 0, msm_multichannel_ec_primary_mic_ch_get,
-		msm_multichannel_ec_primary_mic_ch_put),
-};
-
-static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_fm_vol_mixer,
-	msm_qti_pp_set_fm_vol_mixer, fm_rx_vol_gain),
-	SOC_SINGLE_EXT_TLV("Quat MI2S FM RX Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_quat_mi2s_fm_vol_mixer,
-	msm_qti_pp_set_quat_mi2s_fm_vol_mixer, fm_rx_vol_gain),
-};
-
-static const struct snd_kcontrol_new dsp_bit_width_controls[] = {
-	SOC_SINGLE_EXT(DSP_BIT_WIDTH_MIXER_CTL, SND_SOC_NOPM, 0, 0x20,
-	0, msm_asm_bit_width_get, msm_asm_bit_width_put),
-};
-
-static const struct snd_kcontrol_new pri_mi2s_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("PRI MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_pri_mi2s_lb_vol_mixer,
-	msm_qti_pp_set_pri_mi2s_lb_vol_mixer, afe_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new sec_mi2s_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("SEC MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_sec_mi2s_lb_vol_mixer,
-	msm_qti_pp_set_sec_mi2s_lb_vol_mixer, afe_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new tert_mi2s_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("Tert MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_tert_mi2s_lb_vol_mixer,
-	msm_qti_pp_set_tert_mi2s_lb_vol_mixer, afe_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new slimbus_7_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("SLIMBUS_7 LOOPBACK Volume", SND_SOC_NOPM, 0,
-				INT_RX_VOL_GAIN, 0,
-				msm_qti_pp_get_slimbus_7_lb_vol_mixer,
-				msm_qti_pp_set_slimbus_7_lb_vol_mixer,
-				afe_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new slimbus_8_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("SLIMBUS_8 LOOPBACK Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_slimbus_8_lb_vol_mixer,
-	msm_qti_pp_set_slimbus_8_lb_vol_mixer, afe_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new int_hfp_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("Internal HFP RX Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_hfp_vol_mixer,
-	msm_qti_pp_set_hfp_vol_mixer, hfp_rx_vol_gain),
-};
-
-static const struct snd_kcontrol_new int_icc_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("Internal ICC Volume", SND_SOC_NOPM, 0,
-	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_icc_vol_mixer,
-	msm_qti_pp_set_icc_vol_mixer, icc_rx_vol_gain),
-};
-
-static const struct snd_kcontrol_new pri_auxpcm_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("PRI AUXPCM LOOPBACK Volume",
-	AFE_PORT_ID_PRIMARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0,
-	msm_qti_pp_get_pri_auxpcm_lb_vol_mixer,
-	msm_qti_pp_set_pri_auxpcm_lb_vol_mixer,
-	pri_auxpcm_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new sec_auxpcm_lb_vol_mixer_controls[] = {
-	SOC_SINGLE_EXT_TLV("SEC AUXPCM LOOPBACK Volume",
-	AFE_PORT_ID_SECONDARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0,
-	msm_qti_pp_get_sec_auxpcm_lb_vol_mixer,
-	msm_qti_pp_set_sec_auxpcm_lb_vol_mixer,
-	sec_auxpcm_lb_vol_gain),
-};
-
-static const struct snd_kcontrol_new multi_ch_channel_map_mixer_controls[] = {
-	SOC_SINGLE_MULTI_EXT("Playback Device Channel Map", SND_SOC_NOPM, 0, 16,
-	0, 8, msm_qti_pp_get_channel_map_mixer,
-	msm_qti_pp_put_channel_map_mixer),
-};
-
-
-static const struct snd_kcontrol_new get_rms_controls[] = {
-	SOC_SINGLE_EXT("Get RMS", SND_SOC_NOPM, 0, 0xFFFFFFFF,
-	0, msm_qti_pp_get_rms_value_control, msm_qti_pp_put_rms_value_control),
-};
-
-static const struct snd_kcontrol_new eq_enable_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1 EQ Enable", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_qti_pp_get_eq_enable_mixer,
-	msm_qti_pp_put_eq_enable_mixer),
-	SOC_SINGLE_EXT("MultiMedia2 EQ Enable", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_qti_pp_get_eq_enable_mixer,
-	msm_qti_pp_put_eq_enable_mixer),
-	SOC_SINGLE_EXT("MultiMedia3 EQ Enable", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_qti_pp_get_eq_enable_mixer,
-	msm_qti_pp_put_eq_enable_mixer),
-};
-
-static const struct snd_kcontrol_new eq_band_mixer_controls[] = {
-	SOC_SINGLE_EXT("MultiMedia1 EQ Band Count", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 11, 0,
-	msm_qti_pp_get_eq_band_count_audio_mixer,
-	msm_qti_pp_put_eq_band_count_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia2 EQ Band Count", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 11, 0,
-	msm_qti_pp_get_eq_band_count_audio_mixer,
-	msm_qti_pp_put_eq_band_count_audio_mixer),
-	SOC_SINGLE_EXT("MultiMedia3 EQ Band Count", SND_SOC_NOPM,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 11, 0,
-	msm_qti_pp_get_eq_band_count_audio_mixer,
-	msm_qti_pp_put_eq_band_count_audio_mixer),
-};
-
-static const struct snd_kcontrol_new eq_coeff_mixer_controls[] = {
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band1", EQ_BAND1,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band2", EQ_BAND2,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band3", EQ_BAND3,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band4", EQ_BAND4,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band5", EQ_BAND5,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band6", EQ_BAND6,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band7", EQ_BAND7,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band8", EQ_BAND8,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band9", EQ_BAND9,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band10", EQ_BAND10,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band11", EQ_BAND11,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band12", EQ_BAND12,
-	MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band1", EQ_BAND1,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band2", EQ_BAND2,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band3", EQ_BAND3,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band4", EQ_BAND4,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band5", EQ_BAND5,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band6", EQ_BAND6,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band7", EQ_BAND7,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band8", EQ_BAND8,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band9", EQ_BAND9,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band10", EQ_BAND10,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band11", EQ_BAND11,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band12", EQ_BAND12,
-	MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band1", EQ_BAND1,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band2", EQ_BAND2,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band3", EQ_BAND3,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band4", EQ_BAND4,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band5", EQ_BAND5,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band6", EQ_BAND6,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band7", EQ_BAND7,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band8", EQ_BAND8,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band9", EQ_BAND9,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band10", EQ_BAND10,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band11", EQ_BAND11,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-	SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band12", EQ_BAND12,
-	MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
-	msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
-};
-
-static const struct snd_kcontrol_new asphere_mixer_controls[] = {
-	SOC_SINGLE_MULTI_EXT("MSM ASphere Set Param", SND_SOC_NOPM, 0,
-	0xFFFFFFFF, 0, 2, msm_qti_pp_asphere_get, msm_qti_pp_asphere_set),
-};
-
-#ifdef CONFIG_QTI_PP
-void msm_qti_pp_add_controls(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform, int_fm_vol_mixer_controls,
-			ARRAY_SIZE(int_fm_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, pri_mi2s_lb_vol_mixer_controls,
-			ARRAY_SIZE(pri_mi2s_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, sec_mi2s_lb_vol_mixer_controls,
-			ARRAY_SIZE(sec_mi2s_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, tert_mi2s_lb_vol_mixer_controls,
-			ARRAY_SIZE(tert_mi2s_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, slimbus_7_lb_vol_mixer_controls,
-			ARRAY_SIZE(slimbus_7_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, slimbus_8_lb_vol_mixer_controls,
-			ARRAY_SIZE(slimbus_8_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, int_hfp_vol_mixer_controls,
-			ARRAY_SIZE(int_hfp_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, int_icc_vol_mixer_controls,
-			ARRAY_SIZE(int_icc_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform,
-			pri_auxpcm_lb_vol_mixer_controls,
-			ARRAY_SIZE(pri_auxpcm_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform,
-				sec_auxpcm_lb_vol_mixer_controls,
-			ARRAY_SIZE(sec_auxpcm_lb_vol_mixer_controls));
-
-	snd_soc_add_platform_controls(platform,
-				multi_ch_channel_map_mixer_controls,
-			ARRAY_SIZE(multi_ch_channel_map_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, get_rms_controls,
-			ARRAY_SIZE(get_rms_controls));
-
-	snd_soc_add_platform_controls(platform, eq_enable_mixer_controls,
-			ARRAY_SIZE(eq_enable_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, eq_band_mixer_controls,
-			ARRAY_SIZE(eq_band_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, eq_coeff_mixer_controls,
-			ARRAY_SIZE(eq_coeff_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, asphere_mixer_controls,
-			ARRAY_SIZE(asphere_mixer_controls));
-
-	snd_soc_add_platform_controls(platform, msm_multichannel_ec_controls,
-			ARRAY_SIZE(msm_multichannel_ec_controls));
-
-	snd_soc_add_platform_controls(platform, dsp_bit_width_controls,
-			ARRAY_SIZE(dsp_bit_width_controls));
-}
-#endif /* CONFIG_QTI_PP */
diff --git a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.h b/sound/soc/msm/qdsp6v2/msm-qti-pp-config.h
deleted file mode 100644
index ec69d37..0000000
--- a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 _MSM_QTI_PP_H_
-#define _MSM_QTI_PP_H_
-
-#include <sound/soc.h>
-#define DSP_BIT_WIDTH_MIXER_CTL "ASM Bit Width"
-int msm_adsp_inform_mixer_ctl(struct snd_soc_pcm_runtime *rtd,
-			uint32_t *payload);
-int msm_adsp_init_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd);
-int msm_adsp_clean_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd);
-int msm_adsp_stream_cmd_info(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_info *uinfo);
-int msm_adsp_stream_callback_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol);
-int msm_adsp_stream_callback_info(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_info *uinfo);
-#ifdef CONFIG_QTI_PP
-void msm_qti_pp_send_eq_values(int fedai_id);
-int msm_qti_pp_send_stereo_to_custom_stereo_cmd(int port_id, int copp_idx,
-						unsigned int session_id,
-						uint16_t op_FL_ip_FL_weight,
-						uint16_t op_FL_ip_FR_weight,
-						uint16_t op_FR_ip_FL_weight,
-						uint16_t op_FR_ip_FR_weight);
-void msm_qti_pp_add_controls(struct snd_soc_platform *platform);
-#else /* CONFIG_QTI_PP */
-#define msm_qti_pp_send_eq_values(fedai_id) do {} while (0)
-#define msm_qti_pp_send_stereo_to_custom_stereo_cmd(port_id, copp_idx, \
-			session_id, op_FL_ip_FL_weight, op_FL_ip_FR_weight, \
-			op_FR_ip_FL_weight, op_FR_ip_FR_weight) (0)
-#define msm_qti_pp_add_controls(platform) do {} while (0)
-#endif /* CONFIG_QTI_PP */
-
-
-#if defined(CONFIG_QTI_PP) && defined(CONFIG_QTI_PP_AUDIOSPHERE)
-int msm_qti_pp_asphere_init(int port_id, int copp_idx);
-void msm_qti_pp_asphere_deinit(int port_id);
-#else
-#define msm_qti_pp_asphere_init(port_id, copp_idx) (0)
-#define msm_qti_pp_asphere_deinit(port_id) do {} while (0)
-#endif
-
-#endif /* _MSM_QTI_PP_H_ */
diff --git a/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c
deleted file mode 100644
index b1bb272..0000000
--- a/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/init.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/time.h>
-#include <linux/math64.h>
-#include <linux/wait.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_ion.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/control.h>
-#include <sound/q6asm-v2.h>
-#include <sound/pcm_params.h>
-#include <sound/timer.h>
-#include <sound/tlv.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/compress_params.h>
-#include <sound/compress_offload.h>
-#include <sound/compress_driver.h>
-#include <linux/msm_audio.h>
-
-#include "msm-pcm-routing-v2.h"
-#include "msm-qti-pp-config.h"
-
-#define LOOPBACK_SESSION_MAX_NUM_STREAMS 2
-
-static DEFINE_MUTEX(transcode_loopback_session_lock);
-
-struct trans_loopback_pdata {
-	struct snd_compr_stream *cstream[MSM_FRONTEND_DAI_MAX];
-};
-
-struct loopback_stream {
-	struct snd_compr_stream *cstream;
-	uint32_t codec_format;
-	bool start;
-};
-
-enum loopback_session_state {
-	/* One or both streams not opened */
-	LOOPBACK_SESSION_CLOSE = 0,
-	/* Loopback streams opened */
-	LOOPBACK_SESSION_READY,
-	/* Loopback streams opened and formats configured */
-	LOOPBACK_SESSION_START,
-	/* Trigger issued on either of streams when in START state */
-	LOOPBACK_SESSION_RUN
-};
-
-struct msm_transcode_loopback {
-	struct loopback_stream source;
-	struct loopback_stream sink;
-
-	struct snd_compr_caps source_compr_cap;
-	struct snd_compr_caps sink_compr_cap;
-
-	uint32_t instance;
-	uint32_t num_streams;
-	int session_state;
-
-	struct mutex lock;
-
-	int session_id;
-	struct audio_client *audio_client;
-};
-
-/* Transcode loopback global info struct */
-static struct msm_transcode_loopback transcode_info;
-
-static void loopback_event_handler(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv)
-{
-	struct msm_transcode_loopback *trans =
-			(struct msm_transcode_loopback *)priv;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_compr_stream *cstream;
-	struct audio_client *ac;
-	int stream_id;
-	int ret;
-
-	if (!trans || !payload) {
-		pr_err("%s: rtd or payload is NULL\n", __func__);
-		return;
-	}
-
-	cstream = trans->source.cstream;
-	ac = trans->audio_client;
-
-	/*
-	 * Token for rest of the compressed commands use to set
-	 * session id, stream id, dir etc.
-	 */
-	stream_id = q6asm_get_stream_id_from_token(token);
-
-	switch (opcode) {
-	case ASM_STREAM_CMD_ENCDEC_EVENTS:
-	case ASM_IEC_61937_MEDIA_FMT_EVENT:
-		pr_debug("%s: ASM_IEC_61937_MEDIA_FMT_EVENT\n", __func__);
-		rtd = cstream->private_data;
-		if (!rtd) {
-			pr_err("%s: rtd is NULL\n", __func__);
-			return;
-		}
-
-		ret = msm_adsp_inform_mixer_ctl(rtd, payload);
-		if (ret) {
-			pr_err("%s: failed to inform mixer ctrl. err = %d\n",
-				__func__, ret);
-			return;
-		}
-		break;
-	case APR_BASIC_RSP_RESULT: {
-		switch (payload[0]) {
-		case ASM_SESSION_CMD_RUN_V2:
-			pr_debug("%s: ASM_SESSION_CMD_RUN_V2:", __func__);
-			pr_debug("token 0x%x, stream id %d\n", token,
-				  stream_id);
-			break;
-		case ASM_STREAM_CMD_CLOSE:
-			pr_debug("%s: ASM_DATA_CMD_CLOSE:", __func__);
-			pr_debug("token 0x%x, stream id %d\n", token,
-				  stream_id);
-			break;
-		default:
-			break;
-		}
-		break;
-	}
-	default:
-		pr_debug("%s: Not Supported Event opcode[0x%x]\n",
-			  __func__, opcode);
-		break;
-	}
-}
-
-static void populate_codec_list(struct msm_transcode_loopback *trans,
-				struct snd_compr_stream *cstream)
-{
-	struct snd_compr_caps compr_cap;
-
-	pr_debug("%s\n", __func__);
-
-	memset(&compr_cap, 0, sizeof(struct snd_compr_caps));
-
-	if (cstream->direction == SND_COMPRESS_CAPTURE) {
-		compr_cap.direction = SND_COMPRESS_CAPTURE;
-		compr_cap.num_codecs = 3;
-		compr_cap.codecs[0] = SND_AUDIOCODEC_PCM;
-		compr_cap.codecs[1] = SND_AUDIOCODEC_AC3;
-		compr_cap.codecs[2] = SND_AUDIOCODEC_EAC3;
-		memcpy(&trans->source_compr_cap, &compr_cap,
-				sizeof(struct snd_compr_caps));
-	}
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-		compr_cap.direction = SND_COMPRESS_PLAYBACK;
-		compr_cap.num_codecs = 1;
-		compr_cap.codecs[0] = SND_AUDIOCODEC_PCM;
-		memcpy(&trans->sink_compr_cap, &compr_cap,
-				sizeof(struct snd_compr_caps));
-	}
-}
-
-static int msm_transcode_loopback_open(struct snd_compr_stream *cstream)
-{
-	int ret = 0;
-	struct snd_compr_runtime *runtime;
-	struct snd_soc_pcm_runtime *rtd;
-	struct msm_transcode_loopback *trans = &transcode_info;
-	struct trans_loopback_pdata *pdata;
-
-	if (cstream == NULL) {
-		pr_err("%s: Invalid substream\n", __func__);
-		return -EINVAL;
-	}
-	runtime = cstream->runtime;
-	rtd = snd_pcm_substream_chip(cstream);
-	pdata = snd_soc_platform_get_drvdata(rtd->platform);
-	pdata->cstream[rtd->dai_link->id] = cstream;
-
-	mutex_lock(&trans->lock);
-	if (trans->num_streams > LOOPBACK_SESSION_MAX_NUM_STREAMS) {
-		pr_err("msm_transcode_open failed..invalid stream\n");
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	if (cstream->direction == SND_COMPRESS_CAPTURE) {
-		if (trans->source.cstream == NULL) {
-			trans->source.cstream = cstream;
-			trans->num_streams++;
-		} else {
-			pr_err("%s: capture stream already opened\n",
-				__func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-	} else if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-		if (trans->sink.cstream == NULL) {
-			trans->sink.cstream = cstream;
-			trans->num_streams++;
-		} else {
-			pr_debug("%s: playback stream already opened\n",
-				__func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-	}
-
-	pr_debug("%s: num stream%d, stream name %s\n", __func__,
-		 trans->num_streams, cstream->name);
-
-	populate_codec_list(trans, cstream);
-
-	if (trans->num_streams == LOOPBACK_SESSION_MAX_NUM_STREAMS)	{
-		pr_debug("%s: Moving loopback session to READY state %d\n",
-			 __func__, trans->session_state);
-		trans->session_state = LOOPBACK_SESSION_READY;
-	}
-
-	runtime->private_data = trans;
-	if (trans->num_streams == 1)
-		msm_adsp_init_mixer_ctl_pp_event_queue(rtd);
-exit:
-	mutex_unlock(&trans->lock);
-	return ret;
-}
-
-static void stop_transcoding(struct msm_transcode_loopback *trans)
-{
-	struct snd_soc_pcm_runtime *soc_pcm_rx;
-	struct snd_soc_pcm_runtime *soc_pcm_tx;
-
-	if (trans->audio_client != NULL) {
-		q6asm_cmd(trans->audio_client, CMD_CLOSE);
-
-		if (trans->sink.cstream != NULL) {
-			soc_pcm_rx = trans->sink.cstream->private_data;
-			msm_pcm_routing_dereg_phy_stream(
-					soc_pcm_rx->dai_link->id,
-					SND_COMPRESS_PLAYBACK);
-		}
-		if (trans->source.cstream != NULL) {
-			soc_pcm_tx = trans->source.cstream->private_data;
-			msm_pcm_routing_dereg_phy_stream(
-					soc_pcm_tx->dai_link->id,
-					SND_COMPRESS_CAPTURE);
-		}
-		q6asm_audio_client_free(trans->audio_client);
-		trans->audio_client = NULL;
-	}
-}
-
-static int msm_transcode_loopback_free(struct snd_compr_stream *cstream)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_transcode_loopback *trans = runtime->private_data;
-	struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(cstream);
-	int ret = 0;
-
-	mutex_lock(&trans->lock);
-
-	pr_debug("%s: Transcode loopback end:%d, streams %d\n", __func__,
-		  cstream->direction, trans->num_streams);
-	trans->num_streams--;
-	stop_transcoding(trans);
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK)
-		memset(&trans->sink, 0, sizeof(struct loopback_stream));
-	else if (cstream->direction == SND_COMPRESS_CAPTURE)
-		memset(&trans->source, 0, sizeof(struct loopback_stream));
-
-	trans->session_state = LOOPBACK_SESSION_CLOSE;
-	if (trans->num_streams == 1)
-		msm_adsp_clean_mixer_ctl_pp_event_queue(rtd);
-	mutex_unlock(&trans->lock);
-	return ret;
-}
-
-static int msm_transcode_loopback_trigger(struct snd_compr_stream *cstream,
-					  int cmd)
-{
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_transcode_loopback *trans = runtime->private_data;
-
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-
-		if (trans->session_state == LOOPBACK_SESSION_START) {
-			pr_debug("%s: Issue Loopback session %d RUN\n",
-				  __func__, trans->instance);
-			q6asm_run_nowait(trans->audio_client, 0, 0, 0);
-			trans->session_state = LOOPBACK_SESSION_RUN;
-		}
-		break;
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-	case SNDRV_PCM_TRIGGER_STOP:
-		pr_debug("%s: Issue Loopback session %d STOP\n", __func__,
-			  trans->instance);
-		if (trans->session_state == LOOPBACK_SESSION_RUN)
-			q6asm_cmd_nowait(trans->audio_client, CMD_PAUSE);
-		trans->session_state = LOOPBACK_SESSION_START;
-		break;
-
-	default:
-		break;
-	}
-	return 0;
-}
-
-static int msm_transcode_loopback_set_params(struct snd_compr_stream *cstream,
-				struct snd_compr_params *codec_param)
-{
-
-	struct snd_compr_runtime *runtime = cstream->runtime;
-	struct msm_transcode_loopback *trans = runtime->private_data;
-	struct snd_soc_pcm_runtime *soc_pcm_rx;
-	struct snd_soc_pcm_runtime *soc_pcm_tx;
-	uint32_t bit_width = 16;
-	int ret = 0;
-
-	if (trans == NULL) {
-		pr_err("%s: Invalid param\n", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&trans->lock);
-
-	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-		if (codec_param->codec.id == SND_AUDIOCODEC_PCM) {
-			trans->sink.codec_format =
-				FORMAT_LINEAR_PCM;
-			switch (codec_param->codec.format) {
-			case SNDRV_PCM_FORMAT_S32_LE:
-				bit_width = 32;
-				break;
-			case SNDRV_PCM_FORMAT_S24_LE:
-				bit_width = 24;
-				break;
-			case SNDRV_PCM_FORMAT_S24_3LE:
-				bit_width = 24;
-				break;
-			case SNDRV_PCM_FORMAT_S16_LE:
-			default:
-				bit_width = 16;
-				break;
-			}
-		} else {
-			pr_debug("%s: unknown sink codec\n", __func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-		trans->sink.start = true;
-	}
-
-	if (cstream->direction == SND_COMPRESS_CAPTURE) {
-		switch (codec_param->codec.id) {
-		case SND_AUDIOCODEC_PCM:
-			pr_debug("Source SND_AUDIOCODEC_PCM\n");
-			trans->source.codec_format =
-				FORMAT_LINEAR_PCM;
-			break;
-		case SND_AUDIOCODEC_AC3:
-			pr_debug("Source SND_AUDIOCODEC_AC3\n");
-			trans->source.codec_format =
-				FORMAT_AC3;
-			break;
-		case SND_AUDIOCODEC_EAC3:
-			pr_debug("Source SND_AUDIOCODEC_EAC3\n");
-			trans->source.codec_format =
-				FORMAT_EAC3;
-			break;
-		default:
-			pr_debug("%s: unknown source codec\n", __func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-		trans->source.start = true;
-	}
-
-	pr_debug("%s: trans->source.start %d trans->sink.start %d trans->source.cstream %pK trans->sink.cstream %pK trans->session_state %d\n",
-			__func__, trans->source.start, trans->sink.start,
-			trans->source.cstream, trans->sink.cstream,
-			trans->session_state);
-
-	if ((trans->session_state == LOOPBACK_SESSION_READY) &&
-			trans->source.start && trans->sink.start) {
-		pr_debug("%s: Moving loopback session to start state\n",
-			  __func__);
-		trans->session_state = LOOPBACK_SESSION_START;
-	}
-
-	if (trans->session_state == LOOPBACK_SESSION_START) {
-		if (trans->audio_client != NULL) {
-			pr_debug("%s: ASM client already opened, closing\n",
-				 __func__);
-			stop_transcoding(trans);
-		}
-
-		trans->audio_client = q6asm_audio_client_alloc(
-				(app_cb)loopback_event_handler, trans);
-		if (!trans->audio_client) {
-			pr_err("%s: Could not allocate memory\n", __func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-		pr_debug("%s: ASM client allocated, callback %pK\n", __func__,
-						loopback_event_handler);
-		trans->session_id = trans->audio_client->session;
-		trans->audio_client->perf_mode = false;
-		ret = q6asm_open_transcode_loopback(trans->audio_client,
-					bit_width,
-					trans->source.codec_format,
-					trans->sink.codec_format);
-		if (ret < 0) {
-			pr_err("%s: Session transcode loopback open failed\n",
-				__func__);
-			q6asm_audio_client_free(trans->audio_client);
-			trans->audio_client = NULL;
-			goto exit;
-		}
-
-		pr_debug("%s: Starting ADM open for loopback\n", __func__);
-		soc_pcm_rx = trans->sink.cstream->private_data;
-		soc_pcm_tx = trans->source.cstream->private_data;
-		if (trans->source.codec_format != FORMAT_LINEAR_PCM)
-			msm_pcm_routing_reg_phy_compr_stream(
-					soc_pcm_tx->dai_link->id,
-					trans->audio_client->perf_mode,
-					trans->session_id,
-					SNDRV_PCM_STREAM_CAPTURE,
-					true);
-		else
-			msm_pcm_routing_reg_phy_stream(
-					soc_pcm_tx->dai_link->id,
-					trans->audio_client->perf_mode,
-					trans->session_id,
-					SNDRV_PCM_STREAM_CAPTURE);
-
-		msm_pcm_routing_reg_phy_stream(
-					soc_pcm_rx->dai_link->id,
-					trans->audio_client->perf_mode,
-					trans->session_id,
-					SNDRV_PCM_STREAM_PLAYBACK);
-		pr_debug("%s: Successfully opened ADM sessions\n", __func__);
-	}
-exit:
-	mutex_unlock(&trans->lock);
-	return ret;
-}
-
-static int msm_transcode_loopback_get_caps(struct snd_compr_stream *cstream,
-				struct snd_compr_caps *arg)
-{
-	struct snd_compr_runtime *runtime;
-	struct msm_transcode_loopback *trans;
-
-	if (!arg || !cstream) {
-		pr_err("%s: Invalid arguments\n", __func__);
-		return -EINVAL;
-	}
-
-	runtime = cstream->runtime;
-	trans = runtime->private_data;
-	pr_debug("%s\n", __func__);
-	if (cstream->direction == SND_COMPRESS_CAPTURE)
-		memcpy(arg, &trans->source_compr_cap,
-		       sizeof(struct snd_compr_caps));
-	else
-		memcpy(arg, &trans->sink_compr_cap,
-		       sizeof(struct snd_compr_caps));
-	return 0;
-}
-
-static int msm_transcode_stream_cmd_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct trans_loopback_pdata *pdata = (struct trans_loopback_pdata *)
-				snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_transcode_loopback *prtd;
-	int ret = 0;
-	struct msm_adsp_event_data *event_data = NULL;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data;
-	if ((event_data->event_type < ADSP_STREAM_PP_EVENT) ||
-	    (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) {
-		pr_err("%s: invalid event_type=%d",
-			 __func__, event_data->event_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
-					sizeof(ucontrol->value.bytes.data)) {
-		pr_err("%s param length=%d  exceeds limit",
-			 __func__, event_data->payload_len);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = q6asm_send_stream_cmd(prtd->audio_client, event_data);
-	if (ret < 0)
-		pr_err("%s: failed to send stream event cmd, err = %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-static int msm_transcode_ion_fd_map_put(struct snd_kcontrol *kcontrol,
-				    struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct trans_loopback_pdata *pdata = (struct trans_loopback_pdata *)
-				snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_transcode_loopback *prtd;
-	int fd;
-	int ret = 0;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received out of bounds invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(&fd, ucontrol->value.bytes.data, sizeof(fd));
-	ret = q6asm_send_ion_fd(prtd->audio_client, fd);
-	if (ret < 0)
-		pr_err("%s: failed to register ion fd\n", __func__);
-done:
-	return ret;
-}
-
-static int msm_transcode_rtic_event_ack_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
-	unsigned long fe_id = kcontrol->private_value;
-	struct trans_loopback_pdata *pdata = (struct trans_loopback_pdata *)
-					snd_soc_component_get_drvdata(comp);
-	struct snd_compr_stream *cstream = NULL;
-	struct msm_transcode_loopback *prtd;
-	int ret = 0;
-	int param_length = 0;
-
-	if (fe_id >= MSM_FRONTEND_DAI_MAX) {
-		pr_err("%s Received invalid fe_id %lu\n",
-			__func__, fe_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cstream = pdata->cstream[fe_id];
-	if (cstream == NULL) {
-		pr_err("%s cstream is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	prtd = cstream->runtime->private_data;
-	if (!prtd) {
-		pr_err("%s: prtd is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (prtd->audio_client == NULL) {
-		pr_err("%s: audio_client is null\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memcpy(&param_length, ucontrol->value.bytes.data,
-		sizeof(param_length));
-	if ((param_length + sizeof(param_length))
-		>= sizeof(ucontrol->value.bytes.data)) {
-		pr_err("%s param length=%d  exceeds limit",
-			__func__, param_length);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = q6asm_send_rtic_event_ack(prtd->audio_client,
-			ucontrol->value.bytes.data + sizeof(param_length),
-			param_length);
-	if (ret < 0)
-		pr_err("%s: failed to send rtic event ack, err = %d\n",
-			__func__, ret);
-done:
-	return ret;
-}
-
-static int msm_transcode_stream_cmd_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CMD;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_loopback_stream_cmd_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_transcode_stream_cmd_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_loopback_stream_cmd_config_control[0].name = mixer_str;
-	fe_loopback_stream_cmd_config_control[0].private_value =
-				rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-		fe_loopback_stream_cmd_config_control,
-		ARRAY_SIZE(fe_loopback_stream_cmd_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_transcode_stream_callback_control(
-			struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol *kctl;
-
-	struct snd_kcontrol_new fe_loopback_callback_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_callback_info,
-		.get = msm_adsp_stream_callback_get,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s: rtd is  NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_loopback_callback_config_control[0].name = mixer_str;
-	fe_loopback_callback_config_control[0].private_value =
-					rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-			fe_loopback_callback_config_control,
-			ARRAY_SIZE(fe_loopback_callback_config_control));
-	if (ret < 0) {
-		pr_err("%s: failed to add ctl %s. err = %d\n",
-			__func__, mixer_str, ret);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
-	if (!kctl) {
-		pr_err("%s: failed to get kctl %s.\n", __func__, mixer_str);
-		ret = -EINVAL;
-		goto free_mixer_str;
-	}
-
-	kctl->private_data = NULL;
-free_mixer_str:
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_transcode_add_ion_fd_cmd_control(struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback ION FD";
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_ion_fd_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_transcode_ion_fd_map_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_ion_fd_config_control[0].name = mixer_str;
-	fe_ion_fd_config_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-				fe_ion_fd_config_control,
-				ARRAY_SIZE(fe_ion_fd_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s\n", __func__, mixer_str);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_transcode_add_event_ack_cmd_control(
-					struct snd_soc_pcm_runtime *rtd)
-{
-	const char *mixer_ctl_name = "Playback Event Ack";
-	const char *deviceNo = "NN";
-	char *mixer_str = NULL;
-	int ctl_len = 0, ret = 0;
-	struct snd_kcontrol_new fe_event_ack_config_control[1] = {
-		{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "?",
-		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = msm_adsp_stream_cmd_info,
-		.put = msm_transcode_rtic_event_ack_put,
-		.private_value = 0,
-		}
-	};
-
-	if (!rtd) {
-		pr_err("%s NULL rtd\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
-	mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-	if (!mixer_str) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name, rtd->pcm->device);
-	fe_event_ack_config_control[0].name = mixer_str;
-	fe_event_ack_config_control[0].private_value = rtd->dai_link->id;
-	pr_debug("%s: Registering new mixer ctl %s\n", __func__, mixer_str);
-	ret = snd_soc_add_platform_controls(rtd->platform,
-				fe_event_ack_config_control,
-				ARRAY_SIZE(fe_event_ack_config_control));
-	if (ret < 0)
-		pr_err("%s: failed to add ctl %s\n", __func__, mixer_str);
-
-	kfree(mixer_str);
-done:
-	return ret;
-}
-
-static int msm_transcode_loopback_new(struct snd_soc_pcm_runtime *rtd)
-{
-	int rc;
-
-	rc = msm_transcode_stream_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: ADSP Stream Cmd Control open failed\n", __func__);
-
-	rc = msm_transcode_stream_callback_control(rtd);
-	if (rc)
-		pr_err("%s: ADSP Stream callback Control open failed\n",
-			__func__);
-
-	rc = msm_transcode_add_ion_fd_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add transcode ion fd Control\n",
-			__func__);
-
-	rc = msm_transcode_add_event_ack_cmd_control(rtd);
-	if (rc)
-		pr_err("%s: Could not add transcode event ack Control\n",
-			__func__);
-
-	return 0;
-}
-
-static struct snd_compr_ops msm_transcode_loopback_ops = {
-	.open			= msm_transcode_loopback_open,
-	.free			= msm_transcode_loopback_free,
-	.trigger		= msm_transcode_loopback_trigger,
-	.set_params		= msm_transcode_loopback_set_params,
-	.get_caps		= msm_transcode_loopback_get_caps,
-};
-
-
-static int msm_transcode_loopback_probe(struct snd_soc_platform *platform)
-{
-	struct trans_loopback_pdata *pdata = NULL;
-
-	pr_debug("%s\n", __func__);
-	pdata = (struct trans_loopback_pdata *)
-			kzalloc(sizeof(struct trans_loopback_pdata),
-			GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	snd_soc_platform_set_drvdata(platform, pdata);
-	return 0;
-}
-
-static struct snd_soc_platform_driver msm_soc_platform = {
-	.probe		= msm_transcode_loopback_probe,
-	.compr_ops	= &msm_transcode_loopback_ops,
-	.pcm_new	= msm_transcode_loopback_new,
-};
-
-static int msm_transcode_dev_probe(struct platform_device *pdev)
-{
-
-	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
-	if (pdev->dev.of_node)
-		dev_set_name(&pdev->dev, "%s", "msm-transcode-loopback");
-
-	return snd_soc_register_platform(&pdev->dev,
-					&msm_soc_platform);
-}
-
-static int msm_transcode_remove(struct platform_device *pdev)
-{
-	snd_soc_unregister_platform(&pdev->dev);
-	return 0;
-}
-
-static const struct of_device_id msm_transcode_loopback_dt_match[] = {
-	{.compatible = "qcom,msm-transcode-loopback"},
-	{}
-};
-MODULE_DEVICE_TABLE(of, msm_transcode_loopback_dt_match);
-
-static struct platform_driver msm_transcode_loopback_driver = {
-	.driver = {
-		.name = "msm-transcode-loopback",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_transcode_loopback_dt_match,
-	},
-	.probe = msm_transcode_dev_probe,
-	.remove = msm_transcode_remove,
-};
-
-static int __init msm_soc_platform_init(void)
-{
-	memset(&transcode_info, 0, sizeof(struct msm_transcode_loopback));
-	mutex_init(&transcode_info.lock);
-	return platform_driver_register(&msm_transcode_loopback_driver);
-}
-module_init(msm_soc_platform_init);
-
-static void __exit msm_soc_platform_exit(void)
-{
-	mutex_destroy(&transcode_info.lock);
-	platform_driver_unregister(&msm_transcode_loopback_driver);
-}
-module_exit(msm_soc_platform_exit);
-
-MODULE_DESCRIPTION("Transcode loopback platform driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/q6adm.c b/sound/soc/msm/qdsp6v2/q6adm.c
deleted file mode 100644
index fc0917f..0000000
--- a/sound/soc/msm/qdsp6v2/q6adm.c
+++ /dev/null
@@ -1,4870 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/jiffies.h>
-#include <linux/uaccess.h>
-#include <linux/atomic.h>
-#include <linux/wait.h>
-#include <linux/qdsp6v2/apr.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/q6adm-v2.h>
-#include <sound/q6audio-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/audio_cal_utils.h>
-#include <sound/asound.h>
-#include "msm-dts-srs-tm-config.h"
-#include <sound/adsp_err.h>
-
-#define TIMEOUT_MS 1000
-
-#define RESET_COPP_ID 99
-#define INVALID_COPP_ID 0xFF
-/* Used for inband payload copy, max size is 4k */
-/* 2 is to account for module & param ID in payload */
-#define ADM_GET_PARAMETER_LENGTH  (4096 - APR_HDR_SIZE - 2 * sizeof(uint32_t))
-
-#define ULL_SUPPORTED_BITS_PER_SAMPLE 16
-#define ULL_SUPPORTED_SAMPLE_RATE 48000
-
-#ifndef CONFIG_DOLBY_DAP
-#undef DOLBY_ADM_COPP_TOPOLOGY_ID
-#define DOLBY_ADM_COPP_TOPOLOGY_ID 0xFFFFFFFE
-#endif
-
-#ifndef CONFIG_DOLBY_DS2
-#undef DS2_ADM_COPP_TOPOLOGY_ID
-#define DS2_ADM_COPP_TOPOLOGY_ID 0xFFFFFFFF
-#endif
-
-/* ENUM for adm_status */
-enum adm_cal_status {
-	ADM_STATUS_CALIBRATION_REQUIRED = 0,
-	ADM_STATUS_MAX,
-};
-
-struct adm_copp {
-
-	atomic_t id[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t cnt[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t topology[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t mode[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t stat[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t rate[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t bit_width[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t channels[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t app_type[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t acdb_id[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	wait_queue_head_t wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	wait_queue_head_t adm_delay_wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	atomic_t adm_delay_stat[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	uint32_t adm_delay[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-	unsigned long adm_status[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
-};
-
-struct source_tracking_data {
-	struct ion_client *ion_client;
-	struct ion_handle *ion_handle;
-	struct param_outband memmap;
-	int apr_cmd_status;
-};
-
-struct adm_ctl {
-	void *apr;
-
-	struct adm_copp copp;
-
-	atomic_t matrix_map_stat;
-	wait_queue_head_t matrix_map_wait;
-
-	atomic_t adm_stat;
-	wait_queue_head_t adm_wait;
-
-	struct cal_type_data *cal_data[ADM_MAX_CAL_TYPES];
-
-	atomic_t mem_map_handles[ADM_MEM_MAP_INDEX_MAX];
-	atomic_t mem_map_index;
-
-	struct param_outband outband_memmap;
-	struct source_tracking_data sourceTrackingData;
-
-	int set_custom_topology;
-	int ec_ref_rx;
-	int num_ec_ref_rx_chans;
-	int ec_ref_rx_bit_width;
-	int ec_ref_rx_sampling_rate;
-};
-
-static struct adm_ctl			this_adm;
-
-struct adm_multi_ch_map {
-	bool set_channel_map;
-	char channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL];
-};
-
-#define ADM_MCH_MAP_IDX_PLAYBACK 0
-#define ADM_MCH_MAP_IDX_REC 1
-static struct adm_multi_ch_map multi_ch_maps[2] = {
-							{ false,
-							{0, 0, 0, 0, 0, 0, 0, 0}
-							},
-							{ false,
-							{0, 0, 0, 0, 0, 0, 0, 0}
-							}
-};
-
-static int adm_get_parameters[MAX_COPPS_PER_PORT * ADM_GET_PARAMETER_LENGTH];
-static int adm_module_topo_list[
-	MAX_COPPS_PER_PORT * ADM_GET_TOPO_MODULE_LIST_LENGTH];
-
-int adm_validate_and_get_port_index(int port_id)
-{
-	int index;
-	int ret;
-
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port validation failed id 0x%x ret %d\n",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	index = afe_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid port idx %d port_id 0x%x\n",
-			__func__, index,
-			port_id);
-		return -EINVAL;
-	}
-	pr_debug("%s: port_idx- %d\n", __func__, index);
-	return index;
-}
-
-int adm_get_default_copp_idx(int port_id)
-{
-	int port_idx = adm_validate_and_get_port_index(port_id), idx;
-
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port id: 0x%x", __func__, port_id);
-		return -EINVAL;
-	}
-	pr_debug("%s: port_idx:%d\n", __func__, port_idx);
-	for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-		if (atomic_read(&this_adm.copp.id[port_idx][idx]) !=
-			RESET_COPP_ID)
-			return idx;
-	}
-	return -EINVAL;
-}
-
-int adm_get_topology_for_port_from_copp_id(int port_id, int copp_id)
-{
-	int port_idx = adm_validate_and_get_port_index(port_id), idx;
-
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port id: 0x%x", __func__, port_id);
-		return 0;
-	}
-	for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
-		if (atomic_read(&this_adm.copp.id[port_idx][idx]) == copp_id)
-			return atomic_read(&this_adm.copp.topology[port_idx]
-								  [idx]);
-	pr_err("%s: Invalid copp_id %d port_id 0x%x\n",
-		__func__, copp_id, port_id);
-	return 0;
-}
-
-int adm_get_topology_for_port_copp_idx(int port_id, int copp_idx)
-{
-	int port_idx = adm_validate_and_get_port_index(port_id);
-
-	if (port_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid port: 0x%x copp id: 0x%x",
-				__func__, port_id, copp_idx);
-		return 0;
-	}
-	return atomic_read(&this_adm.copp.topology[port_idx][copp_idx]);
-}
-
-int adm_get_indexes_from_copp_id(int copp_id, int *copp_idx, int *port_idx)
-{
-	int p_idx, c_idx;
-
-	for (p_idx = 0; p_idx < AFE_MAX_PORTS; p_idx++) {
-		for (c_idx = 0; c_idx < MAX_COPPS_PER_PORT; c_idx++) {
-			if (atomic_read(&this_adm.copp.id[p_idx][c_idx])
-								== copp_id) {
-				if (copp_idx != NULL)
-					*copp_idx = c_idx;
-				if (port_idx != NULL)
-					*port_idx = p_idx;
-				return 0;
-			}
-		}
-	}
-	return -EINVAL;
-}
-
-static int adm_get_copp_id(int port_idx, int copp_idx)
-{
-	pr_debug("%s: port_idx:%d copp_idx:%d\n", __func__, port_idx, copp_idx);
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-	return atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-}
-
-static int adm_get_idx_if_copp_exists(int port_idx, int topology, int mode,
-				 int rate, int bit_width, int app_type)
-{
-	int idx;
-
-	pr_debug("%s: port_idx-%d, topology-0x%x, mode-%d, rate-%d, bit_width-%d\n",
-		 __func__, port_idx, topology, mode, rate, bit_width);
-
-	for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
-		if ((topology ==
-			atomic_read(&this_adm.copp.topology[port_idx][idx])) &&
-		    (mode == atomic_read(&this_adm.copp.mode[port_idx][idx])) &&
-		    (rate == atomic_read(&this_adm.copp.rate[port_idx][idx])) &&
-		    (bit_width ==
-			atomic_read(&this_adm.copp.bit_width[port_idx][idx])) &&
-		    (app_type ==
-			atomic_read(&this_adm.copp.app_type[port_idx][idx])))
-			return idx;
-	return -EINVAL;
-}
-
-static int adm_get_next_available_copp(int port_idx)
-{
-	int idx;
-
-	pr_debug("%s:\n", __func__);
-	for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) {
-		pr_debug("%s: copp_id:0x%x port_idx:%d idx:%d\n", __func__,
-			 atomic_read(&this_adm.copp.id[port_idx][idx]),
-			 port_idx, idx);
-		if (atomic_read(&this_adm.copp.id[port_idx][idx]) ==
-								RESET_COPP_ID)
-			break;
-	}
-	return idx;
-}
-
-int srs_trumedia_open(int port_id, int copp_idx, __s32 srs_tech_id,
-		      void *srs_params)
-{
-	struct adm_cmd_set_pp_params_inband_v5 *adm_params = NULL;
-	struct adm_cmd_set_pp_params_v5 *adm_params_ = NULL;
-	__s32 sz = 0, param_id, module_id = SRS_TRUMEDIA_MODULE_ID, outband = 0;
-	int ret = 0, port_idx;
-
-	pr_debug("SRS - %s", __func__);
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		return -EINVAL;
-	}
-	switch (srs_tech_id) {
-	case SRS_ID_GLOBAL: {
-		struct srs_trumedia_params_GLOBAL *glb_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_GLOBAL);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_GLOBAL) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS;
-		adm_params->params.param_size =
-				sizeof(struct srs_trumedia_params_GLOBAL);
-		glb_params = (struct srs_trumedia_params_GLOBAL *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(glb_params, srs_params,
-			sizeof(struct srs_trumedia_params_GLOBAL));
-		break;
-	}
-	case SRS_ID_WOWHD: {
-		struct srs_trumedia_params_WOWHD *whd_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_WOWHD);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_WOWHD) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS_WOWHD;
-		adm_params->params.param_size =
-				sizeof(struct srs_trumedia_params_WOWHD);
-		whd_params = (struct srs_trumedia_params_WOWHD *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(whd_params, srs_params,
-				sizeof(struct srs_trumedia_params_WOWHD));
-		break;
-	}
-	case SRS_ID_CSHP: {
-		struct srs_trumedia_params_CSHP *chp_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_CSHP);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_CSHP) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS_CSHP;
-		adm_params->params.param_size =
-				sizeof(struct srs_trumedia_params_CSHP);
-		chp_params = (struct srs_trumedia_params_CSHP *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(chp_params, srs_params,
-				sizeof(struct srs_trumedia_params_CSHP));
-		break;
-	}
-	case SRS_ID_HPF: {
-		struct srs_trumedia_params_HPF *hpf_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_HPF);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_HPF) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS_HPF;
-		adm_params->params.param_size =
-				sizeof(struct srs_trumedia_params_HPF);
-		hpf_params = (struct srs_trumedia_params_HPF *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(hpf_params, srs_params,
-			sizeof(struct srs_trumedia_params_HPF));
-		break;
-	}
-	case SRS_ID_AEQ: {
-		int *update_params_ptr = (int *)this_adm.outband_memmap.kvaddr;
-
-		outband = 1;
-		adm_params = kzalloc(sizeof(struct adm_cmd_set_pp_params_v5),
-				     GFP_KERNEL);
-		adm_params_ = (struct adm_cmd_set_pp_params_v5 *)adm_params;
-		if (!adm_params_) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-
-		sz = sizeof(struct srs_trumedia_params_AEQ);
-		if (update_params_ptr == NULL) {
-			pr_err("ADM_SRS_TRUMEDIA - %s: null memmap for AEQ params\n",
-				__func__);
-			ret = -EINVAL;
-			goto fail_cmd;
-		}
-		param_id = SRS_TRUMEDIA_PARAMS_AEQ;
-		*update_params_ptr++ = module_id;
-		*update_params_ptr++ = param_id;
-		*update_params_ptr++ = sz;
-		memcpy(update_params_ptr, srs_params, sz);
-
-		adm_params_->payload_size = sz + 12;
-
-		break;
-	}
-	case SRS_ID_HL: {
-		struct srs_trumedia_params_HL *hl_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_HL);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_HL) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS_HL;
-		adm_params->params.param_size =
-			sizeof(struct srs_trumedia_params_HL);
-		hl_params = (struct srs_trumedia_params_HL *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(hl_params, srs_params,
-				sizeof(struct srs_trumedia_params_HL));
-		break;
-	}
-	case SRS_ID_GEQ: {
-		struct srs_trumedia_params_GEQ *geq_params = NULL;
-
-		sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
-			sizeof(struct srs_trumedia_params_GEQ);
-		adm_params = kzalloc(sz, GFP_KERNEL);
-		if (!adm_params) {
-			pr_err("%s, adm params memory alloc failed\n",
-				__func__);
-			return -ENOMEM;
-		}
-		adm_params->payload_size =
-			sizeof(struct srs_trumedia_params_GEQ) +
-			sizeof(struct adm_param_data_v5);
-		param_id = SRS_TRUMEDIA_PARAMS_GEQ;
-		adm_params->params.param_size =
-			sizeof(struct srs_trumedia_params_GEQ);
-		geq_params = (struct srs_trumedia_params_GEQ *)
-			((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pp_params_inband_v5));
-		memcpy(geq_params, srs_params,
-			sizeof(struct srs_trumedia_params_GEQ));
-		pr_debug("SRS - %s: GEQ params prepared\n", __func__);
-		break;
-	}
-	default:
-		goto fail_cmd;
-	}
-
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	if (outband && this_adm.outband_memmap.paddr) {
-		adm_params->hdr.pkt_size =
-					sizeof(struct adm_cmd_set_pp_params_v5);
-		adm_params->payload_addr_lsw = lower_32_bits(
-						this_adm.outband_memmap.paddr);
-		adm_params->payload_addr_msw = msm_audio_populate_upper_32_bits(
-						this_adm.outband_memmap.paddr);
-		adm_params->mem_map_handle = atomic_read(&this_adm.
-					mem_map_handles[ADM_SRS_TRUMEDIA]);
-	} else {
-		adm_params->hdr.pkt_size = sz;
-		adm_params->payload_addr_lsw = 0;
-		adm_params->payload_addr_msw = 0;
-		adm_params->mem_map_handle = 0;
-
-		adm_params->params.module_id = module_id;
-		adm_params->params.param_id = param_id;
-		adm_params->params.reserved = 0;
-	}
-
-	pr_debug("SRS - %s: Command was sent now check Q6 - port id = %d, size %d, module id %x, param id %x.\n",
-			__func__, adm_params->hdr.dest_port,
-			adm_params->payload_size, module_id, param_id);
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (ret < 0) {
-		pr_err("SRS - %s: ADM enable for port %d failed\n", __func__,
-			port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback with copp id */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-			atomic_read(&this_adm.copp.stat
-			[port_idx][copp_idx]) >= 0,
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: SRS set params timed out port = %d\n",
-			__func__, port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	kfree(adm_params);
-	return ret;
-}
-
-static int adm_populate_channel_weight(u16 *ptr,
-					struct msm_pcm_channel_mixer *ch_mixer,
-					int channel_index)
-{
-	u16 i, j, start_index = 0;
-
-	if (channel_index > ch_mixer->output_channel) {
-		pr_err("%s: channel index %d is larger than output_channel %d\n",
-			 __func__, channel_index, ch_mixer->output_channel);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < ch_mixer->output_channel; i++) {
-		pr_debug("%s: weight for output %d:", __func__, i);
-		for (j = 0; j < ADM_MAX_CHANNELS; j++)
-			pr_debug(" %d",
-				ch_mixer->channel_weight[i][j]);
-		pr_debug("\n");
-	}
-
-	for (i = 0; i < channel_index; ++i)
-		start_index += ch_mixer->input_channels[i];
-
-	for (i = 0; i < ch_mixer->output_channel; ++i) {
-		for (j = start_index;
-			j < start_index +
-			ch_mixer->input_channels[channel_index]; j++) {
-			*ptr = ch_mixer->channel_weight[i][j];
-			 pr_debug("%s: ptr[%d][%d] = %d\n",
-				__func__, i, j, *ptr);
-			 ptr++;
-		}
-	}
-
-	return 0;
-}
-
-/*
- * adm_programable_channel_mixer
- *
- * Receives port_id, copp_idx, session_id, session_type, ch_mixer
- * and channel_index to send ADM command to mix COPP data.
- *
- * port_id - Passed value, port_id for which backend is wanted
- * copp_idx - Passed value, copp_idx for which COPP is wanted
- * session_id - Passed value, session_id for which session is needed
- * session_type - Passed value, session_type for RX or TX
- * ch_mixer - Passed value, ch_mixer for which channel mixer config is needed
- * channel_index - Passed value, channel_index for which channel is needed
- */
-int adm_programable_channel_mixer(int port_id, int copp_idx, int session_id,
-				  int session_type,
-				  struct msm_pcm_channel_mixer *ch_mixer,
-				  int channel_index)
-{
-	struct adm_cmd_set_pspd_mtmx_strtr_params_v5 *adm_params = NULL;
-	struct adm_param_data_v5 data_v5;
-	int ret = 0, port_idx, sz = 0, param_size = 0;
-	u16 *adm_pspd_params;
-	u16 *ptr;
-	int index = 0;
-
-	pr_debug("%s: port_id = %d\n", __func__, port_id);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		return -EINVAL;
-	}
-	/*
-	 * First 8 bytes are 4 bytes as rule number, 2 bytes as output
-	 * channel and 2 bytes as input channel.
-	 * 2 * ch_mixer->output_channel means output channel mapping.
-	 * 2 * ch_mixer->input_channels[channel_index]) means input
-	 * channel mapping.
-	 * 2 * ch_mixer->input_channels[channel_index] *
-	 * ch_mixer->output_channel) means the channel mixer weighting
-	 * coefficients.
-	 * param_size needs to be a multiple of 4 bytes.
-	 */
-
-	param_size = 2 * (4 + ch_mixer->output_channel +
-			ch_mixer->input_channels[channel_index] +
-			ch_mixer->input_channels[channel_index] *
-			ch_mixer->output_channel);
-	roundup(param_size, 4);
-
-	sz = sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5) +
-			sizeof(struct default_chmixer_param_id_coeff) +
-			sizeof(struct adm_param_data_v5) + param_size;
-	pr_debug("%s: sz = %d\n", __func__, sz);
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params)
-		return -ENOMEM;
-
-	adm_params->payload_addr_lsw = 0;
-	adm_params->payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->direction = session_type;
-	adm_params->sessionid = session_id;
-	pr_debug("%s: copp_id = %d, session id  %d\n", __func__,
-		atomic_read(&this_adm.copp.id[port_idx][copp_idx]),
-			session_id);
-	adm_params->deviceid = atomic_read(
-				&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->reserved = 0;
-
-	data_v5.module_id = MTMX_MODULE_ID_DEFAULT_CHMIXER;
-	data_v5.param_id =  DEFAULT_CHMIXER_PARAM_ID_COEFF;
-	data_v5.reserved = 0;
-	data_v5.param_size = param_size;
-	adm_params->payload_size =
-			sizeof(struct default_chmixer_param_id_coeff) +
-			sizeof(struct adm_param_data_v5) + data_v5.param_size;
-	adm_pspd_params = (u16 *)((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5));
-	memcpy(adm_pspd_params, &data_v5, sizeof(data_v5));
-
-	adm_pspd_params = (u16 *)((u8 *)adm_params +
-			sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5)
-			+ sizeof(data_v5));
-
-	adm_pspd_params[0] = ch_mixer->rule;
-	adm_pspd_params[2] = ch_mixer->output_channel;
-	adm_pspd_params[3] = ch_mixer->input_channels[channel_index];
-	index = 4;
-
-	if (ch_mixer->output_channel == 1) {
-		adm_pspd_params[index] = PCM_CHANNEL_FC;
-	} else if (ch_mixer->output_channel == 2) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-	} else if (ch_mixer->output_channel == 3) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_FC;
-	} else if (ch_mixer->output_channel == 4) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->output_channel == 5) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->output_channel == 6) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LFE;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 5] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->output_channel == 8) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LFE;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 5] = PCM_CHANNEL_RS;
-		adm_pspd_params[index + 6] = PCM_CHANNEL_LB;
-		adm_pspd_params[index + 7] = PCM_CHANNEL_RB;
-	}
-
-	index = index + ch_mixer->output_channel;
-	if (ch_mixer->input_channels[channel_index] == 1) {
-		adm_pspd_params[index] = PCM_CHANNEL_FC;
-	} else if (ch_mixer->input_channels[channel_index] == 2) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-	} else if (ch_mixer->input_channels[channel_index] == 3) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_FC;
-	} else if (ch_mixer->input_channels[channel_index] == 4) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->input_channels[channel_index] == 5) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->input_channels[channel_index] == 6) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LFE;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 5] = PCM_CHANNEL_RS;
-	} else if (ch_mixer->input_channels[channel_index] == 8) {
-		adm_pspd_params[index] = PCM_CHANNEL_FL;
-		adm_pspd_params[index + 1] = PCM_CHANNEL_FR;
-		adm_pspd_params[index + 2] = PCM_CHANNEL_LFE;
-		adm_pspd_params[index + 3] = PCM_CHANNEL_FC;
-		adm_pspd_params[index + 4] = PCM_CHANNEL_LS;
-		adm_pspd_params[index + 5] = PCM_CHANNEL_RS;
-		adm_pspd_params[index + 6] = PCM_CHANNEL_LB;
-		adm_pspd_params[index + 7] = PCM_CHANNEL_RB;
-	}
-
-	index = index + ch_mixer->input_channels[channel_index];
-	ret = adm_populate_channel_weight(&adm_pspd_params[index],
-					ch_mixer, channel_index);
-	if (!ret) {
-		pr_err("%s: fail to get channel weight with error %d\n",
-			__func__, ret);
-		goto fail_cmd;
-	}
-
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PSPD_MTMX_STRTR_PARAMS_V5;
-	adm_params->hdr.pkt_size = sz;
-	adm_params->payload_addr_lsw = 0;
-	adm_params->payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->reserved = 0;
-
-	ptr = (u16 *)adm_params;
-	for (index = 0; index < (sz / 2); index++)
-		pr_debug("%s: adm_params[%d] = 0x%x\n",
-			__func__, index, (unsigned int)ptr[index]);
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], 0);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (ret < 0) {
-		pr_err("%s: Set params failed port %d rc %d\n", __func__,
-			port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-			atomic_read(
-			&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: set params timed out port = %d\n",
-			__func__, port_id);
-		ret = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	ret = 0;
-fail_cmd:
-	kfree(adm_params);
-
-	return ret;
-}
-
-int adm_set_stereo_to_custom_stereo(int port_id, int copp_idx,
-				    unsigned int session_id, char *params,
-				    uint32_t params_length)
-{
-	struct adm_cmd_set_pspd_mtmx_strtr_params_v5 *adm_params = NULL;
-	int sz, rc = 0, port_idx;
-
-	pr_debug("%s:\n", __func__);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5) +
-		params_length;
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params) {
-		pr_err("%s, adm params memory alloc failed\n", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(((u8 *)adm_params +
-		sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5)),
-		params, params_length);
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.pkt_size = sz;
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port = 0; /* Ignored */;
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PSPD_MTMX_STRTR_PARAMS_V5;
-	adm_params->payload_addr_lsw = 0;
-	adm_params->payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->payload_size = params_length;
-	/* direction RX as 0 */
-	adm_params->direction = ADM_MATRIX_ID_AUDIO_RX;
-	/* session id for this cmd to be applied on */
-	adm_params->sessionid = session_id;
-	adm_params->deviceid =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->reserved = 0;
-	pr_debug("%s: deviceid %d, session_id %d, src_port %d, dest_port %d\n",
-		__func__, adm_params->deviceid, adm_params->sessionid,
-		adm_params->hdr.src_port, adm_params->hdr.dest_port);
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = 0x%x rc %d\n",
-			__func__, port_id, rc);
-		rc = -EINVAL;
-		goto set_stereo_to_custom_stereo_return;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) >= 0,
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Set params timed out port = 0x%x\n", __func__,
-			port_id);
-		rc = -EINVAL;
-		goto set_stereo_to_custom_stereo_return;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n", __func__,
-			adsp_err_get_err_str(atomic_read(
-			&this_adm.copp.stat
-			[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto set_stereo_to_custom_stereo_return;
-	}
-	rc = 0;
-set_stereo_to_custom_stereo_return:
-	kfree(adm_params);
-	return rc;
-}
-
-int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,
-			      uint32_t params_length)
-{
-	struct adm_cmd_set_pp_params_v5	*adm_params = NULL;
-	int sz, rc = 0;
-	int port_idx;
-
-	pr_debug("%s:\n", __func__);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_cmd_set_pp_params_v5) + params_length;
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params) {
-		pr_err("%s, adm params memory alloc failed", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
-			params, params_length);
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.pkt_size = sz;
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	adm_params->payload_addr_lsw = 0;
-	adm_params->payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->payload_size = params_length;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = 0x%x rc %d\n",
-			__func__, port_id, rc);
-		rc = -EINVAL;
-		goto dolby_dap_send_param_return;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Set params timed out port = 0x%x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto dolby_dap_send_param_return;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto dolby_dap_send_param_return;
-	}
-	rc = 0;
-dolby_dap_send_param_return:
-	kfree(adm_params);
-	return rc;
-}
-
-int adm_send_params_v5(int port_id, int copp_idx, char *params,
-			      uint32_t params_length)
-{
-	struct adm_cmd_set_pp_params_v5	*adm_params = NULL;
-	int rc = 0;
-	int sz, port_idx;
-
-	pr_debug("%s:\n", __func__);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_cmd_set_pp_params_v5) + params_length;
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params) {
-		pr_err("%s, adm params memory alloc failed", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
-			params, params_length);
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.pkt_size = sz;
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	adm_params->payload_addr_lsw = 0;
-	adm_params->payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->payload_size = params_length;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = 0x%x rc %d\n",
-			__func__, port_id, rc);
-		rc = -EINVAL;
-		goto send_param_return;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Set params timed out port = 0x%x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto send_param_return;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto send_param_return;
-	}
-	rc = 0;
-send_param_return:
-	kfree(adm_params);
-	return rc;
-}
-
-int adm_get_params_v2(int port_id, int copp_idx, uint32_t module_id,
-		      uint32_t param_id, uint32_t params_length,
-		      char *params, uint32_t client_id)
-{
-	struct adm_cmd_get_pp_params_v5 *adm_params = NULL;
-	int rc = 0, i = 0;
-	int port_idx, idx;
-	int *params_data = (int *)params;
-	uint64_t sz = 0;
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	sz = (uint64_t)sizeof(struct adm_cmd_get_pp_params_v5) +
-				(uint64_t)params_length;
-	/*
-	 * Check if the value of "sz" (which is ultimately assigned to
-	 * "hdr.pkt_size") crosses U16_MAX.
-	 */
-	if (sz > U16_MAX) {
-		pr_err("%s: Invalid params_length\n", __func__);
-		return -EINVAL;
-	}
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params) {
-		pr_err("%s: adm params memory alloc failed", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_get_pp_params_v5)),
-		params, params_length);
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-	APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.pkt_size = sz;
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | client_id << 8 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5;
-	adm_params->data_payload_addr_lsw = 0;
-	adm_params->data_payload_addr_msw = 0;
-	adm_params->mem_map_handle = 0;
-	adm_params->module_id = module_id;
-	adm_params->param_id = param_id;
-	adm_params->param_max_size = params_length;
-	adm_params->reserved = 0;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (rc < 0) {
-		pr_err("%s: Failed to Get Params on port_id 0x%x %d\n",
-			__func__, port_id, rc);
-		rc = -EINVAL;
-		goto adm_get_param_return;
-	}
-	/* Wait for the callback with copp id */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-	atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: get params timed out port_id = 0x%x\n", __func__,
-			port_id);
-		rc = -EINVAL;
-		goto adm_get_param_return;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto adm_get_param_return;
-	}
-	idx = ADM_GET_PARAMETER_LENGTH * copp_idx;
-
-	if (adm_get_parameters[idx] < 0) {
-		pr_err("%s: Size is invalid %d\n", __func__,
-			adm_get_parameters[idx]);
-		rc = -EINVAL;
-		goto adm_get_param_return;
-	}
-	if ((params_data) &&
-		(ARRAY_SIZE(adm_get_parameters) >
-		idx) &&
-		(ARRAY_SIZE(adm_get_parameters) >=
-		1+adm_get_parameters[idx]+idx) &&
-		(params_length/sizeof(uint32_t) >=
-		adm_get_parameters[idx])) {
-		for (i = 0; i < adm_get_parameters[idx]; i++)
-			params_data[i] = adm_get_parameters[1+i+idx];
-
-	} else {
-		pr_err("%s: Get param data not copied! get_param array size %zd, index %d, params array size %zd, index %d\n",
-		__func__, ARRAY_SIZE(adm_get_parameters),
-		(1+adm_get_parameters[idx]+idx),
-		params_length/sizeof(int),
-		adm_get_parameters[idx]);
-	}
-	rc = 0;
-adm_get_param_return:
-	kfree(adm_params);
-
-	return rc;
-}
-
-int adm_get_params(int port_id, int copp_idx, uint32_t module_id,
-		   uint32_t param_id, uint32_t params_length, char *params)
-{
-	return adm_get_params_v2(port_id, copp_idx, module_id, param_id,
-				 params_length, params, 0);
-}
-
-int adm_get_pp_topo_module_list(int port_id, int copp_idx, int32_t param_length,
-				char *params)
-{
-	struct adm_cmd_get_pp_topo_module_list_t *adm_pp_module_list = NULL;
-	int sz, rc = 0, i = 0;
-	int port_idx, idx;
-	int32_t *params_data = (int32_t *)params;
-	int *topo_list;
-
-	pr_debug("%s : port_id %x", __func__, port_id);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_cmd_get_pp_topo_module_list_t) + param_length;
-	adm_pp_module_list = kzalloc(sz, GFP_KERNEL);
-	if (!adm_pp_module_list) {
-		pr_err("%s, adm params memory alloc failed", __func__);
-		return -ENOMEM;
-	}
-
-	memcpy(((u8 *)adm_pp_module_list +
-		sizeof(struct adm_cmd_get_pp_topo_module_list_t)),
-		params, param_length);
-	adm_pp_module_list->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-	APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_pp_module_list->hdr.pkt_size = sz;
-	adm_pp_module_list->hdr.src_svc = APR_SVC_ADM;
-	adm_pp_module_list->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_pp_module_list->hdr.src_port = port_id;
-	adm_pp_module_list->hdr.dest_svc = APR_SVC_ADM;
-	adm_pp_module_list->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_pp_module_list->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_pp_module_list->hdr.token =  port_idx << 16 | copp_idx;
-	adm_pp_module_list->hdr.opcode = ADM_CMD_GET_PP_TOPO_MODULE_LIST;
-	adm_pp_module_list->param_max_size = param_length;
-	/* Payload address and mmap handle set to zero by kzalloc */
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_pp_module_list);
-	if (rc < 0) {
-		pr_err("%s: Failed to Get Params on port %d\n", __func__,
-			port_id);
-		rc = -EINVAL;
-		goto adm_pp_module_list_l;
-	}
-	/* Wait for the callback with copp id */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: get params timed out port = %d\n", __func__,
-			port_id);
-		rc = -EINVAL;
-		goto adm_pp_module_list_l;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto adm_pp_module_list_l;
-	}
-	if (params_data) {
-		idx = ADM_GET_TOPO_MODULE_LIST_LENGTH * copp_idx;
-		topo_list = (int *)(adm_module_topo_list + idx);
-		if (param_length <= ADM_GET_TOPO_MODULE_LIST_LENGTH &&
-			idx <
-			(MAX_COPPS_PER_PORT * ADM_GET_TOPO_MODULE_LIST_LENGTH))
-			memcpy(params_data, topo_list, param_length);
-		else
-			pr_debug("%s: i/p size:%d > MAX param size:%d\n",
-				 __func__, param_length,
-				 (int)ADM_GET_TOPO_MODULE_LIST_LENGTH);
-		for (i = 1; i <= params_data[0]; i++)
-			pr_debug("module = 0x%x\n", params_data[i]);
-	}
-	rc = 0;
-adm_pp_module_list_l:
-	kfree(adm_pp_module_list);
-	pr_debug("%s : rc = %d ", __func__, rc);
-	return rc;
-}
-static void adm_callback_debug_print(struct apr_client_data *data)
-{
-	uint32_t *payload;
-
-	payload = data->payload;
-
-	if (data->payload_size >= 8)
-		pr_debug("%s: code = 0x%x PL#0[0x%x], PL#1[0x%x], size = %d\n",
-			__func__, data->opcode, payload[0], payload[1],
-			data->payload_size);
-	else if (data->payload_size >= 4)
-		pr_debug("%s: code = 0x%x PL#0[0x%x], size = %d\n",
-			__func__, data->opcode, payload[0],
-			data->payload_size);
-	else
-		pr_debug("%s: code = 0x%x, size = %d\n",
-			__func__, data->opcode, data->payload_size);
-}
-
-int adm_set_multi_ch_map(char *channel_map, int path)
-{
-	int idx;
-
-	if (path == ADM_PATH_PLAYBACK) {
-		idx = ADM_MCH_MAP_IDX_PLAYBACK;
-	} else if (path == ADM_PATH_LIVE_REC) {
-		idx = ADM_MCH_MAP_IDX_REC;
-	} else {
-		pr_err("%s: invalid attempt to set path %d\n", __func__, path);
-		return -EINVAL;
-	}
-
-	memcpy(multi_ch_maps[idx].channel_mapping, channel_map,
-		PCM_FORMAT_MAX_NUM_CHANNEL);
-	multi_ch_maps[idx].set_channel_map = true;
-
-	return 0;
-}
-
-int adm_get_multi_ch_map(char *channel_map, int path)
-{
-	int idx;
-
-	if (path == ADM_PATH_PLAYBACK) {
-		idx = ADM_MCH_MAP_IDX_PLAYBACK;
-	} else if (path == ADM_PATH_LIVE_REC) {
-		idx = ADM_MCH_MAP_IDX_REC;
-	} else {
-		pr_err("%s: invalid attempt to get path %d\n", __func__, path);
-		return -EINVAL;
-	}
-
-	if (multi_ch_maps[idx].set_channel_map) {
-		memcpy(channel_map, multi_ch_maps[idx].channel_mapping,
-		       PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	return 0;
-}
-
-static int32_t adm_callback(struct apr_client_data *data, void *priv)
-{
-	uint32_t *payload;
-	int i, j, port_idx, copp_idx, idx, client_id;
-
-	if (data == NULL) {
-		pr_err("%s: data parameter is null\n", __func__);
-		return -EINVAL;
-	}
-
-	payload = data->payload;
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: Reset event is received: %d %d apr[%pK]\n",
-			__func__,
-			data->reset_event, data->reset_proc, this_adm.apr);
-		if (this_adm.apr) {
-			apr_reset(this_adm.apr);
-			for (i = 0; i < AFE_MAX_PORTS; i++) {
-				for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-					atomic_set(&this_adm.copp.id[i][j],
-						   RESET_COPP_ID);
-					atomic_set(&this_adm.copp.cnt[i][j], 0);
-					atomic_set(
-					   &this_adm.copp.topology[i][j], 0);
-					atomic_set(&this_adm.copp.mode[i][j],
-						   0);
-					atomic_set(&this_adm.copp.stat[i][j],
-						   0);
-					atomic_set(&this_adm.copp.rate[i][j],
-						   0);
-					atomic_set(
-					&this_adm.copp.channels[i][j],
-						   0);
-					atomic_set(
-					    &this_adm.copp.bit_width[i][j], 0);
-					atomic_set(
-					    &this_adm.copp.app_type[i][j], 0);
-					atomic_set(
-					   &this_adm.copp.acdb_id[i][j], 0);
-					this_adm.copp.adm_status[i][j] =
-						ADM_STATUS_CALIBRATION_REQUIRED;
-				}
-			}
-			this_adm.apr = NULL;
-			cal_utils_clear_cal_block_q6maps(ADM_MAX_CAL_TYPES,
-				this_adm.cal_data);
-			mutex_lock(&this_adm.cal_data
-				[ADM_CUSTOM_TOP_CAL]->lock);
-			this_adm.set_custom_topology = 1;
-			mutex_unlock(&this_adm.cal_data[
-				ADM_CUSTOM_TOP_CAL]->lock);
-			rtac_clear_mapping(ADM_RTAC_CAL);
-			/*
-			 * Free the ION memory and clear the map handles
-			 * for Source Tracking
-			 */
-			if (this_adm.sourceTrackingData.memmap.paddr != 0) {
-				msm_audio_ion_free(
-					this_adm.sourceTrackingData.ion_client,
-					this_adm.sourceTrackingData.ion_handle);
-				this_adm.sourceTrackingData.ion_client = NULL;
-				this_adm.sourceTrackingData.ion_handle = NULL;
-				this_adm.sourceTrackingData.memmap.size = 0;
-				this_adm.sourceTrackingData.memmap.kvaddr =
-									 NULL;
-				this_adm.sourceTrackingData.memmap.paddr = 0;
-				this_adm.sourceTrackingData.apr_cmd_status = -1;
-				atomic_set(&this_adm.mem_map_handles[
-					ADM_MEM_MAP_INDEX_SOURCE_TRACKING], 0);
-			}
-		}
-		return 0;
-	}
-
-	adm_callback_debug_print(data);
-	if (data->payload_size) {
-		copp_idx = (data->token) & 0XFF;
-		port_idx = ((data->token) >> 16) & 0xFF;
-		client_id = ((data->token) >> 8) & 0xFF;
-		if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
-			pr_err("%s: Invalid port idx %d token %d\n",
-				__func__, port_idx, data->token);
-			return 0;
-		}
-		if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-			pr_err("%s: Invalid copp idx %d token %d\n",
-				__func__, copp_idx, data->token);
-			return 0;
-		}
-		if (client_id < 0 || client_id >= ADM_CLIENT_ID_MAX) {
-			pr_err("%s: Invalid client id %d\n", __func__,
-				client_id);
-			return 0;
-		}
-		if (data->opcode == APR_BASIC_RSP_RESULT) {
-			pr_debug("%s: APR_BASIC_RSP_RESULT id 0x%x\n",
-				__func__, payload[0]);
-			if (payload[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					__func__, payload[0], payload[1]);
-			}
-			switch (payload[0]) {
-			case ADM_CMD_SET_PP_PARAMS_V5:
-				pr_debug("%s: ADM_CMD_SET_PP_PARAMS_V5\n",
-					__func__);
-				if (client_id == ADM_CLIENT_ID_SOURCE_TRACKING)
-					this_adm.sourceTrackingData.
-						apr_cmd_status = payload[1];
-				else if (rtac_make_adm_callback(payload,
-							data->payload_size))
-					break;
-				/*
-				 * if soft volume is called and already
-				 * interrupted break out of the sequence here
-				 */
-			case ADM_CMD_DEVICE_OPEN_V5:
-			case ADM_CMD_DEVICE_CLOSE_V5:
-			case ADM_CMD_DEVICE_OPEN_V6:
-				pr_debug("%s: Basic callback received, wake up.\n",
-					__func__);
-				atomic_set(&this_adm.copp.stat[port_idx]
-						[copp_idx], payload[1]);
-				wake_up(
-				&this_adm.copp.wait[port_idx][copp_idx]);
-				break;
-			case ADM_CMD_ADD_TOPOLOGIES:
-				pr_debug("%s: callback received, ADM_CMD_ADD_TOPOLOGIES.\n",
-					__func__);
-				atomic_set(&this_adm.adm_stat, payload[1]);
-				wake_up(&this_adm.adm_wait);
-				break;
-			case ADM_CMD_MATRIX_MAP_ROUTINGS_V5:
-			case ADM_CMD_STREAM_DEVICE_MAP_ROUTINGS_V5:
-				pr_debug("%s: Basic callback received, wake up.\n",
-					__func__);
-				atomic_set(&this_adm.matrix_map_stat,
-					payload[1]);
-				wake_up(&this_adm.matrix_map_wait);
-				break;
-			case ADM_CMD_SHARED_MEM_UNMAP_REGIONS:
-				pr_debug("%s: ADM_CMD_SHARED_MEM_UNMAP_REGIONS\n",
-					__func__);
-				atomic_set(&this_adm.adm_stat, payload[1]);
-				wake_up(&this_adm.adm_wait);
-				break;
-			case ADM_CMD_SHARED_MEM_MAP_REGIONS:
-				pr_debug("%s: ADM_CMD_SHARED_MEM_MAP_REGIONS\n",
-					__func__);
-				/* Should only come here if there is an APR */
-				/* error or malformed APR packet. Otherwise */
-				/* response will be returned as */
-				if (payload[1] != 0) {
-					pr_err("%s: ADM map error, resuming\n",
-						__func__);
-					atomic_set(&this_adm.adm_stat,
-						payload[1]);
-					wake_up(&this_adm.adm_wait);
-				}
-				break;
-			case ADM_CMD_GET_PP_PARAMS_V5:
-				pr_debug("%s: ADM_CMD_GET_PP_PARAMS_V5\n",
-					__func__);
-				/* Should only come here if there is an APR */
-				/* error or malformed APR packet. Otherwise */
-				/* response will be returned as */
-				/* ADM_CMDRSP_GET_PP_PARAMS_V5 */
-				if (client_id ==
-					ADM_CLIENT_ID_SOURCE_TRACKING) {
-					this_adm.sourceTrackingData.
-						apr_cmd_status = payload[1];
-					if (payload[1] != 0)
-						pr_err("%s: ADM get param error = %d\n",
-							__func__, payload[1]);
-
-					atomic_set(&this_adm.copp.stat
-						[port_idx][copp_idx],
-						payload[1]);
-					wake_up(&this_adm.copp.wait
-							[port_idx][copp_idx]);
-				} else {
-					if (payload[1] != 0) {
-						pr_err("%s: ADM get param error = %d, resuming\n",
-							__func__, payload[1]);
-
-						rtac_make_adm_callback(payload,
-							data->payload_size);
-					}
-				}
-				break;
-			case ADM_CMD_SET_PSPD_MTMX_STRTR_PARAMS_V5:
-				pr_debug("%s: ADM_CMD_SET_PSPD_MTMX_STRTR_PARAMS_V5\n",
-					__func__);
-				atomic_set(&this_adm.copp.stat[port_idx]
-						[copp_idx], payload[1]);
-				wake_up(
-				&this_adm.copp.wait[port_idx][copp_idx]);
-				break;
-			case ADM_CMD_GET_PP_TOPO_MODULE_LIST:
-				pr_debug("%s:ADM_CMD_GET_PP_TOPO_MODULE_LIST\n",
-					 __func__);
-				if (payload[1] != 0)
-					pr_err("%s: ADM get topo list error = %d,\n",
-						__func__, payload[1]);
-				break;
-			default:
-				pr_err("%s: Unknown Cmd: 0x%x\n", __func__,
-								payload[0]);
-				break;
-			}
-			return 0;
-		}
-
-		switch (data->opcode) {
-		case ADM_CMDRSP_DEVICE_OPEN_V5:
-		case ADM_CMDRSP_DEVICE_OPEN_V6: {
-			struct adm_cmd_rsp_device_open_v5 *open =
-			(struct adm_cmd_rsp_device_open_v5 *)data->payload;
-
-			if (open->copp_id == INVALID_COPP_ID) {
-				pr_err("%s: invalid coppid rxed %d\n",
-					__func__, open->copp_id);
-				atomic_set(&this_adm.copp.stat[port_idx]
-						[copp_idx], ADSP_EBADPARAM);
-				wake_up(
-				&this_adm.copp.wait[port_idx][copp_idx]);
-				break;
-			}
-			atomic_set(&this_adm.copp.stat
-				[port_idx][copp_idx], payload[0]);
-			atomic_set(&this_adm.copp.id[port_idx][copp_idx],
-				   open->copp_id);
-			pr_debug("%s: coppid rxed=%d\n", __func__,
-				 open->copp_id);
-			wake_up(&this_adm.copp.wait[port_idx][copp_idx]);
-			}
-			break;
-		case ADM_CMDRSP_GET_PP_PARAMS_V5:
-			pr_debug("%s: ADM_CMDRSP_GET_PP_PARAMS_V5\n", __func__);
-			if (payload[0] != 0)
-				pr_err("%s: ADM_CMDRSP_GET_PP_PARAMS_V5 returned error = 0x%x\n",
-					__func__, payload[0]);
-			if (client_id == ADM_CLIENT_ID_SOURCE_TRACKING)
-				this_adm.sourceTrackingData.apr_cmd_status =
-								payload[0];
-			else if (rtac_make_adm_callback(payload,
-					data->payload_size))
-				break;
-
-			idx = ADM_GET_PARAMETER_LENGTH * copp_idx;
-			if ((payload[0] == 0) && (data->payload_size >
-				(4 * sizeof(*payload))) &&
-				(data->payload_size - 4 >=
-				payload[3]) &&
-				(ARRAY_SIZE(adm_get_parameters) >
-				idx) &&
-				(ARRAY_SIZE(adm_get_parameters)-idx-1 >=
-				payload[3])) {
-				adm_get_parameters[idx] = payload[3] /
-							sizeof(uint32_t);
-				/*
-				 * payload[3] is param_size which is
-				 * expressed in number of bytes
-				 */
-				pr_debug("%s: GET_PP PARAM:received parameter length: 0x%x\n",
-					__func__, adm_get_parameters[idx]);
-				/* storing param size then params */
-				for (i = 0; i < payload[3] /
-						sizeof(uint32_t); i++)
-					adm_get_parameters[idx+1+i] =
-							payload[4+i];
-			} else if (payload[0] == 0) {
-				adm_get_parameters[idx] = -1;
-				pr_err("%s: Out of band case, setting size to %d\n",
-					__func__, adm_get_parameters[idx]);
-			} else {
-				adm_get_parameters[idx] = -1;
-				pr_err("%s: GET_PP_PARAMS failed, setting size to %d\n",
-					__func__, adm_get_parameters[idx]);
-			}
-			atomic_set(&this_adm.copp.stat
-				[port_idx][copp_idx], payload[0]);
-			wake_up(&this_adm.copp.wait[port_idx][copp_idx]);
-			break;
-		case ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST:
-			pr_debug("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST\n",
-				 __func__);
-			if (payload[0] != 0) {
-				pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST",
-					 __func__);
-				pr_err(":err = 0x%x\n", payload[0]);
-			} else if (payload[1] >
-				   ((ADM_GET_TOPO_MODULE_LIST_LENGTH /
-				   sizeof(uint32_t)) - 1)) {
-				pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST",
-					 __func__);
-				pr_err(":size = %d\n", payload[1]);
-			} else {
-				idx = ADM_GET_TOPO_MODULE_LIST_LENGTH *
-					copp_idx;
-				pr_debug("%s:Num modules payload[1] %d\n",
-					 __func__, payload[1]);
-				adm_module_topo_list[idx] = payload[1];
-				for (i = 1; i <= payload[1]; i++) {
-					adm_module_topo_list[idx+i] =
-						payload[1+i];
-					pr_debug("%s:payload[%d] = %x\n",
-						 __func__, (i+1), payload[1+i]);
-				}
-			}
-			atomic_set(&this_adm.copp.stat
-				[port_idx][copp_idx], payload[0]);
-			wake_up(&this_adm.copp.wait[port_idx][copp_idx]);
-			break;
-		case ADM_CMDRSP_SHARED_MEM_MAP_REGIONS:
-			pr_debug("%s: ADM_CMDRSP_SHARED_MEM_MAP_REGIONS\n",
-				__func__);
-			atomic_set(&this_adm.mem_map_handles[
-				   atomic_read(&this_adm.mem_map_index)],
-				   *payload);
-			atomic_set(&this_adm.adm_stat, 0);
-			wake_up(&this_adm.adm_wait);
-			break;
-		default:
-			pr_err("%s: Unknown cmd:0x%x\n", __func__,
-				data->opcode);
-			break;
-		}
-	}
-	return 0;
-}
-
-static int adm_memory_map_regions(phys_addr_t *buf_add, uint32_t mempool_id,
-			   uint32_t *bufsz, uint32_t bufcnt)
-{
-	struct  avs_cmd_shared_mem_map_regions *mmap_regions = NULL;
-	struct  avs_shared_map_region_payload *mregions = NULL;
-	void    *mmap_region_cmd = NULL;
-	void    *payload = NULL;
-	int     ret = 0;
-	int     i = 0;
-	int     cmd_size = 0;
-
-	pr_debug("%s:\n", __func__);
-	if (this_adm.apr == NULL) {
-		this_adm.apr = apr_register("ADSP", "ADM", adm_callback,
-						0xFFFFFFFF, &this_adm);
-		if (this_adm.apr == NULL) {
-			pr_err("%s: Unable to register ADM\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_adm_handle(this_adm.apr);
-	}
-
-	cmd_size = sizeof(struct avs_cmd_shared_mem_map_regions)
-			+ sizeof(struct avs_shared_map_region_payload)
-			* bufcnt;
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (!mmap_region_cmd)
-		return -ENOMEM;
-
-	mmap_regions = (struct avs_cmd_shared_mem_map_regions *)mmap_region_cmd;
-	mmap_regions->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-								APR_PKT_VER);
-	mmap_regions->hdr.pkt_size = cmd_size;
-	mmap_regions->hdr.src_port = 0;
-
-	mmap_regions->hdr.dest_port = 0;
-	mmap_regions->hdr.token = 0;
-	mmap_regions->hdr.opcode = ADM_CMD_SHARED_MEM_MAP_REGIONS;
-	mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL & 0x00ff;
-	mmap_regions->num_regions = bufcnt & 0x00ff;
-	mmap_regions->property_flag = 0x00;
-
-	pr_debug("%s: map_regions->num_regions = %d\n", __func__,
-				mmap_regions->num_regions);
-	payload = ((u8 *) mmap_region_cmd +
-				sizeof(struct avs_cmd_shared_mem_map_regions));
-	mregions = (struct avs_shared_map_region_payload *)payload;
-
-	for (i = 0; i < bufcnt; i++) {
-		mregions->shm_addr_lsw = lower_32_bits(buf_add[i]);
-		mregions->shm_addr_msw =
-				msm_audio_populate_upper_32_bits(buf_add[i]);
-		mregions->mem_size_bytes = bufsz[i];
-		++mregions;
-	}
-
-	atomic_set(&this_adm.adm_stat, -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *) mmap_region_cmd);
-	if (ret < 0) {
-		pr_err("%s: mmap_regions op[0x%x]rc[%d]\n", __func__,
-					mmap_regions->hdr.opcode, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_adm.adm_wait,
-				 atomic_read(&this_adm.adm_stat) >= 0,
-				 5 * HZ);
-	if (!ret) {
-		pr_err("%s: timeout. waited for memory_map\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.adm_stat) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.adm_stat)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.adm_stat));
-		goto fail_cmd;
-	}
-fail_cmd:
-	kfree(mmap_region_cmd);
-	return ret;
-}
-
-static int adm_memory_unmap_regions(void)
-{
-	struct  avs_cmd_shared_mem_unmap_regions unmap_regions;
-	int     ret = 0;
-
-	pr_debug("%s:\n", __func__);
-	if (this_adm.apr == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	unmap_regions.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-							APR_PKT_VER);
-	unmap_regions.hdr.pkt_size = sizeof(unmap_regions);
-	unmap_regions.hdr.src_port = 0;
-	unmap_regions.hdr.dest_port = 0;
-	unmap_regions.hdr.token = 0;
-	unmap_regions.hdr.opcode = ADM_CMD_SHARED_MEM_UNMAP_REGIONS;
-	unmap_regions.mem_map_handle = atomic_read(&this_adm.
-		mem_map_handles[atomic_read(&this_adm.mem_map_index)]);
-	atomic_set(&this_adm.adm_stat, -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *) &unmap_regions);
-	if (ret < 0) {
-		pr_err("%s: mmap_regions op[0x%x]rc[%d]\n", __func__,
-				unmap_regions.hdr.opcode, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_adm.adm_wait,
-				 atomic_read(&this_adm.adm_stat) >= 0,
-				 5 * HZ);
-	if (!ret) {
-		pr_err("%s: timeout. waited for memory_unmap\n",
-		       __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.adm_stat) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.adm_stat)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.adm_stat));
-		goto fail_cmd;
-	} else {
-		pr_debug("%s: Unmap handle 0x%x succeeded\n", __func__,
-			 unmap_regions.mem_map_handle);
-	}
-fail_cmd:
-	return ret;
-}
-
-static int remap_cal_data(struct cal_block_data *cal_block, int cal_index)
-{
-	int ret = 0;
-
-	if (cal_block->map_data.ion_client == NULL) {
-		pr_err("%s: No ION allocation for cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((cal_block->map_data.map_size > 0) &&
-		(cal_block->map_data.q6map_handle == 0)) {
-		atomic_set(&this_adm.mem_map_index, cal_index);
-		ret = adm_memory_map_regions(&cal_block->cal_data.paddr, 0,
-				(uint32_t *)&cal_block->map_data.map_size, 1);
-		if (ret < 0) {
-			pr_err("%s: ADM mmap did not work! size = %zd ret %d\n",
-				__func__,
-				cal_block->map_data.map_size, ret);
-			pr_debug("%s: ADM mmap did not work! addr = 0x%pK, size = %zd ret %d\n",
-				__func__,
-				&cal_block->cal_data.paddr,
-				cal_block->map_data.map_size, ret);
-			goto done;
-		}
-		cal_block->map_data.q6map_handle = atomic_read(&this_adm.
-			mem_map_handles[cal_index]);
-	}
-done:
-	return ret;
-}
-
-static void send_adm_custom_topology(void)
-{
-	struct cal_block_data *cal_block = NULL;
-	struct cmd_set_topologies adm_top;
-	int cal_index = ADM_CUSTOM_TOP_CAL;
-	int result;
-
-	if (this_adm.cal_data[cal_index] == NULL)
-		goto done;
-
-	mutex_lock(&this_adm.cal_data[cal_index]->lock);
-	if (!this_adm.set_custom_topology)
-		goto unlock;
-	this_adm.set_custom_topology = 0;
-
-	cal_block = cal_utils_get_only_cal_block(this_adm.cal_data[cal_index]);
-	if (cal_block == NULL)
-		goto unlock;
-
-	pr_debug("%s: Sending cal_index %d\n", __func__, cal_index);
-
-	result = remap_cal_data(cal_block, cal_index);
-	if (result) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, cal_index);
-		goto unlock;
-	}
-	atomic_set(&this_adm.mem_map_index, cal_index);
-	atomic_set(&this_adm.mem_map_handles[cal_index],
-		cal_block->map_data.q6map_handle);
-
-	if (cal_block->cal_data.size == 0) {
-		pr_debug("%s: No ADM cal to send\n", __func__);
-		goto unlock;
-	}
-
-	adm_top.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(20), APR_PKT_VER);
-	adm_top.hdr.pkt_size = sizeof(adm_top);
-	adm_top.hdr.src_svc = APR_SVC_ADM;
-	adm_top.hdr.src_domain = APR_DOMAIN_APPS;
-	adm_top.hdr.src_port = 0;
-	adm_top.hdr.dest_svc = APR_SVC_ADM;
-	adm_top.hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_top.hdr.dest_port = 0;
-	adm_top.hdr.token = 0;
-	adm_top.hdr.opcode = ADM_CMD_ADD_TOPOLOGIES;
-	adm_top.payload_addr_lsw = lower_32_bits(cal_block->cal_data.paddr);
-	adm_top.payload_addr_msw = msm_audio_populate_upper_32_bits(
-						cal_block->cal_data.paddr);
-	adm_top.mem_map_handle = cal_block->map_data.q6map_handle;
-	adm_top.payload_size = cal_block->cal_data.size;
-
-	atomic_set(&this_adm.adm_stat, -1);
-	pr_debug("%s: Sending ADM_CMD_ADD_TOPOLOGIES payload = 0x%pK, size = %d\n",
-		__func__, &cal_block->cal_data.paddr,
-		adm_top.payload_size);
-	result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_top);
-	if (result < 0) {
-		pr_err("%s: Set topologies failed payload size = %zd result %d\n",
-			__func__, cal_block->cal_data.size, result);
-		goto unlock;
-	}
-	/* Wait for the callback */
-	result = wait_event_timeout(this_adm.adm_wait,
-				    atomic_read(&this_adm.adm_stat) >= 0,
-				    msecs_to_jiffies(TIMEOUT_MS));
-	if (!result) {
-		pr_err("%s: Set topologies timed out payload size = %zd\n",
-			__func__, cal_block->cal_data.size);
-		goto unlock;
-	} else if (atomic_read(&this_adm.adm_stat) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.adm_stat)));
-		result = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.adm_stat));
-		goto unlock;
-	}
-unlock:
-	mutex_unlock(&this_adm.cal_data[cal_index]->lock);
-done:
-	return;
-}
-
-static int send_adm_cal_block(int port_id, int copp_idx,
-			      struct cal_block_data *cal_block, int perf_mode,
-			      int app_type, int acdb_id, int sample_rate)
-{
-	s32 result = 0;
-	struct adm_cmd_set_pp_params_v5	adm_params;
-	int port_idx;
-
-	pr_debug("%s: Port id 0x%x sample_rate %d ,\n", __func__,
-			port_id, sample_rate);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-	if (!cal_block) {
-		pr_debug("%s: No ADM cal to send for port_id = 0x%x!\n",
-			__func__, port_id);
-		result = -EINVAL;
-		goto done;
-	}
-	if (cal_block->cal_data.size <= 0) {
-		pr_debug("%s: No ADM cal send for port_id = 0x%x!\n",
-			__func__, port_id);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (perf_mode == LEGACY_PCM_MODE &&
-		((atomic_read(&this_adm.copp.topology[port_idx][copp_idx])) ==
-			DS2_ADM_COPP_TOPOLOGY_ID)) {
-		pr_err("%s: perf_mode %d, topology 0x%x\n", __func__, perf_mode,
-			atomic_read(
-				&this_adm.copp.topology[port_idx][copp_idx]));
-		goto done;
-	}
-
-	adm_params.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(20), APR_PKT_VER);
-	adm_params.hdr.pkt_size = sizeof(adm_params);
-	adm_params.hdr.src_svc = APR_SVC_ADM;
-	adm_params.hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params.hdr.src_port = port_id;
-	adm_params.hdr.dest_svc = APR_SVC_ADM;
-	adm_params.hdr.dest_domain = APR_DOMAIN_ADSP;
-
-	adm_params.hdr.token = port_idx << 16 | copp_idx;
-	adm_params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	adm_params.payload_addr_lsw = lower_32_bits(cal_block->cal_data.paddr);
-	adm_params.payload_addr_msw = msm_audio_populate_upper_32_bits(
-						cal_block->cal_data.paddr);
-	adm_params.mem_map_handle = cal_block->map_data.q6map_handle;
-	adm_params.payload_size = cal_block->cal_data.size;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	pr_debug("%s: Sending SET_PARAMS payload = 0x%pK, size = %d\n",
-		__func__, &cal_block->cal_data.paddr,
-		adm_params.payload_size);
-	result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_params);
-	if (result < 0) {
-		pr_err("%s: Set params failed port 0x%x result %d\n",
-				__func__, port_id, result);
-		pr_debug("%s: Set params failed port = 0x%x payload = 0x%pK result %d\n",
-			__func__, port_id, &cal_block->cal_data.paddr, result);
-		result = -EINVAL;
-		goto done;
-	}
-	/* Wait for the callback */
-	result = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!result) {
-		pr_err("%s: Set params timed out port = 0x%x\n",
-				__func__, port_id);
-		pr_debug("%s: Set params timed out port = 0x%x, payload = 0x%pK\n",
-			__func__, port_id, &cal_block->cal_data.paddr);
-		result = -EINVAL;
-		goto done;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		result = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto done;
-	}
-
-done:
-	return result;
-}
-
-static struct cal_block_data *adm_find_cal_by_path(int cal_index, int path)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_audproc *audproc_cal_info = NULL;
-	struct audio_cal_info_audvol *audvol_cal_info = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&this_adm.cal_data[cal_index]->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (cal_index == ADM_AUDPROC_CAL) {
-			audproc_cal_info = cal_block->cal_info;
-			if ((audproc_cal_info->path == path) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		} else if (cal_index == ADM_AUDVOL_CAL) {
-			audvol_cal_info = cal_block->cal_info;
-			if ((audvol_cal_info->path == path) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		}
-	}
-	pr_debug("%s: Can't find ADM cal for cal_index %d, path %d\n",
-		__func__, cal_index, path);
-	return NULL;
-}
-
-static struct cal_block_data *adm_find_cal_by_app_type(int cal_index, int path,
-								int app_type)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_audproc *audproc_cal_info = NULL;
-	struct audio_cal_info_audvol *audvol_cal_info = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&this_adm.cal_data[cal_index]->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (cal_index == ADM_AUDPROC_CAL) {
-			audproc_cal_info = cal_block->cal_info;
-			if ((audproc_cal_info->path == path) &&
-			    (audproc_cal_info->app_type == app_type) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		} else if (cal_index == ADM_AUDVOL_CAL) {
-			audvol_cal_info = cal_block->cal_info;
-			if ((audvol_cal_info->path == path) &&
-			    (audvol_cal_info->app_type == app_type) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		}
-	}
-	pr_debug("%s: Can't find ADM cali for cal_index %d, path %d, app %d, defaulting to search by path\n",
-		__func__, cal_index, path, app_type);
-	return adm_find_cal_by_path(cal_index, path);
-}
-
-
-static struct cal_block_data *adm_find_cal(int cal_index, int path,
-					   int app_type, int acdb_id,
-					   int sample_rate)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_audproc *audproc_cal_info = NULL;
-	struct audio_cal_info_audvol *audvol_cal_info = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&this_adm.cal_data[cal_index]->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (cal_index == ADM_AUDPROC_CAL) {
-			audproc_cal_info = cal_block->cal_info;
-			if ((audproc_cal_info->path == path) &&
-			    (audproc_cal_info->app_type == app_type) &&
-			    (audproc_cal_info->acdb_id == acdb_id) &&
-			    (audproc_cal_info->sample_rate == sample_rate) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		} else if (cal_index == ADM_AUDVOL_CAL) {
-			audvol_cal_info = cal_block->cal_info;
-			if ((audvol_cal_info->path == path) &&
-			    (audvol_cal_info->app_type == app_type) &&
-			    (audvol_cal_info->acdb_id == acdb_id) &&
-			    (cal_block->cal_data.size > 0))
-				return cal_block;
-		}
-	}
-	pr_debug("%s: Can't find ADM cal for cal_index %d, path %d, app %d, acdb_id %d sample_rate %d defaulting to search by app type\n",
-		__func__, cal_index, path, app_type, acdb_id, sample_rate);
-	return adm_find_cal_by_app_type(cal_index, path, app_type);
-}
-
-static int adm_remap_and_send_cal_block(int cal_index, int port_id,
-	int copp_idx, struct cal_block_data *cal_block, int perf_mode,
-	int app_type, int acdb_id, int sample_rate)
-{
-	int ret = 0;
-
-	pr_debug("%s: Sending cal_index cal %d\n", __func__, cal_index);
-	ret = remap_cal_data(cal_block, cal_index);
-	if (ret) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, cal_index);
-		goto done;
-	}
-	ret = send_adm_cal_block(port_id, copp_idx, cal_block, perf_mode,
-				app_type, acdb_id, sample_rate);
-	if (ret < 0)
-		pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d sample_rate %d\n",
-			__func__, cal_index, port_id, ret, sample_rate);
-done:
-	return ret;
-}
-
-static void send_adm_cal_type(int cal_index, int path, int port_id,
-			      int copp_idx, int perf_mode, int app_type,
-			      int acdb_id, int sample_rate)
-{
-	struct cal_block_data		*cal_block = NULL;
-	int ret;
-
-	pr_debug("%s: cal index %d\n", __func__, cal_index);
-
-	if (this_adm.cal_data[cal_index] == NULL) {
-		pr_debug("%s: cal_index %d not allocated!\n",
-			__func__, cal_index);
-		goto done;
-	}
-
-	mutex_lock(&this_adm.cal_data[cal_index]->lock);
-	cal_block = adm_find_cal(cal_index, path, app_type, acdb_id,
-				sample_rate);
-	if (cal_block == NULL)
-		goto unlock;
-
-	ret = adm_remap_and_send_cal_block(cal_index, port_id, copp_idx,
-		cal_block, perf_mode, app_type, acdb_id, sample_rate);
-unlock:
-	mutex_unlock(&this_adm.cal_data[cal_index]->lock);
-done:
-	return;
-}
-
-static int get_cal_path(int path)
-{
-	if (path == 0x1)
-		return RX_DEVICE;
-	else
-		return TX_DEVICE;
-}
-
-static void send_adm_cal(int port_id, int copp_idx, int path, int perf_mode,
-			 int app_type, int acdb_id, int sample_rate)
-{
-	pr_debug("%s: port id 0x%x copp_idx %d\n", __func__, port_id, copp_idx);
-
-	send_adm_cal_type(ADM_AUDPROC_CAL, path, port_id, copp_idx, perf_mode,
-			  app_type, acdb_id, sample_rate);
-	send_adm_cal_type(ADM_AUDVOL_CAL, path, port_id, copp_idx, perf_mode,
-			  app_type, acdb_id, sample_rate);
-}
-
-int adm_connect_afe_port(int mode, int session_id, int port_id)
-{
-	struct adm_cmd_connect_afe_port_v5	cmd;
-	int ret = 0;
-	int port_idx, copp_idx = 0;
-
-	pr_debug("%s: port_id: 0x%x session id:%d mode:%d\n", __func__,
-				port_id, session_id, mode);
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	if (this_adm.apr == NULL) {
-		this_adm.apr = apr_register("ADSP", "ADM", adm_callback,
-						0xFFFFFFFF, &this_adm);
-		if (this_adm.apr == NULL) {
-			pr_err("%s: Unable to register ADM\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_adm_handle(this_adm.apr);
-	}
-	pr_debug("%s: Port ID 0x%x, index %d\n", __func__, port_id, port_idx);
-
-	cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cmd.hdr.pkt_size = sizeof(cmd);
-	cmd.hdr.src_svc = APR_SVC_ADM;
-	cmd.hdr.src_domain = APR_DOMAIN_APPS;
-	cmd.hdr.src_port = port_id;
-	cmd.hdr.dest_svc = APR_SVC_ADM;
-	cmd.hdr.dest_domain = APR_DOMAIN_ADSP;
-	cmd.hdr.dest_port = 0; /* Ignored */
-	cmd.hdr.token = port_idx << 16 | copp_idx;
-	cmd.hdr.opcode = ADM_CMD_CONNECT_AFE_PORT_V5;
-
-	cmd.mode = mode;
-	cmd.session_id = session_id;
-	cmd.afe_port_id = port_id;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&cmd);
-	if (ret < 0) {
-		pr_err("%s: ADM enable for port_id: 0x%x failed ret %d\n",
-					__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback with copp id */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: ADM connect timedout for port_id: 0x%x\n",
-			__func__, port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	atomic_inc(&this_adm.copp.cnt[port_idx][copp_idx]);
-	return 0;
-
-fail_cmd:
-
-	return ret;
-}
-
-int adm_arrange_mch_map(struct adm_cmd_device_open_v5 *open, int path,
-			 int channel_mode)
-{
-	int rc = 0, idx;
-
-	memset(open->dev_channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-	switch (path) {
-	case ADM_PATH_PLAYBACK:
-		idx = ADM_MCH_MAP_IDX_PLAYBACK;
-		break;
-	case ADM_PATH_LIVE_REC:
-	case ADM_PATH_NONLIVE_REC:
-		idx = ADM_MCH_MAP_IDX_REC;
-		break;
-	default:
-		goto non_mch_path;
-	};
-	if ((open->dev_num_channel > 2) && multi_ch_maps[idx].set_channel_map) {
-		memcpy(open->dev_channel_mapping,
-			multi_ch_maps[idx].channel_mapping,
-			PCM_FORMAT_MAX_NUM_CHANNEL);
-	} else {
-		if (channel_mode == 1) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FC;
-		} else if (channel_mode == 2) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-		} else if (channel_mode == 3) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_FC;
-		} else if (channel_mode == 4) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_LS;
-			open->dev_channel_mapping[3] = PCM_CHANNEL_RS;
-		} else if (channel_mode == 5) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_FC;
-			open->dev_channel_mapping[3] = PCM_CHANNEL_LS;
-			open->dev_channel_mapping[4] = PCM_CHANNEL_RS;
-		} else if (channel_mode == 6) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_LFE;
-			open->dev_channel_mapping[3] = PCM_CHANNEL_FC;
-			open->dev_channel_mapping[4] = PCM_CHANNEL_LS;
-			open->dev_channel_mapping[5] = PCM_CHANNEL_RS;
-		} else if (channel_mode == 7) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_FC;
-			open->dev_channel_mapping[3] = PCM_CHANNEL_LFE;
-			open->dev_channel_mapping[4] = PCM_CHANNEL_LB;
-			open->dev_channel_mapping[5] = PCM_CHANNEL_RB;
-			open->dev_channel_mapping[6] = PCM_CHANNEL_CS;
-		} else if (channel_mode == 8) {
-			open->dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open->dev_channel_mapping[1] = PCM_CHANNEL_FR;
-			open->dev_channel_mapping[2] = PCM_CHANNEL_LFE;
-			open->dev_channel_mapping[3] = PCM_CHANNEL_FC;
-			open->dev_channel_mapping[4] = PCM_CHANNEL_LS;
-			open->dev_channel_mapping[5] = PCM_CHANNEL_RS;
-			open->dev_channel_mapping[6] = PCM_CHANNEL_LB;
-			open->dev_channel_mapping[7] = PCM_CHANNEL_RB;
-		} else {
-			pr_err("%s: invalid num_chan %d\n", __func__,
-				channel_mode);
-			rc = -EINVAL;
-			goto inval_ch_mod;
-		}
-	}
-
-non_mch_path:
-inval_ch_mod:
-	return rc;
-}
-
-int adm_arrange_mch_ep2_map(struct adm_cmd_device_open_v6 *open_v6,
-			 int channel_mode)
-{
-	int rc = 0;
-
-	memset(open_v6->dev_channel_mapping_eid2, 0,
-	       PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (channel_mode == 1)	{
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FC;
-	} else if (channel_mode == 2) {
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-	} else if (channel_mode == 3)	{
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-		open_v6->dev_channel_mapping_eid2[2] = PCM_CHANNEL_FC;
-	} else if (channel_mode == 4) {
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-		open_v6->dev_channel_mapping_eid2[2] = PCM_CHANNEL_LS;
-		open_v6->dev_channel_mapping_eid2[3] = PCM_CHANNEL_RS;
-	} else if (channel_mode == 5) {
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-		open_v6->dev_channel_mapping_eid2[2] = PCM_CHANNEL_FC;
-		open_v6->dev_channel_mapping_eid2[3] = PCM_CHANNEL_LS;
-		open_v6->dev_channel_mapping_eid2[4] = PCM_CHANNEL_RS;
-	} else if (channel_mode == 6) {
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-		open_v6->dev_channel_mapping_eid2[2] = PCM_CHANNEL_LFE;
-		open_v6->dev_channel_mapping_eid2[3] = PCM_CHANNEL_FC;
-		open_v6->dev_channel_mapping_eid2[4] = PCM_CHANNEL_LS;
-		open_v6->dev_channel_mapping_eid2[5] = PCM_CHANNEL_RS;
-	} else if (channel_mode == 8) {
-		open_v6->dev_channel_mapping_eid2[0] = PCM_CHANNEL_FL;
-		open_v6->dev_channel_mapping_eid2[1] = PCM_CHANNEL_FR;
-		open_v6->dev_channel_mapping_eid2[2] = PCM_CHANNEL_LFE;
-		open_v6->dev_channel_mapping_eid2[3] = PCM_CHANNEL_FC;
-		open_v6->dev_channel_mapping_eid2[4] = PCM_CHANNEL_LS;
-		open_v6->dev_channel_mapping_eid2[5] = PCM_CHANNEL_RS;
-		open_v6->dev_channel_mapping_eid2[6] = PCM_CHANNEL_LB;
-		open_v6->dev_channel_mapping_eid2[7] = PCM_CHANNEL_RB;
-	} else {
-		pr_err("%s: invalid num_chan %d\n", __func__,
-			channel_mode);
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-
-int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
-	     int perf_mode, uint16_t bit_width, int app_type, int acdb_id)
-{
-	struct adm_cmd_device_open_v5	open;
-	struct adm_cmd_device_open_v6	open_v6;
-	int ret = 0;
-	int port_idx, flags;
-	int copp_idx = -1;
-	int tmp_port = q6audio_get_port_id(port_id);
-
-	pr_debug("%s:port %#x path:%d rate:%d mode:%d perf_mode:%d,topo_id %d\n",
-		 __func__, port_id, path, rate, channel_mode, perf_mode,
-		 topology);
-
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	if (this_adm.apr == NULL) {
-		this_adm.apr = apr_register("ADSP", "ADM", adm_callback,
-						0xFFFFFFFF, &this_adm);
-		if (this_adm.apr == NULL) {
-			pr_err("%s: Unable to register ADM\n", __func__);
-			return -ENODEV;
-		}
-		rtac_set_adm_handle(this_adm.apr);
-	}
-
-	if (perf_mode == ULL_POST_PROCESSING_PCM_MODE) {
-		flags = ADM_ULL_POST_PROCESSING_DEVICE_SESSION;
-		if ((topology == DOLBY_ADM_COPP_TOPOLOGY_ID) ||
-		    (topology == DS2_ADM_COPP_TOPOLOGY_ID) ||
-		    (topology == SRS_TRUMEDIA_TOPOLOGY_ID))
-			topology = DEFAULT_COPP_TOPOLOGY;
-	} else if (perf_mode == ULTRA_LOW_LATENCY_PCM_MODE) {
-		flags = ADM_ULTRA_LOW_LATENCY_DEVICE_SESSION;
-		topology = NULL_COPP_TOPOLOGY;
-		rate = ULL_SUPPORTED_SAMPLE_RATE;
-		bit_width = ULL_SUPPORTED_BITS_PER_SAMPLE;
-	} else if (perf_mode == LOW_LATENCY_PCM_MODE) {
-		flags = ADM_LOW_LATENCY_DEVICE_SESSION;
-		if ((topology == DOLBY_ADM_COPP_TOPOLOGY_ID) ||
-		    (topology == DS2_ADM_COPP_TOPOLOGY_ID) ||
-		    (topology == SRS_TRUMEDIA_TOPOLOGY_ID))
-			topology = DEFAULT_COPP_TOPOLOGY;
-	} else {
-		if ((path == ADM_PATH_COMPRESSED_RX) ||
-		    (path == ADM_PATH_COMPRESSED_TX))
-			flags = 0;
-		else
-			flags = ADM_LEGACY_DEVICE_SESSION;
-	}
-
-	if ((topology == VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY) ||
-	    (topology == VPM_TX_DM_FLUENCE_COPP_TOPOLOGY) ||
-	    (topology == VPM_TX_DM_RFECNS_COPP_TOPOLOGY))
-		rate = 16000;
-
-	/*
-	 * Routing driver reuses the same adm for streams with the same
-	 * app_type, sample_rate etc.
-	 * This isn't allowed for ULL streams as per the DSP interface
-	 */
-	if (perf_mode != ULTRA_LOW_LATENCY_PCM_MODE)
-		copp_idx = adm_get_idx_if_copp_exists(port_idx, topology,
-						      perf_mode,
-						      rate, bit_width,
-						      app_type);
-
-	if (copp_idx < 0) {
-		copp_idx = adm_get_next_available_copp(port_idx);
-		if (copp_idx >= MAX_COPPS_PER_PORT) {
-			pr_err("%s: exceeded copp id %d\n",
-				 __func__, copp_idx);
-			return -EINVAL;
-		}
-		atomic_set(&this_adm.copp.cnt[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.topology[port_idx][copp_idx],
-			   topology);
-		atomic_set(&this_adm.copp.mode[port_idx][copp_idx],
-			   perf_mode);
-		atomic_set(&this_adm.copp.rate[port_idx][copp_idx],
-			   rate);
-		atomic_set(&this_adm.copp.channels[port_idx][copp_idx],
-			   channel_mode);
-		atomic_set(&this_adm.copp.bit_width[port_idx][copp_idx],
-			   bit_width);
-		atomic_set(&this_adm.copp.app_type[port_idx][copp_idx],
-			   app_type);
-		atomic_set(&this_adm.copp.acdb_id[port_idx][copp_idx],
-			   acdb_id);
-		set_bit(ADM_STATUS_CALIBRATION_REQUIRED,
-		(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
-		if ((path != ADM_PATH_COMPRESSED_RX) &&
-		    (path != ADM_PATH_COMPRESSED_TX))
-			send_adm_custom_topology();
-	}
-
-	if (this_adm.copp.adm_delay[port_idx][copp_idx] &&
-		perf_mode == LEGACY_PCM_MODE) {
-		atomic_set(&this_adm.copp.adm_delay_stat[port_idx][copp_idx],
-			   1);
-		this_adm.copp.adm_delay[port_idx][copp_idx] = 0;
-		wake_up(&this_adm.copp.adm_delay_wait[port_idx][copp_idx]);
-	}
-
-	/* Create a COPP if port id are not enabled */
-	if (atomic_read(&this_adm.copp.cnt[port_idx][copp_idx]) == 0) {
-		pr_debug("%s: open ADM: port_idx: %d, copp_idx: %d\n", __func__,
-			 port_idx, copp_idx);
-	if ((topology == SRS_TRUMEDIA_TOPOLOGY_ID) &&
-	     perf_mode == LEGACY_PCM_MODE) {
-		int res;
-
-		atomic_set(&this_adm.mem_map_index, ADM_SRS_TRUMEDIA);
-		msm_dts_srs_tm_ion_memmap(&this_adm.outband_memmap);
-		res = adm_memory_map_regions(&this_adm.outband_memmap.paddr, 0,
-		(uint32_t *)&this_adm.outband_memmap.size, 1);
-		if (res < 0) {
-			pr_err("%s: SRS adm_memory_map_regions failed ! addr = 0x%pK, size = %d\n",
-			 __func__, (void *)this_adm.outband_memmap.paddr,
-		(uint32_t)this_adm.outband_memmap.size);
-		}
-	}
-		open.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						   APR_HDR_LEN(APR_HDR_SIZE),
-						   APR_PKT_VER);
-		open.hdr.pkt_size = sizeof(open);
-		open.hdr.src_svc = APR_SVC_ADM;
-		open.hdr.src_domain = APR_DOMAIN_APPS;
-		open.hdr.src_port = tmp_port;
-		open.hdr.dest_svc = APR_SVC_ADM;
-		open.hdr.dest_domain = APR_DOMAIN_ADSP;
-		open.hdr.dest_port = tmp_port;
-		open.hdr.token = port_idx << 16 | copp_idx;
-		open.hdr.opcode = ADM_CMD_DEVICE_OPEN_V5;
-		open.flags = flags;
-		open.mode_of_operation = path;
-		open.endpoint_id_1 = tmp_port;
-		open.endpoint_id_2 = 0xFFFF;
-
-		if (this_adm.ec_ref_rx && (path != 1)) {
-			open.endpoint_id_2 = this_adm.ec_ref_rx;
-			this_adm.ec_ref_rx = -1;
-		}
-
-		open.topology_id = topology;
-
-		open.dev_num_channel = channel_mode & 0x00FF;
-		open.bit_width = bit_width;
-		WARN_ON((perf_mode == ULTRA_LOW_LATENCY_PCM_MODE) &&
-			(rate != ULL_SUPPORTED_SAMPLE_RATE));
-		open.sample_rate  = rate;
-
-		ret = adm_arrange_mch_map(&open, path, channel_mode);
-
-		if (ret)
-			return ret;
-
-		pr_debug("%s: port_id=0x%x rate=%d topology_id=0x%X\n",
-			__func__, open.endpoint_id_1, open.sample_rate,
-			open.topology_id);
-
-		atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-
-		if ((this_adm.num_ec_ref_rx_chans != 0) && (path != 1) &&
-			(open.endpoint_id_2 != 0xFFFF)) {
-			memset(&open_v6, 0,
-				sizeof(struct adm_cmd_device_open_v6));
-			memcpy(&open_v6, &open,
-				sizeof(struct adm_cmd_device_open_v5));
-			open_v6.hdr.opcode = ADM_CMD_DEVICE_OPEN_V6;
-			open_v6.hdr.pkt_size = sizeof(open_v6);
-			open_v6.dev_num_channel_eid2 =
-				this_adm.num_ec_ref_rx_chans;
-			this_adm.num_ec_ref_rx_chans = 0;
-
-			if (this_adm.ec_ref_rx_bit_width != 0) {
-				open_v6.bit_width_eid2 =
-					this_adm.ec_ref_rx_bit_width;
-				this_adm.ec_ref_rx_bit_width = 0;
-			} else {
-				open_v6.bit_width_eid2 = bit_width;
-			}
-
-			if (this_adm.ec_ref_rx_sampling_rate != 0) {
-				open_v6.sample_rate_eid2 =
-					this_adm.ec_ref_rx_sampling_rate;
-				this_adm.ec_ref_rx_sampling_rate = 0;
-			} else {
-				open_v6.sample_rate_eid2 = rate;
-			}
-
-			pr_debug("%s: eid2_channels=%d eid2_bit_width=%d eid2_rate=%d\n",
-				__func__, open_v6.dev_num_channel_eid2,
-				open_v6.bit_width_eid2,
-				open_v6.sample_rate_eid2);
-
-			ret = adm_arrange_mch_ep2_map(&open_v6,
-				open_v6.dev_num_channel_eid2);
-
-			if (ret)
-				return ret;
-
-			ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open_v6);
-		} else {
-			ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open);
-		}
-		if (ret < 0) {
-			pr_err("%s: port_id: 0x%x for[0x%x] failed %d\n",
-			__func__, tmp_port, port_id, ret);
-			return -EINVAL;
-		}
-		/* Wait for the callback with copp id */
-		ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-			atomic_read(&this_adm.copp.stat
-			[port_idx][copp_idx]) >= 0,
-			msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: ADM open timedout for port_id: 0x%x for [0x%x]\n",
-						__func__, tmp_port, port_id);
-			return -EINVAL;
-		} else if (atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]) > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-			return adsp_err_get_lnx_err_code(
-					atomic_read(&this_adm.copp.stat
-						[port_idx][copp_idx]));
-		}
-	}
-	atomic_inc(&this_adm.copp.cnt[port_idx][copp_idx]);
-	return copp_idx;
-}
-
-void adm_copp_mfc_cfg(int port_id, int copp_idx, int dst_sample_rate)
-{
-	struct audproc_mfc_output_media_fmt mfc_cfg;
-	struct adm_cmd_device_open_v5 open;
-	int port_idx;
-	int sz = 0;
-	int rc  = 0;
-	int i  = 0;
-
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		goto fail_cmd;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct audproc_mfc_output_media_fmt);
-
-	mfc_cfg.params.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mfc_cfg.params.hdr.pkt_size = sz;
-	mfc_cfg.params.hdr.src_svc = APR_SVC_ADM;
-	mfc_cfg.params.hdr.src_domain = APR_DOMAIN_APPS;
-	mfc_cfg.params.hdr.src_port = port_id;
-	mfc_cfg.params.hdr.dest_svc = APR_SVC_ADM;
-	mfc_cfg.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	mfc_cfg.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	mfc_cfg.params.hdr.token = port_idx << 16 | copp_idx;
-	mfc_cfg.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	mfc_cfg.params.payload_addr_lsw = 0;
-	mfc_cfg.params.payload_addr_msw = 0;
-	mfc_cfg.params.mem_map_handle = 0;
-	mfc_cfg.params.payload_size = sizeof(mfc_cfg) -
-				sizeof(mfc_cfg.params);
-	mfc_cfg.data.module_id = AUDPROC_MODULE_ID_MFC;
-	mfc_cfg.data.param_id =
-			AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
-	mfc_cfg.data.param_size = mfc_cfg.params.payload_size -
-				sizeof(mfc_cfg.data);
-	mfc_cfg.data.reserved = 0;
-	mfc_cfg.sampling_rate = dst_sample_rate;
-	mfc_cfg.bits_per_sample =
-		atomic_read(&this_adm.copp.bit_width[port_idx][copp_idx]);
-	open.dev_num_channel = mfc_cfg.num_channels =
-		atomic_read(&this_adm.copp.channels[port_idx][copp_idx]);
-
-	rc = adm_arrange_mch_map(&open, ADM_PATH_PLAYBACK,
-		mfc_cfg.num_channels);
-	if (rc < 0) {
-		pr_err("%s: unable to get channal map\n", __func__);
-		goto fail_cmd;
-	}
-
-	for (i = 0; i < mfc_cfg.num_channels; i++)
-		mfc_cfg.channel_type[i] =
-			(uint16_t) open.dev_channel_mapping[i];
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-
-	pr_debug("%s: mfc config: port_idx %d copp_idx  %d copp SR %d copp BW %d copp chan %d o/p SR %d\n",
-			__func__, port_idx, copp_idx,
-			atomic_read(&this_adm.copp.rate[port_idx][copp_idx]),
-			mfc_cfg.bits_per_sample, mfc_cfg.num_channels,
-			mfc_cfg.sampling_rate);
-
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&mfc_cfg);
-
-	if (rc < 0) {
-		pr_err("%s: port_id: for[0x%x] failed %d\n",
-		__func__, port_id, rc);
-		goto fail_cmd;
-	}
-	/* Wait for the callback with copp id */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat
-		[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: mfc_cfg Set params timed out for port_id: for [0x%x]\n",
-					__func__, port_id);
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_adm.copp.stat
-			[port_idx][copp_idx])));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return;
-}
-
-static void route_set_opcode_matrix_id(
-			struct adm_cmd_matrix_map_routings_v5 **route_addr,
-			int path, uint32_t passthr_mode)
-{
-	struct adm_cmd_matrix_map_routings_v5 *route = *route_addr;
-
-	switch (path) {
-	case ADM_PATH_PLAYBACK:
-		route->hdr.opcode = ADM_CMD_MATRIX_MAP_ROUTINGS_V5;
-		route->matrix_id = ADM_MATRIX_ID_AUDIO_RX;
-		break;
-	case ADM_PATH_LIVE_REC:
-		if (passthr_mode == LISTEN) {
-			route->hdr.opcode =
-				ADM_CMD_STREAM_DEVICE_MAP_ROUTINGS_V5;
-			route->matrix_id = ADM_MATRIX_ID_LISTEN_TX;
-			break;
-		}
-		/* fall through to set matrix id for non-listen case */
-	case ADM_PATH_NONLIVE_REC:
-		route->hdr.opcode = ADM_CMD_MATRIX_MAP_ROUTINGS_V5;
-		route->matrix_id = ADM_MATRIX_ID_AUDIO_TX;
-		break;
-	case ADM_PATH_COMPRESSED_RX:
-		route->hdr.opcode = ADM_CMD_STREAM_DEVICE_MAP_ROUTINGS_V5;
-		route->matrix_id = ADM_MATRIX_ID_COMPRESSED_AUDIO_RX;
-		break;
-	case ADM_PATH_COMPRESSED_TX:
-		route->hdr.opcode = ADM_CMD_STREAM_DEVICE_MAP_ROUTINGS_V5;
-		route->matrix_id = ADM_MATRIX_ID_COMPRESSED_AUDIO_TX;
-		break;
-	default:
-		pr_err("%s: Wrong path set[%d]\n", __func__, path);
-		break;
-	}
-	pr_debug("%s: opcode 0x%x, matrix id %d\n",
-		 __func__, route->hdr.opcode, route->matrix_id);
-}
-
-int adm_matrix_map(int path, struct route_payload payload_map, int perf_mode,
-			uint32_t passthr_mode)
-{
-	struct adm_cmd_matrix_map_routings_v5	*route;
-	struct adm_session_map_node_v5 *node;
-	uint16_t *copps_list;
-	int cmd_size = 0;
-	int ret = 0, i = 0;
-	void *payload = NULL;
-	void *matrix_map = NULL;
-	int port_idx, copp_idx;
-
-	/* Assumes port_ids have already been validated during adm_open */
-	cmd_size = (sizeof(struct adm_cmd_matrix_map_routings_v5) +
-			sizeof(struct adm_session_map_node_v5) +
-			(sizeof(uint32_t) * payload_map.num_copps));
-	matrix_map = kzalloc(cmd_size, GFP_KERNEL);
-	if (matrix_map == NULL) {
-		pr_err("%s: Mem alloc failed\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-	route = (struct adm_cmd_matrix_map_routings_v5 *)matrix_map;
-
-	route->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	route->hdr.pkt_size = cmd_size;
-	route->hdr.src_svc = 0;
-	route->hdr.src_domain = APR_DOMAIN_APPS;
-	route->hdr.src_port = 0; /* Ignored */;
-	route->hdr.dest_svc = APR_SVC_ADM;
-	route->hdr.dest_domain = APR_DOMAIN_ADSP;
-	route->hdr.dest_port = 0; /* Ignored */;
-	route->hdr.token = 0;
-	route->num_sessions = 1;
-	route_set_opcode_matrix_id(&route, path, passthr_mode);
-
-	payload = ((u8 *)matrix_map +
-			sizeof(struct adm_cmd_matrix_map_routings_v5));
-	node = (struct adm_session_map_node_v5 *)payload;
-
-	node->session_id = payload_map.session_id;
-	node->num_copps = payload_map.num_copps;
-	payload = (u8 *)node + sizeof(struct adm_session_map_node_v5);
-	copps_list = (uint16_t *)payload;
-	for (i = 0; i < payload_map.num_copps; i++) {
-		port_idx =
-		adm_validate_and_get_port_index(payload_map.port_id[i]);
-		if (port_idx < 0) {
-			pr_err("%s: Invalid port_id 0x%x\n", __func__,
-				payload_map.port_id[i]);
-			ret = -EINVAL;
-			goto fail_cmd;
-		}
-		copp_idx = payload_map.copp_idx[i];
-		copps_list[i] = atomic_read(&this_adm.copp.id[port_idx]
-							     [copp_idx]);
-	}
-	atomic_set(&this_adm.matrix_map_stat, -1);
-
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)matrix_map);
-	if (ret < 0) {
-		pr_err("%s: routing for syream %d failed ret %d\n",
-			__func__, payload_map.session_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	ret = wait_event_timeout(this_adm.matrix_map_wait,
-				atomic_read(&this_adm.matrix_map_stat) >= 0,
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: routing for syream %d failed\n", __func__,
-			payload_map.session_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.matrix_map_stat) > 0) {
-		pr_err("%s: DSP returned error[%s]\n", __func__,
-			adsp_err_get_err_str(atomic_read(
-			&this_adm.matrix_map_stat)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.matrix_map_stat));
-		goto fail_cmd;
-	}
-
-	if ((perf_mode != ULTRA_LOW_LATENCY_PCM_MODE) &&
-		 (path != ADM_PATH_COMPRESSED_RX)) {
-		for (i = 0; i < payload_map.num_copps; i++) {
-			port_idx = afe_get_port_index(payload_map.port_id[i]);
-			copp_idx = payload_map.copp_idx[i];
-			if (port_idx < 0 || copp_idx < 0 ||
-			    (copp_idx > MAX_COPPS_PER_PORT - 1)) {
-				pr_err("%s: Invalid idx port_idx %d copp_idx %d\n",
-					__func__, port_idx, copp_idx);
-				continue;
-			}
-			rtac_add_adm_device(payload_map.port_id[i],
-					    atomic_read(&this_adm.copp.id
-							[port_idx][copp_idx]),
-					    get_cal_path(path),
-					    payload_map.session_id,
-					    payload_map.app_type[i],
-					    payload_map.acdb_dev_id[i]);
-
-			if (!test_bit(ADM_STATUS_CALIBRATION_REQUIRED,
-				(void *)&this_adm.copp.adm_status[port_idx]
-								[copp_idx])) {
-				pr_debug("%s: adm copp[0x%x][%d] already sent",
-						__func__, port_idx, copp_idx);
-				continue;
-			}
-			send_adm_cal(payload_map.port_id[i], copp_idx,
-				     get_cal_path(path), perf_mode,
-				     payload_map.app_type[i],
-				     payload_map.acdb_dev_id[i],
-				     payload_map.sample_rate[i]);
-			/* ADM COPP calibration is already sent */
-			clear_bit(ADM_STATUS_CALIBRATION_REQUIRED,
-				(void *)&this_adm.copp.
-				adm_status[port_idx][copp_idx]);
-			pr_debug("%s: copp_id: %d\n", __func__,
-				 atomic_read(&this_adm.copp.id[port_idx]
-							      [copp_idx]));
-		}
-	}
-
-fail_cmd:
-	kfree(matrix_map);
-	return ret;
-}
-
-void adm_ec_ref_rx_id(int port_id)
-{
-	this_adm.ec_ref_rx = port_id;
-	pr_debug("%s: ec_ref_rx:%d\n", __func__, this_adm.ec_ref_rx);
-}
-
-void adm_num_ec_ref_rx_chans(int num_chans)
-{
-	this_adm.num_ec_ref_rx_chans = num_chans;
-	pr_debug("%s: num_ec_ref_rx_chans:%d\n",
-		__func__, this_adm.num_ec_ref_rx_chans);
-}
-
-void adm_ec_ref_rx_bit_width(int bit_width)
-{
-	this_adm.ec_ref_rx_bit_width = bit_width;
-	pr_debug("%s: ec_ref_rx_bit_width:%d\n",
-		__func__, this_adm.ec_ref_rx_bit_width);
-}
-
-void adm_ec_ref_rx_sampling_rate(int sampling_rate)
-{
-	this_adm.ec_ref_rx_sampling_rate = sampling_rate;
-	pr_debug("%s: ec_ref_rx_sampling_rate:%d\n",
-		__func__, this_adm.ec_ref_rx_sampling_rate);
-}
-
-int adm_close(int port_id, int perf_mode, int copp_idx)
-{
-	struct apr_hdr close;
-
-	int ret = 0, port_idx;
-	int copp_id = RESET_COPP_ID;
-
-	pr_debug("%s: port_id=0x%x perf_mode: %d copp_idx: %d\n", __func__,
-		 port_id, perf_mode, copp_idx);
-
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n",
-			__func__, port_id);
-		return -EINVAL;
-	}
-
-	if ((copp_idx < 0) || (copp_idx >= MAX_COPPS_PER_PORT)) {
-		pr_err("%s: Invalid copp idx: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	if (this_adm.copp.adm_delay[port_idx][copp_idx] && perf_mode
-		== LEGACY_PCM_MODE) {
-		atomic_set(&this_adm.copp.adm_delay_stat[port_idx][copp_idx],
-			   1);
-		this_adm.copp.adm_delay[port_idx][copp_idx] = 0;
-		wake_up(&this_adm.copp.adm_delay_wait[port_idx][copp_idx]);
-	}
-
-	atomic_dec(&this_adm.copp.cnt[port_idx][copp_idx]);
-	if (!(atomic_read(&this_adm.copp.cnt[port_idx][copp_idx]))) {
-		copp_id = adm_get_copp_id(port_idx, copp_idx);
-		pr_debug("%s: Closing ADM port_idx:%d copp_idx:%d copp_id:0x%x\n",
-			 __func__, port_idx, copp_idx, copp_id);
-		if ((!perf_mode) && (this_adm.outband_memmap.paddr != 0) &&
-		    (atomic_read(&this_adm.copp.topology[port_idx][copp_idx]) ==
-			SRS_TRUMEDIA_TOPOLOGY_ID)) {
-			atomic_set(&this_adm.mem_map_index,
-				ADM_SRS_TRUMEDIA);
-			ret = adm_memory_unmap_regions();
-			if (ret < 0) {
-				pr_err("%s: adm mem unmmap err %d",
-					__func__, ret);
-			} else {
-				atomic_set(&this_adm.mem_map_handles
-					   [ADM_SRS_TRUMEDIA], 0);
-			}
-		}
-
-
-		if ((afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) &&
-		    this_adm.sourceTrackingData.memmap.paddr) {
-			atomic_set(&this_adm.mem_map_index,
-				   ADM_MEM_MAP_INDEX_SOURCE_TRACKING);
-			ret = adm_memory_unmap_regions();
-			if (ret < 0) {
-				pr_err("%s: adm mem unmmap err %d",
-					__func__, ret);
-			}
-			msm_audio_ion_free(
-				this_adm.sourceTrackingData.ion_client,
-				this_adm.sourceTrackingData.ion_handle);
-			this_adm.sourceTrackingData.ion_client = NULL;
-			this_adm.sourceTrackingData.ion_handle = NULL;
-			this_adm.sourceTrackingData.memmap.size = 0;
-			this_adm.sourceTrackingData.memmap.kvaddr = NULL;
-			this_adm.sourceTrackingData.memmap.paddr = 0;
-			this_adm.sourceTrackingData.apr_cmd_status = -1;
-			atomic_set(&this_adm.mem_map_handles[
-					ADM_MEM_MAP_INDEX_SOURCE_TRACKING], 0);
-		}
-
-		close.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-		close.pkt_size = sizeof(close);
-		close.src_svc = APR_SVC_ADM;
-		close.src_domain = APR_DOMAIN_APPS;
-		close.src_port = port_id;
-		close.dest_svc = APR_SVC_ADM;
-		close.dest_domain = APR_DOMAIN_ADSP;
-		close.dest_port = copp_id;
-		close.token = port_idx << 16 | copp_idx;
-		close.opcode = ADM_CMD_DEVICE_CLOSE_V5;
-
-		atomic_set(&this_adm.copp.id[port_idx][copp_idx],
-			   RESET_COPP_ID);
-		atomic_set(&this_adm.copp.cnt[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.topology[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.mode[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-		atomic_set(&this_adm.copp.rate[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.channels[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.bit_width[port_idx][copp_idx], 0);
-		atomic_set(&this_adm.copp.app_type[port_idx][copp_idx], 0);
-
-		clear_bit(ADM_STATUS_CALIBRATION_REQUIRED,
-			(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
-
-		ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close);
-		if (ret < 0) {
-			pr_err("%s: ADM close failed %d\n", __func__, ret);
-			return -EINVAL;
-		}
-
-		ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-			atomic_read(&this_adm.copp.stat
-			[port_idx][copp_idx]) >= 0,
-			msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: ADM cmd Route timedout for port 0x%x\n",
-				__func__, port_id);
-			return -EINVAL;
-		} else if (atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]) > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-			return adsp_err_get_lnx_err_code(
-					atomic_read(&this_adm.copp.stat
-						[port_idx][copp_idx]));
-		}
-	}
-
-	if (perf_mode != ULTRA_LOW_LATENCY_PCM_MODE) {
-		pr_debug("%s: remove adm device from rtac\n", __func__);
-		rtac_remove_adm_device(port_id, copp_id);
-	}
-	return 0;
-}
-
-int send_rtac_audvol_cal(void)
-{
-	int ret = 0;
-	int ret2 = 0;
-	int i = 0;
-	int copp_idx, port_idx, acdb_id, app_id, path;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_audvol *audvol_cal_info = NULL;
-	struct rtac_adm rtac_adm_data;
-
-	mutex_lock(&this_adm.cal_data[ADM_RTAC_AUDVOL_CAL]->lock);
-
-	cal_block = cal_utils_get_only_cal_block(
-		this_adm.cal_data[ADM_RTAC_AUDVOL_CAL]);
-	if (cal_block == NULL) {
-		pr_err("%s: can't find cal block!\n", __func__);
-		goto unlock;
-	}
-
-	audvol_cal_info = cal_block->cal_info;
-	if (audvol_cal_info == NULL) {
-		pr_err("%s: audvol_cal_info is NULL!\n", __func__);
-		goto unlock;
-	}
-
-	get_rtac_adm_data(&rtac_adm_data);
-	for (; i < rtac_adm_data.num_of_dev; i++) {
-
-		acdb_id = rtac_adm_data.device[i].acdb_dev_id;
-		if (acdb_id == 0)
-			acdb_id = audvol_cal_info->acdb_id;
-
-		app_id = rtac_adm_data.device[i].app_type;
-		if (app_id == 0)
-			app_id = audvol_cal_info->app_type;
-
-		path = afe_get_port_type(rtac_adm_data.device[i].afe_port);
-		if ((acdb_id == audvol_cal_info->acdb_id) &&
-			(app_id == audvol_cal_info->app_type) &&
-			(path == audvol_cal_info->path)) {
-
-			if (adm_get_indexes_from_copp_id(rtac_adm_data.
-				device[i].copp, &copp_idx, &port_idx) != 0) {
-				pr_debug("%s: Copp Id %d is not active\n",
-					__func__,
-					rtac_adm_data.device[i].copp);
-				continue;
-			}
-
-			ret2 = adm_remap_and_send_cal_block(ADM_RTAC_AUDVOL_CAL,
-				rtac_adm_data.device[i].afe_port,
-				copp_idx, cal_block,
-				atomic_read(&this_adm.copp.
-				mode[port_idx][copp_idx]),
-				audvol_cal_info->app_type,
-				audvol_cal_info->acdb_id,
-				atomic_read(&this_adm.copp.
-				rate[port_idx][copp_idx]));
-			if (ret2 < 0) {
-				pr_debug("%s: remap and send failed for copp Id %d, acdb id %d, app type %d, path %d\n",
-					__func__, rtac_adm_data.device[i].copp,
-					audvol_cal_info->acdb_id,
-					audvol_cal_info->app_type,
-					audvol_cal_info->path);
-				ret = ret2;
-			}
-		}
-	}
-unlock:
-	mutex_unlock(&this_adm.cal_data[ADM_RTAC_AUDVOL_CAL]->lock);
-	return ret;
-}
-
-int adm_map_rtac_block(struct rtac_cal_block_data *cal_block)
-{
-	int result = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: map size is 0!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	/* valid port ID needed for callback use primary I2S */
-	atomic_set(&this_adm.mem_map_index, ADM_RTAC_APR_CAL);
-	result = adm_memory_map_regions(&cal_block->cal_data.paddr, 0,
-					&cal_block->map_data.map_size, 1);
-	if (result < 0) {
-		pr_err("%s: RTAC mmap did not work! size = %d result %d\n",
-			__func__,
-			cal_block->map_data.map_size, result);
-		pr_debug("%s: RTAC mmap did not work! addr = 0x%pK, size = %d\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-		goto done;
-	}
-
-	cal_block->map_data.map_handle = atomic_read(
-		&this_adm.mem_map_handles[ADM_RTAC_APR_CAL]);
-done:
-	return result;
-}
-
-int adm_unmap_rtac_block(uint32_t *mem_map_handle)
-{
-	int result = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (mem_map_handle == NULL) {
-		pr_debug("%s: Map handle is NULL, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	if (*mem_map_handle == 0) {
-		pr_debug("%s: Map handle is 0, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	if (*mem_map_handle != atomic_read(
-			&this_adm.mem_map_handles[ADM_RTAC_APR_CAL])) {
-		pr_err("%s: Map handles do not match! Unmapping RTAC, RTAC map 0x%x, ADM map 0x%x\n",
-			__func__, *mem_map_handle, atomic_read(
-			&this_adm.mem_map_handles[ADM_RTAC_APR_CAL]));
-
-		/* if mismatch use handle passed in to unmap */
-		atomic_set(&this_adm.mem_map_handles[ADM_RTAC_APR_CAL],
-			   *mem_map_handle);
-	}
-
-	/* valid port ID needed for callback use primary I2S */
-	atomic_set(&this_adm.mem_map_index, ADM_RTAC_APR_CAL);
-	result = adm_memory_unmap_regions();
-	if (result < 0) {
-		pr_debug("%s: adm_memory_unmap_regions failed, error %d\n",
-			__func__, result);
-	} else {
-		atomic_set(&this_adm.mem_map_handles[ADM_RTAC_APR_CAL], 0);
-		*mem_map_handle = 0;
-	}
-done:
-	return result;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case ADM_AUDPROC_CAL_TYPE:
-		ret = ADM_AUDPROC_CAL;
-		break;
-	case ADM_AUDVOL_CAL_TYPE:
-		ret = ADM_AUDVOL_CAL;
-		break;
-	case ADM_CUST_TOPOLOGY_CAL_TYPE:
-		ret = ADM_CUSTOM_TOP_CAL;
-		break;
-	case ADM_RTAC_INFO_CAL_TYPE:
-		ret = ADM_RTAC_INFO_CAL;
-		break;
-	case ADM_RTAC_APR_CAL_TYPE:
-		ret = ADM_RTAC_APR_CAL;
-		break;
-	case ADM_RTAC_AUDVOL_CAL_TYPE:
-		ret = ADM_RTAC_AUDVOL_CAL;
-		break;
-	default:
-		pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-static int adm_alloc_cal(int32_t cal_type, size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		this_adm.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int adm_dealloc_cal(int32_t cal_type, size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-		this_adm.cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int adm_set_cal(int32_t cal_type, size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-		this_adm.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_index == ADM_CUSTOM_TOP_CAL) {
-		mutex_lock(&this_adm.cal_data[ADM_CUSTOM_TOP_CAL]->lock);
-		this_adm.set_custom_topology = 1;
-		mutex_unlock(&this_adm.cal_data[ADM_CUSTOM_TOP_CAL]->lock);
-	} else if (cal_index == ADM_RTAC_AUDVOL_CAL) {
-		send_rtac_audvol_cal();
-	}
-done:
-	return ret;
-}
-
-static int adm_map_cal_data(int32_t cal_type,
-			struct cal_block_data *cal_block)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	atomic_set(&this_adm.mem_map_index, cal_index);
-	ret = adm_memory_map_regions(&cal_block->cal_data.paddr, 0,
-		(uint32_t *)&cal_block->map_data.map_size, 1);
-	if (ret < 0) {
-		pr_err("%s: map did not work! cal_type %i ret %d\n",
-			__func__, cal_index, ret);
-		ret = -ENODEV;
-		goto done;
-	}
-	cal_block->map_data.q6map_handle = atomic_read(&this_adm.
-		mem_map_handles[cal_index]);
-done:
-	return ret;
-}
-
-static int adm_unmap_cal_data(int32_t cal_type,
-			struct cal_block_data *cal_block)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block == NULL) {
-		pr_err("%s: Cal block is NULL!\n",
-						__func__);
-		goto done;
-	}
-
-	if (cal_block->map_data.q6map_handle == 0) {
-		pr_err("%s: Map handle is NULL, nothing to unmap\n",
-				__func__);
-		goto done;
-	}
-
-	atomic_set(&this_adm.mem_map_handles[cal_index],
-		cal_block->map_data.q6map_handle);
-	atomic_set(&this_adm.mem_map_index, cal_index);
-	ret = adm_memory_unmap_regions();
-	if (ret < 0) {
-		pr_err("%s: unmap did not work! cal_type %i ret %d\n",
-			__func__, cal_index, ret);
-		ret = -ENODEV;
-		goto done;
-	}
-	cal_block->map_data.q6map_handle = 0;
-done:
-	return ret;
-}
-
-static void adm_delete_cal_data(void)
-{
-	pr_debug("%s:\n", __func__);
-
-	cal_utils_destroy_cal_types(ADM_MAX_CAL_TYPES, this_adm.cal_data);
-}
-
-static int adm_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info	cal_type_info[] = {
-		{{ADM_CUST_TOPOLOGY_CAL_TYPE,
-		{adm_alloc_cal, adm_dealloc_cal, NULL,
-		adm_set_cal, NULL, NULL} },
-		{adm_map_cal_data, adm_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{ADM_AUDPROC_CAL_TYPE,
-		{adm_alloc_cal, adm_dealloc_cal, NULL,
-		adm_set_cal, NULL, NULL} },
-		{adm_map_cal_data, adm_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{ADM_AUDVOL_CAL_TYPE,
-		{adm_alloc_cal, adm_dealloc_cal, NULL,
-		adm_set_cal, NULL, NULL} },
-		{adm_map_cal_data, adm_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{ADM_RTAC_INFO_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{ADM_RTAC_APR_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{SRS_TRUMEDIA_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{ADM_RTAC_AUDVOL_CAL_TYPE,
-		{adm_alloc_cal, adm_dealloc_cal, NULL,
-		adm_set_cal, NULL, NULL} },
-		{adm_map_cal_data, adm_unmap_cal_data,
-		cal_utils_match_buf_num} },
-	};
-	pr_debug("%s:\n", __func__);
-
-	ret = cal_utils_create_cal_types(ADM_MAX_CAL_TYPES, this_adm.cal_data,
-		cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type! ret %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	adm_delete_cal_data();
-	return ret;
-}
-
-int adm_set_volume(int port_id, int copp_idx, int volume)
-{
-	struct audproc_volume_ctrl_master_gain audproc_vol;
-	int sz = 0;
-	int rc  = 0;
-	int port_idx;
-
-	pr_debug("%s: port_id %d, volume %d\n", __func__, port_id, volume);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct audproc_volume_ctrl_master_gain);
-	audproc_vol.params.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	audproc_vol.params.hdr.pkt_size = sz;
-	audproc_vol.params.hdr.src_svc = APR_SVC_ADM;
-	audproc_vol.params.hdr.src_domain = APR_DOMAIN_APPS;
-	audproc_vol.params.hdr.src_port = port_id;
-	audproc_vol.params.hdr.dest_svc = APR_SVC_ADM;
-	audproc_vol.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	audproc_vol.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	audproc_vol.params.hdr.token = port_idx << 16 | copp_idx;
-	audproc_vol.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	audproc_vol.params.payload_addr_lsw = 0;
-	audproc_vol.params.payload_addr_msw = 0;
-	audproc_vol.params.mem_map_handle = 0;
-	audproc_vol.params.payload_size = sizeof(audproc_vol) -
-				sizeof(audproc_vol.params);
-	audproc_vol.data.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
-	audproc_vol.data.param_id = AUDPROC_PARAM_ID_VOL_CTRL_MASTER_GAIN;
-	audproc_vol.data.param_size = audproc_vol.params.payload_size -
-						sizeof(audproc_vol.data);
-	audproc_vol.data.reserved = 0;
-	audproc_vol.master_gain = volume;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&audproc_vol);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Vol cntrl Set params timed out port = %#x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int adm_set_softvolume(int port_id, int copp_idx,
-			struct audproc_softvolume_params *softvol_param)
-{
-	struct audproc_soft_step_volume_params audproc_softvol;
-	int sz = 0;
-	int rc  = 0;
-	int port_idx;
-
-	pr_debug("%s: period %d step %d curve %d\n", __func__,
-		 softvol_param->period, softvol_param->step,
-		 softvol_param->rampingcurve);
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct audproc_soft_step_volume_params);
-
-	audproc_softvol.params.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	audproc_softvol.params.hdr.pkt_size = sz;
-	audproc_softvol.params.hdr.src_svc = APR_SVC_ADM;
-	audproc_softvol.params.hdr.src_domain = APR_DOMAIN_APPS;
-	audproc_softvol.params.hdr.src_port = port_id;
-	audproc_softvol.params.hdr.dest_svc = APR_SVC_ADM;
-	audproc_softvol.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	audproc_softvol.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	audproc_softvol.params.hdr.token = port_idx << 16 | copp_idx;
-	audproc_softvol.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	audproc_softvol.params.payload_addr_lsw = 0;
-	audproc_softvol.params.payload_addr_msw = 0;
-	audproc_softvol.params.mem_map_handle = 0;
-	audproc_softvol.params.payload_size = sizeof(audproc_softvol) -
-				sizeof(audproc_softvol.params);
-	audproc_softvol.data.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
-	audproc_softvol.data.param_id =
-			AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
-	audproc_softvol.data.param_size = audproc_softvol.params.payload_size -
-				sizeof(audproc_softvol.data);
-	audproc_softvol.data.reserved = 0;
-	audproc_softvol.period = softvol_param->period;
-	audproc_softvol.step = softvol_param->step;
-	audproc_softvol.ramping_curve = softvol_param->rampingcurve;
-
-	pr_debug("%s: period %d, step %d, curve %d\n", __func__,
-		 audproc_softvol.period, audproc_softvol.step,
-		 audproc_softvol.ramping_curve);
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&audproc_softvol);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Soft volume Set params timed out port = %#x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int adm_set_mic_gain(int port_id, int copp_idx, int volume)
-{
-	struct adm_set_mic_gain_params	mic_gain_params;
-	int rc = 0;
-	int sz, port_idx;
-
-	pr_debug("%s:\n", __func__);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_set_mic_gain_params);
-
-	mic_gain_params.params.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mic_gain_params.params.hdr.pkt_size = sz;
-	mic_gain_params.params.hdr.src_svc = APR_SVC_ADM;
-	mic_gain_params.params.hdr.src_domain = APR_DOMAIN_APPS;
-	mic_gain_params.params.hdr.src_port = port_id;
-	mic_gain_params.params.hdr.dest_svc = APR_SVC_ADM;
-	mic_gain_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	mic_gain_params.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	mic_gain_params.params.hdr.token = port_idx << 16 | copp_idx;
-	mic_gain_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	mic_gain_params.params.payload_addr_lsw = 0;
-	mic_gain_params.params.payload_addr_msw = 0;
-	mic_gain_params.params.mem_map_handle = 0;
-	mic_gain_params.params.payload_size =
-		sizeof(struct adm_param_data_v5) +
-		sizeof(struct admx_mic_gain);
-	mic_gain_params.data.module_id = ADM_MODULE_IDX_MIC_GAIN_CTRL;
-	mic_gain_params.data.param_id = ADM_PARAM_IDX_MIC_GAIN;
-	mic_gain_params.data.param_size =
-		sizeof(struct admx_mic_gain);
-	mic_gain_params.data.reserved = 0;
-	mic_gain_params.mic_gain_data.tx_mic_gain = volume;
-	mic_gain_params.mic_gain_data.reserved = 0;
-	pr_debug("%s: Mic Gain set to %d at port_id 0x%x\n",
-		__func__, volume, port_id);
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&mic_gain_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Mic Gain Set params timed out port = %#x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx,
-			int primary_mic_ch)
-{
-	struct adm_set_sec_primary_ch_params sec_primary_ch_params;
-	int rc = 0;
-	int sz, port_idx;
-
-	pr_debug("%s port_id 0x%x, copp_idx 0x%x, primary_mic_ch %d\n",
-			__func__, port_id,  copp_idx,  primary_mic_ch);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct adm_set_sec_primary_ch_params);
-
-	sec_primary_ch_params.params.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	sec_primary_ch_params.params.hdr.pkt_size = sz;
-	sec_primary_ch_params.params.hdr.src_svc = APR_SVC_ADM;
-	sec_primary_ch_params.params.hdr.src_domain = APR_DOMAIN_APPS;
-	sec_primary_ch_params.params.hdr.src_port = port_id;
-	sec_primary_ch_params.params.hdr.dest_svc = APR_SVC_ADM;
-	sec_primary_ch_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	sec_primary_ch_params.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	sec_primary_ch_params.params.hdr.token = port_idx << 16 | copp_idx;
-	sec_primary_ch_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	sec_primary_ch_params.params.payload_addr_lsw = 0;
-	sec_primary_ch_params.params.payload_addr_msw = 0;
-	sec_primary_ch_params.params.mem_map_handle = 0;
-	sec_primary_ch_params.params.payload_size =
-			sizeof(struct adm_param_data_v5) +
-			sizeof(struct admx_sec_primary_mic_ch);
-	sec_primary_ch_params.data.module_id =
-			AUDPROC_MODULE_ID_VOICE_TX_SECNS;
-	sec_primary_ch_params.data.param_id =
-			AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH;
-	sec_primary_ch_params.data.param_size =
-			sizeof(struct admx_sec_primary_mic_ch);
-	sec_primary_ch_params.data.reserved = 0;
-	sec_primary_ch_params.sec_primary_mic_ch_data.version = 0;
-	sec_primary_ch_params.sec_primary_mic_ch_data.reserved = 0;
-	sec_primary_ch_params.sec_primary_mic_ch_data.sec_primary_mic_ch =
-			primary_mic_ch;
-	sec_primary_ch_params.sec_primary_mic_ch_data.reserved1 = 0;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&sec_primary_ch_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-				__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Mic Set params timed out port = %#x\n",
-				__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int adm_param_enable(int port_id, int copp_idx, int module_id,  int enable)
-{
-	struct audproc_enable_param_t adm_mod_enable;
-	int sz = 0;
-	int rc  = 0;
-	int port_idx;
-
-	pr_debug("%s port_id %d, module_id 0x%x, enable %d\n",
-		 __func__, port_id,  module_id,  enable);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	sz = sizeof(struct audproc_enable_param_t);
-
-	adm_mod_enable.pp_params.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_mod_enable.pp_params.hdr.pkt_size = sz;
-	adm_mod_enable.pp_params.hdr.src_svc = APR_SVC_ADM;
-	adm_mod_enable.pp_params.hdr.src_domain = APR_DOMAIN_APPS;
-	adm_mod_enable.pp_params.hdr.src_port = port_id;
-	adm_mod_enable.pp_params.hdr.dest_svc = APR_SVC_ADM;
-	adm_mod_enable.pp_params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_mod_enable.pp_params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_mod_enable.pp_params.hdr.token =  port_idx << 16 | copp_idx;
-	adm_mod_enable.pp_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	adm_mod_enable.pp_params.payload_addr_lsw = 0;
-	adm_mod_enable.pp_params.payload_addr_msw = 0;
-	adm_mod_enable.pp_params.mem_map_handle = 0;
-	adm_mod_enable.pp_params.payload_size = sizeof(adm_mod_enable) -
-				sizeof(adm_mod_enable.pp_params) +
-				sizeof(adm_mod_enable.pp_params.params);
-	adm_mod_enable.pp_params.params.module_id = module_id;
-	adm_mod_enable.pp_params.params.param_id = AUDPROC_PARAM_ID_ENABLE;
-	adm_mod_enable.pp_params.params.param_size =
-		adm_mod_enable.pp_params.payload_size -
-		sizeof(adm_mod_enable.pp_params.params);
-	adm_mod_enable.pp_params.params.reserved = 0;
-	adm_mod_enable.enable = enable;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_mod_enable);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s:  module %x  enable %d timed out on port = %#x\n",
-			 __func__, module_id, enable, port_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-
-}
-
-int adm_send_calibration(int port_id, int copp_idx, int path, int perf_mode,
-			 int cal_type, char *params, int size)
-{
-
-	struct adm_cmd_set_pp_params_v5	*adm_params = NULL;
-	int sz, rc = 0;
-	int port_idx;
-
-	pr_debug("%s:port_id %d, path %d, perf_mode %d, cal_type %d, size %d\n",
-		 __func__, port_id, path, perf_mode, cal_type, size);
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	/* Maps audio_dev_ctrl path definition to ACDB definition */
-	if (get_cal_path(path) != RX_DEVICE) {
-		pr_err("%s: acdb_path %d\n", __func__, path);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	sz = sizeof(struct adm_cmd_set_pp_params_v5) + size;
-	adm_params = kzalloc(sz, GFP_KERNEL);
-	if (!adm_params) {
-		pr_err("%s, adm params memory alloc failed", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
-			params, size);
-
-	adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	adm_params->hdr.pkt_size = sz;
-	adm_params->hdr.src_svc = APR_SVC_ADM;
-	adm_params->hdr.src_domain = APR_DOMAIN_APPS;
-	adm_params->hdr.src_port = port_id;
-	adm_params->hdr.dest_svc = APR_SVC_ADM;
-	adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
-	adm_params->hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	adm_params->hdr.token = port_idx << 16 | copp_idx;
-	adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	/* payload address and mmap handle initialized to zero by kzalloc */
-	adm_params->payload_size = size;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
-	if (rc < 0) {
-		pr_err("%s: Set params failed port = %#x\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto end;
-	}
-	/* Wait for the callback */
-	rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!rc) {
-		pr_err("%s: Set params timed out port = %#x\n",
-			 __func__, port_id);
-		rc = -EINVAL;
-		goto end;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto end;
-	}
-	rc = 0;
-
-end:
-	kfree(adm_params);
-	return rc;
-}
-
-/*
- * adm_update_wait_parameters must be called with routing driver locks.
- * adm_reset_wait_parameters must be called with routing driver locks.
- * set and reset parmeters are separated to make sure it is always called
- * under routing driver lock.
- * adm_wait_timeout is to block until timeout or interrupted. Timeout is
- * not a an error.
- */
-int adm_set_wait_parameters(int port_id, int copp_idx)
-{
-
-	int ret = 0, port_idx;
-
-	pr_debug("%s: port_id 0x%x, copp_idx %d\n", __func__, port_id,
-		 copp_idx);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	this_adm.copp.adm_delay[port_idx][copp_idx] = 1;
-	atomic_set(&this_adm.copp.adm_delay_stat[port_idx][copp_idx], 0);
-
-end:
-	return ret;
-
-}
-
-int adm_reset_wait_parameters(int port_id, int copp_idx)
-{
-	int ret = 0, port_idx;
-
-	pr_debug("%s: port_id 0x%x copp_idx %d\n", __func__, port_id,
-		 copp_idx);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	atomic_set(&this_adm.copp.adm_delay_stat[port_idx][copp_idx], 1);
-	this_adm.copp.adm_delay[port_idx][copp_idx] = 0;
-
-end:
-	return ret;
-}
-
-int adm_wait_timeout(int port_id, int copp_idx, int wait_time)
-{
-	int ret = 0, port_idx;
-
-	pr_debug("%s: port_id 0x%x, copp_idx %d, wait_time %d\n", __func__,
-		 port_id, copp_idx, wait_time);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	ret = wait_event_timeout(
-		this_adm.copp.adm_delay_wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.adm_delay_stat[port_idx][copp_idx]),
-		msecs_to_jiffies(wait_time));
-	pr_debug("%s: return %d\n", __func__, ret);
-	if (ret != 0)
-		ret = -EINTR;
-end:
-	pr_debug("%s: return %d--\n", __func__, ret);
-	return ret;
-}
-
-int adm_store_cal_data(int port_id, int copp_idx, int path, int perf_mode,
-		       int cal_index, char *params, int *size)
-{
-	int rc = 0;
-	struct cal_block_data		*cal_block = NULL;
-	int app_type, acdb_id, port_idx, sample_rate;
-
-	if (this_adm.cal_data[cal_index] == NULL) {
-		pr_debug("%s: cal_index %d not allocated!\n",
-			__func__, cal_index);
-		goto end;
-	}
-
-	if (get_cal_path(path) != RX_DEVICE) {
-		pr_debug("%s: Invalid path to store calibration %d\n",
-			 __func__, path);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		rc = -EINVAL;
-		goto end;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		return -EINVAL;
-	}
-
-	acdb_id = atomic_read(&this_adm.copp.acdb_id[port_idx][copp_idx]);
-	app_type = atomic_read(&this_adm.copp.app_type[port_idx][copp_idx]);
-	sample_rate = atomic_read(&this_adm.copp.rate[port_idx][copp_idx]);
-
-	mutex_lock(&this_adm.cal_data[cal_index]->lock);
-	cal_block = adm_find_cal(cal_index, get_cal_path(path), app_type,
-				acdb_id, sample_rate);
-	if (cal_block == NULL)
-		goto unlock;
-
-	if (cal_block->cal_data.size <= 0) {
-		pr_debug("%s: No ADM cal send for port_id = 0x%x!\n",
-			__func__, port_id);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	if (cal_index == ADM_AUDPROC_CAL) {
-		if (cal_block->cal_data.size > AUD_PROC_BLOCK_SIZE) {
-			pr_err("%s:audproc:invalid size exp/actual[%zd, %d]\n",
-				__func__, cal_block->cal_data.size, *size);
-			rc = -ENOMEM;
-			goto unlock;
-		}
-	} else if (cal_index == ADM_AUDVOL_CAL) {
-		if (cal_block->cal_data.size > AUD_VOL_BLOCK_SIZE) {
-			pr_err("%s:aud_vol:invalid size exp/actual[%zd, %d]\n",
-				__func__, cal_block->cal_data.size, *size);
-			rc = -ENOMEM;
-			goto unlock;
-		}
-	} else {
-		pr_debug("%s: Not valid calibration for dolby topolgy\n",
-			 __func__);
-		rc = -EINVAL;
-		goto unlock;
-	}
-	memcpy(params, cal_block->cal_data.kvaddr, cal_block->cal_data.size);
-	*size = cal_block->cal_data.size;
-
-	pr_debug("%s:port_id %d, copp_idx %d, path %d",
-		 __func__, port_id, copp_idx, path);
-	pr_debug("perf_mode %d, cal_type %d, size %d\n",
-		 perf_mode, cal_index, *size);
-
-unlock:
-	mutex_unlock(&this_adm.cal_data[cal_index]->lock);
-end:
-	return rc;
-}
-
-int adm_send_compressed_device_mute(int port_id, int copp_idx, bool mute_on)
-{
-	struct adm_set_compressed_device_mute mute_params;
-	int ret = 0;
-	int port_idx;
-
-	pr_debug("%s port_id: 0x%x, copp_idx %d, mute_on: %d\n",
-		 __func__, port_id, copp_idx, mute_on);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid port_id %#x copp_idx %d\n",
-			__func__, port_id, copp_idx);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	mute_params.command.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mute_params.command.hdr.pkt_size =
-			sizeof(struct adm_set_compressed_device_mute);
-	mute_params.command.hdr.src_svc = APR_SVC_ADM;
-	mute_params.command.hdr.src_domain = APR_DOMAIN_APPS;
-	mute_params.command.hdr.src_port = port_id;
-	mute_params.command.hdr.dest_svc = APR_SVC_ADM;
-	mute_params.command.hdr.dest_domain = APR_DOMAIN_ADSP;
-	mute_params.command.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	mute_params.command.hdr.token = port_idx << 16 | copp_idx;
-	mute_params.command.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	mute_params.command.payload_addr_lsw = 0;
-	mute_params.command.payload_addr_msw = 0;
-	mute_params.command.mem_map_handle = 0;
-	mute_params.command.payload_size = sizeof(mute_params) -
-						sizeof(mute_params.command);
-	mute_params.params.module_id = AUDPROC_MODULE_ID_COMPRESSED_MUTE;
-	mute_params.params.param_id = AUDPROC_PARAM_ID_COMPRESSED_MUTE;
-	mute_params.params.param_size = mute_params.command.payload_size -
-					sizeof(mute_params.params);
-	mute_params.params.reserved = 0;
-	mute_params.mute_on = mute_on;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&mute_params);
-	if (ret < 0) {
-		pr_err("%s: device mute for port %d copp %d failed, ret %d\n",
-			__func__, port_id, copp_idx, ret);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	/* Wait for the callback */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: send device mute for port %d copp %d failed\n",
-			__func__, port_id, copp_idx);
-		ret = -EINVAL;
-		goto end;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto end;
-	}
-	ret = 0;
-end:
-	return ret;
-}
-
-int adm_send_compressed_device_latency(int port_id, int copp_idx, int latency)
-{
-	struct adm_set_compressed_device_latency latency_params;
-	int port_idx;
-	int ret = 0;
-
-	pr_debug("%s port_id: 0x%x, copp_idx %d latency: %d\n", __func__,
-		 port_id, copp_idx, latency);
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid port_id %#x copp_idx %d\n",
-			__func__, port_id, copp_idx);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	latency_params.command.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	latency_params.command.hdr.pkt_size =
-			sizeof(struct adm_set_compressed_device_latency);
-	latency_params.command.hdr.src_svc = APR_SVC_ADM;
-	latency_params.command.hdr.src_domain = APR_DOMAIN_APPS;
-	latency_params.command.hdr.src_port = port_id;
-	latency_params.command.hdr.dest_svc = APR_SVC_ADM;
-	latency_params.command.hdr.dest_domain = APR_DOMAIN_ADSP;
-	latency_params.command.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	latency_params.command.hdr.token = port_idx << 16 | copp_idx;
-	latency_params.command.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	latency_params.command.payload_addr_lsw = 0;
-	latency_params.command.payload_addr_msw = 0;
-	latency_params.command.mem_map_handle = 0;
-	latency_params.command.payload_size = sizeof(latency_params) -
-						sizeof(latency_params.command);
-	latency_params.params.module_id = AUDPROC_MODULE_ID_COMPRESSED_LATENCY;
-	latency_params.params.param_id = AUDPROC_PARAM_ID_COMPRESSED_LATENCY;
-	latency_params.params.param_size = latency_params.command.payload_size -
-					sizeof(latency_params.params);
-	latency_params.params.reserved = 0;
-	latency_params.latency = latency;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&latency_params);
-	if (ret < 0) {
-		pr_err("%s: send device latency err %d for port %d copp %d\n",
-			__func__, port_id, copp_idx, ret);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	/* Wait for the callback */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: send device latency for port %d failed\n", __func__,
-			port_id);
-		ret = -EINVAL;
-		goto end;
-	} else if (atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[port_idx][copp_idx]));
-		goto end;
-	}
-	ret = 0;
-end:
-	return ret;
-}
-
-/**
- * adm_swap_speaker_channels
- *
- * Receives port_id, copp_idx, sample rate, spk_swap and
- * send MFC command to swap speaker channel.
- * Return zero on success. On failure returns nonzero.
- *
- * port_id - Passed value, port_id for which channels swap is wanted
- * copp_idx - Passed value, copp_idx for which channels swap is wanted
- * sample_rate - Passed value, sample rate used by app type config
- * spk_swap  - Passed value, spk_swap for check if swap flag is set
- */
-int adm_swap_speaker_channels(int port_id, int copp_idx,
-			int sample_rate, bool spk_swap)
-{
-	struct audproc_mfc_output_media_fmt mfc_cfg;
-	uint16_t num_channels;
-	int port_idx;
-	int ret  = 0;
-
-	pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
-		  __func__, port_id, copp_idx);
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	num_channels = atomic_read(
-				&this_adm.copp.channels[port_idx][copp_idx]);
-	if (num_channels != 2) {
-		pr_debug("%s: Invalid number of channels: %d\n",
-			__func__, num_channels);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memset(&mfc_cfg, 0, sizeof(mfc_cfg));
-	mfc_cfg.params.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mfc_cfg.params.hdr.pkt_size =
-				sizeof(mfc_cfg);
-	mfc_cfg.params.hdr.src_svc = APR_SVC_ADM;
-	mfc_cfg.params.hdr.src_domain = APR_DOMAIN_APPS;
-	mfc_cfg.params.hdr.src_port = port_id;
-	mfc_cfg.params.hdr.dest_svc = APR_SVC_ADM;
-	mfc_cfg.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	mfc_cfg.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	mfc_cfg.params.hdr.token = port_idx << 16 | copp_idx;
-	mfc_cfg.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	mfc_cfg.params.payload_addr_lsw = 0;
-	mfc_cfg.params.payload_addr_msw = 0;
-	mfc_cfg.params.mem_map_handle = 0;
-	mfc_cfg.params.payload_size = sizeof(mfc_cfg) -
-				sizeof(mfc_cfg.params);
-	mfc_cfg.data.module_id = AUDPROC_MODULE_ID_MFC;
-	mfc_cfg.data.param_id = AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
-	mfc_cfg.data.param_size = mfc_cfg.params.payload_size -
-				sizeof(mfc_cfg.data);
-	mfc_cfg.data.reserved = 0;
-	mfc_cfg.sampling_rate = sample_rate;
-	mfc_cfg.bits_per_sample =
-		atomic_read(&this_adm.copp.bit_width[port_idx][copp_idx]);
-	mfc_cfg.num_channels = num_channels;
-
-	/* Currently applying speaker swap for only 2 channel use case */
-	if (spk_swap) {
-		mfc_cfg.channel_type[0] =
-			(uint16_t) PCM_CHANNEL_FR;
-		mfc_cfg.channel_type[1] =
-			(uint16_t) PCM_CHANNEL_FL;
-	} else {
-		mfc_cfg.channel_type[0] =
-			(uint16_t) PCM_CHANNEL_FL;
-		mfc_cfg.channel_type[1] =
-			(uint16_t) PCM_CHANNEL_FR;
-	}
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	pr_debug("%s: mfc config: port_idx %d copp_idx  %d copp SR %d copp BW %d copp chan %d\n",
-		__func__, port_idx, copp_idx, mfc_cfg.sampling_rate,
-		mfc_cfg.bits_per_sample, mfc_cfg.num_channels);
-
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&mfc_cfg);
-	if (ret < 0) {
-		pr_err("%s: port_id: for[0x%x] failed %d\n",
-		__func__, port_id, ret);
-		goto done;
-	}
-	/* Wait for the callback with copp id */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat
-		[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: mfc_cfg Set params timed out for port_id: for [0x%x]\n",
-					__func__, port_id);
-		ret = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_adm.copp.stat
-			[port_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-			atomic_read(&this_adm.copp.stat
-				[port_idx][copp_idx]));
-		goto done;
-	}
-
-	pr_debug("%s: mfc_cfg Set params returned success", __func__);
-	ret = 0;
-
-done:
-	return ret;
-}
-EXPORT_SYMBOL(adm_swap_speaker_channels);
-
-int adm_set_sound_focus(int port_id, int copp_idx,
-			struct sound_focus_param soundFocusData)
-{
-	struct adm_set_fluence_soundfocus_param soundfocus_params;
-	int sz = 0;
-	int ret  = 0;
-	int port_idx;
-	int i;
-
-	pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
-		  __func__, port_id, copp_idx);
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	port_idx = adm_validate_and_get_port_index(port_id);
-	if (port_idx < 0) {
-		pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
-		pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	sz = sizeof(struct adm_set_fluence_soundfocus_param);
-	soundfocus_params.params.hdr.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
-			      APR_PKT_VER);
-	soundfocus_params.params.hdr.pkt_size = sz;
-	soundfocus_params.params.hdr.src_svc = APR_SVC_ADM;
-	soundfocus_params.params.hdr.src_domain = APR_DOMAIN_APPS;
-	soundfocus_params.params.hdr.src_port = port_id;
-	soundfocus_params.params.hdr.dest_svc = APR_SVC_ADM;
-	soundfocus_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
-	soundfocus_params.params.hdr.dest_port =
-			atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
-	soundfocus_params.params.hdr.token = port_idx << 16 |
-				ADM_CLIENT_ID_SOURCE_TRACKING << 8 | copp_idx;
-	soundfocus_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
-	soundfocus_params.params.payload_addr_lsw = 0;
-	soundfocus_params.params.payload_addr_msw = 0;
-	soundfocus_params.params.mem_map_handle = 0;
-	soundfocus_params.params.payload_size = sizeof(soundfocus_params) -
-				sizeof(soundfocus_params.params);
-	soundfocus_params.data.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
-	soundfocus_params.data.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS;
-	soundfocus_params.data.param_size =
-		soundfocus_params.params.payload_size -
-		sizeof(soundfocus_params.data);
-	soundfocus_params.data.reserved = 0;
-
-	memset(&(soundfocus_params.soundfocus_data), 0xFF,
-		sizeof(struct adm_param_fluence_soundfocus_t));
-	for (i = 0; i < MAX_SECTORS; i++) {
-		soundfocus_params.soundfocus_data.start_angles[i] =
-			soundFocusData.start_angle[i];
-		soundfocus_params.soundfocus_data.enables[i] =
-			soundFocusData.enable[i];
-		pr_debug("%s: start_angle[%d] = %d\n",
-			  __func__, i, soundFocusData.start_angle[i]);
-		pr_debug("%s: enable[%d] = %d\n",
-			  __func__, i, soundFocusData.enable[i]);
-	}
-	soundfocus_params.soundfocus_data.gain_step =
-					soundFocusData.gain_step;
-	pr_debug("%s: gain_step = %d\n", __func__, soundFocusData.gain_step);
-
-	soundfocus_params.soundfocus_data.reserved = 0;
-
-	atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&soundfocus_params);
-	if (ret < 0) {
-		pr_err("%s: Set params failed\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	/* Wait for the callback */
-	ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
-		atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Set params timed out\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (this_adm.sourceTrackingData.apr_cmd_status != 0) {
-		pr_err("%s - set params returned error [%s]\n",
-			__func__, adsp_err_get_err_str(
-			this_adm.sourceTrackingData.apr_cmd_status));
-
-		ret = adsp_err_get_lnx_err_code(
-				this_adm.sourceTrackingData.apr_cmd_status);
-		goto done;
-	}
-
-	ret = 0;
-
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-int adm_get_sound_focus(int port_id, int copp_idx,
-			struct sound_focus_param *soundFocusData)
-{
-	int ret = 0, i;
-	char *params_value;
-	uint32_t param_payload_len = sizeof(struct adm_param_data_v5) +
-				sizeof(struct adm_param_fluence_soundfocus_t);
-	struct adm_param_fluence_soundfocus_t *soundfocus_params;
-
-	pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
-		  __func__, port_id, copp_idx);
-
-	params_value = kzalloc(param_payload_len, GFP_KERNEL);
-	if (!params_value) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	ret = adm_get_params_v2(port_id, copp_idx,
-				VOICEPROC_MODULE_ID_GENERIC_TX,
-				VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS,
-				param_payload_len,
-				params_value,
-				ADM_CLIENT_ID_SOURCE_TRACKING);
-	if (ret) {
-		pr_err("%s: get parameters failed ret:%d\n", __func__, ret);
-
-		kfree(params_value);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (this_adm.sourceTrackingData.apr_cmd_status != 0) {
-		pr_err("%s - get params returned error [%s]\n",
-			__func__, adsp_err_get_err_str(
-			this_adm.sourceTrackingData.apr_cmd_status));
-
-		kfree(params_value);
-		ret = adsp_err_get_lnx_err_code(
-				this_adm.sourceTrackingData.apr_cmd_status);
-		goto done;
-	}
-
-	soundfocus_params = (struct adm_param_fluence_soundfocus_t *)
-								params_value;
-	for (i = 0; i < MAX_SECTORS; i++) {
-		soundFocusData->start_angle[i] =
-					soundfocus_params->start_angles[i];
-		soundFocusData->enable[i] = soundfocus_params->enables[i];
-		pr_debug("%s: start_angle[%d] = %d\n",
-			  __func__, i, soundFocusData->start_angle[i]);
-		pr_debug("%s: enable[%d] = %d\n",
-			  __func__, i, soundFocusData->enable[i]);
-	}
-	soundFocusData->gain_step = soundfocus_params->gain_step;
-	pr_debug("%s: gain_step = %d\n", __func__, soundFocusData->gain_step);
-
-	kfree(params_value);
-
-done:
-	pr_debug("%s: Exit, ret = %d\n", __func__, ret);
-
-	return ret;
-}
-
-static int adm_source_tracking_alloc_map_memory(void)
-{
-	int ret;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	ret = msm_audio_ion_alloc("SOURCE_TRACKING",
-				  &this_adm.sourceTrackingData.ion_client,
-				  &this_adm.sourceTrackingData.ion_handle,
-				  AUD_PROC_BLOCK_SIZE,
-				  &this_adm.sourceTrackingData.memmap.paddr,
-				  &this_adm.sourceTrackingData.memmap.size,
-				  &this_adm.sourceTrackingData.memmap.kvaddr);
-	if (ret) {
-		pr_err("%s: failed to allocate memory\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	atomic_set(&this_adm.mem_map_index, ADM_MEM_MAP_INDEX_SOURCE_TRACKING);
-	ret = adm_memory_map_regions(&this_adm.sourceTrackingData.memmap.paddr,
-			0,
-			(uint32_t *)&this_adm.sourceTrackingData.memmap.size,
-			1);
-	if (ret < 0) {
-		pr_err("%s: failed to map memory, paddr = 0x%pK, size = %d\n",
-			__func__,
-			(void *)this_adm.sourceTrackingData.memmap.paddr,
-			(uint32_t)this_adm.sourceTrackingData.memmap.size);
-
-		msm_audio_ion_free(this_adm.sourceTrackingData.ion_client,
-				   this_adm.sourceTrackingData.ion_handle);
-		this_adm.sourceTrackingData.ion_client = NULL;
-		this_adm.sourceTrackingData.ion_handle = NULL;
-		this_adm.sourceTrackingData.memmap.size = 0;
-		this_adm.sourceTrackingData.memmap.kvaddr = NULL;
-		this_adm.sourceTrackingData.memmap.paddr = 0;
-		this_adm.sourceTrackingData.apr_cmd_status = -1;
-		atomic_set(&this_adm.mem_map_handles
-				[ADM_MEM_MAP_INDEX_SOURCE_TRACKING], 0);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	ret = 0;
-	pr_debug("%s: paddr = 0x%pK, size = %d, mem_map_handle = 0x%x\n",
-		  __func__, (void *)this_adm.sourceTrackingData.memmap.paddr,
-		  (uint32_t)this_adm.sourceTrackingData.memmap.size,
-		  atomic_read(&this_adm.mem_map_handles
-			      [ADM_MEM_MAP_INDEX_SOURCE_TRACKING]));
-
-done:
-	pr_debug("%s: Exit, ret = %d\n", __func__, ret);
-
-	return ret;
-}
-
-int adm_get_source_tracking(int port_id, int copp_idx,
-			    struct source_tracking_param *sourceTrackingData)
-{
-	struct adm_cmd_get_pp_params_v5 admp;
-	int p_idx, ret = 0, i;
-	struct adm_param_fluence_sourcetracking_t *source_tracking_params;
-
-	pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
-		  __func__, port_id, copp_idx);
-
-	if (!this_adm.sourceTrackingData.memmap.paddr) {
-		/* Allocate and map shared memory for out of band usage */
-		ret = adm_source_tracking_alloc_map_memory();
-		if (ret != 0) {
-			ret = -EINVAL;
-			goto done;
-		}
-	}
-
-	port_id = afe_convert_virtual_to_portid(port_id);
-	p_idx = adm_validate_and_get_port_index(port_id);
-	if (p_idx < 0) {
-		pr_err("%s - invalid port index %i, port id %i, copp idx %i\n",
-			__func__, p_idx, port_id, copp_idx);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	admp.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	admp.hdr.pkt_size = sizeof(admp);
-	admp.hdr.src_svc = APR_SVC_ADM;
-	admp.hdr.src_domain = APR_DOMAIN_APPS;
-	admp.hdr.src_port = port_id;
-	admp.hdr.dest_svc = APR_SVC_ADM;
-	admp.hdr.dest_domain = APR_DOMAIN_ADSP;
-	admp.hdr.dest_port = atomic_read(&this_adm.copp.id[p_idx][copp_idx]);
-	admp.hdr.token = p_idx << 16 | ADM_CLIENT_ID_SOURCE_TRACKING << 8 |
-			 copp_idx;
-	admp.hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5;
-	admp.data_payload_addr_lsw =
-		lower_32_bits(this_adm.sourceTrackingData.memmap.paddr);
-	admp.data_payload_addr_msw =
-		msm_audio_populate_upper_32_bits(
-				this_adm.sourceTrackingData.memmap.paddr);
-	admp.mem_map_handle = atomic_read(&this_adm.mem_map_handles[
-					  ADM_MEM_MAP_INDEX_SOURCE_TRACKING]);
-	admp.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
-	admp.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOURCETRACKING;
-	admp.param_max_size = sizeof(struct adm_param_fluence_sourcetracking_t)
-				+ sizeof(struct adm_param_data_v5);
-	admp.reserved = 0;
-
-	atomic_set(&this_adm.copp.stat[p_idx][copp_idx], -1);
-
-	ret = apr_send_pkt(this_adm.apr, (uint32_t *)&admp);
-	if (ret < 0) {
-		pr_err("%s - failed to get Source Tracking Params\n",
-			__func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	ret = wait_event_timeout(this_adm.copp.wait[p_idx][copp_idx],
-			atomic_read(&this_adm.copp.stat[p_idx][copp_idx]) >= 0,
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s - get params timed out\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	} else if (atomic_read(&this_adm.copp.stat
-				[p_idx][copp_idx]) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_adm.copp.stat
-			[p_idx][copp_idx])));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_adm.copp.stat
-					[p_idx][copp_idx]));
-		goto done;
-	}
-
-	if (this_adm.sourceTrackingData.apr_cmd_status != 0) {
-		pr_err("%s - get params returned error [%s]\n",
-			__func__, adsp_err_get_err_str(
-			this_adm.sourceTrackingData.apr_cmd_status));
-
-		ret = adsp_err_get_lnx_err_code(
-				this_adm.sourceTrackingData.apr_cmd_status);
-		goto done;
-	}
-
-	source_tracking_params = (struct adm_param_fluence_sourcetracking_t *)
-			(this_adm.sourceTrackingData.memmap.kvaddr +
-			 sizeof(struct adm_param_data_v5));
-	for (i = 0; i < MAX_SECTORS; i++) {
-		sourceTrackingData->vad[i] = source_tracking_params->vad[i];
-		pr_debug("%s: vad[%d] = %d\n",
-			  __func__, i, sourceTrackingData->vad[i]);
-	}
-	sourceTrackingData->doa_speech = source_tracking_params->doa_speech;
-	pr_debug("%s: doa_speech = %d\n",
-		  __func__, sourceTrackingData->doa_speech);
-
-	for (i = 0; i < MAX_NOISE_SOURCE_INDICATORS; i++) {
-		sourceTrackingData->doa_noise[i] =
-					source_tracking_params->doa_noise[i];
-		pr_debug("%s: doa_noise[%d] = %d\n",
-			  __func__, i, sourceTrackingData->doa_noise[i]);
-	}
-	for (i = 0; i < MAX_POLAR_ACTIVITY_INDICATORS; i++) {
-		sourceTrackingData->polar_activity[i] =
-				source_tracking_params->polar_activity[i];
-		pr_debug("%s: polar_activity[%d] = %d\n",
-			  __func__, i, sourceTrackingData->polar_activity[i]);
-	}
-
-	ret = 0;
-
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int __init adm_init(void)
-{
-	int i = 0, j;
-
-	this_adm.apr = NULL;
-	this_adm.ec_ref_rx = -1;
-	this_adm.num_ec_ref_rx_chans = 0;
-	this_adm.ec_ref_rx_bit_width = 0;
-	this_adm.ec_ref_rx_sampling_rate = 0;
-	atomic_set(&this_adm.matrix_map_stat, 0);
-	init_waitqueue_head(&this_adm.matrix_map_wait);
-	atomic_set(&this_adm.adm_stat, 0);
-	init_waitqueue_head(&this_adm.adm_wait);
-
-	for (i = 0; i < AFE_MAX_PORTS; i++) {
-		for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
-			atomic_set(&this_adm.copp.id[i][j], RESET_COPP_ID);
-			atomic_set(&this_adm.copp.cnt[i][j], 0);
-			atomic_set(&this_adm.copp.topology[i][j], 0);
-			atomic_set(&this_adm.copp.mode[i][j], 0);
-			atomic_set(&this_adm.copp.stat[i][j], 0);
-			atomic_set(&this_adm.copp.rate[i][j], 0);
-			atomic_set(&this_adm.copp.channels[i][j], 0);
-			atomic_set(&this_adm.copp.bit_width[i][j], 0);
-			atomic_set(&this_adm.copp.app_type[i][j], 0);
-			atomic_set(&this_adm.copp.acdb_id[i][j], 0);
-			init_waitqueue_head(&this_adm.copp.wait[i][j]);
-			atomic_set(&this_adm.copp.adm_delay_stat[i][j], 0);
-			init_waitqueue_head(
-				&this_adm.copp.adm_delay_wait[i][j]);
-			atomic_set(&this_adm.copp.topology[i][j], 0);
-			this_adm.copp.adm_delay[i][j] = 0;
-			this_adm.copp.adm_status[i][j] =
-				ADM_STATUS_CALIBRATION_REQUIRED;
-		}
-	}
-
-	if (adm_init_cal_data())
-		pr_err("%s: could not init cal data!\n", __func__);
-
-	this_adm.sourceTrackingData.ion_client = NULL;
-	this_adm.sourceTrackingData.ion_handle = NULL;
-	this_adm.sourceTrackingData.memmap.size = 0;
-	this_adm.sourceTrackingData.memmap.kvaddr = NULL;
-	this_adm.sourceTrackingData.memmap.paddr = 0;
-	this_adm.sourceTrackingData.apr_cmd_status = -1;
-	atomic_set(&this_adm.mem_map_handles[ADM_MEM_MAP_INDEX_SOURCE_TRACKING],
-		   0);
-
-	return 0;
-}
-
-static void __exit adm_exit(void)
-{
-	adm_delete_cal_data();
-}
-
-device_initcall(adm_init);
-module_exit(adm_exit);
diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c
deleted file mode 100644
index e1ce947..0000000
--- a/sound/soc/msm/qdsp6v2/q6afe.c
+++ /dev/null
@@ -1,7150 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/wakelock.h>
-#include <linux/jiffies.h>
-#include <linux/sched.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/delay.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6audio-v2.h>
-#include "msm-pcm-routing-v2.h"
-#include <sound/audio_cal_utils.h>
-#include <sound/adsp_err.h>
-#include <linux/qdsp6v2/apr_tal.h>
-
-#define WAKELOCK_TIMEOUT	5000
-enum {
-	AFE_COMMON_RX_CAL = 0,
-	AFE_COMMON_TX_CAL,
-	AFE_AANC_CAL,
-	AFE_FB_SPKR_PROT_CAL,
-	AFE_HW_DELAY_CAL,
-	AFE_SIDETONE_CAL,
-	AFE_SIDETONE_IIR_CAL,
-	AFE_TOPOLOGY_CAL,
-	AFE_CUST_TOPOLOGY_CAL,
-	AFE_FB_SPKR_PROT_TH_VI_CAL,
-	AFE_FB_SPKR_PROT_EX_VI_CAL,
-	MAX_AFE_CAL_TYPES
-};
-
-enum fbsp_state {
-	FBSP_INCORRECT_OP_MODE,
-	FBSP_INACTIVE,
-	FBSP_WARMUP,
-	FBSP_IN_PROGRESS,
-	FBSP_SUCCESS,
-	FBSP_FAILED,
-	MAX_FBSP_STATE
-};
-
-static char fbsp_state[MAX_FBSP_STATE][50] = {
-	[FBSP_INCORRECT_OP_MODE] = "incorrect operation mode",
-	[FBSP_INACTIVE] = "port not started",
-	[FBSP_WARMUP] = "waiting for warmup",
-	[FBSP_IN_PROGRESS] = "in progress state",
-	[FBSP_SUCCESS] = "success",
-	[FBSP_FAILED] = "failed"
-};
-
-enum {
-	USE_CALIBRATED_R0TO,
-	USE_SAFE_R0TO
-};
-
-enum {
-	QUICK_CALIB_DISABLE,
-	QUICK_CALIB_ENABLE
-};
-
-enum {
-	Q6AFE_MSM_SPKR_PROCESSING = 0,
-	Q6AFE_MSM_SPKR_CALIBRATION,
-	Q6AFE_MSM_SPKR_FTM_MODE
-};
-
-struct wlock {
-	struct wakeup_source ws;
-};
-
-static struct wlock wl;
-
-struct afe_ctl {
-	void *apr;
-	atomic_t state;
-	atomic_t status;
-	wait_queue_head_t wait[AFE_MAX_PORTS];
-	struct task_struct *task;
-	void (*tx_cb)(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv);
-	void (*rx_cb)(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv);
-	void *tx_private_data;
-	void *rx_private_data;
-	uint32_t mmap_handle;
-
-	int	topology[AFE_MAX_PORTS];
-	struct cal_type_data *cal_data[MAX_AFE_CAL_TYPES];
-
-	atomic_t mem_map_cal_handles[MAX_AFE_CAL_TYPES];
-	atomic_t mem_map_cal_index;
-	u32 afe_cal_mode[AFE_MAX_PORTS];
-
-	u16 dtmf_gen_rx_portid;
-	struct audio_cal_info_spk_prot_cfg	prot_cfg;
-	struct afe_spkr_prot_calib_get_resp	calib_data;
-	struct audio_cal_info_sp_th_vi_ftm_cfg	th_ftm_cfg;
-	struct audio_cal_info_sp_ex_vi_ftm_cfg	ex_ftm_cfg;
-	struct afe_sp_th_vi_get_param_resp	th_vi_resp;
-	struct afe_sp_ex_vi_get_param_resp	ex_vi_resp;
-	struct afe_av_dev_drift_get_param_resp	av_dev_drift_resp;
-	int vi_tx_port;
-	int vi_rx_port;
-	uint32_t afe_sample_rates[AFE_MAX_PORTS];
-	struct aanc_data aanc_info;
-	struct mutex afe_cmd_lock;
-	int set_custom_topology;
-	int dev_acdb_id[AFE_MAX_PORTS];
-	routing_cb rt_cb;
-};
-
-static atomic_t afe_ports_mad_type[SLIMBUS_PORT_LAST - SLIMBUS_0_RX];
-static unsigned long afe_configured_cmd;
-
-static struct afe_ctl this_afe;
-
-#define TIMEOUT_MS 1000
-#define Q6AFE_MAX_VOLUME 0x3FFF
-
-static int pcm_afe_instance[2];
-static int proxy_afe_instance[2];
-bool afe_close_done[2] = {true, true};
-
-#define SIZEOF_CFG_CMD(y) \
-		(sizeof(struct apr_hdr) + sizeof(u16) + (sizeof(struct y)))
-
-static int afe_get_cal_hw_delay(int32_t path,
-				struct audio_cal_hw_delay_entry *entry);
-static int remap_cal_data(struct cal_block_data *cal_block, int cal_index);
-
-int afe_get_topology(int port_id)
-{
-	int topology;
-	int port_index = afe_get_port_index(port_id);
-
-	if ((port_index < 0) || (port_index >= AFE_MAX_PORTS)) {
-		pr_err("%s: Invalid port index %d\n", __func__, port_index);
-		topology = -EINVAL;
-		goto done;
-	}
-
-	topology = this_afe.topology[port_index];
-done:
-	return topology;
-}
-
-void afe_set_aanc_info(struct aanc_data *q6_aanc_info)
-{
-	this_afe.aanc_info.aanc_active = q6_aanc_info->aanc_active;
-	this_afe.aanc_info.aanc_rx_port = q6_aanc_info->aanc_rx_port;
-	this_afe.aanc_info.aanc_tx_port = q6_aanc_info->aanc_tx_port;
-
-	pr_debug("%s: aanc active is %d rx port is 0x%x, tx port is 0x%x\n",
-		__func__,
-		this_afe.aanc_info.aanc_active,
-		this_afe.aanc_info.aanc_rx_port,
-		this_afe.aanc_info.aanc_tx_port);
-}
-
-static void afe_callback_debug_print(struct apr_client_data *data)
-{
-	uint32_t *payload;
-
-	payload = data->payload;
-
-	if (data->payload_size >= 8)
-		pr_debug("%s: code = 0x%x PL#0[0x%x], PL#1[0x%x], size = %d\n",
-			__func__, data->opcode, payload[0], payload[1],
-			data->payload_size);
-	else if (data->payload_size >= 4)
-		pr_debug("%s: code = 0x%x PL#0[0x%x], size = %d\n",
-			__func__, data->opcode, payload[0],
-			data->payload_size);
-	else
-		pr_debug("%s: code = 0x%x, size = %d\n",
-			__func__, data->opcode, data->payload_size);
-}
-
-static void av_dev_drift_afe_cb_handler(uint32_t *payload,
-					uint32_t payload_size)
-{
-	u32 param_id;
-	struct afe_av_dev_drift_get_param_resp *resp =
-		(struct afe_av_dev_drift_get_param_resp *) payload;
-
-	if (!(&(resp->pdata))) {
-		pr_err("%s: Error: resp pdata is NULL\n", __func__);
-		return;
-	}
-
-	param_id = resp->pdata.param_id;
-	if (param_id == AFE_PARAM_ID_DEV_TIMING_STATS) {
-		if (payload_size < sizeof(this_afe.av_dev_drift_resp)) {
-			pr_err("%s: Error: received size %d, resp size %zu\n",
-				__func__, payload_size,
-				sizeof(this_afe.av_dev_drift_resp));
-			return;
-		}
-		memcpy(&this_afe.av_dev_drift_resp, payload,
-				sizeof(this_afe.av_dev_drift_resp));
-		if (!this_afe.av_dev_drift_resp.status) {
-			atomic_set(&this_afe.state, 0);
-		} else {
-			pr_debug("%s: av_dev_drift_resp status: %d", __func__,
-				  this_afe.av_dev_drift_resp.status);
-			atomic_set(&this_afe.state, -1);
-		}
-	}
-}
-
-static int32_t sp_make_afe_callback(uint32_t *payload, uint32_t payload_size)
-{
-	u32 param_id;
-	struct afe_spkr_prot_calib_get_resp *resp =
-		(struct afe_spkr_prot_calib_get_resp *) payload;
-
-	if (!(&(resp->pdata))) {
-		pr_err("%s: Error: resp pdata is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	param_id = resp->pdata.param_id;
-	if (param_id == AFE_PARAM_ID_CALIB_RES_CFG_V2) {
-		if (payload_size < sizeof(this_afe.calib_data)) {
-			pr_err("%s: Error: received size %d, calib_data size %zu\n",
-				__func__, payload_size,
-				sizeof(this_afe.calib_data));
-			return -EINVAL;
-		}
-		memcpy(&this_afe.calib_data, payload,
-			sizeof(this_afe.calib_data));
-		if (!this_afe.calib_data.status) {
-			atomic_set(&this_afe.state, 0);
-		} else {
-			pr_debug("%s: calib resp status: %d", __func__,
-				  this_afe.calib_data.status);
-			atomic_set(&this_afe.state, -1);
-		}
-	}
-	if (param_id == AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS) {
-		if (payload_size < sizeof(this_afe.th_vi_resp)) {
-			pr_err("%s: Error: received size %d, th_vi_resp size %zu\n",
-				__func__, payload_size,
-				sizeof(this_afe.th_vi_resp));
-			return -EINVAL;
-		}
-		memcpy(&this_afe.th_vi_resp, payload,
-			sizeof(this_afe.th_vi_resp));
-		if (!this_afe.th_vi_resp.status) {
-			atomic_set(&this_afe.state, 0);
-		} else {
-			pr_debug("%s: th vi resp status: %d", __func__,
-				  this_afe.th_vi_resp.status);
-			atomic_set(&this_afe.state, -1);
-		}
-	}
-	if (param_id == AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS) {
-		if (payload_size < sizeof(this_afe.ex_vi_resp)) {
-			pr_err("%s: Error: received size %d, ex_vi_resp size %zu\n",
-				__func__, payload_size,
-				sizeof(this_afe.ex_vi_resp));
-			return -EINVAL;
-		}
-		memcpy(&this_afe.ex_vi_resp, payload,
-			sizeof(this_afe.ex_vi_resp));
-		if (!this_afe.ex_vi_resp.status) {
-			atomic_set(&this_afe.state, 0);
-		} else {
-			pr_debug("%s: ex vi resp status: %d", __func__,
-				  this_afe.ex_vi_resp.status);
-			atomic_set(&this_afe.state, -1);
-		}
-	}
-
-	return 0;
-}
-
-static int32_t afe_callback(struct apr_client_data *data, void *priv)
-{
-	if (!data) {
-		pr_err("%s: Invalid param data\n", __func__);
-		return -EINVAL;
-	}
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: reset event = %d %d apr[%pK]\n",
-			__func__,
-			data->reset_event, data->reset_proc, this_afe.apr);
-
-		cal_utils_clear_cal_block_q6maps(MAX_AFE_CAL_TYPES,
-			this_afe.cal_data);
-
-		/* Reset the custom topology mode: to resend again to AFE. */
-		mutex_lock(&this_afe.cal_data[AFE_CUST_TOPOLOGY_CAL]->lock);
-		this_afe.set_custom_topology = 1;
-		mutex_unlock(&this_afe.cal_data[AFE_CUST_TOPOLOGY_CAL]->lock);
-		rtac_clear_mapping(AFE_RTAC_CAL);
-
-		if (this_afe.apr) {
-			apr_reset(this_afe.apr);
-			atomic_set(&this_afe.state, 0);
-			this_afe.apr = NULL;
-			rtac_set_afe_handle(this_afe.apr);
-		}
-		/* send info to user */
-		if (this_afe.task == NULL)
-			this_afe.task = current;
-		pr_debug("%s: task_name = %s pid = %d\n",
-			__func__,
-			this_afe.task->comm, this_afe.task->pid);
-
-		/*
-		 * Pass reset events to proxy driver, if cb is registered
-		 */
-		if (this_afe.tx_cb) {
-			this_afe.tx_cb(data->opcode, data->token,
-					data->payload,
-					this_afe.tx_private_data);
-			this_afe.tx_cb = NULL;
-		}
-		if (this_afe.rx_cb) {
-			this_afe.rx_cb(data->opcode, data->token,
-					data->payload,
-					this_afe.rx_private_data);
-			this_afe.rx_cb = NULL;
-		}
-
-		return 0;
-	}
-	afe_callback_debug_print(data);
-	if (data->opcode == AFE_PORT_CMDRSP_GET_PARAM_V2) {
-		uint32_t *payload = data->payload;
-
-		if (!payload || (data->token >= AFE_MAX_PORTS)) {
-			pr_err("%s: Error: size %d payload %pK token %d\n",
-				__func__, data->payload_size,
-				payload, data->token);
-			return -EINVAL;
-		}
-
-		if (payload[2] == AFE_PARAM_ID_DEV_TIMING_STATS) {
-			av_dev_drift_afe_cb_handler(data->payload,
-						    data->payload_size);
-		} else {
-			if (rtac_make_afe_callback(data->payload,
-						   data->payload_size))
-				return 0;
-
-			if (sp_make_afe_callback(data->payload,
-						 data->payload_size))
-				return -EINVAL;
-		}
-		wake_up(&this_afe.wait[data->token]);
-	} else if (data->payload_size) {
-		uint32_t *payload;
-		uint16_t port_id = 0;
-
-		payload = data->payload;
-		if (data->opcode == APR_BASIC_RSP_RESULT) {
-			pr_debug("%s:opcode = 0x%x cmd = 0x%x status = 0x%x token=%d\n",
-				__func__, data->opcode,
-				payload[0], payload[1], data->token);
-			/* payload[1] contains the error status for response */
-			if (payload[1] != 0) {
-				atomic_set(&this_afe.status, payload[1]);
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					__func__, payload[0], payload[1]);
-			}
-			switch (payload[0]) {
-			case AFE_PORT_CMD_SET_PARAM_V2:
-				if (rtac_make_afe_callback(payload,
-					data->payload_size))
-					return 0;
-			case AFE_PORT_CMD_DEVICE_STOP:
-			case AFE_PORT_CMD_DEVICE_START:
-			case AFE_PSEUDOPORT_CMD_START:
-			case AFE_PSEUDOPORT_CMD_STOP:
-			case AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS:
-			case AFE_SERVICE_CMD_SHARED_MEM_UNMAP_REGIONS:
-			case AFE_SERVICE_CMD_UNREGISTER_RT_PORT_DRIVER:
-			case AFE_PORTS_CMD_DTMF_CTL:
-			case AFE_SVC_CMD_SET_PARAM:
-				atomic_set(&this_afe.state, 0);
-				wake_up(&this_afe.wait[data->token]);
-				break;
-			case AFE_SERVICE_CMD_REGISTER_RT_PORT_DRIVER:
-				break;
-			case AFE_PORT_DATA_CMD_RT_PROXY_PORT_WRITE_V2:
-				port_id = RT_PROXY_PORT_001_TX;
-				break;
-			case AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2:
-				port_id = RT_PROXY_PORT_001_RX;
-				break;
-			case AFE_CMD_ADD_TOPOLOGIES:
-				atomic_set(&this_afe.state, 0);
-				wake_up(&this_afe.wait[data->token]);
-				pr_debug("%s: AFE_CMD_ADD_TOPOLOGIES cmd 0x%x\n",
-						__func__, payload[1]);
-				break;
-			default:
-				pr_err("%s: Unknown cmd 0x%x\n", __func__,
-						payload[0]);
-				break;
-			}
-		} else if (data->opcode ==
-				AFE_SERVICE_CMDRSP_SHARED_MEM_MAP_REGIONS) {
-			pr_debug("%s: mmap_handle: 0x%x, cal index %d\n",
-				 __func__, payload[0],
-				 atomic_read(&this_afe.mem_map_cal_index));
-			if (atomic_read(&this_afe.mem_map_cal_index) != -1)
-				atomic_set(&this_afe.mem_map_cal_handles[
-					atomic_read(
-					&this_afe.mem_map_cal_index)],
-					(uint32_t)payload[0]);
-			else
-				this_afe.mmap_handle = payload[0];
-			atomic_set(&this_afe.state, 0);
-			wake_up(&this_afe.wait[data->token]);
-		} else if (data->opcode == AFE_EVENT_RT_PROXY_PORT_STATUS) {
-			port_id = (uint16_t)(0x0000FFFF & payload[0]);
-		}
-		pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-		switch (port_id) {
-		case RT_PROXY_PORT_001_TX: {
-			if (this_afe.tx_cb) {
-				this_afe.tx_cb(data->opcode, data->token,
-					data->payload,
-					this_afe.tx_private_data);
-			}
-			break;
-		}
-		case RT_PROXY_PORT_001_RX: {
-			if (this_afe.rx_cb) {
-				this_afe.rx_cb(data->opcode, data->token,
-					data->payload,
-					this_afe.rx_private_data);
-			}
-			break;
-		}
-		default:
-			pr_debug("%s: default case 0x%x\n", __func__, port_id);
-			break;
-		}
-	}
-	return 0;
-}
-
-int afe_get_port_type(u16 port_id)
-{
-	int ret;
-
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case SECONDARY_I2S_RX:
-	case MI2S_RX:
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-	case AFE_PORT_ID_SPDIF_RX:
-	case SLIMBUS_0_RX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_8_RX:
-	case INT_BT_SCO_RX:
-	case INT_BT_A2DP_RX:
-	case INT_FM_RX:
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case RT_PROXY_PORT_001_RX:
-	case AUDIO_PORT_ID_I2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_INT0_MI2S_RX:
-	case AFE_PORT_ID_INT1_MI2S_RX:
-	case AFE_PORT_ID_INT2_MI2S_RX:
-	case AFE_PORT_ID_INT3_MI2S_RX:
-	case AFE_PORT_ID_INT4_MI2S_RX:
-	case AFE_PORT_ID_INT5_MI2S_RX:
-	case AFE_PORT_ID_INT6_MI2S_RX:
-		ret = MSM_AFE_PORT_TYPE_RX;
-		break;
-
-	case PRIMARY_I2S_TX:
-	case SECONDARY_I2S_TX:
-	case MI2S_TX:
-	case DIGI_MIC_TX:
-	case VOICE_RECORD_TX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_TX:
-	case INT_FM_TX:
-	case VOICE_RECORD_RX:
-	case INT_BT_SCO_TX:
-	case RT_PROXY_PORT_001_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-	case AFE_PORT_ID_USB_TX:
-	case AFE_PORT_ID_INT0_MI2S_TX:
-	case AFE_PORT_ID_INT1_MI2S_TX:
-	case AFE_PORT_ID_INT2_MI2S_TX:
-	case AFE_PORT_ID_INT3_MI2S_TX:
-	case AFE_PORT_ID_INT4_MI2S_TX:
-	case AFE_PORT_ID_INT5_MI2S_TX:
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		ret = MSM_AFE_PORT_TYPE_TX;
-		break;
-
-	default:
-		WARN_ON(1);
-		pr_err("%s: Invalid port id = 0x%x\n",
-			__func__, port_id);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-int afe_sizeof_cfg_cmd(u16 port_id)
-{
-	int ret_size;
-
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_i2s_cfg);
-		break;
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-		ret_size =
-		SIZEOF_CFG_CMD(afe_param_id_hdmi_multi_chan_audio_cfg);
-		break;
-	case SLIMBUS_0_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_slimbus_cfg);
-		break;
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case VOICE_RECORD_RX:
-	case VOICE_RECORD_TX:
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_pseudo_port_cfg);
-		break;
-	case RT_PROXY_PORT_001_RX:
-	case RT_PROXY_PORT_001_TX:
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_rt_proxy_port_cfg);
-		break;
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_usb_audio_cfg);
-		break;
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-	default:
-		pr_debug("%s: default case 0x%x\n", __func__, port_id);
-		ret_size = SIZEOF_CFG_CMD(afe_param_id_pcm_cfg);
-		break;
-	}
-	return ret_size;
-}
-
-int afe_q6_interface_prepare(void)
-{
-	int ret = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-			0xFFFFFFFF, &this_afe);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-	return ret;
-}
-
-/*
- * afe_apr_send_pkt : returns 0 on success, negative otherwise.
- */
-static int afe_apr_send_pkt(void *data, wait_queue_head_t *wait)
-{
-	int ret;
-
-	if (wait)
-		atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, data);
-	if (ret > 0) {
-		if (wait) {
-			ret = wait_event_timeout(*wait,
-					(atomic_read(&this_afe.state) == 0),
-					msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				ret = -ETIMEDOUT;
-			} else if (atomic_read(&this_afe.status) > 0) {
-				pr_err("%s: DSP returned error[%s]\n", __func__,
-					adsp_err_get_err_str(atomic_read(
-					&this_afe.status)));
-				ret = adsp_err_get_lnx_err_code(
-						atomic_read(&this_afe.status));
-			} else {
-				ret = 0;
-			}
-		} else {
-			ret = 0;
-		}
-	} else if (ret == 0) {
-		pr_err("%s: packet not transmitted\n", __func__);
-		/* apr_send_pkt can return 0 when nothing is transmitted */
-		ret = -EINVAL;
-	}
-
-	pr_debug("%s: leave %d\n", __func__, ret);
-	return ret;
-}
-
-static int afe_send_cal_block(u16 port_id, struct cal_block_data *cal_block)
-{
-	int						result = 0;
-	int						index = 0;
-	struct afe_audioif_config_command_no_payload	afe_cal;
-
-	if (!cal_block) {
-		pr_debug("%s: No AFE cal to send!\n", __func__);
-		result = -EINVAL;
-		goto done;
-	}
-	if (cal_block->cal_data.size <= 0) {
-		pr_debug("%s: AFE cal has invalid size!\n", __func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		result = -EINVAL;
-		goto done;
-	}
-
-	afe_cal.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	afe_cal.hdr.pkt_size = sizeof(afe_cal);
-	afe_cal.hdr.src_port = 0;
-	afe_cal.hdr.dest_port = 0;
-	afe_cal.hdr.token = index;
-	afe_cal.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	afe_cal.param.port_id = port_id;
-	afe_cal.param.payload_size = cal_block->cal_data.size;
-	afe_cal.param.payload_address_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	afe_cal.param.payload_address_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	afe_cal.param.mem_map_handle = cal_block->map_data.q6map_handle;
-
-	pr_debug("%s: AFE cal sent for device port = 0x%x, cal size = %zd, cal addr = 0x%pK\n",
-		__func__, port_id,
-		cal_block->cal_data.size, &cal_block->cal_data.paddr);
-
-	result = afe_apr_send_pkt(&afe_cal, &this_afe.wait[index]);
-	if (result)
-		pr_err("%s: AFE cal for port 0x%x failed %d\n",
-		       __func__, port_id, result);
-
-done:
-	return result;
-}
-
-
-static int afe_send_custom_topology_block(struct cal_block_data *cal_block)
-{
-	int	result = 0;
-	int	index = 0;
-	struct cmd_set_topologies afe_cal;
-
-	if (!cal_block) {
-		pr_err("%s: No AFE SVC cal to send!\n", __func__);
-		return -EINVAL;
-	}
-	if (cal_block->cal_data.size <= 0) {
-		pr_err("%s: AFE SVC cal has invalid size: %zd!\n",
-		__func__, cal_block->cal_data.size);
-		return -EINVAL;
-	}
-
-	afe_cal.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	afe_cal.hdr.pkt_size = sizeof(afe_cal);
-	afe_cal.hdr.src_port = 0;
-	afe_cal.hdr.dest_port = 0;
-	afe_cal.hdr.token = index;
-	afe_cal.hdr.opcode = AFE_CMD_ADD_TOPOLOGIES;
-
-	afe_cal.payload_size = cal_block->cal_data.size;
-	afe_cal.payload_addr_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	afe_cal.payload_addr_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	afe_cal.mem_map_handle = cal_block->map_data.q6map_handle;
-
-	pr_debug("%s:cmd_id:0x%x calsize:%zd memmap_hdl:0x%x caladdr:0x%pK",
-		__func__, AFE_CMD_ADD_TOPOLOGIES, cal_block->cal_data.size,
-		afe_cal.mem_map_handle, &cal_block->cal_data.paddr);
-
-	result = afe_apr_send_pkt(&afe_cal, &this_afe.wait[index]);
-	if (result)
-		pr_err("%s: AFE send topology for command 0x%x failed %d\n",
-		       __func__, AFE_CMD_ADD_TOPOLOGIES, result);
-
-	return result;
-}
-
-static void afe_send_custom_topology(void)
-{
-	struct cal_block_data   *cal_block = NULL;
-	int cal_index = AFE_CUST_TOPOLOGY_CAL;
-	int ret;
-
-	if (this_afe.cal_data[cal_index] == NULL) {
-		pr_err("%s: cal_index %d not allocated!\n",
-			__func__, cal_index);
-		return;
-	}
-	mutex_lock(&this_afe.cal_data[cal_index]->lock);
-
-	if (!this_afe.set_custom_topology)
-		goto unlock;
-	this_afe.set_custom_topology = 0;
-	cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
-	if (cal_block == NULL) {
-		pr_err("%s cal_block not found!!\n", __func__);
-		goto unlock;
-	}
-
-	pr_debug("%s: Sending cal_index cal %d\n", __func__, cal_index);
-
-	ret = remap_cal_data(cal_block, cal_index);
-	if (ret) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, cal_index);
-		goto unlock;
-	}
-	ret = afe_send_custom_topology_block(cal_block);
-	if (ret < 0) {
-		pr_err("%s: No cal sent for cal_index %d! ret %d\n",
-			__func__, cal_index, ret);
-		goto unlock;
-	}
-	pr_debug("%s:sent custom topology for AFE\n", __func__);
-unlock:
-	mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-}
-
-static int afe_spk_ramp_dn_cfg(int port)
-{
-	int ret = -EINVAL;
-	int index = 0;
-	struct afe_spkr_prot_config_command config;
-
-	if (afe_get_port_type(port) != MSM_AFE_PORT_TYPE_RX) {
-		pr_debug("%s: port doesn't match 0x%x\n", __func__, port);
-		return 0;
-	}
-	if (this_afe.prot_cfg.mode == MSM_SPKR_PROT_DISABLED ||
-		(this_afe.vi_rx_port != port)) {
-		pr_debug("%s: spkr protection disabled port 0x%x %d 0x%x\n",
-				__func__, port, ret, this_afe.vi_rx_port);
-		return 0;
-	}
-	memset(&config, 0, sizeof(config));
-	ret = q6audio_validate_port(port);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d", __func__, port, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	index = q6audio_get_port_index(port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port);
-	config.param.payload_size =
-		sizeof(config) - sizeof(config.hdr) - sizeof(config.param)
-		- sizeof(config.prot_config);
-	config.pdata.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
-	config.pdata.param_id = AFE_PARAM_ID_FBSP_PTONE_RAMP_CFG;
-	config.pdata.param_size = 0;
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
-	if (ret < 0) {
-		pr_err("%s: port = 0x%x param = 0x%x failed %d\n",
-				__func__, port, config.pdata.param_id, ret);
-		goto fail_cmd;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-	/* dsp needs atleast 15ms to ramp down pilot tone*/
-	usleep_range(15000, 15010);
-	ret = 0;
-fail_cmd:
-	pr_debug("%s: config.pdata.param_id 0x%x status %d\n",
-		__func__, config.pdata.param_id, ret);
-return ret;
-}
-
-static int afe_spk_prot_prepare(int src_port, int dst_port, int param_id,
-		union afe_spkr_prot_config *prot_config)
-{
-	int ret = -EINVAL;
-	int index = 0;
-	struct afe_spkr_prot_config_command config;
-
-	memset(&config, 0, sizeof(config));
-	if (!prot_config) {
-		pr_err("%s: Invalid params\n", __func__);
-		goto fail_cmd;
-	}
-	ret = q6audio_validate_port(src_port);
-	if (ret < 0) {
-		pr_err("%s: Invalid src port 0x%x ret %d",
-				__func__, src_port, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	ret = q6audio_validate_port(dst_port);
-	if (ret < 0) {
-		pr_err("%s: Invalid dst port 0x%x ret %d", __func__,
-				dst_port, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	index = q6audio_get_port_index(src_port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	switch (param_id) {
-	case AFE_PARAM_ID_FBSP_MODE_RX_CFG:
-		config.pdata.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
-		break;
-	case AFE_PARAM_ID_FEEDBACK_PATH_CFG:
-		this_afe.vi_tx_port = src_port;
-		this_afe.vi_rx_port = dst_port;
-		config.pdata.module_id = AFE_MODULE_FEEDBACK;
-		break;
-	/*
-	 * AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2 is same as
-	 * AFE_PARAM_ID_SP_V2_TH_VI_MODE_CFG
-	 */
-	case AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2:
-	case AFE_PARAM_ID_SP_V2_TH_VI_FTM_CFG:
-		config.pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
-		break;
-	case AFE_PARAM_ID_SP_V2_EX_VI_MODE_CFG:
-	case AFE_PARAM_ID_SP_V2_EX_VI_FTM_CFG:
-		config.pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
-		break;
-	default:
-		pr_err("%s: default case 0x%x\n", __func__, param_id);
-		goto fail_cmd;
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(src_port);
-	config.param.payload_size = sizeof(config) - sizeof(config.hdr)
-		- sizeof(config.param);
-	config.pdata.param_id = param_id;
-	config.pdata.param_size = sizeof(config.prot_config);
-	config.prot_config = *prot_config;
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
-	if (ret < 0) {
-		pr_err("%s: port = 0x%x param = 0x%x failed %d\n",
-		__func__, src_port, param_id, ret);
-		goto fail_cmd;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-		(atomic_read(&this_afe.state) == 0),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-	ret = 0;
-fail_cmd:
-	pr_debug("%s: config.pdata.param_id 0x%x status %d 0x%x\n",
-	__func__, config.pdata.param_id, ret, src_port);
-	return ret;
-}
-
-static void afe_send_cal_spkr_prot_tx(int port_id)
-{
-	union afe_spkr_prot_config afe_spk_config;
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_CAL] == NULL ||
-	    this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL] == NULL ||
-	    this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL] == NULL)
-		return;
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-	if ((this_afe.prot_cfg.mode != MSM_SPKR_PROT_DISABLED) &&
-		(this_afe.vi_tx_port == port_id)) {
-		if (this_afe.prot_cfg.mode ==
-			MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS) {
-			afe_spk_config.vi_proc_cfg.operation_mode =
-					Q6AFE_MSM_SPKR_CALIBRATION;
-			afe_spk_config.vi_proc_cfg.quick_calib_flag =
-					this_afe.prot_cfg.quick_calib_flag;
-		} else {
-			afe_spk_config.vi_proc_cfg.operation_mode =
-					Q6AFE_MSM_SPKR_PROCESSING;
-		}
-
-		if (this_afe.th_ftm_cfg.mode == MSM_SPKR_PROT_IN_FTM_MODE)
-			afe_spk_config.vi_proc_cfg.operation_mode =
-					    Q6AFE_MSM_SPKR_FTM_MODE;
-		afe_spk_config.vi_proc_cfg.minor_version = 1;
-		afe_spk_config.vi_proc_cfg.r0_cali_q24[SP_V2_SPKR_1] =
-			(uint32_t) this_afe.prot_cfg.r0[SP_V2_SPKR_1];
-		afe_spk_config.vi_proc_cfg.r0_cali_q24[SP_V2_SPKR_2] =
-			(uint32_t) this_afe.prot_cfg.r0[SP_V2_SPKR_2];
-		afe_spk_config.vi_proc_cfg.t0_cali_q6[SP_V2_SPKR_1] =
-			(uint32_t) this_afe.prot_cfg.t0[SP_V2_SPKR_1];
-		afe_spk_config.vi_proc_cfg.t0_cali_q6[SP_V2_SPKR_2] =
-			(uint32_t) this_afe.prot_cfg.t0[SP_V2_SPKR_2];
-		if (this_afe.prot_cfg.mode != MSM_SPKR_PROT_NOT_CALIBRATED) {
-			struct asm_spkr_calib_vi_proc_cfg *vi_proc_cfg;
-
-			vi_proc_cfg = &afe_spk_config.vi_proc_cfg;
-			vi_proc_cfg->r0_t0_selection_flag[SP_V2_SPKR_1] =
-					    USE_CALIBRATED_R0TO;
-			vi_proc_cfg->r0_t0_selection_flag[SP_V2_SPKR_2] =
-					    USE_CALIBRATED_R0TO;
-		} else {
-			struct asm_spkr_calib_vi_proc_cfg *vi_proc_cfg;
-
-			vi_proc_cfg = &afe_spk_config.vi_proc_cfg;
-			vi_proc_cfg->r0_t0_selection_flag[SP_V2_SPKR_1] =
-							    USE_SAFE_R0TO;
-			vi_proc_cfg->r0_t0_selection_flag[SP_V2_SPKR_2] =
-							    USE_SAFE_R0TO;
-		}
-		if (afe_spk_prot_prepare(port_id, 0,
-			AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2,
-				&afe_spk_config))
-			pr_err("%s: SPKR_CALIB_VI_PROC_CFG failed\n",
-				__func__);
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-	if ((this_afe.th_ftm_cfg.mode == MSM_SPKR_PROT_IN_FTM_MODE) &&
-	    (this_afe.vi_tx_port == port_id)) {
-		afe_spk_config.th_vi_ftm_cfg.minor_version = 1;
-		afe_spk_config.th_vi_ftm_cfg.wait_time_ms[SP_V2_SPKR_1] =
-			this_afe.th_ftm_cfg.wait_time[SP_V2_SPKR_1];
-		afe_spk_config.th_vi_ftm_cfg.wait_time_ms[SP_V2_SPKR_2] =
-			this_afe.th_ftm_cfg.wait_time[SP_V2_SPKR_2];
-		afe_spk_config.th_vi_ftm_cfg.ftm_time_ms[SP_V2_SPKR_1] =
-			this_afe.th_ftm_cfg.ftm_time[SP_V2_SPKR_1];
-		afe_spk_config.th_vi_ftm_cfg.ftm_time_ms[SP_V2_SPKR_2] =
-			this_afe.th_ftm_cfg.ftm_time[SP_V2_SPKR_2];
-
-		if (afe_spk_prot_prepare(port_id, 0,
-					 AFE_PARAM_ID_SP_V2_TH_VI_FTM_CFG,
-					 &afe_spk_config))
-			pr_err("%s: th vi ftm cfg failed\n", __func__);
-		this_afe.th_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED;
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-	if ((this_afe.ex_ftm_cfg.mode == MSM_SPKR_PROT_IN_FTM_MODE) &&
-	    (this_afe.vi_tx_port == port_id)) {
-		afe_spk_config.ex_vi_mode_cfg.minor_version = 1;
-		afe_spk_config.ex_vi_mode_cfg.operation_mode =
-						Q6AFE_MSM_SPKR_FTM_MODE;
-		if (afe_spk_prot_prepare(port_id, 0,
-					 AFE_PARAM_ID_SP_V2_EX_VI_MODE_CFG,
-					 &afe_spk_config))
-			pr_err("%s: ex vi mode cfg failed\n", __func__);
-
-		afe_spk_config.ex_vi_ftm_cfg.minor_version = 1;
-		afe_spk_config.ex_vi_ftm_cfg.wait_time_ms[SP_V2_SPKR_1] =
-			this_afe.ex_ftm_cfg.wait_time[SP_V2_SPKR_1];
-		afe_spk_config.ex_vi_ftm_cfg.wait_time_ms[SP_V2_SPKR_2] =
-			this_afe.ex_ftm_cfg.wait_time[SP_V2_SPKR_2];
-		afe_spk_config.ex_vi_ftm_cfg.ftm_time_ms[SP_V2_SPKR_1] =
-			this_afe.ex_ftm_cfg.ftm_time[SP_V2_SPKR_1];
-		afe_spk_config.ex_vi_ftm_cfg.ftm_time_ms[SP_V2_SPKR_2] =
-			this_afe.ex_ftm_cfg.ftm_time[SP_V2_SPKR_2];
-
-		if (afe_spk_prot_prepare(port_id, 0,
-					 AFE_PARAM_ID_SP_V2_EX_VI_FTM_CFG,
-					 &afe_spk_config))
-			pr_err("%s: ex vi ftm cfg failed\n", __func__);
-		this_afe.ex_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED;
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-
-}
-
-static void afe_send_cal_spkr_prot_rx(int port_id)
-{
-	union afe_spkr_prot_config afe_spk_config;
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_CAL] == NULL)
-		goto done;
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-
-	if (this_afe.prot_cfg.mode != MSM_SPKR_PROT_DISABLED &&
-		(this_afe.vi_rx_port == port_id)) {
-		if (this_afe.prot_cfg.mode ==
-			MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS)
-			afe_spk_config.mode_rx_cfg.mode =
-				Q6AFE_MSM_SPKR_CALIBRATION;
-		else
-			afe_spk_config.mode_rx_cfg.mode =
-				Q6AFE_MSM_SPKR_PROCESSING;
-		afe_spk_config.mode_rx_cfg.minor_version = 1;
-		if (afe_spk_prot_prepare(port_id, 0,
-			AFE_PARAM_ID_FBSP_MODE_RX_CFG,
-			&afe_spk_config))
-			pr_err("%s: RX MODE_VI_PROC_CFG failed\n",
-				   __func__);
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-done:
-	return;
-}
-
-static int afe_send_hw_delay(u16 port_id, u32 rate)
-{
-	struct audio_cal_hw_delay_entry		delay_entry;
-	struct afe_audioif_config_command	config;
-	int index = 0;
-	int ret = -EINVAL;
-
-	pr_debug("%s:\n", __func__);
-
-	memset(&delay_entry, 0, sizeof(delay_entry));
-	delay_entry.sample_rate = rate;
-	if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX)
-		ret = afe_get_cal_hw_delay(TX_DEVICE, &delay_entry);
-	else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX)
-		ret = afe_get_cal_hw_delay(RX_DEVICE, &delay_entry);
-
-	/*
-	 * HW delay is only used for IMS calls to sync audio with video
-	 * It is only needed for devices & sample rates used for IMS video
-	 * calls. Values are received from ACDB calbration files
-	 */
-	if (ret != 0) {
-		pr_debug("%s: debug: HW delay info not available %d\n",
-			__func__, ret);
-		goto fail_cmd;
-	}
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = AFE_PARAM_ID_DEVICE_HW_DELAY;
-	config.pdata.param_size = sizeof(config.port);
-
-	config.port.hw_delay.delay_in_us = delay_entry.delay_usec;
-	config.port.hw_delay.device_hw_delay_minor_version =
-				AFE_API_VERSION_DEVICE_HW_DELAY;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE hw delay for port 0x%x failed %d\n",
-		       __func__, port_id, ret);
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	pr_debug("%s: port_id 0x%x rate %u delay_usec %d status %d\n",
-	__func__, port_id, rate, delay_entry.delay_usec, ret);
-	return ret;
-}
-
-static struct cal_block_data *afe_find_cal_topo_id_by_port(
-			struct cal_type_data *cal_type, u16 port_id)
-{
-	struct list_head		*ptr, *next;
-	struct cal_block_data	*cal_block = NULL;
-	int32_t path;
-	struct audio_cal_info_afe_top *afe_top;
-	int afe_port_index = q6audio_get_port_index(port_id);
-
-	if (afe_port_index < 0)
-		goto err_exit;
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		path = ((afe_get_port_type(port_id) ==
-			MSM_AFE_PORT_TYPE_TX)?(TX_DEVICE):(RX_DEVICE));
-		afe_top =
-		(struct audio_cal_info_afe_top *)cal_block->cal_info;
-		if (afe_top->path == path) {
-			if (this_afe.dev_acdb_id[afe_port_index] > 0) {
-				if (afe_top->acdb_id ==
-				    this_afe.dev_acdb_id[afe_port_index]) {
-					pr_debug("%s: top_id:%x acdb_id:%d afe_port_id:%d\n",
-						 __func__, afe_top->topology,
-						 afe_top->acdb_id,
-						 q6audio_get_port_id(port_id));
-					return cal_block;
-				}
-			} else {
-				pr_debug("%s: top_id:%x acdb_id:%d afe_port:%d\n",
-				 __func__, afe_top->topology, afe_top->acdb_id,
-				 q6audio_get_port_id(port_id));
-				return cal_block;
-			}
-		}
-	}
-
-err_exit:
-	return NULL;
-}
-
-static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id)
-{
-	int ret = 0;
-
-	struct cal_block_data   *cal_block = NULL;
-	struct audio_cal_info_afe_top   *afe_top_info = NULL;
-
-	if (this_afe.cal_data[AFE_TOPOLOGY_CAL] == NULL) {
-		pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized\n", __func__);
-		return -EINVAL;
-	}
-	if (topology_id == NULL) {
-		pr_err("%s: topology_id is NULL\n", __func__);
-		return -EINVAL;
-	}
-	*topology_id = 0;
-
-	mutex_lock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock);
-	cal_block = afe_find_cal_topo_id_by_port(
-		this_afe.cal_data[AFE_TOPOLOGY_CAL], port_id);
-	if (cal_block == NULL) {
-		pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n",
-				__func__, port_id);
-		ret = -EINVAL;
-		goto unlock;
-	}
-
-	afe_top_info = ((struct audio_cal_info_afe_top *)
-		cal_block->cal_info);
-	if (!afe_top_info->topology) {
-		pr_err("%s: invalid topology id : [%d, %d]\n",
-		       __func__, afe_top_info->acdb_id, afe_top_info->topology);
-		ret = -EINVAL;
-		goto unlock;
-	}
-	*topology_id = (u32)afe_top_info->topology;
-
-	pr_debug("%s: port_id = %u acdb_id = %d topology_id = %u ret=%d\n",
-		__func__, port_id, afe_top_info->acdb_id,
-		afe_top_info->topology, ret);
-unlock:
-	mutex_unlock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock);
-	return ret;
-}
-
-static int afe_send_port_topology_id(u16 port_id)
-{
-	struct afe_audioif_config_command	config;
-	int index = 0;
-	int ret = 0;
-	u32 topology_id = 0;
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-
-	ret = afe_get_cal_topology_id(port_id, &topology_id);
-	if (ret || !topology_id) {
-		pr_debug("%s: AFE port[%d] get_cal_topology[%d] invalid!\n",
-				__func__, port_id, topology_id);
-		goto done;
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id   = AFE_PARAM_ID_SET_TOPOLOGY;
-	config.pdata.param_size =  sizeof(config.port);
-	config.port.topology.minor_version = AFE_API_VERSION_TOPOLOGY_V1;
-	config.port.topology.topology_id = topology_id;
-
-	pr_debug("%s: param PL size=%d iparam_size[%d][%zd %zd %zd %zd] param_id[0x%x]\n",
-		__func__, config.param.payload_size, config.pdata.param_size,
-		sizeof(config), sizeof(config.param), sizeof(config.port),
-		sizeof(struct apr_hdr), config.pdata.param_id);
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE set topology id enable for port 0x%x failed %d\n",
-			__func__, port_id, ret);
-		goto done;
-	}
-
-	this_afe.topology[index] = topology_id;
-	rtac_update_afe_topology(port_id);
-done:
-	pr_debug("%s: AFE set topology id 0x%x  enable for port 0x%x ret %d\n",
-			__func__, topology_id, port_id, ret);
-	return ret;
-
-}
-
-static int remap_cal_data(struct cal_block_data *cal_block, int cal_index)
-{
-	int ret = 0;
-
-	if (cal_block->map_data.ion_client == NULL) {
-		pr_err("%s: No ION allocation for cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((cal_block->map_data.map_size > 0) &&
-		(cal_block->map_data.q6map_handle == 0)) {
-		atomic_set(&this_afe.mem_map_cal_index, cal_index);
-		ret = afe_cmd_memory_map(cal_block->cal_data.paddr,
-				cal_block->map_data.map_size);
-		atomic_set(&this_afe.mem_map_cal_index, -1);
-		if (ret < 0) {
-			pr_err("%s: mmap did not work! size = %zd ret %d\n",
-				__func__,
-				cal_block->map_data.map_size, ret);
-			pr_debug("%s: mmap did not work! addr = 0x%pK, size = %zd\n",
-				__func__,
-				&cal_block->cal_data.paddr,
-				cal_block->map_data.map_size);
-			goto done;
-		}
-		cal_block->map_data.q6map_handle = atomic_read(&this_afe.
-			mem_map_cal_handles[cal_index]);
-	}
-done:
-	return ret;
-}
-
-static struct cal_block_data *afe_find_cal(int cal_index, int port_id)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_afe *afe_cal_info = NULL;
-	int afe_port_index = q6audio_get_port_index(port_id);
-
-	pr_debug("%s: cal_index %d port_id %d port_index %d\n", __func__,
-		  cal_index, port_id, afe_port_index);
-	if (afe_port_index < 0) {
-		pr_err("%s: Error getting AFE port index %d\n",
-			__func__, afe_port_index);
-		goto exit;
-	}
-
-	list_for_each_safe(ptr, next,
-			   &this_afe.cal_data[cal_index]->cal_blocks) {
-		cal_block = list_entry(ptr, struct cal_block_data, list);
-		afe_cal_info = cal_block->cal_info;
-		if ((afe_cal_info->acdb_id ==
-		     this_afe.dev_acdb_id[afe_port_index]) &&
-		    (afe_cal_info->sample_rate ==
-		     this_afe.afe_sample_rates[afe_port_index])) {
-			pr_debug("%s: cal block is a match, size is %zd\n",
-				 __func__, cal_block->cal_data.size);
-			goto exit;
-		}
-	}
-	pr_err("%s: no matching cal_block found\n", __func__);
-	cal_block = NULL;
-
-exit:
-	return cal_block;
-}
-
-static void send_afe_cal_type(int cal_index, int port_id)
-{
-	struct cal_block_data		*cal_block = NULL;
-	int ret;
-	int afe_port_index = q6audio_get_port_index(port_id);
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.cal_data[cal_index] == NULL) {
-		pr_warn("%s: cal_index %d not allocated!\n",
-			__func__, cal_index);
-		goto done;
-	}
-
-	if (afe_port_index < 0) {
-		pr_err("%s: Error getting AFE port index %d\n",
-			__func__, afe_port_index);
-		goto done;
-	}
-
-	mutex_lock(&this_afe.cal_data[cal_index]->lock);
-
-	if (((cal_index == AFE_COMMON_RX_CAL) ||
-	     (cal_index == AFE_COMMON_TX_CAL)) &&
-	    (this_afe.dev_acdb_id[afe_port_index] > 0))
-		cal_block = afe_find_cal(cal_index, port_id);
-	else
-		cal_block = cal_utils_get_only_cal_block(
-				this_afe.cal_data[cal_index]);
-
-	if (cal_block == NULL) {
-		pr_err("%s cal_block not found!!\n", __func__);
-		goto unlock;
-	}
-
-	pr_debug("%s: Sending cal_index cal %d\n", __func__, cal_index);
-
-	ret = remap_cal_data(cal_block, cal_index);
-	if (ret) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, cal_index);
-		goto unlock;
-	}
-	ret = afe_send_cal_block(port_id, cal_block);
-	if (ret < 0)
-		pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d\n",
-			__func__, cal_index, port_id, ret);
-unlock:
-	mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-done:
-	return;
-}
-
-void afe_send_cal(u16 port_id)
-{
-	pr_debug("%s: port_id=0x%x\n", __func__, port_id);
-
-	if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) {
-		afe_send_cal_spkr_prot_tx(port_id);
-		send_afe_cal_type(AFE_COMMON_TX_CAL, port_id);
-	} else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX) {
-		afe_send_cal_spkr_prot_rx(port_id);
-		send_afe_cal_type(AFE_COMMON_RX_CAL, port_id);
-	}
-}
-
-int afe_turn_onoff_hw_mad(u16 mad_type, u16 enable)
-{
-	int ret;
-	struct afe_cmd_hw_mad_ctrl config;
-
-	pr_debug("%s: enter\n", __func__);
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = SLIMBUS_5_TX;
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_HW_MAD;
-	config.pdata.param_id = AFE_PARAM_ID_HW_MAD_CTRL;
-	config.pdata.param_size = sizeof(config.payload);
-	config.payload.minor_version = 1;
-	config.payload.mad_type = mad_type;
-	config.payload.mad_enable = enable;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret)
-		pr_err("%s: AFE_PARAM_ID_HW_MAD_CTRL failed %d\n", __func__,
-		       ret);
-	return ret;
-}
-
-static int afe_send_slimbus_slave_cfg(
-	struct afe_param_cdc_slimbus_slave_cfg *sb_slave_cfg)
-{
-	int ret;
-	struct afe_svc_cmd_sb_slave_cfg config;
-
-	pr_debug("%s: enter\n", __func__);
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
-	config.pdata.param_id = AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG;
-	config.pdata.param_size =
-	    sizeof(struct afe_param_cdc_slimbus_slave_cfg);
-	config.sb_slave_cfg = *sb_slave_cfg;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret)
-		pr_err("%s: AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG failed %d\n",
-		       __func__, ret);
-
-	pr_debug("%s: leave %d\n", __func__, ret);
-	return ret;
-}
-
-static int afe_send_codec_reg_page_config(
-	struct afe_param_cdc_reg_page_cfg *cdc_reg_page_cfg)
-{
-	struct afe_svc_cmd_cdc_reg_page_cfg config;
-	int ret;
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
-	config.pdata.param_id = AFE_PARAM_ID_CDC_REG_PAGE_CFG;
-	config.pdata.param_size =
-	    sizeof(struct afe_param_cdc_reg_page_cfg);
-	config.cdc_reg_page_cfg = *cdc_reg_page_cfg;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret)
-		pr_err("%s: AFE_PARAM_ID_CDC_REG_PAGE_CFG failed %d\n",
-		       __func__, ret);
-
-	return ret;
-}
-
-static int afe_send_codec_reg_config(
-	struct afe_param_cdc_reg_cfg_data *cdc_reg_cfg)
-{
-	int i, j, ret = -EINVAL;
-	int pkt_size, payload_size, reg_per_pkt, num_pkts, num_regs;
-	struct afe_svc_cmd_cdc_reg_cfg *config;
-	struct afe_svc_cmd_set_param *param;
-
-	reg_per_pkt = (APR_MAX_BUF - sizeof(*config)) /
-			sizeof(struct afe_param_cdc_reg_cfg_payload);
-	if (reg_per_pkt > 0) {
-		num_pkts = (cdc_reg_cfg->num_registers / reg_per_pkt) +
-			(cdc_reg_cfg->num_registers % reg_per_pkt == 0 ? 0 : 1);
-	} else {
-		pr_err("%s: Failed to build codec reg config APR packet\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	for (j = 0; j < num_pkts; ++j) {
-		/*
-		 * num_regs is set to reg_per_pkt on each pass through the loop
-		 * except the last, when it is set to the number of registers
-		 * remaining from the total
-		 */
-		num_regs = (j < (num_pkts - 1) ? reg_per_pkt :
-				cdc_reg_cfg->num_registers - (reg_per_pkt * j));
-		payload_size = sizeof(struct afe_param_cdc_reg_cfg_payload) *
-				num_regs;
-		pkt_size = sizeof(*config) + payload_size;
-		pr_debug("%s: pkt_size %d, payload_size %d\n", __func__,
-			 pkt_size, payload_size);
-		config = kzalloc(pkt_size, GFP_KERNEL);
-		if (!config)
-			return -ENOMEM;
-
-		config->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						      APR_HDR_LEN(APR_HDR_SIZE),
-						      APR_PKT_VER);
-		config->hdr.pkt_size = pkt_size;
-		config->hdr.src_port = 0;
-		config->hdr.dest_port = 0;
-		config->hdr.token = IDX_GLOBAL_CFG;
-		config->hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-		param = &config->param;
-		param->payload_size = payload_size;
-		param->payload_address_lsw = 0x00;
-		param->payload_address_msw = 0x00;
-		param->mem_map_handle = 0x00;
-
-		for (i = 0; i < num_regs; i++) {
-			config->reg_data[i].common.module_id =
-						AFE_MODULE_CDC_DEV_CFG;
-			config->reg_data[i].common.param_id =
-						AFE_PARAM_ID_CDC_REG_CFG;
-			config->reg_data[i].common.param_size =
-			    sizeof(config->reg_data[i].reg_cfg);
-			config->reg_data[i].reg_cfg =
-				cdc_reg_cfg->reg_data[i + (j * reg_per_pkt)];
-		}
-
-		ret = afe_apr_send_pkt(config, &this_afe.wait[IDX_GLOBAL_CFG]);
-		if (ret) {
-			pr_err("%s: AFE_PARAM_ID_CDC_REG_CFG failed %d\n",
-				__func__, ret);
-			kfree(config);
-			break;
-		}
-		kfree(config);
-	}
-
-	return ret;
-}
-
-static int afe_init_cdc_reg_config(void)
-{
-	int ret;
-	struct afe_svc_cmd_init_cdc_reg_cfg config;
-
-	pr_debug("%s: enter\n", __func__);
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-	config.param.payload_size = sizeof(struct afe_port_param_data_v2);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-
-	config.init.module_id = AFE_MODULE_CDC_DEV_CFG;
-	config.init.param_id = AFE_PARAM_ID_CDC_REG_CFG_INIT;
-	config.init.param_size = 0;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret) {
-		pr_err("%s: AFE_PARAM_ID_CDC_INIT_REG_CFG failed %d\n",
-		       __func__, ret);
-	}
-
-	return ret;
-}
-
-static int afe_send_slimbus_slave_port_cfg(
-	struct afe_param_slimbus_slave_port_cfg *port_config, u16 port_id)
-{
-	int ret, index;
-	struct afe_cmd_hw_mad_slimbus_slave_port_cfg config;
-
-	pr_debug("%s: enter, port_id =  0x%x\n", __func__, port_id);
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id = 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = port_id;
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_HW_MAD;
-	config.pdata.param_id = AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG;
-	config.pdata.param_size = sizeof(*port_config);
-	config.sb_port_cfg = *port_config;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG failed %d\n",
-			__func__, ret);
-	}
-	pr_debug("%s: leave %d\n", __func__, ret);
-	return ret;
-}
-static int afe_aanc_port_cfg(void *apr, uint16_t tx_port, uint16_t rx_port)
-{
-	struct afe_port_cmd_set_aanc_param cfg;
-	int ret = 0;
-	int index = 0;
-
-	pr_debug("%s: tx_port 0x%x, rx_port 0x%x\n",
-		__func__, tx_port, rx_port);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	index = q6audio_get_port_index(tx_port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(tx_port);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, tx_port, ret);
-		return -EINVAL;
-	}
-	pr_debug("%s: AANC sample rate tx rate: %d rx rate %d\n",
-		__func__, this_afe.aanc_info.aanc_tx_port_sample_rate,
-	       this_afe.aanc_info.aanc_rx_port_sample_rate);
-	/*
-	 * If aanc tx sample rate or rx sample rate is zero, skip aanc
-	 * configuration as AFE resampler will fail for invalid sample
-	 * rates.
-	 */
-	if (!this_afe.aanc_info.aanc_tx_port_sample_rate ||
-	    !this_afe.aanc_info.aanc_rx_port_sample_rate) {
-		return -EINVAL;
-	}
-
-	cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cfg.hdr.pkt_size = sizeof(cfg);
-	cfg.hdr.src_port = 0;
-	cfg.hdr.dest_port = 0;
-	cfg.hdr.token = index;
-	cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-
-	cfg.param.port_id = tx_port;
-	cfg.param.payload_size        = sizeof(struct afe_port_param_data_v2) +
-					sizeof(struct afe_param_aanc_port_cfg);
-	cfg.param.payload_address_lsw     = 0;
-	cfg.param.payload_address_msw     = 0;
-	cfg.param.mem_map_handle	  = 0;
-
-	cfg.pdata.module_id = AFE_MODULE_AANC;
-	cfg.pdata.param_id    = AFE_PARAM_ID_AANC_PORT_CONFIG;
-	cfg.pdata.param_size = sizeof(struct afe_param_aanc_port_cfg);
-	cfg.pdata.reserved    = 0;
-
-	cfg.data.aanc_port_cfg.aanc_port_cfg_minor_version =
-		AFE_API_VERSION_AANC_PORT_CONFIG;
-	cfg.data.aanc_port_cfg.tx_port_sample_rate =
-		this_afe.aanc_info.aanc_tx_port_sample_rate;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[0] = AANC_TX_VOICE_MIC;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[1] = AANC_TX_NOISE_MIC;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[2] = AANC_TX_ERROR_MIC;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[3] = AANC_TX_MIC_UNUSED;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[4] = AANC_TX_MIC_UNUSED;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[5] = AANC_TX_MIC_UNUSED;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[6] = AANC_TX_MIC_UNUSED;
-	cfg.data.aanc_port_cfg.tx_port_channel_map[7] = AANC_TX_MIC_UNUSED;
-	cfg.data.aanc_port_cfg.tx_port_num_channels = 3;
-	cfg.data.aanc_port_cfg.rx_path_ref_port_id = rx_port;
-	cfg.data.aanc_port_cfg.ref_port_sample_rate =
-		 this_afe.aanc_info.aanc_rx_port_sample_rate;
-
-	ret = afe_apr_send_pkt((uint32_t *) &cfg, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE AANC port config failed for tx_port 0x%x, rx_port 0x%x ret %d\n",
-			__func__, tx_port, rx_port, ret);
-	}
-
-	return ret;
-}
-
-static int afe_aanc_mod_enable(void *apr, uint16_t tx_port, uint16_t enable)
-{
-	struct afe_port_cmd_set_aanc_param cfg;
-	int ret = 0;
-	int index = 0;
-
-	pr_debug("%s: tx_port 0x%x\n",
-		__func__, tx_port);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	index = q6audio_get_port_index(tx_port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(tx_port);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, tx_port, ret);
-		return -EINVAL;
-	}
-
-	cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cfg.hdr.pkt_size = sizeof(cfg);
-	cfg.hdr.src_port = 0;
-	cfg.hdr.dest_port = 0;
-	cfg.hdr.token = index;
-	cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-
-	cfg.param.port_id = tx_port;
-	cfg.param.payload_size        = sizeof(struct afe_port_param_data_v2) +
-					sizeof(struct afe_mod_enable_param);
-	cfg.param.payload_address_lsw     = 0;
-	cfg.param.payload_address_lsw     = 0;
-	cfg.param.mem_map_handle          = 0;
-
-	cfg.pdata.module_id = AFE_MODULE_AANC;
-	cfg.pdata.param_id    = AFE_PARAM_ID_ENABLE;
-	cfg.pdata.param_size = sizeof(struct afe_mod_enable_param);
-	cfg.pdata.reserved    = 0;
-
-	cfg.data.mod_enable.enable = enable;
-	cfg.data.mod_enable.reserved = 0;
-
-	ret = afe_apr_send_pkt((uint32_t *) &cfg, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE AANC enable failed for tx_port 0x%x ret %d\n",
-			__func__, tx_port, ret);
-	}
-	return ret;
-}
-
-static int afe_send_bank_selection_clip(
-		struct afe_param_id_clip_bank_sel *param)
-{
-	int ret;
-	struct afe_svc_cmd_set_clip_bank_selection config;
-
-	if (!param) {
-		pr_err("%s: Invalid params", __func__);
-		return -EINVAL;
-	}
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-	config.param.payload_size = sizeof(struct afe_port_param_data_v2) +
-				sizeof(struct afe_param_id_clip_bank_sel);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-
-	config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
-	config.pdata.param_id = AFE_PARAM_ID_CLIP_BANK_SEL_CFG;
-	config.pdata.param_size =
-		sizeof(struct afe_param_id_clip_bank_sel);
-	config.bank_sel = *param;
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret) {
-		pr_err("%s: AFE_PARAM_ID_CLIP_BANK_SEL_CFG failed %d\n",
-		__func__, ret);
-	}
-	return ret;
-}
-int afe_send_aanc_version(
-	struct afe_param_id_cdc_aanc_version *version_cfg)
-{
-	int ret;
-	struct afe_svc_cmd_cdc_aanc_version config;
-
-	pr_debug("%s: enter\n", __func__);
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-	config.param.payload_size = sizeof(struct afe_port_param_data_v2) +
-				sizeof(struct afe_param_id_cdc_aanc_version);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-
-	config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
-	config.pdata.param_id = AFE_PARAM_ID_CDC_AANC_VERSION;
-	config.pdata.param_size =
-		sizeof(struct afe_param_id_cdc_aanc_version);
-	config.version = *version_cfg;
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret) {
-		pr_err("%s: AFE_PARAM_ID_CDC_AANC_VERSION failed %d\n",
-		__func__, ret);
-	}
-	return ret;
-}
-
-int afe_port_set_mad_type(u16 port_id, enum afe_mad_type mad_type)
-{
-	int i;
-
-	if (port_id == AFE_PORT_ID_TERTIARY_MI2S_TX ||
-		port_id == AFE_PORT_ID_INT3_MI2S_TX) {
-		mad_type = MAD_SW_AUDIO;
-		return 0;
-	}
-
-	i = port_id - SLIMBUS_0_RX;
-	if (i < 0 || i >= ARRAY_SIZE(afe_ports_mad_type)) {
-		pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-	atomic_set(&afe_ports_mad_type[i], mad_type);
-	return 0;
-}
-
-enum afe_mad_type afe_port_get_mad_type(u16 port_id)
-{
-	int i;
-
-	if (port_id == AFE_PORT_ID_TERTIARY_MI2S_TX ||
-		port_id == AFE_PORT_ID_INT3_MI2S_TX)
-		return MAD_SW_AUDIO;
-
-	i = port_id - SLIMBUS_0_RX;
-	if (i < 0 || i >= ARRAY_SIZE(afe_ports_mad_type)) {
-		pr_debug("%s: Non Slimbus port_id 0x%x\n", __func__, port_id);
-		return MAD_HW_NONE;
-	}
-	return (enum afe_mad_type) atomic_read(&afe_ports_mad_type[i]);
-}
-
-int afe_set_config(enum afe_config_type config_type, void *config_data, int arg)
-{
-	int ret;
-
-	pr_debug("%s: enter config_type %d\n", __func__, config_type);
-	ret = afe_q6_interface_prepare();
-	if (ret) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	switch (config_type) {
-	case AFE_SLIMBUS_SLAVE_CONFIG:
-		ret = afe_send_slimbus_slave_cfg(config_data);
-		if (!ret)
-			ret = afe_init_cdc_reg_config();
-		else
-			pr_err("%s: Sending slimbus slave config failed %d\n",
-			       __func__, ret);
-		break;
-	case AFE_CDC_REGISTERS_CONFIG:
-		ret = afe_send_codec_reg_config(config_data);
-		break;
-	case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
-		ret = afe_send_slimbus_slave_port_cfg(config_data, arg);
-		break;
-	case AFE_AANC_VERSION:
-		ret = afe_send_aanc_version(config_data);
-		break;
-	case AFE_CLIP_BANK_SEL:
-		ret = afe_send_bank_selection_clip(config_data);
-		break;
-	case AFE_CDC_CLIP_REGISTERS_CONFIG:
-		ret = afe_send_codec_reg_config(config_data);
-		break;
-	case AFE_CDC_REGISTER_PAGE_CONFIG:
-		ret = afe_send_codec_reg_page_config(config_data);
-		break;
-	default:
-		pr_err("%s: unknown configuration type %d",
-			__func__, config_type);
-		ret = -EINVAL;
-	}
-
-	if (!ret)
-		set_bit(config_type, &afe_configured_cmd);
-
-	return ret;
-}
-EXPORT_SYMBOL(afe_set_config);
-
-/*
- * afe_clear_config - If SSR happens ADSP loses AFE configs, let AFE driver know
- *		      about the state so client driver can wait until AFE is
- *		      reconfigured.
- */
-void afe_clear_config(enum afe_config_type config)
-{
-	clear_bit(config, &afe_configured_cmd);
-}
-EXPORT_SYMBOL(afe_clear_config);
-
-bool afe_has_config(enum afe_config_type config)
-{
-	return !!test_bit(config, &afe_configured_cmd);
-}
-
-int afe_send_spdif_clk_cfg(struct afe_param_id_spdif_clk_cfg *cfg,
-		u16 port_id)
-{
-	struct afe_spdif_clk_config_command clk_cfg;
-	int ret = 0;
-	int index = 0;
-
-	if (!cfg) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	clk_cfg.param.port_id = q6audio_get_port_id(port_id);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-		- sizeof(clk_cfg.param);
-	clk_cfg.clk_cfg = *cfg;
-
-	pr_debug("%s: Minor version = 0x%x clk val = %d\n"
-			"clk root = 0x%x\n port id = 0x%x\n",
-			__func__, cfg->clk_cfg_minor_version,
-			cfg->clk_value, cfg->clk_root,
-			q6audio_get_port_id(port_id));
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE send clock config for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n",
-				__func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_send_spdif_ch_status_cfg(struct afe_param_id_spdif_ch_status_cfg
-		*ch_status_cfg,	u16 port_id)
-{
-	struct afe_spdif_chstatus_config_command ch_status;
-	int ret = 0;
-	int index = 0;
-
-	if (!ch_status_cfg) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-	ch_status.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	ch_status.hdr.pkt_size = sizeof(ch_status_cfg);
-	ch_status.hdr.src_port = 0;
-	ch_status.hdr.dest_port = 0;
-	ch_status.hdr.token = index;
-
-	ch_status.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	ch_status.param.port_id = q6audio_get_port_id(port_id);
-	ch_status.param.payload_address_lsw = 0x00;
-	ch_status.param.payload_address_msw = 0x00;
-	ch_status.param.mem_map_handle = 0x00;
-	ch_status.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	ch_status.pdata.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
-	ch_status.pdata.param_size =  sizeof(ch_status.ch_status);
-	ch_status.param.payload_size = sizeof(ch_status)
-		- sizeof(struct apr_hdr) - sizeof(ch_status.param);
-	ch_status.ch_status = *ch_status_cfg;
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &ch_status);
-	if (ret < 0) {
-		pr_err("%s: AFE send channel status for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n",
-				__func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-static int afe_send_cmd_port_start(u16 port_id)
-{
-	struct afe_port_cmd_device_start start;
-	int ret, index;
-
-	pr_debug("%s: enter\n", __func__);
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					    APR_HDR_LEN(APR_HDR_SIZE),
-					    APR_PKT_VER);
-	start.hdr.pkt_size = sizeof(start);
-	start.hdr.src_port = 0;
-	start.hdr.dest_port = 0;
-	start.hdr.token = index;
-	start.hdr.opcode = AFE_PORT_CMD_DEVICE_START;
-	start.port_id = q6audio_get_port_id(port_id);
-	pr_debug("%s: cmd device start opcode[0x%x] port id[0x%x]\n",
-		 __func__, start.hdr.opcode, start.port_id);
-
-	ret = afe_apr_send_pkt(&start, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed %d\n", __func__,
-		       port_id, ret);
-	} else if (this_afe.task != current) {
-		this_afe.task = current;
-		pr_debug("task_name = %s pid = %d\n",
-			 this_afe.task->comm, this_afe.task->pid);
-	}
-
-	return ret;
-}
-
-static int afe_aanc_start(uint16_t tx_port_id, uint16_t rx_port_id)
-{
-	int ret;
-
-	pr_debug("%s:  Tx port is 0x%x, Rx port is 0x%x\n",
-		 __func__, tx_port_id, rx_port_id);
-	ret = afe_aanc_port_cfg(this_afe.apr, tx_port_id, rx_port_id);
-	if (ret) {
-		pr_err("%s: Send AANC Port Config failed %d\n",
-			__func__, ret);
-		goto fail_cmd;
-	}
-	send_afe_cal_type(AFE_AANC_CAL, tx_port_id);
-
-fail_cmd:
-	return ret;
-}
-
-int afe_spdif_port_start(u16 port_id, struct afe_spdif_port_config *spdif_port,
-		u32 rate)
-{
-	struct afe_audioif_config_command config;
-	int ret = 0;
-	int index = 0;
-	uint16_t port_index;
-
-	if (!spdif_port) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-
-	pr_debug("%s: port id: 0x%x\n", __func__, port_id);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	afe_send_cal(port_id);
-	afe_send_hw_delay(port_id, rate);
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-		sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = AFE_PARAM_ID_SPDIF_CONFIG;
-	config.pdata.param_size = sizeof(config.port);
-	config.port.spdif = spdif_port->cfg;
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		goto fail_cmd;
-	}
-
-	port_index = afe_get_port_index(port_id);
-	if ((port_index >= 0) && (port_index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[port_index] = rate;
-	} else {
-		pr_err("%s: Invalid port index %d\n", __func__, port_index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = afe_send_spdif_ch_status_cfg(&spdif_port->ch_status, port_id);
-	if (ret < 0) {
-		pr_err("%s: afe send failed %d\n", __func__, ret);
-		goto fail_cmd;
-	}
-
-	return afe_send_cmd_port_start(port_id);
-
-fail_cmd:
-	return ret;
-}
-
-int afe_send_slot_mapping_cfg(
-	struct afe_param_id_slot_mapping_cfg *slot_mapping_cfg,
-	u16 port_id)
-{
-	struct afe_slot_mapping_config_command config;
-	int ret = 0;
-	int index = 0;
-
-	if (!slot_mapping_cfg) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: port id: 0x%x\n", __func__, port_id);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config)
-		- sizeof(struct apr_hdr) - sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_TDM;
-	config.pdata.param_id = AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG;
-	config.pdata.param_size =  sizeof(config.slot_mapping);
-	config.slot_mapping = *slot_mapping_cfg;
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
-	if (ret < 0) {
-		pr_err("%s: AFE send slot mapping for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n",
-				__func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_send_custom_tdm_header_cfg(
-	struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header_cfg,
-	u16 port_id)
-{
-	struct afe_custom_tdm_header_config_command config;
-	int ret = 0;
-	int index = 0;
-
-	if (!custom_tdm_header_cfg) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: port id: 0x%x\n", __func__, port_id);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config)
-		- sizeof(struct apr_hdr) - sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_TDM;
-	config.pdata.param_id = AFE_PARAM_ID_CUSTOM_TDM_HEADER_CONFIG;
-	config.pdata.param_size =  sizeof(config.custom_tdm_header);
-	config.custom_tdm_header = *custom_tdm_header_cfg;
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
-	if (ret < 0) {
-		pr_err("%s: AFE send custom tdm header for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n",
-				__func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port,
-		       u32 rate, u16 num_groups)
-{
-	struct afe_audioif_config_command config;
-	int ret = 0;
-	int index = 0;
-	uint16_t port_index = 0;
-	enum afe_mad_type mad_type = MAD_HW_NONE;
-
-	if (!tdm_port) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: port id: 0x%x\n", __func__, port_id);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	if ((index >= 0) && (index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[index] = rate;
-
-		if (this_afe.rt_cb)
-			this_afe.dev_acdb_id[index] = this_afe.rt_cb(port_id);
-	}
-
-	/* Also send the topology id here if multiple ports: */
-	port_index = afe_get_port_index(port_id);
-	if (!(this_afe.afe_cal_mode[port_index] == AFE_CAL_MODE_NONE) &&
-	    num_groups > 1) {
-		/* One time call: only for first time */
-		afe_send_custom_topology();
-		afe_send_port_topology_id(port_id);
-		afe_send_cal(port_id);
-		afe_send_hw_delay(port_id, rate);
-	}
-
-	/* Start SW MAD module */
-	mad_type = afe_port_get_mad_type(port_id);
-	pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
-		 mad_type);
-	if (mad_type != MAD_HW_NONE && mad_type != MAD_SW_AUDIO) {
-		if (!afe_has_config(AFE_CDC_REGISTERS_CONFIG) ||
-			!afe_has_config(AFE_SLIMBUS_SLAVE_CONFIG)) {
-			pr_err("%s: AFE isn't configured yet for\n"
-				"HW MAD try Again\n", __func__);
-				ret = -EAGAIN;
-				goto fail_cmd;
-		}
-		ret = afe_turn_onoff_hw_mad(mad_type, true);
-		if (ret) {
-			pr_err("%s: afe_turn_onoff_hw_mad failed %d\n",
-			       __func__, ret);
-			goto fail_cmd;
-		}
-	}
-
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-		sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = AFE_PARAM_ID_TDM_CONFIG;
-	config.pdata.param_size = sizeof(config.port);
-	config.port.tdm = tdm_port->tdm;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed ret = %d\n",
-				__func__, port_id, ret);
-		goto fail_cmd;
-	}
-
-	port_index = afe_get_port_index(port_id);
-	if ((port_index >= 0) && (port_index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[port_index] = rate;
-	} else {
-		pr_err("%s: Invalid port index %d\n", __func__, port_index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	/* slot mapping is not need if there is only one group */
-	if (num_groups > 1) {
-		ret = afe_send_slot_mapping_cfg(&tdm_port->slot_mapping,
-						port_id);
-		if (ret < 0) {
-			pr_err("%s: afe send failed %d\n", __func__, ret);
-			goto fail_cmd;
-		}
-	}
-
-	if (tdm_port->custom_tdm_header.header_type) {
-		ret = afe_send_custom_tdm_header_cfg(
-			&tdm_port->custom_tdm_header, port_id);
-		if (ret < 0) {
-			pr_err("%s: afe send failed %d\n", __func__, ret);
-			goto fail_cmd;
-		}
-	}
-
-	ret = afe_send_cmd_port_start(port_id);
-
-fail_cmd:
-	return ret;
-}
-
-void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode)
-{
-	uint16_t port_index;
-
-	port_index = afe_get_port_index(port_id);
-	this_afe.afe_cal_mode[port_index] = afe_cal_mode;
-}
-
-void afe_set_routing_callback(routing_cb cb)
-{
-	this_afe.rt_cb = cb;
-}
-
-int afe_port_send_usb_dev_param(u16 port_id, union afe_port_config *afe_config)
-{
-	struct afe_usb_audio_dev_param_command config;
-	int ret = 0, index = 0;
-
-	if (!afe_config) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		goto exit;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid! for port ID 0x%x\n",
-				__func__, index, port_id);
-		ret = -EINVAL;
-		goto exit;
-	}
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS;
-	config.pdata.param_size = sizeof(config.usb_dev);
-	config.usb_dev.cfg_minor_version =
-				AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
-	config.usb_dev.dev_token = afe_config->usb_audio.dev_token;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE device param cmd failed %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	config.pdata.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT;
-	config.pdata.param_size = sizeof(config.lpcm_fmt);
-	config.lpcm_fmt.cfg_minor_version =
-		AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
-	config.lpcm_fmt.endian = afe_config->usb_audio.endian;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE device param cmd LPCM_FMT failed %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-exit:
-	return ret;
-}
-
-static int q6afe_send_enc_config(u16 port_id,
-				 union afe_enc_config_data *cfg, u32 format,
-				 union afe_port_config afe_config,
-				 u16 afe_in_channels, u16 afe_in_bit_width)
-{
-	struct afe_audioif_config_command config;
-	int index;
-	int ret;
-	int payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				sizeof(config.param) - sizeof(config.port);
-
-	pr_debug("%s:update DSP for enc format = %d\n", __func__, format);
-	if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
-	    format != ASM_MEDIA_FMT_APTX && format != ASM_MEDIA_FMT_APTX_HD) {
-		pr_err("%s:Unsuppported format Ignore AFE config\n", __func__);
-		return 0;
-	}
-	memset(&config, 0, sizeof(config));
-	index = q6audio_get_port_index(port_id);
-	if (index < 0) {
-		pr_err("%s: Invalid index number: %d\n", __func__, index);
-		return -EINVAL;
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = payload_size + sizeof(config.port.enc_fmt);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_ID_ENCODER;
-	config.pdata.param_id = AFE_ENCODER_PARAM_ID_ENC_FMT_ID;
-	config.pdata.param_size = sizeof(config.port.enc_fmt);
-	config.port.enc_fmt.fmt_id = format;
-	pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENC_FMT_ID payload: %d\n",
-			__func__, config.param.payload_size);
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s:unable to send AFE_ENCODER_PARAM_ID_ENC_FMT_ID",
-				__func__);
-		goto exit;
-	}
-
-	config.param.payload_size = payload_size
-					+ sizeof(config.port.enc_blk_param);
-	pr_debug("%s:send AFE_ENCODER_PARAM_ID_ENC_CFG_BLK to DSP payload:%d\n",
-				__func__, config.param.payload_size);
-	config.pdata.param_id = AFE_ENCODER_PARAM_ID_ENC_CFG_BLK;
-	config.pdata.param_size = sizeof(config.port.enc_blk_param);
-	config.port.enc_blk_param.enc_cfg_blk_size =
-			sizeof(config.port.enc_blk_param.enc_blk_config);
-	config.port.enc_blk_param.enc_blk_config = *cfg;
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE_ENCODER_PARAM_ID_ENC_CFG_BLK for port 0x%x failed %d\n",
-			__func__, port_id, ret);
-		goto exit;
-	}
-
-	config.param.payload_size =
-			payload_size + sizeof(config.port.enc_pkt_id_param);
-	pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP payload = %d",
-					__func__, config.param.payload_size);
-	config.pdata.param_id = AFE_ENCODER_PARAM_ID_PACKETIZER_ID;
-	config.pdata.param_size = sizeof(config.port.enc_pkt_id_param);
-	config.port.enc_pkt_id_param.enc_packetizer_id =
-					AFE_MODULE_ID_PACKETIZER_COP;
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE_ENCODER_PARAM_ID_PACKETIZER for port 0x%x failed %d\n",
-			__func__, port_id, ret);
-		goto exit;
-	}
-
-	config.param.payload_size =
-			payload_size + sizeof(config.port.media_type);
-	config.pdata.param_size = sizeof(config.port.media_type);
-
-	pr_debug("%s:Sending AFE_API_VERSION_PORT_MEDIA_TYPE to DSP", __func__);
-	config.pdata.module_id = AFE_MODULE_PORT;
-	config.pdata.param_id = AFE_PARAM_ID_PORT_MEDIA_TYPE;
-	config.port.media_type.minor_version = AFE_API_VERSION_PORT_MEDIA_TYPE;
-	config.port.media_type.sample_rate = afe_config.slim_sch.sample_rate;
-	if (afe_in_bit_width)
-		config.port.media_type.bit_width = afe_in_bit_width;
-	else
-		config.port.media_type.bit_width =
-					afe_config.slim_sch.bit_width;
-
-	if (afe_in_channels)
-		config.port.media_type.num_channels = afe_in_channels;
-	else
-		config.port.media_type.num_channels =
-					afe_config.slim_sch.num_channels;
-	config.port.media_type.data_format = AFE_PORT_DATA_FORMAT_PCM;
-	config.port.media_type.reserved = 0;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE_API_VERSION_PORT_MEDIA_TYPE for port 0x%x failed %d\n",
-			__func__, port_id, ret);
-		goto exit;
-	}
-
-exit:
-	return ret;
-}
-
-static int __afe_port_start(u16 port_id, union afe_port_config *afe_config,
-			    u32 rate, u16 afe_in_channels, u16 afe_in_bit_width,
-			    union afe_enc_config_data *cfg, u32 enc_format)
-{
-	struct afe_audioif_config_command config;
-	int ret = 0;
-	int cfg_type;
-	int index = 0;
-	enum afe_mad_type mad_type;
-	uint16_t port_index;
-
-	if (!afe_config) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-
-	if ((port_id == RT_PROXY_DAI_001_RX) ||
-		(port_id == RT_PROXY_DAI_002_TX)) {
-		pr_debug("%s: before incrementing pcm_afe_instance %d port_id 0x%x\n",
-			__func__,
-			pcm_afe_instance[port_id & 0x1], port_id);
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-		pcm_afe_instance[port_id & 0x1]++;
-		return 0;
-	}
-	if ((port_id == RT_PROXY_DAI_002_RX) ||
-			(port_id == RT_PROXY_DAI_001_TX)) {
-		pr_debug("%s: before incrementing proxy_afe_instance %d port_id 0x%x\n",
-			__func__,
-			proxy_afe_instance[port_id & 0x1], port_id);
-
-		if (!afe_close_done[port_id & 0x1]) {
-			/*close pcm dai corresponding to the proxy dai*/
-			afe_close(port_id - 0x10);
-			pcm_afe_instance[port_id & 0x1]++;
-			pr_debug("%s: reconfigure afe port again\n", __func__);
-		}
-		proxy_afe_instance[port_id & 0x1]++;
-		afe_close_done[port_id & 0x1] = false;
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-	}
-
-	pr_debug("%s: port id: 0x%x\n", __func__, port_id);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	if ((index >= 0) && (index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[index] = rate;
-
-		if (this_afe.rt_cb)
-			this_afe.dev_acdb_id[index] = this_afe.rt_cb(port_id);
-	}
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	/* Also send the topology id here: */
-	port_index = afe_get_port_index(port_id);
-	if (!(this_afe.afe_cal_mode[port_index] == AFE_CAL_MODE_NONE)) {
-		/* One time call: only for first time */
-		afe_send_custom_topology();
-		afe_send_port_topology_id(port_id);
-		afe_send_cal(port_id);
-		afe_send_hw_delay(port_id, rate);
-	}
-
-	/* Start SW MAD module */
-	mad_type = afe_port_get_mad_type(port_id);
-	pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
-		 mad_type);
-	if (mad_type != MAD_HW_NONE && mad_type != MAD_SW_AUDIO) {
-		if (!afe_has_config(AFE_CDC_REGISTERS_CONFIG) ||
-			!afe_has_config(AFE_SLIMBUS_SLAVE_CONFIG)) {
-			pr_err("%s: AFE isn't configured yet for\n"
-				"HW MAD try Again\n", __func__);
-				ret = -EAGAIN;
-				goto fail_cmd;
-		}
-		ret = afe_turn_onoff_hw_mad(mad_type, true);
-		if (ret) {
-			pr_err("%s: afe_turn_onoff_hw_mad failed %d\n",
-			       __func__, ret);
-			goto fail_cmd;
-		}
-	}
-
-	if ((this_afe.aanc_info.aanc_active) &&
-	    (this_afe.aanc_info.aanc_tx_port == port_id)) {
-		this_afe.aanc_info.aanc_tx_port_sample_rate = rate;
-		port_index =
-			afe_get_port_index(this_afe.aanc_info.aanc_rx_port);
-		if ((port_index >= 0) && (port_index < AFE_MAX_PORTS)) {
-			this_afe.aanc_info.aanc_rx_port_sample_rate =
-				this_afe.afe_sample_rates[port_index];
-		} else {
-			pr_err("%s: Invalid port index %d\n",
-				__func__, port_index);
-			ret = -EINVAL;
-			goto fail_cmd;
-		}
-		ret = afe_aanc_start(this_afe.aanc_info.aanc_tx_port,
-				this_afe.aanc_info.aanc_rx_port);
-		pr_debug("%s: afe_aanc_start ret %d\n", __func__, ret);
-	}
-
-	if ((port_id == AFE_PORT_ID_USB_RX) ||
-	    (port_id == AFE_PORT_ID_USB_TX)) {
-		ret = afe_port_send_usb_dev_param(port_id, afe_config);
-		if (ret) {
-			pr_err("%s: AFE device param for port 0x%x failed %d\n",
-				   __func__, port_id, ret);
-			ret = -EINVAL;
-			goto fail_cmd;
-		}
-	}
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-
-	switch (port_id) {
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-		cfg_type = AFE_PARAM_ID_PCM_CONFIG;
-		break;
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-	case AFE_PORT_ID_INT0_MI2S_RX:
-	case AFE_PORT_ID_INT0_MI2S_TX:
-	case AFE_PORT_ID_INT1_MI2S_RX:
-	case AFE_PORT_ID_INT1_MI2S_TX:
-	case AFE_PORT_ID_INT2_MI2S_RX:
-	case AFE_PORT_ID_INT2_MI2S_TX:
-	case AFE_PORT_ID_INT3_MI2S_RX:
-	case AFE_PORT_ID_INT3_MI2S_TX:
-	case AFE_PORT_ID_INT4_MI2S_RX:
-	case AFE_PORT_ID_INT4_MI2S_TX:
-	case AFE_PORT_ID_INT5_MI2S_RX:
-	case AFE_PORT_ID_INT5_MI2S_TX:
-	case AFE_PORT_ID_INT6_MI2S_RX:
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
-		break;
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-		cfg_type = AFE_PARAM_ID_HDMI_CONFIG;
-		break;
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case VOICE_RECORD_RX:
-	case VOICE_RECORD_TX:
-		cfg_type = AFE_PARAM_ID_PSEUDO_PORT_CONFIG;
-		break;
-	case SLIMBUS_0_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-		cfg_type = AFE_PARAM_ID_SLIMBUS_CONFIG;
-		break;
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-		cfg_type = AFE_PARAM_ID_USB_AUDIO_CONFIG;
-		break;
-	case RT_PROXY_PORT_001_RX:
-	case RT_PROXY_PORT_001_TX:
-		cfg_type = AFE_PARAM_ID_RT_PROXY_CONFIG;
-		break;
-	case INT_BT_SCO_RX:
-	case INT_BT_A2DP_RX:
-	case INT_BT_SCO_TX:
-	case INT_FM_RX:
-	case INT_FM_TX:
-		cfg_type = AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG;
-		break;
-	default:
-		pr_err("%s: Invalid port id 0x%x\n", __func__, port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = cfg_type;
-	config.pdata.param_size = sizeof(config.port);
-
-	config.port = *afe_config;
-	if ((enc_format != ASM_MEDIA_FMT_NONE) &&
-	    (cfg_type == AFE_PARAM_ID_SLIMBUS_CONFIG)) {
-		config.port.slim_sch.data_format =
-				AFE_SB_DATA_FORMAT_GENERIC_COMPRESSED;
-	}
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed %d\n",
-			__func__, port_id, ret);
-		goto fail_cmd;
-	}
-
-	if ((enc_format != ASM_MEDIA_FMT_NONE) &&
-	    (cfg_type == AFE_PARAM_ID_SLIMBUS_CONFIG)) {
-		pr_debug("%s: Found AFE encoder support for SLIMBUS enc_format = %d\n",
-					__func__, enc_format);
-		ret = q6afe_send_enc_config(port_id, cfg, enc_format,
-					    *afe_config, afe_in_channels,
-					    afe_in_bit_width);
-		if (ret) {
-			pr_err("%s: AFE encoder config for port 0x%x failed %d\n",
-				__func__, port_id, ret);
-			goto fail_cmd;
-		}
-	}
-
-	port_index = afe_get_port_index(port_id);
-	if ((port_index >= 0) && (port_index < AFE_MAX_PORTS)) {
-		/*
-		 * If afe_port_start() for tx port called before
-		 * rx port, then aanc rx sample rate is zero. So,
-		 * AANC state machine in AFE will not get triggered.
-		 * Make sure to check whether aanc is active during
-		 * afe_port_start() for rx port and if aanc rx
-		 * sample rate is zero, call afe_aanc_start to configure
-		 * aanc with valid sample rates.
-		 */
-		if (this_afe.aanc_info.aanc_active &&
-		    !this_afe.aanc_info.aanc_rx_port_sample_rate) {
-			this_afe.aanc_info.aanc_rx_port_sample_rate =
-				this_afe.afe_sample_rates[port_index];
-			ret = afe_aanc_start(this_afe.aanc_info.aanc_tx_port,
-					this_afe.aanc_info.aanc_rx_port);
-			pr_debug("%s: afe_aanc_start ret %d\n", __func__, ret);
-		}
-	} else {
-		pr_err("%s: Invalid port index %d\n", __func__, port_index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	ret = afe_send_cmd_port_start(port_id);
-
-fail_cmd:
-	mutex_unlock(&this_afe.afe_cmd_lock);
-	return ret;
-}
-
-/**
- * afe_port_start - to configure AFE session with
- * specified port configuration
- *
- * @port_id: AFE port id number
- * @afe_config: port configutation
- * @rate: sampling rate of port
- *
- * Returns 0 on success or error value on port start failure.
- */
-int afe_port_start(u16 port_id, union afe_port_config *afe_config,
-		   u32 rate)
-{
-	return __afe_port_start(port_id, afe_config, rate,
-				0, 0, NULL, ASM_MEDIA_FMT_NONE);
-}
-EXPORT_SYMBOL(afe_port_start);
-
-/**
- * afe_port_start_v2 - to configure AFE session with
- * specified port configuration and encoder params
- *
- * @port_id: AFE port id number
- * @afe_config: port configutation
- * @rate: sampling rate of port
- * @cfg: AFE encoder configuration information to setup encoder
- * @afe_in_channels: AFE input channel configuration, this needs
- *  update only if input channel is differ from AFE output
- *
- * Returns 0 on success or error value on port start failure.
- */
-int afe_port_start_v2(u16 port_id, union afe_port_config *afe_config,
-		      u32 rate, u16 afe_in_channels, u16 afe_in_bit_width,
-		      struct afe_enc_config *enc_cfg)
-{
-	return __afe_port_start(port_id, afe_config, rate,
-				afe_in_channels, afe_in_bit_width,
-				&enc_cfg->data, enc_cfg->format);
-}
-EXPORT_SYMBOL(afe_port_start_v2);
-
-int afe_get_port_index(u16 port_id)
-{
-	switch (port_id) {
-	case PRIMARY_I2S_RX: return IDX_PRIMARY_I2S_RX;
-	case PRIMARY_I2S_TX: return IDX_PRIMARY_I2S_TX;
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_PCM_RX;
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_PCM_TX;
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_PCM_RX;
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_PCM_TX;
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_PCM_RX;
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_PCM_TX;
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_PCM_RX;
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_PCM_TX;
-	case SECONDARY_I2S_RX: return IDX_SECONDARY_I2S_RX;
-	case SECONDARY_I2S_TX: return IDX_SECONDARY_I2S_TX;
-	case MI2S_RX: return IDX_MI2S_RX;
-	case MI2S_TX: return IDX_MI2S_TX;
-	case HDMI_RX: return IDX_HDMI_RX;
-	case DISPLAY_PORT_RX: return IDX_DISPLAY_PORT_RX;
-	case AFE_PORT_ID_SPDIF_RX: return IDX_SPDIF_RX;
-	case RSVD_2: return IDX_RSVD_2;
-	case RSVD_3: return IDX_RSVD_3;
-	case DIGI_MIC_TX: return IDX_DIGI_MIC_TX;
-	case VOICE_RECORD_RX: return IDX_VOICE_RECORD_RX;
-	case VOICE_RECORD_TX: return IDX_VOICE_RECORD_TX;
-	case VOICE_PLAYBACK_TX: return IDX_VOICE_PLAYBACK_TX;
-	case VOICE2_PLAYBACK_TX: return IDX_VOICE2_PLAYBACK_TX;
-	case SLIMBUS_0_RX: return IDX_SLIMBUS_0_RX;
-	case SLIMBUS_0_TX: return IDX_SLIMBUS_0_TX;
-	case SLIMBUS_1_RX: return IDX_SLIMBUS_1_RX;
-	case SLIMBUS_1_TX: return IDX_SLIMBUS_1_TX;
-	case SLIMBUS_2_RX: return IDX_SLIMBUS_2_RX;
-	case SLIMBUS_2_TX: return IDX_SLIMBUS_2_TX;
-	case SLIMBUS_3_RX: return IDX_SLIMBUS_3_RX;
-	case SLIMBUS_3_TX: return IDX_SLIMBUS_3_TX;
-	case INT_BT_SCO_RX: return IDX_INT_BT_SCO_RX;
-	case INT_BT_SCO_TX: return IDX_INT_BT_SCO_TX;
-	case INT_BT_A2DP_RX: return IDX_INT_BT_A2DP_RX;
-	case INT_FM_RX: return IDX_INT_FM_RX;
-	case INT_FM_TX: return IDX_INT_FM_TX;
-	case RT_PROXY_PORT_001_RX: return IDX_RT_PROXY_PORT_001_RX;
-	case RT_PROXY_PORT_001_TX: return IDX_RT_PROXY_PORT_001_TX;
-	case SLIMBUS_4_RX: return IDX_SLIMBUS_4_RX;
-	case SLIMBUS_4_TX: return IDX_SLIMBUS_4_TX;
-	case SLIMBUS_5_RX: return IDX_SLIMBUS_5_RX;
-	case SLIMBUS_5_TX: return IDX_SLIMBUS_5_TX;
-	case SLIMBUS_6_RX: return IDX_SLIMBUS_6_RX;
-	case SLIMBUS_6_TX: return IDX_SLIMBUS_6_TX;
-	case SLIMBUS_7_RX: return IDX_SLIMBUS_7_RX;
-	case SLIMBUS_7_TX: return IDX_SLIMBUS_7_TX;
-	case SLIMBUS_8_RX: return IDX_SLIMBUS_8_RX;
-	case SLIMBUS_8_TX: return IDX_SLIMBUS_8_TX;
-	case AFE_PORT_ID_USB_RX: return IDX_AFE_PORT_ID_USB_RX;
-	case AFE_PORT_ID_USB_TX: return IDX_AFE_PORT_ID_USB_TX;
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_MI2S_RX;
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_MI2S_TX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX;
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_TX;
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_MI2S_RX;
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_MI2S_TX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_QUINARY_MI2S_RX;
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_QUINARY_MI2S_TX;
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_SENARY_MI2S_TX;
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7;
-	case AFE_PORT_ID_INT0_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT0_MI2S_RX;
-	case AFE_PORT_ID_INT0_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT0_MI2S_TX;
-	case AFE_PORT_ID_INT1_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT1_MI2S_RX;
-	case AFE_PORT_ID_INT1_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT1_MI2S_TX;
-	case AFE_PORT_ID_INT2_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT2_MI2S_RX;
-	case AFE_PORT_ID_INT2_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT2_MI2S_TX;
-	case AFE_PORT_ID_INT3_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT3_MI2S_RX;
-	case AFE_PORT_ID_INT3_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT3_MI2S_TX;
-	case AFE_PORT_ID_INT4_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT4_MI2S_RX;
-	case AFE_PORT_ID_INT4_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT4_MI2S_TX;
-	case AFE_PORT_ID_INT5_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT5_MI2S_RX;
-	case AFE_PORT_ID_INT5_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT5_MI2S_TX;
-	case AFE_PORT_ID_INT6_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT6_MI2S_RX;
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT6_MI2S_TX;
-	default:
-		pr_err("%s: port 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-}
-
-int afe_open(u16 port_id,
-		union afe_port_config *afe_config, int rate)
-{
-	struct afe_port_cmd_device_start start;
-	struct afe_audioif_config_command config;
-	int ret = 0;
-	int cfg_type;
-	int index = 0;
-
-	if (!afe_config) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-
-	pr_err("%s: port_id 0x%x rate %d\n", __func__, port_id, rate);
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	if ((port_id == RT_PROXY_DAI_001_RX) ||
-		(port_id == RT_PROXY_DAI_002_TX)) {
-		pr_err("%s: wrong port 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-	if ((port_id == RT_PROXY_DAI_002_RX) ||
-		(port_id == RT_PROXY_DAI_001_TX))
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	if ((index >= 0) && (index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[index] = rate;
-
-		if (this_afe.rt_cb)
-			this_afe.dev_acdb_id[index] = this_afe.rt_cb(port_id);
-	}
-
-	/* Also send the topology id here: */
-	afe_send_custom_topology(); /* One time call: only for first time  */
-	afe_send_port_topology_id(port_id);
-
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Failed : Invalid Port id = 0x%x ret %d\n",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-	mutex_lock(&this_afe.afe_cmd_lock);
-
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = index;
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
-		break;
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-		cfg_type = AFE_PARAM_ID_PCM_CONFIG;
-		break;
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
-		break;
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-		cfg_type = AFE_PARAM_ID_HDMI_CONFIG;
-		break;
-	case SLIMBUS_0_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-		cfg_type = AFE_PARAM_ID_SLIMBUS_CONFIG;
-		break;
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-		cfg_type = AFE_PARAM_ID_USB_AUDIO_CONFIG;
-		break;
-	default:
-		pr_err("%s: Invalid port id 0x%x\n",
-			__func__, port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	config.param.port_id = q6audio_get_port_id(port_id);
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr)
-				 - sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	config.pdata.param_id = cfg_type;
-	config.pdata.param_size =  sizeof(config.port);
-
-	config.port = *afe_config;
-	pr_debug("%s: param PL size=%d iparam_size[%d][%zd %zd %zd %zd] param_id[0x%x]\n",
-		__func__, config.param.payload_size, config.pdata.param_size,
-		sizeof(config), sizeof(config.param), sizeof(config.port),
-		sizeof(struct apr_hdr), config.pdata.param_id);
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x opcode[0x%x]failed %d\n",
-			__func__, port_id, cfg_type, ret);
-		goto fail_cmd;
-	}
-	start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	start.hdr.pkt_size = sizeof(start);
-	start.hdr.src_port = 0;
-	start.hdr.dest_port = 0;
-	start.hdr.token = index;
-	start.hdr.opcode = AFE_PORT_CMD_DEVICE_START;
-	start.port_id = q6audio_get_port_id(port_id);
-	pr_debug("%s: cmd device start opcode[0x%x] port id[0x%x]\n",
-		__func__, start.hdr.opcode, start.port_id);
-
-	ret = afe_apr_send_pkt(&start, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed %d\n", __func__,
-				port_id, ret);
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	mutex_unlock(&this_afe.afe_cmd_lock);
-	return ret;
-}
-
-int afe_loopback(u16 enable, u16 rx_port, u16 tx_port)
-{
-	struct afe_loopback_cfg_v1 lb_cmd;
-	int ret = 0;
-	int index = 0;
-
-	if (rx_port == MI2S_RX)
-		rx_port = AFE_PORT_ID_PRIMARY_MI2S_RX;
-	if (tx_port == MI2S_TX)
-		tx_port = AFE_PORT_ID_PRIMARY_MI2S_TX;
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	index = q6audio_get_port_index(rx_port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(rx_port);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d", __func__, rx_port, ret);
-		return -EINVAL;
-	}
-
-	lb_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(20), APR_PKT_VER);
-	lb_cmd.hdr.pkt_size = sizeof(lb_cmd);
-	lb_cmd.hdr.src_port = 0;
-	lb_cmd.hdr.dest_port = 0;
-	lb_cmd.hdr.token = index;
-	lb_cmd.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	lb_cmd.param.port_id = tx_port;
-	lb_cmd.param.payload_size = (sizeof(lb_cmd) - sizeof(struct apr_hdr) -
-				     sizeof(struct afe_port_cmd_set_param_v2));
-	lb_cmd.param.payload_address_lsw = 0x00;
-	lb_cmd.param.payload_address_msw = 0x00;
-	lb_cmd.param.mem_map_handle = 0x00;
-	lb_cmd.pdata.module_id = AFE_MODULE_LOOPBACK;
-	lb_cmd.pdata.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
-	lb_cmd.pdata.param_size = lb_cmd.param.payload_size -
-				  sizeof(struct afe_port_param_data_v2);
-
-	lb_cmd.dst_port_id = rx_port;
-	lb_cmd.routing_mode = LB_MODE_DEFAULT;
-	lb_cmd.enable = (enable ? 1 : 0);
-	lb_cmd.loopback_cfg_minor_version = AFE_API_VERSION_LOOPBACK_CONFIG;
-
-	ret = afe_apr_send_pkt(&lb_cmd, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE loopback failed %d\n", __func__, ret);
-	return ret;
-}
-
-int afe_loopback_gain(u16 port_id, u16 volume)
-{
-	struct afe_loopback_gain_per_path_param set_param;
-	int ret = 0;
-	int index = 0;
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Failed : Invalid Port id = 0x%x ret %d\n",
-			__func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	/* RX ports numbers are even .TX ports numbers are odd. */
-	if (port_id % 2 == 0) {
-		pr_err("%s: Failed : afe loopback gain only for TX ports. port_id %d\n",
-				__func__, port_id);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	pr_debug("%s: port 0x%x volume %d\n", __func__, port_id, volume);
-
-	set_param.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	set_param.hdr.pkt_size = sizeof(set_param);
-	set_param.hdr.src_port = 0;
-	set_param.hdr.dest_port = 0;
-	set_param.hdr.token = index;
-	set_param.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-
-	set_param.param.port_id	= port_id;
-	set_param.param.payload_size =
-	    (sizeof(struct afe_loopback_gain_per_path_param) -
-	     sizeof(struct apr_hdr) - sizeof(struct afe_port_cmd_set_param_v2));
-	set_param.param.payload_address_lsw	= 0;
-	set_param.param.payload_address_msw	= 0;
-	set_param.param.mem_map_handle        = 0;
-
-	set_param.pdata.module_id = AFE_MODULE_LOOPBACK;
-	set_param.pdata.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
-	set_param.pdata.param_size =
-	    (set_param.param.payload_size -
-	     sizeof(struct afe_port_param_data_v2));
-	set_param.rx_port_id = port_id;
-	set_param.gain = volume;
-
-	ret = afe_apr_send_pkt(&set_param, &this_afe.wait[index]);
-	if (ret) {
-		pr_err("%s: AFE param set failed for port 0x%x ret %d\n",
-					__func__, port_id, ret);
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_pseudo_port_start_nowait(u16 port_id)
-{
-	struct afe_pseudoport_start_command start;
-	int ret = 0;
-
-	pr_debug("%s: port_id=0x%x\n", __func__, port_id);
-	if (this_afe.apr == NULL) {
-		pr_err("%s: AFE APR is not registered\n", __func__);
-		return -ENODEV;
-	}
-
-
-	start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	start.hdr.pkt_size = sizeof(start);
-	start.hdr.src_port = 0;
-	start.hdr.dest_port = 0;
-	start.hdr.token = 0;
-	start.hdr.opcode = AFE_PSEUDOPORT_CMD_START;
-	start.port_id = port_id;
-	start.timing = 1;
-
-	ret = afe_apr_send_pkt(&start, NULL);
-	if (ret) {
-		pr_err("%s: AFE enable for port 0x%x failed %d\n",
-		       __func__, port_id, ret);
-		return ret;
-	}
-	return 0;
-}
-
-int afe_start_pseudo_port(u16 port_id)
-{
-	int ret = 0;
-	struct afe_pseudoport_start_command start;
-	int index = 0;
-
-	pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	start.hdr.pkt_size = sizeof(start);
-	start.hdr.src_port = 0;
-	start.hdr.dest_port = 0;
-	start.hdr.token = 0;
-	start.hdr.opcode = AFE_PSEUDOPORT_CMD_START;
-	start.port_id = port_id;
-	start.timing = 1;
-	start.hdr.token = index;
-
-	ret = afe_apr_send_pkt(&start, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE enable for port 0x%x failed %d\n",
-		       __func__, port_id, ret);
-	return ret;
-}
-
-int afe_pseudo_port_stop_nowait(u16 port_id)
-{
-	int ret = 0;
-	struct afe_pseudoport_stop_command stop;
-	int index = 0;
-
-	pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: AFE is already closed\n", __func__);
-		return -EINVAL;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	stop.hdr.pkt_size = sizeof(stop);
-	stop.hdr.src_port = 0;
-	stop.hdr.dest_port = 0;
-	stop.hdr.token = 0;
-	stop.hdr.opcode = AFE_PSEUDOPORT_CMD_STOP;
-	stop.port_id = port_id;
-	stop.reserved = 0;
-	stop.hdr.token = index;
-
-	ret = afe_apr_send_pkt(&stop, NULL);
-	if (ret)
-		pr_err("%s: AFE close failed %d\n", __func__, ret);
-
-	return ret;
-}
-
-int afe_port_group_set_param(u16 group_id,
-	union afe_port_group_config *afe_group_config)
-{
-	int ret;
-	struct afe_port_group_create config;
-	int cfg_type;
-
-	if (!afe_group_config) {
-		pr_err("%s: Error, no configuration data\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: group id: 0x%x\n", __func__, group_id);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	switch (group_id) {
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
-	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
-		cfg_type = AFE_PARAM_ID_GROUP_DEVICE_TDM_CONFIG;
-		break;
-	default:
-		pr_err("%s: Invalid group id 0x%x\n", __func__, group_id);
-		return -EINVAL;
-	}
-
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_GROUP_DEVICE;
-	config.pdata.param_id = cfg_type;
-	config.pdata.param_size = sizeof(config.data);
-	config.data = *afe_group_config;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret)
-		pr_err("%s: AFE_PARAM_ID_GROUP_DEVICE_CFG failed %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-int afe_port_group_enable(u16 group_id,
-	union afe_port_group_config *afe_group_config,
-	u16 enable)
-{
-	int ret;
-	struct afe_port_group_create config;
-
-	pr_debug("%s: group id: 0x%x enable: %d\n", __func__,
-		group_id, enable);
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	if (enable) {
-		ret = afe_port_group_set_param(group_id, afe_group_config);
-		if (ret < 0) {
-			pr_err("%s: afe send failed %d\n", __func__, ret);
-			return ret;
-		}
-	}
-
-	memset(&config, 0, sizeof(config));
-	config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	config.hdr.pkt_size = sizeof(config);
-	config.hdr.src_port = 0;
-	config.hdr.dest_port = 0;
-	config.hdr.token = IDX_GLOBAL_CFG;
-	config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-
-	config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
-				    sizeof(config.param);
-	config.param.payload_address_lsw = 0x00;
-	config.param.payload_address_msw = 0x00;
-	config.param.mem_map_handle = 0x00;
-	config.pdata.module_id = AFE_MODULE_GROUP_DEVICE;
-	config.pdata.param_id = AFE_PARAM_ID_GROUP_DEVICE_ENABLE;
-	config.pdata.param_size = sizeof(config.data);
-	config.data.group_enable.group_id = group_id;
-	config.data.group_enable.enable = enable;
-
-	ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
-	if (ret)
-		pr_err("%s: AFE_PARAM_ID_GROUP_DEVICE_ENABLE failed %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-int afe_stop_pseudo_port(u16 port_id)
-{
-	int ret = 0;
-	struct afe_pseudoport_stop_command stop;
-	int index = 0;
-
-	pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: AFE is already closed\n", __func__);
-		return -EINVAL;
-	}
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d\n",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	stop.hdr.pkt_size = sizeof(stop);
-	stop.hdr.src_port = 0;
-	stop.hdr.dest_port = 0;
-	stop.hdr.token = 0;
-	stop.hdr.opcode = AFE_PSEUDOPORT_CMD_STOP;
-	stop.port_id = port_id;
-	stop.reserved = 0;
-	stop.hdr.token = index;
-
-	ret = afe_apr_send_pkt(&stop, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE close failed %d\n", __func__, ret);
-
-	return ret;
-}
-
-uint32_t afe_req_mmap_handle(struct afe_audio_client *ac)
-{
-	return ac->mem_map_handle;
-}
-
-struct afe_audio_client *q6afe_audio_client_alloc(void *priv)
-{
-	struct afe_audio_client *ac;
-	int lcnt = 0;
-
-	ac = kzalloc(sizeof(struct afe_audio_client), GFP_KERNEL);
-	if (!ac)
-		return NULL;
-
-	ac->priv = priv;
-
-	init_waitqueue_head(&ac->cmd_wait);
-	INIT_LIST_HEAD(&ac->port[0].mem_map_handle);
-	INIT_LIST_HEAD(&ac->port[1].mem_map_handle);
-	pr_debug("%s: mem_map_handle list init'ed\n", __func__);
-	mutex_init(&ac->cmd_lock);
-	for (lcnt = 0; lcnt <= OUT; lcnt++) {
-		mutex_init(&ac->port[lcnt].lock);
-		spin_lock_init(&ac->port[lcnt].dsp_lock);
-	}
-	atomic_set(&ac->cmd_state, 0);
-
-	return ac;
-}
-
-int q6afe_audio_client_buf_alloc_contiguous(unsigned int dir,
-			struct afe_audio_client *ac,
-			unsigned int bufsz,
-			unsigned int bufcnt)
-{
-	int cnt = 0;
-	int rc = 0;
-	struct afe_audio_buffer *buf;
-	size_t len;
-
-	if (!(ac) || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: bufsz[%d]bufcnt[%d]\n",
-			__func__,
-			bufsz, bufcnt);
-
-	if (ac->port[dir].buf) {
-		pr_debug("%s: buffer already allocated\n", __func__);
-		return 0;
-	}
-	mutex_lock(&ac->cmd_lock);
-	buf = kzalloc(((sizeof(struct afe_audio_buffer))*bufcnt),
-			GFP_KERNEL);
-
-	if (!buf) {
-		pr_err("%s: null buf\n", __func__);
-		mutex_unlock(&ac->cmd_lock);
-		goto fail;
-	}
-
-	ac->port[dir].buf = buf;
-
-	rc = msm_audio_ion_alloc("afe_client", &buf[0].client,
-				&buf[0].handle, bufsz*bufcnt,
-				&buf[0].phys, &len,
-				&buf[0].data);
-	if (rc) {
-		pr_err("%s: audio ION alloc failed, rc = %d\n",
-			__func__, rc);
-		mutex_unlock(&ac->cmd_lock);
-		goto fail;
-	}
-
-	buf[0].used = dir ^ 1;
-	buf[0].size = bufsz;
-	buf[0].actual_size = bufsz;
-	cnt = 1;
-	while (cnt < bufcnt) {
-		if (bufsz > 0) {
-			buf[cnt].data =  buf[0].data + (cnt * bufsz);
-			buf[cnt].phys =  buf[0].phys + (cnt * bufsz);
-			if (!buf[cnt].data) {
-				pr_err("%s: Buf alloc failed\n",
-							__func__);
-				mutex_unlock(&ac->cmd_lock);
-				goto fail;
-			}
-			buf[cnt].used = dir ^ 1;
-			buf[cnt].size = bufsz;
-			buf[cnt].actual_size = bufsz;
-			pr_debug("%s:  data[%pK]phys[%pK][%pK]\n", __func__,
-				   buf[cnt].data,
-				   &buf[cnt].phys,
-				   &buf[cnt].phys);
-		}
-		cnt++;
-	}
-	ac->port[dir].max_buf_cnt = cnt;
-	mutex_unlock(&ac->cmd_lock);
-	return 0;
-fail:
-	pr_err("%s: jump fail\n", __func__);
-	q6afe_audio_client_buf_free_contiguous(dir, ac);
-	return -EINVAL;
-}
-
-int afe_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz,
-			struct afe_audio_client *ac)
-{
-	int ret = 0;
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	ac->mem_map_handle = 0;
-	ret = afe_cmd_memory_map(dma_addr_p, dma_buf_sz);
-	if (ret < 0) {
-		pr_err("%s: afe_cmd_memory_map failed %d\n",
-			__func__, ret);
-
-		mutex_unlock(&this_afe.afe_cmd_lock);
-		return ret;
-	}
-	ac->mem_map_handle = this_afe.mmap_handle;
-	mutex_unlock(&this_afe.afe_cmd_lock);
-
-	return ret;
-}
-
-int afe_cmd_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz)
-{
-	int ret = 0;
-	int cmd_size = 0;
-	void    *payload = NULL;
-	void    *mmap_region_cmd = NULL;
-	struct afe_service_cmd_shared_mem_map_regions *mregion = NULL;
-	struct  afe_service_shared_map_region_payload *mregion_pl = NULL;
-	int index = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-	if (dma_buf_sz % SZ_4K != 0) {
-		/*
-		 * The memory allocated by msm_audio_ion_alloc is always 4kB
-		 * aligned, ADSP expects the size to be 4kB aligned as well
-		 * so re-adjusts the  buffer size before passing to ADSP.
-		 */
-		dma_buf_sz = PAGE_ALIGN(dma_buf_sz);
-	}
-
-	cmd_size = sizeof(struct afe_service_cmd_shared_mem_map_regions)
-		+ sizeof(struct afe_service_shared_map_region_payload);
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (!mmap_region_cmd)
-		return -ENOMEM;
-
-	mregion = (struct afe_service_cmd_shared_mem_map_regions *)
-							mmap_region_cmd;
-	mregion->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mregion->hdr.pkt_size = cmd_size;
-	mregion->hdr.src_port = 0;
-	mregion->hdr.dest_port = 0;
-	mregion->hdr.token = 0;
-	mregion->hdr.opcode = AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS;
-	mregion->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	mregion->num_regions = 1;
-	mregion->property_flag = 0x00;
-	/* Todo */
-	index = mregion->hdr.token = IDX_RSVD_2;
-
-	payload = ((u8 *) mmap_region_cmd +
-		   sizeof(struct afe_service_cmd_shared_mem_map_regions));
-
-	mregion_pl = (struct afe_service_shared_map_region_payload *)payload;
-
-	mregion_pl->shm_addr_lsw = lower_32_bits(dma_addr_p);
-	mregion_pl->shm_addr_msw = msm_audio_populate_upper_32_bits(dma_addr_p);
-	mregion_pl->mem_size_bytes = dma_buf_sz;
-
-	pr_debug("%s: dma_addr_p 0x%pK , size %d\n", __func__,
-					&dma_addr_p, dma_buf_sz);
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	this_afe.mmap_handle = 0;
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) mmap_region_cmd);
-	if (ret < 0) {
-		pr_err("%s: AFE memory map cmd failed %d\n",
-		       __func__, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-				 (atomic_read(&this_afe.state) == 0),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-	kfree(mmap_region_cmd);
-	return 0;
-fail_cmd:
-	kfree(mmap_region_cmd);
-	pr_err("%s: fail_cmd\n", __func__);
-	return ret;
-}
-
-int afe_cmd_memory_map_nowait(int port_id, phys_addr_t dma_addr_p,
-		u32 dma_buf_sz)
-{
-	int ret = 0;
-	int cmd_size = 0;
-	void    *payload = NULL;
-	void    *mmap_region_cmd = NULL;
-	struct afe_service_cmd_shared_mem_map_regions *mregion = NULL;
-	struct  afe_service_shared_map_region_payload *mregion_pl = NULL;
-	int index = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	cmd_size = sizeof(struct afe_service_cmd_shared_mem_map_regions)
-		+ sizeof(struct afe_service_shared_map_region_payload);
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (!mmap_region_cmd)
-		return -ENOMEM;
-
-	mregion = (struct afe_service_cmd_shared_mem_map_regions *)
-						mmap_region_cmd;
-	mregion->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mregion->hdr.pkt_size = sizeof(mregion);
-	mregion->hdr.src_port = 0;
-	mregion->hdr.dest_port = 0;
-	mregion->hdr.token = 0;
-	mregion->hdr.opcode = AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS;
-	mregion->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	mregion->num_regions = 1;
-	mregion->property_flag = 0x00;
-
-	payload = ((u8 *) mmap_region_cmd +
-		sizeof(struct afe_service_cmd_shared_mem_map_regions));
-	mregion_pl = (struct afe_service_shared_map_region_payload *)payload;
-
-	mregion_pl->shm_addr_lsw = lower_32_bits(dma_addr_p);
-	mregion_pl->shm_addr_msw = msm_audio_populate_upper_32_bits(dma_addr_p);
-	mregion_pl->mem_size_bytes = dma_buf_sz;
-
-	ret = afe_apr_send_pkt(mmap_region_cmd, NULL);
-	if (ret)
-		pr_err("%s: AFE memory map cmd failed %d\n",
-		       __func__, ret);
-	kfree(mmap_region_cmd);
-	return ret;
-}
-int q6afe_audio_client_buf_free_contiguous(unsigned int dir,
-			struct afe_audio_client *ac)
-{
-	struct afe_audio_port_data *port;
-	int cnt = 0;
-
-	mutex_lock(&ac->cmd_lock);
-	port = &ac->port[dir];
-	if (!port->buf) {
-		pr_err("%s: buf is null\n", __func__);
-		mutex_unlock(&ac->cmd_lock);
-		return 0;
-	}
-	cnt = port->max_buf_cnt - 1;
-
-	if (port->buf[0].data) {
-		pr_debug("%s: data[%pK]phys[%pK][%pK] , client[%pK] handle[%pK]\n",
-			__func__,
-			port->buf[0].data,
-			&port->buf[0].phys,
-			&port->buf[0].phys,
-			port->buf[0].client,
-			port->buf[0].handle);
-		msm_audio_ion_free(port->buf[0].client, port->buf[0].handle);
-		port->buf[0].client = NULL;
-		port->buf[0].handle = NULL;
-	}
-
-	while (cnt >= 0) {
-		port->buf[cnt].data = NULL;
-		port->buf[cnt].phys = 0;
-		cnt--;
-	}
-	port->max_buf_cnt = 0;
-	kfree(port->buf);
-	port->buf = NULL;
-	mutex_unlock(&ac->cmd_lock);
-	return 0;
-}
-
-void q6afe_audio_client_free(struct afe_audio_client *ac)
-{
-	int loopcnt;
-	struct afe_audio_port_data *port;
-
-	if (!ac) {
-		pr_err("%s: audio client is NULL\n", __func__);
-		return;
-	}
-	for (loopcnt = 0; loopcnt <= OUT; loopcnt++) {
-		port = &ac->port[loopcnt];
-		if (!port->buf)
-			continue;
-		pr_debug("%s: loopcnt = %d\n", __func__, loopcnt);
-		q6afe_audio_client_buf_free_contiguous(loopcnt, ac);
-	}
-	kfree(ac);
-}
-
-int afe_cmd_memory_unmap(u32 mem_map_handle)
-{
-	int ret = 0;
-	struct afe_service_cmd_shared_mem_unmap_regions mregion;
-	int index = 0;
-
-	pr_debug("%s: handle 0x%x\n", __func__, mem_map_handle);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-
-	mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mregion.hdr.pkt_size = sizeof(mregion);
-	mregion.hdr.src_port = 0;
-	mregion.hdr.dest_port = 0;
-	mregion.hdr.token = 0;
-	mregion.hdr.opcode = AFE_SERVICE_CMD_SHARED_MEM_UNMAP_REGIONS;
-	mregion.mem_map_handle = mem_map_handle;
-
-	/* Todo */
-	index = mregion.hdr.token = IDX_RSVD_2;
-
-	atomic_set(&this_afe.status, 0);
-	ret = afe_apr_send_pkt(&mregion, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE memory unmap cmd failed %d\n",
-		       __func__, ret);
-
-	return ret;
-}
-
-int afe_cmd_memory_unmap_nowait(u32 mem_map_handle)
-{
-	int ret = 0;
-	struct afe_service_cmd_shared_mem_unmap_regions mregion;
-
-	pr_debug("%s: handle 0x%x\n", __func__, mem_map_handle);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-
-	mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mregion.hdr.pkt_size = sizeof(mregion);
-	mregion.hdr.src_port = 0;
-	mregion.hdr.dest_port = 0;
-	mregion.hdr.token = 0;
-	mregion.hdr.opcode = AFE_SERVICE_CMD_SHARED_MEM_UNMAP_REGIONS;
-	mregion.mem_map_handle = mem_map_handle;
-
-	ret = afe_apr_send_pkt(&mregion, NULL);
-	if (ret)
-		pr_err("%s: AFE memory unmap cmd failed %d\n",
-			__func__, ret);
-	return ret;
-}
-
-int afe_register_get_events(u16 port_id,
-		void (*cb)(uint32_t opcode,
-		uint32_t token, uint32_t *payload, void *priv),
-		void *private_data)
-{
-	int ret = 0;
-	struct afe_service_cmd_register_rt_port_driver rtproxy;
-
-	pr_debug("%s: port_id: 0x%x\n", __func__, port_id);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-	if ((port_id == RT_PROXY_DAI_002_RX) ||
-		(port_id == RT_PROXY_DAI_001_TX)) {
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-	} else {
-		pr_err("%s: wrong port id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	if (port_id == RT_PROXY_PORT_001_TX) {
-		this_afe.tx_cb = cb;
-		this_afe.tx_private_data = private_data;
-	} else if (port_id == RT_PROXY_PORT_001_RX) {
-		this_afe.rx_cb = cb;
-		this_afe.rx_private_data = private_data;
-	}
-
-	rtproxy.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	rtproxy.hdr.pkt_size = sizeof(rtproxy);
-	rtproxy.hdr.src_port = 1;
-	rtproxy.hdr.dest_port = 1;
-	rtproxy.hdr.opcode = AFE_SERVICE_CMD_REGISTER_RT_PORT_DRIVER;
-	rtproxy.port_id = port_id;
-	rtproxy.reserved = 0;
-
-	ret = afe_apr_send_pkt(&rtproxy, NULL);
-	if (ret)
-		pr_err("%s: AFE  reg. rtproxy_event failed %d\n",
-			   __func__, ret);
-	return ret;
-}
-
-int afe_unregister_get_events(u16 port_id)
-{
-	int ret = 0;
-	struct afe_service_cmd_unregister_rt_port_driver rtproxy;
-	int index = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-
-	if ((port_id == RT_PROXY_DAI_002_RX) ||
-		(port_id == RT_PROXY_DAI_001_TX)) {
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-	} else {
-		pr_err("%s: wrong port id 0x%x\n", __func__, port_id);
-		return -EINVAL;
-	}
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_err("%s: Invalid port 0x%x ret %d", __func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	rtproxy.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	rtproxy.hdr.pkt_size = sizeof(rtproxy);
-	rtproxy.hdr.src_port = 0;
-	rtproxy.hdr.dest_port = 0;
-	rtproxy.hdr.token = 0;
-	rtproxy.hdr.opcode = AFE_SERVICE_CMD_UNREGISTER_RT_PORT_DRIVER;
-	rtproxy.port_id = port_id;
-	rtproxy.reserved = 0;
-
-	rtproxy.hdr.token = index;
-
-	if (port_id == RT_PROXY_PORT_001_TX) {
-		this_afe.tx_cb = NULL;
-		this_afe.tx_private_data = NULL;
-	} else if (port_id == RT_PROXY_PORT_001_RX) {
-		this_afe.rx_cb = NULL;
-		this_afe.rx_private_data = NULL;
-	}
-
-	ret = afe_apr_send_pkt(&rtproxy, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE enable Unreg. rtproxy_event failed %d\n",
-			   __func__, ret);
-	return ret;
-}
-
-int afe_rt_proxy_port_write(phys_addr_t buf_addr_p,
-		u32 mem_map_handle, int bytes)
-{
-	int ret = 0;
-	struct afe_port_data_cmd_rt_proxy_port_write_v2 afecmd_wr;
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: register to AFE is not done\n", __func__);
-		ret = -ENODEV;
-		return ret;
-	}
-	pr_debug("%s: buf_addr_p = 0x%pK bytes = %d\n", __func__,
-						&buf_addr_p, bytes);
-
-	afecmd_wr.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	afecmd_wr.hdr.pkt_size = sizeof(afecmd_wr);
-	afecmd_wr.hdr.src_port = 0;
-	afecmd_wr.hdr.dest_port = 0;
-	afecmd_wr.hdr.token = 0;
-	afecmd_wr.hdr.opcode = AFE_PORT_DATA_CMD_RT_PROXY_PORT_WRITE_V2;
-	afecmd_wr.port_id = RT_PROXY_PORT_001_TX;
-	afecmd_wr.buffer_address_lsw = lower_32_bits(buf_addr_p);
-	afecmd_wr.buffer_address_msw =
-			msm_audio_populate_upper_32_bits(buf_addr_p);
-	afecmd_wr.mem_map_handle = mem_map_handle;
-	afecmd_wr.available_bytes = bytes;
-	afecmd_wr.reserved = 0;
-
-	ret = afe_apr_send_pkt(&afecmd_wr, NULL);
-	if (ret)
-		pr_err("%s: AFE rtproxy write to port 0x%x failed %d\n",
-			   __func__, afecmd_wr.port_id, ret);
-	return ret;
-
-}
-
-int afe_rt_proxy_port_read(phys_addr_t buf_addr_p,
-		u32 mem_map_handle, int bytes)
-{
-	int ret = 0;
-	struct afe_port_data_cmd_rt_proxy_port_read_v2 afecmd_rd;
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: register to AFE is not done\n", __func__);
-		ret = -ENODEV;
-		return ret;
-	}
-	pr_debug("%s: buf_addr_p = 0x%pK bytes = %d\n", __func__,
-						&buf_addr_p, bytes);
-
-	afecmd_rd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	afecmd_rd.hdr.pkt_size = sizeof(afecmd_rd);
-	afecmd_rd.hdr.src_port = 0;
-	afecmd_rd.hdr.dest_port = 0;
-	afecmd_rd.hdr.token = 0;
-	afecmd_rd.hdr.opcode = AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2;
-	afecmd_rd.port_id = RT_PROXY_PORT_001_RX;
-	afecmd_rd.buffer_address_lsw = lower_32_bits(buf_addr_p);
-	afecmd_rd.buffer_address_msw =
-				msm_audio_populate_upper_32_bits(buf_addr_p);
-	afecmd_rd.available_bytes = bytes;
-	afecmd_rd.mem_map_handle = mem_map_handle;
-
-	ret = afe_apr_send_pkt(&afecmd_rd, NULL);
-	if (ret)
-		pr_err("%s: AFE rtproxy read  cmd to port 0x%x failed %d\n",
-			   __func__, afecmd_rd.port_id, ret);
-	return ret;
-}
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_afelb;
-static struct dentry *debugfs_afelb_gain;
-
-static int afe_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	pr_info("%s: debug intf %s\n", __func__, (char *) file->private_data);
-	return 0;
-}
-
-static int afe_get_parameters(char *buf, long int *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token != NULL) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (kstrtoul(token, base, &param1[cnt]) != 0) {
-				pr_err("%s: kstrtoul failed\n",
-					__func__);
-				return -EINVAL;
-			}
-
-			token = strsep(&buf, " ");
-		} else {
-			pr_err("%s: token NULL\n", __func__);
-			return -EINVAL;
-		}
-	}
-	return 0;
-}
-#define AFE_LOOPBACK_ON (1)
-#define AFE_LOOPBACK_OFF (0)
-static ssize_t afe_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *lb_str = filp->private_data;
-	char lbuf[32];
-	int rc;
-	unsigned long param[5];
-
-	if (cnt > sizeof(lbuf) - 1) {
-		pr_err("%s: cnt %zd size %zd\n", __func__, cnt, sizeof(lbuf)-1);
-		return -EINVAL;
-	}
-
-	rc = copy_from_user(lbuf, ubuf, cnt);
-	if (rc) {
-		pr_err("%s: copy from user failed %d\n", __func__, rc);
-		return -EFAULT;
-	}
-
-	lbuf[cnt] = '\0';
-
-	if (!strcmp(lb_str, "afe_loopback")) {
-		rc = afe_get_parameters(lbuf, param, 3);
-		if (!rc) {
-			pr_info("%s: %lu %lu %lu\n", lb_str, param[0], param[1],
-				param[2]);
-
-			if ((param[0] != AFE_LOOPBACK_ON) && (param[0] !=
-				AFE_LOOPBACK_OFF)) {
-				pr_err("%s: Error, parameter 0 incorrect\n",
-					__func__);
-				rc = -EINVAL;
-				goto afe_error;
-			}
-			if ((q6audio_validate_port(param[1]) < 0) ||
-			    (q6audio_validate_port(param[2])) < 0) {
-				pr_err("%s: Error, invalid afe port\n",
-					__func__);
-			}
-			if (this_afe.apr == NULL) {
-				pr_err("%s: Error, AFE not opened\n", __func__);
-				rc = -EINVAL;
-			} else {
-				rc = afe_loopback(param[0], param[1], param[2]);
-			}
-		} else {
-			pr_err("%s: Error, invalid parameters\n", __func__);
-			rc = -EINVAL;
-		}
-
-	} else if (!strcmp(lb_str, "afe_loopback_gain")) {
-		rc = afe_get_parameters(lbuf, param, 2);
-		if (!rc) {
-			pr_info("%s: %s %lu %lu\n",
-				__func__, lb_str, param[0], param[1]);
-
-			rc = q6audio_validate_port(param[0]);
-			if (rc < 0) {
-				pr_err("%s: Error, invalid afe port %d %lu\n",
-					__func__, rc, param[0]);
-				rc = -EINVAL;
-				goto afe_error;
-			}
-
-			if (param[1] > 100) {
-				pr_err("%s: Error, volume should be 0 to 100 percentage param = %lu\n",
-					__func__, param[1]);
-				rc = -EINVAL;
-				goto afe_error;
-			}
-
-			param[1] = (Q6AFE_MAX_VOLUME * param[1]) / 100;
-
-			if (this_afe.apr == NULL) {
-				pr_err("%s: Error, AFE not opened\n", __func__);
-				rc = -EINVAL;
-			} else {
-				rc = afe_loopback_gain(param[0], param[1]);
-			}
-		} else {
-			pr_err("%s: Error, invalid parameters\n", __func__);
-			rc = -EINVAL;
-		}
-	}
-
-afe_error:
-	if (rc == 0)
-		rc = cnt;
-	else
-		pr_err("%s: rc = %d\n", __func__, rc);
-
-	return rc;
-}
-
-static const struct file_operations afe_debug_fops = {
-	.open = afe_debug_open,
-	.write = afe_debug_write
-};
-
-static void config_debug_fs_init(void)
-{
-	debugfs_afelb = debugfs_create_file("afe_loopback",
-	0664, NULL, (void *) "afe_loopback",
-	&afe_debug_fops);
-
-	debugfs_afelb_gain = debugfs_create_file("afe_loopback_gain",
-	0664, NULL, (void *) "afe_loopback_gain",
-	&afe_debug_fops);
-}
-static void config_debug_fs_exit(void)
-{
-	debugfs_remove(debugfs_afelb);
-	debugfs_remove(debugfs_afelb_gain);
-}
-#else
-static void config_debug_fs_init(void)
-{
-}
-static void config_debug_fs_exit(void)
-{
-}
-#endif
-
-void afe_set_dtmf_gen_rx_portid(u16 port_id, int set)
-{
-	if (set)
-		this_afe.dtmf_gen_rx_portid = port_id;
-	else if (this_afe.dtmf_gen_rx_portid == port_id)
-		this_afe.dtmf_gen_rx_portid = -1;
-}
-
-int afe_dtmf_generate_rx(int64_t duration_in_ms,
-			 uint16_t high_freq,
-			 uint16_t low_freq, uint16_t gain)
-{
-	int ret = 0;
-	int index = 0;
-	struct afe_dtmf_generation_command cmd_dtmf;
-
-	pr_debug("%s: DTMF AFE Gen\n", __func__);
-
-	if (afe_validate_port(this_afe.dtmf_gen_rx_portid) < 0) {
-		pr_err("%s: Failed : Invalid Port id = 0x%x\n",
-		       __func__, this_afe.dtmf_gen_rx_portid);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (this_afe.apr == NULL) {
-		this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
-					    0xFFFFFFFF, &this_afe);
-		pr_debug("%s: Register AFE\n", __func__);
-		if (this_afe.apr == NULL) {
-			pr_err("%s: Unable to register AFE\n", __func__);
-			ret = -ENODEV;
-			return ret;
-		}
-		rtac_set_afe_handle(this_afe.apr);
-	}
-
-	pr_debug("%s: dur=%lld: hfreq=%d lfreq=%d gain=%d portid=0x%x\n",
-		__func__,
-		duration_in_ms, high_freq, low_freq, gain,
-		this_afe.dtmf_gen_rx_portid);
-
-	cmd_dtmf.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cmd_dtmf.hdr.pkt_size = sizeof(cmd_dtmf);
-	cmd_dtmf.hdr.src_port = 0;
-	cmd_dtmf.hdr.dest_port = 0;
-	cmd_dtmf.hdr.token = 0;
-	cmd_dtmf.hdr.opcode = AFE_PORTS_CMD_DTMF_CTL;
-	cmd_dtmf.duration_in_ms = duration_in_ms;
-	cmd_dtmf.high_freq = high_freq;
-	cmd_dtmf.low_freq = low_freq;
-	cmd_dtmf.gain = gain;
-	cmd_dtmf.num_ports = 1;
-	cmd_dtmf.port_ids = q6audio_get_port_id(this_afe.dtmf_gen_rx_portid);
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &cmd_dtmf);
-	if (ret < 0) {
-		pr_err("%s: AFE DTMF failed for num_ports:%d ids:0x%x\n",
-		       __func__, cmd_dtmf.num_ports, cmd_dtmf.port_ids);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	index = q6audio_get_port_index(this_afe.dtmf_gen_rx_portid);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-		(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-	return 0;
-
-fail_cmd:
-	pr_err("%s: failed %d\n", __func__, ret);
-	return ret;
-}
-
-static int afe_sidetone_iir(u16 tx_port_id)
-{
-	struct afe_loopback_iir_cfg_v2 iir_sidetone;
-	int ret;
-	int index = 0;
-	uint16_t size = 0;
-	int cal_index = AFE_SIDETONE_IIR_CAL;
-	int iir_pregain = 0;
-	int iir_num_biquad_stages = 0;
-	int iir_enable;
-	struct cal_block_data *cal_block;
-	int mid;
-
-	memset(&iir_sidetone, 0, sizeof(iir_sidetone));
-	index = q6audio_get_port_index(tx_port_id);
-	iir_sidetone.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				     APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	iir_sidetone.hdr.pkt_size = sizeof(iir_sidetone);
-	iir_sidetone.hdr.src_port = 0;
-	iir_sidetone.hdr.dest_port = 0;
-	iir_sidetone.hdr.token = index;
-	iir_sidetone.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	iir_sidetone.param.port_id = tx_port_id;
-	iir_sidetone.param.payload_address_lsw = 0x00;
-	iir_sidetone.param.payload_address_msw = 0x00;
-	iir_sidetone.param.mem_map_handle = 0x00;
-
-	if (this_afe.cal_data[cal_index] == NULL) {
-		pr_err("%s: cal data is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	mutex_lock(&this_afe.cal_data[cal_index]->lock);
-	cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block not found\n ", __func__);
-		mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	iir_pregain = ((struct audio_cal_info_sidetone_iir *)
-			cal_block->cal_info)->pregain;
-	iir_enable = ((struct audio_cal_info_sidetone_iir *)
-			cal_block->cal_info)->iir_enable;
-	iir_num_biquad_stages = ((struct audio_cal_info_sidetone_iir *)
-			cal_block->cal_info)->num_biquad_stages;
-	mid = ((struct audio_cal_info_sidetone_iir *)
-			cal_block->cal_info)->mid;
-
-	/*
-	 * calculate the actual size of payload based on no of stages
-	 * enabled in calibration
-	 */
-	size = (MAX_SIDETONE_IIR_DATA_SIZE / MAX_NO_IIR_FILTER_STAGE) *
-		iir_num_biquad_stages;
-	/*
-	 * For an odd number of stages, 2 bytes of padding are
-	 * required at the end of the payload.
-	 */
-	if (iir_num_biquad_stages % 2) {
-		pr_debug("%s: adding 2 to size:%d\n", __func__, size);
-		size = size + 2;
-	}
-	memcpy(&iir_sidetone.st_iir_filter_config_data.iir_config,
-		&((struct audio_cal_info_sidetone_iir *)
-		cal_block->cal_info)->iir_config,
-		sizeof(iir_sidetone.st_iir_filter_config_data.iir_config));
-	mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-
-	/*
-	 * Calculate the payload size for setparams command
-	 */
-	iir_sidetone.param.payload_size = (sizeof(iir_sidetone) -
-				sizeof(struct apr_hdr) -
-				sizeof(struct afe_port_cmd_set_param_v2) -
-				(MAX_SIDETONE_IIR_DATA_SIZE - size));
-
-	pr_debug("%s: payload size :%d\n", __func__,
-		 iir_sidetone.param.payload_size);
-
-	/*
-	 * Set IIR enable params
-	 */
-	iir_sidetone.st_iir_enable_pdata.module_id = mid;
-	iir_sidetone.st_iir_enable_pdata.param_id =
-			AFE_PARAM_ID_ENABLE;
-	iir_sidetone.st_iir_enable_pdata.param_size =
-			sizeof(iir_sidetone.st_iir_mode_enable_data);
-	iir_sidetone.st_iir_mode_enable_data.enable = iir_enable;
-
-	/*
-	 * Set IIR filter config params
-	 */
-	iir_sidetone.st_iir_filter_config_pdata.module_id = mid;
-	iir_sidetone.st_iir_filter_config_pdata.param_id =
-			AFE_PARAM_ID_SIDETONE_IIR_FILTER_CONFIG;
-	iir_sidetone.st_iir_filter_config_pdata.param_size =
-		sizeof(iir_sidetone.st_iir_filter_config_data.num_biquad_stages)
-		+
-		sizeof(iir_sidetone.st_iir_filter_config_data.pregain) + size;
-	iir_sidetone.st_iir_filter_config_pdata.reserved = 0;
-	iir_sidetone.st_iir_filter_config_data.num_biquad_stages =
-			iir_num_biquad_stages;
-	iir_sidetone.st_iir_filter_config_data.pregain = iir_pregain;
-	pr_debug("%s: tx(0x%x)mid(0x%x)iir_en(%d)stg(%d)gain(0x%x)size(%d)\n",
-		  __func__, tx_port_id, mid,
-		  iir_sidetone.st_iir_mode_enable_data.enable,
-		  iir_sidetone.st_iir_filter_config_data.num_biquad_stages,
-		  iir_sidetone.st_iir_filter_config_data.pregain,
-		  iir_sidetone.st_iir_filter_config_pdata.param_size);
-	ret = afe_apr_send_pkt(&iir_sidetone, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE sidetone failed for tx_port(0x%x)\n",
-			 __func__, tx_port_id);
-
-done:
-	return ret;
-
-}
-
-static int afe_sidetone(u16 tx_port_id, u16 rx_port_id, bool enable)
-{
-	struct afe_st_loopback_cfg_v1 cmd_sidetone;
-	int ret;
-	int index;
-	int cal_index = AFE_SIDETONE_CAL;
-	int sidetone_gain;
-	int sidetone_enable;
-	struct cal_block_data *cal_block;
-	int mid = 0;
-
-	memset(&cmd_sidetone, 0, sizeof(cmd_sidetone));
-	if (this_afe.cal_data[cal_index] == NULL) {
-		pr_err("%s: cal data is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	mutex_lock(&this_afe.cal_data[cal_index]->lock);
-	cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block not found\n", __func__);
-		mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-		ret = -EINVAL;
-		goto done;
-	}
-	sidetone_gain = ((struct audio_cal_info_sidetone *)
-			 cal_block->cal_info)->gain;
-	sidetone_enable = ((struct audio_cal_info_sidetone *)
-			 cal_block->cal_info)->enable;
-	mid = ((struct audio_cal_info_sidetone *)
-			 cal_block->cal_info)->mid;
-	mutex_unlock(&this_afe.cal_data[cal_index]->lock);
-
-	index = q6audio_get_port_index(tx_port_id);
-	cmd_sidetone.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cmd_sidetone.hdr.pkt_size = sizeof(cmd_sidetone);
-	cmd_sidetone.hdr.src_port = 0;
-	cmd_sidetone.hdr.dest_port = 0;
-	cmd_sidetone.hdr.token = index;
-	cmd_sidetone.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	cmd_sidetone.param.port_id = tx_port_id;
-	cmd_sidetone.param.payload_size = (sizeof(cmd_sidetone) -
-			sizeof(struct apr_hdr) -
-			sizeof(struct afe_port_cmd_set_param_v2));
-	cmd_sidetone.param.payload_address_lsw = 0x00;
-	cmd_sidetone.param.payload_address_msw = 0x00;
-	cmd_sidetone.param.mem_map_handle = 0x00;
-	cmd_sidetone.gain_pdata.module_id = AFE_MODULE_LOOPBACK;
-	cmd_sidetone.gain_pdata.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
-	/*
-	 * size of actual payload only
-	 */
-	cmd_sidetone.gain_pdata.param_size = sizeof(
-					     struct afe_loopback_sidetone_gain);
-	cmd_sidetone.gain_data.rx_port_id = rx_port_id;
-	cmd_sidetone.gain_data.gain = sidetone_gain;
-
-	cmd_sidetone.cfg_pdata.module_id = AFE_MODULE_LOOPBACK;
-	cmd_sidetone.cfg_pdata.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
-	/*
-	 * size of actual payload only
-	 */
-	cmd_sidetone.cfg_pdata.param_size = sizeof(struct loopback_cfg_data);
-	cmd_sidetone.cfg_data.loopback_cfg_minor_version =
-					AFE_API_VERSION_LOOPBACK_CONFIG;
-	cmd_sidetone.cfg_data.dst_port_id = rx_port_id;
-	cmd_sidetone.cfg_data.routing_mode = LB_MODE_SIDETONE;
-	cmd_sidetone.cfg_data.enable = enable;
-
-	pr_debug("%s rx(0x%x) tx(0x%x) enable(%d) mid(0x%x) gain(%d) sidetone_enable(%d)\n",
-		  __func__, rx_port_id, tx_port_id,
-		  enable, mid, sidetone_gain, sidetone_enable);
-
-	ret = afe_apr_send_pkt(&cmd_sidetone, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE sidetone send failed for tx_port:%d rx_port:%d ret:%d\n",
-			__func__, tx_port_id, rx_port_id, ret);
-done:
-	return ret;
-}
-
-int afe_sidetone_enable(u16 tx_port_id, u16 rx_port_id, bool enable)
-{
-	int ret;
-	int index;
-
-	index = q6audio_get_port_index(rx_port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (q6audio_validate_port(rx_port_id) < 0) {
-		pr_err("%s: Invalid port 0x%x\n",
-				__func__, rx_port_id);
-		ret = -EINVAL;
-		goto done;
-	}
-	index = q6audio_get_port_index(tx_port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (q6audio_validate_port(tx_port_id) < 0) {
-		pr_err("%s: Invalid port 0x%x\n",
-				__func__, tx_port_id);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (enable) {
-		ret = afe_sidetone_iir(tx_port_id);
-		if (ret)
-			goto done;
-	}
-
-	ret = afe_sidetone(tx_port_id, rx_port_id, enable);
-
-done:
-	return ret;
-}
-
-int afe_validate_port(u16 port_id)
-{
-	int ret;
-
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-	case AFE_PORT_ID_SPDIF_RX:
-	case RSVD_2:
-	case RSVD_3:
-	case DIGI_MIC_TX:
-	case VOICE_RECORD_RX:
-	case VOICE_RECORD_TX:
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case SLIMBUS_0_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_RX:
-	case INT_BT_SCO_RX:
-	case INT_BT_SCO_TX:
-	case INT_BT_A2DP_RX:
-	case INT_FM_RX:
-	case INT_FM_TX:
-	case RT_PROXY_PORT_001_RX:
-	case RT_PROXY_PORT_001_TX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-	case AFE_PORT_ID_QUINARY_MI2S_RX:
-	case AFE_PORT_ID_QUINARY_MI2S_TX:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-	case AFE_PORT_ID_INT0_MI2S_RX:
-	case AFE_PORT_ID_INT1_MI2S_RX:
-	case AFE_PORT_ID_INT2_MI2S_RX:
-	case AFE_PORT_ID_INT3_MI2S_RX:
-	case AFE_PORT_ID_INT4_MI2S_RX:
-	case AFE_PORT_ID_INT5_MI2S_RX:
-	case AFE_PORT_ID_INT6_MI2S_RX:
-	case AFE_PORT_ID_INT0_MI2S_TX:
-	case AFE_PORT_ID_INT1_MI2S_TX:
-	case AFE_PORT_ID_INT2_MI2S_TX:
-	case AFE_PORT_ID_INT3_MI2S_TX:
-	case AFE_PORT_ID_INT4_MI2S_TX:
-	case AFE_PORT_ID_INT5_MI2S_TX:
-	case AFE_PORT_ID_INT6_MI2S_TX:
-	{
-		ret = 0;
-		break;
-	}
-
-	default:
-		pr_err("%s: default ret 0x%x\n", __func__, port_id);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-int afe_convert_virtual_to_portid(u16 port_id)
-{
-	int ret;
-
-	/*
-	 * if port_id is virtual, convert to physical..
-	 * if port_id is already physical, return physical
-	 */
-	if (afe_validate_port(port_id) < 0) {
-		if (port_id == RT_PROXY_DAI_001_RX ||
-		    port_id == RT_PROXY_DAI_001_TX ||
-		    port_id == RT_PROXY_DAI_002_RX ||
-		    port_id == RT_PROXY_DAI_002_TX) {
-			ret = VIRTUAL_ID_TO_PORTID(port_id);
-		} else {
-			pr_err("%s: wrong port 0x%x\n",
-				__func__, port_id);
-			ret = -EINVAL;
-		}
-	} else
-		ret = port_id;
-
-	return ret;
-}
-int afe_port_stop_nowait(int port_id)
-{
-	struct afe_port_cmd_device_stop stop;
-	int ret = 0;
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: AFE is already closed\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-
-	stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	stop.hdr.pkt_size = sizeof(stop);
-	stop.hdr.src_port = 0;
-	stop.hdr.dest_port = 0;
-	stop.hdr.token = 0;
-	stop.hdr.opcode = AFE_PORT_CMD_DEVICE_STOP;
-	stop.port_id = port_id;
-	stop.reserved = 0;
-
-	ret = afe_apr_send_pkt(&stop, NULL);
-	if (ret)
-		pr_err("%s: AFE close failed %d\n", __func__, ret);
-
-fail_cmd:
-	return ret;
-
-}
-
-int afe_close(int port_id)
-{
-	struct afe_port_cmd_device_stop stop;
-	enum afe_mad_type mad_type;
-	int ret = 0;
-	int index = 0;
-	uint16_t port_index;
-
-	if (this_afe.apr == NULL) {
-		pr_err("%s: AFE is already closed\n", __func__);
-		if ((port_id == RT_PROXY_DAI_001_RX) ||
-		    (port_id == RT_PROXY_DAI_002_TX))
-			pcm_afe_instance[port_id & 0x1] = 0;
-		if ((port_id == RT_PROXY_DAI_002_RX) ||
-		    (port_id == RT_PROXY_DAI_001_TX))
-			proxy_afe_instance[port_id & 0x1] = 0;
-		afe_close_done[port_id & 0x1] = true;
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	pr_debug("%s: port_id = 0x%x\n", __func__, port_id);
-	if ((port_id == RT_PROXY_DAI_001_RX) ||
-			(port_id == RT_PROXY_DAI_002_TX)) {
-		pr_debug("%s: before decrementing pcm_afe_instance %d\n",
-			__func__, pcm_afe_instance[port_id & 0x1]);
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-		pcm_afe_instance[port_id & 0x1]--;
-		if ((!(pcm_afe_instance[port_id & 0x1] == 0 &&
-			proxy_afe_instance[port_id & 0x1] == 0)) ||
-			afe_close_done[port_id & 0x1] == true)
-			return 0;
-
-		afe_close_done[port_id & 0x1] = true;
-	}
-
-	if ((port_id == RT_PROXY_DAI_002_RX) ||
-		(port_id == RT_PROXY_DAI_001_TX)) {
-		pr_debug("%s: before decrementing proxy_afe_instance %d\n",
-			__func__, proxy_afe_instance[port_id & 0x1]);
-		port_id = VIRTUAL_ID_TO_PORTID(port_id);
-		proxy_afe_instance[port_id & 0x1]--;
-		if ((!(pcm_afe_instance[port_id & 0x1] == 0 &&
-			proxy_afe_instance[port_id & 0x1] == 0)) ||
-			afe_close_done[port_id & 0x1] == true)
-			return 0;
-
-		afe_close_done[port_id & 0x1] = true;
-	}
-
-	port_id = q6audio_convert_virtual_to_portid(port_id);
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_validate_port(port_id);
-	if (ret < 0) {
-		pr_warn("%s: Not a valid port id 0x%x ret %d\n",
-			__func__, port_id, ret);
-		return -EINVAL;
-	}
-
-	mad_type = afe_port_get_mad_type(port_id);
-	pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
-		 mad_type);
-	if (mad_type != MAD_HW_NONE && mad_type != MAD_SW_AUDIO) {
-		pr_debug("%s: Turn off MAD\n", __func__);
-		ret = afe_turn_onoff_hw_mad(mad_type, false);
-		if (ret) {
-			pr_err("%s: afe_turn_onoff_hw_mad failed %d\n",
-			       __func__, ret);
-			return ret;
-		}
-	} else {
-		pr_debug("%s: Not a MAD port\n", __func__);
-	}
-
-	port_index = afe_get_port_index(port_id);
-	if ((port_index >= 0) && (port_index < AFE_MAX_PORTS)) {
-		this_afe.afe_sample_rates[port_index] = 0;
-		this_afe.topology[port_index] = 0;
-		this_afe.dev_acdb_id[port_index] = 0;
-	} else {
-		pr_err("%s: port %d\n", __func__, port_index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if ((port_id == this_afe.aanc_info.aanc_tx_port) &&
-	    (this_afe.aanc_info.aanc_active)) {
-		memset(&this_afe.aanc_info, 0x00, sizeof(this_afe.aanc_info));
-		ret = afe_aanc_mod_enable(this_afe.apr, port_id, 0);
-		if (ret)
-			pr_err("%s: AFE mod disable failed %d\n",
-				__func__, ret);
-	}
-
-	/*
-	 * even if ramp down configuration failed it is not serious enough to
-	 * warrant bailaing out.
-	 */
-	if (afe_spk_ramp_dn_cfg(port_id) < 0)
-		pr_err("%s: ramp down configuration failed\n", __func__);
-
-	stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	stop.hdr.pkt_size = sizeof(stop);
-	stop.hdr.src_port = 0;
-	stop.hdr.dest_port = 0;
-	stop.hdr.token = index;
-	stop.hdr.opcode = AFE_PORT_CMD_DEVICE_STOP;
-	stop.port_id = q6audio_get_port_id(port_id);
-	stop.reserved = 0;
-
-	ret = afe_apr_send_pkt(&stop, &this_afe.wait[index]);
-	if (ret)
-		pr_err("%s: AFE close failed %d\n", __func__, ret);
-
-fail_cmd:
-	return ret;
-}
-
-int afe_set_digital_codec_core_clock(u16 port_id,
-				struct afe_digital_clk_cfg *cfg)
-{
-	struct afe_lpass_digital_clk_config_command clk_cfg;
-	int index = 0;
-	int ret = 0;
-
-	if (!cfg) {
-		pr_err("%s: clock cfg is NULL\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	/*default rx port is taken to enable the codec digital clock*/
-	clk_cfg.param.port_id = q6audio_get_port_id(port_id);
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-						- sizeof(clk_cfg.param);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.clk_cfg = *cfg;
-
-	pr_debug("%s: Minor version =0x%x clk val = %d\n"
-		 "clk root = 0x%x resrv = 0x%x\n",
-		 __func__, cfg->i2s_cfg_minor_version,
-		 cfg->clk_val, cfg->clk_root, cfg->reserved);
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE enable for port 0x%x ret %d\n",
-		       __func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_set_lpass_clock(u16 port_id, struct afe_clk_cfg *cfg)
-{
-	struct afe_lpass_clk_config_command clk_cfg;
-	int index = 0;
-	int ret = 0;
-
-	if (!cfg) {
-		pr_err("%s: clock cfg is NULL\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_is_digital_pcm_interface(port_id);
-	if (ret < 0) {
-		pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
-			__func__, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	clk_cfg.param.port_id = q6audio_get_port_id(port_id);
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-						- sizeof(clk_cfg.param);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_LPAIF_CLK_CONFIG;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.clk_cfg = *cfg;
-
-	pr_debug("%s: Minor version =0x%x clk val1 = %d\n"
-		 "clk val2 = %d, clk src = 0x%x\n"
-		 "clk root = 0x%x clk mode = 0x%x resrv = 0x%x\n"
-		 "port id = 0x%x\n",
-		 __func__, cfg->i2s_cfg_minor_version,
-		 cfg->clk_val1, cfg->clk_val2, cfg->clk_src,
-		 cfg->clk_root, cfg->clk_set_mode,
-		 cfg->reserved, q6audio_get_port_id(port_id));
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE enable for port 0x%x ret %d\n",
-		       __func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	mutex_unlock(&this_afe.afe_cmd_lock);
-	return ret;
-}
-
-/**
- * afe_set_lpass_clk_cfg - Set AFE clk config
- *
- * @index: port index
- * @cfg: pointer to clk set struct
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int afe_set_lpass_clk_cfg(int index, struct afe_clk_set *cfg)
-{
-	struct afe_lpass_clk_config_command_v2 clk_cfg;
-	int ret = 0;
-
-	if (!cfg) {
-		pr_err("%s: clock cfg is NULL\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: index[%d] invalid!\n", __func__, index);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-						- sizeof(clk_cfg.param);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_CLOCK_SET;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_CLOCK_SET;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.clk_cfg = *cfg;
-
-
-	pr_debug("%s: Minor version =0x%x clk id = %d\n"
-		 "clk freq (Hz) = %d, clk attri = 0x%x\n"
-		 "clk root = 0x%x clk enable = 0x%x\n",
-		 __func__, cfg->clk_set_minor_version,
-		 cfg->clk_id, cfg->clk_freq_in_hz, cfg->clk_attri,
-		 cfg->clk_root, cfg->enable);
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE clk cfg failed with ret %d\n",
-		       __func__, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	} else {
-		/* set ret to 0 as no timeout happened */
-		ret = 0;
-	}
-	if (atomic_read(&this_afe.status) != 0) {
-		pr_err("%s: config cmd failed\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	mutex_unlock(&this_afe.afe_cmd_lock);
-	return ret;
-}
-EXPORT_SYMBOL(afe_set_lpass_clk_cfg);
-
-/**
- * afe_set_lpass_clock_v2 - Enable AFE lpass clock
- *
- * @port_id: AFE port id
- * @cfg: pointer to clk set struct
- *
- * Returns 0 on success, appropriate error code otherwise
- */
-int afe_set_lpass_clock_v2(u16 port_id, struct afe_clk_set *cfg)
-{
-	int index = 0;
-	int ret = 0;
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_is_digital_pcm_interface(port_id);
-	if (ret < 0) {
-		pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
-			__func__, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_set_lpass_clk_cfg(index, cfg);
-	if (ret)
-		pr_err("%s: afe_set_lpass_clk_cfg_v2 failed %d\n",
-			__func__, ret);
-
-	return ret;
-}
-EXPORT_SYMBOL(afe_set_lpass_clock_v2);
-
-int afe_set_lpass_internal_digital_codec_clock(u16 port_id,
-			struct afe_digital_clk_cfg *cfg)
-{
-	struct afe_lpass_digital_clk_config_command clk_cfg;
-	int index = 0;
-	int ret = 0;
-
-	if (!cfg) {
-		pr_err("%s: clock cfg is NULL\n", __func__);
-		ret = -EINVAL;
-		return ret;
-	}
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_is_digital_pcm_interface(port_id);
-	if (ret < 0) {
-		pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
-			__func__, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	clk_cfg.param.port_id = q6audio_get_port_id(port_id);
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-						- sizeof(clk_cfg.param);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.clk_cfg = *cfg;
-
-	pr_debug("%s: Minor version =0x%x clk val = %d\n"
-		 "clk root = 0x%x resrv = 0x%x port id = 0x%x\n",
-		 __func__, cfg->i2s_cfg_minor_version,
-		 cfg->clk_val, cfg->clk_root, cfg->reserved,
-		 q6audio_get_port_id(port_id));
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE enable for port 0x0x%x ret %d\n",
-		       __func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	return ret;
-}
-
-int afe_enable_lpass_core_shared_clock(u16 port_id, u32 enable)
-{
-	struct afe_lpass_core_shared_clk_config_command clk_cfg;
-	int index = 0;
-	int ret = 0;
-
-	index = q6audio_get_port_index(port_id);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		return -EINVAL;
-	}
-	ret = q6audio_is_digital_pcm_interface(port_id);
-	if (ret < 0) {
-		pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
-		       __func__, ret);
-		return -EINVAL;
-	}
-
-	ret = afe_q6_interface_prepare();
-	if (ret != 0) {
-		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
-		return ret;
-	}
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
-	clk_cfg.hdr.src_port = 0;
-	clk_cfg.hdr.dest_port = 0;
-	clk_cfg.hdr.token = index;
-
-	clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-	clk_cfg.param.port_id = q6audio_get_port_id(port_id);
-	clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
-						- sizeof(clk_cfg.param);
-	clk_cfg.param.payload_address_lsw = 0x00;
-	clk_cfg.param.payload_address_msw = 0x00;
-	clk_cfg.param.mem_map_handle = 0x00;
-	clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	clk_cfg.pdata.param_id = AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG;
-	clk_cfg.pdata.param_size =  sizeof(clk_cfg.clk_cfg);
-	clk_cfg.clk_cfg.lpass_core_shared_clk_cfg_minor_version =
-				AFE_API_VERSION_LPASS_CORE_SHARED_CLK_CONFIG;
-	clk_cfg.clk_cfg.enable = enable;
-
-	pr_debug("%s: port id = %d, enable = %d\n",
-		 __func__, q6audio_get_port_id(port_id), enable);
-
-	atomic_set(&this_afe.state, 1);
-	atomic_set(&this_afe.status, 0);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
-	if (ret < 0) {
-		pr_err("%s: AFE enable for port 0x%x ret %d\n",
-		       __func__, port_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	mutex_unlock(&this_afe.afe_cmd_lock);
-	return ret;
-}
-
-int q6afe_check_osr_clk_freq(u32 freq)
-{
-	int ret = 0;
-
-	switch (freq) {
-	case Q6AFE_LPASS_OSR_CLK_12_P288_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_8_P192_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_6_P144_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_4_P096_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_3_P072_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_2_P048_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_1_P536_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_1_P024_MHZ:
-	case Q6AFE_LPASS_OSR_CLK_768_kHZ:
-	case Q6AFE_LPASS_OSR_CLK_512_kHZ:
-		break;
-	default:
-		pr_err("%s: deafault freq 0x%x\n",
-			__func__, freq);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-int afe_get_sp_th_vi_ftm_data(struct afe_sp_th_vi_get_param *th_vi)
-{
-	int ret = -EINVAL;
-	int index = 0, port = SLIMBUS_4_TX;
-
-	if (!th_vi) {
-		pr_err("%s: Invalid params\n", __func__);
-		goto done;
-	}
-	if (this_afe.vi_tx_port != -1)
-		port = this_afe.vi_tx_port;
-
-	ret = q6audio_validate_port(port);
-	if (ret < 0) {
-		pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
-		goto done;
-	}
-	index = q6audio_get_port_index(port);
-	if (index < 0) {
-		pr_err("%s: invalid port 0x%x, index %d\n",
-			__func__, port, index);
-		ret = -EINVAL;
-		goto done;
-	}
-	th_vi->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	th_vi->hdr.pkt_size = sizeof(*th_vi);
-	th_vi->hdr.src_port = 0;
-	th_vi->hdr.dest_port = 0;
-	th_vi->hdr.token = index;
-	th_vi->hdr.opcode =  AFE_PORT_CMD_GET_PARAM_V2;
-	th_vi->get_param.mem_map_handle = 0;
-	th_vi->get_param.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
-	th_vi->get_param.param_id = AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS;
-	th_vi->get_param.payload_address_lsw = 0;
-	th_vi->get_param.payload_address_msw = 0;
-	th_vi->get_param.payload_size = sizeof(*th_vi)
-				- sizeof(th_vi->get_param) - sizeof(th_vi->hdr);
-	th_vi->get_param.port_id = q6audio_get_port_id(port);
-	th_vi->pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
-	th_vi->pdata.param_id = AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS;
-	th_vi->pdata.param_size = sizeof(th_vi->param);
-	atomic_set(&this_afe.status, 0);
-	atomic_set(&this_afe.state, 1);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *)th_vi);
-	if (ret < 0) {
-		pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
-			 __func__, port, th_vi->get_param.param_id, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-				 (atomic_read(&this_afe.state) == 0),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(atomic_read(&this_afe.status));
-		goto done;
-	}
-	memcpy(&th_vi->param, &this_afe.th_vi_resp.param,
-		sizeof(this_afe.th_vi_resp.param));
-	pr_debug("%s: DC resistance %d %d temp %d %d status %d %d\n",
-		 __func__, th_vi->param.dc_res_q24[SP_V2_SPKR_1],
-		 th_vi->param.dc_res_q24[SP_V2_SPKR_2],
-		 th_vi->param.temp_q22[SP_V2_SPKR_1],
-		 th_vi->param.temp_q22[SP_V2_SPKR_2],
-		 th_vi->param.status[SP_V2_SPKR_1],
-		 th_vi->param.status[SP_V2_SPKR_2]);
-	ret = 0;
-done:
-	return ret;
-}
-
-int afe_get_sp_ex_vi_ftm_data(struct afe_sp_ex_vi_get_param *ex_vi)
-{
-	int ret = -EINVAL;
-	int index = 0, port = SLIMBUS_4_TX;
-
-	if (!ex_vi) {
-		pr_err("%s: Invalid params\n", __func__);
-		goto done;
-	}
-	if (this_afe.vi_tx_port != -1)
-		port = this_afe.vi_tx_port;
-
-	ret = q6audio_validate_port(port);
-	if (ret < 0) {
-		pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
-		goto done;
-	}
-
-	index = q6audio_get_port_index(port);
-	if (index < 0) {
-		pr_err("%s: invalid index %d port 0x%x\n", __func__,
-			index, port);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ex_vi->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	ex_vi->hdr.pkt_size = sizeof(*ex_vi);
-	ex_vi->hdr.src_port = 0;
-	ex_vi->hdr.dest_port = 0;
-	ex_vi->hdr.token = index;
-	ex_vi->hdr.opcode =  AFE_PORT_CMD_GET_PARAM_V2;
-	ex_vi->get_param.mem_map_handle = 0;
-	ex_vi->get_param.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
-	ex_vi->get_param.param_id = AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS;
-	ex_vi->get_param.payload_address_lsw = 0;
-	ex_vi->get_param.payload_address_msw = 0;
-	ex_vi->get_param.payload_size = sizeof(*ex_vi)
-		- sizeof(ex_vi->get_param) - sizeof(ex_vi->hdr);
-	ex_vi->get_param.port_id = q6audio_get_port_id(port);
-	ex_vi->pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
-	ex_vi->pdata.param_id = AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS;
-	ex_vi->pdata.param_size = sizeof(ex_vi->param);
-	atomic_set(&this_afe.status, 0);
-	atomic_set(&this_afe.state, 1);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *)ex_vi);
-	if (ret < 0) {
-		pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
-			__func__, port, ex_vi->get_param.param_id, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-				 (atomic_read(&this_afe.state) == 0),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(atomic_read(&this_afe.status));
-		goto done;
-	}
-	memcpy(&ex_vi->param, &this_afe.ex_vi_resp.param,
-		sizeof(this_afe.ex_vi_resp.param));
-	pr_debug("%s: freq %d %d resistance %d %d qfactor %d %d state %d %d\n",
-		 __func__, ex_vi->param.freq_q20[SP_V2_SPKR_1],
-		 ex_vi->param.freq_q20[SP_V2_SPKR_2],
-		 ex_vi->param.resis_q24[SP_V2_SPKR_1],
-		 ex_vi->param.resis_q24[SP_V2_SPKR_2],
-		 ex_vi->param.qmct_q24[SP_V2_SPKR_1],
-		 ex_vi->param.qmct_q24[SP_V2_SPKR_2],
-		 ex_vi->param.status[SP_V2_SPKR_1],
-		 ex_vi->param.status[SP_V2_SPKR_2]);
-	ret = 0;
-done:
-	return ret;
-}
-
-int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
-			 u16 port)
-{
-	int ret = -EINVAL;
-	int index = 0;
-	struct afe_av_dev_drift_get_param av_dev_drift;
-
-	if (!timing_stats) {
-		pr_err("%s: Invalid params\n", __func__);
-		goto exit;
-	}
-
-	ret = q6audio_validate_port(port);
-	if (ret < 0) {
-		pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	index = q6audio_get_port_index(port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid AFE port index[%d]\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	memset(&av_dev_drift, 0, sizeof(struct afe_av_dev_drift_get_param));
-
-	av_dev_drift.hdr.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	av_dev_drift.hdr.pkt_size = sizeof(av_dev_drift);
-	av_dev_drift.hdr.src_port = 0;
-	av_dev_drift.hdr.dest_port = 0;
-	av_dev_drift.hdr.token = index;
-	av_dev_drift.hdr.opcode =  AFE_PORT_CMD_GET_PARAM_V2;
-	av_dev_drift.get_param.mem_map_handle = 0;
-	av_dev_drift.get_param.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	av_dev_drift.get_param.param_id = AFE_PARAM_ID_DEV_TIMING_STATS;
-	av_dev_drift.get_param.payload_address_lsw = 0;
-	av_dev_drift.get_param.payload_address_msw = 0;
-	av_dev_drift.get_param.payload_size = sizeof(av_dev_drift)
-		- sizeof(av_dev_drift.get_param) - sizeof(av_dev_drift.hdr);
-	av_dev_drift.get_param.port_id = q6audio_get_port_id(port);
-	av_dev_drift.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
-	av_dev_drift.pdata.param_id = AFE_PARAM_ID_DEV_TIMING_STATS;
-	av_dev_drift.pdata.param_size = sizeof(av_dev_drift.timing_stats);
-	atomic_set(&this_afe.status, 0);
-	atomic_set(&this_afe.state, 1);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *)&av_dev_drift);
-	if (ret < 0) {
-		pr_err("%s: get param port 0x%x param id[0x%x] failed %d\n",
-			__func__, port, av_dev_drift.get_param.param_id, ret);
-		goto exit;
-	}
-
-	ret = wait_event_timeout(this_afe.wait[index],
-			(atomic_read(&this_afe.state) == 0),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-				__func__, adsp_err_get_err_str(
-					atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto exit;
-	}
-
-	memcpy(timing_stats, &this_afe.av_dev_drift_resp.timing_stats,
-	       sizeof(this_afe.av_dev_drift_resp.timing_stats));
-	ret = 0;
-exit:
-	return ret;
-}
-
-int afe_spk_prot_get_calib_data(struct afe_spkr_prot_get_vi_calib *calib_resp)
-{
-	int ret = -EINVAL;
-	int index = 0, port = SLIMBUS_4_TX;
-
-	if (!calib_resp) {
-		pr_err("%s: Invalid params\n", __func__);
-		goto fail_cmd;
-	}
-	if (this_afe.vi_tx_port != -1)
-		port = this_afe.vi_tx_port;
-
-	ret = q6audio_validate_port(port);
-	if (ret < 0) {
-		pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	index = q6audio_get_port_index(port);
-	if (index < 0 || index >= AFE_MAX_PORTS) {
-		pr_err("%s: AFE port index[%d] invalid!\n",
-				__func__, index);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	calib_resp->hdr.hdr_field =
-	APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-	APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	calib_resp->hdr.pkt_size = sizeof(*calib_resp);
-	calib_resp->hdr.src_port = 0;
-	calib_resp->hdr.dest_port = 0;
-	calib_resp->hdr.token = index;
-	calib_resp->hdr.opcode =  AFE_PORT_CMD_GET_PARAM_V2;
-	calib_resp->get_param.mem_map_handle = 0;
-	calib_resp->get_param.module_id = AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2;
-	calib_resp->get_param.param_id = AFE_PARAM_ID_CALIB_RES_CFG_V2;
-	calib_resp->get_param.payload_address_lsw = 0;
-	calib_resp->get_param.payload_address_msw = 0;
-	calib_resp->get_param.payload_size = sizeof(*calib_resp)
-		- sizeof(calib_resp->get_param) - sizeof(calib_resp->hdr);
-	calib_resp->get_param.port_id = q6audio_get_port_id(port);
-	calib_resp->pdata.module_id = AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2;
-	calib_resp->pdata.param_id = AFE_PARAM_ID_CALIB_RES_CFG_V2;
-	calib_resp->pdata.param_size = sizeof(calib_resp->res_cfg);
-	atomic_set(&this_afe.status, 0);
-	atomic_set(&this_afe.state, 1);
-	ret = apr_send_pkt(this_afe.apr, (uint32_t *)calib_resp);
-	if (ret < 0) {
-		pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
-			   __func__, port, calib_resp->get_param.param_id, ret);
-		goto fail_cmd;
-	}
-	ret = wait_event_timeout(this_afe.wait[index],
-		(atomic_read(&this_afe.state) == 0),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (atomic_read(&this_afe.status) > 0) {
-		pr_err("%s: config cmd failed [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&this_afe.status)));
-		ret = adsp_err_get_lnx_err_code(
-				atomic_read(&this_afe.status));
-		goto fail_cmd;
-	}
-	memcpy(&calib_resp->res_cfg, &this_afe.calib_data.res_cfg,
-		sizeof(this_afe.calib_data.res_cfg));
-	pr_info("%s: state %s resistance %d %d\n", __func__,
-			 fbsp_state[calib_resp->res_cfg.th_vi_ca_state],
-			 calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_1],
-			 calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_2]);
-	ret = 0;
-fail_cmd:
-	return ret;
-}
-
-int afe_spk_prot_feed_back_cfg(int src_port, int dst_port,
-	int l_ch, int r_ch, u32 enable)
-{
-	int ret = -EINVAL;
-	union afe_spkr_prot_config prot_config;
-	int index = 0;
-
-	if (!enable) {
-		pr_debug("%s: Disable Feedback tx path", __func__);
-		this_afe.vi_tx_port = -1;
-		this_afe.vi_rx_port = -1;
-		return 0;
-	}
-
-	if ((q6audio_validate_port(src_port) < 0) ||
-		(q6audio_validate_port(dst_port) < 0)) {
-		pr_err("%s: invalid ports src 0x%x dst 0x%x",
-			__func__, src_port, dst_port);
-		goto fail_cmd;
-	}
-	if (!l_ch && !r_ch) {
-		pr_err("%s: error ch values zero\n", __func__);
-		goto fail_cmd;
-	}
-	pr_debug("%s: src_port 0x%x  dst_port 0x%x l_ch %d r_ch %d\n",
-		 __func__, src_port, dst_port, l_ch, r_ch);
-	memset(&prot_config, 0, sizeof(prot_config));
-	prot_config.feedback_path_cfg.dst_portid =
-		q6audio_get_port_id(dst_port);
-	if (l_ch) {
-		prot_config.feedback_path_cfg.chan_info[index++] = 1;
-		prot_config.feedback_path_cfg.chan_info[index++] = 2;
-	}
-	if (r_ch) {
-		prot_config.feedback_path_cfg.chan_info[index++] = 3;
-		prot_config.feedback_path_cfg.chan_info[index++] = 4;
-	}
-	prot_config.feedback_path_cfg.num_channels = index;
-	pr_debug("%s no of channels: %d\n", __func__, index);
-	prot_config.feedback_path_cfg.minor_version = 1;
-	ret = afe_spk_prot_prepare(src_port, dst_port,
-			AFE_PARAM_ID_FEEDBACK_PATH_CFG, &prot_config);
-fail_cmd:
-	return ret;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case AFE_COMMON_RX_CAL_TYPE:
-		ret = AFE_COMMON_RX_CAL;
-		break;
-	case AFE_COMMON_TX_CAL_TYPE:
-		ret = AFE_COMMON_TX_CAL;
-		break;
-	case AFE_AANC_CAL_TYPE:
-		ret = AFE_AANC_CAL;
-		break;
-	case AFE_HW_DELAY_CAL_TYPE:
-		ret = AFE_HW_DELAY_CAL;
-		break;
-	case AFE_FB_SPKR_PROT_CAL_TYPE:
-		ret = AFE_FB_SPKR_PROT_CAL;
-		break;
-	case AFE_SIDETONE_CAL_TYPE:
-		ret = AFE_SIDETONE_CAL;
-		break;
-	case AFE_SIDETONE_IIR_CAL_TYPE:
-		ret = AFE_SIDETONE_IIR_CAL;
-		break;
-	case AFE_TOPOLOGY_CAL_TYPE:
-		ret = AFE_TOPOLOGY_CAL;
-		break;
-	case AFE_CUST_TOPOLOGY_CAL_TYPE:
-		ret = AFE_CUST_TOPOLOGY_CAL;
-		break;
-	default:
-		pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-int afe_alloc_cal(int32_t cal_type, size_t data_size,
-						void *data)
-{
-	int				ret = 0;
-	int				cal_index;
-
-	cal_index = get_cal_type_index(cal_type);
-	pr_debug("%s: cal_type = %d cal_index = %d\n",
-		  __func__, cal_type, cal_index);
-
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		this_afe.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int afe_dealloc_cal(int32_t cal_type, size_t data_size,
-							void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-		this_afe.cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int afe_set_cal(int32_t cal_type, size_t data_size,
-						void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-		this_afe.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_index == AFE_CUST_TOPOLOGY_CAL) {
-		mutex_lock(&this_afe.cal_data[AFE_CUST_TOPOLOGY_CAL]->lock);
-		this_afe.set_custom_topology = 1;
-		pr_debug("%s:[AFE_CUSTOM_TOPOLOGY] ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		mutex_unlock(&this_afe.cal_data[AFE_CUST_TOPOLOGY_CAL]->lock);
-	}
-
-done:
-	return ret;
-}
-
-static struct cal_block_data *afe_find_hw_delay_by_path(
-			struct cal_type_data *cal_type, int path)
-{
-	struct list_head *ptr, *next;
-	struct cal_block_data *cal_block = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-
-		if (((struct audio_cal_info_hw_delay *)cal_block->cal_info)
-			->path == path) {
-			return cal_block;
-		}
-	}
-	return NULL;
-}
-
-static int afe_get_cal_hw_delay(int32_t path,
-				struct audio_cal_hw_delay_entry *entry)
-{
-	int ret = 0;
-	int i;
-	struct cal_block_data		*cal_block = NULL;
-	struct audio_cal_hw_delay_data	*hw_delay_info = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.cal_data[AFE_HW_DELAY_CAL] == NULL) {
-		pr_err("%s: AFE_HW_DELAY_CAL not initialized\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (entry == NULL) {
-		pr_err("%s: entry is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if ((path >= MAX_PATH_TYPE) || (path < 0)) {
-		pr_err("%s: bad path: %d\n",
-		       __func__, path);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&this_afe.cal_data[AFE_HW_DELAY_CAL]->lock);
-	cal_block = afe_find_hw_delay_by_path(
-		this_afe.cal_data[AFE_HW_DELAY_CAL], path);
-	if (cal_block == NULL)
-		goto unlock;
-
-	hw_delay_info = &((struct audio_cal_info_hw_delay *)
-		cal_block->cal_info)->data;
-	if (hw_delay_info->num_entries > MAX_HW_DELAY_ENTRIES) {
-		pr_err("%s: invalid num entries: %d\n",
-		       __func__, hw_delay_info->num_entries);
-		ret = -EINVAL;
-		goto unlock;
-	}
-
-	for (i = 0; i < hw_delay_info->num_entries; i++) {
-		if (hw_delay_info->entry[i].sample_rate ==
-			entry->sample_rate) {
-			entry->delay_usec = hw_delay_info->entry[i].delay_usec;
-			break;
-		}
-	}
-	if (i == hw_delay_info->num_entries) {
-		pr_err("%s: Unable to find delay for sample rate %d\n",
-		       __func__, entry->sample_rate);
-		ret = -EFAULT;
-		goto unlock;
-	}
-	pr_debug("%s: Path = %d samplerate = %u usec = %u status %d\n",
-		 __func__, path, entry->sample_rate, entry->delay_usec, ret);
-unlock:
-	mutex_unlock(&this_afe.cal_data[AFE_HW_DELAY_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_set_cal_sp_th_vi_ftm_cfg(int32_t cal_type, size_t data_size,
-					void *data)
-{
-	int ret = 0;
-	struct audio_cal_type_sp_th_vi_ftm_cfg *cal_data = data;
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL] == NULL ||
-	    cal_data == NULL ||
-	    data_size != sizeof(*cal_data))
-		goto done;
-
-	pr_debug("%s: cal_type = %d\n", __func__, cal_type);
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-	memcpy(&this_afe.th_ftm_cfg, &cal_data->cal_info,
-		sizeof(this_afe.th_ftm_cfg));
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_set_cal_sp_ex_vi_ftm_cfg(int32_t cal_type, size_t data_size,
-					void *data)
-{
-	int ret = 0;
-	struct audio_cal_type_sp_ex_vi_ftm_cfg *cal_data = data;
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL] == NULL ||
-	    cal_data == NULL ||
-	    data_size != sizeof(*cal_data))
-		goto done;
-
-	pr_debug("%s: cal_type = %d\n", __func__, cal_type);
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-	memcpy(&this_afe.ex_ftm_cfg, &cal_data->cal_info,
-		sizeof(this_afe.ex_ftm_cfg));
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_set_cal_fb_spkr_prot(int32_t cal_type, size_t data_size,
-								void *data)
-{
-	int ret = 0;
-	struct audio_cal_type_fb_spk_prot_cfg	*cal_data = data;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_CAL] == NULL)
-		goto done;
-	if (cal_data == NULL)
-		goto done;
-	if (data_size != sizeof(*cal_data))
-		goto done;
-
-	if (cal_data->cal_info.mode == MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS)
-		__pm_wakeup_event(&wl.ws, jiffies_to_msecs(WAKELOCK_TIMEOUT));
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-	memcpy(&this_afe.prot_cfg, &cal_data->cal_info,
-		sizeof(this_afe.prot_cfg));
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_get_cal_sp_th_vi_ftm_param(int32_t cal_type, size_t data_size,
-					  void *data)
-{
-	int i, ret = 0;
-	struct audio_cal_type_sp_th_vi_param *cal_data = data;
-	struct afe_sp_th_vi_get_param th_vi;
-
-	pr_debug("%s: cal_type = %d\n", __func__, cal_type);
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL] == NULL ||
-	    cal_data == NULL ||
-	    data_size != sizeof(*cal_data))
-		goto done;
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-	for (i = 0; i < SP_V2_NUM_MAX_SPKRS; i++) {
-		cal_data->cal_info.status[i] = -EINVAL;
-		cal_data->cal_info.r_dc_q24[i] = -1;
-		cal_data->cal_info.temp_q22[i] = -1;
-	}
-	if (!afe_get_sp_th_vi_ftm_data(&th_vi)) {
-		for (i = 0; i < SP_V2_NUM_MAX_SPKRS; i++) {
-			pr_debug("%s: ftm param status = %d\n",
-				  __func__, th_vi.param.status[i]);
-			if (th_vi.param.status[i] == FBSP_IN_PROGRESS) {
-				cal_data->cal_info.status[i] = -EAGAIN;
-			} else if (th_vi.param.status[i] == FBSP_SUCCESS) {
-				cal_data->cal_info.status[i] = 0;
-				cal_data->cal_info.r_dc_q24[i] =
-					th_vi.param.dc_res_q24[i];
-				cal_data->cal_info.temp_q22[i] =
-					th_vi.param.temp_q22[i];
-			}
-		}
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_TH_VI_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_get_cal_sp_ex_vi_ftm_param(int32_t cal_type, size_t data_size,
-					  void *data)
-{
-	int i, ret = 0;
-	struct audio_cal_type_sp_ex_vi_param *cal_data = data;
-	struct afe_sp_ex_vi_get_param ex_vi;
-
-	pr_debug("%s: cal_type = %d\n", __func__, cal_type);
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL] == NULL ||
-	    cal_data == NULL ||
-	    data_size != sizeof(*cal_data))
-		goto done;
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-	for (i = 0; i < SP_V2_NUM_MAX_SPKRS; i++) {
-		cal_data->cal_info.status[i] = -EINVAL;
-		cal_data->cal_info.freq_q20[i] = -1;
-		cal_data->cal_info.resis_q24[i] = -1;
-		cal_data->cal_info.qmct_q24[i] = -1;
-	}
-	if (!afe_get_sp_ex_vi_ftm_data(&ex_vi)) {
-		for (i = 0; i < SP_V2_NUM_MAX_SPKRS; i++) {
-			pr_debug("%s: ftm param status = %d\n",
-				  __func__, ex_vi.param.status[i]);
-			if (ex_vi.param.status[i] == FBSP_IN_PROGRESS) {
-				cal_data->cal_info.status[i] = -EAGAIN;
-			} else if (ex_vi.param.status[i] == FBSP_SUCCESS) {
-				cal_data->cal_info.status[i] = 0;
-				cal_data->cal_info.freq_q20[i] =
-					ex_vi.param.freq_q20[i];
-				cal_data->cal_info.resis_q24[i] =
-					ex_vi.param.resis_q24[i];
-				cal_data->cal_info.qmct_q24[i] =
-					ex_vi.param.qmct_q24[i];
-			}
-		}
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_EX_VI_CAL]->lock);
-done:
-	return ret;
-}
-
-static int afe_get_cal_fb_spkr_prot(int32_t cal_type, size_t data_size,
-								void *data)
-{
-	int ret = 0;
-	struct audio_cal_type_fb_spk_prot_status *cal_data = data;
-	struct afe_spkr_prot_get_vi_calib calib_resp;
-
-	pr_debug("%s:\n", __func__);
-
-	if (this_afe.cal_data[AFE_FB_SPKR_PROT_CAL] == NULL)
-		goto done;
-	if (cal_data == NULL)
-		goto done;
-	if (data_size != sizeof(*cal_data))
-		goto done;
-
-	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-	if (this_afe.prot_cfg.mode == MSM_SPKR_PROT_CALIBRATED) {
-		cal_data->cal_info.r0[SP_V2_SPKR_1] =
-			this_afe.prot_cfg.r0[SP_V2_SPKR_1];
-		cal_data->cal_info.r0[SP_V2_SPKR_2] =
-			this_afe.prot_cfg.r0[SP_V2_SPKR_2];
-		cal_data->cal_info.status = 0;
-	} else if (this_afe.prot_cfg.mode ==
-			MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS) {
-		/*Call AFE to query the status*/
-		cal_data->cal_info.status = -EINVAL;
-		cal_data->cal_info.r0[SP_V2_SPKR_1] = -1;
-		cal_data->cal_info.r0[SP_V2_SPKR_2] = -1;
-		if (!afe_spk_prot_get_calib_data(&calib_resp)) {
-			if (calib_resp.res_cfg.th_vi_ca_state ==
-							FBSP_IN_PROGRESS)
-				cal_data->cal_info.status = -EAGAIN;
-			else if (calib_resp.res_cfg.th_vi_ca_state ==
-							FBSP_SUCCESS) {
-				cal_data->cal_info.status = 0;
-				cal_data->cal_info.r0[SP_V2_SPKR_1] =
-				calib_resp.res_cfg.r0_cali_q24[SP_V2_SPKR_1];
-				cal_data->cal_info.r0[SP_V2_SPKR_2] =
-				calib_resp.res_cfg.r0_cali_q24[SP_V2_SPKR_2];
-			}
-		}
-		if (!cal_data->cal_info.status) {
-			this_afe.prot_cfg.mode =
-				MSM_SPKR_PROT_CALIBRATED;
-			this_afe.prot_cfg.r0[SP_V2_SPKR_1] =
-				cal_data->cal_info.r0[SP_V2_SPKR_1];
-			this_afe.prot_cfg.r0[SP_V2_SPKR_2] =
-				cal_data->cal_info.r0[SP_V2_SPKR_2];
-		}
-	} else {
-		/*Indicates calibration data is invalid*/
-		cal_data->cal_info.status = -EINVAL;
-		cal_data->cal_info.r0[SP_V2_SPKR_1] = -1;
-		cal_data->cal_info.r0[SP_V2_SPKR_2] = -1;
-	}
-	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
-	__pm_relax(&wl.ws);
-done:
-	return ret;
-}
-
-static int afe_map_cal_data(int32_t cal_type,
-				struct cal_block_data *cal_block)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-
-	mutex_lock(&this_afe.afe_cmd_lock);
-	atomic_set(&this_afe.mem_map_cal_index, cal_index);
-	ret = afe_cmd_memory_map(cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-	atomic_set(&this_afe.mem_map_cal_index, -1);
-	if (ret < 0) {
-		pr_err("%s: mmap did not work! size = %zd ret %d\n",
-			__func__,
-			cal_block->map_data.map_size, ret);
-		pr_debug("%s: mmap did not work! addr = 0x%pK, size = %zd\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-		mutex_unlock(&this_afe.afe_cmd_lock);
-		goto done;
-	}
-	cal_block->map_data.q6map_handle = atomic_read(&this_afe.
-		mem_map_cal_handles[cal_index]);
-	mutex_unlock(&this_afe.afe_cmd_lock);
-done:
-	return ret;
-}
-
-static int afe_unmap_cal_data(int32_t cal_type,
-				struct cal_block_data *cal_block)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block == NULL) {
-		pr_err("%s: Cal block is NULL!\n",
-						__func__);
-		goto done;
-	}
-
-	if (cal_block->map_data.q6map_handle == 0) {
-		pr_err("%s: Map handle is NULL, nothing to unmap\n",
-				__func__);
-		goto done;
-	}
-
-	atomic_set(&this_afe.mem_map_cal_handles[cal_index],
-		cal_block->map_data.q6map_handle);
-	atomic_set(&this_afe.mem_map_cal_index, cal_index);
-	ret = afe_cmd_memory_unmap_nowait(
-		cal_block->map_data.q6map_handle);
-	atomic_set(&this_afe.mem_map_cal_index, -1);
-	if (ret < 0) {
-		pr_err("%s: unmap did not work! cal_type %i ret %d\n",
-			__func__, cal_index, ret);
-	}
-	cal_block->map_data.q6map_handle = 0;
-done:
-	return ret;
-}
-
-static void afe_delete_cal_data(void)
-{
-	pr_debug("%s:\n", __func__);
-
-	cal_utils_destroy_cal_types(MAX_AFE_CAL_TYPES, this_afe.cal_data);
-}
-
-static int afe_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info	cal_type_info[] = {
-		{{AFE_COMMON_RX_CAL_TYPE,
-		{afe_alloc_cal, afe_dealloc_cal, NULL,
-		afe_set_cal, NULL, NULL} },
-		{afe_map_cal_data, afe_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{AFE_COMMON_TX_CAL_TYPE,
-		{afe_alloc_cal, afe_dealloc_cal, NULL,
-		afe_set_cal, NULL, NULL} },
-		{afe_map_cal_data, afe_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{AFE_AANC_CAL_TYPE,
-		{afe_alloc_cal, afe_dealloc_cal, NULL,
-		afe_set_cal, NULL, NULL} },
-		{afe_map_cal_data, afe_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{AFE_FB_SPKR_PROT_CAL_TYPE,
-		{NULL, NULL, NULL, afe_set_cal_fb_spkr_prot,
-		afe_get_cal_fb_spkr_prot, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{AFE_HW_DELAY_CAL_TYPE,
-		{NULL, NULL, NULL,
-		afe_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{AFE_SIDETONE_CAL_TYPE,
-		{NULL, NULL, NULL,
-		afe_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{AFE_SIDETONE_IIR_CAL_TYPE,
-		{NULL, NULL, NULL,
-		afe_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{AFE_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL,
-		afe_set_cal, NULL, NULL} },
-		{NULL, NULL,
-		cal_utils_match_buf_num} },
-
-		{{AFE_CUST_TOPOLOGY_CAL_TYPE,
-		{afe_alloc_cal, afe_dealloc_cal, NULL,
-		afe_set_cal, NULL, NULL} },
-		{afe_map_cal_data, afe_unmap_cal_data,
-		cal_utils_match_buf_num} },
-
-		{{AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE,
-		{NULL, NULL, NULL, afe_set_cal_sp_th_vi_ftm_cfg,
-		afe_get_cal_sp_th_vi_ftm_param, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE,
-		{NULL, NULL, NULL, afe_set_cal_sp_ex_vi_ftm_cfg,
-		afe_get_cal_sp_ex_vi_ftm_param, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-	};
-	pr_debug("%s:\n", __func__);
-
-	ret = cal_utils_create_cal_types(MAX_AFE_CAL_TYPES, this_afe.cal_data,
-		cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type! %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	afe_delete_cal_data();
-	return ret;
-}
-
-int afe_map_rtac_block(struct rtac_cal_block_data *cal_block)
-{
-	int result = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: map size is 0!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	result = afe_cmd_memory_map(cal_block->cal_data.paddr,
-		cal_block->map_data.map_size);
-	if (result < 0) {
-		pr_err("%s: afe_cmd_memory_map failed for addr = 0x%pK, size = %d, err %d\n",
-			__func__, &cal_block->cal_data.paddr,
-			cal_block->map_data.map_size, result);
-		return result;
-	}
-	cal_block->map_data.map_handle = this_afe.mmap_handle;
-
-done:
-	return result;
-}
-
-int afe_unmap_rtac_block(uint32_t *mem_map_handle)
-{
-	int result = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (mem_map_handle == NULL) {
-		pr_err("%s: Map handle is NULL, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	if (*mem_map_handle == 0) {
-		pr_debug("%s: Map handle is 0, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	result = afe_cmd_memory_unmap(*mem_map_handle);
-	if (result) {
-		pr_err("%s: AFE memory unmap failed %d, handle 0x%x\n",
-		     __func__, result, *mem_map_handle);
-		goto done;
-	} else {
-		*mem_map_handle = 0;
-	}
-
-done:
-	return result;
-}
-
-static int __init afe_init(void)
-{
-	int i = 0, ret;
-
-	atomic_set(&this_afe.state, 0);
-	atomic_set(&this_afe.status, 0);
-	atomic_set(&this_afe.mem_map_cal_index, -1);
-	this_afe.apr = NULL;
-	this_afe.dtmf_gen_rx_portid = -1;
-	this_afe.mmap_handle = 0;
-	this_afe.vi_tx_port = -1;
-	this_afe.vi_rx_port = -1;
-	this_afe.prot_cfg.mode = MSM_SPKR_PROT_DISABLED;
-	this_afe.th_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED;
-	this_afe.ex_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED;
-	mutex_init(&this_afe.afe_cmd_lock);
-	for (i = 0; i < AFE_MAX_PORTS; i++) {
-		this_afe.afe_cal_mode[i] = AFE_CAL_MODE_DEFAULT;
-		this_afe.afe_sample_rates[i] = 0;
-		this_afe.dev_acdb_id[i] = 0;
-		init_waitqueue_head(&this_afe.wait[i]);
-	}
-	wakeup_source_init(&wl.ws, "spkr-prot");
-	ret = afe_init_cal_data();
-	if (ret)
-		pr_err("%s: could not init cal data! %d\n", __func__, ret);
-
-	config_debug_fs_init();
-	return 0;
-}
-
-static void __exit afe_exit(void)
-{
-	afe_delete_cal_data();
-
-	config_debug_fs_exit();
-	mutex_destroy(&this_afe.afe_cmd_lock);
-	wakeup_source_trash(&wl.ws);
-}
-
-device_initcall(afe_init);
-__exitcall(afe_exit);
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
deleted file mode 100644
index e7e1618..0000000
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ /dev/null
@@ -1,9396 +0,0 @@
-/*
- * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/fs.h>
-#include <linux/mutex.h>
-#include <linux/wait.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/dma-mapping.h>
-#include <linux/miscdevice.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-
-#include <linux/debugfs.h>
-#include <linux/time.h>
-#include <linux/atomic.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/mm.h>
-
-#include <asm/ioctls.h>
-
-#include <linux/memory.h>
-
-#include <sound/apr_audio-v2.h>
-#include <sound/q6asm-v2.h>
-#include <sound/q6audio-v2.h>
-#include <sound/audio_cal_utils.h>
-#include <sound/adsp_err.h>
-#include <sound/compress_params.h>
-
-#define TRUE        0x01
-#define FALSE       0x00
-#define SESSION_MAX 8
-
-enum {
-	ASM_TOPOLOGY_CAL = 0,
-	ASM_CUSTOM_TOP_CAL,
-	ASM_AUDSTRM_CAL,
-	ASM_RTAC_APR_CAL,
-	ASM_MAX_CAL_TYPES
-};
-
-union asm_token_struct {
-	struct {
-		u8 stream_id;
-		u8 session_id;
-		u8 buf_index;
-		u8 flags;
-	} _token;
-	u32 token;
-} __packed;
-
-
-enum {
-	ASM_DIRECTION_OFFSET,
-	ASM_CMD_NO_WAIT_OFFSET,
-	/*
-	 * Offset is limited to 7 because flags is stored in u8
-	 * field in asm_token_structure defined above. The offset
-	 * starts from 0.
-	 */
-	ASM_MAX_OFFSET = 7,
-};
-
-enum {
-	WAIT_CMD,
-	NO_WAIT_CMD
-};
-
-#define ASM_SET_BIT(n, x)	(n |= 1 << x)
-#define ASM_TEST_BIT(n, x)	((n >> x) & 1)
-
-/* TODO, combine them together */
-static DEFINE_MUTEX(session_lock);
-struct asm_mmap {
-	atomic_t ref_cnt;
-	void *apr;
-};
-
-static struct asm_mmap this_mmap;
-/* session id: 0 reserved */
-static struct audio_client *session[ASM_ACTIVE_STREAMS_ALLOWED + 1];
-
-struct asm_buffer_node {
-	struct list_head list;
-	phys_addr_t buf_phys_addr;
-	uint32_t  mmap_hdl;
-};
-static int32_t q6asm_srvc_callback(struct apr_client_data *data, void *priv);
-static int32_t q6asm_callback(struct apr_client_data *data, void *priv);
-static void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,
-			uint32_t pkt_size, uint32_t cmd_flg);
-static void q6asm_add_hdr_custom_topology(struct audio_client *ac,
-					  struct apr_hdr *hdr,
-					  uint32_t pkt_size);
-static void q6asm_add_hdr_async(struct audio_client *ac, struct apr_hdr *hdr,
-			uint32_t pkt_size, uint32_t cmd_flg);
-static int q6asm_memory_map_regions(struct audio_client *ac, int dir,
-				uint32_t bufsz, uint32_t bufcnt,
-				bool is_contiguous);
-static int q6asm_memory_unmap_regions(struct audio_client *ac, int dir);
-static void q6asm_reset_buf_state(struct audio_client *ac);
-
-static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels,
-				bool use_back_flavor);
-void *q6asm_mmap_apr_reg(void);
-
-static int q6asm_is_valid_session(struct apr_client_data *data, void *priv);
-static int q6asm_get_asm_topology_cal(void);
-static int q6asm_get_asm_app_type_cal(void);
-
-/* for ASM custom topology */
-static struct cal_type_data *cal_data[ASM_MAX_CAL_TYPES];
-static struct audio_buffer common_buf[2];
-static struct audio_client common_client;
-static int set_custom_topology;
-static int topology_map_handle;
-
-struct generic_get_data_ {
-	int valid;
-	int is_inband;
-	int size_in_ints;
-	int ints[];
-};
-static struct generic_get_data_ *generic_get_data;
-
-#ifdef CONFIG_DEBUG_FS
-#define OUT_BUFFER_SIZE 56
-#define IN_BUFFER_SIZE 24
-
-static struct timeval out_cold_tv;
-static struct timeval out_warm_tv;
-static struct timeval out_cont_tv;
-static struct timeval in_cont_tv;
-static long out_enable_flag;
-static long in_enable_flag;
-static struct dentry *out_dentry;
-static struct dentry *in_dentry;
-static int in_cont_index;
-/*This var is used to keep track of first write done for cold output latency */
-static int out_cold_index;
-static char *out_buffer;
-static char *in_buffer;
-
-static uint32_t adsp_reg_event_opcode[] = {
-	ASM_STREAM_CMD_REGISTER_PP_EVENTS,
-	ASM_STREAM_CMD_REGISTER_ENCDEC_EVENTS,
-	ASM_STREAM_CMD_REGISTER_IEC_61937_FMT_UPDATE };
-
-static uint32_t adsp_raise_event_opcode[] = {
-	ASM_STREAM_PP_EVENT,
-	ASM_STREAM_CMD_ENCDEC_EVENTS,
-	ASM_IEC_61937_MEDIA_FMT_EVENT };
-
-static int is_adsp_reg_event(uint32_t cmd)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(adsp_reg_event_opcode); i++) {
-		if (cmd == adsp_reg_event_opcode[i])
-			return i;
-	}
-	return -EINVAL;
-}
-
-static int is_adsp_raise_event(uint32_t cmd)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(adsp_raise_event_opcode); i++) {
-		if (cmd == adsp_raise_event_opcode[i])
-			return i;
-	}
-	return -EINVAL;
-}
-
-static inline void q6asm_set_flag_in_token(union asm_token_struct *asm_token,
-					   int flag, int flag_offset)
-{
-	if (flag)
-		ASM_SET_BIT(asm_token->_token.flags, flag_offset);
-}
-
-static inline int q6asm_get_flag_from_token(union asm_token_struct *asm_token,
-					    int flag_offset)
-{
-	return ASM_TEST_BIT(asm_token->_token.flags, flag_offset);
-}
-
-static inline void q6asm_update_token(u32 *token, u8 session_id, u8 stream_id,
-				      u8 buf_index, u8 dir, u8 nowait_flag)
-{
-	union asm_token_struct asm_token;
-
-	asm_token.token = 0;
-	asm_token._token.session_id = session_id;
-	asm_token._token.stream_id = stream_id;
-	asm_token._token.buf_index = buf_index;
-	q6asm_set_flag_in_token(&asm_token, dir, ASM_DIRECTION_OFFSET);
-	q6asm_set_flag_in_token(&asm_token, nowait_flag,
-				  ASM_CMD_NO_WAIT_OFFSET);
-	*token = asm_token.token;
-}
-
-static inline uint32_t q6asm_get_pcm_format_id(uint32_t media_format_block_ver)
-{
-	uint32_t pcm_format_id;
-
-	switch (media_format_block_ver) {
-	case PCM_MEDIA_FORMAT_V4:
-		pcm_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V4;
-		break;
-	case PCM_MEDIA_FORMAT_V3:
-		pcm_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
-		break;
-	case PCM_MEDIA_FORMAT_V2:
-	default:
-		pcm_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
-		break;
-	}
-	return pcm_format_id;
-}
-
-/*
- * q6asm_get_buf_index_from_token:
- *       Retrieve buffer index from token.
- *
- * @token: token value sent to ASM service on q6.
- * Returns buffer index in the read/write commands.
- */
-uint8_t q6asm_get_buf_index_from_token(uint32_t token)
-{
-	union asm_token_struct asm_token;
-
-	asm_token.token = token;
-	return asm_token._token.buf_index;
-}
-EXPORT_SYMBOL(q6asm_get_buf_index_from_token);
-
-/*
- * q6asm_get_stream_id_from_token:
- *       Retrieve stream id from token.
- *
- * @token: token value sent to ASM service on q6.
- * Returns stream id.
- */
-uint8_t q6asm_get_stream_id_from_token(uint32_t token)
-{
-	union asm_token_struct asm_token;
-
-	asm_token.token = token;
-	return asm_token._token.stream_id;
-}
-EXPORT_SYMBOL(q6asm_get_stream_id_from_token);
-
-static int audio_output_latency_dbgfs_open(struct inode *inode,
-							struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-static ssize_t audio_output_latency_dbgfs_read(struct file *file,
-				char __user *buf, size_t count, loff_t *ppos)
-{
-	if (out_buffer == NULL) {
-		pr_err("%s: out_buffer is null\n", __func__);
-		return 0;
-	}
-	snprintf(out_buffer, OUT_BUFFER_SIZE, "%ld,%ld,%ld,%ld,%ld,%ld,",
-		out_cold_tv.tv_sec, out_cold_tv.tv_usec, out_warm_tv.tv_sec,
-		out_warm_tv.tv_usec, out_cont_tv.tv_sec, out_cont_tv.tv_usec);
-	return  simple_read_from_buffer(buf, OUT_BUFFER_SIZE, ppos,
-						out_buffer, OUT_BUFFER_SIZE);
-}
-static ssize_t audio_output_latency_dbgfs_write(struct file *file,
-			const char __user *buf, size_t count, loff_t *ppos)
-{
-	char *temp;
-
-	if (count > 2*sizeof(char)) {
-		pr_err("%s: err count is more %zd\n", __func__, count);
-		return -EINVAL;
-	}
-	temp  = kmalloc(2*sizeof(char), GFP_KERNEL);
-
-	out_cold_index = 0;
-
-	if (temp) {
-		if (copy_from_user(temp, buf, 2*sizeof(char))) {
-			pr_err("%s: copy from user failed for size %zd\n",
-				__func__, 2*sizeof(char));
-			kfree(temp);
-			return -EFAULT;
-		}
-		if (!kstrtol(temp, 10, &out_enable_flag)) {
-			kfree(temp);
-			return count;
-		}
-		kfree(temp);
-	}
-	return -EINVAL;
-}
-static const struct file_operations audio_output_latency_debug_fops = {
-	.open = audio_output_latency_dbgfs_open,
-	.read = audio_output_latency_dbgfs_read,
-	.write = audio_output_latency_dbgfs_write
-};
-static int audio_input_latency_dbgfs_open(struct inode *inode,
-							struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-static ssize_t audio_input_latency_dbgfs_read(struct file *file,
-				char __user *buf, size_t count, loff_t *ppos)
-{
-	if (in_buffer == NULL) {
-		pr_err("%s: in_buffer is null\n", __func__);
-		return 0;
-	}
-	snprintf(in_buffer, IN_BUFFER_SIZE, "%ld,%ld,",
-				in_cont_tv.tv_sec, in_cont_tv.tv_usec);
-	return  simple_read_from_buffer(buf, IN_BUFFER_SIZE, ppos,
-						in_buffer, IN_BUFFER_SIZE);
-}
-static ssize_t audio_input_latency_dbgfs_write(struct file *file,
-			const char __user *buf, size_t count, loff_t *ppos)
-{
-	char *temp;
-
-	if (count > 2*sizeof(char)) {
-		pr_err("%s: err count is more %zd\n", __func__, count);
-		return -EINVAL;
-	}
-	temp  = kmalloc(2*sizeof(char), GFP_KERNEL);
-
-	if (temp) {
-		if (copy_from_user(temp, buf, 2*sizeof(char))) {
-			pr_err("%s: copy from user failed for size %zd\n",
-				__func__, 2*sizeof(char));
-			kfree(temp);
-			return -EFAULT;
-		}
-		if (!kstrtol(temp, 10, &in_enable_flag)) {
-			kfree(temp);
-			return count;
-		}
-		kfree(temp);
-	}
-	return -EINVAL;
-}
-static const struct file_operations audio_input_latency_debug_fops = {
-	.open = audio_input_latency_dbgfs_open,
-	.read = audio_input_latency_dbgfs_read,
-	.write = audio_input_latency_dbgfs_write
-};
-
-static void config_debug_fs_write_cb(void)
-{
-	if (out_enable_flag) {
-		/* For first Write done log the time and reset
-		 * out_cold_index
-		 */
-		if (out_cold_index != 1) {
-			do_gettimeofday(&out_cold_tv);
-			pr_debug("COLD: apr_send_pkt at %ld sec %ld microsec\n",
-				out_cold_tv.tv_sec,
-				out_cold_tv.tv_usec);
-			out_cold_index = 1;
-		}
-		pr_debug("%s: out_enable_flag %ld\n",
-			__func__, out_enable_flag);
-	}
-}
-static void config_debug_fs_read_cb(void)
-{
-	if (in_enable_flag) {
-		/* when in_cont_index == 7, DSP would be
-		 * writing into the 8th 512 byte buffer and this
-		 * timestamp is tapped here.Once done it then writes
-		 * to 9th 512 byte buffer.These two buffers(8th, 9th)
-		 * reach the test application in 5th iteration and that
-		 * timestamp is tapped at user level. The difference
-		 * of these two timestamps gives us the time between
-		 * the time at which dsp started filling the sample
-		 * required and when it reached the test application.
-		 * Hence continuous input latency
-		 */
-		if (in_cont_index == 7) {
-			do_gettimeofday(&in_cont_tv);
-			pr_info("%s: read buffer at %ld sec %ld microsec\n",
-				__func__,
-				in_cont_tv.tv_sec, in_cont_tv.tv_usec);
-		}
-		in_cont_index++;
-	}
-}
-
-static void config_debug_fs_reset_index(void)
-{
-	in_cont_index = 0;
-}
-
-static void config_debug_fs_run(void)
-{
-	if (out_enable_flag) {
-		do_gettimeofday(&out_cold_tv);
-		pr_debug("%s: COLD apr_send_pkt at %ld sec %ld microsec\n",
-			__func__, out_cold_tv.tv_sec, out_cold_tv.tv_usec);
-	}
-}
-
-static void config_debug_fs_write(struct audio_buffer *ab)
-{
-	if (out_enable_flag) {
-		char zero_pattern[2] = {0x00, 0x00};
-		/* If First two byte is non zero and last two byte
-		 * is zero then it is warm output pattern
-		 */
-		if ((strcmp(((char *)ab->data), zero_pattern)) &&
-		(!strcmp(((char *)ab->data + 2), zero_pattern))) {
-			do_gettimeofday(&out_warm_tv);
-			pr_debug("%s: WARM:apr_send_pkt at %ld sec %ld microsec\n",
-			 __func__,
-			 out_warm_tv.tv_sec,
-			out_warm_tv.tv_usec);
-			pr_debug("%s: Warm Pattern Matched\n", __func__);
-		}
-		/* If First two byte is zero and last two byte is
-		 * non zero then it is cont output pattern
-		 */
-		else if ((!strcmp(((char *)ab->data), zero_pattern))
-		&& (strcmp(((char *)ab->data + 2), zero_pattern))) {
-			do_gettimeofday(&out_cont_tv);
-			pr_debug("%s: CONT:apr_send_pkt at %ld sec %ld microsec\n",
-			__func__,
-			out_cont_tv.tv_sec,
-			out_cont_tv.tv_usec);
-			pr_debug("%s: Cont Pattern Matched\n", __func__);
-		}
-	}
-}
-static void config_debug_fs_init(void)
-{
-	out_buffer = kzalloc(OUT_BUFFER_SIZE, GFP_KERNEL);
-	if (out_buffer == NULL)
-		goto outbuf_fail;
-
-	in_buffer = kzalloc(IN_BUFFER_SIZE, GFP_KERNEL);
-	if (in_buffer == NULL)
-		goto inbuf_fail;
-
-	out_dentry = debugfs_create_file("audio_out_latency_measurement_node",
-				0664,
-				NULL, NULL, &audio_output_latency_debug_fops);
-	if (IS_ERR(out_dentry)) {
-		pr_err("%s: debugfs_create_file failed\n", __func__);
-		goto file_fail;
-	}
-	in_dentry = debugfs_create_file("audio_in_latency_measurement_node",
-				0664,
-				NULL, NULL, &audio_input_latency_debug_fops);
-	if (IS_ERR(in_dentry)) {
-		pr_err("%s: debugfs_create_file failed\n", __func__);
-		goto file_fail;
-	}
-	return;
-file_fail:
-	kfree(in_buffer);
-inbuf_fail:
-	kfree(out_buffer);
-outbuf_fail:
-	in_buffer = NULL;
-	out_buffer = NULL;
-}
-#else
-static void config_debug_fs_write(struct audio_buffer *ab)
-{
-}
-static void config_debug_fs_run(void)
-{
-}
-static void config_debug_fs_reset_index(void)
-{
-}
-static void config_debug_fs_read_cb(void)
-{
-}
-static void config_debug_fs_write_cb(void)
-{
-}
-static void config_debug_fs_init(void)
-{
-}
-#endif
-
-int q6asm_mmap_apr_dereg(void)
-{
-	int c;
-
-	c = atomic_sub_return(1, &this_mmap.ref_cnt);
-	if (c == 0) {
-		apr_deregister(this_mmap.apr);
-		common_client.mmap_apr = NULL;
-		pr_debug("%s: APR De-Register common port\n", __func__);
-	} else if (c < 0) {
-		pr_err("%s: APR Common Port Already Closed %d\n",
-			__func__, c);
-		atomic_set(&this_mmap.ref_cnt, 0);
-	}
-
-	return 0;
-}
-
-static int q6asm_session_alloc(struct audio_client *ac)
-{
-	int n;
-
-	for (n = 1; n <= ASM_ACTIVE_STREAMS_ALLOWED; n++) {
-		if (!session[n]) {
-			session[n] = ac;
-			return n;
-		}
-	}
-	pr_err("%s: session not available\n", __func__);
-	return -ENOMEM;
-}
-
-static bool q6asm_is_valid_audio_client(struct audio_client *ac)
-{
-	int n;
-
-	for (n = 1; n <= ASM_ACTIVE_STREAMS_ALLOWED; n++) {
-		if (session[n] == ac)
-			return 1;
-	}
-	return 0;
-}
-
-static void q6asm_session_free(struct audio_client *ac)
-{
-	pr_debug("%s: sessionid[%d]\n", __func__, ac->session);
-	rtac_remove_popp_from_adm_devices(ac->session);
-	session[ac->session] = 0;
-	ac->session = 0;
-	ac->perf_mode = LEGACY_PCM_MODE;
-	ac->fptr_cache_ops = NULL;
-}
-
-static uint32_t q6asm_get_next_buf(struct audio_client *ac,
-		uint32_t curr_buf, uint32_t max_buf_cnt)
-{
-	dev_vdbg(ac->dev, "%s: curr_buf = %d, max_buf_cnt = %d\n",
-		 __func__, curr_buf, max_buf_cnt);
-	curr_buf += 1;
-	return (curr_buf >= max_buf_cnt) ? 0 : curr_buf;
-}
-
-static int q6asm_map_cal_memory(int32_t cal_type,
-	struct cal_block_data *cal_block)
-{
-	int result = 0;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n",
-			__func__);
-		goto done;
-	}
-
-	common_client.mmap_apr = q6asm_mmap_apr_reg();
-	if (common_client.mmap_apr == NULL) {
-		pr_err("%s: q6asm_mmap_apr_reg failed\n",
-			__func__);
-		result = -EPERM;
-		goto done;
-	}
-	common_client.apr = common_client.mmap_apr;
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: map size is 0!\n",
-			__func__);
-		goto done;
-	}
-
-	/* Use second asm buf to map memory */
-	if (common_client.port[IN].buf == NULL) {
-		pr_err("%s: common buf is NULL\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	common_client.port[IN].buf->phys = cal_block->cal_data.paddr;
-
-	result = q6asm_memory_map_regions(&common_client,
-			IN, cal_block->map_data.map_size, 1, 1);
-	if (result < 0) {
-		pr_err("%s: mmap did not work! size = %zd result %d\n",
-			__func__,
-			cal_block->map_data.map_size, result);
-		pr_debug("%s: mmap did not work! addr = 0x%pK, size = %zd\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-		goto done;
-	}
-
-	list_for_each_safe(ptr, next,
-		&common_client.port[IN].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-					list);
-		if (buf_node->buf_phys_addr == cal_block->cal_data.paddr) {
-			cal_block->map_data.q6map_handle =  buf_node->mmap_hdl;
-			break;
-		}
-	}
-done:
-	return result;
-}
-
-static int remap_cal_data(int32_t cal_type, struct cal_block_data *cal_block)
-{
-	int ret = 0;
-
-	if (cal_block->map_data.ion_client == NULL) {
-		pr_err("%s: No ION allocation for cal type %d!\n",
-			__func__, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((cal_block->map_data.map_size > 0) &&
-		(cal_block->map_data.q6map_handle == 0)) {
-
-		ret = q6asm_map_cal_memory(cal_type, cal_block);
-		if (ret < 0) {
-			pr_err("%s: mmap did not work! size = %zd ret %d\n",
-				__func__, cal_block->map_data.map_size, ret);
-			goto done;
-		}
-	}
-done:
-	return ret;
-}
-
-static int q6asm_unmap_cal_memory(int32_t cal_type,
-	struct cal_block_data *cal_block)
-{
-	int			result = 0;
-	int			result2 = 0;
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.q6map_handle == 0) {
-		pr_debug("%s: No address to unmap!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (common_client.mmap_apr == NULL) {
-		common_client.mmap_apr = q6asm_mmap_apr_reg();
-		if (common_client.mmap_apr == NULL) {
-			pr_err("%s: q6asm_mmap_apr_reg failed\n",
-				__func__);
-			result = -EPERM;
-			goto done;
-		}
-	}
-
-	result2 = q6asm_memory_unmap_regions(&common_client, IN);
-	if (result2 < 0) {
-		pr_err("%s: unmap failed, err %d\n",
-			__func__, result2);
-		result = result2;
-	}
-
-	cal_block->map_data.q6map_handle = 0;
-done:
-	return result;
-}
-
-int q6asm_unmap_cal_data(int cal_type, struct cal_block_data *cal_block)
-{
-	int ret = 0;
-
-	if ((cal_block->map_data.map_size > 0) &&
-		(cal_block->map_data.q6map_handle != 0)) {
-
-		ret = q6asm_unmap_cal_memory(cal_type, cal_block);
-		if (ret < 0) {
-			pr_err("%s: unmap did not work! size = %zd ret %d\n",
-				__func__, cal_block->map_data.map_size, ret);
-			goto done;
-		}
-	}
-done:
-	return ret;
-}
-
-int send_asm_custom_topology(struct audio_client *ac)
-{
-	struct cal_block_data		*cal_block = NULL;
-	struct cmd_set_topologies	asm_top;
-	int result = 0;
-	int result1 = 0;
-
-	if (cal_data[ASM_CUSTOM_TOP_CAL] == NULL)
-		goto done;
-
-	mutex_lock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-	if (!set_custom_topology)
-		goto unlock;
-	set_custom_topology = 0;
-
-	cal_block = cal_utils_get_only_cal_block(cal_data[ASM_CUSTOM_TOP_CAL]);
-	if (cal_block == NULL)
-		goto unlock;
-
-	if (cal_block->cal_data.size == 0) {
-		pr_debug("%s: No cal to send!\n", __func__);
-		goto unlock;
-	}
-
-	pr_debug("%s: Sending cal_index %d\n", __func__, ASM_CUSTOM_TOP_CAL);
-
-	result = remap_cal_data(ASM_CUST_TOPOLOGY_CAL_TYPE, cal_block);
-	if (result) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, ASM_CUSTOM_TOP_CAL);
-		goto unlock;
-	}
-
-	q6asm_add_hdr_custom_topology(ac, &asm_top.hdr, sizeof(asm_top));
-	atomic_set(&ac->mem_state, -1);
-	asm_top.hdr.opcode = ASM_CMD_ADD_TOPOLOGIES;
-	asm_top.payload_addr_lsw = lower_32_bits(cal_block->cal_data.paddr);
-	asm_top.payload_addr_msw = msm_audio_populate_upper_32_bits(
-						cal_block->cal_data.paddr);
-	asm_top.mem_map_handle = cal_block->map_data.q6map_handle;
-	asm_top.payload_size = cal_block->cal_data.size;
-
-	 pr_debug("%s: Sending ASM_CMD_ADD_TOPOLOGIES payload = %pK, size = %d, map handle = 0x%x\n",
-		__func__, &cal_block->cal_data.paddr,
-		asm_top.payload_size, asm_top.mem_map_handle);
-
-	result = apr_send_pkt(ac->apr, (uint32_t *) &asm_top);
-	if (result < 0) {
-		pr_err("%s: Set topologies failed result %d\n",
-			__func__, result);
-		pr_debug("%s: Set topologies failed payload = 0x%pK\n",
-			__func__, &cal_block->cal_data.paddr);
-		goto unmap;
-
-	}
-
-	result = wait_event_timeout(ac->mem_wait,
-			(atomic_read(&ac->mem_state) >= 0), 5*HZ);
-	if (!result) {
-		pr_err("%s: Set topologies failed timeout\n", __func__);
-		pr_debug("%s: Set topologies failed after timedout payload = 0x%pK\n",
-			__func__, &cal_block->cal_data.paddr);
-		result = -ETIMEDOUT;
-		goto unmap;
-	}
-	if (atomic_read(&ac->mem_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->mem_state)));
-		result = adsp_err_get_lnx_err_code(
-			atomic_read(&ac->mem_state));
-		goto unmap;
-	}
-
-unmap:
-	result1 = q6asm_unmap_cal_memory(ASM_CUST_TOPOLOGY_CAL_TYPE,
-		cal_block);
-	if (result1 < 0) {
-		result = result1;
-		pr_debug("%s: unmap cal failed! %d\n", __func__, result);
-	}
-unlock:
-	mutex_unlock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-done:
-	return result;
-}
-
-int q6asm_map_rtac_block(struct rtac_cal_block_data *cal_block)
-{
-	int result = 0;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-
-	pr_debug("%s:\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (common_client.mmap_apr == NULL) {
-		common_client.mmap_apr = q6asm_mmap_apr_reg();
-		if (common_client.mmap_apr == NULL) {
-			pr_err("%s: q6asm_mmap_apr_reg failed\n",
-				__func__);
-			result = -EPERM;
-			goto done;
-		}
-	}
-
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: map size is 0!\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	/* Use second asm buf to map memory */
-	if (common_client.port[OUT].buf == NULL) {
-		pr_err("%s: common buf is NULL\n",
-			__func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	common_client.port[OUT].buf->phys = cal_block->cal_data.paddr;
-
-	result = q6asm_memory_map_regions(&common_client,
-			OUT, cal_block->map_data.map_size, 1, 1);
-	if (result < 0) {
-		pr_err("%s: mmap did not work! size = %d result %d\n",
-			__func__,
-			cal_block->map_data.map_size, result);
-		pr_debug("%s: mmap did not work! addr = 0x%pK, size = %d\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-		goto done;
-	}
-
-	list_for_each_safe(ptr, next,
-		&common_client.port[OUT].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-					list);
-		if (buf_node->buf_phys_addr == cal_block->cal_data.paddr) {
-			cal_block->map_data.map_handle =  buf_node->mmap_hdl;
-			break;
-		}
-	}
-done:
-	return result;
-}
-
-int q6asm_unmap_rtac_block(uint32_t *mem_map_handle)
-{
-	int result = 0;
-	int result2 = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	if (mem_map_handle == NULL) {
-		pr_debug("%s: Map handle is NULL, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	if (*mem_map_handle == 0) {
-		pr_debug("%s: Map handle is 0, nothing to unmap\n",
-			__func__);
-		goto done;
-	}
-
-	if (common_client.mmap_apr == NULL) {
-		common_client.mmap_apr = q6asm_mmap_apr_reg();
-		if (common_client.mmap_apr == NULL) {
-			pr_err("%s: q6asm_mmap_apr_reg failed\n",
-				__func__);
-			result = -EPERM;
-			goto done;
-		}
-	}
-
-
-	result2 = q6asm_memory_unmap_regions(&common_client, OUT);
-	if (result2 < 0) {
-		pr_err("%s: unmap failed, err %d\n",
-			__func__, result2);
-		result = result2;
-	} else {
-		mem_map_handle = 0;
-	}
-
-	result2 = q6asm_mmap_apr_dereg();
-	if (result2 < 0) {
-		pr_err("%s: q6asm_mmap_apr_dereg failed, err %d\n",
-			__func__, result2);
-		result = result2;
-	}
-done:
-	return result;
-}
-
-int q6asm_audio_client_buf_free(unsigned int dir,
-			struct audio_client *ac)
-{
-	struct audio_port_data *port;
-	int cnt = 0;
-	int rc = 0;
-
-	pr_debug("%s: Session id %d\n", __func__, ac->session);
-	mutex_lock(&ac->cmd_lock);
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[dir];
-		if (!port->buf) {
-			pr_err("%s: buf NULL\n", __func__);
-			mutex_unlock(&ac->cmd_lock);
-			return 0;
-		}
-		cnt = port->max_buf_cnt - 1;
-
-		if (cnt >= 0) {
-			rc = q6asm_memory_unmap_regions(ac, dir);
-			if (rc < 0)
-				pr_err("%s: Memory_unmap_regions failed %d\n",
-								__func__, rc);
-		}
-
-		while (cnt >= 0) {
-			if (port->buf[cnt].data) {
-				if (!rc || atomic_read(&ac->reset))
-					msm_audio_ion_free(
-						port->buf[cnt].client,
-						port->buf[cnt].handle);
-
-				port->buf[cnt].client = NULL;
-				port->buf[cnt].handle = NULL;
-				port->buf[cnt].data = NULL;
-				port->buf[cnt].phys = 0;
-				--(port->max_buf_cnt);
-			}
-			--cnt;
-		}
-		kfree(port->buf);
-		port->buf = NULL;
-	}
-	mutex_unlock(&ac->cmd_lock);
-	return 0;
-}
-
-int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
-			struct audio_client *ac)
-{
-	struct audio_port_data *port;
-	int cnt = 0;
-	int rc = 0;
-
-	pr_debug("%s: Session id %d\n", __func__, ac->session);
-	mutex_lock(&ac->cmd_lock);
-	port = &ac->port[dir];
-	if (!port->buf) {
-		mutex_unlock(&ac->cmd_lock);
-		return 0;
-	}
-	cnt = port->max_buf_cnt - 1;
-
-	if (cnt >= 0) {
-		rc = q6asm_memory_unmap(ac, port->buf[0].phys, dir);
-		if (rc < 0)
-			pr_err("%s: Memory_unmap_regions failed %d\n",
-							__func__, rc);
-	}
-
-	if (port->buf[0].data) {
-		pr_debug("%s: data[%pK]phys[%pK][%pK] , client[%pK] handle[%pK]\n",
-			__func__,
-			port->buf[0].data,
-			&port->buf[0].phys,
-			&port->buf[0].phys,
-			port->buf[0].client,
-			port->buf[0].handle);
-		if (!rc || atomic_read(&ac->reset))
-			msm_audio_ion_free(port->buf[0].client,
-					   port->buf[0].handle);
-		port->buf[0].client = NULL;
-		port->buf[0].handle = NULL;
-	}
-
-	while (cnt >= 0) {
-		port->buf[cnt].data = NULL;
-		port->buf[cnt].phys = 0;
-		cnt--;
-	}
-	port->max_buf_cnt = 0;
-	kfree(port->buf);
-	port->buf = NULL;
-	mutex_unlock(&ac->cmd_lock);
-	return 0;
-}
-
-void q6asm_audio_client_free(struct audio_client *ac)
-{
-	int loopcnt;
-	struct audio_port_data *port;
-
-	if (!ac) {
-		pr_err("%s: ac %pK\n", __func__, ac);
-		return;
-	}
-	if (!ac->session) {
-		pr_err("%s: ac session invalid\n", __func__);
-		return;
-	}
-
-	mutex_lock(&session_lock);
-
-	pr_debug("%s: Session id %d\n", __func__, ac->session);
-	if (ac->io_mode & SYNC_IO_MODE) {
-		for (loopcnt = 0; loopcnt <= OUT; loopcnt++) {
-			port = &ac->port[loopcnt];
-			if (!port->buf)
-				continue;
-			pr_debug("%s: loopcnt = %d\n",
-				__func__, loopcnt);
-			q6asm_audio_client_buf_free(loopcnt, ac);
-		}
-	}
-
-	rtac_set_asm_handle(ac->session, NULL);
-	apr_deregister(ac->apr2);
-	apr_deregister(ac->apr);
-	q6asm_mmap_apr_dereg();
-	ac->apr2 = NULL;
-	ac->apr = NULL;
-	ac->mmap_apr = NULL;
-	q6asm_session_free(ac);
-
-	pr_debug("%s: APR De-Register\n", __func__);
-
-/*done:*/
-	kfree(ac);
-	ac = NULL;
-	mutex_unlock(&session_lock);
-}
-
-int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode1)
-{
-	uint32_t mode;
-	int ret = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	ac->io_mode &= 0xFF00;
-	mode = (mode1 & 0xF);
-
-	pr_debug("%s: ac->mode after anding with FF00:0x%x,\n",
-		__func__, ac->io_mode);
-
-	if ((mode == ASYNC_IO_MODE) || (mode == SYNC_IO_MODE)) {
-		ac->io_mode |= mode1;
-		pr_debug("%s: Set Mode to 0x%x\n", __func__, ac->io_mode);
-	} else {
-		pr_err("%s: Not an valid IO Mode:%d\n", __func__, ac->io_mode);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-void *q6asm_mmap_apr_reg(void)
-{
-	if ((atomic_read(&this_mmap.ref_cnt) == 0) ||
-	    (this_mmap.apr == NULL)) {
-		this_mmap.apr = apr_register("ADSP", "ASM",
-					(apr_fn)q6asm_srvc_callback,
-					0x0FFFFFFFF, &this_mmap);
-		if (this_mmap.apr == NULL) {
-			pr_debug("%s: Unable to register APR ASM common port\n",
-			 __func__);
-			goto fail;
-		}
-	}
-	atomic_inc(&this_mmap.ref_cnt);
-
-	return this_mmap.apr;
-fail:
-	return NULL;
-}
-
-int q6asm_send_stream_cmd(struct audio_client *ac,
-			  struct msm_adsp_event_data *data)
-{
-	char *asm_params = NULL;
-	struct apr_hdr hdr;
-	int sz, rc;
-
-	if (!data || !ac) {
-		pr_err("%s: %s is NULL\n", __func__,
-			(!data) ? "data" : "ac");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (data->event_type >= ARRAY_SIZE(adsp_reg_event_opcode)) {
-		pr_err("%s: event %u out of boundary of array size of (%lu)\n",
-		       __func__, data->event_type,
-		       (long)ARRAY_SIZE(adsp_reg_event_opcode));
-		rc = -EINVAL;
-		goto done;
-	}
-
-	sz = sizeof(struct apr_hdr) + data->payload_len;
-	asm_params = kzalloc(sz, GFP_KERNEL);
-	if (!asm_params) {
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	q6asm_add_hdr_async(ac, &hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	hdr.opcode = adsp_reg_event_opcode[data->event_type];
-	memcpy(asm_params, &hdr, sizeof(struct apr_hdr));
-	memcpy(asm_params + sizeof(struct apr_hdr),
-		data->payload, data->payload_len);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
-	if (rc < 0) {
-		pr_err("%s: stream event cmd apr pkt failed\n", __func__);
-		rc = -EINVAL;
-		goto fail_send_param;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state_pp) >= 0), 1 * HZ);
-	if (!rc) {
-		pr_err("%s: timeout for stream event cmd resp\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_send_param;
-	}
-
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] for stream event cmd\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_send_param;
-	}
-
-	rc = 0;
-fail_send_param:
-	kfree(asm_params);
-done:
-	return rc;
-}
-
-struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv)
-{
-	struct audio_client *ac;
-	int n;
-	int lcnt = 0;
-	int rc = 0;
-
-	ac = kzalloc(sizeof(struct audio_client), GFP_KERNEL);
-	if (!ac)
-		return NULL;
-
-	mutex_lock(&session_lock);
-	n = q6asm_session_alloc(ac);
-	if (n <= 0) {
-		pr_err("%s: ASM Session alloc fail n=%d\n", __func__, n);
-		mutex_unlock(&session_lock);
-		goto fail_session;
-	}
-	ac->session = n;
-	ac->cb = cb;
-	ac->path_delay = UINT_MAX;
-	ac->priv = priv;
-	ac->io_mode = SYNC_IO_MODE;
-	ac->perf_mode = LEGACY_PCM_MODE;
-	ac->fptr_cache_ops = NULL;
-	/* DSP expects stream id from 1 */
-	ac->stream_id = 1;
-	ac->apr = apr_register("ADSP", "ASM",
-			(apr_fn)q6asm_callback,
-			((ac->session) << 8 | 0x0001),
-			ac);
-
-	if (ac->apr == NULL) {
-		pr_err("%s: Registration with APR failed\n", __func__);
-		mutex_unlock(&session_lock);
-		goto fail_apr1;
-	}
-	ac->apr2 = apr_register("ADSP", "ASM",
-			(apr_fn)q6asm_callback,
-			((ac->session) << 8 | 0x0002),
-			ac);
-
-	if (ac->apr2 == NULL) {
-		pr_err("%s: Registration with APR-2 failed\n", __func__);
-		mutex_unlock(&session_lock);
-		goto fail_apr2;
-	}
-
-	rtac_set_asm_handle(n, ac->apr);
-
-	pr_debug("%s: Registering the common port with APR\n", __func__);
-	ac->mmap_apr = q6asm_mmap_apr_reg();
-	if (ac->mmap_apr == NULL) {
-		mutex_unlock(&session_lock);
-		goto fail_mmap;
-	}
-
-	init_waitqueue_head(&ac->cmd_wait);
-	init_waitqueue_head(&ac->time_wait);
-	init_waitqueue_head(&ac->mem_wait);
-	atomic_set(&ac->time_flag, 1);
-	atomic_set(&ac->reset, 0);
-	INIT_LIST_HEAD(&ac->port[0].mem_map_handle);
-	INIT_LIST_HEAD(&ac->port[1].mem_map_handle);
-	pr_debug("%s: mem_map_handle list init'ed\n", __func__);
-	mutex_init(&ac->cmd_lock);
-	for (lcnt = 0; lcnt <= OUT; lcnt++) {
-		mutex_init(&ac->port[lcnt].lock);
-		spin_lock_init(&ac->port[lcnt].dsp_lock);
-	}
-	atomic_set(&ac->cmd_state, 0);
-	atomic_set(&ac->cmd_state_pp, 0);
-	atomic_set(&ac->mem_state, 0);
-
-	rc = send_asm_custom_topology(ac);
-	if (rc < 0) {
-		mutex_unlock(&session_lock);
-		goto fail_mmap;
-	}
-
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	mutex_unlock(&session_lock);
-
-	return ac;
-fail_mmap:
-	apr_deregister(ac->apr2);
-fail_apr2:
-	apr_deregister(ac->apr);
-fail_apr1:
-	q6asm_session_free(ac);
-fail_session:
-	kfree(ac);
-	return NULL;
-}
-
-struct audio_client *q6asm_get_audio_client(int session_id)
-{
-	if (session_id == ASM_CONTROL_SESSION)
-		return &common_client;
-
-	if ((session_id <= 0) || (session_id > ASM_ACTIVE_STREAMS_ALLOWED)) {
-		pr_err("%s: invalid session: %d\n", __func__, session_id);
-		goto err;
-	}
-
-	if (!session[session_id]) {
-		pr_err("%s: session not active: %d\n", __func__, session_id);
-		goto err;
-	}
-	return session[session_id];
-err:
-	return NULL;
-}
-
-int q6asm_audio_client_buf_alloc(unsigned int dir,
-			struct audio_client *ac,
-			unsigned int bufsz,
-			uint32_t bufcnt)
-{
-	int cnt = 0;
-	int rc = 0;
-	struct audio_buffer *buf;
-	size_t len;
-
-	if (!(ac) || !(bufsz) || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK bufsz %d dir %d\n", __func__, ac, bufsz,
-			dir);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: session[%d]bufsz[%d]bufcnt[%d]\n", __func__, ac->session,
-		bufsz, bufcnt);
-
-	if (ac->session <= 0 || ac->session > 8) {
-		pr_err("%s: Session ID is invalid, session = %d\n", __func__,
-			ac->session);
-		goto fail;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		if (ac->port[dir].buf) {
-			pr_debug("%s: buffer already allocated\n", __func__);
-			return 0;
-		}
-		mutex_lock(&ac->cmd_lock);
-		if (bufcnt > (U32_MAX/sizeof(struct audio_buffer))) {
-			pr_err("%s: Buffer size overflows", __func__);
-			mutex_unlock(&ac->cmd_lock);
-			goto fail;
-		}
-		buf = kzalloc(((sizeof(struct audio_buffer))*bufcnt),
-				GFP_KERNEL);
-
-		if (!buf) {
-			mutex_unlock(&ac->cmd_lock);
-			goto fail;
-		}
-
-		ac->port[dir].buf = buf;
-
-		while (cnt < bufcnt) {
-			if (bufsz > 0) {
-				if (!buf[cnt].data) {
-					rc = msm_audio_ion_alloc("asm_client",
-					&buf[cnt].client, &buf[cnt].handle,
-					      bufsz,
-					      (ion_phys_addr_t *)&buf[cnt].phys,
-					      &len,
-					      &buf[cnt].data);
-					if (rc) {
-						pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
-							__func__, rc);
-						mutex_unlock(&ac->cmd_lock);
-					goto fail;
-					}
-
-					buf[cnt].used = 1;
-					buf[cnt].size = bufsz;
-					buf[cnt].actual_size = bufsz;
-					pr_debug("%s: data[%pK]phys[%pK][%pK]\n",
-						__func__,
-					   buf[cnt].data,
-					   &buf[cnt].phys,
-					   &buf[cnt].phys);
-					cnt++;
-				}
-			}
-		}
-		ac->port[dir].max_buf_cnt = cnt;
-
-		mutex_unlock(&ac->cmd_lock);
-		rc = q6asm_memory_map_regions(ac, dir, bufsz, cnt, 0);
-		if (rc < 0) {
-			pr_err("%s: CMD Memory_map_regions failed %d for size %d\n",
-				__func__, rc, bufsz);
-			goto fail;
-		}
-	}
-	return 0;
-fail:
-	q6asm_audio_client_buf_free(dir, ac);
-	return -EINVAL;
-}
-
-int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir,
-			struct audio_client *ac,
-			unsigned int bufsz,
-			unsigned int bufcnt)
-{
-	int cnt = 0;
-	int rc = 0;
-	struct audio_buffer *buf;
-	size_t len;
-	int bytes_to_alloc;
-
-	if (!(ac) || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: session[%d]bufsz[%d]bufcnt[%d]\n",
-			__func__, ac->session,
-			bufsz, bufcnt);
-
-	if (ac->session <= 0 || ac->session > 8) {
-		pr_err("%s: Session ID is invalid, session = %d\n", __func__,
-			ac->session);
-		goto fail;
-	}
-
-	if (ac->port[dir].buf) {
-		pr_err("%s: buffer already allocated\n", __func__);
-		return 0;
-	}
-	mutex_lock(&ac->cmd_lock);
-	buf = kzalloc(((sizeof(struct audio_buffer))*bufcnt),
-			GFP_KERNEL);
-
-	if (!buf) {
-		pr_err("%s: buffer allocation failed\n", __func__);
-		mutex_unlock(&ac->cmd_lock);
-		goto fail;
-	}
-
-	ac->port[dir].buf = buf;
-
-	/* check for integer overflow */
-	if ((bufcnt > 0) && ((INT_MAX / bufcnt) < bufsz)) {
-		pr_err("%s: integer overflow\n", __func__);
-		mutex_unlock(&ac->cmd_lock);
-		goto fail;
-	}
-	bytes_to_alloc = bufsz * bufcnt;
-
-	/* The size to allocate should be multiple of 4K bytes */
-	bytes_to_alloc = PAGE_ALIGN(bytes_to_alloc);
-
-	rc = msm_audio_ion_alloc("asm_client", &buf[0].client, &buf[0].handle,
-		bytes_to_alloc,
-		(ion_phys_addr_t *)&buf[0].phys, &len,
-		&buf[0].data);
-	if (rc) {
-		pr_err("%s: Audio ION alloc is failed, rc = %d\n",
-			__func__, rc);
-		mutex_unlock(&ac->cmd_lock);
-		goto fail;
-	}
-
-	buf[0].used = dir ^ 1;
-	buf[0].size = bufsz;
-	buf[0].actual_size = bufsz;
-	cnt = 1;
-	while (cnt < bufcnt) {
-		if (bufsz > 0) {
-			buf[cnt].data =  buf[0].data + (cnt * bufsz);
-			buf[cnt].phys =  buf[0].phys + (cnt * bufsz);
-			if (!buf[cnt].data) {
-				pr_err("%s: Buf alloc failed\n",
-							__func__);
-				mutex_unlock(&ac->cmd_lock);
-				goto fail;
-			}
-			buf[cnt].used = dir ^ 1;
-			buf[cnt].size = bufsz;
-			buf[cnt].actual_size = bufsz;
-			pr_debug("%s: data[%pK]phys[%pK][%pK]\n",
-				__func__,
-				buf[cnt].data,
-				&buf[cnt].phys,
-				&buf[cnt].phys);
-		}
-		cnt++;
-	}
-	ac->port[dir].max_buf_cnt = cnt;
-	mutex_unlock(&ac->cmd_lock);
-	rc = q6asm_memory_map_regions(ac, dir, bufsz, cnt, 1);
-	if (rc < 0) {
-		pr_err("%s: CMD Memory_map_regions failed %d for size %d\n",
-			__func__, rc, bufsz);
-		goto fail;
-	}
-	return 0;
-fail:
-	q6asm_audio_client_buf_free_contiguous(dir, ac);
-	return -EINVAL;
-}
-
-static int32_t q6asm_srvc_callback(struct apr_client_data *data, void *priv)
-{
-	uint32_t dir = 0;
-	uint32_t i = IN;
-	uint32_t *payload;
-	unsigned long dsp_flags;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	union asm_token_struct asm_token;
-
-	struct audio_client *ac = NULL;
-	struct audio_port_data *port;
-
-	if (!data) {
-		pr_err("%s: Invalid CB\n", __func__);
-		return 0;
-	}
-
-	payload = data->payload;
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: Reset event is received: %d %d apr[%pK]\n",
-				__func__,
-				data->reset_event,
-				data->reset_proc,
-				this_mmap.apr);
-		atomic_set(&this_mmap.ref_cnt, 0);
-		apr_reset(this_mmap.apr);
-		this_mmap.apr = NULL;
-		for (; i <= OUT; i++) {
-			list_for_each_safe(ptr, next,
-				&common_client.port[i].mem_map_handle) {
-				buf_node = list_entry(ptr,
-						struct asm_buffer_node,
-						list);
-				if (buf_node->buf_phys_addr ==
-				common_client.port[i].buf->phys) {
-					list_del(&buf_node->list);
-					kfree(buf_node);
-				}
-			}
-			pr_debug("%s: Clearing custom topology\n", __func__);
-		}
-
-		cal_utils_clear_cal_block_q6maps(ASM_MAX_CAL_TYPES, cal_data);
-		common_client.mmap_apr = NULL;
-		mutex_lock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-		set_custom_topology = 1;
-		mutex_unlock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-		topology_map_handle = 0;
-		rtac_clear_mapping(ASM_RTAC_CAL);
-		return 0;
-	}
-	asm_token.token = data->token;
-	ac = q6asm_get_audio_client(asm_token._token.session_id);
-	dir = q6asm_get_flag_from_token(&asm_token, ASM_DIRECTION_OFFSET);
-
-	if (!ac) {
-		pr_debug("%s: session[%d] already freed\n",
-			 __func__, asm_token._token.session_id);
-		return 0;
-	}
-
-	if (data->payload_size > sizeof(int)) {
-		pr_debug("%s:ptr0[0x%x]ptr1[0x%x]opcode[0x%x] token[0x%x]payload_s[%d] src[%d] dest[%d]sid[%d]dir[%d]\n",
-			__func__, payload[0], payload[1], data->opcode,
-			data->token, data->payload_size, data->src_port,
-			data->dest_port, asm_token._token.session_id, dir);
-		pr_debug("%s:Payload = [0x%x] status[0x%x]\n",
-			__func__, payload[0], payload[1]);
-	} else if (data->payload_size == sizeof(int)) {
-		pr_debug("%s:ptr0[0x%x]opcode[0x%x] token[0x%x]payload_s[%d] src[%d] dest[%d]sid[%d]dir[%d]\n",
-			__func__, payload[0], data->opcode,
-			data->token, data->payload_size, data->src_port,
-			data->dest_port, asm_token._token.session_id, dir);
-		pr_debug("%s:Payload = [0x%x]\n",
-			__func__, payload[0]);
-	}
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		switch (payload[0]) {
-		case ASM_CMD_SHARED_MEM_MAP_REGIONS:
-		case ASM_CMD_SHARED_MEM_UNMAP_REGIONS:
-		case ASM_CMD_ADD_TOPOLOGIES:
-			if (payload[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x sid:%d\n",
-				       __func__, payload[0], payload[1],
-				       asm_token._token.session_id);
-				if (payload[0] ==
-				    ASM_CMD_SHARED_MEM_UNMAP_REGIONS)
-					atomic_set(&ac->unmap_cb_success, 0);
-
-				atomic_set(&ac->mem_state, payload[1]);
-				wake_up(&ac->mem_wait);
-			} else {
-				if (payload[0] ==
-				    ASM_CMD_SHARED_MEM_UNMAP_REGIONS)
-					atomic_set(&ac->unmap_cb_success, 1);
-			}
-
-			if (atomic_cmpxchg(&ac->mem_state, -1, 0) == -1)
-				wake_up(&ac->mem_wait);
-			dev_vdbg(ac->dev, "%s: Payload = [0x%x] status[0x%x]\n",
-					__func__, payload[0], payload[1]);
-			break;
-		default:
-			pr_debug("%s: command[0x%x] not expecting rsp\n",
-						__func__, payload[0]);
-			break;
-		}
-		return 0;
-	}
-
-	port = &ac->port[dir];
-
-	switch (data->opcode) {
-	case ASM_CMDRSP_SHARED_MEM_MAP_REGIONS:{
-		pr_debug("%s:PL#0[0x%x] dir=0x%x s_id=0x%x\n",
-		       __func__, payload[0], dir, asm_token._token.session_id);
-		spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-		if (atomic_cmpxchg(&ac->mem_state, -1, 0) == -1) {
-			ac->port[dir].tmp_hdl = payload[0];
-			wake_up(&ac->mem_wait);
-		}
-		spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-		break;
-	}
-	case ASM_CMD_SHARED_MEM_UNMAP_REGIONS:{
-		pr_debug("%s: PL#0[0x%x]PL#1 [0x%x]\n",
-					__func__, payload[0], payload[1]);
-		spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-		if (atomic_cmpxchg(&ac->mem_state, -1, 0) == -1)
-			wake_up(&ac->mem_wait);
-		spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-
-		break;
-	}
-	default:
-		pr_debug("%s: command[0x%x]success [0x%x]\n",
-					__func__, payload[0], payload[1]);
-	}
-	if (ac->cb)
-		ac->cb(data->opcode, data->token,
-			data->payload, ac->priv);
-	return 0;
-}
-
-static void q6asm_process_mtmx_get_param_rsp(struct audio_client *ac,
-				struct asm_mtmx_strtr_get_params_cmdrsp *cmdrsp)
-{
-	struct asm_session_mtmx_strtr_param_session_time_v3_t *time;
-
-	if (cmdrsp->err_code) {
-		dev_err_ratelimited(ac->dev,
-				    "%s: err=%x, mod_id=%x, param_id=%x\n",
-				    __func__, cmdrsp->err_code,
-				    cmdrsp->param_info.module_id,
-				    cmdrsp->param_info.param_id);
-		return;
-	}
-	dev_dbg_ratelimited(ac->dev,
-			    "%s: mod_id=%x, param_id=%x\n", __func__,
-			    cmdrsp->param_info.module_id,
-			    cmdrsp->param_info.param_id);
-
-	switch (cmdrsp->param_info.module_id) {
-	case ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC:
-		switch (cmdrsp->param_info.param_id) {
-		case ASM_SESSION_MTMX_STRTR_PARAM_SESSION_TIME_V3:
-			time = &cmdrsp->param_data.session_time;
-			dev_vdbg(ac->dev, "%s: GET_TIME_V3, time_lsw=%x, time_msw=%x\n",
-				 __func__, time->session_time_lsw,
-				 time->session_time_msw);
-			ac->time_stamp = (uint64_t)(((uint64_t)
-					 time->session_time_msw << 32) |
-					 time->session_time_lsw);
-			if (time->flags &
-			    ASM_SESSION_MTMX_STRTR_PARAM_STIME_TSTMP_FLG_BMASK)
-				dev_warn_ratelimited(ac->dev,
-						     "%s: recv inval tstmp\n",
-						     __func__);
-			if (atomic_cmpxchg(&ac->time_flag, 1, 0))
-				wake_up(&ac->time_wait);
-
-			break;
-		default:
-			dev_err(ac->dev, "%s: unexpected param_id %x\n",
-				__func__, cmdrsp->param_info.param_id);
-			break;
-		}
-		break;
-	default:
-		dev_err(ac->dev, "%s: unexpected mod_id %x\n",  __func__,
-			cmdrsp->param_info.module_id);
-		break;
-	}
-}
-
-static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
-{
-	int i = 0;
-	struct audio_client *ac = (struct audio_client *)priv;
-	unsigned long dsp_flags;
-	uint32_t *payload;
-	uint32_t wakeup_flag = 1;
-	int32_t  ret = 0;
-	union asm_token_struct asm_token;
-	uint8_t buf_index;
-	struct msm_adsp_event_data *pp_event_package = NULL;
-	uint32_t payload_size = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: ac NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (data == NULL) {
-		pr_err("%s: data NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (!q6asm_is_valid_audio_client(ac)) {
-		pr_err("%s: audio client pointer is invalid, ac = %pK\n",
-				__func__, ac);
-		return -EINVAL;
-	}
-
-	if (ac->session <= 0 || ac->session > 8) {
-		pr_err("%s: Session ID is invalid, session = %d\n", __func__,
-			ac->session);
-		return -EINVAL;
-	}
-
-	payload = data->payload;
-	asm_token.token = data->token;
-	if (q6asm_get_flag_from_token(&asm_token, ASM_CMD_NO_WAIT_OFFSET)) {
-		pr_debug("%s: No wait command opcode[0x%x] cmd_opcode:%x\n",
-			 __func__, data->opcode, payload ? payload[0] : 0);
-		wakeup_flag = 0;
-	}
-
-	if (data->opcode == RESET_EVENTS) {
-		mutex_lock(&ac->cmd_lock);
-		atomic_set(&ac->reset, 1);
-		if (ac->apr == NULL) {
-			ac->apr = ac->apr2;
-			ac->apr2 = NULL;
-		}
-		pr_debug("%s: Reset event is received: %d %d apr[%pK]\n",
-			__func__,
-			data->reset_event, data->reset_proc, ac->apr);
-		if (ac->cb)
-			ac->cb(data->opcode, data->token,
-				(uint32_t *)data->payload, ac->priv);
-		apr_reset(ac->apr);
-		ac->apr = NULL;
-		atomic_set(&ac->time_flag, 0);
-		atomic_set(&ac->cmd_state, 0);
-		atomic_set(&ac->mem_state, 0);
-		atomic_set(&ac->cmd_state_pp, 0);
-		wake_up(&ac->time_wait);
-		wake_up(&ac->cmd_wait);
-		wake_up(&ac->mem_wait);
-		mutex_unlock(&ac->cmd_lock);
-		return 0;
-	}
-
-	dev_vdbg(ac->dev, "%s: session[%d]opcode[0x%x] token[0x%x]payload_size[%d] src[%d] dest[%d]\n",
-		 __func__,
-		ac->session, data->opcode,
-		data->token, data->payload_size, data->src_port,
-		data->dest_port);
-	if ((data->opcode != ASM_DATA_EVENT_RENDERED_EOS) &&
-	    (data->opcode != ASM_DATA_EVENT_EOS) &&
-	    (data->opcode != ASM_SESSION_EVENT_RX_UNDERFLOW)) {
-		if (payload == NULL) {
-			pr_err("%s: payload is null\n", __func__);
-			return -EINVAL;
-		}
-		dev_vdbg(ac->dev, "%s: Payload = [0x%x] status[0x%x] opcode 0x%x\n",
-			__func__, payload[0], payload[1], data->opcode);
-	}
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		switch (payload[0]) {
-		case ASM_STREAM_CMD_SET_PP_PARAMS_V2:
-			if (rtac_make_asm_callback(ac->session, payload,
-					data->payload_size))
-				break;
-		case ASM_SESSION_CMD_PAUSE:
-		case ASM_SESSION_CMD_SUSPEND:
-		case ASM_DATA_CMD_EOS:
-		case ASM_STREAM_CMD_CLOSE:
-		case ASM_STREAM_CMD_FLUSH:
-		case ASM_SESSION_CMD_RUN_V2:
-		case ASM_SESSION_CMD_REGISTER_FORX_OVERFLOW_EVENTS:
-		case ASM_STREAM_CMD_FLUSH_READBUFS:
-		pr_debug("%s: session %d opcode 0x%x token 0x%x Payload = [0x%x] src %d dest %d\n",
-			__func__, ac->session, data->opcode, data->token,
-			payload[0], data->src_port, data->dest_port);
-		ret = q6asm_is_valid_session(data, priv);
-		if (ret != 0) {
-			pr_err("%s: session invalid %d\n", __func__, ret);
-			return ret;
-		}
-		case ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2:
-		case ASM_STREAM_CMD_OPEN_READ_V3:
-		case ASM_STREAM_CMD_OPEN_WRITE_V3:
-		case ASM_STREAM_CMD_OPEN_PULL_MODE_WRITE:
-		case ASM_STREAM_CMD_OPEN_PUSH_MODE_READ:
-		case ASM_STREAM_CMD_OPEN_READWRITE_V2:
-		case ASM_STREAM_CMD_OPEN_LOOPBACK_V2:
-		case ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK:
-		case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
-		case ASM_DATA_CMD_IEC_60958_MEDIA_FMT:
-		case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
-		case ASM_STREAM_CMD_SET_ENCDEC_PARAM_V2:
-		case ASM_STREAM_CMD_REGISTER_ENCDEC_EVENTS:
-		case ASM_STREAM_CMD_REGISTER_IEC_61937_FMT_UPDATE:
-		case ASM_DATA_CMD_REMOVE_INITIAL_SILENCE:
-		case ASM_DATA_CMD_REMOVE_TRAILING_SILENCE:
-		case ASM_SESSION_CMD_REGISTER_FOR_RX_UNDERFLOW_EVENTS:
-		case ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED:
-			pr_debug("%s: session %d opcode 0x%x token 0x%x Payload = [0x%x] stat 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				payload[0], payload[1],
-				data->src_port, data->dest_port);
-			if (payload[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					__func__, payload[0], payload[1]);
-				if (wakeup_flag) {
-					if ((is_adsp_reg_event(payload[0]) >= 0)
-					      || (payload[0] ==
-					      ASM_STREAM_CMD_SET_PP_PARAMS_V2))
-						atomic_set(&ac->cmd_state_pp,
-								payload[1]);
-					else
-						atomic_set(&ac->cmd_state,
-								payload[1]);
-					wake_up(&ac->cmd_wait);
-				}
-				return 0;
-			}
-			if ((is_adsp_reg_event(payload[0]) >= 0) ||
-			    (payload[0] == ASM_STREAM_CMD_SET_PP_PARAMS_V2)) {
-				if (atomic_read(&ac->cmd_state_pp) &&
-					wakeup_flag) {
-					atomic_set(&ac->cmd_state_pp, 0);
-					wake_up(&ac->cmd_wait);
-				}
-			} else {
-				if (atomic_read(&ac->cmd_state) &&
-					wakeup_flag) {
-					atomic_set(&ac->cmd_state, 0);
-					wake_up(&ac->cmd_wait);
-				}
-			}
-			if (ac->cb)
-				ac->cb(data->opcode, data->token,
-					(uint32_t *)data->payload, ac->priv);
-			break;
-		case ASM_CMD_ADD_TOPOLOGIES:
-			pr_debug("%s:Payload = [0x%x]stat[0x%x]\n",
-				 __func__, payload[0], payload[1]);
-			if (payload[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					 __func__, payload[0], payload[1]);
-				if (wakeup_flag) {
-					atomic_set(&ac->mem_state, payload[1]);
-					wake_up(&ac->mem_wait);
-				}
-				return 0;
-			}
-			if (atomic_read(&ac->mem_state) && wakeup_flag) {
-				atomic_set(&ac->mem_state, 0);
-				wake_up(&ac->mem_wait);
-			}
-			if (ac->cb)
-				ac->cb(data->opcode, data->token,
-					(uint32_t *)data->payload, ac->priv);
-			break;
-		case ASM_DATA_EVENT_WATERMARK: {
-			pr_debug("%s: Watermark opcode[0x%x] status[0x%x]",
-				 __func__, payload[0], payload[1]);
-			break;
-		}
-		case ASM_STREAM_CMD_GET_PP_PARAMS_V2:
-			pr_debug("%s: ASM_STREAM_CMD_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-			/* Should only come here if there is an APR */
-			/* error or malformed APR packet. Otherwise */
-			/* response will be returned as */
-			/* ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 */
-			if (payload[1] != 0) {
-				pr_err("%s: ASM get param error = %d, resuming\n",
-					__func__, payload[1]);
-				rtac_make_asm_callback(ac->session, payload,
-							data->payload_size);
-			}
-			break;
-		case ASM_STREAM_CMD_REGISTER_PP_EVENTS:
-			pr_debug("%s: ASM_STREAM_CMD_REGISTER_PP_EVENTS session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-			if (payload[1] != 0)
-				pr_err("%s: ASM get param error = %d, resuming\n",
-					__func__, payload[1]);
-			atomic_set(&ac->cmd_state_pp, payload[1]);
-			wake_up(&ac->cmd_wait);
-			break;
-		default:
-			pr_debug("%s: command[0x%x] not expecting rsp\n",
-							__func__, payload[0]);
-			break;
-		}
-		return 0;
-	}
-
-	switch (data->opcode) {
-	case ASM_DATA_EVENT_WRITE_DONE_V2:{
-		struct audio_port_data *port = &ac->port[IN];
-
-		dev_vdbg(ac->dev, "%s: Rxed opcode[0x%x] status[0x%x] token[%d]",
-				__func__, payload[0], payload[1],
-				data->token);
-		if (ac->io_mode & SYNC_IO_MODE) {
-			if (port->buf == NULL) {
-				pr_err("%s: Unexpected Write Done\n",
-								__func__);
-				return -EINVAL;
-			}
-			spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-			buf_index = asm_token._token.buf_index;
-			if (lower_32_bits(port->buf[buf_index].phys) !=
-			payload[0] ||
-			msm_audio_populate_upper_32_bits(
-				port->buf[buf_index].phys) !=	payload[1]) {
-				pr_debug("%s: Expected addr %pK\n",
-				__func__, &port->buf[buf_index].phys);
-				pr_err("%s: rxedl[0x%x] rxedu [0x%x]\n",
-					__func__, payload[0], payload[1]);
-				spin_unlock_irqrestore(&port->dsp_lock,
-								dsp_flags);
-				return -EINVAL;
-			}
-			port->buf[buf_index].used = 1;
-			spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-
-			config_debug_fs_write_cb();
-
-			for (i = 0; i < port->max_buf_cnt; i++)
-				dev_vdbg(ac->dev, "%s %d\n",
-					__func__, port->buf[i].used);
-
-		}
-		break;
-	}
-	case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2:
-		pr_debug("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session, data->opcode,
-				data->token,
-				data->src_port, data->dest_port);
-		if (payload[0] != 0) {
-			pr_err("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 returned error = 0x%x\n",
-				__func__, payload[0]);
-		} else if (generic_get_data) {
-			generic_get_data->valid = 1;
-			if (generic_get_data->is_inband) {
-				pr_debug("%s: payload[1] = 0x%x, payload[2]=0x%x, payload[3]=0x%x\n",
-				  __func__, payload[1], payload[2], payload[3]);
-				generic_get_data->size_in_ints = payload[3]>>2;
-				for (i = 0; i < payload[3]>>2; i++) {
-					generic_get_data->ints[i] =
-								   payload[4+i];
-					pr_debug("%s: ASM callback val %i = %i\n",
-						 __func__, i, payload[4+i]);
-				}
-				pr_debug("%s: callback size in ints = %i\n",
-					 __func__,
-					generic_get_data->size_in_ints);
-			}
-			if (atomic_read(&ac->cmd_state) && wakeup_flag) {
-				atomic_set(&ac->cmd_state, 0);
-				wake_up(&ac->cmd_wait);
-			}
-			break;
-		}
-		rtac_make_asm_callback(ac->session, payload,
-			data->payload_size);
-		break;
-	case ASM_DATA_EVENT_READ_DONE_V2:{
-
-		struct audio_port_data *port = &ac->port[OUT];
-
-		config_debug_fs_read_cb();
-
-		dev_vdbg(ac->dev, "%s: ReadDone: status=%d buff_add=0x%x act_size=%d offset=%d\n",
-				__func__, payload[READDONE_IDX_STATUS],
-				payload[READDONE_IDX_BUFADD_LSW],
-				payload[READDONE_IDX_SIZE],
-				payload[READDONE_IDX_OFFSET]);
-
-		dev_vdbg(ac->dev, "%s: ReadDone:msw_ts=%d lsw_ts=%d memmap_hdl=0x%x flags=%d id=%d num=%d\n",
-				__func__, payload[READDONE_IDX_MSW_TS],
-				payload[READDONE_IDX_LSW_TS],
-				payload[READDONE_IDX_MEMMAP_HDL],
-				payload[READDONE_IDX_FLAGS],
-				payload[READDONE_IDX_SEQ_ID],
-				payload[READDONE_IDX_NUMFRAMES]);
-
-		if (ac->io_mode & SYNC_IO_MODE) {
-			if (port->buf == NULL) {
-				pr_err("%s: Unexpected Write Done\n", __func__);
-				return -EINVAL;
-			}
-			spin_lock_irqsave(&port->dsp_lock, dsp_flags);
-			buf_index = asm_token._token.buf_index;
-			port->buf[buf_index].used = 0;
-			if (lower_32_bits(port->buf[buf_index].phys) !=
-			payload[READDONE_IDX_BUFADD_LSW] ||
-			msm_audio_populate_upper_32_bits(
-				port->buf[buf_index].phys) !=
-					payload[READDONE_IDX_BUFADD_MSW]) {
-				dev_vdbg(ac->dev, "%s: Expected addr %pK\n",
-					__func__, &port->buf[buf_index].phys);
-				pr_err("%s: rxedl[0x%x] rxedu[0x%x]\n",
-					__func__,
-				payload[READDONE_IDX_BUFADD_LSW],
-				payload[READDONE_IDX_BUFADD_MSW]);
-				spin_unlock_irqrestore(&port->dsp_lock,
-							dsp_flags);
-				break;
-			}
-			port->buf[buf_index].actual_size =
-				payload[READDONE_IDX_SIZE];
-			spin_unlock_irqrestore(&port->dsp_lock, dsp_flags);
-		}
-		break;
-	}
-	case ASM_DATA_EVENT_EOS:
-	case ASM_DATA_EVENT_RENDERED_EOS:
-		pr_debug("%s: EOS ACK received: rxed session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-		break;
-	case ASM_SESSION_EVENTX_OVERFLOW:
-		pr_debug("%s: ASM_SESSION_EVENTX_OVERFLOW session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-		break;
-	case ASM_SESSION_EVENT_RX_UNDERFLOW:
-		pr_debug("%s: ASM_SESSION_EVENT_RX_UNDERFLOW session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-		break;
-	case ASM_SESSION_CMDRSP_GET_SESSIONTIME_V3:
-		dev_vdbg(ac->dev, "%s: ASM_SESSION_CMDRSP_GET_SESSIONTIME_V3, payload[0] = %d, payload[1] = %d, payload[2] = %d\n",
-				 __func__,
-				 payload[0], payload[1], payload[2]);
-		ac->time_stamp = (uint64_t)(((uint64_t)payload[2] << 32) |
-				payload[1]);
-		if (atomic_cmpxchg(&ac->time_flag, 1, 0))
-			wake_up(&ac->time_wait);
-		break;
-	case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
-	case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY:
-		pr_debug("%s: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY session %d opcode 0x%x token 0x%x src %d dest %d\n",
-				__func__, ac->session,
-				data->opcode, data->token,
-				data->src_port, data->dest_port);
-		pr_debug("%s: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, payload[0] = %d, payload[1] = %d, payload[2] = %d, payload[3] = %d\n",
-				 __func__,
-				payload[0], payload[1], payload[2],
-				payload[3]);
-		break;
-	case ASM_SESSION_CMDRSP_GET_MTMX_STRTR_PARAMS_V2:
-		q6asm_process_mtmx_get_param_rsp(ac, (void *) payload);
-		break;
-	case ASM_STREAM_PP_EVENT:
-	case ASM_STREAM_CMD_ENCDEC_EVENTS:
-	case ASM_STREAM_CMD_REGISTER_IEC_61937_FMT_UPDATE:
-		pr_debug("%s: ASM_STREAM_EVENT payload[0][0x%x] payload[1][0x%x]",
-				 __func__, payload[0], payload[1]);
-		i = is_adsp_raise_event(data->opcode);
-		if (i < 0)
-			return 0;
-
-		/* repack payload for asm_stream_pp_event
-		 * package is composed of event type + size + actual payload
-		 */
-		payload_size = data->payload_size;
-		pp_event_package = kzalloc(payload_size
-				+ sizeof(struct msm_adsp_event_data),
-				GFP_ATOMIC);
-		if (!pp_event_package)
-			return -ENOMEM;
-
-		pp_event_package->event_type = i;
-		pp_event_package->payload_len = payload_size;
-		memcpy((void *)pp_event_package->payload,
-			data->payload, payload_size);
-		ac->cb(data->opcode, data->token,
-			(void *)pp_event_package, ac->priv);
-		kfree(pp_event_package);
-		return 0;
-	case ASM_SESSION_CMDRSP_ADJUST_SESSION_CLOCK_V2:
-		pr_debug("%s: ASM_SESSION_CMDRSP_ADJUST_SESSION_CLOCK_V2 sesion %d status 0x%x msw %u lsw %u\n",
-			 __func__, ac->session, payload[0], payload[2],
-			 payload[1]);
-		wake_up(&ac->cmd_wait);
-		break;
-	case ASM_SESSION_CMDRSP_GET_PATH_DELAY_V2:
-		pr_debug("%s: ASM_SESSION_CMDRSP_GET_PATH_DELAY_V2 session %d status 0x%x msw %u lsw %u\n",
-				__func__, ac->session, payload[0], payload[2],
-				payload[1]);
-		if (payload[0] == 0) {
-			atomic_set(&ac->cmd_state, 0);
-			/* ignore msw, as a delay that large shouldn't happen */
-			ac->path_delay = payload[1];
-		} else {
-			atomic_set(&ac->cmd_state, payload[0]);
-			ac->path_delay = UINT_MAX;
-		}
-		wake_up(&ac->cmd_wait);
-		break;
-	}
-	if (ac->cb)
-		ac->cb(data->opcode, data->token,
-			data->payload, ac->priv);
-
-	return 0;
-}
-
-void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac, uint32_t *size,
-				uint32_t *index)
-{
-	void *data;
-	unsigned char idx;
-	struct audio_port_data *port;
-
-	if (!ac || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		return NULL;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[dir];
-
-		mutex_lock(&port->lock);
-		idx = port->cpu_buf;
-		if (port->buf == NULL) {
-			pr_err("%s: Buffer pointer null\n", __func__);
-			mutex_unlock(&port->lock);
-			return NULL;
-		}
-		/* dir 0: used = 0 means buf in use
-		 * dir 1: used = 1 means buf in use
-		 */
-		if (port->buf[idx].used == dir) {
-			/* To make it more robust, we could loop and get the
-			 * next avail buf, its risky though
-			 */
-			pr_err("%s: Next buf idx[0x%x] not available, dir[%d]\n",
-			 __func__, idx, dir);
-			mutex_unlock(&port->lock);
-			return NULL;
-		}
-		*size = port->buf[idx].actual_size;
-		*index = port->cpu_buf;
-		data = port->buf[idx].data;
-		dev_vdbg(ac->dev, "%s: session[%d]index[%d] data[%pK]size[%d]\n",
-						__func__,
-						ac->session,
-						port->cpu_buf,
-						data, *size);
-		/* By default increase the cpu_buf cnt
-		 * user accesses this function,increase cpu
-		 * buf(to avoid another api)
-		 */
-		port->buf[idx].used = dir;
-		port->cpu_buf = q6asm_get_next_buf(ac, port->cpu_buf,
-						   port->max_buf_cnt);
-		mutex_unlock(&port->lock);
-		return data;
-	}
-	return NULL;
-}
-
-int q6asm_cpu_buf_release(int dir, struct audio_client *ac)
-{
-	struct audio_port_data *port;
-	int ret = 0;
-	int idx;
-
-	if (!ac || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[dir];
-		mutex_lock(&port->lock);
-		idx = port->cpu_buf;
-		if (port->cpu_buf == 0) {
-			port->cpu_buf = port->max_buf_cnt - 1;
-		} else if (port->cpu_buf < port->max_buf_cnt) {
-			port->cpu_buf = port->cpu_buf - 1;
-		} else {
-			pr_err("%s: buffer index(%d) out of range\n",
-			       __func__, port->cpu_buf);
-			ret = -EINVAL;
-			mutex_unlock(&port->lock);
-			goto exit;
-		}
-		port->buf[port->cpu_buf].used = dir ^ 1;
-		mutex_unlock(&port->lock);
-	}
-exit:
-	return ret;
-}
-
-void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
-					uint32_t *size, uint32_t *index)
-{
-	void *data;
-	unsigned char idx;
-	struct audio_port_data *port;
-
-	if (!ac || ((dir != IN) && (dir != OUT))) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		return NULL;
-	}
-
-	port = &ac->port[dir];
-
-	idx = port->cpu_buf;
-	if (port->buf == NULL) {
-		pr_err("%s: Buffer pointer null\n", __func__);
-		return NULL;
-	}
-	/*
-	 * dir 0: used = 0 means buf in use
-	 * dir 1: used = 1 means buf in use
-	 */
-	if (port->buf[idx].used == dir) {
-		/*
-		 * To make it more robust, we could loop and get the
-		 * next avail buf, its risky though
-		 */
-		pr_err("%s: Next buf idx[0x%x] not available, dir[%d]\n",
-		 __func__, idx, dir);
-		return NULL;
-	}
-	*size = port->buf[idx].actual_size;
-	*index = port->cpu_buf;
-	data = port->buf[idx].data;
-	dev_vdbg(ac->dev, "%s: session[%d]index[%d] data[%pK]size[%d]\n",
-		__func__, ac->session, port->cpu_buf,
-		data, *size);
-	/*
-	 * By default increase the cpu_buf cnt
-	 * user accesses this function,increase cpu
-	 * buf(to avoid another api)
-	 */
-	port->buf[idx].used = dir;
-	port->cpu_buf = q6asm_get_next_buf(ac, port->cpu_buf,
-					   port->max_buf_cnt);
-	return data;
-}
-
-int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac)
-{
-	int ret = -1;
-	struct audio_port_data *port;
-	uint32_t idx;
-
-	if (!ac || (dir != OUT)) {
-		pr_err("%s: ac %pK dir %d\n", __func__, ac, dir);
-		return ret;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[dir];
-
-		mutex_lock(&port->lock);
-		idx = port->dsp_buf;
-
-		if (port->buf[idx].used == (dir ^ 1)) {
-			/* To make it more robust, we could loop and get the
-			 * next avail buf, its risky though
-			 */
-			pr_err("%s: Next buf idx[0x%x] not available, dir[%d]\n",
-				__func__, idx, dir);
-			mutex_unlock(&port->lock);
-			return ret;
-		}
-		dev_vdbg(ac->dev, "%s: session[%d]dsp_buf=%d cpu_buf=%d\n",
-			__func__,
-			ac->session, port->dsp_buf, port->cpu_buf);
-		ret = ((port->dsp_buf != port->cpu_buf) ? 0 : -1);
-		mutex_unlock(&port->lock);
-	}
-	return ret;
-}
-
-static void __q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,
-			uint32_t pkt_size, uint32_t cmd_flg, uint32_t stream_id)
-{
-	dev_vdbg(ac->dev, "%s: pkt_size=%d cmd_flg=%d session=%d stream_id=%d\n",
-			__func__, pkt_size, cmd_flg, ac->session, stream_id);
-	mutex_lock(&ac->cmd_lock);
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL", __func__);
-		mutex_unlock(&ac->cmd_lock);
-		return;
-	}
-
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(sizeof(struct apr_hdr)),
-			APR_PKT_VER);
-	hdr->src_svc = ((struct apr_svc *)ac->apr)->id;
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->dest_svc = APR_SVC_ASM;
-	hdr->dest_domain = APR_DOMAIN_ADSP;
-	hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id);
-	hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id);
-	if (cmd_flg)
-		q6asm_update_token(&hdr->token,
-				   ac->session,
-				   0, /* Stream ID is NA */
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-
-	hdr->pkt_size  = pkt_size;
-	mutex_unlock(&ac->cmd_lock);
-}
-
-static void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,
-			uint32_t pkt_size, uint32_t cmd_flg)
-{
-	__q6asm_add_hdr(ac, hdr, pkt_size, cmd_flg, ac->stream_id);
-}
-
-static void q6asm_stream_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,
-			uint32_t pkt_size, uint32_t cmd_flg, int32_t stream_id)
-{
-	__q6asm_add_hdr(ac, hdr, pkt_size, cmd_flg, stream_id);
-}
-
-static void __q6asm_add_hdr_async(struct audio_client *ac, struct apr_hdr *hdr,
-				  uint32_t pkt_size, uint32_t cmd_flg,
-				  uint32_t stream_id, u8 no_wait_flag)
-{
-	dev_vdbg(ac->dev, "%s: pkt_size = %d, cmd_flg = %d, session = %d stream_id=%d\n",
-			__func__, pkt_size, cmd_flg, ac->session, stream_id);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(sizeof(struct apr_hdr)),
-			APR_PKT_VER);
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR is NULL", __func__);
-		return;
-	}
-	hdr->src_svc = ((struct apr_svc *)ac->apr)->id;
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->dest_svc = APR_SVC_ASM;
-	hdr->dest_domain = APR_DOMAIN_ADSP;
-	hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id);
-	hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id);
-	if (cmd_flg) {
-		q6asm_update_token(&hdr->token,
-				   ac->session,
-				   0, /* Stream ID is NA */
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   no_wait_flag);
-
-	}
-	hdr->pkt_size  = pkt_size;
-}
-
-static void q6asm_add_hdr_async(struct audio_client *ac, struct apr_hdr *hdr,
-				uint32_t pkt_size, uint32_t cmd_flg)
-{
-	__q6asm_add_hdr_async(ac, hdr, pkt_size, cmd_flg,
-			      ac->stream_id, WAIT_CMD);
-}
-
-static void q6asm_stream_add_hdr_async(struct audio_client *ac,
-					struct apr_hdr *hdr, uint32_t pkt_size,
-					uint32_t cmd_flg, int32_t stream_id)
-{
-	__q6asm_add_hdr_async(ac, hdr, pkt_size, cmd_flg,
-			      stream_id, NO_WAIT_CMD);
-}
-
-static void q6asm_add_hdr_custom_topology(struct audio_client *ac,
-					  struct apr_hdr *hdr,
-					  uint32_t pkt_size)
-{
-	pr_debug("%s: pkt_size=%d session=%d\n",
-			__func__, pkt_size, ac->session);
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return;
-	}
-
-	mutex_lock(&ac->cmd_lock);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(sizeof(struct apr_hdr)),
-			APR_PKT_VER);
-	hdr->src_svc = ((struct apr_svc *)ac->apr)->id;
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->dest_svc = APR_SVC_ASM;
-	hdr->dest_domain = APR_DOMAIN_ADSP;
-	hdr->src_port = ((ac->session << 8) & 0xFF00) | 0x01;
-	hdr->dest_port = 0;
-	q6asm_update_token(&hdr->token,
-			   ac->session,
-			   0, /* Stream ID is NA */
-			   0, /* Buffer index is NA */
-			   0, /* Direction flag is NA */
-			   WAIT_CMD);
-	hdr->pkt_size  = pkt_size;
-	mutex_unlock(&ac->cmd_lock);
-}
-
-static void q6asm_add_mmaphdr(struct audio_client *ac, struct apr_hdr *hdr,
-			u32 pkt_size, int dir)
-{
-	pr_debug("%s: pkt size=%d\n",
-		__func__, pkt_size);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	hdr->src_port = 0;
-	hdr->dest_port = 0;
-	q6asm_update_token(&hdr->token,
-			   ac->session,
-			   0, /* Stream ID is NA */
-			   0, /* Buffer index is NA */
-			   dir,
-			   WAIT_CMD);
-	hdr->pkt_size  = pkt_size;
-}
-
-static int __q6asm_open_read(struct audio_client *ac,
-			     uint32_t format, uint16_t bits_per_sample,
-			     uint32_t pcm_format_block_ver,
-			     bool ts_mode)
-{
-	int rc = 0x00;
-	struct asm_stream_cmd_open_read_v3 open;
-
-	config_debug_fs_reset_index();
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	open.hdr.opcode = ASM_STREAM_CMD_OPEN_READ_V3;
-	/* Stream prio : High, provide meta info with encoded frames */
-	open.src_endpointype = ASM_END_POINT_DEVICE_MATRIX;
-
-	open.preprocopo_id = q6asm_get_asm_topology_cal();
-	open.bits_per_sample = bits_per_sample;
-	open.mode_flags = 0x0;
-
-	ac->topology = open.preprocopo_id;
-	ac->app_type = q6asm_get_asm_app_type_cal();
-	if (ac->perf_mode == LOW_LATENCY_PCM_MODE) {
-		open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION <<
-			ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ;
-	} else {
-		open.mode_flags |= ASM_LEGACY_STREAM_SESSION <<
-			ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ;
-	}
-
-	switch (format) {
-	case FORMAT_LINEAR_PCM:
-		open.mode_flags |= 0x00;
-		open.enc_cfg_id = q6asm_get_pcm_format_id(pcm_format_block_ver);
-		if (ts_mode)
-			open.mode_flags |= ABSOLUTE_TIMESTAMP_ENABLE;
-		break;
-	case FORMAT_MPEG4_AAC:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_G711_ALAW_FS:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_G711_ALAW_FS;
-		break;
-	case FORMAT_G711_MLAW_FS:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_G711_MLAW_FS;
-		break;
-	case FORMAT_V13K:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_V13K_FS;
-		break;
-	case FORMAT_EVRC:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_EVRC_FS;
-		break;
-	case FORMAT_AMRNB:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_AMRNB_FS;
-		break;
-	case FORMAT_AMRWB:
-		open.mode_flags |= BUFFER_META_ENABLE;
-		open.enc_cfg_id = ASM_MEDIA_FMT_AMRWB_FS;
-		break;
-	default:
-		pr_err("%s: Invalid format 0x%x\n",
-			__func__, format);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-				__func__, open.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for open read\n",
-				__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	ac->io_mode |= TUN_READ_IO_MODE;
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_open_read(struct audio_client *ac,
-		uint32_t format)
-{
-	return __q6asm_open_read(ac, format, 16,
-				PCM_MEDIA_FORMAT_V2 /*media fmt block ver*/,
-				false/*ts_mode*/);
-}
-
-int q6asm_open_read_v2(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample)
-{
-	return __q6asm_open_read(ac, format, bits_per_sample,
-				 PCM_MEDIA_FORMAT_V2 /*media fmt block ver*/,
-				 false/*ts_mode*/);
-}
-
-/*
- * asm_open_read_v3 - Opens audio capture session
- *
- * @ac: Client session handle
- * @format: encoder format
- * @bits_per_sample: bit width of capture session
- */
-int q6asm_open_read_v3(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample)
-{
-	return __q6asm_open_read(ac, format, bits_per_sample,
-				 PCM_MEDIA_FORMAT_V3/*media fmt block ver*/,
-				 false/*ts_mode*/);
-}
-EXPORT_SYMBOL(q6asm_open_read_v3);
-
-/*
- * asm_open_read_v4 - Opens audio capture session
- *
- * @ac: Client session handle
- * @format: encoder format
- * @bits_per_sample: bit width of capture session
- * @ts_mode: timestamp mode
- */
-int q6asm_open_read_v4(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample, bool ts_mode)
-{
-	return __q6asm_open_read(ac, format, bits_per_sample,
-				 PCM_MEDIA_FORMAT_V4 /*media fmt block ver*/,
-				 ts_mode);
-}
-EXPORT_SYMBOL(q6asm_open_read_v4);
-
-int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format,
-				uint32_t passthrough_flag)
-{
-	int rc = 0;
-	struct asm_stream_cmd_open_write_compressed open;
-
-	if (ac == NULL) {
-		pr_err("%s: ac[%pK] NULL\n",  __func__, ac);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: APR handle[%pK] NULL\n", __func__,  ac->apr);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	pr_debug("%s: session[%d] wr_format[0x%x]", __func__, ac->session,
-		format);
-
-	q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-	open.hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED;
-	atomic_set(&ac->cmd_state, -1);
-
-	switch (format) {
-	case FORMAT_AC3:
-		open.fmt_id = ASM_MEDIA_FMT_AC3;
-		break;
-	case FORMAT_EAC3:
-		open.fmt_id = ASM_MEDIA_FMT_EAC3;
-		break;
-	case FORMAT_DTS:
-		open.fmt_id = ASM_MEDIA_FMT_DTS;
-		break;
-	case FORMAT_DSD:
-		open.fmt_id = ASM_MEDIA_FMT_DSD;
-		break;
-	case FORMAT_GEN_COMPR:
-		open.fmt_id = ASM_MEDIA_FMT_GENERIC_COMPRESSED;
-		break;
-	case FORMAT_TRUEHD:
-		open.fmt_id = ASM_MEDIA_FMT_TRUEHD;
-		break;
-	case FORMAT_IEC61937:
-		open.fmt_id = ASM_MEDIA_FMT_IEC;
-		break;
-	default:
-		pr_err("%s: Invalid format[%d]\n", __func__, format);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	/* Below flag indicates the DSP that Compressed audio input
-	 * stream is not IEC 61937 or IEC 60958 packetizied
-	 */
-	if (passthrough_flag == COMPRESSED_PASSTHROUGH ||
-		passthrough_flag == COMPRESSED_PASSTHROUGH_DSD ||
-		passthrough_flag == COMPRESSED_PASSTHROUGH_GEN) {
-		open.flags = 0x0;
-		pr_debug("%s: Flag 0 COMPRESSED_PASSTHROUGH\n", __func__);
-	} else if (passthrough_flag == COMPRESSED_PASSTHROUGH_CONVERT) {
-		open.flags = 0x8;
-		pr_debug("%s: Flag 8 - COMPRESSED_PASSTHROUGH_CONVERT\n",
-			 __func__);
-	} else if (passthrough_flag == COMPRESSED_PASSTHROUGH_IEC61937) {
-		open.flags = 0x1;
-		pr_debug("%s: Flag 1 - COMPRESSED_PASSTHROUGH_IEC61937\n",
-			 __func__);
-	} else {
-		pr_err("%s: Invalid passthrough type[%d]\n",
-			__func__, passthrough_flag);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-			__func__, open.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-		(atomic_read(&ac->cmd_state) >= 0), 1*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for OPEN_WRITE_COMPR rc[%d]\n",
-			__func__, rc);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_open_write(struct audio_client *ac, uint32_t format,
-			      uint16_t bits_per_sample, uint32_t stream_id,
-			      bool is_gapless_mode,
-			      uint32_t pcm_format_block_ver)
-{
-	int rc = 0x00;
-	struct asm_stream_cmd_open_write_v3 open;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_vdbg(ac->dev, "%s: session[%d] wr_format[0x%x]\n",
-		__func__, ac->session, format);
-
-	q6asm_stream_add_hdr(ac, &open.hdr, sizeof(open), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&open.hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-
-	dev_vdbg(ac->dev, "%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-			__func__, open.hdr.token, stream_id, ac->session);
-	open.hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE_V3;
-	open.mode_flags = 0x00;
-	if (ac->perf_mode == ULL_POST_PROCESSING_PCM_MODE)
-		open.mode_flags |= ASM_ULL_POST_PROCESSING_STREAM_SESSION;
-	else if (ac->perf_mode == ULTRA_LOW_LATENCY_PCM_MODE)
-		open.mode_flags |= ASM_ULTRA_LOW_LATENCY_STREAM_SESSION;
-	else if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
-		open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
-	else {
-		open.mode_flags |= ASM_LEGACY_STREAM_SESSION;
-		if (is_gapless_mode)
-			open.mode_flags |= 1 << ASM_SHIFT_GAPLESS_MODE_FLAG;
-	}
-
-	/* source endpoint : matrix */
-	open.sink_endpointype = ASM_END_POINT_DEVICE_MATRIX;
-	open.bits_per_sample = bits_per_sample;
-
-	open.postprocopo_id = q6asm_get_asm_topology_cal();
-	if (ac->perf_mode != LEGACY_PCM_MODE)
-		open.postprocopo_id = ASM_STREAM_POSTPROCOPO_ID_NONE;
-
-	pr_debug("%s: perf_mode %d asm_topology 0x%x bps %d\n", __func__,
-		 ac->perf_mode, open.postprocopo_id, open.bits_per_sample);
-
-	/*
-	 * For Gapless playback it will use the same session for next stream,
-	 * So use the same topology
-	 */
-	if (!ac->topology) {
-		ac->topology = open.postprocopo_id;
-		ac->app_type = q6asm_get_asm_app_type_cal();
-	}
-	switch (format) {
-	case FORMAT_LINEAR_PCM:
-		open.dec_fmt_id = q6asm_get_pcm_format_id(pcm_format_block_ver);
-		break;
-	case FORMAT_MPEG4_AAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_MPEG4_MULTI_AAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_WMA_V9:
-		open.dec_fmt_id = ASM_MEDIA_FMT_WMA_V9_V2;
-		break;
-	case FORMAT_WMA_V10PRO:
-		open.dec_fmt_id = ASM_MEDIA_FMT_WMA_V10PRO_V2;
-		break;
-	case FORMAT_MP3:
-		open.dec_fmt_id = ASM_MEDIA_FMT_MP3;
-		break;
-	case FORMAT_AC3:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AC3;
-		break;
-	case FORMAT_EAC3:
-		open.dec_fmt_id = ASM_MEDIA_FMT_EAC3;
-		break;
-	case FORMAT_MP2:
-		open.dec_fmt_id = ASM_MEDIA_FMT_MP2;
-		break;
-	case FORMAT_FLAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_FLAC;
-		break;
-	case FORMAT_ALAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_ALAC;
-		break;
-	case FORMAT_VORBIS:
-		open.dec_fmt_id = ASM_MEDIA_FMT_VORBIS;
-		break;
-	case FORMAT_APE:
-		open.dec_fmt_id = ASM_MEDIA_FMT_APE;
-		break;
-	case FORMAT_DSD:
-		open.dec_fmt_id = ASM_MEDIA_FMT_DSD;
-		break;
-	case FORMAT_APTX:
-		open.dec_fmt_id = ASM_MEDIA_FMT_APTX;
-		break;
-	case FORMAT_GEN_COMPR:
-		open.dec_fmt_id = ASM_MEDIA_FMT_GENERIC_COMPRESSED;
-		break;
-	default:
-		pr_err("%s: Invalid format 0x%x\n", __func__, format);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-				__func__, open.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for open write\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	ac->io_mode |= TUN_WRITE_IO_MODE;
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_open_write(struct audio_client *ac, uint32_t format)
-{
-	return __q6asm_open_write(ac, format, 16, ac->stream_id,
-				  false /*gapless*/,
-				  PCM_MEDIA_FORMAT_V2 /*pcm_format_block_ver*/);
-}
-
-int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  ac->stream_id, false /*gapless*/,
-				  PCM_MEDIA_FORMAT_V2 /*pcm_format_block_ver*/);
-}
-
-/*
- * q6asm_open_write_v3 - Opens audio playback session
- *
- * @ac: Client session handle
- * @format: decoder format
- * @bits_per_sample: bit width of playback session
- */
-int q6asm_open_write_v3(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  ac->stream_id, false /*gapless*/,
-				  PCM_MEDIA_FORMAT_V3 /*pcm_format_block_ver*/);
-}
-EXPORT_SYMBOL(q6asm_open_write_v3);
-
-/*
- * q6asm_open_write_v4 - Opens audio playback session
- *
- * @ac: Client session handle
- * @format: decoder format
- * @bits_per_sample: bit width of playback session
- */
-int q6asm_open_write_v4(struct audio_client *ac, uint32_t format,
-			uint16_t bits_per_sample)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  ac->stream_id, false /*gapless*/,
-				  PCM_MEDIA_FORMAT_V4 /*pcm_format_block_ver*/);
-}
-EXPORT_SYMBOL(q6asm_open_write_v4);
-
-int q6asm_stream_open_write_v2(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  stream_id, is_gapless_mode,
-				  PCM_MEDIA_FORMAT_V2 /*pcm_format_block_ver*/);
-}
-
-/*
- * q6asm_stream_open_write_v3 - Creates audio stream for playback
- *
- * @ac: Client session handle
- * @format: asm playback format
- * @bits_per_sample: bit width of requested stream
- * @stream_id: stream id of stream to be associated with this session
- * @is_gapless_mode: true if gapless mode needs to be enabled
- */
-int q6asm_stream_open_write_v3(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  stream_id, is_gapless_mode,
-				  PCM_MEDIA_FORMAT_V3 /*pcm_format_block_ver*/);
-}
-EXPORT_SYMBOL(q6asm_stream_open_write_v3);
-
-/*
- * q6asm_stream_open_write_v4 - Creates audio stream for playback
- *
- * @ac: Client session handle
- * @format: asm playback format
- * @bits_per_sample: bit width of requested stream
- * @stream_id: stream id of stream to be associated with this session
- * @is_gapless_mode: true if gapless mode needs to be enabled
- */
-int q6asm_stream_open_write_v4(struct audio_client *ac, uint32_t format,
-			       uint16_t bits_per_sample, int32_t stream_id,
-			       bool is_gapless_mode)
-{
-	return __q6asm_open_write(ac, format, bits_per_sample,
-				  stream_id, is_gapless_mode,
-				  PCM_MEDIA_FORMAT_V4 /*pcm_format_block_ver*/);
-}
-EXPORT_SYMBOL(q6asm_stream_open_write_v4);
-
-static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format,
-				   uint32_t wr_format, bool is_meta_data_mode,
-				   uint32_t bits_per_sample,
-				   bool overwrite_topology, int topology)
-{
-	int rc = 0x00;
-	struct asm_stream_cmd_open_readwrite_v2 open;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-	pr_debug("%s: wr_format[0x%x]rd_format[0x%x]\n",
-			__func__, wr_format, rd_format);
-
-	ac->io_mode |= NT_MODE;
-	q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	open.hdr.opcode = ASM_STREAM_CMD_OPEN_READWRITE_V2;
-
-	open.mode_flags = is_meta_data_mode ? BUFFER_META_ENABLE : 0;
-	open.bits_per_sample = bits_per_sample;
-	/* source endpoint : matrix */
-	open.postprocopo_id = q6asm_get_asm_topology_cal();
-
-	open.postprocopo_id = overwrite_topology ?
-			      topology : open.postprocopo_id;
-	ac->topology = open.postprocopo_id;
-	ac->app_type = q6asm_get_asm_app_type_cal();
-
-
-	switch (wr_format) {
-	case FORMAT_LINEAR_PCM:
-	case FORMAT_MULTI_CHANNEL_LINEAR_PCM:
-		open.dec_fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
-		break;
-	case FORMAT_MPEG4_AAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_MPEG4_MULTI_AAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_WMA_V9:
-		open.dec_fmt_id = ASM_MEDIA_FMT_WMA_V9_V2;
-		break;
-	case FORMAT_WMA_V10PRO:
-		open.dec_fmt_id = ASM_MEDIA_FMT_WMA_V10PRO_V2;
-		break;
-	case FORMAT_AMRNB:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AMRNB_FS;
-		break;
-	case FORMAT_AMRWB:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AMRWB_FS;
-		break;
-	case FORMAT_AMR_WB_PLUS:
-		open.dec_fmt_id = ASM_MEDIA_FMT_AMR_WB_PLUS_V2;
-		break;
-	case FORMAT_V13K:
-		open.dec_fmt_id = ASM_MEDIA_FMT_V13K_FS;
-		break;
-	case FORMAT_EVRC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_EVRC_FS;
-		break;
-	case FORMAT_EVRCB:
-		open.dec_fmt_id = ASM_MEDIA_FMT_EVRCB_FS;
-		break;
-	case FORMAT_EVRCWB:
-		open.dec_fmt_id = ASM_MEDIA_FMT_EVRCWB_FS;
-		break;
-	case FORMAT_MP3:
-		open.dec_fmt_id = ASM_MEDIA_FMT_MP3;
-		break;
-	case FORMAT_ALAC:
-		open.dec_fmt_id = ASM_MEDIA_FMT_ALAC;
-		break;
-	case FORMAT_APE:
-		open.dec_fmt_id = ASM_MEDIA_FMT_APE;
-		break;
-	case FORMAT_DSD:
-		open.dec_fmt_id = ASM_MEDIA_FMT_DSD;
-		break;
-	case FORMAT_G711_ALAW_FS:
-		open.dec_fmt_id = ASM_MEDIA_FMT_G711_ALAW_FS;
-		break;
-	case FORMAT_G711_MLAW_FS:
-		open.dec_fmt_id = ASM_MEDIA_FMT_G711_MLAW_FS;
-		break;
-	default:
-		pr_err("%s: Invalid format 0x%x\n",
-				__func__, wr_format);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	switch (rd_format) {
-	case FORMAT_LINEAR_PCM:
-	case FORMAT_MULTI_CHANNEL_LINEAR_PCM:
-		open.enc_cfg_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
-		break;
-	case FORMAT_MPEG4_AAC:
-		open.enc_cfg_id = ASM_MEDIA_FMT_AAC_V2;
-		break;
-	case FORMAT_G711_ALAW_FS:
-		open.enc_cfg_id = ASM_MEDIA_FMT_G711_ALAW_FS;
-		break;
-	case FORMAT_G711_MLAW_FS:
-		open.enc_cfg_id = ASM_MEDIA_FMT_G711_MLAW_FS;
-		break;
-	case FORMAT_V13K:
-		open.enc_cfg_id = ASM_MEDIA_FMT_V13K_FS;
-		break;
-	case FORMAT_EVRC:
-		open.enc_cfg_id = ASM_MEDIA_FMT_EVRC_FS;
-		break;
-	case FORMAT_AMRNB:
-		open.enc_cfg_id = ASM_MEDIA_FMT_AMRNB_FS;
-		break;
-	case FORMAT_AMRWB:
-		open.enc_cfg_id = ASM_MEDIA_FMT_AMRWB_FS;
-		break;
-	case FORMAT_ALAC:
-		open.enc_cfg_id = ASM_MEDIA_FMT_ALAC;
-		break;
-	case FORMAT_APE:
-		open.enc_cfg_id = ASM_MEDIA_FMT_APE;
-		break;
-	default:
-		pr_err("%s: Invalid format 0x%x\n",
-				__func__, rd_format);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	dev_vdbg(ac->dev, "%s: rdformat[0x%x]wrformat[0x%x]\n", __func__,
-			open.enc_cfg_id, open.dec_fmt_id);
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-				__func__, open.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for open read-write\n",
-				__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format,
-			  uint32_t wr_format)
-{
-	return __q6asm_open_read_write(ac, rd_format, wr_format,
-				       true/*meta data mode*/,
-				       16 /*bits_per_sample*/,
-				       false /*overwrite_topology*/, 0);
-}
-
-int q6asm_open_read_write_v2(struct audio_client *ac, uint32_t rd_format,
-			     uint32_t wr_format, bool is_meta_data_mode,
-			     uint32_t bits_per_sample, bool overwrite_topology,
-			     int topology)
-{
-	return __q6asm_open_read_write(ac, rd_format, wr_format,
-				       is_meta_data_mode, bits_per_sample,
-				       overwrite_topology, topology);
-}
-
-int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
-{
-	int rc = 0x00;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	if (ac->perf_mode == LOW_LATENCY_PCM_MODE) {
-		struct asm_stream_cmd_open_transcode_loopback_t open;
-
-		q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-		atomic_set(&ac->cmd_state, -1);
-		open.hdr.opcode = ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK;
-
-		open.mode_flags = 0;
-		open.src_endpoint_type = 0;
-		open.sink_endpoint_type = 0;
-		open.src_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
-		open.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
-		/* source endpoint : matrix */
-		open.audproc_topo_id = q6asm_get_asm_topology_cal();
-
-		ac->app_type = q6asm_get_asm_app_type_cal();
-		if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
-			open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
-		else
-			open.mode_flags |= ASM_LEGACY_STREAM_SESSION;
-		ac->topology = open.audproc_topo_id;
-		open.bits_per_sample = bits_per_sample;
-		open.reserved = 0;
-		pr_debug("%s: opening a transcode_loopback with mode_flags =[%d] session[%d]\n",
-				__func__, open.mode_flags, ac->session);
-
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-		if (rc < 0) {
-			pr_err("%s: open failed op[0x%x]rc[%d]\n",
-					__func__, open.hdr.opcode, rc);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {/*if(ac->perf_mode == LEGACY_PCM_MODE)*/
-		struct asm_stream_cmd_open_loopback_v2 open;
-
-		q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-		atomic_set(&ac->cmd_state, -1);
-		open.hdr.opcode = ASM_STREAM_CMD_OPEN_LOOPBACK_V2;
-
-		open.mode_flags = 0;
-		open.src_endpointype = 0;
-		open.sink_endpointype = 0;
-		/* source endpoint : matrix */
-		open.postprocopo_id = q6asm_get_asm_topology_cal();
-
-		ac->app_type = q6asm_get_asm_app_type_cal();
-		ac->topology = open.postprocopo_id;
-		open.bits_per_sample = bits_per_sample;
-		open.reserved = 0;
-		pr_debug("%s: opening a loopback_v2 with mode_flags =[%d] session[%d]\n",
-				__func__, open.mode_flags, ac->session);
-
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-		if (rc < 0) {
-			pr_err("%s: open failed op[0x%x]rc[%d]\n",
-					__func__, open.hdr.opcode, rc);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for open_loopback\n",
-				__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-
-int q6asm_open_transcode_loopback(struct audio_client *ac,
-			uint16_t bits_per_sample,
-			uint32_t source_format, uint32_t sink_format)
-{
-	int rc = 0x00;
-	struct asm_stream_cmd_open_transcode_loopback_t open;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	open.hdr.opcode = ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK;
-
-	open.mode_flags = 0;
-	open.src_endpoint_type = 0;
-	open.sink_endpoint_type = 0;
-	switch (source_format) {
-	case FORMAT_LINEAR_PCM:
-	case FORMAT_MULTI_CHANNEL_LINEAR_PCM:
-		open.src_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
-		break;
-	case FORMAT_AC3:
-		open.src_format_id = ASM_MEDIA_FMT_AC3;
-		break;
-	case FORMAT_EAC3:
-		open.src_format_id = ASM_MEDIA_FMT_EAC3;
-		break;
-	default:
-		pr_err("%s: Unsupported src fmt [%d]\n",
-		       __func__, source_format);
-		return -EINVAL;
-	}
-	switch (sink_format) {
-	case FORMAT_LINEAR_PCM:
-	case FORMAT_MULTI_CHANNEL_LINEAR_PCM:
-		open.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
-		break;
-	default:
-		pr_err("%s: Unsupported sink fmt [%d]\n",
-		       __func__, sink_format);
-		return -EINVAL;
-	}
-
-	/* source endpoint : matrix */
-	open.audproc_topo_id = q6asm_get_asm_topology_cal();
-
-	ac->app_type = q6asm_get_asm_app_type_cal();
-	if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
-		open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
-	else
-		open.mode_flags |= ASM_LEGACY_STREAM_SESSION;
-	ac->topology = open.audproc_topo_id;
-	open.bits_per_sample = bits_per_sample;
-	open.reserved = 0;
-	pr_debug("%s: opening a transcode_loopback with mode_flags =[%d] session[%d]\n",
-		__func__, open.mode_flags, ac->session);
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &open);
-	if (rc < 0) {
-		pr_err("%s: open failed op[0x%x]rc[%d]\n",
-				__func__, open.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for open_transcode_loopback\n",
-			__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-					atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static
-int q6asm_set_shared_circ_buff(struct audio_client *ac,
-			       struct asm_stream_cmd_open_shared_io *open,
-			       int bufsz, int bufcnt,
-			       int dir)
-{
-	struct audio_buffer *buf_circ;
-	int bytes_to_alloc, rc;
-	size_t len;
-
-	buf_circ = kzalloc(sizeof(struct audio_buffer), GFP_KERNEL);
-
-	if (!buf_circ) {
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	mutex_lock(&ac->cmd_lock);
-
-	ac->port[dir].buf = buf_circ;
-
-	bytes_to_alloc = bufsz * bufcnt;
-	bytes_to_alloc = PAGE_ALIGN(bytes_to_alloc);
-
-	rc = msm_audio_ion_alloc("audio_client", &buf_circ->client,
-			&buf_circ->handle, bytes_to_alloc,
-			(ion_phys_addr_t *)&buf_circ->phys,
-			&len, &buf_circ->data);
-
-	if (rc) {
-		pr_err("%s: Audio ION alloc is failed, rc = %d\n", __func__,
-				rc);
-		mutex_unlock(&ac->cmd_lock);
-		kfree(buf_circ);
-		goto done;
-	}
-
-	buf_circ->used = dir ^ 1;
-	buf_circ->size = bytes_to_alloc;
-	buf_circ->actual_size = bytes_to_alloc;
-	memset(buf_circ->data, 0, buf_circ->actual_size);
-
-	ac->port[dir].max_buf_cnt = 1;
-
-	open->shared_circ_buf_mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	open->shared_circ_buf_num_regions = 1;
-	open->shared_circ_buf_property_flag = 0x00;
-	open->shared_circ_buf_start_phy_addr_lsw =
-			lower_32_bits(buf_circ->phys);
-	open->shared_circ_buf_start_phy_addr_msw =
-			msm_audio_populate_upper_32_bits(buf_circ->phys);
-	open->shared_circ_buf_size = bufsz * bufcnt;
-
-	open->map_region_circ_buf.shm_addr_lsw = lower_32_bits(buf_circ->phys);
-	open->map_region_circ_buf.shm_addr_msw =
-			msm_audio_populate_upper_32_bits(buf_circ->phys);
-	open->map_region_circ_buf.mem_size_bytes = bytes_to_alloc;
-
-	mutex_unlock(&ac->cmd_lock);
-done:
-	return rc;
-}
-
-
-static
-int q6asm_set_shared_pos_buff(struct audio_client *ac,
-			       struct asm_stream_cmd_open_shared_io *open,
-			       int dir)
-{
-	struct audio_buffer *buf_pos = &ac->shared_pos_buf;
-	int rc;
-	size_t len;
-	int bytes_to_alloc = sizeof(struct asm_shared_position_buffer);
-
-	mutex_lock(&ac->cmd_lock);
-
-	bytes_to_alloc = PAGE_ALIGN(bytes_to_alloc);
-
-	rc = msm_audio_ion_alloc("audio_client", &buf_pos->client,
-			&buf_pos->handle, bytes_to_alloc,
-			(ion_phys_addr_t *)&buf_pos->phys, &len,
-			&buf_pos->data);
-
-	if (rc) {
-		pr_err("%s: Audio pos buf ION alloc is failed, rc = %d\n",
-				__func__, rc);
-		goto done;
-	}
-
-	buf_pos->used = dir ^ 1;
-	buf_pos->size = bytes_to_alloc;
-	buf_pos->actual_size = bytes_to_alloc;
-
-	open->shared_pos_buf_mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	open->shared_pos_buf_num_regions = 1;
-	open->shared_pos_buf_property_flag = 0x00;
-	open->shared_pos_buf_phy_addr_lsw = lower_32_bits(buf_pos->phys);
-	open->shared_pos_buf_phy_addr_msw =
-			msm_audio_populate_upper_32_bits(buf_pos->phys);
-
-	open->map_region_pos_buf.shm_addr_lsw = lower_32_bits(buf_pos->phys);
-	open->map_region_pos_buf.shm_addr_msw =
-			msm_audio_populate_upper_32_bits(buf_pos->phys);
-	open->map_region_pos_buf.mem_size_bytes = bytes_to_alloc;
-
-done:
-	mutex_unlock(&ac->cmd_lock);
-	return rc;
-}
-
-/*
- * q6asm_open_shared_io: Open an ASM session for pull mode (playback)
- * or push mode (capture).
- * parameters
- *   config - session parameters (channels, bits_per_sample, sr)
- *   dir - stream direction (IN for playback, OUT for capture)
- * returns 0 if successful, error code otherwise
- */
-int q6asm_open_shared_io(struct audio_client *ac,
-			 struct shared_io_config *config,
-			 int dir)
-{
-	struct asm_stream_cmd_open_shared_io *open;
-	u8 *channel_mapping;
-	int i, size_of_open, num_watermarks, bufsz, bufcnt, rc, flags = 0;
-
-	if (!ac || !config)
-		return -EINVAL;
-
-	bufsz = config->bufsz;
-	bufcnt = config->bufcnt;
-	num_watermarks = 0;
-
-	ac->config = *config;
-
-	if (ac->session <= 0 || ac->session > SESSION_MAX) {
-		pr_err("%s: Session %d is out of bounds\n",
-			__func__, ac->session);
-		return -EINVAL;
-	}
-
-	size_of_open = sizeof(struct asm_stream_cmd_open_shared_io) +
-		(sizeof(struct asm_shared_watermark_level) * num_watermarks);
-
-	open = kzalloc(PAGE_ALIGN(size_of_open), GFP_KERNEL);
-	if (!open)
-		return -ENOMEM;
-
-	q6asm_stream_add_hdr(ac, &open->hdr, size_of_open, TRUE,
-				ac->stream_id);
-
-	atomic_set(&ac->cmd_state, 1);
-
-	pr_debug("%s: token = 0x%x, stream_id %d, session 0x%x, perf %d\n",
-		 __func__, open->hdr.token, ac->stream_id, ac->session,
-		 ac->perf_mode);
-
-	open->hdr.opcode =
-		dir == IN ? ASM_STREAM_CMD_OPEN_PULL_MODE_WRITE :
-		ASM_STREAM_CMD_OPEN_PUSH_MODE_READ;
-
-	pr_debug("%s perf_mode %d\n", __func__, ac->perf_mode);
-	if (dir == IN)
-		if (ac->perf_mode == ULL_POST_PROCESSING_PCM_MODE)
-			flags = 4 << ASM_SHIFT_STREAM_PERF_FLAG_PULL_MODE_WRITE;
-		else if (ac->perf_mode == ULTRA_LOW_LATENCY_PCM_MODE)
-			flags = 2 << ASM_SHIFT_STREAM_PERF_FLAG_PULL_MODE_WRITE;
-		else if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
-			flags = 1 << ASM_SHIFT_STREAM_PERF_FLAG_PULL_MODE_WRITE;
-		else
-			pr_err("Invalid perf mode for pull write\n");
-	else
-		if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
-			flags = ASM_LOW_LATENCY_TX_STREAM_SESSION <<
-				ASM_SHIFT_STREAM_PERF_FLAG_PUSH_MODE_READ;
-		else
-			pr_err("Invalid perf mode for push read\n");
-
-	if (flags == 0) {
-		pr_err("%s: Invalid mode[%d]\n", __func__,
-		       ac->perf_mode);
-		kfree(open);
-		return -EINVAL;
-
-	}
-
-	pr_debug("open.mode_flags = 0x%x\n", flags);
-	open->mode_flags = flags;
-	open->endpoint_type = ASM_END_POINT_DEVICE_MATRIX;
-	open->topo_bits_per_sample = config->bits_per_sample;
-
-	open->topo_id = q6asm_get_asm_topology_cal();
-
-	if (config->format == FORMAT_LINEAR_PCM)
-		open->fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
-	else {
-		pr_err("%s: Invalid format[%d]\n", __func__, config->format);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	if (ac->port[dir].buf) {
-		pr_err("%s: Buffer already allocated\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	rc = q6asm_set_shared_circ_buff(ac, open, bufsz, bufcnt, dir);
-
-	if (rc)
-		goto done;
-
-	ac->port[dir].tmp_hdl = 0;
-
-	rc = q6asm_set_shared_pos_buff(ac, open, dir);
-
-	if (rc)
-		goto done;
-
-	/* asm_multi_channel_pcm_fmt_blk_v3 */
-	open->fmt.num_channels = config->channels;
-	open->fmt.bits_per_sample = config->bits_per_sample;
-	open->fmt.sample_rate = config->rate;
-	open->fmt.is_signed = 1;
-	open->fmt.sample_word_size = config->sample_word_size;
-
-	channel_mapping = open->fmt.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	rc = q6asm_map_channels(channel_mapping, config->channels, false);
-	if (rc) {
-		pr_err("%s: Map channels failed, ret: %d\n", __func__, rc);
-		goto done;
-	}
-
-	open->num_watermark_levels = num_watermarks;
-	for (i = 0; i < num_watermarks; i++) {
-		open->watermark[i].watermark_level_bytes = i *
-				((bufsz * bufcnt) / num_watermarks);
-		pr_debug("%s: Watermark level set for %i\n",
-				__func__,
-				open->watermark[i].watermark_level_bytes);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) open);
-	if (rc < 0) {
-		pr_err("%s: Open failed op[0x%x]rc[%d]\n",
-		       __func__, open->hdr.opcode, rc);
-		goto done;
-	}
-
-	pr_debug("%s: sent open apr pkt\n", __func__);
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) <= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: Timeout. Waited for open write apr pkt rc[%d]\n",
-		       __func__, rc);
-		rc = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (atomic_read(&ac->cmd_state) < 0) {
-		pr_err("%s: DSP returned error [%d]\n", __func__,
-				atomic_read(&ac->cmd_state));
-		rc = -EINVAL;
-		goto done;
-	}
-
-	ac->io_mode |= TUN_WRITE_IO_MODE;
-	rc = 0;
-done:
-	kfree(open);
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_open_shared_io);
-
-/*
- * q6asm_shared_io_buf: Returns handle to the shared circular buffer being
- * used for pull/push mode.
- * parameters
- *   dir - used to identify input/output port
- * returns buffer handle
- */
-struct audio_buffer *q6asm_shared_io_buf(struct audio_client *ac,
-					 int dir)
-{
-	struct audio_port_data *port;
-
-	if (!ac) {
-		pr_err("%s: ac is null\n", __func__);
-		return NULL;
-	}
-	port = &ac->port[dir];
-	return port->buf;
-}
-EXPORT_SYMBOL(q6asm_shared_io_buf);
-
-/*
- * q6asm_shared_io_free: Frees memory allocated for a pull/push session
- * parameters
- *  dir - port direction
- * returns 0 if successful, error otherwise
- */
-int q6asm_shared_io_free(struct audio_client *ac, int dir)
-{
-	struct audio_port_data *port;
-
-	if (!ac) {
-		pr_err("%s: audio client is null\n", __func__);
-		return -EINVAL;
-	}
-	port = &ac->port[dir];
-	mutex_lock(&ac->cmd_lock);
-	if (port->buf && port->buf->data) {
-		msm_audio_ion_free(port->buf->client, port->buf->handle);
-		port->buf->client = NULL;
-		port->buf->handle = NULL;
-		port->max_buf_cnt = 0;
-		kfree(port->buf);
-		port->buf = NULL;
-	}
-	if (ac->shared_pos_buf.data) {
-		msm_audio_ion_free(ac->shared_pos_buf.client,
-				ac->shared_pos_buf.handle);
-		ac->shared_pos_buf.client = NULL;
-		ac->shared_pos_buf.handle = NULL;
-	}
-	mutex_unlock(&ac->cmd_lock);
-	return 0;
-}
-EXPORT_SYMBOL(q6asm_shared_io_free);
-
-/*
- * q6asm_get_shared_pos: Returns current read index/write index as observed
- * by the DSP. Note that this is an offset and iterates from [0,BUF_SIZE - 1]
- * parameters - (all output)
- *   read_index - offset
- *   wall_clk_msw1 - ADSP wallclock msw
- *   wall_clk_lsw1 - ADSP wallclock lsw
- * returns 0 if successful, -EAGAIN if DSP failed to update after some
- * retries
- */
-int q6asm_get_shared_pos(struct audio_client *ac, uint32_t *read_index,
-			 uint32_t *wall_clk_msw1, uint32_t *wall_clk_lsw1)
-{
-	struct asm_shared_position_buffer *pos_buf;
-	uint32_t frame_cnt1, frame_cnt2;
-	int i, j;
-
-	if (!ac) {
-		pr_err("%s: audio client is null\n", __func__);
-		return -EINVAL;
-	}
-
-	pos_buf = ac->shared_pos_buf.data;
-
-	/* always try to get the latest update in the shared pos buffer */
-	for (i = 0; i < 2; i++) {
-		/* retry until there is an update from DSP */
-		for (j = 0; j < 5; j++) {
-			frame_cnt1 = pos_buf->frame_counter;
-			if (frame_cnt1 != 0)
-				break;
-		}
-
-		*wall_clk_msw1 = pos_buf->wall_clock_us_msw;
-		*wall_clk_lsw1 = pos_buf->wall_clock_us_lsw;
-		*read_index = pos_buf->index;
-		frame_cnt2 = pos_buf->frame_counter;
-
-		if (frame_cnt1 != frame_cnt2)
-			continue;
-		return 0;
-	}
-	pr_err("%s out of tries trying to get a good read, try again\n",
-	       __func__);
-	return -EAGAIN;
-}
-
-int q6asm_run(struct audio_client *ac, uint32_t flags,
-		uint32_t msw_ts, uint32_t lsw_ts)
-{
-	struct asm_session_cmd_run_v2 run;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	q6asm_add_hdr(ac, &run.hdr, sizeof(run), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	run.hdr.opcode = ASM_SESSION_CMD_RUN_V2;
-	run.flags    = flags;
-	run.time_lsw = lsw_ts;
-	run.time_msw = msw_ts;
-
-	config_debug_fs_run();
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &run);
-	if (rc < 0) {
-		pr_err("%s: Commmand run failed[%d]",
-				__func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for run success",
-				__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
-		uint32_t msw_ts, uint32_t lsw_ts, uint32_t stream_id)
-{
-	struct asm_session_cmd_run_v2 run;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-
-	q6asm_stream_add_hdr_async(ac, &run.hdr, sizeof(run), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, 1);
-	run.hdr.opcode = ASM_SESSION_CMD_RUN_V2;
-	run.flags    = flags;
-	run.time_lsw = lsw_ts;
-	run.time_msw = msw_ts;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &run);
-	if (rc < 0) {
-		pr_err("%s: Commmand run failed[%d]", __func__, rc);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
-			uint32_t msw_ts, uint32_t lsw_ts)
-{
-	return __q6asm_run_nowait(ac, flags, msw_ts, lsw_ts, ac->stream_id);
-}
-
-int q6asm_stream_run_nowait(struct audio_client *ac, uint32_t flags,
-			uint32_t msw_ts, uint32_t lsw_ts, uint32_t stream_id)
-{
-	return __q6asm_run_nowait(ac, flags, msw_ts, lsw_ts, stream_id);
-}
-
-int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
-			 uint32_t frames_per_buf,
-			uint32_t sample_rate, uint32_t channels,
-			uint32_t bit_rate, uint32_t mode, uint32_t format)
-{
-	struct asm_aac_enc_cfg_v2 enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]SR[%d]ch[%d]bitrate[%d]mode[%d] format[%d]\n",
-		 __func__, ac->session, frames_per_buf,
-		sample_rate, channels, bit_rate, mode, format);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_aac_enc_cfg_v2) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-	enc_cfg.bit_rate = bit_rate;
-	enc_cfg.enc_mode = mode;
-	enc_cfg.aac_fmt_flag = format;
-	enc_cfg.channel_cfg = channels;
-	enc_cfg.sample_rate = sample_rate;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n",
-			__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_enc_cfg_blk_g711(struct audio_client *ac,
-			uint32_t frames_per_buf,
-			uint32_t sample_rate)
-{
-	struct asm_g711_enc_cfg_v2 enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]SR[%d]\n",
-		 __func__, ac->session, frames_per_buf,
-		sample_rate);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_g711_enc_cfg_v2) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-	enc_cfg.sample_rate = sample_rate;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n",
-			__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_set_encdec_chan_map(struct audio_client *ac,
-			uint32_t num_channels)
-{
-	struct asm_dec_out_chan_map_param chan_map;
-	u8 *channel_mapping;
-	int rc = 0;
-
-	pr_debug("%s: Session %d, num_channels = %d\n",
-			 __func__, ac->session, num_channels);
-	q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	chan_map.encdec.param_id = ASM_PARAM_ID_DEC_OUTPUT_CHAN_MAP;
-	chan_map.encdec.param_size = sizeof(struct asm_dec_out_chan_map_param) -
-			 (sizeof(struct apr_hdr) +
-			 sizeof(struct asm_stream_cmd_set_encdec_param));
-	chan_map.num_channels = num_channels;
-	channel_mapping = chan_map.channel_mapping;
-	memset(channel_mapping, PCM_CHANNEL_NULL, MAX_CHAN_MAP_CHANNELS);
-
-	if (q6asm_map_channels(channel_mapping, num_channels, false)) {
-		pr_err("%s: map channels failed %d\n", __func__, num_channels);
-		return -EINVAL;
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &chan_map);
-	if (rc < 0) {
-		pr_err("%s: Command opcode[0x%x]paramid[0x%x] failed %d\n",
-			   __func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM,
-			   ASM_PARAM_ID_DEC_OUTPUT_CHAN_MAP, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				 (atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n", __func__,
-			   chan_map.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-		return rc;
-}
-
-/*
- * q6asm_enc_cfg_blk_pcm_v4 - sends encoder configuration parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @use_default_chmap: true if default channel map  to be used
- * @use_back_flavor: to configure back left and right channel
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- * @endianness: endianness of the pcm data
- * @mode: Mode to provide additional info about the pcm input data
- */
-int q6asm_enc_cfg_blk_pcm_v4(struct audio_client *ac,
-			     uint32_t rate, uint32_t channels,
-			     uint16_t bits_per_sample, bool use_default_chmap,
-			     bool use_back_flavor, u8 *channel_map,
-			     uint16_t sample_word_size, uint16_t endianness,
-			     uint16_t mode)
-{
-	struct asm_multi_channel_pcm_enc_cfg_v4 enc_cfg;
-	struct asm_enc_cfg_blk_param_v2 enc_fg_blk;
-	u8 *channel_mapping;
-	u32 frames_per_buf = 0;
-	int rc;
-
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-				__func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&enc_cfg, 0, sizeof(enc_cfg));
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(enc_cfg) - sizeof(enc_cfg.hdr) -
-				    sizeof(enc_cfg.encdec);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size = enc_cfg.encdec.param_size -
-					  sizeof(enc_fg_blk);
-	enc_cfg.num_channels = channels;
-	enc_cfg.bits_per_sample = bits_per_sample;
-	enc_cfg.sample_rate = rate;
-	enc_cfg.is_signed = 1;
-	enc_cfg.sample_word_size = sample_word_size;
-	enc_cfg.endianness = endianness;
-	enc_cfg.mode = mode;
-	channel_mapping = enc_cfg.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		pr_debug("%s: setting default channel map for %d channels",
-			 __func__, channels);
-		if (q6asm_map_channels(channel_mapping, channels,
-					use_back_flavor)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		pr_debug("%s: Using pre-defined channel map", __func__);
-		memcpy(channel_mapping, channel_map,
-			PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Command open failed %d\n", __func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n",
-		       __func__, enc_cfg.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-		       __func__, adsp_err_get_err_str(
-		       atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_enc_cfg_blk_pcm_v4);
-
-/*
- * q6asm_enc_cfg_blk_pcm_v3 - sends encoder configuration parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @use_default_chmap: true if default channel map  to be used
- * @use_back_flavor: to configure back left and right channel
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- */
-int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
-			     uint32_t rate, uint32_t channels,
-			     uint16_t bits_per_sample, bool use_default_chmap,
-			     bool use_back_flavor, u8 *channel_map,
-			     uint16_t sample_word_size)
-{
-	struct asm_multi_channel_pcm_enc_cfg_v3 enc_cfg;
-	struct asm_enc_cfg_blk_param_v2 enc_fg_blk;
-	u8 *channel_mapping;
-	u32 frames_per_buf = 0;
-	int rc;
-
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-				__func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&enc_cfg, 0, sizeof(enc_cfg));
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(enc_cfg) - sizeof(enc_cfg.hdr) -
-				    sizeof(enc_cfg.encdec);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size = enc_cfg.encdec.param_size -
-					  sizeof(enc_fg_blk);
-	enc_cfg.num_channels = channels;
-	enc_cfg.bits_per_sample = bits_per_sample;
-	enc_cfg.sample_rate = rate;
-	enc_cfg.is_signed = 1;
-	enc_cfg.sample_word_size = sample_word_size;
-	channel_mapping = enc_cfg.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		pr_debug("%s: setting default channel map for %d channels",
-			 __func__, channels);
-		if (q6asm_map_channels(channel_mapping, channels,
-					use_back_flavor)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		pr_debug("%s: Using pre-defined channel map", __func__);
-		memcpy(channel_mapping, channel_map,
-			PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n",
-		       __func__, enc_cfg.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-		       __func__, adsp_err_get_err_str(
-		       atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_enc_cfg_blk_pcm_v3);
-
-int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
-		uint32_t rate, uint32_t channels, uint16_t bits_per_sample,
-		bool use_default_chmap, bool use_back_flavor, u8 *channel_map)
-{
-	struct asm_multi_channel_pcm_enc_cfg_v2  enc_cfg;
-	u8 *channel_mapping;
-	u32 frames_per_buf = 0;
-
-	int rc = 0;
-
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-				__func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
-			 ac->session, rate, channels);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(enc_cfg) - sizeof(enc_cfg.hdr) -
-				sizeof(enc_cfg.encdec);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-					sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.num_channels = channels;
-	enc_cfg.bits_per_sample = bits_per_sample;
-	enc_cfg.sample_rate = rate;
-	enc_cfg.is_signed = 1;
-	channel_mapping = enc_cfg.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		pr_debug("%s: setting default channel map for %d channels",
-		__func__, channels);
-		if (q6asm_map_channels(channel_mapping, channels,
-					use_back_flavor)) {
-			pr_err("%s: map channels failed %d\n",
-			 __func__, channels);
-			return -EINVAL;
-		}
-	} else {
-		pr_debug("%s: Using pre-defined channel map", __func__);
-		memcpy(channel_mapping, channel_map,
-			PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n",
-			__func__, enc_cfg.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_enc_cfg_blk_pcm_v4(struct audio_client *ac,
-				      uint32_t rate, uint32_t channels,
-				      uint16_t bits_per_sample,
-				      uint16_t sample_word_size,
-				      uint16_t endianness,
-				      uint16_t mode)
-{
-	return q6asm_enc_cfg_blk_pcm_v4(ac, rate, channels,
-					bits_per_sample, true, false, NULL,
-					sample_word_size, endianness, mode);
-}
-
-static int __q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
-				      uint32_t rate, uint32_t channels,
-				      uint16_t bits_per_sample,
-				      uint16_t sample_word_size)
-{
-	return q6asm_enc_cfg_blk_pcm_v3(ac, rate, channels,
-					bits_per_sample, true, false, NULL,
-					sample_word_size);
-}
-
-static int __q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
-		uint32_t rate, uint32_t channels, uint16_t bits_per_sample)
-{
-	return q6asm_enc_cfg_blk_pcm_v2(ac, rate, channels,
-					bits_per_sample, true, false, NULL);
-}
-
-int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
-			uint32_t rate, uint32_t channels)
-{
-	return __q6asm_enc_cfg_blk_pcm(ac, rate, channels, 16);
-}
-
-int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
-		uint32_t rate, uint32_t channels, uint16_t bits_per_sample)
-{
-	return __q6asm_enc_cfg_blk_pcm(ac, rate, channels, bits_per_sample);
-}
-
-/*
- * q6asm_enc_cfg_blk_pcm_format_support_v3 - sends encoder configuration
- *                                           parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- */
-int q6asm_enc_cfg_blk_pcm_format_support_v3(struct audio_client *ac,
-					    uint32_t rate, uint32_t channels,
-					    uint16_t bits_per_sample,
-					    uint16_t sample_word_size)
-{
-	return __q6asm_enc_cfg_blk_pcm_v3(ac, rate, channels,
-					  bits_per_sample, sample_word_size);
-}
-EXPORT_SYMBOL(q6asm_enc_cfg_blk_pcm_format_support_v3);
-
-/*
- * q6asm_enc_cfg_blk_pcm_format_support_v4 - sends encoder configuration
- *                                           parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- * @endianness: endianness of the pcm data
- * @mode: Mode to provide additional info about the pcm input data
- */
-int q6asm_enc_cfg_blk_pcm_format_support_v4(struct audio_client *ac,
-					    uint32_t rate, uint32_t channels,
-					    uint16_t bits_per_sample,
-					    uint16_t sample_word_size,
-					    uint16_t endianness,
-					    uint16_t mode)
-{
-	return __q6asm_enc_cfg_blk_pcm_v4(ac, rate, channels,
-					   bits_per_sample, sample_word_size,
-					   endianness, mode);
-}
-EXPORT_SYMBOL(q6asm_enc_cfg_blk_pcm_format_support_v4);
-
-int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
-			uint32_t rate, uint32_t channels)
-{
-	struct asm_multi_channel_pcm_enc_cfg_v2  enc_cfg;
-	u8 *channel_mapping;
-	u32 frames_per_buf = 0;
-
-	int rc = 0;
-
-	pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
-			 ac->session, rate, channels);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(enc_cfg) - sizeof(enc_cfg.hdr) -
-				 sizeof(enc_cfg.encdec);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.num_channels = 0;/*channels;*/
-	enc_cfg.bits_per_sample = 16;
-	enc_cfg.sample_rate = 0;/*rate;*/
-	enc_cfg.is_signed = 1;
-	channel_mapping = enc_cfg.channel_mapping;
-
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (q6asm_map_channels(channel_mapping, channels, false)) {
-		pr_err("%s: map channels failed %d\n", __func__, channels);
-		return -EINVAL;
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n",
-			__func__, enc_cfg.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels,
-		bool use_back_flavor)
-{
-	u8 *lchannel_mapping;
-
-	lchannel_mapping = channel_mapping;
-	pr_debug("%s:  channels passed: %d\n", __func__, channels);
-	if (channels == 1)  {
-		lchannel_mapping[0] = PCM_CHANNEL_FC;
-	} else if (channels == 2) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-	} else if (channels == 3) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = PCM_CHANNEL_FC;
-	} else if (channels == 4) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = use_back_flavor ?
-			PCM_CHANNEL_LB : PCM_CHANNEL_LS;
-		lchannel_mapping[3] = use_back_flavor ?
-			PCM_CHANNEL_RB : PCM_CHANNEL_RS;
-	} else if (channels == 5) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = PCM_CHANNEL_FC;
-		lchannel_mapping[3] = use_back_flavor ?
-			PCM_CHANNEL_LB : PCM_CHANNEL_LS;
-		lchannel_mapping[4] = use_back_flavor ?
-			PCM_CHANNEL_RB : PCM_CHANNEL_RS;
-	} else if (channels == 6) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = PCM_CHANNEL_FC;
-		lchannel_mapping[3] = PCM_CHANNEL_LFE;
-		lchannel_mapping[4] = use_back_flavor ?
-			PCM_CHANNEL_LB : PCM_CHANNEL_LS;
-		lchannel_mapping[5] = use_back_flavor ?
-			PCM_CHANNEL_RB : PCM_CHANNEL_RS;
-	} else if (channels == 7) {
-		/*
-		 * Configured for 5.1 channel mapping + 1 channel for debug
-		 * Can be customized based on DSP.
-		 */
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = PCM_CHANNEL_FC;
-		lchannel_mapping[3] = PCM_CHANNEL_LFE;
-		lchannel_mapping[4] = use_back_flavor ?
-			PCM_CHANNEL_LB : PCM_CHANNEL_LS;
-		lchannel_mapping[5] = use_back_flavor ?
-			PCM_CHANNEL_RB : PCM_CHANNEL_RS;
-		lchannel_mapping[6] = PCM_CHANNEL_CS;
-	} else if (channels == 8) {
-		lchannel_mapping[0] = PCM_CHANNEL_FL;
-		lchannel_mapping[1] = PCM_CHANNEL_FR;
-		lchannel_mapping[2] = PCM_CHANNEL_FC;
-		lchannel_mapping[3] = PCM_CHANNEL_LFE;
-		lchannel_mapping[4] = PCM_CHANNEL_LB;
-		lchannel_mapping[5] = PCM_CHANNEL_RB;
-		lchannel_mapping[6] = PCM_CHANNEL_LS;
-		lchannel_mapping[7] = PCM_CHANNEL_RS;
-	} else {
-		pr_err("%s: ERROR.unsupported num_ch = %u\n",
-		 __func__, channels);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-int q6asm_enable_sbrps(struct audio_client *ac,
-			uint32_t sbr_ps_enable)
-{
-	struct asm_aac_sbr_ps_flag_param  sbrps;
-	u32 frames_per_buf = 0;
-
-	int rc = 0;
-
-	pr_debug("%s: Session %d\n", __func__, ac->session);
-
-	q6asm_add_hdr(ac, &sbrps.hdr, sizeof(sbrps), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	sbrps.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	sbrps.encdec.param_id = ASM_PARAM_ID_AAC_SBR_PS_FLAG;
-	sbrps.encdec.param_size = sizeof(struct asm_aac_sbr_ps_flag_param) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	sbrps.encblk.frames_per_buf = frames_per_buf;
-	sbrps.encblk.enc_cfg_blk_size  = sbrps.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	sbrps.sbr_ps_flag = sbr_ps_enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &sbrps);
-	if (rc < 0) {
-		pr_err("%s: Command opcode[0x%x]paramid[0x%x] failed %d\n",
-				__func__,
-				ASM_STREAM_CMD_SET_ENCDEC_PARAM,
-				ASM_PARAM_ID_AAC_SBR_PS_FLAG, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x] ", __func__, sbrps.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
-			uint16_t sce_left, uint16_t sce_right)
-{
-	struct asm_aac_dual_mono_mapping_param dual_mono;
-
-	int rc = 0;
-
-	pr_debug("%s: Session %d, sce_left = %d, sce_right = %d\n",
-			 __func__, ac->session, sce_left, sce_right);
-
-	q6asm_add_hdr(ac, &dual_mono.hdr, sizeof(dual_mono), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	dual_mono.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	dual_mono.encdec.param_id = ASM_PARAM_ID_AAC_DUAL_MONO_MAPPING;
-	dual_mono.encdec.param_size = sizeof(dual_mono.left_channel_sce) +
-				      sizeof(dual_mono.right_channel_sce);
-	dual_mono.left_channel_sce = sce_left;
-	dual_mono.right_channel_sce = sce_right;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &dual_mono);
-	if (rc < 0) {
-		pr_err("%s: Command opcode[0x%x]paramid[0x%x] failed %d\n",
-				__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM,
-				ASM_PARAM_ID_AAC_DUAL_MONO_MAPPING, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n", __func__,
-						dual_mono.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-/* Support for selecting stereo mixing coefficients for B family not done */
-int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff)
-{
-	struct asm_aac_stereo_mix_coeff_selection_param_v2 aac_mix_coeff;
-	int rc = 0;
-
-	q6asm_add_hdr(ac, &aac_mix_coeff.hdr, sizeof(aac_mix_coeff), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	aac_mix_coeff.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	aac_mix_coeff.param_id =
-		ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG_V2;
-	aac_mix_coeff.param_size =
-		sizeof(struct asm_aac_stereo_mix_coeff_selection_param_v2);
-	aac_mix_coeff.aac_stereo_mix_coeff_flag = mix_coeff;
-	pr_debug("%s: mix_coeff = %u\n", __func__, mix_coeff);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &aac_mix_coeff);
-	if (rc < 0) {
-		pr_err("%s: Command opcode[0x%x]paramid[0x%x] failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM,
-			ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG_V2,
-			rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-		(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n",
-			__func__, aac_mix_coeff.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t min_rate, uint16_t max_rate,
-		uint16_t reduced_rate_level, uint16_t rate_modulation_cmd)
-{
-	struct asm_v13k_enc_cfg enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]min_rate[0x%4x]max_rate[0x%4x] reduced_rate_level[0x%4x]rate_modulation_cmd[0x%4x]\n",
-		 __func__,
-		ac->session, frames_per_buf, min_rate, max_rate,
-		reduced_rate_level, rate_modulation_cmd);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_v13k_enc_cfg) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.min_rate = min_rate;
-	enc_cfg.max_rate = max_rate;
-	enc_cfg.reduced_rate_cmd = reduced_rate_level;
-	enc_cfg.rate_mod_cmd = rate_modulation_cmd;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for setencdec v13k resp\n",
-			__func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
-		uint16_t min_rate, uint16_t max_rate,
-		uint16_t rate_modulation_cmd)
-{
-	struct asm_evrc_enc_cfg enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]min_rate[0x%4x]max_rate[0x%4x] rate_modulation_cmd[0x%4x]\n",
-		 __func__, ac->session,
-		frames_per_buf,	min_rate, max_rate, rate_modulation_cmd);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_evrc_enc_cfg) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.min_rate = min_rate;
-	enc_cfg.max_rate = max_rate;
-	enc_cfg.rate_mod_cmd = rate_modulation_cmd;
-	enc_cfg.reserved = 0;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for encdec evrc\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
-			uint16_t band_mode, uint16_t dtx_enable)
-{
-	struct asm_amrnb_enc_cfg enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]band_mode[0x%4x]dtx_enable[0x%4x]\n",
-		__func__, ac->session, frames_per_buf, band_mode, dtx_enable);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_amrnb_enc_cfg) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.enc_mode = band_mode;
-	enc_cfg.dtx_mode = dtx_enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for set encdec amrnb\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
-			uint16_t band_mode, uint16_t dtx_enable)
-{
-	struct asm_amrwb_enc_cfg enc_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]frames[%d]band_mode[0x%4x]dtx_enable[0x%4x]\n",
-		__func__, ac->session, frames_per_buf, band_mode, dtx_enable);
-
-	q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	enc_cfg.encdec.param_id = ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2;
-	enc_cfg.encdec.param_size = sizeof(struct asm_amrwb_enc_cfg) -
-				sizeof(struct asm_stream_cmd_set_encdec_param);
-	enc_cfg.encblk.frames_per_buf = frames_per_buf;
-	enc_cfg.encblk.enc_cfg_blk_size  = enc_cfg.encdec.param_size -
-				sizeof(struct asm_enc_cfg_blk_param_v2);
-
-	enc_cfg.enc_mode = band_mode;
-	enc_cfg.dtx_mode = dtx_enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg);
-	if (rc < 0) {
-		pr_err("%s: Comamnd %d failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-
-static int __q6asm_media_format_block_pcm(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				uint16_t bits_per_sample, int stream_id,
-				bool use_default_chmap, char *channel_map)
-{
-	struct asm_multi_channel_pcm_fmt_blk_v2 fmt;
-	u8 *channel_mapping;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
-		channels);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&fmt.hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-		  __func__, fmt.hdr.token, stream_id, ac->session);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.num_channels = channels;
-	fmt.bits_per_sample = bits_per_sample;
-	fmt.sample_rate = rate;
-	fmt.is_signed = 1;
-
-	channel_mapping = fmt.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-				__func__, channels);
-			return -EINVAL;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_media_format_block_pcm_v3(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     uint16_t bits_per_sample,
-					     int stream_id,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t sample_word_size)
-{
-	struct asm_multi_channel_pcm_fmt_blk_param_v3 fmt;
-	u8 *channel_mapping;
-	int rc;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		fmt.hdr.token = ((ac->session << 8) & 0xFFFF00) |
-				(stream_id & 0xFF);
-
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-		 __func__, fmt.hdr.token, stream_id, ac->session);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.param.num_channels = channels;
-	fmt.param.bits_per_sample = bits_per_sample;
-	fmt.param.sample_rate = rate;
-	fmt.param.is_signed = 1;
-	fmt.param.sample_word_size = sample_word_size;
-	channel_mapping = fmt.param.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_media_format_block_pcm_v4(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     uint16_t bits_per_sample,
-					     int stream_id,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t sample_word_size,
-					     uint16_t endianness,
-					     uint16_t mode)
-{
-	struct asm_multi_channel_pcm_fmt_blk_param_v4 fmt;
-	u8 *channel_mapping;
-	int rc;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		fmt.hdr.token = ((ac->session << 8) & 0xFFFF00) |
-				(stream_id & 0xFF);
-
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-		 __func__, fmt.hdr.token, stream_id, ac->session);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.param.num_channels = channels;
-	fmt.param.bits_per_sample = bits_per_sample;
-	fmt.param.sample_rate = rate;
-	fmt.param.is_signed = 1;
-	fmt.param.sample_word_size = sample_word_size;
-	fmt.param.endianness = endianness;
-	fmt.param.mode = mode;
-	channel_mapping = fmt.param.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_pcm(struct audio_client *ac,
-				uint32_t rate, uint32_t channels)
-{
-	return __q6asm_media_format_block_pcm(ac, rate,
-				channels, 16, ac->stream_id,
-				true, NULL);
-}
-
-int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				uint16_t bits_per_sample)
-{
-	return __q6asm_media_format_block_pcm(ac, rate,
-				channels, bits_per_sample, ac->stream_id,
-				true, NULL);
-}
-
-int q6asm_media_format_block_pcm_format_support_v2(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				uint16_t bits_per_sample, int stream_id,
-				bool use_default_chmap, char *channel_map)
-{
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-			__func__);
-		return -EINVAL;
-	}
-	return __q6asm_media_format_block_pcm(ac, rate,
-				channels, bits_per_sample, stream_id,
-				use_default_chmap, channel_map);
-}
-
-/*
- * q6asm_media_format_block_pcm_format_support_v3- sends pcm decoder
- *						    configuration parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @stream_id: stream id of stream to be associated with this session
- * @use_default_chmap: true if default channel map  to be used
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- */
-int q6asm_media_format_block_pcm_format_support_v3(struct audio_client *ac,
-						   uint32_t rate,
-						   uint32_t channels,
-						   uint16_t bits_per_sample,
-						   int stream_id,
-						   bool use_default_chmap,
-						   char *channel_map,
-						   uint16_t sample_word_size)
-{
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-			__func__);
-		return -EINVAL;
-	}
-	return __q6asm_media_format_block_pcm_v3(ac, rate,
-				channels, bits_per_sample, stream_id,
-				use_default_chmap, channel_map,
-				sample_word_size);
-
-}
-EXPORT_SYMBOL(q6asm_media_format_block_pcm_format_support_v3);
-
-/*
- * q6asm_media_format_block_pcm_format_support_v4- sends pcm decoder
- *						    configuration parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @stream_id: stream id of stream to be associated with this session
- * @use_default_chmap: true if default channel map  to be used
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- * @endianness: endianness of the pcm data
- * @mode: Mode to provide additional info about the pcm input data
- */
-int q6asm_media_format_block_pcm_format_support_v4(struct audio_client *ac,
-						   uint32_t rate,
-						   uint32_t channels,
-						   uint16_t bits_per_sample,
-						   int stream_id,
-						   bool use_default_chmap,
-						   char *channel_map,
-						   uint16_t sample_word_size,
-						   uint16_t endianness,
-						   uint16_t mode)
-{
-	if (!use_default_chmap && (channel_map == NULL)) {
-		pr_err("%s: No valid chan map and can't use default\n",
-			__func__);
-		return -EINVAL;
-	}
-	return __q6asm_media_format_block_pcm_v4(ac, rate,
-				channels, bits_per_sample, stream_id,
-				use_default_chmap, channel_map,
-				sample_word_size, endianness,
-				mode);
-
-}
-EXPORT_SYMBOL(q6asm_media_format_block_pcm_format_support_v4);
-
-
-static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				bool use_default_chmap, char *channel_map,
-				uint16_t bits_per_sample)
-{
-	struct asm_multi_channel_pcm_fmt_blk_v2 fmt;
-	u8 *channel_mapping;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
-		channels);
-
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.num_channels = channels;
-	fmt.bits_per_sample = bits_per_sample;
-	fmt.sample_rate = rate;
-	fmt.is_signed = 1;
-
-	channel_mapping = fmt.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-				__func__, channels);
-			return -EINVAL;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
-						      uint32_t rate,
-						      uint32_t channels,
-						      bool use_default_chmap,
-						      char *channel_map,
-						      uint16_t bits_per_sample,
-						      uint16_t sample_word_size)
-{
-	struct asm_multi_channel_pcm_fmt_blk_param_v3 fmt;
-	u8 *channel_mapping;
-	int rc;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.param.num_channels = channels;
-	fmt.param.bits_per_sample = bits_per_sample;
-	fmt.param.sample_rate = rate;
-	fmt.param.is_signed = 1;
-	fmt.param.sample_word_size = sample_word_size;
-	channel_mapping = fmt.param.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-		       __func__, adsp_err_get_err_str(
-		       atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_media_format_block_multi_ch_pcm_v4(struct audio_client *ac,
-						      uint32_t rate,
-						      uint32_t channels,
-						      bool use_default_chmap,
-						      char *channel_map,
-						      uint16_t bits_per_sample,
-						      uint16_t sample_word_size,
-						      uint16_t endianness,
-						      uint16_t mode)
-{
-	struct asm_multi_channel_pcm_fmt_blk_param_v4 fmt;
-	u8 *channel_mapping;
-	int rc;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
-		 ac->session, rate, channels,
-		 bits_per_sample, sample_word_size);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.param.num_channels = channels;
-	fmt.param.bits_per_sample = bits_per_sample;
-	fmt.param.sample_rate = rate;
-	fmt.param.is_signed = 1;
-	fmt.param.sample_word_size = sample_word_size;
-	fmt.param.endianness = endianness;
-	fmt.param.mode = mode;
-	channel_mapping = fmt.param.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-			       __func__, channels);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-			 PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-		       __func__, adsp_err_get_err_str(
-		       atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
-		uint32_t rate, uint32_t channels,
-		bool use_default_chmap, char *channel_map)
-{
-	return __q6asm_media_format_block_multi_ch_pcm(ac, rate,
-			channels, use_default_chmap, channel_map, 16);
-}
-
-int q6asm_media_format_block_multi_ch_pcm_v2(
-		struct audio_client *ac,
-		uint32_t rate, uint32_t channels,
-		bool use_default_chmap, char *channel_map,
-		uint16_t bits_per_sample)
-{
-	return __q6asm_media_format_block_multi_ch_pcm(ac, rate,
-			channels, use_default_chmap, channel_map,
-			bits_per_sample);
-}
-
-/*
- * q6asm_media_format_block_multi_ch_pcm_v3 - sends pcm decoder configuration
- *                                            parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @use_default_chmap: true if default channel map  to be used
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- */
-int q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t bits_per_sample,
-					     uint16_t sample_word_size)
-{
-	return __q6asm_media_format_block_multi_ch_pcm_v3(ac, rate, channels,
-							  use_default_chmap,
-							  channel_map,
-							  bits_per_sample,
-							  sample_word_size);
-}
-EXPORT_SYMBOL(q6asm_media_format_block_multi_ch_pcm_v3);
-
-/*
- * q6asm_media_format_block_multi_ch_pcm_v4 - sends pcm decoder configuration
- *                                            parameters
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @bits_per_sample: bit width of encoder session
- * @use_default_chmap: true if default channel map  to be used
- * @channel_map: input channel map
- * @sample_word_size: Size in bits of the word that holds a sample of a channel
- * @endianness: endianness of the pcm data
- * @mode: Mode to provide additional info about the pcm input data
- */
-int q6asm_media_format_block_multi_ch_pcm_v4(struct audio_client *ac,
-					     uint32_t rate, uint32_t channels,
-					     bool use_default_chmap,
-					     char *channel_map,
-					     uint16_t bits_per_sample,
-					     uint16_t sample_word_size,
-					     uint16_t endianness,
-					     uint16_t mode)
-{
-	return __q6asm_media_format_block_multi_ch_pcm_v4(ac, rate, channels,
-							  use_default_chmap,
-							  channel_map,
-							  bits_per_sample,
-							  sample_word_size,
-							  endianness,
-							  mode);
-}
-EXPORT_SYMBOL(q6asm_media_format_block_multi_ch_pcm_v4);
-
-/*
- * q6asm_media_format_block_gen_compr - set up generic compress format params
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- * @use_default_chmap: true if default channel map to be used
- * @channel_map: input channel map
- * @bits_per_sample: bit width of gen compress stream
- */
-int q6asm_media_format_block_gen_compr(struct audio_client *ac,
-				uint32_t rate, uint32_t channels,
-				bool use_default_chmap, char *channel_map,
-				uint16_t bits_per_sample)
-{
-	struct asm_generic_compressed_fmt_blk_t fmt;
-	u8 *channel_mapping;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]\n",
-		 __func__, ac->session, rate,
-		 channels, bits_per_sample);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.num_channels = channels;
-	fmt.bits_per_sample = bits_per_sample;
-	fmt.sampling_rate = rate;
-
-	channel_mapping = fmt.channel_mapping;
-
-	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);
-
-	if (use_default_chmap) {
-		if (q6asm_map_channels(channel_mapping, channels, false)) {
-			pr_err("%s: map channels failed %d\n",
-				__func__, channels);
-			return -EINVAL;
-		}
-	} else {
-		memcpy(channel_mapping, channel_map,
-		       PCM_FORMAT_MAX_NUM_CHANNEL);
-	}
-
-	atomic_set(&ac->cmd_state, -1);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_media_format_block_gen_compr);
-
-
-/*
- * q6asm_media_format_block_iec - set up IEC61937 (compressed) or IEC60958
- *                                (pcm) format params. Both audio standards
- *                                use the same format and are used for
- *                                HDMI or SPDIF.
- *
- * @ac: Client session handle
- * @rate: sample rate
- * @channels: number of channels
- */
-int q6asm_media_format_block_iec(struct audio_client *ac,
-				uint32_t rate, uint32_t channels)
-{
-	struct asm_iec_compressed_fmt_blk_t fmt;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]\n",
-		 __func__, ac->session, rate,
-		 channels);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_IEC_60958_MEDIA_FMT;
-	fmt.num_channels = channels;
-	fmt.sampling_rate = rate;
-
-	atomic_set(&ac->cmd_state, -1);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for format update\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_media_format_block_iec);
-
-static int __q6asm_media_format_block_multi_aac(struct audio_client *ac,
-				struct asm_aac_cfg *cfg, int stream_id)
-{
-	struct asm_aac_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session,
-		cfg->sample_rate, cfg->ch_cfg);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&fmt.hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-		  __func__, fmt.hdr.token, stream_id, ac->session);
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmt_blk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmt_blk);
-	fmt.aac_fmt_flag = cfg->format;
-	fmt.audio_objype = cfg->aot;
-	/* If zero, PCE is assumed to be available in bitstream*/
-	fmt.total_size_of_PCE_bits = 0;
-	fmt.channel_config = cfg->ch_cfg;
-	fmt.sample_rate = cfg->sample_rate;
-
-	pr_debug("%s: format=0x%x cfg_size=%d aac-cfg=0x%x aot=%d ch=%d sr=%d\n",
-			__func__, fmt.aac_fmt_flag, fmt.fmt_blk.fmt_blk_size,
-			fmt.aac_fmt_flag,
-			fmt.audio_objype,
-			fmt.channel_config,
-			fmt.sample_rate);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_multi_aac(struct audio_client *ac,
-				struct asm_aac_cfg *cfg)
-{
-	return __q6asm_media_format_block_multi_aac(ac, cfg, ac->stream_id);
-}
-
-int q6asm_media_format_block_aac(struct audio_client *ac,
-			struct asm_aac_cfg *cfg)
-{
-	return __q6asm_media_format_block_multi_aac(ac, cfg, ac->stream_id);
-}
-
-int q6asm_stream_media_format_block_aac(struct audio_client *ac,
-			struct asm_aac_cfg *cfg, int stream_id)
-{
-	return __q6asm_media_format_block_multi_aac(ac, cfg, stream_id);
-}
-
-int q6asm_media_format_block_wma(struct audio_client *ac,
-				void *cfg, int stream_id)
-{
-	struct asm_wmastdv9_fmt_blk_v2 fmt;
-	struct asm_wma_cfg *wma_cfg = (struct asm_wma_cfg *)cfg;
-	int rc = 0;
-
-	pr_debug("session[%d]format_tag[0x%4x] rate[%d] ch[0x%4x] bps[%d], balign[0x%4x], bit_sample[0x%4x], ch_msk[%d], enc_opt[0x%4x]\n",
-		ac->session, wma_cfg->format_tag, wma_cfg->sample_rate,
-		wma_cfg->ch_cfg, wma_cfg->avg_bytes_per_sec,
-		wma_cfg->block_align, wma_cfg->valid_bits_per_sample,
-		wma_cfg->ch_mask, wma_cfg->encode_opt);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmtblk);
-	fmt.fmtag = wma_cfg->format_tag;
-	fmt.num_channels = wma_cfg->ch_cfg;
-	fmt.sample_rate = wma_cfg->sample_rate;
-	fmt.avg_bytes_per_sec = wma_cfg->avg_bytes_per_sec;
-	fmt.blk_align = wma_cfg->block_align;
-	fmt.bits_per_sample =
-			wma_cfg->valid_bits_per_sample;
-	fmt.channel_mask = wma_cfg->ch_mask;
-	fmt.enc_options = wma_cfg->encode_opt;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_wmapro(struct audio_client *ac,
-				void *cfg, int stream_id)
-{
-	struct asm_wmaprov10_fmt_blk_v2 fmt;
-	struct asm_wmapro_cfg *wmapro_cfg = (struct asm_wmapro_cfg *)cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]format_tag[0x%4x] rate[%d] ch[0x%4x] bps[%d], balign[0x%4x], bit_sample[0x%4x], ch_msk[%d], enc_opt[0x%4x], adv_enc_opt[0x%4x], adv_enc_opt2[0x%8x]\n",
-		__func__,
-		ac->session, wmapro_cfg->format_tag, wmapro_cfg->sample_rate,
-		wmapro_cfg->ch_cfg,  wmapro_cfg->avg_bytes_per_sec,
-		wmapro_cfg->block_align, wmapro_cfg->valid_bits_per_sample,
-		wmapro_cfg->ch_mask, wmapro_cfg->encode_opt,
-		wmapro_cfg->adv_encode_opt, wmapro_cfg->adv_encode_opt2);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-						sizeof(fmt.fmtblk);
-
-	fmt.fmtag = wmapro_cfg->format_tag;
-	fmt.num_channels = wmapro_cfg->ch_cfg;
-	fmt.sample_rate = wmapro_cfg->sample_rate;
-	fmt.avg_bytes_per_sec =
-				wmapro_cfg->avg_bytes_per_sec;
-	fmt.blk_align = wmapro_cfg->block_align;
-	fmt.bits_per_sample = wmapro_cfg->valid_bits_per_sample;
-	fmt.channel_mask = wmapro_cfg->ch_mask;
-	fmt.enc_options = wmapro_cfg->encode_opt;
-	fmt.usAdvancedEncodeOpt = wmapro_cfg->adv_encode_opt;
-	fmt.advanced_enc_options2 = wmapro_cfg->adv_encode_opt2;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
-				struct asm_amrwbplus_cfg *cfg)
-{
-	struct asm_amrwbplus_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s: session[%d]band-mode[%d]frame-fmt[%d]ch[%d]\n",
-		__func__,
-		ac->session,
-		cfg->amr_band_mode,
-		cfg->amr_frame_fmt,
-		cfg->num_channels);
-
-	q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmtblk);
-	fmt.amr_frame_fmt = cfg->amr_frame_fmt;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Comamnd media format update failed.. %d\n",
-			__func__, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_stream_media_format_block_flac(struct audio_client *ac,
-				struct asm_flac_cfg *cfg, int stream_id)
-{
-	struct asm_flac_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s :session[%d] rate[%d] ch[%d] size[%d] stream_id[%d]\n",
-		__func__, ac->session, cfg->sample_rate, cfg->ch_cfg,
-		cfg->sample_size, stream_id);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-						sizeof(fmt.fmtblk);
-
-	fmt.is_stream_info_present = cfg->stream_info_present;
-	fmt.num_channels = cfg->ch_cfg;
-	fmt.min_blk_size = cfg->min_blk_size;
-	fmt.max_blk_size = cfg->max_blk_size;
-	fmt.sample_rate = cfg->sample_rate;
-	fmt.min_frame_size = cfg->min_frame_size;
-	fmt.max_frame_size = cfg->max_frame_size;
-	fmt.sample_size = cfg->sample_size;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s :Comamnd media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_alac(struct audio_client *ac,
-				struct asm_alac_cfg *cfg, int stream_id)
-{
-	struct asm_alac_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s :session[%d]rate[%d]ch[%d]\n", __func__,
-		ac->session, cfg->sample_rate, cfg->num_channels);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-						sizeof(fmt.fmtblk);
-
-	fmt.frame_length = cfg->frame_length;
-	fmt.compatible_version = cfg->compatible_version;
-	fmt.bit_depth = cfg->bit_depth;
-	fmt.pb = cfg->pb;
-	fmt.mb = cfg->mb;
-	fmt.kb = cfg->kb;
-	fmt.num_channels = cfg->num_channels;
-	fmt.max_run = cfg->max_run;
-	fmt.max_frame_bytes = cfg->max_frame_bytes;
-	fmt.avg_bit_rate = cfg->avg_bit_rate;
-	fmt.sample_rate = cfg->sample_rate;
-	fmt.channel_layout_tag = cfg->channel_layout_tag;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s :Comamnd media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-/*
- * q6asm_media_format_block_g711 - sends g711 decoder configuration
- *                                            parameters
- * @ac: Client session handle
- * @cfg: Audio stream manager configuration parameters
- * @stream_id: Stream id
- */
-int q6asm_media_format_block_g711(struct audio_client *ac,
-				struct asm_g711_dec_cfg *cfg, int stream_id)
-{
-	struct asm_g711_dec_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	if (!ac) {
-		pr_err("%s: audio client is null\n", __func__);
-		return -EINVAL;
-	}
-	if (!cfg) {
-		pr_err("%s: Invalid ASM config\n", __func__);
-		return -EINVAL;
-	}
-
-	if (stream_id <= 0) {
-		pr_err("%s: Invalid stream id\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s :session[%d]rate[%d]\n", __func__,
-		ac->session, cfg->sample_rate);
-
-	memset(&fmt, 0, sizeof(struct asm_g711_dec_fmt_blk_v2));
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-						sizeof(fmt.fmtblk);
-
-	fmt.sample_rate = cfg->sample_rate;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s :Command media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_media_format_block_g711);
-
-int q6asm_stream_media_format_block_vorbis(struct audio_client *ac,
-				struct asm_vorbis_cfg *cfg, int stream_id)
-{
-	struct asm_vorbis_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s :session[%d] bit_stream_fmt[%d] stream_id[%d]\n",
-		__func__, ac->session, cfg->bit_stream_fmt, stream_id);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-						sizeof(fmt.fmtblk);
-
-	fmt.bit_stream_fmt = cfg->bit_stream_fmt;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s :Comamnd media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_media_format_block_ape(struct audio_client *ac,
-				struct asm_ape_cfg *cfg, int stream_id)
-{
-	struct asm_ape_fmt_blk_v2 fmt;
-	int rc = 0;
-
-	pr_debug("%s :session[%d]rate[%d]ch[%d]\n", __func__,
-			ac->session, cfg->sample_rate, cfg->num_channels);
-
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-		sizeof(fmt.fmtblk);
-
-	fmt.compatible_version = cfg->compatible_version;
-	fmt.compression_level = cfg->compression_level;
-	fmt.format_flags = cfg->format_flags;
-	fmt.blocks_per_frame = cfg->blocks_per_frame;
-	fmt.final_frame_blocks = cfg->final_frame_blocks;
-	fmt.total_frames = cfg->total_frames;
-	fmt.bits_per_sample = cfg->bits_per_sample;
-	fmt.num_channels = cfg->num_channels;
-	fmt.sample_rate = cfg->sample_rate;
-	fmt.seek_table_present = cfg->seek_table_present;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s :Comamnd media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-/*
- * q6asm_media_format_block_dsd- Sends DSD Decoder
- * configuration parameters
- *
- * @ac: Client session handle
- * @cfg: DSD Media Format Configuration.
- * @stream_id: stream id of stream to be associated with this session
- *
- * Return 0 on success or negative error code on failure
- */
-int q6asm_media_format_block_dsd(struct audio_client *ac,
-				struct asm_dsd_cfg *cfg, int stream_id)
-{
-	struct asm_dsd_fmt_blk_v2 fmt;
-	int rc;
-
-	pr_debug("%s: session[%d] data_rate[%d] ch[%d]\n", __func__,
-		 ac->session, cfg->dsd_data_rate, cfg->num_channels);
-
-	memset(&fmt, 0, sizeof(fmt));
-	q6asm_stream_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE, stream_id);
-
-	fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	fmt.fmtblk.fmt_blk_size = sizeof(fmt) - sizeof(fmt.hdr) -
-					sizeof(fmt.fmtblk);
-
-	fmt.num_version = cfg->num_version;
-	fmt.is_bitwise_big_endian = cfg->is_bitwise_big_endian;
-	fmt.dsd_channel_block_size = cfg->dsd_channel_block_size;
-	fmt.num_channels = cfg->num_channels;
-	fmt.dsd_data_rate = cfg->dsd_data_rate;
-	atomic_set(&ac->cmd_state, -1);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
-	if (rc < 0) {
-		pr_err("%s: Command DSD media format update failed, err: %d\n",
-			__func__, rc);
-		goto done;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for DSD FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto done;
-	}
-	return 0;
-done:
-	return rc;
-}
-EXPORT_SYMBOL(q6asm_media_format_block_dsd);
-
-int q6asm_stream_media_format_block_aptx_dec(struct audio_client *ac,
-						uint32_t srate, int stream_id)
-{
-	struct asm_aptx_dec_fmt_blk_v2 aptx_fmt;
-	int rc = 0;
-
-	if (!ac->session) {
-		pr_err("%s: ac session invalid\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	pr_debug("%s :session[%d] rate[%d] stream_id[%d]\n",
-		__func__, ac->session, srate, stream_id);
-
-	q6asm_stream_add_hdr(ac, &aptx_fmt.hdr, sizeof(aptx_fmt), TRUE,
-				stream_id);
-	atomic_set(&ac->cmd_state, -1);
-
-	aptx_fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2;
-	aptx_fmt.fmtblk.fmt_blk_size = sizeof(aptx_fmt) - sizeof(aptx_fmt.hdr) -
-						sizeof(aptx_fmt.fmtblk);
-
-	aptx_fmt.sample_rate = srate;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &aptx_fmt);
-	if (rc < 0) {
-		pr_err("%s :Comamnd media format update failed %d\n",
-				__func__, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_ds1_set_endp_params(struct audio_client *ac, int param_id,
-				int param_value, int stream_id)
-{
-	struct asm_dec_ddp_endp_param_v2 ddp_cfg;
-	int rc = 0;
-
-	pr_debug("%s: session[%d] stream[%d],param_id[%d]param_value[%d]",
-		 __func__, ac->session, stream_id, param_id, param_value);
-
-	q6asm_stream_add_hdr(ac, &ddp_cfg.hdr, sizeof(ddp_cfg), TRUE,
-			     stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&ddp_cfg.hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-	ddp_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	ddp_cfg.encdec.param_id = param_id;
-	ddp_cfg.encdec.param_size = sizeof(struct asm_dec_ddp_endp_param_v2) -
-				(sizeof(struct apr_hdr) +
-				sizeof(struct asm_stream_cmd_set_encdec_param));
-	ddp_cfg.endp_param_value = param_value;
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &ddp_cfg);
-	if (rc < 0) {
-		pr_err("%s: Command opcode[0x%x] failed %d\n",
-			__func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-		(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout opcode[0x%x]\n", __func__,
-			ddp_cfg.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_ds1_set_endp_params(struct audio_client *ac,
-			      int param_id, int param_value)
-{
-	return __q6asm_ds1_set_endp_params(ac, param_id, param_value,
-					   ac->stream_id);
-}
-
-int q6asm_ds1_set_stream_endp_params(struct audio_client *ac,
-				     int param_id, int param_value,
-				     int stream_id)
-{
-	return __q6asm_ds1_set_endp_params(ac, param_id, param_value,
-					   stream_id);
-}
-
-int q6asm_memory_map(struct audio_client *ac, phys_addr_t buf_add, int dir,
-				uint32_t bufsz, uint32_t bufcnt)
-{
-	struct avs_cmd_shared_mem_map_regions *mmap_regions = NULL;
-	struct avs_shared_map_region_payload  *mregions = NULL;
-	struct audio_port_data *port = NULL;
-	void	*mmap_region_cmd = NULL;
-	void	*payload = NULL;
-	struct asm_buffer_node *buffer_node = NULL;
-	int	rc = 0;
-	int	cmd_size = 0;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->mmap_apr == NULL) {
-		pr_err("%s: mmap APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: Session[%d]\n", __func__, ac->session);
-
-	buffer_node = kmalloc(sizeof(struct asm_buffer_node), GFP_KERNEL);
-	if (!buffer_node)
-		return -ENOMEM;
-
-	cmd_size = sizeof(struct avs_cmd_shared_mem_map_regions)
-			+ sizeof(struct avs_shared_map_region_payload) * bufcnt;
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (mmap_region_cmd == NULL) {
-		rc = -EINVAL;
-		kfree(buffer_node);
-		return rc;
-	}
-	mmap_regions = (struct avs_cmd_shared_mem_map_regions *)
-							mmap_region_cmd;
-	q6asm_add_mmaphdr(ac, &mmap_regions->hdr, cmd_size, dir);
-	atomic_set(&ac->mem_state, -1);
-	mmap_regions->hdr.opcode = ASM_CMD_SHARED_MEM_MAP_REGIONS;
-	mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	mmap_regions->num_regions = bufcnt & 0x00ff;
-	mmap_regions->property_flag = 0x00;
-	payload = ((u8 *) mmap_region_cmd +
-		sizeof(struct avs_cmd_shared_mem_map_regions));
-	mregions = (struct avs_shared_map_region_payload *)payload;
-
-	ac->port[dir].tmp_hdl = 0;
-	port = &ac->port[dir];
-	pr_debug("%s: buf_add 0x%pK, bufsz: %d\n", __func__,
-		&buf_add, bufsz);
-	mregions->shm_addr_lsw = lower_32_bits(buf_add);
-	mregions->shm_addr_msw = msm_audio_populate_upper_32_bits(buf_add);
-	mregions->mem_size_bytes = bufsz;
-	++mregions;
-
-	rc = apr_send_pkt(ac->mmap_apr, (uint32_t *) mmap_region_cmd);
-	if (rc < 0) {
-		pr_err("%s: mmap op[0x%x]rc[%d]\n", __func__,
-					mmap_regions->hdr.opcode, rc);
-		rc = -EINVAL;
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->mem_wait,
-			(atomic_read(&ac->mem_state) >= 0 &&
-			 ac->port[dir].tmp_hdl), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for memory_map\n", __func__);
-		rc = -ETIMEDOUT;
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->mem_state) > 0) {
-		pr_err("%s: DSP returned error[%s] for memory_map\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->mem_state)));
-		rc = adsp_err_get_lnx_err_code(
-			atomic_read(&ac->mem_state));
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-	buffer_node->buf_phys_addr = buf_add;
-	buffer_node->mmap_hdl = ac->port[dir].tmp_hdl;
-	list_add_tail(&buffer_node->list, &ac->port[dir].mem_map_handle);
-	ac->port[dir].tmp_hdl = 0;
-	rc = 0;
-
-fail_cmd:
-	kfree(mmap_region_cmd);
-	return rc;
-}
-
-int q6asm_memory_unmap(struct audio_client *ac, phys_addr_t buf_add, int dir)
-{
-	struct avs_cmd_shared_mem_unmap_regions mem_unmap;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-
-	int rc = 0;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (this_mmap.apr == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: Session[%d]\n", __func__, ac->session);
-
-	q6asm_add_mmaphdr(ac, &mem_unmap.hdr,
-			sizeof(struct avs_cmd_shared_mem_unmap_regions),
-			dir);
-	atomic_set(&ac->mem_state, -1);
-	mem_unmap.hdr.opcode = ASM_CMD_SHARED_MEM_UNMAP_REGIONS;
-	mem_unmap.mem_map_handle = 0;
-	list_for_each_safe(ptr, next, &ac->port[dir].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-						list);
-		if (buf_node->buf_phys_addr == buf_add) {
-			pr_debug("%s: Found the element\n", __func__);
-			mem_unmap.mem_map_handle = buf_node->mmap_hdl;
-			break;
-		}
-	}
-	pr_debug("%s: mem_unmap-mem_map_handle: 0x%x\n",
-		__func__, mem_unmap.mem_map_handle);
-
-	if (mem_unmap.mem_map_handle == 0) {
-		pr_err("%s: Do not send null mem handle to DSP\n", __func__);
-		rc = 0;
-		goto fail_cmd;
-	}
-	rc = apr_send_pkt(ac->mmap_apr, (uint32_t *) &mem_unmap);
-	if (rc < 0) {
-		pr_err("%s: mem_unmap op[0x%x]rc[%d]\n", __func__,
-					mem_unmap.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->mem_wait,
-			(atomic_read(&ac->mem_state) >= 0), 5 * HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for memory_unmap of handle 0x%x\n",
-			__func__, mem_unmap.mem_map_handle);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	} else if (atomic_read(&ac->mem_state) > 0) {
-		pr_err("%s DSP returned error [%s] map handle 0x%x\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->mem_state)),
-			mem_unmap.mem_map_handle);
-		rc = adsp_err_get_lnx_err_code(
-			atomic_read(&ac->mem_state));
-		goto fail_cmd;
-	} else if (atomic_read(&ac->unmap_cb_success) == 0) {
-		pr_err("%s: Error in mem unmap callback of handle 0x%x\n",
-			__func__, mem_unmap.mem_map_handle);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = 0;
-fail_cmd:
-	list_for_each_safe(ptr, next, &ac->port[dir].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-						list);
-		if (buf_node->buf_phys_addr == buf_add) {
-			list_del(&buf_node->list);
-			kfree(buf_node);
-			break;
-		}
-	}
-	return rc;
-}
-
-
-static int q6asm_memory_map_regions(struct audio_client *ac, int dir,
-				uint32_t bufsz, uint32_t bufcnt,
-				bool is_contiguous)
-{
-	struct avs_cmd_shared_mem_map_regions *mmap_regions = NULL;
-	struct avs_shared_map_region_payload  *mregions = NULL;
-	struct audio_port_data *port = NULL;
-	struct audio_buffer *ab = NULL;
-	void	*mmap_region_cmd = NULL;
-	void	*payload = NULL;
-	struct asm_buffer_node *buffer_node = NULL;
-	int	rc = 0;
-	int    i = 0;
-	uint32_t cmd_size = 0;
-	uint32_t bufcnt_t;
-	uint32_t bufsz_t;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->mmap_apr == NULL) {
-		pr_err("%s: mmap APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: Session[%d]\n", __func__, ac->session);
-
-	bufcnt_t = (is_contiguous) ? 1 : bufcnt;
-	bufsz_t = (is_contiguous) ? (bufsz * bufcnt) : bufsz;
-
-	if (is_contiguous) {
-		/* The size to memory map should be multiple of 4K bytes */
-		bufsz_t = PAGE_ALIGN(bufsz_t);
-	}
-
-	if (bufcnt_t > (UINT_MAX
-			- sizeof(struct avs_cmd_shared_mem_map_regions))
-			/ sizeof(struct avs_shared_map_region_payload)) {
-		pr_err("%s: Unsigned Integer Overflow. bufcnt_t = %u\n",
-				__func__, bufcnt_t);
-		return -EINVAL;
-	}
-
-	cmd_size = sizeof(struct avs_cmd_shared_mem_map_regions)
-			+ (sizeof(struct avs_shared_map_region_payload)
-							* bufcnt_t);
-
-
-	if (bufcnt > (UINT_MAX / sizeof(struct asm_buffer_node))) {
-		pr_err("%s: Unsigned Integer Overflow. bufcnt = %u\n",
-				__func__, bufcnt);
-		return -EINVAL;
-	}
-
-	buffer_node = kzalloc(sizeof(struct asm_buffer_node) * bufcnt,
-				GFP_KERNEL);
-	if (!buffer_node)
-		return -ENOMEM;
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (mmap_region_cmd == NULL) {
-		rc = -EINVAL;
-		kfree(buffer_node);
-		return rc;
-	}
-	mmap_regions = (struct avs_cmd_shared_mem_map_regions *)
-							mmap_region_cmd;
-	q6asm_add_mmaphdr(ac, &mmap_regions->hdr, cmd_size, dir);
-	atomic_set(&ac->mem_state, -1);
-	pr_debug("%s: mmap_region=0x%pK token=0x%x\n", __func__,
-		mmap_regions, ((ac->session << 8) | dir));
-
-	mmap_regions->hdr.opcode = ASM_CMD_SHARED_MEM_MAP_REGIONS;
-	mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	mmap_regions->num_regions = bufcnt_t; /*bufcnt & 0x00ff; */
-	mmap_regions->property_flag = 0x00;
-	pr_debug("%s: map_regions->nregions = %d\n", __func__,
-		mmap_regions->num_regions);
-	payload = ((u8 *) mmap_region_cmd +
-		sizeof(struct avs_cmd_shared_mem_map_regions));
-	mregions = (struct avs_shared_map_region_payload *)payload;
-
-	ac->port[dir].tmp_hdl = 0;
-	port = &ac->port[dir];
-	for (i = 0; i < bufcnt_t; i++) {
-		ab = &port->buf[i];
-		mregions->shm_addr_lsw = lower_32_bits(ab->phys);
-		mregions->shm_addr_msw =
-				msm_audio_populate_upper_32_bits(ab->phys);
-		mregions->mem_size_bytes = bufsz_t;
-		++mregions;
-	}
-
-	rc = apr_send_pkt(ac->mmap_apr, (uint32_t *) mmap_region_cmd);
-	if (rc < 0) {
-		pr_err("%s: mmap_regions op[0x%x]rc[%d]\n", __func__,
-					mmap_regions->hdr.opcode, rc);
-		rc = -EINVAL;
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->mem_wait,
-			(atomic_read(&ac->mem_state) >= 0)
-			 , 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for memory_map\n", __func__);
-		rc = -ETIMEDOUT;
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->mem_state) > 0) {
-		pr_err("%s DSP returned error for memory_map [%s]\n",
-			__func__, adsp_err_get_err_str(
-			atomic_read(&ac->mem_state)));
-		rc = adsp_err_get_lnx_err_code(
-			atomic_read(&ac->mem_state));
-		kfree(buffer_node);
-		goto fail_cmd;
-	}
-	mutex_lock(&ac->cmd_lock);
-
-	for (i = 0; i < bufcnt; i++) {
-		ab = &port->buf[i];
-		buffer_node[i].buf_phys_addr = ab->phys;
-		buffer_node[i].mmap_hdl = ac->port[dir].tmp_hdl;
-		list_add_tail(&buffer_node[i].list,
-			&ac->port[dir].mem_map_handle);
-		pr_debug("%s: i=%d, bufadd[i] = 0x%pK, maphdl[i] = 0x%x\n",
-			__func__, i, &buffer_node[i].buf_phys_addr,
-			buffer_node[i].mmap_hdl);
-	}
-	ac->port[dir].tmp_hdl = 0;
-	mutex_unlock(&ac->cmd_lock);
-	rc = 0;
-fail_cmd:
-	kfree(mmap_region_cmd);
-	return rc;
-}
-
-static int q6asm_memory_unmap_regions(struct audio_client *ac, int dir)
-{
-	struct avs_cmd_shared_mem_unmap_regions mem_unmap;
-	struct audio_port_data *port = NULL;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	phys_addr_t buf_add;
-	int	rc = 0;
-	int	cmd_size = 0;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->mmap_apr == NULL) {
-		pr_err("%s: mmap APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: Session[%d]\n", __func__, ac->session);
-
-	cmd_size = sizeof(struct avs_cmd_shared_mem_unmap_regions);
-	q6asm_add_mmaphdr(ac, &mem_unmap.hdr, cmd_size, dir);
-	atomic_set(&ac->mem_state, -1);
-	port = &ac->port[dir];
-	buf_add = port->buf->phys;
-	mem_unmap.hdr.opcode = ASM_CMD_SHARED_MEM_UNMAP_REGIONS;
-	mem_unmap.mem_map_handle = 0;
-	list_for_each_safe(ptr, next, &ac->port[dir].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-						list);
-		if (buf_node->buf_phys_addr == buf_add) {
-			pr_debug("%s: Found the element\n", __func__);
-			mem_unmap.mem_map_handle = buf_node->mmap_hdl;
-			break;
-		}
-	}
-
-	pr_debug("%s: mem_unmap-mem_map_handle: 0x%x\n",
-			__func__, mem_unmap.mem_map_handle);
-
-	if (mem_unmap.mem_map_handle == 0) {
-		pr_err("%s: Do not send null mem handle to DSP\n", __func__);
-		rc = 0;
-		goto fail_cmd;
-	}
-	rc = apr_send_pkt(ac->mmap_apr, (uint32_t *) &mem_unmap);
-	if (rc < 0) {
-		pr_err("mmap_regions op[0x%x]rc[%d]\n",
-				mem_unmap.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->mem_wait,
-			(atomic_read(&ac->mem_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for memory_unmap of handle 0x%x\n",
-			__func__, mem_unmap.mem_map_handle);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	} else if (atomic_read(&ac->mem_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->mem_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->mem_state));
-		goto fail_cmd;
-	} else if (atomic_read(&ac->unmap_cb_success) == 0) {
-		pr_err("%s: Error in mem unmap callback of handle 0x%x\n",
-			__func__, mem_unmap.mem_map_handle);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = 0;
-
-fail_cmd:
-	list_for_each_safe(ptr, next, &ac->port[dir].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-						list);
-		if (buf_node->buf_phys_addr == buf_add) {
-			list_del(&buf_node->list);
-			kfree(buf_node);
-			break;
-		}
-	}
-	return rc;
-}
-
-int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain)
-{
-	struct asm_volume_ctrl_multichannel_gain multi_ch_gain;
-	int sz = 0;
-	int rc  = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	memset(&multi_ch_gain, 0, sizeof(multi_ch_gain));
-	sz = sizeof(struct asm_volume_ctrl_multichannel_gain);
-	q6asm_add_hdr_async(ac, &multi_ch_gain.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	multi_ch_gain.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	multi_ch_gain.param.data_payload_addr_lsw = 0;
-	multi_ch_gain.param.data_payload_addr_msw = 0;
-	multi_ch_gain.param.mem_map_handle = 0;
-	multi_ch_gain.param.data_payload_size = sizeof(multi_ch_gain) -
-		sizeof(multi_ch_gain.hdr) - sizeof(multi_ch_gain.param);
-	multi_ch_gain.data.module_id = ASM_MODULE_ID_VOL_CTRL;
-	multi_ch_gain.data.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
-	multi_ch_gain.data.param_size = multi_ch_gain.param.data_payload_size -
-		sizeof(multi_ch_gain.data);
-	multi_ch_gain.data.reserved = 0;
-	multi_ch_gain.gain_data[0].channeltype = PCM_CHANNEL_FL;
-	multi_ch_gain.gain_data[0].gain = left_gain << 15;
-	multi_ch_gain.gain_data[1].channeltype = PCM_CHANNEL_FR;
-	multi_ch_gain.gain_data[1].gain = right_gain << 15;
-	multi_ch_gain.num_channels = 2;
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &multi_ch_gain);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, multi_ch_gain.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-				multi_ch_gain.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] , set-params paramid[0x%x]\n",
-					__func__, adsp_err_get_err_str(
-					atomic_read(&ac->cmd_state_pp)),
-					multi_ch_gain.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-/*
- * q6asm_set_multich_gain: set multiple channel gains on an ASM session
- * @ac: audio client handle
- * @channels: number of channels caller intends to set gains
- * @gains: list of gains of audio channels
- * @ch_map: list of channel mapping. Only valid if use_default is false
- * @use_default: flag to indicate whether to use default mapping
- */
-int q6asm_set_multich_gain(struct audio_client *ac, uint32_t channels,
-			   uint32_t *gains, uint8_t *ch_map, bool use_default)
-{
-	struct asm_volume_ctrl_multichannel_gain multich_gain;
-	int sz = 0;
-	int rc  = 0;
-	int i;
-	u8 default_chmap[VOLUME_CONTROL_MAX_CHANNELS];
-
-	if (ac == NULL) {
-		pr_err("%s: ac is NULL\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-	if (ac->apr == NULL) {
-		dev_err(ac->dev, "%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-	if (gains == NULL) {
-		dev_err(ac->dev, "%s: gain_list is NULL\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-	if (channels > VOLUME_CONTROL_MAX_CHANNELS) {
-		dev_err(ac->dev, "%s: Invalid channel count %d\n",
-			__func__, channels);
-		rc = -EINVAL;
-		goto done;
-	}
-	if (!use_default && ch_map == NULL) {
-		dev_err(ac->dev, "%s: NULL channel map\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	memset(&multich_gain, 0, sizeof(multich_gain));
-	sz = sizeof(struct asm_volume_ctrl_multichannel_gain);
-	q6asm_add_hdr_async(ac, &multich_gain.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	multich_gain.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	multich_gain.param.data_payload_addr_lsw = 0;
-	multich_gain.param.data_payload_addr_msw = 0;
-	multich_gain.param.mem_map_handle = 0;
-	multich_gain.param.data_payload_size = sizeof(multich_gain) -
-		sizeof(multich_gain.hdr) - sizeof(multich_gain.param);
-	multich_gain.data.module_id = ASM_MODULE_ID_VOL_CTRL;
-	multich_gain.data.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
-	multich_gain.data.param_size = multich_gain.param.data_payload_size -
-		sizeof(multich_gain.data);
-	multich_gain.data.reserved = 0;
-
-	if (use_default) {
-		rc = q6asm_map_channels(default_chmap, channels, false);
-		if (rc < 0)
-			goto done;
-		for (i = 0; i < channels; i++) {
-			multich_gain.gain_data[i].channeltype =
-				default_chmap[i];
-			multich_gain.gain_data[i].gain = gains[i] << 15;
-		}
-	} else {
-		for (i = 0; i < channels; i++) {
-			multich_gain.gain_data[i].channeltype = ch_map[i];
-			multich_gain.gain_data[i].gain = gains[i] << 15;
-		}
-	}
-	multich_gain.num_channels = channels;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &multich_gain);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, multich_gain.data.param_id, rc);
-		goto done;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-				multich_gain.data.param_id);
-		rc = -EINVAL;
-		goto done;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%d] , set-params paramid[0x%x]\n",
-		       __func__, atomic_read(&ac->cmd_state_pp),
-		       multich_gain.data.param_id);
-		rc = -EINVAL;
-		goto done;
-	}
-	rc = 0;
-done:
-	return rc;
-}
-
-int q6asm_set_mute(struct audio_client *ac, int muteflag)
-{
-	struct asm_volume_ctrl_mute_config mute;
-	int sz = 0;
-	int rc  = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct asm_volume_ctrl_mute_config);
-	q6asm_add_hdr_async(ac, &mute.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	mute.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	mute.param.data_payload_addr_lsw = 0;
-	mute.param.data_payload_addr_msw = 0;
-	mute.param.mem_map_handle = 0;
-	mute.param.data_payload_size = sizeof(mute) -
-		sizeof(mute.hdr) - sizeof(mute.param);
-	mute.data.module_id = ASM_MODULE_ID_VOL_CTRL;
-	mute.data.param_id = ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG;
-	mute.data.param_size = mute.param.data_payload_size - sizeof(mute.data);
-	mute.data.reserved = 0;
-	mute.mute_flag = muteflag;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &mute);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, mute.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-				mute.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)),
-				mute.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_set_volume(struct audio_client *ac, int volume, int instance)
-{
-	struct asm_volume_ctrl_master_gain vol;
-	int sz = 0;
-	int rc  = 0;
-	int module_id;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	switch (instance) {
-	case SOFT_VOLUME_INSTANCE_2:
-		module_id = ASM_MODULE_ID_VOL_CTRL2;
-		break;
-	case SOFT_VOLUME_INSTANCE_1:
-	default:
-		module_id = ASM_MODULE_ID_VOL_CTRL;
-		break;
-	}
-
-	sz = sizeof(struct asm_volume_ctrl_master_gain);
-	q6asm_add_hdr_async(ac, &vol.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	vol.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	vol.param.data_payload_addr_lsw = 0;
-	vol.param.data_payload_addr_msw = 0;
-	vol.param.mem_map_handle = 0;
-	vol.param.data_payload_size = sizeof(vol) -
-		sizeof(vol.hdr) - sizeof(vol.param);
-	vol.data.module_id = module_id;
-	vol.data.param_id = ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
-	vol.data.param_size = vol.param.data_payload_size - sizeof(vol.data);
-	vol.data.reserved = 0;
-	vol.master_gain = volume;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &vol);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, vol.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-				vol.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)),
-				vol.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_set_volume(struct audio_client *ac, int volume)
-{
-	return __q6asm_set_volume(ac, volume, SOFT_VOLUME_INSTANCE_1);
-}
-
-int q6asm_set_volume_v2(struct audio_client *ac, int volume, int instance)
-{
-	return __q6asm_set_volume(ac, volume, instance);
-}
-
-int q6asm_set_aptx_dec_bt_addr(struct audio_client *ac,
-				struct aptx_dec_bt_addr_cfg *cfg)
-{
-	struct aptx_dec_bt_dev_addr paylod;
-	int sz = 0;
-	int rc = 0;
-
-	pr_debug("%s: BT addr nap %d, uap %d, lap %d\n", __func__, cfg->nap,
-			cfg->uap, cfg->lap);
-
-	if (ac == NULL) {
-		pr_err("%s: AC handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct aptx_dec_bt_dev_addr);
-	q6asm_add_hdr_async(ac, &paylod.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	paylod.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
-	paylod.encdec.param_id = APTX_DECODER_BT_ADDRESS;
-	paylod.encdec.param_size = sz - sizeof(paylod.hdr)
-					- sizeof(paylod.encdec);
-	paylod.bt_addr_cfg.lap = cfg->lap;
-	paylod.bt_addr_cfg.uap = cfg->uap;
-	paylod.bt_addr_cfg.nap = cfg->nap;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &paylod);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, paylod.encdec.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-			paylod.encdec.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)),
-				paylod.encdec.param_id);
-		rc = adsp_err_get_lnx_err_code(
-			atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	pr_debug("%s: set BT addr is success\n", __func__);
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_send_ion_fd(struct audio_client *ac, int fd)
-{
-	struct ion_client *client;
-	struct ion_handle *handle;
-	ion_phys_addr_t paddr;
-	size_t pa_len = 0;
-	void *vaddr;
-	int ret;
-	int sz = 0;
-	struct avs_rtic_shared_mem_addr shm;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = msm_audio_ion_import("audio_mem_client",
-				   &client,
-				   &handle,
-				   fd,
-				   NULL,
-				   0,
-				   &paddr,
-				   &pa_len,
-				   &vaddr);
-	if (ret) {
-		pr_err("%s: audio ION import failed, rc = %d\n",
-		       __func__, ret);
-		ret = -ENOMEM;
-		goto fail_cmd;
-	}
-	/* get payload length */
-	sz = sizeof(struct avs_rtic_shared_mem_addr);
-	q6asm_add_hdr_async(ac, &shm.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	shm.shm_buf_addr_lsw = lower_32_bits(paddr);
-	shm.shm_buf_addr_msw = msm_audio_populate_upper_32_bits(paddr);
-	shm.buf_size = pa_len;
-	shm.shm_buf_num_regions = 1;
-	shm.shm_buf_mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	shm.shm_buf_flag = 0x00;
-	shm.encdec.param_id = AVS_PARAM_ID_RTIC_SHARED_MEMORY_ADDR;
-	shm.encdec.param_size = sizeof(struct avs_rtic_shared_mem_addr) -
-						sizeof(struct apr_hdr) -
-			sizeof(struct asm_stream_cmd_set_encdec_param_v2);
-	shm.encdec.service_id = OUT;
-	shm.encdec.reserved = 0;
-	shm.map_region.shm_addr_lsw = shm.shm_buf_addr_lsw;
-	shm.map_region.shm_addr_msw = shm.shm_buf_addr_msw;
-	shm.map_region.mem_size_bytes = pa_len;
-	shm.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM_V2;
-	ret = apr_send_pkt(ac->apr, (uint32_t *) &shm);
-	if (ret < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-		       __func__, shm.encdec.param_id, ret);
-		ret = -EINVAL;
-		goto fail_cmd;
-	}
-
-	ret = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 1*HZ);
-	if (!ret) {
-		pr_err("%s: timeout, shm.encdec paramid[0x%x]\n", __func__,
-		       shm.encdec.param_id);
-		ret = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s] shm.encdec paramid[0x%x]\n",
-		       __func__,
-		       adsp_err_get_err_str(atomic_read(&ac->cmd_state)),
-		       shm.encdec.param_id);
-		ret = adsp_err_get_lnx_err_code(atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	ret = 0;
-fail_cmd:
-	return ret;
-}
-
-int q6asm_send_rtic_event_ack(struct audio_client *ac,
-			      void *param, uint32_t params_length)
-{
-	char *asm_params = NULL;
-	int sz, rc;
-	struct avs_param_rtic_event_ack ack;
-
-	if (!param || !ac) {
-		pr_err("%s: %s is NULL\n", __func__,
-			(!param) ? "param" : "ac");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	sz = sizeof(struct avs_param_rtic_event_ack) + params_length;
-	asm_params = kzalloc(sz, GFP_KERNEL);
-	if (!asm_params) {
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	q6asm_add_hdr_async(ac, &ack.hdr,
-			    sizeof(struct avs_param_rtic_event_ack) +
-			    params_length, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	ack.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM_V2;
-	ack.encdec.param_id = AVS_PARAM_ID_RTIC_EVENT_ACK;
-	ack.encdec.param_size = params_length;
-	ack.encdec.reserved = 0;
-	ack.encdec.service_id = OUT;
-	memcpy(asm_params, &ack, sizeof(struct avs_param_rtic_event_ack));
-	memcpy(asm_params + sizeof(struct avs_param_rtic_event_ack),
-		param, params_length);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
-	if (rc < 0) {
-		pr_err("%s: apr pkt failed for rtic event ack\n", __func__);
-		rc = -EINVAL;
-		goto fail_send_param;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 1 * HZ);
-	if (!rc) {
-		pr_err("%s: timeout for rtic event ack cmd\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_send_param;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s] for rtic event ack cmd\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_send_param;
-	}
-	rc = 0;
-
-fail_send_param:
-	kfree(asm_params);
-done:
-	return rc;
-}
-
-int q6asm_set_softpause(struct audio_client *ac,
-			struct asm_softpause_params *pause_param)
-{
-	struct asm_soft_pause_params softpause;
-	int sz = 0;
-	int rc  = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct asm_soft_pause_params);
-	q6asm_add_hdr_async(ac, &softpause.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	softpause.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-
-	softpause.param.data_payload_addr_lsw = 0;
-	softpause.param.data_payload_addr_msw = 0;
-	softpause.param.mem_map_handle = 0;
-	softpause.param.data_payload_size = sizeof(softpause) -
-		sizeof(softpause.hdr) - sizeof(softpause.param);
-	softpause.data.module_id = ASM_MODULE_ID_VOL_CTRL;
-	softpause.data.param_id = ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS;
-	softpause.data.param_size = softpause.param.data_payload_size -
-		sizeof(softpause.data);
-	softpause.data.reserved = 0;
-	softpause.enable_flag = pause_param->enable;
-	softpause.period = pause_param->period;
-	softpause.step = pause_param->step;
-	softpause.ramping_curve = pause_param->rampingcurve;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &softpause);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, softpause.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-						softpause.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)),
-				softpause.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_set_softvolume(struct audio_client *ac,
-				  struct asm_softvolume_params *softvol_param,
-				  int instance)
-{
-	struct asm_soft_step_volume_params softvol;
-	int sz = 0;
-	int rc  = 0;
-	int module_id;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	switch (instance) {
-	case SOFT_VOLUME_INSTANCE_2:
-		module_id = ASM_MODULE_ID_VOL_CTRL2;
-		break;
-	case SOFT_VOLUME_INSTANCE_1:
-	default:
-		module_id = ASM_MODULE_ID_VOL_CTRL;
-		break;
-	}
-
-	sz = sizeof(struct asm_soft_step_volume_params);
-	q6asm_add_hdr_async(ac, &softvol.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	softvol.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	softvol.param.data_payload_addr_lsw = 0;
-	softvol.param.data_payload_addr_msw = 0;
-	softvol.param.mem_map_handle = 0;
-	softvol.param.data_payload_size = sizeof(softvol) -
-		sizeof(softvol.hdr) - sizeof(softvol.param);
-	softvol.data.module_id = module_id;
-	softvol.data.param_id = ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
-	softvol.data.param_size = softvol.param.data_payload_size -
-		sizeof(softvol.data);
-	softvol.data.reserved = 0;
-	softvol.period = softvol_param->period;
-	softvol.step = softvol_param->step;
-	softvol.ramping_curve = softvol_param->rampingcurve;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &softvol);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, softvol.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-						softvol.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)),
-				softvol.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_set_softvolume(struct audio_client *ac,
-			 struct asm_softvolume_params *softvol_param)
-{
-	return __q6asm_set_softvolume(ac, softvol_param,
-				      SOFT_VOLUME_INSTANCE_1);
-}
-
-int q6asm_set_softvolume_v2(struct audio_client *ac,
-			    struct asm_softvolume_params *softvol_param,
-			    int instance)
-{
-	return __q6asm_set_softvolume(ac, softvol_param, instance);
-}
-
-int q6asm_equalizer(struct audio_client *ac, void *eq_p)
-{
-	struct asm_eq_params eq;
-	struct msm_audio_eq_stream_config *eq_params = NULL;
-	int i  = 0;
-	int sz = 0;
-	int rc  = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (eq_p == NULL) {
-		pr_err("%s: [%d]: Invalid Eq param\n", __func__, ac->session);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	sz = sizeof(struct asm_eq_params);
-	eq_params = (struct msm_audio_eq_stream_config *) eq_p;
-	q6asm_add_hdr(ac, &eq.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-
-	eq.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	eq.param.data_payload_addr_lsw = 0;
-	eq.param.data_payload_addr_msw = 0;
-	eq.param.mem_map_handle = 0;
-	eq.param.data_payload_size = sizeof(eq) -
-		sizeof(eq.hdr) - sizeof(eq.param);
-	eq.data.module_id = ASM_MODULE_ID_EQUALIZER;
-	eq.data.param_id = ASM_PARAM_ID_EQUALIZER_PARAMETERS;
-	eq.data.param_size = eq.param.data_payload_size - sizeof(eq.data);
-	eq.enable_flag = eq_params->enable;
-	eq.num_bands = eq_params->num_bands;
-
-	pr_debug("%s: enable:%d numbands:%d\n", __func__, eq_params->enable,
-			eq_params->num_bands);
-	for (i = 0; i < eq_params->num_bands; i++) {
-		eq.eq_bands[i].band_idx =
-			eq_params->eq_bands[i].band_idx;
-		eq.eq_bands[i].filterype =
-			eq_params->eq_bands[i].filter_type;
-		eq.eq_bands[i].center_freq_hz =
-			eq_params->eq_bands[i].center_freq_hz;
-		eq.eq_bands[i].filter_gain =
-			eq_params->eq_bands[i].filter_gain;
-		eq.eq_bands[i].q_factor =
-			eq_params->eq_bands[i].q_factor;
-		pr_debug("%s: filter_type:%u bandnum:%d\n", __func__,
-				eq_params->eq_bands[i].filter_type, i);
-		pr_debug("%s: center_freq_hz:%u bandnum:%d\n", __func__,
-				eq_params->eq_bands[i].center_freq_hz, i);
-		pr_debug("%s: filter_gain:%d bandnum:%d\n", __func__,
-				eq_params->eq_bands[i].filter_gain, i);
-		pr_debug("%s: q_factor:%d bandnum:%d\n", __func__,
-				eq_params->eq_bands[i].q_factor, i);
-	}
-	rc = apr_send_pkt(ac->apr, (uint32_t *)&eq);
-	if (rc < 0) {
-		pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
-				__func__, eq.data.param_id, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
-						eq.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)),
-				eq.data.param_id);
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-static int __q6asm_read(struct audio_client *ac, bool is_custom_len_reqd,
-			int len)
-{
-	struct asm_data_cmd_read_v2 read;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	struct audio_buffer        *ab;
-	int dsp_buf;
-	struct audio_port_data     *port;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[OUT];
-
-		q6asm_add_hdr(ac, &read.hdr, sizeof(read), FALSE);
-
-		mutex_lock(&port->lock);
-
-		dsp_buf = port->dsp_buf;
-		if (port->buf == NULL) {
-			pr_err("%s: buf is NULL\n", __func__);
-			mutex_unlock(&port->lock);
-			return -EINVAL;
-		}
-		ab = &port->buf[dsp_buf];
-
-		dev_vdbg(ac->dev, "%s: session[%d]dsp-buf[%d][%pK]cpu_buf[%d][%pK]\n",
-				__func__,
-				ac->session,
-				dsp_buf,
-				port->buf[dsp_buf].data,
-				port->cpu_buf,
-				&port->buf[port->cpu_buf].phys);
-
-		read.hdr.opcode = ASM_DATA_CMD_READ_V2;
-		read.buf_addr_lsw = lower_32_bits(ab->phys);
-		read.buf_addr_msw = msm_audio_populate_upper_32_bits(ab->phys);
-
-		list_for_each_safe(ptr, next, &ac->port[OUT].mem_map_handle) {
-			buf_node = list_entry(ptr, struct asm_buffer_node,
-					list);
-			if (buf_node->buf_phys_addr == ab->phys)
-				read.mem_map_handle = buf_node->mmap_hdl;
-		}
-		dev_vdbg(ac->dev, "memory_map handle in q6asm_read: [%0x]:",
-				read.mem_map_handle);
-		read.buf_size = is_custom_len_reqd ? len : ab->size;
-		read.seq_id = port->dsp_buf;
-		q6asm_update_token(&read.hdr.token,
-				   0, /* Session ID is NA */
-				   0, /* Stream ID is NA */
-				   port->dsp_buf,
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-		port->dsp_buf = q6asm_get_next_buf(ac, port->dsp_buf,
-						   port->max_buf_cnt);
-		mutex_unlock(&port->lock);
-		dev_vdbg(ac->dev, "%s: buf add[%pK] token[0x%x] uid[%d]\n",
-				__func__, &ab->phys, read.hdr.token,
-				read.seq_id);
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &read);
-		if (rc < 0) {
-			pr_err("%s: read op[0x%x]rc[%d]\n",
-					__func__, read.hdr.opcode, rc);
-			goto fail_cmd;
-		}
-		return 0;
-	}
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_read(struct audio_client *ac)
-{
-	return __q6asm_read(ac, false/*is_custom_len_reqd*/, 0);
-}
-int q6asm_read_v2(struct audio_client *ac, uint32_t len)
-{
-	return __q6asm_read(ac, true /*is_custom_len_reqd*/, len);
-}
-
-int q6asm_read_nolock(struct audio_client *ac)
-{
-	struct asm_data_cmd_read_v2 read;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	struct audio_buffer        *ab;
-	int dsp_buf;
-	struct audio_port_data     *port;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[OUT];
-
-		q6asm_add_hdr_async(ac, &read.hdr, sizeof(read), FALSE);
-
-
-		dsp_buf = port->dsp_buf;
-		ab = &port->buf[dsp_buf];
-
-		dev_vdbg(ac->dev, "%s: session[%d]dsp-buf[%d][%pK]cpu_buf[%d][%pK]\n",
-				__func__,
-				ac->session,
-				dsp_buf,
-				port->buf[dsp_buf].data,
-				port->cpu_buf,
-				&port->buf[port->cpu_buf].phys);
-
-		read.hdr.opcode = ASM_DATA_CMD_READ_V2;
-		read.buf_addr_lsw = lower_32_bits(ab->phys);
-		read.buf_addr_msw = msm_audio_populate_upper_32_bits(ab->phys);
-		read.buf_size = ab->size;
-		read.seq_id = port->dsp_buf;
-		q6asm_update_token(&read.hdr.token,
-				   0, /* Session ID is NA */
-				   0, /* Stream ID is NA */
-				   port->dsp_buf,
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-
-		list_for_each_safe(ptr, next, &ac->port[OUT].mem_map_handle) {
-			buf_node = list_entry(ptr, struct asm_buffer_node,
-					list);
-			if (buf_node->buf_phys_addr == ab->phys) {
-				read.mem_map_handle = buf_node->mmap_hdl;
-				break;
-			}
-		}
-
-		port->dsp_buf = q6asm_get_next_buf(ac, port->dsp_buf,
-						   port->max_buf_cnt);
-		dev_vdbg(ac->dev, "%s: buf add[%pK] token[0x%x] uid[%d]\n",
-				__func__, &ab->phys, read.hdr.token,
-				read.seq_id);
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &read);
-		if (rc < 0) {
-			pr_err("%s: read op[0x%x]rc[%d]\n",
-					__func__, read.hdr.opcode, rc);
-			goto fail_cmd;
-		}
-		return 0;
-	}
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_async_write(struct audio_client *ac,
-					  struct audio_aio_write_param *param)
-{
-	int rc = 0;
-	struct asm_data_cmd_write_v2 write;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	struct audio_buffer        *ab;
-	struct audio_port_data     *port;
-	phys_addr_t lbuf_phys_addr;
-	u32 liomode;
-	u32 io_compressed;
-	u32 io_compressed_stream;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6asm_stream_add_hdr_async(
-			ac, &write.hdr, sizeof(write), TRUE, ac->stream_id);
-	port = &ac->port[IN];
-	ab = &port->buf[port->dsp_buf];
-
-	/* Pass session id as token for AIO scheme */
-	write.hdr.token = param->uid;
-	write.hdr.opcode = ASM_DATA_CMD_WRITE_V2;
-	write.buf_addr_lsw = lower_32_bits(param->paddr);
-	write.buf_addr_msw = msm_audio_populate_upper_32_bits(param->paddr);
-	write.buf_size = param->len;
-	write.timestamp_msw = param->msw_ts;
-	write.timestamp_lsw = param->lsw_ts;
-	liomode = (ASYNC_IO_MODE | NT_MODE);
-	io_compressed = (ASYNC_IO_MODE | COMPRESSED_IO);
-	io_compressed_stream = (ASYNC_IO_MODE | COMPRESSED_STREAM_IO);
-
-	if (ac->io_mode == liomode)
-		lbuf_phys_addr = (param->paddr - 32);
-	else if (ac->io_mode == io_compressed ||
-			ac->io_mode == io_compressed_stream)
-		lbuf_phys_addr = (param->paddr - param->metadata_len);
-	else {
-		if (param->flags & SET_TIMESTAMP)
-			lbuf_phys_addr = param->paddr -
-				sizeof(struct snd_codec_metadata);
-		else
-			lbuf_phys_addr = param->paddr;
-	}
-	dev_vdbg(ac->dev, "%s: token[0x%x], buf_addr[%pK], buf_size[0x%x], ts_msw[0x%x], ts_lsw[0x%x], lbuf_phys_addr: 0x[%pK]\n",
-			__func__,
-			write.hdr.token, &param->paddr,
-			write.buf_size, write.timestamp_msw,
-			write.timestamp_lsw, &lbuf_phys_addr);
-
-	/* Use 0xFF00 for disabling timestamps */
-	if (param->flags == 0xFF00)
-		write.flags = (0x00000000 | (param->flags & 0x800000FF));
-	else
-		write.flags = (0x80000000 | param->flags);
-	write.flags |= param->last_buffer << ASM_SHIFT_LAST_BUFFER_FLAG;
-	write.seq_id = param->uid;
-	list_for_each_safe(ptr, next, &ac->port[IN].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-				list);
-		if (buf_node->buf_phys_addr == lbuf_phys_addr) {
-			write.mem_map_handle = buf_node->mmap_hdl;
-			break;
-		}
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &write);
-	if (rc < 0) {
-		pr_err("%s: write op[0x%x]rc[%d]\n", __func__,
-				write.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_async_read(struct audio_client *ac,
-					  struct audio_aio_read_param *param)
-{
-	int rc = 0;
-	struct asm_data_cmd_read_v2 read;
-	struct asm_buffer_node *buf_node = NULL;
-	struct list_head *ptr, *next;
-	phys_addr_t lbuf_phys_addr;
-	u32 liomode;
-	u32 io_compressed;
-	int dir = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6asm_add_hdr_async(ac, &read.hdr, sizeof(read), FALSE);
-
-	/* Pass session id as token for AIO scheme */
-	read.hdr.token = param->uid;
-	read.hdr.opcode = ASM_DATA_CMD_READ_V2;
-	read.buf_addr_lsw = lower_32_bits(param->paddr);
-	read.buf_addr_msw = msm_audio_populate_upper_32_bits(param->paddr);
-	read.buf_size = param->len;
-	read.seq_id = param->uid;
-	liomode = (NT_MODE | ASYNC_IO_MODE);
-	io_compressed = (ASYNC_IO_MODE | COMPRESSED_IO);
-	if (ac->io_mode == liomode) {
-		lbuf_phys_addr = (param->paddr - 32);
-		/*legacy wma driver case*/
-		dir = IN;
-	} else if (ac->io_mode == io_compressed) {
-		lbuf_phys_addr = (param->paddr - 64);
-		dir = OUT;
-	} else {
-		if (param->flags & COMPRESSED_TIMESTAMP_FLAG)
-			lbuf_phys_addr = param->paddr -
-				 sizeof(struct snd_codec_metadata);
-		else
-			lbuf_phys_addr = param->paddr;
-		dir = OUT;
-	}
-
-	list_for_each_safe(ptr, next, &ac->port[dir].mem_map_handle) {
-		buf_node = list_entry(ptr, struct asm_buffer_node,
-				list);
-		if (buf_node->buf_phys_addr == lbuf_phys_addr) {
-			read.mem_map_handle = buf_node->mmap_hdl;
-			break;
-		}
-	}
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &read);
-	if (rc < 0) {
-		pr_err("%s: read op[0x%x]rc[%d]\n", __func__,
-				read.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
-		uint32_t lsw_ts, uint32_t flags)
-{
-	int rc = 0;
-	struct asm_data_cmd_write_v2 write;
-	struct asm_buffer_node *buf_node = NULL;
-	struct audio_port_data *port;
-	struct audio_buffer    *ab;
-	int dsp_buf = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_vdbg(ac->dev, "%s: session[%d] len=%d\n",
-			__func__, ac->session, len);
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[IN];
-
-		q6asm_add_hdr(ac, &write.hdr, sizeof(write),
-				FALSE);
-		mutex_lock(&port->lock);
-
-		dsp_buf = port->dsp_buf;
-		ab = &port->buf[dsp_buf];
-
-		q6asm_update_token(&write.hdr.token,
-				   0, /* Session ID is NA */
-				   0, /* Stream ID is NA */
-				   port->dsp_buf,
-				   0, /* Direction flag is NA */
-				   NO_WAIT_CMD);
-		write.hdr.opcode = ASM_DATA_CMD_WRITE_V2;
-		write.buf_addr_lsw = lower_32_bits(ab->phys);
-		write.buf_addr_msw = msm_audio_populate_upper_32_bits(ab->phys);
-		write.buf_size = len;
-		write.seq_id = port->dsp_buf;
-		write.timestamp_lsw = lsw_ts;
-		write.timestamp_msw = msw_ts;
-		/* Use 0xFF00 for disabling timestamps */
-		if (flags == 0xFF00)
-			write.flags = (0x00000000 | (flags & 0x800000FF));
-		else
-			write.flags = (0x80000000 | flags);
-		port->dsp_buf = q6asm_get_next_buf(ac, port->dsp_buf,
-						   port->max_buf_cnt);
-		buf_node = list_first_entry(&ac->port[IN].mem_map_handle,
-				struct asm_buffer_node,
-				list);
-		write.mem_map_handle = buf_node->mmap_hdl;
-
-		dev_vdbg(ac->dev, "%s: ab->phys[%pK]bufadd[0x%x] token[0x%x]buf_id[0x%x]buf_size[0x%x]mmaphdl[0x%x]"
-				, __func__,
-				&ab->phys,
-				write.buf_addr_lsw,
-				write.hdr.token,
-				write.seq_id,
-				write.buf_size,
-				write.mem_map_handle);
-		mutex_unlock(&port->lock);
-
-		config_debug_fs_write(ab);
-
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &write);
-		if (rc < 0) {
-			pr_err("%s: write op[0x%x]rc[%d]\n",
-					__func__, write.hdr.opcode, rc);
-			goto fail_cmd;
-		}
-		return 0;
-	}
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
-			uint32_t lsw_ts, uint32_t flags)
-{
-	int rc = 0;
-	struct asm_data_cmd_write_v2 write;
-	struct asm_buffer_node *buf_node = NULL;
-	struct audio_port_data *port;
-	struct audio_buffer    *ab;
-	int dsp_buf = 0;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_vdbg(ac->dev, "%s: session[%d] len=%d\n",
-			__func__, ac->session, len);
-	if (ac->io_mode & SYNC_IO_MODE) {
-		port = &ac->port[IN];
-
-		q6asm_add_hdr_async(ac, &write.hdr, sizeof(write),
-				FALSE);
-
-		dsp_buf = port->dsp_buf;
-		ab = &port->buf[dsp_buf];
-
-		q6asm_update_token(&write.hdr.token,
-				   0, /* Session ID is NA */
-				   0, /* Stream ID is NA */
-				   port->dsp_buf,
-				   0, /* Direction flag is NA */
-				   NO_WAIT_CMD);
-
-		write.hdr.opcode = ASM_DATA_CMD_WRITE_V2;
-		write.buf_addr_lsw = lower_32_bits(ab->phys);
-		write.buf_addr_msw = msm_audio_populate_upper_32_bits(ab->phys);
-		write.buf_size = len;
-		write.seq_id = port->dsp_buf;
-		write.timestamp_lsw = lsw_ts;
-		write.timestamp_msw = msw_ts;
-		buf_node = list_first_entry(&ac->port[IN].mem_map_handle,
-				struct asm_buffer_node,
-				list);
-		write.mem_map_handle = buf_node->mmap_hdl;
-		/* Use 0xFF00 for disabling timestamps */
-		if (flags == 0xFF00)
-			write.flags = (0x00000000 | (flags & 0x800000FF));
-		else
-			write.flags = (0x80000000 | flags);
-		port->dsp_buf = q6asm_get_next_buf(ac, port->dsp_buf,
-						   port->max_buf_cnt);
-
-		dev_vdbg(ac->dev, "%s: ab->phys[%pK]bufadd[0x%x]token[0x%x] buf_id[0x%x]buf_size[0x%x]mmaphdl[0x%x]"
-				, __func__,
-				&ab->phys,
-				write.buf_addr_lsw,
-				write.hdr.token,
-				write.seq_id,
-				write.buf_size,
-				write.mem_map_handle);
-
-		rc = apr_send_pkt(ac->apr, (uint32_t *) &write);
-		if (rc < 0) {
-			pr_err("%s: write op[0x%x]rc[%d]\n",
-					__func__, write.hdr.opcode, rc);
-			goto fail_cmd;
-		}
-		return 0;
-	}
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp)
-{
-	struct asm_mtmx_strtr_get_params mtmx_params;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (tstamp == NULL) {
-		pr_err("%s: tstamp NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6asm_add_hdr(ac, &mtmx_params.hdr, sizeof(mtmx_params), TRUE);
-	mtmx_params.hdr.opcode = ASM_SESSION_CMD_GET_MTMX_STRTR_PARAMS_V2;
-	mtmx_params.param_info.data_payload_addr_lsw = 0;
-	mtmx_params.param_info.data_payload_addr_msw = 0;
-	mtmx_params.param_info.mem_map_handle = 0;
-	mtmx_params.param_info.direction = (ac->io_mode & TUN_READ_IO_MODE
-					    ? 1 : 0);
-	mtmx_params.param_info.module_id =
-		ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
-	mtmx_params.param_info.param_id =
-		ASM_SESSION_MTMX_STRTR_PARAM_SESSION_TIME_V3;
-	mtmx_params.param_info.param_max_size =
-		sizeof(struct asm_stream_param_data_v2) +
-		sizeof(struct asm_session_mtmx_strtr_param_session_time_v3_t);
-	atomic_set(&ac->time_flag, 1);
-
-	dev_vdbg(ac->dev, "%s: session[%d]opcode[0x%x]\n", __func__,
-		 ac->session, mtmx_params.hdr.opcode);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &mtmx_params);
-	if (rc < 0) {
-		pr_err("%s: Commmand 0x%x failed %d\n", __func__,
-		       mtmx_params.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->time_wait,
-			(atomic_read(&ac->time_flag) == 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout in getting session time from DSP\n",
-				__func__);
-		goto fail_cmd;
-	}
-
-	*tstamp = ac->time_stamp;
-	return 0;
-
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp)
-{
-	struct apr_hdr hdr;
-	int rc;
-
-	if (ac == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (tstamp == NULL) {
-		pr_err("%s: tstamp NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE);
-	hdr.opcode = ASM_SESSION_CMD_GET_SESSIONTIME_V3;
-	atomic_set(&ac->time_flag, 1);
-
-	dev_vdbg(ac->dev, "%s: session[%d]opcode[0x%x]\n", __func__,
-			ac->session,
-			hdr.opcode);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr);
-	if (rc < 0) {
-		pr_err("%s: Commmand 0x%x failed %d\n",
-				__func__, hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->time_wait,
-			(atomic_read(&ac->time_flag) == 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout in getting session time from DSP\n",
-				__func__);
-		goto fail_cmd;
-	}
-
-	*tstamp = ac->time_stamp;
-	return 0;
-
-fail_cmd:
-	return -EINVAL;
-}
-
-
-int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
-				    uint32_t params_length)
-{
-	char *asm_params = NULL;
-	struct apr_hdr hdr;
-	struct asm_stream_cmd_set_pp_params_v2 payload_params;
-	int sz, rc;
-
-	pr_debug("%s:\n", __func__);
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (params == NULL) {
-		pr_err("%s: params NULL\n", __func__);
-		return -EINVAL;
-	}
-	sz = sizeof(struct apr_hdr) +
-		sizeof(struct asm_stream_cmd_set_pp_params_v2) +
-		params_length;
-	asm_params = kzalloc(sz, GFP_KERNEL);
-	if (!asm_params) {
-		pr_err("%s, asm params memory alloc failed", __func__);
-		return -ENOMEM;
-	}
-	q6asm_add_hdr_async(ac, &hdr, (sizeof(struct apr_hdr) +
-				sizeof(struct asm_stream_cmd_set_pp_params_v2) +
-				params_length), TRUE);
-	atomic_set(&ac->cmd_state_pp, -1);
-	hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	payload_params.data_payload_addr_lsw = 0;
-	payload_params.data_payload_addr_msw = 0;
-	payload_params.mem_map_handle = 0;
-	payload_params.data_payload_size = params_length;
-	memcpy(((u8 *)asm_params), &hdr, sizeof(struct apr_hdr));
-	memcpy(((u8 *)asm_params + sizeof(struct apr_hdr)), &payload_params,
-			sizeof(struct asm_stream_cmd_set_pp_params_v2));
-	memcpy(((u8 *)asm_params + sizeof(struct apr_hdr) +
-				sizeof(struct asm_stream_cmd_set_pp_params_v2)),
-			params, params_length);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
-	if (rc < 0) {
-		pr_err("%s: audio effects set-params send failed\n", __func__);
-		rc = -EINVAL;
-		goto fail_send_param;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state_pp) >= 0), 1*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, audio effects set-params\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_send_param;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%s] set-params\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state_pp)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state_pp));
-		goto fail_send_param;
-	}
-
-	rc = 0;
-fail_send_param:
-	kfree(asm_params);
-	return rc;
-}
-
-int q6asm_send_mtmx_strtr_window(struct audio_client *ac,
-		struct asm_session_mtmx_strtr_param_window_v2_t *window_param,
-		uint32_t param_id)
-{
-	struct asm_mtmx_strtr_params matrix;
-	int sz = 0;
-	int rc  = 0;
-
-	pr_debug("%s: Window lsw is %d, window msw is %d\n", __func__,
-		  window_param->window_lsw, window_param->window_msw);
-
-	if (!ac) {
-		pr_err("%s: audio client handle is NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: ac->apr is NULL", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct asm_mtmx_strtr_params);
-	q6asm_add_hdr(ac, &matrix.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	matrix.hdr.opcode = ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2;
-
-	matrix.param.data_payload_addr_lsw = 0;
-	matrix.param.data_payload_addr_msw = 0;
-	matrix.param.mem_map_handle = 0;
-	matrix.param.data_payload_size =
-		sizeof(struct asm_stream_param_data_v2) +
-		sizeof(struct asm_session_mtmx_strtr_param_window_v2_t);
-	matrix.param.direction = 0; /* RX */
-	matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
-	matrix.data.param_id = param_id;
-	matrix.data.param_size =
-		sizeof(struct asm_session_mtmx_strtr_param_window_v2_t);
-	matrix.data.reserved = 0;
-	memcpy(&(matrix.config.window_param),
-	       window_param,
-	       sizeof(struct asm_session_mtmx_strtr_param_window_v2_t));
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &matrix);
-	if (rc < 0) {
-		pr_err("%s: Render window start send failed paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, Render window start paramid[0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_send_mtmx_strtr_render_mode(struct audio_client *ac,
-		uint32_t render_mode)
-{
-	struct asm_mtmx_strtr_params matrix;
-	struct asm_session_mtmx_strtr_param_render_mode_t render_param;
-	int sz = 0;
-	int rc  = 0;
-
-	pr_debug("%s: render mode is %d\n", __func__, render_mode);
-
-	if (!ac) {
-		pr_err("%s: audio client handle is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: ac->apr is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	if ((render_mode != ASM_SESSION_MTMX_STRTR_PARAM_RENDER_DEFAULT) &&
-	    (render_mode != ASM_SESSION_MTMX_STRTR_PARAM_RENDER_LOCAL_STC)) {
-		pr_err("%s: Invalid render mode %d\n", __func__, render_mode);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	memset(&render_param, 0,
-	       sizeof(struct asm_session_mtmx_strtr_param_render_mode_t));
-	render_param.flags = render_mode;
-
-	memset(&matrix, 0, sizeof(struct asm_mtmx_strtr_params));
-	sz = sizeof(struct asm_mtmx_strtr_params);
-	q6asm_add_hdr(ac, &matrix.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	matrix.hdr.opcode = ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2;
-
-	matrix.param.data_payload_addr_lsw = 0;
-	matrix.param.data_payload_addr_msw = 0;
-	matrix.param.mem_map_handle = 0;
-	matrix.param.data_payload_size =
-		sizeof(struct asm_stream_param_data_v2) +
-		sizeof(struct asm_session_mtmx_strtr_param_render_mode_t);
-	matrix.param.direction = 0; /* RX */
-	matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
-	matrix.data.param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_MODE_CMD;
-	matrix.data.param_size =
-		sizeof(struct asm_session_mtmx_strtr_param_render_mode_t);
-	matrix.data.reserved = 0;
-	memcpy(&(matrix.config.render_param),
-	       &render_param,
-	       sizeof(struct asm_session_mtmx_strtr_param_render_mode_t));
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &matrix);
-	if (rc < 0) {
-		pr_err("%s: Render mode send failed paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, Render mode send paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -ETIMEDOUT;
-		goto exit;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto exit;
-	}
-	rc = 0;
-exit:
-	return rc;
-}
-
-int q6asm_send_mtmx_strtr_clk_rec_mode(struct audio_client *ac,
-		uint32_t clk_rec_mode)
-{
-	struct asm_mtmx_strtr_params matrix;
-	struct asm_session_mtmx_strtr_param_clk_rec_t clk_rec_param;
-	int sz = 0;
-	int rc  = 0;
-
-	pr_debug("%s: clk rec mode is %d\n", __func__, clk_rec_mode);
-
-	if (!ac) {
-		pr_err("%s: audio client handle is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: ac->apr is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	if ((clk_rec_mode != ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_NONE) &&
-	    (clk_rec_mode != ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_AUTO)) {
-		pr_err("%s: Invalid clk rec mode %d\n", __func__, clk_rec_mode);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	memset(&clk_rec_param, 0,
-	       sizeof(struct asm_session_mtmx_strtr_param_clk_rec_t));
-	clk_rec_param.flags = clk_rec_mode;
-
-	memset(&matrix, 0, sizeof(struct asm_mtmx_strtr_params));
-	sz = sizeof(struct asm_mtmx_strtr_params);
-	q6asm_add_hdr(ac, &matrix.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	matrix.hdr.opcode = ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2;
-
-	matrix.param.data_payload_addr_lsw = 0;
-	matrix.param.data_payload_addr_msw = 0;
-	matrix.param.mem_map_handle = 0;
-	matrix.param.data_payload_size =
-		sizeof(struct asm_stream_param_data_v2) +
-		sizeof(struct asm_session_mtmx_strtr_param_clk_rec_t);
-	matrix.param.direction = 0; /* RX */
-	matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
-	matrix.data.param_id = ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_CMD;
-	matrix.data.param_size =
-		sizeof(struct asm_session_mtmx_strtr_param_clk_rec_t);
-	matrix.data.reserved = 0;
-	memcpy(&(matrix.config.clk_rec_param),
-	       &clk_rec_param,
-	       sizeof(struct asm_session_mtmx_strtr_param_clk_rec_t));
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &matrix);
-	if (rc < 0) {
-		pr_err("%s: clk rec mode send failed paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, clk rec mode send paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -ETIMEDOUT;
-		goto exit;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto exit;
-	}
-	rc = 0;
-exit:
-	return rc;
-}
-
-int q6asm_send_mtmx_strtr_enable_adjust_session_clock(struct audio_client *ac,
-		bool enable)
-{
-	struct asm_mtmx_strtr_params matrix;
-	struct asm_session_mtmx_param_adjust_session_time_ctl_t adjust_time;
-	int sz = 0;
-	int rc  = 0;
-
-	pr_debug("%s: adjust session enable %d\n", __func__, enable);
-
-	if (!ac) {
-		pr_err("%s: audio client handle is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: ac->apr is NULL\n", __func__);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	adjust_time.enable = enable;
-	memset(&matrix, 0, sizeof(struct asm_mtmx_strtr_params));
-	sz = sizeof(struct asm_mtmx_strtr_params);
-	q6asm_add_hdr(ac, &matrix.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	matrix.hdr.opcode = ASM_SESSION_CMD_SET_MTMX_STRTR_PARAMS_V2;
-
-	matrix.param.data_payload_addr_lsw = 0;
-	matrix.param.data_payload_addr_msw = 0;
-	matrix.param.mem_map_handle = 0;
-	matrix.param.data_payload_size =
-		sizeof(struct asm_stream_param_data_v2) +
-		sizeof(struct asm_session_mtmx_param_adjust_session_time_ctl_t);
-	matrix.param.direction = 0; /* RX */
-	matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
-	matrix.data.param_id = ASM_SESSION_MTMX_PARAM_ADJUST_SESSION_TIME_CTL;
-	matrix.data.param_size =
-		sizeof(struct asm_session_mtmx_param_adjust_session_time_ctl_t);
-	matrix.data.reserved = 0;
-	matrix.config.adj_time_param.enable = adjust_time.enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &matrix);
-	if (rc < 0) {
-		pr_err("%s: enable adjust session failed failed paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -EINVAL;
-		goto exit;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: enable adjust session failed failed paramid [0x%x]\n",
-			__func__, matrix.data.param_id);
-		rc = -ETIMEDOUT;
-		goto exit;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto exit;
-	}
-	rc = 0;
-exit:
-	return rc;
-}
-
-
-static int __q6asm_cmd(struct audio_client *ac, int cmd, uint32_t stream_id)
-{
-	struct apr_hdr hdr;
-	int rc;
-	atomic_t *state;
-	int cnt = 0;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	q6asm_stream_add_hdr(ac, &hdr, sizeof(hdr), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, -1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   WAIT_CMD);
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-			__func__, hdr.token, stream_id, ac->session);
-	switch (cmd) {
-	case CMD_PAUSE:
-		pr_debug("%s: CMD_PAUSE\n", __func__);
-		hdr.opcode = ASM_SESSION_CMD_PAUSE;
-		state = &ac->cmd_state;
-		break;
-	case CMD_SUSPEND:
-		pr_debug("%s: CMD_SUSPEND\n", __func__);
-		hdr.opcode = ASM_SESSION_CMD_SUSPEND;
-		state = &ac->cmd_state;
-		break;
-	case CMD_FLUSH:
-		pr_debug("%s: CMD_FLUSH\n", __func__);
-		hdr.opcode = ASM_STREAM_CMD_FLUSH;
-		state = &ac->cmd_state;
-		break;
-	case CMD_OUT_FLUSH:
-		pr_debug("%s: CMD_OUT_FLUSH\n", __func__);
-		hdr.opcode = ASM_STREAM_CMD_FLUSH_READBUFS;
-		state = &ac->cmd_state;
-		break;
-	case CMD_EOS:
-		pr_debug("%s: CMD_EOS\n", __func__);
-		hdr.opcode = ASM_DATA_CMD_EOS;
-		atomic_set(&ac->cmd_state, 0);
-		state = &ac->cmd_state;
-		break;
-	case CMD_CLOSE:
-		pr_debug("%s: CMD_CLOSE\n", __func__);
-		hdr.opcode = ASM_STREAM_CMD_CLOSE;
-		state = &ac->cmd_state;
-		break;
-	default:
-		pr_err("%s: Invalid format[%d]\n", __func__, cmd);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	pr_debug("%s: session[%d]opcode[0x%x]\n", __func__,
-			ac->session,
-			hdr.opcode);
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr);
-	if (rc < 0) {
-		pr_err("%s: Commmand 0x%x failed %d\n",
-				__func__, hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait, (atomic_read(state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for response opcode[0x%x]\n",
-				__func__, hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(state) > 0) {
-		pr_err("%s: DSP returned error[%s] opcode %d\n",
-					__func__, adsp_err_get_err_str(
-					atomic_read(state)),
-					hdr.opcode);
-		rc = adsp_err_get_lnx_err_code(atomic_read(state));
-		goto fail_cmd;
-	}
-
-	if (cmd == CMD_FLUSH)
-		q6asm_reset_buf_state(ac);
-	if (cmd == CMD_CLOSE) {
-		/* check if DSP return all buffers */
-		if (ac->port[IN].buf) {
-			for (cnt = 0; cnt < ac->port[IN].max_buf_cnt;
-					cnt++) {
-				if (ac->port[IN].buf[cnt].used == IN) {
-					dev_vdbg(ac->dev, "Write Buf[%d] not returned\n",
-							cnt);
-				}
-			}
-		}
-		if (ac->port[OUT].buf) {
-			for (cnt = 0; cnt < ac->port[OUT].max_buf_cnt; cnt++) {
-				if (ac->port[OUT].buf[cnt].used == OUT) {
-					dev_vdbg(ac->dev, "Read Buf[%d] not returned\n",
-							cnt);
-				}
-			}
-		}
-	}
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_cmd(struct audio_client *ac, int cmd)
-{
-	return __q6asm_cmd(ac, cmd, ac->stream_id);
-}
-
-int q6asm_stream_cmd(struct audio_client *ac, int cmd, uint32_t stream_id)
-{
-	return __q6asm_cmd(ac, cmd, stream_id);
-}
-
-static int __q6asm_cmd_nowait(struct audio_client *ac, int cmd,
-			      uint32_t stream_id)
-{
-	struct apr_hdr hdr;
-	int rc;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	q6asm_stream_add_hdr_async(ac, &hdr, sizeof(hdr), TRUE, stream_id);
-	atomic_set(&ac->cmd_state, 1);
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   NO_WAIT_CMD);
-
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-			__func__, hdr.token, stream_id, ac->session);
-	switch (cmd) {
-	case CMD_PAUSE:
-		pr_debug("%s: CMD_PAUSE\n", __func__);
-		hdr.opcode = ASM_SESSION_CMD_PAUSE;
-		break;
-	case CMD_EOS:
-		pr_debug("%s: CMD_EOS\n", __func__);
-		hdr.opcode = ASM_DATA_CMD_EOS;
-		break;
-	case CMD_CLOSE:
-		pr_debug("%s: CMD_CLOSE\n", __func__);
-		hdr.opcode = ASM_STREAM_CMD_CLOSE;
-		break;
-	default:
-		pr_err("%s: Invalid format[%d]\n", __func__, cmd);
-		goto fail_cmd;
-	}
-	pr_debug("%s: session[%d]opcode[0x%x]\n", __func__,
-			ac->session,
-			hdr.opcode);
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr);
-	if (rc < 0) {
-		pr_err("%s: Commmand 0x%x failed %d\n",
-				__func__, hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_cmd_nowait(struct audio_client *ac, int cmd)
-{
-	pr_debug("%s: stream_id: %d\n", __func__, ac->stream_id);
-	return __q6asm_cmd_nowait(ac, cmd, ac->stream_id);
-}
-
-int q6asm_stream_cmd_nowait(struct audio_client *ac, int cmd,
-			    uint32_t stream_id)
-{
-	pr_debug("%s: stream_id: %d\n", __func__, stream_id);
-	return __q6asm_cmd_nowait(ac, cmd, stream_id);
-}
-
-int __q6asm_send_meta_data(struct audio_client *ac, uint32_t stream_id,
-			  uint32_t initial_samples, uint32_t trailing_samples)
-{
-	struct asm_data_cmd_remove_silence silence;
-	int rc = 0;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]\n", __func__, ac->session);
-	q6asm_stream_add_hdr_async(ac, &silence.hdr, sizeof(silence), TRUE,
-			stream_id);
-
-	/*
-	 * Updated the token field with stream/session for compressed playback
-	 * Platform driver must know the the stream with which the command is
-	 * associated
-	 */
-	if (ac->io_mode & COMPRESSED_STREAM_IO)
-		q6asm_update_token(&silence.hdr.token,
-				   ac->session,
-				   stream_id,
-				   0, /* Buffer index is NA */
-				   0, /* Direction flag is NA */
-				   NO_WAIT_CMD);
-	pr_debug("%s: token = 0x%x, stream_id  %d, session 0x%x\n",
-			__func__, silence.hdr.token, stream_id, ac->session);
-
-	silence.hdr.opcode = ASM_DATA_CMD_REMOVE_INITIAL_SILENCE;
-	silence.num_samples_to_remove    = initial_samples;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &silence);
-	if (rc < 0) {
-		pr_err("%s: Commmand silence failed[%d]", __func__, rc);
-
-		goto fail_cmd;
-	}
-
-	silence.hdr.opcode = ASM_DATA_CMD_REMOVE_TRAILING_SILENCE;
-	silence.num_samples_to_remove    = trailing_samples;
-
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &silence);
-	if (rc < 0) {
-		pr_err("%s: Commmand silence failed[%d]", __func__, rc);
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_stream_send_meta_data(struct audio_client *ac, uint32_t stream_id,
-		uint32_t initial_samples, uint32_t trailing_samples)
-{
-	return __q6asm_send_meta_data(ac, stream_id, initial_samples,
-				     trailing_samples);
-}
-
-int q6asm_send_meta_data(struct audio_client *ac, uint32_t initial_samples,
-		uint32_t trailing_samples)
-{
-	return __q6asm_send_meta_data(ac, ac->stream_id, initial_samples,
-				     trailing_samples);
-}
-
-static void q6asm_reset_buf_state(struct audio_client *ac)
-{
-	int cnt = 0;
-	int loopcnt = 0;
-	int used;
-	struct audio_port_data *port = NULL;
-
-	if (ac->io_mode & SYNC_IO_MODE) {
-		used = (ac->io_mode & TUN_WRITE_IO_MODE ? 1 : 0);
-		mutex_lock(&ac->cmd_lock);
-		for (loopcnt = 0; loopcnt <= OUT; loopcnt++) {
-			port = &ac->port[loopcnt];
-			cnt = port->max_buf_cnt - 1;
-			port->dsp_buf = 0;
-			port->cpu_buf = 0;
-			while (cnt >= 0) {
-				if (!port->buf)
-					continue;
-				port->buf[cnt].used = used;
-				cnt--;
-			}
-		}
-		mutex_unlock(&ac->cmd_lock);
-	}
-}
-
-int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable)
-{
-	struct asm_session_cmd_regx_overflow tx_overflow;
-	int rc;
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]enable[%d]\n", __func__,
-			ac->session, enable);
-	q6asm_add_hdr(ac, &tx_overflow.hdr, sizeof(tx_overflow), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	tx_overflow.hdr.opcode =
-				 ASM_SESSION_CMD_REGISTER_FORX_OVERFLOW_EVENTS;
-	/* tx overflow event: enable */
-	tx_overflow.enable_flag = enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &tx_overflow);
-	if (rc < 0) {
-		pr_err("%s: tx overflow op[0x%x]rc[%d]\n",
-				__func__, tx_overflow.hdr.opcode, rc);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for tx overflow\n", __func__);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-
-	return 0;
-fail_cmd:
-	return rc;
-}
-
-int q6asm_reg_rx_underflow(struct audio_client *ac, uint16_t enable)
-{
-	struct asm_session_cmd_rgstr_rx_underflow rx_underflow;
-	int rc;
-
-	if (!ac) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: session[%d]enable[%d]\n", __func__,
-			ac->session, enable);
-	q6asm_add_hdr_async(ac, &rx_underflow.hdr, sizeof(rx_underflow), FALSE);
-
-	rx_underflow.hdr.opcode =
-		ASM_SESSION_CMD_REGISTER_FOR_RX_UNDERFLOW_EVENTS;
-	/* tx overflow event: enable */
-	rx_underflow.enable_flag = enable;
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &rx_underflow);
-	if (rc < 0) {
-		pr_err("%s: tx overflow op[0x%x]rc[%d]\n",
-				__func__, rx_underflow.hdr.opcode, rc);
-		goto fail_cmd;
-	}
-	return 0;
-fail_cmd:
-	return -EINVAL;
-}
-
-int q6asm_adjust_session_clock(struct audio_client *ac,
-		uint32_t adjust_time_lsw,
-		uint32_t adjust_time_msw)
-{
-	int rc = 0;
-	int sz = 0;
-	struct asm_session_cmd_adjust_session_clock_v2 adjust_clock;
-
-	pr_debug("%s: adjust_time_lsw is %x, adjust_time_msw is %x\n", __func__,
-		  adjust_time_lsw, adjust_time_msw);
-
-	if (!ac) {
-		pr_err("%s: audio client handle is NULL\n", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	if (ac->apr == NULL) {
-		pr_err("%s: ac->apr is NULL", __func__);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	sz = sizeof(struct asm_session_cmd_adjust_session_clock_v2);
-	q6asm_add_hdr(ac, &adjust_clock.hdr, sz, TRUE);
-	atomic_set(&ac->cmd_state, -1);
-	adjust_clock.hdr.opcode = ASM_SESSION_CMD_ADJUST_SESSION_CLOCK_V2;
-
-	adjust_clock.adjustime_lsw = adjust_time_lsw;
-	adjust_clock.adjustime_msw = adjust_time_msw;
-
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &adjust_clock);
-	if (rc < 0) {
-		pr_err("%s: adjust_clock send failed paramid [0x%x]\n",
-			__func__, adjust_clock.hdr.opcode);
-		rc = -EINVAL;
-		goto fail_cmd;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
-	if (!rc) {
-		pr_err("%s: timeout, adjust_clock paramid[0x%x]\n",
-			__func__, adjust_clock.hdr.opcode);
-		rc = -ETIMEDOUT;
-		goto fail_cmd;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		goto fail_cmd;
-	}
-	rc = 0;
-fail_cmd:
-	return rc;
-}
-
-/*
- * q6asm_get_path_delay() - get the path delay for an audio session
- * @ac: audio client handle
- *
- * Retrieves the current audio DSP path delay for the given audio session.
- *
- * Return: 0 on success, error code otherwise
- */
-int q6asm_get_path_delay(struct audio_client *ac)
-{
-	int rc = 0;
-	struct apr_hdr hdr;
-
-	if (!ac || ac->apr == NULL) {
-		pr_err("%s: invalid audio client\n", __func__);
-		return -EINVAL;
-	}
-
-	hdr.opcode = ASM_SESSION_CMD_GET_PATH_DELAY_V2;
-	q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE);
-	atomic_set(&ac->cmd_state, -1);
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr);
-	if (rc < 0) {
-		pr_err("%s: Commmand 0x%x failed %d\n", __func__,
-				hdr.opcode, rc);
-		return rc;
-	}
-
-	rc = wait_event_timeout(ac->cmd_wait,
-			(atomic_read(&ac->cmd_state) >= 0), 5 * HZ);
-	if (!rc) {
-		pr_err("%s: timeout. waited for response opcode[0x%x]\n",
-				__func__, hdr.opcode);
-		return -ETIMEDOUT;
-	}
-
-	if (atomic_read(&ac->cmd_state) > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				atomic_read(&ac->cmd_state)));
-		rc = adsp_err_get_lnx_err_code(
-				atomic_read(&ac->cmd_state));
-		return rc;
-	}
-
-	return 0;
-}
-
-int q6asm_get_apr_service_id(int session_id)
-{
-	pr_debug("%s:\n", __func__);
-
-	if (session_id <= 0 || session_id > ASM_ACTIVE_STREAMS_ALLOWED) {
-		pr_err("%s: invalid session_id = %d\n", __func__, session_id);
-		return -EINVAL;
-	}
-
-	return ((struct apr_svc *)session[session_id]->apr)->id;
-}
-
-int q6asm_get_asm_topology(int session_id)
-{
-	int topology = -EINVAL;
-
-	if (session_id <= 0 || session_id > ASM_ACTIVE_STREAMS_ALLOWED) {
-		pr_err("%s: invalid session_id = %d\n", __func__, session_id);
-		goto done;
-	}
-	if (session[session_id] == NULL) {
-		pr_err("%s: session not created for session id = %d\n",
-		       __func__, session_id);
-		goto done;
-	}
-	topology = session[session_id]->topology;
-done:
-	return topology;
-}
-
-int q6asm_get_asm_app_type(int session_id)
-{
-	int app_type = -EINVAL;
-
-	if (session_id <= 0 || session_id > ASM_ACTIVE_STREAMS_ALLOWED) {
-		pr_err("%s: invalid session_id = %d\n", __func__, session_id);
-		goto done;
-	}
-	if (session[session_id] == NULL) {
-		pr_err("%s: session not created for session id = %d\n",
-		       __func__, session_id);
-		goto done;
-	}
-	app_type = session[session_id]->app_type;
-done:
-	return app_type;
-}
-
-static int q6asm_get_asm_topology_cal(void)
-{
-	int topology = DEFAULT_POPP_TOPOLOGY;
-	struct cal_block_data *cal_block = NULL;
-
-	if (cal_data[ASM_TOPOLOGY_CAL] == NULL)
-		goto done;
-
-	mutex_lock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
-	cal_block = cal_utils_get_only_cal_block(cal_data[ASM_TOPOLOGY_CAL]);
-	if (cal_block == NULL)
-		goto unlock;
-
-	topology = ((struct audio_cal_info_asm_top *)
-		cal_block->cal_info)->topology;
-unlock:
-	mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
-done:
-	pr_debug("%s: Using topology %d\n", __func__, topology);
-	return topology;
-}
-
-static int q6asm_get_asm_app_type_cal(void)
-{
-	int app_type = DEFAULT_APP_TYPE;
-	struct cal_block_data *cal_block = NULL;
-
-	if (cal_data[ASM_TOPOLOGY_CAL] == NULL)
-		goto done;
-
-	mutex_lock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
-	cal_block = cal_utils_get_only_cal_block(cal_data[ASM_TOPOLOGY_CAL]);
-	if (cal_block == NULL)
-		goto unlock;
-
-	app_type = ((struct audio_cal_info_asm_top *)
-		cal_block->cal_info)->app_type;
-
-	if (app_type == 0)
-		app_type = DEFAULT_APP_TYPE;
-unlock:
-	mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
-done:
-	pr_debug("%s: Using app_type %d\n", __func__, app_type);
-	return app_type;
-}
-
-int q6asm_send_cal(struct audio_client *ac)
-{
-	struct cal_block_data *cal_block = NULL;
-	struct apr_hdr	hdr;
-	char *asm_params = NULL;
-	struct asm_stream_cmd_set_pp_params_v2 payload_params;
-	int sz, rc = -EINVAL;
-
-	pr_debug("%s:\n", __func__);
-
-	if (!ac) {
-		pr_err("%s: APR handle NULL\n", __func__);
-		goto done;
-	}
-	if (ac->apr == NULL) {
-		pr_err("%s: AC APR handle NULL\n", __func__);
-		goto done;
-	}
-	if (ac->io_mode & NT_MODE) {
-		pr_debug("%s: called for NT MODE, exiting\n", __func__);
-		goto done;
-	}
-
-	if (cal_data[ASM_AUDSTRM_CAL] == NULL)
-		goto done;
-
-	if (ac->perf_mode == ULTRA_LOW_LATENCY_PCM_MODE) {
-		rc = 0; /* no cal is required, not error case */
-		goto done;
-	}
-
-	mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock);
-	cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]);
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL\n",
-			__func__);
-		goto unlock;
-	}
-
-	if (cal_block->cal_data.size == 0) {
-		rc = 0; /* not error case */
-		pr_debug("%s: cal_data.size is 0, don't send cal data\n",
-			__func__);
-		goto unlock;
-	}
-
-	rc = remap_cal_data(ASM_AUDSTRM_CAL_TYPE, cal_block);
-	if (rc) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, ASM_AUDSTRM_CAL);
-		goto unlock;
-	}
-
-	sz = sizeof(struct apr_hdr) +
-		sizeof(struct asm_stream_cmd_set_pp_params_v2);
-	asm_params = kzalloc(sz, GFP_KERNEL);
-	if (!asm_params) {
-		pr_err("%s, asm params memory alloc failed", __func__);
-		rc = -ENOMEM;
-		goto unlock;
-	}
-
-	/* asm_stream_cmd_set_pp_params_v2 has no APR header in it */
-	q6asm_add_hdr_async(ac, &hdr, (sizeof(struct apr_hdr) +
-		sizeof(struct asm_stream_cmd_set_pp_params_v2)), TRUE);
-
-	atomic_set(&ac->cmd_state_pp, -1);
-	hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-	payload_params.data_payload_addr_lsw =
-			lower_32_bits(cal_block->cal_data.paddr);
-	payload_params.data_payload_addr_msw =
-			msm_audio_populate_upper_32_bits(
-						cal_block->cal_data.paddr);
-	payload_params.mem_map_handle = cal_block->map_data.q6map_handle;
-	payload_params.data_payload_size = cal_block->cal_data.size;
-	memcpy(((u8 *)asm_params), &hdr, sizeof(struct apr_hdr));
-	memcpy(((u8 *)asm_params + sizeof(struct apr_hdr)), &payload_params,
-			sizeof(struct asm_stream_cmd_set_pp_params_v2));
-
-	pr_debug("%s: phyaddr lsw = %x msw = %x, maphdl = %x calsize = %d\n",
-		__func__, payload_params.data_payload_addr_lsw,
-		payload_params.data_payload_addr_msw,
-		payload_params.mem_map_handle,
-		payload_params.data_payload_size);
-
-	rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
-	if (rc < 0) {
-		pr_err("%s: audio audstrm cal send failed\n", __func__);
-		rc = -EINVAL;
-		goto free;
-	}
-	rc = wait_event_timeout(ac->cmd_wait,
-				(atomic_read(&ac->cmd_state_pp) >= 0), 5 * HZ);
-	if (!rc) {
-		pr_err("%s: timeout, audio audstrm cal send\n", __func__);
-		rc = -ETIMEDOUT;
-		goto free;
-	}
-	if (atomic_read(&ac->cmd_state_pp) > 0) {
-		pr_err("%s: DSP returned error[%d] audio audstrm cal send\n",
-				__func__, atomic_read(&ac->cmd_state_pp));
-		rc = -EINVAL;
-		goto free;
-	}
-
-	rc = 0;
-
-free:
-	kfree(asm_params);
-unlock:
-	mutex_unlock(&cal_data[ASM_AUDSTRM_CAL]->lock);
-done:
-	return rc;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case ASM_TOPOLOGY_CAL_TYPE:
-		ret = ASM_TOPOLOGY_CAL;
-		break;
-	case ASM_CUST_TOPOLOGY_CAL_TYPE:
-		ret = ASM_CUSTOM_TOP_CAL;
-		break;
-	case ASM_AUDSTRM_CAL_TYPE:
-		ret = ASM_AUDSTRM_CAL;
-		break;
-	case ASM_RTAC_APR_CAL_TYPE:
-		ret = ASM_RTAC_APR_CAL;
-		break;
-	default:
-		pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-static int q6asm_alloc_cal(int32_t cal_type,
-				size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6asm_dealloc_cal(int32_t cal_type,
-				size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-		cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6asm_set_cal(int32_t cal_type,
-			size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-		cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_index == ASM_CUSTOM_TOP_CAL) {
-		mutex_lock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-		set_custom_topology = 1;
-		mutex_unlock(&cal_data[ASM_CUSTOM_TOP_CAL]->lock);
-	}
-done:
-	return ret;
-}
-
-static void q6asm_delete_cal_data(void)
-{
-	pr_debug("%s:\n", __func__);
-	cal_utils_destroy_cal_types(ASM_MAX_CAL_TYPES, cal_data);
-}
-
-static int q6asm_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info	cal_type_info[] = {
-		{{ASM_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL,
-		q6asm_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{ASM_CUST_TOPOLOGY_CAL_TYPE,
-		{q6asm_alloc_cal, q6asm_dealloc_cal, NULL,
-		q6asm_set_cal, NULL, NULL} },
-		{NULL, q6asm_unmap_cal_memory, cal_utils_match_buf_num} },
-
-		{{ASM_AUDSTRM_CAL_TYPE,
-		{q6asm_alloc_cal, q6asm_dealloc_cal, NULL,
-		q6asm_set_cal, NULL, NULL} },
-		{NULL, q6asm_unmap_cal_memory, cal_utils_match_buf_num} },
-
-		{{ASM_RTAC_APR_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} }
-	};
-	pr_debug("%s\n", __func__);
-
-	ret = cal_utils_create_cal_types(ASM_MAX_CAL_TYPES, cal_data,
-		cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type! %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	q6asm_delete_cal_data();
-	return ret;
-}
-
-static int q6asm_is_valid_session(struct apr_client_data *data, void *priv)
-{
-	struct audio_client *ac = (struct audio_client *)priv;
-	union asm_token_struct asm_token;
-
-	asm_token.token = data->token;
-	if (asm_token._token.session_id != ac->session) {
-		pr_err("%s: Invalid session[%d] rxed expected[%d]",
-			__func__, asm_token._token.session_id, ac->session);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int __init q6asm_init(void)
-{
-	int lcnt, ret;
-
-	pr_debug("%s:\n", __func__);
-
-	memset(session, 0, sizeof(session));
-	set_custom_topology = 1;
-
-	/*setup common client used for cal mem map */
-	common_client.session = ASM_CONTROL_SESSION;
-	common_client.port[0].buf = &common_buf[0];
-	common_client.port[1].buf = &common_buf[1];
-	init_waitqueue_head(&common_client.cmd_wait);
-	init_waitqueue_head(&common_client.time_wait);
-	init_waitqueue_head(&common_client.mem_wait);
-	atomic_set(&common_client.time_flag, 1);
-	INIT_LIST_HEAD(&common_client.port[0].mem_map_handle);
-	INIT_LIST_HEAD(&common_client.port[1].mem_map_handle);
-	mutex_init(&common_client.cmd_lock);
-	for (lcnt = 0; lcnt <= OUT; lcnt++) {
-		mutex_init(&common_client.port[lcnt].lock);
-		spin_lock_init(&common_client.port[lcnt].dsp_lock);
-	}
-	atomic_set(&common_client.cmd_state, 0);
-	atomic_set(&common_client.mem_state, 0);
-
-	ret = q6asm_init_cal_data();
-	if (ret)
-		pr_err("%s: could not init cal data! ret %d\n",
-			__func__, ret);
-
-	config_debug_fs_init();
-
-	return 0;
-}
-
-static void __exit q6asm_exit(void)
-{
-	q6asm_delete_cal_data();
-}
-
-device_initcall(q6asm_init);
-__exitcall(q6asm_exit);
diff --git a/sound/soc/msm/qdsp6v2/q6audio-v2.c b/sound/soc/msm/qdsp6v2/q6audio-v2.c
deleted file mode 100644
index ea78e6a..0000000
--- a/sound/soc/msm/qdsp6v2/q6audio-v2.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/jiffies.h>
-#include <linux/uaccess.h>
-#include <linux/atomic.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6audio-v2.h>
-
-int q6audio_get_port_index(u16 port_id)
-{
-	switch (port_id) {
-	case PRIMARY_I2S_RX: return IDX_PRIMARY_I2S_RX;
-	case PRIMARY_I2S_TX: return IDX_PRIMARY_I2S_TX;
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_PCM_RX;
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_PCM_TX;
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_PCM_RX;
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_PCM_TX;
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_PCM_RX;
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_PCM_TX;
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_PCM_RX;
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_PCM_TX;
-	case SECONDARY_I2S_RX: return IDX_SECONDARY_I2S_RX;
-	case SECONDARY_I2S_TX: return IDX_SECONDARY_I2S_TX;
-	case MI2S_RX: return IDX_MI2S_RX;
-	case MI2S_TX: return IDX_MI2S_TX;
-	case HDMI_RX: return IDX_HDMI_RX;
-	case DISPLAY_PORT_RX: return IDX_DISPLAY_PORT_RX;
-	case AFE_PORT_ID_SPDIF_RX: return IDX_SPDIF_RX;
-	case RSVD_2: return IDX_RSVD_2;
-	case RSVD_3: return IDX_RSVD_3;
-	case DIGI_MIC_TX: return IDX_DIGI_MIC_TX;
-	case VOICE_RECORD_RX: return IDX_VOICE_RECORD_RX;
-	case VOICE_RECORD_TX: return IDX_VOICE_RECORD_TX;
-	case VOICE_PLAYBACK_TX: return IDX_VOICE_PLAYBACK_TX;
-	case VOICE2_PLAYBACK_TX: return IDX_VOICE2_PLAYBACK_TX;
-	case SLIMBUS_0_RX: return IDX_SLIMBUS_0_RX;
-	case SLIMBUS_0_TX: return IDX_SLIMBUS_0_TX;
-	case SLIMBUS_1_RX: return IDX_SLIMBUS_1_RX;
-	case SLIMBUS_1_TX: return IDX_SLIMBUS_1_TX;
-	case SLIMBUS_2_RX: return IDX_SLIMBUS_2_RX;
-	case SLIMBUS_2_TX: return IDX_SLIMBUS_2_TX;
-	case SLIMBUS_3_RX: return IDX_SLIMBUS_3_RX;
-	case SLIMBUS_3_TX: return IDX_SLIMBUS_3_TX;
-	case SLIMBUS_4_RX: return IDX_SLIMBUS_4_RX;
-	case SLIMBUS_4_TX: return IDX_SLIMBUS_4_TX;
-	case SLIMBUS_5_RX: return IDX_SLIMBUS_5_RX;
-	case SLIMBUS_5_TX: return IDX_SLIMBUS_5_TX;
-	case SLIMBUS_6_RX: return IDX_SLIMBUS_6_RX;
-	case SLIMBUS_6_TX: return IDX_SLIMBUS_6_TX;
-	case SLIMBUS_7_RX: return IDX_SLIMBUS_7_RX;
-	case SLIMBUS_7_TX: return IDX_SLIMBUS_7_TX;
-	case SLIMBUS_8_RX: return IDX_SLIMBUS_8_RX;
-	case SLIMBUS_8_TX: return IDX_SLIMBUS_8_TX;
-	case INT_BT_SCO_RX: return IDX_INT_BT_SCO_RX;
-	case INT_BT_SCO_TX: return IDX_INT_BT_SCO_TX;
-	case INT_BT_A2DP_RX: return IDX_INT_BT_A2DP_RX;
-	case INT_FM_RX: return IDX_INT_FM_RX;
-	case INT_FM_TX: return IDX_INT_FM_TX;
-	case RT_PROXY_PORT_001_RX: return IDX_RT_PROXY_PORT_001_RX;
-	case RT_PROXY_PORT_001_TX: return IDX_RT_PROXY_PORT_001_TX;
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_MI2S_RX;
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_MI2S_TX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX;
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_TX;
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_MI2S_RX;
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_MI2S_TX;
-	case AUDIO_PORT_ID_I2S_RX:
-		return IDX_AUDIO_PORT_ID_I2S_RX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-		return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7;
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-		return IDX_AFE_PORT_ID_SENARY_MI2S_TX;
-	case AFE_PORT_ID_USB_RX:
-		return IDX_AFE_PORT_ID_USB_RX;
-	case AFE_PORT_ID_USB_TX:
-		return IDX_AFE_PORT_ID_USB_TX;
-	case AFE_PORT_ID_INT0_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT0_MI2S_RX;
-	case AFE_PORT_ID_INT0_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT0_MI2S_TX;
-	case AFE_PORT_ID_INT1_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT1_MI2S_RX;
-	case AFE_PORT_ID_INT1_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT1_MI2S_TX;
-	case AFE_PORT_ID_INT2_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT2_MI2S_RX;
-	case AFE_PORT_ID_INT2_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT2_MI2S_TX;
-	case AFE_PORT_ID_INT3_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT3_MI2S_RX;
-	case AFE_PORT_ID_INT3_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT3_MI2S_TX;
-	case AFE_PORT_ID_INT4_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT4_MI2S_RX;
-	case AFE_PORT_ID_INT4_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT4_MI2S_TX;
-	case AFE_PORT_ID_INT5_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT5_MI2S_RX;
-	case AFE_PORT_ID_INT5_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT5_MI2S_TX;
-	case AFE_PORT_ID_INT6_MI2S_RX:
-		return IDX_AFE_PORT_ID_INT6_MI2S_RX;
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		return IDX_AFE_PORT_ID_INT6_MI2S_TX;
-	default: return -EINVAL;
-	}
-}
-
-int q6audio_get_port_id(u16 port_id)
-{
-	switch (port_id) {
-	case PRIMARY_I2S_RX: return PRIMARY_I2S_RX;
-	case PRIMARY_I2S_TX: return PRIMARY_I2S_TX;
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-			return AFE_PORT_ID_PRIMARY_PCM_RX;
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-			return AFE_PORT_ID_PRIMARY_PCM_TX;
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-			return AFE_PORT_ID_SECONDARY_PCM_RX;
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-			return AFE_PORT_ID_SECONDARY_PCM_TX;
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-			return AFE_PORT_ID_TERTIARY_PCM_RX;
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-			return AFE_PORT_ID_TERTIARY_PCM_TX;
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-			return AFE_PORT_ID_QUATERNARY_PCM_RX;
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-			return AFE_PORT_ID_QUATERNARY_PCM_TX;
-	case SECONDARY_I2S_RX: return AFE_PORT_ID_SECONDARY_MI2S_RX;
-	case SECONDARY_I2S_TX: return AFE_PORT_ID_SECONDARY_MI2S_TX;
-	case MI2S_RX: return AFE_PORT_ID_PRIMARY_MI2S_RX;
-	case MI2S_TX: return AFE_PORT_ID_PRIMARY_MI2S_TX;
-	case HDMI_RX: return AFE_PORT_ID_MULTICHAN_HDMI_RX;
-	case DISPLAY_PORT_RX:
-			return AFE_PORT_ID_HDMI_OVER_DP_RX;
-	case AFE_PORT_ID_SPDIF_RX: return AFE_PORT_ID_SPDIF_RX;
-	case RSVD_2: return IDX_RSVD_2;
-	case RSVD_3: return IDX_RSVD_3;
-	case DIGI_MIC_TX: return AFE_PORT_ID_DIGITAL_MIC_TX;
-	case VOICE_RECORD_RX: return AFE_PORT_ID_VOICE_RECORD_RX;
-	case VOICE_RECORD_TX: return AFE_PORT_ID_VOICE_RECORD_TX;
-	case VOICE_PLAYBACK_TX: return AFE_PORT_ID_VOICE_PLAYBACK_TX;
-	case VOICE2_PLAYBACK_TX: return AFE_PORT_ID_VOICE2_PLAYBACK_TX;
-	case SLIMBUS_0_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX;
-	case SLIMBUS_0_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX;
-	case SLIMBUS_1_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX;
-	case SLIMBUS_1_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX;
-	case SLIMBUS_2_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX;
-	case SLIMBUS_2_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX;
-	case SLIMBUS_3_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX;
-	case SLIMBUS_3_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX;
-	case SLIMBUS_4_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX;
-	case SLIMBUS_4_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX;
-	case SLIMBUS_5_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX;
-	case SLIMBUS_5_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX;
-	case SLIMBUS_6_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX;
-	case SLIMBUS_6_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX;
-	case SLIMBUS_7_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_RX;
-	case SLIMBUS_7_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_TX;
-	case SLIMBUS_8_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_RX;
-	case SLIMBUS_8_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_TX;
-	case INT_BT_SCO_RX: return AFE_PORT_ID_INTERNAL_BT_SCO_RX;
-	case INT_BT_SCO_TX: return AFE_PORT_ID_INTERNAL_BT_SCO_TX;
-	case INT_BT_A2DP_RX: return AFE_PORT_ID_INTERNAL_BT_A2DP_RX;
-	case INT_FM_RX: return AFE_PORT_ID_INTERNAL_FM_RX;
-	case INT_FM_TX: return AFE_PORT_ID_INTERNAL_FM_TX;
-	case RT_PROXY_PORT_001_RX: return AFE_PORT_ID_RT_PROXY_PORT_001_RX;
-	case RT_PROXY_PORT_001_TX: return AFE_PORT_ID_RT_PROXY_PORT_001_TX;
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-			return AFE_PORT_ID_PRIMARY_MI2S_RX;
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-			return AFE_PORT_ID_PRIMARY_MI2S_TX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-			return AFE_PORT_ID_QUATERNARY_MI2S_RX;
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-			return AFE_PORT_ID_QUATERNARY_MI2S_TX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-			return AFE_PORT_ID_SECONDARY_MI2S_RX;
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-			return AFE_PORT_ID_SECONDARY_MI2S_TX;
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-			return AFE_PORT_ID_TERTIARY_MI2S_RX;
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-			return AFE_PORT_ID_TERTIARY_MI2S_TX;
-	case AUDIO_PORT_ID_I2S_RX:
-			return AUDIO_PORT_ID_I2S_RX;
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-			return AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-		return AFE_PORT_ID_PRIMARY_TDM_RX;
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-		return AFE_PORT_ID_PRIMARY_TDM_TX;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_1;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_2;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_3;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_4;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_5;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_6;
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-		return AFE_PORT_ID_PRIMARY_TDM_RX_7;
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-		return AFE_PORT_ID_PRIMARY_TDM_TX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-		return AFE_PORT_ID_SECONDARY_TDM_RX;
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-		return AFE_PORT_ID_SECONDARY_TDM_TX;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_1;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_2;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_3;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_4;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_5;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_6;
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-		return AFE_PORT_ID_SECONDARY_TDM_RX_7;
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-		return AFE_PORT_ID_SECONDARY_TDM_TX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-		return AFE_PORT_ID_TERTIARY_TDM_RX;
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-		return AFE_PORT_ID_TERTIARY_TDM_TX;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_1;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_2;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_3;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_4;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_5;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_6;
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-		return AFE_PORT_ID_TERTIARY_TDM_RX_7;
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-		return AFE_PORT_ID_TERTIARY_TDM_TX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_1;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_2;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_3;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_4;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_5;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_6;
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-		return AFE_PORT_ID_QUATERNARY_TDM_RX_7;
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-		return AFE_PORT_ID_QUATERNARY_TDM_TX_7;
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-		return AFE_PORT_ID_SENARY_MI2S_TX;
-	case AFE_PORT_ID_USB_RX:
-		return AFE_PORT_ID_USB_RX;
-	case AFE_PORT_ID_USB_TX:
-		return AFE_PORT_ID_USB_TX;
-	case AFE_PORT_ID_INT0_MI2S_RX:
-		return AFE_PORT_ID_INT0_MI2S_RX;
-	case AFE_PORT_ID_INT0_MI2S_TX:
-		return AFE_PORT_ID_INT0_MI2S_TX;
-	case AFE_PORT_ID_INT1_MI2S_RX:
-		return AFE_PORT_ID_INT1_MI2S_RX;
-	case AFE_PORT_ID_INT1_MI2S_TX:
-		return AFE_PORT_ID_INT1_MI2S_TX;
-	case AFE_PORT_ID_INT2_MI2S_RX:
-		return AFE_PORT_ID_INT2_MI2S_RX;
-	case AFE_PORT_ID_INT2_MI2S_TX:
-		return AFE_PORT_ID_INT2_MI2S_TX;
-	case AFE_PORT_ID_INT3_MI2S_RX:
-		return AFE_PORT_ID_INT3_MI2S_RX;
-	case AFE_PORT_ID_INT3_MI2S_TX:
-		return AFE_PORT_ID_INT3_MI2S_TX;
-	case AFE_PORT_ID_INT4_MI2S_RX:
-		return AFE_PORT_ID_INT4_MI2S_RX;
-	case AFE_PORT_ID_INT4_MI2S_TX:
-		return AFE_PORT_ID_INT4_MI2S_TX;
-	case AFE_PORT_ID_INT5_MI2S_RX:
-		return AFE_PORT_ID_INT5_MI2S_RX;
-	case AFE_PORT_ID_INT5_MI2S_TX:
-		return AFE_PORT_ID_INT5_MI2S_TX;
-	case AFE_PORT_ID_INT6_MI2S_RX:
-		return AFE_PORT_ID_INT6_MI2S_RX;
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		return AFE_PORT_ID_INT6_MI2S_TX;
-	default:
-		pr_warn("%s: Invalid port_id %d\n", __func__, port_id);
-		return -EINVAL;
-	}
-}
-int q6audio_convert_virtual_to_portid(u16 port_id)
-{
-	int ret;
-
-	/* if port_id is virtual, convert to physical..
-	 * if port_id is already physical, return physical
-	 */
-	if (q6audio_validate_port(port_id) < 0) {
-		if (port_id == RT_PROXY_DAI_001_RX ||
-			port_id == RT_PROXY_DAI_001_TX ||
-			port_id == RT_PROXY_DAI_002_RX ||
-			port_id == RT_PROXY_DAI_002_TX)
-			ret = VIRTUAL_ID_TO_PORTID(port_id);
-		else
-			ret = -EINVAL;
-	} else
-		ret = port_id;
-
-	return ret;
-}
-
-int q6audio_is_digital_pcm_interface(u16 port_id)
-{
-	int ret = 0;
-
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-	case AUDIO_PORT_ID_I2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-	case AFE_PORT_ID_INT0_MI2S_RX:
-	case AFE_PORT_ID_INT0_MI2S_TX:
-	case AFE_PORT_ID_INT1_MI2S_RX:
-	case AFE_PORT_ID_INT1_MI2S_TX:
-	case AFE_PORT_ID_INT2_MI2S_RX:
-	case AFE_PORT_ID_INT2_MI2S_TX:
-	case AFE_PORT_ID_INT3_MI2S_RX:
-	case AFE_PORT_ID_INT3_MI2S_TX:
-	case AFE_PORT_ID_INT4_MI2S_RX:
-	case AFE_PORT_ID_INT4_MI2S_TX:
-	case AFE_PORT_ID_INT5_MI2S_RX:
-	case AFE_PORT_ID_INT5_MI2S_TX:
-	case AFE_PORT_ID_INT6_MI2S_RX:
-	case AFE_PORT_ID_INT6_MI2S_TX:
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-int q6audio_validate_port(u16 port_id)
-{
-	int ret;
-
-	switch (port_id) {
-	case PRIMARY_I2S_RX:
-	case PRIMARY_I2S_TX:
-	case AFE_PORT_ID_PRIMARY_PCM_RX:
-	case AFE_PORT_ID_PRIMARY_PCM_TX:
-	case AFE_PORT_ID_SECONDARY_PCM_RX:
-	case AFE_PORT_ID_SECONDARY_PCM_TX:
-	case AFE_PORT_ID_TERTIARY_PCM_RX:
-	case AFE_PORT_ID_TERTIARY_PCM_TX:
-	case AFE_PORT_ID_QUATERNARY_PCM_RX:
-	case AFE_PORT_ID_QUATERNARY_PCM_TX:
-	case SECONDARY_I2S_RX:
-	case SECONDARY_I2S_TX:
-	case MI2S_RX:
-	case MI2S_TX:
-	case HDMI_RX:
-	case DISPLAY_PORT_RX:
-	case RSVD_2:
-	case RSVD_3:
-	case DIGI_MIC_TX:
-	case VOICE_RECORD_RX:
-	case VOICE_RECORD_TX:
-	case VOICE_PLAYBACK_TX:
-	case VOICE2_PLAYBACK_TX:
-	case SLIMBUS_0_RX:
-	case SLIMBUS_0_TX:
-	case SLIMBUS_1_RX:
-	case SLIMBUS_1_TX:
-	case SLIMBUS_2_RX:
-	case SLIMBUS_2_TX:
-	case SLIMBUS_3_RX:
-	case SLIMBUS_3_TX:
-	case SLIMBUS_4_RX:
-	case SLIMBUS_4_TX:
-	case SLIMBUS_5_RX:
-	case SLIMBUS_5_TX:
-	case SLIMBUS_6_RX:
-	case SLIMBUS_6_TX:
-	case SLIMBUS_7_RX:
-	case SLIMBUS_7_TX:
-	case SLIMBUS_8_RX:
-	case SLIMBUS_8_TX:
-	case INT_BT_SCO_RX:
-	case INT_BT_SCO_TX:
-	case INT_BT_A2DP_RX:
-	case INT_FM_RX:
-	case INT_FM_TX:
-	case RT_PROXY_PORT_001_RX:
-	case RT_PROXY_PORT_001_TX:
-	case AFE_PORT_ID_PRIMARY_MI2S_RX:
-	case AFE_PORT_ID_PRIMARY_MI2S_TX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_RX:
-	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX:
-	case AFE_PORT_ID_SECONDARY_MI2S_TX:
-	case AFE_PORT_ID_SPDIF_RX:
-	case AFE_PORT_ID_TERTIARY_MI2S_RX:
-	case AFE_PORT_ID_TERTIARY_MI2S_TX:
-	case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
-	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
-	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_1:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_2:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_3:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_4:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_5:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_6:
-	case AFE_PORT_ID_SECONDARY_TDM_RX_7:
-	case AFE_PORT_ID_SECONDARY_TDM_TX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_1:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_2:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_3:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_4:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_5:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_6:
-	case AFE_PORT_ID_TERTIARY_TDM_RX_7:
-	case AFE_PORT_ID_TERTIARY_TDM_TX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
-	case AFE_PORT_ID_SENARY_MI2S_TX:
-	case AFE_PORT_ID_USB_RX:
-	case AFE_PORT_ID_USB_TX:
-	case AFE_PORT_ID_INT0_MI2S_RX:
-	case AFE_PORT_ID_INT0_MI2S_TX:
-	case AFE_PORT_ID_INT1_MI2S_RX:
-	case AFE_PORT_ID_INT1_MI2S_TX:
-	case AFE_PORT_ID_INT2_MI2S_RX:
-	case AFE_PORT_ID_INT2_MI2S_TX:
-	case AFE_PORT_ID_INT3_MI2S_RX:
-	case AFE_PORT_ID_INT3_MI2S_TX:
-	case AFE_PORT_ID_INT4_MI2S_RX:
-	case AFE_PORT_ID_INT4_MI2S_TX:
-	case AFE_PORT_ID_INT5_MI2S_RX:
-	case AFE_PORT_ID_INT5_MI2S_TX:
-	case AFE_PORT_ID_INT6_MI2S_RX:
-	case AFE_PORT_ID_INT6_MI2S_TX:
-	{
-		ret = 0;
-		break;
-	}
-
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
diff --git a/sound/soc/msm/qdsp6v2/q6core.c b/sound/soc/msm/qdsp6v2/q6core.c
deleted file mode 100644
index d806004..0000000
--- a/sound/soc/msm/qdsp6v2/q6core.c
+++ /dev/null
@@ -1,1095 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/qdsp6v2/apr.h>
-#include <sound/q6core.h>
-#include <sound/audio_cal_utils.h>
-#include <sound/adsp_err.h>
-#include <sound/apr_audio-v2.h>
-
-#define TIMEOUT_MS 1000
-/*
- * AVS bring up in the modem is optimitized for the new
- * Sub System Restart design and 100 milliseconds timeout
- * is sufficient to make sure the Q6 will be ready.
- */
-#define Q6_READY_TIMEOUT_MS 100
-
-enum {
-	META_CAL,
-	CUST_TOP_CAL,
-	CORE_MAX_CAL
-};
-
-enum ver_query_status {
-	VER_QUERY_UNATTEMPTED,
-	VER_QUERY_UNSUPPORTED,
-	VER_QUERY_SUPPORTED
-};
-
-struct q6core_avcs_ver_info {
-	enum ver_query_status status;
-	struct avcs_fwk_ver_info ver_info;
-};
-
-struct q6core_str {
-	struct apr_svc *core_handle_q;
-	wait_queue_head_t bus_bw_req_wait;
-	wait_queue_head_t cmd_req_wait;
-	wait_queue_head_t avcs_fwk_ver_req_wait;
-	u32 bus_bw_resp_received;
-	enum cmd_flags {
-		FLAG_NONE,
-		FLAG_CMDRSP_LICENSE_RESULT
-	} cmd_resp_received_flag;
-	u32 avcs_fwk_ver_resp_received;
-	struct mutex cmd_lock;
-	struct mutex ver_lock;
-	union {
-		struct avcs_cmdrsp_get_license_validation_result
-						cmdrsp_license_result;
-	} cmd_resp_payload;
-	u32 param;
-	struct cal_type_data *cal_data[CORE_MAX_CAL];
-	uint32_t mem_map_cal_handle;
-	int32_t adsp_status;
-	struct q6core_avcs_ver_info q6core_avcs_ver_info;
-};
-
-static struct q6core_str q6core_lcl;
-
-struct generic_get_data_ {
-	int valid;
-	int size_in_ints;
-	int ints[];
-};
-static struct generic_get_data_ *generic_get_data;
-
-static int parse_fwk_version_info(uint32_t *payload)
-{
-	size_t fwk_ver_size;
-	size_t svc_size;
-	int num_services;
-	int ret = 0;
-
-	pr_debug("%s: Payload info num services %d\n",
-		 __func__, payload[4]);
-	/*
-	 * payload1[4] is the number of services running on DSP
-	 * Based on this info, we copy the payload into core
-	 * avcs version info structure.
-	 */
-	num_services = payload[4];
-	q6core_lcl.q6core_avcs_ver_info.ver_info.avcs_fwk_version.
-			num_services = num_services;
-	if (num_services > VSS_MAX_AVCS_NUM_SERVICES) {
-		pr_err("%s: num_services: %d greater than max services: %d\n",
-		       __func__, num_services, VSS_MAX_AVCS_NUM_SERVICES);
-		ret = -EINVAL;
-		goto done;
-	}
-	fwk_ver_size = sizeof(struct avcs_get_fwk_version);
-	svc_size = num_services * sizeof(struct avs_svc_api_info);
-	/*
-	 * Dynamically allocate memory for all
-	 * the services based on num_services
-	 */
-	q6core_lcl.q6core_avcs_ver_info.ver_info.services = NULL;
-	q6core_lcl.q6core_avcs_ver_info.ver_info.services =
-				kzalloc(svc_size, GFP_ATOMIC);
-	if (q6core_lcl.q6core_avcs_ver_info.ver_info.services == NULL) {
-		ret = -ENOMEM;
-		goto done;
-	}
-	/*
-	 * memcpy is done twice because the memory allocated for
-	 * q6core_lcl.q6core_avcs_ver_info.ver_info is not
-	 * contiguous.
-	 */
-	memcpy(&q6core_lcl.q6core_avcs_ver_info.ver_info,
-	       (uint8_t *)payload, fwk_ver_size);
-	memcpy(q6core_lcl.q6core_avcs_ver_info.ver_info.services,
-	       (uint8_t *)&payload[sizeof(struct avcs_get_fwk_version)/
-				   sizeof(uint32_t)], svc_size);
-	ret = 0;
-done:
-	return ret;
-}
-
-static int32_t aprv2_core_fn_q(struct apr_client_data *data, void *priv)
-{
-	uint32_t *payload1;
-	int ret = 0;
-
-	if (data == NULL) {
-		pr_err("%s: data argument is null\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: core msg: payload len = %u, apr resp opcode = 0x%x\n",
-		__func__,
-		data->payload_size, data->opcode);
-
-	switch (data->opcode) {
-
-	case APR_BASIC_RSP_RESULT:{
-
-		if (data->payload_size == 0) {
-			pr_err("%s: APR_BASIC_RSP_RESULT No Payload ",
-					__func__);
-			return 0;
-		}
-
-		payload1 = data->payload;
-
-		switch (payload1[0]) {
-
-		case AVCS_CMD_SHARED_MEM_UNMAP_REGIONS:
-			pr_debug("%s: Cmd = AVCS_CMD_SHARED_MEM_UNMAP_REGIONS status[0x%x]\n",
-				__func__, payload1[1]);
-			q6core_lcl.bus_bw_resp_received = 1;
-			wake_up(&q6core_lcl.bus_bw_req_wait);
-			break;
-		case AVCS_CMD_SHARED_MEM_MAP_REGIONS:
-			pr_debug("%s: Cmd = AVCS_CMD_SHARED_MEM_MAP_REGIONS status[0x%x]\n",
-				__func__, payload1[1]);
-			q6core_lcl.bus_bw_resp_received = 1;
-			wake_up(&q6core_lcl.bus_bw_req_wait);
-			break;
-		case AVCS_CMD_REGISTER_TOPOLOGIES:
-			pr_debug("%s: Cmd = AVCS_CMD_REGISTER_TOPOLOGIES status[0x%x]\n",
-				__func__, payload1[1]);
-			/* -ADSP status to match Linux error standard */
-			q6core_lcl.adsp_status = -payload1[1];
-			q6core_lcl.bus_bw_resp_received = 1;
-			wake_up(&q6core_lcl.bus_bw_req_wait);
-			break;
-		case AVCS_CMD_DEREGISTER_TOPOLOGIES:
-			pr_debug("%s: Cmd = AVCS_CMD_DEREGISTER_TOPOLOGIES status[0x%x]\n",
-				__func__, payload1[1]);
-			q6core_lcl.bus_bw_resp_received = 1;
-			wake_up(&q6core_lcl.bus_bw_req_wait);
-			break;
-		case AVCS_CMD_GET_FWK_VERSION:
-			pr_debug("%s: Cmd = AVCS_CMD_GET_FWK_VERSION status[%s]\n",
-				__func__, adsp_err_get_err_str(payload1[1]));
-			/* ADSP status to match Linux error standard */
-			q6core_lcl.adsp_status = -payload1[1];
-			if (payload1[1] == ADSP_EUNSUPPORTED)
-				q6core_lcl.q6core_avcs_ver_info.status =
-					VER_QUERY_UNSUPPORTED;
-			q6core_lcl.avcs_fwk_ver_resp_received = 1;
-			wake_up(&q6core_lcl.avcs_fwk_ver_req_wait);
-			break;
-		default:
-			pr_err("%s: Invalid cmd rsp[0x%x][0x%x] opcode %d\n",
-					__func__,
-					payload1[0], payload1[1], data->opcode);
-			break;
-		}
-		break;
-	}
-
-	case RESET_EVENTS:{
-		pr_debug("%s: Reset event received in Core service\n",
-			__func__);
-		/* no reset done as the data will not change after SSR*/
-		q6core_lcl.core_handle_q = NULL;
-		break;
-	}
-	case AVCS_CMDRSP_SHARED_MEM_MAP_REGIONS:
-		payload1 = data->payload;
-		pr_debug("%s: AVCS_CMDRSP_SHARED_MEM_MAP_REGIONS handle %d\n",
-			__func__, payload1[0]);
-		q6core_lcl.mem_map_cal_handle = payload1[0];
-		q6core_lcl.bus_bw_resp_received = 1;
-		wake_up(&q6core_lcl.bus_bw_req_wait);
-		break;
-	case AVCS_CMDRSP_ADSP_EVENT_GET_STATE:
-		payload1 = data->payload;
-		q6core_lcl.param = payload1[0];
-		pr_debug("%s: Received ADSP get state response 0x%x\n",
-			 __func__, q6core_lcl.param);
-		/* ensure .param is updated prior to .bus_bw_resp_received */
-		wmb();
-		q6core_lcl.bus_bw_resp_received = 1;
-		wake_up(&q6core_lcl.bus_bw_req_wait);
-		break;
-	case AVCS_CMDRSP_GET_LICENSE_VALIDATION_RESULT:
-		payload1 = data->payload;
-		pr_debug("%s: cmd = LICENSE_VALIDATION_RESULT, result = 0x%x\n",
-				__func__, payload1[0]);
-		q6core_lcl.cmd_resp_payload.cmdrsp_license_result.result
-								= payload1[0];
-		q6core_lcl.cmd_resp_received_flag = FLAG_CMDRSP_LICENSE_RESULT;
-		wake_up(&q6core_lcl.cmd_req_wait);
-		break;
-	case AVCS_CMDRSP_GET_FWK_VERSION:
-		pr_debug("%s: Received AVCS_CMDRSP_GET_FWK_VERSION\n",
-			 __func__);
-		payload1 = data->payload;
-		q6core_lcl.q6core_avcs_ver_info.status = VER_QUERY_SUPPORTED;
-		q6core_lcl.avcs_fwk_ver_resp_received = 1;
-		ret = parse_fwk_version_info(payload1);
-		if (ret < 0)
-			pr_err("%s: Failed to parse payload:%d\n",
-			       __func__, ret);
-		wake_up(&q6core_lcl.avcs_fwk_ver_req_wait);
-		break;
-	default:
-		pr_err("%s: Message id from adsp core svc: 0x%x\n",
-			__func__, data->opcode);
-		if (generic_get_data) {
-			generic_get_data->valid = 1;
-			generic_get_data->size_in_ints =
-				data->payload_size/sizeof(int);
-			pr_debug("callback size = %i\n",
-				 data->payload_size);
-			memcpy(generic_get_data->ints, data->payload,
-				data->payload_size);
-			q6core_lcl.bus_bw_resp_received = 1;
-			wake_up(&q6core_lcl.bus_bw_req_wait);
-			break;
-		}
-		break;
-	}
-
-	return 0;
-}
-
-void ocm_core_open(void)
-{
-	if (q6core_lcl.core_handle_q == NULL)
-		q6core_lcl.core_handle_q = apr_register("ADSP", "CORE",
-					aprv2_core_fn_q, 0xFFFFFFFF, NULL);
-	pr_debug("%s: Open_q %pK\n", __func__, q6core_lcl.core_handle_q);
-	if (q6core_lcl.core_handle_q == NULL)
-		pr_err("%s: Unable to register CORE\n", __func__);
-}
-
-struct cal_block_data *cal_utils_get_cal_block_by_key(
-		struct cal_type_data *cal_type, uint32_t key)
-{
-	struct list_head                *ptr, *next;
-	struct cal_block_data           *cal_block = NULL;
-	struct audio_cal_info_metainfo  *metainfo;
-
-	list_for_each_safe(ptr, next,
-		&cal_type->cal_blocks) {
-
-		cal_block = list_entry(ptr,
-			struct cal_block_data, list);
-		metainfo = (struct audio_cal_info_metainfo *)
-			cal_block->cal_info;
-		if (metainfo->nKey != key) {
-			pr_debug("%s: metainfo key mismatch!!! found:%x, needed:%x\n",
-				__func__, metainfo->nKey, key);
-		} else {
-			pr_debug("%s: metainfo key match found", __func__);
-			return cal_block;
-		}
-	}
-	return NULL;
-}
-
-static int q6core_send_get_avcs_fwk_ver_cmd(void)
-{
-	struct apr_hdr avcs_ver_cmd;
-	int ret;
-
-	avcs_ver_cmd.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
-			      APR_PKT_VER);
-	avcs_ver_cmd.pkt_size = sizeof(struct apr_hdr);
-	avcs_ver_cmd.src_port = 0;
-	avcs_ver_cmd.dest_port = 0;
-	avcs_ver_cmd.token = 0;
-	avcs_ver_cmd.opcode = AVCS_CMD_GET_FWK_VERSION;
-
-	q6core_lcl.adsp_status = 0;
-	q6core_lcl.avcs_fwk_ver_resp_received = 0;
-
-	ret = apr_send_pkt(q6core_lcl.core_handle_q,
-			   (uint32_t *) &avcs_ver_cmd);
-	if (ret < 0) {
-		pr_err("%s: failed to send apr packet, ret=%d\n", __func__,
-		       ret);
-		goto done;
-	}
-
-	ret = wait_event_timeout(q6core_lcl.avcs_fwk_ver_req_wait,
-				 (q6core_lcl.avcs_fwk_ver_resp_received == 1),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout for AVCS fwk version info\n",
-		       __func__);
-		ret = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (q6core_lcl.adsp_status < 0) {
-		/*
-		 * adsp_err_get_err_str expects a positive value but we store
-		 * the DSP error as negative to match the Linux error standard.
-		 * Pass in the negated value so adsp_err_get_err_str returns
-		 * the correct string.
-		 */
-		pr_err("%s: DSP returned error[%s]\n", __func__,
-		       adsp_err_get_err_str(-q6core_lcl.adsp_status));
-		ret = adsp_err_get_lnx_err_code(q6core_lcl.adsp_status);
-		goto done;
-	}
-
-	ret = 0;
-
-done:
-	return ret;
-}
-
-int q6core_get_service_version(uint32_t service_id,
-			       struct avcs_fwk_ver_info *ver_info,
-			       size_t size)
-{
-	int i;
-	uint32_t num_services;
-	size_t svc_size;
-
-	svc_size = q6core_get_avcs_service_size(service_id);
-	if (svc_size != size) {
-		pr_err("%s: Expected size: %zu, Provided size: %zu",
-		       __func__, svc_size, size);
-		return -EINVAL;
-	}
-
-	num_services =
-		q6core_lcl.q6core_avcs_ver_info.ver_info.
-		avcs_fwk_version.num_services;
-
-	if (ver_info == NULL) {
-		pr_err("%s: NULL parameter ver_info\n", __func__);
-		return -EINVAL;
-	}
-
-	memcpy(ver_info, &q6core_lcl.q6core_avcs_ver_info.
-	       ver_info.avcs_fwk_version, sizeof(struct avcs_get_fwk_version));
-
-	if (service_id == AVCS_SERVICE_ID_ALL) {
-		memcpy(&ver_info->services[0], &q6core_lcl.
-		       q6core_avcs_ver_info.ver_info.services[0],
-		       (num_services * sizeof(struct avs_svc_api_info)));
-	} else {
-		for (i = 0; i < num_services; i++) {
-			if (q6core_lcl.q6core_avcs_ver_info.
-			    ver_info.services[i].service_id == service_id) {
-				memcpy(&ver_info->services[0],
-				       &q6core_lcl.q6core_avcs_ver_info.
-				       ver_info.services[i], size);
-				break;
-			}
-		}
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(q6core_get_service_version);
-
-size_t q6core_get_avcs_service_size(uint32_t service_id)
-{
-	int ret = 0;
-	uint32_t num_services;
-
-	num_services =
-		q6core_lcl.q6core_avcs_ver_info.ver_info.
-		avcs_fwk_version.num_services;
-
-	mutex_lock(&(q6core_lcl.ver_lock));
-	pr_debug("%s: q6core_avcs_ver_info.status(%d)\n", __func__,
-		 q6core_lcl.q6core_avcs_ver_info.status);
-
-	switch (q6core_lcl.q6core_avcs_ver_info.status) {
-	case VER_QUERY_SUPPORTED:
-		pr_debug("%s: AVCS FWK version query already attempted\n",
-			 __func__);
-		ret = num_services * sizeof(struct avs_svc_api_info);
-		break;
-	case VER_QUERY_UNSUPPORTED:
-		ret = -EOPNOTSUPP;
-		break;
-	case VER_QUERY_UNATTEMPTED:
-		pr_debug("%s: Attempting AVCS FWK version query\n", __func__);
-		if (q6core_is_adsp_ready()) {
-			ret = q6core_send_get_avcs_fwk_ver_cmd();
-			if (ret == 0)
-				ret = num_services *
-				      sizeof(struct avs_svc_api_info);
-		} else {
-			pr_err("%s: ADSP is not ready to query version\n",
-			       __func__);
-			ret = -ENODEV;
-		}
-		break;
-	default:
-		pr_err("%s: Invalid version query status %d\n", __func__,
-		       q6core_lcl.q6core_avcs_ver_info.status);
-		ret = -EINVAL;
-		break;
-	}
-	mutex_unlock(&(q6core_lcl.ver_lock));
-
-	if (service_id != AVCS_SERVICE_ID_ALL)
-		return sizeof(struct avs_svc_api_info);
-
-	return ret;
-}
-EXPORT_SYMBOL(q6core_get_avcs_service_size);
-
-int32_t core_set_license(uint32_t key, uint32_t module_id)
-{
-	struct avcs_cmd_set_license *cmd_setl = NULL;
-	struct cal_block_data *cal_block = NULL;
-	int rc = 0, packet_size = 0;
-
-	pr_debug("%s: key:0x%x, id:0x%x\n", __func__, key, module_id);
-
-	mutex_lock(&(q6core_lcl.cmd_lock));
-	if (q6core_lcl.cal_data[META_CAL] == NULL) {
-		pr_err("%s: cal_data not initialized yet!!\n", __func__);
-		rc = -EINVAL;
-		goto cmd_unlock;
-	}
-
-	mutex_lock(&((q6core_lcl.cal_data[META_CAL])->lock));
-	cal_block = cal_utils_get_cal_block_by_key(
-				q6core_lcl.cal_data[META_CAL], key);
-	if (cal_block == NULL ||
-		cal_block->cal_data.kvaddr == NULL ||
-		cal_block->cal_data.size <= 0) {
-		pr_err("%s: Invalid cal block to send", __func__);
-		rc = -EINVAL;
-		goto cal_data_unlock;
-	}
-
-	packet_size = sizeof(struct avcs_cmd_set_license) +
-					cal_block->cal_data.size;
-	/*round up total packet_size to next 4 byte boundary*/
-	packet_size = ((packet_size + 0x3)>>2)<<2;
-
-	cmd_setl = kzalloc(packet_size, GFP_KERNEL);
-	if (cmd_setl == NULL) {
-		rc  = -ENOMEM;
-		goto cal_data_unlock;
-	}
-
-	ocm_core_open();
-	if (q6core_lcl.core_handle_q == NULL) {
-		pr_err("%s: apr registration for CORE failed\n", __func__);
-		rc  = -ENODEV;
-		goto fail_cmd;
-	}
-
-	cmd_setl->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_EVENT,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cmd_setl->hdr.pkt_size = packet_size;
-	cmd_setl->hdr.src_port = 0;
-	cmd_setl->hdr.dest_port = 0;
-	cmd_setl->hdr.token = 0;
-	cmd_setl->hdr.opcode = AVCS_CMD_SET_LICENSE;
-	cmd_setl->id = module_id;
-	cmd_setl->overwrite = 1;
-	cmd_setl->size = cal_block->cal_data.size;
-	memcpy((uint8_t *)cmd_setl + sizeof(struct avcs_cmd_set_license),
-		cal_block->cal_data.kvaddr,
-		cal_block->cal_data.size);
-	pr_info("%s: Set license opcode=0x%x, id =0x%x, size = %d\n",
-			__func__, cmd_setl->hdr.opcode,
-			cmd_setl->id, cmd_setl->size);
-	rc = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *)cmd_setl);
-	if (rc < 0)
-		pr_err("%s: SET_LICENSE failed op[0x%x]rc[%d]\n",
-					__func__, cmd_setl->hdr.opcode, rc);
-
-fail_cmd:
-	kfree(cmd_setl);
-cal_data_unlock:
-	mutex_unlock(&((q6core_lcl.cal_data[META_CAL])->lock));
-cmd_unlock:
-	mutex_unlock(&(q6core_lcl.cmd_lock));
-
-	return rc;
-}
-
-int32_t core_get_license_status(uint32_t module_id)
-{
-	struct avcs_cmd_get_license_validation_result get_lvr_cmd;
-	int ret = 0;
-
-	pr_debug("%s: module_id 0x%x", __func__, module_id);
-
-	mutex_lock(&(q6core_lcl.cmd_lock));
-	ocm_core_open();
-	if (q6core_lcl.core_handle_q == NULL) {
-		pr_err("%s: apr registration for CORE failed\n", __func__);
-		ret  = -ENODEV;
-		goto fail_cmd;
-	}
-
-	get_lvr_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	get_lvr_cmd.hdr.pkt_size =
-		sizeof(struct avcs_cmd_get_license_validation_result);
-
-	get_lvr_cmd.hdr.src_port = 0;
-	get_lvr_cmd.hdr.dest_port = 0;
-	get_lvr_cmd.hdr.token = 0;
-	get_lvr_cmd.hdr.opcode = AVCS_CMD_GET_LICENSE_VALIDATION_RESULT;
-	get_lvr_cmd.id = module_id;
-
-
-	ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *) &get_lvr_cmd);
-	if (ret < 0) {
-		pr_err("%s: license_validation request failed, err %d\n",
-							__func__, ret);
-		ret = -EREMOTE;
-		goto fail_cmd;
-	}
-
-	q6core_lcl.cmd_resp_received_flag &= ~(FLAG_CMDRSP_LICENSE_RESULT);
-	mutex_unlock(&(q6core_lcl.cmd_lock));
-	ret = wait_event_timeout(q6core_lcl.cmd_req_wait,
-			(q6core_lcl.cmd_resp_received_flag ==
-				FLAG_CMDRSP_LICENSE_RESULT),
-				msecs_to_jiffies(TIMEOUT_MS));
-	mutex_lock(&(q6core_lcl.cmd_lock));
-	if (!ret) {
-		pr_err("%s: wait_event timeout for CMDRSP_LICENSE_RESULT\n",
-				__func__);
-		ret = -ETIME;
-		goto fail_cmd;
-	}
-	q6core_lcl.cmd_resp_received_flag &= ~(FLAG_CMDRSP_LICENSE_RESULT);
-	ret = q6core_lcl.cmd_resp_payload.cmdrsp_license_result.result;
-
-fail_cmd:
-	mutex_unlock(&(q6core_lcl.cmd_lock));
-	pr_info("%s: cmdrsp_license_result.result = 0x%x for module 0x%x\n",
-				__func__, ret, module_id);
-	return ret;
-}
-
-uint32_t core_set_dolby_manufacturer_id(int manufacturer_id)
-{
-	struct adsp_dolby_manufacturer_id payload;
-	int rc = 0;
-
-	pr_debug("%s: manufacturer_id :%d\n", __func__, manufacturer_id);
-	mutex_lock(&(q6core_lcl.cmd_lock));
-	ocm_core_open();
-	if (q6core_lcl.core_handle_q) {
-		payload.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_EVENT,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		payload.hdr.pkt_size =
-			sizeof(struct adsp_dolby_manufacturer_id);
-		payload.hdr.src_port = 0;
-		payload.hdr.dest_port = 0;
-		payload.hdr.token = 0;
-		payload.hdr.opcode = ADSP_CMD_SET_DOLBY_MANUFACTURER_ID;
-		payload.manufacturer_id = manufacturer_id;
-		pr_debug("%s: Send Dolby security opcode=0x%x manufacturer ID = %d\n",
-			__func__,
-			payload.hdr.opcode, payload.manufacturer_id);
-		rc = apr_send_pkt(q6core_lcl.core_handle_q,
-						(uint32_t *)&payload);
-		if (rc < 0)
-			pr_err("%s: SET_DOLBY_MANUFACTURER_ID failed op[0x%x]rc[%d]\n",
-				__func__, payload.hdr.opcode, rc);
-	}
-	mutex_unlock(&(q6core_lcl.cmd_lock));
-	return rc;
-}
-
-/**
- * q6core_is_adsp_ready - check adsp ready status
- *
- * Returns true if adsp is ready otherwise returns false
- */
-bool q6core_is_adsp_ready(void)
-{
-	int rc = 0;
-	bool ret = false;
-	struct apr_hdr hdr;
-
-	pr_debug("%s: enter\n", __func__);
-	memset(&hdr, 0, sizeof(hdr));
-	hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				      APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, 0);
-	hdr.opcode = AVCS_CMD_ADSP_EVENT_GET_STATE;
-
-	mutex_lock(&(q6core_lcl.cmd_lock));
-	ocm_core_open();
-	if (q6core_lcl.core_handle_q) {
-		q6core_lcl.bus_bw_resp_received = 0;
-		rc = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *)&hdr);
-		if (rc < 0) {
-			pr_err("%s: Get ADSP state APR packet send event %d\n",
-				__func__, rc);
-			goto bail;
-		}
-
-		rc = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
-					(q6core_lcl.bus_bw_resp_received == 1),
-					msecs_to_jiffies(Q6_READY_TIMEOUT_MS));
-		if (rc > 0 && q6core_lcl.bus_bw_resp_received) {
-			/* ensure to read updated param by callback thread */
-			rmb();
-			ret = !!q6core_lcl.param;
-		}
-	}
-bail:
-	pr_debug("%s: leave, rc %d, adsp ready %d\n", __func__, rc, ret);
-	mutex_unlock(&(q6core_lcl.cmd_lock));
-	return ret;
-}
-EXPORT_SYMBOL(q6core_is_adsp_ready);
-
-static int q6core_map_memory_regions(phys_addr_t *buf_add, uint32_t mempool_id,
-			uint32_t *bufsz, uint32_t bufcnt, uint32_t *map_handle)
-{
-	struct avs_cmd_shared_mem_map_regions *mmap_regions = NULL;
-	struct avs_shared_map_region_payload *mregions = NULL;
-	void *mmap_region_cmd = NULL;
-	void *payload = NULL;
-	int ret = 0;
-	int i = 0;
-	int cmd_size = 0;
-
-	cmd_size = sizeof(struct avs_cmd_shared_mem_map_regions)
-			+ sizeof(struct avs_shared_map_region_payload)
-			* bufcnt;
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (mmap_region_cmd == NULL)
-		return -ENOMEM;
-
-	mmap_regions = (struct avs_cmd_shared_mem_map_regions *)mmap_region_cmd;
-	mmap_regions->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-								APR_PKT_VER);
-	mmap_regions->hdr.pkt_size = cmd_size;
-	mmap_regions->hdr.src_port = 0;
-	mmap_regions->hdr.dest_port = 0;
-	mmap_regions->hdr.token = 0;
-	mmap_regions->hdr.opcode = AVCS_CMD_SHARED_MEM_MAP_REGIONS;
-	mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL & 0x00ff;
-	mmap_regions->num_regions = bufcnt & 0x00ff;
-	mmap_regions->property_flag = 0x00;
-
-	payload = ((u8 *) mmap_region_cmd +
-				sizeof(struct avs_cmd_shared_mem_map_regions));
-	mregions = (struct avs_shared_map_region_payload *)payload;
-
-	for (i = 0; i < bufcnt; i++) {
-		mregions->shm_addr_lsw = lower_32_bits(buf_add[i]);
-		mregions->shm_addr_msw =
-				msm_audio_populate_upper_32_bits(buf_add[i]);
-		mregions->mem_size_bytes = bufsz[i];
-		++mregions;
-	}
-
-	pr_debug("%s: sending memory map, addr %pK, size %d, bufcnt = %d\n",
-		__func__, buf_add, bufsz[0], mmap_regions->num_regions);
-
-	*map_handle = 0;
-	q6core_lcl.bus_bw_resp_received = 0;
-	ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *)
-		mmap_regions);
-	if (ret < 0) {
-		pr_err("%s: mmap regions failed %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
-				(q6core_lcl.bus_bw_resp_received == 1),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: timeout. waited for memory map\n", __func__);
-		ret = -ETIME;
-		goto done;
-	}
-
-	*map_handle = q6core_lcl.mem_map_cal_handle;
-done:
-	kfree(mmap_region_cmd);
-	return ret;
-}
-
-static int q6core_memory_unmap_regions(uint32_t mem_map_handle)
-{
-	struct avs_cmd_shared_mem_unmap_regions unmap_regions;
-	int ret = 0;
-
-	memset(&unmap_regions, 0, sizeof(unmap_regions));
-	unmap_regions.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	unmap_regions.hdr.pkt_size = sizeof(unmap_regions);
-	unmap_regions.hdr.src_svc = APR_SVC_ADSP_CORE;
-	unmap_regions.hdr.src_domain = APR_DOMAIN_APPS;
-	unmap_regions.hdr.src_port = 0;
-	unmap_regions.hdr.dest_svc = APR_SVC_ADSP_CORE;
-	unmap_regions.hdr.dest_domain = APR_DOMAIN_ADSP;
-	unmap_regions.hdr.dest_port = 0;
-	unmap_regions.hdr.token = 0;
-	unmap_regions.hdr.opcode = AVCS_CMD_SHARED_MEM_UNMAP_REGIONS;
-	unmap_regions.mem_map_handle = mem_map_handle;
-
-	q6core_lcl.bus_bw_resp_received = 0;
-
-	pr_debug("%s: unmap regions map handle %d\n",
-		__func__, mem_map_handle);
-
-	ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *)
-		&unmap_regions);
-	if (ret < 0) {
-		pr_err("%s: unmap regions failed %d\n",
-			__func__, ret);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
-				(q6core_lcl.bus_bw_resp_received == 1),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: timeout. waited for memory_unmap\n",
-		       __func__);
-		ret = -ETIME;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6core_dereg_all_custom_topologies(void)
-{
-	int ret = 0;
-	struct avcs_cmd_deregister_topologies dereg_top;
-
-	memset(&dereg_top, 0, sizeof(dereg_top));
-	dereg_top.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	dereg_top.hdr.pkt_size = sizeof(dereg_top);
-	dereg_top.hdr.src_svc = APR_SVC_ADSP_CORE;
-	dereg_top.hdr.src_domain = APR_DOMAIN_APPS;
-	dereg_top.hdr.src_port = 0;
-	dereg_top.hdr.dest_svc = APR_SVC_ADSP_CORE;
-	dereg_top.hdr.dest_domain = APR_DOMAIN_ADSP;
-	dereg_top.hdr.dest_port = 0;
-	dereg_top.hdr.token = 0;
-	dereg_top.hdr.opcode = AVCS_CMD_DEREGISTER_TOPOLOGIES;
-	dereg_top.payload_addr_lsw = 0;
-	dereg_top.payload_addr_msw = 0;
-	dereg_top.mem_map_handle = 0;
-	dereg_top.payload_size = 0;
-	dereg_top.mode = AVCS_MODE_DEREGISTER_ALL_CUSTOM_TOPOLOGIES;
-
-	q6core_lcl.bus_bw_resp_received = 0;
-
-	pr_debug("%s: Deregister topologies mode %d\n",
-		__func__, dereg_top.mode);
-
-	ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *) &dereg_top);
-	if (ret < 0) {
-		pr_err("%s: Deregister topologies failed %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	ret = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
-				(q6core_lcl.bus_bw_resp_received == 1),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout for Deregister topologies\n",
-			__func__);
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6core_send_custom_topologies(void)
-{
-	int ret = 0;
-	int ret2 = 0;
-	struct cal_block_data *cal_block = NULL;
-	struct avcs_cmd_register_topologies reg_top;
-
-	if (!q6core_is_adsp_ready()) {
-		pr_err("%s: ADSP is not ready!\n", __func__);
-		return -ENODEV;
-	}
-
-	memset(&reg_top, 0, sizeof(reg_top));
-	mutex_lock(&q6core_lcl.cal_data[CUST_TOP_CAL]->lock);
-	mutex_lock(&q6core_lcl.cmd_lock);
-
-	cal_block = cal_utils_get_only_cal_block(
-		q6core_lcl.cal_data[CUST_TOP_CAL]);
-	if (cal_block == NULL) {
-		pr_debug("%s: cal block is NULL!\n", __func__);
-		goto unlock;
-	}
-	if (cal_block->cal_data.size <= 0) {
-		pr_debug("%s: cal size is %zd not sending\n",
-			__func__, cal_block->cal_data.size);
-		goto unlock;
-	}
-
-	q6core_dereg_all_custom_topologies();
-
-	ret = q6core_map_memory_regions(&cal_block->cal_data.paddr, 0,
-		(uint32_t *)&cal_block->map_data.map_size, 1,
-		&cal_block->map_data.q6map_handle);
-	if (!ret)  {
-		pr_err("%s: q6core_map_memory_regions failed\n", __func__);
-		goto unlock;
-	}
-
-	reg_top.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	reg_top.hdr.pkt_size = sizeof(reg_top);
-	reg_top.hdr.src_svc = APR_SVC_ADSP_CORE;
-	reg_top.hdr.src_domain = APR_DOMAIN_APPS;
-	reg_top.hdr.src_port = 0;
-	reg_top.hdr.dest_svc = APR_SVC_ADSP_CORE;
-	reg_top.hdr.dest_domain = APR_DOMAIN_ADSP;
-	reg_top.hdr.dest_port = 0;
-	reg_top.hdr.token = 0;
-	reg_top.hdr.opcode = AVCS_CMD_REGISTER_TOPOLOGIES;
-	reg_top.payload_addr_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	reg_top.payload_addr_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	reg_top.mem_map_handle = cal_block->map_data.q6map_handle;
-	reg_top.payload_size = cal_block->cal_data.size;
-
-	q6core_lcl.adsp_status = 0;
-	q6core_lcl.bus_bw_resp_received = 0;
-
-	pr_debug("%s: Register topologies addr %pK, size %zd, map handle %d\n",
-		__func__, &cal_block->cal_data.paddr, cal_block->cal_data.size,
-		cal_block->map_data.q6map_handle);
-
-	ret = apr_send_pkt(q6core_lcl.core_handle_q, (uint32_t *) &reg_top);
-	if (ret < 0) {
-		pr_err("%s: Register topologies failed %d\n",
-			__func__, ret);
-		goto unmap;
-	}
-
-	ret = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
-				(q6core_lcl.bus_bw_resp_received == 1),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout for Register topologies\n",
-			__func__);
-		goto unmap;
-	}
-
-	if (q6core_lcl.adsp_status < 0)
-		ret = q6core_lcl.adsp_status;
-unmap:
-	ret2 = q6core_memory_unmap_regions(cal_block->map_data.q6map_handle);
-	if (!ret2)  {
-		pr_err("%s: q6core_memory_unmap_regions failed for map handle %d\n",
-			__func__, cal_block->map_data.q6map_handle);
-		ret = ret2;
-		goto unlock;
-	}
-
-unlock:
-	mutex_unlock(&q6core_lcl.cmd_lock);
-	mutex_unlock(&q6core_lcl.cal_data[CUST_TOP_CAL]->lock);
-
-	return ret;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case AUDIO_CORE_METAINFO_CAL_TYPE:
-		ret = META_CAL;
-		break;
-	case CORE_CUSTOM_TOPOLOGIES_CAL_TYPE:
-		ret = CUST_TOP_CAL;
-		break;
-	default:
-		pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-static int q6core_alloc_cal(int32_t cal_type,
-			    size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		q6core_lcl.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6core_dealloc_cal(int32_t cal_type,
-			      size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-					q6core_lcl.cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6core_set_cal(int32_t cal_type,
-	size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-
-	ret = cal_utils_set_cal(data_size, data,
-				    q6core_lcl.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-		__func__, ret, cal_type);
-		goto done;
-	}
-
-	if (cal_index == CUST_TOP_CAL)
-		ret = q6core_send_custom_topologies();
-done:
-	return ret;
-}
-
-static void q6core_delete_cal_data(void)
-{
-	pr_debug("%s:\n", __func__);
-
-	cal_utils_destroy_cal_types(CORE_MAX_CAL, q6core_lcl.cal_data);
-}
-
-
-static int q6core_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info    cal_type_info[] = {
-		{{AUDIO_CORE_METAINFO_CAL_TYPE,
-		{q6core_alloc_cal, q6core_dealloc_cal, NULL,
-		q6core_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{CORE_CUSTOM_TOPOLOGIES_CAL_TYPE,
-		{q6core_alloc_cal, q6core_dealloc_cal, NULL,
-		q6core_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} }
-	};
-	pr_debug("%s:\n", __func__);
-
-	ret = cal_utils_create_cal_types(CORE_MAX_CAL,
-		q6core_lcl.cal_data, cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type!\n",
-			__func__);
-		goto err;
-	}
-
-	return ret;
-err:
-	q6core_delete_cal_data();
-	return ret;
-}
-
-static int __init core_init(void)
-{
-	memset(&q6core_lcl, 0, sizeof(struct q6core_str));
-	init_waitqueue_head(&q6core_lcl.bus_bw_req_wait);
-	init_waitqueue_head(&q6core_lcl.cmd_req_wait);
-	init_waitqueue_head(&q6core_lcl.avcs_fwk_ver_req_wait);
-	q6core_lcl.cmd_resp_received_flag = FLAG_NONE;
-	mutex_init(&q6core_lcl.cmd_lock);
-	mutex_init(&q6core_lcl.ver_lock);
-
-	q6core_init_cal_data();
-
-	return 0;
-}
-module_init(core_init);
-
-static void __exit core_exit(void)
-{
-	mutex_destroy(&q6core_lcl.cmd_lock);
-	mutex_destroy(&q6core_lcl.ver_lock);
-	q6core_delete_cal_data();
-}
-module_exit(core_exit);
-MODULE_DESCRIPTION("ADSP core driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/qdsp6v2/q6lsm.c b/sound/soc/msm/qdsp6v2/q6lsm.c
deleted file mode 100644
index 799d1be..0000000
--- a/sound/soc/msm/qdsp6v2/q6lsm.c
+++ /dev/null
@@ -1,2173 +0,0 @@
-/*
- * Copyright (c) 2013-2017, Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/fs.h>
-#include <linux/mutex.h>
-#include <linux/wait.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/miscdevice.h>
-#include <linux/delay.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/time.h>
-#include <linux/atomic.h>
-#include <sound/apr_audio-v2.h>
-#include <sound/lsm_params.h>
-#include <sound/q6core.h>
-#include <sound/q6lsm.h>
-#include <asm/ioctls.h>
-#include <linux/memory.h>
-#include <linux/msm_audio_ion.h>
-#include <sound/q6afe-v2.h>
-#include <sound/audio_cal_utils.h>
-#include <sound/adsp_err.h>
-
-#define APR_TIMEOUT	(5 * HZ)
-#define LSM_ALIGN_BOUNDARY 512
-#define LSM_SAMPLE_RATE 16000
-#define QLSM_PARAM_ID_MINOR_VERSION 1
-#define QLSM_PARAM_ID_MINOR_VERSION_2 2
-
-static int lsm_afe_port;
-
-enum {
-	LSM_CUSTOM_TOP_IDX,
-	LSM_TOP_IDX,
-	LSM_CAL_IDX,
-	LSM_MAX_CAL_IDX
-};
-
-enum {
-	CMD_STATE_CLEARED = 0,
-	CMD_STATE_WAIT_RESP = 1,
-};
-
-enum {
-	LSM_INVALID_SESSION_ID = 0,
-	LSM_MIN_SESSION_ID = 1,
-	LSM_MAX_SESSION_ID = 8,
-	LSM_CONTROL_SESSION = 0x0F,
-};
-
-#define CHECK_SESSION(x) (x < LSM_MIN_SESSION_ID || x > LSM_MAX_SESSION_ID)
-struct lsm_common {
-	void *apr;
-	atomic_t apr_users;
-	struct lsm_client	common_client[LSM_MAX_SESSION_ID + 1];
-
-	int set_custom_topology;
-	struct cal_type_data	*cal_data[LSM_MAX_CAL_IDX];
-
-	struct mutex apr_lock;
-};
-
-struct lsm_module_param_ids {
-	uint32_t module_id;
-	uint32_t param_id;
-};
-
-static struct lsm_common lsm_common;
-/*
- * mmap_handle_p can point either client->sound_model.mem_map_handle or
- * lsm_common.mmap_handle_for_cal.
- * mmap_lock must be held while accessing this.
- */
-static spinlock_t mmap_lock;
-static uint32_t *mmap_handle_p;
-
-static spinlock_t lsm_session_lock;
-static struct lsm_client *lsm_session[LSM_MAX_SESSION_ID + 1];
-
-static int q6lsm_mmapcallback(struct apr_client_data *data, void *priv);
-static int q6lsm_send_cal(struct lsm_client *client, u32 set_params_opcode);
-static int q6lsm_memory_map_regions(struct lsm_client *client,
-				    dma_addr_t dma_addr_p, uint32_t dma_buf_sz,
-				    uint32_t *mmap_p);
-static int q6lsm_memory_unmap_regions(struct lsm_client *client,
-				      uint32_t handle);
-
-static void q6lsm_set_param_hdr_info(
-		struct lsm_set_params_hdr *param_hdr,
-		u32 payload_size, u32 addr_lsw, u32 addr_msw,
-		u32 mmap_handle)
-{
-	param_hdr->data_payload_size = payload_size;
-	param_hdr->data_payload_addr_lsw = addr_lsw;
-	param_hdr->data_payload_addr_msw = addr_msw;
-	param_hdr->mem_map_handle = mmap_handle;
-}
-
-static void q6lsm_set_param_common(
-		struct lsm_param_payload_common *common,
-		struct lsm_module_param_ids *ids,
-		u32 param_size, u32 set_param_version)
-{
-	common->module_id = ids->module_id;
-	common->param_id = ids->param_id;
-
-	switch (set_param_version) {
-	case LSM_SESSION_CMD_SET_PARAMS_V2:
-		common->p_size.param_size = param_size;
-		break;
-	case LSM_SESSION_CMD_SET_PARAMS:
-	default:
-		common->p_size.sr.param_size =
-			(u16) param_size;
-		common->p_size.sr.reserved = 0;
-		break;
-	}
-}
-
-static int q6lsm_callback(struct apr_client_data *data, void *priv)
-{
-	struct lsm_client *client = (struct lsm_client *)priv;
-	uint32_t token;
-	uint32_t *payload;
-
-	if (!client || !data) {
-		pr_err("%s: client %pK data %pK\n",
-			__func__, client, data);
-		WARN_ON(1);
-		return -EINVAL;
-	}
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: SSR event received 0x%x, event 0x%x, proc 0x%x\n",
-			 __func__, data->opcode, data->reset_event,
-			 data->reset_proc);
-
-		cal_utils_clear_cal_block_q6maps(LSM_MAX_CAL_IDX,
-			lsm_common.cal_data);
-		mutex_lock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-		lsm_common.set_custom_topology = 1;
-		mutex_unlock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-		return 0;
-	}
-
-	payload = data->payload;
-	pr_debug("%s: Session %d opcode 0x%x token 0x%x payload size %d\n"
-			 "payload [0] = 0x%x\n", __func__, client->session,
-		data->opcode, data->token, data->payload_size, payload[0]);
-	if (data->opcode == LSM_DATA_EVENT_READ_DONE) {
-		struct lsm_cmd_read_done read_done;
-
-		token = data->token;
-		if (data->payload_size > sizeof(read_done)) {
-			pr_err("%s: read done error payload size %d expected size %zd\n",
-				__func__, data->payload_size,
-				sizeof(read_done));
-			return -EINVAL;
-		}
-		pr_debug("%s: opcode %x status %x lsw %x msw %x mem_map handle %x\n",
-			__func__, data->opcode, payload[0], payload[1],
-			payload[2], payload[3]);
-		read_done.status = payload[0];
-		read_done.buf_addr_lsw = payload[1];
-		read_done.buf_addr_msw = payload[2];
-		read_done.mem_map_handle = payload[3];
-		read_done.total_size = payload[4];
-		read_done.offset = payload[5];
-		if (client->cb)
-			client->cb(data->opcode, data->token,
-					(void *)&read_done,
-					client->priv);
-		return 0;
-	} else if (data->opcode == APR_BASIC_RSP_RESULT) {
-		token = data->token;
-		switch (payload[0]) {
-		case LSM_SESSION_CMD_START:
-		case LSM_SESSION_CMD_STOP:
-		case LSM_SESSION_CMD_SET_PARAMS:
-		case LSM_SESSION_CMD_OPEN_TX:
-		case LSM_SESSION_CMD_CLOSE_TX:
-		case LSM_SESSION_CMD_REGISTER_SOUND_MODEL:
-		case LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL:
-		case LSM_SESSION_CMD_SHARED_MEM_UNMAP_REGIONS:
-		case LSM_SESSION_CMD_EOB:
-		case LSM_SESSION_CMD_READ:
-		case LSM_SESSION_CMD_OPEN_TX_V2:
-		case LSM_CMD_ADD_TOPOLOGIES:
-		case LSM_SESSION_CMD_SET_PARAMS_V2:
-			if (token != client->session &&
-			    payload[0] !=
-				LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL) {
-				pr_err("%s: Invalid session %d receivced expected %d\n",
-					__func__, token, client->session);
-				return -EINVAL;
-			}
-			client->cmd_err_code = payload[1];
-			if (client->cmd_err_code)
-				pr_err("%s: cmd 0x%x failed status %d\n",
-				__func__, payload[0], client->cmd_err_code);
-			if (atomic_cmpxchg(&client->cmd_state,
-					   CMD_STATE_WAIT_RESP,
-					   CMD_STATE_CLEARED) ==
-					       CMD_STATE_WAIT_RESP)
-				wake_up(&client->cmd_wait);
-			break;
-		default:
-			pr_debug("%s: Unknown command 0x%x\n",
-				__func__, payload[0]);
-			break;
-		}
-		return 0;
-	}
-
-	if (client->cb)
-		client->cb(data->opcode, data->token, data->payload,
-			   client->priv);
-
-	return 0;
-}
-
-static int q6lsm_session_alloc(struct lsm_client *client)
-{
-	unsigned long flags;
-	int n, ret = -ENOMEM;
-
-	spin_lock_irqsave(&lsm_session_lock, flags);
-	for (n = LSM_MIN_SESSION_ID; n <= LSM_MAX_SESSION_ID; n++) {
-		if (!lsm_session[n]) {
-			lsm_session[n] = client;
-			ret = n;
-			break;
-		}
-	}
-	spin_unlock_irqrestore(&lsm_session_lock, flags);
-	pr_debug("%s: Alloc Session %d", __func__, n);
-	return ret;
-}
-
-static void q6lsm_session_free(struct lsm_client *client)
-{
-	unsigned long flags;
-
-	pr_debug("%s: Freeing session ID %d\n", __func__, client->session);
-	spin_lock_irqsave(&lsm_session_lock, flags);
-	lsm_session[client->session] = LSM_INVALID_SESSION_ID;
-	spin_unlock_irqrestore(&lsm_session_lock, flags);
-	client->session = LSM_INVALID_SESSION_ID;
-}
-
-static void *q6lsm_mmap_apr_reg(void)
-{
-	if (atomic_inc_return(&lsm_common.apr_users) == 1) {
-		lsm_common.apr =
-		    apr_register("ADSP", "LSM", q6lsm_mmapcallback,
-				 0x0FFFFFFFF, &lsm_common);
-		if (!lsm_common.apr) {
-			pr_debug("%s: Unable to register APR LSM common port\n",
-				 __func__);
-			atomic_dec(&lsm_common.apr_users);
-		}
-	}
-	return lsm_common.apr;
-}
-
-static int q6lsm_mmap_apr_dereg(void)
-{
-	if (atomic_read(&lsm_common.apr_users) <= 0) {
-		WARN("%s: APR common port already closed\n", __func__);
-	} else {
-		if (atomic_dec_return(&lsm_common.apr_users) == 0) {
-			apr_deregister(lsm_common.apr);
-			pr_debug("%s: APR De-Register common port\n", __func__);
-		}
-	}
-	return 0;
-}
-
-struct lsm_client *q6lsm_client_alloc(lsm_app_cb cb, void *priv)
-{
-	struct lsm_client *client;
-	int n;
-
-	client = kzalloc(sizeof(struct lsm_client), GFP_KERNEL);
-	if (!client)
-		return NULL;
-	n = q6lsm_session_alloc(client);
-	if (n <= 0) {
-		kfree(client);
-		return NULL;
-	}
-	client->session = n;
-	client->cb = cb;
-	client->priv = priv;
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: Client session %d\n",
-			__func__, client->session);
-		kfree(client);
-		return NULL;
-	}
-	pr_debug("%s: Client Session %d\n", __func__, client->session);
-	client->apr = apr_register("ADSP", "LSM", q6lsm_callback,
-				   ((client->session) << 8 | client->session),
-				   client);
-
-	if (client->apr == NULL) {
-		pr_err("%s: Registration with APR failed\n", __func__);
-		goto fail;
-	}
-
-	pr_debug("%s: Registering the common port with APR\n", __func__);
-	client->mmap_apr = q6lsm_mmap_apr_reg();
-	if (!client->mmap_apr) {
-		pr_err("%s: APR registration failed\n", __func__);
-		goto fail;
-	}
-
-	init_waitqueue_head(&client->cmd_wait);
-	mutex_init(&client->cmd_lock);
-	atomic_set(&client->cmd_state, CMD_STATE_CLEARED);
-	pr_debug("%s: New client allocated\n", __func__);
-	return client;
-fail:
-	q6lsm_client_free(client);
-	return NULL;
-}
-
-void q6lsm_client_free(struct lsm_client *client)
-{
-	if (!client)
-		return;
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: Invalid Session %d\n", __func__, client->session);
-		return;
-	}
-	apr_deregister(client->apr);
-	client->mmap_apr = NULL;
-	q6lsm_session_free(client);
-	q6lsm_mmap_apr_dereg();
-	mutex_destroy(&client->cmd_lock);
-	kfree(client);
-	client = NULL;
-}
-
-/*
- * q6lsm_apr_send_pkt : If wait == true, hold mutex to prevent from preempting
- *			other thread's wait.
- *			If mmap_handle_p != NULL, disable irq and spin lock to
- *			protect mmap_handle_p
- */
-static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle,
-			      void *data, bool wait, uint32_t *mmap_p)
-{
-	int ret;
-	unsigned long flags = 0;
-	struct apr_hdr *msg_hdr = (struct apr_hdr *) data;
-
-	pr_debug("%s: enter wait %d\n", __func__, wait);
-	if (wait)
-		mutex_lock(&lsm_common.apr_lock);
-	if (mmap_p) {
-		WARN_ON(!wait);
-		spin_lock_irqsave(&mmap_lock, flags);
-		mmap_handle_p = mmap_p;
-	}
-	atomic_set(&client->cmd_state, CMD_STATE_WAIT_RESP);
-	client->cmd_err_code = 0;
-	ret = apr_send_pkt(handle, data);
-	if (mmap_p)
-		spin_unlock_irqrestore(&mmap_lock, flags);
-
-	if (ret < 0) {
-		pr_err("%s: apr_send_pkt failed %d\n", __func__, ret);
-	} else if (wait) {
-		ret = wait_event_timeout(client->cmd_wait,
-					 (atomic_read(&client->cmd_state) ==
-					      CMD_STATE_CLEARED),
-					 APR_TIMEOUT);
-		if (likely(ret)) {
-			/* q6 returned error */
-			if (client->cmd_err_code) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					client->cmd_err_code));
-				ret = adsp_err_get_lnx_err_code(
-						client->cmd_err_code);
-			} else {
-				ret = 0;
-			}
-		} else {
-			pr_err("%s: wait timedout, apr_opcode = 0x%x, size = %d\n",
-				__func__, msg_hdr->opcode, msg_hdr->pkt_size);
-			/* ret = 0 means wait timed out */
-			ret = -ETIMEDOUT;
-		}
-	} else {
-		ret = 0;
-	}
-	if (wait)
-		mutex_unlock(&lsm_common.apr_lock);
-
-	pr_debug("%s: leave ret %d\n", __func__, ret);
-	return ret;
-}
-
-static void q6lsm_add_hdr(struct lsm_client *client, struct apr_hdr *hdr,
-			uint32_t pkt_size, bool cmd_flg)
-{
-	pr_debug("%s: pkt_size %d cmd_flg %d session %d\n", __func__,
-		pkt_size, cmd_flg, client->session);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				       APR_HDR_LEN(sizeof(struct apr_hdr)),
-				       APR_PKT_VER);
-	hdr->src_svc = APR_SVC_LSM;
-	hdr->src_domain = APR_DOMAIN_APPS;
-	hdr->dest_svc = APR_SVC_LSM;
-	hdr->dest_domain = APR_DOMAIN_ADSP;
-	hdr->src_port = ((client->session << 8) & 0xFF00) | client->session;
-	hdr->dest_port = ((client->session << 8) & 0xFF00) | client->session;
-	hdr->pkt_size = pkt_size;
-	if (cmd_flg)
-		hdr->token = client->session;
-}
-
-
-static int q6lsm_send_custom_topologies(struct lsm_client *client)
-{
-	int rc;
-	struct cal_block_data *cal_block = NULL;
-	struct lsm_custom_topologies cstm_top;
-
-	if (lsm_common.cal_data[LSM_CUSTOM_TOP_IDX] == NULL) {
-		pr_err("%s: LSM_CUSTOM_TOP_IDX invalid\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	lsm_common.set_custom_topology = 0;
-
-	mutex_lock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-			lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]);
-	if (!cal_block) {
-		pr_err("%s: Cal block for LSM_CUSTOM_TOP_IDX not found\n",
-			__func__);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	if (cal_block->cal_data.size <= 0) {
-		pr_err("%s: Invalid size for LSM_CUSTOM_TOP %zd\n",
-			__func__, cal_block->cal_data.size);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	memset(&cstm_top, 0, sizeof(cstm_top));
-	/* Map the memory for out-of-band data */
-	rc = q6lsm_memory_map_regions(client, cal_block->cal_data.paddr,
-				      cal_block->map_data.map_size,
-				      &cal_block->map_data.q6map_handle);
-	if (rc < 0) {
-		pr_err("%s: Failed to map custom topologied, err = %d\n",
-			__func__, rc);
-		goto unlock;
-	}
-
-	q6lsm_add_hdr(client, &cstm_top.hdr,
-		      sizeof(cstm_top), true);
-	cstm_top.hdr.opcode = LSM_CMD_ADD_TOPOLOGIES;
-
-	/*
-	 * For ADD_TOPOLOGIES, the dest_port should be 0
-	 * Note that source port cannot be zero as it is used
-	 * to route the response to a specific client registered
-	 * on APR
-	 */
-	cstm_top.hdr.dest_port = 0;
-
-	cstm_top.data_payload_addr_lsw =
-			lower_32_bits(cal_block->cal_data.paddr);
-	cstm_top.data_payload_addr_msw =
-			msm_audio_populate_upper_32_bits(
-					cal_block->cal_data.paddr);
-	cstm_top.mem_map_handle = cal_block->map_data.q6map_handle;
-	cstm_top.buffer_size = cal_block->cal_data.size;
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&cstm_top, true, NULL);
-	if (rc)
-		pr_err("%s: Failed to add custom top, err = %d\n",
-			__func__, rc);
-	/* go ahead and unmap even if custom top failed */
-	rc = q6lsm_memory_unmap_regions(client,
-					cal_block->map_data.q6map_handle);
-	if (rc) {
-		pr_err("%s: Failed to unmap, err = %d\n",
-			__func__, rc);
-		/* Even if mem unmap failed, treat the cmd as success */
-		rc = 0;
-	}
-
-unlock:
-	mutex_unlock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-done:
-	return rc;
-}
-
-static int q6lsm_do_open_v2(struct lsm_client *client,
-		uint16_t app_id)
-{
-	int rc;
-	struct cal_block_data *cal_block = NULL;
-	struct audio_cal_info_lsm_top *lsm_top;
-	struct lsm_stream_cmd_open_tx_v2 open_v2;
-
-	if (lsm_common.cal_data[LSM_TOP_IDX] == NULL) {
-		pr_err("%s: LSM_TOP_IDX invalid\n", __func__);
-		rc = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&lsm_common.cal_data[LSM_TOP_IDX]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-			lsm_common.cal_data[LSM_TOP_IDX]);
-	if (!cal_block) {
-		pr_err("%s: Cal block for LSM_TOP_IDX not found\n",
-			__func__);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	lsm_top = (struct audio_cal_info_lsm_top *)
-			cal_block->cal_info;
-	if (!lsm_top) {
-		pr_err("%s: cal_info for LSM_TOP_IDX not found\n",
-			__func__);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	pr_debug("%s: topology_id = 0x%x, acdb_id = 0x%x, app_type = 0x%x\n",
-		 __func__, lsm_top->topology, lsm_top->acdb_id,
-		 lsm_top->app_type);
-
-	if (lsm_top->topology == 0) {
-		pr_err("%s: toplogy id not sent for app_type 0x%x\n",
-			__func__, lsm_top->app_type);
-		rc = -EINVAL;
-		goto unlock;
-	}
-
-	client->app_id = lsm_top->app_type;
-	memset(&open_v2, 0, sizeof(open_v2));
-	q6lsm_add_hdr(client, &open_v2.hdr,
-		      sizeof(open_v2), true);
-	open_v2.topology_id = lsm_top->topology;
-	open_v2.hdr.opcode = LSM_SESSION_CMD_OPEN_TX_V2;
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&open_v2, true, NULL);
-	if (rc)
-		pr_err("%s: open_v2 failed, err = %d\n",
-			__func__, rc);
-	else
-		client->use_topology = true;
-unlock:
-	mutex_unlock(&lsm_common.cal_data[LSM_TOP_IDX]->lock);
-done:
-	return rc;
-
-}
-
-void q6lsm_sm_set_param_data(struct lsm_client *client,
-		struct lsm_params_info *p_info,
-		size_t *offset)
-{
-	struct lsm_param_payload_common *param;
-
-	param = (struct lsm_param_payload_common *)
-			client->sound_model.data;
-	param->module_id = p_info->module_id;
-	param->param_id = p_info->param_id;
-	param->p_size.param_size = client->sound_model.size;
-	*offset = sizeof(*param);
-}
-
-int q6lsm_open(struct lsm_client *client, uint16_t app_id)
-{
-	int rc = 0;
-	struct lsm_stream_cmd_open_tx open;
-
-	/* Add Custom topologies if needed */
-	if (lsm_common.set_custom_topology) {
-		rc = q6lsm_send_custom_topologies(client);
-		if (rc)
-			pr_err("%s: Failed to send cust_top, err = %d\n",
-				__func__, rc);
-	}
-
-	/* Try to open with topology first */
-	rc = q6lsm_do_open_v2(client, app_id);
-	if (!rc)
-		/* open_v2 was successful */
-		goto done;
-
-	pr_debug("%s: try without topology\n",
-		 __func__);
-
-	memset(&open, 0, sizeof(open));
-	q6lsm_add_hdr(client, &open.hdr, sizeof(open), true);
-	switch (client->app_id) {
-	case LSM_VOICE_WAKEUP_APP_ID_V2:
-		open.app_id = client->app_id;
-		break;
-	default:
-		pr_err("%s:  default err 0x%x\n", __func__, client->app_id);
-		rc = -EINVAL;
-		break;
-	}
-
-	open.sampling_rate = LSM_SAMPLE_RATE;
-	open.hdr.opcode = LSM_SESSION_CMD_OPEN_TX;
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&open, true, NULL);
-	if (rc)
-		pr_err("%s: Open failed opcode 0x%x, rc %d\n",
-		       __func__, open.hdr.opcode, rc);
-	else
-		client->use_topology = false;
-done:
-	pr_debug("%s: leave %d\n", __func__, rc);
-	return rc;
-}
-
-static int q6lsm_send_confidence_levels(
-		struct lsm_client *client,
-		struct lsm_module_param_ids *ids,
-		u32 set_param_opcode)
-{
-	u8 *packet;
-	size_t pkt_size;
-	struct lsm_cmd_set_params_conf *conf_params;
-	struct apr_hdr *msg_hdr;
-	struct lsm_param_min_confidence_levels *cfl;
-	uint8_t i = 0;
-	uint8_t padd_size = 0;
-	u8 *conf_levels;
-	int rc;
-	u32 payload_size, param_size;
-
-	padd_size = (4 - (client->num_confidence_levels % 4)) - 1;
-	pkt_size = sizeof(*conf_params) + padd_size +
-		   client->num_confidence_levels;
-
-	packet = kzalloc(pkt_size, GFP_KERNEL);
-	if (!packet)
-		return -ENOMEM;
-
-	conf_params = (struct lsm_cmd_set_params_conf *) packet;
-	conf_levels = (u8 *) (packet + sizeof(*conf_params));
-	msg_hdr = &conf_params->msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      pkt_size, true);
-	msg_hdr->opcode = set_param_opcode;
-	payload_size = pkt_size - sizeof(*msg_hdr) -
-		       sizeof(conf_params->params_hdr);
-	q6lsm_set_param_hdr_info(&conf_params->params_hdr,
-				 payload_size, 0, 0, 0);
-	cfl = &conf_params->conf_payload;
-	param_size = ((sizeof(uint8_t) + padd_size +
-		       client->num_confidence_levels)) *
-		      sizeof(uint8_t);
-	q6lsm_set_param_common(&cfl->common, ids,
-			       param_size, set_param_opcode);
-	cfl->num_confidence_levels = client->num_confidence_levels;
-
-	pr_debug("%s: CMD PARAM SIZE = %d\n",
-		 __func__, param_size);
-	pr_debug("%s: Num conf_level = %d\n",
-		 __func__, client->num_confidence_levels);
-
-	memcpy(conf_levels, client->confidence_levels,
-	       client->num_confidence_levels);
-	for (i = 0; i < client->num_confidence_levels; i++)
-		pr_debug("%s: Confidence_level[%d] = %d\n",
-			 __func__, i, conf_levels[i]);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				packet, true, NULL);
-	if (rc)
-		pr_err("%s: confidence_levels cmd failed, err = %d\n",
-			__func__, rc);
-	kfree(packet);
-	return rc;
-}
-
-static int q6lsm_send_param_opmode(struct lsm_client *client,
-		struct lsm_module_param_ids *opmode_ids,
-		u32 set_param_opcode)
-{
-	int rc;
-	struct lsm_cmd_set_params_opmode opmode_params;
-	struct apr_hdr  *msg_hdr;
-
-	struct lsm_param_op_mode *op_mode;
-	u32 data_payload_size, param_size;
-
-	msg_hdr = &opmode_params.msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(opmode_params), true);
-	msg_hdr->opcode = set_param_opcode;
-	data_payload_size = sizeof(opmode_params) -
-			    sizeof(*msg_hdr) -
-			    sizeof(opmode_params.params_hdr);
-	q6lsm_set_param_hdr_info(&opmode_params.params_hdr,
-				 data_payload_size, 0, 0, 0);
-	op_mode = &opmode_params.op_mode;
-
-
-	param_size = sizeof(struct lsm_param_op_mode) -
-		     sizeof(op_mode->common);
-	q6lsm_set_param_common(&op_mode->common,
-			       opmode_ids, param_size,
-			       set_param_opcode);
-	op_mode->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	op_mode->mode = client->mode;
-	op_mode->reserved = 0;
-	pr_debug("%s: mode = 0x%x", __func__, op_mode->mode);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&opmode_params, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-		       __func__, msg_hdr->opcode, rc);
-
-	pr_debug("%s: leave %d\n", __func__, rc);
-	return rc;
-}
-
-void set_lsm_port(int lsm_port)
-{
-	lsm_afe_port = lsm_port;
-}
-
-int get_lsm_port(void)
-{
-	return lsm_afe_port;
-}
-
-int q6lsm_set_port_connected(struct lsm_client *client)
-{
-	int rc;
-	struct lsm_cmd_set_connectport connectport;
-	struct lsm_module_param_ids connectport_ids;
-	struct apr_hdr *msg_hdr;
-	struct lsm_param_connect_to_port *connect_to_port;
-	u32 data_payload_size, param_size, set_param_opcode;
-
-	if (client->use_topology) {
-		set_param_opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		connectport_ids.module_id = LSM_MODULE_ID_FRAMEWORK;
-		connectport_ids.param_id = LSM_PARAM_ID_CONNECT_TO_PORT;
-	} else {
-		set_param_opcode = LSM_SESSION_CMD_SET_PARAMS;
-		connectport_ids.module_id = LSM_MODULE_ID_VOICE_WAKEUP;
-		connectport_ids.param_id = LSM_PARAM_ID_CONNECT_TO_PORT;
-	}
-	client->connect_to_port = get_lsm_port();
-
-	msg_hdr = &connectport.msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(connectport), true);
-	msg_hdr->opcode = set_param_opcode;
-	data_payload_size = sizeof(connectport) -
-			    sizeof(*msg_hdr) -
-			    sizeof(connectport.params_hdr);
-	q6lsm_set_param_hdr_info(&connectport.params_hdr,
-				 data_payload_size, 0, 0, 0);
-	connect_to_port = &connectport.connect_to_port;
-
-	param_size = (sizeof(struct lsm_param_connect_to_port) -
-		      sizeof(connect_to_port->common));
-	q6lsm_set_param_common(&connect_to_port->common,
-			       &connectport_ids, param_size,
-			       set_param_opcode);
-	connect_to_port->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	connect_to_port->port_id = client->connect_to_port;
-	connect_to_port->reserved = 0;
-	pr_debug("%s: port= %d", __func__, connect_to_port->port_id);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&connectport, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-			__func__, msg_hdr->opcode, rc);
-
-	return rc;
-}
-static int q6lsm_send_param_polling_enable(struct lsm_client *client,
-		bool poll_en,
-		struct lsm_module_param_ids *poll_enable_ids,
-		u32 set_param_opcode)
-{
-	int rc = 0;
-	struct lsm_cmd_poll_enable cmd;
-	struct apr_hdr  *msg_hdr;
-	struct lsm_param_poll_enable *poll_enable;
-	u32 data_payload_size, param_size;
-
-	msg_hdr = &cmd.msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(struct lsm_cmd_poll_enable), true);
-	msg_hdr->opcode = set_param_opcode;
-	data_payload_size = sizeof(struct lsm_cmd_poll_enable) -
-			    sizeof(struct apr_hdr) -
-			    sizeof(struct lsm_set_params_hdr);
-	q6lsm_set_param_hdr_info(&cmd.params_hdr,
-				 data_payload_size, 0, 0, 0);
-	poll_enable = &cmd.poll_enable;
-
-	param_size = (sizeof(struct lsm_param_poll_enable) -
-		      sizeof(poll_enable->common));
-	q6lsm_set_param_common(&poll_enable->common,
-			       poll_enable_ids, param_size,
-			       set_param_opcode);
-	poll_enable->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	poll_enable->polling_enable = (poll_en) ? 1 : 0;
-	pr_debug("%s: poll enable= %d", __func__, poll_enable->polling_enable);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&cmd, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-		       __func__, msg_hdr->opcode, rc);
-
-	return rc;
-}
-
-int q6lsm_set_fwk_mode_cfg(struct lsm_client *client,
-			   uint32_t event_mode)
-{
-	int rc = 0;
-	struct lsm_cmd_set_fwk_mode_cfg cmd;
-	struct lsm_module_param_ids fwk_mode_cfg_ids;
-	struct apr_hdr  *msg_hdr;
-	struct lsm_param_fwk_mode_cfg *fwk_mode_cfg;
-	u32 data_payload_size, param_size, set_param_opcode;
-
-	if (client->use_topology) {
-		set_param_opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		fwk_mode_cfg_ids.module_id = LSM_MODULE_ID_FRAMEWORK;
-		fwk_mode_cfg_ids.param_id = LSM_PARAM_ID_FWK_MODE_CONFIG;
-	} else {
-		pr_debug("%s: Ignore sending event mode\n", __func__);
-		return rc;
-	}
-
-	msg_hdr = &cmd.msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(struct lsm_cmd_set_fwk_mode_cfg), true);
-	msg_hdr->opcode = set_param_opcode;
-	data_payload_size = sizeof(struct lsm_cmd_set_fwk_mode_cfg) -
-			    sizeof(struct apr_hdr) -
-			    sizeof(struct lsm_set_params_hdr);
-	q6lsm_set_param_hdr_info(&cmd.params_hdr,
-				 data_payload_size, 0, 0, 0);
-	fwk_mode_cfg = &cmd.fwk_mode_cfg;
-
-	param_size = (sizeof(struct lsm_param_fwk_mode_cfg) -
-		      sizeof(fwk_mode_cfg->common));
-	q6lsm_set_param_common(&fwk_mode_cfg->common,
-			       &fwk_mode_cfg_ids, param_size,
-			       set_param_opcode);
-
-	fwk_mode_cfg->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	fwk_mode_cfg->mode = event_mode;
-	pr_debug("%s: mode = %d\n", __func__, fwk_mode_cfg->mode);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&cmd, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-		       __func__, msg_hdr->opcode, rc);
-	return rc;
-}
-
-static int q6lsm_arrange_mch_map(struct lsm_param_media_fmt *media_fmt,
-			 int channel_count)
-{
-	int rc = 0;
-
-	memset(media_fmt->channel_mapping, 0, LSM_MAX_NUM_CHANNELS);
-
-	switch (channel_count) {
-	case 1:
-		media_fmt->channel_mapping[0] = PCM_CHANNEL_FC;
-		break;
-	case 2:
-		media_fmt->channel_mapping[0] = PCM_CHANNEL_FL;
-		media_fmt->channel_mapping[1] = PCM_CHANNEL_FR;
-		break;
-	case 3:
-		media_fmt->channel_mapping[0] = PCM_CHANNEL_FL;
-		media_fmt->channel_mapping[1] = PCM_CHANNEL_FR;
-		media_fmt->channel_mapping[2] = PCM_CHANNEL_FC;
-		break;
-	case 4:
-		media_fmt->channel_mapping[0] = PCM_CHANNEL_FL;
-		media_fmt->channel_mapping[1] = PCM_CHANNEL_FR;
-		media_fmt->channel_mapping[2] = PCM_CHANNEL_LS;
-		media_fmt->channel_mapping[3] = PCM_CHANNEL_RS;
-		break;
-	default:
-		pr_err("%s: invalid num_chan %d\n", __func__, channel_count);
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-int q6lsm_set_media_fmt_params(struct lsm_client *client)
-{
-	int rc = 0;
-	struct lsm_cmd_set_media_fmt cmd;
-	struct lsm_module_param_ids media_fmt_ids;
-	struct apr_hdr  *msg_hdr;
-	struct lsm_param_media_fmt *media_fmt;
-	u32 data_payload_size, param_size, set_param_opcode;
-	struct lsm_hw_params param = client->hw_params;
-
-	if (client->use_topology) {
-		set_param_opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		media_fmt_ids.module_id = LSM_MODULE_ID_FRAMEWORK;
-		media_fmt_ids.param_id = LSM_PARAM_ID_MEDIA_FMT;
-	} else {
-		pr_debug("%s: Ignore sending media format\n", __func__);
-		goto err_ret;
-	}
-
-	msg_hdr = &cmd.msg_hdr;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(struct lsm_cmd_set_media_fmt), true);
-	msg_hdr->opcode = set_param_opcode;
-	data_payload_size = sizeof(struct lsm_cmd_set_media_fmt) -
-			    sizeof(struct apr_hdr) -
-			    sizeof(struct lsm_set_params_hdr);
-	q6lsm_set_param_hdr_info(&cmd.params_hdr,
-				 data_payload_size, 0, 0, 0);
-	media_fmt = &cmd.media_fmt;
-
-	param_size = (sizeof(struct lsm_param_media_fmt) -
-		      sizeof(media_fmt->common));
-	q6lsm_set_param_common(&media_fmt->common,
-			       &media_fmt_ids, param_size,
-			       set_param_opcode);
-
-	media_fmt->minor_version = QLSM_PARAM_ID_MINOR_VERSION_2;
-	media_fmt->sample_rate = param.sample_rate;
-	media_fmt->num_channels = param.num_chs;
-	media_fmt->bit_width = param.sample_size;
-
-	rc = q6lsm_arrange_mch_map(media_fmt, media_fmt->num_channels);
-	if (rc)
-		goto err_ret;
-
-	pr_debug("%s: sample rate= %d, channels %d bit width %d\n",
-		 __func__, media_fmt->sample_rate, media_fmt->num_channels,
-		 media_fmt->bit_width);
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&cmd, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-		       __func__, msg_hdr->opcode, rc);
-err_ret:
-	return rc;
-}
-
-int q6lsm_set_data(struct lsm_client *client,
-			   enum lsm_detection_mode mode,
-			   bool detectfailure)
-{
-	int rc = 0;
-	struct lsm_module_param_ids opmode_ids;
-	struct lsm_module_param_ids conf_levels_ids;
-
-	if (!client->confidence_levels) {
-		/*
-		 * It is possible that confidence levels are
-		 * not provided. This is not a error condition.
-		 * Return gracefully without any error
-		 */
-		pr_debug("%s: no conf levels to set\n",
-			__func__);
-		return rc;
-	}
-
-	if (mode == LSM_MODE_KEYWORD_ONLY_DETECTION) {
-		client->mode = 0x01;
-	} else if (mode == LSM_MODE_USER_KEYWORD_DETECTION) {
-		client->mode = 0x03;
-	} else {
-		pr_err("%s: Incorrect detection mode %d\n", __func__, mode);
-		rc = -EINVAL;
-		goto err_ret;
-	}
-	client->mode |= detectfailure << 2;
-
-	opmode_ids.module_id = LSM_MODULE_ID_VOICE_WAKEUP;
-	opmode_ids.param_id = LSM_PARAM_ID_OPERATION_MODE;
-
-	rc = q6lsm_send_param_opmode(client, &opmode_ids,
-					LSM_SESSION_CMD_SET_PARAMS);
-	if (rc) {
-		pr_err("%s: Failed to set lsm config params %d\n",
-			__func__, rc);
-		goto err_ret;
-	}
-
-	conf_levels_ids.module_id = LSM_MODULE_ID_VOICE_WAKEUP;
-	conf_levels_ids.param_id = LSM_PARAM_ID_MIN_CONFIDENCE_LEVELS;
-
-	rc = q6lsm_send_confidence_levels(client, &conf_levels_ids,
-					 LSM_SESSION_CMD_SET_PARAMS);
-	if (rc) {
-		pr_err("%s: Failed to send conf_levels, err = %d\n",
-			__func__, rc);
-		goto err_ret;
-	}
-
-	rc = q6lsm_send_cal(client, LSM_SESSION_CMD_SET_PARAMS);
-	if (rc) {
-		pr_err("%s: Failed to send calibration data %d\n",
-			__func__, rc);
-		goto err_ret;
-	}
-
-err_ret:
-	return rc;
-}
-
-int q6lsm_register_sound_model(struct lsm_client *client,
-			       enum lsm_detection_mode mode,
-			       bool detectfailure)
-{
-	int rc;
-	struct lsm_cmd_reg_snd_model cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	rc = q6lsm_set_data(client, mode, detectfailure);
-	if (rc) {
-		pr_err("%s: Failed to set lsm data, err = %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	q6lsm_add_hdr(client, &cmd.hdr, sizeof(cmd), true);
-	cmd.hdr.opcode = LSM_SESSION_CMD_REGISTER_SOUND_MODEL;
-	cmd.model_addr_lsw = lower_32_bits(client->sound_model.phys);
-	cmd.model_addr_msw = msm_audio_populate_upper_32_bits(
-						client->sound_model.phys);
-	cmd.model_size = client->sound_model.size;
-	/* read updated mem_map_handle by q6lsm_mmapcallback */
-	rmb();
-	cmd.mem_map_handle = client->sound_model.mem_map_handle;
-
-	pr_debug("%s: addr %pK, size %d, handle 0x%x\n", __func__,
-		&client->sound_model.phys, cmd.model_size, cmd.mem_map_handle);
-	rc = q6lsm_apr_send_pkt(client, client->apr, &cmd, true, NULL);
-	if (rc)
-		pr_err("%s: Failed cmd op[0x%x]rc[%d]\n", __func__,
-		       cmd.hdr.opcode, rc);
-	else
-		pr_debug("%s: Register sound model succeeded\n", __func__);
-
-	return rc;
-}
-
-int q6lsm_deregister_sound_model(struct lsm_client *client)
-{
-	int rc;
-	struct lsm_cmd_reg_snd_model cmd;
-
-	if (!client) {
-		pr_err("APR handle NULL\n");
-		return -EINVAL;
-	}
-	if (!client->apr) {
-		pr_err("APR client handle NULL\n");
-		return -EINVAL;
-	}
-
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: session[%d]", __func__, client->session);
-		return -EINVAL;
-	}
-
-	memset(&cmd, 0, sizeof(cmd));
-	q6lsm_add_hdr(client, &cmd.hdr, sizeof(cmd.hdr), false);
-	cmd.hdr.opcode = LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL;
-
-	rc = q6lsm_apr_send_pkt(client, client->apr, &cmd.hdr, true, NULL);
-	if (rc) {
-		pr_err("%s: Failed cmd opcode 0x%x, rc %d\n", __func__,
-		       cmd.hdr.opcode, rc);
-	} else {
-		pr_debug("%s: Deregister sound model succeeded\n", __func__);
-	}
-
-	q6lsm_snd_model_buf_free(client);
-
-	return rc;
-}
-
-static void q6lsm_add_mmaphdr(struct lsm_client *client, struct apr_hdr *hdr,
-			      u32 pkt_size, u32 cmd_flg, u32 token)
-{
-	pr_debug("%s: pkt size=%d cmd_flg=%d session=%d\n", __func__, pkt_size,
-		 cmd_flg, client->session);
-	hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				       APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	hdr->src_port = 0x00;
-	hdr->dest_port = client->session;
-	if (cmd_flg)
-		hdr->token = token;
-	hdr->pkt_size = pkt_size;
-}
-
-static int q6lsm_memory_map_regions(struct lsm_client *client,
-				    dma_addr_t dma_addr_p, uint32_t dma_buf_sz,
-				    uint32_t *mmap_p)
-{
-	struct avs_cmd_shared_mem_map_regions *mmap_regions = NULL;
-	struct avs_shared_map_region_payload *mregions = NULL;
-	void *mmap_region_cmd = NULL;
-	void *payload = NULL;
-	int rc;
-	int cmd_size = 0;
-
-	pr_debug("%s: dma_addr_p 0x%pK, dma_buf_sz %d, mmap_p 0x%pK, session %d\n",
-		__func__, &dma_addr_p, dma_buf_sz, mmap_p,
-		client->session);
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: session[%d]", __func__, client->session);
-		return -EINVAL;
-	}
-	cmd_size = sizeof(struct avs_cmd_shared_mem_map_regions) +
-		   sizeof(struct avs_shared_map_region_payload);
-
-	mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
-	if (!mmap_region_cmd)
-		return -ENOMEM;
-
-	mmap_regions = (struct avs_cmd_shared_mem_map_regions *)mmap_region_cmd;
-	q6lsm_add_mmaphdr(client, &mmap_regions->hdr, cmd_size, true,
-			  (client->session << 8));
-
-	mmap_regions->hdr.opcode = LSM_SESSION_CMD_SHARED_MEM_MAP_REGIONS;
-	mmap_regions->mem_pool_id = ADSP_MEMORY_MAP_SHMEM8_4K_POOL;
-	mmap_regions->num_regions = 1;
-	mmap_regions->property_flag = 0x00;
-	payload = ((u8 *)mmap_region_cmd +
-		   sizeof(struct avs_cmd_shared_mem_map_regions));
-	mregions = (struct avs_shared_map_region_payload *)payload;
-
-	mregions->shm_addr_lsw = lower_32_bits(dma_addr_p);
-	mregions->shm_addr_msw = msm_audio_populate_upper_32_bits(dma_addr_p);
-	mregions->mem_size_bytes = dma_buf_sz;
-
-	rc = q6lsm_apr_send_pkt(client, client->mmap_apr, mmap_region_cmd,
-				true, mmap_p);
-	if (rc)
-		pr_err("%s: Failed mmap_regions opcode 0x%x, rc %d\n",
-			__func__, mmap_regions->hdr.opcode, rc);
-
-	pr_debug("%s: leave %d\n", __func__, rc);
-	kfree(mmap_region_cmd);
-	return rc;
-}
-
-static int q6lsm_memory_unmap_regions(struct lsm_client *client,
-				      uint32_t handle)
-{
-	struct avs_cmd_shared_mem_unmap_regions unmap;
-	int rc = 0;
-	int cmd_size = 0;
-
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: session[%d]", __func__, client->session);
-		return -EINVAL;
-	}
-	cmd_size = sizeof(struct avs_cmd_shared_mem_unmap_regions);
-	q6lsm_add_mmaphdr(client, &unmap.hdr, cmd_size,
-			  true, (client->session << 8));
-	unmap.hdr.opcode = LSM_SESSION_CMD_SHARED_MEM_UNMAP_REGIONS;
-	unmap.mem_map_handle = handle;
-
-	pr_debug("%s: unmap handle 0x%x\n", __func__, unmap.mem_map_handle);
-	rc = q6lsm_apr_send_pkt(client, client->mmap_apr, &unmap, true,
-				NULL);
-	if (rc)
-		pr_err("%s: Failed mmap_regions opcode 0x%x rc %d\n",
-		       __func__, unmap.hdr.opcode, rc);
-
-	return rc;
-}
-
-static int q6lsm_send_cal(struct lsm_client *client,
-			  u32 set_params_opcode)
-{
-	int rc = 0;
-	struct lsm_cmd_set_params params;
-	struct lsm_set_params_hdr *params_hdr = &params.param_hdr;
-	struct apr_hdr *msg_hdr = &params.msg_hdr;
-	struct cal_block_data *cal_block = NULL;
-
-	pr_debug("%s: Session id %d\n", __func__, client->session);
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: session[%d]", __func__, client->session);
-		return -EINVAL;
-	}
-
-	if (lsm_common.cal_data[LSM_CAL_IDX] == NULL)
-		goto done;
-
-	mutex_lock(&lsm_common.cal_data[LSM_CAL_IDX]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-		lsm_common.cal_data[LSM_CAL_IDX]);
-
-	if (!cal_block || cal_block->cal_data.size <= 0) {
-		pr_debug("%s: No cal to send!\n", __func__);
-		goto unlock;
-	}
-
-	if (cal_block->cal_data.size != client->lsm_cal_size) {
-		pr_err("%s: Cal size %zd doesn't match lsm cal size %d\n",
-			__func__, cal_block->cal_data.size,
-			client->lsm_cal_size);
-		rc = -EINVAL;
-		goto unlock;
-	}
-	/* Cache mmap address, only map once or if new addr */
-	lsm_common.common_client[client->session].session = client->session;
-	q6lsm_add_hdr(client, msg_hdr, sizeof(params), true);
-	msg_hdr->opcode = set_params_opcode;
-	q6lsm_set_param_hdr_info(params_hdr,
-			cal_block->cal_data.size,
-			lower_32_bits(client->lsm_cal_phy_addr),
-			msm_audio_populate_upper_32_bits(
-				client->lsm_cal_phy_addr),
-			client->sound_model.mem_map_handle);
-
-	pr_debug("%s: Cal Size = %zd", __func__,
-		cal_block->cal_data.size);
-	rc = q6lsm_apr_send_pkt(client, client->apr, &params, true, NULL);
-	if (rc)
-		pr_err("%s: Failed set_params opcode 0x%x, rc %d\n",
-		       __func__, msg_hdr->opcode, rc);
-unlock:
-	mutex_unlock(&lsm_common.cal_data[LSM_CAL_IDX]->lock);
-done:
-	return rc;
-}
-
-
-int q6lsm_snd_model_buf_free(struct lsm_client *client)
-{
-	int rc;
-
-	pr_debug("%s: Session id %d\n", __func__, client->session);
-	if (CHECK_SESSION(client->session)) {
-		pr_err("%s: session[%d]", __func__, client->session);
-		return -EINVAL;
-	}
-
-	mutex_lock(&client->cmd_lock);
-	rc = q6lsm_memory_unmap_regions(client,
-					client->sound_model.mem_map_handle);
-	if (rc)
-		pr_err("%s: CMD Memory_unmap_regions failed %d\n",
-			__func__, rc);
-
-	if (client->sound_model.data) {
-		msm_audio_ion_free(client->sound_model.client,
-				 client->sound_model.handle);
-		client->sound_model.client = NULL;
-		client->sound_model.handle = NULL;
-		client->sound_model.data = NULL;
-		client->sound_model.phys = 0;
-		client->lsm_cal_phy_addr = 0;
-		client->lsm_cal_size = 0;
-	}
-	mutex_unlock(&client->cmd_lock);
-	return rc;
-}
-
-static struct lsm_client *q6lsm_get_lsm_client(int session_id)
-{
-	unsigned long flags;
-	struct lsm_client *client = NULL;
-
-	spin_lock_irqsave(&lsm_session_lock, flags);
-	if (session_id < LSM_MIN_SESSION_ID || session_id > LSM_MAX_SESSION_ID)
-		pr_err("%s: Invalid session %d\n", __func__, session_id);
-	else if (!lsm_session[session_id])
-		pr_err("%s: Not an active session %d\n", __func__, session_id);
-	else
-		client = lsm_session[session_id];
-	spin_unlock_irqrestore(&lsm_session_lock, flags);
-	return client;
-}
-
-/*
- * q6lsm_mmapcallback : atomic context
- */
-static int q6lsm_mmapcallback(struct apr_client_data *data, void *priv)
-{
-	unsigned long flags;
-	uint32_t command;
-	uint32_t retcode;
-	uint32_t sid;
-	const uint32_t *payload = data->payload;
-	struct lsm_client *client = NULL;
-
-	if (data->opcode == RESET_EVENTS) {
-		sid = (data->token >> 8) & 0x0F;
-		pr_debug("%s: SSR event received 0x%x, event 0x%x,\n"
-			 "proc 0x%x SID 0x%x\n", __func__, data->opcode,
-			 data->reset_event, data->reset_proc, sid);
-		lsm_common.common_client[sid].lsm_cal_phy_addr = 0;
-		cal_utils_clear_cal_block_q6maps(LSM_MAX_CAL_IDX,
-			lsm_common.cal_data);
-		lsm_common.set_custom_topology = 1;
-		return 0;
-	}
-
-	command = payload[0];
-	retcode = payload[1];
-	sid = (data->token >> 8) & 0x0F;
-	pr_debug("%s: opcode 0x%x command 0x%x return code 0x%x SID 0x%x\n",
-		 __func__, data->opcode, command, retcode, sid);
-	client = q6lsm_get_lsm_client(sid);
-	if (!client) {
-		pr_debug("%s: Session %d already freed\n", __func__, sid);
-		return 0;
-	}
-
-	switch (data->opcode) {
-	case LSM_SESSION_CMDRSP_SHARED_MEM_MAP_REGIONS:
-		if (atomic_read(&client->cmd_state) == CMD_STATE_WAIT_RESP) {
-			spin_lock_irqsave(&mmap_lock, flags);
-			*mmap_handle_p = command;
-			/* spin_unlock_irqrestore implies barrier */
-			spin_unlock_irqrestore(&mmap_lock, flags);
-			atomic_set(&client->cmd_state, CMD_STATE_CLEARED);
-			wake_up(&client->cmd_wait);
-		}
-		break;
-	case APR_BASIC_RSP_RESULT:
-		switch (command) {
-		case LSM_SESSION_CMD_SHARED_MEM_UNMAP_REGIONS:
-			atomic_set(&client->cmd_state, CMD_STATE_CLEARED);
-			wake_up(&client->cmd_wait);
-			break;
-		case LSM_SESSION_CMD_SHARED_MEM_MAP_REGIONS:
-			if (retcode != 0) {
-				/* error state, signal to stop waiting */
-				if (atomic_read(&client->cmd_state) ==
-					CMD_STATE_WAIT_RESP) {
-					spin_lock_irqsave(&mmap_lock, flags);
-					/* implies barrier */
-					spin_unlock_irqrestore(&mmap_lock,
-						flags);
-					atomic_set(&client->cmd_state,
-						CMD_STATE_CLEARED);
-					wake_up(&client->cmd_wait);
-				}
-			}
-			break;
-		default:
-			pr_warn("%s: Unexpected command 0x%x\n", __func__,
-				command);
-		}
-		/* fallthrough */
-	default:
-		pr_debug("%s: command 0x%x return code 0x%x opcode 0x%x\n",
-			 __func__, command, retcode, data->opcode);
-		break;
-	}
-	if (client->cb)
-		client->cb(data->opcode, data->token,
-			   data->payload, client->priv);
-	return 0;
-}
-
-int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len,
-			      bool allocate_module_data)
-{
-	int rc = -EINVAL;
-	struct cal_block_data		*cal_block = NULL;
-
-	size_t pad_zero = 0, total_mem = 0;
-
-	if (!client || len <= LSM_ALIGN_BOUNDARY)
-		return rc;
-
-	mutex_lock(&client->cmd_lock);
-
-	mutex_lock(&lsm_common.cal_data[LSM_CAL_IDX]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-		lsm_common.cal_data[LSM_CAL_IDX]);
-	if (cal_block == NULL)
-		goto fail;
-
-	pr_debug("%s:Snd Model len = %zd cal size %zd phys addr %pK", __func__,
-		len, cal_block->cal_data.size,
-		&cal_block->cal_data.paddr);
-	if (!cal_block->cal_data.paddr) {
-		pr_err("%s: No LSM calibration set for session", __func__);
-		rc = -EINVAL;
-		goto fail;
-	}
-	if (!client->sound_model.data) {
-
-		/*
-		 * if sound module is sent as set_param
-		 * Then memory needs to be allocated for
-		 * set_param payload as well.
-		 */
-		if (allocate_module_data)
-			len += sizeof(struct lsm_param_payload_common);
-
-		client->sound_model.size = len;
-		pad_zero = (LSM_ALIGN_BOUNDARY -
-			    (len % LSM_ALIGN_BOUNDARY));
-		if ((len > SIZE_MAX - pad_zero) ||
-		    (len + pad_zero >
-		     SIZE_MAX - cal_block->cal_data.size)) {
-			pr_err("%s: invalid allocation size, len = %zd, pad_zero =%zd, cal_size = %zd\n",
-				__func__, len, pad_zero,
-				cal_block->cal_data.size);
-			rc = -EINVAL;
-			goto fail;
-		}
-
-		total_mem = PAGE_ALIGN(pad_zero + len +
-			cal_block->cal_data.size);
-		pr_debug("%s: Pad zeros sound model %zd Total mem %zd\n",
-				 __func__, pad_zero, total_mem);
-		rc = msm_audio_ion_alloc("lsm_client",
-				&client->sound_model.client,
-				&client->sound_model.handle,
-				total_mem,
-				&client->sound_model.phys,
-				&len,
-				&client->sound_model.data);
-		if (rc) {
-			pr_err("%s: Audio ION alloc is failed, rc = %d\n",
-				__func__, rc);
-			goto fail;
-		}
-	pr_debug("%s: Length = %zd\n", __func__, len);
-	client->lsm_cal_phy_addr = (pad_zero +
-				    client->sound_model.phys +
-				    client->sound_model.size);
-	client->lsm_cal_size = cal_block->cal_data.size;
-	memcpy((client->sound_model.data + pad_zero +
-		client->sound_model.size),
-	       (uint32_t *)cal_block->cal_data.kvaddr, client->lsm_cal_size);
-	pr_debug("%s: Copy cal start virt_addr %pK phy_addr %pK\n"
-			 "Offset cal virtual Addr %pK\n", __func__,
-			 client->sound_model.data, &client->sound_model.phys,
-			 (pad_zero + client->sound_model.data +
-			 client->sound_model.size));
-	} else {
-		pr_err("%s: sound model busy\n", __func__);
-		rc = -EBUSY;
-		goto fail;
-	}
-	mutex_unlock(&lsm_common.cal_data[LSM_CAL_IDX]->lock);
-	mutex_unlock(&client->cmd_lock);
-
-	rc = q6lsm_memory_map_regions(client, client->sound_model.phys,
-				      len,
-				      &client->sound_model.mem_map_handle);
-	if (rc) {
-		pr_err("%s: CMD Memory_map_regions failed %d\n", __func__, rc);
-		goto exit;
-	}
-
-	return 0;
-fail:
-	mutex_unlock(&lsm_common.cal_data[LSM_CAL_IDX]->lock);
-	mutex_unlock(&client->cmd_lock);
-exit:
-	q6lsm_snd_model_buf_free(client);
-	return rc;
-}
-
-static int q6lsm_cmd(struct lsm_client *client, int opcode, bool wait)
-{
-	struct apr_hdr hdr;
-	int rc;
-
-	pr_debug("%s: enter opcode %x wait %d\n", __func__, opcode, wait);
-	q6lsm_add_hdr(client, &hdr, sizeof(hdr), true);
-	switch (opcode) {
-	case LSM_SESSION_CMD_START:
-	case LSM_SESSION_CMD_STOP:
-	case LSM_SESSION_CMD_CLOSE_TX:
-	case LSM_SESSION_CMD_EOB:
-		hdr.opcode = opcode;
-		break;
-	default:
-		pr_err("%s: Invalid opcode 0x%x\n", __func__, opcode);
-		return -EINVAL;
-	}
-	rc = q6lsm_apr_send_pkt(client, client->apr, &hdr, wait, NULL);
-	if (rc)
-		pr_err("%s: Failed commmand 0x%x\n", __func__, hdr.opcode);
-
-	pr_debug("%s: leave %d\n", __func__, rc);
-	return rc;
-}
-
-static int q6lsm_send_param_epd_thres(
-		struct lsm_client *client,
-		void *data, struct lsm_module_param_ids *ids)
-{
-	struct snd_lsm_ep_det_thres *ep_det_data;
-	struct lsm_cmd_set_epd_threshold epd_cmd;
-	struct apr_hdr *msg_hdr = &epd_cmd.msg_hdr;
-	struct lsm_set_params_hdr *param_hdr =
-			&epd_cmd.param_hdr;
-	struct lsm_param_epd_thres *epd_thres =
-			&epd_cmd.epd_thres;
-	int rc;
-
-	ep_det_data = (struct snd_lsm_ep_det_thres *) data;
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(epd_cmd), true);
-	msg_hdr->opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-	q6lsm_set_param_hdr_info(param_hdr,
-		sizeof(*epd_thres), 0, 0, 0);
-	q6lsm_set_param_common(&epd_thres->common, ids,
-		sizeof(*epd_thres) - sizeof(epd_thres->common),
-		LSM_SESSION_CMD_SET_PARAMS_V2);
-	epd_thres->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	epd_thres->epd_begin = ep_det_data->epd_begin;
-	epd_thres->epd_end = ep_det_data->epd_end;
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&epd_cmd, true, NULL);
-	if (unlikely(rc))
-		pr_err("%s: EPD_THRESHOLD failed, rc %d\n",
-			__func__, rc);
-	return rc;
-}
-
-static int q6lsm_send_param_gain(
-		struct lsm_client *client,
-		u16 gain, struct lsm_module_param_ids *ids)
-{
-	struct lsm_cmd_set_gain lsm_cmd_gain;
-	struct apr_hdr *msg_hdr = &lsm_cmd_gain.msg_hdr;
-	struct lsm_param_gain *lsm_gain = &lsm_cmd_gain.lsm_gain;
-	int rc;
-
-	q6lsm_add_hdr(client, msg_hdr,
-		      sizeof(lsm_cmd_gain), true);
-	msg_hdr->opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-	q6lsm_set_param_hdr_info(&lsm_cmd_gain.param_hdr,
-			sizeof(*lsm_gain), 0, 0, 0);
-	q6lsm_set_param_common(&lsm_gain->common, ids,
-		sizeof(*lsm_gain) - sizeof(lsm_gain->common),
-		LSM_SESSION_CMD_SET_PARAMS_V2);
-	lsm_gain->minor_version = QLSM_PARAM_ID_MINOR_VERSION;
-	lsm_gain->gain = gain;
-	lsm_gain->reserved = 0;
-
-	rc = q6lsm_apr_send_pkt(client, client->apr,
-				&lsm_cmd_gain, true, NULL);
-	if (unlikely(rc))
-		pr_err("%s: LSM_GAIN CMD send failed, rc %d\n",
-			 __func__, rc);
-	return rc;
-}
-
-int q6lsm_set_one_param(struct lsm_client *client,
-	struct lsm_params_info *p_info, void *data,
-	uint32_t param_type)
-{
-	int rc = 0, pkt_sz;
-	struct lsm_module_param_ids ids;
-	u8 *packet;
-
-	memset(&ids, 0, sizeof(ids));
-	switch (param_type) {
-	case LSM_ENDPOINT_DETECT_THRESHOLD: {
-		ids.module_id = p_info->module_id;
-		ids.param_id = p_info->param_id;
-		rc = q6lsm_send_param_epd_thres(client, data,
-						&ids);
-		break;
-	}
-
-	case LSM_OPERATION_MODE: {
-		struct snd_lsm_detect_mode *det_mode = data;
-		struct lsm_module_param_ids opmode_ids;
-
-		if (det_mode->mode == LSM_MODE_KEYWORD_ONLY_DETECTION) {
-			client->mode = 0x01;
-		} else if (det_mode->mode == LSM_MODE_USER_KEYWORD_DETECTION) {
-			client->mode = 0x03;
-		} else {
-			pr_err("%s: Incorrect detection mode %d\n",
-				__func__, det_mode->mode);
-			return -EINVAL;
-		}
-
-		client->mode |= det_mode->detect_failure << 2;
-
-		opmode_ids.module_id = p_info->module_id;
-		opmode_ids.param_id = p_info->param_id;
-
-		rc = q6lsm_send_param_opmode(client, &opmode_ids,
-					LSM_SESSION_CMD_SET_PARAMS_V2);
-		if (rc)
-			pr_err("%s: OPERATION_MODE failed, rc %d\n",
-				__func__, rc);
-		break;
-	}
-
-	case LSM_GAIN: {
-		struct snd_lsm_gain *lsm_gain = (struct snd_lsm_gain *) data;
-
-		ids.module_id = p_info->module_id;
-		ids.param_id = p_info->param_id;
-		rc = q6lsm_send_param_gain(client, lsm_gain->gain, &ids);
-		if (rc)
-			pr_err("%s: LSM_GAIN command failed, rc %d\n",
-				__func__, rc);
-		break;
-	}
-
-	case LSM_MIN_CONFIDENCE_LEVELS:
-		ids.module_id = p_info->module_id;
-		ids.param_id = p_info->param_id;
-		rc = q6lsm_send_confidence_levels(client, &ids,
-				LSM_SESSION_CMD_SET_PARAMS_V2);
-		if (rc)
-			pr_err("%s: CONFIDENCE_LEVELS cmd failed, rc %d\n",
-				 __func__, rc);
-		break;
-	case LSM_POLLING_ENABLE: {
-		struct snd_lsm_poll_enable *lsm_poll_enable =
-				(struct snd_lsm_poll_enable *) data;
-		ids.module_id = p_info->module_id;
-		ids.param_id = p_info->param_id;
-		rc = q6lsm_send_param_polling_enable(client,
-				lsm_poll_enable->poll_en, &ids,
-				LSM_SESSION_CMD_SET_PARAMS_V2);
-		if (rc)
-			pr_err("%s: POLLING ENABLE cmd failed, rc %d\n",
-				 __func__, rc);
-		break;
-	}
-
-	case LSM_REG_SND_MODEL: {
-		struct lsm_cmd_set_params model_param;
-		u32 payload_size;
-
-		memset(&model_param, 0, sizeof(model_param));
-		q6lsm_add_hdr(client, &model_param.msg_hdr,
-			      sizeof(model_param), true);
-		model_param.msg_hdr.opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		payload_size = p_info->param_size +
-			       sizeof(struct lsm_param_payload_common);
-		q6lsm_set_param_hdr_info(&model_param.param_hdr,
-				payload_size,
-				lower_32_bits(client->sound_model.phys),
-				msm_audio_populate_upper_32_bits(
-					client->sound_model.phys),
-				client->sound_model.mem_map_handle);
-
-		rc = q6lsm_apr_send_pkt(client, client->apr,
-					&model_param, true, NULL);
-		if (rc) {
-			pr_err("%s: REG_SND_MODEL failed, rc %d\n",
-				__func__, rc);
-			return rc;
-		}
-
-		rc = q6lsm_send_cal(client, LSM_SESSION_CMD_SET_PARAMS);
-		if (rc)
-			pr_err("%s: Failed to send lsm cal, err = %d\n",
-				__func__, rc);
-		break;
-	}
-
-	case LSM_DEREG_SND_MODEL: {
-		struct lsm_param_payload_common *common;
-		struct lsm_cmd_set_params *param;
-
-		pkt_sz = sizeof(*param) + sizeof(*common);
-		packet = kzalloc(pkt_sz, GFP_KERNEL);
-		if (!packet) {
-			pr_err("%s: No memory for DEREG_SND_MODEL pkt, size = %d\n",
-				__func__, pkt_sz);
-			return -ENOMEM;
-		}
-
-		param = (struct lsm_cmd_set_params *) packet;
-		common = (struct lsm_param_payload_common *)
-				(packet + sizeof(*param));
-		q6lsm_add_hdr(client, &param->msg_hdr, pkt_sz, true);
-		param->msg_hdr.opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		q6lsm_set_param_hdr_info(&param->param_hdr,
-					 sizeof(*common),
-					 0, 0, 0);
-		ids.module_id = p_info->module_id;
-		ids.param_id = p_info->param_id;
-		q6lsm_set_param_common(common, &ids, 0,
-				       LSM_SESSION_CMD_SET_PARAMS_V2);
-		rc = q6lsm_apr_send_pkt(client, client->apr,
-					packet, true, NULL);
-		if (rc)
-			pr_err("%s: DEREG_SND_MODEL failed, rc %d\n",
-				__func__, rc);
-		kfree(packet);
-		break;
-	}
-
-	case LSM_CUSTOM_PARAMS: {
-		struct apr_hdr *hdr;
-		u8 *custom_data;
-
-		if (p_info->param_size <
-		    sizeof(struct lsm_param_payload_common)) {
-			pr_err("%s: Invalid param_size %d\n",
-				__func__, p_info->param_size);
-			return -EINVAL;
-		}
-
-		pkt_sz = p_info->param_size + sizeof(*hdr);
-		packet = kzalloc(pkt_sz, GFP_KERNEL);
-		if (!packet) {
-			pr_err("%s: no memory for CUSTOM_PARAMS, size = %d\n",
-				__func__, pkt_sz);
-			return -ENOMEM;
-		}
-
-		hdr = (struct apr_hdr *) packet;
-		custom_data = (u8 *) (packet + sizeof(*hdr));
-		q6lsm_add_hdr(client, hdr, pkt_sz, true);
-		hdr->opcode = LSM_SESSION_CMD_SET_PARAMS_V2;
-		memcpy(custom_data, data, p_info->param_size);
-
-		rc = q6lsm_apr_send_pkt(client, client->apr,
-					packet, true, NULL);
-		if (rc)
-			pr_err("%s: CUSTOM_PARAMS failed, rc %d\n",
-				__func__, rc);
-		kfree(packet);
-		break;
-	}
-	default:
-		pr_err("%s: wrong param_type 0x%x\n",
-			__func__, p_info->param_type);
-	}
-
-	return rc;
-}
-
-
-int q6lsm_start(struct lsm_client *client, bool wait)
-{
-	return q6lsm_cmd(client, LSM_SESSION_CMD_START, wait);
-}
-
-int q6lsm_stop(struct lsm_client *client, bool wait)
-{
-	return q6lsm_cmd(client, LSM_SESSION_CMD_STOP, wait);
-}
-
-int q6lsm_close(struct lsm_client *client)
-{
-	return q6lsm_cmd(client, LSM_SESSION_CMD_CLOSE_TX, true);
-}
-
-int q6lsm_lab_control(struct lsm_client *client, u32 enable)
-{
-	int rc = 0;
-	struct lsm_params_lab_enable lab_enable;
-	struct lsm_params_lab_config lab_config;
-	struct lsm_module_param_ids lab_ids;
-	u32 param_size;
-
-	if (!client) {
-		pr_err("%s: invalid param client %pK\n", __func__, client);
-		return -EINVAL;
-	}
-	/* enable/disable lab on dsp */
-	q6lsm_add_hdr(client, &lab_enable.msg_hdr, sizeof(lab_enable), true);
-	lab_enable.msg_hdr.opcode = LSM_SESSION_CMD_SET_PARAMS;
-	q6lsm_set_param_hdr_info(&lab_enable.params_hdr,
-				 sizeof(struct lsm_lab_enable),
-				 0, 0, 0);
-	param_size = (sizeof(struct lsm_lab_enable) -
-		      sizeof(struct lsm_param_payload_common));
-	lab_ids.module_id = LSM_MODULE_ID_LAB;
-	lab_ids.param_id = LSM_PARAM_ID_LAB_ENABLE;
-	q6lsm_set_param_common(&lab_enable.lab_enable.common,
-				&lab_ids, param_size,
-				LSM_SESSION_CMD_SET_PARAMS);
-	lab_enable.lab_enable.enable = (enable) ? 1 : 0;
-	rc = q6lsm_apr_send_pkt(client, client->apr, &lab_enable, true, NULL);
-	if (rc) {
-		pr_err("%s: Lab enable failed rc %d\n", __func__, rc);
-		return rc;
-	}
-	if (!enable)
-		goto exit;
-	/* lab session is being enabled set the config values */
-	q6lsm_add_hdr(client, &lab_config.msg_hdr, sizeof(lab_config), true);
-	lab_config.msg_hdr.opcode = LSM_SESSION_CMD_SET_PARAMS;
-	q6lsm_set_param_hdr_info(&lab_config.params_hdr,
-				 sizeof(struct lsm_lab_config),
-				 0, 0, 0);
-	lab_ids.module_id = LSM_MODULE_ID_LAB;
-	lab_ids.param_id = LSM_PARAM_ID_LAB_CONFIG;
-	param_size = (sizeof(struct lsm_lab_config) -
-		      sizeof(struct lsm_param_payload_common));
-	q6lsm_set_param_common(&lab_config.lab_config.common,
-			       &lab_ids, param_size,
-			       LSM_SESSION_CMD_SET_PARAMS);
-	lab_config.lab_config.minor_version = 1;
-	lab_config.lab_config.wake_up_latency_ms = 250;
-	rc = q6lsm_apr_send_pkt(client, client->apr, &lab_config, true, NULL);
-	if (rc) {
-		pr_err("%s: Lab config failed rc %d disable lab\n",
-		 __func__, rc);
-		/* Lab config failed disable lab */
-		lab_enable.lab_enable.enable = 0;
-		if (q6lsm_apr_send_pkt(client, client->apr,
-			&lab_enable, true, NULL))
-			pr_err("%s: Lab disable failed\n", __func__);
-	}
-exit:
-	return rc;
-}
-
-int q6lsm_stop_lab(struct lsm_client *client)
-{
-	int rc = 0;
-
-	if (!client) {
-		pr_err("%s: invalid param client %pK\n", __func__, client);
-		return -EINVAL;
-	}
-	rc = q6lsm_cmd(client, LSM_SESSION_CMD_EOB, true);
-	if (rc)
-		pr_err("%s: Lab stop failed %d\n", __func__, rc);
-	return rc;
-}
-
-int q6lsm_read(struct lsm_client *client, struct lsm_cmd_read *read)
-{
-	int rc = 0;
-
-	if (!client || !read) {
-		pr_err("%s: Invalid params client %pK read %pK\n", __func__,
-			client, read);
-		return -EINVAL;
-	}
-	pr_debug("%s: read call memmap handle %x address %x%x size %d\n",
-		 __func__, read->mem_map_handle, read->buf_addr_msw,
-		read->buf_addr_lsw, read->buf_size);
-	q6lsm_add_hdr(client, &read->hdr, sizeof(struct lsm_cmd_read), true);
-	read->hdr.opcode = LSM_SESSION_CMD_READ;
-	rc = q6lsm_apr_send_pkt(client, client->apr, read, false, NULL);
-	if (rc)
-		pr_err("%s: read buffer call failed rc %d\n", __func__, rc);
-	return rc;
-}
-
-int q6lsm_lab_buffer_alloc(struct lsm_client *client, bool alloc)
-{
-	int ret = 0, i = 0;
-	size_t allocate_size = 0, len = 0;
-
-	if (!client) {
-		pr_err("%s: invalid client\n", __func__);
-		return -EINVAL;
-	}
-	if (alloc) {
-		if (client->lab_buffer) {
-			pr_err("%s: buffers are allocated period count %d period size %d\n",
-				__func__,
-				client->hw_params.period_count,
-				client->hw_params.buf_sz);
-			return -EINVAL;
-		}
-		allocate_size = client->hw_params.period_count *
-				client->hw_params.buf_sz;
-		allocate_size = PAGE_ALIGN(allocate_size);
-		client->lab_buffer =
-			kzalloc(sizeof(struct lsm_lab_buffer) *
-			client->hw_params.period_count, GFP_KERNEL);
-		if (!client->lab_buffer) {
-			pr_err("%s: memory allocation for lab buffer failed count %d\n"
-				, __func__,
-				client->hw_params.period_count);
-			return -ENOMEM;
-		}
-		ret = msm_audio_ion_alloc("lsm_lab",
-			&client->lab_buffer[0].client,
-			&client->lab_buffer[0].handle,
-			allocate_size, &client->lab_buffer[0].phys,
-			&len,
-			&client->lab_buffer[0].data);
-		if (ret)
-			pr_err("%s: ion alloc failed ret %d size %zd\n",
-				__func__, ret, allocate_size);
-		else {
-			ret = q6lsm_memory_map_regions(client,
-				client->lab_buffer[0].phys, len,
-				&client->lab_buffer[0].mem_map_handle);
-			if (ret) {
-				pr_err("%s: memory map filed ret %d size %zd\n",
-					__func__, ret, len);
-				msm_audio_ion_free(
-				client->lab_buffer[0].client,
-				client->lab_buffer[0].handle);
-			}
-		}
-		if (ret) {
-			pr_err("%s: alloc lab buffer failed ret %d\n",
-				__func__, ret);
-			kfree(client->lab_buffer);
-			client->lab_buffer = NULL;
-		} else {
-			pr_debug("%s: Memory map handle %x phys %pK size %d\n",
-				__func__,
-				client->lab_buffer[0].mem_map_handle,
-				&client->lab_buffer[0].phys,
-				client->hw_params.buf_sz);
-			for (i = 0; i < client->hw_params.period_count; i++) {
-				client->lab_buffer[i].phys =
-				client->lab_buffer[0].phys +
-				(i * client->hw_params.buf_sz);
-				client->lab_buffer[i].size =
-				client->hw_params.buf_sz;
-				client->lab_buffer[i].data =
-				(u8 *)(client->lab_buffer[0].data) +
-				(i * client->hw_params.buf_sz);
-				client->lab_buffer[i].mem_map_handle =
-				client->lab_buffer[0].mem_map_handle;
-			}
-		}
-	} else {
-		ret = q6lsm_memory_unmap_regions(client,
-			client->lab_buffer[0].mem_map_handle);
-		if (!ret)
-			msm_audio_ion_free(
-			client->lab_buffer[0].client,
-			client->lab_buffer[0].handle);
-		else
-			pr_err("%s: unmap failed not freeing memory\n",
-			__func__);
-		kfree(client->lab_buffer);
-		client->lab_buffer = NULL;
-	}
-	return ret;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case LSM_CUST_TOPOLOGY_CAL_TYPE:
-		ret = LSM_CUSTOM_TOP_IDX;
-		break;
-	case LSM_TOPOLOGY_CAL_TYPE:
-		ret = LSM_TOP_IDX;
-		break;
-	case LSM_CAL_TYPE:
-		ret = LSM_CAL_IDX;
-		break;
-	default:
-		pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-static int q6lsm_alloc_cal(int32_t cal_type,
-				size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		lsm_common.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6lsm_dealloc_cal(int32_t cal_type,
-				size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-		lsm_common.cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int q6lsm_set_cal(int32_t cal_type,
-			size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s:\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-		lsm_common.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (cal_index == LSM_CUSTOM_TOP_IDX) {
-		mutex_lock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-		lsm_common.set_custom_topology = 1;
-		mutex_unlock(&lsm_common.cal_data[LSM_CUSTOM_TOP_IDX]->lock);
-	}
-
-done:
-	return ret;
-}
-
-static void lsm_delete_cal_data(void)
-{
-	pr_debug("%s:\n", __func__);
-
-	cal_utils_destroy_cal_types(LSM_MAX_CAL_IDX, lsm_common.cal_data);
-}
-
-static int q6lsm_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info	cal_type_info[] = {
-		{{LSM_CUST_TOPOLOGY_CAL_TYPE,
-		{q6lsm_alloc_cal, q6lsm_dealloc_cal, NULL,
-		q6lsm_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{LSM_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL,
-		q6lsm_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{LSM_CAL_TYPE,
-		{q6lsm_alloc_cal, q6lsm_dealloc_cal, NULL,
-		q6lsm_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} }
-	};
-	pr_debug("%s:\n", __func__);
-
-	ret = cal_utils_create_cal_types(LSM_MAX_CAL_IDX,
-		lsm_common.cal_data, cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: could not create cal type!\n",
-			__func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	lsm_delete_cal_data();
-	return ret;
-}
-
-static int __init q6lsm_init(void)
-{
-	int i = 0;
-
-	pr_debug("%s:\n", __func__);
-	spin_lock_init(&lsm_session_lock);
-	spin_lock_init(&mmap_lock);
-	mutex_init(&lsm_common.apr_lock);
-	for (; i <= LSM_MAX_SESSION_ID; i++) {
-		lsm_common.common_client[i].session = LSM_CONTROL_SESSION;
-		init_waitqueue_head(&lsm_common.common_client[i].cmd_wait);
-		mutex_init(&lsm_common.common_client[i].cmd_lock);
-		atomic_set(&lsm_common.common_client[i].cmd_state,
-			   CMD_STATE_CLEARED);
-	}
-
-	if (q6lsm_init_cal_data())
-		pr_err("%s: could not init cal data!\n", __func__);
-
-	return 0;
-}
-
-static void __exit q6lsm_exit(void)
-{
-	lsm_delete_cal_data();
-}
-
-device_initcall(q6lsm_init);
-__exitcall(q6lsm_exit);
diff --git a/sound/soc/msm/qdsp6v2/q6voice.c b/sound/soc/msm/qdsp6v2/q6voice.c
deleted file mode 100644
index a85e0fd..0000000
--- a/sound/soc/msm/qdsp6v2/q6voice.c
+++ /dev/null
@@ -1,8998 +0,0 @@
-/*  Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-#include <linux/slab.h>
-#include <linux/kthread.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/mutex.h>
-#include <linux/msm_audio_ion.h>
-
-#include <soc/qcom/socinfo.h>
-#include <linux/qdsp6v2/apr_tal.h>
-
-#include "sound/q6core.h"
-#include "sound/q6audio-v2.h"
-#include "sound/apr_audio-v2.h"
-#include "sound/q6afe-v2.h"
-#include <sound/audio_cal_utils.h>
-#include "q6voice.h"
-#include <sound/adsp_err.h>
-
-#define TIMEOUT_MS 300
-
-
-#define CMD_STATUS_SUCCESS 0
-#define CMD_STATUS_FAIL 1
-#define NUM_CHANNELS_MONO 1
-#define NUM_CHANNELS_STEREO 2
-#define CVP_VERSION_2 2
-
-enum {
-	VOC_TOKEN_NONE,
-	VOIP_MEM_MAP_TOKEN,
-	VOC_CAL_MEM_MAP_TOKEN,
-	VOC_VOICE_HOST_PCM_MAP_TOKEN,
-	VOC_RTAC_MEM_MAP_TOKEN,
-	VOC_SOURCE_TRACKING_MEM_MAP_TOKEN
-};
-
-struct cvd_version_table cvd_version_table_mapping[CVD_INT_VERSION_MAX] = {
-		{CVD_VERSION_DEFAULT, CVD_INT_VERSION_DEFAULT},
-		{CVD_VERSION_0_0, CVD_INT_VERSION_0_0},
-		{CVD_VERSION_2_1, CVD_INT_VERSION_2_1},
-		{CVD_VERSION_2_2, CVD_INT_VERSION_2_2},
-		{CVD_VERSION_2_3, CVD_INT_VERSION_2_3},
-};
-
-static struct common_data common;
-static bool module_initialized;
-
-static int voice_send_enable_vocproc_cmd(struct voice_data *v);
-static int voice_send_netid_timing_cmd(struct voice_data *v);
-static int voice_send_attach_vocproc_cmd(struct voice_data *v);
-static int voice_send_set_device_cmd(struct voice_data *v);
-static int voice_send_vol_step_cmd(struct voice_data *v);
-static int voice_send_mvm_unmap_memory_physical_cmd(struct voice_data *v,
-						    uint32_t mem_handle);
-static int voice_send_mvm_cal_network_cmd(struct voice_data *v);
-static int voice_send_mvm_media_type_cmd(struct voice_data *v);
-static int voice_send_mvm_cvd_version_cmd(struct voice_data *v);
-static int voice_send_cvs_data_exchange_mode_cmd(struct voice_data *v);
-static int voice_send_cvs_packet_exchange_config_cmd(struct voice_data *v);
-static int voice_set_packet_exchange_mode_and_config(uint32_t session_id,
-						     uint32_t mode);
-
-static int voice_send_cvs_register_cal_cmd(struct voice_data *v);
-static int voice_send_cvs_deregister_cal_cmd(struct voice_data *v);
-static int voice_send_cvp_create_cmd(struct voice_data *v);
-static int voice_send_cvp_register_dev_cfg_cmd(struct voice_data *v);
-static int voice_send_cvp_deregister_dev_cfg_cmd(struct voice_data *v);
-static int voice_send_cvp_register_cal_cmd(struct voice_data *v);
-static int voice_send_cvp_deregister_cal_cmd(struct voice_data *v);
-static int voice_send_cvp_register_vol_cal_cmd(struct voice_data *v);
-static int voice_send_cvp_deregister_vol_cal_cmd(struct voice_data *v);
-static int voice_send_cvp_media_fmt_info_cmd(struct voice_data *v);
-static int voice_send_cvp_device_channels_cmd(struct voice_data *v);
-static int voice_send_cvp_media_format_cmd(struct voice_data *v,
-					   uint32_t param_type);
-static int voice_send_cvp_topology_commit_cmd(struct voice_data *v);
-static int voice_send_cvp_channel_info_cmd(struct voice_data *v);
-static int voice_send_cvp_channel_info_v2(struct voice_data *v,
-					  uint32_t param_type);
-static int voice_get_avcs_version_per_service(uint32_t service_id);
-
-
-static int voice_cvs_stop_playback(struct voice_data *v);
-static int voice_cvs_start_playback(struct voice_data *v);
-static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode);
-static int voice_cvs_stop_record(struct voice_data *v);
-
-static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv);
-static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv);
-static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv);
-
-static int voice_send_set_pp_enable_cmd(struct voice_data *v,
-					uint32_t module_id, int enable);
-static int is_cal_memory_allocated(void);
-static bool is_cvd_version_queried(void);
-static int is_voip_memory_allocated(void);
-static int voice_get_cvd_int_version(char *cvd_ver_string);
-static int voice_alloc_cal_mem_map_table(void);
-static int voice_alloc_rtac_mem_map_table(void);
-static int voice_alloc_oob_shared_mem(void);
-static int voice_free_oob_shared_mem(void);
-static int voice_alloc_oob_mem_table(void);
-static int voice_alloc_and_map_oob_mem(struct voice_data *v);
-
-static struct voice_data *voice_get_session_by_idx(int idx);
-
-static int remap_cal_data(struct cal_block_data *cal_block,
-			  uint32_t session_id);
-static int voice_unmap_cal_memory(int32_t cal_type,
-				  struct cal_block_data *cal_block);
-
-static int is_source_tracking_shared_memomry_allocated(void);
-static int voice_alloc_source_tracking_shared_memory(void);
-static int voice_alloc_and_map_source_tracking_shared_memory(
-						struct voice_data *v);
-static int voice_unmap_and_free_source_tracking_shared_memory(
-						struct voice_data *v);
-static int voice_send_set_sound_focus_cmd(struct voice_data *v,
-				struct sound_focus_param soundFocusData);
-static int voice_send_get_sound_focus_cmd(struct voice_data *v,
-				struct sound_focus_param *soundFocusData);
-static int voice_send_get_source_tracking_cmd(struct voice_data *v,
-			struct source_tracking_param *sourceTrackingData);
-
-static void voice_itr_init(struct voice_session_itr *itr,
-			   u32 session_id)
-{
-	if (itr == NULL)
-		return;
-	itr->session_idx = voice_get_idx_for_session(session_id);
-	if (session_id == ALL_SESSION_VSID)
-		itr->cur_idx = 0;
-	else
-		itr->cur_idx = itr->session_idx;
-
-}
-
-static bool voice_itr_get_next_session(struct voice_session_itr *itr,
-					struct voice_data **voice)
-{
-	bool ret = false;
-
-	if (itr == NULL)
-		return false;
-	pr_debug("%s : cur idx = %d session idx = %d\n",
-			 __func__, itr->cur_idx, itr->session_idx);
-
-	if (itr->cur_idx <= itr->session_idx) {
-		ret = true;
-		*voice = voice_get_session_by_idx(itr->cur_idx);
-		itr->cur_idx++;
-	} else {
-		*voice = NULL;
-	}
-
-	return ret;
-}
-
-static bool voice_is_valid_session_id(uint32_t session_id)
-{
-	bool ret = false;
-
-	switch (session_id) {
-	case VOICE_SESSION_VSID:
-	case VOICE2_SESSION_VSID:
-	case VOLTE_SESSION_VSID:
-	case VOIP_SESSION_VSID:
-	case QCHAT_SESSION_VSID:
-	case VOWLAN_SESSION_VSID:
-	case VOICEMMODE1_VSID:
-	case VOICEMMODE2_VSID:
-	case ALL_SESSION_VSID:
-		ret = true;
-		break;
-	default:
-		pr_err("%s: Invalid session_id : %x\n", __func__, session_id);
-
-		break;
-	}
-
-	return ret;
-}
-
-static u16 voice_get_mvm_handle(struct voice_data *v)
-{
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: mvm_handle %d\n", __func__, v->mvm_handle);
-
-	return v->mvm_handle;
-}
-
-static void voice_set_mvm_handle(struct voice_data *v, u16 mvm_handle)
-{
-	pr_debug("%s: mvm_handle %d\n", __func__, mvm_handle);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return;
-	}
-
-	v->mvm_handle = mvm_handle;
-}
-
-static u16 voice_get_cvs_handle(struct voice_data *v)
-{
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: cvs_handle %d\n", __func__, v->cvs_handle);
-
-	return v->cvs_handle;
-}
-
-static void voice_set_cvs_handle(struct voice_data *v, u16 cvs_handle)
-{
-	pr_debug("%s: cvs_handle %d\n", __func__, cvs_handle);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return;
-	}
-
-	v->cvs_handle = cvs_handle;
-}
-
-static u16 voice_get_cvp_handle(struct voice_data *v)
-{
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return 0;
-	}
-
-	pr_debug("%s: cvp_handle %d\n", __func__, v->cvp_handle);
-
-	return v->cvp_handle;
-}
-
-static void voice_set_cvp_handle(struct voice_data *v, u16 cvp_handle)
-{
-	pr_debug("%s: cvp_handle %d\n", __func__, cvp_handle);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return;
-	}
-
-	v->cvp_handle = cvp_handle;
-}
-
-char *voc_get_session_name(u32 session_id)
-{
-	char *session_name = NULL;
-
-	if (session_id == common.voice[VOC_PATH_PASSIVE].session_id) {
-		session_name = VOICE_SESSION_NAME;
-	} else if (session_id ==
-			common.voice[VOC_PATH_VOLTE_PASSIVE].session_id) {
-		session_name = VOLTE_SESSION_NAME;
-	} else if (session_id ==
-			common.voice[VOC_PATH_QCHAT_PASSIVE].session_id) {
-		session_name = QCHAT_SESSION_NAME;
-	} else if (session_id ==
-			common.voice[VOC_PATH_VOWLAN_PASSIVE].session_id) {
-		session_name = VOWLAN_SESSION_NAME;
-	} else if (session_id ==
-		common.voice[VOC_PATH_VOICEMMODE1_PASSIVE].session_id) {
-		session_name = VOICEMMODE1_NAME;
-	} else if (session_id ==
-		common.voice[VOC_PATH_VOICEMMODE2_PASSIVE].session_id) {
-		session_name = VOICEMMODE2_NAME;
-	} else if (session_id == common.voice[VOC_PATH_FULL].session_id) {
-		session_name = VOIP_SESSION_NAME;
-	}
-	return session_name;
-}
-
-uint32_t voc_get_session_id(char *name)
-{
-	u32 session_id = 0;
-
-	if (name != NULL) {
-		if (!strcmp(name, "Voice session"))
-			session_id = common.voice[VOC_PATH_PASSIVE].session_id;
-		else if (!strcmp(name, "Voice2 session"))
-			session_id =
-			common.voice[VOC_PATH_VOICE2_PASSIVE].session_id;
-		else if (!strcmp(name, "VoLTE session"))
-			session_id =
-			common.voice[VOC_PATH_VOLTE_PASSIVE].session_id;
-		else if (!strcmp(name, "QCHAT session"))
-			session_id =
-			common.voice[VOC_PATH_QCHAT_PASSIVE].session_id;
-		else if (!strcmp(name, "VoWLAN session"))
-			session_id =
-			common.voice[VOC_PATH_VOWLAN_PASSIVE].session_id;
-		else if (!strcmp(name, "VoiceMMode1"))
-			session_id =
-			common.voice[VOC_PATH_VOICEMMODE1_PASSIVE].session_id;
-		else if (!strcmp(name, "VoiceMMode2"))
-			session_id =
-			common.voice[VOC_PATH_VOICEMMODE2_PASSIVE].session_id;
-		else
-			session_id = common.voice[VOC_PATH_FULL].session_id;
-
-		pr_debug("%s: %s has session id 0x%x\n", __func__, name,
-				session_id);
-	}
-
-	return session_id;
-}
-
-static struct voice_data *voice_get_session(u32 session_id)
-{
-	struct voice_data *v = NULL;
-
-	switch (session_id) {
-	case VOICE_SESSION_VSID:
-		v = &common.voice[VOC_PATH_PASSIVE];
-		break;
-
-	case VOICE2_SESSION_VSID:
-		v = &common.voice[VOC_PATH_VOICE2_PASSIVE];
-		break;
-
-	case VOLTE_SESSION_VSID:
-		v = &common.voice[VOC_PATH_VOLTE_PASSIVE];
-		break;
-
-	case VOIP_SESSION_VSID:
-		v = &common.voice[VOC_PATH_FULL];
-		break;
-
-	case QCHAT_SESSION_VSID:
-		v = &common.voice[VOC_PATH_QCHAT_PASSIVE];
-		break;
-
-	case VOWLAN_SESSION_VSID:
-		v = &common.voice[VOC_PATH_VOWLAN_PASSIVE];
-		break;
-
-	case VOICEMMODE1_VSID:
-		v = &common.voice[VOC_PATH_VOICEMMODE1_PASSIVE];
-		break;
-
-	case VOICEMMODE2_VSID:
-		v = &common.voice[VOC_PATH_VOICEMMODE2_PASSIVE];
-		break;
-
-	case ALL_SESSION_VSID:
-		break;
-
-	default:
-		pr_err("%s: Invalid session_id : %x\n", __func__, session_id);
-
-		break;
-	}
-
-	pr_debug("%s:session_id 0x%x session handle %pK\n",
-		__func__, session_id, v);
-
-	return v;
-}
-
-int voice_get_idx_for_session(u32 session_id)
-{
-	int idx = 0;
-
-	switch (session_id) {
-	case VOICE_SESSION_VSID:
-		idx = VOC_PATH_PASSIVE;
-		break;
-
-	case VOICE2_SESSION_VSID:
-		idx = VOC_PATH_VOICE2_PASSIVE;
-		break;
-
-	case VOLTE_SESSION_VSID:
-		idx = VOC_PATH_VOLTE_PASSIVE;
-		break;
-
-	case VOIP_SESSION_VSID:
-		idx = VOC_PATH_FULL;
-		break;
-
-	case QCHAT_SESSION_VSID:
-		idx = VOC_PATH_QCHAT_PASSIVE;
-		break;
-
-	case VOWLAN_SESSION_VSID:
-		idx = VOC_PATH_VOWLAN_PASSIVE;
-		break;
-
-	case VOICEMMODE1_VSID:
-		idx = VOC_PATH_VOICEMMODE1_PASSIVE;
-		break;
-
-	case VOICEMMODE2_VSID:
-		idx = VOC_PATH_VOICEMMODE2_PASSIVE;
-		break;
-
-	case ALL_SESSION_VSID:
-		idx = MAX_VOC_SESSIONS - 1;
-		break;
-
-	default:
-		pr_err("%s: Invalid session_id : %x\n", __func__, session_id);
-
-		break;
-	}
-
-	return idx;
-}
-
-static struct voice_data *voice_get_session_by_idx(int idx)
-{
-	return ((idx < 0 || idx >= MAX_VOC_SESSIONS) ?
-				NULL : &common.voice[idx]);
-}
-
-static bool is_voip_session(u32 session_id)
-{
-	return (session_id == common.voice[VOC_PATH_FULL].session_id);
-}
-
-static bool is_volte_session(u32 session_id)
-{
-	return (session_id == common.voice[VOC_PATH_VOLTE_PASSIVE].session_id);
-}
-
-static bool is_voice2_session(u32 session_id)
-{
-	return (session_id == common.voice[VOC_PATH_VOICE2_PASSIVE].session_id);
-}
-
-static bool is_qchat_session(u32 session_id)
-{
-	return (session_id == common.voice[VOC_PATH_QCHAT_PASSIVE].session_id);
-}
-
-static bool is_vowlan_session(u32 session_id)
-{
-	return (session_id == common.voice[VOC_PATH_VOWLAN_PASSIVE].session_id);
-}
-
-static bool is_voicemmode1(u32 session_id)
-{
-	return session_id ==
-			common.voice[VOC_PATH_VOICEMMODE1_PASSIVE].session_id;
-}
-
-static bool is_voicemmode2(u32 session_id)
-{
-	return session_id ==
-			common.voice[VOC_PATH_VOICEMMODE2_PASSIVE].session_id;
-}
-
-static bool is_voc_state_active(int voc_state)
-{
-	if ((voc_state == VOC_RUN) ||
-		(voc_state == VOC_CHANGE) ||
-		(voc_state == VOC_STANDBY))
-		return true;
-
-	return false;
-}
-
-static void voc_set_error_state(uint16_t reset_proc)
-{
-	struct voice_data *v = NULL;
-	int i;
-
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		v = &common.voice[i];
-		if (v != NULL) {
-			v->voc_state = VOC_ERROR;
-			v->rec_info.recording = 0;
-		}
-	}
-}
-
-static bool is_other_session_active(u32 session_id)
-{
-	int i;
-	bool ret = false;
-
-	/* Check if there is other active session except the input one */
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		if (common.voice[i].session_id == session_id)
-			continue;
-
-		if (is_voc_state_active(common.voice[i].voc_state)) {
-			ret = true;
-			break;
-		}
-	}
-	pr_debug("%s: ret %d\n", __func__, ret);
-
-	return ret;
-}
-
-static bool is_sub1_vsid(u32 session_id)
-{
-	bool ret;
-
-	switch (session_id) {
-	case VOICE_SESSION_VSID:
-	case VOLTE_SESSION_VSID:
-	case VOWLAN_SESSION_VSID:
-	case VOICEMMODE1_VSID:
-		ret = true;
-		break;
-	default:
-		ret = false;
-	}
-
-	return ret;
-}
-
-static bool is_sub2_vsid(u32 session_id)
-{
-	bool ret;
-
-	switch (session_id) {
-	case VOICE2_SESSION_VSID:
-	case VOICEMMODE2_VSID:
-		ret = true;
-		break;
-	default:
-		ret = false;
-	}
-
-	return ret;
-}
-
-static bool is_voice_app_id(u32 session_id)
-{
-	return is_sub1_vsid(session_id) || is_sub2_vsid(session_id);
-}
-
-static void init_session_id(void)
-{
-	common.voice[VOC_PATH_PASSIVE].session_id = VOICE_SESSION_VSID;
-	common.voice[VOC_PATH_VOLTE_PASSIVE].session_id = VOLTE_SESSION_VSID;
-	common.voice[VOC_PATH_VOICE2_PASSIVE].session_id = VOICE2_SESSION_VSID;
-	common.voice[VOC_PATH_FULL].session_id = VOIP_SESSION_VSID;
-	common.voice[VOC_PATH_QCHAT_PASSIVE].session_id = QCHAT_SESSION_VSID;
-	common.voice[VOC_PATH_VOWLAN_PASSIVE].session_id = VOWLAN_SESSION_VSID;
-	common.voice[VOC_PATH_VOICEMMODE1_PASSIVE].session_id =
-							VOICEMMODE1_VSID;
-	common.voice[VOC_PATH_VOICEMMODE2_PASSIVE].session_id =
-							VOICEMMODE2_VSID;
-}
-
-static bool is_cvd_version_queried(void)
-{
-	bool ret = 0;
-
-	if (!strcmp(common.cvd_version, CVD_VERSION_DEFAULT))
-		ret = false;
-	else
-		ret = true;
-
-	return ret;
-}
-
-static int voice_get_cvd_int_version(char *cvd_ver_string)
-{
-	unsigned int idx;
-	int cvd_int_ver = CVD_INT_VERSION_DEFAULT;
-
-	for (idx = 0; idx < CVD_INT_VERSION_MAX; idx++) {
-		if (strcmp((char *)cvd_ver_string,
-			  cvd_version_table_mapping[idx].cvd_ver) == 0) {
-			cvd_int_ver =
-			cvd_version_table_mapping[idx].cvd_ver_int;
-			break;
-		}
-	}
-	return cvd_int_ver;
-}
-
-static int voice_apr_register(uint32_t session_id)
-{
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&common.common_lock);
-
-	/* register callback to APR */
-	if (common.apr_q6_mvm == NULL) {
-		pr_debug("%s: Start to register MVM callback\n", __func__);
-
-		common.apr_q6_mvm = apr_register("ADSP", "MVM",
-						 qdsp_mvm_callback,
-						 0xFFFFFFFF, &common);
-
-		if (common.apr_q6_mvm == NULL) {
-			pr_err("%s: Unable to register MVM\n", __func__);
-			goto err;
-		}
-	}
-
-	if (common.apr_q6_cvs == NULL) {
-		pr_debug("%s: Start to register CVS callback\n", __func__);
-
-		common.apr_q6_cvs = apr_register("ADSP", "CVS",
-						 qdsp_cvs_callback,
-						 0xFFFFFFFF, &common);
-
-		if (common.apr_q6_cvs == NULL) {
-			pr_err("%s: Unable to register CVS\n", __func__);
-			goto err;
-		}
-		rtac_set_voice_handle(RTAC_CVS, common.apr_q6_cvs);
-	}
-
-	if (common.apr_q6_cvp == NULL) {
-		pr_debug("%s: Start to register CVP callback\n", __func__);
-
-		common.apr_q6_cvp = apr_register("ADSP", "CVP",
-						 qdsp_cvp_callback,
-						 0xFFFFFFFF, &common);
-
-		if (common.apr_q6_cvp == NULL) {
-			pr_err("%s: Unable to register CVP\n", __func__);
-			goto err;
-		}
-		rtac_set_voice_handle(RTAC_CVP, common.apr_q6_cvp);
-	}
-
-	mutex_unlock(&common.common_lock);
-
-	return 0;
-
-err:
-	if (common.apr_q6_cvs != NULL) {
-		apr_deregister(common.apr_q6_cvs);
-		common.apr_q6_cvs = NULL;
-		rtac_set_voice_handle(RTAC_CVS, NULL);
-	}
-	if (common.apr_q6_mvm != NULL) {
-		apr_deregister(common.apr_q6_mvm);
-		common.apr_q6_mvm = NULL;
-	}
-
-	mutex_unlock(&common.common_lock);
-
-	return -ENODEV;
-}
-
-static int voice_send_mvm_cvd_version_cmd(struct voice_data *v)
-{
-	int ret;
-	struct apr_hdr cvd_version_get_cmd;
-	void *apr_mvm;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_mvm = common.apr_q6_mvm;
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/* Send command to CVD to retrieve Version */
-	cvd_version_get_cmd.hdr_field = APR_HDR_FIELD(
-				APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE),
-				APR_PKT_VER);
-	cvd_version_get_cmd.pkt_size = APR_PKT_SIZE(
-				APR_HDR_SIZE,
-				sizeof(cvd_version_get_cmd) -
-				APR_HDR_SIZE);
-	cvd_version_get_cmd.src_port =
-		voice_get_idx_for_session(v->session_id);
-	cvd_version_get_cmd.dest_port = 0;
-	cvd_version_get_cmd.token = 0;
-	cvd_version_get_cmd.opcode = VSS_IVERSION_CMD_GET;
-
-	pr_debug("%s: send CVD version get cmd, pkt size = %d\n",
-		 __func__, cvd_version_get_cmd.pkt_size);
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm,
-			   (uint32_t *) &cvd_version_get_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error sending command\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-			(v->mvm_state == CMD_STATUS_SUCCESS),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout, fall back to default\n",
-		       __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-			v->async_err);
-		goto done;
-	}
-	ret = 0;
-
-done:
-	if (ret) {
-		strlcpy(common.cvd_version, CVD_VERSION_0_0,
-				sizeof(common.cvd_version));
-	}
-	pr_debug("%s: CVD Version retrieved=%s\n",
-		 __func__, common.cvd_version);
-
-	return ret;
-}
-
-static int voice_send_dual_control_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct mvm_modem_dual_control_session_cmd mvm_voice_ctl_cmd;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: Send Dual Control command to MVM\n", __func__);
-	if (!is_voip_session(v->session_id)) {
-		mvm_handle = voice_get_mvm_handle(v);
-		mvm_voice_ctl_cmd.hdr.hdr_field = APR_HDR_FIELD(
-						APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-		mvm_voice_ctl_cmd.hdr.pkt_size = APR_PKT_SIZE(
-						APR_HDR_SIZE,
-						sizeof(mvm_voice_ctl_cmd) -
-						APR_HDR_SIZE);
-		pr_debug("%s: send mvm Voice Ctl pkt size = %d\n",
-			__func__, mvm_voice_ctl_cmd.hdr.pkt_size);
-		mvm_voice_ctl_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		mvm_voice_ctl_cmd.hdr.dest_port = mvm_handle;
-		mvm_voice_ctl_cmd.hdr.token = 0;
-		mvm_voice_ctl_cmd.hdr.opcode =
-					VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL;
-		mvm_voice_ctl_cmd.voice_ctl.enable_flag = true;
-		v->mvm_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_voice_ctl_cmd);
-		if (ret < 0) {
-			pr_err("%s: Error sending MVM Voice CTL CMD\n",
-							__func__);
-			ret = -EINVAL;
-			goto fail;
-		}
-		ret = wait_event_timeout(v->mvm_wait,
-				(v->mvm_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-			ret = -EINVAL;
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-	}
-	ret = 0;
-fail:
-	return ret;
-}
-
-
-static int voice_create_mvm_cvs_session(struct voice_data *v)
-{
-	int ret = 0;
-	struct mvm_create_ctl_session_cmd mvm_session_cmd;
-	struct cvs_create_passive_ctl_session_cmd cvs_session_cmd;
-	struct cvs_create_full_ctl_session_cmd cvs_full_ctl_cmd;
-	struct mvm_attach_stream_cmd attach_stream_cmd;
-	void *apr_mvm, *apr_cvs, *apr_cvp;
-	u16 mvm_handle, cvs_handle, cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-	apr_cvs = common.apr_q6_cvs;
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_mvm || !apr_cvs || !apr_cvp) {
-		pr_err("%s: apr_mvm or apr_cvs or apr_cvp is NULL\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-	cvs_handle = voice_get_cvs_handle(v);
-	cvp_handle = voice_get_cvp_handle(v);
-
-	pr_debug("%s: mvm_hdl=%d, cvs_hdl=%d\n", __func__,
-		mvm_handle, cvs_handle);
-	/* send cmd to create mvm session and wait for response */
-
-	if (!mvm_handle) {
-		memset(mvm_session_cmd.mvm_session.name, 0,
-			sizeof(mvm_session_cmd.mvm_session.name));
-		if (!is_voip_session(v->session_id)) {
-			mvm_session_cmd.hdr.hdr_field = APR_HDR_FIELD(
-						APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-			mvm_session_cmd.hdr.pkt_size = APR_PKT_SIZE(
-						APR_HDR_SIZE,
-						sizeof(mvm_session_cmd) -
-						APR_HDR_SIZE);
-			pr_debug("%s: send mvm create session pkt size = %d\n",
-				 __func__, mvm_session_cmd.hdr.pkt_size);
-			mvm_session_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-			mvm_session_cmd.hdr.dest_port = 0;
-			mvm_session_cmd.hdr.token = 0;
-			mvm_session_cmd.hdr.opcode =
-				VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION;
-			if (is_volte_session(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				"default volte voice",
-				strlen("default volte voice")+1);
-			} else if (is_voice2_session(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				VOICE2_SESSION_VSID_STR,
-				strlen(VOICE2_SESSION_VSID_STR)+1);
-			} else if (is_qchat_session(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				QCHAT_SESSION_VSID_STR,
-				strlen(QCHAT_SESSION_VSID_STR)+1);
-			} else if (is_vowlan_session(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				VOWLAN_SESSION_VSID_STR,
-				strlen(VOWLAN_SESSION_VSID_STR)+1);
-			} else if (is_voicemmode1(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				VOICEMMODE1_VSID_STR,
-				strlen(VOICEMMODE1_VSID_STR) + 1);
-			} else if (is_voicemmode2(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				VOICEMMODE2_VSID_STR,
-				strlen(VOICEMMODE2_VSID_STR) + 1);
-			} else {
-				strlcpy(mvm_session_cmd.mvm_session.name,
-				"default modem voice",
-				strlen("default modem voice")+1);
-			}
-
-			v->mvm_state = CMD_STATUS_FAIL;
-			v->async_err = 0;
-
-			ret = apr_send_pkt(apr_mvm,
-					(uint32_t *) &mvm_session_cmd);
-			if (ret < 0) {
-				pr_err("%s: Error sending MVM_CONTROL_SESSION\n",
-				       __func__);
-				goto fail;
-			}
-			ret = wait_event_timeout(v->mvm_wait,
-					(v->mvm_state == CMD_STATUS_SUCCESS),
-					msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				pr_err("%s: wait_event timeout\n", __func__);
-				goto fail;
-			}
-			if (v->async_err > 0) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					v->async_err));
-				ret = adsp_err_get_lnx_err_code(
-						v->async_err);
-				goto fail;
-			}
-		} else {
-			pr_debug("%s: creating MVM full ctrl\n", __func__);
-			mvm_session_cmd.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-			mvm_session_cmd.hdr.pkt_size =
-					APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(mvm_session_cmd) -
-					APR_HDR_SIZE);
-			mvm_session_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-			mvm_session_cmd.hdr.dest_port = 0;
-			mvm_session_cmd.hdr.token = 0;
-			mvm_session_cmd.hdr.opcode =
-				VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION;
-			strlcpy(mvm_session_cmd.mvm_session.name,
-				"default voip",
-				strlen("default voip")+1);
-
-			v->mvm_state = CMD_STATUS_FAIL;
-			v->async_err = 0;
-
-			ret = apr_send_pkt(apr_mvm,
-					(uint32_t *) &mvm_session_cmd);
-			if (ret < 0) {
-				pr_err("Fail in sending MVM_CONTROL_SESSION\n");
-				goto fail;
-			}
-			ret = wait_event_timeout(v->mvm_wait,
-					 (v->mvm_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				pr_err("%s: wait_event timeout\n", __func__);
-				goto fail;
-			}
-			if (v->async_err > 0) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					v->async_err));
-				ret = adsp_err_get_lnx_err_code(
-						v->async_err);
-				goto fail;
-			}
-		}
-		/* Get the created MVM handle. */
-		mvm_handle = voice_get_mvm_handle(v);
-	}
-	/* send cmd to create cvs session */
-	if (!cvs_handle) {
-		memset(cvs_session_cmd.cvs_session.name, 0,
-			sizeof(cvs_session_cmd.cvs_session.name));
-		if (!is_voip_session(v->session_id)) {
-			pr_debug("%s: creating CVS passive session\n",
-				 __func__);
-
-			cvs_session_cmd.hdr.hdr_field = APR_HDR_FIELD(
-						APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-			cvs_session_cmd.hdr.pkt_size =
-						APR_PKT_SIZE(APR_HDR_SIZE,
-						sizeof(cvs_session_cmd) -
-						APR_HDR_SIZE);
-			cvs_session_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-			cvs_session_cmd.hdr.dest_port = 0;
-			cvs_session_cmd.hdr.token = 0;
-			cvs_session_cmd.hdr.opcode =
-				VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION;
-			if (is_volte_session(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				"default volte voice",
-				strlen("default volte voice")+1);
-			} else if (is_voice2_session(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				VOICE2_SESSION_VSID_STR,
-				strlen(VOICE2_SESSION_VSID_STR)+1);
-			} else if (is_qchat_session(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				QCHAT_SESSION_VSID_STR,
-				strlen(QCHAT_SESSION_VSID_STR)+1);
-			} else if (is_vowlan_session(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				VOWLAN_SESSION_VSID_STR,
-				strlen(VOWLAN_SESSION_VSID_STR)+1);
-			} else if (is_voicemmode1(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				VOICEMMODE1_VSID_STR,
-				strlen(VOICEMMODE1_VSID_STR) + 1);
-			} else if (is_voicemmode2(v->session_id)) {
-				strlcpy(cvs_session_cmd.cvs_session.name,
-				VOICEMMODE2_VSID_STR,
-				strlen(VOICEMMODE2_VSID_STR) + 1);
-			} else {
-			strlcpy(cvs_session_cmd.cvs_session.name,
-				"default modem voice",
-				strlen("default modem voice")+1);
-			}
-			v->cvs_state = CMD_STATUS_FAIL;
-			v->async_err = 0;
-
-			ret = apr_send_pkt(apr_cvs,
-					(uint32_t *) &cvs_session_cmd);
-			if (ret < 0) {
-				pr_err("Fail in sending STREAM_CONTROL_SESSION\n");
-				goto fail;
-			}
-			ret = wait_event_timeout(v->cvs_wait,
-					 (v->cvs_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				pr_err("%s: wait_event timeout\n", __func__);
-				goto fail;
-			}
-			if (v->async_err > 0) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					v->async_err));
-				ret = adsp_err_get_lnx_err_code(
-						v->async_err);
-				goto fail;
-			}
-			/* Get the created CVS handle. */
-			cvs_handle = voice_get_cvs_handle(v);
-
-		} else {
-			pr_debug("%s: creating CVS full session\n", __func__);
-
-			cvs_full_ctl_cmd.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-
-			cvs_full_ctl_cmd.hdr.pkt_size =
-					APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(cvs_full_ctl_cmd) -
-					APR_HDR_SIZE);
-
-			cvs_full_ctl_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-			cvs_full_ctl_cmd.hdr.dest_port = 0;
-			cvs_full_ctl_cmd.hdr.token = 0;
-			cvs_full_ctl_cmd.hdr.opcode =
-				VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION;
-			cvs_full_ctl_cmd.cvs_session.direction = 2;
-			cvs_full_ctl_cmd.cvs_session.enc_media_type =
-						common.mvs_info.media_type;
-			cvs_full_ctl_cmd.cvs_session.dec_media_type =
-						common.mvs_info.media_type;
-			cvs_full_ctl_cmd.cvs_session.network_id =
-					       common.mvs_info.network_type;
-			strlcpy(cvs_full_ctl_cmd.cvs_session.name,
-				"default q6 voice",
-				strlen("default q6 voice")+1);
-
-			v->cvs_state = CMD_STATUS_FAIL;
-			v->async_err = 0;
-
-			ret = apr_send_pkt(apr_cvs,
-					   (uint32_t *) &cvs_full_ctl_cmd);
-
-			if (ret < 0) {
-				pr_err("%s: Err %d sending CREATE_FULL_CTRL\n",
-					__func__, ret);
-				goto fail;
-			}
-			ret = wait_event_timeout(v->cvs_wait,
-					(v->cvs_state == CMD_STATUS_SUCCESS),
-					msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				pr_err("%s: wait_event timeout\n", __func__);
-				goto fail;
-			}
-			if (v->async_err > 0) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					v->async_err));
-				ret = adsp_err_get_lnx_err_code(
-						v->async_err);
-				goto fail;
-			}
-			/* Get the created CVS handle. */
-			cvs_handle = voice_get_cvs_handle(v);
-
-			/* Attach MVM to CVS. */
-			pr_debug("%s: Attach MVM to stream\n", __func__);
-
-			attach_stream_cmd.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-			attach_stream_cmd.hdr.pkt_size =
-					APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(attach_stream_cmd) -
-					APR_HDR_SIZE);
-			attach_stream_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-			attach_stream_cmd.hdr.dest_port = mvm_handle;
-			attach_stream_cmd.hdr.token = 0;
-			attach_stream_cmd.hdr.opcode =
-						VSS_IMVM_CMD_ATTACH_STREAM;
-			attach_stream_cmd.attach_stream.handle = cvs_handle;
-
-			v->mvm_state = CMD_STATUS_FAIL;
-			v->async_err = 0;
-			ret = apr_send_pkt(apr_mvm,
-					   (uint32_t *) &attach_stream_cmd);
-			if (ret < 0) {
-				pr_err("%s: Error %d sending ATTACH_STREAM\n",
-				       __func__, ret);
-				goto fail;
-			}
-			ret = wait_event_timeout(v->mvm_wait,
-					 (v->mvm_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-			if (!ret) {
-				pr_err("%s: wait_event timeout\n", __func__);
-				goto fail;
-			}
-			if (v->async_err > 0) {
-				pr_err("%s: DSP returned error[%s]\n",
-					__func__, adsp_err_get_err_str(
-					v->async_err));
-				ret = adsp_err_get_lnx_err_code(
-						v->async_err);
-				goto fail;
-			}
-		}
-	}
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_unmap_cal_block(struct voice_data *v, int cal_index)
-{
-	int result = 0;
-	struct cal_block_data *cal_block;
-
-	if (common.cal_data[cal_index] == NULL) {
-		pr_err("%s: Cal type is NULL, index %d!\n",
-			__func__, cal_index);
-
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[cal_index]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-		common.cal_data[cal_index]);
-	if (cal_block == NULL) {
-		pr_err("%s: Cal block is NULL, index %d!\n",
-			__func__, cal_index);
-
-		result = -EINVAL;
-		goto unlock;
-	}
-
-	if (cal_block->map_data.q6map_handle == 0) {
-		pr_debug("%s: Q6 handle is not set!\n", __func__);
-
-		result = -EINVAL;
-		goto unlock;
-	}
-
-	mutex_lock(&common.common_lock);
-	result = voice_send_mvm_unmap_memory_physical_cmd(
-		v, cal_block->map_data.q6map_handle);
-	if (result)
-		pr_err("%s: Voice_send_mvm_unmap_memory_physical_cmd failed for session 0x%x, err %d!\n",
-			__func__, v->session_id, result);
-
-	cal_block->map_data.q6map_handle = 0;
-	mutex_unlock(&common.common_lock);
-unlock:
-	mutex_unlock(&common.cal_data[cal_index]->lock);
-done:
-	return result;
-}
-
-static int voice_destroy_mvm_cvs_session(struct voice_data *v)
-{
-	int ret = 0;
-	struct mvm_detach_stream_cmd detach_stream;
-	struct apr_hdr mvm_destroy;
-	struct apr_hdr cvs_destroy;
-	void *apr_mvm, *apr_cvs;
-	u16 mvm_handle, cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_mvm || !apr_cvs) {
-		pr_err("%s: apr_mvm or apr_cvs is NULL\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-	cvs_handle = voice_get_cvs_handle(v);
-
-	/* MVM, CVS sessions are destroyed only for Full control sessions. */
-	if (is_voip_session(v->session_id)) {
-		pr_debug("%s: MVM detach stream, VOC_STATE: %d\n", __func__,
-				v->voc_state);
-
-		/* Detach voice stream. */
-		detach_stream.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-		detach_stream.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(detach_stream) - APR_HDR_SIZE);
-		detach_stream.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		detach_stream.hdr.dest_port = mvm_handle;
-		detach_stream.hdr.token = 0;
-		detach_stream.hdr.opcode = VSS_IMVM_CMD_DETACH_STREAM;
-		detach_stream.detach_stream.handle = cvs_handle;
-
-		v->mvm_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-		ret = apr_send_pkt(apr_mvm, (uint32_t *) &detach_stream);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending DETACH_STREAM\n",
-			       __func__, ret);
-
-			goto fail;
-		}
-		ret = wait_event_timeout(v->mvm_wait,
-					 (v->mvm_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-
-		/* Unmap memory */
-		if (v->shmem_info.mem_handle != 0) {
-			ret = voice_send_mvm_unmap_memory_physical_cmd(v,
-						v->shmem_info.mem_handle);
-			if (ret < 0) {
-				pr_err("%s Memory_unmap for voip failed %d\n",
-				       __func__, ret);
-
-				goto fail;
-			}
-			v->shmem_info.mem_handle = 0;
-		}
-	}
-
-	/* Unmap Source Tracking shared memory if mapped earlier */
-	voice_unmap_and_free_source_tracking_shared_memory(v);
-
-	if (is_voip_session(v->session_id) ||
-	    is_qchat_session(v->session_id) ||
-	    is_volte_session(v->session_id) ||
-	    is_vowlan_session(v->session_id) ||
-	    v->voc_state == VOC_ERROR || common.is_destroy_cvd) {
-		/* Destroy CVS. */
-		pr_debug("%s: CVS destroy session\n", __func__);
-
-		cvs_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						      APR_HDR_LEN(APR_HDR_SIZE),
-						      APR_PKT_VER);
-		cvs_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(cvs_destroy) - APR_HDR_SIZE);
-		cvs_destroy.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_destroy.dest_port = cvs_handle;
-		cvs_destroy.token = 0;
-		cvs_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION;
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_destroy);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending CVS DESTROY\n",
-			       __func__, ret);
-
-			goto fail;
-		}
-		ret = wait_event_timeout(v->cvs_wait,
-					 (v->cvs_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-		cvs_handle = 0;
-		voice_set_cvs_handle(v, cvs_handle);
-
-		/* Unmap physical memory for all calibration buffers */
-		if (!is_other_session_active(v->session_id)) {
-			if (voice_unmap_cal_block(v, CVP_VOCPROC_CAL))
-				pr_err("%s: Unmap VOCPROC cal failed\n",
-					__func__);
-			if (voice_unmap_cal_block(v, CVP_VOCVOL_CAL))
-				pr_err("%s: Unmap VOCVOL cal failed\n",
-					__func__);
-			if (voice_unmap_cal_block(v, CVP_VOCDEV_CFG_CAL))
-				pr_err("%s: Unmap VOCDEV_CFG cal failed\n",
-					__func__);
-			if (voice_unmap_cal_block(v, CVS_VOCSTRM_CAL))
-				pr_err("%s: Unmap VOCSTRM cal failed\n",
-					__func__);
-		}
-
-		/* Destroy MVM. */
-		pr_debug("%s: MVM destroy session\n", __func__);
-
-		mvm_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						      APR_HDR_LEN(APR_HDR_SIZE),
-						      APR_PKT_VER);
-		mvm_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					    sizeof(mvm_destroy) - APR_HDR_SIZE);
-		mvm_destroy.src_port =
-				voice_get_idx_for_session(v->session_id);
-		mvm_destroy.dest_port = mvm_handle;
-		mvm_destroy.token = 0;
-		mvm_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION;
-
-		v->mvm_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_destroy);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending MVM DESTROY\n",
-			       __func__, ret);
-
-			goto fail;
-		}
-		ret = wait_event_timeout(v->mvm_wait,
-					 (v->mvm_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait event timeout\n", __func__);
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-		mvm_handle = 0;
-		voice_set_mvm_handle(v, mvm_handle);
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_tty_mode_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct mvm_set_tty_mode_cmd mvm_tty_mode_cmd;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	/* send tty mode cmd to mvm */
-	mvm_tty_mode_cmd.hdr.hdr_field = APR_HDR_FIELD(
-					APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-	mvm_tty_mode_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(mvm_tty_mode_cmd) -
-					APR_HDR_SIZE);
-	pr_debug("%s: pkt size = %d\n",
-		 __func__, mvm_tty_mode_cmd.hdr.pkt_size);
-	mvm_tty_mode_cmd.hdr.src_port =
-			voice_get_idx_for_session(v->session_id);
-	mvm_tty_mode_cmd.hdr.dest_port = mvm_handle;
-	mvm_tty_mode_cmd.hdr.token = 0;
-	mvm_tty_mode_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_TTY_MODE;
-	mvm_tty_mode_cmd.tty_mode.mode = v->tty_mode;
-	pr_debug("tty mode =%d\n", mvm_tty_mode_cmd.tty_mode.mode);
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_tty_mode_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_TTY_MODE\n",
-		       __func__, ret);
-		goto fail;
-	}
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_set_pp_enable_cmd(struct voice_data *v,
-					uint32_t module_id, int enable)
-{
-	struct cvs_set_pp_enable_cmd cvs_set_pp_cmd;
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvs_handle = voice_get_cvs_handle(v);
-
-	cvs_set_pp_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						     APR_HDR_LEN(APR_HDR_SIZE),
-						     APR_PKT_VER);
-	cvs_set_pp_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-						   sizeof(cvs_set_pp_cmd) -
-						   APR_HDR_SIZE);
-	cvs_set_pp_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
-	cvs_set_pp_cmd.hdr.dest_port = cvs_handle;
-	cvs_set_pp_cmd.hdr.token = 0;
-	cvs_set_pp_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_UI_PROPERTY;
-
-	cvs_set_pp_cmd.vss_set_pp.module_id = module_id;
-	cvs_set_pp_cmd.vss_set_pp.param_id = VOICE_PARAM_MOD_ENABLE;
-	cvs_set_pp_cmd.vss_set_pp.param_size = MOD_ENABLE_PARAM_LEN;
-	cvs_set_pp_cmd.vss_set_pp.reserved = 0;
-	cvs_set_pp_cmd.vss_set_pp.enable = enable;
-	cvs_set_pp_cmd.vss_set_pp.reserved_field = 0;
-	pr_debug("voice_send_set_pp_enable_cmd, module_id=%d, enable=%d\n",
-		module_id, enable);
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_pp_cmd);
-	if (ret < 0) {
-		pr_err("Fail: sending cvs set pp enable,\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_hd_cmd(struct voice_data *v, int enable)
-{
-	struct mvm_set_hd_enable_cmd mvm_set_hd_cmd;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_mvm = common.apr_q6_mvm;
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mvm_handle = voice_get_mvm_handle(v);
-	if (!mvm_handle) {
-		pr_err("%s: mvm_handle is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mvm_set_hd_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						     APR_HDR_LEN(APR_HDR_SIZE),
-						     APR_PKT_VER);
-	mvm_set_hd_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-						   sizeof(mvm_set_hd_cmd) -
-						   APR_HDR_SIZE);
-	mvm_set_hd_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
-	mvm_set_hd_cmd.hdr.dest_port = mvm_handle;
-	mvm_set_hd_cmd.hdr.token = 0;
-
-	if (enable)
-		mvm_set_hd_cmd.hdr.opcode = VSS_IHDVOICE_CMD_ENABLE;
-	else
-		mvm_set_hd_cmd.hdr.opcode = VSS_IHDVOICE_CMD_DISABLE;
-
-	pr_debug("%s: enable=%d\n", __func__, enable);
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_hd_cmd);
-	if (ret < 0) {
-		pr_err("%s: Failed to sending mvm set HD Voice enable %d\n",
-		       __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_set_dtx(struct voice_data *v)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-	struct cvs_set_enc_dtx_mode_cmd cvs_set_dtx;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	/* Set DTX */
-	cvs_set_dtx.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					      APR_HDR_LEN(APR_HDR_SIZE),
-					      APR_PKT_VER);
-	cvs_set_dtx.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(cvs_set_dtx) - APR_HDR_SIZE);
-	cvs_set_dtx.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_set_dtx.hdr.dest_port = cvs_handle;
-	cvs_set_dtx.hdr.token = 0;
-	cvs_set_dtx.hdr.opcode = VSS_ISTREAM_CMD_SET_ENC_DTX_MODE;
-	cvs_set_dtx.dtx_mode.enable = common.mvs_info.dtx_mode;
-
-	pr_debug("%s: Setting DTX %d\n", __func__, common.mvs_info.dtx_mode);
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_dtx);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_DTX\n", __func__, ret);
-		return -EINVAL;
-	}
-
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		return -EINVAL;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int voice_send_mvm_media_type_cmd(struct voice_data *v)
-{
-	struct vss_imvm_cmd_set_cal_media_type_t mvm_set_cal_media_type;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	mvm_set_cal_media_type.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-	mvm_set_cal_media_type.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(mvm_set_cal_media_type) -
-					APR_HDR_SIZE);
-	mvm_set_cal_media_type.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_set_cal_media_type.hdr.dest_port = mvm_handle;
-	mvm_set_cal_media_type.hdr.token = 0;
-	mvm_set_cal_media_type.hdr.opcode = VSS_IMVM_CMD_SET_CAL_MEDIA_TYPE;
-	mvm_set_cal_media_type.media_id = common.mvs_info.media_type;
-	pr_debug("%s: setting media_id as %x\n",
-		 __func__, mvm_set_cal_media_type.media_id);
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_cal_media_type);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending media type\n", __func__, ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				(v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout %d\n", __func__, ret);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_dtmf_rx_detection_cmd(struct voice_data *v,
-					    uint32_t enable)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-	struct cvs_set_rx_dtmf_detection_cmd cvs_dtmf_rx_detection;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	/* Set SET_DTMF_RX_DETECTION */
-	cvs_dtmf_rx_detection.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					      APR_HDR_LEN(APR_HDR_SIZE),
-					      APR_PKT_VER);
-	cvs_dtmf_rx_detection.hdr.pkt_size =
-				APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvs_dtmf_rx_detection) - APR_HDR_SIZE);
-	cvs_dtmf_rx_detection.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_dtmf_rx_detection.hdr.dest_port = cvs_handle;
-	cvs_dtmf_rx_detection.hdr.token = 0;
-	cvs_dtmf_rx_detection.hdr.opcode =
-					VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION;
-	cvs_dtmf_rx_detection.cvs_dtmf_det.enable = enable;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_dtmf_rx_detection);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_DTMF_RX_DETECTION\n",
-		       __func__,
-		       ret);
-		return -EINVAL;
-	}
-
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		return -EINVAL;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		return ret;
-	}
-
-	return ret;
-}
-
-void voc_disable_dtmf_det_on_active_sessions(void)
-{
-	struct voice_data *v = NULL;
-	int i;
-
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		v = &common.voice[i];
-		if ((v->dtmf_rx_detect_en) &&
-			is_voc_state_active(v->voc_state)) {
-
-			pr_debug("disable dtmf det on ses_id=%d\n",
-				 v->session_id);
-			voice_send_dtmf_rx_detection_cmd(v, 0);
-		}
-	}
-}
-
-int voc_enable_dtmf_rx_detection(uint32_t session_id, uint32_t enable)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-	v->dtmf_rx_detect_en = enable;
-
-	if (is_voc_state_active(v->voc_state))
-		ret = voice_send_dtmf_rx_detection_cmd(v,
-						       v->dtmf_rx_detect_en);
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-void voc_set_destroy_cvd_flag(bool is_destroy_cvd)
-{
-	pr_debug("%s: %d\n", __func__, is_destroy_cvd);
-	common.is_destroy_cvd = is_destroy_cvd;
-}
-
-int voc_alloc_cal_shared_memory(void)
-{
-	int rc = 0;
-
-	mutex_lock(&common.common_lock);
-	if (is_cal_memory_allocated()) {
-		pr_debug("%s: Calibration shared buffer already allocated",
-			 __func__);
-	} else {
-		/* Allocate memory for calibration memory map table. */
-		rc = voice_alloc_cal_mem_map_table();
-		if ((rc < 0) && (rc != -EPROBE_DEFER)) {
-			pr_err("%s: Failed to allocate cal memory, err=%d",
-			       __func__, rc);
-		}
-	}
-	mutex_unlock(&common.common_lock);
-
-	return rc;
-}
-
-int voc_alloc_voip_shared_memory(void)
-{
-	int rc = 0;
-
-	/* Allocate shared memory for OOB Voip */
-	rc = voice_alloc_oob_shared_mem();
-	if (rc < 0) {
-		pr_err("%s: Failed to alloc shared memory for OOB rc:%d\n",
-			   __func__, rc);
-	} else {
-		/* Allocate mem map table for OOB */
-		rc = voice_alloc_oob_mem_table();
-		if (rc < 0) {
-			pr_err("%s: Failed to alloc mem map talbe rc:%d\n",
-			       __func__, rc);
-
-			voice_free_oob_shared_mem();
-		}
-	}
-
-	return rc;
-}
-
-static int is_cal_memory_allocated(void)
-{
-	bool ret;
-
-	if (common.cal_mem_map_table.client != NULL &&
-	    common.cal_mem_map_table.handle != NULL)
-		ret = true;
-	else
-		ret = false;
-
-	return ret;
-}
-
-
-static int free_cal_map_table(void)
-{
-	int ret = 0;
-
-	if ((common.cal_mem_map_table.client == NULL) ||
-		(common.cal_mem_map_table.handle == NULL))
-		goto done;
-
-	ret = msm_audio_ion_free(common.cal_mem_map_table.client,
-		common.cal_mem_map_table.handle);
-	if (ret < 0)
-		pr_err("%s: msm_audio_ion_free failed:\n", __func__);
-
-done:
-	common.cal_mem_map_table.client = NULL;
-	common.cal_mem_map_table.handle = NULL;
-	return ret;
-}
-
-static int is_rtac_memory_allocated(void)
-{
-	bool ret;
-
-	if (common.rtac_mem_map_table.client != NULL &&
-	    common.rtac_mem_map_table.handle != NULL)
-		ret = true;
-	else
-		ret = false;
-
-	return ret;
-}
-
-static int free_rtac_map_table(void)
-{
-	int ret = 0;
-
-	if ((common.rtac_mem_map_table.client == NULL) ||
-		(common.rtac_mem_map_table.handle == NULL))
-		goto done;
-
-	ret = msm_audio_ion_free(common.rtac_mem_map_table.client,
-		common.rtac_mem_map_table.handle);
-	if (ret < 0)
-		pr_err("%s: msm_audio_ion_free failed:\n", __func__);
-
-done:
-	common.rtac_mem_map_table.client = NULL;
-	common.rtac_mem_map_table.handle = NULL;
-	return ret;
-}
-
-
-static int is_voip_memory_allocated(void)
-{
-	bool ret;
-	struct voice_data *v = voice_get_session(
-				common.voice[VOC_PATH_FULL].session_id);
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL, session_id:%d\n", __func__,
-		common.voice[VOC_PATH_FULL].session_id);
-
-		ret = false;
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-	if (v->shmem_info.sh_buf.client != NULL &&
-	    v->shmem_info.sh_buf.handle != NULL)
-		ret = true;
-	else
-		ret = false;
-	mutex_unlock(&common.common_lock);
-
-done:
-	return ret;
-}
-
-static int voice_config_cvs_vocoder_amr_rate(struct voice_data *v)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-	struct cvs_set_amr_enc_rate_cmd cvs_set_amr_rate;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	pr_debug("%s: Setting AMR rate. Media Type: %d\n", __func__,
-		 common.mvs_info.media_type);
-
-	cvs_set_amr_rate.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE),
-			APR_PKT_VER);
-	cvs_set_amr_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-			       sizeof(cvs_set_amr_rate) - APR_HDR_SIZE);
-	cvs_set_amr_rate.hdr.src_port =
-			voice_get_idx_for_session(v->session_id);
-	cvs_set_amr_rate.hdr.dest_port = cvs_handle;
-	cvs_set_amr_rate.hdr.token = 0;
-
-	if (common.mvs_info.media_type == VSS_MEDIA_ID_AMR_NB_MODEM)
-		cvs_set_amr_rate.hdr.opcode =
-				VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE;
-	else if (common.mvs_info.media_type == VSS_MEDIA_ID_AMR_WB_MODEM)
-		cvs_set_amr_rate.hdr.opcode =
-				VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE;
-
-	cvs_set_amr_rate.amr_rate.mode = common.mvs_info.rate;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_amr_rate);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_AMR_RATE\n",
-		       __func__, ret);
-
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-	return 0;
-done:
-	return ret;
-}
-
-static int voice_config_cvs_vocoder(struct voice_data *v)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-	/* Set media type. */
-	struct cvs_set_media_type_cmd cvs_set_media_cmd;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	cvs_set_media_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvs_set_media_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-						sizeof(cvs_set_media_cmd) -
-						APR_HDR_SIZE);
-	cvs_set_media_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_set_media_cmd.hdr.dest_port = cvs_handle;
-	cvs_set_media_cmd.hdr.token = 0;
-	cvs_set_media_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_MEDIA_TYPE;
-	cvs_set_media_cmd.media_type.tx_media_id = common.mvs_info.media_type;
-	cvs_set_media_cmd.media_type.rx_media_id = common.mvs_info.media_type;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_media_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_MEDIA_TYPE\n",
-			__func__, ret);
-
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	/* Set encoder properties. */
-	switch (common.mvs_info.media_type) {
-	case VSS_MEDIA_ID_EVRC_MODEM:
-	case VSS_MEDIA_ID_4GV_NB_MODEM:
-	case VSS_MEDIA_ID_4GV_WB_MODEM:
-	case VSS_MEDIA_ID_4GV_NW_MODEM: {
-		struct cvs_set_cdma_enc_minmax_rate_cmd cvs_set_cdma_rate;
-
-		pr_debug("Setting EVRC min-max rate\n");
-
-		cvs_set_cdma_rate.hdr.hdr_field =
-					APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-		cvs_set_cdma_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				      sizeof(cvs_set_cdma_rate) - APR_HDR_SIZE);
-		cvs_set_cdma_rate.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_set_cdma_rate.hdr.dest_port = cvs_handle;
-		cvs_set_cdma_rate.hdr.token = 0;
-		cvs_set_cdma_rate.hdr.opcode =
-				VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE;
-		cvs_set_cdma_rate.cdma_rate.min_rate =
-				common.mvs_info.evrc_min_rate;
-		cvs_set_cdma_rate.cdma_rate.max_rate =
-				common.mvs_info.evrc_max_rate;
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_cdma_rate);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending SET_EVRC_MINMAX_RATE\n",
-			       __func__, ret);
-			goto fail;
-		}
-		ret = wait_event_timeout(v->cvs_wait,
-					 (v->cvs_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-
-		if (common.mvs_info.media_type != VSS_MEDIA_ID_EVRC_MODEM) {
-			ret = voice_set_dtx(v);
-			if (ret < 0)
-				goto fail;
-		}
-
-		break;
-	}
-	case VSS_MEDIA_ID_AMR_NB_MODEM:
-	case VSS_MEDIA_ID_AMR_WB_MODEM: {
-		ret = voice_config_cvs_vocoder_amr_rate(v);
-		if (ret) {
-			pr_err("%s: Failed to update vocoder rate. %d\n",
-			       __func__, ret);
-
-			goto fail;
-		}
-
-		ret = voice_set_dtx(v);
-		if (ret < 0)
-			goto fail;
-
-		break;
-	}
-	case VSS_MEDIA_ID_G729:
-	case VSS_MEDIA_ID_G711_ALAW:
-	case VSS_MEDIA_ID_G711_MULAW: {
-		ret = voice_set_dtx(v);
-
-		break;
-	}
-	default:
-		/* Do nothing. */
-		break;
-	}
-	return 0;
-
-fail:
-	return ret;
-}
-
-int voc_update_amr_vocoder_rate(uint32_t session_id)
-{
-	int ret = 0;
-	struct voice_data *v;
-
-	pr_debug("%s: session_id:%d", __func__, session_id);
-
-	v = voice_get_session(session_id);
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL, session_id:%d\n", __func__,
-		       session_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&v->lock);
-	ret = voice_config_cvs_vocoder_amr_rate(v);
-	mutex_unlock(&v->lock);
-
-done:
-	return ret;
-}
-
-static int voice_send_start_voice_cmd(struct voice_data *v)
-{
-	struct apr_hdr mvm_start_voice_cmd;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	mvm_start_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_start_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_start_voice_cmd) - APR_HDR_SIZE);
-	pr_debug("send mvm_start_voice_cmd pkt size = %d\n",
-				mvm_start_voice_cmd.pkt_size);
-	mvm_start_voice_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_start_voice_cmd.dest_port = mvm_handle;
-	mvm_start_voice_cmd.token = 0;
-	mvm_start_voice_cmd.opcode = VSS_IMVM_CMD_START_VOICE;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_start_voice_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IMVM_CMD_START_VOICE\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static void voc_get_tx_rx_topology(struct voice_data *v,
-				   uint32_t *tx_topology_id,
-				   uint32_t *rx_topology_id)
-{
-	uint32_t tx_id = 0;
-	uint32_t rx_id = 0;
-
-	if (v->lch_mode == VOICE_LCH_START || v->disable_topology) {
-		pr_debug("%s: Setting TX and RX topology to NONE for LCH\n",
-			 __func__);
-
-		tx_id = VSS_IVOCPROC_TOPOLOGY_ID_NONE;
-		rx_id = VSS_IVOCPROC_TOPOLOGY_ID_NONE;
-	} else {
-		tx_id = voice_get_topology(CVP_VOC_TX_TOPOLOGY_CAL);
-		rx_id = voice_get_topology(CVP_VOC_RX_TOPOLOGY_CAL);
-	}
-
-	*tx_topology_id = tx_id;
-	*rx_topology_id = rx_id;
-}
-
-static int voice_send_set_device_cmd(struct voice_data *v)
-{
-	struct cvp_set_device_cmd  cvp_setdev_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* set device and wait for response */
-	cvp_setdev_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_setdev_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_setdev_cmd) - APR_HDR_SIZE);
-	pr_debug(" send create cvp setdev, pkt size = %d\n",
-			cvp_setdev_cmd.hdr.pkt_size);
-	cvp_setdev_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_setdev_cmd.hdr.dest_port = cvp_handle;
-	cvp_setdev_cmd.hdr.token = 0;
-
-	if (voice_get_cvd_int_version(common.cvd_version) >=
-	    CVD_INT_VERSION_2_2)
-		cvp_setdev_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_SET_DEVICE_V3;
-	else
-		cvp_setdev_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_SET_DEVICE_V2;
-
-	voc_get_tx_rx_topology(v,
-			&cvp_setdev_cmd.cvp_set_device_v2.tx_topology_id,
-			&cvp_setdev_cmd.cvp_set_device_v2.rx_topology_id);
-
-	cvp_setdev_cmd.cvp_set_device_v2.tx_port_id = v->dev_tx.port_id;
-	cvp_setdev_cmd.cvp_set_device_v2.rx_port_id = v->dev_rx.port_id;
-
-	if (common.ec_ref_ext) {
-		cvp_setdev_cmd.cvp_set_device_v2.vocproc_mode =
-				VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING;
-		cvp_setdev_cmd.cvp_set_device_v2.ec_ref_port_id =
-				common.ec_media_fmt_info.port_id;
-	} else {
-		cvp_setdev_cmd.cvp_set_device_v2.vocproc_mode =
-				    VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING;
-		cvp_setdev_cmd.cvp_set_device_v2.ec_ref_port_id =
-				    VSS_IVOCPROC_PORT_ID_NONE;
-	}
-	pr_debug("topology=%d , tx_port_id=%d, rx_port_id=%d\n",
-		cvp_setdev_cmd.cvp_set_device_v2.tx_topology_id,
-		cvp_setdev_cmd.cvp_set_device_v2.tx_port_id,
-		cvp_setdev_cmd.cvp_set_device_v2.rx_port_id);
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_setdev_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IVOCPROC_CMD_SET_DEVICE\n");
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-			(v->cvp_state == CMD_STATUS_SUCCESS),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_stop_voice_cmd(struct voice_data *v)
-{
-	struct apr_hdr mvm_stop_voice_cmd;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	mvm_stop_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_stop_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_stop_voice_cmd) - APR_HDR_SIZE);
-	pr_debug("send mvm_stop_voice_cmd pkt size = %d\n",
-				mvm_stop_voice_cmd.pkt_size);
-	mvm_stop_voice_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_stop_voice_cmd.dest_port = mvm_handle;
-	mvm_stop_voice_cmd.token = 0;
-	mvm_stop_voice_cmd.opcode = VSS_IMVM_CMD_STOP_VOICE;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_stop_voice_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IMVM_CMD_STOP_VOICE\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-static int voice_get_cal(struct cal_block_data **cal_block,
-			 int cal_block_idx,
-			 struct cal_block_data **col_data,
-			 int col_data_idx, int session_id)
-{
-	int ret = 0;
-
-	*cal_block = cal_utils_get_only_cal_block(
-		common.cal_data[cal_block_idx]);
-	if (*cal_block == NULL) {
-		pr_err("%s: No cal data for cal %d!\n",
-			__func__, cal_block_idx);
-
-		ret = -ENODEV;
-		goto done;
-	}
-	ret = remap_cal_data(*cal_block, session_id);
-	if (ret < 0) {
-		pr_err("%s: Remap_cal_data failed for cal %d!\n",
-			__func__, cal_block_idx);
-
-		ret = -ENODEV;
-		goto done;
-	}
-
-	if (col_data == NULL)
-		goto done;
-
-	*col_data = cal_utils_get_only_cal_block(
-		common.cal_data[col_data_idx]);
-	if (*col_data == NULL) {
-		pr_err("%s: No cal data for cal %d!\n",
-			__func__, col_data_idx);
-
-		ret = -ENODEV;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int voice_send_cvs_register_cal_cmd(struct voice_data *v)
-{
-	struct cvs_register_cal_data_cmd cvs_reg_cal_cmd;
-	struct cal_block_data *cal_block = NULL;
-	struct cal_block_data *col_data = NULL;
-	int ret = 0;
-
-	memset(&cvs_reg_cal_cmd, 0, sizeof(cvs_reg_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvs) {
-		pr_err("%s: apr_cvs is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[CVS_VOCSTRM_CAL]->lock);
-	mutex_lock(&common.cal_data[CVS_VOCSTRM_COL_CAL]->lock);
-
-	ret = voice_get_cal(&cal_block, CVS_VOCSTRM_CAL, &col_data,
-		CVS_VOCSTRM_COL_CAL, v->session_id);
-	if (ret < 0) {
-		pr_err("%s: Voice_get_cal failed for cal %d!\n",
-			__func__, CVS_VOCSTRM_CAL);
-
-		goto unlock;
-	}
-
-	memcpy(&cvs_reg_cal_cmd.cvs_cal_data.column_info[0],
-	       (void *) &((struct audio_cal_info_voc_col *)
-	       col_data->cal_info)->data,
-	       col_data->cal_data.size);
-
-	cvs_reg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvs_reg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvs_reg_cal_cmd) - APR_HDR_SIZE);
-	cvs_reg_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_reg_cal_cmd.hdr.dest_port = voice_get_cvs_handle(v);
-	cvs_reg_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvs_reg_cal_cmd.hdr.opcode =
-			VSS_ISTREAM_CMD_REGISTER_STATIC_CALIBRATION_DATA;
-	else
-		cvs_reg_cal_cmd.hdr.opcode =
-			VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA_V2;
-
-	cvs_reg_cal_cmd.cvs_cal_data.cal_mem_handle =
-		cal_block->map_data.q6map_handle;
-	cvs_reg_cal_cmd.cvs_cal_data.cal_mem_address_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	cvs_reg_cal_cmd.cvs_cal_data.cal_mem_address_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	cvs_reg_cal_cmd.cvs_cal_data.cal_mem_size =
-		cal_block->cal_data.size;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvs, (uint32_t *) &cvs_reg_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d registering CVS cal\n", __func__, ret);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto unlock;
-	}
-unlock:
-	mutex_unlock(&common.cal_data[CVS_VOCSTRM_COL_CAL]->lock);
-	mutex_unlock(&common.cal_data[CVS_VOCSTRM_CAL]->lock);
-done:
-	return ret;
-}
-
-static int voice_send_cvs_deregister_cal_cmd(struct voice_data *v)
-{
-	struct cvs_deregister_cal_data_cmd cvs_dereg_cal_cmd;
-	int ret = 0;
-
-	memset(&cvs_dereg_cal_cmd, 0, sizeof(cvs_dereg_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvs) {
-		pr_err("%s: apr_cvs is NULL\n", __func__);
-
-		ret = -EPERM;
-		goto done;
-	}
-
-	cvs_dereg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvs_dereg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvs_dereg_cal_cmd) - APR_HDR_SIZE);
-	cvs_dereg_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_dereg_cal_cmd.hdr.dest_port = voice_get_cvs_handle(v);
-	cvs_dereg_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvs_dereg_cal_cmd.hdr.opcode =
-			VSS_ISTREAM_CMD_DEREGISTER_STATIC_CALIBRATION_DATA;
-	else
-		cvs_dereg_cal_cmd.hdr.opcode =
-			VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvs, (uint32_t *) &cvs_dereg_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d de-registering CVS cal\n", __func__, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command  timeout\n", __func__);
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-
-}
-
-static int voice_send_cvp_create_cmd(struct voice_data *v)
-{
-	struct cvp_create_full_ctl_session_cmd cvp_session_cmd;
-	void *apr_cvp;
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/* create cvp session and wait for response */
-	cvp_session_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_session_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_session_cmd) - APR_HDR_SIZE);
-	pr_debug("%s: send create cvp session, pkt size = %d\n",
-		 __func__, cvp_session_cmd.hdr.pkt_size);
-	cvp_session_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_session_cmd.hdr.dest_port = 0;
-	cvp_session_cmd.hdr.token = 0;
-
-	if (voice_get_cvd_int_version(common.cvd_version) >=
-	    CVD_INT_VERSION_2_2)
-		cvp_session_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V3;
-	else
-		cvp_session_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V2;
-
-	voc_get_tx_rx_topology(v,
-			&cvp_session_cmd.cvp_session.tx_topology_id,
-			&cvp_session_cmd.cvp_session.rx_topology_id);
-
-	cvp_session_cmd.cvp_session.direction = 2; /*tx and rx*/
-	cvp_session_cmd.cvp_session.tx_port_id = v->dev_tx.port_id;
-	cvp_session_cmd.cvp_session.rx_port_id = v->dev_rx.port_id;
-	cvp_session_cmd.cvp_session.profile_id =
-					 VSS_ICOMMON_CAL_NETWORK_ID_NONE;
-	if (common.ec_ref_ext) {
-		cvp_session_cmd.cvp_session.vocproc_mode =
-				VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING;
-		cvp_session_cmd.cvp_session.ec_ref_port_id =
-				common.ec_media_fmt_info.port_id;
-	} else {
-		cvp_session_cmd.cvp_session.vocproc_mode =
-				 VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING;
-		cvp_session_cmd.cvp_session.ec_ref_port_id =
-						 VSS_IVOCPROC_PORT_ID_NONE;
-	}
-
-	pr_debug("tx_topology: %d tx_port_id=%d, rx_port_id=%d, mode: 0x%x\n",
-		cvp_session_cmd.cvp_session.tx_topology_id,
-		cvp_session_cmd.cvp_session.tx_port_id,
-		cvp_session_cmd.cvp_session.rx_port_id,
-		cvp_session_cmd.cvp_session.vocproc_mode);
-	pr_debug("rx_topology: %d, profile_id: 0x%x, pkt_size: %d\n",
-		cvp_session_cmd.cvp_session.rx_topology_id,
-		cvp_session_cmd.cvp_session.profile_id,
-		cvp_session_cmd.hdr.pkt_size);
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_session_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n");
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_register_dev_cfg_cmd(struct voice_data *v)
-{
-	struct cvp_register_dev_cfg_cmd cvp_reg_dev_cfg_cmd;
-	struct cal_block_data *cal_block = NULL;
-	int ret = 0;
-
-	memset(&cvp_reg_dev_cfg_cmd, 0, sizeof(cvp_reg_dev_cfg_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EPERM;
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[CVP_VOCDEV_CFG_CAL]->lock);
-
-	ret = voice_get_cal(&cal_block, CVP_VOCDEV_CFG_CAL, NULL,
-		0, v->session_id);
-	if (ret < 0) {
-		pr_err("%s: Voice_get_cal failed for cal %d!\n",
-			__func__, CVP_VOCDEV_CFG_CAL);
-
-		goto unlock;
-	}
-
-	cvp_reg_dev_cfg_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_reg_dev_cfg_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_reg_dev_cfg_cmd) - APR_HDR_SIZE);
-	cvp_reg_dev_cfg_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_reg_dev_cfg_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_reg_dev_cfg_cmd.hdr.token = 0;
-	cvp_reg_dev_cfg_cmd.hdr.opcode =
-					VSS_IVOCPROC_CMD_REGISTER_DEVICE_CONFIG;
-
-	cvp_reg_dev_cfg_cmd.cvp_dev_cfg_data.mem_handle =
-		cal_block->map_data.q6map_handle;
-	cvp_reg_dev_cfg_cmd.cvp_dev_cfg_data.mem_address_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_dev_cfg_cmd.cvp_dev_cfg_data.mem_address_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_dev_cfg_cmd.cvp_dev_cfg_data.mem_size =
-		cal_block->cal_data.size;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp,
-			   (uint32_t *) &cvp_reg_dev_cfg_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d registering CVP dev cfg cal\n",
-		       __func__, ret);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto unlock;
-	}
-unlock:
-	mutex_unlock(&common.cal_data[CVP_VOCDEV_CFG_CAL]->lock);
-done:
-	return ret;
-}
-
-static int voice_send_cvp_deregister_dev_cfg_cmd(struct voice_data *v)
-{
-	struct cvp_deregister_dev_cfg_cmd cvp_dereg_dev_cfg_cmd;
-	int ret = 0;
-
-	memset(&cvp_dereg_dev_cfg_cmd, 0, sizeof(cvp_dereg_dev_cfg_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EPERM;
-		goto done;
-	}
-
-	cvp_dereg_dev_cfg_cmd.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_dereg_dev_cfg_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_dereg_dev_cfg_cmd) - APR_HDR_SIZE);
-	cvp_dereg_dev_cfg_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_dereg_dev_cfg_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_dereg_dev_cfg_cmd.hdr.token = 0;
-	cvp_dereg_dev_cfg_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_DEREGISTER_DEVICE_CONFIG;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp,
-			   (uint32_t *) &cvp_dereg_dev_cfg_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d de-registering CVP dev cfg cal\n",
-		       __func__, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_register_cal_cmd(struct voice_data *v)
-{
-	struct cvp_register_cal_data_cmd cvp_reg_cal_cmd;
-	struct cal_block_data *cal_block = NULL;
-	struct cal_block_data *col_data = NULL;
-	int ret = 0;
-
-	memset(&cvp_reg_cal_cmd, 0, sizeof(cvp_reg_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[CVP_VOCPROC_CAL]->lock);
-	mutex_lock(&common.cal_data[CVP_VOCPROC_COL_CAL]->lock);
-
-	ret = voice_get_cal(&cal_block, CVP_VOCPROC_CAL, &col_data,
-		CVP_VOCPROC_COL_CAL, v->session_id);
-	if (ret < 0) {
-		pr_err("%s: Voice_get_cal failed for cal %d!\n",
-			__func__, CVP_VOCPROC_CAL);
-
-		goto unlock;
-	}
-
-	v->dev_tx.dev_id = ((struct audio_cal_info_vocproc *)
-				cal_block->cal_info)->tx_acdb_id;
-	v->dev_rx.dev_id = ((struct audio_cal_info_vocproc *)
-				cal_block->cal_info)->rx_acdb_id;
-	pr_debug("%s: %s: Tx acdb id = %d and Rx acdb id = %d", __func__,
-		 voc_get_session_name(v->session_id), v->dev_tx.dev_id,
-		 v->dev_rx.dev_id);
-
-	memcpy(&cvp_reg_cal_cmd.cvp_cal_data.column_info[0],
-	       (void *) &((struct audio_cal_info_voc_col *)
-	       col_data->cal_info)->data,
-	       col_data->cal_data.size);
-
-	cvp_reg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_reg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_reg_cal_cmd) - APR_HDR_SIZE);
-	cvp_reg_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_reg_cal_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_reg_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvp_reg_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_REGISTER_STATIC_CALIBRATION_DATA;
-	else
-		cvp_reg_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA_V2;
-
-	cvp_reg_cal_cmd.cvp_cal_data.cal_mem_handle =
-		cal_block->map_data.q6map_handle;
-	cvp_reg_cal_cmd.cvp_cal_data.cal_mem_address_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_cal_cmd.cvp_cal_data.cal_mem_address_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_cal_cmd.cvp_cal_data.cal_mem_size =
-		cal_block->cal_data.size;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp, (uint32_t *) &cvp_reg_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d registering CVP cal\n", __func__, ret);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto unlock;
-	}
-unlock:
-	mutex_unlock(&common.cal_data[CVP_VOCPROC_COL_CAL]->lock);
-	mutex_unlock(&common.cal_data[CVP_VOCPROC_CAL]->lock);
-done:
-	return ret;
-}
-
-static int voice_send_cvp_deregister_cal_cmd(struct voice_data *v)
-{
-	struct cvp_deregister_cal_data_cmd cvp_dereg_cal_cmd;
-	int ret = 0;
-
-	memset(&cvp_dereg_cal_cmd, 0, sizeof(cvp_dereg_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-
-		ret = -EPERM;
-		goto done;
-	}
-
-	cvp_dereg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_dereg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_dereg_cal_cmd) - APR_HDR_SIZE);
-	cvp_dereg_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_dereg_cal_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_dereg_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvp_dereg_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_DEREGISTER_STATIC_CALIBRATION_DATA;
-	else
-		cvp_dereg_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp, (uint32_t *) &cvp_dereg_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d de-registering CVP cal\n", __func__, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_register_vol_cal_cmd(struct voice_data *v)
-{
-	struct cvp_register_vol_cal_data_cmd cvp_reg_vol_cal_cmd;
-	struct cal_block_data *cal_block = NULL;
-	struct cal_block_data *col_data = NULL;
-	int ret = 0;
-
-	memset(&cvp_reg_vol_cal_cmd, 0, sizeof(cvp_reg_vol_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[CVP_VOCVOL_CAL]->lock);
-	mutex_lock(&common.cal_data[CVP_VOCVOL_COL_CAL]->lock);
-
-	ret = voice_get_cal(&cal_block, CVP_VOCVOL_CAL, &col_data,
-		CVP_VOCVOL_COL_CAL, v->session_id);
-	if (ret < 0) {
-		pr_err("%s: Voice_get_cal failed for cal %d!\n",
-			__func__, CVP_VOCVOL_CAL);
-
-		goto unlock;
-	}
-
-	memcpy(&cvp_reg_vol_cal_cmd.cvp_vol_cal_data.column_info[0],
-	       (void *) &((struct audio_cal_info_voc_col *)
-	       col_data->cal_info)->data,
-	       col_data->cal_data.size);
-
-	cvp_reg_vol_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_reg_vol_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_reg_vol_cal_cmd) - APR_HDR_SIZE);
-	cvp_reg_vol_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_reg_vol_cal_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_reg_vol_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvp_reg_vol_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_REGISTER_DYNAMIC_CALIBRATION_DATA;
-	else
-		cvp_reg_vol_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_REGISTER_VOL_CALIBRATION_DATA;
-
-	cvp_reg_vol_cal_cmd.cvp_vol_cal_data.cal_mem_handle =
-		cal_block->map_data.q6map_handle;
-	cvp_reg_vol_cal_cmd.cvp_vol_cal_data.cal_mem_address_lsw =
-		lower_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_vol_cal_cmd.cvp_vol_cal_data.cal_mem_address_msw =
-		msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
-	cvp_reg_vol_cal_cmd.cvp_vol_cal_data.cal_mem_size =
-		cal_block->cal_data.size;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp,
-			   (uint32_t *) &cvp_reg_vol_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d registering CVP vol cal\n", __func__, ret);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto unlock;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto unlock;
-	}
-unlock:
-	mutex_unlock(&common.cal_data[CVP_VOCVOL_COL_CAL]->lock);
-	mutex_unlock(&common.cal_data[CVP_VOCVOL_CAL]->lock);
-done:
-	return ret;
-}
-
-static int voice_send_cvp_deregister_vol_cal_cmd(struct voice_data *v)
-{
-	struct cvp_deregister_vol_cal_data_cmd cvp_dereg_vol_cal_cmd;
-	int ret = 0;
-
-	memset(&cvp_dereg_vol_cal_cmd, 0, sizeof(cvp_dereg_vol_cal_cmd));
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EPERM;
-		goto done;
-	}
-
-	cvp_dereg_vol_cal_cmd.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_dereg_vol_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_dereg_vol_cal_cmd) - APR_HDR_SIZE);
-	cvp_dereg_vol_cal_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_dereg_vol_cal_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_dereg_vol_cal_cmd.hdr.token = 0;
-	if (common.is_per_vocoder_cal_enabled)
-		cvp_dereg_vol_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_DEREGISTER_DYNAMIC_CALIBRATION_DATA;
-	else
-		cvp_dereg_vol_cal_cmd.hdr.opcode =
-			VSS_IVOCPROC_CMD_DEREGISTER_VOL_CALIBRATION_DATA;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp,
-			   (uint32_t *) &cvp_dereg_vol_cal_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d de-registering CVP vol cal\n",
-		       __func__, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_map_memory_physical_cmd(struct voice_data *v,
-					 struct mem_map_table *table_info,
-					 dma_addr_t phys,
-					 uint32_t size,
-					 uint32_t token)
-{
-	struct vss_imemory_cmd_map_physical_t mvm_map_phys_cmd;
-	uint32_t *memtable;
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (!common.apr_q6_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (!table_info->data) {
-		pr_err("%s: memory table is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	memtable = (uint32_t *) table_info->data;
-
-	/*
-	 * Store next table descriptor's address(64 bit) as NULL as there
-	 * is only one memory block
-	 */
-	memtable[0] = 0;
-	memtable[1] = 0;
-
-	/* Store next table descriptor's size */
-	memtable[2] = 0;
-
-	/* Store shared mem adddress (64 bit) */
-	memtable[3] = lower_32_bits(phys);
-	memtable[4] = msm_audio_populate_upper_32_bits(phys);
-
-	/* Store shared memory size */
-	memtable[5] = size;
-
-	mvm_map_phys_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mvm_map_phys_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_map_phys_cmd) - APR_HDR_SIZE);
-	mvm_map_phys_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_map_phys_cmd.hdr.dest_port = voice_get_mvm_handle(v);
-	mvm_map_phys_cmd.hdr.token = token;
-	mvm_map_phys_cmd.hdr.opcode = VSS_IMEMORY_CMD_MAP_PHYSICAL;
-
-	mvm_map_phys_cmd.table_descriptor.mem_address_lsw =
-			lower_32_bits(table_info->phys);
-	mvm_map_phys_cmd.table_descriptor.mem_address_msw =
-			msm_audio_populate_upper_32_bits(table_info->phys);
-	mvm_map_phys_cmd.table_descriptor.mem_size =
-			sizeof(struct vss_imemory_block_t) +
-			sizeof(struct vss_imemory_table_descriptor_t);
-	mvm_map_phys_cmd.is_cached = true;
-	mvm_map_phys_cmd.cache_line_size = 128;
-	mvm_map_phys_cmd.access_mask = 3;
-	mvm_map_phys_cmd.page_align = 4096;
-	mvm_map_phys_cmd.min_data_width = 8;
-	mvm_map_phys_cmd.max_data_width = 64;
-
-	pr_debug("%s: next table desc: add: %lld, size: %d\n",
-		 __func__, *((uint64_t *) memtable),
-		 *(((uint32_t *) memtable) + 2));
-	pr_debug("%s: phy add of of mem being mapped LSW:0x%x, MSW:0x%x size: %d\n",
-		 __func__, *(((uint32_t *) memtable) + 3),
-		*(((uint32_t *) memtable) + 4), *(((uint32_t *) memtable) + 5));
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_mvm, (uint32_t *) &mvm_map_phys_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending mvm map phy cmd\n", __func__, ret);
-
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_pause_voice_call(struct voice_data *v)
-{
-	struct apr_hdr	mvm_pause_voice_cmd;
-	void		*apr_mvm;
-	int		ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (v == NULL) {
-		pr_err("%s: Voice data is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_mvm = common.apr_q6_mvm;
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mvm_pause_voice_cmd.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	mvm_pause_voice_cmd.pkt_size =
-		APR_PKT_SIZE(APR_HDR_SIZE,
-		sizeof(mvm_pause_voice_cmd) - APR_HDR_SIZE);
-	mvm_pause_voice_cmd.src_port =
-			voice_get_idx_for_session(v->session_id);
-	mvm_pause_voice_cmd.dest_port = voice_get_mvm_handle(v);
-	mvm_pause_voice_cmd.token = 0;
-	mvm_pause_voice_cmd.opcode = VSS_IMVM_CMD_PAUSE_VOICE;
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	pr_debug("%s: send mvm_pause_voice_cmd pkt size = %d\n",
-		__func__, mvm_pause_voice_cmd.pkt_size);
-
-	ret = apr_send_pkt(apr_mvm,
-		(uint32_t *)&mvm_pause_voice_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IMVM_CMD_PAUSE_VOICE\n");
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-		(v->mvm_state == CMD_STATUS_SUCCESS),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_map_cal_memory(struct cal_block_data *cal_block,
-				uint32_t session_id)
-{
-	int result = 0;
-	int voc_index;
-	struct voice_data *v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: Cal block is NULL!\n", __func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n", __func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: Map size is 0!\n", __func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	voc_index = voice_get_idx_for_session(session_id);
-	if (voc_index < 0) {
-		pr_err("%s:  Invalid session ID %d\n", __func__, session_id);
-
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-	v = &common.voice[voc_index];
-
-	result = voice_map_memory_physical_cmd(v,
-		&common.cal_mem_map_table,
-		(dma_addr_t)cal_block->cal_data.paddr,
-		cal_block->map_data.map_size,
-		VOC_CAL_MEM_MAP_TOKEN);
-	if (result < 0) {
-		pr_err("%s: Mmap did not work! addr = 0x%pK, size = %zd\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-
-		goto done_unlock;
-	}
-
-	cal_block->map_data.q6map_handle = common.cal_mem_handle;
-done_unlock:
-	mutex_unlock(&common.common_lock);
-done:
-	return result;
-}
-
-static int remap_cal_data(struct cal_block_data *cal_block,
-			   uint32_t session_id)
-{
-	int ret = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_block->map_data.ion_client == NULL) {
-		pr_err("%s: No ION allocation for session_id %d!\n",
-			__func__, session_id);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if ((cal_block->map_data.map_size > 0) &&
-		(cal_block->map_data.q6map_handle == 0)) {
-
-		/* cal type not used */
-		ret = voice_map_cal_memory(cal_block, session_id);
-		if (ret < 0) {
-			pr_err("%s: Mmap did not work! size = %zd\n",
-				__func__, cal_block->map_data.map_size);
-
-			goto done;
-		}
-	} else {
-		pr_debug("%s:  Cal block 0x%pK, size %zd already mapped. Q6 map handle = %d\n",
-			__func__, &cal_block->cal_data.paddr,
-			cal_block->map_data.map_size,
-			cal_block->map_data.q6map_handle);
-	}
-done:
-	return ret;
-}
-
-static int voice_unmap_cal_memory(int32_t cal_type,
-				  struct cal_block_data *cal_block)
-{
-	int result = 0;
-	int result2 = 0;
-	int i;
-	struct voice_data *v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: Cal block is NULL!\n", __func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.q6map_handle == 0) {
-		pr_debug("%s: Q6 handle is not set!\n", __func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		v = &common.voice[i];
-
-		mutex_lock(&v->lock);
-		if (is_voc_state_active(v->voc_state)) {
-			result2 = voice_pause_voice_call(v);
-			if (result2 < 0) {
-				pr_err("%s: Voice_pause_voice_call failed for session 0x%x, err %d!\n",
-					__func__, v->session_id, result2);
-
-				result = result2;
-			}
-
-			if (cal_type == CVP_VOCPROC_DYNAMIC_CAL_TYPE)
-				voice_send_cvp_deregister_vol_cal_cmd(v);
-			else if (cal_type == CVP_VOCPROC_STATIC_CAL_TYPE)
-				voice_send_cvp_deregister_cal_cmd(v);
-			else if (cal_type == CVP_VOCDEV_CFG_CAL_TYPE)
-				voice_send_cvp_deregister_dev_cfg_cmd(v);
-			else if (cal_type == CVS_VOCSTRM_STATIC_CAL_TYPE)
-				voice_send_cvs_deregister_cal_cmd(v);
-			else
-				pr_err("%s: Invalid cal type %d!\n",
-					__func__, cal_type);
-
-			result2 = voice_send_start_voice_cmd(v);
-			if (result2) {
-				pr_err("%s: Voice_send_start_voice_cmd failed for session 0x%x, err %d!\n",
-					__func__, v->session_id, result2);
-
-				result = result2;
-			}
-		}
-
-		if ((cal_block->map_data.q6map_handle != 0) &&
-			(!is_other_session_active(v->session_id))) {
-
-			result2 = voice_send_mvm_unmap_memory_physical_cmd(
-				v, cal_block->map_data.q6map_handle);
-			if (result2) {
-				pr_err("%s: Voice_send_mvm_unmap_memory_physical_cmd failed for session 0x%x, err %d!\n",
-					__func__, v->session_id, result2);
-
-				result = result2;
-			}
-			cal_block->map_data.q6map_handle = 0;
-		}
-		mutex_unlock(&v->lock);
-	}
-	mutex_unlock(&common.common_lock);
-done:
-	return result;
-}
-
-int voc_register_vocproc_vol_table(void)
-{
-	int			result = 0;
-	int			result2 = 0;
-	int			i;
-	struct voice_data	*v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&common.common_lock);
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		v = &common.voice[i];
-
-		mutex_lock(&v->lock);
-		if (is_voc_state_active(v->voc_state)) {
-			result2 = voice_send_cvp_register_vol_cal_cmd(v);
-			if (result2 < 0) {
-				pr_err("%s: Failed to register vocvol table for session 0x%x!\n",
-					__func__, v->session_id);
-
-				result = result2;
-				/* Still try to register other sessions */
-			}
-		}
-		mutex_unlock(&v->lock);
-	}
-
-	mutex_unlock(&common.common_lock);
-	return result;
-}
-
-int voc_deregister_vocproc_vol_table(void)
-{
-	int			result = 0;
-	int			success = 0;
-	int			i;
-	struct voice_data	*v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&common.common_lock);
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-		v = &common.voice[i];
-
-		mutex_lock(&v->lock);
-		if (is_voc_state_active(v->voc_state)) {
-			result = voice_send_cvp_deregister_vol_cal_cmd(v);
-			if (result < 0) {
-				pr_err("%s: Failed to deregister vocvol table for session 0x%x!\n",
-					__func__, v->session_id);
-
-				mutex_unlock(&v->lock);
-				mutex_unlock(&common.common_lock);
-				if (success) {
-					pr_err("%s: Try to re-register all deregistered sessions!\n",
-						__func__);
-
-					voc_register_vocproc_vol_table();
-				}
-				goto done;
-			} else {
-				success = 1;
-			}
-		}
-		mutex_unlock(&v->lock);
-	}
-	mutex_unlock(&common.common_lock);
-done:
-	return result;
-}
-
-int voc_map_rtac_block(struct rtac_cal_block_data *cal_block)
-{
-	int			result = 0;
-	struct voice_data	*v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_block == NULL) {
-		pr_err("%s: cal_block is NULL!\n",
-			__func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->cal_data.paddr == 0) {
-		pr_debug("%s: No address to map!\n",
-			__func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	if (cal_block->map_data.map_size == 0) {
-		pr_debug("%s: map size is 0!\n",
-			__func__);
-
-		result = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-	/* use first session */
-	v = &common.voice[0];
-	mutex_lock(&v->lock);
-
-	if (!is_rtac_memory_allocated()) {
-		result = voice_alloc_rtac_mem_map_table();
-		if (result < 0) {
-			pr_err("%s: RTAC alloc mem map table did not work! addr = 0x%pK, size = %d\n",
-				__func__,
-				&cal_block->cal_data.paddr,
-				cal_block->map_data.map_size);
-
-			goto done_unlock;
-		}
-	}
-
-	result = voice_map_memory_physical_cmd(v,
-		&common.rtac_mem_map_table,
-		(dma_addr_t)cal_block->cal_data.paddr,
-		cal_block->map_data.map_size,
-		VOC_RTAC_MEM_MAP_TOKEN);
-	if (result < 0) {
-		pr_err("%s: RTAC mmap did not work! addr = 0x%pK, size = %d\n",
-			__func__,
-			&cal_block->cal_data.paddr,
-			cal_block->map_data.map_size);
-
-		free_rtac_map_table();
-		goto done_unlock;
-	}
-
-	cal_block->map_data.map_handle = common.rtac_mem_handle;
-done_unlock:
-	mutex_unlock(&v->lock);
-	mutex_unlock(&common.common_lock);
-done:
-	return result;
-}
-
-int voc_unmap_rtac_block(uint32_t *mem_map_handle)
-{
-	int			result = 0;
-	struct voice_data	*v = NULL;
-
-	pr_debug("%s\n", __func__);
-
-	if (mem_map_handle == NULL) {
-		pr_debug("%s: Map handle is NULL, nothing to unmap\n",
-			__func__);
-
-		goto done;
-	}
-
-	if (*mem_map_handle == 0) {
-		pr_debug("%s: Map handle is 0, nothing to unmap\n",
-			__func__);
-
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-	/* Use first session */
-	/* Only used for apr wait lock */
-	v = &common.voice[0];
-	mutex_lock(&v->lock);
-
-	result = voice_send_mvm_unmap_memory_physical_cmd(
-			v, *mem_map_handle);
-	if (result) {
-		pr_err("%s: voice_send_mvm_unmap_memory_physical_cmd Failed for session 0x%x!\n",
-			__func__, v->session_id);
-	} else {
-		*mem_map_handle = 0;
-		common.rtac_mem_handle = 0;
-		free_rtac_map_table();
-	}
-	mutex_unlock(&v->lock);
-	mutex_unlock(&common.common_lock);
-done:
-	return result;
-}
-
-static int voice_send_cvp_channel_info_v2(struct voice_data *v,
-					  uint32_t param_type)
-{
-	int ret;
-	struct cvp_set_channel_info_cmd_v2 cvp_set_channel_info_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct vss_icommon_param_data_channel_info_v2_t
-		*channel_info_param_data =
-			&cvp_set_channel_info_cmd.
-			cvp_set_ch_info_param_v2.param_data;
-	struct vss_param_vocproc_dev_channel_info_t *channel_info =
-			&channel_info_param_data->channel_info;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-	memset(&cvp_set_channel_info_cmd, 0, sizeof(cvp_set_channel_info_cmd));
-
-	cvp_set_channel_info_cmd.hdr.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
-			      APR_PKT_VER);
-	cvp_set_channel_info_cmd.hdr.pkt_size =
-		APR_PKT_SIZE(APR_HDR_SIZE,
-		sizeof(cvp_set_channel_info_cmd) - APR_HDR_SIZE);
-	cvp_set_channel_info_cmd.hdr.src_svc = 0;
-	cvp_set_channel_info_cmd.hdr.src_domain = APR_DOMAIN_APPS;
-	cvp_set_channel_info_cmd.hdr.src_port =
-		voice_get_idx_for_session(v->session_id);
-	cvp_set_channel_info_cmd.hdr.dest_svc = 0;
-	cvp_set_channel_info_cmd.hdr.dest_domain = APR_DOMAIN_ADSP;
-	cvp_set_channel_info_cmd.hdr.dest_port = cvp_handle;
-	cvp_set_channel_info_cmd.hdr.token = 0;
-	cvp_set_channel_info_cmd.hdr.opcode =  VSS_ICOMMON_CMD_SET_PARAM_V2;
-
-	cvp_set_channel_info_cmd.cvp_set_ch_info_param_v2.mem_size =
-			sizeof(struct vss_icommon_param_data_channel_info_v2_t);
-
-	channel_info_param_data->module_id = VSS_MODULE_CVD_GENERIC;
-	channel_info_param_data->param_size =
-		sizeof(struct vss_param_vocproc_dev_channel_info_t);
-
-	 /* Device specific data */
-	switch (param_type) {
-	case RX_PATH:
-		channel_info_param_data->param_id =
-			VSS_PARAM_VOCPROC_RX_CHANNEL_INFO;
-		channel_info->num_channels = v->dev_rx.no_of_channels;
-		channel_info->bits_per_sample = v->dev_rx.bits_per_sample;
-		break;
-
-	case TX_PATH:
-		channel_info_param_data->param_id =
-			VSS_PARAM_VOCPROC_TX_CHANNEL_INFO;
-		channel_info->num_channels = v->dev_tx.no_of_channels;
-		channel_info->bits_per_sample = v->dev_tx.bits_per_sample;
-		break;
-
-	case EC_REF_PATH:
-		channel_info_param_data->param_id =
-			VSS_PARAM_VOCPROC_EC_REF_CHANNEL_INFO;
-		channel_info->num_channels = v->dev_rx.no_of_channels;
-		channel_info->bits_per_sample = v->dev_rx.bits_per_sample;
-		break;
-	default:
-		pr_err("%s: Invalid param type\n",
-		       __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (channel_info->num_channels == NUM_CHANNELS_MONO) {
-		channel_info->channel_mapping[0] = PCM_CHANNEL_FC;
-	} else if (channel_info->num_channels == NUM_CHANNELS_STEREO) {
-		channel_info->channel_mapping[0] = PCM_CHANNEL_FL;
-		channel_info->channel_mapping[1] = PCM_CHANNEL_FR;
-	} else {
-		pr_err("%s: Unsupported num channels: %d\n",
-		       __func__, channel_info->num_channels);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_set_channel_info_cmd);
-	if (ret < 0) {
-		pr_err("%s: Failed to send VSS_ICOMMON_CMD_SET_PARAM_V2\n",
-		       __func__);
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-				(v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s] handle = %d\n", __func__,
-		       adsp_err_get_err_str(v->async_err), cvp_handle);
-		ret = adsp_err_get_lnx_err_code(v->async_err);
-		goto done;
-	}
-	ret = 0;
-done:
-	return ret;
-}
-
-static int voice_send_cvp_channel_info_cmd(struct voice_data *v)
-{
-	int ret = 0;
-
-	ret = voice_send_cvp_channel_info_v2(v, RX_PATH);
-	if (ret < 0) {
-		pr_err("%s: Error in sending cvp_channel_info RX: %d\n",
-		       __func__, ret);
-		goto done;
-	}
-
-	ret = voice_send_cvp_channel_info_v2(v, TX_PATH);
-	if (ret < 0) {
-		pr_err("%s: Error in sending cvp_channel_info TX: %d\n",
-		       __func__, ret);
-		goto done;
-	}
-
-	ret = voice_send_cvp_channel_info_v2(v, EC_REF_PATH);
-	if (ret < 0) {
-		pr_err("%s: Error in sending cvp_channel_info EC Ref: %d\n",
-		       __func__, ret);
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int voice_send_cvp_mfc_config_v2(struct voice_data *v)
-{
-	int ret;
-	struct cvp_set_mfc_config_cmd_v2 cvp_set_mfc_config_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct vss_icommon_param_data_mfc_config_v2_t *cvp_config_param_data =
-		&cvp_set_mfc_config_cmd.cvp_set_mfc_param_v2.param_data;
-	struct vss_param_mfc_config_info_t *mfc_config_info =
-		&cvp_config_param_data->mfc_config_info;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp  = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-	memset(&cvp_set_mfc_config_cmd, 0, sizeof(cvp_set_mfc_config_cmd));
-
-	cvp_set_mfc_config_cmd.hdr.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
-			      APR_PKT_VER);
-	cvp_set_mfc_config_cmd.hdr.pkt_size =
-		APR_PKT_SIZE(APR_HDR_SIZE,
-		sizeof(cvp_set_mfc_config_cmd) - APR_HDR_SIZE);
-	cvp_set_mfc_config_cmd.hdr.src_svc = 0;
-	cvp_set_mfc_config_cmd.hdr.src_domain = APR_DOMAIN_APPS;
-	cvp_set_mfc_config_cmd.hdr.src_port =
-		voice_get_idx_for_session(v->session_id);
-	cvp_set_mfc_config_cmd.hdr.dest_svc = 0;
-	cvp_set_mfc_config_cmd.hdr.dest_domain = APR_DOMAIN_ADSP;
-	cvp_set_mfc_config_cmd.hdr.dest_port = cvp_handle;
-	cvp_set_mfc_config_cmd.hdr.token = 0;
-	cvp_set_mfc_config_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_PARAM_V2;
-	cvp_set_mfc_config_cmd.cvp_set_mfc_param_v2.mem_size =
-		sizeof(struct vss_icommon_param_data_mfc_config_v2_t);
-
-	cvp_config_param_data->module_id = AUDPROC_MODULE_ID_MFC;
-	cvp_config_param_data->param_id =
-		AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
-	cvp_config_param_data->param_size =
-		sizeof(struct vss_param_mfc_config_info_t);
-
-	mfc_config_info->num_channels = v->dev_rx.no_of_channels;
-	mfc_config_info->bits_per_sample = 16;
-	mfc_config_info->sample_rate = v->dev_rx.sample_rate;
-
-	if (mfc_config_info->num_channels == NUM_CHANNELS_MONO) {
-		mfc_config_info->channel_type[0] = PCM_CHANNEL_FC;
-	} else if (mfc_config_info->num_channels == NUM_CHANNELS_STEREO) {
-		mfc_config_info->channel_type[0] = PCM_CHANNEL_FL;
-		mfc_config_info->channel_type[1] = PCM_CHANNEL_FR;
-	} else {
-		pr_err("%s: Unsupported num channels: %d\n",
-		       __func__, mfc_config_info->num_channels);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *)&cvp_set_mfc_config_cmd);
-	if (ret < 0) {
-		pr_err("%s: Failed to send VSS_ICOMMON_CMD_SET_PARAM_V2 %d\n",
-		       __func__, ret);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				(v->cvp_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -ETIMEDOUT;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s] handle = %d\n", __func__,
-		       adsp_err_get_err_str(v->async_err), cvp_handle);
-		ret = adsp_err_get_lnx_err_code(v->async_err);
-		goto done;
-	}
-	ret = 0;
-done:
-	return ret;
-}
-
-static int voice_send_cvp_mfc_config_cmd(struct voice_data *v)
-{
-	int ret = 0;
-
-	if (common.cvp_version >= CVP_VERSION_2) {
-		ret = voice_send_cvp_mfc_config_v2(v);
-	} else {
-		pr_warn("%s: CVP Version not supported\n", __func__);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int voice_get_avcs_version_per_service(uint32_t service_id)
-{
-	int ret = 0;
-	size_t svc_size;
-	struct avcs_fwk_ver_info ver_info = {{0}, NULL};
-
-	if (service_id == AVCS_SERVICE_ID_ALL) {
-		pr_err("%s: Invalid service id: %d", __func__,
-		       AVCS_SERVICE_ID_ALL);
-		return -EINVAL;
-	}
-
-	svc_size = sizeof(struct avs_svc_api_info);
-	ver_info.services = kzalloc(svc_size, GFP_KERNEL);
-	if (ver_info.services == NULL)
-		return -ENOMEM;
-
-	ret = q6core_get_service_version(service_id, &ver_info, svc_size);
-	if (ret < 0)
-		goto done;
-
-	ret = ver_info.services[0].api_version;
-	common.is_avcs_version_queried = true;
-done:
-	kfree(ver_info.services);
-	return ret;
-}
-
-static int voice_setup_vocproc(struct voice_data *v)
-{
-	int ret = 0;
-
-	ret = voice_send_cvp_create_cmd(v);
-	if (ret < 0) {
-		pr_err("%s: CVP create failed err:%d\n", __func__, ret);
-		goto fail;
-	}
-
-	if (common.is_avcs_version_queried == false)
-		common.cvp_version = voice_get_avcs_version_per_service(
-				     APRV2_IDS_SERVICE_ID_ADSP_CVP_V);
-
-	if (common.cvp_version < 0) {
-		pr_err("%s: Invalid CVP version %d\n",
-		       __func__, common.cvp_version);
-		ret = -EINVAL;
-		goto fail;
-	}
-	pr_debug("%s: CVP Version %d\n", __func__, common.cvp_version);
-
-	ret = voice_send_cvp_media_fmt_info_cmd(v);
-	if (ret < 0) {
-		pr_err("%s: Set media format info failed err:%d\n", __func__,
-		       ret);
-		goto fail;
-	}
-
-	ret = voice_send_cvp_topology_commit_cmd(v);
-	if (ret < 0) {
-		pr_err("%s: Set topology commit failed err:%d\n",
-		       __func__, ret);
-		goto fail;
-	}
-
-	/* Send MFC config only when the no of channels are more than 1 */
-	if (v->dev_rx.no_of_channels > NUM_CHANNELS_MONO) {
-		ret = voice_send_cvp_mfc_config_cmd(v);
-		if (ret < 0) {
-			pr_warn("%s: Set mfc config failed err:%d\n",
-				__func__, ret);
-		}
-	}
-
-	voice_send_cvs_register_cal_cmd(v);
-	voice_send_cvp_register_dev_cfg_cmd(v);
-	voice_send_cvp_register_cal_cmd(v);
-	voice_send_cvp_register_vol_cal_cmd(v);
-
-	/* enable vocproc */
-	ret = voice_send_enable_vocproc_cmd(v);
-	if (ret < 0)
-		goto fail;
-
-	/* attach vocproc */
-	ret = voice_send_attach_vocproc_cmd(v);
-	if (ret < 0)
-		goto fail;
-
-	/* send tty mode if tty device is used */
-	voice_send_tty_mode_cmd(v);
-
-	if (is_voip_session(v->session_id)) {
-		ret = voice_send_mvm_cal_network_cmd(v);
-		if (ret < 0)
-			pr_err("%s: voice_send_mvm_cal_network_cmd: %d\n",
-				__func__, ret);
-
-		ret = voice_send_mvm_media_type_cmd(v);
-		if (ret < 0)
-			pr_err("%s: voice_send_mvm_media_type_cmd: %d\n",
-				__func__, ret);
-
-		voice_send_netid_timing_cmd(v);
-	}
-
-	if (v->st_enable && !v->tty_mode)
-		voice_send_set_pp_enable_cmd(v,
-					     MODULE_ID_VOICE_MODULE_ST,
-					     v->st_enable);
-	/* Start in-call music delivery if this feature is enabled */
-	if (v->music_info.play_enable)
-		voice_cvs_start_playback(v);
-
-	/* Start in-call recording if this feature is enabled */
-	if (v->rec_info.rec_enable)
-		voice_cvs_start_record(v, v->rec_info.rec_mode);
-
-	if (v->dtmf_rx_detect_en)
-		voice_send_dtmf_rx_detection_cmd(v, v->dtmf_rx_detect_en);
-
-	if (v->hd_enable)
-		voice_send_hd_cmd(v, v->hd_enable);
-
-	rtac_add_voice(voice_get_cvs_handle(v),
-		voice_get_cvp_handle(v),
-		v->dev_rx.port_id, v->dev_tx.port_id,
-		v->dev_rx.dev_id, v->dev_tx.dev_id,
-		v->session_id);
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_send_cvp_device_channels_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct  cvp_set_dev_channels_cmd cvp_set_dev_channels_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-
-	if (!(voice_get_cvd_int_version(common.cvd_version) >=
-	      CVD_INT_VERSION_2_2)) {
-		pr_debug("%s CVD ver %s doesn't support send_device_channels cmd\n",
-			 __func__, common.cvd_version);
-
-		goto done;
-	}
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-	cvp_set_dev_channels_cmd.hdr.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE),
-			APR_PKT_VER);
-	cvp_set_dev_channels_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-			sizeof(cvp_set_dev_channels_cmd) - APR_HDR_SIZE);
-	cvp_set_dev_channels_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_set_dev_channels_cmd.hdr.dest_port = cvp_handle;
-	cvp_set_dev_channels_cmd.hdr.token = 0;
-	cvp_set_dev_channels_cmd.hdr.opcode =
-				VSS_IVOCPROC_CMD_TOPOLOGY_SET_DEV_CHANNELS;
-	cvp_set_dev_channels_cmd.cvp_set_channels.rx_num_channels =
-				VSS_NUM_DEV_CHANNELS_1;
-	cvp_set_dev_channels_cmd.cvp_set_channels.tx_num_channels =
-				v->dev_tx.no_of_channels;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_set_dev_channels_cmd);
-	if (ret < 0) {
-		pr_err("%s: Fail in sending VSS_IVOCPROC_CMD_TOPOLOGY_SET_DEV_CHANNELS\n",
-		       __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-				(v->cvp_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_media_fmt_info_cmd(struct voice_data *v)
-{
-	int ret = 0;
-
-	if (common.cvp_version < CVP_VERSION_2)
-		ret = voice_send_cvp_device_channels_cmd(v);
-	else
-		ret = voice_send_cvp_channel_info_cmd(v);
-
-	if (ret < 0) {
-		pr_err("%s: Set channel info failed err: %d\n", __func__,
-		       ret);
-		goto done;
-	}
-
-	if (voice_get_cvd_int_version(common.cvd_version) >=
-	    CVD_INT_VERSION_2_3) {
-		ret = voice_send_cvp_media_format_cmd(v, RX_PATH);
-		if (ret < 0)
-			goto done;
-
-		ret = voice_send_cvp_media_format_cmd(v, TX_PATH);
-		if (ret < 0)
-			goto done;
-
-		if (common.ec_ref_ext)
-			ret = voice_send_cvp_media_format_cmd(v, EC_REF_PATH);
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_media_format_cmd(struct voice_data *v,
-					   uint32_t param_type)
-{
-	int ret = 0;
-	struct cvp_set_media_format_cmd cvp_set_media_format_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct vss_icommon_param_data_t *media_fmt_param_data =
-		&cvp_set_media_format_cmd.cvp_set_media_param_v2.param_data;
-	struct vss_param_endpoint_media_format_info_t *media_fmt_info =
-		&media_fmt_param_data->media_format_info;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-	memset(&cvp_set_media_format_cmd, 0, sizeof(cvp_set_media_format_cmd));
-
-	/* Fill header data */
-	cvp_set_media_format_cmd.hdr.hdr_field =
-		APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
-			      APR_PKT_VER);
-	cvp_set_media_format_cmd.hdr.pkt_size =
-		APR_PKT_SIZE(APR_HDR_SIZE,
-			     sizeof(cvp_set_media_format_cmd) - APR_HDR_SIZE);
-	cvp_set_media_format_cmd.hdr.src_svc = 0;
-	cvp_set_media_format_cmd.hdr.src_domain = APR_DOMAIN_APPS;
-	cvp_set_media_format_cmd.hdr.src_port =
-		voice_get_idx_for_session(v->session_id);
-	cvp_set_media_format_cmd.hdr.dest_svc = 0;
-	cvp_set_media_format_cmd.hdr.dest_domain = APR_DOMAIN_ADSP;
-	cvp_set_media_format_cmd.hdr.dest_port = cvp_handle;
-	cvp_set_media_format_cmd.hdr.token = VOC_SET_MEDIA_FORMAT_PARAM_TOKEN;
-	cvp_set_media_format_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_PARAM_V2;
-
-	/* Fill param data */
-	cvp_set_media_format_cmd.cvp_set_media_param_v2.mem_size =
-		sizeof(struct vss_icommon_param_data_t);
-	media_fmt_param_data->module_id = VSS_MODULE_CVD_GENERIC;
-	media_fmt_param_data->param_size =
-		sizeof(struct vss_param_endpoint_media_format_info_t);
-
-	/* Fill device specific data */
-	switch (param_type) {
-	case RX_PATH:
-		media_fmt_param_data->param_id =
-			VSS_PARAM_RX_PORT_ENDPOINT_MEDIA_INFO;
-		media_fmt_info->port_id = v->dev_rx.port_id;
-		media_fmt_info->num_channels = v->dev_rx.no_of_channels;
-		media_fmt_info->bits_per_sample = v->dev_rx.bits_per_sample;
-		media_fmt_info->sample_rate = v->dev_rx.sample_rate;
-		memcpy(&media_fmt_info->channel_mapping,
-		       &v->dev_rx.channel_mapping, VSS_CHANNEL_MAPPING_SIZE);
-		break;
-
-	case TX_PATH:
-		media_fmt_param_data->param_id =
-			VSS_PARAM_TX_PORT_ENDPOINT_MEDIA_INFO;
-		media_fmt_info->port_id = v->dev_tx.port_id;
-		media_fmt_info->num_channels = v->dev_tx.no_of_channels;
-		media_fmt_info->bits_per_sample = v->dev_tx.bits_per_sample;
-		media_fmt_info->sample_rate = v->dev_tx.sample_rate;
-		memcpy(&media_fmt_info->channel_mapping,
-		       &v->dev_tx.channel_mapping, VSS_CHANNEL_MAPPING_SIZE);
-		break;
-
-	case EC_REF_PATH:
-		media_fmt_param_data->param_id =
-			VSS_PARAM_EC_REF_PORT_ENDPOINT_MEDIA_INFO;
-		media_fmt_info->port_id = common.ec_media_fmt_info.port_id;
-		media_fmt_info->num_channels =
-			common.ec_media_fmt_info.num_channels;
-		media_fmt_info->bits_per_sample =
-			common.ec_media_fmt_info.bits_per_sample;
-		media_fmt_info->sample_rate =
-			common.ec_media_fmt_info.sample_rate;
-		memcpy(&media_fmt_info->channel_mapping,
-		       &common.ec_media_fmt_info.channel_mapping,
-		       VSS_CHANNEL_MAPPING_SIZE);
-		break;
-
-	default:
-		pr_err("%s: Invalid param type %d\n", __func__, param_type);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/* Send command */
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_set_media_format_cmd);
-	if (ret < 0) {
-		pr_err("%s: Fail in sending VSS_ICOMMON_CMD_SET_PARAM_V2\n",
-		       __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s] handle = %d\n", __func__,
-		       adsp_err_get_err_str(v->async_err), cvp_handle);
-		ret = adsp_err_get_lnx_err_code(v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_cvp_topology_commit_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct apr_hdr cvp_topology_commit_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-
-	if (!(voice_get_cvd_int_version(common.cvd_version) >=
-	      CVD_INT_VERSION_2_2)) {
-		pr_debug("%s CVD version string %s doesn't support this command\n",
-			 __func__, common.cvd_version);
-
-		goto done;
-	}
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	apr_cvp = common.apr_q6_cvp;
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-	cvp_topology_commit_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_topology_commit_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_topology_commit_cmd) - APR_HDR_SIZE);
-	cvp_topology_commit_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_topology_commit_cmd.dest_port = cvp_handle;
-	cvp_topology_commit_cmd.token = 0;
-	cvp_topology_commit_cmd.opcode = VSS_IVOCPROC_CMD_TOPOLOGY_COMMIT;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_topology_commit_cmd);
-	if (ret < 0) {
-		pr_err("%s: Fail in sending VSS_IVOCPROC_CMD_TOPOLOGY_COMMIT\n",
-		       __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = wait_event_timeout(v->cvp_wait,
-				(v->cvp_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-			__func__, adsp_err_get_err_str(
-			v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int voice_send_enable_vocproc_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct apr_hdr cvp_enable_cmd;
-	void *apr_cvp;
-	u16 cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* enable vocproc and wait for respose */
-	cvp_enable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_enable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_enable_cmd) - APR_HDR_SIZE);
-	pr_debug("cvp_enable_cmd pkt size = %d, cvp_handle=%d\n",
-		cvp_enable_cmd.pkt_size, cvp_handle);
-	cvp_enable_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_enable_cmd.dest_port = cvp_handle;
-	cvp_enable_cmd.token = 0;
-	cvp_enable_cmd.opcode = VSS_IVOCPROC_CMD_ENABLE;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_enable_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IVOCPROC_CMD_ENABLE\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				(v->cvp_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_mvm_cal_network_cmd(struct voice_data *v)
-{
-	struct vss_imvm_cmd_set_cal_network_t mvm_set_cal_network;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	mvm_set_cal_network.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_set_cal_network.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_set_cal_network) - APR_HDR_SIZE);
-	mvm_set_cal_network.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_set_cal_network.hdr.dest_port = mvm_handle;
-	mvm_set_cal_network.hdr.token = 0;
-	mvm_set_cal_network.hdr.opcode = VSS_IMVM_CMD_SET_CAL_NETWORK;
-	mvm_set_cal_network.network_id = VSS_ICOMMON_CAL_NETWORK_ID_NONE;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_cal_network);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_NETWORK\n", __func__, ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				(v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout %d\n", __func__, ret);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_netid_timing_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-	struct mvm_set_network_cmd mvm_set_network;
-	struct mvm_set_voice_timing_cmd mvm_set_voice_timing;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	ret = voice_config_cvs_vocoder(v);
-	if (ret < 0) {
-		pr_err("%s: Error %d configuring CVS voc",
-					__func__, ret);
-		goto fail;
-	}
-	/* Set network ID. */
-	pr_debug("Setting network ID %x\n", common.mvs_info.network_type);
-
-	mvm_set_network.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_set_network.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(mvm_set_network) - APR_HDR_SIZE);
-	mvm_set_network.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_set_network.hdr.dest_port = mvm_handle;
-	mvm_set_network.hdr.token = 0;
-	mvm_set_network.hdr.opcode = VSS_IMVM_CMD_SET_CAL_NETWORK;
-	mvm_set_network.network.network_id = common.mvs_info.network_type;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_network);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_NETWORK\n", __func__, ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				(v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	/* Set voice timing. */
-	 pr_debug("Setting voice timing\n");
-
-	mvm_set_voice_timing.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_set_voice_timing.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-						sizeof(mvm_set_voice_timing) -
-						APR_HDR_SIZE);
-	mvm_set_voice_timing.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_set_voice_timing.hdr.dest_port = mvm_handle;
-	mvm_set_voice_timing.hdr.token = 0;
-	mvm_set_voice_timing.hdr.opcode = VSS_ICOMMON_CMD_SET_VOICE_TIMING;
-	mvm_set_voice_timing.timing.mode = 0;
-	mvm_set_voice_timing.timing.enc_offset = 8000;
-	mvm_set_voice_timing.timing.dec_req_offset = 3300;
-	mvm_set_voice_timing.timing.dec_offset = 8300;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_voice_timing);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending SET_TIMING\n", __func__, ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				(v->mvm_state == CMD_STATUS_SUCCESS),
-				msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_attach_vocproc_cmd(struct voice_data *v)
-{
-	int ret = 0;
-	struct mvm_attach_vocproc_cmd mvm_a_vocproc_cmd;
-	void *apr_mvm;
-	u16 mvm_handle, cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* attach vocproc and wait for response */
-	mvm_a_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_a_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_a_vocproc_cmd) - APR_HDR_SIZE);
-	pr_debug("send mvm_a_vocproc_cmd pkt size = %d\n",
-		mvm_a_vocproc_cmd.hdr.pkt_size);
-	mvm_a_vocproc_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_a_vocproc_cmd.hdr.dest_port = mvm_handle;
-	mvm_a_vocproc_cmd.hdr.token = 0;
-	mvm_a_vocproc_cmd.hdr.opcode = VSS_IMVM_CMD_ATTACH_VOCPROC;
-	mvm_a_vocproc_cmd.mvm_attach_cvp_handle.handle = cvp_handle;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_a_vocproc_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IMVM_CMD_ATTACH_VOCPROC\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-
-static void voc_update_session_params(struct voice_data *v)
-{
-	/* reset LCH mode */
-	v->lch_mode = 0;
-
-	/* clear disable topology setting */
-	v->disable_topology = false;
-
-	/* clear mute setting */
-	v->dev_rx.dev_mute =  common.default_mute_val;
-	v->dev_tx.dev_mute =  common.default_mute_val;
-	v->stream_rx.stream_mute = common.default_mute_val;
-	v->stream_tx.stream_mute = common.default_mute_val;
-}
-
-static int voice_destroy_vocproc(struct voice_data *v)
-{
-	struct mvm_detach_vocproc_cmd mvm_d_vocproc_cmd;
-	struct apr_hdr cvp_destroy_session_cmd;
-	int ret = 0;
-	void *apr_mvm, *apr_cvp;
-	u16 mvm_handle, cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_mvm || !apr_cvp) {
-		pr_err("%s: apr_mvm or apr_cvp is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* disable slowtalk if st_enable is set */
-	if (v->st_enable)
-		voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_ST, 0);
-
-	/* Disable HD Voice if hd_enable is set */
-	if (v->hd_enable)
-		voice_send_hd_cmd(v, 0);
-
-	/* stop playback or recording */
-	v->music_info.force = 1;
-	voice_cvs_stop_playback(v);
-	voice_cvs_stop_record(v);
-	/* If voice call is active during VoLTE, SRVCC happens.
-	 * Start recording on voice session if recording started during VoLTE.
-	 */
-	if (is_volte_session(v->session_id) &&
-	    ((common.voice[VOC_PATH_PASSIVE].voc_state == VOC_RUN) ||
-	     (common.voice[VOC_PATH_PASSIVE].voc_state == VOC_CHANGE))) {
-		if (v->rec_info.rec_enable) {
-			voice_cvs_start_record(
-				&common.voice[VOC_PATH_PASSIVE],
-				v->rec_info.rec_mode);
-			common.srvcc_rec_flag = true;
-
-			pr_debug("%s: switch recording, srvcc_rec_flag %d\n",
-				 __func__, common.srvcc_rec_flag);
-		}
-	}
-
-	/* send stop voice cmd */
-	voice_send_stop_voice_cmd(v);
-
-	/* send stop dtmf detecton cmd */
-	if (v->dtmf_rx_detect_en)
-		voice_send_dtmf_rx_detection_cmd(v, 0);
-
-	/* detach VOCPROC and wait for response from mvm */
-	mvm_d_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mvm_d_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mvm_d_vocproc_cmd) - APR_HDR_SIZE);
-	pr_debug("mvm_d_vocproc_cmd  pkt size = %d\n",
-		mvm_d_vocproc_cmd.hdr.pkt_size);
-	mvm_d_vocproc_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mvm_d_vocproc_cmd.hdr.dest_port = mvm_handle;
-	mvm_d_vocproc_cmd.hdr.token = 0;
-	mvm_d_vocproc_cmd.hdr.opcode = VSS_IMVM_CMD_DETACH_VOCPROC;
-	mvm_d_vocproc_cmd.mvm_detach_cvp_handle.handle = cvp_handle;
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_d_vocproc_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending VSS_IMVM_CMD_DETACH_VOCPROC\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	voice_send_cvp_deregister_vol_cal_cmd(v);
-	voice_send_cvp_deregister_cal_cmd(v);
-	voice_send_cvp_deregister_dev_cfg_cmd(v);
-	voice_send_cvs_deregister_cal_cmd(v);
-
-	/* destrop cvp session */
-	cvp_destroy_session_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_destroy_session_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_destroy_session_cmd) - APR_HDR_SIZE);
-	pr_debug("cvp_destroy_session_cmd pkt size = %d\n",
-		cvp_destroy_session_cmd.pkt_size);
-	cvp_destroy_session_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_destroy_session_cmd.dest_port = cvp_handle;
-	cvp_destroy_session_cmd.token = 0;
-	cvp_destroy_session_cmd.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_destroy_session_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending APRV2_IBASIC_CMD_DESTROY_SESSION\n");
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	rtac_remove_voice(voice_get_cvs_handle(v));
-	cvp_handle = 0;
-	voice_set_cvp_handle(v, cvp_handle);
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_mvm_unmap_memory_physical_cmd(struct voice_data *v,
-						    uint32_t mem_handle)
-{
-	struct vss_imemory_cmd_unmap_t mem_unmap;
-	int ret = 0;
-	void *apr_mvm;
-	u16 mvm_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_mvm = common.apr_q6_mvm;
-
-	if (!apr_mvm) {
-		pr_err("%s: apr_mvm is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	mvm_handle = voice_get_mvm_handle(v);
-
-	mem_unmap.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	mem_unmap.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(mem_unmap) - APR_HDR_SIZE);
-	mem_unmap.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	mem_unmap.hdr.dest_port = mvm_handle;
-	mem_unmap.hdr.token = 0;
-	mem_unmap.hdr.opcode = VSS_IMEMORY_CMD_UNMAP;
-	mem_unmap.mem_handle = mem_handle;
-
-	pr_debug("%s: mem_handle: 0x%x\n", __func__, mem_unmap.mem_handle);
-
-	v->mvm_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_mvm, (uint32_t *) &mem_unmap);
-	if (ret < 0) {
-		pr_err("mem_unmap op[0x%x]ret[%d]\n",
-			mem_unmap.hdr.opcode, ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->mvm_wait,
-				 (v->mvm_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout %d\n", __func__, ret);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_send_cvs_packet_exchange_config_cmd(struct voice_data *v)
-{
-	struct vss_istream_cmd_set_oob_packet_exchange_config_t
-						 packet_exchange_config_pkt;
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvs_handle = voice_get_cvs_handle(v);
-
-	packet_exchange_config_pkt.hdr.hdr_field = APR_HDR_FIELD(
-						APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	packet_exchange_config_pkt.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(packet_exchange_config_pkt) -
-					 APR_HDR_SIZE);
-	packet_exchange_config_pkt.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	packet_exchange_config_pkt.hdr.dest_port = cvs_handle;
-	packet_exchange_config_pkt.hdr.token = 0;
-	packet_exchange_config_pkt.hdr.opcode =
-			 VSS_ISTREAM_CMD_SET_OOB_PACKET_EXCHANGE_CONFIG;
-	packet_exchange_config_pkt.mem_handle = v->shmem_info.mem_handle;
-	/* dec buffer address */
-	packet_exchange_config_pkt.dec_buf_addr_lsw =
-		lower_32_bits(v->shmem_info.sh_buf.buf[0].phys);
-	packet_exchange_config_pkt.dec_buf_addr_msw =
-		msm_audio_populate_upper_32_bits(
-					v->shmem_info.sh_buf.buf[0].phys);
-	packet_exchange_config_pkt.dec_buf_size = 4096;
-	/* enc buffer address */
-	packet_exchange_config_pkt.enc_buf_addr_lsw =
-		lower_32_bits(v->shmem_info.sh_buf.buf[1].phys);
-	packet_exchange_config_pkt.enc_buf_addr_msw =
-		msm_audio_populate_upper_32_bits(
-					v->shmem_info.sh_buf.buf[1].phys);
-	packet_exchange_config_pkt.enc_buf_size = 4096;
-
-	pr_debug("%s: dec buf add: lsw %0x msw %0x, size %d, enc buf add: lsw %0x msw %0x, size %d\n",
-		__func__,
-		packet_exchange_config_pkt.dec_buf_addr_lsw,
-		packet_exchange_config_pkt.dec_buf_addr_msw,
-		packet_exchange_config_pkt.dec_buf_size,
-		packet_exchange_config_pkt.enc_buf_addr_lsw,
-		packet_exchange_config_pkt.enc_buf_addr_msw,
-		packet_exchange_config_pkt.enc_buf_size);
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &packet_exchange_config_pkt);
-	if (ret < 0) {
-		pr_err("Failed to send packet exchange config cmd %d\n", ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret)
-		pr_err("%s: wait_event timeout %d\n", __func__, ret);
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_cvs_data_exchange_mode_cmd(struct voice_data *v)
-{
-	struct vss_istream_cmd_set_packet_exchange_mode_t data_exchange_pkt;
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvs_handle = voice_get_cvs_handle(v);
-
-	data_exchange_pkt.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	data_exchange_pkt.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(data_exchange_pkt) - APR_HDR_SIZE);
-	data_exchange_pkt.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	data_exchange_pkt.hdr.dest_port = cvs_handle;
-	data_exchange_pkt.hdr.token = 0;
-	data_exchange_pkt.hdr.opcode = VSS_ISTREAM_CMD_SET_PACKET_EXCHANGE_MODE;
-	data_exchange_pkt.mode = VSS_ISTREAM_PACKET_EXCHANGE_MODE_OUT_OF_BAND;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvs, (uint32_t *) &data_exchange_pkt);
-	if (ret < 0) {
-		pr_err("Failed to send data exchange mode %d\n", ret);
-		goto fail;
-	}
-
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret)
-		pr_err("%s: wait_event timeout %d\n", __func__, ret);
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-	return 0;
-fail:
-	return ret;
-}
-
-static int voice_send_stream_mute_cmd(struct voice_data *v, uint16_t direction,
-				     uint16_t mute_flag, uint32_t ramp_duration)
-{
-	struct cvs_set_mute_cmd cvs_mute_cmd;
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (!common.apr_q6_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	/* send mute/unmute to cvs */
-	cvs_mute_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvs_mute_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(cvs_mute_cmd) - APR_HDR_SIZE);
-	cvs_mute_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvs_mute_cmd.hdr.dest_port = voice_get_cvs_handle(v);
-	cvs_mute_cmd.hdr.token = 0;
-	cvs_mute_cmd.hdr.opcode = VSS_IVOLUME_CMD_MUTE_V2;
-	cvs_mute_cmd.cvs_set_mute.direction = direction;
-	cvs_mute_cmd.cvs_set_mute.mute_flag = mute_flag;
-	cvs_mute_cmd.cvs_set_mute.ramp_duration_ms = ramp_duration;
-
-	v->cvs_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvs, (uint32_t *) &cvs_mute_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending stream mute\n", __func__, ret);
-
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_send_device_mute_cmd(struct voice_data *v, uint16_t direction,
-				     uint16_t mute_flag, uint32_t ramp_duration)
-{
-	struct cvp_set_mute_cmd cvp_mute_cmd;
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (!common.apr_q6_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	cvp_mute_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_mute_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(cvp_mute_cmd) - APR_HDR_SIZE);
-	cvp_mute_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_mute_cmd.hdr.dest_port = voice_get_cvp_handle(v);
-	cvp_mute_cmd.hdr.token = 0;
-	cvp_mute_cmd.hdr.opcode = VSS_IVOLUME_CMD_MUTE_V2;
-	cvp_mute_cmd.cvp_set_mute.direction = direction;
-	cvp_mute_cmd.cvp_set_mute.mute_flag = mute_flag;
-	cvp_mute_cmd.cvp_set_mute.ramp_duration_ms = ramp_duration;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(common.apr_q6_cvp, (uint32_t *) &cvp_mute_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error %d sending rx device cmd\n", __func__, ret);
-
-		goto fail;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: Command timeout\n", __func__);
-		goto fail;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto fail;
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_send_vol_step_cmd(struct voice_data *v)
-{
-	struct cvp_set_rx_volume_step_cmd cvp_vol_step_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		return -EINVAL;
-	}
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* send volume index to cvp */
-	cvp_vol_step_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-						APR_HDR_LEN(APR_HDR_SIZE),
-						APR_PKT_VER);
-	cvp_vol_step_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvp_vol_step_cmd) - APR_HDR_SIZE);
-	cvp_vol_step_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_vol_step_cmd.hdr.dest_port = cvp_handle;
-	cvp_vol_step_cmd.hdr.token = 0;
-	cvp_vol_step_cmd.hdr.opcode = VSS_IVOLUME_CMD_SET_STEP;
-	cvp_vol_step_cmd.cvp_set_vol_step.direction = VSS_IVOLUME_DIRECTION_RX;
-	cvp_vol_step_cmd.cvp_set_vol_step.value = v->dev_rx.volume_step_value;
-	cvp_vol_step_cmd.cvp_set_vol_step.ramp_duration_ms =
-					v->dev_rx.volume_ramp_duration_ms;
-	 pr_debug("%s step_value:%d, ramp_duration_ms:%d",
-			__func__,
-			cvp_vol_step_cmd.cvp_set_vol_step.value,
-			cvp_vol_step_cmd.cvp_set_vol_step.ramp_duration_ms);
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_vol_step_cmd);
-	if (ret < 0) {
-		pr_err("Fail in sending RX VOL step\n");
-		return -EINVAL;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		return -EINVAL;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		return ret;
-	}
-	return 0;
-}
-
-static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-
-	struct cvs_start_record_cmd cvs_start_record;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	if (!v->rec_info.recording) {
-		cvs_start_record.hdr.hdr_field = APR_HDR_FIELD(
-					APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-		cvs_start_record.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				  sizeof(cvs_start_record) - APR_HDR_SIZE);
-		cvs_start_record.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_start_record.hdr.dest_port = cvs_handle;
-		cvs_start_record.hdr.token = 0;
-		cvs_start_record.hdr.opcode = VSS_IRECORD_CMD_START;
-
-		cvs_start_record.rec_mode.port_id =
-					VSS_IRECORD_PORT_ID_DEFAULT;
-		if (rec_mode == VOC_REC_UPLINK) {
-			cvs_start_record.rec_mode.rx_tap_point =
-					VSS_IRECORD_TAP_POINT_NONE;
-			cvs_start_record.rec_mode.tx_tap_point =
-					VSS_IRECORD_TAP_POINT_STREAM_END;
-		} else if (rec_mode == VOC_REC_DOWNLINK) {
-			cvs_start_record.rec_mode.rx_tap_point =
-					VSS_IRECORD_TAP_POINT_STREAM_END;
-			cvs_start_record.rec_mode.tx_tap_point =
-					VSS_IRECORD_TAP_POINT_NONE;
-		} else if (rec_mode == VOC_REC_BOTH) {
-			cvs_start_record.rec_mode.rx_tap_point =
-					VSS_IRECORD_TAP_POINT_STREAM_END;
-			cvs_start_record.rec_mode.tx_tap_point =
-					VSS_IRECORD_TAP_POINT_STREAM_END;
-		} else {
-			pr_err("%s: Invalid in-call rec_mode %d\n", __func__,
-				rec_mode);
-
-			ret = -EINVAL;
-			goto fail;
-		}
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_record);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending START_RECORD\n", __func__,
-				ret);
-
-			goto fail;
-		}
-
-		ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-		v->rec_info.recording = 1;
-	} else {
-		pr_debug("%s: Start record already sent\n", __func__);
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_cvs_stop_record(struct voice_data *v)
-{
-	int ret = 0;
-	void *apr_cvs;
-	u16 cvs_handle;
-	struct apr_hdr cvs_stop_record;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	if (v->rec_info.recording) {
-		cvs_stop_record.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				  APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		cvs_stop_record.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				  sizeof(cvs_stop_record) - APR_HDR_SIZE);
-		cvs_stop_record.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_stop_record.dest_port = cvs_handle;
-		cvs_stop_record.token = 0;
-		cvs_stop_record.opcode = VSS_IRECORD_CMD_STOP;
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_record);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending STOP_RECORD\n",
-				__func__, ret);
-
-			goto fail;
-		}
-
-		ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-		v->rec_info.recording = 0;
-	} else {
-		pr_debug("%s: Stop record already sent\n", __func__);
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id)
-{
-	int ret = 0;
-	int rec_mode = 0;
-	u16 cvs_handle;
-	int rec_set = 0;
-	struct voice_session_itr itr;
-	struct voice_data *v = NULL;
-
-	/* check if session_id is valid */
-	if (!voice_is_valid_session_id(session_id)) {
-		pr_err("%s: Invalid session id:%u\n", __func__,
-		       session_id);
-
-		return -EINVAL;
-	}
-
-	voice_itr_init(&itr, session_id);
-	pr_debug("%s: session_id:%u\n", __func__, session_id);
-
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v == NULL) {
-			pr_err("%s: v is NULL, sessionid:%u\n", __func__,
-				session_id);
-
-			break;
-		}
-		pr_debug("%s: port_id: %d, set: %d, v: %pK\n",
-			 __func__, port_id, set, v);
-
-		mutex_lock(&v->lock);
-		rec_mode = v->rec_info.rec_mode;
-		rec_set = set;
-		if (set) {
-			if ((v->rec_route_state.ul_flag != 0) &&
-				(v->rec_route_state.dl_flag != 0)) {
-				pr_debug("%s: rec mode already set.\n",
-					__func__);
-
-				mutex_unlock(&v->lock);
-				continue;
-			}
-
-			if (port_id == VOICE_RECORD_TX) {
-				if ((v->rec_route_state.ul_flag == 0)
-				&& (v->rec_route_state.dl_flag == 0)) {
-					rec_mode = VOC_REC_UPLINK;
-					v->rec_route_state.ul_flag = 1;
-				} else if ((v->rec_route_state.ul_flag == 0)
-					&& (v->rec_route_state.dl_flag != 0)) {
-					voice_cvs_stop_record(v);
-					rec_mode = VOC_REC_BOTH;
-					v->rec_route_state.ul_flag = 1;
-				}
-			} else if (port_id == VOICE_RECORD_RX) {
-				if ((v->rec_route_state.ul_flag == 0)
-					&& (v->rec_route_state.dl_flag == 0)) {
-					rec_mode = VOC_REC_DOWNLINK;
-					v->rec_route_state.dl_flag = 1;
-				} else if ((v->rec_route_state.ul_flag != 0)
-					&& (v->rec_route_state.dl_flag == 0)) {
-					voice_cvs_stop_record(v);
-					rec_mode = VOC_REC_BOTH;
-					v->rec_route_state.dl_flag = 1;
-				}
-			}
-			rec_set = 1;
-		} else {
-			if ((v->rec_route_state.ul_flag == 0) &&
-				(v->rec_route_state.dl_flag == 0)) {
-				pr_debug("%s: rec already stops.\n",
-					__func__);
-				mutex_unlock(&v->lock);
-				continue;
-			}
-
-			if (port_id == VOICE_RECORD_TX) {
-				if ((v->rec_route_state.ul_flag != 0)
-					&& (v->rec_route_state.dl_flag == 0)) {
-					v->rec_route_state.ul_flag = 0;
-					rec_set = 0;
-				} else if ((v->rec_route_state.ul_flag != 0)
-					&& (v->rec_route_state.dl_flag != 0)) {
-					voice_cvs_stop_record(v);
-					v->rec_route_state.ul_flag = 0;
-					rec_mode = VOC_REC_DOWNLINK;
-					rec_set = 1;
-				}
-			} else if (port_id == VOICE_RECORD_RX) {
-				if ((v->rec_route_state.ul_flag == 0)
-					&& (v->rec_route_state.dl_flag != 0)) {
-					v->rec_route_state.dl_flag = 0;
-					rec_set = 0;
-				} else if ((v->rec_route_state.ul_flag != 0)
-					&& (v->rec_route_state.dl_flag != 0)) {
-					voice_cvs_stop_record(v);
-					v->rec_route_state.dl_flag = 0;
-					rec_mode = VOC_REC_UPLINK;
-					rec_set = 1;
-				}
-			}
-		}
-		pr_debug("%s: mode =%d, set =%d\n", __func__,
-			 rec_mode, rec_set);
-		cvs_handle = voice_get_cvs_handle(v);
-
-		if (cvs_handle != 0) {
-			if (rec_set)
-				ret = voice_cvs_start_record(v, rec_mode);
-			else
-				ret = voice_cvs_stop_record(v);
-		}
-
-		/* During SRVCC, recording will switch from VoLTE session to
-		 * voice session.
-		 * Then stop recording, need to stop recording on voice session.
-		 */
-		if ((!rec_set) && common.srvcc_rec_flag) {
-			pr_debug("%s, srvcc_rec_flag:%d\n",  __func__,
-				 common.srvcc_rec_flag);
-
-			voice_cvs_stop_record(&common.voice[VOC_PATH_PASSIVE]);
-			common.srvcc_rec_flag = false;
-		}
-
-		/* Cache the value */
-		v->rec_info.rec_enable = rec_set;
-		v->rec_info.rec_mode = rec_mode;
-
-		mutex_unlock(&v->lock);
-	}
-
-	return ret;
-}
-
-static int voice_cvs_start_playback(struct voice_data *v)
-{
-	int ret = 0;
-	struct cvs_start_playback_cmd cvs_start_playback;
-	void *apr_cvs;
-	u16 cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	if (!v->music_info.playing && v->music_info.count) {
-		cvs_start_playback.hdr.hdr_field = APR_HDR_FIELD(
-					APR_MSG_TYPE_SEQ_CMD,
-					APR_HDR_LEN(APR_HDR_SIZE),
-					APR_PKT_VER);
-		cvs_start_playback.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvs_start_playback) - APR_HDR_SIZE);
-		cvs_start_playback.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_start_playback.hdr.dest_port = cvs_handle;
-		cvs_start_playback.hdr.token = 0;
-		cvs_start_playback.hdr.opcode = VSS_IPLAYBACK_CMD_START;
-		cvs_start_playback.playback_mode.port_id =
-						v->music_info.port_id;
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_playback);
-
-		if (ret < 0) {
-			pr_err("%s: Error %d sending START_PLAYBACK\n",
-				__func__, ret);
-
-			goto fail;
-		}
-
-		ret = wait_event_timeout(v->cvs_wait,
-				 (v->cvs_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-
-		v->music_info.playing = 1;
-	} else {
-		pr_debug("%s: Start playback already sent\n", __func__);
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voice_cvs_stop_playback(struct voice_data *v)
-{
-	 int ret = 0;
-	 struct apr_hdr cvs_stop_playback;
-	 void *apr_cvs;
-	 u16 cvs_handle;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvs = common.apr_q6_cvs;
-
-	if (!apr_cvs) {
-		pr_err("%s: apr_cvs is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvs_handle = voice_get_cvs_handle(v);
-
-	if (v->music_info.playing && ((!v->music_info.count) ||
-						(v->music_info.force))) {
-		cvs_stop_playback.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		cvs_stop_playback.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(cvs_stop_playback) - APR_HDR_SIZE);
-		cvs_stop_playback.src_port =
-				voice_get_idx_for_session(v->session_id);
-		cvs_stop_playback.dest_port = cvs_handle;
-		cvs_stop_playback.token = 0;
-
-		cvs_stop_playback.opcode = VSS_IPLAYBACK_CMD_STOP;
-
-		v->cvs_state = CMD_STATUS_FAIL;
-		v->async_err = 0;
-
-		ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_playback);
-		if (ret < 0) {
-			pr_err("%s: Error %d sending STOP_PLAYBACK\n",
-			       __func__, ret);
-
-
-			goto fail;
-		}
-
-		ret = wait_event_timeout(v->cvs_wait,
-					 (v->cvs_state == CMD_STATUS_SUCCESS),
-					 msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret) {
-			pr_err("%s: wait_event timeout\n", __func__);
-
-			goto fail;
-		}
-		if (v->async_err > 0) {
-			pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-			ret = adsp_err_get_lnx_err_code(
-					v->async_err);
-			goto fail;
-		}
-
-		v->music_info.playing = 0;
-		v->music_info.force = 0;
-	} else {
-		pr_debug("%s: Stop playback already sent\n", __func__);
-	}
-
-	return 0;
-
-fail:
-	return ret;
-}
-
-static int voc_lch_ops(struct voice_data *v, enum voice_lch_mode lch_mode)
-{
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	switch (lch_mode) {
-	case VOICE_LCH_START:
-
-		ret = voc_end_voice_call(v->session_id);
-		if (ret < 0)
-			pr_err("%s: voice call end failed %d\n",
-				__func__, ret);
-		break;
-	case VOICE_LCH_STOP:
-
-		ret = voc_start_voice_call(v->session_id);
-		if (ret < 0) {
-			pr_err("%s: voice call start failed %d\n",
-				__func__, ret);
-			goto done;
-		}
-		break;
-	default:
-		pr_err("%s: Invalid LCH mode: %d\n",
-			__func__, v->lch_mode);
-		break;
-	}
-done:
-	return ret;
-}
-
-int voc_start_playback(uint32_t set, uint16_t port_id)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-	u16 cvs_handle;
-
-	pr_debug("%s port_id = %#x set = %d", __func__, port_id, set);
-
-	voice_itr_init(&itr, ALL_SESSION_VSID);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if ((v != NULL) &&
-		    (((port_id == VOICE_PLAYBACK_TX) &&
-		       is_sub1_vsid(v->session_id)) ||
-		     ((port_id == VOICE2_PLAYBACK_TX) &&
-		       is_sub2_vsid(v->session_id)))) {
-
-			mutex_lock(&v->lock);
-			v->music_info.port_id = port_id;
-			v->music_info.play_enable = set;
-			if (set)
-				v->music_info.count++;
-			else
-				v->music_info.count--;
-			pr_debug("%s: music_info count=%d\n", __func__,
-				 v->music_info.count);
-
-			cvs_handle = voice_get_cvs_handle(v);
-			if (cvs_handle != 0) {
-				if (set)
-					ret = voice_cvs_start_playback(v);
-				else
-					ret = voice_cvs_stop_playback(v);
-			}
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: Invalid session\n", __func__);
-		}
-	}
-
-	return ret;
-}
-
-int voc_disable_topology(uint32_t session_id, uint32_t disable)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	v->disable_topology = disable;
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-static int voice_set_packet_exchange_mode_and_config(uint32_t session_id,
-						 uint32_t mode)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-		return -EINVAL;
-	}
-
-	if (v->voc_state != VOC_RUN)
-		ret = voice_send_cvs_data_exchange_mode_cmd(v);
-
-	if (ret) {
-		pr_err("%s: Error voice_send_data_exchange_mode_cmd %d\n",
-			__func__, ret);
-		goto fail;
-	}
-
-	ret = voice_send_cvs_packet_exchange_config_cmd(v);
-	if (ret) {
-		pr_err("%s: Error: voice_send_packet_exchange_config_cmd %d\n",
-			__func__, ret);
-		goto fail;
-	}
-
-	return ret;
-fail:
-	return -EINVAL;
-}
-
-int voc_set_tx_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
-		    uint32_t ramp_duration)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			v->stream_tx.stream_mute = mute;
-			v->stream_tx.stream_mute_ramp_duration_ms =
-								ramp_duration;
-			if (is_voc_state_active(v->voc_state) &&
-				(v->lch_mode == 0))
-				ret = voice_send_stream_mute_cmd(v,
-				VSS_IVOLUME_DIRECTION_TX,
-				v->stream_tx.stream_mute,
-				v->stream_tx.stream_mute_ramp_duration_ms);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-				session_id);
-
-			ret = -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-int voc_set_device_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
-			uint32_t ramp_duration)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			if (dir == VSS_IVOLUME_DIRECTION_TX) {
-				v->dev_tx.dev_mute = mute;
-				v->dev_tx.dev_mute_ramp_duration_ms =
-							ramp_duration;
-			} else {
-				v->dev_rx.dev_mute = mute;
-				v->dev_rx.dev_mute_ramp_duration_ms =
-							ramp_duration;
-			}
-
-			if (((v->voc_state == VOC_RUN) ||
-				(v->voc_state == VOC_STANDBY)) &&
-				(v->lch_mode == 0))
-				ret = voice_send_device_mute_cmd(v,
-							dir,
-							mute,
-							ramp_duration);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-				session_id);
-
-			ret = -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-int voc_get_rx_device_mute(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	ret = v->dev_rx.dev_mute;
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_set_tty_mode(uint32_t session_id, uint8_t tty_mode)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	v->tty_mode = tty_mode;
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-uint8_t voc_get_tty_mode(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	ret = v->tty_mode;
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_set_pp_enable(uint32_t session_id, uint32_t module_id, uint32_t enable)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			if (!(is_voice_app_id(v->session_id)))
-				continue;
-
-			mutex_lock(&v->lock);
-			if (module_id == MODULE_ID_VOICE_MODULE_ST)
-				v->st_enable = enable;
-
-			if (v->voc_state == VOC_RUN) {
-				if ((module_id == MODULE_ID_VOICE_MODULE_ST) &&
-				    (!v->tty_mode))
-					ret = voice_send_set_pp_enable_cmd(v,
-						MODULE_ID_VOICE_MODULE_ST,
-						enable);
-			}
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-								session_id);
-			ret =  -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-int voc_set_hd_enable(uint32_t session_id, uint32_t enable)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			v->hd_enable = enable;
-
-			if (v->voc_state == VOC_RUN)
-				ret = voice_send_hd_cmd(v, enable);
-
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-			       session_id);
-			ret =  -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-int voc_set_afe_sidetone(uint32_t session_id, bool sidetone_enable)
-{
-	struct voice_data *v = NULL;
-	int ret = -EINVAL;
-	struct voice_session_itr itr;
-	u16 rx_port, tx_port;
-
-	common.sidetone_enable = sidetone_enable;
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v == NULL) {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-				  session_id);
-			ret = -EINVAL;
-			break;
-		}
-		mutex_lock(&v->lock);
-		if (v->voc_state != VOC_RUN) {
-			mutex_unlock(&v->lock);
-			continue;
-		}
-		rx_port = v->dev_rx.port_id;
-		tx_port = v->dev_tx.port_id;
-		ret = afe_sidetone_enable(tx_port, rx_port,
-					  sidetone_enable);
-		if (!ret) {
-			mutex_unlock(&v->lock);
-			break;
-		}
-		mutex_unlock(&v->lock);
-	}
-	return ret;
-}
-
-bool voc_get_afe_sidetone(void)
-{
-	bool ret;
-
-	ret = common.sidetone_enable;
-	return ret;
-}
-
-int voc_get_pp_enable(uint32_t session_id, uint32_t module_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-	if (module_id == MODULE_ID_VOICE_MODULE_ST)
-		ret = v->st_enable;
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_set_rx_vol_step(uint32_t session_id, uint32_t dir, uint32_t vol_step,
-			uint32_t ramp_duration)
-{
-	struct voice_data *v = NULL;
-	int ret = 0;
-	struct voice_session_itr itr;
-
-	pr_debug("%s session id = %#x vol = %u", __func__, session_id,
-		vol_step);
-
-	voice_itr_init(&itr, session_id);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			v->dev_rx.volume_step_value = vol_step;
-			v->dev_rx.volume_ramp_duration_ms = ramp_duration;
-			if (is_voc_state_active(v->voc_state))
-				ret = voice_send_vol_step_cmd(v);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session_id 0x%x\n", __func__,
-				session_id);
-
-			ret = -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-int voc_set_device_config(uint32_t session_id, uint8_t path_dir,
-			  struct media_format_info *finfo)
-{
-	struct voice_data *v = voice_get_session(session_id);
-
-	if (v == NULL) {
-		pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	pr_debug("%s: path_dir=%d port_id=%x, channels=%d, sample_rate=%d, bits_per_sample=%d\n",
-		__func__, path_dir, finfo->port_id, finfo->num_channels,
-		finfo->sample_rate, finfo->bits_per_sample);
-
-	mutex_lock(&v->lock);
-	switch (path_dir) {
-	case RX_PATH:
-		v->dev_rx.port_id = q6audio_get_port_id(finfo->port_id);
-		v->dev_rx.no_of_channels = finfo->num_channels;
-		v->dev_rx.sample_rate = finfo->sample_rate;
-		v->dev_rx.bits_per_sample = finfo->bits_per_sample;
-		memcpy(&v->dev_rx.channel_mapping, &finfo->channel_mapping,
-		       VSS_CHANNEL_MAPPING_SIZE);
-		break;
-	case TX_PATH:
-		v->dev_tx.port_id = q6audio_get_port_id(finfo->port_id);
-		v->dev_tx.no_of_channels = finfo->num_channels;
-		v->dev_tx.sample_rate = finfo->sample_rate;
-		v->dev_tx.bits_per_sample = finfo->bits_per_sample;
-		memcpy(&v->dev_tx.channel_mapping, &finfo->channel_mapping,
-		       VSS_CHANNEL_MAPPING_SIZE);
-		break;
-	default:
-		pr_err("%s: Invalid path_dir %d\n", __func__, path_dir);
-		return -EINVAL;
-	}
-
-	mutex_unlock(&v->lock);
-
-	return 0;
-}
-
-int voc_set_ext_ec_ref_media_fmt_info(struct media_format_info *finfo)
-{
-	mutex_lock(&common.common_lock);
-	if (common.ec_ref_ext) {
-		common.ec_media_fmt_info.num_channels = finfo->num_channels;
-		common.ec_media_fmt_info.bits_per_sample =
-			finfo->bits_per_sample;
-		common.ec_media_fmt_info.sample_rate = finfo->sample_rate;
-		memcpy(&common.ec_media_fmt_info.channel_mapping,
-		       &finfo->channel_mapping, VSS_CHANNEL_MAPPING_SIZE);
-	} else {
-		pr_debug("%s: Ext Ec Ref not active, returning", __func__);
-	}
-	mutex_unlock(&common.common_lock);
-	return 0;
-}
-
-int voc_set_route_flag(uint32_t session_id, uint8_t path_dir, uint8_t set)
-{
-	struct voice_data *v = voice_get_session(session_id);
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	pr_debug("%s: path_dir=%d, set=%d\n", __func__, path_dir, set);
-
-	mutex_lock(&v->lock);
-
-	if (path_dir == RX_PATH)
-		v->voc_route_state.rx_route_flag = set;
-	else
-		v->voc_route_state.tx_route_flag = set;
-
-	mutex_unlock(&v->lock);
-
-	return 0;
-}
-
-uint8_t voc_get_route_flag(uint32_t session_id, uint8_t path_dir)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return 0;
-	}
-
-	mutex_lock(&v->lock);
-
-	if (path_dir == RX_PATH)
-		ret = v->voc_route_state.rx_route_flag;
-	else
-		ret = v->voc_route_state.tx_route_flag;
-
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_end_voice_call(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	if (v->voc_state == VOC_RUN || v->voc_state == VOC_ERROR ||
-	    v->voc_state == VOC_CHANGE || v->voc_state == VOC_STANDBY) {
-
-		pr_debug("%s: VOC_STATE: %d\n", __func__, v->voc_state);
-
-		ret = voice_destroy_vocproc(v);
-		if (ret < 0)
-			pr_err("%s:  destroy voice failed\n", __func__);
-
-		voc_update_session_params(v);
-
-		voice_destroy_mvm_cvs_session(v);
-		v->voc_state = VOC_RELEASE;
-	} else {
-		pr_err("%s: Error: End voice called in state %d\n",
-			__func__, v->voc_state);
-
-		ret = -EINVAL;
-	}
-
-	mutex_unlock(&v->lock);
-	return ret;
-}
-
-int voc_standby_voice_call(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	struct apr_hdr mvm_standby_voice_cmd;
-	void *apr_mvm;
-	u16 mvm_handle;
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	pr_debug("%s: voc state=%d", __func__, v->voc_state);
-
-	if (v->voc_state == VOC_RUN) {
-		apr_mvm = common.apr_q6_mvm;
-		if (!apr_mvm) {
-			pr_err("%s: apr_mvm is NULL.\n", __func__);
-			ret = -EINVAL;
-			goto fail;
-		}
-		mvm_handle = voice_get_mvm_handle(v);
-		mvm_standby_voice_cmd.hdr_field =
-			APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-			APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-		mvm_standby_voice_cmd.pkt_size =
-			APR_PKT_SIZE(APR_HDR_SIZE,
-			sizeof(mvm_standby_voice_cmd) - APR_HDR_SIZE);
-		pr_debug("send mvm_standby_voice_cmd pkt size = %d\n",
-			 mvm_standby_voice_cmd.pkt_size);
-		mvm_standby_voice_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-		mvm_standby_voice_cmd.dest_port = mvm_handle;
-		mvm_standby_voice_cmd.token = 0;
-		mvm_standby_voice_cmd.opcode = VSS_IMVM_CMD_STANDBY_VOICE;
-		v->mvm_state = CMD_STATUS_FAIL;
-		ret = apr_send_pkt(apr_mvm,
-				(uint32_t *)&mvm_standby_voice_cmd);
-		if (ret < 0) {
-			pr_err("Fail in sending VSS_IMVM_CMD_STANDBY_VOICE\n");
-			ret = -EINVAL;
-			goto fail;
-		}
-		v->voc_state = VOC_STANDBY;
-	}
-fail:
-	return ret;
-}
-
-int voc_disable_device(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: voc state=%d\n", __func__, v->voc_state);
-
-	mutex_lock(&v->lock);
-	if (v->voc_state == VOC_RUN) {
-		ret = voice_pause_voice_call(v);
-		if (ret < 0) {
-			pr_err("%s: Pause Voice Call failed for session 0x%x, err %d!\n",
-			       __func__, v->session_id, ret);
-			goto done;
-		}
-		rtac_remove_voice(voice_get_cvs_handle(v));
-		voice_send_cvp_deregister_vol_cal_cmd(v);
-		voice_send_cvp_deregister_cal_cmd(v);
-		voice_send_cvp_deregister_dev_cfg_cmd(v);
-
-		v->voc_state = VOC_CHANGE;
-	} else {
-		pr_debug("%s: called in voc state=%d, No_OP\n",
-			 __func__, v->voc_state);
-	}
-
-done:
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_enable_device(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: voc state=%d\n", __func__, v->voc_state);
-	mutex_lock(&v->lock);
-	if (v->voc_state == VOC_CHANGE) {
-		ret = voice_send_tty_mode_cmd(v);
-		if (ret < 0) {
-			pr_err("%s: Sending TTY mode failed, ret=%d\n",
-			       __func__, ret);
-			/* Not a critical error, allow voice call to continue */
-		}
-
-		if (v->tty_mode) {
-			/* disable slowtalk */
-			voice_send_set_pp_enable_cmd(v,
-						     MODULE_ID_VOICE_MODULE_ST,
-						     0);
-		} else {
-			/* restore slowtalk */
-			voice_send_set_pp_enable_cmd(v,
-						     MODULE_ID_VOICE_MODULE_ST,
-						     v->st_enable);
-		}
-
-		ret = voice_send_set_device_cmd(v);
-		if (ret < 0) {
-			pr_err("%s: Set device failed, ret=%d\n",
-			       __func__, ret);
-			goto done;
-		}
-
-		ret = voice_send_cvp_media_fmt_info_cmd(v);
-		if (ret < 0) {
-			pr_err("%s: Set format failed err:%d\n", __func__, ret);
-			goto done;
-		}
-
-		ret = voice_send_cvp_topology_commit_cmd(v);
-		if (ret < 0) {
-			pr_err("%s:  Set topology commit failed\n", __func__);
-			goto done;
-		}
-
-		/* Send MFC config only when the no of channels are > 1 */
-		if (v->dev_rx.no_of_channels > NUM_CHANNELS_MONO) {
-			ret = voice_send_cvp_mfc_config_cmd(v);
-			if (ret < 0) {
-				pr_warn("%s: Set mfc config failed err: %d\n",
-					__func__, ret);
-			}
-		}
-
-		voice_send_cvp_register_dev_cfg_cmd(v);
-		voice_send_cvp_register_cal_cmd(v);
-		voice_send_cvp_register_vol_cal_cmd(v);
-
-		rtac_add_voice(voice_get_cvs_handle(v),
-			       voice_get_cvp_handle(v),
-			       v->dev_rx.port_id, v->dev_tx.port_id,
-			       v->dev_rx.dev_id, v->dev_tx.dev_id,
-			       v->session_id);
-
-		ret = voice_send_start_voice_cmd(v);
-		if (ret < 0) {
-			pr_err("%s: Fail in sending START_VOICE, ret=%d\n",
-			       __func__, ret);
-			goto done;
-		}
-		v->voc_state = VOC_RUN;
-	} else {
-		pr_debug("%s: called in voc state=%d, No_OP\n",
-			 __func__, v->voc_state);
-	}
-
-done:
-	mutex_unlock(&v->lock);
-
-	return ret;
-}
-
-int voc_set_lch(uint32_t session_id, enum voice_lch_mode lch_mode)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	mutex_lock(&v->lock);
-	if (v->lch_mode == lch_mode) {
-		pr_debug("%s: Session %d already in LCH mode %d\n",
-				 __func__, session_id, lch_mode);
-
-		mutex_unlock(&v->lock);
-		goto done;
-	}
-
-	v->lch_mode = lch_mode;
-	mutex_unlock(&v->lock);
-
-	ret = voc_lch_ops(v, v->lch_mode);
-	if (ret < 0) {
-		pr_err("%s: lch ops failed %d\n", __func__, ret);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-int voc_resume_voice_call(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	ret = voice_send_start_voice_cmd(v);
-	if (ret < 0) {
-		pr_err("Fail in sending START_VOICE\n");
-		goto fail;
-	}
-	v->voc_state = VOC_RUN;
-	return 0;
-fail:
-	return -EINVAL;
-}
-
-int voc_start_voice_call(uint32_t session_id)
-{
-	struct voice_data *v = voice_get_session(session_id);
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n", __func__, session_id);
-
-		return -EINVAL;
-	}
-
-	mutex_lock(&v->lock);
-
-	if (v->voc_state == VOC_ERROR) {
-		pr_debug("%s: VOC in ERR state\n", __func__);
-
-		voice_destroy_mvm_cvs_session(v);
-		v->voc_state = VOC_INIT;
-	}
-
-	if ((v->voc_state == VOC_INIT) ||
-		(v->voc_state == VOC_RELEASE)) {
-		ret = voice_apr_register(session_id);
-		if (ret < 0) {
-			pr_err("%s:  apr register failed\n", __func__);
-			goto fail;
-		}
-
-		if (is_cvd_version_queried()) {
-			pr_debug("%s: Returning the cached value %s\n",
-				 __func__, common.cvd_version);
-		} else {
-			ret = voice_send_mvm_cvd_version_cmd(v);
-			if (ret < 0)
-				pr_debug("%s: Error retrieving CVD version %d\n",
-					 __func__, ret);
-		}
-
-		ret = voice_create_mvm_cvs_session(v);
-		if (ret < 0) {
-			pr_err("create mvm and cvs failed\n");
-			goto fail;
-		}
-
-		if (is_voip_session(session_id)) {
-			/* Allocate oob mem if not already allocated and
-			 * memory map the oob memory block.
-			 */
-			ret = voice_alloc_and_map_oob_mem(v);
-			if (ret < 0) {
-				pr_err("%s: voice_alloc_and_map_oob_mem() failed, ret:%d\n",
-				       __func__, ret);
-
-				goto fail;
-			}
-
-			ret = voice_set_packet_exchange_mode_and_config(
-				session_id,
-				VSS_ISTREAM_PACKET_EXCHANGE_MODE_OUT_OF_BAND);
-			if (ret) {
-				pr_err("%s: Err: exchange_mode_and_config  %d\n",
-					__func__, ret);
-
-				goto fail;
-			}
-		}
-		ret = voice_send_dual_control_cmd(v);
-		if (ret < 0) {
-			pr_err("Err Dual command failed\n");
-			goto fail;
-		}
-		ret = voice_setup_vocproc(v);
-		if (ret < 0) {
-			pr_err("setup voice failed\n");
-			goto fail;
-		}
-
-		ret = voice_send_vol_step_cmd(v);
-		if (ret < 0)
-			pr_err("voice volume failed\n");
-
-		ret = voice_send_stream_mute_cmd(v,
-				VSS_IVOLUME_DIRECTION_TX,
-				v->stream_tx.stream_mute,
-				v->stream_tx.stream_mute_ramp_duration_ms);
-		if (ret < 0)
-			pr_err("voice mute failed\n");
-
-		ret = voice_send_start_voice_cmd(v);
-		if (ret < 0) {
-			pr_err("start voice failed\n");
-			goto fail;
-		}
-
-		v->voc_state = VOC_RUN;
-	} else {
-		pr_err("%s: Error: Start voice called in state %d\n",
-			__func__, v->voc_state);
-
-		ret = -EINVAL;
-		goto fail;
-	}
-fail:
-	mutex_unlock(&v->lock);
-	return ret;
-}
-
-int voc_set_ext_ec_ref_port_id(uint16_t port_id, bool state)
-{
-	int ret = 0;
-
-	mutex_lock(&common.common_lock);
-	if (state == true) {
-		if (port_id == AFE_PORT_INVALID) {
-			pr_err("%s: Invalid port id", __func__);
-			ret = -EINVAL;
-			goto exit;
-		}
-		common.ec_ref_ext = true;
-	} else {
-		common.ec_ref_ext = false;
-	}
-	/* Cache EC Fromat Info in common */
-	common.ec_media_fmt_info.port_id = port_id;
-exit:
-	mutex_unlock(&common.common_lock);
-	return ret;
-}
-
-int voc_get_ext_ec_ref_port_id(void)
-{
-	if (common.ec_ref_ext)
-		return common.ec_media_fmt_info.port_id;
-	else
-		return AFE_PORT_INVALID;
-}
-
-void voc_register_mvs_cb(ul_cb_fn ul_cb,
-			   dl_cb_fn dl_cb,
-			   voip_ssr_cb ssr_cb,
-			   void *private_data)
-{
-	common.mvs_info.ul_cb = ul_cb;
-	common.mvs_info.dl_cb = dl_cb;
-	common.mvs_info.ssr_cb = ssr_cb;
-	common.mvs_info.private_data = private_data;
-}
-
-void voc_register_dtmf_rx_detection_cb(dtmf_rx_det_cb_fn dtmf_rx_ul_cb,
-				       void *private_data)
-{
-	common.dtmf_info.dtmf_rx_ul_cb = dtmf_rx_ul_cb;
-	common.dtmf_info.private_data = private_data;
-}
-
-void voc_config_vocoder(uint32_t media_type,
-			uint32_t rate,
-			uint32_t network_type,
-			uint32_t dtx_mode,
-			uint32_t evrc_min_rate,
-			uint32_t evrc_max_rate)
-{
-	common.mvs_info.media_type = media_type;
-	common.mvs_info.rate = rate;
-	common.mvs_info.network_type = network_type;
-	common.mvs_info.dtx_mode = dtx_mode;
-	common.mvs_info.evrc_min_rate = evrc_min_rate;
-	common.mvs_info.evrc_max_rate = evrc_max_rate;
-}
-
-static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv)
-{
-	uint32_t *ptr = NULL;
-	struct common_data *c = NULL;
-	struct voice_data *v = NULL;
-	int i = 0;
-	struct vss_iversion_rsp_get_t *version_rsp = NULL;
-
-	if ((data == NULL) || (priv == NULL)) {
-		pr_err("%s: data or priv is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	c = priv;
-
-	pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__,
-		data->payload_size, data->opcode);
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: Reset event received in Voice service\n",
-				__func__);
-
-		if (common.mvs_info.ssr_cb) {
-			pr_debug("%s: Informing reset event to VoIP\n",
-					__func__);
-			common.mvs_info.ssr_cb(data->opcode,
-					common.mvs_info.private_data);
-		}
-
-		apr_reset(c->apr_q6_mvm);
-		c->apr_q6_mvm = NULL;
-
-		/* clean up memory handle */
-		c->cal_mem_handle = 0;
-		c->rtac_mem_handle = 0;
-		cal_utils_clear_cal_block_q6maps(MAX_VOICE_CAL_TYPES,
-				common.cal_data);
-		rtac_clear_mapping(VOICE_RTAC_CAL);
-
-		/* Sub-system restart is applicable to all sessions. */
-		for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-			c->voice[i].mvm_handle = 0;
-			c->voice[i].shmem_info.mem_handle = 0;
-		}
-
-		/* Free the ION memory and clear handles for Source Tracking */
-		if (is_source_tracking_shared_memomry_allocated()) {
-			msm_audio_ion_free(
-			common.source_tracking_sh_mem.sh_mem_block.client,
-			common.source_tracking_sh_mem.sh_mem_block.handle);
-			common.source_tracking_sh_mem.mem_handle = 0;
-			common.source_tracking_sh_mem.sh_mem_block.client =
-									NULL;
-			common.source_tracking_sh_mem.sh_mem_block.handle =
-									NULL;
-		}
-		/* clean up srvcc rec flag */
-		c->srvcc_rec_flag = false;
-		voc_set_error_state(data->reset_proc);
-		return 0;
-	}
-
-	pr_debug("%s: session_idx 0x%x\n", __func__, data->dest_port);
-
-	v = voice_get_session_by_idx(data->dest_port);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		return -EINVAL;
-	}
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		if (data->payload_size) {
-			ptr = data->payload;
-
-			pr_debug("%x %x\n", ptr[0], ptr[1]);
-			/* ping mvm service ACK */
-			switch (ptr[0]) {
-			case VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION:
-			case VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION:
-				/* Passive session is used for CS call
-				 * Full session is used for VoIP call.
-				 */
-				pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]);
-				if (!ptr[1]) {
-					pr_debug("%s: MVM handle is %d\n",
-						 __func__, data->src_port);
-					voice_set_mvm_handle(v, data->src_port);
-				} else
-					pr_err("got NACK for sending MVM create session\n");
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->mvm_wait);
-				break;
-			case VSS_IMVM_CMD_START_VOICE:
-			case VSS_IMVM_CMD_ATTACH_VOCPROC:
-			case VSS_IMVM_CMD_STOP_VOICE:
-			case VSS_IMVM_CMD_DETACH_VOCPROC:
-			case VSS_ISTREAM_CMD_SET_TTY_MODE:
-			case APRV2_IBASIC_CMD_DESTROY_SESSION:
-			case VSS_IMVM_CMD_ATTACH_STREAM:
-			case VSS_IMVM_CMD_DETACH_STREAM:
-			case VSS_ICOMMON_CMD_SET_NETWORK:
-			case VSS_ICOMMON_CMD_SET_VOICE_TIMING:
-			case VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL:
-			case VSS_IMVM_CMD_SET_CAL_NETWORK:
-			case VSS_IMVM_CMD_SET_CAL_MEDIA_TYPE:
-			case VSS_IMEMORY_CMD_MAP_PHYSICAL:
-			case VSS_IMEMORY_CMD_UNMAP:
-			case VSS_IMVM_CMD_PAUSE_VOICE:
-			case VSS_IMVM_CMD_STANDBY_VOICE:
-			case VSS_IHDVOICE_CMD_ENABLE:
-			case VSS_IHDVOICE_CMD_DISABLE:
-				pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]);
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->mvm_wait);
-				break;
-			case VSS_IVERSION_CMD_GET:
-				pr_debug("%s: Error retrieving CVD Version, error:%d\n",
-					 __func__, ptr[1]);
-
-				strlcpy(common.cvd_version, CVD_VERSION_0_0,
-					sizeof(common.cvd_version));
-				pr_debug("%s: Fall back to default value, CVD Version = %s\n",
-					 __func__, common.cvd_version);
-
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->mvm_wait);
-				break;
-			default:
-				pr_debug("%s: not match cmd = 0x%x\n",
-					__func__, ptr[0]);
-				break;
-			}
-		}
-	} else if (data->opcode == VSS_IMEMORY_RSP_MAP) {
-		pr_debug("%s, Revd VSS_IMEMORY_RSP_MAP response\n", __func__);
-
-		if (data->payload_size && data->token == VOIP_MEM_MAP_TOKEN) {
-			ptr = data->payload;
-			if (ptr[0]) {
-				v->shmem_info.mem_handle = ptr[0];
-				pr_debug("%s: shared mem_handle: 0x[%x]\n",
-					 __func__, v->shmem_info.mem_handle);
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				wake_up(&v->mvm_wait);
-			}
-		} else if (data->payload_size &&
-			   data->token == VOC_CAL_MEM_MAP_TOKEN) {
-			ptr = data->payload;
-			if (ptr[0]) {
-				c->cal_mem_handle = ptr[0];
-
-				pr_debug("%s: cal mem handle 0x%x\n",
-					 __func__, c->cal_mem_handle);
-
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				wake_up(&v->mvm_wait);
-			}
-		} else if (data->payload_size &&
-			   data->token == VOC_VOICE_HOST_PCM_MAP_TOKEN) {
-			ptr = data->payload;
-			if (ptr[0]) {
-				common.voice_host_pcm_mem_handle = ptr[0];
-
-				pr_debug("%s: vhpcm mem handle 0x%x\n",
-					 __func__,
-					 common.voice_host_pcm_mem_handle);
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				wake_up(&v->mvm_wait);
-			}
-		} else if (data->payload_size &&
-				data->token == VOC_RTAC_MEM_MAP_TOKEN) {
-			ptr = data->payload;
-			if (ptr[0]) {
-				c->rtac_mem_handle = ptr[0];
-
-				pr_debug("%s: cal mem handle 0x%x\n",
-					 __func__, c->rtac_mem_handle);
-
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				wake_up(&v->mvm_wait);
-			}
-		} else if (data->payload_size &&
-			   data->token == VOC_SOURCE_TRACKING_MEM_MAP_TOKEN) {
-			ptr = data->payload;
-			if (ptr[0]) {
-				common.source_tracking_sh_mem.mem_handle =
-									ptr[0];
-
-				pr_debug("%s: Source Tracking shared mem handle 0x%x\n",
-					 __func__,
-				   common.source_tracking_sh_mem.mem_handle);
-
-				v->mvm_state = CMD_STATUS_SUCCESS;
-				wake_up(&v->mvm_wait);
-			}
-		} else {
-			pr_err("%s: Unknown mem map token %d\n",
-			       __func__, data->token);
-		}
-	} else if (data->opcode == VSS_IVERSION_RSP_GET) {
-		pr_debug("%s: Received VSS_IVERSION_RSP_GET\n", __func__);
-
-		if (data->payload_size) {
-			version_rsp =
-				(struct vss_iversion_rsp_get_t *)data->payload;
-			memcpy(common.cvd_version, version_rsp->version,
-			       CVD_VERSION_STRING_MAX_SIZE);
-			pr_debug("%s: CVD Version = %s\n",
-				 __func__, common.cvd_version);
-
-			v->mvm_state = CMD_STATUS_SUCCESS;
-			wake_up(&v->mvm_wait);
-		}
-	}
-	return 0;
-}
-
-static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv)
-{
-	uint32_t *ptr = NULL;
-	struct common_data *c = NULL;
-	struct voice_data *v = NULL;
-	int i = 0;
-
-	if ((data == NULL) || (priv == NULL)) {
-		pr_err("%s: data or priv is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	c = priv;
-
-	pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port);
-	pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__,
-		data->payload_size, data->opcode);
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: Reset event received in Voice service\n",
-				__func__);
-
-		apr_reset(c->apr_q6_cvs);
-		c->apr_q6_cvs = NULL;
-
-		/* Sub-system restart is applicable to all sessions. */
-		for (i = 0; i < MAX_VOC_SESSIONS; i++)
-			c->voice[i].cvs_handle = 0;
-
-		cal_utils_clear_cal_block_q6maps(MAX_VOICE_CAL_TYPES,
-				common.cal_data);
-
-		/* Free the ION memory and clear handles for Source Tracking */
-		if (is_source_tracking_shared_memomry_allocated()) {
-			msm_audio_ion_free(
-			common.source_tracking_sh_mem.sh_mem_block.client,
-			common.source_tracking_sh_mem.sh_mem_block.handle);
-			common.source_tracking_sh_mem.mem_handle = 0;
-			common.source_tracking_sh_mem.sh_mem_block.client =
-									NULL;
-			common.source_tracking_sh_mem.sh_mem_block.handle =
-									NULL;
-		}
-		voc_set_error_state(data->reset_proc);
-		return 0;
-	}
-
-	v = voice_get_session_by_idx(data->dest_port);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		return -EINVAL;
-	}
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		if (data->payload_size) {
-			ptr = data->payload;
-
-			pr_debug("%x %x\n", ptr[0], ptr[1]);
-			if (ptr[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					__func__, ptr[0], ptr[1]);
-			}
-			/*response from  CVS */
-			switch (ptr[0]) {
-			case VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION:
-			case VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION:
-				if (!ptr[1]) {
-					pr_debug("%s: CVS handle is %d\n",
-						 __func__, data->src_port);
-					voice_set_cvs_handle(v, data->src_port);
-				} else
-					pr_err("got NACK for sending CVS create session\n");
-				v->cvs_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvs_wait);
-				break;
-			case VSS_IVOLUME_CMD_MUTE_V2:
-			case VSS_ISTREAM_CMD_SET_MEDIA_TYPE:
-			case VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE:
-			case VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE:
-			case VSS_ISTREAM_CMD_SET_ENC_DTX_MODE:
-			case VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE:
-			case APRV2_IBASIC_CMD_DESTROY_SESSION:
-			case VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA_V2:
-			case VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA:
-			case VSS_ISTREAM_CMD_REGISTER_STATIC_CALIBRATION_DATA:
-			case VSS_ISTREAM_CMD_DEREGISTER_STATIC_CALIBRATION_DATA:
-			case VSS_ICOMMON_CMD_MAP_MEMORY:
-			case VSS_ICOMMON_CMD_UNMAP_MEMORY:
-			case VSS_ICOMMON_CMD_SET_UI_PROPERTY:
-			case VSS_IPLAYBACK_CMD_START:
-			case VSS_IPLAYBACK_CMD_STOP:
-			case VSS_IRECORD_CMD_START:
-			case VSS_IRECORD_CMD_STOP:
-			case VSS_ISTREAM_CMD_SET_PACKET_EXCHANGE_MODE:
-			case VSS_ISTREAM_CMD_SET_OOB_PACKET_EXCHANGE_CONFIG:
-			case VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION:
-				pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]);
-				v->cvs_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvs_wait);
-				break;
-			case VSS_ICOMMON_CMD_SET_PARAM_V2:
-				pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2\n",
-					 __func__);
-				rtac_make_voice_callback(RTAC_CVS, ptr,
-							data->payload_size);
-				break;
-			case VSS_ICOMMON_CMD_GET_PARAM_V2:
-				pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
-					 __func__);
-				/* Should only come here if there is an APR */
-				/* error or malformed APR packet. Otherwise */
-				/* response will be returned as */
-				/* VSS_ICOMMON_RSP_GET_PARAM */
-				if (ptr[1] != 0) {
-					pr_err("%s: CVP get param error = %d, resuming\n",
-						__func__, ptr[1]);
-					rtac_make_voice_callback(RTAC_CVP,
-						data->payload,
-						data->payload_size);
-				}
-				break;
-			default:
-				pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]);
-				break;
-			}
-		}
-	} else if (data->opcode ==
-			 VSS_ISTREAM_EVT_OOB_NOTIFY_ENC_BUFFER_READY) {
-		int ret = 0;
-		u16 cvs_handle;
-		uint32_t *cvs_voc_pkt;
-		struct cvs_enc_buffer_consumed_cmd send_enc_buf_consumed_cmd;
-		void *apr_cvs;
-
-		pr_debug("Encoder buffer is ready\n");
-
-		apr_cvs = common.apr_q6_cvs;
-		if (!apr_cvs) {
-			pr_err("%s: apr_cvs is NULL\n", __func__);
-			return -EINVAL;
-		}
-		cvs_handle = voice_get_cvs_handle(v);
-
-		send_enc_buf_consumed_cmd.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE),
-				APR_PKT_VER);
-		send_enc_buf_consumed_cmd.hdr.pkt_size =
-			APR_PKT_SIZE(APR_HDR_SIZE,
-			sizeof(send_enc_buf_consumed_cmd) - APR_HDR_SIZE);
-
-		send_enc_buf_consumed_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		send_enc_buf_consumed_cmd.hdr.dest_port = cvs_handle;
-		send_enc_buf_consumed_cmd.hdr.token = 0;
-		send_enc_buf_consumed_cmd.hdr.opcode =
-			VSS_ISTREAM_EVT_OOB_NOTIFY_ENC_BUFFER_CONSUMED;
-
-		cvs_voc_pkt = v->shmem_info.sh_buf.buf[1].data;
-		if (cvs_voc_pkt != NULL &&  common.mvs_info.ul_cb != NULL) {
-			/* cvs_voc_pkt[0] contains tx timestamp */
-			common.mvs_info.ul_cb((uint8_t *)&cvs_voc_pkt[3],
-					      cvs_voc_pkt[2],
-					      cvs_voc_pkt[0],
-					      common.mvs_info.private_data);
-		} else
-			pr_err("%s: cvs_voc_pkt or ul_cb is NULL\n", __func__);
-
-		ret = apr_send_pkt(apr_cvs,
-			(uint32_t *) &send_enc_buf_consumed_cmd);
-		if (ret < 0) {
-			pr_err("%s: Err send ENC_BUF_CONSUMED_NOTIFY %d\n",
-				__func__, ret);
-			goto fail;
-		}
-	} else if (data->opcode == VSS_ISTREAM_EVT_SEND_ENC_BUFFER) {
-		pr_debug("Recd VSS_ISTREAM_EVT_SEND_ENC_BUFFER\n");
-	} else if (data->opcode ==
-			 VSS_ISTREAM_EVT_OOB_NOTIFY_DEC_BUFFER_REQUEST) {
-		int ret = 0;
-		u16 cvs_handle;
-		uint32_t *cvs_voc_pkt;
-		struct cvs_dec_buffer_ready_cmd send_dec_buf;
-		void *apr_cvs;
-
-		apr_cvs = common.apr_q6_cvs;
-
-		if (!apr_cvs) {
-			pr_err("%s: apr_cvs is NULL\n", __func__);
-			return -EINVAL;
-		}
-		cvs_handle = voice_get_cvs_handle(v);
-
-		send_dec_buf.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE),
-				APR_PKT_VER);
-
-		send_dec_buf.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					sizeof(send_dec_buf) - APR_HDR_SIZE);
-
-		send_dec_buf.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-		send_dec_buf.hdr.dest_port = cvs_handle;
-		send_dec_buf.hdr.token = 0;
-		send_dec_buf.hdr.opcode =
-				 VSS_ISTREAM_EVT_OOB_NOTIFY_DEC_BUFFER_READY;
-
-		cvs_voc_pkt = (uint32_t *)(v->shmem_info.sh_buf.buf[0].data);
-		if (cvs_voc_pkt != NULL && common.mvs_info.dl_cb != NULL) {
-			/* Set timestamp to 0 and advance the pointer */
-			cvs_voc_pkt[0] = 0;
-			/* Set media_type and advance the pointer */
-			cvs_voc_pkt[1] = common.mvs_info.media_type;
-			common.mvs_info.dl_cb(
-					      (uint8_t *)&cvs_voc_pkt[2],
-					      common.mvs_info.private_data);
-			ret = apr_send_pkt(apr_cvs, (uint32_t *) &send_dec_buf);
-			if (ret < 0) {
-				pr_err("%s: Err send DEC_BUF_READY_NOTIFI %d\n",
-					__func__, ret);
-				goto fail;
-			}
-		} else {
-			pr_debug("%s: voc_pkt or dl_cb is NULL\n", __func__);
-			goto fail;
-		}
-	} else if (data->opcode == VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER) {
-		pr_debug("Recd VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER\n");
-	} else if (data->opcode == VSS_ISTREAM_EVT_SEND_DEC_BUFFER) {
-		pr_debug("Send dec buf resp\n");
-	} else if (data->opcode == APR_RSP_ACCEPTED) {
-		ptr = data->payload;
-		if (ptr[0])
-			pr_debug("%s: APR_RSP_ACCEPTED for 0x%x:\n",
-				 __func__, ptr[0]);
-	} else if (data->opcode == VSS_ISTREAM_EVT_NOT_READY) {
-		pr_debug("Recd VSS_ISTREAM_EVT_NOT_READY\n");
-	} else if (data->opcode == VSS_ISTREAM_EVT_READY) {
-		pr_debug("Recd VSS_ISTREAM_EVT_READY\n");
-	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
-		pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
-		ptr = data->payload;
-		if (ptr[0] != 0) {
-			pr_err("%s: VSS_ICOMMON_RSP_GET_PARAM returned error = 0x%x\n",
-			       __func__, ptr[0]);
-		}
-		rtac_make_voice_callback(RTAC_CVS, data->payload,
-					data->payload_size);
-	}  else if (data->opcode == VSS_ISTREAM_EVT_RX_DTMF_DETECTED) {
-		struct vss_istream_evt_rx_dtmf_detected *dtmf_rx_detected;
-		uint32_t *voc_pkt = data->payload;
-		uint32_t pkt_len = data->payload_size;
-
-		if ((voc_pkt != NULL) &&
-		    (pkt_len ==
-			sizeof(struct vss_istream_evt_rx_dtmf_detected))) {
-
-			dtmf_rx_detected =
-			(struct vss_istream_evt_rx_dtmf_detected *) voc_pkt;
-			pr_debug("RX_DTMF_DETECTED low_freq=%d high_freq=%d\n",
-				 dtmf_rx_detected->low_freq,
-				 dtmf_rx_detected->high_freq);
-			if (c->dtmf_info.dtmf_rx_ul_cb)
-				c->dtmf_info.dtmf_rx_ul_cb((uint8_t *)voc_pkt,
-					voc_get_session_name(v->session_id),
-					c->dtmf_info.private_data);
-		} else {
-			pr_err("Invalid packet\n");
-		}
-	}  else
-		pr_debug("Unknown opcode 0x%x\n", data->opcode);
-
-fail:
-	return 0;
-}
-
-static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv)
-{
-	uint32_t *ptr = NULL;
-	struct common_data *c = NULL;
-	struct voice_data *v = NULL;
-	int i = 0;
-
-	if ((data == NULL) || (priv == NULL)) {
-		pr_err("%s: data or priv is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	c = priv;
-
-	if (data->opcode == RESET_EVENTS) {
-		pr_debug("%s: Reset event received in Voice service\n",
-				__func__);
-
-		apr_reset(c->apr_q6_cvp);
-		c->apr_q6_cvp = NULL;
-		cal_utils_clear_cal_block_q6maps(MAX_VOICE_CAL_TYPES,
-				common.cal_data);
-
-		/* Sub-system restart is applicable to all sessions. */
-		for (i = 0; i < MAX_VOC_SESSIONS; i++)
-			c->voice[i].cvp_handle = 0;
-
-		/*
-		 * Free the ION memory and clear handles for
-		 * Source Tracking
-		 */
-		if (is_source_tracking_shared_memomry_allocated()) {
-			msm_audio_ion_free(
-			common.source_tracking_sh_mem.sh_mem_block.client,
-			common.source_tracking_sh_mem.sh_mem_block.handle);
-			common.source_tracking_sh_mem.mem_handle = 0;
-			common.source_tracking_sh_mem.sh_mem_block.client =
-									NULL;
-			common.source_tracking_sh_mem.sh_mem_block.handle =
-									NULL;
-		}
-		voc_set_error_state(data->reset_proc);
-		return 0;
-	}
-
-	v = voice_get_session_by_idx(data->dest_port);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		return -EINVAL;
-	}
-
-	if (data->opcode == APR_BASIC_RSP_RESULT) {
-		if (data->payload_size) {
-			ptr = data->payload;
-
-			pr_debug("%x %x\n", ptr[0], ptr[1]);
-			if (ptr[1] != 0) {
-				pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
-					__func__, ptr[0], ptr[1]);
-			}
-			switch (ptr[0]) {
-			case VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V2:
-			case VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V3:
-			/*response from  CVP */
-				pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]);
-				if (!ptr[1]) {
-					voice_set_cvp_handle(v, data->src_port);
-					pr_debug("status: %d, cvphdl=%d\n",
-						 ptr[1], data->src_port);
-				} else
-					pr_err("got NACK from CVP create session response\n");
-				v->cvp_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvp_wait);
-				break;
-			case VSS_IVOCPROC_CMD_SET_DEVICE_V2:
-			case VSS_IVOCPROC_CMD_SET_DEVICE_V3:
-			case VSS_IVOLUME_CMD_SET_STEP:
-			case VSS_IVOCPROC_CMD_ENABLE:
-			case VSS_IVOCPROC_CMD_DISABLE:
-			case APRV2_IBASIC_CMD_DESTROY_SESSION:
-			case VSS_IVOCPROC_CMD_REGISTER_VOL_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_DEREGISTER_VOL_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA_V2:
-			case VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_REGISTER_DYNAMIC_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_DEREGISTER_DYNAMIC_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_REGISTER_STATIC_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_DEREGISTER_STATIC_CALIBRATION_DATA:
-			case VSS_IVOCPROC_CMD_REGISTER_DEVICE_CONFIG:
-			case VSS_IVOCPROC_CMD_DEREGISTER_DEVICE_CONFIG:
-			case VSS_ICOMMON_CMD_MAP_MEMORY:
-			case VSS_ICOMMON_CMD_UNMAP_MEMORY:
-			case VSS_IVOLUME_CMD_MUTE_V2:
-			case VSS_IVPCM_CMD_START_V2:
-			case VSS_IVPCM_CMD_STOP:
-			case VSS_IVOCPROC_CMD_TOPOLOGY_SET_DEV_CHANNELS:
-			case VSS_IVOCPROC_CMD_TOPOLOGY_COMMIT:
-				v->cvp_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvp_wait);
-				break;
-			case VSS_IVPCM_EVT_PUSH_BUFFER_V2:
-				break;
-			case VSS_ICOMMON_CMD_SET_PARAM_V2:
-				switch (data->token) {
-				case VOC_SET_MEDIA_FORMAT_PARAM_TOKEN:
-				case VOC_GENERIC_SET_PARAM_TOKEN:
-					pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2 called\n",
-						__func__);
-					v->cvp_state = CMD_STATUS_SUCCESS;
-					v->async_err = ptr[1];
-					wake_up(&v->cvp_wait);
-					break;
-				case VOC_RTAC_SET_PARAM_TOKEN:
-					pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2 called by rtac\n",
-						__func__);
-					rtac_make_voice_callback(
-						RTAC_CVP, ptr,
-						data->payload_size);
-					break;
-				default:
-					pr_debug("%s: invalid token for command VSS_ICOMMON_CMD_SET_PARAM_V2: %d\n",
-						__func__, data->token);
-					break;
-				}
-				break;
-			case VSS_ICOMMON_CMD_GET_PARAM_V2:
-				pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
-					 __func__);
-				/* Should only come here if there is an APR */
-				/* error or malformed APR packet. Otherwise */
-				/* response will be returned as */
-				/* VSS_ICOMMON_RSP_GET_PARAM */
-				if (ptr[1] != 0) {
-					pr_err("%s: CVP get param error = %d, resuming\n",
-						__func__, ptr[1]);
-					rtac_make_voice_callback(RTAC_CVP,
-						data->payload,
-						data->payload_size);
-				}
-				break;
-			case VSS_ISOUNDFOCUS_CMD_SET_SECTORS:
-				if (!ptr[1])
-					common.is_sound_focus_resp_success =
-									true;
-				else
-					common.is_sound_focus_resp_success =
-									false;
-				v->cvp_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvp_wait);
-				break;
-			case VSS_ISOUNDFOCUS_CMD_GET_SECTORS:
-				/*
-				 * Should only come here if there is an error
-				 * response received from ADSP. Otherwise
-				 * response will be returned as
-				 * VSS_ISOUNDFOCUS_RSP_GET_SECTORS
-				 */
-				pr_err("%s: VSS_ISOUNDFOCUS_CMD_GET_SECTORS failed\n",
-					__func__);
-
-				common.is_sound_focus_resp_success = false;
-				v->cvp_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvp_wait);
-				break;
-			case VSS_ISOURCETRACK_CMD_GET_ACTIVITY:
-				if (!ptr[1]) {
-					/* Read data from shared memory */
-					memcpy(&common.sourceTrackingResponse,
-					       common.source_tracking_sh_mem.
-							sh_mem_block.data,
-					       sizeof(struct
-					 vss_isourcetrack_activity_data_t));
-					common.is_source_tracking_resp_success =
-									true;
-				} else {
-					common.is_source_tracking_resp_success =
-									false;
-					pr_err("%s: Error received for source tracking params\n",
-						__func__);
-				}
-				v->cvp_state = CMD_STATUS_SUCCESS;
-				v->async_err = ptr[1];
-				wake_up(&v->cvp_wait);
-				break;
-			default:
-				pr_debug("%s: not match cmd = 0x%x\n",
-					  __func__, ptr[0]);
-				break;
-			}
-		}
-	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
-		pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
-		ptr = data->payload;
-		if (ptr[0] != 0) {
-			pr_err("%s: VSS_ICOMMON_RSP_GET_PARAM returned error = 0x%x\n",
-			       __func__, ptr[0]);
-		}
-		rtac_make_voice_callback(RTAC_CVP, data->payload,
-			data->payload_size);
-	} else if (data->opcode == VSS_IVPCM_EVT_NOTIFY_V2) {
-		if ((data->payload != NULL) && data->payload_size ==
-		    sizeof(struct vss_ivpcm_evt_notify_v2_t) &&
-		    common.hostpcm_info.hostpcm_evt_cb != NULL) {
-			common.hostpcm_info.hostpcm_evt_cb(data->payload,
-					voc_get_session_name(v->session_id),
-					common.hostpcm_info.private_data);
-		}
-	} else if (data->opcode == VSS_ISOUNDFOCUS_RSP_GET_SECTORS) {
-		if (data->payload && (data->payload_size ==
-			sizeof(struct vss_isoundfocus_rsp_get_sectors_t))) {
-			common.is_sound_focus_resp_success = true;
-			memcpy(&common.soundFocusResponse,
-			       (struct vss_isoundfocus_rsp_get_sectors_t *)
-			       data->payload,
-			       sizeof(struct
-					 vss_isoundfocus_rsp_get_sectors_t));
-		} else {
-			common.is_sound_focus_resp_success = false;
-			pr_debug("%s: Invalid payload received from CVD\n",
-				 __func__);
-		}
-		v->cvp_state = CMD_STATUS_SUCCESS;
-		wake_up(&v->cvp_wait);
-	}
-	return 0;
-}
-
-static int voice_free_oob_shared_mem(void)
-{
-	int rc = 0;
-	int cnt = 0;
-	int bufcnt = NUM_OF_BUFFERS;
-	struct voice_data *v = voice_get_session(
-				common.voice[VOC_PATH_FULL].session_id);
-
-	mutex_lock(&common.common_lock);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		rc = -EINVAL;
-		goto done;
-	}
-
-	rc = msm_audio_ion_free(v->shmem_info.sh_buf.client,
-				v->shmem_info.sh_buf.handle);
-	v->shmem_info.sh_buf.client = NULL;
-	v->shmem_info.sh_buf.handle = NULL;
-	if (rc < 0) {
-		pr_err("%s: Error:%d freeing memory\n", __func__, rc);
-
-		goto done;
-	}
-
-
-	while (cnt < bufcnt) {
-		v->shmem_info.sh_buf.buf[cnt].data =  NULL;
-		v->shmem_info.sh_buf.buf[cnt].phys =  0;
-		cnt++;
-	}
-
-	v->shmem_info.sh_buf.client = NULL;
-	v->shmem_info.sh_buf.handle = NULL;
-
-done:
-	mutex_unlock(&common.common_lock);
-	return rc;
-}
-
-static int voice_alloc_oob_shared_mem(void)
-{
-	int cnt = 0;
-	int rc = 0;
-	size_t len;
-	void *mem_addr;
-	dma_addr_t phys;
-	int bufsz = BUFFER_BLOCK_SIZE;
-	int bufcnt = NUM_OF_BUFFERS;
-	struct voice_data *v = voice_get_session(
-				common.voice[VOC_PATH_FULL].session_id);
-
-	mutex_lock(&common.common_lock);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		rc = -EINVAL;
-		goto done;
-	}
-
-	rc = msm_audio_ion_alloc("voip_client", &(v->shmem_info.sh_buf.client),
-			&(v->shmem_info.sh_buf.handle),
-			bufsz*bufcnt,
-			&phys, &len,
-			&mem_addr);
-	if (rc < 0) {
-		pr_err("%s: audio ION alloc failed, rc = %d\n",
-			__func__, rc);
-
-		goto done;
-	}
-
-	while (cnt < bufcnt) {
-		v->shmem_info.sh_buf.buf[cnt].data =  mem_addr  + (cnt * bufsz);
-		v->shmem_info.sh_buf.buf[cnt].phys =  phys + (cnt * bufsz);
-		v->shmem_info.sh_buf.buf[cnt].size = bufsz;
-		cnt++;
-	}
-
-	pr_debug("%s buf[0].data:[%pK], buf[0].phys:[%pK], &buf[0].phys:[%pK],\n",
-		 __func__,
-		(void *)v->shmem_info.sh_buf.buf[0].data,
-		&v->shmem_info.sh_buf.buf[0].phys,
-		(void *)&v->shmem_info.sh_buf.buf[0].phys);
-	pr_debug("%s: buf[1].data:[%pK], buf[1].phys[%pK], &buf[1].phys[%pK]\n",
-		__func__,
-		(void *)v->shmem_info.sh_buf.buf[1].data,
-		&v->shmem_info.sh_buf.buf[1].phys,
-		(void *)&v->shmem_info.sh_buf.buf[1].phys);
-
-	memset((void *)v->shmem_info.sh_buf.buf[0].data, 0, (bufsz * bufcnt));
-
-done:
-	mutex_unlock(&common.common_lock);
-	return rc;
-}
-
-static int voice_alloc_oob_mem_table(void)
-{
-	int rc = 0;
-	size_t len;
-	struct voice_data *v = voice_get_session(
-				common.voice[VOC_PATH_FULL].session_id);
-
-	mutex_lock(&common.common_lock);
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		rc = -EINVAL;
-		goto done;
-	}
-
-	rc = msm_audio_ion_alloc("voip_client", &(v->shmem_info.memtbl.client),
-				&(v->shmem_info.memtbl.handle),
-				sizeof(struct vss_imemory_table_t),
-				&v->shmem_info.memtbl.phys,
-				&len,
-				&(v->shmem_info.memtbl.data));
-	if (rc < 0) {
-		pr_err("%s: audio ION alloc failed, rc = %d\n",
-			__func__, rc);
-
-		goto done;
-	}
-
-	v->shmem_info.memtbl.size = sizeof(struct vss_imemory_table_t);
-	pr_debug("%s data[%pK]phys[%pK][%pK]\n", __func__,
-		 (void *)v->shmem_info.memtbl.data,
-		 &v->shmem_info.memtbl.phys,
-		 (void *)&v->shmem_info.memtbl.phys);
-
-done:
-	mutex_unlock(&common.common_lock);
-	return rc;
-}
-
-int voc_send_cvp_start_vocpcm(uint32_t session_id,
-			      struct vss_ivpcm_tap_point *vpcm_tp,
-			      uint32_t no_of_tp)
-{
-	struct cvp_start_cmd cvp_start_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct voice_data *v = voice_get_session(session_id);
-	int i = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* Fill the header */
-	cvp_start_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	cvp_start_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-		sizeof(struct vss_ivpcm_tap_point) * no_of_tp) +
-		sizeof(cvp_start_cmd.vpcm_start_cmd.num_tap_points) +
-		sizeof(cvp_start_cmd.vpcm_start_cmd.mem_handle);
-	cvp_start_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
-	cvp_start_cmd.hdr.dest_port = cvp_handle;
-	cvp_start_cmd.hdr.token = 0;
-	cvp_start_cmd.hdr.opcode = VSS_IVPCM_CMD_START_V2;
-
-	for (i = 0; i < no_of_tp; i++) {
-		cvp_start_cmd.vpcm_start_cmd.tap_points[i].tap_point =
-							vpcm_tp[i].tap_point;
-		cvp_start_cmd.vpcm_start_cmd.tap_points[i].direction =
-							vpcm_tp[i].direction;
-		cvp_start_cmd.vpcm_start_cmd.tap_points[i].sampling_rate =
-						    vpcm_tp[i].sampling_rate;
-		cvp_start_cmd.vpcm_start_cmd.tap_points[i].duration = 0;
-	}
-
-	cvp_start_cmd.vpcm_start_cmd.mem_handle =
-				common.voice_host_pcm_mem_handle;
-	cvp_start_cmd.vpcm_start_cmd.num_tap_points = no_of_tp;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_start_cmd);
-	if (ret < 0) {
-		pr_err("%s: Fail: sending vocpcm map memory,\n", __func__);
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-			(v->cvp_state == CMD_STATUS_SUCCESS),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto done;
-	}
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-int voc_send_cvp_stop_vocpcm(uint32_t session_id)
-{
-	struct cvp_command vpcm_stop_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct voice_data *v = voice_get_session(session_id);
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* fill in the header */
-	vpcm_stop_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				 APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	vpcm_stop_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-			 sizeof(vpcm_stop_cmd) - APR_HDR_SIZE);
-	vpcm_stop_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
-	vpcm_stop_cmd.hdr.dest_port = cvp_handle;
-	vpcm_stop_cmd.hdr.token = 0;
-	vpcm_stop_cmd.hdr.opcode = VSS_IVPCM_CMD_STOP;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &vpcm_stop_cmd);
-	if (ret < 0) {
-		pr_err("Fail: sending vocpcm stop,\n");
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-			(v->cvp_state == CMD_STATUS_SUCCESS),
-			msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-int voc_send_cvp_map_vocpcm_memory(uint32_t session_id,
-				   struct mem_map_table *tp_mem_table,
-				   phys_addr_t paddr, uint32_t bufsize)
-{
-	return  voice_map_memory_physical_cmd(voice_get_session(session_id),
-					      tp_mem_table,
-					      (dma_addr_t) paddr, bufsize,
-					      VOC_VOICE_HOST_PCM_MAP_TOKEN);
-}
-
-int voc_send_cvp_unmap_vocpcm_memory(uint32_t session_id)
-{
-	int ret = 0;
-
-	ret =  voice_send_mvm_unmap_memory_physical_cmd(
-				voice_get_session(session_id),
-				common.voice_host_pcm_mem_handle);
-
-	if (ret == 0)
-		common.voice_host_pcm_mem_handle = 0;
-
-	return ret;
-}
-
-int voc_send_cvp_vocpcm_push_buf_evt(uint32_t session_id,
-			struct vss_ivpcm_evt_push_buffer_v2_t *push_buff_evt)
-{
-	struct cvp_push_buf_cmd vpcm_push_buf_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	struct voice_data *v = voice_get_session(session_id);
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	memset(&vpcm_push_buf_cmd, 0, sizeof(vpcm_push_buf_cmd));
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* fill in the header */
-	vpcm_push_buf_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-				APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	vpcm_push_buf_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-				sizeof(vpcm_push_buf_cmd) - APR_HDR_SIZE);
-	vpcm_push_buf_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	vpcm_push_buf_cmd.hdr.dest_port = cvp_handle;
-	vpcm_push_buf_cmd.hdr.token = 0;
-	vpcm_push_buf_cmd.hdr.opcode = VSS_IVPCM_EVT_PUSH_BUFFER_V2;
-
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.tap_point =
-					push_buff_evt->tap_point;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.push_buf_mask =
-					push_buff_evt->push_buf_mask;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.out_buf_mem_address =
-					push_buff_evt->out_buf_mem_address;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.in_buf_mem_address =
-					push_buff_evt->in_buf_mem_address;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.out_buf_mem_size =
-					push_buff_evt->out_buf_mem_size;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.in_buf_mem_size =
-					push_buff_evt->in_buf_mem_size;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.sampling_rate =
-					push_buff_evt->sampling_rate;
-	vpcm_push_buf_cmd.vpcm_evt_push_buffer.num_in_channels =
-					push_buff_evt->num_in_channels;
-
-	ret = apr_send_pkt(apr_cvp, (uint32_t *) &vpcm_push_buf_cmd);
-	if (ret < 0) {
-		pr_err("Fail: sending vocpcm map memory,\n");
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-void voc_register_hpcm_evt_cb(hostpcm_cb_fn hostpcm_cb,
-			      void *private_data)
-{
-	common.hostpcm_info.hostpcm_evt_cb = hostpcm_cb;
-	common.hostpcm_info.private_data = private_data;
-}
-
-void voc_deregister_hpcm_evt_cb(void)
-{
-	common.hostpcm_info.hostpcm_evt_cb = NULL;
-	common.hostpcm_info.private_data = NULL;
-}
-
-int voc_get_cvd_version(char *cvd_version)
-{
-	int ret = 0;
-	struct voice_data *v = voice_get_session(VOICE_SESSION_VSID);
-
-
-	if (v == NULL) {
-		pr_err("%s: invalid session_id 0x%x\n",
-		       __func__, VOICE_SESSION_VSID);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (is_cvd_version_queried()) {
-		pr_debug("%s: Returning the cached value %s\n",
-			 __func__, common.cvd_version);
-
-		goto done;
-	}
-
-	/* Register callback to APR */
-	ret = voice_apr_register(VOICE_SESSION_VSID);
-	if (ret < 0) {
-		pr_err("%s: apr register failed\n", __func__);
-		goto done;
-	}
-
-	mutex_lock(&common.common_lock);
-	mutex_lock(&v->lock);
-	ret = voice_send_mvm_cvd_version_cmd(v);
-	if (ret < 0) {
-		pr_err("%s: voice_send_mvm_cvd_version_cmd failed\n", __func__);
-		goto unlock;
-	}
-	ret = 0;
-
-unlock:
-	mutex_unlock(&v->lock);
-	mutex_unlock(&common.common_lock);
-
-done:
-	if (cvd_version)
-		memcpy(cvd_version, common.cvd_version,
-		       CVD_VERSION_STRING_MAX_SIZE);
-
-	return ret;
-}
-
-static int voice_alloc_cal_mem_map_table(void)
-{
-	int ret = 0;
-	size_t len;
-
-	ret = msm_audio_ion_alloc("voc_cal",
-				&(common.cal_mem_map_table.client),
-				&(common.cal_mem_map_table.handle),
-				sizeof(struct vss_imemory_table_t),
-				&common.cal_mem_map_table.phys,
-				&len,
-				&(common.cal_mem_map_table.data));
-	if ((ret < 0) && (ret != -EPROBE_DEFER)) {
-		pr_err("%s: audio ION alloc failed, rc = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	common.cal_mem_map_table.size = sizeof(struct vss_imemory_table_t);
-	pr_debug("%s: data %pK phys %pK\n", __func__,
-		 common.cal_mem_map_table.data,
-		 &common.cal_mem_map_table.phys);
-
-done:
-	return ret;
-}
-
-static int voice_alloc_rtac_mem_map_table(void)
-{
-	int ret = 0;
-	size_t len;
-
-	ret = msm_audio_ion_alloc("voc_rtac_cal",
-			&(common.rtac_mem_map_table.client),
-			&(common.rtac_mem_map_table.handle),
-			sizeof(struct vss_imemory_table_t),
-			&common.rtac_mem_map_table.phys,
-			&len,
-			&(common.rtac_mem_map_table.data));
-	if (ret < 0) {
-		pr_err("%s: audio ION alloc failed, rc = %d\n",
-			__func__, ret);
-		goto done;
-	}
-
-	common.rtac_mem_map_table.size = sizeof(struct vss_imemory_table_t);
-	pr_debug("%s: data %pK phys %pK\n", __func__,
-		 common.rtac_mem_map_table.data,
-		 &common.rtac_mem_map_table.phys);
-
-done:
-	return ret;
-}
-
-static int voice_alloc_and_map_oob_mem(struct voice_data *v)
-{
-	int ret = 0;
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		return -EINVAL;
-	}
-
-	if (!is_voip_memory_allocated()) {
-		ret = voc_alloc_voip_shared_memory();
-		if (ret < 0) {
-			pr_err("%s: Failed to create voip oob memory %d\n",
-				   __func__, ret);
-
-			goto done;
-		}
-	}
-
-	ret = voice_map_memory_physical_cmd(v,
-			&v->shmem_info.memtbl,
-			v->shmem_info.sh_buf.buf[0].phys,
-			v->shmem_info.sh_buf.buf[0].size * NUM_OF_BUFFERS,
-			VOIP_MEM_MAP_TOKEN);
-	if (ret) {
-		pr_err("%s: mvm_map_memory_phy failed %d\n",
-			   __func__, ret);
-
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-uint32_t voice_get_topology(uint32_t topology_idx)
-{
-	uint32_t topology = VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT;
-	struct cal_block_data *cal_block = NULL;
-
-	/* initialize as default topology */
-	if (topology_idx == CVP_VOC_RX_TOPOLOGY_CAL) {
-		topology = VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT;
-	} else if (topology_idx == CVP_VOC_TX_TOPOLOGY_CAL) {
-		topology = VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS_V2;
-	} else {
-		pr_err("%s: cal index %x is invalid!\n",
-			__func__, topology_idx);
-
-		goto done;
-	}
-
-	if (common.cal_data[topology_idx] == NULL) {
-		pr_err("%s: cal type is NULL for cal index %x\n",
-			__func__, topology_idx);
-
-		goto done;
-	}
-
-	mutex_lock(&common.cal_data[topology_idx]->lock);
-	cal_block = cal_utils_get_only_cal_block(
-		common.cal_data[topology_idx]);
-	if (cal_block == NULL) {
-		pr_debug("%s: cal_block not found for cal index %x\n",
-			__func__, topology_idx);
-
-		goto unlock;
-	}
-
-	topology = ((struct audio_cal_info_voc_top *)
-		cal_block->cal_info)->topology;
-unlock:
-	mutex_unlock(&common.cal_data[topology_idx]->lock);
-done:
-	pr_debug("%s: Using topology %d\n", __func__, topology);
-
-	return topology;
-}
-
-static int get_cal_type_index(int32_t cal_type)
-{
-	int ret = -EINVAL;
-
-	switch (cal_type) {
-	case CVP_VOC_RX_TOPOLOGY_CAL_TYPE:
-		ret = CVP_VOC_RX_TOPOLOGY_CAL;
-		break;
-	case CVP_VOC_TX_TOPOLOGY_CAL_TYPE:
-		ret = CVP_VOC_TX_TOPOLOGY_CAL;
-		break;
-	case CVP_VOCPROC_STATIC_CAL_TYPE:
-		ret = CVP_VOCPROC_CAL;
-		break;
-	case CVP_VOCPROC_DYNAMIC_CAL_TYPE:
-		ret = CVP_VOCVOL_CAL;
-		break;
-	case CVS_VOCSTRM_STATIC_CAL_TYPE:
-		ret = CVS_VOCSTRM_CAL;
-		break;
-	case CVP_VOCDEV_CFG_CAL_TYPE:
-		ret = CVP_VOCDEV_CFG_CAL;
-		break;
-	case CVP_VOCPROC_STATIC_COL_CAL_TYPE:
-		ret = CVP_VOCPROC_COL_CAL;
-		break;
-	case CVP_VOCPROC_DYNAMIC_COL_CAL_TYPE:
-		ret = CVP_VOCVOL_COL_CAL;
-		break;
-	case CVS_VOCSTRM_STATIC_COL_CAL_TYPE:
-		ret = CVS_VOCSTRM_COL_CAL;
-		break;
-	case VOICE_RTAC_INFO_CAL_TYPE:
-		ret = VOICE_RTAC_INFO_CAL;
-		break;
-	case VOICE_RTAC_APR_CAL_TYPE:
-		ret = VOICE_RTAC_APR_CAL;
-		break;
-	default:
-		pr_err("%s: Invalid cal type %d!\n", __func__, cal_type);
-	}
-	return ret;
-}
-
-static int voice_prepare_volume_boost(int32_t cal_type,
-					size_t data_size, void *data)
-{
-	return voc_deregister_vocproc_vol_table();
-}
-
-static int voice_enable_volume_boost(int32_t cal_type,
-				size_t data_size, void *data)
-{
-	return voc_register_vocproc_vol_table();
-}
-
-static int voice_alloc_cal(int32_t cal_type,
-			   size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-	int cal_version;
-
-	pr_debug("%s\n", __func__);
-
-	cal_version = cal_utils_get_cal_type_version(data);
-	common.is_per_vocoder_cal_enabled =
-			!!(cal_version & PER_VOCODER_CAL_BIT_MASK);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: Could not get cal index %d!\n",
-			__func__, cal_index);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_alloc_cal(data_size, data,
-		common.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: Cal_utils_alloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int voice_dealloc_cal(int32_t cal_type,
-			     size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: Could not get cal index %d!\n",
-			__func__, cal_index);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_dealloc_cal(data_size, data,
-		common.cal_data[cal_index]);
-	if (ret < 0) {
-		pr_err("%s: Cal_utils_dealloc_block failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static int voice_set_cal(int32_t cal_type,
-			 size_t data_size, void *data)
-{
-	int ret = 0;
-	int cal_index;
-
-	pr_debug("%s\n", __func__);
-
-	cal_index = get_cal_type_index(cal_type);
-	if (cal_index < 0) {
-		pr_err("%s: Could not get cal index %d!\n",
-			__func__, cal_index);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = cal_utils_set_cal(data_size, data,
-		common.cal_data[cal_index], 0, NULL);
-	if (ret < 0) {
-		pr_err("%s: Cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
-			__func__, ret, cal_type);
-
-		ret = -EINVAL;
-		goto done;
-	}
-done:
-	return ret;
-}
-
-static void voice_delete_cal_data(void)
-{
-	pr_debug("%s\n", __func__);
-
-	cal_utils_destroy_cal_types(MAX_VOICE_CAL_TYPES, common.cal_data);
-}
-
-static int voice_init_cal_data(void)
-{
-	int ret = 0;
-	struct cal_type_info cal_type_info[] = {
-		{{CVP_VOC_RX_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL, voice_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{CVP_VOC_TX_TOPOLOGY_CAL_TYPE,
-		{NULL, NULL, NULL, voice_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{CVP_VOCPROC_STATIC_CAL_TYPE,
-		{voice_alloc_cal, voice_dealloc_cal, NULL,
-		voice_set_cal, NULL, NULL} },
-		{NULL, voice_unmap_cal_memory,
-		cal_utils_match_buf_num} },
-
-		{{CVP_VOCPROC_DYNAMIC_CAL_TYPE,
-		{voice_alloc_cal, voice_dealloc_cal,
-		voice_prepare_volume_boost,
-		voice_set_cal, NULL,
-		voice_enable_volume_boost} },
-		{NULL, voice_unmap_cal_memory,
-		cal_utils_match_buf_num} },
-
-		{{CVP_VOCDEV_CFG_CAL_TYPE,
-		{voice_alloc_cal, voice_dealloc_cal, NULL,
-		voice_set_cal, NULL, NULL} },
-		{NULL, voice_unmap_cal_memory,
-		cal_utils_match_buf_num} },
-
-		{{CVP_VOCPROC_STATIC_COL_CAL_TYPE,
-		{NULL, NULL, NULL, voice_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{CVP_VOCPROC_DYNAMIC_COL_CAL_TYPE,
-		{NULL, NULL, NULL, voice_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{CVS_VOCSTRM_STATIC_CAL_TYPE,
-		{voice_alloc_cal, voice_dealloc_cal, NULL,
-		voice_set_cal, NULL, NULL} },
-		{NULL, voice_unmap_cal_memory,
-		cal_utils_match_buf_num} },
-
-		{{CVS_VOCSTRM_STATIC_COL_CAL_TYPE,
-		{NULL, NULL, NULL, voice_set_cal, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{VOICE_RTAC_INFO_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-
-		{{VOICE_RTAC_APR_CAL_TYPE,
-		{NULL, NULL, NULL, NULL, NULL, NULL} },
-		{NULL, NULL, cal_utils_match_buf_num} },
-	};
-
-	ret = cal_utils_create_cal_types(MAX_VOICE_CAL_TYPES, common.cal_data,
-		cal_type_info);
-	if (ret < 0) {
-		pr_err("%s: Could not create cal type!\n",
-			__func__);
-
-		ret = -EINVAL;
-		goto err;
-	}
-
-	return ret;
-err:
-	voice_delete_cal_data();
-	memset(&common, 0, sizeof(struct common_data));
-	return ret;
-}
-
-static int voice_send_set_sound_focus_cmd(struct voice_data *v,
-				 struct sound_focus_param soundFocusData)
-{
-	struct cvp_set_sound_focus_param_cmd_t cvp_set_sound_focus_param_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	int i;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	if (v == NULL) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* send Sound Focus Params to cvp */
-	cvp_set_sound_focus_param_cmd.hdr.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					      APR_HDR_LEN(APR_HDR_SIZE),
-					      APR_PKT_VER);
-	cvp_set_sound_focus_param_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-			sizeof(cvp_set_sound_focus_param_cmd) - APR_HDR_SIZE);
-	cvp_set_sound_focus_param_cmd.hdr.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_set_sound_focus_param_cmd.hdr.dest_port = cvp_handle;
-	cvp_set_sound_focus_param_cmd.hdr.token = 0;
-	cvp_set_sound_focus_param_cmd.hdr.opcode =
-					 VSS_ISOUNDFOCUS_CMD_SET_SECTORS;
-
-	memset(&(cvp_set_sound_focus_param_cmd.cvp_set_sound_focus_param), 0xFF,
-		sizeof(struct vss_isoundfocus_cmd_set_sectors_t));
-	for (i = 0; i < MAX_SECTORS; i++) {
-		cvp_set_sound_focus_param_cmd.cvp_set_sound_focus_param.
-			start_angles[i] = soundFocusData.start_angle[i];
-		cvp_set_sound_focus_param_cmd.cvp_set_sound_focus_param.
-			enables[i] = soundFocusData.enable[i];
-		pr_debug("%s: start_angle[%d] = %d\n",
-			  __func__, i, soundFocusData.start_angle[i]);
-		pr_debug("%s: enable[%d] = %d\n",
-			  __func__, i, soundFocusData.enable[i]);
-	}
-	cvp_set_sound_focus_param_cmd.cvp_set_sound_focus_param.gain_step =
-					soundFocusData.gain_step;
-	pr_debug("%s: gain_step = %d\n", __func__, soundFocusData.gain_step);
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-
-	ret = apr_send_pkt(apr_cvp, (uint32_t *)&cvp_set_sound_focus_param_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error in sending APR command\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-	if (common.is_sound_focus_resp_success) {
-		ret = 0;
-	} else {
-		pr_err("%s: Error in setting sound focus params\n", __func__);
-
-		ret = -EINVAL;
-	}
-
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-int voc_set_sound_focus(struct sound_focus_param soundFocusData)
-{
-	struct voice_data *v = NULL;
-	int ret = -EINVAL;
-	struct voice_session_itr itr;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	mutex_lock(&common.common_lock);
-	voice_itr_init(&itr, ALL_SESSION_VSID);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			if (is_voc_state_active(v->voc_state) &&
-				(v->lch_mode != VOICE_LCH_START) &&
-				!v->disable_topology)
-				ret = voice_send_set_sound_focus_cmd(v,
-							soundFocusData);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session\n", __func__);
-
-			ret = -EINVAL;
-			break;
-		}
-	}
-	mutex_unlock(&common.common_lock);
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int voice_send_get_sound_focus_cmd(struct voice_data *v,
-				struct sound_focus_param *soundFocusData)
-{
-	struct apr_hdr cvp_get_sound_focus_param_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	int i;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	if (!v) {
-		pr_err("%s: v is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-
-	/* send APR command to retrieve Sound Focus Params */
-	cvp_get_sound_focus_param_cmd.hdr_field =
-				APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					      APR_HDR_LEN(APR_HDR_SIZE),
-					      APR_PKT_VER);
-	cvp_get_sound_focus_param_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-			sizeof(cvp_get_sound_focus_param_cmd) - APR_HDR_SIZE);
-	cvp_get_sound_focus_param_cmd.src_port =
-				voice_get_idx_for_session(v->session_id);
-	cvp_get_sound_focus_param_cmd.dest_port = cvp_handle;
-	cvp_get_sound_focus_param_cmd.token = 0;
-	cvp_get_sound_focus_param_cmd.opcode = VSS_ISOUNDFOCUS_CMD_GET_SECTORS;
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp, (uint32_t *)&cvp_get_sound_focus_param_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error in sending APR command\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-	if (common.is_sound_focus_resp_success) {
-		for (i = 0; i < MAX_SECTORS; i++) {
-			soundFocusData->start_angle[i] =
-				common.soundFocusResponse.start_angles[i];
-			soundFocusData->enable[i] =
-				common.soundFocusResponse.enables[i];
-			pr_debug("%s: start_angle[%d] = %d\n",
-				  __func__, i, soundFocusData->start_angle[i]);
-			pr_debug("%s: enable[%d] = %d\n",
-				  __func__, i, soundFocusData->enable[i]);
-		}
-		soundFocusData->gain_step = common.soundFocusResponse.gain_step;
-		pr_debug("%s: gain_step = %d\n", __func__,
-			  soundFocusData->gain_step);
-
-		common.is_sound_focus_resp_success = false;
-		ret = 0;
-	} else {
-		pr_err("%s: Invalid payload received from CVD\n", __func__);
-
-		ret = -EINVAL;
-	}
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-int voc_get_sound_focus(struct sound_focus_param *soundFocusData)
-{
-	struct voice_data *v = NULL;
-	int ret = -EINVAL;
-	struct voice_session_itr itr;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	mutex_lock(&common.common_lock);
-	voice_itr_init(&itr, ALL_SESSION_VSID);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v) {
-			mutex_lock(&v->lock);
-			if (is_voc_state_active(v->voc_state) &&
-				(v->lch_mode != VOICE_LCH_START) &&
-				!v->disable_topology)
-				ret = voice_send_get_sound_focus_cmd(v,
-							soundFocusData);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session\n", __func__);
-
-			ret =  -EINVAL;
-			break;
-		}
-	}
-	mutex_unlock(&common.common_lock);
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int is_source_tracking_shared_memomry_allocated(void)
-{
-	bool ret;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	if (common.source_tracking_sh_mem.sh_mem_block.client != NULL &&
-	    common.source_tracking_sh_mem.sh_mem_block.handle != NULL)
-		ret = true;
-	else
-		ret = false;
-
-	pr_debug("%s: Exit\n", __func__);
-
-	return ret;
-}
-
-static int voice_alloc_source_tracking_shared_memory(void)
-{
-	int ret = 0;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	ret = msm_audio_ion_alloc("source_tracking_sh_mem_block",
-		&(common.source_tracking_sh_mem.sh_mem_block.client),
-		&(common.source_tracking_sh_mem.sh_mem_block.handle),
-		BUFFER_BLOCK_SIZE,
-		&(common.source_tracking_sh_mem.sh_mem_block.phys),
-		(size_t *)&(common.source_tracking_sh_mem.sh_mem_block.size),
-		&(common.source_tracking_sh_mem.sh_mem_block.data));
-	if (ret < 0) {
-		pr_err("%s: audio ION alloc failed for sh_mem block, ret = %d\n",
-			__func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	memset((void *)(common.source_tracking_sh_mem.sh_mem_block.data), 0,
-		   common.source_tracking_sh_mem.sh_mem_block.size);
-
-	pr_debug("%s: sh_mem_block: phys:[%pK], data:[0x%pK], size:[%zd]\n",
-		 __func__,
-		&(common.source_tracking_sh_mem.sh_mem_block.phys),
-		(void *)(common.source_tracking_sh_mem.sh_mem_block.data),
-		(size_t)(common.source_tracking_sh_mem.sh_mem_block.size));
-
-	ret = msm_audio_ion_alloc("source_tracking_sh_mem_table",
-		&(common.source_tracking_sh_mem.sh_mem_table.client),
-		&(common.source_tracking_sh_mem.sh_mem_table.handle),
-		sizeof(struct vss_imemory_table_t),
-		&(common.source_tracking_sh_mem.sh_mem_table.phys),
-		(size_t *)&(common.source_tracking_sh_mem.sh_mem_table.size),
-		&(common.source_tracking_sh_mem.sh_mem_table.data));
-	if (ret < 0) {
-		pr_err("%s: audio ION alloc failed for sh_mem table, ret = %d\n",
-			__func__, ret);
-
-		ret = msm_audio_ion_free(
-			common.source_tracking_sh_mem.sh_mem_block.client,
-			common.source_tracking_sh_mem.sh_mem_block.handle);
-		common.source_tracking_sh_mem.sh_mem_block.client = NULL;
-		common.source_tracking_sh_mem.sh_mem_block.handle = NULL;
-		if (ret < 0)
-			pr_err("%s: Error:%d freeing memory\n", __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	memset((void *)(common.source_tracking_sh_mem.sh_mem_table.data), 0,
-		common.source_tracking_sh_mem.sh_mem_table.size);
-
-	pr_debug("%s sh_mem_table: phys:[%pK], data:[0x%pK], size:[%zd],\n",
-		 __func__,
-		&(common.source_tracking_sh_mem.sh_mem_table.phys),
-		(void *)(common.source_tracking_sh_mem.sh_mem_table.data),
-		(size_t)(common.source_tracking_sh_mem.sh_mem_table.size));
-
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int voice_alloc_and_map_source_tracking_shared_memory(
-						struct voice_data *v)
-{
-	int ret = 0;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	ret = voice_alloc_source_tracking_shared_memory();
-	if (ret) {
-		pr_err("%s: Failed to allocate shared memory %d\n",
-			__func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	ret = voice_map_memory_physical_cmd(v,
-			&(common.source_tracking_sh_mem.sh_mem_table),
-			common.source_tracking_sh_mem.sh_mem_block.phys,
-			common.source_tracking_sh_mem.sh_mem_block.size,
-			VOC_SOURCE_TRACKING_MEM_MAP_TOKEN);
-	if (ret) {
-		pr_err("%s: memory mapping failed %d\n",
-			__func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int voice_unmap_and_free_source_tracking_shared_memory(
-							struct voice_data *v)
-{
-	int ret = 0;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	if (common.source_tracking_sh_mem.mem_handle != 0) {
-		ret = voice_send_mvm_unmap_memory_physical_cmd(v,
-				common.source_tracking_sh_mem.mem_handle);
-		if (ret < 0) {
-			pr_err("%s: Memory_unmap failed err %d\n",
-				 __func__, ret);
-
-			ret = -EINVAL;
-			goto done;
-		}
-	}
-
-	if ((common.source_tracking_sh_mem.sh_mem_block.client == NULL) ||
-	    (common.source_tracking_sh_mem.sh_mem_block.handle == NULL))
-		goto done;
-
-	ret = msm_audio_ion_free(
-			common.source_tracking_sh_mem.sh_mem_block.client,
-			common.source_tracking_sh_mem.sh_mem_block.handle);
-	if (ret < 0) {
-		pr_err("%s: Error:%d freeing memory\n", __func__, ret);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-done:
-	common.source_tracking_sh_mem.mem_handle = 0;
-	common.source_tracking_sh_mem.sh_mem_block.client = NULL;
-	common.source_tracking_sh_mem.sh_mem_block.handle = NULL;
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static int voice_send_get_source_tracking_cmd(struct voice_data *v,
-			struct source_tracking_param *sourceTrackingData)
-{
-	struct cvp_get_source_tracking_param_cmd_t st_cmd;
-	int ret = 0;
-	void *apr_cvp;
-	u16 cvp_handle;
-	int i;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	if (!v) {
-		pr_err("%s: v is NULL\n", __func__);
-		return -EINVAL;
-	}
-	apr_cvp = common.apr_q6_cvp;
-
-	if (!apr_cvp) {
-		pr_err("%s: apr_cvp is NULL.\n", __func__);
-		return -EINVAL;
-	}
-
-	cvp_handle = voice_get_cvp_handle(v);
-
-	if (!is_source_tracking_shared_memomry_allocated()) {
-		ret = voice_alloc_and_map_source_tracking_shared_memory(v);
-		if (ret) {
-			pr_err("%s: Fail in allocating/mapping shared memory\n",
-				__func__);
-
-			ret = -EINVAL;
-			goto done;
-		}
-	}
-	st_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-					     APR_HDR_LEN(APR_HDR_SIZE),
-					     APR_PKT_VER);
-	st_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-					   sizeof(st_cmd) - APR_HDR_SIZE);
-	st_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
-	st_cmd.hdr.dest_port = cvp_handle;
-	st_cmd.hdr.token = 0;
-	st_cmd.hdr.opcode = VSS_ISOURCETRACK_CMD_GET_ACTIVITY;
-
-	st_cmd.cvp_get_source_tracking_param.mem_handle	=
-				 common.source_tracking_sh_mem.mem_handle;
-	st_cmd.cvp_get_source_tracking_param.mem_address_lsw =
-		lower_32_bits(common.source_tracking_sh_mem.sh_mem_block.phys);
-	st_cmd.cvp_get_source_tracking_param.mem_address_msw =
-		msm_audio_populate_upper_32_bits(common.source_tracking_sh_mem.
-					sh_mem_block.phys);
-	st_cmd.cvp_get_source_tracking_param.mem_size =
-		(uint32_t)common.source_tracking_sh_mem.sh_mem_block.size;
-	pr_debug("%s: mem_handle=0x%x, mem_address_lsw=0x%x, msw=0x%x, mem_size=%d\n",
-		 __func__,
-		 st_cmd.cvp_get_source_tracking_param.mem_handle,
-		 st_cmd.cvp_get_source_tracking_param.mem_address_lsw,
-		 st_cmd.cvp_get_source_tracking_param.mem_address_msw,
-		 (uint32_t)st_cmd.cvp_get_source_tracking_param.mem_size);
-
-	v->cvp_state = CMD_STATUS_FAIL;
-	v->async_err = 0;
-	ret = apr_send_pkt(apr_cvp,
-			   (uint32_t *) &st_cmd);
-	if (ret < 0) {
-		pr_err("%s: Error in sending APR command\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-	ret = wait_event_timeout(v->cvp_wait,
-				 (v->cvp_state == CMD_STATUS_SUCCESS),
-				 msecs_to_jiffies(TIMEOUT_MS));
-	if (!ret) {
-		pr_err("%s: wait_event timeout\n", __func__);
-
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (v->async_err > 0) {
-		pr_err("%s: DSP returned error[%s]\n",
-				__func__, adsp_err_get_err_str(
-				v->async_err));
-		ret = adsp_err_get_lnx_err_code(
-				v->async_err);
-		goto done;
-	}
-
-	if (common.is_source_tracking_resp_success) {
-		for (i = 0; i < MAX_SECTORS; i++) {
-			sourceTrackingData->vad[i] =
-				common.sourceTrackingResponse.voice_active[i];
-			pr_debug("%s: vad[%d] = %d\n",
-				  __func__, i, sourceTrackingData->vad[i]);
-		}
-		sourceTrackingData->doa_speech =
-				common.sourceTrackingResponse.talker_doa;
-		pr_debug("%s: doa_speech = %d\n",
-			  __func__, sourceTrackingData->doa_speech);
-
-		for (i = 0; i < MAX_NOISE_SOURCE_INDICATORS; i++) {
-			sourceTrackingData->doa_noise[i] =
-			 common.sourceTrackingResponse.interferer_doa[i];
-			pr_debug("%s: doa_noise[%d] = %d\n",
-			 __func__, i, sourceTrackingData->doa_noise[i]);
-		}
-		for (i = 0; i < MAX_POLAR_ACTIVITY_INDICATORS; i++) {
-			sourceTrackingData->polar_activity[i] =
-			 common.sourceTrackingResponse.sound_strength[i];
-			pr_debug("%s: polar_activity[%d] = %d\n",
-			 __func__, i, sourceTrackingData->polar_activity[i]);
-		}
-		common.is_source_tracking_resp_success = false;
-		ret = 0;
-	} else {
-		pr_err("%s: Error response received from CVD\n", __func__);
-
-		ret = -EINVAL;
-	}
-done:
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-int voc_get_source_tracking(struct source_tracking_param *sourceTrackingData)
-{
-	struct voice_data *v = NULL;
-	int ret = -EINVAL;
-	struct voice_session_itr itr;
-
-	pr_debug("%s: Enter\n", __func__);
-
-	mutex_lock(&common.common_lock);
-
-	voice_itr_init(&itr, ALL_SESSION_VSID);
-	while (voice_itr_get_next_session(&itr, &v)) {
-		if (v != NULL) {
-			mutex_lock(&v->lock);
-			if (is_voc_state_active(v->voc_state) &&
-				(v->lch_mode != VOICE_LCH_START) &&
-				!v->disable_topology)
-				ret = voice_send_get_source_tracking_cmd(v,
-							sourceTrackingData);
-			mutex_unlock(&v->lock);
-		} else {
-			pr_err("%s: invalid session\n", __func__);
-
-			break;
-		}
-	}
-
-	mutex_unlock(&common.common_lock);
-	pr_debug("%s: Exit, ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-int is_voc_initialized(void)
-{
-	return module_initialized;
-}
-
-static int __init voice_init(void)
-{
-	int rc = 0, i = 0;
-
-	memset(&common, 0, sizeof(struct common_data));
-
-	/* set default value */
-	common.default_mute_val = 0;  /* default is un-mute */
-	common.default_sample_val = 8000;
-	common.default_vol_step_val = 0;
-	common.default_vol_ramp_duration_ms = DEFAULT_VOLUME_RAMP_DURATION;
-	common.default_mute_ramp_duration_ms = DEFAULT_MUTE_RAMP_DURATION;
-	common.cvp_version = 0;
-	common.is_avcs_version_queried = false;
-	/* Initialize EC Ref media format info */
-	common.ec_ref_ext = false;
-	common.ec_media_fmt_info.port_id = AFE_PORT_INVALID;
-	common.ec_media_fmt_info.num_channels = 0;
-	common.ec_media_fmt_info.bits_per_sample = 16;
-	common.ec_media_fmt_info.sample_rate = 8000;
-	memset(&common.ec_media_fmt_info.channel_mapping, 0,
-	       VSS_CHANNEL_MAPPING_SIZE);
-
-	/* Initialize AFE Sidetone Enable */
-	common.sidetone_enable = false;
-
-	/* Initialize MVS info. */
-	common.mvs_info.network_type = VSS_NETWORK_ID_DEFAULT;
-
-	/* Initialize is low memory flag */
-	common.is_destroy_cvd = false;
-
-	/* Initialize CVD version */
-	strlcpy(common.cvd_version, CVD_VERSION_DEFAULT,
-		sizeof(common.cvd_version));
-	/* Initialize Per-Vocoder Calibration flag */
-	common.is_per_vocoder_cal_enabled = false;
-
-	mutex_init(&common.common_lock);
-
-	/* Initialize session id with vsid */
-	init_session_id();
-
-	for (i = 0; i < MAX_VOC_SESSIONS; i++) {
-
-		/* initialize dev_rx and dev_tx */
-		common.voice[i].dev_rx.dev_mute =  common.default_mute_val;
-		common.voice[i].dev_tx.dev_mute =  common.default_mute_val;
-		common.voice[i].dev_rx.volume_step_value =
-					common.default_vol_step_val;
-		common.voice[i].dev_rx.volume_ramp_duration_ms =
-					common.default_vol_ramp_duration_ms;
-		common.voice[i].dev_rx.dev_mute_ramp_duration_ms =
-					common.default_mute_ramp_duration_ms;
-		common.voice[i].dev_tx.dev_mute_ramp_duration_ms =
-					common.default_mute_ramp_duration_ms;
-		common.voice[i].stream_rx.stream_mute = common.default_mute_val;
-		common.voice[i].stream_tx.stream_mute = common.default_mute_val;
-
-		common.voice[i].dev_tx.port_id = 0x100B;
-		common.voice[i].dev_rx.port_id = 0x100A;
-		common.voice[i].dev_tx.dev_id = 0;
-		common.voice[i].dev_rx.dev_id = 0;
-		common.voice[i].dev_tx.no_of_channels = 0;
-		common.voice[i].dev_rx.no_of_channels = 0;
-		common.voice[i].dev_tx.sample_rate = 8000;
-		common.voice[i].dev_rx.sample_rate = 8000;
-		common.voice[i].dev_tx.bits_per_sample = 16;
-		common.voice[i].dev_rx.bits_per_sample = 16;
-		memset(&common.voice[i].dev_tx.channel_mapping, 0,
-		       VSS_CHANNEL_MAPPING_SIZE);
-		memset(&common.voice[i].dev_rx.channel_mapping, 0,
-		       VSS_CHANNEL_MAPPING_SIZE);
-		common.voice[i].sidetone_gain = 0x512;
-		common.voice[i].dtmf_rx_detect_en = 0;
-		common.voice[i].lch_mode = 0;
-		common.voice[i].disable_topology = false;
-
-		common.voice[i].voc_state = VOC_INIT;
-
-		init_waitqueue_head(&common.voice[i].mvm_wait);
-		init_waitqueue_head(&common.voice[i].cvs_wait);
-		init_waitqueue_head(&common.voice[i].cvp_wait);
-
-		mutex_init(&common.voice[i].lock);
-	}
-
-	if (voice_init_cal_data())
-		pr_err("%s: Could not init cal data!\n", __func__);
-
-	if (rc == 0)
-		module_initialized = true;
-
-	pr_debug("%s: rc=%d\n", __func__, rc);
-	return rc;
-}
-
-device_initcall(voice_init);
-
-static void __exit voice_exit(void)
-{
-	voice_delete_cal_data();
-	free_cal_map_table();
-}
-
-__exitcall(voice_exit);
diff --git a/sound/soc/msm/qdsp6v2/q6voice.h b/sound/soc/msm/qdsp6v2/q6voice.h
deleted file mode 100644
index 8a83996e..0000000
--- a/sound/soc/msm/qdsp6v2/q6voice.h
+++ /dev/null
@@ -1,2014 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __QDSP6VOICE_H__
-#define __QDSP6VOICE_H__
-
-#include <linux/qdsp6v2/apr.h>
-#include <linux/qdsp6v2/rtac.h>
-#include <linux/msm_ion.h>
-#include <sound/voice_params.h>
-
-#define MAX_VOC_PKT_SIZE 642
-#define SESSION_NAME_LEN 20
-#define NUM_OF_MEMORY_BLOCKS 1
-#define NUM_OF_BUFFERS 2
-#define VSS_NUM_CHANNELS_MAX 8
-#define VSS_CHANNEL_MAPPING_SIZE (sizeof(uint8_t) * VSS_NUM_CHANNELS_MAX)
-/*
- * BUFFER BLOCK SIZE based on
- * the supported page size
- */
-#define BUFFER_BLOCK_SIZE       4096
-
-#define MAX_COL_INFO_SIZE	324
-
-#define VOC_REC_UPLINK		0x00
-#define VOC_REC_DOWNLINK	0x01
-#define VOC_REC_BOTH		0x02
-
-#define VSS_IVERSION_CMD_GET                 0x00011378
-#define VSS_IVERSION_RSP_GET                 0x00011379
-#define CVD_VERSION_STRING_MAX_SIZE          31
-#define CVD_VERSION_DEFAULT                  ""
-#define CVD_VERSION_0_0                      "0.0"
-#define CVD_VERSION_2_1                      "2.1"
-#define CVD_VERSION_2_2                      "2.2"
-#define CVD_VERSION_2_3                      "2.3"
-
-#define CVD_INT_VERSION_DEFAULT              0
-#define CVD_INT_VERSION_0_0                  1
-#define CVD_INT_VERSION_2_1                  2
-#define CVD_INT_VERSION_2_2                  3
-#define CVD_INT_VERSION_2_3                  4
-#define CVD_INT_VERSION_LAST                 CVD_INT_VERSION_2_3
-#define CVD_INT_VERSION_MAX                  (CVD_INT_VERSION_LAST + 1)
-
-struct cvd_version_table {
-	char cvd_ver[CVD_VERSION_STRING_MAX_SIZE];
-	int cvd_ver_int;
-};
-
-int voc_get_cvd_version(char *cvd_version);
-
-/* Payload structure for the VSS_IVERSION_RSP_GET command response */
-struct vss_iversion_rsp_get_t {
-	char version[CVD_VERSION_STRING_MAX_SIZE];
-	/* NULL-terminated version string */
-};
-
-enum {
-	CVP_VOC_RX_TOPOLOGY_CAL = 0,
-	CVP_VOC_TX_TOPOLOGY_CAL,
-	CVP_VOCPROC_CAL,
-	CVP_VOCVOL_CAL,
-	CVP_VOCDEV_CFG_CAL,
-	CVP_VOCPROC_COL_CAL,
-	CVP_VOCVOL_COL_CAL,
-	CVS_VOCSTRM_CAL,
-	CVS_VOCSTRM_COL_CAL,
-	VOICE_RTAC_INFO_CAL,
-	VOICE_RTAC_APR_CAL,
-	MAX_VOICE_CAL_TYPES
-};
-
-struct voice_header {
-	uint32_t id;
-	uint32_t data_len;
-};
-
-struct voice_init {
-	struct voice_header hdr;
-	void *cb_handle;
-};
-
-/* Stream information payload structure */
-struct stream_data {
-	uint32_t stream_mute;
-	uint32_t stream_mute_ramp_duration_ms;
-};
-
-/* Device information payload structure */
-struct device_data {
-	uint32_t dev_mute;
-	uint32_t sample_rate;
-	uint16_t bits_per_sample;
-	uint8_t  channel_mapping[VSS_NUM_CHANNELS_MAX];
-	uint32_t enabled;
-	uint32_t dev_id;
-	uint32_t port_id;
-	uint32_t volume_step_value;
-	uint32_t volume_ramp_duration_ms;
-	uint32_t dev_mute_ramp_duration_ms;
-	uint32_t no_of_channels;
-};
-
-/*
- * Format information structure to match
- * vss_param_endpoint_media_format_info_t
- */
-struct media_format_info {
-	uint32_t port_id;
-	uint16_t num_channels;
-	uint16_t bits_per_sample;
-	uint32_t sample_rate;
-	uint8_t  channel_mapping[VSS_NUM_CHANNELS_MAX];
-};
-
-enum {
-	VOC_GENERIC_SET_PARAM_TOKEN = 0,
-	VOC_RTAC_SET_PARAM_TOKEN,
-	VOC_SET_MEDIA_FORMAT_PARAM_TOKEN,
-	VOC_SET_PARAM_TOKEN_MAX
-};
-
-struct voice_dev_route_state {
-	u16 rx_route_flag;
-	u16 tx_route_flag;
-};
-
-struct voice_rec_route_state {
-	u16 ul_flag;
-	u16 dl_flag;
-};
-
-enum {
-	VOC_INIT = 0,
-	VOC_RUN,
-	VOC_CHANGE,
-	VOC_RELEASE,
-	VOC_ERROR,
-	VOC_STANDBY,
-};
-
-struct mem_buffer {
-	dma_addr_t		phys;
-	void			*data;
-	uint32_t		size; /* size of buffer */
-};
-
-struct share_mem_buf {
-	struct ion_handle	*handle;
-	struct ion_client	*client;
-	struct mem_buffer	buf[NUM_OF_BUFFERS];
-};
-
-struct mem_map_table {
-	dma_addr_t		phys;
-	void			*data;
-	size_t			size; /* size of buffer */
-	struct ion_handle	*handle;
-	struct ion_client	*client;
-};
-
-/* Common */
-#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
-/* Set a UI property */
-#define VSS_ICOMMON_CMD_MAP_MEMORY   0x00011025
-#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
-/* General shared memory; byte-accessible, 4 kB-aligned. */
-#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL  3
-
-struct vss_icommon_cmd_map_memory_t {
-	uint32_t phys_addr;
-	/* Physical address of a memory region; must be at least
-	 *  4 kB aligned.
-	 */
-
-	uint32_t mem_size;
-	/* Number of bytes in the region; should be a multiple of 32. */
-
-	uint16_t mem_pool_id;
-	/* Type of memory being provided. The memory ID implicitly defines
-	 *  the characteristics of the memory. The characteristics might include
-	 *  alignment type, permissions, etc.
-	 * Memory pool ID. Possible values:
-	 * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL.
-	 */
-} __packed;
-
-struct vss_icommon_cmd_unmap_memory_t {
-	uint32_t phys_addr;
-	/* Physical address of a memory region; must be at least
-	 *  4 kB aligned.
-	 */
-} __packed;
-
-struct vss_map_memory_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_map_memory_t vss_map_mem;
-} __packed;
-
-struct vss_unmap_memory_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
-} __packed;
-
-struct vss_param_endpoint_media_format_info_t {
-	/* AFE port ID to which this media format corresponds to. */
-	uint32_t port_id;
-	/*
-	 * Number of channels of data.
-	 * Supported values: 1 to 8
-	 */
-	uint16_t num_channels;
-	/*
-	 * Bits per sample of data.
-	 * Supported values: 16 and 24
-	 */
-	uint16_t bits_per_sample;
-	/*
-	 * Sampling rate in Hz.
-	 * Supported values: 8000, 11025, 16000, 22050, 24000, 32000,
-	 * 44100, 48000, 88200, 96000, 176400, and 192000
-	 */
-	uint32_t sample_rate;
-	/*
-	 * The channel[i] mapping describes channel i. Each element i
-	 * of the array describes channel i inside the data buffer. An
-	 * unused or unknown channel is set to 0.
-	 */
-	uint8_t channel_mapping[VSS_NUM_CHANNELS_MAX];
-} __packed;
-
-struct vss_param_vocproc_dev_channel_info_t {
-	uint32_t num_channels;
-	uint32_t bits_per_sample;
-	uint8_t channel_mapping[VSS_NUM_CHANNELS_MAX];
-} __packed;
-
-struct vss_param_mfc_config_info_t {
-	uint32_t sample_rate;
-	uint16_t bits_per_sample;
-	uint16_t num_channels;
-	uint16_t channel_type[VSS_NUM_CHANNELS_MAX];
-} __packed;
-
-struct vss_icommon_param_data_t {
-	/* Valid ID of the module. */
-	uint32_t module_id;
-	/* Valid ID of the parameter. */
-	uint32_t param_id;
-	/*
-	 * Data size of the structure relating to the param_id/module_id
-	 * combination in uint8_t bytes.
-	 */
-	uint16_t param_size;
-	/* This field must be set to zero. */
-	uint16_t reserved;
-	/*
-	 * Parameter data payload when inband. Should have size param_size.
-	 * Bit size of payload must be a multiple of 4.
-	 */
-	union {
-		struct vss_param_endpoint_media_format_info_t media_format_info;
-	};
-} __packed;
-
-struct vss_icommon_param_data_channel_info_v2_t {
-	/* Valid ID of the module. */
-	uint32_t module_id;
-	/* Valid ID of the parameter. */
-	uint32_t param_id;
-	/*
-	 * Data size of the structure relating to the param_id/module_id
-	 * combination in uint8_t bytes.
-	 */
-	uint16_t param_size;
-	/* This field must be set to zero. */
-	uint16_t reserved;
-	struct vss_param_vocproc_dev_channel_info_t channel_info;
-} __packed;
-
-struct vss_icommon_cmd_set_param_channel_info_v2_t {
-	/*
-	 * Pointer to the unique identifier for an address (physical/virtual).
-	 *
-	 * If the parameter data payload is within the message payload
-	 * (in-band), set this field to 0. The parameter data begins at the
-	 * specified data payload address.
-	 *
-	 * If the parameter data is out-of-band, this field is the handle to
-	 * the physical address in the shared memory that holds the parameter
-	 * data.
-	 */
-	uint32_t mem_handle;
-	/*
-	 * Location of the parameter data payload.
-	 *
-	 * The payload is an array of vss_icommon_param_data_t. If the
-	 * mem_handle is 0, this field is ignored.
-	 */
-	uint64_t mem_address;
-	/* Size of the parameter data payload in bytes. */
-	uint32_t mem_size;
-	struct vss_icommon_param_data_channel_info_v2_t param_data;
-} __packed;
-
-struct vss_icommon_param_data_mfc_config_v2_t {
-	/* Valid ID of the module. */
-	uint32_t module_id;
-	/* Valid ID of the parameter. */
-	uint32_t param_id;
-	/*
-	 * Data size of the structure relating to the param_id/module_id
-	 * combination in uint8_t bytes.
-	 */
-	uint16_t param_size;
-	/* This field must be set to zero. */
-	uint16_t reserved;
-	struct vss_param_mfc_config_info_t mfc_config_info;
-} __packed;
-
-struct vss_icommon_cmd_set_param_mfc_config_v2_t {
-	/*
-	 * Pointer to the unique identifier for an address (physical/virtual).
-	 *
-	 * If the parameter data payload is within the message payload
-	 * (in-band), set this field to 0. The parameter data begins at the
-	 * specified data payload address.
-	 *
-	 * If the parameter data is out-of-band, this field is the handle to
-	 * the physical address in the shared memory that holds the parameter
-	 * data.
-	 */
-
-	uint32_t mem_handle;
-	/*
-	 * Location of the parameter data payload.
-	 *
-	 * The payload is an array of vss_icommon_param_data_t. If the
-	 * mem_handle is 0, this field is ignored.
-	 */
-	uint64_t mem_address;
-	/* Size of the parameter data payload in bytes. */
-	uint32_t mem_size;
-
-	struct vss_icommon_param_data_mfc_config_v2_t param_data;
-} __packed;
-
-/* Payload structure for the VSS_ICOMMON_CMD_SET_PARAM_V2 command. */
-struct vss_icommon_cmd_set_param_v2_t {
-	/*
-	 * Pointer to the unique identifier for an address (physical/virtual).
-	 *
-	 * If the parameter data payload is within the message payload
-	 * (in-band), set this field to 0. The parameter data begins at the
-	 * specified data payload address.
-	 *
-	 * If the parameter data is out-of-band, this field is the handle to
-	 * the physical address in the shared memory that holds the parameter
-	 * data.
-	 */
-	uint32_t mem_handle;
-	/*
-	 * Location of the parameter data payload.
-	 *
-	 * The payload is an array of vss_icommon_param_data_t. If the
-	 * mem_handle is 0, this field is ignored.
-	 */
-	uint64_t mem_address;
-	/* Size of the parameter data payload in bytes. */
-	uint32_t mem_size;
-	/* Parameter data payload when the data is inband. */
-	struct vss_icommon_param_data_t param_data;
-} __packed;
-
-/* TO MVM commands */
-#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION	0x000110FF
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL	0x00011327
-/*
- * VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL
- * Description: This command is required to let MVM know
- * who is in control of session.
- * Payload: Defined by vss_imvm_cmd_set_policy_dual_control_t.
- * Result: Wait for APRV2_IBASIC_RSP_RESULT response.
- */
-
-#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION	0x000110FE
-/* Create a new full control MVM session. */
-
-#define APRV2_IBASIC_CMD_DESTROY_SESSION		0x0001003C
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IMVM_CMD_ATTACH_STREAM			0x0001123C
-/* Attach a stream to the MVM. */
-
-#define VSS_IMVM_CMD_DETACH_STREAM			0x0001123D
-/* Detach a stream from the MVM. */
-
-#define VSS_IMVM_CMD_ATTACH_VOCPROC		       0x0001123E
-/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc
- * to all the streams currently attached to it.
- */
-
-#define VSS_IMVM_CMD_DETACH_VOCPROC			0x0001123F
-/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this
- * vocproc from all the streams to which it is currently attached.
- */
-
-#define VSS_IMVM_CMD_START_VOICE			0x00011190
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IMVM_CMD_STANDBY_VOICE                       0x00011191
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IMVM_CMD_STOP_VOICE				0x00011192
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IMVM_CMD_PAUSE_VOICE			0x0001137D
-/* No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_ISTREAM_CMD_ATTACH_VOCPROC			0x000110F8
-/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_ISTREAM_CMD_DETACH_VOCPROC			0x000110F9
-/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-
-#define VSS_ISTREAM_CMD_SET_TTY_MODE			0x00011196
-/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_ICOMMON_CMD_SET_NETWORK			0x0001119C
-/* Set the network type. */
-
-#define VSS_ICOMMON_CMD_SET_VOICE_TIMING		0x000111E0
-/* Set the voice timing parameters. */
-
-#define VSS_IMEMORY_CMD_MAP_PHYSICAL			0x00011334
-#define VSS_IMEMORY_RSP_MAP				0x00011336
-#define VSS_IMEMORY_CMD_UNMAP				0x00011337
-#define VSS_IMVM_CMD_SET_CAL_NETWORK			0x0001137A
-#define VSS_IMVM_CMD_SET_CAL_MEDIA_TYPE		0x0001137B
-#define VSS_IHDVOICE_CMD_ENABLE				0x000130A2
-#define VSS_IHDVOICE_CMD_DISABLE			0x000130A3
-
-enum msm_audio_voc_rate {
-		VOC_0_RATE, /* Blank frame */
-		VOC_8_RATE, /* 1/8 rate    */
-		VOC_4_RATE, /* 1/4 rate    */
-		VOC_2_RATE, /* 1/2 rate    */
-		VOC_1_RATE,  /* Full rate   */
-		VOC_8_RATE_NC  /* Noncritical 1/8 rate   */
-};
-
-struct vss_istream_cmd_set_tty_mode_t {
-	uint32_t mode;
-	/**<
-	 * TTY mode.
-	 *
-	 * 0 : TTY disabled
-	 * 1 : HCO
-	 * 2 : VCO
-	 * 3 : FULL
-	 */
-} __packed;
-
-struct vss_istream_cmd_attach_vocproc_t {
-	uint16_t handle;
-	/**< Handle of vocproc being attached. */
-} __packed;
-
-struct vss_istream_cmd_detach_vocproc_t {
-	uint16_t handle;
-	/**< Handle of vocproc being detached. */
-} __packed;
-
-struct vss_imvm_cmd_attach_stream_t {
-	uint16_t handle;
-	/* The stream handle to attach. */
-} __packed;
-
-struct vss_imvm_cmd_detach_stream_t {
-	uint16_t handle;
-	/* The stream handle to detach. */
-} __packed;
-
-struct vss_icommon_cmd_set_network_t {
-	uint32_t network_id;
-	/* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
-} __packed;
-
-struct vss_icommon_cmd_set_voice_timing_t {
-	uint16_t mode;
-	/*
-	 * The vocoder frame synchronization mode.
-	 *
-	 * 0 : No frame sync.
-	 * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt).
-	 */
-	uint16_t enc_offset;
-	/*
-	 * The offset in microseconds from the VFR to deliver a Tx vocoder
-	 * packet. The offset should be less than 20000us.
-	 */
-	uint16_t dec_req_offset;
-	/*
-	 * The offset in microseconds from the VFR to request for an Rx vocoder
-	 * packet. The offset should be less than 20000us.
-	 */
-	uint16_t dec_offset;
-	/*
-	 * The offset in microseconds from the VFR to indicate the deadline to
-	 * receive an Rx vocoder packet. The offset should be less than 20000us.
-	 * Rx vocoder packets received after this deadline are not guaranteed to
-	 * be processed.
-	 */
-} __packed;
-
-struct vss_imvm_cmd_create_control_session_t {
-	char name[SESSION_NAME_LEN];
-	/*
-	 * A variable-sized stream name.
-	 *
-	 * The stream name size is the payload size minus the size of the other
-	 * fields.
-	 */
-} __packed;
-
-
-struct vss_imvm_cmd_set_policy_dual_control_t {
-	bool enable_flag;
-	/* Set to TRUE to enable modem state machine control */
-} __packed;
-
-struct mvm_attach_vocproc_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle;
-} __packed;
-
-struct mvm_detach_vocproc_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle;
-} __packed;
-
-struct mvm_create_ctl_session_cmd {
-	struct apr_hdr hdr;
-	struct vss_imvm_cmd_create_control_session_t mvm_session;
-} __packed;
-
-struct mvm_modem_dual_control_session_cmd {
-	struct apr_hdr hdr;
-	struct vss_imvm_cmd_set_policy_dual_control_t voice_ctl;
-} __packed;
-
-struct mvm_set_tty_mode_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_set_tty_mode_t tty_mode;
-} __packed;
-
-struct mvm_attach_stream_cmd {
-	struct apr_hdr hdr;
-	struct vss_imvm_cmd_attach_stream_t attach_stream;
-} __packed;
-
-struct mvm_detach_stream_cmd {
-	struct apr_hdr hdr;
-	struct vss_imvm_cmd_detach_stream_t detach_stream;
-} __packed;
-
-struct mvm_set_network_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_network_t network;
-} __packed;
-
-struct mvm_set_voice_timing_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_voice_timing_t timing;
-} __packed;
-
-struct mvm_set_hd_enable_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct vss_imemory_table_descriptor_t {
-	uint32_t mem_address_lsw;
-	uint32_t mem_address_msw;
-	/*
-	 * Base physical address of the table. The address must be aligned
-	 * to LCM( cache_line_size, page_align, max_data_width ), where the
-	 * attributes are specified in #VSS_IMEMORY_CMD_MAP_PHYSICAL, and
-	 * LCM = Least Common Multiple. The table at the address must have
-	 * the format specified by #vss_imemory_table_t.
-	 */
-	uint32_t mem_size;
-	/* Size in bytes of the table. */
-} __packed;
-
-struct vss_imemory_block_t {
-	uint64_t mem_address;
-	/*
-	 * Base address of the memory block. The address is virtual for virtual
-	 * memory and physical for physical memory. The address must be aligned
-	 * to LCM( cache_line_size, page_align, max_data_width ), where the
-	 * attributes are specified in VSS_IMEMORY_CMD_MAP_VIRTUAL or
-	 * VSS_IMEMORY_CMD_MAP_PHYSICAL, and LCM = Least Common Multiple.
-	 */
-	uint32_t mem_size;
-	/*
-	 * Size in bytes of the memory block. The size must be multiple of
-	 * page_align, where page_align is specified in
-	 * VSS_IMEMORY_CMD_MAP_VIRTUAL or #VSS_IMEMORY_CMD_MAP_PHYSICAL.
-	 */
-} __packed;
-
-struct vss_imemory_table_t {
-	struct vss_imemory_table_descriptor_t next_table_descriptor;
-	/*
-	 * Specifies the next table. If there is no next table,
-	 * set the size of the table to 0 and the table address is ignored.
-	 */
-	struct vss_imemory_block_t blocks[NUM_OF_MEMORY_BLOCKS];
-	/* Specifies one ore more memory blocks. */
-} __packed;
-
-struct vss_imemory_cmd_map_physical_t {
-	struct apr_hdr hdr;
-	struct vss_imemory_table_descriptor_t table_descriptor;
-	bool is_cached;
-	/*
-	 * Indicates cached or uncached memory. Supported values:
-	 * TRUE - Cached.
-	 */
-	uint16_t cache_line_size;
-	/* Cache line size in bytes. Supported values: 128 */
-	uint32_t access_mask;
-	/*
-	 * CVD's access permission to the memory while it is mapped.
-	 * Supported values:
-	 * bit 0 - If set, the memory is readable.
-	 * bit 1 - If set, the memory is writable.
-	 */
-	uint32_t page_align;
-	/* Page frame alignment in bytes. Supported values: 4096 */
-	uint8_t min_data_width;
-	/*
-	 * Minimum native data type width in bits that can be accessed.
-	 * Supported values: 8
-	 */
-	uint8_t max_data_width;
-	/*
-	 * Maximum native data type width in bits that can be accessed.
-	 * Supported values: 64
-	 */
-} __packed;
-
-struct vss_imvm_cmd_set_cal_network_t {
-	struct apr_hdr hdr;
-	uint32_t network_id;
-} __packed;
-
-struct vss_imvm_cmd_set_cal_media_type_t {
-	struct apr_hdr hdr;
-	uint32_t media_id;
-} __packed;
-
-struct vss_imemory_cmd_unmap_t {
-	struct apr_hdr hdr;
-	uint32_t mem_handle;
-} __packed;
-
-/* TO CVS commands */
-#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION	0x00011140
-/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION	0x000110F7
-/* Create a new full control stream session. */
-
-#define APRV2_IBASIC_CMD_DESTROY_SESSION		0x0001003C
-
-/*
- * This command changes the mute setting. The new mute setting will
- * be applied over the specified ramp duration.
- */
-#define VSS_IVOLUME_CMD_MUTE_V2				0x0001138B
-
-#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA_V2    0x00011369
-
-#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA     0x0001127A
-
-#define VSS_ISTREAM_CMD_REGISTER_STATIC_CALIBRATION_DATA        0x0001307D
-#define VSS_ISTREAM_CMD_DEREGISTER_STATIC_CALIBRATION_DATA      0x0001307E
-
-#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE			0x00011186
-/* Set media type on the stream. */
-
-#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER			0x00011015
-/* Event sent by the stream to its client to provide an encoded packet. */
-
-#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER		0x00011017
-/* Event sent by the stream to its client requesting for a decoder packet.
- * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event.
- */
-
-#define VSS_ISTREAM_EVT_OOB_NOTIFY_DEC_BUFFER_REQUEST	0x0001136E
-
-#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER			0x00011016
-/* Event sent by the client to the stream in response to a
- * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet.
- */
-
-#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE		0x0001113E
-/* Set AMR encoder rate. */
-
-#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE		0x0001113F
-/* Set AMR-WB encoder rate. */
-
-#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE	0x00011019
-/* Set encoder minimum and maximum rate. */
-
-#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE		0x0001101D
-/* Set encoder DTX mode. */
-
-#define MODULE_ID_VOICE_MODULE_ST			0x00010EE3
-#define VOICE_PARAM_MOD_ENABLE				0x00010E00
-#define MOD_ENABLE_PARAM_LEN				4
-
-#define VSS_IPLAYBACK_CMD_START				0x000112BD
-/* Start in-call music delivery on the Tx voice path. */
-
-#define VSS_IPLAYBACK_CMD_STOP				0x00011239
-/* Stop the in-call music delivery on the Tx voice path. */
-
-#define VSS_IPLAYBACK_PORT_ID_DEFAULT			0x0000FFFF
-/* Default AFE port ID. */
-
-#define VSS_IPLAYBACK_PORT_ID_VOICE			0x00008005
-/* AFE port ID for VOICE 1. */
-
-#define VSS_IPLAYBACK_PORT_ID_VOICE2			0x00008002
-/* AFE port ID for VOICE 2. */
-
-#define VSS_IRECORD_CMD_START				0x000112BE
-/* Start in-call conversation recording. */
-#define VSS_IRECORD_CMD_STOP				0x00011237
-/* Stop in-call conversation recording. */
-
-#define VSS_IRECORD_PORT_ID_DEFAULT			0x0000FFFF
-/* Default AFE port ID. */
-
-#define VSS_IRECORD_TAP_POINT_NONE			0x00010F78
-/* Indicates no tapping for specified path. */
-
-#define VSS_IRECORD_TAP_POINT_STREAM_END		0x00010F79
-/* Indicates that specified path should be tapped at the end of the stream. */
-
-#define VSS_IRECORD_MODE_TX_RX_STEREO			0x00010F7A
-/* Select Tx on left channel and Rx on right channel. */
-
-#define VSS_IRECORD_MODE_TX_RX_MIXING			0x00010F7B
-/* Select mixed Tx and Rx paths. */
-
-#define VSS_PARAM_VOCPROC_TX_CHANNEL_INFO              0x0001328E
-
-#define VSS_PARAM_VOCPROC_RX_CHANNEL_INFO              0x0001328F
-
-#define VSS_PARAM_VOCPROC_EC_REF_CHANNEL_INFO          0x00013290
-
-#define VSS_PARAM_TX_PORT_ENDPOINT_MEDIA_INFO		0x00013253
-
-#define VSS_PARAM_RX_PORT_ENDPOINT_MEDIA_INFO		0x00013254
-
-#define VSS_PARAM_EC_REF_PORT_ENDPOINT_MEDIA_INFO	0x00013255
-
-#define VSS_MODULE_CVD_GENERIC				0x0001316E
-
-#define VSS_ISTREAM_EVT_NOT_READY			0x000110FD
-
-#define VSS_ISTREAM_EVT_READY				0x000110FC
-
-#define VSS_ISTREAM_EVT_OOB_NOTIFY_DEC_BUFFER_READY	0x0001136F
-/*notify dsp that decoder buffer is ready*/
-
-#define VSS_ISTREAM_EVT_OOB_NOTIFY_ENC_BUFFER_READY	0x0001136C
-/*dsp notifying client that encoder buffer is ready*/
-
-#define VSS_ISTREAM_EVT_OOB_NOTIFY_ENC_BUFFER_CONSUMED	0x0001136D
-/*notify dsp that encoder buffer is consumed*/
-
-#define VSS_ISTREAM_CMD_SET_OOB_PACKET_EXCHANGE_CONFIG	0x0001136B
-
-#define VSS_ISTREAM_PACKET_EXCHANGE_MODE_INBAND	0
-/* In-band packet exchange mode. */
-
-#define VSS_ISTREAM_PACKET_EXCHANGE_MODE_OUT_OF_BAND	1
-/* Out-of-band packet exchange mode. */
-
-#define VSS_ISTREAM_CMD_SET_PACKET_EXCHANGE_MODE	0x0001136A
-
-struct vss_iplayback_cmd_start_t {
-	uint16_t port_id;
-	/*
-	 * AFE Port ID from which the audio samples are available.
-	 * To use the default AFE pseudo port (0x8005), set this value to
-	 * #VSS_IPLAYBACK_PORT_ID_DEFAULT.
-	 */
-}  __packed;
-
-struct vss_irecord_cmd_start_t {
-	uint32_t rx_tap_point;
-	/* Tap point to use on the Rx path. Supported values are:
-	 * VSS_IRECORD_TAP_POINT_NONE : Do not record Rx path.
-	 * VSS_IRECORD_TAP_POINT_STREAM_END : Rx tap point is at the end of
-	 * the stream.
-	 */
-	uint32_t tx_tap_point;
-	/* Tap point to use on the Tx path. Supported values are:
-	 * VSS_IRECORD_TAP_POINT_NONE : Do not record tx path.
-	 * VSS_IRECORD_TAP_POINT_STREAM_END : Tx tap point is at the end of
-	 * the stream.
-	 */
-	uint16_t port_id;
-	/* AFE Port ID to which the conversation recording stream needs to be
-	 * sent. Set this to #VSS_IRECORD_PORT_ID_DEFAULT to use default AFE
-	 * pseudo ports (0x8003 for Rx and 0x8004 for Tx).
-	 */
-	uint32_t mode;
-	/* Recording Mode. The mode parameter value is ignored if the port_id
-	 * is set to #VSS_IRECORD_PORT_ID_DEFAULT.
-	 * The supported values:
-	 * #VSS_IRECORD_MODE_TX_RX_STEREO
-	 * #VSS_IRECORD_MODE_TX_RX_MIXING
-	 */
-} __packed;
-
-struct vss_istream_cmd_create_passive_control_session_t {
-	char name[SESSION_NAME_LEN];
-	/**<
-	 * A variable-sized stream name.
-	 *
-	 * The stream name size is the payload size minus the size of the other
-	 * fields.
-	 */
-} __packed;
-
-#define VSS_IVOLUME_DIRECTION_TX	0
-#define VSS_IVOLUME_DIRECTION_RX	1
-
-#define VSS_IVOLUME_MUTE_OFF		0
-#define VSS_IVOLUME_MUTE_ON		1
-
-#define DEFAULT_MUTE_RAMP_DURATION	500
-#define DEFAULT_VOLUME_RAMP_DURATION	20
-#define MAX_RAMP_DURATION		5000
-
-struct vss_ivolume_cmd_mute_v2_t {
-	uint16_t direction;
-	/*
-	 * The direction field sets the direction to apply the mute command.
-	 * The Supported values:
-	 * VSS_IVOLUME_DIRECTION_TX
-	 * VSS_IVOLUME_DIRECTION_RX
-	 */
-	uint16_t mute_flag;
-	/*
-	 * Turn mute on or off. The Supported values:
-	 * VSS_IVOLUME_MUTE_OFF
-	 * VSS_IVOLUME_MUTE_ON
-	 */
-	uint16_t ramp_duration_ms;
-	/*
-	 * Mute change ramp duration in milliseconds.
-	 * The Supported values: 0 to 5000.
-	 */
-} __packed;
-
-struct vss_istream_cmd_create_full_control_session_t {
-	uint16_t direction;
-	/*
-	 * Stream direction.
-	 *
-	 * 0 : TX only
-	 * 1 : RX only
-	 * 2 : TX and RX
-	 * 3 : TX and RX loopback
-	 */
-	uint32_t enc_media_type;
-	/* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
-	uint32_t dec_media_type;
-	/* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
-	uint32_t network_id;
-	/* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
-	char name[SESSION_NAME_LEN];
-	/*
-	 * A variable-sized stream name.
-	 *
-	 * The stream name size is the payload size minus the size of the other
-	 * fields.
-	 */
-} __packed;
-
-struct vss_istream_cmd_set_media_type_t {
-	uint32_t rx_media_id;
-	/* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
-	uint32_t tx_media_id;
-	/* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
-} __packed;
-
-struct vss_istream_evt_send_enc_buffer_t {
-	uint32_t media_id;
-      /* Media ID of the packet. */
-	uint8_t packet_data[MAX_VOC_PKT_SIZE];
-      /* Packet data buffer. */
-} __packed;
-
-struct vss_istream_evt_send_dec_buffer_t {
-	uint32_t media_id;
-      /* Media ID of the packet. */
-	uint8_t packet_data[MAX_VOC_PKT_SIZE];
-      /* Packet data. */
-} __packed;
-
-struct vss_istream_cmd_voc_amr_set_enc_rate_t {
-	uint32_t mode;
-	/* Set the AMR encoder rate.
-	 *
-	 * 0x00000000 : 4.75 kbps
-	 * 0x00000001 : 5.15 kbps
-	 * 0x00000002 : 5.90 kbps
-	 * 0x00000003 : 6.70 kbps
-	 * 0x00000004 : 7.40 kbps
-	 * 0x00000005 : 7.95 kbps
-	 * 0x00000006 : 10.2 kbps
-	 * 0x00000007 : 12.2 kbps
-	 */
-} __packed;
-
-struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
-	uint32_t mode;
-	/* Set the AMR-WB encoder rate.
-	 *
-	 * 0x00000000 :  6.60 kbps
-	 * 0x00000001 :  8.85 kbps
-	 * 0x00000002 : 12.65 kbps
-	 * 0x00000003 : 14.25 kbps
-	 * 0x00000004 : 15.85 kbps
-	 * 0x00000005 : 18.25 kbps
-	 * 0x00000006 : 19.85 kbps
-	 * 0x00000007 : 23.05 kbps
-	 * 0x00000008 : 23.85 kbps
-	 */
-} __packed;
-
-struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
-	uint16_t min_rate;
-	/* Set the lower bound encoder rate.
-	 *
-	 * 0x0000 : Blank frame
-	 * 0x0001 : Eighth rate
-	 * 0x0002 : Quarter rate
-	 * 0x0003 : Half rate
-	 * 0x0004 : Full rate
-	 */
-	uint16_t max_rate;
-	/* Set the upper bound encoder rate.
-	 *
-	 * 0x0000 : Blank frame
-	 * 0x0001 : Eighth rate
-	 * 0x0002 : Quarter rate
-	 * 0x0003 : Half rate
-	 * 0x0004 : Full rate
-	 */
-} __packed;
-
-struct vss_istream_cmd_set_enc_dtx_mode_t {
-	uint32_t enable;
-	/* Toggle DTX on or off.
-	 *
-	 * 0 : Disables DTX
-	 * 1 : Enables DTX
-	 */
-} __packed;
-
-struct vss_istream_cmd_register_calibration_data_v2_t {
-	uint32_t cal_mem_handle;
-	/* Handle to the shared memory that holds the calibration data. */
-	uint32_t cal_mem_address_lsw;
-	uint32_t cal_mem_address_msw;
-	/* Location of calibration data. */
-	uint32_t cal_mem_size;
-	/* Size of the calibration data in bytes. */
-	uint8_t column_info[MAX_COL_INFO_SIZE];
-	/*
-	 * Column info contains the number of columns and the array of columns
-	 * in the calibration table. The order in which the columns are provided
-	 * here must match the order in which they exist in the calibration
-	 * table provided.
-	 */
-} __packed;
-
-struct vss_icommon_cmd_set_ui_property_enable_t {
-	uint32_t module_id;
-	/* Unique ID of the module. */
-	uint32_t param_id;
-	/* Unique ID of the parameter. */
-	uint16_t param_size;
-	/* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
-	uint16_t reserved;
-	/* Reserved; set to 0. */
-	uint16_t enable;
-	uint16_t reserved_field;
-	/* Reserved, set to 0. */
-};
-
-/*
- * Event sent by the stream to the client that enables Rx DTMF
- * detection whenever DTMF is detected in the Rx path.
- *
- * The DTMF detection feature can only be used to detect DTMF
- * frequencies as listed in the vss_istream_evt_rx_dtmf_detected_t
- * structure.
- */
-
-#define VSS_ISTREAM_EVT_RX_DTMF_DETECTED 0x0001101A
-
-struct vss_istream_cmd_set_rx_dtmf_detection {
-	/*
-	 * Enables/disables Rx DTMF detection
-	 *
-	 * Possible values are
-	 * 0 - disable
-	 * 1 - enable
-	 *
-	 */
-	uint32_t enable;
-};
-
-#define VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION 0x00011027
-
-struct vss_istream_evt_rx_dtmf_detected {
-	uint16_t low_freq;
-	/*
-	 * Detected low frequency. Possible values:
-	 * 697 Hz
-	 * 770 Hz
-	 * 852 Hz
-	 * 941 Hz
-	 */
-	uint16_t high_freq;
-	/*
-	 * Detected high frequency. Possible values:
-	 * 1209 Hz
-	 * 1336 Hz
-	 * 1477 Hz
-	 * 1633 Hz
-	 */
-};
-
-struct cvs_set_rx_dtmf_detection_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_set_rx_dtmf_detection cvs_dtmf_det;
-} __packed;
-
-
-struct cvs_create_passive_ctl_session_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_create_passive_control_session_t cvs_session;
-} __packed;
-
-struct cvs_create_full_ctl_session_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_create_full_control_session_t cvs_session;
-} __packed;
-
-struct cvs_destroy_session_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvs_set_mute_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivolume_cmd_mute_v2_t cvs_set_mute;
-} __packed;
-
-struct cvs_set_media_type_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_set_media_type_t media_type;
-} __packed;
-
-struct cvs_send_dec_buf_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_evt_send_dec_buffer_t dec_buf;
-} __packed;
-
-struct cvs_set_amr_enc_rate_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
-} __packed;
-
-struct cvs_set_amrwb_enc_rate_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
-} __packed;
-
-struct cvs_set_cdma_enc_minmax_rate_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
-} __packed;
-
-struct cvs_set_enc_dtx_mode_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
-} __packed;
-
-struct cvs_register_cal_data_cmd {
-	struct apr_hdr hdr;
-	struct vss_istream_cmd_register_calibration_data_v2_t cvs_cal_data;
-} __packed;
-
-struct cvs_deregister_cal_data_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvs_set_pp_enable_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
-} __packed;
-struct cvs_start_record_cmd {
-	struct apr_hdr hdr;
-	struct vss_irecord_cmd_start_t rec_mode;
-} __packed;
-
-struct cvs_start_playback_cmd {
-	struct apr_hdr hdr;
-	struct vss_iplayback_cmd_start_t playback_mode;
-} __packed;
-
-struct cvs_dec_buffer_ready_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvs_enc_buffer_consumed_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct vss_istream_cmd_set_oob_packet_exchange_config_t {
-	struct apr_hdr hdr;
-	uint32_t mem_handle;
-	uint32_t enc_buf_addr_lsw;
-	uint32_t enc_buf_addr_msw;
-	uint32_t enc_buf_size;
-	uint32_t dec_buf_addr_lsw;
-	uint32_t dec_buf_addr_msw;
-	uint32_t dec_buf_size;
-} __packed;
-
-struct vss_istream_cmd_set_packet_exchange_mode_t {
-	struct apr_hdr hdr;
-	uint32_t mode;
-} __packed;
-
-/* TO CVP commands */
-
-#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION	0x000100C3
-/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define APRV2_IBASIC_CMD_DESTROY_SESSION		0x0001003C
-
-#define VSS_IVOCPROC_CMD_SET_DEVICE_V2			0x000112C6
-
-#define VSS_IVOCPROC_CMD_SET_DEVICE_V3			0x0001316A
-
-#define VSS_IVOCPROC_CMD_TOPOLOGY_SET_DEV_CHANNELS	0x00013199
-
-#define VSS_IVOCPROC_CMD_TOPOLOGY_COMMIT		0x00013198
-
-#define VSS_IVOCPROC_CMD_SET_VP3_DATA			0x000110EB
-
-#define VSS_IVOLUME_CMD_SET_STEP			0x000112C2
-
-#define VSS_IVOCPROC_CMD_ENABLE				0x000100C6
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-#define VSS_IVOCPROC_CMD_DISABLE			0x000110E1
-/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
-
-/*
- * Registers the memory that contains device specific configuration data with
- * the vocproc. The client must register device configuration data with the
- * vocproc that corresponds with the device being set on the vocproc.
- */
-#define VSS_IVOCPROC_CMD_REGISTER_DEVICE_CONFIG		0x00011371
-
-/*
- * Deregisters the memory that holds device configuration data from the
-  vocproc.
-*/
-#define VSS_IVOCPROC_CMD_DEREGISTER_DEVICE_CONFIG	0x00011372
-
-#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA_V2	0x00011373
-#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA	0x00011276
-
-#define VSS_IVOCPROC_CMD_REGISTER_VOL_CALIBRATION_DATA	0x00011374
-#define VSS_IVOCPROC_CMD_DEREGISTER_VOL_CALIBRATION_DATA	0x00011375
-
-#define VSS_IVOCPROC_CMD_REGISTER_STATIC_CALIBRATION_DATA       0x00013079
-#define VSS_IVOCPROC_CMD_DEREGISTER_STATIC_CALIBRATION_DATA     0x0001307A
-
-#define VSS_IVOCPROC_CMD_REGISTER_DYNAMIC_CALIBRATION_DATA      0x0001307B
-#define VSS_IVOCPROC_CMD_DEREGISTER_DYNAMIC_CALIBRATION_DATA    0x0001307C
-
-#define VSS_IVOCPROC_TOPOLOGY_ID_NONE			0x00010F70
-#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS_V2		0x00010F89
-#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE		0x00010F72
-
-#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT		0x00010F77
-
-/* Newtwork IDs */
-#define VSS_ICOMMON_CAL_NETWORK_ID_NONE		0x0001135E
-
-/* Select internal mixing mode. */
-#define VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING	0x00010F7C
-
-/* Select external mixing mode. */
-#define VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING	0x00010F7D
-
-/* Default AFE port ID. Applicable to Tx and Rx. */
-#define VSS_IVOCPROC_PORT_ID_NONE		0xFFFF
-
-#define VSS_NETWORK_ID_DEFAULT		0x00010037
-
-/* Voice over Internet Protocol (VoIP) network ID. Common for all bands.*/
-#define VSS_NETWORK_ID_VOIP		0x00011362
-
-/* Media types */
-#define VSS_MEDIA_ID_EVRC_MODEM		0x00010FC2
-/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
-#define VSS_MEDIA_ID_AMR_NB_MODEM	0x00010FC6
-/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
-#define VSS_MEDIA_ID_AMR_WB_MODEM	0x00010FC7
-/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
-
-#define VSS_MEDIA_ID_PCM_8_KHZ		0x00010FCB
-#define VSS_MEDIA_ID_PCM_16_KHZ		0x00010FCC
-#define VSS_MEDIA_ID_PCM_32_KHZ		0x00010FD9
-#define VSS_MEDIA_ID_PCM_48_KHZ		0x00010FD6
-
-/* Linear PCM (16-bit, little-endian). */
-#define VSS_MEDIA_ID_G711_ALAW		0x00010FCD
-/* G.711 a-law (contains two 10ms vocoder frames). */
-#define VSS_MEDIA_ID_G711_MULAW		0x00010FCE
-/* G.711 mu-law (contains two 10ms vocoder frames). */
-#define VSS_MEDIA_ID_G729		0x00010FD0
-/* G.729AB (contains two 10ms vocoder frames. */
-#define VSS_MEDIA_ID_4GV_NB_MODEM	0x00010FC3
-/*CDMA EVRC-B vocoder modem format */
-#define VSS_MEDIA_ID_4GV_WB_MODEM	0x00010FC4
-/*CDMA EVRC-WB vocoder modem format */
-#define VSS_MEDIA_ID_4GV_NW_MODEM	0x00010FC5
-/*CDMA EVRC-NW vocoder modem format */
-
-#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V2	0x000112BF
-#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION_V3	0x00013169
-
-#define VSS_NUM_DEV_CHANNELS_1 1
-#define VSS_NUM_DEV_CHANNELS_2 2
-#define VSS_NUM_DEV_CHANNELS_3 3
-#define VSS_NUM_DEV_CHANNELS_4 4
-
-struct vss_ivocproc_cmd_create_full_control_session_v2_t {
-	uint16_t direction;
-	/*
-	 * Vocproc direction. The supported values:
-	 * VSS_IVOCPROC_DIRECTION_RX
-	 * VSS_IVOCPROC_DIRECTION_TX
-	 * VSS_IVOCPROC_DIRECTION_RX_TX
-	 */
-	uint16_t tx_port_id;
-	/*
-	 * Tx device port ID to which the vocproc connects. If a port ID is
-	 * not being supplied, set this to #VSS_IVOCPROC_PORT_ID_NONE.
-	 */
-	uint32_t tx_topology_id;
-	/*
-	 * Tx path topology ID. If a topology ID is not being supplied, set
-	 * this to #VSS_IVOCPROC_TOPOLOGY_ID_NONE.
-	 */
-	uint16_t rx_port_id;
-	/*
-	 * Rx device port ID to which the vocproc connects. If a port ID is
-	 * not being supplied, set this to #VSS_IVOCPROC_PORT_ID_NONE.
-	 */
-	uint32_t rx_topology_id;
-	/*
-	 * Rx path topology ID. If a topology ID is not being supplied, set
-	 * this to #VSS_IVOCPROC_TOPOLOGY_ID_NONE.
-	 */
-	uint32_t profile_id;
-	/* Voice calibration profile ID. */
-	uint32_t vocproc_mode;
-	/*
-	 * Vocproc mode. The supported values:
-	 * VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING
-	 * VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING
-	 */
-	uint16_t ec_ref_port_id;
-	/*
-	 * Port ID to which the vocproc connects for receiving echo
-	 * cancellation reference signal. If a port ID is not being supplied,
-	 * set this to #VSS_IVOCPROC_PORT_ID_NONE. This parameter value is
-	 * ignored when the vocproc_mode parameter is set to
-	 * VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING.
-	 */
-	char name[SESSION_NAME_LEN];
-	/*
-	 * Session name string used to identify a session that can be shared
-	 * with passive controllers (optional). The string size, including the
-	 * NULL termination character, is limited to 31 characters.
-	 */
-} __packed;
-
-struct vss_ivocproc_cmd_set_volume_index_t {
-	uint16_t vol_index;
-	/*
-	 * Volume index utilized by the vocproc to index into the volume table
-	 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
-	 * volume on the VDSP.
-	 */
-} __packed;
-
-struct vss_ivolume_cmd_set_step_t {
-	uint16_t direction;
-	/*
-	 * The direction field sets the direction to apply the volume command.
-	 * The supported values:
-	 * #VSS_IVOLUME_DIRECTION_RX
-	 */
-	uint32_t value;
-	/*
-	 * Volume step used to find the corresponding linear volume and
-	 * the best match index in the registered volume calibration table.
-	 */
-	uint16_t ramp_duration_ms;
-	/*
-	 * Volume change ramp duration in milliseconds.
-	 * The supported values: 0 to 5000.
-	 */
-} __packed;
-
-struct vss_ivocproc_cmd_set_device_v2_t {
-	uint16_t tx_port_id;
-	/*
-	 * TX device port ID which vocproc will connect to.
-	 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
-	 */
-	uint32_t tx_topology_id;
-	/*
-	 * TX leg topology ID.
-	 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
-	 * pre/post-processing blocks and is pass-through.
-	 */
-	uint16_t rx_port_id;
-	/*
-	 * RX device port ID which vocproc will connect to.
-	 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
-	 */
-	uint32_t rx_topology_id;
-	/*
-	 * RX leg topology ID.
-	 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
-	 * pre/post-processing blocks and is pass-through.
-	 */
-	uint32_t vocproc_mode;
-	/* Vocproc mode. The supported values:
-	 * VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING - 0x00010F7C
-	 * VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING - 0x00010F7D
-	 */
-	uint16_t ec_ref_port_id;
-	/* Port ID to which the vocproc connects for receiving
-	 * echo
-	 */
-} __packed;
-
-struct vss_ivocproc_cmd_register_device_config_t {
-	uint32_t mem_handle;
-	/*
-	 * Handle to the shared memory that holds the per-network calibration
-	 * data.
-	 */
-	uint32_t mem_address_lsw;
-	uint32_t mem_address_msw;
-	/* Location of calibration data. */
-	uint32_t mem_size;
-	/* Size of the calibration data in bytes. */
-} __packed;
-
-struct vss_ivocproc_cmd_register_calibration_data_v2_t {
-	uint32_t cal_mem_handle;
-	/*
-	 * Handle to the shared memory that holds the per-network calibration
-	 * data.
-	 */
-	uint32_t cal_mem_address_lsw;
-	uint32_t cal_mem_address_msw;
-	/* Location of calibration data. */
-	uint32_t cal_mem_size;
-	/* Size of the calibration data in bytes. */
-	uint8_t column_info[MAX_COL_INFO_SIZE];
-	/*
-	 * Column info contains the number of columns and the array of columns
-	 * in the calibration table. The order in which the columns are provided
-	 * here must match the order in which they exist in the calibration
-	 * table provided.
-	 */
-} __packed;
-
-struct vss_ivocproc_cmd_register_volume_cal_data_t {
-	uint32_t cal_mem_handle;
-	/*
-	 * Handle to the shared memory that holds the volume calibration
-	 * data.
-	 */
-	uint32_t cal_mem_address_lsw;
-	uint32_t cal_mem_address_msw;
-	/* Location of volume calibration data. */
-	uint32_t cal_mem_size;
-	/* Size of the volume calibration data in bytes. */
-	uint8_t column_info[MAX_COL_INFO_SIZE];
-	/*
-	 * Column info contains the number of columns and the array of columns
-	 * in the calibration table. The order in which the columns are provided
-	 * here must match the order in which they exist in the calibration
-	 * table provided.
-	 */
-} __packed;
-
-struct vss_ivocproc_cmd_topology_set_dev_channels_t {
-	uint16_t tx_num_channels;
-	/*
-	 * Number of Mics.
-	 * Supported values
-	 * 1  VSS_NUM_DEV_CHANNELS_1
-	 * 2  VSS_NUM_DEV_CHANNELS_2
-	 * 3  VSS_NUM_DEV_CHANNELS_3
-	 * 4  VSS_NUM_DEV_CHANNELS_4
-	 */
-	uint16_t rx_num_channels;
-	/*
-	 * Number of speaker channels.
-	 * Supported values
-	 * 1 VSS_NUM_DEV_CHANNELS_1
-	 */
-} __packed;
-
-/* Starts a vocoder PCM session */
-#define VSS_IVPCM_CMD_START_V2	0x00011339
-
-/* Default tap point location on the TX path. */
-#define VSS_IVPCM_TAP_POINT_TX_DEFAULT	0x00011289
-
-/* Default tap point location on the RX path. */
-#define VSS_IVPCM_TAP_POINT_RX_DEFAULT	0x0001128A
-
-/* Indicates tap point direction is output. */
-#define VSS_IVPCM_TAP_POINT_DIR_OUT	0
-
-/* Indicates tap point direction is input. */
-#define VSS_IVPCM_TAP_POINT_DIR_IN	1
-
-/* Indicates tap point direction is output and input. */
-#define VSS_IVPCM_TAP_POINT_DIR_OUT_IN	2
-
-
-#define VSS_IVPCM_SAMPLING_RATE_AUTO	0
-
-/* Indicates 8 KHz vocoder PCM sampling rate. */
-#define VSS_IVPCM_SAMPLING_RATE_8K	8000
-
-/* Indicates 16 KHz vocoder PCM sampling rate. */
-#define VSS_IVPCM_SAMPLING_RATE_16K	16000
-
-/* RX and TX */
-#define MAX_TAP_POINTS_SUPPORTED	2
-
-struct vss_ivpcm_tap_point {
-	uint32_t tap_point;
-	uint16_t direction;
-	uint16_t sampling_rate;
-	uint16_t duration;
-} __packed;
-
-
-struct vss_ivpcm_cmd_start_v2_t {
-	uint32_t mem_handle;
-	uint32_t num_tap_points;
-	struct vss_ivpcm_tap_point tap_points[MAX_TAP_POINTS_SUPPORTED];
-} __packed;
-
-#define VSS_IVPCM_EVT_PUSH_BUFFER_V2	0x0001133A
-
-/* Push buffer event mask indicating output buffer is filled. */
-#define VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER 1
-
-/* Push buffer event mask indicating input buffer is consumed. */
-#define VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER 2
-
-
-struct vss_ivpcm_evt_push_buffer_v2_t {
-	uint32_t tap_point;
-	uint32_t push_buf_mask;
-	uint64_t out_buf_mem_address;
-	uint16_t out_buf_mem_size;
-	uint64_t in_buf_mem_address;
-	uint16_t in_buf_mem_size;
-	uint16_t sampling_rate;
-	uint16_t num_in_channels;
-} __packed;
-
-#define VSS_IVPCM_EVT_NOTIFY_V2 0x0001133B
-
-/* Notify event mask indicates output buffer is filled. */
-#define VSS_IVPCM_NOTIFY_MASK_OUTPUT_BUFFER 1
-
-/* Notify event mask indicates input buffer is consumed. */
-#define VSS_IVPCM_NOTIFY_MASK_INPUT_BUFFER 2
-
-/* Notify event mask indicates a timetick */
-#define VSS_IVPCM_NOTIFY_MASK_TIMETICK 4
-
-/* Notify event mask indicates an error occurred in output buffer operation */
-#define VSS_IVPCM_NOTIFY_MASK_OUTPUT_ERROR 8
-
-/* Notify event mask indicates an error occurred in input buffer operation */
-#define VSS_IVPCM_NOTIFY_MASK_INPUT_ERROR 16
-
-
-struct vss_ivpcm_evt_notify_v2_t {
-	uint32_t tap_point;
-	uint32_t notify_mask;
-	uint64_t out_buff_addr;
-	uint64_t in_buff_addr;
-	uint16_t filled_out_size;
-	uint16_t request_buf_size;
-	uint16_t sampling_rate;
-	uint16_t num_out_channels;
-} __packed;
-
-struct cvp_start_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivpcm_cmd_start_v2_t vpcm_start_cmd;
-} __packed;
-
-struct cvp_push_buf_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivpcm_evt_push_buffer_v2_t vpcm_evt_push_buffer;
-} __packed;
-
-#define VSS_IVPCM_CMD_STOP 0x0001100B
-
-struct cvp_create_full_ctl_session_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_create_full_control_session_v2_t cvp_session;
-} __packed;
-
-struct cvp_command {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvp_set_device_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_set_device_v2_t cvp_set_device_v2;
-} __packed;
-
-struct cvp_set_dev_channels_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_topology_set_dev_channels_t cvp_set_channels;
-} __packed;
-
-struct cvp_set_media_format_cmd {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_param_v2_t cvp_set_media_param_v2;
-} __packed;
-
-struct cvp_set_channel_info_cmd_v2 {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_param_channel_info_v2_t
-					cvp_set_ch_info_param_v2;
-} __packed;
-
-struct cvp_set_mfc_config_cmd_v2 {
-	struct apr_hdr hdr;
-	struct vss_icommon_cmd_set_param_mfc_config_v2_t cvp_set_mfc_param_v2;
-} __packed;
-
-struct cvp_set_vp3_data_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvp_set_rx_volume_index_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
-} __packed;
-
-struct cvp_set_rx_volume_step_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivolume_cmd_set_step_t cvp_set_vol_step;
-} __packed;
-
-struct cvp_register_dev_cfg_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_register_device_config_t cvp_dev_cfg_data;
-} __packed;
-
-struct cvp_deregister_dev_cfg_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvp_register_cal_data_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_register_calibration_data_v2_t cvp_cal_data;
-} __packed;
-
-struct cvp_deregister_cal_data_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvp_register_vol_cal_data_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivocproc_cmd_register_volume_cal_data_t cvp_vol_cal_data;
-} __packed;
-
-struct cvp_deregister_vol_cal_data_cmd {
-	struct apr_hdr hdr;
-} __packed;
-
-struct cvp_set_mute_cmd {
-	struct apr_hdr hdr;
-	struct vss_ivolume_cmd_mute_v2_t cvp_set_mute;
-} __packed;
-
-/* CB for up-link packets. */
-typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
-			 uint32_t pkt_len,
-			 uint32_t timestamp,
-			 void *private_data);
-
-/* CB for down-link packets. */
-typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
-			 void *private_data);
-
-/* CB for DTMF RX Detection */
-typedef void (*dtmf_rx_det_cb_fn)(uint8_t *pkt,
-				  char *session,
-				  void *private_data);
-
-typedef void (*voip_ssr_cb) (uint32_t opcode,
-				void *private_data);
-
-typedef void (*hostpcm_cb_fn)(uint8_t *data,
-			   char *session,
-			   void *private_data);
-
-struct mvs_driver_info {
-	uint32_t media_type;
-	uint32_t rate;
-	uint32_t network_type;
-	uint32_t dtx_mode;
-	ul_cb_fn ul_cb;
-	dl_cb_fn dl_cb;
-	voip_ssr_cb ssr_cb;
-	void *private_data;
-	uint32_t evrc_min_rate;
-	uint32_t evrc_max_rate;
-};
-
-struct dtmf_driver_info {
-	dtmf_rx_det_cb_fn dtmf_rx_ul_cb;
-	void *private_data;
-};
-
-struct hostpcm_driver_info {
-	hostpcm_cb_fn hostpcm_evt_cb;
-	void *private_data;
-};
-
-struct incall_rec_info {
-	uint32_t rec_enable;
-	uint32_t rec_mode;
-	uint32_t recording;
-};
-
-struct incall_music_info {
-	uint32_t play_enable;
-	uint32_t playing;
-	int count;
-	int force;
-	uint16_t port_id;
-};
-
-struct share_memory_info {
-	u32			mem_handle;
-	struct share_mem_buf	sh_buf;
-	struct mem_map_table	memtbl;
-};
-
-#define VSS_ISOUNDFOCUS_CMD_SET_SECTORS     0x00013133
-#define VSS_ISOUNDFOCUS_CMD_GET_SECTORS     0x00013134
-#define VSS_ISOUNDFOCUS_RSP_GET_SECTORS     0x00013135
-#define VSS_ISOURCETRACK_CMD_GET_ACTIVITY   0x00013136
-
-struct vss_isoundfocus_cmd_set_sectors_t {
-	uint16_t start_angles[8];
-	uint8_t enables[8];
-	uint16_t gain_step;
-} __packed;
-
-/* Payload of the VSS_ISOUNDFOCUS_RSP_GET_SECTORS response */
-struct vss_isoundfocus_rsp_get_sectors_t {
-	uint16_t start_angles[8];
-	uint8_t enables[8];
-	uint16_t gain_step;
-} __packed;
-
-struct cvp_set_sound_focus_param_cmd_t {
-	struct apr_hdr hdr;
-	struct vss_isoundfocus_cmd_set_sectors_t cvp_set_sound_focus_param;
-} __packed;
-
-/* Payload structure for the VSS_ISOURCETRACK_CMD_GET_ACTIVITY command */
-struct vss_isourcetrack_cmd_get_activity_t {
-	uint32_t mem_handle;
-	uint32_t mem_address_lsw;
-	uint32_t mem_address_msw;
-	uint32_t mem_size;
-} __packed;
-
-struct cvp_get_source_tracking_param_cmd_t {
-	struct apr_hdr hdr;
-	struct vss_isourcetrack_cmd_get_activity_t
-			cvp_get_source_tracking_param;
-} __packed;
-
-/* Structure for the sound activity data */
-struct vss_isourcetrack_activity_data_t {
-	uint8_t voice_active[8];
-	uint16_t talker_doa;
-	uint16_t interferer_doa[3];
-	uint8_t sound_strength[360];
-} __packed;
-
-struct shared_mem_info {
-	uint32_t mem_handle;
-	struct mem_map_table sh_mem_block;
-	struct mem_map_table sh_mem_table;
-};
-
-struct voice_data {
-	int voc_state;/*INIT, CHANGE, RELEASE, RUN */
-
-	/* Shared mem to store decoder and encoder packets */
-	struct share_memory_info	shmem_info;
-
-	wait_queue_head_t mvm_wait;
-	wait_queue_head_t cvs_wait;
-	wait_queue_head_t cvp_wait;
-
-	/* Cache the values related to Rx and Tx devices */
-	struct device_data dev_rx;
-	struct device_data dev_tx;
-
-	/* Cache the values related to Rx and Tx streams */
-	struct stream_data stream_rx;
-	struct stream_data stream_tx;
-
-	u32 mvm_state;
-	u32 cvs_state;
-	u32 cvp_state;
-
-	u32 async_err;
-
-	/* Handle to MVM in the Q6 */
-	u16 mvm_handle;
-	/* Handle to CVS in the Q6 */
-	u16 cvs_handle;
-	/* Handle to CVP in the Q6 */
-	u16 cvp_handle;
-
-	struct mutex lock;
-
-	bool disable_topology;
-
-	uint16_t sidetone_gain;
-	uint8_t tty_mode;
-	/* slowtalk enable value */
-	uint32_t st_enable;
-	uint32_t hd_enable;
-	uint32_t dtmf_rx_detect_en;
-	/* Local Call Hold mode */
-	uint8_t lch_mode;
-
-	struct voice_dev_route_state voc_route_state;
-
-	u32 session_id;
-
-	struct incall_rec_info rec_info;
-
-	struct incall_music_info music_info;
-
-	struct voice_rec_route_state rec_route_state;
-};
-
-struct cal_mem {
-	struct ion_handle *handle;
-	uint32_t phy;
-	void *buf;
-};
-
-#define MAX_VOC_SESSIONS 8
-
-struct common_data {
-	/* these default values are for all devices */
-	uint32_t default_mute_val;
-	uint32_t default_sample_val;
-	uint32_t default_vol_step_val;
-	uint32_t default_vol_ramp_duration_ms;
-	uint32_t default_mute_ramp_duration_ms;
-	bool ec_ref_ext;
-	struct media_format_info ec_media_fmt_info;
-
-	/* APR to MVM in the Q6 */
-	void *apr_q6_mvm;
-	/* APR to CVS in the Q6 */
-	void *apr_q6_cvs;
-	/* APR to CVP in the Q6 */
-	void *apr_q6_cvp;
-
-	struct cal_type_data *cal_data[MAX_VOICE_CAL_TYPES];
-
-	struct mem_map_table cal_mem_map_table;
-	uint32_t cal_mem_handle;
-
-	struct mem_map_table rtac_mem_map_table;
-	uint32_t rtac_mem_handle;
-
-	uint32_t voice_host_pcm_mem_handle;
-
-	struct cal_mem cvp_cal;
-	struct cal_mem cvs_cal;
-
-	struct mutex common_lock;
-
-	struct mvs_driver_info mvs_info;
-
-	struct dtmf_driver_info dtmf_info;
-
-	struct hostpcm_driver_info hostpcm_info;
-
-	struct voice_data voice[MAX_VOC_SESSIONS];
-
-	bool srvcc_rec_flag;
-	bool is_destroy_cvd;
-	char cvd_version[CVD_VERSION_STRING_MAX_SIZE];
-	int cvp_version;
-	bool is_avcs_version_queried;
-	bool is_per_vocoder_cal_enabled;
-	bool is_sound_focus_resp_success;
-	bool is_source_tracking_resp_success;
-	struct vss_isoundfocus_rsp_get_sectors_t soundFocusResponse;
-	struct shared_mem_info source_tracking_sh_mem;
-	struct vss_isourcetrack_activity_data_t sourceTrackingResponse;
-	bool sidetone_enable;
-};
-
-struct voice_session_itr {
-	int cur_idx;
-	int session_idx;
-};
-
-void voc_register_mvs_cb(ul_cb_fn ul_cb,
-			dl_cb_fn dl_cb,
-			voip_ssr_cb ssr_cb,
-			void *private_data);
-
-void voc_register_dtmf_rx_detection_cb(dtmf_rx_det_cb_fn dtmf_rx_ul_cb,
-				       void *private_data);
-
-void voc_config_vocoder(uint32_t media_type,
-			uint32_t rate,
-			uint32_t network_type,
-			uint32_t dtx_mode,
-			uint32_t evrc_min_rate,
-			uint32_t evrc_max_rate);
-
-enum {
-	DEV_RX = 0,
-	DEV_TX,
-};
-
-enum {
-	RX_PATH = 0,
-	TX_PATH,
-	EC_REF_PATH,
-};
-
-#define VOC_PATH_PASSIVE 0
-#define VOC_PATH_FULL 1
-#define VOC_PATH_VOLTE_PASSIVE 2
-#define VOC_PATH_VOICE2_PASSIVE 3
-#define VOC_PATH_QCHAT_PASSIVE 4
-#define VOC_PATH_VOWLAN_PASSIVE 5
-#define VOC_PATH_VOICEMMODE1_PASSIVE 6
-#define VOC_PATH_VOICEMMODE2_PASSIVE 7
-
-#define MAX_SESSION_NAME_LEN 32
-#define VOICE_SESSION_NAME   "Voice session"
-#define VOIP_SESSION_NAME    "VoIP session"
-#define VOLTE_SESSION_NAME   "VoLTE session"
-#define VOICE2_SESSION_NAME  "Voice2 session"
-#define QCHAT_SESSION_NAME   "QCHAT session"
-#define VOWLAN_SESSION_NAME  "VoWLAN session"
-#define VOICEMMODE1_NAME     "VoiceMMode1"
-#define VOICEMMODE2_NAME     "VoiceMMode2"
-
-#define VOICE2_SESSION_VSID_STR      "10DC1000"
-#define QCHAT_SESSION_VSID_STR       "10803000"
-#define VOWLAN_SESSION_VSID_STR      "10002000"
-#define VOICEMMODE1_VSID_STR         "11C05000"
-#define VOICEMMODE2_VSID_STR         "11DC5000"
-#define VOICE_SESSION_VSID           0x10C01000
-#define VOICE2_SESSION_VSID          0x10DC1000
-#define VOLTE_SESSION_VSID           0x10C02000
-#define VOIP_SESSION_VSID            0x10004000
-#define QCHAT_SESSION_VSID           0x10803000
-#define VOWLAN_SESSION_VSID          0x10002000
-#define VOICEMMODE1_VSID             0x11C05000
-#define VOICEMMODE2_VSID             0x11DC5000
-#define ALL_SESSION_VSID             0xFFFFFFFF
-#define VSID_MAX                     ALL_SESSION_VSID
-
-/* called  by alsa driver */
-int voc_set_pp_enable(uint32_t session_id, uint32_t module_id,
-		      uint32_t enable);
-int voc_get_pp_enable(uint32_t session_id, uint32_t module_id);
-int voc_set_hd_enable(uint32_t session_id, uint32_t enable);
-uint8_t voc_get_tty_mode(uint32_t session_id);
-int voc_set_tty_mode(uint32_t session_id, uint8_t tty_mode);
-int voc_start_voice_call(uint32_t session_id);
-int voc_end_voice_call(uint32_t session_id);
-int voc_standby_voice_call(uint32_t session_id);
-int voc_resume_voice_call(uint32_t session_id);
-int voc_set_lch(uint32_t session_id, enum voice_lch_mode lch_mode);
-int voc_set_rx_vol_step(uint32_t session_id, uint32_t dir, uint32_t vol_step,
-			uint32_t ramp_duration);
-int voc_set_tx_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
-		    uint32_t ramp_duration);
-int voc_set_device_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
-			uint32_t ramp_duration);
-int voc_get_rx_device_mute(uint32_t session_id);
-int voc_set_route_flag(uint32_t session_id, uint8_t path_dir, uint8_t set);
-uint8_t voc_get_route_flag(uint32_t session_id, uint8_t path_dir);
-int voc_enable_dtmf_rx_detection(uint32_t session_id, uint32_t enable);
-void voc_disable_dtmf_det_on_active_sessions(void);
-int voc_alloc_cal_shared_memory(void);
-int voc_alloc_voip_shared_memory(void);
-int is_voc_initialized(void);
-int voc_register_vocproc_vol_table(void);
-int voc_deregister_vocproc_vol_table(void);
-int voc_send_cvp_map_vocpcm_memory(uint32_t session_id,
-				   struct mem_map_table *tp_mem_table,
-				   phys_addr_t paddr, uint32_t bufsize);
-int voc_send_cvp_unmap_vocpcm_memory(uint32_t session_id);
-int voc_send_cvp_start_vocpcm(uint32_t session_id,
-			      struct vss_ivpcm_tap_point *vpcm_tp,
-			      uint32_t no_of_tp);
-int voc_send_cvp_vocpcm_push_buf_evt(uint32_t session_id,
-			struct vss_ivpcm_evt_push_buffer_v2_t *push_buff_evt);
-int voc_send_cvp_stop_vocpcm(uint32_t session_id);
-void voc_register_hpcm_evt_cb(hostpcm_cb_fn hostpcm_cb,
-			      void *private_data);
-void voc_deregister_hpcm_evt_cb(void);
-
-int voc_map_rtac_block(struct rtac_cal_block_data *cal_block);
-int voc_unmap_rtac_block(uint32_t *mem_map_handle);
-
-uint32_t voc_get_session_id(char *name);
-
-int voc_start_playback(uint32_t set, uint16_t port_id);
-int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id);
-int voice_get_idx_for_session(u32 session_id);
-int voc_set_ext_ec_ref_port_id(uint16_t port_id, bool state);
-int voc_get_ext_ec_ref_port_id(void);
-int voc_set_ext_ec_ref_media_fmt_info(struct media_format_info *finfo);
-int voc_update_amr_vocoder_rate(uint32_t session_id);
-int voc_disable_device(uint32_t session_id);
-int voc_enable_device(uint32_t session_id);
-void voc_set_destroy_cvd_flag(bool is_destroy_cvd);
-int voc_disable_topology(uint32_t session_id, uint32_t disable);
-int voc_set_device_config(uint32_t session_id, uint8_t path_dir,
-			  struct media_format_info *finfo);
-uint32_t voice_get_topology(uint32_t topology_idx);
-int voc_set_sound_focus(struct sound_focus_param sound_focus_param);
-int voc_get_sound_focus(struct sound_focus_param *soundFocusData);
-int voc_get_source_tracking(struct source_tracking_param *sourceTrackingData);
-int voc_set_afe_sidetone(uint32_t session_id, bool sidetone_enable);
-bool voc_get_afe_sidetone(void);
-#endif
diff --git a/sound/soc/msm/qdsp6v2/rtac.c b/sound/soc/msm/qdsp6v2/rtac.c
deleted file mode 100644
index cd02501..0000000
--- a/sound/soc/msm/qdsp6v2/rtac.c
+++ /dev/null
@@ -1,1924 +0,0 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/msm_audio_calibration.h>
-#include <linux/atomic.h>
-#include <linux/msm_audio_ion.h>
-#include <linux/qdsp6v2/rtac.h>
-#include <linux/compat.h>
-#include <sound/q6asm-v2.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6adm-v2.h>
-#include <sound/apr_audio-v2.h>
-#include "q6voice.h"
-#include "msm-pcm-routing-v2.h"
-#include <sound/adsp_err.h>
-
-
-/* Max size of payload (buf size - apr header) */
-#define MAX_PAYLOAD_SIZE		4076
-#define RTAC_MAX_ACTIVE_VOICE_COMBOS	2
-#define RTAC_MAX_ACTIVE_POPP		8
-#define RTAC_BUF_SIZE			163840
-
-#define TIMEOUT_MS	1000
-
-struct rtac_cal_block_data	rtac_cal[MAX_RTAC_BLOCKS] = {
-/* ADM_RTAC_CAL */
-	{{RTAC_BUF_SIZE, 0, 0, 0}, {0, 0, 0} },
-/* ASM_RTAC_CAL */
-	{{RTAC_BUF_SIZE, 0, 0, 0}, {0, 0, 0} },
-/* VOICE_RTAC_CAL */
-	{{RTAC_BUF_SIZE, 0, 0, 0}, {0, 0, 0} },
-/* AFE_RTAC_CAL */
-	{{RTAC_BUF_SIZE, 0, 0, 0}, {0, 0, 0} }
-};
-
-struct rtac_common_data {
-	atomic_t			usage_count;
-	atomic_t			apr_err_code;
-};
-
-static struct rtac_common_data		rtac_common;
-
-/* APR data */
-struct rtac_apr_data {
-	void			*apr_handle;
-	atomic_t		cmd_state;
-	wait_queue_head_t	cmd_wait;
-};
-
-static struct rtac_apr_data rtac_adm_apr_data;
-static struct rtac_apr_data rtac_asm_apr_data[ASM_ACTIVE_STREAMS_ALLOWED + 1];
-static struct rtac_apr_data	rtac_afe_apr_data;
-static struct rtac_apr_data	rtac_voice_apr_data[RTAC_VOICE_MODES];
-
-/* ADM info & APR */
-static struct rtac_adm		rtac_adm_data;
-static u32			*rtac_adm_buffer;
-
-
-/* ASM APR */
-static u32			*rtac_asm_buffer;
-
-static u32			*rtac_afe_buffer;
-
-/* Voice info & APR */
-struct rtac_voice_data_t {
-	uint32_t	tx_topology_id;
-	uint32_t	rx_topology_id;
-	uint32_t	tx_afe_topology;
-	uint32_t	rx_afe_topology;
-	uint32_t	tx_afe_port;
-	uint32_t	rx_afe_port;
-	uint16_t	cvs_handle;
-	uint16_t	cvp_handle;
-	uint32_t	tx_acdb_id;
-	uint32_t	rx_acdb_id;
-};
-
-struct rtac_voice {
-	uint32_t			num_of_voice_combos;
-	struct rtac_voice_data_t	voice[RTAC_MAX_ACTIVE_VOICE_COMBOS];
-};
-
-struct rtac_afe_user_data {
-	uint32_t	buf_size;
-	uint32_t	cmd_size;
-	uint32_t	port_id;
-	union {
-		struct rtac_afe_set {
-			struct afe_port_cmd_set_param_v2 cmd;
-			struct afe_port_param_data_v2    data;
-		} rtac_afe_set;
-		struct rtac_afe_get {
-			struct afe_port_cmd_get_param_v2 cmd;
-			struct afe_port_param_data_v2    data;
-		} rtac_afe_get;
-	};
-}  __packed;
-
-static struct rtac_voice	rtac_voice_data;
-static u32			*rtac_voice_buffer;
-static u32			voice_session_id[RTAC_MAX_ACTIVE_VOICE_COMBOS];
-
-
-struct mutex			rtac_adm_mutex;
-struct mutex			rtac_adm_apr_mutex;
-struct mutex			rtac_asm_apr_mutex;
-struct mutex			rtac_voice_mutex;
-struct mutex			rtac_voice_apr_mutex;
-struct mutex			rtac_afe_apr_mutex;
-
-int rtac_clear_mapping(uint32_t cal_type)
-{
-	int result = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type >= MAX_RTAC_BLOCKS) {
-		pr_debug("%s: invalid cal type %d\n", __func__, cal_type);
-		result = -EINVAL;
-		goto done;
-	}
-
-	rtac_cal[cal_type].map_data.map_handle = 0;
-done:
-	return result;
-}
-
-int rtac_allocate_cal_buffer(uint32_t cal_type)
-{
-	int result = 0;
-	size_t len;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type >= MAX_RTAC_BLOCKS) {
-		pr_err("%s: cal_type %d is invalid!\n",
-		       __func__, cal_type);
-		result =  -EINVAL;
-		goto done;
-	}
-
-	if (rtac_cal[cal_type].cal_data.paddr != 0) {
-		pr_err("%s: memory already allocated! cal_type %d, paddr 0x%pK\n",
-		       __func__, cal_type, &rtac_cal[cal_type].cal_data.paddr);
-		result = -EPERM;
-		goto done;
-	}
-
-	result = msm_audio_ion_alloc("rtac_client",
-		&rtac_cal[cal_type].map_data.ion_client,
-		&rtac_cal[cal_type].map_data.ion_handle,
-		rtac_cal[cal_type].map_data.map_size,
-		&rtac_cal[cal_type].cal_data.paddr,
-		&len,
-		&rtac_cal[cal_type].cal_data.kvaddr);
-	if (result < 0) {
-		pr_err("%s: ION create client for RTAC failed\n",
-		       __func__);
-		goto done;
-	}
-
-	pr_debug("%s: cal_type %d, paddr 0x%pK, kvaddr 0x%pK, map_size 0x%x\n",
-		__func__, cal_type,
-		&rtac_cal[cal_type].cal_data.paddr,
-		rtac_cal[cal_type].cal_data.kvaddr,
-		rtac_cal[cal_type].map_data.map_size);
-done:
-	return result;
-}
-
-int rtac_free_cal_buffer(uint32_t cal_type)
-{
-	int result = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type >= MAX_RTAC_BLOCKS) {
-		pr_err("%s: cal_type %d is invalid!\n",
-		       __func__, cal_type);
-		result =  -EINVAL;
-		goto done;
-	}
-
-	if (rtac_cal[cal_type].map_data.ion_client == NULL) {
-		pr_debug("%s: cal_type %d not allocated!\n",
-		       __func__, cal_type);
-		goto done;
-	}
-
-	result = msm_audio_ion_free(rtac_cal[cal_type].map_data.ion_client,
-				rtac_cal[cal_type].map_data.ion_handle);
-	if (result < 0) {
-		pr_err("%s: ION free for RTAC failed! cal_type %d, paddr 0x%pK\n",
-		       __func__, cal_type, &rtac_cal[cal_type].cal_data.paddr);
-		goto done;
-	}
-
-	rtac_cal[cal_type].map_data.map_handle = 0;
-	rtac_cal[cal_type].map_data.ion_client = NULL;
-	rtac_cal[cal_type].map_data.ion_handle = NULL;
-	rtac_cal[cal_type].cal_data.size = 0;
-	rtac_cal[cal_type].cal_data.kvaddr = 0;
-	rtac_cal[cal_type].cal_data.paddr = 0;
-done:
-	return result;
-}
-
-int rtac_map_cal_buffer(uint32_t cal_type)
-{
-	int result = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type >= MAX_RTAC_BLOCKS) {
-		pr_err("%s: cal_type %d is invalid!\n",
-		       __func__, cal_type);
-		result =  -EINVAL;
-		goto done;
-	}
-
-	if (rtac_cal[cal_type].map_data.map_handle != 0) {
-		pr_err("%s: already mapped cal_type %d\n",
-			__func__, cal_type);
-		result =  -EPERM;
-		goto done;
-	}
-
-	if (rtac_cal[cal_type].cal_data.paddr == 0) {
-		pr_err("%s: physical address is NULL cal_type %d\n",
-			__func__, cal_type);
-		result =  -EPERM;
-		goto done;
-	}
-
-	switch (cal_type) {
-	case ADM_RTAC_CAL:
-		result = adm_map_rtac_block(&rtac_cal[cal_type]);
-		break;
-	case ASM_RTAC_CAL:
-		result = q6asm_map_rtac_block(&rtac_cal[cal_type]);
-		break;
-	case VOICE_RTAC_CAL:
-		result = voc_map_rtac_block(&rtac_cal[cal_type]);
-		break;
-	case AFE_RTAC_CAL:
-		result = afe_map_rtac_block(&rtac_cal[cal_type]);
-		break;
-	}
-	if (result < 0) {
-		pr_err("%s: map RTAC failed! cal_type %d\n",
-		       __func__, cal_type);
-		goto done;
-	}
-done:
-	return result;
-}
-
-int rtac_unmap_cal_buffer(uint32_t cal_type)
-{
-	int result = 0;
-
-	pr_debug("%s\n", __func__);
-
-	if (cal_type >= MAX_RTAC_BLOCKS) {
-		pr_err("%s: cal_type %d is invalid!\n",
-		       __func__, cal_type);
-		result =  -EINVAL;
-		goto done;
-	}
-
-	if (rtac_cal[cal_type].map_data.map_handle == 0) {
-		pr_debug("%s: nothing to unmap cal_type %d\n",
-			__func__, cal_type);
-		goto done;
-	}
-
-	switch (cal_type) {
-	case ADM_RTAC_CAL:
-		result = adm_unmap_rtac_block(
-			&rtac_cal[cal_type].map_data.map_handle);
-		break;
-	case ASM_RTAC_CAL:
-		result = q6asm_unmap_rtac_block(
-			&rtac_cal[cal_type].map_data.map_handle);
-		break;
-	case VOICE_RTAC_CAL:
-		result = voc_unmap_rtac_block(
-			&rtac_cal[cal_type].map_data.map_handle);
-		break;
-	case AFE_RTAC_CAL:
-		result = afe_unmap_rtac_block(
-			&rtac_cal[cal_type].map_data.map_handle);
-		break;
-	}
-	if (result < 0) {
-		pr_err("%s: unmap RTAC failed! cal_type %d\n",
-		       __func__, cal_type);
-		goto done;
-	}
-done:
-	return result;
-}
-
-static int rtac_open(struct inode *inode, struct file *f)
-{
-	int result = 0;
-
-	pr_debug("%s\n", __func__);
-
-	atomic_inc(&rtac_common.usage_count);
-	return result;
-}
-
-static int rtac_release(struct inode *inode, struct file *f)
-{
-	int result = 0;
-	int result2 = 0;
-	int i;
-
-	pr_debug("%s\n", __func__);
-
-	atomic_dec(&rtac_common.usage_count);
-	pr_debug("%s: ref count %d!\n", __func__,
-		atomic_read(&rtac_common.usage_count));
-
-	if (atomic_read(&rtac_common.usage_count) > 0)
-		goto done;
-
-	for (i = 0; i < MAX_RTAC_BLOCKS; i++) {
-		result2 = rtac_unmap_cal_buffer(i);
-		if (result2 < 0) {
-			pr_err("%s: unmap buffer failed! error %d!\n",
-				__func__, result2);
-			result = result2;
-		}
-
-		result2 = rtac_free_cal_buffer(i);
-		if (result2 < 0) {
-			pr_err("%s: free buffer failed! error %d!\n",
-				__func__, result2);
-			result = result2;
-		}
-	}
-done:
-	return result;
-}
-
-
-/* ADM Info */
-void add_popp(u32 dev_idx, u32 port_id, u32 popp_id)
-{
-	u32 i = 0;
-
-	for (; i < rtac_adm_data.device[dev_idx].num_of_popp; i++)
-		if (rtac_adm_data.device[dev_idx].popp[i].popp == popp_id)
-			goto done;
-
-	if (rtac_adm_data.device[dev_idx].num_of_popp ==
-			RTAC_MAX_ACTIVE_POPP) {
-		pr_err("%s, Max POPP!\n", __func__);
-		goto done;
-	}
-	rtac_adm_data.device[dev_idx].popp[
-		rtac_adm_data.device[dev_idx].num_of_popp].popp = popp_id;
-	rtac_adm_data.device[dev_idx].popp[
-		rtac_adm_data.device[dev_idx].num_of_popp].popp_topology =
-		q6asm_get_asm_topology(popp_id);
-	rtac_adm_data.device[dev_idx].popp[
-		rtac_adm_data.device[dev_idx].num_of_popp++].app_type =
-		q6asm_get_asm_app_type(popp_id);
-
-	pr_debug("%s: popp_id = %d, popp topology = 0x%x, popp app type = 0x%x\n",
-		__func__,
-		rtac_adm_data.device[dev_idx].popp[
-			rtac_adm_data.device[dev_idx].num_of_popp - 1].popp,
-		rtac_adm_data.device[dev_idx].popp[
-		rtac_adm_data.device[dev_idx].num_of_popp - 1].popp_topology,
-		rtac_adm_data.device[dev_idx].popp[
-		rtac_adm_data.device[dev_idx].num_of_popp - 1].app_type);
-done:
-	return;
-}
-
-void rtac_update_afe_topology(u32 port_id)
-{
-	u32 i = 0;
-
-	mutex_lock(&rtac_adm_mutex);
-	for (i = 0; i < rtac_adm_data.num_of_dev; i++) {
-		if (rtac_adm_data.device[i].afe_port == port_id) {
-			rtac_adm_data.device[i].afe_topology =
-						afe_get_topology(port_id);
-			pr_debug("%s: port_id = 0x%x topology_id = 0x%x copp_id = %d\n",
-				 __func__, port_id,
-				 rtac_adm_data.device[i].afe_topology,
-				 rtac_adm_data.device[i].copp);
-		}
-	}
-	mutex_unlock(&rtac_adm_mutex);
-}
-
-void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id,
-			 u32 app_type, u32 acdb_id)
-{
-	u32 i = 0;
-
-	pr_debug("%s: num rtac devices %d port_id = %d, copp_id = %d\n",
-		__func__, rtac_adm_data.num_of_dev, port_id, copp_id);
-
-	mutex_lock(&rtac_adm_mutex);
-	if (rtac_adm_data.num_of_dev == RTAC_MAX_ACTIVE_DEVICES) {
-		pr_err("%s, Can't add anymore RTAC devices!\n", __func__);
-		goto done;
-	}
-
-	/* Check if device already added */
-	if (rtac_adm_data.num_of_dev != 0) {
-		for (; i < rtac_adm_data.num_of_dev; i++) {
-			if (rtac_adm_data.device[i].afe_port == port_id &&
-			    rtac_adm_data.device[i].copp == copp_id) {
-				add_popp(i, port_id, popp_id);
-				goto done;
-			}
-			if (rtac_adm_data.device[i].num_of_popp ==
-						RTAC_MAX_ACTIVE_POPP) {
-				pr_err("%s, Max POPP!\n", __func__);
-				goto done;
-			}
-		}
-	}
-
-	/* Add device */
-	rtac_adm_data.num_of_dev++;
-
-	rtac_adm_data.device[i].topology_id =
-		adm_get_topology_for_port_from_copp_id(port_id, copp_id);
-	rtac_adm_data.device[i].afe_topology =
-		afe_get_topology(port_id);
-	rtac_adm_data.device[i].afe_port = port_id;
-	rtac_adm_data.device[i].copp = copp_id;
-	rtac_adm_data.device[i].app_type = app_type;
-	rtac_adm_data.device[i].acdb_dev_id = acdb_id;
-	rtac_adm_data.device[i].popp[
-		rtac_adm_data.device[i].num_of_popp].popp = popp_id;
-	rtac_adm_data.device[i].popp[
-		rtac_adm_data.device[i].num_of_popp].popp_topology =
-		q6asm_get_asm_topology(popp_id);
-	rtac_adm_data.device[i].popp[
-		rtac_adm_data.device[i].num_of_popp++].app_type =
-		q6asm_get_asm_app_type(popp_id);
-
-	pr_debug("%s: topology = 0x%x, afe_topology = 0x%x, port_id = %d, copp_id = %d, app id = 0x%x, acdb id = %d, popp_id = %d, popp topology = 0x%x, popp app type = 0x%x\n",
-		__func__,
-		rtac_adm_data.device[i].topology_id,
-		rtac_adm_data.device[i].afe_topology,
-		rtac_adm_data.device[i].afe_port,
-		rtac_adm_data.device[i].copp,
-		rtac_adm_data.device[i].app_type,
-		rtac_adm_data.device[i].acdb_dev_id,
-		rtac_adm_data.device[i].popp[
-			rtac_adm_data.device[i].num_of_popp - 1].popp,
-		rtac_adm_data.device[i].popp[
-		rtac_adm_data.device[i].num_of_popp - 1].popp_topology,
-		rtac_adm_data.device[i].popp[
-		rtac_adm_data.device[i].num_of_popp - 1].app_type);
-done:
-	mutex_unlock(&rtac_adm_mutex);
-}
-
-static void shift_adm_devices(u32 dev_idx)
-{
-	for (; dev_idx < rtac_adm_data.num_of_dev; dev_idx++) {
-		memcpy(&rtac_adm_data.device[dev_idx],
-			&rtac_adm_data.device[dev_idx + 1],
-			sizeof(rtac_adm_data.device[dev_idx]));
-		memset(&rtac_adm_data.device[dev_idx + 1], 0,
-			   sizeof(rtac_adm_data.device[dev_idx]));
-	}
-}
-
-static void shift_popp(u32 copp_idx, u32 popp_idx)
-{
-	for (; popp_idx < rtac_adm_data.device[copp_idx].num_of_popp;
-							popp_idx++) {
-		memcpy(&rtac_adm_data.device[copp_idx].popp[popp_idx].popp,
-			&rtac_adm_data.device[copp_idx].popp[popp_idx + 1].
-			popp, sizeof(uint32_t));
-		memcpy(&rtac_adm_data.device[copp_idx].popp[popp_idx].
-			popp_topology,
-			&rtac_adm_data.device[copp_idx].popp[popp_idx + 1].
-			popp_topology,
-			sizeof(uint32_t));
-		memset(&rtac_adm_data.device[copp_idx].popp[popp_idx + 1].
-			popp, 0, sizeof(uint32_t));
-		memset(&rtac_adm_data.device[copp_idx].popp[popp_idx + 1].
-			popp_topology, 0, sizeof(uint32_t));
-	}
-}
-
-void rtac_remove_adm_device(u32 port_id, u32 copp_id)
-{
-	s32 i;
-
-	pr_debug("%s: num rtac devices %d port_id = %d, copp_id = %d\n",
-		__func__, rtac_adm_data.num_of_dev, port_id, copp_id);
-
-	mutex_lock(&rtac_adm_mutex);
-	/* look for device */
-	for (i = 0; i < rtac_adm_data.num_of_dev; i++) {
-		if (rtac_adm_data.device[i].afe_port == port_id &&
-		    rtac_adm_data.device[i].copp == copp_id) {
-			memset(&rtac_adm_data.device[i], 0,
-				   sizeof(rtac_adm_data.device[i]));
-			rtac_adm_data.num_of_dev--;
-
-			if (rtac_adm_data.num_of_dev >= 1) {
-				shift_adm_devices(i);
-				break;
-			}
-		}
-	}
-
-	mutex_unlock(&rtac_adm_mutex);
-}
-
-void rtac_remove_popp_from_adm_devices(u32 popp_id)
-{
-	s32 i, j;
-
-	pr_debug("%s: popp_id = %d\n", __func__, popp_id);
-
-	mutex_lock(&rtac_adm_mutex);
-	for (i = 0; i < rtac_adm_data.num_of_dev; i++) {
-		for (j = 0; j < rtac_adm_data.device[i].num_of_popp; j++) {
-			if (rtac_adm_data.device[i].popp[j].popp ==
-								popp_id) {
-				rtac_adm_data.device[i].popp[j].popp = 0;
-				rtac_adm_data.device[i].popp[j].
-					popp_topology = 0;
-				rtac_adm_data.device[i].num_of_popp--;
-				shift_popp(i, j);
-			}
-		}
-	}
-	mutex_unlock(&rtac_adm_mutex);
-}
-
-
-/* Voice Info */
-static void set_rtac_voice_data(int idx, u32 cvs_handle, u32 cvp_handle,
-					u32 rx_afe_port, u32 tx_afe_port,
-					u32 rx_acdb_id, u32 tx_acdb_id,
-					u32 session_id)
-{
-	rtac_voice_data.voice[idx].tx_topology_id =
-		voice_get_topology(CVP_VOC_TX_TOPOLOGY_CAL);
-	rtac_voice_data.voice[idx].rx_topology_id =
-		voice_get_topology(CVP_VOC_RX_TOPOLOGY_CAL);
-	rtac_voice_data.voice[idx].tx_afe_topology =
-		afe_get_topology(tx_afe_port);
-	rtac_voice_data.voice[idx].rx_afe_topology =
-		afe_get_topology(rx_afe_port);
-	rtac_voice_data.voice[idx].tx_afe_port = tx_afe_port;
-	rtac_voice_data.voice[idx].rx_afe_port = rx_afe_port;
-	rtac_voice_data.voice[idx].tx_acdb_id = tx_acdb_id;
-	rtac_voice_data.voice[idx].rx_acdb_id = rx_acdb_id;
-	rtac_voice_data.voice[idx].cvs_handle = cvs_handle;
-	rtac_voice_data.voice[idx].cvp_handle = cvp_handle;
-	pr_debug("%s\n%s: %x\n%s: %d %s: %d\n%s: %d %s: %d\n %s: %d\n %s: %d\n%s: %d %s: %d\n%s",
-		 "<---- Voice Data Info ---->", "Session id", session_id,
-		 "cvs_handle", cvs_handle, "cvp_handle", cvp_handle,
-		 "rx_afe_topology", rtac_voice_data.voice[idx].rx_afe_topology,
-		 "tx_afe_topology", rtac_voice_data.voice[idx].tx_afe_topology,
-		 "rx_afe_port", rx_afe_port, "tx_afe_port", tx_afe_port,
-		 "rx_acdb_id", rx_acdb_id, "tx_acdb_id", tx_acdb_id,
-		 "<-----------End----------->");
-
-	/* Store session ID for voice RTAC */
-	voice_session_id[idx] = session_id;
-}
-
-void rtac_add_voice(u32 cvs_handle, u32 cvp_handle, u32 rx_afe_port,
-			u32 tx_afe_port, u32 rx_acdb_id, u32 tx_acdb_id,
-			u32 session_id)
-{
-	u32 i = 0;
-
-	pr_debug("%s\n", __func__);
-	mutex_lock(&rtac_voice_mutex);
-
-	if (rtac_voice_data.num_of_voice_combos ==
-			RTAC_MAX_ACTIVE_VOICE_COMBOS) {
-		pr_err("%s, Can't add anymore RTAC devices!\n", __func__);
-		goto done;
-	}
-
-	/* Check if device already added */
-	if (rtac_voice_data.num_of_voice_combos != 0) {
-		for (; i < rtac_voice_data.num_of_voice_combos; i++) {
-			if (rtac_voice_data.voice[i].cvs_handle ==
-							cvs_handle) {
-				set_rtac_voice_data(i, cvs_handle, cvp_handle,
-					rx_afe_port, tx_afe_port, rx_acdb_id,
-					tx_acdb_id, session_id);
-				goto done;
-			}
-		}
-	}
-
-	/* Add device */
-	rtac_voice_data.num_of_voice_combos++;
-	set_rtac_voice_data(i, cvs_handle, cvp_handle,
-				rx_afe_port, tx_afe_port,
-				rx_acdb_id, tx_acdb_id,
-				session_id);
-done:
-	mutex_unlock(&rtac_voice_mutex);
-}
-
-static void shift_voice_devices(u32 idx)
-{
-	for (; idx < rtac_voice_data.num_of_voice_combos - 1; idx++) {
-		memcpy(&rtac_voice_data.voice[idx],
-			&rtac_voice_data.voice[idx + 1],
-			sizeof(rtac_voice_data.voice[idx]));
-		voice_session_id[idx] = voice_session_id[idx + 1];
-	}
-}
-
-void rtac_remove_voice(u32 cvs_handle)
-{
-	u32 i = 0;
-
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&rtac_voice_mutex);
-	/* look for device */
-	for (i = 0; i < rtac_voice_data.num_of_voice_combos; i++) {
-		if (rtac_voice_data.voice[i].cvs_handle == cvs_handle) {
-			shift_voice_devices(i);
-			rtac_voice_data.num_of_voice_combos--;
-			memset(&rtac_voice_data.voice[
-				rtac_voice_data.num_of_voice_combos], 0,
-				sizeof(rtac_voice_data.voice
-				[rtac_voice_data.num_of_voice_combos]));
-			voice_session_id[rtac_voice_data.num_of_voice_combos]
-				= 0;
-			break;
-		}
-	}
-	mutex_unlock(&rtac_voice_mutex);
-}
-
-static u32 get_voice_session_id_cvs(u32 cvs_handle)
-{
-	u32 i;
-
-	for (i = 0; i < rtac_voice_data.num_of_voice_combos; i++) {
-		if (rtac_voice_data.voice[i].cvs_handle == cvs_handle)
-			return voice_session_id[i];
-	}
-
-	pr_err("%s: No voice index for CVS handle %d found returning 0\n",
-	       __func__, cvs_handle);
-	return 0;
-}
-
-static u32 get_voice_session_id_cvp(u32 cvp_handle)
-{
-	u32 i;
-
-	for (i = 0; i < rtac_voice_data.num_of_voice_combos; i++) {
-		if (rtac_voice_data.voice[i].cvp_handle == cvp_handle)
-			return voice_session_id[i];
-	}
-
-	pr_err("%s: No voice index for CVP handle %d found returning 0\n",
-	       __func__, cvp_handle);
-	return 0;
-}
-
-static int get_voice_index(u32 mode, u32 handle)
-{
-	if (mode == RTAC_CVP)
-		return voice_get_idx_for_session(
-			get_voice_session_id_cvp(handle));
-	if (mode == RTAC_CVS)
-		return voice_get_idx_for_session(
-			get_voice_session_id_cvs(handle));
-
-	pr_err("%s: Invalid mode %d, returning 0\n",
-	       __func__, mode);
-	return 0;
-}
-
-
-/* ADM APR */
-void rtac_set_adm_handle(void *handle)
-{
-	pr_debug("%s: handle = %pK\n", __func__, handle);
-
-	mutex_lock(&rtac_adm_apr_mutex);
-	rtac_adm_apr_data.apr_handle = handle;
-	mutex_unlock(&rtac_adm_apr_mutex);
-}
-
-bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size)
-{
-	pr_debug("%s:cmd_state = %d\n", __func__,
-			atomic_read(&rtac_adm_apr_data.cmd_state));
-	if (atomic_read(&rtac_adm_apr_data.cmd_state) != 1)
-		return false;
-
-	pr_debug("%s\n", __func__);
-	if (payload_size == sizeof(uint32_t))
-		atomic_set(&rtac_common.apr_err_code, payload[0]);
-	else if (payload_size == (2*sizeof(uint32_t)))
-		atomic_set(&rtac_common.apr_err_code, payload[1]);
-
-	atomic_set(&rtac_adm_apr_data.cmd_state, 0);
-	wake_up(&rtac_adm_apr_data.cmd_wait);
-	return true;
-}
-
-int send_adm_apr(void *buf, u32 opcode)
-{
-	s32	result;
-	u32	user_buf_size = 0;
-	u32	bytes_returned = 0;
-	u32	copp_id;
-	u32	payload_size;
-	u32	data_size = 0;
-	int	copp_idx;
-	int	port_idx;
-	struct apr_hdr	adm_params;
-
-	pr_debug("%s\n", __func__);
-
-	if (rtac_cal[ADM_RTAC_CAL].map_data.ion_handle == NULL) {
-		result = rtac_allocate_cal_buffer(ADM_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: allocate buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (rtac_cal[ADM_RTAC_CAL].map_data.map_handle == 0) {
-		result = rtac_map_cal_buffer(ADM_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: map buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (copy_from_user(&user_buf_size, (void *)buf,
-						sizeof(user_buf_size))) {
-		pr_err("%s: Copy from user failed! buf = 0x%pK\n",
-		       __func__, buf);
-		goto done;
-	}
-	if (user_buf_size <= 0) {
-		pr_err("%s: Invalid buffer size = %d\n",
-			__func__, user_buf_size);
-		goto done;
-	}
-
-	if (copy_from_user(&payload_size, buf + sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy payload size from user buffer\n",
-			__func__);
-		goto done;
-	}
-
-	if (copy_from_user(&copp_id, buf + 2 * sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy port id from user buffer\n",
-			__func__);
-		goto done;
-	}
-
-	if (adm_get_indexes_from_copp_id(copp_id, &copp_idx, &port_idx) != 0) {
-		pr_err("%s: Copp Id-%d is not active\n", __func__, copp_id);
-		goto done;
-	}
-
-	mutex_lock(&rtac_adm_apr_mutex);
-	if (rtac_adm_apr_data.apr_handle == NULL) {
-		pr_err("%s: APR not initialized\n", __func__);
-		result = -EINVAL;
-		goto err;
-	}
-
-	if (opcode == ADM_CMD_SET_PP_PARAMS_V5) {
-		/* set payload size to in-band payload */
-		/* set data size to actual out of band payload size */
-		data_size = payload_size - 4 * sizeof(u32);
-		if (data_size > rtac_cal[ADM_RTAC_CAL].map_data.map_size) {
-			pr_err("%s: Invalid data size = %d\n",
-				__func__, data_size);
-			result = -EINVAL;
-			goto err;
-		}
-		payload_size = 4 * sizeof(u32);
-
-		/* Copy buffer to out-of-band payload */
-		if (copy_from_user((void *)
-				rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
-				buf + 7 * sizeof(u32), data_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-		/* set payload size in packet */
-		rtac_adm_buffer[8] = data_size;
-	} else {
-		if (payload_size > MAX_PAYLOAD_SIZE) {
-			pr_err("%s: Invalid payload size = %d\n",
-				__func__, payload_size);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy buffer to in-band payload */
-		if (copy_from_user(rtac_adm_buffer +
-				sizeof(adm_params)/sizeof(u32),
-				buf + 3 * sizeof(u32), payload_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-	}
-
-	/* Pack header */
-	adm_params.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(20), APR_PKT_VER);
-	adm_params.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-		payload_size);
-	adm_params.src_svc = APR_SVC_ADM;
-	adm_params.src_domain = APR_DOMAIN_APPS;
-	adm_params.src_port = copp_id;
-	adm_params.dest_svc = APR_SVC_ADM;
-	adm_params.dest_domain = APR_DOMAIN_ADSP;
-	adm_params.dest_port = copp_id;
-	adm_params.token = port_idx << 16 | copp_idx;
-	adm_params.opcode = opcode;
-
-	/* fill for out-of-band */
-	rtac_adm_buffer[5] =
-		lower_32_bits(rtac_cal[ADM_RTAC_CAL].cal_data.paddr);
-	rtac_adm_buffer[6] =
-		msm_audio_populate_upper_32_bits(
-				rtac_cal[ADM_RTAC_CAL].cal_data.paddr);
-	rtac_adm_buffer[7] = rtac_cal[ADM_RTAC_CAL].map_data.map_handle;
-
-	memcpy(rtac_adm_buffer, &adm_params, sizeof(adm_params));
-	atomic_set(&rtac_adm_apr_data.cmd_state, 1);
-
-	pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n",
-		__func__, opcode,
-		&rtac_cal[ADM_RTAC_CAL].cal_data.paddr);
-
-	result = apr_send_pkt(rtac_adm_apr_data.apr_handle,
-					(uint32_t *)rtac_adm_buffer);
-	if (result < 0) {
-		pr_err("%s: Set params failed copp = %d\n", __func__, copp_id);
-		goto err;
-	}
-	/* Wait for the callback */
-	result = wait_event_timeout(rtac_adm_apr_data.cmd_wait,
-		(atomic_read(&rtac_adm_apr_data.cmd_state) == 0),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!result) {
-		pr_err("%s: Set params timed out copp = %d\n", __func__,
-			copp_id);
-		goto err;
-	}
-	if (atomic_read(&rtac_common.apr_err_code)) {
-		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
-			__func__, adsp_err_get_err_str(atomic_read(
-			&rtac_common.apr_err_code)),
-			opcode);
-		result = adsp_err_get_lnx_err_code(
-					atomic_read(
-					&rtac_common.apr_err_code));
-		goto err;
-	}
-
-	if (opcode == ADM_CMD_GET_PP_PARAMS_V5) {
-		bytes_returned = ((u32 *)rtac_cal[ADM_RTAC_CAL].cal_data.
-			kvaddr)[2] + 3 * sizeof(u32);
-
-		if (bytes_returned > user_buf_size) {
-			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
-				__func__, user_buf_size, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-
-		if (copy_to_user(buf, (void *)
-				rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
-				bytes_returned)) {
-			pr_err("%s: Could not copy buffer to user,size = %d\n",
-				__func__, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-	} else {
-		bytes_returned = data_size;
-	}
-	mutex_unlock(&rtac_adm_apr_mutex);
-done:
-	return bytes_returned;
-err:
-	mutex_unlock(&rtac_adm_apr_mutex);
-	return result;
-}
-
-
-/* ASM APR */
-void rtac_set_asm_handle(u32 session_id, void *handle)
-{
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&rtac_asm_apr_mutex);
-	rtac_asm_apr_data[session_id].apr_handle = handle;
-	mutex_unlock(&rtac_asm_apr_mutex);
-}
-
-bool rtac_make_asm_callback(u32 session_id, uint32_t *payload,
-	u32 payload_size)
-{
-	if (atomic_read(&rtac_asm_apr_data[session_id].cmd_state) != 1)
-		return false;
-
-	pr_debug("%s\n", __func__);
-	if (payload_size == sizeof(uint32_t))
-		atomic_set(&rtac_common.apr_err_code, payload[0]);
-	else if (payload_size == (2*sizeof(uint32_t)))
-		atomic_set(&rtac_common.apr_err_code, payload[1]);
-
-	atomic_set(&rtac_asm_apr_data[session_id].cmd_state, 0);
-	wake_up(&rtac_asm_apr_data[session_id].cmd_wait);
-	return true;
-}
-
-int send_rtac_asm_apr(void *buf, u32 opcode)
-{
-	s32 result;
-	u32 user_buf_size = 0;
-	u32 bytes_returned = 0;
-	u32 session_id = 0;
-	u32 payload_size;
-	u32 data_size = 0;
-	struct apr_hdr asm_params;
-
-	pr_debug("%s\n", __func__);
-
-	if (rtac_cal[ASM_RTAC_CAL].map_data.ion_handle == NULL) {
-		result = rtac_allocate_cal_buffer(ASM_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: allocate buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (rtac_cal[ASM_RTAC_CAL].map_data.map_handle == 0) {
-		result = rtac_map_cal_buffer(ASM_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: map buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (copy_from_user(&user_buf_size, (void *)buf,
-						sizeof(user_buf_size))) {
-		pr_err("%s: Copy from user failed! buf = 0x%pK\n",
-		       __func__, buf);
-		goto done;
-	}
-	if (user_buf_size <= 0) {
-		pr_err("%s: Invalid buffer size = %d\n",
-			__func__, user_buf_size);
-		goto done;
-	}
-
-	if (copy_from_user(&payload_size, buf + sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy payload size from user buffer\n",
-			__func__);
-		goto done;
-	}
-
-	if (copy_from_user(&session_id, buf + 2 * sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy session id from user buffer\n",
-			__func__);
-		goto done;
-	}
-	if (session_id >= (ASM_ACTIVE_STREAMS_ALLOWED + 1)) {
-		pr_err("%s: Invalid Session = %d\n", __func__, session_id);
-		goto done;
-	}
-
-	mutex_lock(&rtac_asm_apr_mutex);
-	if (rtac_asm_apr_data[session_id].apr_handle == NULL) {
-		pr_err("%s: APR not initialized\n", __func__);
-		result = -EINVAL;
-		goto err;
-	}
-
-	if (opcode == ASM_STREAM_CMD_SET_PP_PARAMS_V2) {
-		/* set payload size to in-band payload */
-		/* set data size to actual out of band payload size */
-		data_size = payload_size - 4 * sizeof(u32);
-		if (data_size > rtac_cal[ASM_RTAC_CAL].map_data.map_size) {
-			pr_err("%s: Invalid data size = %d\n",
-				__func__, data_size);
-			result = -EINVAL;
-			goto err;
-		}
-		payload_size = 4 * sizeof(u32);
-
-		/* Copy buffer to out-of-band payload */
-		if (copy_from_user((void *)
-				rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
-				buf + 7 * sizeof(u32), data_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-		/* set payload size in packet */
-		rtac_asm_buffer[8] = data_size;
-
-	} else {
-		if (payload_size > MAX_PAYLOAD_SIZE) {
-			pr_err("%s: Invalid payload size = %d\n",
-				__func__, payload_size);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy buffer to in-band payload */
-		if (copy_from_user(rtac_asm_buffer +
-				sizeof(asm_params)/sizeof(u32),
-				buf + 3 * sizeof(u32), payload_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-	}
-
-	/* Pack header */
-	asm_params.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(20), APR_PKT_VER);
-	asm_params.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-		payload_size);
-	asm_params.src_svc = q6asm_get_apr_service_id(session_id);
-	asm_params.src_domain = APR_DOMAIN_APPS;
-	asm_params.src_port = (session_id << 8) | 0x0001;
-	asm_params.dest_svc = APR_SVC_ASM;
-	asm_params.dest_domain = APR_DOMAIN_ADSP;
-	asm_params.dest_port = (session_id << 8) | 0x0001;
-	asm_params.token = session_id;
-	asm_params.opcode = opcode;
-
-	/* fill for out-of-band */
-	rtac_asm_buffer[5] =
-		lower_32_bits(rtac_cal[ASM_RTAC_CAL].cal_data.paddr);
-	rtac_asm_buffer[6] =
-		msm_audio_populate_upper_32_bits(
-				rtac_cal[ASM_RTAC_CAL].cal_data.paddr);
-	rtac_asm_buffer[7] = rtac_cal[ASM_RTAC_CAL].map_data.map_handle;
-
-	memcpy(rtac_asm_buffer, &asm_params, sizeof(asm_params));
-	atomic_set(&rtac_asm_apr_data[session_id].cmd_state, 1);
-
-	pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n",
-		__func__, opcode,
-		&rtac_cal[ASM_RTAC_CAL].cal_data.paddr);
-
-	result = apr_send_pkt(rtac_asm_apr_data[session_id].apr_handle,
-				(uint32_t *)rtac_asm_buffer);
-	if (result < 0) {
-		pr_err("%s: Set params failed session = %d\n",
-			__func__, session_id);
-		goto err;
-	}
-
-	/* Wait for the callback */
-	result = wait_event_timeout(rtac_asm_apr_data[session_id].cmd_wait,
-		(atomic_read(&rtac_asm_apr_data[session_id].cmd_state) == 0),
-		5 * HZ);
-	if (!result) {
-		pr_err("%s: Set params timed out session = %d\n",
-			__func__, session_id);
-		goto err;
-	}
-	if (atomic_read(&rtac_common.apr_err_code)) {
-		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
-			__func__, adsp_err_get_err_str(atomic_read(
-			&rtac_common.apr_err_code)),
-			opcode);
-		result = adsp_err_get_lnx_err_code(
-					atomic_read(
-					&rtac_common.apr_err_code));
-		goto err;
-	}
-
-	if (opcode == ASM_STREAM_CMD_GET_PP_PARAMS_V2) {
-		bytes_returned = ((u32 *)rtac_cal[ASM_RTAC_CAL].cal_data.
-			kvaddr)[2] + 3 * sizeof(u32);
-
-		if (bytes_returned > user_buf_size) {
-			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
-				__func__, user_buf_size, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-
-		if (copy_to_user(buf, (void *)
-				rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
-				bytes_returned)) {
-			pr_err("%s: Could not copy buffer to user,size = %d\n",
-				 __func__, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-	} else {
-		bytes_returned = data_size;
-	}
-	mutex_unlock(&rtac_asm_apr_mutex);
-done:
-	return bytes_returned;
-err:
-	mutex_unlock(&rtac_asm_apr_mutex);
-	return result;
-}
-
-/* AFE APR */
-void rtac_set_afe_handle(void *handle)
-{
-	mutex_lock(&rtac_afe_apr_mutex);
-	rtac_afe_apr_data.apr_handle = handle;
-	mutex_unlock(&rtac_afe_apr_mutex);
-}
-
-bool rtac_make_afe_callback(uint32_t *payload, uint32_t payload_size)
-{
-	pr_debug("%s:cmd_state = %d\n", __func__,
-			atomic_read(&rtac_afe_apr_data.cmd_state));
-	if (atomic_read(&rtac_afe_apr_data.cmd_state) != 1)
-		return false;
-
-	if (payload_size == sizeof(uint32_t))
-		atomic_set(&rtac_common.apr_err_code, payload[0]);
-	else if (payload_size == (2*sizeof(uint32_t)))
-		atomic_set(&rtac_common.apr_err_code, payload[1]);
-
-	atomic_set(&rtac_afe_apr_data.cmd_state, 0);
-	wake_up(&rtac_afe_apr_data.cmd_wait);
-	return true;
-}
-
-static int fill_afe_apr_hdr(struct apr_hdr *apr_hdr, uint32_t port,
-			 uint32_t opcode, uint32_t apr_msg_size)
-{
-	if (apr_hdr == NULL) {
-		pr_err("%s: invalid APR pointer", __func__);
-		return -EINVAL;
-	}
-
-	apr_hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
-	apr_hdr->pkt_size = apr_msg_size;
-	apr_hdr->src_svc = APR_SVC_AFE;
-	apr_hdr->src_domain = APR_DOMAIN_APPS;
-	apr_hdr->src_port = 0;
-	apr_hdr->dest_svc = APR_SVC_AFE;
-	apr_hdr->dest_domain = APR_DOMAIN_ADSP;
-	apr_hdr->dest_port = 0;
-	apr_hdr->token = port;
-	apr_hdr->opcode = opcode;
-
-	return 0;
-
-}
-static int send_rtac_afe_apr(void *buf, uint32_t opcode)
-{
-	int32_t result;
-	uint32_t bytes_returned = 0;
-	uint32_t port_index = 0;
-	uint32_t apr_msg_size = 0;
-	struct rtac_afe_user_data user_afe_buf;
-
-	pr_debug("%s\n", __func__);
-
-	if (rtac_cal[AFE_RTAC_CAL].map_data.ion_handle == NULL) {
-		result = rtac_allocate_cal_buffer(AFE_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: allocate buffer failed! ret = %d\n",
-				__func__, result);
-			goto done;
-		}
-	}
-
-	if (rtac_cal[AFE_RTAC_CAL].map_data.map_handle == 0) {
-		result = rtac_map_cal_buffer(AFE_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: map buffer failed! ret = %d\n",
-				__func__, result);
-			goto done;
-		}
-	}
-
-	if (copy_from_user(&user_afe_buf, (void *)buf,
-		sizeof(struct rtac_afe_user_data))) {
-		pr_err("%s: Copy from user failed! buf = 0x%pK\n",
-		       __func__, buf);
-		goto done;
-	}
-
-	if (user_afe_buf.buf_size <= 0) {
-		pr_err("%s: Invalid buffer size = %d\n",
-			__func__, user_afe_buf.buf_size);
-		goto done;
-	}
-
-	port_index = q6audio_get_port_index(user_afe_buf.port_id);
-	if (port_index >= AFE_MAX_PORTS) {
-		pr_err("%s: Invalid AFE port = 0x%x\n",
-		       __func__, user_afe_buf.port_id);
-		goto done;
-	}
-
-	mutex_lock(&rtac_afe_apr_mutex);
-	if (rtac_afe_apr_data.apr_handle == NULL) {
-		pr_err("%s: APR not initialized\n", __func__);
-		result = -EINVAL;
-		goto err;
-	}
-	if (opcode == AFE_PORT_CMD_SET_PARAM_V2) {
-		struct afe_port_cmd_set_param_v2 *afe_set_apr_msg;
-
-		/* set data size to actual out of band payload size */
-		if (user_afe_buf.rtac_afe_set.cmd.payload_size >
-			rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
-			pr_err("%s: Invalid data size = %d\n",
-				   __func__,
-				   user_afe_buf.rtac_afe_set.cmd.payload_size);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy buffer to out-of-band payload */
-		if (copy_from_user((void *)
-				rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
-				buf+offsetof(struct rtac_afe_user_data,
-				rtac_afe_set.data),
-				user_afe_buf.rtac_afe_set.cmd.payload_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy AFE APR Message */
-		afe_set_apr_msg = (struct afe_port_cmd_set_param_v2 *)
-				((u8 *)rtac_afe_buffer +
-				sizeof(struct apr_hdr));
-		if (copy_from_user((void *)
-				afe_set_apr_msg,
-				buf + offsetof(struct rtac_afe_user_data,
-				rtac_afe_set.cmd),
-				sizeof(struct afe_port_cmd_set_param_v2))) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-
-		afe_set_apr_msg->payload_address_lsw =
-			lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
-		afe_set_apr_msg->payload_address_msw =
-				msm_audio_populate_upper_32_bits(
-					rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
-		afe_set_apr_msg->mem_map_handle =
-				rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
-
-		apr_msg_size = sizeof(struct apr_hdr) +
-				sizeof(struct afe_port_cmd_set_param_v2);
-
-	} else {
-		struct afe_port_cmd_get_param_v2 *afe_get_apr_msg;
-
-		if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
-			pr_err("%s: Invalid payload size = %d\n",
-				__func__, user_afe_buf.cmd_size);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy buffer to in-band payload */
-		afe_get_apr_msg = (struct afe_port_cmd_get_param_v2 *)
-					((u8 *) rtac_afe_buffer +
-					sizeof(struct apr_hdr));
-		if (copy_from_user((void *)afe_get_apr_msg,
-				buf+offsetof(struct rtac_afe_user_data,
-				rtac_afe_get.cmd),
-			sizeof(struct afe_port_cmd_get_param_v2))) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-
-		afe_get_apr_msg->payload_address_lsw =
-			lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
-		afe_get_apr_msg->payload_address_msw =
-				msm_audio_populate_upper_32_bits(
-					rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
-		afe_get_apr_msg->mem_map_handle =
-				rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
-		afe_get_apr_msg->payload_size -= sizeof(struct apr_hdr);
-		apr_msg_size = sizeof(struct apr_hdr) +
-				sizeof(struct afe_port_cmd_get_param_v2);
-	}
-
-	fill_afe_apr_hdr((struct apr_hdr *) rtac_afe_buffer,
-			port_index, opcode, apr_msg_size);
-
-	atomic_set(&rtac_afe_apr_data.cmd_state, 1);
-
-	pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n",
-		__func__, opcode,
-		&rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
-
-	result = apr_send_pkt(rtac_afe_apr_data.apr_handle,
-					(uint32_t *)rtac_afe_buffer);
-	if (result < 0) {
-		pr_err("%s: Set params failed port = 0x%x, ret = %d\n",
-			__func__, user_afe_buf.port_id, result);
-		goto err;
-	}
-	/* Wait for the callback */
-	result = wait_event_timeout(rtac_afe_apr_data.cmd_wait,
-		(atomic_read(&rtac_afe_apr_data.cmd_state) == 0),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!result) {
-		pr_err("%s: Set params timed out port = 0x%x, ret = %d\n",
-			__func__, user_afe_buf.port_id, result);
-		goto err;
-	}
-	if (atomic_read(&rtac_common.apr_err_code)) {
-		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
-			__func__, adsp_err_get_err_str(atomic_read(
-			&rtac_common.apr_err_code)),
-			opcode);
-		result = adsp_err_get_lnx_err_code(
-					atomic_read(
-					&rtac_common.apr_err_code));
-		goto err;
-	}
-
-	if (opcode == AFE_PORT_CMD_GET_PARAM_V2) {
-		struct afe_port_param_data_v2 *get_resp;
-
-		get_resp = (struct afe_port_param_data_v2 *)
-				rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr;
-
-		bytes_returned = get_resp->param_size +
-				sizeof(struct afe_port_param_data_v2);
-
-		if (bytes_returned > user_afe_buf.buf_size) {
-			pr_err("%s: user size = 0x%x, returned size = 0x%x\n",
-				__func__, user_afe_buf.buf_size,
-				bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-
-		if (copy_to_user(buf, (void *)
-				rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
-				bytes_returned)) {
-			pr_err("%s: Could not copy buffer to user,size = %d\n",
-				__func__, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-	} else {
-		bytes_returned = user_afe_buf.rtac_afe_set.cmd.payload_size;
-	}
-	mutex_unlock(&rtac_afe_apr_mutex);
-done:
-	return bytes_returned;
-err:
-	mutex_unlock(&rtac_afe_apr_mutex);
-	return result;
-}
-
-/* Voice APR */
-void rtac_set_voice_handle(u32 mode, void *handle)
-{
-	pr_debug("%s\n", __func__);
-
-	mutex_lock(&rtac_voice_apr_mutex);
-	rtac_voice_apr_data[mode].apr_handle = handle;
-	mutex_unlock(&rtac_voice_apr_mutex);
-}
-
-bool rtac_make_voice_callback(u32 mode, uint32_t *payload, u32 payload_size)
-{
-	if ((atomic_read(&rtac_voice_apr_data[mode].cmd_state) != 1) ||
-		(mode >= RTAC_VOICE_MODES))
-		return false;
-
-	pr_debug("%s\n", __func__);
-	if (payload_size == sizeof(uint32_t))
-		atomic_set(&rtac_common.apr_err_code, payload[0]);
-	else if (payload_size == (2*sizeof(uint32_t)))
-		atomic_set(&rtac_common.apr_err_code, payload[1]);
-
-	atomic_set(&rtac_voice_apr_data[mode].cmd_state, 0);
-	wake_up(&rtac_voice_apr_data[mode].cmd_wait);
-	return true;
-}
-
-int send_voice_apr(u32 mode, void *buf, u32 opcode)
-{
-	s32 result;
-	u32 user_buf_size = 0;
-	u32 bytes_returned = 0;
-	u32 payload_size;
-	u32 dest_port;
-	u32 data_size = 0;
-	struct apr_hdr voice_params;
-
-	pr_debug("%s\n", __func__);
-
-	if (rtac_cal[VOICE_RTAC_CAL].map_data.ion_handle == NULL) {
-		result = rtac_allocate_cal_buffer(VOICE_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: allocate buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (rtac_cal[VOICE_RTAC_CAL].map_data.map_handle == 0) {
-		result = rtac_map_cal_buffer(VOICE_RTAC_CAL);
-		if (result < 0) {
-			pr_err("%s: map buffer failed!",
-				__func__);
-			goto done;
-		}
-	}
-
-	if (copy_from_user(&user_buf_size, (void *)buf,
-						sizeof(user_buf_size))) {
-		pr_err("%s: Copy from user failed! buf = 0x%pK\n",
-		       __func__, buf);
-		goto done;
-	}
-	if (user_buf_size <= 0) {
-		pr_err("%s: Invalid buffer size = %d\n",
-			__func__, user_buf_size);
-		goto done;
-	}
-
-	if (copy_from_user(&payload_size, buf + sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy payload size from user buffer\n",
-			__func__);
-		goto done;
-	}
-
-	if (copy_from_user(&dest_port, buf + 2 * sizeof(u32), sizeof(u32))) {
-		pr_err("%s: Could not copy port id from user buffer\n",
-			__func__);
-		goto done;
-	}
-
-	if ((mode != RTAC_CVP) && (mode != RTAC_CVS)) {
-		pr_err("%s: Invalid Mode for APR, mode = %d\n",
-			__func__, mode);
-		goto done;
-	}
-
-	mutex_lock(&rtac_voice_apr_mutex);
-	if (rtac_voice_apr_data[mode].apr_handle == NULL) {
-		pr_err("%s: APR not initialized\n", __func__);
-		result = -EINVAL;
-		goto err;
-	}
-
-	if (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) {
-		/* set payload size to in-band payload */
-		/* set data size to actual out of band payload size */
-		data_size = payload_size - 4 * sizeof(u32);
-		if (data_size > rtac_cal[VOICE_RTAC_CAL].map_data.map_size) {
-			pr_err("%s: Invalid data size = %d\n",
-				__func__, data_size);
-			result = -EINVAL;
-			goto err;
-		}
-		payload_size = 4 * sizeof(u32);
-
-		/* Copy buffer to out-of-band payload */
-		if (copy_from_user((void *)
-				rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
-				buf + 7 * sizeof(u32), data_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-		/* set payload size in packet */
-		rtac_voice_buffer[8] = data_size;
-	} else {
-		if (payload_size > MAX_PAYLOAD_SIZE) {
-			pr_err("%s: Invalid payload size = %d\n",
-					__func__, payload_size);
-			result = -EINVAL;
-			goto err;
-		}
-
-		/* Copy buffer to in-band payload */
-		if (copy_from_user(rtac_voice_buffer +
-				sizeof(voice_params)/sizeof(u32),
-				buf + 3 * sizeof(u32), payload_size)) {
-			pr_err("%s: Could not copy payload from user buffer\n",
-				__func__);
-			result = -EINVAL;
-			goto err;
-		}
-	}
-
-	/* Pack header */
-	voice_params.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
-		APR_HDR_LEN(20), APR_PKT_VER);
-	voice_params.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
-		payload_size);
-	voice_params.src_svc = 0;
-	voice_params.src_domain = APR_DOMAIN_APPS;
-	voice_params.src_port = get_voice_index(mode, dest_port);
-	voice_params.dest_svc = 0;
-	voice_params.dest_domain = APR_DOMAIN_MODEM;
-	voice_params.dest_port = (u16)dest_port;
-	voice_params.token = (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) ?
-				     VOC_RTAC_SET_PARAM_TOKEN :
-				     0;
-	voice_params.opcode = opcode;
-
-	/* fill for out-of-band */
-	rtac_voice_buffer[5] = rtac_cal[VOICE_RTAC_CAL].map_data.map_handle;
-	rtac_voice_buffer[6] =
-		lower_32_bits(rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
-	rtac_voice_buffer[7] =
-		msm_audio_populate_upper_32_bits(
-				rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
-
-	memcpy(rtac_voice_buffer, &voice_params, sizeof(voice_params));
-	atomic_set(&rtac_voice_apr_data[mode].cmd_state, 1);
-
-	pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n",
-		__func__, opcode,
-		&rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
-
-	result = apr_send_pkt(rtac_voice_apr_data[mode].apr_handle,
-					(uint32_t *)rtac_voice_buffer);
-	if (result < 0) {
-		pr_err("%s: apr_send_pkt failed opcode = %x\n",
-			__func__, opcode);
-		goto err;
-	}
-	/* Wait for the callback */
-	result = wait_event_timeout(rtac_voice_apr_data[mode].cmd_wait,
-		(atomic_read(&rtac_voice_apr_data[mode].cmd_state) == 0),
-		msecs_to_jiffies(TIMEOUT_MS));
-	if (!result) {
-		pr_err("%s: apr_send_pkt timed out opcode = %x\n",
-			__func__, opcode);
-		goto err;
-	}
-	if (atomic_read(&rtac_common.apr_err_code)) {
-		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
-			__func__, adsp_err_get_err_str(atomic_read(
-			&rtac_common.apr_err_code)),
-			opcode);
-		result = adsp_err_get_lnx_err_code(
-					atomic_read(
-					&rtac_common.apr_err_code));
-		goto err;
-	}
-
-	if (opcode == VSS_ICOMMON_CMD_GET_PARAM_V2) {
-		bytes_returned = ((u32 *)rtac_cal[VOICE_RTAC_CAL].cal_data.
-			kvaddr)[2] + 3 * sizeof(u32);
-
-		if (bytes_returned > user_buf_size) {
-			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
-				__func__, user_buf_size, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-
-		if (copy_to_user(buf, (void *)
-				rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
-				bytes_returned)) {
-			pr_err("%s: Could not copy buffer to user, size = %d\n",
-				 __func__, bytes_returned);
-			result = -EINVAL;
-			goto err;
-		}
-	} else {
-		bytes_returned = data_size;
-	}
-	mutex_unlock(&rtac_voice_apr_mutex);
-done:
-	return bytes_returned;
-err:
-	mutex_unlock(&rtac_voice_apr_mutex);
-	return result;
-}
-
-void get_rtac_adm_data(struct rtac_adm *adm_data)
-{
-	mutex_lock(&rtac_adm_mutex);
-	memcpy(adm_data, &rtac_adm_data, sizeof(struct rtac_adm));
-	mutex_unlock(&rtac_adm_mutex);
-}
-
-
-static long rtac_ioctl_shared(struct file *f,
-		unsigned int cmd, void *arg)
-{
-	int result = 0;
-
-	if (!arg) {
-		pr_err("%s: No data sent to driver!\n", __func__);
-		result = -EFAULT;
-		goto done;
-	}
-
-	switch (cmd) {
-	case AUDIO_GET_RTAC_ADM_INFO: {
-		mutex_lock(&rtac_adm_mutex);
-		if (copy_to_user((void *)arg, &rtac_adm_data,
-						sizeof(rtac_adm_data))) {
-			pr_err("%s: copy_to_user failed for AUDIO_GET_RTAC_ADM_INFO\n",
-					__func__);
-			mutex_unlock(&rtac_adm_mutex);
-			return -EFAULT;
-		}
-		result = sizeof(rtac_adm_data);
-		mutex_unlock(&rtac_adm_mutex);
-		break;
-	}
-	case AUDIO_GET_RTAC_VOICE_INFO: {
-		mutex_lock(&rtac_voice_mutex);
-		if (copy_to_user((void *)arg, &rtac_voice_data,
-						sizeof(rtac_voice_data))) {
-			pr_err("%s: copy_to_user failed for AUDIO_GET_RTAC_VOICE_INFO\n",
-					__func__);
-			mutex_unlock(&rtac_voice_mutex);
-			return -EFAULT;
-		}
-		result = sizeof(rtac_voice_data);
-		mutex_unlock(&rtac_voice_mutex);
-		break;
-	}
-
-	case AUDIO_GET_RTAC_ADM_CAL:
-		result = send_adm_apr((void *)arg, ADM_CMD_GET_PP_PARAMS_V5);
-		break;
-	case AUDIO_SET_RTAC_ADM_CAL:
-		result = send_adm_apr((void *)arg, ADM_CMD_SET_PP_PARAMS_V5);
-		break;
-	case AUDIO_GET_RTAC_ASM_CAL:
-		result = send_rtac_asm_apr((void *)arg,
-			ASM_STREAM_CMD_GET_PP_PARAMS_V2);
-		break;
-	case AUDIO_SET_RTAC_ASM_CAL:
-		result = send_rtac_asm_apr((void *)arg,
-			ASM_STREAM_CMD_SET_PP_PARAMS_V2);
-		break;
-	case AUDIO_GET_RTAC_CVS_CAL:
-		result = send_voice_apr(RTAC_CVS, (void *) arg,
-					VSS_ICOMMON_CMD_GET_PARAM_V2);
-		break;
-	case AUDIO_SET_RTAC_CVS_CAL:
-		result = send_voice_apr(RTAC_CVS, (void *) arg,
-					VSS_ICOMMON_CMD_SET_PARAM_V2);
-		break;
-	case AUDIO_GET_RTAC_CVP_CAL:
-		result = send_voice_apr(RTAC_CVP, (void *) arg,
-					VSS_ICOMMON_CMD_GET_PARAM_V2);
-		break;
-	case AUDIO_SET_RTAC_CVP_CAL:
-		result = send_voice_apr(RTAC_CVP, (void *) arg,
-					VSS_ICOMMON_CMD_SET_PARAM_V2);
-		break;
-	case AUDIO_GET_RTAC_AFE_CAL:
-		result = send_rtac_afe_apr((void *)arg,
-			AFE_PORT_CMD_GET_PARAM_V2);
-		break;
-	case AUDIO_SET_RTAC_AFE_CAL:
-		result = send_rtac_afe_apr((void *)arg,
-			AFE_PORT_CMD_SET_PARAM_V2);
-		break;
-	default:
-		pr_err("%s: Invalid IOCTL, command = %d!\n",
-		       __func__, cmd);
-		result = -EINVAL;
-	}
-done:
-	return result;
-}
-
-static long rtac_ioctl(struct file *f,
-		unsigned int cmd, unsigned long arg)
-{
-	int result = 0;
-
-	if (!arg) {
-		pr_err("%s: No data sent to driver!\n", __func__);
-		result = -EFAULT;
-	} else {
-		result = rtac_ioctl_shared(f, cmd, (void __user *)arg);
-	}
-
-	return result;
-}
-
-#ifdef CONFIG_COMPAT
-#define AUDIO_GET_RTAC_ADM_INFO_32   _IOR(CAL_IOCTL_MAGIC, 207, compat_uptr_t)
-#define AUDIO_GET_RTAC_VOICE_INFO_32 _IOR(CAL_IOCTL_MAGIC, 208, compat_uptr_t)
-#define AUDIO_GET_RTAC_ADM_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 209, compat_uptr_t)
-#define AUDIO_SET_RTAC_ADM_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 210, compat_uptr_t)
-#define AUDIO_GET_RTAC_ASM_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 211, compat_uptr_t)
-#define AUDIO_SET_RTAC_ASM_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 212, compat_uptr_t)
-#define AUDIO_GET_RTAC_CVS_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 213, compat_uptr_t)
-#define AUDIO_SET_RTAC_CVS_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 214, compat_uptr_t)
-#define AUDIO_GET_RTAC_CVP_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 215, compat_uptr_t)
-#define AUDIO_SET_RTAC_CVP_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 216, compat_uptr_t)
-#define AUDIO_GET_RTAC_AFE_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 217, compat_uptr_t)
-#define AUDIO_SET_RTAC_AFE_CAL_32 _IOWR(CAL_IOCTL_MAGIC, 218, compat_uptr_t)
-
-static long rtac_compat_ioctl(struct file *f,
-		unsigned int cmd, unsigned long arg)
-{
-	int result = 0;
-
-	if (!arg) {
-		pr_err("%s: No data sent to driver!\n", __func__);
-		result = -EINVAL;
-		goto done;
-	}
-
-	switch (cmd) {
-	case AUDIO_GET_RTAC_ADM_INFO_32:
-		cmd = AUDIO_GET_RTAC_ADM_INFO;
-		goto process;
-	case AUDIO_GET_RTAC_VOICE_INFO_32:
-		cmd = AUDIO_GET_RTAC_VOICE_INFO;
-		goto process;
-	case AUDIO_GET_RTAC_AFE_CAL_32:
-		cmd = AUDIO_GET_RTAC_AFE_CAL;
-		goto process;
-	case AUDIO_SET_RTAC_AFE_CAL_32:
-		cmd = AUDIO_SET_RTAC_AFE_CAL;
-		goto process;
-	case AUDIO_GET_RTAC_ADM_CAL_32:
-		cmd = AUDIO_GET_RTAC_ADM_CAL;
-		goto process;
-	case AUDIO_SET_RTAC_ADM_CAL_32:
-		cmd = AUDIO_SET_RTAC_ADM_CAL;
-		goto process;
-	case AUDIO_GET_RTAC_ASM_CAL_32:
-		cmd = AUDIO_GET_RTAC_ASM_CAL;
-		goto process;
-	case AUDIO_SET_RTAC_ASM_CAL_32:
-		cmd =  AUDIO_SET_RTAC_ASM_CAL;
-		goto process;
-	case AUDIO_GET_RTAC_CVS_CAL_32:
-		cmd = AUDIO_GET_RTAC_CVS_CAL;
-		goto process;
-	case AUDIO_SET_RTAC_CVS_CAL_32:
-		cmd = AUDIO_SET_RTAC_CVS_CAL;
-		goto process;
-	case AUDIO_GET_RTAC_CVP_CAL_32:
-		cmd =  AUDIO_GET_RTAC_CVP_CAL;
-		goto process;
-	case AUDIO_SET_RTAC_CVP_CAL_32:
-		cmd = AUDIO_SET_RTAC_CVP_CAL;
-process:
-		result = rtac_ioctl_shared(f, cmd, compat_ptr(arg));
-		break;
-	default:
-		result = -EINVAL;
-		pr_err("%s: Invalid IOCTL, command = %d!\n",
-		       __func__, cmd);
-		break;
-	}
-done:
-	return result;
-}
-#else
-#define rtac_compat_ioctl NULL
-#endif
-
-static const struct file_operations rtac_fops = {
-	.owner = THIS_MODULE,
-	.open = rtac_open,
-	.release = rtac_release,
-	.unlocked_ioctl = rtac_ioctl,
-	.compat_ioctl = rtac_compat_ioctl,
-};
-
-struct miscdevice rtac_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_rtac",
-	.fops	= &rtac_fops,
-};
-
-static int __init rtac_init(void)
-{
-	int i = 0;
-
-	/* Driver */
-	atomic_set(&rtac_common.usage_count, 0);
-	atomic_set(&rtac_common.apr_err_code, 0);
-
-	/* ADM */
-	memset(&rtac_adm_data, 0, sizeof(rtac_adm_data));
-	rtac_adm_apr_data.apr_handle = NULL;
-	atomic_set(&rtac_adm_apr_data.cmd_state, 0);
-	init_waitqueue_head(&rtac_adm_apr_data.cmd_wait);
-	mutex_init(&rtac_adm_mutex);
-	mutex_init(&rtac_adm_apr_mutex);
-
-	rtac_adm_buffer = kzalloc(
-		rtac_cal[ADM_RTAC_CAL].map_data.map_size, GFP_KERNEL);
-	if (rtac_adm_buffer == NULL)
-		goto nomem;
-
-	/* ASM */
-	for (i = 0; i < ASM_ACTIVE_STREAMS_ALLOWED+1; i++) {
-		rtac_asm_apr_data[i].apr_handle = NULL;
-		atomic_set(&rtac_asm_apr_data[i].cmd_state, 0);
-		init_waitqueue_head(&rtac_asm_apr_data[i].cmd_wait);
-	}
-	mutex_init(&rtac_asm_apr_mutex);
-
-	rtac_asm_buffer = kzalloc(
-		rtac_cal[ASM_RTAC_CAL].map_data.map_size, GFP_KERNEL);
-	if (rtac_asm_buffer == NULL) {
-		kzfree(rtac_adm_buffer);
-		goto nomem;
-	}
-
-	/* AFE */
-	rtac_afe_apr_data.apr_handle = NULL;
-	atomic_set(&rtac_afe_apr_data.cmd_state, 0);
-	init_waitqueue_head(&rtac_afe_apr_data.cmd_wait);
-	mutex_init(&rtac_afe_apr_mutex);
-
-	rtac_afe_buffer = kzalloc(
-		rtac_cal[AFE_RTAC_CAL].map_data.map_size, GFP_KERNEL);
-	if (rtac_afe_buffer == NULL) {
-		kzfree(rtac_adm_buffer);
-		kzfree(rtac_asm_buffer);
-		goto nomem;
-	}
-
-	/* Voice */
-	memset(&rtac_voice_data, 0, sizeof(rtac_voice_data));
-	for (i = 0; i < RTAC_VOICE_MODES; i++) {
-		rtac_voice_apr_data[i].apr_handle = NULL;
-		atomic_set(&rtac_voice_apr_data[i].cmd_state, 0);
-		init_waitqueue_head(&rtac_voice_apr_data[i].cmd_wait);
-	}
-	mutex_init(&rtac_voice_mutex);
-	mutex_init(&rtac_voice_apr_mutex);
-
-	rtac_voice_buffer = kzalloc(
-		rtac_cal[VOICE_RTAC_CAL].map_data.map_size, GFP_KERNEL);
-	if (rtac_voice_buffer == NULL) {
-		kzfree(rtac_adm_buffer);
-		kzfree(rtac_asm_buffer);
-		kzfree(rtac_afe_buffer);
-		goto nomem;
-	}
-
-	return misc_register(&rtac_misc);
-nomem:
-	return -ENOMEM;
-}
-
-module_init(rtac_init);
-
-MODULE_DESCRIPTION("SoC QDSP6v2 Real-Time Audio Calibration driver");
-MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/msm/sdm660-common.c b/sound/soc/msm/sdm660-common.c
deleted file mode 100644
index 16f137e..0000000
--- a/sound/soc/msm/sdm660-common.c
+++ /dev/null
@@ -1,3224 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/input.h>
-#include <linux/of_gpio.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/of_device.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/pcm_params.h>
-#include <sound/q6afe-v2.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "sdm660-common.h"
-#include "sdm660-internal.h"
-#include "sdm660-external.h"
-#include "../codecs/sdm660_cdc/msm-analog-cdc.h"
-#include "../codecs/wsa881x.h"
-
-#define DRV_NAME "sdm660-asoc-snd"
-
-#define MSM_INT_DIGITAL_CODEC "msm-dig-codec"
-#define PMIC_INT_ANALOG_CODEC "analog-codec"
-
-#define DEV_NAME_STR_LEN  32
-#define DEFAULT_MCLK_RATE 9600000
-
-struct dev_config {
-	u32 sample_rate;
-	u32 bit_format;
-	u32 channels;
-};
-
-enum {
-	DP_RX_IDX,
-	EXT_DISP_RX_IDX_MAX,
-};
-
-bool codec_reg_done;
-
-/* TDM default config */
-static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	}
-};
-
-/* TDM default config */
-static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	}
-};
-
-/* Default configuration of external display BE */
-static struct dev_config ext_disp_rx_cfg[] = {
-	[DP_RX_IDX] =   {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-static struct dev_config usb_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-static struct dev_config usb_tx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 1,
-};
-
-enum {
-	PRIM_MI2S = 0,
-	SEC_MI2S,
-	TERT_MI2S,
-	QUAT_MI2S,
-	MI2S_MAX,
-};
-
-enum {
-	PRIM_AUX_PCM = 0,
-	SEC_AUX_PCM,
-	TERT_AUX_PCM,
-	QUAT_AUX_PCM,
-	AUX_PCM_MAX,
-};
-
-enum {
-	PCM_I2S_SEL_PRIM = 0,
-	PCM_I2S_SEL_SEC,
-	PCM_I2S_SEL_TERT,
-	PCM_I2S_SEL_QUAT,
-	PCM_I2S_SEL_MAX,
-};
-
-struct mi2s_conf {
-	struct mutex lock;
-	u32 ref_cnt;
-	u32 msm_is_mi2s_master;
-	u32 msm_is_ext_mclk;
-};
-
-static u32 mi2s_ebit_clk[MI2S_MAX] = {
-	Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT
-};
-
-struct msm_wsa881x_dev_info {
-	struct device_node *of_node;
-	u32 index;
-};
-static struct snd_soc_aux_dev *msm_aux_dev;
-static struct snd_soc_codec_conf *msm_codec_conf;
-
-static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active);
-
-static struct wcd_mbhc_config mbhc_cfg = {
-	.read_fw_bin = false,
-	.calibration = NULL,
-	.detect_extn_cable = true,
-	.mono_stero_detection = false,
-	.swap_gnd_mic = NULL,
-	.hs_ext_micbias = true,
-	.key_code[0] = KEY_MEDIA,
-	.key_code[1] = KEY_VOICECOMMAND,
-	.key_code[2] = KEY_VOLUMEUP,
-	.key_code[3] = KEY_VOLUMEDOWN,
-	.key_code[4] = 0,
-	.key_code[5] = 0,
-	.key_code[6] = 0,
-	.key_code[7] = 0,
-	.linein_th = 5000,
-	.moisture_en = false,
-	.mbhc_micbias = 0,
-	.anc_micbias = 0,
-	.enable_anc_mic_detect = false,
-};
-
-static struct dev_config proxy_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-/* Default configuration of MI2S channels */
-static struct dev_config mi2s_rx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config mi2s_tx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_rx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_tx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static char const *ch_text[] = {"Two", "Three", "Four", "Five",
-					"Six", "Seven", "Eight"};
-static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
-static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_16",
-				      "KHZ_32", "KHZ_44P1", "KHZ_48",
-				      "KHZ_96", "KHZ_192"};
-static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
-					  "S32_LE"};
-static char const *mi2s_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
-					  "S32_LE"};
-static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
-				    "Five", "Six", "Seven", "Eight"};
-static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
-static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
-					     "KHZ_44P1", "KHZ_48", "KHZ_96",
-					     "KHZ_192", "KHZ_352P8", "KHZ_384"};
-static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
-					"KHZ_16", "KHZ_22P05",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_96", "KHZ_192", "KHZ_384"};
-static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE"};
-static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
-						  "KHZ_192"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_format, mi2s_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
-				ext_disp_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
-
-static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	}
-};
-
-static struct afe_clk_set mi2s_mclk[MI2S_MAX] = {
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_MCLK_3,
-		Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_MCLK_4,
-		Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_MCLK_1,
-		Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_MCLK_2,
-		Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	}
-};
-
-static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
-
-static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
-
-	return 0;
-}
-
-static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-
-	return 1;
-}
-
-static int tdm_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int tdm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 8;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
-			    struct tdm_port *port)
-{
-	if (port) {
-		if (strnstr(kcontrol->id.name, "PRI",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_PRI;
-		} else if (strnstr(kcontrol->id.name, "SEC",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_SEC;
-		} else if (strnstr(kcontrol->id.name, "TERT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_TERT;
-		} else if (strnstr(kcontrol->id.name, "QUAT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_QUAT;
-		} else {
-			pr_err("%s: unsupported mode in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-
-		if (strnstr(kcontrol->id.name, "RX_0",
-		    sizeof(kcontrol->id.name)) ||
-		    strnstr(kcontrol->id.name, "TX_0",
-		    sizeof(kcontrol->id.name))) {
-			port->channel = TDM_0;
-		} else if (strnstr(kcontrol->id.name, "RX_1",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_1",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_1;
-		} else if (strnstr(kcontrol->id.name, "RX_2",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_2",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_2;
-		} else if (strnstr(kcontrol->id.name, "RX_3",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_3",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_3;
-		} else if (strnstr(kcontrol->id.name, "RX_4",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_4",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_4;
-		} else if (strnstr(kcontrol->id.name, "RX_5",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_5",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_5;
-		} else if (strnstr(kcontrol->id.name, "RX_6",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_6",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_6;
-		} else if (strnstr(kcontrol->id.name, "RX_7",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_7",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_7;
-		} else {
-			pr_err("%s: unsupported channel in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-	} else
-		return -EINVAL;
-	return 0;
-}
-
-static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_rx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_tx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_get_format(int value)
-{
-	int format = 0;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int tdm_get_format_val(int format)
-{
-	int value = 0;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 2;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int mi2s_get_format(int value)
-{
-	int format = 0;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int mi2s_get_format_value(int format)
-{
-	int value = 0;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		value = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 3;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_rx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_tx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-
-		ucontrol->value.enumerated.item[0] =
-			tdm_rx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] =
-			tdm_tx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int aux_pcm_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 0:
-	default:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int aux_pcm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
-		    sizeof("PRIM_AUX_PCM")))
-		idx = PRIM_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
-			 sizeof("SEC_AUX_PCM")))
-		idx = SEC_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
-			 sizeof("TERT_AUX_PCM")))
-		idx = TERT_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
-			 sizeof("QUAT_AUX_PCM")))
-		idx = QUAT_AUX_PCM;
-	else {
-		pr_err("%s: unsupported port: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_rx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_tx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
-	    sizeof("PRIM_MI2S_RX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
-		 sizeof("SEC_MI2S_RX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
-		 sizeof("TERT_MI2S_RX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
-		 sizeof("QUAT_MI2S_RX")))
-		idx = QUAT_MI2S;
-	else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
-		 sizeof("PRIM_MI2S_TX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
-		 sizeof("SEC_MI2S_TX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
-		 sizeof("TERT_MI2S_TX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
-		 sizeof("QUAT_MI2S_TX")))
-		idx = QUAT_MI2S;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int mi2s_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int mi2s_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].bit_format =
-		mi2s_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d] _tx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_tx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_format_value(mi2s_tx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		idx, mi2s_tx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].bit_format =
-		mi2s_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d] _rx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_rx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_format_value(mi2s_rx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		idx, mi2s_rx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_rx_ch  = %d\n", __func__,
-		 usb_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_rx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
-		 usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 9:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 8:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 7:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_rx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_tx_ch  = %d\n", __func__,
-		 usb_tx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_tx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	default:
-		sample_rate_val = 6;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
-		 usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 9:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 8:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 7:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_tx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "Display Port RX",
-			 sizeof("Display Port RX")))
-		idx = DP_RX_IDX;
-	else {
-		pr_err("%s: unsupported BE: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].bit_format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.integer.value[0] =
-			ext_disp_rx_cfg[idx].channels - 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ext_disp_rx_cfg[idx].channels =
-			ucontrol->value.integer.value[0] + 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-	return 1;
-}
-
-static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].sample_rate) {
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 2;
-		break;
-
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 1;
-		break;
-
-	case SAMPLING_RATE_48KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].sample_rate);
-
-	return 0;
-}
-
-static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 2:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 1:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
-		 __func__, ucontrol->value.integer.value[0], idx,
-		 ext_disp_rx_cfg[idx].sample_rate);
-	return 0;
-}
-
-const struct snd_kcontrol_new msm_common_snd_controls[] = {
-	SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
-			proxy_rx_ch_get, proxy_rx_ch_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Format", prim_mi2s_rx_format,
-			mi2s_rx_format_get,
-			mi2s_rx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Format", sec_mi2s_rx_format,
-			mi2s_rx_format_get,
-			mi2s_rx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Format", tert_mi2s_rx_format,
-			mi2s_rx_format_get,
-			mi2s_rx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Format", quat_mi2s_rx_format,
-			mi2s_rx_format_get,
-			mi2s_rx_format_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Format", prim_mi2s_tx_format,
-			mi2s_tx_format_get,
-			mi2s_tx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Format", sec_mi2s_tx_format,
-			mi2s_tx_format_get,
-			mi2s_tx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Format", tert_mi2s_tx_format,
-			mi2s_tx_format_get,
-			mi2s_tx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Format", quat_mi2s_tx_format,
-			mi2s_tx_format_get,
-			mi2s_tx_format_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
-			usb_audio_rx_ch_get, usb_audio_rx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
-			usb_audio_tx_ch_get, usb_audio_tx_ch_put),
-	SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
-			ext_disp_rx_ch_get, ext_disp_rx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
-			usb_audio_rx_format_get, usb_audio_rx_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
-			usb_audio_tx_format_get, usb_audio_tx_format_put),
-	SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
-			ext_disp_rx_format_get, ext_disp_rx_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
-			usb_audio_rx_sample_rate_get,
-			usb_audio_rx_sample_rate_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
-			usb_audio_tx_sample_rate_get,
-			usb_audio_tx_sample_rate_put),
-	SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
-			ext_disp_rx_sample_rate_get,
-			ext_disp_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-};
-
-/**
- * msm_common_snd_controls_size - to return controls size
- *
- * Return: returns size of common controls array
- */
-int msm_common_snd_controls_size(void)
-{
-	return ARRAY_SIZE(msm_common_snd_controls);
-}
-EXPORT_SYMBOL(msm_common_snd_controls_size);
-
-void msm_set_codec_reg_done(bool done)
-{
-	codec_reg_done = done;
-}
-EXPORT_SYMBOL(msm_set_codec_reg_done);
-
-static inline int param_is_mask(int p)
-{
-	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
-			(p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
-}
-
-static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
-					     int n)
-{
-	return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
-}
-
-static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
-{
-	if (bit >= SNDRV_MASK_MAX)
-		return;
-	if (param_is_mask(n)) {
-		struct snd_mask *m = param_to_mask(p, n);
-
-		m->bits[0] = 0;
-		m->bits[1] = 0;
-		m->bits[bit >> 5] |= (1 << (bit & 31));
-	}
-}
-
-static int msm_ext_disp_get_idx_from_beid(int32_t id)
-{
-	int idx;
-
-	switch (id) {
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = DP_RX_IDX;
-		break;
-	default:
-		pr_err("%s: Incorrect ext_disp id %d\n", __func__, id);
-		idx = -EINVAL;
-		break;
-	}
-
-	return idx;
-}
-
-/**
- * msm_common_be_hw_params_fixup - updates settings of ALSA BE hw params.
- *
- * @rtd: runtime dailink instance
- * @params: HW params of associated backend dailink.
- *
- * Returns 0.
- */
-int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-	int rc = 0;
-	int idx;
-
-	pr_debug("%s: format = %d, rate = %d\n",
-		  __func__, params_format(params), params_rate(params));
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_USB_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_rx_cfg.bit_format);
-		rate->min = rate->max = usb_rx_cfg.sample_rate;
-		channels->min = channels->max = usb_rx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_USB_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_tx_cfg.bit_format);
-		rate->min = rate->max = usb_tx_cfg.sample_rate;
-		channels->min = channels->max = usb_tx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
-		if (idx < 0) {
-			pr_err("%s: Incorrect ext disp idx %d\n",
-			       __func__, idx);
-			rc = idx;
-			break;
-		}
-
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				ext_disp_rx_cfg[idx].bit_format);
-		rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AFE_PCM_RX:
-		channels->min = channels->max = proxy_rx_cfg.channels;
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				   tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[PRIM_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_rx_cfg[PRIM_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[PRIM_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_tx_cfg[PRIM_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[SEC_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_rx_cfg[SEC_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[SEC_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_tx_cfg[SEC_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[TERT_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_rx_cfg[TERT_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[TERT_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_tx_cfg[TERT_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[QUAT_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_rx_cfg[QUAT_MI2S].bit_format);
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[QUAT_MI2S].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       mi2s_tx_cfg[QUAT_MI2S].bit_format);
-		break;
-
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return rc;
-}
-EXPORT_SYMBOL(msm_common_be_hw_params_fixup);
-
-/**
- * msm_aux_pcm_snd_startup - startup ops of auxpcm.
- *
- * @substream: PCM stream pointer of associated backend dailink
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		rtd->cpu_dai->name, rtd->cpu_dai->id);
-
-	return 0;
-}
-EXPORT_SYMBOL(msm_aux_pcm_snd_startup);
-
-/**
- * msm_aux_pcm_snd_shutdown - shutdown ops of auxpcm.
- *
- * @substream: PCM stream pointer of associated backend dailink
- */
-void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__,
-		substream->name, substream->stream,
-		rtd->cpu_dai->name, rtd->cpu_dai->id);
-}
-EXPORT_SYMBOL(msm_aux_pcm_snd_shutdown);
-
-static int msm_get_port_id(int id)
-{
-	int afe_port_id;
-
-	switch (id) {
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	default:
-		pr_err("%s: Invalid id: %d\n", __func__, id);
-		afe_port_id = -EINVAL;
-	}
-
-	return afe_port_id;
-}
-
-static u32 get_mi2s_bits_per_sample(u32 bit_format)
-{
-	u32 bit_per_sample;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bit_per_sample = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bit_per_sample = 16;
-		break;
-	}
-
-	return bit_per_sample;
-}
-
-static void update_mi2s_clk_val(int dai_id, int stream)
-{
-	u32 bit_per_sample;
-
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	} else {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	}
-}
-
-static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int port_id = 0;
-	int index = cpu_dai->id;
-
-	port_id = msm_get_port_id(rtd->dai_link->id);
-	if (port_id < 0) {
-		dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
-		ret = port_id;
-		goto done;
-	}
-
-	if (enable) {
-		update_mi2s_clk_val(index, substream->stream);
-		dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
-			mi2s_clk[index].clk_freq_in_hz);
-	}
-
-	mi2s_clk[index].enable = enable;
-	ret = afe_set_lpass_clock_v2(port_id,
-				     &mi2s_clk[index]);
-	if (ret < 0) {
-		dev_err(rtd->card->dev,
-			"%s: afe lpass clock failed for port 0x%x , err:%d\n",
-			__func__, port_id, ret);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-/**
- * msm_mi2s_snd_startup - startup ops of mi2s.
- *
- * @substream: PCM stream pointer of associated backend dailink
- *
- * Returns 0 on success or -EINVAL on error.
- */
-int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int port_id = msm_get_port_id(rtd->dai_link->id);
-	int index = cpu_dai->id;
-	unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		cpu_dai->name, cpu_dai->id);
-
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		ret = -EINVAL;
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, cpu_dai->id);
-		goto done;
-	}
-	/*
-	 * Muxtex protection in case the same MI2S
-	 * interface using for both TX and RX  so
-	 * that the same clock won't be enable twice.
-	 */
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (++mi2s_intf_conf[index].ref_cnt == 1) {
-		/* Check if msm needs to provide the clock to the interface */
-		if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
-			mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
-			fmt = SND_SOC_DAIFMT_CBM_CFM;
-		}
-		ret = msm_mi2s_set_sclk(substream, true);
-		if (ret < 0) {
-			dev_err(rtd->card->dev,
-				"%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
-				__func__, ret);
-			goto clean_up;
-		}
-		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
-		if (ret < 0) {
-			dev_err(rtd->card->dev,
-				"%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
-				__func__, index, ret);
-			goto clk_off;
-		}
-		if (mi2s_intf_conf[index].msm_is_ext_mclk) {
-			mi2s_mclk[index].enable = 1;
-			pr_debug("%s: Enabling mclk, clk_freq_in_hz = %u\n",
-				__func__, mi2s_mclk[index].clk_freq_in_hz);
-			ret = afe_set_lpass_clock_v2(port_id,
-						     &mi2s_mclk[index]);
-			if (ret < 0) {
-				pr_err("%s: afe lpass mclk failed, err:%d\n",
-					__func__, ret);
-				goto clk_off;
-			}
-		}
-	}
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-	return 0;
-clk_off:
-	if (ret < 0)
-		msm_mi2s_set_sclk(substream, false);
-clean_up:
-	if (ret < 0)
-		mi2s_intf_conf[index].ref_cnt--;
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-done:
-	return ret;
-}
-EXPORT_SYMBOL(msm_mi2s_snd_startup);
-
-/**
- * msm_mi2s_snd_shutdown - shutdown ops of mi2s.
- *
- * @substream: PCM stream pointer of associated backend dailink
- */
-void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int port_id = msm_get_port_id(rtd->dai_link->id);
-	int index = rtd->cpu_dai->id;
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
-		return;
-	}
-
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (--mi2s_intf_conf[index].ref_cnt == 0) {
-		ret = msm_mi2s_set_sclk(substream, false);
-		if (ret < 0) {
-			pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
-				__func__, index, ret);
-			mi2s_intf_conf[index].ref_cnt++;
-		}
-		if (mi2s_intf_conf[index].msm_is_ext_mclk) {
-			mi2s_mclk[index].enable = 0;
-			pr_debug("%s: Disabling mclk, clk_freq_in_hz = %u\n",
-				 __func__, mi2s_mclk[index].clk_freq_in_hz);
-			ret = afe_set_lpass_clock_v2(port_id,
-						     &mi2s_mclk[index]);
-			if (ret < 0) {
-				pr_err("%s: mclk disable failed for MCLK (%d); ret=%d\n",
-					__func__, index, ret);
-			}
-		}
-	}
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-}
-EXPORT_SYMBOL(msm_mi2s_snd_shutdown);
-
-/* Validate whether US EU switch is present or not */
-static int msm_prepare_us_euro(struct snd_soc_card *card)
-{
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-	int ret = 0;
-
-	if (pdata->us_euro_gpio >= 0) {
-		dev_dbg(card->dev, "%s: us_euro gpio request %d", __func__,
-			pdata->us_euro_gpio);
-		ret = gpio_request(pdata->us_euro_gpio, "TASHA_CODEC_US_EURO");
-		if (ret) {
-			dev_err(card->dev,
-				"%s: Failed to request codec US/EURO gpio %d error %d\n",
-				__func__, pdata->us_euro_gpio, ret);
-		}
-	}
-
-	return ret;
-}
-
-static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
-{
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-	int value = 0;
-
-	if (pdata->us_euro_gpio_p) {
-		value = msm_cdc_pinctrl_get_state(pdata->us_euro_gpio_p);
-		if (value)
-			msm_cdc_pinctrl_select_sleep_state(
-							pdata->us_euro_gpio_p);
-		else
-			msm_cdc_pinctrl_select_active_state(
-							pdata->us_euro_gpio_p);
-	} else if (pdata->us_euro_gpio >= 0) {
-		value = gpio_get_value_cansleep(pdata->us_euro_gpio);
-		gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
-	}
-	pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
-	return true;
-}
-
-static int msm_populate_dai_link_component_of_node(
-		struct msm_asoc_mach_data *pdata,
-		struct snd_soc_card *card)
-{
-	int i, index, ret = 0;
-	struct device *cdev = card->dev;
-	struct snd_soc_dai_link *dai_link = card->dai_link;
-	struct device_node *phandle;
-
-	if (!cdev) {
-		pr_err("%s: Sound card device memory NULL\n", __func__);
-		return -ENODEV;
-	}
-
-	for (i = 0; i < card->num_links; i++) {
-		if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
-			continue;
-
-		/* populate platform_of_node for snd card dai links */
-		if (dai_link[i].platform_name &&
-				!dai_link[i].platform_of_node) {
-			index = of_property_match_string(cdev->of_node,
-					"asoc-platform-names",
-					dai_link[i].platform_name);
-			if (index < 0) {
-				pr_err("%s: No match found for platform name: %s\n",
-					__func__, dai_link[i].platform_name);
-				ret = index;
-				goto cpu_dai;
-			}
-			phandle = of_parse_phandle(cdev->of_node,
-					"asoc-platform",
-					index);
-			if (!phandle) {
-				pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
-					__func__, dai_link[i].platform_name,
-						index);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].platform_of_node = phandle;
-			dai_link[i].platform_name = NULL;
-		}
-cpu_dai:
-		/* populate cpu_of_node for snd card dai links */
-		if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
-			index = of_property_match_string(cdev->of_node,
-					"asoc-cpu-names",
-					dai_link[i].cpu_dai_name);
-			if (index < 0)
-				goto codec_dai;
-			phandle = of_parse_phandle(cdev->of_node, "asoc-cpu",
-					index);
-			if (!phandle) {
-				pr_err("%s: retrieving phandle for cpu dai %s failed\n",
-					__func__, dai_link[i].cpu_dai_name);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].cpu_of_node = phandle;
-			dai_link[i].cpu_dai_name = NULL;
-		}
-codec_dai:
-		/* populate codec_of_node for snd card dai links */
-		if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
-			index = of_property_match_string(cdev->of_node,
-					"asoc-codec-names",
-					dai_link[i].codec_name);
-			if (index < 0)
-				continue;
-			phandle = of_parse_phandle(cdev->of_node, "asoc-codec",
-					index);
-			if (!phandle) {
-				pr_err("%s: retrieving phandle for codec dai %s failed\n",
-					__func__, dai_link[i].codec_name);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].codec_of_node = phandle;
-			dai_link[i].codec_name = NULL;
-		}
-		if (pdata->snd_card_val == INT_SND_CARD) {
-			if ((dai_link[i].id ==
-					MSM_BACKEND_DAI_INT0_MI2S_RX) ||
-			    (dai_link[i].id ==
-					MSM_BACKEND_DAI_INT1_MI2S_RX) ||
-			    (dai_link[i].id ==
-					MSM_BACKEND_DAI_INT2_MI2S_TX) ||
-			    (dai_link[i].id ==
-					MSM_BACKEND_DAI_INT3_MI2S_TX)) {
-				index = of_property_match_string(cdev->of_node,
-							"asoc-codec-names",
-							MSM_INT_DIGITAL_CODEC);
-				phandle = of_parse_phandle(cdev->of_node,
-							   "asoc-codec",
-							   index);
-				dai_link[i].codecs[DIG_CDC].of_node = phandle;
-				index = of_property_match_string(cdev->of_node,
-							"asoc-codec-names",
-							PMIC_INT_ANALOG_CODEC);
-				phandle = of_parse_phandle(cdev->of_node,
-							   "asoc-codec",
-							   index);
-				dai_link[i].codecs[ANA_CDC].of_node = phandle;
-			}
-		}
-	}
-err:
-	return ret;
-}
-
-static int msm_wsa881x_init(struct snd_soc_component *component)
-{
-	u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
-	u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
-	unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
-	unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
-	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
-	struct msm_asoc_mach_data *pdata;
-	struct snd_soc_dapm_context *dapm =
-			snd_soc_codec_get_dapm(codec);
-
-	if (!codec) {
-		pr_err("%s codec is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!strcmp(component->name_prefix, "SpkrLeft")) {
-		dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
-				__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkleft_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
-		}
-	} else if (!strcmp(component->name_prefix, "SpkrRight")) {
-		dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
-				__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkright_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
-		}
-	} else {
-		dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
-				codec->component.name);
-		return -EINVAL;
-	}
-
-
-	pdata = snd_soc_card_get_drvdata(component->card);
-	if (pdata && pdata->codec_root)
-		wsa881x_codec_info_create_codec_entry(pdata->codec_root,
-						      codec);
-	return 0;
-}
-
-
-static int msm_init_wsa_dev(struct platform_device *pdev,
-			    struct snd_soc_card *card)
-{
-	struct device_node *wsa_of_node;
-	u32 wsa_max_devs;
-	u32 wsa_dev_cnt;
-	char *dev_name_str = NULL;
-	struct msm_wsa881x_dev_info *wsa881x_dev_info;
-	const char *wsa_auxdev_name_prefix[1];
-	int found = 0;
-	int i;
-	int ret;
-
-	/* Get maximum WSA device count for this platform */
-	ret = of_property_read_u32(pdev->dev.of_node,
-					"qcom,wsa-max-devs", &wsa_max_devs);
-	if (ret) {
-		dev_dbg(&pdev->dev,
-			"%s: wsa-max-devs property missing in DT %s, ret = %d\n",
-			__func__, pdev->dev.of_node->full_name, ret);
-		goto err_dt;
-	}
-	if (wsa_max_devs == 0) {
-		dev_warn(&pdev->dev,
-			"%s: Max WSA devices is 0 for this target?\n",
-			__func__);
-		goto err_dt;
-				}
-
-	/* Get count of WSA device phandles for this platform */
-	wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
-						"qcom,wsa-devs", NULL);
-	if (wsa_dev_cnt == -ENOENT) {
-		dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
-			__func__);
-		goto err_dt;
-	} else if (wsa_dev_cnt <= 0) {
-		dev_err(&pdev->dev,
-			"%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
-			__func__, wsa_dev_cnt);
-		ret = -EINVAL;
-		goto err_dt;
-	}
-
-	/*
-	 * Expect total phandles count to be NOT less than maximum possible
-	 * WSA count. However, if it is less, then assign same value to
-	 * max count as well.
-	 */
-	if (wsa_dev_cnt < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
-			__func__, wsa_max_devs, wsa_dev_cnt);
-		wsa_max_devs = wsa_dev_cnt;
-	}
-
-	/* Make sure prefix string passed for each WSA device */
-	ret = of_property_count_strings(pdev->dev.of_node,
-			"qcom,wsa-aux-dev-prefix");
-	if (ret != wsa_dev_cnt) {
-		dev_err(&pdev->dev,
-			"%s: expecting %d wsa prefix. Defined only %d in DT\n",
-			__func__, wsa_dev_cnt, ret);
-		ret = -EINVAL;
-		goto err_dt;
-	}
-
-	/*
-	 * Alloc mem to store phandle and index info of WSA device, if already
-	 * registered with ALSA core
-	 */
-	wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
-					sizeof(struct msm_wsa881x_dev_info),
-					GFP_KERNEL);
-	if (!wsa881x_dev_info) {
-		ret = -ENOMEM;
-		goto err_mem;
-	}
-
-	/*
-	 * search and check whether all WSA devices are already
-	 * registered with ALSA core or not. If found a node, store
-	 * the node and the index in a local array of struct for later
-	 * use.
-	 */
-	for (i = 0; i < wsa_dev_cnt; i++) {
-		wsa_of_node = of_parse_phandle(pdev->dev.of_node,
-					       "qcom,wsa-devs", i);
-		if (unlikely(!wsa_of_node)) {
-			/* we should not be here */
-			dev_err(&pdev->dev,
-				"%s: wsa dev node is not present\n",
-				__func__);
-			ret = -EINVAL;
-			goto err_dev_node;
-		}
-		if (soc_find_component(wsa_of_node, NULL)) {
-			/* WSA device registered with ALSA core */
-			wsa881x_dev_info[found].of_node = wsa_of_node;
-			wsa881x_dev_info[found].index = i;
-			found++;
-			if (found == wsa_max_devs)
-				break;
-		}
-	}
-
-	if (found < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: failed to find %d components. Found only %d\n",
-			__func__, wsa_max_devs, found);
-		return -EPROBE_DEFER;
-	}
-	dev_info(&pdev->dev,
-		"%s: found %d wsa881x devices registered with ALSA core\n",
-		__func__, found);
-
-	card->num_aux_devs = wsa_max_devs;
-	card->num_configs = wsa_max_devs;
-
-	/* Alloc array of AUX devs struct */
-	msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-				   sizeof(struct snd_soc_aux_dev),
-				   GFP_KERNEL);
-	if (!msm_aux_dev) {
-		ret = -ENOMEM;
-		goto err_auxdev_mem;
-	}
-
-	/* Alloc array of codec conf struct */
-	msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-				      sizeof(struct snd_soc_codec_conf),
-				      GFP_KERNEL);
-	if (!msm_codec_conf) {
-		ret = -ENOMEM;
-		goto err_codec_conf;
-	}
-
-	for (i = 0; i < card->num_aux_devs; i++) {
-		dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
-					    GFP_KERNEL);
-		if (!dev_name_str) {
-			ret = -ENOMEM;
-			goto err_dev_str;
-		}
-
-		ret = of_property_read_string_index(pdev->dev.of_node,
-						    "qcom,wsa-aux-dev-prefix",
-						    wsa881x_dev_info[i].index,
-						    wsa_auxdev_name_prefix);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: failed to read wsa aux dev prefix, ret = %d\n",
-				__func__, ret);
-			ret = -EINVAL;
-			goto err_dt_prop;
-		}
-
-		snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
-		msm_aux_dev[i].name = dev_name_str;
-		msm_aux_dev[i].codec_name = NULL;
-		msm_aux_dev[i].codec_of_node =
-			wsa881x_dev_info[i].of_node;
-		msm_aux_dev[i].init = msm_wsa881x_init;
-		msm_codec_conf[i].dev_name = NULL;
-		msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
-		msm_codec_conf[i].of_node = wsa881x_dev_info[i].of_node;
-	}
-	card->codec_conf = msm_codec_conf;
-	card->aux_dev = msm_aux_dev;
-
-	return 0;
-
-err_dt_prop:
-	devm_kfree(&pdev->dev, dev_name_str);
-err_dev_str:
-	devm_kfree(&pdev->dev, msm_codec_conf);
-err_codec_conf:
-	devm_kfree(&pdev->dev, msm_aux_dev);
-err_auxdev_mem:
-err_dev_node:
-	devm_kfree(&pdev->dev, wsa881x_dev_info);
-err_mem:
-err_dt:
-	return ret;
-}
-
-static void msm_free_auxdev_mem(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	int i;
-
-	if (card->num_aux_devs > 0) {
-		for (i = 0; i < card->num_aux_devs; i++) {
-			kfree(msm_aux_dev[i].codec_name);
-			kfree(msm_codec_conf[i].dev_name);
-			kfree(msm_codec_conf[i].name_prefix);
-		}
-	}
-}
-
-static void i2s_auxpcm_init(struct platform_device *pdev)
-{
-	int count;
-	u32 mi2s_master_slave[MI2S_MAX];
-	u32 mi2s_ext_mclk[MI2S_MAX];
-	int ret;
-
-	for (count = 0; count < MI2S_MAX; count++) {
-		mutex_init(&mi2s_intf_conf[count].lock);
-		mi2s_intf_conf[count].ref_cnt = 0;
-	}
-
-	ret = of_property_read_u32_array(pdev->dev.of_node,
-					 "qcom,msm-mi2s-master",
-					 mi2s_master_slave, MI2S_MAX);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
-			__func__);
-	} else {
-		for (count = 0; count < MI2S_MAX; count++) {
-			mi2s_intf_conf[count].msm_is_mi2s_master =
-				mi2s_master_slave[count];
-		}
-	}
-
-	ret = of_property_read_u32_array(pdev->dev.of_node,
-					 "qcom,msm-mi2s-ext-mclk",
-					 mi2s_ext_mclk, MI2S_MAX);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-ext-mclk in DT node\n",
-			__func__);
-	} else {
-		for (count = 0; count < MI2S_MAX; count++)
-			mi2s_intf_conf[count].msm_is_ext_mclk =
-				mi2s_ext_mclk[count];
-	}
-}
-
-static const struct of_device_id sdm660_asoc_machine_of_match[]  = {
-	{ .compatible = "qcom,sdm660-asoc-snd",
-	  .data = "internal_codec"},
-	{ .compatible = "qcom,sdm660-asoc-snd-tasha",
-	  .data = "tasha_codec"},
-	{ .compatible = "qcom,sdm660-asoc-snd-tavil",
-	  .data = "tavil_codec"},
-	{ .compatible = "qcom,sdm670-asoc-snd",
-	  .data = "internal_codec"},
-	{ .compatible = "qcom,sdm670-asoc-snd-tasha",
-	  .data = "tasha_codec"},
-	{ .compatible = "qcom,sdm670-asoc-snd-tavil",
-	  .data = "tavil_codec"},
-	{},
-};
-
-static int msm_asoc_machine_probe(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = NULL;
-	struct msm_asoc_mach_data *pdata = NULL;
-	const char *mclk = "qcom,msm-mclk-freq";
-	int ret = -EINVAL, id;
-	const struct of_device_id *match;
-
-	pdata = devm_kzalloc(&pdev->dev,
-			     sizeof(struct msm_asoc_mach_data),
-			     GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	msm_set_codec_reg_done(false);
-	match = of_match_node(sdm660_asoc_machine_of_match,
-			      pdev->dev.of_node);
-	if (!match)
-		goto err;
-
-	ret = of_property_read_u32(pdev->dev.of_node, mclk, &id);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"%s: missing %s in dt node\n", __func__, mclk);
-		id = DEFAULT_MCLK_RATE;
-	}
-	pdata->mclk_freq = id;
-
-	if (!strcmp(match->data, "tasha_codec") ||
-	    !strcmp(match->data, "tavil_codec")) {
-		if (!strcmp(match->data, "tasha_codec"))
-			pdata->snd_card_val = EXT_SND_CARD_TASHA;
-		else
-			pdata->snd_card_val = EXT_SND_CARD_TAVIL;
-		ret = msm_ext_cdc_init(pdev, pdata, &card, &mbhc_cfg);
-		if (ret)
-			goto err;
-	} else if (!strcmp(match->data, "internal_codec")) {
-		pdata->snd_card_val = INT_SND_CARD;
-		ret = msm_int_cdc_init(pdev, pdata, &card, &mbhc_cfg);
-		if (ret)
-			goto err;
-	} else {
-		dev_err(&pdev->dev,
-			"%s: Not a matching DT sound node\n", __func__);
-		goto err;
-	}
-	if (!card)
-		goto err;
-
-	if (pdata->snd_card_val == INT_SND_CARD) {
-		/*reading the gpio configurations from dtsi file*/
-		pdata->pdm_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,cdc-pdm-gpios", 0);
-		pdata->comp_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,cdc-comp-gpios", 0);
-		pdata->dmic_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,cdc-dmic-gpios", 0);
-		pdata->ext_spk_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,cdc-ext-spk-gpios", 0);
-	}
-
-	/*
-	 * Parse US-Euro gpio info from DT. Report no error if us-euro
-	 * entry is not found in DT file as some targets do not support
-	 * US-Euro detection
-	 */
-	pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
-				"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio))
-		pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio) && (!pdata->us_euro_gpio_p)) {
-		dev_dbg(&pdev->dev, "property %s not detected in node %s",
-			"qcom,us-euro-gpios", pdev->dev.of_node->full_name);
-	} else {
-		dev_dbg(&pdev->dev, "%s detected",
-			"qcom,us-euro-gpios");
-		mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
-	}
-
-	ret = msm_prepare_us_euro(card);
-	if (ret)
-		dev_dbg(&pdev->dev, "msm_prepare_us_euro failed (%d)\n",
-			ret);
-
-	i2s_auxpcm_init(pdev);
-
-	ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
-	if (ret)
-		goto err;
-
-	ret = msm_populate_dai_link_component_of_node(pdata, card);
-	if (ret) {
-		ret = -EPROBE_DEFER;
-		goto err;
-	}
-
-	if (!of_property_read_bool(pdev->dev.of_node, "qcom,wsa-disable")) {
-		ret = msm_init_wsa_dev(pdev, card);
-		if (ret)
-			goto err;
-	}
-
-	ret = devm_snd_soc_register_card(&pdev->dev, card);
-	if (ret == -EPROBE_DEFER) {
-		if (codec_reg_done) {
-			/*
-			 * return failure as EINVAL since other codec
-			 * registered sound card successfully.
-			 * This avoids any further probe calls.
-			 */
-			ret = -EINVAL;
-		}
-		goto err;
-	} else if (ret) {
-		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
-			ret);
-		goto err;
-	}
-	if (pdata->snd_card_val != INT_SND_CARD)
-		msm_ext_register_audio_notifier(pdev);
-
-	return 0;
-err:
-	if (pdata->us_euro_gpio > 0) {
-		dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
-			__func__, pdata->us_euro_gpio);
-		pdata->us_euro_gpio = 0;
-	}
-	if (pdata->hph_en1_gpio > 0) {
-		dev_dbg(&pdev->dev, "%s free hph_en1_gpio %d\n",
-			__func__, pdata->hph_en1_gpio);
-		gpio_free(pdata->hph_en1_gpio);
-		pdata->hph_en1_gpio = 0;
-	}
-	if (pdata->hph_en0_gpio > 0) {
-		dev_dbg(&pdev->dev, "%s free hph_en0_gpio %d\n",
-			__func__, pdata->hph_en0_gpio);
-		gpio_free(pdata->hph_en0_gpio);
-		pdata->hph_en0_gpio = 0;
-	}
-	devm_kfree(&pdev->dev, pdata);
-	return ret;
-}
-
-static int msm_asoc_machine_remove(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-
-	if (pdata->snd_card_val == INT_SND_CARD)
-		mutex_destroy(&pdata->cdc_int_mclk0_mutex);
-
-	msm_free_auxdev_mem(pdev);
-	gpio_free(pdata->us_euro_gpio);
-	gpio_free(pdata->hph_en1_gpio);
-	gpio_free(pdata->hph_en0_gpio);
-	snd_soc_unregister_card(card);
-	return 0;
-}
-
-static struct platform_driver sdm660_asoc_machine_driver = {
-	.driver = {
-		.name = DRV_NAME,
-		.owner = THIS_MODULE,
-		.pm = &snd_soc_pm_ops,
-		.of_match_table = sdm660_asoc_machine_of_match,
-	},
-	.probe = msm_asoc_machine_probe,
-	.remove = msm_asoc_machine_remove,
-};
-module_platform_driver(sdm660_asoc_machine_driver);
-
-MODULE_DESCRIPTION("ALSA SoC msm");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
-MODULE_DEVICE_TABLE(of, sdm660_asoc_machine_of_match);
diff --git a/sound/soc/msm/sdm660-common.h b/sound/soc/msm/sdm660-common.h
deleted file mode 100644
index f4787ae..0000000
--- a/sound/soc/msm/sdm660-common.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __MSM_COMMON
-#define __MSM_COMMON
-
-#include <sound/soc.h>
-#include <sound/q6afe-v2.h>
-#include "../codecs/wcd-mbhc-v2.h"
-
-#define SAMPLING_RATE_8KHZ      8000
-#define SAMPLING_RATE_11P025KHZ 11025
-#define SAMPLING_RATE_16KHZ     16000
-#define SAMPLING_RATE_22P05KHZ  22050
-#define SAMPLING_RATE_32KHZ     32000
-#define SAMPLING_RATE_44P1KHZ   44100
-#define SAMPLING_RATE_48KHZ     48000
-#define SAMPLING_RATE_88P2KHZ   88200
-#define SAMPLING_RATE_96KHZ     96000
-#define SAMPLING_RATE_176P4KHZ  176400
-#define SAMPLING_RATE_192KHZ    192000
-#define SAMPLING_RATE_352P8KHZ  352800
-#define SAMPLING_RATE_384KHZ    384000
-
-#define TDM_CHANNEL_MAX 8
-#define TDM_SLOT_OFFSET_MAX 8
-
-enum {
-	TDM_0 = 0,
-	TDM_1,
-	TDM_2,
-	TDM_3,
-	TDM_4,
-	TDM_5,
-	TDM_6,
-	TDM_7,
-	TDM_PORT_MAX,
-};
-
-enum {
-	TDM_PRI = 0,
-	TDM_SEC,
-	TDM_TERT,
-	TDM_QUAT,
-	TDM_INTERFACE_MAX,
-};
-
-struct tdm_port {
-	u32 mode;
-	u32 channel;
-};
-
-enum {
-	DIG_CDC,
-	ANA_CDC,
-	CODECS_MAX,
-};
-
-extern const struct snd_kcontrol_new msm_common_snd_controls[];
-extern bool codec_reg_done;
-struct sdm660_codec {
-	void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
-				   enum afe_config_type config_type);
-};
-
-enum {
-	INT_SND_CARD,
-	EXT_SND_CARD_TASHA,
-	EXT_SND_CARD_TAVIL,
-};
-
-struct msm_asoc_mach_data {
-	int us_euro_gpio; /* used by gpio driver API */
-	int hph_en1_gpio;
-	int hph_en0_gpio;
-	struct device_node *us_euro_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
-	struct device_node *pdm_gpio_p; /* used by pinctrl API */
-	struct device_node *comp_gpio_p; /* used by pinctrl API */
-	struct device_node *dmic_gpio_p; /* used by pinctrl API */
-	struct device_node *ext_spk_gpio_p; /* used by pinctrl API */
-	struct snd_soc_codec *codec;
-	struct sdm660_codec sdm660_codec_fn;
-	struct snd_info_entry *codec_root;
-	int spk_ext_pa_gpio;
-	int mclk_freq;
-	bool native_clk_set;
-	int lb_mode;
-	int snd_card_val;
-	u8 micbias1_cap_mode;
-	u8 micbias2_cap_mode;
-	atomic_t int_mclk0_rsc_ref;
-	atomic_t int_mclk0_enabled;
-	struct mutex cdc_int_mclk0_mutex;
-	struct delayed_work disable_int_mclk0_work;
-	struct afe_clk_set digital_cdc_core_clk;
-};
-
-int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				  struct snd_pcm_hw_params *params);
-int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream);
-void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream);
-int msm_mi2s_snd_startup(struct snd_pcm_substream *substream);
-void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream);
-int msm_common_snd_controls_size(void);
-void msm_set_codec_reg_done(bool done);
-#endif
diff --git a/sound/soc/msm/sdm660-ext-dai-links.c b/sound/soc/msm/sdm660-ext-dai-links.c
deleted file mode 100644
index 68a0f37..0000000
--- a/sound/soc/msm/sdm660-ext-dai-links.c
+++ /dev/null
@@ -1,2046 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/mfd/wcd9xxx/core.h>
-#include <linux/of.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "../codecs/wcd9335.h"
-#include "sdm660-common.h"
-#include "sdm660-external.h"
-
-#define DEV_NAME_STR_LEN            32
-#define __CHIPSET__ "SDM660 "
-#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
-
-#define WCN_CDC_SLIM_RX_CH_MAX 2
-#define WCN_CDC_SLIM_TX_CH_MAX 3
-
-static struct snd_soc_card snd_soc_card_msm_card_tavil = {
-	.name = "sdm670-tavil-snd-card",
-	.late_probe = msm_snd_card_tavil_late_probe,
-};
-
-static struct snd_soc_card snd_soc_card_msm_card_tasha = {
-	.name = "sdm670-tasha-snd-card",
-	.late_probe = msm_snd_card_tasha_late_probe,
-};
-
-static struct snd_soc_ops msm_ext_slimbus_be_ops = {
-	.hw_params = msm_snd_hw_params,
-};
-
-static struct snd_soc_ops msm_ext_cpe_ops = {
-	.hw_params = msm_snd_cpe_hw_params,
-};
-
-static struct snd_soc_ops msm_ext_slimbus_2_be_ops = {
-	.hw_params = msm_ext_slimbus_2_hw_params,
-};
-
-static struct snd_soc_ops msm_mi2s_be_ops = {
-	.startup = msm_mi2s_snd_startup,
-	.shutdown = msm_mi2s_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_aux_pcm_be_ops = {
-	.startup = msm_aux_pcm_snd_startup,
-	.shutdown = msm_aux_pcm_snd_shutdown,
-};
-
-static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
-{
-	unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
-	unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX]  = {159, 160, 161};
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-
-	return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					   tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
-}
-
-static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	int ret;
-
-	dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-	if (ret) {
-		dev_err(rtd->dev,
-			"%s: failed to get BTFM codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto exit;
-	}
-
-	dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) id %d\n",
-		__func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
-	if (ret)
-		dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-
-exit:
-	return ret;
-}
-
-static struct snd_soc_ops msm_wcn_ops = {
-	.hw_params = msm_wcn_hw_params,
-};
-
-/*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */
-static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
-	{0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */
-};
-
-static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width,
-					    int slots)
-{
-	unsigned int slot_mask = 0;
-	int i, j;
-	unsigned int *slot_offset;
-
-	for (i = TDM_0; i < TDM_PORT_MAX; i++) {
-		slot_offset = tdm_slot_offset[i];
-
-		for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) {
-			if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-				slot_mask |=
-				(1 << ((slot_offset[j] * 8) / slot_width));
-			else
-				break;
-		}
-	}
-
-	return slot_mask;
-}
-
-static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int *slot_offset;
-	int offset_channels = 0;
-	int i;
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	channels = params_channels(params);
-	switch (channels) {
-	case 1:
-	case 2:
-	case 3:
-	case 4:
-	case 5:
-	case 6:
-	case 7:
-	case 8:
-		switch (params_format(params)) {
-		case SNDRV_PCM_FORMAT_S32_LE:
-		case SNDRV_PCM_FORMAT_S24_LE:
-		case SNDRV_PCM_FORMAT_S16_LE:
-		/*
-		 * up to 8 channels HW config should
-		 * use 32 bit slot width for max support of
-		 * stream bit width. (slot_width > bit_width)
-		 */
-			slot_width = 32;
-			break;
-		default:
-			pr_err("%s: invalid param format 0x%x\n",
-				__func__, params_format(params));
-			return -EINVAL;
-		}
-		slots = 8;
-		slot_mask = tdm_param_set_slot_mask(cpu_dai->id,
-						    slot_width,
-						    slots);
-		if (!slot_mask) {
-			pr_err("%s: invalid slot_mask 0x%x\n",
-				__func__, slot_mask);
-			return -EINVAL;
-		}
-		break;
-	default:
-		pr_err("%s: invalid param channels %d\n",
-			__func__, channels);
-		return -EINVAL;
-	}
-	/* currently only supporting TDM_RX_0 and TDM_TX_0 */
-	switch (cpu_dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		slot_offset = tdm_slot_offset[TDM_0];
-		break;
-	default:
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
-		if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-			offset_channels++;
-		else
-			break;
-	}
-
-	if (offset_channels == 0) {
-		pr_err("%s: slot offset not supported, offset_channels %d\n",
-			__func__, offset_channels);
-		return -EINVAL;
-	}
-
-	if (channels > offset_channels) {
-		pr_err("%s: channels %d exceed offset_channels %d\n",
-			__func__, channels, offset_channels);
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
-						  channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
-						  slot_offset, 0, NULL);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	}
-end:
-	return ret;
-}
-
-static struct snd_soc_ops msm_tdm_be_ops = {
-	.hw_params = msm_tdm_snd_hw_params
-};
-
-static struct snd_soc_dai_link msm_ext_tasha_fe_dai[] = {
-	/* tasha_vifeedback for speaker protection */
-	{
-		.name = LPASS_BE_SLIMBUS_4_TX,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-	},
-	/* Ultrasound RX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Playback",
-		.stream_name = "SLIMBUS_2 Hostless Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx2",
-		.ignore_suspend = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_ext_slimbus_2_be_ops,
-	},
-	/* Ultrasound TX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Capture",
-		.stream_name = "SLIMBUS_2 Hostless Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16389",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx2",
-		.ignore_suspend = 1,
-		.dpcm_capture = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_ext_slimbus_2_be_ops,
-	},
-	/* CPE LSM direct dai-link */
-	{
-		.name = "CPE Listen service",
-		.stream_name = "CPE Listen Audio Service",
-		.cpu_dai_name = "msm-dai-slim",
-		.platform_name = "msm-cpe-lsm",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.dpcm_capture = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "tasha_mad1",
-		.codec_name = "tasha_codec",
-		.ops = &msm_ext_cpe_ops,
-	},
-	{
-		.name = "SLIMBUS_6 Hostless Playback",
-		.stream_name = "SLIMBUS_6 Hostless",
-		.cpu_dai_name = "SLIMBUS6_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	/* CPE LSM EC PP direct dai-link */
-	{
-		.name = "CPE Listen service ECPP",
-		.stream_name = "CPE Listen Audio Service ECPP",
-		.cpu_dai_name = "CPE_LSM_NOHOST",
-		.platform_name = "msm-cpe-lsm.3",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "tasha_cpe",
-		.codec_name = "tasha_codec",
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_tavil_fe_dai[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_4_TX,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-	},
-	/* Ultrasound RX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Playback",
-		.stream_name = "SLIMBUS_2 Hostless Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_ext_slimbus_2_be_ops,
-	},
-	/* Ultrasound TX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Capture",
-		.stream_name = "SLIMBUS_2 Hostless Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16389",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_ext_slimbus_2_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_tasha_be_dai[] = {
-	/* Backend DAI Links */
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_ext_slimbus_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_ext_slimbus_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_RX,
-		.stream_name = "Slimbus1 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16386",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_TX,
-		.stream_name = "Slimbus1 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16387",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx3",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_RX,
-		.stream_name = "Slimbus3 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16390",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_TX,
-		.stream_name = "Slimbus3 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16391",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_4_RX,
-		.stream_name = "Slimbus4 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16392",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mix_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_5_RX,
-		.stream_name = "Slimbus5 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16394",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx3",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* MAD BE */
-	{
-		.name = LPASS_BE_SLIMBUS_5_TX,
-		.stream_name = "Slimbus5 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16395",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_mad1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_6_RX,
-		.stream_name = "Slimbus6 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16396",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tasha_codec",
-		.codec_dai_name = "tasha_rx4",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_tavil_be_dai[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_ext_slimbus_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_ext_slimbus_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_RX,
-		.stream_name = "Slimbus1 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16386",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_TX,
-		.stream_name = "Slimbus1 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16387",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx3",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_2_RX,
-		.stream_name = "Slimbus2 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_RX,
-		.stream_name = "Slimbus3 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16390",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_TX,
-		.stream_name = "Slimbus3 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16391",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_4_RX,
-		.stream_name = "Slimbus4 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16392",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_5_RX,
-		.stream_name = "Slimbus5 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16394",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx3",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* MAD BE */
-	{
-		.name = LPASS_BE_SLIMBUS_5_TX,
-		.stream_name = "Slimbus5 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16395",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_mad1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_6_RX,
-		.stream_name = "Slimbus6 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16396",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx4",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_ext_slimbus_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_common_fe_dai[] = {
-	/* FrontEnd DAI Links */
-	{/* hw:x,0 */
-		.name = MSM_DAILINK_NAME(Media1),
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name	= "MultiMedia1",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-	{/* hw:x,1 */
-		.name = MSM_DAILINK_NAME(Media2),
-		.stream_name = "MultiMedia2",
-		.cpu_dai_name   = "MultiMedia2",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA2,
-	},
-	{/* hw:x,2 */
-		.name = "VoiceMMode1",
-		.stream_name = "VoiceMMode1",
-		.cpu_dai_name = "VoiceMMode1",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE1,
-	},
-	{/* hw:x,3 */
-		.name = "MSM VoIP",
-		.stream_name = "VoIP",
-		.cpu_dai_name	= "VoIP",
-		.platform_name  = "msm-voip-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_VOIP,
-	},
-	{/* hw:x,4 */
-		.name = MSM_DAILINK_NAME(ULL),
-		.stream_name = "ULL",
-		.cpu_dai_name	= "MultiMedia3",
-		.platform_name  = "msm-pcm-dsp.2",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA3,
-	},
-	/* Hostless PCM purpose */
-	{/* hw:x,5 */
-		.name = "SLIMBUS_0 Hostless",
-		.stream_name = "SLIMBUS_0 Hostless",
-		.cpu_dai_name = "SLIMBUS0_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* This dai link has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,6 */
-		.name = "MSM AFE-PCM RX",
-		.stream_name = "AFE-PROXY RX",
-		.cpu_dai_name = "msm-dai-q6-dev.241",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.platform_name  = "msm-pcm-afe",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-	},
-	{/* hw:x,7 */
-		.name = "MSM AFE-PCM TX",
-		.stream_name = "AFE-PROXY TX",
-		.cpu_dai_name = "msm-dai-q6-dev.240",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.platform_name  = "msm-pcm-afe",
-		.ignore_suspend = 1,
-	},
-	{/* hw:x,8 */
-		.name = MSM_DAILINK_NAME(Compress1),
-		.stream_name = "Compress1",
-		.cpu_dai_name	= "MultiMedia4",
-		.platform_name  = "msm-compress-dsp",
-		.async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA4,
-	},
-	{/* hw:x,9*/
-		.name = "AUXPCM Hostless",
-		.stream_name = "AUXPCM Hostless",
-		.cpu_dai_name   = "AUXPCM_HOSTLESS",
-		.platform_name  = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,10 */
-		.name = "SLIMBUS_1 Hostless",
-		.stream_name = "SLIMBUS_1 Hostless",
-		.cpu_dai_name = "SLIMBUS1_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,11 */
-		.name = "SLIMBUS_3 Hostless",
-		.stream_name = "SLIMBUS_3 Hostless",
-		.cpu_dai_name = "SLIMBUS3_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,12 */
-		.name = "SLIMBUS_4 Hostless",
-		.stream_name = "SLIMBUS_4 Hostless",
-		.cpu_dai_name = "SLIMBUS4_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,13 */
-		.name = MSM_DAILINK_NAME(LowLatency),
-		.stream_name = "MultiMedia5",
-		.cpu_dai_name   = "MultiMedia5",
-		.platform_name  = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA5,
-	},
-	/* LSM FE */
-	{/* hw:x,14 */
-		.name = "Listen 1 Audio Service",
-		.stream_name = "Listen 1 Audio Service",
-		.cpu_dai_name = "LSM1",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM1,
-	},
-	{/* hw:x,15 */
-		.name = MSM_DAILINK_NAME(Compress2),
-		.stream_name = "Compress2",
-		.cpu_dai_name   = "MultiMedia7",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA7,
-	},
-	{/* hw:x,16 */
-		.name = MSM_DAILINK_NAME(MultiMedia10),
-		.stream_name = "MultiMedia10",
-		.cpu_dai_name	= "MultiMedia10",
-		.platform_name  = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA10,
-	},
-	{/* hw:x,17 */
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ),
-		.stream_name = "MM_NOIRQ",
-		.cpu_dai_name	= "MultiMedia8",
-		.platform_name  = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA8,
-	},
-	{/* hw:x,18 */
-		.name = "HDMI_RX_HOSTLESS",
-		.stream_name = "HDMI_RX_HOSTLESS",
-		.cpu_dai_name	= "HDMI_HOSTLESS",
-		.platform_name  = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,19 */
-		.name = "VoiceMMode2",
-		.stream_name = "VoiceMMode2",
-		.cpu_dai_name = "VoiceMMode2",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE2,
-	},
-	{/* hw:x,20 */
-		.name = "Listen 2 Audio Service",
-		.stream_name = "Listen 2 Audio Service",
-		.cpu_dai_name = "LSM2",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM2,
-	},
-	{/* hw:x,21 */
-		.name = "Listen 3 Audio Service",
-		.stream_name = "Listen 3 Audio Service",
-		.cpu_dai_name = "LSM3",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM3,
-	},
-	{/* hw:x,22 */
-		.name = "Listen 4 Audio Service",
-		.stream_name = "Listen 4 Audio Service",
-		.cpu_dai_name = "LSM4",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM4,
-	},
-	{/* hw:x,23 */
-		.name = "Listen 5 Audio Service",
-		.stream_name = "Listen 5 Audio Service",
-		.cpu_dai_name = "LSM5",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM5,
-	},
-	{/* hw:x,24 */
-		.name = "Listen 6 Audio Service",
-		.stream_name = "Listen 6 Audio Service",
-		.cpu_dai_name = "LSM6",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM6
-	},
-	{/* hw:x,25 */
-		.name = "Listen 7 Audio Service",
-		.stream_name = "Listen 7 Audio Service",
-		.cpu_dai_name = "LSM7",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM7,
-	},
-	{/* hw:x,26 */
-		.name = "Listen 8 Audio Service",
-		.stream_name = "Listen 8 Audio Service",
-		.cpu_dai_name = "LSM8",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM8,
-	},
-	{/* hw:x,27 */
-		.name = MSM_DAILINK_NAME(Media9),
-		.stream_name = "MultiMedia9",
-		.cpu_dai_name	= "MultiMedia9",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA9,
-	},
-	{/* hw:x,28 */
-		.name = MSM_DAILINK_NAME(Compress4),
-		.stream_name = "Compress4",
-		.cpu_dai_name	= "MultiMedia11",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA11,
-	},
-	{/* hw:x,29 */
-		.name = MSM_DAILINK_NAME(Compress5),
-		.stream_name = "Compress5",
-		.cpu_dai_name	= "MultiMedia12",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA12,
-	},
-	{/* hw:x,30 */
-		.name = MSM_DAILINK_NAME(Compress6),
-		.stream_name = "Compress6",
-		.cpu_dai_name	= "MultiMedia13",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA13,
-	},
-	{/* hw:x,31 */
-		.name = MSM_DAILINK_NAME(Compress7),
-		.stream_name = "Compress7",
-		.cpu_dai_name	= "MultiMedia14",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA14,
-	},
-	{/* hw:x,32 */
-		.name = MSM_DAILINK_NAME(Compress8),
-		.stream_name = "Compress8",
-		.cpu_dai_name	= "MultiMedia15",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA15,
-	},
-	{/* hw:x,33 */
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
-		.stream_name = "MM_NOIRQ_2",
-		.cpu_dai_name	= "MultiMedia16",
-		.platform_name  = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA16,
-	},
-	{/* hw:x,34 */
-		.name = "SLIMBUS_8 Hostless",
-		.stream_name = "SLIMBUS8_HOSTLESS Capture",
-		.cpu_dai_name = "SLIMBUS8_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,35 */
-		.name = "SLIMBUS7 Hostless",
-		.stream_name = "SLIMBUS7 Hostless",
-		.cpu_dai_name = "SLIMBUS7_HOSTLESS",
-		.platform_name  = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,36 */
-		.name = "SDM660 HFP TX",
-		.stream_name = "MultiMedia6",
-		.cpu_dai_name = "MultiMedia6",
-		.platform_name  = "msm-pcm-loopback",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA6,
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_common_be_dai[] = {
-	{
-		.name = LPASS_BE_AFE_PCM_RX,
-		.stream_name = "AFE Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.224",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_AFE_PCM_TX,
-		.stream_name = "AFE Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.225",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Uplink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_TX,
-		.stream_name = "Voice Uplink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32772",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Downlink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_RX,
-		.stream_name = "Voice Downlink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32771",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE_PLAYBACK_TX,
-		.stream_name = "Voice Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32773",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music 2 BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE2_PLAYBACK_TX,
-		.stream_name = "Voice2 Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32770",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_RX,
-		.stream_name = "USB Audio Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.28672",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_USB_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_TX,
-		.stream_name = "USB Audio Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.28673",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_USB_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_RX_0,
-		.stream_name = "Primary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36864",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_TX_0,
-		.stream_name = "Primary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36865",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_RX_0,
-		.stream_name = "Secondary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36880",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_TX_0,
-		.stream_name = "Secondary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36881",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_RX_0,
-		.stream_name = "Tertiary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36896",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_TX_0,
-		.stream_name = "Tertiary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36897",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_RX_0,
-		.stream_name = "Quaternary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36912",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_TX_0,
-		.stream_name = "Quaternary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36913",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
-	{
-		.name = LPASS_BE_PRI_MI2S_RX,
-		.stream_name = "Primary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_MI2S_TX,
-		.stream_name = "Primary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_RX,
-		.stream_name = "Secondary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_TX,
-		.stream_name = "Secondary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_RX,
-		.stream_name = "Tertiary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_TX,
-		.stream_name = "Tertiary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_RX,
-		.stream_name = "Quaternary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_TX,
-		.stream_name = "Quaternary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
-	/* Primary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_AUXPCM_RX,
-		.stream_name = "AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_AUXPCM_TX,
-		.stream_name = "AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Secondary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_SEC_AUXPCM_RX,
-		.stream_name = "Sec AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SEC_AUXPCM_TX,
-		.stream_name = "Sec AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Tertiary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_TERT_AUXPCM_RX,
-		.stream_name = "Tert AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_TERT_AUXPCM_TX,
-		.stream_name = "Tert AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Quaternary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_RX,
-		.stream_name = "Quat AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_TX,
-		.stream_name = "Quat AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_7_RX,
-		.stream_name = "Slimbus7 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16398",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		/* BT codec driver determines capabilities based on
-		 * dai name, bt codecdai name should always contains
-		 * supported usecase information
-		 */
-		.codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_7_TX,
-		.stream_name = "Slimbus7 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16399",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_bt_sco_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_8_TX,
-		.stream_name = "Slimbus8 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16401",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_fm_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
-		.be_hw_params_fixup = msm_ext_be_hw_params_fixup,
-		.init = &msm_wcn_init,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
-	/* DISP PORT BACK END DAI Link */
-	{
-		.name = LPASS_BE_DISPLAY_PORT,
-		.stream_name = "Display Port Playback",
-		.cpu_dai_name = "msm-dai-q6-dp.24608",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-ext-disp-audio-codec-rx",
-		.codec_dai_name = "msm_dp_audio_codec_rx_dai",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_ext_tasha_dai_links[
-ARRAY_SIZE(msm_ext_common_fe_dai) +
-ARRAY_SIZE(msm_ext_tasha_fe_dai) +
-ARRAY_SIZE(msm_ext_common_be_dai) +
-ARRAY_SIZE(msm_ext_tasha_be_dai) +
-ARRAY_SIZE(msm_mi2s_be_dai_links) +
-ARRAY_SIZE(msm_auxpcm_be_dai_links) +
-ARRAY_SIZE(msm_wcn_be_dai_links) +
-ARRAY_SIZE(ext_disp_be_dai_link)];
-
-static struct snd_soc_dai_link msm_ext_tavil_dai_links[
-ARRAY_SIZE(msm_ext_common_fe_dai) +
-ARRAY_SIZE(msm_ext_tavil_fe_dai) +
-ARRAY_SIZE(msm_ext_common_be_dai) +
-ARRAY_SIZE(msm_ext_tavil_be_dai) +
-ARRAY_SIZE(msm_mi2s_be_dai_links) +
-ARRAY_SIZE(msm_auxpcm_be_dai_links) +
-ARRAY_SIZE(msm_wcn_be_dai_links) +
-ARRAY_SIZE(ext_disp_be_dai_link)];
-
-/**
- * populate_snd_card_dailinks - prepares dailink array and initializes card.
- *
- * @dev: device handle
- *
- * Returns card on success or NULL on failure.
- */
-struct snd_soc_card *populate_snd_card_dailinks(struct device *dev,
-						int snd_card_val)
-{
-	struct snd_soc_card *card;
-	struct snd_soc_dai_link *msm_ext_dai_links = NULL;
-	int ret, len1, len2, len3, len4;
-	enum codec_variant codec_ver = 0;
-
-	if (snd_card_val == EXT_SND_CARD_TASHA) {
-		card = &snd_soc_card_msm_card_tasha;
-	} else if (snd_card_val == EXT_SND_CARD_TAVIL) {
-		card = &snd_soc_card_msm_card_tavil;
-	} else {
-		dev_err(dev, "%s: failing as no matching card name\n",
-			__func__);
-		return NULL;
-	}
-
-	card->dev = dev;
-	ret = snd_soc_of_parse_card_name(card, "qcom,model");
-	if (ret) {
-		dev_err(dev, "%s: parse card name failed, err:%d\n",
-			__func__, ret);
-		return NULL;
-	}
-
-	if (strnstr(card->name, "tasha", strlen(card->name))) {
-		codec_ver = tasha_codec_ver();
-		if (codec_ver == WCD9326)
-			card->name = "sdm660-tashalite-snd-card";
-
-		len1 = ARRAY_SIZE(msm_ext_common_fe_dai);
-		len2 = len1 + ARRAY_SIZE(msm_ext_tasha_fe_dai);
-		len3 = len2 + ARRAY_SIZE(msm_ext_common_be_dai);
-		memcpy(msm_ext_tasha_dai_links, msm_ext_common_fe_dai,
-		       sizeof(msm_ext_common_fe_dai));
-		memcpy(msm_ext_tasha_dai_links + len1,
-		       msm_ext_tasha_fe_dai, sizeof(msm_ext_tasha_fe_dai));
-		memcpy(msm_ext_tasha_dai_links + len2,
-		       msm_ext_common_be_dai, sizeof(msm_ext_common_be_dai));
-		memcpy(msm_ext_tasha_dai_links + len3,
-		       msm_ext_tasha_be_dai, sizeof(msm_ext_tasha_be_dai));
-		len4 = len3 + ARRAY_SIZE(msm_ext_tasha_be_dai);
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,mi2s-audio-intf")) {
-			memcpy(msm_ext_tasha_dai_links + len4,
-			       msm_mi2s_be_dai_links,
-			       sizeof(msm_mi2s_be_dai_links));
-			len4 += ARRAY_SIZE(msm_mi2s_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,auxpcm-audio-intf")) {
-			memcpy(msm_ext_tasha_dai_links + len4,
-			       msm_auxpcm_be_dai_links,
-			       sizeof(msm_auxpcm_be_dai_links));
-			len4 += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-			dev_dbg(dev, "%s(): WCN BTFM support present\n",
-					__func__);
-			memcpy(msm_ext_tasha_dai_links + len4,
-				   msm_wcn_be_dai_links,
-				   sizeof(msm_wcn_be_dai_links));
-			len4 += ARRAY_SIZE(msm_wcn_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,ext-disp-audio-rx")) {
-			dev_dbg(dev, "%s(): ext disp audio support present\n",
-					__func__);
-			memcpy(msm_ext_tasha_dai_links + len4,
-				ext_disp_be_dai_link,
-				sizeof(ext_disp_be_dai_link));
-			len4 += ARRAY_SIZE(ext_disp_be_dai_link);
-		}
-		msm_ext_dai_links = msm_ext_tasha_dai_links;
-	} else if (strnstr(card->name, "tavil", strlen(card->name))) {
-		len1 = ARRAY_SIZE(msm_ext_common_fe_dai);
-		len2 = len1 + ARRAY_SIZE(msm_ext_tavil_fe_dai);
-		len3 = len2 + ARRAY_SIZE(msm_ext_common_be_dai);
-		memcpy(msm_ext_tavil_dai_links, msm_ext_common_fe_dai,
-		       sizeof(msm_ext_common_fe_dai));
-		memcpy(msm_ext_tavil_dai_links + len1,
-		       msm_ext_tavil_fe_dai, sizeof(msm_ext_tavil_fe_dai));
-		memcpy(msm_ext_tavil_dai_links + len2,
-		       msm_ext_common_be_dai, sizeof(msm_ext_common_be_dai));
-		memcpy(msm_ext_tavil_dai_links + len3,
-		       msm_ext_tavil_be_dai, sizeof(msm_ext_tavil_be_dai));
-		len4 = len3 + ARRAY_SIZE(msm_ext_tavil_be_dai);
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,mi2s-audio-intf")) {
-			memcpy(msm_ext_tavil_dai_links + len4,
-			       msm_mi2s_be_dai_links,
-			       sizeof(msm_mi2s_be_dai_links));
-			len4 += ARRAY_SIZE(msm_mi2s_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,auxpcm-audio-intf")) {
-			memcpy(msm_ext_tavil_dai_links + len4,
-			       msm_auxpcm_be_dai_links,
-			       sizeof(msm_auxpcm_be_dai_links));
-			len4 += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-			dev_dbg(dev, "%s(): WCN BTFM support present\n",
-					__func__);
-			memcpy(msm_ext_tavil_dai_links + len4,
-				   msm_wcn_be_dai_links,
-				   sizeof(msm_wcn_be_dai_links));
-			len4 += ARRAY_SIZE(msm_wcn_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,ext-disp-audio-rx")) {
-			dev_dbg(dev, "%s(): ext disp audio support present\n",
-					__func__);
-			memcpy(msm_ext_tavil_dai_links + len4,
-				ext_disp_be_dai_link,
-				sizeof(ext_disp_be_dai_link));
-			len4 += ARRAY_SIZE(ext_disp_be_dai_link);
-		}
-		msm_ext_dai_links = msm_ext_tavil_dai_links;
-	} else {
-		dev_err(dev, "%s: failing as no matching card name\n",
-			__func__);
-		return NULL;
-	}
-	card->dai_link = msm_ext_dai_links;
-	card->num_links = len4;
-
-	return card;
-}
-EXPORT_SYMBOL(populate_snd_card_dailinks);
diff --git a/sound/soc/msm/sdm660-external.c b/sound/soc/msm/sdm660-external.c
deleted file mode 100644
index 6bf9e58..0000000
--- a/sound/soc/msm/sdm660-external.c
+++ /dev/null
@@ -1,1849 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/delay.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/module.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/q6core.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "sdm660-common.h"
-#include "sdm660-external.h"
-#include "../codecs/wcd9335.h"
-#include "../codecs/wcd934x/wcd934x.h"
-#include "../codecs/wcd934x/wcd934x-mbhc.h"
-
-#define SDM660_SPK_ON     1
-#define SDM660_SPK_OFF    0
-
-#define WCD9XXX_MBHC_DEF_BUTTONS    8
-#define WCD9XXX_MBHC_DEF_RLOADS     5
-#define CODEC_EXT_CLK_RATE          9600000
-#define ADSP_STATE_READY_TIMEOUT_MS 3000
-
-#define WSA8810_NAME_1 "wsa881x.20170211"
-#define WSA8810_NAME_2 "wsa881x.20170212"
-
-static int msm_ext_spk_control = 1;
-static struct wcd_mbhc_config *wcd_mbhc_cfg_ptr;
-
-struct msm_asoc_wcd93xx_codec {
-	void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
-				   enum afe_config_type config_type);
-	void (*mbhc_hs_detect_exit)(struct snd_soc_codec *codec);
-};
-
-static struct msm_asoc_wcd93xx_codec msm_codec_fn;
-static struct platform_device *spdev;
-
-static bool is_initial_boot;
-
-static void *def_ext_mbhc_cal(void);
-
-enum {
-	SLIM_RX_0 = 0,
-	SLIM_RX_1,
-	SLIM_RX_2,
-	SLIM_RX_3,
-	SLIM_RX_4,
-	SLIM_RX_5,
-	SLIM_RX_6,
-	SLIM_RX_7,
-	SLIM_RX_MAX,
-};
-
-enum {
-	SLIM_TX_0 = 0,
-	SLIM_TX_1,
-	SLIM_TX_2,
-	SLIM_TX_3,
-	SLIM_TX_4,
-	SLIM_TX_5,
-	SLIM_TX_6,
-	SLIM_TX_7,
-	SLIM_TX_8,
-	SLIM_TX_MAX,
-};
-
-struct dev_config {
-	u32 sample_rate;
-	u32 bit_format;
-	u32 channels;
-};
-
-/* Default configuration of slimbus channels */
-static struct dev_config slim_rx_cfg[] = {
-	[SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config slim_tx_cfg[] = {
-	[SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static int msm_vi_feed_tx_ch = 2;
-static const char *const slim_rx_ch_text[] = {"One", "Two"};
-static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
-						"Five", "Six", "Seven",
-						"Eight"};
-static const char *const vi_feed_ch_text[] = {"One", "Two"};
-static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
-					  "S32_LE"};
-static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_88P2", "KHZ_96", "KHZ_176P4",
-					"KHZ_192", "KHZ_352P8", "KHZ_384"};
-static const char *const spk_function_text[] = {"Off", "On"};
-static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(spk_func_en, spk_function_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
-
-static int slim_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 10;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int slim_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int slim_get_bit_format_val(int bit_format)
-{
-	int val = 0;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		val = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		val = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		val = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		val = 0;
-		break;
-	}
-	return val;
-}
-
-static int slim_get_bit_format(int val)
-{
-	int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-
-	switch (val) {
-	case 0:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return bit_fmt;
-}
-
-static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int port_id = 0;
-
-	if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX")))
-		port_id = SLIM_RX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_2_RX", sizeof("SLIM_2_RX")))
-		port_id = SLIM_RX_2;
-	else if (strnstr(kcontrol->id.name, "SLIM_5_RX", sizeof("SLIM_5_RX")))
-		port_id = SLIM_RX_5;
-	else if (strnstr(kcontrol->id.name, "SLIM_6_RX", sizeof("SLIM_6_RX")))
-		port_id = SLIM_RX_6;
-	else if (strnstr(kcontrol->id.name, "SLIM_0_TX", sizeof("SLIM_0_TX")))
-		port_id = SLIM_TX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_1_TX", sizeof("SLIM_1_TX")))
-		port_id = SLIM_TX_1;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	return port_id;
-}
-
-static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	/*
-	 * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
-	 * when used for BT_SCO use case. Return either Rx or Tx sample rate
-	 * value.
-	 */
-	switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
-	case SAMPLING_RATE_48KHZ:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: sample rate = %d", __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate);
-
-	return 0;
-}
-
-static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 0:
-	default:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
-		 __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate,
-		 slim_tx_cfg[SLIM_TX_7].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].sample_rate =
-		slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate = 0;
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-	if (sample_rate == SAMPLING_RATE_44P1KHZ) {
-		pr_err("%s: Unsupported sample rate %d: for Tx path\n",
-			__func__, sample_rate);
-		return -EINVAL;
-	}
-	slim_tx_cfg[ch_num].sample_rate = sample_rate;
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_slim_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_tx_ch  = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
-	pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
-	return 1;
-}
-
-static void *def_ext_mbhc_cal(void)
-{
-	void *wcd_mbhc_cal;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	u16 *btn_high;
-
-	wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
-				WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
-	if (!wcd_mbhc_cal)
-		return NULL;
-
-#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->X) = (Y))
-	S(v_hs_max, 1600);
-#undef S
-#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->X) = (Y))
-	S(num_btn, WCD_MBHC_DEF_BUTTONS);
-#undef S
-
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
-	btn_high = ((void *)&btn_cfg->_v_btn_low) +
-		(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
-
-	btn_high[0] = 75;
-	btn_high[1] = 150;
-	btn_high[2] = 237;
-	btn_high[3] = 500;
-	btn_high[4] = 500;
-	btn_high[5] = 500;
-	btn_high[6] = 500;
-	btn_high[7] = 500;
-
-	return wcd_mbhc_cal;
-}
-
-static inline int param_is_mask(int p)
-{
-	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
-		(p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
-}
-
-static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n)
-{
-	return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
-}
-
-
-static void msm_ext_control(struct snd_soc_codec *codec)
-{
-	struct snd_soc_dapm_context *dapm =
-			snd_soc_codec_get_dapm(codec);
-
-	pr_debug("%s: msm_ext_spk_control = %d", __func__, msm_ext_spk_control);
-	if (msm_ext_spk_control == SDM660_SPK_ON) {
-		snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
-		snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
-	} else {
-		snd_soc_dapm_disable_pin(dapm, "Lineout_1 amp");
-		snd_soc_dapm_disable_pin(dapm, "Lineout_3 amp");
-	}
-	snd_soc_dapm_sync(dapm);
-}
-
-static int msm_ext_get_spk(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: msm_ext_spk_control = %d\n",
-		 __func__, msm_ext_spk_control);
-	ucontrol->value.integer.value[0] = msm_ext_spk_control;
-	return 0;
-}
-
-static int msm_ext_set_spk(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	pr_debug("%s()\n", __func__);
-	if (msm_ext_spk_control == ucontrol->value.integer.value[0])
-		return 0;
-
-	msm_ext_spk_control = ucontrol->value.integer.value[0];
-	msm_ext_control(codec);
-	return 1;
-}
-
-
-int msm_ext_enable_codec_mclk(struct snd_soc_codec *codec, int enable,
-			      bool dapm)
-{
-	int ret;
-
-	pr_debug("%s: enable = %d\n", __func__, enable);
-
-	if (!strcmp(dev_name(codec->dev), "tasha_codec"))
-		ret = tasha_cdc_mclk_enable(codec, enable, dapm);
-	else if (!strcmp(dev_name(codec->dev), "tavil_codec"))
-		ret = tavil_cdc_mclk_enable(codec, enable);
-	else {
-		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static const struct snd_kcontrol_new msm_snd_controls[] = {
-	SOC_ENUM_EXT("Speaker Function", spk_func_en, msm_ext_get_spk,
-			msm_ext_set_spk),
-	SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
-			msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
-			slim_tx_bit_format_get, slim_tx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
-			slim_tx_sample_rate_get, slim_tx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
-			msm_bt_sample_rate_get,
-			msm_bt_sample_rate_put),
-};
-
-static int msm_slim_get_ch_from_beid(int32_t id)
-{
-	int ch_id = 0;
-
-	switch (id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-		ch_id = SLIM_RX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-		ch_id = SLIM_RX_1;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-		ch_id = SLIM_RX_2;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-		ch_id = SLIM_RX_3;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-		ch_id = SLIM_RX_4;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		ch_id = SLIM_RX_6;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-		ch_id = SLIM_TX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		ch_id = SLIM_TX_3;
-		break;
-	default:
-		ch_id = SLIM_RX_0;
-		break;
-	}
-
-	return ch_id;
-}
-
-static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
-{
-	if (bit >= SNDRV_MASK_MAX)
-		return;
-	if (param_is_mask(n)) {
-		struct snd_mask *m = param_to_mask(p, n);
-
-		m->bits[0] = 0;
-		m->bits[1] = 0;
-		m->bits[bit >> 5] |= (1 << (bit & 31));
-	}
-}
-
-/**
- * msm_ext_be_hw_params_fixup - updates settings of ALSA BE hw params.
- *
- * @rtd: runtime dailink instance
- * @params: HW params of associated backend dailink.
- *
- * Returns 0 on success or rc on failure.
- */
-int msm_ext_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-			       struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-	int rc = 0;
-	int idx;
-	void *config = NULL;
-	struct snd_soc_codec *codec = rtd->codec;
-
-	pr_debug("%s: format = %d, rate = %d\n",
-		  __func__, params_format(params), params_rate(params));
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_1_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[1].bit_format);
-		rate->min = rate->max = slim_tx_cfg[1].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[1].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_4_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       SNDRV_PCM_FORMAT_S32_LE);
-		rate->min = rate->max = SAMPLING_RATE_8KHZ;
-		channels->min = channels->max = msm_vi_feed_tx_ch;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[5].bit_format);
-		rate->min = rate->max = slim_rx_cfg[5].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[5].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_TX:
-		rate->min = rate->max = SAMPLING_RATE_16KHZ;
-		channels->min = channels->max = 1;
-
-		config = msm_codec_fn.get_afe_config_fn(codec,
-					AFE_SLIMBUS_SLAVE_PORT_CONFIG);
-		if (config) {
-			rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
-					    config, SLIMBUS_5_TX);
-			if (rc)
-				pr_err("%s: Failed to set slimbus slave port config %d\n",
-					__func__, rc);
-		}
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[SLIM_RX_7].bit_format);
-		rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
-		channels->min = channels->max =
-			slim_rx_cfg[SLIM_RX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_8_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_8].channels;
-		break;
-
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return rc;
-}
-EXPORT_SYMBOL(msm_ext_be_hw_params_fixup);
-
-/**
- * msm_snd_hw_params - hw params ops of backend dailink.
- *
- * @substream: PCM stream of associated backend dailink.
- * @params: HW params of associated backend dailink.
- *
- * Returns 0 on success or ret on failure.
- */
-int msm_snd_hw_params(struct snd_pcm_substream *substream,
-		      struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
-	int ret = 0;
-	u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	u32 user_set_tx_ch = 0;
-	u32 rx_ch_count;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
-			pr_debug("%s: rx_5_ch=%d\n", __func__,
-				  slim_rx_cfg[5].channels);
-			rx_ch_count = slim_rx_cfg[5].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
-			pr_debug("%s: rx_2_ch=%d\n", __func__,
-				 slim_rx_cfg[2].channels);
-			rx_ch_count = slim_rx_cfg[2].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
-			pr_debug("%s: rx_6_ch=%d\n", __func__,
-				  slim_rx_cfg[6].channels);
-			rx_ch_count = slim_rx_cfg[6].channels;
-		} else {
-			pr_debug("%s: rx_0_ch=%d\n", __func__,
-				  slim_rx_cfg[0].channels);
-			rx_ch_count = slim_rx_cfg[0].channels;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-						  rx_ch_count, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-	} else {
-		pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
-			 codec_dai->name, codec_dai->id, user_set_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map\n, err:%d\n",
-				__func__, ret);
-			goto err_ch_map;
-		}
-		/* For <codec>_tx1 case */
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
-			user_set_tx_ch = slim_tx_cfg[0].channels;
-		/* For <codec>_tx3 case */
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
-			user_set_tx_ch = slim_tx_cfg[1].channels;
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
-			user_set_tx_ch = msm_vi_feed_tx_ch;
-		else
-			user_set_tx_ch = tx_ch_cnt;
-
-		pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), id (%d)\n",
-			 __func__,  slim_tx_cfg[0].channels, user_set_tx_ch,
-			 tx_ch_cnt, dai_link->id);
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-						  user_set_tx_ch, tx_ch, 0, 0);
-		if (ret < 0)
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-	}
-
-err_ch_map:
-	return ret;
-}
-EXPORT_SYMBOL(msm_snd_hw_params);
-
-/**
- * msm_ext_slimbus_2_hw_params - hw params ops of slimbus_2 BE.
- *
- * @substream: PCM stream of associated backend dailink.
- * @params: HW params of associated backend dailink.
- *
- * Returns 0 on success or ret on failure.
- */
-int msm_ext_slimbus_2_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
-	unsigned int num_tx_ch = 0;
-	unsigned int num_rx_ch = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		num_rx_ch =  params_channels(params);
-		pr_debug("%s: %s rx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_rx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-				num_rx_ch, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		num_tx_ch =  params_channels(params);
-		pr_debug("%s: %s  tx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-				num_tx_ch, tx_ch, 0, 0);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	}
-end:
-	return ret;
-}
-EXPORT_SYMBOL(msm_ext_slimbus_2_hw_params);
-
-/**
- * msm_snd_cpe_hw_params - hw params ops of CPE backend.
- *
- * @substream: PCM stream of associated backend dailink.
- * @params: HW params of associated backend dailink.
- *
- * Returns 0 on success or ret on failure.
- */
-int msm_snd_cpe_hw_params(struct snd_pcm_substream *substream,
-			  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	int ret = 0;
-	u32 tx_ch[SLIM_MAX_TX_PORTS];
-	u32 tx_ch_cnt = 0;
-
-	if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) {
-		pr_err("%s: Invalid stream type %d\n",
-			__func__, substream->stream);
-		ret = -EINVAL;
-		goto end;
-	}
-
-	pr_debug("%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, NULL, NULL);
-	if (ret < 0) {
-		pr_err("%s: failed to get codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto end;
-	}
-
-	pr_debug("%s: tx_ch_cnt(%d) id %d\n",
-		 __func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  tx_ch_cnt, tx_ch, 0, 0);
-	if (ret < 0) {
-		pr_err("%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-		goto end;
-	}
-end:
-	return ret;
-}
-EXPORT_SYMBOL(msm_snd_cpe_hw_params);
-
-static int msm_afe_set_config(struct snd_soc_codec *codec)
-{
-	int rc;
-	void *config_data;
-
-	pr_debug("%s: enter\n", __func__);
-
-	if (!msm_codec_fn.get_afe_config_fn) {
-		dev_err(codec->dev, "%s: codec get afe config not init'ed\n",
-				__func__);
-		return -EINVAL;
-	}
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-				AFE_CDC_REGISTERS_CONFIG);
-	if (config_data) {
-		rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
-		if (rc) {
-			pr_err("%s: Failed to set codec registers config %d\n",
-					__func__, rc);
-			return rc;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTER_PAGE_CONFIG);
-	if (config_data) {
-		rc = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
-				    0);
-		if (rc)
-			pr_err("%s: Failed to set cdc register page config\n",
-				__func__);
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_SLIMBUS_SLAVE_CONFIG);
-	if (config_data) {
-		rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
-		if (rc) {
-			pr_err("%s: Failed to set slimbus slave config %d\n",
-					__func__, rc);
-			return rc;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_AANC_VERSION);
-	if (config_data) {
-		rc = afe_set_config(AFE_AANC_VERSION, config_data, 0);
-		if (rc) {
-			pr_err("%s: Failed to set AANC version %d\n",
-					__func__, rc);
-			return rc;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-				AFE_CDC_CLIP_REGISTERS_CONFIG);
-	if (config_data) {
-		rc = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
-					config_data, 0);
-		if (rc) {
-			pr_err("%s: Failed to set clip registers %d\n",
-				__func__, rc);
-			return rc;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CLIP_BANK_SEL);
-	if (config_data) {
-		rc = afe_set_config(AFE_CLIP_BANK_SEL,
-				config_data, 0);
-		if (rc) {
-			pr_err("%s: Failed to set AFE bank selection %d\n",
-				__func__, rc);
-			return rc;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTER_PAGE_CONFIG);
-	if (config_data) {
-		rc = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
-				0);
-		if (rc)
-			pr_err("%s: Failed to set cdc register page config\n",
-					__func__);
-	}
-
-	return 0;
-}
-
-static void msm_afe_clear_config(void)
-{
-	afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
-	afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
-}
-
-static int msm_adsp_power_up_config(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	unsigned long timeout;
-	int adsp_ready = 0;
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata;
-
-	pdata = snd_soc_card_get_drvdata(card);
-	timeout = jiffies +
-		msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
-
-	do {
-		if (q6core_is_adsp_ready()) {
-			pr_debug("%s: ADSP Audio is ready\n", __func__);
-			adsp_ready = 1;
-			break;
-		}
-		/*
-		 * ADSP will be coming up after subsystem restart and
-		 * it might not be fully up when the control reaches
-		 * here. So, wait for 50msec before checking ADSP state
-		 */
-		msleep(50);
-	} while (time_after(timeout, jiffies));
-
-	if (!adsp_ready) {
-		pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
-		ret = -ETIMEDOUT;
-		goto err_fail;
-	}
-
-	ret = msm_afe_set_config(codec);
-	if (ret)
-		pr_err("%s: Failed to set AFE config. err %d\n",
-			__func__, ret);
-
-	return 0;
-
-err_fail:
-	return ret;
-}
-
-static int sdm660_notifier_service_cb(struct notifier_block *this,
-					 unsigned long opcode, void *ptr)
-{
-	int ret;
-	struct snd_soc_card *card = NULL;
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_soc_codec *codec;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		/*
-		 * Use flag to ignore initial boot notifications
-		 * On initial boot msm_adsp_power_up_config is
-		 * called on init. There is no need to clear
-		 * and set the config again on initial boot.
-		 */
-		if (is_initial_boot)
-			break;
-		msm_afe_clear_config();
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (is_initial_boot) {
-			is_initial_boot = false;
-			break;
-		}
-		if (!spdev)
-			return -EINVAL;
-
-		card = platform_get_drvdata(spdev);
-		rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-		if (!rtd) {
-			dev_err(card->dev,
-				"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-				__func__, be_dl_name);
-			ret = -EINVAL;
-			goto done;
-		}
-		codec = rtd->codec;
-
-		ret = msm_adsp_power_up_config(codec);
-		if (ret < 0) {
-			dev_err(card->dev,
-				"%s: msm_adsp_power_up_config failed ret = %d!\n",
-				__func__, ret);
-			goto done;
-		}
-		break;
-	default:
-		break;
-	}
-done:
-	return NOTIFY_OK;
-}
-
-static struct notifier_block service_nb = {
-	.notifier_call  = sdm660_notifier_service_cb,
-	.priority = -INT_MAX,
-};
-
-static int msm_config_hph_en0_gpio(struct snd_soc_codec *codec, bool high)
-{
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata;
-	int val;
-
-	if (!card)
-		return 0;
-
-	pdata = snd_soc_card_get_drvdata(card);
-	if (!pdata || !gpio_is_valid(pdata->hph_en0_gpio))
-		return 0;
-
-	val = gpio_get_value_cansleep(pdata->hph_en0_gpio);
-	if ((!!val) == high)
-		return 0;
-
-	gpio_direction_output(pdata->hph_en0_gpio, (int)high);
-
-	return 1;
-}
-
-static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_codec *codec,
-					   int enable, bool dapm)
-{
-	int ret = 0;
-
-	if (!strcmp(dev_name(codec->dev), "tasha_codec"))
-		ret = tasha_cdc_mclk_tx_enable(codec, enable, dapm);
-	else {
-		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int msm_ext_mclk_tx_event(struct snd_soc_dapm_widget *w,
-				 struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_ext_mclk_event(struct snd_soc_dapm_widget *w,
-			      struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_ext_enable_codec_mclk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_ext_enable_codec_mclk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_ext_prepare_hifi(struct msm_asoc_mach_data *pdata)
-{
-	int ret = 0;
-
-	if (gpio_is_valid(pdata->hph_en1_gpio)) {
-		pr_debug("%s: hph_en1_gpio request %d\n", __func__,
-			pdata->hph_en1_gpio);
-		ret = gpio_request(pdata->hph_en1_gpio, "hph_en1_gpio");
-		if (ret) {
-			pr_err("%s: hph_en1_gpio request failed, ret:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	}
-	if (gpio_is_valid(pdata->hph_en0_gpio)) {
-		pr_debug("%s: hph_en0_gpio request %d\n", __func__,
-			pdata->hph_en0_gpio);
-		ret = gpio_request(pdata->hph_en0_gpio, "hph_en0_gpio");
-		if (ret)
-			pr_err("%s: hph_en0_gpio request failed, ret:%d\n",
-				__func__, ret);
-	}
-
-err:
-	return ret;
-}
-
-static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
-
-	SND_SOC_DAPM_SUPPLY_S("MCLK", -1,  SND_SOC_NOPM, 0, 0,
-	msm_ext_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SUPPLY_S("MCLK TX", -1,  SND_SOC_NOPM, 0, 0,
-	msm_ext_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_3 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_4 amp", NULL),
-	SND_SOC_DAPM_MIC("Handset Mic", NULL),
-	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("Secondary Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic4", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic6", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic7", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic8", NULL),
-
-	SND_SOC_DAPM_MIC("Digital Mic0", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic1", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic2", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic3", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic4", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic5", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic6", NULL),
-};
-
-static struct snd_soc_dapm_route wcd_audio_paths_tasha[] = {
-	{"MIC BIAS1", NULL, "MCLK TX"},
-	{"MIC BIAS2", NULL, "MCLK TX"},
-	{"MIC BIAS3", NULL, "MCLK TX"},
-	{"MIC BIAS4", NULL, "MCLK TX"},
-};
-
-static struct snd_soc_dapm_route wcd_audio_paths[] = {
-	{"MIC BIAS1", NULL, "MCLK"},
-	{"MIC BIAS2", NULL, "MCLK"},
-	{"MIC BIAS3", NULL, "MCLK"},
-	{"MIC BIAS4", NULL, "MCLK"},
-};
-
-int msm_snd_card_tasha_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-	void *mbhc_calibration;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		ret = -EINVAL;
-		goto err_pcm_runtime;
-	}
-
-	mbhc_calibration = def_ext_mbhc_cal();
-	if (!mbhc_calibration) {
-		ret = -ENOMEM;
-		goto err_mbhc_cal;
-	}
-	wcd_mbhc_cfg_ptr->calibration = mbhc_calibration;
-	ret = tasha_mbhc_hs_detect(rtd->codec, wcd_mbhc_cfg_ptr);
-	if (ret) {
-		dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
-			__func__, ret);
-		goto err_hs_detect;
-	}
-	return 0;
-
-err_hs_detect:
-	kfree(mbhc_calibration);
-err_mbhc_cal:
-err_pcm_runtime:
-	return ret;
-}
-
-int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-	void *mbhc_calibration;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	mbhc_calibration = def_ext_mbhc_cal();
-	if (!mbhc_calibration) {
-		ret = -ENOMEM;
-		goto err;
-	}
-	wcd_mbhc_cfg_ptr->calibration = mbhc_calibration;
-	ret = tavil_mbhc_hs_detect(rtd->codec, wcd_mbhc_cfg_ptr);
-	if (ret) {
-		dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
-			__func__, ret);
-		goto err_free_mbhc_cal;
-	}
-	return 0;
-
-err_free_mbhc_cal:
-	kfree(mbhc_calibration);
-err:
-	return ret;
-}
-
-/**
- * msm_audrx_init - Audio init function of sound card instantiate.
- *
- * @rtd: runtime dailink instance
- *
- * Returns 0 on success or ret on failure.
- */
-int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret;
-	void *config_data;
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm =
-			snd_soc_codec_get_dapm(codec);
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_component *aux_comp;
-	struct snd_card *card;
-	struct snd_info_entry *entry;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(rtd->card);
-
-	/* Codec SLIMBUS configuration
-	 * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
-	 * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
-	 * TX14, TX15, TX16
-	 */
-	unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
-					    151, 152, 153, 154, 155, 156};
-	unsigned int tx_ch[TASHA_TX_MAX]  = {128, 129, 130, 131, 132, 133,
-					     134, 135, 136, 137, 138, 139,
-					     140, 141, 142, 143};
-
-	/* Tavil Codec SLIMBUS configuration
-	 * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
-	 * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
-	 * TX14, TX15, TX16
-	 */
-	unsigned int rx_ch_tavil[WCD934X_RX_MAX] = {144, 145, 146, 147, 148,
-					    149, 150, 151};
-	unsigned int tx_ch_tavil[WCD934X_TX_MAX] = {128, 129, 130, 131, 132,
-					    133, 134, 135, 136, 137, 138,
-					    139, 140, 141, 142, 143};
-
-	pr_debug("%s: dev_name%s\n", __func__, dev_name(cpu_dai->dev));
-
-	rtd->pmdown_time = 0;
-
-	ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
-					 ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		pr_err("%s: add_codec_controls failed: %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	ret = snd_soc_add_codec_controls(codec, msm_common_snd_controls,
-					 msm_common_snd_controls_size());
-	if (ret < 0) {
-		pr_err("%s: add_common_snd_controls failed: %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
-			ARRAY_SIZE(msm_dapm_widgets));
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec"))
-		snd_soc_dapm_add_routes(dapm, wcd_audio_paths_tasha,
-					ARRAY_SIZE(wcd_audio_paths_tasha));
-	else
-		snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
-					ARRAY_SIZE(wcd_audio_paths));
-
-	snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
-	snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
-	snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
-	snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
-
-	snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Secondary Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Lineout_1 amp");
-	snd_soc_dapm_ignore_suspend(dapm, "Lineout_3 amp");
-	snd_soc_dapm_ignore_suspend(dapm, "Lineout_2 amp");
-	snd_soc_dapm_ignore_suspend(dapm, "Lineout_4 amp");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic6");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic7");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic8");
-
-	snd_soc_dapm_ignore_suspend(dapm, "EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC5");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC0");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC1");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC2");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC3");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC4");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC5");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHL");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHR");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
-	snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
-		snd_soc_dapm_ignore_suspend(dapm, "LINEOUT3");
-		snd_soc_dapm_ignore_suspend(dapm, "LINEOUT4");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT1");
-		snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT2");
-	} else {
-		snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
-		snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT2");
-	}
-
-	snd_soc_dapm_sync(dapm);
-
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch_tavil),
-					tx_ch_tavil, ARRAY_SIZE(rx_ch_tavil),
-					rx_ch_tavil);
-	} else {
-		snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					tx_ch, ARRAY_SIZE(rx_ch),
-					rx_ch);
-	}
-
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
-	} else {
-		msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
-		msm_codec_fn.mbhc_hs_detect_exit = tasha_mbhc_hs_detect_exit;
-	}
-
-	ret = msm_adsp_power_up_config(codec);
-	if (ret) {
-		pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
-		goto err_afe_cfg;
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-						     AFE_AANC_VERSION);
-	if (config_data) {
-		ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
-		if (ret) {
-			pr_err("%s: Failed to set aanc version %d\n",
-				__func__, ret);
-			goto err_afe_cfg;
-		}
-	}
-
-	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
-		config_data = msm_codec_fn.get_afe_config_fn(codec,
-						AFE_CDC_CLIP_REGISTERS_CONFIG);
-		if (config_data) {
-			ret = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
-						 config_data, 0);
-			if (ret) {
-				pr_err("%s: Failed to set clip registers %d\n",
-					__func__, ret);
-				goto err_afe_cfg;
-			}
-		}
-		config_data = msm_codec_fn.get_afe_config_fn(codec,
-				AFE_CLIP_BANK_SEL);
-		if (config_data) {
-			ret = afe_set_config(AFE_CLIP_BANK_SEL, config_data, 0);
-			if (ret) {
-				pr_err("%s: Failed to set AFE bank selection %d\n",
-					__func__, ret);
-				goto err_afe_cfg;
-			}
-		}
-	}
-
-	/*
-	 * Send speaker configuration only for WSA8810.
-	 * Defalut configuration is for WSA8815.
-	 */
-	pr_debug("%s: Number of aux devices: %d\n",
-		__func__, rtd->card->num_aux_devs);
-
-	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
-		if (rtd->card->num_aux_devs &&
-		    !list_empty(&rtd->card->aux_comp_list)) {
-			aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-				struct snd_soc_component, list_aux);
-			if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-			    !strcmp(aux_comp->name, WSA8810_NAME_2)) {
-				tavil_set_spkr_mode(rtd->codec, SPKR_MODE_1);
-				tavil_set_spkr_gain_offset(rtd->codec,
-							RX_GAIN_OFFSET_M1P5_DB);
-			}
-		}
-		card = rtd->card->snd_card;
-		entry = snd_info_create_subdir(card->module, "codecs",
-						 card->proc_root);
-		if (!entry) {
-			pr_debug("%s: Cannot create codecs module entry\n",
-				 __func__);
-			goto done;
-		}
-		pdata->codec_root = entry;
-		tavil_codec_info_create_codec_entry(pdata->codec_root, codec);
-	} else {
-		if (rtd->card->num_aux_devs &&
-		    !list_empty(&rtd->card->aux_comp_list)) {
-			aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-				struct snd_soc_component, list_aux);
-			if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-			    !strcmp(aux_comp->name, WSA8810_NAME_2)) {
-				tasha_set_spkr_mode(rtd->codec, SPKR_MODE_1);
-				tasha_set_spkr_gain_offset(rtd->codec,
-							RX_GAIN_OFFSET_M1P5_DB);
-			}
-		}
-		card = rtd->card->snd_card;
-		entry = snd_info_create_subdir(card->module, "codecs",
-						 card->proc_root);
-		if (!entry) {
-			pr_debug("%s: Cannot create codecs module entry\n",
-				 __func__);
-			goto done;
-		}
-		pdata->codec_root = entry;
-		tasha_codec_info_create_codec_entry(pdata->codec_root, codec);
-		tasha_mbhc_zdet_gpio_ctrl(msm_config_hph_en0_gpio, rtd->codec);
-	}
-done:
-	msm_set_codec_reg_done(true);
-	return 0;
-
-err_afe_cfg:
-	return ret;
-}
-EXPORT_SYMBOL(msm_audrx_init);
-
-/**
- * msm_ext_register_audio_notifier - register SSR notifier.
- */
-void msm_ext_register_audio_notifier(struct platform_device *pdev)
-{
-	int ret;
-
-	is_initial_boot = true;
-	spdev = pdev;
-	ret = audio_notifier_register("sdm660", AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &service_nb);
-	if (ret < 0)
-		pr_err("%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-}
-EXPORT_SYMBOL(msm_ext_register_audio_notifier);
-
-/**
- * msm_ext_cdc_init - external codec machine specific init.
- *
- * @pdev: platform device handle
- * @pdata: private data of machine driver
- * @card: sound card pointer reference
- * @mbhc_cfg: MBHC config reference
- *
- * Returns 0 on success or ret on failure.
- */
-int msm_ext_cdc_init(struct platform_device *pdev,
-		     struct msm_asoc_mach_data *pdata,
-		     struct snd_soc_card **card,
-		     struct wcd_mbhc_config *wcd_mbhc_cfg_ptr1)
-{
-	int ret = 0;
-
-	wcd_mbhc_cfg_ptr = wcd_mbhc_cfg_ptr1;
-	pdev->id = 0;
-	wcd_mbhc_cfg_ptr->moisture_en = true;
-	wcd_mbhc_cfg_ptr->mbhc_micbias = MIC_BIAS_2;
-	wcd_mbhc_cfg_ptr->anc_micbias = MIC_BIAS_2;
-	wcd_mbhc_cfg_ptr->enable_anc_mic_detect = false;
-
-	*card = populate_snd_card_dailinks(&pdev->dev, pdata->snd_card_val);
-	if (!(*card)) {
-		dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
-		ret = -EPROBE_DEFER;
-		goto err;
-	}
-	platform_set_drvdata(pdev, *card);
-	snd_soc_card_set_drvdata(*card, pdata);
-	pdata->hph_en1_gpio = of_get_named_gpio(pdev->dev.of_node,
-						"qcom,hph-en1-gpio", 0);
-	if (!gpio_is_valid(pdata->hph_en1_gpio))
-		pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,hph-en1-gpio", 0);
-	if (!gpio_is_valid(pdata->hph_en1_gpio) && (!pdata->hph_en1_gpio_p)) {
-		dev_dbg(&pdev->dev, "property %s not detected in node %s",
-			"qcom,hph-en1-gpio", pdev->dev.of_node->full_name);
-	}
-
-	pdata->hph_en0_gpio = of_get_named_gpio(pdev->dev.of_node,
-						"qcom,hph-en0-gpio", 0);
-	if (!gpio_is_valid(pdata->hph_en0_gpio))
-		pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,hph-en0-gpio", 0);
-	if (!gpio_is_valid(pdata->hph_en0_gpio) && (!pdata->hph_en0_gpio_p)) {
-		dev_dbg(&pdev->dev, "property %s not detected in node %s",
-			"qcom,hph-en0-gpio", pdev->dev.of_node->full_name);
-	}
-
-	ret = msm_ext_prepare_hifi(pdata);
-	if (ret) {
-		dev_dbg(&pdev->dev, "msm_ext_prepare_hifi failed (%d)\n",
-			ret);
-		ret = 0;
-	}
-err:
-	return ret;
-}
-EXPORT_SYMBOL(msm_ext_cdc_init);
diff --git a/sound/soc/msm/sdm660-external.h b/sound/soc/msm/sdm660-external.h
deleted file mode 100644
index 0648c01..0000000
--- a/sound/soc/msm/sdm660-external.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __SDM660_EXTERNAL
-#define __SDM660_EXTERNAL
-
-int msm_snd_hw_params(struct snd_pcm_substream *substream,
-		      struct snd_pcm_hw_params *params);
-int msm_ext_slimbus_2_hw_params(struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params);
-int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				 struct snd_pcm_hw_params *params);
-int msm_proxy_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				    struct snd_pcm_hw_params *params);
-int msm_proxy_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				    struct snd_pcm_hw_params *params);
-int msm_audrx_init(struct snd_soc_pcm_runtime *rtd);
-int msm_snd_cpe_hw_params(struct snd_pcm_substream *substream,
-			  struct snd_pcm_hw_params *params);
-struct snd_soc_card *populate_snd_card_dailinks(struct device *dev,
-						int snd_card_val);
-int msm_ext_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-			       struct snd_pcm_hw_params *params);
-int msm_snd_card_tavil_late_probe(struct snd_soc_card *card);
-int msm_snd_card_tasha_late_probe(struct snd_soc_card *card);
-#ifdef CONFIG_SND_SOC_EXT_CODEC
-int msm_ext_cdc_init(struct platform_device *, struct msm_asoc_mach_data *,
-		     struct snd_soc_card **, struct wcd_mbhc_config *);
-void msm_ext_register_audio_notifier(struct platform_device *pdev);
-#else
-inline int msm_ext_cdc_init(struct platform_device *pdev,
-			    struct msm_asoc_mach_data *pdata,
-			    struct snd_soc_card **card,
-			    struct wcd_mbhc_config *wcd_mbhc_cfg_ptr1)
-{
-	return 0;
-}
-
-inline void msm_ext_register_audio_notifier(struct platform_device *pdev)
-{
-}
-#endif
-#endif
diff --git a/sound/soc/msm/sdm660-internal.c b/sound/soc/msm/sdm660-internal.c
deleted file mode 100644
index 14e7308..0000000
--- a/sound/soc/msm/sdm660-internal.c
+++ /dev/null
@@ -1,3157 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/module.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/pcm_params.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "sdm660-common.h"
-#include "../codecs/sdm660_cdc/msm-digital-cdc.h"
-#include "../codecs/sdm660_cdc/msm-analog-cdc.h"
-#include "../codecs/msm_sdw/msm_sdw.h"
-
-#define __CHIPSET__ "SDM660 "
-#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
-
-#define DEFAULT_MCLK_RATE 9600000
-#define NATIVE_MCLK_RATE 11289600
-
-#define WCD_MBHC_DEF_RLOADS 5
-
-#define WCN_CDC_SLIM_RX_CH_MAX 2
-#define WCN_CDC_SLIM_TX_CH_MAX 3
-
-#define WSA8810_NAME_1 "wsa881x.20170211"
-#define WSA8810_NAME_2 "wsa881x.20170212"
-
-enum {
-	INT0_MI2S = 0,
-	INT1_MI2S,
-	INT2_MI2S,
-	INT3_MI2S,
-	INT4_MI2S,
-	INT5_MI2S,
-	INT6_MI2S,
-	INT_MI2S_MAX,
-};
-
-enum {
-	BT_SLIM7,
-	FM_SLIM8,
-	SLIM_MAX,
-};
-
-/*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */
-static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
-	{0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */
-};
-
-static struct afe_clk_set int_mi2s_clk[INT_MI2S_MAX] = {
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT1_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT2_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT4_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT5_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_INT6_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-};
-
-struct dev_config {
-	u32 sample_rate;
-	u32 bit_format;
-	u32 channels;
-};
-
-/* Default configuration of MI2S channels */
-static struct dev_config int_mi2s_cfg[] = {
-	[INT0_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[INT1_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[INT2_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[INT3_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[INT4_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[INT5_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[INT6_MI2S] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config bt_fm_cfg[] = {
-	[BT_SLIM7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[FM_SLIM8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static char const *int_mi2s_rate_text[] = {"KHZ_8", "KHZ_16",
-					   "KHZ_32", "KHZ_44P1", "KHZ_48",
-					   "KHZ_96", "KHZ_192"};
-static const char *const int_mi2s_ch_text[] = {"One", "Two"};
-static const char *const int_mi2s_tx_ch_text[] = {"One", "Two",
-						"Three", "Four"};
-static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
-static const char *const loopback_mclk_text[] = {"DISABLE", "ENABLE"};
-static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_sample_rate, int_mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_chs, int_mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_sample_rate, int_mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_chs, int_mi2s_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_sample_rate, int_mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_chs, int_mi2s_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_sample_rate, int_mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_chs, int_mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(int5_mi2s_tx_chs, int_mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(loopback_mclk_en, loopback_mclk_text);
-static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
-
-static int msm_dmic_event(struct snd_soc_dapm_widget *w,
-			  struct snd_kcontrol *kcontrol, int event);
-static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec, int enable,
-				      bool dapm);
-static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w,
-			      struct snd_kcontrol *kcontrol, int event);
-static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream);
-static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream);
-
-static struct wcd_mbhc_config *mbhc_cfg_ptr;
-static struct snd_info_entry *codec_root;
-
-static int int_mi2s_get_bit_format_val(int bit_format)
-{
-	int val = 0;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		val = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		val = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		val = 0;
-		break;
-	}
-	return val;
-}
-
-static int int_mi2s_get_bit_format(int val)
-{
-	int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-
-	switch (val) {
-	case 0:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	default:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return bit_fmt;
-}
-
-static int int_mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int port_id = 0;
-
-	if (strnstr(kcontrol->id.name, "INT0_MI2S", sizeof("INT0_MI2S")))
-		port_id = INT0_MI2S;
-	else if (strnstr(kcontrol->id.name, "INT2_MI2S", sizeof("INT2_MI2S")))
-		port_id = INT2_MI2S;
-	else if (strnstr(kcontrol->id.name, "INT3_MI2S", sizeof("INT3_MI2S")))
-		port_id = INT3_MI2S;
-	else if (strnstr(kcontrol->id.name, "INT4_MI2S", sizeof("INT4_MI2S")))
-		port_id = INT4_MI2S;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	return port_id;
-}
-
-static int int_mi2s_bit_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = int_mi2s_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		int_mi2s_get_bit_format_val(int_mi2s_cfg[ch_num].bit_format);
-
-	pr_debug("%s: int_mi2s[%d]_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, int_mi2s_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int int_mi2s_bit_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = int_mi2s_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	int_mi2s_cfg[ch_num].bit_format =
-		int_mi2s_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: int_mi2s[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, int_mi2s_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static inline int param_is_mask(int p)
-{
-	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
-			(p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
-}
-
-static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
-					     int n)
-{
-	return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
-}
-
-static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
-{
-	if (bit >= SNDRV_MASK_MAX)
-		return;
-	if (param_is_mask(n)) {
-		struct snd_mask *m = param_to_mask(p, n);
-
-		m->bits[0] = 0;
-		m->bits[1] = 0;
-		m->bits[bit >> 5] |= (1 << (bit & 31));
-	}
-}
-
-static int int_mi2s_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int int_mi2s_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int int_mi2s_sample_rate_put(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = int_mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	int_mi2s_cfg[idx].sample_rate =
-		int_mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__,
-		 idx, int_mi2s_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int int_mi2s_sample_rate_get(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = int_mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		int_mi2s_get_sample_rate_val(int_mi2s_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__,
-		 idx, int_mi2s_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int int_mi2s_ch_get(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = int_mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: int_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, int_mi2s_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = int_mi2s_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int int_mi2s_ch_put(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = int_mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	int_mi2s_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: int_mi2s_[%d]_ch  = %d\n", __func__,
-		 idx, int_mi2s_cfg[idx].channels);
-
-	return 1;
-}
-
-static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
-	SND_SOC_DAPM_SUPPLY_S("INT_MCLK0", -1, SND_SOC_NOPM, 0, 0,
-	msm_int_mclk0_event, SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_MIC("Handset Mic", NULL),
-	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("Secondary Mic", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
-	SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
-	SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
-	SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
-};
-
-static int msm_config_hph_compander_gpio(bool enable,
-					 struct snd_soc_codec *codec)
-{
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	int ret = 0;
-
-	pr_debug("%s: %s HPH Compander\n", __func__,
-		enable ? "Enable" : "Disable");
-
-	if (enable) {
-		ret = msm_cdc_pinctrl_select_active_state(pdata->comp_gpio_p);
-		if (ret) {
-			pr_err("%s: gpio set cannot be activated %s\n",
-				__func__, "comp_gpio");
-			goto done;
-		}
-	} else {
-		ret = msm_cdc_pinctrl_select_sleep_state(pdata->comp_gpio_p);
-		if (ret) {
-			pr_err("%s: gpio set cannot be de-activated %s\n",
-				__func__, "comp_gpio");
-			goto done;
-		}
-	}
-
-done:
-	return ret;
-}
-
-static int is_ext_spk_gpio_support(struct platform_device *pdev,
-				   struct msm_asoc_mach_data *pdata)
-{
-	const char *spk_ext_pa = "qcom,msm-spk-ext-pa";
-
-	pr_debug("%s:Enter\n", __func__);
-
-	pdata->spk_ext_pa_gpio = of_get_named_gpio(pdev->dev.of_node,
-				spk_ext_pa, 0);
-
-	if (pdata->spk_ext_pa_gpio < 0) {
-		dev_dbg(&pdev->dev,
-			"%s: missing %s in dt node\n", __func__, spk_ext_pa);
-	} else {
-		if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) {
-			pr_err("%s: Invalid external speaker gpio: %d",
-				__func__, pdata->spk_ext_pa_gpio);
-			return -EINVAL;
-		}
-	}
-	return 0;
-}
-
-static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable)
-{
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	int ret;
-
-	if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) {
-		pr_err("%s: Invalid gpio: %d\n", __func__,
-			pdata->spk_ext_pa_gpio);
-		return false;
-	}
-
-	pr_debug("%s: %s external speaker PA\n", __func__,
-		enable ? "Enable" : "Disable");
-
-	if (enable) {
-		ret = msm_cdc_pinctrl_select_active_state(
-						pdata->ext_spk_gpio_p);
-		if (ret) {
-			pr_err("%s: gpio set cannot be de-activated %s\n",
-					__func__, "ext_spk_gpio");
-			return ret;
-		}
-		gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
-	} else {
-		gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
-		ret = msm_cdc_pinctrl_select_sleep_state(
-						pdata->ext_spk_gpio_p);
-		if (ret) {
-			pr_err("%s: gpio set cannot be de-activated %s\n",
-					__func__, "ext_spk_gpio");
-			return ret;
-		}
-	}
-	return 0;
-}
-
-static int int_mi2s_get_idx_from_beid(int32_t id)
-{
-	int idx = 0;
-
-	switch (id) {
-	case MSM_BACKEND_DAI_INT0_MI2S_RX:
-		idx = INT0_MI2S;
-		break;
-	case MSM_BACKEND_DAI_INT2_MI2S_TX:
-		idx = INT2_MI2S;
-		break;
-	case MSM_BACKEND_DAI_INT3_MI2S_TX:
-		idx = INT3_MI2S;
-		break;
-	case MSM_BACKEND_DAI_INT4_MI2S_RX:
-		idx = INT4_MI2S;
-		break;
-	case MSM_BACKEND_DAI_INT5_MI2S_TX:
-		idx = INT5_MI2S;
-		break;
-	default:
-		idx = INT0_MI2S;
-		break;
-	}
-
-	return idx;
-}
-
-static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				  struct snd_pcm_hw_params *params)
-{
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	pr_debug("%s()\n", __func__);
-	rate->min = rate->max = 48000;
-	channels->min = channels->max = 2;
-
-	return 0;
-}
-
-static int int_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-	int idx;
-
-	pr_debug("%s: format = %d, rate = %d\n",
-		  __func__, params_format(params), params_rate(params));
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_INT0_MI2S_RX:
-	case MSM_BACKEND_DAI_INT2_MI2S_TX:
-	case MSM_BACKEND_DAI_INT3_MI2S_TX:
-	case MSM_BACKEND_DAI_INT4_MI2S_RX:
-	case MSM_BACKEND_DAI_INT5_MI2S_TX:
-		idx = int_mi2s_get_idx_from_beid(dai_link->id);
-		rate->min = rate->max = int_mi2s_cfg[idx].sample_rate;
-		channels->min = channels->max =
-			int_mi2s_cfg[idx].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       int_mi2s_cfg[idx].bit_format);
-		break;
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return 0;
-}
-
-static int msm_btfm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_SLIMBUS_7_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_7_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				bt_fm_cfg[BT_SLIM7].bit_format);
-		rate->min = rate->max = bt_fm_cfg[BT_SLIM7].sample_rate;
-		channels->min = channels->max =
-			bt_fm_cfg[BT_SLIM7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_8_TX:
-		rate->min = rate->max = bt_fm_cfg[FM_SLIM8].sample_rate;
-		channels->min = channels->max =
-			bt_fm_cfg[FM_SLIM8].channels;
-		break;
-
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return 0;
-}
-
-static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] =
-		(int_mi2s_cfg[INT5_MI2S].channels/2 - 1);
-	pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
-				ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	int_mi2s_cfg[INT5_MI2S].channels =
-		roundup_pow_of_two(ucontrol->value.integer.value[0] + 2);
-
-	pr_debug("%s: msm_vi_feed_tx_ch = %d\n",
-		 __func__, int_mi2s_cfg[INT5_MI2S].channels);
-	return 1;
-}
-
-static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec,
-				      int enable, bool dapm)
-{
-	int ret = 0;
-	struct msm_asoc_mach_data *pdata = NULL;
-	int clk_freq_in_hz;
-	bool int_mclk0_freq_chg = false;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	pr_debug("%s: enable %d mclk ref counter %d\n",
-		   __func__, enable,
-		   atomic_read(&pdata->int_mclk0_rsc_ref));
-	if (enable) {
-		if (int_mi2s_cfg[INT0_MI2S].sample_rate ==
-				SAMPLING_RATE_44P1KHZ) {
-			clk_freq_in_hz = NATIVE_MCLK_RATE;
-			pdata->native_clk_set = true;
-		} else {
-			clk_freq_in_hz = pdata->mclk_freq;
-			pdata->native_clk_set = false;
-		}
-
-		if (pdata->digital_cdc_core_clk.clk_freq_in_hz
-				!= clk_freq_in_hz)
-			int_mclk0_freq_chg = true;
-		if (!atomic_read(&pdata->int_mclk0_rsc_ref) ||
-				int_mclk0_freq_chg) {
-			cancel_delayed_work_sync(
-					&pdata->disable_int_mclk0_work);
-			mutex_lock(&pdata->cdc_int_mclk0_mutex);
-			if (atomic_read(&pdata->int_mclk0_enabled) == false ||
-				int_mclk0_freq_chg) {
-				if (atomic_read(&pdata->int_mclk0_enabled)) {
-					pdata->digital_cdc_core_clk.enable = 0;
-					afe_set_lpass_clock_v2(
-						AFE_PORT_ID_INT0_MI2S_RX,
-						&pdata->digital_cdc_core_clk);
-				}
-				pdata->digital_cdc_core_clk.clk_freq_in_hz =
-							clk_freq_in_hz;
-				pdata->digital_cdc_core_clk.enable = 1;
-				ret = afe_set_lpass_clock_v2(
-					AFE_PORT_ID_INT0_MI2S_RX,
-					&pdata->digital_cdc_core_clk);
-				if (ret < 0) {
-					pr_err("%s: failed to enable CCLK\n",
-							__func__);
-					mutex_unlock(
-						&pdata->cdc_int_mclk0_mutex);
-					return ret;
-				}
-				pr_debug("enabled digital codec core clk\n");
-				atomic_set(&pdata->int_mclk0_enabled, true);
-			}
-			mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		}
-		atomic_inc(&pdata->int_mclk0_rsc_ref);
-	} else {
-		cancel_delayed_work_sync(&pdata->disable_int_mclk0_work);
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		if (atomic_read(&pdata->int_mclk0_enabled) == true) {
-			pdata->digital_cdc_core_clk.enable = 0;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT0_MI2S_RX,
-				&pdata->digital_cdc_core_clk);
-			if (ret < 0)
-				pr_err("%s: failed to disable CCLK\n",
-						__func__);
-			atomic_set(&pdata->int_mclk0_enabled, false);
-		}
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-	}
-	return ret;
-}
-
-static int loopback_mclk_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s\n", __func__);
-	return 0;
-}
-
-static int loopback_mclk_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	int ret = -EINVAL;
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	pr_debug("%s: mclk_rsc_ref %d enable %ld\n",
-			__func__, atomic_read(&pdata->int_mclk0_rsc_ref),
-			ucontrol->value.integer.value[0]);
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
-		if (ret) {
-			pr_err("%s: failed to enable the pri gpios: %d\n",
-					__func__, ret);
-			break;
-		}
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		if ((!atomic_read(&pdata->int_mclk0_rsc_ref)) &&
-				(!atomic_read(&pdata->int_mclk0_enabled))) {
-			pdata->digital_cdc_core_clk.enable = 1;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT0_MI2S_RX,
-				&pdata->digital_cdc_core_clk);
-			if (ret < 0) {
-				pr_err("%s: failed to enable the MCLK: %d\n",
-						__func__, ret);
-				mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-				ret = msm_cdc_pinctrl_select_sleep_state(
-							pdata->pdm_gpio_p);
-				if (ret)
-					pr_err("%s: failed to disable the pri gpios: %d\n",
-							__func__, ret);
-				break;
-			}
-			atomic_set(&pdata->int_mclk0_enabled, true);
-		}
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		atomic_inc(&pdata->int_mclk0_rsc_ref);
-		msm_anlg_cdc_mclk_enable(codec, 1, true);
-		break;
-	case 0:
-		if (atomic_read(&pdata->int_mclk0_rsc_ref) <= 0)
-			break;
-		msm_anlg_cdc_mclk_enable(codec, 0, true);
-		mutex_lock(&pdata->cdc_int_mclk0_mutex);
-		if ((!atomic_dec_return(&pdata->int_mclk0_rsc_ref)) &&
-				(atomic_read(&pdata->int_mclk0_enabled))) {
-			pdata->digital_cdc_core_clk.enable = 0;
-			ret = afe_set_lpass_clock_v2(
-				AFE_PORT_ID_INT0_MI2S_RX,
-				&pdata->digital_cdc_core_clk);
-			if (ret < 0) {
-				pr_err("%s: failed to disable the CCLK: %d\n",
-						__func__, ret);
-				mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-				break;
-			}
-			atomic_set(&pdata->int_mclk0_enabled, false);
-		}
-		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-		ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
-		if (ret)
-			pr_err("%s: failed to disable the pri gpios: %d\n",
-					__func__, ret);
-		break;
-	default:
-		pr_err("%s: Unexpected input value\n", __func__);
-		break;
-	}
-	return ret;
-}
-
-static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	/*
-	 * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
-	 * when used for BT_SCO use case. Return either Rx or Tx sample rate
-	 * value.
-	 */
-	switch (bt_fm_cfg[BT_SLIM7].sample_rate) {
-	case SAMPLING_RATE_48KHZ:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: sample rate = %d", __func__,
-		 bt_fm_cfg[BT_SLIM7].sample_rate);
-
-	return 0;
-}
-
-static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 0:
-	default:
-		bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	pr_debug("%s: sample rates: slim7_rx = %d, value = %d\n",
-		 __func__,
-		 bt_fm_cfg[BT_SLIM7].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new msm_snd_controls[] = {
-	SOC_ENUM_EXT("INT0_MI2S_RX Format", int0_mi2s_rx_format,
-		     int_mi2s_bit_format_get, int_mi2s_bit_format_put),
-	SOC_ENUM_EXT("INT2_MI2S_TX Format", int2_mi2s_tx_format,
-		     int_mi2s_bit_format_get, int_mi2s_bit_format_put),
-	SOC_ENUM_EXT("INT3_MI2S_TX Format", int3_mi2s_tx_format,
-		     int_mi2s_bit_format_get, int_mi2s_bit_format_put),
-	SOC_ENUM_EXT("INT0_MI2S_RX SampleRate", int0_mi2s_rx_sample_rate,
-			int_mi2s_sample_rate_get,
-			int_mi2s_sample_rate_put),
-	SOC_ENUM_EXT("INT2_MI2S_TX SampleRate", int2_mi2s_tx_sample_rate,
-			int_mi2s_sample_rate_get,
-			int_mi2s_sample_rate_put),
-	SOC_ENUM_EXT("INT3_MI2S_TX SampleRate", int3_mi2s_tx_sample_rate,
-			int_mi2s_sample_rate_get,
-			int_mi2s_sample_rate_put),
-	SOC_ENUM_EXT("INT0_MI2S_RX Channels", int0_mi2s_rx_chs,
-			int_mi2s_ch_get, int_mi2s_ch_put),
-	SOC_ENUM_EXT("INT2_MI2S_TX Channels", int2_mi2s_tx_chs,
-			int_mi2s_ch_get, int_mi2s_ch_put),
-	SOC_ENUM_EXT("INT3_MI2S_TX Channels", int3_mi2s_tx_chs,
-			int_mi2s_ch_get, int_mi2s_ch_put),
-	SOC_ENUM_EXT("Loopback MCLK", loopback_mclk_en,
-		     loopback_mclk_get, loopback_mclk_put),
-	SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
-			msm_bt_sample_rate_get,
-			msm_bt_sample_rate_put),
-};
-
-static const struct snd_kcontrol_new msm_sdw_controls[] = {
-	SOC_ENUM_EXT("INT4_MI2S_RX Format", int4_mi2s_rx_format,
-		     int_mi2s_bit_format_get, int_mi2s_bit_format_put),
-	SOC_ENUM_EXT("INT4_MI2S_RX SampleRate", int4_mi2s_rx_sample_rate,
-			int_mi2s_sample_rate_get,
-			int_mi2s_sample_rate_put),
-	SOC_ENUM_EXT("INT4_MI2S_RX Channels", int4_mi2s_rx_chs,
-			int_mi2s_ch_get, int_mi2s_ch_put),
-	SOC_ENUM_EXT("VI_FEED_TX Channels", int5_mi2s_tx_chs,
-		     msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
-};
-
-static int msm_dmic_event(struct snd_soc_dapm_widget *w,
-			  struct snd_kcontrol *kcontrol, int event)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	pr_debug("%s: event = %d\n", __func__, event);
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		ret = msm_cdc_pinctrl_select_active_state(pdata->dmic_gpio_p);
-		if (ret < 0) {
-			pr_err("%s: gpio set cannot be activated %sd",
-					__func__, "dmic_gpio");
-			return ret;
-		}
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		ret = msm_cdc_pinctrl_select_sleep_state(pdata->dmic_gpio_p);
-		if (ret < 0) {
-			pr_err("%s: gpio set cannot be de-activated %sd",
-					__func__, "dmic_gpio");
-			return ret;
-		}
-		break;
-	default:
-		pr_err("%s: invalid DAPM event %d\n", __func__, event);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w,
-			       struct snd_kcontrol *kcontrol, int event)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	int ret = 0;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	pr_debug("%s: event = %d\n", __func__, event);
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMD:
-		pr_debug("%s: mclk_res_ref = %d\n",
-			__func__, atomic_read(&pdata->int_mclk0_rsc_ref));
-		ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
-		if (ret < 0) {
-			pr_err("%s: gpio set cannot be de-activated %sd",
-					__func__, "int_pdm");
-			return ret;
-		}
-		if (atomic_read(&pdata->int_mclk0_rsc_ref) == 0) {
-			pr_debug("%s: disabling MCLK\n", __func__);
-			/* disable the codec mclk config*/
-			msm_anlg_cdc_mclk_enable(codec, 0, true);
-			msm_int_enable_dig_cdc_clk(codec, 0, true);
-		}
-		break;
-	default:
-		pr_err("%s: invalid DAPM event %d\n", __func__, event);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int int_mi2s_get_port_id(int id)
-{
-	int afe_port_id;
-
-	switch (id) {
-	case MSM_BACKEND_DAI_INT0_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_INT0_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_INT2_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_INT2_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_INT3_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_INT3_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_INT4_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_INT4_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_INT5_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_INT5_MI2S_TX;
-		break;
-	default:
-		pr_err("%s: Invalid id: %d\n", __func__, id);
-		afe_port_id = -EINVAL;
-	}
-
-	return afe_port_id;
-}
-
-static int int_mi2s_get_index(int port_id)
-{
-	int index;
-
-	switch (port_id) {
-	case AFE_PORT_ID_INT0_MI2S_RX:
-		index = INT0_MI2S;
-		break;
-	case AFE_PORT_ID_INT2_MI2S_TX:
-		index = INT2_MI2S;
-		break;
-	case AFE_PORT_ID_INT3_MI2S_TX:
-		index = INT3_MI2S;
-		break;
-	case AFE_PORT_ID_INT4_MI2S_RX:
-		index = INT4_MI2S;
-		break;
-	case AFE_PORT_ID_INT5_MI2S_TX:
-		index = INT5_MI2S;
-		break;
-	default:
-		pr_err("%s: Invalid port_id: %d\n", __func__, port_id);
-		index = -EINVAL;
-	}
-
-	return index;
-}
-
-static u32 get_int_mi2s_bits_per_sample(u32 bit_format)
-{
-	u32 bit_per_sample;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S24_3LE:
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bit_per_sample = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bit_per_sample = 16;
-		break;
-	}
-
-	return bit_per_sample;
-}
-
-static void update_int_mi2s_clk_val(int idx, int stream)
-{
-	u32 bit_per_sample;
-
-	bit_per_sample =
-	    get_int_mi2s_bits_per_sample(int_mi2s_cfg[idx].bit_format);
-	int_mi2s_clk[idx].clk_freq_in_hz =
-	    (int_mi2s_cfg[idx].sample_rate * 2 * bit_per_sample);
-}
-
-static int int_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int port_id = 0;
-	int index;
-
-	port_id = int_mi2s_get_port_id(rtd->dai_link->id);
-	if (port_id < 0) {
-		dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
-		ret = port_id;
-		goto done;
-	}
-	index = int_mi2s_get_index(port_id);
-	if (index < 0) {
-		dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
-		ret = port_id;
-		goto done;
-	}
-	if (enable) {
-		update_int_mi2s_clk_val(index, substream->stream);
-		dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
-			int_mi2s_clk[index].clk_freq_in_hz);
-	}
-
-	int_mi2s_clk[index].enable = enable;
-	ret = afe_set_lpass_clock_v2(port_id,
-				     &int_mi2s_clk[index]);
-	if (ret < 0) {
-		dev_err(rtd->card->dev,
-			"%s: afe lpass clock failed for port 0x%x , err:%d\n",
-			__func__, port_id, ret);
-		goto done;
-	}
-
-done:
-	return ret;
-}
-
-static int msm_sdw_mi2s_snd_startup(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	ret = int_mi2s_set_sclk(substream, true);
-	if (ret < 0) {
-		pr_err("%s: failed to enable sclk %d\n",
-				__func__, ret);
-		return ret;
-	}
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static void msm_sdw_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret;
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-			substream->name, substream->stream);
-
-	ret = int_mi2s_set_sclk(substream, false);
-	if (ret < 0)
-		pr_err("%s:clock disable failed; ret=%d\n", __func__,
-				ret);
-}
-
-static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_codec *codec = rtd->codec_dais[ANA_CDC]->codec;
-	int ret = 0;
-	struct msm_asoc_mach_data *pdata = NULL;
-
-	pdata = snd_soc_card_get_drvdata(codec->component.card);
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-
-	ret = int_mi2s_set_sclk(substream, true);
-	if (ret < 0) {
-		pr_err("%s: failed to enable sclk %d\n",
-				__func__, ret);
-		return ret;
-	}
-	ret =  msm_int_enable_dig_cdc_clk(codec, 1, true);
-	if (ret < 0) {
-		pr_err("failed to enable mclk\n");
-		return ret;
-	}
-	/* Enable the codec mclk config */
-	ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
-	if (ret < 0) {
-		pr_err("%s: gpio set cannot be activated %s\n",
-				__func__, "int_pdm");
-		return ret;
-	}
-	msm_anlg_cdc_mclk_enable(codec, 1, true);
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret);
-
-	return ret;
-}
-
-static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-			substream->name, substream->stream);
-
-	ret = int_mi2s_set_sclk(substream, false);
-	if (ret < 0)
-		pr_err("%s:clock disable failed; ret=%d\n", __func__,
-				ret);
-	if (atomic_read(&pdata->int_mclk0_rsc_ref) > 0) {
-		atomic_dec(&pdata->int_mclk0_rsc_ref);
-		pr_debug("%s: decrementing mclk_res_ref %d\n",
-			 __func__,
-			 atomic_read(&pdata->int_mclk0_rsc_ref));
-	}
-}
-
-static void *def_msm_int_wcd_mbhc_cal(void)
-{
-	void *msm_int_wcd_cal;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	u16 *btn_low, *btn_high;
-
-	msm_int_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
-				WCD_MBHC_DEF_RLOADS), GFP_KERNEL);
-	if (!msm_int_wcd_cal)
-		return NULL;
-
-#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(msm_int_wcd_cal)->X) = (Y))
-	S(v_hs_max, 1500);
-#undef S
-#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal)->X) = (Y))
-	S(num_btn, WCD_MBHC_DEF_BUTTONS);
-#undef S
-
-
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal);
-	btn_low = btn_cfg->_v_btn_low;
-	btn_high = ((void *)&btn_cfg->_v_btn_low) +
-		(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
-
-	/*
-	 * In SW we are maintaining two sets of threshold register
-	 * one for current source and another for Micbias.
-	 * all btn_low corresponds to threshold for current source
-	 * all bt_high corresponds to threshold for Micbias
-	 * Below thresholds are based on following resistances
-	 * 0-70    == Button 0
-	 * 110-180 == Button 1
-	 * 210-290 == Button 2
-	 * 360-680 == Button 3
-	 */
-	btn_low[0] = 75;
-	btn_high[0] = 75;
-	btn_low[1] = 150;
-	btn_high[1] = 150;
-	btn_low[2] = 225;
-	btn_high[2] = 225;
-	btn_low[3] = 450;
-	btn_high[3] = 450;
-	btn_low[4] = 500;
-	btn_high[4] = 500;
-
-	return msm_int_wcd_cal;
-}
-
-static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_codec *dig_cdc = rtd->codec_dais[DIG_CDC]->codec;
-	struct snd_soc_codec *ana_cdc = rtd->codec_dais[ANA_CDC]->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(ana_cdc);
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card);
-	struct snd_card *card;
-	int ret = -ENOMEM;
-
-	pr_debug("%s(),dev_name%s\n", __func__, dev_name(cpu_dai->dev));
-
-	ret = snd_soc_add_codec_controls(ana_cdc, msm_snd_controls,
-				   ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		pr_err("%s: add_codec_controls failed: %d\n",
-			__func__, ret);
-		return ret;
-	}
-	ret = snd_soc_add_codec_controls(ana_cdc, msm_common_snd_controls,
-				   msm_common_snd_controls_size());
-	if (ret < 0) {
-		pr_err("%s: add common snd controls failed: %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
-				  ARRAY_SIZE(msm_int_dapm_widgets));
-
-	snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Secondary Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
-
-	snd_soc_dapm_ignore_suspend(dapm, "EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "HEADPHONE");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK_OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
-	snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC1");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC2");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC3");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC4");
-
-	snd_soc_dapm_sync(dapm);
-
-	msm_anlg_cdc_spk_ext_pa_cb(enable_spk_ext_pa, ana_cdc);
-	msm_dig_cdc_hph_comp_cb(msm_config_hph_compander_gpio, dig_cdc);
-
-	card = rtd->card->snd_card;
-	if (!codec_root)
-		codec_root = snd_info_create_subdir(card->module, "codecs",
-						      card->proc_root);
-	if (!codec_root) {
-		pr_debug("%s: Cannot create codecs module entry\n",
-			 __func__);
-		goto done;
-	}
-	pdata->codec_root = codec_root;
-	msm_dig_codec_info_create_codec_entry(codec_root, dig_cdc);
-	msm_anlg_codec_info_create_codec_entry(codec_root, ana_cdc);
-done:
-	msm_set_codec_reg_done(true);
-	return 0;
-}
-
-static int msm_sdw_audrx_init(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm =
-			snd_soc_codec_get_dapm(codec);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card);
-	struct snd_soc_component *aux_comp;
-	struct snd_card *card;
-
-	snd_soc_add_codec_controls(codec, msm_sdw_controls,
-			ARRAY_SIZE(msm_sdw_controls));
-
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW Playback");
-	snd_soc_dapm_ignore_suspend(dapm, "VIfeed_SDW");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW VI");
-	snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_SDW");
-
-	snd_soc_dapm_sync(dapm);
-
-	/*
-	 * Send speaker configuration only for WSA8810.
-	 * Default configuration is for WSA8815.
-	 */
-	pr_debug("%s: Number of aux devices: %d\n",
-		 __func__, rtd->card->num_aux_devs);
-	if (rtd->card->num_aux_devs &&
-		!list_empty(&rtd->card->aux_comp_list)) {
-		aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-					struct snd_soc_component, list_aux);
-		if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-			!strcmp(aux_comp->name, WSA8810_NAME_2)) {
-			msm_sdw_set_spkr_mode(rtd->codec, SPKR_MODE_1);
-			msm_sdw_set_spkr_gain_offset(rtd->codec,
-						   RX_GAIN_OFFSET_M1P5_DB);
-		}
-	}
-	card = rtd->card->snd_card;
-	if (!codec_root)
-		codec_root = snd_info_create_subdir(card->module, "codecs",
-						      card->proc_root);
-	if (!codec_root) {
-		pr_debug("%s: Cannot create codecs module entry\n",
-			 __func__);
-		goto done;
-	}
-	pdata->codec_root = codec_root;
-	msm_sdw_codec_info_create_codec_entry(codec_root, codec);
-done:
-	return 0;
-}
-
-static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
-{
-	unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
-	unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX]  = {159, 160, 161};
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-
-	return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					   tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
-}
-
-static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	int ret;
-
-	dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-	if (ret) {
-		dev_err(rtd->dev,
-			"%s: failed to get BTFM codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto exit;
-	}
-
-	dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) id %d\n",
-		__func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
-	if (ret)
-		dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-
-exit:
-	return ret;
-}
-
-static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width,
-					    int slots)
-{
-	unsigned int slot_mask = 0;
-	int i, j;
-	unsigned int *slot_offset;
-
-	for (i = TDM_0; i < TDM_PORT_MAX; i++) {
-		slot_offset = tdm_slot_offset[i];
-
-		for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) {
-			if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-				slot_mask |=
-				(1 << ((slot_offset[j] * 8) / slot_width));
-			else
-				break;
-		}
-	}
-
-	return slot_mask;
-}
-
-static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int *slot_offset;
-	int offset_channels = 0;
-	int i;
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	channels = params_channels(params);
-	switch (channels) {
-	case 1:
-	case 2:
-	case 3:
-	case 4:
-	case 5:
-	case 6:
-	case 7:
-	case 8:
-		switch (params_format(params)) {
-		case SNDRV_PCM_FORMAT_S32_LE:
-		case SNDRV_PCM_FORMAT_S24_LE:
-		case SNDRV_PCM_FORMAT_S16_LE:
-		/*
-		 * up to 8 channels HW config should
-		 * use 32 bit slot width for max support of
-		 * stream bit width. (slot_width > bit_width)
-		 */
-			slot_width = 32;
-			break;
-		default:
-			pr_err("%s: invalid param format 0x%x\n",
-				__func__, params_format(params));
-			return -EINVAL;
-		}
-		slots = 8;
-		slot_mask = tdm_param_set_slot_mask(cpu_dai->id,
-						    slot_width,
-						    slots);
-		if (!slot_mask) {
-			pr_err("%s: invalid slot_mask 0x%x\n",
-				__func__, slot_mask);
-			return -EINVAL;
-		}
-		break;
-	default:
-		pr_err("%s: invalid param channels %d\n",
-			__func__, channels);
-		return -EINVAL;
-	}
-	/* currently only supporting TDM_RX_0 and TDM_TX_0 */
-	switch (cpu_dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		slot_offset = tdm_slot_offset[TDM_0];
-		break;
-	default:
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
-		if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-			offset_channels++;
-		else
-			break;
-	}
-
-	if (offset_channels == 0) {
-		pr_err("%s: slot offset not supported, offset_channels %d\n",
-			__func__, offset_channels);
-		return -EINVAL;
-	}
-
-	if (channels > offset_channels) {
-		pr_err("%s: channels %d exceed offset_channels %d\n",
-			__func__, channels, offset_channels);
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
-						  channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
-						  slot_offset, 0, NULL);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	}
-end:
-	return ret;
-}
-
-static int msm_snd_card_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_INT0_MI2S_RX;
-	struct snd_soc_codec *ana_cdc;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		return -EINVAL;
-	}
-
-	ana_cdc = rtd->codec_dais[ANA_CDC]->codec;
-	mbhc_cfg_ptr->calibration = def_msm_int_wcd_mbhc_cal();
-	if (!mbhc_cfg_ptr->calibration)
-		return -ENOMEM;
-
-	ret = msm_anlg_cdc_hs_detect(ana_cdc, mbhc_cfg_ptr);
-	if (ret) {
-		dev_err(card->dev,
-			"%s: msm_anlg_cdc_hs_detect failed\n", __func__);
-		kfree(mbhc_cfg_ptr->calibration);
-	}
-
-	return ret;
-}
-
-static struct snd_soc_ops msm_tdm_be_ops = {
-	.hw_params = msm_tdm_snd_hw_params
-};
-
-static struct snd_soc_ops msm_wcn_ops = {
-	.hw_params = msm_wcn_hw_params,
-};
-
-static struct snd_soc_ops msm_mi2s_be_ops = {
-	.startup = msm_mi2s_snd_startup,
-	.shutdown = msm_mi2s_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_aux_pcm_be_ops = {
-	.startup = msm_aux_pcm_snd_startup,
-	.shutdown = msm_aux_pcm_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_int_mi2s_be_ops = {
-	.startup = msm_int_mi2s_snd_startup,
-	.shutdown = msm_int_mi2s_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_sdw_mi2s_be_ops = {
-	.startup = msm_sdw_mi2s_snd_startup,
-	.shutdown = msm_sdw_mi2s_snd_shutdown,
-};
-
-struct snd_soc_dai_link_component dlc_rx1[] = {
-	{
-		.of_node = NULL,
-		.dai_name = "msm_dig_cdc_dai_rx1",
-	},
-	{
-		.of_node = NULL,
-		.dai_name  = "msm_anlg_cdc_i2s_rx1",
-	},
-};
-
-struct snd_soc_dai_link_component dlc_tx1[] = {
-	{
-		.of_node = NULL,
-		.dai_name = "msm_dig_cdc_dai_tx1",
-	},
-	{
-		.of_node = NULL,
-		.dai_name  = "msm_anlg_cdc_i2s_tx1",
-	},
-};
-
-struct snd_soc_dai_link_component dlc_tx2[] = {
-	{
-		.of_node = NULL,
-		.dai_name = "msm_dig_cdc_dai_tx2",
-	},
-	{
-		.of_node = NULL,
-		.dai_name  = "msm_anlg_cdc_i2s_tx2",
-	},
-};
-
-/* Digital audio interface glue - connects codec <---> CPU */
-static struct snd_soc_dai_link msm_int_dai[] = {
-	/* FrontEnd DAI Links */
-	{/* hw:x,0 */
-		.name = MSM_DAILINK_NAME(Media1),
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name	= "MultiMedia1",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-	{/* hw:x,1 */
-		.name = MSM_DAILINK_NAME(Media2),
-		.stream_name = "MultiMedia2",
-		.cpu_dai_name   = "MultiMedia2",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA2,
-	},
-	{/* hw:x,2 */
-		.name = "VoiceMMode1",
-		.stream_name = "VoiceMMode1",
-		.cpu_dai_name = "VoiceMMode1",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE1,
-	},
-	{/* hw:x,3 */
-		.name = "MSM VoIP",
-		.stream_name = "VoIP",
-		.cpu_dai_name	= "VoIP",
-		.platform_name  = "msm-voip-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_VOIP,
-	},
-	{/* hw:x,4 */
-		.name = MSM_DAILINK_NAME(ULL),
-		.stream_name = "ULL",
-		.cpu_dai_name	= "MultiMedia3",
-		.platform_name  = "msm-pcm-dsp.2",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA3,
-	},
-	/* Hostless PCM purpose */
-	{/* hw:x,5 */
-		.name = "INT4 MI2S_RX Hostless",
-		.stream_name = "INT4 MI2S_RX Hostless",
-		.cpu_dai_name = "INT4_MI2S_RX_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		/* This dainlink has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,6 */
-		.name = "MSM AFE-PCM RX",
-		.stream_name = "AFE-PROXY RX",
-		.cpu_dai_name = "msm-dai-q6-dev.241",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.platform_name  = "msm-pcm-afe",
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-	},
-	{/* hw:x,7 */
-		.name = "MSM AFE-PCM TX",
-		.stream_name = "AFE-PROXY TX",
-		.cpu_dai_name = "msm-dai-q6-dev.240",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.platform_name  = "msm-pcm-afe",
-		.ignore_suspend = 1,
-	},
-	{/* hw:x,8 */
-		.name = MSM_DAILINK_NAME(Compress1),
-		.stream_name = "Compress1",
-		.cpu_dai_name	= "MultiMedia4",
-		.platform_name  = "msm-compress-dsp",
-		.async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA4,
-	},
-	{/* hw:x,9*/
-		.name = "AUXPCM Hostless",
-		.stream_name = "AUXPCM Hostless",
-		.cpu_dai_name   = "AUXPCM_HOSTLESS",
-		.platform_name  = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,10 */
-		.name = "SLIMBUS_1 Hostless",
-		.stream_name = "SLIMBUS_1 Hostless",
-		.cpu_dai_name = "SLIMBUS1_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,11 */
-		.name = "INT3 MI2S_TX Hostless",
-		.stream_name = "INT3 MI2S_TX Hostless",
-		.cpu_dai_name = "INT3_MI2S_TX_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,12 */
-		.name = "SLIMBUS_7 Hostless",
-		.stream_name = "SLIMBUS_7 Hostless",
-		.cpu_dai_name = "SLIMBUS7_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,13 */
-		.name = MSM_DAILINK_NAME(LowLatency),
-		.stream_name = "MultiMedia5",
-		.cpu_dai_name   = "MultiMedia5",
-		.platform_name  = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA5,
-	},
-	/* LSM FE */
-	{/* hw:x,14 */
-		.name = "Listen 1 Audio Service",
-		.stream_name = "Listen 1 Audio Service",
-		.cpu_dai_name = "LSM1",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM1,
-	},
-	{/* hw:x,15 */
-		.name = MSM_DAILINK_NAME(Compress2),
-		.stream_name = "Compress2",
-		.cpu_dai_name   = "MultiMedia7",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA7,
-	},
-	{/* hw:x,16 */
-		.name = MSM_DAILINK_NAME(MultiMedia10),
-		.stream_name = "MultiMedia10",
-		.cpu_dai_name	= "MultiMedia10",
-		.platform_name  = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA10,
-	},
-	{/* hw:x,17 */
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ),
-		.stream_name = "MM_NOIRQ",
-		.cpu_dai_name	= "MultiMedia8",
-		.platform_name  = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA8,
-	},
-	{/* hw:x,18 */
-		.name = "HDMI_RX_HOSTLESS",
-		.stream_name = "HDMI_RX_HOSTLESS",
-		.cpu_dai_name	= "HDMI_HOSTLESS",
-		.platform_name  = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,19 */
-		.name = "VoiceMMode2",
-		.stream_name = "VoiceMMode2",
-		.cpu_dai_name = "VoiceMMode2",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE2,
-	},
-	{/* hw:x,20 */
-		.name = "Listen 2 Audio Service",
-		.stream_name = "Listen 2 Audio Service",
-		.cpu_dai_name = "LSM2",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM2,
-	},
-	{/* hw:x,21 */
-		.name = "Listen 3 Audio Service",
-		.stream_name = "Listen 3 Audio Service",
-		.cpu_dai_name = "LSM3",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM3,
-	},
-	{/* hw:x,22 */
-		.name = "Listen 4 Audio Service",
-		.stream_name = "Listen 4 Audio Service",
-		.cpu_dai_name = "LSM4",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM4,
-	},
-	{/* hw:x,23 */
-		.name = "Listen 5 Audio Service",
-		.stream_name = "Listen 5 Audio Service",
-		.cpu_dai_name = "LSM5",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM5,
-	},
-	{/* hw:x,24 */
-		.name = "Listen 6 Audio Service",
-		.stream_name = "Listen 6 Audio Service",
-		.cpu_dai_name = "LSM6",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM6
-	},
-	{/* hw:x,25 */
-		.name = "Listen 7 Audio Service",
-		.stream_name = "Listen 7 Audio Service",
-		.cpu_dai_name = "LSM7",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM7,
-	},
-	{/* hw:x,26 */
-		.name = "Listen 8 Audio Service",
-		.stream_name = "Listen 8 Audio Service",
-		.cpu_dai_name = "LSM8",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM8,
-	},
-	{/* hw:x,27 */
-		.name = MSM_DAILINK_NAME(Media9),
-		.stream_name = "MultiMedia9",
-		.cpu_dai_name	= "MultiMedia9",
-		.platform_name  = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA9,
-	},
-	{/* hw:x,28 */
-		.name = MSM_DAILINK_NAME(Compress4),
-		.stream_name = "Compress4",
-		.cpu_dai_name	= "MultiMedia11",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA11,
-	},
-	{/* hw:x,29 */
-		.name = MSM_DAILINK_NAME(Compress5),
-		.stream_name = "Compress5",
-		.cpu_dai_name	= "MultiMedia12",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA12,
-	},
-	{/* hw:x,30 */
-		.name = MSM_DAILINK_NAME(Compress6),
-		.stream_name = "Compress6",
-		.cpu_dai_name	= "MultiMedia13",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA13,
-	},
-	{/* hw:x,31 */
-		.name = MSM_DAILINK_NAME(Compress7),
-		.stream_name = "Compress7",
-		.cpu_dai_name	= "MultiMedia14",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA14,
-	},
-	{/* hw:x,32 */
-		.name = MSM_DAILINK_NAME(Compress8),
-		.stream_name = "Compress8",
-		.cpu_dai_name	= "MultiMedia15",
-		.platform_name  = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA15,
-	},
-	{/* hw:x,33 */
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
-		.stream_name = "MM_NOIRQ_2",
-		.cpu_dai_name	= "MultiMedia16",
-		.platform_name  = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dai link has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA16,
-	},
-	{/* hw:x,34 */
-		.name = "SLIMBUS_8 Hostless",
-		.stream_name = "SLIMBUS8_HOSTLESS Capture",
-		.cpu_dai_name = "SLIMBUS8_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,35 */
-		.name = "Primary MI2S_RX Hostless",
-		.stream_name = "Primary MI2S_RX Hostless",
-		.cpu_dai_name = "PRI_MI2S_RX_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		/* This dainlink has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,36 */
-		.name = "Secondary MI2S_RX Hostless",
-		.stream_name = "Secondary MI2S_RX Hostless",
-		.cpu_dai_name = "SEC_MI2S_RX_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		/* This dainlink has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,37 */
-		.name = "Tertiary MI2S_RX Hostless",
-		.stream_name = "Tertiary MI2S_RX Hostless",
-		.cpu_dai_name = "TERT_MI2S_RX_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		/* This dainlink has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,38 */
-		.name = "INT0 MI2S_RX Hostless",
-		.stream_name = "INT0 MI2S_RX Hostless",
-		.cpu_dai_name = "INT0_MI2S_RX_HOSTLESS",
-		.platform_name	= "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		/* This dainlink has MI2S support */
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{/* hw:x,39 */
-		.name = "SDM660 HFP TX",
-		.stream_name = "MultiMedia6",
-		.cpu_dai_name = "MultiMedia6",
-		.platform_name  = "msm-pcm-loopback",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA6,
-	},
-};
-
-
-static struct snd_soc_dai_link msm_int_wsa_dai[] = {
-	{/* hw:x,40 */
-		.name = LPASS_BE_INT5_MI2S_TX,
-		.stream_name = "INT5_mi2s Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.12",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "msm_sdw_codec",
-		.codec_dai_name = "msm_sdw_vifeedback",
-		.id = MSM_BACKEND_DAI_INT5_MI2S_TX,
-		.be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
-		.ops = &msm_sdw_mi2s_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.dpcm_capture = 1,
-		.ignore_pmdown_time = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_int_be_dai[] = {
-	/* Backend I2S DAI Links */
-	{
-		.name = LPASS_BE_INT0_MI2S_RX,
-		.stream_name = "INT0 MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.7",
-		.platform_name = "msm-pcm-routing",
-		.codecs = dlc_rx1,
-		.num_codecs = CODECS_MAX,
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
-			ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.id = MSM_BACKEND_DAI_INT0_MI2S_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
-		.ops = &msm_int_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_INT3_MI2S_TX,
-		.stream_name = "INT3 MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.10",
-		.platform_name = "msm-pcm-routing",
-		.codecs = dlc_tx1,
-		.num_codecs = CODECS_MAX,
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
-			ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.id = MSM_BACKEND_DAI_INT3_MI2S_TX,
-		.be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
-		.ops = &msm_int_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_INT2_MI2S_TX,
-		.stream_name = "INT2 MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.9",
-		.platform_name = "msm-pcm-routing",
-		.codecs = dlc_tx2,
-		.num_codecs = CODECS_MAX,
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
-			ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.id = MSM_BACKEND_DAI_INT2_MI2S_TX,
-		.be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
-		.ops = &msm_int_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_AFE_PCM_RX,
-		.stream_name = "AFE Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.224",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_AFE_PCM_TX,
-		.stream_name = "AFE Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.225",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Uplink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_TX,
-		.stream_name = "Voice Uplink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32772",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Downlink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_RX,
-		.stream_name = "Voice Downlink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32771",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE_PLAYBACK_TX,
-		.stream_name = "Voice Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32773",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music 2 BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE2_PLAYBACK_TX,
-		.stream_name = "Voice2 Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32770",
-		.platform_name = "msm-pcm-routing",
-		.codec_name     = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_RX,
-		.stream_name = "USB Audio Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.28672",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_USB_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_TX,
-		.stream_name = "USB Audio Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.28673",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_USB_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_RX_0,
-		.stream_name = "Primary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36864",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_TX_0,
-		.stream_name = "Primary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36865",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_RX_0,
-		.stream_name = "Secondary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36880",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_TX_0,
-		.stream_name = "Secondary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36881",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_RX_0,
-		.stream_name = "Tertiary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36896",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_TX_0,
-		.stream_name = "Tertiary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36897",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_RX_0,
-		.stream_name = "Quaternary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36912",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_TX_0,
-		.stream_name = "Quaternary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36913",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
-	{
-		.name = LPASS_BE_PRI_MI2S_RX,
-		.stream_name = "Primary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_MI2S_TX,
-		.stream_name = "Primary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_RX,
-		.stream_name = "Secondary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_TX,
-		.stream_name = "Secondary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_RX,
-		.stream_name = "Tertiary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_TX,
-		.stream_name = "Tertiary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_RX,
-		.stream_name = "Quaternary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_TX,
-		.stream_name = "Quaternary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
-	/* Primary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_AUXPCM_RX,
-		.stream_name = "AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_AUXPCM_TX,
-		.stream_name = "AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Secondary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_SEC_AUXPCM_RX,
-		.stream_name = "Sec AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SEC_AUXPCM_TX,
-		.stream_name = "Sec AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Tertiary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_TERT_AUXPCM_RX,
-		.stream_name = "Tert AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_TERT_AUXPCM_TX,
-		.stream_name = "Tert AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Quaternary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_RX,
-		.stream_name = "Quat AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_TX,
-		.stream_name = "Quat AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-};
-
-
-static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_7_RX,
-		.stream_name = "Slimbus7 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16398",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		/* BT codec driver determines capabilities based on
-		 * dai name, bt codecdai name should always contains
-		 * supported usecase information
-		 */
-		.codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
-		.be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_7_TX,
-		.stream_name = "Slimbus7 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16399",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_bt_sco_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
-		.be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_8_TX,
-		.stream_name = "Slimbus8 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16401",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_fm_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
-		.be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
-		.init = &msm_wcn_init,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_wsa_be_dai_links[] = {
-	{
-		.name = LPASS_BE_INT4_MI2S_RX,
-		.stream_name = "INT4 MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.11",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm_sdw_codec",
-		.codec_dai_name = "msm_sdw_i2s_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_INT4_MI2S_RX,
-		.init = &msm_sdw_audrx_init,
-		.be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
-		.ops = &msm_sdw_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
-	/* DISP PORT BACK END DAI Link */
-	{
-		.name = LPASS_BE_DISPLAY_PORT,
-		.stream_name = "Display Port Playback",
-		.cpu_dai_name = "msm-dai-q6-dp.24608",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-ext-disp-audio-codec-rx",
-		.codec_dai_name = "msm_dp_audio_codec_rx_dai",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-		.be_hw_params_fixup = msm_common_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_int_dai_links[
-ARRAY_SIZE(msm_int_dai) +
-ARRAY_SIZE(msm_int_wsa_dai) +
-ARRAY_SIZE(msm_int_be_dai) +
-ARRAY_SIZE(msm_mi2s_be_dai_links) +
-ARRAY_SIZE(msm_auxpcm_be_dai_links)+
-ARRAY_SIZE(msm_wcn_be_dai_links) +
-ARRAY_SIZE(msm_wsa_be_dai_links) +
-ARRAY_SIZE(ext_disp_be_dai_link)];
-
-static struct snd_soc_card sdm660_card = {
-	/* snd_soc_card_sdm660 */
-	.name		= "sdm660-snd-card",
-	.dai_link	= msm_int_dai,
-	.num_links	= ARRAY_SIZE(msm_int_dai),
-	.late_probe	= msm_snd_card_late_probe,
-};
-
-static void msm_disable_int_mclk0(struct work_struct *work)
-{
-	struct msm_asoc_mach_data *pdata = NULL;
-	struct delayed_work *dwork;
-	int ret = 0;
-
-	dwork = to_delayed_work(work);
-	pdata = container_of(dwork, struct msm_asoc_mach_data,
-			disable_int_mclk0_work);
-	mutex_lock(&pdata->cdc_int_mclk0_mutex);
-	pr_debug("%s: mclk_enabled %d mclk_rsc_ref %d\n", __func__,
-			atomic_read(&pdata->int_mclk0_enabled),
-			atomic_read(&pdata->int_mclk0_rsc_ref));
-
-	if (atomic_read(&pdata->int_mclk0_enabled) == true
-			&& atomic_read(&pdata->int_mclk0_rsc_ref) == 0) {
-		pr_debug("Disable the mclk\n");
-		pdata->digital_cdc_core_clk.enable = 0;
-		ret = afe_set_lpass_clock_v2(
-			AFE_PORT_ID_INT0_MI2S_RX,
-			&pdata->digital_cdc_core_clk);
-		if (ret < 0)
-			pr_err("%s failed to disable the CCLK\n", __func__);
-		atomic_set(&pdata->int_mclk0_enabled, false);
-	}
-	mutex_unlock(&pdata->cdc_int_mclk0_mutex);
-}
-
-static void msm_int_dt_parse_cap_info(struct platform_device *pdev,
-				      struct msm_asoc_mach_data *pdata)
-{
-	const char *ext1_cap = "qcom,msm-micbias1-ext-cap";
-	const char *ext2_cap = "qcom,msm-micbias2-ext-cap";
-
-	pdata->micbias1_cap_mode =
-		(of_property_read_bool(pdev->dev.of_node, ext1_cap) ?
-		 MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-
-	pdata->micbias2_cap_mode =
-		(of_property_read_bool(pdev->dev.of_node, ext2_cap) ?
-		 MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
-}
-
-static struct snd_soc_card *msm_int_populate_sndcard_dailinks(
-						struct device *dev)
-{
-	struct snd_soc_card *card = &sdm660_card;
-	struct snd_soc_dai_link *dailink;
-	int len1;
-
-	card->name = dev_name(dev);
-	len1 = ARRAY_SIZE(msm_int_dai);
-	memcpy(msm_int_dai_links, msm_int_dai, sizeof(msm_int_dai));
-	dailink = msm_int_dai_links;
-	if (!of_property_read_bool(dev->of_node,
-				  "qcom,wsa-disable")) {
-		memcpy(dailink + len1,
-		       msm_int_wsa_dai,
-		       sizeof(msm_int_wsa_dai));
-		len1 += ARRAY_SIZE(msm_int_wsa_dai);
-	}
-	memcpy(dailink + len1, msm_int_be_dai, sizeof(msm_int_be_dai));
-	len1 += ARRAY_SIZE(msm_int_be_dai);
-
-	if (of_property_read_bool(dev->of_node,
-				  "qcom,mi2s-audio-intf")) {
-		memcpy(dailink + len1,
-		       msm_mi2s_be_dai_links,
-		       sizeof(msm_mi2s_be_dai_links));
-		len1 += ARRAY_SIZE(msm_mi2s_be_dai_links);
-	}
-	if (of_property_read_bool(dev->of_node,
-				  "qcom,auxpcm-audio-intf")) {
-		memcpy(dailink + len1,
-		       msm_auxpcm_be_dai_links,
-		       sizeof(msm_auxpcm_be_dai_links));
-		len1 += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-	}
-	if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-		dev_dbg(dev, "%s(): WCN BTFM support present\n",
-				__func__);
-		memcpy(dailink + len1,
-		       msm_wcn_be_dai_links,
-		       sizeof(msm_wcn_be_dai_links));
-		len1 += ARRAY_SIZE(msm_wcn_be_dai_links);
-	}
-	if (!of_property_read_bool(dev->of_node, "qcom,wsa-disable")) {
-		memcpy(dailink + len1,
-		       msm_wsa_be_dai_links,
-		       sizeof(msm_wsa_be_dai_links));
-		len1 += ARRAY_SIZE(msm_wsa_be_dai_links);
-	}
-	if (of_property_read_bool(dev->of_node, "qcom,ext-disp-audio-rx")) {
-		dev_dbg(dev, "%s(): ext disp audio support present\n",
-				__func__);
-		memcpy(dailink + len1,
-			ext_disp_be_dai_link,
-			sizeof(ext_disp_be_dai_link));
-		len1 += ARRAY_SIZE(ext_disp_be_dai_link);
-	}
-	card->dai_link = dailink;
-	card->num_links = len1;
-	return card;
-}
-
-static int msm_internal_init(struct platform_device *pdev,
-			     struct msm_asoc_mach_data *pdata,
-			     struct snd_soc_card *card)
-{
-	const char *type = NULL;
-	const char *hs_micbias_type = "qcom,msm-hs-micbias-type";
-	int ret;
-
-	ret = is_ext_spk_gpio_support(pdev, pdata);
-	if (ret < 0)
-		dev_dbg(&pdev->dev,
-			"%s: doesn't support external speaker pa\n",
-			__func__);
-
-	ret = of_property_read_string(pdev->dev.of_node,
-				      hs_micbias_type, &type);
-	if (ret) {
-		dev_err(&pdev->dev, "%s: missing %s in dt node\n",
-			__func__, hs_micbias_type);
-		goto err;
-	}
-	if (!strcmp(type, "external")) {
-		dev_dbg(&pdev->dev, "Headset is using external micbias\n");
-		mbhc_cfg_ptr->hs_ext_micbias = true;
-	} else {
-		dev_dbg(&pdev->dev, "Headset is using internal micbias\n");
-		mbhc_cfg_ptr->hs_ext_micbias = false;
-	}
-
-	/* initialize the int_mclk0 */
-	pdata->digital_cdc_core_clk.clk_set_minor_version =
-			AFE_API_VERSION_I2S_CONFIG;
-	pdata->digital_cdc_core_clk.clk_id =
-			Q6AFE_LPASS_CLK_ID_INT_MCLK_0;
-	pdata->digital_cdc_core_clk.clk_freq_in_hz = pdata->mclk_freq;
-	pdata->digital_cdc_core_clk.clk_attri =
-			Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
-	pdata->digital_cdc_core_clk.clk_root =
-			Q6AFE_LPASS_CLK_ROOT_DEFAULT;
-	pdata->digital_cdc_core_clk.enable = 1;
-
-	/* Initialize loopback mode to false */
-	pdata->lb_mode = false;
-
-	msm_int_dt_parse_cap_info(pdev, pdata);
-
-	card->dev = &pdev->dev;
-	platform_set_drvdata(pdev, card);
-	snd_soc_card_set_drvdata(card, pdata);
-	ret = snd_soc_of_parse_card_name(card, "qcom,model");
-	if (ret)
-		goto err;
-	/* initialize timer */
-	INIT_DELAYED_WORK(&pdata->disable_int_mclk0_work,
-			  msm_disable_int_mclk0);
-	mutex_init(&pdata->cdc_int_mclk0_mutex);
-	atomic_set(&pdata->int_mclk0_rsc_ref, 0);
-	atomic_set(&pdata->int_mclk0_enabled, false);
-
-	dev_info(&pdev->dev, "%s: default codec configured\n", __func__);
-
-	return 0;
-err:
-	return ret;
-}
-
-/**
- * msm_int_cdc_init - internal codec machine specific init.
- *
- * @pdev: platform device handle
- * @pdata: private data of machine driver
- * @card: sound card pointer reference
- * @mbhc_cfg: MBHC config reference
- *
- * Returns 0.
- */
-int msm_int_cdc_init(struct platform_device *pdev,
-		     struct msm_asoc_mach_data *pdata,
-		     struct snd_soc_card **card,
-		     struct wcd_mbhc_config *mbhc_cfg)
-{
-	mbhc_cfg_ptr = mbhc_cfg;
-
-	*card = msm_int_populate_sndcard_dailinks(&pdev->dev);
-	msm_internal_init(pdev, pdata, *card);
-	return 0;
-}
-EXPORT_SYMBOL(msm_int_cdc_init);
diff --git a/sound/soc/msm/sdm660-internal.h b/sound/soc/msm/sdm660-internal.h
deleted file mode 100644
index ccc62b8..0000000
--- a/sound/soc/msm/sdm660-internal.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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 __SDM660_INTERNAL
-#define __SDM660_INTERNAL
-
-#include <sound/soc.h>
-
-#ifdef CONFIG_SND_SOC_INT_CODEC
-int msm_int_cdc_init(struct platform_device *pdev,
-		     struct msm_asoc_mach_data *pdata,
-		     struct snd_soc_card **card,
-		     struct wcd_mbhc_config *mbhc_cfg);
-#else
-int msm_int_cdc_init(struct platform_device *pdev,
-		     struct msm_asoc_mach_data *pdata,
-		     struct snd_soc_card **card,
-		     struct wcd_mbhc_config *mbhc_cfg)
-{
-	return 0;
-}
-#endif
-#endif
diff --git a/sound/soc/msm/sdm845.c b/sound/soc/msm/sdm845.c
deleted file mode 100644
index 2792616..0000000
--- a/sound/soc/msm/sdm845.c
+++ /dev/null
@@ -1,7171 +0,0 @@
-/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/input.h>
-#include <linux/of_device.h>
-#include <linux/mfd/msm-cdc-pinctrl.h>
-#include <sound/core.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/pcm.h>
-#include <sound/jack.h>
-#include <sound/q6afe-v2.h>
-#include <sound/q6core.h>
-#include <sound/pcm_params.h>
-#include <sound/info.h>
-#include <device_event.h>
-#include <linux/qdsp6v2/audio_notifier.h>
-#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "../codecs/wcd934x/wcd934x.h"
-#include "../codecs/wcd934x/wcd934x-mbhc.h"
-#include "../codecs/wsa881x.h"
-
-#define DRV_NAME "sdm845-asoc-snd"
-
-#define __CHIPSET__ "SDM845 "
-#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
-
-#define SAMPLING_RATE_8KHZ      8000
-#define SAMPLING_RATE_11P025KHZ 11025
-#define SAMPLING_RATE_16KHZ     16000
-#define SAMPLING_RATE_22P05KHZ  22050
-#define SAMPLING_RATE_32KHZ     32000
-#define SAMPLING_RATE_44P1KHZ   44100
-#define SAMPLING_RATE_48KHZ     48000
-#define SAMPLING_RATE_88P2KHZ   88200
-#define SAMPLING_RATE_96KHZ     96000
-#define SAMPLING_RATE_176P4KHZ  176400
-#define SAMPLING_RATE_192KHZ    192000
-#define SAMPLING_RATE_352P8KHZ  352800
-#define SAMPLING_RATE_384KHZ    384000
-
-#define WCD9XXX_MBHC_DEF_BUTTONS    8
-#define WCD9XXX_MBHC_DEF_RLOADS     5
-#define CODEC_EXT_CLK_RATE          9600000
-#define ADSP_STATE_READY_TIMEOUT_MS 3000
-#define DEV_NAME_STR_LEN            32
-
-#define WSA8810_NAME_1 "wsa881x.20170211"
-#define WSA8810_NAME_2 "wsa881x.20170212"
-
-#define WCN_CDC_SLIM_RX_CH_MAX 2
-#define WCN_CDC_SLIM_TX_CH_MAX 3
-
-#define TDM_CHANNEL_MAX 8
-#define TDM_SLOT_OFFSET_MAX 8
-
-#define MSM_HIFI_ON 1
-
-enum {
-	SLIM_RX_0 = 0,
-	SLIM_RX_1,
-	SLIM_RX_2,
-	SLIM_RX_3,
-	SLIM_RX_4,
-	SLIM_RX_5,
-	SLIM_RX_6,
-	SLIM_RX_7,
-	SLIM_RX_MAX,
-};
-
-enum {
-	SLIM_TX_0 = 0,
-	SLIM_TX_1,
-	SLIM_TX_2,
-	SLIM_TX_3,
-	SLIM_TX_4,
-	SLIM_TX_5,
-	SLIM_TX_6,
-	SLIM_TX_7,
-	SLIM_TX_8,
-	SLIM_TX_MAX,
-};
-
-enum {
-	PRIM_MI2S = 0,
-	SEC_MI2S,
-	TERT_MI2S,
-	QUAT_MI2S,
-	MI2S_MAX,
-};
-
-enum {
-	PRIM_AUX_PCM = 0,
-	SEC_AUX_PCM,
-	TERT_AUX_PCM,
-	QUAT_AUX_PCM,
-	AUX_PCM_MAX,
-};
-
-enum {
-	PCM_I2S_SEL_PRIM = 0,
-	PCM_I2S_SEL_SEC,
-	PCM_I2S_SEL_TERT,
-	PCM_I2S_SEL_QUAT,
-	PCM_I2S_SEL_MAX,
-};
-
-struct mi2s_aux_pcm_common_conf {
-	struct mutex lock;
-	void *pcm_i2s_sel_vt_addr;
-};
-
-struct mi2s_conf {
-	struct mutex lock;
-	u32 ref_cnt;
-	u32 msm_is_mi2s_master;
-};
-
-static u32 mi2s_ebit_clk[MI2S_MAX] = {
-	Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
-	Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT
-};
-
-struct auxpcm_conf {
-	struct mutex lock;
-	u32 ref_cnt;
-};
-
-struct dev_config {
-	u32 sample_rate;
-	u32 bit_format;
-	u32 channels;
-};
-
-enum {
-	DP_RX_IDX = 0,
-	EXT_DISP_RX_IDX_MAX,
-};
-
-struct msm_wsa881x_dev_info {
-	struct device_node *of_node;
-	u32 index;
-};
-
-enum pinctrl_pin_state {
-	STATE_DISABLE = 0, /* All pins are in sleep state */
-	STATE_MI2S_ACTIVE,  /* IS2 = active, TDM = sleep */
-	STATE_TDM_ACTIVE,  /* IS2 = sleep, TDM = active */
-};
-
-struct msm_pinctrl_info {
-	struct pinctrl *pinctrl;
-	struct pinctrl_state *mi2s_disable;
-	struct pinctrl_state *tdm_disable;
-	struct pinctrl_state *mi2s_active;
-	struct pinctrl_state *tdm_active;
-	enum pinctrl_pin_state curr_state;
-};
-
-struct msm_asoc_mach_data {
-	u32 mclk_freq;
-	int us_euro_gpio; /* used by gpio driver API */
-	int usbc_en2_gpio; /* used by gpio driver API */
-	struct device_node *us_euro_gpio_p; /* used by pinctrl API */
-	struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
-	struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
-	struct snd_info_entry *codec_root;
-	struct msm_pinctrl_info pinctrl_info;
-};
-
-struct msm_asoc_wcd93xx_codec {
-	void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
-				   enum afe_config_type config_type);
-	void (*mbhc_hs_detect_exit)(struct snd_soc_codec *codec);
-};
-
-static const char *const pin_states[] = {"sleep", "i2s-active",
-					 "tdm-active"};
-
-enum {
-	TDM_0 = 0,
-	TDM_1,
-	TDM_2,
-	TDM_3,
-	TDM_4,
-	TDM_5,
-	TDM_6,
-	TDM_7,
-	TDM_PORT_MAX,
-};
-
-enum {
-	TDM_PRI = 0,
-	TDM_SEC,
-	TDM_TERT,
-	TDM_QUAT,
-	TDM_INTERFACE_MAX,
-};
-
-struct tdm_port {
-	u32 mode;
-	u32 channel;
-};
-
-/* TDM default config */
-static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
-	}
-};
-
-/* TDM default config */
-static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
-	{ /* PRI TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* SEC TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* TERT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	},
-	{ /* QUAT TDM */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
-		{SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
-	}
-};
-
-/*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */
-static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
-	{0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */
-	{AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */
-};
-
-/* Default configuration of slimbus channels */
-static struct dev_config slim_rx_cfg[] = {
-	[SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config slim_tx_cfg[] = {
-	[SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-
-/* Default configuration of external display BE */
-static struct dev_config ext_disp_rx_cfg[] = {
-	[DP_RX_IDX] =   {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config usb_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-static struct dev_config usb_tx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 1,
-};
-
-static struct dev_config proxy_rx_cfg = {
-	.sample_rate = SAMPLING_RATE_48KHZ,
-	.bit_format = SNDRV_PCM_FORMAT_S16_LE,
-	.channels = 2,
-};
-
-/* Default configuration of MI2S channels */
-static struct dev_config mi2s_rx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
-};
-
-static struct dev_config mi2s_tx_cfg[] = {
-	[PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_MI2S]  = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_rx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static struct dev_config aux_pcm_tx_cfg[] = {
-	[PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[SEC_AUX_PCM]  = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-	[QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
-};
-
-static int msm_vi_feed_tx_ch = 2;
-static const char *const slim_rx_ch_text[] = {"One", "Two"};
-static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
-						"Five", "Six", "Seven",
-						"Eight"};
-static const char *const vi_feed_ch_text[] = {"One", "Two"};
-static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
-					  "S32_LE"};
-static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE"};
-static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_88P2", "KHZ_96", "KHZ_176P4",
-					"KHZ_192", "KHZ_352P8", "KHZ_384"};
-static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"};
-static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static char const *ch_text[] = {"Two", "Three", "Four", "Five",
-					"Six", "Seven", "Eight"};
-static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
-					"KHZ_16", "KHZ_22P05",
-					"KHZ_32", "KHZ_44P1", "KHZ_48",
-					"KHZ_88P2", "KHZ_96", "KHZ_176P4",
-					"KHZ_192", "KHZ_352P8", "KHZ_384"};
-static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
-						"KHZ_192", "KHZ_32", "KHZ_44P1",
-						"KHZ_88P2", "KHZ_176P4"	};
-static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
-				    "Five", "Six", "Seven", "Eight"};
-static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
-static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
-					     "KHZ_44P1", "KHZ_48", "KHZ_96",
-					     "KHZ_192", "KHZ_352P8", "KHZ_384"};
-static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
-static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_16",
-				      "KHZ_32", "KHZ_44P1", "KHZ_48",
-				      "KHZ_96", "KHZ_192"};
-static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
-					   "Five", "Six", "Seven",
-					   "Eight"};
-static const char *const hifi_text[] = {"Off", "On"};
-static const char *const qos_text[] = {"Disable", "Enable"};
-
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
-				ext_disp_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
-static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
-static SOC_ENUM_SINGLE_EXT_DECL(hifi_function, hifi_text);
-static SOC_ENUM_SINGLE_EXT_DECL(qos_vote, qos_text);
-
-static struct platform_device *spdev;
-static int msm_hifi_control;
-static int qos_vote_status;
-
-static bool is_initial_boot;
-static bool codec_reg_done;
-static struct snd_soc_aux_dev *msm_aux_dev;
-static struct snd_soc_codec_conf *msm_codec_conf;
-static struct msm_asoc_wcd93xx_codec msm_codec_fn;
-
-static void *def_tavil_mbhc_cal(void);
-static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
-					int enable, bool dapm);
-static int msm_wsa881x_init(struct snd_soc_component *component);
-
-/*
- * Need to report LINEIN
- * if R/L channel impedance is larger than 5K ohm
- */
-static struct wcd_mbhc_config wcd_mbhc_cfg = {
-	.read_fw_bin = false,
-	.calibration = NULL,
-	.detect_extn_cable = true,
-	.mono_stero_detection = false,
-	.swap_gnd_mic = NULL,
-	.hs_ext_micbias = true,
-	.key_code[0] = KEY_MEDIA,
-	.key_code[1] = KEY_VOICECOMMAND,
-	.key_code[2] = KEY_VOLUMEUP,
-	.key_code[3] = KEY_VOLUMEDOWN,
-	.key_code[4] = 0,
-	.key_code[5] = 0,
-	.key_code[6] = 0,
-	.key_code[7] = 0,
-	.linein_th = 5000,
-	.moisture_en = true,
-	.mbhc_micbias = MIC_BIAS_2,
-	.anc_micbias = MIC_BIAS_2,
-	.enable_anc_mic_detect = false,
-};
-
-static struct snd_soc_dapm_route wcd_audio_paths[] = {
-	{"MIC BIAS1", NULL, "MCLK TX"},
-	{"MIC BIAS2", NULL, "MCLK TX"},
-	{"MIC BIAS3", NULL, "MCLK TX"},
-	{"MIC BIAS4", NULL, "MCLK TX"},
-};
-
-static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	},
-	{
-		AFE_API_VERSION_I2S_CONFIG,
-		Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
-		Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
-		Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
-		Q6AFE_LPASS_CLK_ROOT_DEFAULT,
-		0,
-	}
-};
-
-static struct mi2s_aux_pcm_common_conf mi2s_auxpcm_conf[PCM_I2S_SEL_MAX];
-static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
-static struct auxpcm_conf auxpcm_intf_conf[AUX_PCM_MAX];
-
-static int slim_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 10;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int slim_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int slim_get_bit_format_val(int bit_format)
-{
-	int val = 0;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		val = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		val = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		val = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		val = 0;
-		break;
-	}
-	return val;
-}
-
-static int slim_get_bit_format(int val)
-{
-	int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-
-	switch (val) {
-	case 0:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return bit_fmt;
-}
-
-static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int port_id = 0;
-
-	if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX")))
-		port_id = SLIM_RX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_2_RX", sizeof("SLIM_2_RX")))
-		port_id = SLIM_RX_2;
-	else if (strnstr(kcontrol->id.name, "SLIM_5_RX", sizeof("SLIM_5_RX")))
-		port_id = SLIM_RX_5;
-	else if (strnstr(kcontrol->id.name, "SLIM_6_RX", sizeof("SLIM_6_RX")))
-		port_id = SLIM_RX_6;
-	else if (strnstr(kcontrol->id.name, "SLIM_0_TX", sizeof("SLIM_0_TX")))
-		port_id = SLIM_TX_0;
-	else if (strnstr(kcontrol->id.name, "SLIM_1_TX", sizeof("SLIM_1_TX")))
-		port_id = SLIM_TX_1;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		return -EINVAL;
-	}
-
-	return port_id;
-}
-
-static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].sample_rate =
-		slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-		slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate = 0;
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
-	if (sample_rate == SAMPLING_RATE_44P1KHZ) {
-		pr_err("%s: Unsupported sample rate %d: for Tx path\n",
-			__func__, sample_rate);
-		return -EINVAL;
-	}
-	slim_tx_cfg[ch_num].sample_rate = sample_rate;
-
-	pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	ucontrol->value.enumerated.item[0] =
-			slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].bit_format =
-		slim_get_bit_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
-		 __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
-			ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_rx_ch  = %d\n", __func__,
-		 ch_num, slim_rx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_slim_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	pr_debug("%s: msm_slim_[%d]_tx_ch  = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-	ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
-
-	return 0;
-}
-
-static int msm_slim_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int ch_num = slim_get_port_idx(kcontrol);
-
-	if (ch_num < 0)
-		return ch_num;
-
-	slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
-		 ch_num, slim_tx_cfg[ch_num].channels);
-
-	return 1;
-}
-
-static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
-	pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
-				 struct snd_ctl_elem_value *ucontrol)
-{
-	msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
-	return 1;
-}
-
-static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	/*
-	 * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
-	 * when used for BT_SCO use case. Return either Rx or Tx sample rate
-	 * value.
-	 */
-	switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
-	case SAMPLING_RATE_48KHZ:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-	pr_debug("%s: sample rate = %d", __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate);
-
-	return 0;
-}
-
-static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 0:
-	default:
-		slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
-		 __func__,
-		 slim_rx_cfg[SLIM_RX_7].sample_rate,
-		 slim_tx_cfg[SLIM_TX_7].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_rx_ch  = %d\n", __func__,
-		 usb_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_rx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 12;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 11;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 10;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
-		 usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 12:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 11:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_rx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_rx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_rx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: usb_audio_tx_ch  = %d\n", __func__,
-		 usb_tx_cfg.channels);
-	ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
-	return 0;
-}
-
-static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
-
-	pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
-	return 1;
-}
-
-static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-
-	switch (usb_tx_cfg.sample_rate) {
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 12;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 11;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 10;
-		break;
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 9;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 8;
-		break;
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_22P05KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_11P025KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	default:
-		sample_rate_val = 6;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
-		 usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-					struct snd_ctl_elem_value *ucontrol)
-{
-	switch (ucontrol->value.integer.value[0]) {
-	case 12:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	case 11:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 10:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 9:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 8:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 7:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 6:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
-		break;
-	case 2:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 1:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
-		break;
-	case 0:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	default:
-		usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
-		__func__, ucontrol->value.integer.value[0],
-		usb_tx_cfg.sample_rate);
-	return 0;
-}
-
-static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	switch (usb_tx_cfg.bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-		ucontrol->value.integer.value[0] = 3;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		ucontrol->value.integer.value[0] = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int rc = 0;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 3:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	case 2:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 1:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
-		 __func__, usb_tx_cfg.bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return rc;
-}
-
-static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "Display Port RX",
-		    sizeof("Display Port RX"))) {
-		idx = DP_RX_IDX;
-	} else {
-		pr_err("%s: unsupported BE: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].bit_format) {
-	case SNDRV_PCM_FORMAT_S24_LE:
-		ucontrol->value.integer.value[0] = 1;
-		break;
-
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		ucontrol->value.integer.value[0] = 0;
-		break;
-	}
-
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-	return 0;
-}
-
-static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
-				  struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 1:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
-		 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
-		 ucontrol->value.integer.value[0]);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.integer.value[0] =
-			ext_disp_rx_cfg[idx].channels - 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-
-	return 0;
-}
-
-static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ext_disp_rx_cfg[idx].channels =
-			ucontrol->value.integer.value[0] + 2;
-
-	pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].channels);
-	return 1;
-}
-
-static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int sample_rate_val;
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ext_disp_rx_cfg[idx].sample_rate) {
-	case SAMPLING_RATE_176P4KHZ:
-		sample_rate_val = 6;
-		break;
-
-	case SAMPLING_RATE_88P2KHZ:
-		sample_rate_val = 5;
-		break;
-
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 4;
-		break;
-
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 3;
-		break;
-
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 2;
-		break;
-
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 1;
-		break;
-
-	case SAMPLING_RATE_48KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-
-	ucontrol->value.integer.value[0] = sample_rate_val;
-	pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
-		 idx, ext_disp_rx_cfg[idx].sample_rate);
-
-	return 0;
-}
-
-static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				       struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = ext_disp_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	switch (ucontrol->value.integer.value[0]) {
-	case 6:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
-		break;
-	case 5:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
-		break;
-	case 4:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 3:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 2:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 1:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 0:
-	default:
-		ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-	pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
-		 __func__, ucontrol->value.integer.value[0], idx,
-		 ext_disp_rx_cfg[idx].sample_rate);
-	return 0;
-}
-
-static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-	ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
-
-	return 0;
-}
-
-static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
-	pr_debug("%s: proxy_rx channels = %d\n",
-		 __func__, proxy_rx_cfg.channels);
-
-	return 1;
-}
-
-static int tdm_get_sample_rate(int value)
-{
-	int sample_rate = 0;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	case 7:
-		sample_rate = SAMPLING_RATE_352P8KHZ;
-		break;
-	case 8:
-		sample_rate = SAMPLING_RATE_384KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int aux_pcm_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 0:
-	default:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int tdm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val = 0;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	case SAMPLING_RATE_352P8KHZ:
-		sample_rate_val = 7;
-		break;
-	case SAMPLING_RATE_384KHZ:
-		sample_rate_val = 8;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int aux_pcm_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_8KHZ:
-	default:
-		sample_rate_val = 0;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
-			    struct tdm_port *port)
-{
-	if (port) {
-		if (strnstr(kcontrol->id.name, "PRI",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_PRI;
-		} else if (strnstr(kcontrol->id.name, "SEC",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_SEC;
-		} else if (strnstr(kcontrol->id.name, "TERT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_TERT;
-		} else if (strnstr(kcontrol->id.name, "QUAT",
-		    sizeof(kcontrol->id.name))) {
-			port->mode = TDM_QUAT;
-		} else {
-			pr_err("%s: unsupported mode in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-
-		if (strnstr(kcontrol->id.name, "RX_0",
-		    sizeof(kcontrol->id.name)) ||
-		    strnstr(kcontrol->id.name, "TX_0",
-		    sizeof(kcontrol->id.name))) {
-			port->channel = TDM_0;
-		} else if (strnstr(kcontrol->id.name, "RX_1",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_1",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_1;
-		} else if (strnstr(kcontrol->id.name, "RX_2",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_2",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_2;
-		} else if (strnstr(kcontrol->id.name, "RX_3",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_3",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_3;
-		} else if (strnstr(kcontrol->id.name, "RX_4",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_4",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_4;
-		} else if (strnstr(kcontrol->id.name, "RX_5",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_5",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_5;
-		} else if (strnstr(kcontrol->id.name, "RX_6",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_6",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_6;
-		} else if (strnstr(kcontrol->id.name, "RX_7",
-			   sizeof(kcontrol->id.name)) ||
-			   strnstr(kcontrol->id.name, "TX_7",
-			   sizeof(kcontrol->id.name))) {
-			port->channel = TDM_7;
-		} else {
-			pr_err("%s: unsupported channel in: %s",
-				__func__, kcontrol->id.name);
-			return -EINVAL;
-		}
-	} else
-		return -EINVAL;
-	return 0;
-}
-
-static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_rx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
-			tdm_tx_cfg[port.mode][port.channel].sample_rate);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].sample_rate =
-			tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].sample_rate,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_get_format(int value)
-{
-	int format = 0;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int tdm_get_format_val(int format)
-{
-	int value = 0;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 2;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_rx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] = tdm_get_format_val(
-				tdm_tx_cfg[port.mode][port.channel].bit_format);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
-			     struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].bit_format =
-			tdm_get_format(ucontrol->value.enumerated.item[0]);
-
-		pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].bit_format,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-
-		ucontrol->value.enumerated.item[0] =
-			tdm_rx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
-			 struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_rx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
-			 tdm_rx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		ucontrol->value.enumerated.item[0] =
-			tdm_tx_cfg[port.mode][port.channel].channels - 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels - 1,
-			 ucontrol->value.enumerated.item[0]);
-	}
-	return ret;
-}
-
-static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	struct tdm_port port;
-	int ret = tdm_get_port_idx(kcontrol, &port);
-
-	if (ret) {
-		pr_err("%s: unsupported control: %s",
-			__func__, kcontrol->id.name);
-	} else {
-		tdm_tx_cfg[port.mode][port.channel].channels =
-			ucontrol->value.enumerated.item[0] + 1;
-
-		pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
-			 tdm_tx_cfg[port.mode][port.channel].channels,
-			 ucontrol->value.enumerated.item[0] + 1);
-	}
-	return ret;
-}
-
-static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
-		    sizeof("PRIM_AUX_PCM")))
-		idx = PRIM_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
-			 sizeof("SEC_AUX_PCM")))
-		idx = SEC_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
-			 sizeof("TERT_AUX_PCM")))
-		idx = TERT_AUX_PCM;
-	else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
-			 sizeof("QUAT_AUX_PCM")))
-		idx = QUAT_AUX_PCM;
-	else {
-		pr_err("%s: unsupported port: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_rx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_tx_cfg[idx].sample_rate =
-		aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-	     aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, aux_pcm_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
-{
-	int idx;
-
-	if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
-	    sizeof("PRIM_MI2S_RX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
-		 sizeof("SEC_MI2S_RX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
-		 sizeof("TERT_MI2S_RX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
-		 sizeof("QUAT_MI2S_RX")))
-		idx = QUAT_MI2S;
-	else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
-		 sizeof("PRIM_MI2S_TX")))
-		idx = PRIM_MI2S;
-	else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
-		 sizeof("SEC_MI2S_TX")))
-		idx = SEC_MI2S;
-	else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
-		 sizeof("TERT_MI2S_TX")))
-		idx = TERT_MI2S;
-	else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
-		 sizeof("QUAT_MI2S_TX")))
-		idx = QUAT_MI2S;
-	else {
-		pr_err("%s: unsupported channel: %s",
-			__func__, kcontrol->id.name);
-		idx = -EINVAL;
-	}
-
-	return idx;
-}
-
-static int mi2s_get_sample_rate_val(int sample_rate)
-{
-	int sample_rate_val;
-
-	switch (sample_rate) {
-	case SAMPLING_RATE_8KHZ:
-		sample_rate_val = 0;
-		break;
-	case SAMPLING_RATE_16KHZ:
-		sample_rate_val = 1;
-		break;
-	case SAMPLING_RATE_32KHZ:
-		sample_rate_val = 2;
-		break;
-	case SAMPLING_RATE_44P1KHZ:
-		sample_rate_val = 3;
-		break;
-	case SAMPLING_RATE_48KHZ:
-		sample_rate_val = 4;
-		break;
-	case SAMPLING_RATE_96KHZ:
-		sample_rate_val = 5;
-		break;
-	case SAMPLING_RATE_192KHZ:
-		sample_rate_val = 6;
-		break;
-	default:
-		sample_rate_val = 4;
-		break;
-	}
-	return sample_rate_val;
-}
-
-static int mi2s_get_sample_rate(int value)
-{
-	int sample_rate;
-
-	switch (value) {
-	case 0:
-		sample_rate = SAMPLING_RATE_8KHZ;
-		break;
-	case 1:
-		sample_rate = SAMPLING_RATE_16KHZ;
-		break;
-	case 2:
-		sample_rate = SAMPLING_RATE_32KHZ;
-		break;
-	case 3:
-		sample_rate = SAMPLING_RATE_44P1KHZ;
-		break;
-	case 4:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	case 5:
-		sample_rate = SAMPLING_RATE_96KHZ;
-		break;
-	case 6:
-		sample_rate = SAMPLING_RATE_192KHZ;
-		break;
-	default:
-		sample_rate = SAMPLING_RATE_48KHZ;
-		break;
-	}
-	return sample_rate;
-}
-
-static int mi2s_auxpcm_get_format(int value)
-{
-	int format;
-
-	switch (value) {
-	case 0:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	case 1:
-		format = SNDRV_PCM_FORMAT_S24_LE;
-		break;
-	case 2:
-		format = SNDRV_PCM_FORMAT_S24_3LE;
-		break;
-	case 3:
-		format = SNDRV_PCM_FORMAT_S32_LE;
-		break;
-	default:
-		format = SNDRV_PCM_FORMAT_S16_LE;
-		break;
-	}
-	return format;
-}
-
-static int mi2s_auxpcm_get_format_value(int format)
-{
-	int value;
-
-	switch (format) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-		value = 0;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-		value = 1;
-		break;
-	case SNDRV_PCM_FORMAT_S24_3LE:
-		value = 2;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-		value = 3;
-		break;
-	default:
-		value = 0;
-		break;
-	}
-	return value;
-}
-
-static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].sample_rate =
-		mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
-				   struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
-
-	pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].sample_rate,
-		 ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_rx_ch  = %d\n", __func__,
-		 idx, mi2s_rx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-	ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
-
-	return 0;
-}
-
-static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
-			      struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
-	pr_debug("%s: msm_mi2s_[%d]_tx_ch  = %d\n", __func__,
-		 idx, mi2s_tx_cfg[idx].channels);
-
-	return 1;
-}
-
-static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		idx, mi2s_rx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_rx_cfg[idx].bit_format =
-		mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_rx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		idx, mi2s_tx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = mi2s_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	mi2s_tx_cfg[idx].bit_format =
-		mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		  idx, mi2s_tx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		idx, aux_pcm_rx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_rx_cfg[idx].bit_format =
-		mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
-		  idx, aux_pcm_rx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	ucontrol->value.enumerated.item[0] =
-		mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		idx, aux_pcm_tx_cfg[idx].bit_format,
-		ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
-				struct snd_ctl_elem_value *ucontrol)
-{
-	int idx = aux_pcm_get_port_idx(kcontrol);
-
-	if (idx < 0)
-		return idx;
-
-	aux_pcm_tx_cfg[idx].bit_format =
-		mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
-
-	pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
-		  idx, aux_pcm_tx_cfg[idx].bit_format,
-		  ucontrol->value.enumerated.item[0]);
-
-	return 0;
-}
-
-static int msm_hifi_ctrl(struct snd_soc_codec *codec)
-{
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	pr_debug("%s: msm_hifi_control = %d", __func__,
-		 msm_hifi_control);
-
-	if (!pdata || !pdata->hph_en1_gpio_p) {
-		pr_err("%s: hph_en1_gpio is invalid\n", __func__);
-		return -EINVAL;
-	}
-	if (msm_hifi_control == MSM_HIFI_ON) {
-		msm_cdc_pinctrl_select_active_state(pdata->hph_en1_gpio_p);
-		/* 5msec delay needed as per HW requirement */
-		usleep_range(5000, 5010);
-	} else {
-		msm_cdc_pinctrl_select_sleep_state(pdata->hph_en1_gpio_p);
-	}
-	snd_soc_dapm_sync(dapm);
-
-	return 0;
-}
-
-static int msm_hifi_get(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	pr_debug("%s: msm_hifi_control = %d\n",
-		 __func__, msm_hifi_control);
-	ucontrol->value.integer.value[0] = msm_hifi_control;
-
-	return 0;
-}
-
-static int msm_hifi_put(struct snd_kcontrol *kcontrol,
-			struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-	pr_debug("%s() ucontrol->value.integer.value[0] = %ld\n",
-		 __func__, ucontrol->value.integer.value[0]);
-
-	msm_hifi_control = ucontrol->value.integer.value[0];
-	msm_hifi_ctrl(codec);
-
-	return 0;
-}
-
-static s32 msm_qos_value(struct snd_pcm_runtime *runtime)
-{
-	s32 usecs;
-
-	if (!runtime->rate)
-		return -EINVAL;
-
-	/* take 75% of period time as the deadline */
-	usecs = (750000 / runtime->rate) * runtime->period_size;
-	usecs += ((750000 % runtime->rate) * runtime->period_size) /
-		 runtime->rate;
-
-	return usecs;
-}
-
-static int msm_qos_ctl_get(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.enumerated.item[0] = qos_vote_status;
-
-	return 0;
-}
-
-static int msm_qos_ctl_put(struct snd_kcontrol *kcontrol,
-			   struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-	struct snd_soc_card *card = codec->component.card;
-	const char *be_name = MSM_DAILINK_NAME(LowLatency);
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_pcm_substream *substream;
-	s32 usecs;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_name);
-	if (!rtd) {
-		pr_err("%s: fail to get pcm runtime for %s\n",
-			__func__, be_name);
-		return -EINVAL;
-	}
-
-	substream = rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-	if (!substream) {
-		pr_err("%s: substream is null\n", __func__);
-		return -EINVAL;
-	}
-
-	qos_vote_status = ucontrol->value.enumerated.item[0];
-	if (qos_vote_status) {
-		if (pm_qos_request_active(&substream->latency_pm_qos_req))
-			pm_qos_remove_request(&substream->latency_pm_qos_req);
-		if (!substream->runtime) {
-			pr_err("%s: runtime is null\n", __func__);
-			return -EINVAL;
-		}
-		usecs = msm_qos_value(substream->runtime);
-		if (usecs >= 0)
-			pm_qos_add_request(&substream->latency_pm_qos_req,
-					PM_QOS_CPU_DMA_LATENCY, usecs);
-	} else {
-		if (pm_qos_request_active(&substream->latency_pm_qos_req))
-			pm_qos_remove_request(&substream->latency_pm_qos_req);
-	}
-
-	return 0;
-}
-
-static const struct snd_kcontrol_new msm_snd_controls[] = {
-	SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
-			msm_slim_tx_ch_get, msm_slim_tx_ch_put),
-	SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
-			msm_slim_rx_ch_get, msm_slim_rx_ch_put),
-	SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
-			msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
-			usb_audio_rx_ch_get, usb_audio_rx_ch_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
-			usb_audio_tx_ch_get, usb_audio_tx_ch_put),
-	SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
-			ext_disp_rx_ch_get, ext_disp_rx_ch_put),
-	SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
-			proxy_rx_ch_get, proxy_rx_ch_put),
-	SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
-			slim_rx_bit_format_get, slim_rx_bit_format_put),
-	SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
-			slim_tx_bit_format_get, slim_tx_bit_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
-			usb_audio_rx_format_get, usb_audio_rx_format_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
-			usb_audio_tx_format_get, usb_audio_tx_format_put),
-	SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
-			ext_disp_rx_format_get, ext_disp_rx_format_put),
-	SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
-			slim_tx_sample_rate_get, slim_tx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
-			slim_rx_sample_rate_get, slim_rx_sample_rate_put),
-	SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
-			msm_bt_sample_rate_get,
-			msm_bt_sample_rate_put),
-	SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
-			usb_audio_rx_sample_rate_get,
-			usb_audio_rx_sample_rate_put),
-	SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
-			usb_audio_tx_sample_rate_get,
-			usb_audio_tx_sample_rate_put),
-	SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
-			ext_disp_rx_sample_rate_get,
-			ext_disp_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
-			tdm_rx_sample_rate_get,
-			tdm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
-			tdm_tx_sample_rate_get,
-			tdm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
-			tdm_rx_format_get,
-			tdm_rx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
-			tdm_tx_format_get,
-			tdm_tx_format_put),
-	SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
-			tdm_rx_ch_get,
-			tdm_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
-			tdm_tx_ch_get,
-			tdm_tx_ch_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
-			aux_pcm_rx_sample_rate_get,
-			aux_pcm_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
-			aux_pcm_tx_sample_rate_get,
-			aux_pcm_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
-			mi2s_rx_sample_rate_get,
-			mi2s_rx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
-			mi2s_tx_sample_rate_get,
-			mi2s_tx_sample_rate_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
-			msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
-			msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
-	SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
-			msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
-	SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
-			msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
-			msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
-	SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
-			msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
-			msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
-	SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
-			msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
-			msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
-	SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
-			msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
-			msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
-	SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
-			msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
-	SOC_ENUM_EXT("HiFi Function", hifi_function, msm_hifi_get,
-			msm_hifi_put),
-	SOC_ENUM_EXT("MultiMedia5_RX QOS Vote", qos_vote, msm_qos_ctl_get,
-			msm_qos_ctl_put),
-};
-
-static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
-					int enable, bool dapm)
-{
-	int ret = 0;
-
-	if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
-		ret = tavil_cdc_mclk_enable(codec, enable);
-	} else {
-		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_codec *codec,
-					   int enable, bool dapm)
-{
-	int ret = 0;
-
-	if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
-		ret = tavil_cdc_mclk_tx_enable(codec, enable);
-	} else {
-		dev_err(codec->dev, "%s: unknown codec to enable TX ext clk\n",
-			__func__);
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
-			     struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_snd_enable_codec_ext_tx_clk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_mclk_event(struct snd_soc_dapm_widget *w,
-				 struct snd_kcontrol *kcontrol, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-	pr_debug("%s: event = %d\n", __func__, event);
-
-	switch (event) {
-	case SND_SOC_DAPM_PRE_PMU:
-		return msm_snd_enable_codec_ext_clk(codec, 1, true);
-	case SND_SOC_DAPM_POST_PMD:
-		return msm_snd_enable_codec_ext_clk(codec, 0, true);
-	}
-	return 0;
-}
-
-static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
-			       struct snd_kcontrol *k, int event)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	pr_debug("%s: msm_hifi_control = %d", __func__, msm_hifi_control);
-
-	if (!pdata || !pdata->hph_en0_gpio_p) {
-		pr_err("%s: hph_en0_gpio is invalid\n", __func__);
-		return -EINVAL;
-	}
-
-	if (msm_hifi_control != MSM_HIFI_ON) {
-		pr_debug("%s: HiFi mixer control is not set\n",
-			 __func__);
-		return 0;
-	}
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		msm_cdc_pinctrl_select_active_state(pdata->hph_en0_gpio_p);
-		break;
-	case SND_SOC_DAPM_PRE_PMD:
-		msm_cdc_pinctrl_select_sleep_state(pdata->hph_en0_gpio_p);
-		break;
-	}
-
-	return 0;
-}
-
-static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
-
-	SND_SOC_DAPM_SUPPLY("MCLK",  SND_SOC_NOPM, 0, 0,
-			    msm_mclk_event,
-			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SUPPLY("MCLK TX",  SND_SOC_NOPM, 0, 0,
-	msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
-	SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
-	SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
-	SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
-	SND_SOC_DAPM_MIC("Handset Mic", NULL),
-	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
-	SND_SOC_DAPM_MIC("Analog Mic5", NULL),
-
-	SND_SOC_DAPM_MIC("Digital Mic0", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic1", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic2", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic3", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic4", NULL),
-	SND_SOC_DAPM_MIC("Digital Mic5", NULL),
-};
-
-static inline int param_is_mask(int p)
-{
-	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
-			(p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
-}
-
-static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
-					     int n)
-{
-	return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
-}
-
-static void param_set_mask(struct snd_pcm_hw_params *p, int n,
-			   unsigned int bit)
-{
-	if (bit >= SNDRV_MASK_MAX)
-		return;
-	if (param_is_mask(n)) {
-		struct snd_mask *m = param_to_mask(p, n);
-
-		m->bits[0] = 0;
-		m->bits[1] = 0;
-		m->bits[bit >> 5] |= (1 << (bit & 31));
-	}
-}
-
-static int msm_slim_get_ch_from_beid(int32_t be_id)
-{
-	int ch_id = 0;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-		ch_id = SLIM_RX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-		ch_id = SLIM_RX_1;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-		ch_id = SLIM_RX_2;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-		ch_id = SLIM_RX_3;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-		ch_id = SLIM_RX_4;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		ch_id = SLIM_RX_6;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-		ch_id = SLIM_TX_0;
-		break;
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		ch_id = SLIM_TX_3;
-		break;
-	default:
-		ch_id = SLIM_RX_0;
-		break;
-	}
-
-	return ch_id;
-}
-
-static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
-{
-	int idx;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = DP_RX_IDX;
-		break;
-	default:
-		pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
-		idx = -EINVAL;
-		break;
-	}
-
-	return idx;
-}
-
-static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-	int rc = 0;
-	int idx;
-	void *config = NULL;
-	struct snd_soc_codec *codec = NULL;
-
-	pr_debug("%s: format = %d, rate = %d\n",
-		  __func__, params_format(params), params_rate(params));
-
-	switch (dai_link->id) {
-	case MSM_BACKEND_DAI_SLIMBUS_0_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_1_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_2_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_4_RX:
-	case MSM_BACKEND_DAI_SLIMBUS_6_RX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_0_TX:
-	case MSM_BACKEND_DAI_SLIMBUS_3_TX:
-		idx = msm_slim_get_ch_from_beid(dai_link->id);
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[idx].bit_format);
-		rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_1_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_tx_cfg[1].bit_format);
-		rate->min = rate->max = slim_tx_cfg[1].sample_rate;
-		channels->min = channels->max = slim_tx_cfg[1].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_4_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       SNDRV_PCM_FORMAT_S32_LE);
-		rate->min = rate->max = SAMPLING_RATE_8KHZ;
-		channels->min = channels->max = msm_vi_feed_tx_ch;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[5].bit_format);
-		rate->min = rate->max = slim_rx_cfg[5].sample_rate;
-		channels->min = channels->max = slim_rx_cfg[5].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_5_TX:
-		codec = rtd->codec;
-		rate->min = rate->max = SAMPLING_RATE_16KHZ;
-		channels->min = channels->max = 1;
-
-		config = msm_codec_fn.get_afe_config_fn(codec,
-					AFE_SLIMBUS_SLAVE_PORT_CONFIG);
-		if (config) {
-			rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
-					    config, SLIMBUS_5_TX);
-			if (rc)
-				pr_err("%s: Failed to set slimbus slave port config %d\n",
-					__func__, rc);
-		}
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				slim_rx_cfg[SLIM_RX_7].bit_format);
-		rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
-		channels->min = channels->max =
-			slim_rx_cfg[SLIM_RX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_7_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_7].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SLIMBUS_8_TX:
-		rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
-		channels->min = channels->max =
-			slim_tx_cfg[SLIM_TX_8].channels;
-		break;
-
-	case MSM_BACKEND_DAI_USB_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_rx_cfg.bit_format);
-		rate->min = rate->max = usb_rx_cfg.sample_rate;
-		channels->min = channels->max = usb_rx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_USB_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				usb_tx_cfg.bit_format);
-		rate->min = rate->max = usb_tx_cfg.sample_rate;
-		channels->min = channels->max = usb_tx_cfg.channels;
-		break;
-
-	case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
-		idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
-		if (idx < 0) {
-			pr_err("%s: Incorrect ext disp idx %d\n",
-			       __func__, idx);
-			rc = idx;
-			goto done;
-		}
-
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-				ext_disp_rx_cfg[idx].bit_format);
-		rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
-		channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AFE_PCM_RX:
-		channels->min = channels->max = proxy_rx_cfg.channels;
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_PRI][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_TERT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
-		channels->min = channels->max =
-				tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_AUXPCM_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
-		rate->min = rate->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
-		channels->min = channels->max =
-			aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[PRIM_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[PRIM_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[PRIM_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[PRIM_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[SEC_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[SEC_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[SEC_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[SEC_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[TERT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[TERT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[TERT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[TERT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_rx_cfg[QUAT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_rx_cfg[QUAT_MI2S].channels;
-		break;
-
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			mi2s_tx_cfg[QUAT_MI2S].bit_format);
-		rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
-		channels->min = channels->max =
-			mi2s_tx_cfg[QUAT_MI2S].channels;
-		break;
-
-	default:
-		rate->min = rate->max = SAMPLING_RATE_48KHZ;
-		break;
-	}
-
-done:
-	return rc;
-}
-
-static bool msm_usbc_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
-{
-	int value = 0;
-	bool ret = 0;
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct pinctrl_state *en2_pinctrl_active;
-	struct pinctrl_state *en2_pinctrl_sleep;
-
-	if (!pdata->usbc_en2_gpio_p) {
-		if (active) {
-			/* if active and usbc_en2_gpio undefined, get pin */
-			pdata->usbc_en2_gpio_p = devm_pinctrl_get(card->dev);
-			if (IS_ERR_OR_NULL(pdata->usbc_en2_gpio_p)) {
-				dev_err(card->dev,
-					"%s: Can't get EN2 gpio pinctrl:%ld\n",
-					__func__,
-					PTR_ERR(pdata->usbc_en2_gpio_p));
-				pdata->usbc_en2_gpio_p = NULL;
-				return false;
-			}
-		} else
-			/* if not active and usbc_en2_gpio undefined, return */
-			return false;
-	}
-
-	pdata->usbc_en2_gpio = of_get_named_gpio(card->dev->of_node,
-				    "qcom,usbc-analog-en2-gpio", 0);
-	if (!gpio_is_valid(pdata->usbc_en2_gpio)) {
-		dev_err(card->dev, "%s, property %s not in node %s",
-			__func__, "qcom,usbc-analog-en2-gpio",
-			card->dev->of_node->full_name);
-		return false;
-	}
-
-	en2_pinctrl_active = pinctrl_lookup_state(
-					pdata->usbc_en2_gpio_p, "aud_active");
-	if (IS_ERR_OR_NULL(en2_pinctrl_active)) {
-		dev_err(card->dev,
-			"%s: Cannot get aud_active pinctrl state:%ld\n",
-			__func__, PTR_ERR(en2_pinctrl_active));
-		ret = false;
-		goto err_lookup_state;
-	}
-
-	en2_pinctrl_sleep = pinctrl_lookup_state(
-					pdata->usbc_en2_gpio_p, "aud_sleep");
-	if (IS_ERR_OR_NULL(en2_pinctrl_sleep)) {
-		dev_err(card->dev,
-			"%s: Cannot get aud_sleep pinctrl state:%ld\n",
-			__func__, PTR_ERR(en2_pinctrl_sleep));
-		ret = false;
-		goto err_lookup_state;
-	}
-
-	/* if active and usbc_en2_gpio_p defined, swap using usbc_en2_gpio_p */
-	if (active) {
-		dev_dbg(codec->dev, "%s: enter\n", __func__);
-		if (pdata->usbc_en2_gpio_p) {
-			value = gpio_get_value_cansleep(pdata->usbc_en2_gpio);
-			if (value)
-				pinctrl_select_state(pdata->usbc_en2_gpio_p,
-							en2_pinctrl_sleep);
-			else
-				pinctrl_select_state(pdata->usbc_en2_gpio_p,
-							en2_pinctrl_active);
-		} else if (pdata->usbc_en2_gpio >= 0) {
-			value = gpio_get_value_cansleep(pdata->usbc_en2_gpio);
-			gpio_set_value_cansleep(pdata->usbc_en2_gpio, !value);
-		}
-		pr_debug("%s: swap select switch %d to %d\n", __func__,
-			value, !value);
-		ret = true;
-	} else {
-		/* if not active, release usbc_en2_gpio_p pin */
-		pinctrl_select_state(pdata->usbc_en2_gpio_p,
-					en2_pinctrl_sleep);
-	}
-
-err_lookup_state:
-	devm_pinctrl_put(pdata->usbc_en2_gpio_p);
-	pdata->usbc_en2_gpio_p = NULL;
-	return ret;
-}
-
-static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
-{
-	int value = 0;
-	int ret = 0;
-	struct snd_soc_card *card = codec->component.card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-
-	if (!pdata)
-		return false;
-
-	if (!wcd_mbhc_cfg.enable_usbc_analog) {
-		/* if usbc is not defined, swap using us_euro_gpio_p */
-		if (pdata->us_euro_gpio_p) {
-			value = msm_cdc_pinctrl_get_state(
-						pdata->us_euro_gpio_p);
-			if (value)
-				msm_cdc_pinctrl_select_sleep_state(
-						pdata->us_euro_gpio_p);
-			else
-				msm_cdc_pinctrl_select_active_state(
-						pdata->us_euro_gpio_p);
-		} else if (pdata->us_euro_gpio >= 0) {
-			value = gpio_get_value_cansleep(
-						pdata->us_euro_gpio);
-			gpio_set_value_cansleep(
-					pdata->us_euro_gpio, !value);
-		}
-		pr_debug("%s: swap select switch %d to %d\n", __func__,
-			 value, !value);
-		ret = true;
-	} else {
-		/* if usbc is defined, swap using usbc_en2 */
-		ret = msm_usbc_swap_gnd_mic(codec, active);
-	}
-	return ret;
-}
-
-static int msm_afe_set_config(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	void *config_data = NULL;
-
-	if (!msm_codec_fn.get_afe_config_fn) {
-		dev_err(codec->dev, "%s: codec get afe config not init'ed\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTERS_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
-		if (ret) {
-			dev_err(codec->dev,
-				"%s: Failed to set codec registers config %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_CDC_REGISTER_PAGE_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
-				    0);
-		if (ret)
-			dev_err(codec->dev,
-				"%s: Failed to set cdc register page config\n",
-				__func__);
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-			AFE_SLIMBUS_SLAVE_CONFIG);
-	if (config_data) {
-		ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
-		if (ret) {
-			dev_err(codec->dev,
-				"%s: Failed to set slimbus slave config %d\n",
-				__func__, ret);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static void msm_afe_clear_config(void)
-{
-	afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
-	afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
-}
-
-static int msm_adsp_power_up_config(struct snd_soc_codec *codec)
-{
-	int ret = 0;
-	unsigned long timeout;
-	int adsp_ready = 0;
-
-	timeout = jiffies +
-		msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
-
-	do {
-		if (q6core_is_adsp_ready()) {
-			pr_debug("%s: ADSP Audio is ready\n", __func__);
-			adsp_ready = 1;
-			break;
-		}
-		/*
-		 * ADSP will be coming up after subsystem restart and
-		 * it might not be fully up when the control reaches
-		 * here. So, wait for 50msec before checking ADSP state
-		 */
-		msleep(50);
-	} while (time_after(timeout, jiffies));
-
-	if (!adsp_ready) {
-		pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
-		ret = -ETIMEDOUT;
-		goto err;
-	}
-
-	ret = msm_afe_set_config(codec);
-	if (ret)
-		pr_err("%s: Failed to set AFE config. err %d\n",
-			__func__, ret);
-
-	return 0;
-
-err:
-	return ret;
-}
-
-static int sdm845_notifier_service_cb(struct notifier_block *this,
-					 unsigned long opcode, void *ptr)
-{
-	int ret;
-	struct snd_soc_card *card = NULL;
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	struct snd_soc_codec *codec;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		/*
-		 * Use flag to ignore initial boot notifications
-		 * On initial boot msm_adsp_power_up_config is
-		 * called on init. There is no need to clear
-		 * and set the config again on initial boot.
-		 */
-		if (is_initial_boot)
-			break;
-		msm_afe_clear_config();
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (is_initial_boot) {
-			is_initial_boot = false;
-			break;
-		}
-		if (!spdev)
-			return -EINVAL;
-
-		card = platform_get_drvdata(spdev);
-		rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-		if (!rtd) {
-			dev_err(card->dev,
-				"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-				__func__, be_dl_name);
-			ret = -EINVAL;
-			goto err;
-		}
-		codec = rtd->codec;
-
-		ret = msm_adsp_power_up_config(codec);
-		if (ret < 0) {
-			dev_err(card->dev,
-				"%s: msm_adsp_power_up_config failed ret = %d!\n",
-				__func__, ret);
-			goto err;
-		}
-		break;
-	default:
-		break;
-	}
-err:
-	return NOTIFY_OK;
-}
-
-static struct notifier_block service_nb = {
-	.notifier_call  = sdm845_notifier_service_cb,
-	.priority = -INT_MAX,
-};
-
-static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	void *config_data;
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_component *aux_comp;
-	struct snd_card *card;
-	struct snd_info_entry *entry;
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(rtd->card);
-
-	/* Codec SLIMBUS configuration
-	 * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
-	 * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
-	 * TX14, TX15, TX16
-	 */
-	unsigned int rx_ch[WCD934X_RX_MAX] = {144, 145, 146, 147, 148, 149,
-					      150, 151};
-	unsigned int tx_ch[WCD934X_TX_MAX] = {128, 129, 130, 131, 132, 133,
-					      134, 135, 136, 137, 138, 139,
-					      140, 141, 142, 143};
-
-	pr_info("%s: dev_name%s\n", __func__, dev_name(cpu_dai->dev));
-
-	rtd->pmdown_time = 0;
-
-	ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
-					 ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		pr_err("%s: add_codec_controls failed, err %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
-				ARRAY_SIZE(msm_dapm_widgets));
-
-	snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
-				ARRAY_SIZE(wcd_audio_paths));
-
-	snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
-	snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
-	snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
-	snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
-	snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT2");
-	snd_soc_dapm_ignore_suspend(dapm, "EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
-	snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHL");
-	snd_soc_dapm_ignore_suspend(dapm, "HPHR");
-	snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
-	snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
-	snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
-
-	snd_soc_dapm_sync(dapm);
-
-	snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-				    tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
-
-	msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
-
-	ret = msm_adsp_power_up_config(codec);
-	if (ret) {
-		pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
-		goto err;
-	}
-
-	config_data = msm_codec_fn.get_afe_config_fn(codec,
-						     AFE_AANC_VERSION);
-	if (config_data) {
-		ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
-		if (ret) {
-			pr_err("%s: Failed to set aanc version %d\n",
-				__func__, ret);
-			goto err;
-		}
-	}
-
-	/*
-	 * Send speaker configuration only for WSA8810.
-	 * Default configuration is for WSA8815.
-	 */
-	pr_debug("%s: Number of aux devices: %d\n",
-		__func__, rtd->card->num_aux_devs);
-	if (rtd->card->num_aux_devs &&
-	    !list_empty(&rtd->card->aux_comp_list)) {
-		aux_comp = list_first_entry(&rtd->card->aux_comp_list,
-				struct snd_soc_component, list_aux);
-		if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
-		    !strcmp(aux_comp->name, WSA8810_NAME_2)) {
-			tavil_set_spkr_mode(rtd->codec, WCD934X_SPKR_MODE_1);
-			tavil_set_spkr_gain_offset(rtd->codec,
-					WCD934X_RX_GAIN_OFFSET_M1P5_DB);
-		}
-	}
-	card = rtd->card->snd_card;
-	entry = snd_info_create_subdir(card->module, "codecs",
-				       card->proc_root);
-	if (!entry) {
-		pr_debug("%s: Cannot create codecs module entry\n",
-			 __func__);
-		pdata->codec_root = NULL;
-		goto done;
-	}
-	pdata->codec_root = entry;
-	tavil_codec_info_create_codec_entry(pdata->codec_root, codec);
-
-done:
-	codec_reg_done = true;
-	return 0;
-
-err:
-	return ret;
-}
-
-static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
-{
-	unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
-	unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX]  = {159, 160, 161};
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-
-	return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
-					   tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
-}
-
-static void *def_tavil_mbhc_cal(void)
-{
-	void *tavil_wcd_cal;
-	struct wcd_mbhc_btn_detect_cfg *btn_cfg;
-	u16 *btn_high;
-
-	tavil_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
-				WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
-	if (!tavil_wcd_cal)
-		return NULL;
-
-#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(tavil_wcd_cal)->X) = (Y))
-	S(v_hs_max, 1600);
-#undef S
-#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal)->X) = (Y))
-	S(num_btn, WCD_MBHC_DEF_BUTTONS);
-#undef S
-
-	btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal);
-	btn_high = ((void *)&btn_cfg->_v_btn_low) +
-		(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
-
-	btn_high[0] = 75;
-	btn_high[1] = 150;
-	btn_high[2] = 237;
-	btn_high[3] = 500;
-	btn_high[4] = 500;
-	btn_high[5] = 500;
-	btn_high[6] = 500;
-	btn_high[7] = 500;
-
-	return tavil_wcd_cal;
-}
-
-static int msm_snd_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
-	int ret = 0;
-	u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	u32 user_set_tx_ch = 0;
-	u32 rx_ch_count;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
-			pr_debug("%s: rx_5_ch=%d\n", __func__,
-				  slim_rx_cfg[5].channels);
-			rx_ch_count = slim_rx_cfg[5].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
-			pr_debug("%s: rx_2_ch=%d\n", __func__,
-				 slim_rx_cfg[2].channels);
-			rx_ch_count = slim_rx_cfg[2].channels;
-		} else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
-			pr_debug("%s: rx_6_ch=%d\n", __func__,
-				  slim_rx_cfg[6].channels);
-			rx_ch_count = slim_rx_cfg[6].channels;
-		} else {
-			pr_debug("%s: rx_0_ch=%d\n", __func__,
-				  slim_rx_cfg[0].channels);
-			rx_ch_count = slim_rx_cfg[0].channels;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-						  rx_ch_count, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	} else {
-
-		pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
-			 codec_dai->name, codec_dai->id, user_set_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-					 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map\n, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-		/* For <codec>_tx1 case */
-		if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
-			user_set_tx_ch = slim_tx_cfg[0].channels;
-		/* For <codec>_tx3 case */
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
-			user_set_tx_ch = slim_tx_cfg[1].channels;
-		else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
-			user_set_tx_ch = msm_vi_feed_tx_ch;
-		else
-			user_set_tx_ch = tx_ch_cnt;
-
-		pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
-			 __func__,  slim_tx_cfg[0].channels, user_set_tx_ch,
-			 tx_ch_cnt, dai_link->id);
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-						  user_set_tx_ch, tx_ch, 0, 0);
-		if (ret < 0)
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-	}
-
-err:
-	return ret;
-}
-
-static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream,
-					  struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
-	unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
-	unsigned int num_tx_ch = 0;
-	unsigned int num_rx_ch = 0;
-	int ret = 0;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		num_rx_ch =  params_channels(params);
-		pr_debug("%s: %s rx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_rx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-				num_rx_ch, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	} else {
-		num_tx_ch =  params_channels(params);
-		pr_debug("%s: %s  tx_dai_id = %d  num_ch = %d\n", __func__,
-			codec_dai->name, codec_dai->id, num_tx_ch);
-		ret = snd_soc_dai_get_channel_map(codec_dai,
-				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-		if (ret < 0) {
-			pr_err("%s: failed to get codec chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-				num_tx_ch, tx_ch, 0, 0);
-		if (ret < 0) {
-			pr_err("%s: failed to set cpu chan map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	}
-
-err:
-	return ret;
-}
-
-static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai_link *dai_link = rtd->dai_link;
-	u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
-	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
-	int ret;
-
-	dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
-		 codec_dai->name, codec_dai->id);
-	ret = snd_soc_dai_get_channel_map(codec_dai,
-				 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
-	if (ret) {
-		dev_err(rtd->dev,
-			"%s: failed to get BTFM codec chan map\n, err:%d\n",
-			__func__, ret);
-		goto err;
-	}
-
-	dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
-		__func__, tx_ch_cnt, dai_link->id);
-
-	ret = snd_soc_dai_set_channel_map(cpu_dai,
-					  tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
-	if (ret)
-		dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
-			__func__, ret);
-
-err:
-	return ret;
-}
-
-static int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int index = cpu_dai->id - 1;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		cpu_dai->name, cpu_dai->id);
-
-	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
-		ret = -EINVAL;
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, cpu_dai->id);
-		goto err;
-	}
-
-	mutex_lock(&auxpcm_intf_conf[index].lock);
-	if (++auxpcm_intf_conf[index].ref_cnt == 1) {
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(1,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
-				__func__);
-			ret = -EINVAL;
-		}
-	}
-	if (ret < 0)
-		auxpcm_intf_conf[index].ref_cnt--;
-
-	mutex_unlock(&auxpcm_intf_conf[index].lock);
-
-err:
-	return ret;
-}
-
-static void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int index = rtd->cpu_dai->id - 1;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__,
-		substream->name, substream->stream,
-		rtd->cpu_dai->name, rtd->cpu_dai->id);
-
-	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, rtd->cpu_dai->id);
-		return;
-	}
-
-	mutex_lock(&auxpcm_intf_conf[index].lock);
-	if (--auxpcm_intf_conf[index].ref_cnt == 0) {
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(0,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
-				__func__);
-			auxpcm_intf_conf[index].ref_cnt++;
-		}
-	}
-	mutex_unlock(&auxpcm_intf_conf[index].lock);
-}
-
-static int msm_get_port_id(int be_id)
-{
-	int afe_port_id;
-
-	switch (be_id) {
-	case MSM_BACKEND_DAI_PRI_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_PRI_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
-		break;
-	case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
-		afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
-		break;
-	default:
-		pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
-		afe_port_id = -EINVAL;
-	}
-
-	return afe_port_id;
-}
-
-static u32 get_mi2s_bits_per_sample(u32 bit_format)
-{
-	u32 bit_per_sample;
-
-	switch (bit_format) {
-	case SNDRV_PCM_FORMAT_S32_LE:
-	case SNDRV_PCM_FORMAT_S24_3LE:
-	case SNDRV_PCM_FORMAT_S24_LE:
-		bit_per_sample = 32;
-		break;
-	case SNDRV_PCM_FORMAT_S16_LE:
-	default:
-		bit_per_sample = 16;
-		break;
-	}
-
-	return bit_per_sample;
-}
-
-static void update_mi2s_clk_val(int dai_id, int stream)
-{
-	u32 bit_per_sample;
-
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	} else {
-		bit_per_sample =
-		    get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
-		mi2s_clk[dai_id].clk_freq_in_hz =
-		    mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
-	}
-}
-
-static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int port_id = 0;
-	int index = cpu_dai->id;
-
-	port_id = msm_get_port_id(rtd->dai_link->id);
-	if (port_id < 0) {
-		dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
-		ret = port_id;
-		goto err;
-	}
-
-	if (enable) {
-		update_mi2s_clk_val(index, substream->stream);
-		dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
-			mi2s_clk[index].clk_freq_in_hz);
-	}
-
-	mi2s_clk[index].enable = enable;
-	ret = afe_set_lpass_clock_v2(port_id,
-				     &mi2s_clk[index]);
-	if (ret < 0) {
-		dev_err(rtd->card->dev,
-			"%s: afe lpass clock failed for port 0x%x , err:%d\n",
-			__func__, port_id, ret);
-		goto err;
-	}
-
-err:
-	return ret;
-}
-
-static int msm_set_pinctrl(struct msm_pinctrl_info *pinctrl_info,
-				enum pinctrl_pin_state new_state)
-{
-	int ret = 0;
-	int curr_state = 0;
-
-	if (pinctrl_info == NULL) {
-		pr_err("%s: pinctrl_info is NULL\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	if (pinctrl_info->pinctrl == NULL) {
-		pr_err("%s: pinctrl_info->pinctrl is NULL\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	curr_state = pinctrl_info->curr_state;
-	pinctrl_info->curr_state = new_state;
-	pr_debug("%s: curr_state = %s new_state = %s\n", __func__,
-		 pin_states[curr_state], pin_states[pinctrl_info->curr_state]);
-
-	if (curr_state == pinctrl_info->curr_state) {
-		pr_debug("%s: Already in same state\n", __func__);
-		goto err;
-	}
-
-	if (curr_state != STATE_DISABLE &&
-		pinctrl_info->curr_state != STATE_DISABLE) {
-		pr_debug("%s: state already active cannot switch\n", __func__);
-		ret = -EIO;
-		goto err;
-	}
-
-	switch (pinctrl_info->curr_state) {
-	case STATE_MI2S_ACTIVE:
-		ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_active);
-		if (ret) {
-			pr_err("%s: MI2S state select failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	case STATE_TDM_ACTIVE:
-		ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->tdm_active);
-		if (ret) {
-			pr_err("%s: TDM state select failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	case STATE_DISABLE:
-		if (curr_state == STATE_MI2S_ACTIVE) {
-			ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_disable);
-		} else {
-			ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->tdm_disable);
-		}
-		if (ret) {
-			pr_err("%s:  state disable failed with %d\n",
-				__func__, ret);
-			ret = -EIO;
-			goto err;
-		}
-		break;
-	default:
-		pr_err("%s: TLMM pin state is invalid\n", __func__);
-		return -EINVAL;
-	}
-
-err:
-	return ret;
-}
-
-static void msm_release_pinctrl(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	if (pinctrl_info->pinctrl) {
-		devm_pinctrl_put(pinctrl_info->pinctrl);
-		pinctrl_info->pinctrl = NULL;
-	}
-}
-
-static int msm_get_pinctrl(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = NULL;
-	struct pinctrl *pinctrl;
-	int ret;
-
-	pinctrl_info = &pdata->pinctrl_info;
-
-	if (pinctrl_info == NULL) {
-		pr_err("%s: pinctrl_info is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	pinctrl = devm_pinctrl_get(&pdev->dev);
-	if (IS_ERR_OR_NULL(pinctrl)) {
-		pr_err("%s: Unable to get pinctrl handle\n", __func__);
-		return -EINVAL;
-	}
-	pinctrl_info->pinctrl = pinctrl;
-
-	/* get all the states handles from Device Tree */
-	pinctrl_info->mi2s_disable = pinctrl_lookup_state(pinctrl,
-						"quat-mi2s-sleep");
-	if (IS_ERR(pinctrl_info->mi2s_disable)) {
-		pr_err("%s: could not get mi2s_disable pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->mi2s_active = pinctrl_lookup_state(pinctrl,
-						"quat-mi2s-active");
-	if (IS_ERR(pinctrl_info->mi2s_active)) {
-		pr_err("%s: could not get mi2s_active pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->tdm_disable = pinctrl_lookup_state(pinctrl,
-						"quat-tdm-sleep");
-	if (IS_ERR(pinctrl_info->tdm_disable)) {
-		pr_err("%s: could not get tdm_disable pinstate\n", __func__);
-		goto err;
-	}
-	pinctrl_info->tdm_active = pinctrl_lookup_state(pinctrl,
-						"quat-tdm-active");
-	if (IS_ERR(pinctrl_info->tdm_active)) {
-		pr_err("%s: could not get tdm_active pinstate\n",
-			__func__);
-		goto err;
-	}
-	/* Reset the TLMM pins to a default state */
-	ret = pinctrl_select_state(pinctrl_info->pinctrl,
-					pinctrl_info->mi2s_disable);
-	if (ret != 0) {
-		pr_err("%s: Disable TLMM pins failed with %d\n",
-			__func__, ret);
-		ret = -EIO;
-		goto err;
-	}
-	pinctrl_info->curr_state = STATE_DISABLE;
-
-	return 0;
-
-err:
-	devm_pinctrl_put(pinctrl);
-	pinctrl_info->pinctrl = NULL;
-	return -EINVAL;
-}
-
-static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				      struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	if (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) {
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
-		rate->min = rate->max =
-				tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
-	} else if (cpu_dai->id == AFE_PORT_ID_SECONDARY_TDM_RX) {
-		channels->min = channels->max =
-				tdm_rx_cfg[TDM_SEC][TDM_0].channels;
-		param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
-			       tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
-		rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
-	} else {
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
-		__func__, cpu_dai->id, channels->max, rate->max,
-		params_format(params));
-
-	return 0;
-}
-
-static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	slots = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
-	/*2 slot config - bits 0 and 1 set for the first two slots */
-	slot_mask = 0x0000FFFF >> (16-slots);
-	slot_width = 32;
-	channels = slots;
-
-	pr_debug("%s: slot_width %d slots %d\n", __func__, slot_width, slots);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		pr_debug("%s: slot_width %d\n", __func__, slot_width);
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-			slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-			0, NULL, channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto end;
-		}
-	} else {
-		pr_err("%s: invalid use case, err:%d\n",
-			__func__, ret);
-	}
-
-end:
-	return ret;
-}
-
-static int sdm845_tdm_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	ret = msm_set_pinctrl(pinctrl_info, STATE_TDM_ACTIVE);
-	if (ret)
-		pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-static void sdm845_tdm_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-
-	ret = msm_set_pinctrl(pinctrl_info, STATE_DISABLE);
-	if (ret)
-		pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-			__func__, ret);
-
-}
-
-static struct snd_soc_ops sdm845_tdm_be_ops = {
-	.hw_params = sdm845_tdm_snd_hw_params,
-	.startup = sdm845_tdm_snd_startup,
-	.shutdown = sdm845_tdm_snd_shutdown
-};
-
-static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int index = cpu_dai->id;
-	unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-	int ret_pinctrl = 0;
-
-	dev_dbg(rtd->card->dev,
-		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
-		__func__, substream->name, substream->stream,
-		cpu_dai->name, cpu_dai->id);
-
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		ret = -EINVAL;
-		dev_err(rtd->card->dev,
-			"%s: CPU DAI id (%d) out of range\n",
-			__func__, cpu_dai->id);
-		goto err;
-	}
-	if (index == QUAT_MI2S) {
-		ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_MI2S_ACTIVE);
-		if (ret_pinctrl)
-			pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-				__func__, ret_pinctrl);
-	}
-	/*
-	 * Muxtex protection in case the same MI2S
-	 * interface using for both TX and RX  so
-	 * that the same clock won't be enable twice.
-	 */
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (++mi2s_intf_conf[index].ref_cnt == 1) {
-		/* Check if msm needs to provide the clock to the interface */
-		if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
-			mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
-			fmt = SND_SOC_DAIFMT_CBM_CFM;
-		}
-		ret = msm_mi2s_set_sclk(substream, true);
-		if (ret < 0) {
-			dev_err(rtd->card->dev,
-				"%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
-				__func__, ret);
-			goto clean_up;
-		}
-		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
-			mutex_lock(&mi2s_auxpcm_conf[index].lock);
-			iowrite32(0,
-				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
-			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
-		} else {
-			dev_err(rtd->card->dev,
-				"%s lpaif_muxsel_virt_addr is NULL for dai %d\n",
-				__func__, index);
-			ret = -EINVAL;
-			goto clk_off;
-		}
-		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
-		if (ret < 0) {
-			pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
-				__func__, index, ret);
-			goto clk_off;
-		}
-	}
-clk_off:
-	if (ret < 0)
-		msm_mi2s_set_sclk(substream, false);
-clean_up:
-	if (ret < 0)
-		mi2s_intf_conf[index].ref_cnt--;
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-err:
-	return ret;
-}
-
-static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
-{
-	int ret;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int index = rtd->cpu_dai->id;
-	struct snd_soc_card *card = rtd->card;
-	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
-	struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
-	int ret_pinctrl = 0;
-
-	pr_debug("%s(): substream = %s  stream = %d\n", __func__,
-		 substream->name, substream->stream);
-	if (index < PRIM_MI2S || index > QUAT_MI2S) {
-		pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
-		return;
-	}
-
-	mutex_lock(&mi2s_intf_conf[index].lock);
-	if (--mi2s_intf_conf[index].ref_cnt == 0) {
-		ret = msm_mi2s_set_sclk(substream, false);
-		if (ret < 0) {
-			pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
-				__func__, index, ret);
-			mi2s_intf_conf[index].ref_cnt++;
-		}
-	}
-	mutex_unlock(&mi2s_intf_conf[index].lock);
-
-	if (index == QUAT_MI2S) {
-		ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_DISABLE);
-		if (ret_pinctrl)
-			pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
-				__func__, ret_pinctrl);
-	}
-}
-
-static struct snd_soc_ops msm_mi2s_be_ops = {
-	.startup = msm_mi2s_snd_startup,
-	.shutdown = msm_mi2s_snd_shutdown,
-};
-
-static struct snd_soc_ops msm_aux_pcm_be_ops = {
-	.startup = msm_aux_pcm_snd_startup,
-	.shutdown = msm_aux_pcm_snd_shutdown,
-};
-
-static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width,
-					    int slots)
-{
-	unsigned int slot_mask = 0;
-	int i, j;
-	unsigned int *slot_offset;
-
-	for (i = TDM_0; i < TDM_PORT_MAX; i++) {
-		slot_offset = tdm_slot_offset[i];
-
-		for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) {
-			if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-				slot_mask |=
-				(1 << ((slot_offset[j] * 8) / slot_width));
-			else
-				break;
-		}
-	}
-
-	return slot_mask;
-}
-
-static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
-				     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
-	int channels, slot_width, slots;
-	unsigned int slot_mask;
-	unsigned int *slot_offset;
-	int offset_channels = 0;
-	int i;
-
-	pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
-
-	channels = params_channels(params);
-	switch (channels) {
-	case 1:
-	case 2:
-	case 3:
-	case 4:
-	case 5:
-	case 6:
-	case 7:
-	case 8:
-		switch (params_format(params)) {
-		case SNDRV_PCM_FORMAT_S32_LE:
-		case SNDRV_PCM_FORMAT_S24_LE:
-		case SNDRV_PCM_FORMAT_S16_LE:
-		/*
-		 * Up to 8 channels HW config should
-		 * use 32 bit slot width for max support of
-		 * stream bit width. (slot_width > bit_width)
-		 */
-			slot_width = 32;
-			break;
-		default:
-			pr_err("%s: invalid param format 0x%x\n",
-				__func__, params_format(params));
-			return -EINVAL;
-		}
-		slots = 8;
-		slot_mask = tdm_param_set_slot_mask(cpu_dai->id,
-						    slot_width,
-						    slots);
-		if (!slot_mask) {
-			pr_err("%s: invalid slot_mask 0x%x\n",
-				__func__, slot_mask);
-			return -EINVAL;
-		}
-		break;
-	default:
-		pr_err("%s: invalid param channels %d\n",
-			__func__, channels);
-		return -EINVAL;
-	}
-	/* currently only supporting TDM_RX_0 and TDM_TX_0 */
-	switch (cpu_dai->id) {
-	case AFE_PORT_ID_PRIMARY_TDM_RX:
-	case AFE_PORT_ID_SECONDARY_TDM_RX:
-	case AFE_PORT_ID_TERTIARY_TDM_RX:
-	case AFE_PORT_ID_QUATERNARY_TDM_RX:
-	case AFE_PORT_ID_PRIMARY_TDM_TX:
-	case AFE_PORT_ID_SECONDARY_TDM_TX:
-	case AFE_PORT_ID_TERTIARY_TDM_TX:
-	case AFE_PORT_ID_QUATERNARY_TDM_TX:
-		slot_offset = tdm_slot_offset[TDM_0];
-		break;
-	default:
-		pr_err("%s: dai id 0x%x not supported\n",
-			__func__, cpu_dai->id);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
-		if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
-			offset_channels++;
-		else
-			break;
-	}
-
-	if (offset_channels == 0) {
-		pr_err("%s: slot offset not supported, offset_channels %d\n",
-			__func__, offset_channels);
-		return -EINVAL;
-	}
-
-	if (channels > offset_channels) {
-		pr_err("%s: channels %d exceed offset_channels %d\n",
-			__func__, channels, offset_channels);
-		return -EINVAL;
-	}
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
-						  channels, slot_offset);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	} else {
-		ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
-					       slots, slot_width);
-		if (ret < 0) {
-			pr_err("%s: failed to set tdm slot, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-
-		ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
-						  slot_offset, 0, NULL);
-		if (ret < 0) {
-			pr_err("%s: failed to set channel map, err:%d\n",
-				__func__, ret);
-			goto err;
-		}
-	}
-err:
-	return ret;
-}
-
-static struct snd_soc_ops msm_be_ops = {
-	.hw_params = msm_snd_hw_params,
-};
-
-static struct snd_soc_ops msm_slimbus_2_be_ops = {
-	.hw_params = msm_slimbus_2_hw_params,
-};
-
-static struct snd_soc_ops msm_wcn_ops = {
-	.hw_params = msm_wcn_hw_params,
-};
-
-static struct snd_soc_ops msm_tdm_be_ops = {
-	.hw_params = msm_tdm_snd_hw_params
-};
-
-/* Digital audio interface glue - connects codec <---> CPU */
-static struct snd_soc_dai_link msm_common_dai_links[] = {
-	/* FrontEnd DAI Links */
-	{
-		.name = MSM_DAILINK_NAME(Media1),
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name = "MultiMedia1",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-	{
-		.name = MSM_DAILINK_NAME(Media2),
-		.stream_name = "MultiMedia2",
-		.cpu_dai_name = "MultiMedia2",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA2,
-	},
-	{
-		.name = "VoiceMMode1",
-		.stream_name = "VoiceMMode1",
-		.cpu_dai_name = "VoiceMMode1",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE1,
-	},
-	{
-		.name = "MSM VoIP",
-		.stream_name = "VoIP",
-		.cpu_dai_name = "VoIP",
-		.platform_name = "msm-voip-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_VOIP,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL),
-		.stream_name = "MultiMedia3",
-		.cpu_dai_name = "MultiMedia3",
-		.platform_name = "msm-pcm-dsp.2",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA3,
-	},
-	/* Hostless PCM purpose */
-	{
-		.name = "SLIMBUS_0 Hostless",
-		.stream_name = "SLIMBUS_0 Hostless",
-		.cpu_dai_name = "SLIMBUS0_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "MSM AFE-PCM RX",
-		.stream_name = "AFE-PROXY RX",
-		.cpu_dai_name = "msm-dai-q6-dev.241",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.platform_name = "msm-pcm-afe",
-		.dpcm_playback = 1,
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = "MSM AFE-PCM TX",
-		.stream_name = "AFE-PROXY TX",
-		.cpu_dai_name = "msm-dai-q6-dev.240",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.platform_name  = "msm-pcm-afe",
-		.dpcm_capture = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress1),
-		.stream_name = "Compress1",
-		.cpu_dai_name = "MultiMedia4",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA4,
-	},
-	{
-		.name = "AUXPCM Hostless",
-		.stream_name = "AUXPCM Hostless",
-		.cpu_dai_name = "AUXPCM_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_1 Hostless",
-		.stream_name = "SLIMBUS_1 Hostless",
-		.cpu_dai_name = "SLIMBUS1_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_3 Hostless",
-		.stream_name = "SLIMBUS_3 Hostless",
-		.cpu_dai_name = "SLIMBUS3_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "SLIMBUS_4 Hostless",
-		.stream_name = "SLIMBUS_4 Hostless",
-		.cpu_dai_name = "SLIMBUS4_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		 /* this dailink has playback support */
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = MSM_DAILINK_NAME(LowLatency),
-		.stream_name = "MultiMedia5",
-		.cpu_dai_name = "MultiMedia5",
-		.platform_name = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA5,
-	},
-	{
-		.name = "Listen 1 Audio Service",
-		.stream_name = "Listen 1 Audio Service",
-		.cpu_dai_name = "LSM1",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-			     SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM1,
-	},
-	/* Multiple Tunnel instances */
-	{
-		.name = MSM_DAILINK_NAME(Compress2),
-		.stream_name = "Compress2",
-		.cpu_dai_name = "MultiMedia7",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA7,
-	},
-	{
-		.name = MSM_DAILINK_NAME(MultiMedia10),
-		.stream_name = "MultiMedia10",
-		.cpu_dai_name = "MultiMedia10",
-		.platform_name = "msm-pcm-dsp.1",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA10,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ),
-		.stream_name = "MM_NOIRQ",
-		.cpu_dai_name = "MultiMedia8",
-		.platform_name = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA8,
-	},
-	/* HDMI Hostless */
-	{
-		.name = "HDMI_RX_HOSTLESS",
-		.stream_name = "HDMI_RX_HOSTLESS",
-		.cpu_dai_name = "HDMI_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-	{
-		.name = "VoiceMMode2",
-		.stream_name = "VoiceMMode2",
-		.cpu_dai_name = "VoiceMMode2",
-		.platform_name = "msm-pcm-voice",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_VOICEMMODE2,
-	},
-	/* LSM FE */
-	{
-		.name = "Listen 2 Audio Service",
-		.stream_name = "Listen 2 Audio Service",
-		.cpu_dai_name = "LSM2",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM2,
-	},
-	{
-		.name = "Listen 3 Audio Service",
-		.stream_name = "Listen 3 Audio Service",
-		.cpu_dai_name = "LSM3",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM3,
-	},
-	{
-		.name = "Listen 4 Audio Service",
-		.stream_name = "Listen 4 Audio Service",
-		.cpu_dai_name = "LSM4",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM4,
-	},
-	{
-		.name = "Listen 5 Audio Service",
-		.stream_name = "Listen 5 Audio Service",
-		.cpu_dai_name = "LSM5",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM5,
-	},
-	{
-		.name = "Listen 6 Audio Service",
-		.stream_name = "Listen 6 Audio Service",
-		.cpu_dai_name = "LSM6",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM6,
-	},
-	{
-		.name = "Listen 7 Audio Service",
-		.stream_name = "Listen 7 Audio Service",
-		.cpu_dai_name = "LSM7",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM7,
-	},
-	{
-		.name = "Listen 8 Audio Service",
-		.stream_name = "Listen 8 Audio Service",
-		.cpu_dai_name = "LSM8",
-		.platform_name = "msm-lsm-client",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = { SND_SOC_DPCM_TRIGGER_POST,
-				 SND_SOC_DPCM_TRIGGER_POST },
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.id = MSM_FRONTEND_DAI_LSM8,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Media9),
-		.stream_name = "MultiMedia9",
-		.cpu_dai_name = "MultiMedia9",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-				SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA9,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress4),
-		.stream_name = "Compress4",
-		.cpu_dai_name = "MultiMedia11",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA11,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress5),
-		.stream_name = "Compress5",
-		.cpu_dai_name = "MultiMedia12",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA12,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress6),
-		.stream_name = "Compress6",
-		.cpu_dai_name = "MultiMedia13",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA13,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress7),
-		.stream_name = "Compress7",
-		.cpu_dai_name = "MultiMedia14",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA14,
-	},
-	{
-		.name = MSM_DAILINK_NAME(Compress8),
-		.stream_name = "Compress8",
-		.cpu_dai_name = "MultiMedia15",
-		.platform_name = "msm-compress-dsp",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA15,
-	},
-	{
-		.name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
-		.stream_name = "MM_NOIRQ_2",
-		.cpu_dai_name = "MultiMedia16",
-		.platform_name = "msm-pcm-dsp-noirq",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			 SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		 /* this dainlink has playback support */
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA16,
-	},
-	{
-		.name = "SLIMBUS_8 Hostless",
-		.stream_name = "SLIMBUS8_HOSTLESS Capture",
-		.cpu_dai_name = "SLIMBUS8_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-};
-
-static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_4_TX,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-	},
-	/* Ultrasound RX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Playback",
-		.stream_name = "SLIMBUS_2 Hostless Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-	/* Ultrasound TX DAI Link */
-	{
-		.name = "SLIMBUS_2 Hostless Capture",
-		.stream_name = "SLIMBUS_2 Hostless Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16389",
-		.platform_name = "msm-pcm-hostless",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx2",
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ops = &msm_slimbus_2_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
-	{
-		.name = MSM_DAILINK_NAME(ASM Loopback),
-		.stream_name = "MultiMedia6",
-		.cpu_dai_name = "MultiMedia6",
-		.platform_name = "msm-pcm-loopback",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.ignore_suspend = 1,
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA6,
-	},
-	{
-		.name = "USB Audio Hostless",
-		.stream_name = "USB Audio Hostless",
-		.cpu_dai_name = "USBAUDIO_HOSTLESS",
-		.platform_name = "msm-pcm-hostless",
-		.dynamic = 1,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			    SND_SOC_DPCM_TRIGGER_POST},
-		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-	},
-};
-
-static struct snd_soc_dai_link msm_common_be_dai_links[] = {
-	/* Backend AFE DAI Links */
-	{
-		.name = LPASS_BE_AFE_PCM_RX,
-		.stream_name = "AFE Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.224",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_AFE_PCM_TX,
-		.stream_name = "AFE Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.225",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AFE_PCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Uplink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_TX,
-		.stream_name = "Voice Uplink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32772",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Record Downlink BACK END DAI Link */
-	{
-		.name = LPASS_BE_INCALL_RECORD_RX,
-		.stream_name = "Voice Downlink Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.32771",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE_PLAYBACK_TX,
-		.stream_name = "Voice Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32773",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	/* Incall Music 2 BACK END DAI Link */
-	{
-		.name = LPASS_BE_VOICE2_PLAYBACK_TX,
-		.stream_name = "Voice2 Farend Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.32770",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_RX,
-		.stream_name = "USB Audio Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.28672",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_USB_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_USB_AUDIO_TX,
-		.stream_name = "USB Audio Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.28673",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_USB_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_RX_0,
-		.stream_name = "Primary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36864",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_TDM_TX_0,
-		.stream_name = "Primary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36865",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_RX_0,
-		.stream_name = "Secondary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36880",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_TDM_TX_0,
-		.stream_name = "Secondary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36881",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_RX_0,
-		.stream_name = "Tertiary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36896",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_TDM_TX_0,
-		.stream_name = "Tertiary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36897",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_RX_0,
-		.stream_name = "Quaternary TDM0 Playback",
-		.cpu_dai_name = "msm-dai-q6-tdm.36912",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
-		.be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
-		.ops = &sdm845_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_TDM_TX_0,
-		.stream_name = "Quaternary TDM0 Capture",
-		.cpu_dai_name = "msm-dai-q6-tdm.36913",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_tdm_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_init,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_RX,
-		.stream_name = "Slimbus1 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16386",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_1_TX,
-		.stream_name = "Slimbus1 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16387",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx3",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_2_RX,
-		.stream_name = "Slimbus2 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16388",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx2",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_RX,
-		.stream_name = "Slimbus3 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16390",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_3_TX,
-		.stream_name = "Slimbus3 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16391",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_tx1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_4_RX,
-		.stream_name = "Slimbus4 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16392",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx1",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_5_RX,
-		.stream_name = "Slimbus5 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16394",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx3",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* MAD BE */
-	{
-		.name = LPASS_BE_SLIMBUS_5_TX,
-		.stream_name = "Slimbus5 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16395",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_mad1",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_6_RX,
-		.stream_name = "Slimbus6 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16396",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_rx4",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	/* Slimbus VI Recording */
-	{
-		.name = LPASS_BE_SLIMBUS_TX_VI,
-		.stream_name = "Slimbus4 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16393",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "tavil_codec",
-		.codec_dai_name = "tavil_vifeedback",
-		.id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_be_ops,
-		.ignore_suspend = 1,
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.ignore_pmdown_time = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
-	{
-		.name = LPASS_BE_SLIMBUS_7_RX,
-		.stream_name = "Slimbus7 Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16398",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		/* BT codec driver determines capabilities based on
-		 * dai name, bt codecdai name should always contains
-		 * supported usecase information
-		 */
-		.codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		/* dai link has playback support */
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_7_TX,
-		.stream_name = "Slimbus7 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16399",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_bt_sco_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_8_TX,
-		.stream_name = "Slimbus8 Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16401",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "btfmslim_slave",
-		.codec_dai_name = "btfm_fm_slim_tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.init = &msm_wcn_init,
-		.ops = &msm_wcn_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
-	/* DISP PORT BACK END DAI Link */
-	{
-		.name = LPASS_BE_DISPLAY_PORT,
-		.stream_name = "Display Port Playback",
-		.cpu_dai_name = "msm-dai-q6-dp.24608",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-ext-disp-audio-codec-rx",
-		.codec_dai_name = "msm_dp_audio_codec_rx_dai",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
-	{
-		.name = LPASS_BE_PRI_MI2S_RX,
-		.stream_name = "Primary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_PRI_MI2S_TX,
-		.stream_name = "Primary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.0",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_PRI_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_RX,
-		.stream_name = "Secondary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_SEC_MI2S_TX,
-		.stream_name = "Secondary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_RX,
-		.stream_name = "Tertiary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_TERT_MI2S_TX,
-		.stream_name = "Tertiary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_RX,
-		.stream_name = "Quaternary MI2S Playback",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-	},
-	{
-		.name = LPASS_BE_QUAT_MI2S_TX,
-		.stream_name = "Quaternary MI2S Capture",
-		.cpu_dai_name = "msm-dai-q6-mi2s.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ops = &msm_mi2s_be_ops,
-		.ignore_suspend = 1,
-	},
-};
-
-static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
-	/* Primary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_AUXPCM_RX,
-		.stream_name = "AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_AUXPCM_TX,
-		.stream_name = "AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.1",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Secondary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_SEC_AUXPCM_RX,
-		.stream_name = "Sec AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_SEC_AUXPCM_TX,
-		.stream_name = "Sec AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.2",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Tertiary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_TERT_AUXPCM_RX,
-		.stream_name = "Tert AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_TERT_AUXPCM_TX,
-		.stream_name = "Tert AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.3",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	/* Quaternary AUX PCM Backend DAI Links */
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_RX,
-		.stream_name = "Quat AUX PCM Playback",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1,
-		.ignore_suspend = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-	{
-		.name = LPASS_BE_QUAT_AUXPCM_TX,
-		.stream_name = "Quat AUX PCM Capture",
-		.cpu_dai_name = "msm-dai-q6-auxpcm.4",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ignore_pmdown_time = 1,
-		.ops = &msm_aux_pcm_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_tavil_snd_card_dai_links[
-			 ARRAY_SIZE(msm_common_dai_links) +
-			 ARRAY_SIZE(msm_tavil_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_misc_fe_dai_links) +
-			 ARRAY_SIZE(msm_common_be_dai_links) +
-			 ARRAY_SIZE(msm_tavil_be_dai_links) +
-			 ARRAY_SIZE(msm_wcn_be_dai_links) +
-			 ARRAY_SIZE(ext_disp_be_dai_link) +
-			 ARRAY_SIZE(msm_mi2s_be_dai_links) +
-			 ARRAY_SIZE(msm_auxpcm_be_dai_links)];
-
-static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
-{
-	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
-	struct snd_soc_pcm_runtime *rtd;
-	int ret = 0;
-	void *mbhc_calibration;
-
-	rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
-	if (!rtd) {
-		dev_err(card->dev,
-			"%s: snd_soc_get_pcm_runtime for %s failed!\n",
-			__func__, be_dl_name);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	mbhc_calibration = def_tavil_mbhc_cal();
-	if (!mbhc_calibration) {
-		ret = -ENOMEM;
-		goto err;
-	}
-	wcd_mbhc_cfg.calibration = mbhc_calibration;
-	ret = tavil_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
-	if (ret) {
-		dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
-			__func__, ret);
-		goto err_free_mbhc_cal;
-	}
-	return 0;
-
-err_free_mbhc_cal:
-	kfree(mbhc_calibration);
-err:
-	return ret;
-}
-
-struct snd_soc_card snd_soc_card_tavil_msm = {
-	.name		= "sdm845-tavil-snd-card",
-	.late_probe	= msm_snd_card_tavil_late_probe,
-};
-
-static int msm_populate_dai_link_component_of_node(
-					struct snd_soc_card *card)
-{
-	int i, index, ret = 0;
-	struct device *cdev = card->dev;
-	struct snd_soc_dai_link *dai_link = card->dai_link;
-	struct device_node *np;
-
-	if (!cdev) {
-		pr_err("%s: Sound card device memory NULL\n", __func__);
-		return -ENODEV;
-	}
-
-	for (i = 0; i < card->num_links; i++) {
-		if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
-			continue;
-
-		/* populate platform_of_node for snd card dai links */
-		if (dai_link[i].platform_name &&
-		    !dai_link[i].platform_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						"asoc-platform-names",
-						dai_link[i].platform_name);
-			if (index < 0) {
-				pr_err("%s: No match found for platform name: %s\n",
-					__func__, dai_link[i].platform_name);
-				ret = index;
-				goto err;
-			}
-			np = of_parse_phandle(cdev->of_node, "asoc-platform",
-					      index);
-			if (!np) {
-				pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
-					__func__, dai_link[i].platform_name,
-					index);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].platform_of_node = np;
-			dai_link[i].platform_name = NULL;
-		}
-
-		/* populate cpu_of_node for snd card dai links */
-		if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						 "asoc-cpu-names",
-						 dai_link[i].cpu_dai_name);
-			if (index >= 0) {
-				np = of_parse_phandle(cdev->of_node, "asoc-cpu",
-						index);
-				if (!np) {
-					pr_err("%s: retrieving phandle for cpu dai %s failed\n",
-						__func__,
-						dai_link[i].cpu_dai_name);
-					ret = -ENODEV;
-					goto err;
-				}
-				dai_link[i].cpu_of_node = np;
-				dai_link[i].cpu_dai_name = NULL;
-			}
-		}
-
-		/* populate codec_of_node for snd card dai links */
-		if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
-			index = of_property_match_string(cdev->of_node,
-						 "asoc-codec-names",
-						 dai_link[i].codec_name);
-			if (index < 0)
-				continue;
-			np = of_parse_phandle(cdev->of_node, "asoc-codec",
-					      index);
-			if (!np) {
-				pr_err("%s: retrieving phandle for codec %s failed\n",
-					__func__, dai_link[i].codec_name);
-				ret = -ENODEV;
-				goto err;
-			}
-			dai_link[i].codec_of_node = np;
-			dai_link[i].codec_name = NULL;
-		}
-	}
-
-err:
-	return ret;
-}
-
-static int msm_prepare_us_euro(struct snd_soc_card *card)
-{
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-	int ret = 0;
-
-	if (pdata->us_euro_gpio >= 0) {
-		dev_dbg(card->dev, "%s: us_euro gpio request %d", __func__,
-			pdata->us_euro_gpio);
-		ret = gpio_request(pdata->us_euro_gpio, "TAVIL_CODEC_US_EURO");
-		if (ret) {
-			dev_err(card->dev,
-				"%s: Failed to request codec US/EURO gpio %d error %d\n",
-				__func__, pdata->us_euro_gpio, ret);
-		}
-	}
-
-	return ret;
-}
-
-static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
-	ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
-					 ARRAY_SIZE(msm_snd_controls));
-	if (ret < 0) {
-		dev_err(codec->dev,
-			"%s: add_codec_controls failed, err = %d\n",
-			__func__, ret);
-		return ret;
-	}
-
-	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
-				  ARRAY_SIZE(msm_dapm_widgets));
-
-	return 0;
-}
-
-static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-
-	int ret = 0;
-	unsigned int rx_ch[] = {144, 145, 146, 147, 148, 149, 150,
-				151};
-	unsigned int tx_ch[] = {128, 129, 130, 131, 132, 133,
-				134, 135, 136, 137, 138, 139,
-				140, 141, 142, 143};
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
-						  slim_rx_cfg[0].channels,
-						  rx_ch);
-		if (ret < 0)
-			pr_err("%s: RX failed to set cpu chan map error %d\n",
-				__func__, ret);
-	} else {
-		ret = snd_soc_dai_set_channel_map(cpu_dai,
-						  slim_tx_cfg[0].channels,
-						  tx_ch, 0, 0);
-		if (ret < 0)
-			pr_err("%s: TX failed to set cpu chan map error %d\n",
-				__func__, ret);
-	}
-
-	return ret;
-}
-
-static struct snd_soc_ops msm_stub_be_ops = {
-	.hw_params = msm_snd_stub_hw_params,
-};
-
-static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
-
-	/* FrontEnd DAI Links */
-	{
-		.name = "MSMSTUB Media1",
-		.stream_name = "MultiMedia1",
-		.cpu_dai_name = "MultiMedia1",
-		.platform_name = "msm-pcm-dsp.0",
-		.dynamic = 1,
-		.async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
-		.dpcm_playback = 1,
-		.dpcm_capture = 1,
-		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
-			SND_SOC_DPCM_TRIGGER_POST},
-		.codec_dai_name = "snd-soc-dummy-dai",
-		.codec_name = "snd-soc-dummy",
-		.ignore_suspend = 1,
-		/* this dainlink has playback support */
-		.ignore_pmdown_time = 1,
-		.id = MSM_FRONTEND_DAI_MULTIMEDIA1
-	},
-};
-
-static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
-
-	/* Backend DAI Links */
-	{
-		.name = LPASS_BE_SLIMBUS_0_RX,
-		.stream_name = "Slimbus Playback",
-		.cpu_dai_name = "msm-dai-q6-dev.16384",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-rx",
-		.no_pcm = 1,
-		.dpcm_playback = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
-		.init = &msm_audrx_stub_init,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_pmdown_time = 1, /* dai link has playback support */
-		.ignore_suspend = 1,
-		.ops = &msm_stub_be_ops,
-	},
-	{
-		.name = LPASS_BE_SLIMBUS_0_TX,
-		.stream_name = "Slimbus Capture",
-		.cpu_dai_name = "msm-dai-q6-dev.16385",
-		.platform_name = "msm-pcm-routing",
-		.codec_name = "msm-stub-codec.1",
-		.codec_dai_name = "msm-stub-tx",
-		.no_pcm = 1,
-		.dpcm_capture = 1,
-		.id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
-		.ignore_suspend = 1,
-		.ops = &msm_stub_be_ops,
-	},
-};
-
-static struct snd_soc_dai_link msm_stub_dai_links[
-			 ARRAY_SIZE(msm_stub_fe_dai_links) +
-			 ARRAY_SIZE(msm_stub_be_dai_links)];
-
-struct snd_soc_card snd_soc_card_stub_msm = {
-	.name		= "sdm845-stub-snd-card",
-};
-
-static const struct of_device_id sdm845_asoc_machine_of_match[]  = {
-	{ .compatible = "qcom,sdm845-asoc-snd-tavil",
-	  .data = "tavil_codec"},
-	{ .compatible = "qcom,sdm845-asoc-snd-stub",
-	  .data = "stub_codec"},
-	{},
-};
-
-static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
-{
-	struct snd_soc_card *card = NULL;
-	struct snd_soc_dai_link *dailink;
-	int len_1, len_2, len_3, len_4;
-	int total_links;
-	const struct of_device_id *match;
-
-	match = of_match_node(sdm845_asoc_machine_of_match, dev->of_node);
-	if (!match) {
-		dev_err(dev, "%s: No DT match found for sound card\n",
-			__func__);
-		return NULL;
-	}
-
-	if (!strcmp(match->data, "tavil_codec")) {
-		card = &snd_soc_card_tavil_msm;
-		len_1 = ARRAY_SIZE(msm_common_dai_links);
-		len_2 = len_1 + ARRAY_SIZE(msm_tavil_fe_dai_links);
-		len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
-		len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
-		total_links = len_4 + ARRAY_SIZE(msm_tavil_be_dai_links);
-		memcpy(msm_tavil_snd_card_dai_links,
-		       msm_common_dai_links,
-		       sizeof(msm_common_dai_links));
-		memcpy(msm_tavil_snd_card_dai_links + len_1,
-		       msm_tavil_fe_dai_links,
-		       sizeof(msm_tavil_fe_dai_links));
-		memcpy(msm_tavil_snd_card_dai_links + len_2,
-		       msm_common_misc_fe_dai_links,
-		       sizeof(msm_common_misc_fe_dai_links));
-		memcpy(msm_tavil_snd_card_dai_links + len_3,
-		       msm_common_be_dai_links,
-		       sizeof(msm_common_be_dai_links));
-		memcpy(msm_tavil_snd_card_dai_links + len_4,
-		       msm_tavil_be_dai_links,
-		       sizeof(msm_tavil_be_dai_links));
-
-		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
-			dev_dbg(dev, "%s(): WCN BTFM support present\n",
-				__func__);
-			memcpy(msm_tavil_snd_card_dai_links + total_links,
-			       msm_wcn_be_dai_links,
-			       sizeof(msm_wcn_be_dai_links));
-			total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
-		}
-
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,ext-disp-audio-rx")) {
-			dev_dbg(dev, "%s(): ext disp audio support present\n",
-				__func__);
-			memcpy(msm_tavil_snd_card_dai_links + total_links,
-			       ext_disp_be_dai_link,
-			       sizeof(ext_disp_be_dai_link));
-			total_links += ARRAY_SIZE(ext_disp_be_dai_link);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,mi2s-audio-intf")) {
-			memcpy(msm_tavil_snd_card_dai_links + total_links,
-			       msm_mi2s_be_dai_links,
-			       sizeof(msm_mi2s_be_dai_links));
-			total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
-		}
-		if (of_property_read_bool(dev->of_node,
-					  "qcom,auxpcm-audio-intf")) {
-			memcpy(msm_tavil_snd_card_dai_links + total_links,
-			msm_auxpcm_be_dai_links,
-			sizeof(msm_auxpcm_be_dai_links));
-			total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
-		}
-		dailink = msm_tavil_snd_card_dai_links;
-	} else if (!strcmp(match->data, "stub_codec")) {
-		card = &snd_soc_card_stub_msm;
-		len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
-		len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
-
-		memcpy(msm_stub_dai_links,
-		       msm_stub_fe_dai_links,
-		       sizeof(msm_stub_fe_dai_links));
-		memcpy(msm_stub_dai_links + len_1,
-		       msm_stub_be_dai_links,
-		       sizeof(msm_stub_be_dai_links));
-
-		dailink = msm_stub_dai_links;
-		total_links = len_2;
-	}
-
-	if (card) {
-		card->dai_link = dailink;
-		card->num_links = total_links;
-	}
-
-	return card;
-}
-
-static int msm_wsa881x_init(struct snd_soc_component *component)
-{
-	u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
-	u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
-	unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
-	unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
-	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
-	struct msm_asoc_mach_data *pdata;
-	struct snd_soc_dapm_context *dapm;
-	int ret = 0;
-
-	if (!codec) {
-		pr_err("%s codec is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	dapm = snd_soc_codec_get_dapm(codec);
-
-	if (!strcmp(component->name_prefix, "SpkrLeft")) {
-		dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
-			__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkleft_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
-		}
-	} else if (!strcmp(component->name_prefix, "SpkrRight")) {
-		dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
-			__func__, codec->component.name);
-		wsa881x_set_channel_map(codec, &spkright_ports[0],
-				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
-				&ch_rate[0]);
-		if (dapm->component) {
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
-			snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
-		}
-	} else {
-		dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
-			codec->component.name);
-		ret = -EINVAL;
-		goto err;
-	}
-	pdata = snd_soc_card_get_drvdata(component->card);
-	if (pdata && pdata->codec_root)
-		wsa881x_codec_info_create_codec_entry(pdata->codec_root,
-						      codec);
-
-err:
-	return ret;
-}
-
-static int msm_init_wsa_dev(struct platform_device *pdev,
-				struct snd_soc_card *card)
-{
-	struct device_node *wsa_of_node;
-	u32 wsa_max_devs;
-	u32 wsa_dev_cnt;
-	int i;
-	struct msm_wsa881x_dev_info *wsa881x_dev_info;
-	const char *wsa_auxdev_name_prefix[1];
-	char *dev_name_str = NULL;
-	int found = 0;
-	int ret = 0;
-
-	/* Get maximum WSA device count for this platform */
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "qcom,wsa-max-devs", &wsa_max_devs);
-	if (ret) {
-		dev_info(&pdev->dev,
-			 "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
-			 __func__, pdev->dev.of_node->full_name, ret);
-		card->num_aux_devs = 0;
-		return 0;
-	}
-	if (wsa_max_devs == 0) {
-		dev_warn(&pdev->dev,
-			 "%s: Max WSA devices is 0 for this target?\n",
-			 __func__);
-		card->num_aux_devs = 0;
-		return 0;
-	}
-
-	/* Get count of WSA device phandles for this platform */
-	wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
-						 "qcom,wsa-devs", NULL);
-	if (wsa_dev_cnt == -ENOENT) {
-		dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
-			 __func__);
-		goto err;
-	} else if (wsa_dev_cnt <= 0) {
-		dev_err(&pdev->dev,
-			"%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
-			__func__, wsa_dev_cnt);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	/*
-	 * Expect total phandles count to be NOT less than maximum possible
-	 * WSA count. However, if it is less, then assign same value to
-	 * max count as well.
-	 */
-	if (wsa_dev_cnt < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
-			__func__, wsa_max_devs, wsa_dev_cnt);
-		wsa_max_devs = wsa_dev_cnt;
-	}
-
-	/* Make sure prefix string passed for each WSA device */
-	ret = of_property_count_strings(pdev->dev.of_node,
-					"qcom,wsa-aux-dev-prefix");
-	if (ret != wsa_dev_cnt) {
-		dev_err(&pdev->dev,
-			"%s: expecting %d wsa prefix. Defined only %d in DT\n",
-			__func__, wsa_dev_cnt, ret);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	/*
-	 * Alloc mem to store phandle and index info of WSA device, if already
-	 * registered with ALSA core
-	 */
-	wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
-					sizeof(struct msm_wsa881x_dev_info),
-					GFP_KERNEL);
-	if (!wsa881x_dev_info) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	/*
-	 * search and check whether all WSA devices are already
-	 * registered with ALSA core or not. If found a node, store
-	 * the node and the index in a local array of struct for later
-	 * use.
-	 */
-	for (i = 0; i < wsa_dev_cnt; i++) {
-		wsa_of_node = of_parse_phandle(pdev->dev.of_node,
-					    "qcom,wsa-devs", i);
-		if (unlikely(!wsa_of_node)) {
-			/* we should not be here */
-			dev_err(&pdev->dev,
-				"%s: wsa dev node is not present\n",
-				__func__);
-			ret = -EINVAL;
-			goto err_free_dev_info;
-		}
-		if (soc_find_component(wsa_of_node, NULL)) {
-			/* WSA device registered with ALSA core */
-			wsa881x_dev_info[found].of_node = wsa_of_node;
-			wsa881x_dev_info[found].index = i;
-			found++;
-			if (found == wsa_max_devs)
-				break;
-		}
-	}
-
-	if (found < wsa_max_devs) {
-		dev_dbg(&pdev->dev,
-			"%s: failed to find %d components. Found only %d\n",
-			__func__, wsa_max_devs, found);
-		return -EPROBE_DEFER;
-	}
-	dev_info(&pdev->dev,
-		"%s: found %d wsa881x devices registered with ALSA core\n",
-		__func__, found);
-
-	card->num_aux_devs = wsa_max_devs;
-	card->num_configs = wsa_max_devs;
-
-	/* Alloc array of AUX devs struct */
-	msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-				       sizeof(struct snd_soc_aux_dev),
-				       GFP_KERNEL);
-	if (!msm_aux_dev) {
-		ret = -ENOMEM;
-		goto err_free_dev_info;
-	}
-
-	/* Alloc array of codec conf struct */
-	msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
-					  sizeof(struct snd_soc_codec_conf),
-					  GFP_KERNEL);
-	if (!msm_codec_conf) {
-		ret = -ENOMEM;
-		goto err_free_aux_dev;
-	}
-
-	for (i = 0; i < card->num_aux_devs; i++) {
-		dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
-					    GFP_KERNEL);
-		if (!dev_name_str) {
-			ret = -ENOMEM;
-			goto err_free_cdc_conf;
-		}
-
-		ret = of_property_read_string_index(pdev->dev.of_node,
-						    "qcom,wsa-aux-dev-prefix",
-						    wsa881x_dev_info[i].index,
-						    wsa_auxdev_name_prefix);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"%s: failed to read wsa aux dev prefix, ret = %d\n",
-				__func__, ret);
-			ret = -EINVAL;
-			goto err_free_dev_name_str;
-		}
-
-		snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
-		msm_aux_dev[i].name = dev_name_str;
-		msm_aux_dev[i].codec_name = NULL;
-		msm_aux_dev[i].codec_of_node =
-					wsa881x_dev_info[i].of_node;
-		msm_aux_dev[i].init = msm_wsa881x_init;
-		msm_codec_conf[i].dev_name = NULL;
-		msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
-		msm_codec_conf[i].of_node =
-				wsa881x_dev_info[i].of_node;
-	}
-	card->codec_conf = msm_codec_conf;
-	card->aux_dev = msm_aux_dev;
-
-	return 0;
-
-err_free_dev_name_str:
-	devm_kfree(&pdev->dev, dev_name_str);
-err_free_cdc_conf:
-	devm_kfree(&pdev->dev, msm_codec_conf);
-err_free_aux_dev:
-	devm_kfree(&pdev->dev, msm_aux_dev);
-err_free_dev_info:
-	devm_kfree(&pdev->dev, wsa881x_dev_info);
-err:
-	return ret;
-}
-
-static void msm_i2s_auxpcm_init(struct platform_device *pdev)
-{
-	struct resource *muxsel;
-	int count;
-	u32 mi2s_master_slave[MI2S_MAX];
-	int ret;
-	char *str[PCM_I2S_SEL_MAX] = {
-		"lpaif_pri_mode_muxsel",
-		"lpaif_sec_mode_muxsel",
-		"lpaif_tert_mode_muxsel",
-		"lpaif_quat_mode_muxsel"
-	};
-
-	for (count = 0; count < MI2S_MAX; count++) {
-		mutex_init(&mi2s_intf_conf[count].lock);
-		mi2s_intf_conf[count].ref_cnt = 0;
-	}
-
-	for (count = 0; count < AUX_PCM_MAX; count++) {
-		mutex_init(&auxpcm_intf_conf[count].lock);
-		auxpcm_intf_conf[count].ref_cnt = 0;
-	}
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
-		mutex_init(&mi2s_auxpcm_conf[count].lock);
-		mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr = NULL;
-	}
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
-		muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						      str[count]);
-		if (muxsel) {
-			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr
-				= ioremap(muxsel->start, resource_size(muxsel));
-		}
-	}
-
-	ret = of_property_read_u32_array(pdev->dev.of_node,
-			"qcom,msm-mi2s-master",
-			mi2s_master_slave, MI2S_MAX);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
-			__func__);
-	} else {
-		for (count = 0; count < MI2S_MAX; count++) {
-			mi2s_intf_conf[count].msm_is_mi2s_master =
-				mi2s_master_slave[count];
-		}
-	}
-}
-
-static void msm_i2s_auxpcm_deinit(void)
-{
-	int count;
-
-	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
-		if (mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr !=
-		    NULL) {
-			iounmap(
-			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr);
-			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr = NULL;
-		}
-		mutex_destroy(&mi2s_auxpcm_conf[count].lock);
-	}
-
-	for (count = 0; count < AUX_PCM_MAX; count++) {
-		mutex_destroy(&auxpcm_intf_conf[count].lock);
-		auxpcm_intf_conf[count].ref_cnt = 0;
-	}
-
-	for (count = 0; count < MI2S_MAX; count++) {
-		mutex_destroy(&mi2s_intf_conf[count].lock);
-		mi2s_intf_conf[count].ref_cnt = 0;
-		mi2s_intf_conf[count].msm_is_mi2s_master = 0;
-	}
-}
-
-static int msm_asoc_machine_probe(struct platform_device *pdev)
-{
-	struct snd_soc_card *card;
-	struct msm_asoc_mach_data *pdata;
-	const char *mbhc_audio_jack_type = NULL;
-	char *mclk_freq_prop_name;
-	const struct of_device_id *match;
-	int ret;
-	const char *usb_c_dt = "qcom,msm-mbhc-usbc-audio-supported";
-
-	if (!pdev->dev.of_node) {
-		dev_err(&pdev->dev, "No platform supplied from device tree\n");
-		return -EINVAL;
-	}
-
-	pdata = devm_kzalloc(&pdev->dev,
-			sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
-
-	card = populate_snd_card_dailinks(&pdev->dev);
-	if (!card) {
-		dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
-		ret = -EINVAL;
-		goto err;
-	}
-	card->dev = &pdev->dev;
-	platform_set_drvdata(pdev, card);
-	snd_soc_card_set_drvdata(card, pdata);
-
-	ret = snd_soc_of_parse_card_name(card, "qcom,model");
-	if (ret) {
-		dev_err(&pdev->dev, "parse card name failed, err:%d\n",
-			ret);
-		goto err;
-	}
-
-	ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
-	if (ret) {
-		dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
-			ret);
-		goto err;
-	}
-
-	match = of_match_node(sdm845_asoc_machine_of_match,
-			pdev->dev.of_node);
-	if (!match) {
-		dev_err(&pdev->dev, "%s: no matched codec is found.\n",
-			__func__);
-		goto err;
-	}
-
-	mclk_freq_prop_name = "qcom,tavil-mclk-clk-freq";
-
-	ret = of_property_read_u32(pdev->dev.of_node,
-			mclk_freq_prop_name, &pdata->mclk_freq);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"Looking up %s property in node %s failed, err%d\n",
-			mclk_freq_prop_name,
-			pdev->dev.of_node->full_name, ret);
-		goto err;
-	}
-
-	if (pdata->mclk_freq != CODEC_EXT_CLK_RATE) {
-		dev_err(&pdev->dev, "unsupported mclk freq %u\n",
-			pdata->mclk_freq);
-		ret = -EINVAL;
-		goto err;
-	}
-
-	ret = msm_populate_dai_link_component_of_node(card);
-	if (ret) {
-		ret = -EPROBE_DEFER;
-		goto err;
-	}
-	ret = msm_init_wsa_dev(pdev, card);
-	if (ret)
-		goto err;
-
-	ret = devm_snd_soc_register_card(&pdev->dev, card);
-	if (ret == -EPROBE_DEFER) {
-		if (codec_reg_done)
-			ret = -EINVAL;
-		goto err;
-	} else if (ret) {
-		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
-			ret);
-		goto err;
-	}
-	dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
-	spdev = pdev;
-
-	ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (ret) {
-		dev_dbg(&pdev->dev, "%s: failed to add child nodes, ret=%d\n",
-			__func__, ret);
-	} else {
-		pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
-							"qcom,hph-en1-gpio", 0);
-		if (!pdata->hph_en1_gpio_p) {
-			dev_dbg(&pdev->dev, "property %s not detected in node %s",
-				"qcom,hph-en1-gpio",
-				pdev->dev.of_node->full_name);
-		}
-
-		pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
-							"qcom,hph-en0-gpio", 0);
-		if (!pdata->hph_en0_gpio_p) {
-			dev_dbg(&pdev->dev, "property %s not detected in node %s",
-				"qcom,hph-en0-gpio",
-				pdev->dev.of_node->full_name);
-		}
-	}
-
-	ret = of_property_read_string(pdev->dev.of_node,
-		"qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
-	if (ret) {
-		dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
-			"qcom,mbhc-audio-jack-type",
-			pdev->dev.of_node->full_name);
-		dev_dbg(&pdev->dev, "Jack type properties set to default");
-	} else {
-		if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = false;
-			dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
-		} else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = true;
-			dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
-		} else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
-			wcd_mbhc_cfg.enable_anc_mic_detect = true;
-			dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
-		} else {
-			wcd_mbhc_cfg.enable_anc_mic_detect = false;
-			dev_dbg(&pdev->dev, "Unknown value, set to default");
-		}
-	}
-	/*
-	 * Parse US-Euro gpio info from DT. Report no error if us-euro
-	 * entry is not found in DT file as some targets do not support
-	 * US-Euro detection
-	 */
-	pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
-				"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio))
-		pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
-					"qcom,us-euro-gpios", 0);
-	if (!gpio_is_valid(pdata->us_euro_gpio) && (!pdata->us_euro_gpio_p)) {
-		dev_dbg(&pdev->dev, "property %s not detected in node %s",
-			"qcom,us-euro-gpios", pdev->dev.of_node->full_name);
-	} else {
-		dev_dbg(&pdev->dev, "%s detected",
-			"qcom,us-euro-gpios");
-		wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
-	}
-
-	if (of_find_property(pdev->dev.of_node, usb_c_dt, NULL))
-		wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
-
-	ret = msm_prepare_us_euro(card);
-	if (ret)
-		dev_dbg(&pdev->dev, "msm_prepare_us_euro failed (%d)\n",
-			ret);
-
-	/* Parse pinctrl info from devicetree */
-	ret = msm_get_pinctrl(pdev);
-	if (!ret) {
-		pr_debug("%s: pinctrl parsing successful\n", __func__);
-	} else {
-		dev_dbg(&pdev->dev,
-			"%s: Parsing pinctrl failed with %d. Cannot use Ports\n",
-			__func__, ret);
-		ret = 0;
-	}
-
-	msm_i2s_auxpcm_init(pdev);
-
-	is_initial_boot = true;
-	ret = audio_notifier_register("sdm845", AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &service_nb);
-	if (ret < 0)
-		pr_err("%s: Audio notifier register failed ret = %d\n",
-			__func__, ret);
-
-	return 0;
-err:
-	msm_release_pinctrl(pdev);
-	devm_kfree(&pdev->dev, pdata);
-	return ret;
-}
-
-static int msm_asoc_machine_remove(struct platform_device *pdev)
-{
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct msm_asoc_mach_data *pdata =
-				snd_soc_card_get_drvdata(card);
-
-	if (pdata->us_euro_gpio > 0) {
-		gpio_free(pdata->us_euro_gpio);
-		pdata->us_euro_gpio = 0;
-	}
-	msm_i2s_auxpcm_deinit();
-
-	msm_release_pinctrl(pdev);
-	snd_soc_unregister_card(card);
-	audio_notifier_deregister("sdm845");
-	return 0;
-}
-
-static struct platform_driver sdm845_asoc_machine_driver = {
-	.driver = {
-		.name = DRV_NAME,
-		.owner = THIS_MODULE,
-		.pm = &snd_soc_pm_ops,
-		.of_match_table = sdm845_asoc_machine_of_match,
-	},
-	.probe = msm_asoc_machine_probe,
-	.remove = msm_asoc_machine_remove,
-};
-module_platform_driver(sdm845_asoc_machine_driver);
-
-MODULE_DESCRIPTION("ALSA SoC msm");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
-MODULE_DEVICE_TABLE(of, sdm845_asoc_machine_of_match);
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index be6290d..bd8f34a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -212,6 +212,7 @@
 			pr_debug("%s Don't close BE\n", __func__);
 			continue;
 		}
+
 		snd_soc_dapm_stream_event(be, dir, event);
 	}
 
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 70e1477..6bd424b 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -384,6 +384,9 @@
 	if (unlikely(atomic_read(&ep->chip->shutdown)))
 		goto exit_clear;
 
+	if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags)))
+		goto exit_clear;
+
 	if (usb_pipeout(ep->pipe)) {
 		retire_outbound_urb(ep, ctx);
 		/* can be stopped during retire callback */
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 9e7861a..6c3d62f 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -554,6 +554,8 @@
 
 	if (size < sizeof(scale))
 		return -ENOMEM;
+	if (cval->min_mute)
+		scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE;
 	scale[2] = cval->dBmin;
 	scale[3] = cval->dBmax;
 	if (copy_to_user(_tlv, scale, sizeof(scale)))
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 3417ef3..2b4b067 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -64,6 +64,7 @@
 	int cached;
 	int cache_val[MAX_CHANNELS];
 	u8 initialized;
+	u8 min_mute;
 	void *private_data;
 };
 
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 04991b0..5d2fc5f 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -1873,6 +1873,12 @@
 		if (unitid == 7 && cval->control == UAC_FU_VOLUME)
 			snd_dragonfly_quirk_db_scale(mixer, cval, kctl);
 		break;
+	/* lowest playback value is muted on C-Media devices */
+	case USB_ID(0x0d8c, 0x000c):
+	case USB_ID(0x0d8c, 0x0014):
+		if (strstr(kctl->id.name, "Playback"))
+			cval->min_mute = 1;
+		break;
 	}
 }
 
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 8279009..dd81574 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -39,6 +39,8 @@
 #define SUBSTREAM_FLAG_DATA_EP_STARTED	0
 #define SUBSTREAM_FLAG_SYNC_EP_STARTED	1
 
+#define MAX_SETALT_TIMEOUT_MS 1000
+
 /* return the estimated delay based on USB frame counters */
 snd_pcm_uframes_t snd_usb_pcm_delay(struct snd_usb_substream *subs,
 				    unsigned int rate)
@@ -508,7 +510,8 @@
 
 	/* close the old interface */
 	if (subs->interface >= 0 && subs->interface != fmt->iface) {
-		err = usb_set_interface(subs->dev, subs->interface, 0);
+		err = usb_set_interface_timeout(subs->dev, subs->interface, 0,
+			MAX_SETALT_TIMEOUT_MS);
 		if (err < 0) {
 			dev_err(&dev->dev,
 				"%d:%d: return to setting 0 failed (%d)\n",
@@ -527,7 +530,8 @@
 		if (err < 0)
 			return -EIO;
 
-		err = usb_set_interface(dev, fmt->iface, fmt->altsetting);
+		err = usb_set_interface_timeout(dev, fmt->iface,
+				fmt->altsetting, MAX_SETALT_TIMEOUT_MS);
 		if (err < 0) {
 			dev_err(&dev->dev,
 				"%d:%d: usb_set_interface failed (%d)\n",
@@ -574,7 +578,8 @@
 
 	if (!enable) {
 		if (subs->interface >= 0) {
-			usb_set_interface(subs->dev, subs->interface, 0);
+			usb_set_interface_timeout(subs->dev, subs->interface, 0,
+				MAX_SETALT_TIMEOUT_MS);
 			subs->altset_idx = 0;
 			subs->interface = -1;
 			subs->cur_audiofmt = NULL;
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index eb4b9f7..286efc3 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1142,6 +1142,7 @@
 	case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
 	case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
 	case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
+	case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
 	case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
 	case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
 	case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
@@ -1308,10 +1309,13 @@
 	    && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
 		mdelay(20);
 
-	/* Zoom R16/24 needs a tiny delay here, otherwise requests like
-	 * get/set frequency return as failed despite actually succeeding.
+	/* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
+	 * otherwise requests like get/set frequency return as failed despite
+	 * actually succeeding.
 	 */
-	if (chip->usb_id == USB_ID(0x1686, 0x00dd) &&
+	if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
+	     chip->usb_id == USB_ID(0x046d, 0x0a46) ||
+	     chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
 	    (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
 		mdelay(1);
 }
diff --git a/sound/usb/usb_audio_qmi_svc.c b/sound/usb/usb_audio_qmi_svc.c
index 801508c..ebc081f 100644
--- a/sound/usb/usb_audio_qmi_svc.c
+++ b/sound/usb/usb_audio_qmi_svc.c
@@ -45,8 +45,7 @@
 /*  event ring iova base address */
 #define IOVA_BASE 0x1000
 
-#define IOVA_DCBA_BASE 0x2000
-#define IOVA_XFER_RING_BASE (IOVA_DCBA_BASE + PAGE_SIZE * (SNDRV_CARDS + 1))
+#define IOVA_XFER_RING_BASE (IOVA_BASE + PAGE_SIZE * (SNDRV_CARDS + 1))
 #define IOVA_XFER_BUF_BASE (IOVA_XFER_RING_BASE + PAGE_SIZE * SNDRV_CARDS * 32)
 #define IOVA_XFER_RING_MAX (IOVA_XFER_BUF_BASE - PAGE_SIZE)
 #define IOVA_XFER_BUF_MAX (0xfffff000 - PAGE_SIZE)
@@ -83,8 +82,6 @@
 	unsigned int card_num;
 	atomic_t in_use;
 	struct kref kref;
-	unsigned long dcba_iova;
-	size_t dcba_size;
 	wait_queue_head_t disconnect_wq;
 
 	/* interface specific */
@@ -101,9 +98,6 @@
 	struct iommu_domain *domain;
 
 	/* list to keep track of available iova */
-	struct list_head dcba_list;
-	size_t dcba_iova_size;
-	unsigned long curr_dcba_iova;
 	struct list_head xfer_ring_list;
 	size_t xfer_ring_iova_size;
 	unsigned long curr_xfer_ring_iova;
@@ -150,7 +144,6 @@
 
 enum mem_type {
 	MEM_EVENT_RING,
-	MEM_DCBA,
 	MEM_XFER_RING,
 	MEM_XFER_BUF,
 };
@@ -176,6 +169,24 @@
 	USB_QMI_PCM_FORMAT_U32_BE,
 };
 
+static enum usb_audio_device_speed_enum_v01
+get_speed_info(enum usb_device_speed udev_speed)
+{
+	switch (udev_speed) {
+	case USB_SPEED_LOW:
+		return USB_AUDIO_DEVICE_SPEED_LOW_V01;
+	case USB_SPEED_FULL:
+		return USB_AUDIO_DEVICE_SPEED_FULL_V01;
+	case USB_SPEED_HIGH:
+		return USB_AUDIO_DEVICE_SPEED_HIGH_V01;
+	case USB_SPEED_SUPER:
+		return USB_AUDIO_DEVICE_SPEED_SUPER_V01;
+	default:
+		pr_err("%s: udev speed %d\n", __func__, udev_speed);
+		return USB_AUDIO_DEVICE_SPEED_INVALID_V01;
+	}
+}
+
 static unsigned long uaudio_get_iova(unsigned long *curr_iova,
 	size_t *curr_iova_size, struct list_head *head, size_t size)
 {
@@ -275,10 +286,6 @@
 		if (uaudio_qdev->er_phys_addr == pa)
 			map = false;
 		break;
-	case MEM_DCBA:
-		va = uaudio_get_iova(&uaudio_qdev->curr_dcba_iova,
-		&uaudio_qdev->dcba_iova_size, &uaudio_qdev->dcba_list, size);
-		break;
 	case MEM_XFER_RING:
 		va = uaudio_get_iova(&uaudio_qdev->curr_xfer_ring_iova,
 		&uaudio_qdev->xfer_ring_iova_size, &uaudio_qdev->xfer_ring_list,
@@ -363,10 +370,7 @@
 		else
 			unmap = false;
 		break;
-	case MEM_DCBA:
-		uaudio_put_iova(va, size, &uaudio_qdev->dcba_list,
-		&uaudio_qdev->dcba_iova_size);
-		break;
+
 	case MEM_XFER_RING:
 		uaudio_put_iova(va, size, &uaudio_qdev->xfer_ring_list,
 		&uaudio_qdev->xfer_ring_iova_size);
@@ -407,10 +411,12 @@
 	int protocol, card_num, pcm_dev_num;
 	void *hdr_ptr;
 	u8 *xfer_buf;
-	u32 len, mult, remainder, xfer_buf_len;
-	unsigned long va, tr_data_va = 0, tr_sync_va = 0, dcba_va = 0,
-	xfer_buf_va = 0;
-	phys_addr_t xhci_pa, xfer_buf_pa;
+	u32 len, mult, remainder, xfer_buf_len, sg_len, i, total_len = 0;
+	unsigned long va, va_sg, tr_data_va = 0, tr_sync_va = 0;
+	phys_addr_t xhci_pa, xfer_buf_pa, tr_data_pa = 0, tr_sync_pa = 0;
+	dma_addr_t dma;
+	struct sg_table sgt;
+	struct scatterlist *sg;
 
 	iface = usb_ifnum_to_if(subs->dev, subs->interface);
 	if (!iface) {
@@ -524,13 +530,13 @@
 	memcpy(&resp->std_as_data_ep_desc, &ep->desc, sizeof(ep->desc));
 	resp->std_as_data_ep_desc_valid = 1;
 
-	xhci_pa = usb_get_xfer_ring_dma_addr(subs->dev, ep);
-	if (!xhci_pa) {
+	tr_data_pa = usb_get_xfer_ring_phys_addr(subs->dev, ep, &dma);
+	if (!tr_data_pa) {
 		pr_err("%s:failed to get data ep ring dma address\n", __func__);
 		goto err;
 	}
 
-	resp->xhci_mem_info.tr_data.pa = xhci_pa;
+	resp->xhci_mem_info.tr_data.pa = dma;
 
 	if (subs->sync_endpoint) {
 		ep = usb_pipe_endpoint(subs->dev, subs->sync_endpoint->pipe);
@@ -541,19 +547,26 @@
 		memcpy(&resp->std_as_sync_ep_desc, &ep->desc, sizeof(ep->desc));
 		resp->std_as_sync_ep_desc_valid = 1;
 
-		xhci_pa = usb_get_xfer_ring_dma_addr(subs->dev, ep);
-		if (!xhci_pa) {
+		tr_sync_pa = usb_get_xfer_ring_phys_addr(subs->dev, ep, &dma);
+		if (!tr_sync_pa) {
 			pr_err("%s:failed to get sync ep ring dma address\n",
 				__func__);
 			goto err;
 		}
-		resp->xhci_mem_info.tr_sync.pa = xhci_pa;
+		resp->xhci_mem_info.tr_sync.pa = dma;
 	}
 
 skip_sync_ep:
 	resp->interrupter_num = uaudio_qdev->intr_num;
 	resp->interrupter_num_valid = 1;
 
+	ret = usb_get_controller_id(subs->dev);
+	if (ret < 0)
+		goto err;
+
+	resp->controller_num =  ret;
+	resp->controller_num_valid = 1;
+
 	/*  map xhci data structures PA memory to iova */
 
 	/* event ring */
@@ -563,8 +576,8 @@
 			ret);
 		goto err;
 	}
-	xhci_pa = usb_get_sec_event_ring_dma_addr(subs->dev,
-			resp->interrupter_num);
+	xhci_pa = usb_get_sec_event_ring_phys_addr(subs->dev,
+			resp->interrupter_num, &dma);
 	if (!xhci_pa) {
 		pr_err("%s: failed to get sec event ring dma address\n",
 		__func__);
@@ -577,37 +590,20 @@
 
 	resp->xhci_mem_info.evt_ring.va = PREPEND_SID_TO_IOVA(va,
 						uaudio_qdev->sid);
-	resp->xhci_mem_info.evt_ring.pa = xhci_pa;
+	resp->xhci_mem_info.evt_ring.pa = dma;
 	resp->xhci_mem_info.evt_ring.size = PAGE_SIZE;
 	uaudio_qdev->er_phys_addr = xhci_pa;
 
-	/* dcba */
-	xhci_pa = usb_get_dcba_dma_addr(subs->dev);
-	if (!xhci_pa) {
-		pr_err("%s:failed to get dcba dma address\n", __func__);
+	resp->speed_info = get_speed_info(subs->dev->speed);
+	if (resp->speed_info == USB_AUDIO_DEVICE_SPEED_INVALID_V01)
 		goto unmap_er;
-	}
 
-	if (!uadev[card_num].dcba_iova) { /* mappped per usb device */
-		va = uaudio_iommu_map(MEM_DCBA, xhci_pa, PAGE_SIZE);
-		if (!va)
-			goto unmap_er;
-
-		uadev[card_num].dcba_iova = va;
-		uadev[card_num].dcba_size = PAGE_SIZE;
-	}
-
-	dcba_va = uadev[card_num].dcba_iova;
-	resp->xhci_mem_info.dcba.va = PREPEND_SID_TO_IOVA(dcba_va,
-						uaudio_qdev->sid);
-	resp->xhci_mem_info.dcba.pa = xhci_pa;
-	resp->xhci_mem_info.dcba.size = PAGE_SIZE;
+	resp->speed_info_valid = 1;
 
 	/* data transfer ring */
-	xhci_pa = resp->xhci_mem_info.tr_data.pa;
-	va = uaudio_iommu_map(MEM_XFER_RING, xhci_pa, PAGE_SIZE);
+	va = uaudio_iommu_map(MEM_XFER_RING, tr_data_pa, PAGE_SIZE);
 	if (!va)
-		goto unmap_dcba;
+		goto unmap_er;
 
 	tr_data_va = va;
 	resp->xhci_mem_info.tr_data.va = PREPEND_SID_TO_IOVA(va,
@@ -619,7 +615,7 @@
 		goto skip_sync;
 
 	xhci_pa = resp->xhci_mem_info.tr_sync.pa;
-	va = uaudio_iommu_map(MEM_XFER_RING, xhci_pa, PAGE_SIZE);
+	va = uaudio_iommu_map(MEM_XFER_RING, tr_sync_pa, PAGE_SIZE);
 	if (!va)
 		goto unmap_data;
 
@@ -648,19 +644,33 @@
 	if (!xfer_buf)
 		goto unmap_sync;
 
+	dma_get_sgtable(subs->dev->bus->sysdev, &sgt, xfer_buf, xfer_buf_pa,
+			len);
+
+	va = 0;
+	for_each_sg(sgt.sgl, sg, sgt.nents, i) {
+		sg_len = PAGE_ALIGN(sg->offset + sg->length);
+		va_sg = uaudio_iommu_map(MEM_XFER_BUF,
+			page_to_phys(sg_page(sg)), sg_len);
+		if (!va_sg)
+			goto unmap_xfer_buf;
+
+		if (!va)
+			va = va_sg;
+
+		total_len += sg_len;
+	}
+
 	resp->xhci_mem_info.xfer_buff.pa = xfer_buf_pa;
 	resp->xhci_mem_info.xfer_buff.size = len;
 
-	va = uaudio_iommu_map(MEM_XFER_BUF, xfer_buf_pa, len);
-	if (!va)
-		goto unmap_sync;
-
-	xfer_buf_va = va;
 	resp->xhci_mem_info.xfer_buff.va = PREPEND_SID_TO_IOVA(va,
 						uaudio_qdev->sid);
 
 	resp->xhci_mem_info_valid = 1;
 
+	sg_free_table(&sgt);
+
 	if (!atomic_read(&uadev[card_num].in_use)) {
 		kref_init(&uadev[card_num].kref);
 		init_waitqueue_head(&uadev[card_num].disconnect_wq);
@@ -686,7 +696,7 @@
 	uadev[card_num].info[info_idx].data_xfer_ring_size = PAGE_SIZE;
 	uadev[card_num].info[info_idx].sync_xfer_ring_va = tr_sync_va;
 	uadev[card_num].info[info_idx].sync_xfer_ring_size = PAGE_SIZE;
-	uadev[card_num].info[info_idx].xfer_buf_va = xfer_buf_va;
+	uadev[card_num].info[info_idx].xfer_buf_va = va;
 	uadev[card_num].info[info_idx].xfer_buf_pa = xfer_buf_pa;
 	uadev[card_num].info[info_idx].xfer_buf_size = len;
 	uadev[card_num].info[info_idx].xfer_buf = xfer_buf;
@@ -701,14 +711,13 @@
 	return 0;
 
 unmap_xfer_buf:
-	uaudio_iommu_unmap(MEM_XFER_BUF, xfer_buf_va, len);
+	if (va)
+		uaudio_iommu_unmap(MEM_XFER_BUF, va, total_len);
 unmap_sync:
 	usb_free_coherent(subs->dev, len, xfer_buf, xfer_buf_pa);
 	uaudio_iommu_unmap(MEM_XFER_RING, tr_sync_va, PAGE_SIZE);
 unmap_data:
 	uaudio_iommu_unmap(MEM_XFER_RING, tr_data_va, PAGE_SIZE);
-unmap_dcba:
-	uaudio_iommu_unmap(MEM_DCBA, dcba_va, PAGE_SIZE);
 unmap_er:
 	uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE);
 err:
@@ -754,11 +763,6 @@
 			dev->info[if_idx].intf_num, dev->card_num);
 	}
 
-	/* iommu_unmap dcba iova for a usb device */
-	uaudio_iommu_unmap(MEM_DCBA, dev->dcba_iova, dev->dcba_size);
-
-	dev->dcba_iova = 0;
-	dev->dcba_size = 0;
 	dev->num_intf = 0;
 
 	/* free interface info */
@@ -1228,11 +1232,7 @@
 		goto free_domain;
 	}
 
-	/* initialize dcba, xfer ring and xfer buf iova list */
-	INIT_LIST_HEAD(&uaudio_qdev->dcba_list);
-	uaudio_qdev->curr_dcba_iova = IOVA_DCBA_BASE;
-	uaudio_qdev->dcba_iova_size = SNDRV_CARDS * PAGE_SIZE;
-
+	/* initialize xfer ring and xfer buf iova list */
 	INIT_LIST_HEAD(&uaudio_qdev->xfer_ring_list);
 	uaudio_qdev->curr_xfer_ring_iova = IOVA_XFER_RING_BASE;
 	uaudio_qdev->xfer_ring_iova_size =
diff --git a/sound/usb/usb_audio_qmi_v01.c b/sound/usb/usb_audio_qmi_v01.c
index fef7505..a93665c 100644
--- a/sound/usb/usb_audio_qmi_v01.c
+++ b/sound/usb/usb_audio_qmi_v01.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ /* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -633,6 +633,46 @@
 					interrupter_num),
 	},
 	{
+		.data_type      = QMI_OPT_FLAG,
+		.elem_len       = 1,
+		.elem_size      = sizeof(uint8_t),
+		.is_array       = NO_ARRAY,
+		.tlv_type       = 0x1C,
+		.offset         = offsetof(
+					struct qmi_uaudio_stream_resp_msg_v01,
+					speed_info_valid),
+	},
+	{
+		.data_type      = QMI_SIGNED_4_BYTE_ENUM,
+		.elem_len       = 1,
+		.elem_size      = sizeof(enum usb_audio_device_speed_enum_v01),
+		.is_array       = NO_ARRAY,
+		.tlv_type       = 0x1C,
+		.offset         = offsetof(
+					struct qmi_uaudio_stream_resp_msg_v01,
+					speed_info),
+	},
+	{
+		.data_type      = QMI_OPT_FLAG,
+		.elem_len       = 1,
+		.elem_size      = sizeof(uint8_t),
+		.is_array       = NO_ARRAY,
+		.tlv_type       = 0x1D,
+		.offset         = offsetof(
+					struct qmi_uaudio_stream_resp_msg_v01,
+					controller_num_valid),
+	},
+	{
+		.data_type      = QMI_UNSIGNED_1_BYTE,
+		.elem_len       = 1,
+		.elem_size      = sizeof(uint8_t),
+		.is_array       = NO_ARRAY,
+		.tlv_type       = 0x1D,
+		.offset         = offsetof(
+					struct qmi_uaudio_stream_resp_msg_v01,
+					controller_num),
+	},
+	{
 		.data_type      = QMI_EOTI,
 		.is_array       = NO_ARRAY,
 		.is_array       = QMI_COMMON_TLV_TYPE,
diff --git a/sound/usb/usb_audio_qmi_v01.h b/sound/usb/usb_audio_qmi_v01.h
index 83a966c..9900764 100644
--- a/sound/usb/usb_audio_qmi_v01.h
+++ b/sound/usb/usb_audio_qmi_v01.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ /* Copyright (c) 2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -77,6 +77,16 @@
 	USB_AUDIO_DEVICE_INDICATION_ENUM_MAX_VAL_V01 = INT_MAX,
 };
 
+enum usb_audio_device_speed_enum_v01 {
+	USB_AUDIO_DEVICE_SPEED_ENUM_MIN_VAL_V01 = INT_MIN,
+	USB_AUDIO_DEVICE_SPEED_INVALID_V01 = 0,
+	USB_AUDIO_DEVICE_SPEED_LOW_V01 = 1,
+	USB_AUDIO_DEVICE_SPEED_FULL_V01 = 2,
+	USB_AUDIO_DEVICE_SPEED_HIGH_V01 = 3,
+	USB_AUDIO_DEVICE_SPEED_SUPER_V01 = 4,
+	USB_AUDIO_DEVICE_SPEED_ENUM_MAX_VAL_V01 = INT_MAX,
+};
+
 struct qmi_uaudio_stream_req_msg_v01 {
 	uint8_t enable;
 	uint32_t usb_token;
@@ -118,8 +128,12 @@
 	struct apps_mem_info_v01 xhci_mem_info;
 	uint8_t interrupter_num_valid;
 	uint8_t interrupter_num;
+	uint8_t speed_info_valid;
+	enum usb_audio_device_speed_enum_v01 speed_info;
+	uint8_t controller_num_valid;
+	uint8_t controller_num;
 };
-#define QMI_UAUDIO_STREAM_RESP_MSG_V01_MAX_MSG_LEN 191
+#define QMI_UAUDIO_STREAM_RESP_MSG_V01_MAX_MSG_LEN 202
 extern struct elem_info qmi_uaudio_stream_resp_msg_v01_ei[];
 
 struct qmi_uaudio_stream_ind_msg_v01 {
diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
index f1ce600..ec30c2f 100644
--- a/tools/lib/traceevent/plugin_sched_switch.c
+++ b/tools/lib/traceevent/plugin_sched_switch.c
@@ -111,7 +111,7 @@
 	trace_seq_printf(s, "%lld ", val);
 
 	if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
-		trace_seq_printf(s, "[%lld] ", val);
+		trace_seq_printf(s, "[%d] ", (int) val);
 
 	if (pevent_get_field_val(s,  event, "prev_state", record, &val, 0) == 0)
 		write_state(s, val);
@@ -129,7 +129,7 @@
 	trace_seq_printf(s, "%lld", val);
 
 	if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
-		trace_seq_printf(s, " [%lld]", val);
+		trace_seq_printf(s, " [%d]", (int) val);
 
 	return 0;
 }
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 982d643..ef52d1e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -729,9 +729,9 @@
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
 		$(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
 
-install-bin: install-tools install-tests
+install-bin: install-tools install-tests install-traceevent-plugins
 
-install: install-bin try-install-man install-traceevent-plugins
+install: install-bin try-install-man
 
 install-python_ext:
 	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7ea13f4..6a6f44d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -163,7 +163,7 @@
 
 	/* A file path -- this is an offline module */
 	if (module && strchr(module, '/'))
-		return machine__findnew_module_map(host_machine, 0, module);
+		return dso__new_map(module);
 
 	if (!module)
 		module = "kernel";
@@ -173,6 +173,7 @@
 		if (strncmp(pos->dso->short_name + 1, module,
 			    pos->dso->short_name_len - 2) == 0 &&
 		    module[pos->dso->short_name_len - 2] == '\0') {
+			map__get(pos);
 			return pos;
 		}
 	}
@@ -188,15 +189,6 @@
 		return kernel_get_module_map(target);
 }
 
-static void put_target_map(struct map *map, bool user)
-{
-	if (map && user) {
-		/* Only the user map needs to be released */
-		map__put(map);
-	}
-}
-
-
 static int convert_exec_to_group(const char *exec, char **result)
 {
 	char *ptr1, *ptr2, *exec_copy;
@@ -268,21 +260,6 @@
 }
 
 /*
- * NOTE:
- * '.gnu.linkonce.this_module' section of kernel module elf directly
- * maps to 'struct module' from linux/module.h. This section contains
- * actual module name which will be used by kernel after loading it.
- * But, we cannot use 'struct module' here since linux/module.h is not
- * exposed to user-space. Offset of 'name' has remained same from long
- * time, so hardcoding it here.
- */
-#ifdef __LP64__
-#define MOD_NAME_OFFSET 24
-#else
-#define MOD_NAME_OFFSET 12
-#endif
-
-/*
  * @module can be module name of module file path. In case of path,
  * inspect elf and find out what is actual module name.
  * Caller has to free mod_name after using it.
@@ -296,6 +273,7 @@
 	Elf_Data *data;
 	Elf_Scn *sec;
 	char *mod_name = NULL;
+	int name_offset;
 
 	fd = open(module, O_RDONLY);
 	if (fd < 0)
@@ -317,7 +295,21 @@
 	if (!data || !data->d_buf)
 		goto ret_err;
 
-	mod_name = strdup((char *)data->d_buf + MOD_NAME_OFFSET);
+	/*
+	 * NOTE:
+	 * '.gnu.linkonce.this_module' section of kernel module elf directly
+	 * maps to 'struct module' from linux/module.h. This section contains
+	 * actual module name which will be used by kernel after loading it.
+	 * But, we cannot use 'struct module' here since linux/module.h is not
+	 * exposed to user-space. Offset of 'name' has remained same from long
+	 * time, so hardcoding it here.
+	 */
+	if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
+		name_offset = 12;
+	else	/* expect ELFCLASS64 by default */
+		name_offset = 24;
+
+	mod_name = strdup((char *)data->d_buf + name_offset);
 
 ret_err:
 	elf_end(elf);
@@ -412,7 +404,7 @@
 	}
 
 out:
-	put_target_map(map, uprobes);
+	map__put(map);
 	return ret;
 
 }
@@ -2944,7 +2936,7 @@
 	}
 
 out:
-	put_target_map(map, pev->uprobes);
+	map__put(map);
 	free(syms);
 	return ret;
 
@@ -3437,10 +3429,7 @@
 		return ret;
 
 	/* Get a symbol map */
-	if (user)
-		map = dso__new_map(target);
-	else
-		map = kernel_get_module_map(target);
+	map = get_target_map(target, user);
 	if (!map) {
 		pr_err("Failed to get a map for %s\n", (target) ? : "kernel");
 		return -EINVAL;
@@ -3472,9 +3461,7 @@
         }
 
 end:
-	if (user) {
-		map__put(map);
-	}
+	map__put(map);
 	exit_probe_symbol_maps();
 
 	return ret;
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 99400b0..adbc6c0 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -537,6 +537,12 @@
 				break;
 		} else {
 			int n = namesz + descsz;
+
+			if (n > (int)sizeof(bf)) {
+				n = sizeof(bf);
+				pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
+					 __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
+			}
 			if (read(fd, bf, n) != n)
 				break;
 		}
diff --git a/tools/testing/selftests/ntb/ntb_test.sh b/tools/testing/selftests/ntb/ntb_test.sh
index a676d3e..b3c48fc 100755
--- a/tools/testing/selftests/ntb/ntb_test.sh
+++ b/tools/testing/selftests/ntb/ntb_test.sh
@@ -305,7 +305,7 @@
 	echo "Running remote perf test $WITH DMA"
 	write_file "" $REMOTE_PERF/run
 	echo -n "  "
-	read_file $LOCAL_PERF/run
+	read_file $REMOTE_PERF/run
 	echo "  Passed"
 
 	_modprobe -r ntb_perf
@@ -326,6 +326,10 @@
 	link_test $LOCAL_TOOL $REMOTE_TOOL
 	link_test $REMOTE_TOOL $LOCAL_TOOL
 
+	#Ensure the link is up on both sides before continuing
+	write_file Y $LOCAL_TOOL/link_event
+	write_file Y $REMOTE_TOOL/link_event
+
 	for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do
 		PT=$(basename $PEER_TRANS)
 		write_file $MW_SIZE $LOCAL_TOOL/$PT
diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c
index 5b2b4b3..9b4610c 100644
--- a/tools/testing/selftests/x86/fsgsbase.c
+++ b/tools/testing/selftests/x86/fsgsbase.c
@@ -285,9 +285,12 @@
 	}
 }
 
-static void set_gs_and_switch_to(unsigned long local, unsigned long remote)
+static void set_gs_and_switch_to(unsigned long local,
+				 unsigned short force_sel,
+				 unsigned long remote)
 {
 	unsigned long base;
+	unsigned short sel_pre_sched, sel_post_sched;
 
 	bool hard_zero = false;
 	if (local == HARD_ZERO) {
@@ -297,6 +300,8 @@
 
 	printf("[RUN]\tARCH_SET_GS(0x%lx)%s, then schedule to 0x%lx\n",
 	       local, hard_zero ? " and clear gs" : "", remote);
+	if (force_sel)
+		printf("\tBefore schedule, set selector to 0x%hx\n", force_sel);
 	if (syscall(SYS_arch_prctl, ARCH_SET_GS, local) != 0)
 		err(1, "ARCH_SET_GS");
 	if (hard_zero)
@@ -307,18 +312,35 @@
 		printf("[FAIL]\tGSBASE wasn't set as expected\n");
 	}
 
+	if (force_sel) {
+		asm volatile ("mov %0, %%gs" : : "rm" (force_sel));
+		sel_pre_sched = force_sel;
+		local = read_base(GS);
+
+		/*
+		 * Signal delivery seems to mess up weird selectors.  Put it
+		 * back.
+		 */
+		asm volatile ("mov %0, %%gs" : : "rm" (force_sel));
+	} else {
+		asm volatile ("mov %%gs, %0" : "=rm" (sel_pre_sched));
+	}
+
 	remote_base = remote;
 	ftx = 1;
 	syscall(SYS_futex, &ftx, FUTEX_WAKE, 0, NULL, NULL, 0);
 	while (ftx != 0)
 		syscall(SYS_futex, &ftx, FUTEX_WAIT, 1, NULL, NULL, 0);
 
+	asm volatile ("mov %%gs, %0" : "=rm" (sel_post_sched));
 	base = read_base(GS);
-	if (base == local) {
-		printf("[OK]\tGSBASE remained 0x%lx\n", local);
+	if (base == local && sel_pre_sched == sel_post_sched) {
+		printf("[OK]\tGS/BASE remained 0x%hx/0x%lx\n",
+		       sel_pre_sched, local);
 	} else {
 		nerrs++;
-		printf("[FAIL]\tGSBASE changed to 0x%lx\n", base);
+		printf("[FAIL]\tGS/BASE changed from 0x%hx/0x%lx to 0x%hx/0x%lx\n",
+		       sel_pre_sched, local, sel_post_sched, base);
 	}
 }
 
@@ -381,8 +403,15 @@
 
 	for (int local = 0; local < 4; local++) {
 		for (int remote = 0; remote < 4; remote++) {
-			set_gs_and_switch_to(bases_with_hard_zero[local],
-					     bases_with_hard_zero[remote]);
+			for (unsigned short s = 0; s < 5; s++) {
+				unsigned short sel = s;
+				if (s == 4)
+					asm ("mov %%ss, %0" : "=rm" (sel));
+				set_gs_and_switch_to(
+					bases_with_hard_zero[local],
+					sel,
+					bases_with_hard_zero[remote]);
+			}
 		}
 	}